summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/acpica/acglobal.h3
-rw-r--r--drivers/acpi/acpica/dsobject.c5
-rw-r--r--drivers/acpi/acpica/dsopcode.c17
-rw-r--r--drivers/acpi/acpica/dswstate.c4
-rw-r--r--drivers/acpi/acpica/evxfevnt.c4
-rw-r--r--drivers/acpi/acpica/exmutex.c9
-rw-r--r--drivers/acpi/acpica/hwregs.c4
-rw-r--r--drivers/acpi/acpica/nsnames.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c7
-rw-r--r--drivers/acpi/acpica/nssearch.c4
-rw-r--r--drivers/acpi/acpica/rscalc.c3
-rw-r--r--drivers/acpi/acpica/rsxface.c8
-rw-r--r--drivers/acpi/acpica/tbfadt.c16
-rw-r--r--drivers/acpi/acpica/tbinstal.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c23
-rw-r--r--drivers/acpi/acpica/utdebug.c8
-rw-r--r--drivers/acpi/acpica/utmisc.c20
-rw-r--r--drivers/acpi/acpica/utmutex.c26
-rw-r--r--drivers/acpi/pci_irq.c5
-rw-r--r--drivers/acpi/processor_throttling.c72
-rw-r--r--drivers/ata/ahci.c35
-rw-r--r--drivers/ata/ata_piix.c10
-rw-r--r--drivers/ata/libata-acpi.c4
-rw-r--r--drivers/ata/libata-core.c11
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/libata-sff.c20
-rw-r--r--drivers/ata/pata_ali.c17
-rw-r--r--drivers/ata/sata_sil.c2
-rw-r--r--drivers/ata/sata_sx4.c11
-rw-r--r--drivers/base/Kconfig25
-rw-r--r--drivers/base/Makefile1
-rw-r--r--drivers/base/base.h6
-rw-r--r--drivers/base/bus.c6
-rw-r--r--drivers/base/core.c59
-rw-r--r--drivers/base/dd.c6
-rw-r--r--drivers/base/devtmpfs.c367
-rw-r--r--drivers/base/driver.c4
-rw-r--r--drivers/base/firmware_class.c137
-rw-r--r--drivers/base/init.c1
-rw-r--r--drivers/base/platform.c5
-rw-r--r--drivers/base/power/main.c91
-rw-r--r--drivers/base/sys.c24
-rw-r--r--drivers/block/DAC960.c10
-rw-r--r--drivers/block/Kconfig2
-rw-r--r--drivers/block/amiflop.c54
-rw-r--r--drivers/block/aoe/aoechr.c7
-rw-r--r--drivers/block/ataflop.c66
-rw-r--r--drivers/block/cciss.c45
-rw-r--r--drivers/block/cpqarray.c20
-rw-r--r--drivers/block/floppy.c58
-rw-r--r--drivers/block/hd.c106
-rw-r--r--drivers/block/loop.c37
-rw-r--r--drivers/block/mg_disk.c537
-rw-r--r--drivers/block/nbd.c23
-rw-r--r--drivers/block/paride/pcd.c29
-rw-r--r--drivers/block/paride/pd.c22
-rw-r--r--drivers/block/paride/pf.c47
-rw-r--r--drivers/block/pktcdvd.c15
-rw-r--r--drivers/block/ps3disk.c42
-rw-r--r--drivers/block/ps3vram.c46
-rw-r--r--drivers/block/sunvdc.c14
-rw-r--r--drivers/block/swim.c48
-rw-r--r--drivers/block/swim3.c107
-rw-r--r--drivers/block/sx8.c17
-rw-r--r--drivers/block/ub.c54
-rw-r--r--drivers/block/viodasd.c12
-rw-r--r--drivers/block/virtio_blk.c83
-rw-r--r--drivers/block/xd.c41
-rw-r--r--drivers/block/xen-blkfront.c48
-rw-r--r--drivers/block/xsysace.c46
-rw-r--r--drivers/block/z2ram.c19
-rw-r--r--drivers/cdrom/cdrom.c4
-rw-r--r--drivers/cdrom/gdrom.c36
-rw-r--r--drivers/cdrom/viocd.c33
-rw-r--r--drivers/char/agp/hp-agp.c5
-rw-r--r--drivers/char/amiserial.c2
-rw-r--r--drivers/char/cyclades.c288
-rw-r--r--drivers/char/epca.c13
-rw-r--r--drivers/char/hpet.c4
-rw-r--r--drivers/char/hvcs.c6
-rw-r--r--drivers/char/hw_random/Kconfig14
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/core.c1
-rw-r--r--drivers/char/hw_random/mxc-rnga.c247
-rw-r--r--drivers/char/hw_random/omap-rng.c2
-rw-r--r--drivers/char/hw_random/via-rng.c15
-rw-r--r--drivers/char/hw_random/virtio-rng.c6
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c13
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c4
-rw-r--r--drivers/char/isicom.c19
-rw-r--r--drivers/char/istallion.c8
-rw-r--r--drivers/char/keyboard.c2
-rw-r--r--drivers/char/misc.c15
-rw-r--r--drivers/char/mxser.c12
-rw-r--r--drivers/char/pcmcia/synclink_cs.c11
-rw-r--r--drivers/char/raw.c8
-rw-r--r--drivers/char/rocket.c19
-rw-r--r--drivers/char/stallion.c6
-rw-r--r--drivers/char/synclink.c9
-rw-r--r--drivers/char/synclink_gt.c86
-rw-r--r--drivers/char/synclinkmp.c9
-rw-r--r--drivers/char/tty_port.c38
-rw-r--r--drivers/char/virtio_console.c26
-rw-r--r--drivers/char/vt.c7
-rw-r--r--drivers/clocksource/Makefile2
-rw-r--r--drivers/clocksource/sh_cmt.c116
-rw-r--r--drivers/clocksource/sh_mtu2.c357
-rw-r--r--drivers/clocksource/sh_tmu.c461
-rw-r--r--drivers/cpufreq/cpufreq.c4
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c66
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c73
-rw-r--r--drivers/crypto/Kconfig2
-rw-r--r--drivers/crypto/padlock-aes.c13
-rw-r--r--drivers/crypto/talitos.c713
-rw-r--r--drivers/dma/Kconfig8
-rw-r--r--drivers/dma/Makefile1
-rw-r--r--drivers/dma/fsldma.c13
-rw-r--r--drivers/dma/txx9dmac.c1354
-rw-r--r--drivers/dma/txx9dmac.h307
-rw-r--r--drivers/edac/Kconfig26
-rw-r--r--drivers/edac/Makefile7
-rw-r--r--drivers/edac/amd64_edac.c3354
-rw-r--r--drivers/edac/amd64_edac.h657
-rw-r--r--drivers/edac/amd64_edac_dbg.c255
-rw-r--r--drivers/edac/amd64_edac_err_types.c161
-rw-r--r--drivers/edac/amd64_edac_inj.c185
-rw-r--r--drivers/edac/e752x_edac.c2
-rw-r--r--drivers/edac/edac_core.h9
-rw-r--r--drivers/eisa/pci_eisa.c2
-rw-r--r--drivers/eisa/virtual_root.c2
-rw-r--r--drivers/firewire/fw-cdev.c6
-rw-r--r--drivers/firewire/fw-device.c3
-rw-r--r--drivers/firewire/fw-device.h1
-rw-r--r--drivers/firewire/fw-sbp2.c6
-rw-r--r--drivers/firmware/dcdbas.c49
-rw-r--r--drivers/firmware/pcdp.c4
-rw-r--r--drivers/gpu/drm/drm_sysfs.c7
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h3
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c42
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h17
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c102
-rw-r--r--drivers/gpu/drm/i915/intel_bios.h17
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c149
-rw-r--r--drivers/gpu/drm/i915/intel_display.c26
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c4
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c137
-rw-r--r--drivers/hid/Kconfig92
-rw-r--r--drivers/hid/Makefile10
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-debug.c23
-rw-r--r--drivers/hid/hid-drff.c8
-rw-r--r--drivers/hid/hid-gaff.c8
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-lgff.c10
-rw-r--r--drivers/hid/hid-ntrig.c222
-rw-r--r--drivers/hid/hid-sjoy.c180
-rw-r--r--drivers/hid/hid-tmff.c17
-rw-r--r--drivers/hid/hid-wacom.c259
-rw-r--r--drivers/hid/hid-zpff.c7
-rw-r--r--drivers/hid/usbhid/hiddev.c7
-rw-r--r--drivers/hwmon/Kconfig12
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/ibmaem.c1
-rw-r--r--drivers/hwmon/lm78.c2
-rw-r--r--drivers/hwmon/tmp401.c690
-rw-r--r--drivers/hwmon/w83627ehf.c10
-rw-r--r--drivers/i2c/busses/Kconfig6
-rw-r--r--drivers/i2c/busses/i2c-pxa.c22
-rw-r--r--drivers/i2c/busses/i2c-sh7760.c2
-rw-r--r--drivers/i2c/busses/i2c-viapro.c4
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c1
-rw-r--r--drivers/i2c/chips/Kconfig15
-rw-r--r--drivers/i2c/chips/Makefile1
-rw-r--r--drivers/i2c/i2c-core.c43
-rw-r--r--drivers/ide/alim15x3.c10
-rw-r--r--drivers/ide/at91_ide.c7
-rw-r--r--drivers/ide/au1xxx-ide.c8
-rw-r--r--drivers/ide/buddha.c9
-rw-r--r--drivers/ide/cmd640.c7
-rw-r--r--drivers/ide/cs5520.c4
-rw-r--r--drivers/ide/delkin_cb.c6
-rw-r--r--drivers/ide/falconide.c9
-rw-r--r--drivers/ide/gayle.c9
-rw-r--r--drivers/ide/icside.c13
-rw-r--r--drivers/ide/ide-4drives.c6
-rw-r--r--drivers/ide/ide-atapi.c179
-rw-r--r--drivers/ide/ide-cd.c152
-rw-r--r--drivers/ide/ide-cd.h4
-rw-r--r--drivers/ide/ide-cs.c6
-rw-r--r--drivers/ide/ide-disk.c15
-rw-r--r--drivers/ide/ide-dma.c22
-rw-r--r--drivers/ide/ide-eh.c9
-rw-r--r--drivers/ide/ide-floppy.c32
-rw-r--r--drivers/ide/ide-generic.c7
-rw-r--r--drivers/ide/ide-h8300.c10
-rw-r--r--drivers/ide/ide-io.c130
-rw-r--r--drivers/ide/ide-ioctls.c1
-rw-r--r--drivers/ide/ide-iops.c21
-rw-r--r--drivers/ide/ide-legacy.c7
-rw-r--r--drivers/ide/ide-lib.c29
-rw-r--r--drivers/ide/ide-park.c7
-rw-r--r--drivers/ide/ide-pm.c44
-rw-r--r--drivers/ide/ide-pnp.c6
-rw-r--r--drivers/ide/ide-probe.c47
-rw-r--r--drivers/ide/ide-tape.c735
-rw-r--r--drivers/ide/ide-taskfile.c22
-rw-r--r--drivers/ide/ide_platform.c11
-rw-r--r--drivers/ide/macide.c9
-rw-r--r--drivers/ide/palm_bk3710.c6
-rw-r--r--drivers/ide/pdc202xx_old.c2
-rw-r--r--drivers/ide/pmac.c13
-rw-r--r--drivers/ide/q40ide.c11
-rw-r--r--drivers/ide/rapide.c8
-rw-r--r--drivers/ide/scc_pata.c6
-rw-r--r--drivers/ide/setup-pci.c21
-rw-r--r--drivers/ide/sgiioc4.c7
-rw-r--r--drivers/ide/siimage.c4
-rw-r--r--drivers/ide/tc86c001.c2
-rw-r--r--drivers/ide/tx4938ide.c5
-rw-r--r--drivers/ide/tx4939ide.c7
-rw-r--r--drivers/ide/via82cxxx.c2
-rw-r--r--drivers/ieee1394/eth1394.c16
-rw-r--r--drivers/ieee1394/sbp2.c8
-rw-r--r--drivers/infiniband/core/sysfs.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_cq.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c9
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c10
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c94
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.c6
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.h2
-rw-r--r--drivers/infiniband/hw/ehca/hcp_phyp.c11
-rw-r--r--drivers/infiniband/hw/ehca/hcp_phyp.h2
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.c19
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c14
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c6
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c10
-rw-r--r--drivers/input/evdev.c9
-rw-r--r--drivers/input/gameport/fm801-gp.c1
-rw-r--r--drivers/input/gameport/gameport.c25
-rw-r--r--drivers/input/input.c7
-rw-r--r--drivers/input/joydev.c14
-rw-r--r--drivers/input/keyboard/Kconfig21
-rw-r--r--drivers/input/keyboard/Makefile2
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c470
-rw-r--r--drivers/input/keyboard/gpio_keys.c3
-rw-r--r--drivers/input/keyboard/lm8323.c878
-rw-r--r--drivers/input/misc/Kconfig21
-rw-r--r--drivers/input/misc/Makefile2
-rw-r--r--drivers/input/misc/ati_remote2.c16
-rw-r--r--drivers/input/misc/dm355evm_keys.c329
-rw-r--r--drivers/input/misc/rotary_encoder.c61
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c145
-rw-r--r--drivers/input/misc/uinput.c94
-rw-r--r--drivers/input/mouse/alps.c18
-rw-r--r--drivers/input/mouse/lifebook.c25
-rw-r--r--drivers/input/mouse/psmouse-base.c4
-rw-r--r--drivers/input/mousedev.c9
-rw-r--r--drivers/input/serio/i8042.c17
-rw-r--r--drivers/input/serio/serio.c58
-rw-r--r--drivers/input/tablet/gtco.c1
-rw-r--r--drivers/input/tablet/wacom.h5
-rw-r--r--drivers/input/tablet/wacom_sys.c13
-rw-r--r--drivers/input/tablet/wacom_wac.c168
-rw-r--r--drivers/input/tablet/wacom_wac.h3
-rw-r--r--drivers/input/touchscreen/Kconfig24
-rw-r--r--drivers/input/touchscreen/Makefile2
-rw-r--r--drivers/input/touchscreen/ads7846.c11
-rw-r--r--drivers/input/touchscreen/atmel-wm97xx.c446
-rw-r--r--drivers/input/touchscreen/eeti_ts.c286
-rw-r--r--drivers/input/touchscreen/tsc2007.c2
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c2
-rw-r--r--drivers/input/xen-kbdfront.c8
-rw-r--r--drivers/isdn/Kconfig2
-rw-r--r--drivers/isdn/divert/isdn_divert.c2
-rw-r--r--drivers/isdn/gigaset/Kconfig8
-rw-r--r--drivers/isdn/gigaset/asyncdata.c5
-rw-r--r--drivers/isdn/gigaset/common.c12
-rw-r--r--drivers/isdn/gigaset/ev-layer.c4
-rw-r--r--drivers/isdn/gigaset/gigaset.h5
-rw-r--r--drivers/isdn/gigaset/i4l.c12
-rw-r--r--drivers/isdn/gigaset/interface.c3
-rw-r--r--drivers/isdn/gigaset/isocdata.c6
-rw-r--r--drivers/isdn/gigaset/proc.c2
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c62
-rw-r--r--drivers/isdn/hardware/mISDN/Kconfig11
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_multi.h47
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_multi_8xx.h167
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c614
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c98
-rw-r--r--drivers/isdn/hardware/mISDN/hfcsusb.c4
-rw-r--r--drivers/isdn/i4l/Kconfig2
-rw-r--r--drivers/isdn/mISDN/core.c8
-rw-r--r--drivers/isdn/mISDN/dsp.h19
-rw-r--r--drivers/isdn/mISDN/dsp_audio.c5
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c115
-rw-r--r--drivers/isdn/mISDN/dsp_core.c74
-rw-r--r--drivers/isdn/mISDN/dsp_dtmf.c3
-rw-r--r--drivers/isdn/mISDN/dsp_ecdis.h2
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c5
-rw-r--r--drivers/isdn/mISDN/dsp_tones.c23
-rw-r--r--drivers/isdn/mISDN/hwchannel.c4
-rw-r--r--drivers/isdn/mISDN/l1oip.h2
-rw-r--r--drivers/isdn/mISDN/l1oip_codec.c1
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c71
-rw-r--r--drivers/isdn/mISDN/layer2.c37
-rw-r--r--drivers/isdn/mISDN/layer2.h2
-rw-r--r--drivers/isdn/mISDN/socket.c45
-rw-r--r--drivers/isdn/mISDN/tei.c95
-rw-r--r--drivers/isdn/mISDN/timerdev.c2
-rw-r--r--drivers/leds/leds-h1940.c2
-rw-r--r--drivers/leds/leds-s3c24xx.c1
-rw-r--r--drivers/lguest/core.c28
-rw-r--r--drivers/lguest/hypercalls.c4
-rw-r--r--drivers/lguest/interrupts_and_traps.c57
-rw-r--r--drivers/lguest/lg.h17
-rw-r--r--drivers/lguest/lguest_device.c41
-rw-r--r--drivers/lguest/lguest_user.c102
-rw-r--r--drivers/lguest/x86/core.c19
-rw-r--r--drivers/macintosh/therm_adt746x.c84
-rw-r--r--drivers/macintosh/therm_pm72.c95
-rw-r--r--drivers/macintosh/therm_windtunnel.c126
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c129
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c103
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c109
-rw-r--r--drivers/md/Kconfig9
-rw-r--r--drivers/md/Makefile1
-rw-r--r--drivers/md/bitmap.c17
-rw-r--r--drivers/md/dm-crypt.c8
-rw-r--r--drivers/md/dm-delay.c6
-rw-r--r--drivers/md/dm-exception-store.c2
-rw-r--r--drivers/md/dm-io.c14
-rw-r--r--drivers/md/dm-ioctl.c1
-rw-r--r--drivers/md/dm-linear.c4
-rw-r--r--drivers/md/dm-log.c3
-rw-r--r--drivers/md/dm-mpath.c120
-rw-r--r--drivers/md/dm-path-selector.h8
-rw-r--r--drivers/md/dm-queue-length.c263
-rw-r--r--drivers/md/dm-region-hash.c2
-rw-r--r--drivers/md/dm-round-robin.c2
-rw-r--r--drivers/md/dm-snap-persistent.c4
-rw-r--r--drivers/md/dm-snap.c11
-rw-r--r--drivers/md/dm-stripe.c15
-rw-r--r--drivers/md/dm-table.c169
-rw-r--r--drivers/md/dm.c203
-rw-r--r--drivers/md/faulty.c15
-rw-r--r--drivers/md/linear.c158
-rw-r--r--drivers/md/linear.h10
-rw-r--r--drivers/md/md.c146
-rw-r--r--drivers/md/md.h6
-rw-r--r--drivers/md/multipath.c24
-rw-r--r--drivers/md/multipath.h6
-rw-r--r--drivers/md/raid0.c392
-rw-r--r--drivers/md/raid0.h10
-rw-r--r--drivers/md/raid1.c46
-rw-r--r--drivers/md/raid1.h6
-rw-r--r--drivers/md/raid10.c66
-rw-r--r--drivers/md/raid10.h6
-rw-r--r--drivers/md/raid5.c223
-rw-r--r--drivers/md/raid5.h8
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.c2
-rw-r--r--drivers/media/common/tuners/xc5000.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c10
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c86
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c7
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/dvb/firewire/firedtv-1394.c4
-rw-r--r--drivers/media/dvb/firewire/firedtv-dvb.c2
-rw-r--r--drivers/media/dvb/firewire/firedtv-rc.c4
-rw-r--r--drivers/media/dvb/frontends/Kconfig22
-rw-r--r--drivers/media/dvb/frontends/Makefile4
-rw-r--r--drivers/media/dvb/frontends/af9013.c2
-rw-r--r--drivers/media/dvb/frontends/cx24116.c2
-rw-r--r--drivers/media/dvb/frontends/drx397xD.c4
-rw-r--r--drivers/media/dvb/frontends/isl6423.c308
-rw-r--r--drivers/media/dvb/frontends/isl6423.h63
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c6
-rw-r--r--drivers/media/dvb/frontends/or51132.c2
-rw-r--r--drivers/media/dvb/frontends/stv0900_priv.h2
-rw-r--r--drivers/media/dvb/frontends/stv090x.c4299
-rw-r--r--drivers/media/dvb/frontends/stv090x.h106
-rw-r--r--drivers/media/dvb/frontends/stv090x_priv.h269
-rw-r--r--drivers/media/dvb/frontends/stv090x_reg.h2373
-rw-r--r--drivers/media/dvb/frontends/stv6110x.c373
-rw-r--r--drivers/media/dvb/frontends/stv6110x.h71
-rw-r--r--drivers/media/dvb/frontends/stv6110x_priv.h75
-rw-r--r--drivers/media/dvb/frontends/stv6110x_reg.h82
-rw-r--r--drivers/media/dvb/frontends/tda10048.c224
-rw-r--r--drivers/media/dvb/frontends/tda10048.h17
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c36
-rw-r--r--drivers/media/dvb/siano/smscoreapi.h176
-rw-r--r--drivers/media/dvb/siano/smsdvb.c41
-rw-r--r--drivers/media/dvb/siano/smsendian.c100
-rw-r--r--drivers/media/dvb/siano/smsendian.h32
-rw-r--r--drivers/media/dvb/siano/smsir.c301
-rw-r--r--drivers/media/dvb/siano/smsir.h93
-rw-r--r--drivers/media/dvb/siano/smssdio.c354
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c2
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c2
-rw-r--r--drivers/media/dvb/ttpci/budget.c85
-rw-r--r--drivers/media/radio/radio-sf16fmi.c16
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c22
-rw-r--r--drivers/media/radio/radio-si470x.c1
-rw-r--r--drivers/media/video/Kconfig24
-rw-r--r--drivers/media/video/Makefile11
-rw-r--r--drivers/media/video/adv7343.c534
-rw-r--r--drivers/media/video/adv7343_regs.h185
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c6
-rw-r--r--drivers/media/video/cx18/cx18-audio.c44
-rw-r--r--drivers/media/video/cx18/cx18-av-core.c234
-rw-r--r--drivers/media/video/cx18/cx18-av-firmware.c82
-rw-r--r--drivers/media/video/cx18/cx18-controls.c6
-rw-r--r--drivers/media/video/cx18/cx18-driver.c97
-rw-r--r--drivers/media/video/cx18/cx18-driver.h17
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c1
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c7
-rw-r--r--drivers/media/video/cx18/cx18-mailbox.c114
-rw-r--r--drivers/media/video/cx18/cx18-mailbox.h2
-rw-r--r--drivers/media/video/cx18/cx18-queue.c85
-rw-r--r--drivers/media/video/cx18/cx18-streams.c35
-rw-r--r--drivers/media/video/cx18/cx18-streams.h20
-rw-r--r--drivers/media/video/cx18/cx18-version.h2
-rw-r--r--drivers/media/video/cx231xx/cx231xx-avcore.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-vbi.c1
-rw-r--r--drivers/media/video/cx23885/cimax2.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c10
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c4
-rw-r--r--drivers/media/video/cx88/Makefile2
-rw-r--r--drivers/media/video/cx88/cx88-cards.c13
-rw-r--r--drivers/media/video/cx88/cx88-core.c26
-rw-r--r--drivers/media/video/cx88/cx88-dsp.c312
-rw-r--r--drivers/media/video/cx88/cx88-input.c4
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c115
-rw-r--r--drivers/media/video/cx88/cx88.h11
-rw-r--r--drivers/media/video/dabusb.c6
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c27
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c1
-rw-r--r--drivers/media/video/em28xx/em28xx.h1
-rw-r--r--drivers/media/video/gspca/finepix.c1
-rw-r--r--drivers/media/video/gspca/gspca.c50
-rw-r--r--drivers/media/video/gspca/gspca.h6
-rw-r--r--drivers/media/video/gspca/m5602/Makefile3
-rw-r--r--drivers/media/video/gspca/m5602/m5602_bridge.h26
-rw-r--r--drivers/media/video/gspca/m5602/m5602_core.c44
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.c400
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.h805
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov7660.c227
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov7660.h279
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.c195
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.h57
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.c494
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.h439
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.c385
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.h93
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.c473
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.h280
-rw-r--r--drivers/media/video/gspca/m5602/m5602_sensor.h9
-rw-r--r--drivers/media/video/gspca/mr97310a.c8
-rw-r--r--drivers/media/video/gspca/ov534.c30
-rw-r--r--drivers/media/video/gspca/sonixb.c2
-rw-r--r--drivers/media/video/gspca/sonixj.c66
-rw-r--r--drivers/media/video/gspca/spca500.c33
-rw-r--r--drivers/media/video/gspca/sq905.c1
-rw-r--r--drivers/media/video/gspca/sq905c.c1
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c76
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h10
-rw-r--r--drivers/media/video/gspca/sunplus.c33
-rw-r--r--drivers/media/video/gspca/t613.c2
-rw-r--r--drivers/media/video/gspca/vc032x.c22
-rw-r--r--drivers/media/video/gspca/zc3xx.c22
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c2
-rw-r--r--drivers/media/video/hexium_gemini.c2
-rw-r--r--drivers/media/video/hexium_orion.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c7
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c2
-rw-r--r--drivers/media/video/mt9m001.c108
-rw-r--r--drivers/media/video/mt9m111.c73
-rw-r--r--drivers/media/video/mt9t031.c135
-rw-r--r--drivers/media/video/mt9v022.c138
-rw-r--r--drivers/media/video/mx1_camera.c50
-rw-r--r--drivers/media/video/mx3_camera.c40
-rw-r--r--drivers/media/video/mxb.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.h23
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c74
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c51
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c22
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c6
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c2
-rw-r--r--drivers/media/video/pxa_camera.c120
-rw-r--r--drivers/media/video/s2255drv.c62
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c438
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c3
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c13
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c2
-rw-r--r--drivers/media/video/saa7134/saa7134.h15
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c27
-rw-r--r--drivers/media/video/soc_camera.c106
-rw-r--r--drivers/media/video/stk-webcam.c4
-rw-r--r--drivers/media/video/tda7432.c14
-rw-r--r--drivers/media/video/tea6415c.c1
-rw-r--r--drivers/media/video/tea6420.c1
-rw-r--r--drivers/media/video/ths7303.c151
-rw-r--r--drivers/media/video/tuner-core.c27
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c2
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c10
-rw-r--r--drivers/media/video/v4l2-common.c4
-rw-r--r--drivers/media/video/v4l2-device.c31
-rw-r--r--drivers/media/video/videobuf-core.c5
-rw-r--r--drivers/media/video/videobuf-dma-contig.c14
-rw-r--r--drivers/media/video/zoran/zoran_card.c2
-rw-r--r--drivers/memstick/core/mspro_block.c19
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt6
-rw-r--r--drivers/message/fusion/mptsas.c22
-rw-r--r--drivers/message/i2o/i2o_block.c43
-rw-r--r--drivers/mfd/Kconfig14
-rw-r--r--drivers/mfd/Makefile3
-rwxr-xr-xdrivers/mfd/ab3100-core.c991
-rw-r--r--drivers/mfd/htc-pasic3.c4
-rw-r--r--drivers/mfd/pcf50633-core.c2
-rw-r--r--drivers/mfd/pcf50633-gpio.c3
-rw-r--r--drivers/mfd/twl4030-core.c2
-rw-r--r--drivers/mfd/twl4030-irq.c2
-rw-r--r--drivers/mfd/wm8350-regmap.c4
-rw-r--r--drivers/mfd/wm8400-core.c2
-rw-r--r--drivers/misc/eeprom/Kconfig14
-rw-r--r--drivers/misc/eeprom/Makefile1
-rw-r--r--drivers/misc/eeprom/max6875.c (renamed from drivers/i2c/chips/max6875.c)2
-rw-r--r--drivers/misc/enclosure.c6
-rw-r--r--drivers/mmc/card/block.c12
-rw-r--r--drivers/mmc/card/queue.c11
-rw-r--r--drivers/mmc/core/core.c107
-rw-r--r--drivers/mmc/host/Kconfig2
-rw-r--r--drivers/mmc/host/atmel-mci.c12
-rw-r--r--drivers/mmc/host/mmc_spi.c12
-rw-r--r--drivers/mmc/host/mvsdio.c10
-rw-r--r--drivers/mmc/host/mxcmmc.c45
-rw-r--r--drivers/mmc/host/omap.c5
-rw-r--r--drivers/mmc/host/omap_hsmmc.c2
-rw-r--r--drivers/mmc/host/s3cmci.c5
-rw-r--r--drivers/mmc/host/sdhci-of.c1
-rw-r--r--drivers/mmc/host/sdhci.c53
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mtd/Kconfig3
-rw-r--r--drivers/mtd/mtd_blkdevs.c43
-rw-r--r--drivers/mtd/onenand/omap2.c1
-rw-r--r--drivers/mtd/ubi/build.c17
-rw-r--r--drivers/mtd/ubi/cdev.c30
-rw-r--r--drivers/mtd/ubi/io.c80
-rw-r--r--drivers/mtd/ubi/kapi.c9
-rw-r--r--drivers/mtd/ubi/ubi.h12
-rw-r--r--drivers/mtd/ubi/upd.c8
-rw-r--r--drivers/mtd/ubi/vmt.c35
-rw-r--r--drivers/net/3c509.c12
-rw-r--r--drivers/net/8139too.c92
-rw-r--r--drivers/net/82596.c14
-rw-r--r--drivers/net/8390.c10
-rw-r--r--drivers/net/8390p.c19
-rw-r--r--drivers/net/Kconfig37
-rw-r--r--drivers/net/Makefile7
-rw-r--r--drivers/net/appletalk/ipddp.c1
-rw-r--r--drivers/net/appletalk/ltpc.c2
-rw-r--r--drivers/net/arm/ixp4xx_eth.c26
-rw-r--r--drivers/net/atl1c/atl1c_main.c24
-rw-r--r--drivers/net/atl1e/atl1e_main.c3
-rw-r--r--drivers/net/atlx/atl1.c7
-rw-r--r--drivers/net/b44.h2
-rw-r--r--drivers/net/benet/be_main.c28
-rw-r--r--drivers/net/bmac.c16
-rw-r--r--drivers/net/bnx2.c18
-rw-r--r--drivers/net/bnx2.h2
-rw-r--r--drivers/net/bnx2x.h15
-rw-r--r--drivers/net/bnx2x_fw_file_hdr.h37
-rw-r--r--drivers/net/bnx2x_init.h605
-rw-r--r--drivers/net/bnx2x_init_ops.h442
-rw-r--r--drivers/net/bnx2x_init_values.h16322
-rw-r--r--drivers/net/bnx2x_main.c358
-rw-r--r--drivers/net/bonding/bond_3ad.c5
-rw-r--r--drivers/net/bonding/bond_3ad.h4
-rw-r--r--drivers/net/bonding/bond_main.c73
-rw-r--r--drivers/net/bonding/bond_sysfs.c9
-rw-r--r--drivers/net/can/Kconfig53
-rw-r--r--drivers/net/can/Makefile7
-rw-r--r--drivers/net/can/dev.c657
-rw-r--r--drivers/net/can/sja1000/Makefile10
-rw-r--r--drivers/net/can/sja1000/ems_pci.c329
-rw-r--r--drivers/net/can/sja1000/kvaser_pci.c411
-rw-r--r--drivers/net/can/sja1000/sja1000.c637
-rw-r--r--drivers/net/can/sja1000/sja1000.h180
-rw-r--r--drivers/net/can/sja1000/sja1000_platform.c164
-rw-r--r--drivers/net/chelsio/common.h2
-rw-r--r--drivers/net/chelsio/cphy.h51
-rw-r--r--drivers/net/chelsio/cxgb2.c36
-rw-r--r--drivers/net/chelsio/mv88e1xxx.c5
-rw-r--r--drivers/net/chelsio/mv88x201x.c50
-rw-r--r--drivers/net/chelsio/my3126.c14
-rw-r--r--drivers/net/chelsio/sge.c4
-rw-r--r--drivers/net/chelsio/subr.c46
-rw-r--r--drivers/net/cpmac.c23
-rw-r--r--drivers/net/cxgb3/adapter.h2
-rw-r--r--drivers/net/cxgb3/ael1002.c147
-rw-r--r--drivers/net/cxgb3/common.h63
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c71
-rw-r--r--drivers/net/cxgb3/sge.c53
-rw-r--r--drivers/net/cxgb3/t3_hw.c82
-rw-r--r--drivers/net/cxgb3/vsc8211.c70
-rw-r--r--drivers/net/davinci_emac.c2832
-rw-r--r--drivers/net/de600.c19
-rw-r--r--drivers/net/de620.c61
-rw-r--r--drivers/net/depca.c4
-rw-r--r--drivers/net/dm9000.c30
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000/e1000_main.c15
-rw-r--r--drivers/net/e1000e/e1000.h2
-rw-r--r--drivers/net/e1000e/netdev.c19
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c8
-rw-r--r--drivers/net/eql.c1
-rw-r--r--drivers/net/fec.c897
-rw-r--r--drivers/net/fec.h127
-rw-r--r--drivers/net/fec_mpc52xx.c180
-rw-r--r--drivers/net/fec_mpc52xx_phy.c26
-rw-r--r--drivers/net/forcedeth.c23
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c108
-rw-r--r--drivers/net/fs_enet/fs_enet.h5
-rw-r--r--drivers/net/fs_enet/mac-fec.c34
-rw-r--r--drivers/net/fs_enet/mii-bitbang.c29
-rw-r--r--drivers/net/fs_enet/mii-fec.c32
-rw-r--r--drivers/net/fsl_pq_mdio.c53
-rw-r--r--drivers/net/gianfar.c123
-rw-r--r--drivers/net/gianfar.h4
-rw-r--r--drivers/net/hp100.c4
-rw-r--r--drivers/net/hplance.c21
-rw-r--r--drivers/net/ibmveth.c40
-rw-r--r--drivers/net/ifb.c1
-rw-r--r--drivers/net/igb/e1000_82575.h1
-rw-r--r--drivers/net/igb/e1000_defines.h3
-rw-r--r--drivers/net/igb/e1000_mbx.c8
-rw-r--r--drivers/net/igb/igb.h2
-rw-r--r--drivers/net/igb/igb_ethtool.c20
-rw-r--r--drivers/net/igb/igb_main.c113
-rw-r--r--drivers/net/igbvf/ethtool.c36
-rw-r--r--drivers/net/igbvf/igbvf.h8
-rw-r--r--drivers/net/igbvf/netdev.c17
-rw-r--r--drivers/net/ipg.h2
-rw-r--r--drivers/net/irda/au1k_ir.c18
-rw-r--r--drivers/net/irda/pxaficp_ir.c16
-rw-r--r--drivers/net/irda/sa1100_ir.c18
-rw-r--r--drivers/net/iseries_veth.c17
-rw-r--r--drivers/net/ixgb/ixgb_hw.c20
-rw-r--r--drivers/net/ixgb/ixgb_hw.h14
-rw-r--r--drivers/net/ixgb/ixgb_main.c15
-rw-r--r--drivers/net/ixgb/ixgb_osdep.h2
-rw-r--r--drivers/net/ixgbe/Makefile2
-rw-r--r--drivers/net/ixgbe/ixgbe.h47
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c217
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c360
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c64
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82598.c4
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_nl.c119
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c62
-rw-r--r--drivers/net/ixgbe/ixgbe_fcoe.c552
-rw-r--r--drivers/net/ixgbe/ixgbe_fcoe.h66
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c1132
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c152
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.h5
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h164
-rw-r--r--drivers/net/ixp2000/ixpdev.c19
-rw-r--r--drivers/net/jazzsonic.c19
-rw-r--r--drivers/net/korina.c25
-rw-r--r--drivers/net/lasi_82596.c6
-rw-r--r--drivers/net/lib82596.c23
-rw-r--r--drivers/net/ll_temac.h374
-rw-r--r--drivers/net/ll_temac_main.c969
-rw-r--r--drivers/net/ll_temac_mdio.c120
-rw-r--r--drivers/net/loopback.c22
-rw-r--r--drivers/net/mac8390.c10
-rw-r--r--drivers/net/mac89x0.c2
-rw-r--r--drivers/net/macb.c18
-rw-r--r--drivers/net/mace.c16
-rw-r--r--drivers/net/macmace.c18
-rw-r--r--drivers/net/macvlan.c23
-rw-r--r--drivers/net/mdio.c414
-rw-r--r--drivers/net/meth.c28
-rw-r--r--drivers/net/mii.c91
-rw-r--r--drivers/net/mipsnet.c15
-rw-r--r--drivers/net/mlx4/en_cq.c3
-rw-r--r--drivers/net/mlx4/en_netdev.c28
-rw-r--r--drivers/net/mlx4/en_rx.c71
-rw-r--r--drivers/net/mv643xx_eth.c87
-rw-r--r--drivers/net/mvme147.c17
-rw-r--r--drivers/net/myri10ge/myri10ge.c67
-rw-r--r--drivers/net/ne2k-pci.c2
-rw-r--r--drivers/net/ne3210.c4
-rw-r--r--drivers/net/netx-eth.c17
-rw-r--r--drivers/net/netxen/netxen_nic.h624
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c241
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c106
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h8
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c737
-rw-r--r--drivers/net/netxen/netxen_nic_hw.h76
-rw-r--r--drivers/net/netxen/netxen_nic_init.c536
-rw-r--r--drivers/net/netxen/netxen_nic_main.c410
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c341
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h27
-rw-r--r--drivers/net/niu.h4
-rw-r--r--drivers/net/pasemi_mac.c58
-rw-r--r--drivers/net/pasemi_mac.h1
-rw-r--r--drivers/net/pci-skeleton.c19
-rw-r--r--drivers/net/pcmcia/3c574_cs.c2
-rw-r--r--drivers/net/pcmcia/3c589_cs.c4
-rw-r--r--drivers/net/pcnet32.c5
-rw-r--r--drivers/net/phy/mdio_bus.c29
-rw-r--r--drivers/net/phy/phy_device.c163
-rw-r--r--drivers/net/ppp_generic.c1
-rw-r--r--drivers/net/pppol2tp.c3
-rw-r--r--drivers/net/qlge/qlge_mpi.c6
-rw-r--r--drivers/net/r6040.c12
-rw-r--r--drivers/net/r8169.c277
-rw-r--r--drivers/net/rionet.c14
-rw-r--r--drivers/net/s2io-regs.h5
-rw-r--r--drivers/net/s2io.c21
-rw-r--r--drivers/net/sb1250-mac.c35
-rw-r--r--drivers/net/sfc/Kconfig2
-rw-r--r--drivers/net/sfc/boards.c2
-rw-r--r--drivers/net/sfc/efx.c29
-rw-r--r--drivers/net/sfc/ethtool.c19
-rw-r--r--drivers/net/sfc/falcon.c137
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h3
-rw-r--r--drivers/net/sfc/falcon_xmac.c2
-rw-r--r--drivers/net/sfc/mdio_10g.c385
-rw-r--r--drivers/net/sfc/mdio_10g.h282
-rw-r--r--drivers/net/sfc/net_driver.h34
-rw-r--r--drivers/net/sfc/rx.c26
-rw-r--r--drivers/net/sfc/selftest.c21
-rw-r--r--drivers/net/sfc/selftest.h2
-rw-r--r--drivers/net/sfc/sfe4001.c3
-rw-r--r--drivers/net/sfc/tenxpress.c240
-rw-r--r--drivers/net/sfc/xenpack.h62
-rw-r--r--drivers/net/sfc/xfp_phy.c55
-rw-r--r--drivers/net/sgiseeq.c18
-rw-r--r--drivers/net/skfp/h/smt.h2
-rw-r--r--drivers/net/skfp/skfddi.c156
-rw-r--r--drivers/net/slip.c96
-rw-r--r--drivers/net/smc-mca.c4
-rw-r--r--drivers/net/smc911x.c23
-rw-r--r--drivers/net/smc91x.h5
-rw-r--r--drivers/net/smsc911x.c61
-rw-r--r--drivers/net/sun3lance.c17
-rw-r--r--drivers/net/tc35815.c13
-rw-r--r--drivers/net/tg3.c89
-rw-r--r--drivers/net/tg3.h6
-rw-r--r--drivers/net/tokenring/3c359.c2
-rw-r--r--drivers/net/tokenring/lanstreamer.c2
-rw-r--r--drivers/net/tokenring/olympic.c2
-rw-r--r--drivers/net/tulip/de4x5.c6
-rw-r--r--drivers/net/tulip/winbond-840.c3
-rw-r--r--drivers/net/tun.c94
-rw-r--r--drivers/net/ucc_geth.c99
-rw-r--r--drivers/net/ucc_geth.h7
-rw-r--r--drivers/net/ucc_geth_ethtool.c2
-rw-r--r--drivers/net/usb/Kconfig8
-rw-r--r--drivers/net/usb/Makefile1
-rw-r--r--drivers/net/usb/cdc_ether.c33
-rw-r--r--drivers/net/usb/dm9601.c12
-rw-r--r--drivers/net/usb/hso.c8
-rw-r--r--drivers/net/usb/int51x1.c253
-rw-r--r--drivers/net/usb/kaweth.c33
-rw-r--r--drivers/net/usb/smsc95xx.c4
-rw-r--r--drivers/net/usb/usbnet.c37
-rw-r--r--drivers/net/virtio_net.c57
-rw-r--r--drivers/net/vxge/vxge-traffic.c4
-rw-r--r--drivers/net/wan/hdlc_fr.c1
-rw-r--r--drivers/net/wan/ixp4xx_hss.c11
-rw-r--r--drivers/net/wan/pc300_drv.c20
-rw-r--r--drivers/net/wimax/i2400m/usb.c35
-rw-r--r--drivers/net/wireless/Kconfig18
-rw-r--r--drivers/net/wireless/Makefile8
-rw-r--r--drivers/net/wireless/adm8211.c14
-rw-r--r--drivers/net/wireless/airo.c23
-rw-r--r--drivers/net/wireless/at76c50x-usb.c19
-rw-r--r--drivers/net/wireless/ath/Kconfig8
-rw-r--r--drivers/net/wireless/ath/Makefile6
-rw-r--r--drivers/net/wireless/ath/ar9170/Kconfig (renamed from drivers/net/wireless/ar9170/Kconfig)1
-rw-r--r--drivers/net/wireless/ath/ar9170/Makefile (renamed from drivers/net/wireless/ar9170/Makefile)0
-rw-r--r--drivers/net/wireless/ath/ar9170/ar9170.h (renamed from drivers/net/wireless/ar9170/ar9170.h)32
-rw-r--r--drivers/net/wireless/ath/ar9170/cmd.c (renamed from drivers/net/wireless/ar9170/cmd.c)0
-rw-r--r--drivers/net/wireless/ath/ar9170/cmd.h (renamed from drivers/net/wireless/ar9170/cmd.h)0
-rw-r--r--drivers/net/wireless/ath/ar9170/eeprom.h (renamed from drivers/net/wireless/ar9170/eeprom.h)0
-rw-r--r--drivers/net/wireless/ath/ar9170/hw.h (renamed from drivers/net/wireless/ar9170/hw.h)17
-rw-r--r--drivers/net/wireless/ath/ar9170/led.c (renamed from drivers/net/wireless/ar9170/led.c)0
-rw-r--r--drivers/net/wireless/ath/ar9170/mac.c (renamed from drivers/net/wireless/ar9170/mac.c)33
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c (renamed from drivers/net/wireless/ar9170/main.c)659
-rw-r--r--drivers/net/wireless/ath/ar9170/phy.c (renamed from drivers/net/wireless/ar9170/phy.c)0
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c (renamed from drivers/net/wireless/ar9170/usb.c)6
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.h (renamed from drivers/net/wireless/ar9170/usb.h)2
-rw-r--r--drivers/net/wireless/ath/ath5k/Kconfig (renamed from drivers/net/wireless/ath5k/Kconfig)1
-rw-r--r--drivers/net/wireless/ath/ath5k/Makefile (renamed from drivers/net/wireless/ath5k/Makefile)0
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h (renamed from drivers/net/wireless/ath5k/ath5k.h)42
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c (renamed from drivers/net/wireless/ath5k/attach.c)1
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c (renamed from drivers/net/wireless/ath5k/base.c)326
-rw-r--r--drivers/net/wireless/ath/ath5k/base.h (renamed from drivers/net/wireless/ath5k/base.h)1
-rw-r--r--drivers/net/wireless/ath/ath5k/caps.c (renamed from drivers/net/wireless/ath5k/caps.c)0
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c (renamed from drivers/net/wireless/ath5k/debug.c)0
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.h (renamed from drivers/net/wireless/ath5k/debug.h)0
-rw-r--r--drivers/net/wireless/ath/ath5k/desc.c (renamed from drivers/net/wireless/ath5k/desc.c)0
-rw-r--r--drivers/net/wireless/ath/ath5k/desc.h (renamed from drivers/net/wireless/ath5k/desc.h)0
-rw-r--r--drivers/net/wireless/ath/ath5k/dma.c (renamed from drivers/net/wireless/ath5k/dma.c)2
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c (renamed from drivers/net/wireless/ath5k/eeprom.c)73
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.h (renamed from drivers/net/wireless/ath5k/eeprom.h)46
-rw-r--r--drivers/net/wireless/ath/ath5k/gpio.c (renamed from drivers/net/wireless/ath5k/gpio.c)0
-rw-r--r--drivers/net/wireless/ath/ath5k/initvals.c (renamed from drivers/net/wireless/ath5k/initvals.c)8
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c (renamed from drivers/net/wireless/ath5k/led.c)10
-rw-r--r--drivers/net/wireless/ath/ath5k/pcu.c (renamed from drivers/net/wireless/ath5k/pcu.c)10
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c (renamed from drivers/net/wireless/ath5k/phy.c)541
-rw-r--r--drivers/net/wireless/ath/ath5k/qcu.c (renamed from drivers/net/wireless/ath5k/qcu.c)7
-rw-r--r--drivers/net/wireless/ath/ath5k/reg.h (renamed from drivers/net/wireless/ath5k/reg.h)9
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c (renamed from drivers/net/wireless/ath5k/reset.c)83
-rw-r--r--drivers/net/wireless/ath/ath5k/rfbuffer.h (renamed from drivers/net/wireless/ath5k/rfbuffer.h)0
-rw-r--r--drivers/net/wireless/ath/ath5k/rfgain.h (renamed from drivers/net/wireless/ath5k/rfgain.h)0
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig (renamed from drivers/net/wireless/ath9k/Kconfig)1
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile (renamed from drivers/net/wireless/ath9k/Makefile)1
-rw-r--r--drivers/net/wireless/ath/ath9k/ahb.c (renamed from drivers/net/wireless/ath9k/ahb.c)0
-rw-r--r--drivers/net/wireless/ath/ath9k/ani.c (renamed from drivers/net/wireless/ath9k/ani.c)8
-rw-r--r--drivers/net/wireless/ath/ath9k/ani.h (renamed from drivers/net/wireless/ath9k/ani.h)0
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h (renamed from drivers/net/wireless/ath9k/ath9k.h)119
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c (renamed from drivers/net/wireless/ath9k/beacon.c)124
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c (renamed from drivers/net/wireless/ath9k/calib.c)129
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h (renamed from drivers/net/wireless/ath9k/calib.h)33
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c (renamed from drivers/net/wireless/ath9k/debug.c)3
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h (renamed from drivers/net/wireless/ath9k/debug.h)25
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c (renamed from drivers/net/wireless/ath9k/eeprom.c)75
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.h (renamed from drivers/net/wireless/ath9k/eeprom.h)4
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c (renamed from drivers/net/wireless/ath9k/hw.c)269
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h (renamed from drivers/net/wireless/ath9k/hw.h)95
-rw-r--r--drivers/net/wireless/ath/ath9k/initvals.h (renamed from drivers/net/wireless/ath9k/initvals.h)0
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c (renamed from drivers/net/wireless/ath9k/mac.c)63
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.h (renamed from drivers/net/wireless/ath9k/mac.h)0
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c (renamed from drivers/net/wireless/ath9k/main.c)664
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c (renamed from drivers/net/wireless/ath9k/pci.c)0
-rw-r--r--drivers/net/wireless/ath/ath9k/phy.c (renamed from drivers/net/wireless/ath9k/phy.c)11
-rw-r--r--drivers/net/wireless/ath/ath9k/phy.h (renamed from drivers/net/wireless/ath9k/phy.h)5
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c (renamed from drivers/net/wireless/ath9k/rc.c)96
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.h (renamed from drivers/net/wireless/ath9k/rc.h)4
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c (renamed from drivers/net/wireless/ath9k/recv.c)279
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h (renamed from drivers/net/wireless/ath9k/reg.h)0
-rw-r--r--drivers/net/wireless/ath/ath9k/virtual.c (renamed from drivers/net/wireless/ath9k/virtual.c)0
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c (renamed from drivers/net/wireless/ath9k/xmit.c)86
-rw-r--r--drivers/net/wireless/ath/main.c22
-rw-r--r--drivers/net/wireless/ath/regd.c (renamed from drivers/net/wireless/ath9k/regd.c)251
-rw-r--r--drivers/net/wireless/ath/regd.h (renamed from drivers/net/wireless/ath9k/regd.h)40
-rw-r--r--drivers/net/wireless/ath/regd_common.h (renamed from drivers/net/wireless/ath9k/regd_common.h)0
-rw-r--r--drivers/net/wireless/atmel_cs.c2
-rw-r--r--drivers/net/wireless/b43/Kconfig8
-rw-r--r--drivers/net/wireless/b43/b43.h8
-rw-r--r--drivers/net/wireless/b43/main.c145
-rw-r--r--drivers/net/wireless/b43legacy/Kconfig8
-rw-r--r--drivers/net/wireless/b43legacy/b43legacy.h12
-rw-r--r--drivers/net/wireless/b43legacy/main.c329
-rw-r--r--drivers/net/wireless/b43legacy/pio.c2
-rw-r--r--drivers/net/wireless/b43legacy/xmit.c2
-rw-r--r--drivers/net/wireless/b43legacy/xmit.h4
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c2
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c8
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c54
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_module.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-led.c70
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c369
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c101
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000-hw.h12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c183
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c591
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c1255
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h21
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c1119
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h99
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c191
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h57
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c155
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h253
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c233
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h39
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c70
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c221
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c29
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c1225
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Kconfig24
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Makefile5
-rw-r--r--drivers/net/wireless/iwmc3200wifi/bus.h57
-rw-r--r--drivers/net/wireless/iwmc3200wifi/cfg80211.c409
-rw-r--r--drivers/net/wireless/iwmc3200wifi/cfg80211.h31
-rw-r--r--drivers/net/wireless/iwmc3200wifi/commands.c920
-rw-r--r--drivers/net/wireless/iwmc3200wifi/commands.h419
-rw-r--r--drivers/net/wireless/iwmc3200wifi/debug.h124
-rw-r--r--drivers/net/wireless/iwmc3200wifi/debugfs.c453
-rw-r--r--drivers/net/wireless/iwmc3200wifi/eeprom.c187
-rw-r--r--drivers/net/wireless/iwmc3200wifi/eeprom.h114
-rw-r--r--drivers/net/wireless/iwmc3200wifi/fw.c388
-rw-r--r--drivers/net/wireless/iwmc3200wifi/fw.h100
-rw-r--r--drivers/net/wireless/iwmc3200wifi/hal.c464
-rw-r--r--drivers/net/wireless/iwmc3200wifi/hal.h236
-rw-r--r--drivers/net/wireless/iwmc3200wifi/iwm.h350
-rw-r--r--drivers/net/wireless/iwmc3200wifi/lmac.h457
-rw-r--r--drivers/net/wireless/iwmc3200wifi/main.c680
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c172
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rfkill.c88
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rx.c1431
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rx.h60
-rw-r--r--drivers/net/wireless/iwmc3200wifi/sdio.c516
-rw-r--r--drivers/net/wireless/iwmc3200wifi/sdio.h67
-rw-r--r--drivers/net/wireless/iwmc3200wifi/tx.c492
-rw-r--r--drivers/net/wireless/iwmc3200wifi/umac.h744
-rw-r--r--drivers/net/wireless/iwmc3200wifi/wext.c723
-rw-r--r--drivers/net/wireless/libertas/cmd.c26
-rw-r--r--drivers/net/wireless/libertas/defs.h21
-rw-r--r--drivers/net/wireless/libertas/dev.h3
-rw-r--r--drivers/net/wireless/libertas/host.h5
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h28
-rw-r--r--drivers/net/wireless/libertas/if_cs.c34
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c160
-rw-r--r--drivers/net/wireless/libertas/if_sdio.h10
-rw-r--r--drivers/net/wireless/libertas/if_spi.c13
-rw-r--r--drivers/net/wireless/libertas/if_usb.c3
-rw-r--r--drivers/net/wireless/libertas/main.c64
-rw-r--r--drivers/net/wireless/libertas/rx.c48
-rw-r--r--drivers/net/wireless/libertas/tx.c8
-rw-r--r--drivers/net/wireless/libertas/types.h2
-rw-r--r--drivers/net/wireless/libertas_tf/if_usb.c3
-rw-r--r--drivers/net/wireless/libertas_tf/main.c56
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c82
-rw-r--r--drivers/net/wireless/mwl8k.c20
-rw-r--r--drivers/net/wireless/p54/p54.h74
-rw-r--r--drivers/net/wireless/p54/p54common.c302
-rw-r--r--drivers/net/wireless/p54/p54spi.c175
-rw-r--r--drivers/net/wireless/p54/p54usb.c314
-rw-r--r--drivers/net/wireless/p54/p54usb.h16
-rw-r--r--drivers/net/wireless/ray_cs.c2
-rw-r--r--drivers/net/wireless/rndis_wlan.c870
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig17
-rw-r--r--drivers/net/wireless/rt2x00/Makefile2
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c33
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c33
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c20
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c3066
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.h1945
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h52
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00crypto.c89
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c134
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00ht.c69
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h67
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00link.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c88
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c16
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c48
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h53
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c36
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.h6
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c32
-rw-r--r--drivers/net/wireless/rtl818x/Makefile2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180_dev.c33
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187.h7
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c69
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_leds.c218
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_leds.h57
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/net/wireless/wavelan_cs.c2
-rw-r--r--drivers/net/wireless/wl12xx/Kconfig11
-rw-r--r--drivers/net/wireless/wl12xx/Makefile4
-rw-r--r--drivers/net/wireless/wl12xx/acx.c689
-rw-r--r--drivers/net/wireless/wl12xx/acx.h1245
-rw-r--r--drivers/net/wireless/wl12xx/boot.c295
-rw-r--r--drivers/net/wireless/wl12xx/boot.h40
-rw-r--r--drivers/net/wireless/wl12xx/cmd.c353
-rw-r--r--drivers/net/wireless/wl12xx/cmd.h265
-rw-r--r--drivers/net/wireless/wl12xx/debugfs.c508
-rw-r--r--drivers/net/wireless/wl12xx/debugfs.h33
-rw-r--r--drivers/net/wireless/wl12xx/event.c127
-rw-r--r--drivers/net/wireless/wl12xx/event.h121
-rw-r--r--drivers/net/wireless/wl12xx/init.c200
-rw-r--r--drivers/net/wireless/wl12xx/init.h40
-rw-r--r--drivers/net/wireless/wl12xx/main.c1358
-rw-r--r--drivers/net/wireless/wl12xx/ps.c151
-rw-r--r--drivers/net/wireless/wl12xx/ps.h36
-rw-r--r--drivers/net/wireless/wl12xx/reg.h745
-rw-r--r--drivers/net/wireless/wl12xx/rx.c208
-rw-r--r--drivers/net/wireless/wl12xx/rx.h122
-rw-r--r--drivers/net/wireless/wl12xx/spi.c358
-rw-r--r--drivers/net/wireless/wl12xx/spi.h109
-rw-r--r--drivers/net/wireless/wl12xx/tx.c557
-rw-r--r--drivers/net/wireless/wl12xx/tx.h215
-rw-r--r--drivers/net/wireless/wl12xx/wl1251.c709
-rw-r--r--drivers/net/wireless/wl12xx/wl1251.h165
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h409
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx_80211.h156
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c86
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h2
-rw-r--r--drivers/net/xen-netfront.c10
-rw-r--r--drivers/of/Kconfig6
-rw-r--r--drivers/of/Makefile1
-rw-r--r--drivers/of/base.c25
-rw-r--r--drivers/of/of_mdio.c139
-rw-r--r--drivers/oprofile/cpu_buffer.c8
-rw-r--r--drivers/parisc/eisa.c2
-rw-r--r--drivers/parisc/iosapic.c6
-rw-r--r--drivers/parisc/sba_iommu.c6
-rw-r--r--drivers/parport/parport_gsc.c4
-rw-r--r--drivers/pci/Makefile1
-rw-r--r--drivers/pci/bus.c7
-rw-r--r--drivers/pci/dmar.c46
-rw-r--r--drivers/pci/hotplug/Kconfig2
-rw-r--r--drivers/pci/hotplug/cpqphp.h167
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c1101
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c371
-rw-r--r--drivers/pci/hotplug/cpqphp_nvram.c97
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c599
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c1
-rw-r--r--drivers/pci/htirq.c4
-rw-r--r--drivers/pci/intel-iommu.c329
-rw-r--r--drivers/pci/intr_remapping.c62
-rw-r--r--drivers/pci/msi.c2
-rw-r--r--drivers/pci/msi.h14
-rw-r--r--drivers/pci/pci.c8
-rw-r--r--drivers/pci/pcie/portdrv_core.c2
-rw-r--r--drivers/pci/probe.c9
-rw-r--r--drivers/pci/quirks.c26
-rw-r--r--drivers/pci/search.c30
-rw-r--r--drivers/pci/setup-bus.c53
-rw-r--r--drivers/pci/setup-res.c49
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/pcmcia/Makefile1
-rw-r--r--drivers/pcmcia/ds.c8
-rw-r--r--drivers/pcmcia/pxa2xx_stargate2.c174
-rw-r--r--drivers/platform/x86/Kconfig14
-rw-r--r--drivers/platform/x86/Makefile1
-rw-r--r--drivers/platform/x86/eeepc-laptop.c87
-rw-r--r--drivers/platform/x86/oqo-wmi.c941
-rw-r--r--drivers/platform/x86/toshiba_acpi.c206
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c2
-rw-r--r--drivers/rapidio/rio-scan.c6
-rw-r--r--drivers/regulator/Kconfig26
-rw-r--r--drivers/regulator/Makefile3
-rw-r--r--drivers/regulator/da903x.c2
-rw-r--r--drivers/regulator/fixed.c18
-rw-r--r--drivers/regulator/lp3971.c562
-rw-r--r--drivers/regulator/max1586.c249
-rw-r--r--drivers/regulator/pcf50633-regulator.c2
-rw-r--r--drivers/regulator/userspace-consumer.c200
-rw-r--r--drivers/regulator/virtual.c1
-rw-r--r--drivers/regulator/wm8350-regulator.c1
-rw-r--r--drivers/regulator/wm8400-regulator.c8
-rw-r--r--drivers/rtc/Kconfig21
-rw-r--r--drivers/rtc/Makefile2
-rw-r--r--drivers/rtc/rtc-ep93xx.c149
-rw-r--r--drivers/rtc/rtc-msm6242.c268
-rw-r--r--drivers/rtc/rtc-rp5c01.c222
-rw-r--r--drivers/s390/block/dasd.c37
-rw-r--r--drivers/s390/block/dasd_diag.c5
-rw-r--r--drivers/s390/block/dasd_eckd.c6
-rw-r--r--drivers/s390/block/dasd_fba.c7
-rw-r--r--drivers/s390/block/dcssblk.c2
-rw-r--r--drivers/s390/block/xpram.c2
-rw-r--r--drivers/s390/char/con3215.c16
-rw-r--r--drivers/s390/char/con3270.c38
-rw-r--r--drivers/s390/char/raw3270.c16
-rw-r--r--drivers/s390/char/tape_34xx.c4
-rw-r--r--drivers/s390/char/tape_3590.c4
-rw-r--r--drivers/s390/char/tape_block.c26
-rw-r--r--drivers/s390/char/tape_core.c22
-rw-r--r--drivers/s390/char/tty3270.c57
-rw-r--r--drivers/s390/char/vmlogrdr.c12
-rw-r--r--drivers/s390/char/vmur.c16
-rw-r--r--drivers/s390/cio/cio.c2
-rw-r--r--drivers/s390/cio/device_ops.c24
-rw-r--r--drivers/s390/cio/qdio_main.c46
-rw-r--r--drivers/s390/cio/qdio_perf.c12
-rw-r--r--drivers/s390/cio/qdio_perf.h10
-rw-r--r--drivers/s390/kvm/kvm_virtio.c43
-rw-r--r--drivers/s390/net/claw.c52
-rw-r--r--drivers/s390/net/ctcm_main.c6
-rw-r--r--drivers/s390/net/lcs.c20
-rw-r--r--drivers/s390/net/lcs.h4
-rw-r--r--drivers/s390/net/netiucv.c47
-rw-r--r--drivers/s390/net/qeth_core_main.c3
-rw-r--r--drivers/s390/net/qeth_core_mpc.c2
-rw-r--r--drivers/s390/net/qeth_core_mpc.h2
-rw-r--r--drivers/s390/net/qeth_l2_main.c30
-rw-r--r--drivers/s390/net/qeth_l3_main.c24
-rw-r--r--drivers/s390/scsi/zfcp_aux.c10
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c30
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c10
-rw-r--r--drivers/s390/scsi/zfcp_def.h25
-rw-r--r--drivers/s390/scsi/zfcp_erp.c10
-rw-r--r--drivers/s390/scsi/zfcp_ext.h7
-rw-r--r--drivers/s390/scsi/zfcp_fc.c194
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c32
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c28
-rw-r--r--drivers/sbus/char/jsflash.c26
-rw-r--r--drivers/scsi/3w-9xxx.c3
-rw-r--r--drivers/scsi/3w-xxxx.c5
-rw-r--r--drivers/scsi/3w-xxxx.h2
-rw-r--r--drivers/scsi/Kconfig41
-rw-r--r--drivers/scsi/Makefile3
-rw-r--r--drivers/scsi/NCR_D700.c2
-rw-r--r--drivers/scsi/aha1740.c2
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i.h1
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_iscsi.c25
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_offload.c23
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_offload.h3
-rw-r--r--drivers/scsi/device_handler/scsi_dh_rdac.c6
-rw-r--r--drivers/scsi/dpt/osd_util.h2
-rw-r--r--drivers/scsi/eata.c24
-rw-r--r--drivers/scsi/fcoe/fcoe.c202
-rw-r--r--drivers/scsi/fcoe/libfcoe.c10
-rw-r--r--drivers/scsi/fnic/Makefile15
-rw-r--r--drivers/scsi/fnic/cq_desc.h78
-rw-r--r--drivers/scsi/fnic/cq_enet_desc.h167
-rw-r--r--drivers/scsi/fnic/cq_exch_desc.h182
-rw-r--r--drivers/scsi/fnic/fcpio.h780
-rw-r--r--drivers/scsi/fnic/fnic.h265
-rw-r--r--drivers/scsi/fnic/fnic_attrs.c56
-rw-r--r--drivers/scsi/fnic/fnic_fcs.c742
-rw-r--r--drivers/scsi/fnic/fnic_io.h67
-rw-r--r--drivers/scsi/fnic/fnic_isr.c332
-rw-r--r--drivers/scsi/fnic/fnic_main.c943
-rw-r--r--drivers/scsi/fnic/fnic_res.c444
-rw-r--r--drivers/scsi/fnic/fnic_res.h197
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c1850
-rw-r--r--drivers/scsi/fnic/rq_enet_desc.h58
-rw-r--r--drivers/scsi/fnic/vnic_cq.c85
-rw-r--r--drivers/scsi/fnic/vnic_cq.h121
-rw-r--r--drivers/scsi/fnic/vnic_cq_copy.h62
-rw-r--r--drivers/scsi/fnic/vnic_dev.c690
-rw-r--r--drivers/scsi/fnic/vnic_dev.h161
-rw-r--r--drivers/scsi/fnic/vnic_devcmd.h281
-rw-r--r--drivers/scsi/fnic/vnic_intr.c60
-rw-r--r--drivers/scsi/fnic/vnic_intr.h118
-rw-r--r--drivers/scsi/fnic/vnic_nic.h69
-rw-r--r--drivers/scsi/fnic/vnic_resource.h61
-rw-r--r--drivers/scsi/fnic/vnic_rq.c196
-rw-r--r--drivers/scsi/fnic/vnic_rq.h235
-rw-r--r--drivers/scsi/fnic/vnic_scsi.h99
-rw-r--r--drivers/scsi/fnic/vnic_stats.h68
-rw-r--r--drivers/scsi/fnic/vnic_wq.c182
-rw-r--r--drivers/scsi/fnic/vnic_wq.h175
-rw-r--r--drivers/scsi/fnic/vnic_wq_copy.c117
-rw-r--r--drivers/scsi/fnic/vnic_wq_copy.h128
-rw-r--r--drivers/scsi/fnic/wq_enet_desc.h96
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c9
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c2
-rw-r--r--drivers/scsi/ipr.c5
-rw-r--r--drivers/scsi/libfc/fc_rport.c6
-rw-r--r--drivers/scsi/libiscsi.c468
-rw-r--r--drivers/scsi/libiscsi_tcp.c18
-rw-r--r--drivers/scsi/libsas/sas_expander.c16
-rw-r--r--drivers/scsi/libsas/sas_host_smp.c49
-rw-r--r--drivers/scsi/libsrp.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c26
-rw-r--r--drivers/scsi/megaraid.h2
-rw-r--r--drivers/scsi/megaraid/mbox_defs.h2
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.h7
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c32
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c363
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_transport.c59
-rw-r--r--drivers/scsi/mvsas.c3222
-rw-r--r--drivers/scsi/mvsas/Kconfig42
-rw-r--r--drivers/scsi/mvsas/Makefile32
-rw-r--r--drivers/scsi/mvsas/mv_64xx.c793
-rw-r--r--drivers/scsi/mvsas/mv_64xx.h151
-rw-r--r--drivers/scsi/mvsas/mv_94xx.c672
-rw-r--r--drivers/scsi/mvsas/mv_94xx.h222
-rw-r--r--drivers/scsi/mvsas/mv_chips.h280
-rw-r--r--drivers/scsi/mvsas/mv_defs.h502
-rw-r--r--drivers/scsi/mvsas/mv_init.c703
-rw-r--r--drivers/scsi/mvsas/mv_sas.c2154
-rw-r--r--drivers/scsi/mvsas/mv_sas.h406
-rw-r--r--drivers/scsi/osd/Kbuild25
-rwxr-xr-xdrivers/scsi/osd/Makefile37
-rw-r--r--drivers/scsi/osd/osd_initiator.c155
-rw-r--r--drivers/scsi/osd/osd_uld.c66
-rw-r--r--drivers/scsi/qla1280.c387
-rw-r--r--drivers/scsi/qla1280.h3
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c81
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h34
-rw-r--r--drivers/scsi/qla2xxx/qla_fw.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h29
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c90
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c59
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c236
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c90
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c118
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c233
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c38
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi_debug.c2
-rw-r--r--drivers/scsi/scsi_lib.c101
-rw-r--r--drivers/scsi/scsi_scan.c5
-rw-r--r--drivers/scsi/scsi_tgt_lib.c2
-rw-r--r--drivers/scsi/scsi_transport_fc.c614
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c53
-rw-r--r--drivers/scsi/scsi_transport_sas.c4
-rw-r--r--drivers/scsi/sd.c26
-rw-r--r--drivers/scsi/sd_dif.c2
-rw-r--r--drivers/scsi/sg.c18
-rw-r--r--drivers/scsi/sr.c17
-rw-r--r--drivers/scsi/st.c8
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c66
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c49
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h2
-rw-r--r--drivers/scsi/u14-34f.c22
-rw-r--r--drivers/serial/8250_pci.c3
-rw-r--r--drivers/serial/icom.c2
-rw-r--r--drivers/serial/imx.c13
-rw-r--r--drivers/serial/of_serial.c4
-rw-r--r--drivers/serial/serial_cs.c22
-rw-r--r--drivers/serial/sh-sci.c385
-rw-r--r--drivers/serial/sh-sci.h42
-rw-r--r--drivers/sh/intc.c17
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c1
-rw-r--r--drivers/staging/Kconfig4
-rw-r--r--drivers/staging/Makefile2
-rw-r--r--drivers/staging/agnx/debug.h9
-rw-r--r--drivers/staging/agnx/pci.c62
-rw-r--r--drivers/staging/agnx/phy.c4
-rw-r--r--drivers/staging/agnx/phy.h2
-rw-r--r--drivers/staging/agnx/sta.c2
-rw-r--r--drivers/staging/agnx/sta.h2
-rw-r--r--drivers/staging/altpciechdma/altpciechdma.c18
-rw-r--r--drivers/staging/android/Kconfig6
-rw-r--r--drivers/staging/android/Makefile1
-rw-r--r--drivers/staging/android/binder.c436
-rw-r--r--drivers/staging/android/logger.c12
-rw-r--r--drivers/staging/android/lowmemorykiller.c101
-rw-r--r--drivers/staging/android/ram_console.c9
-rw-r--r--drivers/staging/android/timed_gpio.c98
-rw-r--r--drivers/staging/android/timed_gpio.h4
-rw-r--r--drivers/staging/android/timed_output.c121
-rw-r--r--drivers/staging/android/timed_output.h37
-rw-r--r--drivers/staging/b3dfg/b3dfg.c1
-rw-r--r--drivers/staging/comedi/Kconfig9
-rw-r--r--drivers/staging/comedi/Makefile5
-rw-r--r--drivers/staging/comedi/comedi.h1
-rw-r--r--drivers/staging/comedi/comedi_fops.c504
-rw-r--r--drivers/staging/comedi/comedi_ksyms.c7
-rw-r--r--drivers/staging/comedi/comedi_rt.h149
-rw-r--r--drivers/staging/comedi/comedidev.h15
-rw-r--r--drivers/staging/comedi/drivers.c19
-rw-r--r--drivers/staging/comedi/drivers/8253.h50
-rw-r--r--drivers/staging/comedi/drivers/8255.c23
-rw-r--r--drivers/staging/comedi/drivers/8255.h14
-rw-r--r--drivers/staging/comedi/drivers/Makefile4
-rw-r--r--drivers/staging/comedi/drivers/acl7225b.c22
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c372
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h32
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c402
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h36
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c309
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h8
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c1012
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h188
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c204
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h8
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c1314
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h70
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c230
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h6
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c432
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h8
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c198
-rw-r--r--drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h8
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c119
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h6
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h12
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_common.c191
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_common.h356
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_eeprom.c438
-rw-r--r--drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h43
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c169
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h2
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c214
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h34
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c106
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h29
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c532
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h4
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c174
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h29
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c507
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h52
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c134
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c136
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h26
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c176
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h32
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c174
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h26
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c1055
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h142
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c1701
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h176
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c225
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h44
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c274
-rw-r--r--drivers/staging/comedi/drivers/addi_apci_035.c2
-rw-r--r--drivers/staging/comedi/drivers/adl_pci6208.c177
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7296.c22
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7432.c32
-rw-r--r--drivers/staging/comedi/drivers/adl_pci8164.c325
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9111.c135
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9118.c648
-rw-r--r--drivers/staging/comedi/drivers/adq12b.c82
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1710.c348
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1723.c122
-rw-r--r--drivers/staging/comedi/drivers/adv_pci_dio.c112
-rw-r--r--drivers/staging/comedi/drivers/aio_aio12_8.c46
-rw-r--r--drivers/staging/comedi/drivers/aio_iiro_16.c44
-rw-r--r--drivers/staging/comedi/drivers/am9513.h16
-rw-r--r--drivers/staging/comedi/drivers/amcc_s5933.h10
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c226
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc236.c138
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc263.c82
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci224.c131
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci230.c306
-rw-r--r--drivers/staging/comedi/drivers/c6xdigio.c140
-rw-r--r--drivers/staging/comedi/drivers/cb_das16_cs.c160
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c840
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c1755
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidda.c323
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidio.c75
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdas.c187
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdda.c71
-rw-r--r--drivers/staging/comedi/drivers/comedi_bond.c2
-rw-r--r--drivers/staging/comedi/drivers/comedi_fc.c2
-rw-r--r--drivers/staging/comedi/drivers/comedi_parport.c9
-rw-r--r--drivers/staging/comedi/drivers/comedi_rt_timer.c728
-rw-r--r--drivers/staging/comedi/drivers/comedi_test.c2
-rw-r--r--drivers/staging/comedi/drivers/contec_pci_dio.c46
-rw-r--r--drivers/staging/comedi/drivers/daqboard2000.c230
-rw-r--r--drivers/staging/comedi/drivers/das08.c542
-rw-r--r--drivers/staging/comedi/drivers/das08.h24
-rw-r--r--drivers/staging/comedi/drivers/das08_cs.c65
-rw-r--r--drivers/staging/comedi/drivers/das16.c816
-rw-r--r--drivers/staging/comedi/drivers/das16m1.c152
-rw-r--r--drivers/staging/comedi/drivers/das1800.c689
-rw-r--r--drivers/staging/comedi/drivers/das6402.c47
-rw-r--r--drivers/staging/comedi/drivers/das800.c213
-rw-r--r--drivers/staging/comedi/drivers/dmm32at.c128
-rw-r--r--drivers/staging/comedi/drivers/dt2801.c214
-rw-r--r--drivers/staging/comedi/drivers/dt2811.c92
-rw-r--r--drivers/staging/comedi/drivers/dt2814.c48
-rw-r--r--drivers/staging/comedi/drivers/dt2815.c36
-rw-r--r--drivers/staging/comedi/drivers/dt2817.c27
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c391
-rw-r--r--drivers/staging/comedi/drivers/dt3000.c220
-rw-r--r--drivers/staging/comedi/drivers/fl512.c42
-rw-r--r--drivers/staging/comedi/drivers/gsc_hpdi.c234
-rw-r--r--drivers/staging/comedi/drivers/icp_multi.c15
-rw-r--r--drivers/staging/comedi/drivers/icp_multi.h12
-rw-r--r--drivers/staging/comedi/drivers/ii_pci20kc.c83
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c211
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.h8
-rw-r--r--drivers/staging/comedi/drivers/ke_counter.c47
-rw-r--r--drivers/staging/comedi/drivers/me4000.c9
-rw-r--r--drivers/staging/comedi/drivers/me_daq.c1
-rw-r--r--drivers/staging/comedi/drivers/mite.c28
-rw-r--r--drivers/staging/comedi/drivers/mite.h2
-rw-r--r--drivers/staging/comedi/drivers/mpc624.c218
-rw-r--r--drivers/staging/comedi/drivers/mpc8260cpm.c32
-rw-r--r--drivers/staging/comedi/drivers/multiq3.c43
-rw-r--r--drivers/staging/comedi/drivers/ni_6527.c73
-rw-r--r--drivers/staging/comedi/drivers/ni_65xx.c251
-rw-r--r--drivers/staging/comedi/drivers/ni_660x.c232
-rw-r--r--drivers/staging/comedi/drivers/ni_670x.c84
-rw-r--r--drivers/staging/comedi/drivers/ni_at_a2150.c275
-rw-r--r--drivers/staging/comedi/drivers/ni_at_ao.c90
-rw-r--r--drivers/staging/comedi/drivers/ni_atmio.c327
-rw-r--r--drivers/staging/comedi/drivers/ni_atmio16d.c117
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_700.c113
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_dio24.c110
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c693
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.h50
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc_cs.c105
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_common.c970
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_cs.c256
-rw-r--r--drivers/staging/comedi/drivers/ni_pcidio.c188
-rw-r--r--drivers/staging/comedi/drivers/ni_pcimio.c139
-rw-r--r--drivers/staging/comedi/drivers/ni_stc.h148
-rw-r--r--drivers/staging/comedi/drivers/ni_tio.c18
-rw-r--r--drivers/staging/comedi/drivers/ni_tio.h18
-rw-r--r--drivers/staging/comedi/drivers/ni_tio_internal.h14
-rw-r--r--drivers/staging/comedi/drivers/ni_tiocmd.c40
-rw-r--r--drivers/staging/comedi/drivers/pcl711.c68
-rw-r--r--drivers/staging/comedi/drivers/pcl724.c54
-rw-r--r--drivers/staging/comedi/drivers/pcl725.c24
-rw-r--r--drivers/staging/comedi/drivers/pcl726.c72
-rw-r--r--drivers/staging/comedi/drivers/pcl730.c34
-rw-r--r--drivers/staging/comedi/drivers/pcl812.c320
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c417
-rw-r--r--drivers/staging/comedi/drivers/pcl818.c574
-rw-r--r--drivers/staging/comedi/drivers/pcm3724.c67
-rw-r--r--drivers/staging/comedi/drivers/pcm3730.c28
-rw-r--r--drivers/staging/comedi/drivers/pcmad.c42
-rw-r--r--drivers/staging/comedi/drivers/pcmda12.c46
-rw-r--r--drivers/staging/comedi/drivers/pcmmio.c163
-rw-r--r--drivers/staging/comedi/drivers/pcmuio.c137
-rw-r--r--drivers/staging/comedi/drivers/plx9080.h8
-rw-r--r--drivers/staging/comedi/drivers/poc.c104
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c79
-rw-r--r--drivers/staging/comedi/drivers/rtd520.c78
-rw-r--r--drivers/staging/comedi/drivers/rti800.c77
-rw-r--r--drivers/staging/comedi/drivers/rti802.c24
-rw-r--r--drivers/staging/comedi/drivers/s526.c386
-rw-r--r--drivers/staging/comedi/drivers/s626.c282
-rw-r--r--drivers/staging/comedi/drivers/s626.h2
-rw-r--r--drivers/staging/comedi/drivers/serial2002.c100
-rw-r--r--drivers/staging/comedi/drivers/skel.c90
-rw-r--r--drivers/staging/comedi/drivers/ssv_dnp.c49
-rw-r--r--drivers/staging/comedi/drivers/unioxx5.c86
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c166
-rw-r--r--drivers/staging/comedi/drivers/usbduxfast.c202
-rw-r--r--drivers/staging/comedi/drivers/vmk80xx.c1399
-rw-r--r--drivers/staging/comedi/interrupt.h51
-rw-r--r--drivers/staging/comedi/kcomedilib/data.c4
-rw-r--r--drivers/staging/comedi/kcomedilib/kcomedilib_main.c33
-rw-r--r--drivers/staging/comedi/kcomedilib/ksyms.c49
-rw-r--r--drivers/staging/comedi/range.c9
-rw-r--r--drivers/staging/comedi/rt.c411
-rw-r--r--drivers/staging/comedi/rt_pend_tq.c113
-rw-r--r--drivers/staging/comedi/rt_pend_tq.h10
-rw-r--r--drivers/staging/cpc-usb/Kconfig4
-rw-r--r--drivers/staging/cpc-usb/Makefile3
-rw-r--r--drivers/staging/cpc-usb/TODO9
-rw-r--r--drivers/staging/cpc-usb/cpc-usb_drv.c1191
-rw-r--r--drivers/staging/cpc-usb/cpc.h440
-rw-r--r--drivers/staging/cpc-usb/cpc_int.h85
-rw-r--r--drivers/staging/cpc-usb/cpcusb.h86
-rw-r--r--drivers/staging/cpc-usb/sja2m16c.h41
-rw-r--r--drivers/staging/cpc-usb/sja2m16c_2.c452
-rw-r--r--drivers/staging/epl/EplSdoUdpu.c3
-rw-r--r--drivers/staging/epl/ShbIpc-LinuxKernel.c8
-rw-r--r--drivers/staging/frontier/alphatrack.c1
-rw-r--r--drivers/staging/frontier/tranzport.c1
-rw-r--r--drivers/staging/go7007/go7007.txt4
-rw-r--r--drivers/staging/heci/heci.h1
-rw-r--r--drivers/staging/heci/heci_data_structures.h1
-rw-r--r--drivers/staging/heci/heci_interface.h1
-rw-r--r--drivers/staging/meilhaus/me0600_ext_irq.c5
-rw-r--r--drivers/staging/meilhaus/me0900_di.c1
-rw-r--r--drivers/staging/meilhaus/me1400_device.c1
-rw-r--r--drivers/staging/meilhaus/me1400_ext_irq.c5
-rw-r--r--drivers/staging/meilhaus/me4600_ai.c4
-rw-r--r--drivers/staging/meilhaus/me4600_ai.h1
-rw-r--r--drivers/staging/meilhaus/me4600_ao.c6
-rw-r--r--drivers/staging/meilhaus/me4600_ext_irq.c5
-rw-r--r--drivers/staging/meilhaus/me6000_ao.c4
-rw-r--r--drivers/staging/meilhaus/me6000_ao.h1
-rw-r--r--drivers/staging/meilhaus/me8100_di.c5
-rw-r--r--drivers/staging/meilhaus/me8200_di.c9
-rw-r--r--drivers/staging/meilhaus/me8200_do.c5
-rw-r--r--drivers/staging/meilhaus/memain.c182
-rw-r--r--drivers/staging/meilhaus/memain.h194
-rw-r--r--drivers/staging/otus/80211core/ccmd.c2982
-rw-r--r--drivers/staging/panel/lcd-panel-cgram.txt2
-rw-r--r--drivers/staging/pohmelfs/crypto.c3
-rw-r--r--drivers/staging/pohmelfs/dir.c9
-rw-r--r--drivers/staging/pohmelfs/inode.c15
-rw-r--r--drivers/staging/pohmelfs/net.c7
-rw-r--r--drivers/staging/pohmelfs/netfs.h65
-rw-r--r--drivers/staging/pohmelfs/trans.c7
-rw-r--r--drivers/staging/rspiusb/rspiusb.c14
-rw-r--r--drivers/staging/rt2860/2860_main_dev.c41
-rw-r--r--drivers/staging/rt2860/Makefile5
-rw-r--r--drivers/staging/rt2860/ap.h40
-rw-r--r--drivers/staging/rt2860/chlist.h56
-rw-r--r--drivers/staging/rt2860/common/2860_rtmp_init.c25
-rw-r--r--drivers/staging/rt2860/common/action.c444
-rw-r--r--drivers/staging/rt2860/common/action.h7
-rw-r--r--drivers/staging/rt2860/common/ba_action.c179
-rw-r--r--drivers/staging/rt2860/common/cmm_data.c647
-rw-r--r--drivers/staging/rt2860/common/cmm_data_2860.c105
-rw-r--r--drivers/staging/rt2860/common/cmm_info.c273
-rw-r--r--drivers/staging/rt2860/common/cmm_sanity.c401
-rw-r--r--drivers/staging/rt2860/common/cmm_sync.c113
-rw-r--r--drivers/staging/rt2860/common/cmm_wpa.c28
-rw-r--r--drivers/staging/rt2860/common/dfs.c21
-rw-r--r--drivers/staging/rt2860/common/eeprom.c1268
-rw-r--r--drivers/staging/rt2860/common/md5.c12
-rw-r--r--drivers/staging/rt2860/common/mlme.c1890
-rw-r--r--drivers/staging/rt2860/common/netif_block.c144
-rw-r--r--drivers/staging/rt2860/common/netif_block.h58
-rw-r--r--drivers/staging/rt2860/common/rtmp_init.c1251
-rw-r--r--drivers/staging/rt2860/common/rtmp_tkip.c21
-rw-r--r--drivers/staging/rt2860/common/rtmp_wep.c2
-rw-r--r--drivers/staging/rt2860/common/spectrum.c57
-rw-r--r--drivers/staging/rt2860/leap.h215
-rw-r--r--drivers/staging/rt2860/mlme.h309
-rw-r--r--drivers/staging/rt2860/oid.h173
-rw-r--r--drivers/staging/rt2860/rt28xx.h1218
-rw-r--r--drivers/staging/rt2860/rt_ate.c6009
-rw-r--r--drivers/staging/rt2860/rt_ate.h347
-rw-r--r--drivers/staging/rt2860/rt_config.h33
-rw-r--r--drivers/staging/rt2860/rt_linux.c45
-rw-r--r--drivers/staging/rt2860/rt_linux.h188
-rw-r--r--drivers/staging/rt2860/rt_main_dev.c717
-rw-r--r--drivers/staging/rt2860/rt_profile.c161
-rw-r--r--drivers/staging/rt2860/rtmp.h1831
-rw-r--r--drivers/staging/rt2860/rtmp_def.h210
-rw-r--r--drivers/staging/rt2860/spectrum.h30
-rw-r--r--drivers/staging/rt2860/sta/assoc.c586
-rw-r--r--drivers/staging/rt2860/sta/auth.c14
-rw-r--r--drivers/staging/rt2860/sta/auth_rsp.c19
-rw-r--r--drivers/staging/rt2860/sta/connect.c602
-rw-r--r--drivers/staging/rt2860/sta/dls.c2197
-rw-r--r--drivers/staging/rt2860/sta/rtmp_data.c336
-rw-r--r--drivers/staging/rt2860/sta/sanity.c2
-rw-r--r--drivers/staging/rt2860/sta/sync.c290
-rw-r--r--drivers/staging/rt2860/sta/wpa.c12
-rw-r--r--drivers/staging/rt2860/sta_ioctl.c1236
-rw-r--r--drivers/staging/rt2860/wpa.h31
-rw-r--r--drivers/staging/rt2870/2870_main_dev.c264
-rw-r--r--drivers/staging/rt2870/Makefile4
-rw-r--r--drivers/staging/rt2870/aironet.h211
-rw-r--r--drivers/staging/rt2870/ap.h563
-rw-r--r--drivers/staging/rt2870/chlist.h1297
-rw-r--r--drivers/staging/rt2870/common/2870_rtmp_init.c117
-rw-r--r--drivers/staging/rt2870/common/action.c1047
-rw-r--r--drivers/staging/rt2870/common/action.h69
-rw-r--r--drivers/staging/rt2870/common/ba_action.c1799
-rw-r--r--drivers/staging/rt2870/common/cmm_data.c2732
-rw-r--r--drivers/staging/rt2870/common/cmm_data_2870.c73
-rw-r--r--drivers/staging/rt2870/common/cmm_info.c3713
-rw-r--r--drivers/staging/rt2870/common/cmm_sanity.c1664
-rw-r--r--drivers/staging/rt2870/common/cmm_sync.c712
-rw-r--r--drivers/staging/rt2870/common/cmm_wpa.c1655
-rw-r--r--drivers/staging/rt2870/common/dfs.c454
-rw-r--r--drivers/staging/rt2870/common/eeprom.c255
-rw-r--r--drivers/staging/rt2870/common/md5.c1428
-rw-r--r--drivers/staging/rt2870/common/mlme.c8610
-rw-r--r--drivers/staging/rt2870/common/netif_block.c144
-rw-r--r--drivers/staging/rt2870/common/rtmp_init.c4133
-rw-r--r--drivers/staging/rt2870/common/rtmp_tkip.c1614
-rw-r--r--drivers/staging/rt2870/common/rtmp_wep.c509
-rw-r--r--drivers/staging/rt2870/common/rtusb_bulk.c775
-rw-r--r--drivers/staging/rt2870/common/rtusb_data.c13
-rw-r--r--drivers/staging/rt2870/common/rtusb_io.c211
-rw-r--r--drivers/staging/rt2870/common/spectrum.c1877
-rw-r--r--drivers/staging/rt2870/dfs.h101
-rw-r--r--drivers/staging/rt2870/leap.h215
-rw-r--r--drivers/staging/rt2870/link_list.h135
-rw-r--r--drivers/staging/rt2870/md5.h108
-rw-r--r--drivers/staging/rt2870/mlme.h1472
-rw-r--r--drivers/staging/rt2870/netif_block.h58
-rw-r--r--drivers/staging/rt2870/oid.h1092
-rw-r--r--drivers/staging/rt2870/rt2870.h252
-rw-r--r--drivers/staging/rt2870/rt28xx.h2690
-rw-r--r--drivers/staging/rt2870/rt_ate.c6452
-rw-r--r--drivers/staging/rt2870/rt_ate.h315
-rw-r--r--drivers/staging/rt2870/rt_config.h105
-rw-r--r--drivers/staging/rt2870/rt_linux.c1096
-rw-r--r--drivers/staging/rt2870/rt_linux.h907
-rw-r--r--drivers/staging/rt2870/rt_main_dev.c1866
-rw-r--r--drivers/staging/rt2870/rt_profile.c2021
-rw-r--r--drivers/staging/rt2870/rtmp.h7587
-rw-r--r--drivers/staging/rt2870/rtmp_ckipmic.h114
-rw-r--r--drivers/staging/rt2870/rtmp_def.h1623
-rw-r--r--drivers/staging/rt2870/rtmp_type.h95
-rw-r--r--drivers/staging/rt2870/spectrum.h323
-rw-r--r--drivers/staging/rt2870/spectrum_def.h96
-rw-r--r--drivers/staging/rt2870/sta/aironet.c1313
-rw-r--r--drivers/staging/rt2870/sta/assoc.c2040
-rw-r--r--drivers/staging/rt2870/sta/auth.c475
-rw-r--r--drivers/staging/rt2870/sta/auth_rsp.c167
-rw-r--r--drivers/staging/rt2870/sta/connect.c2823
-rw-r--r--drivers/staging/rt2870/sta/dls.c2210
-rw-r--r--drivers/staging/rt2870/sta/rtmp_data.c2620
-rw-r--r--drivers/staging/rt2870/sta/sanity.c421
-rw-r--r--drivers/staging/rt2870/sta/sync.c1754
-rw-r--r--drivers/staging/rt2870/sta/wpa.c2108
-rw-r--r--drivers/staging/rt2870/sta_ioctl.c7069
-rw-r--r--drivers/staging/rt2870/sta_ioctl.c.patch18
-rw-r--r--drivers/staging/rt2870/tmp607037
-rw-r--r--drivers/staging/rt2870/tmp617037
-rw-r--r--drivers/staging/rt2870/wpa.h358
-rw-r--r--drivers/staging/rt3070/2870_main_dev.c1628
-rw-r--r--drivers/staging/rt3070/Makefile4
-rw-r--r--drivers/staging/rt3070/action.h69
-rw-r--r--drivers/staging/rt3070/aironet.h211
-rw-r--r--drivers/staging/rt3070/ap.h558
-rw-r--r--drivers/staging/rt3070/chlist.h1254
-rw-r--r--drivers/staging/rt3070/common/2870_rtmp_init.c1763
-rw-r--r--drivers/staging/rt3070/common/action.c1039
-rw-r--r--drivers/staging/rt3070/common/ba_action.c1811
-rw-r--r--drivers/staging/rt3070/common/cmm_data.c2828
-rw-r--r--drivers/staging/rt3070/common/cmm_data_2870.c981
-rw-r--r--drivers/staging/rt3070/common/cmm_info.c3396
-rw-r--r--drivers/staging/rt3070/common/cmm_sanity.c1670
-rw-r--r--drivers/staging/rt3070/common/cmm_sync.c712
-rw-r--r--drivers/staging/rt3070/common/cmm_wpa.c1607
-rw-r--r--drivers/staging/rt3070/common/dfs.c442
-rw-r--r--drivers/staging/rt3070/common/eeprom.c1499
-rw-r--r--drivers/staging/rt3070/common/md5.c1428
-rw-r--r--drivers/staging/rt3070/common/mlme.c9137
-rw-r--r--drivers/staging/rt3070/common/netif_block.c136
-rw-r--r--drivers/staging/rt3070/common/rtmp_init.c4198
-rw-r--r--drivers/staging/rt3070/common/rtmp_tkip.c1614
-rw-r--r--drivers/staging/rt3070/common/rtmp_wep.c509
-rw-r--r--drivers/staging/rt3070/common/rtusb_bulk.c1383
-rw-r--r--drivers/staging/rt3070/common/rtusb_data.c219
-rw-r--r--drivers/staging/rt3070/common/rtusb_io.c1909
-rw-r--r--drivers/staging/rt3070/common/spectrum.c1877
-rw-r--r--drivers/staging/rt3070/dfs.h101
-rw-r--r--drivers/staging/rt3070/leap.h215
-rw-r--r--drivers/staging/rt3070/link_list.h135
-rw-r--r--drivers/staging/rt3070/md5.h108
-rw-r--r--drivers/staging/rt3070/mlme.h1469
-rw-r--r--drivers/staging/rt3070/netif_block.h58
-rw-r--r--drivers/staging/rt3070/oid.h1143
-rw-r--r--drivers/staging/rt3070/rt2870.h757
-rw-r--r--drivers/staging/rt3070/rt28xx.h2726
-rw-r--r--drivers/staging/rt3070/rt_ate.c6506
-rw-r--r--drivers/staging/rt3070/rt_ate.h294
-rw-r--r--drivers/staging/rt3070/rt_config.h122
-rw-r--r--drivers/staging/rt3070/rt_linux.c1064
-rw-r--r--drivers/staging/rt3070/rt_linux.h888
-rw-r--r--drivers/staging/rt3070/rt_main_dev.c1802
-rw-r--r--drivers/staging/rt3070/rt_profile.c2042
-rw-r--r--drivers/staging/rt3070/rtmp.h7729
-rw-r--r--drivers/staging/rt3070/rtmp_ckipmic.h114
-rw-r--r--drivers/staging/rt3070/rtmp_def.h1560
-rw-r--r--drivers/staging/rt3070/rtmp_type.h96
-rw-r--r--drivers/staging/rt3070/spectrum.h323
-rw-r--r--drivers/staging/rt3070/spectrum_def.h96
-rw-r--r--drivers/staging/rt3070/sta/aironet.c1313
-rw-r--r--drivers/staging/rt3070/sta/assoc.c2061
-rw-r--r--drivers/staging/rt3070/sta/auth.c476
-rw-r--r--drivers/staging/rt3070/sta/auth_rsp.c168
-rw-r--r--drivers/staging/rt3070/sta/connect.c2857
-rw-r--r--drivers/staging/rt3070/sta/dls.c2170
-rw-r--r--drivers/staging/rt3070/sta/rtmp_data.c2638
-rw-r--r--drivers/staging/rt3070/sta/sanity.c421
-rw-r--r--drivers/staging/rt3070/sta/sync.c1756
-rw-r--r--drivers/staging/rt3070/sta/wpa.c2100
-rw-r--r--drivers/staging/rt3070/sta_ioctl.c7204
-rw-r--r--drivers/staging/rt3070/wpa.h357
-rw-r--r--drivers/staging/rtl8187se/Kconfig2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_module.c1
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c25
-rw-r--r--drivers/staging/rtl8187se/r8180_dm.c6
-rw-r--r--drivers/staging/rtl8187se/r8180_pm.c6
-rw-r--r--drivers/staging/rtl8192su/Kconfig6
-rw-r--r--drivers/staging/rtl8192su/Makefile66
-rw-r--r--drivers/staging/rtl8192su/authors1
-rw-r--r--drivers/staging/rtl8192su/dot11d.h102
-rw-r--r--drivers/staging/rtl8192su/ieee80211.h2901
-rw-r--r--drivers/staging/rtl8192su/ieee80211/EndianFree.h199
-rw-r--r--drivers/staging/rtl8192su/ieee80211/Makefile31
-rw-r--r--drivers/staging/rtl8192su/ieee80211/aes.c469
-rw-r--r--drivers/staging/rtl8192su/ieee80211/api.c246
-rw-r--r--drivers/staging/rtl8192su/ieee80211/arc4.c103
-rw-r--r--drivers/staging/rtl8192su/ieee80211/autoload.c40
-rw-r--r--drivers/staging/rtl8192su/ieee80211/cipher.c299
-rw-r--r--drivers/staging/rtl8192su/ieee80211/compress.c64
-rw-r--r--drivers/staging/rtl8192su/ieee80211/crypto_compat.h90
-rw-r--r--drivers/staging/rtl8192su/ieee80211/digest.c108
-rw-r--r--drivers/staging/rtl8192su/ieee80211/dot11d.c239
-rw-r--r--drivers/staging/rtl8192su/ieee80211/dot11d.h102
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211.h2901
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c273
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h93
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c534
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c1034
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c397
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_module.c394
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c2832
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c3580
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c711
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c947
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c1032
-rw-r--r--drivers/staging/rtl8192su/ieee80211/internal.h115
-rw-r--r--drivers/staging/rtl8192su/ieee80211/kmap_types.h20
-rw-r--r--drivers/staging/rtl8192su/ieee80211/michael_mic.c194
-rw-r--r--drivers/staging/rtl8192su/ieee80211/proc.c116
-rw-r--r--drivers/staging/rtl8192su/ieee80211/readme162
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h69
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c781
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h517
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c2037
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h749
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h56
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c667
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl_crypto.h399
-rw-r--r--drivers/staging/rtl8192su/ieee80211/scatterwalk.c126
-rw-r--r--drivers/staging/rtl8192su/ieee80211/scatterwalk.h51
-rw-r--r--drivers/staging/rtl8192su/ieee80211_crypt.h86
-rw-r--r--drivers/staging/rtl8192su/r8180_93cx6.c146
-rw-r--r--drivers/staging/rtl8192su/r8180_93cx6.h45
-rw-r--r--drivers/staging/rtl8192su/r8190_rtl8256.c312
-rw-r--r--drivers/staging/rtl8192su/r8190_rtl8256.h27
-rw-r--r--drivers/staging/rtl8192su/r8192SU_HWImg.c4902
-rw-r--r--drivers/staging/rtl8192su/r8192SU_HWImg.h44
-rw-r--r--drivers/staging/rtl8192su/r8192S_Efuse.c2442
-rw-r--r--drivers/staging/rtl8192su/r8192S_Efuse.h101
-rw-r--r--drivers/staging/rtl8192su/r8192S_FwImgDTM.h3797
-rw-r--r--drivers/staging/rtl8192su/r8192S_firmware.c1023
-rw-r--r--drivers/staging/rtl8192su/r8192S_firmware.h212
-rw-r--r--drivers/staging/rtl8192su/r8192S_hw.h1677
-rw-r--r--drivers/staging/rtl8192su/r8192S_phy.c5028
-rw-r--r--drivers/staging/rtl8192su/r8192S_phy.h138
-rw-r--r--drivers/staging/rtl8192su/r8192S_phyreg.h1033
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl6052.c946
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl6052.h134
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl8225.c292
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl8225.h30
-rw-r--r--drivers/staging/rtl8192su/r8192U.h2112
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c12460
-rw-r--r--drivers/staging/rtl8192su/r8192U_dm.c4521
-rw-r--r--drivers/staging/rtl8192su/r8192U_dm.h309
-rw-r--r--drivers/staging/rtl8192su/r8192U_hw.h746
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.c77
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.h27
-rw-r--r--drivers/staging/rtl8192su/r8192U_wx.c1350
-rw-r--r--drivers/staging/rtl8192su/r8192U_wx.h23
-rw-r--r--drivers/staging/rtl8192su/r819xU_HTGen.h22
-rw-r--r--drivers/staging/rtl8192su/r819xU_HTType.h392
-rw-r--r--drivers/staging/rtl8192su/r819xU_cmdpkt.c826
-rw-r--r--drivers/staging/rtl8192su/r819xU_cmdpkt.h219
-rw-r--r--drivers/staging/rtl8192su/r819xU_firmware.c707
-rw-r--r--drivers/staging/rtl8192su/r819xU_firmware.h106
-rw-r--r--drivers/staging/rtl8192su/r819xU_firmware_img.c3447
-rw-r--r--drivers/staging/rtl8192su/r819xU_firmware_img.h35
-rw-r--r--drivers/staging/rtl8192su/r819xU_phy.c1826
-rw-r--r--drivers/staging/rtl8192su/r819xU_phy.h94
-rw-r--r--drivers/staging/rtl8192su/r819xU_phyreg.h871
-rw-r--r--drivers/staging/serqt_usb/serqt_usb.c1
-rw-r--r--drivers/staging/stlc45xx/stlc45xx.c11
-rw-r--r--drivers/staging/sxg/sxg.c38
-rw-r--r--drivers/staging/sxg/sxg_ethtool.c2
-rw-r--r--drivers/staging/vt6655/80211hdr.h357
-rw-r--r--drivers/staging/vt6655/80211mgr.c1050
-rw-r--r--drivers/staging/vt6655/80211mgr.h832
-rw-r--r--drivers/staging/vt6655/IEEE11h.c324
-rw-r--r--drivers/staging/vt6655/IEEE11h.h68
-rw-r--r--drivers/staging/vt6655/Makefile218
-rw-r--r--drivers/staging/vt6655/Makefile.arm181
-rw-r--r--drivers/staging/vt6655/Makefile.x86209
-rw-r--r--drivers/staging/vt6655/aes_ccmp.c410
-rw-r--r--drivers/staging/vt6655/aes_ccmp.h48
-rw-r--r--drivers/staging/vt6655/baseband.c2990
-rw-r--r--drivers/staging/vt6655/baseband.h198
-rw-r--r--drivers/staging/vt6655/bssdb.c1791
-rw-r--r--drivers/staging/vt6655/bssdb.h380
-rw-r--r--drivers/staging/vt6655/card.c3126
-rw-r--r--drivers/staging/vt6655/card.h273
-rw-r--r--drivers/staging/vt6655/country.h192
-rw-r--r--drivers/staging/vt6655/datarate.c455
-rw-r--r--drivers/staging/vt6655/datarate.h95
-rw-r--r--drivers/staging/vt6655/desc.h697
-rw-r--r--drivers/staging/vt6655/device.h1063
-rw-r--r--drivers/staging/vt6655/device_cfg.h142
-rw-r--r--drivers/staging/vt6655/device_main.c4159
-rw-r--r--drivers/staging/vt6655/dpc.c1688
-rw-r--r--drivers/staging/vt6655/dpc.h75
-rw-r--r--drivers/staging/vt6655/hostap.c907
-rw-r--r--drivers/staging/vt6655/hostap.h94
-rw-r--r--drivers/staging/vt6655/iocmd.h481
-rw-r--r--drivers/staging/vt6655/ioctl.c775
-rw-r--r--drivers/staging/vt6655/ioctl.h74
-rw-r--r--drivers/staging/vt6655/iowpa.h159
-rw-r--r--drivers/staging/vt6655/iwctl.c2453
-rw-r--r--drivers/staging/vt6655/iwctl.h332
-rw-r--r--drivers/staging/vt6655/kcompat.h302
-rw-r--r--drivers/staging/vt6655/key.c836
-rw-r--r--drivers/staging/vt6655/key.h202
-rw-r--r--drivers/staging/vt6655/mac.c1752
-rw-r--r--drivers/staging/vt6655/mac.h1166
-rw-r--r--drivers/staging/vt6655/mib.c616
-rw-r--r--drivers/staging/vt6655/mib.h399
-rw-r--r--drivers/staging/vt6655/michael.c188
-rw-r--r--drivers/staging/vt6655/michael.h62
-rw-r--r--drivers/staging/vt6655/power.c441
-rw-r--r--drivers/staging/vt6655/power.h85
-rw-r--r--drivers/staging/vt6655/rc4.c86
-rw-r--r--drivers/staging/vt6655/rc4.h51
-rw-r--r--drivers/staging/vt6655/rf.c1283
-rw-r--r--drivers/staging/vt6655/rf.h118
-rw-r--r--drivers/staging/vt6655/rxtx.c3269
-rw-r--r--drivers/staging/vt6655/rxtx.h132
-rw-r--r--drivers/staging/vt6655/srom.c437
-rw-r--r--drivers/staging/vt6655/srom.h179
-rw-r--r--drivers/staging/vt6655/tbit.h78
-rw-r--r--drivers/staging/vt6655/tcrc.c207
-rw-r--r--drivers/staging/vt6655/tcrc.h71
-rw-r--r--drivers/staging/vt6655/test9
-rw-r--r--drivers/staging/vt6655/tether.c123
-rw-r--r--drivers/staging/vt6655/tether.h256
-rw-r--r--drivers/staging/vt6655/tkip.c284
-rw-r--r--drivers/staging/vt6655/tkip.h76
-rw-r--r--drivers/staging/vt6655/tmacro.h152
-rw-r--r--drivers/staging/vt6655/tpci.h117
-rw-r--r--drivers/staging/vt6655/ttype.h386
-rw-r--r--drivers/staging/vt6655/umem.h75
-rw-r--r--drivers/staging/vt6655/upc.h171
-rw-r--r--drivers/staging/vt6655/vntconfiguration.dat1
-rw-r--r--drivers/staging/vt6655/vntwifi.c832
-rw-r--r--drivers/staging/vt6655/vntwifi.h330
-rw-r--r--drivers/staging/vt6655/wcmd.c1178
-rw-r--r--drivers/staging/vt6655/wcmd.h151
-rw-r--r--drivers/staging/vt6655/wctl.c261
-rw-r--r--drivers/staging/vt6655/wctl.h127
-rw-r--r--drivers/staging/vt6655/wmgr.c5100
-rw-r--r--drivers/staging/vt6655/wmgr.h521
-rw-r--r--drivers/staging/vt6655/wpa.c339
-rw-r--r--drivers/staging/vt6655/wpa.h98
-rw-r--r--drivers/staging/vt6655/wpa2.c373
-rw-r--r--drivers/staging/vt6655/wpa2.h100
-rw-r--r--drivers/staging/vt6655/wpactl.c1014
-rw-r--r--drivers/staging/vt6655/wpactl.h89
-rw-r--r--drivers/staging/vt6655/wroute.c211
-rw-r--r--drivers/staging/vt6655/wroute.h65
-rw-r--r--drivers/staging/winbond/Makefile1
-rw-r--r--drivers/staging/winbond/mds.c2
-rw-r--r--drivers/staging/winbond/mto.c2
-rw-r--r--drivers/staging/winbond/phy_calibration.c19
-rw-r--r--drivers/staging/winbond/wbhal.c568
-rw-r--r--drivers/staging/winbond/wbhal_f.h21
-rw-r--r--drivers/staging/winbond/wbhal_s.h1
-rw-r--r--drivers/staging/winbond/wbusb.c785
-rw-r--r--drivers/staging/wlan-ng/hfa384x.h244
-rw-r--r--drivers/staging/wlan-ng/hfa384x_usb.c23
-rw-r--r--drivers/staging/wlan-ng/p80211conv.c2
-rw-r--r--drivers/staging/wlan-ng/p80211metadef.h48
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.c15
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.h3
-rw-r--r--drivers/staging/wlan-ng/p80211wep.c1
-rw-r--r--drivers/staging/wlan-ng/p80211wext.c6
-rw-r--r--drivers/staging/wlan-ng/prism2fw.c1410
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.c28
-rw-r--r--drivers/staging/wlan-ng/prism2mib.c1
-rw-r--r--drivers/staging/wlan-ng/prism2sta.c16
-rw-r--r--drivers/staging/wlan-ng/prism2usb.c9
-rw-r--r--drivers/thermal/thermal_sys.c4
-rw-r--r--drivers/usb/Kconfig1
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/class/cdc-acm.c445
-rw-r--r--drivers/usb/class/cdc-acm.h5
-rw-r--r--drivers/usb/class/usblp.c6
-rw-r--r--drivers/usb/core/Kconfig16
-rw-r--r--drivers/usb/core/Makefile4
-rw-r--r--drivers/usb/core/config.c192
-rw-r--r--drivers/usb/core/driver.c21
-rw-r--r--drivers/usb/core/file.c13
-rw-r--r--drivers/usb/core/hcd-pci.c244
-rw-r--r--drivers/usb/core/hcd.c220
-rw-r--r--drivers/usb/core/hcd.h55
-rw-r--r--drivers/usb/core/hub.c134
-rw-r--r--drivers/usb/core/hub.h3
-rw-r--r--drivers/usb/core/message.c194
-rw-r--r--drivers/usb/core/sysfs.c12
-rw-r--r--drivers/usb/core/urb.c12
-rw-r--r--drivers/usb/core/usb.c76
-rw-r--r--drivers/usb/core/usb.h2
-rw-r--r--drivers/usb/gadget/Kconfig2
-rw-r--r--drivers/usb/gadget/at91_udc.c10
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c9
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c6
-rw-r--r--drivers/usb/gadget/file_storage.c93
-rw-r--r--drivers/usb/gadget/goku_udc.c6
-rw-r--r--drivers/usb/gadget/inode.c14
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c71
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h2
-rw-r--r--drivers/usb/host/Kconfig20
-rw-r--r--drivers/usb/host/Makefile2
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/host/ehci-hub.c4
-rw-r--r--drivers/usb/host/ehci-orion.c2
-rw-r--r--drivers/usb/host/ehci-pci.c26
-rw-r--r--drivers/usb/host/fhci-dbg.c2
-rw-r--r--drivers/usb/host/hwa-hc.c21
-rw-r--r--drivers/usb/host/isp1760-hcd.c24
-rw-r--r--drivers/usb/host/ohci-dbg.c31
-rw-r--r--drivers/usb/host/ohci-hcd.c38
-rw-r--r--drivers/usb/host/ohci-pci.c24
-rw-r--r--drivers/usb/host/pci-quirks.c123
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/uhci-hcd.c23
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/host/xhci-dbg.c485
-rw-r--r--drivers/usb/host/xhci-ext-caps.h145
-rw-r--r--drivers/usb/host/xhci-hcd.c1256
-rw-r--r--drivers/usb/host/xhci-hub.c308
-rw-r--r--drivers/usb/host/xhci-mem.c768
-rw-r--r--drivers/usb/host/xhci-pci.c166
-rw-r--r--drivers/usb/host/xhci-ring.c1649
-rw-r--r--drivers/usb/host/xhci.h1155
-rw-r--r--drivers/usb/misc/iowarrior.c6
-rw-r--r--drivers/usb/misc/legousbtower.c6
-rw-r--r--drivers/usb/mon/mon_text.c2
-rw-r--r--drivers/usb/musb/Kconfig2
-rw-r--r--drivers/usb/musb/blackfin.c11
-rw-r--r--drivers/usb/musb/cppi_dma.c34
-rw-r--r--drivers/usb/musb/cppi_dma.h6
-rw-r--r--drivers/usb/musb/davinci.c54
-rw-r--r--drivers/usb/musb/musb_core.c228
-rw-r--r--drivers/usb/musb/musb_core.h22
-rw-r--r--drivers/usb/musb/musb_gadget.c45
-rw-r--r--drivers/usb/musb/musb_gadget_ep0.c45
-rw-r--r--drivers/usb/musb/musb_host.c273
-rw-r--r--drivers/usb/musb/musb_host.h1
-rw-r--r--drivers/usb/musb/musb_virthub.c35
-rw-r--r--drivers/usb/musb/omap2430.c64
-rw-r--r--drivers/usb/musb/tusb6010.c70
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c25
-rw-r--r--drivers/usb/otg/twl4030-usb.c28
-rw-r--r--drivers/usb/serial/belkin_sa.c6
-rw-r--r--drivers/usb/serial/ch341.c46
-rw-r--r--drivers/usb/serial/console.c6
-rw-r--r--drivers/usb/serial/cp210x.c6
-rw-r--r--drivers/usb/serial/cyberjack.c6
-rw-r--r--drivers/usb/serial/cypress_m8.c81
-rw-r--r--drivers/usb/serial/digi_acceleport.c75
-rw-r--r--drivers/usb/serial/empeg.c6
-rw-r--r--drivers/usb/serial/ftdi_sio.c214
-rw-r--r--drivers/usb/serial/ftdi_sio.h10
-rw-r--r--drivers/usb/serial/garmin_gps.c201
-rw-r--r--drivers/usb/serial/generic.c180
-rw-r--r--drivers/usb/serial/io_edgeport.c10
-rw-r--r--drivers/usb/serial/io_ti.c5
-rw-r--r--drivers/usb/serial/ipaq.c6
-rw-r--r--drivers/usb/serial/ipw.c18
-rw-r--r--drivers/usb/serial/ir-usb.c6
-rw-r--r--drivers/usb/serial/iuu_phoenix.c25
-rw-r--r--drivers/usb/serial/keyspan.c13
-rw-r--r--drivers/usb/serial/keyspan.h8
-rw-r--r--drivers/usb/serial/keyspan_pda.c48
-rw-r--r--drivers/usb/serial/kl5kusb105.c6
-rw-r--r--drivers/usb/serial/kobil_sct.c9
-rw-r--r--drivers/usb/serial/mct_u232.c37
-rw-r--r--drivers/usb/serial/mos7720.c3
-rw-r--r--drivers/usb/serial/mos7840.c366
-rw-r--r--drivers/usb/serial/navman.c3
-rw-r--r--drivers/usb/serial/omninet.c6
-rw-r--r--drivers/usb/serial/opticon.c3
-rw-r--r--drivers/usb/serial/option.c87
-rw-r--r--drivers/usb/serial/oti6858.c57
-rw-r--r--drivers/usb/serial/pl2303.c79
-rw-r--r--drivers/usb/serial/sierra.c280
-rw-r--r--drivers/usb/serial/spcp8x5.c85
-rw-r--r--drivers/usb/serial/symbolserial.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c6
-rw-r--r--drivers/usb/serial/usb-serial.c144
-rw-r--r--drivers/usb/serial/usb_debug.c41
-rw-r--r--drivers/usb/serial/visor.c6
-rw-r--r--drivers/usb/serial/whiteheat.c33
-rw-r--r--drivers/usb/storage/initializers.c14
-rw-r--r--drivers/usb/storage/option_ms.c3
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/usb/storage/unusual_devs.h2
-rw-r--r--drivers/video/Kconfig12
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/aty/aty128fb.c2
-rw-r--r--drivers/video/cyber2000fb.c9
-rw-r--r--drivers/video/hitfb.c4
-rw-r--r--drivers/video/mx3fb.c4
-rw-r--r--drivers/video/omap/hwa742.c26
-rw-r--r--drivers/video/pxa168fb.c798
-rw-r--r--drivers/video/pxa168fb.h558
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c7
-rw-r--r--drivers/video/tdfxfb.c1
-rw-r--r--drivers/video/uvesafb.c10
-rw-r--r--drivers/video/xen-fbfront.c8
-rw-r--r--drivers/virtio/virtio.c25
-rw-r--r--drivers/virtio/virtio_balloon.c27
-rw-r--r--drivers/virtio/virtio_pci.c307
-rw-r--r--drivers/virtio/virtio_ring.c102
-rw-r--r--drivers/watchdog/alim7101_wdt.c15
-rw-r--r--drivers/watchdog/ar7_wdt.c3
-rw-r--r--drivers/watchdog/at91rm9200_wdt.c3
-rw-r--r--drivers/watchdog/at91sam9_wdt.c3
-rw-r--r--drivers/watchdog/bfin_wdt.c14
-rw-r--r--drivers/watchdog/cpwd.c6
-rw-r--r--drivers/watchdog/davinci_wdt.c6
-rw-r--r--drivers/watchdog/iTCO_vendor_support.c6
-rw-r--r--drivers/watchdog/iTCO_wdt.c24
-rw-r--r--drivers/watchdog/indydog.c4
-rw-r--r--drivers/watchdog/iop_wdt.c2
-rw-r--r--drivers/watchdog/it8712f_wdt.c3
-rw-r--r--drivers/watchdog/ks8695_wdt.c4
-rw-r--r--drivers/watchdog/machzwd.c9
-rw-r--r--drivers/watchdog/mpcore_wdt.c7
-rw-r--r--drivers/watchdog/mtx-1_wdt.c6
-rw-r--r--drivers/watchdog/pnx4008_wdt.c6
-rw-r--r--drivers/watchdog/rdc321x_wdt.c4
-rw-r--r--drivers/watchdog/rm9k_wdt.c6
-rw-r--r--drivers/watchdog/s3c2410_wdt.c32
-rw-r--r--drivers/watchdog/sb_wdog.c9
-rw-r--r--drivers/watchdog/sbc60xxwdt.c5
-rw-r--r--drivers/watchdog/sbc8360.c4
-rw-r--r--drivers/watchdog/sbc_epx_c3.c12
-rw-r--r--drivers/watchdog/scx200_wdt.c7
-rw-r--r--drivers/watchdog/shwdt.c4
-rw-r--r--drivers/watchdog/softdog.c7
-rw-r--r--drivers/watchdog/w83697hf_wdt.c3
-rw-r--r--drivers/watchdog/wdrtas.c7
-rw-r--r--drivers/xen/Kconfig20
-rw-r--r--drivers/xen/Makefile4
-rw-r--r--drivers/xen/events.c20
-rw-r--r--drivers/xen/evtchn.c507
-rw-r--r--drivers/xen/manage.c25
-rw-r--r--drivers/xen/sys-hypervisor.c445
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c61
-rw-r--r--drivers/xen/xenbus/xenbus_xs.c2
-rw-r--r--drivers/xen/xenfs/super.c19
2032 files changed, 279381 insertions, 283460 deletions
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 16e5210ae936..3d87362d17ed 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -362,9 +362,6 @@ extern u8 acpi_gbl_method_executing;
extern u8 acpi_gbl_abort_method;
extern u8 acpi_gbl_db_terminate_threads;
-ACPI_EXTERN int optind;
-ACPI_EXTERN char *optarg;
-
ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index dab3f48f0b42..02e6caad4a76 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -734,7 +734,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
/* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
- obj_desc->reference.value = opcode - AML_LOCAL_OP;
+ obj_desc->reference.value =
+ ((u32)opcode) - AML_LOCAL_OP;
obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
#ifndef ACPI_NO_METHOD_EXECUTION
@@ -754,7 +755,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
/* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
- obj_desc->reference.value = opcode - AML_ARG_OP;
+ obj_desc->reference.value = ((u32)opcode) - AML_ARG_OP;
obj_desc->reference.class = ACPI_REFCLASS_ARG;
#ifndef ACPI_NO_METHOD_EXECUTION
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index b4c87b5053e6..584d766e6f12 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -1386,14 +1386,19 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
case AML_BREAK_POINT_OP:
- /* Call up to the OS service layer to handle this */
-
- status =
- acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
- "Executed AML Breakpoint opcode");
+ /*
+ * Set the single-step flag. This will cause the debugger (if present)
+ * to break to the console within the AML debugger at the start of the
+ * next AML instruction.
+ */
+ ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
+ ACPI_DEBUGGER_EXEC(acpi_os_printf
+ ("**break** Executed AML BreakPoint opcode\n"));
- /* If and when it returns, all done. */
+ /* Call to the OSL in case OS wants a piece of the action */
+ status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
+ "Executed AML Breakpoint opcode");
break;
case AML_BREAK_OP:
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index 40f92bf7dce5..e46c821cf572 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -102,7 +102,7 @@ acpi_ds_result_pop(union acpi_operand_object **object,
/* Return object of the top element and clean that top element result stack */
walk_state->result_count--;
- index = walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM;
+ index = (u32)walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM;
*object = state->results.obj_desc[index];
if (!*object) {
@@ -186,7 +186,7 @@ acpi_ds_result_push(union acpi_operand_object * object,
/* Assign the address of object to the top free element of result stack */
- index = walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM;
+ index = (u32)walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM;
state->results.obj_desc[index] = object;
walk_state->result_count++;
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index d0a080747ec3..4721f58fe42c 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -51,7 +51,7 @@
ACPI_MODULE_NAME("evxfevnt")
/* Local prototypes */
-acpi_status
+static acpi_status
acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
struct acpi_gpe_block_info *gpe_block, void *context);
@@ -785,7 +785,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
* block device. NULL if the GPE is one of the FADT-defined GPEs.
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
struct acpi_gpe_block_info *gpe_block, void *context)
{
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index d301c1f363ef..d7cb030a21f8 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -373,11 +373,12 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
walk_state->thread->thread_id)
&& (obj_desc != acpi_gbl_global_lock_mutex)) {
ACPI_ERROR((AE_INFO,
- "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX",
- (unsigned long)walk_state->thread->thread_id,
+ "Thread %p cannot release Mutex [%4.4s] acquired by thread %p",
+ ACPI_CAST_PTR(void, walk_state->thread->thread_id),
acpi_ut_get_node_name(obj_desc->mutex.node),
- (unsigned long)obj_desc->mutex.owner_thread->
- thread_id));
+ ACPI_CAST_PTR(void,
+ obj_desc->mutex.owner_thread->
+ thread_id)));
return_ACPI_STATUS(AE_AML_NOT_OWNER);
}
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 7b2fb602b5cb..23d5505cb1f7 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -81,9 +81,9 @@ acpi_status acpi_hw_clear_acpi_status(void)
ACPI_FUNCTION_TRACE(hw_clear_acpi_status);
- ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %0llX\n",
+ ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
ACPI_BITMASK_ALL_FIXED_STATUS,
- acpi_gbl_xpm1a_status.address));
+ ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address)));
lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index ae3dc10a7e81..af8e6bcee07e 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -149,7 +149,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
name_buffer = ACPI_ALLOCATE_ZEROED(size);
if (!name_buffer) {
- ACPI_ERROR((AE_INFO, "Allocation failure"));
+ ACPI_ERROR((AE_INFO, "Could not allocate %u bytes", (u32)size));
return_PTR(NULL);
}
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index d9e8cbc6e679..7f8e066b12a3 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -144,7 +144,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
pathname = acpi_ns_get_external_pathname(node);
if (!pathname) {
- pathname = ACPI_CAST_PTR(char, predefined->info.name);
+ return AE_OK; /* Could not get pathname, ignore */
}
/*
@@ -230,10 +230,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
}
exit:
- if (pathname != predefined->info.name) {
- ACPI_FREE(pathname);
- }
-
+ ACPI_FREE(pathname);
return (status);
}
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index f9b4f51bf8f2..7e865639a928 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -45,6 +45,10 @@
#include "accommon.h"
#include "acnamesp.h"
+#ifdef ACPI_ASL_COMPILER
+#include "amlcode.h"
+#endif
+
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nssearch")
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 88b5a2c4814d..d3f77a5df79d 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -593,9 +593,6 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
} else {
temp_size_needed +=
acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
- if (!temp_size_needed) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
}
} else {
/*
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 69a2aa5b5d83..395212bcd19b 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -338,13 +338,17 @@ acpi_resource_to_address64(struct acpi_resource *resource,
switch (resource->type) {
case ACPI_RESOURCE_TYPE_ADDRESS16:
- address16 = (struct acpi_resource_address16 *)&resource->data;
+ address16 =
+ ACPI_CAST_PTR(struct acpi_resource_address16,
+ &resource->data);
ACPI_COPY_ADDRESS(out, address16);
break;
case ACPI_RESOURCE_TYPE_ADDRESS32:
- address32 = (struct acpi_resource_address32 *)&resource->data;
+ address32 =
+ ACPI_CAST_PTR(struct acpi_resource_address32,
+ &resource->data);
ACPI_COPY_ADDRESS(out, address32);
break;
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 71e655d14cb0..82b02dcb942e 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -284,9 +284,9 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
if (length > sizeof(struct acpi_table_fadt)) {
ACPI_WARNING((AE_INFO,
"FADT (revision %u) is longer than ACPI 2.0 version, "
- "truncating length 0x%X to 0x%zX",
- table->revision, (unsigned)length,
- sizeof(struct acpi_table_fadt)));
+ "truncating length 0x%X to 0x%X",
+ table->revision, length,
+ (u32)sizeof(struct acpi_table_fadt)));
}
/* Clear the entire local FADT */
@@ -441,7 +441,7 @@ static void acpi_tb_convert_fadt(void)
&acpi_gbl_FADT,
fadt_info_table
[i].length),
- address32);
+ (u64) address32);
}
}
}
@@ -469,7 +469,6 @@ static void acpi_tb_convert_fadt(void)
static void acpi_tb_validate_fadt(void)
{
char *name;
- u32 *address32;
struct acpi_generic_address *address64;
u8 length;
u32 i;
@@ -505,15 +504,12 @@ static void acpi_tb_validate_fadt(void)
for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
/*
- * Generate pointers to the 32-bit and 64-bit addresses, get the
- * register length (width), and the register name
+ * Generate pointer to the 64-bit address, get the register
+ * length (width) and the register name
*/
address64 = ACPI_ADD_PTR(struct acpi_generic_address,
&acpi_gbl_FADT,
fadt_info_table[i].address64);
- address32 =
- ACPI_ADD_PTR(u32, &acpi_gbl_FADT,
- fadt_info_table[i].address32);
length =
*ACPI_ADD_PTR(u8, &acpi_gbl_FADT,
fadt_info_table[i].length);
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index f865d5a096de..63e82329a9e8 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -472,7 +472,7 @@ acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
* lock may block, and also since the execution of a namespace walk
* must be allowed to use the interpreter.
*/
- acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
+ (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
acpi_ns_delete_namespace_by_owner(owner_id);
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 919624f123d5..0f0c64bf8ac9 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -676,6 +676,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
{
u16 reference_count;
union acpi_operand_object *next_object;
+ acpi_status status;
/* Save fields from destination that we don't want to overwrite */
@@ -768,6 +769,28 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
}
break;
+ /*
+ * For Mutex and Event objects, we cannot simply copy the underlying
+ * OS object. We must create a new one.
+ */
+ case ACPI_TYPE_MUTEX:
+
+ status = acpi_os_create_mutex(&dest_desc->mutex.os_mutex);
+ if (ACPI_FAILURE(status)) {
+ return status;
+ }
+ break;
+
+ case ACPI_TYPE_EVENT:
+
+ status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
+ &dest_desc->event.
+ os_semaphore);
+ if (ACPI_FAILURE(status)) {
+ return status;
+ }
+ break;
+
default:
/* Nothing to do for other simple objects */
break;
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 38821f53042c..527d729f6815 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -179,9 +179,9 @@ acpi_debug_print(u32 requested_debug_level,
if (thread_id != acpi_gbl_prev_thread_id) {
if (ACPI_LV_THREADS & acpi_dbg_level) {
acpi_os_printf
- ("\n**** Context Switch from TID %lX to TID %lX ****\n\n",
- (unsigned long)acpi_gbl_prev_thread_id,
- (unsigned long)thread_id);
+ ("\n**** Context Switch from TID %p to TID %p ****\n\n",
+ ACPI_CAST_PTR(void, acpi_gbl_prev_thread_id),
+ ACPI_CAST_PTR(void, thread_id));
}
acpi_gbl_prev_thread_id = thread_id;
@@ -194,7 +194,7 @@ acpi_debug_print(u32 requested_debug_level,
acpi_os_printf("%8s-%04ld ", module_name, line_number);
if (ACPI_LV_THREADS & acpi_dbg_level) {
- acpi_os_printf("[%04lX] ", (unsigned long)thread_id);
+ acpi_os_printf("[%p] ", ACPI_CAST_PTR(void, thread_id));
}
acpi_os_printf("[%02ld] %-22.22s: ",
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 1c9e250caefb..fbe782348b0b 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -1033,11 +1033,12 @@ acpi_error(const char *module_name, u32 line_number, const char *format, ...)
{
va_list args;
- acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
+ acpi_os_printf("ACPI Error: ");
va_start(args, format);
acpi_os_vprintf(format, args);
- acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
+ acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name,
+ line_number);
va_end(args);
}
@@ -1047,12 +1048,12 @@ acpi_exception(const char *module_name,
{
va_list args;
- acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name,
- line_number, acpi_format_exception(status));
+ acpi_os_printf("ACPI Exception: %s, ", acpi_format_exception(status));
va_start(args, format);
acpi_os_vprintf(format, args);
- acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
+ acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name,
+ line_number);
va_end(args);
}
@@ -1061,11 +1062,12 @@ acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
{
va_list args;
- acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
+ acpi_os_printf("ACPI Warning: ");
va_start(args, format);
acpi_os_vprintf(format, args);
- acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
+ acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name,
+ line_number);
va_end(args);
}
@@ -1074,10 +1076,6 @@ acpi_info(const char *module_name, u32 line_number, const char *format, ...)
{
va_list args;
- /*
- * Removed module_name, line_number, and acpica version, not needed
- * for info output
- */
acpi_os_printf("ACPI: ");
va_start(args, format);
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 26c93a748e64..80bb65154117 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -230,17 +230,18 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
if (i == mutex_id) {
ACPI_ERROR((AE_INFO,
- "Mutex [%s] already acquired by this thread [%X]",
+ "Mutex [%s] already acquired by this thread [%p]",
acpi_ut_get_mutex_name
(mutex_id),
- this_thread_id));
+ ACPI_CAST_PTR(void,
+ this_thread_id)));
return (AE_ALREADY_ACQUIRED);
}
ACPI_ERROR((AE_INFO,
- "Invalid acquire order: Thread %X owns [%s], wants [%s]",
- this_thread_id,
+ "Invalid acquire order: Thread %p owns [%s], wants [%s]",
+ ACPI_CAST_PTR(void, this_thread_id),
acpi_ut_get_mutex_name(i),
acpi_ut_get_mutex_name(mutex_id)));
@@ -251,24 +252,24 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
#endif
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
- "Thread %lX attempting to acquire Mutex [%s]\n",
- (unsigned long)this_thread_id,
+ "Thread %p attempting to acquire Mutex [%s]\n",
+ ACPI_CAST_PTR(void, this_thread_id),
acpi_ut_get_mutex_name(mutex_id)));
status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
- "Thread %lX acquired Mutex [%s]\n",
- (unsigned long)this_thread_id,
+ "Thread %p acquired Mutex [%s]\n",
+ ACPI_CAST_PTR(void, this_thread_id),
acpi_ut_get_mutex_name(mutex_id)));
acpi_gbl_mutex_info[mutex_id].use_count++;
acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
} else {
ACPI_EXCEPTION((AE_INFO, status,
- "Thread %lX could not acquire Mutex [%X]",
- (unsigned long)this_thread_id, mutex_id));
+ "Thread %p could not acquire Mutex [%X]",
+ ACPI_CAST_PTR(void, this_thread_id), mutex_id));
}
return (status);
@@ -293,9 +294,8 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
ACPI_FUNCTION_NAME(ut_release_mutex);
this_thread_id = acpi_os_get_thread_id();
- ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
- "Thread %lX releasing Mutex [%s]\n",
- (unsigned long)this_thread_id,
+ ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n",
+ ACPI_CAST_PTR(void, this_thread_id),
acpi_ut_get_mutex_name(mutex_id)));
if (mutex_id > ACPI_MAX_MUTEX) {
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 51b9f8280f88..2faa9e2ac893 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -401,7 +401,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
/* Interrupt Line values above 0xF are forbidden */
if (dev->irq > 0 && (dev->irq <= 0xF)) {
printk(" - using IRQ %d\n", dev->irq);
- acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
+ acpi_register_gsi(&dev->dev, dev->irq,
+ ACPI_LEVEL_SENSITIVE,
ACPI_ACTIVE_LOW);
return 0;
} else {
@@ -410,7 +411,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
}
}
- rc = acpi_register_gsi(gsi, triggering, polarity);
+ rc = acpi_register_gsi(&dev->dev, gsi, triggering, polarity);
if (rc < 0) {
dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
pin_name(pin));
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 7f16f5f8e7d3..806b448a22c5 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -852,32 +852,22 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
return 0;
}
-static int acpi_processor_get_throttling(struct acpi_processor *pr)
+static long get_throttling(void *_pr)
{
- cpumask_var_t saved_mask;
- int ret;
+ struct acpi_processor *pr = _pr;
+
+ return pr->throttling.acpi_processor_get_throttling(pr);
+}
+static int acpi_processor_get_throttling(struct acpi_processor *pr)
+{
if (!pr)
return -EINVAL;
if (!pr->flags.throttling)
return -ENODEV;
- if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
- return -ENOMEM;
-
- /*
- * Migrate task to the cpu pointed by pr.
- */
- cpumask_copy(saved_mask, &current->cpus_allowed);
- /* FIXME: use work_on_cpu() */
- set_cpus_allowed_ptr(current, cpumask_of(pr->id));
- ret = pr->throttling.acpi_processor_get_throttling(pr);
- /* restore the previous state */
- set_cpus_allowed_ptr(current, saved_mask);
- free_cpumask_var(saved_mask);
-
- return ret;
+ return work_on_cpu(pr->id, get_throttling, pr);
}
static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
@@ -1018,9 +1008,22 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
return 0;
}
+struct set_throttling_info {
+ struct acpi_processor *pr;
+ struct acpi_processor_throttling *p_throttling;
+ int target_state;
+};
+
+static long set_throttling(void *_sti)
+{
+ struct set_throttling_info *s = _sti;
+
+ return s->p_throttling->acpi_processor_set_throttling(s->pr,
+ s->target_state);
+}
+
int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
{
- cpumask_var_t saved_mask;
int ret = 0;
unsigned int i;
struct acpi_processor *match_pr;
@@ -1037,15 +1040,9 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
if ((state < 0) || (state > (pr->throttling.state_count - 1)))
return -EINVAL;
- if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
- return -ENOMEM;
-
- if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL)) {
- free_cpumask_var(saved_mask);
+ if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL))
return -ENOMEM;
- }
- cpumask_copy(saved_mask, &current->cpus_allowed);
t_state.target_state = state;
p_throttling = &(pr->throttling);
cpumask_and(online_throttling_cpus, cpu_online_mask,
@@ -1067,10 +1064,9 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
* it can be called only for the cpu pointed by pr.
*/
if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
- /* FIXME: use work_on_cpu() */
- set_cpus_allowed_ptr(current, cpumask_of(pr->id));
- ret = p_throttling->acpi_processor_set_throttling(pr,
- t_state.target_state);
+ struct set_throttling_info sti
+ = { pr, p_throttling, t_state.target_state };
+ ret = work_on_cpu(pr->id, set_throttling, &sti);
} else {
/*
* When the T-state coordination is SW_ALL or HW_ALL,
@@ -1078,6 +1074,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
* cpus.
*/
for_each_cpu(i, online_throttling_cpus) {
+ struct set_throttling_info sti;
+
match_pr = per_cpu(processors, i);
/*
* If the pointer is invalid, we will report the
@@ -1099,11 +1097,10 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
continue;
}
t_state.cpu = i;
- /* FIXME: use work_on_cpu() */
- set_cpus_allowed_ptr(current, cpumask_of(i));
- ret = match_pr->throttling.
- acpi_processor_set_throttling(
- match_pr, t_state.target_state);
+ sti.pr = match_pr;
+ sti.p_throttling = &match_pr->throttling;
+ sti.target_state = t_state.target_state;
+ ret = work_on_cpu(i, set_throttling, &sti);
}
}
/*
@@ -1117,11 +1114,6 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE,
&t_state);
}
- /* restore the previous state */
- /* FIXME: use work_on_cpu() */
- set_cpus_allowed_ptr(current, saved_mask);
- free_cpumask_var(online_throttling_cpus);
- free_cpumask_var(saved_mask);
return ret;
}
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 08186ecbaf8d..2af686a19a64 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -77,8 +77,6 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
size_t size);
static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
ssize_t size);
-#define MAX_SLOTS 8
-#define MAX_RETRY 15
enum {
AHCI_PCI_BAR = 5,
@@ -230,6 +228,10 @@ enum {
ICH_MAP = 0x90, /* ICH MAP register */
+ /* em constants */
+ EM_MAX_SLOTS = 8,
+ EM_MAX_RETRY = 5,
+
/* em_ctl bits */
EM_CTL_RST = (1 << 9), /* Reset */
EM_CTL_TM = (1 << 8), /* Transmit Message */
@@ -281,8 +283,8 @@ struct ahci_port_priv {
unsigned int ncq_saw_dmas:1;
unsigned int ncq_saw_sdb:1;
u32 intr_mask; /* interrupts to enable */
- struct ahci_em_priv em_priv[MAX_SLOTS];/* enclosure management info
- * per PM slot */
+ /* enclosure management info per PM slot */
+ struct ahci_em_priv em_priv[EM_MAX_SLOTS];
};
static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
@@ -312,7 +314,6 @@ static void ahci_error_handler(struct ata_port *ap);
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
static int ahci_port_resume(struct ata_port *ap);
static void ahci_dev_config(struct ata_device *dev);
-static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl);
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
u32 opts);
#ifdef CONFIG_PM
@@ -403,14 +404,14 @@ static struct ata_port_operations ahci_sb600_ops = {
#define AHCI_HFLAGS(flags) .private_data = (void *)(flags)
static const struct ata_port_info ahci_port_info[] = {
- /* board_ahci */
+ [board_ahci] =
{
.flags = AHCI_FLAG_COMMON,
.pio_mask = ATA_PIO4,
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_ops,
},
- /* board_ahci_vt8251 */
+ [board_ahci_vt8251] =
{
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP),
.flags = AHCI_FLAG_COMMON,
@@ -418,7 +419,7 @@ static const struct ata_port_info ahci_port_info[] = {
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_vt8251_ops,
},
- /* board_ahci_ign_iferr */
+ [board_ahci_ign_iferr] =
{
AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
.flags = AHCI_FLAG_COMMON,
@@ -426,7 +427,7 @@ static const struct ata_port_info ahci_port_info[] = {
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_ops,
},
- /* board_ahci_sb600 */
+ [board_ahci_sb600] =
{
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI |
@@ -436,7 +437,7 @@ static const struct ata_port_info ahci_port_info[] = {
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_sb600_ops,
},
- /* board_ahci_mv */
+ [board_ahci_mv] =
{
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI |
AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP),
@@ -446,7 +447,7 @@ static const struct ata_port_info ahci_port_info[] = {
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_ops,
},
- /* board_ahci_sb700, for SB700 and SB800 */
+ [board_ahci_sb700] = /* for SB700 and SB800 */
{
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),
.flags = AHCI_FLAG_COMMON,
@@ -454,7 +455,7 @@ static const struct ata_port_info ahci_port_info[] = {
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_sb600_ops,
},
- /* board_ahci_mcp65 */
+ [board_ahci_mcp65] =
{
AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
.flags = AHCI_FLAG_COMMON,
@@ -462,7 +463,7 @@ static const struct ata_port_info ahci_port_info[] = {
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_ops,
},
- /* board_ahci_nopmp */
+ [board_ahci_nopmp] =
{
AHCI_HFLAGS (AHCI_HFLAG_NO_PMP),
.flags = AHCI_FLAG_COMMON,
@@ -1140,12 +1141,12 @@ static void ahci_start_port(struct ata_port *ap)
emp = &pp->em_priv[link->pmp];
/* EM Transmit bit maybe busy during init */
- for (i = 0; i < MAX_RETRY; i++) {
+ for (i = 0; i < EM_MAX_RETRY; i++) {
rc = ahci_transmit_led_message(ap,
emp->led_state,
4);
if (rc == -EBUSY)
- udelay(100);
+ msleep(1);
else
break;
}
@@ -1339,7 +1340,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
/* get the slot number from the message */
pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
- if (pmp < MAX_SLOTS)
+ if (pmp < EM_MAX_SLOTS)
emp = &pp->em_priv[pmp];
else
return -EINVAL;
@@ -1407,7 +1408,7 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
/* get the slot number from the message */
pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
- if (pmp < MAX_SLOTS)
+ if (pmp < EM_MAX_SLOTS)
emp = &pp->em_priv[pmp];
else
return -EINVAL;
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index d51a17c0f59b..0fba1124718d 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -223,10 +223,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
/* ICH8 Mobile PATA Controller */
{ 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
- /* NOTE: The following PCI ids must be kept in sync with the
- * list in drivers/pci/quirks.c.
- */
-
+ /* SATA ports */
+
/* 82801EB (ICH5) */
{ 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
/* 82801EB (ICH5) */
@@ -1500,8 +1498,8 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
- /* no hotplugging support (FIXME) */
- if (!in_module_init)
+ /* no hotplugging support for later devices (FIXME) */
+ if (!in_module_init && ent->driver_data >= ich5_sata)
return -ENODEV;
if (piix_broken_system_poweroff(pdev)) {
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 6273d98d00eb..ac176da1f94e 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -748,9 +748,9 @@ static int ata_acpi_run_tf(struct ata_device *dev,
/**
* ata_acpi_exec_tfs - get then write drive taskfile settings
* @dev: target ATA device
- * @nr_executed: out paramter for the number of executed commands
+ * @nr_executed: out parameter for the number of executed commands
*
- * Evaluate _GTF and excute returned taskfiles.
+ * Evaluate _GTF and execute returned taskfiles.
*
* LOCKING:
* EH context.
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c9242301cfa1..ca4d208ddf3b 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5031,7 +5031,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
{
int nr_done = 0;
u32 done_mask;
- int i;
done_mask = ap->qc_active ^ qc_active;
@@ -5041,16 +5040,16 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
return -EINVAL;
}
- for (i = 0; i < ATA_MAX_QUEUE; i++) {
+ while (done_mask) {
struct ata_queued_cmd *qc;
+ unsigned int tag = __ffs(done_mask);
- if (!(done_mask & (1 << i)))
- continue;
-
- if ((qc = ata_qc_from_tag(ap, i))) {
+ qc = ata_qc_from_tag(ap, tag);
+ if (qc) {
ata_qc_complete(qc);
nr_done++;
}
+ done_mask &= ~(1 << tag);
}
return nr_done;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 94919ad03df1..fa22f94ca415 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2864,7 +2864,7 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
/**
* ata_set_mode - Program timings and issue SET FEATURES - XFER
* @link: link on which timings will be programmed
- * @r_failed_dev: out paramter for failed device
+ * @r_failed_dev: out parameter for failed device
*
* Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If
* ata_set_mode() fails, pointer to the failing device is
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 342316064e9f..d0dfeef55db5 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1084,7 +1084,7 @@ static int atapi_drain_needed(struct request *rq)
if (likely(!blk_pc_request(rq)))
return 0;
- if (!rq->data_len || (rq->cmd_flags & REQ_RW))
+ if (!blk_rq_bytes(rq) || (rq->cmd_flags & REQ_RW))
return 0;
return atapi_cmd_type(rq->cmd[0]) == ATAPI_MISC;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index bb18415d3d63..bbbb1fab1755 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -727,17 +727,23 @@ unsigned int ata_sff_data_xfer(struct ata_device *dev, unsigned char *buf,
else
iowrite16_rep(data_addr, buf, words);
- /* Transfer trailing 1 byte, if any. */
+ /* Transfer trailing byte, if any. */
if (unlikely(buflen & 0x01)) {
- __le16 align_buf[1] = { 0 };
- unsigned char *trailing_buf = buf + buflen - 1;
+ unsigned char pad[2];
+ /* Point buf to the tail of buffer */
+ buf += buflen - 1;
+
+ /*
+ * Use io*16_rep() accessors here as well to avoid pointlessly
+ * swapping bytes to and fro on the big endian machines...
+ */
if (rw == READ) {
- align_buf[0] = cpu_to_le16(ioread16(data_addr));
- memcpy(trailing_buf, align_buf, 1);
+ ioread16_rep(data_addr, pad, 1);
+ *buf = pad[0];
} else {
- memcpy(align_buf, trailing_buf, 1);
- iowrite16(le16_to_cpu(align_buf[0]), data_addr);
+ pad[0] = *buf;
+ iowrite16_rep(data_addr, pad, 1);
}
words++;
}
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 751b7ea4816c..fc9c5d6d7d80 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -497,14 +497,16 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
};
/* Revision 0x20 added DMA */
static const struct ata_port_info info_20 = {
- .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
+ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48 |
+ ATA_FLAG_IGN_SIMPLEX,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.port_ops = &ali_20_port_ops
};
/* Revision 0x20 with support logic added UDMA */
static const struct ata_port_info info_20_udma = {
- .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
+ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48 |
+ ATA_FLAG_IGN_SIMPLEX,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.udma_mask = ATA_UDMA2,
@@ -512,7 +514,8 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
};
/* Revision 0xC2 adds UDMA66 */
static const struct ata_port_info info_c2 = {
- .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
+ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48 |
+ ATA_FLAG_IGN_SIMPLEX,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.udma_mask = ATA_UDMA4,
@@ -520,7 +523,8 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
};
/* Revision 0xC3 is UDMA66 for now */
static const struct ata_port_info info_c3 = {
- .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
+ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48 |
+ ATA_FLAG_IGN_SIMPLEX,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.udma_mask = ATA_UDMA4,
@@ -528,7 +532,8 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
};
/* Revision 0xC4 is UDMA100 */
static const struct ata_port_info info_c4 = {
- .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
+ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48 |
+ ATA_FLAG_IGN_SIMPLEX,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.udma_mask = ATA_UDMA5,
@@ -536,7 +541,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
};
/* Revision 0xC5 is UDMA133 with LBA48 DMA */
static const struct ata_port_info info_c5 = {
- .flags = ATA_FLAG_SLAVE_POSS,
+ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_IGN_SIMPLEX,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index e67ce8e5caa5..030ec079b184 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -183,7 +183,7 @@ static struct scsi_host_template sil_sht = {
};
static struct ata_port_operations sil_ops = {
- .inherits = &ata_bmdma_port_ops,
+ .inherits = &ata_bmdma32_port_ops,
.dev_config = sil_dev_config,
.set_mode = sil_set_mode,
.bmdma_setup = sil_bmdma_setup,
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index eb05a3c82a9e..bbcf970068ad 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -193,6 +193,7 @@ enum {
PDC_TIMER_MASK_INT,
};
+#define ECC_ERASE_BUF_SZ (128 * 1024)
struct pdc_port_priv {
u8 dimm_buf[(ATA_PRD_SZ * ATA_MAX_PRD) + 512];
@@ -1280,7 +1281,6 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
{
int speed, size, length;
u32 addr, spd0, pci_status;
- u32 tmp = 0;
u32 time_period = 0;
u32 tcount = 0;
u32 ticks = 0;
@@ -1395,14 +1395,17 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
PDC_DIMM_SPD_TYPE, &spd0);
if (spd0 == 0x02) {
+ void *buf;
VPRINTK("Start ECC initialization\n");
addr = 0;
length = size * 1024 * 1024;
+ buf = kzalloc(ECC_ERASE_BUF_SZ, GFP_KERNEL);
while (addr < length) {
- pdc20621_put_to_dimm(host, (void *) &tmp, addr,
- sizeof(u32));
- addr += sizeof(u32);
+ pdc20621_put_to_dimm(host, buf, addr,
+ ECC_ERASE_BUF_SZ);
+ addr += ECC_ERASE_BUF_SZ;
}
+ kfree(buf);
VPRINTK("Finish ECC initialization\n");
}
return 0;
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 8f006f96ff53..ee377270beb9 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -8,6 +8,31 @@ config UEVENT_HELPER_PATH
Path to uevent helper program forked by the kernel for
every uevent.
+config DEVTMPFS
+ bool "Create a kernel maintained /dev tmpfs (EXPERIMENTAL)"
+ depends on HOTPLUG && SHMEM && TMPFS
+ help
+ This creates a tmpfs filesystem, and mounts it at bootup
+ and mounts it at /dev. The kernel driver core creates device
+ nodes for all registered devices in that filesystem. All device
+ nodes are owned by root and have the default mode of 0600.
+ Userspace can add and delete the nodes as needed. This is
+ intended to simplify bootup, and make it possible to delay
+ the initial coldplug at bootup done by udev in userspace.
+ It should also provide a simpler way for rescue systems
+ to bring up a kernel with dynamic major/minor numbers.
+ Meaningful symlinks, permissions and device ownership must
+ still be handled by userspace.
+ If unsure, say N here.
+
+config DEVTMPFS_MOUNT
+ bool "Automount devtmpfs at /dev"
+ depends on DEVTMPFS
+ help
+ This will mount devtmpfs at /dev if the kernel mounts the root
+ filesystem. It will not affect initramfs based mounting.
+ If unsure, say N here.
+
config STANDALONE
bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL
default y
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index b5b8ba512b28..68b225aa2266 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -4,6 +4,7 @@ obj-y := core.o sys.o bus.o dd.o \
driver.o class.o platform.o \
cpu.o firmware.o init.o map.o devres.o \
attribute_container.o transport_class.o
+obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
obj-y += power/
obj-$(CONFIG_HAS_DMA) += dma-mapping.o
obj-$(CONFIG_ISA) += isa.o
diff --git a/drivers/base/base.h b/drivers/base/base.h
index b528145a078f..45be568a7d96 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -134,3 +134,9 @@ static inline void module_add_driver(struct module *mod,
struct device_driver *drv) { }
static inline void module_remove_driver(struct device_driver *drv) { }
#endif
+
+#ifdef CONFIG_DEVTMPFS
+extern int devtmpfs_init(void);
+#else
+static inline int devtmpfs_init(void) { return 0; }
+#endif
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index dc030f1f00f1..4b04a15146d7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -279,7 +279,7 @@ static struct device *next_device(struct klist_iter *i)
*
* NOTE: The device that returns a non-zero value is not retained
* in any way, nor is its refcount incremented. If the caller needs
- * to retain this data, it should do, and increment the reference
+ * to retain this data, it should do so, and increment the reference
* count in the supplied callback.
*/
int bus_for_each_dev(struct bus_type *bus, struct device *start,
@@ -700,8 +700,10 @@ int bus_add_driver(struct device_driver *drv)
}
kobject_uevent(&priv->kobj, KOBJ_ADD);
- return error;
+ return 0;
out_unregister:
+ kfree(drv->p);
+ drv->p = NULL;
kobject_put(&priv->kobj);
out_put_bus:
bus_put(bus);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4aa527b8a913..8aa3b3c2d368 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -161,10 +161,18 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
struct device *dev = to_dev(kobj);
int retval = 0;
- /* add the major/minor if present */
+ /* add device node properties if present */
if (MAJOR(dev->devt)) {
+ const char *tmp;
+ const char *name;
+
add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt));
add_uevent_var(env, "MINOR=%u", MINOR(dev->devt));
+ name = device_get_nodename(dev, &tmp);
+ if (name) {
+ add_uevent_var(env, "DEVNAME=%s", name);
+ kfree(tmp);
+ }
}
if (dev->type && dev->type->name)
@@ -879,7 +887,7 @@ int device_add(struct device *dev)
}
if (!dev_name(dev))
- goto done;
+ goto name_error;
pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
@@ -912,6 +920,8 @@ int device_add(struct device *dev)
error = device_create_sys_dev_entry(dev);
if (error)
goto devtattrError;
+
+ devtmpfs_create_node(dev);
}
error = device_add_class_symlinks(dev);
@@ -978,6 +988,9 @@ done:
cleanup_device_parent(dev);
if (parent)
put_device(parent);
+name_error:
+ kfree(dev->p);
+ dev->p = NULL;
goto done;
}
@@ -1055,6 +1068,7 @@ void device_del(struct device *dev)
if (parent)
klist_del(&dev->p->knode_parent);
if (MAJOR(dev->devt)) {
+ devtmpfs_delete_node(dev);
device_remove_sys_dev_entry(dev);
device_remove_file(dev, &devt_attr);
}
@@ -1125,6 +1139,47 @@ static struct device *next_device(struct klist_iter *i)
}
/**
+ * device_get_nodename - path of device node file
+ * @dev: device
+ * @tmp: possibly allocated string
+ *
+ * Return the relative path of a possible device node.
+ * Non-default names may need to allocate a memory to compose
+ * a name. This memory is returned in tmp and needs to be
+ * freed by the caller.
+ */
+const char *device_get_nodename(struct device *dev, const char **tmp)
+{
+ char *s;
+
+ *tmp = NULL;
+
+ /* the device type may provide a specific name */
+ if (dev->type && dev->type->nodename)
+ *tmp = dev->type->nodename(dev);
+ if (*tmp)
+ return *tmp;
+
+ /* the class may provide a specific name */
+ if (dev->class && dev->class->nodename)
+ *tmp = dev->class->nodename(dev);
+ if (*tmp)
+ return *tmp;
+
+ /* return name without allocation, tmp == NULL */
+ if (strchr(dev_name(dev), '!') == NULL)
+ return dev_name(dev);
+
+ /* replace '!' in the name with '/' */
+ *tmp = kstrdup(dev_name(dev), GFP_KERNEL);
+ if (!*tmp)
+ return NULL;
+ while ((s = strchr(*tmp, '!')))
+ s[0] = '/';
+ return *tmp;
+}
+
+/**
* device_for_each_child - device child iterator.
* @parent: parent struct device.
* @data: data for the callback.
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 742cbe6b042b..f0106875f01d 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -226,7 +226,7 @@ static int __device_attach(struct device_driver *drv, void *data)
* pair is found, break out and return.
*
* Returns 1 if the device was bound to a driver;
- * 0 if no matching device was found;
+ * 0 if no matching driver was found;
* -ENODEV if the device is not registered.
*
* When called for a USB interface, @dev->parent->sem must be held.
@@ -320,6 +320,10 @@ static void __device_release_driver(struct device *dev)
devres_release_all(dev);
dev->driver = NULL;
klist_remove(&dev->p->knode_driver);
+ if (dev->bus)
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
+ BUS_NOTIFY_UNBOUND_DRIVER,
+ dev);
}
}
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
new file mode 100644
index 000000000000..51c410ffa145
--- /dev/null
+++ b/drivers/base/devtmpfs.c
@@ -0,0 +1,367 @@
+/*
+ * devtmpfs - kernel-maintained tmpfs-based /dev
+ *
+ * Copyright (C) 2009, Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * During bootup, before any driver core device is registered,
+ * devtmpfs, a tmpfs-based filesystem is created. Every driver-core
+ * device which requests a device node, will add a node in this
+ * filesystem. The node is named after the the name of the device,
+ * or the susbsytem can provide a custom name. All devices are
+ * owned by root and have a mode of 0600.
+ */
+
+#include <linux/kernel.h>
+#include <linux/syscalls.h>
+#include <linux/mount.h>
+#include <linux/device.h>
+#include <linux/genhd.h>
+#include <linux/namei.h>
+#include <linux/fs.h>
+#include <linux/shmem_fs.h>
+#include <linux/cred.h>
+#include <linux/init_task.h>
+
+static struct vfsmount *dev_mnt;
+
+#if defined CONFIG_DEVTMPFS_MOUNT
+static int dev_mount = 1;
+#else
+static int dev_mount;
+#endif
+
+static int __init mount_param(char *str)
+{
+ dev_mount = simple_strtoul(str, NULL, 0);
+ return 1;
+}
+__setup("devtmpfs.mount=", mount_param);
+
+static int dev_get_sb(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data, struct vfsmount *mnt)
+{
+ return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt);
+}
+
+static struct file_system_type dev_fs_type = {
+ .name = "devtmpfs",
+ .get_sb = dev_get_sb,
+ .kill_sb = kill_litter_super,
+};
+
+#ifdef CONFIG_BLOCK
+static inline int is_blockdev(struct device *dev)
+{
+ return dev->class == &block_class;
+}
+#else
+static inline int is_blockdev(struct device *dev) { return 0; }
+#endif
+
+static int dev_mkdir(const char *name, mode_t mode)
+{
+ struct nameidata nd;
+ struct dentry *dentry;
+ int err;
+
+ err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
+ name, LOOKUP_PARENT, &nd);
+ if (err)
+ return err;
+
+ dentry = lookup_create(&nd, 1);
+ if (!IS_ERR(dentry)) {
+ err = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode);
+ dput(dentry);
+ } else {
+ err = PTR_ERR(dentry);
+ }
+ mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
+
+ path_put(&nd.path);
+ return err;
+}
+
+static int create_path(const char *nodepath)
+{
+ char *path;
+ struct nameidata nd;
+ int err = 0;
+
+ path = kstrdup(nodepath, GFP_KERNEL);
+ if (!path)
+ return -ENOMEM;
+
+ err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
+ path, LOOKUP_PARENT, &nd);
+ if (err == 0) {
+ struct dentry *dentry;
+
+ /* create directory right away */
+ dentry = lookup_create(&nd, 1);
+ if (!IS_ERR(dentry)) {
+ err = vfs_mkdir(nd.path.dentry->d_inode,
+ dentry, 0775);
+ dput(dentry);
+ }
+ mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
+
+ path_put(&nd.path);
+ } else if (err == -ENOENT) {
+ char *s;
+
+ /* parent directories do not exist, create them */
+ s = path;
+ while (1) {
+ s = strchr(s, '/');
+ if (!s)
+ break;
+ s[0] = '\0';
+ err = dev_mkdir(path, 0755);
+ if (err && err != -EEXIST)
+ break;
+ s[0] = '/';
+ s++;
+ }
+ }
+
+ kfree(path);
+ return err;
+}
+
+int devtmpfs_create_node(struct device *dev)
+{
+ const char *tmp = NULL;
+ const char *nodename;
+ const struct cred *curr_cred;
+ mode_t mode;
+ struct nameidata nd;
+ struct dentry *dentry;
+ int err;
+
+ if (!dev_mnt)
+ return 0;
+
+ nodename = device_get_nodename(dev, &tmp);
+ if (!nodename)
+ return -ENOMEM;
+
+ if (is_blockdev(dev))
+ mode = S_IFBLK|0600;
+ else
+ mode = S_IFCHR|0600;
+
+ curr_cred = override_creds(&init_cred);
+ err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
+ nodename, LOOKUP_PARENT, &nd);
+ if (err == -ENOENT) {
+ /* create missing parent directories */
+ create_path(nodename);
+ err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
+ nodename, LOOKUP_PARENT, &nd);
+ if (err)
+ goto out;
+ }
+
+ dentry = lookup_create(&nd, 0);
+ if (!IS_ERR(dentry)) {
+ err = vfs_mknod(nd.path.dentry->d_inode,
+ dentry, mode, dev->devt);
+ /* mark as kernel created inode */
+ if (!err)
+ dentry->d_inode->i_private = &dev_mnt;
+ dput(dentry);
+ } else {
+ err = PTR_ERR(dentry);
+ }
+ mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
+
+ path_put(&nd.path);
+out:
+ kfree(tmp);
+ revert_creds(curr_cred);
+ return err;
+}
+
+static int dev_rmdir(const char *name)
+{
+ struct nameidata nd;
+ struct dentry *dentry;
+ int err;
+
+ err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
+ name, LOOKUP_PARENT, &nd);
+ if (err)
+ return err;
+
+ mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
+ dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
+ if (!IS_ERR(dentry)) {
+ if (dentry->d_inode)
+ err = vfs_rmdir(nd.path.dentry->d_inode, dentry);
+ else
+ err = -ENOENT;
+ dput(dentry);
+ } else {
+ err = PTR_ERR(dentry);
+ }
+ mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
+
+ path_put(&nd.path);
+ return err;
+}
+
+static int delete_path(const char *nodepath)
+{
+ const char *path;
+ int err = 0;
+
+ path = kstrdup(nodepath, GFP_KERNEL);
+ if (!path)
+ return -ENOMEM;
+
+ while (1) {
+ char *base;
+
+ base = strrchr(path, '/');
+ if (!base)
+ break;
+ base[0] = '\0';
+ err = dev_rmdir(path);
+ if (err)
+ break;
+ }
+
+ kfree(path);
+ return err;
+}
+
+static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *stat)
+{
+ /* did we create it */
+ if (inode->i_private != &dev_mnt)
+ return 0;
+
+ /* does the dev_t match */
+ if (is_blockdev(dev)) {
+ if (!S_ISBLK(stat->mode))
+ return 0;
+ } else {
+ if (!S_ISCHR(stat->mode))
+ return 0;
+ }
+ if (stat->rdev != dev->devt)
+ return 0;
+
+ /* ours */
+ return 1;
+}
+
+int devtmpfs_delete_node(struct device *dev)
+{
+ const char *tmp = NULL;
+ const char *nodename;
+ const struct cred *curr_cred;
+ struct nameidata nd;
+ struct dentry *dentry;
+ struct kstat stat;
+ int deleted = 1;
+ int err;
+
+ if (!dev_mnt)
+ return 0;
+
+ nodename = device_get_nodename(dev, &tmp);
+ if (!nodename)
+ return -ENOMEM;
+
+ curr_cred = override_creds(&init_cred);
+ err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
+ nodename, LOOKUP_PARENT, &nd);
+ if (err)
+ goto out;
+
+ mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
+ dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
+ if (!IS_ERR(dentry)) {
+ if (dentry->d_inode) {
+ err = vfs_getattr(nd.path.mnt, dentry, &stat);
+ if (!err && dev_mynode(dev, dentry->d_inode, &stat)) {
+ err = vfs_unlink(nd.path.dentry->d_inode,
+ dentry);
+ if (!err || err == -ENOENT)
+ deleted = 1;
+ }
+ } else {
+ err = -ENOENT;
+ }
+ dput(dentry);
+ } else {
+ err = PTR_ERR(dentry);
+ }
+ mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
+
+ path_put(&nd.path);
+ if (deleted && strchr(nodename, '/'))
+ delete_path(nodename);
+out:
+ kfree(tmp);
+ revert_creds(curr_cred);
+ return err;
+}
+
+/*
+ * If configured, or requested by the commandline, devtmpfs will be
+ * auto-mounted after the kernel mounted the root filesystem.
+ */
+int devtmpfs_mount(const char *mountpoint)
+{
+ struct path path;
+ int err;
+
+ if (!dev_mount)
+ return 0;
+
+ if (!dev_mnt)
+ return 0;
+
+ err = kern_path(mountpoint, LOOKUP_FOLLOW, &path);
+ if (err)
+ return err;
+ err = do_add_mount(dev_mnt, &path, 0, NULL);
+ if (err)
+ printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
+ else
+ printk(KERN_INFO "devtmpfs: mounted\n");
+ path_put(&path);
+ return err;
+}
+
+/*
+ * Create devtmpfs instance, driver-core devices will add their device
+ * nodes here.
+ */
+int __init devtmpfs_init(void)
+{
+ int err;
+ struct vfsmount *mnt;
+
+ err = register_filesystem(&dev_fs_type);
+ if (err) {
+ printk(KERN_ERR "devtmpfs: unable to register devtmpfs "
+ "type %i\n", err);
+ return err;
+ }
+
+ mnt = kern_mount(&dev_fs_type);
+ if (IS_ERR(mnt)) {
+ err = PTR_ERR(mnt);
+ printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err);
+ unregister_filesystem(&dev_fs_type);
+ return err;
+ }
+ dev_mnt = mnt;
+
+ printk(KERN_INFO "devtmpfs: initialized\n");
+ return 0;
+}
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index c51f11bb29ae..8ae0f63602e0 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -257,6 +257,10 @@ EXPORT_SYMBOL_GPL(driver_register);
*/
void driver_unregister(struct device_driver *drv)
{
+ if (!drv || !drv->p) {
+ WARN(1, "Unexpected driver unregister!\n");
+ return;
+ }
driver_remove_groups(drv, drv->groups);
bus_remove_driver(drv);
}
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d3a59c688fe4..2d296b7f7034 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -17,7 +17,7 @@
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/kthread.h>
-
+#include <linux/highmem.h>
#include <linux/firmware.h>
#include "base.h"
@@ -45,7 +45,10 @@ struct firmware_priv {
struct bin_attribute attr_data;
struct firmware *fw;
unsigned long status;
- int alloc_size;
+ struct page **pages;
+ int nr_pages;
+ int page_array_size;
+ const char *vdata;
struct timer_list timeout;
};
@@ -122,6 +125,10 @@ static ssize_t firmware_loading_show(struct device *dev,
return sprintf(buf, "%d\n", loading);
}
+/* Some architectures don't have PAGE_KERNEL_RO */
+#ifndef PAGE_KERNEL_RO
+#define PAGE_KERNEL_RO PAGE_KERNEL
+#endif
/**
* firmware_loading_store - set value in the 'loading' control file
* @dev: device pointer
@@ -141,6 +148,7 @@ static ssize_t firmware_loading_store(struct device *dev,
{
struct firmware_priv *fw_priv = dev_get_drvdata(dev);
int loading = simple_strtol(buf, NULL, 10);
+ int i;
switch (loading) {
case 1:
@@ -151,13 +159,30 @@ static ssize_t firmware_loading_store(struct device *dev,
}
vfree(fw_priv->fw->data);
fw_priv->fw->data = NULL;
+ for (i = 0; i < fw_priv->nr_pages; i++)
+ __free_page(fw_priv->pages[i]);
+ kfree(fw_priv->pages);
+ fw_priv->pages = NULL;
+ fw_priv->page_array_size = 0;
+ fw_priv->nr_pages = 0;
fw_priv->fw->size = 0;
- fw_priv->alloc_size = 0;
set_bit(FW_STATUS_LOADING, &fw_priv->status);
mutex_unlock(&fw_lock);
break;
case 0:
if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) {
+ vfree(fw_priv->fw->data);
+ fw_priv->fw->data = vmap(fw_priv->pages,
+ fw_priv->nr_pages,
+ 0, PAGE_KERNEL_RO);
+ if (!fw_priv->fw->data) {
+ dev_err(dev, "%s: vmap() failed\n", __func__);
+ goto err;
+ }
+ /* Pages will be freed by vfree() */
+ fw_priv->pages = NULL;
+ fw_priv->page_array_size = 0;
+ fw_priv->nr_pages = 0;
complete(&fw_priv->completion);
clear_bit(FW_STATUS_LOADING, &fw_priv->status);
break;
@@ -167,6 +192,7 @@ static ssize_t firmware_loading_store(struct device *dev,
dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
/* fallthrough */
case -1:
+ err:
fw_load_abort(fw_priv);
break;
}
@@ -191,8 +217,28 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
ret_count = -ENODEV;
goto out;
}
- ret_count = memory_read_from_buffer(buffer, count, &offset,
- fw->data, fw->size);
+ if (offset > fw->size)
+ return 0;
+ if (count > fw->size - offset)
+ count = fw->size - offset;
+
+ ret_count = count;
+
+ while (count) {
+ void *page_data;
+ int page_nr = offset >> PAGE_SHIFT;
+ int page_ofs = offset & (PAGE_SIZE-1);
+ int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
+
+ page_data = kmap(fw_priv->pages[page_nr]);
+
+ memcpy(buffer, page_data + page_ofs, page_cnt);
+
+ kunmap(fw_priv->pages[page_nr]);
+ buffer += page_cnt;
+ offset += page_cnt;
+ count -= page_cnt;
+ }
out:
mutex_unlock(&fw_lock);
return ret_count;
@@ -201,27 +247,39 @@ out:
static int
fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
{
- u8 *new_data;
- int new_size = fw_priv->alloc_size;
+ int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT;
+
+ /* If the array of pages is too small, grow it... */
+ if (fw_priv->page_array_size < pages_needed) {
+ int new_array_size = max(pages_needed,
+ fw_priv->page_array_size * 2);
+ struct page **new_pages;
+
+ new_pages = kmalloc(new_array_size * sizeof(void *),
+ GFP_KERNEL);
+ if (!new_pages) {
+ fw_load_abort(fw_priv);
+ return -ENOMEM;
+ }
+ memcpy(new_pages, fw_priv->pages,
+ fw_priv->page_array_size * sizeof(void *));
+ memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) *
+ (new_array_size - fw_priv->page_array_size));
+ kfree(fw_priv->pages);
+ fw_priv->pages = new_pages;
+ fw_priv->page_array_size = new_array_size;
+ }
- if (min_size <= fw_priv->alloc_size)
- return 0;
+ while (fw_priv->nr_pages < pages_needed) {
+ fw_priv->pages[fw_priv->nr_pages] =
+ alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
- new_size = ALIGN(min_size, PAGE_SIZE);
- new_data = vmalloc(new_size);
- if (!new_data) {
- printk(KERN_ERR "%s: unable to alloc buffer\n", __func__);
- /* Make sure that we don't keep incomplete data */
- fw_load_abort(fw_priv);
- return -ENOMEM;
- }
- fw_priv->alloc_size = new_size;
- if (fw_priv->fw->data) {
- memcpy(new_data, fw_priv->fw->data, fw_priv->fw->size);
- vfree(fw_priv->fw->data);
+ if (!fw_priv->pages[fw_priv->nr_pages]) {
+ fw_load_abort(fw_priv);
+ return -ENOMEM;
+ }
+ fw_priv->nr_pages++;
}
- fw_priv->fw->data = new_data;
- BUG_ON(min_size > fw_priv->alloc_size);
return 0;
}
@@ -258,10 +316,25 @@ firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr,
if (retval)
goto out;
- memcpy((u8 *)fw->data + offset, buffer, count);
-
- fw->size = max_t(size_t, offset + count, fw->size);
retval = count;
+
+ while (count) {
+ void *page_data;
+ int page_nr = offset >> PAGE_SHIFT;
+ int page_ofs = offset & (PAGE_SIZE - 1);
+ int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
+
+ page_data = kmap(fw_priv->pages[page_nr]);
+
+ memcpy(page_data + page_ofs, buffer, page_cnt);
+
+ kunmap(fw_priv->pages[page_nr]);
+ buffer += page_cnt;
+ offset += page_cnt;
+ count -= page_cnt;
+ }
+
+ fw->size = max_t(size_t, offset, fw->size);
out:
mutex_unlock(&fw_lock);
return retval;
@@ -277,9 +350,13 @@ static struct bin_attribute firmware_attr_data_tmpl = {
static void fw_dev_release(struct device *dev)
{
struct firmware_priv *fw_priv = dev_get_drvdata(dev);
+ int i;
+ for (i = 0; i < fw_priv->nr_pages; i++)
+ __free_page(fw_priv->pages[i]);
+ kfree(fw_priv->pages);
kfree(fw_priv);
- kfree(dev);
+ put_device(dev);
module_put(THIS_MODULE);
}
@@ -323,14 +400,16 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
retval = device_register(f_dev);
if (retval) {
dev_err(device, "%s: device_register failed\n", __func__);
- goto error_kfree;
+ put_device(f_dev);
+ goto error_kfree1;
}
*dev_p = f_dev;
return 0;
error_kfree:
- kfree(fw_priv);
kfree(f_dev);
+error_kfree1:
+ kfree(fw_priv);
return retval;
}
diff --git a/drivers/base/init.c b/drivers/base/init.c
index 7bd9b6a5b01f..c8a934e79421 100644
--- a/drivers/base/init.c
+++ b/drivers/base/init.c
@@ -20,6 +20,7 @@
void __init driver_init(void)
{
/* These are the core pieces */
+ devtmpfs_init();
devices_init();
buses_init();
classes_init();
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8b4708e06244..8a583bebec55 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -69,7 +69,8 @@ EXPORT_SYMBOL_GPL(platform_get_irq);
* @name: resource name
*/
struct resource *platform_get_resource_byname(struct platform_device *dev,
- unsigned int type, char *name)
+ unsigned int type,
+ const char *name)
{
int i;
@@ -88,7 +89,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname);
* @dev: platform device
* @name: IRQ name
*/
-int platform_get_irq_byname(struct platform_device *dev, char *name)
+int platform_get_irq_byname(struct platform_device *dev, const char *name)
{
struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ,
name);
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 69b4ddb7de3b..68f9f3cecf7a 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -315,13 +315,13 @@ static void pm_dev_err(struct device *dev, pm_message_t state, char *info,
/*------------------------- Resume routines -------------------------*/
/**
- * resume_device_noirq - Power on one device (early resume).
+ * device_resume_noirq - Power on one device (early resume).
* @dev: Device.
* @state: PM transition of the system being carried out.
*
* Must be called with interrupts disabled.
*/
-static int resume_device_noirq(struct device *dev, pm_message_t state)
+static int device_resume_noirq(struct device *dev, pm_message_t state)
{
int error = 0;
@@ -334,9 +334,6 @@ static int resume_device_noirq(struct device *dev, pm_message_t state)
if (dev->bus->pm) {
pm_dev_dbg(dev, state, "EARLY ");
error = pm_noirq_op(dev, dev->bus->pm, state);
- } else if (dev->bus->resume_early) {
- pm_dev_dbg(dev, state, "legacy EARLY ");
- error = dev->bus->resume_early(dev);
}
End:
TRACE_RESUME(error);
@@ -344,50 +341,40 @@ static int resume_device_noirq(struct device *dev, pm_message_t state)
}
/**
- * dpm_power_up - Power on all regular (non-sysdev) devices.
+ * dpm_resume_noirq - Power on all regular (non-sysdev) devices.
* @state: PM transition of the system being carried out.
*
- * Execute the appropriate "noirq resume" callback for all devices marked
- * as DPM_OFF_IRQ.
+ * Call the "noirq" resume handlers for all devices marked as
+ * DPM_OFF_IRQ and enable device drivers to receive interrupts.
*
* Must be called under dpm_list_mtx. Device drivers should not receive
* interrupts while it's being executed.
*/
-static void dpm_power_up(pm_message_t state)
+void dpm_resume_noirq(pm_message_t state)
{
struct device *dev;
+ mutex_lock(&dpm_list_mtx);
list_for_each_entry(dev, &dpm_list, power.entry)
if (dev->power.status > DPM_OFF) {
int error;
dev->power.status = DPM_OFF;
- error = resume_device_noirq(dev, state);
+ error = device_resume_noirq(dev, state);
if (error)
pm_dev_err(dev, state, " early", error);
}
-}
-
-/**
- * device_power_up - Turn on all devices that need special attention.
- * @state: PM transition of the system being carried out.
- *
- * Call the "early" resume handlers and enable device drivers to receive
- * interrupts.
- */
-void device_power_up(pm_message_t state)
-{
- dpm_power_up(state);
+ mutex_unlock(&dpm_list_mtx);
resume_device_irqs();
}
-EXPORT_SYMBOL_GPL(device_power_up);
+EXPORT_SYMBOL_GPL(dpm_resume_noirq);
/**
- * resume_device - Restore state for one device.
+ * device_resume - Restore state for one device.
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
-static int resume_device(struct device *dev, pm_message_t state)
+static int device_resume(struct device *dev, pm_message_t state)
{
int error = 0;
@@ -460,7 +447,7 @@ static void dpm_resume(pm_message_t state)
dev->power.status = DPM_RESUMING;
mutex_unlock(&dpm_list_mtx);
- error = resume_device(dev, state);
+ error = device_resume(dev, state);
mutex_lock(&dpm_list_mtx);
if (error)
@@ -478,11 +465,11 @@ static void dpm_resume(pm_message_t state)
}
/**
- * complete_device - Complete a PM transition for given device
+ * device_complete - Complete a PM transition for given device
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
-static void complete_device(struct device *dev, pm_message_t state)
+static void device_complete(struct device *dev, pm_message_t state)
{
down(&dev->sem);
@@ -525,7 +512,7 @@ static void dpm_complete(pm_message_t state)
dev->power.status = DPM_ON;
mutex_unlock(&dpm_list_mtx);
- complete_device(dev, state);
+ device_complete(dev, state);
mutex_lock(&dpm_list_mtx);
}
@@ -538,19 +525,19 @@ static void dpm_complete(pm_message_t state)
}
/**
- * device_resume - Restore state of each device in system.
+ * dpm_resume_end - Restore state of each device in system.
* @state: PM transition of the system being carried out.
*
* Resume all the devices, unlock them all, and allow new
* devices to be registered once again.
*/
-void device_resume(pm_message_t state)
+void dpm_resume_end(pm_message_t state)
{
might_sleep();
dpm_resume(state);
dpm_complete(state);
}
-EXPORT_SYMBOL_GPL(device_resume);
+EXPORT_SYMBOL_GPL(dpm_resume_end);
/*------------------------- Suspend routines -------------------------*/
@@ -575,13 +562,13 @@ static pm_message_t resume_event(pm_message_t sleep_state)
}
/**
- * suspend_device_noirq - Shut down one device (late suspend).
+ * device_suspend_noirq - Shut down one device (late suspend).
* @dev: Device.
* @state: PM transition of the system being carried out.
*
* This is called with interrupts off and only a single CPU running.
*/
-static int suspend_device_noirq(struct device *dev, pm_message_t state)
+static int device_suspend_noirq(struct device *dev, pm_message_t state)
{
int error = 0;
@@ -591,49 +578,47 @@ static int suspend_device_noirq(struct device *dev, pm_message_t state)
if (dev->bus->pm) {
pm_dev_dbg(dev, state, "LATE ");
error = pm_noirq_op(dev, dev->bus->pm, state);
- } else if (dev->bus->suspend_late) {
- pm_dev_dbg(dev, state, "legacy LATE ");
- error = dev->bus->suspend_late(dev, state);
- suspend_report_result(dev->bus->suspend_late, error);
}
return error;
}
/**
- * device_power_down - Shut down special devices.
+ * dpm_suspend_noirq - Power down all regular (non-sysdev) devices.
* @state: PM transition of the system being carried out.
*
- * Prevent device drivers from receiving interrupts and call the "late"
+ * Prevent device drivers from receiving interrupts and call the "noirq"
* suspend handlers.
*
* Must be called under dpm_list_mtx.
*/
-int device_power_down(pm_message_t state)
+int dpm_suspend_noirq(pm_message_t state)
{
struct device *dev;
int error = 0;
suspend_device_irqs();
+ mutex_lock(&dpm_list_mtx);
list_for_each_entry_reverse(dev, &dpm_list, power.entry) {
- error = suspend_device_noirq(dev, state);
+ error = device_suspend_noirq(dev, state);
if (error) {
pm_dev_err(dev, state, " late", error);
break;
}
dev->power.status = DPM_OFF_IRQ;
}
+ mutex_unlock(&dpm_list_mtx);
if (error)
- device_power_up(resume_event(state));
+ dpm_resume_noirq(resume_event(state));
return error;
}
-EXPORT_SYMBOL_GPL(device_power_down);
+EXPORT_SYMBOL_GPL(dpm_suspend_noirq);
/**
- * suspend_device - Save state of one device.
+ * device_suspend - Save state of one device.
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
-static int suspend_device(struct device *dev, pm_message_t state)
+static int device_suspend(struct device *dev, pm_message_t state)
{
int error = 0;
@@ -700,7 +685,7 @@ static int dpm_suspend(pm_message_t state)
get_device(dev);
mutex_unlock(&dpm_list_mtx);
- error = suspend_device(dev, state);
+ error = device_suspend(dev, state);
mutex_lock(&dpm_list_mtx);
if (error) {
@@ -719,11 +704,11 @@ static int dpm_suspend(pm_message_t state)
}
/**
- * prepare_device - Execute the ->prepare() callback(s) for given device.
+ * device_prepare - Execute the ->prepare() callback(s) for given device.
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
-static int prepare_device(struct device *dev, pm_message_t state)
+static int device_prepare(struct device *dev, pm_message_t state)
{
int error = 0;
@@ -777,7 +762,7 @@ static int dpm_prepare(pm_message_t state)
dev->power.status = DPM_PREPARING;
mutex_unlock(&dpm_list_mtx);
- error = prepare_device(dev, state);
+ error = device_prepare(dev, state);
mutex_lock(&dpm_list_mtx);
if (error) {
@@ -803,12 +788,12 @@ static int dpm_prepare(pm_message_t state)
}
/**
- * device_suspend - Save state and stop all devices in system.
+ * dpm_suspend_start - Save state and stop all devices in system.
* @state: PM transition of the system being carried out.
*
* Prepare and suspend all devices.
*/
-int device_suspend(pm_message_t state)
+int dpm_suspend_start(pm_message_t state)
{
int error;
@@ -818,7 +803,7 @@ int device_suspend(pm_message_t state)
error = dpm_suspend(state);
return error;
}
-EXPORT_SYMBOL_GPL(device_suspend);
+EXPORT_SYMBOL_GPL(dpm_suspend_start);
void __suspend_report_result(const char *function, void *fn, int ret)
{
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 3236b434b964..162355cd745a 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -131,6 +131,8 @@ static struct kset *system_kset;
int sysdev_class_register(struct sysdev_class *cls)
{
+ int retval;
+
pr_debug("Registering sysdev class '%s'\n", cls->name);
INIT_LIST_HEAD(&cls->drivers);
@@ -138,7 +140,11 @@ int sysdev_class_register(struct sysdev_class *cls)
cls->kset.kobj.parent = &system_kset->kobj;
cls->kset.kobj.ktype = &ktype_sysdev_class;
cls->kset.kobj.kset = system_kset;
- kobject_set_name(&cls->kset.kobj, cls->name);
+
+ retval = kobject_set_name(&cls->kset.kobj, cls->name);
+ if (retval)
+ return retval;
+
return kset_register(&cls->kset);
}
@@ -343,11 +349,15 @@ static void __sysdev_resume(struct sys_device *dev)
/* First, call the class-specific one */
if (cls->resume)
cls->resume(dev);
+ WARN_ONCE(!irqs_disabled(),
+ "Interrupts enabled after %pF\n", cls->resume);
/* Call auxillary drivers next. */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->resume)
drv->resume(dev);
+ WARN_ONCE(!irqs_disabled(),
+ "Interrupts enabled after %pF\n", drv->resume);
}
}
@@ -377,6 +387,9 @@ int sysdev_suspend(pm_message_t state)
if (ret)
return ret;
+ WARN_ONCE(!irqs_disabled(),
+ "Interrupts enabled while suspending system devices\n");
+
pr_debug("Suspending System Devices\n");
list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
@@ -393,6 +406,9 @@ int sysdev_suspend(pm_message_t state)
if (ret)
goto aux_driver;
}
+ WARN_ONCE(!irqs_disabled(),
+ "Interrupts enabled after %pF\n",
+ drv->suspend);
}
/* Now call the generic one */
@@ -400,6 +416,9 @@ int sysdev_suspend(pm_message_t state)
ret = cls->suspend(sysdev, state);
if (ret)
goto cls_driver;
+ WARN_ONCE(!irqs_disabled(),
+ "Interrupts enabled after %pF\n",
+ cls->suspend);
}
}
}
@@ -452,6 +471,9 @@ int sysdev_resume(void)
{
struct sysdev_class *cls;
+ WARN_ONCE(!irqs_disabled(),
+ "Interrupts enabled while resuming system devices\n");
+
pr_debug("Resuming System Devices\n");
list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) {
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index f22ed6cc69f2..668dc234b8e2 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -3321,7 +3321,7 @@ static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_
DAC960_Command_T *Command;
while(1) {
- Request = elv_next_request(req_q);
+ Request = blk_peek_request(req_q);
if (!Request)
return 1;
@@ -3338,10 +3338,10 @@ static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_
}
Command->Completion = Request->end_io_data;
Command->LogicalDriveNumber = (long)Request->rq_disk->private_data;
- Command->BlockNumber = Request->sector;
- Command->BlockCount = Request->nr_sectors;
+ Command->BlockNumber = blk_rq_pos(Request);
+ Command->BlockCount = blk_rq_sectors(Request);
Command->Request = Request;
- blkdev_dequeue_request(Request);
+ blk_start_request(Request);
Command->SegmentCount = blk_rq_map_sg(req_q,
Command->Request, Command->cmd_sglist);
/* pci_map_sg MAY change the value of SegCount */
@@ -3431,7 +3431,7 @@ static void DAC960_queue_partial_rw(DAC960_Command_T *Command)
* successfully as possible.
*/
Command->SegmentCount = 1;
- Command->BlockNumber = Request->sector;
+ Command->BlockNumber = blk_rq_pos(Request);
Command->BlockCount = 1;
DAC960_QueueReadWriteCommand(Command);
return;
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 9f1665fc0f66..ac5e05a98b2f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -412,7 +412,7 @@ config ATA_OVER_ETH
config MG_DISK
tristate "mGine mflash, gflash support"
- depends on ARM && ATA && GPIOLIB
+ depends on ARM && GPIOLIB
help
mGine mFlash(gFlash) block device driver
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 8df436ff7068..9c6e5b0fe894 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -112,8 +112,6 @@ module_param(fd_def_df0, ulong, 0);
MODULE_LICENSE("GPL");
static struct request_queue *floppy_queue;
-#define QUEUE (floppy_queue)
-#define CURRENT elv_next_request(floppy_queue)
/*
* Macros
@@ -1335,64 +1333,60 @@ static int get_track(int drive, int track)
static void redo_fd_request(void)
{
+ struct request *rq;
unsigned int cnt, block, track, sector;
int drive;
struct amiga_floppy_struct *floppy;
char *data;
unsigned long flags;
+ int err;
- repeat:
- if (!CURRENT) {
+next_req:
+ rq = blk_fetch_request(floppy_queue);
+ if (!rq) {
/* Nothing left to do */
return;
}
- floppy = CURRENT->rq_disk->private_data;
+ floppy = rq->rq_disk->private_data;
drive = floppy - unit;
+next_segment:
/* Here someone could investigate to be more efficient */
- for (cnt = 0; cnt < CURRENT->current_nr_sectors; cnt++) {
+ for (cnt = 0, err = 0; cnt < blk_rq_cur_sectors(rq); cnt++) {
#ifdef DEBUG
printk("fd: sector %ld + %d requested for %s\n",
- CURRENT->sector,cnt,
- (rq_data_dir(CURRENT) == READ) ? "read" : "write");
+ blk_rq_pos(rq), cnt,
+ (rq_data_dir(rq) == READ) ? "read" : "write");
#endif
- block = CURRENT->sector + cnt;
+ block = blk_rq_pos(rq) + cnt;
if ((int)block > floppy->blocks) {
- end_request(CURRENT, 0);
- goto repeat;
+ err = -EIO;
+ break;
}
track = block / (floppy->dtype->sects * floppy->type->sect_mult);
sector = block % (floppy->dtype->sects * floppy->type->sect_mult);
- data = CURRENT->buffer + 512 * cnt;
+ data = rq->buffer + 512 * cnt;
#ifdef DEBUG
printk("access to track %d, sector %d, with buffer at "
"0x%08lx\n", track, sector, data);
#endif
- if ((rq_data_dir(CURRENT) != READ) && (rq_data_dir(CURRENT) != WRITE)) {
- printk(KERN_WARNING "do_fd_request: unknown command\n");
- end_request(CURRENT, 0);
- goto repeat;
- }
if (get_track(drive, track) == -1) {
- end_request(CURRENT, 0);
- goto repeat;
+ err = -EIO;
+ break;
}
- switch (rq_data_dir(CURRENT)) {
- case READ:
+ if (rq_data_dir(rq) == READ) {
memcpy(data, floppy->trackbuf + sector * 512, 512);
- break;
-
- case WRITE:
+ } else {
memcpy(floppy->trackbuf + sector * 512, data, 512);
/* keep the drive spinning while writes are scheduled */
if (!fd_motor_on(drive)) {
- end_request(CURRENT, 0);
- goto repeat;
+ err = -EIO;
+ break;
}
/*
* setup a callback to write the track buffer
@@ -1404,14 +1398,12 @@ static void redo_fd_request(void)
/* reset the timer */
mod_timer (flush_track_timer + drive, jiffies + 1);
local_irq_restore(flags);
- break;
}
}
- CURRENT->nr_sectors -= CURRENT->current_nr_sectors;
- CURRENT->sector += CURRENT->current_nr_sectors;
- end_request(CURRENT, 1);
- goto repeat;
+ if (__blk_end_request_cur(rq, err))
+ goto next_segment;
+ goto next_req;
}
static void do_fd_request(struct request_queue * q)
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 200efc4d2c1e..19888354188f 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -266,6 +266,11 @@ static const struct file_operations aoe_fops = {
.owner = THIS_MODULE,
};
+static char *aoe_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "etherd/%s", dev_name(dev));
+}
+
int __init
aoechr_init(void)
{
@@ -283,6 +288,8 @@ aoechr_init(void)
unregister_chrdev(AOE_MAJOR, "aoechr");
return PTR_ERR(aoe_class);
}
+ aoe_class->nodename = aoe_nodename;
+
for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
device_create(aoe_class, NULL,
MKDEV(AOE_MAJOR, chardevs[i].minor), NULL,
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 4234c11c1e4c..f5e7180d7f47 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -79,9 +79,7 @@
#undef DEBUG
static struct request_queue *floppy_queue;
-
-#define QUEUE (floppy_queue)
-#define CURRENT elv_next_request(floppy_queue)
+static struct request *fd_request;
/* Disk types: DD, HD, ED */
static struct atari_disk_type {
@@ -376,6 +374,12 @@ static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0);
static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0);
static DEFINE_TIMER(fd_timer, check_change, 0, 0);
+static void fd_end_request_cur(int err)
+{
+ if (!__blk_end_request_cur(fd_request, err))
+ fd_request = NULL;
+}
+
static inline void start_motor_off_timer(void)
{
mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY);
@@ -606,15 +610,15 @@ static void fd_error( void )
return;
}
- if (!CURRENT)
+ if (!fd_request)
return;
- CURRENT->errors++;
- if (CURRENT->errors >= MAX_ERRORS) {
+ fd_request->errors++;
+ if (fd_request->errors >= MAX_ERRORS) {
printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive );
- end_request(CURRENT, 0);
+ fd_end_request_cur(-EIO);
}
- else if (CURRENT->errors == RECALIBRATE_ERRORS) {
+ else if (fd_request->errors == RECALIBRATE_ERRORS) {
printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive );
if (SelectedDrive != -1)
SUD.track = -1;
@@ -725,16 +729,14 @@ static void do_fd_action( int drive )
if (IS_BUFFERED( drive, ReqSide, ReqTrack )) {
if (ReqCmd == READ) {
copy_buffer( SECTOR_BUFFER(ReqSector), ReqData );
- if (++ReqCnt < CURRENT->current_nr_sectors) {
+ if (++ReqCnt < blk_rq_cur_sectors(fd_request)) {
/* read next sector */
setup_req_params( drive );
goto repeat;
}
else {
/* all sectors finished */
- CURRENT->nr_sectors -= CURRENT->current_nr_sectors;
- CURRENT->sector += CURRENT->current_nr_sectors;
- end_request(CURRENT, 1);
+ fd_end_request_cur(0);
redo_fd_request();
return;
}
@@ -1132,16 +1134,14 @@ static void fd_rwsec_done1(int status)
}
}
- if (++ReqCnt < CURRENT->current_nr_sectors) {
+ if (++ReqCnt < blk_rq_cur_sectors(fd_request)) {
/* read next sector */
setup_req_params( SelectedDrive );
do_fd_action( SelectedDrive );
}
else {
/* all sectors finished */
- CURRENT->nr_sectors -= CURRENT->current_nr_sectors;
- CURRENT->sector += CURRENT->current_nr_sectors;
- end_request(CURRENT, 1);
+ fd_end_request_cur(0);
redo_fd_request();
}
return;
@@ -1382,7 +1382,7 @@ static void setup_req_params( int drive )
ReqData = ReqBuffer + 512 * ReqCnt;
if (UseTrackbuffer)
- read_track = (ReqCmd == READ && CURRENT->errors == 0);
+ read_track = (ReqCmd == READ && fd_request->errors == 0);
else
read_track = 0;
@@ -1396,25 +1396,27 @@ static void redo_fd_request(void)
int drive, type;
struct atari_floppy_struct *floppy;
- DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n",
- CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "",
- CURRENT ? CURRENT->sector : 0 ));
+ DPRINT(("redo_fd_request: fd_request=%p dev=%s fd_request->sector=%ld\n",
+ fd_request, fd_request ? fd_request->rq_disk->disk_name : "",
+ fd_request ? blk_rq_pos(fd_request) : 0 ));
IsFormatting = 0;
repeat:
+ if (!fd_request) {
+ fd_request = blk_fetch_request(floppy_queue);
+ if (!fd_request)
+ goto the_end;
+ }
- if (!CURRENT)
- goto the_end;
-
- floppy = CURRENT->rq_disk->private_data;
+ floppy = fd_request->rq_disk->private_data;
drive = floppy - unit;
type = floppy->type;
if (!UD.connected) {
/* drive not connected */
printk(KERN_ERR "Unknown Device: fd%d\n", drive );
- end_request(CURRENT, 0);
+ fd_end_request_cur(-EIO);
goto repeat;
}
@@ -1430,12 +1432,12 @@ repeat:
/* user supplied disk type */
if (--type >= NUM_DISK_MINORS) {
printk(KERN_WARNING "fd%d: invalid disk format", drive );
- end_request(CURRENT, 0);
+ fd_end_request_cur(-EIO);
goto repeat;
}
if (minor2disktype[type].drive_types > DriveType) {
printk(KERN_WARNING "fd%d: unsupported disk format", drive );
- end_request(CURRENT, 0);
+ fd_end_request_cur(-EIO);
goto repeat;
}
type = minor2disktype[type].index;
@@ -1444,8 +1446,8 @@ repeat:
UD.autoprobe = 0;
}
- if (CURRENT->sector + 1 > UDT->blocks) {
- end_request(CURRENT, 0);
+ if (blk_rq_pos(fd_request) + 1 > UDT->blocks) {
+ fd_end_request_cur(-EIO);
goto repeat;
}
@@ -1453,9 +1455,9 @@ repeat:
del_timer( &motor_off_timer );
ReqCnt = 0;
- ReqCmd = rq_data_dir(CURRENT);
- ReqBlock = CURRENT->sector;
- ReqBuffer = CURRENT->buffer;
+ ReqCmd = rq_data_dir(fd_request);
+ ReqBlock = blk_rq_pos(fd_request);
+ ReqBuffer = fd_request->buffer;
setup_req_params( drive );
do_fd_action( drive );
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 4d4d5e0d3fa6..94474f5f8bce 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1299,7 +1299,6 @@ static void cciss_softirq_done(struct request *rq)
{
CommandList_struct *cmd = rq->completion_data;
ctlr_info_t *h = hba[cmd->ctlr];
- unsigned int nr_bytes;
unsigned long flags;
u64bit temp64;
int i, ddir;
@@ -1321,15 +1320,11 @@ static void cciss_softirq_done(struct request *rq)
printk("Done with %p\n", rq);
#endif /* CCISS_DEBUG */
- /*
- * Store the full size and set the residual count for pc requests
- */
- nr_bytes = blk_rq_bytes(rq);
+ /* set the residual count for pc requests */
if (blk_pc_request(rq))
- rq->data_len = cmd->err_info->ResidualCnt;
+ rq->resid_len = cmd->err_info->ResidualCnt;
- if (blk_end_request(rq, (rq->errors == 0) ? 0 : -EIO, nr_bytes))
- BUG();
+ blk_end_request_all(rq, (rq->errors == 0) ? 0 : -EIO);
spin_lock_irqsave(&h->lock, flags);
cmd_free(h, cmd, 1);
@@ -1394,8 +1389,8 @@ static void cciss_add_disk(ctlr_info_t *h, struct gendisk *disk,
disk->queue->queuedata = h;
- blk_queue_hardsect_size(disk->queue,
- h->drv[drv_index].block_size);
+ blk_queue_logical_block_size(disk->queue,
+ h->drv[drv_index].block_size);
/* Make sure all queue data is written out before */
/* setting h->drv[drv_index].queue, as setting this */
@@ -2303,7 +2298,7 @@ static int cciss_revalidate(struct gendisk *disk)
cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size,
inq_buff, drv);
- blk_queue_hardsect_size(drv->queue, drv->block_size);
+ blk_queue_logical_block_size(drv->queue, drv->block_size);
set_capacity(disk, drv->nr_blocks);
kfree(inq_buff);
@@ -2691,7 +2686,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
printk(KERN_WARNING "cciss: cmd %p has"
" completed with data underrun "
"reported\n", cmd);
- cmd->rq->data_len = cmd->err_info->ResidualCnt;
+ cmd->rq->resid_len = cmd->err_info->ResidualCnt;
}
break;
case CMD_DATA_OVERRUN:
@@ -2806,7 +2801,7 @@ static void do_cciss_request(struct request_queue *q)
goto startio;
queue:
- creq = elv_next_request(q);
+ creq = blk_peek_request(q);
if (!creq)
goto startio;
@@ -2815,7 +2810,7 @@ static void do_cciss_request(struct request_queue *q)
if ((c = cmd_alloc(h, 1)) == NULL)
goto full;
- blkdev_dequeue_request(creq);
+ blk_start_request(creq);
spin_unlock_irq(q->queue_lock);
@@ -2840,10 +2835,10 @@ static void do_cciss_request(struct request_queue *q)
c->Request.Timeout = 0; // Don't time out
c->Request.CDB[0] =
(rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write;
- start_blk = creq->sector;
+ start_blk = blk_rq_pos(creq);
#ifdef CCISS_DEBUG
- printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n", (int)creq->sector,
- (int)creq->nr_sectors);
+ printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n",
+ (int)blk_rq_pos(creq), (int)blk_rq_sectors(creq));
#endif /* CCISS_DEBUG */
sg_init_table(tmp_sg, MAXSGENTRIES);
@@ -2869,8 +2864,8 @@ static void do_cciss_request(struct request_queue *q)
h->maxSG = seg;
#ifdef CCISS_DEBUG
- printk(KERN_DEBUG "cciss: Submitting %lu sectors in %d segments\n",
- creq->nr_sectors, seg);
+ printk(KERN_DEBUG "cciss: Submitting %u sectors in %d segments\n",
+ blk_rq_sectors(creq), seg);
#endif /* CCISS_DEBUG */
c->Header.SGList = c->Header.SGTotal = seg;
@@ -2882,8 +2877,8 @@ static void do_cciss_request(struct request_queue *q)
c->Request.CDB[4] = (start_blk >> 8) & 0xff;
c->Request.CDB[5] = start_blk & 0xff;
c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB
- c->Request.CDB[7] = (creq->nr_sectors >> 8) & 0xff;
- c->Request.CDB[8] = creq->nr_sectors & 0xff;
+ c->Request.CDB[7] = (blk_rq_sectors(creq) >> 8) & 0xff;
+ c->Request.CDB[8] = blk_rq_sectors(creq) & 0xff;
c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0;
} else {
u32 upper32 = upper_32_bits(start_blk);
@@ -2898,10 +2893,10 @@ static void do_cciss_request(struct request_queue *q)
c->Request.CDB[7]= (start_blk >> 16) & 0xff;
c->Request.CDB[8]= (start_blk >> 8) & 0xff;
c->Request.CDB[9]= start_blk & 0xff;
- c->Request.CDB[10]= (creq->nr_sectors >> 24) & 0xff;
- c->Request.CDB[11]= (creq->nr_sectors >> 16) & 0xff;
- c->Request.CDB[12]= (creq->nr_sectors >> 8) & 0xff;
- c->Request.CDB[13]= creq->nr_sectors & 0xff;
+ c->Request.CDB[10]= (blk_rq_sectors(creq) >> 24) & 0xff;
+ c->Request.CDB[11]= (blk_rq_sectors(creq) >> 16) & 0xff;
+ c->Request.CDB[12]= (blk_rq_sectors(creq) >> 8) & 0xff;
+ c->Request.CDB[13]= blk_rq_sectors(creq) & 0xff;
c->Request.CDB[14] = c->Request.CDB[15] = 0;
}
} else if (blk_pc_request(creq)) {
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index ca268ca11159..44fa2018f6b0 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -474,7 +474,7 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev)
disk->fops = &ida_fops;
if (j && !drv->nr_blks)
continue;
- blk_queue_hardsect_size(hba[i]->queue, drv->blk_size);
+ blk_queue_logical_block_size(hba[i]->queue, drv->blk_size);
set_capacity(disk, drv->nr_blks);
disk->queue = hba[i]->queue;
disk->private_data = drv;
@@ -903,7 +903,7 @@ static void do_ida_request(struct request_queue *q)
goto startio;
queue_next:
- creq = elv_next_request(q);
+ creq = blk_peek_request(q);
if (!creq)
goto startio;
@@ -912,17 +912,18 @@ queue_next:
if ((c = cmd_alloc(h,1)) == NULL)
goto startio;
- blkdev_dequeue_request(creq);
+ blk_start_request(creq);
c->ctlr = h->ctlr;
c->hdr.unit = (drv_info_t *)(creq->rq_disk->private_data) - h->drv;
c->hdr.size = sizeof(rblk_t) >> 2;
c->size += sizeof(rblk_t);
- c->req.hdr.blk = creq->sector;
+ c->req.hdr.blk = blk_rq_pos(creq);
c->rq = creq;
DBGPX(
- printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors);
+ printk("sector=%d, nr_sectors=%u\n",
+ blk_rq_pos(creq), blk_rq_sectors(creq));
);
sg_init_table(tmp_sg, SG_MAX);
seg = blk_rq_map_sg(q, creq, tmp_sg);
@@ -940,9 +941,9 @@ DBGPX(
tmp_sg[i].offset,
tmp_sg[i].length, dir);
}
-DBGPX( printk("Submitting %d sectors in %d segments\n", creq->nr_sectors, seg); );
+DBGPX( printk("Submitting %u sectors in %d segments\n", blk_rq_sectors(creq), seg); );
c->req.hdr.sg_cnt = seg;
- c->req.hdr.blk_cnt = creq->nr_sectors;
+ c->req.hdr.blk_cnt = blk_rq_sectors(creq);
c->req.hdr.cmd = (rq_data_dir(creq) == READ) ? IDA_READ : IDA_WRITE;
c->type = CMD_RWREQ;
@@ -1024,8 +1025,7 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
cmd->req.sg[i].size, ddir);
DBGPX(printk("Done with %p\n", rq););
- if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
- BUG();
+ __blk_end_request_all(rq, error);
}
/*
@@ -1546,7 +1546,7 @@ static int revalidate_allvol(ctlr_info_t *host)
drv_info_t *drv = &host->drv[i];
if (i && !drv->nr_blks)
continue;
- blk_queue_hardsect_size(host->queue, drv->blk_size);
+ blk_queue_logical_block_size(host->queue, drv->blk_size);
set_capacity(disk, drv->nr_blks);
disk->queue = host->queue;
disk->private_data = drv;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 1300df6f1642..90877fee0ee0 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -931,7 +931,7 @@ static inline void unlock_fdc(void)
del_timer(&fd_timeout);
cont = NULL;
clear_bit(0, &fdc_busy);
- if (elv_next_request(floppy_queue))
+ if (current_req || blk_peek_request(floppy_queue))
do_fd_request(floppy_queue);
spin_unlock_irqrestore(&floppy_lock, flags);
wake_up(&fdc_wait);
@@ -2303,7 +2303,7 @@ static void floppy_end_request(struct request *req, int error)
/* current_count_sectors can be zero if transfer failed */
if (error)
- nr_sectors = req->current_nr_sectors;
+ nr_sectors = blk_rq_cur_sectors(req);
if (__blk_end_request(req, error, nr_sectors << 9))
return;
@@ -2332,7 +2332,7 @@ static void request_done(int uptodate)
if (uptodate) {
/* maintain values for invalidation on geometry
* change */
- block = current_count_sectors + req->sector;
+ block = current_count_sectors + blk_rq_pos(req);
INFBOUND(DRS->maxblock, block);
if (block > _floppy->sect)
DRS->maxtrack = 1;
@@ -2346,10 +2346,10 @@ static void request_done(int uptodate)
/* record write error information */
DRWE->write_errors++;
if (DRWE->write_errors == 1) {
- DRWE->first_error_sector = req->sector;
+ DRWE->first_error_sector = blk_rq_pos(req);
DRWE->first_error_generation = DRS->generation;
}
- DRWE->last_error_sector = req->sector;
+ DRWE->last_error_sector = blk_rq_pos(req);
DRWE->last_error_generation = DRS->generation;
}
spin_lock_irqsave(q->queue_lock, flags);
@@ -2503,24 +2503,23 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
max_sector = transfer_size(ssize,
min(max_sector, max_sector_2),
- current_req->nr_sectors);
+ blk_rq_sectors(current_req));
if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
- buffer_max > fsector_t + current_req->nr_sectors)
+ buffer_max > fsector_t + blk_rq_sectors(current_req))
current_count_sectors = min_t(int, buffer_max - fsector_t,
- current_req->nr_sectors);
+ blk_rq_sectors(current_req));
remaining = current_count_sectors << 9;
#ifdef FLOPPY_SANITY_CHECK
- if ((remaining >> 9) > current_req->nr_sectors &&
- CT(COMMAND) == FD_WRITE) {
+ if (remaining > blk_rq_bytes(current_req) && CT(COMMAND) == FD_WRITE) {
DPRINT("in copy buffer\n");
printk("current_count_sectors=%ld\n", current_count_sectors);
printk("remaining=%d\n", remaining >> 9);
- printk("current_req->nr_sectors=%ld\n",
- current_req->nr_sectors);
+ printk("current_req->nr_sectors=%u\n",
+ blk_rq_sectors(current_req));
printk("current_req->current_nr_sectors=%u\n",
- current_req->current_nr_sectors);
+ blk_rq_cur_sectors(current_req));
printk("max_sector=%d\n", max_sector);
printk("ssize=%d\n", ssize);
}
@@ -2530,7 +2529,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
- size = current_req->current_nr_sectors << 9;
+ size = blk_rq_cur_bytes(current_req);
rq_for_each_segment(bv, current_req, iter) {
if (!remaining)
@@ -2648,10 +2647,10 @@ static int make_raw_rw_request(void)
max_sector = _floppy->sect * _floppy->head;
- TRACK = (int)current_req->sector / max_sector;
- fsector_t = (int)current_req->sector % max_sector;
+ TRACK = (int)blk_rq_pos(current_req) / max_sector;
+ fsector_t = (int)blk_rq_pos(current_req) % max_sector;
if (_floppy->track && TRACK >= _floppy->track) {
- if (current_req->current_nr_sectors & 1) {
+ if (blk_rq_cur_sectors(current_req) & 1) {
current_count_sectors = 1;
return 1;
} else
@@ -2669,7 +2668,7 @@ static int make_raw_rw_request(void)
if (fsector_t >= max_sector) {
current_count_sectors =
min_t(int, _floppy->sect - fsector_t,
- current_req->nr_sectors);
+ blk_rq_sectors(current_req));
return 1;
}
SIZECODE = 2;
@@ -2720,7 +2719,7 @@ static int make_raw_rw_request(void)
in_sector_offset = (fsector_t % _floppy->sect) % ssize;
aligned_sector_t = fsector_t - in_sector_offset;
- max_size = current_req->nr_sectors;
+ max_size = blk_rq_sectors(current_req);
if ((raw_cmd->track == buffer_track) &&
(current_drive == buffer_drive) &&
(fsector_t >= buffer_min) && (fsector_t < buffer_max)) {
@@ -2729,10 +2728,10 @@ static int make_raw_rw_request(void)
copy_buffer(1, max_sector, buffer_max);
return 1;
}
- } else if (in_sector_offset || current_req->nr_sectors < ssize) {
+ } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) {
if (CT(COMMAND) == FD_WRITE) {
- if (fsector_t + current_req->nr_sectors > ssize &&
- fsector_t + current_req->nr_sectors < ssize + ssize)
+ if (fsector_t + blk_rq_sectors(current_req) > ssize &&
+ fsector_t + blk_rq_sectors(current_req) < ssize + ssize)
max_size = ssize + ssize;
else
max_size = ssize;
@@ -2776,7 +2775,7 @@ static int make_raw_rw_request(void)
(indirect * 2 > direct * 3 &&
*errors < DP->max_errors.read_track && ((!probing
|| (DP->read_track & (1 << DRS->probed_format)))))) {
- max_size = current_req->nr_sectors;
+ max_size = blk_rq_sectors(current_req);
} else {
raw_cmd->kernel_data = current_req->buffer;
raw_cmd->length = current_count_sectors << 9;
@@ -2801,7 +2800,7 @@ static int make_raw_rw_request(void)
fsector_t > buffer_max ||
fsector_t < buffer_min ||
((CT(COMMAND) == FD_READ ||
- (!in_sector_offset && current_req->nr_sectors >= ssize)) &&
+ (!in_sector_offset && blk_rq_sectors(current_req) >= ssize)) &&
max_sector > 2 * max_buffer_sectors + buffer_min &&
max_size + fsector_t > 2 * max_buffer_sectors + buffer_min)
/* not enough space */
@@ -2879,8 +2878,8 @@ static int make_raw_rw_request(void)
printk("write\n");
return 0;
}
- } else if (raw_cmd->length > current_req->nr_sectors << 9 ||
- current_count_sectors > current_req->nr_sectors) {
+ } else if (raw_cmd->length > blk_rq_bytes(current_req) ||
+ current_count_sectors > blk_rq_sectors(current_req)) {
DPRINT("buffer overrun in direct transfer\n");
return 0;
} else if (raw_cmd->length < current_count_sectors << 9) {
@@ -2913,7 +2912,7 @@ static void redo_fd_request(void)
struct request *req;
spin_lock_irq(floppy_queue->queue_lock);
- req = elv_next_request(floppy_queue);
+ req = blk_fetch_request(floppy_queue);
spin_unlock_irq(floppy_queue->queue_lock);
if (!req) {
do_floppy = NULL;
@@ -2990,8 +2989,9 @@ static void do_fd_request(struct request_queue * q)
if (usage_count == 0) {
printk("warning: usage count=0, current_req=%p exiting\n",
current_req);
- printk("sect=%ld type=%x flags=%x\n", (long)current_req->sector,
- current_req->cmd_type, current_req->cmd_flags);
+ printk("sect=%ld type=%x flags=%x\n",
+ (long)blk_rq_pos(current_req), current_req->cmd_type,
+ current_req->cmd_flags);
return;
}
if (test_bit(0, &fdc_busy)) {
diff --git a/drivers/block/hd.c b/drivers/block/hd.c
index baaa9e486e50..f65b3f369eb0 100644
--- a/drivers/block/hd.c
+++ b/drivers/block/hd.c
@@ -98,10 +98,9 @@
static DEFINE_SPINLOCK(hd_lock);
static struct request_queue *hd_queue;
+static struct request *hd_req;
#define MAJOR_NR HD_MAJOR
-#define QUEUE (hd_queue)
-#define CURRENT elv_next_request(hd_queue)
#define TIMEOUT_VALUE (6*HZ)
#define HD_DELAY 0
@@ -195,11 +194,24 @@ static void __init hd_setup(char *str, int *ints)
NR_HD = hdind+1;
}
+static bool hd_end_request(int err, unsigned int bytes)
+{
+ if (__blk_end_request(hd_req, err, bytes))
+ return true;
+ hd_req = NULL;
+ return false;
+}
+
+static bool hd_end_request_cur(int err)
+{
+ return hd_end_request(err, blk_rq_cur_bytes(hd_req));
+}
+
static void dump_status(const char *msg, unsigned int stat)
{
char *name = "hd?";
- if (CURRENT)
- name = CURRENT->rq_disk->disk_name;
+ if (hd_req)
+ name = hd_req->rq_disk->disk_name;
#ifdef VERBOSE_ERRORS
printk("%s: %s: status=0x%02x { ", name, msg, stat & 0xff);
@@ -227,8 +239,8 @@ static void dump_status(const char *msg, unsigned int stat)
if (hd_error & (BBD_ERR|ECC_ERR|ID_ERR|MARK_ERR)) {
printk(", CHS=%d/%d/%d", (inb(HD_HCYL)<<8) + inb(HD_LCYL),
inb(HD_CURRENT) & 0xf, inb(HD_SECTOR));
- if (CURRENT)
- printk(", sector=%ld", CURRENT->sector);
+ if (hd_req)
+ printk(", sector=%ld", blk_rq_pos(hd_req));
}
printk("\n");
}
@@ -406,11 +418,12 @@ static void unexpected_hd_interrupt(void)
*/
static void bad_rw_intr(void)
{
- struct request *req = CURRENT;
+ struct request *req = hd_req;
+
if (req != NULL) {
struct hd_i_struct *disk = req->rq_disk->private_data;
if (++req->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) {
- end_request(req, 0);
+ hd_end_request_cur(-EIO);
disk->special_op = disk->recalibrate = 1;
} else if (req->errors % RESET_FREQ == 0)
reset = 1;
@@ -452,37 +465,30 @@ static void read_intr(void)
bad_rw_intr();
hd_request();
return;
+
ok_to_read:
- req = CURRENT;
+ req = hd_req;
insw(HD_DATA, req->buffer, 256);
- req->sector++;
- req->buffer += 512;
- req->errors = 0;
- i = --req->nr_sectors;
- --req->current_nr_sectors;
#ifdef DEBUG
- printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
- req->rq_disk->disk_name, req->sector, req->nr_sectors,
- req->buffer+512);
+ printk("%s: read: sector %ld, remaining = %u, buffer=%p\n",
+ req->rq_disk->disk_name, blk_rq_pos(req) + 1,
+ blk_rq_sectors(req) - 1, req->buffer+512);
#endif
- if (req->current_nr_sectors <= 0)
- end_request(req, 1);
- if (i > 0) {
+ if (hd_end_request(0, 512)) {
SET_HANDLER(&read_intr);
return;
}
+
(void) inb_p(HD_STATUS);
#if (HD_DELAY > 0)
last_req = read_timer();
#endif
- if (elv_next_request(QUEUE))
- hd_request();
- return;
+ hd_request();
}
static void write_intr(void)
{
- struct request *req = CURRENT;
+ struct request *req = hd_req;
int i;
int retries = 100000;
@@ -492,30 +498,25 @@ static void write_intr(void)
continue;
if (!OK_STATUS(i))
break;
- if ((req->nr_sectors <= 1) || (i & DRQ_STAT))
+ if ((blk_rq_sectors(req) <= 1) || (i & DRQ_STAT))
goto ok_to_write;
} while (--retries > 0);
dump_status("write_intr", i);
bad_rw_intr();
hd_request();
return;
+
ok_to_write:
- req->sector++;
- i = --req->nr_sectors;
- --req->current_nr_sectors;
- req->buffer += 512;
- if (!i || (req->bio && req->current_nr_sectors <= 0))
- end_request(req, 1);
- if (i > 0) {
+ if (hd_end_request(0, 512)) {
SET_HANDLER(&write_intr);
outsw(HD_DATA, req->buffer, 256);
- } else {
+ return;
+ }
+
#if (HD_DELAY > 0)
- last_req = read_timer();
+ last_req = read_timer();
#endif
- hd_request();
- }
- return;
+ hd_request();
}
static void recal_intr(void)
@@ -537,18 +538,18 @@ static void hd_times_out(unsigned long dummy)
do_hd = NULL;
- if (!CURRENT)
+ if (!hd_req)
return;
spin_lock_irq(hd_queue->queue_lock);
reset = 1;
- name = CURRENT->rq_disk->disk_name;
+ name = hd_req->rq_disk->disk_name;
printk("%s: timeout\n", name);
- if (++CURRENT->errors >= MAX_ERRORS) {
+ if (++hd_req->errors >= MAX_ERRORS) {
#ifdef DEBUG
printk("%s: too many errors\n", name);
#endif
- end_request(CURRENT, 0);
+ hd_end_request_cur(-EIO);
}
hd_request();
spin_unlock_irq(hd_queue->queue_lock);
@@ -563,7 +564,7 @@ static int do_special_op(struct hd_i_struct *disk, struct request *req)
}
if (disk->head > 16) {
printk("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name);
- end_request(req, 0);
+ hd_end_request_cur(-EIO);
}
disk->special_op = 0;
return 1;
@@ -590,24 +591,27 @@ static void hd_request(void)
repeat:
del_timer(&device_timer);
- req = CURRENT;
- if (!req) {
- do_hd = NULL;
- return;
+ if (!hd_req) {
+ hd_req = blk_fetch_request(hd_queue);
+ if (!hd_req) {
+ do_hd = NULL;
+ return;
+ }
}
+ req = hd_req;
if (reset) {
reset_hd();
return;
}
disk = req->rq_disk->private_data;
- block = req->sector;
- nsect = req->nr_sectors;
+ block = blk_rq_pos(req);
+ nsect = blk_rq_sectors(req);
if (block >= get_capacity(req->rq_disk) ||
((block+nsect) > get_capacity(req->rq_disk))) {
printk("%s: bad access: block=%d, count=%d\n",
req->rq_disk->disk_name, block, nsect);
- end_request(req, 0);
+ hd_end_request_cur(-EIO);
goto repeat;
}
@@ -647,7 +651,7 @@ repeat:
break;
default:
printk("unknown hd-command\n");
- end_request(req, 0);
+ hd_end_request_cur(-EIO);
break;
}
}
@@ -720,7 +724,7 @@ static int __init hd_init(void)
blk_queue_max_sectors(hd_queue, 255);
init_timer(&device_timer);
device_timer.function = hd_times_out;
- blk_queue_hardsect_size(hd_queue, 512);
+ blk_queue_logical_block_size(hd_queue, 512);
if (!NR_HD) {
/*
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ddae80825899..801f4ab83302 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -511,11 +511,7 @@ out:
*/
static void loop_add_bio(struct loop_device *lo, struct bio *bio)
{
- if (lo->lo_biotail) {
- lo->lo_biotail->bi_next = bio;
- lo->lo_biotail = bio;
- } else
- lo->lo_bio = lo->lo_biotail = bio;
+ bio_list_add(&lo->lo_bio_list, bio);
}
/*
@@ -523,16 +519,7 @@ static void loop_add_bio(struct loop_device *lo, struct bio *bio)
*/
static struct bio *loop_get_bio(struct loop_device *lo)
{
- struct bio *bio;
-
- if ((bio = lo->lo_bio)) {
- if (bio == lo->lo_biotail)
- lo->lo_biotail = NULL;
- lo->lo_bio = bio->bi_next;
- bio->bi_next = NULL;
- }
-
- return bio;
+ return bio_list_pop(&lo->lo_bio_list);
}
static int loop_make_request(struct request_queue *q, struct bio *old_bio)
@@ -609,12 +596,13 @@ static int loop_thread(void *data)
set_user_nice(current, -20);
- while (!kthread_should_stop() || lo->lo_bio) {
+ while (!kthread_should_stop() || !bio_list_empty(&lo->lo_bio_list)) {
wait_event_interruptible(lo->lo_event,
- lo->lo_bio || kthread_should_stop());
+ !bio_list_empty(&lo->lo_bio_list) ||
+ kthread_should_stop());
- if (!lo->lo_bio)
+ if (bio_list_empty(&lo->lo_bio_list))
continue;
spin_lock_irq(&lo->lo_lock);
bio = loop_get_bio(lo);
@@ -721,10 +709,6 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
goto out_putf;
- /* new backing store needs to support loop (eg splice_read) */
- if (!inode->i_fop->splice_read)
- goto out_putf;
-
/* size of the new backing store needs to be the same */
if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
goto out_putf;
@@ -800,12 +784,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
error = -EINVAL;
if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) {
const struct address_space_operations *aops = mapping->a_ops;
- /*
- * If we can't read - sorry. If we only can't write - well,
- * it's going to be read-only.
- */
- if (!file->f_op->splice_read)
- goto out_putf;
+
if (aops->write_begin)
lo_flags |= LO_FLAGS_USE_AOPS;
if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write)
@@ -841,7 +820,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
lo->old_gfp_mask = mapping_gfp_mask(mapping);
mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
- lo->lo_bio = lo->lo_biotail = NULL;
+ bio_list_init(&lo->lo_bio_list);
/*
* set queue make_request_fn, and add limits based on lower level
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index f3898353d0a8..60de5a01e71e 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -17,71 +17,220 @@
#include <linux/fs.h>
#include <linux/blkdev.h>
#include <linux/hdreg.h>
-#include <linux/libata.h>
+#include <linux/ata.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
-#include <linux/mg_disk.h>
#define MG_RES_SEC (CONFIG_MG_DISK_RES << 1)
+/* name for block device */
+#define MG_DISK_NAME "mgd"
+/* name for platform device */
+#define MG_DEV_NAME "mg_disk"
+
+#define MG_DISK_MAJ 0
+#define MG_DISK_MAX_PART 16
+#define MG_SECTOR_SIZE 512
+#define MG_MAX_SECTS 256
+
+/* Register offsets */
+#define MG_BUFF_OFFSET 0x8000
+#define MG_STORAGE_BUFFER_SIZE 0x200
+#define MG_REG_OFFSET 0xC000
+#define MG_REG_FEATURE (MG_REG_OFFSET + 2) /* write case */
+#define MG_REG_ERROR (MG_REG_OFFSET + 2) /* read case */
+#define MG_REG_SECT_CNT (MG_REG_OFFSET + 4)
+#define MG_REG_SECT_NUM (MG_REG_OFFSET + 6)
+#define MG_REG_CYL_LOW (MG_REG_OFFSET + 8)
+#define MG_REG_CYL_HIGH (MG_REG_OFFSET + 0xA)
+#define MG_REG_DRV_HEAD (MG_REG_OFFSET + 0xC)
+#define MG_REG_COMMAND (MG_REG_OFFSET + 0xE) /* write case */
+#define MG_REG_STATUS (MG_REG_OFFSET + 0xE) /* read case */
+#define MG_REG_DRV_CTRL (MG_REG_OFFSET + 0x10)
+#define MG_REG_BURST_CTRL (MG_REG_OFFSET + 0x12)
+
+/* handy status */
+#define MG_STAT_READY (ATA_DRDY | ATA_DSC)
+#define MG_READY_OK(s) (((s) & (MG_STAT_READY | (ATA_BUSY | ATA_DF | \
+ ATA_ERR))) == MG_STAT_READY)
+
+/* error code for others */
+#define MG_ERR_NONE 0
+#define MG_ERR_TIMEOUT 0x100
+#define MG_ERR_INIT_STAT 0x101
+#define MG_ERR_TRANSLATION 0x102
+#define MG_ERR_CTRL_RST 0x103
+#define MG_ERR_INV_STAT 0x104
+#define MG_ERR_RSTOUT 0x105
+
+#define MG_MAX_ERRORS 6 /* Max read/write errors */
+
+/* command */
+#define MG_CMD_RD 0x20
+#define MG_CMD_WR 0x30
+#define MG_CMD_SLEEP 0x99
+#define MG_CMD_WAKEUP 0xC3
+#define MG_CMD_ID 0xEC
+#define MG_CMD_WR_CONF 0x3C
+#define MG_CMD_RD_CONF 0x40
+
+/* operation mode */
+#define MG_OP_CASCADE (1 << 0)
+#define MG_OP_CASCADE_SYNC_RD (1 << 1)
+#define MG_OP_CASCADE_SYNC_WR (1 << 2)
+#define MG_OP_INTERLEAVE (1 << 3)
+
+/* synchronous */
+#define MG_BURST_LAT_4 (3 << 4)
+#define MG_BURST_LAT_5 (4 << 4)
+#define MG_BURST_LAT_6 (5 << 4)
+#define MG_BURST_LAT_7 (6 << 4)
+#define MG_BURST_LAT_8 (7 << 4)
+#define MG_BURST_LEN_4 (1 << 1)
+#define MG_BURST_LEN_8 (2 << 1)
+#define MG_BURST_LEN_16 (3 << 1)
+#define MG_BURST_LEN_32 (4 << 1)
+#define MG_BURST_LEN_CONT (0 << 1)
+
+/* timeout value (unit: ms) */
+#define MG_TMAX_CONF_TO_CMD 1
+#define MG_TMAX_WAIT_RD_DRQ 10
+#define MG_TMAX_WAIT_WR_DRQ 500
+#define MG_TMAX_RST_TO_BUSY 10
+#define MG_TMAX_HDRST_TO_RDY 500
+#define MG_TMAX_SWRST_TO_RDY 500
+#define MG_TMAX_RSTOUT 3000
+
+/* device attribution */
+/* use mflash as boot device */
+#define MG_BOOT_DEV (1 << 0)
+/* use mflash as storage device */
+#define MG_STORAGE_DEV (1 << 1)
+/* same as MG_STORAGE_DEV, but bootloader already done reset sequence */
+#define MG_STORAGE_DEV_SKIP_RST (1 << 2)
+
+#define MG_DEV_MASK (MG_BOOT_DEV | MG_STORAGE_DEV | MG_STORAGE_DEV_SKIP_RST)
+
+/* names of GPIO resource */
+#define MG_RST_PIN "mg_rst"
+/* except MG_BOOT_DEV, reset-out pin should be assigned */
+#define MG_RSTOUT_PIN "mg_rstout"
+
+/* private driver data */
+struct mg_drv_data {
+ /* disk resource */
+ u32 use_polling;
+
+ /* device attribution */
+ u32 dev_attr;
+
+ /* internally used */
+ struct mg_host *host;
+};
+
+/* main structure for mflash driver */
+struct mg_host {
+ struct device *dev;
+
+ struct request_queue *breq;
+ struct request *req;
+ spinlock_t lock;
+ struct gendisk *gd;
+
+ struct timer_list timer;
+ void (*mg_do_intr) (struct mg_host *);
+
+ u16 id[ATA_ID_WORDS];
+
+ u16 cyls;
+ u16 heads;
+ u16 sectors;
+ u32 n_sectors;
+ u32 nres_sectors;
+
+ void __iomem *dev_base;
+ unsigned int irq;
+ unsigned int rst;
+ unsigned int rstout;
+
+ u32 major;
+ u32 error;
+};
+
+/*
+ * Debugging macro and defines
+ */
+#undef DO_MG_DEBUG
+#ifdef DO_MG_DEBUG
+# define MG_DBG(fmt, args...) \
+ printk(KERN_DEBUG "%s:%d "fmt, __func__, __LINE__, ##args)
+#else /* CONFIG_MG_DEBUG */
+# define MG_DBG(fmt, args...) do { } while (0)
+#endif /* CONFIG_MG_DEBUG */
+
static void mg_request(struct request_queue *);
+static bool mg_end_request(struct mg_host *host, int err, unsigned int nr_bytes)
+{
+ if (__blk_end_request(host->req, err, nr_bytes))
+ return true;
+
+ host->req = NULL;
+ return false;
+}
+
+static bool mg_end_request_cur(struct mg_host *host, int err)
+{
+ return mg_end_request(host, err, blk_rq_cur_bytes(host->req));
+}
+
static void mg_dump_status(const char *msg, unsigned int stat,
struct mg_host *host)
{
char *name = MG_DISK_NAME;
- struct request *req;
- if (host->breq) {
- req = elv_next_request(host->breq);
- if (req)
- name = req->rq_disk->disk_name;
- }
+ if (host->req)
+ name = host->req->rq_disk->disk_name;
printk(KERN_ERR "%s: %s: status=0x%02x { ", name, msg, stat & 0xff);
- if (stat & MG_REG_STATUS_BIT_BUSY)
+ if (stat & ATA_BUSY)
printk("Busy ");
- if (stat & MG_REG_STATUS_BIT_READY)
+ if (stat & ATA_DRDY)
printk("DriveReady ");
- if (stat & MG_REG_STATUS_BIT_WRITE_FAULT)
+ if (stat & ATA_DF)
printk("WriteFault ");
- if (stat & MG_REG_STATUS_BIT_SEEK_DONE)
+ if (stat & ATA_DSC)
printk("SeekComplete ");
- if (stat & MG_REG_STATUS_BIT_DATA_REQ)
+ if (stat & ATA_DRQ)
printk("DataRequest ");
- if (stat & MG_REG_STATUS_BIT_CORRECTED_ERROR)
+ if (stat & ATA_CORR)
printk("CorrectedError ");
- if (stat & MG_REG_STATUS_BIT_ERROR)
+ if (stat & ATA_ERR)
printk("Error ");
printk("}\n");
- if ((stat & MG_REG_STATUS_BIT_ERROR) == 0) {
+ if ((stat & ATA_ERR) == 0) {
host->error = 0;
} else {
host->error = inb((unsigned long)host->dev_base + MG_REG_ERROR);
printk(KERN_ERR "%s: %s: error=0x%02x { ", name, msg,
host->error & 0xff);
- if (host->error & MG_REG_ERR_BBK)
+ if (host->error & ATA_BBK)
printk("BadSector ");
- if (host->error & MG_REG_ERR_UNC)
+ if (host->error & ATA_UNC)
printk("UncorrectableError ");
- if (host->error & MG_REG_ERR_IDNF)
+ if (host->error & ATA_IDNF)
printk("SectorIdNotFound ");
- if (host->error & MG_REG_ERR_ABRT)
+ if (host->error & ATA_ABORTED)
printk("DriveStatusError ");
- if (host->error & MG_REG_ERR_AMNF)
+ if (host->error & ATA_AMNF)
printk("AddrMarkNotFound ");
printk("}");
- if (host->error &
- (MG_REG_ERR_BBK | MG_REG_ERR_UNC |
- MG_REG_ERR_IDNF | MG_REG_ERR_AMNF)) {
- if (host->breq) {
- req = elv_next_request(host->breq);
- if (req)
- printk(", sector=%u", (u32)req->sector);
- }
-
+ if (host->error & (ATA_BBK | ATA_UNC | ATA_IDNF | ATA_AMNF)) {
+ if (host->req)
+ printk(", sector=%u",
+ (unsigned int)blk_rq_pos(host->req));
}
printk("\n");
}
@@ -100,12 +249,12 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec)
do {
cur_jiffies = jiffies;
- if (status & MG_REG_STATUS_BIT_BUSY) {
- if (expect == MG_REG_STATUS_BIT_BUSY)
+ if (status & ATA_BUSY) {
+ if (expect == ATA_BUSY)
break;
} else {
/* Check the error condition! */
- if (status & MG_REG_STATUS_BIT_ERROR) {
+ if (status & ATA_ERR) {
mg_dump_status("mg_wait", status, host);
break;
}
@@ -114,8 +263,8 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec)
if (MG_READY_OK(status))
break;
- if (expect == MG_REG_STATUS_BIT_DATA_REQ)
- if (status & MG_REG_STATUS_BIT_DATA_REQ)
+ if (expect == ATA_DRQ)
+ if (status & ATA_DRQ)
break;
}
if (!msec) {
@@ -173,6 +322,42 @@ static irqreturn_t mg_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
+/* local copy of ata_id_string() */
+static void mg_id_string(const u16 *id, unsigned char *s,
+ unsigned int ofs, unsigned int len)
+{
+ unsigned int c;
+
+ BUG_ON(len & 1);
+
+ while (len > 0) {
+ c = id[ofs] >> 8;
+ *s = c;
+ s++;
+
+ c = id[ofs] & 0xff;
+ *s = c;
+ s++;
+
+ ofs++;
+ len -= 2;
+ }
+}
+
+/* local copy of ata_id_c_string() */
+static void mg_id_c_string(const u16 *id, unsigned char *s,
+ unsigned int ofs, unsigned int len)
+{
+ unsigned char *p;
+
+ mg_id_string(id, s, ofs, len - 1);
+
+ p = s + strnlen(s, len - 1);
+ while (p > s && p[-1] == ' ')
+ p--;
+ *p = '\0';
+}
+
static int mg_get_disk_id(struct mg_host *host)
{
u32 i;
@@ -184,12 +369,10 @@ static int mg_get_disk_id(struct mg_host *host)
char serial[ATA_ID_SERNO_LEN + 1];
if (!prv_data->use_polling)
- outb(MG_REG_CTRL_INTR_DISABLE,
- (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
outb(MG_CMD_ID, (unsigned long)host->dev_base + MG_REG_COMMAND);
- err = mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, MG_TMAX_WAIT_RD_DRQ);
+ err = mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_RD_DRQ);
if (err)
return err;
@@ -219,9 +402,9 @@ static int mg_get_disk_id(struct mg_host *host)
host->n_sectors -= host->nres_sectors;
}
- ata_id_c_string(id, fwrev, ATA_ID_FW_REV, sizeof(fwrev));
- ata_id_c_string(id, model, ATA_ID_PROD, sizeof(model));
- ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
+ mg_id_c_string(id, fwrev, ATA_ID_FW_REV, sizeof(fwrev));
+ mg_id_c_string(id, model, ATA_ID_PROD, sizeof(model));
+ mg_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
printk(KERN_INFO "mg_disk: model: %s\n", model);
printk(KERN_INFO "mg_disk: firm: %.8s\n", fwrev);
printk(KERN_INFO "mg_disk: serial: %s\n", serial);
@@ -229,8 +412,7 @@ static int mg_get_disk_id(struct mg_host *host)
host->n_sectors, host->nres_sectors);
if (!prv_data->use_polling)
- outb(MG_REG_CTRL_INTR_ENABLE, (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
return err;
}
@@ -244,7 +426,7 @@ static int mg_disk_init(struct mg_host *host)
/* hdd rst low */
gpio_set_value(host->rst, 0);
- err = mg_wait(host, MG_REG_STATUS_BIT_BUSY, MG_TMAX_RST_TO_BUSY);
+ err = mg_wait(host, ATA_BUSY, MG_TMAX_RST_TO_BUSY);
if (err)
return err;
@@ -255,17 +437,14 @@ static int mg_disk_init(struct mg_host *host)
return err;
/* soft reset on */
- outb(MG_REG_CTRL_RESET |
- (prv_data->use_polling ? MG_REG_CTRL_INTR_DISABLE :
- MG_REG_CTRL_INTR_ENABLE),
+ outb(ATA_SRST | (prv_data->use_polling ? ATA_NIEN : 0),
(unsigned long)host->dev_base + MG_REG_DRV_CTRL);
- err = mg_wait(host, MG_REG_STATUS_BIT_BUSY, MG_TMAX_RST_TO_BUSY);
+ err = mg_wait(host, ATA_BUSY, MG_TMAX_RST_TO_BUSY);
if (err)
return err;
/* soft reset off */
- outb(prv_data->use_polling ? MG_REG_CTRL_INTR_DISABLE :
- MG_REG_CTRL_INTR_ENABLE,
+ outb(prv_data->use_polling ? ATA_NIEN : 0,
(unsigned long)host->dev_base + MG_REG_DRV_CTRL);
err = mg_wait(host, MG_STAT_READY, MG_TMAX_SWRST_TO_RDY);
if (err)
@@ -281,11 +460,10 @@ static int mg_disk_init(struct mg_host *host)
static void mg_bad_rw_intr(struct mg_host *host)
{
- struct request *req = elv_next_request(host->breq);
- if (req != NULL)
- if (++req->errors >= MG_MAX_ERRORS ||
- host->error == MG_ERR_TIMEOUT)
- end_request(req, 0);
+ if (host->req)
+ if (++host->req->errors >= MG_MAX_ERRORS ||
+ host->error == MG_ERR_TIMEOUT)
+ mg_end_request_cur(host, -EIO);
}
static unsigned int mg_out(struct mg_host *host,
@@ -311,7 +489,7 @@ static unsigned int mg_out(struct mg_host *host,
MG_REG_CYL_LOW);
outb((u8)(sect_num >> 16), (unsigned long)host->dev_base +
MG_REG_CYL_HIGH);
- outb((u8)((sect_num >> 24) | MG_REG_HEAD_LBA_MODE),
+ outb((u8)((sect_num >> 24) | ATA_LBA | ATA_DEVICE_OBS),
(unsigned long)host->dev_base + MG_REG_DRV_HEAD);
outb(cmd, (unsigned long)host->dev_base + MG_REG_COMMAND);
return MG_ERR_NONE;
@@ -319,105 +497,77 @@ static unsigned int mg_out(struct mg_host *host,
static void mg_read(struct request *req)
{
- u32 remains, j;
+ u32 j;
struct mg_host *host = req->rq_disk->private_data;
- remains = req->nr_sectors;
-
- if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_RD, NULL) !=
- MG_ERR_NONE)
+ if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req),
+ MG_CMD_RD, NULL) != MG_ERR_NONE)
mg_bad_rw_intr(host);
MG_DBG("requested %d sects (from %ld), buffer=0x%p\n",
- remains, req->sector, req->buffer);
+ blk_rq_sectors(req), blk_rq_pos(req), req->buffer);
+
+ do {
+ u16 *buff = (u16 *)req->buffer;
- while (remains) {
- if (mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ,
- MG_TMAX_WAIT_RD_DRQ) != MG_ERR_NONE) {
+ if (mg_wait(host, ATA_DRQ,
+ MG_TMAX_WAIT_RD_DRQ) != MG_ERR_NONE) {
mg_bad_rw_intr(host);
return;
}
- for (j = 0; j < MG_SECTOR_SIZE >> 1; j++) {
- *(u16 *)req->buffer =
- inw((unsigned long)host->dev_base +
- MG_BUFF_OFFSET + (j << 1));
- req->buffer += 2;
- }
-
- req->sector++;
- req->errors = 0;
- remains = --req->nr_sectors;
- --req->current_nr_sectors;
-
- if (req->current_nr_sectors <= 0) {
- MG_DBG("remain : %d sects\n", remains);
- end_request(req, 1);
- if (remains > 0)
- req = elv_next_request(host->breq);
- }
+ for (j = 0; j < MG_SECTOR_SIZE >> 1; j++)
+ *buff++ = inw((unsigned long)host->dev_base +
+ MG_BUFF_OFFSET + (j << 1));
outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base +
MG_REG_COMMAND);
- }
+ } while (mg_end_request(host, 0, MG_SECTOR_SIZE));
}
static void mg_write(struct request *req)
{
- u32 remains, j;
+ u32 j;
struct mg_host *host = req->rq_disk->private_data;
- remains = req->nr_sectors;
-
- if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_WR, NULL) !=
- MG_ERR_NONE) {
+ if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req),
+ MG_CMD_WR, NULL) != MG_ERR_NONE) {
mg_bad_rw_intr(host);
return;
}
-
MG_DBG("requested %d sects (from %ld), buffer=0x%p\n",
- remains, req->sector, req->buffer);
- while (remains) {
- if (mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ,
- MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
+ blk_rq_sectors(req), blk_rq_pos(req), req->buffer);
+
+ do {
+ u16 *buff = (u16 *)req->buffer;
+
+ if (mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
mg_bad_rw_intr(host);
return;
}
- for (j = 0; j < MG_SECTOR_SIZE >> 1; j++) {
- outw(*(u16 *)req->buffer,
- (unsigned long)host->dev_base +
- MG_BUFF_OFFSET + (j << 1));
- req->buffer += 2;
- }
- req->sector++;
- remains = --req->nr_sectors;
- --req->current_nr_sectors;
-
- if (req->current_nr_sectors <= 0) {
- MG_DBG("remain : %d sects\n", remains);
- end_request(req, 1);
- if (remains > 0)
- req = elv_next_request(host->breq);
- }
+ for (j = 0; j < MG_SECTOR_SIZE >> 1; j++)
+ outw(*buff++, (unsigned long)host->dev_base +
+ MG_BUFF_OFFSET + (j << 1));
outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base +
MG_REG_COMMAND);
- }
+ } while (mg_end_request(host, 0, MG_SECTOR_SIZE));
}
static void mg_read_intr(struct mg_host *host)
{
+ struct request *req = host->req;
u32 i;
- struct request *req;
+ u16 *buff;
/* check status */
do {
i = inb((unsigned long)host->dev_base + MG_REG_STATUS);
- if (i & MG_REG_STATUS_BIT_BUSY)
+ if (i & ATA_BUSY)
break;
if (!MG_READY_OK(i))
break;
- if (i & MG_REG_STATUS_BIT_DATA_REQ)
+ if (i & ATA_DRQ)
goto ok_to_read;
} while (0);
mg_dump_status("mg_read_intr", i, host);
@@ -427,60 +577,42 @@ static void mg_read_intr(struct mg_host *host)
ok_to_read:
/* get current segment of request */
- req = elv_next_request(host->breq);
+ buff = (u16 *)req->buffer;
/* read 1 sector */
- for (i = 0; i < MG_SECTOR_SIZE >> 1; i++) {
- *(u16 *)req->buffer =
- inw((unsigned long)host->dev_base + MG_BUFF_OFFSET +
- (i << 1));
- req->buffer += 2;
- }
+ for (i = 0; i < MG_SECTOR_SIZE >> 1; i++)
+ *buff++ = inw((unsigned long)host->dev_base + MG_BUFF_OFFSET +
+ (i << 1));
- /* manipulate request */
MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n",
- req->sector, req->nr_sectors - 1, req->buffer);
-
- req->sector++;
- req->errors = 0;
- i = --req->nr_sectors;
- --req->current_nr_sectors;
-
- /* let know if current segment done */
- if (req->current_nr_sectors <= 0)
- end_request(req, 1);
-
- /* set handler if read remains */
- if (i > 0) {
- host->mg_do_intr = mg_read_intr;
- mod_timer(&host->timer, jiffies + 3 * HZ);
- }
+ blk_rq_pos(req), blk_rq_sectors(req) - 1, req->buffer);
/* send read confirm */
outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND);
- /* goto next request */
- if (!i)
+ if (mg_end_request(host, 0, MG_SECTOR_SIZE)) {
+ /* set handler if read remains */
+ host->mg_do_intr = mg_read_intr;
+ mod_timer(&host->timer, jiffies + 3 * HZ);
+ } else /* goto next request */
mg_request(host->breq);
}
static void mg_write_intr(struct mg_host *host)
{
+ struct request *req = host->req;
u32 i, j;
u16 *buff;
- struct request *req;
-
- /* get current segment of request */
- req = elv_next_request(host->breq);
+ bool rem;
/* check status */
do {
i = inb((unsigned long)host->dev_base + MG_REG_STATUS);
- if (i & MG_REG_STATUS_BIT_BUSY)
+ if (i & ATA_BUSY)
break;
if (!MG_READY_OK(i))
break;
- if ((req->nr_sectors <= 1) || (i & MG_REG_STATUS_BIT_DATA_REQ))
+ if ((blk_rq_sectors(req) <= 1) || (i & ATA_DRQ))
goto ok_to_write;
} while (0);
mg_dump_status("mg_write_intr", i, host);
@@ -489,18 +621,8 @@ static void mg_write_intr(struct mg_host *host)
return;
ok_to_write:
- /* manipulate request */
- req->sector++;
- i = --req->nr_sectors;
- --req->current_nr_sectors;
- req->buffer += MG_SECTOR_SIZE;
-
- /* let know if current segment or all done */
- if (!i || (req->bio && req->current_nr_sectors <= 0))
- end_request(req, 1);
-
- /* write 1 sector and set handler if remains */
- if (i > 0) {
+ if ((rem = mg_end_request(host, 0, MG_SECTOR_SIZE))) {
+ /* write 1 sector and set handler if remains */
buff = (u16 *)req->buffer;
for (j = 0; j < MG_STORAGE_BUFFER_SIZE >> 1; j++) {
outw(*buff, (unsigned long)host->dev_base +
@@ -508,7 +630,7 @@ ok_to_write:
buff++;
}
MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n",
- req->sector, req->nr_sectors, req->buffer);
+ blk_rq_pos(req), blk_rq_sectors(req), req->buffer);
host->mg_do_intr = mg_write_intr;
mod_timer(&host->timer, jiffies + 3 * HZ);
}
@@ -516,7 +638,7 @@ ok_to_write:
/* send write confirm */
outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND);
- if (!i)
+ if (!rem)
mg_request(host->breq);
}
@@ -524,49 +646,45 @@ void mg_times_out(unsigned long data)
{
struct mg_host *host = (struct mg_host *)data;
char *name;
- struct request *req;
spin_lock_irq(&host->lock);
- req = elv_next_request(host->breq);
- if (!req)
+ if (!host->req)
goto out_unlock;
host->mg_do_intr = NULL;
- name = req->rq_disk->disk_name;
+ name = host->req->rq_disk->disk_name;
printk(KERN_DEBUG "%s: timeout\n", name);
host->error = MG_ERR_TIMEOUT;
mg_bad_rw_intr(host);
- mg_request(host->breq);
out_unlock:
+ mg_request(host->breq);
spin_unlock_irq(&host->lock);
}
static void mg_request_poll(struct request_queue *q)
{
- struct request *req;
- struct mg_host *host;
+ struct mg_host *host = q->queuedata;
- while ((req = elv_next_request(q)) != NULL) {
- host = req->rq_disk->private_data;
- if (blk_fs_request(req)) {
- switch (rq_data_dir(req)) {
- case READ:
- mg_read(req);
- break;
- case WRITE:
- mg_write(req);
- break;
- default:
- printk(KERN_WARNING "%s:%d unknown command\n",
- __func__, __LINE__);
- end_request(req, 0);
+ while (1) {
+ if (!host->req) {
+ host->req = blk_fetch_request(q);
+ if (!host->req)
break;
- }
}
+
+ if (unlikely(!blk_fs_request(host->req))) {
+ mg_end_request_cur(host, -EIO);
+ continue;
+ }
+
+ if (rq_data_dir(host->req) == READ)
+ mg_read(host->req);
+ else
+ mg_write(host->req);
}
}
@@ -588,18 +706,15 @@ static unsigned int mg_issue_req(struct request *req,
break;
case WRITE:
/* TODO : handler */
- outb(MG_REG_CTRL_INTR_DISABLE,
- (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
if (mg_out(host, sect_num, sect_cnt, MG_CMD_WR, &mg_write_intr)
!= MG_ERR_NONE) {
mg_bad_rw_intr(host);
return host->error;
}
del_timer(&host->timer);
- mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, MG_TMAX_WAIT_WR_DRQ);
- outb(MG_REG_CTRL_INTR_ENABLE, (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ);
+ outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
if (host->error) {
mg_bad_rw_intr(host);
return host->error;
@@ -614,11 +729,6 @@ static unsigned int mg_issue_req(struct request *req,
outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base +
MG_REG_COMMAND);
break;
- default:
- printk(KERN_WARNING "%s:%d unknown command\n",
- __func__, __LINE__);
- end_request(req, 0);
- break;
}
return MG_ERR_NONE;
}
@@ -626,16 +736,17 @@ static unsigned int mg_issue_req(struct request *req,
/* This function also called from IRQ context */
static void mg_request(struct request_queue *q)
{
+ struct mg_host *host = q->queuedata;
struct request *req;
- struct mg_host *host;
u32 sect_num, sect_cnt;
while (1) {
- req = elv_next_request(q);
- if (!req)
- return;
-
- host = req->rq_disk->private_data;
+ if (!host->req) {
+ host->req = blk_fetch_request(q);
+ if (!host->req)
+ break;
+ }
+ req = host->req;
/* check unwanted request call */
if (host->mg_do_intr)
@@ -643,9 +754,9 @@ static void mg_request(struct request_queue *q)
del_timer(&host->timer);
- sect_num = req->sector;
+ sect_num = blk_rq_pos(req);
/* deal whole segments */
- sect_cnt = req->nr_sectors;
+ sect_cnt = blk_rq_sectors(req);
/* sanity check */
if (sect_num >= get_capacity(req->rq_disk) ||
@@ -655,12 +766,14 @@ static void mg_request(struct request_queue *q)
"%s: bad access: sector=%d, count=%d\n",
req->rq_disk->disk_name,
sect_num, sect_cnt);
- end_request(req, 0);
+ mg_end_request_cur(host, -EIO);
continue;
}
- if (!blk_fs_request(req))
- return;
+ if (unlikely(!blk_fs_request(req))) {
+ mg_end_request_cur(host, -EIO);
+ continue;
+ }
if (!mg_issue_req(req, host, sect_num, sect_cnt))
return;
@@ -690,9 +803,7 @@ static int mg_suspend(struct platform_device *plat_dev, pm_message_t state)
return -EIO;
if (!prv_data->use_polling)
- outb(MG_REG_CTRL_INTR_DISABLE,
- (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
outb(MG_CMD_SLEEP, (unsigned long)host->dev_base + MG_REG_COMMAND);
/* wait until mflash deep sleep */
@@ -700,9 +811,7 @@ static int mg_suspend(struct platform_device *plat_dev, pm_message_t state)
if (mg_wait(host, MG_STAT_READY, MG_TMAX_CONF_TO_CMD)) {
if (!prv_data->use_polling)
- outb(MG_REG_CTRL_INTR_ENABLE,
- (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
return -EIO;
}
@@ -725,8 +834,7 @@ static int mg_resume(struct platform_device *plat_dev)
return -EIO;
if (!prv_data->use_polling)
- outb(MG_REG_CTRL_INTR_ENABLE, (unsigned long)host->dev_base +
- MG_REG_DRV_CTRL);
+ outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
return 0;
}
@@ -877,6 +985,7 @@ static int mg_probe(struct platform_device *plat_dev)
__func__, __LINE__);
goto probe_err_5;
}
+ host->breq->queuedata = host;
/* mflash is random device, thanx for the noop */
elevator_exit(host->breq->elevator);
@@ -887,7 +996,7 @@ static int mg_probe(struct platform_device *plat_dev)
goto probe_err_6;
}
blk_queue_max_sectors(host->breq, MG_MAX_SECTS);
- blk_queue_hardsect_size(host->breq, MG_SECTOR_SIZE);
+ blk_queue_logical_block_size(host->breq, MG_SECTOR_SIZE);
init_timer(&host->timer);
host->timer.function = mg_times_out;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 4d6de4f15ccb..5d23ffad7c77 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -110,7 +110,7 @@ static void nbd_end_request(struct request *req)
req, error ? "failed" : "done");
spin_lock_irqsave(q->queue_lock, flags);
- __blk_end_request(req, error, req->nr_sectors << 9);
+ __blk_end_request_all(req, error);
spin_unlock_irqrestore(q->queue_lock, flags);
}
@@ -231,19 +231,19 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
{
int result, flags;
struct nbd_request request;
- unsigned long size = req->nr_sectors << 9;
+ unsigned long size = blk_rq_bytes(req);
request.magic = htonl(NBD_REQUEST_MAGIC);
request.type = htonl(nbd_cmd(req));
- request.from = cpu_to_be64((u64) req->sector << 9);
+ request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
request.len = htonl(size);
memcpy(request.handle, &req, sizeof(req));
- dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%luB)\n",
+ dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%uB)\n",
lo->disk->disk_name, req,
nbdcmd_to_ascii(nbd_cmd(req)),
- (unsigned long long)req->sector << 9,
- req->nr_sectors << 9);
+ (unsigned long long)blk_rq_pos(req) << 9,
+ blk_rq_bytes(req));
result = sock_xmit(lo, 1, &request, sizeof(request),
(nbd_cmd(req) == NBD_CMD_WRITE) ? MSG_MORE : 0);
if (result <= 0) {
@@ -533,11 +533,9 @@ static void do_nbd_request(struct request_queue *q)
{
struct request *req;
- while ((req = elv_next_request(q)) != NULL) {
+ while ((req = blk_fetch_request(q)) != NULL) {
struct nbd_device *lo;
- blkdev_dequeue_request(req);
-
spin_unlock_irq(q->queue_lock);
dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n",
@@ -580,13 +578,6 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *lo,
blk_rq_init(NULL, &sreq);
sreq.cmd_type = REQ_TYPE_SPECIAL;
nbd_cmd(&sreq) = NBD_CMD_DISC;
- /*
- * Set these to sane values in case server implementation
- * fails to check the request type first and also to keep
- * debugging output cleaner.
- */
- sreq.sector = 0;
- sreq.nr_sectors = 0;
if (!lo->sock)
return -EINVAL;
nbd_send_req(lo, &sreq);
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index e91d4b4b014f..911dfd98d813 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -719,32 +719,37 @@ static void do_pcd_request(struct request_queue * q)
if (pcd_busy)
return;
while (1) {
- pcd_req = elv_next_request(q);
- if (!pcd_req)
- return;
+ if (!pcd_req) {
+ pcd_req = blk_fetch_request(q);
+ if (!pcd_req)
+ return;
+ }
if (rq_data_dir(pcd_req) == READ) {
struct pcd_unit *cd = pcd_req->rq_disk->private_data;
if (cd != pcd_current)
pcd_bufblk = -1;
pcd_current = cd;
- pcd_sector = pcd_req->sector;
- pcd_count = pcd_req->current_nr_sectors;
+ pcd_sector = blk_rq_pos(pcd_req);
+ pcd_count = blk_rq_cur_sectors(pcd_req);
pcd_buf = pcd_req->buffer;
pcd_busy = 1;
ps_set_intr(do_pcd_read, NULL, 0, nice);
return;
- } else
- end_request(pcd_req, 0);
+ } else {
+ __blk_end_request_all(pcd_req, -EIO);
+ pcd_req = NULL;
+ }
}
}
-static inline void next_request(int success)
+static inline void next_request(int err)
{
unsigned long saved_flags;
spin_lock_irqsave(&pcd_lock, saved_flags);
- end_request(pcd_req, success);
+ if (!__blk_end_request_cur(pcd_req, err))
+ pcd_req = NULL;
pcd_busy = 0;
do_pcd_request(pcd_queue);
spin_unlock_irqrestore(&pcd_lock, saved_flags);
@@ -781,7 +786,7 @@ static void pcd_start(void)
if (pcd_command(pcd_current, rd_cmd, 2048, "read block")) {
pcd_bufblk = -1;
- next_request(0);
+ next_request(-EIO);
return;
}
@@ -796,7 +801,7 @@ static void do_pcd_read(void)
pcd_retries = 0;
pcd_transfer();
if (!pcd_count) {
- next_request(1);
+ next_request(0);
return;
}
@@ -815,7 +820,7 @@ static void do_pcd_read_drq(void)
return;
}
pcd_bufblk = -1;
- next_request(0);
+ next_request(-EIO);
return;
}
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 9299455b0af6..bf5955b3d873 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -410,10 +410,12 @@ static void run_fsm(void)
pd_claimed = 0;
phase = NULL;
spin_lock_irqsave(&pd_lock, saved_flags);
- end_request(pd_req, res);
- pd_req = elv_next_request(pd_queue);
- if (!pd_req)
- stop = 1;
+ if (!__blk_end_request_cur(pd_req,
+ res == Ok ? 0 : -EIO)) {
+ pd_req = blk_fetch_request(pd_queue);
+ if (!pd_req)
+ stop = 1;
+ }
spin_unlock_irqrestore(&pd_lock, saved_flags);
if (stop)
return;
@@ -443,11 +445,11 @@ static enum action do_pd_io_start(void)
pd_cmd = rq_data_dir(pd_req);
if (pd_cmd == READ || pd_cmd == WRITE) {
- pd_block = pd_req->sector;
- pd_count = pd_req->current_nr_sectors;
+ pd_block = blk_rq_pos(pd_req);
+ pd_count = blk_rq_cur_sectors(pd_req);
if (pd_block + pd_count > get_capacity(pd_req->rq_disk))
return Fail;
- pd_run = pd_req->nr_sectors;
+ pd_run = blk_rq_sectors(pd_req);
pd_buf = pd_req->buffer;
pd_retries = 0;
if (pd_cmd == READ)
@@ -477,8 +479,8 @@ static int pd_next_buf(void)
if (pd_count)
return 0;
spin_lock_irqsave(&pd_lock, saved_flags);
- end_request(pd_req, 1);
- pd_count = pd_req->current_nr_sectors;
+ __blk_end_request_cur(pd_req, 0);
+ pd_count = blk_rq_cur_sectors(pd_req);
pd_buf = pd_req->buffer;
spin_unlock_irqrestore(&pd_lock, saved_flags);
return 0;
@@ -702,7 +704,7 @@ static void do_pd_request(struct request_queue * q)
{
if (pd_req)
return;
- pd_req = elv_next_request(q);
+ pd_req = blk_fetch_request(q);
if (!pd_req)
return;
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index bef3b997ba3e..68a90834e993 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -750,12 +750,10 @@ static int pf_ready(void)
static struct request_queue *pf_queue;
-static void pf_end_request(int uptodate)
+static void pf_end_request(int err)
{
- if (pf_req) {
- end_request(pf_req, uptodate);
+ if (pf_req && !__blk_end_request_cur(pf_req, err))
pf_req = NULL;
- }
}
static void do_pf_request(struct request_queue * q)
@@ -763,17 +761,19 @@ static void do_pf_request(struct request_queue * q)
if (pf_busy)
return;
repeat:
- pf_req = elv_next_request(q);
- if (!pf_req)
- return;
+ if (!pf_req) {
+ pf_req = blk_fetch_request(q);
+ if (!pf_req)
+ return;
+ }
pf_current = pf_req->rq_disk->private_data;
- pf_block = pf_req->sector;
- pf_run = pf_req->nr_sectors;
- pf_count = pf_req->current_nr_sectors;
+ pf_block = blk_rq_pos(pf_req);
+ pf_run = blk_rq_sectors(pf_req);
+ pf_count = blk_rq_cur_sectors(pf_req);
if (pf_block + pf_count > get_capacity(pf_req->rq_disk)) {
- pf_end_request(0);
+ pf_end_request(-EIO);
goto repeat;
}
@@ -788,7 +788,7 @@ repeat:
pi_do_claimed(pf_current->pi, do_pf_write);
else {
pf_busy = 0;
- pf_end_request(0);
+ pf_end_request(-EIO);
goto repeat;
}
}
@@ -805,23 +805,22 @@ static int pf_next_buf(void)
return 1;
if (!pf_count) {
spin_lock_irqsave(&pf_spin_lock, saved_flags);
- pf_end_request(1);
- pf_req = elv_next_request(pf_queue);
+ pf_end_request(0);
spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
if (!pf_req)
return 1;
- pf_count = pf_req->current_nr_sectors;
+ pf_count = blk_rq_cur_sectors(pf_req);
pf_buf = pf_req->buffer;
}
return 0;
}
-static inline void next_request(int success)
+static inline void next_request(int err)
{
unsigned long saved_flags;
spin_lock_irqsave(&pf_spin_lock, saved_flags);
- pf_end_request(success);
+ pf_end_request(err);
pf_busy = 0;
do_pf_request(pf_queue);
spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
@@ -844,7 +843,7 @@ static void do_pf_read_start(void)
pi_do_claimed(pf_current->pi, do_pf_read_start);
return;
}
- next_request(0);
+ next_request(-EIO);
return;
}
pf_mask = STAT_DRQ;
@@ -863,7 +862,7 @@ static void do_pf_read_drq(void)
pi_do_claimed(pf_current->pi, do_pf_read_start);
return;
}
- next_request(0);
+ next_request(-EIO);
return;
}
pi_read_block(pf_current->pi, pf_buf, 512);
@@ -871,7 +870,7 @@ static void do_pf_read_drq(void)
break;
}
pi_disconnect(pf_current->pi);
- next_request(1);
+ next_request(0);
}
static void do_pf_write(void)
@@ -890,7 +889,7 @@ static void do_pf_write_start(void)
pi_do_claimed(pf_current->pi, do_pf_write_start);
return;
}
- next_request(0);
+ next_request(-EIO);
return;
}
@@ -903,7 +902,7 @@ static void do_pf_write_start(void)
pi_do_claimed(pf_current->pi, do_pf_write_start);
return;
}
- next_request(0);
+ next_request(-EIO);
return;
}
pi_write_block(pf_current->pi, pf_buf, 512);
@@ -923,11 +922,11 @@ static void do_pf_write_done(void)
pi_do_claimed(pf_current->pi, do_pf_write_start);
return;
}
- next_request(0);
+ next_request(-EIO);
return;
}
pi_disconnect(pf_current->pi);
- next_request(1);
+ next_request(0);
}
static int __init pf_init(void)
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index dc7a8c352da2..37e0f81cada2 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -991,13 +991,15 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
*/
static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
{
- if ((pd->settings.size << 9) / CD_FRAMESIZE <= q->max_phys_segments) {
+ if ((pd->settings.size << 9) / CD_FRAMESIZE
+ <= queue_max_phys_segments(q)) {
/*
* The cdrom device can handle one segment/frame
*/
clear_bit(PACKET_MERGE_SEGS, &pd->flags);
return 0;
- } else if ((pd->settings.size << 9) / PAGE_SIZE <= q->max_phys_segments) {
+ } else if ((pd->settings.size << 9) / PAGE_SIZE
+ <= queue_max_phys_segments(q)) {
/*
* We can handle this case at the expense of some extra memory
* copies during write operations
@@ -2657,7 +2659,7 @@ static void pkt_init_queue(struct pktcdvd_device *pd)
struct request_queue *q = pd->disk->queue;
blk_queue_make_request(q, pkt_make_request);
- blk_queue_hardsect_size(q, CD_FRAMESIZE);
+ blk_queue_logical_block_size(q, CD_FRAMESIZE);
blk_queue_max_sectors(q, PACKET_MAX_SECTORS);
blk_queue_merge_bvec(q, pkt_merge_bvec);
q->queuedata = pd;
@@ -2853,6 +2855,11 @@ static struct block_device_operations pktcdvd_ops = {
.media_changed = pkt_media_changed,
};
+static char *pktcdvd_nodename(struct gendisk *gd)
+{
+ return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
+}
+
/*
* Set up mapping from pktcdvd device to CD-ROM device.
*/
@@ -2905,6 +2912,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
disk->fops = &pktcdvd_ops;
disk->flags = GENHD_FL_REMOVABLE;
strcpy(disk->disk_name, pd->name);
+ disk->nodename = pktcdvd_nodename;
disk->private_data = pd;
disk->queue = blk_alloc_queue(GFP_KERNEL);
if (!disk->queue)
@@ -3060,6 +3068,7 @@ static const struct file_operations pkt_ctl_fops = {
static struct miscdevice pkt_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DRIVER_NAME,
+ .name = "pktcdvd/control",
.fops = &pkt_ctl_fops
};
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index bccc42bb9212..1299db15f085 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -120,7 +120,7 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev,
static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
struct request *req)
{
- struct ps3disk_private *priv = dev->sbd.core.driver_data;
+ struct ps3disk_private *priv = dev_get_drvdata(&dev->sbd.core);
int write = rq_data_dir(req), res;
const char *op = write ? "write" : "read";
u64 start_sector, sectors;
@@ -134,13 +134,12 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
rq_for_each_segment(bv, req, iter)
n++;
dev_dbg(&dev->sbd.core,
- "%s:%u: %s req has %u bvecs for %lu sectors %lu hard sectors\n",
- __func__, __LINE__, op, n, req->nr_sectors,
- req->hard_nr_sectors);
+ "%s:%u: %s req has %u bvecs for %u sectors\n",
+ __func__, __LINE__, op, n, blk_rq_sectors(req));
#endif
- start_sector = req->sector * priv->blocking_factor;
- sectors = req->nr_sectors * priv->blocking_factor;
+ start_sector = blk_rq_pos(req) * priv->blocking_factor;
+ sectors = blk_rq_sectors(req) * priv->blocking_factor;
dev_dbg(&dev->sbd.core, "%s:%u: %s %llu sectors starting at %llu\n",
__func__, __LINE__, op, sectors, start_sector);
@@ -158,7 +157,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
if (res) {
dev_err(&dev->sbd.core, "%s:%u: %s failed %d\n", __func__,
__LINE__, op, res);
- end_request(req, 0);
+ __blk_end_request_all(req, -EIO);
return 0;
}
@@ -169,7 +168,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,
struct request *req)
{
- struct ps3disk_private *priv = dev->sbd.core.driver_data;
+ struct ps3disk_private *priv = dev_get_drvdata(&dev->sbd.core);
u64 res;
dev_dbg(&dev->sbd.core, "%s:%u: flush request\n", __func__, __LINE__);
@@ -180,7 +179,7 @@ static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,
if (res) {
dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n",
__func__, __LINE__, res);
- end_request(req, 0);
+ __blk_end_request_all(req, -EIO);
return 0;
}
@@ -195,7 +194,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
- while ((req = elv_next_request(q))) {
+ while ((req = blk_fetch_request(q))) {
if (blk_fs_request(req)) {
if (ps3disk_submit_request_sg(dev, req))
break;
@@ -205,7 +204,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
break;
} else {
blk_dump_rq_flags(req, DEVICE_NAME " bad request");
- end_request(req, 0);
+ __blk_end_request_all(req, -EIO);
continue;
}
}
@@ -214,7 +213,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
static void ps3disk_request(struct request_queue *q)
{
struct ps3_storage_device *dev = q->queuedata;
- struct ps3disk_private *priv = dev->sbd.core.driver_data;
+ struct ps3disk_private *priv = dev_get_drvdata(&dev->sbd.core);
if (priv->req) {
dev_dbg(&dev->sbd.core, "%s:%u busy\n", __func__, __LINE__);
@@ -231,7 +230,6 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
struct request *req;
int res, read, error;
u64 tag, status;
- unsigned long num_sectors;
const char *op;
res = lv1_storage_get_async_status(dev->sbd.dev_id, &tag, &status);
@@ -247,7 +245,7 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
return IRQ_HANDLED;
}
- priv = dev->sbd.core.driver_data;
+ priv = dev_get_drvdata(&dev->sbd.core);
req = priv->req;
if (!req) {
dev_dbg(&dev->sbd.core,
@@ -261,11 +259,9 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
req->cmd[0] == REQ_LB_OP_FLUSH) {
read = 0;
- num_sectors = req->hard_cur_sectors;
op = "flush";
} else {
read = !rq_data_dir(req);
- num_sectors = req->nr_sectors;
op = read ? "read" : "write";
}
if (status) {
@@ -281,7 +277,7 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
}
spin_lock(&priv->lock);
- __blk_end_request(req, error, num_sectors << 9);
+ __blk_end_request_all(req, error);
priv->req = NULL;
ps3disk_do_request(dev, priv->queue);
spin_unlock(&priv->lock);
@@ -368,7 +364,7 @@ static void ata_id_c_string(const u16 *id, unsigned char *s, unsigned int ofs,
static int ps3disk_identify(struct ps3_storage_device *dev)
{
- struct ps3disk_private *priv = dev->sbd.core.driver_data;
+ struct ps3disk_private *priv = dev_get_drvdata(&dev->sbd.core);
struct lv1_ata_cmnd_block ata_cmnd;
u16 *id = dev->bounce_buf;
u64 res;
@@ -449,7 +445,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
goto fail;
}
- dev->sbd.core.driver_data = priv;
+ dev_set_drvdata(&dev->sbd.core, priv);
spin_lock_init(&priv->lock);
dev->bounce_size = BOUNCE_SIZE;
@@ -481,7 +477,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
blk_queue_max_sectors(queue, dev->bounce_size >> 9);
blk_queue_segment_boundary(queue, -1UL);
blk_queue_dma_alignment(queue, dev->blk_size-1);
- blk_queue_hardsect_size(queue, dev->blk_size);
+ blk_queue_logical_block_size(queue, dev->blk_size);
blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH,
ps3disk_prepare_flush);
@@ -527,7 +523,7 @@ fail_free_bounce:
kfree(dev->bounce_buf);
fail_free_priv:
kfree(priv);
- dev->sbd.core.driver_data = NULL;
+ dev_set_drvdata(&dev->sbd.core, NULL);
fail:
mutex_lock(&ps3disk_mask_mutex);
__clear_bit(devidx, &ps3disk_mask);
@@ -538,7 +534,7 @@ fail:
static int ps3disk_remove(struct ps3_system_bus_device *_dev)
{
struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
- struct ps3disk_private *priv = dev->sbd.core.driver_data;
+ struct ps3disk_private *priv = dev_get_drvdata(&dev->sbd.core);
mutex_lock(&ps3disk_mask_mutex);
__clear_bit(MINOR(disk_devt(priv->gendisk)) / PS3DISK_MINORS,
@@ -552,7 +548,7 @@ static int ps3disk_remove(struct ps3_system_bus_device *_dev)
ps3stor_teardown(dev);
kfree(dev->bounce_buf);
kfree(priv);
- dev->sbd.core.driver_data = NULL;
+ dev_set_drvdata(&dev->sbd.core, NULL);
return 0;
}
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 8eddef373a91..8ecf1e00cede 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -111,7 +111,7 @@ static u32 *ps3vram_get_notifier(u32 *reports, int notifier)
static void ps3vram_notifier_reset(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
int i;
@@ -122,7 +122,7 @@ static void ps3vram_notifier_reset(struct ps3_system_bus_device *dev)
static int ps3vram_notifier_wait(struct ps3_system_bus_device *dev,
unsigned int timeout_ms)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
@@ -137,7 +137,7 @@ static int ps3vram_notifier_wait(struct ps3_system_bus_device *dev,
static void ps3vram_init_ring(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET;
priv->ctrl[CTRL_GET] = FIFO_BASE + FIFO_OFFSET;
@@ -146,7 +146,7 @@ static void ps3vram_init_ring(struct ps3_system_bus_device *dev)
static int ps3vram_wait_ring(struct ps3_system_bus_device *dev,
unsigned int timeout_ms)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
do {
@@ -175,7 +175,7 @@ static void ps3vram_begin_ring(struct ps3vram_priv *priv, u32 chan, u32 tag,
static void ps3vram_rewind_ring(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
int status;
ps3vram_out_ring(priv, 0x20000000 | (FIFO_BASE + FIFO_OFFSET));
@@ -196,7 +196,7 @@ static void ps3vram_rewind_ring(struct ps3_system_bus_device *dev)
static void ps3vram_fire_ring(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
int status;
mutex_lock(&ps3_gpu_mutex);
@@ -225,7 +225,7 @@ static void ps3vram_fire_ring(struct ps3_system_bus_device *dev)
static void ps3vram_bind(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0, 1);
ps3vram_out_ring(priv, 0x31337303);
@@ -248,7 +248,7 @@ static int ps3vram_upload(struct ps3_system_bus_device *dev,
unsigned int src_offset, unsigned int dst_offset,
int len, int count)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
ps3vram_begin_ring(priv, UPLOAD_SUBCH,
NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
@@ -280,7 +280,7 @@ static int ps3vram_download(struct ps3_system_bus_device *dev,
unsigned int src_offset, unsigned int dst_offset,
int len, int count)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
ps3vram_begin_ring(priv, DOWNLOAD_SUBCH,
NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
@@ -310,7 +310,7 @@ static int ps3vram_download(struct ps3_system_bus_device *dev,
static void ps3vram_cache_evict(struct ps3_system_bus_device *dev, int entry)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
struct ps3vram_cache *cache = &priv->cache;
if (!(cache->tags[entry].flags & CACHE_PAGE_DIRTY))
@@ -332,7 +332,7 @@ static void ps3vram_cache_evict(struct ps3_system_bus_device *dev, int entry)
static void ps3vram_cache_load(struct ps3_system_bus_device *dev, int entry,
unsigned int address)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
struct ps3vram_cache *cache = &priv->cache;
dev_dbg(&dev->core, "Fetching %d: 0x%08x\n", entry, address);
@@ -352,7 +352,7 @@ static void ps3vram_cache_load(struct ps3_system_bus_device *dev, int entry,
static void ps3vram_cache_flush(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
struct ps3vram_cache *cache = &priv->cache;
int i;
@@ -366,7 +366,7 @@ static void ps3vram_cache_flush(struct ps3_system_bus_device *dev)
static unsigned int ps3vram_cache_match(struct ps3_system_bus_device *dev,
loff_t address)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
struct ps3vram_cache *cache = &priv->cache;
unsigned int base;
unsigned int offset;
@@ -400,7 +400,7 @@ static unsigned int ps3vram_cache_match(struct ps3_system_bus_device *dev,
static int ps3vram_cache_init(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
priv->cache.page_count = CACHE_PAGE_COUNT;
priv->cache.page_size = CACHE_PAGE_SIZE;
@@ -419,7 +419,7 @@ static int ps3vram_cache_init(struct ps3_system_bus_device *dev)
static void ps3vram_cache_cleanup(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
ps3vram_cache_flush(dev);
kfree(priv->cache.tags);
@@ -428,7 +428,7 @@ static void ps3vram_cache_cleanup(struct ps3_system_bus_device *dev)
static int ps3vram_read(struct ps3_system_bus_device *dev, loff_t from,
size_t len, size_t *retlen, u_char *buf)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
unsigned int cached, count;
dev_dbg(&dev->core, "%s: from=0x%08x len=0x%zx\n", __func__,
@@ -476,7 +476,7 @@ static int ps3vram_read(struct ps3_system_bus_device *dev, loff_t from,
static int ps3vram_write(struct ps3_system_bus_device *dev, loff_t to,
size_t len, size_t *retlen, const u_char *buf)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
unsigned int cached, count;
if (to >= priv->size)
@@ -543,7 +543,7 @@ static const struct file_operations ps3vram_proc_fops = {
static void __devinit ps3vram_proc_init(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
struct proc_dir_entry *pde;
pde = proc_create(DEVICE_NAME, 0444, NULL, &ps3vram_proc_fops);
@@ -615,9 +615,9 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
}
mutex_init(&priv->lock);
- dev->core.driver_data = priv;
+ dev_set_drvdata(&dev->core, priv);
- priv = dev->core.driver_data;
+ priv = dev_get_drvdata(&dev->core);
/* Allocate XDR buffer (1MiB aligned) */
priv->xdr_buf = (void *)__get_free_pages(GFP_KERNEL,
@@ -787,14 +787,14 @@ out_free_xdr_buf:
free_pages((unsigned long) priv->xdr_buf, get_order(XDR_BUF_SIZE));
fail_free_priv:
kfree(priv);
- dev->core.driver_data = NULL;
+ dev_set_drvdata(&dev->core, NULL);
fail:
return error;
}
static int ps3vram_remove(struct ps3_system_bus_device *dev)
{
- struct ps3vram_priv *priv = dev->core.driver_data;
+ struct ps3vram_priv *priv = dev_get_drvdata(&dev->core);
del_gendisk(priv->gendisk);
put_disk(priv->gendisk);
@@ -809,7 +809,7 @@ static int ps3vram_remove(struct ps3_system_bus_device *dev)
ps3_close_hv_device(dev);
free_pages((unsigned long) priv->xdr_buf, get_order(XDR_BUF_SIZE));
kfree(priv);
- dev->core.driver_data = NULL;
+ dev_set_drvdata(&dev->core, NULL);
return 0;
}
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 5861e33efe63..cbfd9c0aef03 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -212,11 +212,6 @@ static void vdc_end_special(struct vdc_port *port, struct vio_disk_desc *desc)
vdc_finish(&port->vio, -err, WAITING_FOR_GEN_CMD);
}
-static void vdc_end_request(struct request *req, int error, int num_sectors)
-{
- __blk_end_request(req, error, num_sectors << 9);
-}
-
static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr,
unsigned int index)
{
@@ -239,7 +234,7 @@ static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr,
rqe->req = NULL;
- vdc_end_request(req, (desc->status ? -EIO : 0), desc->size >> 9);
+ __blk_end_request(req, (desc->status ? -EIO : 0), desc->size);
if (blk_queue_stopped(port->disk->queue))
blk_start_queue(port->disk->queue);
@@ -421,7 +416,7 @@ static int __send_request(struct request *req)
desc->slice = 0;
}
desc->status = ~0;
- desc->offset = (req->sector << 9) / port->vdisk_block_size;
+ desc->offset = (blk_rq_pos(req) << 9) / port->vdisk_block_size;
desc->size = len;
desc->ncookies = err;
@@ -446,14 +441,13 @@ out:
static void do_vdc_request(struct request_queue *q)
{
while (1) {
- struct request *req = elv_next_request(q);
+ struct request *req = blk_fetch_request(q);
if (!req)
break;
- blkdev_dequeue_request(req);
if (__send_request(req) < 0)
- vdc_end_request(req, -EIO, req->hard_nr_sectors);
+ __blk_end_request_all(req, -EIO);
}
}
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index d22cc3856937..cf7877fb8a7d 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs,
ret = swim_read_sector(fs, side, track, sector,
buffer);
if (try-- == 0)
- return -1;
+ return -EIO;
} while (ret != 512);
buffer += ret;
@@ -528,45 +528,31 @@ static void redo_fd_request(struct request_queue *q)
struct request *req;
struct floppy_state *fs;
- while ((req = elv_next_request(q))) {
+ req = blk_fetch_request(q);
+ while (req) {
+ int err = -EIO;
fs = req->rq_disk->private_data;
- if (req->sector < 0 || req->sector >= fs->total_secs) {
- end_request(req, 0);
- continue;
- }
- if (req->current_nr_sectors == 0) {
- end_request(req, 1);
- continue;
- }
- if (!fs->disk_in) {
- end_request(req, 0);
- continue;
- }
- if (rq_data_dir(req) == WRITE) {
- if (fs->write_protected) {
- end_request(req, 0);
- continue;
- }
- }
+ if (blk_rq_pos(req) >= fs->total_secs)
+ goto done;
+ if (!fs->disk_in)
+ goto done;
+ if (rq_data_dir(req) == WRITE && fs->write_protected)
+ goto done;
+
switch (rq_data_dir(req)) {
case WRITE:
/* NOT IMPLEMENTED */
- end_request(req, 0);
break;
case READ:
- if (floppy_read_sectors(fs, req->sector,
- req->current_nr_sectors,
- req->buffer)) {
- end_request(req, 0);
- continue;
- }
- req->nr_sectors -= req->current_nr_sectors;
- req->sector += req->current_nr_sectors;
- req->buffer += req->current_nr_sectors * 512;
- end_request(req, 1);
+ err = floppy_read_sectors(fs, blk_rq_pos(req),
+ blk_rq_cur_sectors(req),
+ req->buffer);
break;
}
+ done:
+ if (!__blk_end_request_cur(req, err))
+ req = blk_fetch_request(q);
}
}
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 612965307ba0..80df93e3cdd0 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -251,6 +251,20 @@ static int floppy_release(struct gendisk *disk, fmode_t mode);
static int floppy_check_change(struct gendisk *disk);
static int floppy_revalidate(struct gendisk *disk);
+static bool swim3_end_request(int err, unsigned int nr_bytes)
+{
+ if (__blk_end_request(fd_req, err, nr_bytes))
+ return true;
+
+ fd_req = NULL;
+ return false;
+}
+
+static bool swim3_end_request_cur(int err)
+{
+ return swim3_end_request(err, blk_rq_cur_bytes(fd_req));
+}
+
static void swim3_select(struct floppy_state *fs, int sel)
{
struct swim3 __iomem *sw = fs->swim3;
@@ -310,25 +324,27 @@ static void start_request(struct floppy_state *fs)
wake_up(&fs->wait);
return;
}
- while (fs->state == idle && (req = elv_next_request(swim3_queue))) {
+ while (fs->state == idle) {
+ if (!fd_req) {
+ fd_req = blk_fetch_request(swim3_queue);
+ if (!fd_req)
+ break;
+ }
+ req = fd_req;
#if 0
- printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n",
+ printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%u buf=%p\n",
req->rq_disk->disk_name, req->cmd,
- (long)req->sector, req->nr_sectors, req->buffer);
- printk(" errors=%d current_nr_sectors=%ld\n",
- req->errors, req->current_nr_sectors);
+ (long)blk_rq_pos(req), blk_rq_sectors(req), req->buffer);
+ printk(" errors=%d current_nr_sectors=%u\n",
+ req->errors, blk_rq_cur_sectors(req));
#endif
- if (req->sector < 0 || req->sector >= fs->total_secs) {
- end_request(req, 0);
- continue;
- }
- if (req->current_nr_sectors == 0) {
- end_request(req, 1);
+ if (blk_rq_pos(req) >= fs->total_secs) {
+ swim3_end_request_cur(-EIO);
continue;
}
if (fs->ejected) {
- end_request(req, 0);
+ swim3_end_request_cur(-EIO);
continue;
}
@@ -336,18 +352,19 @@ static void start_request(struct floppy_state *fs)
if (fs->write_prot < 0)
fs->write_prot = swim3_readbit(fs, WRITE_PROT);
if (fs->write_prot) {
- end_request(req, 0);
+ swim3_end_request_cur(-EIO);
continue;
}
}
- /* Do not remove the cast. req->sector is now a sector_t and
- * can be 64 bits, but it will never go past 32 bits for this
- * driver anyway, so we can safely cast it down and not have
- * to do a 64/32 division
+ /* Do not remove the cast. blk_rq_pos(req) is now a
+ * sector_t and can be 64 bits, but it will never go
+ * past 32 bits for this driver anyway, so we can
+ * safely cast it down and not have to do a 64/32
+ * division
*/
- fs->req_cyl = ((long)req->sector) / fs->secpercyl;
- x = ((long)req->sector) % fs->secpercyl;
+ fs->req_cyl = ((long)blk_rq_pos(req)) / fs->secpercyl;
+ x = ((long)blk_rq_pos(req)) % fs->secpercyl;
fs->head = x / fs->secpertrack;
fs->req_sector = x % fs->secpertrack + 1;
fd_req = req;
@@ -424,7 +441,7 @@ static inline void setup_transfer(struct floppy_state *fs)
struct dbdma_cmd *cp = fs->dma_cmd;
struct dbdma_regs __iomem *dr = fs->dma;
- if (fd_req->current_nr_sectors <= 0) {
+ if (blk_rq_cur_sectors(fd_req) <= 0) {
printk(KERN_ERR "swim3: transfer 0 sectors?\n");
return;
}
@@ -432,8 +449,8 @@ static inline void setup_transfer(struct floppy_state *fs)
n = 1;
else {
n = fs->secpertrack - fs->req_sector + 1;
- if (n > fd_req->current_nr_sectors)
- n = fd_req->current_nr_sectors;
+ if (n > blk_rq_cur_sectors(fd_req))
+ n = blk_rq_cur_sectors(fd_req);
}
fs->scount = n;
swim3_select(fs, fs->head? READ_DATA_1: READ_DATA_0);
@@ -508,7 +525,7 @@ static void act(struct floppy_state *fs)
case do_transfer:
if (fs->cur_cyl != fs->req_cyl) {
if (fs->retries > 5) {
- end_request(fd_req, 0);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
return;
}
@@ -540,7 +557,7 @@ static void scan_timeout(unsigned long data)
out_8(&sw->intr_enable, 0);
fs->cur_cyl = -1;
if (fs->retries > 5) {
- end_request(fd_req, 0);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
start_request(fs);
} else {
@@ -559,7 +576,7 @@ static void seek_timeout(unsigned long data)
out_8(&sw->select, RELAX);
out_8(&sw->intr_enable, 0);
printk(KERN_ERR "swim3: seek timeout\n");
- end_request(fd_req, 0);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
start_request(fs);
}
@@ -583,7 +600,7 @@ static void settle_timeout(unsigned long data)
return;
}
printk(KERN_ERR "swim3: seek settle timeout\n");
- end_request(fd_req, 0);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
start_request(fs);
}
@@ -593,8 +610,6 @@ static void xfer_timeout(unsigned long data)
struct floppy_state *fs = (struct floppy_state *) data;
struct swim3 __iomem *sw = fs->swim3;
struct dbdma_regs __iomem *dr = fs->dma;
- struct dbdma_cmd *cp = fs->dma_cmd;
- unsigned long s;
int n;
fs->timeout_pending = 0;
@@ -605,17 +620,10 @@ static void xfer_timeout(unsigned long data)
out_8(&sw->intr_enable, 0);
out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
out_8(&sw->select, RELAX);
- if (rq_data_dir(fd_req) == WRITE)
- ++cp;
- if (ld_le16(&cp->xfer_status) != 0)
- s = fs->scount - ((ld_le16(&cp->res_count) + 511) >> 9);
- else
- s = 0;
- fd_req->sector += s;
- fd_req->current_nr_sectors -= s;
printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
- (rq_data_dir(fd_req)==WRITE? "writ": "read"), (long)fd_req->sector);
- end_request(fd_req, 0);
+ (rq_data_dir(fd_req)==WRITE? "writ": "read"),
+ (long)blk_rq_pos(fd_req));
+ swim3_end_request_cur(-EIO);
fs->state = idle;
start_request(fs);
}
@@ -646,7 +654,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
printk(KERN_ERR "swim3: seen sector but cyl=ff?\n");
fs->cur_cyl = -1;
if (fs->retries > 5) {
- end_request(fd_req, 0);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
start_request(fs);
} else {
@@ -719,9 +727,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
if (intr & ERROR_INTR) {
n = fs->scount - 1 - resid / 512;
if (n > 0) {
- fd_req->sector += n;
- fd_req->current_nr_sectors -= n;
- fd_req->buffer += n * 512;
+ blk_update_request(fd_req, 0, n << 9);
fs->req_sector += n;
}
if (fs->retries < 5) {
@@ -730,8 +736,8 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
} else {
printk("swim3: error %sing block %ld (err=%x)\n",
rq_data_dir(fd_req) == WRITE? "writ": "read",
- (long)fd_req->sector, err);
- end_request(fd_req, 0);
+ (long)blk_rq_pos(fd_req), err);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
}
} else {
@@ -740,18 +746,12 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid);
printk(KERN_ERR " state=%d, dir=%x, intr=%x, err=%x\n",
fs->state, rq_data_dir(fd_req), intr, err);
- end_request(fd_req, 0);
+ swim3_end_request_cur(-EIO);
fs->state = idle;
start_request(fs);
break;
}
- fd_req->sector += fs->scount;
- fd_req->current_nr_sectors -= fs->scount;
- fd_req->buffer += fs->scount * 512;
- if (fd_req->current_nr_sectors <= 0) {
- end_request(fd_req, 1);
- fs->state = idle;
- } else {
+ if (swim3_end_request(0, fs->scount << 9)) {
fs->req_sector += fs->scount;
if (fs->req_sector > fs->secpertrack) {
fs->req_sector -= fs->secpertrack;
@@ -761,7 +761,8 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
}
}
act(fs);
- }
+ } else
+ fs->state = idle;
}
if (fs->state == idle)
start_request(fs);
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index ff0448e4bf03..da403b6a7f43 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -749,8 +749,7 @@ static inline void carm_end_request_queued(struct carm_host *host,
struct request *req = crq->rq;
int rc;
- rc = __blk_end_request(req, error, blk_rq_bytes(req));
- assert(rc == 0);
+ __blk_end_request_all(req, error);
rc = carm_put_request(host, crq);
assert(rc == 0);
@@ -811,12 +810,10 @@ static void carm_oob_rq_fn(struct request_queue *q)
while (1) {
DPRINTK("get req\n");
- rq = elv_next_request(q);
+ rq = blk_fetch_request(q);
if (!rq)
break;
- blkdev_dequeue_request(rq);
-
crq = rq->special;
assert(crq != NULL);
assert(crq->rq == rq);
@@ -847,7 +844,7 @@ static void carm_rq_fn(struct request_queue *q)
queue_one_request:
VPRINTK("get req\n");
- rq = elv_next_request(q);
+ rq = blk_peek_request(q);
if (!rq)
return;
@@ -858,7 +855,7 @@ queue_one_request:
}
crq->rq = rq;
- blkdev_dequeue_request(rq);
+ blk_start_request(rq);
if (rq_data_dir(rq) == WRITE) {
writing = 1;
@@ -904,10 +901,10 @@ queue_one_request:
msg->sg_count = n_elem;
msg->sg_type = SGT_32BIT;
msg->handle = cpu_to_le32(TAG_ENCODE(crq->tag));
- msg->lba = cpu_to_le32(rq->sector & 0xffffffff);
- tmp = (rq->sector >> 16) >> 16;
+ msg->lba = cpu_to_le32(blk_rq_pos(rq) & 0xffffffff);
+ tmp = (blk_rq_pos(rq) >> 16) >> 16;
msg->lba_high = cpu_to_le16( (u16) tmp );
- msg->lba_count = cpu_to_le16(rq->nr_sectors);
+ msg->lba_count = cpu_to_le16(blk_rq_sectors(rq));
msg_size = sizeof(struct carm_msg_rw) - sizeof(msg->sg);
for (i = 0; i < n_elem; i++) {
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 689cd27ac890..cc54473b8e77 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -360,8 +360,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
struct ub_scsi_cmd *cmd, struct ub_request *urq);
static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
-static void ub_end_rq(struct request *rq, unsigned int status,
- unsigned int cmd_len);
+static void ub_end_rq(struct request *rq, unsigned int status);
static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
struct ub_request *urq, struct ub_scsi_cmd *cmd);
static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
@@ -627,7 +626,7 @@ static void ub_request_fn(struct request_queue *q)
struct ub_lun *lun = q->queuedata;
struct request *rq;
- while ((rq = elv_next_request(q)) != NULL) {
+ while ((rq = blk_peek_request(q)) != NULL) {
if (ub_request_fn_1(lun, rq) != 0) {
blk_stop_queue(q);
break;
@@ -643,14 +642,14 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
int n_elem;
if (atomic_read(&sc->poison)) {
- blkdev_dequeue_request(rq);
- ub_end_rq(rq, DID_NO_CONNECT << 16, blk_rq_bytes(rq));
+ blk_start_request(rq);
+ ub_end_rq(rq, DID_NO_CONNECT << 16);
return 0;
}
if (lun->changed && !blk_pc_request(rq)) {
- blkdev_dequeue_request(rq);
- ub_end_rq(rq, SAM_STAT_CHECK_CONDITION, blk_rq_bytes(rq));
+ blk_start_request(rq);
+ ub_end_rq(rq, SAM_STAT_CHECK_CONDITION);
return 0;
}
@@ -660,7 +659,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
return -1;
memset(cmd, 0, sizeof(struct ub_scsi_cmd));
- blkdev_dequeue_request(rq);
+ blk_start_request(rq);
urq = &lun->urq;
memset(urq, 0, sizeof(struct ub_request));
@@ -702,7 +701,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
drop:
ub_put_cmd(lun, cmd);
- ub_end_rq(rq, DID_ERROR << 16, blk_rq_bytes(rq));
+ ub_end_rq(rq, DID_ERROR << 16);
return 0;
}
@@ -723,11 +722,11 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
/*
* build the command
*
- * The call to blk_queue_hardsect_size() guarantees that request
+ * The call to blk_queue_logical_block_size() guarantees that request
* is aligned, but it is given in terms of 512 byte units, always.
*/
- block = rq->sector >> lun->capacity.bshift;
- nblks = rq->nr_sectors >> lun->capacity.bshift;
+ block = blk_rq_pos(rq) >> lun->capacity.bshift;
+ nblks = blk_rq_sectors(rq) >> lun->capacity.bshift;
cmd->cdb[0] = (cmd->dir == UB_DIR_READ)? READ_10: WRITE_10;
/* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */
@@ -739,7 +738,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
cmd->cdb[8] = nblks;
cmd->cdb_len = 10;
- cmd->len = rq->nr_sectors * 512;
+ cmd->len = blk_rq_bytes(rq);
}
static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
@@ -747,7 +746,7 @@ static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
{
struct request *rq = urq->rq;
- if (rq->data_len == 0) {
+ if (blk_rq_bytes(rq) == 0) {
cmd->dir = UB_DIR_NONE;
} else {
if (rq_data_dir(rq) == WRITE)
@@ -762,7 +761,7 @@ static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
memcpy(&cmd->cdb, rq->cmd, rq->cmd_len);
cmd->cdb_len = rq->cmd_len;
- cmd->len = rq->data_len;
+ cmd->len = blk_rq_bytes(rq);
/*
* To reapply this to every URB is not as incorrect as it looks.
@@ -777,16 +776,15 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
struct ub_request *urq = cmd->back;
struct request *rq;
unsigned int scsi_status;
- unsigned int cmd_len;
rq = urq->rq;
if (cmd->error == 0) {
if (blk_pc_request(rq)) {
- if (cmd->act_len >= rq->data_len)
- rq->data_len = 0;
+ if (cmd->act_len >= rq->resid_len)
+ rq->resid_len = 0;
else
- rq->data_len -= cmd->act_len;
+ rq->resid_len -= cmd->act_len;
scsi_status = 0;
} else {
if (cmd->act_len != cmd->len) {
@@ -818,17 +816,14 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
urq->rq = NULL;
- cmd_len = cmd->len;
ub_put_cmd(lun, cmd);
- ub_end_rq(rq, scsi_status, cmd_len);
+ ub_end_rq(rq, scsi_status);
blk_start_queue(lun->disk->queue);
}
-static void ub_end_rq(struct request *rq, unsigned int scsi_status,
- unsigned int cmd_len)
+static void ub_end_rq(struct request *rq, unsigned int scsi_status)
{
int error;
- long rqlen;
if (scsi_status == 0) {
error = 0;
@@ -836,12 +831,7 @@ static void ub_end_rq(struct request *rq, unsigned int scsi_status,
error = -EIO;
rq->errors = scsi_status;
}
- rqlen = blk_rq_bytes(rq); /* Oddly enough, this is the residue. */
- if (__blk_end_request(rq, error, cmd_len)) {
- printk(KERN_WARNING DRV_NAME
- ": __blk_end_request blew, %s-cmd total %u rqlen %ld\n",
- blk_pc_request(rq)? "pc": "fs", cmd_len, rqlen);
- }
+ __blk_end_request_all(rq, error);
}
static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
@@ -1759,7 +1749,7 @@ static int ub_bd_revalidate(struct gendisk *disk)
ub_revalidate(lun->udev, lun);
/* XXX Support sector size switching like in sr.c */
- blk_queue_hardsect_size(disk->queue, lun->capacity.bsize);
+ blk_queue_logical_block_size(disk->queue, lun->capacity.bsize);
set_capacity(disk, lun->capacity.nsec);
// set_disk_ro(sdkp->disk, lun->readonly);
@@ -2334,7 +2324,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
blk_queue_max_phys_segments(q, UB_MAX_REQ_SG);
blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */
blk_queue_max_sectors(q, UB_MAX_SECTORS);
- blk_queue_hardsect_size(q, lun->capacity.bsize);
+ blk_queue_logical_block_size(q, lun->capacity.bsize);
lun->disk = disk;
q->queuedata = lun;
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index ecccf65dce2f..390d69bb7c48 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -252,7 +252,7 @@ static int send_request(struct request *req)
struct viodasd_device *d;
unsigned long flags;
- start = (u64)req->sector << 9;
+ start = (u64)blk_rq_pos(req) << 9;
if (rq_data_dir(req) == READ) {
direction = DMA_FROM_DEVICE;
@@ -361,19 +361,17 @@ static void do_viodasd_request(struct request_queue *q)
* back later.
*/
while (num_req_outstanding < VIOMAXREQ) {
- req = elv_next_request(q);
+ req = blk_fetch_request(q);
if (req == NULL)
return;
- /* dequeue the current request from the queue */
- blkdev_dequeue_request(req);
/* check that request contains a valid command */
if (!blk_fs_request(req)) {
- viodasd_end_request(req, -EIO, req->hard_nr_sectors);
+ viodasd_end_request(req, -EIO, blk_rq_sectors(req));
continue;
}
/* Try sending the request */
if (send_request(req) != 0)
- viodasd_end_request(req, -EIO, req->hard_nr_sectors);
+ viodasd_end_request(req, -EIO, blk_rq_sectors(req));
}
}
@@ -590,7 +588,7 @@ static int viodasd_handle_read_write(struct vioblocklpevent *bevent)
err = vio_lookup_rc(viodasd_err_table, bevent->sub_result);
printk(VIOD_KERN_WARNING "read/write error %d:0x%04x (%s)\n",
event->xRc, bevent->sub_result, err->msg);
- num_sect = req->hard_nr_sectors;
+ num_sect = blk_rq_sectors(req);
}
qlock = req->q->queue_lock;
spin_lock_irqsave(qlock, irq_flags);
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 5d34764c8a87..129706857cea 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -37,6 +37,7 @@ struct virtblk_req
struct list_head list;
struct request *req;
struct virtio_blk_outhdr out_hdr;
+ struct virtio_scsi_inhdr in_hdr;
u8 status;
};
@@ -50,6 +51,7 @@ static void blk_done(struct virtqueue *vq)
spin_lock_irqsave(&vblk->lock, flags);
while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) {
int error;
+
switch (vbr->status) {
case VIRTIO_BLK_S_OK:
error = 0;
@@ -62,7 +64,13 @@ static void blk_done(struct virtqueue *vq)
break;
}
- __blk_end_request(vbr->req, error, blk_rq_bytes(vbr->req));
+ if (blk_pc_request(vbr->req)) {
+ vbr->req->resid_len = vbr->in_hdr.residual;
+ vbr->req->sense_len = vbr->in_hdr.sense_len;
+ vbr->req->errors = vbr->in_hdr.errors;
+ }
+
+ __blk_end_request_all(vbr->req, error);
list_del(&vbr->list);
mempool_free(vbr, vblk->pool);
}
@@ -74,7 +82,7 @@ static void blk_done(struct virtqueue *vq)
static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
struct request *req)
{
- unsigned long num, out, in;
+ unsigned long num, out = 0, in = 0;
struct virtblk_req *vbr;
vbr = mempool_alloc(vblk->pool, GFP_ATOMIC);
@@ -85,7 +93,7 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
vbr->req = req;
if (blk_fs_request(vbr->req)) {
vbr->out_hdr.type = 0;
- vbr->out_hdr.sector = vbr->req->sector;
+ vbr->out_hdr.sector = blk_rq_pos(vbr->req);
vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
} else if (blk_pc_request(vbr->req)) {
vbr->out_hdr.type = VIRTIO_BLK_T_SCSI_CMD;
@@ -99,18 +107,36 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
if (blk_barrier_rq(vbr->req))
vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER;
- sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr));
- num = blk_rq_map_sg(q, vbr->req, vblk->sg+1);
- sg_set_buf(&vblk->sg[num+1], &vbr->status, sizeof(vbr->status));
+ sg_set_buf(&vblk->sg[out++], &vbr->out_hdr, sizeof(vbr->out_hdr));
- if (rq_data_dir(vbr->req) == WRITE) {
- vbr->out_hdr.type |= VIRTIO_BLK_T_OUT;
- out = 1 + num;
- in = 1;
- } else {
- vbr->out_hdr.type |= VIRTIO_BLK_T_IN;
- out = 1;
- in = 1 + num;
+ /*
+ * If this is a packet command we need a couple of additional headers.
+ * Behind the normal outhdr we put a segment with the scsi command
+ * block, and before the normal inhdr we put the sense data and the
+ * inhdr with additional status information before the normal inhdr.
+ */
+ if (blk_pc_request(vbr->req))
+ sg_set_buf(&vblk->sg[out++], vbr->req->cmd, vbr->req->cmd_len);
+
+ num = blk_rq_map_sg(q, vbr->req, vblk->sg + out);
+
+ if (blk_pc_request(vbr->req)) {
+ sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, 96);
+ sg_set_buf(&vblk->sg[num + out + in++], &vbr->in_hdr,
+ sizeof(vbr->in_hdr));
+ }
+
+ sg_set_buf(&vblk->sg[num + out + in++], &vbr->status,
+ sizeof(vbr->status));
+
+ if (num) {
+ if (rq_data_dir(vbr->req) == WRITE) {
+ vbr->out_hdr.type |= VIRTIO_BLK_T_OUT;
+ out += num;
+ } else {
+ vbr->out_hdr.type |= VIRTIO_BLK_T_IN;
+ in += num;
+ }
}
if (vblk->vq->vq_ops->add_buf(vblk->vq, vblk->sg, out, in, vbr)) {
@@ -124,12 +150,11 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
static void do_virtblk_request(struct request_queue *q)
{
- struct virtio_blk *vblk = NULL;
+ struct virtio_blk *vblk = q->queuedata;
struct request *req;
unsigned int issued = 0;
- while ((req = elv_next_request(q)) != NULL) {
- vblk = req->rq_disk->private_data;
+ while ((req = blk_peek_request(q)) != NULL) {
BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
/* If this request fails, stop queue and wait for something to
@@ -138,7 +163,7 @@ static void do_virtblk_request(struct request_queue *q)
blk_stop_queue(q);
break;
}
- blkdev_dequeue_request(req);
+ blk_start_request(req);
issued++;
}
@@ -149,8 +174,16 @@ static void do_virtblk_request(struct request_queue *q)
static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
unsigned cmd, unsigned long data)
{
- return scsi_cmd_ioctl(bdev->bd_disk->queue,
- bdev->bd_disk, mode, cmd,
+ struct gendisk *disk = bdev->bd_disk;
+ struct virtio_blk *vblk = disk->private_data;
+
+ /*
+ * Only allow the generic SCSI ioctls if the host can support it.
+ */
+ if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI))
+ return -ENOIOCTLCMD;
+
+ return scsi_cmd_ioctl(disk->queue, disk, mode, cmd,
(void __user *)data);
}
@@ -224,7 +257,7 @@ static int virtblk_probe(struct virtio_device *vdev)
sg_init_table(vblk->sg, vblk->sg_elems);
/* We expect one virtqueue, for output. */
- vblk->vq = vdev->config->find_vq(vdev, 0, blk_done);
+ vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests");
if (IS_ERR(vblk->vq)) {
err = PTR_ERR(vblk->vq);
goto out_free_vblk;
@@ -249,6 +282,7 @@ static int virtblk_probe(struct virtio_device *vdev)
goto out_put_disk;
}
+ vblk->disk->queue->queuedata = vblk;
queue_flag_set_unlocked(QUEUE_FLAG_VIRT, vblk->disk->queue);
if (index < 26) {
@@ -313,7 +347,7 @@ static int virtblk_probe(struct virtio_device *vdev)
offsetof(struct virtio_blk_config, blk_size),
&blk_size);
if (!err)
- blk_queue_hardsect_size(vblk->disk->queue, blk_size);
+ blk_queue_logical_block_size(vblk->disk->queue, blk_size);
add_disk(vblk->disk);
return 0;
@@ -323,7 +357,7 @@ out_put_disk:
out_mempool:
mempool_destroy(vblk->pool);
out_free_vq:
- vdev->config->del_vq(vblk->vq);
+ vdev->config->del_vqs(vdev);
out_free_vblk:
kfree(vblk);
out:
@@ -344,7 +378,7 @@ static void virtblk_remove(struct virtio_device *vdev)
blk_cleanup_queue(vblk->disk->queue);
put_disk(vblk->disk);
mempool_destroy(vblk->pool);
- vdev->config->del_vq(vblk->vq);
+ vdev->config->del_vqs(vdev);
kfree(vblk);
}
@@ -356,6 +390,7 @@ static struct virtio_device_id id_table[] = {
static unsigned int features[] = {
VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
+ VIRTIO_BLK_F_SCSI,
};
static struct virtio_driver virtio_blk = {
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index 64b496fce98b..ce2429219925 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -305,30 +305,25 @@ static void do_xd_request (struct request_queue * q)
if (xdc_busy)
return;
- while ((req = elv_next_request(q)) != NULL) {
- unsigned block = req->sector;
- unsigned count = req->nr_sectors;
- int rw = rq_data_dir(req);
+ req = blk_fetch_request(q);
+ while (req) {
+ unsigned block = blk_rq_pos(req);
+ unsigned count = blk_rq_cur_sectors(req);
XD_INFO *disk = req->rq_disk->private_data;
- int res = 0;
+ int res = -EIO;
int retry;
- if (!blk_fs_request(req)) {
- end_request(req, 0);
- continue;
- }
- if (block + count > get_capacity(req->rq_disk)) {
- end_request(req, 0);
- continue;
- }
- if (rw != READ && rw != WRITE) {
- printk("do_xd_request: unknown request\n");
- end_request(req, 0);
- continue;
- }
+ if (!blk_fs_request(req))
+ goto done;
+ if (block + count > get_capacity(req->rq_disk))
+ goto done;
for (retry = 0; (retry < XD_RETRIES) && !res; retry++)
- res = xd_readwrite(rw, disk, req->buffer, block, count);
- end_request(req, res); /* wrap up, 0 = fail, 1 = success */
+ res = xd_readwrite(rq_data_dir(req), disk, req->buffer,
+ block, count);
+ done:
+ /* wrap up, 0 = success, -errno = fail */
+ if (!__blk_end_request_cur(req, res))
+ req = blk_fetch_request(q);
}
}
@@ -418,7 +413,7 @@ static int xd_readwrite (u_char operation,XD_INFO *p,char *buffer,u_int block,u_
printk("xd%c: %s timeout, recalibrating drive\n",'a'+drive,(operation == READ ? "read" : "write"));
xd_recalibrate(drive);
spin_lock_irq(&xd_lock);
- return (0);
+ return -EIO;
case 2:
if (sense[0] & 0x30) {
printk("xd%c: %s - ",'a'+drive,(operation == READ ? "reading" : "writing"));
@@ -439,7 +434,7 @@ static int xd_readwrite (u_char operation,XD_INFO *p,char *buffer,u_int block,u_
else
printk(" - no valid disk address\n");
spin_lock_irq(&xd_lock);
- return (0);
+ return -EIO;
}
if (xd_dma_buffer)
for (i=0; i < (temp * 0x200); i++)
@@ -448,7 +443,7 @@ static int xd_readwrite (u_char operation,XD_INFO *p,char *buffer,u_int block,u_
count -= temp, buffer += temp * 0x200, block += temp;
}
spin_lock_irq(&xd_lock);
- return (1);
+ return 0;
}
/* xd_recalibrate: recalibrate a given drive and reset controller if necessary */
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index a6cbf7b808e6..e53284767f7c 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -122,7 +122,7 @@ static DEFINE_SPINLOCK(blkif_io_lock);
static int get_id_from_freelist(struct blkfront_info *info)
{
unsigned long free = info->shadow_free;
- BUG_ON(free > BLK_RING_SIZE);
+ BUG_ON(free >= BLK_RING_SIZE);
info->shadow_free = info->shadow[free].req.id;
info->shadow[free].req.id = 0x0fffffee; /* debug */
return free;
@@ -231,7 +231,7 @@ static int blkif_queue_request(struct request *req)
info->shadow[id].request = (unsigned long)req;
ring_req->id = id;
- ring_req->sector_number = (blkif_sector_t)req->sector;
+ ring_req->sector_number = (blkif_sector_t)blk_rq_pos(req);
ring_req->handle = info->handle;
ring_req->operation = rq_data_dir(req) ?
@@ -299,25 +299,25 @@ static void do_blkif_request(struct request_queue *rq)
queued = 0;
- while ((req = elv_next_request(rq)) != NULL) {
+ while ((req = blk_peek_request(rq)) != NULL) {
info = req->rq_disk->private_data;
- if (!blk_fs_request(req)) {
- end_request(req, 0);
- continue;
- }
if (RING_FULL(&info->ring))
goto wait;
- pr_debug("do_blk_req %p: cmd %p, sec %lx, "
- "(%u/%li) buffer:%p [%s]\n",
- req, req->cmd, (unsigned long)req->sector,
- req->current_nr_sectors,
- req->nr_sectors, req->buffer,
- rq_data_dir(req) ? "write" : "read");
+ blk_start_request(req);
+ if (!blk_fs_request(req)) {
+ __blk_end_request_all(req, -EIO);
+ continue;
+ }
+
+ pr_debug("do_blk_req %p: cmd %p, sec %lx, "
+ "(%u/%u) buffer:%p [%s]\n",
+ req, req->cmd, (unsigned long)blk_rq_pos(req),
+ blk_rq_cur_sectors(req), blk_rq_sectors(req),
+ req->buffer, rq_data_dir(req) ? "write" : "read");
- blkdev_dequeue_request(req);
if (blkif_queue_request(req)) {
blk_requeue_request(rq, req);
wait:
@@ -344,7 +344,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq);
/* Hard sector size and max sectors impersonate the equiv. hardware. */
- blk_queue_hardsect_size(rq, sector_size);
+ blk_queue_logical_block_size(rq, sector_size);
blk_queue_max_sectors(rq, 512);
/* Each segment in a request is up to an aligned page in size. */
@@ -551,7 +551,6 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
for (i = info->ring.rsp_cons; i != rp; i++) {
unsigned long id;
- int ret;
bret = RING_GET_RESPONSE(&info->ring, i);
id = bret->id;
@@ -578,8 +577,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
dev_dbg(&info->xbdev->dev, "Bad return from blkdev data "
"request: %x\n", bret->status);
- ret = __blk_end_request(req, error, blk_rq_bytes(req));
- BUG_ON(ret);
+ __blk_end_request_all(req, error);
break;
default:
BUG();
@@ -755,12 +753,12 @@ static int blkfront_probe(struct xenbus_device *dev,
/* Front end dir is a number, which is used as the id. */
info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0);
- dev->dev.driver_data = info;
+ dev_set_drvdata(&dev->dev, info);
err = talk_to_backend(dev, info);
if (err) {
kfree(info);
- dev->dev.driver_data = NULL;
+ dev_set_drvdata(&dev->dev, NULL);
return err;
}
@@ -845,7 +843,7 @@ static int blkif_recover(struct blkfront_info *info)
*/
static int blkfront_resume(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->dev.driver_data;
+ struct blkfront_info *info = dev_get_drvdata(&dev->dev);
int err;
dev_dbg(&dev->dev, "blkfront_resume: %s\n", dev->nodename);
@@ -924,7 +922,7 @@ static void blkfront_connect(struct blkfront_info *info)
*/
static void blkfront_closing(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->dev.driver_data;
+ struct blkfront_info *info = dev_get_drvdata(&dev->dev);
unsigned long flags;
dev_dbg(&dev->dev, "blkfront_closing: %s removed\n", dev->nodename);
@@ -959,7 +957,7 @@ static void blkfront_closing(struct xenbus_device *dev)
static void backend_changed(struct xenbus_device *dev,
enum xenbus_state backend_state)
{
- struct blkfront_info *info = dev->dev.driver_data;
+ struct blkfront_info *info = dev_get_drvdata(&dev->dev);
struct block_device *bd;
dev_dbg(&dev->dev, "blkfront:backend_changed.\n");
@@ -999,7 +997,7 @@ static void backend_changed(struct xenbus_device *dev,
static int blkfront_remove(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->dev.driver_data;
+ struct blkfront_info *info = dev_get_drvdata(&dev->dev);
dev_dbg(&dev->dev, "blkfront_remove: %s removed\n", dev->nodename);
@@ -1012,7 +1010,7 @@ static int blkfront_remove(struct xenbus_device *dev)
static int blkfront_is_ready(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->dev.driver_data;
+ struct blkfront_info *info = dev_get_drvdata(&dev->dev);
return info->is_ready;
}
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 4aecf5dc6a93..f08491a3a813 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -463,10 +463,11 @@ struct request *ace_get_next_request(struct request_queue * q)
{
struct request *req;
- while ((req = elv_next_request(q)) != NULL) {
+ while ((req = blk_peek_request(q)) != NULL) {
if (blk_fs_request(req))
break;
- end_request(req, 0);
+ blk_start_request(req);
+ __blk_end_request_all(req, -EIO);
}
return req;
}
@@ -492,9 +493,13 @@ static void ace_fsm_dostate(struct ace_device *ace)
set_capacity(ace->gd, 0);
dev_info(ace->dev, "No CF in slot\n");
- /* Drop all pending requests */
- while ((req = elv_next_request(ace->queue)) != NULL)
- end_request(req, 0);
+ /* Drop all in-flight and pending requests */
+ if (ace->req) {
+ __blk_end_request_all(ace->req, -EIO);
+ ace->req = NULL;
+ }
+ while ((req = blk_fetch_request(ace->queue)) != NULL)
+ __blk_end_request_all(req, -EIO);
/* Drop back to IDLE state and notify waiters */
ace->fsm_state = ACE_FSM_STATE_IDLE;
@@ -642,19 +647,21 @@ static void ace_fsm_dostate(struct ace_device *ace)
ace->fsm_state = ACE_FSM_STATE_IDLE;
break;
}
+ blk_start_request(req);
/* Okay, it's a data request, set it up for transfer */
dev_dbg(ace->dev,
- "request: sec=%llx hcnt=%lx, ccnt=%x, dir=%i\n",
- (unsigned long long) req->sector, req->hard_nr_sectors,
- req->current_nr_sectors, rq_data_dir(req));
+ "request: sec=%llx hcnt=%x, ccnt=%x, dir=%i\n",
+ (unsigned long long)blk_rq_pos(req),
+ blk_rq_sectors(req), blk_rq_cur_sectors(req),
+ rq_data_dir(req));
ace->req = req;
ace->data_ptr = req->buffer;
- ace->data_count = req->current_nr_sectors * ACE_BUF_PER_SECTOR;
- ace_out32(ace, ACE_MPULBA, req->sector & 0x0FFFFFFF);
+ ace->data_count = blk_rq_cur_sectors(req) * ACE_BUF_PER_SECTOR;
+ ace_out32(ace, ACE_MPULBA, blk_rq_pos(req) & 0x0FFFFFFF);
- count = req->hard_nr_sectors;
+ count = blk_rq_sectors(req);
if (rq_data_dir(req)) {
/* Kick off write request */
dev_dbg(ace->dev, "write data\n");
@@ -688,7 +695,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
dev_dbg(ace->dev,
"CFBSY set; t=%i iter=%i c=%i dc=%i irq=%i\n",
ace->fsm_task, ace->fsm_iter_num,
- ace->req->current_nr_sectors * 16,
+ blk_rq_cur_sectors(ace->req) * 16,
ace->data_count, ace->in_irq);
ace_fsm_yield(ace); /* need to poll CFBSY bit */
break;
@@ -697,7 +704,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
dev_dbg(ace->dev,
"DATABUF not set; t=%i iter=%i c=%i dc=%i irq=%i\n",
ace->fsm_task, ace->fsm_iter_num,
- ace->req->current_nr_sectors * 16,
+ blk_rq_cur_sectors(ace->req) * 16,
ace->data_count, ace->in_irq);
ace_fsm_yieldirq(ace);
break;
@@ -717,14 +724,13 @@ static void ace_fsm_dostate(struct ace_device *ace)
}
/* bio finished; is there another one? */
- if (__blk_end_request(ace->req, 0,
- blk_rq_cur_bytes(ace->req))) {
- /* dev_dbg(ace->dev, "next block; h=%li c=%i\n",
- * ace->req->hard_nr_sectors,
- * ace->req->current_nr_sectors);
+ if (__blk_end_request_cur(ace->req, 0)) {
+ /* dev_dbg(ace->dev, "next block; h=%u c=%u\n",
+ * blk_rq_sectors(ace->req),
+ * blk_rq_cur_sectors(ace->req));
*/
ace->data_ptr = ace->req->buffer;
- ace->data_count = ace->req->current_nr_sectors * 16;
+ ace->data_count = blk_rq_cur_sectors(ace->req) * 16;
ace_fsm_yieldirq(ace);
break;
}
@@ -978,7 +984,7 @@ static int __devinit ace_setup(struct ace_device *ace)
ace->queue = blk_init_queue(ace_request, &ace->lock);
if (ace->queue == NULL)
goto err_blk_initq;
- blk_queue_hardsect_size(ace->queue, 512);
+ blk_queue_logical_block_size(ace->queue, 512);
/*
* Allocate and initialize GD structure
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 80754cdd3119..4575171e5beb 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -70,15 +70,18 @@ static struct gendisk *z2ram_gendisk;
static void do_z2_request(struct request_queue *q)
{
struct request *req;
- while ((req = elv_next_request(q)) != NULL) {
- unsigned long start = req->sector << 9;
- unsigned long len = req->current_nr_sectors << 9;
+
+ req = blk_fetch_request(q);
+ while (req) {
+ unsigned long start = blk_rq_pos(req) << 9;
+ unsigned long len = blk_rq_cur_bytes(req);
+ int err = 0;
if (start + len > z2ram_size) {
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",
- req->sector, req->current_nr_sectors);
- end_request(req, 0);
- continue;
+ blk_rq_pos(req), blk_rq_cur_sectors(req));
+ err = -EIO;
+ goto done;
}
while (len) {
unsigned long addr = start & Z2RAM_CHUNKMASK;
@@ -93,7 +96,9 @@ static void do_z2_request(struct request_queue *q)
start += size;
len -= size;
}
- end_request(req, 1);
+ done:
+ if (!__blk_end_request_cur(req, err))
+ req = blk_fetch_request(q);
}
}
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index cceace61ef28..71d1b9bab70b 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2101,8 +2101,8 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
nr = nframes;
if (cdi->cdda_method == CDDA_BPC_SINGLE)
nr = 1;
- if (nr * CD_FRAMESIZE_RAW > (q->max_sectors << 9))
- nr = (q->max_sectors << 9) / CD_FRAMESIZE_RAW;
+ if (nr * CD_FRAMESIZE_RAW > (queue_max_sectors(q) << 9))
+ nr = (queue_max_sectors(q) << 9) / CD_FRAMESIZE_RAW;
len = nr * CD_FRAMESIZE_RAW;
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 2eecb779437b..b5621f27c4be 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -584,8 +584,8 @@ static void gdrom_readdisk_dma(struct work_struct *work)
list_for_each_safe(elem, next, &gdrom_deferred) {
req = list_entry(elem, struct request, queuelist);
spin_unlock(&gdrom_lock);
- block = req->sector/GD_TO_BLK + GD_SESSION_OFFSET;
- block_cnt = req->nr_sectors/GD_TO_BLK;
+ block = blk_rq_pos(req)/GD_TO_BLK + GD_SESSION_OFFSET;
+ block_cnt = blk_rq_sectors(req)/GD_TO_BLK;
ctrl_outl(PHYSADDR(req->buffer), GDROM_DMA_STARTADDR_REG);
ctrl_outl(block_cnt * GDROM_HARD_SECTOR, GDROM_DMA_LENGTH_REG);
ctrl_outl(1, GDROM_DMA_DIRECTION_REG);
@@ -632,39 +632,35 @@ static void gdrom_readdisk_dma(struct work_struct *work)
* before handling ending the request */
spin_lock(&gdrom_lock);
list_del_init(&req->queuelist);
- __blk_end_request(req, err, blk_rq_bytes(req));
+ __blk_end_request_all(req, err);
}
spin_unlock(&gdrom_lock);
kfree(read_command);
}
-static void gdrom_request_handler_dma(struct request *req)
-{
- /* dequeue, add to list of deferred work
- * and then schedule workqueue */
- blkdev_dequeue_request(req);
- list_add_tail(&req->queuelist, &gdrom_deferred);
- schedule_work(&work);
-}
-
static void gdrom_request(struct request_queue *rq)
{
struct request *req;
- while ((req = elv_next_request(rq)) != NULL) {
+ while ((req = blk_fetch_request(rq)) != NULL) {
if (!blk_fs_request(req)) {
printk(KERN_DEBUG "GDROM: Non-fs request ignored\n");
- end_request(req, 0);
+ __blk_end_request_all(req, -EIO);
+ continue;
}
if (rq_data_dir(req) != READ) {
printk(KERN_NOTICE "GDROM: Read only device -");
printk(" write request ignored\n");
- end_request(req, 0);
+ __blk_end_request_all(req, -EIO);
+ continue;
}
- if (req->nr_sectors)
- gdrom_request_handler_dma(req);
- else
- end_request(req, 0);
+
+ /*
+ * Add to list of deferred work and then schedule
+ * workqueue.
+ */
+ list_add_tail(&req->queuelist, &gdrom_deferred);
+ schedule_work(&work);
}
}
@@ -743,7 +739,7 @@ static void __devinit probe_gdrom_setupdisk(void)
static int __devinit probe_gdrom_setupqueue(void)
{
- blk_queue_hardsect_size(gd.gdrom_rq, GDROM_HARD_SECTOR);
+ blk_queue_logical_block_size(gd.gdrom_rq, GDROM_HARD_SECTOR);
/* using DMA so memory will need to be contiguous */
blk_queue_max_hw_segments(gd.gdrom_rq, 1);
/* set a large max size to get most from DMA */
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 9b1624e0ddeb..0fff646cc2f0 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -282,7 +282,7 @@ static int send_request(struct request *req)
viopath_targetinst(viopath_hostLp),
(u64)req, VIOVERSION << 16,
((u64)DEVICE_NR(diskinfo) << 48) | dmaaddr,
- (u64)req->sector * 512, len, 0);
+ (u64)blk_rq_pos(req) * 512, len, 0);
if (hvrc != HvLpEvent_Rc_Good) {
printk(VIOCD_KERN_WARNING "hv error on op %d\n", (int)hvrc);
return -1;
@@ -291,36 +291,19 @@ static int send_request(struct request *req)
return 0;
}
-static void viocd_end_request(struct request *req, int error)
-{
- int nsectors = req->hard_nr_sectors;
-
- /*
- * Make sure it's fully ended, and ensure that we process
- * at least one sector.
- */
- if (blk_pc_request(req))
- nsectors = (req->data_len + 511) >> 9;
- if (!nsectors)
- nsectors = 1;
-
- if (__blk_end_request(req, error, nsectors << 9))
- BUG();
-}
-
static int rwreq;
static void do_viocd_request(struct request_queue *q)
{
struct request *req;
- while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
+ while ((rwreq == 0) && ((req = blk_fetch_request(q)) != NULL)) {
if (!blk_fs_request(req))
- viocd_end_request(req, -EIO);
+ __blk_end_request_all(req, -EIO);
else if (send_request(req) < 0) {
printk(VIOCD_KERN_WARNING
"unable to send message to OS/400!");
- viocd_end_request(req, -EIO);
+ __blk_end_request_all(req, -EIO);
} else
rwreq++;
}
@@ -486,8 +469,8 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
case viocdopen:
if (event->xRc == 0) {
di = &viocd_diskinfo[bevent->disk];
- blk_queue_hardsect_size(di->viocd_disk->queue,
- bevent->block_size);
+ blk_queue_logical_block_size(di->viocd_disk->queue,
+ bevent->block_size);
set_capacity(di->viocd_disk,
bevent->media_size *
bevent->block_size / 512);
@@ -531,9 +514,9 @@ return_complete:
"with rc %d:0x%04X: %s\n",
req, event->xRc,
bevent->sub_result, err->msg);
- viocd_end_request(req, -EIO);
+ __blk_end_request_all(req, -EIO);
} else
- viocd_end_request(req, 0);
+ __blk_end_request_all(req, 0);
/* restart handling of incoming requests */
spin_unlock_irqrestore(&viocd_reqlock, flags);
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 183ac3fe44fb..9c7e2343c399 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -518,8 +518,9 @@ zx1_gart_probe (acpi_handle obj, u32 depth, void *context, void **ret)
if (hp_zx1_setup(sba_hpa + HP_ZX1_IOC_OFFSET, lba_hpa))
return AE_OK;
- printk(KERN_INFO PFX "Detected HP ZX1 %s AGP chipset (ioc=%lx, lba=%lx)\n",
- (char *) context, sba_hpa + HP_ZX1_IOC_OFFSET, lba_hpa);
+ printk(KERN_INFO PFX "Detected HP ZX1 %s AGP chipset "
+ "(ioc=%llx, lba=%llx)\n", (char *)context,
+ sba_hpa + HP_ZX1_IOC_OFFSET, lba_hpa);
hp_zx1_gart_found = 1;
return AE_CTRL_TERMINATE; /* we only support one bridge; quit looking */
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index fd3ebd1be570..72429b6b2fa8 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -779,7 +779,7 @@ static void change_speed(struct async_struct *info,
info->IER |= UART_IER_MSI;
}
/* TBD:
- * Does clearing IER_MSI imply that we should disbale the VBL interrupt ?
+ * Does clearing IER_MSI imply that we should disable the VBL interrupt ?
*/
/*
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 1fdb9f657d8f..456019051742 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -604,7 +604,6 @@
#define NR_PORTS 256
-#define ZE_V1_NPORTS 64
#define ZO_V1 0
#define ZO_V2 1
#define ZE_V1 2
@@ -663,18 +662,6 @@
static void cy_throttle(struct tty_struct *tty);
static void cy_send_xchar(struct tty_struct *tty, char ch);
-#define IS_CYC_Z(card) ((card).num_chips == (unsigned int)-1)
-
-#define Z_FPGA_CHECK(card) \
- ((readl(&((struct RUNTIME_9060 __iomem *) \
- ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
-
-#define ISZLOADED(card) (((ZO_V1 == readl(&((struct RUNTIME_9060 __iomem *) \
- ((card).ctl_addr))->mail_box_0)) || \
- Z_FPGA_CHECK(card)) && \
- (ZFIRM_ID == readl(&((struct FIRM_ID __iomem *) \
- ((card).base_addr+ID_ADDRESS))->signature)))
-
#ifndef SERIAL_XMIT_SIZE
#define SERIAL_XMIT_SIZE (min(PAGE_SIZE, 4096))
#endif
@@ -687,8 +674,6 @@ static void cy_send_xchar(struct tty_struct *tty, char ch);
#define DRIVER_VERSION 0x02010203
#define RAM_SIZE 0x80000
-#define Z_FPGA_LOADED(X) ((readl(&(X)->init_ctrl) & (1<<17)) != 0)
-
enum zblock_type {
ZBLOCK_PRG = 0,
ZBLOCK_FPGA = 1
@@ -883,6 +868,29 @@ static void cyz_rx_restart(unsigned long);
static struct timer_list cyz_rx_full_timer[NR_PORTS];
#endif /* CONFIG_CYZ_INTR */
+static inline bool cy_is_Z(struct cyclades_card *card)
+{
+ return card->num_chips == (unsigned int)-1;
+}
+
+static inline bool __cyz_fpga_loaded(struct RUNTIME_9060 __iomem *ctl_addr)
+{
+ return readl(&ctl_addr->init_ctrl) & (1 << 17);
+}
+
+static inline bool cyz_fpga_loaded(struct cyclades_card *card)
+{
+ return __cyz_fpga_loaded(card->ctl_addr.p9060);
+}
+
+static inline bool cyz_is_loaded(struct cyclades_card *card)
+{
+ struct FIRM_ID __iomem *fw_id = card->base_addr + ID_ADDRESS;
+
+ return (card->hw_ver == ZO_V1 || cyz_fpga_loaded(card)) &&
+ readl(&fw_id->signature) == ZFIRM_ID;
+}
+
static inline int serial_paranoia_check(struct cyclades_port *info,
char *name, const char *routine)
{
@@ -1395,19 +1403,15 @@ cyz_fetch_msg(struct cyclades_card *cinfo,
unsigned long loc_doorbell;
firm_id = cinfo->base_addr + ID_ADDRESS;
- if (!ISZLOADED(*cinfo))
- return -1;
zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl;
- loc_doorbell = readl(&((struct RUNTIME_9060 __iomem *)
- (cinfo->ctl_addr))->loc_doorbell);
+ loc_doorbell = readl(&cinfo->ctl_addr.p9060->loc_doorbell);
if (loc_doorbell) {
*cmd = (char)(0xff & loc_doorbell);
*channel = readl(&board_ctrl->fwcmd_channel);
*param = (__u32) readl(&board_ctrl->fwcmd_param);
- cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
- loc_doorbell, 0xffffffff);
+ cy_writel(&cinfo->ctl_addr.p9060->loc_doorbell, 0xffffffff);
return 1;
}
return 0;
@@ -1424,15 +1428,14 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
unsigned int index;
firm_id = cinfo->base_addr + ID_ADDRESS;
- if (!ISZLOADED(*cinfo))
+ if (!cyz_is_loaded(cinfo))
return -1;
zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl;
index = 0;
- pci_doorbell =
- &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
+ pci_doorbell = &cinfo->ctl_addr.p9060->pci_doorbell;
while ((readl(pci_doorbell) & 0xff) != 0) {
if (index++ == 1000)
return (int)(readl(pci_doorbell) & 0xff);
@@ -1624,10 +1627,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
static struct BOARD_CTRL __iomem *board_ctrl;
static struct CH_CTRL __iomem *ch_ctrl;
static struct BUF_CTRL __iomem *buf_ctrl;
- __u32 channel;
+ __u32 channel, param, fw_ver;
__u8 cmd;
- __u32 param;
- __u32 hw_ver, fw_ver;
int special_count;
int delta_count;
@@ -1635,8 +1636,6 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl;
fw_ver = readl(&board_ctrl->fw_version);
- hw_ver = readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
- mail_box_0);
while (cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) {
special_count = 0;
@@ -1737,15 +1736,7 @@ static irqreturn_t cyz_interrupt(int irq, void *dev_id)
{
struct cyclades_card *cinfo = dev_id;
- if (unlikely(cinfo == NULL)) {
-#ifdef CY_DEBUG_INTERRUPTS
- printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",
- irq);
-#endif
- return IRQ_NONE; /* spurious interrupt */
- }
-
- if (unlikely(!ISZLOADED(*cinfo))) {
+ if (unlikely(!cyz_is_loaded(cinfo))) {
#ifdef CY_DEBUG_INTERRUPTS
printk(KERN_DEBUG "cyz_interrupt: board not yet loaded "
"(IRQ%d).\n", irq);
@@ -1785,7 +1776,6 @@ static void cyz_poll(unsigned long arg)
struct tty_struct *tty;
struct FIRM_ID __iomem *firm_id;
struct ZFW_CTRL __iomem *zfw_ctrl;
- struct BOARD_CTRL __iomem *board_ctrl;
struct BUF_CTRL __iomem *buf_ctrl;
unsigned long expires = jiffies + HZ;
unsigned int port, card;
@@ -1793,19 +1783,17 @@ static void cyz_poll(unsigned long arg)
for (card = 0; card < NR_CARDS; card++) {
cinfo = &cy_card[card];
- if (!IS_CYC_Z(*cinfo))
+ if (!cy_is_Z(cinfo))
continue;
- if (!ISZLOADED(*cinfo))
+ if (!cyz_is_loaded(cinfo))
continue;
firm_id = cinfo->base_addr + ID_ADDRESS;
zfw_ctrl = cinfo->base_addr +
(readl(&firm_id->zfwctrl_addr) & 0xfffff);
- board_ctrl = &(zfw_ctrl->board_ctrl);
/* Skip first polling cycle to avoid racing conditions with the FW */
if (!cinfo->intr_enabled) {
- cinfo->nports = (int)readl(&board_ctrl->n_channel);
cinfo->intr_enabled = 1;
continue;
}
@@ -1874,7 +1862,7 @@ static int startup(struct cyclades_port *info)
set_line_char(info);
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -1931,7 +1919,7 @@ static int startup(struct cyclades_port *info)
base_addr = card->base_addr;
firm_id = base_addr + ID_ADDRESS;
- if (!ISZLOADED(*card))
+ if (!cyz_is_loaded(card))
return -ENODEV;
zfw_ctrl = card->base_addr +
@@ -2026,7 +2014,7 @@ static void start_xmit(struct cyclades_port *info)
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -2070,7 +2058,7 @@ static void shutdown(struct cyclades_port *info)
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -2126,7 +2114,7 @@ static void shutdown(struct cyclades_port *info)
#endif
firm_id = base_addr + ID_ADDRESS;
- if (!ISZLOADED(*card))
+ if (!cyz_is_loaded(card))
return;
zfw_ctrl = card->base_addr +
@@ -2233,7 +2221,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
#endif
info->port.blocked_open++;
- if (!IS_CYC_Z(*cinfo)) {
+ if (!cy_is_Z(cinfo)) {
chip = channel >> 2;
channel &= 0x03;
index = cinfo->bus_index;
@@ -2296,7 +2284,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
base_addr = cinfo->base_addr;
firm_id = base_addr + ID_ADDRESS;
- if (!ISZLOADED(*cinfo)) {
+ if (!cyz_is_loaded(cinfo)) {
__set_current_state(TASK_RUNNING);
remove_wait_queue(&info->port.open_wait, &wait);
return -EINVAL;
@@ -2397,16 +2385,14 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
treat it as absent from the system. This
will make the user pay attention.
*/
- if (IS_CYC_Z(*info->card)) {
+ if (cy_is_Z(info->card)) {
struct cyclades_card *cinfo = info->card;
struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS;
- if (!ISZLOADED(*cinfo)) {
- if (((ZE_V1 == readl(&((struct RUNTIME_9060 __iomem *)
- (cinfo->ctl_addr))->mail_box_0)) &&
- Z_FPGA_CHECK(*cinfo)) &&
- (ZFIRM_HLT == readl(
- &firm_id->signature))) {
+ if (!cyz_is_loaded(cinfo)) {
+ if (cinfo->hw_ver == ZE_V1 && cyz_fpga_loaded(cinfo) &&
+ readl(&firm_id->signature) ==
+ ZFIRM_HLT) {
printk(KERN_ERR "cyc:Cyclades-Z Error: you "
"need an external power supply for "
"this number of ports.\nFirmware "
@@ -2423,18 +2409,13 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
interrupts should be enabled as soon as the first open
happens to one of its ports. */
if (!cinfo->intr_enabled) {
- struct ZFW_CTRL __iomem *zfw_ctrl;
- struct BOARD_CTRL __iomem *board_ctrl;
-
- zfw_ctrl = cinfo->base_addr +
- (readl(&firm_id->zfwctrl_addr) &
- 0xfffff);
-
- board_ctrl = &zfw_ctrl->board_ctrl;
+ u16 intr;
/* Enable interrupts on the PLX chip */
- cy_writew(cinfo->ctl_addr + 0x68,
- readw(cinfo->ctl_addr + 0x68) | 0x0900);
+ intr = readw(&cinfo->ctl_addr.p9060->
+ intr_ctrl_stat) | 0x0900;
+ cy_writew(&cinfo->ctl_addr.p9060->
+ intr_ctrl_stat, intr);
/* Enable interrupts on the FW */
retval = cyz_issue_cmd(cinfo, 0,
C_CM_IRQ_ENBL, 0L);
@@ -2442,8 +2423,6 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
printk(KERN_ERR "cyc:IRQ enable retval "
"was %x\n", retval);
}
- cinfo->nports =
- (int)readl(&board_ctrl->n_channel);
cinfo->intr_enabled = 1;
}
}
@@ -2556,7 +2535,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
#endif
card = info->card;
channel = (info->line) - (card->first_line);
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -2601,7 +2580,7 @@ static void cy_flush_buffer(struct tty_struct *tty)
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
spin_unlock_irqrestore(&card->card_lock, flags);
- if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board
+ if (cy_is_Z(card)) { /* If it is a Z card, flush the on-board
buffers as well */
spin_lock_irqsave(&card->card_lock, flags);
retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L);
@@ -2682,7 +2661,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
spin_lock_irqsave(&card->card_lock, flags);
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
int channel = info->line - card->first_line;
int index = card->bus_index;
void __iomem *base_addr = card->base_addr +
@@ -2902,7 +2881,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
channel = (info->line) - (card->first_line);
#ifdef Z_EXT_CHARS_IN_BUFFER
- if (!IS_CYC_Z(cy_card[card])) {
+ if (!cy_is_Z(card)) {
#endif /* Z_EXT_CHARS_IN_BUFFER */
#ifdef CY_DEBUG_IO
printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n",
@@ -2984,7 +2963,6 @@ static void set_line_char(struct cyclades_port *info)
void __iomem *base_addr;
int chip, channel, index;
unsigned cflag, iflag;
- unsigned short chip_number;
int baud, baud_rate = 0;
int i;
@@ -3013,9 +2991,8 @@ static void set_line_char(struct cyclades_port *info)
card = info->card;
channel = info->line - card->first_line;
- chip_number = channel / 4;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
index = card->bus_index;
@@ -3233,21 +3210,17 @@ static void set_line_char(struct cyclades_port *info)
} else {
struct FIRM_ID __iomem *firm_id;
struct ZFW_CTRL __iomem *zfw_ctrl;
- struct BOARD_CTRL __iomem *board_ctrl;
struct CH_CTRL __iomem *ch_ctrl;
- struct BUF_CTRL __iomem *buf_ctrl;
__u32 sw_flow;
int retval;
firm_id = card->base_addr + ID_ADDRESS;
- if (!ISZLOADED(*card))
+ if (!cyz_is_loaded(card))
return;
zfw_ctrl = card->base_addr +
(readl(&firm_id->zfwctrl_addr) & 0xfffff);
- board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
- buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
/* baud rate */
baud = tty_get_baud_rate(info->port.tty);
@@ -3457,7 +3430,7 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
card = info->card;
channel = (info->line) - (card->first_line);
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -3497,7 +3470,7 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -3523,7 +3496,7 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
} else {
base_addr = card->base_addr;
firm_id = card->base_addr + ID_ADDRESS;
- if (ISZLOADED(*card)) {
+ if (cyz_is_loaded(card)) {
zfw_ctrl = card->base_addr +
(readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl;
@@ -3566,7 +3539,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
card = info->card;
channel = (info->line) - (card->first_line);
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -3641,7 +3614,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
base_addr = card->base_addr;
firm_id = card->base_addr + ID_ADDRESS;
- if (ISZLOADED(*card)) {
+ if (cyz_is_loaded(card)) {
zfw_ctrl = card->base_addr +
(readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl;
@@ -3713,7 +3686,7 @@ static int cy_break(struct tty_struct *tty, int break_state)
card = info->card;
spin_lock_irqsave(&card->card_lock, flags);
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
/* Let the transmit ISR take care of this (since it
requires stuffing characters into the output stream).
*/
@@ -3782,7 +3755,7 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -3810,7 +3783,7 @@ static int get_threshold(struct cyclades_port *info,
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -3844,7 +3817,7 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -3867,7 +3840,7 @@ static int get_timeout(struct cyclades_port *info,
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -4121,7 +4094,7 @@ static void cy_send_xchar(struct tty_struct *tty, char ch)
card = info->card;
channel = info->line - card->first_line;
- if (IS_CYC_Z(*card)) {
+ if (cy_is_Z(card)) {
if (ch == STOP_CHAR(tty))
cyz_issue_cmd(card, channel, C_CM_SENDXOFF, 0L);
else if (ch == START_CHAR(tty))
@@ -4154,7 +4127,7 @@ static void cy_throttle(struct tty_struct *tty)
card = info->card;
if (I_IXOFF(tty)) {
- if (!IS_CYC_Z(*card))
+ if (!cy_is_Z(card))
cy_send_xchar(tty, STOP_CHAR(tty));
else
info->throttle = 1;
@@ -4162,7 +4135,7 @@ static void cy_throttle(struct tty_struct *tty)
if (tty->termios->c_cflag & CRTSCTS) {
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -4219,7 +4192,7 @@ static void cy_unthrottle(struct tty_struct *tty)
if (tty->termios->c_cflag & CRTSCTS) {
card = info->card;
channel = info->line - card->first_line;
- if (!IS_CYC_Z(*card)) {
+ if (!cy_is_Z(card)) {
chip = channel >> 2;
channel &= 0x03;
index = card->bus_index;
@@ -4263,7 +4236,7 @@ static void cy_stop(struct tty_struct *tty)
cinfo = info->card;
channel = info->line - cinfo->first_line;
- if (!IS_CYC_Z(*cinfo)) {
+ if (!cy_is_Z(cinfo)) {
index = cinfo->bus_index;
chip = channel >> 2;
channel &= 0x03;
@@ -4296,7 +4269,7 @@ static void cy_start(struct tty_struct *tty)
cinfo = info->card;
channel = info->line - cinfo->first_line;
index = cinfo->bus_index;
- if (!IS_CYC_Z(*cinfo)) {
+ if (!cy_is_Z(cinfo)) {
chip = channel >> 2;
channel &= 0x03;
base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
@@ -4347,33 +4320,20 @@ static void cy_hangup(struct tty_struct *tty)
static int __devinit cy_init_card(struct cyclades_card *cinfo)
{
struct cyclades_port *info;
- u32 uninitialized_var(mailbox);
- unsigned int nports, port;
+ unsigned int port;
unsigned short chip_number;
- int uninitialized_var(index);
spin_lock_init(&cinfo->card_lock);
+ cinfo->intr_enabled = 0;
- if (IS_CYC_Z(*cinfo)) { /* Cyclades-Z */
- mailbox = readl(&((struct RUNTIME_9060 __iomem *)
- cinfo->ctl_addr)->mail_box_0);
- nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
- cinfo->intr_enabled = 0;
- cinfo->nports = 0; /* Will be correctly set later, after
- Z FW is loaded */
- } else {
- index = cinfo->bus_index;
- nports = cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
- }
-
- cinfo->ports = kzalloc(sizeof(*cinfo->ports) * nports, GFP_KERNEL);
+ cinfo->ports = kcalloc(cinfo->nports, sizeof(*cinfo->ports),
+ GFP_KERNEL);
if (cinfo->ports == NULL) {
printk(KERN_ERR "Cyclades: cannot allocate ports\n");
- cinfo->nports = 0;
return -ENOMEM;
}
- for (port = cinfo->first_line; port < cinfo->first_line + nports;
+ for (port = cinfo->first_line; port < cinfo->first_line + cinfo->nports;
port++) {
info = &cinfo->ports[port - cinfo->first_line];
tty_port_init(&info->port);
@@ -4387,9 +4347,9 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
init_completion(&info->shutdown_wait);
init_waitqueue_head(&info->delta_msr_wait);
- if (IS_CYC_Z(*cinfo)) {
+ if (cy_is_Z(cinfo)) {
info->type = PORT_STARTECH;
- if (mailbox == ZO_V1)
+ if (cinfo->hw_ver == ZO_V1)
info->xmit_fifo_size = CYZ_FIFO_SIZE;
else
info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE;
@@ -4398,6 +4358,7 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
cyz_rx_restart, (unsigned long)info);
#endif
} else {
+ int index = cinfo->bus_index;
info->type = PORT_CIRRUS;
info->xmit_fifo_size = CyMAX_CHAR_FIFO;
info->cor1 = CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
@@ -4430,7 +4391,7 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
}
#ifndef CONFIG_CYZ_INTR
- if (IS_CYC_Z(*cinfo) && !timer_pending(&cyz_timerlist)) {
+ if (cy_is_Z(cinfo) && !timer_pending(&cyz_timerlist)) {
mod_timer(&cyz_timerlist, jiffies + 1);
#ifdef CY_PCI_DEBUG
printk(KERN_DEBUG "Cyclades-Z polling initialized\n");
@@ -4621,11 +4582,12 @@ static int __init cy_detect_isa(void)
/* set cy_card */
cy_card[j].base_addr = cy_isa_address;
- cy_card[j].ctl_addr = NULL;
+ cy_card[j].ctl_addr.p9050 = NULL;
cy_card[j].irq = (int)cy_isa_irq;
cy_card[j].bus_index = 0;
cy_card[j].first_line = cy_next_channel;
- cy_card[j].num_chips = cy_isa_nchan / 4;
+ cy_card[j].num_chips = cy_isa_nchan / CyPORTS_PER_CHIP;
+ cy_card[j].nports = cy_isa_nchan;
if (cy_init_card(&cy_card[j])) {
cy_card[j].base_addr = NULL;
free_irq(cy_isa_irq, &cy_card[j]);
@@ -4781,7 +4743,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
struct CUSTOM_REG __iomem *cust = base_addr;
struct ZFW_CTRL __iomem *pt_zfwctrl;
void __iomem *tmp;
- u32 mailbox, status;
+ u32 mailbox, status, nchan;
unsigned int i;
int retval;
@@ -4793,7 +4755,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
/* Check whether the firmware is already loaded and running. If
positive, skip this board */
- if (Z_FPGA_LOADED(ctl_addr) && readl(&fid->signature) == ZFIRM_ID) {
+ if (__cyz_fpga_loaded(ctl_addr) && readl(&fid->signature) == ZFIRM_ID) {
u32 cntval = readl(base_addr + 0x190);
udelay(100);
@@ -4812,7 +4774,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
mailbox = readl(&ctl_addr->mail_box_0);
- if (mailbox == 0 || Z_FPGA_LOADED(ctl_addr)) {
+ if (mailbox == 0 || __cyz_fpga_loaded(ctl_addr)) {
/* stops CPU and set window to beginning of RAM */
cy_writel(&ctl_addr->loc_addr_base, WIN_CREG);
cy_writel(&cust->cpu_stop, 0);
@@ -4828,7 +4790,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
base_addr);
if (retval)
goto err_rel;
- if (!Z_FPGA_LOADED(ctl_addr)) {
+ if (!__cyz_fpga_loaded(ctl_addr)) {
dev_err(&pdev->dev, "fw upload successful, but fw is "
"not loaded\n");
goto err_rel;
@@ -4887,7 +4849,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
"system before loading the new FW to the "
"Cyclades-Z.\n");
- if (Z_FPGA_LOADED(ctl_addr))
+ if (__cyz_fpga_loaded(ctl_addr))
plx_init(pdev, irq, ctl_addr);
retval = -EIO;
@@ -4902,16 +4864,16 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
base_addr + ID_ADDRESS, readl(&fid->zfwctrl_addr),
base_addr + readl(&fid->zfwctrl_addr));
+ nchan = readl(&pt_zfwctrl->board_ctrl.n_channel);
dev_info(&pdev->dev, "Cyclades-Z FW loaded: version = %x, ports = %u\n",
- readl(&pt_zfwctrl->board_ctrl.fw_version),
- readl(&pt_zfwctrl->board_ctrl.n_channel));
+ readl(&pt_zfwctrl->board_ctrl.fw_version), nchan);
- if (readl(&pt_zfwctrl->board_ctrl.n_channel) == 0) {
+ if (nchan == 0) {
dev_warn(&pdev->dev, "no Cyclades-Z ports were found. Please "
"check the connection between the Z host card and the "
"serial expanders.\n");
- if (Z_FPGA_LOADED(ctl_addr))
+ if (__cyz_fpga_loaded(ctl_addr))
plx_init(pdev, irq, ctl_addr);
dev_info(&pdev->dev, "Null number of ports detected. Board "
@@ -4932,9 +4894,7 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
cy_writel(&ctl_addr->intr_ctrl_stat, readl(&ctl_addr->intr_ctrl_stat) |
0x00030800UL);
- plx_init(pdev, irq, ctl_addr);
-
- return 0;
+ return nchan;
err_rel:
release_firmware(fw);
err:
@@ -4946,7 +4906,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
{
void __iomem *addr0 = NULL, *addr2 = NULL;
char *card_name = NULL;
- u32 mailbox;
+ u32 uninitialized_var(mailbox);
unsigned int device_id, nchan = 0, card_no, i;
unsigned char plx_ver;
int retval, irq;
@@ -5023,11 +4983,12 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
}
/* Disable interrupts on the PLX before resetting it */
- cy_writew(addr0 + 0x68, readw(addr0 + 0x68) & ~0x0900);
+ cy_writew(&ctl_addr->intr_ctrl_stat,
+ readw(&ctl_addr->intr_ctrl_stat) & ~0x0900);
plx_init(pdev, irq, addr0);
- mailbox = (u32)readl(&ctl_addr->mail_box_0);
+ mailbox = readl(&ctl_addr->mail_box_0);
addr2 = ioremap_nocache(pci_resource_start(pdev, 2),
mailbox == ZE_V1 ? CyPCI_Ze_win : CyPCI_Zwin);
@@ -5038,12 +4999,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
if (mailbox == ZE_V1) {
card_name = "Cyclades-Ze";
-
- readl(&ctl_addr->mail_box_0);
- nchan = ZE_V1_NPORTS;
} else {
card_name = "Cyclades-8Zo";
-
#ifdef CY_PCI_DEBUG
if (mailbox == ZO_V1) {
cy_writel(&ctl_addr->loc_addr_base, WIN_CREG);
@@ -5065,15 +5022,12 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
*/
if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
cy_writel(addr2 + ID_ADDRESS, 0L);
-
- retval = cyz_load_fw(pdev, addr2, addr0, irq);
- if (retval)
- goto err_unmap;
- /* This must be a Cyclades-8Zo/PCI. The extendable
- version will have a different device_id and will
- be allocated its maximum number of ports. */
- nchan = 8;
}
+
+ retval = cyz_load_fw(pdev, addr2, addr0, irq);
+ if (retval <= 0)
+ goto err_unmap;
+ nchan = retval;
}
if ((cy_next_channel + nchan) > NR_PORTS) {
@@ -5103,8 +5057,10 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
dev_err(&pdev->dev, "could not allocate IRQ\n");
goto err_unmap;
}
- cy_card[card_no].num_chips = nchan / 4;
+ cy_card[card_no].num_chips = nchan / CyPORTS_PER_CHIP;
} else {
+ cy_card[card_no].hw_ver = mailbox;
+ cy_card[card_no].num_chips = (unsigned int)-1;
#ifdef CONFIG_CYZ_INTR
/* allocate IRQ only if board has an IRQ */
if (irq != 0 && irq != 255) {
@@ -5117,15 +5073,15 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
}
}
#endif /* CONFIG_CYZ_INTR */
- cy_card[card_no].num_chips = (unsigned int)-1;
}
/* set cy_card */
cy_card[card_no].base_addr = addr2;
- cy_card[card_no].ctl_addr = addr0;
+ cy_card[card_no].ctl_addr.p9050 = addr0;
cy_card[card_no].irq = irq;
cy_card[card_no].bus_index = 1;
cy_card[card_no].first_line = cy_next_channel;
+ cy_card[card_no].nports = nchan;
retval = cy_init_card(&cy_card[card_no]);
if (retval)
goto err_null;
@@ -5138,17 +5094,20 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
plx_ver = readb(addr2 + CyPLX_VER) & 0x0f;
switch (plx_ver) {
case PLX_9050:
-
cy_writeb(addr0 + 0x4c, 0x43);
break;
case PLX_9060:
case PLX_9080:
default: /* Old boards, use PLX_9060 */
- plx_init(pdev, irq, addr0);
- cy_writew(addr0 + 0x68, readw(addr0 + 0x68) | 0x0900);
+ {
+ struct RUNTIME_9060 __iomem *ctl_addr = addr0;
+ plx_init(pdev, irq, ctl_addr);
+ cy_writew(&ctl_addr->intr_ctrl_stat,
+ readw(&ctl_addr->intr_ctrl_stat) | 0x0900);
break;
}
+ }
}
dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from "
@@ -5179,22 +5138,23 @@ static void __devexit cy_pci_remove(struct pci_dev *pdev)
unsigned int i;
/* non-Z with old PLX */
- if (!IS_CYC_Z(*cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) ==
+ if (!cy_is_Z(cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) ==
PLX_9050)
- cy_writeb(cinfo->ctl_addr + 0x4c, 0);
+ cy_writeb(cinfo->ctl_addr.p9050 + 0x4c, 0);
else
#ifndef CONFIG_CYZ_INTR
- if (!IS_CYC_Z(*cinfo))
+ if (!cy_is_Z(cinfo))
#endif
- cy_writew(cinfo->ctl_addr + 0x68,
- readw(cinfo->ctl_addr + 0x68) & ~0x0900);
+ cy_writew(&cinfo->ctl_addr.p9060->intr_ctrl_stat,
+ readw(&cinfo->ctl_addr.p9060->intr_ctrl_stat) &
+ ~0x0900);
iounmap(cinfo->base_addr);
- if (cinfo->ctl_addr)
- iounmap(cinfo->ctl_addr);
+ if (cinfo->ctl_addr.p9050)
+ iounmap(cinfo->ctl_addr.p9050);
if (cinfo->irq
#ifndef CONFIG_CYZ_INTR
- && !IS_CYC_Z(*cinfo)
+ && !cy_is_Z(cinfo)
#endif /* CONFIG_CYZ_INTR */
)
free_irq(cinfo->irq, cinfo);
@@ -5386,11 +5346,11 @@ static void __exit cy_cleanup_module(void)
/* clear interrupt */
cy_writeb(card->base_addr + Cy_ClrIntr, 0);
iounmap(card->base_addr);
- if (card->ctl_addr)
- iounmap(card->ctl_addr);
+ if (card->ctl_addr.p9050)
+ iounmap(card->ctl_addr.p9050);
if (card->irq
#ifndef CONFIG_CYZ_INTR
- && !IS_CYC_Z(*card)
+ && !cy_is_Z(card)
#endif /* CONFIG_CYZ_INTR */
)
free_irq(card->irq, card);
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index af7c13ca9493..710ee9333057 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -745,7 +745,7 @@ static int epca_carrier_raised(struct tty_port *port)
return 0;
}
-static void epca_raise_dtr_rts(struct tty_port *port)
+static void epca_dtr_rts(struct tty_port *port, int onoff)
{
}
@@ -925,7 +925,7 @@ static const struct tty_operations pc_ops = {
static const struct tty_port_operations epca_port_ops = {
.carrier_raised = epca_carrier_raised,
- .raise_dtr_rts = epca_raise_dtr_rts,
+ .dtr_rts = epca_dtr_rts,
};
static int info_open(struct tty_struct *tty, struct file *filp)
@@ -1518,7 +1518,7 @@ static void doevent(int crd)
if (event & MODEMCHG_IND) {
/* A modem signal change has been indicated */
ch->imodem = mstat;
- if (test_bit(ASYNC_CHECK_CD, &ch->port.flags)) {
+ if (test_bit(ASYNCB_CHECK_CD, &ch->port.flags)) {
/* We are now receiving dcd */
if (mstat & ch->dcd)
wake_up_interruptible(&ch->port.open_wait);
@@ -1765,9 +1765,9 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
* that the driver will wait on carrier detect.
*/
if (ts->c_cflag & CLOCAL)
- clear_bit(ASYNC_CHECK_CD, &ch->port.flags);
+ clear_bit(ASYNCB_CHECK_CD, &ch->port.flags);
else
- set_bit(ASYNC_CHECK_CD, &ch->port.flags);
+ set_bit(ASYNCB_CHECK_CD, &ch->port.flags);
mval = ch->m_dtr | ch->m_rts;
} /* End CBAUD not detected */
iflag = termios2digi_i(ch, ts->c_iflag);
@@ -2244,7 +2244,8 @@ static void do_softint(struct work_struct *work)
if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
tty_hangup(tty);
wake_up_interruptible(&ch->port.open_wait);
- clear_bit(ASYNC_NORMAL_ACTIVE, &ch->port.flags);
+ clear_bit(ASYNCB_NORMAL_ACTIVE,
+ &ch->port.flags);
}
}
tty_kref_put(tty);
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 340ba4f9dc54..4a9f3492b921 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -224,7 +224,7 @@ static void hpet_timer_set_irq(struct hpet_dev *devp)
break;
}
- gsi = acpi_register_gsi(irq, ACPI_LEVEL_SENSITIVE,
+ gsi = acpi_register_gsi(NULL, irq, ACPI_LEVEL_SENSITIVE,
ACPI_ACTIVE_LOW);
if (gsi > 0)
break;
@@ -939,7 +939,7 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
irqp = &res->data.extended_irq;
for (i = 0; i < irqp->interrupt_count; i++) {
- irq = acpi_register_gsi(irqp->interrupts[i],
+ irq = acpi_register_gsi(NULL, irqp->interrupts[i],
irqp->triggering, irqp->polarity);
if (irq < 0)
return AE_ERROR;
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index c76bccf5354d..7d64e4230e66 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -347,7 +347,7 @@ static void __exit hvcs_module_exit(void);
static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
{
- return viod->dev.driver_data;
+ return dev_get_drvdata(&viod->dev);
}
/* The sysfs interface for the driver and devices */
@@ -785,7 +785,7 @@ static int __devinit hvcs_probe(
kref_init(&hvcsd->kref);
hvcsd->vdev = dev;
- dev->dev.driver_data = hvcsd;
+ dev_set_drvdata(&dev->dev, hvcsd);
hvcsd->index = index;
@@ -831,7 +831,7 @@ static int __devinit hvcs_probe(
static int __devexit hvcs_remove(struct vio_dev *dev)
{
- struct hvcs_struct *hvcsd = dev->dev.driver_data;
+ struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev);
unsigned long flags;
struct tty_struct *tty;
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 5fab6470f4b2..f4b3f7293feb 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -88,7 +88,7 @@ config HW_RANDOM_N2RNG
config HW_RANDOM_VIA
tristate "VIA HW Random Number Generator support"
- depends on HW_RANDOM && X86_32
+ depends on HW_RANDOM && X86
default HW_RANDOM
---help---
This driver provides kernel-side support for the Random Number
@@ -148,3 +148,15 @@ config HW_RANDOM_VIRTIO
To compile this driver as a module, choose M here: the
module will be called virtio-rng. If unsure, say N.
+
+config HW_RANDOM_MXC_RNGA
+ tristate "Freescale i.MX RNGA Random Number Generator"
+ depends on HW_RANDOM && ARCH_HAS_RNGA
+ ---help---
+ This driver provides kernel-side support for the Random Number
+ Generator hardware found on Freescale i.MX processors.
+
+ To compile this driver as a module, choose M here: the
+ module will be called mxc-rnga.
+
+ If unsure, say Y.
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index e81d21a5f28f..fd1ecd2f6731 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o
obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o
obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o
obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o
+obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index e5d583c84e4f..fc93e2fc7c71 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -153,6 +153,7 @@ static const struct file_operations rng_chrdev_ops = {
static struct miscdevice rng_miscdev = {
.minor = RNG_MISCDEV_MINOR,
.name = RNG_MODULE_NAME,
+ .devnode = "hwrng",
.fops = &rng_chrdev_ops,
};
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c
new file mode 100644
index 000000000000..187c6be80f43
--- /dev/null
+++ b/drivers/char/hw_random/mxc-rnga.c
@@ -0,0 +1,247 @@
+/*
+ * RNG driver for Freescale RNGA
+ *
+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Author: Alan Carvalho de Assis <acassis@gmail.com>
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * This driver is based on other RNG drivers.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/hw_random.h>
+#include <linux/io.h>
+
+/* RNGA Registers */
+#define RNGA_CONTROL 0x00
+#define RNGA_STATUS 0x04
+#define RNGA_ENTROPY 0x08
+#define RNGA_OUTPUT_FIFO 0x0c
+#define RNGA_MODE 0x10
+#define RNGA_VERIFICATION_CONTROL 0x14
+#define RNGA_OSC_CONTROL_COUNTER 0x18
+#define RNGA_OSC1_COUNTER 0x1c
+#define RNGA_OSC2_COUNTER 0x20
+#define RNGA_OSC_COUNTER_STATUS 0x24
+
+/* RNGA Registers Range */
+#define RNG_ADDR_RANGE 0x28
+
+/* RNGA Control Register */
+#define RNGA_CONTROL_SLEEP 0x00000010
+#define RNGA_CONTROL_CLEAR_INT 0x00000008
+#define RNGA_CONTROL_MASK_INTS 0x00000004
+#define RNGA_CONTROL_HIGH_ASSURANCE 0x00000002
+#define RNGA_CONTROL_GO 0x00000001
+
+#define RNGA_STATUS_LEVEL_MASK 0x0000ff00
+
+/* RNGA Status Register */
+#define RNGA_STATUS_OSC_DEAD 0x80000000
+#define RNGA_STATUS_SLEEP 0x00000010
+#define RNGA_STATUS_ERROR_INT 0x00000008
+#define RNGA_STATUS_FIFO_UNDERFLOW 0x00000004
+#define RNGA_STATUS_LAST_READ_STATUS 0x00000002
+#define RNGA_STATUS_SECURITY_VIOLATION 0x00000001
+
+static struct platform_device *rng_dev;
+
+static int mxc_rnga_data_present(struct hwrng *rng)
+{
+ int level;
+ void __iomem *rng_base = (void __iomem *)rng->priv;
+
+ /* how many random numbers is in FIFO? [0-16] */
+ level = ((__raw_readl(rng_base + RNGA_STATUS) &
+ RNGA_STATUS_LEVEL_MASK) >> 8);
+
+ return level > 0 ? 1 : 0;
+}
+
+static int mxc_rnga_data_read(struct hwrng *rng, u32 * data)
+{
+ int err;
+ u32 ctrl;
+ void __iomem *rng_base = (void __iomem *)rng->priv;
+
+ /* retrieve a random number from FIFO */
+ *data = __raw_readl(rng_base + RNGA_OUTPUT_FIFO);
+
+ /* some error while reading this random number? */
+ err = __raw_readl(rng_base + RNGA_STATUS) & RNGA_STATUS_ERROR_INT;
+
+ /* if error: clear error interrupt, but doesn't return random number */
+ if (err) {
+ dev_dbg(&rng_dev->dev, "Error while reading random number!\n");
+ ctrl = __raw_readl(rng_base + RNGA_CONTROL);
+ __raw_writel(ctrl | RNGA_CONTROL_CLEAR_INT,
+ rng_base + RNGA_CONTROL);
+ return 0;
+ } else
+ return 4;
+}
+
+static int mxc_rnga_init(struct hwrng *rng)
+{
+ u32 ctrl, osc;
+ void __iomem *rng_base = (void __iomem *)rng->priv;
+
+ /* wake up */
+ ctrl = __raw_readl(rng_base + RNGA_CONTROL);
+ __raw_writel(ctrl & ~RNGA_CONTROL_SLEEP, rng_base + RNGA_CONTROL);
+
+ /* verify if oscillator is working */
+ osc = __raw_readl(rng_base + RNGA_STATUS);
+ if (osc & RNGA_STATUS_OSC_DEAD) {
+ dev_err(&rng_dev->dev, "RNGA Oscillator is dead!\n");
+ return -ENODEV;
+ }
+
+ /* go running */
+ ctrl = __raw_readl(rng_base + RNGA_CONTROL);
+ __raw_writel(ctrl | RNGA_CONTROL_GO, rng_base + RNGA_CONTROL);
+
+ return 0;
+}
+
+static void mxc_rnga_cleanup(struct hwrng *rng)
+{
+ u32 ctrl;
+ void __iomem *rng_base = (void __iomem *)rng->priv;
+
+ ctrl = __raw_readl(rng_base + RNGA_CONTROL);
+
+ /* stop rnga */
+ __raw_writel(ctrl & ~RNGA_CONTROL_GO, rng_base + RNGA_CONTROL);
+}
+
+static struct hwrng mxc_rnga = {
+ .name = "mxc-rnga",
+ .init = mxc_rnga_init,
+ .cleanup = mxc_rnga_cleanup,
+ .data_present = mxc_rnga_data_present,
+ .data_read = mxc_rnga_data_read
+};
+
+static int __init mxc_rnga_probe(struct platform_device *pdev)
+{
+ int err = -ENODEV;
+ struct clk *clk;
+ struct resource *res, *mem;
+ void __iomem *rng_base = NULL;
+
+ if (rng_dev)
+ return -EBUSY;
+
+ clk = clk_get(&pdev->dev, "rng");
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "Could not get rng_clk!\n");
+ err = PTR_ERR(clk);
+ goto out;
+ }
+
+ clk_enable(clk);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ err = -ENOENT;
+ goto err_region;
+ }
+
+ mem = request_mem_region(res->start, resource_size(res), pdev->name);
+ if (mem == NULL) {
+ err = -EBUSY;
+ goto err_region;
+ }
+
+ rng_base = ioremap(res->start, resource_size(res));
+ if (!rng_base) {
+ err = -ENOMEM;
+ goto err_ioremap;
+ }
+
+ mxc_rnga.priv = (unsigned long)rng_base;
+
+ err = hwrng_register(&mxc_rnga);
+ if (err) {
+ dev_err(&pdev->dev, "MXC RNGA registering failed (%d)\n", err);
+ goto err_register;
+ }
+
+ rng_dev = pdev;
+
+ dev_info(&pdev->dev, "MXC RNGA Registered.\n");
+
+ return 0;
+
+err_register:
+ iounmap(rng_base);
+ rng_base = NULL;
+
+err_ioremap:
+ release_mem_region(res->start, resource_size(res));
+
+err_region:
+ clk_disable(clk);
+ clk_put(clk);
+
+out:
+ return err;
+}
+
+static int __exit mxc_rnga_remove(struct platform_device *pdev)
+{
+ struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ void __iomem *rng_base = (void __iomem *)mxc_rnga.priv;
+ struct clk *clk = clk_get(&pdev->dev, "rng");
+
+ hwrng_unregister(&mxc_rnga);
+
+ iounmap(rng_base);
+
+ release_mem_region(res->start, resource_size(res));
+
+ clk_disable(clk);
+ clk_put(clk);
+
+ return 0;
+}
+
+static struct platform_driver mxc_rnga_driver = {
+ .driver = {
+ .name = "mxc_rnga",
+ .owner = THIS_MODULE,
+ },
+ .remove = __exit_p(mxc_rnga_remove),
+};
+
+static int __init mod_init(void)
+{
+ return platform_driver_probe(&mxc_rnga_driver, mxc_rnga_probe);
+}
+
+static void __exit mod_exit(void)
+{
+ platform_driver_unregister(&mxc_rnga_driver);
+}
+
+module_init(mod_init);
+module_exit(mod_exit);
+
+MODULE_AUTHOR("Freescale Semiconductor, Inc.");
+MODULE_DESCRIPTION("H/W RNGA driver for i.MX");
+MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 538313f9e7ac..00dd3de1be51 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -89,7 +89,7 @@ static struct hwrng omap_rng_ops = {
.data_read = omap_rng_data_read,
};
-static int __init omap_rng_probe(struct platform_device *pdev)
+static int __devinit omap_rng_probe(struct platform_device *pdev)
{
struct resource *res, *mem;
int ret;
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index 4e9573c1d39e..794aacb715c1 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -132,6 +132,19 @@ static int via_rng_init(struct hwrng *rng)
struct cpuinfo_x86 *c = &cpu_data(0);
u32 lo, hi, old_lo;
+ /* VIA Nano CPUs don't have the MSR_VIA_RNG anymore. The RNG
+ * is always enabled if CPUID rng_en is set. There is no
+ * RNG configuration like it used to be the case in this
+ * register */
+ if ((c->x86 == 6) && (c->x86_model >= 0x0f)) {
+ if (!cpu_has_xstore_enabled) {
+ printk(KERN_ERR PFX "can't enable hardware RNG "
+ "if XSTORE is not enabled\n");
+ return -ENODEV;
+ }
+ return 0;
+ }
+
/* Control the RNG via MSR. Tread lightly and pay very close
* close attention to values written, as the reserved fields
* are documented to be "undefined and unpredictable"; but it
@@ -205,5 +218,5 @@ static void __exit mod_exit(void)
module_init(mod_init);
module_exit(mod_exit);
-MODULE_DESCRIPTION("H/W RNG driver for VIA chipsets");
+MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock");
MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 86e83f883139..f2041fede822 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -94,13 +94,13 @@ static int virtrng_probe(struct virtio_device *vdev)
int err;
/* We expect a single virtqueue. */
- vq = vdev->config->find_vq(vdev, 0, random_recv_done);
+ vq = virtio_find_single_vq(vdev, random_recv_done, "input");
if (IS_ERR(vq))
return PTR_ERR(vq);
err = hwrng_register(&virtio_hwrng);
if (err) {
- vdev->config->del_vq(vq);
+ vdev->config->del_vqs(vdev);
return err;
}
@@ -112,7 +112,7 @@ static void virtrng_remove(struct virtio_device *vdev)
{
vdev->config->reset(vdev);
hwrng_unregister(&virtio_hwrng);
- vdev->config->del_vq(vq);
+ vdev->config->del_vqs(vdev);
}
static struct virtio_device_id id_table[] = {
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index aa83a0865ec1..09050797c76a 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2856,6 +2856,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
/* Assume a single IPMB channel at zero. */
intf->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB;
intf->channels[0].protocol = IPMI_CHANNEL_PROTOCOL_IPMB;
+ intf->curr_channel = IPMI_MAX_CHANNELS;
}
if (rv == 0)
@@ -3648,13 +3649,13 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
}
/*
- ** We need to make sure the channels have been initialized.
- ** The channel_handler routine will set the "curr_channel"
- ** equal to or greater than IPMI_MAX_CHANNELS when all the
- ** channels for this interface have been initialized.
- */
+ * We need to make sure the channels have been initialized.
+ * The channel_handler routine will set the "curr_channel"
+ * equal to or greater than IPMI_MAX_CHANNELS when all the
+ * channels for this interface have been initialized.
+ */
if (intf->curr_channel < IPMI_MAX_CHANNELS) {
- requeue = 1; /* Just put the message back for now */
+ requeue = 0; /* Throw the message away */
goto out;
}
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 259644646b82..d2e698096ace 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2375,14 +2375,14 @@ static int __devinit ipmi_of_probe(struct of_device *dev,
info->io.addr_data, info->io.regsize, info->io.regspacing,
info->irq);
- dev->dev.driver_data = (void *) info;
+ dev_set_drvdata(&dev->dev, info);
return try_smi_init(info);
}
static int __devexit ipmi_of_remove(struct of_device *dev)
{
- cleanup_one_si(dev->dev.driver_data);
+ cleanup_one_si(dev_get_drvdata(&dev->dev));
return 0;
}
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index a59eac584d16..4d745a89504f 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -329,7 +329,7 @@ static inline void drop_rts(struct isi_port *port)
/* card->lock MUST NOT be held */
-static void isicom_raise_dtr_rts(struct tty_port *port)
+static void isicom_dtr_rts(struct tty_port *port, int on)
{
struct isi_port *ip = container_of(port, struct isi_port, port);
struct isi_board *card = ip->card;
@@ -339,10 +339,17 @@ static void isicom_raise_dtr_rts(struct tty_port *port)
if (!lock_card(card))
return;
- outw(0x8000 | (channel << card->shift_count) | 0x02, base);
- outw(0x0f04, base);
- InterruptTheCard(base);
- ip->status |= (ISI_DTR | ISI_RTS);
+ if (on) {
+ outw(0x8000 | (channel << card->shift_count) | 0x02, base);
+ outw(0x0f04, base);
+ InterruptTheCard(base);
+ ip->status |= (ISI_DTR | ISI_RTS);
+ } else {
+ outw(0x8000 | (channel << card->shift_count) | 0x02, base);
+ outw(0x0C04, base);
+ InterruptTheCard(base);
+ ip->status &= ~(ISI_DTR | ISI_RTS);
+ }
unlock_card(card);
}
@@ -1339,7 +1346,7 @@ static const struct tty_operations isicom_ops = {
static const struct tty_port_operations isicom_port_ops = {
.carrier_raised = isicom_carrier_raised,
- .raise_dtr_rts = isicom_raise_dtr_rts,
+ .dtr_rts = isicom_dtr_rts,
};
static int __devinit reset_card(struct pci_dev *pdev,
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index fff19f7e29d2..e18800c400b1 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -1140,14 +1140,14 @@ static int stli_carrier_raised(struct tty_port *port)
return (portp->sigs & TIOCM_CD) ? 1 : 0;
}
-static void stli_raise_dtr_rts(struct tty_port *port)
+static void stli_dtr_rts(struct tty_port *port, int on)
{
struct stliport *portp = container_of(port, struct stliport, port);
struct stlibrd *brdp = stli_brds[portp->brdnr];
- stli_mkasysigs(&portp->asig, 1, 1);
+ stli_mkasysigs(&portp->asig, on, on);
if (stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
sizeof(asysigs_t), 0) < 0)
- printk(KERN_WARNING "istallion: dtr raise failed.\n");
+ printk(KERN_WARNING "istallion: dtr set failed.\n");
}
@@ -4417,7 +4417,7 @@ static const struct tty_operations stli_ops = {
static const struct tty_port_operations stli_port_ops = {
.carrier_raised = stli_carrier_raised,
- .raise_dtr_rts = stli_raise_dtr_rts,
+ .dtr_rts = stli_dtr_rts,
};
/*****************************************************************************/
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index de26a978fbdd..737be953cc58 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1123,8 +1123,6 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
#define HW_RAW(dev) 0
-#warning "Cannot generate rawmode keyboard for your architecture yet."
-
static int emulate_raw(struct vc_data *vc, unsigned int keycode, unsigned char up_flag)
{
if (keycode > 127)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index a5e0db9d7662..62c99fa59e2b 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -168,7 +168,6 @@ static const struct file_operations misc_fops = {
.open = misc_open,
};
-
/**
* misc_register - register a miscellaneous device
* @misc: device structure
@@ -217,8 +216,8 @@ int misc_register(struct miscdevice * misc)
misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
dev = MKDEV(MISC_MAJOR, misc->minor);
- misc->this_device = device_create(misc_class, misc->parent, dev, NULL,
- "%s", misc->name);
+ misc->this_device = device_create(misc_class, misc->parent, dev,
+ misc, "%s", misc->name);
if (IS_ERR(misc->this_device)) {
err = PTR_ERR(misc->this_device);
goto out;
@@ -264,6 +263,15 @@ int misc_deregister(struct miscdevice *misc)
EXPORT_SYMBOL(misc_register);
EXPORT_SYMBOL(misc_deregister);
+static char *misc_nodename(struct device *dev)
+{
+ struct miscdevice *c = dev_get_drvdata(dev);
+
+ if (c->devnode)
+ return kstrdup(c->devnode, GFP_KERNEL);
+ return NULL;
+}
+
static int __init misc_init(void)
{
int err;
@@ -279,6 +287,7 @@ static int __init misc_init(void)
err = -EIO;
if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
goto fail_printk;
+ misc_class->nodename = misc_nodename;
return 0;
fail_printk:
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index a420e8d437dd..6dfef561ee50 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -547,14 +547,18 @@ static int mxser_carrier_raised(struct tty_port *port)
return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0;
}
-static void mxser_raise_dtr_rts(struct tty_port *port)
+static void mxser_dtr_rts(struct tty_port *port, int on)
{
struct mxser_port *mp = container_of(port, struct mxser_port, port);
unsigned long flags;
spin_lock_irqsave(&mp->slock, flags);
- outb(inb(mp->ioaddr + UART_MCR) |
- UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR);
+ if (on)
+ outb(inb(mp->ioaddr + UART_MCR) |
+ UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR);
+ else
+ outb(inb(mp->ioaddr + UART_MCR)&~(UART_MCR_DTR | UART_MCR_RTS),
+ mp->ioaddr + UART_MCR);
spin_unlock_irqrestore(&mp->slock, flags);
}
@@ -2356,7 +2360,7 @@ static const struct tty_operations mxser_ops = {
struct tty_port_operations mxser_port_ops = {
.carrier_raised = mxser_carrier_raised,
- .raise_dtr_rts = mxser_raise_dtr_rts,
+ .dtr_rts = mxser_dtr_rts,
};
/*
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 19d79fc54461..77b364889224 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -383,7 +383,7 @@ static void async_mode(MGSLPC_INFO *info);
static void tx_timeout(unsigned long context);
static int carrier_raised(struct tty_port *port);
-static void raise_dtr_rts(struct tty_port *port);
+static void dtr_rts(struct tty_port *port, int onoff);
#if SYNCLINK_GENERIC_HDLC
#define dev_to_port(D) (dev_to_hdlc(D)->priv)
@@ -513,7 +513,7 @@ static void ldisc_receive_buf(struct tty_struct *tty,
static const struct tty_port_operations mgslpc_port_ops = {
.carrier_raised = carrier_raised,
- .raise_dtr_rts = raise_dtr_rts
+ .dtr_rts = dtr_rts
};
static int mgslpc_probe(struct pcmcia_device *link)
@@ -2528,13 +2528,16 @@ static int carrier_raised(struct tty_port *port)
return 0;
}
-static void raise_dtr_rts(struct tty_port *port)
+static void dtr_rts(struct tty_port *port, int onoff)
{
MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port);
unsigned long flags;
spin_lock_irqsave(&info->lock,flags);
- info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ if (onoff)
+ info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ else
+ info->serial_signals &= ~SerialSignal_RTS + SerialSignal_DTR;
set_signals(info);
spin_unlock_irqrestore(&info->lock,flags);
}
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 20d90e6a6e50..05f9d18b9361 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -71,7 +71,7 @@ static int raw_open(struct inode *inode, struct file *filp)
err = bd_claim(bdev, raw_open);
if (err)
goto out1;
- err = set_blocksize(bdev, bdev_hardsect_size(bdev));
+ err = set_blocksize(bdev, bdev_logical_block_size(bdev));
if (err)
goto out2;
filp->f_flags |= O_DIRECT;
@@ -261,6 +261,11 @@ static const struct file_operations raw_ctl_fops = {
static struct cdev raw_cdev;
+static char *raw_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev));
+}
+
static int __init raw_init(void)
{
dev_t dev = MKDEV(RAW_MAJOR, 0);
@@ -284,6 +289,7 @@ static int __init raw_init(void)
ret = PTR_ERR(raw_class);
goto error_region;
}
+ raw_class->nodename = raw_nodename;
device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
return 0;
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index f59fc5cea067..63d5b628477a 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -872,11 +872,16 @@ static int carrier_raised(struct tty_port *port)
return (sGetChanStatusLo(&info->channel) & CD_ACT) ? 1 : 0;
}
-static void raise_dtr_rts(struct tty_port *port)
+static void dtr_rts(struct tty_port *port, int on)
{
struct r_port *info = container_of(port, struct r_port, port);
- sSetDTR(&info->channel);
- sSetRTS(&info->channel);
+ if (on) {
+ sSetDTR(&info->channel);
+ sSetRTS(&info->channel);
+ } else {
+ sClrDTR(&info->channel);
+ sClrRTS(&info->channel);
+ }
}
/*
@@ -934,7 +939,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
/*
* Info->count is now 1; so it's safe to sleep now.
*/
- if (!test_bit(ASYNC_INITIALIZED, &port->flags)) {
+ if (!test_bit(ASYNCB_INITIALIZED, &port->flags)) {
cp = &info->channel;
sSetRxTrigger(cp, TRIG_1);
if (sGetChanStatus(cp) & CD_ACT)
@@ -958,7 +963,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
sEnRxFIFO(cp);
sEnTransmit(cp);
- set_bit(ASYNC_INITIALIZED, &info->port.flags);
+ set_bit(ASYNCB_INITIALIZED, &info->port.flags);
/*
* Set up the tty->alt_speed kludge
@@ -1641,7 +1646,7 @@ static int rp_write(struct tty_struct *tty,
/* Write remaining data into the port's xmit_buf */
while (1) {
/* Hung up ? */
- if (!test_bit(ASYNC_NORMAL_ACTIVE, &info->port.flags))
+ if (!test_bit(ASYNCB_NORMAL_ACTIVE, &info->port.flags))
goto end;
c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1);
c = min(c, XMIT_BUF_SIZE - info->xmit_head);
@@ -2250,7 +2255,7 @@ static const struct tty_operations rocket_ops = {
static const struct tty_port_operations rocket_port_ops = {
.carrier_raised = carrier_raised,
- .raise_dtr_rts = raise_dtr_rts,
+ .dtr_rts = dtr_rts,
};
/*
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 2ad813a801dc..53e504f41b20 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -772,11 +772,11 @@ static int stl_carrier_raised(struct tty_port *port)
return (portp->sigs & TIOCM_CD) ? 1 : 0;
}
-static void stl_raise_dtr_rts(struct tty_port *port)
+static void stl_dtr_rts(struct tty_port *port, int on)
{
struct stlport *portp = container_of(port, struct stlport, port);
/* Takes brd_lock internally */
- stl_setsignals(portp, 1, 1);
+ stl_setsignals(portp, on, on);
}
/*****************************************************************************/
@@ -2547,7 +2547,7 @@ static const struct tty_operations stl_ops = {
static const struct tty_port_operations stl_port_ops = {
.carrier_raised = stl_carrier_raised,
- .raise_dtr_rts = stl_raise_dtr_rts,
+ .dtr_rts = stl_dtr_rts,
};
/*****************************************************************************/
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index afd0b26ca056..afded3a2379c 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -3247,13 +3247,16 @@ static int carrier_raised(struct tty_port *port)
return (info->serial_signals & SerialSignal_DCD) ? 1 : 0;
}
-static void raise_dtr_rts(struct tty_port *port)
+static void dtr_rts(struct tty_port *port, int on)
{
struct mgsl_struct *info = container_of(port, struct mgsl_struct, port);
unsigned long flags;
spin_lock_irqsave(&info->irq_spinlock,flags);
- info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ if (on)
+ info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ else
+ info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR);
usc_set_serial_signals(info);
spin_unlock_irqrestore(&info->irq_spinlock,flags);
}
@@ -4258,7 +4261,7 @@ static void mgsl_add_device( struct mgsl_struct *info )
static const struct tty_port_operations mgsl_port_ops = {
.carrier_raised = carrier_raised,
- .raise_dtr_rts = raise_dtr_rts,
+ .dtr_rts = dtr_rts,
};
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 5e256494686a..1386625fc4ca 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -214,6 +214,7 @@ struct slgt_desc
#define set_desc_next(a,b) (a).next = cpu_to_le32((unsigned int)(b))
#define set_desc_count(a,b)(a).count = cpu_to_le16((unsigned short)(b))
#define set_desc_eof(a,b) (a).status = cpu_to_le16((b) ? (le16_to_cpu((a).status) | BIT0) : (le16_to_cpu((a).status) & ~BIT0))
+#define set_desc_status(a, b) (a).status = cpu_to_le16((unsigned short)(b))
#define desc_count(a) (le16_to_cpu((a).count))
#define desc_status(a) (le16_to_cpu((a).status))
#define desc_complete(a) (le16_to_cpu((a).status) & BIT15)
@@ -297,6 +298,7 @@ struct slgt_info {
u32 max_frame_size; /* as set by device config */
unsigned int rbuf_fill_level;
+ unsigned int rx_pio;
unsigned int if_mode;
unsigned int base_clock;
@@ -331,6 +333,8 @@ struct slgt_info {
struct slgt_desc *rbufs;
unsigned int rbuf_current;
unsigned int rbuf_index;
+ unsigned int rbuf_fill_index;
+ unsigned short rbuf_fill_count;
unsigned int tbuf_count;
struct slgt_desc *tbufs;
@@ -2110,6 +2114,40 @@ static void ri_change(struct slgt_info *info, unsigned short status)
info->pending_bh |= BH_STATUS;
}
+static void isr_rxdata(struct slgt_info *info)
+{
+ unsigned int count = info->rbuf_fill_count;
+ unsigned int i = info->rbuf_fill_index;
+ unsigned short reg;
+
+ while (rd_reg16(info, SSR) & IRQ_RXDATA) {
+ reg = rd_reg16(info, RDR);
+ DBGISR(("isr_rxdata %s RDR=%04X\n", info->device_name, reg));
+ if (desc_complete(info->rbufs[i])) {
+ /* all buffers full */
+ rx_stop(info);
+ info->rx_restart = 1;
+ continue;
+ }
+ info->rbufs[i].buf[count++] = (unsigned char)reg;
+ /* async mode saves status byte to buffer for each data byte */
+ if (info->params.mode == MGSL_MODE_ASYNC)
+ info->rbufs[i].buf[count++] = (unsigned char)(reg >> 8);
+ if (count == info->rbuf_fill_level || (reg & BIT10)) {
+ /* buffer full or end of frame */
+ set_desc_count(info->rbufs[i], count);
+ set_desc_status(info->rbufs[i], BIT15 | (reg >> 8));
+ info->rbuf_fill_count = count = 0;
+ if (++i == info->rbuf_count)
+ i = 0;
+ info->pending_bh |= BH_RECEIVE;
+ }
+ }
+
+ info->rbuf_fill_index = i;
+ info->rbuf_fill_count = count;
+}
+
static void isr_serial(struct slgt_info *info)
{
unsigned short status = rd_reg16(info, SSR);
@@ -2125,6 +2163,8 @@ static void isr_serial(struct slgt_info *info)
if (info->tx_count)
isr_txeom(info, status);
}
+ if (info->rx_pio && (status & IRQ_RXDATA))
+ isr_rxdata(info);
if ((status & IRQ_RXBREAK) && (status & RXBREAK)) {
info->icount.brk++;
/* process break detection if tty control allows */
@@ -2141,7 +2181,8 @@ static void isr_serial(struct slgt_info *info)
} else {
if (status & (IRQ_TXIDLE + IRQ_TXUNDER))
isr_txeom(info, status);
-
+ if (info->rx_pio && (status & IRQ_RXDATA))
+ isr_rxdata(info);
if (status & IRQ_RXIDLE) {
if (status & RXIDLE)
info->icount.rxidle++;
@@ -2642,6 +2683,10 @@ static int rx_enable(struct slgt_info *info, int enable)
return -EINVAL;
}
info->rbuf_fill_level = rbuf_fill_level;
+ if (rbuf_fill_level < 128)
+ info->rx_pio = 1; /* PIO mode */
+ else
+ info->rx_pio = 0; /* DMA mode */
rx_stop(info); /* restart receiver to use new fill level */
}
@@ -3099,13 +3144,16 @@ static int carrier_raised(struct tty_port *port)
return (info->signals & SerialSignal_DCD) ? 1 : 0;
}
-static void raise_dtr_rts(struct tty_port *port)
+static void dtr_rts(struct tty_port *port, int on)
{
unsigned long flags;
struct slgt_info *info = container_of(port, struct slgt_info, port);
spin_lock_irqsave(&info->lock,flags);
- info->signals |= SerialSignal_RTS + SerialSignal_DTR;
+ if (on)
+ info->signals |= SerialSignal_RTS + SerialSignal_DTR;
+ else
+ info->signals &= ~(SerialSignal_RTS + SerialSignal_DTR);
set_signals(info);
spin_unlock_irqrestore(&info->lock,flags);
}
@@ -3419,7 +3467,7 @@ static void add_device(struct slgt_info *info)
static const struct tty_port_operations slgt_port_ops = {
.carrier_raised = carrier_raised,
- .raise_dtr_rts = raise_dtr_rts,
+ .dtr_rts = dtr_rts,
};
/*
@@ -3841,15 +3889,27 @@ static void rx_start(struct slgt_info *info)
rdma_reset(info);
reset_rbufs(info);
- /* set 1st descriptor address */
- wr_reg32(info, RDDAR, info->rbufs[0].pdesc);
-
- if (info->params.mode != MGSL_MODE_ASYNC) {
- /* enable rx DMA and DMA interrupt */
- wr_reg32(info, RDCSR, (BIT2 + BIT0));
+ if (info->rx_pio) {
+ /* rx request when rx FIFO not empty */
+ wr_reg16(info, SCR, (unsigned short)(rd_reg16(info, SCR) & ~BIT14));
+ slgt_irq_on(info, IRQ_RXDATA);
+ if (info->params.mode == MGSL_MODE_ASYNC) {
+ /* enable saving of rx status */
+ wr_reg32(info, RDCSR, BIT6);
+ }
} else {
- /* enable saving of rx status, rx DMA and DMA interrupt */
- wr_reg32(info, RDCSR, (BIT6 + BIT2 + BIT0));
+ /* rx request when rx FIFO half full */
+ wr_reg16(info, SCR, (unsigned short)(rd_reg16(info, SCR) | BIT14));
+ /* set 1st descriptor address */
+ wr_reg32(info, RDDAR, info->rbufs[0].pdesc);
+
+ if (info->params.mode != MGSL_MODE_ASYNC) {
+ /* enable rx DMA and DMA interrupt */
+ wr_reg32(info, RDCSR, (BIT2 + BIT0));
+ } else {
+ /* enable saving of rx status, rx DMA and DMA interrupt */
+ wr_reg32(info, RDCSR, (BIT6 + BIT2 + BIT0));
+ }
}
slgt_irq_on(info, IRQ_RXOVER);
@@ -4467,6 +4527,8 @@ static void free_rbufs(struct slgt_info *info, unsigned int i, unsigned int last
static void reset_rbufs(struct slgt_info *info)
{
free_rbufs(info, 0, info->rbuf_count - 1);
+ info->rbuf_fill_index = 0;
+ info->rbuf_fill_count = 0;
}
/*
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 26de60efe4b2..6f727e3c53ad 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -3277,13 +3277,16 @@ static int carrier_raised(struct tty_port *port)
return (info->serial_signals & SerialSignal_DCD) ? 1 : 0;
}
-static void raise_dtr_rts(struct tty_port *port)
+static void dtr_rts(struct tty_port *port, int on)
{
SLMP_INFO *info = container_of(port, SLMP_INFO, port);
unsigned long flags;
spin_lock_irqsave(&info->lock,flags);
- info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ if (on)
+ info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ else
+ info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR);
set_signals(info);
spin_unlock_irqrestore(&info->lock,flags);
}
@@ -3746,7 +3749,7 @@ static void add_device(SLMP_INFO *info)
static const struct tty_port_operations port_ops = {
.carrier_raised = carrier_raised,
- .raise_dtr_rts = raise_dtr_rts,
+ .dtr_rts = dtr_rts,
};
/* Allocate and initialize a device instance structure
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index 9b8004c72686..4d08b6d27c28 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -137,7 +137,7 @@ int tty_port_carrier_raised(struct tty_port *port)
EXPORT_SYMBOL(tty_port_carrier_raised);
/**
- * tty_port_raise_dtr_rts - Riase DTR/RTS
+ * tty_port_raise_dtr_rts - Raise DTR/RTS
* @port: tty port
*
* Wrapper for the DTR/RTS raise logic. For the moment this is used
@@ -147,12 +147,28 @@ EXPORT_SYMBOL(tty_port_carrier_raised);
void tty_port_raise_dtr_rts(struct tty_port *port)
{
- if (port->ops->raise_dtr_rts)
- port->ops->raise_dtr_rts(port);
+ if (port->ops->dtr_rts)
+ port->ops->dtr_rts(port, 1);
}
EXPORT_SYMBOL(tty_port_raise_dtr_rts);
/**
+ * tty_port_lower_dtr_rts - Lower DTR/RTS
+ * @port: tty port
+ *
+ * Wrapper for the DTR/RTS raise logic. For the moment this is used
+ * to hide some internal details. This will eventually become entirely
+ * internal to the tty port.
+ */
+
+void tty_port_lower_dtr_rts(struct tty_port *port)
+{
+ if (port->ops->dtr_rts)
+ port->ops->dtr_rts(port, 0);
+}
+EXPORT_SYMBOL(tty_port_lower_dtr_rts);
+
+/**
* tty_port_block_til_ready - Waiting logic for tty open
* @port: the tty port being opened
* @tty: the tty device being bound
@@ -167,7 +183,7 @@ EXPORT_SYMBOL(tty_port_raise_dtr_rts);
* - port flags and counts
*
* The passed tty_port must implement the carrier_raised method if it can
- * do carrier detect and the raise_dtr_rts method if it supports software
+ * do carrier detect and the dtr_rts method if it supports software
* management of these lines. Note that the dtr/rts raise is done each
* iteration as a hangup may have previously dropped them while we wait.
*/
@@ -292,6 +308,17 @@ int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct f
if (port->flags & ASYNC_INITIALIZED &&
port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->closing_wait);
+ if (port->drain_delay) {
+ unsigned int bps = tty_get_baud_rate(tty);
+ long timeout;
+
+ if (bps > 1200)
+ timeout = max_t(long, (HZ * 10 * port->drain_delay) / bps,
+ HZ / 10);
+ else
+ timeout = 2 * HZ;
+ schedule_timeout_interruptible(timeout);
+ }
return 1;
}
EXPORT_SYMBOL(tty_port_close_start);
@@ -302,6 +329,9 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty)
tty_ldisc_flush(tty);
+ if (tty->termios->c_cflag & HUPCL)
+ tty_port_lower_dtr_rts(port);
+
spin_lock_irqsave(&port->lock, flags);
tty->closing = 0;
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index ff6f5a4b58fb..c74dacfa6795 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -188,6 +188,9 @@ static void hvc_handle_input(struct virtqueue *vq)
* Finally we put our input buffer in the input queue, ready to receive. */
static int __devinit virtcons_probe(struct virtio_device *dev)
{
+ vq_callback_t *callbacks[] = { hvc_handle_input, NULL};
+ const char *names[] = { "input", "output" };
+ struct virtqueue *vqs[2];
int err;
vdev = dev;
@@ -199,20 +202,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
goto fail;
}
- /* Find the input queue. */
+ /* Find the queues. */
/* FIXME: This is why we want to wean off hvc: we do nothing
* when input comes in. */
- in_vq = vdev->config->find_vq(vdev, 0, hvc_handle_input);
- if (IS_ERR(in_vq)) {
- err = PTR_ERR(in_vq);
+ err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names);
+ if (err)
goto free;
- }
- out_vq = vdev->config->find_vq(vdev, 1, NULL);
- if (IS_ERR(out_vq)) {
- err = PTR_ERR(out_vq);
- goto free_in_vq;
- }
+ in_vq = vqs[0];
+ out_vq = vqs[1];
/* Start using the new console output. */
virtio_cons.get_chars = get_chars;
@@ -233,17 +231,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE);
if (IS_ERR(hvc)) {
err = PTR_ERR(hvc);
- goto free_out_vq;
+ goto free_vqs;
}
/* Register the input buffer the first time. */
add_inbuf();
return 0;
-free_out_vq:
- vdev->config->del_vq(out_vq);
-free_in_vq:
- vdev->config->del_vq(in_vq);
+free_vqs:
+ vdev->config->del_vqs(vdev);
free:
kfree(inbuf);
fail:
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 08151d4de489..961c1a788c61 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -104,6 +104,7 @@
#include <linux/io.h>
#include <asm/system.h>
#include <linux/uaccess.h>
+#include <linux/kmemleak.h>
#define MAX_NR_CON_DRIVER 16
@@ -2880,6 +2881,12 @@ static int __init con_init(void)
*/
for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data));
+ /*
+ * Kmemleak does not track the memory allocated via
+ * alloc_bootmem() but this block contains pointers to
+ * other blocks allocated via kmalloc.
+ */
+ kmemleak_alloc(vc, sizeof(struct vc_data), 1, GFP_ATOMIC);
INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
visual_init(vc, currcons, 1);
vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size);
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 1efb2879a94f..eef216f7f61d 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -3,3 +3,5 @@ obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
+obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o
+obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 1c92c39a53aa..cf56a2af5fe1 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -18,7 +18,6 @@
*/
#include <linux/init.h>
-#include <linux/bootmem.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
@@ -29,7 +28,7 @@
#include <linux/err.h>
#include <linux/clocksource.h>
#include <linux/clockchips.h>
-#include <linux/sh_cmt.h>
+#include <linux/sh_timer.h>
struct sh_cmt_priv {
void __iomem *mapbase;
@@ -47,6 +46,7 @@ struct sh_cmt_priv {
unsigned long rate;
spinlock_t lock;
struct clock_event_device ced;
+ struct clocksource cs;
unsigned long total_cycles;
};
@@ -59,7 +59,7 @@ static DEFINE_SPINLOCK(sh_cmt_lock);
static inline unsigned long sh_cmt_read(struct sh_cmt_priv *p, int reg_nr)
{
- struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
void __iomem *base = p->mapbase;
unsigned long offs;
@@ -83,7 +83,7 @@ static inline unsigned long sh_cmt_read(struct sh_cmt_priv *p, int reg_nr)
static inline void sh_cmt_write(struct sh_cmt_priv *p, int reg_nr,
unsigned long value)
{
- struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
void __iomem *base = p->mapbase;
unsigned long offs;
@@ -110,23 +110,28 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
int *has_wrapped)
{
unsigned long v1, v2, v3;
+ int o1, o2;
+
+ o1 = sh_cmt_read(p, CMCSR) & p->overflow_bit;
/* Make sure the timer value is stable. Stolen from acpi_pm.c */
do {
+ o2 = o1;
v1 = sh_cmt_read(p, CMCNT);
v2 = sh_cmt_read(p, CMCNT);
v3 = sh_cmt_read(p, CMCNT);
- } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
- || (v3 > v1 && v3 < v2)));
+ o1 = sh_cmt_read(p, CMCSR) & p->overflow_bit;
+ } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3)
+ || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
- *has_wrapped = sh_cmt_read(p, CMCSR) & p->overflow_bit;
+ *has_wrapped = o1;
return v2;
}
static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start)
{
- struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
unsigned long flags, value;
/* start stop register shared by multiple timer channels */
@@ -144,7 +149,7 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start)
static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
{
- struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
int ret;
/* enable clock */
@@ -153,16 +158,18 @@ static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
pr_err("sh_cmt: cannot enable clock \"%s\"\n", cfg->clk);
return ret;
}
- *rate = clk_get_rate(p->clk) / 8;
/* make sure channel is disabled */
sh_cmt_start_stop_ch(p, 0);
/* configure channel, periodic mode and maximum timeout */
- if (p->width == 16)
- sh_cmt_write(p, CMCSR, 0);
- else
+ if (p->width == 16) {
+ *rate = clk_get_rate(p->clk) / 512;
+ sh_cmt_write(p, CMCSR, 0x43);
+ } else {
+ *rate = clk_get_rate(p->clk) / 8;
sh_cmt_write(p, CMCSR, 0x01a4);
+ }
sh_cmt_write(p, CMCOR, 0xffffffff);
sh_cmt_write(p, CMCNT, 0);
@@ -376,6 +383,68 @@ static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag)
spin_unlock_irqrestore(&p->lock, flags);
}
+static struct sh_cmt_priv *cs_to_sh_cmt(struct clocksource *cs)
+{
+ return container_of(cs, struct sh_cmt_priv, cs);
+}
+
+static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
+{
+ struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+ unsigned long flags, raw;
+ unsigned long value;
+ int has_wrapped;
+
+ spin_lock_irqsave(&p->lock, flags);
+ value = p->total_cycles;
+ raw = sh_cmt_get_counter(p, &has_wrapped);
+
+ if (unlikely(has_wrapped))
+ raw += p->match_value;
+ spin_unlock_irqrestore(&p->lock, flags);
+
+ return value + raw;
+}
+
+static int sh_cmt_clocksource_enable(struct clocksource *cs)
+{
+ struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+ int ret;
+
+ p->total_cycles = 0;
+
+ ret = sh_cmt_start(p, FLAG_CLOCKSOURCE);
+ if (ret)
+ return ret;
+
+ /* TODO: calculate good shift from rate and counter bit width */
+ cs->shift = 0;
+ cs->mult = clocksource_hz2mult(p->rate, cs->shift);
+ return 0;
+}
+
+static void sh_cmt_clocksource_disable(struct clocksource *cs)
+{
+ sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
+}
+
+static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
+ char *name, unsigned long rating)
+{
+ struct clocksource *cs = &p->cs;
+
+ cs->name = name;
+ cs->rating = rating;
+ cs->read = sh_cmt_clocksource_read;
+ cs->enable = sh_cmt_clocksource_enable;
+ cs->disable = sh_cmt_clocksource_disable;
+ cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
+ cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+ pr_info("sh_cmt: %s used as clock source\n", cs->name);
+ clocksource_register(cs);
+ return 0;
+}
+
static struct sh_cmt_priv *ced_to_sh_cmt(struct clock_event_device *ced)
{
return container_of(ced, struct sh_cmt_priv, ced);
@@ -468,9 +537,9 @@ static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
clockevents_register_device(ced);
}
-int sh_cmt_register(struct sh_cmt_priv *p, char *name,
- unsigned long clockevent_rating,
- unsigned long clocksource_rating)
+static int sh_cmt_register(struct sh_cmt_priv *p, char *name,
+ unsigned long clockevent_rating,
+ unsigned long clocksource_rating)
{
if (p->width == (sizeof(p->max_match_value) * 8))
p->max_match_value = ~0;
@@ -483,12 +552,15 @@ int sh_cmt_register(struct sh_cmt_priv *p, char *name,
if (clockevent_rating)
sh_cmt_register_clockevent(p, name, clockevent_rating);
+ if (clocksource_rating)
+ sh_cmt_register_clocksource(p, name, clocksource_rating);
+
return 0;
}
static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
{
- struct sh_cmt_config *cfg = pdev->dev.platform_data;
+ struct sh_timer_config *cfg = pdev->dev.platform_data;
struct resource *res;
int irq, ret;
ret = -ENXIO;
@@ -545,7 +617,7 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
if (resource_size(res) == 6) {
p->width = 16;
p->overflow_bit = 0x80;
- p->clear_bits = ~0xc0;
+ p->clear_bits = ~0x80;
} else {
p->width = 32;
p->overflow_bit = 0x8000;
@@ -566,8 +638,14 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
static int __devinit sh_cmt_probe(struct platform_device *pdev)
{
struct sh_cmt_priv *p = platform_get_drvdata(pdev);
+ struct sh_timer_config *cfg = pdev->dev.platform_data;
int ret;
+ if (p) {
+ pr_info("sh_cmt: %s kept as earlytimer\n", cfg->name);
+ return 0;
+ }
+
p = kmalloc(sizeof(*p), GFP_KERNEL);
if (p == NULL) {
dev_err(&pdev->dev, "failed to allocate driver data\n");
@@ -577,7 +655,6 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev)
ret = sh_cmt_setup(p, pdev);
if (ret) {
kfree(p);
-
platform_set_drvdata(pdev, NULL);
}
return ret;
@@ -606,6 +683,7 @@ static void __exit sh_cmt_exit(void)
platform_driver_unregister(&sh_cmt_device_driver);
}
+early_platform_init("earlytimer", &sh_cmt_device_driver);
module_init(sh_cmt_init);
module_exit(sh_cmt_exit);
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
new file mode 100644
index 000000000000..d1ae75454d10
--- /dev/null
+++ b/drivers/clocksource/sh_mtu2.c
@@ -0,0 +1,357 @@
+/*
+ * SuperH Timer Support - MTU2
+ *
+ * Copyright (C) 2009 Magnus Damm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/irq.h>
+#include <linux/err.h>
+#include <linux/clockchips.h>
+#include <linux/sh_timer.h>
+
+struct sh_mtu2_priv {
+ void __iomem *mapbase;
+ struct clk *clk;
+ struct irqaction irqaction;
+ struct platform_device *pdev;
+ unsigned long rate;
+ unsigned long periodic;
+ struct clock_event_device ced;
+};
+
+static DEFINE_SPINLOCK(sh_mtu2_lock);
+
+#define TSTR -1 /* shared register */
+#define TCR 0 /* channel register */
+#define TMDR 1 /* channel register */
+#define TIOR 2 /* channel register */
+#define TIER 3 /* channel register */
+#define TSR 4 /* channel register */
+#define TCNT 5 /* channel register */
+#define TGR 6 /* channel register */
+
+static unsigned long mtu2_reg_offs[] = {
+ [TCR] = 0,
+ [TMDR] = 1,
+ [TIOR] = 2,
+ [TIER] = 4,
+ [TSR] = 5,
+ [TCNT] = 6,
+ [TGR] = 8,
+};
+
+static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ void __iomem *base = p->mapbase;
+ unsigned long offs;
+
+ if (reg_nr == TSTR)
+ return ioread8(base + cfg->channel_offset);
+
+ offs = mtu2_reg_offs[reg_nr];
+
+ if ((reg_nr == TCNT) || (reg_nr == TGR))
+ return ioread16(base + offs);
+ else
+ return ioread8(base + offs);
+}
+
+static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr,
+ unsigned long value)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ void __iomem *base = p->mapbase;
+ unsigned long offs;
+
+ if (reg_nr == TSTR) {
+ iowrite8(value, base + cfg->channel_offset);
+ return;
+ }
+
+ offs = mtu2_reg_offs[reg_nr];
+
+ if ((reg_nr == TCNT) || (reg_nr == TGR))
+ iowrite16(value, base + offs);
+ else
+ iowrite8(value, base + offs);
+}
+
+static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ unsigned long flags, value;
+
+ /* start stop register shared by multiple timer channels */
+ spin_lock_irqsave(&sh_mtu2_lock, flags);
+ value = sh_mtu2_read(p, TSTR);
+
+ if (start)
+ value |= 1 << cfg->timer_bit;
+ else
+ value &= ~(1 << cfg->timer_bit);
+
+ sh_mtu2_write(p, TSTR, value);
+ spin_unlock_irqrestore(&sh_mtu2_lock, flags);
+}
+
+static int sh_mtu2_enable(struct sh_mtu2_priv *p)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ int ret;
+
+ /* enable clock */
+ ret = clk_enable(p->clk);
+ if (ret) {
+ pr_err("sh_mtu2: cannot enable clock \"%s\"\n", cfg->clk);
+ return ret;
+ }
+
+ /* make sure channel is disabled */
+ sh_mtu2_start_stop_ch(p, 0);
+
+ p->rate = clk_get_rate(p->clk) / 64;
+ p->periodic = (p->rate + HZ/2) / HZ;
+
+ /* "Periodic Counter Operation" */
+ sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */
+ sh_mtu2_write(p, TIOR, 0);
+ sh_mtu2_write(p, TGR, p->periodic);
+ sh_mtu2_write(p, TCNT, 0);
+ sh_mtu2_write(p, TMDR, 0);
+ sh_mtu2_write(p, TIER, 0x01);
+
+ /* enable channel */
+ sh_mtu2_start_stop_ch(p, 1);
+
+ return 0;
+}
+
+static void sh_mtu2_disable(struct sh_mtu2_priv *p)
+{
+ /* disable channel */
+ sh_mtu2_start_stop_ch(p, 0);
+
+ /* stop clock */
+ clk_disable(p->clk);
+}
+
+static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id)
+{
+ struct sh_mtu2_priv *p = dev_id;
+
+ /* acknowledge interrupt */
+ sh_mtu2_read(p, TSR);
+ sh_mtu2_write(p, TSR, 0xfe);
+
+ /* notify clockevent layer */
+ p->ced.event_handler(&p->ced);
+ return IRQ_HANDLED;
+}
+
+static struct sh_mtu2_priv *ced_to_sh_mtu2(struct clock_event_device *ced)
+{
+ return container_of(ced, struct sh_mtu2_priv, ced);
+}
+
+static void sh_mtu2_clock_event_mode(enum clock_event_mode mode,
+ struct clock_event_device *ced)
+{
+ struct sh_mtu2_priv *p = ced_to_sh_mtu2(ced);
+ int disabled = 0;
+
+ /* deal with old setting first */
+ switch (ced->mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ sh_mtu2_disable(p);
+ disabled = 1;
+ break;
+ default:
+ break;
+ }
+
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ pr_info("sh_mtu2: %s used for periodic clock events\n",
+ ced->name);
+ sh_mtu2_enable(p);
+ break;
+ case CLOCK_EVT_MODE_UNUSED:
+ if (!disabled)
+ sh_mtu2_disable(p);
+ break;
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ default:
+ break;
+ }
+}
+
+static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p,
+ char *name, unsigned long rating)
+{
+ struct clock_event_device *ced = &p->ced;
+ int ret;
+
+ memset(ced, 0, sizeof(*ced));
+
+ ced->name = name;
+ ced->features = CLOCK_EVT_FEAT_PERIODIC;
+ ced->rating = rating;
+ ced->cpumask = cpumask_of(0);
+ ced->set_mode = sh_mtu2_clock_event_mode;
+
+ ret = setup_irq(p->irqaction.irq, &p->irqaction);
+ if (ret) {
+ pr_err("sh_mtu2: failed to request irq %d\n",
+ p->irqaction.irq);
+ return;
+ }
+
+ pr_info("sh_mtu2: %s used for clock events\n", ced->name);
+ clockevents_register_device(ced);
+}
+
+static int sh_mtu2_register(struct sh_mtu2_priv *p, char *name,
+ unsigned long clockevent_rating)
+{
+ if (clockevent_rating)
+ sh_mtu2_register_clockevent(p, name, clockevent_rating);
+
+ return 0;
+}
+
+static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
+{
+ struct sh_timer_config *cfg = pdev->dev.platform_data;
+ struct resource *res;
+ int irq, ret;
+ ret = -ENXIO;
+
+ memset(p, 0, sizeof(*p));
+ p->pdev = pdev;
+
+ if (!cfg) {
+ dev_err(&p->pdev->dev, "missing platform data\n");
+ goto err0;
+ }
+
+ platform_set_drvdata(pdev, p);
+
+ res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&p->pdev->dev, "failed to get I/O memory\n");
+ goto err0;
+ }
+
+ irq = platform_get_irq(p->pdev, 0);
+ if (irq < 0) {
+ dev_err(&p->pdev->dev, "failed to get irq\n");
+ goto err0;
+ }
+
+ /* map memory, let mapbase point to our channel */
+ p->mapbase = ioremap_nocache(res->start, resource_size(res));
+ if (p->mapbase == NULL) {
+ pr_err("sh_mtu2: failed to remap I/O memory\n");
+ goto err0;
+ }
+
+ /* setup data for setup_irq() (too early for request_irq()) */
+ p->irqaction.name = cfg->name;
+ p->irqaction.handler = sh_mtu2_interrupt;
+ p->irqaction.dev_id = p;
+ p->irqaction.irq = irq;
+ p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
+ p->irqaction.mask = CPU_MASK_NONE;
+
+ /* get hold of clock */
+ p->clk = clk_get(&p->pdev->dev, cfg->clk);
+ if (IS_ERR(p->clk)) {
+ pr_err("sh_mtu2: cannot get clock \"%s\"\n", cfg->clk);
+ ret = PTR_ERR(p->clk);
+ goto err1;
+ }
+
+ return sh_mtu2_register(p, cfg->name, cfg->clockevent_rating);
+ err1:
+ iounmap(p->mapbase);
+ err0:
+ return ret;
+}
+
+static int __devinit sh_mtu2_probe(struct platform_device *pdev)
+{
+ struct sh_mtu2_priv *p = platform_get_drvdata(pdev);
+ struct sh_timer_config *cfg = pdev->dev.platform_data;
+ int ret;
+
+ if (p) {
+ pr_info("sh_mtu2: %s kept as earlytimer\n", cfg->name);
+ return 0;
+ }
+
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
+ if (p == NULL) {
+ dev_err(&pdev->dev, "failed to allocate driver data\n");
+ return -ENOMEM;
+ }
+
+ ret = sh_mtu2_setup(p, pdev);
+ if (ret) {
+ kfree(p);
+ platform_set_drvdata(pdev, NULL);
+ }
+ return ret;
+}
+
+static int __devexit sh_mtu2_remove(struct platform_device *pdev)
+{
+ return -EBUSY; /* cannot unregister clockevent */
+}
+
+static struct platform_driver sh_mtu2_device_driver = {
+ .probe = sh_mtu2_probe,
+ .remove = __devexit_p(sh_mtu2_remove),
+ .driver = {
+ .name = "sh_mtu2",
+ }
+};
+
+static int __init sh_mtu2_init(void)
+{
+ return platform_driver_register(&sh_mtu2_device_driver);
+}
+
+static void __exit sh_mtu2_exit(void)
+{
+ platform_driver_unregister(&sh_mtu2_device_driver);
+}
+
+early_platform_init("earlytimer", &sh_mtu2_device_driver);
+module_init(sh_mtu2_init);
+module_exit(sh_mtu2_exit);
+
+MODULE_AUTHOR("Magnus Damm");
+MODULE_DESCRIPTION("SuperH MTU2 Timer Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
new file mode 100644
index 000000000000..d6ea4398bf62
--- /dev/null
+++ b/drivers/clocksource/sh_tmu.c
@@ -0,0 +1,461 @@
+/*
+ * SuperH Timer Support - TMU
+ *
+ * Copyright (C) 2009 Magnus Damm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/irq.h>
+#include <linux/err.h>
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <linux/sh_timer.h>
+
+struct sh_tmu_priv {
+ void __iomem *mapbase;
+ struct clk *clk;
+ struct irqaction irqaction;
+ struct platform_device *pdev;
+ unsigned long rate;
+ unsigned long periodic;
+ struct clock_event_device ced;
+ struct clocksource cs;
+};
+
+static DEFINE_SPINLOCK(sh_tmu_lock);
+
+#define TSTR -1 /* shared register */
+#define TCOR 0 /* channel register */
+#define TCNT 1 /* channel register */
+#define TCR 2 /* channel register */
+
+static inline unsigned long sh_tmu_read(struct sh_tmu_priv *p, int reg_nr)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ void __iomem *base = p->mapbase;
+ unsigned long offs;
+
+ if (reg_nr == TSTR)
+ return ioread8(base - cfg->channel_offset);
+
+ offs = reg_nr << 2;
+
+ if (reg_nr == TCR)
+ return ioread16(base + offs);
+ else
+ return ioread32(base + offs);
+}
+
+static inline void sh_tmu_write(struct sh_tmu_priv *p, int reg_nr,
+ unsigned long value)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ void __iomem *base = p->mapbase;
+ unsigned long offs;
+
+ if (reg_nr == TSTR) {
+ iowrite8(value, base - cfg->channel_offset);
+ return;
+ }
+
+ offs = reg_nr << 2;
+
+ if (reg_nr == TCR)
+ iowrite16(value, base + offs);
+ else
+ iowrite32(value, base + offs);
+}
+
+static void sh_tmu_start_stop_ch(struct sh_tmu_priv *p, int start)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ unsigned long flags, value;
+
+ /* start stop register shared by multiple timer channels */
+ spin_lock_irqsave(&sh_tmu_lock, flags);
+ value = sh_tmu_read(p, TSTR);
+
+ if (start)
+ value |= 1 << cfg->timer_bit;
+ else
+ value &= ~(1 << cfg->timer_bit);
+
+ sh_tmu_write(p, TSTR, value);
+ spin_unlock_irqrestore(&sh_tmu_lock, flags);
+}
+
+static int sh_tmu_enable(struct sh_tmu_priv *p)
+{
+ struct sh_timer_config *cfg = p->pdev->dev.platform_data;
+ int ret;
+
+ /* enable clock */
+ ret = clk_enable(p->clk);
+ if (ret) {
+ pr_err("sh_tmu: cannot enable clock \"%s\"\n", cfg->clk);
+ return ret;
+ }
+
+ /* make sure channel is disabled */
+ sh_tmu_start_stop_ch(p, 0);
+
+ /* maximum timeout */
+ sh_tmu_write(p, TCOR, 0xffffffff);
+ sh_tmu_write(p, TCNT, 0xffffffff);
+
+ /* configure channel to parent clock / 4, irq off */
+ p->rate = clk_get_rate(p->clk) / 4;
+ sh_tmu_write(p, TCR, 0x0000);
+
+ /* enable channel */
+ sh_tmu_start_stop_ch(p, 1);
+
+ return 0;
+}
+
+static void sh_tmu_disable(struct sh_tmu_priv *p)
+{
+ /* disable channel */
+ sh_tmu_start_stop_ch(p, 0);
+
+ /* stop clock */
+ clk_disable(p->clk);
+}
+
+static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta,
+ int periodic)
+{
+ /* stop timer */
+ sh_tmu_start_stop_ch(p, 0);
+
+ /* acknowledge interrupt */
+ sh_tmu_read(p, TCR);
+
+ /* enable interrupt */
+ sh_tmu_write(p, TCR, 0x0020);
+
+ /* reload delta value in case of periodic timer */
+ if (periodic)
+ sh_tmu_write(p, TCOR, delta);
+ else
+ sh_tmu_write(p, TCOR, 0);
+
+ sh_tmu_write(p, TCNT, delta);
+
+ /* start timer */
+ sh_tmu_start_stop_ch(p, 1);
+}
+
+static irqreturn_t sh_tmu_interrupt(int irq, void *dev_id)
+{
+ struct sh_tmu_priv *p = dev_id;
+
+ /* disable or acknowledge interrupt */
+ if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT)
+ sh_tmu_write(p, TCR, 0x0000);
+ else
+ sh_tmu_write(p, TCR, 0x0020);
+
+ /* notify clockevent layer */
+ p->ced.event_handler(&p->ced);
+ return IRQ_HANDLED;
+}
+
+static struct sh_tmu_priv *cs_to_sh_tmu(struct clocksource *cs)
+{
+ return container_of(cs, struct sh_tmu_priv, cs);
+}
+
+static cycle_t sh_tmu_clocksource_read(struct clocksource *cs)
+{
+ struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+
+ return sh_tmu_read(p, TCNT) ^ 0xffffffff;
+}
+
+static int sh_tmu_clocksource_enable(struct clocksource *cs)
+{
+ struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+ int ret;
+
+ ret = sh_tmu_enable(p);
+ if (ret)
+ return ret;
+
+ /* TODO: calculate good shift from rate and counter bit width */
+ cs->shift = 10;
+ cs->mult = clocksource_hz2mult(p->rate, cs->shift);
+ return 0;
+}
+
+static void sh_tmu_clocksource_disable(struct clocksource *cs)
+{
+ sh_tmu_disable(cs_to_sh_tmu(cs));
+}
+
+static int sh_tmu_register_clocksource(struct sh_tmu_priv *p,
+ char *name, unsigned long rating)
+{
+ struct clocksource *cs = &p->cs;
+
+ cs->name = name;
+ cs->rating = rating;
+ cs->read = sh_tmu_clocksource_read;
+ cs->enable = sh_tmu_clocksource_enable;
+ cs->disable = sh_tmu_clocksource_disable;
+ cs->mask = CLOCKSOURCE_MASK(32);
+ cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+ pr_info("sh_tmu: %s used as clock source\n", cs->name);
+ clocksource_register(cs);
+ return 0;
+}
+
+static struct sh_tmu_priv *ced_to_sh_tmu(struct clock_event_device *ced)
+{
+ return container_of(ced, struct sh_tmu_priv, ced);
+}
+
+static void sh_tmu_clock_event_start(struct sh_tmu_priv *p, int periodic)
+{
+ struct clock_event_device *ced = &p->ced;
+
+ sh_tmu_enable(p);
+
+ /* TODO: calculate good shift from rate and counter bit width */
+
+ ced->shift = 32;
+ ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift);
+ ced->max_delta_ns = clockevent_delta2ns(0xffffffff, ced);
+ ced->min_delta_ns = 5000;
+
+ if (periodic) {
+ p->periodic = (p->rate + HZ/2) / HZ;
+ sh_tmu_set_next(p, p->periodic, 1);
+ }
+}
+
+static void sh_tmu_clock_event_mode(enum clock_event_mode mode,
+ struct clock_event_device *ced)
+{
+ struct sh_tmu_priv *p = ced_to_sh_tmu(ced);
+ int disabled = 0;
+
+ /* deal with old setting first */
+ switch (ced->mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ case CLOCK_EVT_MODE_ONESHOT:
+ sh_tmu_disable(p);
+ disabled = 1;
+ break;
+ default:
+ break;
+ }
+
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ pr_info("sh_tmu: %s used for periodic clock events\n",
+ ced->name);
+ sh_tmu_clock_event_start(p, 1);
+ break;
+ case CLOCK_EVT_MODE_ONESHOT:
+ pr_info("sh_tmu: %s used for oneshot clock events\n",
+ ced->name);
+ sh_tmu_clock_event_start(p, 0);
+ break;
+ case CLOCK_EVT_MODE_UNUSED:
+ if (!disabled)
+ sh_tmu_disable(p);
+ break;
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ default:
+ break;
+ }
+}
+
+static int sh_tmu_clock_event_next(unsigned long delta,
+ struct clock_event_device *ced)
+{
+ struct sh_tmu_priv *p = ced_to_sh_tmu(ced);
+
+ BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT);
+
+ /* program new delta value */
+ sh_tmu_set_next(p, delta, 0);
+ return 0;
+}
+
+static void sh_tmu_register_clockevent(struct sh_tmu_priv *p,
+ char *name, unsigned long rating)
+{
+ struct clock_event_device *ced = &p->ced;
+ int ret;
+
+ memset(ced, 0, sizeof(*ced));
+
+ ced->name = name;
+ ced->features = CLOCK_EVT_FEAT_PERIODIC;
+ ced->features |= CLOCK_EVT_FEAT_ONESHOT;
+ ced->rating = rating;
+ ced->cpumask = cpumask_of(0);
+ ced->set_next_event = sh_tmu_clock_event_next;
+ ced->set_mode = sh_tmu_clock_event_mode;
+
+ ret = setup_irq(p->irqaction.irq, &p->irqaction);
+ if (ret) {
+ pr_err("sh_tmu: failed to request irq %d\n",
+ p->irqaction.irq);
+ return;
+ }
+
+ pr_info("sh_tmu: %s used for clock events\n", ced->name);
+ clockevents_register_device(ced);
+}
+
+static int sh_tmu_register(struct sh_tmu_priv *p, char *name,
+ unsigned long clockevent_rating,
+ unsigned long clocksource_rating)
+{
+ if (clockevent_rating)
+ sh_tmu_register_clockevent(p, name, clockevent_rating);
+ else if (clocksource_rating)
+ sh_tmu_register_clocksource(p, name, clocksource_rating);
+
+ return 0;
+}
+
+static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
+{
+ struct sh_timer_config *cfg = pdev->dev.platform_data;
+ struct resource *res;
+ int irq, ret;
+ ret = -ENXIO;
+
+ memset(p, 0, sizeof(*p));
+ p->pdev = pdev;
+
+ if (!cfg) {
+ dev_err(&p->pdev->dev, "missing platform data\n");
+ goto err0;
+ }
+
+ platform_set_drvdata(pdev, p);
+
+ res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&p->pdev->dev, "failed to get I/O memory\n");
+ goto err0;
+ }
+
+ irq = platform_get_irq(p->pdev, 0);
+ if (irq < 0) {
+ dev_err(&p->pdev->dev, "failed to get irq\n");
+ goto err0;
+ }
+
+ /* map memory, let mapbase point to our channel */
+ p->mapbase = ioremap_nocache(res->start, resource_size(res));
+ if (p->mapbase == NULL) {
+ pr_err("sh_tmu: failed to remap I/O memory\n");
+ goto err0;
+ }
+
+ /* setup data for setup_irq() (too early for request_irq()) */
+ p->irqaction.name = cfg->name;
+ p->irqaction.handler = sh_tmu_interrupt;
+ p->irqaction.dev_id = p;
+ p->irqaction.irq = irq;
+ p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
+ p->irqaction.mask = CPU_MASK_NONE;
+
+ /* get hold of clock */
+ p->clk = clk_get(&p->pdev->dev, cfg->clk);
+ if (IS_ERR(p->clk)) {
+ pr_err("sh_tmu: cannot get clock \"%s\"\n", cfg->clk);
+ ret = PTR_ERR(p->clk);
+ goto err1;
+ }
+
+ return sh_tmu_register(p, cfg->name,
+ cfg->clockevent_rating,
+ cfg->clocksource_rating);
+ err1:
+ iounmap(p->mapbase);
+ err0:
+ return ret;
+}
+
+static int __devinit sh_tmu_probe(struct platform_device *pdev)
+{
+ struct sh_tmu_priv *p = platform_get_drvdata(pdev);
+ struct sh_timer_config *cfg = pdev->dev.platform_data;
+ int ret;
+
+ if (p) {
+ pr_info("sh_tmu: %s kept as earlytimer\n", cfg->name);
+ return 0;
+ }
+
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
+ if (p == NULL) {
+ dev_err(&pdev->dev, "failed to allocate driver data\n");
+ return -ENOMEM;
+ }
+
+ ret = sh_tmu_setup(p, pdev);
+ if (ret) {
+ kfree(p);
+ platform_set_drvdata(pdev, NULL);
+ }
+ return ret;
+}
+
+static int __devexit sh_tmu_remove(struct platform_device *pdev)
+{
+ return -EBUSY; /* cannot unregister clockevent and clocksource */
+}
+
+static struct platform_driver sh_tmu_device_driver = {
+ .probe = sh_tmu_probe,
+ .remove = __devexit_p(sh_tmu_remove),
+ .driver = {
+ .name = "sh_tmu",
+ }
+};
+
+static int __init sh_tmu_init(void)
+{
+ return platform_driver_register(&sh_tmu_device_driver);
+}
+
+static void __exit sh_tmu_exit(void)
+{
+ platform_driver_unregister(&sh_tmu_device_driver);
+}
+
+early_platform_init("earlytimer", &sh_tmu_device_driver);
+module_init(sh_tmu_init);
+module_exit(sh_tmu_exit);
+
+MODULE_AUTHOR("Magnus Damm");
+MODULE_DESCRIPTION("SuperH TMU Timer Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d270e8eb3e67..47d2ad0ae079 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1070,11 +1070,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif
+ unlock_policy_rwsem_write(cpu);
+
if (cpufreq_driver->target)
__cpufreq_governor(data, CPUFREQ_GOV_STOP);
- unlock_policy_rwsem_write(cpu);
-
kobject_put(&data->kobj);
/* we need to make sure that the underlying kobj is actually
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 2ecd95e4ab1a..7fc58af748b4 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -42,27 +42,12 @@
* this governor will not work.
* All times here are in uS.
*/
-static unsigned int def_sampling_rate;
#define MIN_SAMPLING_RATE_RATIO (2)
-/* for correct statistics, we need at least 10 ticks between each measure */
-#define MIN_STAT_SAMPLING_RATE \
- (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
-#define MIN_SAMPLING_RATE \
- (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
-/* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon
- * Define the minimal settable sampling rate to the greater of:
- * - "HW transition latency" * 100 (same as default sampling / 10)
- * - MIN_STAT_SAMPLING_RATE
- * To avoid that userspace shoots itself.
-*/
-static unsigned int minimum_sampling_rate(void)
-{
- return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE);
-}
-/* This will also vanish soon with removing sampling_rate_max */
-#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
+static unsigned int min_sampling_rate;
+
#define LATENCY_MULTIPLIER (1000)
+#define MIN_LATENCY_MULTIPLIER (100)
#define DEF_SAMPLING_DOWN_FACTOR (1)
#define MAX_SAMPLING_DOWN_FACTOR (10)
#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
@@ -91,6 +76,9 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
* (like __cpufreq_driver_target()) is being called with dbs_mutex taken, then
* cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock
* is recursive for the same process. -Venki
+ * DEADLOCK ALERT! (2) : do_dbs_timer() must not take the dbs_mutex, because it
+ * would deadlock with cancel_delayed_work_sync(), which is needed for proper
+ * raceless workqueue teardown.
*/
static DEFINE_MUTEX(dbs_mutex);
@@ -179,27 +167,14 @@ static struct notifier_block dbs_cpufreq_notifier_block = {
/************************** sysfs interface ************************/
static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf)
{
- static int print_once;
-
- if (!print_once) {
- printk(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
- "sysfs file is deprecated - used by: %s\n",
- current->comm);
- print_once = 1;
- }
- return sprintf(buf, "%u\n", MAX_SAMPLING_RATE);
+ printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
+ "sysfs file is deprecated - used by: %s\n", current->comm);
+ return sprintf(buf, "%u\n", -1U);
}
static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
{
- static int print_once;
-
- if (!print_once) {
- printk(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
- "sysfs file is deprecated - used by: %s\n", current->comm);
- print_once = 1;
- }
- return sprintf(buf, "%u\n", MIN_SAMPLING_RATE);
+ return sprintf(buf, "%u\n", min_sampling_rate);
}
#define define_one_ro(_name) \
@@ -251,7 +226,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
return -EINVAL;
mutex_lock(&dbs_mutex);
- dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate());
+ dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate);
mutex_unlock(&dbs_mutex);
return count;
@@ -542,7 +517,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
{
dbs_info->enable = 0;
- cancel_delayed_work(&dbs_info->work);
+ cancel_delayed_work_sync(&dbs_info->work);
}
static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
@@ -598,11 +573,18 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
if (latency == 0)
latency = 1;
- def_sampling_rate =
- max(latency * LATENCY_MULTIPLIER,
- MIN_STAT_SAMPLING_RATE);
-
- dbs_tuners_ins.sampling_rate = def_sampling_rate;
+ /*
+ * conservative does not implement micro like ondemand
+ * governor, thus we are bound to jiffes/HZ
+ */
+ min_sampling_rate =
+ MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
+ /* Bring kernel and HW constraints together */
+ min_sampling_rate = max(min_sampling_rate,
+ MIN_LATENCY_MULTIPLIER * latency);
+ dbs_tuners_ins.sampling_rate =
+ max(min_sampling_rate,
+ latency * LATENCY_MULTIPLIER);
cpufreq_register_notifier(
&dbs_cpufreq_notifier_block,
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 338f428a15b7..1911d1729353 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -32,6 +32,7 @@
#define DEF_FREQUENCY_UP_THRESHOLD (80)
#define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3)
#define MICRO_FREQUENCY_UP_THRESHOLD (95)
+#define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000)
#define MIN_FREQUENCY_UP_THRESHOLD (11)
#define MAX_FREQUENCY_UP_THRESHOLD (100)
@@ -45,27 +46,12 @@
* this governor will not work.
* All times here are in uS.
*/
-static unsigned int def_sampling_rate;
#define MIN_SAMPLING_RATE_RATIO (2)
-/* for correct statistics, we need at least 10 ticks between each measure */
-#define MIN_STAT_SAMPLING_RATE \
- (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
-#define MIN_SAMPLING_RATE \
- (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
-/* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon
- * Define the minimal settable sampling rate to the greater of:
- * - "HW transition latency" * 100 (same as default sampling / 10)
- * - MIN_STAT_SAMPLING_RATE
- * To avoid that userspace shoots itself.
-*/
-static unsigned int minimum_sampling_rate(void)
-{
- return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE);
-}
-/* This will also vanish soon with removing sampling_rate_max */
-#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
+static unsigned int min_sampling_rate;
+
#define LATENCY_MULTIPLIER (1000)
+#define MIN_LATENCY_MULTIPLIER (100)
#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
static void do_dbs_timer(struct work_struct *work);
@@ -98,6 +84,9 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
* (like __cpufreq_driver_target()) is being called with dbs_mutex taken, then
* cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock
* is recursive for the same process. -Venki
+ * DEADLOCK ALERT! (2) : do_dbs_timer() must not take the dbs_mutex, because it
+ * would deadlock with cancel_delayed_work_sync(), which is needed for proper
+ * raceless workqueue teardown.
*/
static DEFINE_MUTEX(dbs_mutex);
@@ -216,28 +205,14 @@ static void ondemand_powersave_bias_init(void)
/************************** sysfs interface ************************/
static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf)
{
- static int print_once;
-
- if (!print_once) {
- printk(KERN_INFO "CPUFREQ: ondemand sampling_rate_max "
- "sysfs file is deprecated - used by: %s\n",
- current->comm);
- print_once = 1;
- }
- return sprintf(buf, "%u\n", MAX_SAMPLING_RATE);
+ printk_once(KERN_INFO "CPUFREQ: ondemand sampling_rate_max "
+ "sysfs file is deprecated - used by: %s\n", current->comm);
+ return sprintf(buf, "%u\n", -1U);
}
static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
{
- static int print_once;
-
- if (!print_once) {
- printk(KERN_INFO "CPUFREQ: ondemand sampling_rate_min "
- "sysfs file is deprecated - used by: %s\n",
- current->comm);
- print_once = 1;
- }
- return sprintf(buf, "%u\n", MIN_SAMPLING_RATE);
+ return sprintf(buf, "%u\n", min_sampling_rate);
}
#define define_one_ro(_name) \
@@ -271,7 +246,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
mutex_unlock(&dbs_mutex);
return -EINVAL;
}
- dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate());
+ dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate);
mutex_unlock(&dbs_mutex);
return count;
@@ -562,7 +537,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
{
dbs_info->enable = 0;
- cancel_delayed_work(&dbs_info->work);
+ cancel_delayed_work_sync(&dbs_info->work);
}
static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
@@ -616,12 +591,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
latency = policy->cpuinfo.transition_latency / 1000;
if (latency == 0)
latency = 1;
-
- def_sampling_rate =
- max(latency * LATENCY_MULTIPLIER,
- MIN_STAT_SAMPLING_RATE);
-
- dbs_tuners_ins.sampling_rate = def_sampling_rate;
+ /* Bring kernel and HW constraints together */
+ min_sampling_rate = max(min_sampling_rate,
+ MIN_LATENCY_MULTIPLIER * latency);
+ dbs_tuners_ins.sampling_rate =
+ max(min_sampling_rate,
+ latency * LATENCY_MULTIPLIER);
}
dbs_timer_init(this_dbs_info);
@@ -675,6 +650,16 @@ static int __init cpufreq_gov_dbs_init(void)
dbs_tuners_ins.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
dbs_tuners_ins.down_differential =
MICRO_FREQUENCY_DOWN_DIFFERENTIAL;
+ /*
+ * In no_hz/micro accounting case we set the minimum frequency
+ * not depending on HZ, but fixed (very low). The deferred
+ * timer might skip some samples if idle/sleeping as needed.
+ */
+ min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE;
+ } else {
+ /* For correct statistics, we need 10 ticks for each measure */
+ min_sampling_rate =
+ MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
}
kondemand_wq = create_workqueue("kondemand");
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 01afd758072f..e748e55bd86b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -12,7 +12,7 @@ if CRYPTO_HW
config CRYPTO_DEV_PADLOCK
tristate "Support for VIA PadLock ACE"
- depends on X86_32 && !UML
+ depends on X86 && !UML
select CRYPTO_ALGAPI
help
Some VIA processors come with an integrated crypto engine
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 856b3cc25583..87f92c39b5f0 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -154,7 +154,11 @@ static inline void padlock_reset_key(struct cword *cword)
int cpu = raw_smp_processor_id();
if (cword != per_cpu(last_cword, cpu))
+#ifndef CONFIG_X86_64
asm volatile ("pushfl; popfl");
+#else
+ asm volatile ("pushfq; popfq");
+#endif
}
static inline void padlock_store_cword(struct cword *cword)
@@ -208,10 +212,19 @@ static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key,
asm volatile ("test $1, %%cl;"
"je 1f;"
+#ifndef CONFIG_X86_64
"lea -1(%%ecx), %%eax;"
"mov $1, %%ecx;"
+#else
+ "lea -1(%%rcx), %%rax;"
+ "mov $1, %%rcx;"
+#endif
".byte 0xf3,0x0f,0xa7,0xc8;" /* rep xcryptecb */
+#ifndef CONFIG_X86_64
"mov %%eax, %%ecx;"
+#else
+ "mov %%rax, %%rcx;"
+#endif
"1:"
".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */
: "+S"(input), "+D"(output)
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index a3918c16b3db..c70775fd3ce2 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -44,6 +44,8 @@
#include <crypto/sha.h>
#include <crypto/aead.h>
#include <crypto/authenc.h>
+#include <crypto/skcipher.h>
+#include <crypto/scatterwalk.h>
#include "talitos.h"
@@ -339,7 +341,8 @@ static void flush_channel(struct device *dev, int ch, int error, int reset_ch)
status = error;
dma_unmap_single(dev, request->dma_desc,
- sizeof(struct talitos_desc), DMA_BIDIRECTIONAL);
+ sizeof(struct talitos_desc),
+ DMA_BIDIRECTIONAL);
/* copy entries so we can call callback outside lock */
saved_req.desc = request->desc;
@@ -413,7 +416,8 @@ static struct talitos_desc *current_desc(struct device *dev, int ch)
/*
* user diagnostics; report root cause of error based on execution unit status
*/
-static void report_eu_error(struct device *dev, int ch, struct talitos_desc *desc)
+static void report_eu_error(struct device *dev, int ch,
+ struct talitos_desc *desc)
{
struct talitos_private *priv = dev_get_drvdata(dev);
int i;
@@ -684,8 +688,8 @@ struct talitos_ctx {
unsigned int authsize;
};
-static int aead_authenc_setauthsize(struct crypto_aead *authenc,
- unsigned int authsize)
+static int aead_setauthsize(struct crypto_aead *authenc,
+ unsigned int authsize)
{
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
@@ -694,8 +698,8 @@ static int aead_authenc_setauthsize(struct crypto_aead *authenc,
return 0;
}
-static int aead_authenc_setkey(struct crypto_aead *authenc,
- const u8 *key, unsigned int keylen)
+static int aead_setkey(struct crypto_aead *authenc,
+ const u8 *key, unsigned int keylen)
{
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
struct rtattr *rta = (void *)key;
@@ -740,7 +744,7 @@ badkey:
}
/*
- * ipsec_esp_edesc - s/w-extended ipsec_esp descriptor
+ * talitos_edesc - s/w-extended descriptor
* @src_nents: number of segments in input scatterlist
* @dst_nents: number of segments in output scatterlist
* @dma_len: length of dma mapped link_tbl space
@@ -752,17 +756,67 @@ badkey:
* is greater than 1, an integrity check value is concatenated to the end
* of link_tbl data
*/
-struct ipsec_esp_edesc {
+struct talitos_edesc {
int src_nents;
int dst_nents;
+ int src_is_chained;
+ int dst_is_chained;
int dma_len;
dma_addr_t dma_link_tbl;
struct talitos_desc desc;
struct talitos_ptr link_tbl[0];
};
+static int talitos_map_sg(struct device *dev, struct scatterlist *sg,
+ unsigned int nents, enum dma_data_direction dir,
+ int chained)
+{
+ if (unlikely(chained))
+ while (sg) {
+ dma_map_sg(dev, sg, 1, dir);
+ sg = scatterwalk_sg_next(sg);
+ }
+ else
+ dma_map_sg(dev, sg, nents, dir);
+ return nents;
+}
+
+static void talitos_unmap_sg_chain(struct device *dev, struct scatterlist *sg,
+ enum dma_data_direction dir)
+{
+ while (sg) {
+ dma_unmap_sg(dev, sg, 1, dir);
+ sg = scatterwalk_sg_next(sg);
+ }
+}
+
+static void talitos_sg_unmap(struct device *dev,
+ struct talitos_edesc *edesc,
+ struct scatterlist *src,
+ struct scatterlist *dst)
+{
+ unsigned int src_nents = edesc->src_nents ? : 1;
+ unsigned int dst_nents = edesc->dst_nents ? : 1;
+
+ if (src != dst) {
+ if (edesc->src_is_chained)
+ talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE);
+ else
+ dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE);
+
+ if (edesc->dst_is_chained)
+ talitos_unmap_sg_chain(dev, dst, DMA_FROM_DEVICE);
+ else
+ dma_unmap_sg(dev, dst, dst_nents, DMA_FROM_DEVICE);
+ } else
+ if (edesc->src_is_chained)
+ talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL);
+ else
+ dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL);
+}
+
static void ipsec_esp_unmap(struct device *dev,
- struct ipsec_esp_edesc *edesc,
+ struct talitos_edesc *edesc,
struct aead_request *areq)
{
unmap_single_talitos_ptr(dev, &edesc->desc.ptr[6], DMA_FROM_DEVICE);
@@ -772,15 +826,7 @@ static void ipsec_esp_unmap(struct device *dev,
dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE);
- if (areq->src != areq->dst) {
- dma_unmap_sg(dev, areq->src, edesc->src_nents ? : 1,
- DMA_TO_DEVICE);
- dma_unmap_sg(dev, areq->dst, edesc->dst_nents ? : 1,
- DMA_FROM_DEVICE);
- } else {
- dma_unmap_sg(dev, areq->src, edesc->src_nents ? : 1,
- DMA_BIDIRECTIONAL);
- }
+ talitos_sg_unmap(dev, edesc, areq->src, areq->dst);
if (edesc->dma_len)
dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len,
@@ -795,13 +841,14 @@ static void ipsec_esp_encrypt_done(struct device *dev,
int err)
{
struct aead_request *areq = context;
- struct ipsec_esp_edesc *edesc =
- container_of(desc, struct ipsec_esp_edesc, desc);
struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
+ struct talitos_edesc *edesc;
struct scatterlist *sg;
void *icvdata;
+ edesc = container_of(desc, struct talitos_edesc, desc);
+
ipsec_esp_unmap(dev, edesc, areq);
/* copy the generated ICV to dst */
@@ -819,17 +866,18 @@ static void ipsec_esp_encrypt_done(struct device *dev,
}
static void ipsec_esp_decrypt_swauth_done(struct device *dev,
- struct talitos_desc *desc, void *context,
- int err)
+ struct talitos_desc *desc,
+ void *context, int err)
{
struct aead_request *req = context;
- struct ipsec_esp_edesc *edesc =
- container_of(desc, struct ipsec_esp_edesc, desc);
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
+ struct talitos_edesc *edesc;
struct scatterlist *sg;
void *icvdata;
+ edesc = container_of(desc, struct talitos_edesc, desc);
+
ipsec_esp_unmap(dev, edesc, req);
if (!err) {
@@ -851,20 +899,20 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,
}
static void ipsec_esp_decrypt_hwauth_done(struct device *dev,
- struct talitos_desc *desc, void *context,
- int err)
+ struct talitos_desc *desc,
+ void *context, int err)
{
struct aead_request *req = context;
- struct ipsec_esp_edesc *edesc =
- container_of(desc, struct ipsec_esp_edesc, desc);
+ struct talitos_edesc *edesc;
+
+ edesc = container_of(desc, struct talitos_edesc, desc);
ipsec_esp_unmap(dev, edesc, req);
/* check ICV auth status */
- if (!err)
- if ((desc->hdr_lo & DESC_HDR_LO_ICCR1_MASK) !=
- DESC_HDR_LO_ICCR1_PASS)
- err = -EBADMSG;
+ if (!err && ((desc->hdr_lo & DESC_HDR_LO_ICCR1_MASK) !=
+ DESC_HDR_LO_ICCR1_PASS))
+ err = -EBADMSG;
kfree(edesc);
@@ -886,7 +934,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
link_tbl_ptr->j_extent = 0;
link_tbl_ptr++;
cryptlen -= sg_dma_len(sg);
- sg = sg_next(sg);
+ sg = scatterwalk_sg_next(sg);
}
/* adjust (decrease) last one (or two) entry's len to cryptlen */
@@ -910,7 +958,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
/*
* fill in and submit ipsec_esp descriptor
*/
-static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
+static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
u8 *giv, u64 seq,
void (*callback) (struct device *dev,
struct talitos_desc *desc,
@@ -952,32 +1000,31 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
desc->ptr[4].len = cpu_to_be16(cryptlen);
desc->ptr[4].j_extent = authsize;
- if (areq->src == areq->dst)
- sg_count = dma_map_sg(dev, areq->src, edesc->src_nents ? : 1,
- DMA_BIDIRECTIONAL);
- else
- sg_count = dma_map_sg(dev, areq->src, edesc->src_nents ? : 1,
- DMA_TO_DEVICE);
+ sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
+ (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
+ : DMA_TO_DEVICE,
+ edesc->src_is_chained);
if (sg_count == 1) {
desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->src));
} else {
sg_link_tbl_len = cryptlen;
- if ((edesc->desc.hdr & DESC_HDR_MODE1_MDEU_CICV) &&
- (edesc->desc.hdr & DESC_HDR_MODE0_ENCRYPT) == 0) {
+ if (edesc->desc.hdr & DESC_HDR_MODE1_MDEU_CICV)
sg_link_tbl_len = cryptlen + authsize;
- }
+
sg_count = sg_to_link_tbl(areq->src, sg_count, sg_link_tbl_len,
&edesc->link_tbl[0]);
if (sg_count > 1) {
desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP;
desc->ptr[4].ptr = cpu_to_be32(edesc->dma_link_tbl);
- dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl,
- edesc->dma_len, DMA_BIDIRECTIONAL);
+ dma_sync_single_for_device(dev, edesc->dma_link_tbl,
+ edesc->dma_len,
+ DMA_BIDIRECTIONAL);
} else {
/* Only one segment now, so no link tbl needed */
- desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->src));
+ desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->
+ src));
}
}
@@ -985,10 +1032,11 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
desc->ptr[5].len = cpu_to_be16(cryptlen);
desc->ptr[5].j_extent = authsize;
- if (areq->src != areq->dst) {
- sg_count = dma_map_sg(dev, areq->dst, edesc->dst_nents ? : 1,
- DMA_FROM_DEVICE);
- }
+ if (areq->src != areq->dst)
+ sg_count = talitos_map_sg(dev, areq->dst,
+ edesc->dst_nents ? : 1,
+ DMA_FROM_DEVICE,
+ edesc->dst_is_chained);
if (sg_count == 1) {
desc->ptr[5].ptr = cpu_to_be32(sg_dma_address(areq->dst));
@@ -1033,49 +1081,55 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
return ret;
}
-
/*
* derive number of elements in scatterlist
*/
-static int sg_count(struct scatterlist *sg_list, int nbytes)
+static int sg_count(struct scatterlist *sg_list, int nbytes, int *chained)
{
struct scatterlist *sg = sg_list;
int sg_nents = 0;
- while (nbytes) {
+ *chained = 0;
+ while (nbytes > 0) {
sg_nents++;
nbytes -= sg->length;
- sg = sg_next(sg);
+ if (!sg_is_last(sg) && (sg + 1)->length == 0)
+ *chained = 1;
+ sg = scatterwalk_sg_next(sg);
}
return sg_nents;
}
/*
- * allocate and map the ipsec_esp extended descriptor
+ * allocate and map the extended descriptor
*/
-static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq,
- int icv_stashing)
+static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
+ struct scatterlist *src,
+ struct scatterlist *dst,
+ unsigned int cryptlen,
+ unsigned int authsize,
+ int icv_stashing,
+ u32 cryptoflags)
{
- struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
- struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
- struct ipsec_esp_edesc *edesc;
+ struct talitos_edesc *edesc;
int src_nents, dst_nents, alloc_len, dma_len;
- gfp_t flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
+ int src_chained, dst_chained = 0;
+ gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
GFP_ATOMIC;
- if (areq->cryptlen + ctx->authsize > TALITOS_MAX_DATA_LEN) {
- dev_err(ctx->dev, "cryptlen exceeds h/w max limit\n");
+ if (cryptlen + authsize > TALITOS_MAX_DATA_LEN) {
+ dev_err(dev, "length exceeds h/w max limit\n");
return ERR_PTR(-EINVAL);
}
- src_nents = sg_count(areq->src, areq->cryptlen + ctx->authsize);
+ src_nents = sg_count(src, cryptlen + authsize, &src_chained);
src_nents = (src_nents == 1) ? 0 : src_nents;
- if (areq->dst == areq->src) {
+ if (dst == src) {
dst_nents = src_nents;
} else {
- dst_nents = sg_count(areq->dst, areq->cryptlen + ctx->authsize);
+ dst_nents = sg_count(dst, cryptlen + authsize, &dst_chained);
dst_nents = (dst_nents == 1) ? 0 : dst_nents;
}
@@ -1084,39 +1138,52 @@ static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq,
* allowing for two separate entries for ICV and generated ICV (+ 2),
* and the ICV data itself
*/
- alloc_len = sizeof(struct ipsec_esp_edesc);
+ alloc_len = sizeof(struct talitos_edesc);
if (src_nents || dst_nents) {
dma_len = (src_nents + dst_nents + 2) *
- sizeof(struct talitos_ptr) + ctx->authsize;
+ sizeof(struct talitos_ptr) + authsize;
alloc_len += dma_len;
} else {
dma_len = 0;
- alloc_len += icv_stashing ? ctx->authsize : 0;
+ alloc_len += icv_stashing ? authsize : 0;
}
edesc = kmalloc(alloc_len, GFP_DMA | flags);
if (!edesc) {
- dev_err(ctx->dev, "could not allocate edescriptor\n");
+ dev_err(dev, "could not allocate edescriptor\n");
return ERR_PTR(-ENOMEM);
}
edesc->src_nents = src_nents;
edesc->dst_nents = dst_nents;
+ edesc->src_is_chained = src_chained;
+ edesc->dst_is_chained = dst_chained;
edesc->dma_len = dma_len;
- edesc->dma_link_tbl = dma_map_single(ctx->dev, &edesc->link_tbl[0],
+ edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0],
edesc->dma_len, DMA_BIDIRECTIONAL);
return edesc;
}
-static int aead_authenc_encrypt(struct aead_request *req)
+static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq,
+ int icv_stashing)
+{
+ struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
+ struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
+
+ return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst,
+ areq->cryptlen, ctx->authsize, icv_stashing,
+ areq->base.flags);
+}
+
+static int aead_encrypt(struct aead_request *req)
{
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
- struct ipsec_esp_edesc *edesc;
+ struct talitos_edesc *edesc;
/* allocate extended descriptor */
- edesc = ipsec_esp_edesc_alloc(req, 0);
+ edesc = aead_edesc_alloc(req, 0);
if (IS_ERR(edesc))
return PTR_ERR(edesc);
@@ -1126,70 +1193,67 @@ static int aead_authenc_encrypt(struct aead_request *req)
return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done);
}
-
-
-static int aead_authenc_decrypt(struct aead_request *req)
+static int aead_decrypt(struct aead_request *req)
{
struct crypto_aead *authenc = crypto_aead_reqtfm(req);
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
unsigned int authsize = ctx->authsize;
struct talitos_private *priv = dev_get_drvdata(ctx->dev);
- struct ipsec_esp_edesc *edesc;
+ struct talitos_edesc *edesc;
struct scatterlist *sg;
void *icvdata;
req->cryptlen -= authsize;
/* allocate extended descriptor */
- edesc = ipsec_esp_edesc_alloc(req, 1);
+ edesc = aead_edesc_alloc(req, 1);
if (IS_ERR(edesc))
return PTR_ERR(edesc);
if ((priv->features & TALITOS_FTR_HW_AUTH_CHECK) &&
- (((!edesc->src_nents && !edesc->dst_nents) ||
- priv->features & TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT))) {
+ ((!edesc->src_nents && !edesc->dst_nents) ||
+ priv->features & TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT)) {
/* decrypt and check the ICV */
- edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND |
+ edesc->desc.hdr = ctx->desc_hdr_template |
+ DESC_HDR_DIR_INBOUND |
DESC_HDR_MODE1_MDEU_CICV;
/* reset integrity check result bits */
edesc->desc.hdr_lo = 0;
- return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_hwauth_done);
+ return ipsec_esp(edesc, req, NULL, 0,
+ ipsec_esp_decrypt_hwauth_done);
- } else {
-
- /* Have to check the ICV with software */
+ }
- edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND;
+ /* Have to check the ICV with software */
+ edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND;
- /* stash incoming ICV for later cmp with ICV generated by the h/w */
- if (edesc->dma_len)
- icvdata = &edesc->link_tbl[edesc->src_nents +
- edesc->dst_nents + 2];
- else
- icvdata = &edesc->link_tbl[0];
+ /* stash incoming ICV for later cmp with ICV generated by the h/w */
+ if (edesc->dma_len)
+ icvdata = &edesc->link_tbl[edesc->src_nents +
+ edesc->dst_nents + 2];
+ else
+ icvdata = &edesc->link_tbl[0];
- sg = sg_last(req->src, edesc->src_nents ? : 1);
+ sg = sg_last(req->src, edesc->src_nents ? : 1);
- memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize,
- ctx->authsize);
+ memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize,
+ ctx->authsize);
- return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done);
- }
+ return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done);
}
-static int aead_authenc_givencrypt(
- struct aead_givcrypt_request *req)
+static int aead_givencrypt(struct aead_givcrypt_request *req)
{
struct aead_request *areq = &req->areq;
struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
- struct ipsec_esp_edesc *edesc;
+ struct talitos_edesc *edesc;
/* allocate extended descriptor */
- edesc = ipsec_esp_edesc_alloc(areq, 0);
+ edesc = aead_edesc_alloc(areq, 0);
if (IS_ERR(edesc))
return PTR_ERR(edesc);
@@ -1204,31 +1268,228 @@ static int aead_authenc_givencrypt(
ipsec_esp_encrypt_done);
}
+static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
+ const u8 *key, unsigned int keylen)
+{
+ struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ struct ablkcipher_alg *alg = crypto_ablkcipher_alg(cipher);
+
+ if (keylen > TALITOS_MAX_KEY_SIZE)
+ goto badkey;
+
+ if (keylen < alg->min_keysize || keylen > alg->max_keysize)
+ goto badkey;
+
+ memcpy(&ctx->key, key, keylen);
+ ctx->keylen = keylen;
+
+ return 0;
+
+badkey:
+ crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
+ return -EINVAL;
+}
+
+static void common_nonsnoop_unmap(struct device *dev,
+ struct talitos_edesc *edesc,
+ struct ablkcipher_request *areq)
+{
+ unmap_single_talitos_ptr(dev, &edesc->desc.ptr[5], DMA_FROM_DEVICE);
+ unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE);
+ unmap_single_talitos_ptr(dev, &edesc->desc.ptr[1], DMA_TO_DEVICE);
+
+ talitos_sg_unmap(dev, edesc, areq->src, areq->dst);
+
+ if (edesc->dma_len)
+ dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len,
+ DMA_BIDIRECTIONAL);
+}
+
+static void ablkcipher_done(struct device *dev,
+ struct talitos_desc *desc, void *context,
+ int err)
+{
+ struct ablkcipher_request *areq = context;
+ struct talitos_edesc *edesc;
+
+ edesc = container_of(desc, struct talitos_edesc, desc);
+
+ common_nonsnoop_unmap(dev, edesc, areq);
+
+ kfree(edesc);
+
+ areq->base.complete(&areq->base, err);
+}
+
+static int common_nonsnoop(struct talitos_edesc *edesc,
+ struct ablkcipher_request *areq,
+ u8 *giv,
+ void (*callback) (struct device *dev,
+ struct talitos_desc *desc,
+ void *context, int error))
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ struct device *dev = ctx->dev;
+ struct talitos_desc *desc = &edesc->desc;
+ unsigned int cryptlen = areq->nbytes;
+ unsigned int ivsize;
+ int sg_count, ret;
+
+ /* first DWORD empty */
+ desc->ptr[0].len = 0;
+ desc->ptr[0].ptr = 0;
+ desc->ptr[0].j_extent = 0;
+
+ /* cipher iv */
+ ivsize = crypto_ablkcipher_ivsize(cipher);
+ map_single_talitos_ptr(dev, &desc->ptr[1], ivsize, giv ?: areq->info, 0,
+ DMA_TO_DEVICE);
+
+ /* cipher key */
+ map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen,
+ (char *)&ctx->key, 0, DMA_TO_DEVICE);
+
+ /*
+ * cipher in
+ */
+ desc->ptr[3].len = cpu_to_be16(cryptlen);
+ desc->ptr[3].j_extent = 0;
+
+ sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
+ (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
+ : DMA_TO_DEVICE,
+ edesc->src_is_chained);
+
+ if (sg_count == 1) {
+ desc->ptr[3].ptr = cpu_to_be32(sg_dma_address(areq->src));
+ } else {
+ sg_count = sg_to_link_tbl(areq->src, sg_count, cryptlen,
+ &edesc->link_tbl[0]);
+ if (sg_count > 1) {
+ desc->ptr[3].j_extent |= DESC_PTR_LNKTBL_JUMP;
+ desc->ptr[3].ptr = cpu_to_be32(edesc->dma_link_tbl);
+ dma_sync_single_for_device(dev, edesc->dma_link_tbl,
+ edesc->dma_len,
+ DMA_BIDIRECTIONAL);
+ } else {
+ /* Only one segment now, so no link tbl needed */
+ desc->ptr[3].ptr = cpu_to_be32(sg_dma_address(areq->
+ src));
+ }
+ }
+
+ /* cipher out */
+ desc->ptr[4].len = cpu_to_be16(cryptlen);
+ desc->ptr[4].j_extent = 0;
+
+ if (areq->src != areq->dst)
+ sg_count = talitos_map_sg(dev, areq->dst,
+ edesc->dst_nents ? : 1,
+ DMA_FROM_DEVICE,
+ edesc->dst_is_chained);
+
+ if (sg_count == 1) {
+ desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->dst));
+ } else {
+ struct talitos_ptr *link_tbl_ptr =
+ &edesc->link_tbl[edesc->src_nents + 1];
+
+ desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP;
+ desc->ptr[4].ptr = cpu_to_be32((struct talitos_ptr *)
+ edesc->dma_link_tbl +
+ edesc->src_nents + 1);
+ sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen,
+ link_tbl_ptr);
+ dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl,
+ edesc->dma_len, DMA_BIDIRECTIONAL);
+ }
+
+ /* iv out */
+ map_single_talitos_ptr(dev, &desc->ptr[5], ivsize, ctx->iv, 0,
+ DMA_FROM_DEVICE);
+
+ /* last DWORD empty */
+ desc->ptr[6].len = 0;
+ desc->ptr[6].ptr = 0;
+ desc->ptr[6].j_extent = 0;
+
+ ret = talitos_submit(dev, desc, callback, areq);
+ if (ret != -EINPROGRESS) {
+ common_nonsnoop_unmap(dev, edesc, areq);
+ kfree(edesc);
+ }
+ return ret;
+}
+
+static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request *
+ areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, areq->nbytes,
+ 0, 0, areq->base.flags);
+}
+
+static int ablkcipher_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ struct talitos_edesc *edesc;
+
+ /* allocate extended descriptor */
+ edesc = ablkcipher_edesc_alloc(areq);
+ if (IS_ERR(edesc))
+ return PTR_ERR(edesc);
+
+ /* set encrypt */
+ edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT;
+
+ return common_nonsnoop(edesc, areq, NULL, ablkcipher_done);
+}
+
+static int ablkcipher_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ struct talitos_edesc *edesc;
+
+ /* allocate extended descriptor */
+ edesc = ablkcipher_edesc_alloc(areq);
+ if (IS_ERR(edesc))
+ return PTR_ERR(edesc);
+
+ edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND;
+
+ return common_nonsnoop(edesc, areq, NULL, ablkcipher_done);
+}
+
struct talitos_alg_template {
- char name[CRYPTO_MAX_ALG_NAME];
- char driver_name[CRYPTO_MAX_ALG_NAME];
- unsigned int blocksize;
- struct aead_alg aead;
- struct device *dev;
+ struct crypto_alg alg;
__be32 desc_hdr_template;
};
static struct talitos_alg_template driver_algs[] = {
- /* single-pass ipsec_esp descriptor */
+ /* AEAD algorithms. These use a single-pass ipsec_esp descriptor */
{
- .name = "authenc(hmac(sha1),cbc(aes))",
- .driver_name = "authenc-hmac-sha1-cbc-aes-talitos",
- .blocksize = AES_BLOCK_SIZE,
- .aead = {
- .setkey = aead_authenc_setkey,
- .setauthsize = aead_authenc_setauthsize,
- .encrypt = aead_authenc_encrypt,
- .decrypt = aead_authenc_decrypt,
- .givencrypt = aead_authenc_givencrypt,
- .geniv = "<built-in>",
- .ivsize = AES_BLOCK_SIZE,
- .maxauthsize = SHA1_DIGEST_SIZE,
- },
+ .alg = {
+ .cra_name = "authenc(hmac(sha1),cbc(aes))",
+ .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos",
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_aead_type,
+ .cra_aead = {
+ .setkey = aead_setkey,
+ .setauthsize = aead_setauthsize,
+ .encrypt = aead_encrypt,
+ .decrypt = aead_decrypt,
+ .givencrypt = aead_givencrypt,
+ .geniv = "<built-in>",
+ .ivsize = AES_BLOCK_SIZE,
+ .maxauthsize = SHA1_DIGEST_SIZE,
+ }
+ },
.desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
DESC_HDR_SEL0_AESU |
DESC_HDR_MODE0_AESU_CBC |
@@ -1238,19 +1499,23 @@ static struct talitos_alg_template driver_algs[] = {
DESC_HDR_MODE1_MDEU_SHA1_HMAC,
},
{
- .name = "authenc(hmac(sha1),cbc(des3_ede))",
- .driver_name = "authenc-hmac-sha1-cbc-3des-talitos",
- .blocksize = DES3_EDE_BLOCK_SIZE,
- .aead = {
- .setkey = aead_authenc_setkey,
- .setauthsize = aead_authenc_setauthsize,
- .encrypt = aead_authenc_encrypt,
- .decrypt = aead_authenc_decrypt,
- .givencrypt = aead_authenc_givencrypt,
- .geniv = "<built-in>",
- .ivsize = DES3_EDE_BLOCK_SIZE,
- .maxauthsize = SHA1_DIGEST_SIZE,
- },
+ .alg = {
+ .cra_name = "authenc(hmac(sha1),cbc(des3_ede))",
+ .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos",
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_aead_type,
+ .cra_aead = {
+ .setkey = aead_setkey,
+ .setauthsize = aead_setauthsize,
+ .encrypt = aead_encrypt,
+ .decrypt = aead_decrypt,
+ .givencrypt = aead_givencrypt,
+ .geniv = "<built-in>",
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ .maxauthsize = SHA1_DIGEST_SIZE,
+ }
+ },
.desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
DESC_HDR_SEL0_DEU |
DESC_HDR_MODE0_DEU_CBC |
@@ -1261,19 +1526,23 @@ static struct talitos_alg_template driver_algs[] = {
DESC_HDR_MODE1_MDEU_SHA1_HMAC,
},
{
- .name = "authenc(hmac(sha256),cbc(aes))",
- .driver_name = "authenc-hmac-sha256-cbc-aes-talitos",
- .blocksize = AES_BLOCK_SIZE,
- .aead = {
- .setkey = aead_authenc_setkey,
- .setauthsize = aead_authenc_setauthsize,
- .encrypt = aead_authenc_encrypt,
- .decrypt = aead_authenc_decrypt,
- .givencrypt = aead_authenc_givencrypt,
- .geniv = "<built-in>",
- .ivsize = AES_BLOCK_SIZE,
- .maxauthsize = SHA256_DIGEST_SIZE,
- },
+ .alg = {
+ .cra_name = "authenc(hmac(sha256),cbc(aes))",
+ .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos",
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_aead_type,
+ .cra_aead = {
+ .setkey = aead_setkey,
+ .setauthsize = aead_setauthsize,
+ .encrypt = aead_encrypt,
+ .decrypt = aead_decrypt,
+ .givencrypt = aead_givencrypt,
+ .geniv = "<built-in>",
+ .ivsize = AES_BLOCK_SIZE,
+ .maxauthsize = SHA256_DIGEST_SIZE,
+ }
+ },
.desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
DESC_HDR_SEL0_AESU |
DESC_HDR_MODE0_AESU_CBC |
@@ -1283,19 +1552,23 @@ static struct talitos_alg_template driver_algs[] = {
DESC_HDR_MODE1_MDEU_SHA256_HMAC,
},
{
- .name = "authenc(hmac(sha256),cbc(des3_ede))",
- .driver_name = "authenc-hmac-sha256-cbc-3des-talitos",
- .blocksize = DES3_EDE_BLOCK_SIZE,
- .aead = {
- .setkey = aead_authenc_setkey,
- .setauthsize = aead_authenc_setauthsize,
- .encrypt = aead_authenc_encrypt,
- .decrypt = aead_authenc_decrypt,
- .givencrypt = aead_authenc_givencrypt,
- .geniv = "<built-in>",
- .ivsize = DES3_EDE_BLOCK_SIZE,
- .maxauthsize = SHA256_DIGEST_SIZE,
- },
+ .alg = {
+ .cra_name = "authenc(hmac(sha256),cbc(des3_ede))",
+ .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos",
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_aead_type,
+ .cra_aead = {
+ .setkey = aead_setkey,
+ .setauthsize = aead_setauthsize,
+ .encrypt = aead_encrypt,
+ .decrypt = aead_decrypt,
+ .givencrypt = aead_givencrypt,
+ .geniv = "<built-in>",
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ .maxauthsize = SHA256_DIGEST_SIZE,
+ }
+ },
.desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
DESC_HDR_SEL0_DEU |
DESC_HDR_MODE0_DEU_CBC |
@@ -1306,19 +1579,23 @@ static struct talitos_alg_template driver_algs[] = {
DESC_HDR_MODE1_MDEU_SHA256_HMAC,
},
{
- .name = "authenc(hmac(md5),cbc(aes))",
- .driver_name = "authenc-hmac-md5-cbc-aes-talitos",
- .blocksize = AES_BLOCK_SIZE,
- .aead = {
- .setkey = aead_authenc_setkey,
- .setauthsize = aead_authenc_setauthsize,
- .encrypt = aead_authenc_encrypt,
- .decrypt = aead_authenc_decrypt,
- .givencrypt = aead_authenc_givencrypt,
- .geniv = "<built-in>",
- .ivsize = AES_BLOCK_SIZE,
- .maxauthsize = MD5_DIGEST_SIZE,
- },
+ .alg = {
+ .cra_name = "authenc(hmac(md5),cbc(aes))",
+ .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos",
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_aead_type,
+ .cra_aead = {
+ .setkey = aead_setkey,
+ .setauthsize = aead_setauthsize,
+ .encrypt = aead_encrypt,
+ .decrypt = aead_decrypt,
+ .givencrypt = aead_givencrypt,
+ .geniv = "<built-in>",
+ .ivsize = AES_BLOCK_SIZE,
+ .maxauthsize = MD5_DIGEST_SIZE,
+ }
+ },
.desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
DESC_HDR_SEL0_AESU |
DESC_HDR_MODE0_AESU_CBC |
@@ -1328,19 +1605,23 @@ static struct talitos_alg_template driver_algs[] = {
DESC_HDR_MODE1_MDEU_MD5_HMAC,
},
{
- .name = "authenc(hmac(md5),cbc(des3_ede))",
- .driver_name = "authenc-hmac-md5-cbc-3des-talitos",
- .blocksize = DES3_EDE_BLOCK_SIZE,
- .aead = {
- .setkey = aead_authenc_setkey,
- .setauthsize = aead_authenc_setauthsize,
- .encrypt = aead_authenc_encrypt,
- .decrypt = aead_authenc_decrypt,
- .givencrypt = aead_authenc_givencrypt,
- .geniv = "<built-in>",
- .ivsize = DES3_EDE_BLOCK_SIZE,
- .maxauthsize = MD5_DIGEST_SIZE,
- },
+ .alg = {
+ .cra_name = "authenc(hmac(md5),cbc(des3_ede))",
+ .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos",
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_aead_type,
+ .cra_aead = {
+ .setkey = aead_setkey,
+ .setauthsize = aead_setauthsize,
+ .encrypt = aead_encrypt,
+ .decrypt = aead_decrypt,
+ .givencrypt = aead_givencrypt,
+ .geniv = "<built-in>",
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ .maxauthsize = MD5_DIGEST_SIZE,
+ }
+ },
.desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
DESC_HDR_SEL0_DEU |
DESC_HDR_MODE0_DEU_CBC |
@@ -1349,6 +1630,52 @@ static struct talitos_alg_template driver_algs[] = {
DESC_HDR_MODE1_MDEU_INIT |
DESC_HDR_MODE1_MDEU_PAD |
DESC_HDR_MODE1_MDEU_MD5_HMAC,
+ },
+ /* ABLKCIPHER algorithms. */
+ {
+ .alg = {
+ .cra_name = "cbc(aes)",
+ .cra_driver_name = "cbc-aes-talitos",
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+ CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_ablkcipher = {
+ .setkey = ablkcipher_setkey,
+ .encrypt = ablkcipher_encrypt,
+ .decrypt = ablkcipher_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ },
+ .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+ DESC_HDR_SEL0_AESU |
+ DESC_HDR_MODE0_AESU_CBC,
+ },
+ {
+ .alg = {
+ .cra_name = "cbc(des3_ede)",
+ .cra_driver_name = "cbc-3des-talitos",
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+ CRYPTO_ALG_ASYNC,
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_ablkcipher = {
+ .setkey = ablkcipher_setkey,
+ .encrypt = ablkcipher_encrypt,
+ .decrypt = ablkcipher_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ },
+ .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+ DESC_HDR_SEL0_DEU |
+ DESC_HDR_MODE0_DEU_CBC |
+ DESC_HDR_MODE0_DEU_3DES,
}
};
@@ -1362,12 +1689,14 @@ struct talitos_crypto_alg {
static int talitos_cra_init(struct crypto_tfm *tfm)
{
struct crypto_alg *alg = tfm->__crt_alg;
- struct talitos_crypto_alg *talitos_alg =
- container_of(alg, struct talitos_crypto_alg, crypto_alg);
+ struct talitos_crypto_alg *talitos_alg;
struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
+ talitos_alg = container_of(alg, struct talitos_crypto_alg, crypto_alg);
+
/* update context with ptr to dev */
ctx->dev = talitos_alg->dev;
+
/* copy descriptor header template value */
ctx->desc_hdr_template = talitos_alg->desc_hdr_template;
@@ -1453,19 +1782,13 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
return ERR_PTR(-ENOMEM);
alg = &t_alg->crypto_alg;
+ *alg = template->alg;
- snprintf(alg->cra_name, CRYPTO_MAX_ALG_NAME, "%s", template->name);
- snprintf(alg->cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s",
- template->driver_name);
alg->cra_module = THIS_MODULE;
alg->cra_init = talitos_cra_init;
alg->cra_priority = TALITOS_CRA_PRIORITY;
- alg->cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC;
- alg->cra_blocksize = template->blocksize;
alg->cra_alignmask = 0;
- alg->cra_type = &crypto_aead_type;
alg->cra_ctxsize = sizeof(struct talitos_ctx);
- alg->cra_u.aead = template->aead;
t_alg->desc_hdr_template = template->desc_hdr_template;
t_alg->dev = dev;
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 3b3c01b6f1ee..070357aaedbc 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -81,6 +81,14 @@ config MX3_IPU_IRQS
To avoid bloating the irq_desc[] array we allocate a sufficient
number of IRQ slots and map them dynamically to specific sources.
+config TXX9_DMAC
+ tristate "Toshiba TXx9 SoC DMA support"
+ depends on MACH_TX49XX || MACH_TX39XX
+ select DMA_ENGINE
+ help
+ Support the TXx9 SoC internal DMA controller. This can be
+ integrated in chips such as the Toshiba TX4927/38/39.
+
config DMA_ENGINE
bool
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 2e5dc96700d2..a0b6564800c4 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_FSL_DMA) += fsldma.o
obj-$(CONFIG_MV_XOR) += mv_xor.o
obj-$(CONFIG_DW_DMAC) += dw_dmac.o
obj-$(CONFIG_MX3_IPU) += ipu/
+obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index da8a8ed9e411..66a7687cca73 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -622,8 +622,8 @@ static void fsl_chan_xfer_ld_queue(struct fsl_dma_chan *fsl_chan)
if (ld_node != &fsl_chan->ld_queue) {
/* Get the ld start address from ld_queue */
next_dest_addr = to_fsl_desc(ld_node)->async_tx.phys;
- dev_dbg(fsl_chan->dev, "xfer LDs staring from %p\n",
- (void *)next_dest_addr);
+ dev_dbg(fsl_chan->dev, "xfer LDs staring from 0x%llx\n",
+ (unsigned long long)next_dest_addr);
set_cdar(fsl_chan, next_dest_addr);
dma_start(fsl_chan);
} else {
@@ -734,8 +734,9 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
*/
if (stat & FSL_DMA_SR_EOSI) {
dev_dbg(fsl_chan->dev, "event: End-of-segments INT\n");
- dev_dbg(fsl_chan->dev, "event: clndar %p, nlndar %p\n",
- (void *)get_cdar(fsl_chan), (void *)get_ndar(fsl_chan));
+ dev_dbg(fsl_chan->dev, "event: clndar 0x%llx, nlndar 0x%llx\n",
+ (unsigned long long)get_cdar(fsl_chan),
+ (unsigned long long)get_ndar(fsl_chan));
stat &= ~FSL_DMA_SR_EOSI;
update_cookie = 1;
}
@@ -925,8 +926,8 @@ static int __devinit of_fsl_dma_probe(struct of_device *dev,
}
dev_info(&dev->dev, "Probe the Freescale DMA driver for %s "
- "controller at %p...\n",
- match->compatible, (void *)fdev->reg.start);
+ "controller at 0x%llx...\n",
+ match->compatible, (unsigned long long)fdev->reg.start);
fdev->reg_base = ioremap(fdev->reg.start, fdev->reg.end
- fdev->reg.start + 1);
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c
new file mode 100644
index 000000000000..9aa9ea9822c8
--- /dev/null
+++ b/drivers/dma/txx9dmac.c
@@ -0,0 +1,1354 @@
+/*
+ * Driver for the TXx9 SoC DMA Controller
+ *
+ * Copyright (C) 2009 Atsushi Nemoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/dma-mapping.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/scatterlist.h>
+#include "txx9dmac.h"
+
+static struct txx9dmac_chan *to_txx9dmac_chan(struct dma_chan *chan)
+{
+ return container_of(chan, struct txx9dmac_chan, chan);
+}
+
+static struct txx9dmac_cregs __iomem *__dma_regs(const struct txx9dmac_chan *dc)
+{
+ return dc->ch_regs;
+}
+
+static struct txx9dmac_cregs32 __iomem *__dma_regs32(
+ const struct txx9dmac_chan *dc)
+{
+ return dc->ch_regs;
+}
+
+#define channel64_readq(dc, name) \
+ __raw_readq(&(__dma_regs(dc)->name))
+#define channel64_writeq(dc, name, val) \
+ __raw_writeq((val), &(__dma_regs(dc)->name))
+#define channel64_readl(dc, name) \
+ __raw_readl(&(__dma_regs(dc)->name))
+#define channel64_writel(dc, name, val) \
+ __raw_writel((val), &(__dma_regs(dc)->name))
+
+#define channel32_readl(dc, name) \
+ __raw_readl(&(__dma_regs32(dc)->name))
+#define channel32_writel(dc, name, val) \
+ __raw_writel((val), &(__dma_regs32(dc)->name))
+
+#define channel_readq(dc, name) channel64_readq(dc, name)
+#define channel_writeq(dc, name, val) channel64_writeq(dc, name, val)
+#define channel_readl(dc, name) \
+ (is_dmac64(dc) ? \
+ channel64_readl(dc, name) : channel32_readl(dc, name))
+#define channel_writel(dc, name, val) \
+ (is_dmac64(dc) ? \
+ channel64_writel(dc, name, val) : channel32_writel(dc, name, val))
+
+static dma_addr_t channel64_read_CHAR(const struct txx9dmac_chan *dc)
+{
+ if (sizeof(__dma_regs(dc)->CHAR) == sizeof(u64))
+ return channel64_readq(dc, CHAR);
+ else
+ return channel64_readl(dc, CHAR);
+}
+
+static void channel64_write_CHAR(const struct txx9dmac_chan *dc, dma_addr_t val)
+{
+ if (sizeof(__dma_regs(dc)->CHAR) == sizeof(u64))
+ channel64_writeq(dc, CHAR, val);
+ else
+ channel64_writel(dc, CHAR, val);
+}
+
+static void channel64_clear_CHAR(const struct txx9dmac_chan *dc)
+{
+#if defined(CONFIG_32BIT) && !defined(CONFIG_64BIT_PHYS_ADDR)
+ channel64_writel(dc, CHAR, 0);
+ channel64_writel(dc, __pad_CHAR, 0);
+#else
+ channel64_writeq(dc, CHAR, 0);
+#endif
+}
+
+static dma_addr_t channel_read_CHAR(const struct txx9dmac_chan *dc)
+{
+ if (is_dmac64(dc))
+ return channel64_read_CHAR(dc);
+ else
+ return channel32_readl(dc, CHAR);
+}
+
+static void channel_write_CHAR(const struct txx9dmac_chan *dc, dma_addr_t val)
+{
+ if (is_dmac64(dc))
+ channel64_write_CHAR(dc, val);
+ else
+ channel32_writel(dc, CHAR, val);
+}
+
+static struct txx9dmac_regs __iomem *__txx9dmac_regs(
+ const struct txx9dmac_dev *ddev)
+{
+ return ddev->regs;
+}
+
+static struct txx9dmac_regs32 __iomem *__txx9dmac_regs32(
+ const struct txx9dmac_dev *ddev)
+{
+ return ddev->regs;
+}
+
+#define dma64_readl(ddev, name) \
+ __raw_readl(&(__txx9dmac_regs(ddev)->name))
+#define dma64_writel(ddev, name, val) \
+ __raw_writel((val), &(__txx9dmac_regs(ddev)->name))
+
+#define dma32_readl(ddev, name) \
+ __raw_readl(&(__txx9dmac_regs32(ddev)->name))
+#define dma32_writel(ddev, name, val) \
+ __raw_writel((val), &(__txx9dmac_regs32(ddev)->name))
+
+#define dma_readl(ddev, name) \
+ (__is_dmac64(ddev) ? \
+ dma64_readl(ddev, name) : dma32_readl(ddev, name))
+#define dma_writel(ddev, name, val) \
+ (__is_dmac64(ddev) ? \
+ dma64_writel(ddev, name, val) : dma32_writel(ddev, name, val))
+
+static struct device *chan2dev(struct dma_chan *chan)
+{
+ return &chan->dev->device;
+}
+static struct device *chan2parent(struct dma_chan *chan)
+{
+ return chan->dev->device.parent;
+}
+
+static struct txx9dmac_desc *
+txd_to_txx9dmac_desc(struct dma_async_tx_descriptor *txd)
+{
+ return container_of(txd, struct txx9dmac_desc, txd);
+}
+
+static dma_addr_t desc_read_CHAR(const struct txx9dmac_chan *dc,
+ const struct txx9dmac_desc *desc)
+{
+ return is_dmac64(dc) ? desc->hwdesc.CHAR : desc->hwdesc32.CHAR;
+}
+
+static void desc_write_CHAR(const struct txx9dmac_chan *dc,
+ struct txx9dmac_desc *desc, dma_addr_t val)
+{
+ if (is_dmac64(dc))
+ desc->hwdesc.CHAR = val;
+ else
+ desc->hwdesc32.CHAR = val;
+}
+
+#define TXX9_DMA_MAX_COUNT 0x04000000
+
+#define TXX9_DMA_INITIAL_DESC_COUNT 64
+
+static struct txx9dmac_desc *txx9dmac_first_active(struct txx9dmac_chan *dc)
+{
+ return list_entry(dc->active_list.next,
+ struct txx9dmac_desc, desc_node);
+}
+
+static struct txx9dmac_desc *txx9dmac_last_active(struct txx9dmac_chan *dc)
+{
+ return list_entry(dc->active_list.prev,
+ struct txx9dmac_desc, desc_node);
+}
+
+static struct txx9dmac_desc *txx9dmac_first_queued(struct txx9dmac_chan *dc)
+{
+ return list_entry(dc->queue.next, struct txx9dmac_desc, desc_node);
+}
+
+static struct txx9dmac_desc *txx9dmac_last_child(struct txx9dmac_desc *desc)
+{
+ if (!list_empty(&desc->txd.tx_list))
+ desc = list_entry(desc->txd.tx_list.prev,
+ struct txx9dmac_desc, desc_node);
+ return desc;
+}
+
+static dma_cookie_t txx9dmac_tx_submit(struct dma_async_tx_descriptor *tx);
+
+static struct txx9dmac_desc *txx9dmac_desc_alloc(struct txx9dmac_chan *dc,
+ gfp_t flags)
+{
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_desc *desc;
+
+ desc = kzalloc(sizeof(*desc), flags);
+ if (!desc)
+ return NULL;
+ dma_async_tx_descriptor_init(&desc->txd, &dc->chan);
+ desc->txd.tx_submit = txx9dmac_tx_submit;
+ /* txd.flags will be overwritten in prep funcs */
+ desc->txd.flags = DMA_CTRL_ACK;
+ desc->txd.phys = dma_map_single(chan2parent(&dc->chan), &desc->hwdesc,
+ ddev->descsize, DMA_TO_DEVICE);
+ return desc;
+}
+
+static struct txx9dmac_desc *txx9dmac_desc_get(struct txx9dmac_chan *dc)
+{
+ struct txx9dmac_desc *desc, *_desc;
+ struct txx9dmac_desc *ret = NULL;
+ unsigned int i = 0;
+
+ spin_lock_bh(&dc->lock);
+ list_for_each_entry_safe(desc, _desc, &dc->free_list, desc_node) {
+ if (async_tx_test_ack(&desc->txd)) {
+ list_del(&desc->desc_node);
+ ret = desc;
+ break;
+ }
+ dev_dbg(chan2dev(&dc->chan), "desc %p not ACKed\n", desc);
+ i++;
+ }
+ spin_unlock_bh(&dc->lock);
+
+ dev_vdbg(chan2dev(&dc->chan), "scanned %u descriptors on freelist\n",
+ i);
+ if (!ret) {
+ ret = txx9dmac_desc_alloc(dc, GFP_ATOMIC);
+ if (ret) {
+ spin_lock_bh(&dc->lock);
+ dc->descs_allocated++;
+ spin_unlock_bh(&dc->lock);
+ } else
+ dev_err(chan2dev(&dc->chan),
+ "not enough descriptors available\n");
+ }
+ return ret;
+}
+
+static void txx9dmac_sync_desc_for_cpu(struct txx9dmac_chan *dc,
+ struct txx9dmac_desc *desc)
+{
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_desc *child;
+
+ list_for_each_entry(child, &desc->txd.tx_list, desc_node)
+ dma_sync_single_for_cpu(chan2parent(&dc->chan),
+ child->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+ dma_sync_single_for_cpu(chan2parent(&dc->chan),
+ desc->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+}
+
+/*
+ * Move a descriptor, including any children, to the free list.
+ * `desc' must not be on any lists.
+ */
+static void txx9dmac_desc_put(struct txx9dmac_chan *dc,
+ struct txx9dmac_desc *desc)
+{
+ if (desc) {
+ struct txx9dmac_desc *child;
+
+ txx9dmac_sync_desc_for_cpu(dc, desc);
+
+ spin_lock_bh(&dc->lock);
+ list_for_each_entry(child, &desc->txd.tx_list, desc_node)
+ dev_vdbg(chan2dev(&dc->chan),
+ "moving child desc %p to freelist\n",
+ child);
+ list_splice_init(&desc->txd.tx_list, &dc->free_list);
+ dev_vdbg(chan2dev(&dc->chan), "moving desc %p to freelist\n",
+ desc);
+ list_add(&desc->desc_node, &dc->free_list);
+ spin_unlock_bh(&dc->lock);
+ }
+}
+
+/* Called with dc->lock held and bh disabled */
+static dma_cookie_t
+txx9dmac_assign_cookie(struct txx9dmac_chan *dc, struct txx9dmac_desc *desc)
+{
+ dma_cookie_t cookie = dc->chan.cookie;
+
+ if (++cookie < 0)
+ cookie = 1;
+
+ dc->chan.cookie = cookie;
+ desc->txd.cookie = cookie;
+
+ return cookie;
+}
+
+/*----------------------------------------------------------------------*/
+
+static void txx9dmac_dump_regs(struct txx9dmac_chan *dc)
+{
+ if (is_dmac64(dc))
+ dev_err(chan2dev(&dc->chan),
+ " CHAR: %#llx SAR: %#llx DAR: %#llx CNTR: %#x"
+ " SAIR: %#x DAIR: %#x CCR: %#x CSR: %#x\n",
+ (u64)channel64_read_CHAR(dc),
+ channel64_readq(dc, SAR),
+ channel64_readq(dc, DAR),
+ channel64_readl(dc, CNTR),
+ channel64_readl(dc, SAIR),
+ channel64_readl(dc, DAIR),
+ channel64_readl(dc, CCR),
+ channel64_readl(dc, CSR));
+ else
+ dev_err(chan2dev(&dc->chan),
+ " CHAR: %#x SAR: %#x DAR: %#x CNTR: %#x"
+ " SAIR: %#x DAIR: %#x CCR: %#x CSR: %#x\n",
+ channel32_readl(dc, CHAR),
+ channel32_readl(dc, SAR),
+ channel32_readl(dc, DAR),
+ channel32_readl(dc, CNTR),
+ channel32_readl(dc, SAIR),
+ channel32_readl(dc, DAIR),
+ channel32_readl(dc, CCR),
+ channel32_readl(dc, CSR));
+}
+
+static void txx9dmac_reset_chan(struct txx9dmac_chan *dc)
+{
+ channel_writel(dc, CCR, TXX9_DMA_CCR_CHRST);
+ if (is_dmac64(dc)) {
+ channel64_clear_CHAR(dc);
+ channel_writeq(dc, SAR, 0);
+ channel_writeq(dc, DAR, 0);
+ } else {
+ channel_writel(dc, CHAR, 0);
+ channel_writel(dc, SAR, 0);
+ channel_writel(dc, DAR, 0);
+ }
+ channel_writel(dc, CNTR, 0);
+ channel_writel(dc, SAIR, 0);
+ channel_writel(dc, DAIR, 0);
+ channel_writel(dc, CCR, 0);
+ mmiowb();
+}
+
+/* Called with dc->lock held and bh disabled */
+static void txx9dmac_dostart(struct txx9dmac_chan *dc,
+ struct txx9dmac_desc *first)
+{
+ struct txx9dmac_slave *ds = dc->chan.private;
+ u32 sai, dai;
+
+ dev_vdbg(chan2dev(&dc->chan), "dostart %u %p\n",
+ first->txd.cookie, first);
+ /* ASSERT: channel is idle */
+ if (channel_readl(dc, CSR) & TXX9_DMA_CSR_XFACT) {
+ dev_err(chan2dev(&dc->chan),
+ "BUG: Attempted to start non-idle channel\n");
+ txx9dmac_dump_regs(dc);
+ /* The tasklet will hopefully advance the queue... */
+ return;
+ }
+
+ if (is_dmac64(dc)) {
+ channel64_writel(dc, CNTR, 0);
+ channel64_writel(dc, CSR, 0xffffffff);
+ if (ds) {
+ if (ds->tx_reg) {
+ sai = ds->reg_width;
+ dai = 0;
+ } else {
+ sai = 0;
+ dai = ds->reg_width;
+ }
+ } else {
+ sai = 8;
+ dai = 8;
+ }
+ channel64_writel(dc, SAIR, sai);
+ channel64_writel(dc, DAIR, dai);
+ /* All 64-bit DMAC supports SMPCHN */
+ channel64_writel(dc, CCR, dc->ccr);
+ /* Writing a non zero value to CHAR will assert XFACT */
+ channel64_write_CHAR(dc, first->txd.phys);
+ } else {
+ channel32_writel(dc, CNTR, 0);
+ channel32_writel(dc, CSR, 0xffffffff);
+ if (ds) {
+ if (ds->tx_reg) {
+ sai = ds->reg_width;
+ dai = 0;
+ } else {
+ sai = 0;
+ dai = ds->reg_width;
+ }
+ } else {
+ sai = 4;
+ dai = 4;
+ }
+ channel32_writel(dc, SAIR, sai);
+ channel32_writel(dc, DAIR, dai);
+ if (txx9_dma_have_SMPCHN()) {
+ channel32_writel(dc, CCR, dc->ccr);
+ /* Writing a non zero value to CHAR will assert XFACT */
+ channel32_writel(dc, CHAR, first->txd.phys);
+ } else {
+ channel32_writel(dc, CHAR, first->txd.phys);
+ channel32_writel(dc, CCR, dc->ccr);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------*/
+
+static void
+txx9dmac_descriptor_complete(struct txx9dmac_chan *dc,
+ struct txx9dmac_desc *desc)
+{
+ dma_async_tx_callback callback;
+ void *param;
+ struct dma_async_tx_descriptor *txd = &desc->txd;
+ struct txx9dmac_slave *ds = dc->chan.private;
+
+ dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n",
+ txd->cookie, desc);
+
+ dc->completed = txd->cookie;
+ callback = txd->callback;
+ param = txd->callback_param;
+
+ txx9dmac_sync_desc_for_cpu(dc, desc);
+ list_splice_init(&txd->tx_list, &dc->free_list);
+ list_move(&desc->desc_node, &dc->free_list);
+
+ /*
+ * We use dma_unmap_page() regardless of how the buffers were
+ * mapped before they were submitted...
+ */
+ if (!ds) {
+ dma_addr_t dmaaddr;
+ if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
+ dmaaddr = is_dmac64(dc) ?
+ desc->hwdesc.DAR : desc->hwdesc32.DAR;
+ dma_unmap_page(chan2parent(&dc->chan), dmaaddr,
+ desc->len, DMA_FROM_DEVICE);
+ }
+ if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
+ dmaaddr = is_dmac64(dc) ?
+ desc->hwdesc.SAR : desc->hwdesc32.SAR;
+ dma_unmap_page(chan2parent(&dc->chan), dmaaddr,
+ desc->len, DMA_TO_DEVICE);
+ }
+ }
+
+ /*
+ * The API requires that no submissions are done from a
+ * callback, so we don't need to drop the lock here
+ */
+ if (callback)
+ callback(param);
+ dma_run_dependencies(txd);
+}
+
+static void txx9dmac_dequeue(struct txx9dmac_chan *dc, struct list_head *list)
+{
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_desc *desc;
+ struct txx9dmac_desc *prev = NULL;
+
+ BUG_ON(!list_empty(list));
+ do {
+ desc = txx9dmac_first_queued(dc);
+ if (prev) {
+ desc_write_CHAR(dc, prev, desc->txd.phys);
+ dma_sync_single_for_device(chan2parent(&dc->chan),
+ prev->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+ }
+ prev = txx9dmac_last_child(desc);
+ list_move_tail(&desc->desc_node, list);
+ /* Make chain-completion interrupt happen */
+ if ((desc->txd.flags & DMA_PREP_INTERRUPT) &&
+ !txx9dmac_chan_INTENT(dc))
+ break;
+ } while (!list_empty(&dc->queue));
+}
+
+static void txx9dmac_complete_all(struct txx9dmac_chan *dc)
+{
+ struct txx9dmac_desc *desc, *_desc;
+ LIST_HEAD(list);
+
+ /*
+ * Submit queued descriptors ASAP, i.e. before we go through
+ * the completed ones.
+ */
+ list_splice_init(&dc->active_list, &list);
+ if (!list_empty(&dc->queue)) {
+ txx9dmac_dequeue(dc, &dc->active_list);
+ txx9dmac_dostart(dc, txx9dmac_first_active(dc));
+ }
+
+ list_for_each_entry_safe(desc, _desc, &list, desc_node)
+ txx9dmac_descriptor_complete(dc, desc);
+}
+
+static void txx9dmac_dump_desc(struct txx9dmac_chan *dc,
+ struct txx9dmac_hwdesc *desc)
+{
+ if (is_dmac64(dc)) {
+#ifdef TXX9_DMA_USE_SIMPLE_CHAIN
+ dev_crit(chan2dev(&dc->chan),
+ " desc: ch%#llx s%#llx d%#llx c%#x\n",
+ (u64)desc->CHAR, desc->SAR, desc->DAR, desc->CNTR);
+#else
+ dev_crit(chan2dev(&dc->chan),
+ " desc: ch%#llx s%#llx d%#llx c%#x"
+ " si%#x di%#x cc%#x cs%#x\n",
+ (u64)desc->CHAR, desc->SAR, desc->DAR, desc->CNTR,
+ desc->SAIR, desc->DAIR, desc->CCR, desc->CSR);
+#endif
+ } else {
+ struct txx9dmac_hwdesc32 *d = (struct txx9dmac_hwdesc32 *)desc;
+#ifdef TXX9_DMA_USE_SIMPLE_CHAIN
+ dev_crit(chan2dev(&dc->chan),
+ " desc: ch%#x s%#x d%#x c%#x\n",
+ d->CHAR, d->SAR, d->DAR, d->CNTR);
+#else
+ dev_crit(chan2dev(&dc->chan),
+ " desc: ch%#x s%#x d%#x c%#x"
+ " si%#x di%#x cc%#x cs%#x\n",
+ d->CHAR, d->SAR, d->DAR, d->CNTR,
+ d->SAIR, d->DAIR, d->CCR, d->CSR);
+#endif
+ }
+}
+
+static void txx9dmac_handle_error(struct txx9dmac_chan *dc, u32 csr)
+{
+ struct txx9dmac_desc *bad_desc;
+ struct txx9dmac_desc *child;
+ u32 errors;
+
+ /*
+ * The descriptor currently at the head of the active list is
+ * borked. Since we don't have any way to report errors, we'll
+ * just have to scream loudly and try to carry on.
+ */
+ dev_crit(chan2dev(&dc->chan), "Abnormal Chain Completion\n");
+ txx9dmac_dump_regs(dc);
+
+ bad_desc = txx9dmac_first_active(dc);
+ list_del_init(&bad_desc->desc_node);
+
+ /* Clear all error flags and try to restart the controller */
+ errors = csr & (TXX9_DMA_CSR_ABCHC |
+ TXX9_DMA_CSR_CFERR | TXX9_DMA_CSR_CHERR |
+ TXX9_DMA_CSR_DESERR | TXX9_DMA_CSR_SORERR);
+ channel_writel(dc, CSR, errors);
+
+ if (list_empty(&dc->active_list) && !list_empty(&dc->queue))
+ txx9dmac_dequeue(dc, &dc->active_list);
+ if (!list_empty(&dc->active_list))
+ txx9dmac_dostart(dc, txx9dmac_first_active(dc));
+
+ dev_crit(chan2dev(&dc->chan),
+ "Bad descriptor submitted for DMA! (cookie: %d)\n",
+ bad_desc->txd.cookie);
+ txx9dmac_dump_desc(dc, &bad_desc->hwdesc);
+ list_for_each_entry(child, &bad_desc->txd.tx_list, desc_node)
+ txx9dmac_dump_desc(dc, &child->hwdesc);
+ /* Pretend the descriptor completed successfully */
+ txx9dmac_descriptor_complete(dc, bad_desc);
+}
+
+static void txx9dmac_scan_descriptors(struct txx9dmac_chan *dc)
+{
+ dma_addr_t chain;
+ struct txx9dmac_desc *desc, *_desc;
+ struct txx9dmac_desc *child;
+ u32 csr;
+
+ if (is_dmac64(dc)) {
+ chain = channel64_read_CHAR(dc);
+ csr = channel64_readl(dc, CSR);
+ channel64_writel(dc, CSR, csr);
+ } else {
+ chain = channel32_readl(dc, CHAR);
+ csr = channel32_readl(dc, CSR);
+ channel32_writel(dc, CSR, csr);
+ }
+ /* For dynamic chain, we should look at XFACT instead of NCHNC */
+ if (!(csr & (TXX9_DMA_CSR_XFACT | TXX9_DMA_CSR_ABCHC))) {
+ /* Everything we've submitted is done */
+ txx9dmac_complete_all(dc);
+ return;
+ }
+ if (!(csr & TXX9_DMA_CSR_CHNEN))
+ chain = 0; /* last descriptor of this chain */
+
+ dev_vdbg(chan2dev(&dc->chan), "scan_descriptors: char=%#llx\n",
+ (u64)chain);
+
+ list_for_each_entry_safe(desc, _desc, &dc->active_list, desc_node) {
+ if (desc_read_CHAR(dc, desc) == chain) {
+ /* This one is currently in progress */
+ if (csr & TXX9_DMA_CSR_ABCHC)
+ goto scan_done;
+ return;
+ }
+
+ list_for_each_entry(child, &desc->txd.tx_list, desc_node)
+ if (desc_read_CHAR(dc, child) == chain) {
+ /* Currently in progress */
+ if (csr & TXX9_DMA_CSR_ABCHC)
+ goto scan_done;
+ return;
+ }
+
+ /*
+ * No descriptors so far seem to be in progress, i.e.
+ * this one must be done.
+ */
+ txx9dmac_descriptor_complete(dc, desc);
+ }
+scan_done:
+ if (csr & TXX9_DMA_CSR_ABCHC) {
+ txx9dmac_handle_error(dc, csr);
+ return;
+ }
+
+ dev_err(chan2dev(&dc->chan),
+ "BUG: All descriptors done, but channel not idle!\n");
+
+ /* Try to continue after resetting the channel... */
+ txx9dmac_reset_chan(dc);
+
+ if (!list_empty(&dc->queue)) {
+ txx9dmac_dequeue(dc, &dc->active_list);
+ txx9dmac_dostart(dc, txx9dmac_first_active(dc));
+ }
+}
+
+static void txx9dmac_chan_tasklet(unsigned long data)
+{
+ int irq;
+ u32 csr;
+ struct txx9dmac_chan *dc;
+
+ dc = (struct txx9dmac_chan *)data;
+ csr = channel_readl(dc, CSR);
+ dev_vdbg(chan2dev(&dc->chan), "tasklet: status=%x\n", csr);
+
+ spin_lock(&dc->lock);
+ if (csr & (TXX9_DMA_CSR_ABCHC | TXX9_DMA_CSR_NCHNC |
+ TXX9_DMA_CSR_NTRNFC))
+ txx9dmac_scan_descriptors(dc);
+ spin_unlock(&dc->lock);
+ irq = dc->irq;
+
+ enable_irq(irq);
+}
+
+static irqreturn_t txx9dmac_chan_interrupt(int irq, void *dev_id)
+{
+ struct txx9dmac_chan *dc = dev_id;
+
+ dev_vdbg(chan2dev(&dc->chan), "interrupt: status=%#x\n",
+ channel_readl(dc, CSR));
+
+ tasklet_schedule(&dc->tasklet);
+ /*
+ * Just disable the interrupts. We'll turn them back on in the
+ * softirq handler.
+ */
+ disable_irq_nosync(irq);
+
+ return IRQ_HANDLED;
+}
+
+static void txx9dmac_tasklet(unsigned long data)
+{
+ int irq;
+ u32 csr;
+ struct txx9dmac_chan *dc;
+
+ struct txx9dmac_dev *ddev = (struct txx9dmac_dev *)data;
+ u32 mcr;
+ int i;
+
+ mcr = dma_readl(ddev, MCR);
+ dev_vdbg(ddev->chan[0]->dma.dev, "tasklet: mcr=%x\n", mcr);
+ for (i = 0; i < TXX9_DMA_MAX_NR_CHANNELS; i++) {
+ if ((mcr >> (24 + i)) & 0x11) {
+ dc = ddev->chan[i];
+ csr = channel_readl(dc, CSR);
+ dev_vdbg(chan2dev(&dc->chan), "tasklet: status=%x\n",
+ csr);
+ spin_lock(&dc->lock);
+ if (csr & (TXX9_DMA_CSR_ABCHC | TXX9_DMA_CSR_NCHNC |
+ TXX9_DMA_CSR_NTRNFC))
+ txx9dmac_scan_descriptors(dc);
+ spin_unlock(&dc->lock);
+ }
+ }
+ irq = ddev->irq;
+
+ enable_irq(irq);
+}
+
+static irqreturn_t txx9dmac_interrupt(int irq, void *dev_id)
+{
+ struct txx9dmac_dev *ddev = dev_id;
+
+ dev_vdbg(ddev->chan[0]->dma.dev, "interrupt: status=%#x\n",
+ dma_readl(ddev, MCR));
+
+ tasklet_schedule(&ddev->tasklet);
+ /*
+ * Just disable the interrupts. We'll turn them back on in the
+ * softirq handler.
+ */
+ disable_irq_nosync(irq);
+
+ return IRQ_HANDLED;
+}
+
+/*----------------------------------------------------------------------*/
+
+static dma_cookie_t txx9dmac_tx_submit(struct dma_async_tx_descriptor *tx)
+{
+ struct txx9dmac_desc *desc = txd_to_txx9dmac_desc(tx);
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(tx->chan);
+ dma_cookie_t cookie;
+
+ spin_lock_bh(&dc->lock);
+ cookie = txx9dmac_assign_cookie(dc, desc);
+
+ dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u %p\n",
+ desc->txd.cookie, desc);
+
+ list_add_tail(&desc->desc_node, &dc->queue);
+ spin_unlock_bh(&dc->lock);
+
+ return cookie;
+}
+
+static struct dma_async_tx_descriptor *
+txx9dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
+ size_t len, unsigned long flags)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_desc *desc;
+ struct txx9dmac_desc *first;
+ struct txx9dmac_desc *prev;
+ size_t xfer_count;
+ size_t offset;
+
+ dev_vdbg(chan2dev(chan), "prep_dma_memcpy d%#llx s%#llx l%#zx f%#lx\n",
+ (u64)dest, (u64)src, len, flags);
+
+ if (unlikely(!len)) {
+ dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n");
+ return NULL;
+ }
+
+ prev = first = NULL;
+
+ for (offset = 0; offset < len; offset += xfer_count) {
+ xfer_count = min_t(size_t, len - offset, TXX9_DMA_MAX_COUNT);
+ /*
+ * Workaround for ERT-TX49H2-033, ERT-TX49H3-020,
+ * ERT-TX49H4-016 (slightly conservative)
+ */
+ if (__is_dmac64(ddev)) {
+ if (xfer_count > 0x100 &&
+ (xfer_count & 0xff) >= 0xfa &&
+ (xfer_count & 0xff) <= 0xff)
+ xfer_count -= 0x20;
+ } else {
+ if (xfer_count > 0x80 &&
+ (xfer_count & 0x7f) >= 0x7e &&
+ (xfer_count & 0x7f) <= 0x7f)
+ xfer_count -= 0x20;
+ }
+
+ desc = txx9dmac_desc_get(dc);
+ if (!desc) {
+ txx9dmac_desc_put(dc, first);
+ return NULL;
+ }
+
+ if (__is_dmac64(ddev)) {
+ desc->hwdesc.SAR = src + offset;
+ desc->hwdesc.DAR = dest + offset;
+ desc->hwdesc.CNTR = xfer_count;
+ txx9dmac_desc_set_nosimple(ddev, desc, 8, 8,
+ dc->ccr | TXX9_DMA_CCR_XFACT);
+ } else {
+ desc->hwdesc32.SAR = src + offset;
+ desc->hwdesc32.DAR = dest + offset;
+ desc->hwdesc32.CNTR = xfer_count;
+ txx9dmac_desc_set_nosimple(ddev, desc, 4, 4,
+ dc->ccr | TXX9_DMA_CCR_XFACT);
+ }
+
+ /*
+ * The descriptors on tx_list are not reachable from
+ * the dc->queue list or dc->active_list after a
+ * submit. If we put all descriptors on active_list,
+ * calling of callback on the completion will be more
+ * complex.
+ */
+ if (!first) {
+ first = desc;
+ } else {
+ desc_write_CHAR(dc, prev, desc->txd.phys);
+ dma_sync_single_for_device(chan2parent(&dc->chan),
+ prev->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+ list_add_tail(&desc->desc_node,
+ &first->txd.tx_list);
+ }
+ prev = desc;
+ }
+
+ /* Trigger interrupt after last block */
+ if (flags & DMA_PREP_INTERRUPT)
+ txx9dmac_desc_set_INTENT(ddev, prev);
+
+ desc_write_CHAR(dc, prev, 0);
+ dma_sync_single_for_device(chan2parent(&dc->chan),
+ prev->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+
+ first->txd.flags = flags;
+ first->len = len;
+
+ return &first->txd;
+}
+
+static struct dma_async_tx_descriptor *
+txx9dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
+ unsigned int sg_len, enum dma_data_direction direction,
+ unsigned long flags)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_slave *ds = chan->private;
+ struct txx9dmac_desc *prev;
+ struct txx9dmac_desc *first;
+ unsigned int i;
+ struct scatterlist *sg;
+
+ dev_vdbg(chan2dev(chan), "prep_dma_slave\n");
+
+ BUG_ON(!ds || !ds->reg_width);
+ if (ds->tx_reg)
+ BUG_ON(direction != DMA_TO_DEVICE);
+ else
+ BUG_ON(direction != DMA_FROM_DEVICE);
+ if (unlikely(!sg_len))
+ return NULL;
+
+ prev = first = NULL;
+
+ for_each_sg(sgl, sg, sg_len, i) {
+ struct txx9dmac_desc *desc;
+ dma_addr_t mem;
+ u32 sai, dai;
+
+ desc = txx9dmac_desc_get(dc);
+ if (!desc) {
+ txx9dmac_desc_put(dc, first);
+ return NULL;
+ }
+
+ mem = sg_dma_address(sg);
+
+ if (__is_dmac64(ddev)) {
+ if (direction == DMA_TO_DEVICE) {
+ desc->hwdesc.SAR = mem;
+ desc->hwdesc.DAR = ds->tx_reg;
+ } else {
+ desc->hwdesc.SAR = ds->rx_reg;
+ desc->hwdesc.DAR = mem;
+ }
+ desc->hwdesc.CNTR = sg_dma_len(sg);
+ } else {
+ if (direction == DMA_TO_DEVICE) {
+ desc->hwdesc32.SAR = mem;
+ desc->hwdesc32.DAR = ds->tx_reg;
+ } else {
+ desc->hwdesc32.SAR = ds->rx_reg;
+ desc->hwdesc32.DAR = mem;
+ }
+ desc->hwdesc32.CNTR = sg_dma_len(sg);
+ }
+ if (direction == DMA_TO_DEVICE) {
+ sai = ds->reg_width;
+ dai = 0;
+ } else {
+ sai = 0;
+ dai = ds->reg_width;
+ }
+ txx9dmac_desc_set_nosimple(ddev, desc, sai, dai,
+ dc->ccr | TXX9_DMA_CCR_XFACT);
+
+ if (!first) {
+ first = desc;
+ } else {
+ desc_write_CHAR(dc, prev, desc->txd.phys);
+ dma_sync_single_for_device(chan2parent(&dc->chan),
+ prev->txd.phys,
+ ddev->descsize,
+ DMA_TO_DEVICE);
+ list_add_tail(&desc->desc_node,
+ &first->txd.tx_list);
+ }
+ prev = desc;
+ }
+
+ /* Trigger interrupt after last block */
+ if (flags & DMA_PREP_INTERRUPT)
+ txx9dmac_desc_set_INTENT(ddev, prev);
+
+ desc_write_CHAR(dc, prev, 0);
+ dma_sync_single_for_device(chan2parent(&dc->chan),
+ prev->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+
+ first->txd.flags = flags;
+ first->len = 0;
+
+ return &first->txd;
+}
+
+static void txx9dmac_terminate_all(struct dma_chan *chan)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+ struct txx9dmac_desc *desc, *_desc;
+ LIST_HEAD(list);
+
+ dev_vdbg(chan2dev(chan), "terminate_all\n");
+ spin_lock_bh(&dc->lock);
+
+ txx9dmac_reset_chan(dc);
+
+ /* active_list entries will end up before queued entries */
+ list_splice_init(&dc->queue, &list);
+ list_splice_init(&dc->active_list, &list);
+
+ spin_unlock_bh(&dc->lock);
+
+ /* Flush all pending and queued descriptors */
+ list_for_each_entry_safe(desc, _desc, &list, desc_node)
+ txx9dmac_descriptor_complete(dc, desc);
+}
+
+static enum dma_status
+txx9dmac_is_tx_complete(struct dma_chan *chan,
+ dma_cookie_t cookie,
+ dma_cookie_t *done, dma_cookie_t *used)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+ dma_cookie_t last_used;
+ dma_cookie_t last_complete;
+ int ret;
+
+ last_complete = dc->completed;
+ last_used = chan->cookie;
+
+ ret = dma_async_is_complete(cookie, last_complete, last_used);
+ if (ret != DMA_SUCCESS) {
+ spin_lock_bh(&dc->lock);
+ txx9dmac_scan_descriptors(dc);
+ spin_unlock_bh(&dc->lock);
+
+ last_complete = dc->completed;
+ last_used = chan->cookie;
+
+ ret = dma_async_is_complete(cookie, last_complete, last_used);
+ }
+
+ if (done)
+ *done = last_complete;
+ if (used)
+ *used = last_used;
+
+ return ret;
+}
+
+static void txx9dmac_chain_dynamic(struct txx9dmac_chan *dc,
+ struct txx9dmac_desc *prev)
+{
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_desc *desc;
+ LIST_HEAD(list);
+
+ prev = txx9dmac_last_child(prev);
+ txx9dmac_dequeue(dc, &list);
+ desc = list_entry(list.next, struct txx9dmac_desc, desc_node);
+ desc_write_CHAR(dc, prev, desc->txd.phys);
+ dma_sync_single_for_device(chan2parent(&dc->chan),
+ prev->txd.phys, ddev->descsize,
+ DMA_TO_DEVICE);
+ mmiowb();
+ if (!(channel_readl(dc, CSR) & TXX9_DMA_CSR_CHNEN) &&
+ channel_read_CHAR(dc) == prev->txd.phys)
+ /* Restart chain DMA */
+ channel_write_CHAR(dc, desc->txd.phys);
+ list_splice_tail(&list, &dc->active_list);
+}
+
+static void txx9dmac_issue_pending(struct dma_chan *chan)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+
+ spin_lock_bh(&dc->lock);
+
+ if (!list_empty(&dc->active_list))
+ txx9dmac_scan_descriptors(dc);
+ if (!list_empty(&dc->queue)) {
+ if (list_empty(&dc->active_list)) {
+ txx9dmac_dequeue(dc, &dc->active_list);
+ txx9dmac_dostart(dc, txx9dmac_first_active(dc));
+ } else if (txx9_dma_have_SMPCHN()) {
+ struct txx9dmac_desc *prev = txx9dmac_last_active(dc);
+
+ if (!(prev->txd.flags & DMA_PREP_INTERRUPT) ||
+ txx9dmac_chan_INTENT(dc))
+ txx9dmac_chain_dynamic(dc, prev);
+ }
+ }
+
+ spin_unlock_bh(&dc->lock);
+}
+
+static int txx9dmac_alloc_chan_resources(struct dma_chan *chan)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+ struct txx9dmac_slave *ds = chan->private;
+ struct txx9dmac_desc *desc;
+ int i;
+
+ dev_vdbg(chan2dev(chan), "alloc_chan_resources\n");
+
+ /* ASSERT: channel is idle */
+ if (channel_readl(dc, CSR) & TXX9_DMA_CSR_XFACT) {
+ dev_dbg(chan2dev(chan), "DMA channel not idle?\n");
+ return -EIO;
+ }
+
+ dc->completed = chan->cookie = 1;
+
+ dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE;
+ txx9dmac_chan_set_SMPCHN(dc);
+ if (!txx9_dma_have_SMPCHN() || (dc->ccr & TXX9_DMA_CCR_SMPCHN))
+ dc->ccr |= TXX9_DMA_CCR_INTENC;
+ if (chan->device->device_prep_dma_memcpy) {
+ if (ds)
+ return -EINVAL;
+ dc->ccr |= TXX9_DMA_CCR_XFSZ_X8;
+ } else {
+ if (!ds ||
+ (ds->tx_reg && ds->rx_reg) || (!ds->tx_reg && !ds->rx_reg))
+ return -EINVAL;
+ dc->ccr |= TXX9_DMA_CCR_EXTRQ |
+ TXX9_DMA_CCR_XFSZ(__ffs(ds->reg_width));
+ txx9dmac_chan_set_INTENT(dc);
+ }
+
+ spin_lock_bh(&dc->lock);
+ i = dc->descs_allocated;
+ while (dc->descs_allocated < TXX9_DMA_INITIAL_DESC_COUNT) {
+ spin_unlock_bh(&dc->lock);
+
+ desc = txx9dmac_desc_alloc(dc, GFP_KERNEL);
+ if (!desc) {
+ dev_info(chan2dev(chan),
+ "only allocated %d descriptors\n", i);
+ spin_lock_bh(&dc->lock);
+ break;
+ }
+ txx9dmac_desc_put(dc, desc);
+
+ spin_lock_bh(&dc->lock);
+ i = ++dc->descs_allocated;
+ }
+ spin_unlock_bh(&dc->lock);
+
+ dev_dbg(chan2dev(chan),
+ "alloc_chan_resources allocated %d descriptors\n", i);
+
+ return i;
+}
+
+static void txx9dmac_free_chan_resources(struct dma_chan *chan)
+{
+ struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
+ struct txx9dmac_dev *ddev = dc->ddev;
+ struct txx9dmac_desc *desc, *_desc;
+ LIST_HEAD(list);
+
+ dev_dbg(chan2dev(chan), "free_chan_resources (descs allocated=%u)\n",
+ dc->descs_allocated);
+
+ /* ASSERT: channel is idle */
+ BUG_ON(!list_empty(&dc->active_list));
+ BUG_ON(!list_empty(&dc->queue));
+ BUG_ON(channel_readl(dc, CSR) & TXX9_DMA_CSR_XFACT);
+
+ spin_lock_bh(&dc->lock);
+ list_splice_init(&dc->free_list, &list);
+ dc->descs_allocated = 0;
+ spin_unlock_bh(&dc->lock);
+
+ list_for_each_entry_safe(desc, _desc, &list, desc_node) {
+ dev_vdbg(chan2dev(chan), " freeing descriptor %p\n", desc);
+ dma_unmap_single(chan2parent(chan), desc->txd.phys,
+ ddev->descsize, DMA_TO_DEVICE);
+ kfree(desc);
+ }
+
+ dev_vdbg(chan2dev(chan), "free_chan_resources done\n");
+}
+
+/*----------------------------------------------------------------------*/
+
+static void txx9dmac_off(struct txx9dmac_dev *ddev)
+{
+ dma_writel(ddev, MCR, 0);
+ mmiowb();
+}
+
+static int __init txx9dmac_chan_probe(struct platform_device *pdev)
+{
+ struct txx9dmac_chan_platform_data *cpdata = pdev->dev.platform_data;
+ struct platform_device *dmac_dev = cpdata->dmac_dev;
+ struct txx9dmac_platform_data *pdata = dmac_dev->dev.platform_data;
+ struct txx9dmac_chan *dc;
+ int err;
+ int ch = pdev->id % TXX9_DMA_MAX_NR_CHANNELS;
+ int irq;
+
+ dc = devm_kzalloc(&pdev->dev, sizeof(*dc), GFP_KERNEL);
+ if (!dc)
+ return -ENOMEM;
+
+ dc->dma.dev = &pdev->dev;
+ dc->dma.device_alloc_chan_resources = txx9dmac_alloc_chan_resources;
+ dc->dma.device_free_chan_resources = txx9dmac_free_chan_resources;
+ dc->dma.device_terminate_all = txx9dmac_terminate_all;
+ dc->dma.device_is_tx_complete = txx9dmac_is_tx_complete;
+ dc->dma.device_issue_pending = txx9dmac_issue_pending;
+ if (pdata && pdata->memcpy_chan == ch) {
+ dc->dma.device_prep_dma_memcpy = txx9dmac_prep_dma_memcpy;
+ dma_cap_set(DMA_MEMCPY, dc->dma.cap_mask);
+ } else {
+ dc->dma.device_prep_slave_sg = txx9dmac_prep_slave_sg;
+ dma_cap_set(DMA_SLAVE, dc->dma.cap_mask);
+ dma_cap_set(DMA_PRIVATE, dc->dma.cap_mask);
+ }
+
+ INIT_LIST_HEAD(&dc->dma.channels);
+ dc->ddev = platform_get_drvdata(dmac_dev);
+ if (dc->ddev->irq < 0) {
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+ tasklet_init(&dc->tasklet, txx9dmac_chan_tasklet,
+ (unsigned long)dc);
+ dc->irq = irq;
+ err = devm_request_irq(&pdev->dev, dc->irq,
+ txx9dmac_chan_interrupt, 0, dev_name(&pdev->dev), dc);
+ if (err)
+ return err;
+ } else
+ dc->irq = -1;
+ dc->ddev->chan[ch] = dc;
+ dc->chan.device = &dc->dma;
+ list_add_tail(&dc->chan.device_node, &dc->chan.device->channels);
+ dc->chan.cookie = dc->completed = 1;
+
+ if (is_dmac64(dc))
+ dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch];
+ else
+ dc->ch_regs = &__txx9dmac_regs32(dc->ddev)->CHAN[ch];
+ spin_lock_init(&dc->lock);
+
+ INIT_LIST_HEAD(&dc->active_list);
+ INIT_LIST_HEAD(&dc->queue);
+ INIT_LIST_HEAD(&dc->free_list);
+
+ txx9dmac_reset_chan(dc);
+
+ platform_set_drvdata(pdev, dc);
+
+ err = dma_async_device_register(&dc->dma);
+ if (err)
+ return err;
+ dev_dbg(&pdev->dev, "TXx9 DMA Channel (dma%d%s%s)\n",
+ dc->dma.dev_id,
+ dma_has_cap(DMA_MEMCPY, dc->dma.cap_mask) ? " memcpy" : "",
+ dma_has_cap(DMA_SLAVE, dc->dma.cap_mask) ? " slave" : "");
+
+ return 0;
+}
+
+static int __exit txx9dmac_chan_remove(struct platform_device *pdev)
+{
+ struct txx9dmac_chan *dc = platform_get_drvdata(pdev);
+
+ dma_async_device_unregister(&dc->dma);
+ if (dc->irq >= 0)
+ tasklet_kill(&dc->tasklet);
+ dc->ddev->chan[pdev->id % TXX9_DMA_MAX_NR_CHANNELS] = NULL;
+ return 0;
+}
+
+static int __init txx9dmac_probe(struct platform_device *pdev)
+{
+ struct txx9dmac_platform_data *pdata = pdev->dev.platform_data;
+ struct resource *io;
+ struct txx9dmac_dev *ddev;
+ u32 mcr;
+ int err;
+
+ io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!io)
+ return -EINVAL;
+
+ ddev = devm_kzalloc(&pdev->dev, sizeof(*ddev), GFP_KERNEL);
+ if (!ddev)
+ return -ENOMEM;
+
+ if (!devm_request_mem_region(&pdev->dev, io->start, resource_size(io),
+ dev_name(&pdev->dev)))
+ return -EBUSY;
+
+ ddev->regs = devm_ioremap(&pdev->dev, io->start, resource_size(io));
+ if (!ddev->regs)
+ return -ENOMEM;
+ ddev->have_64bit_regs = pdata->have_64bit_regs;
+ if (__is_dmac64(ddev))
+ ddev->descsize = sizeof(struct txx9dmac_hwdesc);
+ else
+ ddev->descsize = sizeof(struct txx9dmac_hwdesc32);
+
+ /* force dma off, just in case */
+ txx9dmac_off(ddev);
+
+ ddev->irq = platform_get_irq(pdev, 0);
+ if (ddev->irq >= 0) {
+ tasklet_init(&ddev->tasklet, txx9dmac_tasklet,
+ (unsigned long)ddev);
+ err = devm_request_irq(&pdev->dev, ddev->irq,
+ txx9dmac_interrupt, 0, dev_name(&pdev->dev), ddev);
+ if (err)
+ return err;
+ }
+
+ mcr = TXX9_DMA_MCR_MSTEN | MCR_LE;
+ if (pdata && pdata->memcpy_chan >= 0)
+ mcr |= TXX9_DMA_MCR_FIFUM(pdata->memcpy_chan);
+ dma_writel(ddev, MCR, mcr);
+
+ platform_set_drvdata(pdev, ddev);
+ return 0;
+}
+
+static int __exit txx9dmac_remove(struct platform_device *pdev)
+{
+ struct txx9dmac_dev *ddev = platform_get_drvdata(pdev);
+
+ txx9dmac_off(ddev);
+ if (ddev->irq >= 0)
+ tasklet_kill(&ddev->tasklet);
+ return 0;
+}
+
+static void txx9dmac_shutdown(struct platform_device *pdev)
+{
+ struct txx9dmac_dev *ddev = platform_get_drvdata(pdev);
+
+ txx9dmac_off(ddev);
+}
+
+static int txx9dmac_suspend_late(struct platform_device *pdev,
+ pm_message_t mesg)
+{
+ struct txx9dmac_dev *ddev = platform_get_drvdata(pdev);
+
+ txx9dmac_off(ddev);
+ return 0;
+}
+
+static int txx9dmac_resume_early(struct platform_device *pdev)
+{
+ struct txx9dmac_dev *ddev = platform_get_drvdata(pdev);
+ struct txx9dmac_platform_data *pdata = pdev->dev.platform_data;
+ u32 mcr;
+
+ mcr = TXX9_DMA_MCR_MSTEN | MCR_LE;
+ if (pdata && pdata->memcpy_chan >= 0)
+ mcr |= TXX9_DMA_MCR_FIFUM(pdata->memcpy_chan);
+ dma_writel(ddev, MCR, mcr);
+ return 0;
+
+}
+
+static struct platform_driver txx9dmac_chan_driver = {
+ .remove = __exit_p(txx9dmac_chan_remove),
+ .driver = {
+ .name = "txx9dmac-chan",
+ },
+};
+
+static struct platform_driver txx9dmac_driver = {
+ .remove = __exit_p(txx9dmac_remove),
+ .shutdown = txx9dmac_shutdown,
+ .suspend_late = txx9dmac_suspend_late,
+ .resume_early = txx9dmac_resume_early,
+ .driver = {
+ .name = "txx9dmac",
+ },
+};
+
+static int __init txx9dmac_init(void)
+{
+ int rc;
+
+ rc = platform_driver_probe(&txx9dmac_driver, txx9dmac_probe);
+ if (!rc) {
+ rc = platform_driver_probe(&txx9dmac_chan_driver,
+ txx9dmac_chan_probe);
+ if (rc)
+ platform_driver_unregister(&txx9dmac_driver);
+ }
+ return rc;
+}
+module_init(txx9dmac_init);
+
+static void __exit txx9dmac_exit(void)
+{
+ platform_driver_unregister(&txx9dmac_chan_driver);
+ platform_driver_unregister(&txx9dmac_driver);
+}
+module_exit(txx9dmac_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("TXx9 DMA Controller driver");
+MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
diff --git a/drivers/dma/txx9dmac.h b/drivers/dma/txx9dmac.h
new file mode 100644
index 000000000000..c907ff01d276
--- /dev/null
+++ b/drivers/dma/txx9dmac.h
@@ -0,0 +1,307 @@
+/*
+ * Driver for the TXx9 SoC DMA Controller
+ *
+ * Copyright (C) 2009 Atsushi Nemoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef TXX9DMAC_H
+#define TXX9DMAC_H
+
+#include <linux/dmaengine.h>
+#include <asm/txx9/dmac.h>
+
+/*
+ * Design Notes:
+ *
+ * This DMAC have four channels and one FIFO buffer. Each channel can
+ * be configured for memory-memory or device-memory transfer, but only
+ * one channel can do alignment-free memory-memory transfer at a time
+ * while the channel should occupy the FIFO buffer for effective
+ * transfers.
+ *
+ * Instead of dynamically assign the FIFO buffer to channels, I chose
+ * make one dedicated channel for memory-memory transfer. The
+ * dedicated channel is public. Other channels are private and used
+ * for slave transfer. Some devices in the SoC are wired to certain
+ * DMA channel.
+ */
+
+#ifdef CONFIG_MACH_TX49XX
+static inline bool txx9_dma_have_SMPCHN(void)
+{
+ return true;
+}
+#define TXX9_DMA_USE_SIMPLE_CHAIN
+#else
+static inline bool txx9_dma_have_SMPCHN(void)
+{
+ return false;
+}
+#endif
+
+#ifdef __LITTLE_ENDIAN
+#ifdef CONFIG_MACH_TX49XX
+#define CCR_LE TXX9_DMA_CCR_LE
+#define MCR_LE 0
+#else
+#define CCR_LE 0
+#define MCR_LE TXX9_DMA_MCR_LE
+#endif
+#else
+#define CCR_LE 0
+#define MCR_LE 0
+#endif
+
+/*
+ * Redefine this macro to handle differences between 32- and 64-bit
+ * addressing, big vs. little endian, etc.
+ */
+#ifdef __BIG_ENDIAN
+#define TXX9_DMA_REG32(name) u32 __pad_##name; u32 name
+#else
+#define TXX9_DMA_REG32(name) u32 name; u32 __pad_##name
+#endif
+
+/* Hardware register definitions. */
+struct txx9dmac_cregs {
+#if defined(CONFIG_32BIT) && !defined(CONFIG_64BIT_PHYS_ADDR)
+ TXX9_DMA_REG32(CHAR); /* Chain Address Register */
+#else
+ u64 CHAR; /* Chain Address Register */
+#endif
+ u64 SAR; /* Source Address Register */
+ u64 DAR; /* Destination Address Register */
+ TXX9_DMA_REG32(CNTR); /* Count Register */
+ TXX9_DMA_REG32(SAIR); /* Source Address Increment Register */
+ TXX9_DMA_REG32(DAIR); /* Destination Address Increment Register */
+ TXX9_DMA_REG32(CCR); /* Channel Control Register */
+ TXX9_DMA_REG32(CSR); /* Channel Status Register */
+};
+struct txx9dmac_cregs32 {
+ u32 CHAR;
+ u32 SAR;
+ u32 DAR;
+ u32 CNTR;
+ u32 SAIR;
+ u32 DAIR;
+ u32 CCR;
+ u32 CSR;
+};
+
+struct txx9dmac_regs {
+ /* per-channel registers */
+ struct txx9dmac_cregs CHAN[TXX9_DMA_MAX_NR_CHANNELS];
+ u64 __pad[9];
+ u64 MFDR; /* Memory Fill Data Register */
+ TXX9_DMA_REG32(MCR); /* Master Control Register */
+};
+struct txx9dmac_regs32 {
+ struct txx9dmac_cregs32 CHAN[TXX9_DMA_MAX_NR_CHANNELS];
+ u32 __pad[9];
+ u32 MFDR;
+ u32 MCR;
+};
+
+/* bits for MCR */
+#define TXX9_DMA_MCR_EIS(ch) (0x10000000<<(ch))
+#define TXX9_DMA_MCR_DIS(ch) (0x01000000<<(ch))
+#define TXX9_DMA_MCR_RSFIF 0x00000080
+#define TXX9_DMA_MCR_FIFUM(ch) (0x00000008<<(ch))
+#define TXX9_DMA_MCR_LE 0x00000004
+#define TXX9_DMA_MCR_RPRT 0x00000002
+#define TXX9_DMA_MCR_MSTEN 0x00000001
+
+/* bits for CCRn */
+#define TXX9_DMA_CCR_IMMCHN 0x20000000
+#define TXX9_DMA_CCR_USEXFSZ 0x10000000
+#define TXX9_DMA_CCR_LE 0x08000000
+#define TXX9_DMA_CCR_DBINH 0x04000000
+#define TXX9_DMA_CCR_SBINH 0x02000000
+#define TXX9_DMA_CCR_CHRST 0x01000000
+#define TXX9_DMA_CCR_RVBYTE 0x00800000
+#define TXX9_DMA_CCR_ACKPOL 0x00400000
+#define TXX9_DMA_CCR_REQPL 0x00200000
+#define TXX9_DMA_CCR_EGREQ 0x00100000
+#define TXX9_DMA_CCR_CHDN 0x00080000
+#define TXX9_DMA_CCR_DNCTL 0x00060000
+#define TXX9_DMA_CCR_EXTRQ 0x00010000
+#define TXX9_DMA_CCR_INTRQD 0x0000e000
+#define TXX9_DMA_CCR_INTENE 0x00001000
+#define TXX9_DMA_CCR_INTENC 0x00000800
+#define TXX9_DMA_CCR_INTENT 0x00000400
+#define TXX9_DMA_CCR_CHNEN 0x00000200
+#define TXX9_DMA_CCR_XFACT 0x00000100
+#define TXX9_DMA_CCR_SMPCHN 0x00000020
+#define TXX9_DMA_CCR_XFSZ(order) (((order) << 2) & 0x0000001c)
+#define TXX9_DMA_CCR_XFSZ_1 TXX9_DMA_CCR_XFSZ(0)
+#define TXX9_DMA_CCR_XFSZ_2 TXX9_DMA_CCR_XFSZ(1)
+#define TXX9_DMA_CCR_XFSZ_4 TXX9_DMA_CCR_XFSZ(2)
+#define TXX9_DMA_CCR_XFSZ_8 TXX9_DMA_CCR_XFSZ(3)
+#define TXX9_DMA_CCR_XFSZ_X4 TXX9_DMA_CCR_XFSZ(4)
+#define TXX9_DMA_CCR_XFSZ_X8 TXX9_DMA_CCR_XFSZ(5)
+#define TXX9_DMA_CCR_XFSZ_X16 TXX9_DMA_CCR_XFSZ(6)
+#define TXX9_DMA_CCR_XFSZ_X32 TXX9_DMA_CCR_XFSZ(7)
+#define TXX9_DMA_CCR_MEMIO 0x00000002
+#define TXX9_DMA_CCR_SNGAD 0x00000001
+
+/* bits for CSRn */
+#define TXX9_DMA_CSR_CHNEN 0x00000400
+#define TXX9_DMA_CSR_STLXFER 0x00000200
+#define TXX9_DMA_CSR_XFACT 0x00000100
+#define TXX9_DMA_CSR_ABCHC 0x00000080
+#define TXX9_DMA_CSR_NCHNC 0x00000040
+#define TXX9_DMA_CSR_NTRNFC 0x00000020
+#define TXX9_DMA_CSR_EXTDN 0x00000010
+#define TXX9_DMA_CSR_CFERR 0x00000008
+#define TXX9_DMA_CSR_CHERR 0x00000004
+#define TXX9_DMA_CSR_DESERR 0x00000002
+#define TXX9_DMA_CSR_SORERR 0x00000001
+
+struct txx9dmac_chan {
+ struct dma_chan chan;
+ struct dma_device dma;
+ struct txx9dmac_dev *ddev;
+ void __iomem *ch_regs;
+ struct tasklet_struct tasklet;
+ int irq;
+ u32 ccr;
+
+ spinlock_t lock;
+
+ /* these other elements are all protected by lock */
+ dma_cookie_t completed;
+ struct list_head active_list;
+ struct list_head queue;
+ struct list_head free_list;
+
+ unsigned int descs_allocated;
+};
+
+struct txx9dmac_dev {
+ void __iomem *regs;
+ struct tasklet_struct tasklet;
+ int irq;
+ struct txx9dmac_chan *chan[TXX9_DMA_MAX_NR_CHANNELS];
+ bool have_64bit_regs;
+ unsigned int descsize;
+};
+
+static inline bool __is_dmac64(const struct txx9dmac_dev *ddev)
+{
+ return ddev->have_64bit_regs;
+}
+
+static inline bool is_dmac64(const struct txx9dmac_chan *dc)
+{
+ return __is_dmac64(dc->ddev);
+}
+
+#ifdef TXX9_DMA_USE_SIMPLE_CHAIN
+/* Hardware descriptor definition. (for simple-chain) */
+struct txx9dmac_hwdesc {
+#if defined(CONFIG_32BIT) && !defined(CONFIG_64BIT_PHYS_ADDR)
+ TXX9_DMA_REG32(CHAR);
+#else
+ u64 CHAR;
+#endif
+ u64 SAR;
+ u64 DAR;
+ TXX9_DMA_REG32(CNTR);
+};
+struct txx9dmac_hwdesc32 {
+ u32 CHAR;
+ u32 SAR;
+ u32 DAR;
+ u32 CNTR;
+};
+#else
+#define txx9dmac_hwdesc txx9dmac_cregs
+#define txx9dmac_hwdesc32 txx9dmac_cregs32
+#endif
+
+struct txx9dmac_desc {
+ /* FIRST values the hardware uses */
+ union {
+ struct txx9dmac_hwdesc hwdesc;
+ struct txx9dmac_hwdesc32 hwdesc32;
+ };
+
+ /* THEN values for driver housekeeping */
+ struct list_head desc_node ____cacheline_aligned;
+ struct dma_async_tx_descriptor txd;
+ size_t len;
+};
+
+#ifdef TXX9_DMA_USE_SIMPLE_CHAIN
+
+static inline bool txx9dmac_chan_INTENT(struct txx9dmac_chan *dc)
+{
+ return (dc->ccr & TXX9_DMA_CCR_INTENT) != 0;
+}
+
+static inline void txx9dmac_chan_set_INTENT(struct txx9dmac_chan *dc)
+{
+ dc->ccr |= TXX9_DMA_CCR_INTENT;
+}
+
+static inline void txx9dmac_desc_set_INTENT(struct txx9dmac_dev *ddev,
+ struct txx9dmac_desc *desc)
+{
+}
+
+static inline void txx9dmac_chan_set_SMPCHN(struct txx9dmac_chan *dc)
+{
+ dc->ccr |= TXX9_DMA_CCR_SMPCHN;
+}
+
+static inline void txx9dmac_desc_set_nosimple(struct txx9dmac_dev *ddev,
+ struct txx9dmac_desc *desc,
+ u32 sair, u32 dair, u32 ccr)
+{
+}
+
+#else /* TXX9_DMA_USE_SIMPLE_CHAIN */
+
+static inline bool txx9dmac_chan_INTENT(struct txx9dmac_chan *dc)
+{
+ return true;
+}
+
+static void txx9dmac_chan_set_INTENT(struct txx9dmac_chan *dc)
+{
+}
+
+static inline void txx9dmac_desc_set_INTENT(struct txx9dmac_dev *ddev,
+ struct txx9dmac_desc *desc)
+{
+ if (__is_dmac64(ddev))
+ desc->hwdesc.CCR |= TXX9_DMA_CCR_INTENT;
+ else
+ desc->hwdesc32.CCR |= TXX9_DMA_CCR_INTENT;
+}
+
+static inline void txx9dmac_chan_set_SMPCHN(struct txx9dmac_chan *dc)
+{
+}
+
+static inline void txx9dmac_desc_set_nosimple(struct txx9dmac_dev *ddev,
+ struct txx9dmac_desc *desc,
+ u32 sai, u32 dai, u32 ccr)
+{
+ if (__is_dmac64(ddev)) {
+ desc->hwdesc.SAIR = sai;
+ desc->hwdesc.DAIR = dai;
+ desc->hwdesc.CCR = ccr;
+ } else {
+ desc->hwdesc32.SAIR = sai;
+ desc->hwdesc32.DAIR = dai;
+ desc->hwdesc32.CCR = ccr;
+ }
+}
+
+#endif /* TXX9_DMA_USE_SIMPLE_CHAIN */
+
+#endif /* TXX9DMAC_H */
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index e5f5c5a8ba6c..bb2cff8eeff9 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -49,7 +49,6 @@ config EDAC_DEBUG_VERBOSE
config EDAC_MM_EDAC
tristate "Main Memory EDAC (Error Detection And Correction) reporting"
- default y
help
Some systems are able to detect and correct errors in main
memory. EDAC can report statistics on memory error
@@ -58,6 +57,31 @@ config EDAC_MM_EDAC
occurred so that a particular failing memory module can be
replaced. If unsure, select 'Y'.
+config EDAC_AMD64
+ tristate "AMD64 (Opteron, Athlon64) K8, F10h, F11h"
+ depends on EDAC_MM_EDAC && K8_NB && X86_64 && PCI
+ help
+ Support for error detection and correction on the AMD 64
+ Families of Memory Controllers (K8, F10h and F11h)
+
+config EDAC_AMD64_ERROR_INJECTION
+ bool "Sysfs Error Injection facilities"
+ depends on EDAC_AMD64
+ help
+ Recent Opterons (Family 10h and later) provide for Memory Error
+ Injection into the ECC detection circuits. The amd64_edac module
+ allows the operator/user to inject Uncorrectable and Correctable
+ errors into DRAM.
+
+ When enabled, in each of the respective memory controller directories
+ (/sys/devices/system/edac/mc/mcX), there are 3 input files:
+
+ - inject_section (0..3, 16-byte section of 64-byte cacheline),
+ - inject_word (0..8, 16-bit word of 16-byte section),
+ - inject_ecc_vector (hex ecc vector: select bits of inject word)
+
+ In addition, there are two control files, inject_read and inject_write,
+ which trigger the DRAM ECC Read and Write respectively.
config EDAC_AMD76X
tristate "AMD 76x (760, 762, 768)"
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index a5fdcf02f591..6f334e69239d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -30,6 +30,13 @@ obj-$(CONFIG_EDAC_I3000) += i3000_edac.o
obj-$(CONFIG_EDAC_X38) += x38_edac.o
obj-$(CONFIG_EDAC_I82860) += i82860_edac.o
obj-$(CONFIG_EDAC_R82600) += r82600_edac.o
+
+amd64_edac_mod-y := amd64_edac_err_types.o amd64_edac.o
+amd64_edac_mod-$(CONFIG_EDAC_DEBUG) += amd64_edac_dbg.o
+amd64_edac_mod-$(CONFIG_EDAC_AMD64_ERROR_INJECTION) += amd64_edac_inj.o
+
+obj-$(CONFIG_EDAC_AMD64) += amd64_edac_mod.o
+
obj-$(CONFIG_EDAC_PASEMI) += pasemi_edac.o
obj-$(CONFIG_EDAC_MPC85XX) += mpc85xx_edac.o
obj-$(CONFIG_EDAC_MV64X60) += mv64x60_edac.o
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
new file mode 100644
index 000000000000..46e0a254840b
--- /dev/null
+++ b/drivers/edac/amd64_edac.c
@@ -0,0 +1,3354 @@
+#include "amd64_edac.h"
+#include <asm/k8.h>
+
+static struct edac_pci_ctl_info *amd64_ctl_pci;
+
+static int report_gart_errors;
+module_param(report_gart_errors, int, 0644);
+
+/*
+ * Set by command line parameter. If BIOS has enabled the ECC, this override is
+ * cleared to prevent re-enabling the hardware by this driver.
+ */
+static int ecc_enable_override;
+module_param(ecc_enable_override, int, 0644);
+
+/* Lookup table for all possible MC control instances */
+struct amd64_pvt;
+static struct mem_ctl_info *mci_lookup[MAX_NUMNODES];
+static struct amd64_pvt *pvt_lookup[MAX_NUMNODES];
+
+/*
+ * Memory scrubber control interface. For K8, memory scrubbing is handled by
+ * hardware and can involve L2 cache, dcache as well as the main memory. With
+ * F10, this is extended to L3 cache scrubbing on CPU models sporting that
+ * functionality.
+ *
+ * This causes the "units" for the scrubbing speed to vary from 64 byte blocks
+ * (dram) over to cache lines. This is nasty, so we will use bandwidth in
+ * bytes/sec for the setting.
+ *
+ * Currently, we only do dram scrubbing. If the scrubbing is done in software on
+ * other archs, we might not have access to the caches directly.
+ */
+
+/*
+ * scan the scrub rate mapping table for a close or matching bandwidth value to
+ * issue. If requested is too big, then use last maximum value found.
+ */
+static int amd64_search_set_scrub_rate(struct pci_dev *ctl, u32 new_bw,
+ u32 min_scrubrate)
+{
+ u32 scrubval;
+ int i;
+
+ /*
+ * map the configured rate (new_bw) to a value specific to the AMD64
+ * memory controller and apply to register. Search for the first
+ * bandwidth entry that is greater or equal than the setting requested
+ * and program that. If at last entry, turn off DRAM scrubbing.
+ */
+ for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
+ /*
+ * skip scrub rates which aren't recommended
+ * (see F10 BKDG, F3x58)
+ */
+ if (scrubrates[i].scrubval < min_scrubrate)
+ continue;
+
+ if (scrubrates[i].bandwidth <= new_bw)
+ break;
+
+ /*
+ * if no suitable bandwidth found, turn off DRAM scrubbing
+ * entirely by falling back to the last element in the
+ * scrubrates array.
+ */
+ }
+
+ scrubval = scrubrates[i].scrubval;
+ if (scrubval)
+ edac_printk(KERN_DEBUG, EDAC_MC,
+ "Setting scrub rate bandwidth: %u\n",
+ scrubrates[i].bandwidth);
+ else
+ edac_printk(KERN_DEBUG, EDAC_MC, "Turning scrubbing off.\n");
+
+ pci_write_bits32(ctl, K8_SCRCTRL, scrubval, 0x001F);
+
+ return 0;
+}
+
+static int amd64_set_scrub_rate(struct mem_ctl_info *mci, u32 *bandwidth)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u32 min_scrubrate = 0x0;
+
+ switch (boot_cpu_data.x86) {
+ case 0xf:
+ min_scrubrate = K8_MIN_SCRUB_RATE_BITS;
+ break;
+ case 0x10:
+ min_scrubrate = F10_MIN_SCRUB_RATE_BITS;
+ break;
+ case 0x11:
+ min_scrubrate = F11_MIN_SCRUB_RATE_BITS;
+ break;
+
+ default:
+ amd64_printk(KERN_ERR, "Unsupported family!\n");
+ break;
+ }
+ return amd64_search_set_scrub_rate(pvt->misc_f3_ctl, *bandwidth,
+ min_scrubrate);
+}
+
+static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u32 scrubval = 0;
+ int status = -1, i, ret = 0;
+
+ ret = pci_read_config_dword(pvt->misc_f3_ctl, K8_SCRCTRL, &scrubval);
+ if (ret)
+ debugf0("Reading K8_SCRCTRL failed\n");
+
+ scrubval = scrubval & 0x001F;
+
+ edac_printk(KERN_DEBUG, EDAC_MC,
+ "pci-read, sdram scrub control value: %d \n", scrubval);
+
+ for (i = 0; ARRAY_SIZE(scrubrates); i++) {
+ if (scrubrates[i].scrubval == scrubval) {
+ *bw = scrubrates[i].bandwidth;
+ status = 0;
+ break;
+ }
+ }
+
+ return status;
+}
+
+/* Map from a CSROW entry to the mask entry that operates on it */
+static inline u32 amd64_map_to_dcs_mask(struct amd64_pvt *pvt, int csrow)
+{
+ return csrow >> (pvt->num_dcsm >> 3);
+}
+
+/* return the 'base' address the i'th CS entry of the 'dct' DRAM controller */
+static u32 amd64_get_dct_base(struct amd64_pvt *pvt, int dct, int csrow)
+{
+ if (dct == 0)
+ return pvt->dcsb0[csrow];
+ else
+ return pvt->dcsb1[csrow];
+}
+
+/*
+ * Return the 'mask' address the i'th CS entry. This function is needed because
+ * there number of DCSM registers on Rev E and prior vs Rev F and later is
+ * different.
+ */
+static u32 amd64_get_dct_mask(struct amd64_pvt *pvt, int dct, int csrow)
+{
+ if (dct == 0)
+ return pvt->dcsm0[amd64_map_to_dcs_mask(pvt, csrow)];
+ else
+ return pvt->dcsm1[amd64_map_to_dcs_mask(pvt, csrow)];
+}
+
+
+/*
+ * In *base and *limit, pass back the full 40-bit base and limit physical
+ * addresses for the node given by node_id. This information is obtained from
+ * DRAM Base (section 3.4.4.1) and DRAM Limit (section 3.4.4.2) registers. The
+ * base and limit addresses are of type SysAddr, as defined at the start of
+ * section 3.4.4 (p. 70). They are the lowest and highest physical addresses
+ * in the address range they represent.
+ */
+static void amd64_get_base_and_limit(struct amd64_pvt *pvt, int node_id,
+ u64 *base, u64 *limit)
+{
+ *base = pvt->dram_base[node_id];
+ *limit = pvt->dram_limit[node_id];
+}
+
+/*
+ * Return 1 if the SysAddr given by sys_addr matches the base/limit associated
+ * with node_id
+ */
+static int amd64_base_limit_match(struct amd64_pvt *pvt,
+ u64 sys_addr, int node_id)
+{
+ u64 base, limit, addr;
+
+ amd64_get_base_and_limit(pvt, node_id, &base, &limit);
+
+ /* The K8 treats this as a 40-bit value. However, bits 63-40 will be
+ * all ones if the most significant implemented address bit is 1.
+ * Here we discard bits 63-40. See section 3.4.2 of AMD publication
+ * 24592: AMD x86-64 Architecture Programmer's Manual Volume 1
+ * Application Programming.
+ */
+ addr = sys_addr & 0x000000ffffffffffull;
+
+ return (addr >= base) && (addr <= limit);
+}
+
+/*
+ * Attempt to map a SysAddr to a node. On success, return a pointer to the
+ * mem_ctl_info structure for the node that the SysAddr maps to.
+ *
+ * On failure, return NULL.
+ */
+static struct mem_ctl_info *find_mc_by_sys_addr(struct mem_ctl_info *mci,
+ u64 sys_addr)
+{
+ struct amd64_pvt *pvt;
+ int node_id;
+ u32 intlv_en, bits;
+
+ /*
+ * Here we use the DRAM Base (section 3.4.4.1) and DRAM Limit (section
+ * 3.4.4.2) registers to map the SysAddr to a node ID.
+ */
+ pvt = mci->pvt_info;
+
+ /*
+ * The value of this field should be the same for all DRAM Base
+ * registers. Therefore we arbitrarily choose to read it from the
+ * register for node 0.
+ */
+ intlv_en = pvt->dram_IntlvEn[0];
+
+ if (intlv_en == 0) {
+ for (node_id = 0; ; ) {
+ if (amd64_base_limit_match(pvt, sys_addr, node_id))
+ break;
+
+ if (++node_id >= DRAM_REG_COUNT)
+ goto err_no_match;
+ }
+ goto found;
+ }
+
+ if (unlikely((intlv_en != (0x01 << 8)) &&
+ (intlv_en != (0x03 << 8)) &&
+ (intlv_en != (0x07 << 8)))) {
+ amd64_printk(KERN_WARNING, "junk value of 0x%x extracted from "
+ "IntlvEn field of DRAM Base Register for node 0: "
+ "This probably indicates a BIOS bug.\n", intlv_en);
+ return NULL;
+ }
+
+ bits = (((u32) sys_addr) >> 12) & intlv_en;
+
+ for (node_id = 0; ; ) {
+ if ((pvt->dram_limit[node_id] & intlv_en) == bits)
+ break; /* intlv_sel field matches */
+
+ if (++node_id >= DRAM_REG_COUNT)
+ goto err_no_match;
+ }
+
+ /* sanity test for sys_addr */
+ if (unlikely(!amd64_base_limit_match(pvt, sys_addr, node_id))) {
+ amd64_printk(KERN_WARNING,
+ "%s(): sys_addr 0x%lx falls outside base/limit "
+ "address range for node %d with node interleaving "
+ "enabled.\n", __func__, (unsigned long)sys_addr,
+ node_id);
+ return NULL;
+ }
+
+found:
+ return edac_mc_find(node_id);
+
+err_no_match:
+ debugf2("sys_addr 0x%lx doesn't match any node\n",
+ (unsigned long)sys_addr);
+
+ return NULL;
+}
+
+/*
+ * Extract the DRAM CS base address from selected csrow register.
+ */
+static u64 base_from_dct_base(struct amd64_pvt *pvt, int csrow)
+{
+ return ((u64) (amd64_get_dct_base(pvt, 0, csrow) & pvt->dcsb_base)) <<
+ pvt->dcs_shift;
+}
+
+/*
+ * Extract the mask from the dcsb0[csrow] entry in a CPU revision-specific way.
+ */
+static u64 mask_from_dct_mask(struct amd64_pvt *pvt, int csrow)
+{
+ u64 dcsm_bits, other_bits;
+ u64 mask;
+
+ /* Extract bits from DRAM CS Mask. */
+ dcsm_bits = amd64_get_dct_mask(pvt, 0, csrow) & pvt->dcsm_mask;
+
+ other_bits = pvt->dcsm_mask;
+ other_bits = ~(other_bits << pvt->dcs_shift);
+
+ /*
+ * The extracted bits from DCSM belong in the spaces represented by
+ * the cleared bits in other_bits.
+ */
+ mask = (dcsm_bits << pvt->dcs_shift) | other_bits;
+
+ return mask;
+}
+
+/*
+ * @input_addr is an InputAddr associated with the node given by mci. Return the
+ * csrow that input_addr maps to, or -1 on failure (no csrow claims input_addr).
+ */
+static int input_addr_to_csrow(struct mem_ctl_info *mci, u64 input_addr)
+{
+ struct amd64_pvt *pvt;
+ int csrow;
+ u64 base, mask;
+
+ pvt = mci->pvt_info;
+
+ /*
+ * Here we use the DRAM CS Base and DRAM CS Mask registers. For each CS
+ * base/mask register pair, test the condition shown near the start of
+ * section 3.5.4 (p. 84, BKDG #26094, K8, revA-E).
+ */
+ for (csrow = 0; csrow < CHIPSELECT_COUNT; csrow++) {
+
+ /* This DRAM chip select is disabled on this node */
+ if ((pvt->dcsb0[csrow] & K8_DCSB_CS_ENABLE) == 0)
+ continue;
+
+ base = base_from_dct_base(pvt, csrow);
+ mask = ~mask_from_dct_mask(pvt, csrow);
+
+ if ((input_addr & mask) == (base & mask)) {
+ debugf2("InputAddr 0x%lx matches csrow %d (node %d)\n",
+ (unsigned long)input_addr, csrow,
+ pvt->mc_node_id);
+
+ return csrow;
+ }
+ }
+
+ debugf2("no matching csrow for InputAddr 0x%lx (MC node %d)\n",
+ (unsigned long)input_addr, pvt->mc_node_id);
+
+ return -1;
+}
+
+/*
+ * Return the base value defined by the DRAM Base register for the node
+ * represented by mci. This function returns the full 40-bit value despite the
+ * fact that the register only stores bits 39-24 of the value. See section
+ * 3.4.4.1 (BKDG #26094, K8, revA-E)
+ */
+static inline u64 get_dram_base(struct mem_ctl_info *mci)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return pvt->dram_base[pvt->mc_node_id];
+}
+
+/*
+ * Obtain info from the DRAM Hole Address Register (section 3.4.8, pub #26094)
+ * for the node represented by mci. Info is passed back in *hole_base,
+ * *hole_offset, and *hole_size. Function returns 0 if info is valid or 1 if
+ * info is invalid. Info may be invalid for either of the following reasons:
+ *
+ * - The revision of the node is not E or greater. In this case, the DRAM Hole
+ * Address Register does not exist.
+ *
+ * - The DramHoleValid bit is cleared in the DRAM Hole Address Register,
+ * indicating that its contents are not valid.
+ *
+ * The values passed back in *hole_base, *hole_offset, and *hole_size are
+ * complete 32-bit values despite the fact that the bitfields in the DHAR
+ * only represent bits 31-24 of the base and offset values.
+ */
+int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
+ u64 *hole_offset, u64 *hole_size)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u64 base;
+
+ /* only revE and later have the DRAM Hole Address Register */
+ if (boot_cpu_data.x86 == 0xf && pvt->ext_model < OPTERON_CPU_REV_E) {
+ debugf1(" revision %d for node %d does not support DHAR\n",
+ pvt->ext_model, pvt->mc_node_id);
+ return 1;
+ }
+
+ /* only valid for Fam10h */
+ if (boot_cpu_data.x86 == 0x10 &&
+ (pvt->dhar & F10_DRAM_MEM_HOIST_VALID) == 0) {
+ debugf1(" Dram Memory Hoisting is DISABLED on this system\n");
+ return 1;
+ }
+
+ if ((pvt->dhar & DHAR_VALID) == 0) {
+ debugf1(" Dram Memory Hoisting is DISABLED on this node %d\n",
+ pvt->mc_node_id);
+ return 1;
+ }
+
+ /* This node has Memory Hoisting */
+
+ /* +------------------+--------------------+--------------------+-----
+ * | memory | DRAM hole | relocated |
+ * | [0, (x - 1)] | [x, 0xffffffff] | addresses from |
+ * | | | DRAM hole |
+ * | | | [0x100000000, |
+ * | | | (0x100000000+ |
+ * | | | (0xffffffff-x))] |
+ * +------------------+--------------------+--------------------+-----
+ *
+ * Above is a diagram of physical memory showing the DRAM hole and the
+ * relocated addresses from the DRAM hole. As shown, the DRAM hole
+ * starts at address x (the base address) and extends through address
+ * 0xffffffff. The DRAM Hole Address Register (DHAR) relocates the
+ * addresses in the hole so that they start at 0x100000000.
+ */
+
+ base = dhar_base(pvt->dhar);
+
+ *hole_base = base;
+ *hole_size = (0x1ull << 32) - base;
+
+ if (boot_cpu_data.x86 > 0xf)
+ *hole_offset = f10_dhar_offset(pvt->dhar);
+ else
+ *hole_offset = k8_dhar_offset(pvt->dhar);
+
+ debugf1(" DHAR info for node %d base 0x%lx offset 0x%lx size 0x%lx\n",
+ pvt->mc_node_id, (unsigned long)*hole_base,
+ (unsigned long)*hole_offset, (unsigned long)*hole_size);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(amd64_get_dram_hole_info);
+
+/*
+ * Return the DramAddr that the SysAddr given by @sys_addr maps to. It is
+ * assumed that sys_addr maps to the node given by mci.
+ *
+ * The first part of section 3.4.4 (p. 70) shows how the DRAM Base (section
+ * 3.4.4.1) and DRAM Limit (section 3.4.4.2) registers are used to translate a
+ * SysAddr to a DramAddr. If the DRAM Hole Address Register (DHAR) is enabled,
+ * then it is also involved in translating a SysAddr to a DramAddr. Sections
+ * 3.4.8 and 3.5.8.2 describe the DHAR and how it is used for memory hoisting.
+ * These parts of the documentation are unclear. I interpret them as follows:
+ *
+ * When node n receives a SysAddr, it processes the SysAddr as follows:
+ *
+ * 1. It extracts the DRAMBase and DRAMLimit values from the DRAM Base and DRAM
+ * Limit registers for node n. If the SysAddr is not within the range
+ * specified by the base and limit values, then node n ignores the Sysaddr
+ * (since it does not map to node n). Otherwise continue to step 2 below.
+ *
+ * 2. If the DramHoleValid bit of the DHAR for node n is clear, the DHAR is
+ * disabled so skip to step 3 below. Otherwise see if the SysAddr is within
+ * the range of relocated addresses (starting at 0x100000000) from the DRAM
+ * hole. If not, skip to step 3 below. Else get the value of the
+ * DramHoleOffset field from the DHAR. To obtain the DramAddr, subtract the
+ * offset defined by this value from the SysAddr.
+ *
+ * 3. Obtain the base address for node n from the DRAMBase field of the DRAM
+ * Base register for node n. To obtain the DramAddr, subtract the base
+ * address from the SysAddr, as shown near the start of section 3.4.4 (p.70).
+ */
+static u64 sys_addr_to_dram_addr(struct mem_ctl_info *mci, u64 sys_addr)
+{
+ u64 dram_base, hole_base, hole_offset, hole_size, dram_addr;
+ int ret = 0;
+
+ dram_base = get_dram_base(mci);
+
+ ret = amd64_get_dram_hole_info(mci, &hole_base, &hole_offset,
+ &hole_size);
+ if (!ret) {
+ if ((sys_addr >= (1ull << 32)) &&
+ (sys_addr < ((1ull << 32) + hole_size))) {
+ /* use DHAR to translate SysAddr to DramAddr */
+ dram_addr = sys_addr - hole_offset;
+
+ debugf2("using DHAR to translate SysAddr 0x%lx to "
+ "DramAddr 0x%lx\n",
+ (unsigned long)sys_addr,
+ (unsigned long)dram_addr);
+
+ return dram_addr;
+ }
+ }
+
+ /*
+ * Translate the SysAddr to a DramAddr as shown near the start of
+ * section 3.4.4 (p. 70). Although sys_addr is a 64-bit value, the k8
+ * only deals with 40-bit values. Therefore we discard bits 63-40 of
+ * sys_addr below. If bit 39 of sys_addr is 1 then the bits we
+ * discard are all 1s. Otherwise the bits we discard are all 0s. See
+ * section 3.4.2 of AMD publication 24592: AMD x86-64 Architecture
+ * Programmer's Manual Volume 1 Application Programming.
+ */
+ dram_addr = (sys_addr & 0xffffffffffull) - dram_base;
+
+ debugf2("using DRAM Base register to translate SysAddr 0x%lx to "
+ "DramAddr 0x%lx\n", (unsigned long)sys_addr,
+ (unsigned long)dram_addr);
+ return dram_addr;
+}
+
+/*
+ * @intlv_en is the value of the IntlvEn field from a DRAM Base register
+ * (section 3.4.4.1). Return the number of bits from a SysAddr that are used
+ * for node interleaving.
+ */
+static int num_node_interleave_bits(unsigned intlv_en)
+{
+ static const int intlv_shift_table[] = { 0, 1, 0, 2, 0, 0, 0, 3 };
+ int n;
+
+ BUG_ON(intlv_en > 7);
+ n = intlv_shift_table[intlv_en];
+ return n;
+}
+
+/* Translate the DramAddr given by @dram_addr to an InputAddr. */
+static u64 dram_addr_to_input_addr(struct mem_ctl_info *mci, u64 dram_addr)
+{
+ struct amd64_pvt *pvt;
+ int intlv_shift;
+ u64 input_addr;
+
+ pvt = mci->pvt_info;
+
+ /*
+ * See the start of section 3.4.4 (p. 70, BKDG #26094, K8, revA-E)
+ * concerning translating a DramAddr to an InputAddr.
+ */
+ intlv_shift = num_node_interleave_bits(pvt->dram_IntlvEn[0]);
+ input_addr = ((dram_addr >> intlv_shift) & 0xffffff000ull) +
+ (dram_addr & 0xfff);
+
+ debugf2(" Intlv Shift=%d DramAddr=0x%lx maps to InputAddr=0x%lx\n",
+ intlv_shift, (unsigned long)dram_addr,
+ (unsigned long)input_addr);
+
+ return input_addr;
+}
+
+/*
+ * Translate the SysAddr represented by @sys_addr to an InputAddr. It is
+ * assumed that @sys_addr maps to the node given by mci.
+ */
+static u64 sys_addr_to_input_addr(struct mem_ctl_info *mci, u64 sys_addr)
+{
+ u64 input_addr;
+
+ input_addr =
+ dram_addr_to_input_addr(mci, sys_addr_to_dram_addr(mci, sys_addr));
+
+ debugf2("SysAdddr 0x%lx translates to InputAddr 0x%lx\n",
+ (unsigned long)sys_addr, (unsigned long)input_addr);
+
+ return input_addr;
+}
+
+
+/*
+ * @input_addr is an InputAddr associated with the node represented by mci.
+ * Translate @input_addr to a DramAddr and return the result.
+ */
+static u64 input_addr_to_dram_addr(struct mem_ctl_info *mci, u64 input_addr)
+{
+ struct amd64_pvt *pvt;
+ int node_id, intlv_shift;
+ u64 bits, dram_addr;
+ u32 intlv_sel;
+
+ /*
+ * Near the start of section 3.4.4 (p. 70, BKDG #26094, K8, revA-E)
+ * shows how to translate a DramAddr to an InputAddr. Here we reverse
+ * this procedure. When translating from a DramAddr to an InputAddr, the
+ * bits used for node interleaving are discarded. Here we recover these
+ * bits from the IntlvSel field of the DRAM Limit register (section
+ * 3.4.4.2) for the node that input_addr is associated with.
+ */
+ pvt = mci->pvt_info;
+ node_id = pvt->mc_node_id;
+ BUG_ON((node_id < 0) || (node_id > 7));
+
+ intlv_shift = num_node_interleave_bits(pvt->dram_IntlvEn[0]);
+
+ if (intlv_shift == 0) {
+ debugf1(" InputAddr 0x%lx translates to DramAddr of "
+ "same value\n", (unsigned long)input_addr);
+
+ return input_addr;
+ }
+
+ bits = ((input_addr & 0xffffff000ull) << intlv_shift) +
+ (input_addr & 0xfff);
+
+ intlv_sel = pvt->dram_IntlvSel[node_id] & ((1 << intlv_shift) - 1);
+ dram_addr = bits + (intlv_sel << 12);
+
+ debugf1("InputAddr 0x%lx translates to DramAddr 0x%lx "
+ "(%d node interleave bits)\n", (unsigned long)input_addr,
+ (unsigned long)dram_addr, intlv_shift);
+
+ return dram_addr;
+}
+
+/*
+ * @dram_addr is a DramAddr that maps to the node represented by mci. Convert
+ * @dram_addr to a SysAddr.
+ */
+static u64 dram_addr_to_sys_addr(struct mem_ctl_info *mci, u64 dram_addr)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u64 hole_base, hole_offset, hole_size, base, limit, sys_addr;
+ int ret = 0;
+
+ ret = amd64_get_dram_hole_info(mci, &hole_base, &hole_offset,
+ &hole_size);
+ if (!ret) {
+ if ((dram_addr >= hole_base) &&
+ (dram_addr < (hole_base + hole_size))) {
+ sys_addr = dram_addr + hole_offset;
+
+ debugf1("using DHAR to translate DramAddr 0x%lx to "
+ "SysAddr 0x%lx\n", (unsigned long)dram_addr,
+ (unsigned long)sys_addr);
+
+ return sys_addr;
+ }
+ }
+
+ amd64_get_base_and_limit(pvt, pvt->mc_node_id, &base, &limit);
+ sys_addr = dram_addr + base;
+
+ /*
+ * The sys_addr we have computed up to this point is a 40-bit value
+ * because the k8 deals with 40-bit values. However, the value we are
+ * supposed to return is a full 64-bit physical address. The AMD
+ * x86-64 architecture specifies that the most significant implemented
+ * address bit through bit 63 of a physical address must be either all
+ * 0s or all 1s. Therefore we sign-extend the 40-bit sys_addr to a
+ * 64-bit value below. See section 3.4.2 of AMD publication 24592:
+ * AMD x86-64 Architecture Programmer's Manual Volume 1 Application
+ * Programming.
+ */
+ sys_addr |= ~((sys_addr & (1ull << 39)) - 1);
+
+ debugf1(" Node %d, DramAddr 0x%lx to SysAddr 0x%lx\n",
+ pvt->mc_node_id, (unsigned long)dram_addr,
+ (unsigned long)sys_addr);
+
+ return sys_addr;
+}
+
+/*
+ * @input_addr is an InputAddr associated with the node given by mci. Translate
+ * @input_addr to a SysAddr.
+ */
+static inline u64 input_addr_to_sys_addr(struct mem_ctl_info *mci,
+ u64 input_addr)
+{
+ return dram_addr_to_sys_addr(mci,
+ input_addr_to_dram_addr(mci, input_addr));
+}
+
+/*
+ * Find the minimum and maximum InputAddr values that map to the given @csrow.
+ * Pass back these values in *input_addr_min and *input_addr_max.
+ */
+static void find_csrow_limits(struct mem_ctl_info *mci, int csrow,
+ u64 *input_addr_min, u64 *input_addr_max)
+{
+ struct amd64_pvt *pvt;
+ u64 base, mask;
+
+ pvt = mci->pvt_info;
+ BUG_ON((csrow < 0) || (csrow >= CHIPSELECT_COUNT));
+
+ base = base_from_dct_base(pvt, csrow);
+ mask = mask_from_dct_mask(pvt, csrow);
+
+ *input_addr_min = base & ~mask;
+ *input_addr_max = base | mask | pvt->dcs_mask_notused;
+}
+
+/*
+ * Extract error address from MCA NB Address Low (section 3.6.4.5) and MCA NB
+ * Address High (section 3.6.4.6) register values and return the result. Address
+ * is located in the info structure (nbeah and nbeal), the encoding is device
+ * specific.
+ */
+static u64 extract_error_address(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return pvt->ops->get_error_address(mci, info);
+}
+
+
+/* Map the Error address to a PAGE and PAGE OFFSET. */
+static inline void error_address_to_page_and_offset(u64 error_address,
+ u32 *page, u32 *offset)
+{
+ *page = (u32) (error_address >> PAGE_SHIFT);
+ *offset = ((u32) error_address) & ~PAGE_MASK;
+}
+
+/*
+ * @sys_addr is an error address (a SysAddr) extracted from the MCA NB Address
+ * Low (section 3.6.4.5) and MCA NB Address High (section 3.6.4.6) registers
+ * of a node that detected an ECC memory error. mci represents the node that
+ * the error address maps to (possibly different from the node that detected
+ * the error). Return the number of the csrow that sys_addr maps to, or -1 on
+ * error.
+ */
+static int sys_addr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr)
+{
+ int csrow;
+
+ csrow = input_addr_to_csrow(mci, sys_addr_to_input_addr(mci, sys_addr));
+
+ if (csrow == -1)
+ amd64_mc_printk(mci, KERN_ERR,
+ "Failed to translate InputAddr to csrow for "
+ "address 0x%lx\n", (unsigned long)sys_addr);
+ return csrow;
+}
+
+static int get_channel_from_ecc_syndrome(unsigned short syndrome);
+
+static void amd64_cpu_display_info(struct amd64_pvt *pvt)
+{
+ if (boot_cpu_data.x86 == 0x11)
+ edac_printk(KERN_DEBUG, EDAC_MC, "F11h CPU detected\n");
+ else if (boot_cpu_data.x86 == 0x10)
+ edac_printk(KERN_DEBUG, EDAC_MC, "F10h CPU detected\n");
+ else if (boot_cpu_data.x86 == 0xf)
+ edac_printk(KERN_DEBUG, EDAC_MC, "%s detected\n",
+ (pvt->ext_model >= OPTERON_CPU_REV_F) ?
+ "Rev F or later" : "Rev E or earlier");
+ else
+ /* we'll hardly ever ever get here */
+ edac_printk(KERN_ERR, EDAC_MC, "Unknown cpu!\n");
+}
+
+/*
+ * Determine if the DIMMs have ECC enabled. ECC is enabled ONLY if all the DIMMs
+ * are ECC capable.
+ */
+static enum edac_type amd64_determine_edac_cap(struct amd64_pvt *pvt)
+{
+ int bit;
+ enum dev_type edac_cap = EDAC_NONE;
+
+ bit = (boot_cpu_data.x86 > 0xf || pvt->ext_model >= OPTERON_CPU_REV_F)
+ ? 19
+ : 17;
+
+ if (pvt->dclr0 >> BIT(bit))
+ edac_cap = EDAC_FLAG_SECDED;
+
+ return edac_cap;
+}
+
+
+static void f10_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt,
+ int ganged);
+
+/* Display and decode various NB registers for debug purposes. */
+static void amd64_dump_misc_regs(struct amd64_pvt *pvt)
+{
+ int ganged;
+
+ debugf1(" nbcap:0x%8.08x DctDualCap=%s DualNode=%s 8-Node=%s\n",
+ pvt->nbcap,
+ (pvt->nbcap & K8_NBCAP_DCT_DUAL) ? "True" : "False",
+ (pvt->nbcap & K8_NBCAP_DUAL_NODE) ? "True" : "False",
+ (pvt->nbcap & K8_NBCAP_8_NODE) ? "True" : "False");
+ debugf1(" ECC Capable=%s ChipKill Capable=%s\n",
+ (pvt->nbcap & K8_NBCAP_SECDED) ? "True" : "False",
+ (pvt->nbcap & K8_NBCAP_CHIPKILL) ? "True" : "False");
+ debugf1(" DramCfg0-low=0x%08x DIMM-ECC=%s Parity=%s Width=%s\n",
+ pvt->dclr0,
+ (pvt->dclr0 & BIT(19)) ? "Enabled" : "Disabled",
+ (pvt->dclr0 & BIT(8)) ? "Enabled" : "Disabled",
+ (pvt->dclr0 & BIT(11)) ? "128b" : "64b");
+ debugf1(" DIMM x4 Present: L0=%s L1=%s L2=%s L3=%s DIMM Type=%s\n",
+ (pvt->dclr0 & BIT(12)) ? "Y" : "N",
+ (pvt->dclr0 & BIT(13)) ? "Y" : "N",
+ (pvt->dclr0 & BIT(14)) ? "Y" : "N",
+ (pvt->dclr0 & BIT(15)) ? "Y" : "N",
+ (pvt->dclr0 & BIT(16)) ? "UN-Buffered" : "Buffered");
+
+
+ debugf1(" online-spare: 0x%8.08x\n", pvt->online_spare);
+
+ if (boot_cpu_data.x86 == 0xf) {
+ debugf1(" dhar: 0x%8.08x Base=0x%08x Offset=0x%08x\n",
+ pvt->dhar, dhar_base(pvt->dhar),
+ k8_dhar_offset(pvt->dhar));
+ debugf1(" DramHoleValid=%s\n",
+ (pvt->dhar & DHAR_VALID) ? "True" : "False");
+
+ debugf1(" dbam-dkt: 0x%8.08x\n", pvt->dbam0);
+
+ /* everything below this point is Fam10h and above */
+ return;
+
+ } else {
+ debugf1(" dhar: 0x%8.08x Base=0x%08x Offset=0x%08x\n",
+ pvt->dhar, dhar_base(pvt->dhar),
+ f10_dhar_offset(pvt->dhar));
+ debugf1(" DramMemHoistValid=%s DramHoleValid=%s\n",
+ (pvt->dhar & F10_DRAM_MEM_HOIST_VALID) ?
+ "True" : "False",
+ (pvt->dhar & DHAR_VALID) ?
+ "True" : "False");
+ }
+
+ /* Only if NOT ganged does dcl1 have valid info */
+ if (!dct_ganging_enabled(pvt)) {
+ debugf1(" DramCfg1-low=0x%08x DIMM-ECC=%s Parity=%s "
+ "Width=%s\n", pvt->dclr1,
+ (pvt->dclr1 & BIT(19)) ? "Enabled" : "Disabled",
+ (pvt->dclr1 & BIT(8)) ? "Enabled" : "Disabled",
+ (pvt->dclr1 & BIT(11)) ? "128b" : "64b");
+ debugf1(" DIMM x4 Present: L0=%s L1=%s L2=%s L3=%s "
+ "DIMM Type=%s\n",
+ (pvt->dclr1 & BIT(12)) ? "Y" : "N",
+ (pvt->dclr1 & BIT(13)) ? "Y" : "N",
+ (pvt->dclr1 & BIT(14)) ? "Y" : "N",
+ (pvt->dclr1 & BIT(15)) ? "Y" : "N",
+ (pvt->dclr1 & BIT(16)) ? "UN-Buffered" : "Buffered");
+ }
+
+ /*
+ * Determine if ganged and then dump memory sizes for first controller,
+ * and if NOT ganged dump info for 2nd controller.
+ */
+ ganged = dct_ganging_enabled(pvt);
+
+ f10_debug_display_dimm_sizes(0, pvt, ganged);
+
+ if (!ganged)
+ f10_debug_display_dimm_sizes(1, pvt, ganged);
+}
+
+/* Read in both of DBAM registers */
+static void amd64_read_dbam_reg(struct amd64_pvt *pvt)
+{
+ int err = 0;
+ unsigned int reg;
+
+ reg = DBAM0;
+ err = pci_read_config_dword(pvt->dram_f2_ctl, reg, &pvt->dbam0);
+ if (err)
+ goto err_reg;
+
+ if (boot_cpu_data.x86 >= 0x10) {
+ reg = DBAM1;
+ err = pci_read_config_dword(pvt->dram_f2_ctl, reg, &pvt->dbam1);
+
+ if (err)
+ goto err_reg;
+ }
+
+err_reg:
+ debugf0("Error reading F2x%03x.\n", reg);
+}
+
+/*
+ * NOTE: CPU Revision Dependent code: Rev E and Rev F
+ *
+ * Set the DCSB and DCSM mask values depending on the CPU revision value. Also
+ * set the shift factor for the DCSB and DCSM values.
+ *
+ * ->dcs_mask_notused, RevE:
+ *
+ * To find the max InputAddr for the csrow, start with the base address and set
+ * all bits that are "don't care" bits in the test at the start of section
+ * 3.5.4 (p. 84).
+ *
+ * The "don't care" bits are all set bits in the mask and all bits in the gaps
+ * between bit ranges [35:25] and [19:13]. The value REV_E_DCS_NOTUSED_BITS
+ * represents bits [24:20] and [12:0], which are all bits in the above-mentioned
+ * gaps.
+ *
+ * ->dcs_mask_notused, RevF and later:
+ *
+ * To find the max InputAddr for the csrow, start with the base address and set
+ * all bits that are "don't care" bits in the test at the start of NPT section
+ * 4.5.4 (p. 87).
+ *
+ * The "don't care" bits are all set bits in the mask and all bits in the gaps
+ * between bit ranges [36:27] and [21:13].
+ *
+ * The value REV_F_F1Xh_DCS_NOTUSED_BITS represents bits [26:22] and [12:0],
+ * which are all bits in the above-mentioned gaps.
+ */
+static void amd64_set_dct_base_and_mask(struct amd64_pvt *pvt)
+{
+ if (pvt->ext_model >= OPTERON_CPU_REV_F) {
+ pvt->dcsb_base = REV_F_F1Xh_DCSB_BASE_BITS;
+ pvt->dcsm_mask = REV_F_F1Xh_DCSM_MASK_BITS;
+ pvt->dcs_mask_notused = REV_F_F1Xh_DCS_NOTUSED_BITS;
+ pvt->dcs_shift = REV_F_F1Xh_DCS_SHIFT;
+
+ switch (boot_cpu_data.x86) {
+ case 0xf:
+ pvt->num_dcsm = REV_F_DCSM_COUNT;
+ break;
+
+ case 0x10:
+ pvt->num_dcsm = F10_DCSM_COUNT;
+ break;
+
+ case 0x11:
+ pvt->num_dcsm = F11_DCSM_COUNT;
+ break;
+
+ default:
+ amd64_printk(KERN_ERR, "Unsupported family!\n");
+ break;
+ }
+ } else {
+ pvt->dcsb_base = REV_E_DCSB_BASE_BITS;
+ pvt->dcsm_mask = REV_E_DCSM_MASK_BITS;
+ pvt->dcs_mask_notused = REV_E_DCS_NOTUSED_BITS;
+ pvt->dcs_shift = REV_E_DCS_SHIFT;
+ pvt->num_dcsm = REV_E_DCSM_COUNT;
+ }
+}
+
+/*
+ * Function 2 Offset F10_DCSB0; read in the DCS Base and DCS Mask hw registers
+ */
+static void amd64_read_dct_base_mask(struct amd64_pvt *pvt)
+{
+ int cs, reg, err = 0;
+
+ amd64_set_dct_base_and_mask(pvt);
+
+ for (cs = 0; cs < CHIPSELECT_COUNT; cs++) {
+ reg = K8_DCSB0 + (cs * 4);
+ err = pci_read_config_dword(pvt->dram_f2_ctl, reg,
+ &pvt->dcsb0[cs]);
+ if (unlikely(err))
+ debugf0("Reading K8_DCSB0[%d] failed\n", cs);
+ else
+ debugf0(" DCSB0[%d]=0x%08x reg: F2x%x\n",
+ cs, pvt->dcsb0[cs], reg);
+
+ /* If DCT are NOT ganged, then read in DCT1's base */
+ if (boot_cpu_data.x86 >= 0x10 && !dct_ganging_enabled(pvt)) {
+ reg = F10_DCSB1 + (cs * 4);
+ err = pci_read_config_dword(pvt->dram_f2_ctl, reg,
+ &pvt->dcsb1[cs]);
+ if (unlikely(err))
+ debugf0("Reading F10_DCSB1[%d] failed\n", cs);
+ else
+ debugf0(" DCSB1[%d]=0x%08x reg: F2x%x\n",
+ cs, pvt->dcsb1[cs], reg);
+ } else {
+ pvt->dcsb1[cs] = 0;
+ }
+ }
+
+ for (cs = 0; cs < pvt->num_dcsm; cs++) {
+ reg = K8_DCSB0 + (cs * 4);
+ err = pci_read_config_dword(pvt->dram_f2_ctl, reg,
+ &pvt->dcsm0[cs]);
+ if (unlikely(err))
+ debugf0("Reading K8_DCSM0 failed\n");
+ else
+ debugf0(" DCSM0[%d]=0x%08x reg: F2x%x\n",
+ cs, pvt->dcsm0[cs], reg);
+
+ /* If DCT are NOT ganged, then read in DCT1's mask */
+ if (boot_cpu_data.x86 >= 0x10 && !dct_ganging_enabled(pvt)) {
+ reg = F10_DCSM1 + (cs * 4);
+ err = pci_read_config_dword(pvt->dram_f2_ctl, reg,
+ &pvt->dcsm1[cs]);
+ if (unlikely(err))
+ debugf0("Reading F10_DCSM1[%d] failed\n", cs);
+ else
+ debugf0(" DCSM1[%d]=0x%08x reg: F2x%x\n",
+ cs, pvt->dcsm1[cs], reg);
+ } else
+ pvt->dcsm1[cs] = 0;
+ }
+}
+
+static enum mem_type amd64_determine_memory_type(struct amd64_pvt *pvt)
+{
+ enum mem_type type;
+
+ if (boot_cpu_data.x86 >= 0x10 || pvt->ext_model >= OPTERON_CPU_REV_F) {
+ /* Rev F and later */
+ type = (pvt->dclr0 & BIT(16)) ? MEM_DDR2 : MEM_RDDR2;
+ } else {
+ /* Rev E and earlier */
+ type = (pvt->dclr0 & BIT(18)) ? MEM_DDR : MEM_RDDR;
+ }
+
+ debugf1(" Memory type is: %s\n",
+ (type == MEM_DDR2) ? "MEM_DDR2" :
+ (type == MEM_RDDR2) ? "MEM_RDDR2" :
+ (type == MEM_DDR) ? "MEM_DDR" : "MEM_RDDR");
+
+ return type;
+}
+
+/*
+ * Read the DRAM Configuration Low register. It differs between CG, D & E revs
+ * and the later RevF memory controllers (DDR vs DDR2)
+ *
+ * Return:
+ * number of memory channels in operation
+ * Pass back:
+ * contents of the DCL0_LOW register
+ */
+static int k8_early_channel_count(struct amd64_pvt *pvt)
+{
+ int flag, err = 0;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCLR_0, &pvt->dclr0);
+ if (err)
+ return err;
+
+ if ((boot_cpu_data.x86_model >> 4) >= OPTERON_CPU_REV_F) {
+ /* RevF (NPT) and later */
+ flag = pvt->dclr0 & F10_WIDTH_128;
+ } else {
+ /* RevE and earlier */
+ flag = pvt->dclr0 & REVE_WIDTH_128;
+ }
+
+ /* not used */
+ pvt->dclr1 = 0;
+
+ return (flag) ? 2 : 1;
+}
+
+/* extract the ERROR ADDRESS for the K8 CPUs */
+static u64 k8_get_error_address(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ return (((u64) (info->nbeah & 0xff)) << 32) +
+ (info->nbeal & ~0x03);
+}
+
+/*
+ * Read the Base and Limit registers for K8 based Memory controllers; extract
+ * fields from the 'raw' reg into separate data fields
+ *
+ * Isolates: BASE, LIMIT, IntlvEn, IntlvSel, RW_EN
+ */
+static void k8_read_dram_base_limit(struct amd64_pvt *pvt, int dram)
+{
+ u32 low;
+ u32 off = dram << 3; /* 8 bytes between DRAM entries */
+ int err;
+
+ err = pci_read_config_dword(pvt->addr_f1_ctl,
+ K8_DRAM_BASE_LOW + off, &low);
+ if (err)
+ debugf0("Reading K8_DRAM_BASE_LOW failed\n");
+
+ /* Extract parts into separate data entries */
+ pvt->dram_base[dram] = ((u64) low & 0xFFFF0000) << 8;
+ pvt->dram_IntlvEn[dram] = (low >> 8) & 0x7;
+ pvt->dram_rw_en[dram] = (low & 0x3);
+
+ err = pci_read_config_dword(pvt->addr_f1_ctl,
+ K8_DRAM_LIMIT_LOW + off, &low);
+ if (err)
+ debugf0("Reading K8_DRAM_LIMIT_LOW failed\n");
+
+ /*
+ * Extract parts into separate data entries. Limit is the HIGHEST memory
+ * location of the region, so lower 24 bits need to be all ones
+ */
+ pvt->dram_limit[dram] = (((u64) low & 0xFFFF0000) << 8) | 0x00FFFFFF;
+ pvt->dram_IntlvSel[dram] = (low >> 8) & 0x7;
+ pvt->dram_DstNode[dram] = (low & 0x7);
+}
+
+static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info,
+ u64 SystemAddress)
+{
+ struct mem_ctl_info *src_mci;
+ unsigned short syndrome;
+ int channel, csrow;
+ u32 page, offset;
+
+ /* Extract the syndrome parts and form a 16-bit syndrome */
+ syndrome = EXTRACT_HIGH_SYNDROME(info->nbsl) << 8;
+ syndrome |= EXTRACT_LOW_SYNDROME(info->nbsh);
+
+ /* CHIPKILL enabled */
+ if (info->nbcfg & K8_NBCFG_CHIPKILL) {
+ channel = get_channel_from_ecc_syndrome(syndrome);
+ if (channel < 0) {
+ /*
+ * Syndrome didn't map, so we don't know which of the
+ * 2 DIMMs is in error. So we need to ID 'both' of them
+ * as suspect.
+ */
+ amd64_mc_printk(mci, KERN_WARNING,
+ "unknown syndrome 0x%x - possible error "
+ "reporting race\n", syndrome);
+ edac_mc_handle_ce_no_info(mci, EDAC_MOD_STR);
+ return;
+ }
+ } else {
+ /*
+ * non-chipkill ecc mode
+ *
+ * The k8 documentation is unclear about how to determine the
+ * channel number when using non-chipkill memory. This method
+ * was obtained from email communication with someone at AMD.
+ * (Wish the email was placed in this comment - norsk)
+ */
+ channel = ((SystemAddress & BIT(3)) != 0);
+ }
+
+ /*
+ * Find out which node the error address belongs to. This may be
+ * different from the node that detected the error.
+ */
+ src_mci = find_mc_by_sys_addr(mci, SystemAddress);
+ if (src_mci) {
+ amd64_mc_printk(mci, KERN_ERR,
+ "failed to map error address 0x%lx to a node\n",
+ (unsigned long)SystemAddress);
+ edac_mc_handle_ce_no_info(mci, EDAC_MOD_STR);
+ return;
+ }
+
+ /* Now map the SystemAddress to a CSROW */
+ csrow = sys_addr_to_csrow(src_mci, SystemAddress);
+ if (csrow < 0) {
+ edac_mc_handle_ce_no_info(src_mci, EDAC_MOD_STR);
+ } else {
+ error_address_to_page_and_offset(SystemAddress, &page, &offset);
+
+ edac_mc_handle_ce(src_mci, page, offset, syndrome, csrow,
+ channel, EDAC_MOD_STR);
+ }
+}
+
+/*
+ * determrine the number of PAGES in for this DIMM's size based on its DRAM
+ * Address Mapping.
+ *
+ * First step is to calc the number of bits to shift a value of 1 left to
+ * indicate show many pages. Start with the DBAM value as the starting bits,
+ * then proceed to adjust those shift bits, based on CPU rev and the table.
+ * See BKDG on the DBAM
+ */
+static int k8_dbam_map_to_pages(struct amd64_pvt *pvt, int dram_map)
+{
+ int nr_pages;
+
+ if (pvt->ext_model >= OPTERON_CPU_REV_F) {
+ nr_pages = 1 << (revf_quad_ddr2_shift[dram_map] - PAGE_SHIFT);
+ } else {
+ /*
+ * RevE and less section; this line is tricky. It collapses the
+ * table used by RevD and later to one that matches revisions CG
+ * and earlier.
+ */
+ dram_map -= (pvt->ext_model >= OPTERON_CPU_REV_D) ?
+ (dram_map > 8 ? 4 : (dram_map > 5 ?
+ 3 : (dram_map > 2 ? 1 : 0))) : 0;
+
+ /* 25 shift is 32MiB minimum DIMM size in RevE and prior */
+ nr_pages = 1 << (dram_map + 25 - PAGE_SHIFT);
+ }
+
+ return nr_pages;
+}
+
+/*
+ * Get the number of DCT channels in use.
+ *
+ * Return:
+ * number of Memory Channels in operation
+ * Pass back:
+ * contents of the DCL0_LOW register
+ */
+static int f10_early_channel_count(struct amd64_pvt *pvt)
+{
+ int err = 0, channels = 0;
+ u32 dbam;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCLR_0, &pvt->dclr0);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCLR_1, &pvt->dclr1);
+ if (err)
+ goto err_reg;
+
+ /* If we are in 128 bit mode, then we are using 2 channels */
+ if (pvt->dclr0 & F10_WIDTH_128) {
+ debugf0("Data WIDTH is 128 bits - 2 channels\n");
+ channels = 2;
+ return channels;
+ }
+
+ /*
+ * Need to check if in UN-ganged mode: In such, there are 2 channels,
+ * but they are NOT in 128 bit mode and thus the above 'dcl0' status bit
+ * will be OFF.
+ *
+ * Need to check DCT0[0] and DCT1[0] to see if only one of them has
+ * their CSEnable bit on. If so, then SINGLE DIMM case.
+ */
+ debugf0("Data WIDTH is NOT 128 bits - need more decoding\n");
+
+ /*
+ * Check DRAM Bank Address Mapping values for each DIMM to see if there
+ * is more than just one DIMM present in unganged mode. Need to check
+ * both controllers since DIMMs can be placed in either one.
+ */
+ channels = 0;
+ err = pci_read_config_dword(pvt->dram_f2_ctl, DBAM0, &dbam);
+ if (err)
+ goto err_reg;
+
+ if (DBAM_DIMM(0, dbam) > 0)
+ channels++;
+ if (DBAM_DIMM(1, dbam) > 0)
+ channels++;
+ if (DBAM_DIMM(2, dbam) > 0)
+ channels++;
+ if (DBAM_DIMM(3, dbam) > 0)
+ channels++;
+
+ /* If more than 2 DIMMs are present, then we have 2 channels */
+ if (channels > 2)
+ channels = 2;
+ else if (channels == 0) {
+ /* No DIMMs on DCT0, so look at DCT1 */
+ err = pci_read_config_dword(pvt->dram_f2_ctl, DBAM1, &dbam);
+ if (err)
+ goto err_reg;
+
+ if (DBAM_DIMM(0, dbam) > 0)
+ channels++;
+ if (DBAM_DIMM(1, dbam) > 0)
+ channels++;
+ if (DBAM_DIMM(2, dbam) > 0)
+ channels++;
+ if (DBAM_DIMM(3, dbam) > 0)
+ channels++;
+
+ if (channels > 2)
+ channels = 2;
+ }
+
+ /* If we found ALL 0 values, then assume just ONE DIMM-ONE Channel */
+ if (channels == 0)
+ channels = 1;
+
+ debugf0("DIMM count= %d\n", channels);
+
+ return channels;
+
+err_reg:
+ return -1;
+
+}
+
+static int f10_dbam_map_to_pages(struct amd64_pvt *pvt, int dram_map)
+{
+ return 1 << (revf_quad_ddr2_shift[dram_map] - PAGE_SHIFT);
+}
+
+/* Enable extended configuration access via 0xCF8 feature */
+static void amd64_setup(struct amd64_pvt *pvt)
+{
+ u32 reg;
+
+ pci_read_config_dword(pvt->misc_f3_ctl, F10_NB_CFG_HIGH, &reg);
+
+ pvt->flags.cf8_extcfg = !!(reg & F10_NB_CFG_LOW_ENABLE_EXT_CFG);
+ reg |= F10_NB_CFG_LOW_ENABLE_EXT_CFG;
+ pci_write_config_dword(pvt->misc_f3_ctl, F10_NB_CFG_HIGH, reg);
+}
+
+/* Restore the extended configuration access via 0xCF8 feature */
+static void amd64_teardown(struct amd64_pvt *pvt)
+{
+ u32 reg;
+
+ pci_read_config_dword(pvt->misc_f3_ctl, F10_NB_CFG_HIGH, &reg);
+
+ reg &= ~F10_NB_CFG_LOW_ENABLE_EXT_CFG;
+ if (pvt->flags.cf8_extcfg)
+ reg |= F10_NB_CFG_LOW_ENABLE_EXT_CFG;
+ pci_write_config_dword(pvt->misc_f3_ctl, F10_NB_CFG_HIGH, reg);
+}
+
+static u64 f10_get_error_address(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ return (((u64) (info->nbeah & 0xffff)) << 32) +
+ (info->nbeal & ~0x01);
+}
+
+/*
+ * Read the Base and Limit registers for F10 based Memory controllers. Extract
+ * fields from the 'raw' reg into separate data fields.
+ *
+ * Isolates: BASE, LIMIT, IntlvEn, IntlvSel, RW_EN.
+ */
+static void f10_read_dram_base_limit(struct amd64_pvt *pvt, int dram)
+{
+ u32 high_offset, low_offset, high_base, low_base, high_limit, low_limit;
+
+ low_offset = K8_DRAM_BASE_LOW + (dram << 3);
+ high_offset = F10_DRAM_BASE_HIGH + (dram << 3);
+
+ /* read the 'raw' DRAM BASE Address register */
+ pci_read_config_dword(pvt->addr_f1_ctl, low_offset, &low_base);
+
+ /* Read from the ECS data register */
+ pci_read_config_dword(pvt->addr_f1_ctl, high_offset, &high_base);
+
+ /* Extract parts into separate data entries */
+ pvt->dram_rw_en[dram] = (low_base & 0x3);
+
+ if (pvt->dram_rw_en[dram] == 0)
+ return;
+
+ pvt->dram_IntlvEn[dram] = (low_base >> 8) & 0x7;
+
+ pvt->dram_base[dram] = (((((u64) high_base & 0x000000FF) << 32) |
+ ((u64) low_base & 0xFFFF0000))) << 8;
+
+ low_offset = K8_DRAM_LIMIT_LOW + (dram << 3);
+ high_offset = F10_DRAM_LIMIT_HIGH + (dram << 3);
+
+ /* read the 'raw' LIMIT registers */
+ pci_read_config_dword(pvt->addr_f1_ctl, low_offset, &low_limit);
+
+ /* Read from the ECS data register for the HIGH portion */
+ pci_read_config_dword(pvt->addr_f1_ctl, high_offset, &high_limit);
+
+ debugf0(" HW Regs: BASE=0x%08x-%08x LIMIT= 0x%08x-%08x\n",
+ high_base, low_base, high_limit, low_limit);
+
+ pvt->dram_DstNode[dram] = (low_limit & 0x7);
+ pvt->dram_IntlvSel[dram] = (low_limit >> 8) & 0x7;
+
+ /*
+ * Extract address values and form a LIMIT address. Limit is the HIGHEST
+ * memory location of the region, so low 24 bits need to be all ones.
+ */
+ low_limit |= 0x0000FFFF;
+ pvt->dram_limit[dram] =
+ ((((u64) high_limit << 32) + (u64) low_limit) << 8) | (0xFF);
+}
+
+static void f10_read_dram_ctl_register(struct amd64_pvt *pvt)
+{
+ int err = 0;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCTL_SEL_LOW,
+ &pvt->dram_ctl_select_low);
+ if (err) {
+ debugf0("Reading F10_DCTL_SEL_LOW failed\n");
+ } else {
+ debugf0("DRAM_DCTL_SEL_LOW=0x%x DctSelBaseAddr=0x%x\n",
+ pvt->dram_ctl_select_low, dct_sel_baseaddr(pvt));
+
+ debugf0(" DRAM DCTs are=%s DRAM Is=%s DRAM-Ctl-"
+ "sel-hi-range=%s\n",
+ (dct_ganging_enabled(pvt) ? "GANGED" : "NOT GANGED"),
+ (dct_dram_enabled(pvt) ? "Enabled" : "Disabled"),
+ (dct_high_range_enabled(pvt) ? "Enabled" : "Disabled"));
+
+ debugf0(" DctDatIntLv=%s MemCleared=%s DctSelIntLvAddr=0x%x\n",
+ (dct_data_intlv_enabled(pvt) ? "Enabled" : "Disabled"),
+ (dct_memory_cleared(pvt) ? "True " : "False "),
+ dct_sel_interleave_addr(pvt));
+ }
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCTL_SEL_HIGH,
+ &pvt->dram_ctl_select_high);
+ if (err)
+ debugf0("Reading F10_DCTL_SEL_HIGH failed\n");
+}
+
+/*
+ * determine channel based on the interleaving mode: F10h BKDG, 2.8.9 Memory
+ * Interleaving Modes.
+ */
+static u32 f10_determine_channel(struct amd64_pvt *pvt, u64 sys_addr,
+ int hi_range_sel, u32 intlv_en)
+{
+ u32 cs, temp, dct_sel_high = (pvt->dram_ctl_select_low >> 1) & 1;
+
+ if (dct_ganging_enabled(pvt))
+ cs = 0;
+ else if (hi_range_sel)
+ cs = dct_sel_high;
+ else if (dct_interleave_enabled(pvt)) {
+ /*
+ * see F2x110[DctSelIntLvAddr] - channel interleave mode
+ */
+ if (dct_sel_interleave_addr(pvt) == 0)
+ cs = sys_addr >> 6 & 1;
+ else if ((dct_sel_interleave_addr(pvt) >> 1) & 1) {
+ temp = popcnt((u32) ((sys_addr >> 16) & 0x1F)) % 2;
+
+ if (dct_sel_interleave_addr(pvt) & 1)
+ cs = (sys_addr >> 9 & 1) ^ temp;
+ else
+ cs = (sys_addr >> 6 & 1) ^ temp;
+ } else if (intlv_en & 4)
+ cs = sys_addr >> 15 & 1;
+ else if (intlv_en & 2)
+ cs = sys_addr >> 14 & 1;
+ else if (intlv_en & 1)
+ cs = sys_addr >> 13 & 1;
+ else
+ cs = sys_addr >> 12 & 1;
+ } else if (dct_high_range_enabled(pvt) && !dct_ganging_enabled(pvt))
+ cs = ~dct_sel_high & 1;
+ else
+ cs = 0;
+
+ return cs;
+}
+
+static inline u32 f10_map_intlv_en_to_shift(u32 intlv_en)
+{
+ if (intlv_en == 1)
+ return 1;
+ else if (intlv_en == 3)
+ return 2;
+ else if (intlv_en == 7)
+ return 3;
+
+ return 0;
+}
+
+/* See F10h BKDG, 2.8.10.2 DctSelBaseOffset Programming */
+static inline u64 f10_get_base_addr_offset(u64 sys_addr, int hi_range_sel,
+ u32 dct_sel_base_addr,
+ u64 dct_sel_base_off,
+ u32 hole_valid, u32 hole_off,
+ u64 dram_base)
+{
+ u64 chan_off;
+
+ if (hi_range_sel) {
+ if ((!dct_sel_base_addr & 0xFFFF0000) &&
+ hole_valid && (sys_addr >= 0x100000000ULL))
+ chan_off = hole_off << 16;
+ else
+ chan_off = dct_sel_base_off;
+ } else {
+ if (hole_valid && (sys_addr >= 0x100000000ULL))
+ chan_off = hole_off << 16;
+ else
+ chan_off = dram_base & 0xFFFFF8000000ULL;
+ }
+
+ return (sys_addr & 0x0000FFFFFFFFFFC0ULL) -
+ (chan_off & 0x0000FFFFFF800000ULL);
+}
+
+/* Hack for the time being - Can we get this from BIOS?? */
+#define CH0SPARE_RANK 0
+#define CH1SPARE_RANK 1
+
+/*
+ * checks if the csrow passed in is marked as SPARED, if so returns the new
+ * spare row
+ */
+static inline int f10_process_possible_spare(int csrow,
+ u32 cs, struct amd64_pvt *pvt)
+{
+ u32 swap_done;
+ u32 bad_dram_cs;
+
+ /* Depending on channel, isolate respective SPARING info */
+ if (cs) {
+ swap_done = F10_ONLINE_SPARE_SWAPDONE1(pvt->online_spare);
+ bad_dram_cs = F10_ONLINE_SPARE_BADDRAM_CS1(pvt->online_spare);
+ if (swap_done && (csrow == bad_dram_cs))
+ csrow = CH1SPARE_RANK;
+ } else {
+ swap_done = F10_ONLINE_SPARE_SWAPDONE0(pvt->online_spare);
+ bad_dram_cs = F10_ONLINE_SPARE_BADDRAM_CS0(pvt->online_spare);
+ if (swap_done && (csrow == bad_dram_cs))
+ csrow = CH0SPARE_RANK;
+ }
+ return csrow;
+}
+
+/*
+ * Iterate over the DRAM DCT "base" and "mask" registers looking for a
+ * SystemAddr match on the specified 'ChannelSelect' and 'NodeID'
+ *
+ * Return:
+ * -EINVAL: NOT FOUND
+ * 0..csrow = Chip-Select Row
+ */
+static int f10_lookup_addr_in_dct(u32 in_addr, u32 nid, u32 cs)
+{
+ struct mem_ctl_info *mci;
+ struct amd64_pvt *pvt;
+ u32 cs_base, cs_mask;
+ int cs_found = -EINVAL;
+ int csrow;
+
+ mci = mci_lookup[nid];
+ if (!mci)
+ return cs_found;
+
+ pvt = mci->pvt_info;
+
+ debugf1("InputAddr=0x%x channelselect=%d\n", in_addr, cs);
+
+ for (csrow = 0; csrow < CHIPSELECT_COUNT; csrow++) {
+
+ cs_base = amd64_get_dct_base(pvt, cs, csrow);
+ if (!(cs_base & K8_DCSB_CS_ENABLE))
+ continue;
+
+ /*
+ * We have an ENABLED CSROW, Isolate just the MASK bits of the
+ * target: [28:19] and [13:5], which map to [36:27] and [21:13]
+ * of the actual address.
+ */
+ cs_base &= REV_F_F1Xh_DCSB_BASE_BITS;
+
+ /*
+ * Get the DCT Mask, and ENABLE the reserved bits: [18:16] and
+ * [4:0] to become ON. Then mask off bits [28:0] ([36:8])
+ */
+ cs_mask = amd64_get_dct_mask(pvt, cs, csrow);
+
+ debugf1(" CSROW=%d CSBase=0x%x RAW CSMask=0x%x\n",
+ csrow, cs_base, cs_mask);
+
+ cs_mask = (cs_mask | 0x0007C01F) & 0x1FFFFFFF;
+
+ debugf1(" Final CSMask=0x%x\n", cs_mask);
+ debugf1(" (InputAddr & ~CSMask)=0x%x "
+ "(CSBase & ~CSMask)=0x%x\n",
+ (in_addr & ~cs_mask), (cs_base & ~cs_mask));
+
+ if ((in_addr & ~cs_mask) == (cs_base & ~cs_mask)) {
+ cs_found = f10_process_possible_spare(csrow, cs, pvt);
+
+ debugf1(" MATCH csrow=%d\n", cs_found);
+ break;
+ }
+ }
+ return cs_found;
+}
+
+/* For a given @dram_range, check if @sys_addr falls within it. */
+static int f10_match_to_this_node(struct amd64_pvt *pvt, int dram_range,
+ u64 sys_addr, int *nid, int *chan_sel)
+{
+ int node_id, cs_found = -EINVAL, high_range = 0;
+ u32 intlv_en, intlv_sel, intlv_shift, hole_off;
+ u32 hole_valid, tmp, dct_sel_base, channel;
+ u64 dram_base, chan_addr;
+
+ dram_base = pvt->dram_base[dram_range];
+ intlv_en = pvt->dram_IntlvEn[dram_range];
+
+ node_id = pvt->dram_DstNode[dram_range];
+ intlv_sel = pvt->dram_IntlvSel[dram_range];
+
+ debugf1("(dram=%d) Base=0x%llx SystemAddr= 0x%llx Limit=0x%llx\n",
+ dram_range, dram_base, sys_addr, pvt->dram_limit[dram_range]);
+
+ /*
+ * This assumes that one node's DHAR is the same as all the other
+ * nodes' DHAR.
+ */
+ hole_off = (pvt->dhar & 0x0000FF80);
+ hole_valid = (pvt->dhar & 0x1);
+
+ debugf1(" HoleOffset=0x%x HoleValid=0x%x IntlvSel=0x%x\n",
+ hole_off, hole_valid, intlv_sel);
+
+ if (intlv_en ||
+ (intlv_sel != ((sys_addr >> 12) & intlv_en)))
+ return -EINVAL;
+
+ dct_sel_base = dct_sel_baseaddr(pvt);
+
+ /*
+ * check whether addresses >= DctSelBaseAddr[47:27] are to be used to
+ * select between DCT0 and DCT1.
+ */
+ if (dct_high_range_enabled(pvt) &&
+ !dct_ganging_enabled(pvt) &&
+ ((sys_addr >> 27) >= (dct_sel_base >> 11)))
+ high_range = 1;
+
+ channel = f10_determine_channel(pvt, sys_addr, high_range, intlv_en);
+
+ chan_addr = f10_get_base_addr_offset(sys_addr, high_range, dct_sel_base,
+ pvt->dram_ctl_select_high << 16,
+ hole_valid, hole_off, dram_base);
+
+ intlv_shift = f10_map_intlv_en_to_shift(intlv_en);
+
+ /* remove Node ID (in case of memory interleaving) */
+ tmp = chan_addr & 0xFC0;
+
+ chan_addr = ((chan_addr >> intlv_shift) & 0xFFFFFFFFF000ULL) | tmp;
+
+ /* remove channel interleave and hash */
+ if (dct_interleave_enabled(pvt) &&
+ !dct_high_range_enabled(pvt) &&
+ !dct_ganging_enabled(pvt)) {
+ if (dct_sel_interleave_addr(pvt) != 1)
+ chan_addr = (chan_addr >> 1) & 0xFFFFFFFFFFFFFFC0ULL;
+ else {
+ tmp = chan_addr & 0xFC0;
+ chan_addr = ((chan_addr & 0xFFFFFFFFFFFFC000ULL) >> 1)
+ | tmp;
+ }
+ }
+
+ debugf1(" (ChannelAddrLong=0x%llx) >> 8 becomes InputAddr=0x%x\n",
+ chan_addr, (u32)(chan_addr >> 8));
+
+ cs_found = f10_lookup_addr_in_dct(chan_addr >> 8, node_id, channel);
+
+ if (cs_found >= 0) {
+ *nid = node_id;
+ *chan_sel = channel;
+ }
+ return cs_found;
+}
+
+static int f10_translate_sysaddr_to_cs(struct amd64_pvt *pvt, u64 sys_addr,
+ int *node, int *chan_sel)
+{
+ int dram_range, cs_found = -EINVAL;
+ u64 dram_base, dram_limit;
+
+ for (dram_range = 0; dram_range < DRAM_REG_COUNT; dram_range++) {
+
+ if (!pvt->dram_rw_en[dram_range])
+ continue;
+
+ dram_base = pvt->dram_base[dram_range];
+ dram_limit = pvt->dram_limit[dram_range];
+
+ if ((dram_base <= sys_addr) && (sys_addr <= dram_limit)) {
+
+ cs_found = f10_match_to_this_node(pvt, dram_range,
+ sys_addr, node,
+ chan_sel);
+ if (cs_found >= 0)
+ break;
+ }
+ }
+ return cs_found;
+}
+
+/*
+ * This the F10h reference code from AMD to map a @sys_addr to NodeID,
+ * CSROW, Channel.
+ *
+ * The @sys_addr is usually an error address received from the hardware.
+ */
+static void f10_map_sysaddr_to_csrow(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info,
+ u64 sys_addr)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u32 page, offset;
+ unsigned short syndrome;
+ int nid, csrow, chan = 0;
+
+ csrow = f10_translate_sysaddr_to_cs(pvt, sys_addr, &nid, &chan);
+
+ if (csrow >= 0) {
+ error_address_to_page_and_offset(sys_addr, &page, &offset);
+
+ syndrome = EXTRACT_HIGH_SYNDROME(info->nbsl) << 8;
+ syndrome |= EXTRACT_LOW_SYNDROME(info->nbsh);
+
+ /*
+ * Is CHIPKILL on? If so, then we can attempt to use the
+ * syndrome to isolate which channel the error was on.
+ */
+ if (pvt->nbcfg & K8_NBCFG_CHIPKILL)
+ chan = get_channel_from_ecc_syndrome(syndrome);
+
+ if (chan >= 0) {
+ edac_mc_handle_ce(mci, page, offset, syndrome,
+ csrow, chan, EDAC_MOD_STR);
+ } else {
+ /*
+ * Channel unknown, report all channels on this
+ * CSROW as failed.
+ */
+ for (chan = 0; chan < mci->csrows[csrow].nr_channels;
+ chan++) {
+ edac_mc_handle_ce(mci, page, offset,
+ syndrome,
+ csrow, chan,
+ EDAC_MOD_STR);
+ }
+ }
+
+ } else {
+ edac_mc_handle_ce_no_info(mci, EDAC_MOD_STR);
+ }
+}
+
+/*
+ * Input (@index) is the DBAM DIMM value (1 of 4) used as an index into a shift
+ * table (revf_quad_ddr2_shift) which starts at 128MB DIMM size. Index of 0
+ * indicates an empty DIMM slot, as reported by Hardware on empty slots.
+ *
+ * Normalize to 128MB by subracting 27 bit shift.
+ */
+static int map_dbam_to_csrow_size(int index)
+{
+ int mega_bytes = 0;
+
+ if (index > 0 && index <= DBAM_MAX_VALUE)
+ mega_bytes = ((128 << (revf_quad_ddr2_shift[index]-27)));
+
+ return mega_bytes;
+}
+
+/*
+ * debug routine to display the memory sizes of a DIMM (ganged or not) and it
+ * CSROWs as well
+ */
+static void f10_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt,
+ int ganged)
+{
+ int dimm, size0, size1;
+ u32 dbam;
+ u32 *dcsb;
+
+ debugf1(" dbam%d: 0x%8.08x CSROW is %s\n", ctrl,
+ ctrl ? pvt->dbam1 : pvt->dbam0,
+ ganged ? "GANGED - dbam1 not used" : "NON-GANGED");
+
+ dbam = ctrl ? pvt->dbam1 : pvt->dbam0;
+ dcsb = ctrl ? pvt->dcsb1 : pvt->dcsb0;
+
+ /* Dump memory sizes for DIMM and its CSROWs */
+ for (dimm = 0; dimm < 4; dimm++) {
+
+ size0 = 0;
+ if (dcsb[dimm*2] & K8_DCSB_CS_ENABLE)
+ size0 = map_dbam_to_csrow_size(DBAM_DIMM(dimm, dbam));
+
+ size1 = 0;
+ if (dcsb[dimm*2 + 1] & K8_DCSB_CS_ENABLE)
+ size1 = map_dbam_to_csrow_size(DBAM_DIMM(dimm, dbam));
+
+ debugf1(" CTRL-%d DIMM-%d=%5dMB CSROW-%d=%5dMB "
+ "CSROW-%d=%5dMB\n",
+ ctrl,
+ dimm,
+ size0 + size1,
+ dimm * 2,
+ size0,
+ dimm * 2 + 1,
+ size1);
+ }
+}
+
+/*
+ * Very early hardware probe on pci_probe thread to determine if this module
+ * supports the hardware.
+ *
+ * Return:
+ * 0 for OK
+ * 1 for error
+ */
+static int f10_probe_valid_hardware(struct amd64_pvt *pvt)
+{
+ int ret = 0;
+
+ /*
+ * If we are on a DDR3 machine, we don't know yet if
+ * we support that properly at this time
+ */
+ if ((pvt->dchr0 & F10_DCHR_Ddr3Mode) ||
+ (pvt->dchr1 & F10_DCHR_Ddr3Mode)) {
+
+ amd64_printk(KERN_WARNING,
+ "%s() This machine is running with DDR3 memory. "
+ "This is not currently supported. "
+ "DCHR0=0x%x DCHR1=0x%x\n",
+ __func__, pvt->dchr0, pvt->dchr1);
+
+ amd64_printk(KERN_WARNING,
+ " Contact '%s' module MAINTAINER to help add"
+ " support.\n",
+ EDAC_MOD_STR);
+
+ ret = 1;
+
+ }
+ return ret;
+}
+
+/*
+ * There currently are 3 types type of MC devices for AMD Athlon/Opterons
+ * (as per PCI DEVICE_IDs):
+ *
+ * Family K8: That is the Athlon64 and Opteron CPUs. They all have the same PCI
+ * DEVICE ID, even though there is differences between the different Revisions
+ * (CG,D,E,F).
+ *
+ * Family F10h and F11h.
+ *
+ */
+static struct amd64_family_type amd64_family_types[] = {
+ [K8_CPUS] = {
+ .ctl_name = "RevF",
+ .addr_f1_ctl = PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP,
+ .misc_f3_ctl = PCI_DEVICE_ID_AMD_K8_NB_MISC,
+ .ops = {
+ .early_channel_count = k8_early_channel_count,
+ .get_error_address = k8_get_error_address,
+ .read_dram_base_limit = k8_read_dram_base_limit,
+ .map_sysaddr_to_csrow = k8_map_sysaddr_to_csrow,
+ .dbam_map_to_pages = k8_dbam_map_to_pages,
+ }
+ },
+ [F10_CPUS] = {
+ .ctl_name = "Family 10h",
+ .addr_f1_ctl = PCI_DEVICE_ID_AMD_10H_NB_MAP,
+ .misc_f3_ctl = PCI_DEVICE_ID_AMD_10H_NB_MISC,
+ .ops = {
+ .probe_valid_hardware = f10_probe_valid_hardware,
+ .early_channel_count = f10_early_channel_count,
+ .get_error_address = f10_get_error_address,
+ .read_dram_base_limit = f10_read_dram_base_limit,
+ .read_dram_ctl_register = f10_read_dram_ctl_register,
+ .map_sysaddr_to_csrow = f10_map_sysaddr_to_csrow,
+ .dbam_map_to_pages = f10_dbam_map_to_pages,
+ }
+ },
+ [F11_CPUS] = {
+ .ctl_name = "Family 11h",
+ .addr_f1_ctl = PCI_DEVICE_ID_AMD_11H_NB_MAP,
+ .misc_f3_ctl = PCI_DEVICE_ID_AMD_11H_NB_MISC,
+ .ops = {
+ .probe_valid_hardware = f10_probe_valid_hardware,
+ .early_channel_count = f10_early_channel_count,
+ .get_error_address = f10_get_error_address,
+ .read_dram_base_limit = f10_read_dram_base_limit,
+ .read_dram_ctl_register = f10_read_dram_ctl_register,
+ .map_sysaddr_to_csrow = f10_map_sysaddr_to_csrow,
+ .dbam_map_to_pages = f10_dbam_map_to_pages,
+ }
+ },
+};
+
+static struct pci_dev *pci_get_related_function(unsigned int vendor,
+ unsigned int device,
+ struct pci_dev *related)
+{
+ struct pci_dev *dev = NULL;
+
+ dev = pci_get_device(vendor, device, dev);
+ while (dev) {
+ if ((dev->bus->number == related->bus->number) &&
+ (PCI_SLOT(dev->devfn) == PCI_SLOT(related->devfn)))
+ break;
+ dev = pci_get_device(vendor, device, dev);
+ }
+
+ return dev;
+}
+
+/*
+ * syndrome mapping table for ECC ChipKill devices
+ *
+ * The comment in each row is the token (nibble) number that is in error.
+ * The least significant nibble of the syndrome is the mask for the bits
+ * that are in error (need to be toggled) for the particular nibble.
+ *
+ * Each row contains 16 entries.
+ * The first entry (0th) is the channel number for that row of syndromes.
+ * The remaining 15 entries are the syndromes for the respective Error
+ * bit mask index.
+ *
+ * 1st index entry is 0x0001 mask, indicating that the rightmost bit is the
+ * bit in error.
+ * The 2nd index entry is 0x0010 that the second bit is damaged.
+ * The 3rd index entry is 0x0011 indicating that the rightmost 2 bits
+ * are damaged.
+ * Thus so on until index 15, 0x1111, whose entry has the syndrome
+ * indicating that all 4 bits are damaged.
+ *
+ * A search is performed on this table looking for a given syndrome.
+ *
+ * See the AMD documentation for ECC syndromes. This ECC table is valid
+ * across all the versions of the AMD64 processors.
+ *
+ * A fast lookup is to use the LAST four bits of the 16-bit syndrome as a
+ * COLUMN index, then search all ROWS of that column, looking for a match
+ * with the input syndrome. The ROW value will be the token number.
+ *
+ * The 0'th entry on that row, can be returned as the CHANNEL (0 or 1) of this
+ * error.
+ */
+#define NUMBER_ECC_ROWS 36
+static const unsigned short ecc_chipkill_syndromes[NUMBER_ECC_ROWS][16] = {
+ /* Channel 0 syndromes */
+ {/*0*/ 0, 0xe821, 0x7c32, 0x9413, 0xbb44, 0x5365, 0xc776, 0x2f57,
+ 0xdd88, 0x35a9, 0xa1ba, 0x499b, 0x66cc, 0x8eed, 0x1afe, 0xf2df },
+ {/*1*/ 0, 0x5d31, 0xa612, 0xfb23, 0x9584, 0xc8b5, 0x3396, 0x6ea7,
+ 0xeac8, 0xb7f9, 0x4cda, 0x11eb, 0x7f4c, 0x227d, 0xd95e, 0x846f },
+ {/*2*/ 0, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f },
+ {/*3*/ 0, 0x2021, 0x3032, 0x1013, 0x4044, 0x6065, 0x7076, 0x5057,
+ 0x8088, 0xa0a9, 0xb0ba, 0x909b, 0xc0cc, 0xe0ed, 0xf0fe, 0xd0df },
+ {/*4*/ 0, 0x5041, 0xa082, 0xf0c3, 0x9054, 0xc015, 0x30d6, 0x6097,
+ 0xe0a8, 0xb0e9, 0x402a, 0x106b, 0x70fc, 0x20bd, 0xd07e, 0x803f },
+ {/*5*/ 0, 0xbe21, 0xd732, 0x6913, 0x2144, 0x9f65, 0xf676, 0x4857,
+ 0x3288, 0x8ca9, 0xe5ba, 0x5b9b, 0x13cc, 0xaded, 0xc4fe, 0x7adf },
+ {/*6*/ 0, 0x4951, 0x8ea2, 0xc7f3, 0x5394, 0x1ac5, 0xdd36, 0x9467,
+ 0xa1e8, 0xe8b9, 0x2f4a, 0x661b, 0xf27c, 0xbb2d, 0x7cde, 0x358f },
+ {/*7*/ 0, 0x74e1, 0x9872, 0xec93, 0xd6b4, 0xa255, 0x4ec6, 0x3a27,
+ 0x6bd8, 0x1f39, 0xf3aa, 0x874b, 0xbd6c, 0xc98d, 0x251e, 0x51ff },
+ {/*8*/ 0, 0x15c1, 0x2a42, 0x3f83, 0xcef4, 0xdb35, 0xe4b6, 0xf177,
+ 0x4758, 0x5299, 0x6d1a, 0x78db, 0x89ac, 0x9c6d, 0xa3ee, 0xb62f },
+ {/*9*/ 0, 0x3d01, 0x1602, 0x2b03, 0x8504, 0xb805, 0x9306, 0xae07,
+ 0xca08, 0xf709, 0xdc0a, 0xe10b, 0x4f0c, 0x720d, 0x590e, 0x640f },
+ {/*a*/ 0, 0x9801, 0xec02, 0x7403, 0x6b04, 0xf305, 0x8706, 0x1f07,
+ 0xbd08, 0x2509, 0x510a, 0xc90b, 0xd60c, 0x4e0d, 0x3a0e, 0xa20f },
+ {/*b*/ 0, 0xd131, 0x6212, 0xb323, 0x3884, 0xe9b5, 0x5a96, 0x8ba7,
+ 0x1cc8, 0xcdf9, 0x7eda, 0xafeb, 0x244c, 0xf57d, 0x465e, 0x976f },
+ {/*c*/ 0, 0xe1d1, 0x7262, 0x93b3, 0xb834, 0x59e5, 0xca56, 0x2b87,
+ 0xdc18, 0x3dc9, 0xae7a, 0x4fab, 0x542c, 0x85fd, 0x164e, 0xf79f },
+ {/*d*/ 0, 0x6051, 0xb0a2, 0xd0f3, 0x1094, 0x70c5, 0xa036, 0xc067,
+ 0x20e8, 0x40b9, 0x904a, 0x601b, 0x307c, 0x502d, 0x80de, 0xe08f },
+ {/*e*/ 0, 0xa4c1, 0xf842, 0x5c83, 0xe6f4, 0x4235, 0x1eb6, 0xba77,
+ 0x7b58, 0xdf99, 0x831a, 0x27db, 0x9dac, 0x396d, 0x65ee, 0xc12f },
+ {/*f*/ 0, 0x11c1, 0x2242, 0x3383, 0xc8f4, 0xd935, 0xeab6, 0xfb77,
+ 0x4c58, 0x5d99, 0x6e1a, 0x7fdb, 0x84ac, 0x956d, 0xa6ee, 0xb72f },
+
+ /* Channel 1 syndromes */
+ {/*10*/ 1, 0x45d1, 0x8a62, 0xcfb3, 0x5e34, 0x1be5, 0xd456, 0x9187,
+ 0xa718, 0xe2c9, 0x2d7a, 0x68ab, 0xf92c, 0xbcfd, 0x734e, 0x369f },
+ {/*11*/ 1, 0x63e1, 0xb172, 0xd293, 0x14b4, 0x7755, 0xa5c6, 0xc627,
+ 0x28d8, 0x4b39, 0x99aa, 0xfa4b, 0x3c6c, 0x5f8d, 0x8d1e, 0xeeff },
+ {/*12*/ 1, 0xb741, 0xd982, 0x6ec3, 0x2254, 0x9515, 0xfbd6, 0x4c97,
+ 0x33a8, 0x84e9, 0xea2a, 0x5d6b, 0x11fc, 0xa6bd, 0xc87e, 0x7f3f },
+ {/*13*/ 1, 0xdd41, 0x6682, 0xbbc3, 0x3554, 0xe815, 0x53d6, 0xce97,
+ 0x1aa8, 0xc7e9, 0x7c2a, 0xa1fb, 0x2ffc, 0xf2bd, 0x497e, 0x943f },
+ {/*14*/ 1, 0x2bd1, 0x3d62, 0x16b3, 0x4f34, 0x64e5, 0x7256, 0x5987,
+ 0x8518, 0xaec9, 0xb87a, 0x93ab, 0xca2c, 0xe1fd, 0xf74e, 0xdc9f },
+ {/*15*/ 1, 0x83c1, 0xc142, 0x4283, 0xa4f4, 0x2735, 0x65b6, 0xe677,
+ 0xf858, 0x7b99, 0x391a, 0xbadb, 0x5cac, 0xdf6d, 0x9dee, 0x1e2f },
+ {/*16*/ 1, 0x8fd1, 0xc562, 0x4ab3, 0xa934, 0x26e5, 0x6c56, 0xe387,
+ 0xfe18, 0x71c9, 0x3b7a, 0xb4ab, 0x572c, 0xd8fd, 0x924e, 0x1d9f },
+ {/*17*/ 1, 0x4791, 0x89e2, 0xce73, 0x5264, 0x15f5, 0xdb86, 0x9c17,
+ 0xa3b8, 0xe429, 0x2a5a, 0x6dcb, 0xf1dc, 0xb64d, 0x783e, 0x3faf },
+ {/*18*/ 1, 0x5781, 0xa9c2, 0xfe43, 0x92a4, 0xc525, 0x3b66, 0x6ce7,
+ 0xe3f8, 0xb479, 0x4a3a, 0x1dbb, 0x715c, 0x26dd, 0xd89e, 0x8f1f },
+ {/*19*/ 1, 0xbf41, 0xd582, 0x6ac3, 0x2954, 0x9615, 0xfcd6, 0x4397,
+ 0x3ea8, 0x81e9, 0xeb2a, 0x546b, 0x17fc, 0xa8bd, 0xc27e, 0x7d3f },
+ {/*1a*/ 1, 0x9891, 0xe1e2, 0x7273, 0x6464, 0xf7f5, 0x8586, 0x1617,
+ 0xb8b8, 0x2b29, 0x595a, 0xcacb, 0xdcdc, 0x4f4d, 0x3d3e, 0xaeaf },
+ {/*1b*/ 1, 0xcce1, 0x4472, 0x8893, 0xfdb4, 0x3f55, 0xb9c6, 0x7527,
+ 0x56d8, 0x9a39, 0x12aa, 0xde4b, 0xab6c, 0x678d, 0xef1e, 0x23ff },
+ {/*1c*/ 1, 0xa761, 0xf9b2, 0x5ed3, 0xe214, 0x4575, 0x1ba6, 0xbcc7,
+ 0x7328, 0xd449, 0x8a9a, 0x2dfb, 0x913c, 0x365d, 0x688e, 0xcfef },
+ {/*1d*/ 1, 0xff61, 0x55b2, 0xaad3, 0x7914, 0x8675, 0x2ca6, 0xd3c7,
+ 0x9e28, 0x6149, 0xcb9a, 0x34fb, 0xe73c, 0x185d, 0xb28e, 0x4def },
+ {/*1e*/ 1, 0x5451, 0xa8a2, 0xfcf3, 0x9694, 0xc2c5, 0x3e36, 0x6a67,
+ 0xebe8, 0xbfb9, 0x434a, 0x171b, 0x7d7c, 0x292d, 0xd5de, 0x818f },
+ {/*1f*/ 1, 0x6fc1, 0xb542, 0xda83, 0x19f4, 0x7635, 0xacb6, 0xc377,
+ 0x2e58, 0x4199, 0x9b1a, 0xf4db, 0x37ac, 0x586d, 0x82ee, 0xed2f },
+
+ /* ECC bits are also in the set of tokens and they too can go bad
+ * first 2 cover channel 0, while the second 2 cover channel 1
+ */
+ {/*20*/ 0, 0xbe01, 0xd702, 0x6903, 0x2104, 0x9f05, 0xf606, 0x4807,
+ 0x3208, 0x8c09, 0xe50a, 0x5b0b, 0x130c, 0xad0d, 0xc40e, 0x7a0f },
+ {/*21*/ 0, 0x4101, 0x8202, 0xc303, 0x5804, 0x1905, 0xda06, 0x9b07,
+ 0xac08, 0xed09, 0x2e0a, 0x6f0b, 0x640c, 0xb50d, 0x760e, 0x370f },
+ {/*22*/ 1, 0xc441, 0x4882, 0x8cc3, 0xf654, 0x3215, 0xbed6, 0x7a97,
+ 0x5ba8, 0x9fe9, 0x132a, 0xd76b, 0xadfc, 0x69bd, 0xe57e, 0x213f },
+ {/*23*/ 1, 0x7621, 0x9b32, 0xed13, 0xda44, 0xac65, 0x4176, 0x3757,
+ 0x6f88, 0x19a9, 0xf4ba, 0x829b, 0xb5cc, 0xc3ed, 0x2efe, 0x58df }
+};
+
+/*
+ * Given the syndrome argument, scan each of the channel tables for a syndrome
+ * match. Depending on which table it is found, return the channel number.
+ */
+static int get_channel_from_ecc_syndrome(unsigned short syndrome)
+{
+ int row;
+ int column;
+
+ /* Determine column to scan */
+ column = syndrome & 0xF;
+
+ /* Scan all rows, looking for syndrome, or end of table */
+ for (row = 0; row < NUMBER_ECC_ROWS; row++) {
+ if (ecc_chipkill_syndromes[row][column] == syndrome)
+ return ecc_chipkill_syndromes[row][0];
+ }
+
+ debugf0("syndrome(%x) not found\n", syndrome);
+ return -1;
+}
+
+/*
+ * Check for valid error in the NB Status High register. If so, proceed to read
+ * NB Status Low, NB Address Low and NB Address High registers and store data
+ * into error structure.
+ *
+ * Returns:
+ * - 1: if hardware regs contains valid error info
+ * - 0: if no valid error is indicated
+ */
+static int amd64_get_error_info_regs(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *regs)
+{
+ struct amd64_pvt *pvt;
+ struct pci_dev *misc_f3_ctl;
+ int err = 0;
+
+ pvt = mci->pvt_info;
+ misc_f3_ctl = pvt->misc_f3_ctl;
+
+ err = pci_read_config_dword(misc_f3_ctl, K8_NBSH, &regs->nbsh);
+ if (err)
+ goto err_reg;
+
+ if (!(regs->nbsh & K8_NBSH_VALID_BIT))
+ return 0;
+
+ /* valid error, read remaining error information registers */
+ err = pci_read_config_dword(misc_f3_ctl, K8_NBSL, &regs->nbsl);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(misc_f3_ctl, K8_NBEAL, &regs->nbeal);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(misc_f3_ctl, K8_NBEAH, &regs->nbeah);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(misc_f3_ctl, K8_NBCFG, &regs->nbcfg);
+ if (err)
+ goto err_reg;
+
+ return 1;
+
+err_reg:
+ debugf0("Reading error info register failed\n");
+ return 0;
+}
+
+/*
+ * This function is called to retrieve the error data from hardware and store it
+ * in the info structure.
+ *
+ * Returns:
+ * - 1: if a valid error is found
+ * - 0: if no error is found
+ */
+static int amd64_get_error_info(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ struct amd64_pvt *pvt;
+ struct amd64_error_info_regs regs;
+
+ pvt = mci->pvt_info;
+
+ if (!amd64_get_error_info_regs(mci, info))
+ return 0;
+
+ /*
+ * Here's the problem with the K8's EDAC reporting: There are four
+ * registers which report pieces of error information. They are shared
+ * between CEs and UEs. Furthermore, contrary to what is stated in the
+ * BKDG, the overflow bit is never used! Every error always updates the
+ * reporting registers.
+ *
+ * Can you see the race condition? All four error reporting registers
+ * must be read before a new error updates them! There is no way to read
+ * all four registers atomically. The best than can be done is to detect
+ * that a race has occured and then report the error without any kind of
+ * precision.
+ *
+ * What is still positive is that errors are still reported and thus
+ * problems can still be detected - just not localized because the
+ * syndrome and address are spread out across registers.
+ *
+ * Grrrrr!!!!! Here's hoping that AMD fixes this in some future K8 rev.
+ * UEs and CEs should have separate register sets with proper overflow
+ * bits that are used! At very least the problem can be fixed by
+ * honoring the ErrValid bit in 'nbsh' and not updating registers - just
+ * set the overflow bit - unless the current error is CE and the new
+ * error is UE which would be the only situation for overwriting the
+ * current values.
+ */
+
+ regs = *info;
+
+ /* Use info from the second read - most current */
+ if (unlikely(!amd64_get_error_info_regs(mci, info)))
+ return 0;
+
+ /* clear the error bits in hardware */
+ pci_write_bits32(pvt->misc_f3_ctl, K8_NBSH, 0, K8_NBSH_VALID_BIT);
+
+ /* Check for the possible race condition */
+ if ((regs.nbsh != info->nbsh) ||
+ (regs.nbsl != info->nbsl) ||
+ (regs.nbeah != info->nbeah) ||
+ (regs.nbeal != info->nbeal)) {
+ amd64_mc_printk(mci, KERN_WARNING,
+ "hardware STATUS read access race condition "
+ "detected!\n");
+ return 0;
+ }
+ return 1;
+}
+
+static inline void amd64_decode_gart_tlb_error(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ u32 err_code;
+ u32 ec_tt; /* error code transaction type (2b) */
+ u32 ec_ll; /* error code cache level (2b) */
+
+ err_code = EXTRACT_ERROR_CODE(info->nbsl);
+ ec_ll = EXTRACT_LL_CODE(err_code);
+ ec_tt = EXTRACT_TT_CODE(err_code);
+
+ amd64_mc_printk(mci, KERN_ERR,
+ "GART TLB event: transaction type(%s), "
+ "cache level(%s)\n", tt_msgs[ec_tt], ll_msgs[ec_ll]);
+}
+
+static inline void amd64_decode_mem_cache_error(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ u32 err_code;
+ u32 ec_rrrr; /* error code memory transaction (4b) */
+ u32 ec_tt; /* error code transaction type (2b) */
+ u32 ec_ll; /* error code cache level (2b) */
+
+ err_code = EXTRACT_ERROR_CODE(info->nbsl);
+ ec_ll = EXTRACT_LL_CODE(err_code);
+ ec_tt = EXTRACT_TT_CODE(err_code);
+ ec_rrrr = EXTRACT_RRRR_CODE(err_code);
+
+ amd64_mc_printk(mci, KERN_ERR,
+ "cache hierarchy error: memory transaction type(%s), "
+ "transaction type(%s), cache level(%s)\n",
+ rrrr_msgs[ec_rrrr], tt_msgs[ec_tt], ll_msgs[ec_ll]);
+}
+
+
+/*
+ * Handle any Correctable Errors (CEs) that have occurred. Check for valid ERROR
+ * ADDRESS and process.
+ */
+static void amd64_handle_ce(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u64 SystemAddress;
+
+ /* Ensure that the Error Address is VALID */
+ if ((info->nbsh & K8_NBSH_VALID_ERROR_ADDR) == 0) {
+ amd64_mc_printk(mci, KERN_ERR,
+ "HW has no ERROR_ADDRESS available\n");
+ edac_mc_handle_ce_no_info(mci, EDAC_MOD_STR);
+ return;
+ }
+
+ SystemAddress = extract_error_address(mci, info);
+
+ amd64_mc_printk(mci, KERN_ERR,
+ "CE ERROR_ADDRESS= 0x%llx\n", SystemAddress);
+
+ pvt->ops->map_sysaddr_to_csrow(mci, info, SystemAddress);
+}
+
+/* Handle any Un-correctable Errors (UEs) */
+static void amd64_handle_ue(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ int csrow;
+ u64 SystemAddress;
+ u32 page, offset;
+ struct mem_ctl_info *log_mci, *src_mci = NULL;
+
+ log_mci = mci;
+
+ if ((info->nbsh & K8_NBSH_VALID_ERROR_ADDR) == 0) {
+ amd64_mc_printk(mci, KERN_CRIT,
+ "HW has no ERROR_ADDRESS available\n");
+ edac_mc_handle_ue_no_info(log_mci, EDAC_MOD_STR);
+ return;
+ }
+
+ SystemAddress = extract_error_address(mci, info);
+
+ /*
+ * Find out which node the error address belongs to. This may be
+ * different from the node that detected the error.
+ */
+ src_mci = find_mc_by_sys_addr(mci, SystemAddress);
+ if (!src_mci) {
+ amd64_mc_printk(mci, KERN_CRIT,
+ "ERROR ADDRESS (0x%lx) value NOT mapped to a MC\n",
+ (unsigned long)SystemAddress);
+ edac_mc_handle_ue_no_info(log_mci, EDAC_MOD_STR);
+ return;
+ }
+
+ log_mci = src_mci;
+
+ csrow = sys_addr_to_csrow(log_mci, SystemAddress);
+ if (csrow < 0) {
+ amd64_mc_printk(mci, KERN_CRIT,
+ "ERROR_ADDRESS (0x%lx) value NOT mapped to 'csrow'\n",
+ (unsigned long)SystemAddress);
+ edac_mc_handle_ue_no_info(log_mci, EDAC_MOD_STR);
+ } else {
+ error_address_to_page_and_offset(SystemAddress, &page, &offset);
+ edac_mc_handle_ue(log_mci, page, offset, csrow, EDAC_MOD_STR);
+ }
+}
+
+static void amd64_decode_bus_error(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info)
+{
+ u32 err_code, ext_ec;
+ u32 ec_pp; /* error code participating processor (2p) */
+ u32 ec_to; /* error code timed out (1b) */
+ u32 ec_rrrr; /* error code memory transaction (4b) */
+ u32 ec_ii; /* error code memory or I/O (2b) */
+ u32 ec_ll; /* error code cache level (2b) */
+
+ ext_ec = EXTRACT_EXT_ERROR_CODE(info->nbsl);
+ err_code = EXTRACT_ERROR_CODE(info->nbsl);
+
+ ec_ll = EXTRACT_LL_CODE(err_code);
+ ec_ii = EXTRACT_II_CODE(err_code);
+ ec_rrrr = EXTRACT_RRRR_CODE(err_code);
+ ec_to = EXTRACT_TO_CODE(err_code);
+ ec_pp = EXTRACT_PP_CODE(err_code);
+
+ amd64_mc_printk(mci, KERN_ERR,
+ "BUS ERROR:\n"
+ " time-out(%s) mem or i/o(%s)\n"
+ " participating processor(%s)\n"
+ " memory transaction type(%s)\n"
+ " cache level(%s) Error Found by: %s\n",
+ to_msgs[ec_to],
+ ii_msgs[ec_ii],
+ pp_msgs[ec_pp],
+ rrrr_msgs[ec_rrrr],
+ ll_msgs[ec_ll],
+ (info->nbsh & K8_NBSH_ERR_SCRUBER) ?
+ "Scrubber" : "Normal Operation");
+
+ /* If this was an 'observed' error, early out */
+ if (ec_pp == K8_NBSL_PP_OBS)
+ return; /* We aren't the node involved */
+
+ /* Parse out the extended error code for ECC events */
+ switch (ext_ec) {
+ /* F10 changed to one Extended ECC error code */
+ case F10_NBSL_EXT_ERR_RES: /* Reserved field */
+ case F10_NBSL_EXT_ERR_ECC: /* F10 ECC ext err code */
+ break;
+
+ default:
+ amd64_mc_printk(mci, KERN_ERR, "NOT ECC: no special error "
+ "handling for this error\n");
+ return;
+ }
+
+ if (info->nbsh & K8_NBSH_CECC)
+ amd64_handle_ce(mci, info);
+ else if (info->nbsh & K8_NBSH_UECC)
+ amd64_handle_ue(mci, info);
+
+ /*
+ * If main error is CE then overflow must be CE. If main error is UE
+ * then overflow is unknown. We'll call the overflow a CE - if
+ * panic_on_ue is set then we're already panic'ed and won't arrive
+ * here. Else, then apparently someone doesn't think that UE's are
+ * catastrophic.
+ */
+ if (info->nbsh & K8_NBSH_OVERFLOW)
+ edac_mc_handle_ce_no_info(mci, EDAC_MOD_STR
+ "Error Overflow set");
+}
+
+int amd64_process_error_info(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info,
+ int handle_errors)
+{
+ struct amd64_pvt *pvt;
+ struct amd64_error_info_regs *regs;
+ u32 err_code, ext_ec;
+ int gart_tlb_error = 0;
+
+ pvt = mci->pvt_info;
+
+ /* If caller doesn't want us to process the error, return */
+ if (!handle_errors)
+ return 1;
+
+ regs = info;
+
+ debugf1("NorthBridge ERROR: mci(0x%p)\n", mci);
+ debugf1(" MC node(%d) Error-Address(0x%.8x-%.8x)\n",
+ pvt->mc_node_id, regs->nbeah, regs->nbeal);
+ debugf1(" nbsh(0x%.8x) nbsl(0x%.8x)\n",
+ regs->nbsh, regs->nbsl);
+ debugf1(" Valid Error=%s Overflow=%s\n",
+ (regs->nbsh & K8_NBSH_VALID_BIT) ? "True" : "False",
+ (regs->nbsh & K8_NBSH_OVERFLOW) ? "True" : "False");
+ debugf1(" Err Uncorrected=%s MCA Error Reporting=%s\n",
+ (regs->nbsh & K8_NBSH_UNCORRECTED_ERR) ?
+ "True" : "False",
+ (regs->nbsh & K8_NBSH_ERR_ENABLE) ?
+ "True" : "False");
+ debugf1(" MiscErr Valid=%s ErrAddr Valid=%s PCC=%s\n",
+ (regs->nbsh & K8_NBSH_MISC_ERR_VALID) ?
+ "True" : "False",
+ (regs->nbsh & K8_NBSH_VALID_ERROR_ADDR) ?
+ "True" : "False",
+ (regs->nbsh & K8_NBSH_PCC) ?
+ "True" : "False");
+ debugf1(" CECC=%s UECC=%s Found by Scruber=%s\n",
+ (regs->nbsh & K8_NBSH_CECC) ?
+ "True" : "False",
+ (regs->nbsh & K8_NBSH_UECC) ?
+ "True" : "False",
+ (regs->nbsh & K8_NBSH_ERR_SCRUBER) ?
+ "True" : "False");
+ debugf1(" CORE0=%s CORE1=%s CORE2=%s CORE3=%s\n",
+ (regs->nbsh & K8_NBSH_CORE0) ? "True" : "False",
+ (regs->nbsh & K8_NBSH_CORE1) ? "True" : "False",
+ (regs->nbsh & K8_NBSH_CORE2) ? "True" : "False",
+ (regs->nbsh & K8_NBSH_CORE3) ? "True" : "False");
+
+
+ err_code = EXTRACT_ERROR_CODE(regs->nbsl);
+
+ /* Determine which error type:
+ * 1) GART errors - non-fatal, developmental events
+ * 2) MEMORY errors
+ * 3) BUS errors
+ * 4) Unknown error
+ */
+ if (TEST_TLB_ERROR(err_code)) {
+ /*
+ * GART errors are intended to help graphics driver developers
+ * to detect bad GART PTEs. It is recommended by AMD to disable
+ * GART table walk error reporting by default[1] (currently
+ * being disabled in mce_cpu_quirks()) and according to the
+ * comment in mce_cpu_quirks(), such GART errors can be
+ * incorrectly triggered. We may see these errors anyway and
+ * unless requested by the user, they won't be reported.
+ *
+ * [1] section 13.10.1 on BIOS and Kernel Developers Guide for
+ * AMD NPT family 0Fh processors
+ */
+ if (report_gart_errors == 0)
+ return 1;
+
+ /*
+ * Only if GART error reporting is requested should we generate
+ * any logs.
+ */
+ gart_tlb_error = 1;
+
+ debugf1("GART TLB error\n");
+ amd64_decode_gart_tlb_error(mci, info);
+ } else if (TEST_MEM_ERROR(err_code)) {
+ debugf1("Memory/Cache error\n");
+ amd64_decode_mem_cache_error(mci, info);
+ } else if (TEST_BUS_ERROR(err_code)) {
+ debugf1("Bus (Link/DRAM) error\n");
+ amd64_decode_bus_error(mci, info);
+ } else {
+ /* shouldn't reach here! */
+ amd64_mc_printk(mci, KERN_WARNING,
+ "%s(): unknown MCE error 0x%x\n", __func__,
+ err_code);
+ }
+
+ ext_ec = EXTRACT_EXT_ERROR_CODE(regs->nbsl);
+ amd64_mc_printk(mci, KERN_ERR,
+ "ExtErr=(0x%x) %s\n", ext_ec, ext_msgs[ext_ec]);
+
+ if (((ext_ec >= F10_NBSL_EXT_ERR_CRC &&
+ ext_ec <= F10_NBSL_EXT_ERR_TGT) ||
+ (ext_ec == F10_NBSL_EXT_ERR_RMW)) &&
+ EXTRACT_LDT_LINK(info->nbsh)) {
+
+ amd64_mc_printk(mci, KERN_ERR,
+ "Error on hypertransport link: %s\n",
+ htlink_msgs[
+ EXTRACT_LDT_LINK(info->nbsh)]);
+ }
+
+ /*
+ * Check the UE bit of the NB status high register, if set generate some
+ * logs. If NOT a GART error, then process the event as a NO-INFO event.
+ * If it was a GART error, skip that process.
+ */
+ if (regs->nbsh & K8_NBSH_UNCORRECTED_ERR) {
+ amd64_mc_printk(mci, KERN_CRIT, "uncorrected error\n");
+ if (!gart_tlb_error)
+ edac_mc_handle_ue_no_info(mci, "UE bit is set\n");
+ }
+
+ if (regs->nbsh & K8_NBSH_PCC)
+ amd64_mc_printk(mci, KERN_CRIT,
+ "PCC (processor context corrupt) set\n");
+
+ return 1;
+}
+EXPORT_SYMBOL_GPL(amd64_process_error_info);
+
+/*
+ * The main polling 'check' function, called FROM the edac core to perform the
+ * error checking and if an error is encountered, error processing.
+ */
+static void amd64_check(struct mem_ctl_info *mci)
+{
+ struct amd64_error_info_regs info;
+
+ if (amd64_get_error_info(mci, &info))
+ amd64_process_error_info(mci, &info, 1);
+}
+
+/*
+ * Input:
+ * 1) struct amd64_pvt which contains pvt->dram_f2_ctl pointer
+ * 2) AMD Family index value
+ *
+ * Ouput:
+ * Upon return of 0, the following filled in:
+ *
+ * struct pvt->addr_f1_ctl
+ * struct pvt->misc_f3_ctl
+ *
+ * Filled in with related device funcitions of 'dram_f2_ctl'
+ * These devices are "reserved" via the pci_get_device()
+ *
+ * Upon return of 1 (error status):
+ *
+ * Nothing reserved
+ */
+static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, int mc_idx)
+{
+ const struct amd64_family_type *amd64_dev = &amd64_family_types[mc_idx];
+
+ /* Reserve the ADDRESS MAP Device */
+ pvt->addr_f1_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor,
+ amd64_dev->addr_f1_ctl,
+ pvt->dram_f2_ctl);
+
+ if (!pvt->addr_f1_ctl) {
+ amd64_printk(KERN_ERR, "error address map device not found: "
+ "vendor %x device 0x%x (broken BIOS?)\n",
+ PCI_VENDOR_ID_AMD, amd64_dev->addr_f1_ctl);
+ return 1;
+ }
+
+ /* Reserve the MISC Device */
+ pvt->misc_f3_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor,
+ amd64_dev->misc_f3_ctl,
+ pvt->dram_f2_ctl);
+
+ if (!pvt->misc_f3_ctl) {
+ pci_dev_put(pvt->addr_f1_ctl);
+ pvt->addr_f1_ctl = NULL;
+
+ amd64_printk(KERN_ERR, "error miscellaneous device not found: "
+ "vendor %x device 0x%x (broken BIOS?)\n",
+ PCI_VENDOR_ID_AMD, amd64_dev->misc_f3_ctl);
+ return 1;
+ }
+
+ debugf1(" Addr Map device PCI Bus ID:\t%s\n",
+ pci_name(pvt->addr_f1_ctl));
+ debugf1(" DRAM MEM-CTL PCI Bus ID:\t%s\n",
+ pci_name(pvt->dram_f2_ctl));
+ debugf1(" Misc device PCI Bus ID:\t%s\n",
+ pci_name(pvt->misc_f3_ctl));
+
+ return 0;
+}
+
+static void amd64_free_mc_sibling_devices(struct amd64_pvt *pvt)
+{
+ pci_dev_put(pvt->addr_f1_ctl);
+ pci_dev_put(pvt->misc_f3_ctl);
+}
+
+/*
+ * Retrieve the hardware registers of the memory controller (this includes the
+ * 'Address Map' and 'Misc' device regs)
+ */
+static void amd64_read_mc_registers(struct amd64_pvt *pvt)
+{
+ u64 msr_val;
+ int dram, err = 0;
+
+ /*
+ * Retrieve TOP_MEM and TOP_MEM2; no masking off of reserved bits since
+ * those are Read-As-Zero
+ */
+ rdmsrl(MSR_K8_TOP_MEM1, msr_val);
+ pvt->top_mem = msr_val >> 23;
+ debugf0(" TOP_MEM=0x%08llx\n", pvt->top_mem);
+
+ /* check first whether TOP_MEM2 is enabled */
+ rdmsrl(MSR_K8_SYSCFG, msr_val);
+ if (msr_val & (1U << 21)) {
+ rdmsrl(MSR_K8_TOP_MEM2, msr_val);
+ pvt->top_mem2 = msr_val >> 23;
+ debugf0(" TOP_MEM2=0x%08llx\n", pvt->top_mem2);
+ } else
+ debugf0(" TOP_MEM2 disabled.\n");
+
+ amd64_cpu_display_info(pvt);
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCAP, &pvt->nbcap);
+ if (err)
+ goto err_reg;
+
+ if (pvt->ops->read_dram_ctl_register)
+ pvt->ops->read_dram_ctl_register(pvt);
+
+ for (dram = 0; dram < DRAM_REG_COUNT; dram++) {
+ /*
+ * Call CPU specific READ function to get the DRAM Base and
+ * Limit values from the DCT.
+ */
+ pvt->ops->read_dram_base_limit(pvt, dram);
+
+ /*
+ * Only print out debug info on rows with both R and W Enabled.
+ * Normal processing, compiler should optimize this whole 'if'
+ * debug output block away.
+ */
+ if (pvt->dram_rw_en[dram] != 0) {
+ debugf1(" DRAM_BASE[%d]: 0x%8.08x-%8.08x "
+ "DRAM_LIMIT: 0x%8.08x-%8.08x\n",
+ dram,
+ (u32)(pvt->dram_base[dram] >> 32),
+ (u32)(pvt->dram_base[dram] & 0xFFFFFFFF),
+ (u32)(pvt->dram_limit[dram] >> 32),
+ (u32)(pvt->dram_limit[dram] & 0xFFFFFFFF));
+ debugf1(" IntlvEn=%s %s %s "
+ "IntlvSel=%d DstNode=%d\n",
+ pvt->dram_IntlvEn[dram] ?
+ "Enabled" : "Disabled",
+ (pvt->dram_rw_en[dram] & 0x2) ? "W" : "!W",
+ (pvt->dram_rw_en[dram] & 0x1) ? "R" : "!R",
+ pvt->dram_IntlvSel[dram],
+ pvt->dram_DstNode[dram]);
+ }
+ }
+
+ amd64_read_dct_base_mask(pvt);
+
+ err = pci_read_config_dword(pvt->addr_f1_ctl, K8_DHAR, &pvt->dhar);
+ if (err)
+ goto err_reg;
+
+ amd64_read_dbam_reg(pvt);
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl,
+ F10_ONLINE_SPARE, &pvt->online_spare);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCLR_0, &pvt->dclr0);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCHR_0, &pvt->dchr0);
+ if (err)
+ goto err_reg;
+
+ if (!dct_ganging_enabled(pvt)) {
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCLR_1,
+ &pvt->dclr1);
+ if (err)
+ goto err_reg;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCHR_1,
+ &pvt->dchr1);
+ if (err)
+ goto err_reg;
+ }
+
+ amd64_dump_misc_regs(pvt);
+
+err_reg:
+ debugf0("Reading an MC register failed\n");
+
+}
+
+/*
+ * NOTE: CPU Revision Dependent code
+ *
+ * Input:
+ * @csrow_nr ChipSelect Row Number (0..CHIPSELECT_COUNT-1)
+ * k8 private pointer to -->
+ * DRAM Bank Address mapping register
+ * node_id
+ * DCL register where dual_channel_active is
+ *
+ * The DBAM register consists of 4 sets of 4 bits each definitions:
+ *
+ * Bits: CSROWs
+ * 0-3 CSROWs 0 and 1
+ * 4-7 CSROWs 2 and 3
+ * 8-11 CSROWs 4 and 5
+ * 12-15 CSROWs 6 and 7
+ *
+ * Values range from: 0 to 15
+ * The meaning of the values depends on CPU revision and dual-channel state,
+ * see relevant BKDG more info.
+ *
+ * The memory controller provides for total of only 8 CSROWs in its current
+ * architecture. Each "pair" of CSROWs normally represents just one DIMM in
+ * single channel or two (2) DIMMs in dual channel mode.
+ *
+ * The following code logic collapses the various tables for CSROW based on CPU
+ * revision.
+ *
+ * Returns:
+ * The number of PAGE_SIZE pages on the specified CSROW number it
+ * encompasses
+ *
+ */
+static u32 amd64_csrow_nr_pages(int csrow_nr, struct amd64_pvt *pvt)
+{
+ u32 dram_map, nr_pages;
+
+ /*
+ * The math on this doesn't look right on the surface because x/2*4 can
+ * be simplified to x*2 but this expression makes use of the fact that
+ * it is integral math where 1/2=0. This intermediate value becomes the
+ * number of bits to shift the DBAM register to extract the proper CSROW
+ * field.
+ */
+ dram_map = (pvt->dbam0 >> ((csrow_nr / 2) * 4)) & 0xF;
+
+ nr_pages = pvt->ops->dbam_map_to_pages(pvt, dram_map);
+
+ /*
+ * If dual channel then double the memory size of single channel.
+ * Channel count is 1 or 2
+ */
+ nr_pages <<= (pvt->channel_count - 1);
+
+ debugf0(" (csrow=%d) DBAM map index= %d\n", csrow_nr, dram_map);
+ debugf0(" nr_pages= %u channel-count = %d\n",
+ nr_pages, pvt->channel_count);
+
+ return nr_pages;
+}
+
+/*
+ * Initialize the array of csrow attribute instances, based on the values
+ * from pci config hardware registers.
+ */
+static int amd64_init_csrows(struct mem_ctl_info *mci)
+{
+ struct csrow_info *csrow;
+ struct amd64_pvt *pvt;
+ u64 input_addr_min, input_addr_max, sys_addr;
+ int i, err = 0, empty = 1;
+
+ pvt = mci->pvt_info;
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCFG, &pvt->nbcfg);
+ if (err)
+ debugf0("Reading K8_NBCFG failed\n");
+
+ debugf0("NBCFG= 0x%x CHIPKILL= %s DRAM ECC= %s\n", pvt->nbcfg,
+ (pvt->nbcfg & K8_NBCFG_CHIPKILL) ? "Enabled" : "Disabled",
+ (pvt->nbcfg & K8_NBCFG_ECC_ENABLE) ? "Enabled" : "Disabled"
+ );
+
+ for (i = 0; i < CHIPSELECT_COUNT; i++) {
+ csrow = &mci->csrows[i];
+
+ if ((pvt->dcsb0[i] & K8_DCSB_CS_ENABLE) == 0) {
+ debugf1("----CSROW %d EMPTY for node %d\n", i,
+ pvt->mc_node_id);
+ continue;
+ }
+
+ debugf1("----CSROW %d VALID for MC node %d\n",
+ i, pvt->mc_node_id);
+
+ empty = 0;
+ csrow->nr_pages = amd64_csrow_nr_pages(i, pvt);
+ find_csrow_limits(mci, i, &input_addr_min, &input_addr_max);
+ sys_addr = input_addr_to_sys_addr(mci, input_addr_min);
+ csrow->first_page = (u32) (sys_addr >> PAGE_SHIFT);
+ sys_addr = input_addr_to_sys_addr(mci, input_addr_max);
+ csrow->last_page = (u32) (sys_addr >> PAGE_SHIFT);
+ csrow->page_mask = ~mask_from_dct_mask(pvt, i);
+ /* 8 bytes of resolution */
+
+ csrow->mtype = amd64_determine_memory_type(pvt);
+
+ debugf1(" for MC node %d csrow %d:\n", pvt->mc_node_id, i);
+ debugf1(" input_addr_min: 0x%lx input_addr_max: 0x%lx\n",
+ (unsigned long)input_addr_min,
+ (unsigned long)input_addr_max);
+ debugf1(" sys_addr: 0x%lx page_mask: 0x%lx\n",
+ (unsigned long)sys_addr, csrow->page_mask);
+ debugf1(" nr_pages: %u first_page: 0x%lx "
+ "last_page: 0x%lx\n",
+ (unsigned)csrow->nr_pages,
+ csrow->first_page, csrow->last_page);
+
+ /*
+ * determine whether CHIPKILL or JUST ECC or NO ECC is operating
+ */
+ if (pvt->nbcfg & K8_NBCFG_ECC_ENABLE)
+ csrow->edac_mode =
+ (pvt->nbcfg & K8_NBCFG_CHIPKILL) ?
+ EDAC_S4ECD4ED : EDAC_SECDED;
+ else
+ csrow->edac_mode = EDAC_NONE;
+ }
+
+ return empty;
+}
+
+/*
+ * Only if 'ecc_enable_override' is set AND BIOS had ECC disabled, do "we"
+ * enable it.
+ */
+static void amd64_enable_ecc_error_reporting(struct mem_ctl_info *mci)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ const cpumask_t *cpumask = cpumask_of_node(pvt->mc_node_id);
+ int cpu, idx = 0, err = 0;
+ struct msr msrs[cpumask_weight(cpumask)];
+ u32 value;
+ u32 mask = K8_NBCTL_CECCEn | K8_NBCTL_UECCEn;
+
+ if (!ecc_enable_override)
+ return;
+
+ memset(msrs, 0, sizeof(msrs));
+
+ amd64_printk(KERN_WARNING,
+ "'ecc_enable_override' parameter is active, "
+ "Enabling AMD ECC hardware now: CAUTION\n");
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCTL, &value);
+ if (err)
+ debugf0("Reading K8_NBCTL failed\n");
+
+ /* turn on UECCn and CECCEn bits */
+ pvt->old_nbctl = value & mask;
+ pvt->nbctl_mcgctl_saved = 1;
+
+ value |= mask;
+ pci_write_config_dword(pvt->misc_f3_ctl, K8_NBCTL, value);
+
+ rdmsr_on_cpus(cpumask, K8_MSR_MCGCTL, msrs);
+
+ for_each_cpu(cpu, cpumask) {
+ if (msrs[idx].l & K8_MSR_MCGCTL_NBE)
+ set_bit(idx, &pvt->old_mcgctl);
+
+ msrs[idx].l |= K8_MSR_MCGCTL_NBE;
+ idx++;
+ }
+ wrmsr_on_cpus(cpumask, K8_MSR_MCGCTL, msrs);
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCFG, &value);
+ if (err)
+ debugf0("Reading K8_NBCFG failed\n");
+
+ debugf0("NBCFG(1)= 0x%x CHIPKILL= %s ECC_ENABLE= %s\n", value,
+ (value & K8_NBCFG_CHIPKILL) ? "Enabled" : "Disabled",
+ (value & K8_NBCFG_ECC_ENABLE) ? "Enabled" : "Disabled");
+
+ if (!(value & K8_NBCFG_ECC_ENABLE)) {
+ amd64_printk(KERN_WARNING,
+ "This node reports that DRAM ECC is "
+ "currently Disabled; ENABLING now\n");
+
+ /* Attempt to turn on DRAM ECC Enable */
+ value |= K8_NBCFG_ECC_ENABLE;
+ pci_write_config_dword(pvt->misc_f3_ctl, K8_NBCFG, value);
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCFG, &value);
+ if (err)
+ debugf0("Reading K8_NBCFG failed\n");
+
+ if (!(value & K8_NBCFG_ECC_ENABLE)) {
+ amd64_printk(KERN_WARNING,
+ "Hardware rejects Enabling DRAM ECC checking\n"
+ "Check memory DIMM configuration\n");
+ } else {
+ amd64_printk(KERN_DEBUG,
+ "Hardware accepted DRAM ECC Enable\n");
+ }
+ }
+ debugf0("NBCFG(2)= 0x%x CHIPKILL= %s ECC_ENABLE= %s\n", value,
+ (value & K8_NBCFG_CHIPKILL) ? "Enabled" : "Disabled",
+ (value & K8_NBCFG_ECC_ENABLE) ? "Enabled" : "Disabled");
+
+ pvt->ctl_error_info.nbcfg = value;
+}
+
+static void amd64_restore_ecc_error_reporting(struct amd64_pvt *pvt)
+{
+ const cpumask_t *cpumask = cpumask_of_node(pvt->mc_node_id);
+ int cpu, idx = 0, err = 0;
+ struct msr msrs[cpumask_weight(cpumask)];
+ u32 value;
+ u32 mask = K8_NBCTL_CECCEn | K8_NBCTL_UECCEn;
+
+ if (!pvt->nbctl_mcgctl_saved)
+ return;
+
+ memset(msrs, 0, sizeof(msrs));
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCTL, &value);
+ if (err)
+ debugf0("Reading K8_NBCTL failed\n");
+ value &= ~mask;
+ value |= pvt->old_nbctl;
+
+ /* restore the NB Enable MCGCTL bit */
+ pci_write_config_dword(pvt->misc_f3_ctl, K8_NBCTL, value);
+
+ rdmsr_on_cpus(cpumask, K8_MSR_MCGCTL, msrs);
+
+ for_each_cpu(cpu, cpumask) {
+ msrs[idx].l &= ~K8_MSR_MCGCTL_NBE;
+ msrs[idx].l |=
+ test_bit(idx, &pvt->old_mcgctl) << K8_MSR_MCGCTL_NBE;
+ idx++;
+ }
+
+ wrmsr_on_cpus(cpumask, K8_MSR_MCGCTL, msrs);
+}
+
+static void check_mcg_ctl(void *ret)
+{
+ u64 msr_val = 0;
+ u8 nbe;
+
+ rdmsrl(MSR_IA32_MCG_CTL, msr_val);
+ nbe = msr_val & K8_MSR_MCGCTL_NBE;
+
+ debugf0("core: %u, MCG_CTL: 0x%llx, NB MSR is %s\n",
+ raw_smp_processor_id(), msr_val,
+ (nbe ? "enabled" : "disabled"));
+
+ if (!nbe)
+ *(int *)ret = 0;
+}
+
+/* check MCG_CTL on all the cpus on this node */
+static int amd64_mcg_ctl_enabled_on_cpus(const cpumask_t *mask)
+{
+ int ret = 1;
+ preempt_disable();
+ smp_call_function_many(mask, check_mcg_ctl, &ret, 1);
+ preempt_enable();
+
+ return ret;
+}
+
+/*
+ * EDAC requires that the BIOS have ECC enabled before taking over the
+ * processing of ECC errors. This is because the BIOS can properly initialize
+ * the memory system completely. A command line option allows to force-enable
+ * hardware ECC later in amd64_enable_ecc_error_reporting().
+ */
+static int amd64_check_ecc_enabled(struct amd64_pvt *pvt)
+{
+ u32 value;
+ int err = 0, ret = 0;
+ u8 ecc_enabled = 0;
+
+ err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCFG, &value);
+ if (err)
+ debugf0("Reading K8_NBCTL failed\n");
+
+ ecc_enabled = !!(value & K8_NBCFG_ECC_ENABLE);
+
+ ret = amd64_mcg_ctl_enabled_on_cpus(cpumask_of_node(pvt->mc_node_id));
+
+ debugf0("K8_NBCFG=0x%x, DRAM ECC is %s\n", value,
+ (value & K8_NBCFG_ECC_ENABLE ? "enabled" : "disabled"));
+
+ if (!ecc_enabled || !ret) {
+ if (!ecc_enabled) {
+ amd64_printk(KERN_WARNING, "This node reports that "
+ "Memory ECC is currently "
+ "disabled.\n");
+
+ amd64_printk(KERN_WARNING, "bit 0x%lx in register "
+ "F3x%x of the MISC_CONTROL device (%s) "
+ "should be enabled\n", K8_NBCFG_ECC_ENABLE,
+ K8_NBCFG, pci_name(pvt->misc_f3_ctl));
+ }
+ if (!ret) {
+ amd64_printk(KERN_WARNING, "bit 0x%016lx in MSR 0x%08x "
+ "of node %d should be enabled\n",
+ K8_MSR_MCGCTL_NBE, MSR_IA32_MCG_CTL,
+ pvt->mc_node_id);
+ }
+ if (!ecc_enable_override) {
+ amd64_printk(KERN_WARNING, "WARNING: ECC is NOT "
+ "currently enabled by the BIOS. Module "
+ "will NOT be loaded.\n"
+ " Either Enable ECC in the BIOS, "
+ "or use the 'ecc_enable_override' "
+ "parameter.\n"
+ " Might be a BIOS bug, if BIOS says "
+ "ECC is enabled\n"
+ " Use of the override can cause "
+ "unknown side effects.\n");
+ ret = -ENODEV;
+ }
+ } else {
+ amd64_printk(KERN_INFO,
+ "ECC is enabled by BIOS, Proceeding "
+ "with EDAC module initialization\n");
+
+ /* CLEAR the override, since BIOS controlled it */
+ ecc_enable_override = 0;
+ }
+
+ return ret;
+}
+
+struct mcidev_sysfs_attribute sysfs_attrs[ARRAY_SIZE(amd64_dbg_attrs) +
+ ARRAY_SIZE(amd64_inj_attrs) +
+ 1];
+
+struct mcidev_sysfs_attribute terminator = { .attr = { .name = NULL } };
+
+static void amd64_set_mc_sysfs_attributes(struct mem_ctl_info *mci)
+{
+ unsigned int i = 0, j = 0;
+
+ for (; i < ARRAY_SIZE(amd64_dbg_attrs); i++)
+ sysfs_attrs[i] = amd64_dbg_attrs[i];
+
+ for (j = 0; j < ARRAY_SIZE(amd64_inj_attrs); j++, i++)
+ sysfs_attrs[i] = amd64_inj_attrs[j];
+
+ sysfs_attrs[i] = terminator;
+
+ mci->mc_driver_sysfs_attributes = sysfs_attrs;
+}
+
+static void amd64_setup_mci_misc_attributes(struct mem_ctl_info *mci)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ mci->mtype_cap = MEM_FLAG_DDR2 | MEM_FLAG_RDDR2;
+ mci->edac_ctl_cap = EDAC_FLAG_NONE;
+ mci->edac_cap = EDAC_FLAG_NONE;
+
+ if (pvt->nbcap & K8_NBCAP_SECDED)
+ mci->edac_ctl_cap |= EDAC_FLAG_SECDED;
+
+ if (pvt->nbcap & K8_NBCAP_CHIPKILL)
+ mci->edac_ctl_cap |= EDAC_FLAG_S4ECD4ED;
+
+ mci->edac_cap = amd64_determine_edac_cap(pvt);
+ mci->mod_name = EDAC_MOD_STR;
+ mci->mod_ver = EDAC_AMD64_VERSION;
+ mci->ctl_name = get_amd_family_name(pvt->mc_type_index);
+ mci->dev_name = pci_name(pvt->dram_f2_ctl);
+ mci->ctl_page_to_phys = NULL;
+
+ /* IMPORTANT: Set the polling 'check' function in this module */
+ mci->edac_check = amd64_check;
+
+ /* memory scrubber interface */
+ mci->set_sdram_scrub_rate = amd64_set_scrub_rate;
+ mci->get_sdram_scrub_rate = amd64_get_scrub_rate;
+}
+
+/*
+ * Init stuff for this DRAM Controller device.
+ *
+ * Due to a hardware feature on Fam10h CPUs, the Enable Extended Configuration
+ * Space feature MUST be enabled on ALL Processors prior to actually reading
+ * from the ECS registers. Since the loading of the module can occur on any
+ * 'core', and cores don't 'see' all the other processors ECS data when the
+ * others are NOT enabled. Our solution is to first enable ECS access in this
+ * routine on all processors, gather some data in a amd64_pvt structure and
+ * later come back in a finish-setup function to perform that final
+ * initialization. See also amd64_init_2nd_stage() for that.
+ */
+static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl,
+ int mc_type_index)
+{
+ struct amd64_pvt *pvt = NULL;
+ int err = 0, ret;
+
+ ret = -ENOMEM;
+ pvt = kzalloc(sizeof(struct amd64_pvt), GFP_KERNEL);
+ if (!pvt)
+ goto err_exit;
+
+ pvt->mc_node_id = get_mc_node_id_from_pdev(dram_f2_ctl);
+
+ pvt->dram_f2_ctl = dram_f2_ctl;
+ pvt->ext_model = boot_cpu_data.x86_model >> 4;
+ pvt->mc_type_index = mc_type_index;
+ pvt->ops = family_ops(mc_type_index);
+ pvt->old_mcgctl = 0;
+
+ /*
+ * We have the dram_f2_ctl device as an argument, now go reserve its
+ * sibling devices from the PCI system.
+ */
+ ret = -ENODEV;
+ err = amd64_reserve_mc_sibling_devices(pvt, mc_type_index);
+ if (err)
+ goto err_free;
+
+ ret = -EINVAL;
+ err = amd64_check_ecc_enabled(pvt);
+ if (err)
+ goto err_put;
+
+ /*
+ * Key operation here: setup of HW prior to performing ops on it. Some
+ * setup is required to access ECS data. After this is performed, the
+ * 'teardown' function must be called upon error and normal exit paths.
+ */
+ if (boot_cpu_data.x86 >= 0x10)
+ amd64_setup(pvt);
+
+ /*
+ * Save the pointer to the private data for use in 2nd initialization
+ * stage
+ */
+ pvt_lookup[pvt->mc_node_id] = pvt;
+
+ return 0;
+
+err_put:
+ amd64_free_mc_sibling_devices(pvt);
+
+err_free:
+ kfree(pvt);
+
+err_exit:
+ return ret;
+}
+
+/*
+ * This is the finishing stage of the init code. Needs to be performed after all
+ * MCs' hardware have been prepped for accessing extended config space.
+ */
+static int amd64_init_2nd_stage(struct amd64_pvt *pvt)
+{
+ int node_id = pvt->mc_node_id;
+ struct mem_ctl_info *mci;
+ int ret, err = 0;
+
+ amd64_read_mc_registers(pvt);
+
+ ret = -ENODEV;
+ if (pvt->ops->probe_valid_hardware) {
+ err = pvt->ops->probe_valid_hardware(pvt);
+ if (err)
+ goto err_exit;
+ }
+
+ /*
+ * We need to determine how many memory channels there are. Then use
+ * that information for calculating the size of the dynamic instance
+ * tables in the 'mci' structure
+ */
+ pvt->channel_count = pvt->ops->early_channel_count(pvt);
+ if (pvt->channel_count < 0)
+ goto err_exit;
+
+ ret = -ENOMEM;
+ mci = edac_mc_alloc(0, CHIPSELECT_COUNT, pvt->channel_count, node_id);
+ if (!mci)
+ goto err_exit;
+
+ mci->pvt_info = pvt;
+
+ mci->dev = &pvt->dram_f2_ctl->dev;
+ amd64_setup_mci_misc_attributes(mci);
+
+ if (amd64_init_csrows(mci))
+ mci->edac_cap = EDAC_FLAG_NONE;
+
+ amd64_enable_ecc_error_reporting(mci);
+ amd64_set_mc_sysfs_attributes(mci);
+
+ ret = -ENODEV;
+ if (edac_mc_add_mc(mci)) {
+ debugf1("failed edac_mc_add_mc()\n");
+ goto err_add_mc;
+ }
+
+ mci_lookup[node_id] = mci;
+ pvt_lookup[node_id] = NULL;
+ return 0;
+
+err_add_mc:
+ edac_mc_free(mci);
+
+err_exit:
+ debugf0("failure to init 2nd stage: ret=%d\n", ret);
+
+ amd64_restore_ecc_error_reporting(pvt);
+
+ if (boot_cpu_data.x86 > 0xf)
+ amd64_teardown(pvt);
+
+ amd64_free_mc_sibling_devices(pvt);
+
+ kfree(pvt_lookup[pvt->mc_node_id]);
+ pvt_lookup[node_id] = NULL;
+
+ return ret;
+}
+
+
+static int __devinit amd64_init_one_instance(struct pci_dev *pdev,
+ const struct pci_device_id *mc_type)
+{
+ int ret = 0;
+
+ debugf0("(MC node=%d,mc_type='%s')\n",
+ get_mc_node_id_from_pdev(pdev),
+ get_amd_family_name(mc_type->driver_data));
+
+ ret = pci_enable_device(pdev);
+ if (ret < 0)
+ ret = -EIO;
+ else
+ ret = amd64_probe_one_instance(pdev, mc_type->driver_data);
+
+ if (ret < 0)
+ debugf0("ret=%d\n", ret);
+
+ return ret;
+}
+
+static void __devexit amd64_remove_one_instance(struct pci_dev *pdev)
+{
+ struct mem_ctl_info *mci;
+ struct amd64_pvt *pvt;
+
+ /* Remove from EDAC CORE tracking list */
+ mci = edac_mc_del_mc(&pdev->dev);
+ if (!mci)
+ return;
+
+ pvt = mci->pvt_info;
+
+ amd64_restore_ecc_error_reporting(pvt);
+
+ if (boot_cpu_data.x86 > 0xf)
+ amd64_teardown(pvt);
+
+ amd64_free_mc_sibling_devices(pvt);
+
+ kfree(pvt);
+ mci->pvt_info = NULL;
+
+ mci_lookup[pvt->mc_node_id] = NULL;
+
+ /* Free the EDAC CORE resources */
+ edac_mc_free(mci);
+}
+
+/*
+ * This table is part of the interface for loading drivers for PCI devices. The
+ * PCI core identifies what devices are on a system during boot, and then
+ * inquiry this table to see if this driver is for a given device found.
+ */
+static const struct pci_device_id amd64_pci_table[] __devinitdata = {
+ {
+ .vendor = PCI_VENDOR_ID_AMD,
+ .device = PCI_DEVICE_ID_AMD_K8_NB_MEMCTL,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .class = 0,
+ .class_mask = 0,
+ .driver_data = K8_CPUS
+ },
+ {
+ .vendor = PCI_VENDOR_ID_AMD,
+ .device = PCI_DEVICE_ID_AMD_10H_NB_DRAM,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .class = 0,
+ .class_mask = 0,
+ .driver_data = F10_CPUS
+ },
+ {
+ .vendor = PCI_VENDOR_ID_AMD,
+ .device = PCI_DEVICE_ID_AMD_11H_NB_DRAM,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .class = 0,
+ .class_mask = 0,
+ .driver_data = F11_CPUS
+ },
+ {0, }
+};
+MODULE_DEVICE_TABLE(pci, amd64_pci_table);
+
+static struct pci_driver amd64_pci_driver = {
+ .name = EDAC_MOD_STR,
+ .probe = amd64_init_one_instance,
+ .remove = __devexit_p(amd64_remove_one_instance),
+ .id_table = amd64_pci_table,
+};
+
+static void amd64_setup_pci_device(void)
+{
+ struct mem_ctl_info *mci;
+ struct amd64_pvt *pvt;
+
+ if (amd64_ctl_pci)
+ return;
+
+ mci = mci_lookup[0];
+ if (mci) {
+
+ pvt = mci->pvt_info;
+ amd64_ctl_pci =
+ edac_pci_create_generic_ctl(&pvt->dram_f2_ctl->dev,
+ EDAC_MOD_STR);
+
+ if (!amd64_ctl_pci) {
+ pr_warning("%s(): Unable to create PCI control\n",
+ __func__);
+
+ pr_warning("%s(): PCI error report via EDAC not set\n",
+ __func__);
+ }
+ }
+}
+
+static int __init amd64_edac_init(void)
+{
+ int nb, err = -ENODEV;
+
+ edac_printk(KERN_INFO, EDAC_MOD_STR, EDAC_AMD64_VERSION "\n");
+
+ opstate_init();
+
+ if (cache_k8_northbridges() < 0)
+ goto err_exit;
+
+ err = pci_register_driver(&amd64_pci_driver);
+
+ /*
+ * At this point, the array 'pvt_lookup[]' contains pointers to alloc'd
+ * amd64_pvt structs. These will be used in the 2nd stage init function
+ * to finish initialization of the MC instances.
+ */
+ if (err)
+ return err;
+
+ for (nb = 0; nb < num_k8_northbridges; nb++) {
+ if (!pvt_lookup[nb])
+ continue;
+
+ err = amd64_init_2nd_stage(pvt_lookup[nb]);
+ if (err)
+ goto err_exit;
+ }
+
+ amd64_setup_pci_device();
+
+ return 0;
+
+err_exit:
+ debugf0("'finish_setup' stage failed\n");
+ pci_unregister_driver(&amd64_pci_driver);
+
+ return err;
+}
+
+static void __exit amd64_edac_exit(void)
+{
+ if (amd64_ctl_pci)
+ edac_pci_release_generic_ctl(amd64_ctl_pci);
+
+ pci_unregister_driver(&amd64_pci_driver);
+}
+
+module_init(amd64_edac_init);
+module_exit(amd64_edac_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("SoftwareBitMaker: Doug Thompson, "
+ "Dave Peterson, Thayne Harbaugh");
+MODULE_DESCRIPTION("MC support for AMD64 memory controllers - "
+ EDAC_AMD64_VERSION);
+
+module_param(edac_op_state, int, 0444);
+MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
new file mode 100644
index 000000000000..0386d1d8d099
--- /dev/null
+++ b/drivers/edac/amd64_edac.h
@@ -0,0 +1,657 @@
+/*
+ * AMD64 class Memory Controller kernel module
+ *
+ * Copyright (c) 2009 SoftwareBitMaker.
+ * Copyright (c) 2009 Advanced Micro Devices, Inc.
+ *
+ * This file may be distributed under the terms of the
+ * GNU General Public License.
+ *
+ * Originally Written by Thayne Harbaugh
+ *
+ * Changes by Douglas "norsk" Thompson <dougthompson@xmission.com>:
+ * - K8 CPU Revision D and greater support
+ *
+ * Changes by Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>:
+ * - Module largely rewritten, with new (and hopefully correct)
+ * code for dealing with node and chip select interleaving,
+ * various code cleanup, and bug fixes
+ * - Added support for memory hoisting using DRAM hole address
+ * register
+ *
+ * Changes by Douglas "norsk" Thompson <dougthompson@xmission.com>:
+ * -K8 Rev (1207) revision support added, required Revision
+ * specific mini-driver code to support Rev F as well as
+ * prior revisions
+ *
+ * Changes by Douglas "norsk" Thompson <dougthompson@xmission.com>:
+ * -Family 10h revision support added. New PCI Device IDs,
+ * indicating new changes. Actual registers modified
+ * were slight, less than the Rev E to Rev F transition
+ * but changing the PCI Device ID was the proper thing to
+ * do, as it provides for almost automactic family
+ * detection. The mods to Rev F required more family
+ * information detection.
+ *
+ * Changes/Fixes by Borislav Petkov <borislav.petkov@amd.com>:
+ * - misc fixes and code cleanups
+ *
+ * This module is based on the following documents
+ * (available from http://www.amd.com/):
+ *
+ * Title: BIOS and Kernel Developer's Guide for AMD Athlon 64 and AMD
+ * Opteron Processors
+ * AMD publication #: 26094
+ *` Revision: 3.26
+ *
+ * Title: BIOS and Kernel Developer's Guide for AMD NPT Family 0Fh
+ * Processors
+ * AMD publication #: 32559
+ * Revision: 3.00
+ * Issue Date: May 2006
+ *
+ * Title: BIOS and Kernel Developer's Guide (BKDG) For AMD Family 10h
+ * Processors
+ * AMD publication #: 31116
+ * Revision: 3.00
+ * Issue Date: September 07, 2007
+ *
+ * Sections in the first 2 documents are no longer in sync with each other.
+ * The Family 10h BKDG was totally re-written from scratch with a new
+ * presentation model.
+ * Therefore, comments that refer to a Document section might be off.
+ */
+
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
+#include <linux/slab.h>
+#include <linux/mmzone.h>
+#include <linux/edac.h>
+#include <asm/msr.h>
+#include "edac_core.h"
+
+#define amd64_printk(level, fmt, arg...) \
+ edac_printk(level, "amd64", fmt, ##arg)
+
+#define amd64_mc_printk(mci, level, fmt, arg...) \
+ edac_mc_chipset_printk(mci, level, "amd64", fmt, ##arg)
+
+/*
+ * Throughout the comments in this code, the following terms are used:
+ *
+ * SysAddr, DramAddr, and InputAddr
+ *
+ * These terms come directly from the amd64 documentation
+ * (AMD publication #26094). They are defined as follows:
+ *
+ * SysAddr:
+ * This is a physical address generated by a CPU core or a device
+ * doing DMA. If generated by a CPU core, a SysAddr is the result of
+ * a virtual to physical address translation by the CPU core's address
+ * translation mechanism (MMU).
+ *
+ * DramAddr:
+ * A DramAddr is derived from a SysAddr by subtracting an offset that
+ * depends on which node the SysAddr maps to and whether the SysAddr
+ * is within a range affected by memory hoisting. The DRAM Base
+ * (section 3.4.4.1) and DRAM Limit (section 3.4.4.2) registers
+ * determine which node a SysAddr maps to.
+ *
+ * If the DRAM Hole Address Register (DHAR) is enabled and the SysAddr
+ * is within the range of addresses specified by this register, then
+ * a value x from the DHAR is subtracted from the SysAddr to produce a
+ * DramAddr. Here, x represents the base address for the node that
+ * the SysAddr maps to plus an offset due to memory hoisting. See
+ * section 3.4.8 and the comments in amd64_get_dram_hole_info() and
+ * sys_addr_to_dram_addr() below for more information.
+ *
+ * If the SysAddr is not affected by the DHAR then a value y is
+ * subtracted from the SysAddr to produce a DramAddr. Here, y is the
+ * base address for the node that the SysAddr maps to. See section
+ * 3.4.4 and the comments in sys_addr_to_dram_addr() below for more
+ * information.
+ *
+ * InputAddr:
+ * A DramAddr is translated to an InputAddr before being passed to the
+ * memory controller for the node that the DramAddr is associated
+ * with. The memory controller then maps the InputAddr to a csrow.
+ * If node interleaving is not in use, then the InputAddr has the same
+ * value as the DramAddr. Otherwise, the InputAddr is produced by
+ * discarding the bits used for node interleaving from the DramAddr.
+ * See section 3.4.4 for more information.
+ *
+ * The memory controller for a given node uses its DRAM CS Base and
+ * DRAM CS Mask registers to map an InputAddr to a csrow. See
+ * sections 3.5.4 and 3.5.5 for more information.
+ */
+
+#define EDAC_AMD64_VERSION " Ver: 3.2.0 " __DATE__
+#define EDAC_MOD_STR "amd64_edac"
+
+/* Extended Model from CPUID, for CPU Revision numbers */
+#define OPTERON_CPU_LE_REV_C 0
+#define OPTERON_CPU_REV_D 1
+#define OPTERON_CPU_REV_E 2
+
+/* NPT processors have the following Extended Models */
+#define OPTERON_CPU_REV_F 4
+#define OPTERON_CPU_REV_FA 5
+
+/* Hardware limit on ChipSelect rows per MC and processors per system */
+#define CHIPSELECT_COUNT 8
+#define DRAM_REG_COUNT 8
+
+
+/*
+ * PCI-defined configuration space registers
+ */
+
+
+/*
+ * Function 1 - Address Map
+ */
+#define K8_DRAM_BASE_LOW 0x40
+#define K8_DRAM_LIMIT_LOW 0x44
+#define K8_DHAR 0xf0
+
+#define DHAR_VALID BIT(0)
+#define F10_DRAM_MEM_HOIST_VALID BIT(1)
+
+#define DHAR_BASE_MASK 0xff000000
+#define dhar_base(dhar) (dhar & DHAR_BASE_MASK)
+
+#define K8_DHAR_OFFSET_MASK 0x0000ff00
+#define k8_dhar_offset(dhar) ((dhar & K8_DHAR_OFFSET_MASK) << 16)
+
+#define F10_DHAR_OFFSET_MASK 0x0000ff80
+ /* NOTE: Extra mask bit vs K8 */
+#define f10_dhar_offset(dhar) ((dhar & F10_DHAR_OFFSET_MASK) << 16)
+
+
+/* F10 High BASE/LIMIT registers */
+#define F10_DRAM_BASE_HIGH 0x140
+#define F10_DRAM_LIMIT_HIGH 0x144
+
+
+/*
+ * Function 2 - DRAM controller
+ */
+#define K8_DCSB0 0x40
+#define F10_DCSB1 0x140
+
+#define K8_DCSB_CS_ENABLE BIT(0)
+#define K8_DCSB_NPT_SPARE BIT(1)
+#define K8_DCSB_NPT_TESTFAIL BIT(2)
+
+/*
+ * REV E: select [31:21] and [15:9] from DCSB and the shift amount to form
+ * the address
+ */
+#define REV_E_DCSB_BASE_BITS (0xFFE0FE00ULL)
+#define REV_E_DCS_SHIFT 4
+#define REV_E_DCSM_COUNT 8
+
+#define REV_F_F1Xh_DCSB_BASE_BITS (0x1FF83FE0ULL)
+#define REV_F_F1Xh_DCS_SHIFT 8
+
+/*
+ * REV F and later: selects [28:19] and [13:5] from DCSB and the shift amount
+ * to form the address
+ */
+#define REV_F_DCSB_BASE_BITS (0x1FF83FE0ULL)
+#define REV_F_DCS_SHIFT 8
+#define REV_F_DCSM_COUNT 4
+#define F10_DCSM_COUNT 4
+#define F11_DCSM_COUNT 2
+
+/* DRAM CS Mask Registers */
+#define K8_DCSM0 0x60
+#define F10_DCSM1 0x160
+
+/* REV E: select [29:21] and [15:9] from DCSM */
+#define REV_E_DCSM_MASK_BITS 0x3FE0FE00
+
+/* unused bits [24:20] and [12:0] */
+#define REV_E_DCS_NOTUSED_BITS 0x01F01FFF
+
+/* REV F and later: select [28:19] and [13:5] from DCSM */
+#define REV_F_F1Xh_DCSM_MASK_BITS 0x1FF83FE0
+
+/* unused bits [26:22] and [12:0] */
+#define REV_F_F1Xh_DCS_NOTUSED_BITS 0x07C01FFF
+
+#define DBAM0 0x80
+#define DBAM1 0x180
+
+/* Extract the DIMM 'type' on the i'th DIMM from the DBAM reg value passed */
+#define DBAM_DIMM(i, reg) ((((reg) >> (4*i))) & 0xF)
+
+#define DBAM_MAX_VALUE 11
+
+
+#define F10_DCLR_0 0x90
+#define F10_DCLR_1 0x190
+#define REVE_WIDTH_128 BIT(16)
+#define F10_WIDTH_128 BIT(11)
+
+
+#define F10_DCHR_0 0x94
+#define F10_DCHR_1 0x194
+
+#define F10_DCHR_FOUR_RANK_DIMM BIT(18)
+#define F10_DCHR_Ddr3Mode BIT(8)
+#define F10_DCHR_MblMode BIT(6)
+
+
+#define F10_DCTL_SEL_LOW 0x110
+
+#define dct_sel_baseaddr(pvt) \
+ ((pvt->dram_ctl_select_low) & 0xFFFFF800)
+
+#define dct_sel_interleave_addr(pvt) \
+ (((pvt->dram_ctl_select_low) >> 6) & 0x3)
+
+enum {
+ F10_DCTL_SEL_LOW_DctSelHiRngEn = BIT(0),
+ F10_DCTL_SEL_LOW_DctSelIntLvEn = BIT(2),
+ F10_DCTL_SEL_LOW_DctGangEn = BIT(4),
+ F10_DCTL_SEL_LOW_DctDatIntLv = BIT(5),
+ F10_DCTL_SEL_LOW_DramEnable = BIT(8),
+ F10_DCTL_SEL_LOW_MemCleared = BIT(10),
+};
+
+#define dct_high_range_enabled(pvt) \
+ (pvt->dram_ctl_select_low & F10_DCTL_SEL_LOW_DctSelHiRngEn)
+
+#define dct_interleave_enabled(pvt) \
+ (pvt->dram_ctl_select_low & F10_DCTL_SEL_LOW_DctSelIntLvEn)
+
+#define dct_ganging_enabled(pvt) \
+ (pvt->dram_ctl_select_low & F10_DCTL_SEL_LOW_DctGangEn)
+
+#define dct_data_intlv_enabled(pvt) \
+ (pvt->dram_ctl_select_low & F10_DCTL_SEL_LOW_DctDatIntLv)
+
+#define dct_dram_enabled(pvt) \
+ (pvt->dram_ctl_select_low & F10_DCTL_SEL_LOW_DramEnable)
+
+#define dct_memory_cleared(pvt) \
+ (pvt->dram_ctl_select_low & F10_DCTL_SEL_LOW_MemCleared)
+
+
+#define F10_DCTL_SEL_HIGH 0x114
+
+
+/*
+ * Function 3 - Misc Control
+ */
+#define K8_NBCTL 0x40
+
+/* Correctable ECC error reporting enable */
+#define K8_NBCTL_CECCEn BIT(0)
+
+/* UnCorrectable ECC error reporting enable */
+#define K8_NBCTL_UECCEn BIT(1)
+
+#define K8_NBCFG 0x44
+#define K8_NBCFG_CHIPKILL BIT(23)
+#define K8_NBCFG_ECC_ENABLE BIT(22)
+
+#define K8_NBSL 0x48
+
+
+#define EXTRACT_HIGH_SYNDROME(x) (((x) >> 24) & 0xff)
+#define EXTRACT_EXT_ERROR_CODE(x) (((x) >> 16) & 0x1f)
+
+/* Family F10h: Normalized Extended Error Codes */
+#define F10_NBSL_EXT_ERR_RES 0x0
+#define F10_NBSL_EXT_ERR_CRC 0x1
+#define F10_NBSL_EXT_ERR_SYNC 0x2
+#define F10_NBSL_EXT_ERR_MST 0x3
+#define F10_NBSL_EXT_ERR_TGT 0x4
+#define F10_NBSL_EXT_ERR_GART 0x5
+#define F10_NBSL_EXT_ERR_RMW 0x6
+#define F10_NBSL_EXT_ERR_WDT 0x7
+#define F10_NBSL_EXT_ERR_ECC 0x8
+#define F10_NBSL_EXT_ERR_DEV 0x9
+#define F10_NBSL_EXT_ERR_LINK_DATA 0xA
+
+/* Next two are overloaded values */
+#define F10_NBSL_EXT_ERR_LINK_PROTO 0xB
+#define F10_NBSL_EXT_ERR_L3_PROTO 0xB
+
+#define F10_NBSL_EXT_ERR_NB_ARRAY 0xC
+#define F10_NBSL_EXT_ERR_DRAM_PARITY 0xD
+#define F10_NBSL_EXT_ERR_LINK_RETRY 0xE
+
+/* Next two are overloaded values */
+#define F10_NBSL_EXT_ERR_GART_WALK 0xF
+#define F10_NBSL_EXT_ERR_DEV_WALK 0xF
+
+/* 0x10 to 0x1B: Reserved */
+#define F10_NBSL_EXT_ERR_L3_DATA 0x1C
+#define F10_NBSL_EXT_ERR_L3_TAG 0x1D
+#define F10_NBSL_EXT_ERR_L3_LRU 0x1E
+
+/* K8: Normalized Extended Error Codes */
+#define K8_NBSL_EXT_ERR_ECC 0x0
+#define K8_NBSL_EXT_ERR_CRC 0x1
+#define K8_NBSL_EXT_ERR_SYNC 0x2
+#define K8_NBSL_EXT_ERR_MST 0x3
+#define K8_NBSL_EXT_ERR_TGT 0x4
+#define K8_NBSL_EXT_ERR_GART 0x5
+#define K8_NBSL_EXT_ERR_RMW 0x6
+#define K8_NBSL_EXT_ERR_WDT 0x7
+#define K8_NBSL_EXT_ERR_CHIPKILL_ECC 0x8
+#define K8_NBSL_EXT_ERR_DRAM_PARITY 0xD
+
+#define EXTRACT_ERROR_CODE(x) ((x) & 0xffff)
+#define TEST_TLB_ERROR(x) (((x) & 0xFFF0) == 0x0010)
+#define TEST_MEM_ERROR(x) (((x) & 0xFF00) == 0x0100)
+#define TEST_BUS_ERROR(x) (((x) & 0xF800) == 0x0800)
+#define EXTRACT_TT_CODE(x) (((x) >> 2) & 0x3)
+#define EXTRACT_II_CODE(x) (((x) >> 2) & 0x3)
+#define EXTRACT_LL_CODE(x) (((x) >> 0) & 0x3)
+#define EXTRACT_RRRR_CODE(x) (((x) >> 4) & 0xf)
+#define EXTRACT_TO_CODE(x) (((x) >> 8) & 0x1)
+#define EXTRACT_PP_CODE(x) (((x) >> 9) & 0x3)
+
+/*
+ * The following are for BUS type errors AFTER values have been normalized by
+ * shifting right
+ */
+#define K8_NBSL_PP_SRC 0x0
+#define K8_NBSL_PP_RES 0x1
+#define K8_NBSL_PP_OBS 0x2
+#define K8_NBSL_PP_GENERIC 0x3
+
+
+#define K8_NBSH 0x4C
+
+#define K8_NBSH_VALID_BIT BIT(31)
+#define K8_NBSH_OVERFLOW BIT(30)
+#define K8_NBSH_UNCORRECTED_ERR BIT(29)
+#define K8_NBSH_ERR_ENABLE BIT(28)
+#define K8_NBSH_MISC_ERR_VALID BIT(27)
+#define K8_NBSH_VALID_ERROR_ADDR BIT(26)
+#define K8_NBSH_PCC BIT(25)
+#define K8_NBSH_CECC BIT(14)
+#define K8_NBSH_UECC BIT(13)
+#define K8_NBSH_ERR_SCRUBER BIT(8)
+#define K8_NBSH_CORE3 BIT(3)
+#define K8_NBSH_CORE2 BIT(2)
+#define K8_NBSH_CORE1 BIT(1)
+#define K8_NBSH_CORE0 BIT(0)
+
+#define EXTRACT_LDT_LINK(x) (((x) >> 4) & 0x7)
+#define EXTRACT_ERR_CPU_MAP(x) ((x) & 0xF)
+#define EXTRACT_LOW_SYNDROME(x) (((x) >> 15) & 0xff)
+
+
+#define K8_NBEAL 0x50
+#define K8_NBEAH 0x54
+#define K8_SCRCTRL 0x58
+
+#define F10_NB_CFG_LOW 0x88
+#define F10_NB_CFG_LOW_ENABLE_EXT_CFG BIT(14)
+
+#define F10_NB_CFG_HIGH 0x8C
+
+#define F10_ONLINE_SPARE 0xB0
+#define F10_ONLINE_SPARE_SWAPDONE0(x) ((x) & BIT(1))
+#define F10_ONLINE_SPARE_SWAPDONE1(x) ((x) & BIT(3))
+#define F10_ONLINE_SPARE_BADDRAM_CS0(x) (((x) >> 4) & 0x00000007)
+#define F10_ONLINE_SPARE_BADDRAM_CS1(x) (((x) >> 8) & 0x00000007)
+
+#define F10_NB_ARRAY_ADDR 0xB8
+
+#define F10_NB_ARRAY_DRAM_ECC 0x80000000
+
+/* Bits [2:1] are used to select 16-byte section within a 64-byte cacheline */
+#define SET_NB_ARRAY_ADDRESS(section) (((section) & 0x3) << 1)
+
+#define F10_NB_ARRAY_DATA 0xBC
+
+#define SET_NB_DRAM_INJECTION_WRITE(word, bits) \
+ (BIT(((word) & 0xF) + 20) | \
+ BIT(17) | \
+ ((bits) & 0xF))
+
+#define SET_NB_DRAM_INJECTION_READ(word, bits) \
+ (BIT(((word) & 0xF) + 20) | \
+ BIT(16) | \
+ ((bits) & 0xF))
+
+#define K8_NBCAP 0xE8
+#define K8_NBCAP_CORES (BIT(12)|BIT(13))
+#define K8_NBCAP_CHIPKILL BIT(4)
+#define K8_NBCAP_SECDED BIT(3)
+#define K8_NBCAP_8_NODE BIT(2)
+#define K8_NBCAP_DUAL_NODE BIT(1)
+#define K8_NBCAP_DCT_DUAL BIT(0)
+
+/*
+ * MSR Regs
+ */
+#define K8_MSR_MCGCTL 0x017b
+#define K8_MSR_MCGCTL_NBE BIT(4)
+
+#define K8_MSR_MC4CTL 0x0410
+#define K8_MSR_MC4STAT 0x0411
+#define K8_MSR_MC4ADDR 0x0412
+
+/*
+ * popcnt - count the set bits in a bit vector.
+ * @vec - bit vector
+ *
+ * This instruction is supported only on F10h and later CPUs.
+ */
+#define popcnt(x) \
+({ \
+ typeof(x) __ret; \
+ __asm__("popcnt %1, %0" : "=r" (__ret) : "r" (x)); \
+ __ret; \
+})
+
+/* AMD sets the first MC device at device ID 0x18. */
+static inline int get_mc_node_id_from_pdev(struct pci_dev *pdev)
+{
+ return PCI_SLOT(pdev->devfn) - 0x18;
+}
+
+enum amd64_chipset_families {
+ K8_CPUS = 0,
+ F10_CPUS,
+ F11_CPUS,
+};
+
+/*
+ * Structure to hold:
+ *
+ * 1) dynamically read status and error address HW registers
+ * 2) sysfs entered values
+ * 3) MCE values
+ *
+ * Depends on entry into the modules
+ */
+struct amd64_error_info_regs {
+ u32 nbcfg;
+ u32 nbsh;
+ u32 nbsl;
+ u32 nbeah;
+ u32 nbeal;
+};
+
+/* Error injection control structure */
+struct error_injection {
+ u32 section;
+ u32 word;
+ u32 bit_map;
+};
+
+struct amd64_pvt {
+ /* pci_device handles which we utilize */
+ struct pci_dev *addr_f1_ctl;
+ struct pci_dev *dram_f2_ctl;
+ struct pci_dev *misc_f3_ctl;
+
+ int mc_node_id; /* MC index of this MC node */
+ int ext_model; /* extended model value of this node */
+
+ struct low_ops *ops; /* pointer to per PCI Device ID func table */
+
+ int channel_count;
+
+ /* Raw registers */
+ u32 dclr0; /* DRAM Configuration Low DCT0 reg */
+ u32 dclr1; /* DRAM Configuration Low DCT1 reg */
+ u32 dchr0; /* DRAM Configuration High DCT0 reg */
+ u32 dchr1; /* DRAM Configuration High DCT1 reg */
+ u32 nbcap; /* North Bridge Capabilities */
+ u32 nbcfg; /* F10 North Bridge Configuration */
+ u32 ext_nbcfg; /* Extended F10 North Bridge Configuration */
+ u32 dhar; /* DRAM Hoist reg */
+ u32 dbam0; /* DRAM Base Address Mapping reg for DCT0 */
+ u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */
+
+ /* DRAM CS Base Address Registers F2x[1,0][5C:40] */
+ u32 dcsb0[CHIPSELECT_COUNT];
+ u32 dcsb1[CHIPSELECT_COUNT];
+
+ /* DRAM CS Mask Registers F2x[1,0][6C:60] */
+ u32 dcsm0[CHIPSELECT_COUNT];
+ u32 dcsm1[CHIPSELECT_COUNT];
+
+ /*
+ * Decoded parts of DRAM BASE and LIMIT Registers
+ * F1x[78,70,68,60,58,50,48,40]
+ */
+ u64 dram_base[DRAM_REG_COUNT];
+ u64 dram_limit[DRAM_REG_COUNT];
+ u8 dram_IntlvSel[DRAM_REG_COUNT];
+ u8 dram_IntlvEn[DRAM_REG_COUNT];
+ u8 dram_DstNode[DRAM_REG_COUNT];
+ u8 dram_rw_en[DRAM_REG_COUNT];
+
+ /*
+ * The following fields are set at (load) run time, after CPU revision
+ * has been determined, since the dct_base and dct_mask registers vary
+ * based on revision
+ */
+ u32 dcsb_base; /* DCSB base bits */
+ u32 dcsm_mask; /* DCSM mask bits */
+ u32 num_dcsm; /* Number of DCSM registers */
+ u32 dcs_mask_notused; /* DCSM notused mask bits */
+ u32 dcs_shift; /* DCSB and DCSM shift value */
+
+ u64 top_mem; /* top of memory below 4GB */
+ u64 top_mem2; /* top of memory above 4GB */
+
+ u32 dram_ctl_select_low; /* DRAM Controller Select Low Reg */
+ u32 dram_ctl_select_high; /* DRAM Controller Select High Reg */
+ u32 online_spare; /* On-Line spare Reg */
+
+ /* temp storage for when input is received from sysfs */
+ struct amd64_error_info_regs ctl_error_info;
+
+ /* place to store error injection parameters prior to issue */
+ struct error_injection injection;
+
+ /* Save old hw registers' values before we modified them */
+ u32 nbctl_mcgctl_saved; /* When true, following 2 are valid */
+ u32 old_nbctl;
+ unsigned long old_mcgctl; /* per core on this node */
+
+ /* MC Type Index value: socket F vs Family 10h */
+ u32 mc_type_index;
+
+ /* misc settings */
+ struct flags {
+ unsigned long cf8_extcfg:1;
+ } flags;
+};
+
+struct scrubrate {
+ u32 scrubval; /* bit pattern for scrub rate */
+ u32 bandwidth; /* bandwidth consumed (bytes/sec) */
+};
+
+extern struct scrubrate scrubrates[23];
+extern u32 revf_quad_ddr2_shift[16];
+extern const char *tt_msgs[4];
+extern const char *ll_msgs[4];
+extern const char *rrrr_msgs[16];
+extern const char *to_msgs[2];
+extern const char *pp_msgs[4];
+extern const char *ii_msgs[4];
+extern const char *ext_msgs[32];
+extern const char *htlink_msgs[8];
+
+#ifdef CONFIG_EDAC_DEBUG
+#define NUM_DBG_ATTRS 9
+#else
+#define NUM_DBG_ATTRS 0
+#endif
+
+#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION
+#define NUM_INJ_ATTRS 5
+#else
+#define NUM_INJ_ATTRS 0
+#endif
+
+extern struct mcidev_sysfs_attribute amd64_dbg_attrs[NUM_DBG_ATTRS],
+ amd64_inj_attrs[NUM_INJ_ATTRS];
+
+/*
+ * Each of the PCI Device IDs types have their own set of hardware accessor
+ * functions and per device encoding/decoding logic.
+ */
+struct low_ops {
+ int (*probe_valid_hardware)(struct amd64_pvt *pvt);
+ int (*early_channel_count)(struct amd64_pvt *pvt);
+
+ u64 (*get_error_address)(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info);
+ void (*read_dram_base_limit)(struct amd64_pvt *pvt, int dram);
+ void (*read_dram_ctl_register)(struct amd64_pvt *pvt);
+ void (*map_sysaddr_to_csrow)(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info,
+ u64 SystemAddr);
+ int (*dbam_map_to_pages)(struct amd64_pvt *pvt, int dram_map);
+};
+
+struct amd64_family_type {
+ const char *ctl_name;
+ u16 addr_f1_ctl;
+ u16 misc_f3_ctl;
+ struct low_ops ops;
+};
+
+static struct amd64_family_type amd64_family_types[];
+
+static inline const char *get_amd_family_name(int index)
+{
+ return amd64_family_types[index].ctl_name;
+}
+
+static inline struct low_ops *family_ops(int index)
+{
+ return &amd64_family_types[index].ops;
+}
+
+/*
+ * For future CPU versions, verify the following as new 'slow' rates appear and
+ * modify the necessary skip values for the supported CPU.
+ */
+#define K8_MIN_SCRUB_RATE_BITS 0x0
+#define F10_MIN_SCRUB_RATE_BITS 0x5
+#define F11_MIN_SCRUB_RATE_BITS 0x6
+
+int amd64_process_error_info(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info,
+ int handle_errors);
+int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
+ u64 *hole_offset, u64 *hole_size);
diff --git a/drivers/edac/amd64_edac_dbg.c b/drivers/edac/amd64_edac_dbg.c
new file mode 100644
index 000000000000..0a41b248a4ad
--- /dev/null
+++ b/drivers/edac/amd64_edac_dbg.c
@@ -0,0 +1,255 @@
+#include "amd64_edac.h"
+
+/*
+ * accept a hex value and store it into the virtual error register file, field:
+ * nbeal and nbeah. Assume virtual error values have already been set for: NBSL,
+ * NBSH and NBCFG. Then proceed to map the error values to a MC, CSROW and
+ * CHANNEL
+ */
+static ssize_t amd64_nbea_store(struct mem_ctl_info *mci, const char *data,
+ size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long long value;
+ int ret = 0;
+
+ ret = strict_strtoull(data, 16, &value);
+ if (ret != -EINVAL) {
+ debugf0("received NBEA= 0x%llx\n", value);
+
+ /* place the value into the virtual error packet */
+ pvt->ctl_error_info.nbeal = (u32) value;
+ value >>= 32;
+ pvt->ctl_error_info.nbeah = (u32) value;
+
+ /* Process the Mapping request */
+ /* TODO: Add race prevention */
+ amd64_process_error_info(mci, &pvt->ctl_error_info, 1);
+
+ return count;
+ }
+ return ret;
+}
+
+/* display back what the last NBEA (MCA NB Address (MC4_ADDR)) was written */
+static ssize_t amd64_nbea_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u64 value;
+
+ value = pvt->ctl_error_info.nbeah;
+ value <<= 32;
+ value |= pvt->ctl_error_info.nbeal;
+
+ return sprintf(data, "%llx\n", value);
+}
+
+/* store the NBSL (MCA NB Status Low (MC4_STATUS)) value user desires */
+static ssize_t amd64_nbsl_store(struct mem_ctl_info *mci, const char *data,
+ size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 16, &value);
+ if (ret != -EINVAL) {
+ debugf0("received NBSL= 0x%lx\n", value);
+
+ pvt->ctl_error_info.nbsl = (u32) value;
+
+ return count;
+ }
+ return ret;
+}
+
+/* display back what the last NBSL value written */
+static ssize_t amd64_nbsl_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u32 value;
+
+ value = pvt->ctl_error_info.nbsl;
+
+ return sprintf(data, "%x\n", value);
+}
+
+/* store the NBSH (MCA NB Status High) value user desires */
+static ssize_t amd64_nbsh_store(struct mem_ctl_info *mci, const char *data,
+ size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 16, &value);
+ if (ret != -EINVAL) {
+ debugf0("received NBSH= 0x%lx\n", value);
+
+ pvt->ctl_error_info.nbsh = (u32) value;
+
+ return count;
+ }
+ return ret;
+}
+
+/* display back what the last NBSH value written */
+static ssize_t amd64_nbsh_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u32 value;
+
+ value = pvt->ctl_error_info.nbsh;
+
+ return sprintf(data, "%x\n", value);
+}
+
+/* accept and store the NBCFG (MCA NB Configuration) value user desires */
+static ssize_t amd64_nbcfg_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 16, &value);
+ if (ret != -EINVAL) {
+ debugf0("received NBCFG= 0x%lx\n", value);
+
+ pvt->ctl_error_info.nbcfg = (u32) value;
+
+ return count;
+ }
+ return ret;
+}
+
+/* various show routines for the controls of a MCI */
+static ssize_t amd64_nbcfg_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return sprintf(data, "%x\n", pvt->ctl_error_info.nbcfg);
+}
+
+
+static ssize_t amd64_dhar_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return sprintf(data, "%x\n", pvt->dhar);
+}
+
+
+static ssize_t amd64_dbam_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return sprintf(data, "%x\n", pvt->dbam0);
+}
+
+
+static ssize_t amd64_topmem_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return sprintf(data, "%llx\n", pvt->top_mem);
+}
+
+
+static ssize_t amd64_topmem2_show(struct mem_ctl_info *mci, char *data)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+
+ return sprintf(data, "%llx\n", pvt->top_mem2);
+}
+
+static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data)
+{
+ u64 hole_base = 0;
+ u64 hole_offset = 0;
+ u64 hole_size = 0;
+
+ amd64_get_dram_hole_info(mci, &hole_base, &hole_offset, &hole_size);
+
+ return sprintf(data, "%llx %llx %llx\n", hole_base, hole_offset,
+ hole_size);
+}
+
+/*
+ * update NUM_DBG_ATTRS in case you add new members
+ */
+struct mcidev_sysfs_attribute amd64_dbg_attrs[] = {
+
+ {
+ .attr = {
+ .name = "nbea_ctl",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = amd64_nbea_show,
+ .store = amd64_nbea_store,
+ },
+ {
+ .attr = {
+ .name = "nbsl_ctl",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = amd64_nbsl_show,
+ .store = amd64_nbsl_store,
+ },
+ {
+ .attr = {
+ .name = "nbsh_ctl",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = amd64_nbsh_show,
+ .store = amd64_nbsh_store,
+ },
+ {
+ .attr = {
+ .name = "nbcfg_ctl",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = amd64_nbcfg_show,
+ .store = amd64_nbcfg_store,
+ },
+ {
+ .attr = {
+ .name = "dhar",
+ .mode = (S_IRUGO)
+ },
+ .show = amd64_dhar_show,
+ .store = NULL,
+ },
+ {
+ .attr = {
+ .name = "dbam",
+ .mode = (S_IRUGO)
+ },
+ .show = amd64_dbam_show,
+ .store = NULL,
+ },
+ {
+ .attr = {
+ .name = "topmem",
+ .mode = (S_IRUGO)
+ },
+ .show = amd64_topmem_show,
+ .store = NULL,
+ },
+ {
+ .attr = {
+ .name = "topmem2",
+ .mode = (S_IRUGO)
+ },
+ .show = amd64_topmem2_show,
+ .store = NULL,
+ },
+ {
+ .attr = {
+ .name = "dram_hole",
+ .mode = (S_IRUGO)
+ },
+ .show = amd64_hole_show,
+ .store = NULL,
+ },
+};
diff --git a/drivers/edac/amd64_edac_err_types.c b/drivers/edac/amd64_edac_err_types.c
new file mode 100644
index 000000000000..f212ff12a9d8
--- /dev/null
+++ b/drivers/edac/amd64_edac_err_types.c
@@ -0,0 +1,161 @@
+#include "amd64_edac.h"
+
+/*
+ * See F2x80 for K8 and F2x[1,0]80 for Fam10 and later. The table below is only
+ * for DDR2 DRAM mapping.
+ */
+u32 revf_quad_ddr2_shift[] = {
+ 0, /* 0000b NULL DIMM (128mb) */
+ 28, /* 0001b 256mb */
+ 29, /* 0010b 512mb */
+ 29, /* 0011b 512mb */
+ 29, /* 0100b 512mb */
+ 30, /* 0101b 1gb */
+ 30, /* 0110b 1gb */
+ 31, /* 0111b 2gb */
+ 31, /* 1000b 2gb */
+ 32, /* 1001b 4gb */
+ 32, /* 1010b 4gb */
+ 33, /* 1011b 8gb */
+ 0, /* 1100b future */
+ 0, /* 1101b future */
+ 0, /* 1110b future */
+ 0 /* 1111b future */
+};
+
+/*
+ * Valid scrub rates for the K8 hardware memory scrubber. We map the scrubbing
+ * bandwidth to a valid bit pattern. The 'set' operation finds the 'matching-
+ * or higher value'.
+ *
+ *FIXME: Produce a better mapping/linearisation.
+ */
+
+struct scrubrate scrubrates[] = {
+ { 0x01, 1600000000UL},
+ { 0x02, 800000000UL},
+ { 0x03, 400000000UL},
+ { 0x04, 200000000UL},
+ { 0x05, 100000000UL},
+ { 0x06, 50000000UL},
+ { 0x07, 25000000UL},
+ { 0x08, 12284069UL},
+ { 0x09, 6274509UL},
+ { 0x0A, 3121951UL},
+ { 0x0B, 1560975UL},
+ { 0x0C, 781440UL},
+ { 0x0D, 390720UL},
+ { 0x0E, 195300UL},
+ { 0x0F, 97650UL},
+ { 0x10, 48854UL},
+ { 0x11, 24427UL},
+ { 0x12, 12213UL},
+ { 0x13, 6101UL},
+ { 0x14, 3051UL},
+ { 0x15, 1523UL},
+ { 0x16, 761UL},
+ { 0x00, 0UL}, /* scrubbing off */
+};
+
+/*
+ * string representation for the different MCA reported error types, see F3x48
+ * or MSR0000_0411.
+ */
+const char *tt_msgs[] = { /* transaction type */
+ "instruction",
+ "data",
+ "generic",
+ "reserved"
+};
+
+const char *ll_msgs[] = { /* cache level */
+ "L0",
+ "L1",
+ "L2",
+ "L3/generic"
+};
+
+const char *rrrr_msgs[] = {
+ "generic",
+ "generic read",
+ "generic write",
+ "data read",
+ "data write",
+ "inst fetch",
+ "prefetch",
+ "evict",
+ "snoop",
+ "reserved RRRR= 9",
+ "reserved RRRR= 10",
+ "reserved RRRR= 11",
+ "reserved RRRR= 12",
+ "reserved RRRR= 13",
+ "reserved RRRR= 14",
+ "reserved RRRR= 15"
+};
+
+const char *pp_msgs[] = { /* participating processor */
+ "local node originated (SRC)",
+ "local node responded to request (RES)",
+ "local node observed as 3rd party (OBS)",
+ "generic"
+};
+
+const char *to_msgs[] = {
+ "no timeout",
+ "timed out"
+};
+
+const char *ii_msgs[] = { /* memory or i/o */
+ "mem access",
+ "reserved",
+ "i/o access",
+ "generic"
+};
+
+/* Map the 5 bits of Extended Error code to the string table. */
+const char *ext_msgs[] = { /* extended error */
+ "K8 ECC error/F10 reserved", /* 0_0000b */
+ "CRC error", /* 0_0001b */
+ "sync error", /* 0_0010b */
+ "mst abort", /* 0_0011b */
+ "tgt abort", /* 0_0100b */
+ "GART error", /* 0_0101b */
+ "RMW error", /* 0_0110b */
+ "Wdog timer error", /* 0_0111b */
+ "F10-ECC/K8-Chipkill error", /* 0_1000b */
+ "DEV Error", /* 0_1001b */
+ "Link Data error", /* 0_1010b */
+ "Link or L3 Protocol error", /* 0_1011b */
+ "NB Array error", /* 0_1100b */
+ "DRAM Parity error", /* 0_1101b */
+ "Link Retry/GART Table Walk/DEV Table Walk error", /* 0_1110b */
+ "Res 0x0ff error", /* 0_1111b */
+ "Res 0x100 error", /* 1_0000b */
+ "Res 0x101 error", /* 1_0001b */
+ "Res 0x102 error", /* 1_0010b */
+ "Res 0x103 error", /* 1_0011b */
+ "Res 0x104 error", /* 1_0100b */
+ "Res 0x105 error", /* 1_0101b */
+ "Res 0x106 error", /* 1_0110b */
+ "Res 0x107 error", /* 1_0111b */
+ "Res 0x108 error", /* 1_1000b */
+ "Res 0x109 error", /* 1_1001b */
+ "Res 0x10A error", /* 1_1010b */
+ "Res 0x10B error", /* 1_1011b */
+ "L3 Cache Data error", /* 1_1100b */
+ "L3 CacheTag error", /* 1_1101b */
+ "L3 Cache LRU error", /* 1_1110b */
+ "Res 0x1FF error" /* 1_1111b */
+};
+
+const char *htlink_msgs[] = {
+ "none",
+ "1",
+ "2",
+ "1 2",
+ "3",
+ "1 3",
+ "2 3",
+ "1 2 3"
+};
diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
new file mode 100644
index 000000000000..d3675b76b3a7
--- /dev/null
+++ b/drivers/edac/amd64_edac_inj.c
@@ -0,0 +1,185 @@
+#include "amd64_edac.h"
+
+/*
+ * store error injection section value which refers to one of 4 16-byte sections
+ * within a 64-byte cacheline
+ *
+ * range: 0..3
+ */
+static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 10, &value);
+ if (ret != -EINVAL) {
+ pvt->injection.section = (u32) value;
+ return count;
+ }
+ return ret;
+}
+
+/*
+ * store error injection word value which refers to one of 9 16-bit word of the
+ * 16-byte (128-bit + ECC bits) section
+ *
+ * range: 0..8
+ */
+static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 10, &value);
+ if (ret != -EINVAL) {
+
+ value = (value <= 8) ? value : 0;
+ pvt->injection.word = (u32) value;
+
+ return count;
+ }
+ return ret;
+}
+
+/*
+ * store 16 bit error injection vector which enables injecting errors to the
+ * corresponding bit within the error injection word above. When used during a
+ * DRAM ECC read, it holds the contents of the of the DRAM ECC bits.
+ */
+static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 16, &value);
+ if (ret != -EINVAL) {
+
+ pvt->injection.bit_map = (u32) value & 0xFFFF;
+
+ return count;
+ }
+ return ret;
+}
+
+/*
+ * Do a DRAM ECC read. Assemble staged values in the pvt area, format into
+ * fields needed by the injection registers and read the NB Array Data Port.
+ */
+static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ u32 section, word_bits;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 10, &value);
+ if (ret != -EINVAL) {
+
+ /* Form value to choose 16-byte section of cacheline */
+ section = F10_NB_ARRAY_DRAM_ECC |
+ SET_NB_ARRAY_ADDRESS(pvt->injection.section);
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_ADDR, section);
+
+ word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
+ pvt->injection.bit_map);
+
+ /* Issue 'word' and 'bit' along with the READ request */
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_DATA, word_bits);
+
+ debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
+
+ return count;
+ }
+ return ret;
+}
+
+/*
+ * Do a DRAM ECC write. Assemble staged values in the pvt area and format into
+ * fields needed by the injection registers.
+ */
+static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ u32 section, word_bits;
+ int ret = 0;
+
+ ret = strict_strtoul(data, 10, &value);
+ if (ret != -EINVAL) {
+
+ /* Form value to choose 16-byte section of cacheline */
+ section = F10_NB_ARRAY_DRAM_ECC |
+ SET_NB_ARRAY_ADDRESS(pvt->injection.section);
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_ADDR, section);
+
+ word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
+ pvt->injection.bit_map);
+
+ /* Issue 'word' and 'bit' along with the READ request */
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_DATA, word_bits);
+
+ debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
+
+ return count;
+ }
+ return ret;
+}
+
+/*
+ * update NUM_INJ_ATTRS in case you add new members
+ */
+struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
+
+ {
+ .attr = {
+ .name = "inject_section",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_section_store,
+ },
+ {
+ .attr = {
+ .name = "inject_word",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_word_store,
+ },
+ {
+ .attr = {
+ .name = "inject_ecc_vector",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_ecc_vector_store,
+ },
+ {
+ .attr = {
+ .name = "inject_write",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_write_store,
+ },
+ {
+ .attr = {
+ .name = "inject_read",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_read_store,
+ },
+};
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index facfdb1fa71c..d205d493a68a 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -1084,7 +1084,7 @@ static void e752x_init_sysbus_parity_mask(struct e752x_pvt *pvt)
struct pci_dev *dev = pvt->dev_d0f1;
int enable = 1;
- /* Allow module paramter override, else see if CPU supports parity */
+ /* Allow module parameter override, else see if CPU supports parity */
if (sysbus_parity != -1) {
enable = sysbus_parity;
} else if (cpu_id[0] &&
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 6ad95c8d6363..48d3b1409834 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -76,10 +76,11 @@
extern int edac_debug_level;
#ifndef CONFIG_EDAC_DEBUG_VERBOSE
-#define edac_debug_printk(level, fmt, arg...) \
- do { \
- if (level <= edac_debug_level) \
- edac_printk(KERN_DEBUG, EDAC_DEBUG, fmt, ##arg); \
+#define edac_debug_printk(level, fmt, arg...) \
+ do { \
+ if (level <= edac_debug_level) \
+ edac_printk(KERN_DEBUG, EDAC_DEBUG, \
+ "%s: " fmt, __func__, ##arg); \
} while (0)
#else /* CONFIG_EDAC_DEBUG_VERBOSE */
#define edac_debug_printk(level, fmt, arg...) \
diff --git a/drivers/eisa/pci_eisa.c b/drivers/eisa/pci_eisa.c
index 74edb1d0110f..0dd0f633b18d 100644
--- a/drivers/eisa/pci_eisa.c
+++ b/drivers/eisa/pci_eisa.c
@@ -31,11 +31,11 @@ static int __init pci_eisa_init(struct pci_dev *pdev,
}
pci_eisa_root.dev = &pdev->dev;
- pci_eisa_root.dev->driver_data = &pci_eisa_root;
pci_eisa_root.res = pdev->bus->resource[0];
pci_eisa_root.bus_base_addr = pdev->bus->resource[0]->start;
pci_eisa_root.slots = EISA_MAX_SLOTS;
pci_eisa_root.dma_mask = pdev->dma_mask;
+ dev_set_drvdata(pci_eisa_root.dev, &pci_eisa_root);
if (eisa_root_register (&pci_eisa_root)) {
printk (KERN_ERR "pci_eisa : Could not register EISA root\n");
diff --git a/drivers/eisa/virtual_root.c b/drivers/eisa/virtual_root.c
index 3074879f231f..535e4f9c83f4 100644
--- a/drivers/eisa/virtual_root.c
+++ b/drivers/eisa/virtual_root.c
@@ -57,7 +57,7 @@ static int __init virtual_eisa_root_init (void)
eisa_bus_root.force_probe = force_probe;
- eisa_root_dev.dev.driver_data = &eisa_bus_root;
+ dev_set_drvdata(&eisa_root_dev.dev, &eisa_bus_root);
if (eisa_root_register (&eisa_bus_root)) {
/* A real bridge may have been registered before
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 7eb6594cc3e5..8a5e6ae2552c 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -739,15 +739,11 @@ static void release_descriptor(struct client *client,
static int ioctl_add_descriptor(struct client *client, void *buffer)
{
struct fw_cdev_add_descriptor *request = buffer;
- struct fw_card *card = client->device->card;
struct descriptor_resource *r;
int ret;
/* Access policy: Allow this ioctl only on local nodes' device files. */
- spin_lock_irq(&card->lock);
- ret = client->device->node_id != card->local_node->node_id;
- spin_unlock_irq(&card->lock);
- if (ret)
+ if (!client->device->is_local)
return -ENOSYS;
if (request->length > 256)
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index a47e2129d83d..a38a68b97b58 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -1042,6 +1042,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
device->node = fw_node_get(node);
device->node_id = node->node_id;
device->generation = card->generation;
+ device->is_local = node == card->local_node;
mutex_init(&device->client_list_mutex);
INIT_LIST_HEAD(&device->client_list);
@@ -1075,7 +1076,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
FW_DEVICE_INITIALIZING) == FW_DEVICE_RUNNING) {
PREPARE_DELAYED_WORK(&device->work, fw_device_refresh);
schedule_delayed_work(&device->work,
- node == card->local_node ? 0 : INITIAL_DELAY);
+ device->is_local ? 0 : INITIAL_DELAY);
}
break;
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index 97588937c018..623cfee289bd 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -80,6 +80,7 @@ struct fw_device {
u32 *config_rom;
size_t config_rom_length;
int config_rom_retries;
+ unsigned is_local:1;
unsigned cmc:1;
unsigned bc_implemented:2;
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 2bcf51557c72..a70e66e78c7b 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -1125,7 +1125,7 @@ static int sbp2_probe(struct device *dev)
return -ENOMEM;
tgt = (struct sbp2_target *)shost->hostdata;
- unit->device.driver_data = tgt;
+ dev_set_drvdata(&unit->device, tgt);
tgt->unit = unit;
kref_init(&tgt->kref);
INIT_LIST_HEAD(&tgt->lu_list);
@@ -1180,7 +1180,7 @@ static int sbp2_probe(struct device *dev)
static int sbp2_remove(struct device *dev)
{
struct fw_unit *unit = fw_unit(dev);
- struct sbp2_target *tgt = unit->device.driver_data;
+ struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
sbp2_target_put(tgt);
return 0;
@@ -1240,7 +1240,7 @@ static void sbp2_reconnect(struct work_struct *work)
static void sbp2_update(struct fw_unit *unit)
{
- struct sbp2_target *tgt = unit->device.driver_data;
+ struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
struct sbp2_logical_unit *lu;
fw_device_enable_phys_dma(fw_device(unit->device.parent));
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 18d65fb42ee7..e8727817c8b5 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -237,6 +237,23 @@ static ssize_t host_control_on_shutdown_store(struct device *dev,
return count;
}
+static long generate_smi(void *_smi_cmd)
+{
+ struct smi_cmd *smi_cmd = _smi_cmd;
+
+ /* generate SMI */
+ asm volatile (
+ "outb %b0,%w1"
+ : /* no output args */
+ : "a" (smi_cmd->command_code),
+ "d" (smi_cmd->command_address),
+ "b" (smi_cmd->ebx),
+ "c" (smi_cmd->ecx)
+ : "memory"
+ );
+ return 0;
+}
+
/**
* dcdbas_smi_request: generate SMI request
*
@@ -244,9 +261,6 @@ static ssize_t host_control_on_shutdown_store(struct device *dev,
*/
int dcdbas_smi_request(struct smi_cmd *smi_cmd)
{
- cpumask_var_t old_mask;
- int ret = 0;
-
if (smi_cmd->magic != SMI_CMD_MAGIC) {
dev_info(&dcdbas_pdev->dev, "%s: invalid magic value\n",
__func__);
@@ -254,35 +268,8 @@ int dcdbas_smi_request(struct smi_cmd *smi_cmd)
}
/* SMI requires CPU 0 */
- if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
- return -ENOMEM;
-
- cpumask_copy(old_mask, &current->cpus_allowed);
- set_cpus_allowed_ptr(current, cpumask_of(0));
- if (smp_processor_id() != 0) {
- dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
- __func__);
- ret = -EBUSY;
- goto out;
- }
-
- /* generate SMI */
- asm volatile (
- "outb %b0,%w1"
- : /* no output args */
- : "a" (smi_cmd->command_code),
- "d" (smi_cmd->command_address),
- "b" (smi_cmd->ebx),
- "c" (smi_cmd->ecx)
- : "memory"
- );
-
-out:
- set_cpus_allowed_ptr(current, old_mask);
- free_cpumask_var(old_mask);
- return ret;
+ return work_on_cpu(0, generate_smi, smi_cmd);
}
-
/**
* smi_request_store:
*
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c
index 58e9f8e457f8..51e0e2d8fac6 100644
--- a/drivers/firmware/pcdp.c
+++ b/drivers/firmware/pcdp.c
@@ -28,10 +28,10 @@ setup_serial_console(struct pcdp_uart *uart)
char parity;
mmio = (uart->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
- p += sprintf(p, "uart8250,%s,0x%lx",
+ p += sprintf(p, "uart8250,%s,0x%llx",
mmio ? "mmio" : "io", uart->addr.address);
if (uart->baud) {
- p += sprintf(p, ",%lu", uart->baud);
+ p += sprintf(p, ",%llu", uart->baud);
if (uart->bits) {
switch (uart->parity) {
case 0x2: parity = 'e'; break;
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 8f9372921f82..caeae240d0bd 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -70,6 +70,11 @@ static ssize_t version_show(struct class *dev, char *buf)
CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
}
+static char *drm_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
+}
+
static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
/**
@@ -101,6 +106,8 @@ struct class *drm_sysfs_create(struct module *owner, char *name)
if (err)
goto err_out_class;
+ class->nodename = drm_nodename;
+
return class;
err_out_class:
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 9b149fe824c3..c431fa54bbb5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -180,7 +180,8 @@ typedef struct drm_i915_private {
int backlight_duty_cycle; /* restore backlight to this value */
bool panel_wants_dither;
struct drm_display_mode *panel_fixed_mode;
- struct drm_display_mode *vbt_mode; /* if any */
+ struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
+ struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
/* Feature bits from the VBIOS */
unsigned int int_tv_support:1;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b189b49c7602..717b6a854bcd 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -349,7 +349,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev, struct drm_gem_object *obj,
last_data_page = (data_ptr + args->size - 1) / PAGE_SIZE;
num_pages = last_data_page - first_data_page + 1;
- user_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
+ user_pages = drm_calloc_large(num_pages, sizeof(struct page *));
if (user_pages == NULL)
return -ENOMEM;
@@ -429,7 +429,7 @@ fail_put_user_pages:
SetPageDirty(user_pages[i]);
page_cache_release(user_pages[i]);
}
- kfree(user_pages);
+ drm_free_large(user_pages);
return ret;
}
@@ -649,7 +649,7 @@ i915_gem_gtt_pwrite_slow(struct drm_device *dev, struct drm_gem_object *obj,
last_data_page = (data_ptr + args->size - 1) / PAGE_SIZE;
num_pages = last_data_page - first_data_page + 1;
- user_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
+ user_pages = drm_calloc_large(num_pages, sizeof(struct page *));
if (user_pages == NULL)
return -ENOMEM;
@@ -719,7 +719,7 @@ out_unlock:
out_unpin_pages:
for (i = 0; i < pinned_pages; i++)
page_cache_release(user_pages[i]);
- kfree(user_pages);
+ drm_free_large(user_pages);
return ret;
}
@@ -824,7 +824,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev, struct drm_gem_object *obj,
last_data_page = (data_ptr + args->size - 1) / PAGE_SIZE;
num_pages = last_data_page - first_data_page + 1;
- user_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
+ user_pages = drm_calloc_large(num_pages, sizeof(struct page *));
if (user_pages == NULL)
return -ENOMEM;
@@ -902,7 +902,7 @@ fail_unlock:
fail_put_user_pages:
for (i = 0; i < pinned_pages; i++)
page_cache_release(user_pages[i]);
- kfree(user_pages);
+ drm_free_large(user_pages);
return ret;
}
@@ -1145,7 +1145,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
mutex_unlock(&dev->struct_mutex);
return VM_FAULT_SIGBUS;
}
- list_add(&obj_priv->list, &dev_priv->mm.inactive_list);
+ list_add_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
}
/* Need a new fence register? */
@@ -1375,7 +1375,7 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
mutex_unlock(&dev->struct_mutex);
return ret;
}
- list_add(&obj_priv->list, &dev_priv->mm.inactive_list);
+ list_add_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
}
drm_gem_object_unreference(obj);
@@ -1408,9 +1408,7 @@ i915_gem_object_put_pages(struct drm_gem_object *obj)
}
obj_priv->dirty = 0;
- drm_free(obj_priv->pages,
- page_count * sizeof(struct page *),
- DRM_MEM_DRIVER);
+ drm_free_large(obj_priv->pages);
obj_priv->pages = NULL;
}
@@ -2024,8 +2022,7 @@ i915_gem_object_get_pages(struct drm_gem_object *obj)
*/
page_count = obj->size / PAGE_SIZE;
BUG_ON(obj_priv->pages != NULL);
- obj_priv->pages = drm_calloc(page_count, sizeof(struct page *),
- DRM_MEM_DRIVER);
+ obj_priv->pages = drm_calloc_large(page_count, sizeof(struct page *));
if (obj_priv->pages == NULL) {
DRM_ERROR("Faled to allocate page list\n");
obj_priv->pages_refcount--;
@@ -3111,7 +3108,7 @@ i915_gem_get_relocs_from_user(struct drm_i915_gem_exec_object *exec_list,
reloc_count += exec_list[i].relocation_count;
}
- *relocs = drm_calloc(reloc_count, sizeof(**relocs), DRM_MEM_DRIVER);
+ *relocs = drm_calloc_large(reloc_count, sizeof(**relocs));
if (*relocs == NULL)
return -ENOMEM;
@@ -3125,8 +3122,7 @@ i915_gem_get_relocs_from_user(struct drm_i915_gem_exec_object *exec_list,
exec_list[i].relocation_count *
sizeof(**relocs));
if (ret != 0) {
- drm_free(*relocs, reloc_count * sizeof(**relocs),
- DRM_MEM_DRIVER);
+ drm_free_large(*relocs);
*relocs = NULL;
return -EFAULT;
}
@@ -3165,7 +3161,7 @@ i915_gem_put_relocs_to_user(struct drm_i915_gem_exec_object *exec_list,
}
err:
- drm_free(relocs, reloc_count * sizeof(*relocs), DRM_MEM_DRIVER);
+ drm_free_large(relocs);
return ret;
}
@@ -3198,10 +3194,8 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
return -EINVAL;
}
/* Copy in the exec list from userland */
- exec_list = drm_calloc(sizeof(*exec_list), args->buffer_count,
- DRM_MEM_DRIVER);
- object_list = drm_calloc(sizeof(*object_list), args->buffer_count,
- DRM_MEM_DRIVER);
+ exec_list = drm_calloc_large(sizeof(*exec_list), args->buffer_count);
+ object_list = drm_calloc_large(sizeof(*object_list), args->buffer_count);
if (exec_list == NULL || object_list == NULL) {
DRM_ERROR("Failed to allocate exec or object list "
"for %d buffers\n",
@@ -3462,10 +3456,8 @@ err:
}
pre_mutex_err:
- drm_free(object_list, sizeof(*object_list) * args->buffer_count,
- DRM_MEM_DRIVER);
- drm_free(exec_list, sizeof(*exec_list) * args->buffer_count,
- DRM_MEM_DRIVER);
+ drm_free_large(object_list);
+ drm_free_large(exec_list);
drm_free(cliprects, sizeof(*cliprects) * args->num_cliprects,
DRM_MEM_DRIVER);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 15da44cf21b1..9668cc0d7f4e 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1410,9 +1410,25 @@
/* Cursor A & B regs */
#define CURACNTR 0x70080
+/* Old style CUR*CNTR flags (desktop 8xx) */
+#define CURSOR_ENABLE 0x80000000
+#define CURSOR_GAMMA_ENABLE 0x40000000
+#define CURSOR_STRIDE_MASK 0x30000000
+#define CURSOR_FORMAT_SHIFT 24
+#define CURSOR_FORMAT_MASK (0x07 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_2C (0x00 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_3C (0x01 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_4C (0x02 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_ARGB (0x04 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_XRGB (0x05 << CURSOR_FORMAT_SHIFT)
+/* New style CUR*CNTR flags */
+#define CURSOR_MODE 0x27
#define CURSOR_MODE_DISABLE 0x00
#define CURSOR_MODE_64_32B_AX 0x07
#define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX)
+#define MCURSOR_PIPE_SELECT (1 << 28)
+#define MCURSOR_PIPE_A 0x00
+#define MCURSOR_PIPE_B (1 << 28)
#define MCURSOR_GAMMA_ENABLE (1 << 26)
#define CURABASE 0x70084
#define CURAPOS 0x70088
@@ -1420,6 +1436,7 @@
#define CURSOR_POS_SIGN 0x8000
#define CURSOR_X_SHIFT 0
#define CURSOR_Y_SHIFT 16
+#define CURSIZE 0x700a0
#define CURBCNTR 0x700c0
#define CURBBASE 0x700c4
#define CURBPOS 0x700c8
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index fc28e2bbd542..9d78cff33b24 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -57,9 +57,43 @@ find_section(struct bdb_header *bdb, int section_id)
return NULL;
}
-/* Try to find panel data */
static void
-parse_panel_data(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
+ struct lvds_dvo_timing *dvo_timing)
+{
+ panel_fixed_mode->hdisplay = (dvo_timing->hactive_hi << 8) |
+ dvo_timing->hactive_lo;
+ panel_fixed_mode->hsync_start = panel_fixed_mode->hdisplay +
+ ((dvo_timing->hsync_off_hi << 8) | dvo_timing->hsync_off_lo);
+ panel_fixed_mode->hsync_end = panel_fixed_mode->hsync_start +
+ dvo_timing->hsync_pulse_width;
+ panel_fixed_mode->htotal = panel_fixed_mode->hdisplay +
+ ((dvo_timing->hblank_hi << 8) | dvo_timing->hblank_lo);
+
+ panel_fixed_mode->vdisplay = (dvo_timing->vactive_hi << 8) |
+ dvo_timing->vactive_lo;
+ panel_fixed_mode->vsync_start = panel_fixed_mode->vdisplay +
+ dvo_timing->vsync_off;
+ panel_fixed_mode->vsync_end = panel_fixed_mode->vsync_start +
+ dvo_timing->vsync_pulse_width;
+ panel_fixed_mode->vtotal = panel_fixed_mode->vdisplay +
+ ((dvo_timing->vblank_hi << 8) | dvo_timing->vblank_lo);
+ panel_fixed_mode->clock = dvo_timing->clock * 10;
+ panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED;
+
+ /* Some VBTs have bogus h/vtotal values */
+ if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal)
+ panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1;
+ if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal)
+ panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1;
+
+ drm_mode_set_name(panel_fixed_mode);
+}
+
+/* Try to find integrated panel data */
+static void
+parse_lfp_panel_data(struct drm_i915_private *dev_priv,
+ struct bdb_header *bdb)
{
struct bdb_lvds_options *lvds_options;
struct bdb_lvds_lfp_data *lvds_lfp_data;
@@ -91,38 +125,45 @@ parse_panel_data(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode),
DRM_MEM_DRIVER);
- panel_fixed_mode->hdisplay = (dvo_timing->hactive_hi << 8) |
- dvo_timing->hactive_lo;
- panel_fixed_mode->hsync_start = panel_fixed_mode->hdisplay +
- ((dvo_timing->hsync_off_hi << 8) | dvo_timing->hsync_off_lo);
- panel_fixed_mode->hsync_end = panel_fixed_mode->hsync_start +
- dvo_timing->hsync_pulse_width;
- panel_fixed_mode->htotal = panel_fixed_mode->hdisplay +
- ((dvo_timing->hblank_hi << 8) | dvo_timing->hblank_lo);
+ fill_detail_timing_data(panel_fixed_mode, dvo_timing);
- panel_fixed_mode->vdisplay = (dvo_timing->vactive_hi << 8) |
- dvo_timing->vactive_lo;
- panel_fixed_mode->vsync_start = panel_fixed_mode->vdisplay +
- dvo_timing->vsync_off;
- panel_fixed_mode->vsync_end = panel_fixed_mode->vsync_start +
- dvo_timing->vsync_pulse_width;
- panel_fixed_mode->vtotal = panel_fixed_mode->vdisplay +
- ((dvo_timing->vblank_hi << 8) | dvo_timing->vblank_lo);
- panel_fixed_mode->clock = dvo_timing->clock * 10;
- panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED;
+ dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
- /* Some VBTs have bogus h/vtotal values */
- if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal)
- panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1;
- if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal)
- panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1;
+ DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
+ drm_mode_debug_printmodeline(panel_fixed_mode);
- drm_mode_set_name(panel_fixed_mode);
+ return;
+}
+
+/* Try to find sdvo panel data */
+static void
+parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
+ struct bdb_header *bdb)
+{
+ struct bdb_sdvo_lvds_options *sdvo_lvds_options;
+ struct lvds_dvo_timing *dvo_timing;
+ struct drm_display_mode *panel_fixed_mode;
- dev_priv->vbt_mode = panel_fixed_mode;
+ dev_priv->sdvo_lvds_vbt_mode = NULL;
- DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
- drm_mode_debug_printmodeline(panel_fixed_mode);
+ sdvo_lvds_options = find_section(bdb, BDB_SDVO_LVDS_OPTIONS);
+ if (!sdvo_lvds_options)
+ return;
+
+ dvo_timing = find_section(bdb, BDB_SDVO_PANEL_DTDS);
+ if (!dvo_timing)
+ return;
+
+ panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode),
+ DRM_MEM_DRIVER);
+
+ if (!panel_fixed_mode)
+ return;
+
+ fill_detail_timing_data(panel_fixed_mode,
+ dvo_timing + sdvo_lvds_options->panel_type);
+
+ dev_priv->sdvo_lvds_vbt_mode = panel_fixed_mode;
return;
}
@@ -199,7 +240,8 @@ intel_init_bios(struct drm_device *dev)
/* Grab useful general definitions */
parse_general_features(dev_priv, bdb);
- parse_panel_data(dev_priv, bdb);
+ parse_lfp_panel_data(dev_priv, bdb);
+ parse_sdvo_panel_data(dev_priv, bdb);
pci_unmap_rom(pdev, bios);
diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
index de621aad85b5..8ca2cde15804 100644
--- a/drivers/gpu/drm/i915/intel_bios.h
+++ b/drivers/gpu/drm/i915/intel_bios.h
@@ -279,6 +279,23 @@ struct vch_bdb_22 {
struct vch_panel_data panels[16];
} __attribute__((packed));
+struct bdb_sdvo_lvds_options {
+ u8 panel_backlight;
+ u8 h40_set_panel_type;
+ u8 panel_type;
+ u8 ssc_clk_freq;
+ u16 als_low_trip;
+ u16 als_high_trip;
+ u8 sclalarcoeff_tab_row_num;
+ u8 sclalarcoeff_tab_row_size;
+ u8 coefficient[8];
+ u8 panel_misc_bits_1;
+ u8 panel_misc_bits_2;
+ u8 panel_misc_bits_3;
+ u8 panel_misc_bits_4;
+} __attribute__((packed));
+
+
bool intel_init_bios(struct drm_device *dev);
/*
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 19148c3df637..640f5158effc 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -198,9 +198,142 @@ static bool intel_crt_detect_ddc(struct drm_connector *connector)
return intel_ddc_probe(intel_output);
}
+static enum drm_connector_status
+intel_crt_load_detect(struct drm_crtc *crtc, struct intel_output *intel_output)
+{
+ struct drm_encoder *encoder = &intel_output->enc;
+ struct drm_device *dev = encoder->dev;
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+ uint32_t pipe = intel_crtc->pipe;
+ uint32_t save_bclrpat;
+ uint32_t save_vtotal;
+ uint32_t vtotal, vactive;
+ uint32_t vsample;
+ uint32_t vblank, vblank_start, vblank_end;
+ uint32_t dsl;
+ uint32_t bclrpat_reg;
+ uint32_t vtotal_reg;
+ uint32_t vblank_reg;
+ uint32_t vsync_reg;
+ uint32_t pipeconf_reg;
+ uint32_t pipe_dsl_reg;
+ uint8_t st00;
+ enum drm_connector_status status;
+
+ if (pipe == 0) {
+ bclrpat_reg = BCLRPAT_A;
+ vtotal_reg = VTOTAL_A;
+ vblank_reg = VBLANK_A;
+ vsync_reg = VSYNC_A;
+ pipeconf_reg = PIPEACONF;
+ pipe_dsl_reg = PIPEADSL;
+ } else {
+ bclrpat_reg = BCLRPAT_B;
+ vtotal_reg = VTOTAL_B;
+ vblank_reg = VBLANK_B;
+ vsync_reg = VSYNC_B;
+ pipeconf_reg = PIPEBCONF;
+ pipe_dsl_reg = PIPEBDSL;
+ }
+
+ save_bclrpat = I915_READ(bclrpat_reg);
+ save_vtotal = I915_READ(vtotal_reg);
+ vblank = I915_READ(vblank_reg);
+
+ vtotal = ((save_vtotal >> 16) & 0xfff) + 1;
+ vactive = (save_vtotal & 0x7ff) + 1;
+
+ vblank_start = (vblank & 0xfff) + 1;
+ vblank_end = ((vblank >> 16) & 0xfff) + 1;
+
+ /* Set the border color to purple. */
+ I915_WRITE(bclrpat_reg, 0x500050);
+
+ if (IS_I9XX(dev)) {
+ uint32_t pipeconf = I915_READ(pipeconf_reg);
+ I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER);
+ /* Wait for next Vblank to substitue
+ * border color for Color info */
+ intel_wait_for_vblank(dev);
+ st00 = I915_READ8(VGA_MSR_WRITE);
+ status = ((st00 & (1 << 4)) != 0) ?
+ connector_status_connected :
+ connector_status_disconnected;
+
+ I915_WRITE(pipeconf_reg, pipeconf);
+ } else {
+ bool restore_vblank = false;
+ int count, detect;
+
+ /*
+ * If there isn't any border, add some.
+ * Yes, this will flicker
+ */
+ if (vblank_start <= vactive && vblank_end >= vtotal) {
+ uint32_t vsync = I915_READ(vsync_reg);
+ uint32_t vsync_start = (vsync & 0xffff) + 1;
+
+ vblank_start = vsync_start;
+ I915_WRITE(vblank_reg,
+ (vblank_start - 1) |
+ ((vblank_end - 1) << 16));
+ restore_vblank = true;
+ }
+ /* sample in the vertical border, selecting the larger one */
+ if (vblank_start - vactive >= vtotal - vblank_end)
+ vsample = (vblank_start + vactive) >> 1;
+ else
+ vsample = (vtotal + vblank_end) >> 1;
+
+ /*
+ * Wait for the border to be displayed
+ */
+ while (I915_READ(pipe_dsl_reg) >= vactive)
+ ;
+ while ((dsl = I915_READ(pipe_dsl_reg)) <= vsample)
+ ;
+ /*
+ * Watch ST00 for an entire scanline
+ */
+ detect = 0;
+ count = 0;
+ do {
+ count++;
+ /* Read the ST00 VGA status register */
+ st00 = I915_READ8(VGA_MSR_WRITE);
+ if (st00 & (1 << 4))
+ detect++;
+ } while ((I915_READ(pipe_dsl_reg) == dsl));
+
+ /* restore vblank if necessary */
+ if (restore_vblank)
+ I915_WRITE(vblank_reg, vblank);
+ /*
+ * If more than 3/4 of the scanline detected a monitor,
+ * then it is assumed to be present. This works even on i830,
+ * where there isn't any way to force the border color across
+ * the screen
+ */
+ status = detect * 4 > count * 3 ?
+ connector_status_connected :
+ connector_status_disconnected;
+ }
+
+ /* Restore previous settings */
+ I915_WRITE(bclrpat_reg, save_bclrpat);
+
+ return status;
+}
+
static enum drm_connector_status intel_crt_detect(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
+ struct intel_output *intel_output = to_intel_output(connector);
+ struct drm_encoder *encoder = &intel_output->enc;
+ struct drm_crtc *crtc;
+ int dpms_mode;
+ enum drm_connector_status status;
if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) {
if (intel_crt_detect_hotplug(connector))
@@ -212,8 +345,20 @@ static enum drm_connector_status intel_crt_detect(struct drm_connector *connecto
if (intel_crt_detect_ddc(connector))
return connector_status_connected;
- /* TODO use load detect */
- return connector_status_unknown;
+ /* for pre-945g platforms use load detect */
+ if (encoder->crtc && encoder->crtc->enabled) {
+ status = intel_crt_load_detect(encoder->crtc, intel_output);
+ } else {
+ crtc = intel_get_load_detect_pipe(intel_output,
+ NULL, &dpms_mode);
+ if (crtc) {
+ status = intel_crt_load_detect(crtc, intel_output);
+ intel_release_load_detect_pipe(intel_output, dpms_mode);
+ } else
+ status = connector_status_unknown;
+ }
+
+ return status;
}
static void intel_crt_destroy(struct drm_connector *connector)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3387cf32f385..c9d6f10ba92e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1357,7 +1357,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
int pipe = intel_crtc->pipe;
uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
- uint32_t temp;
+ uint32_t temp = I915_READ(control);
size_t addr;
int ret;
@@ -1366,7 +1366,12 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
/* if we want to turn off the cursor ignore width and height */
if (!handle) {
DRM_DEBUG("cursor off\n");
- temp = CURSOR_MODE_DISABLE;
+ if (IS_MOBILE(dev) || IS_I9XX(dev)) {
+ temp &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
+ temp |= CURSOR_MODE_DISABLE;
+ } else {
+ temp &= ~(CURSOR_ENABLE | CURSOR_GAMMA_ENABLE);
+ }
addr = 0;
bo = NULL;
mutex_lock(&dev->struct_mutex);
@@ -1409,10 +1414,19 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
addr = obj_priv->phys_obj->handle->busaddr;
}
- temp = 0;
- /* set the pipe for the cursor */
- temp |= (pipe << 28);
- temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
+ if (!IS_I9XX(dev))
+ I915_WRITE(CURSIZE, (height << 12) | width);
+
+ /* Hooray for CUR*CNTR differences */
+ if (IS_MOBILE(dev) || IS_I9XX(dev)) {
+ temp &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT);
+ temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
+ temp |= (pipe << 28); /* Connect to correct pipe */
+ } else {
+ temp &= ~(CURSOR_FORMAT_MASK);
+ temp |= CURSOR_ENABLE;
+ temp |= CURSOR_FORMAT_ARGB | CURSOR_GAMMA_ENABLE;
+ }
finish:
I915_WRITE(control, temp);
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 439a86514993..53731f0ffcb5 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -511,10 +511,10 @@ void intel_lvds_init(struct drm_device *dev)
}
/* Failed to get EDID, what about VBT? */
- if (dev_priv->vbt_mode) {
+ if (dev_priv->lfp_lvds_vbt_mode) {
mutex_lock(&dev->mode_config.mutex);
dev_priv->panel_fixed_mode =
- drm_mode_duplicate(dev, dev_priv->vbt_mode);
+ drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
mutex_unlock(&dev->mode_config.mutex);
if (dev_priv->panel_fixed_mode) {
dev_priv->panel_fixed_mode->type |=
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 9913651c1e17..f3ef6bfd8ffc 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -69,6 +69,10 @@ struct intel_sdvo_priv {
* This is set if we treat the device as HDMI, instead of DVI.
*/
bool is_hdmi;
+ /**
+ * This is set if we detect output of sdvo device as LVDS.
+ */
+ bool is_lvds;
/**
* Returned SDTV resolutions allowed for the current format, if the
@@ -1398,10 +1402,8 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
{
struct intel_output *intel_output = to_intel_output(connector);
- struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
/* set the bus switch and get the modes */
- intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
intel_ddc_get_modes(intel_output);
#if 0
@@ -1543,6 +1545,37 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
}
}
+static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
+{
+ struct intel_output *intel_output = to_intel_output(connector);
+ struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
+ struct drm_i915_private *dev_priv = connector->dev->dev_private;
+
+ /*
+ * Attempt to get the mode list from DDC.
+ * Assume that the preferred modes are
+ * arranged in priority order.
+ */
+ /* set the bus switch and get the modes */
+ intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
+ intel_ddc_get_modes(intel_output);
+ if (list_empty(&connector->probed_modes) == false)
+ return;
+
+ /* Fetch modes from VBT */
+ if (dev_priv->sdvo_lvds_vbt_mode != NULL) {
+ struct drm_display_mode *newmode;
+ newmode = drm_mode_duplicate(connector->dev,
+ dev_priv->sdvo_lvds_vbt_mode);
+ if (newmode != NULL) {
+ /* Guarantee the mode is preferred */
+ newmode->type = (DRM_MODE_TYPE_PREFERRED |
+ DRM_MODE_TYPE_DRIVER);
+ drm_mode_probed_add(connector, newmode);
+ }
+ }
+}
+
static int intel_sdvo_get_modes(struct drm_connector *connector)
{
struct intel_output *output = to_intel_output(connector);
@@ -1550,6 +1583,8 @@ static int intel_sdvo_get_modes(struct drm_connector *connector)
if (sdvo_priv->is_tv)
intel_sdvo_get_tv_modes(connector);
+ else if (sdvo_priv->is_lvds == true)
+ intel_sdvo_get_lvds_modes(connector);
else
intel_sdvo_get_ddc_modes(connector);
@@ -1564,6 +1599,9 @@ static void intel_sdvo_destroy(struct drm_connector *connector)
if (intel_output->i2c_bus)
intel_i2c_destroy(intel_output->i2c_bus);
+ if (intel_output->ddc_bus)
+ intel_i2c_destroy(intel_output->ddc_bus);
+
drm_sysfs_connector_remove(connector);
drm_connector_cleanup(connector);
kfree(intel_output);
@@ -1660,12 +1698,56 @@ intel_sdvo_get_digital_encoding_mode(struct intel_output *output)
return true;
}
+static struct intel_output *
+intel_sdvo_chan_to_intel_output(struct intel_i2c_chan *chan)
+{
+ struct drm_device *dev = chan->drm_dev;
+ struct drm_connector *connector;
+ struct intel_output *intel_output = NULL;
+
+ list_for_each_entry(connector,
+ &dev->mode_config.connector_list, head) {
+ if (to_intel_output(connector)->ddc_bus == chan) {
+ intel_output = to_intel_output(connector);
+ break;
+ }
+ }
+ return intel_output;
+}
+
+static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
+ struct i2c_msg msgs[], int num)
+{
+ struct intel_output *intel_output;
+ struct intel_sdvo_priv *sdvo_priv;
+ struct i2c_algo_bit_data *algo_data;
+ struct i2c_algorithm *algo;
+
+ algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data;
+ intel_output =
+ intel_sdvo_chan_to_intel_output(
+ (struct intel_i2c_chan *)(algo_data->data));
+ if (intel_output == NULL)
+ return -EINVAL;
+
+ sdvo_priv = intel_output->dev_priv;
+ algo = (struct i2c_algorithm *)intel_output->i2c_bus->adapter.algo;
+
+ intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
+ return algo->master_xfer(i2c_adap, msgs, num);
+}
+
+static struct i2c_algorithm intel_sdvo_i2c_bit_algo = {
+ .master_xfer = intel_sdvo_master_xfer,
+};
+
bool intel_sdvo_init(struct drm_device *dev, int output_device)
{
struct drm_connector *connector;
struct intel_output *intel_output;
struct intel_sdvo_priv *sdvo_priv;
struct intel_i2c_chan *i2cbus = NULL;
+ struct intel_i2c_chan *ddcbus = NULL;
int connector_type;
u8 ch[0x40];
int i;
@@ -1676,17 +1758,9 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
return false;
}
- connector = &intel_output->base;
-
- drm_connector_init(dev, connector, &intel_sdvo_connector_funcs,
- DRM_MODE_CONNECTOR_Unknown);
- drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs);
sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1);
intel_output->type = INTEL_OUTPUT_SDVO;
- connector->interlace_allowed = 0;
- connector->doublescan_allowed = 0;
-
/* setup the DDC bus. */
if (output_device == SDVOB)
i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB");
@@ -1694,7 +1768,7 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC");
if (!i2cbus)
- goto err_connector;
+ goto err_inteloutput;
sdvo_priv->i2c_bus = i2cbus;
@@ -1710,7 +1784,6 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
intel_output->i2c_bus = i2cbus;
intel_output->dev_priv = sdvo_priv;
-
/* Read the regs to test if we can talk to the device */
for (i = 0; i < 0x40; i++) {
if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) {
@@ -1720,6 +1793,22 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
}
}
+ /* setup the DDC bus. */
+ if (output_device == SDVOB)
+ ddcbus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS");
+ else
+ ddcbus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS");
+
+ if (ddcbus == NULL)
+ goto err_i2c;
+
+ intel_sdvo_i2c_bit_algo.functionality =
+ intel_output->i2c_bus->adapter.algo->functionality;
+ ddcbus->adapter.algo = &intel_sdvo_i2c_bit_algo;
+ intel_output->ddc_bus = ddcbus;
+
+ /* In defaut case sdvo lvds is false */
+ sdvo_priv->is_lvds = false;
intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps);
if (sdvo_priv->caps.output_flags &
@@ -1729,7 +1818,6 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
else
sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1;
- connector->display_info.subpixel_order = SubPixelHorizontalRGB;
encoder_type = DRM_MODE_ENCODER_TMDS;
connector_type = DRM_MODE_CONNECTOR_DVID;
@@ -1747,7 +1835,6 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0)
{
sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
- connector->display_info.subpixel_order = SubPixelHorizontalRGB;
encoder_type = DRM_MODE_ENCODER_TVDAC;
connector_type = DRM_MODE_CONNECTOR_SVIDEO;
sdvo_priv->is_tv = true;
@@ -1756,30 +1843,28 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0)
{
sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
- connector->display_info.subpixel_order = SubPixelHorizontalRGB;
encoder_type = DRM_MODE_ENCODER_DAC;
connector_type = DRM_MODE_CONNECTOR_VGA;
}
else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1)
{
sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
- connector->display_info.subpixel_order = SubPixelHorizontalRGB;
encoder_type = DRM_MODE_ENCODER_DAC;
connector_type = DRM_MODE_CONNECTOR_VGA;
}
else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0)
{
sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
- connector->display_info.subpixel_order = SubPixelHorizontalRGB;
encoder_type = DRM_MODE_ENCODER_LVDS;
connector_type = DRM_MODE_CONNECTOR_LVDS;
+ sdvo_priv->is_lvds = true;
}
else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1)
{
sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1;
- connector->display_info.subpixel_order = SubPixelHorizontalRGB;
encoder_type = DRM_MODE_ENCODER_LVDS;
connector_type = DRM_MODE_CONNECTOR_LVDS;
+ sdvo_priv->is_lvds = true;
}
else
{
@@ -1795,9 +1880,16 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
goto err_i2c;
}
+ connector = &intel_output->base;
+ drm_connector_init(dev, connector, &intel_sdvo_connector_funcs,
+ connector_type);
+ drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs);
+ connector->interlace_allowed = 0;
+ connector->doublescan_allowed = 0;
+ connector->display_info.subpixel_order = SubPixelHorizontalRGB;
+
drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type);
drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs);
- connector->connector_type = connector_type;
drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
drm_sysfs_connector_add(connector);
@@ -1829,14 +1921,13 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
sdvo_priv->caps.output_flags &
(SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
- intel_output->ddc_bus = i2cbus;
-
return true;
err_i2c:
+ if (ddcbus != NULL)
+ intel_i2c_destroy(intel_output->ddc_bus);
intel_i2c_destroy(intel_output->i2c_bus);
-err_connector:
- drm_connector_cleanup(connector);
+err_inteloutput:
kfree(intel_output);
return false;
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 7e67dcb3d4f6..7831a0318d3c 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -116,9 +116,16 @@ config HID_CYPRESS
---help---
Support for cypress mouse and barcode readers.
-config DRAGONRISE_FF
- tristate "DragonRise Inc. force feedback support"
+config HID_DRAGONRISE
+ tristate "DragonRise Inc. support" if EMBEDDED
depends on USB_HID
+ default !EMBEDDED
+ ---help---
+ Say Y here if you have DragonRise Inc.game controllers.
+
+config DRAGONRISE_FF
+ bool "DragonRise Inc. force feedback support"
+ depends on HID_DRAGONRISE
select INPUT_FF_MEMLESS
---help---
Say Y here if you want to enable force feedback support for DragonRise Inc.
@@ -160,7 +167,7 @@ config HID_LOGITECH
Support for Logitech devices that are not fully compliant with HID standard.
config LOGITECH_FF
- bool "Logitech force feedback"
+ bool "Logitech force feedback support"
depends on HID_LOGITECH
select INPUT_FF_MEMLESS
help
@@ -176,7 +183,7 @@ config LOGITECH_FF
force feedback.
config LOGIRUMBLEPAD2_FF
- bool "Logitech Rumblepad 2 force feedback"
+ bool "Logitech Rumblepad 2 force feedback support"
depends on HID_LOGITECH
select INPUT_FF_MEMLESS
help
@@ -211,11 +218,19 @@ config HID_PANTHERLORD
---help---
Support for PantherLord/GreenAsia based device support.
+config HID_PANTHERLORD
+ tristate "Pantherlord support" if EMBEDDED
+ depends on USB_HID
+ default !EMBEDDED
+ ---help---
+ Say Y here if you have a PantherLord/GreenAsia based game controller
+ or adapter.
+
config PANTHERLORD_FF
bool "Pantherlord force feedback support"
depends on HID_PANTHERLORD
select INPUT_FF_MEMLESS
- help
+ ---help---
Say Y here if you have a PantherLord/GreenAsia based game controller
or adapter and want to enable force feedback support for it.
@@ -247,15 +262,38 @@ config HID_SUNPLUS
---help---
Support for Sunplus wireless desktop.
-config GREENASIA_FF
- tristate "GreenAsia (Product ID 0x12) force feedback support"
+config HID_GREENASIA
+ tristate "GreenAsia (Product ID 0x12) support" if EMBEDDED
depends on USB_HID
+ default !EMBEDDED
+ ---help---
+ Say Y here if you have a GreenAsia (Product ID 0x12) based game
+ controller or adapter.
+
+config GREENASIA_FF
+ bool "GreenAsia (Product ID 0x12) force feedback support"
+ depends on HID_GREENASIA
select INPUT_FF_MEMLESS
---help---
Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
(like MANTA Warrior MM816 and SpeedLink Strike2 SL-6635) or adapter
and want to enable force feedback support for it.
+config HID_SMARTJOYPLUS
+ tristate "SmartJoy PLUS PS2/USB adapter support" if EMBEDDED
+ depends on USB_HID
+ default !EMBEDDED
+ ---help---
+ Support for SmartJoy PLUS PS2/USB adapter.
+
+config SMARTJOYPLUS_FF
+ bool "SmartJoy PLUS PS2/USB adapter force feedback support"
+ depends on HID_SMARTJOYPLUS
+ select INPUT_FF_MEMLESS
+ ---help---
+ Say Y here if you have a SmartJoy PLUS PS2/USB adapter and want to
+ enable force feedback support for it.
+
config HID_TOPSEED
tristate "TopSeed Cyberlink remote control support" if EMBEDDED
depends on USB_HID
@@ -263,21 +301,45 @@ config HID_TOPSEED
---help---
Say Y if you have a TopSeed Cyberlink remote control.
-config THRUSTMASTER_FF
- tristate "ThrustMaster devices support"
+config HID_THRUSTMASTER
+ tristate "ThrustMaster devices support" if EMBEDDED
depends on USB_HID
+ default !EMBEDDED
+ ---help---
+ Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
+ a THRUSTMASTER Ferrari GT Rumble Wheel.
+
+config THRUSTMASTER_FF
+ bool "ThrustMaster devices force feedback support"
+ depends on HID_THRUSTMASTER
select INPUT_FF_MEMLESS
- help
+ ---help---
Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
- a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel.
+ a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel and
+ want to enable force feedback support for it.
-config ZEROPLUS_FF
- tristate "Zeroplus based game controller support"
+config HID_WACOM
+ tristate "Wacom Bluetooth devices support" if EMBEDDED
+ depends on BT_HIDP
+ default !EMBEDDED
+ ---help---
+ Support for Wacom Graphire Bluetooth tablet.
+
+config HID_ZEROPLUS
+ tristate "Zeroplus based game controller support" if EMBEDDED
depends on USB_HID
- select INPUT_FF_MEMLESS
- help
+ default !EMBEDDED
+ ---help---
Say Y here if you have a Zeroplus based game controller.
+config ZEROPLUS_FF
+ bool "Zeroplus based game controller force feedback support"
+ depends on HID_ZEROPLUS
+ select INPUT_FF_MEMLESS
+ ---help---
+ Say Y here if you have a Zeroplus based game controller and want
+ to have force feedback support for it.
+
endmenu
endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 1f7cb0fd4505..db35151673b1 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
-obj-$(CONFIG_DRAGONRISE_FF) += hid-drff.o
+obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o
obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o
@@ -34,12 +34,14 @@ obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
+obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
obj-$(CONFIG_HID_SONY) += hid-sony.o
obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
-obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o
-obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
+obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o
+obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o
obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o
-obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o
+obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
+obj-$(CONFIG_HID_WACOM) += hid-wacom.o
obj-$(CONFIG_USB_HID) += usbhid/
obj-$(CONFIG_USB_MOUSE) += usbhid/
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 8551693d645f..f2c21d5d24e8 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1312,6 +1312,8 @@ static const struct hid_device_id hid_blacklist[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
{ HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
{ HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 47ac1a7d66e1..04359ed64b87 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -137,6 +137,14 @@ static const struct hid_usage_entry hid_usage_table[] = {
{0, 0x44, "BarrelSwitch"},
{0, 0x45, "Eraser"},
{0, 0x46, "TabletPick"},
+ {0, 0x47, "Confidence"},
+ {0, 0x48, "Width"},
+ {0, 0x49, "Height"},
+ {0, 0x51, "ContactID"},
+ {0, 0x52, "InputMode"},
+ {0, 0x53, "DeviceIndex"},
+ {0, 0x54, "ContactCount"},
+ {0, 0x55, "ContactMaximumNumber"},
{ 15, 0, "PhysicalInterfaceDevice" },
{0, 0x00, "Undefined"},
{0, 0x01, "Physical_Interface_Device"},
@@ -514,9 +522,11 @@ static const char *events[EV_MAX + 1] = {
[EV_FF_STATUS] = "ForceFeedbackStatus",
};
-static const char *syncs[2] = {
+static const char *syncs[3] = {
[SYN_REPORT] = "Report", [SYN_CONFIG] = "Config",
+ [SYN_MT_REPORT] = "MT Report",
};
+
static const char *keys[KEY_MAX + 1] = {
[KEY_RESERVED] = "Reserved", [KEY_ESC] = "Esc",
[KEY_1] = "1", [KEY_2] = "2",
@@ -734,8 +744,17 @@ static const char *absolutes[ABS_MAX + 1] = {
[ABS_HAT2Y] = "Hat2Y", [ABS_HAT3X] = "Hat3X",
[ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure",
[ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt",
- [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "Tool Width",
+ [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "ToolWidth",
[ABS_VOLUME] = "Volume", [ABS_MISC] = "Misc",
+ [ABS_MT_TOUCH_MAJOR] = "MTMajor",
+ [ABS_MT_TOUCH_MINOR] = "MTMinor",
+ [ABS_MT_WIDTH_MAJOR] = "MTMajorW",
+ [ABS_MT_WIDTH_MINOR] = "MTMinorW",
+ [ABS_MT_ORIENTATION] = "MTOrientation",
+ [ABS_MT_POSITION_X] = "MTPositionX",
+ [ABS_MT_POSITION_Y] = "MTPositionY",
+ [ABS_MT_TOOL_TYPE] = "MTToolType",
+ [ABS_MT_BLOB_ID] = "MTBlobID",
};
static const char *misc[MSC_MAX + 1] = {
diff --git a/drivers/hid/hid-drff.c b/drivers/hid/hid-drff.c
index 34f3eb65100b..a239d20ad7a5 100644
--- a/drivers/hid/hid-drff.c
+++ b/drivers/hid/hid-drff.c
@@ -32,6 +32,8 @@
#include <linux/hid.h>
#include "hid-ids.h"
+
+#ifdef CONFIG_DRAGONRISE_FF
#include "usbhid/usbhid.h"
struct drff_device {
@@ -135,6 +137,12 @@ static int drff_init(struct hid_device *hid)
return 0;
}
+#else
+static inline int drff_init(struct hid_device *hid)
+{
+ return 0;
+}
+#endif
static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
index 510ad3ab8d33..8a11ccddaf2e 100644
--- a/drivers/hid/hid-gaff.c
+++ b/drivers/hid/hid-gaff.c
@@ -31,6 +31,8 @@
#include <linux/usb.h>
#include <linux/hid.h>
#include "hid-ids.h"
+
+#ifdef CONFIG_GREENASIA_FF
#include "usbhid/usbhid.h"
struct gaff_device {
@@ -130,6 +132,12 @@ static int gaff_init(struct hid_device *hid)
return 0;
}
+#else
+static inline int gaff_init(struct hid_device *hdev)
+{
+ return 0;
+}
+#endif
static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 4d5ee2bbc62b..630101037921 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -414,8 +414,10 @@
#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
#define USB_VENDOR_ID_WACOM 0x056a
+#define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81
#define USB_VENDOR_ID_WISEGROUP 0x0925
+#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
index 51aff08e10ce..56099709581c 100644
--- a/drivers/hid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -50,6 +50,12 @@ static const signed short ff_joystick[] = {
-1
};
+static const signed short ff_joystick_ac[] = {
+ FF_CONSTANT,
+ FF_AUTOCENTER,
+ -1
+};
+
static const signed short ff_wheel[] = {
FF_CONSTANT,
FF_AUTOCENTER,
@@ -60,8 +66,8 @@ static const struct dev_type devices[] = {
{ 0x046d, 0xc211, ff_rumble },
{ 0x046d, 0xc219, ff_rumble },
{ 0x046d, 0xc283, ff_joystick },
- { 0x046d, 0xc286, ff_joystick },
- { 0x046d, 0xc294, ff_joystick },
+ { 0x046d, 0xc286, ff_joystick_ac },
+ { 0x046d, 0xc294, ff_wheel },
{ 0x046d, 0xc295, ff_joystick },
{ 0x046d, 0xca03, ff_wheel },
};
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index c5b252be9c21..75ed9d2c1a36 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -1,13 +1,8 @@
/*
- * HID driver for some ntrig "special" devices
+ * HID driver for N-Trig touchscreens
*
- * Copyright (c) 1999 Andreas Gal
- * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
- * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
- * Copyright (c) 2006-2007 Jiri Kosina
- * Copyright (c) 2007 Paul Walmsley
- * Copyright (c) 2008 Jiri Slaby
* Copyright (c) 2008 Rafi Rubin
+ * Copyright (c) 2009 Stephane Chatty
*
*/
@@ -29,15 +24,79 @@
#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
EV_KEY, (c))
+struct ntrig_data {
+ __s32 x, y, id, w, h;
+ char reading_a_point, found_contact_id;
+};
+
+/*
+ * this driver is aimed at two firmware versions in circulation:
+ * - dual pen/finger single touch
+ * - finger multitouch, pen not working
+ */
+
static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
- if ((usage->hid & HID_USAGE_PAGE) == HID_UP_DIGITIZER &&
- (usage->hid & 0xff) == 0x47) {
- nt_map_key_clear(BTN_TOOL_DOUBLETAP);
- return 1;
+ switch (usage->hid & HID_USAGE_PAGE) {
+
+ case HID_UP_GENDESK:
+ switch (usage->hid) {
+ case HID_GD_X:
+ hid_map_usage(hi, usage, bit, max,
+ EV_ABS, ABS_MT_POSITION_X);
+ input_set_abs_params(hi->input, ABS_X,
+ field->logical_minimum,
+ field->logical_maximum, 0, 0);
+ return 1;
+ case HID_GD_Y:
+ hid_map_usage(hi, usage, bit, max,
+ EV_ABS, ABS_MT_POSITION_Y);
+ input_set_abs_params(hi->input, ABS_Y,
+ field->logical_minimum,
+ field->logical_maximum, 0, 0);
+ return 1;
+ }
+ return 0;
+
+ case HID_UP_DIGITIZER:
+ switch (usage->hid) {
+ /* we do not want to map these for now */
+ case HID_DG_INVERT: /* value is always 0 */
+ case HID_DG_ERASER: /* value is always 0 */
+ case HID_DG_CONTACTID: /* value is useless */
+ case HID_DG_BARRELSWITCH: /* doubtful */
+ case HID_DG_INPUTMODE:
+ case HID_DG_DEVICEINDEX:
+ case HID_DG_CONTACTCOUNT:
+ case HID_DG_CONTACTMAX:
+ return -1;
+
+ /* original mapping by Rafi Rubin */
+ case HID_DG_CONFIDENCE:
+ nt_map_key_clear(BTN_TOOL_DOUBLETAP);
+ return 1;
+
+ /* width/height mapped on TouchMajor/TouchMinor/Orientation */
+ case HID_DG_WIDTH:
+ hid_map_usage(hi, usage, bit, max,
+ EV_ABS, ABS_MT_TOUCH_MAJOR);
+ return 1;
+ case HID_DG_HEIGHT:
+ hid_map_usage(hi, usage, bit, max,
+ EV_ABS, ABS_MT_TOUCH_MINOR);
+ input_set_abs_params(hi->input, ABS_MT_ORIENTATION,
+ 0, 1, 0, 0);
+ return 1;
+ }
+ return 0;
+
+ case 0xff000000:
+ /* we do not want to map these: no input-oriented meaning */
+ return -1;
}
+
return 0;
}
@@ -51,6 +110,138 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
return 0;
}
+
+/*
+ * this function is called upon all reports
+ * so that we can filter contact point information,
+ * decide whether we are in multi or single touch mode
+ * and call input_mt_sync after each point if necessary
+ */
+static int ntrig_event (struct hid_device *hid, struct hid_field *field,
+ struct hid_usage *usage, __s32 value)
+{
+ struct input_dev *input = field->hidinput->input;
+ struct ntrig_data *nd = hid_get_drvdata(hid);
+
+ if (hid->claimed & HID_CLAIMED_INPUT) {
+ switch (usage->hid) {
+ case HID_GD_X:
+ nd->x = value;
+ nd->reading_a_point = 1;
+ break;
+ case HID_GD_Y:
+ nd->y = value;
+ break;
+ case HID_DG_CONTACTID:
+ nd->id = value;
+ /* we receive this only when in multitouch mode */
+ nd->found_contact_id = 1;
+ break;
+ case HID_DG_WIDTH:
+ nd->w = value;
+ break;
+ case HID_DG_HEIGHT:
+ nd->h = value;
+ /*
+ * when in single touch mode, this is the last
+ * report received in a finger event. We want
+ * to emit a normal (X, Y) position
+ */
+ if (! nd->found_contact_id) {
+ input_event(input, EV_ABS, ABS_X, nd->x);
+ input_event(input, EV_ABS, ABS_Y, nd->y);
+ }
+ break;
+ case HID_DG_TIPPRESSURE:
+ /*
+ * when in single touch mode, this is the last
+ * report received in a pen event. We want
+ * to emit a normal (X, Y) position
+ */
+ if (! nd->found_contact_id) {
+ input_event(input, EV_ABS, ABS_X, nd->x);
+ input_event(input, EV_ABS, ABS_Y, nd->y);
+ input_event(input, EV_ABS, ABS_PRESSURE, value);
+ }
+ break;
+ case 0xff000002:
+ /*
+ * we receive this when the device is in multitouch
+ * mode. The first of the three values tagged with
+ * this usage tells if the contact point is real
+ * or a placeholder
+ */
+ if (!nd->reading_a_point || value != 1)
+ break;
+ /* emit a normal (X, Y) for the first point only */
+ if (nd->id == 0) {
+ input_event(input, EV_ABS, ABS_X, nd->x);
+ input_event(input, EV_ABS, ABS_Y, nd->y);
+ }
+ input_event(input, EV_ABS, ABS_MT_POSITION_X, nd->x);
+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, nd->y);
+ if (nd->w > nd->h) {
+ input_event(input, EV_ABS,
+ ABS_MT_ORIENTATION, 1);
+ input_event(input, EV_ABS,
+ ABS_MT_TOUCH_MAJOR, nd->w);
+ input_event(input, EV_ABS,
+ ABS_MT_TOUCH_MINOR, nd->h);
+ } else {
+ input_event(input, EV_ABS,
+ ABS_MT_ORIENTATION, 0);
+ input_event(input, EV_ABS,
+ ABS_MT_TOUCH_MAJOR, nd->h);
+ input_event(input, EV_ABS,
+ ABS_MT_TOUCH_MINOR, nd->w);
+ }
+ input_mt_sync(field->hidinput->input);
+ nd->reading_a_point = 0;
+ nd->found_contact_id = 0;
+ break;
+
+ default:
+ /* fallback to the generic hidinput handling */
+ return 0;
+ }
+ }
+
+ /* we have handled the hidinput part, now remains hiddev */
+ if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
+ hid->hiddev_hid_event(hid, field, usage, value);
+
+ return 1;
+}
+
+static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int ret;
+ struct ntrig_data *nd;
+
+ nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL);
+ if (!nd) {
+ dev_err(&hdev->dev, "cannot allocate N-Trig data\n");
+ return -ENOMEM;
+ }
+ nd->reading_a_point = 0;
+ nd->found_contact_id = 0;
+ hid_set_drvdata(hdev, nd);
+
+ ret = hid_parse(hdev);
+ if (!ret)
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+
+ if (ret)
+ kfree (nd);
+ return ret;
+}
+
+static void ntrig_remove(struct hid_device *hdev)
+{
+ hid_hw_stop(hdev);
+ kfree(hid_get_drvdata(hdev));
+}
+
static const struct hid_device_id ntrig_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN),
.driver_data = NTRIG_DUPLICATE_USAGES },
@@ -58,11 +249,20 @@ static const struct hid_device_id ntrig_devices[] = {
};
MODULE_DEVICE_TABLE(hid, ntrig_devices);
+static const struct hid_usage_id ntrig_grabbed_usages[] = {
+ { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
+ { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
+};
+
static struct hid_driver ntrig_driver = {
.name = "ntrig",
.id_table = ntrig_devices,
+ .probe = ntrig_probe,
+ .remove = ntrig_remove,
.input_mapping = ntrig_input_mapping,
.input_mapped = ntrig_input_mapped,
+ .usage_table = ntrig_grabbed_usages,
+ .event = ntrig_event,
};
static int ntrig_init(void)
diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c
new file mode 100644
index 000000000000..eab169e5c371
--- /dev/null
+++ b/drivers/hid/hid-sjoy.c
@@ -0,0 +1,180 @@
+/*
+ * Force feedback support for SmartJoy PLUS PS2->USB adapter
+ *
+ * Copyright (c) 2009 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
+ *
+ * Based of hid-pl.c and hid-gaff.c
+ * Copyright (c) 2007, 2009 Anssi Hannula <anssi.hannula@gmail.com>
+ * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* #define DEBUG */
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+#include "hid-ids.h"
+
+#ifdef CONFIG_SMARTJOYPLUS_FF
+#include "usbhid/usbhid.h"
+
+struct sjoyff_device {
+ struct hid_report *report;
+};
+
+static int hid_sjoyff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct sjoyff_device *sjoyff = data;
+ u32 left, right;
+
+ left = effect->u.rumble.strong_magnitude;
+ right = effect->u.rumble.weak_magnitude;
+ dev_dbg(&dev->dev, "called with 0x%08x 0x%08x\n", left, right);
+
+ left = left * 0xff / 0xffff;
+ right = (right != 0); /* on/off only */
+
+ sjoyff->report->field[0]->value[1] = right;
+ sjoyff->report->field[0]->value[2] = left;
+ dev_dbg(&dev->dev, "running with 0x%02x 0x%02x\n", left, right);
+ usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT);
+
+ return 0;
+}
+
+static int sjoyff_init(struct hid_device *hid)
+{
+ struct sjoyff_device *sjoyff;
+ struct hid_report *report;
+ struct hid_input *hidinput = list_entry(hid->inputs.next,
+ struct hid_input, list);
+ struct list_head *report_list =
+ &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+ struct list_head *report_ptr = report_list;
+ struct input_dev *dev;
+ int error;
+
+ if (list_empty(report_list)) {
+ dev_err(&hid->dev, "no output reports found\n");
+ return -ENODEV;
+ }
+
+ report_ptr = report_ptr->next;
+
+ if (report_ptr == report_list) {
+ dev_err(&hid->dev, "required output report is "
+ "missing\n");
+ return -ENODEV;
+ }
+
+ report = list_entry(report_ptr, struct hid_report, list);
+ if (report->maxfield < 1) {
+ dev_err(&hid->dev, "no fields in the report\n");
+ return -ENODEV;
+ }
+
+ if (report->field[0]->report_count < 3) {
+ dev_err(&hid->dev, "not enough values in the field\n");
+ return -ENODEV;
+ }
+
+ sjoyff = kzalloc(sizeof(struct sjoyff_device), GFP_KERNEL);
+ if (!sjoyff)
+ return -ENOMEM;
+
+ dev = hidinput->input;
+
+ set_bit(FF_RUMBLE, dev->ffbit);
+
+ error = input_ff_create_memless(dev, sjoyff, hid_sjoyff_play);
+ if (error) {
+ kfree(sjoyff);
+ return error;
+ }
+
+ sjoyff->report = report;
+ sjoyff->report->field[0]->value[0] = 0x01;
+ sjoyff->report->field[0]->value[1] = 0x00;
+ sjoyff->report->field[0]->value[2] = 0x00;
+ usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT);
+
+ dev_info(&hid->dev,
+ "Force feedback for SmartJoy PLUS PS2/USB adapter\n");
+
+ return 0;
+}
+#else
+static inline int sjoyff_init(struct hid_device *hid)
+{
+ return 0;
+}
+#endif
+
+static int sjoy_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int ret;
+
+ ret = hid_parse(hdev);
+ if (ret) {
+ dev_err(&hdev->dev, "parse failed\n");
+ goto err;
+ }
+
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
+ if (ret) {
+ dev_err(&hdev->dev, "hw start failed\n");
+ goto err;
+ }
+
+ sjoyff_init(hdev);
+
+ return 0;
+err:
+ return ret;
+}
+
+static const struct hid_device_id sjoy_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, sjoy_devices);
+
+static struct hid_driver sjoy_driver = {
+ .name = "smartjoyplus",
+ .id_table = sjoy_devices,
+ .probe = sjoy_probe,
+};
+
+static int sjoy_init(void)
+{
+ return hid_register_driver(&sjoy_driver);
+}
+
+static void sjoy_exit(void)
+{
+ hid_unregister_driver(&sjoy_driver);
+}
+
+module_init(sjoy_init);
+module_exit(sjoy_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jussi Kivilinna");
+
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 7c1f7b50330c..fcd6ccd02fee 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -33,11 +33,6 @@
#include "hid-ids.h"
-#include "usbhid/usbhid.h"
-
-/* Usages for thrustmaster devices I know about */
-#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb)
-
static const signed short ff_rumble[] = {
FF_RUMBLE,
-1
@@ -48,6 +43,12 @@ static const signed short ff_joystick[] = {
-1
};
+#ifdef CONFIG_THRUSTMASTER_FF
+#include "usbhid/usbhid.h"
+
+/* Usages for thrustmaster devices I know about */
+#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb)
+
struct tmff_device {
struct hid_report *report;
struct hid_field *ff_field;
@@ -209,6 +210,12 @@ fail:
kfree(tmff);
return error;
}
+#else
+static inline int tmff_init(struct hid_device *hid, const signed short *ff_bits)
+{
+ return 0;
+}
+#endif
static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
new file mode 100644
index 000000000000..1f9237f511e3
--- /dev/null
+++ b/drivers/hid/hid-wacom.c
@@ -0,0 +1,259 @@
+/*
+ * Bluetooth Wacom Tablet support
+ *
+ * Copyright (c) 1999 Andreas Gal
+ * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
+ * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
+ * Copyright (c) 2006-2007 Jiri Kosina
+ * Copyright (c) 2007 Paul Walmsley
+ * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
+ * Copyright (c) 2006 Andrew Zabolotny <zap@homelink.ru>
+ * Copyright (c) 2009 Bastien Nocera <hadess@hadess.net>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+struct wacom_data {
+ __u16 tool;
+ unsigned char butstate;
+};
+
+static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
+ u8 *raw_data, int size)
+{
+ struct wacom_data *wdata = hid_get_drvdata(hdev);
+ struct hid_input *hidinput;
+ struct input_dev *input;
+ unsigned char *data = (unsigned char *) raw_data;
+ int tool, x, y, rw;
+
+ if (!(hdev->claimed & HID_CLAIMED_INPUT))
+ return 0;
+
+ tool = 0;
+ hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
+ input = hidinput->input;
+
+ /* Check if this is a tablet report */
+ if (data[0] != 0x03)
+ return 0;
+
+ /* Get X & Y positions */
+ x = le16_to_cpu(*(__le16 *) &data[2]);
+ y = le16_to_cpu(*(__le16 *) &data[4]);
+
+ /* Get current tool identifier */
+ if (data[1] & 0x90) { /* If pen is in the in/active area */
+ switch ((data[1] >> 5) & 3) {
+ case 0: /* Pen */
+ tool = BTN_TOOL_PEN;
+ break;
+
+ case 1: /* Rubber */
+ tool = BTN_TOOL_RUBBER;
+ break;
+
+ case 2: /* Mouse with wheel */
+ case 3: /* Mouse without wheel */
+ tool = BTN_TOOL_MOUSE;
+ break;
+ }
+
+ /* Reset tool if out of active tablet area */
+ if (!(data[1] & 0x10))
+ tool = 0;
+ }
+
+ /* If tool changed, notify input subsystem */
+ if (wdata->tool != tool) {
+ if (wdata->tool) {
+ /* Completely reset old tool state */
+ if (wdata->tool == BTN_TOOL_MOUSE) {
+ input_report_key(input, BTN_LEFT, 0);
+ input_report_key(input, BTN_RIGHT, 0);
+ input_report_key(input, BTN_MIDDLE, 0);
+ input_report_abs(input, ABS_DISTANCE,
+ input->absmax[ABS_DISTANCE]);
+ } else {
+ input_report_key(input, BTN_TOUCH, 0);
+ input_report_key(input, BTN_STYLUS, 0);
+ input_report_key(input, BTN_STYLUS2, 0);
+ input_report_abs(input, ABS_PRESSURE, 0);
+ }
+ input_report_key(input, wdata->tool, 0);
+ input_sync(input);
+ }
+ wdata->tool = tool;
+ if (tool)
+ input_report_key(input, tool, 1);
+ }
+
+ if (tool) {
+ input_report_abs(input, ABS_X, x);
+ input_report_abs(input, ABS_Y, y);
+
+ switch ((data[1] >> 5) & 3) {
+ case 2: /* Mouse with wheel */
+ input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
+ rw = (data[6] & 0x01) ? -1 :
+ (data[6] & 0x02) ? 1 : 0;
+ input_report_rel(input, REL_WHEEL, rw);
+ /* fall through */
+
+ case 3: /* Mouse without wheel */
+ input_report_key(input, BTN_LEFT, data[1] & 0x01);
+ input_report_key(input, BTN_RIGHT, data[1] & 0x02);
+ /* Compute distance between mouse and tablet */
+ rw = 44 - (data[6] >> 2);
+ if (rw < 0)
+ rw = 0;
+ else if (rw > 31)
+ rw = 31;
+ input_report_abs(input, ABS_DISTANCE, rw);
+ break;
+
+ default:
+ input_report_abs(input, ABS_PRESSURE,
+ data[6] | (((__u16) (data[1] & 0x08)) << 5));
+ input_report_key(input, BTN_TOUCH, data[1] & 0x01);
+ input_report_key(input, BTN_STYLUS, data[1] & 0x02);
+ input_report_key(input, BTN_STYLUS2, (tool == BTN_TOOL_PEN) && data[1] & 0x04);
+ break;
+ }
+
+ input_sync(input);
+ }
+
+ /* Report the state of the two buttons at the top of the tablet
+ * as two extra fingerpad keys (buttons 4 & 5). */
+ rw = data[7] & 0x03;
+ if (rw != wdata->butstate) {
+ wdata->butstate = rw;
+ input_report_key(input, BTN_0, rw & 0x02);
+ input_report_key(input, BTN_1, rw & 0x01);
+ input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
+ input_sync(input);
+ }
+
+ return 1;
+}
+
+static int wacom_probe(struct hid_device *hdev,
+ const struct hid_device_id *id)
+{
+ struct hid_input *hidinput;
+ struct input_dev *input;
+ struct wacom_data *wdata;
+ int ret;
+
+ wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
+ if (wdata == NULL) {
+ dev_err(&hdev->dev, "can't alloc wacom descriptor\n");
+ return -ENOMEM;
+ }
+
+ hid_set_drvdata(hdev, wdata);
+
+ ret = hid_parse(hdev);
+ if (ret) {
+ dev_err(&hdev->dev, "parse failed\n");
+ goto err_free;
+ }
+
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+ if (ret) {
+ dev_err(&hdev->dev, "hw start failed\n");
+ goto err_free;
+ }
+
+ hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
+ input = hidinput->input;
+
+ /* Basics */
+ input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL);
+ input->absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) |
+ BIT(ABS_PRESSURE) | BIT(ABS_DISTANCE);
+ input->relbit[0] |= BIT(REL_WHEEL);
+ set_bit(BTN_TOOL_PEN, input->keybit);
+ set_bit(BTN_TOUCH, input->keybit);
+ set_bit(BTN_STYLUS, input->keybit);
+ set_bit(BTN_STYLUS2, input->keybit);
+ set_bit(BTN_LEFT, input->keybit);
+ set_bit(BTN_RIGHT, input->keybit);
+ set_bit(BTN_MIDDLE, input->keybit);
+
+ /* Pad */
+ input->evbit[0] |= BIT(EV_MSC);
+ input->mscbit[0] |= BIT(MSC_SERIAL);
+
+ /* Distance, rubber and mouse */
+ input->absbit[0] |= BIT(ABS_DISTANCE);
+ set_bit(BTN_TOOL_RUBBER, input->keybit);
+ set_bit(BTN_TOOL_MOUSE, input->keybit);
+
+ input->absmax[ABS_PRESSURE] = 511;
+ input->absmax[ABS_DISTANCE] = 32;
+
+ input->absmax[ABS_X] = 16704;
+ input->absmax[ABS_Y] = 12064;
+ input->absfuzz[ABS_X] = 4;
+ input->absfuzz[ABS_Y] = 4;
+
+ return 0;
+err_free:
+ kfree(wdata);
+ return ret;
+}
+
+static void wacom_remove(struct hid_device *hdev)
+{
+ hid_hw_stop(hdev);
+ kfree(hid_get_drvdata(hdev));
+}
+
+static const struct hid_device_id wacom_devices[] = {
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
+
+ { }
+};
+MODULE_DEVICE_TABLE(hid, wacom_devices);
+
+static struct hid_driver wacom_driver = {
+ .name = "wacom",
+ .id_table = wacom_devices,
+ .probe = wacom_probe,
+ .remove = wacom_remove,
+ .raw_event = wacom_raw_event,
+};
+
+static int wacom_init(void)
+{
+ int ret;
+
+ ret = hid_register_driver(&wacom_driver);
+ if (ret)
+ printk(KERN_ERR "can't register wacom driver\n");
+ printk(KERN_ERR "wacom driver registered\n");
+ return ret;
+}
+
+static void wacom_exit(void)
+{
+ hid_unregister_driver(&wacom_driver);
+}
+
+module_init(wacom_init);
+module_exit(wacom_exit);
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
index 85a198a18537..57f710757bf4 100644
--- a/drivers/hid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -27,6 +27,7 @@
#include "hid-ids.h"
+#ifdef CONFIG_ZEROPLUS_FF
#include "usbhid/usbhid.h"
struct zpff_device {
@@ -108,6 +109,12 @@ static int zpff_init(struct hid_device *hid)
return 0;
}
+#else
+static inline int zpff_init(struct hid_device *hid)
+{
+ return 0;
+}
+#endif
static int zp_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index e9b436d2d944..9e9421525fb9 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -850,8 +850,14 @@ static const struct file_operations hiddev_fops = {
#endif
};
+static char *hiddev_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
static struct usb_class_driver hiddev_class = {
.name = "hiddev%d",
+ .nodename = hiddev_nodename,
.fops = &hiddev_fops,
.minor_base = HIDDEV_MINOR_BASE,
};
@@ -955,7 +961,6 @@ static int hiddev_usbd_probe(struct usb_interface *intf,
return -ENODEV;
}
-
static /* const */ struct usb_driver hiddev_driver = {
.name = "hiddev",
.probe = hiddev_usbd_probe,
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index d73f5f473e38..79117c3abb41 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -418,7 +418,7 @@ config SENSORS_IBMAEM
power sensors and capping hardware in various IBM System X
servers that support Active Energy Manager. This includes
the x3350, x3550, x3650, x3655, x3755, x3850 M2, x3950 M2,
- and certain HS2x/LS2x/QS2x blades.
+ and certain HC10/HS2x/LS2x/QS2x blades.
This driver can also be built as a module. If so, the module
will be called ibmaem.
@@ -787,6 +787,16 @@ config SENSORS_THMC50
This driver can also be built as a module. If so, the module
will be called thmc50.
+config SENSORS_TMP401
+ tristate "Texas Instruments TMP401 and compatibles"
+ depends on I2C && EXPERIMENTAL
+ help
+ If you say yes here you get support for Texas Instruments TMP401 and
+ TMP411 temperature sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called tmp401.
+
config SENSORS_VIA686A
tristate "VIA686A"
depends on PCI
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 0ae26984ba45..b793dce6bed5 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -82,6 +82,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
obj-$(CONFIG_SENSORS_THMC50) += thmc50.o
+obj-$(CONFIG_SENSORS_TMP401) += tmp401.o
obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
obj-$(CONFIG_SENSORS_VT1211) += vt1211.o
obj-$(CONFIG_SENSORS_VT8231) += vt8231.o
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index fe74609a7feb..405d3fb5d76f 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -1127,3 +1127,4 @@ MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3650-*");
MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3655-*");
MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3755-*");
MODULE_ALIAS("dmi:bvnIBM:*:pnIBM3850M2/x3950M2-*");
+MODULE_ALIAS("dmi:bvnIBM:*:pnIBMBladeHC10-*");
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index b5e3b2851698..a1787fdf5b9f 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -182,7 +182,7 @@ static struct platform_driver lm78_isa_driver = {
.name = "lm78",
},
.probe = lm78_isa_probe,
- .remove = lm78_isa_remove,
+ .remove = __devexit_p(lm78_isa_remove),
};
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
new file mode 100644
index 000000000000..339d0d4af4ca
--- /dev/null
+++ b/drivers/hwmon/tmp401.c
@@ -0,0 +1,690 @@
+/* tmp401.c
+ *
+ * Copyright (C) 2007,2008 Hans de Goede <hdegoede@redhat.com>
+ * Preliminary tmp411 support by:
+ * Gabriel Konat, Sander Leget, Wouter Willems
+ * Copyright (C) 2009 Andre Prendel <andre.prendel@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*
+ * Driver for the Texas Instruments TMP401 SMBUS temperature sensor IC.
+ *
+ * Note this IC is in some aspect similar to the LM90, but it has quite a
+ * few differences too, for example the local temp has a higher resolution
+ * and thus has 16 bits registers for its value and limit instead of 8 bits.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/i2c.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/sysfs.h>
+
+/* Addresses to scan */
+static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
+
+/* Insmod parameters */
+I2C_CLIENT_INSMOD_2(tmp401, tmp411);
+
+/*
+ * The TMP401 registers, note some registers have different addresses for
+ * reading and writing
+ */
+#define TMP401_STATUS 0x02
+#define TMP401_CONFIG_READ 0x03
+#define TMP401_CONFIG_WRITE 0x09
+#define TMP401_CONVERSION_RATE_READ 0x04
+#define TMP401_CONVERSION_RATE_WRITE 0x0A
+#define TMP401_TEMP_CRIT_HYST 0x21
+#define TMP401_CONSECUTIVE_ALERT 0x22
+#define TMP401_MANUFACTURER_ID_REG 0xFE
+#define TMP401_DEVICE_ID_REG 0xFF
+#define TMP411_N_FACTOR_REG 0x18
+
+static const u8 TMP401_TEMP_MSB[2] = { 0x00, 0x01 };
+static const u8 TMP401_TEMP_LSB[2] = { 0x15, 0x10 };
+static const u8 TMP401_TEMP_LOW_LIMIT_MSB_READ[2] = { 0x06, 0x08 };
+static const u8 TMP401_TEMP_LOW_LIMIT_MSB_WRITE[2] = { 0x0C, 0x0E };
+static const u8 TMP401_TEMP_LOW_LIMIT_LSB[2] = { 0x17, 0x14 };
+static const u8 TMP401_TEMP_HIGH_LIMIT_MSB_READ[2] = { 0x05, 0x07 };
+static const u8 TMP401_TEMP_HIGH_LIMIT_MSB_WRITE[2] = { 0x0B, 0x0D };
+static const u8 TMP401_TEMP_HIGH_LIMIT_LSB[2] = { 0x16, 0x13 };
+/* These are called the THERM limit / hysteresis / mask in the datasheet */
+static const u8 TMP401_TEMP_CRIT_LIMIT[2] = { 0x20, 0x19 };
+
+static const u8 TMP411_TEMP_LOWEST_MSB[2] = { 0x30, 0x34 };
+static const u8 TMP411_TEMP_LOWEST_LSB[2] = { 0x31, 0x35 };
+static const u8 TMP411_TEMP_HIGHEST_MSB[2] = { 0x32, 0x36 };
+static const u8 TMP411_TEMP_HIGHEST_LSB[2] = { 0x33, 0x37 };
+
+/* Flags */
+#define TMP401_CONFIG_RANGE 0x04
+#define TMP401_CONFIG_SHUTDOWN 0x40
+#define TMP401_STATUS_LOCAL_CRIT 0x01
+#define TMP401_STATUS_REMOTE_CRIT 0x02
+#define TMP401_STATUS_REMOTE_OPEN 0x04
+#define TMP401_STATUS_REMOTE_LOW 0x08
+#define TMP401_STATUS_REMOTE_HIGH 0x10
+#define TMP401_STATUS_LOCAL_LOW 0x20
+#define TMP401_STATUS_LOCAL_HIGH 0x40
+
+/* Manufacturer / Device ID's */
+#define TMP401_MANUFACTURER_ID 0x55
+#define TMP401_DEVICE_ID 0x11
+#define TMP411_DEVICE_ID 0x12
+
+/*
+ * Functions declarations
+ */
+
+static int tmp401_probe(struct i2c_client *client,
+ const struct i2c_device_id *id);
+static int tmp401_detect(struct i2c_client *client, int kind,
+ struct i2c_board_info *info);
+static int tmp401_remove(struct i2c_client *client);
+static struct tmp401_data *tmp401_update_device(struct device *dev);
+
+/*
+ * Driver data (common to all clients)
+ */
+
+static const struct i2c_device_id tmp401_id[] = {
+ { "tmp401", tmp401 },
+ { "tmp411", tmp411 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, tmp401_id);
+
+static struct i2c_driver tmp401_driver = {
+ .class = I2C_CLASS_HWMON,
+ .driver = {
+ .name = "tmp401",
+ },
+ .probe = tmp401_probe,
+ .remove = tmp401_remove,
+ .id_table = tmp401_id,
+ .detect = tmp401_detect,
+ .address_data = &addr_data,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct tmp401_data {
+ struct device *hwmon_dev;
+ struct mutex update_lock;
+ char valid; /* zero until following fields are valid */
+ unsigned long last_updated; /* in jiffies */
+ int kind;
+
+ /* register values */
+ u8 status;
+ u8 config;
+ u16 temp[2];
+ u16 temp_low[2];
+ u16 temp_high[2];
+ u8 temp_crit[2];
+ u8 temp_crit_hyst;
+ u16 temp_lowest[2];
+ u16 temp_highest[2];
+};
+
+/*
+ * Sysfs attr show / store functions
+ */
+
+static int tmp401_register_to_temp(u16 reg, u8 config)
+{
+ int temp = reg;
+
+ if (config & TMP401_CONFIG_RANGE)
+ temp -= 64 * 256;
+
+ return (temp * 625 + 80) / 160;
+}
+
+static u16 tmp401_temp_to_register(long temp, u8 config)
+{
+ if (config & TMP401_CONFIG_RANGE) {
+ temp = SENSORS_LIMIT(temp, -64000, 191000);
+ temp += 64000;
+ } else
+ temp = SENSORS_LIMIT(temp, 0, 127000);
+
+ return (temp * 160 + 312) / 625;
+}
+
+static int tmp401_crit_register_to_temp(u8 reg, u8 config)
+{
+ int temp = reg;
+
+ if (config & TMP401_CONFIG_RANGE)
+ temp -= 64;
+
+ return temp * 1000;
+}
+
+static u8 tmp401_crit_temp_to_register(long temp, u8 config)
+{
+ if (config & TMP401_CONFIG_RANGE) {
+ temp = SENSORS_LIMIT(temp, -64000, 191000);
+ temp += 64000;
+ } else
+ temp = SENSORS_LIMIT(temp, 0, 127000);
+
+ return (temp + 500) / 1000;
+}
+
+static ssize_t show_temp_value(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ return sprintf(buf, "%d\n",
+ tmp401_register_to_temp(data->temp[index], data->config));
+}
+
+static ssize_t show_temp_min(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ return sprintf(buf, "%d\n",
+ tmp401_register_to_temp(data->temp_low[index], data->config));
+}
+
+static ssize_t show_temp_max(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ return sprintf(buf, "%d\n",
+ tmp401_register_to_temp(data->temp_high[index], data->config));
+}
+
+static ssize_t show_temp_crit(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ return sprintf(buf, "%d\n",
+ tmp401_crit_register_to_temp(data->temp_crit[index],
+ data->config));
+}
+
+static ssize_t show_temp_crit_hyst(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int temp, index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ mutex_lock(&data->update_lock);
+ temp = tmp401_crit_register_to_temp(data->temp_crit[index],
+ data->config);
+ temp -= data->temp_crit_hyst * 1000;
+ mutex_unlock(&data->update_lock);
+
+ return sprintf(buf, "%d\n", temp);
+}
+
+static ssize_t show_temp_lowest(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ return sprintf(buf, "%d\n",
+ tmp401_register_to_temp(data->temp_lowest[index],
+ data->config));
+}
+
+static ssize_t show_temp_highest(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ return sprintf(buf, "%d\n",
+ tmp401_register_to_temp(data->temp_highest[index],
+ data->config));
+}
+
+static ssize_t show_status(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int mask = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+
+ if (data->status & mask)
+ return sprintf(buf, "1\n");
+ else
+ return sprintf(buf, "0\n");
+}
+
+static ssize_t store_temp_min(struct device *dev, struct device_attribute
+ *devattr, const char *buf, size_t count)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+ long val;
+ u16 reg;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+
+ reg = tmp401_temp_to_register(val, data->config);
+
+ mutex_lock(&data->update_lock);
+
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP401_TEMP_LOW_LIMIT_MSB_WRITE[index], reg >> 8);
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP401_TEMP_LOW_LIMIT_LSB[index], reg & 0xFF);
+
+ data->temp_low[index] = reg;
+
+ mutex_unlock(&data->update_lock);
+
+ return count;
+}
+
+static ssize_t store_temp_max(struct device *dev, struct device_attribute
+ *devattr, const char *buf, size_t count)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+ long val;
+ u16 reg;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+
+ reg = tmp401_temp_to_register(val, data->config);
+
+ mutex_lock(&data->update_lock);
+
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP401_TEMP_HIGH_LIMIT_MSB_WRITE[index], reg >> 8);
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP401_TEMP_HIGH_LIMIT_LSB[index], reg & 0xFF);
+
+ data->temp_high[index] = reg;
+
+ mutex_unlock(&data->update_lock);
+
+ return count;
+}
+
+static ssize_t store_temp_crit(struct device *dev, struct device_attribute
+ *devattr, const char *buf, size_t count)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+ long val;
+ u8 reg;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+
+ reg = tmp401_crit_temp_to_register(val, data->config);
+
+ mutex_lock(&data->update_lock);
+
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP401_TEMP_CRIT_LIMIT[index], reg);
+
+ data->temp_crit[index] = reg;
+
+ mutex_unlock(&data->update_lock);
+
+ return count;
+}
+
+static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute
+ *devattr, const char *buf, size_t count)
+{
+ int temp, index = to_sensor_dev_attr(devattr)->index;
+ struct tmp401_data *data = tmp401_update_device(dev);
+ long val;
+ u8 reg;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+
+ if (data->config & TMP401_CONFIG_RANGE)
+ val = SENSORS_LIMIT(val, -64000, 191000);
+ else
+ val = SENSORS_LIMIT(val, 0, 127000);
+
+ mutex_lock(&data->update_lock);
+ temp = tmp401_crit_register_to_temp(data->temp_crit[index],
+ data->config);
+ val = SENSORS_LIMIT(val, temp - 255000, temp);
+ reg = ((temp - val) + 500) / 1000;
+
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP401_TEMP_CRIT_HYST, reg);
+
+ data->temp_crit_hyst = reg;
+
+ mutex_unlock(&data->update_lock);
+
+ return count;
+}
+
+/*
+ * Resets the historical measurements of minimum and maximum temperatures.
+ * This is done by writing any value to any of the minimum/maximum registers
+ * (0x30-0x37).
+ */
+static ssize_t reset_temp_history(struct device *dev,
+ struct device_attribute *devattr, const char *buf, size_t count)
+{
+ long val;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+
+ if (val != 1) {
+ dev_err(dev, "temp_reset_history value %ld not"
+ " supported. Use 1 to reset the history!\n", val);
+ return -EINVAL;
+ }
+ i2c_smbus_write_byte_data(to_i2c_client(dev),
+ TMP411_TEMP_LOWEST_MSB[0], val);
+
+ return count;
+}
+
+static struct sensor_device_attribute tmp401_attr[] = {
+ SENSOR_ATTR(temp1_input, 0444, show_temp_value, NULL, 0),
+ SENSOR_ATTR(temp1_min, 0644, show_temp_min, store_temp_min, 0),
+ SENSOR_ATTR(temp1_max, 0644, show_temp_max, store_temp_max, 0),
+ SENSOR_ATTR(temp1_crit, 0644, show_temp_crit, store_temp_crit, 0),
+ SENSOR_ATTR(temp1_crit_hyst, 0644, show_temp_crit_hyst,
+ store_temp_crit_hyst, 0),
+ SENSOR_ATTR(temp1_min_alarm, 0444, show_status, NULL,
+ TMP401_STATUS_LOCAL_LOW),
+ SENSOR_ATTR(temp1_max_alarm, 0444, show_status, NULL,
+ TMP401_STATUS_LOCAL_HIGH),
+ SENSOR_ATTR(temp1_crit_alarm, 0444, show_status, NULL,
+ TMP401_STATUS_LOCAL_CRIT),
+ SENSOR_ATTR(temp2_input, 0444, show_temp_value, NULL, 1),
+ SENSOR_ATTR(temp2_min, 0644, show_temp_min, store_temp_min, 1),
+ SENSOR_ATTR(temp2_max, 0644, show_temp_max, store_temp_max, 1),
+ SENSOR_ATTR(temp2_crit, 0644, show_temp_crit, store_temp_crit, 1),
+ SENSOR_ATTR(temp2_crit_hyst, 0444, show_temp_crit_hyst, NULL, 1),
+ SENSOR_ATTR(temp2_fault, 0444, show_status, NULL,
+ TMP401_STATUS_REMOTE_OPEN),
+ SENSOR_ATTR(temp2_min_alarm, 0444, show_status, NULL,
+ TMP401_STATUS_REMOTE_LOW),
+ SENSOR_ATTR(temp2_max_alarm, 0444, show_status, NULL,
+ TMP401_STATUS_REMOTE_HIGH),
+ SENSOR_ATTR(temp2_crit_alarm, 0444, show_status, NULL,
+ TMP401_STATUS_REMOTE_CRIT),
+};
+
+/*
+ * Additional features of the TMP411 chip.
+ * The TMP411 stores the minimum and maximum
+ * temperature measured since power-on, chip-reset, or
+ * minimum and maximum register reset for both the local
+ * and remote channels.
+ */
+static struct sensor_device_attribute tmp411_attr[] = {
+ SENSOR_ATTR(temp1_highest, 0444, show_temp_highest, NULL, 0),
+ SENSOR_ATTR(temp1_lowest, 0444, show_temp_lowest, NULL, 0),
+ SENSOR_ATTR(temp2_highest, 0444, show_temp_highest, NULL, 1),
+ SENSOR_ATTR(temp2_lowest, 0444, show_temp_lowest, NULL, 1),
+ SENSOR_ATTR(temp_reset_history, 0200, NULL, reset_temp_history, 0),
+};
+
+/*
+ * Begin non sysfs callback code (aka Real code)
+ */
+
+static void tmp401_init_client(struct i2c_client *client)
+{
+ int config, config_orig;
+
+ /* Set the conversion rate to 2 Hz */
+ i2c_smbus_write_byte_data(client, TMP401_CONVERSION_RATE_WRITE, 5);
+
+ /* Start conversions (disable shutdown if necessary) */
+ config = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ);
+ if (config < 0) {
+ dev_warn(&client->dev, "Initialization failed!\n");
+ return;
+ }
+
+ config_orig = config;
+ config &= ~TMP401_CONFIG_SHUTDOWN;
+
+ if (config != config_orig)
+ i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config);
+}
+
+static int tmp401_detect(struct i2c_client *client, int kind,
+ struct i2c_board_info *info)
+{
+ struct i2c_adapter *adapter = client->adapter;
+
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+ return -ENODEV;
+
+ /* Detect and identify the chip */
+ if (kind <= 0) {
+ u8 reg;
+
+ reg = i2c_smbus_read_byte_data(client,
+ TMP401_MANUFACTURER_ID_REG);
+ if (reg != TMP401_MANUFACTURER_ID)
+ return -ENODEV;
+
+ reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);
+
+ switch (reg) {
+ case TMP401_DEVICE_ID:
+ kind = tmp401;
+ break;
+ case TMP411_DEVICE_ID:
+ kind = tmp411;
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ);
+ if (reg & 0x1b)
+ return -ENODEV;
+
+ reg = i2c_smbus_read_byte_data(client,
+ TMP401_CONVERSION_RATE_READ);
+ /* Datasheet says: 0x1-0x6 */
+ if (reg > 15)
+ return -ENODEV;
+ }
+ strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE);
+
+ return 0;
+}
+
+static int tmp401_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int i, err = 0;
+ struct tmp401_data *data;
+ const char *names[] = { "TMP401", "TMP411" };
+
+ data = kzalloc(sizeof(struct tmp401_data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ i2c_set_clientdata(client, data);
+ mutex_init(&data->update_lock);
+ data->kind = id->driver_data;
+
+ /* Initialize the TMP401 chip */
+ tmp401_init_client(client);
+
+ /* Register sysfs hooks */
+ for (i = 0; i < ARRAY_SIZE(tmp401_attr); i++) {
+ err = device_create_file(&client->dev,
+ &tmp401_attr[i].dev_attr);
+ if (err)
+ goto exit_remove;
+ }
+
+ /* Register aditional tmp411 sysfs hooks */
+ if (data->kind == tmp411) {
+ for (i = 0; i < ARRAY_SIZE(tmp411_attr); i++) {
+ err = device_create_file(&client->dev,
+ &tmp411_attr[i].dev_attr);
+ if (err)
+ goto exit_remove;
+ }
+ }
+
+ data->hwmon_dev = hwmon_device_register(&client->dev);
+ if (IS_ERR(data->hwmon_dev)) {
+ err = PTR_ERR(data->hwmon_dev);
+ data->hwmon_dev = NULL;
+ goto exit_remove;
+ }
+
+ dev_info(&client->dev, "Detected TI %s chip\n",
+ names[data->kind]);
+
+ return 0;
+
+exit_remove:
+ tmp401_remove(client); /* will also free data for us */
+ return err;
+}
+
+static int tmp401_remove(struct i2c_client *client)
+{
+ struct tmp401_data *data = i2c_get_clientdata(client);
+ int i;
+
+ if (data->hwmon_dev)
+ hwmon_device_unregister(data->hwmon_dev);
+
+ for (i = 0; i < ARRAY_SIZE(tmp401_attr); i++)
+ device_remove_file(&client->dev, &tmp401_attr[i].dev_attr);
+
+ if (data->kind == tmp411) {
+ for (i = 0; i < ARRAY_SIZE(tmp411_attr); i++)
+ device_remove_file(&client->dev,
+ &tmp411_attr[i].dev_attr);
+ }
+
+ kfree(data);
+ return 0;
+}
+
+static struct tmp401_data *tmp401_update_device_reg16(
+ struct i2c_client *client, struct tmp401_data *data)
+{
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ /*
+ * High byte must be read first immediately followed
+ * by the low byte
+ */
+ data->temp[i] = i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_MSB[i]) << 8;
+ data->temp[i] |= i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_LSB[i]);
+ data->temp_low[i] = i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_LOW_LIMIT_MSB_READ[i]) << 8;
+ data->temp_low[i] |= i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_LOW_LIMIT_LSB[i]);
+ data->temp_high[i] = i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_HIGH_LIMIT_MSB_READ[i]) << 8;
+ data->temp_high[i] |= i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_HIGH_LIMIT_LSB[i]);
+ data->temp_crit[i] = i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_CRIT_LIMIT[i]);
+
+ if (data->kind == tmp411) {
+ data->temp_lowest[i] = i2c_smbus_read_byte_data(client,
+ TMP411_TEMP_LOWEST_MSB[i]) << 8;
+ data->temp_lowest[i] |= i2c_smbus_read_byte_data(
+ client, TMP411_TEMP_LOWEST_LSB[i]);
+
+ data->temp_highest[i] = i2c_smbus_read_byte_data(
+ client, TMP411_TEMP_HIGHEST_MSB[i]) << 8;
+ data->temp_highest[i] |= i2c_smbus_read_byte_data(
+ client, TMP411_TEMP_HIGHEST_LSB[i]);
+ }
+ }
+ return data;
+}
+
+static struct tmp401_data *tmp401_update_device(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct tmp401_data *data = i2c_get_clientdata(client);
+
+ mutex_lock(&data->update_lock);
+
+ if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
+ data->status = i2c_smbus_read_byte_data(client, TMP401_STATUS);
+ data->config = i2c_smbus_read_byte_data(client,
+ TMP401_CONFIG_READ);
+ tmp401_update_device_reg16(client, data);
+
+ data->temp_crit_hyst = i2c_smbus_read_byte_data(client,
+ TMP401_TEMP_CRIT_HYST);
+
+ data->last_updated = jiffies;
+ data->valid = 1;
+ }
+
+ mutex_unlock(&data->update_lock);
+
+ return data;
+}
+
+static int __init tmp401_init(void)
+{
+ return i2c_add_driver(&tmp401_driver);
+}
+
+static void __exit tmp401_exit(void)
+{
+ i2c_del_driver(&tmp401_driver);
+}
+
+MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
+MODULE_DESCRIPTION("Texas Instruments TMP401 temperature sensor driver");
+MODULE_LICENSE("GPL");
+
+module_init(tmp401_init);
+module_exit(tmp401_exit);
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index e64b42058b21..0e9746913d2b 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -36,6 +36,7 @@
w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3
0x8860 0xa1
w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3
+ w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3
w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3
*/
@@ -53,12 +54,13 @@
#include <asm/io.h>
#include "lm75.h"
-enum kinds { w83627ehf, w83627dhg, w83667hg };
+enum kinds { w83627ehf, w83627dhg, w83627dhg_p, w83667hg };
/* used to set data->name = w83627ehf_device_names[data->sio_kind] */
static const char * w83627ehf_device_names[] = {
"w83627ehf",
"w83627dhg",
+ "w83627dhg",
"w83667hg",
};
@@ -86,6 +88,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID");
#define SIO_W83627EHF_ID 0x8850
#define SIO_W83627EHG_ID 0x8860
#define SIO_W83627DHG_ID 0xa020
+#define SIO_W83627DHG_P_ID 0xb070
#define SIO_W83667HG_ID 0xa510
#define SIO_ID_MASK 0xFFF0
@@ -1517,6 +1520,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
static const char __initdata sio_name_W83627EHF[] = "W83627EHF";
static const char __initdata sio_name_W83627EHG[] = "W83627EHG";
static const char __initdata sio_name_W83627DHG[] = "W83627DHG";
+ static const char __initdata sio_name_W83627DHG_P[] = "W83627DHG-P";
static const char __initdata sio_name_W83667HG[] = "W83667HG";
u16 val;
@@ -1542,6 +1546,10 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
sio_data->kind = w83627dhg;
sio_name = sio_name_W83627DHG;
break;
+ case SIO_W83627DHG_P_ID:
+ sio_data->kind = w83627dhg_p;
+ sio_name = sio_name_W83627DHG_P;
+ break;
case SIO_W83667HG_ID:
sio_data->kind = w83667hg;
sio_name = sio_name_W83667HG;
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f1c6ca7e2852..660e8365a950 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -211,7 +211,7 @@ config I2C_VIA
will be called i2c-via.
config I2C_VIAPRO
- tristate "VIA VT82C596/82C686/82xx and CX700/VX800/VX820"
+ tristate "VIA VT82C596/82C686/82xx and CX700/VX8xx"
depends on PCI
help
If you say yes to this option, support will be included for the VIA
@@ -225,8 +225,8 @@ config I2C_VIAPRO
VT8237R/A/S
VT8251
CX700
- VX800
- VX820
+ VX800/VX820
+ VX855/VX875
This driver can also be built as a module. If so, the module
will be called i2c-viapro.
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index acc7143d9655..035a6c7e59df 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -34,10 +34,24 @@
#include <linux/err.h>
#include <linux/clk.h>
-#include <mach/hardware.h>
#include <asm/irq.h>
#include <asm/io.h>
-#include <mach/i2c.h>
+#include <plat/i2c.h>
+
+/*
+ * I2C register offsets will be shifted 0 or 1 bit left, depending on
+ * different SoCs
+ */
+#define REG_SHIFT_0 (0 << 0)
+#define REG_SHIFT_1 (1 << 0)
+#define REG_SHIFT(d) ((d) & 0x1)
+
+static const struct platform_device_id i2c_pxa_id_table[] = {
+ { "pxa2xx-i2c", REG_SHIFT_1 },
+ { "pxa3xx-pwri2c", REG_SHIFT_0 },
+ { },
+};
+MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
/*
* I2C registers and bit definitions
@@ -985,6 +999,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
struct pxa_i2c *i2c;
struct resource *res;
struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
+ struct platform_device_id *id = platform_get_device_id(dev);
int ret;
int irq;
@@ -1028,7 +1043,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
ret = -EIO;
goto eremap;
}
- i2c->reg_shift = (cpu_is_pxa3xx() && (dev->id == 1)) ? 0 : 1;
+ i2c->reg_shift = REG_SHIFT(id->driver_data);
i2c->iobase = res->start;
i2c->iosize = res_len(res);
@@ -1150,6 +1165,7 @@ static struct platform_driver i2c_pxa_driver = {
.name = "pxa2xx-i2c",
.owner = THIS_MODULE,
},
+ .id_table = i2c_pxa_id_table,
};
static int __init i2c_adap_pxa_init(void)
diff --git a/drivers/i2c/busses/i2c-sh7760.c b/drivers/i2c/busses/i2c-sh7760.c
index baa28b73ae42..b9680f50f541 100644
--- a/drivers/i2c/busses/i2c-sh7760.c
+++ b/drivers/i2c/busses/i2c-sh7760.c
@@ -396,7 +396,7 @@ static int __devinit calc_CCR(unsigned long scl_hz)
signed char cdf, cdfm;
int scgd, scgdm, scgds;
- mclk = clk_get(NULL, "module_clk");
+ mclk = clk_get(NULL, "peripheral_clk");
if (IS_ERR(mclk)) {
return PTR_ERR(mclk);
} else {
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 02e6f724b05f..54d810a4d00f 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -37,6 +37,7 @@
VT8251 0x3287 yes
CX700 0x8324 yes
VX800/VX820 0x8353 yes
+ VX855/VX875 0x8409 yes
Note: we assume there can only be one device, with one SMBus interface.
*/
@@ -404,6 +405,7 @@ found:
switch (pdev->device) {
case PCI_DEVICE_ID_VIA_CX700:
case PCI_DEVICE_ID_VIA_VX800:
+ case PCI_DEVICE_ID_VIA_VX855:
case PCI_DEVICE_ID_VIA_8251:
case PCI_DEVICE_ID_VIA_8237:
case PCI_DEVICE_ID_VIA_8237A:
@@ -469,6 +471,8 @@ static struct pci_device_id vt596_ids[] = {
.driver_data = SMBBA3 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800),
.driver_data = SMBBA3 },
+ { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855),
+ .driver_data = SMBBA3 },
{ 0, }
};
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index 1a474acc0ddd..7663d57833a0 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -163,7 +163,6 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = {
static struct i2c_adapter voodoo3_i2c_adapter = {
.owner = THIS_MODULE,
- .class = I2C_CLASS_TV_ANALOG,
.name = "I2C Voodoo3/Banshee adapter",
.algo_data = &voo_i2c_bit_data,
};
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 8f8c81eb0aee..02d746c9c474 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -64,21 +64,6 @@ config SENSORS_PCA9539
This driver is deprecated and will be dropped soon. Use
drivers/gpio/pca953x.c instead.
-config SENSORS_MAX6875
- tristate "Maxim MAX6875 Power supply supervisor"
- depends on EXPERIMENTAL
- help
- If you say yes here you get support for the Maxim MAX6875
- EEPROM-programmable, quad power-supply sequencer/supervisor.
-
- This provides an interface to program the EEPROM and reset the chip.
-
- This driver also supports the Maxim MAX6874 hex power-supply
- sequencer/supervisor if found at a compatible address.
-
- This driver can also be built as a module. If so, the module
- will be called max6875.
-
config SENSORS_TSL2550
tristate "Taos TSL2550 ambient light sensor"
depends on EXPERIMENTAL
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 55a376037183..f4680d16ee34 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -11,7 +11,6 @@
#
obj-$(CONFIG_DS1682) += ds1682.o
-obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
obj-$(CONFIG_PCF8575) += pcf8575.o
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 85e2e919d1cd..5ed622ee65c3 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -29,7 +29,6 @@
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/idr.h>
-#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/completion.h>
#include <linux/hardirq.h>
@@ -451,16 +450,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
mutex_lock(&core_lock);
- /* Add the adapter to the driver core.
- * If the parent pointer is not set up,
- * we add this adapter to the host bus.
- */
- if (adap->dev.parent == NULL) {
- adap->dev.parent = &platform_bus;
- pr_debug("I2C adapter driver [%s] forgot to specify "
- "physical device\n", adap->name);
- }
-
/* Set default timeout to 1 second if not already set */
if (adap->timeout == 0)
adap->timeout = HZ;
@@ -1022,7 +1011,8 @@ module_exit(i2c_exit);
*/
int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{
- int ret;
+ unsigned long orig_jiffies;
+ int ret, try;
/* REVISIT the fault reporting model here is weak:
*
@@ -1060,7 +1050,15 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
mutex_lock_nested(&adap->bus_lock, adap->level);
}
- ret = adap->algo->master_xfer(adap,msgs,num);
+ /* Retry automatically on arbitration loss */
+ orig_jiffies = jiffies;
+ for (ret = 0, try = 0; try <= adap->retries; try++) {
+ ret = adap->algo->master_xfer(adap, msgs, num);
+ if (ret != -EAGAIN)
+ break;
+ if (time_after(jiffies, orig_jiffies + adap->timeout))
+ break;
+ }
mutex_unlock(&adap->bus_lock);
return ret;
@@ -1509,7 +1507,7 @@ struct i2c_adapter* i2c_get_adapter(int id)
struct i2c_adapter *adapter;
mutex_lock(&core_lock);
- adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
+ adapter = idr_find(&i2c_adapter_idr, id);
if (adapter && !try_module_get(adapter->owner))
adapter = NULL;
@@ -1995,14 +1993,27 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
char read_write, u8 command, int protocol,
union i2c_smbus_data *data)
{
+ unsigned long orig_jiffies;
+ int try;
s32 res;
flags &= I2C_M_TEN | I2C_CLIENT_PEC;
if (adapter->algo->smbus_xfer) {
mutex_lock(&adapter->bus_lock);
- res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write,
- command, protocol, data);
+
+ /* Retry automatically on arbitration loss */
+ orig_jiffies = jiffies;
+ for (res = 0, try = 0; try <= adapter->retries; try++) {
+ res = adapter->algo->smbus_xfer(adapter, addr, flags,
+ read_write, command,
+ protocol, data);
+ if (res != -EAGAIN)
+ break;
+ if (time_after(jiffies,
+ orig_jiffies + adapter->timeout))
+ break;
+ }
mutex_unlock(&adapter->bus_lock);
} else
res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
index 537da1cde16d..e59b6dee9ae2 100644
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -402,27 +402,23 @@ static u8 ali_cable_detect(ide_hwif_t *hwif)
return cbl;
}
-#if !defined(CONFIG_SPARC64) && !defined(CONFIG_PPC)
+#ifndef CONFIG_SPARC64
/**
* init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff
* @hwif: interface to configure
*
* Obtain the IRQ tables for an ALi based IDE solution on the PC
* class platforms. This part of the code isn't applicable to the
- * Sparc and PowerPC systems.
+ * Sparc systems.
*/
static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif)
{
- struct pci_dev *dev = to_pci_dev(hwif->dev);
u8 ideic, inmir;
s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6,
1, 11, 0, 12, 0, 14, 0, 15 };
int irq = -1;
- if (dev->device == PCI_DEVICE_ID_AL_M5229)
- hwif->irq = hwif->channel ? 15 : 14;
-
if (isa_dev) {
/*
* read IDE interface control
@@ -455,7 +451,7 @@ static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif)
}
#else
#define init_hwif_ali15x3 NULL
-#endif /* !defined(CONFIG_SPARC64) && !defined(CONFIG_PPC) */
+#endif /* CONFIG_SPARC64 */
/**
* init_dma_ali15x3 - set up DMA on ALi15x3
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c
index 403d0e4265db..fc0949a8cfde 100644
--- a/drivers/ide/at91_ide.c
+++ b/drivers/ide/at91_ide.c
@@ -216,6 +216,7 @@ static const struct ide_port_info at91_ide_port_info __initdata = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE |
IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS,
.pio_mask = ATA_PIO6,
+ .chipset = ide_generic,
};
/*
@@ -246,8 +247,7 @@ irqreturn_t at91_irq_handler(int irq, void *dev_id)
static int __init at91_ide_probe(struct platform_device *pdev)
{
int ret;
- hw_regs_t hw;
- hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
struct ide_host *host;
struct resource *res;
unsigned long tf_base = 0, ctl_base = 0;
@@ -304,10 +304,9 @@ static int __init at91_ide_probe(struct platform_device *pdev)
ide_std_init_ports(&hw, tf_base, ctl_base + 6);
hw.irq = board->irq_pin;
- hw.chipset = ide_generic;
hw.dev = &pdev->dev;
- host = ide_host_alloc(&at91_ide_port_info, hws);
+ host = ide_host_alloc(&at91_ide_port_info, hws, 1);
if (!host) {
perr("failed to allocate ide host\n");
return -ENOMEM;
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 46013644c965..58121bd6c115 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -449,7 +449,7 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
}
#endif
-static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
+static void auide_setup_ports(struct ide_hw *hw, _auide_hwif *ahwif)
{
int i;
unsigned long *ata_regs = hw->io_ports_array;
@@ -499,6 +499,7 @@ static const struct ide_port_info au1xxx_port_info = {
#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
.mwdma_mask = ATA_MWDMA2,
#endif
+ .chipset = ide_au1xxx,
};
static int au_ide_probe(struct platform_device *dev)
@@ -507,7 +508,7 @@ static int au_ide_probe(struct platform_device *dev)
struct resource *res;
struct ide_host *host;
int ret = 0;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
char *mode = "MWDMA2";
@@ -548,9 +549,8 @@ static int au_ide_probe(struct platform_device *dev)
auide_setup_ports(&hw, ahwif);
hw.irq = ahwif->irq;
hw.dev = &dev->dev;
- hw.chipset = ide_au1xxx;
- ret = ide_host_add(&au1xxx_port_info, hws, &host);
+ ret = ide_host_add(&au1xxx_port_info, hws, 1, &host);
if (ret)
goto out;
diff --git a/drivers/ide/buddha.c b/drivers/ide/buddha.c
index d028f8864bc1..e3c6a5913305 100644
--- a/drivers/ide/buddha.c
+++ b/drivers/ide/buddha.c
@@ -121,7 +121,7 @@ static int xsurf_ack_intr(ide_hwif_t *hwif)
return 1;
}
-static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
+static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base,
unsigned long ctl, unsigned long irq_port,
ide_ack_intr_t *ack_intr)
{
@@ -139,13 +139,12 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
hw->irq = IRQ_AMIGA_PORTS;
hw->ack_intr = ack_intr;
-
- hw->chipset = ide_generic;
}
static const struct ide_port_info buddha_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
+ .chipset = ide_generic,
};
/*
@@ -161,7 +160,7 @@ static int __init buddha_init(void)
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
unsigned long board;
- hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS];
if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
buddha_num_hwifs = BUDDHA_NUM_HWIFS;
@@ -225,7 +224,7 @@ fail_base2:
hws[i] = &hw[i];
}
- ide_host_add(&buddha_port_info, hws, NULL);
+ ide_host_add(&buddha_port_info, hws, i, NULL);
}
return 0;
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c
index 8890276fef7f..1683ed5c7329 100644
--- a/drivers/ide/cmd640.c
+++ b/drivers/ide/cmd640.c
@@ -708,7 +708,7 @@ static int __init cmd640x_init(void)
int second_port_cmd640 = 0, rc;
const char *bus_type, *port2;
u8 b, cfr;
- hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[2], *hws[2];
if (cmd640_vlb && probe_for_cmd640_vlb()) {
bus_type = "VLB";
@@ -762,11 +762,9 @@ static int __init cmd640x_init(void)
ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
hw[0].irq = 14;
- hw[0].chipset = ide_cmd640;
ide_std_init_ports(&hw[1], 0x170, 0x376);
hw[1].irq = 15;
- hw[1].chipset = ide_cmd640;
printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x"
"\n", 'a' + cmd640_chip_version - 1, bus_type, cfr);
@@ -824,7 +822,8 @@ static int __init cmd640x_init(void)
cmd640_dump_regs();
#endif
- return ide_host_add(&cmd640_port_info, hws, NULL);
+ return ide_host_add(&cmd640_port_info, hws, second_port_cmd640 ? 2 : 1,
+ NULL);
}
module_param_named(probe_vlb, cmd640_vlb, bool, 0);
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
index 87987a7d36c9..bd066bb9d611 100644
--- a/drivers/ide/cs5520.c
+++ b/drivers/ide/cs5520.c
@@ -110,7 +110,7 @@ static const struct ide_port_info cyrix_chipset __devinitdata = {
static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
const struct ide_port_info *d = &cyrix_chipset;
- hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[2], *hws[] = { NULL, NULL };
ide_setup_pci_noise(dev, d);
@@ -136,7 +136,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
hw[0].irq = 14;
- return ide_host_add(d, hws, NULL);
+ return ide_host_add(d, hws, 2, NULL);
}
static const struct pci_device_id cs5520_pci_tbl[] = {
diff --git a/drivers/ide/delkin_cb.c b/drivers/ide/delkin_cb.c
index f153b95619bb..1e10eba62ceb 100644
--- a/drivers/ide/delkin_cb.c
+++ b/drivers/ide/delkin_cb.c
@@ -68,6 +68,7 @@ static const struct ide_port_info delkin_cb_port_info = {
IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
.init_chipset = delkin_cb_init_chipset,
+ .chipset = ide_pci,
};
static int __devinit
@@ -76,7 +77,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
struct ide_host *host;
unsigned long base;
int rc;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
rc = pci_enable_device(dev);
if (rc) {
@@ -97,9 +98,8 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
hw.irq = dev->irq;
hw.dev = &dev->dev;
- hw.chipset = ide_pci; /* this enables IRQ sharing */
- rc = ide_host_add(&delkin_cb_port_info, hws, &host);
+ rc = ide_host_add(&delkin_cb_port_info, hws, 1, &host);
if (rc)
goto out_disable;
diff --git a/drivers/ide/falconide.c b/drivers/ide/falconide.c
index 0e2df6755ec9..22fa27389c3b 100644
--- a/drivers/ide/falconide.c
+++ b/drivers/ide/falconide.c
@@ -111,9 +111,10 @@ static const struct ide_port_info falconide_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
+ .chipset = ide_generic,
};
-static void __init falconide_setup_ports(hw_regs_t *hw)
+static void __init falconide_setup_ports(struct ide_hw *hw)
{
int i;
@@ -128,8 +129,6 @@ static void __init falconide_setup_ports(hw_regs_t *hw)
hw->irq = IRQ_MFP_IDE;
hw->ack_intr = NULL;
-
- hw->chipset = ide_generic;
}
/*
@@ -139,7 +138,7 @@ static void __init falconide_setup_ports(hw_regs_t *hw)
static int __init falconide_init(void)
{
struct ide_host *host;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
int rc;
if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
@@ -154,7 +153,7 @@ static int __init falconide_init(void)
falconide_setup_ports(&hw);
- host = ide_host_alloc(&falconide_port_info, hws);
+ host = ide_host_alloc(&falconide_port_info, hws, 1);
if (host == NULL) {
rc = -ENOMEM;
goto err;
diff --git a/drivers/ide/gayle.c b/drivers/ide/gayle.c
index c7119516c5a7..4451a6a5dfe0 100644
--- a/drivers/ide/gayle.c
+++ b/drivers/ide/gayle.c
@@ -88,7 +88,7 @@ static int gayle_ack_intr_a1200(ide_hwif_t *hwif)
return 1;
}
-static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base,
+static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
unsigned long ctl, unsigned long irq_port,
ide_ack_intr_t *ack_intr)
{
@@ -106,14 +106,13 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base,
hw->irq = IRQ_AMIGA_PORTS;
hw->ack_intr = ack_intr;
-
- hw->chipset = ide_generic;
}
static const struct ide_port_info gayle_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
+ .chipset = ide_generic,
};
/*
@@ -126,7 +125,7 @@ static int __init gayle_init(void)
unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr;
int a4000, i, rc;
- hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS];
if (!MACH_IS_AMIGA)
return -ENODEV;
@@ -171,7 +170,7 @@ found:
hws[i] = &hw[i];
}
- rc = ide_host_add(&gayle_port_info, hws, NULL);
+ rc = ide_host_add(&gayle_port_info, hws, i, NULL);
if (rc)
release_mem_region(res_start, res_n);
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 36da913cc553..c5269fa1f733 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -381,7 +381,7 @@ static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d)
return -EOPNOTSUPP;
}
-static void icside_setup_ports(hw_regs_t *hw, void __iomem *base,
+static void icside_setup_ports(struct ide_hw *hw, void __iomem *base,
struct cardinfo *info, struct expansion_card *ec)
{
unsigned long port = (unsigned long)base + info->dataoffset;
@@ -398,11 +398,11 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base,
hw->irq = ec->irq;
hw->dev = &ec->dev;
- hw->chipset = ide_acorn;
}
static const struct ide_port_info icside_v5_port_info = {
.host_flags = IDE_HFLAG_NO_DMA,
+ .chipset = ide_acorn,
};
static int __devinit
@@ -410,7 +410,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
{
void __iomem *base;
struct ide_host *host;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
int ret;
base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
@@ -431,7 +431,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec);
- host = ide_host_alloc(&icside_v5_port_info, hws);
+ host = ide_host_alloc(&icside_v5_port_info, hws, 1);
if (host == NULL)
return -ENODEV;
@@ -457,6 +457,7 @@ static const struct ide_port_info icside_v6_port_info __initdata = {
.host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO,
.mwdma_mask = ATA_MWDMA2,
.swdma_mask = ATA_SWDMA2,
+ .chipset = ide_acorn,
};
static int __devinit
@@ -466,7 +467,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
struct ide_host *host;
unsigned int sel = 0;
int ret;
- hw_regs_t hw[2], *hws[] = { &hw[0], &hw[1], NULL, NULL };
+ struct ide_hw hw[2], *hws[] = { &hw[0], &hw[1] };
struct ide_port_info d = icside_v6_port_info;
ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
@@ -506,7 +507,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec);
icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec);
- host = ide_host_alloc(&d, hws);
+ host = ide_host_alloc(&d, hws, 2);
if (host == NULL)
return -ENODEV;
diff --git a/drivers/ide/ide-4drives.c b/drivers/ide/ide-4drives.c
index 78aca75a2c48..979d342c338a 100644
--- a/drivers/ide/ide-4drives.c
+++ b/drivers/ide/ide-4drives.c
@@ -25,12 +25,13 @@ static const struct ide_port_info ide_4drives_port_info = {
.port_ops = &ide_4drives_port_ops,
.host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA |
IDE_HFLAG_4DRIVES,
+ .chipset = ide_4drives,
};
static int __init ide_4drives_init(void)
{
unsigned long base = 0x1f0, ctl = 0x3f6;
- hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw, &hw };
if (probe_4drives == 0)
return -ENODEV;
@@ -52,9 +53,8 @@ static int __init ide_4drives_init(void)
ide_std_init_ports(&hw, base, ctl);
hw.irq = 14;
- hw.chipset = ide_4drives;
- return ide_host_add(&ide_4drives_port_info, hws, NULL);
+ return ide_host_add(&ide_4drives_port_info, hws, 2, NULL);
}
module_init(ide_4drives_init);
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 7201b176d75b..ffa1bb877949 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -80,34 +80,6 @@ void ide_init_pc(struct ide_atapi_pc *pc)
EXPORT_SYMBOL_GPL(ide_init_pc);
/*
- * Generate a new packet command request in front of the request queue, before
- * the current request, so that it will be processed immediately, on the next
- * pass through the driver.
- */
-static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
- struct ide_atapi_pc *pc, struct request *rq)
-{
- blk_rq_init(NULL, rq);
- rq->cmd_type = REQ_TYPE_SPECIAL;
- rq->cmd_flags |= REQ_PREEMPT;
- rq->buffer = (char *)pc;
- rq->rq_disk = disk;
-
- if (pc->req_xfer) {
- rq->data = pc->buf;
- rq->data_len = pc->req_xfer;
- }
-
- memcpy(rq->cmd, pc->c, 12);
- if (drive->media == ide_tape)
- rq->cmd[13] = REQ_IDETAPE_PC1;
-
- drive->hwif->rq = NULL;
-
- elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
-}
-
-/*
* Add a special packet command request to the tail of the request queue,
* and wait for it to be serviced.
*/
@@ -119,19 +91,21 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_SPECIAL;
- rq->buffer = (char *)pc;
+ rq->special = (char *)pc;
if (pc->req_xfer) {
- rq->data = pc->buf;
- rq->data_len = pc->req_xfer;
+ error = blk_rq_map_kern(drive->queue, rq, pc->buf, pc->req_xfer,
+ GFP_NOIO);
+ if (error)
+ goto put_req;
}
memcpy(rq->cmd, pc->c, 12);
if (drive->media == ide_tape)
rq->cmd[13] = REQ_IDETAPE_PC1;
error = blk_execute_rq(drive->queue, disk, rq, 0);
+put_req:
blk_put_request(rq);
-
return error;
}
EXPORT_SYMBOL_GPL(ide_queue_pc_tail);
@@ -191,20 +165,113 @@ void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc)
}
EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);
+void ide_prep_sense(ide_drive_t *drive, struct request *rq)
+{
+ struct request_sense *sense = &drive->sense_data;
+ struct request *sense_rq = &drive->sense_rq;
+ unsigned int cmd_len, sense_len;
+ int err;
+
+ debug_log("%s: enter\n", __func__);
+
+ switch (drive->media) {
+ case ide_floppy:
+ cmd_len = 255;
+ sense_len = 18;
+ break;
+ case ide_tape:
+ cmd_len = 20;
+ sense_len = 20;
+ break;
+ default:
+ cmd_len = 18;
+ sense_len = 18;
+ }
+
+ BUG_ON(sense_len > sizeof(*sense));
+
+ if (blk_sense_request(rq) || drive->sense_rq_armed)
+ return;
+
+ memset(sense, 0, sizeof(*sense));
+
+ blk_rq_init(rq->q, sense_rq);
+
+ err = blk_rq_map_kern(drive->queue, sense_rq, sense, sense_len,
+ GFP_NOIO);
+ if (unlikely(err)) {
+ if (printk_ratelimit())
+ printk(KERN_WARNING "%s: failed to map sense buffer\n",
+ drive->name);
+ return;
+ }
+
+ sense_rq->rq_disk = rq->rq_disk;
+ sense_rq->cmd[0] = GPCMD_REQUEST_SENSE;
+ sense_rq->cmd[4] = cmd_len;
+ sense_rq->cmd_type = REQ_TYPE_SENSE;
+ sense_rq->cmd_flags |= REQ_PREEMPT;
+
+ if (drive->media == ide_tape)
+ sense_rq->cmd[13] = REQ_IDETAPE_PC1;
+
+ drive->sense_rq_armed = true;
+}
+EXPORT_SYMBOL_GPL(ide_prep_sense);
+
+int ide_queue_sense_rq(ide_drive_t *drive, void *special)
+{
+ /* deferred failure from ide_prep_sense() */
+ if (!drive->sense_rq_armed) {
+ printk(KERN_WARNING "%s: failed queue sense request\n",
+ drive->name);
+ return -ENOMEM;
+ }
+
+ drive->sense_rq.special = special;
+ drive->sense_rq_armed = false;
+
+ drive->hwif->rq = NULL;
+
+ elv_add_request(drive->queue, &drive->sense_rq,
+ ELEVATOR_INSERT_FRONT, 0);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
+
/*
* Called when an error was detected during the last packet command.
- * We queue a request sense packet command in the head of the request list.
+ * We queue a request sense packet command at the head of the request
+ * queue.
*/
-void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk)
+void ide_retry_pc(ide_drive_t *drive)
{
- struct request *rq = &drive->request_sense_rq;
+ struct request *failed_rq = drive->hwif->rq;
+ struct request *sense_rq = &drive->sense_rq;
struct ide_atapi_pc *pc = &drive->request_sense_pc;
(void)ide_read_error(drive);
- ide_create_request_sense_cmd(drive, pc);
+
+ /* init pc from sense_rq */
+ ide_init_pc(pc);
+ memcpy(pc->c, sense_rq->cmd, 12);
+ pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */
+ pc->req_xfer = blk_rq_bytes(sense_rq);
+
if (drive->media == ide_tape)
set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
- ide_queue_pc_head(drive, disk, pc, rq);
+
+ /*
+ * Push back the failed request and put request sense on top
+ * of it. The failed command will be retried after sense data
+ * is acquired.
+ */
+ blk_requeue_request(failed_rq->q, failed_rq);
+ drive->hwif->rq = NULL;
+ if (ide_queue_sense_rq(drive, pc)) {
+ blk_start_request(failed_rq);
+ ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq));
+ }
}
EXPORT_SYMBOL_GPL(ide_retry_pc);
@@ -246,7 +313,7 @@ int ide_cd_get_xferlen(struct request *rq)
return 32768;
else if (blk_sense_request(rq) || blk_pc_request(rq) ||
rq->cmd_type == REQ_TYPE_ATA_PC)
- return rq->data_len;
+ return blk_rq_bytes(rq);
else
return 0;
}
@@ -276,7 +343,6 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
struct ide_cmd *cmd = &hwif->cmd;
struct request *rq = hwif->rq;
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
- xfer_func_t *xferfunc;
unsigned int timeout, done;
u16 bcount;
u8 stat, ireason, dsc = 0;
@@ -303,18 +369,14 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
drive->name, rq_data_dir(pc->rq)
? "write" : "read");
pc->flags |= PC_FLAG_DMA_ERROR;
- } else {
+ } else
pc->xferred = pc->req_xfer;
- if (drive->pc_update_buffers)
- drive->pc_update_buffers(drive, pc);
- }
debug_log("%s: DMA finished\n", drive->name);
}
/* No more interrupts */
if ((stat & ATA_DRQ) == 0) {
int uptodate, error;
- unsigned int done;
debug_log("Packet command completed, %d bytes transferred\n",
pc->xferred);
@@ -343,7 +405,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
/* Retry operation */
- ide_retry_pc(drive, rq->rq_disk);
+ ide_retry_pc(drive);
/* queued, but not started */
return ide_stopped;
@@ -361,7 +423,6 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
if (blk_special_request(rq)) {
rq->errors = 0;
- done = blk_rq_bytes(rq);
error = 0;
} else {
@@ -370,15 +431,10 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
rq->errors = -EIO;
}
- if (drive->media == ide_tape)
- done = ide_rq_bytes(rq); /* FIXME */
- else
- done = blk_rq_bytes(rq);
-
error = uptodate ? 0 : -EIO;
}
- ide_complete_rq(drive, error, done);
+ ide_complete_rq(drive, error, blk_rq_bytes(rq));
return ide_stopped;
}
@@ -407,21 +463,11 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
return ide_do_reset(drive);
}
- xferfunc = write ? tp_ops->output_data : tp_ops->input_data;
-
- if (drive->media == ide_floppy && pc->buf == NULL) {
- done = min_t(unsigned int, bcount, cmd->nleft);
- ide_pio_bytes(drive, cmd, write, done);
- } else if (drive->media == ide_tape && pc->bh) {
- done = drive->pc_io_buffers(drive, pc, bcount, write);
- } else {
- done = min_t(unsigned int, bcount, pc->req_xfer - pc->xferred);
- xferfunc(drive, NULL, pc->cur_pos, done);
- }
+ done = min_t(unsigned int, bcount, cmd->nleft);
+ ide_pio_bytes(drive, cmd, write, done);
- /* Update the current position */
+ /* Update transferred byte count */
pc->xferred += done;
- pc->cur_pos += done;
bcount -= done;
@@ -525,7 +571,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
/*
* If necessary schedule the packet transfer to occur 'timeout'
- * miliseconds later in ide_delayed_transfer_pc() after the
+ * milliseconds later in ide_delayed_transfer_pc() after the
* device says it's ready for a packet.
*/
if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) {
@@ -599,7 +645,6 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
/* We haven't transferred any data yet */
pc->xferred = 0;
- pc->cur_pos = pc->buf;
valid_tf = IDE_VALID_DEVICE;
bcount = ((drive->media == ide_tape) ?
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 925eb9e245d1..424140c6c400 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -182,7 +182,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
(sense->information[2] << 8) |
(sense->information[3]);
- if (drive->queue->hardsect_size == 2048)
+ if (queue_logical_block_size(drive->queue) == 2048)
/* device sector size is 2K */
sector <<= 2;
@@ -206,54 +206,25 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
ide_cd_log_error(drive->name, failed_command, sense);
}
-static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
- struct request *failed_command)
-{
- struct cdrom_info *info = drive->driver_data;
- struct request *rq = &drive->request_sense_rq;
-
- ide_debug_log(IDE_DBG_SENSE, "enter");
-
- if (sense == NULL)
- sense = &info->sense_data;
-
- /* stuff the sense request in front of our current request */
- blk_rq_init(NULL, rq);
- rq->cmd_type = REQ_TYPE_ATA_PC;
- rq->rq_disk = info->disk;
-
- rq->data = sense;
- rq->cmd[0] = GPCMD_REQUEST_SENSE;
- rq->cmd[4] = 18;
- rq->data_len = 18;
-
- rq->cmd_type = REQ_TYPE_SENSE;
- rq->cmd_flags |= REQ_PREEMPT;
-
- /* NOTE! Save the failed command in "rq->buffer" */
- rq->buffer = (void *) failed_command;
-
- if (failed_command)
- ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x",
- failed_command->cmd[0]);
-
- drive->hwif->rq = NULL;
-
- elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
-}
-
static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
{
/*
- * For REQ_TYPE_SENSE, "rq->buffer" points to the original
- * failed request
+ * For REQ_TYPE_SENSE, "rq->special" points to the original
+ * failed request. Also, the sense data should be read
+ * directly from rq which might be different from the original
+ * sense buffer if it got copied during mapping.
*/
- struct request *failed = (struct request *)rq->buffer;
- struct cdrom_info *info = drive->driver_data;
- void *sense = &info->sense_data;
+ struct request *failed = (struct request *)rq->special;
+ void *sense = bio_data(rq->bio);
if (failed) {
if (failed->sense) {
+ /*
+ * Sense is always read into drive->sense_data.
+ * Copy back if the failed request has its
+ * sense pointer set.
+ */
+ memcpy(failed->sense, sense, 18);
sense = failed->sense;
failed->sense_len = rq->sense_len;
}
@@ -428,22 +399,13 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
/* if we got a CHECK_CONDITION status, queue a request sense command */
if (stat & ATA_ERR)
- cdrom_queue_request_sense(drive, NULL, NULL);
+ return ide_queue_sense_rq(drive, NULL) ? 2 : 1;
return 1;
end_request:
if (stat & ATA_ERR) {
- struct request_queue *q = drive->queue;
- unsigned long flags;
-
- spin_lock_irqsave(q->queue_lock, flags);
- blkdev_dequeue_request(rq);
- spin_unlock_irqrestore(q->queue_lock, flags);
-
hwif->rq = NULL;
-
- cdrom_queue_request_sense(drive, rq->sense, rq);
- return 1;
+ return ide_queue_sense_rq(drive, rq) ? 2 : 1;
} else
return 2;
}
@@ -503,14 +465,8 @@ static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd)
* and some drives don't send them. Sigh.
*/
if (rq->cmd[0] == GPCMD_REQUEST_SENSE &&
- cmd->nleft > 0 && cmd->nleft <= 5) {
- unsigned int ofs = cmd->nbytes - cmd->nleft;
-
- while (cmd->nleft > 0) {
- *((u8 *)rq->data + ofs++) = 0;
- cmd->nleft--;
- }
- }
+ cmd->nleft > 0 && cmd->nleft <= 5)
+ cmd->nleft = 0;
}
int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
@@ -543,14 +499,18 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
rq->cmd_flags |= cmd_flags;
rq->timeout = timeout;
if (buffer) {
- rq->data = buffer;
- rq->data_len = *bufflen;
+ error = blk_rq_map_kern(drive->queue, rq, buffer,
+ *bufflen, GFP_NOIO);
+ if (error) {
+ blk_put_request(rq);
+ return error;
+ }
}
error = blk_execute_rq(drive->queue, info->disk, rq, 0);
if (buffer)
- *bufflen = rq->data_len;
+ *bufflen = rq->resid_len;
flags = rq->cmd_flags;
blk_put_request(rq);
@@ -608,7 +568,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
struct request *rq = hwif->rq;
ide_expiry_t *expiry = NULL;
int dma_error = 0, dma, thislen, uptodate = 0;
- int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors;
+ int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0;
int sense = blk_sense_request(rq);
unsigned int timeout;
u16 len;
@@ -738,13 +698,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
out_end:
if (blk_pc_request(rq) && rc == 0) {
- unsigned int dlen = rq->data_len;
-
- rq->data_len = 0;
-
- if (blk_end_request(rq, 0, dlen))
- BUG();
-
+ rq->resid_len = 0;
+ blk_end_request_all(rq, 0);
hwif->rq = NULL;
} else {
if (sense && uptodate)
@@ -762,21 +717,13 @@ out_end:
ide_cd_error_cmd(drive, cmd);
/* make sure it's fully ended */
- if (blk_pc_request(rq))
- nsectors = (rq->data_len + 511) >> 9;
- else
- nsectors = rq->hard_nr_sectors;
-
- if (nsectors == 0)
- nsectors = 1;
-
if (blk_fs_request(rq) == 0) {
- rq->data_len -= (cmd->nbytes - cmd->nleft);
+ rq->resid_len -= cmd->nbytes - cmd->nleft;
if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
- rq->data_len += cmd->last_xfer_len;
+ rq->resid_len += cmd->last_xfer_len;
}
- ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9);
+ ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq));
if (sense && rc == 2)
ide_error(drive, "request sense failure", stat);
@@ -790,7 +737,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
struct request_queue *q = drive->queue;
int write = rq_data_dir(rq) == WRITE;
unsigned short sectors_per_frame =
- queue_hardsect_size(q) >> SECTOR_BITS;
+ queue_logical_block_size(q) >> SECTOR_BITS;
ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, "
"secs_per_frame: %u",
@@ -809,8 +756,8 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
}
/* fs requests *must* be hardware frame aligned */
- if ((rq->nr_sectors & (sectors_per_frame - 1)) ||
- (rq->sector & (sectors_per_frame - 1)))
+ if ((blk_rq_sectors(rq) & (sectors_per_frame - 1)) ||
+ (blk_rq_pos(rq) & (sectors_per_frame - 1)))
return ide_stopped;
/* use DMA, if possible */
@@ -838,15 +785,10 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
drive->dma = 0;
/* sg request */
- if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) {
+ if (rq->bio) {
struct request_queue *q = drive->queue;
+ char *buf = bio_data(rq->bio);
unsigned int alignment;
- char *buf;
-
- if (rq->bio)
- buf = bio_data(rq->bio);
- else
- buf = rq->data;
drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
@@ -858,7 +800,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
*/
alignment = queue_dma_alignment(q) | q->dma_pad_mask;
if ((unsigned long)buf & alignment
- || rq->data_len & q->dma_pad_mask
+ || blk_rq_bytes(rq) & q->dma_pad_mask
|| object_is_on_stack(buf))
drive->dma = 0;
}
@@ -896,6 +838,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
goto out_end;
}
+ /* prepare sense request for this command */
+ ide_prep_sense(drive, rq);
+
memset(&cmd, 0, sizeof(cmd));
if (rq_data_dir(rq))
@@ -903,15 +848,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
cmd.rq = rq;
- if (blk_fs_request(rq) || rq->data_len) {
- ide_init_sg_cmd(&cmd, blk_fs_request(rq) ? (rq->nr_sectors << 9)
- : rq->data_len);
+ if (blk_fs_request(rq) || blk_rq_bytes(rq)) {
+ ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
ide_map_sg(drive, &cmd);
}
return ide_issue_pc(drive, &cmd);
out_end:
- nsectors = rq->hard_nr_sectors;
+ nsectors = blk_rq_sectors(rq);
if (nsectors == 0)
nsectors = 1;
@@ -1077,8 +1021,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
/* save a private copy of the TOC capacity for error handling */
drive->probed_capacity = toc->capacity * sectors_per_frame;
- blk_queue_hardsect_size(drive->queue,
- sectors_per_frame << SECTOR_BITS);
+ blk_queue_logical_block_size(drive->queue,
+ sectors_per_frame << SECTOR_BITS);
/* first read just the header, so we know how long the TOC is */
stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
@@ -1394,9 +1338,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
/* standard prep_rq_fn that builds 10 byte cmds */
static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
{
- int hard_sect = queue_hardsect_size(q);
- long block = (long)rq->hard_sector / (hard_sect >> 9);
- unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9);
+ int hard_sect = queue_logical_block_size(q);
+ long block = (long)blk_rq_pos(rq) / (hard_sect >> 9);
+ unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9);
memset(rq->cmd, 0, BLK_MAX_CDB);
@@ -1599,7 +1543,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
nslots = ide_cdrom_probe_capabilities(drive);
- blk_queue_hardsect_size(q, CD_FRAMESIZE);
+ blk_queue_logical_block_size(q, CD_FRAMESIZE);
if (ide_cdrom_register(drive, nslots)) {
printk(KERN_ERR PFX "%s: %s failed to register device with the"
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 1d97101099ce..93a3cf1b0f3f 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -87,10 +87,6 @@ struct cdrom_info {
struct atapi_toc *toc;
- /* The result of the last successful request sense command
- on this device. */
- struct request_sense sense_data;
-
u8 max_speed; /* Max speed of the drive. */
u8 current_speed; /* Current speed of the drive. */
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index 9e47f3529d55..527908ff298c 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -155,6 +155,7 @@ static const struct ide_port_info idecs_port_info = {
.port_ops = &idecs_port_ops,
.host_flags = IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
+ .chipset = ide_pci,
};
static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
@@ -163,7 +164,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
struct ide_host *host;
ide_hwif_t *hwif;
int i, rc;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
if (!request_region(io, 8, DRV_NAME)) {
printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
@@ -181,10 +182,9 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
memset(&hw, 0, sizeof(hw));
ide_std_init_ports(&hw, io, ctl);
hw.irq = irq;
- hw.chipset = ide_pci;
hw.dev = &handle->dev;
- rc = ide_host_add(&idecs_port_info, hws, &host);
+ rc = ide_host_add(&idecs_port_info, hws, 1, &host);
if (rc)
goto out_release;
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index a9fbe2c31210..762fae296f62 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -82,7 +82,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
sector_t block)
{
ide_hwif_t *hwif = drive->hwif;
- u16 nsectors = (u16)rq->nr_sectors;
+ u16 nsectors = (u16)blk_rq_sectors(rq);
u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48);
u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
struct ide_cmd cmd;
@@ -90,7 +90,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
ide_startstop_t rc;
if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) {
- if (block + rq->nr_sectors > 1ULL << 28)
+ if (block + blk_rq_sectors(rq) > 1ULL << 28)
dma = 0;
else
lba48 = 0;
@@ -195,9 +195,9 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
ledtrig_ide_activity();
- pr_debug("%s: %sing: block=%llu, sectors=%lu, buffer=0x%08lx\n",
+ pr_debug("%s: %sing: block=%llu, sectors=%u, buffer=0x%08lx\n",
drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
- (unsigned long long)block, rq->nr_sectors,
+ (unsigned long long)block, blk_rq_sectors(rq),
(unsigned long)rq->buffer);
if (hwif->rw_disk)
@@ -411,7 +411,6 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
cmd->protocol = ATA_PROT_NODATA;
rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
- rq->cmd_flags |= REQ_SOFTBARRIER;
rq->special = cmd;
}
@@ -429,14 +428,14 @@ static int set_multcount(ide_drive_t *drive, int arg)
if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff))
return -EINVAL;
- if (drive->special.b.set_multmode)
+ if (drive->special_flags & IDE_SFLAG_SET_MULTMODE)
return -EBUSY;
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
drive->mult_req = arg;
- drive->special.b.set_multmode = 1;
+ drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
error = blk_execute_rq(drive->queue, NULL, rq, 0);
blk_put_request(rq);
@@ -640,7 +639,7 @@ static void ide_disk_setup(ide_drive_t *drive)
}
printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
- q->max_sectors / 2);
+ queue_max_sectors(q) / 2);
if (ata_id_is_ssd(id))
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index a0b8cab1d9a6..001f68f0bb28 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -103,7 +103,7 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive)
ide_finish_cmd(drive, cmd, stat);
else
ide_complete_rq(drive, 0,
- cmd->rq->nr_sectors << 9);
+ blk_rq_sectors(cmd->rq) << 9);
return ide_stopped;
}
printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n",
@@ -510,23 +510,11 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
/*
* un-busy drive etc and make sure request is sane
*/
-
rq = hwif->rq;
- if (!rq)
- goto out;
-
- hwif->rq = NULL;
-
- rq->errors = 0;
-
- if (!rq->bio)
- goto out;
-
- rq->sector = rq->bio->bi_sector;
- rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
- rq->hard_cur_sectors = rq->current_nr_sectors;
- rq->buffer = bio_data(rq->bio);
-out:
+ if (rq) {
+ hwif->rq = NULL;
+ rq->errors = 0;
+ }
return ret;
}
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index 5d5fb961b5ce..39d589254d41 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -52,7 +52,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
}
if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
- drive->special.b.recalibrate = 1;
+ drive->special_flags |= IDE_SFLAG_RECALIBRATE;
++rq->errors;
@@ -268,9 +268,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
{
int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1;
- drive->special.all = 0;
- drive->special.b.set_geometry = legacy;
- drive->special.b.recalibrate = legacy;
+ drive->special_flags =
+ legacy ? (IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE) : 0;
drive->mult_count = 0;
drive->dev_flags &= ~IDE_DFLAG_PARKED;
@@ -280,7 +279,7 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
drive->mult_req = 0;
if (drive->mult_req != drive->mult_count)
- drive->special.b.set_multmode = 1;
+ drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
}
static void pre_reset(ide_drive_t *drive)
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 2b4868d95f8b..650981758f15 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -134,13 +134,17 @@ static ide_startstop_t ide_floppy_issue_pc(ide_drive_t *drive,
drive->pc = pc;
if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) {
+ unsigned int done = blk_rq_bytes(drive->hwif->rq);
+
if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR))
ide_floppy_report_error(floppy, pc);
+
/* Giving up */
pc->error = IDE_DRV_ERROR_GENERAL;
drive->failed_pc = NULL;
drive->pc_callback(drive, 0);
+ ide_complete_rq(drive, -EIO, done);
return ide_stopped;
}
@@ -190,7 +194,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
{
struct ide_disk_obj *floppy = drive->driver_data;
int block = sector / floppy->bs_factor;
- int blocks = rq->nr_sectors / floppy->bs_factor;
+ int blocks = blk_rq_sectors(rq) / floppy->bs_factor;
int cmd = rq_data_dir(rq);
ide_debug_log(IDE_DBG_FUNC, "block: %d, blocks: %d", block, blocks);
@@ -216,16 +220,14 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy,
ide_init_pc(pc);
memcpy(pc->c, rq->cmd, sizeof(pc->c));
pc->rq = rq;
- if (rq->data_len && rq_data_dir(rq) == WRITE)
- pc->flags |= PC_FLAG_WRITING;
- pc->buf = rq->data;
- if (rq->bio)
+ if (blk_rq_bytes(rq)) {
pc->flags |= PC_FLAG_DMA_OK;
- /*
- * possibly problematic, doesn't look like ide-floppy correctly
- * handled scattered requests if dma fails...
- */
- pc->req_xfer = pc->buf_size = rq->data_len;
+ if (rq_data_dir(rq) == WRITE)
+ pc->flags |= PC_FLAG_WRITING;
+ }
+ /* pio will be performed by ide_pio_bytes() which handles sg fine */
+ pc->buf = NULL;
+ pc->req_xfer = pc->buf_size = blk_rq_bytes(rq);
}
static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
@@ -257,16 +259,16 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
goto out_end;
}
if (blk_fs_request(rq)) {
- if (((long)rq->sector % floppy->bs_factor) ||
- (rq->nr_sectors % floppy->bs_factor)) {
+ if (((long)blk_rq_pos(rq) % floppy->bs_factor) ||
+ (blk_rq_sectors(rq) % floppy->bs_factor)) {
printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
drive->name);
goto out_end;
}
pc = &floppy->queued_pc;
idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
- } else if (blk_special_request(rq)) {
- pc = (struct ide_atapi_pc *) rq->buffer;
+ } else if (blk_special_request(rq) || blk_sense_request(rq)) {
+ pc = (struct ide_atapi_pc *)rq->special;
} else if (blk_pc_request(rq)) {
pc = &floppy->queued_pc;
idefloppy_blockpc_cmd(floppy, pc, rq);
@@ -275,6 +277,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
goto out_end;
}
+ ide_prep_sense(drive, rq);
+
memset(&cmd, 0, sizeof(cmd));
if (rq_data_dir(rq))
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index 7812ca0be13b..54d7c4685d23 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -29,6 +29,7 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports");
static const struct ide_port_info ide_generic_port_info = {
.host_flags = IDE_HFLAG_NO_DMA,
+ .chipset = ide_generic,
};
#ifdef CONFIG_ARM
@@ -85,7 +86,7 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary)
static int __init ide_generic_init(void)
{
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
unsigned long io_addr;
int i, rc = 0, primary = 0, secondary = 0;
@@ -132,9 +133,7 @@ static int __init ide_generic_init(void)
#else
hw.irq = legacy_irqs[i];
#endif
- hw.chipset = ide_generic;
-
- rc = ide_host_add(&ide_generic_port_info, hws, NULL);
+ rc = ide_host_add(&ide_generic_port_info, hws, 1, NULL);
if (rc) {
release_region(io_addr + 0x206, 1);
release_region(io_addr, 8);
diff --git a/drivers/ide/ide-h8300.c b/drivers/ide/ide-h8300.c
index c06ebdc4a130..520f42c5445a 100644
--- a/drivers/ide/ide-h8300.c
+++ b/drivers/ide/ide-h8300.c
@@ -64,26 +64,26 @@ static const struct ide_tp_ops h8300_tp_ops = {
#define H8300_IDE_GAP (2)
-static inline void hw_setup(hw_regs_t *hw)
+static inline void hw_setup(struct ide_hw *hw)
{
int i;
- memset(hw, 0, sizeof(hw_regs_t));
+ memset(hw, 0, sizeof(*hw));
for (i = 0; i <= 7; i++)
hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i;
hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT;
hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ;
- hw->chipset = ide_generic;
}
static const struct ide_port_info h8300_port_info = {
.tp_ops = &h8300_tp_ops,
.host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA,
+ .chipset = ide_generic,
};
static int __init h8300_ide_init(void)
{
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
@@ -96,7 +96,7 @@ static int __init h8300_ide_init(void)
hw_setup(&hw);
- return ide_host_add(&h8300_port_info, hws, NULL);
+ return ide_host_add(&h8300_port_info, hws, 1, NULL);
out_busy:
printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n");
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 35dc38d3b2c5..18f5f3beded3 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -116,9 +116,9 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
unsigned int ide_rq_bytes(struct request *rq)
{
if (blk_pc_request(rq))
- return rq->data_len;
+ return blk_rq_bytes(rq);
else
- return rq->hard_cur_sectors << 9;
+ return blk_rq_cur_sectors(rq) << 9;
}
EXPORT_SYMBOL_GPL(ide_rq_bytes);
@@ -133,7 +133,7 @@ int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes)
* and complete the whole request right now
*/
if (blk_noretry_request(rq) && error <= 0)
- nr_bytes = rq->hard_nr_sectors << 9;
+ nr_bytes = blk_rq_sectors(rq) << 9;
rc = ide_end_rq(drive, rq, error, nr_bytes);
if (rc == 0)
@@ -184,29 +184,42 @@ static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
tf->command = ATA_CMD_SET_MULTI;
}
-static ide_startstop_t ide_disk_special(ide_drive_t *drive)
+/**
+ * do_special - issue some special commands
+ * @drive: drive the command is for
+ *
+ * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS,
+ * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive.
+ */
+
+static ide_startstop_t do_special(ide_drive_t *drive)
{
- special_t *s = &drive->special;
struct ide_cmd cmd;
+#ifdef DEBUG
+ printk(KERN_DEBUG "%s: %s: 0x%02x\n", drive->name, __func__,
+ drive->special_flags);
+#endif
+ if (drive->media != ide_disk) {
+ drive->special_flags = 0;
+ drive->mult_req = 0;
+ return ide_stopped;
+ }
+
memset(&cmd, 0, sizeof(cmd));
cmd.protocol = ATA_PROT_NODATA;
- if (s->b.set_geometry) {
- s->b.set_geometry = 0;
+ if (drive->special_flags & IDE_SFLAG_SET_GEOMETRY) {
+ drive->special_flags &= ~IDE_SFLAG_SET_GEOMETRY;
ide_tf_set_specify_cmd(drive, &cmd.tf);
- } else if (s->b.recalibrate) {
- s->b.recalibrate = 0;
+ } else if (drive->special_flags & IDE_SFLAG_RECALIBRATE) {
+ drive->special_flags &= ~IDE_SFLAG_RECALIBRATE;
ide_tf_set_restore_cmd(drive, &cmd.tf);
- } else if (s->b.set_multmode) {
- s->b.set_multmode = 0;
+ } else if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) {
+ drive->special_flags &= ~IDE_SFLAG_SET_MULTMODE;
ide_tf_set_setmult_cmd(drive, &cmd.tf);
- } else if (s->all) {
- int special = s->all;
- s->all = 0;
- printk(KERN_ERR "%s: bad special flag: 0x%02x\n", drive->name, special);
- return ide_stopped;
- }
+ } else
+ BUG();
cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
@@ -217,45 +230,13 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive)
return ide_started;
}
-/**
- * do_special - issue some special commands
- * @drive: drive the command is for
- *
- * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS,
- * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive.
- *
- * It used to do much more, but has been scaled back.
- */
-
-static ide_startstop_t do_special (ide_drive_t *drive)
-{
- special_t *s = &drive->special;
-
-#ifdef DEBUG
- printk("%s: do_special: 0x%02x\n", drive->name, s->all);
-#endif
- if (drive->media == ide_disk)
- return ide_disk_special(drive);
-
- s->all = 0;
- drive->mult_req = 0;
- return ide_stopped;
-}
-
void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct scatterlist *sg = hwif->sg_table;
struct request *rq = cmd->rq;
- if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
- sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE);
- cmd->sg_nents = 1;
- } else if (!rq->bio) {
- sg_init_one(sg, rq->data, rq->data_len);
- cmd->sg_nents = 1;
- } else
- cmd->sg_nents = blk_rq_map_sg(drive->queue, rq, sg);
+ cmd->sg_nents = blk_rq_map_sg(drive->queue, rq, sg);
}
EXPORT_SYMBOL_GPL(ide_map_sg);
@@ -286,7 +267,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
if (cmd) {
if (cmd->protocol == ATA_PROT_PIO) {
- ide_init_sg_cmd(cmd, rq->nr_sectors << 9);
+ ide_init_sg_cmd(cmd, blk_rq_sectors(rq) << 9);
ide_map_sg(drive, cmd);
}
@@ -358,7 +339,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
printk(KERN_ERR "%s: drive not ready for command\n", drive->name);
return startstop;
}
- if (!drive->special.all) {
+
+ if (drive->special_flags == 0) {
struct ide_driver *drv;
/*
@@ -371,7 +353,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
return execute_drive_cmd(drive, rq);
else if (blk_pm_request(rq)) {
- struct request_pm_state *pm = rq->data;
+ struct request_pm_state *pm = rq->special;
#ifdef DEBUG_PM
printk("%s: start_power_step(step: %d)\n",
drive->name, pm->pm_step);
@@ -394,7 +376,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
drv = *(struct ide_driver **)rq->rq_disk->private_data;
- return drv->do_request(drive, rq, rq->sector);
+ return drv->do_request(drive, rq, blk_rq_pos(rq));
}
return do_special(drive);
kill_rq:
@@ -484,6 +466,9 @@ void do_ide_request(struct request_queue *q)
spin_unlock_irq(q->queue_lock);
+ /* HLD do_request() callback might sleep, make sure it's okay */
+ might_sleep();
+
if (ide_lock_host(host, hwif))
goto plug_device_2;
@@ -491,10 +476,10 @@ void do_ide_request(struct request_queue *q)
if (!ide_lock_port(hwif)) {
ide_hwif_t *prev_port;
+
+ WARN_ON_ONCE(hwif->rq);
repeat:
prev_port = hwif->host->cur_port;
- hwif->rq = NULL;
-
if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
time_after(drive->sleep, jiffies)) {
ide_unlock_port(hwif);
@@ -523,7 +508,9 @@ repeat:
* we know that the queue isn't empty, but this can happen
* if the q->prep_rq_fn() decides to kill a request
*/
- rq = elv_next_request(drive->queue);
+ if (!rq)
+ rq = blk_fetch_request(drive->queue);
+
spin_unlock_irq(q->queue_lock);
spin_lock_irq(&hwif->lock);
@@ -535,7 +522,7 @@ repeat:
/*
* Sanity: don't accept a request that isn't a PM request
* if we are currently power managed. This is very important as
- * blk_stop_queue() doesn't prevent the elv_next_request()
+ * blk_stop_queue() doesn't prevent the blk_fetch_request()
* above to return us whatever is in the queue. Since we call
* ide_do_request() ourselves, we end up taking requests while
* the queue is blocked...
@@ -559,8 +546,11 @@ repeat:
startstop = start_request(drive, rq);
spin_lock_irq(&hwif->lock);
- if (startstop == ide_stopped)
+ if (startstop == ide_stopped) {
+ rq = hwif->rq;
+ hwif->rq = NULL;
goto repeat;
+ }
} else
goto plug_device;
out:
@@ -576,18 +566,24 @@ plug_device:
plug_device_2:
spin_lock_irq(q->queue_lock);
+ if (rq)
+ blk_requeue_request(q, rq);
if (!elv_queue_empty(q))
blk_plug_device(q);
}
-static void ide_plug_device(ide_drive_t *drive)
+static void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq)
{
struct request_queue *q = drive->queue;
unsigned long flags;
spin_lock_irqsave(q->queue_lock, flags);
+
+ if (rq)
+ blk_requeue_request(q, rq);
if (!elv_queue_empty(q))
blk_plug_device(q);
+
spin_unlock_irqrestore(q->queue_lock, flags);
}
@@ -636,6 +632,7 @@ void ide_timer_expiry (unsigned long data)
unsigned long flags;
int wait = -1;
int plug_device = 0;
+ struct request *uninitialized_var(rq_in_flight);
spin_lock_irqsave(&hwif->lock, flags);
@@ -696,7 +693,9 @@ void ide_timer_expiry (unsigned long data)
}
spin_lock_irq(&hwif->lock);
enable_irq(hwif->irq);
- if (startstop == ide_stopped) {
+ if (startstop == ide_stopped && hwif->polling == 0) {
+ rq_in_flight = hwif->rq;
+ hwif->rq = NULL;
ide_unlock_port(hwif);
plug_device = 1;
}
@@ -705,7 +704,7 @@ void ide_timer_expiry (unsigned long data)
if (plug_device) {
ide_unlock_host(hwif->host);
- ide_plug_device(drive);
+ ide_requeue_and_plug(drive, rq_in_flight);
}
}
@@ -791,6 +790,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
ide_startstop_t startstop;
irqreturn_t irq_ret = IRQ_NONE;
int plug_device = 0;
+ struct request *uninitialized_var(rq_in_flight);
if (host->host_flags & IDE_HFLAG_SERIALIZE) {
if (hwif != host->cur_port)
@@ -868,8 +868,10 @@ irqreturn_t ide_intr (int irq, void *dev_id)
* same irq as is currently being serviced here, and Linux
* won't allow another of the same (on any CPU) until we return.
*/
- if (startstop == ide_stopped) {
+ if (startstop == ide_stopped && hwif->polling == 0) {
BUG_ON(hwif->handler);
+ rq_in_flight = hwif->rq;
+ hwif->rq = NULL;
ide_unlock_port(hwif);
plug_device = 1;
}
@@ -879,7 +881,7 @@ out:
out_early:
if (plug_device) {
ide_unlock_host(hwif->host);
- ide_plug_device(drive);
+ ide_requeue_and_plug(drive, rq_in_flight);
}
return irq_ret;
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index c1c25ebbaa1f..5991b23793f2 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -231,7 +231,6 @@ static int generic_drive_reset(ide_drive_t *drive)
rq->cmd_type = REQ_TYPE_SPECIAL;
rq->cmd_len = 1;
rq->cmd[0] = REQ_DRIVE_RESET;
- rq->cmd_flags |= REQ_SOFTBARRIER;
if (blk_execute_rq(drive->queue, NULL, rq, 1))
ret = rq->errors;
blk_put_request(rq);
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index c19a221b1e18..06fe002116ec 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -206,8 +206,6 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
/*
* Early UDMA66 devices don't set bit14 to 1, only bit13 is valid.
- * We list them here and depend on the device side cable detection for them.
- *
* Some optical devices with the buggy firmwares have the same problem.
*/
static const struct drive_list_entry ivb_list[] = {
@@ -251,10 +249,25 @@ u8 eighty_ninty_three(ide_drive_t *drive)
* - force bit13 (80c cable present) check also for !ivb devices
* (unless the slave device is pre-ATA3)
*/
- if ((id[ATA_ID_HW_CONFIG] & 0x4000) ||
- (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000)))
+ if (id[ATA_ID_HW_CONFIG] & 0x4000)
return 1;
+ if (ivb) {
+ const char *model = (char *)&id[ATA_ID_PROD];
+
+ if (strstr(model, "TSSTcorp CDDVDW SH-S202")) {
+ /*
+ * These ATAPI devices always report 80c cable
+ * so we have to depend on the host in this case.
+ */
+ if (hwif->cbl == ATA_CBL_PATA80)
+ return 1;
+ } else {
+ /* Depend on the device side cable detection. */
+ if (id[ATA_ID_HW_CONFIG] & 0x2000)
+ return 1;
+ }
+ }
no_80w:
if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED)
return 0;
diff --git a/drivers/ide/ide-legacy.c b/drivers/ide/ide-legacy.c
index 8c5dcbf22547..b9654a7bb7be 100644
--- a/drivers/ide/ide-legacy.c
+++ b/drivers/ide/ide-legacy.c
@@ -1,7 +1,7 @@
#include <linux/kernel.h>
#include <linux/ide.h>
-static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
+static void ide_legacy_init_one(struct ide_hw **hws, struct ide_hw *hw,
u8 port_no, const struct ide_port_info *d,
unsigned long config)
{
@@ -33,7 +33,6 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
ide_std_init_ports(hw, base, ctl);
hw->irq = irq;
- hw->chipset = d->chipset;
hw->config = config;
hws[port_no] = hw;
@@ -41,7 +40,7 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
{
- hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[2], *hws[] = { NULL, NULL };
memset(&hw, 0, sizeof(hw));
@@ -53,6 +52,6 @@ int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
(d->host_flags & IDE_HFLAG_SINGLE))
return -ENOENT;
- return ide_host_add(d, hws, NULL);
+ return ide_host_add(d, hws, 2, NULL);
}
EXPORT_SYMBOL_GPL(ide_legacy_device_add);
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 56ff8c46c7d1..e386a32dc9ba 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -31,24 +31,6 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
blk_queue_bounce_limit(drive->queue, addr);
}
-static void ide_dump_opcode(ide_drive_t *drive)
-{
- struct request *rq = drive->hwif->rq;
- struct ide_cmd *cmd = NULL;
-
- if (!rq)
- return;
-
- if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
- cmd = rq->special;
-
- printk(KERN_ERR "ide: failed opcode was: ");
- if (cmd == NULL)
- printk(KERN_CONT "unknown\n");
- else
- printk(KERN_CONT "0x%02x\n", cmd->tf.command);
-}
-
u64 ide_get_lba_addr(struct ide_cmd *cmd, int lba48)
{
struct ide_taskfile *tf = &cmd->tf;
@@ -91,7 +73,7 @@ static void ide_dump_sector(ide_drive_t *drive)
static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
{
- printk(KERN_ERR "{ ");
+ printk(KERN_CONT "{ ");
if (err & ATA_ABORTED)
printk(KERN_CONT "DriveStatusError ");
if (err & ATA_ICRC)
@@ -114,14 +96,14 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
if (rq)
printk(KERN_CONT ", sector=%llu",
- (unsigned long long)rq->sector);
+ (unsigned long long)blk_rq_pos(rq));
}
printk(KERN_CONT "\n");
}
static void ide_dump_atapi_error(ide_drive_t *drive, u8 err)
{
- printk(KERN_ERR "{ ");
+ printk(KERN_CONT "{ ");
if (err & ATAPI_ILI)
printk(KERN_CONT "IllegalLengthIndication ");
if (err & ATAPI_EOM)
@@ -179,7 +161,10 @@ u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
else
ide_dump_atapi_error(drive, err);
}
- ide_dump_opcode(drive);
+
+ printk(KERN_ERR "%s: possibly failed opcode: 0x%02x\n",
+ drive->name, drive->hwif->cmd.tf.command);
+
return err;
}
EXPORT_SYMBOL(ide_dump_status);
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 310d03f2b5b7..a914023d6d03 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -24,11 +24,8 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
start_queue = 1;
spin_unlock_irq(&hwif->lock);
- if (start_queue) {
- spin_lock_irq(q->queue_lock);
- blk_start_queueing(q);
- spin_unlock_irq(q->queue_lock);
- }
+ if (start_queue)
+ blk_run_queue(q);
return;
}
spin_unlock_irq(&hwif->lock);
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 0d8a151c0a01..c14ca144cffe 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -3,11 +3,11 @@
int generic_ide_suspend(struct device *dev, pm_message_t mesg)
{
- ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
+ ide_drive_t *drive = dev_get_drvdata(dev);
+ ide_drive_t *pair = ide_get_pair_dev(drive);
ide_hwif_t *hwif = drive->hwif;
struct request *rq;
struct request_pm_state rqpm;
- struct ide_cmd cmd;
int ret;
/* call ACPI _GTM only once */
@@ -15,11 +15,9 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
ide_acpi_get_timing(hwif);
memset(&rqpm, 0, sizeof(rqpm));
- memset(&cmd, 0, sizeof(cmd));
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_PM_SUSPEND;
- rq->special = &cmd;
- rq->data = &rqpm;
+ rq->special = &rqpm;
rqpm.pm_step = IDE_PM_START_SUSPEND;
if (mesg.event == PM_EVENT_PRETHAW)
mesg.event = PM_EVENT_FREEZE;
@@ -37,11 +35,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
int generic_ide_resume(struct device *dev)
{
- ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
+ ide_drive_t *drive = dev_get_drvdata(dev);
+ ide_drive_t *pair = ide_get_pair_dev(drive);
ide_hwif_t *hwif = drive->hwif;
struct request *rq;
struct request_pm_state rqpm;
- struct ide_cmd cmd;
int err;
/* call ACPI _PS0 / _STM only once */
@@ -53,12 +51,10 @@ int generic_ide_resume(struct device *dev)
ide_acpi_exec_tfs(drive);
memset(&rqpm, 0, sizeof(rqpm));
- memset(&cmd, 0, sizeof(cmd));
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_PM_RESUME;
rq->cmd_flags |= REQ_PREEMPT;
- rq->special = &cmd;
- rq->data = &rqpm;
+ rq->special = &rqpm;
rqpm.pm_step = IDE_PM_START_RESUME;
rqpm.pm_state = PM_EVENT_ON;
@@ -77,7 +73,7 @@ int generic_ide_resume(struct device *dev)
void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
{
- struct request_pm_state *pm = rq->data;
+ struct request_pm_state *pm = rq->special;
#ifdef DEBUG_PM
printk(KERN_INFO "%s: complete_power_step(step: %d)\n",
@@ -107,10 +103,8 @@ void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
{
- struct request_pm_state *pm = rq->data;
- struct ide_cmd *cmd = rq->special;
-
- memset(cmd, 0, sizeof(*cmd));
+ struct request_pm_state *pm = rq->special;
+ struct ide_cmd cmd = { };
switch (pm->pm_step) {
case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
@@ -123,12 +117,12 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
return ide_stopped;
}
if (ata_id_flush_ext_enabled(drive->id))
- cmd->tf.command = ATA_CMD_FLUSH_EXT;
+ cmd.tf.command = ATA_CMD_FLUSH_EXT;
else
- cmd->tf.command = ATA_CMD_FLUSH;
+ cmd.tf.command = ATA_CMD_FLUSH;
goto out_do_tf;
case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
- cmd->tf.command = ATA_CMD_STANDBYNOW1;
+ cmd.tf.command = ATA_CMD_STANDBYNOW1;
goto out_do_tf;
case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
ide_set_max_pio(drive);
@@ -141,7 +135,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
ide_complete_power_step(drive, rq);
return ide_stopped;
case IDE_PM_IDLE: /* Resume step 2 (idle) */
- cmd->tf.command = ATA_CMD_IDLEIMMEDIATE;
+ cmd.tf.command = ATA_CMD_IDLEIMMEDIATE;
goto out_do_tf;
case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
/*
@@ -163,11 +157,11 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
return ide_stopped;
out_do_tf:
- cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
- cmd->valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
- cmd->protocol = ATA_PROT_NODATA;
+ cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
+ cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
+ cmd.protocol = ATA_PROT_NODATA;
- return do_rw_taskfile(drive, cmd);
+ return do_rw_taskfile(drive, &cmd);
}
/**
@@ -181,7 +175,7 @@ out_do_tf:
void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
{
struct request_queue *q = drive->queue;
- struct request_pm_state *pm = rq->data;
+ struct request_pm_state *pm = rq->special;
unsigned long flags;
ide_complete_power_step(drive, rq);
@@ -207,7 +201,7 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
{
- struct request_pm_state *pm = rq->data;
+ struct request_pm_state *pm = rq->special;
if (blk_pm_suspend_request(rq) &&
pm->pm_step == IDE_PM_START_SUSPEND)
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index 6e80b774e88a..017b1df3b805 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -29,6 +29,7 @@ static struct pnp_device_id idepnp_devices[] = {
static const struct ide_port_info ide_pnp_port_info = {
.host_flags = IDE_HFLAG_NO_DMA,
+ .chipset = ide_generic,
};
static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
@@ -36,7 +37,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
struct ide_host *host;
unsigned long base, ctl;
int rc;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
@@ -62,9 +63,8 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
memset(&hw, 0, sizeof(hw));
ide_std_init_ports(&hw, base, ctl);
hw.irq = pnp_irq(dev, 0);
- hw.chipset = ide_generic;
- rc = ide_host_add(&ide_pnp_port_info, hws, &host);
+ rc = ide_host_add(&ide_pnp_port_info, hws, 1, &host);
if (rc)
goto out;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 7f264ed1141b..a5ad8481c7f7 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -97,7 +97,7 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
drive->mult_req = id[ATA_ID_MULTSECT] & 0xff;
if (drive->mult_req)
- drive->special.b.set_multmode = 1;
+ drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
}
}
@@ -295,7 +295,7 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
- if (ide_busy_sleep(hwif, timeout, use_altstatus))
+ if (ide_busy_sleep(drive, timeout, use_altstatus))
return 1;
/* wait for IRQ and ATA_DRQ */
@@ -316,8 +316,9 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
return rc;
}
-int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
+int ide_busy_sleep(ide_drive_t *drive, unsigned long timeout, int altstatus)
{
+ ide_hwif_t *hwif = drive->hwif;
u8 stat;
timeout += jiffies;
@@ -330,6 +331,8 @@ int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
return 0;
} while (time_before(jiffies, timeout));
+ printk(KERN_ERR "%s: timeout in %s\n", drive->name, __func__);
+
return 1; /* drive timed-out */
}
@@ -420,7 +423,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
tp_ops->dev_select(drive);
msleep(50);
tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
- (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
+ (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0);
rc = ide_dev_read_id(drive, cmd, id);
}
@@ -550,7 +553,7 @@ static int ide_register_port(ide_hwif_t *hwif)
/* register with global device tree */
dev_set_name(&hwif->gendev, hwif->name);
- hwif->gendev.driver_data = hwif;
+ dev_set_drvdata(&hwif->gendev, hwif);
if (hwif->gendev.parent == NULL)
hwif->gendev.parent = hwif->dev;
hwif->gendev.release = hwif_release_dev;
@@ -999,9 +1002,9 @@ static void hwif_register_devices(ide_hwif_t *hwif)
int ret;
dev_set_name(dev, "%u.%u", hwif->index, i);
+ dev_set_drvdata(dev, drive);
dev->parent = &hwif->gendev;
dev->bus = &ide_bus_type;
- dev->driver_data = drive;
dev->release = drive_release_dev;
ret = device_register(dev);
@@ -1032,6 +1035,15 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
if (port_ops && port_ops->init_dev)
port_ops->init_dev(drive);
}
+
+ ide_port_for_each_dev(i, drive, hwif) {
+ /*
+ * default to PIO Mode 0 before we figure out
+ * the most suited mode for the attached device
+ */
+ if (port_ops && port_ops->set_pio_mode)
+ port_ops->set_pio_mode(drive, 0);
+ }
}
static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
@@ -1039,8 +1051,7 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
{
hwif->channel = port;
- if (d->chipset)
- hwif->chipset = d->chipset;
+ hwif->chipset = d->chipset ? d->chipset : ide_pci;
if (d->init_iops)
d->init_iops(hwif);
@@ -1129,8 +1140,8 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
drive->hwif = hwif;
drive->ready_stat = ATA_DRDY;
drive->bad_wstat = BAD_W_STAT;
- drive->special.b.recalibrate = 1;
- drive->special.b.set_geometry = 1;
+ drive->special_flags = IDE_SFLAG_RECALIBRATE |
+ IDE_SFLAG_SET_GEOMETRY;
drive->name[0] = 'h';
drive->name[1] = 'd';
drive->name[2] = 'a' + j;
@@ -1165,11 +1176,10 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
ide_port_init_devices_data(hwif);
}
-static void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
+static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw)
{
memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
hwif->irq = hw->irq;
- hwif->chipset = hw->chipset;
hwif->dev = hw->dev;
hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
hwif->ack_intr = hw->ack_intr;
@@ -1254,7 +1264,8 @@ out_nomem:
return -ENOMEM;
}
-struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
+struct ide_host *ide_host_alloc(const struct ide_port_info *d,
+ struct ide_hw **hws, unsigned int n_ports)
{
struct ide_host *host;
struct device *dev = hws[0] ? hws[0]->dev : NULL;
@@ -1265,7 +1276,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
if (host == NULL)
return NULL;
- for (i = 0; i < MAX_HOST_PORTS; i++) {
+ for (i = 0; i < n_ports; i++) {
ide_hwif_t *hwif;
int idx;
@@ -1341,7 +1352,7 @@ static void ide_disable_port(ide_hwif_t *hwif)
}
int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
- hw_regs_t **hws)
+ struct ide_hw **hws)
{
ide_hwif_t *hwif, *mate = NULL;
int i, j = 0;
@@ -1435,13 +1446,13 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
}
EXPORT_SYMBOL_GPL(ide_host_register);
-int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws,
- struct ide_host **hostp)
+int ide_host_add(const struct ide_port_info *d, struct ide_hw **hws,
+ unsigned int n_ports, struct ide_host **hostp)
{
struct ide_host *host;
int rc;
- host = ide_host_alloc(d, hws);
+ host = ide_host_alloc(d, hws, n_ports);
if (host == NULL)
return -ENOMEM;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 3a53e0834cf7..58baca8b48ff 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -131,13 +131,6 @@ enum {
IDETAPE_DIR_WRITE = (1 << 2),
};
-struct idetape_bh {
- u32 b_size;
- atomic_t b_count;
- struct idetape_bh *b_reqnext;
- char *b_data;
-};
-
/* Tape door status */
#define DOOR_UNLOCKED 0
#define DOOR_LOCKED 1
@@ -219,18 +212,12 @@ typedef struct ide_tape_obj {
/* Data buffer size chosen based on the tape's recommendation */
int buffer_size;
- /* merge buffer */
- struct idetape_bh *merge_bh;
- /* size of the merge buffer */
- int merge_bh_size;
- /* pointer to current buffer head within the merge buffer */
- struct idetape_bh *bh;
- char *b_data;
- int b_count;
-
- int pages_per_buffer;
- /* Wasted space in each stage */
- int excess_bh_size;
+ /* Staging buffer of buffer_size bytes */
+ void *buf;
+ /* The read/write cursor */
+ void *cur;
+ /* The number of valid bytes in buf */
+ size_t valid;
/* Measures average tape speed */
unsigned long avg_time;
@@ -297,84 +284,6 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
return tape;
}
-static int idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
- unsigned int bcount)
-{
- struct idetape_bh *bh = pc->bh;
- int count;
-
- while (bcount) {
- if (bh == NULL)
- break;
- count = min(
- (unsigned int)(bh->b_size - atomic_read(&bh->b_count)),
- bcount);
- drive->hwif->tp_ops->input_data(drive, NULL, bh->b_data +
- atomic_read(&bh->b_count), count);
- bcount -= count;
- atomic_add(count, &bh->b_count);
- if (atomic_read(&bh->b_count) == bh->b_size) {
- bh = bh->b_reqnext;
- if (bh)
- atomic_set(&bh->b_count, 0);
- }
- }
-
- pc->bh = bh;
-
- return bcount;
-}
-
-static int idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
- unsigned int bcount)
-{
- struct idetape_bh *bh = pc->bh;
- int count;
-
- while (bcount) {
- if (bh == NULL)
- break;
- count = min((unsigned int)pc->b_count, (unsigned int)bcount);
- drive->hwif->tp_ops->output_data(drive, NULL, pc->b_data, count);
- bcount -= count;
- pc->b_data += count;
- pc->b_count -= count;
- if (!pc->b_count) {
- bh = bh->b_reqnext;
- pc->bh = bh;
- if (bh) {
- pc->b_data = bh->b_data;
- pc->b_count = atomic_read(&bh->b_count);
- }
- }
- }
-
- return bcount;
-}
-
-static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc)
-{
- struct idetape_bh *bh = pc->bh;
- int count;
- unsigned int bcount = pc->xferred;
-
- if (pc->flags & PC_FLAG_WRITING)
- return;
- while (bcount) {
- if (bh == NULL) {
- printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
- __func__);
- return;
- }
- count = min((unsigned int)bh->b_size, (unsigned int)bcount);
- atomic_set(&bh->b_count, count);
- if (atomic_read(&bh->b_count) == bh->b_size)
- bh = bh->b_reqnext;
- bcount -= count;
- }
- pc->bh = bh;
-}
-
/*
* called on each failed packet command retry to analyze the request sense. We
* currently do not utilize this information.
@@ -392,12 +301,10 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
pc->c[0], tape->sense_key, tape->asc, tape->ascq);
/* Correct pc->xferred by asking the tape. */
- if (pc->flags & PC_FLAG_DMA_ERROR) {
+ if (pc->flags & PC_FLAG_DMA_ERROR)
pc->xferred = pc->req_xfer -
tape->blk_size *
get_unaligned_be32(&sense[3]);
- idetape_update_buffers(drive, pc);
- }
/*
* If error was the result of a zero-length read or write command,
@@ -436,29 +343,6 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
}
}
-/* Free data buffers completely. */
-static void ide_tape_kfree_buffer(idetape_tape_t *tape)
-{
- struct idetape_bh *prev_bh, *bh = tape->merge_bh;
-
- while (bh) {
- u32 size = bh->b_size;
-
- while (size) {
- unsigned int order = fls(size >> PAGE_SHIFT)-1;
-
- if (bh->b_data)
- free_pages((unsigned long)bh->b_data, order);
-
- size &= (order-1);
- bh->b_data += (1 << order) * PAGE_SIZE;
- }
- prev_bh = bh;
- bh = bh->b_reqnext;
- kfree(prev_bh);
- }
-}
-
static void ide_tape_handle_dsc(ide_drive_t *);
static int ide_tape_callback(ide_drive_t *drive, int dsc)
@@ -496,7 +380,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
}
tape->first_frame += blocks;
- rq->current_nr_sectors -= blocks;
+ rq->resid_len -= blocks * tape->blk_size;
if (pc->error) {
uptodate = 0;
@@ -558,19 +442,6 @@ static void ide_tape_handle_dsc(ide_drive_t *drive)
idetape_postpone_request(drive);
}
-static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
- unsigned int bcount, int write)
-{
- unsigned int bleft;
-
- if (write)
- bleft = idetape_output_buffers(drive, pc, bcount);
- else
- bleft = idetape_input_buffers(drive, pc, bcount);
-
- return bcount - bleft;
-}
-
/*
* Packet Command Interface
*
@@ -622,6 +493,8 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
if (pc->retries > IDETAPE_MAX_PC_RETRIES ||
(pc->flags & PC_FLAG_ABORT)) {
+ unsigned int done = blk_rq_bytes(drive->hwif->rq);
+
/*
* We will "abort" retrying a packet command in case legitimate
* error code was received (crossing a filemark, or end of the
@@ -641,8 +514,10 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
/* Giving up */
pc->error = IDE_DRV_ERROR_GENERAL;
}
+
drive->failed_pc = NULL;
drive->pc_callback(drive, 0);
+ ide_complete_rq(drive, -EIO, done);
return ide_stopped;
}
debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]);
@@ -695,7 +570,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
printk(KERN_ERR "ide-tape: %s: I/O error, ",
tape->name);
/* Retry operation */
- ide_retry_pc(drive, tape->disk);
+ ide_retry_pc(drive);
return ide_stopped;
}
pc->error = 0;
@@ -711,27 +586,22 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape,
struct ide_atapi_pc *pc, struct request *rq,
u8 opcode)
{
- struct idetape_bh *bh = (struct idetape_bh *)rq->special;
- unsigned int length = rq->current_nr_sectors;
+ unsigned int length = blk_rq_sectors(rq);
ide_init_pc(pc);
put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
- pc->bh = bh;
pc->buf = NULL;
pc->buf_size = length * tape->blk_size;
pc->req_xfer = pc->buf_size;
if (pc->req_xfer == tape->buffer_size)
pc->flags |= PC_FLAG_DMA_OK;
- if (opcode == READ_6) {
+ if (opcode == READ_6)
pc->c[0] = READ_6;
- atomic_set(&bh->b_count, 0);
- } else if (opcode == WRITE_6) {
+ else if (opcode == WRITE_6) {
pc->c[0] = WRITE_6;
pc->flags |= PC_FLAG_WRITING;
- pc->b_data = bh->b_data;
- pc->b_count = atomic_read(&bh->b_count);
}
memcpy(rq->cmd, pc->c, 12);
@@ -747,12 +617,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
struct ide_cmd cmd;
u8 stat;
- debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu,"
- " current_nr_sectors: %u\n",
- (unsigned long long)rq->sector, rq->nr_sectors,
- rq->current_nr_sectors);
+ debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n",
+ (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq));
- if (!blk_special_request(rq)) {
+ if (!(blk_special_request(rq) || blk_sense_request(rq))) {
/* We do not support buffer cache originated requests. */
printk(KERN_NOTICE "ide-tape: %s: Unsupported request in "
"request queue (%d)\n", drive->name, rq->cmd_type);
@@ -828,7 +696,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
goto out;
}
if (rq->cmd[13] & REQ_IDETAPE_PC1) {
- pc = (struct ide_atapi_pc *) rq->buffer;
+ pc = (struct ide_atapi_pc *)rq->special;
rq->cmd[13] &= ~(REQ_IDETAPE_PC1);
rq->cmd[13] |= REQ_IDETAPE_PC2;
goto out;
@@ -840,6 +708,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
BUG();
out:
+ /* prepare sense request for this command */
+ ide_prep_sense(drive, rq);
+
memset(&cmd, 0, sizeof(cmd));
if (rq_data_dir(rq))
@@ -847,167 +718,10 @@ out:
cmd.rq = rq;
- return ide_tape_issue_pc(drive, &cmd, pc);
-}
-
-/*
- * The function below uses __get_free_pages to allocate a data buffer of size
- * tape->buffer_size (or a bit more). We attempt to combine sequential pages as
- * much as possible.
- *
- * It returns a pointer to the newly allocated buffer, or NULL in case of
- * failure.
- */
-static struct idetape_bh *ide_tape_kmalloc_buffer(idetape_tape_t *tape,
- int full, int clear)
-{
- struct idetape_bh *prev_bh, *bh, *merge_bh;
- int pages = tape->pages_per_buffer;
- unsigned int order, b_allocd;
- char *b_data = NULL;
-
- merge_bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL);
- bh = merge_bh;
- if (bh == NULL)
- goto abort;
-
- order = fls(pages) - 1;
- bh->b_data = (char *) __get_free_pages(GFP_KERNEL, order);
- if (!bh->b_data)
- goto abort;
- b_allocd = (1 << order) * PAGE_SIZE;
- pages &= (order-1);
-
- if (clear)
- memset(bh->b_data, 0, b_allocd);
- bh->b_reqnext = NULL;
- bh->b_size = b_allocd;
- atomic_set(&bh->b_count, full ? bh->b_size : 0);
-
- while (pages) {
- order = fls(pages) - 1;
- b_data = (char *) __get_free_pages(GFP_KERNEL, order);
- if (!b_data)
- goto abort;
- b_allocd = (1 << order) * PAGE_SIZE;
-
- if (clear)
- memset(b_data, 0, b_allocd);
-
- /* newly allocated page frames below buffer header or ...*/
- if (bh->b_data == b_data + b_allocd) {
- bh->b_size += b_allocd;
- bh->b_data -= b_allocd;
- if (full)
- atomic_add(b_allocd, &bh->b_count);
- continue;
- }
- /* they are above the header */
- if (b_data == bh->b_data + bh->b_size) {
- bh->b_size += b_allocd;
- if (full)
- atomic_add(b_allocd, &bh->b_count);
- continue;
- }
- prev_bh = bh;
- bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL);
- if (!bh) {
- free_pages((unsigned long) b_data, order);
- goto abort;
- }
- bh->b_reqnext = NULL;
- bh->b_data = b_data;
- bh->b_size = b_allocd;
- atomic_set(&bh->b_count, full ? bh->b_size : 0);
- prev_bh->b_reqnext = bh;
-
- pages &= (order-1);
- }
-
- bh->b_size -= tape->excess_bh_size;
- if (full)
- atomic_sub(tape->excess_bh_size, &bh->b_count);
- return merge_bh;
-abort:
- ide_tape_kfree_buffer(tape);
- return NULL;
-}
+ ide_init_sg_cmd(&cmd, pc->req_xfer);
+ ide_map_sg(drive, &cmd);
-static int idetape_copy_stage_from_user(idetape_tape_t *tape,
- const char __user *buf, int n)
-{
- struct idetape_bh *bh = tape->bh;
- int count;
- int ret = 0;
-
- while (n) {
- if (bh == NULL) {
- printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
- __func__);
- return 1;
- }
- count = min((unsigned int)
- (bh->b_size - atomic_read(&bh->b_count)),
- (unsigned int)n);
- if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf,
- count))
- ret = 1;
- n -= count;
- atomic_add(count, &bh->b_count);
- buf += count;
- if (atomic_read(&bh->b_count) == bh->b_size) {
- bh = bh->b_reqnext;
- if (bh)
- atomic_set(&bh->b_count, 0);
- }
- }
- tape->bh = bh;
- return ret;
-}
-
-static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf,
- int n)
-{
- struct idetape_bh *bh = tape->bh;
- int count;
- int ret = 0;
-
- while (n) {
- if (bh == NULL) {
- printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
- __func__);
- return 1;
- }
- count = min(tape->b_count, n);
- if (copy_to_user(buf, tape->b_data, count))
- ret = 1;
- n -= count;
- tape->b_data += count;
- tape->b_count -= count;
- buf += count;
- if (!tape->b_count) {
- bh = bh->b_reqnext;
- tape->bh = bh;
- if (bh) {
- tape->b_data = bh->b_data;
- tape->b_count = atomic_read(&bh->b_count);
- }
- }
- }
- return ret;
-}
-
-static void idetape_init_merge_buffer(idetape_tape_t *tape)
-{
- struct idetape_bh *bh = tape->merge_bh;
- tape->bh = tape->merge_bh;
-
- if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
- atomic_set(&bh->b_count, 0);
- else {
- tape->b_data = bh->b_data;
- tape->b_count = atomic_read(&bh->b_count);
- }
+ return ide_tape_issue_pc(drive, &cmd, pc);
}
/*
@@ -1107,10 +821,10 @@ static void __ide_tape_discard_merge_buffer(ide_drive_t *drive)
return;
clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags);
- tape->merge_bh_size = 0;
- if (tape->merge_bh != NULL) {
- ide_tape_kfree_buffer(tape);
- tape->merge_bh = NULL;
+ tape->valid = 0;
+ if (tape->buf != NULL) {
+ kfree(tape->buf);
+ tape->buf = NULL;
}
tape->chrdev_dir = IDETAPE_DIR_NONE;
@@ -1164,36 +878,43 @@ static void ide_tape_discard_merge_buffer(ide_drive_t *drive,
* Generate a read/write request for the block device interface and wait for it
* to be serviced.
*/
-static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks,
- struct idetape_bh *bh)
+static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
{
idetape_tape_t *tape = drive->driver_data;
struct request *rq;
- int ret, errors;
+ int ret;
debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd);
+ BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE);
+ BUG_ON(size < 0 || size % tape->blk_size);
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_SPECIAL;
rq->cmd[13] = cmd;
rq->rq_disk = tape->disk;
- rq->special = (void *)bh;
- rq->sector = tape->first_frame;
- rq->nr_sectors = blocks;
- rq->current_nr_sectors = blocks;
- blk_execute_rq(drive->queue, tape->disk, rq, 0);
- errors = rq->errors;
- ret = tape->blk_size * (blocks - rq->current_nr_sectors);
- blk_put_request(rq);
+ if (size) {
+ ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size,
+ __GFP_WAIT);
+ if (ret)
+ goto out_put;
+ }
- if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0)
- return 0;
+ blk_execute_rq(drive->queue, tape->disk, rq, 0);
- if (tape->merge_bh)
- idetape_init_merge_buffer(tape);
- if (errors == IDE_DRV_ERROR_GENERAL)
- return -EIO;
+ /* calculate the number of transferred bytes and update buffer state */
+ size -= rq->resid_len;
+ tape->cur = tape->buf;
+ if (cmd == REQ_IDETAPE_READ)
+ tape->valid = size;
+ else
+ tape->valid = 0;
+
+ ret = size;
+ if (rq->errors == IDE_DRV_ERROR_GENERAL)
+ ret = -EIO;
+out_put:
+ blk_put_request(rq);
return ret;
}
@@ -1230,153 +951,87 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd)
pc->flags |= PC_FLAG_WAIT_FOR_DSC;
}
-/* Queue up a character device originated write request. */
-static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks)
-{
- idetape_tape_t *tape = drive->driver_data;
-
- debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
-
- return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE,
- blocks, tape->merge_bh);
-}
-
static void ide_tape_flush_merge_buffer(ide_drive_t *drive)
{
idetape_tape_t *tape = drive->driver_data;
- int blocks, min;
- struct idetape_bh *bh;
if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer"
" but we are not writing.\n");
return;
}
- if (tape->merge_bh_size > tape->buffer_size) {
- printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n");
- tape->merge_bh_size = tape->buffer_size;
- }
- if (tape->merge_bh_size) {
- blocks = tape->merge_bh_size / tape->blk_size;
- if (tape->merge_bh_size % tape->blk_size) {
- unsigned int i;
-
- blocks++;
- i = tape->blk_size - tape->merge_bh_size %
- tape->blk_size;
- bh = tape->bh->b_reqnext;
- while (bh) {
- atomic_set(&bh->b_count, 0);
- bh = bh->b_reqnext;
- }
- bh = tape->bh;
- while (i) {
- if (bh == NULL) {
- printk(KERN_INFO "ide-tape: bug,"
- " bh NULL\n");
- break;
- }
- min = min(i, (unsigned int)(bh->b_size -
- atomic_read(&bh->b_count)));
- memset(bh->b_data + atomic_read(&bh->b_count),
- 0, min);
- atomic_add(min, &bh->b_count);
- i -= min;
- bh = bh->b_reqnext;
- }
- }
- (void) idetape_add_chrdev_write_request(drive, blocks);
- tape->merge_bh_size = 0;
- }
- if (tape->merge_bh != NULL) {
- ide_tape_kfree_buffer(tape);
- tape->merge_bh = NULL;
+ if (tape->buf) {
+ size_t aligned = roundup(tape->valid, tape->blk_size);
+
+ memset(tape->cur, 0, aligned - tape->valid);
+ idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, aligned);
+ kfree(tape->buf);
+ tape->buf = NULL;
}
tape->chrdev_dir = IDETAPE_DIR_NONE;
}
-static int idetape_init_read(ide_drive_t *drive)
+static int idetape_init_rw(ide_drive_t *drive, int dir)
{
idetape_tape_t *tape = drive->driver_data;
- int bytes_read;
+ int rc;
- /* Initialize read operation */
- if (tape->chrdev_dir != IDETAPE_DIR_READ) {
- if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
- ide_tape_flush_merge_buffer(drive);
- idetape_flush_tape_buffers(drive);
- }
- if (tape->merge_bh || tape->merge_bh_size) {
- printk(KERN_ERR "ide-tape: merge_bh_size should be"
- " 0 now\n");
- tape->merge_bh_size = 0;
- }
- tape->merge_bh = ide_tape_kmalloc_buffer(tape, 0, 0);
- if (!tape->merge_bh)
- return -ENOMEM;
- tape->chrdev_dir = IDETAPE_DIR_READ;
+ BUG_ON(dir != IDETAPE_DIR_READ && dir != IDETAPE_DIR_WRITE);
- /*
- * Issue a read 0 command to ensure that DSC handshake is
- * switched from completion mode to buffer available mode.
- * No point in issuing this if DSC overlap isn't supported, some
- * drives (Seagate STT3401A) will return an error.
- */
- if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) {
- bytes_read = idetape_queue_rw_tail(drive,
- REQ_IDETAPE_READ, 0,
- tape->merge_bh);
- if (bytes_read < 0) {
- ide_tape_kfree_buffer(tape);
- tape->merge_bh = NULL;
- tape->chrdev_dir = IDETAPE_DIR_NONE;
- return bytes_read;
- }
- }
- }
+ if (tape->chrdev_dir == dir)
+ return 0;
- return 0;
-}
+ if (tape->chrdev_dir == IDETAPE_DIR_READ)
+ ide_tape_discard_merge_buffer(drive, 1);
+ else if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
+ ide_tape_flush_merge_buffer(drive);
+ idetape_flush_tape_buffers(drive);
+ }
-/* called from idetape_chrdev_read() to service a chrdev read request. */
-static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks)
-{
- idetape_tape_t *tape = drive->driver_data;
+ if (tape->buf || tape->valid) {
+ printk(KERN_ERR "ide-tape: valid should be 0 now\n");
+ tape->valid = 0;
+ }
- debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks);
+ tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL);
+ if (!tape->buf)
+ return -ENOMEM;
+ tape->chrdev_dir = dir;
+ tape->cur = tape->buf;
- /* If we are at a filemark, return a read length of 0 */
- if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags))
- return 0;
-
- idetape_init_read(drive);
+ /*
+ * Issue a 0 rw command to ensure that DSC handshake is
+ * switched from completion mode to buffer available mode. No
+ * point in issuing this if DSC overlap isn't supported, some
+ * drives (Seagate STT3401A) will return an error.
+ */
+ if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) {
+ int cmd = dir == IDETAPE_DIR_READ ? REQ_IDETAPE_READ
+ : REQ_IDETAPE_WRITE;
+
+ rc = idetape_queue_rw_tail(drive, cmd, 0);
+ if (rc < 0) {
+ kfree(tape->buf);
+ tape->buf = NULL;
+ tape->chrdev_dir = IDETAPE_DIR_NONE;
+ return rc;
+ }
+ }
- return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks,
- tape->merge_bh);
+ return 0;
}
static void idetape_pad_zeros(ide_drive_t *drive, int bcount)
{
idetape_tape_t *tape = drive->driver_data;
- struct idetape_bh *bh;
- int blocks;
+
+ memset(tape->buf, 0, tape->buffer_size);
while (bcount) {
- unsigned int count;
+ unsigned int count = min(tape->buffer_size, bcount);
- bh = tape->merge_bh;
- count = min(tape->buffer_size, bcount);
+ idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, count);
bcount -= count;
- blocks = count / tape->blk_size;
- while (count) {
- atomic_set(&bh->b_count,
- min(count, (unsigned int)bh->b_size));
- memset(bh->b_data, 0, atomic_read(&bh->b_count));
- count -= atomic_read(&bh->b_count);
- bh = bh->b_reqnext;
- }
- idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks,
- tape->merge_bh);
}
}
@@ -1456,7 +1111,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
}
if (tape->chrdev_dir == IDETAPE_DIR_READ) {
- tape->merge_bh_size = 0;
+ tape->valid = 0;
if (test_and_clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags))
++count;
ide_tape_discard_merge_buffer(drive, 0);
@@ -1505,9 +1160,9 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
{
struct ide_tape_obj *tape = file->private_data;
ide_drive_t *drive = tape->drive;
- ssize_t bytes_read, temp, actually_read = 0, rc;
+ size_t done = 0;
ssize_t ret = 0;
- u16 ctl = *(u16 *)&tape->caps[12];
+ int rc;
debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
@@ -1517,49 +1172,43 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
(count % tape->blk_size) == 0)
tape->user_bs_factor = count / tape->blk_size;
}
- rc = idetape_init_read(drive);
+
+ rc = idetape_init_rw(drive, IDETAPE_DIR_READ);
if (rc < 0)
return rc;
- if (count == 0)
- return (0);
- if (tape->merge_bh_size) {
- actually_read = min((unsigned int)(tape->merge_bh_size),
- (unsigned int)count);
- if (idetape_copy_stage_to_user(tape, buf, actually_read))
- ret = -EFAULT;
- buf += actually_read;
- tape->merge_bh_size -= actually_read;
- count -= actually_read;
- }
- while (count >= tape->buffer_size) {
- bytes_read = idetape_add_chrdev_read_request(drive, ctl);
- if (bytes_read <= 0)
- goto finish;
- if (idetape_copy_stage_to_user(tape, buf, bytes_read))
- ret = -EFAULT;
- buf += bytes_read;
- count -= bytes_read;
- actually_read += bytes_read;
- }
- if (count) {
- bytes_read = idetape_add_chrdev_read_request(drive, ctl);
- if (bytes_read <= 0)
- goto finish;
- temp = min((unsigned long)count, (unsigned long)bytes_read);
- if (idetape_copy_stage_to_user(tape, buf, temp))
+
+ while (done < count) {
+ size_t todo;
+
+ /* refill if staging buffer is empty */
+ if (!tape->valid) {
+ /* If we are at a filemark, nothing more to read */
+ if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags))
+ break;
+ /* read */
+ if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ,
+ tape->buffer_size) <= 0)
+ break;
+ }
+
+ /* copy out */
+ todo = min_t(size_t, count - done, tape->valid);
+ if (copy_to_user(buf + done, tape->cur, todo))
ret = -EFAULT;
- actually_read += temp;
- tape->merge_bh_size = bytes_read-temp;
+
+ tape->cur += todo;
+ tape->valid -= todo;
+ done += todo;
}
-finish:
- if (!actually_read && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) {
+
+ if (!done && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) {
debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name);
idetape_space_over_filemarks(drive, MTFSF, 1);
return 0;
}
- return ret ? ret : actually_read;
+ return ret ? ret : done;
}
static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
@@ -1567,9 +1216,9 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
{
struct ide_tape_obj *tape = file->private_data;
ide_drive_t *drive = tape->drive;
- ssize_t actually_written = 0;
+ size_t done = 0;
ssize_t ret = 0;
- u16 ctl = *(u16 *)&tape->caps[12];
+ int rc;
/* The drive is write protected. */
if (tape->write_prot)
@@ -1578,80 +1227,31 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
/* Initialize write operation */
- if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
- if (tape->chrdev_dir == IDETAPE_DIR_READ)
- ide_tape_discard_merge_buffer(drive, 1);
- if (tape->merge_bh || tape->merge_bh_size) {
- printk(KERN_ERR "ide-tape: merge_bh_size "
- "should be 0 now\n");
- tape->merge_bh_size = 0;
- }
- tape->merge_bh = ide_tape_kmalloc_buffer(tape, 0, 0);
- if (!tape->merge_bh)
- return -ENOMEM;
- tape->chrdev_dir = IDETAPE_DIR_WRITE;
- idetape_init_merge_buffer(tape);
+ rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE);
+ if (rc < 0)
+ return rc;
- /*
- * Issue a write 0 command to ensure that DSC handshake is
- * switched from completion mode to buffer available mode. No
- * point in issuing this if DSC overlap isn't supported, some
- * drives (Seagate STT3401A) will return an error.
- */
- if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) {
- ssize_t retval = idetape_queue_rw_tail(drive,
- REQ_IDETAPE_WRITE, 0,
- tape->merge_bh);
- if (retval < 0) {
- ide_tape_kfree_buffer(tape);
- tape->merge_bh = NULL;
- tape->chrdev_dir = IDETAPE_DIR_NONE;
- return retval;
- }
- }
- }
- if (count == 0)
- return (0);
- if (tape->merge_bh_size) {
- if (tape->merge_bh_size >= tape->buffer_size) {
- printk(KERN_ERR "ide-tape: bug: merge buf too big\n");
- tape->merge_bh_size = 0;
- }
- actually_written = min((unsigned int)
- (tape->buffer_size - tape->merge_bh_size),
- (unsigned int)count);
- if (idetape_copy_stage_from_user(tape, buf, actually_written))
- ret = -EFAULT;
- buf += actually_written;
- tape->merge_bh_size += actually_written;
- count -= actually_written;
-
- if (tape->merge_bh_size == tape->buffer_size) {
- ssize_t retval;
- tape->merge_bh_size = 0;
- retval = idetape_add_chrdev_write_request(drive, ctl);
- if (retval <= 0)
- return (retval);
- }
- }
- while (count >= tape->buffer_size) {
- ssize_t retval;
- if (idetape_copy_stage_from_user(tape, buf, tape->buffer_size))
- ret = -EFAULT;
- buf += tape->buffer_size;
- count -= tape->buffer_size;
- retval = idetape_add_chrdev_write_request(drive, ctl);
- actually_written += tape->buffer_size;
- if (retval <= 0)
- return (retval);
- }
- if (count) {
- actually_written += count;
- if (idetape_copy_stage_from_user(tape, buf, count))
+ while (done < count) {
+ size_t todo;
+
+ /* flush if staging buffer is full */
+ if (tape->valid == tape->buffer_size &&
+ idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE,
+ tape->buffer_size) <= 0)
+ return rc;
+
+ /* copy in */
+ todo = min_t(size_t, count - done,
+ tape->buffer_size - tape->valid);
+ if (copy_from_user(tape->cur, buf + done, todo))
ret = -EFAULT;
- tape->merge_bh_size += count;
+
+ tape->cur += todo;
+ tape->valid += todo;
+ done += todo;
}
- return ret ? ret : actually_written;
+
+ return ret ? ret : done;
}
static int idetape_write_filemark(ide_drive_t *drive)
@@ -1812,7 +1412,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
idetape_flush_tape_buffers(drive);
}
if (cmd == MTIOCGET || cmd == MTIOCPOS) {
- block_offset = tape->merge_bh_size /
+ block_offset = tape->valid /
(tape->blk_size * tape->user_bs_factor);
position = idetape_read_position(drive);
if (position < 0)
@@ -1960,12 +1560,12 @@ static void idetape_write_release(ide_drive_t *drive, unsigned int minor)
idetape_tape_t *tape = drive->driver_data;
ide_tape_flush_merge_buffer(drive);
- tape->merge_bh = ide_tape_kmalloc_buffer(tape, 1, 0);
- if (tape->merge_bh != NULL) {
+ tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL);
+ if (tape->buf != NULL) {
idetape_pad_zeros(drive, tape->blk_size *
(tape->user_bs_factor - 1));
- ide_tape_kfree_buffer(tape);
- tape->merge_bh = NULL;
+ kfree(tape->buf);
+ tape->buf = NULL;
}
idetape_write_filemark(drive);
idetape_flush_tape_buffers(drive);
@@ -2159,8 +1759,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
u16 *ctl = (u16 *)&tape->caps[12];
drive->pc_callback = ide_tape_callback;
- drive->pc_update_buffers = idetape_update_buffers;
- drive->pc_io_buffers = ide_tape_io_buffers;
drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP;
@@ -2191,11 +1789,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
tape->buffer_size = *ctl * tape->blk_size;
}
buffer_size = tape->buffer_size;
- tape->pages_per_buffer = buffer_size / PAGE_SIZE;
- if (buffer_size % PAGE_SIZE) {
- tape->pages_per_buffer++;
- tape->excess_bh_size = PAGE_SIZE - buffer_size % PAGE_SIZE;
- }
/* select the "best" DSC read/write polling freq */
speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]);
@@ -2238,7 +1831,7 @@ static void ide_tape_release(struct device *dev)
ide_drive_t *drive = tape->drive;
struct gendisk *g = tape->disk;
- BUG_ON(tape->merge_bh_size);
+ BUG_ON(tape->valid);
drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
drive->driver_data = NULL;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 4aa6223c11be..908e6c7acafe 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -166,7 +166,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) {
if (custom && tf->command == ATA_CMD_SET_MULTI) {
drive->mult_req = drive->mult_count = 0;
- drive->special.b.recalibrate = 1;
+ drive->special_flags |= IDE_SFLAG_RECALIBRATE;
(void)ide_dump_status(drive, __func__, stat);
return ide_stopped;
} else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) {
@@ -385,7 +385,7 @@ out_end:
if ((cmd->tf_flags & IDE_TFLAG_FS) == 0)
ide_finish_cmd(drive, cmd, stat);
else
- ide_complete_rq(drive, 0, cmd->rq->nr_sectors << 9);
+ ide_complete_rq(drive, 0, blk_rq_sectors(cmd->rq) << 9);
return ide_stopped;
out_err:
ide_error_cmd(drive, cmd);
@@ -424,7 +424,9 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
- rq->buffer = buf;
+
+ if (cmd->tf_flags & IDE_TFLAG_WRITE)
+ rq->cmd_flags |= REQ_RW;
/*
* (ks) We transfer currently only whole sectors.
@@ -432,18 +434,20 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
* if we would find a solution to transfer any size.
* To support special commands like READ LONG.
*/
- rq->hard_nr_sectors = rq->nr_sectors = nsect;
- rq->hard_cur_sectors = rq->current_nr_sectors = nsect;
-
- if (cmd->tf_flags & IDE_TFLAG_WRITE)
- rq->cmd_flags |= REQ_RW;
+ if (nsect) {
+ error = blk_rq_map_kern(drive->queue, rq, buf,
+ nsect * SECTOR_SIZE, __GFP_WAIT);
+ if (error)
+ goto put_req;
+ }
rq->special = cmd;
cmd->rq = rq;
error = blk_execute_rq(drive->queue, NULL, rq, 0);
- blk_put_request(rq);
+put_req:
+ blk_put_request(rq);
return error;
}
diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c
index 051b4ab0f359..b579fbe88370 100644
--- a/drivers/ide/ide_platform.c
+++ b/drivers/ide/ide_platform.c
@@ -21,7 +21,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
-static void __devinit plat_ide_setup_ports(hw_regs_t *hw,
+static void __devinit plat_ide_setup_ports(struct ide_hw *hw,
void __iomem *base,
void __iomem *ctrl,
struct pata_platform_info *pdata,
@@ -40,12 +40,11 @@ static void __devinit plat_ide_setup_ports(hw_regs_t *hw,
hw->io_ports.ctl_addr = (unsigned long)ctrl;
hw->irq = irq;
-
- hw->chipset = ide_generic;
}
static const struct ide_port_info platform_ide_port_info = {
.host_flags = IDE_HFLAG_NO_DMA,
+ .chipset = ide_generic,
};
static int __devinit plat_ide_probe(struct platform_device *pdev)
@@ -55,7 +54,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
struct pata_platform_info *pdata;
struct ide_host *host;
int ret = 0, mmio = 0;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
struct ide_port_info d = platform_ide_port_info;
pdata = pdev->dev.platform_data;
@@ -99,7 +98,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
if (mmio)
d.host_flags |= IDE_HFLAG_MMIO;
- ret = ide_host_add(&d, hws, &host);
+ ret = ide_host_add(&d, hws, 1, &host);
if (ret)
goto out;
@@ -113,7 +112,7 @@ out:
static int __devexit plat_ide_remove(struct platform_device *pdev)
{
- struct ide_host *host = pdev->dev.driver_data;
+ struct ide_host *host = dev_get_drvdata(&pdev->dev);
ide_host_remove(host);
diff --git a/drivers/ide/macide.c b/drivers/ide/macide.c
index 4b1718e83283..1447c8c90565 100644
--- a/drivers/ide/macide.c
+++ b/drivers/ide/macide.c
@@ -62,7 +62,7 @@ int macide_ack_intr(ide_hwif_t* hwif)
return 0;
}
-static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base,
+static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
int irq, ide_ack_intr_t *ack_intr)
{
int i;
@@ -76,13 +76,12 @@ static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base,
hw->irq = irq;
hw->ack_intr = ack_intr;
-
- hw->chipset = ide_generic;
}
static const struct ide_port_info macide_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
+ .chipset = ide_generic,
};
static const char *mac_ide_name[] =
@@ -97,7 +96,7 @@ static int __init macide_init(void)
ide_ack_intr_t *ack_intr;
unsigned long base;
int irq;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
if (!MACH_IS_MAC)
return -ENODEV;
@@ -127,7 +126,7 @@ static int __init macide_init(void)
macide_setup_ports(&hw, base, irq, ack_intr);
- return ide_host_add(&macide_port_info, hws, NULL);
+ return ide_host_add(&macide_port_info, hws, 1, NULL);
}
module_init(macide_init);
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
index 09d813d313f4..3c1dc0152153 100644
--- a/drivers/ide/palm_bk3710.c
+++ b/drivers/ide/palm_bk3710.c
@@ -306,6 +306,7 @@ static struct ide_port_info __devinitdata palm_bk3710_port_info = {
.host_flags = IDE_HFLAG_MMIO,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
+ .chipset = ide_palm3710,
};
static int __init palm_bk3710_probe(struct platform_device *pdev)
@@ -315,7 +316,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
void __iomem *base;
unsigned long rate, mem_size;
int i, rc;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
clk = clk_get(&pdev->dev, "IDECLK");
if (IS_ERR(clk))
@@ -363,13 +364,12 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
(base + IDE_PALM_ATA_PRI_CTL_OFFSET);
hw.irq = irq->start;
hw.dev = &pdev->dev;
- hw.chipset = ide_palm3710;
palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 :
ATA_UDMA5;
/* Register the IDE interface with Linux */
- rc = ide_host_add(&palm_bk3710_port_info, hws, NULL);
+ rc = ide_host_add(&palm_bk3710_port_info, hws, 1, NULL);
if (rc)
goto out;
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 248a54bd2386..c2a16a8f486d 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -177,7 +177,7 @@ static void pdc202xx_dma_start(ide_drive_t *drive)
u8 clock = inb(high_16 + 0x11);
outb(clock | (hwif->channel ? 0x08 : 0x02), high_16 + 0x11);
- word_count = (rq->nr_sectors << 8);
+ word_count = (blk_rq_sectors(rq) << 8);
word_count = (rq_data_dir(rq) == READ) ?
word_count | 0x05000000 :
word_count | 0x06000000;
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index f76e4e6b408f..97642a7a79c4 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1023,13 +1023,14 @@ static const struct ide_port_info pmac_port_info = {
* Setup, register & probe an IDE channel driven by this driver, this is
* called by one of the 2 probe functions (macio or PCI).
*/
-static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
+static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif,
+ struct ide_hw *hw)
{
struct device_node *np = pmif->node;
const int *bidp;
struct ide_host *host;
ide_hwif_t *hwif;
- hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
+ struct ide_hw *hws[] = { hw };
struct ide_port_info d = pmac_port_info;
int rc;
@@ -1077,7 +1078,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
/* Make sure we have sane timings */
sanitize_timings(pmif);
- host = ide_host_alloc(&d, hws);
+ host = ide_host_alloc(&d, hws, 1);
if (host == NULL)
return -ENOMEM;
hwif = host->ports[0];
@@ -1124,7 +1125,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
return 0;
}
-static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base)
+static void __devinit pmac_ide_init_ports(struct ide_hw *hw, unsigned long base)
{
int i;
@@ -1144,7 +1145,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
unsigned long regbase;
pmac_ide_hwif_t *pmif;
int irq, rc;
- hw_regs_t hw;
+ struct ide_hw hw;
pmif = kzalloc(sizeof(*pmif), GFP_KERNEL);
if (pmif == NULL)
@@ -1268,7 +1269,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
void __iomem *base;
unsigned long rbase, rlen;
int rc;
- hw_regs_t hw;
+ struct ide_hw hw;
np = pci_device_to_OF_node(pdev);
if (np == NULL) {
diff --git a/drivers/ide/q40ide.c b/drivers/ide/q40ide.c
index c79346679244..ab49a97023d9 100644
--- a/drivers/ide/q40ide.c
+++ b/drivers/ide/q40ide.c
@@ -51,11 +51,11 @@ static int q40ide_default_irq(unsigned long base)
/*
* Addresses are pretranslated for Q40 ISA access.
*/
-static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base,
+static void q40_ide_setup_ports(struct ide_hw *hw, unsigned long base,
ide_ack_intr_t *ack_intr,
int irq)
{
- memset(hw, 0, sizeof(hw_regs_t));
+ memset(hw, 0, sizeof(*hw));
/* BIG FAT WARNING:
assumption: only DATA port is ever used in 16 bit mode */
hw->io_ports.data_addr = Q40_ISA_IO_W(base);
@@ -70,8 +70,6 @@ static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base,
hw->irq = irq;
hw->ack_intr = ack_intr;
-
- hw->chipset = ide_generic;
}
static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
@@ -119,6 +117,7 @@ static const struct ide_port_info q40ide_port_info = {
.tp_ops = &q40ide_tp_ops,
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
+ .chipset = ide_generic,
};
/*
@@ -136,7 +135,7 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={
static int __init q40ide_init(void)
{
int i;
- hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL };
if (!MACH_IS_Q40)
return -ENODEV;
@@ -163,7 +162,7 @@ static int __init q40ide_init(void)
hws[i] = &hw[i];
}
- return ide_host_add(&q40ide_port_info, hws, NULL);
+ return ide_host_add(&q40ide_port_info, hws, Q40IDE_NUM_HWIFS, NULL);
}
module_init(q40ide_init);
diff --git a/drivers/ide/rapide.c b/drivers/ide/rapide.c
index d5003ca69801..00f54248f41f 100644
--- a/drivers/ide/rapide.c
+++ b/drivers/ide/rapide.c
@@ -13,9 +13,10 @@
static const struct ide_port_info rapide_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
+ .chipset = ide_generic,
};
-static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
+static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base,
void __iomem *ctrl, unsigned int sz, int irq)
{
unsigned long port = (unsigned long)base;
@@ -35,7 +36,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
void __iomem *base;
struct ide_host *host;
int ret;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
ret = ecard_request_resources(ec);
if (ret)
@@ -49,10 +50,9 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
memset(&hw, 0, sizeof(hw));
rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
- hw.chipset = ide_generic;
hw.dev = &ec->dev;
- ret = ide_host_add(&rapide_port_info, hws, &host);
+ ret = ide_host_add(&rapide_port_info, hws, 1, &host);
if (ret)
goto release;
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 5be41f25204f..1104bb301eb9 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -559,7 +559,7 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
{
struct scc_ports *ports = pci_get_drvdata(dev);
struct ide_host *host;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
int i, rc;
memset(&hw, 0, sizeof(hw));
@@ -567,9 +567,8 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
hw.io_ports_array[i] = ports->dma + 0x20 + i * 4;
hw.irq = dev->irq;
hw.dev = &dev->dev;
- hw.chipset = ide_pci;
- rc = ide_host_add(d, hws, &host);
+ rc = ide_host_add(d, hws, 1, &host);
if (rc)
return rc;
@@ -823,6 +822,7 @@ static const struct ide_port_info scc_chipset __devinitdata = {
.host_flags = IDE_HFLAG_SINGLE,
.irq_flags = IRQF_SHARED,
.pio_mask = ATA_PIO4,
+ .chipset = ide_pci,
};
/**
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 7a3a12d6e638..5314edffc303 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -301,11 +301,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
}
/**
- * ide_hw_configure - configure a hw_regs_t instance
+ * ide_hw_configure - configure a struct ide_hw instance
* @dev: PCI device holding interface
* @d: IDE port info
* @port: port number
- * @hw: hw_regs_t instance corresponding to this port
+ * @hw: struct ide_hw instance corresponding to this port
*
* Perform the initial set up for the hardware interface structure. This
* is done per interface port rather than per PCI device. There may be
@@ -315,7 +315,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
*/
static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
- unsigned int port, hw_regs_t *hw)
+ unsigned int port, struct ide_hw *hw)
{
unsigned long ctl = 0, base = 0;
@@ -344,7 +344,6 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
memset(hw, 0, sizeof(*hw));
hw->dev = &dev->dev;
- hw->chipset = d->chipset ? d->chipset : ide_pci;
ide_std_init_ports(hw, base, ctl | 2);
return 0;
@@ -446,8 +445,8 @@ out:
* ide_pci_setup_ports - configure ports/devices on PCI IDE
* @dev: PCI device
* @d: IDE port info
- * @hw: hw_regs_t instances corresponding to this PCI IDE device
- * @hws: hw_regs_t pointers table to update
+ * @hw: struct ide_hw instances corresponding to this PCI IDE device
+ * @hws: struct ide_hw pointers table to update
*
* Scan the interfaces attached to this device and do any
* necessary per port setup. Attach the devices and ask the
@@ -459,7 +458,7 @@ out:
*/
void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
- hw_regs_t *hw, hw_regs_t **hws)
+ struct ide_hw *hw, struct ide_hw **hws)
{
int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
u8 tmp;
@@ -539,7 +538,7 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
void *priv)
{
struct ide_host *host;
- hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[2], *hws[] = { NULL, NULL };
int ret;
ret = ide_setup_pci_controller(dev, d, 1);
@@ -548,7 +547,7 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
- host = ide_host_alloc(d, hws);
+ host = ide_host_alloc(d, hws, 2);
if (host == NULL) {
ret = -ENOMEM;
goto out;
@@ -587,7 +586,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
struct pci_dev *pdev[] = { dev1, dev2 };
struct ide_host *host;
int ret, i;
- hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
+ struct ide_hw hw[4], *hws[] = { NULL, NULL, NULL, NULL };
for (i = 0; i < 2; i++) {
ret = ide_setup_pci_controller(pdev[i], d, !i);
@@ -597,7 +596,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]);
}
- host = ide_host_alloc(d, hws);
+ host = ide_host_alloc(d, hws, 4);
if (host == NULL) {
ret = -ENOMEM;
goto out;
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c
index e5d2a48a84de..5f37f168f944 100644
--- a/drivers/ide/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -91,7 +91,7 @@ typedef struct {
static void
-sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
+sgiioc4_init_hwif_ports(struct ide_hw *hw, unsigned long data_port,
unsigned long ctrl_port, unsigned long irq_port)
{
unsigned long reg = data_port;
@@ -546,7 +546,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
unsigned long cmd_base, irqport;
unsigned long bar0, cmd_phys_base, ctl;
void __iomem *virt_base;
- hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
int rc;
/* Get the CmdBlk and CtrlBlk Base Registers */
@@ -575,13 +575,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
memset(&hw, 0, sizeof(hw));
sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport);
hw.irq = dev->irq;
- hw.chipset = ide_pci;
hw.dev = &dev->dev;
/* Initializing chipset IRQ Registers */
writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
- rc = ide_host_add(&sgiioc4_port_info, hws, NULL);
+ rc = ide_host_add(&sgiioc4_port_info, hws, 1, NULL);
if (!rc)
return 0;
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c
index e4973cd1fba9..bd82d228608c 100644
--- a/drivers/ide/siimage.c
+++ b/drivers/ide/siimage.c
@@ -451,8 +451,8 @@ static int sil_sata_reset_poll(ide_drive_t *drive)
static void sil_sata_pre_reset(ide_drive_t *drive)
{
if (drive->media == ide_disk) {
- drive->special.b.set_geometry = 0;
- drive->special.b.recalibrate = 0;
+ drive->special_flags &=
+ ~(IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE);
}
}
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c
index b4cf42dc8a6f..05a93d6baecc 100644
--- a/drivers/ide/tc86c001.c
+++ b/drivers/ide/tc86c001.c
@@ -112,7 +112,7 @@ static void tc86c001_dma_start(ide_drive_t *drive)
ide_hwif_t *hwif = drive->hwif;
unsigned long sc_base = hwif->config_data;
unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04);
- unsigned long nsectors = hwif->rq->nr_sectors;
+ unsigned long nsectors = blk_rq_sectors(hwif->rq);
/*
* We have to manually load the sector count and size into
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index e33d764e2945..ea89fddeed91 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -130,8 +130,7 @@ static const struct ide_port_info tx4938ide_port_info __initdata = {
static int __init tx4938ide_probe(struct platform_device *pdev)
{
- hw_regs_t hw;
- hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
struct ide_host *host;
struct resource *res;
struct tx4938ide_platform_info *pdata = pdev->dev.platform_data;
@@ -183,7 +182,7 @@ static int __init tx4938ide_probe(struct platform_device *pdev)
tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0);
else
d.port_ops = NULL;
- ret = ide_host_add(&d, hws, &host);
+ ret = ide_host_add(&d, hws, 1, &host);
if (!ret)
platform_set_drvdata(pdev, host);
return ret;
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 564422d23976..64b58ecc3f0e 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -307,7 +307,7 @@ static int tx4939ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
tx4939ide_writew(SECTOR_SIZE / 2, base, drive->dn ?
TX4939IDE_Xfer_Cnt_2 : TX4939IDE_Xfer_Cnt_1);
- tx4939ide_writew(cmd->rq->nr_sectors, base, TX4939IDE_Sec_Cnt);
+ tx4939ide_writew(blk_rq_sectors(cmd->rq), base, TX4939IDE_Sec_Cnt);
return 0;
}
@@ -537,8 +537,7 @@ static const struct ide_port_info tx4939ide_port_info __initdata = {
static int __init tx4939ide_probe(struct platform_device *pdev)
{
- hw_regs_t hw;
- hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
+ struct ide_hw hw, *hws[] = { &hw };
struct ide_host *host;
struct resource *res;
int irq, ret;
@@ -581,7 +580,7 @@ static int __init tx4939ide_probe(struct platform_device *pdev)
hw.dev = &pdev->dev;
pr_info("TX4939 IDE interface (base %#lx, irq %d)\n", mapbase, irq);
- host = ide_host_alloc(&tx4939ide_port_info, hws);
+ host = ide_host_alloc(&tx4939ide_port_info, hws, 1);
if (!host)
return -ENOMEM;
/* use extra_base for base address of the all registers */
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index 3ff7231e4858..028de26a25fe 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -67,6 +67,7 @@ static struct via_isa_bridge {
u8 udma_mask;
u8 flags;
} via_isa_bridges[] = {
+ { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
{ "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
{ "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
{ "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
@@ -474,6 +475,7 @@ static const struct pci_device_id via_pci_tbl[] = {
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 },
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 },
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 },
+ { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_VX855_IDE), 0 },
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 },
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 },
{ 0, },
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 4ca103577c0a..f5c586c2bba6 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -361,7 +361,7 @@ static int eth1394_new_node(struct eth1394_host_info *hi,
node_info->pdg.sz = 0;
node_info->fifo = CSR1212_INVALID_ADDR_SPACE;
- ud->device.driver_data = node_info;
+ dev_set_drvdata(&ud->device, node_info);
new_node->ud = ud;
priv = netdev_priv(hi->dev);
@@ -406,7 +406,7 @@ static int eth1394_remove(struct device *dev)
list_del(&old_node->list);
kfree(old_node);
- node_info = (struct eth1394_node_info*)ud->device.driver_data;
+ node_info = dev_get_drvdata(&ud->device);
spin_lock_irqsave(&node_info->pdg.lock, flags);
/* The partial datagram list should be empty, but we'll just
@@ -416,7 +416,7 @@ static int eth1394_remove(struct device *dev)
spin_unlock_irqrestore(&node_info->pdg.lock, flags);
kfree(node_info);
- ud->device.driver_data = NULL;
+ dev_set_drvdata(&ud->device, NULL);
return 0;
}
@@ -688,7 +688,7 @@ static void ether1394_host_reset(struct hpsb_host *host)
ether1394_reset_priv(dev, 0);
list_for_each_entry(node, &priv->ip_node_list, list) {
- node_info = node->ud->device.driver_data;
+ node_info = dev_get_drvdata(&node->ud->device);
spin_lock_irqsave(&node_info->pdg.lock, flags);
@@ -872,8 +872,7 @@ static __be16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
if (!node)
return cpu_to_be16(0);
- node_info =
- (struct eth1394_node_info *)node->ud->device.driver_data;
+ node_info = dev_get_drvdata(&node->ud->device);
/* Update our speed/payload/fifo_offset table */
node_info->maxpayload = maxpayload;
@@ -1080,7 +1079,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
priv->ud_list[NODEID_TO_NODE(srcid)] = ud;
}
- node_info = (struct eth1394_node_info *)ud->device.driver_data;
+ node_info = dev_get_drvdata(&ud->device);
/* First, did we receive a fragmented or unfragmented datagram? */
hdr->words.word1 = ntohs(hdr->words.word1);
@@ -1617,8 +1616,7 @@ static int ether1394_tx(struct sk_buff *skb, struct net_device *dev)
if (!node)
goto fail;
- node_info =
- (struct eth1394_node_info *)node->ud->device.driver_data;
+ node_info = dev_get_drvdata(&node->ud->device);
if (node_info->fifo == CSR1212_INVALID_ADDR_SPACE)
goto fail;
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index a51ab233342d..83b734aec923 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -718,7 +718,7 @@ static int sbp2_remove(struct device *dev)
struct scsi_device *sdev;
ud = container_of(dev, struct unit_directory, device);
- lu = ud->device.driver_data;
+ lu = dev_get_drvdata(&ud->device);
if (!lu)
return 0;
@@ -746,7 +746,7 @@ static int sbp2_remove(struct device *dev)
static int sbp2_update(struct unit_directory *ud)
{
- struct sbp2_lu *lu = ud->device.driver_data;
+ struct sbp2_lu *lu = dev_get_drvdata(&ud->device);
if (sbp2_reconnect_device(lu) != 0) {
/*
@@ -815,7 +815,7 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
atomic_set(&lu->state, SBP2LU_STATE_RUNNING);
INIT_WORK(&lu->protocol_work, NULL);
- ud->device.driver_data = lu;
+ dev_set_drvdata(&ud->device, lu);
hi = hpsb_get_hostinfo(&sbp2_highlevel, ud->ne->host);
if (!hi) {
@@ -1051,7 +1051,7 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
hpsb_unregister_addrspace(&sbp2_highlevel, hi->host,
lu->status_fifo_addr);
- lu->ud->device.driver_data = NULL;
+ dev_set_drvdata(&lu->ud->device, NULL);
module_put(hi->host->driver->owner);
no_hi:
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 5c04cfb54cb9..158a214da2f7 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -760,9 +760,9 @@ int ib_device_register_sysfs(struct ib_device *device)
int i;
class_dev->class = &ib_class;
- class_dev->driver_data = device;
class_dev->parent = device->dma_device;
dev_set_name(class_dev, device->name);
+ dev_set_drvdata(class_dev, device);
INIT_LIST_HEAD(&device->port_list);
diff --git a/drivers/infiniband/hw/amso1100/c2_cq.c b/drivers/infiniband/hw/amso1100/c2_cq.c
index bb17cce3cb59..f5c45b194f53 100644
--- a/drivers/infiniband/hw/amso1100/c2_cq.c
+++ b/drivers/infiniband/hw/amso1100/c2_cq.c
@@ -133,7 +133,7 @@ static inline int c2_poll_one(struct c2_dev *c2dev,
struct c2_qp *qp;
int is_recv = 0;
- ce = (struct c2wr_ce *) c2_mq_consume(&cq->mq);
+ ce = c2_mq_consume(&cq->mq);
if (!ce) {
return -EAGAIN;
}
@@ -146,7 +146,7 @@ static inline int c2_poll_one(struct c2_dev *c2dev,
while ((qp =
(struct c2_qp *) (unsigned long) ce->qp_user_context) == NULL) {
c2_mq_free(&cq->mq);
- ce = (struct c2wr_ce *) c2_mq_consume(&cq->mq);
+ ce = c2_mq_consume(&cq->mq);
if (!ce)
return -EAGAIN;
}
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 99bcbd7ffb0a..4b89b791be6a 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -479,13 +479,13 @@ void ehca_tasklet_neq(unsigned long data)
struct ehca_eqe *eqe;
u64 ret;
- eqe = (struct ehca_eqe *)ehca_poll_eq(shca, &shca->neq);
+ eqe = ehca_poll_eq(shca, &shca->neq);
while (eqe) {
if (!EHCA_BMASK_GET(NEQE_COMPLETION_EVENT, eqe->entry))
parse_ec(shca, eqe->entry);
- eqe = (struct ehca_eqe *)ehca_poll_eq(shca, &shca->neq);
+ eqe = ehca_poll_eq(shca, &shca->neq);
}
ret = hipz_h_reset_event(shca->ipz_hca_handle,
@@ -572,8 +572,7 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
eqe_cnt = 0;
do {
u32 token;
- eqe_cache[eqe_cnt].eqe =
- (struct ehca_eqe *)ehca_poll_eq(shca, eq);
+ eqe_cache[eqe_cnt].eqe = ehca_poll_eq(shca, eq);
if (!eqe_cache[eqe_cnt].eqe)
break;
eqe_value = eqe_cache[eqe_cnt].eqe->entry;
@@ -637,7 +636,7 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
goto unlock_irq_spinlock;
do {
struct ehca_eqe *eqe;
- eqe = (struct ehca_eqe *)ehca_poll_eq(shca, &shca->eq);
+ eqe = ehca_poll_eq(shca, &shca->eq);
if (!eqe)
break;
process_eqe(shca, eqe);
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 368311ce332b..ce4e6eff4792 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -52,7 +52,7 @@
#include "ehca_tools.h"
#include "hcp_if.h"
-#define HCAD_VERSION "0026"
+#define HCAD_VERSION "0027"
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
@@ -636,7 +636,7 @@ static ssize_t ehca_show_##name(struct device *dev, \
struct hipz_query_hca *rblock; \
int data; \
\
- shca = dev->driver_data; \
+ shca = dev_get_drvdata(dev); \
\
rblock = ehca_alloc_fw_ctrlblock(GFP_KERNEL); \
if (!rblock) { \
@@ -680,7 +680,7 @@ static ssize_t ehca_show_adapter_handle(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct ehca_shca *shca = dev->driver_data;
+ struct ehca_shca *shca = dev_get_drvdata(dev);
return sprintf(buf, "%llx\n", shca->ipz_hca_handle.handle);
@@ -749,7 +749,7 @@ static int __devinit ehca_probe(struct of_device *dev,
shca->ofdev = dev;
shca->ipz_hca_handle.handle = *handle;
- dev->dev.driver_data = shca;
+ dev_set_drvdata(&dev->dev, shca);
ret = ehca_sense_attributes(shca);
if (ret < 0) {
@@ -878,7 +878,7 @@ probe1:
static int __devexit ehca_remove(struct of_device *dev)
{
- struct ehca_shca *shca = dev->dev.driver_data;
+ struct ehca_shca *shca = dev_get_drvdata(&dev->dev);
unsigned long flags;
int ret;
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 00c108159714..ead4e718c082 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -461,7 +461,7 @@ static struct ehca_qp *internal_create_qp(
ib_device);
struct ib_ucontext *context = NULL;
u64 h_ret;
- int is_llqp = 0, has_srq = 0;
+ int is_llqp = 0, has_srq = 0, is_user = 0;
int qp_type, max_send_sge, max_recv_sge, ret;
/* h_call's out parameters */
@@ -609,9 +609,6 @@ static struct ehca_qp *internal_create_qp(
}
}
- if (pd->uobject && udata)
- context = pd->uobject->context;
-
my_qp = kmem_cache_zalloc(qp_cache, GFP_KERNEL);
if (!my_qp) {
ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
@@ -619,6 +616,11 @@ static struct ehca_qp *internal_create_qp(
return ERR_PTR(-ENOMEM);
}
+ if (pd->uobject && udata) {
+ is_user = 1;
+ context = pd->uobject->context;
+ }
+
atomic_set(&my_qp->nr_events, 0);
init_waitqueue_head(&my_qp->wait_completion);
spin_lock_init(&my_qp->spinlock_s);
@@ -707,7 +709,7 @@ static struct ehca_qp *internal_create_qp(
(parms.squeue.is_small || parms.rqueue.is_small);
}
- h_ret = hipz_h_alloc_resource_qp(shca->ipz_hca_handle, &parms);
+ h_ret = hipz_h_alloc_resource_qp(shca->ipz_hca_handle, &parms, is_user);
if (h_ret != H_SUCCESS) {
ehca_err(pd->device, "h_alloc_resource_qp() failed h_ret=%lli",
h_ret);
@@ -769,18 +771,20 @@ static struct ehca_qp *internal_create_qp(
goto create_qp_exit2;
}
- my_qp->sq_map.entries = my_qp->ipz_squeue.queue_length /
- my_qp->ipz_squeue.qe_size;
- my_qp->sq_map.map = vmalloc(my_qp->sq_map.entries *
- sizeof(struct ehca_qmap_entry));
- if (!my_qp->sq_map.map) {
- ehca_err(pd->device, "Couldn't allocate squeue "
- "map ret=%i", ret);
- goto create_qp_exit3;
+ if (!is_user) {
+ my_qp->sq_map.entries = my_qp->ipz_squeue.queue_length /
+ my_qp->ipz_squeue.qe_size;
+ my_qp->sq_map.map = vmalloc(my_qp->sq_map.entries *
+ sizeof(struct ehca_qmap_entry));
+ if (!my_qp->sq_map.map) {
+ ehca_err(pd->device, "Couldn't allocate squeue "
+ "map ret=%i", ret);
+ goto create_qp_exit3;
+ }
+ INIT_LIST_HEAD(&my_qp->sq_err_node);
+ /* to avoid the generation of bogus flush CQEs */
+ reset_queue_map(&my_qp->sq_map);
}
- INIT_LIST_HEAD(&my_qp->sq_err_node);
- /* to avoid the generation of bogus flush CQEs */
- reset_queue_map(&my_qp->sq_map);
}
if (HAS_RQ(my_qp)) {
@@ -792,20 +796,21 @@ static struct ehca_qp *internal_create_qp(
"and pages ret=%i", ret);
goto create_qp_exit4;
}
-
- my_qp->rq_map.entries = my_qp->ipz_rqueue.queue_length /
- my_qp->ipz_rqueue.qe_size;
- my_qp->rq_map.map = vmalloc(my_qp->rq_map.entries *
- sizeof(struct ehca_qmap_entry));
- if (!my_qp->rq_map.map) {
- ehca_err(pd->device, "Couldn't allocate squeue "
- "map ret=%i", ret);
- goto create_qp_exit5;
+ if (!is_user) {
+ my_qp->rq_map.entries = my_qp->ipz_rqueue.queue_length /
+ my_qp->ipz_rqueue.qe_size;
+ my_qp->rq_map.map = vmalloc(my_qp->rq_map.entries *
+ sizeof(struct ehca_qmap_entry));
+ if (!my_qp->rq_map.map) {
+ ehca_err(pd->device, "Couldn't allocate squeue "
+ "map ret=%i", ret);
+ goto create_qp_exit5;
+ }
+ INIT_LIST_HEAD(&my_qp->rq_err_node);
+ /* to avoid the generation of bogus flush CQEs */
+ reset_queue_map(&my_qp->rq_map);
}
- INIT_LIST_HEAD(&my_qp->rq_err_node);
- /* to avoid the generation of bogus flush CQEs */
- reset_queue_map(&my_qp->rq_map);
- } else if (init_attr->srq) {
+ } else if (init_attr->srq && !is_user) {
/* this is a base QP, use the queue map of the SRQ */
my_qp->rq_map = my_srq->rq_map;
INIT_LIST_HEAD(&my_qp->rq_err_node);
@@ -918,7 +923,7 @@ create_qp_exit7:
kfree(my_qp->mod_qp_parm);
create_qp_exit6:
- if (HAS_RQ(my_qp))
+ if (HAS_RQ(my_qp) && !is_user)
vfree(my_qp->rq_map.map);
create_qp_exit5:
@@ -926,7 +931,7 @@ create_qp_exit5:
ipz_queue_dtor(my_pd, &my_qp->ipz_rqueue);
create_qp_exit4:
- if (HAS_SQ(my_qp))
+ if (HAS_SQ(my_qp) && !is_user)
vfree(my_qp->sq_map.map);
create_qp_exit3:
@@ -1244,6 +1249,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
u64 update_mask;
u64 h_ret;
int bad_wqe_cnt = 0;
+ int is_user = 0;
int squeue_locked = 0;
unsigned long flags = 0;
@@ -1266,6 +1272,8 @@ static int internal_modify_qp(struct ib_qp *ibqp,
ret = ehca2ib_return_code(h_ret);
goto modify_qp_exit1;
}
+ if (ibqp->uobject)
+ is_user = 1;
qp_cur_state = ehca2ib_qp_state(mqpcb->qp_state);
@@ -1728,7 +1736,8 @@ static int internal_modify_qp(struct ib_qp *ibqp,
goto modify_qp_exit2;
}
}
- if ((qp_new_state == IB_QPS_ERR) && (qp_cur_state != IB_QPS_ERR)) {
+ if ((qp_new_state == IB_QPS_ERR) && (qp_cur_state != IB_QPS_ERR)
+ && !is_user) {
ret = check_for_left_cqes(my_qp, shca);
if (ret)
goto modify_qp_exit2;
@@ -1738,16 +1747,17 @@ static int internal_modify_qp(struct ib_qp *ibqp,
ipz_qeit_reset(&my_qp->ipz_rqueue);
ipz_qeit_reset(&my_qp->ipz_squeue);
- if (qp_cur_state == IB_QPS_ERR) {
+ if (qp_cur_state == IB_QPS_ERR && !is_user) {
del_from_err_list(my_qp->send_cq, &my_qp->sq_err_node);
if (HAS_RQ(my_qp))
del_from_err_list(my_qp->recv_cq,
&my_qp->rq_err_node);
}
- reset_queue_map(&my_qp->sq_map);
+ if (!is_user)
+ reset_queue_map(&my_qp->sq_map);
- if (HAS_RQ(my_qp))
+ if (HAS_RQ(my_qp) && !is_user)
reset_queue_map(&my_qp->rq_map);
}
@@ -2138,10 +2148,12 @@ static int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp,
int ret;
u64 h_ret;
u8 port_num;
+ int is_user = 0;
enum ib_qp_type qp_type;
unsigned long flags;
if (uobject) {
+ is_user = 1;
if (my_qp->mm_count_galpa ||
my_qp->mm_count_rqueue || my_qp->mm_count_squeue) {
ehca_err(dev, "Resources still referenced in "
@@ -2168,10 +2180,10 @@ static int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp,
* SRQs will never get into an error list and do not have a recv_cq,
* so we need to skip them here.
*/
- if (HAS_RQ(my_qp) && !IS_SRQ(my_qp))
+ if (HAS_RQ(my_qp) && !IS_SRQ(my_qp) && !is_user)
del_from_err_list(my_qp->recv_cq, &my_qp->rq_err_node);
- if (HAS_SQ(my_qp))
+ if (HAS_SQ(my_qp) && !is_user)
del_from_err_list(my_qp->send_cq, &my_qp->sq_err_node);
/* now wait until all pending events have completed */
@@ -2209,13 +2221,13 @@ static int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp,
if (HAS_RQ(my_qp)) {
ipz_queue_dtor(my_pd, &my_qp->ipz_rqueue);
-
- vfree(my_qp->rq_map.map);
+ if (!is_user)
+ vfree(my_qp->rq_map.map);
}
if (HAS_SQ(my_qp)) {
ipz_queue_dtor(my_pd, &my_qp->ipz_squeue);
-
- vfree(my_qp->sq_map.map);
+ if (!is_user)
+ vfree(my_qp->sq_map.map);
}
kmem_cache_free(qp_cache, my_qp);
atomic_dec(&shca->num_qps);
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index d0ab0c0d5e91..4d5dc3304d42 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -284,7 +284,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle,
param->act_pages = (u32)outs[4];
if (ret == H_SUCCESS)
- hcp_galpas_ctor(&cq->galpas, outs[5], outs[6]);
+ hcp_galpas_ctor(&cq->galpas, 0, outs[5], outs[6]);
if (ret == H_NOT_ENOUGH_RESOURCES)
ehca_gen_err("Not enough resources. ret=%lli", ret);
@@ -293,7 +293,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle,
}
u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle,
- struct ehca_alloc_qp_parms *parms)
+ struct ehca_alloc_qp_parms *parms, int is_user)
{
u64 ret;
u64 allocate_controls, max_r10_reg, r11, r12;
@@ -359,7 +359,7 @@ u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle,
(u32)EHCA_BMASK_GET(H_ALL_RES_QP_RQUEUE_SIZE_PAGES, outs[4]);
if (ret == H_SUCCESS)
- hcp_galpas_ctor(&parms->galpas, outs[6], outs[6]);
+ hcp_galpas_ctor(&parms->galpas, is_user, outs[6], outs[6]);
if (ret == H_NOT_ENOUGH_RESOURCES)
ehca_gen_err("Not enough resources. ret=%lli", ret);
diff --git a/drivers/infiniband/hw/ehca/hcp_if.h b/drivers/infiniband/hw/ehca/hcp_if.h
index 2c3c6e0ea5c2..39c1c3618ec7 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.h
+++ b/drivers/infiniband/hw/ehca/hcp_if.h
@@ -78,7 +78,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle,
* initialize resources, create empty QPPTs (2 rings).
*/
u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle,
- struct ehca_alloc_qp_parms *parms);
+ struct ehca_alloc_qp_parms *parms, int is_user);
u64 hipz_h_query_port(const struct ipz_adapter_handle adapter_handle,
const u8 port_id,
diff --git a/drivers/infiniband/hw/ehca/hcp_phyp.c b/drivers/infiniband/hw/ehca/hcp_phyp.c
index 214821095cb1..b3e0e72e8a73 100644
--- a/drivers/infiniband/hw/ehca/hcp_phyp.c
+++ b/drivers/infiniband/hw/ehca/hcp_phyp.c
@@ -54,12 +54,15 @@ int hcall_unmap_page(u64 mapaddr)
return 0;
}
-int hcp_galpas_ctor(struct h_galpas *galpas,
+int hcp_galpas_ctor(struct h_galpas *galpas, int is_user,
u64 paddr_kernel, u64 paddr_user)
{
- int ret = hcall_map_page(paddr_kernel, &galpas->kernel.fw_handle);
- if (ret)
- return ret;
+ if (!is_user) {
+ int ret = hcall_map_page(paddr_kernel, &galpas->kernel.fw_handle);
+ if (ret)
+ return ret;
+ } else
+ galpas->kernel.fw_handle = 0;
galpas->user.fw_handle = paddr_user;
diff --git a/drivers/infiniband/hw/ehca/hcp_phyp.h b/drivers/infiniband/hw/ehca/hcp_phyp.h
index 5305c2a3ed94..204227d5303a 100644
--- a/drivers/infiniband/hw/ehca/hcp_phyp.h
+++ b/drivers/infiniband/hw/ehca/hcp_phyp.h
@@ -78,7 +78,7 @@ static inline void hipz_galpa_store(struct h_galpa galpa, u32 offset, u64 value)
*(volatile u64 __force *)addr = value;
}
-int hcp_galpas_ctor(struct h_galpas *galpas,
+int hcp_galpas_ctor(struct h_galpas *galpas, int is_user,
u64 paddr_kernel, u64 paddr_user);
int hcp_galpas_dtor(struct h_galpas *galpas);
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
index c3a328465431..1227c593627a 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
@@ -220,10 +220,13 @@ int ipz_queue_ctor(struct ehca_pd *pd, struct ipz_queue *queue,
queue->small_page = NULL;
/* allocate queue page pointers */
- queue->queue_pages = vmalloc(nr_of_pages * sizeof(void *));
+ queue->queue_pages = kmalloc(nr_of_pages * sizeof(void *), GFP_KERNEL);
if (!queue->queue_pages) {
- ehca_gen_err("Couldn't allocate queue page list");
- return 0;
+ queue->queue_pages = vmalloc(nr_of_pages * sizeof(void *));
+ if (!queue->queue_pages) {
+ ehca_gen_err("Couldn't allocate queue page list");
+ return 0;
+ }
}
memset(queue->queue_pages, 0, nr_of_pages * sizeof(void *));
@@ -240,7 +243,10 @@ int ipz_queue_ctor(struct ehca_pd *pd, struct ipz_queue *queue,
ipz_queue_ctor_exit0:
ehca_gen_err("Couldn't alloc pages queue=%p "
"nr_of_pages=%x", queue, nr_of_pages);
- vfree(queue->queue_pages);
+ if (is_vmalloc_addr(queue->queue_pages))
+ vfree(queue->queue_pages);
+ else
+ kfree(queue->queue_pages);
return 0;
}
@@ -262,7 +268,10 @@ int ipz_queue_dtor(struct ehca_pd *pd, struct ipz_queue *queue)
free_page((unsigned long)queue->queue_pages[i]);
}
- vfree(queue->queue_pages);
+ if (is_vmalloc_addr(queue->queue_pages))
+ vfree(queue->queue_pages);
+ else
+ kfree(queue->queue_pages);
return 1;
}
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index b832a7b814a2..4a84d02ece06 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -667,7 +667,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
i = 0;
while (((nes_read32(nesdev->regs+NES_SOFTWARE_RESET) & 0x00000040) == 0) && i++ < 10000)
mdelay(1);
- if (i >= 10000) {
+ if (i > 10000) {
nes_debug(NES_DBG_INIT, "Did not see full soft reset done.\n");
return 0;
}
@@ -675,7 +675,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
i = 0;
while ((nes_read_indexed(nesdev, NES_IDX_INT_CPU_STATUS) != 0x80) && i++ < 10000)
mdelay(1);
- if (i >= 10000) {
+ if (i > 10000) {
printk(KERN_ERR PFX "Internal CPU not ready, status = %02X\n",
nes_read_indexed(nesdev, NES_IDX_INT_CPU_STATUS));
return 0;
@@ -701,7 +701,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
i = 0;
while (((nes_read32(nesdev->regs+NES_SOFTWARE_RESET) & 0x00000040) == 0) && i++ < 10000)
mdelay(1);
- if (i >= 10000) {
+ if (i > 10000) {
nes_debug(NES_DBG_INIT, "Did not see port soft reset done.\n");
return 0;
}
@@ -711,7 +711,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0)
& 0x0000000f)) != 0x0000000f) && i++ < 5000)
mdelay(1);
- if (i >= 5000) {
+ if (i > 5000) {
nes_debug(NES_DBG_INIT, "Serdes 0 not ready, status=%x\n", u32temp);
return 0;
}
@@ -722,7 +722,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS1)
& 0x0000000f)) != 0x0000000f) && i++ < 5000)
mdelay(1);
- if (i >= 5000) {
+ if (i > 5000) {
nes_debug(NES_DBG_INIT, "Serdes 1 not ready, status=%x\n", u32temp);
return 0;
}
@@ -792,7 +792,7 @@ static int nes_init_serdes(struct nes_device *nesdev, u8 hw_rev, u8 port_count,
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0)
& 0x0000000f)) != 0x0000000f) && i++ < 5000)
mdelay(1);
- if (i >= 5000) {
+ if (i > 5000) {
nes_debug(NES_DBG_PHY, "Init: serdes 0 not ready, status=%x\n", u32temp);
return 1;
}
@@ -815,7 +815,7 @@ static int nes_init_serdes(struct nes_device *nesdev, u8 hw_rev, u8 port_count,
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS1)
& 0x0000000f)) != 0x0000000f) && (i++ < 5000))
mdelay(1);
- if (i >= 5000) {
+ if (i > 5000) {
printk("%s: Init: serdes 1 not ready, status=%x\n", __func__, u32temp);
/* return 1; */
}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 47d588ba2a7f..4248c3139364 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1455,13 +1455,15 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
struct net_device *dev = to_net_dev(d);
struct ipoib_dev_priv *priv = netdev_priv(dev);
+ if (!rtnl_trylock())
+ return restart_syscall();
+
/* flush paths if we switch modes so that connections are restarted */
if (IPOIB_CM_SUPPORTED(dev->dev_addr) && !strcmp(buf, "connected\n")) {
set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
ipoib_warn(priv, "enabling connected mode "
"will cause multicast packet drops\n");
- rtnl_lock();
dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO);
rtnl_unlock();
priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM;
@@ -1473,7 +1475,6 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
if (!strcmp(buf, "datagram\n")) {
clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
- rtnl_lock();
if (test_bit(IPOIB_FLAG_CSUM, &priv->flags)) {
dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
if (priv->hca_caps & IB_DEVICE_UD_TSO)
@@ -1485,6 +1486,7 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
return count;
}
+ rtnl_unlock();
return -EINVAL;
}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 4c57f329dd50..e3bf00d8cd25 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -61,7 +61,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
ppriv = netdev_priv(pdev);
- rtnl_lock();
+ if (!rtnl_trylock())
+ return restart_syscall();
mutex_lock(&ppriv->vlan_mutex);
/*
@@ -167,7 +168,8 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
ppriv = netdev_priv(pdev);
- rtnl_lock();
+ if (!rtnl_trylock())
+ return restart_syscall();
mutex_lock(&ppriv->vlan_mutex);
list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) {
if (priv->pkey == pkey) {
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 75223f50de58..0ba6ec876296 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -257,11 +257,8 @@ static void iscsi_iser_cleanup_task(struct iscsi_task *task)
{
struct iscsi_iser_task *iser_task = task->dd_data;
- /*
- * mgmt tasks do not need special cleanup and we do not
- * allocate anything in the init task callout
- */
- if (!task->sc || task->state == ISCSI_TASK_PENDING)
+ /* mgmt tasks do not need special cleanup */
+ if (!task->sc)
return;
if (iser_task->status == ISER_TASK_STATUS_STARTED) {
@@ -517,7 +514,8 @@ iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *s
}
static struct iscsi_endpoint *
-iscsi_iser_ep_connect(struct sockaddr *dst_addr, int non_blocking)
+iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
+ int non_blocking)
{
int err;
struct iser_conn *ib_conn;
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 7a7a026ba712..c238116400b3 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -25,7 +25,6 @@ struct evdev {
int exist;
int open;
int minor;
- char name[16];
struct input_handle handle;
wait_queue_head_t wait;
struct evdev_client *grab;
@@ -609,7 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
p, compat_mode);
if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
- return str_to_user(dev->name, _IOC_SIZE(cmd), p);
+ return str_to_user(dev_name(&evdev->dev),
+ _IOC_SIZE(cmd), p);
if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
@@ -807,16 +807,15 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
mutex_init(&evdev->mutex);
init_waitqueue_head(&evdev->wait);
- snprintf(evdev->name, sizeof(evdev->name), "event%d", minor);
+ dev_set_name(&evdev->dev, "event%d", minor);
evdev->exist = 1;
evdev->minor = minor;
evdev->handle.dev = input_get_device(dev);
- evdev->handle.name = evdev->name;
+ evdev->handle.name = dev_name(&evdev->dev);
evdev->handle.handler = handler;
evdev->handle.private = evdev;
- dev_set_name(&evdev->dev, evdev->name);
evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor);
evdev->dev.class = &input_class;
evdev->dev.parent = &dev->dev;
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 1dec00e20dbc..8a1810f88b9e 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -167,5 +167,6 @@ module_exit(fm801_gp_exit);
MODULE_DEVICE_TABLE(pci, fm801_gp_id_table);
+MODULE_DESCRIPTION("FM801 gameport driver");
MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
MODULE_LICENSE("GPL");
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 2d175b5928ff..ac11be08585e 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -30,16 +30,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Generic gameport layer");
MODULE_LICENSE("GPL");
-EXPORT_SYMBOL(__gameport_register_port);
-EXPORT_SYMBOL(gameport_unregister_port);
-EXPORT_SYMBOL(__gameport_register_driver);
-EXPORT_SYMBOL(gameport_unregister_driver);
-EXPORT_SYMBOL(gameport_open);
-EXPORT_SYMBOL(gameport_close);
-EXPORT_SYMBOL(gameport_set_phys);
-EXPORT_SYMBOL(gameport_start_polling);
-EXPORT_SYMBOL(gameport_stop_polling);
-
/*
* gameport_mutex protects entire gameport subsystem and is taken
* every time gameport port or driver registrered or unregistered.
@@ -162,6 +152,7 @@ void gameport_start_polling(struct gameport *gameport)
spin_unlock(&gameport->timer_lock);
}
+EXPORT_SYMBOL(gameport_start_polling);
void gameport_stop_polling(struct gameport *gameport)
{
@@ -172,6 +163,7 @@ void gameport_stop_polling(struct gameport *gameport)
spin_unlock(&gameport->timer_lock);
}
+EXPORT_SYMBOL(gameport_stop_polling);
static void gameport_run_poll_handler(unsigned long d)
{
@@ -516,6 +508,7 @@ void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
vsnprintf(gameport->phys, sizeof(gameport->phys), fmt, args);
va_end(args);
}
+EXPORT_SYMBOL(gameport_set_phys);
/*
* Prepare gameport port for registration.
@@ -658,6 +651,7 @@ void __gameport_register_port(struct gameport *gameport, struct module *owner)
gameport_init_port(gameport);
gameport_queue_event(gameport, owner, GAMEPORT_REGISTER_PORT);
}
+EXPORT_SYMBOL(__gameport_register_port);
/*
* Synchronously unregisters gameport port.
@@ -669,6 +663,7 @@ void gameport_unregister_port(struct gameport *gameport)
gameport_destroy_port(gameport);
mutex_unlock(&gameport_mutex);
}
+EXPORT_SYMBOL(gameport_unregister_port);
/*
@@ -728,7 +723,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
* Temporarily disable automatic binding because probing
* takes long time and we are better off doing it in kgameportd
*/
- drv->ignore = 1;
+ drv->ignore = true;
error = driver_register(&drv->driver);
if (error) {
@@ -741,7 +736,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
/*
* Reset ignore flag and let kgameportd bind the driver to free ports
*/
- drv->ignore = 0;
+ drv->ignore = false;
error = gameport_queue_event(drv, NULL, GAMEPORT_ATTACH_DRIVER);
if (error) {
driver_unregister(&drv->driver);
@@ -750,6 +745,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
return 0;
}
+EXPORT_SYMBOL(__gameport_register_driver);
void gameport_unregister_driver(struct gameport_driver *drv)
{
@@ -757,7 +753,7 @@ void gameport_unregister_driver(struct gameport_driver *drv)
mutex_lock(&gameport_mutex);
- drv->ignore = 1; /* so gameport_find_driver ignores it */
+ drv->ignore = true; /* so gameport_find_driver ignores it */
gameport_remove_pending_events(drv);
start_over:
@@ -774,6 +770,7 @@ start_over:
mutex_unlock(&gameport_mutex);
}
+EXPORT_SYMBOL(gameport_unregister_driver);
static int gameport_bus_match(struct device *dev, struct device_driver *drv)
{
@@ -812,6 +809,7 @@ int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mo
gameport_set_drv(gameport, drv);
return 0;
}
+EXPORT_SYMBOL(gameport_open);
void gameport_close(struct gameport *gameport)
{
@@ -822,6 +820,7 @@ void gameport_close(struct gameport *gameport)
if (gameport->close)
gameport->close(gameport);
}
+EXPORT_SYMBOL(gameport_close);
static int __init gameport_init(void)
{
diff --git a/drivers/input/input.c b/drivers/input/input.c
index e54e002665b0..7c237e6ac711 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -42,6 +42,7 @@ static unsigned int input_abs_bypass_init_data[] __initdata = {
ABS_MT_POSITION_Y,
ABS_MT_TOOL_TYPE,
ABS_MT_BLOB_ID,
+ ABS_MT_TRACKING_ID,
0
};
static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)];
@@ -1264,8 +1265,14 @@ static struct device_type input_dev_type = {
.uevent = input_dev_uevent,
};
+static char *input_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "input/%s", dev_name(dev));
+}
+
struct class input_class = {
.name = "input",
+ .nodename = input_nodename,
};
EXPORT_SYMBOL_GPL(input_class);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 012a5e753991..0e12f89276a3 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -39,7 +39,6 @@ struct joydev {
int exist;
int open;
int minor;
- char name[16];
struct input_handle handle;
wait_queue_head_t wait;
struct list_head client_list;
@@ -537,12 +536,14 @@ static int joydev_ioctl_common(struct joydev *joydev,
default:
if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) {
int len;
- if (!dev->name)
+ const char *name = dev_name(&dev->dev);
+
+ if (!name)
return 0;
- len = strlen(dev->name) + 1;
+ len = strlen(name) + 1;
if (len > _IOC_SIZE(cmd))
len = _IOC_SIZE(cmd);
- if (copy_to_user(argp, dev->name, len))
+ if (copy_to_user(argp, name, len))
return -EFAULT;
return len;
}
@@ -742,13 +743,13 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
mutex_init(&joydev->mutex);
init_waitqueue_head(&joydev->wait);
- snprintf(joydev->name, sizeof(joydev->name), "js%d", minor);
+ dev_set_name(&joydev->dev, "js%d", minor);
joydev->exist = 1;
joydev->minor = minor;
joydev->exist = 1;
joydev->handle.dev = input_get_device(dev);
- joydev->handle.name = joydev->name;
+ joydev->handle.name = dev_name(&joydev->dev);
joydev->handle.handler = handler;
joydev->handle.private = joydev;
@@ -797,7 +798,6 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
}
}
- dev_set_name(&joydev->dev, joydev->name);
joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor);
joydev->dev.class = &input_class;
joydev->dev.parent = &dev->dev;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index ea2638b41982..9d8f796c6745 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -250,6 +250,17 @@ config KEYBOARD_HP7XX
To compile this driver as a module, choose M here: the
module will be called jornada720_kbd.
+config KEYBOARD_LM8323
+ tristate "LM8323 keypad chip"
+ depends on I2C
+ depends on LEDS_CLASS
+ help
+ If you say yes here you get support for the National Semiconductor
+ LM8323 keypad controller.
+
+ To compile this driver as a module, choose M here: the
+ module will be called lm8323.
+
config KEYBOARD_OMAP
tristate "TI OMAP keypad support"
depends on (ARCH_OMAP1 || ARCH_OMAP2)
@@ -332,4 +343,14 @@ config KEYBOARD_SH_KEYSC
To compile this driver as a module, choose M here: the
module will be called sh_keysc.
+
+config KEYBOARD_EP93XX
+ tristate "EP93xx Matrix Keypad support"
+ depends on ARCH_EP93XX
+ help
+ Say Y here to enable the matrix keypad on the Cirrus EP93XX.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ep93xx_keypad.
+
endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 36351e1190f9..156b647a259b 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
+obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o
obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
@@ -28,3 +29,4 @@ obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
+obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
new file mode 100644
index 000000000000..181d30e3018e
--- /dev/null
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -0,0 +1,470 @@
+/*
+ * Driver for the Cirrus EP93xx matrix keypad controller.
+ *
+ * Copyright (c) 2008 H Hartley Sweeten <hsweeten@visionengravers.com>
+ *
+ * Based on the pxa27x matrix keypad controller by Rodolfo Giometti.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * NOTE:
+ *
+ * The 3-key reset is triggered by pressing the 3 keys in
+ * Row 0, Columns 2, 4, and 7 at the same time. This action can
+ * be disabled by setting the EP93XX_KEYPAD_DISABLE_3_KEY flag.
+ *
+ * Normal operation for the matrix does not autorepeat the key press.
+ * This action can be enabled by setting the EP93XX_KEYPAD_AUTOREPEAT
+ * flag.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/clk.h>
+
+#include <mach/hardware.h>
+#include <mach/gpio.h>
+#include <mach/ep93xx_keypad.h>
+
+/*
+ * Keypad Interface Register offsets
+ */
+#define KEY_INIT 0x00 /* Key Scan Initialization register */
+#define KEY_DIAG 0x04 /* Key Scan Diagnostic register */
+#define KEY_REG 0x08 /* Key Value Capture register */
+
+/* Key Scan Initialization Register bit defines */
+#define KEY_INIT_DBNC_MASK (0x00ff0000)
+#define KEY_INIT_DBNC_SHIFT (16)
+#define KEY_INIT_DIS3KY (1<<15)
+#define KEY_INIT_DIAG (1<<14)
+#define KEY_INIT_BACK (1<<13)
+#define KEY_INIT_T2 (1<<12)
+#define KEY_INIT_PRSCL_MASK (0x000003ff)
+#define KEY_INIT_PRSCL_SHIFT (0)
+
+/* Key Scan Diagnostic Register bit defines */
+#define KEY_DIAG_MASK (0x0000003f)
+#define KEY_DIAG_SHIFT (0)
+
+/* Key Value Capture Register bit defines */
+#define KEY_REG_K (1<<15)
+#define KEY_REG_INT (1<<14)
+#define KEY_REG_2KEYS (1<<13)
+#define KEY_REG_1KEY (1<<12)
+#define KEY_REG_KEY2_MASK (0x00000fc0)
+#define KEY_REG_KEY2_SHIFT (6)
+#define KEY_REG_KEY1_MASK (0x0000003f)
+#define KEY_REG_KEY1_SHIFT (0)
+
+#define keypad_readl(off) __raw_readl(keypad->mmio_base + (off))
+#define keypad_writel(v, off) __raw_writel((v), keypad->mmio_base + (off))
+
+#define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS)
+
+struct ep93xx_keypad {
+ struct ep93xx_keypad_platform_data *pdata;
+
+ struct clk *clk;
+ struct input_dev *input_dev;
+ void __iomem *mmio_base;
+
+ int irq;
+ int enabled;
+
+ int key1;
+ int key2;
+
+ unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM];
+};
+
+static void ep93xx_keypad_build_keycode(struct ep93xx_keypad *keypad)
+{
+ struct ep93xx_keypad_platform_data *pdata = keypad->pdata;
+ struct input_dev *input_dev = keypad->input_dev;
+ int i;
+
+ for (i = 0; i < pdata->matrix_key_map_size; i++) {
+ unsigned int key = pdata->matrix_key_map[i];
+ int row = (key >> 28) & 0xf;
+ int col = (key >> 24) & 0xf;
+ int code = key & 0xffffff;
+
+ keypad->matrix_keycodes[(row << 3) + col] = code;
+ __set_bit(code, input_dev->keybit);
+ }
+}
+
+static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
+{
+ struct ep93xx_keypad *keypad = dev_id;
+ struct input_dev *input_dev = keypad->input_dev;
+ unsigned int status = keypad_readl(KEY_REG);
+ int keycode, key1, key2;
+
+ keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT;
+ key1 = keypad->matrix_keycodes[keycode];
+
+ keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT;
+ key2 = keypad->matrix_keycodes[keycode];
+
+ if (status & KEY_REG_2KEYS) {
+ if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1)
+ input_report_key(input_dev, keypad->key1, 0);
+
+ if (keypad->key2 && key1 != keypad->key2 && key2 != keypad->key2)
+ input_report_key(input_dev, keypad->key2, 0);
+
+ input_report_key(input_dev, key1, 1);
+ input_report_key(input_dev, key2, 1);
+
+ keypad->key1 = key1;
+ keypad->key2 = key2;
+
+ } else if (status & KEY_REG_1KEY) {
+ if (keypad->key1 && key1 != keypad->key1)
+ input_report_key(input_dev, keypad->key1, 0);
+
+ if (keypad->key2 && key1 != keypad->key2)
+ input_report_key(input_dev, keypad->key2, 0);
+
+ input_report_key(input_dev, key1, 1);
+
+ keypad->key1 = key1;
+ keypad->key2 = 0;
+
+ } else {
+ input_report_key(input_dev, keypad->key1, 0);
+ input_report_key(input_dev, keypad->key2, 0);
+
+ keypad->key1 = keypad->key2 = 0;
+ }
+ input_sync(input_dev);
+
+ return IRQ_HANDLED;
+}
+
+static void ep93xx_keypad_config(struct ep93xx_keypad *keypad)
+{
+ struct ep93xx_keypad_platform_data *pdata = keypad->pdata;
+ unsigned int val = 0;
+
+ clk_set_rate(keypad->clk, pdata->flags & EP93XX_KEYPAD_KDIV);
+
+ if (pdata->flags & EP93XX_KEYPAD_DISABLE_3_KEY)
+ val |= KEY_INIT_DIS3KY;
+ if (pdata->flags & EP93XX_KEYPAD_DIAG_MODE)
+ val |= KEY_INIT_DIAG;
+ if (pdata->flags & EP93XX_KEYPAD_BACK_DRIVE)
+ val |= KEY_INIT_BACK;
+ if (pdata->flags & EP93XX_KEYPAD_TEST_MODE)
+ val |= KEY_INIT_T2;
+
+ val |= ((pdata->debounce << KEY_INIT_DBNC_SHIFT) & KEY_INIT_DBNC_MASK);
+
+ val |= ((pdata->prescale << KEY_INIT_PRSCL_SHIFT) & KEY_INIT_PRSCL_MASK);
+
+ keypad_writel(val, KEY_INIT);
+}
+
+static int ep93xx_keypad_open(struct input_dev *pdev)
+{
+ struct ep93xx_keypad *keypad = input_get_drvdata(pdev);
+
+ if (!keypad->enabled) {
+ ep93xx_keypad_config(keypad);
+ clk_enable(keypad->clk);
+ keypad->enabled = 1;
+ }
+
+ return 0;
+}
+
+static void ep93xx_keypad_close(struct input_dev *pdev)
+{
+ struct ep93xx_keypad *keypad = input_get_drvdata(pdev);
+
+ if (keypad->enabled) {
+ clk_disable(keypad->clk);
+ keypad->enabled = 0;
+ }
+}
+
+
+#ifdef CONFIG_PM
+/*
+ * NOTE: I don't know if this is correct, or will work on the ep93xx.
+ *
+ * None of the existing ep93xx drivers have power management support.
+ * But, this is basically what the pxa27x_keypad driver does.
+ */
+static int ep93xx_keypad_suspend(struct platform_device *pdev,
+ pm_message_t state)
+{
+ struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct input_dev *input_dev = keypad->input_dev;
+
+ mutex_lock(&input_dev->mutex);
+
+ if (keypad->enabled) {
+ clk_disable(keypad->clk);
+ keypad->enabled = 0;
+ }
+
+ mutex_unlock(&input_dev->mutex);
+
+ if (device_may_wakeup(&pdev->dev))
+ enable_irq_wake(keypad->irq);
+
+ return 0;
+}
+
+static int ep93xx_keypad_resume(struct platform_device *pdev)
+{
+ struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct input_dev *input_dev = keypad->input_dev;
+
+ if (device_may_wakeup(&pdev->dev))
+ disable_irq_wake(keypad->irq);
+
+ mutex_lock(&input_dev->mutex);
+
+ if (input_dev->users) {
+ if (!keypad->enabled) {
+ ep93xx_keypad_config(keypad);
+ clk_enable(keypad->clk);
+ keypad->enabled = 1;
+ }
+ }
+
+ mutex_unlock(&input_dev->mutex);
+
+ return 0;
+}
+#else /* !CONFIG_PM */
+#define ep93xx_keypad_suspend NULL
+#define ep93xx_keypad_resume NULL
+#endif /* !CONFIG_PM */
+
+static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
+{
+ struct ep93xx_keypad *keypad;
+ struct ep93xx_keypad_platform_data *pdata = pdev->dev.platform_data;
+ struct input_dev *input_dev;
+ struct resource *res;
+ int irq, err, i, gpio;
+
+ if (!pdata ||
+ !pdata->matrix_key_rows ||
+ pdata->matrix_key_rows > MAX_MATRIX_KEY_ROWS ||
+ !pdata->matrix_key_cols ||
+ pdata->matrix_key_cols > MAX_MATRIX_KEY_COLS) {
+ dev_err(&pdev->dev, "invalid or missing platform data\n");
+ return -EINVAL;
+ }
+
+ keypad = kzalloc(sizeof(struct ep93xx_keypad), GFP_KERNEL);
+ if (!keypad) {
+ dev_err(&pdev->dev, "failed to allocate driver data\n");
+ return -ENOMEM;
+ }
+
+ keypad->pdata = pdata;
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ dev_err(&pdev->dev, "failed to get keypad irq\n");
+ err = -ENXIO;
+ goto failed_free;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "failed to get I/O memory\n");
+ err = -ENXIO;
+ goto failed_free;
+ }
+
+ res = request_mem_region(res->start, resource_size(res), pdev->name);
+ if (!res) {
+ dev_err(&pdev->dev, "failed to request I/O memory\n");
+ err = -EBUSY;
+ goto failed_free;
+ }
+
+ keypad->mmio_base = ioremap(res->start, resource_size(res));
+ if (keypad->mmio_base == NULL) {
+ dev_err(&pdev->dev, "failed to remap I/O memory\n");
+ err = -ENXIO;
+ goto failed_free_mem;
+ }
+
+ /* Request the needed GPIO's */
+ gpio = EP93XX_GPIO_LINE_ROW0;
+ for (i = 0; i < keypad->pdata->matrix_key_rows; i++, gpio++) {
+ err = gpio_request(gpio, pdev->name);
+ if (err) {
+ dev_err(&pdev->dev, "failed to request gpio-%d\n",
+ gpio);
+ goto failed_free_rows;
+ }
+ }
+
+ gpio = EP93XX_GPIO_LINE_COL0;
+ for (i = 0; i < keypad->pdata->matrix_key_cols; i++, gpio++) {
+ err = gpio_request(gpio, pdev->name);
+ if (err) {
+ dev_err(&pdev->dev, "failed to request gpio-%d\n",
+ gpio);
+ goto failed_free_cols;
+ }
+ }
+
+ keypad->clk = clk_get(&pdev->dev, "key_clk");
+ if (IS_ERR(keypad->clk)) {
+ dev_err(&pdev->dev, "failed to get keypad clock\n");
+ err = PTR_ERR(keypad->clk);
+ goto failed_free_io;
+ }
+
+ /* Create and register the input driver */
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ dev_err(&pdev->dev, "failed to allocate input device\n");
+ err = -ENOMEM;
+ goto failed_put_clk;
+ }
+
+ keypad->input_dev = input_dev;
+
+ input_dev->name = pdev->name;
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->open = ep93xx_keypad_open;
+ input_dev->close = ep93xx_keypad_close;
+ input_dev->dev.parent = &pdev->dev;
+ input_dev->keycode = keypad->matrix_keycodes;
+ input_dev->keycodesize = sizeof(keypad->matrix_keycodes[0]);
+ input_dev->keycodemax = ARRAY_SIZE(keypad->matrix_keycodes);
+
+ input_set_drvdata(input_dev, keypad);
+
+ input_dev->evbit[0] = BIT_MASK(EV_KEY);
+ if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
+ input_dev->evbit[0] |= BIT_MASK(EV_REP);
+
+ ep93xx_keypad_build_keycode(keypad);
+ platform_set_drvdata(pdev, keypad);
+
+ err = request_irq(irq, ep93xx_keypad_irq_handler, IRQF_DISABLED,
+ pdev->name, keypad);
+ if (err) {
+ dev_err(&pdev->dev, "failed to request IRQ\n");
+ goto failed_free_dev;
+ }
+
+ keypad->irq = irq;
+
+ /* Register the input device */
+ err = input_register_device(input_dev);
+ if (err) {
+ dev_err(&pdev->dev, "failed to register input device\n");
+ goto failed_free_irq;
+ }
+
+ device_init_wakeup(&pdev->dev, 1);
+
+ return 0;
+
+failed_free_irq:
+ free_irq(irq, pdev);
+ platform_set_drvdata(pdev, NULL);
+failed_free_dev:
+ input_free_device(input_dev);
+failed_put_clk:
+ clk_put(keypad->clk);
+failed_free_io:
+ i = keypad->pdata->matrix_key_cols - 1;
+ gpio = EP93XX_GPIO_LINE_COL0 + i;
+failed_free_cols:
+ for ( ; i >= 0; i--, gpio--)
+ gpio_free(gpio);
+ i = keypad->pdata->matrix_key_rows - 1;
+ gpio = EP93XX_GPIO_LINE_ROW0 + i;
+failed_free_rows:
+ for ( ; i >= 0; i--, gpio--)
+ gpio_free(gpio);
+ iounmap(keypad->mmio_base);
+failed_free_mem:
+ release_mem_region(res->start, resource_size(res));
+failed_free:
+ kfree(keypad);
+ return err;
+}
+
+static int __devexit ep93xx_keypad_remove(struct platform_device *pdev)
+{
+ struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct resource *res;
+ int i, gpio;
+
+ free_irq(keypad->irq, pdev);
+
+ platform_set_drvdata(pdev, NULL);
+
+ if (keypad->enabled)
+ clk_disable(keypad->clk);
+ clk_put(keypad->clk);
+
+ input_unregister_device(keypad->input_dev);
+
+ i = keypad->pdata->matrix_key_cols - 1;
+ gpio = EP93XX_GPIO_LINE_COL0 + i;
+ for ( ; i >= 0; i--, gpio--)
+ gpio_free(gpio);
+
+ i = keypad->pdata->matrix_key_rows - 1;
+ gpio = EP93XX_GPIO_LINE_ROW0 + i;
+ for ( ; i >= 0; i--, gpio--)
+ gpio_free(gpio);
+
+ iounmap(keypad->mmio_base);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ release_mem_region(res->start, resource_size(res));
+
+ kfree(keypad);
+
+ return 0;
+}
+
+static struct platform_driver ep93xx_keypad_driver = {
+ .driver = {
+ .name = "ep93xx-keypad",
+ .owner = THIS_MODULE,
+ },
+ .probe = ep93xx_keypad_probe,
+ .remove = __devexit_p(ep93xx_keypad_remove),
+ .suspend = ep93xx_keypad_suspend,
+ .resume = ep93xx_keypad_resume,
+};
+
+static int __init ep93xx_keypad_init(void)
+{
+ return platform_driver_register(&ep93xx_keypad_driver);
+}
+
+static void __exit ep93xx_keypad_exit(void)
+{
+ platform_driver_unregister(&ep93xx_keypad_driver);
+}
+
+module_init(ep93xx_keypad_init);
+module_exit(ep93xx_keypad_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>");
+MODULE_DESCRIPTION("EP93xx Matrix Keypad Controller");
+MODULE_ALIAS("platform:ep93xx-keypad");
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ad67d763fdbd..9767213b6c8f 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -142,8 +142,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
}
error = request_irq(irq, gpio_keys_isr,
- IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
- IRQF_TRIGGER_FALLING,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
button->desc ? button->desc : "gpio_keys",
bdata);
if (error) {
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
new file mode 100644
index 000000000000..574eda2a4957
--- /dev/null
+++ b/drivers/input/keyboard/lm8323.c
@@ -0,0 +1,878 @@
+/*
+ * drivers/i2c/chips/lm8323.c
+ *
+ * Copyright (C) 2007-2009 Nokia Corporation
+ *
+ * Written by Daniel Stone <daniel.stone@nokia.com>
+ * Timo O. Karjalainen <timo.o.karjalainen@nokia.com>
+ *
+ * Updated by Felipe Balbi <felipe.balbi@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License only).
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/leds.h>
+#include <linux/i2c/lm8323.h>
+
+/* Commands to send to the chip. */
+#define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */
+#define LM8323_CMD_WRITE_CFG 0x81 /* Set configuration item. */
+#define LM8323_CMD_READ_INT 0x82 /* Get interrupt status. */
+#define LM8323_CMD_RESET 0x83 /* Reset, same as external one */
+#define LM8323_CMD_WRITE_PORT_SEL 0x85 /* Set GPIO in/out. */
+#define LM8323_CMD_WRITE_PORT_STATE 0x86 /* Set GPIO pullup. */
+#define LM8323_CMD_READ_PORT_SEL 0x87 /* Get GPIO in/out. */
+#define LM8323_CMD_READ_PORT_STATE 0x88 /* Get GPIO pullup. */
+#define LM8323_CMD_READ_FIFO 0x89 /* Read byte from FIFO. */
+#define LM8323_CMD_RPT_READ_FIFO 0x8a /* Read FIFO (no increment). */
+#define LM8323_CMD_SET_ACTIVE 0x8b /* Set active time. */
+#define LM8323_CMD_READ_ERR 0x8c /* Get error status. */
+#define LM8323_CMD_READ_ROTATOR 0x8e /* Read rotator status. */
+#define LM8323_CMD_SET_DEBOUNCE 0x8f /* Set debouncing time. */
+#define LM8323_CMD_SET_KEY_SIZE 0x90 /* Set keypad size. */
+#define LM8323_CMD_READ_KEY_SIZE 0x91 /* Get keypad size. */
+#define LM8323_CMD_READ_CFG 0x92 /* Get configuration item. */
+#define LM8323_CMD_WRITE_CLOCK 0x93 /* Set clock config. */
+#define LM8323_CMD_READ_CLOCK 0x94 /* Get clock config. */
+#define LM8323_CMD_PWM_WRITE 0x95 /* Write PWM script. */
+#define LM8323_CMD_START_PWM 0x96 /* Start PWM engine. */
+#define LM8323_CMD_STOP_PWM 0x97 /* Stop PWM engine. */
+
+/* Interrupt status. */
+#define INT_KEYPAD 0x01 /* Key event. */
+#define INT_ROTATOR 0x02 /* Rotator event. */
+#define INT_ERROR 0x08 /* Error: use CMD_READ_ERR. */
+#define INT_NOINIT 0x10 /* Lost configuration. */
+#define INT_PWM1 0x20 /* PWM1 stopped. */
+#define INT_PWM2 0x40 /* PWM2 stopped. */
+#define INT_PWM3 0x80 /* PWM3 stopped. */
+
+/* Errors (signalled by INT_ERROR, read with CMD_READ_ERR). */
+#define ERR_BADPAR 0x01 /* Bad parameter. */
+#define ERR_CMDUNK 0x02 /* Unknown command. */
+#define ERR_KEYOVR 0x04 /* Too many keys pressed. */
+#define ERR_FIFOOVER 0x40 /* FIFO overflow. */
+
+/* Configuration keys (CMD_{WRITE,READ}_CFG). */
+#define CFG_MUX1SEL 0x01 /* Select MUX1_OUT input. */
+#define CFG_MUX1EN 0x02 /* Enable MUX1_OUT. */
+#define CFG_MUX2SEL 0x04 /* Select MUX2_OUT input. */
+#define CFG_MUX2EN 0x08 /* Enable MUX2_OUT. */
+#define CFG_PSIZE 0x20 /* Package size (must be 0). */
+#define CFG_ROTEN 0x40 /* Enable rotator. */
+
+/* Clock settings (CMD_{WRITE,READ}_CLOCK). */
+#define CLK_RCPWM_INTERNAL 0x00
+#define CLK_RCPWM_EXTERNAL 0x03
+#define CLK_SLOWCLKEN 0x08 /* Enable 32.768kHz clock. */
+#define CLK_SLOWCLKOUT 0x40 /* Enable slow pulse output. */
+
+/* The possible addresses corresponding to CONFIG1 and CONFIG2 pin wirings. */
+#define LM8323_I2C_ADDR00 (0x84 >> 1) /* 1000 010x */
+#define LM8323_I2C_ADDR01 (0x86 >> 1) /* 1000 011x */
+#define LM8323_I2C_ADDR10 (0x88 >> 1) /* 1000 100x */
+#define LM8323_I2C_ADDR11 (0x8A >> 1) /* 1000 101x */
+
+/* Key event fifo length */
+#define LM8323_FIFO_LEN 15
+
+/* Commands for PWM engine; feed in with PWM_WRITE. */
+/* Load ramp counter from duty cycle field (range 0 - 0xff). */
+#define PWM_SET(v) (0x4000 | ((v) & 0xff))
+/* Go to start of script. */
+#define PWM_GOTOSTART 0x0000
+/*
+ * Stop engine (generates interrupt). If reset is 1, clear the program
+ * counter, else leave it.
+ */
+#define PWM_END(reset) (0xc000 | (!!(reset) << 11))
+/*
+ * Ramp. If s is 1, divide clock by 512, else divide clock by 16.
+ * Take t clock scales (up to 63) per step, for n steps (up to 126).
+ * If u is set, ramp up, else ramp down.
+ */
+#define PWM_RAMP(s, t, n, u) ((!!(s) << 14) | ((t) & 0x3f) << 8 | \
+ ((n) & 0x7f) | ((u) ? 0 : 0x80))
+/*
+ * Loop (i.e. jump back to pos) for a given number of iterations (up to 63).
+ * If cnt is zero, execute until PWM_END is encountered.
+ */
+#define PWM_LOOP(cnt, pos) (0xa000 | (((cnt) & 0x3f) << 7) | \
+ ((pos) & 0x3f))
+/*
+ * Wait for trigger. Argument is a mask of channels, shifted by the channel
+ * number, e.g. 0xa for channels 3 and 1. Note that channels are numbered
+ * from 1, not 0.
+ */
+#define PWM_WAIT_TRIG(chans) (0xe000 | (((chans) & 0x7) << 6))
+/* Send trigger. Argument is same as PWM_WAIT_TRIG. */
+#define PWM_SEND_TRIG(chans) (0xe000 | ((chans) & 0x7))
+
+struct lm8323_pwm {
+ int id;
+ int fade_time;
+ int brightness;
+ int desired_brightness;
+ bool enabled;
+ bool running;
+ /* pwm lock */
+ struct mutex lock;
+ struct work_struct work;
+ struct led_classdev cdev;
+ struct lm8323_chip *chip;
+};
+
+struct lm8323_chip {
+ /* device lock */
+ struct mutex lock;
+ struct i2c_client *client;
+ struct work_struct work;
+ struct input_dev *idev;
+ bool kp_enabled;
+ bool pm_suspend;
+ unsigned keys_down;
+ char phys[32];
+ unsigned short keymap[LM8323_KEYMAP_SIZE];
+ int size_x;
+ int size_y;
+ int debounce_time;
+ int active_time;
+ struct lm8323_pwm pwm[LM8323_NUM_PWMS];
+};
+
+#define client_to_lm8323(c) container_of(c, struct lm8323_chip, client)
+#define dev_to_lm8323(d) container_of(d, struct lm8323_chip, client->dev)
+#define work_to_lm8323(w) container_of(w, struct lm8323_chip, work)
+#define cdev_to_pwm(c) container_of(c, struct lm8323_pwm, cdev)
+#define work_to_pwm(w) container_of(w, struct lm8323_pwm, work)
+
+#define LM8323_MAX_DATA 8
+
+/*
+ * To write, we just access the chip's address in write mode, and dump the
+ * command and data out on the bus. The command byte and data are taken as
+ * sequential u8s out of varargs, to a maximum of LM8323_MAX_DATA.
+ */
+static int lm8323_write(struct lm8323_chip *lm, int len, ...)
+{
+ int ret, i;
+ va_list ap;
+ u8 data[LM8323_MAX_DATA];
+
+ va_start(ap, len);
+
+ if (unlikely(len > LM8323_MAX_DATA)) {
+ dev_err(&lm->client->dev, "tried to send %d bytes\n", len);
+ va_end(ap);
+ return 0;
+ }
+
+ for (i = 0; i < len; i++)
+ data[i] = va_arg(ap, int);
+
+ va_end(ap);
+
+ /*
+ * If the host is asleep while we send the data, we can get a NACK
+ * back while it wakes up, so try again, once.
+ */
+ ret = i2c_master_send(lm->client, data, len);
+ if (unlikely(ret == -EREMOTEIO))
+ ret = i2c_master_send(lm->client, data, len);
+ if (unlikely(ret != len))
+ dev_err(&lm->client->dev, "sent %d bytes of %d total\n",
+ len, ret);
+
+ return ret;
+}
+
+/*
+ * To read, we first send the command byte to the chip and end the transaction,
+ * then access the chip in read mode, at which point it will send the data.
+ */
+static int lm8323_read(struct lm8323_chip *lm, u8 cmd, u8 *buf, int len)
+{
+ int ret;
+
+ /*
+ * If the host is asleep while we send the byte, we can get a NACK
+ * back while it wakes up, so try again, once.
+ */
+ ret = i2c_master_send(lm->client, &cmd, 1);
+ if (unlikely(ret == -EREMOTEIO))
+ ret = i2c_master_send(lm->client, &cmd, 1);
+ if (unlikely(ret != 1)) {
+ dev_err(&lm->client->dev, "sending read cmd 0x%02x failed\n",
+ cmd);
+ return 0;
+ }
+
+ ret = i2c_master_recv(lm->client, buf, len);
+ if (unlikely(ret != len))
+ dev_err(&lm->client->dev, "wanted %d bytes, got %d\n",
+ len, ret);
+
+ return ret;
+}
+
+/*
+ * Set the chip active time (idle time before it enters halt).
+ */
+static void lm8323_set_active_time(struct lm8323_chip *lm, int time)
+{
+ lm8323_write(lm, 2, LM8323_CMD_SET_ACTIVE, time >> 2);
+}
+
+/*
+ * The signals are AT-style: the low 7 bits are the keycode, and the top
+ * bit indicates the state (1 for down, 0 for up).
+ */
+static inline u8 lm8323_whichkey(u8 event)
+{
+ return event & 0x7f;
+}
+
+static inline int lm8323_ispress(u8 event)
+{
+ return (event & 0x80) ? 1 : 0;
+}
+
+static void process_keys(struct lm8323_chip *lm)
+{
+ u8 event;
+ u8 key_fifo[LM8323_FIFO_LEN + 1];
+ int old_keys_down = lm->keys_down;
+ int ret;
+ int i = 0;
+
+ /*
+ * Read all key events from the FIFO at once. Next READ_FIFO clears the
+ * FIFO even if we didn't read all events previously.
+ */
+ ret = lm8323_read(lm, LM8323_CMD_READ_FIFO, key_fifo, LM8323_FIFO_LEN);
+
+ if (ret < 0) {
+ dev_err(&lm->client->dev, "Failed reading fifo \n");
+ return;
+ }
+ key_fifo[ret] = 0;
+
+ while ((event = key_fifo[i++])) {
+ u8 key = lm8323_whichkey(event);
+ int isdown = lm8323_ispress(event);
+ unsigned short keycode = lm->keymap[key];
+
+ dev_vdbg(&lm->client->dev, "key 0x%02x %s\n",
+ key, isdown ? "down" : "up");
+
+ if (lm->kp_enabled) {
+ input_event(lm->idev, EV_MSC, MSC_SCAN, key);
+ input_report_key(lm->idev, keycode, isdown);
+ input_sync(lm->idev);
+ }
+
+ if (isdown)
+ lm->keys_down++;
+ else
+ lm->keys_down--;
+ }
+
+ /*
+ * Errata: We need to ensure that the chip never enters halt mode
+ * during a keypress, so set active time to 0. When it's released,
+ * we can enter halt again, so set the active time back to normal.
+ */
+ if (!old_keys_down && lm->keys_down)
+ lm8323_set_active_time(lm, 0);
+ if (old_keys_down && !lm->keys_down)
+ lm8323_set_active_time(lm, lm->active_time);
+}
+
+static void lm8323_process_error(struct lm8323_chip *lm)
+{
+ u8 error;
+
+ if (lm8323_read(lm, LM8323_CMD_READ_ERR, &error, 1) == 1) {
+ if (error & ERR_FIFOOVER)
+ dev_vdbg(&lm->client->dev, "fifo overflow!\n");
+ if (error & ERR_KEYOVR)
+ dev_vdbg(&lm->client->dev,
+ "more than two keys pressed\n");
+ if (error & ERR_CMDUNK)
+ dev_vdbg(&lm->client->dev,
+ "unknown command submitted\n");
+ if (error & ERR_BADPAR)
+ dev_vdbg(&lm->client->dev, "bad command parameter\n");
+ }
+}
+
+static void lm8323_reset(struct lm8323_chip *lm)
+{
+ /* The docs say we must pass 0xAA as the data byte. */
+ lm8323_write(lm, 2, LM8323_CMD_RESET, 0xAA);
+}
+
+static int lm8323_configure(struct lm8323_chip *lm)
+{
+ int keysize = (lm->size_x << 4) | lm->size_y;
+ int clock = (CLK_SLOWCLKEN | CLK_RCPWM_EXTERNAL);
+ int debounce = lm->debounce_time >> 2;
+ int active = lm->active_time >> 2;
+
+ /*
+ * Active time must be greater than the debounce time: if it's
+ * a close-run thing, give ourselves a 12ms buffer.
+ */
+ if (debounce >= active)
+ active = debounce + 3;
+
+ lm8323_write(lm, 2, LM8323_CMD_WRITE_CFG, 0);
+ lm8323_write(lm, 2, LM8323_CMD_WRITE_CLOCK, clock);
+ lm8323_write(lm, 2, LM8323_CMD_SET_KEY_SIZE, keysize);
+ lm8323_set_active_time(lm, lm->active_time);
+ lm8323_write(lm, 2, LM8323_CMD_SET_DEBOUNCE, debounce);
+ lm8323_write(lm, 3, LM8323_CMD_WRITE_PORT_STATE, 0xff, 0xff);
+ lm8323_write(lm, 3, LM8323_CMD_WRITE_PORT_SEL, 0, 0);
+
+ /*
+ * Not much we can do about errors at this point, so just hope
+ * for the best.
+ */
+
+ return 0;
+}
+
+static void pwm_done(struct lm8323_pwm *pwm)
+{
+ mutex_lock(&pwm->lock);
+ pwm->running = false;
+ if (pwm->desired_brightness != pwm->brightness)
+ schedule_work(&pwm->work);
+ mutex_unlock(&pwm->lock);
+}
+
+/*
+ * Bottom half: handle the interrupt by posting key events, or dealing with
+ * errors appropriately.
+ */
+static void lm8323_work(struct work_struct *work)
+{
+ struct lm8323_chip *lm = work_to_lm8323(work);
+ u8 ints;
+ int i;
+
+ mutex_lock(&lm->lock);
+
+ while ((lm8323_read(lm, LM8323_CMD_READ_INT, &ints, 1) == 1) && ints) {
+ if (likely(ints & INT_KEYPAD))
+ process_keys(lm);
+ if (ints & INT_ROTATOR) {
+ /* We don't currently support the rotator. */
+ dev_vdbg(&lm->client->dev, "rotator fired\n");
+ }
+ if (ints & INT_ERROR) {
+ dev_vdbg(&lm->client->dev, "error!\n");
+ lm8323_process_error(lm);
+ }
+ if (ints & INT_NOINIT) {
+ dev_err(&lm->client->dev, "chip lost config; "
+ "reinitialising\n");
+ lm8323_configure(lm);
+ }
+ for (i = 0; i < LM8323_NUM_PWMS; i++) {
+ if (ints & (1 << (INT_PWM1 + i))) {
+ dev_vdbg(&lm->client->dev,
+ "pwm%d engine completed\n", i);
+ pwm_done(&lm->pwm[i]);
+ }
+ }
+ }
+
+ mutex_unlock(&lm->lock);
+}
+
+/*
+ * We cannot use I2C in interrupt context, so we just schedule work.
+ */
+static irqreturn_t lm8323_irq(int irq, void *data)
+{
+ struct lm8323_chip *lm = data;
+
+ schedule_work(&lm->work);
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * Read the chip ID.
+ */
+static int lm8323_read_id(struct lm8323_chip *lm, u8 *buf)
+{
+ int bytes;
+
+ bytes = lm8323_read(lm, LM8323_CMD_READ_ID, buf, 2);
+ if (unlikely(bytes != 2))
+ return -EIO;
+
+ return 0;
+}
+
+static void lm8323_write_pwm_one(struct lm8323_pwm *pwm, int pos, u16 cmd)
+{
+ lm8323_write(pwm->chip, 4, LM8323_CMD_PWM_WRITE, (pos << 2) | pwm->id,
+ (cmd & 0xff00) >> 8, cmd & 0x00ff);
+}
+
+/*
+ * Write a script into a given PWM engine, concluding with PWM_END.
+ * If 'kill' is nonzero, the engine will be shut down at the end
+ * of the script, producing a zero output. Otherwise the engine
+ * will be kept running at the final PWM level indefinitely.
+ */
+static void lm8323_write_pwm(struct lm8323_pwm *pwm, int kill,
+ int len, const u16 *cmds)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ lm8323_write_pwm_one(pwm, i, cmds[i]);
+
+ lm8323_write_pwm_one(pwm, i++, PWM_END(kill));
+ lm8323_write(pwm->chip, 2, LM8323_CMD_START_PWM, pwm->id);
+ pwm->running = true;
+}
+
+static void lm8323_pwm_work(struct work_struct *work)
+{
+ struct lm8323_pwm *pwm = work_to_pwm(work);
+ int div512, perstep, steps, hz, up, kill;
+ u16 pwm_cmds[3];
+ int num_cmds = 0;
+
+ mutex_lock(&pwm->lock);
+
+ /*
+ * Do nothing if we're already at the requested level,
+ * or previous setting is not yet complete. In the latter
+ * case we will be called again when the previous PWM script
+ * finishes.
+ */
+ if (pwm->running || pwm->desired_brightness == pwm->brightness)
+ goto out;
+
+ kill = (pwm->desired_brightness == 0);
+ up = (pwm->desired_brightness > pwm->brightness);
+ steps = abs(pwm->desired_brightness - pwm->brightness);
+
+ /*
+ * Convert time (in ms) into a divisor (512 or 16 on a refclk of
+ * 32768Hz), and number of ticks per step.
+ */
+ if ((pwm->fade_time / steps) > (32768 / 512)) {
+ div512 = 1;
+ hz = 32768 / 512;
+ } else {
+ div512 = 0;
+ hz = 32768 / 16;
+ }
+
+ perstep = (hz * pwm->fade_time) / (steps * 1000);
+
+ if (perstep == 0)
+ perstep = 1;
+ else if (perstep > 63)
+ perstep = 63;
+
+ while (steps) {
+ int s;
+
+ s = min(126, steps);
+ pwm_cmds[num_cmds++] = PWM_RAMP(div512, perstep, s, up);
+ steps -= s;
+ }
+
+ lm8323_write_pwm(pwm, kill, num_cmds, pwm_cmds);
+ pwm->brightness = pwm->desired_brightness;
+
+ out:
+ mutex_unlock(&pwm->lock);
+}
+
+static void lm8323_pwm_set_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
+ struct lm8323_chip *lm = pwm->chip;
+
+ mutex_lock(&pwm->lock);
+ pwm->desired_brightness = brightness;
+ mutex_unlock(&pwm->lock);
+
+ if (in_interrupt()) {
+ schedule_work(&pwm->work);
+ } else {
+ /*
+ * Schedule PWM work as usual unless we are going into suspend
+ */
+ mutex_lock(&lm->lock);
+ if (likely(!lm->pm_suspend))
+ schedule_work(&pwm->work);
+ else
+ lm8323_pwm_work(&pwm->work);
+ mutex_unlock(&lm->lock);
+ }
+}
+
+static ssize_t lm8323_pwm_show_time(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct led_classdev *led_cdev = dev_get_drvdata(dev);
+ struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
+
+ return sprintf(buf, "%d\n", pwm->fade_time);
+}
+
+static ssize_t lm8323_pwm_store_time(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct led_classdev *led_cdev = dev_get_drvdata(dev);
+ struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
+ int ret;
+ unsigned long time;
+
+ ret = strict_strtoul(buf, 10, &time);
+ /* Numbers only, please. */
+ if (ret)
+ return -EINVAL;
+
+ pwm->fade_time = time;
+
+ return strlen(buf);
+}
+static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time);
+
+static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
+ const char *name)
+{
+ struct lm8323_pwm *pwm;
+
+ BUG_ON(id > 3);
+
+ pwm = &lm->pwm[id - 1];
+
+ pwm->id = id;
+ pwm->fade_time = 0;
+ pwm->brightness = 0;
+ pwm->desired_brightness = 0;
+ pwm->running = false;
+ pwm->enabled = false;
+ INIT_WORK(&pwm->work, lm8323_pwm_work);
+ mutex_init(&pwm->lock);
+ pwm->chip = lm;
+
+ if (name) {
+ pwm->cdev.name = name;
+ pwm->cdev.brightness_set = lm8323_pwm_set_brightness;
+ if (led_classdev_register(dev, &pwm->cdev) < 0) {
+ dev_err(dev, "couldn't register PWM %d\n", id);
+ return -1;
+ }
+ if (device_create_file(pwm->cdev.dev,
+ &dev_attr_time) < 0) {
+ dev_err(dev, "couldn't register time attribute\n");
+ led_classdev_unregister(&pwm->cdev);
+ return -1;
+ }
+ pwm->enabled = true;
+ }
+
+ return 0;
+}
+
+static struct i2c_driver lm8323_i2c_driver;
+
+static ssize_t lm8323_show_disable(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct lm8323_chip *lm = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%u\n", !lm->kp_enabled);
+}
+
+static ssize_t lm8323_set_disable(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct lm8323_chip *lm = dev_get_drvdata(dev);
+ int ret;
+ unsigned long i;
+
+ ret = strict_strtoul(buf, 10, &i);
+
+ mutex_lock(&lm->lock);
+ lm->kp_enabled = !i;
+ mutex_unlock(&lm->lock);
+
+ return count;
+}
+static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable);
+
+static int __devinit lm8323_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct lm8323_platform_data *pdata = client->dev.platform_data;
+ struct input_dev *idev;
+ struct lm8323_chip *lm;
+ int i, err;
+ unsigned long tmo;
+ u8 data[2];
+
+ if (!pdata || !pdata->size_x || !pdata->size_y) {
+ dev_err(&client->dev, "missing platform_data\n");
+ return -EINVAL;
+ }
+
+ if (pdata->size_x > 8) {
+ dev_err(&client->dev, "invalid x size %d specified\n",
+ pdata->size_x);
+ return -EINVAL;
+ }
+
+ if (pdata->size_y > 12) {
+ dev_err(&client->dev, "invalid y size %d specified\n",
+ pdata->size_y);
+ return -EINVAL;
+ }
+
+ lm = kzalloc(sizeof *lm, GFP_KERNEL);
+ idev = input_allocate_device();
+ if (!lm || !idev) {
+ err = -ENOMEM;
+ goto fail1;
+ }
+
+ i2c_set_clientdata(client, lm);
+
+ lm->client = client;
+ lm->idev = idev;
+ mutex_init(&lm->lock);
+ INIT_WORK(&lm->work, lm8323_work);
+
+ lm->size_x = pdata->size_x;
+ lm->size_y = pdata->size_y;
+ dev_vdbg(&client->dev, "Keypad size: %d x %d\n",
+ lm->size_x, lm->size_y);
+
+ lm->debounce_time = pdata->debounce_time;
+ lm->active_time = pdata->active_time;
+
+ lm8323_reset(lm);
+
+ /* Nothing's set up to service the IRQ yet, so just spin for max.
+ * 100ms until we can configure. */
+ tmo = jiffies + msecs_to_jiffies(100);
+ while (lm8323_read(lm, LM8323_CMD_READ_INT, data, 1) == 1) {
+ if (data[0] & INT_NOINIT)
+ break;
+
+ if (time_after(jiffies, tmo)) {
+ dev_err(&client->dev,
+ "timeout waiting for initialisation\n");
+ break;
+ }
+
+ msleep(1);
+ }
+
+ lm8323_configure(lm);
+
+ /* If a true probe check the device */
+ if (lm8323_read_id(lm, data) != 0) {
+ dev_err(&client->dev, "device not found\n");
+ err = -ENODEV;
+ goto fail1;
+ }
+
+ for (i = 0; i < LM8323_NUM_PWMS; i++) {
+ err = init_pwm(lm, i + 1, &client->dev, pdata->pwm_names[i]);
+ if (err < 0)
+ goto fail2;
+ }
+
+ lm->kp_enabled = true;
+ err = device_create_file(&client->dev, &dev_attr_disable_kp);
+ if (err < 0)
+ goto fail2;
+
+ idev->name = pdata->name ? : "LM8323 keypad";
+ snprintf(lm->phys, sizeof(lm->phys),
+ "%s/input-kp", dev_name(&client->dev));
+ idev->phys = lm->phys;
+
+ idev->evbit[0] = BIT(EV_KEY) | BIT(EV_MSC);
+ __set_bit(MSC_SCAN, idev->mscbit);
+ for (i = 0; i < LM8323_KEYMAP_SIZE; i++) {
+ __set_bit(pdata->keymap[i], idev->keybit);
+ lm->keymap[i] = pdata->keymap[i];
+ }
+ __clear_bit(KEY_RESERVED, idev->keybit);
+
+ if (pdata->repeat)
+ __set_bit(EV_REP, idev->evbit);
+
+ err = input_register_device(idev);
+ if (err) {
+ dev_dbg(&client->dev, "error registering input device\n");
+ goto fail3;
+ }
+
+ err = request_irq(client->irq, lm8323_irq,
+ IRQF_TRIGGER_FALLING | IRQF_DISABLED,
+ "lm8323", lm);
+ if (err) {
+ dev_err(&client->dev, "could not get IRQ %d\n", client->irq);
+ goto fail4;
+ }
+
+ device_init_wakeup(&client->dev, 1);
+ enable_irq_wake(client->irq);
+
+ return 0;
+
+fail4:
+ input_unregister_device(idev);
+ idev = NULL;
+fail3:
+ device_remove_file(&client->dev, &dev_attr_disable_kp);
+fail2:
+ while (--i >= 0)
+ if (lm->pwm[i].enabled)
+ led_classdev_unregister(&lm->pwm[i].cdev);
+fail1:
+ input_free_device(idev);
+ kfree(lm);
+ return err;
+}
+
+static int __devexit lm8323_remove(struct i2c_client *client)
+{
+ struct lm8323_chip *lm = i2c_get_clientdata(client);
+ int i;
+
+ disable_irq_wake(client->irq);
+ free_irq(client->irq, lm);
+ cancel_work_sync(&lm->work);
+
+ input_unregister_device(lm->idev);
+
+ device_remove_file(&lm->client->dev, &dev_attr_disable_kp);
+
+ for (i = 0; i < 3; i++)
+ if (lm->pwm[i].enabled)
+ led_classdev_unregister(&lm->pwm[i].cdev);
+
+ kfree(lm);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+/*
+ * We don't need to explicitly suspend the chip, as it already switches off
+ * when there's no activity.
+ */
+static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ struct lm8323_chip *lm = i2c_get_clientdata(client);
+ int i;
+
+ set_irq_wake(client->irq, 0);
+ disable_irq(client->irq);
+
+ mutex_lock(&lm->lock);
+ lm->pm_suspend = true;
+ mutex_unlock(&lm->lock);
+
+ for (i = 0; i < 3; i++)
+ if (lm->pwm[i].enabled)
+ led_classdev_suspend(&lm->pwm[i].cdev);
+
+ return 0;
+}
+
+static int lm8323_resume(struct i2c_client *client)
+{
+ struct lm8323_chip *lm = i2c_get_clientdata(client);
+ int i;
+
+ mutex_lock(&lm->lock);
+ lm->pm_suspend = false;
+ mutex_unlock(&lm->lock);
+
+ for (i = 0; i < 3; i++)
+ if (lm->pwm[i].enabled)
+ led_classdev_resume(&lm->pwm[i].cdev);
+
+ enable_irq(client->irq);
+ set_irq_wake(client->irq, 1);
+
+ return 0;
+}
+#else
+#define lm8323_suspend NULL
+#define lm8323_resume NULL
+#endif
+
+static const struct i2c_device_id lm8323_id[] = {
+ { "lm8323", 0 },
+ { }
+};
+
+static struct i2c_driver lm8323_i2c_driver = {
+ .driver = {
+ .name = "lm8323",
+ },
+ .probe = lm8323_probe,
+ .remove = __devexit_p(lm8323_remove),
+ .suspend = lm8323_suspend,
+ .resume = lm8323_resume,
+ .id_table = lm8323_id,
+};
+MODULE_DEVICE_TABLE(i2c, lm8323_id);
+
+static int __init lm8323_init(void)
+{
+ return i2c_add_driver(&lm8323_i2c_driver);
+}
+module_init(lm8323_init);
+
+static void __exit lm8323_exit(void)
+{
+ i2c_del_driver(&lm8323_i2c_driver);
+}
+module_exit(lm8323_exit);
+
+MODULE_AUTHOR("Timo O. Karjalainen <timo.o.karjalainen@nokia.com>");
+MODULE_AUTHOR("Daniel Stone");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
+MODULE_DESCRIPTION("LM8323 keypad driver");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5c0a631d1455..1acfa3a05aad 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -193,6 +193,16 @@ config INPUT_CM109
To compile this driver as a module, choose M here: the module will be
called cm109.
+config INPUT_TWL4030_PWRBUTTON
+ tristate "TWL4030 Power button Driver"
+ depends on TWL4030_CORE
+ help
+ Say Y here if you want to enable power key reporting via the
+ TWL4030 family of chips.
+
+ To compile this driver as a module, choose M here. The module will
+ be called twl4030_pwrbutton.
+
config INPUT_UINPUT
tristate "User level driver support"
help
@@ -232,7 +242,7 @@ config INPUT_GPIO_ROTARY_ENCODER
depends on GPIOLIB && GENERIC_GPIO
help
Say Y here to add support for rotary encoders connected to GPIO lines.
- Check file:Documentation/incput/rotary_encoder.txt for more
+ Check file:Documentation/input/rotary-encoder.txt for more
information.
To compile this driver as a module, choose M here: the
@@ -250,4 +260,13 @@ config INPUT_RB532_BUTTON
To compile this driver as a module, choose M here: the
module will be called rb532_button.
+config INPUT_DM355EVM
+ tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
+ depends on MFD_DM355EVM_MSP
+ help
+ Supports the pushbuttons and IR remote used with
+ the DM355 EVM board.
+
+ To compile this driver as a module, choose M here: the
+ module will be called dm355evm_keys.
endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index eb3f407baedf..0d979fd4cd57 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
obj-$(CONFIG_INPUT_CM109) += cm109.o
obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o
+obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o
obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o
obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
@@ -21,6 +22,7 @@ obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o
+obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o
obj-$(CONFIG_INPUT_UINPUT) += uinput.o
obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
obj-$(CONFIG_INPUT_YEALINK) += yealink.o
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 922c05141585..0501f0e65157 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -509,7 +509,7 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc
old_keycode = ar2->keycode[mode][index];
ar2->keycode[mode][index] = keycode;
- set_bit(keycode, idev->keybit);
+ __set_bit(keycode, idev->keybit);
for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
@@ -518,7 +518,7 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc
}
}
- clear_bit(old_keycode, idev->keybit);
+ __clear_bit(old_keycode, idev->keybit);
return 0;
}
@@ -543,7 +543,7 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode;
- set_bit(ar2->keycode[mode][index], idev->keybit);
+ __set_bit(ar2->keycode[mode][index], idev->keybit);
}
}
@@ -554,11 +554,11 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3;
ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4;
ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC;
- set_bit(KEY_PROG1, idev->keybit);
- set_bit(KEY_PROG2, idev->keybit);
- set_bit(KEY_PROG3, idev->keybit);
- set_bit(KEY_PROG4, idev->keybit);
- set_bit(KEY_PC, idev->keybit);
+ __set_bit(KEY_PROG1, idev->keybit);
+ __set_bit(KEY_PROG2, idev->keybit);
+ __set_bit(KEY_PROG3, idev->keybit);
+ __set_bit(KEY_PROG4, idev->keybit);
+ __set_bit(KEY_PC, idev->keybit);
idev->rep[REP_DELAY] = 250;
idev->rep[REP_PERIOD] = 33;
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c
new file mode 100644
index 000000000000..a63315ce4a6c
--- /dev/null
+++ b/drivers/input/misc/dm355evm_keys.c
@@ -0,0 +1,329 @@
+/*
+ * dm355evm_keys.c - support buttons and IR remote on DM355 EVM board
+ *
+ * Copyright (c) 2008 by David Brownell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+
+#include <linux/i2c/dm355evm_msp.h>
+
+
+/*
+ * The MSP430 firmware on the DM355 EVM monitors on-board pushbuttons
+ * and an IR receptor used for the remote control. When any key is
+ * pressed, or its autorepeat kicks in, an event is sent. This driver
+ * read those events from the small (32 event) queue and reports them.
+ *
+ * Because we communicate with the MSP430 using I2C, and all I2C calls
+ * in Linux sleep, we need to cons up a kind of threaded IRQ handler
+ * using a work_struct. The IRQ is active low, but we use it through
+ * the GPIO controller so we can trigger on falling edges.
+ *
+ * Note that physically there can only be one of these devices.
+ *
+ * This driver was tested with firmware revision A4.
+ */
+struct dm355evm_keys {
+ struct work_struct work;
+ struct input_dev *input;
+ struct device *dev;
+ int irq;
+};
+
+static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
+{
+ struct dm355evm_keys *keys = _keys;
+
+ schedule_work(&keys->work);
+ return IRQ_HANDLED;
+}
+
+/* These initial keycodes can be remapped by dm355evm_setkeycode(). */
+static struct {
+ u16 event;
+ u16 keycode;
+} dm355evm_keys[] = {
+
+ /*
+ * Pushbuttons on the EVM board ... note that the labels for these
+ * are SW10/SW11/etc on the PC board. The left/right orientation
+ * comes only from the firmware's documentation, and presumes the
+ * power connector is immediately in front of you and the IR sensor
+ * is to the right. (That is, rotate the board counter-clockwise
+ * by 90 degrees from the SW10/etc and "DM355 EVM" labels.)
+ */
+ { 0x00d8, KEY_OK, }, /* SW12 */
+ { 0x00b8, KEY_UP, }, /* SW13 */
+ { 0x00e8, KEY_DOWN, }, /* SW11 */
+ { 0x0078, KEY_LEFT, }, /* SW14 */
+ { 0x00f0, KEY_RIGHT, }, /* SW10 */
+
+ /*
+ * IR buttons ... codes assigned to match the universal remote
+ * provided with the EVM (Philips PM4S) using DVD code 0020.
+ *
+ * These event codes match firmware documentation, but other
+ * remote controls could easily send more RC5-encoded events.
+ * The PM4S manual was used in several cases to help select
+ * a keycode reflecting the intended usage.
+ *
+ * RC5 codes are 14 bits, with two start bits (0x3 prefix)
+ * and a toggle bit (masked out below).
+ */
+ { 0x300c, KEY_POWER, }, /* NOTE: docs omit this */
+ { 0x3000, KEY_NUMERIC_0, },
+ { 0x3001, KEY_NUMERIC_1, },
+ { 0x3002, KEY_NUMERIC_2, },
+ { 0x3003, KEY_NUMERIC_3, },
+ { 0x3004, KEY_NUMERIC_4, },
+ { 0x3005, KEY_NUMERIC_5, },
+ { 0x3006, KEY_NUMERIC_6, },
+ { 0x3007, KEY_NUMERIC_7, },
+ { 0x3008, KEY_NUMERIC_8, },
+ { 0x3009, KEY_NUMERIC_9, },
+ { 0x3022, KEY_ENTER, },
+ { 0x30ec, KEY_MODE, }, /* "tv/vcr/..." */
+ { 0x300f, KEY_SELECT, }, /* "info" */
+ { 0x3020, KEY_CHANNELUP, }, /* "up" */
+ { 0x302e, KEY_MENU, }, /* "in/out" */
+ { 0x3011, KEY_VOLUMEDOWN, }, /* "left" */
+ { 0x300d, KEY_MUTE, }, /* "ok" */
+ { 0x3010, KEY_VOLUMEUP, }, /* "right" */
+ { 0x301e, KEY_SUBTITLE, }, /* "cc" */
+ { 0x3021, KEY_CHANNELDOWN, }, /* "down" */
+ { 0x3022, KEY_PREVIOUS, },
+ { 0x3026, KEY_SLEEP, },
+ { 0x3172, KEY_REWIND, }, /* NOTE: docs wrongly say 0x30ca */
+ { 0x3175, KEY_PLAY, },
+ { 0x3174, KEY_FASTFORWARD, },
+ { 0x3177, KEY_RECORD, },
+ { 0x3176, KEY_STOP, },
+ { 0x3169, KEY_PAUSE, },
+};
+
+static void dm355evm_keys_work(struct work_struct *work)
+{
+ struct dm355evm_keys *keys;
+ int status;
+
+ keys = container_of(work, struct dm355evm_keys, work);
+
+ /* For simplicity we ignore INPUT_COUNT and just read
+ * events until we get the "queue empty" indicator.
+ * Reading INPUT_LOW decrements the count.
+ */
+ for (;;) {
+ static u16 last_event;
+ u16 event;
+ int keycode;
+ int i;
+
+ status = dm355evm_msp_read(DM355EVM_MSP_INPUT_HIGH);
+ if (status < 0) {
+ dev_dbg(keys->dev, "input high err %d\n",
+ status);
+ break;
+ }
+ event = status << 8;
+
+ status = dm355evm_msp_read(DM355EVM_MSP_INPUT_LOW);
+ if (status < 0) {
+ dev_dbg(keys->dev, "input low err %d\n",
+ status);
+ break;
+ }
+ event |= status;
+ if (event == 0xdead)
+ break;
+
+ /* Press and release a button: two events, same code.
+ * Press and hold (autorepeat), then release: N events
+ * (N > 2), same code. For RC5 buttons the toggle bits
+ * distinguish (for example) "1-autorepeat" from "1 1";
+ * but PCB buttons don't support that bit.
+ *
+ * So we must synthesize release events. We do that by
+ * mapping events to a press/release event pair; then
+ * to avoid adding extra events, skip the second event
+ * of each pair.
+ */
+ if (event == last_event) {
+ last_event = 0;
+ continue;
+ }
+ last_event = event;
+
+ /* ignore the RC5 toggle bit */
+ event &= ~0x0800;
+
+ /* find the key, or leave it as unknown */
+ keycode = KEY_UNKNOWN;
+ for (i = 0; i < ARRAY_SIZE(dm355evm_keys); i++) {
+ if (dm355evm_keys[i].event != event)
+ continue;
+ keycode = dm355evm_keys[i].keycode;
+ break;
+ }
+ dev_dbg(keys->dev,
+ "input event 0x%04x--> keycode %d\n",
+ event, keycode);
+
+ /* report press + release */
+ input_report_key(keys->input, keycode, 1);
+ input_sync(keys->input);
+ input_report_key(keys->input, keycode, 0);
+ input_sync(keys->input);
+ }
+}
+
+static int dm355evm_setkeycode(struct input_dev *dev, int index, int keycode)
+{
+ u16 old_keycode;
+ unsigned i;
+
+ if (((unsigned)index) >= ARRAY_SIZE(dm355evm_keys))
+ return -EINVAL;
+
+ old_keycode = dm355evm_keys[index].keycode;
+ dm355evm_keys[index].keycode = keycode;
+ set_bit(keycode, dev->keybit);
+
+ for (i = 0; i < ARRAY_SIZE(dm355evm_keys); i++) {
+ if (dm355evm_keys[index].keycode == old_keycode)
+ goto done;
+ }
+ clear_bit(old_keycode, dev->keybit);
+done:
+ return 0;
+}
+
+static int dm355evm_getkeycode(struct input_dev *dev, int index, int *keycode)
+{
+ if (((unsigned)index) >= ARRAY_SIZE(dm355evm_keys))
+ return -EINVAL;
+
+ return dm355evm_keys[index].keycode;
+}
+
+/*----------------------------------------------------------------------*/
+
+static int __devinit dm355evm_keys_probe(struct platform_device *pdev)
+{
+ struct dm355evm_keys *keys;
+ struct input_dev *input;
+ int status;
+ int i;
+
+ /* allocate instance struct and input dev */
+ keys = kzalloc(sizeof *keys, GFP_KERNEL);
+ input = input_allocate_device();
+ if (!keys || !input) {
+ status = -ENOMEM;
+ goto fail1;
+ }
+
+ keys->dev = &pdev->dev;
+ keys->input = input;
+ INIT_WORK(&keys->work, dm355evm_keys_work);
+
+ /* set up "threaded IRQ handler" */
+ status = platform_get_irq(pdev, 0);
+ if (status < 0)
+ goto fail1;
+ keys->irq = status;
+
+ input_set_drvdata(input, keys);
+
+ input->name = "DM355 EVM Controls";
+ input->phys = "dm355evm/input0";
+ input->dev.parent = &pdev->dev;
+
+ input->id.bustype = BUS_I2C;
+ input->id.product = 0x0355;
+ input->id.version = dm355evm_msp_read(DM355EVM_MSP_FIRMREV);
+
+ input->evbit[0] = BIT(EV_KEY);
+ for (i = 0; i < ARRAY_SIZE(dm355evm_keys); i++)
+ __set_bit(dm355evm_keys[i].keycode, input->keybit);
+
+ input->setkeycode = dm355evm_setkeycode;
+ input->getkeycode = dm355evm_getkeycode;
+
+ /* REVISIT: flush the event queue? */
+
+ status = request_irq(keys->irq, dm355evm_keys_irq,
+ IRQF_TRIGGER_FALLING,
+ dev_name(&pdev->dev), keys);
+ if (status < 0)
+ goto fail1;
+
+ /* register */
+ status = input_register_device(input);
+ if (status < 0)
+ goto fail2;
+
+ platform_set_drvdata(pdev, keys);
+
+ return 0;
+
+fail2:
+ free_irq(keys->irq, keys);
+fail1:
+ input_free_device(input);
+ kfree(keys);
+ dev_err(&pdev->dev, "can't register, err %d\n", status);
+
+ return status;
+}
+
+static int __devexit dm355evm_keys_remove(struct platform_device *pdev)
+{
+ struct dm355evm_keys *keys = platform_get_drvdata(pdev);
+
+ free_irq(keys->irq, keys);
+ input_unregister_device(keys->input);
+ kfree(keys);
+
+ return 0;
+}
+
+/* REVISIT: add suspend/resume when DaVinci supports it. The IRQ should
+ * be able to wake up the system. When device_may_wakeup(&pdev->dev), call
+ * enable_irq_wake() on suspend, and disable_irq_wake() on resume.
+ */
+
+/*
+ * I2C is used to talk to the MSP430, but this platform device is
+ * exposed by an MFD driver that manages I2C communications.
+ */
+static struct platform_driver dm355evm_keys_driver = {
+ .probe = dm355evm_keys_probe,
+ .remove = __devexit_p(dm355evm_keys_remove),
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "dm355evm_keys",
+ },
+};
+
+static int __init dm355evm_keys_init(void)
+{
+ return platform_driver_register(&dm355evm_keys_driver);
+}
+module_init(dm355evm_keys_init);
+
+static void __exit dm355evm_keys_exit(void)
+{
+ platform_driver_unregister(&dm355evm_keys_driver);
+}
+module_exit(dm355evm_keys_exit);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 5bb3ab51b8c6..c806fbf1e174 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -26,13 +26,17 @@
#define DRV_NAME "rotary-encoder"
struct rotary_encoder {
- unsigned int irq_a;
- unsigned int irq_b;
- unsigned int pos;
- unsigned int armed;
- unsigned int dir;
struct input_dev *input;
struct rotary_encoder_platform_data *pdata;
+
+ unsigned int axis;
+ unsigned int pos;
+
+ unsigned int irq_a;
+ unsigned int irq_b;
+
+ bool armed;
+ unsigned char dir; /* 0 - clockwise, 1 - CCW */
};
static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
@@ -53,21 +57,32 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
if (!encoder->armed)
break;
- if (encoder->dir) {
- /* turning counter-clockwise */
- encoder->pos += pdata->steps;
- encoder->pos--;
- encoder->pos %= pdata->steps;
+ if (pdata->relative_axis) {
+ input_report_rel(encoder->input, pdata->axis,
+ encoder->dir ? -1 : 1);
} else {
- /* turning clockwise */
- encoder->pos++;
- encoder->pos %= pdata->steps;
+ unsigned int pos = encoder->pos;
+
+ if (encoder->dir) {
+ /* turning counter-clockwise */
+ if (pdata->rollover)
+ pos += pdata->steps;
+ if (pos)
+ pos--;
+ } else {
+ /* turning clockwise */
+ if (pdata->rollover || pos < pdata->steps)
+ pos++;
+ }
+ if (pdata->rollover)
+ pos %= pdata->steps;
+ encoder->pos = pos;
+ input_report_abs(encoder->input, pdata->axis,
+ encoder->pos);
}
-
- input_report_abs(encoder->input, pdata->axis, encoder->pos);
input_sync(encoder->input);
- encoder->armed = 0;
+ encoder->armed = false;
break;
case 0x1:
@@ -77,7 +92,7 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
break;
case 0x3:
- encoder->armed = 1;
+ encoder->armed = true;
break;
}
@@ -113,9 +128,15 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
input->name = pdev->name;
input->id.bustype = BUS_HOST;
input->dev.parent = &pdev->dev;
- input->evbit[0] = BIT_MASK(EV_ABS);
- input_set_abs_params(encoder->input,
- pdata->axis, 0, pdata->steps, 0, 1);
+
+ if (pdata->relative_axis) {
+ input->evbit[0] = BIT_MASK(EV_REL);
+ input->relbit[0] = BIT_MASK(pdata->axis);
+ } else {
+ input->evbit[0] = BIT_MASK(EV_ABS);
+ input_set_abs_params(encoder->input,
+ pdata->axis, 0, pdata->steps, 0, 1);
+ }
err = input_register_device(input);
if (err) {
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
new file mode 100644
index 000000000000..f5fc9974a111
--- /dev/null
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -0,0 +1,145 @@
+/**
+ * twl4030-pwrbutton.c - TWL4030 Power Button Input Driver
+ *
+ * Copyright (C) 2008-2009 Nokia Corporation
+ *
+ * Written by Peter De Schrijver <peter.de-schrijver@nokia.com>
+ * Several fixes by Felipe Balbi <felipe.balbi@nokia.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/i2c/twl4030.h>
+
+#define PWR_PWRON_IRQ (1 << 0)
+
+#define STS_HW_CONDITIONS 0xf
+
+static irqreturn_t powerbutton_irq(int irq, void *_pwr)
+{
+ struct input_dev *pwr = _pwr;
+ int err;
+ u8 value;
+
+#ifdef CONFIG_LOCKDEP
+ /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which
+ * we don't want and can't tolerate since this is a threaded
+ * IRQ and can sleep due to the i2c reads it has to issue.
+ * Although it might be friendlier not to borrow this thread
+ * context...
+ */
+ local_irq_enable();
+#endif
+
+ err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
+ STS_HW_CONDITIONS);
+ if (!err) {
+ input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
+ input_sync(pwr);
+ } else {
+ dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading"
+ " TWL4030 PM_MASTER STS_HW_CONDITIONS register\n", err);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static int __devinit twl4030_pwrbutton_probe(struct platform_device *pdev)
+{
+ struct input_dev *pwr;
+ int irq = platform_get_irq(pdev, 0);
+ int err;
+
+ pwr = input_allocate_device();
+ if (!pwr) {
+ dev_dbg(&pdev->dev, "Can't allocate power button\n");
+ return -ENOMEM;
+ }
+
+ pwr->evbit[0] = BIT_MASK(EV_KEY);
+ pwr->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
+ pwr->name = "twl4030_pwrbutton";
+ pwr->phys = "twl4030_pwrbutton/input0";
+ pwr->dev.parent = &pdev->dev;
+
+ err = request_irq(irq, powerbutton_irq,
+ IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+ "twl4030_pwrbutton", pwr);
+ if (err < 0) {
+ dev_dbg(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
+ goto free_input_dev;
+ }
+
+ err = input_register_device(pwr);
+ if (err) {
+ dev_dbg(&pdev->dev, "Can't register power button: %d\n", err);
+ goto free_irq;
+ }
+
+ platform_set_drvdata(pdev, pwr);
+
+ return 0;
+
+free_irq:
+ free_irq(irq, NULL);
+free_input_dev:
+ input_free_device(pwr);
+ return err;
+}
+
+static int __devexit twl4030_pwrbutton_remove(struct platform_device *pdev)
+{
+ struct input_dev *pwr = platform_get_drvdata(pdev);
+ int irq = platform_get_irq(pdev, 0);
+
+ free_irq(irq, pwr);
+ input_unregister_device(pwr);
+
+ return 0;
+}
+
+struct platform_driver twl4030_pwrbutton_driver = {
+ .probe = twl4030_pwrbutton_probe,
+ .remove = __devexit_p(twl4030_pwrbutton_remove),
+ .driver = {
+ .name = "twl4030_pwrbutton",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init twl4030_pwrbutton_init(void)
+{
+ return platform_driver_register(&twl4030_pwrbutton_driver);
+}
+module_init(twl4030_pwrbutton_init);
+
+static void __exit twl4030_pwrbutton_exit(void)
+{
+ platform_driver_unregister(&twl4030_pwrbutton_driver);
+}
+module_exit(twl4030_pwrbutton_exit);
+
+MODULE_ALIAS("platform:twl4030_pwrbutton");
+MODULE_DESCRIPTION("Triton2 Power Button");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Peter De Schrijver <peter.de-schrijver@nokia.com>");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
+
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 46b7caeb2817..c5a49aba418f 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -54,27 +54,28 @@ static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned i
return 0;
}
+/* Atomically allocate an ID for the given request. Returns 0 on success. */
static int uinput_request_alloc_id(struct uinput_device *udev, struct uinput_request *request)
{
- /* Atomically allocate an ID for the given request. Returns 0 on success. */
int id;
int err = -1;
spin_lock(&udev->requests_lock);
- for (id = 0; id < UINPUT_NUM_REQUESTS; id++)
+ for (id = 0; id < UINPUT_NUM_REQUESTS; id++) {
if (!udev->requests[id]) {
request->id = id;
udev->requests[id] = request;
err = 0;
break;
}
+ }
spin_unlock(&udev->requests_lock);
return err;
}
-static struct uinput_request* uinput_request_find(struct uinput_device *udev, int id)
+static struct uinput_request *uinput_request_find(struct uinput_device *udev, int id)
{
/* Find an input request, by ID. Returns NULL if the ID isn't valid. */
if (id >= UINPUT_NUM_REQUESTS || id < 0)
@@ -99,14 +100,51 @@ static void uinput_request_done(struct uinput_device *udev, struct uinput_reques
complete(&request->done);
}
-static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request)
+static int uinput_request_submit(struct uinput_device *udev, struct uinput_request *request)
{
+ int retval;
+
+ retval = uinput_request_reserve_slot(udev, request);
+ if (retval)
+ return retval;
+
+ retval = mutex_lock_interruptible(&udev->mutex);
+ if (retval)
+ return retval;
+
+ if (udev->state != UIST_CREATED) {
+ retval = -ENODEV;
+ goto out;
+ }
+
/* Tell our userspace app about this new request by queueing an input event */
- uinput_dev_event(dev, EV_UINPUT, request->code, request->id);
+ uinput_dev_event(udev->dev, EV_UINPUT, request->code, request->id);
+
+ out:
+ mutex_unlock(&udev->mutex);
+ return retval;
+}
+
+/*
+ * Fail all ouitstanding requests so handlers don't wait for the userspace
+ * to finish processing them.
+ */
+static void uinput_flush_requests(struct uinput_device *udev)
+{
+ struct uinput_request *request;
+ int i;
+
+ spin_lock(&udev->requests_lock);
+
+ for (i = 0; i < UINPUT_NUM_REQUESTS; i++) {
+ request = udev->requests[i];
+ if (request) {
+ request->retval = -ENODEV;
+ uinput_request_done(udev, request);
+ }
+ }
- /* Wait for the request to complete */
- wait_for_completion(&request->done);
- return request->retval;
+ spin_unlock(&udev->requests_lock);
}
static void uinput_dev_set_gain(struct input_dev *dev, u16 gain)
@@ -126,6 +164,7 @@ static int uinput_dev_playback(struct input_dev *dev, int effect_id, int value)
static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old)
{
+ struct uinput_device *udev = input_get_drvdata(dev);
struct uinput_request request;
int retval;
@@ -146,15 +185,18 @@ static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *eff
request.u.upload.effect = effect;
request.u.upload.old = old;
- retval = uinput_request_reserve_slot(input_get_drvdata(dev), &request);
- if (!retval)
- retval = uinput_request_submit(dev, &request);
+ retval = uinput_request_submit(udev, &request);
+ if (!retval) {
+ wait_for_completion(&request.done);
+ retval = request.retval;
+ }
return retval;
}
static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)
{
+ struct uinput_device *udev = input_get_drvdata(dev);
struct uinput_request request;
int retval;
@@ -166,9 +208,11 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)
request.code = UI_FF_ERASE;
request.u.effect_id = effect_id;
- retval = uinput_request_reserve_slot(input_get_drvdata(dev), &request);
- if (!retval)
- retval = uinput_request_submit(dev, &request);
+ retval = uinput_request_submit(udev, &request);
+ if (!retval) {
+ wait_for_completion(&request.done);
+ retval = request.retval;
+ }
return retval;
}
@@ -176,20 +220,24 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)
static void uinput_destroy_device(struct uinput_device *udev)
{
const char *name, *phys;
+ struct input_dev *dev = udev->dev;
+ enum uinput_state old_state = udev->state;
- if (udev->dev) {
- name = udev->dev->name;
- phys = udev->dev->phys;
- if (udev->state == UIST_CREATED)
- input_unregister_device(udev->dev);
- else
- input_free_device(udev->dev);
+ udev->state = UIST_NEW_DEVICE;
+
+ if (dev) {
+ name = dev->name;
+ phys = dev->phys;
+ if (old_state == UIST_CREATED) {
+ uinput_flush_requests(udev);
+ input_unregister_device(dev);
+ } else {
+ input_free_device(dev);
+ }
kfree(name);
kfree(phys);
udev->dev = NULL;
}
-
- udev->state = UIST_NEW_DEVICE;
}
static int uinput_create_device(struct uinput_device *udev)
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index daecc75c72e6..cd4203c4deb9 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -38,25 +38,25 @@
static const struct alps_model_info alps_model_data[] = {
{ { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
- { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */
+ { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */
{ { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
{ { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
- { { 0x60, 0x03, 0xc8 }, 0xf8, 0xf8, 0 }, /* HP ze1115 */
+ { { 0x60, 0x03, 0xc8 }, 0xf8, 0xf8, 0 }, /* HP ze1115 */
{ { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
{ { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
- { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
- { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
- { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
+ { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
+ { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
+ { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
{ { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 },
- { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS }, /* Dell Latitude D800 */
- { { 0x73, 0x00, 0x0a }, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */
+ { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */
+ { { 0x73, 0x00, 0x0a }, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */
{ { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
- { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */
+ { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */
{ { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
{ { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
{ { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
{ { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */
- { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */
+ { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 }, /* Dell Vostro 1400 */
};
/*
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index 15ac3205ac05..dcd4236af1e3 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -159,21 +159,22 @@ static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse)
if (!dev2)
printk(KERN_WARNING "lifebook.c: got relative packet "
"but no relative device set up\n");
- } else if (lifebook_use_6byte_proto) {
- input_report_abs(dev1, ABS_X,
- ((packet[1] & 0x3f) << 6) | (packet[2] & 0x3f));
- input_report_abs(dev1, ABS_Y,
- 4096 - (((packet[4] & 0x3f) << 6) | (packet[5] & 0x3f)));
} else {
- input_report_abs(dev1, ABS_X,
- (packet[1] | ((packet[0] & 0x30) << 4)));
- input_report_abs(dev1, ABS_Y,
- 1024 - (packet[2] | ((packet[0] & 0xC0) << 2)));
+ if (lifebook_use_6byte_proto) {
+ input_report_abs(dev1, ABS_X,
+ ((packet[1] & 0x3f) << 6) | (packet[2] & 0x3f));
+ input_report_abs(dev1, ABS_Y,
+ 4096 - (((packet[4] & 0x3f) << 6) | (packet[5] & 0x3f)));
+ } else {
+ input_report_abs(dev1, ABS_X,
+ (packet[1] | ((packet[0] & 0x30) << 4)));
+ input_report_abs(dev1, ABS_Y,
+ 1024 - (packet[2] | ((packet[0] & 0xC0) << 2)));
+ }
+ input_report_key(dev1, BTN_TOUCH, packet[0] & 0x04);
+ input_sync(dev1);
}
- input_report_key(dev1, BTN_TOUCH, packet[0] & 0x04);
- input_sync(dev1);
-
if (dev2) {
if (relative_packet) {
input_report_rel(dev2, REL_X,
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index f8f86de694bb..b407b355dceb 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -327,7 +327,9 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
goto out;
}
- if (psmouse->packet[1] == PSMOUSE_RET_ID) {
+ if (psmouse->packet[1] == PSMOUSE_RET_ID ||
+ (psmouse->type == PSMOUSE_HGPK &&
+ psmouse->packet[1] == PSMOUSE_RET_BAT)) {
__psmouse_set_state(psmouse, PSMOUSE_IGNORE);
serio_reconnect(serio);
goto out;
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 17fd6d46d082..966b8868f792 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -60,7 +60,6 @@ struct mousedev {
int exist;
int open;
int minor;
- char name[16];
struct input_handle handle;
wait_queue_head_t wait;
struct list_head client_list;
@@ -863,19 +862,17 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
init_waitqueue_head(&mousedev->wait);
if (minor == MOUSEDEV_MIX)
- strlcpy(mousedev->name, "mice", sizeof(mousedev->name));
+ dev_set_name(&mousedev->dev, "mice");
else
- snprintf(mousedev->name, sizeof(mousedev->name),
- "mouse%d", minor);
+ dev_set_name(&mousedev->dev, "mouse%d", minor);
mousedev->minor = minor;
mousedev->exist = 1;
mousedev->handle.dev = input_get_device(dev);
- mousedev->handle.name = mousedev->name;
+ mousedev->handle.name = dev_name(&mousedev->dev);
mousedev->handle.handler = handler;
mousedev->handle.private = mousedev;
- dev_set_name(&mousedev->dev, mousedev->name);
mousedev->dev.class = &input_class;
if (dev)
mousedev->dev.parent = &dev->dev;
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 3cffb704e374..f919bf57293c 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -10,6 +10,7 @@
* the Free Software Foundation.
*/
+#include <linux/types.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/interrupt.h>
@@ -921,6 +922,9 @@ static void i8042_dritek_enable(void)
#endif
#ifdef CONFIG_PM
+
+static bool i8042_suspended;
+
/*
* Here we try to restore the original BIOS settings. We only want to
* do that once, when we really suspend, not when we taking memory
@@ -930,11 +934,9 @@ static void i8042_dritek_enable(void)
static int i8042_suspend(struct platform_device *dev, pm_message_t state)
{
- if (dev->dev.power.power_state.event != state.event) {
- if (state.event == PM_EVENT_SUSPEND)
- i8042_controller_reset();
-
- dev->dev.power.power_state = state;
+ if (!i8042_suspended && state.event == PM_EVENT_SUSPEND) {
+ i8042_controller_reset();
+ i8042_suspended = true;
}
return 0;
@@ -952,7 +954,7 @@ static int i8042_resume(struct platform_device *dev)
/*
* Do not bother with restoring state if we haven't suspened yet
*/
- if (dev->dev.power.power_state.event == PM_EVENT_ON)
+ if (!i8042_suspended)
return 0;
error = i8042_controller_check();
@@ -998,10 +1000,9 @@ static int i8042_resume(struct platform_device *dev)
if (i8042_ports[I8042_KBD_PORT_NO].serio)
i8042_enable_kbd_port();
+ i8042_suspended = false;
i8042_interrupt(0, NULL);
- dev->dev.power.power_state = PMSG_ON;
-
return 0;
}
#endif /* CONFIG_PM */
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index bc033250dfcd..fb17573f8f2d 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -41,17 +41,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Serio abstraction core");
MODULE_LICENSE("GPL");
-EXPORT_SYMBOL(serio_interrupt);
-EXPORT_SYMBOL(__serio_register_port);
-EXPORT_SYMBOL(serio_unregister_port);
-EXPORT_SYMBOL(serio_unregister_child_port);
-EXPORT_SYMBOL(__serio_register_driver);
-EXPORT_SYMBOL(serio_unregister_driver);
-EXPORT_SYMBOL(serio_open);
-EXPORT_SYMBOL(serio_close);
-EXPORT_SYMBOL(serio_rescan);
-EXPORT_SYMBOL(serio_reconnect);
-
/*
* serio_mutex protects entire serio subsystem and is taken every time
* serio port or driver registrered or unregistered.
@@ -506,9 +495,9 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *
retval = count;
if (!strncmp(buf, "manual", count)) {
- serio->manual_bind = 1;
+ serio->manual_bind = true;
} else if (!strncmp(buf, "auto", count)) {
- serio->manual_bind = 0;
+ serio->manual_bind = false;
} else {
retval = -EINVAL;
}
@@ -581,7 +570,7 @@ static void serio_add_port(struct serio *serio)
"serio: device_add() failed for %s (%s), error: %d\n",
serio->phys, serio->name, error);
else {
- serio->registered = 1;
+ serio->registered = true;
error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
if (error)
printk(KERN_ERR
@@ -617,7 +606,7 @@ static void serio_destroy_port(struct serio *serio)
if (serio->registered) {
sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
device_del(&serio->dev);
- serio->registered = 0;
+ serio->registered = false;
}
list_del_init(&serio->node);
@@ -692,11 +681,13 @@ void serio_rescan(struct serio *serio)
{
serio_queue_event(serio, NULL, SERIO_RESCAN_PORT);
}
+EXPORT_SYMBOL(serio_rescan);
void serio_reconnect(struct serio *serio)
{
serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN);
}
+EXPORT_SYMBOL(serio_reconnect);
/*
* Submits register request to kseriod for subsequent execution.
@@ -707,6 +698,7 @@ void __serio_register_port(struct serio *serio, struct module *owner)
serio_init_port(serio);
serio_queue_event(serio, owner, SERIO_REGISTER_PORT);
}
+EXPORT_SYMBOL(__serio_register_port);
/*
* Synchronously unregisters serio port.
@@ -718,6 +710,7 @@ void serio_unregister_port(struct serio *serio)
serio_destroy_port(serio);
mutex_unlock(&serio_mutex);
}
+EXPORT_SYMBOL(serio_unregister_port);
/*
* Safely unregisters child port if one is present.
@@ -731,6 +724,7 @@ void serio_unregister_child_port(struct serio *serio)
}
mutex_unlock(&serio_mutex);
}
+EXPORT_SYMBOL(serio_unregister_child_port);
/*
@@ -756,9 +750,9 @@ static ssize_t serio_driver_set_bind_mode(struct device_driver *drv, const char
retval = count;
if (!strncmp(buf, "manual", count)) {
- serio_drv->manual_bind = 1;
+ serio_drv->manual_bind = true;
} else if (!strncmp(buf, "auto", count)) {
- serio_drv->manual_bind = 0;
+ serio_drv->manual_bind = false;
} else {
retval = -EINVAL;
}
@@ -818,7 +812,7 @@ static void serio_attach_driver(struct serio_driver *drv)
int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
{
- int manual_bind = drv->manual_bind;
+ bool manual_bind = drv->manual_bind;
int error;
drv->driver.bus = &serio_bus;
@@ -829,7 +823,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
* Temporarily disable automatic binding because probing
* takes long time and we are better off doing it in kseriod
*/
- drv->manual_bind = 1;
+ drv->manual_bind = true;
error = driver_register(&drv->driver);
if (error) {
@@ -844,7 +838,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
* driver to free ports
*/
if (!manual_bind) {
- drv->manual_bind = 0;
+ drv->manual_bind = false;
error = serio_queue_event(drv, NULL, SERIO_ATTACH_DRIVER);
if (error) {
driver_unregister(&drv->driver);
@@ -854,6 +848,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
return 0;
}
+EXPORT_SYMBOL(__serio_register_driver);
void serio_unregister_driver(struct serio_driver *drv)
{
@@ -861,7 +856,7 @@ void serio_unregister_driver(struct serio_driver *drv)
mutex_lock(&serio_mutex);
- drv->manual_bind = 1; /* so serio_find_driver ignores it */
+ drv->manual_bind = true; /* so serio_find_driver ignores it */
serio_remove_pending_events(drv);
start_over:
@@ -877,6 +872,7 @@ start_over:
driver_unregister(&drv->driver);
mutex_unlock(&serio_mutex);
}
+EXPORT_SYMBOL(serio_unregister_driver);
static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
{
@@ -937,11 +933,11 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
#ifdef CONFIG_PM
static int serio_suspend(struct device *dev, pm_message_t state)
{
- if (dev->power.power_state.event != state.event) {
- if (state.event == PM_EVENT_SUSPEND)
- serio_cleanup(to_serio_port(dev));
+ struct serio *serio = to_serio_port(dev);
- dev->power.power_state = state;
+ if (!serio->suspended && state.event == PM_EVENT_SUSPEND) {
+ serio_cleanup(serio);
+ serio->suspended = true;
}
return 0;
@@ -949,14 +945,15 @@ static int serio_suspend(struct device *dev, pm_message_t state)
static int serio_resume(struct device *dev)
{
+ struct serio *serio = to_serio_port(dev);
+
/*
* Driver reconnect can take a while, so better let kseriod
* deal with it.
*/
- if (dev->power.power_state.event != PM_EVENT_ON) {
- dev->power.power_state = PMSG_ON;
- serio_queue_event(to_serio_port(dev), NULL,
- SERIO_RECONNECT_PORT);
+ if (serio->suspended) {
+ serio->suspended = false;
+ serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
}
return 0;
@@ -974,6 +971,7 @@ int serio_open(struct serio *serio, struct serio_driver *drv)
}
return 0;
}
+EXPORT_SYMBOL(serio_open);
/* called from serio_driver->connect/disconnect methods under serio_mutex */
void serio_close(struct serio *serio)
@@ -983,6 +981,7 @@ void serio_close(struct serio *serio)
serio_set_drv(serio, NULL);
}
+EXPORT_SYMBOL(serio_close);
irqreturn_t serio_interrupt(struct serio *serio,
unsigned char data, unsigned int dfl)
@@ -1003,6 +1002,7 @@ irqreturn_t serio_interrupt(struct serio *serio,
return ret;
}
+EXPORT_SYMBOL(serio_interrupt);
static struct bus_type serio_bus = {
.name = "serio",
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index 2e18a1c0c351..3d32d3f4e486 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -1050,4 +1050,5 @@ static void __exit gtco_exit(void)
module_init(gtco_init);
module_exit(gtco_exit);
+MODULE_DESCRIPTION("GTCO digitizer USB driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 9710bfd49cf9..9114ae1c7488 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -68,6 +68,7 @@
* v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX
* v1.49 (pc) - Added support for USB Tablet PC (0x90, 0x93, and 0x9A)
* v1.50 (pc) - Fixed a TabletPC touch bug in 2.6.28
+ * v1.51 (pc) - Added support for Intuos4
*/
/*
@@ -88,7 +89,7 @@
/*
* Version Information
*/
-#define DRIVER_VERSION "v1.50"
+#define DRIVER_VERSION "v1.51"
#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
#define DRIVER_LICENSE "GPL"
@@ -128,6 +129,8 @@ extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac
extern void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
+extern void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
+extern void input_dev_i4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
extern void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index b8624f27abf9..a9d5031b855e 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -229,6 +229,19 @@ void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
}
+void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
+{
+ input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
+ input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
+ input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) | BIT_MASK(BTN_5) | BIT_MASK(BTN_6);
+ input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
+}
+
+void input_dev_i4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
+{
+ input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_7) | BIT_MASK(BTN_8);
+}
+
void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 2638811c61ac..2ff89904f26f 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -283,10 +283,11 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
{
unsigned char *data = wacom->data;
- int idx;
+ int idx = 0;
/* tool number */
- idx = data[1] & 0x01;
+ if (wacom->features->type == INTUOS)
+ idx = data[1] & 0x01;
/* Enter report */
if ((data[1] & 0xfc) == 0xc0) {
@@ -299,6 +300,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
switch (wacom->id[idx]) {
case 0x812: /* Inking pen */
case 0x801: /* Intuos3 Inking pen */
+ case 0x20802: /* Intuos4 Classic Pen */
case 0x012:
wacom->tool[idx] = BTN_TOOL_PENCIL;
break;
@@ -308,6 +310,9 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
case 0x823: /* Intuos3 Grip Pen */
case 0x813: /* Intuos3 Classic Pen */
case 0x885: /* Intuos3 Marker Pen */
+ case 0x802: /* Intuos4 Grip Pen Eraser */
+ case 0x804: /* Intuos4 Marker Pen */
+ case 0x40802: /* Intuos4 Classic Pen */
case 0x022:
wacom->tool[idx] = BTN_TOOL_PEN;
break;
@@ -319,10 +324,12 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
case 0x09c:
case 0x094:
case 0x017: /* Intuos3 2D Mouse */
+ case 0x806: /* Intuos4 Mouse */
wacom->tool[idx] = BTN_TOOL_MOUSE;
break;
case 0x096: /* Lens cursor */
case 0x097: /* Intuos3 Lens cursor */
+ case 0x006: /* Intuos4 Lens cursor */
wacom->tool[idx] = BTN_TOOL_LENS;
break;
case 0x82a: /* Eraser */
@@ -333,12 +340,17 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
case 0x82b: /* Intuos3 Grip Pen Eraser */
case 0x81b: /* Intuos3 Classic Pen Eraser */
case 0x91b: /* Intuos3 Airbrush Eraser */
+ case 0x80c: /* Intuos4 Marker Pen Eraser */
+ case 0x80a: /* Intuos4 Grip Pen Eraser */
+ case 0x4080a: /* Intuos4 Classic Pen Eraser */
+ case 0x90a: /* Intuos4 Airbrush Eraser */
wacom->tool[idx] = BTN_TOOL_RUBBER;
break;
case 0xd12:
case 0x912:
case 0x112:
case 0x913: /* Intuos3 Airbrush */
+ case 0x902: /* Intuos4 Airbrush */
wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
break;
default: /* Unknown tool */
@@ -349,9 +361,15 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
/* Exit report */
if ((data[1] & 0xfe) == 0x80) {
+ /*
+ * Reset all states otherwise we lose the initial states
+ * when in-prox next time
+ */
wacom_report_abs(wcombo, ABS_X, 0);
wacom_report_abs(wcombo, ABS_Y, 0);
wacom_report_abs(wcombo, ABS_DISTANCE, 0);
+ wacom_report_abs(wcombo, ABS_TILT_X, 0);
+ wacom_report_abs(wcombo, ABS_TILT_Y, 0);
if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
wacom_report_key(wcombo, BTN_LEFT, 0);
wacom_report_key(wcombo, BTN_MIDDLE, 0);
@@ -362,8 +380,6 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
wacom_report_abs(wcombo, ABS_RZ, 0);
} else {
wacom_report_abs(wcombo, ABS_PRESSURE, 0);
- wacom_report_abs(wcombo, ABS_TILT_X, 0);
- wacom_report_abs(wcombo, ABS_TILT_Y, 0);
wacom_report_key(wcombo, BTN_STYLUS, 0);
wacom_report_key(wcombo, BTN_STYLUS2, 0);
wacom_report_key(wcombo, BTN_TOUCH, 0);
@@ -372,6 +388,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
wacom_report_key(wcombo, wacom->tool[idx], 0);
wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
+ wacom->id[idx] = 0;
return 2;
}
return 0;
@@ -385,6 +402,8 @@ static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
/* general pen packet */
if ((data[1] & 0xb8) == 0xa0) {
t = (data[6] << 2) | ((data[7] >> 6) & 3);
+ if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L)
+ t = (t << 1) | (data[1] & 1);
wacom_report_abs(wcombo, ABS_PRESSURE, t);
wacom_report_abs(wcombo, ABS_TILT_X,
((data[7] << 1) & 0x7e) | (data[8] >> 7));
@@ -409,7 +428,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
{
unsigned char *data = wacom->data;
unsigned int t;
- int idx, result;
+ int idx = 0, result;
if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
@@ -417,7 +436,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
}
/* tool number */
- idx = data[1] & 0x01;
+ if (wacom->features->type == INTUOS)
+ idx = data[1] & 0x01;
/* pad packets. Works as a second tool and is always in prox */
if (data[0] == 12) {
@@ -425,25 +445,51 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
if (wacom->tool[1] != BTN_TOOL_FINGER)
wacom->tool[1] = BTN_TOOL_FINGER;
- wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
- wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
- wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
- wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
- wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
- wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
- wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
- wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
- wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
- wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
- wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
- wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
-
- if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
- data[2] | (data[3] & 0x1f) | data[4])
- wacom_report_key(wcombo, wacom->tool[1], 1);
- else
- wacom_report_key(wcombo, wacom->tool[1], 0);
- wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
+ if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
+ wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
+ wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
+ wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
+ wacom_report_key(wcombo, BTN_3, (data[3] & 0x04));
+ wacom_report_key(wcombo, BTN_4, (data[3] & 0x08));
+ wacom_report_key(wcombo, BTN_5, (data[3] & 0x10));
+ wacom_report_key(wcombo, BTN_6, (data[3] & 0x20));
+ if (data[1] & 0x80) {
+ wacom_report_abs(wcombo, ABS_WHEEL, (data[1] & 0x7f));
+ }
+ if (wacom->features->type != INTUOS4S) {
+ wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
+ wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
+ }
+ if (data[1] | (data[2] & 0x01) | data[3]) {
+ wacom_report_key(wcombo, wacom->tool[1], 1);
+ wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
+ } else {
+ wacom_report_key(wcombo, wacom->tool[1], 0);
+ wacom_report_abs(wcombo, ABS_MISC, 0);
+ }
+ } else {
+ wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
+ wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
+ wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
+ wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
+ wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
+ wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
+ wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
+ wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
+ wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
+ wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
+ wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
+ wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
+
+ if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
+ data[2] | (data[3] & 0x1f) | data[4]) {
+ wacom_report_key(wcombo, wacom->tool[1], 1);
+ wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
+ } else {
+ wacom_report_key(wcombo, wacom->tool[1], 0);
+ wacom_report_abs(wcombo, ABS_MISC, 0);
+ }
+ }
wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
return 1;
}
@@ -453,10 +499,16 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
if (result)
return result-1;
- /* Only large I3 and I1 & I2 support Lense Cursor */
+ /* don't proceed if we don't know the ID */
+ if (!wacom->id[idx])
+ return 0;
+
+ /* Only large Intuos support Lense Cursor */
if ((wacom->tool[idx] == BTN_TOOL_LENS)
&& ((wacom->features->type == INTUOS3)
- || (wacom->features->type == INTUOS3S)))
+ || (wacom->features->type == INTUOS3S)
+ || (wacom->features->type == INTUOS4)
+ || (wacom->features->type == INTUOS4S)))
return 0;
/* Cintiq doesn't send data when RDY bit isn't set */
@@ -476,8 +528,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
/* process general packets */
wacom_intuos_general(wacom, wcombo);
- /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
- if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
+ /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
+ if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
if (data[1] & 0x02) {
/* Rotation packet */
@@ -506,20 +558,36 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
} else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
- /* 2D mouse packet */
- wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
- wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
- wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
- wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
+ /* I4 mouse */
+ if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
+ wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
+ wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
+ wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
+ wacom_report_rel(wcombo, REL_WHEEL, ((data[7] & 0x80) >> 7)
+ - ((data[7] & 0x40) >> 6));
+ wacom_report_key(wcombo, BTN_SIDE, data[6] & 0x08);
+ wacom_report_key(wcombo, BTN_EXTRA, data[6] & 0x10);
+
+ wacom_report_abs(wcombo, ABS_TILT_X,
+ ((data[7] << 1) & 0x7e) | (data[8] >> 7));
+ wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
+ } else {
+ /* 2D mouse packet */
+ wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
+ wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
+ wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
+ wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
- ((data[8] & 0x02) >> 1));
- /* I3 2D mouse side buttons */
- if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
- wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
- wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
+ /* I3 2D mouse side buttons */
+ if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
+ wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
+ wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
+ }
}
-
- } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
+ } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L ||
+ wacom->features->type == INTUOS4L) &&
+ wacom->tool[idx] == BTN_TOOL_LENS) {
/* Lens cursor packets */
wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -581,6 +649,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
}
} else if (touchOut || !prox) { /* force touch out-prox */
wacom_report_abs(wcombo, ABS_MISC, TOUCH_DEVICE_ID);
+ wacom_report_key(wcombo, wacom->tool[1], 0);
wacom_report_key(wcombo, BTN_TOUCH, 0);
touchOut = 0;
touchInProx = 1;
@@ -669,6 +738,9 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
case INTUOS3S:
case INTUOS3:
case INTUOS3L:
+ case INTUOS4S:
+ case INTUOS4:
+ case INTUOS4L:
case CINTIQ:
case WACOM_BEE:
return wacom_intuos_irq(wacom_wac, wcombo);
@@ -706,6 +778,14 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
case INTUOS:
input_dev_i(input_dev, wacom_wac);
break;
+ case INTUOS4:
+ case INTUOS4L:
+ input_dev_i4(input_dev, wacom_wac);
+ /* fall through */
+ case INTUOS4S:
+ input_dev_i4s(input_dev, wacom_wac);
+ input_dev_i(input_dev, wacom_wac);
+ break;
case PL:
case PTU:
case TABLETPC:
@@ -766,6 +846,10 @@ static struct wacom_features wacom_features[] = {
{ "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
{ "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
{ "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S },
+ { "Wacom Intuos4 4x6", 10, 31496, 19685, 2047, 63, INTUOS4S },
+ { "Wacom Intuos4 6x9", 10, 44704, 27940, 2047, 63, INTUOS4 },
+ { "Wacom Intuos4 8x13", 10, 65024, 40640, 2047, 63, INTUOS4L },
+ { "Wacom Intuos4 12x19", 10, 97536, 60960, 2047, 63, INTUOS4L },
{ "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
{ "Wacom Cintiq 20WSX", 10, 86680, 54180, 1023, 63, WACOM_BEE },
{ "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE },
@@ -825,6 +909,10 @@ static struct usb_device_id wacom_ids[] = {
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
+ { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) },
+ { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) },
+ { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) },
+ { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index f9c8b69673b7..c10235aba7e5 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -25,6 +25,9 @@ enum {
INTUOS3S,
INTUOS3,
INTUOS3L,
+ INTUOS4S,
+ INTUOS4,
+ INTUOS4L,
CINTIQ,
WACOM_BEE,
WACOM_MO,
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index b01fd61dadcc..1b4a1675cbc8 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -111,6 +111,15 @@ config TOUCHSCREEN_DA9034
Say Y here to enable the support for the touchscreen found
on Dialog Semiconductor DA9034 PMIC.
+config TOUCHSCREEN_EETI
+ tristate "EETI touchscreen panel support"
+ depends on I2C
+ help
+ Say Y here to enable support for I2C connected EETI touch panels.
+
+ To compile this driver as a module, choose M here: the
+ module will be called eeti_ts.
+
config TOUCHSCREEN_FUJITSU
tristate "Fujitsu serial touchscreen"
select SERIO
@@ -341,6 +350,21 @@ config TOUCHSCREEN_WM9713
Say Y here to enable support for the Wolfson Microelectronics
WM9713 touchscreen controller.
+config TOUCHSCREEN_WM97XX_ATMEL
+ tristate "WM97xx Atmel accelerated touch"
+ depends on TOUCHSCREEN_WM97XX && (AVR32 || ARCH_AT91)
+ help
+ Say Y here for support for streaming mode with WM97xx touchscreens
+ on Atmel AT91 or AVR32 systems with an AC97C module.
+
+ Be aware that this will use channel B in the controller for
+ streaming data, this must not conflict with other AC97C drivers.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the module will
+ be called atmel-wm97xx.
+
config TOUCHSCREEN_WM97XX_MAINSTONE
tristate "WM97xx Mainstone accelerated touch"
depends on TOUCHSCREEN_WM97XX && ARCH_PXA
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 6700f7b9d165..10e0be6cea43 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
+obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o
obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o
obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
@@ -35,5 +36,6 @@ obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o
wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o
wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL) += atmel-wm97xx.o
obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o
obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 2b01e56568f8..90f792c17ab3 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -83,6 +83,7 @@ struct ads7846_packet {
struct ads7846 {
struct input_dev *input;
char phys[32];
+ char name[32];
struct spi_device *spi;
@@ -97,6 +98,8 @@ struct ads7846 {
u16 x_plate_ohms;
u16 pressure_max;
+ bool swap_xy;
+
struct ads7846_packet *packet;
struct spi_transfer xfer[18];
@@ -599,6 +602,10 @@ static void ads7846_rx(void *ads)
dev_dbg(&ts->spi->dev, "DOWN\n");
#endif
}
+
+ if (ts->swap_xy)
+ swap(x, y);
+
input_report_abs(input, ABS_X, x);
input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_PRESSURE, Rt);
@@ -917,6 +924,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
ts->spi = spi;
ts->input = input_dev;
ts->vref_mv = pdata->vref_mv;
+ ts->swap_xy = pdata->swap_xy;
hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ts->timer.function = ads7846_timer;
@@ -958,8 +966,9 @@ static int __devinit ads7846_probe(struct spi_device *spi)
ts->wait_for_sync = pdata->wait_for_sync ? : null_wait_for_sync;
snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&spi->dev));
+ snprintf(ts->name, sizeof(ts->name), "ADS%d Touchscreen", ts->model);
- input_dev->name = "ADS784x Touchscreen";
+ input_dev->name = ts->name;
input_dev->phys = ts->phys;
input_dev->dev.parent = &spi->dev;
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c
new file mode 100644
index 000000000000..35377f583e28
--- /dev/null
+++ b/drivers/input/touchscreen/atmel-wm97xx.c
@@ -0,0 +1,446 @@
+/*
+ * Atmel AT91 and AVR32 continuous touch screen driver for Wolfson WM97xx AC97
+ * codecs.
+ *
+ * Copyright (C) 2008 - 2009 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/wm97xx.h>
+#include <linux/timer.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+
+#define AC97C_ICA 0x10
+#define AC97C_CBRHR 0x30
+#define AC97C_CBSR 0x38
+#define AC97C_CBMR 0x3c
+#define AC97C_IER 0x54
+#define AC97C_IDR 0x58
+
+#define AC97C_RXRDY (1 << 4)
+#define AC97C_OVRUN (1 << 5)
+
+#define AC97C_CMR_SIZE_20 (0 << 16)
+#define AC97C_CMR_SIZE_18 (1 << 16)
+#define AC97C_CMR_SIZE_16 (2 << 16)
+#define AC97C_CMR_SIZE_10 (3 << 16)
+#define AC97C_CMR_CEM_LITTLE (1 << 18)
+#define AC97C_CMR_CEM_BIG (0 << 18)
+#define AC97C_CMR_CENA (1 << 21)
+
+#define AC97C_INT_CBEVT (1 << 4)
+
+#define AC97C_SR_CAEVT (1 << 3)
+
+#define AC97C_CH_MASK(slot) \
+ (0x7 << (3 * (slot - 3)))
+#define AC97C_CH_ASSIGN(slot, channel) \
+ (AC97C_CHANNEL_##channel << (3 * (slot - 3)))
+#define AC97C_CHANNEL_NONE 0x0
+#define AC97C_CHANNEL_B 0x2
+
+#define ac97c_writel(chip, reg, val) \
+ __raw_writel((val), (chip)->regs + AC97C_##reg)
+#define ac97c_readl(chip, reg) \
+ __raw_readl((chip)->regs + AC97C_##reg)
+
+#ifdef CONFIG_CPU_AT32AP700X
+#define ATMEL_WM97XX_AC97C_IOMEM (0xfff02800)
+#define ATMEL_WM97XX_AC97C_IRQ (29)
+#define ATMEL_WM97XX_GPIO_DEFAULT (32+16) /* Pin 16 on port B. */
+#else
+#error Unkown CPU, this driver only supports AT32AP700X CPUs.
+#endif
+
+struct continuous {
+ u16 id; /* codec id */
+ u8 code; /* continuous code */
+ u8 reads; /* number of coord reads per read cycle */
+ u32 speed; /* number of coords per second */
+};
+
+#define WM_READS(sp) ((sp / HZ) + 1)
+
+static const struct continuous cinfo[] = {
+ {WM9705_ID2, 0, WM_READS(94), 94},
+ {WM9705_ID2, 1, WM_READS(188), 188},
+ {WM9705_ID2, 2, WM_READS(375), 375},
+ {WM9705_ID2, 3, WM_READS(750), 750},
+ {WM9712_ID2, 0, WM_READS(94), 94},
+ {WM9712_ID2, 1, WM_READS(188), 188},
+ {WM9712_ID2, 2, WM_READS(375), 375},
+ {WM9712_ID2, 3, WM_READS(750), 750},
+ {WM9713_ID2, 0, WM_READS(94), 94},
+ {WM9713_ID2, 1, WM_READS(120), 120},
+ {WM9713_ID2, 2, WM_READS(154), 154},
+ {WM9713_ID2, 3, WM_READS(188), 188},
+};
+
+/* Continuous speed index. */
+static int sp_idx;
+
+/*
+ * Pen sampling frequency (Hz) in continuous mode.
+ */
+static int cont_rate = 188;
+module_param(cont_rate, int, 0);
+MODULE_PARM_DESC(cont_rate, "Sampling rate in continuous mode (Hz)");
+
+/*
+ * Pen down detection.
+ *
+ * This driver can either poll or use an interrupt to indicate a pen down
+ * event. If the irq request fails then it will fall back to polling mode.
+ */
+static int pen_int = 1;
+module_param(pen_int, int, 0);
+MODULE_PARM_DESC(pen_int, "Pen down detection (1 = interrupt, 0 = polling)");
+
+/*
+ * Pressure readback.
+ *
+ * Set to 1 to read back pen down pressure.
+ */
+static int pressure;
+module_param(pressure, int, 0);
+MODULE_PARM_DESC(pressure, "Pressure readback (1 = pressure, 0 = no pressure)");
+
+/*
+ * AC97 touch data slot.
+ *
+ * Touch screen readback data ac97 slot.
+ */
+static int ac97_touch_slot = 5;
+module_param(ac97_touch_slot, int, 0);
+MODULE_PARM_DESC(ac97_touch_slot, "Touch screen data slot AC97 number");
+
+/*
+ * GPIO line number.
+ *
+ * Set to GPIO number where the signal from the WM97xx device is hooked up.
+ */
+static int atmel_gpio_line = ATMEL_WM97XX_GPIO_DEFAULT;
+module_param(atmel_gpio_line, int, 0);
+MODULE_PARM_DESC(atmel_gpio_line, "GPIO line number connected to WM97xx");
+
+struct atmel_wm97xx {
+ struct wm97xx *wm;
+ struct timer_list pen_timer;
+ void __iomem *regs;
+ unsigned long ac97c_irq;
+ unsigned long gpio_pen;
+ unsigned long gpio_irq;
+ unsigned short x;
+ unsigned short y;
+};
+
+static irqreturn_t atmel_wm97xx_channel_b_interrupt(int irq, void *dev_id)
+{
+ struct atmel_wm97xx *atmel_wm97xx = dev_id;
+ struct wm97xx *wm = atmel_wm97xx->wm;
+ int status = ac97c_readl(atmel_wm97xx, CBSR);
+ irqreturn_t retval = IRQ_NONE;
+
+ if (status & AC97C_OVRUN) {
+ dev_dbg(&wm->touch_dev->dev, "AC97C overrun\n");
+ ac97c_readl(atmel_wm97xx, CBRHR);
+ retval = IRQ_HANDLED;
+ } else if (status & AC97C_RXRDY) {
+ u16 data;
+ u16 value;
+ u16 source;
+ u16 pen_down;
+
+ data = ac97c_readl(atmel_wm97xx, CBRHR);
+ value = data & 0x0fff;
+ source = data & WM97XX_ADCSRC_MASK;
+ pen_down = (data & WM97XX_PEN_DOWN) >> 8;
+
+ if (source == WM97XX_ADCSEL_X)
+ atmel_wm97xx->x = value;
+ if (source == WM97XX_ADCSEL_Y)
+ atmel_wm97xx->y = value;
+
+ if (!pressure && source == WM97XX_ADCSEL_Y) {
+ input_report_abs(wm->input_dev, ABS_X, atmel_wm97xx->x);
+ input_report_abs(wm->input_dev, ABS_Y, atmel_wm97xx->y);
+ input_report_key(wm->input_dev, BTN_TOUCH, pen_down);
+ input_sync(wm->input_dev);
+ } else if (pressure && source == WM97XX_ADCSEL_PRES) {
+ input_report_abs(wm->input_dev, ABS_X, atmel_wm97xx->x);
+ input_report_abs(wm->input_dev, ABS_Y, atmel_wm97xx->y);
+ input_report_abs(wm->input_dev, ABS_PRESSURE, value);
+ input_report_key(wm->input_dev, BTN_TOUCH, value);
+ input_sync(wm->input_dev);
+ }
+
+ retval = IRQ_HANDLED;
+ }
+
+ return retval;
+}
+
+static void atmel_wm97xx_acc_pen_up(struct wm97xx *wm)
+{
+ struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(wm->touch_dev);
+ struct input_dev *input_dev = wm->input_dev;
+ int pen_down = gpio_get_value(atmel_wm97xx->gpio_pen);
+
+ if (pen_down != 0) {
+ mod_timer(&atmel_wm97xx->pen_timer,
+ jiffies + msecs_to_jiffies(1));
+ } else {
+ if (pressure)
+ input_report_abs(input_dev, ABS_PRESSURE, 0);
+ input_report_key(input_dev, BTN_TOUCH, 0);
+ input_sync(input_dev);
+ }
+}
+
+static void atmel_wm97xx_pen_timer(unsigned long data)
+{
+ atmel_wm97xx_acc_pen_up((struct wm97xx *)data);
+}
+
+static int atmel_wm97xx_acc_startup(struct wm97xx *wm)
+{
+ struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(wm->touch_dev);
+ int idx = 0;
+
+ if (wm->ac97 == NULL)
+ return -ENODEV;
+
+ for (idx = 0; idx < ARRAY_SIZE(cinfo); idx++) {
+ if (wm->id != cinfo[idx].id)
+ continue;
+
+ sp_idx = idx;
+
+ if (cont_rate <= cinfo[idx].speed)
+ break;
+ }
+
+ wm->acc_rate = cinfo[sp_idx].code;
+ wm->acc_slot = ac97_touch_slot;
+ dev_info(&wm->touch_dev->dev, "atmel accelerated touchscreen driver, "
+ "%d samples/sec\n", cinfo[sp_idx].speed);
+
+ if (pen_int) {
+ unsigned long reg;
+
+ wm->pen_irq = atmel_wm97xx->gpio_irq;
+
+ switch (wm->id) {
+ case WM9712_ID2: /* Fall through. */
+ case WM9713_ID2:
+ /*
+ * Use GPIO 13 (PEN_DOWN) to assert GPIO line 3
+ * (PENDOWN).
+ */
+ wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN,
+ WM97XX_GPIO_POL_HIGH,
+ WM97XX_GPIO_STICKY,
+ WM97XX_GPIO_WAKE);
+ wm97xx_config_gpio(wm, WM97XX_GPIO_3, WM97XX_GPIO_OUT,
+ WM97XX_GPIO_POL_HIGH,
+ WM97XX_GPIO_NOTSTICKY,
+ WM97XX_GPIO_NOWAKE);
+ case WM9705_ID2: /* Fall through. */
+ /*
+ * Enable touch data slot in AC97 controller channel B.
+ */
+ reg = ac97c_readl(atmel_wm97xx, ICA);
+ reg &= ~AC97C_CH_MASK(wm->acc_slot);
+ reg |= AC97C_CH_ASSIGN(wm->acc_slot, B);
+ ac97c_writel(atmel_wm97xx, ICA, reg);
+
+ /*
+ * Enable channel and interrupt for RXRDY and OVERRUN.
+ */
+ ac97c_writel(atmel_wm97xx, CBMR, AC97C_CMR_CENA
+ | AC97C_CMR_CEM_BIG
+ | AC97C_CMR_SIZE_16
+ | AC97C_OVRUN
+ | AC97C_RXRDY);
+ /* Dummy read to empty RXRHR. */
+ ac97c_readl(atmel_wm97xx, CBRHR);
+ /*
+ * Enable interrupt for channel B in the AC97
+ * controller.
+ */
+ ac97c_writel(atmel_wm97xx, IER, AC97C_INT_CBEVT);
+ break;
+ default:
+ dev_err(&wm->touch_dev->dev, "pen down irq not "
+ "supported on this device\n");
+ pen_int = 0;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static void atmel_wm97xx_acc_shutdown(struct wm97xx *wm)
+{
+ if (pen_int) {
+ struct atmel_wm97xx *atmel_wm97xx =
+ platform_get_drvdata(wm->touch_dev);
+ unsigned long ica;
+
+ switch (wm->id & 0xffff) {
+ case WM9705_ID2: /* Fall through. */
+ case WM9712_ID2: /* Fall through. */
+ case WM9713_ID2:
+ /* Disable slot and turn off channel B interrupts. */
+ ica = ac97c_readl(atmel_wm97xx, ICA);
+ ica &= ~AC97C_CH_MASK(wm->acc_slot);
+ ac97c_writel(atmel_wm97xx, ICA, ica);
+ ac97c_writel(atmel_wm97xx, IDR, AC97C_INT_CBEVT);
+ ac97c_writel(atmel_wm97xx, CBMR, 0);
+ wm->pen_irq = 0;
+ break;
+ default:
+ dev_err(&wm->touch_dev->dev, "unknown codec\n");
+ break;
+ }
+ }
+}
+
+static void atmel_wm97xx_irq_enable(struct wm97xx *wm, int enable)
+{
+ /* Intentionally left empty. */
+}
+
+static struct wm97xx_mach_ops atmel_mach_ops = {
+ .acc_enabled = 1,
+ .acc_pen_up = atmel_wm97xx_acc_pen_up,
+ .acc_startup = atmel_wm97xx_acc_startup,
+ .acc_shutdown = atmel_wm97xx_acc_shutdown,
+ .irq_enable = atmel_wm97xx_irq_enable,
+ .irq_gpio = WM97XX_GPIO_3,
+};
+
+static int __init atmel_wm97xx_probe(struct platform_device *pdev)
+{
+ struct wm97xx *wm = platform_get_drvdata(pdev);
+ struct atmel_wm97xx *atmel_wm97xx;
+ int ret;
+
+ atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL);
+ if (!atmel_wm97xx) {
+ dev_dbg(&pdev->dev, "out of memory\n");
+ return -ENOMEM;
+ }
+
+ atmel_wm97xx->wm = wm;
+ atmel_wm97xx->regs = (void *)ATMEL_WM97XX_AC97C_IOMEM;
+ atmel_wm97xx->ac97c_irq = ATMEL_WM97XX_AC97C_IRQ;
+ atmel_wm97xx->gpio_pen = atmel_gpio_line;
+ atmel_wm97xx->gpio_irq = gpio_to_irq(atmel_wm97xx->gpio_pen);
+
+ setup_timer(&atmel_wm97xx->pen_timer, atmel_wm97xx_pen_timer,
+ (unsigned long)wm);
+
+ ret = request_irq(atmel_wm97xx->ac97c_irq,
+ atmel_wm97xx_channel_b_interrupt,
+ IRQF_SHARED, "atmel-wm97xx-ch-b", atmel_wm97xx);
+ if (ret) {
+ dev_dbg(&pdev->dev, "could not request ac97c irq\n");
+ goto err;
+ }
+
+ platform_set_drvdata(pdev, atmel_wm97xx);
+
+ ret = wm97xx_register_mach_ops(wm, &atmel_mach_ops);
+ if (ret)
+ goto err_irq;
+
+ return ret;
+
+err_irq:
+ free_irq(atmel_wm97xx->ac97c_irq, atmel_wm97xx);
+err:
+ platform_set_drvdata(pdev, NULL);
+ kfree(atmel_wm97xx);
+ return ret;
+}
+
+static int __exit atmel_wm97xx_remove(struct platform_device *pdev)
+{
+ struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev);
+ struct wm97xx *wm = atmel_wm97xx->wm;
+
+ ac97c_writel(atmel_wm97xx, IDR, AC97C_INT_CBEVT);
+ free_irq(atmel_wm97xx->ac97c_irq, atmel_wm97xx);
+ del_timer_sync(&atmel_wm97xx->pen_timer);
+ wm97xx_unregister_mach_ops(wm);
+ platform_set_drvdata(pdev, NULL);
+ kfree(atmel_wm97xx);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int atmel_wm97xx_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+ struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev);
+
+ ac97c_writel(atmel_wm97xx, IDR, AC97C_INT_CBEVT);
+ disable_irq(atmel_wm97xx->gpio_irq);
+ del_timer_sync(&atmel_wm97xx->pen_timer);
+
+ return 0;
+}
+
+static int atmel_wm97xx_resume(struct platform_device *pdev)
+{
+ struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev);
+ struct wm97xx *wm = atmel_wm97xx->wm;
+
+ if (wm->input_dev->users) {
+ enable_irq(atmel_wm97xx->gpio_irq);
+ ac97c_writel(atmel_wm97xx, IER, AC97C_INT_CBEVT);
+ }
+
+ return 0;
+}
+#else
+#define atmel_wm97xx_suspend NULL
+#define atmel_wm97xx_resume NULL
+#endif
+
+static struct platform_driver atmel_wm97xx_driver = {
+ .remove = __exit_p(atmel_wm97xx_remove),
+ .driver = {
+ .name = "wm97xx-touch",
+ },
+ .suspend = atmel_wm97xx_suspend,
+ .resume = atmel_wm97xx_resume,
+};
+
+static int __init atmel_wm97xx_init(void)
+{
+ return platform_driver_probe(&atmel_wm97xx_driver, atmel_wm97xx_probe);
+}
+module_init(atmel_wm97xx_init);
+
+static void __exit atmel_wm97xx_exit(void)
+{
+ platform_driver_unregister(&atmel_wm97xx_driver);
+}
+module_exit(atmel_wm97xx_exit);
+
+MODULE_AUTHOR("Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>");
+MODULE_DESCRIPTION("wm97xx continuous touch driver for Atmel AT91 and AVR32");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
new file mode 100644
index 000000000000..3ab92222a525
--- /dev/null
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -0,0 +1,286 @@
+/*
+ * Touch Screen driver for EETI's I2C connected touch screen panels
+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
+ *
+ * See EETI's software guide for the protocol specification:
+ * http://home.eeti.com.tw/web20/eg/guide.htm
+ *
+ * Based on migor_ts.c
+ * Copyright (c) 2008 Magnus Damm
+ * Copyright (c) 2007 Ujjwal Pande <ujjwal@kenati.com>
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/timer.h>
+#include <linux/gpio.h>
+
+static int flip_x;
+module_param(flip_x, bool, 0644);
+MODULE_PARM_DESC(flip_x, "flip x coordinate");
+
+static int flip_y;
+module_param(flip_y, bool, 0644);
+MODULE_PARM_DESC(flip_y, "flip y coordinate");
+
+struct eeti_ts_priv {
+ struct i2c_client *client;
+ struct input_dev *input;
+ struct work_struct work;
+ struct mutex mutex;
+ int irq;
+};
+
+#define EETI_TS_BITDEPTH (11)
+#define EETI_MAXVAL ((1 << (EETI_TS_BITDEPTH + 1)) - 1)
+
+#define REPORT_BIT_PRESSED (1 << 0)
+#define REPORT_BIT_AD0 (1 << 1)
+#define REPORT_BIT_AD1 (1 << 2)
+#define REPORT_BIT_HAS_PRESSURE (1 << 6)
+#define REPORT_RES_BITS(v) (((v) >> 1) + EETI_TS_BITDEPTH)
+
+static void eeti_ts_read(struct work_struct *work)
+{
+ char buf[6];
+ unsigned int x, y, res, pressed, to = 100;
+ struct eeti_ts_priv *priv =
+ container_of(work, struct eeti_ts_priv, work);
+
+ mutex_lock(&priv->mutex);
+
+ while (!gpio_get_value(irq_to_gpio(priv->irq)) && --to)
+ i2c_master_recv(priv->client, buf, sizeof(buf));
+
+ if (!to) {
+ dev_err(&priv->client->dev,
+ "unable to clear IRQ - line stuck?\n");
+ goto out;
+ }
+
+ /* drop non-report packets */
+ if (!(buf[0] & 0x80))
+ goto out;
+
+ pressed = buf[0] & REPORT_BIT_PRESSED;
+ res = REPORT_RES_BITS(buf[0] & (REPORT_BIT_AD0 | REPORT_BIT_AD1));
+ x = buf[2] | (buf[1] << 8);
+ y = buf[4] | (buf[3] << 8);
+
+ /* fix the range to 11 bits */
+ x >>= res - EETI_TS_BITDEPTH;
+ y >>= res - EETI_TS_BITDEPTH;
+
+ if (flip_x)
+ x = EETI_MAXVAL - x;
+
+ if (flip_y)
+ y = EETI_MAXVAL - y;
+
+ if (buf[0] & REPORT_BIT_HAS_PRESSURE)
+ input_report_abs(priv->input, ABS_PRESSURE, buf[5]);
+
+ input_report_abs(priv->input, ABS_X, x);
+ input_report_abs(priv->input, ABS_Y, y);
+ input_report_key(priv->input, BTN_TOUCH, !!pressed);
+ input_sync(priv->input);
+
+out:
+ mutex_unlock(&priv->mutex);
+}
+
+static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
+{
+ struct eeti_ts_priv *priv = dev_id;
+
+ /* postpone I2C transactions as we are atomic */
+ schedule_work(&priv->work);
+
+ return IRQ_HANDLED;
+}
+
+static int eeti_ts_open(struct input_dev *dev)
+{
+ struct eeti_ts_priv *priv = input_get_drvdata(dev);
+
+ enable_irq(priv->irq);
+
+ /* Read the events once to arm the IRQ */
+ eeti_ts_read(&priv->work);
+
+ return 0;
+}
+
+static void eeti_ts_close(struct input_dev *dev)
+{
+ struct eeti_ts_priv *priv = input_get_drvdata(dev);
+
+ disable_irq(priv->irq);
+ cancel_work_sync(&priv->work);
+}
+
+static int __devinit eeti_ts_probe(struct i2c_client *client,
+ const struct i2c_device_id *idp)
+{
+ struct eeti_ts_priv *priv;
+ struct input_dev *input;
+ int err = -ENOMEM;
+
+ /* In contrast to what's described in the datasheet, there seems
+ * to be no way of probing the presence of that device using I2C
+ * commands. So we need to blindly believe it is there, and wait
+ * for interrupts to occur. */
+
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ if (!priv) {
+ dev_err(&client->dev, "failed to allocate driver data\n");
+ goto err0;
+ }
+
+ mutex_init(&priv->mutex);
+ input = input_allocate_device();
+
+ if (!input) {
+ dev_err(&client->dev, "Failed to allocate input device.\n");
+ goto err1;
+ }
+
+ input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+ input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+
+ input_set_abs_params(input, ABS_X, 0, EETI_MAXVAL, 0, 0);
+ input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0);
+ input_set_abs_params(input, ABS_PRESSURE, 0, 0xff, 0, 0);
+
+ input->name = client->name;
+ input->id.bustype = BUS_I2C;
+ input->dev.parent = &client->dev;
+ input->open = eeti_ts_open;
+ input->close = eeti_ts_close;
+
+ priv->client = client;
+ priv->input = input;
+ priv->irq = client->irq;
+
+ INIT_WORK(&priv->work, eeti_ts_read);
+ i2c_set_clientdata(client, priv);
+ input_set_drvdata(input, priv);
+
+ err = input_register_device(input);
+ if (err)
+ goto err1;
+
+ err = request_irq(priv->irq, eeti_ts_isr, IRQF_TRIGGER_FALLING,
+ client->name, priv);
+ if (err) {
+ dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
+ goto err2;
+ }
+
+ /* Disable the irq for now. It will be enabled once the input device
+ * is opened. */
+ disable_irq(priv->irq);
+
+ device_init_wakeup(&client->dev, 0);
+ return 0;
+
+err2:
+ input_unregister_device(input);
+ input = NULL; /* so we dont try to free it below */
+err1:
+ input_free_device(input);
+ i2c_set_clientdata(client, NULL);
+ kfree(priv);
+err0:
+ return err;
+}
+
+static int __devexit eeti_ts_remove(struct i2c_client *client)
+{
+ struct eeti_ts_priv *priv = i2c_get_clientdata(client);
+
+ free_irq(priv->irq, priv);
+ input_unregister_device(priv->input);
+ i2c_set_clientdata(client, NULL);
+ kfree(priv);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ struct eeti_ts_priv *priv = i2c_get_clientdata(client);
+
+ if (device_may_wakeup(&client->dev))
+ enable_irq_wake(priv->irq);
+
+ return 0;
+}
+
+static int eeti_ts_resume(struct i2c_client *client)
+{
+ struct eeti_ts_priv *priv = i2c_get_clientdata(client);
+
+ if (device_may_wakeup(&client->dev))
+ disable_irq_wake(priv->irq);
+
+ return 0;
+}
+#else
+#define eeti_ts_suspend NULL
+#define eeti_ts_resume NULL
+#endif
+
+static const struct i2c_device_id eeti_ts_id[] = {
+ { "eeti_ts", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, eeti_ts_id);
+
+static struct i2c_driver eeti_ts_driver = {
+ .driver = {
+ .name = "eeti_ts",
+ },
+ .probe = eeti_ts_probe,
+ .remove = __devexit_p(eeti_ts_remove),
+ .suspend = eeti_ts_suspend,
+ .resume = eeti_ts_resume,
+ .id_table = eeti_ts_id,
+};
+
+static int __init eeti_ts_init(void)
+{
+ return i2c_add_driver(&eeti_ts_driver);
+}
+
+static void __exit eeti_ts_exit(void)
+{
+ i2c_del_driver(&eeti_ts_driver);
+}
+
+MODULE_DESCRIPTION("EETI Touchscreen driver");
+MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
+MODULE_LICENSE("GPL");
+
+module_init(eeti_ts_init);
+module_exit(eeti_ts_exit);
+
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 948e167557f1..880f58c6a7c4 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -257,7 +257,7 @@ static int tsc2007_probe(struct i2c_client *client,
struct input_dev *input_dev;
int err;
- if (!pdata) {
+ if (!pdata || !pdata->get_pendown_state) {
dev_err(&client->dev, "platform data is required!\n");
return -EINVAL;
}
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 69af8385ab14..2957d48e0045 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -569,7 +569,7 @@ static int wm97xx_probe(struct device *dev)
mutex_init(&wm->codec_mutex);
wm->dev = dev;
- dev->driver_data = wm;
+ dev_set_drvdata(dev, wm);
wm->ac97 = to_ac97_t(dev);
/* check that we have a supported codec */
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
index 928d2ed8865f..b115726dc088 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/xen-kbdfront.c
@@ -114,7 +114,7 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure");
return -ENOMEM;
}
- dev->dev.driver_data = info;
+ dev_set_drvdata(&dev->dev, info);
info->xbdev = dev;
info->irq = -1;
snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename);
@@ -186,7 +186,7 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
static int xenkbd_resume(struct xenbus_device *dev)
{
- struct xenkbd_info *info = dev->dev.driver_data;
+ struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
xenkbd_disconnect_backend(info);
memset(info->page, 0, PAGE_SIZE);
@@ -195,7 +195,7 @@ static int xenkbd_resume(struct xenbus_device *dev)
static int xenkbd_remove(struct xenbus_device *dev)
{
- struct xenkbd_info *info = dev->dev.driver_data;
+ struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
xenkbd_disconnect_backend(info);
if (info->kbd)
@@ -266,7 +266,7 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *info)
static void xenkbd_backend_changed(struct xenbus_device *dev,
enum xenbus_state backend_state)
{
- struct xenkbd_info *info = dev->dev.driver_data;
+ struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
int ret, val;
switch (backend_state) {
diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
index 3d113c6e4a70..02bdca6f95c3 100644
--- a/drivers/isdn/Kconfig
+++ b/drivers/isdn/Kconfig
@@ -61,4 +61,6 @@ source "drivers/isdn/hardware/Kconfig"
endif # ISDN_CAPI
+source "drivers/isdn/gigaset/Kconfig"
+
endif # ISDN
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 7d97d54588d9..77e9fdda0597 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -183,7 +183,7 @@ int cf_command(int drvid, int mode,
(mode != 1) ? "" : " 0 ",
(mode != 1) ? "" : fwd_nr);
- retval = divert_if.ll_cmd(&cs->ics); /* excute command */
+ retval = divert_if.ll_cmd(&cs->ics); /* execute command */
if (!retval)
{ cs->prev = NULL;
diff --git a/drivers/isdn/gigaset/Kconfig b/drivers/isdn/gigaset/Kconfig
index 9ca889adf120..18ab8652aa57 100644
--- a/drivers/isdn/gigaset/Kconfig
+++ b/drivers/isdn/gigaset/Kconfig
@@ -1,5 +1,6 @@
menuconfig ISDN_DRV_GIGASET
tristate "Siemens Gigaset support"
+ depends on ISDN_I4L
select CRC_CCITT
select BITREVERSE
help
@@ -42,11 +43,4 @@ config GIGASET_DEBUG
This enables debugging code in the Gigaset drivers.
If in doubt, say yes.
-config GIGASET_UNDOCREQ
- bool "Support for undocumented USB requests"
- help
- This enables support for USB requests we only know from
- reverse engineering (currently M105 only). If you need
- features like configuration mode of M105, say yes.
-
endif # ISDN_DRV_GIGASET
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c
index 2a4ce96f04bd..234cc5d53312 100644
--- a/drivers/isdn/gigaset/asyncdata.c
+++ b/drivers/isdn/gigaset/asyncdata.c
@@ -174,9 +174,8 @@ byte_stuff:
if (unlikely(fcs != PPP_GOODFCS)) {
dev_err(cs->dev,
- "Packet checksum at %lu failed, "
- "packet is corrupted (%u bytes)!\n",
- bcs->rcvbytes, skb->len);
+ "Checksum failed, %u bytes corrupted!\n",
+ skb->len);
compskb = NULL;
gigaset_rcv_error(compskb, cs, bcs);
error = 1;
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 0048ce98bfa8..e4141bf8b2f3 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -565,8 +565,6 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
gig_dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel);
gigaset_at_init(&bcs->at_state, bcs, cs, -1);
- bcs->rcvbytes = 0;
-
#ifdef CONFIG_GIGASET_DEBUG
bcs->emptycount = 0;
#endif
@@ -672,14 +670,8 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->tty = NULL;
cs->tty_dev = NULL;
cs->cidmode = cidmode != 0;
-
- //if(onechannel) { //FIXME
- cs->tabnocid = gigaset_tab_nocid_m10x;
- cs->tabcid = gigaset_tab_cid_m10x;
- //} else {
- // cs->tabnocid = gigaset_tab_nocid;
- // cs->tabcid = gigaset_tab_cid;
- //}
+ cs->tabnocid = gigaset_tab_nocid;
+ cs->tabcid = gigaset_tab_cid;
init_waitqueue_head(&cs->waitqueue);
cs->waiting = 0;
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index e582a4887bc1..ec5169604a6a 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -160,7 +160,7 @@
// 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid), 400: hup, 500: reset, 600: dial, 700: ring
-struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
+struct reply_t gigaset_tab_nocid[] =
{
/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
@@ -280,7 +280,7 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
};
// 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring, 400: hup, 750: accepted icall
-struct reply_t gigaset_tab_cid_m10x[] = /* for M10x */
+struct reply_t gigaset_tab_cid[] =
{
/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 747178f03d2c..a2f6125739eb 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -282,8 +282,8 @@ struct reply_t {
char *command; /* NULL==none */
};
-extern struct reply_t gigaset_tab_cid_m10x[];
-extern struct reply_t gigaset_tab_nocid_m10x[];
+extern struct reply_t gigaset_tab_cid[];
+extern struct reply_t gigaset_tab_nocid[];
struct inbuf_t {
unsigned char *rcvbuf; /* usb-gigaset receive buffer */
@@ -384,7 +384,6 @@ struct bc_state {
int trans_up; /* Counter of packages (upstream) */
struct at_state_t at_state;
- unsigned long rcvbytes;
__u16 fcs;
struct sk_buff *skb;
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c
index 69a702f0db93..9b22f9cf2f33 100644
--- a/drivers/isdn/gigaset/i4l.c
+++ b/drivers/isdn/gigaset/i4l.c
@@ -544,11 +544,11 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
gig_dbg(DEBUG_ANY, "Register driver capabilities to LL");
- //iif->id[sizeof(iif->id) - 1]=0;
- //strncpy(iif->id, isdnid, sizeof(iif->id) - 1);
if (snprintf(iif->id, sizeof iif->id, "%s_%u", isdnid, cs->minor_index)
- >= sizeof iif->id)
- return -ENOMEM; //FIXME EINVAL/...??
+ >= sizeof iif->id) {
+ pr_err("ID too long: %s\n", isdnid);
+ return 0;
+ }
iif->owner = THIS_MODULE;
iif->channels = cs->channels;
@@ -568,8 +568,10 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
iif->rcvcallb_skb = NULL; /* Will be set by LL */
iif->statcallb = NULL; /* Will be set by LL */
- if (!register_isdn(iif))
+ if (!register_isdn(iif)) {
+ pr_err("register_isdn failed\n");
return 0;
+ }
cs->myid = iif->channels; /* Set my device id */
return 1;
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 820a30923fee..1ebfcab74662 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -599,8 +599,7 @@ void gigaset_if_init(struct cardstate *cs)
if (!IS_ERR(cs->tty_dev))
dev_set_drvdata(cs->tty_dev, cs);
else {
- dev_warn(cs->dev,
- "could not register device to the tty subsystem\n");
+ pr_warning("could not register device to the tty subsystem\n");
cs->tty_dev = NULL;
}
mutex_unlock(&cs->mutex);
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index b171e75cb52e..db3a1e4cd489 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -175,7 +175,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
return -EINVAL;
}
src = iwb->read;
- if (unlikely(limit > BAS_OUTBUFSIZE + BAS_OUTBUFPAD ||
+ if (unlikely(limit >= BAS_OUTBUFSIZE + BAS_OUTBUFPAD ||
(read < src && limit >= src))) {
pr_err("isoc write buffer frame reservation violated\n");
return -EFAULT;
@@ -246,6 +246,10 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
unsigned char c;
static char dbgline[3 * 32 + 1];
int i = 0;
+
+ if (!(gigaset_debuglevel & level))
+ return;
+
while (count-- > 0) {
if (i > sizeof(dbgline) - 4) {
dbgline[i] = '\0';
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index da6f3acf9fd0..9715aad9c3f0 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -79,5 +79,5 @@ void gigaset_init_dev_sysfs(struct cardstate *cs)
gig_dbg(DEBUG_INIT, "setting up sysfs");
if (device_create_file(cs->tty_dev, &dev_attr_cidmode))
- dev_err(cs->dev, "could not create sysfs attribute\n");
+ pr_err("could not create sysfs attribute\n");
}
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index d78385166099..4deb1ab0dbf8 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -153,8 +153,6 @@ static inline unsigned tiocm_to_gigaset(unsigned state)
return ((state & TIOCM_DTR) ? 1 : 0) | ((state & TIOCM_RTS) ? 2 : 0);
}
-#ifdef CONFIG_GIGASET_UNDOCREQ
-/* WARNING: EXPERIMENTAL! */
static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
unsigned new_state)
{
@@ -176,6 +174,11 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
return 0;
}
+/*
+ * Set M105 configuration value
+ * using undocumented device commands reverse engineered from USB traces
+ * of the Siemens Windows driver
+ */
static int set_value(struct cardstate *cs, u8 req, u16 val)
{
struct usb_device *udev = cs->hw.usb->udev;
@@ -205,8 +208,10 @@ static int set_value(struct cardstate *cs, u8 req, u16 val)
return r < 0 ? r : (r2 < 0 ? r2 : 0);
}
-/* WARNING: HIGHLY EXPERIMENTAL! */
-// don't use this in an interrupt/BH
+/*
+ * set the baud rate on the internal serial adapter
+ * using the undocumented parameter setting command
+ */
static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
{
u16 val;
@@ -237,8 +242,10 @@ static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
return set_value(cs, 1, val);
}
-/* WARNING: HIGHLY EXPERIMENTAL! */
-// don't use this in an interrupt/BH
+/*
+ * set the line format on the internal serial adapter
+ * using the undocumented parameter setting command
+ */
static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
{
u16 val = 0;
@@ -274,24 +281,6 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
return set_value(cs, 3, val);
}
-#else
-static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
- unsigned new_state)
-{
- return -ENOTTY;
-}
-
-static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
-{
- return -ENOTTY;
-}
-
-static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
-{
- return -ENOTTY;
-}
-#endif
-
/*================================================================================================================*/
static int gigaset_init_bchannel(struct bc_state *bcs)
@@ -362,10 +351,8 @@ static void gigaset_modem_fill(unsigned long data)
} while (again);
}
-/**
- * gigaset_read_int_callback
- *
- * It is called if the data was received from the device.
+/*
+ * Interrupt Input URB completion routine
*/
static void gigaset_read_int_callback(struct urb *urb)
{
@@ -567,18 +554,19 @@ static int gigaset_chars_in_buffer(struct cardstate *cs)
return cs->cmdbytes;
}
+/*
+ * set the break characters on the internal serial adapter
+ * using undocumented device commands reverse engineered from USB traces
+ * of the Siemens Windows driver
+ */
static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
{
-#ifdef CONFIG_GIGASET_UNDOCREQ
struct usb_device *udev = cs->hw.usb->udev;
gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
memcpy(cs->hw.usb->bchars, buf, 6);
return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
0, 0, &buf, 6, 2000);
-#else
- return -ENOTTY;
-#endif
}
static int gigaset_freebcshw(struct bc_state *bcs)
@@ -625,7 +613,6 @@ static int gigaset_initcshw(struct cardstate *cs)
ucs->bchars[5] = 0x13;
ucs->bulk_out_buffer = NULL;
ucs->bulk_out_urb = NULL;
- //ucs->urb_cmd_out = NULL;
ucs->read_urb = NULL;
tasklet_init(&cs->write_tasklet,
&gigaset_modem_fill, (unsigned long) cs);
@@ -742,7 +729,7 @@ static int gigaset_probe(struct usb_interface *interface,
cs->dev = &interface->dev;
/* save address of controller structure */
- usb_set_intfdata(interface, cs); // dev_set_drvdata(&interface->dev, cs);
+ usb_set_intfdata(interface, cs);
endpoint = &hostif->endpoint[0].desc;
@@ -921,8 +908,7 @@ static const struct gigaset_ops ops = {
gigaset_m10x_input,
};
-/**
- * usb_gigaset_init
+/*
* This function is called while kernel-module is loaded
*/
static int __init usb_gigaset_init(void)
@@ -952,9 +938,7 @@ error:
return -1;
}
-
-/**
- * usb_gigaset_exit
+/*
* This function is called while unloading the kernel-module
*/
static void __exit usb_gigaset_exit(void)
diff --git a/drivers/isdn/hardware/mISDN/Kconfig b/drivers/isdn/hardware/mISDN/Kconfig
index fd112ae252cf..3024566dd099 100644
--- a/drivers/isdn/hardware/mISDN/Kconfig
+++ b/drivers/isdn/hardware/mISDN/Kconfig
@@ -13,7 +13,7 @@ config MISDN_HFCPCI
config MISDN_HFCMULTI
tristate "Support for HFC multiport cards (HFC-4S/8S/E1)"
- depends on PCI
+ depends on PCI || 8xx
depends on MISDN
help
Enable support for cards with Cologne Chip AG's HFC multiport
@@ -23,6 +23,15 @@ config MISDN_HFCMULTI
* HFC-8S (8 S/T interfaces on one chip)
* HFC-E1 (E1 interface for 2Mbit ISDN)
+config MISDN_HFCMULTI_8xx
+ boolean "Support for XHFC embedded board in HFC multiport driver"
+ depends on MISDN
+ depends on MISDN_HFCMULTI
+ depends on 8xx
+ default 8xx
+ help
+ Enable support for the XHFC embedded solution from Speech Design.
+
config MISDN_HFCUSB
tristate "Support for HFC-S USB based TAs"
depends on USB
diff --git a/drivers/isdn/hardware/mISDN/hfc_multi.h b/drivers/isdn/hardware/mISDN/hfc_multi.h
index 663b77f578be..0c773866efc7 100644
--- a/drivers/isdn/hardware/mISDN/hfc_multi.h
+++ b/drivers/isdn/hardware/mISDN/hfc_multi.h
@@ -17,6 +17,16 @@
#define PCI_ENA_REGIO 0x01
#define PCI_ENA_MEMIO 0x02
+#define XHFC_IRQ 4 /* SIU_IRQ2 */
+#define XHFC_MEMBASE 0xFE000000
+#define XHFC_MEMSIZE 0x00001000
+#define XHFC_OFFSET 0x00001000
+#define PA_XHFC_A0 0x0020 /* PA10 */
+#define PB_XHFC_IRQ1 0x00000100 /* PB23 */
+#define PB_XHFC_IRQ2 0x00000200 /* PB22 */
+#define PB_XHFC_IRQ3 0x00000400 /* PB21 */
+#define PB_XHFC_IRQ4 0x00000800 /* PB20 */
+
/*
* NOTE: some registers are assigned multiple times due to different modes
* also registers are assigned differen for HFC-4s/8s and HFC-E1
@@ -44,6 +54,7 @@ struct hfc_chan {
int conf; /* conference setting of TX slot */
int txpending; /* if there is currently data in */
/* the FIFO 0=no, 1=yes, 2=splloop */
+ int Zfill; /* rx-fifo level on last hfcmulti_tx */
int rx_off; /* set to turn fifo receive off */
int coeff_count; /* curren coeff block */
s32 *coeff; /* memory pointer to 8 coeff blocks */
@@ -62,6 +73,7 @@ struct hfcm_hw {
u_char r_sci_msk;
u_char r_tx0, r_tx1;
u_char a_st_ctrl0[8];
+ u_char r_bert_wd_md;
timer_t timer;
};
@@ -79,6 +91,11 @@ struct hfcm_hw {
#define HFC_CFG_CRC4 10 /* disable CRC-4 Multiframe mode, */
/* use double frame instead. */
+#define HFC_TYPE_E1 1 /* controller is HFC-E1 */
+#define HFC_TYPE_4S 4 /* controller is HFC-4S */
+#define HFC_TYPE_8S 8 /* controller is HFC-8S */
+#define HFC_TYPE_XHFC 5 /* controller is XHFC */
+
#define HFC_CHIP_EXRAM_128 0 /* external ram 128k */
#define HFC_CHIP_EXRAM_512 1 /* external ram 256k */
#define HFC_CHIP_REVISION0 2 /* old fifo handling */
@@ -86,19 +103,22 @@ struct hfcm_hw {
#define HFC_CHIP_PCM_MASTER 4 /* PCM is master */
#define HFC_CHIP_RX_SYNC 5 /* disable pll sync for pcm */
#define HFC_CHIP_DTMF 6 /* DTMF decoding is enabled */
-#define HFC_CHIP_ULAW 7 /* ULAW mode */
-#define HFC_CHIP_CLOCK2 8 /* double clock mode */
-#define HFC_CHIP_E1CLOCK_GET 9 /* always get clock from E1 interface */
-#define HFC_CHIP_E1CLOCK_PUT 10 /* always put clock from E1 interface */
-#define HFC_CHIP_WATCHDOG 11 /* whether we should send signals */
+#define HFC_CHIP_CONF 7 /* conference handling is enabled */
+#define HFC_CHIP_ULAW 8 /* ULAW mode */
+#define HFC_CHIP_CLOCK2 9 /* double clock mode */
+#define HFC_CHIP_E1CLOCK_GET 10 /* always get clock from E1 interface */
+#define HFC_CHIP_E1CLOCK_PUT 11 /* always put clock from E1 interface */
+#define HFC_CHIP_WATCHDOG 12 /* whether we should send signals */
/* to the watchdog */
-#define HFC_CHIP_B410P 12 /* whether we have a b410p with echocan in */
+#define HFC_CHIP_B410P 13 /* whether we have a b410p with echocan in */
/* hw */
-#define HFC_CHIP_PLXSD 13 /* whether we have a Speech-Design PLX */
+#define HFC_CHIP_PLXSD 14 /* whether we have a Speech-Design PLX */
+#define HFC_CHIP_EMBSD 15 /* whether we have a SD Embedded board */
#define HFC_IO_MODE_PCIMEM 0x00 /* normal memory mapped IO */
#define HFC_IO_MODE_REGIO 0x01 /* PCI io access */
#define HFC_IO_MODE_PLXSD 0x02 /* access HFC via PLX9030 */
+#define HFC_IO_MODE_EMBSD 0x03 /* direct access */
/* table entry in the PCI devices list */
struct hm_map {
@@ -111,6 +131,7 @@ struct hm_map {
int opticalsupport;
int dip_type;
int io_mode;
+ int irq;
};
struct hfc_multi {
@@ -118,7 +139,7 @@ struct hfc_multi {
struct hm_map *mtyp;
int id;
int pcm; /* id of pcm bus */
- int type;
+ int ctype; /* controller type */
int ports;
u_int irq; /* irq used by card */
@@ -158,10 +179,16 @@ struct hfc_multi {
int len);
void (*write_fifo)(struct hfc_multi *hc, u_char *data,
int len);
- u_long pci_origmembase, plx_origmembase, dsp_origmembase;
+ u_long pci_origmembase, plx_origmembase;
void __iomem *pci_membase; /* PCI memory */
void __iomem *plx_membase; /* PLX memory */
- u_char *dsp_membase; /* DSP on PLX */
+ u_long xhfc_origmembase;
+ u_char *xhfc_membase;
+ u_long *xhfc_memaddr, *xhfc_memdata;
+#ifdef CONFIG_MISDN_HFCMULTI_8xx
+ struct immap *immap;
+#endif
+ u_long pb_irqmsk; /* Portbit mask to check the IRQ line */
u_long pci_iobase; /* PCI IO */
struct hfcm_hw hw; /* remember data of write-only-registers */
diff --git a/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h b/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h
new file mode 100644
index 000000000000..45ddced956d5
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h
@@ -0,0 +1,167 @@
+/*
+ * For License see notice in hfc_multi.c
+ *
+ * special IO and init functions for the embedded XHFC board
+ * from Speech Design
+ *
+ */
+
+#include <asm/8xx_immap.h>
+
+/* Change this to the value used by your board */
+#ifndef IMAP_ADDR
+#define IMAP_ADDR 0xFFF00000
+#endif
+
+static void
+#ifdef HFC_REGISTER_DEBUG
+HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val,
+ const char *function, int line)
+#else
+HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val)
+#endif
+{
+ hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
+ writeb(reg, hc->xhfc_memaddr);
+ hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
+ writeb(val, hc->xhfc_memdata);
+}
+static u_char
+#ifdef HFC_REGISTER_DEBUG
+HFC_inb_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)
+#else
+HFC_inb_embsd(struct hfc_multi *hc, u_char reg)
+#endif
+{
+ hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
+ writeb(reg, hc->xhfc_memaddr);
+ hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
+ return readb(hc->xhfc_memdata);
+}
+static u_short
+#ifdef HFC_REGISTER_DEBUG
+HFC_inw_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)
+#else
+HFC_inw_embsd(struct hfc_multi *hc, u_char reg)
+#endif
+{
+ hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
+ writeb(reg, hc->xhfc_memaddr);
+ hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
+ return readb(hc->xhfc_memdata);
+}
+static void
+#ifdef HFC_REGISTER_DEBUG
+HFC_wait_embsd(struct hfc_multi *hc, const char *function, int line)
+#else
+HFC_wait_embsd(struct hfc_multi *hc)
+#endif
+{
+ hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
+ writeb(R_STATUS, hc->xhfc_memaddr);
+ hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
+ while (readb(hc->xhfc_memdata) & V_BUSY)
+ cpu_relax();
+}
+
+/* write fifo data (EMBSD) */
+void
+write_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)
+{
+ hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
+ *hc->xhfc_memaddr = A_FIFO_DATA0;
+ hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
+ while (len) {
+ *hc->xhfc_memdata = *data;
+ data++;
+ len--;
+ }
+}
+
+/* read fifo data (EMBSD) */
+void
+read_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)
+{
+ hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
+ *hc->xhfc_memaddr = A_FIFO_DATA0;
+ hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
+ while (len) {
+ *data = (u_char)(*hc->xhfc_memdata);
+ data++;
+ len--;
+ }
+}
+
+static int
+setup_embedded(struct hfc_multi *hc, struct hm_map *m)
+{
+ printk(KERN_INFO
+ "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n",
+ m->vendor_name, m->card_name, m->clock2 ? "double" : "normal");
+
+ hc->pci_dev = NULL;
+ if (m->clock2)
+ test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip);
+
+ hc->leds = m->leds;
+ hc->ledstate = 0xAFFEAFFE;
+ hc->opticalsupport = m->opticalsupport;
+
+ hc->pci_iobase = 0;
+ hc->pci_membase = 0;
+ hc->xhfc_membase = NULL;
+ hc->xhfc_memaddr = NULL;
+ hc->xhfc_memdata = NULL;
+
+ /* set memory access methods */
+ if (m->io_mode) /* use mode from card config */
+ hc->io_mode = m->io_mode;
+ switch (hc->io_mode) {
+ case HFC_IO_MODE_EMBSD:
+ test_and_set_bit(HFC_CHIP_EMBSD, &hc->chip);
+ hc->slots = 128; /* required */
+ /* fall through */
+ hc->HFC_outb = HFC_outb_embsd;
+ hc->HFC_inb = HFC_inb_embsd;
+ hc->HFC_inw = HFC_inw_embsd;
+ hc->HFC_wait = HFC_wait_embsd;
+ hc->read_fifo = read_fifo_embsd;
+ hc->write_fifo = write_fifo_embsd;
+ hc->xhfc_origmembase = XHFC_MEMBASE + XHFC_OFFSET * hc->id;
+ hc->xhfc_membase = (u_char *)ioremap(hc->xhfc_origmembase,
+ XHFC_MEMSIZE);
+ if (!hc->xhfc_membase) {
+ printk(KERN_WARNING
+ "HFC-multi: failed to remap xhfc address space. "
+ "(internal error)\n");
+ return -EIO;
+ }
+ hc->xhfc_memaddr = (u_long *)(hc->xhfc_membase + 4);
+ hc->xhfc_memdata = (u_long *)(hc->xhfc_membase);
+ printk(KERN_INFO
+ "HFC-multi: xhfc_membase:%#lx xhfc_origmembase:%#lx "
+ "xhfc_memaddr:%#lx xhfc_memdata:%#lx\n",
+ (u_long)hc->xhfc_membase, hc->xhfc_origmembase,
+ (u_long)hc->xhfc_memaddr, (u_long)hc->xhfc_memdata);
+ break;
+ default:
+ printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n");
+ return -EIO;
+ }
+
+ /* Prepare the MPC8XX PortA 10 as output (address/data selector) */
+ hc->immap = (struct immap *)(IMAP_ADDR);
+ hc->immap->im_ioport.iop_papar &= ~(PA_XHFC_A0);
+ hc->immap->im_ioport.iop_paodr &= ~(PA_XHFC_A0);
+ hc->immap->im_ioport.iop_padir |= PA_XHFC_A0;
+
+ /* Prepare the MPC8xx PortB __X__ as input (ISDN__X__IRQ) */
+ hc->pb_irqmsk = (PB_XHFC_IRQ1 << hc->id);
+ hc->immap->im_cpm.cp_pbpar &= ~(hc->pb_irqmsk);
+ hc->immap->im_cpm.cp_pbodr &= ~(hc->pb_irqmsk);
+ hc->immap->im_cpm.cp_pbdir &= ~(hc->pb_irqmsk);
+
+ /* At this point the needed config is done */
+ /* fifos are still not enabled */
+ return 0;
+}
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 0b28141e43bf..e1dab30aed30 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -104,7 +104,7 @@
* If unsure, don't give this parameter.
*
* dslot:
- * NOTE: only one poll value must be given for every card.
+ * NOTE: only one dslot value must be given for every card.
* Also this value must be given for non-E1 cards. If omitted, the E1
* card has D-channel on time slot 16, which is default.
* If 1..15 or 17..31, an alternate time slot is used for D-channel.
@@ -139,6 +139,10 @@
* Selects interface with clock source for mISDN and applications.
* Set to card number starting with 1. Set to -1 to disable.
* By default, the first card is used as clock source.
+ *
+ * hwid:
+ * NOTE: only one hwid value must be given once
+ * Enable special embedded devices with XHFC controllers.
*/
/*
@@ -206,6 +210,11 @@ static int clock;
static uint timer;
static uint clockdelay_te = CLKDEL_TE;
static uint clockdelay_nt = CLKDEL_NT;
+#define HWID_NONE 0
+#define HWID_MINIP4 1
+#define HWID_MINIP8 2
+#define HWID_MINIP16 3
+static uint hwid = HWID_NONE;
static int HFC_cnt, Port_cnt, PCM_cnt = 99;
@@ -223,6 +232,7 @@ module_param_array(pcm, int, NULL, S_IRUGO | S_IWUSR);
module_param_array(dslot, int, NULL, S_IRUGO | S_IWUSR);
module_param_array(iomode, uint, NULL, S_IRUGO | S_IWUSR);
module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR);
+module_param(hwid, uint, S_IRUGO | S_IWUSR); /* The hardware ID */
#ifdef HFC_REGISTER_DEBUG
#define HFC_outb(hc, reg, val) \
@@ -252,6 +262,10 @@ module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR);
#define HFC_wait_nodebug(hc) (hc->HFC_wait_nodebug(hc))
#endif
+#ifdef CONFIG_MISDN_HFCMULTI_8xx
+#include "hfc_multi_8xx.h"
+#endif
+
/* HFC_IO_MODE_PCIMEM */
static void
#ifdef HFC_REGISTER_DEBUG
@@ -261,7 +275,7 @@ HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val,
HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val)
#endif
{
- writeb(val, (hc->pci_membase)+reg);
+ writeb(val, hc->pci_membase + reg);
}
static u_char
#ifdef HFC_REGISTER_DEBUG
@@ -270,7 +284,7 @@ HFC_inb_pcimem(struct hfc_multi *hc, u_char reg, const char *function, int line)
HFC_inb_pcimem(struct hfc_multi *hc, u_char reg)
#endif
{
- return readb((hc->pci_membase)+reg);
+ return readb(hc->pci_membase + reg);
}
static u_short
#ifdef HFC_REGISTER_DEBUG
@@ -279,7 +293,7 @@ HFC_inw_pcimem(struct hfc_multi *hc, u_char reg, const char *function, int line)
HFC_inw_pcimem(struct hfc_multi *hc, u_char reg)
#endif
{
- return readw((hc->pci_membase)+reg);
+ return readw(hc->pci_membase + reg);
}
static void
#ifdef HFC_REGISTER_DEBUG
@@ -288,7 +302,8 @@ HFC_wait_pcimem(struct hfc_multi *hc, const char *function, int line)
HFC_wait_pcimem(struct hfc_multi *hc)
#endif
{
- while (readb((hc->pci_membase)+R_STATUS) & V_BUSY);
+ while (readb(hc->pci_membase + R_STATUS) & V_BUSY)
+ cpu_relax();
}
/* HFC_IO_MODE_REGIO */
@@ -300,7 +315,7 @@ HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val,
HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val)
#endif
{
- outb(reg, (hc->pci_iobase)+4);
+ outb(reg, hc->pci_iobase + 4);
outb(val, hc->pci_iobase);
}
static u_char
@@ -310,7 +325,7 @@ HFC_inb_regio(struct hfc_multi *hc, u_char reg, const char *function, int line)
HFC_inb_regio(struct hfc_multi *hc, u_char reg)
#endif
{
- outb(reg, (hc->pci_iobase)+4);
+ outb(reg, hc->pci_iobase + 4);
return inb(hc->pci_iobase);
}
static u_short
@@ -320,7 +335,7 @@ HFC_inw_regio(struct hfc_multi *hc, u_char reg, const char *function, int line)
HFC_inw_regio(struct hfc_multi *hc, u_char reg)
#endif
{
- outb(reg, (hc->pci_iobase)+4);
+ outb(reg, hc->pci_iobase + 4);
return inw(hc->pci_iobase);
}
static void
@@ -330,8 +345,9 @@ HFC_wait_regio(struct hfc_multi *hc, const char *function, int line)
HFC_wait_regio(struct hfc_multi *hc)
#endif
{
- outb(R_STATUS, (hc->pci_iobase)+4);
- while (inb(hc->pci_iobase) & V_BUSY);
+ outb(R_STATUS, hc->pci_iobase + 4);
+ while (inb(hc->pci_iobase) & V_BUSY)
+ cpu_relax();
}
#ifdef HFC_REGISTER_DEBUG
@@ -350,14 +366,14 @@ HFC_outb_debug(struct hfc_multi *hc, u_char reg, u_char val,
if (regname[0] == '\0')
strcpy(regname, "register");
- bits[7] = '0'+(!!(val&1));
- bits[6] = '0'+(!!(val&2));
- bits[5] = '0'+(!!(val&4));
- bits[4] = '0'+(!!(val&8));
- bits[3] = '0'+(!!(val&16));
- bits[2] = '0'+(!!(val&32));
- bits[1] = '0'+(!!(val&64));
- bits[0] = '0'+(!!(val&128));
+ bits[7] = '0' + (!!(val & 1));
+ bits[6] = '0' + (!!(val & 2));
+ bits[5] = '0' + (!!(val & 4));
+ bits[4] = '0' + (!!(val & 8));
+ bits[3] = '0' + (!!(val & 16));
+ bits[2] = '0' + (!!(val & 32));
+ bits[1] = '0' + (!!(val & 64));
+ bits[0] = '0' + (!!(val & 128));
printk(KERN_DEBUG
"HFC_outb(chip %d, %02x=%s, 0x%02x=%s); in %s() line %d\n",
hc->id, reg, regname, val, bits, function, line);
@@ -380,14 +396,14 @@ HFC_inb_debug(struct hfc_multi *hc, u_char reg, const char *function, int line)
if (regname[0] == '\0')
strcpy(regname, "register");
- bits[7] = '0'+(!!(val&1));
- bits[6] = '0'+(!!(val&2));
- bits[5] = '0'+(!!(val&4));
- bits[4] = '0'+(!!(val&8));
- bits[3] = '0'+(!!(val&16));
- bits[2] = '0'+(!!(val&32));
- bits[1] = '0'+(!!(val&64));
- bits[0] = '0'+(!!(val&128));
+ bits[7] = '0' + (!!(val & 1));
+ bits[6] = '0' + (!!(val & 2));
+ bits[5] = '0' + (!!(val & 4));
+ bits[4] = '0' + (!!(val & 8));
+ bits[3] = '0' + (!!(val & 16));
+ bits[2] = '0' + (!!(val & 32));
+ bits[1] = '0' + (!!(val & 64));
+ bits[0] = '0' + (!!(val & 128));
printk(KERN_DEBUG
"HFC_inb(chip %d, %02x=%s) = 0x%02x=%s; in %s() line %d\n",
hc->id, reg, regname, val, bits, function, line);
@@ -467,6 +483,7 @@ write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
len--;
}
}
+
/* read fifo data (REGIO) */
static void
read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
@@ -512,7 +529,6 @@ read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
}
}
-
static void
enable_hwirq(struct hfc_multi *hc)
{
@@ -928,7 +944,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
writel(pv, plx_acc_32);
if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) {
pcmmaster = hc;
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
if (debug & DEBUG_HFCMULTI_PLXSD)
printk(KERN_DEBUG
"Schedule SYNC_I\n");
@@ -949,7 +965,8 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
pv |= PLX_SYNC_O_EN;
writel(pv, plx_acc_32);
/* switch to jatt PLL, if not disabled by RX_SYNC */
- if (hc->type == 1 && !test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) {
+ if (hc->ctype == HFC_TYPE_E1
+ && !test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) {
if (debug & DEBUG_HFCMULTI_PLXSD)
printk(KERN_DEBUG "Schedule jatt PLL\n");
hc->e1_resync |= 2; /* switch to jatt */
@@ -961,7 +978,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
printk(KERN_DEBUG
"id=%d (0x%p) = PCM master syncronized "
"with QUARTZ\n", hc->id, hc);
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
/* Use the crystal clock for the PCM
master card */
if (debug & DEBUG_HFCMULTI_PLXSD)
@@ -972,7 +989,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
if (debug & DEBUG_HFCMULTI_PLXSD)
printk(KERN_DEBUG
"QUARTZ is automatically "
- "enabled by HFC-%dS\n", hc->type);
+ "enabled by HFC-%dS\n", hc->ctype);
}
plx_acc_32 = hc->plx_membase + PLX_GPIOC;
pv = readl(plx_acc_32);
@@ -996,7 +1013,7 @@ plxsd_checksync(struct hfc_multi *hc, int rm)
if (hc->syncronized) {
if (syncmaster == NULL) {
if (debug & DEBUG_HFCMULTI_PLXSD)
- printk(KERN_WARNING "%s: GOT sync on card %d"
+ printk(KERN_DEBUG "%s: GOT sync on card %d"
" (id=%d)\n", __func__, hc->id + 1,
hc->id);
hfcmulti_resync(hc, hc, rm);
@@ -1004,7 +1021,7 @@ plxsd_checksync(struct hfc_multi *hc, int rm)
} else {
if (syncmaster == hc) {
if (debug & DEBUG_HFCMULTI_PLXSD)
- printk(KERN_WARNING "%s: LOST sync on card %d"
+ printk(KERN_DEBUG "%s: LOST sync on card %d"
" (id=%d)\n", __func__, hc->id + 1,
hc->id);
hfcmulti_resync(hc, NULL, rm);
@@ -1053,20 +1070,23 @@ release_io_hfcmulti(struct hfc_multi *hc)
pv &= ~PLX_DSP_RES_N;
writel(pv, plx_acc_32);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: PCM off: PLX_GPIO=%x\n",
+ printk(KERN_DEBUG "%s: PCM off: PLX_GPIO=%x\n",
__func__, pv);
spin_unlock_irqrestore(&plx_lock, plx_flags);
}
/* disable memory mapped ports / io ports */
test_and_clear_bit(HFC_CHIP_PLXSD, &hc->chip); /* prevent resync */
- pci_write_config_word(hc->pci_dev, PCI_COMMAND, 0);
+ if (hc->pci_dev)
+ pci_write_config_word(hc->pci_dev, PCI_COMMAND, 0);
if (hc->pci_membase)
iounmap(hc->pci_membase);
if (hc->plx_membase)
iounmap(hc->plx_membase);
if (hc->pci_iobase)
release_region(hc->pci_iobase, 8);
+ if (hc->xhfc_membase)
+ iounmap((void *)hc->xhfc_membase);
if (hc->pci_dev) {
pci_disable_device(hc->pci_dev);
@@ -1100,8 +1120,9 @@ init_chip(struct hfc_multi *hc)
/* revision check */
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG "%s: entered\n", __func__);
- val = HFC_inb(hc, R_CHIP_ID)>>4;
- if (val != 0x8 && val != 0xc && val != 0xe) {
+ val = HFC_inb(hc, R_CHIP_ID);
+ if ((val >> 4) != 0x8 && (val >> 4) != 0xc && (val >> 4) != 0xe &&
+ (val >> 1) != 0x31) {
printk(KERN_INFO "HFC_multi: unknown CHIP_ID:%x\n", (u_int)val);
err = -EIO;
goto out;
@@ -1109,8 +1130,9 @@ init_chip(struct hfc_multi *hc)
rev = HFC_inb(hc, R_CHIP_RV);
printk(KERN_INFO
"HFC_multi: detected HFC with chip ID=0x%lx revision=%ld%s\n",
- val, rev, (rev == 0) ? " (old FIFO handling)" : "");
- if (rev == 0) {
+ val, rev, (rev == 0 && (hc->ctype != HFC_TYPE_XHFC)) ?
+ " (old FIFO handling)" : "");
+ if (hc->ctype != HFC_TYPE_XHFC && rev == 0) {
test_and_set_bit(HFC_CHIP_REVISION0, &hc->chip);
printk(KERN_WARNING
"HFC_multi: NOTE: Your chip is revision 0, "
@@ -1152,6 +1174,12 @@ init_chip(struct hfc_multi *hc)
hc->Zlen = 8000;
hc->DTMFbase = 0x2000;
}
+ if (hc->ctype == HFC_TYPE_XHFC) {
+ hc->Flen = 0x8;
+ hc->Zmin = 0x0;
+ hc->Zlen = 64;
+ hc->DTMFbase = 0x0;
+ }
hc->max_trans = poll << 1;
if (hc->max_trans > hc->Zlen)
hc->max_trans = hc->Zlen;
@@ -1176,7 +1204,7 @@ init_chip(struct hfc_multi *hc)
writel(pv, plx_acc_32);
spin_unlock_irqrestore(&plx_lock, plx_flags);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: slave/term: PLX_GPIO=%x\n",
+ printk(KERN_DEBUG "%s: slave/term: PLX_GPIO=%x\n",
__func__, pv);
/*
* If we are the 3rd PLXSD card or higher, we must turn
@@ -1204,13 +1232,17 @@ init_chip(struct hfc_multi *hc)
writel(pv, plx_acc_32);
spin_unlock_irqrestore(&plx_lock, plx_flags);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: term off: PLX_GPIO=%x\n",
- __func__, pv);
+ printk(KERN_DEBUG
+ "%s: term off: PLX_GPIO=%x\n",
+ __func__, pv);
}
spin_unlock_irqrestore(&HFClock, hfc_flags);
hc->hw.r_pcm_md0 = V_F0_LEN; /* shift clock for DSP */
}
+ if (test_bit(HFC_CHIP_EMBSD, &hc->chip))
+ hc->hw.r_pcm_md0 = V_F0_LEN; /* shift clock for DSP */
+
/* we only want the real Z2 read-pointer for revision > 0 */
if (!test_bit(HFC_CHIP_REVISION0, &hc->chip))
hc->hw.r_ram_sz |= V_FZ_MD;
@@ -1234,15 +1266,24 @@ init_chip(struct hfc_multi *hc)
/* soft reset */
HFC_outb(hc, R_CTRL, hc->hw.r_ctrl);
- HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, 0x0C /* R_FIFO_THRES */,
+ 0x11 /* 16 Bytes TX/RX */);
+ else
+ HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz);
HFC_outb(hc, R_FIFO_MD, 0);
- hc->hw.r_cirm = V_SRES | V_HFCRES | V_PCMRES | V_STRES | V_RLD_EPR;
+ if (hc->ctype == HFC_TYPE_XHFC)
+ hc->hw.r_cirm = V_SRES | V_HFCRES | V_PCMRES | V_STRES;
+ else
+ hc->hw.r_cirm = V_SRES | V_HFCRES | V_PCMRES | V_STRES
+ | V_RLD_EPR;
HFC_outb(hc, R_CIRM, hc->hw.r_cirm);
udelay(100);
hc->hw.r_cirm = 0;
HFC_outb(hc, R_CIRM, hc->hw.r_cirm);
udelay(100);
- HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz);
+ if (hc->ctype != HFC_TYPE_XHFC)
+ HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz);
/* Speech Design PLX bridge pcm and sync mode */
if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
@@ -1254,13 +1295,13 @@ init_chip(struct hfc_multi *hc)
pv |= PLX_MASTER_EN | PLX_SLAVE_EN_N;
pv |= PLX_SYNC_O_EN;
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: master: PLX_GPIO=%x\n",
+ printk(KERN_DEBUG "%s: master: PLX_GPIO=%x\n",
__func__, pv);
} else {
pv &= ~(PLX_MASTER_EN | PLX_SLAVE_EN_N);
pv &= ~PLX_SYNC_O_EN;
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: slave: PLX_GPIO=%x\n",
+ printk(KERN_DEBUG "%s: slave: PLX_GPIO=%x\n",
__func__, pv);
}
writel(pv, plx_acc_32);
@@ -1278,13 +1319,16 @@ init_chip(struct hfc_multi *hc)
HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0xa0);
if (test_bit(HFC_CHIP_PLXSD, &hc->chip))
HFC_outb(hc, R_PCM_MD2, V_SYNC_SRC); /* sync via SYNC_I / O */
+ else if (test_bit(HFC_CHIP_EMBSD, &hc->chip))
+ HFC_outb(hc, R_PCM_MD2, 0x10); /* V_C2O_EN */
else
HFC_outb(hc, R_PCM_MD2, 0x00); /* sync from interface */
HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00);
for (i = 0; i < 256; i++) {
HFC_outb_nodebug(hc, R_SLOT, i);
HFC_outb_nodebug(hc, A_SL_CFG, 0);
- HFC_outb_nodebug(hc, A_CONF, 0);
+ if (hc->ctype != HFC_TYPE_XHFC)
+ HFC_outb_nodebug(hc, A_CONF, 0);
hc->slot_owner[i] = -1;
}
@@ -1296,6 +1340,9 @@ init_chip(struct hfc_multi *hc)
HFC_outb(hc, R_BRG_PCM_CFG, V_PCM_CLK);
}
+ if (test_bit(HFC_CHIP_EMBSD, &hc->chip))
+ HFC_outb(hc, 0x02 /* R_CLK_CFG */, 0x40 /* V_CLKO_OFF */);
+
/* B410P GPIO */
if (test_bit(HFC_CHIP_B410P, &hc->chip)) {
printk(KERN_NOTICE "Setting GPIOs\n");
@@ -1366,8 +1413,8 @@ controller_fail:
writel(pv, plx_acc_32);
spin_unlock_irqrestore(&plx_lock, plx_flags);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: master: PLX_GPIO"
- "=%x\n", __func__, pv);
+ printk(KERN_DEBUG "%s: master: "
+ "PLX_GPIO=%x\n", __func__, pv);
}
hc->hw.r_pcm_md0 |= V_PCM_MD;
HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00);
@@ -1401,7 +1448,7 @@ controller_fail:
writel(pv, plx_acc_32);
spin_unlock_irqrestore(&plx_lock, plx_flags);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: reset off: PLX_GPIO=%x\n",
+ printk(KERN_DEBUG "%s: reset off: PLX_GPIO=%x\n",
__func__, pv);
}
@@ -1424,7 +1471,7 @@ controller_fail:
hc->hw.r_irqmsk_misc |= V_TI_IRQMSK;
/* set E1 state machine IRQ */
- if (hc->type == 1)
+ if (hc->ctype == HFC_TYPE_E1)
hc->hw.r_irqmsk_misc |= V_STA_IRQMSK;
/* set DTMF detection */
@@ -1444,7 +1491,8 @@ controller_fail:
r_conf_en = V_CONF_EN | V_ULAW;
else
r_conf_en = V_CONF_EN;
- HFC_outb(hc, R_CONF_EN, r_conf_en);
+ if (hc->ctype != HFC_TYPE_XHFC)
+ HFC_outb(hc, R_CONF_EN, r_conf_en);
/* setting leds */
switch (hc->leds) {
@@ -1468,16 +1516,23 @@ controller_fail:
break;
}
+ if (test_bit(HFC_CHIP_EMBSD, &hc->chip)) {
+ hc->hw.r_st_sync = 0x10; /* V_AUTO_SYNCI */
+ HFC_outb(hc, R_ST_SYNC, hc->hw.r_st_sync);
+ }
+
/* set master clock */
if (hc->masterclk >= 0) {
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG "%s: setting ST master clock "
"to port %d (0..%d)\n",
__func__, hc->masterclk, hc->ports-1);
- hc->hw.r_st_sync = hc->masterclk | V_AUTO_SYNC;
+ hc->hw.r_st_sync |= (hc->masterclk | V_AUTO_SYNC);
HFC_outb(hc, R_ST_SYNC, hc->hw.r_st_sync);
}
+
+
/* setting misc irq */
HFC_outb(hc, R_IRQMSK_MISC, hc->hw.r_irqmsk_misc);
if (debug & DEBUG_HFCMULTI_INIT)
@@ -1817,8 +1872,8 @@ hfcmulti_dtmf(struct hfc_multi *hc)
coeff[(co<<1)|1] = mantissa;
}
if (debug & DEBUG_HFCMULTI_DTMF)
- printk("%s: DTMF ready %08x %08x %08x %08x "
- "%08x %08x %08x %08x\n", __func__,
+ printk(" DTMF ready %08x %08x %08x %08x "
+ "%08x %08x %08x %08x\n",
coeff[0], coeff[1], coeff[2], coeff[3],
coeff[4], coeff[5], coeff[6], coeff[7]);
hc->chan[ch].coeff_count++;
@@ -1826,7 +1881,7 @@ hfcmulti_dtmf(struct hfc_multi *hc)
hc->chan[ch].coeff_count = 0;
skb = mI_alloc_skb(512, GFP_ATOMIC);
if (!skb) {
- printk(KERN_WARNING "%s: No memory for skb\n",
+ printk(KERN_DEBUG "%s: No memory for skb\n",
__func__);
continue;
}
@@ -1929,7 +1984,7 @@ next_frame:
Fspace = 1;
}
/* one frame only for ST D-channels, to allow resending */
- if (hc->type != 1 && dch) {
+ if (hc->ctype != HFC_TYPE_E1 && dch) {
if (f1 != f2)
Fspace = 0;
}
@@ -1945,6 +2000,9 @@ next_frame:
"%d!=%d\n", __func__, hc->id + 1, temp, z2);
z2 = temp; /* repeat unti Z2 is equal */
}
+ hc->chan[ch].Zfill = z1 - z2;
+ if (hc->chan[ch].Zfill < 0)
+ hc->chan[ch].Zfill += hc->Zlen;
Zspace = z2 - z1;
if (Zspace <= 0)
Zspace += hc->Zlen;
@@ -1968,12 +2026,22 @@ next_frame:
"slot_tx %d\n",
__func__, ch, slot_tx);
/* connect slot */
- HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 |
- V_HDLC_TRP | V_IFF);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CON_HDLC, 0xc0
+ | 0x07 << 2 | V_HDLC_TRP | V_IFF);
+ /* Enable FIFO, no interrupt */
+ else
+ HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 |
+ V_HDLC_TRP | V_IFF);
HFC_outb_nodebug(hc, R_FIFO, ch<<1 | 1);
HFC_wait_nodebug(hc);
- HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 |
- V_HDLC_TRP | V_IFF);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CON_HDLC, 0xc0
+ | 0x07 << 2 | V_HDLC_TRP | V_IFF);
+ /* Enable FIFO, no interrupt */
+ else
+ HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 |
+ V_HDLC_TRP | V_IFF);
HFC_outb_nodebug(hc, R_FIFO, ch<<1);
HFC_wait_nodebug(hc);
}
@@ -2001,10 +2069,22 @@ next_frame:
"FIFO data: channel %d slot_tx %d\n",
__func__, ch, slot_tx);
/* disconnect slot */
- HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 | V_HDLC_TRP | V_IFF);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CON_HDLC, 0x80
+ | 0x07 << 2 | V_HDLC_TRP | V_IFF);
+ /* Enable FIFO, no interrupt */
+ else
+ HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 |
+ V_HDLC_TRP | V_IFF);
HFC_outb_nodebug(hc, R_FIFO, ch<<1 | 1);
HFC_wait_nodebug(hc);
- HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 | V_HDLC_TRP | V_IFF);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CON_HDLC, 0x80
+ | 0x07 << 2 | V_HDLC_TRP | V_IFF);
+ /* Enable FIFO, no interrupt */
+ else
+ HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 |
+ V_HDLC_TRP | V_IFF);
HFC_outb_nodebug(hc, R_FIFO, ch<<1);
HFC_wait_nodebug(hc);
}
@@ -2027,10 +2107,11 @@ next_frame:
printk(KERN_DEBUG "%s(card %d): fifo(%d) has %d bytes space "
"left (z1=%04x, z2=%04x) sending %d of %d bytes %s\n",
__func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i,
- temp ? "HDLC":"TRANS");
+ temp ? "HDLC" : "TRANS");
/* Have to prep the audio data */
hc->write_fifo(hc, d, ii - i);
+ hc->chan[ch].Zfill += ii - i;
*idxp = ii;
/* if not all data has been written */
@@ -2226,7 +2307,7 @@ next_frame:
if (dch)
recv_Dchannel(dch);
else
- recv_Bchannel(bch);
+ recv_Bchannel(bch, MISDN_ID_ANY);
*sp = skb;
again++;
goto next_frame;
@@ -2258,7 +2339,7 @@ next_frame:
"(z1=%04x, z2=%04x) TRANS\n",
__func__, hc->id + 1, ch, Zsize, z1, z2);
/* only bch is transparent */
- recv_Bchannel(bch);
+ recv_Bchannel(bch, hc->chan[ch].Zfill);
*sp = skb;
}
}
@@ -2323,7 +2404,7 @@ handle_timer_irq(struct hfc_multi *hc)
spin_unlock_irqrestore(&HFClock, flags);
}
- if (hc->type != 1 || hc->e1_state == 1)
+ if (hc->ctype != HFC_TYPE_E1 || hc->e1_state == 1)
for (ch = 0; ch <= 31; ch++) {
if (hc->created[hc->chan[ch].port]) {
hfcmulti_tx(hc, ch);
@@ -2346,7 +2427,7 @@ handle_timer_irq(struct hfc_multi *hc)
}
}
}
- if (hc->type == 1 && hc->created[0]) {
+ if (hc->ctype == HFC_TYPE_E1 && hc->created[0]) {
dch = hc->chan[hc->dslot].dch;
if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
/* LOS */
@@ -2606,7 +2687,10 @@ hfcmulti_interrupt(int intno, void *dev_id)
"card %d, this is no bug.\n", hc->id + 1, irqsem);
irqsem = hc->id + 1;
#endif
-
+#ifdef CONFIG_MISDN_HFCMULTI_8xx
+ if (hc->immap->im_cpm.cp_pbdat & hc->pb_irqmsk)
+ goto irq_notforus;
+#endif
if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
spin_lock_irqsave(&plx_lock, flags);
plx_acc = hc->plx_membase + PLX_INTCSR;
@@ -2646,7 +2730,7 @@ hfcmulti_interrupt(int intno, void *dev_id)
}
hc->irqcnt++;
if (r_irq_statech) {
- if (hc->type != 1)
+ if (hc->ctype != HFC_TYPE_E1)
ph_state_irq(hc, r_irq_statech);
}
if (status & V_EXT_IRQSTA)
@@ -2660,7 +2744,7 @@ hfcmulti_interrupt(int intno, void *dev_id)
r_irq_misc = HFC_inb_nodebug(hc, R_IRQ_MISC);
r_irq_misc &= hc->hw.r_irqmsk_misc; /* ignore disabled irqs */
if (r_irq_misc & V_STA_IRQ) {
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
/* state machine */
dch = hc->chan[hc->dslot].dch;
e1_syncsta = HFC_inb_nodebug(hc, R_SYNC_STA);
@@ -2699,13 +2783,13 @@ hfcmulti_interrupt(int intno, void *dev_id)
handle_timer_irq(hc);
}
- if (r_irq_misc & V_DTMF_IRQ) {
+ if (r_irq_misc & V_DTMF_IRQ)
hfcmulti_dtmf(hc);
- }
+
if (r_irq_misc & V_IRQ_PROC) {
static int irq_proc_cnt;
if (!irq_proc_cnt++)
- printk(KERN_WARNING "%s: got V_IRQ_PROC -"
+ printk(KERN_DEBUG "%s: got V_IRQ_PROC -"
" this should not happen\n", __func__);
}
@@ -2782,7 +2866,8 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
if (hc->slot_owner[oslot_tx<<1] == ch) {
HFC_outb(hc, R_SLOT, oslot_tx << 1);
HFC_outb(hc, A_SL_CFG, 0);
- HFC_outb(hc, A_CONF, 0);
+ if (hc->ctype != HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CONF, 0);
hc->slot_owner[oslot_tx<<1] = -1;
} else {
if (debug & DEBUG_HFCMULTI_MODE)
@@ -2835,7 +2920,9 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
flow_tx, routing, conf);
HFC_outb(hc, R_SLOT, slot_tx << 1);
HFC_outb(hc, A_SL_CFG, (ch<<1) | routing);
- HFC_outb(hc, A_CONF, (conf < 0) ? 0 : (conf | V_CONF_SL));
+ if (hc->ctype != HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CONF,
+ (conf < 0) ? 0 : (conf | V_CONF_SL));
hc->slot_owner[slot_tx << 1] = ch;
hc->chan[ch].slot_tx = slot_tx;
hc->chan[ch].bank_tx = bank_tx;
@@ -2852,7 +2939,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
else
flow_rx = 0xc0; /* ST->(FIFO,PCM) */
/* put on slot */
- routing = bank_rx?0x80:0xc0; /* reversed */
+ routing = bank_rx ? 0x80 : 0xc0; /* reversed */
if (conf >= 0 || bank_rx > 1)
routing = 0x40; /* loop */
if (debug & DEBUG_HFCMULTI_MODE)
@@ -2885,9 +2972,9 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
HFC_outb(hc, A_IRQ_MSK, 0);
HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
HFC_wait(hc);
- if (hc->chan[ch].bch && hc->type != 1) {
+ if (hc->chan[ch].bch && hc->ctype != HFC_TYPE_E1) {
hc->hw.a_st_ctrl0[hc->chan[ch].port] &=
- ((ch & 0x3) == 0)? ~V_B1_EN: ~V_B2_EN;
+ ((ch & 0x3) == 0) ? ~V_B1_EN : ~V_B2_EN;
HFC_outb(hc, R_ST_SEL, hc->chan[ch].port);
/* undocumented: delay after R_ST_SEL */
udelay(1);
@@ -2961,8 +3048,13 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
/* enable TX fifo */
HFC_outb(hc, R_FIFO, ch << 1);
HFC_wait(hc);
- HFC_outb(hc, A_CON_HDLC, flow_tx | 0x00 |
- V_HDLC_TRP | V_IFF);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CON_HDLC, flow_tx | 0x07 << 2 |
+ V_HDLC_TRP | V_IFF);
+ /* Enable FIFO, no interrupt */
+ else
+ HFC_outb(hc, A_CON_HDLC, flow_tx | 0x00 |
+ V_HDLC_TRP | V_IFF);
HFC_outb(hc, A_SUBCH_CFG, 0);
HFC_outb(hc, A_IRQ_MSK, 0);
HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
@@ -2972,13 +3064,19 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
/* enable RX fifo */
HFC_outb(hc, R_FIFO, (ch<<1)|1);
HFC_wait(hc);
- HFC_outb(hc, A_CON_HDLC, flow_rx | 0x00 | V_HDLC_TRP);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ HFC_outb(hc, A_CON_HDLC, flow_rx | 0x07 << 2 |
+ V_HDLC_TRP);
+ /* Enable FIFO, no interrupt*/
+ else
+ HFC_outb(hc, A_CON_HDLC, flow_rx | 0x00 |
+ V_HDLC_TRP);
HFC_outb(hc, A_SUBCH_CFG, 0);
HFC_outb(hc, A_IRQ_MSK, 0);
HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
HFC_wait(hc);
}
- if (hc->type != 1) {
+ if (hc->ctype != HFC_TYPE_E1) {
hc->hw.a_st_ctrl0[hc->chan[ch].port] |=
((ch & 0x3) == 0) ? V_B1_EN : V_B2_EN;
HFC_outb(hc, R_ST_SEL, hc->chan[ch].port);
@@ -2999,7 +3097,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
/* enable TX fifo */
HFC_outb(hc, R_FIFO, ch<<1);
HFC_wait(hc);
- if (hc->type == 1 || hc->chan[ch].bch) {
+ if (hc->ctype == HFC_TYPE_E1 || hc->chan[ch].bch) {
/* E1 or B-channel */
HFC_outb(hc, A_CON_HDLC, flow_tx | 0x04);
HFC_outb(hc, A_SUBCH_CFG, 0);
@@ -3015,7 +3113,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
HFC_outb(hc, R_FIFO, (ch<<1)|1);
HFC_wait(hc);
HFC_outb(hc, A_CON_HDLC, flow_rx | 0x04);
- if (hc->type == 1 || hc->chan[ch].bch)
+ if (hc->ctype == HFC_TYPE_E1 || hc->chan[ch].bch)
HFC_outb(hc, A_SUBCH_CFG, 0); /* full 8 bits */
else
HFC_outb(hc, A_SUBCH_CFG, 2); /* 2 bits dchannel */
@@ -3024,7 +3122,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
HFC_wait(hc);
if (hc->chan[ch].bch) {
test_and_set_bit(FLG_HDLC, &hc->chan[ch].bch->Flags);
- if (hc->type != 1) {
+ if (hc->ctype != HFC_TYPE_E1) {
hc->hw.a_st_ctrl0[hc->chan[ch].port] |=
((ch&0x3) == 0) ? V_B1_EN : V_B2_EN;
HFC_outb(hc, R_ST_SEL, hc->chan[ch].port);
@@ -3104,7 +3202,7 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)
case HW_RESET_REQ:
/* start activation */
spin_lock_irqsave(&hc->lock, flags);
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
if (debug & DEBUG_HFCMULTI_MSG)
printk(KERN_DEBUG
"%s: HW_RESET_REQ no BRI\n",
@@ -3125,7 +3223,7 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)
case HW_DEACT_REQ:
/* start deactivation */
spin_lock_irqsave(&hc->lock, flags);
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
if (debug & DEBUG_HFCMULTI_MSG)
printk(KERN_DEBUG
"%s: HW_DEACT_REQ no BRI\n",
@@ -3159,7 +3257,7 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd)
break;
case HW_POWERUP_REQ:
spin_lock_irqsave(&hc->lock, flags);
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
if (debug & DEBUG_HFCMULTI_MSG)
printk(KERN_DEBUG
"%s: HW_POWERUP_REQ no BRI\n",
@@ -3236,7 +3334,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
__func__, hc->chan[dch->slot].port,
hc->ports-1);
/* start activation */
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
ph_state_change(dch);
if (debug & DEBUG_HFCMULTI_STATE)
printk(KERN_DEBUG
@@ -3269,7 +3367,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
__func__, hc->chan[dch->slot].port,
hc->ports-1);
/* start deactivation */
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
if (debug & DEBUG_HFCMULTI_MSG)
printk(KERN_DEBUG
"%s: PH_DEACTIVATE no BRI\n",
@@ -3410,9 +3508,9 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
switch (hh->id) {
case HFC_SPL_LOOP_ON: /* set sample loop */
if (debug & DEBUG_HFCMULTI_MSG)
- printk(KERN_DEBUG
- "%s: HFC_SPL_LOOP_ON (len = %d)\n",
- __func__, skb->len);
+ printk(KERN_DEBUG
+ "%s: HFC_SPL_LOOP_ON (len = %d)\n",
+ __func__, skb->len);
ret = 0;
break;
case HFC_SPL_LOOP_OFF: /* set silence */
@@ -3489,6 +3587,8 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
features->hfc_id = hc->id;
if (test_bit(HFC_CHIP_DTMF, &hc->chip))
features->hfc_dtmf = 1;
+ if (test_bit(HFC_CHIP_CONF, &hc->chip))
+ features->hfc_conf = 1;
features->hfc_loops = 0;
if (test_bit(HFC_CHIP_B410P, &hc->chip)) {
features->hfc_echocanhw = 1;
@@ -3619,14 +3719,13 @@ ph_state_change(struct dchannel *dch)
int ch, i;
if (!dch) {
- printk(KERN_WARNING "%s: ERROR given dch is NULL\n",
- __func__);
+ printk(KERN_WARNING "%s: ERROR given dch is NULL\n", __func__);
return;
}
hc = dch->hw;
ch = dch->slot;
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
if (dch->dev.D.protocol == ISDN_P_TE_E1) {
if (debug & DEBUG_HFCMULTI_STATE)
printk(KERN_DEBUG
@@ -3641,14 +3740,15 @@ ph_state_change(struct dchannel *dch)
switch (dch->state) {
case (1):
if (hc->e1_state != 1) {
- for (i = 1; i <= 31; i++) {
- /* reset fifos on e1 activation */
- HFC_outb_nodebug(hc, R_FIFO, (i << 1) | 1);
- HFC_wait_nodebug(hc);
- HFC_outb_nodebug(hc,
- R_INC_RES_FIFO, V_RES_F);
- HFC_wait_nodebug(hc);
- }
+ for (i = 1; i <= 31; i++) {
+ /* reset fifos on e1 activation */
+ HFC_outb_nodebug(hc, R_FIFO,
+ (i << 1) | 1);
+ HFC_wait_nodebug(hc);
+ HFC_outb_nodebug(hc, R_INC_RES_FIFO,
+ V_RES_F);
+ HFC_wait_nodebug(hc);
+ }
}
test_and_set_bit(FLG_ACTIVE, &dch->Flags);
_queue_data(&dch->dev.D, PH_ACTIVATE_IND,
@@ -3751,7 +3851,7 @@ hfcmulti_initmode(struct dchannel *dch)
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG "%s: entered\n", __func__);
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
hc->chan[hc->dslot].slot_tx = -1;
hc->chan[hc->dslot].slot_rx = -1;
hc->chan[hc->dslot].conf = -1;
@@ -3900,6 +4000,11 @@ hfcmulti_initmode(struct dchannel *dch)
}
if (!test_bit(HFC_CFG_NONCAP_TX, &hc->chan[i].cfg))
hc->hw.a_st_ctrl0[pt] |= V_TX_LI;
+ if (hc->ctype == HFC_TYPE_XHFC) {
+ hc->hw.a_st_ctrl0[pt] |= 0x40 /* V_ST_PU_CTRL */;
+ HFC_outb(hc, 0x35 /* A_ST_CTRL3 */,
+ 0x7c << 1 /* V_ST_PULSE */);
+ }
/* line setup */
HFC_outb(hc, A_ST_CTRL0, hc->hw.a_st_ctrl0[pt]);
/* disable E-channel */
@@ -3943,12 +4048,12 @@ open_dchannel(struct hfc_multi *hc, struct dchannel *dch,
return -EINVAL;
if ((dch->dev.D.protocol != ISDN_P_NONE) &&
(dch->dev.D.protocol != rq->protocol)) {
- if (debug & DEBUG_HFCMULTI_MODE)
- printk(KERN_WARNING "%s: change protocol %x to %x\n",
- __func__, dch->dev.D.protocol, rq->protocol);
+ if (debug & DEBUG_HFCMULTI_MODE)
+ printk(KERN_DEBUG "%s: change protocol %x to %x\n",
+ __func__, dch->dev.D.protocol, rq->protocol);
}
- if ((dch->dev.D.protocol == ISDN_P_TE_S0)
- && (rq->protocol != ISDN_P_TE_S0))
+ if ((dch->dev.D.protocol == ISDN_P_TE_S0) &&
+ (rq->protocol != ISDN_P_TE_S0))
l1_event(dch->l1, CLOSE_CHANNEL);
if (dch->dev.D.protocol != rq->protocol) {
if (rq->protocol == ISDN_P_TE_S0) {
@@ -3986,7 +4091,7 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
return -EINVAL;
if (rq->protocol == ISDN_P_NONE)
return -EINVAL;
- if (hc->type == 1)
+ if (hc->ctype == HFC_TYPE_E1)
ch = rq->adr.channel;
else
ch = (rq->adr.channel - 1) + (dch->slot - 2);
@@ -4013,11 +4118,41 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
static int
channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq)
{
+ struct hfc_multi *hc = dch->hw;
int ret = 0;
+ int wd_mode, wd_cnt;
switch (cq->op) {
case MISDN_CTRL_GETOP:
- cq->op = 0;
+ cq->op = MISDN_CTRL_HFC_OP;
+ break;
+ case MISDN_CTRL_HFC_WD_INIT: /* init the watchdog */
+ wd_cnt = cq->p1 & 0xf;
+ wd_mode = !!(cq->p1 >> 4);
+ if (debug & DEBUG_HFCMULTI_MSG)
+ printk(KERN_DEBUG "%s: MISDN_CTRL_HFC_WD_INIT mode %s"
+ ", counter 0x%x\n", __func__,
+ wd_mode ? "AUTO" : "MANUAL", wd_cnt);
+ /* set the watchdog timer */
+ HFC_outb(hc, R_TI_WD, poll_timer | (wd_cnt << 4));
+ hc->hw.r_bert_wd_md = (wd_mode ? V_AUTO_WD_RES : 0);
+ if (hc->ctype == HFC_TYPE_XHFC)
+ hc->hw.r_bert_wd_md |= 0x40 /* V_WD_EN */;
+ /* init the watchdog register and reset the counter */
+ HFC_outb(hc, R_BERT_WD_MD, hc->hw.r_bert_wd_md | V_WD_RES);
+ if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
+ /* enable the watchdog output for Speech-Design */
+ HFC_outb(hc, R_GPIO_SEL, V_GPIO_SEL7);
+ HFC_outb(hc, R_GPIO_EN1, V_GPIO_EN15);
+ HFC_outb(hc, R_GPIO_OUT1, 0);
+ HFC_outb(hc, R_GPIO_OUT1, V_GPIO_OUT15);
+ }
+ break;
+ case MISDN_CTRL_HFC_WD_RESET: /* reset the watchdog counter */
+ if (debug & DEBUG_HFCMULTI_MSG)
+ printk(KERN_DEBUG "%s: MISDN_CTRL_HFC_WD_RESET\n",
+ __func__);
+ HFC_outb(hc, R_BERT_WD_MD, hc->hw.r_bert_wd_md | V_WD_RES);
break;
default:
printk(KERN_WARNING "%s: unknown Op %x\n",
@@ -4047,7 +4182,7 @@ hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
switch (rq->protocol) {
case ISDN_P_TE_S0:
case ISDN_P_NT_S0:
- if (hc->type == 1) {
+ if (hc->ctype == HFC_TYPE_E1) {
err = -EINVAL;
break;
}
@@ -4055,7 +4190,7 @@ hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
break;
case ISDN_P_TE_E1:
case ISDN_P_NT_E1:
- if (hc->type != 1) {
+ if (hc->ctype != HFC_TYPE_E1) {
err = -EINVAL;
break;
}
@@ -4122,13 +4257,13 @@ init_card(struct hfc_multi *hc)
disable_hwirq(hc);
spin_unlock_irqrestore(&hc->lock, flags);
- if (request_irq(hc->pci_dev->irq, hfcmulti_interrupt, IRQF_SHARED,
+ if (request_irq(hc->irq, hfcmulti_interrupt, IRQF_SHARED,
"HFC-multi", hc)) {
printk(KERN_WARNING "mISDN: Could not get interrupt %d.\n",
- hc->pci_dev->irq);
+ hc->irq);
+ hc->irq = 0;
return -EIO;
}
- hc->irq = hc->pci_dev->irq;
if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
spin_lock_irqsave(&plx_lock, plx_flags);
@@ -4187,7 +4322,7 @@ error:
}
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: free irq %d\n", __func__, hc->irq);
+ printk(KERN_DEBUG "%s: free irq %d\n", __func__, hc->irq);
if (hc->irq) {
free_irq(hc->irq, hc);
hc->irq = 0;
@@ -4235,6 +4370,10 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev,
hc->ledstate = 0xAFFEAFFE;
hc->opticalsupport = m->opticalsupport;
+ hc->pci_iobase = 0;
+ hc->pci_membase = NULL;
+ hc->plx_membase = NULL;
+
/* set memory access methods */
if (m->io_mode) /* use mode from card config */
hc->io_mode = m->io_mode;
@@ -4242,44 +4381,12 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev,
case HFC_IO_MODE_PLXSD:
test_and_set_bit(HFC_CHIP_PLXSD, &hc->chip);
hc->slots = 128; /* required */
- /* fall through */
- case HFC_IO_MODE_PCIMEM:
hc->HFC_outb = HFC_outb_pcimem;
hc->HFC_inb = HFC_inb_pcimem;
hc->HFC_inw = HFC_inw_pcimem;
hc->HFC_wait = HFC_wait_pcimem;
hc->read_fifo = read_fifo_pcimem;
hc->write_fifo = write_fifo_pcimem;
- break;
- case HFC_IO_MODE_REGIO:
- hc->HFC_outb = HFC_outb_regio;
- hc->HFC_inb = HFC_inb_regio;
- hc->HFC_inw = HFC_inw_regio;
- hc->HFC_wait = HFC_wait_regio;
- hc->read_fifo = read_fifo_regio;
- hc->write_fifo = write_fifo_regio;
- break;
- default:
- printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n");
- pci_disable_device(hc->pci_dev);
- return -EIO;
- }
- hc->HFC_outb_nodebug = hc->HFC_outb;
- hc->HFC_inb_nodebug = hc->HFC_inb;
- hc->HFC_inw_nodebug = hc->HFC_inw;
- hc->HFC_wait_nodebug = hc->HFC_wait;
-#ifdef HFC_REGISTER_DEBUG
- hc->HFC_outb = HFC_outb_debug;
- hc->HFC_inb = HFC_inb_debug;
- hc->HFC_inw = HFC_inw_debug;
- hc->HFC_wait = HFC_wait_debug;
-#endif
- hc->pci_iobase = 0;
- hc->pci_membase = NULL;
- hc->plx_membase = NULL;
-
- switch (hc->io_mode) {
- case HFC_IO_MODE_PLXSD:
hc->plx_origmembase = hc->pci_dev->resource[0].start;
/* MEMBASE 1 is PLX PCI Bridge */
@@ -4327,6 +4434,12 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev,
pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO);
break;
case HFC_IO_MODE_PCIMEM:
+ hc->HFC_outb = HFC_outb_pcimem;
+ hc->HFC_inb = HFC_inb_pcimem;
+ hc->HFC_inw = HFC_inw_pcimem;
+ hc->HFC_wait = HFC_wait_pcimem;
+ hc->read_fifo = read_fifo_pcimem;
+ hc->write_fifo = write_fifo_pcimem;
hc->pci_origmembase = hc->pci_dev->resource[1].start;
if (!hc->pci_origmembase) {
printk(KERN_WARNING
@@ -4343,12 +4456,18 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev,
pci_disable_device(hc->pci_dev);
return -EIO;
}
- printk(KERN_INFO "card %d: defined at MEMBASE %#lx (%#lx) IRQ %d "
- "HZ %d leds-type %d\n", hc->id, (u_long)hc->pci_membase,
+ printk(KERN_INFO "card %d: defined at MEMBASE %#lx (%#lx) IRQ "
+ "%d HZ %d leds-type %d\n", hc->id, (u_long)hc->pci_membase,
hc->pci_origmembase, hc->pci_dev->irq, HZ, hc->leds);
pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO);
break;
case HFC_IO_MODE_REGIO:
+ hc->HFC_outb = HFC_outb_regio;
+ hc->HFC_inb = HFC_inb_regio;
+ hc->HFC_inw = HFC_inw_regio;
+ hc->HFC_wait = HFC_wait_regio;
+ hc->read_fifo = read_fifo_regio;
+ hc->write_fifo = write_fifo_regio;
hc->pci_iobase = (u_int) hc->pci_dev->resource[0].start;
if (!hc->pci_iobase) {
printk(KERN_WARNING
@@ -4430,7 +4549,7 @@ release_port(struct hfc_multi *hc, struct dchannel *dch)
dch->timer.function = NULL;
}
- if (hc->type == 1) { /* E1 */
+ if (hc->ctype == HFC_TYPE_E1) { /* E1 */
/* remove sync */
if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
hc->syncronized = 0;
@@ -4508,7 +4627,7 @@ release_card(struct hfc_multi *hc)
int ch;
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: release card (%d) entered\n",
+ printk(KERN_DEBUG "%s: release card (%d) entered\n",
__func__, hc->id);
/* unregister clock source */
@@ -4537,7 +4656,7 @@ release_card(struct hfc_multi *hc)
/* release hardware & irq */
if (hc->irq) {
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: free irq %d\n",
+ printk(KERN_DEBUG "%s: free irq %d\n",
__func__, hc->irq);
free_irq(hc->irq, hc);
hc->irq = 0;
@@ -4546,17 +4665,17 @@ release_card(struct hfc_multi *hc)
release_io_hfcmulti(hc);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: remove instance from list\n",
+ printk(KERN_DEBUG "%s: remove instance from list\n",
__func__);
list_del(&hc->list);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: delete instance\n", __func__);
+ printk(KERN_DEBUG "%s: delete instance\n", __func__);
if (hc == syncmaster)
syncmaster = NULL;
kfree(hc);
if (debug & DEBUG_HFCMULTI_INIT)
- printk(KERN_WARNING "%s: card successfully removed\n",
+ printk(KERN_DEBUG "%s: card successfully removed\n",
__func__);
}
@@ -4579,7 +4698,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
dch->dev.D.send = handle_dmsg;
dch->dev.D.ctrl = hfcm_dctrl;
- dch->dev.nrbchan = (hc->dslot)?30:31;
+ dch->dev.nrbchan = (hc->dslot) ? 30 : 31;
dch->slot = hc->dslot;
hc->chan[hc->dslot].dch = dch;
hc->chan[hc->dslot].port = 0;
@@ -4821,7 +4940,7 @@ init_multi_port(struct hfc_multi *hc, int pt)
}
/* disable E-channel */
if (port[Port_cnt] & 0x004) {
- if (debug & DEBUG_HFCMULTI_INIT)
+ if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG
"%s: PROTOCOL disable E-channel: "
"card(%d) port(%d)\n",
@@ -4829,9 +4948,15 @@ init_multi_port(struct hfc_multi *hc, int pt)
test_and_set_bit(HFC_CFG_DIS_ECHANNEL,
&hc->chan[i + 2].cfg);
}
- snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d-%d",
- hc->type, HFC_cnt + 1, pt + 1);
- ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name);
+ if (hc->ctype == HFC_TYPE_XHFC) {
+ snprintf(name, MISDN_MAX_IDLEN - 1, "xhfc.%d-%d",
+ HFC_cnt + 1, pt + 1);
+ ret = mISDN_register_device(&dch->dev, NULL, name);
+ } else {
+ snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d-%d",
+ hc->ctype, HFC_cnt + 1, pt + 1);
+ ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name);
+ }
if (ret)
goto free_chan;
hc->created[pt] = 1;
@@ -4842,9 +4967,9 @@ free_chan:
}
static int
-hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
+hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
+ const struct pci_device_id *ent)
{
- struct hm_map *m = (struct hm_map *)ent->driver_data;
int ret_err = 0;
int pt;
struct hfc_multi *hc;
@@ -4879,16 +5004,18 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
}
spin_lock_init(&hc->lock);
hc->mtyp = m;
- hc->type = m->type;
+ hc->ctype = m->type;
hc->ports = m->ports;
hc->id = HFC_cnt;
hc->pcm = pcm[HFC_cnt];
hc->io_mode = iomode[HFC_cnt];
- if (dslot[HFC_cnt] < 0 && hc->type == 1) {
+ if (dslot[HFC_cnt] < 0 && hc->ctype == HFC_TYPE_E1) {
hc->dslot = 0;
printk(KERN_INFO "HFC-E1 card has disabled D-channel, but "
"31 B-channels\n");
- } if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32 && hc->type == 1) {
+ }
+ if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32
+ && hc->ctype == HFC_TYPE_E1) {
hc->dslot = dslot[HFC_cnt];
printk(KERN_INFO "HFC-E1 card has alternating D-channel on "
"time slot %d\n", dslot[HFC_cnt]);
@@ -4910,8 +5037,11 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
for (i = 0; i < (poll >> 1); i++)
hc->silence_data[i] = hc->silence;
- if (!(type[HFC_cnt] & 0x200))
- test_and_set_bit(HFC_CHIP_DTMF, &hc->chip);
+ if (hc->ctype != HFC_TYPE_XHFC) {
+ if (!(type[HFC_cnt] & 0x200))
+ test_and_set_bit(HFC_CHIP_DTMF, &hc->chip);
+ test_and_set_bit(HFC_CHIP_CONF, &hc->chip);
+ }
if (type[HFC_cnt] & 0x800)
test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip);
@@ -4935,8 +5065,18 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
printk(KERN_NOTICE "Watchdog enabled\n");
}
- /* setup pci, hc->slots may change due to PLXSD */
- ret_err = setup_pci(hc, pdev, ent);
+ if (pdev && ent)
+ /* setup pci, hc->slots may change due to PLXSD */
+ ret_err = setup_pci(hc, pdev, ent);
+ else
+#ifdef CONFIG_MISDN_HFCMULTI_8xx
+ ret_err = setup_embedded(hc, m);
+#else
+ {
+ printk(KERN_WARNING "Embedded IO Mode not selected\n");
+ ret_err = -EIO;
+ }
+#endif
if (ret_err) {
if (hc == syncmaster)
syncmaster = NULL;
@@ -4944,7 +5084,17 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
return ret_err;
}
- /* crate channels */
+ hc->HFC_outb_nodebug = hc->HFC_outb;
+ hc->HFC_inb_nodebug = hc->HFC_inb;
+ hc->HFC_inw_nodebug = hc->HFC_inw;
+ hc->HFC_wait_nodebug = hc->HFC_wait;
+#ifdef HFC_REGISTER_DEBUG
+ hc->HFC_outb = HFC_outb_debug;
+ hc->HFC_inb = HFC_inb_debug;
+ hc->HFC_inw = HFC_inw_debug;
+ hc->HFC_wait = HFC_wait_debug;
+#endif
+ /* create channels */
for (pt = 0; pt < hc->ports; pt++) {
if (Port_cnt >= MAX_PORTS) {
printk(KERN_ERR "too many ports (max=%d).\n",
@@ -4952,7 +5102,7 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
ret_err = -EINVAL;
goto free_card;
}
- if (hc->type == 1)
+ if (hc->ctype == HFC_TYPE_E1)
ret_err = init_e1_port(hc, m);
else
ret_err = init_multi_port(hc, pt);
@@ -5036,6 +5186,7 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
hc->iclock = mISDN_register_clock("HFCMulti", 0, clockctl, hc);
/* initialize hardware */
+ hc->irq = (m->irq) ? : hc->pci_dev->irq;
ret_err = init_card(hc);
if (ret_err) {
printk(KERN_ERR "init card returns %d\n", ret_err);
@@ -5074,7 +5225,7 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev)
spin_unlock_irqrestore(&HFClock, flags);
} else {
if (debug)
- printk(KERN_WARNING "%s: drvdata allready removed\n",
+ printk(KERN_DEBUG "%s: drvdata allready removed\n",
__func__);
}
}
@@ -5086,45 +5237,48 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev)
#define VENDOR_PRIM "PrimuX"
static const struct hm_map hfcm_map[] = {
-/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0},
-/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0},
-/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0},
-/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0},
-/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0},
-/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0},
-/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0},
-/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0},
-/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO},
-/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0},
-/*10*/ {VENDOR_JH, "HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0},
-/*11*/ {VENDOR_PRIM, "HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0},
-
-/*12*/ {VENDOR_BN, "HFC-8S Card", 8, 8, 1, 0, 0, 0, 0},
+/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0, 0},
+/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0, 0},
+/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0, 0},
+/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0, 0},
+/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0, 0},
+/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0, 0},
+/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0, 0},
+/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0, 0},
+/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO, 0},
+/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0, 0},
+/*10*/ {VENDOR_JH, "HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0, 0},
+/*11*/ {VENDOR_PRIM, "HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0, 0},
+
+/*12*/ {VENDOR_BN, "HFC-8S Card", 8, 8, 1, 0, 0, 0, 0, 0},
/*13*/ {VENDOR_BN, "HFC-8S Card (+)", 8, 8, 1, 8, 0, DIP_8S,
- HFC_IO_MODE_REGIO},
-/*14*/ {VENDOR_CCD, "HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0},
-/*15*/ {VENDOR_CCD, "HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0},
+ HFC_IO_MODE_REGIO, 0},
+/*14*/ {VENDOR_CCD, "HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0, 0},
+/*15*/ {VENDOR_CCD, "HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0, 0},
-/*16*/ {VENDOR_CCD, "HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0},
-/*17*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0},
-/*18*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0},
+/*16*/ {VENDOR_CCD, "HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0, 0},
+/*17*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0},
+/*18*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0},
-/*19*/ {VENDOR_BN, "HFC-E1 Card", 1, 1, 0, 1, 0, DIP_E1, 0},
-/*20*/ {VENDOR_BN, "HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0},
-/*21*/ {VENDOR_BN, "HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0},
-/*22*/ {VENDOR_BN, "HFC-E1 Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0},
+/*19*/ {VENDOR_BN, "HFC-E1 Card", 1, 1, 0, 1, 0, DIP_E1, 0, 0},
+/*20*/ {VENDOR_BN, "HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0, 0},
+/*21*/ {VENDOR_BN, "HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0},
+/*22*/ {VENDOR_BN, "HFC-E1 Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0},
-/*23*/ {VENDOR_CCD, "HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0},
-/*24*/ {VENDOR_CCD, "HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0},
-/*25*/ {VENDOR_CCD, "HFC-E1", 1, 1, 0, 1, 0, 0, 0},
+/*23*/ {VENDOR_CCD, "HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0, 0},
+/*24*/ {VENDOR_CCD, "HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0, 0},
+/*25*/ {VENDOR_CCD, "HFC-E1", 1, 1, 0, 1, 0, 0, 0, 0},
/*26*/ {VENDOR_CCD, "HFC-4S Speech Design", 4, 4, 0, 0, 0, 0,
- HFC_IO_MODE_PLXSD},
+ HFC_IO_MODE_PLXSD, 0},
/*27*/ {VENDOR_CCD, "HFC-E1 Speech Design", 1, 1, 0, 0, 0, 0,
- HFC_IO_MODE_PLXSD},
-/*28*/ {VENDOR_CCD, "HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0},
-/*29*/ {VENDOR_CCD, "HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0},
-/*30*/ {VENDOR_CCD, "HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0},
+ HFC_IO_MODE_PLXSD, 0},
+/*28*/ {VENDOR_CCD, "HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0, 0},
+/*29*/ {VENDOR_CCD, "HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0, 0},
+/*30*/ {VENDOR_CCD, "HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0, 0},
+/*31*/ {VENDOR_CCD, "XHFC-4S Speech Design", 5, 4, 0, 0, 0, 0,
+ HFC_IO_MODE_EMBSD, XHFC_IRQ},
+/*32*/ {VENDOR_JH, "HFC-8S (junghanns)", 8, 8, 1, 0, 0, 0, 0, 0},
};
#undef H
@@ -5178,6 +5332,8 @@ static struct pci_device_id hfmultipci_ids[] __devinitdata = {
PCI_SUBDEVICE_ID_CCD_HFC8S, 0, 0, H(18)}, /* 8S */
{ PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
PCI_SUBDEVICE_ID_CCD_OV8S, 0, 0, H(30)}, /* OpenVox 8 */
+ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
+ PCI_SUBDEVICE_ID_CCD_JH8S, 0, 0, H(32)}, /* Junganns 8S */
/* Cards with HFC-E1 Chip */
@@ -5201,6 +5357,10 @@ static struct pci_device_id hfmultipci_ids[] __devinitdata = {
PCI_SUBDEVICE_ID_CCD_SPD4S, 0, 0, H(26)}, /* PLX PCI Bridge */
{ PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_CCD,
PCI_SUBDEVICE_ID_CCD_SPDE1, 0, 0, H(27)}, /* PLX PCI Bridge */
+
+ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
+ PCI_SUBDEVICE_ID_CCD_JHSE1, 0, 0, H(25)}, /* Junghanns E1 */
+
{ PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_ANY_ID, PCI_ANY_ID,
0, 0, 0},
{ PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_ANY_ID, PCI_ANY_ID,
@@ -5231,7 +5391,7 @@ hfcmulti_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
"Please contact the driver maintainer for support.\n");
return -ENODEV;
}
- ret = hfcmulti_init(pdev, ent);
+ ret = hfcmulti_init(m, pdev, ent);
if (ret)
return ret;
HFC_cnt++;
@@ -5261,6 +5421,8 @@ static int __init
HFCmulti_init(void)
{
int err;
+ int i, xhfc = 0;
+ struct hm_map m;
printk(KERN_INFO "mISDN: HFC-multi driver %s\n", HFC_MULTI_VERSION);
@@ -5308,11 +5470,43 @@ HFCmulti_init(void)
if (!clock)
clock = 1;
+ /* Register the embedded devices.
+ * This should be done before the PCI cards registration */
+ switch (hwid) {
+ case HWID_MINIP4:
+ xhfc = 1;
+ m = hfcm_map[31];
+ break;
+ case HWID_MINIP8:
+ xhfc = 2;
+ m = hfcm_map[31];
+ break;
+ case HWID_MINIP16:
+ xhfc = 4;
+ m = hfcm_map[31];
+ break;
+ default:
+ xhfc = 0;
+ }
+
+ for (i = 0; i < xhfc; ++i) {
+ err = hfcmulti_init(&m, NULL, NULL);
+ if (err) {
+ printk(KERN_ERR "error registering embedded driver: "
+ "%x\n", err);
+ return -err;
+ }
+ HFC_cnt++;
+ printk(KERN_INFO "%d devices registered\n", HFC_cnt);
+ }
+
+ /* Register the PCI cards */
err = pci_register_driver(&hfcmultipci_driver);
if (err < 0) {
printk(KERN_ERR "error registering pci driver: %x\n", err);
return err;
}
+
return 0;
}
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 641a9cd1a532..776afc8c9270 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -257,7 +257,7 @@ reset_hfcpci(struct hfc_pci *hc)
Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
/* Clear already pending ints */
- if (Read_hfc(hc, HFCPCI_INT_S1));
+ val = Read_hfc(hc, HFCPCI_INT_S1);
/* set NT/TE mode */
hfcpci_setmode(hc);
@@ -452,7 +452,7 @@ hfcpci_empty_bfifo(struct bchannel *bch, struct bzfifo *bz,
}
bz->za[new_f2].z2 = cpu_to_le16(new_z2);
bz->f2 = new_f2; /* next buffer */
- recv_Bchannel(bch);
+ recv_Bchannel(bch, MISDN_ID_ANY);
}
}
@@ -499,7 +499,8 @@ receive_dmsg(struct hfc_pci *hc)
df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) |
(MAX_D_FRAMES + 1); /* next buffer */
df->za[df->f2 & D_FREG_MASK].z2 =
- cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) & (D_FIFO_SIZE - 1));
+ cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) &
+ (D_FIFO_SIZE - 1));
} else {
dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC);
if (!dch->rx_skb) {
@@ -541,35 +542,45 @@ receive_dmsg(struct hfc_pci *hc)
* check for transparent receive data and read max one 'poll' size if avail
*/
static void
-hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
+hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *rxbz,
+ struct bzfifo *txbz, u_char *bdata)
{
- __le16 *z1r, *z2r;
- int new_z2, fcnt, maxlen;
- u_char *ptr, *ptr1;
+ __le16 *z1r, *z2r, *z1t, *z2t;
+ int new_z2, fcnt_rx, fcnt_tx, maxlen;
+ u_char *ptr, *ptr1;
- z1r = &bz->za[MAX_B_FRAMES].z1; /* pointer to z reg */
+ z1r = &rxbz->za[MAX_B_FRAMES].z1; /* pointer to z reg */
z2r = z1r + 1;
+ z1t = &txbz->za[MAX_B_FRAMES].z1;
+ z2t = z1t + 1;
- fcnt = le16_to_cpu(*z1r) - le16_to_cpu(*z2r);
- if (!fcnt)
+ fcnt_rx = le16_to_cpu(*z1r) - le16_to_cpu(*z2r);
+ if (!fcnt_rx)
return; /* no data avail */
- if (fcnt <= 0)
- fcnt += B_FIFO_SIZE; /* bytes actually buffered */
- new_z2 = le16_to_cpu(*z2r) + fcnt; /* new position in fifo */
+ if (fcnt_rx <= 0)
+ fcnt_rx += B_FIFO_SIZE; /* bytes actually buffered */
+ new_z2 = le16_to_cpu(*z2r) + fcnt_rx; /* new position in fifo */
if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL))
new_z2 -= B_FIFO_SIZE; /* buffer wrap */
- if (fcnt > MAX_DATA_SIZE) { /* flush, if oversized */
+ if (fcnt_rx > MAX_DATA_SIZE) { /* flush, if oversized */
*z2r = cpu_to_le16(new_z2); /* new position */
return;
}
- bch->rx_skb = mI_alloc_skb(fcnt, GFP_ATOMIC);
+ fcnt_tx = le16_to_cpu(*z2t) - le16_to_cpu(*z1t);
+ if (fcnt_tx <= 0)
+ fcnt_tx += B_FIFO_SIZE;
+ /* fcnt_tx contains available bytes in tx-fifo */
+ fcnt_tx = B_FIFO_SIZE - fcnt_tx;
+ /* remaining bytes to send (bytes in tx-fifo) */
+
+ bch->rx_skb = mI_alloc_skb(fcnt_rx, GFP_ATOMIC);
if (bch->rx_skb) {
- ptr = skb_put(bch->rx_skb, fcnt);
- if (le16_to_cpu(*z2r) + fcnt <= B_FIFO_SIZE + B_SUB_VAL)
- maxlen = fcnt; /* complete transfer */
+ ptr = skb_put(bch->rx_skb, fcnt_rx);
+ if (le16_to_cpu(*z2r) + fcnt_rx <= B_FIFO_SIZE + B_SUB_VAL)
+ maxlen = fcnt_rx; /* complete transfer */
else
maxlen = B_FIFO_SIZE + B_SUB_VAL - le16_to_cpu(*z2r);
/* maximum */
@@ -577,14 +588,14 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
ptr1 = bdata + (le16_to_cpu(*z2r) - B_SUB_VAL);
/* start of data */
memcpy(ptr, ptr1, maxlen); /* copy data */
- fcnt -= maxlen;
+ fcnt_rx -= maxlen;
- if (fcnt) { /* rest remaining */
+ if (fcnt_rx) { /* rest remaining */
ptr += maxlen;
ptr1 = bdata; /* start of buffer */
- memcpy(ptr, ptr1, fcnt); /* rest */
+ memcpy(ptr, ptr1, fcnt_rx); /* rest */
}
- recv_Bchannel(bch);
+ recv_Bchannel(bch, fcnt_tx); /* bch, id */
} else
printk(KERN_WARNING "HFCPCI: receive out of memory\n");
@@ -600,26 +611,28 @@ main_rec_hfcpci(struct bchannel *bch)
struct hfc_pci *hc = bch->hw;
int rcnt, real_fifo;
int receive = 0, count = 5;
- struct bzfifo *bz;
+ struct bzfifo *txbz, *rxbz;
u_char *bdata;
struct zt *zp;
if ((bch->nr & 2) && (!hc->hw.bswapped)) {
- bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2;
+ rxbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2;
+ txbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b2;
bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b2;
real_fifo = 1;
} else {
- bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b1;
+ rxbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b1;
+ txbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b1;
bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b1;
real_fifo = 0;
}
Begin:
count--;
- if (bz->f1 != bz->f2) {
+ if (rxbz->f1 != rxbz->f2) {
if (bch->debug & DEBUG_HW_BCHANNEL)
printk(KERN_DEBUG "hfcpci rec ch(%x) f1(%d) f2(%d)\n",
- bch->nr, bz->f1, bz->f2);
- zp = &bz->za[bz->f2];
+ bch->nr, rxbz->f1, rxbz->f2);
+ zp = &rxbz->za[rxbz->f2];
rcnt = le16_to_cpu(zp->z1) - le16_to_cpu(zp->z2);
if (rcnt < 0)
@@ -630,8 +643,8 @@ Begin:
"hfcpci rec ch(%x) z1(%x) z2(%x) cnt(%d)\n",
bch->nr, le16_to_cpu(zp->z1),
le16_to_cpu(zp->z2), rcnt);
- hfcpci_empty_bfifo(bch, bz, bdata, rcnt);
- rcnt = bz->f1 - bz->f2;
+ hfcpci_empty_bfifo(bch, rxbz, bdata, rcnt);
+ rcnt = rxbz->f1 - rxbz->f2;
if (rcnt < 0)
rcnt += MAX_B_FRAMES + 1;
if (hc->hw.last_bfifo_cnt[real_fifo] > rcnt + 1) {
@@ -644,7 +657,7 @@ Begin:
else
receive = 0;
} else if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
- hfcpci_empty_fifo_trans(bch, bz, bdata);
+ hfcpci_empty_fifo_trans(bch, rxbz, txbz, bdata);
return;
} else
receive = 0;
@@ -954,6 +967,7 @@ static void
ph_state_nt(struct dchannel *dch)
{
struct hfc_pci *hc = dch->hw;
+ u_char val;
if (dch->debug)
printk(KERN_DEBUG "%s: NT newstate %x\n",
@@ -967,7 +981,7 @@ ph_state_nt(struct dchannel *dch)
hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
/* Clear already pending ints */
- if (Read_hfc(hc, HFCPCI_INT_S1));
+ val = Read_hfc(hc, HFCPCI_INT_S1);
Write_hfc(hc, HFCPCI_STATES, 4 | HFCPCI_LOAD_STATE);
udelay(10);
Write_hfc(hc, HFCPCI_STATES, 4);
@@ -1256,8 +1270,7 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
rx_slot = (bc>>8) & 0xff;
tx_slot = (bc>>16) & 0xff;
bc = bc & 0xff;
- } else if (test_bit(HFC_CFG_PCM, &hc->cfg) &&
- (protocol > ISDN_P_NONE))
+ } else if (test_bit(HFC_CFG_PCM, &hc->cfg) && (protocol > ISDN_P_NONE))
printk(KERN_WARNING "%s: no pcm channel id but HFC_CFG_PCM\n",
__func__);
if (hc->chanlimit > 1) {
@@ -1315,8 +1328,8 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
case (ISDN_P_B_RAW):
bch->state = protocol;
bch->nr = bc;
- hfcpci_clear_fifo_rx(hc, (fifo2 & 2)?1:0);
- hfcpci_clear_fifo_tx(hc, (fifo2 & 2)?1:0);
+ hfcpci_clear_fifo_rx(hc, (fifo2 & 2) ? 1 : 0);
+ hfcpci_clear_fifo_tx(hc, (fifo2 & 2) ? 1 : 0);
if (bc & 2) {
hc->hw.sctrl |= SCTRL_B2_ENA;
hc->hw.sctrl_r |= SCTRL_B2_ENA;
@@ -1350,8 +1363,8 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
case (ISDN_P_B_HDLC):
bch->state = protocol;
bch->nr = bc;
- hfcpci_clear_fifo_rx(hc, (fifo2 & 2)?1:0);
- hfcpci_clear_fifo_tx(hc, (fifo2 & 2)?1:0);
+ hfcpci_clear_fifo_rx(hc, (fifo2 & 2) ? 1 : 0);
+ hfcpci_clear_fifo_tx(hc, (fifo2 & 2) ? 1 : 0);
if (bc & 2) {
hc->hw.sctrl |= SCTRL_B2_ENA;
hc->hw.sctrl_r |= SCTRL_B2_ENA;
@@ -1445,7 +1458,7 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
switch (protocol) {
case (ISDN_P_B_RAW):
bch->state = protocol;
- hfcpci_clear_fifo_rx(hc, (chan & 2)?1:0);
+ hfcpci_clear_fifo_rx(hc, (chan & 2) ? 1 : 0);
if (chan & 2) {
hc->hw.sctrl_r |= SCTRL_B2_ENA;
hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX;
@@ -1470,7 +1483,7 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
break;
case (ISDN_P_B_HDLC):
bch->state = protocol;
- hfcpci_clear_fifo_rx(hc, (chan & 2)?1:0);
+ hfcpci_clear_fifo_rx(hc, (chan & 2) ? 1 : 0);
if (chan & 2) {
hc->hw.sctrl_r |= SCTRL_B2_ENA;
hc->hw.last_bfifo_cnt[1] = 0;
@@ -2035,7 +2048,8 @@ setup_hw(struct hfc_pci *hc)
printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
return 1;
}
- hc->hw.pci_io = (char __iomem *)(unsigned long)hc->pdev->resource[1].start;
+ hc->hw.pci_io =
+ (char __iomem *)(unsigned long)hc->pdev->resource[1].start;
if (!hc->hw.pci_io) {
printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
@@ -2277,7 +2291,7 @@ hfc_remove_pci(struct pci_dev *pdev)
release_card(card);
else
if (debug)
- printk(KERN_WARNING "%s: drvdata already removed\n",
+ printk(KERN_DEBUG "%s: drvdata already removed\n",
__func__);
}
diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
index 9c427fb204ee..6b7704c41b94 100644
--- a/drivers/isdn/hardware/mISDN/hfcsusb.c
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
@@ -947,7 +947,7 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len,
if (fifo->dch)
recv_Dchannel(fifo->dch);
if (fifo->bch)
- recv_Bchannel(fifo->bch);
+ recv_Bchannel(fifo->bch, MISDN_ID_ANY);
if (fifo->ech)
recv_Echannel(fifo->ech,
&hw->dch);
@@ -969,7 +969,7 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len,
} else {
/* deliver transparent data to layer2 */
if (rx_skb->len >= poll)
- recv_Bchannel(fifo->bch);
+ recv_Bchannel(fifo->bch, MISDN_ID_ANY);
}
spin_unlock(&hw->lock);
}
diff --git a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
index 36778b270c30..ed3510f273d8 100644
--- a/drivers/isdn/i4l/Kconfig
+++ b/drivers/isdn/i4l/Kconfig
@@ -135,5 +135,3 @@ source "drivers/isdn/act2000/Kconfig"
source "drivers/isdn/hysdn/Kconfig"
endmenu
-
-source "drivers/isdn/gigaset/Kconfig"
diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
index 9426c9827e47..21d34be5af6a 100644
--- a/drivers/isdn/mISDN/core.c
+++ b/drivers/isdn/mISDN/core.c
@@ -214,7 +214,7 @@ get_free_devid(void)
if (!test_and_set_bit(i, (u_long *)&device_ids))
break;
if (i > MAX_DEVICE_ID)
- return -1;
+ return -EBUSY;
return i;
}
@@ -224,10 +224,10 @@ mISDN_register_device(struct mISDNdevice *dev,
{
int err;
- dev->id = get_free_devid();
- err = -EBUSY;
- if (dev->id < 0)
+ err = get_free_devid();
+ if (err < 0)
goto error1;
+ dev->id = err;
device_initialize(&dev->dev);
if (name && name[0])
diff --git a/drivers/isdn/mISDN/dsp.h b/drivers/isdn/mISDN/dsp.h
index 98a33c58f091..18af86879c05 100644
--- a/drivers/isdn/mISDN/dsp.h
+++ b/drivers/isdn/mISDN/dsp.h
@@ -112,9 +112,11 @@ struct dsp_conf {
#define DSP_DTMF_NPOINTS 102
-#define ECHOCAN_BUFLEN (4*128)
+#define ECHOCAN_BUFF_SIZE 0x400 /* must be 2**n */
+#define ECHOCAN_BUFF_MASK 0x3ff /* -1 */
struct dsp_dtmf {
+ int enable; /* dtmf is enabled */
int treshold; /* above this is dtmf (square of) */
int software; /* dtmf uses software decoding */
int hardware; /* dtmf uses hardware decoding */
@@ -123,7 +125,7 @@ struct dsp_dtmf {
/* buffers one full dtmf frame */
u8 lastwhat, lastdigit;
int count;
- u8 digits[16]; /* just the dtmf result */
+ u8 digits[16]; /* dtmf result */
};
@@ -150,6 +152,15 @@ struct dsp_tone {
struct timer_list tl;
};
+/***************
+ * echo stuff *
+ ***************/
+
+struct dsp_echo {
+ int software; /* echo is generated by software */
+ int hardware; /* echo is generated by hardware */
+};
+
/*****************
* general stuff *
*****************/
@@ -160,7 +171,7 @@ struct dsp {
struct mISDNchannel *up;
unsigned char name[64];
int b_active;
- int echo; /* echo is enabled */
+ struct dsp_echo echo;
int rx_disabled; /* what the user wants */
int rx_is_off; /* what the card is */
int tx_mix;
@@ -261,5 +272,5 @@ extern int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg);
extern void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data,
int len);
extern void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data,
- int len);
+ int len, unsigned int txlen);
diff --git a/drivers/isdn/mISDN/dsp_audio.c b/drivers/isdn/mISDN/dsp_audio.c
index de3795e3f432..9c7c6451bf3d 100644
--- a/drivers/isdn/mISDN/dsp_audio.c
+++ b/drivers/isdn/mISDN/dsp_audio.c
@@ -210,9 +210,8 @@ dsp_audio_generate_seven(void)
j = 0;
for (k = 0; k < 256; k++) {
if (dsp_audio_alaw_to_s32[k]
- < dsp_audio_alaw_to_s32[i]) {
- j++;
- }
+ < dsp_audio_alaw_to_s32[i])
+ j++;
}
sorted_alaw[j] = i;
}
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index 58c43e429f73..9c7c0d1ba55f 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -163,8 +163,9 @@ dsp_cmx_debug(struct dsp *dsp)
printk(KERN_DEBUG "-----Current DSP\n");
list_for_each_entry(odsp, &dsp_ilist, list) {
- printk(KERN_DEBUG "* %s echo=%d txmix=%d",
- odsp->name, odsp->echo, odsp->tx_mix);
+ printk(KERN_DEBUG "* %s hardecho=%d softecho=%d txmix=%d",
+ odsp->name, odsp->echo.hardware, odsp->echo.software,
+ odsp->tx_mix);
if (odsp->conf)
printk(" (Conf %d)", odsp->conf->id);
if (dsp == odsp)
@@ -177,10 +178,12 @@ dsp_cmx_debug(struct dsp *dsp)
list_for_each_entry(member, &conf->mlist, list) {
printk(KERN_DEBUG
" - member = %s (slot_tx %d, bank_tx %d, "
- "slot_rx %d, bank_rx %d hfc_conf %d)%s\n",
+ "slot_rx %d, bank_rx %d hfc_conf %d "
+ "tx_data %d rx_is_off %d)%s\n",
member->dsp->name, member->dsp->pcm_slot_tx,
member->dsp->pcm_bank_tx, member->dsp->pcm_slot_rx,
member->dsp->pcm_bank_rx, member->dsp->hfc_conf,
+ member->dsp->tx_data, member->dsp->rx_is_off,
(member->dsp == dsp) ? " *this*" : "");
}
}
@@ -235,7 +238,7 @@ dsp_cmx_add_conf_member(struct dsp *dsp, struct dsp_conf *conf)
member = kzalloc(sizeof(struct dsp_conf_member), GFP_ATOMIC);
if (!member) {
- printk(KERN_ERR "kmalloc struct dsp_conf_member failed\n");
+ printk(KERN_ERR "kzalloc struct dsp_conf_member failed\n");
return -ENOMEM;
}
member->dsp = dsp;
@@ -314,7 +317,7 @@ static struct dsp_conf
conf = kzalloc(sizeof(struct dsp_conf), GFP_ATOMIC);
if (!conf) {
- printk(KERN_ERR "kmalloc struct dsp_conf failed\n");
+ printk(KERN_ERR "kzalloc struct dsp_conf failed\n");
return NULL;
}
INIT_LIST_HEAD(&conf->mlist);
@@ -385,7 +388,7 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp)
int freeunits[8];
u_char freeslots[256];
int same_hfc = -1, same_pcm = -1, current_conf = -1,
- all_conf = 1;
+ all_conf = 1, tx_data = 0;
/* dsp gets updated (no conf) */
if (!conf) {
@@ -409,7 +412,7 @@ one_member:
/* process hw echo */
if (dsp->features.pcm_banks < 1)
return;
- if (!dsp->echo) {
+ if (!dsp->echo.software && !dsp->echo.hardware) {
/* NO ECHO: remove PCM slot if assigned */
if (dsp->pcm_slot_tx >= 0 || dsp->pcm_slot_rx >= 0) {
if (dsp_debug & DEBUG_DSP_CMX)
@@ -427,10 +430,15 @@ one_member:
}
return;
}
+ /* echo is enabled, find out if we use soft or hardware */
+ dsp->echo.software = dsp->tx_data;
+ dsp->echo.hardware = 0;
/* ECHO: already echo */
if (dsp->pcm_slot_tx >= 0 && dsp->pcm_slot_rx < 0 &&
- dsp->pcm_bank_tx == 2 && dsp->pcm_bank_rx == 2)
+ dsp->pcm_bank_tx == 2 && dsp->pcm_bank_rx == 2) {
+ dsp->echo.hardware = 1;
return;
+ }
/* ECHO: if slot already assigned */
if (dsp->pcm_slot_tx >= 0) {
dsp->pcm_slot_rx = dsp->pcm_slot_tx;
@@ -443,6 +451,7 @@ one_member:
dsp->pcm_slot_tx);
dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_CONN,
dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2);
+ dsp->echo.hardware = 1;
return;
}
/* ECHO: find slot */
@@ -472,6 +481,7 @@ one_member:
"%s no slot available for echo\n",
__func__);
/* no more slots available */
+ dsp->echo.software = 1;
return;
}
/* assign free slot */
@@ -485,6 +495,7 @@ one_member:
__func__, dsp->name, dsp->pcm_slot_tx);
dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_CONN,
dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2);
+ dsp->echo.hardware = 1;
return;
}
@@ -554,7 +565,7 @@ conf_software:
return;
}
/* check if member has echo turned on */
- if (member->dsp->echo) {
+ if (member->dsp->echo.hardware || member->dsp->echo.software) {
if (dsp_debug & DEBUG_DSP_CMX)
printk(KERN_DEBUG
"%s dsp %s cannot form a conf, because "
@@ -592,10 +603,9 @@ conf_software:
if (member->dsp->tx_data) {
if (dsp_debug & DEBUG_DSP_CMX)
printk(KERN_DEBUG
- "%s dsp %s cannot form a conf, because "
- "tx_data is turned on\n",
+ "%s dsp %s tx_data is turned on\n",
__func__, member->dsp->name);
- goto conf_software;
+ tx_data = 1;
}
/* check if pipeline exists */
if (member->dsp->pipeline.inuse) {
@@ -794,7 +804,7 @@ conf_software:
nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx,
nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx);
conf->hardware = 1;
- conf->software = 0;
+ conf->software = tx_data;
return;
/* if members have one bank (or on the same chip) */
} else {
@@ -904,7 +914,7 @@ conf_software:
nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx,
nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx);
conf->hardware = 1;
- conf->software = 0;
+ conf->software = tx_data;
return;
}
}
@@ -937,6 +947,10 @@ conf_software:
if (current_conf >= 0) {
join_members:
list_for_each_entry(member, &conf->mlist, list) {
+ /* if no conference engine on our chip, change to
+ * software */
+ if (!member->dsp->features.hfc_conf)
+ goto conf_software;
/* in case of hdlc, change to software */
if (member->dsp->hdlc)
goto conf_software;
@@ -1295,17 +1309,25 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
int r, rr, t, tt, o_r, o_rr;
int preload = 0;
struct mISDNhead *hh, *thh;
+ int tx_data_only = 0;
/* don't process if: */
if (!dsp->b_active) { /* if not active */
dsp->last_tx = 0;
return;
}
- if (dsp->pcm_slot_tx >= 0 && /* connected to pcm slot */
+ if (((dsp->conf && dsp->conf->hardware) || /* hardware conf */
+ dsp->echo.hardware) && /* OR hardware echo */
dsp->tx_R == dsp->tx_W && /* AND no tx-data */
!(dsp->tone.tone && dsp->tone.software)) { /* AND not soft tones */
- dsp->last_tx = 0;
- return;
+ if (!dsp->tx_data) { /* no tx_data for user space required */
+ dsp->last_tx = 0;
+ return;
+ }
+ if (dsp->conf && dsp->conf->software && dsp->conf->hardware)
+ tx_data_only = 1;
+ if (dsp->conf->software && dsp->echo.hardware)
+ tx_data_only = 1;
}
#ifdef CMX_DEBUG
@@ -1367,7 +1389,8 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
while (r != rr && t != tt) {
#ifdef CMX_TX_DEBUG
if (strlen(debugbuf) < 48)
- sprintf(debugbuf+strlen(debugbuf), " %02x", p[t]);
+ sprintf(debugbuf+strlen(debugbuf), " %02x",
+ p[t]);
#endif
*d++ = p[t]; /* write tx_buff */
t = (t+1) & CMX_BUFF_MASK;
@@ -1388,7 +1411,7 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
/* PROCESS DATA (one member / no conf) */
if (!conf || members <= 1) {
/* -> if echo is NOT enabled */
- if (!dsp->echo) {
+ if (!dsp->echo.software) {
/* -> send tx-data if available or use 0-volume */
while (r != rr && t != tt) {
*d++ = p[t]; /* write tx_buff */
@@ -1438,7 +1461,7 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
o_r = (o_rr - rr + r) & CMX_BUFF_MASK;
/* start rx-pointer at current read position*/
/* -> if echo is NOT enabled */
- if (!dsp->echo) {
+ if (!dsp->echo.software) {
/*
* -> copy other member's rx-data,
* if tx-data is available, mix
@@ -1486,7 +1509,7 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
#endif
/* PROCESS DATA (three or more members) */
/* -> if echo is NOT enabled */
- if (!dsp->echo) {
+ if (!dsp->echo.software) {
/*
* -> substract rx-data from conf-data,
* if tx-data is available, mix
@@ -1550,27 +1573,40 @@ send_packet:
* becuase we want what we send, not what we filtered
*/
if (dsp->tx_data) {
- /* PREPARE RESULT */
- txskb = mI_alloc_skb(len, GFP_ATOMIC);
- if (!txskb) {
- printk(KERN_ERR
- "FATAL ERROR in mISDN_dsp.o: "
- "cannot alloc %d bytes\n", len);
+ if (tx_data_only) {
+ hh->prim = DL_DATA_REQ;
+ hh->id = 0;
+ /* queue and trigger */
+ skb_queue_tail(&dsp->sendq, nskb);
+ schedule_work(&dsp->workq);
+ /* exit because only tx_data is used */
+ return;
} else {
- thh = mISDN_HEAD_P(txskb);
- thh->prim = DL_DATA_REQ;
- thh->id = 0;
- memcpy(skb_put(txskb, len), nskb->data+preload, len);
- /* queue (trigger later) */
- skb_queue_tail(&dsp->sendq, txskb);
+ txskb = mI_alloc_skb(len, GFP_ATOMIC);
+ if (!txskb) {
+ printk(KERN_ERR
+ "FATAL ERROR in mISDN_dsp.o: "
+ "cannot alloc %d bytes\n", len);
+ } else {
+ thh = mISDN_HEAD_P(txskb);
+ thh->prim = DL_DATA_REQ;
+ thh->id = 0;
+ memcpy(skb_put(txskb, len), nskb->data+preload,
+ len);
+ /* queue (trigger later) */
+ skb_queue_tail(&dsp->sendq, txskb);
+ }
}
}
+
+ /* send data only to card, if we don't just calculated tx_data */
/* adjust volume */
if (dsp->tx_volume)
dsp_change_volume(nskb, dsp->tx_volume);
/* pipeline */
if (dsp->pipeline.inuse)
- dsp_pipeline_process_tx(&dsp->pipeline, nskb->data, nskb->len);
+ dsp_pipeline_process_tx(&dsp->pipeline, nskb->data,
+ nskb->len);
/* crypt */
if (dsp->bf_enable)
dsp_bf_encrypt(dsp, nskb->data, nskb->len);
@@ -1592,7 +1628,8 @@ dsp_cmx_send(void *arg)
struct dsp_conf_member *member;
struct dsp *dsp;
int mustmix, members;
- s32 mixbuffer[MAX_POLL+100], *c;
+ static s32 mixbuffer[MAX_POLL+100];
+ s32 *c;
u8 *p, *q;
int r, rr;
int jittercheck = 0, delay, i;
@@ -1890,10 +1927,8 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
/* no conf */
if (!dsp->conf) {
- /* in case of hardware (echo) */
- if (dsp->pcm_slot_tx >= 0)
- return;
- if (dsp->echo) {
+ /* in case of software echo */
+ if (dsp->echo.software) {
nskb = skb_clone(skb, GFP_ATOMIC);
if (nskb) {
hh = mISDN_HEAD_P(nskb);
@@ -1909,7 +1944,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
if (dsp->conf->hardware)
return;
list_for_each_entry(member, &dsp->conf->mlist, list) {
- if (dsp->echo || member->dsp != dsp) {
+ if (dsp->echo.software || member->dsp != dsp) {
nskb = skb_clone(skb, GFP_ATOMIC);
if (nskb) {
hh = mISDN_HEAD_P(nskb);
diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
index 3083338716b2..77ee2867c8b4 100644
--- a/drivers/isdn/mISDN/dsp_core.c
+++ b/drivers/isdn/mISDN/dsp_core.c
@@ -203,13 +203,13 @@ dsp_rx_off_member(struct dsp *dsp)
else if (dsp->dtmf.software)
rx_off = 0;
/* echo in software */
- else if (dsp->echo && dsp->pcm_slot_tx < 0)
+ else if (dsp->echo.software)
rx_off = 0;
/* bridge in software */
- else if (dsp->conf) {
- if (dsp->conf->software)
- rx_off = 0;
- }
+ else if (dsp->conf && dsp->conf->software)
+ rx_off = 0;
+ /* data is not required by user space and not required
+ * for echo dtmf detection, soft-echo, soft-bridging */
if (rx_off == dsp->rx_is_off)
return;
@@ -280,7 +280,7 @@ dsp_fill_empty(struct dsp *dsp)
static int
dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
{
- struct sk_buff *nskb;
+ struct sk_buff *nskb;
int ret = 0;
int cont;
u8 *data;
@@ -306,15 +306,18 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
"to %d\n", *((int *)data));
dsp->dtmf.treshold = (*(int *)data) * 10000;
}
+ dsp->dtmf.enable = 1;
/* init goertzel */
dsp_dtmf_goertzel_init(dsp);
/* check dtmf hardware */
dsp_dtmf_hardware(dsp);
+ dsp_rx_off(dsp);
break;
case DTMF_TONE_STOP: /* turn off DTMF */
if (dsp_debug & DEBUG_DSP_CORE)
printk(KERN_DEBUG "%s: stop dtmf\n", __func__);
+ dsp->dtmf.enable = 0;
dsp->dtmf.hardware = 0;
dsp->dtmf.software = 0;
break;
@@ -414,7 +417,7 @@ tone_off:
dsp_rx_off(dsp);
break;
case DSP_ECHO_ON: /* enable echo */
- dsp->echo = 1; /* soft echo */
+ dsp->echo.software = 1; /* soft echo */
if (dsp_debug & DEBUG_DSP_CORE)
printk(KERN_DEBUG "%s: enable cmx-echo\n", __func__);
dsp_cmx_hardware(dsp->conf, dsp);
@@ -423,7 +426,8 @@ tone_off:
dsp_cmx_debug(dsp);
break;
case DSP_ECHO_OFF: /* disable echo */
- dsp->echo = 0;
+ dsp->echo.software = 0;
+ dsp->echo.hardware = 0;
if (dsp_debug & DEBUG_DSP_CORE)
printk(KERN_DEBUG "%s: disable cmx-echo\n", __func__);
dsp_cmx_hardware(dsp->conf, dsp);
@@ -502,7 +506,7 @@ tone_off:
break;
}
dsp->cmx_delay = (*((int *)data)) << 3;
- /* miliseconds to samples */
+ /* milliseconds to samples */
if (dsp->cmx_delay >= (CMX_BUFF_HALF>>1))
/* clip to half of maximum usable buffer
(half of half buffer) */
@@ -556,7 +560,7 @@ tone_off:
dsp->pipeline.inuse = 1;
dsp_cmx_hardware(dsp->conf, dsp);
ret = dsp_pipeline_build(&dsp->pipeline,
- len > 0 ? (char *)data : NULL);
+ len > 0 ? data : NULL);
dsp_cmx_hardware(dsp->conf, dsp);
dsp_rx_off(dsp);
}
@@ -657,11 +661,10 @@ get_features(struct mISDNchannel *ch)
static int
dsp_function(struct mISDNchannel *ch, struct sk_buff *skb)
{
- struct dsp *dsp = container_of(ch, struct dsp, ch);
+ struct dsp *dsp = container_of(ch, struct dsp, ch);
struct mISDNhead *hh;
int ret = 0;
- u8 *digits;
- int cont;
+ u8 *digits = NULL;
u_long flags;
hh = mISDN_HEAD_P(skb);
@@ -704,50 +707,55 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb)
break;
}
+ spin_lock_irqsave(&dsp_lock, flags);
+
/* decrypt if enabled */
if (dsp->bf_enable)
dsp_bf_decrypt(dsp, skb->data, skb->len);
/* pipeline */
if (dsp->pipeline.inuse)
dsp_pipeline_process_rx(&dsp->pipeline, skb->data,
- skb->len);
+ skb->len, hh->id);
/* change volume if requested */
if (dsp->rx_volume)
dsp_change_volume(skb, dsp->rx_volume);
-
/* check if dtmf soft decoding is turned on */
if (dsp->dtmf.software) {
digits = dsp_dtmf_goertzel_decode(dsp, skb->data,
- skb->len, (dsp_options&DSP_OPT_ULAW)?1:0);
+ skb->len, (dsp_options&DSP_OPT_ULAW) ? 1 : 0);
+ }
+ /* we need to process receive data if software */
+ if (dsp->conf && dsp->conf->software) {
+ /* process data from card at cmx */
+ dsp_cmx_receive(dsp, skb);
+ }
+
+ spin_unlock_irqrestore(&dsp_lock, flags);
+
+ /* send dtmf result, if any */
+ if (digits) {
while (*digits) {
+ int k;
struct sk_buff *nskb;
if (dsp_debug & DEBUG_DSP_DTMF)
printk(KERN_DEBUG "%s: digit"
"(%c) to layer %s\n",
__func__, *digits, dsp->name);
- cont = DTMF_TONE_VAL | *digits;
+ k = *digits | DTMF_TONE_VAL;
nskb = _alloc_mISDN_skb(PH_CONTROL_IND,
- MISDN_ID_ANY, sizeof(int), &cont,
- GFP_ATOMIC);
+ MISDN_ID_ANY, sizeof(int), &k,
+ GFP_ATOMIC);
if (nskb) {
if (dsp->up) {
if (dsp->up->send(
dsp->up, nskb))
- dev_kfree_skb(nskb);
+ dev_kfree_skb(nskb);
} else
dev_kfree_skb(nskb);
}
digits++;
}
}
- /* we need to process receive data if software */
- spin_lock_irqsave(&dsp_lock, flags);
- if (dsp->pcm_slot_tx < 0 && dsp->pcm_slot_rx < 0) {
- /* process data from card at cmx */
- dsp_cmx_receive(dsp, skb);
- }
- spin_unlock_irqrestore(&dsp_lock, flags);
-
if (dsp->rx_disabled) {
/* if receive is not allowed */
break;
@@ -787,7 +795,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb)
if (dsp->up) {
if (dsp->up->send(
dsp->up, nskb))
- dev_kfree_skb(nskb);
+ dev_kfree_skb(nskb);
} else
dev_kfree_skb(nskb);
}
@@ -946,7 +954,7 @@ dsp_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
int err = 0;
if (debug & DEBUG_DSP_CTRL)
- printk(KERN_DEBUG "%s:(%x)\n", __func__, cmd);
+ printk(KERN_DEBUG "%s:(%x)\n", __func__, cmd);
switch (cmd) {
case OPEN_CHANNEL:
@@ -1169,9 +1177,9 @@ static int dsp_init(void)
/* init conversion tables */
dsp_audio_generate_law_tables();
- dsp_silence = (dsp_options&DSP_OPT_ULAW)?0xff:0x2a;
- dsp_audio_law_to_s32 = (dsp_options&DSP_OPT_ULAW)?dsp_audio_ulaw_to_s32:
- dsp_audio_alaw_to_s32;
+ dsp_silence = (dsp_options&DSP_OPT_ULAW) ? 0xff : 0x2a;
+ dsp_audio_law_to_s32 = (dsp_options&DSP_OPT_ULAW) ?
+ dsp_audio_ulaw_to_s32 : dsp_audio_alaw_to_s32;
dsp_audio_generate_s2law_table();
dsp_audio_generate_seven();
dsp_audio_generate_mix_table();
diff --git a/drivers/isdn/mISDN/dsp_dtmf.c b/drivers/isdn/mISDN/dsp_dtmf.c
index efc371c1f0dc..9ae2d33b06f7 100644
--- a/drivers/isdn/mISDN/dsp_dtmf.c
+++ b/drivers/isdn/mISDN/dsp_dtmf.c
@@ -51,6 +51,9 @@ void dsp_dtmf_hardware(struct dsp *dsp)
{
int hardware = 1;
+ if (!dsp->dtmf.enable)
+ return;
+
if (!dsp->features.hfc_dtmf)
hardware = 0;
diff --git a/drivers/isdn/mISDN/dsp_ecdis.h b/drivers/isdn/mISDN/dsp_ecdis.h
index 8a20af43308b..21dbd153ee26 100644
--- a/drivers/isdn/mISDN/dsp_ecdis.h
+++ b/drivers/isdn/mISDN/dsp_ecdis.h
@@ -91,7 +91,7 @@ int16_t amp)
&& det->tone_cycle_duration <= 475*8) {
det->good_cycles++;
if (det->good_cycles > 2)
- det->hit = TRUE;
+ det->hit = TRUE;
}
det->tone_cycle_duration = 0;
}
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 18cf87c113e7..ac61f198eb32 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -347,7 +347,8 @@ void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data, int len)
entry->elem->process_tx(entry->p, data, len);
}
-void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len)
+void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len,
+ unsigned int txlen)
{
struct dsp_pipeline_entry *entry;
@@ -356,7 +357,7 @@ void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len)
list_for_each_entry_reverse(entry, &pipeline->list, list)
if (entry->elem->process_rx)
- entry->elem->process_rx(entry->p, data, len);
+ entry->elem->process_rx(entry->p, data, len, txlen);
}
diff --git a/drivers/isdn/mISDN/dsp_tones.c b/drivers/isdn/mISDN/dsp_tones.c
index 7a9af66f4b19..1debf53670de 100644
--- a/drivers/isdn/mISDN/dsp_tones.c
+++ b/drivers/isdn/mISDN/dsp_tones.c
@@ -253,18 +253,24 @@ static struct pattern {
{8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
{TONE_GERMAN_DIALPBX,
- {DATA_GA, DATA_S, DATA_GA, DATA_S, DATA_GA, DATA_S, NULL, NULL, NULL, NULL},
- {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL},
+ {DATA_GA, DATA_S, DATA_GA, DATA_S, DATA_GA, DATA_S, NULL, NULL, NULL,
+ NULL},
+ {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, NULL, NULL, NULL,
+ NULL},
{2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} },
{TONE_GERMAN_OLDDIALPBX,
- {DATA_GO, DATA_S, DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, NULL},
- {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL},
+ {DATA_GO, DATA_S, DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL,
+ NULL},
+ {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL,
+ NULL},
{2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} },
{TONE_AMERICAN_DIALPBX,
- {DATA_DT, DATA_S, DATA_DT, DATA_S, DATA_DT, DATA_S, NULL, NULL, NULL, NULL},
- {SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, NULL, NULL, NULL, NULL},
+ {DATA_DT, DATA_S, DATA_DT, DATA_S, DATA_DT, DATA_S, NULL, NULL, NULL,
+ NULL},
+ {SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, NULL, NULL, NULL,
+ NULL},
{2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} },
{TONE_GERMAN_RINGING,
@@ -434,7 +440,7 @@ dsp_tone_hw_message(struct dsp *dsp, u8 *sample, int len)
/* unlocking is not required, because we don't expect a response */
nskb = _alloc_mISDN_skb(PH_CONTROL_REQ,
- (len)?HFC_SPL_LOOP_ON:HFC_SPL_LOOP_OFF, len, sample,
+ (len) ? HFC_SPL_LOOP_ON : HFC_SPL_LOOP_OFF, len, sample,
GFP_ATOMIC);
if (nskb) {
if (dsp->ch.peer) {
@@ -498,8 +504,7 @@ dsp_tone(struct dsp *dsp, int tone)
/* we turn off the tone */
if (!tone) {
- if (dsp->features.hfc_loops)
- if (timer_pending(&tonet->tl))
+ if (dsp->features.hfc_loops && timer_pending(&tonet->tl))
del_timer(&tonet->tl);
if (dsp->features.hfc_loops)
dsp_tone_hw_message(dsp, NULL, 0);
diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c
index ab1168a110ae..0481a0cdf6db 100644
--- a/drivers/isdn/mISDN/hwchannel.c
+++ b/drivers/isdn/mISDN/hwchannel.c
@@ -185,13 +185,13 @@ recv_Echannel(struct dchannel *ech, struct dchannel *dch)
EXPORT_SYMBOL(recv_Echannel);
void
-recv_Bchannel(struct bchannel *bch)
+recv_Bchannel(struct bchannel *bch, unsigned int id)
{
struct mISDNhead *hh;
hh = mISDN_HEAD_P(bch->rx_skb);
hh->prim = PH_DATA_IND;
- hh->id = MISDN_ID_ANY;
+ hh->id = id;
if (bch->rcount >= 64) {
printk(KERN_WARNING "B-channel %p receive queue overflow, "
"fushing!\n", bch);
diff --git a/drivers/isdn/mISDN/l1oip.h b/drivers/isdn/mISDN/l1oip.h
index a23d575449f6..bc26c890d9a2 100644
--- a/drivers/isdn/mISDN/l1oip.h
+++ b/drivers/isdn/mISDN/l1oip.h
@@ -76,7 +76,7 @@ struct l1oip {
struct sockaddr_in sin_local; /* local socket name */
struct sockaddr_in sin_remote; /* remote socket name */
struct msghdr sendmsg; /* ip message to send */
- struct iovec sendiov; /* iov for message */
+ struct kvec sendiov; /* iov for message */
/* frame */
struct l1oip_chan chan[128]; /* channel instances */
diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
index e4ecba3d48df..bbfd1b863ed3 100644
--- a/drivers/isdn/mISDN/l1oip_codec.c
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -48,6 +48,7 @@ NOTE: The bytes are handled as they are law-encoded.
#include <linux/vmalloc.h>
#include <linux/mISDNif.h>
+#include <linux/in.h>
#include "core.h"
#include "l1oip.h"
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index abe574989572..990e6a7e6674 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -279,7 +279,6 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
int multi = 0;
u8 frame[len+32];
struct socket *socket = NULL;
- mm_segment_t oldfs;
if (debug & DEBUG_L1OIP_MSG)
printk(KERN_DEBUG "%s: sending data to socket (len = %d)\n",
@@ -308,8 +307,8 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
/* assemble frame */
*p++ = (L1OIP_VERSION<<6) /* version and coding */
- | (hc->pri?0x20:0x00) /* type */
- | (hc->id?0x10:0x00) /* id */
+ | (hc->pri ? 0x20 : 0x00) /* type */
+ | (hc->id ? 0x10 : 0x00) /* id */
| localcodec;
if (hc->id) {
*p++ = hc->id>>24; /* id */
@@ -317,7 +316,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
*p++ = hc->id>>8;
*p++ = hc->id;
}
- *p++ = (multi == 1)?0x80:0x00 + channel; /* m-flag, channel */
+ *p++ = (multi == 1) ? 0x80 : 0x00 + channel; /* m-flag, channel */
if (multi == 1)
*p++ = len; /* length */
*p++ = timebase>>8; /* time base */
@@ -352,10 +351,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
"= %d)\n", __func__, len);
hc->sendiov.iov_base = frame;
hc->sendiov.iov_len = len;
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- len = sock_sendmsg(socket, &hc->sendmsg, len);
- set_fs(oldfs);
+ len = kernel_sendmsg(socket, &hc->sendmsg, &hc->sendiov, 1, len);
/* give socket back */
hc->socket = socket; /* no locking required */
@@ -401,12 +397,12 @@ l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase,
}
/* prepare message */
- nskb = mI_alloc_skb((remotecodec == 3)?(len<<1):len, GFP_ATOMIC);
+ nskb = mI_alloc_skb((remotecodec == 3) ? (len<<1) : len, GFP_ATOMIC);
if (!nskb) {
printk(KERN_ERR "%s: No mem for skb.\n", __func__);
return;
}
- p = skb_put(nskb, (remotecodec == 3)?(len<<1):len);
+ p = skb_put(nskb, (remotecodec == 3) ? (len<<1) : len);
if (remotecodec == 1 && ulaw)
l1oip_alaw_to_ulaw(buf, len, p);
@@ -458,7 +454,7 @@ l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase,
hc->chan[channel].disorder_flag ^= 1;
if (nskb)
#endif
- queue_ch_frame(&bch->ch, PH_DATA_IND, rx_counter, nskb);
+ queue_ch_frame(&bch->ch, PH_DATA_IND, rx_counter, nskb);
}
}
@@ -660,21 +656,29 @@ l1oip_socket_thread(void *data)
struct l1oip *hc = (struct l1oip *)data;
int ret = 0;
struct msghdr msg;
- struct iovec iov;
- mm_segment_t oldfs;
struct sockaddr_in sin_rx;
- unsigned char recvbuf[1500];
+ unsigned char *recvbuf;
+ size_t recvbuf_size = 1500;
int recvlen;
struct socket *socket = NULL;
DECLARE_COMPLETION(wait);
+ /* allocate buffer memory */
+ recvbuf = kmalloc(recvbuf_size, GFP_KERNEL);
+ if (!recvbuf) {
+ printk(KERN_ERR "%s: Failed to alloc recvbuf.\n", __func__);
+ ret = -ENOMEM;
+ goto fail;
+ }
+
/* make daemon */
allow_signal(SIGTERM);
/* create socket */
if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) {
printk(KERN_ERR "%s: Failed to create socket.\n", __func__);
- return -EIO;
+ ret = -EIO;
+ goto fail;
}
/* set incoming address */
@@ -708,16 +712,12 @@ l1oip_socket_thread(void *data)
msg.msg_namelen = sizeof(sin_rx);
msg.msg_control = NULL;
msg.msg_controllen = 0;
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
/* build send message */
hc->sendmsg.msg_name = &hc->sin_remote;
hc->sendmsg.msg_namelen = sizeof(hc->sin_remote);
hc->sendmsg.msg_control = NULL;
hc->sendmsg.msg_controllen = 0;
- hc->sendmsg.msg_iov = &hc->sendiov;
- hc->sendmsg.msg_iovlen = 1;
/* give away socket */
spin_lock(&hc->socket_lock);
@@ -729,18 +729,18 @@ l1oip_socket_thread(void *data)
printk(KERN_DEBUG "%s: socket created and open\n",
__func__);
while (!signal_pending(current)) {
- iov.iov_base = recvbuf;
- iov.iov_len = sizeof(recvbuf);
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- recvlen = sock_recvmsg(socket, &msg, sizeof(recvbuf), 0);
- set_fs(oldfs);
+ struct kvec iov = {
+ .iov_base = recvbuf,
+ .iov_len = sizeof(recvbuf),
+ };
+ recvlen = kernel_recvmsg(socket, &msg, &iov, 1,
+ sizeof(recvbuf), 0);
if (recvlen > 0) {
l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
} else {
if (debug & DEBUG_L1OIP_SOCKET)
- printk(KERN_WARNING "%s: broken pipe on socket\n",
- __func__);
+ printk(KERN_WARNING
+ "%s: broken pipe on socket\n", __func__);
}
}
@@ -760,6 +760,9 @@ l1oip_socket_thread(void *data)
__func__);
fail:
+ /* free recvbuf */
+ kfree(recvbuf);
+
/* close socket */
if (socket)
sock_release(socket);
@@ -912,7 +915,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
p = skb->data;
l = skb->len;
while (l) {
- ll = (l < L1OIP_MAX_PERFRAME)?l:L1OIP_MAX_PERFRAME;
+ ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME;
l1oip_socket_send(hc, 0, dch->slot, 0,
hc->chan[dch->slot].tx_counter++, p, ll);
p += ll;
@@ -1160,7 +1163,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
p = skb->data;
l = skb->len;
while (l) {
- ll = (l < L1OIP_MAX_PERFRAME)?l:L1OIP_MAX_PERFRAME;
+ ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME;
l1oip_socket_send(hc, hc->codec, bch->slot, 0,
hc->chan[bch->slot].tx_counter, p, ll);
hc->chan[bch->slot].tx_counter += ll;
@@ -1318,8 +1321,8 @@ init_card(struct l1oip *hc, int pri, int bundle)
spin_lock_init(&hc->socket_lock);
hc->idx = l1oip_cnt;
hc->pri = pri;
- hc->d_idx = pri?16:3;
- hc->b_num = pri?30:2;
+ hc->d_idx = pri ? 16 : 3;
+ hc->b_num = pri ? 30 : 2;
hc->bundle = bundle;
if (hc->pri)
sprintf(hc->name, "l1oip-e1.%d", l1oip_cnt + 1);
@@ -1504,9 +1507,9 @@ l1oip_init(void)
if (debug & DEBUG_L1OIP_INIT)
printk(KERN_DEBUG "%s: interface %d is %s with %s.\n",
- __func__, l1oip_cnt, pri?"PRI":"BRI",
- bundle?"bundled IP packet for all B-channels"
- :"seperate IP packets for every B-channel");
+ __func__, l1oip_cnt, pri ? "PRI" : "BRI",
+ bundle ? "bundled IP packet for all B-channels" :
+ "seperate IP packets for every B-channel");
hc = kzalloc(sizeof(struct l1oip), GFP_ATOMIC);
if (!hc) {
diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c
index d6e2863f224a..9c2589e986d6 100644
--- a/drivers/isdn/mISDN/layer2.c
+++ b/drivers/isdn/mISDN/layer2.c
@@ -99,7 +99,7 @@ l2m_debug(struct FsmInst *fi, char *fmt, ...)
if (!(*debug & DEBUG_L2_FSM))
return;
va_start(va, fmt);
- printk(KERN_DEBUG "l2 (tei %d): ", l2->tei);
+ printk(KERN_DEBUG "l2 (sapi %d tei %d): ", l2->sapi, l2->tei);
vprintk(fmt, va);
printk("\n");
va_end(va);
@@ -1859,20 +1859,18 @@ ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb)
psapi >>= 2;
ptei >>= 1;
if (psapi != l2->sapi) {
- /* not our bussiness
- * printk(KERN_DEBUG "%s: sapi %d/%d sapi mismatch\n",
- * __func__,
- * psapi, l2->sapi);
- */
+ /* not our bussiness */
+ if (*debug & DEBUG_L2)
+ printk(KERN_DEBUG "%s: sapi %d/%d mismatch\n",
+ __func__, psapi, l2->sapi);
dev_kfree_skb(skb);
return 0;
}
if ((ptei != l2->tei) && (ptei != GROUP_TEI)) {
- /* not our bussiness
- * printk(KERN_DEBUG "%s: tei %d/%d sapi %d mismatch\n",
- * __func__,
- * ptei, l2->tei, psapi);
- */
+ /* not our bussiness */
+ if (*debug & DEBUG_L2)
+ printk(KERN_DEBUG "%s: tei %d/%d mismatch\n",
+ __func__, ptei, l2->tei);
dev_kfree_skb(skb);
return 0;
}
@@ -1927,8 +1925,8 @@ l2_send(struct mISDNchannel *ch, struct sk_buff *skb)
int ret = -EINVAL;
if (*debug & DEBUG_L2_RECV)
- printk(KERN_DEBUG "%s: prim(%x) id(%x) tei(%d)\n",
- __func__, hh->prim, hh->id, l2->tei);
+ printk(KERN_DEBUG "%s: prim(%x) id(%x) sapi(%d) tei(%d)\n",
+ __func__, hh->prim, hh->id, l2->sapi, l2->tei);
switch (hh->prim) {
case PH_DATA_IND:
ret = ph_data_indication(l2, hh, skb);
@@ -2068,7 +2066,8 @@ l2_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
}
struct layer2 *
-create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
+create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, int tei,
+ int sapi)
{
struct layer2 *l2;
struct channel_req rq;
@@ -2089,7 +2088,7 @@ create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
test_and_set_bit(FLG_LAPD, &l2->flag);
test_and_set_bit(FLG_LAPD_NET, &l2->flag);
test_and_set_bit(FLG_MOD128, &l2->flag);
- l2->sapi = 0;
+ l2->sapi = sapi;
l2->maxlen = MAX_DFRAME_LEN;
if (test_bit(OPTION_L2_PMX, &options))
l2->window = 7;
@@ -2099,7 +2098,7 @@ create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
test_and_set_bit(FLG_PTP, &l2->flag);
if (test_bit(OPTION_L2_FIXEDTEI, &options))
test_and_set_bit(FLG_FIXED_TEI, &l2->flag);
- l2->tei = (u_int)arg;
+ l2->tei = tei;
l2->T200 = 1000;
l2->N200 = 3;
l2->T203 = 10000;
@@ -2114,7 +2113,7 @@ create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
test_and_set_bit(FLG_LAPD, &l2->flag);
test_and_set_bit(FLG_MOD128, &l2->flag);
test_and_set_bit(FLG_ORIG, &l2->flag);
- l2->sapi = 0;
+ l2->sapi = sapi;
l2->maxlen = MAX_DFRAME_LEN;
if (test_bit(OPTION_L2_PMX, &options))
l2->window = 7;
@@ -2124,7 +2123,7 @@ create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
test_and_set_bit(FLG_PTP, &l2->flag);
if (test_bit(OPTION_L2_FIXEDTEI, &options))
test_and_set_bit(FLG_FIXED_TEI, &l2->flag);
- l2->tei = (u_int)arg;
+ l2->tei = tei;
l2->T200 = 1000;
l2->N200 = 3;
l2->T203 = 10000;
@@ -2180,7 +2179,7 @@ x75create(struct channel_req *crq)
if (crq->protocol != ISDN_P_B_X75SLP)
return -EPROTONOSUPPORT;
- l2 = create_l2(crq->ch, crq->protocol, 0, 0);
+ l2 = create_l2(crq->ch, crq->protocol, 0, 0, 0);
if (!l2)
return -ENOMEM;
crq->ch = &l2->ch;
diff --git a/drivers/isdn/mISDN/layer2.h b/drivers/isdn/mISDN/layer2.h
index 6293f80dc2d3..9547fb3707a3 100644
--- a/drivers/isdn/mISDN/layer2.h
+++ b/drivers/isdn/mISDN/layer2.h
@@ -90,7 +90,7 @@ enum {
#define L2_STATE_COUNT (ST_L2_8+1)
extern struct layer2 *create_l2(struct mISDNchannel *, u_int,
- u_long, u_long);
+ u_long, int, int);
extern int tei_l2(struct layer2 *, u_int, u_long arg);
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 508945d1b9c1..c36f52137456 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -209,7 +209,7 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
err = -EFAULT;
- goto drop;
+ goto done;
}
memcpy(mISDN_HEAD_P(skb), skb->data, MISDN_HEADER_LEN);
@@ -222,7 +222,7 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
} else { /* use default for L2 messages */
if ((sk->sk_protocol == ISDN_P_LAPD_TE) ||
(sk->sk_protocol == ISDN_P_LAPD_NT))
- mISDN_HEAD_ID(skb) = _pms(sk)->ch.nr;
+ mISDN_HEAD_ID(skb) = _pms(sk)->ch.nr;
}
if (*debug & DEBUG_SOCKET)
@@ -230,19 +230,21 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
__func__, mISDN_HEAD_ID(skb));
err = -ENODEV;
- if (!_pms(sk)->ch.peer ||
- (err = _pms(sk)->ch.recv(_pms(sk)->ch.peer, skb)))
- goto drop;
-
- err = len;
+ if (!_pms(sk)->ch.peer)
+ goto done;
+ err = _pms(sk)->ch.recv(_pms(sk)->ch.peer, skb);
+ if (err)
+ goto done;
+ else {
+ skb = NULL;
+ err = len;
+ }
done:
+ if (skb)
+ kfree_skb(skb);
release_sock(sk);
return err;
-
-drop:
- kfree_skb(skb);
- goto done;
}
static int
@@ -292,7 +294,7 @@ static int
data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p)
{
struct mISDN_ctrl_req cq;
- int err = -EINVAL, val;
+ int err = -EINVAL, val[2];
struct mISDNchannel *bchan, *next;
lock_sock(sk);
@@ -328,12 +330,27 @@ data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p)
err = -EINVAL;
break;
}
- if (get_user(val, (int __user *)p)) {
+ val[0] = cmd;
+ if (get_user(val[1], (int __user *)p)) {
+ err = -EFAULT;
+ break;
+ }
+ err = _pms(sk)->dev->teimgr->ctrl(_pms(sk)->dev->teimgr,
+ CONTROL_CHANNEL, val);
+ break;
+ case IMHOLD_L1:
+ if (sk->sk_protocol != ISDN_P_LAPD_NT
+ && sk->sk_protocol != ISDN_P_LAPD_TE) {
+ err = -EINVAL;
+ break;
+ }
+ val[0] = cmd;
+ if (get_user(val[1], (int __user *)p)) {
err = -EFAULT;
break;
}
err = _pms(sk)->dev->teimgr->ctrl(_pms(sk)->dev->teimgr,
- CONTROL_CHANNEL, &val);
+ CONTROL_CHANNEL, val);
break;
default:
err = -EINVAL;
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
index b452dead8fd0..bfcdd97df95d 100644
--- a/drivers/isdn/mISDN/tei.c
+++ b/drivers/isdn/mISDN/tei.c
@@ -122,8 +122,11 @@ da_deactivate(struct FsmInst *fi, int event, void *arg)
}
read_unlock_irqrestore(&mgr->lock, flags);
/* All TEI are inactiv */
- mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, NULL, 1);
- mISDN_FsmChangeState(fi, ST_L1_DEACT_PENDING);
+ if (!test_bit(OPTION_L1_HOLD, &mgr->options)) {
+ mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER,
+ NULL, 1);
+ mISDN_FsmChangeState(fi, ST_L1_DEACT_PENDING);
+ }
}
static void
@@ -132,9 +135,11 @@ da_ui(struct FsmInst *fi, int event, void *arg)
struct manager *mgr = fi->userdata;
/* restart da timer */
- mISDN_FsmDelTimer(&mgr->datimer, 2);
- mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, NULL, 2);
-
+ if (!test_bit(OPTION_L1_HOLD, &mgr->options)) {
+ mISDN_FsmDelTimer(&mgr->datimer, 2);
+ mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER,
+ NULL, 2);
+ }
}
static void
@@ -222,7 +227,7 @@ tei_debug(struct FsmInst *fi, char *fmt, ...)
if (!(*debug & DEBUG_L2_TEIFSM))
return;
va_start(va, fmt);
- printk(KERN_DEBUG "tei(%d): ", tm->l2->tei);
+ printk(KERN_DEBUG "sapi(%d) tei(%d): ", tm->l2->sapi, tm->l2->tei);
vprintk(fmt, va);
printk("\n");
va_end(va);
@@ -421,7 +426,7 @@ done:
}
static void
-put_tei_msg(struct manager *mgr, u_char m_id, unsigned int ri, u_char tei)
+put_tei_msg(struct manager *mgr, u_char m_id, unsigned int ri, int tei)
{
struct sk_buff *skb;
u_char bp[8];
@@ -435,9 +440,8 @@ put_tei_msg(struct manager *mgr, u_char m_id, unsigned int ri, u_char tei)
bp[4] = ri >> 8;
bp[5] = ri & 0xff;
bp[6] = m_id;
- bp[7] = (tei << 1) | 1;
- skb = _alloc_mISDN_skb(PH_DATA_REQ, new_id(mgr),
- 8, bp, GFP_ATOMIC);
+ bp[7] = ((tei << 1) & 0xff) | 1;
+ skb = _alloc_mISDN_skb(PH_DATA_REQ, new_id(mgr), 8, bp, GFP_ATOMIC);
if (!skb) {
printk(KERN_WARNING "%s: no skb for tei msg\n", __func__);
return;
@@ -772,7 +776,7 @@ tei_ph_data_ind(struct teimgr *tm, u_int mt, u_char *dp, int len)
}
static struct layer2 *
-create_new_tei(struct manager *mgr, int tei)
+create_new_tei(struct manager *mgr, int tei, int sapi)
{
u_long opt = 0;
u_long flags;
@@ -781,12 +785,12 @@ create_new_tei(struct manager *mgr, int tei)
if (!mgr->up)
return NULL;
- if (tei < 64)
+ if ((tei >= 0) && (tei < 64))
test_and_set_bit(OPTION_L2_FIXEDTEI, &opt);
if (mgr->ch.st->dev->Dprotocols
& ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1)))
test_and_set_bit(OPTION_L2_PMX, &opt);
- l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, (u_int)opt, (u_long)tei);
+ l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, opt, tei, sapi);
if (!l2) {
printk(KERN_WARNING "%s:no memory for layer2\n", __func__);
return NULL;
@@ -834,12 +838,17 @@ new_tei_req(struct manager *mgr, u_char *dp)
ri += dp[1];
if (!mgr->up)
goto denied;
- tei = get_free_tei(mgr);
+ if (!(dp[3] & 1)) /* Extension bit != 1 */
+ goto denied;
+ if (dp[3] != 0xff)
+ tei = dp[3] >> 1; /* 3GPP TS 08.56 6.1.11.2 */
+ else
+ tei = get_free_tei(mgr);
if (tei < 0) {
printk(KERN_WARNING "%s:No free tei\n", __func__);
goto denied;
}
- l2 = create_new_tei(mgr, tei);
+ l2 = create_new_tei(mgr, tei, CTRL_SAPI);
if (!l2)
goto denied;
else
@@ -863,7 +872,6 @@ ph_data_ind(struct manager *mgr, struct sk_buff *skb)
__func__, skb->len);
goto done;
}
- if (*debug & DEBUG_L2_TEI)
if ((skb->data[0] >> 2) != TEI_SAPI) /* not for us */
goto done;
@@ -971,8 +979,6 @@ create_teimgr(struct manager *mgr, struct channel_req *crq)
__func__, dev_name(&mgr->ch.st->dev->dev),
crq->protocol, crq->adr.dev, crq->adr.channel,
crq->adr.sapi, crq->adr.tei);
- if (crq->adr.sapi != 0) /* not supported yet */
- return -EINVAL;
if (crq->adr.tei > GROUP_TEI)
return -EINVAL;
if (crq->adr.tei < 64)
@@ -1019,8 +1025,8 @@ create_teimgr(struct manager *mgr, struct channel_req *crq)
}
return 0;
}
- l2 = create_l2(crq->ch, crq->protocol, (u_int)opt,
- (u_long)crq->adr.tei);
+ l2 = create_l2(crq->ch, crq->protocol, opt,
+ crq->adr.tei, crq->adr.sapi);
if (!l2)
return -ENOMEM;
l2->tm = kzalloc(sizeof(struct teimgr), GFP_KERNEL);
@@ -1103,6 +1109,7 @@ free_teimanager(struct manager *mgr)
{
struct layer2 *l2, *nl2;
+ test_and_clear_bit(OPTION_L1_HOLD, &mgr->options);
if (test_bit(MGR_OPT_NETWORK, &mgr->options)) {
/* not locked lock is taken in release tei */
mgr->up = NULL;
@@ -1133,13 +1140,26 @@ static int
ctrl_teimanager(struct manager *mgr, void *arg)
{
/* currently we only have one option */
- int clean = *((int *)arg);
-
- if (clean)
- test_and_set_bit(OPTION_L2_CLEANUP, &mgr->options);
- else
- test_and_clear_bit(OPTION_L2_CLEANUP, &mgr->options);
- return 0;
+ int *val = (int *)arg;
+ int ret = 0;
+
+ switch (val[0]) {
+ case IMCLEAR_L2:
+ if (val[1])
+ test_and_set_bit(OPTION_L2_CLEANUP, &mgr->options);
+ else
+ test_and_clear_bit(OPTION_L2_CLEANUP, &mgr->options);
+ break;
+ case IMHOLD_L1:
+ if (val[1])
+ test_and_set_bit(OPTION_L1_HOLD, &mgr->options);
+ else
+ test_and_clear_bit(OPTION_L1_HOLD, &mgr->options);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ return ret;
}
/* This function does create a L2 for fixed TEI in NT Mode */
@@ -1147,7 +1167,7 @@ static int
check_data(struct manager *mgr, struct sk_buff *skb)
{
struct mISDNhead *hh = mISDN_HEAD_P(skb);
- int ret, tei;
+ int ret, tei, sapi;
struct layer2 *l2;
if (*debug & DEBUG_L2_CTRL)
@@ -1159,20 +1179,27 @@ check_data(struct manager *mgr, struct sk_buff *skb)
return -ENOTCONN;
if (skb->len != 3)
return -ENOTCONN;
- if (skb->data[0] != 0)
- /* only SAPI 0 command */
- return -ENOTCONN;
+ if (skb->data[0] & 3) /* EA0 and CR must be 0 */
+ return -EINVAL;
+ sapi = skb->data[0] >> 2;
if (!(skb->data[1] & 1)) /* invalid EA1 */
return -EINVAL;
- tei = skb->data[1] >> 0;
+ tei = skb->data[1] >> 1;
if (tei > 63) /* not a fixed tei */
return -ENOTCONN;
if ((skb->data[2] & ~0x10) != SABME)
return -ENOTCONN;
/* We got a SABME for a fixed TEI */
- l2 = create_new_tei(mgr, tei);
- if (!l2)
+ if (*debug & DEBUG_L2_CTRL)
+ printk(KERN_DEBUG "%s: SABME sapi(%d) tei(%d)\n",
+ __func__, sapi, tei);
+ l2 = create_new_tei(mgr, tei, sapi);
+ if (!l2) {
+ if (*debug & DEBUG_L2_CTRL)
+ printk(KERN_DEBUG "%s: failed to create new tei\n",
+ __func__);
return -ENOMEM;
+ }
ret = l2->ch.send(&l2->ch, skb);
return ret;
}
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index bbd99d3282c0..5b7e9bf514f1 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -259,7 +259,7 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
return ret;
}
-static struct file_operations mISDN_fops = {
+static const struct file_operations mISDN_fops = {
.read = mISDN_read,
.poll = mISDN_poll,
.ioctl = mISDN_ioctl,
diff --git a/drivers/leds/leds-h1940.c b/drivers/leds/leds-h1940.c
index 1aa46a390a0d..173d104d9ff2 100644
--- a/drivers/leds/leds-h1940.c
+++ b/drivers/leds/leds-h1940.c
@@ -16,6 +16,8 @@
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/leds.h>
+#include <linux/gpio.h>
+
#include <mach/regs-gpio.h>
#include <mach/hardware.h>
#include <mach/h1940-latch.h>
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index aa2e7ae0cdae..aa7acf3b9224 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
+#include <linux/gpio.h>
#include <mach/hardware.h>
#include <mach/regs-gpio.h>
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 4845fb3cf74b..be62e9f26e59 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -188,6 +188,9 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
{
/* We stop running once the Guest is dead. */
while (!cpu->lg->dead) {
+ unsigned int irq;
+ bool more;
+
/* First we run any hypercalls the Guest wants done. */
if (cpu->hcall)
do_hypercalls(cpu);
@@ -195,23 +198,23 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
/* It's possible the Guest did a NOTIFY hypercall to the
* Launcher, in which case we return from the read() now. */
if (cpu->pending_notify) {
- if (put_user(cpu->pending_notify, user))
- return -EFAULT;
- return sizeof(cpu->pending_notify);
+ if (!send_notify_to_eventfd(cpu)) {
+ if (put_user(cpu->pending_notify, user))
+ return -EFAULT;
+ return sizeof(cpu->pending_notify);
+ }
}
/* Check for signals */
if (signal_pending(current))
return -ERESTARTSYS;
- /* If Waker set break_out, return to Launcher. */
- if (cpu->break_out)
- return -EAGAIN;
-
/* Check if there are any interrupts which can be delivered now:
* if so, this sets up the hander to be executed when we next
* run the Guest. */
- maybe_do_interrupt(cpu);
+ irq = interrupt_pending(cpu, &more);
+ if (irq < LGUEST_IRQS)
+ try_deliver_interrupt(cpu, irq, more);
/* All long-lived kernel loops need to check with this horrible
* thing called the freezer. If the Host is trying to suspend,
@@ -224,10 +227,15 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
break;
/* If the Guest asked to be stopped, we sleep. The Guest's
- * clock timer or LHREQ_BREAK from the Waker will wake us. */
+ * clock timer will wake us. */
if (cpu->halted) {
set_current_state(TASK_INTERRUPTIBLE);
- schedule();
+ /* Just before we sleep, make sure no interrupt snuck in
+ * which we should be doing. */
+ if (interrupt_pending(cpu, &more) < LGUEST_IRQS)
+ set_current_state(TASK_RUNNING);
+ else
+ schedule();
continue;
}
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c
index 54d66f05fefa..f252b71ae79e 100644
--- a/drivers/lguest/hypercalls.c
+++ b/drivers/lguest/hypercalls.c
@@ -37,6 +37,10 @@ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
/* This call does nothing, except by breaking out of the Guest
* it makes us process all the asynchronous hypercalls. */
break;
+ case LHCALL_SEND_INTERRUPTS:
+ /* This call does nothing too, but by breaking out of the Guest
+ * it makes us process any pending interrupts. */
+ break;
case LHCALL_LGUEST_INIT:
/* You can't get here unless you're already initialized. Don't
* do that. */
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 6e99adbe1946..0e9067b0d507 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -128,30 +128,39 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi,
/*H:205
* Virtual Interrupts.
*
- * maybe_do_interrupt() gets called before every entry to the Guest, to see if
- * we should divert the Guest to running an interrupt handler. */
-void maybe_do_interrupt(struct lg_cpu *cpu)
+ * interrupt_pending() returns the first pending interrupt which isn't blocked
+ * by the Guest. It is called before every entry to the Guest, and just before
+ * we go to sleep when the Guest has halted itself. */
+unsigned int interrupt_pending(struct lg_cpu *cpu, bool *more)
{
unsigned int irq;
DECLARE_BITMAP(blk, LGUEST_IRQS);
- struct desc_struct *idt;
/* If the Guest hasn't even initialized yet, we can do nothing. */
if (!cpu->lg->lguest_data)
- return;
+ return LGUEST_IRQS;
/* Take our "irqs_pending" array and remove any interrupts the Guest
* wants blocked: the result ends up in "blk". */
if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts,
sizeof(blk)))
- return;
+ return LGUEST_IRQS;
bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS);
/* Find the first interrupt. */
irq = find_first_bit(blk, LGUEST_IRQS);
- /* None? Nothing to do */
- if (irq >= LGUEST_IRQS)
- return;
+ *more = find_next_bit(blk, LGUEST_IRQS, irq+1);
+
+ return irq;
+}
+
+/* This actually diverts the Guest to running an interrupt handler, once an
+ * interrupt has been identified by interrupt_pending(). */
+void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq, bool more)
+{
+ struct desc_struct *idt;
+
+ BUG_ON(irq >= LGUEST_IRQS);
/* They may be in the middle of an iret, where they asked us never to
* deliver interrupts. */
@@ -170,8 +179,12 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
u32 irq_enabled;
if (get_user(irq_enabled, &cpu->lg->lguest_data->irq_enabled))
irq_enabled = 0;
- if (!irq_enabled)
+ if (!irq_enabled) {
+ /* Make sure they know an IRQ is pending. */
+ put_user(X86_EFLAGS_IF,
+ &cpu->lg->lguest_data->irq_pending);
return;
+ }
}
/* Look at the IDT entry the Guest gave us for this interrupt. The
@@ -194,6 +207,25 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
* here is a compromise which means at least it gets updated every
* timer interrupt. */
write_timestamp(cpu);
+
+ /* If there are no other interrupts we want to deliver, clear
+ * the pending flag. */
+ if (!more)
+ put_user(0, &cpu->lg->lguest_data->irq_pending);
+}
+
+/* And this is the routine when we want to set an interrupt for the Guest. */
+void set_interrupt(struct lg_cpu *cpu, unsigned int irq)
+{
+ /* Next time the Guest runs, the core code will see if it can deliver
+ * this interrupt. */
+ set_bit(irq, cpu->irqs_pending);
+
+ /* Make sure it sees it; it might be asleep (eg. halted), or
+ * running the Guest right now, in which case kick_process()
+ * will knock it out. */
+ if (!wake_up_process(cpu->tsk))
+ kick_process(cpu->tsk);
}
/*:*/
@@ -510,10 +542,7 @@ static enum hrtimer_restart clockdev_fn(struct hrtimer *timer)
struct lg_cpu *cpu = container_of(timer, struct lg_cpu, hrt);
/* Remember the first interrupt is the timer interrupt. */
- set_bit(0, cpu->irqs_pending);
- /* If the Guest is actually stopped, we need to wake it up. */
- if (cpu->halted)
- wake_up_process(cpu->tsk);
+ set_interrupt(cpu, 0);
return HRTIMER_NORESTART;
}
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index af92a176697f..554d735a122a 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -71,9 +71,7 @@ struct lg_cpu {
/* Virtual clock device */
struct hrtimer hrt;
- /* Do we need to stop what we're doing and return to userspace? */
- int break_out;
- wait_queue_head_t break_wq;
+ /* Did the Guest tell us to halt? */
int halted;
/* Pending virtual interrupts */
@@ -82,6 +80,11 @@ struct lg_cpu {
struct lg_cpu_arch arch;
};
+struct lg_eventfds {
+ unsigned long addr;
+ struct file *event;
+};
+
/* The private info the thread maintains about the guest. */
struct lguest
{
@@ -102,6 +105,9 @@ struct lguest
unsigned int stack_pages;
u32 tsc_khz;
+ unsigned int num_eventfds;
+ struct lg_eventfds *eventfds;
+
/* Dead? */
const char *dead;
};
@@ -139,7 +145,9 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user);
#define pgd_pfn(x) (pgd_val(x) >> PAGE_SHIFT)
/* interrupts_and_traps.c: */
-void maybe_do_interrupt(struct lg_cpu *cpu);
+unsigned int interrupt_pending(struct lg_cpu *cpu, bool *more);
+void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq, bool more);
+void set_interrupt(struct lg_cpu *cpu, unsigned int irq);
bool deliver_trap(struct lg_cpu *cpu, unsigned int num);
void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int i,
u32 low, u32 hi);
@@ -150,6 +158,7 @@ void setup_default_idt_entries(struct lguest_ro_state *state,
void copy_traps(const struct lg_cpu *cpu, struct desc_struct *idt,
const unsigned long *def);
void guest_set_clockevent(struct lg_cpu *cpu, unsigned long delta);
+bool send_notify_to_eventfd(struct lg_cpu *cpu);
void init_clockdev(struct lg_cpu *cpu);
bool check_syscall_vector(struct lguest *lg);
int init_interrupts(void);
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index df44d962626d..e082cdac88b4 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -228,7 +228,8 @@ extern void lguest_setup_irq(unsigned int irq);
* function. */
static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
unsigned index,
- void (*callback)(struct virtqueue *vq))
+ void (*callback)(struct virtqueue *vq),
+ const char *name)
{
struct lguest_device *ldev = to_lgdev(vdev);
struct lguest_vq_info *lvq;
@@ -263,7 +264,7 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
/* OK, tell virtio_ring.c to set up a virtqueue now we know its size
* and we've got a pointer to its pages. */
vq = vring_new_virtqueue(lvq->config.num, LGUEST_VRING_ALIGN,
- vdev, lvq->pages, lg_notify, callback);
+ vdev, lvq->pages, lg_notify, callback, name);
if (!vq) {
err = -ENOMEM;
goto unmap;
@@ -312,6 +313,38 @@ static void lg_del_vq(struct virtqueue *vq)
kfree(lvq);
}
+static void lg_del_vqs(struct virtio_device *vdev)
+{
+ struct virtqueue *vq, *n;
+
+ list_for_each_entry_safe(vq, n, &vdev->vqs, list)
+ lg_del_vq(vq);
+}
+
+static int lg_find_vqs(struct virtio_device *vdev, unsigned nvqs,
+ struct virtqueue *vqs[],
+ vq_callback_t *callbacks[],
+ const char *names[])
+{
+ struct lguest_device *ldev = to_lgdev(vdev);
+ int i;
+
+ /* We must have this many virtqueues. */
+ if (nvqs > ldev->desc->num_vq)
+ return -ENOENT;
+
+ for (i = 0; i < nvqs; ++i) {
+ vqs[i] = lg_find_vq(vdev, i, callbacks[i], names[i]);
+ if (IS_ERR(vqs[i]))
+ goto error;
+ }
+ return 0;
+
+error:
+ lg_del_vqs(vdev);
+ return PTR_ERR(vqs[i]);
+}
+
/* The ops structure which hooks everything together. */
static struct virtio_config_ops lguest_config_ops = {
.get_features = lg_get_features,
@@ -321,8 +354,8 @@ static struct virtio_config_ops lguest_config_ops = {
.get_status = lg_get_status,
.set_status = lg_set_status,
.reset = lg_reset,
- .find_vq = lg_find_vq,
- .del_vq = lg_del_vq,
+ .find_vqs = lg_find_vqs,
+ .del_vqs = lg_del_vqs,
};
/* The root device for the lguest virtio devices. This makes them appear as
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index b8ee103eed5f..27a433613d77 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -7,32 +7,72 @@
#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/sched.h>
+#include <linux/eventfd.h>
+#include <linux/file.h>
#include "lg.h"
-/*L:055 When something happens, the Waker process needs a way to stop the
- * kernel running the Guest and return to the Launcher. So the Waker writes
- * LHREQ_BREAK and the value "1" to /dev/lguest to do this. Once the Launcher
- * has done whatever needs attention, it writes LHREQ_BREAK and "0" to release
- * the Waker. */
-static int break_guest_out(struct lg_cpu *cpu, const unsigned long __user*input)
+bool send_notify_to_eventfd(struct lg_cpu *cpu)
{
- unsigned long on;
+ unsigned int i;
+
+ /* lg->eventfds is RCU-protected */
+ preempt_disable();
+ for (i = 0; i < cpu->lg->num_eventfds; i++) {
+ if (cpu->lg->eventfds[i].addr == cpu->pending_notify) {
+ eventfd_signal(cpu->lg->eventfds[i].event, 1);
+ cpu->pending_notify = 0;
+ break;
+ }
+ }
+ preempt_enable();
+ return cpu->pending_notify == 0;
+}
+
+static int add_eventfd(struct lguest *lg, unsigned long addr, int fd)
+{
+ struct lg_eventfds *new, *old;
+
+ if (!addr)
+ return -EINVAL;
- /* Fetch whether they're turning break on or off. */
- if (get_user(on, input) != 0)
+ /* Replace the old array with the new one, carefully: others can
+ * be accessing it at the same time */
+ new = kmalloc(sizeof(*new) * (lg->num_eventfds + 1), GFP_KERNEL);
+ if (!new)
+ return -ENOMEM;
+
+ memcpy(new, lg->eventfds, sizeof(*new) * lg->num_eventfds);
+ old = lg->eventfds;
+ lg->eventfds = new;
+ synchronize_rcu();
+ kfree(old);
+
+ lg->eventfds[lg->num_eventfds].addr = addr;
+ lg->eventfds[lg->num_eventfds].event = eventfd_fget(fd);
+ if (IS_ERR(lg->eventfds[lg->num_eventfds].event))
+ return PTR_ERR(lg->eventfds[lg->num_eventfds].event);
+
+ wmb();
+ lg->num_eventfds++;
+ return 0;
+}
+
+static int attach_eventfd(struct lguest *lg, const unsigned long __user *input)
+{
+ unsigned long addr, fd;
+ int err;
+
+ if (get_user(addr, input) != 0)
+ return -EFAULT;
+ input++;
+ if (get_user(fd, input) != 0)
return -EFAULT;
- if (on) {
- cpu->break_out = 1;
- /* Pop it out of the Guest (may be running on different CPU) */
- wake_up_process(cpu->tsk);
- /* Wait for them to reset it */
- return wait_event_interruptible(cpu->break_wq, !cpu->break_out);
- } else {
- cpu->break_out = 0;
- wake_up(&cpu->break_wq);
- return 0;
- }
+ mutex_lock(&lguest_lock);
+ err = add_eventfd(lg, addr, fd);
+ mutex_unlock(&lguest_lock);
+
+ return 0;
}
/*L:050 Sending an interrupt is done by writing LHREQ_IRQ and an interrupt
@@ -45,9 +85,8 @@ static int user_send_irq(struct lg_cpu *cpu, const unsigned long __user *input)
return -EFAULT;
if (irq >= LGUEST_IRQS)
return -EINVAL;
- /* Next time the Guest runs, the core code will see if it can deliver
- * this interrupt. */
- set_bit(irq, cpu->irqs_pending);
+
+ set_interrupt(cpu, irq);
return 0;
}
@@ -126,9 +165,6 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
* address. */
lguest_arch_setup_regs(cpu, start_ip);
- /* Initialize the queue for the Waker to wait on */
- init_waitqueue_head(&cpu->break_wq);
-
/* We keep a pointer to the Launcher task (ie. current task) for when
* other Guests want to wake this one (eg. console input). */
cpu->tsk = current;
@@ -252,11 +288,6 @@ static ssize_t write(struct file *file, const char __user *in,
/* Once the Guest is dead, you can only read() why it died. */
if (lg->dead)
return -ENOENT;
-
- /* If you're not the task which owns the Guest, all you can do
- * is break the Launcher out of running the Guest. */
- if (current != cpu->tsk && req != LHREQ_BREAK)
- return -EPERM;
}
switch (req) {
@@ -264,8 +295,8 @@ static ssize_t write(struct file *file, const char __user *in,
return initialize(file, input);
case LHREQ_IRQ:
return user_send_irq(cpu, input);
- case LHREQ_BREAK:
- return break_guest_out(cpu, input);
+ case LHREQ_EVENTFD:
+ return attach_eventfd(lg, input);
default:
return -EINVAL;
}
@@ -303,6 +334,11 @@ static int close(struct inode *inode, struct file *file)
* the Launcher's memory management structure. */
mmput(lg->cpus[i].mm);
}
+
+ /* Release any eventfds they registered. */
+ for (i = 0; i < lg->num_eventfds; i++)
+ fput(lg->eventfds[i].event);
+
/* If lg->dead doesn't contain an error code it will be NULL or a
* kmalloc()ed string, either of which is ok to hand to kfree(). */
if (!IS_ERR(lg->dead))
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 1a83910f674f..eaf722fe309a 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -358,6 +358,16 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
if (emulate_insn(cpu))
return;
}
+ /* If KVM is active, the vmcall instruction triggers a
+ * General Protection Fault. Normally it triggers an
+ * invalid opcode fault (6): */
+ case 6:
+ /* We need to check if ring == GUEST_PL and
+ * faulting instruction == vmcall. */
+ if (is_hypercall(cpu)) {
+ rewrite_hypercall(cpu);
+ return;
+ }
break;
case 14: /* We've intercepted a Page Fault. */
/* The Guest accessed a virtual address that wasn't mapped.
@@ -403,15 +413,6 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
* up the pointer now to indicate a hypercall is pending. */
cpu->hcall = (struct hcall_args *)cpu->regs;
return;
- case 6:
- /* kvm hypercalls trigger an invalid opcode fault (6).
- * We need to check if ring == GUEST_PL and
- * faulting instruction == vmcall. */
- if (is_hypercall(cpu)) {
- rewrite_hypercall(cpu);
- return;
- }
- break;
}
/* We didn't handle the trap, so it needs to go to the Guest. */
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index c0621d50c8a0..4a8bf467ff43 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -71,7 +71,7 @@ MODULE_PARM_DESC(verbose,"Verbose log operations "
"(default 0)");
struct thermostat {
- struct i2c_client clt;
+ struct i2c_client *clt;
u8 temps[3];
u8 cached_temp[3];
u8 initial_limits[3];
@@ -86,9 +86,6 @@ static struct of_device * of_dev;
static struct thermostat* thermostat;
static struct task_struct *thread_therm = NULL;
-static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
- int busno);
-
static void write_both_fan_speed(struct thermostat *th, int speed);
static void write_fan_speed(struct thermostat *th, int speed, int fan);
@@ -100,7 +97,7 @@ write_reg(struct thermostat* th, int reg, u8 data)
tmp[0] = reg;
tmp[1] = data;
- rc = i2c_master_send(&th->clt, (const char *)tmp, 2);
+ rc = i2c_master_send(th->clt, (const char *)tmp, 2);
if (rc < 0)
return rc;
if (rc != 2)
@@ -115,12 +112,12 @@ read_reg(struct thermostat* th, int reg)
int rc;
reg_addr = (u8)reg;
- rc = i2c_master_send(&th->clt, &reg_addr, 1);
+ rc = i2c_master_send(th->clt, &reg_addr, 1);
if (rc < 0)
return rc;
if (rc != 1)
return -ENODEV;
- rc = i2c_master_recv(&th->clt, (char *)&data, 1);
+ rc = i2c_master_recv(th->clt, (char *)&data, 1);
if (rc < 0)
return rc;
return data;
@@ -130,26 +127,36 @@ static int
attach_thermostat(struct i2c_adapter *adapter)
{
unsigned long bus_no;
+ struct i2c_board_info info;
+ struct i2c_client *client;
if (strncmp(adapter->name, "uni-n", 5))
return -ENODEV;
bus_no = simple_strtoul(adapter->name + 6, NULL, 10);
if (bus_no != therm_bus)
return -ENODEV;
- return attach_one_thermostat(adapter, therm_address, bus_no);
+
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ strlcpy(info.type, "therm_adt746x", I2C_NAME_SIZE);
+ info.addr = therm_address;
+ client = i2c_new_device(adapter, &info);
+ if (!client)
+ return -ENODEV;
+
+ /*
+ * Let i2c-core delete that device on driver removal.
+ * This is safe because i2c-core holds the core_lock mutex for us.
+ */
+ list_add_tail(&client->detected, &client->driver->clients);
+ return 0;
}
static int
-detach_thermostat(struct i2c_adapter *adapter)
+remove_thermostat(struct i2c_client *client)
{
- struct thermostat* th;
+ struct thermostat *th = i2c_get_clientdata(client);
int i;
- if (thermostat == NULL)
- return 0;
-
- th = thermostat;
-
if (thread_therm != NULL) {
kthread_stop(thread_therm);
}
@@ -165,8 +172,6 @@ detach_thermostat(struct i2c_adapter *adapter)
write_both_fan_speed(th, -1);
- i2c_detach_client(&th->clt);
-
thermostat = NULL;
kfree(th);
@@ -174,14 +179,6 @@ detach_thermostat(struct i2c_adapter *adapter)
return 0;
}
-static struct i2c_driver thermostat_driver = {
- .driver = {
- .name = "therm_adt746x",
- },
- .attach_adapter = attach_thermostat,
- .detach_adapter = detach_thermostat,
-};
-
static int read_fan_speed(struct thermostat *th, u8 addr)
{
u8 tmp[2];
@@ -369,8 +366,8 @@ static void set_limit(struct thermostat *th, int i)
th->limits[i] = default_limits_local[i] + limit_adjust;
}
-static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
- int busno)
+static int probe_thermostat(struct i2c_client *client,
+ const struct i2c_device_id *id)
{
struct thermostat* th;
int rc;
@@ -383,16 +380,12 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
if (!th)
return -ENOMEM;
- th->clt.addr = addr;
- th->clt.adapter = adapter;
- th->clt.driver = &thermostat_driver;
- strcpy(th->clt.name, "thermostat");
+ i2c_set_clientdata(client, th);
+ th->clt = client;
rc = read_reg(th, 0);
if (rc < 0) {
- printk(KERN_ERR "adt746x: Thermostat failed to read config "
- "from bus %d !\n",
- busno);
+ dev_err(&client->dev, "Thermostat failed to read config!\n");
kfree(th);
return -ENODEV;
}
@@ -421,14 +414,6 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
thermostat = th;
- if (i2c_attach_client(&th->clt)) {
- printk(KERN_INFO "adt746x: Thermostat failed to attach "
- "client !\n");
- thermostat = NULL;
- kfree(th);
- return -ENODEV;
- }
-
/* be sure to really write fan speed the first time */
th->last_speed[0] = -2;
th->last_speed[1] = -2;
@@ -454,6 +439,21 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
return 0;
}
+static const struct i2c_device_id therm_adt746x_id[] = {
+ { "therm_adt746x", 0 },
+ { }
+};
+
+static struct i2c_driver thermostat_driver = {
+ .driver = {
+ .name = "therm_adt746x",
+ },
+ .attach_adapter = attach_thermostat,
+ .probe = probe_thermostat,
+ .remove = remove_thermostat,
+ .id_table = therm_adt746x_id,
+};
+
/*
* Now, unfortunately, sysfs doesn't give us a nice void * we could
* pass around to the attribute functions, so we don't really have
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 817607e2af6a..a028598af2d3 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -287,22 +287,6 @@ struct fcu_fan_table fcu_fans[] = {
};
/*
- * i2c_driver structure to attach to the host i2c controller
- */
-
-static int therm_pm72_attach(struct i2c_adapter *adapter);
-static int therm_pm72_detach(struct i2c_adapter *adapter);
-
-static struct i2c_driver therm_pm72_driver =
-{
- .driver = {
- .name = "therm_pm72",
- },
- .attach_adapter = therm_pm72_attach,
- .detach_adapter = therm_pm72_detach,
-};
-
-/*
* Utility function to create an i2c_client structure and
* attach it to one of u3 adapters
*/
@@ -310,6 +294,7 @@ static struct i2c_client *attach_i2c_chip(int id, const char *name)
{
struct i2c_client *clt;
struct i2c_adapter *adap;
+ struct i2c_board_info info;
if (id & 0x200)
adap = k2;
@@ -320,31 +305,21 @@ static struct i2c_client *attach_i2c_chip(int id, const char *name)
if (adap == NULL)
return NULL;
- clt = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
- if (clt == NULL)
- return NULL;
-
- clt->addr = (id >> 1) & 0x7f;
- clt->adapter = adap;
- clt->driver = &therm_pm72_driver;
- strncpy(clt->name, name, I2C_NAME_SIZE-1);
-
- if (i2c_attach_client(clt)) {
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ info.addr = (id >> 1) & 0x7f;
+ strlcpy(info.type, "therm_pm72", I2C_NAME_SIZE);
+ clt = i2c_new_device(adap, &info);
+ if (!clt) {
printk(KERN_ERR "therm_pm72: Failed to attach to i2c ID 0x%x\n", id);
- kfree(clt);
return NULL;
}
- return clt;
-}
-/*
- * Utility function to get rid of the i2c_client structure
- * (will also detach from the adapter hopepfully)
- */
-static void detach_i2c_chip(struct i2c_client *clt)
-{
- i2c_detach_client(clt);
- kfree(clt);
+ /*
+ * Let i2c-core delete that device on driver removal.
+ * This is safe because i2c-core holds the core_lock mutex for us.
+ */
+ list_add_tail(&clt->detected, &clt->driver->clients);
+ return clt;
}
/*
@@ -1203,8 +1178,6 @@ static int init_cpu_state(struct cpu_pid_state *state, int index)
return 0;
fail:
- if (state->monitor)
- detach_i2c_chip(state->monitor);
state->monitor = NULL;
return -ENODEV;
@@ -1232,7 +1205,6 @@ static void dispose_cpu_state(struct cpu_pid_state *state)
device_remove_file(&of_dev->dev, &dev_attr_cpu1_intake_fan_rpm);
}
- detach_i2c_chip(state->monitor);
state->monitor = NULL;
}
@@ -1407,7 +1379,6 @@ static void dispose_backside_state(struct backside_pid_state *state)
device_remove_file(&of_dev->dev, &dev_attr_backside_temperature);
device_remove_file(&of_dev->dev, &dev_attr_backside_fan_pwm);
- detach_i2c_chip(state->monitor);
state->monitor = NULL;
}
@@ -1532,7 +1503,6 @@ static void dispose_drives_state(struct drives_pid_state *state)
device_remove_file(&of_dev->dev, &dev_attr_drives_temperature);
device_remove_file(&of_dev->dev, &dev_attr_drives_fan_rpm);
- detach_i2c_chip(state->monitor);
state->monitor = NULL;
}
@@ -1654,7 +1624,6 @@ static void dispose_dimms_state(struct dimm_pid_state *state)
device_remove_file(&of_dev->dev, &dev_attr_dimms_temperature);
- detach_i2c_chip(state->monitor);
state->monitor = NULL;
}
@@ -1779,7 +1748,6 @@ static void dispose_slots_state(struct slots_pid_state *state)
device_remove_file(&of_dev->dev, &dev_attr_slots_temperature);
device_remove_file(&of_dev->dev, &dev_attr_slots_fan_pwm);
- detach_i2c_chip(state->monitor);
state->monitor = NULL;
}
@@ -2008,8 +1976,6 @@ static int attach_fcu(void)
*/
static void detach_fcu(void)
{
- if (fcu)
- detach_i2c_chip(fcu);
fcu = NULL;
}
@@ -2060,12 +2026,21 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
return 0;
}
+static int therm_pm72_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ /* Always succeed, the real work was done in therm_pm72_attach() */
+ return 0;
+}
+
/*
- * Called on every adapter when the driver or the i2c controller
+ * Called when any of the devices which participates into thermal management
* is going away.
*/
-static int therm_pm72_detach(struct i2c_adapter *adapter)
+static int therm_pm72_remove(struct i2c_client *client)
{
+ struct i2c_adapter *adapter = client->adapter;
+
mutex_lock(&driver_lock);
if (state != state_detached)
@@ -2096,6 +2071,30 @@ static int therm_pm72_detach(struct i2c_adapter *adapter)
return 0;
}
+/*
+ * i2c_driver structure to attach to the host i2c controller
+ */
+
+static const struct i2c_device_id therm_pm72_id[] = {
+ /*
+ * Fake device name, thermal management is done by several
+ * chips but we don't need to differentiate between them at
+ * this point.
+ */
+ { "therm_pm72", 0 },
+ { }
+};
+
+static struct i2c_driver therm_pm72_driver = {
+ .driver = {
+ .name = "therm_pm72",
+ },
+ .attach_adapter = therm_pm72_attach,
+ .probe = therm_pm72_probe,
+ .remove = therm_pm72_remove,
+ .id_table = therm_pm72_id,
+};
+
static int fan_check_loc_match(const char *loc, int fan)
{
char tmp[64];
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 3da0a02efd76..40023313a760 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -48,16 +48,6 @@
#define LOG_TEMP 0 /* continously log temperature */
-static int do_probe( struct i2c_adapter *adapter, int addr, int kind);
-
-/* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */
-static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
- 0x4c, 0x4d, 0x4e, 0x4f,
- 0x2c, 0x2d, 0x2e, 0x2f,
- I2C_CLIENT_END };
-
-I2C_CLIENT_INSMOD;
-
static struct {
volatile int running;
struct task_struct *poll_task;
@@ -315,53 +305,54 @@ static int control_loop(void *dummy)
static int
do_attach( struct i2c_adapter *adapter )
{
- int ret = 0;
+ /* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */
+ static const unsigned short scan_ds1775[] = {
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ I2C_CLIENT_END
+ };
+ static const unsigned short scan_adm1030[] = {
+ 0x2c, 0x2d, 0x2e, 0x2f,
+ I2C_CLIENT_END
+ };
if( strncmp(adapter->name, "uni-n", 5) )
return 0;
if( !x.running ) {
- ret = i2c_probe( adapter, &addr_data, &do_probe );
+ struct i2c_board_info info;
+
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ strlcpy(info.type, "therm_ds1775", I2C_NAME_SIZE);
+ i2c_new_probed_device(adapter, &info, scan_ds1775);
+
+ strlcpy(info.type, "therm_adm1030", I2C_NAME_SIZE);
+ i2c_new_probed_device(adapter, &info, scan_adm1030);
+
if( x.thermostat && x.fan ) {
x.running = 1;
x.poll_task = kthread_run(control_loop, NULL, "g4fand");
}
}
- return ret;
+ return 0;
}
static int
-do_detach( struct i2c_client *client )
+do_remove(struct i2c_client *client)
{
- int err;
-
- if( (err=i2c_detach_client(client)) )
- printk(KERN_ERR "failed to detach thermostat client\n");
- else {
- if( x.running ) {
- x.running = 0;
- kthread_stop(x.poll_task);
- x.poll_task = NULL;
- }
- if( client == x.thermostat )
- x.thermostat = NULL;
- else if( client == x.fan )
- x.fan = NULL;
- else {
- printk(KERN_ERR "g4fan: bad client\n");
- }
- kfree( client );
+ if (x.running) {
+ x.running = 0;
+ kthread_stop(x.poll_task);
+ x.poll_task = NULL;
}
- return err;
-}
+ if (client == x.thermostat)
+ x.thermostat = NULL;
+ else if (client == x.fan)
+ x.fan = NULL;
+ else
+ printk(KERN_ERR "g4fan: bad client\n");
-static struct i2c_driver g4fan_driver = {
- .driver = {
- .name = "therm_windtunnel",
- },
- .attach_adapter = do_attach,
- .detach_client = do_detach,
-};
+ return 0;
+}
static int
attach_fan( struct i2c_client *cl )
@@ -374,13 +365,8 @@ attach_fan( struct i2c_client *cl )
goto out;
printk("ADM1030 fan controller [@%02x]\n", cl->addr );
- strlcpy( cl->name, "ADM1030 fan controller", sizeof(cl->name) );
-
- if( !i2c_attach_client(cl) )
- x.fan = cl;
+ x.fan = cl;
out:
- if( cl != x.fan )
- kfree( cl );
return 0;
}
@@ -412,39 +398,47 @@ attach_thermostat( struct i2c_client *cl )
x.temp = temp;
x.overheat_temp = os_temp;
x.overheat_hyst = hyst_temp;
-
- strlcpy( cl->name, "DS1775 thermostat", sizeof(cl->name) );
-
- if( !i2c_attach_client(cl) )
- x.thermostat = cl;
+ x.thermostat = cl;
out:
- if( cl != x.thermostat )
- kfree( cl );
return 0;
}
+enum chip { ds1775, adm1030 };
+
+static const struct i2c_device_id therm_windtunnel_id[] = {
+ { "therm_ds1775", ds1775 },
+ { "therm_adm1030", adm1030 },
+ { }
+};
+
static int
-do_probe( struct i2c_adapter *adapter, int addr, int kind )
+do_probe(struct i2c_client *cl, const struct i2c_device_id *id)
{
- struct i2c_client *cl;
+ struct i2c_adapter *adapter = cl->adapter;
if( !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA
| I2C_FUNC_SMBUS_WRITE_BYTE) )
return 0;
- if( !(cl=kzalloc(sizeof(*cl), GFP_KERNEL)) )
- return -ENOMEM;
-
- cl->addr = addr;
- cl->adapter = adapter;
- cl->driver = &g4fan_driver;
- cl->flags = 0;
-
- if( addr < 0x48 )
+ switch (id->driver_data) {
+ case adm1030:
return attach_fan( cl );
- return attach_thermostat( cl );
+ case ds1775:
+ return attach_thermostat(cl);
+ }
+ return 0;
}
+static struct i2c_driver g4fan_driver = {
+ .driver = {
+ .name = "therm_windtunnel",
+ },
+ .attach_adapter = do_attach,
+ .probe = do_probe,
+ .remove = do_remove,
+ .id_table = therm_windtunnel_id,
+};
+
/************************************************************************/
/* initialization / cleanup */
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index b92b959fe16e..529886c7a826 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -37,34 +37,22 @@
struct wf_lm75_sensor {
int ds1775 : 1;
int inited : 1;
- struct i2c_client i2c;
+ struct i2c_client *i2c;
struct wf_sensor sens;
};
#define wf_to_lm75(c) container_of(c, struct wf_lm75_sensor, sens)
-#define i2c_to_lm75(c) container_of(c, struct wf_lm75_sensor, i2c)
-
-static int wf_lm75_attach(struct i2c_adapter *adapter);
-static int wf_lm75_detach(struct i2c_client *client);
-
-static struct i2c_driver wf_lm75_driver = {
- .driver = {
- .name = "wf_lm75",
- },
- .attach_adapter = wf_lm75_attach,
- .detach_client = wf_lm75_detach,
-};
static int wf_lm75_get(struct wf_sensor *sr, s32 *value)
{
struct wf_lm75_sensor *lm = wf_to_lm75(sr);
s32 data;
- if (lm->i2c.adapter == NULL)
+ if (lm->i2c == NULL)
return -ENODEV;
/* Init chip if necessary */
if (!lm->inited) {
- u8 cfg_new, cfg = (u8)i2c_smbus_read_byte_data(&lm->i2c, 1);
+ u8 cfg_new, cfg = (u8)i2c_smbus_read_byte_data(lm->i2c, 1);
DBG("wf_lm75: Initializing %s, cfg was: %02x\n",
sr->name, cfg);
@@ -73,7 +61,7 @@ static int wf_lm75_get(struct wf_sensor *sr, s32 *value)
* the firmware for now
*/
cfg_new = cfg & ~0x01;
- i2c_smbus_write_byte_data(&lm->i2c, 1, cfg_new);
+ i2c_smbus_write_byte_data(lm->i2c, 1, cfg_new);
lm->inited = 1;
/* If we just powered it up, let's wait 200 ms */
@@ -81,7 +69,7 @@ static int wf_lm75_get(struct wf_sensor *sr, s32 *value)
}
/* Read temperature register */
- data = (s32)le16_to_cpu(i2c_smbus_read_word_data(&lm->i2c, 0));
+ data = (s32)le16_to_cpu(i2c_smbus_read_word_data(lm->i2c, 0));
data <<= 8;
*value = data;
@@ -92,12 +80,6 @@ static void wf_lm75_release(struct wf_sensor *sr)
{
struct wf_lm75_sensor *lm = wf_to_lm75(sr);
- /* check if client is registered and detach from i2c */
- if (lm->i2c.adapter) {
- i2c_detach_client(&lm->i2c);
- lm->i2c.adapter = NULL;
- }
-
kfree(lm);
}
@@ -107,59 +89,77 @@ static struct wf_sensor_ops wf_lm75_ops = {
.owner = THIS_MODULE,
};
-static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
- u8 addr, int ds1775,
- const char *loc)
+static int wf_lm75_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
{
struct wf_lm75_sensor *lm;
int rc;
- DBG("wf_lm75: creating %s device at address 0x%02x\n",
- ds1775 ? "ds1775" : "lm75", addr);
-
lm = kzalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
if (lm == NULL)
- return NULL;
+ return -ENODEV;
+
+ lm->inited = 0;
+ lm->ds1775 = id->driver_data;
+ lm->i2c = client;
+ lm->sens.name = client->dev.platform_data;
+ lm->sens.ops = &wf_lm75_ops;
+ i2c_set_clientdata(client, lm);
+
+ rc = wf_register_sensor(&lm->sens);
+ if (rc) {
+ i2c_set_clientdata(client, NULL);
+ kfree(lm);
+ }
+
+ return rc;
+}
+
+static struct i2c_client *wf_lm75_create(struct i2c_adapter *adapter,
+ u8 addr, int ds1775,
+ const char *loc)
+{
+ struct i2c_board_info info;
+ struct i2c_client *client;
+ char *name;
+
+ DBG("wf_lm75: creating %s device at address 0x%02x\n",
+ ds1775 ? "ds1775" : "lm75", addr);
/* Usual rant about sensor names not beeing very consistent in
* the device-tree, oh well ...
* Add more entries below as you deal with more setups
*/
if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
- lm->sens.name = "hd-temp";
+ name = "hd-temp";
else if (!strcmp(loc, "Incoming Air Temp"))
- lm->sens.name = "incoming-air-temp";
+ name = "incoming-air-temp";
else if (!strcmp(loc, "ODD Temp"))
- lm->sens.name = "optical-drive-temp";
+ name = "optical-drive-temp";
else if (!strcmp(loc, "HD Temp"))
- lm->sens.name = "hard-drive-temp";
+ name = "hard-drive-temp";
else
goto fail;
- lm->inited = 0;
- lm->sens.ops = &wf_lm75_ops;
- lm->ds1775 = ds1775;
- lm->i2c.addr = (addr >> 1) & 0x7f;
- lm->i2c.adapter = adapter;
- lm->i2c.driver = &wf_lm75_driver;
- strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1);
-
- rc = i2c_attach_client(&lm->i2c);
- if (rc) {
- printk(KERN_ERR "windfarm: failed to attach %s %s to i2c,"
- " err %d\n", ds1775 ? "ds1775" : "lm75",
- lm->i2c.name, rc);
- goto fail;
- }
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ info.addr = (addr >> 1) & 0x7f;
+ info.platform_data = name;
+ strlcpy(info.type, ds1775 ? "wf_ds1775" : "wf_lm75", I2C_NAME_SIZE);
- if (wf_register_sensor(&lm->sens)) {
- i2c_detach_client(&lm->i2c);
+ client = i2c_new_device(adapter, &info);
+ if (client == NULL) {
+ printk(KERN_ERR "windfarm: failed to attach %s %s to i2c\n",
+ ds1775 ? "ds1775" : "lm75", name);
goto fail;
}
- return lm;
+ /*
+ * Let i2c-core delete that device on driver removal.
+ * This is safe because i2c-core holds the core_lock mutex for us.
+ */
+ list_add_tail(&client->detected, &client->driver->clients);
+ return client;
fail:
- kfree(lm);
return NULL;
}
@@ -202,21 +202,38 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
return 0;
}
-static int wf_lm75_detach(struct i2c_client *client)
+static int wf_lm75_remove(struct i2c_client *client)
{
- struct wf_lm75_sensor *lm = i2c_to_lm75(client);
+ struct wf_lm75_sensor *lm = i2c_get_clientdata(client);
DBG("wf_lm75: i2c detatch called for %s\n", lm->sens.name);
/* Mark client detached */
- lm->i2c.adapter = NULL;
+ lm->i2c = NULL;
/* release sensor */
wf_unregister_sensor(&lm->sens);
+ i2c_set_clientdata(client, NULL);
return 0;
}
+static const struct i2c_device_id wf_lm75_id[] = {
+ { "wf_lm75", 0 },
+ { "wf_ds1775", 1 },
+ { }
+};
+
+static struct i2c_driver wf_lm75_driver = {
+ .driver = {
+ .name = "wf_lm75",
+ },
+ .attach_adapter = wf_lm75_attach,
+ .probe = wf_lm75_probe,
+ .remove = wf_lm75_remove,
+ .id_table = wf_lm75_id,
+};
+
static int __init wf_lm75_sensor_init(void)
{
/* Don't register on old machines that use therm_pm72 for now */
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index e207a90d6b27..e2a55ecda2b2 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -26,34 +26,22 @@
#define MAX6690_EXTERNAL_TEMP 1
struct wf_6690_sensor {
- struct i2c_client i2c;
+ struct i2c_client *i2c;
struct wf_sensor sens;
};
#define wf_to_6690(x) container_of((x), struct wf_6690_sensor, sens)
-#define i2c_to_6690(x) container_of((x), struct wf_6690_sensor, i2c)
-
-static int wf_max6690_attach(struct i2c_adapter *adapter);
-static int wf_max6690_detach(struct i2c_client *client);
-
-static struct i2c_driver wf_max6690_driver = {
- .driver = {
- .name = "wf_max6690",
- },
- .attach_adapter = wf_max6690_attach,
- .detach_client = wf_max6690_detach,
-};
static int wf_max6690_get(struct wf_sensor *sr, s32 *value)
{
struct wf_6690_sensor *max = wf_to_6690(sr);
s32 data;
- if (max->i2c.adapter == NULL)
+ if (max->i2c == NULL)
return -ENODEV;
/* chip gets initialized by firmware */
- data = i2c_smbus_read_byte_data(&max->i2c, MAX6690_EXTERNAL_TEMP);
+ data = i2c_smbus_read_byte_data(max->i2c, MAX6690_EXTERNAL_TEMP);
if (data < 0)
return data;
*value = data << 16;
@@ -64,10 +52,6 @@ static void wf_max6690_release(struct wf_sensor *sr)
{
struct wf_6690_sensor *max = wf_to_6690(sr);
- if (max->i2c.adapter) {
- i2c_detach_client(&max->i2c);
- max->i2c.adapter = NULL;
- }
kfree(max);
}
@@ -77,19 +61,40 @@ static struct wf_sensor_ops wf_max6690_ops = {
.owner = THIS_MODULE,
};
-static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
- const char *loc)
+static int wf_max6690_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
{
struct wf_6690_sensor *max;
- char *name;
+ int rc;
max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
if (max == NULL) {
- printk(KERN_ERR "windfarm: Couldn't create MAX6690 sensor %s: "
- "no memory\n", loc);
- return;
+ printk(KERN_ERR "windfarm: Couldn't create MAX6690 sensor: "
+ "no memory\n");
+ return -ENOMEM;
+ }
+
+ max->i2c = client;
+ max->sens.name = client->dev.platform_data;
+ max->sens.ops = &wf_max6690_ops;
+ i2c_set_clientdata(client, max);
+
+ rc = wf_register_sensor(&max->sens);
+ if (rc) {
+ i2c_set_clientdata(client, NULL);
+ kfree(max);
}
+ return rc;
+}
+
+static struct i2c_client *wf_max6690_create(struct i2c_adapter *adapter,
+ u8 addr, const char *loc)
+{
+ struct i2c_board_info info;
+ struct i2c_client *client;
+ char *name;
+
if (!strcmp(loc, "BACKSIDE"))
name = "backside-temp";
else if (!strcmp(loc, "NB Ambient"))
@@ -99,27 +104,26 @@ static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
else
goto fail;
- max->sens.ops = &wf_max6690_ops;
- max->sens.name = name;
- max->i2c.addr = addr >> 1;
- max->i2c.adapter = adapter;
- max->i2c.driver = &wf_max6690_driver;
- strncpy(max->i2c.name, name, I2C_NAME_SIZE-1);
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ info.addr = addr >> 1;
+ info.platform_data = name;
+ strlcpy(info.type, "wf_max6690", I2C_NAME_SIZE);
- if (i2c_attach_client(&max->i2c)) {
+ client = i2c_new_device(adapter, &info);
+ if (client == NULL) {
printk(KERN_ERR "windfarm: failed to attach MAX6690 sensor\n");
goto fail;
}
- if (wf_register_sensor(&max->sens)) {
- i2c_detach_client(&max->i2c);
- goto fail;
- }
-
- return;
+ /*
+ * Let i2c-core delete that device on driver removal.
+ * This is safe because i2c-core holds the core_lock mutex for us.
+ */
+ list_add_tail(&client->detected, &client->driver->clients);
+ return client;
fail:
- kfree(max);
+ return NULL;
}
static int wf_max6690_attach(struct i2c_adapter *adapter)
@@ -154,16 +158,31 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
return 0;
}
-static int wf_max6690_detach(struct i2c_client *client)
+static int wf_max6690_remove(struct i2c_client *client)
{
- struct wf_6690_sensor *max = i2c_to_6690(client);
+ struct wf_6690_sensor *max = i2c_get_clientdata(client);
- max->i2c.adapter = NULL;
+ max->i2c = NULL;
wf_unregister_sensor(&max->sens);
return 0;
}
+static const struct i2c_device_id wf_max6690_id[] = {
+ { "wf_max6690", 0 },
+ { }
+};
+
+static struct i2c_driver wf_max6690_driver = {
+ .driver = {
+ .name = "wf_max6690",
+ },
+ .attach_adapter = wf_max6690_attach,
+ .probe = wf_max6690_probe,
+ .remove = wf_max6690_remove,
+ .id_table = wf_max6690_id,
+};
+
static int __init wf_max6690_sensor_init(void)
{
/* Don't register on old machines that use therm_pm72 for now */
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 7847e981ac33..5da729e58f99 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -39,7 +39,7 @@ struct wf_sat {
struct mutex mutex;
unsigned long last_read; /* jiffies when cache last updated */
u8 cache[16];
- struct i2c_client i2c;
+ struct i2c_client *i2c;
struct device_node *node;
};
@@ -54,18 +54,6 @@ struct wf_sat_sensor {
};
#define wf_to_sat(c) container_of(c, struct wf_sat_sensor, sens)
-#define i2c_to_sat(c) container_of(c, struct wf_sat, i2c)
-
-static int wf_sat_attach(struct i2c_adapter *adapter);
-static int wf_sat_detach(struct i2c_client *client);
-
-static struct i2c_driver wf_sat_driver = {
- .driver = {
- .name = "wf_smu_sat",
- },
- .attach_adapter = wf_sat_attach,
- .detach_client = wf_sat_detach,
-};
struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
unsigned int *size)
@@ -81,13 +69,13 @@ struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
if (sat_id > 1 || (sat = sats[sat_id]) == NULL)
return NULL;
- err = i2c_smbus_write_word_data(&sat->i2c, 8, id << 8);
+ err = i2c_smbus_write_word_data(sat->i2c, 8, id << 8);
if (err) {
printk(KERN_ERR "smu_sat_get_sdb_part wr error %d\n", err);
return NULL;
}
- err = i2c_smbus_read_word_data(&sat->i2c, 9);
+ err = i2c_smbus_read_word_data(sat->i2c, 9);
if (err < 0) {
printk(KERN_ERR "smu_sat_get_sdb_part rd len error\n");
return NULL;
@@ -105,7 +93,7 @@ struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
return NULL;
for (i = 0; i < len; i += 4) {
- err = i2c_smbus_read_i2c_block_data(&sat->i2c, 0xa, 4, data);
+ err = i2c_smbus_read_i2c_block_data(sat->i2c, 0xa, 4, data);
if (err < 0) {
printk(KERN_ERR "smu_sat_get_sdb_part rd err %d\n",
err);
@@ -138,7 +126,7 @@ static int wf_sat_read_cache(struct wf_sat *sat)
{
int err;
- err = i2c_smbus_read_i2c_block_data(&sat->i2c, 0x3f, 16, sat->cache);
+ err = i2c_smbus_read_i2c_block_data(sat->i2c, 0x3f, 16, sat->cache);
if (err < 0)
return err;
sat->last_read = jiffies;
@@ -161,7 +149,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
int i, err;
s32 val;
- if (sat->i2c.adapter == NULL)
+ if (sat->i2c == NULL)
return -ENODEV;
mutex_lock(&sat->mutex);
@@ -193,10 +181,6 @@ static void wf_sat_release(struct wf_sensor *sr)
struct wf_sat *sat = sens->sat;
if (atomic_dec_and_test(&sat->refcnt)) {
- if (sat->i2c.adapter) {
- i2c_detach_client(&sat->i2c);
- sat->i2c.adapter = NULL;
- }
if (sat->nr >= 0)
sats[sat->nr] = NULL;
kfree(sat);
@@ -212,38 +196,58 @@ static struct wf_sensor_ops wf_sat_ops = {
static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
{
+ struct i2c_board_info info;
+ struct i2c_client *client;
+ const u32 *reg;
+ u8 addr;
+
+ reg = of_get_property(dev, "reg", NULL);
+ if (reg == NULL)
+ return;
+ addr = *reg;
+ DBG(KERN_DEBUG "wf_sat: creating sat at address %x\n", addr);
+
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ info.addr = (addr >> 1) & 0x7f;
+ info.platform_data = dev;
+ strlcpy(info.type, "wf_sat", I2C_NAME_SIZE);
+
+ client = i2c_new_device(adapter, &info);
+ if (client == NULL) {
+ printk(KERN_ERR "windfarm: failed to attach smu-sat to i2c\n");
+ return;
+ }
+
+ /*
+ * Let i2c-core delete that device on driver removal.
+ * This is safe because i2c-core holds the core_lock mutex for us.
+ */
+ list_add_tail(&client->detected, &client->driver->clients);
+}
+
+static int wf_sat_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct device_node *dev = client->dev.platform_data;
struct wf_sat *sat;
struct wf_sat_sensor *sens;
const u32 *reg;
const char *loc, *type;
- u8 addr, chip, core;
+ u8 chip, core;
struct device_node *child;
int shift, cpu, index;
char *name;
int vsens[2], isens[2];
- reg = of_get_property(dev, "reg", NULL);
- if (reg == NULL)
- return;
- addr = *reg;
- DBG(KERN_DEBUG "wf_sat: creating sat at address %x\n", addr);
-
sat = kzalloc(sizeof(struct wf_sat), GFP_KERNEL);
if (sat == NULL)
- return;
+ return -ENOMEM;
sat->nr = -1;
sat->node = of_node_get(dev);
atomic_set(&sat->refcnt, 0);
mutex_init(&sat->mutex);
- sat->i2c.addr = (addr >> 1) & 0x7f;
- sat->i2c.adapter = adapter;
- sat->i2c.driver = &wf_sat_driver;
- strncpy(sat->i2c.name, "smu-sat", I2C_NAME_SIZE-1);
-
- if (i2c_attach_client(&sat->i2c)) {
- printk(KERN_ERR "windfarm: failed to attach smu-sat to i2c\n");
- goto fail;
- }
+ sat->i2c = client;
+ i2c_set_clientdata(client, sat);
vsens[0] = vsens[1] = -1;
isens[0] = isens[1] = -1;
@@ -344,10 +348,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
if (sat->nr >= 0)
sats[sat->nr] = sat;
- return;
-
- fail:
- kfree(sat);
+ return 0;
}
static int wf_sat_attach(struct i2c_adapter *adapter)
@@ -366,16 +367,32 @@ static int wf_sat_attach(struct i2c_adapter *adapter)
return 0;
}
-static int wf_sat_detach(struct i2c_client *client)
+static int wf_sat_remove(struct i2c_client *client)
{
- struct wf_sat *sat = i2c_to_sat(client);
+ struct wf_sat *sat = i2c_get_clientdata(client);
/* XXX TODO */
- sat->i2c.adapter = NULL;
+ sat->i2c = NULL;
+ i2c_set_clientdata(client, NULL);
return 0;
}
+static const struct i2c_device_id wf_sat_id[] = {
+ { "wf_sat", 0 },
+ { }
+};
+
+static struct i2c_driver wf_sat_driver = {
+ .driver = {
+ .name = "wf_smu_sat",
+ },
+ .attach_adapter = wf_sat_attach,
+ .probe = wf_sat_probe,
+ .remove = wf_sat_remove,
+ .id_table = wf_sat_id,
+};
+
static int __init sat_sensors_init(void)
{
return i2c_add_driver(&wf_sat_driver);
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 36e0675be9f7..3b311d273346 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -249,6 +249,15 @@ config DM_MULTIPATH
---help---
Allow volume managers to support multipath hardware.
+config DM_MULTIPATH_QL
+ tristate "I/O Path Selector based on the number of in-flight I/Os"
+ depends on DM_MULTIPATH
+ ---help---
+ This path selector is a dynamic load balancer which selects
+ the path with the least number of in-flight I/Os.
+
+ If unsure, say N.
+
config DM_DELAY
tristate "I/O delaying target (EXPERIMENTAL)"
depends on BLK_DEV_DM && EXPERIMENTAL
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index 45cc5951d928..ff9f545dd516 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o
obj-$(CONFIG_DM_CRYPT) += dm-crypt.o
obj-$(CONFIG_DM_DELAY) += dm-delay.o
obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o
+obj-$(CONFIG_DM_MULTIPATH_QL) += dm-queue-length.o
obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o
obj-$(CONFIG_DM_MIRROR) += dm-mirror.o dm-log.o dm-region-hash.o
obj-$(CONFIG_DM_ZERO) += dm-zero.o
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 47c68bc75a17..3319c2fec28e 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -232,7 +232,7 @@ static struct page *read_sb_page(mddev_t *mddev, long offset,
target = rdev->sb_start + offset + index * (PAGE_SIZE/512);
if (sync_page_io(rdev->bdev, target,
- roundup(size, bdev_hardsect_size(rdev->bdev)),
+ roundup(size, bdev_logical_block_size(rdev->bdev)),
page, READ)) {
page->index = index;
attach_page_buffers(page, NULL); /* so that free_buffer will
@@ -287,7 +287,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
int size = PAGE_SIZE;
if (page->index == bitmap->file_pages-1)
size = roundup(bitmap->last_page_size,
- bdev_hardsect_size(rdev->bdev));
+ bdev_logical_block_size(rdev->bdev));
/* Just make sure we aren't corrupting data or
* metadata
*/
@@ -1097,14 +1097,12 @@ void bitmap_daemon_work(struct bitmap *bitmap)
}
bitmap->allclean = 1;
+ spin_lock_irqsave(&bitmap->lock, flags);
for (j = 0; j < bitmap->chunks; j++) {
bitmap_counter_t *bmc;
- spin_lock_irqsave(&bitmap->lock, flags);
- if (!bitmap->filemap) {
+ if (!bitmap->filemap)
/* error or shutdown */
- spin_unlock_irqrestore(&bitmap->lock, flags);
break;
- }
page = filemap_get_page(bitmap, j);
@@ -1121,6 +1119,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
write_page(bitmap, page, 0);
bitmap->allclean = 0;
}
+ spin_lock_irqsave(&bitmap->lock, flags);
+ j |= (PAGE_BITS - 1);
continue;
}
@@ -1181,9 +1181,10 @@ void bitmap_daemon_work(struct bitmap *bitmap)
ext2_clear_bit(file_page_offset(j), paddr);
kunmap_atomic(paddr, KM_USER0);
}
- }
- spin_unlock_irqrestore(&bitmap->lock, flags);
+ } else
+ j |= PAGE_COUNTER_MASK;
}
+ spin_unlock_irqrestore(&bitmap->lock, flags);
/* now sync the final page */
if (lastpage != NULL) {
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 53394e863c74..04db6c4004a8 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1132,6 +1132,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad_crypt_queue;
}
+ ti->num_flush_requests = 1;
ti->private = cc;
return 0;
@@ -1189,6 +1190,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
union map_info *map_context)
{
struct dm_crypt_io *io;
+ struct crypt_config *cc;
+
+ if (unlikely(bio_empty_barrier(bio))) {
+ cc = ti->private;
+ bio->bi_bdev = cc->dev->bdev;
+ return DM_MAPIO_REMAPPED;
+ }
io = crypt_io_alloc(ti, bio, bio->bi_sector - ti->begin);
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index 559dbb52bc85..8ad8a9044bbf 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -197,6 +197,7 @@ out:
mutex_init(&dc->timer_lock);
atomic_set(&dc->may_delay, 1);
+ ti->num_flush_requests = 1;
ti->private = dc;
return 0;
@@ -278,8 +279,9 @@ static int delay_map(struct dm_target *ti, struct bio *bio,
if ((bio_data_dir(bio) == WRITE) && (dc->dev_write)) {
bio->bi_bdev = dc->dev_write->bdev;
- bio->bi_sector = dc->start_write +
- (bio->bi_sector - ti->begin);
+ if (bio_sectors(bio))
+ bio->bi_sector = dc->start_write +
+ (bio->bi_sector - ti->begin);
return delay_bio(dc, dc->write_delay, bio);
}
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index a2e26c242141..75d8081a9041 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -178,7 +178,7 @@ static int set_chunk_size(struct dm_exception_store *store,
}
/* Validate the chunk size against the device block size */
- if (chunk_size_ulong % (bdev_hardsect_size(store->cow->bdev) >> 9)) {
+ if (chunk_size_ulong % (bdev_logical_block_size(store->cow->bdev) >> 9)) {
*error = "Chunk size is not a multiple of device blocksize";
return -EINVAL;
}
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index e73aabd61cd7..3a2e6a2f8bdd 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -22,6 +22,7 @@ struct dm_io_client {
/* FIXME: can we shrink this ? */
struct io {
unsigned long error_bits;
+ unsigned long eopnotsupp_bits;
atomic_t count;
struct task_struct *sleeper;
struct dm_io_client *client;
@@ -107,8 +108,11 @@ static inline unsigned bio_get_region(struct bio *bio)
*---------------------------------------------------------------*/
static void dec_count(struct io *io, unsigned int region, int error)
{
- if (error)
+ if (error) {
set_bit(region, &io->error_bits);
+ if (error == -EOPNOTSUPP)
+ set_bit(region, &io->eopnotsupp_bits);
+ }
if (atomic_dec_and_test(&io->count)) {
if (io->sleeper)
@@ -360,7 +364,9 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
return -EIO;
}
+retry:
io.error_bits = 0;
+ io.eopnotsupp_bits = 0;
atomic_set(&io.count, 1); /* see dispatch_io() */
io.sleeper = current;
io.client = client;
@@ -377,6 +383,11 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
}
set_current_state(TASK_RUNNING);
+ if (io.eopnotsupp_bits && (rw & (1 << BIO_RW_BARRIER))) {
+ rw &= ~(1 << BIO_RW_BARRIER);
+ goto retry;
+ }
+
if (error_bits)
*error_bits = io.error_bits;
@@ -397,6 +408,7 @@ static int async_io(struct dm_io_client *client, unsigned int num_regions,
io = mempool_alloc(client->pool, GFP_NOIO);
io->error_bits = 0;
+ io->eopnotsupp_bits = 0;
atomic_set(&io->count, 1); /* see dispatch_io() */
io->sleeper = NULL;
io->client = client;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 823ceba6efa8..1128d3fba797 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1513,6 +1513,7 @@ static const struct file_operations _ctl_fops = {
static struct miscdevice _dm_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DM_NAME,
+ .devnode = "mapper/control",
.fops = &_ctl_fops
};
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 79fb53e51c70..ecbb17421da4 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -53,6 +53,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}
+ ti->num_flush_requests = 1;
ti->private = lc;
return 0;
@@ -81,7 +82,8 @@ static void linear_map_bio(struct dm_target *ti, struct bio *bio)
struct linear_c *lc = ti->private;
bio->bi_bdev = lc->dev->bdev;
- bio->bi_sector = linear_map_sector(ti, bio->bi_sector);
+ if (bio_sectors(bio))
+ bio->bi_sector = linear_map_sector(ti, bio->bi_sector);
}
static int linear_map(struct dm_target *ti, struct bio *bio,
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index be233bc4d917..6fa8ccf91c70 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -413,7 +413,8 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
* Buffer holds both header and bitset.
*/
buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
- bitset_size, ti->limits.hardsect_size);
+ bitset_size,
+ ti->limits.logical_block_size);
if (buf_size > dev->bdev->bd_inode->i_size) {
DMWARN("log device %s too small: need %llu bytes",
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 6a386ab4f7eb..252bc09bfaba 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -35,6 +35,7 @@ struct pgpath {
struct dm_path path;
struct work_struct deactivate_path;
+ struct work_struct activate_path;
};
#define path_to_pgpath(__pgp) container_of((__pgp), struct pgpath, path)
@@ -64,8 +65,6 @@ struct multipath {
spinlock_t lock;
const char *hw_handler_name;
- struct work_struct activate_path;
- struct pgpath *pgpath_to_activate;
unsigned nr_priority_groups;
struct list_head priority_groups;
unsigned pg_init_required; /* pg_init needs calling? */
@@ -102,6 +101,7 @@ struct multipath {
struct dm_mpath_io {
struct pgpath *pgpath;
struct dm_bio_details details;
+ size_t nr_bytes;
};
typedef int (*action_fn) (struct pgpath *pgpath);
@@ -128,6 +128,7 @@ static struct pgpath *alloc_pgpath(void)
if (pgpath) {
pgpath->is_active = 1;
INIT_WORK(&pgpath->deactivate_path, deactivate_path);
+ INIT_WORK(&pgpath->activate_path, activate_path);
}
return pgpath;
@@ -160,7 +161,6 @@ static struct priority_group *alloc_priority_group(void)
static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
{
- unsigned long flags;
struct pgpath *pgpath, *tmp;
struct multipath *m = ti->private;
@@ -169,10 +169,6 @@ static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
if (m->hw_handler_name)
scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev));
dm_put_device(ti, pgpath->path.dev);
- spin_lock_irqsave(&m->lock, flags);
- if (m->pgpath_to_activate == pgpath)
- m->pgpath_to_activate = NULL;
- spin_unlock_irqrestore(&m->lock, flags);
free_pgpath(pgpath);
}
}
@@ -202,7 +198,6 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
m->queue_io = 1;
INIT_WORK(&m->process_queued_ios, process_queued_ios);
INIT_WORK(&m->trigger_event, trigger_event);
- INIT_WORK(&m->activate_path, activate_path);
m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
if (!m->mpio_pool) {
kfree(m);
@@ -250,11 +245,12 @@ static void __switch_pg(struct multipath *m, struct pgpath *pgpath)
m->pg_init_count = 0;
}
-static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg)
+static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg,
+ size_t nr_bytes)
{
struct dm_path *path;
- path = pg->ps.type->select_path(&pg->ps, &m->repeat_count);
+ path = pg->ps.type->select_path(&pg->ps, &m->repeat_count, nr_bytes);
if (!path)
return -ENXIO;
@@ -266,7 +262,7 @@ static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg)
return 0;
}
-static void __choose_pgpath(struct multipath *m)
+static void __choose_pgpath(struct multipath *m, size_t nr_bytes)
{
struct priority_group *pg;
unsigned bypassed = 1;
@@ -278,12 +274,12 @@ static void __choose_pgpath(struct multipath *m)
if (m->next_pg) {
pg = m->next_pg;
m->next_pg = NULL;
- if (!__choose_path_in_pg(m, pg))
+ if (!__choose_path_in_pg(m, pg, nr_bytes))
return;
}
/* Don't change PG until it has no remaining paths */
- if (m->current_pg && !__choose_path_in_pg(m, m->current_pg))
+ if (m->current_pg && !__choose_path_in_pg(m, m->current_pg, nr_bytes))
return;
/*
@@ -295,7 +291,7 @@ static void __choose_pgpath(struct multipath *m)
list_for_each_entry(pg, &m->priority_groups, list) {
if (pg->bypassed == bypassed)
continue;
- if (!__choose_path_in_pg(m, pg))
+ if (!__choose_path_in_pg(m, pg, nr_bytes))
return;
}
} while (bypassed--);
@@ -326,6 +322,7 @@ static int map_io(struct multipath *m, struct bio *bio,
struct dm_mpath_io *mpio, unsigned was_queued)
{
int r = DM_MAPIO_REMAPPED;
+ size_t nr_bytes = bio->bi_size;
unsigned long flags;
struct pgpath *pgpath;
@@ -334,7 +331,7 @@ static int map_io(struct multipath *m, struct bio *bio,
/* Do we need to select a new pgpath? */
if (!m->current_pgpath ||
(!m->queue_io && (m->repeat_count && --m->repeat_count == 0)))
- __choose_pgpath(m);
+ __choose_pgpath(m, nr_bytes);
pgpath = m->current_pgpath;
@@ -359,6 +356,11 @@ static int map_io(struct multipath *m, struct bio *bio,
r = -EIO; /* Failed */
mpio->pgpath = pgpath;
+ mpio->nr_bytes = nr_bytes;
+
+ if (r == DM_MAPIO_REMAPPED && pgpath->pg->ps.type->start_io)
+ pgpath->pg->ps.type->start_io(&pgpath->pg->ps, &pgpath->path,
+ nr_bytes);
spin_unlock_irqrestore(&m->lock, flags);
@@ -427,8 +429,8 @@ static void process_queued_ios(struct work_struct *work)
{
struct multipath *m =
container_of(work, struct multipath, process_queued_ios);
- struct pgpath *pgpath = NULL;
- unsigned init_required = 0, must_queue = 1;
+ struct pgpath *pgpath = NULL, *tmp;
+ unsigned must_queue = 1;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
@@ -437,7 +439,7 @@ static void process_queued_ios(struct work_struct *work)
goto out;
if (!m->current_pgpath)
- __choose_pgpath(m);
+ __choose_pgpath(m, 0);
pgpath = m->current_pgpath;
@@ -446,19 +448,15 @@ static void process_queued_ios(struct work_struct *work)
must_queue = 0;
if (m->pg_init_required && !m->pg_init_in_progress && pgpath) {
- m->pgpath_to_activate = pgpath;
m->pg_init_count++;
m->pg_init_required = 0;
- m->pg_init_in_progress = 1;
- init_required = 1;
+ list_for_each_entry(tmp, &pgpath->pg->pgpaths, list) {
+ queue_work(kmpath_handlerd, &tmp->activate_path);
+ m->pg_init_in_progress++;
+ }
}
-
out:
spin_unlock_irqrestore(&m->lock, flags);
-
- if (init_required)
- queue_work(kmpath_handlerd, &m->activate_path);
-
if (!must_queue)
dispatch_queued_ios(m);
}
@@ -553,6 +551,12 @@ static int parse_path_selector(struct arg_set *as, struct priority_group *pg,
return -EINVAL;
}
+ if (ps_argc > as->argc) {
+ dm_put_path_selector(pst);
+ ti->error = "not enough arguments for path selector";
+ return -EINVAL;
+ }
+
r = pst->create(&pg->ps, ps_argc, as->argv);
if (r) {
dm_put_path_selector(pst);
@@ -591,9 +595,20 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
}
if (m->hw_handler_name) {
- r = scsi_dh_attach(bdev_get_queue(p->path.dev->bdev),
- m->hw_handler_name);
+ struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+
+ r = scsi_dh_attach(q, m->hw_handler_name);
+ if (r == -EBUSY) {
+ /*
+ * Already attached to different hw_handler,
+ * try to reattach with correct one.
+ */
+ scsi_dh_detach(q);
+ r = scsi_dh_attach(q, m->hw_handler_name);
+ }
+
if (r < 0) {
+ ti->error = "error attaching hardware handler";
dm_put_device(ti, p->path.dev);
goto bad;
}
@@ -699,6 +714,11 @@ static int parse_hw_handler(struct arg_set *as, struct multipath *m)
if (!hw_argc)
return 0;
+ if (hw_argc > as->argc) {
+ ti->error = "not enough arguments for hardware handler";
+ return -EINVAL;
+ }
+
m->hw_handler_name = kstrdup(shift(as), GFP_KERNEL);
request_module("scsi_dh_%s", m->hw_handler_name);
if (scsi_dh_handler_exist(m->hw_handler_name) == 0) {
@@ -823,6 +843,8 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
goto bad;
}
+ ti->num_flush_requests = 1;
+
return 0;
bad:
@@ -836,6 +858,7 @@ static void multipath_dtr(struct dm_target *ti)
flush_workqueue(kmpath_handlerd);
flush_workqueue(kmultipathd);
+ flush_scheduled_work();
free_multipath(m);
}
@@ -924,9 +947,13 @@ static int reinstate_path(struct pgpath *pgpath)
pgpath->is_active = 1;
- m->current_pgpath = NULL;
- if (!m->nr_valid_paths++ && m->queue_size)
+ if (!m->nr_valid_paths++ && m->queue_size) {
+ m->current_pgpath = NULL;
queue_work(kmultipathd, &m->process_queued_ios);
+ } else if (m->hw_handler_name && (m->current_pg == pgpath->pg)) {
+ m->pg_init_in_progress++;
+ queue_work(kmpath_handlerd, &pgpath->activate_path);
+ }
dm_path_uevent(DM_UEVENT_PATH_REINSTATED, m->ti,
pgpath->path.dev->name, m->nr_valid_paths);
@@ -1102,35 +1129,30 @@ static void pg_init_done(struct dm_path *path, int errors)
spin_lock_irqsave(&m->lock, flags);
if (errors) {
- DMERR("Could not failover device. Error %d.", errors);
- m->current_pgpath = NULL;
- m->current_pg = NULL;
+ if (pgpath == m->current_pgpath) {
+ DMERR("Could not failover device. Error %d.", errors);
+ m->current_pgpath = NULL;
+ m->current_pg = NULL;
+ }
} else if (!m->pg_init_required) {
m->queue_io = 0;
pg->bypassed = 0;
}
- m->pg_init_in_progress = 0;
- queue_work(kmultipathd, &m->process_queued_ios);
+ m->pg_init_in_progress--;
+ if (!m->pg_init_in_progress)
+ queue_work(kmultipathd, &m->process_queued_ios);
spin_unlock_irqrestore(&m->lock, flags);
}
static void activate_path(struct work_struct *work)
{
int ret;
- struct multipath *m =
- container_of(work, struct multipath, activate_path);
- struct dm_path *path;
- unsigned long flags;
+ struct pgpath *pgpath =
+ container_of(work, struct pgpath, activate_path);
- spin_lock_irqsave(&m->lock, flags);
- path = &m->pgpath_to_activate->path;
- m->pgpath_to_activate = NULL;
- spin_unlock_irqrestore(&m->lock, flags);
- if (!path)
- return;
- ret = scsi_dh_activate(bdev_get_queue(path->dev->bdev));
- pg_init_done(path, ret);
+ ret = scsi_dh_activate(bdev_get_queue(pgpath->path.dev->bdev));
+ pg_init_done(&pgpath->path, ret);
}
/*
@@ -1195,7 +1217,7 @@ static int multipath_end_io(struct dm_target *ti, struct bio *bio,
if (pgpath) {
ps = &pgpath->pg->ps;
if (ps->type->end_io)
- ps->type->end_io(ps, &pgpath->path);
+ ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
}
if (r != DM_ENDIO_INCOMPLETE)
mempool_free(mpio, m->mpio_pool);
@@ -1411,7 +1433,7 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
spin_lock_irqsave(&m->lock, flags);
if (!m->current_pgpath)
- __choose_pgpath(m);
+ __choose_pgpath(m, 0);
if (m->current_pgpath) {
bdev = m->current_pgpath->path.dev->bdev;
diff --git a/drivers/md/dm-path-selector.h b/drivers/md/dm-path-selector.h
index 27357b85d73d..e7d1fa8b0459 100644
--- a/drivers/md/dm-path-selector.h
+++ b/drivers/md/dm-path-selector.h
@@ -56,7 +56,8 @@ struct path_selector_type {
* the path fails.
*/
struct dm_path *(*select_path) (struct path_selector *ps,
- unsigned *repeat_count);
+ unsigned *repeat_count,
+ size_t nr_bytes);
/*
* Notify the selector that a path has failed.
@@ -75,7 +76,10 @@ struct path_selector_type {
int (*status) (struct path_selector *ps, struct dm_path *path,
status_type_t type, char *result, unsigned int maxlen);
- int (*end_io) (struct path_selector *ps, struct dm_path *path);
+ int (*start_io) (struct path_selector *ps, struct dm_path *path,
+ size_t nr_bytes);
+ int (*end_io) (struct path_selector *ps, struct dm_path *path,
+ size_t nr_bytes);
};
/* Register a path selector */
diff --git a/drivers/md/dm-queue-length.c b/drivers/md/dm-queue-length.c
new file mode 100644
index 000000000000..f92b6cea9d9c
--- /dev/null
+++ b/drivers/md/dm-queue-length.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2004-2005 IBM Corp. All Rights Reserved.
+ * Copyright (C) 2006-2009 NEC Corporation.
+ *
+ * dm-queue-length.c
+ *
+ * Module Author: Stefan Bader, IBM
+ * Modified by: Kiyoshi Ueda, NEC
+ *
+ * This file is released under the GPL.
+ *
+ * queue-length path selector - choose a path with the least number of
+ * in-flight I/Os.
+ */
+
+#include "dm.h"
+#include "dm-path-selector.h"
+
+#include <linux/slab.h>
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <asm/atomic.h>
+
+#define DM_MSG_PREFIX "multipath queue-length"
+#define QL_MIN_IO 128
+#define QL_VERSION "0.1.0"
+
+struct selector {
+ struct list_head valid_paths;
+ struct list_head failed_paths;
+};
+
+struct path_info {
+ struct list_head list;
+ struct dm_path *path;
+ unsigned repeat_count;
+ atomic_t qlen; /* the number of in-flight I/Os */
+};
+
+static struct selector *alloc_selector(void)
+{
+ struct selector *s = kmalloc(sizeof(*s), GFP_KERNEL);
+
+ if (s) {
+ INIT_LIST_HEAD(&s->valid_paths);
+ INIT_LIST_HEAD(&s->failed_paths);
+ }
+
+ return s;
+}
+
+static int ql_create(struct path_selector *ps, unsigned argc, char **argv)
+{
+ struct selector *s = alloc_selector();
+
+ if (!s)
+ return -ENOMEM;
+
+ ps->context = s;
+ return 0;
+}
+
+static void ql_free_paths(struct list_head *paths)
+{
+ struct path_info *pi, *next;
+
+ list_for_each_entry_safe(pi, next, paths, list) {
+ list_del(&pi->list);
+ kfree(pi);
+ }
+}
+
+static void ql_destroy(struct path_selector *ps)
+{
+ struct selector *s = ps->context;
+
+ ql_free_paths(&s->valid_paths);
+ ql_free_paths(&s->failed_paths);
+ kfree(s);
+ ps->context = NULL;
+}
+
+static int ql_status(struct path_selector *ps, struct dm_path *path,
+ status_type_t type, char *result, unsigned maxlen)
+{
+ unsigned sz = 0;
+ struct path_info *pi;
+
+ /* When called with NULL path, return selector status/args. */
+ if (!path)
+ DMEMIT("0 ");
+ else {
+ pi = path->pscontext;
+
+ switch (type) {
+ case STATUSTYPE_INFO:
+ DMEMIT("%d ", atomic_read(&pi->qlen));
+ break;
+ case STATUSTYPE_TABLE:
+ DMEMIT("%u ", pi->repeat_count);
+ break;
+ }
+ }
+
+ return sz;
+}
+
+static int ql_add_path(struct path_selector *ps, struct dm_path *path,
+ int argc, char **argv, char **error)
+{
+ struct selector *s = ps->context;
+ struct path_info *pi;
+ unsigned repeat_count = QL_MIN_IO;
+
+ /*
+ * Arguments: [<repeat_count>]
+ * <repeat_count>: The number of I/Os before switching path.
+ * If not given, default (QL_MIN_IO) is used.
+ */
+ if (argc > 1) {
+ *error = "queue-length ps: incorrect number of arguments";
+ return -EINVAL;
+ }
+
+ if ((argc == 1) && (sscanf(argv[0], "%u", &repeat_count) != 1)) {
+ *error = "queue-length ps: invalid repeat count";
+ return -EINVAL;
+ }
+
+ /* Allocate the path information structure */
+ pi = kmalloc(sizeof(*pi), GFP_KERNEL);
+ if (!pi) {
+ *error = "queue-length ps: Error allocating path information";
+ return -ENOMEM;
+ }
+
+ pi->path = path;
+ pi->repeat_count = repeat_count;
+ atomic_set(&pi->qlen, 0);
+
+ path->pscontext = pi;
+
+ list_add_tail(&pi->list, &s->valid_paths);
+
+ return 0;
+}
+
+static void ql_fail_path(struct path_selector *ps, struct dm_path *path)
+{
+ struct selector *s = ps->context;
+ struct path_info *pi = path->pscontext;
+
+ list_move(&pi->list, &s->failed_paths);
+}
+
+static int ql_reinstate_path(struct path_selector *ps, struct dm_path *path)
+{
+ struct selector *s = ps->context;
+ struct path_info *pi = path->pscontext;
+
+ list_move_tail(&pi->list, &s->valid_paths);
+
+ return 0;
+}
+
+/*
+ * Select a path having the minimum number of in-flight I/Os
+ */
+static struct dm_path *ql_select_path(struct path_selector *ps,
+ unsigned *repeat_count, size_t nr_bytes)
+{
+ struct selector *s = ps->context;
+ struct path_info *pi = NULL, *best = NULL;
+
+ if (list_empty(&s->valid_paths))
+ return NULL;
+
+ /* Change preferred (first in list) path to evenly balance. */
+ list_move_tail(s->valid_paths.next, &s->valid_paths);
+
+ list_for_each_entry(pi, &s->valid_paths, list) {
+ if (!best ||
+ (atomic_read(&pi->qlen) < atomic_read(&best->qlen)))
+ best = pi;
+
+ if (!atomic_read(&best->qlen))
+ break;
+ }
+
+ if (!best)
+ return NULL;
+
+ *repeat_count = best->repeat_count;
+
+ return best->path;
+}
+
+static int ql_start_io(struct path_selector *ps, struct dm_path *path,
+ size_t nr_bytes)
+{
+ struct path_info *pi = path->pscontext;
+
+ atomic_inc(&pi->qlen);
+
+ return 0;
+}
+
+static int ql_end_io(struct path_selector *ps, struct dm_path *path,
+ size_t nr_bytes)
+{
+ struct path_info *pi = path->pscontext;
+
+ atomic_dec(&pi->qlen);
+
+ return 0;
+}
+
+static struct path_selector_type ql_ps = {
+ .name = "queue-length",
+ .module = THIS_MODULE,
+ .table_args = 1,
+ .info_args = 1,
+ .create = ql_create,
+ .destroy = ql_destroy,
+ .status = ql_status,
+ .add_path = ql_add_path,
+ .fail_path = ql_fail_path,
+ .reinstate_path = ql_reinstate_path,
+ .select_path = ql_select_path,
+ .start_io = ql_start_io,
+ .end_io = ql_end_io,
+};
+
+static int __init dm_ql_init(void)
+{
+ int r = dm_register_path_selector(&ql_ps);
+
+ if (r < 0)
+ DMERR("register failed %d", r);
+
+ DMINFO("version " QL_VERSION " loaded");
+
+ return r;
+}
+
+static void __exit dm_ql_exit(void)
+{
+ int r = dm_unregister_path_selector(&ql_ps);
+
+ if (r < 0)
+ DMERR("unregister failed %d", r);
+}
+
+module_init(dm_ql_init);
+module_exit(dm_ql_exit);
+
+MODULE_AUTHOR("Stefan Bader <Stefan.Bader at de.ibm.com>");
+MODULE_DESCRIPTION(
+ "(C) Copyright IBM Corp. 2004,2005 All Rights Reserved.\n"
+ DM_NAME " path selector to balance the number of in-flight I/Os"
+);
+MODULE_LICENSE("GPL");
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
index 7b899be0b087..36dbe29f2fd6 100644
--- a/drivers/md/dm-region-hash.c
+++ b/drivers/md/dm-region-hash.c
@@ -283,7 +283,7 @@ static struct dm_region *__rh_alloc(struct dm_region_hash *rh, region_t region)
nreg = mempool_alloc(rh->region_pool, GFP_ATOMIC);
if (unlikely(!nreg))
- nreg = kmalloc(sizeof(*nreg), GFP_NOIO);
+ nreg = kmalloc(sizeof(*nreg), GFP_NOIO | __GFP_NOFAIL);
nreg->state = rh->log->type->in_sync(rh->log, region, 1) ?
DM_RH_CLEAN : DM_RH_NOSYNC;
diff --git a/drivers/md/dm-round-robin.c b/drivers/md/dm-round-robin.c
index cdfbf65b28cb..24752f449bef 100644
--- a/drivers/md/dm-round-robin.c
+++ b/drivers/md/dm-round-robin.c
@@ -161,7 +161,7 @@ static int rr_reinstate_path(struct path_selector *ps, struct dm_path *p)
}
static struct dm_path *rr_select_path(struct path_selector *ps,
- unsigned *repeat_count)
+ unsigned *repeat_count, size_t nr_bytes)
{
struct selector *s = (struct selector *) ps->context;
struct path_info *pi = NULL;
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index e75c6dd76a9a..6e3fe4f14934 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -282,7 +282,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)
*/
if (!ps->store->chunk_size) {
ps->store->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS,
- bdev_hardsect_size(ps->store->cow->bdev) >> 9);
+ bdev_logical_block_size(ps->store->cow->bdev) >> 9);
ps->store->chunk_mask = ps->store->chunk_size - 1;
ps->store->chunk_shift = ffs(ps->store->chunk_size) - 1;
chunk_size_supplied = 0;
@@ -636,7 +636,7 @@ static void persistent_commit_exception(struct dm_exception_store *store,
/*
* Commit exceptions to disk.
*/
- if (ps->valid && area_io(ps, WRITE))
+ if (ps->valid && area_io(ps, WRITE_BARRIER))
ps->valid = 0;
/*
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index d73f17fc7778..d573165cd2b7 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -678,6 +678,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->private = s;
ti->split_io = s->store->chunk_size;
+ ti->num_flush_requests = 1;
return 0;
@@ -1030,6 +1031,11 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
chunk_t chunk;
struct dm_snap_pending_exception *pe = NULL;
+ if (unlikely(bio_empty_barrier(bio))) {
+ bio->bi_bdev = s->store->cow->bdev;
+ return DM_MAPIO_REMAPPED;
+ }
+
chunk = sector_to_chunk(s->store, bio->bi_sector);
/* Full snapshots are not usable */
@@ -1338,6 +1344,8 @@ static int origin_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}
ti->private = dev;
+ ti->num_flush_requests = 1;
+
return 0;
}
@@ -1353,6 +1361,9 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
struct dm_dev *dev = ti->private;
bio->bi_bdev = dev->bdev;
+ if (unlikely(bio_empty_barrier(bio)))
+ return DM_MAPIO_REMAPPED;
+
/* Only tell snapshots if this is a write */
return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED;
}
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 41569bc60abc..c64fe827a5f1 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -167,6 +167,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
sc->stripes = stripes;
sc->stripe_width = width;
ti->split_io = chunk_size;
+ ti->num_flush_requests = stripes;
sc->chunk_mask = ((sector_t) chunk_size) - 1;
for (sc->chunk_shift = 0; chunk_size; sc->chunk_shift++)
@@ -211,10 +212,18 @@ static int stripe_map(struct dm_target *ti, struct bio *bio,
union map_info *map_context)
{
struct stripe_c *sc = (struct stripe_c *) ti->private;
+ sector_t offset, chunk;
+ uint32_t stripe;
- sector_t offset = bio->bi_sector - ti->begin;
- sector_t chunk = offset >> sc->chunk_shift;
- uint32_t stripe = sector_div(chunk, sc->stripes);
+ if (unlikely(bio_empty_barrier(bio))) {
+ BUG_ON(map_context->flush_request >= sc->stripes);
+ bio->bi_bdev = sc->stripe[map_context->flush_request].dev->bdev;
+ return DM_MAPIO_REMAPPED;
+ }
+
+ offset = bio->bi_sector - ti->begin;
+ chunk = offset >> sc->chunk_shift;
+ stripe = sector_div(chunk, sc->stripes);
bio->bi_bdev = sc->stripe[stripe].dev->bdev;
bio->bi_sector = sc->stripe[stripe].physical_start +
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 429b50b975d5..8f734ada22f2 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -108,7 +108,8 @@ static void combine_restrictions_low(struct io_restrictions *lhs,
lhs->max_hw_segments =
min_not_zero(lhs->max_hw_segments, rhs->max_hw_segments);
- lhs->hardsect_size = max(lhs->hardsect_size, rhs->hardsect_size);
+ lhs->logical_block_size = max(lhs->logical_block_size,
+ rhs->logical_block_size);
lhs->max_segment_size =
min_not_zero(lhs->max_segment_size, rhs->max_segment_size);
@@ -266,6 +267,8 @@ static void free_devices(struct list_head *devices)
list_for_each_safe(tmp, next, devices) {
struct dm_dev_internal *dd =
list_entry(tmp, struct dm_dev_internal, list);
+ DMWARN("dm_table_destroy: dm_put_device call missing for %s",
+ dd->dm_dev.name);
kfree(dd);
}
}
@@ -295,12 +298,8 @@ void dm_table_destroy(struct dm_table *t)
vfree(t->highs);
/* free the device list */
- if (t->devices.next != &t->devices) {
- DMWARN("devices still present during destroy: "
- "dm_table_remove_device calls missing");
-
+ if (t->devices.next != &t->devices)
free_devices(&t->devices);
- }
kfree(t);
}
@@ -384,15 +383,42 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
/*
* If possible, this checks an area of a destination device is valid.
*/
-static int check_device_area(struct dm_dev_internal *dd, sector_t start,
- sector_t len)
+static int device_area_is_valid(struct dm_target *ti, struct block_device *bdev,
+ sector_t start, sector_t len)
{
- sector_t dev_size = dd->dm_dev.bdev->bd_inode->i_size >> SECTOR_SHIFT;
+ sector_t dev_size = bdev->bd_inode->i_size >> SECTOR_SHIFT;
+ unsigned short hardsect_size_sectors = ti->limits.logical_block_size >>
+ SECTOR_SHIFT;
+ char b[BDEVNAME_SIZE];
if (!dev_size)
return 1;
- return ((start < dev_size) && (len <= (dev_size - start)));
+ if ((start >= dev_size) || (start + len > dev_size)) {
+ DMWARN("%s: %s too small for target",
+ dm_device_name(ti->table->md), bdevname(bdev, b));
+ return 0;
+ }
+
+ if (hardsect_size_sectors <= 1)
+ return 1;
+
+ if (start & (hardsect_size_sectors - 1)) {
+ DMWARN("%s: start=%llu not aligned to h/w sector of %s",
+ dm_device_name(ti->table->md),
+ (unsigned long long)start, bdevname(bdev, b));
+ return 0;
+ }
+
+ if (len & (hardsect_size_sectors - 1)) {
+ DMWARN("%s: len=%llu not aligned to h/w sector size %hu of %s",
+ dm_device_name(ti->table->md),
+ (unsigned long long)len,
+ ti->limits.logical_block_size, bdevname(bdev, b));
+ return 0;
+ }
+
+ return 1;
}
/*
@@ -478,14 +504,7 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti,
}
atomic_inc(&dd->count);
- if (!check_device_area(dd, start, len)) {
- DMWARN("device %s too small for target", path);
- dm_put_device(ti, &dd->dm_dev);
- return -EINVAL;
- }
-
*result = &dd->dm_dev;
-
return 0;
}
@@ -509,7 +528,7 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
* combine_restrictions_low()
*/
rs->max_sectors =
- min_not_zero(rs->max_sectors, q->max_sectors);
+ min_not_zero(rs->max_sectors, queue_max_sectors(q));
/*
* Check if merge fn is supported.
@@ -524,24 +543,25 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
rs->max_phys_segments =
min_not_zero(rs->max_phys_segments,
- q->max_phys_segments);
+ queue_max_phys_segments(q));
rs->max_hw_segments =
- min_not_zero(rs->max_hw_segments, q->max_hw_segments);
+ min_not_zero(rs->max_hw_segments, queue_max_hw_segments(q));
- rs->hardsect_size = max(rs->hardsect_size, q->hardsect_size);
+ rs->logical_block_size = max(rs->logical_block_size,
+ queue_logical_block_size(q));
rs->max_segment_size =
- min_not_zero(rs->max_segment_size, q->max_segment_size);
+ min_not_zero(rs->max_segment_size, queue_max_segment_size(q));
rs->max_hw_sectors =
- min_not_zero(rs->max_hw_sectors, q->max_hw_sectors);
+ min_not_zero(rs->max_hw_sectors, queue_max_hw_sectors(q));
rs->seg_boundary_mask =
min_not_zero(rs->seg_boundary_mask,
- q->seg_boundary_mask);
+ queue_segment_boundary(q));
- rs->bounce_pfn = min_not_zero(rs->bounce_pfn, q->bounce_pfn);
+ rs->bounce_pfn = min_not_zero(rs->bounce_pfn, queue_bounce_pfn(q));
rs->no_cluster |= !test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
}
@@ -553,8 +573,16 @@ int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
int r = __table_get_device(ti->table, ti, path,
start, len, mode, result);
- if (!r)
- dm_set_device_limits(ti, (*result)->bdev);
+ if (r)
+ return r;
+
+ dm_set_device_limits(ti, (*result)->bdev);
+
+ if (!device_area_is_valid(ti, (*result)->bdev, start, len)) {
+ dm_put_device(ti, *result);
+ *result = NULL;
+ return -EINVAL;
+ }
return r;
}
@@ -683,8 +711,8 @@ static void check_for_valid_limits(struct io_restrictions *rs)
rs->max_phys_segments = MAX_PHYS_SEGMENTS;
if (!rs->max_hw_segments)
rs->max_hw_segments = MAX_HW_SEGMENTS;
- if (!rs->hardsect_size)
- rs->hardsect_size = 1 << SECTOR_SHIFT;
+ if (!rs->logical_block_size)
+ rs->logical_block_size = 1 << SECTOR_SHIFT;
if (!rs->max_segment_size)
rs->max_segment_size = MAX_SEGMENT_SIZE;
if (!rs->seg_boundary_mask)
@@ -693,6 +721,71 @@ static void check_for_valid_limits(struct io_restrictions *rs)
rs->bounce_pfn = -1;
}
+/*
+ * Impose necessary and sufficient conditions on a devices's table such
+ * that any incoming bio which respects its hardsect_size can be
+ * processed successfully. If it falls across the boundary between
+ * two or more targets, the size of each piece it gets split into must
+ * be compatible with the hardsect_size of the target processing it.
+ */
+static int validate_hardsect_alignment(struct dm_table *table)
+{
+ /*
+ * This function uses arithmetic modulo the hardsect_size
+ * (in units of 512-byte sectors).
+ */
+ unsigned short device_hardsect_size_sects =
+ table->limits.logical_block_size >> SECTOR_SHIFT;
+
+ /*
+ * Offset of the start of the next table entry, mod hardsect_size.
+ */
+ unsigned short next_target_start = 0;
+
+ /*
+ * Given an aligned bio that extends beyond the end of a
+ * target, how many sectors must the next target handle?
+ */
+ unsigned short remaining = 0;
+
+ struct dm_target *uninitialized_var(ti);
+ unsigned i = 0;
+
+ /*
+ * Check each entry in the table in turn.
+ */
+ while (i < dm_table_get_num_targets(table)) {
+ ti = dm_table_get_target(table, i++);
+
+ /*
+ * If the remaining sectors fall entirely within this
+ * table entry are they compatible with its hardsect_size?
+ */
+ if (remaining < ti->len &&
+ remaining & ((ti->limits.logical_block_size >>
+ SECTOR_SHIFT) - 1))
+ break; /* Error */
+
+ next_target_start =
+ (unsigned short) ((next_target_start + ti->len) &
+ (device_hardsect_size_sects - 1));
+ remaining = next_target_start ?
+ device_hardsect_size_sects - next_target_start : 0;
+ }
+
+ if (remaining) {
+ DMWARN("%s: table line %u (start sect %llu len %llu) "
+ "not aligned to hardware sector size %hu",
+ dm_device_name(table->md), i,
+ (unsigned long long) ti->begin,
+ (unsigned long long) ti->len,
+ table->limits.logical_block_size);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
int dm_table_add_target(struct dm_table *t, const char *type,
sector_t start, sector_t len, char *params)
{
@@ -792,6 +885,10 @@ int dm_table_complete(struct dm_table *t)
check_for_valid_limits(&t->limits);
+ r = validate_hardsect_alignment(t);
+ if (r)
+ return r;
+
/* how many indexes will the btree have ? */
leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
@@ -912,13 +1009,13 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q)
* restrictions.
*/
blk_queue_max_sectors(q, t->limits.max_sectors);
- q->max_phys_segments = t->limits.max_phys_segments;
- q->max_hw_segments = t->limits.max_hw_segments;
- q->hardsect_size = t->limits.hardsect_size;
- q->max_segment_size = t->limits.max_segment_size;
- q->max_hw_sectors = t->limits.max_hw_sectors;
- q->seg_boundary_mask = t->limits.seg_boundary_mask;
- q->bounce_pfn = t->limits.bounce_pfn;
+ blk_queue_max_phys_segments(q, t->limits.max_phys_segments);
+ blk_queue_max_hw_segments(q, t->limits.max_hw_segments);
+ blk_queue_logical_block_size(q, t->limits.logical_block_size);
+ blk_queue_max_segment_size(q, t->limits.max_segment_size);
+ blk_queue_max_hw_sectors(q, t->limits.max_hw_sectors);
+ blk_queue_segment_boundary(q, t->limits.seg_boundary_mask);
+ blk_queue_bounce_limit(q, t->limits.bounce_pfn);
if (t->limits.no_cluster)
queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 424f7b048c30..ededb6cb8a23 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -159,13 +159,16 @@ struct mapped_device {
* freeze/thaw support require holding onto a super block
*/
struct super_block *frozen_sb;
- struct block_device *suspended_bdev;
+ struct block_device *bdev;
/* forced geometry settings */
struct hd_geometry geometry;
/* sysfs handle */
struct kobject kobj;
+
+ /* zero-length barrier that will be cloned and submitted to targets */
+ struct bio barrier_bio;
};
#define MIN_IOS 256
@@ -393,11 +396,6 @@ static void free_io(struct mapped_device *md, struct dm_io *io)
mempool_free(io, md->io_pool);
}
-static struct dm_target_io *alloc_tio(struct mapped_device *md)
-{
- return mempool_alloc(md->tio_pool, GFP_NOIO);
-}
-
static void free_tio(struct mapped_device *md, struct dm_target_io *tio)
{
mempool_free(tio, md->tio_pool);
@@ -538,9 +536,11 @@ static void dec_pending(struct dm_io *io, int error)
* Target requested pushing back the I/O.
*/
spin_lock_irqsave(&md->deferred_lock, flags);
- if (__noflush_suspending(md))
- bio_list_add_head(&md->deferred, io->bio);
- else
+ if (__noflush_suspending(md)) {
+ if (!bio_barrier(io->bio))
+ bio_list_add_head(&md->deferred,
+ io->bio);
+ } else
/* noflush suspend was interrupted. */
io->error = -EIO;
spin_unlock_irqrestore(&md->deferred_lock, flags);
@@ -555,7 +555,8 @@ static void dec_pending(struct dm_io *io, int error)
* a per-device variable for error reporting.
* Note that you can't touch the bio after end_io_acct
*/
- md->barrier_error = io_error;
+ if (!md->barrier_error && io_error != -EOPNOTSUPP)
+ md->barrier_error = io_error;
end_io_acct(io);
} else {
end_io_acct(io);
@@ -636,11 +637,6 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
sector_t sector;
struct mapped_device *md;
- /*
- * Sanity checks.
- */
- BUG_ON(!clone->bi_size);
-
clone->bi_end_io = clone_endio;
clone->bi_private = tio;
@@ -656,8 +652,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
/* the bio has been remapped so dispatch it */
trace_block_remap(bdev_get_queue(clone->bi_bdev), clone,
- tio->io->bio->bi_bdev->bd_dev,
- clone->bi_sector, sector);
+ tio->io->bio->bi_bdev->bd_dev, sector);
generic_make_request(clone);
} else if (r < 0 || r == DM_MAPIO_REQUEUE) {
@@ -755,6 +750,48 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector,
return clone;
}
+static struct dm_target_io *alloc_tio(struct clone_info *ci,
+ struct dm_target *ti)
+{
+ struct dm_target_io *tio = mempool_alloc(ci->md->tio_pool, GFP_NOIO);
+
+ tio->io = ci->io;
+ tio->ti = ti;
+ memset(&tio->info, 0, sizeof(tio->info));
+
+ return tio;
+}
+
+static void __flush_target(struct clone_info *ci, struct dm_target *ti,
+ unsigned flush_nr)
+{
+ struct dm_target_io *tio = alloc_tio(ci, ti);
+ struct bio *clone;
+
+ tio->info.flush_request = flush_nr;
+
+ clone = bio_alloc_bioset(GFP_NOIO, 0, ci->md->bs);
+ __bio_clone(clone, ci->bio);
+ clone->bi_destructor = dm_bio_destructor;
+
+ __map_bio(ti, clone, tio);
+}
+
+static int __clone_and_map_empty_barrier(struct clone_info *ci)
+{
+ unsigned target_nr = 0, flush_nr;
+ struct dm_target *ti;
+
+ while ((ti = dm_table_get_target(ci->map, target_nr++)))
+ for (flush_nr = 0; flush_nr < ti->num_flush_requests;
+ flush_nr++)
+ __flush_target(ci, ti, flush_nr);
+
+ ci->sector_count = 0;
+
+ return 0;
+}
+
static int __clone_and_map(struct clone_info *ci)
{
struct bio *clone, *bio = ci->bio;
@@ -762,6 +799,9 @@ static int __clone_and_map(struct clone_info *ci)
sector_t len = 0, max;
struct dm_target_io *tio;
+ if (unlikely(bio_empty_barrier(bio)))
+ return __clone_and_map_empty_barrier(ci);
+
ti = dm_table_find_target(ci->map, ci->sector);
if (!dm_target_is_valid(ti))
return -EIO;
@@ -771,10 +811,7 @@ static int __clone_and_map(struct clone_info *ci)
/*
* Allocate a target io object.
*/
- tio = alloc_tio(ci->md);
- tio->io = ci->io;
- tio->ti = ti;
- memset(&tio->info, 0, sizeof(tio->info));
+ tio = alloc_tio(ci, ti);
if (ci->sector_count <= max) {
/*
@@ -830,10 +867,7 @@ static int __clone_and_map(struct clone_info *ci)
max = max_io_len(ci->md, ci->sector, ti);
- tio = alloc_tio(ci->md);
- tio->io = ci->io;
- tio->ti = ti;
- memset(&tio->info, 0, sizeof(tio->info));
+ tio = alloc_tio(ci, ti);
}
len = min(remaining, max);
@@ -868,7 +902,8 @@ static void __split_and_process_bio(struct mapped_device *md, struct bio *bio)
if (!bio_barrier(bio))
bio_io_error(bio);
else
- md->barrier_error = -EIO;
+ if (!md->barrier_error)
+ md->barrier_error = -EIO;
return;
}
@@ -881,6 +916,8 @@ static void __split_and_process_bio(struct mapped_device *md, struct bio *bio)
ci.io->md = md;
ci.sector = bio->bi_sector;
ci.sector_count = bio_sectors(bio);
+ if (unlikely(bio_empty_barrier(bio)))
+ ci.sector_count = 1;
ci.idx = bio->bi_idx;
start_io_acct(ci.io);
@@ -928,6 +965,15 @@ static int dm_merge_bvec(struct request_queue *q,
*/
if (max_size && ti->type->merge)
max_size = ti->type->merge(ti, bvm, biovec, max_size);
+ /*
+ * If the target doesn't support merge method and some of the devices
+ * provided their merge_bvec method (we know this by looking at
+ * max_hw_sectors), then we can't allow bios with multiple vector
+ * entries. So always set max_size to 0, and the code below allows
+ * just one page.
+ */
+ else if (queue_max_hw_sectors(q) <= PAGE_SIZE >> 9)
+ max_size = 0;
out_table:
dm_table_put(map);
@@ -1173,6 +1219,10 @@ static struct mapped_device *alloc_dev(int minor)
if (!md->wq)
goto bad_thread;
+ md->bdev = bdget_disk(md->disk, 0);
+ if (!md->bdev)
+ goto bad_bdev;
+
/* Populate the mapping, nobody knows we exist yet */
spin_lock(&_minor_lock);
old_md = idr_replace(&_minor_idr, md, minor);
@@ -1182,6 +1232,8 @@ static struct mapped_device *alloc_dev(int minor)
return md;
+bad_bdev:
+ destroy_workqueue(md->wq);
bad_thread:
put_disk(md->disk);
bad_disk:
@@ -1207,10 +1259,8 @@ static void free_dev(struct mapped_device *md)
{
int minor = MINOR(disk_devt(md->disk));
- if (md->suspended_bdev) {
- unlock_fs(md);
- bdput(md->suspended_bdev);
- }
+ unlock_fs(md);
+ bdput(md->bdev);
destroy_workqueue(md->wq);
mempool_destroy(md->tio_pool);
mempool_destroy(md->io_pool);
@@ -1252,9 +1302,9 @@ static void __set_size(struct mapped_device *md, sector_t size)
{
set_capacity(md->disk, size);
- mutex_lock(&md->suspended_bdev->bd_inode->i_mutex);
- i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
- mutex_unlock(&md->suspended_bdev->bd_inode->i_mutex);
+ mutex_lock(&md->bdev->bd_inode->i_mutex);
+ i_size_write(md->bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
+ mutex_unlock(&md->bdev->bd_inode->i_mutex);
}
static int __bind(struct mapped_device *md, struct dm_table *t)
@@ -1270,8 +1320,7 @@ static int __bind(struct mapped_device *md, struct dm_table *t)
if (size != get_capacity(md->disk))
memset(&md->geometry, 0, sizeof(md->geometry));
- if (md->suspended_bdev)
- __set_size(md, size);
+ __set_size(md, size);
if (!size) {
dm_table_destroy(t);
@@ -1429,34 +1478,36 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
return r;
}
-static int dm_flush(struct mapped_device *md)
+static void dm_flush(struct mapped_device *md)
{
dm_wait_for_completion(md, TASK_UNINTERRUPTIBLE);
- return 0;
+
+ bio_init(&md->barrier_bio);
+ md->barrier_bio.bi_bdev = md->bdev;
+ md->barrier_bio.bi_rw = WRITE_BARRIER;
+ __split_and_process_bio(md, &md->barrier_bio);
+
+ dm_wait_for_completion(md, TASK_UNINTERRUPTIBLE);
}
static void process_barrier(struct mapped_device *md, struct bio *bio)
{
- int error = dm_flush(md);
+ md->barrier_error = 0;
- if (unlikely(error)) {
- bio_endio(bio, error);
- return;
- }
- if (bio_empty_barrier(bio)) {
- bio_endio(bio, 0);
- return;
- }
+ dm_flush(md);
- __split_and_process_bio(md, bio);
-
- error = dm_flush(md);
-
- if (!error && md->barrier_error)
- error = md->barrier_error;
+ if (!bio_empty_barrier(bio)) {
+ __split_and_process_bio(md, bio);
+ dm_flush(md);
+ }
if (md->barrier_error != DM_ENDIO_REQUEUE)
- bio_endio(bio, error);
+ bio_endio(bio, md->barrier_error);
+ else {
+ spin_lock_irq(&md->deferred_lock);
+ bio_list_add_head(&md->deferred, bio);
+ spin_unlock_irq(&md->deferred_lock);
+ }
}
/*
@@ -1513,11 +1564,6 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
if (!dm_suspended(md))
goto out;
- /* without bdev, the device size cannot be changed */
- if (!md->suspended_bdev)
- if (get_capacity(md->disk) != dm_table_get_size(table))
- goto out;
-
__unbind(md);
r = __bind(md, table);
@@ -1536,7 +1582,7 @@ static int lock_fs(struct mapped_device *md)
WARN_ON(md->frozen_sb);
- md->frozen_sb = freeze_bdev(md->suspended_bdev);
+ md->frozen_sb = freeze_bdev(md->bdev);
if (IS_ERR(md->frozen_sb)) {
r = PTR_ERR(md->frozen_sb);
md->frozen_sb = NULL;
@@ -1545,9 +1591,6 @@ static int lock_fs(struct mapped_device *md)
set_bit(DMF_FROZEN, &md->flags);
- /* don't bdput right now, we don't want the bdev
- * to go away while it is locked.
- */
return 0;
}
@@ -1556,7 +1599,7 @@ static void unlock_fs(struct mapped_device *md)
if (!test_bit(DMF_FROZEN, &md->flags))
return;
- thaw_bdev(md->suspended_bdev, md->frozen_sb);
+ thaw_bdev(md->bdev, md->frozen_sb);
md->frozen_sb = NULL;
clear_bit(DMF_FROZEN, &md->flags);
}
@@ -1594,24 +1637,14 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
/* This does not get reverted if there's an error later. */
dm_table_presuspend_targets(map);
- /* bdget() can stall if the pending I/Os are not flushed */
- if (!noflush) {
- md->suspended_bdev = bdget_disk(md->disk, 0);
- if (!md->suspended_bdev) {
- DMWARN("bdget failed in dm_suspend");
- r = -ENOMEM;
+ /*
+ * Flush I/O to the device. noflush supersedes do_lockfs,
+ * because lock_fs() needs to flush I/Os.
+ */
+ if (!noflush && do_lockfs) {
+ r = lock_fs(md);
+ if (r)
goto out;
- }
-
- /*
- * Flush I/O to the device. noflush supersedes do_lockfs,
- * because lock_fs() needs to flush I/Os.
- */
- if (do_lockfs) {
- r = lock_fs(md);
- if (r)
- goto out;
- }
}
/*
@@ -1668,11 +1701,6 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
set_bit(DMF_SUSPENDED, &md->flags);
out:
- if (r && md->suspended_bdev) {
- bdput(md->suspended_bdev);
- md->suspended_bdev = NULL;
- }
-
dm_table_put(map);
out_unlock:
@@ -1701,11 +1729,6 @@ int dm_resume(struct mapped_device *md)
unlock_fs(md);
- if (md->suspended_bdev) {
- bdput(md->suspended_bdev);
- md->suspended_bdev = NULL;
- }
-
clear_bit(DMF_SUSPENDED, &md->flags);
dm_table_unplug_all(map);
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 8695809b24b0..6e83b38d931d 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -255,14 +255,14 @@ static void status(struct seq_file *seq, mddev_t *mddev)
}
-static int reconfig(mddev_t *mddev, int layout, int chunk_size)
+static int reshape(mddev_t *mddev)
{
- int mode = layout & ModeMask;
- int count = layout >> ModeShift;
+ int mode = mddev->new_layout & ModeMask;
+ int count = mddev->new_layout >> ModeShift;
conf_t *conf = mddev->private;
- if (chunk_size != -1)
- return -EINVAL;
+ if (mddev->new_layout < 0)
+ return 0;
/* new layout */
if (mode == ClearFaults)
@@ -279,6 +279,7 @@ static int reconfig(mddev_t *mddev, int layout, int chunk_size)
atomic_set(&conf->counters[mode], count);
} else
return -EINVAL;
+ mddev->new_layout = -1;
mddev->layout = -1; /* makes sure further changes come through */
return 0;
}
@@ -315,7 +316,7 @@ static int run(mddev_t *mddev)
md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
mddev->private = conf;
- reconfig(mddev, mddev->layout, -1);
+ reshape(mddev);
return 0;
}
@@ -338,7 +339,7 @@ static struct mdk_personality faulty_personality =
.run = run,
.stop = stop,
.status = status,
- .reconfig = reconfig,
+ .check_reshape = reshape,
.size = faulty_size,
};
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 7a36e38393a1..9f7cec42dd8e 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -27,19 +27,26 @@
*/
static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
{
- dev_info_t *hash;
- linear_conf_t *conf = mddev_to_conf(mddev);
- sector_t idx = sector >> conf->sector_shift;
+ int lo, mid, hi;
+ linear_conf_t *conf = mddev->private;
+
+ lo = 0;
+ hi = mddev->raid_disks - 1;
/*
- * sector_div(a,b) returns the remainer and sets a to a/b
+ * Binary Search
*/
- (void)sector_div(idx, conf->spacing);
- hash = conf->hash_table[idx];
- while (sector >= hash->num_sectors + hash->start_sector)
- hash++;
- return hash;
+ while (hi > lo) {
+
+ mid = (hi + lo) / 2;
+ if (sector < conf->disks[mid].end_sector)
+ hi = mid;
+ else
+ lo = mid + 1;
+ }
+
+ return conf->disks + lo;
}
/**
@@ -60,7 +67,7 @@ static int linear_mergeable_bvec(struct request_queue *q,
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
dev0 = which_dev(mddev, sector);
- maxsectors = dev0->num_sectors - (sector - dev0->start_sector);
+ maxsectors = dev0->end_sector - sector;
if (maxsectors < bio_sectors)
maxsectors = 0;
@@ -79,7 +86,7 @@ static int linear_mergeable_bvec(struct request_queue *q,
static void linear_unplug(struct request_queue *q)
{
mddev_t *mddev = q->queuedata;
- linear_conf_t *conf = mddev_to_conf(mddev);
+ linear_conf_t *conf = mddev->private;
int i;
for (i=0; i < mddev->raid_disks; i++) {
@@ -91,7 +98,7 @@ static void linear_unplug(struct request_queue *q)
static int linear_congested(void *data, int bits)
{
mddev_t *mddev = data;
- linear_conf_t *conf = mddev_to_conf(mddev);
+ linear_conf_t *conf = mddev->private;
int i, ret = 0;
for (i = 0; i < mddev->raid_disks && !ret ; i++) {
@@ -103,7 +110,7 @@ static int linear_congested(void *data, int bits)
static sector_t linear_size(mddev_t *mddev, sector_t sectors, int raid_disks)
{
- linear_conf_t *conf = mddev_to_conf(mddev);
+ linear_conf_t *conf = mddev->private;
WARN_ONCE(sectors || raid_disks,
"%s does not support generic reshape\n", __func__);
@@ -114,11 +121,8 @@ static sector_t linear_size(mddev_t *mddev, sector_t sectors, int raid_disks)
static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
{
linear_conf_t *conf;
- dev_info_t **table;
mdk_rdev_t *rdev;
- int i, nb_zone, cnt;
- sector_t min_sectors;
- sector_t curr_sector;
+ int i, cnt;
conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t),
GFP_KERNEL);
@@ -146,105 +150,27 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
* a one page request is never in violation.
*/
if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
- disk->num_sectors = rdev->sectors;
conf->array_sectors += rdev->sectors;
-
cnt++;
+
}
if (cnt != raid_disks) {
printk("linear: not enough drives present. Aborting!\n");
goto out;
}
- min_sectors = conf->array_sectors;
- sector_div(min_sectors, PAGE_SIZE/sizeof(struct dev_info *));
- if (min_sectors == 0)
- min_sectors = 1;
-
- /* min_sectors is the minimum spacing that will fit the hash
- * table in one PAGE. This may be much smaller than needed.
- * We find the smallest non-terminal set of consecutive devices
- * that is larger than min_sectors and use the size of that as
- * the actual spacing
- */
- conf->spacing = conf->array_sectors;
- for (i=0; i < cnt-1 ; i++) {
- sector_t tmp = 0;
- int j;
- for (j = i; j < cnt - 1 && tmp < min_sectors; j++)
- tmp += conf->disks[j].num_sectors;
- if (tmp >= min_sectors && tmp < conf->spacing)
- conf->spacing = tmp;
- }
-
- /* spacing may be too large for sector_div to work with,
- * so we might need to pre-shift
- */
- conf->sector_shift = 0;
- if (sizeof(sector_t) > sizeof(u32)) {
- sector_t space = conf->spacing;
- while (space > (sector_t)(~(u32)0)) {
- space >>= 1;
- conf->sector_shift++;
- }
- }
/*
- * This code was restructured to work around a gcc-2.95.3 internal
- * compiler error. Alter it with care.
+ * Here we calculate the device offsets.
*/
- {
- sector_t sz;
- unsigned round;
- unsigned long base;
-
- sz = conf->array_sectors >> conf->sector_shift;
- sz += 1; /* force round-up */
- base = conf->spacing >> conf->sector_shift;
- round = sector_div(sz, base);
- nb_zone = sz + (round ? 1 : 0);
- }
- BUG_ON(nb_zone > PAGE_SIZE / sizeof(struct dev_info *));
+ conf->disks[0].end_sector = conf->disks[0].rdev->sectors;
- conf->hash_table = kmalloc (sizeof (struct dev_info *) * nb_zone,
- GFP_KERNEL);
- if (!conf->hash_table)
- goto out;
-
- /*
- * Here we generate the linear hash table
- * First calculate the device offsets.
- */
- conf->disks[0].start_sector = 0;
for (i = 1; i < raid_disks; i++)
- conf->disks[i].start_sector =
- conf->disks[i-1].start_sector +
- conf->disks[i-1].num_sectors;
-
- table = conf->hash_table;
- i = 0;
- for (curr_sector = 0;
- curr_sector < conf->array_sectors;
- curr_sector += conf->spacing) {
-
- while (i < raid_disks-1 &&
- curr_sector >= conf->disks[i+1].start_sector)
- i++;
-
- *table ++ = conf->disks + i;
- }
-
- if (conf->sector_shift) {
- conf->spacing >>= conf->sector_shift;
- /* round spacing up so that when we divide by it,
- * we err on the side of "too-low", which is safest.
- */
- conf->spacing++;
- }
-
- BUG_ON(table - conf->hash_table > nb_zone);
+ conf->disks[i].end_sector =
+ conf->disks[i-1].end_sector +
+ conf->disks[i].rdev->sectors;
return conf;
@@ -294,7 +220,7 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
if (!newconf)
return -ENOMEM;
- newconf->prev = mddev_to_conf(mddev);
+ newconf->prev = mddev->private;
mddev->private = newconf;
mddev->raid_disks++;
md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
@@ -304,12 +230,11 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
static int linear_stop (mddev_t *mddev)
{
- linear_conf_t *conf = mddev_to_conf(mddev);
+ linear_conf_t *conf = mddev->private;
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
do {
linear_conf_t *t = conf->prev;
- kfree(conf->hash_table);
kfree(conf);
conf = t;
} while (conf);
@@ -322,6 +247,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
const int rw = bio_data_dir(bio);
mddev_t *mddev = q->queuedata;
dev_info_t *tmp_dev;
+ sector_t start_sector;
int cpu;
if (unlikely(bio_barrier(bio))) {
@@ -336,32 +262,30 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
part_stat_unlock();
tmp_dev = which_dev(mddev, bio->bi_sector);
-
- if (unlikely(bio->bi_sector >= (tmp_dev->num_sectors +
- tmp_dev->start_sector)
- || (bio->bi_sector <
- tmp_dev->start_sector))) {
+ start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
+
+ if (unlikely(bio->bi_sector >= (tmp_dev->end_sector)
+ || (bio->bi_sector < start_sector))) {
char b[BDEVNAME_SIZE];
printk("linear_make_request: Sector %llu out of bounds on "
"dev %s: %llu sectors, offset %llu\n",
(unsigned long long)bio->bi_sector,
bdevname(tmp_dev->rdev->bdev, b),
- (unsigned long long)tmp_dev->num_sectors,
- (unsigned long long)tmp_dev->start_sector);
+ (unsigned long long)tmp_dev->rdev->sectors,
+ (unsigned long long)start_sector);
bio_io_error(bio);
return 0;
}
if (unlikely(bio->bi_sector + (bio->bi_size >> 9) >
- tmp_dev->start_sector + tmp_dev->num_sectors)) {
+ tmp_dev->end_sector)) {
/* This bio crosses a device boundary, so we have to
* split it.
*/
struct bio_pair *bp;
bp = bio_split(bio,
- tmp_dev->start_sector + tmp_dev->num_sectors
- - bio->bi_sector);
+ tmp_dev->end_sector - bio->bi_sector);
if (linear_make_request(q, &bp->bio1))
generic_make_request(&bp->bio1);
@@ -372,7 +296,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
}
bio->bi_bdev = tmp_dev->rdev->bdev;
- bio->bi_sector = bio->bi_sector - tmp_dev->start_sector
+ bio->bi_sector = bio->bi_sector - start_sector
+ tmp_dev->rdev->data_offset;
return 1;
@@ -381,7 +305,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
static void linear_status (struct seq_file *seq, mddev_t *mddev)
{
- seq_printf(seq, " %dk rounding", mddev->chunk_size/1024);
+ seq_printf(seq, " %dk rounding", mddev->chunk_sectors / 2);
}
diff --git a/drivers/md/linear.h b/drivers/md/linear.h
index bf8179587f95..599e5c1bbb01 100644
--- a/drivers/md/linear.h
+++ b/drivers/md/linear.h
@@ -3,8 +3,7 @@
struct dev_info {
mdk_rdev_t *rdev;
- sector_t num_sectors;
- sector_t start_sector;
+ sector_t end_sector;
};
typedef struct dev_info dev_info_t;
@@ -12,18 +11,11 @@ typedef struct dev_info dev_info_t;
struct linear_private_data
{
struct linear_private_data *prev; /* earlier version */
- dev_info_t **hash_table;
- sector_t spacing;
sector_t array_sectors;
- int sector_shift; /* shift before dividing
- * by spacing
- */
dev_info_t disks[0];
};
typedef struct linear_private_data linear_conf_t;
-#define mddev_to_conf(mddev) ((linear_conf_t *) mddev->private)
-
#endif
diff --git a/drivers/md/md.c b/drivers/md/md.c
index fccc8343a250..037f3836af1e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -444,8 +444,11 @@ static sector_t calc_num_sectors(mdk_rdev_t *rdev, unsigned chunk_size)
{
sector_t num_sectors = rdev->sb_start;
- if (chunk_size)
- num_sectors &= ~((sector_t)chunk_size/512 - 1);
+ if (chunk_size) {
+ sector_t chunk_sects = chunk_size>>9;
+ sector_div(num_sectors, chunk_sects);
+ num_sectors *= chunk_sects;
+ }
return num_sectors;
}
@@ -866,7 +869,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
mddev->minor_version = sb->minor_version;
mddev->patch_version = sb->patch_version;
mddev->external = 0;
- mddev->chunk_size = sb->chunk_size;
+ mddev->chunk_sectors = sb->chunk_size >> 9;
mddev->ctime = sb->ctime;
mddev->utime = sb->utime;
mddev->level = sb->level;
@@ -883,13 +886,13 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
mddev->delta_disks = sb->delta_disks;
mddev->new_level = sb->new_level;
mddev->new_layout = sb->new_layout;
- mddev->new_chunk = sb->new_chunk;
+ mddev->new_chunk_sectors = sb->new_chunk >> 9;
} else {
mddev->reshape_position = MaxSector;
mddev->delta_disks = 0;
mddev->new_level = mddev->level;
mddev->new_layout = mddev->layout;
- mddev->new_chunk = mddev->chunk_size;
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
}
if (sb->state & (1<<MD_SB_CLEAN))
@@ -1004,7 +1007,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->new_level = mddev->new_level;
sb->delta_disks = mddev->delta_disks;
sb->new_layout = mddev->new_layout;
- sb->new_chunk = mddev->new_chunk;
+ sb->new_chunk = mddev->new_chunk_sectors << 9;
}
mddev->minor_version = sb->minor_version;
if (mddev->in_sync)
@@ -1018,7 +1021,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->recovery_cp = 0;
sb->layout = mddev->layout;
- sb->chunk_size = mddev->chunk_size;
+ sb->chunk_size = mddev->chunk_sectors << 9;
if (mddev->bitmap && mddev->bitmap_file == NULL)
sb->state |= (1<<MD_SB_BITMAP_PRESENT);
@@ -1202,7 +1205,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
- bmask = queue_hardsect_size(rdev->bdev->bd_disk->queue)-1;
+ bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
if (rdev->sb_size & bmask)
rdev->sb_size = (rdev->sb_size | bmask) + 1;
@@ -1271,7 +1274,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
mddev->major_version = 1;
mddev->patch_version = 0;
mddev->external = 0;
- mddev->chunk_size = le32_to_cpu(sb->chunksize) << 9;
+ mddev->chunk_sectors = le32_to_cpu(sb->chunksize);
mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1);
mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1);
mddev->level = le32_to_cpu(sb->level);
@@ -1297,13 +1300,13 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
mddev->delta_disks = le32_to_cpu(sb->delta_disks);
mddev->new_level = le32_to_cpu(sb->new_level);
mddev->new_layout = le32_to_cpu(sb->new_layout);
- mddev->new_chunk = le32_to_cpu(sb->new_chunk)<<9;
+ mddev->new_chunk_sectors = le32_to_cpu(sb->new_chunk);
} else {
mddev->reshape_position = MaxSector;
mddev->delta_disks = 0;
mddev->new_level = mddev->level;
mddev->new_layout = mddev->layout;
- mddev->new_chunk = mddev->chunk_size;
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
}
} else if (mddev->pers == NULL) {
@@ -1375,6 +1378,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->raid_disks = cpu_to_le32(mddev->raid_disks);
sb->size = cpu_to_le64(mddev->dev_sectors);
+ sb->chunksize = cpu_to_le32(mddev->chunk_sectors);
+ sb->level = cpu_to_le32(mddev->level);
+ sb->layout = cpu_to_le32(mddev->layout);
if (mddev->bitmap && mddev->bitmap_file == NULL) {
sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
@@ -1399,7 +1405,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->new_layout = cpu_to_le32(mddev->new_layout);
sb->delta_disks = cpu_to_le32(mddev->delta_disks);
sb->new_level = cpu_to_le32(mddev->new_level);
- sb->new_chunk = cpu_to_le32(mddev->new_chunk>>9);
+ sb->new_chunk = cpu_to_le32(mddev->new_chunk_sectors);
}
max_dev = 0;
@@ -2743,7 +2749,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
if (IS_ERR(priv)) {
mddev->new_level = mddev->level;
mddev->new_layout = mddev->layout;
- mddev->new_chunk = mddev->chunk_size;
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
mddev->raid_disks -= mddev->delta_disks;
mddev->delta_disks = 0;
module_put(pers->owner);
@@ -2761,7 +2767,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
mddev->level = mddev->new_level;
mddev->layout = mddev->new_layout;
- mddev->chunk_size = mddev->new_chunk;
+ mddev->chunk_sectors = mddev->new_chunk_sectors;
mddev->delta_disks = 0;
pers->run(mddev);
mddev_resume(mddev);
@@ -2797,11 +2803,14 @@ layout_store(mddev_t *mddev, const char *buf, size_t len)
if (mddev->pers) {
int err;
- if (mddev->pers->reconfig == NULL)
+ if (mddev->pers->check_reshape == NULL)
return -EBUSY;
- err = mddev->pers->reconfig(mddev, n, -1);
- if (err)
+ mddev->new_layout = n;
+ err = mddev->pers->check_reshape(mddev);
+ if (err) {
+ mddev->new_layout = mddev->layout;
return err;
+ }
} else {
mddev->new_layout = n;
if (mddev->reshape_position == MaxSector)
@@ -2854,10 +2863,11 @@ static ssize_t
chunk_size_show(mddev_t *mddev, char *page)
{
if (mddev->reshape_position != MaxSector &&
- mddev->chunk_size != mddev->new_chunk)
- return sprintf(page, "%d (%d)\n", mddev->new_chunk,
- mddev->chunk_size);
- return sprintf(page, "%d\n", mddev->chunk_size);
+ mddev->chunk_sectors != mddev->new_chunk_sectors)
+ return sprintf(page, "%d (%d)\n",
+ mddev->new_chunk_sectors << 9,
+ mddev->chunk_sectors << 9);
+ return sprintf(page, "%d\n", mddev->chunk_sectors << 9);
}
static ssize_t
@@ -2871,15 +2881,18 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
if (mddev->pers) {
int err;
- if (mddev->pers->reconfig == NULL)
+ if (mddev->pers->check_reshape == NULL)
return -EBUSY;
- err = mddev->pers->reconfig(mddev, -1, n);
- if (err)
+ mddev->new_chunk_sectors = n >> 9;
+ err = mddev->pers->check_reshape(mddev);
+ if (err) {
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
return err;
+ }
} else {
- mddev->new_chunk = n;
+ mddev->new_chunk_sectors = n >> 9;
if (mddev->reshape_position == MaxSector)
- mddev->chunk_size = n;
+ mddev->chunk_sectors = n >> 9;
}
return len;
}
@@ -3303,7 +3316,9 @@ static ssize_t
action_show(mddev_t *mddev, char *page)
{
char *type = "idle";
- if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
+ if (test_bit(MD_RECOVERY_FROZEN, &mddev->recovery))
+ type = "frozen";
+ else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
(!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))) {
if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
type = "reshape";
@@ -3326,7 +3341,12 @@ action_store(mddev_t *mddev, const char *page, size_t len)
if (!mddev->pers || !mddev->pers->sync_request)
return -EINVAL;
- if (cmd_match(page, "idle")) {
+ if (cmd_match(page, "frozen"))
+ set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
+ else
+ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
+
+ if (cmd_match(page, "idle") || cmd_match(page, "frozen")) {
if (mddev->sync_thread) {
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_unregister_thread(mddev->sync_thread);
@@ -3517,8 +3537,9 @@ min_sync_store(mddev_t *mddev, const char *buf, size_t len)
return -EBUSY;
/* Must be a multiple of chunk_size */
- if (mddev->chunk_size) {
- if (min & (sector_t)((mddev->chunk_size>>9)-1))
+ if (mddev->chunk_sectors) {
+ sector_t temp = min;
+ if (sector_div(temp, mddev->chunk_sectors))
return -EINVAL;
}
mddev->resync_min = min;
@@ -3554,8 +3575,9 @@ max_sync_store(mddev_t *mddev, const char *buf, size_t len)
return -EBUSY;
/* Must be a multiple of chunk_size */
- if (mddev->chunk_size) {
- if (max & (sector_t)((mddev->chunk_size>>9)-1))
+ if (mddev->chunk_sectors) {
+ sector_t temp = max;
+ if (sector_div(temp, mddev->chunk_sectors))
return -EINVAL;
}
mddev->resync_max = max;
@@ -3646,7 +3668,7 @@ reshape_position_store(mddev_t *mddev, const char *buf, size_t len)
mddev->delta_disks = 0;
mddev->new_level = mddev->level;
mddev->new_layout = mddev->layout;
- mddev->new_chunk = mddev->chunk_size;
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
return len;
}
@@ -3680,7 +3702,7 @@ array_size_store(mddev_t *mddev, const char *buf, size_t len)
if (strict_blocks_to_sectors(buf, &sectors) < 0)
return -EINVAL;
if (mddev->pers && mddev->pers->size(mddev, 0, 0) < sectors)
- return -EINVAL;
+ return -E2BIG;
mddev->external_size = 1;
}
@@ -3988,7 +4010,7 @@ static int do_md_run(mddev_t * mddev)
analyze_sbs(mddev);
}
- chunk_size = mddev->chunk_size;
+ chunk_size = mddev->chunk_sectors << 9;
if (chunk_size) {
if (chunk_size > MAX_CHUNK_SIZE) {
@@ -3996,14 +4018,6 @@ static int do_md_run(mddev_t * mddev)
chunk_size, MAX_CHUNK_SIZE);
return -EINVAL;
}
- /*
- * chunk-size has to be a power of 2
- */
- if ( (1 << ffz(~chunk_size)) != chunk_size) {
- printk(KERN_ERR "chunk_size of %d not valid\n", chunk_size);
- return -EINVAL;
- }
-
/* devices must have minimum size of one chunk */
list_for_each_entry(rdev, &mddev->disks, same_set) {
if (test_bit(Faulty, &rdev->flags))
@@ -4395,7 +4409,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
mddev->flags = 0;
mddev->ro = 0;
mddev->metadata_type[0] = 0;
- mddev->chunk_size = 0;
+ mddev->chunk_sectors = 0;
mddev->ctime = mddev->utime = 0;
mddev->layout = 0;
mddev->max_disks = 0;
@@ -4403,7 +4417,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
mddev->delta_disks = 0;
mddev->new_level = LEVEL_NONE;
mddev->new_layout = 0;
- mddev->new_chunk = 0;
+ mddev->new_chunk_sectors = 0;
mddev->curr_resync = 0;
mddev->resync_mismatches = 0;
mddev->suspend_lo = mddev->suspend_hi = 0;
@@ -4608,7 +4622,7 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
info.spare_disks = spare;
info.layout = mddev->layout;
- info.chunk_size = mddev->chunk_size;
+ info.chunk_size = mddev->chunk_sectors << 9;
if (copy_to_user(arg, &info, sizeof(info)))
return -EFAULT;
@@ -4833,7 +4847,8 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
rdev->sb_start = rdev->bdev->bd_inode->i_size / 512;
} else
rdev->sb_start = calc_dev_sboffset(rdev->bdev);
- rdev->sectors = calc_num_sectors(rdev, mddev->chunk_size);
+ rdev->sectors = calc_num_sectors(rdev,
+ mddev->chunk_sectors << 9);
err = bind_rdev_to_array(rdev, mddev);
if (err) {
@@ -4903,7 +4918,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
else
rdev->sb_start = rdev->bdev->bd_inode->i_size / 512;
- rdev->sectors = calc_num_sectors(rdev, mddev->chunk_size);
+ rdev->sectors = calc_num_sectors(rdev, mddev->chunk_sectors << 9);
if (test_bit(Faulty, &rdev->flags)) {
printk(KERN_WARNING
@@ -5052,7 +5067,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
mddev->external = 0;
mddev->layout = info->layout;
- mddev->chunk_size = info->chunk_size;
+ mddev->chunk_sectors = info->chunk_size >> 9;
mddev->max_disks = MD_SB_DISKS;
@@ -5071,7 +5086,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
get_random_bytes(mddev->uuid, 16);
mddev->new_level = mddev->level;
- mddev->new_chunk = mddev->chunk_size;
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
mddev->new_layout = mddev->layout;
mddev->delta_disks = 0;
@@ -5181,7 +5196,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
mddev->level != info->level ||
/* mddev->layout != info->layout || */
!mddev->persistent != info->not_persistent||
- mddev->chunk_size != info->chunk_size ||
+ mddev->chunk_sectors != info->chunk_size >> 9 ||
/* ignore bottom 8 bits of state, and allow SB_BITMAP_PRESENT to change */
((state^info->state) & 0xfffffe00)
)
@@ -5205,10 +5220,15 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
* we don't need to do anything at the md level, the
* personality will take care of it all.
*/
- if (mddev->pers->reconfig == NULL)
+ if (mddev->pers->check_reshape == NULL)
return -EINVAL;
- else
- return mddev->pers->reconfig(mddev, info->layout, -1);
+ else {
+ mddev->new_layout = info->layout;
+ rv = mddev->pers->check_reshape(mddev);
+ if (rv)
+ mddev->new_layout = mddev->layout;
+ return rv;
+ }
}
if (info->size >= 0 && mddev->dev_sectors / 2 != info->size)
rv = update_size(mddev, (sector_t)info->size * 2);
@@ -5557,7 +5577,7 @@ static struct block_device_operations md_fops =
.owner = THIS_MODULE,
.open = md_open,
.release = md_release,
- .locked_ioctl = md_ioctl,
+ .ioctl = md_ioctl,
.getgeo = md_getgeo,
.media_changed = md_media_changed,
.revalidate_disk= md_revalidate,
@@ -6352,12 +6372,13 @@ void md_do_sync(mddev_t *mddev)
skipped = 0;
- if ((mddev->curr_resync > mddev->curr_resync_completed &&
- (mddev->curr_resync - mddev->curr_resync_completed)
- > (max_sectors >> 4)) ||
- (j - mddev->curr_resync_completed)*2
- >= mddev->resync_max - mddev->curr_resync_completed
- ) {
+ if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
+ ((mddev->curr_resync > mddev->curr_resync_completed &&
+ (mddev->curr_resync - mddev->curr_resync_completed)
+ > (max_sectors >> 4)) ||
+ (j - mddev->curr_resync_completed)*2
+ >= mddev->resync_max - mddev->curr_resync_completed
+ )) {
/* time to update curr_resync_completed */
blk_unplug(mddev->queue);
wait_event(mddev->recovery_wait,
@@ -6706,7 +6727,8 @@ void md_check_recovery(mddev_t *mddev)
*/
if (mddev->reshape_position != MaxSector) {
- if (mddev->pers->check_reshape(mddev) != 0)
+ if (mddev->pers->check_reshape == NULL ||
+ mddev->pers->check_reshape(mddev) != 0)
/* Cannot proceed */
goto unlock;
set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 8227ab909d44..bac7c2bf8616 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -145,7 +145,7 @@ struct mddev_s
int external; /* metadata is
* managed externally */
char metadata_type[17]; /* externally set*/
- int chunk_size;
+ int chunk_sectors;
time_t ctime, utime;
int level, layout;
char clevel[16];
@@ -166,7 +166,8 @@ struct mddev_s
* If reshape_position is MaxSector, then no reshape is happening (yet).
*/
sector_t reshape_position;
- int delta_disks, new_level, new_layout, new_chunk;
+ int delta_disks, new_level, new_layout;
+ int new_chunk_sectors;
struct mdk_thread_s *thread; /* management thread */
struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
@@ -325,7 +326,6 @@ struct mdk_personality
int (*check_reshape) (mddev_t *mddev);
int (*start_reshape) (mddev_t *mddev);
void (*finish_reshape) (mddev_t *mddev);
- int (*reconfig) (mddev_t *mddev, int layout, int chunk_size);
/* quiesce moves between quiescence states
* 0 - fully active
* 1 - no new requests allowed
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 41ced0cbe823..c1ca63f278a9 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -58,7 +58,7 @@ static void multipath_reschedule_retry (struct multipath_bh *mp_bh)
{
unsigned long flags;
mddev_t *mddev = mp_bh->mddev;
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
spin_lock_irqsave(&conf->device_lock, flags);
list_add(&mp_bh->retry_list, &conf->retry_list);
@@ -75,7 +75,7 @@ static void multipath_reschedule_retry (struct multipath_bh *mp_bh)
static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err)
{
struct bio *bio = mp_bh->master_bio;
- multipath_conf_t *conf = mddev_to_conf(mp_bh->mddev);
+ multipath_conf_t *conf = mp_bh->mddev->private;
bio_endio(bio, err);
mempool_free(mp_bh, conf->pool);
@@ -85,7 +85,7 @@ static void multipath_end_request(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct multipath_bh * mp_bh = (struct multipath_bh *)(bio->bi_private);
- multipath_conf_t *conf = mddev_to_conf(mp_bh->mddev);
+ multipath_conf_t *conf = mp_bh->mddev->private;
mdk_rdev_t *rdev = conf->multipaths[mp_bh->path].rdev;
if (uptodate)
@@ -107,7 +107,7 @@ static void multipath_end_request(struct bio *bio, int error)
static void unplug_slaves(mddev_t *mddev)
{
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
int i;
rcu_read_lock();
@@ -138,7 +138,7 @@ static void multipath_unplug(struct request_queue *q)
static int multipath_make_request (struct request_queue *q, struct bio * bio)
{
mddev_t *mddev = q->queuedata;
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
struct multipath_bh * mp_bh;
struct multipath_info *multipath;
const int rw = bio_data_dir(bio);
@@ -180,7 +180,7 @@ static int multipath_make_request (struct request_queue *q, struct bio * bio)
static void multipath_status (struct seq_file *seq, mddev_t *mddev)
{
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
int i;
seq_printf (seq, " [%d/%d] [", conf->raid_disks,
@@ -195,7 +195,7 @@ static void multipath_status (struct seq_file *seq, mddev_t *mddev)
static int multipath_congested(void *data, int bits)
{
mddev_t *mddev = data;
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
int i, ret = 0;
rcu_read_lock();
@@ -220,7 +220,7 @@ static int multipath_congested(void *data, int bits)
*/
static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
{
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
if (conf->working_disks <= 1) {
/*
@@ -303,7 +303,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
* merge_bvec_fn will be involved in multipath.)
*/
if (q->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
+ queue_max_sectors(q) > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
conf->working_disks++;
@@ -367,7 +367,7 @@ static void multipathd (mddev_t *mddev)
struct multipath_bh *mp_bh;
struct bio *bio;
unsigned long flags;
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
struct list_head *head = &conf->retry_list;
md_check_recovery(mddev);
@@ -467,7 +467,7 @@ static int multipath_run (mddev_t *mddev)
* violating it, not that we ever expect a device with
* a merge_bvec_fn to be involved in multipath */
if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
if (!test_bit(Faulty, &rdev->flags))
@@ -531,7 +531,7 @@ out:
static int multipath_stop (mddev_t *mddev)
{
- multipath_conf_t *conf = mddev_to_conf(mddev);
+ multipath_conf_t *conf = mddev->private;
md_unregister_thread(mddev->thread);
mddev->thread = NULL;
diff --git a/drivers/md/multipath.h b/drivers/md/multipath.h
index 6fa70b400cda..d1c2a8d78395 100644
--- a/drivers/md/multipath.h
+++ b/drivers/md/multipath.h
@@ -19,12 +19,6 @@ struct multipath_private_data {
typedef struct multipath_private_data multipath_conf_t;
/*
- * this is the only point in the RAID code where we violate
- * C type safety. mddev->private is an 'opaque' pointer.
- */
-#define mddev_to_conf(mddev) ((multipath_conf_t *) mddev->private)
-
-/*
* this is our 'private' 'collective' MULTIPATH buffer head.
* it contains information about what kind of IO operations were started
* for this MULTIPATH operation, and about their status:
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index c08d7559be55..f9e6073d4a46 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -26,8 +26,8 @@
static void raid0_unplug(struct request_queue *q)
{
mddev_t *mddev = q->queuedata;
- raid0_conf_t *conf = mddev_to_conf(mddev);
- mdk_rdev_t **devlist = conf->strip_zone[0].dev;
+ raid0_conf_t *conf = mddev->private;
+ mdk_rdev_t **devlist = conf->devlist;
int i;
for (i=0; i<mddev->raid_disks; i++) {
@@ -40,8 +40,8 @@ static void raid0_unplug(struct request_queue *q)
static int raid0_congested(void *data, int bits)
{
mddev_t *mddev = data;
- raid0_conf_t *conf = mddev_to_conf(mddev);
- mdk_rdev_t **devlist = conf->strip_zone[0].dev;
+ raid0_conf_t *conf = mddev->private;
+ mdk_rdev_t **devlist = conf->devlist;
int i, ret = 0;
for (i = 0; i < mddev->raid_disks && !ret ; i++) {
@@ -52,23 +52,50 @@ static int raid0_congested(void *data, int bits)
return ret;
}
+/*
+ * inform the user of the raid configuration
+*/
+static void dump_zones(mddev_t *mddev)
+{
+ int j, k, h;
+ sector_t zone_size = 0;
+ sector_t zone_start = 0;
+ char b[BDEVNAME_SIZE];
+ raid0_conf_t *conf = mddev->private;
+ printk(KERN_INFO "******* %s configuration *********",
+ mdname(mddev));
+ h = 0;
+ for (j = 0; j < conf->nr_strip_zones; j++) {
+ printk("\nzone%d", j);
+ printk("=[");
+ for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
+ printk("%s/",
+ bdevname(conf->devlist[j*mddev->raid_disks
+ + k]->bdev, b));
+
+ zone_size = conf->strip_zone[j].zone_end - zone_start;
+ printk("]\n\t zone offset=%llukb "
+ "device offset=%llukb size=%llukb\n",
+ (unsigned long long)zone_start>>1,
+ (unsigned long long)conf->strip_zone[j].dev_start>>1,
+ (unsigned long long)zone_size>>1);
+ zone_start = conf->strip_zone[j].zone_end;
+ }
+ printk(KERN_INFO "**********************************\n\n");
+}
-static int create_strip_zones (mddev_t *mddev)
+static int create_strip_zones(mddev_t *mddev)
{
- int i, c, j;
- sector_t current_start, curr_zone_start;
- sector_t min_spacing;
- raid0_conf_t *conf = mddev_to_conf(mddev);
- mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev;
+ int i, c, j, err;
+ sector_t current_start, curr_zone_start, sectors;
+ mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev, **dev;
struct strip_zone *zone;
int cnt;
char b[BDEVNAME_SIZE];
-
- /*
- * The number of 'same size groups'
- */
- conf->nr_strip_zones = 0;
-
+ raid0_conf_t *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
+
+ if (!conf)
+ return -ENOMEM;
list_for_each_entry(rdev1, &mddev->disks, same_set) {
printk(KERN_INFO "raid0: looking at %s\n",
bdevname(rdev1->bdev,b));
@@ -103,16 +130,16 @@ static int create_strip_zones (mddev_t *mddev)
}
}
printk(KERN_INFO "raid0: FINAL %d zones\n", conf->nr_strip_zones);
-
+ err = -ENOMEM;
conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
conf->nr_strip_zones, GFP_KERNEL);
if (!conf->strip_zone)
- return 1;
+ goto abort;
conf->devlist = kzalloc(sizeof(mdk_rdev_t*)*
conf->nr_strip_zones*mddev->raid_disks,
GFP_KERNEL);
if (!conf->devlist)
- return 1;
+ goto abort;
/* The first zone must contain all devices, so here we check that
* there is a proper alignment of slots to devices and find them all
@@ -120,7 +147,8 @@ static int create_strip_zones (mddev_t *mddev)
zone = &conf->strip_zone[0];
cnt = 0;
smallest = NULL;
- zone->dev = conf->devlist;
+ dev = conf->devlist;
+ err = -EINVAL;
list_for_each_entry(rdev1, &mddev->disks, same_set) {
int j = rdev1->raid_disk;
@@ -129,12 +157,12 @@ static int create_strip_zones (mddev_t *mddev)
"aborting!\n", j);
goto abort;
}
- if (zone->dev[j]) {
+ if (dev[j]) {
printk(KERN_ERR "raid0: multiple devices for %d - "
"aborting!\n", j);
goto abort;
}
- zone->dev[j] = rdev1;
+ dev[j] = rdev1;
blk_queue_stack_limits(mddev->queue,
rdev1->bdev->bd_disk->queue);
@@ -144,7 +172,7 @@ static int create_strip_zones (mddev_t *mddev)
*/
if (rdev1->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
if (!smallest || (rdev1->sectors < smallest->sectors))
@@ -157,17 +185,16 @@ static int create_strip_zones (mddev_t *mddev)
goto abort;
}
zone->nb_dev = cnt;
- zone->sectors = smallest->sectors * cnt;
- zone->zone_start = 0;
+ zone->zone_end = smallest->sectors * cnt;
current_start = smallest->sectors;
- curr_zone_start = zone->sectors;
+ curr_zone_start = zone->zone_end;
/* now do the other zones */
for (i = 1; i < conf->nr_strip_zones; i++)
{
zone = conf->strip_zone + i;
- zone->dev = conf->strip_zone[i-1].dev + mddev->raid_disks;
+ dev = conf->devlist + i * mddev->raid_disks;
printk(KERN_INFO "raid0: zone %d\n", i);
zone->dev_start = current_start;
@@ -176,7 +203,7 @@ static int create_strip_zones (mddev_t *mddev)
for (j=0; j<cnt; j++) {
char b[BDEVNAME_SIZE];
- rdev = conf->strip_zone[0].dev[j];
+ rdev = conf->devlist[j];
printk(KERN_INFO "raid0: checking %s ...",
bdevname(rdev->bdev, b));
if (rdev->sectors <= current_start) {
@@ -184,7 +211,7 @@ static int create_strip_zones (mddev_t *mddev)
continue;
}
printk(KERN_INFO " contained as device %d\n", c);
- zone->dev[c] = rdev;
+ dev[c] = rdev;
c++;
if (!smallest || rdev->sectors < smallest->sectors) {
smallest = rdev;
@@ -194,47 +221,40 @@ static int create_strip_zones (mddev_t *mddev)
}
zone->nb_dev = c;
- zone->sectors = (smallest->sectors - current_start) * c;
+ sectors = (smallest->sectors - current_start) * c;
printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n",
- zone->nb_dev, (unsigned long long)zone->sectors);
-
- zone->zone_start = curr_zone_start;
- curr_zone_start += zone->sectors;
+ zone->nb_dev, (unsigned long long)sectors);
+ curr_zone_start += sectors;
current_start = smallest->sectors;
+ zone->zone_end = curr_zone_start;
+
printk(KERN_INFO "raid0: current zone start: %llu\n",
(unsigned long long)current_start);
}
-
- /* Now find appropriate hash spacing.
- * We want a number which causes most hash entries to cover
- * at most two strips, but the hash table must be at most
- * 1 PAGE. We choose the smallest strip, or contiguous collection
- * of strips, that has big enough size. We never consider the last
- * strip though as it's size has no bearing on the efficacy of the hash
- * table.
- */
- conf->spacing = curr_zone_start;
- min_spacing = curr_zone_start;
- sector_div(min_spacing, PAGE_SIZE/sizeof(struct strip_zone*));
- for (i=0; i < conf->nr_strip_zones-1; i++) {
- sector_t s = 0;
- for (j = i; j < conf->nr_strip_zones - 1 &&
- s < min_spacing; j++)
- s += conf->strip_zone[j].sectors;
- if (s >= min_spacing && s < conf->spacing)
- conf->spacing = s;
- }
-
mddev->queue->unplug_fn = raid0_unplug;
-
mddev->queue->backing_dev_info.congested_fn = raid0_congested;
mddev->queue->backing_dev_info.congested_data = mddev;
+ /*
+ * now since we have the hard sector sizes, we can make sure
+ * chunk size is a multiple of that sector size
+ */
+ if ((mddev->chunk_sectors << 9) % queue_logical_block_size(mddev->queue)) {
+ printk(KERN_ERR "%s chunk_size of %d not valid\n",
+ mdname(mddev),
+ mddev->chunk_sectors << 9);
+ goto abort;
+ }
printk(KERN_INFO "raid0: done.\n");
+ mddev->private = conf;
return 0;
- abort:
- return 1;
+abort:
+ kfree(conf->strip_zone);
+ kfree(conf->devlist);
+ kfree(conf);
+ mddev->private = NULL;
+ return err;
}
/**
@@ -252,10 +272,15 @@ static int raid0_mergeable_bvec(struct request_queue *q,
mddev_t *mddev = q->queuedata;
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
int max;
- unsigned int chunk_sectors = mddev->chunk_size >> 9;
+ unsigned int chunk_sectors = mddev->chunk_sectors;
unsigned int bio_sectors = bvm->bi_size >> 9;
- max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
+ if (is_power_of_2(chunk_sectors))
+ max = (chunk_sectors - ((sector & (chunk_sectors-1))
+ + bio_sectors)) << 9;
+ else
+ max = (chunk_sectors - (sector_div(sector, chunk_sectors)
+ + bio_sectors)) << 9;
if (max < 0) max = 0; /* bio_add cannot handle a negative return */
if (max <= biovec->bv_len && bio_sectors == 0)
return biovec->bv_len;
@@ -277,84 +302,27 @@ static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
return array_sectors;
}
-static int raid0_run (mddev_t *mddev)
+static int raid0_run(mddev_t *mddev)
{
- unsigned cur=0, i=0, nb_zone;
- s64 sectors;
- raid0_conf_t *conf;
+ int ret;
- if (mddev->chunk_size == 0) {
- printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
+ if (mddev->chunk_sectors == 0 ||
+ !is_power_of_2(mddev->chunk_sectors)) {
+ printk(KERN_ERR "md/raid0: chunk size must be a power of 2.\n");
return -EINVAL;
}
- printk(KERN_INFO "%s: setting max_sectors to %d, segment boundary to %d\n",
- mdname(mddev),
- mddev->chunk_size >> 9,
- (mddev->chunk_size>>1)-1);
- blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
- blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
+ blk_queue_max_sectors(mddev->queue, mddev->chunk_sectors);
mddev->queue->queue_lock = &mddev->queue->__queue_lock;
- conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
- if (!conf)
- goto out;
- mddev->private = (void *)conf;
-
- conf->strip_zone = NULL;
- conf->devlist = NULL;
- if (create_strip_zones (mddev))
- goto out_free_conf;
+ ret = create_strip_zones(mddev);
+ if (ret < 0)
+ return ret;
/* calculate array device size */
md_set_array_sectors(mddev, raid0_size(mddev, 0, 0));
printk(KERN_INFO "raid0 : md_size is %llu sectors.\n",
(unsigned long long)mddev->array_sectors);
- printk(KERN_INFO "raid0 : conf->spacing is %llu sectors.\n",
- (unsigned long long)conf->spacing);
- {
- sector_t s = raid0_size(mddev, 0, 0);
- sector_t space = conf->spacing;
- int round;
- conf->sector_shift = 0;
- if (sizeof(sector_t) > sizeof(u32)) {
- /*shift down space and s so that sector_div will work */
- while (space > (sector_t) (~(u32)0)) {
- s >>= 1;
- space >>= 1;
- s += 1; /* force round-up */
- conf->sector_shift++;
- }
- }
- round = sector_div(s, (u32)space) ? 1 : 0;
- nb_zone = s + round;
- }
- printk(KERN_INFO "raid0 : nb_zone is %d.\n", nb_zone);
-
- printk(KERN_INFO "raid0 : Allocating %zu bytes for hash.\n",
- nb_zone*sizeof(struct strip_zone*));
- conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL);
- if (!conf->hash_table)
- goto out_free_conf;
- sectors = conf->strip_zone[cur].sectors;
-
- conf->hash_table[0] = conf->strip_zone + cur;
- for (i=1; i< nb_zone; i++) {
- while (sectors <= conf->spacing) {
- cur++;
- sectors += conf->strip_zone[cur].sectors;
- }
- sectors -= conf->spacing;
- conf->hash_table[i] = conf->strip_zone + cur;
- }
- if (conf->sector_shift) {
- conf->spacing >>= conf->sector_shift;
- /* round spacing up so when we divide by it, we
- * err on the side of too-low, which is safest
- */
- conf->spacing++;
- }
-
/* calculate the max read-ahead size.
* For read-ahead of large files to be effective, we need to
* readahead at least twice a whole stripe. i.e. number of devices
@@ -365,48 +333,107 @@ static int raid0_run (mddev_t *mddev)
* chunksize should be used in that case.
*/
{
- int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_SIZE;
+ int stripe = mddev->raid_disks *
+ (mddev->chunk_sectors << 9) / PAGE_SIZE;
if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
mddev->queue->backing_dev_info.ra_pages = 2* stripe;
}
-
blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec);
+ dump_zones(mddev);
return 0;
+}
-out_free_conf:
+static int raid0_stop(mddev_t *mddev)
+{
+ raid0_conf_t *conf = mddev->private;
+
+ blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
kfree(conf->strip_zone);
kfree(conf->devlist);
kfree(conf);
mddev->private = NULL;
-out:
- return -ENOMEM;
+ return 0;
}
-static int raid0_stop (mddev_t *mddev)
+/* Find the zone which holds a particular offset
+ * Update *sectorp to be an offset in that zone
+ */
+static struct strip_zone *find_zone(struct raid0_private_data *conf,
+ sector_t *sectorp)
{
- raid0_conf_t *conf = mddev_to_conf(mddev);
+ int i;
+ struct strip_zone *z = conf->strip_zone;
+ sector_t sector = *sectorp;
+
+ for (i = 0; i < conf->nr_strip_zones; i++)
+ if (sector < z[i].zone_end) {
+ if (i)
+ *sectorp = sector - z[i-1].zone_end;
+ return z + i;
+ }
+ BUG();
+}
- blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
- kfree(conf->hash_table);
- conf->hash_table = NULL;
- kfree(conf->strip_zone);
- conf->strip_zone = NULL;
- kfree(conf);
- mddev->private = NULL;
+/*
+ * remaps the bio to the target device. we separate two flows.
+ * power 2 flow and a general flow for the sake of perfromance
+*/
+static mdk_rdev_t *map_sector(mddev_t *mddev, struct strip_zone *zone,
+ sector_t sector, sector_t *sector_offset)
+{
+ unsigned int sect_in_chunk;
+ sector_t chunk;
+ raid0_conf_t *conf = mddev->private;
+ unsigned int chunk_sects = mddev->chunk_sectors;
+
+ if (is_power_of_2(chunk_sects)) {
+ int chunksect_bits = ffz(~chunk_sects);
+ /* find the sector offset inside the chunk */
+ sect_in_chunk = sector & (chunk_sects - 1);
+ sector >>= chunksect_bits;
+ /* chunk in zone */
+ chunk = *sector_offset;
+ /* quotient is the chunk in real device*/
+ sector_div(chunk, zone->nb_dev << chunksect_bits);
+ } else{
+ sect_in_chunk = sector_div(sector, chunk_sects);
+ chunk = *sector_offset;
+ sector_div(chunk, chunk_sects * zone->nb_dev);
+ }
+ /*
+ * position the bio over the real device
+ * real sector = chunk in device + starting of zone
+ * + the position in the chunk
+ */
+ *sector_offset = (chunk * chunk_sects) + sect_in_chunk;
+ return conf->devlist[(zone - conf->strip_zone)*mddev->raid_disks
+ + sector_div(sector, zone->nb_dev)];
+}
- return 0;
+/*
+ * Is io distribute over 1 or more chunks ?
+*/
+static inline int is_io_in_chunk_boundary(mddev_t *mddev,
+ unsigned int chunk_sects, struct bio *bio)
+{
+ if (likely(is_power_of_2(chunk_sects))) {
+ return chunk_sects >= ((bio->bi_sector & (chunk_sects-1))
+ + (bio->bi_size >> 9));
+ } else{
+ sector_t sector = bio->bi_sector;
+ return chunk_sects >= (sector_div(sector, chunk_sects)
+ + (bio->bi_size >> 9));
+ }
}
-static int raid0_make_request (struct request_queue *q, struct bio *bio)
+static int raid0_make_request(struct request_queue *q, struct bio *bio)
{
mddev_t *mddev = q->queuedata;
- unsigned int sect_in_chunk, chunksect_bits, chunk_sects;
- raid0_conf_t *conf = mddev_to_conf(mddev);
+ unsigned int chunk_sects;
+ sector_t sector_offset;
struct strip_zone *zone;
mdk_rdev_t *tmp_dev;
- sector_t chunk;
- sector_t sector, rsect;
const int rw = bio_data_dir(bio);
int cpu;
@@ -421,11 +448,9 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio)
bio_sectors(bio));
part_stat_unlock();
- chunk_sects = mddev->chunk_size >> 9;
- chunksect_bits = ffz(~chunk_sects);
- sector = bio->bi_sector;
-
- if (unlikely(chunk_sects < (bio->bi_sector & (chunk_sects - 1)) + (bio->bi_size >> 9))) {
+ chunk_sects = mddev->chunk_sectors;
+ if (unlikely(!is_io_in_chunk_boundary(mddev, chunk_sects, bio))) {
+ sector_t sector = bio->bi_sector;
struct bio_pair *bp;
/* Sanity check -- queue functions should prevent this happening */
if (bio->bi_vcnt != 1 ||
@@ -434,7 +459,12 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio)
/* This is a one page bio that upper layers
* refuse to split for us, so we need to split it.
*/
- bp = bio_split(bio, chunk_sects - (bio->bi_sector & (chunk_sects - 1)));
+ if (likely(is_power_of_2(chunk_sects)))
+ bp = bio_split(bio, chunk_sects - (sector &
+ (chunk_sects-1)));
+ else
+ bp = bio_split(bio, chunk_sects -
+ sector_div(sector, chunk_sects));
if (raid0_make_request(q, &bp->bio1))
generic_make_request(&bp->bio1);
if (raid0_make_request(q, &bp->bio2))
@@ -443,34 +473,14 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio)
bio_pair_release(bp);
return 0;
}
-
-
- {
- sector_t x = sector >> conf->sector_shift;
- sector_div(x, (u32)conf->spacing);
- zone = conf->hash_table[x];
- }
- while (sector >= zone->zone_start + zone->sectors)
- zone++;
-
- sect_in_chunk = bio->bi_sector & (chunk_sects - 1);
-
-
- {
- sector_t x = (sector - zone->zone_start) >> chunksect_bits;
-
- sector_div(x, zone->nb_dev);
- chunk = x;
-
- x = sector >> chunksect_bits;
- tmp_dev = zone->dev[sector_div(x, zone->nb_dev)];
- }
- rsect = (chunk << chunksect_bits) + zone->dev_start + sect_in_chunk;
-
+ sector_offset = bio->bi_sector;
+ zone = find_zone(mddev->private, &sector_offset);
+ tmp_dev = map_sector(mddev, zone, bio->bi_sector,
+ &sector_offset);
bio->bi_bdev = tmp_dev->bdev;
- bio->bi_sector = rsect + tmp_dev->data_offset;
-
+ bio->bi_sector = sector_offset + zone->dev_start +
+ tmp_dev->data_offset;
/*
* Let the main block layer submit the IO and resolve recursion:
*/
@@ -485,31 +495,35 @@ bad_map:
return 0;
}
-static void raid0_status (struct seq_file *seq, mddev_t *mddev)
+static void raid0_status(struct seq_file *seq, mddev_t *mddev)
{
#undef MD_DEBUG
#ifdef MD_DEBUG
int j, k, h;
char b[BDEVNAME_SIZE];
- raid0_conf_t *conf = mddev_to_conf(mddev);
+ raid0_conf_t *conf = mddev->private;
+ sector_t zone_size;
+ sector_t zone_start = 0;
h = 0;
+
for (j = 0; j < conf->nr_strip_zones; j++) {
seq_printf(seq, " z%d", j);
- if (conf->hash_table[h] == conf->strip_zone+j)
- seq_printf(seq, "(h%d)", h++);
seq_printf(seq, "=[");
for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
seq_printf(seq, "%s/", bdevname(
- conf->strip_zone[j].dev[k]->bdev,b));
-
- seq_printf(seq, "] zs=%d ds=%d s=%d\n",
- conf->strip_zone[j].zone_start,
- conf->strip_zone[j].dev_start,
- conf->strip_zone[j].sectors);
+ conf->devlist[j*mddev->raid_disks + k]
+ ->bdev, b));
+
+ zone_size = conf->strip_zone[j].zone_end - zone_start;
+ seq_printf(seq, "] ze=%lld ds=%lld s=%lld\n",
+ (unsigned long long)zone_start>>1,
+ (unsigned long long)conf->strip_zone[j].dev_start>>1,
+ (unsigned long long)zone_size>>1);
+ zone_start = conf->strip_zone[j].zone_end;
}
#endif
- seq_printf(seq, " %dk chunks", mddev->chunk_size/1024);
+ seq_printf(seq, " %dk chunks", mddev->chunk_sectors / 2);
return;
}
diff --git a/drivers/md/raid0.h b/drivers/md/raid0.h
index 824b12eb1d4f..91f8e876ee64 100644
--- a/drivers/md/raid0.h
+++ b/drivers/md/raid0.h
@@ -3,26 +3,18 @@
struct strip_zone
{
- sector_t zone_start; /* Zone offset in md_dev (in sectors) */
+ sector_t zone_end; /* Start of the next zone (in sectors) */
sector_t dev_start; /* Zone offset in real dev (in sectors) */
- sector_t sectors; /* Zone size in sectors */
int nb_dev; /* # of devices attached to the zone */
- mdk_rdev_t **dev; /* Devices attached to the zone */
};
struct raid0_private_data
{
- struct strip_zone **hash_table; /* Table of indexes into strip_zone */
struct strip_zone *strip_zone;
mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */
int nr_strip_zones;
-
- sector_t spacing;
- int sector_shift; /* shift this before divide by spacing */
};
typedef struct raid0_private_data raid0_conf_t;
-#define mddev_to_conf(mddev) ((raid0_conf_t *) mddev->private)
-
#endif
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 36df9109cde1..12f8f34f17ae 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -182,7 +182,7 @@ static void put_all_bios(conf_t *conf, r1bio_t *r1_bio)
static void free_r1bio(r1bio_t *r1_bio)
{
- conf_t *conf = mddev_to_conf(r1_bio->mddev);
+ conf_t *conf = r1_bio->mddev->private;
/*
* Wake up any possible resync thread that waits for the device
@@ -196,7 +196,7 @@ static void free_r1bio(r1bio_t *r1_bio)
static void put_buf(r1bio_t *r1_bio)
{
- conf_t *conf = mddev_to_conf(r1_bio->mddev);
+ conf_t *conf = r1_bio->mddev->private;
int i;
for (i=0; i<conf->raid_disks; i++) {
@@ -214,7 +214,7 @@ static void reschedule_retry(r1bio_t *r1_bio)
{
unsigned long flags;
mddev_t *mddev = r1_bio->mddev;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
spin_lock_irqsave(&conf->device_lock, flags);
list_add(&r1_bio->retry_list, &conf->retry_list);
@@ -253,7 +253,7 @@ static void raid_end_bio_io(r1bio_t *r1_bio)
*/
static inline void update_head_pos(int disk, r1bio_t *r1_bio)
{
- conf_t *conf = mddev_to_conf(r1_bio->mddev);
+ conf_t *conf = r1_bio->mddev->private;
conf->mirrors[disk].head_position =
r1_bio->sector + (r1_bio->sectors);
@@ -264,7 +264,7 @@ static void raid1_end_read_request(struct bio *bio, int error)
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
int mirror;
- conf_t *conf = mddev_to_conf(r1_bio->mddev);
+ conf_t *conf = r1_bio->mddev->private;
mirror = r1_bio->read_disk;
/*
@@ -309,7 +309,7 @@ static void raid1_end_write_request(struct bio *bio, int error)
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state);
- conf_t *conf = mddev_to_conf(r1_bio->mddev);
+ conf_t *conf = r1_bio->mddev->private;
struct bio *to_put = NULL;
@@ -541,7 +541,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
static void unplug_slaves(mddev_t *mddev)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i;
rcu_read_lock();
@@ -573,7 +573,7 @@ static void raid1_unplug(struct request_queue *q)
static int raid1_congested(void *data, int bits)
{
mddev_t *mddev = data;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i, ret = 0;
rcu_read_lock();
@@ -772,7 +772,7 @@ do_sync_io:
static int make_request(struct request_queue *q, struct bio * bio)
{
mddev_t *mddev = q->queuedata;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
mirror_info_t *mirror;
r1bio_t *r1_bio;
struct bio *read_bio;
@@ -991,7 +991,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
static void status(struct seq_file *seq, mddev_t *mddev)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i;
seq_printf(seq, " [%d/%d] [", conf->raid_disks,
@@ -1010,7 +1010,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
static void error(mddev_t *mddev, mdk_rdev_t *rdev)
{
char b[BDEVNAME_SIZE];
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
/*
* If it is not operational, then we have already marked it as dead
@@ -1130,7 +1130,7 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
* a one page request is never in violation.
*/
if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
p->head_position = 0;
@@ -1214,7 +1214,7 @@ static void end_sync_write(struct bio *bio, int error)
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
mddev_t *mddev = r1_bio->mddev;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i;
int mirror=0;
@@ -1248,7 +1248,7 @@ static void end_sync_write(struct bio *bio, int error)
static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i;
int disks = conf->raid_disks;
struct bio *bio, *wbio;
@@ -1562,7 +1562,7 @@ static void raid1d(mddev_t *mddev)
r1bio_t *r1_bio;
struct bio *bio;
unsigned long flags;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
struct list_head *head = &conf->retry_list;
int unplug=0;
mdk_rdev_t *rdev;
@@ -1585,7 +1585,7 @@ static void raid1d(mddev_t *mddev)
spin_unlock_irqrestore(&conf->device_lock, flags);
mddev = r1_bio->mddev;
- conf = mddev_to_conf(mddev);
+ conf = mddev->private;
if (test_bit(R1BIO_IsSync, &r1_bio->state)) {
sync_request_write(mddev, r1_bio);
unplug = 1;
@@ -1706,7 +1706,7 @@ static int init_resync(conf_t *conf)
static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
r1bio_t *r1_bio;
struct bio *bio;
sector_t max_sector, nr_sectors;
@@ -1996,7 +1996,7 @@ static int run(mddev_t *mddev)
* a one page request is never in violation.
*/
if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
disk->head_position = 0;
@@ -2087,7 +2087,7 @@ out:
static int stop(mddev_t *mddev)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
struct bitmap *bitmap = mddev->bitmap;
int behind_wait = 0;
@@ -2155,16 +2155,16 @@ static int raid1_reshape(mddev_t *mddev)
mempool_t *newpool, *oldpool;
struct pool_info *newpoolinfo;
mirror_info_t *newmirrors;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int cnt, raid_disks;
unsigned long flags;
int d, d2, err;
/* Cannot change chunk_size, layout, or level */
- if (mddev->chunk_size != mddev->new_chunk ||
+ if (mddev->chunk_sectors != mddev->new_chunk_sectors ||
mddev->layout != mddev->new_layout ||
mddev->level != mddev->new_level) {
- mddev->new_chunk = mddev->chunk_size;
+ mddev->new_chunk_sectors = mddev->chunk_sectors;
mddev->new_layout = mddev->layout;
mddev->new_level = mddev->level;
return -EINVAL;
@@ -2252,7 +2252,7 @@ static int raid1_reshape(mddev_t *mddev)
static void raid1_quiesce(mddev_t *mddev, int state)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
switch(state) {
case 1:
diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
index 1620eea3d57c..e87b84deff68 100644
--- a/drivers/md/raid1.h
+++ b/drivers/md/raid1.h
@@ -64,12 +64,6 @@ struct r1_private_data_s {
typedef struct r1_private_data_s conf_t;
/*
- * this is the only point in the RAID code where we violate
- * C type safety. mddev->private is an 'opaque' pointer.
- */
-#define mddev_to_conf(mddev) ((conf_t *) mddev->private)
-
-/*
* this is our 'private' RAID1 bio.
*
* it contains information about what kind of IO operations were started
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 499620afb44b..30029a312cf5 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -188,7 +188,7 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio)
static void free_r10bio(r10bio_t *r10_bio)
{
- conf_t *conf = mddev_to_conf(r10_bio->mddev);
+ conf_t *conf = r10_bio->mddev->private;
/*
* Wake up any possible resync thread that waits for the device
@@ -202,7 +202,7 @@ static void free_r10bio(r10bio_t *r10_bio)
static void put_buf(r10bio_t *r10_bio)
{
- conf_t *conf = mddev_to_conf(r10_bio->mddev);
+ conf_t *conf = r10_bio->mddev->private;
mempool_free(r10_bio, conf->r10buf_pool);
@@ -213,7 +213,7 @@ static void reschedule_retry(r10bio_t *r10_bio)
{
unsigned long flags;
mddev_t *mddev = r10_bio->mddev;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
spin_lock_irqsave(&conf->device_lock, flags);
list_add(&r10_bio->retry_list, &conf->retry_list);
@@ -245,7 +245,7 @@ static void raid_end_bio_io(r10bio_t *r10_bio)
*/
static inline void update_head_pos(int slot, r10bio_t *r10_bio)
{
- conf_t *conf = mddev_to_conf(r10_bio->mddev);
+ conf_t *conf = r10_bio->mddev->private;
conf->mirrors[r10_bio->devs[slot].devnum].head_position =
r10_bio->devs[slot].addr + (r10_bio->sectors);
@@ -256,7 +256,7 @@ static void raid10_end_read_request(struct bio *bio, int error)
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
int slot, dev;
- conf_t *conf = mddev_to_conf(r10_bio->mddev);
+ conf_t *conf = r10_bio->mddev->private;
slot = r10_bio->read_slot;
@@ -297,7 +297,7 @@ static void raid10_end_write_request(struct bio *bio, int error)
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
int slot, dev;
- conf_t *conf = mddev_to_conf(r10_bio->mddev);
+ conf_t *conf = r10_bio->mddev->private;
for (slot = 0; slot < conf->copies; slot++)
if (r10_bio->devs[slot].bio == bio)
@@ -461,7 +461,7 @@ static int raid10_mergeable_bvec(struct request_queue *q,
mddev_t *mddev = q->queuedata;
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
int max;
- unsigned int chunk_sectors = mddev->chunk_size >> 9;
+ unsigned int chunk_sectors = mddev->chunk_sectors;
unsigned int bio_sectors = bvm->bi_size >> 9;
max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
@@ -596,7 +596,7 @@ rb_out:
static void unplug_slaves(mddev_t *mddev)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i;
rcu_read_lock();
@@ -628,7 +628,7 @@ static void raid10_unplug(struct request_queue *q)
static int raid10_congested(void *data, int bits)
{
mddev_t *mddev = data;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i, ret = 0;
rcu_read_lock();
@@ -788,7 +788,7 @@ static void unfreeze_array(conf_t *conf)
static int make_request(struct request_queue *q, struct bio * bio)
{
mddev_t *mddev = q->queuedata;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
mirror_info_t *mirror;
r10bio_t *r10_bio;
struct bio *read_bio;
@@ -981,11 +981,11 @@ static int make_request(struct request_queue *q, struct bio * bio)
static void status(struct seq_file *seq, mddev_t *mddev)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i;
if (conf->near_copies < conf->raid_disks)
- seq_printf(seq, " %dK chunks", mddev->chunk_size/1024);
+ seq_printf(seq, " %dK chunks", mddev->chunk_sectors / 2);
if (conf->near_copies > 1)
seq_printf(seq, " %d near-copies", conf->near_copies);
if (conf->far_copies > 1) {
@@ -1006,7 +1006,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
static void error(mddev_t *mddev, mdk_rdev_t *rdev)
{
char b[BDEVNAME_SIZE];
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
/*
* If it is not operational, then we have already marked it as dead
@@ -1158,8 +1158,8 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
* a one page request is never in violation.
*/
if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
- mddev->queue->max_sectors = (PAGE_SIZE>>9);
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
+ blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
p->head_position = 0;
rdev->raid_disk = mirror;
@@ -1215,7 +1215,7 @@ abort:
static void end_sync_read(struct bio *bio, int error)
{
r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
- conf_t *conf = mddev_to_conf(r10_bio->mddev);
+ conf_t *conf = r10_bio->mddev->private;
int i,d;
for (i=0; i<conf->copies; i++)
@@ -1253,7 +1253,7 @@ static void end_sync_write(struct bio *bio, int error)
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
mddev_t *mddev = r10_bio->mddev;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i,d;
for (i = 0; i < conf->copies; i++)
@@ -1300,7 +1300,7 @@ static void end_sync_write(struct bio *bio, int error)
*/
static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i, first;
struct bio *tbio, *fbio;
@@ -1400,7 +1400,7 @@ done:
static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
int i, d;
struct bio *bio, *wbio;
@@ -1549,7 +1549,7 @@ static void raid10d(mddev_t *mddev)
r10bio_t *r10_bio;
struct bio *bio;
unsigned long flags;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
struct list_head *head = &conf->retry_list;
int unplug=0;
mdk_rdev_t *rdev;
@@ -1572,7 +1572,7 @@ static void raid10d(mddev_t *mddev)
spin_unlock_irqrestore(&conf->device_lock, flags);
mddev = r10_bio->mddev;
- conf = mddev_to_conf(mddev);
+ conf = mddev->private;
if (test_bit(R10BIO_IsSync, &r10_bio->state)) {
sync_request_write(mddev, r10_bio);
unplug = 1;
@@ -1680,7 +1680,7 @@ static int init_resync(conf_t *conf)
static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
r10bio_t *r10_bio;
struct bio *biolist = NULL, *bio;
sector_t max_sector, nr_sectors;
@@ -2026,7 +2026,7 @@ static sector_t
raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks)
{
sector_t size;
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
if (!raid_disks)
raid_disks = mddev->raid_disks;
@@ -2050,9 +2050,10 @@ static int run(mddev_t *mddev)
int nc, fc, fo;
sector_t stride, size;
- if (mddev->chunk_size < PAGE_SIZE) {
+ if (mddev->chunk_sectors < (PAGE_SIZE >> 9) ||
+ !is_power_of_2(mddev->chunk_sectors)) {
printk(KERN_ERR "md/raid10: chunk size must be "
- "at least PAGE_SIZE(%ld).\n", PAGE_SIZE);
+ "at least PAGE_SIZE(%ld) and be a power of 2.\n", PAGE_SIZE);
return -EINVAL;
}
@@ -2095,8 +2096,8 @@ static int run(mddev_t *mddev)
conf->far_copies = fc;
conf->copies = nc*fc;
conf->far_offset = fo;
- conf->chunk_mask = (sector_t)(mddev->chunk_size>>9)-1;
- conf->chunk_shift = ffz(~mddev->chunk_size) - 9;
+ conf->chunk_mask = mddev->chunk_sectors - 1;
+ conf->chunk_shift = ffz(~mddev->chunk_sectors);
size = mddev->dev_sectors >> conf->chunk_shift;
sector_div(size, fc);
size = size * conf->raid_disks;
@@ -2145,8 +2146,8 @@ static int run(mddev_t *mddev)
* a one page request is never in violation.
*/
if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
- mddev->queue->max_sectors > (PAGE_SIZE>>9))
- mddev->queue->max_sectors = (PAGE_SIZE>>9);
+ queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
+ blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
disk->head_position = 0;
}
@@ -2204,7 +2205,8 @@ static int run(mddev_t *mddev)
* maybe...
*/
{
- int stripe = conf->raid_disks * (mddev->chunk_size / PAGE_SIZE);
+ int stripe = conf->raid_disks *
+ ((mddev->chunk_sectors << 9) / PAGE_SIZE);
stripe /= conf->near_copies;
if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
mddev->queue->backing_dev_info.ra_pages = 2* stripe;
@@ -2227,7 +2229,7 @@ out:
static int stop(mddev_t *mddev)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
raise_barrier(conf, 0);
lower_barrier(conf);
@@ -2245,7 +2247,7 @@ static int stop(mddev_t *mddev)
static void raid10_quiesce(mddev_t *mddev, int state)
{
- conf_t *conf = mddev_to_conf(mddev);
+ conf_t *conf = mddev->private;
switch(state) {
case 1:
diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h
index 244dbe507a54..59cd1efb8d30 100644
--- a/drivers/md/raid10.h
+++ b/drivers/md/raid10.h
@@ -62,12 +62,6 @@ struct r10_private_data_s {
typedef struct r10_private_data_s conf_t;
/*
- * this is the only point in the RAID code where we violate
- * C type safety. mddev->private is an 'opaque' pointer.
- */
-#define mddev_to_conf(mddev) ((conf_t *) mddev->private)
-
-/*
* this is our 'private' RAID10 bio.
*
* it contains information about what kind of IO operations were started
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 4616bc3a6e71..b1fa70f7a05e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1274,8 +1274,8 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
sector_t new_sector;
int algorithm = previous ? conf->prev_algo
: conf->algorithm;
- int sectors_per_chunk = previous ? (conf->prev_chunk >> 9)
- : (conf->chunk_size >> 9);
+ int sectors_per_chunk = previous ? conf->prev_chunk_sectors
+ : conf->chunk_sectors;
int raid_disks = previous ? conf->previous_raid_disks
: conf->raid_disks;
int data_disks = raid_disks - conf->max_degraded;
@@ -1480,8 +1480,8 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous)
int raid_disks = sh->disks;
int data_disks = raid_disks - conf->max_degraded;
sector_t new_sector = sh->sector, check;
- int sectors_per_chunk = previous ? (conf->prev_chunk >> 9)
- : (conf->chunk_size >> 9);
+ int sectors_per_chunk = previous ? conf->prev_chunk_sectors
+ : conf->chunk_sectors;
int algorithm = previous ? conf->prev_algo
: conf->algorithm;
sector_t stripe;
@@ -1997,8 +1997,7 @@ static void stripe_set_idx(sector_t stripe, raid5_conf_t *conf, int previous,
struct stripe_head *sh)
{
int sectors_per_chunk =
- previous ? (conf->prev_chunk >> 9)
- : (conf->chunk_size >> 9);
+ previous ? conf->prev_chunk_sectors : conf->chunk_sectors;
int dd_idx;
int chunk_offset = sector_div(stripe, sectors_per_chunk);
int disks = previous ? conf->previous_raid_disks : conf->raid_disks;
@@ -3284,7 +3283,7 @@ static void activate_bit_delay(raid5_conf_t *conf)
static void unplug_slaves(mddev_t *mddev)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
int i;
rcu_read_lock();
@@ -3308,7 +3307,7 @@ static void unplug_slaves(mddev_t *mddev)
static void raid5_unplug_device(struct request_queue *q)
{
mddev_t *mddev = q->queuedata;
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
unsigned long flags;
spin_lock_irqsave(&conf->device_lock, flags);
@@ -3327,7 +3326,7 @@ static void raid5_unplug_device(struct request_queue *q)
static int raid5_congested(void *data, int bits)
{
mddev_t *mddev = data;
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
/* No difference between reads and writes. Just check
* how busy the stripe_cache is
@@ -3352,14 +3351,14 @@ static int raid5_mergeable_bvec(struct request_queue *q,
mddev_t *mddev = q->queuedata;
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
int max;
- unsigned int chunk_sectors = mddev->chunk_size >> 9;
+ unsigned int chunk_sectors = mddev->chunk_sectors;
unsigned int bio_sectors = bvm->bi_size >> 9;
if ((bvm->bi_rw & 1) == WRITE)
return biovec->bv_len; /* always allow writes to be mergeable */
- if (mddev->new_chunk < mddev->chunk_size)
- chunk_sectors = mddev->new_chunk >> 9;
+ if (mddev->new_chunk_sectors < mddev->chunk_sectors)
+ chunk_sectors = mddev->new_chunk_sectors;
max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
if (max < 0) max = 0;
if (max <= biovec->bv_len && bio_sectors == 0)
@@ -3372,11 +3371,11 @@ static int raid5_mergeable_bvec(struct request_queue *q,
static int in_chunk_boundary(mddev_t *mddev, struct bio *bio)
{
sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev);
- unsigned int chunk_sectors = mddev->chunk_size >> 9;
+ unsigned int chunk_sectors = mddev->chunk_sectors;
unsigned int bio_sectors = bio->bi_size >> 9;
- if (mddev->new_chunk < mddev->chunk_size)
- chunk_sectors = mddev->new_chunk >> 9;
+ if (mddev->new_chunk_sectors < mddev->chunk_sectors)
+ chunk_sectors = mddev->new_chunk_sectors;
return chunk_sectors >=
((sector & (chunk_sectors - 1)) + bio_sectors);
}
@@ -3440,7 +3439,7 @@ static void raid5_align_endio(struct bio *bi, int error)
bio_put(bi);
mddev = raid_bi->bi_bdev->bd_disk->queue->queuedata;
- conf = mddev_to_conf(mddev);
+ conf = mddev->private;
rdev = (void*)raid_bi->bi_next;
raid_bi->bi_next = NULL;
@@ -3463,10 +3462,10 @@ static int bio_fits_rdev(struct bio *bi)
{
struct request_queue *q = bdev_get_queue(bi->bi_bdev);
- if ((bi->bi_size>>9) > q->max_sectors)
+ if ((bi->bi_size>>9) > queue_max_sectors(q))
return 0;
blk_recount_segments(q, bi);
- if (bi->bi_phys_segments > q->max_phys_segments)
+ if (bi->bi_phys_segments > queue_max_phys_segments(q))
return 0;
if (q->merge_bvec_fn)
@@ -3482,7 +3481,7 @@ static int bio_fits_rdev(struct bio *bi)
static int chunk_aligned_read(struct request_queue *q, struct bio * raid_bio)
{
mddev_t *mddev = q->queuedata;
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
unsigned int dd_idx;
struct bio* align_bi;
mdk_rdev_t *rdev;
@@ -3599,7 +3598,7 @@ static struct stripe_head *__get_priority_stripe(raid5_conf_t *conf)
static int make_request(struct request_queue *q, struct bio * bi)
{
mddev_t *mddev = q->queuedata;
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
int dd_idx;
sector_t new_sector;
sector_t logical_sector, last_sector;
@@ -3791,10 +3790,10 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
* If old and new chunk sizes differ, we need to process the
* largest of these
*/
- if (mddev->new_chunk > mddev->chunk_size)
- reshape_sectors = mddev->new_chunk / 512;
+ if (mddev->new_chunk_sectors > mddev->chunk_sectors)
+ reshape_sectors = mddev->new_chunk_sectors;
else
- reshape_sectors = mddev->chunk_size / 512;
+ reshape_sectors = mddev->chunk_sectors;
/* we update the metadata when there is more than 3Meg
* in the block range (that is rather arbitrary, should
@@ -3811,13 +3810,13 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
safepos = conf->reshape_safe;
sector_div(safepos, data_disks);
if (mddev->delta_disks < 0) {
- writepos -= reshape_sectors;
+ writepos -= min(reshape_sectors, writepos);
readpos += reshape_sectors;
safepos += reshape_sectors;
} else {
writepos += reshape_sectors;
- readpos -= reshape_sectors;
- safepos -= reshape_sectors;
+ readpos -= min(reshape_sectors, readpos);
+ safepos -= min(reshape_sectors, safepos);
}
/* 'writepos' is the most advanced device address we might write.
@@ -3916,8 +3915,8 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
raid5_compute_sector(conf, stripe_addr*(new_data_disks),
1, &dd_idx, NULL);
last_sector =
- raid5_compute_sector(conf, ((stripe_addr+conf->chunk_size/512)
- *(new_data_disks) - 1),
+ raid5_compute_sector(conf, ((stripe_addr + conf->chunk_sectors)
+ * new_data_disks - 1),
1, &dd_idx, NULL);
if (last_sector >= mddev->dev_sectors)
last_sector = mddev->dev_sectors - 1;
@@ -4129,7 +4128,7 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio)
static void raid5d(mddev_t *mddev)
{
struct stripe_head *sh;
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
int handled;
pr_debug("+++ raid5d active\n");
@@ -4185,7 +4184,7 @@ static void raid5d(mddev_t *mddev)
static ssize_t
raid5_show_stripe_cache_size(mddev_t *mddev, char *page)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
if (conf)
return sprintf(page, "%d\n", conf->max_nr_stripes);
else
@@ -4195,7 +4194,7 @@ raid5_show_stripe_cache_size(mddev_t *mddev, char *page)
static ssize_t
raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
unsigned long new;
int err;
@@ -4233,7 +4232,7 @@ raid5_stripecache_size = __ATTR(stripe_cache_size, S_IRUGO | S_IWUSR,
static ssize_t
raid5_show_preread_threshold(mddev_t *mddev, char *page)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
if (conf)
return sprintf(page, "%d\n", conf->bypass_threshold);
else
@@ -4243,7 +4242,7 @@ raid5_show_preread_threshold(mddev_t *mddev, char *page)
static ssize_t
raid5_store_preread_threshold(mddev_t *mddev, const char *page, size_t len)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
unsigned long new;
if (len >= PAGE_SIZE)
return -EINVAL;
@@ -4267,7 +4266,7 @@ raid5_preread_bypass_threshold = __ATTR(preread_bypass_threshold,
static ssize_t
stripe_cache_active_show(mddev_t *mddev, char *page)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
if (conf)
return sprintf(page, "%d\n", atomic_read(&conf->active_stripes));
else
@@ -4291,7 +4290,7 @@ static struct attribute_group raid5_attrs_group = {
static sector_t
raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
if (!sectors)
sectors = mddev->dev_sectors;
@@ -4303,8 +4302,8 @@ raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks)
raid_disks = conf->previous_raid_disks;
}
- sectors &= ~((sector_t)mddev->chunk_size/512 - 1);
- sectors &= ~((sector_t)mddev->new_chunk/512 - 1);
+ sectors &= ~((sector_t)mddev->chunk_sectors - 1);
+ sectors &= ~((sector_t)mddev->new_chunk_sectors - 1);
return sectors * (raid_disks - conf->max_degraded);
}
@@ -4336,9 +4335,11 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
return ERR_PTR(-EINVAL);
}
- if (!mddev->new_chunk || mddev->new_chunk % PAGE_SIZE) {
+ if (!mddev->new_chunk_sectors ||
+ (mddev->new_chunk_sectors << 9) % PAGE_SIZE ||
+ !is_power_of_2(mddev->new_chunk_sectors)) {
printk(KERN_ERR "raid5: invalid chunk size %d for %s\n",
- mddev->new_chunk, mdname(mddev));
+ mddev->new_chunk_sectors << 9, mdname(mddev));
return ERR_PTR(-EINVAL);
}
@@ -4401,7 +4402,7 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
conf->fullsync = 1;
}
- conf->chunk_size = mddev->new_chunk;
+ conf->chunk_sectors = mddev->new_chunk_sectors;
conf->level = mddev->new_level;
if (conf->level == 6)
conf->max_degraded = 2;
@@ -4411,7 +4412,7 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
conf->max_nr_stripes = NR_STRIPES;
conf->reshape_progress = mddev->reshape_position;
if (conf->reshape_progress != MaxSector) {
- conf->prev_chunk = mddev->chunk_size;
+ conf->prev_chunk_sectors = mddev->chunk_sectors;
conf->prev_algo = mddev->layout;
}
@@ -4475,7 +4476,7 @@ static int run(mddev_t *mddev)
* geometry.
*/
here_new = mddev->reshape_position;
- if (sector_div(here_new, (mddev->new_chunk>>9)*
+ if (sector_div(here_new, mddev->new_chunk_sectors *
(mddev->raid_disks - max_degraded))) {
printk(KERN_ERR "raid5: reshape_position not "
"on a stripe boundary\n");
@@ -4483,7 +4484,7 @@ static int run(mddev_t *mddev)
}
/* here_new is the stripe we will write to */
here_old = mddev->reshape_position;
- sector_div(here_old, (mddev->chunk_size>>9)*
+ sector_div(here_old, mddev->chunk_sectors *
(old_disks-max_degraded));
/* here_old is the first stripe that we might need to read
* from */
@@ -4498,7 +4499,7 @@ static int run(mddev_t *mddev)
} else {
BUG_ON(mddev->level != mddev->new_level);
BUG_ON(mddev->layout != mddev->new_layout);
- BUG_ON(mddev->chunk_size != mddev->new_chunk);
+ BUG_ON(mddev->chunk_sectors != mddev->new_chunk_sectors);
BUG_ON(mddev->delta_disks != 0);
}
@@ -4532,7 +4533,7 @@ static int run(mddev_t *mddev)
}
/* device size must be a multiple of chunk size */
- mddev->dev_sectors &= ~(mddev->chunk_size / 512 - 1);
+ mddev->dev_sectors &= ~(mddev->chunk_sectors - 1);
mddev->resync_max_sectors = mddev->dev_sectors;
if (mddev->degraded > 0 &&
@@ -4581,7 +4582,7 @@ static int run(mddev_t *mddev)
{
int data_disks = conf->previous_raid_disks - conf->max_degraded;
int stripe = data_disks *
- (mddev->chunk_size / PAGE_SIZE);
+ ((mddev->chunk_sectors << 9) / PAGE_SIZE);
if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
}
@@ -4678,7 +4679,8 @@ static void status(struct seq_file *seq, mddev_t *mddev)
raid5_conf_t *conf = (raid5_conf_t *) mddev->private;
int i;
- seq_printf (seq, " level %d, %dk chunk, algorithm %d", mddev->level, mddev->chunk_size >> 10, mddev->layout);
+ seq_printf(seq, " level %d, %dk chunk, algorithm %d", mddev->level,
+ mddev->chunk_sectors / 2, mddev->layout);
seq_printf (seq, " [%d/%d] [", conf->raid_disks, conf->raid_disks - mddev->degraded);
for (i = 0; i < conf->raid_disks; i++)
seq_printf (seq, "%s",
@@ -4826,7 +4828,7 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
* any io in the removed space completes, but it hardly seems
* worth it.
*/
- sectors &= ~((sector_t)mddev->chunk_size/512 - 1);
+ sectors &= ~((sector_t)mddev->chunk_sectors - 1);
md_set_array_sectors(mddev, raid5_size(mddev, sectors,
mddev->raid_disks));
if (mddev->array_sectors >
@@ -4843,14 +4845,37 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
return 0;
}
-static int raid5_check_reshape(mddev_t *mddev)
+static int check_stripe_cache(mddev_t *mddev)
+{
+ /* Can only proceed if there are plenty of stripe_heads.
+ * We need a minimum of one full stripe,, and for sensible progress
+ * it is best to have about 4 times that.
+ * If we require 4 times, then the default 256 4K stripe_heads will
+ * allow for chunk sizes up to 256K, which is probably OK.
+ * If the chunk size is greater, user-space should request more
+ * stripe_heads first.
+ */
+ raid5_conf_t *conf = mddev->private;
+ if (((mddev->chunk_sectors << 9) / STRIPE_SIZE) * 4
+ > conf->max_nr_stripes ||
+ ((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4
+ > conf->max_nr_stripes) {
+ printk(KERN_WARNING "raid5: reshape: not enough stripes. Needed %lu\n",
+ ((max(mddev->chunk_sectors, mddev->new_chunk_sectors) << 9)
+ / STRIPE_SIZE)*4);
+ return 0;
+ }
+ return 1;
+}
+
+static int check_reshape(mddev_t *mddev)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
if (mddev->delta_disks == 0 &&
mddev->new_layout == mddev->layout &&
- mddev->new_chunk == mddev->chunk_size)
- return -EINVAL; /* nothing to do */
+ mddev->new_chunk_sectors == mddev->chunk_sectors)
+ return 0; /* nothing to do */
if (mddev->bitmap)
/* Cannot grow a bitmap yet */
return -EBUSY;
@@ -4869,28 +4894,15 @@ static int raid5_check_reshape(mddev_t *mddev)
return -EINVAL;
}
- /* Can only proceed if there are plenty of stripe_heads.
- * We need a minimum of one full stripe,, and for sensible progress
- * it is best to have about 4 times that.
- * If we require 4 times, then the default 256 4K stripe_heads will
- * allow for chunk sizes up to 256K, which is probably OK.
- * If the chunk size is greater, user-space should request more
- * stripe_heads first.
- */
- if ((mddev->chunk_size / STRIPE_SIZE) * 4 > conf->max_nr_stripes ||
- (mddev->new_chunk / STRIPE_SIZE) * 4 > conf->max_nr_stripes) {
- printk(KERN_WARNING "raid5: reshape: not enough stripes. Needed %lu\n",
- (max(mddev->chunk_size, mddev->new_chunk)
- / STRIPE_SIZE)*4);
+ if (!check_stripe_cache(mddev))
return -ENOSPC;
- }
return resize_stripes(conf, conf->raid_disks + mddev->delta_disks);
}
static int raid5_start_reshape(mddev_t *mddev)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
mdk_rdev_t *rdev;
int spares = 0;
int added_devices = 0;
@@ -4899,6 +4911,9 @@ static int raid5_start_reshape(mddev_t *mddev)
if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
return -EBUSY;
+ if (!check_stripe_cache(mddev))
+ return -ENOSPC;
+
list_for_each_entry(rdev, &mddev->disks, same_set)
if (rdev->raid_disk < 0 &&
!test_bit(Faulty, &rdev->flags))
@@ -4925,8 +4940,8 @@ static int raid5_start_reshape(mddev_t *mddev)
spin_lock_irq(&conf->device_lock);
conf->previous_raid_disks = conf->raid_disks;
conf->raid_disks += mddev->delta_disks;
- conf->prev_chunk = conf->chunk_size;
- conf->chunk_size = mddev->new_chunk;
+ conf->prev_chunk_sectors = conf->chunk_sectors;
+ conf->chunk_sectors = mddev->new_chunk_sectors;
conf->prev_algo = conf->algorithm;
conf->algorithm = mddev->new_layout;
if (mddev->delta_disks < 0)
@@ -5008,7 +5023,7 @@ static void end_reshape(raid5_conf_t *conf)
*/
{
int data_disks = conf->raid_disks - conf->max_degraded;
- int stripe = data_disks * (conf->chunk_size
+ int stripe = data_disks * ((conf->chunk_sectors << 9)
/ PAGE_SIZE);
if (conf->mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
conf->mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
@@ -5022,7 +5037,7 @@ static void end_reshape(raid5_conf_t *conf)
static void raid5_finish_reshape(mddev_t *mddev)
{
struct block_device *bdev;
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
@@ -5053,7 +5068,7 @@ static void raid5_finish_reshape(mddev_t *mddev)
raid5_remove_disk(mddev, d);
}
mddev->layout = conf->algorithm;
- mddev->chunk_size = conf->chunk_size;
+ mddev->chunk_sectors = conf->chunk_sectors;
mddev->reshape_position = MaxSector;
mddev->delta_disks = 0;
}
@@ -5061,7 +5076,7 @@ static void raid5_finish_reshape(mddev_t *mddev)
static void raid5_quiesce(mddev_t *mddev, int state)
{
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
switch(state) {
case 2: /* resume for a suspend */
@@ -5111,7 +5126,7 @@ static void *raid5_takeover_raid1(mddev_t *mddev)
mddev->new_level = 5;
mddev->new_layout = ALGORITHM_LEFT_SYMMETRIC;
- mddev->new_chunk = chunksect << 9;
+ mddev->new_chunk_sectors = chunksect;
return setup_conf(mddev);
}
@@ -5150,24 +5165,24 @@ static void *raid5_takeover_raid6(mddev_t *mddev)
}
-static int raid5_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
+static int raid5_check_reshape(mddev_t *mddev)
{
/* For a 2-drive array, the layout and chunk size can be changed
* immediately as not restriping is needed.
* For larger arrays we record the new value - after validation
* to be used by a reshape pass.
*/
- raid5_conf_t *conf = mddev_to_conf(mddev);
+ raid5_conf_t *conf = mddev->private;
+ int new_chunk = mddev->new_chunk_sectors;
- if (new_layout >= 0 && !algorithm_valid_raid5(new_layout))
+ if (mddev->new_layout >= 0 && !algorithm_valid_raid5(mddev->new_layout))
return -EINVAL;
if (new_chunk > 0) {
- if (new_chunk & (new_chunk-1))
- /* not a power of 2 */
+ if (!is_power_of_2(new_chunk))
return -EINVAL;
- if (new_chunk < PAGE_SIZE)
+ if (new_chunk < (PAGE_SIZE>>9))
return -EINVAL;
- if (mddev->array_sectors & ((new_chunk>>9)-1))
+ if (mddev->array_sectors & (new_chunk-1))
/* not factor of array size */
return -EINVAL;
}
@@ -5175,49 +5190,39 @@ static int raid5_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
/* They look valid */
if (mddev->raid_disks == 2) {
-
- if (new_layout >= 0) {
- conf->algorithm = new_layout;
- mddev->layout = mddev->new_layout = new_layout;
+ /* can make the change immediately */
+ if (mddev->new_layout >= 0) {
+ conf->algorithm = mddev->new_layout;
+ mddev->layout = mddev->new_layout;
}
if (new_chunk > 0) {
- conf->chunk_size = new_chunk;
- mddev->chunk_size = mddev->new_chunk = new_chunk;
+ conf->chunk_sectors = new_chunk ;
+ mddev->chunk_sectors = new_chunk;
}
set_bit(MD_CHANGE_DEVS, &mddev->flags);
md_wakeup_thread(mddev->thread);
- } else {
- if (new_layout >= 0)
- mddev->new_layout = new_layout;
- if (new_chunk > 0)
- mddev->new_chunk = new_chunk;
}
- return 0;
+ return check_reshape(mddev);
}
-static int raid6_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
+static int raid6_check_reshape(mddev_t *mddev)
{
- if (new_layout >= 0 && !algorithm_valid_raid6(new_layout))
+ int new_chunk = mddev->new_chunk_sectors;
+
+ if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout))
return -EINVAL;
if (new_chunk > 0) {
- if (new_chunk & (new_chunk-1))
- /* not a power of 2 */
+ if (!is_power_of_2(new_chunk))
return -EINVAL;
- if (new_chunk < PAGE_SIZE)
+ if (new_chunk < (PAGE_SIZE >> 9))
return -EINVAL;
- if (mddev->array_sectors & ((new_chunk>>9)-1))
+ if (mddev->array_sectors & (new_chunk-1))
/* not factor of array size */
return -EINVAL;
}
/* They look valid */
-
- if (new_layout >= 0)
- mddev->new_layout = new_layout;
- if (new_chunk > 0)
- mddev->new_chunk = new_chunk;
-
- return 0;
+ return check_reshape(mddev);
}
static void *raid5_takeover(mddev_t *mddev)
@@ -5227,8 +5232,6 @@ static void *raid5_takeover(mddev_t *mddev)
* raid1 - if there are two drives. We need to know the chunk size
* raid4 - trivial - just use a raid4 layout.
* raid6 - Providing it is a *_6 layout
- *
- * For now, just do raid1
*/
if (mddev->level == 1)
@@ -5310,12 +5313,11 @@ static struct mdk_personality raid6_personality =
.sync_request = sync_request,
.resize = raid5_resize,
.size = raid5_size,
- .check_reshape = raid5_check_reshape,
+ .check_reshape = raid6_check_reshape,
.start_reshape = raid5_start_reshape,
.finish_reshape = raid5_finish_reshape,
.quiesce = raid5_quiesce,
.takeover = raid6_takeover,
- .reconfig = raid6_reconfig,
};
static struct mdk_personality raid5_personality =
{
@@ -5338,7 +5340,6 @@ static struct mdk_personality raid5_personality =
.finish_reshape = raid5_finish_reshape,
.quiesce = raid5_quiesce,
.takeover = raid5_takeover,
- .reconfig = raid5_reconfig,
};
static struct mdk_personality raid4_personality =
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index 52ba99954dec..9459689c4ea0 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -334,7 +334,8 @@ struct raid5_private_data {
struct hlist_head *stripe_hashtbl;
mddev_t *mddev;
struct disk_info *spare;
- int chunk_size, level, algorithm;
+ int chunk_sectors;
+ int level, algorithm;
int max_degraded;
int raid_disks;
int max_nr_stripes;
@@ -350,7 +351,8 @@ struct raid5_private_data {
*/
sector_t reshape_safe;
int previous_raid_disks;
- int prev_chunk, prev_algo;
+ int prev_chunk_sectors;
+ int prev_algo;
short generation; /* increments with every reshape */
unsigned long reshape_checkpoint; /* Time we last updated
* metadata */
@@ -408,8 +410,6 @@ struct raid5_private_data {
typedef struct raid5_private_data raid5_conf_t;
-#define mddev_to_conf(mddev) ((raid5_conf_t *) mddev->private)
-
/*
* Our supported algorithms
*/
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index 1adce9ff52ce..fd83cc0c134c 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -272,7 +272,7 @@ static int load_all_firmwares(struct dvb_frontend *fe)
fname = firmware_name;
tuner_dbg("Reading firmware %s\n", fname);
- rc = request_firmware(&fw, fname, &priv->i2c_props.adap->dev);
+ rc = request_firmware(&fw, fname, priv->i2c_props.adap->dev.parent);
if (rc < 0) {
if (rc == -ENOENT)
tuner_err("Error: firmware %s not found.\n",
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index b54598550dc4..f3880f8977e0 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -575,7 +575,7 @@ static int xc5000_fwupload(struct dvb_frontend *fe)
XC5000_DEFAULT_FIRMWARE);
ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE,
- &priv->i2c_props.adap->dev);
+ priv->i2c_props.adap->dev.parent);
if (ret) {
printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n");
ret = XC_RESULT_RESET_FAILURE;
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index a454ee8f1e43..479dd05762a5 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -447,6 +447,15 @@ static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env)
return 0;
}
+static char *dvb_nodename(struct device *dev)
+{
+ struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+ return kasprintf(GFP_KERNEL, "dvb/adapter%d/%s%d",
+ dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id);
+}
+
+
static int __init init_dvbdev(void)
{
int retval;
@@ -469,6 +478,7 @@ static int __init init_dvbdev(void)
goto error;
}
dvb_class->dev_uevent = dvb_uevent;
+ dvb_class->nodename = dvb_nodename;
return 0;
error:
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 53bfc8e42fb9..06d54b005945 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -40,7 +40,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
static DEFINE_MUTEX(af9015_usb_mutex);
static struct af9015_config af9015_config;
-static struct dvb_usb_device_properties af9015_properties[2];
+static struct dvb_usb_device_properties af9015_properties[3];
static int af9015_properties_count = ARRAY_SIZE(af9015_properties);
static struct af9013_config af9015_af9013_config[] = {
@@ -1261,7 +1261,10 @@ static struct usb_device_id af9015_usb_table[] = {
{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)},
{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3)},
{USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT)},
- {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)},
+/* 20 */{USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)},
+ {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A805)},
+ {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)},
+ {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)},
{0},
};
MODULE_DEVICE_TABLE(usb, af9015_usb_table);
@@ -1321,7 +1324,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
.i2c_algo = &af9015_i2c_algo,
- .num_device_descs = 9,
+ .num_device_descs = 9, /* max 9 */
.devices = {
{
.name = "Afatech AF9015 DVB-T USB2.0 stick",
@@ -1426,7 +1429,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
.i2c_algo = &af9015_i2c_algo,
- .num_device_descs = 9,
+ .num_device_descs = 9, /* max 9 */
.devices = {
{
.name = "Xtensions XD-380",
@@ -1478,7 +1481,80 @@ static struct dvb_usb_device_properties af9015_properties[] = {
.warm_ids = {NULL},
},
}
- }
+ }, {
+ .caps = DVB_USB_IS_AN_I2C_ADAPTER,
+
+ .usb_ctrl = DEVICE_SPECIFIC,
+ .download_firmware = af9015_download_firmware,
+ .firmware = "dvb-usb-af9015.fw",
+ .no_reconnect = 1,
+
+ .size_of_priv = sizeof(struct af9015_state), \
+
+ .num_adapters = 2,
+ .adapter = {
+ {
+ .caps = DVB_USB_ADAP_HAS_PID_FILTER |
+ DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+
+ .pid_filter_count = 32,
+ .pid_filter = af9015_pid_filter,
+ .pid_filter_ctrl = af9015_pid_filter_ctrl,
+
+ .frontend_attach =
+ af9015_af9013_frontend_attach,
+ .tuner_attach = af9015_tuner_attach,
+ .stream = {
+ .type = USB_BULK,
+ .count = 6,
+ .endpoint = 0x84,
+ },
+ },
+ {
+ .frontend_attach =
+ af9015_af9013_frontend_attach,
+ .tuner_attach = af9015_tuner_attach,
+ .stream = {
+ .type = USB_BULK,
+ .count = 6,
+ .endpoint = 0x85,
+ .u = {
+ .bulk = {
+ .buffersize =
+ TS_USB20_MAX_PACKET_SIZE,
+ }
+ }
+ },
+ }
+ },
+
+ .identify_state = af9015_identify_state,
+
+ .rc_query = af9015_rc_query,
+ .rc_interval = 150,
+
+ .i2c_algo = &af9015_i2c_algo,
+
+ .num_device_descs = 3, /* max 9 */
+ .devices = {
+ {
+ .name = "AverMedia AVerTV Volar GPS 805 (A805)",
+ .cold_ids = {&af9015_usb_table[21], NULL},
+ .warm_ids = {NULL},
+ },
+ {
+ .name = "Conceptronic USB2.0 DVB-T CTVDIGRCU " \
+ "V3.0",
+ .cold_ids = {&af9015_usb_table[22], NULL},
+ .warm_ids = {NULL},
+ },
+ {
+ .name = "KWorld Digial MC-810",
+ .cold_ids = {&af9015_usb_table[23], NULL},
+ .warm_ids = {NULL},
+ },
+ }
+ },
};
static int af9015_usb_probe(struct usb_interface *intf,
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 8ddbadf62194..6251b384fb53 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -1493,6 +1493,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
+/* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
{ 0 } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -1692,7 +1693,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
},
},
- .num_device_descs = 11,
+ .num_device_descs = 12,
.devices = {
{ "DiBcom STK7070P reference design",
{ &dib0700_usb_id_table[15], NULL },
@@ -1738,6 +1739,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
{ &dib0700_usb_id_table[45], NULL },
{ NULL },
},
+ { "Elgato EyeTV Dtt Dlx PD378S",
+ { &dib0700_usb_id_table[50], NULL },
+ { NULL },
+ },
},
.rc_interval = DEFAULT_RC_INTERVAL,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index f506c74119f3..1b5e65f1ddaa 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -80,6 +80,7 @@
#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d
#define USB_PID_COMPRO_VIDEOMATE_U500 0x1e78
#define USB_PID_COMPRO_VIDEOMATE_U500_PC 0x1e80
+#define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397
#define USB_PID_CONEXANT_D680_DMB 0x86d6
#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064
#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065
@@ -104,6 +105,7 @@
#define USB_PID_KWORLD_395U 0xe396
#define USB_PID_KWORLD_395U_2 0xe39b
#define USB_PID_KWORLD_395U_3 0xe395
+#define USB_PID_KWORLD_MC810 0xc810
#define USB_PID_KWORLD_PC160_2T 0xc160
#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
@@ -171,6 +173,7 @@
#define USB_PID_AVERMEDIA_A309 0xa309
#define USB_PID_AVERMEDIA_A310 0xa310
#define USB_PID_AVERMEDIA_A850 0x850a
+#define USB_PID_AVERMEDIA_A805 0xa805
#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
@@ -251,5 +254,6 @@
#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807
#define USB_PID_SONY_PLAYTV 0x0003
#define USB_PID_ELGATO_EYETV_DTT 0x0021
+#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020
#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 2d5352e54dc0..97495154f746 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -223,7 +223,7 @@ struct dvb_usb_device_properties {
int generic_bulk_ctrl_endpoint;
int num_device_descs;
- struct dvb_usb_device_description devices[11];
+ struct dvb_usb_device_description devices[12];
};
/**
diff --git a/drivers/media/dvb/firewire/firedtv-1394.c b/drivers/media/dvb/firewire/firedtv-1394.c
index 4e207658c5d9..2b6eeeab5b25 100644
--- a/drivers/media/dvb/firewire/firedtv-1394.c
+++ b/drivers/media/dvb/firewire/firedtv-1394.c
@@ -225,7 +225,7 @@ fail_free:
static int node_remove(struct device *dev)
{
- struct firedtv *fdtv = dev->driver_data;
+ struct firedtv *fdtv = dev_get_drvdata(dev);
fdtv_dvb_unregister(fdtv);
@@ -242,7 +242,7 @@ static int node_remove(struct device *dev)
static int node_update(struct unit_directory *ud)
{
- struct firedtv *fdtv = ud->device.driver_data;
+ struct firedtv *fdtv = dev_get_drvdata(&ud->device);
if (fdtv->isochannel >= 0)
cmp_establish_pp_connection(fdtv, fdtv->subunit,
diff --git a/drivers/media/dvb/firewire/firedtv-dvb.c b/drivers/media/dvb/firewire/firedtv-dvb.c
index 9d308dd32a5c..5742fde79d99 100644
--- a/drivers/media/dvb/firewire/firedtv-dvb.c
+++ b/drivers/media/dvb/firewire/firedtv-dvb.c
@@ -268,7 +268,7 @@ struct firedtv *fdtv_alloc(struct device *dev,
if (!fdtv)
return NULL;
- dev->driver_data = fdtv;
+ dev_set_drvdata(dev, fdtv);
fdtv->device = dev;
fdtv->isochannel = -1;
fdtv->voltage = 0xff;
diff --git a/drivers/media/dvb/firewire/firedtv-rc.c b/drivers/media/dvb/firewire/firedtv-rc.c
index 46a6324d7b73..27bca2e283df 100644
--- a/drivers/media/dvb/firewire/firedtv-rc.c
+++ b/drivers/media/dvb/firewire/firedtv-rc.c
@@ -18,7 +18,7 @@
#include "firedtv.h"
/* fixed table with older keycodes, geared towards MythTV */
-const static u16 oldtable[] = {
+static const u16 oldtable[] = {
/* code from device: 0x4501...0x451f */
@@ -62,7 +62,7 @@ const static u16 oldtable[] = {
};
/* user-modifiable table for a remote as sold in 2008 */
-const static u16 keytable[] = {
+static const u16 keytable[] = {
/* code from device: 0x0300...0x031f */
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 23e4cffeba38..be967ac09a39 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -35,6 +35,21 @@ config DVB_STB6100
A Silicon tuner from ST used in conjunction with the STB0899
demodulator. Say Y when you want to support this tuner.
+config DVB_STV090x
+ tristate "STV0900/STV0903(A/B) based"
+ depends on DVB_CORE && I2C
+ default m if DVB_FE_CUSTOMISE
+ help
+ DVB-S/S2/DSS Multistandard Professional/Broadcast demodulators.
+ Say Y when you want to support these frontends.
+
+config DVB_STV6110x
+ tristate "STV6110/(A) based tuners"
+ depends on DVB_CORE && I2C
+ default m if DVB_FE_CUSTOMISE
+ help
+ A Silicon tuner that supports DVB-S and DVB-S2 modes
+
comment "DVB-S (satellite) frontends"
depends on DVB_CORE
@@ -506,6 +521,13 @@ config DVB_ISL6421
help
An SEC control chip.
+config DVB_ISL6423
+ tristate "ISL6423 SEC controller"
+ depends on DVB_CORE && I2C
+ default m if DVB_FE_CUSTOMISE
+ help
+ A SEC controller chip from Intersil
+
config DVB_LGS8GL5
tristate "Silicon Legend LGS-8GL5 demodulator (OFDM)"
depends on DVB_CORE && I2C
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index bc2b00abd106..832473c1e512 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -71,4 +71,6 @@ obj-$(CONFIG_DVB_STB6000) += stb6000.o
obj-$(CONFIG_DVB_S921) += s921.o
obj-$(CONFIG_DVB_STV6110) += stv6110.o
obj-$(CONFIG_DVB_STV0900) += stv0900.o
-
+obj-$(CONFIG_DVB_STV090x) += stv090x.o
+obj-$(CONFIG_DVB_STV6110x) += stv6110x.o
+obj-$(CONFIG_DVB_ISL6423) += isl6423.o
diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c
index b2b50fb4cfd3..136c5863d81b 100644
--- a/drivers/media/dvb/frontends/af9013.c
+++ b/drivers/media/dvb/frontends/af9013.c
@@ -1455,7 +1455,7 @@ static int af9013_download_firmware(struct af9013_state *state)
af9013_ops.info.name);
/* request the firmware, this will block and timeout */
- ret = request_firmware(&fw, fw_file, &state->i2c->dev);
+ ret = request_firmware(&fw, fw_file, state->i2c->dev.parent);
if (ret) {
err("did not find the firmware file. (%s) "
"Please see linux/Documentation/dvb/ for more details" \
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c
index 9b9f57264cef..2410d8b59b6b 100644
--- a/drivers/media/dvb/frontends/cx24116.c
+++ b/drivers/media/dvb/frontends/cx24116.c
@@ -492,7 +492,7 @@ static int cx24116_firmware_ondemand(struct dvb_frontend *fe)
printk(KERN_INFO "%s: Waiting for firmware upload (%s)...\n",
__func__, CX24116_DEFAULT_FIRMWARE);
ret = request_firmware(&fw, CX24116_DEFAULT_FIRMWARE,
- &state->i2c->dev);
+ state->i2c->dev.parent);
printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n",
__func__);
if (ret) {
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c
index 172f1f928f02..010075535221 100644
--- a/drivers/media/dvb/frontends/drx397xD.c
+++ b/drivers/media/dvb/frontends/drx397xD.c
@@ -123,10 +123,10 @@ static int drx_load_fw(struct drx397xD_state *s, enum fw_ix ix)
}
memset(&fw[ix].data[0], 0, sizeof(fw[0].data));
- if (request_firmware(&fw[ix].file, fw[ix].name, &s->i2c->dev) != 0) {
+ rc = request_firmware(&fw[ix].file, fw[ix].name, s->i2c->dev.parent);
+ if (rc != 0) {
printk(KERN_ERR "%s: Firmware \"%s\" not available\n",
mod_name, fw[ix].name);
- rc = -ENOENT;
goto exit_err;
}
diff --git a/drivers/media/dvb/frontends/isl6423.c b/drivers/media/dvb/frontends/isl6423.c
new file mode 100644
index 000000000000..dca5bebfeeb5
--- /dev/null
+++ b/drivers/media/dvb/frontends/isl6423.c
@@ -0,0 +1,308 @@
+/*
+ Intersil ISL6423 SEC and LNB Power supply controller
+
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include "dvb_frontend.h"
+#include "isl6423.h"
+
+static unsigned int verbose;
+module_param(verbose, int, 0644);
+MODULE_PARM_DESC(verbose, "Set Verbosity level");
+
+#define FE_ERROR 0
+#define FE_NOTICE 1
+#define FE_INFO 2
+#define FE_DEBUG 3
+#define FE_DEBUGREG 4
+
+#define dprintk(__y, __z, format, arg...) do { \
+ if (__z) { \
+ if ((verbose > FE_ERROR) && (verbose > __y)) \
+ printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_NOTICE) && (verbose > __y)) \
+ printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_INFO) && (verbose > __y)) \
+ printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_DEBUG) && (verbose > __y)) \
+ printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
+ } else { \
+ if (verbose > __y) \
+ printk(format, ##arg); \
+ } \
+} while (0)
+
+struct isl6423_dev {
+ const struct isl6423_config *config;
+ struct i2c_adapter *i2c;
+
+ u8 reg_3;
+ u8 reg_4;
+
+ unsigned int verbose;
+};
+
+static int isl6423_write(struct isl6423_dev *isl6423, u8 reg)
+{
+ struct i2c_adapter *i2c = isl6423->i2c;
+ u8 addr = isl6423->config->addr;
+ int err = 0;
+
+ struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = &reg, .len = 1 };
+
+ dprintk(FE_DEBUG, 1, "write reg %02X", reg);
+ err = i2c_transfer(i2c, &msg, 1);
+ if (err < 0)
+ goto exit;
+ return 0;
+
+exit:
+ dprintk(FE_ERROR, 1, "I/O error <%d>", err);
+ return err;
+}
+
+static int isl6423_set_modulation(struct dvb_frontend *fe)
+{
+ struct isl6423_dev *isl6423 = (struct isl6423_dev *) fe->sec_priv;
+ const struct isl6423_config *config = isl6423->config;
+ int err = 0;
+ u8 reg_2 = 0;
+
+ reg_2 = 0x01 << 5;
+
+ if (config->mod_extern)
+ reg_2 |= (1 << 3);
+ else
+ reg_2 |= (1 << 4);
+
+ err = isl6423_write(isl6423, reg_2);
+ if (err < 0)
+ goto exit;
+ return 0;
+
+exit:
+ dprintk(FE_ERROR, 1, "I/O error <%d>", err);
+ return err;
+}
+
+static int isl6423_voltage_boost(struct dvb_frontend *fe, long arg)
+{
+ struct isl6423_dev *isl6423 = (struct isl6423_dev *) fe->sec_priv;
+ u8 reg_3 = isl6423->reg_3;
+ u8 reg_4 = isl6423->reg_4;
+ int err = 0;
+
+ if (arg) {
+ /* EN = 1, VSPEN = 1, VBOT = 1 */
+ reg_4 |= (1 << 4);
+ reg_4 |= 0x1;
+ reg_3 |= (1 << 3);
+ } else {
+ /* EN = 1, VSPEN = 1, VBOT = 0 */
+ reg_4 |= (1 << 4);
+ reg_4 &= ~0x1;
+ reg_3 |= (1 << 3);
+ }
+ err = isl6423_write(isl6423, reg_3);
+ if (err < 0)
+ goto exit;
+
+ err = isl6423_write(isl6423, reg_4);
+ if (err < 0)
+ goto exit;
+
+ isl6423->reg_3 = reg_3;
+ isl6423->reg_4 = reg_4;
+
+ return 0;
+exit:
+ dprintk(FE_ERROR, 1, "I/O error <%d>", err);
+ return err;
+}
+
+
+static int isl6423_set_voltage(struct dvb_frontend *fe,
+ enum fe_sec_voltage voltage)
+{
+ struct isl6423_dev *isl6423 = (struct isl6423_dev *) fe->sec_priv;
+ u8 reg_3 = isl6423->reg_3;
+ u8 reg_4 = isl6423->reg_4;
+ int err = 0;
+
+ switch (voltage) {
+ case SEC_VOLTAGE_OFF:
+ /* EN = 0 */
+ reg_4 &= ~(1 << 4);
+ break;
+
+ case SEC_VOLTAGE_13:
+ /* EN = 1, VSPEN = 1, VTOP = 0, VBOT = 0 */
+ reg_4 |= (1 << 4);
+ reg_4 &= ~0x3;
+ reg_3 |= (1 << 3);
+ break;
+
+ case SEC_VOLTAGE_18:
+ /* EN = 1, VSPEN = 1, VTOP = 1, VBOT = 0 */
+ reg_4 |= (1 << 4);
+ reg_4 |= 0x2;
+ reg_4 &= ~0x1;
+ reg_3 |= (1 << 3);
+ break;
+
+ default:
+ break;
+ }
+ err = isl6423_write(isl6423, reg_3);
+ if (err < 0)
+ goto exit;
+
+ err = isl6423_write(isl6423, reg_4);
+ if (err < 0)
+ goto exit;
+
+ isl6423->reg_3 = reg_3;
+ isl6423->reg_4 = reg_4;
+
+ return 0;
+exit:
+ dprintk(FE_ERROR, 1, "I/O error <%d>", err);
+ return err;
+}
+
+static int isl6423_set_current(struct dvb_frontend *fe)
+{
+ struct isl6423_dev *isl6423 = (struct isl6423_dev *) fe->sec_priv;
+ u8 reg_3 = isl6423->reg_3;
+ const struct isl6423_config *config = isl6423->config;
+ int err = 0;
+
+ switch (config->current_max) {
+ case SEC_CURRENT_275m:
+ /* 275mA */
+ /* ISELH = 0, ISELL = 0 */
+ reg_3 &= ~0x3;
+ break;
+
+ case SEC_CURRENT_515m:
+ /* 515mA */
+ /* ISELH = 0, ISELL = 1 */
+ reg_3 &= ~0x2;
+ reg_3 |= 0x1;
+ break;
+
+ case SEC_CURRENT_635m:
+ /* 635mA */
+ /* ISELH = 1, ISELL = 0 */
+ reg_3 &= ~0x1;
+ reg_3 |= 0x2;
+ break;
+
+ case SEC_CURRENT_800m:
+ /* 800mA */
+ /* ISELH = 1, ISELL = 1 */
+ reg_3 |= 0x3;
+ break;
+ }
+
+ err = isl6423_write(isl6423, reg_3);
+ if (err < 0)
+ goto exit;
+
+ switch (config->curlim) {
+ case SEC_CURRENT_LIM_ON:
+ /* DCL = 0 */
+ reg_3 &= ~0x10;
+ break;
+
+ case SEC_CURRENT_LIM_OFF:
+ /* DCL = 1 */
+ reg_3 |= 0x10;
+ break;
+ }
+
+ err = isl6423_write(isl6423, reg_3);
+ if (err < 0)
+ goto exit;
+
+ isl6423->reg_3 = reg_3;
+
+ return 0;
+exit:
+ dprintk(FE_ERROR, 1, "I/O error <%d>", err);
+ return err;
+}
+
+static void isl6423_release(struct dvb_frontend *fe)
+{
+ isl6423_set_voltage(fe, SEC_VOLTAGE_OFF);
+
+ kfree(fe->sec_priv);
+ fe->sec_priv = NULL;
+}
+
+struct dvb_frontend *isl6423_attach(struct dvb_frontend *fe,
+ struct i2c_adapter *i2c,
+ const struct isl6423_config *config)
+{
+ struct isl6423_dev *isl6423;
+
+ isl6423 = kzalloc(sizeof(struct isl6423_dev), GFP_KERNEL);
+ if (!isl6423)
+ return NULL;
+
+ isl6423->config = config;
+ isl6423->i2c = i2c;
+ fe->sec_priv = isl6423;
+
+ /* SR3H = 0, SR3M = 1, SR3L = 0 */
+ isl6423->reg_3 = 0x02 << 5;
+ /* SR4H = 0, SR4M = 1, SR4L = 1 */
+ isl6423->reg_4 = 0x03 << 5;
+
+ if (isl6423_set_current(fe))
+ goto exit;
+
+ if (isl6423_set_modulation(fe))
+ goto exit;
+
+ fe->ops.release_sec = isl6423_release;
+ fe->ops.set_voltage = isl6423_set_voltage;
+ fe->ops.enable_high_lnb_voltage = isl6423_voltage_boost;
+ isl6423->verbose = verbose;
+
+ return fe;
+
+exit:
+ kfree(isl6423);
+ fe->sec_priv = NULL;
+ return NULL;
+}
+EXPORT_SYMBOL(isl6423_attach);
+
+MODULE_DESCRIPTION("ISL6423 SEC");
+MODULE_AUTHOR("Manu Abraham");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/isl6423.h b/drivers/media/dvb/frontends/isl6423.h
new file mode 100644
index 000000000000..e1a37fba01ca
--- /dev/null
+++ b/drivers/media/dvb/frontends/isl6423.h
@@ -0,0 +1,63 @@
+/*
+ Intersil ISL6423 SEC and LNB Power supply controller
+
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __ISL_6423_H
+#define __ISL_6423_H
+
+#include <linux/dvb/frontend.h>
+
+enum isl6423_current {
+ SEC_CURRENT_275m = 0,
+ SEC_CURRENT_515m,
+ SEC_CURRENT_635m,
+ SEC_CURRENT_800m,
+};
+
+enum isl6423_curlim {
+ SEC_CURRENT_LIM_ON = 1,
+ SEC_CURRENT_LIM_OFF
+};
+
+struct isl6423_config {
+ enum isl6423_current current_max;
+ enum isl6423_curlim curlim;
+ u8 addr;
+ u8 mod_extern;
+};
+
+#if defined(CONFIG_DVB_ISL6423) || (defined(CONFIG_DVB_ISL6423_MODULE) && defined(MODULE))
+
+
+extern struct dvb_frontend *isl6423_attach(struct dvb_frontend *fe,
+ struct i2c_adapter *i2c,
+ const struct isl6423_config *config);
+
+#else
+static inline struct dvb_frontend *isl6423_attach(struct dvb_frontend *fe,
+ struct i2c_adapter *i2c,
+ const struct isl6423_config *config)
+{
+ printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+ return NULL;
+}
+
+#endif /* CONFIG_DVB_ISL6423 */
+
+#endif /* __ISL_6423_H */
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index a8429ebfa8a2..eac20650499f 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -879,7 +879,8 @@ static int nxt2002_init(struct dvb_frontend* fe)
/* request the firmware, this will block until someone uploads it */
printk("nxt2002: Waiting for firmware upload (%s)...\n", NXT2002_DEFAULT_FIRMWARE);
- ret = request_firmware(&fw, NXT2002_DEFAULT_FIRMWARE, &state->i2c->dev);
+ ret = request_firmware(&fw, NXT2002_DEFAULT_FIRMWARE,
+ state->i2c->dev.parent);
printk("nxt2002: Waiting for firmware upload(2)...\n");
if (ret) {
printk("nxt2002: No firmware uploaded (timeout or file not found?)\n");
@@ -943,7 +944,8 @@ static int nxt2004_init(struct dvb_frontend* fe)
/* request the firmware, this will block until someone uploads it */
printk("nxt2004: Waiting for firmware upload (%s)...\n", NXT2004_DEFAULT_FIRMWARE);
- ret = request_firmware(&fw, NXT2004_DEFAULT_FIRMWARE, &state->i2c->dev);
+ ret = request_firmware(&fw, NXT2004_DEFAULT_FIRMWARE,
+ state->i2c->dev.parent);
printk("nxt2004: Waiting for firmware upload(2)...\n");
if (ret) {
printk("nxt2004: No firmware uploaded (timeout or file not found?)\n");
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
index 5ed32544de39..8133ea3cddd7 100644
--- a/drivers/media/dvb/frontends/or51132.c
+++ b/drivers/media/dvb/frontends/or51132.c
@@ -340,7 +340,7 @@ static int or51132_set_parameters(struct dvb_frontend* fe,
}
printk("or51132: Waiting for firmware upload(%s)...\n",
fwname);
- ret = request_firmware(&fw, fwname, &state->i2c->dev);
+ ret = request_firmware(&fw, fwname, state->i2c->dev.parent);
if (ret) {
printk(KERN_WARNING "or51132: No firmware up"
"loaded(timeout or file not found?)\n");
diff --git a/drivers/media/dvb/frontends/stv0900_priv.h b/drivers/media/dvb/frontends/stv0900_priv.h
index 762d5af62d7a..67dc8ec634e2 100644
--- a/drivers/media/dvb/frontends/stv0900_priv.h
+++ b/drivers/media/dvb/frontends/stv0900_priv.h
@@ -60,8 +60,6 @@
} \
} while (0)
-#define dmd_choose(a, b) (demod = STV0900_DEMOD_2 ? b : a))
-
static int stvdebug;
#define dprintk(args...) \
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c
new file mode 100644
index 000000000000..96ef745a2e4e
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -0,0 +1,4299 @@
+/*
+ STV0900/0903 Multistandard Broadcast Frontend driver
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/mutex.h>
+
+#include <linux/dvb/frontend.h>
+#include "dvb_frontend.h"
+
+#include "stv6110x.h" /* for demodulator internal modes */
+
+#include "stv090x_reg.h"
+#include "stv090x.h"
+#include "stv090x_priv.h"
+
+static unsigned int verbose;
+module_param(verbose, int, 0644);
+
+struct mutex demod_lock;
+
+/* DVBS1 and DSS C/N Lookup table */
+static const struct stv090x_tab stv090x_s1cn_tab[] = {
+ { 0, 8917 }, /* 0.0dB */
+ { 5, 8801 }, /* 0.5dB */
+ { 10, 8667 }, /* 1.0dB */
+ { 15, 8522 }, /* 1.5dB */
+ { 20, 8355 }, /* 2.0dB */
+ { 25, 8175 }, /* 2.5dB */
+ { 30, 7979 }, /* 3.0dB */
+ { 35, 7763 }, /* 3.5dB */
+ { 40, 7530 }, /* 4.0dB */
+ { 45, 7282 }, /* 4.5dB */
+ { 50, 7026 }, /* 5.0dB */
+ { 55, 6781 }, /* 5.5dB */
+ { 60, 6514 }, /* 6.0dB */
+ { 65, 6241 }, /* 6.5dB */
+ { 70, 5965 }, /* 7.0dB */
+ { 75, 5690 }, /* 7.5dB */
+ { 80, 5424 }, /* 8.0dB */
+ { 85, 5161 }, /* 8.5dB */
+ { 90, 4902 }, /* 9.0dB */
+ { 95, 4654 }, /* 9.5dB */
+ { 100, 4417 }, /* 10.0dB */
+ { 105, 4186 }, /* 10.5dB */
+ { 110, 3968 }, /* 11.0dB */
+ { 115, 3757 }, /* 11.5dB */
+ { 120, 3558 }, /* 12.0dB */
+ { 125, 3366 }, /* 12.5dB */
+ { 130, 3185 }, /* 13.0dB */
+ { 135, 3012 }, /* 13.5dB */
+ { 140, 2850 }, /* 14.0dB */
+ { 145, 2698 }, /* 14.5dB */
+ { 150, 2550 }, /* 15.0dB */
+ { 160, 2283 }, /* 16.0dB */
+ { 170, 2042 }, /* 17.0dB */
+ { 180, 1827 }, /* 18.0dB */
+ { 190, 1636 }, /* 19.0dB */
+ { 200, 1466 }, /* 20.0dB */
+ { 210, 1315 }, /* 21.0dB */
+ { 220, 1181 }, /* 22.0dB */
+ { 230, 1064 }, /* 23.0dB */
+ { 240, 960 }, /* 24.0dB */
+ { 250, 869 }, /* 25.0dB */
+ { 260, 792 }, /* 26.0dB */
+ { 270, 724 }, /* 27.0dB */
+ { 280, 665 }, /* 28.0dB */
+ { 290, 616 }, /* 29.0dB */
+ { 300, 573 }, /* 30.0dB */
+ { 310, 537 }, /* 31.0dB */
+ { 320, 507 }, /* 32.0dB */
+ { 330, 483 }, /* 33.0dB */
+ { 400, 398 }, /* 40.0dB */
+ { 450, 381 }, /* 45.0dB */
+ { 500, 377 } /* 50.0dB */
+};
+
+/* DVBS2 C/N Lookup table */
+static const struct stv090x_tab stv090x_s2cn_tab[] = {
+ { -30, 13348 }, /* -3.0dB */
+ { -20, 12640 }, /* -2d.0B */
+ { -10, 11883 }, /* -1.0dB */
+ { 0, 11101 }, /* -0.0dB */
+ { 5, 10718 }, /* 0.5dB */
+ { 10, 10339 }, /* 1.0dB */
+ { 15, 9947 }, /* 1.5dB */
+ { 20, 9552 }, /* 2.0dB */
+ { 25, 9183 }, /* 2.5dB */
+ { 30, 8799 }, /* 3.0dB */
+ { 35, 8422 }, /* 3.5dB */
+ { 40, 8062 }, /* 4.0dB */
+ { 45, 7707 }, /* 4.5dB */
+ { 50, 7353 }, /* 5.0dB */
+ { 55, 7025 }, /* 5.5dB */
+ { 60, 6684 }, /* 6.0dB */
+ { 65, 6331 }, /* 6.5dB */
+ { 70, 6036 }, /* 7.0dB */
+ { 75, 5727 }, /* 7.5dB */
+ { 80, 5437 }, /* 8.0dB */
+ { 85, 5164 }, /* 8.5dB */
+ { 90, 4902 }, /* 9.0dB */
+ { 95, 4653 }, /* 9.5dB */
+ { 100, 4408 }, /* 10.0dB */
+ { 105, 4187 }, /* 10.5dB */
+ { 110, 3961 }, /* 11.0dB */
+ { 115, 3751 }, /* 11.5dB */
+ { 120, 3558 }, /* 12.0dB */
+ { 125, 3368 }, /* 12.5dB */
+ { 130, 3191 }, /* 13.0dB */
+ { 135, 3017 }, /* 13.5dB */
+ { 140, 2862 }, /* 14.0dB */
+ { 145, 2710 }, /* 14.5dB */
+ { 150, 2565 }, /* 15.0dB */
+ { 160, 2300 }, /* 16.0dB */
+ { 170, 2058 }, /* 17.0dB */
+ { 180, 1849 }, /* 18.0dB */
+ { 190, 1663 }, /* 19.0dB */
+ { 200, 1495 }, /* 20.0dB */
+ { 210, 1349 }, /* 21.0dB */
+ { 220, 1222 }, /* 22.0dB */
+ { 230, 1110 }, /* 23.0dB */
+ { 240, 1011 }, /* 24.0dB */
+ { 250, 925 }, /* 25.0dB */
+ { 260, 853 }, /* 26.0dB */
+ { 270, 789 }, /* 27.0dB */
+ { 280, 734 }, /* 28.0dB */
+ { 290, 690 }, /* 29.0dB */
+ { 300, 650 }, /* 30.0dB */
+ { 310, 619 }, /* 31.0dB */
+ { 320, 593 }, /* 32.0dB */
+ { 330, 571 }, /* 33.0dB */
+ { 400, 498 }, /* 40.0dB */
+ { 450, 484 }, /* 45.0dB */
+ { 500, 481 } /* 50.0dB */
+};
+
+/* RF level C/N lookup table */
+static const struct stv090x_tab stv090x_rf_tab[] = {
+ { -5, 0xcaa1 }, /* -5dBm */
+ { -10, 0xc229 }, /* -10dBm */
+ { -15, 0xbb08 }, /* -15dBm */
+ { -20, 0xb4bc }, /* -20dBm */
+ { -25, 0xad5a }, /* -25dBm */
+ { -30, 0xa298 }, /* -30dBm */
+ { -35, 0x98a8 }, /* -35dBm */
+ { -40, 0x8389 }, /* -40dBm */
+ { -45, 0x59be }, /* -45dBm */
+ { -50, 0x3a14 }, /* -50dBm */
+ { -55, 0x2d11 }, /* -55dBm */
+ { -60, 0x210d }, /* -60dBm */
+ { -65, 0xa14f }, /* -65dBm */
+ { -70, 0x07aa } /* -70dBm */
+};
+
+
+static struct stv090x_reg stv0900_initval[] = {
+
+ { STV090x_OUTCFG, 0x00 },
+ { STV090x_MODECFG, 0xff },
+ { STV090x_AGCRF1CFG, 0x11 },
+ { STV090x_AGCRF2CFG, 0x13 },
+ { STV090x_TSGENERAL1X, 0x14 },
+ { STV090x_TSTTNR2, 0x21 },
+ { STV090x_TSTTNR4, 0x21 },
+ { STV090x_P2_DISTXCTL, 0x22 },
+ { STV090x_P2_F22TX, 0xc0 },
+ { STV090x_P2_F22RX, 0xc0 },
+ { STV090x_P2_DISRXCTL, 0x00 },
+ { STV090x_P2_DMDCFGMD, 0xF9 },
+ { STV090x_P2_DEMOD, 0x08 },
+ { STV090x_P2_DMDCFG3, 0xc4 },
+ { STV090x_P2_CARFREQ, 0xed },
+ { STV090x_P2_LDT, 0xd0 },
+ { STV090x_P2_LDT2, 0xb8 },
+ { STV090x_P2_TMGCFG, 0xd2 },
+ { STV090x_P2_TMGTHRISE, 0x20 },
+ { STV090x_P1_TMGCFG, 0xd2 },
+
+ { STV090x_P2_TMGTHFALL, 0x00 },
+ { STV090x_P2_FECSPY, 0x88 },
+ { STV090x_P2_FSPYDATA, 0x3a },
+ { STV090x_P2_FBERCPT4, 0x00 },
+ { STV090x_P2_FSPYBER, 0x10 },
+ { STV090x_P2_ERRCTRL1, 0x35 },
+ { STV090x_P2_ERRCTRL2, 0xc1 },
+ { STV090x_P2_CFRICFG, 0xf8 },
+ { STV090x_P2_NOSCFG, 0x1c },
+ { STV090x_P2_DMDTOM, 0x20 },
+ { STV090x_P2_CORRELMANT, 0x70 },
+ { STV090x_P2_CORRELABS, 0x88 },
+ { STV090x_P2_AGC2O, 0x5b },
+ { STV090x_P2_AGC2REF, 0x38 },
+ { STV090x_P2_CARCFG, 0xe4 },
+ { STV090x_P2_ACLC, 0x1A },
+ { STV090x_P2_BCLC, 0x09 },
+ { STV090x_P2_CARHDR, 0x08 },
+ { STV090x_P2_KREFTMG, 0xc1 },
+ { STV090x_P2_SFRUPRATIO, 0xf0 },
+ { STV090x_P2_SFRLOWRATIO, 0x70 },
+ { STV090x_P2_SFRSTEP, 0x58 },
+ { STV090x_P2_TMGCFG2, 0x01 },
+ { STV090x_P2_CAR2CFG, 0x26 },
+ { STV090x_P2_BCLC2S2Q, 0x86 },
+ { STV090x_P2_BCLC2S28, 0x86 },
+ { STV090x_P2_SMAPCOEF7, 0x77 },
+ { STV090x_P2_SMAPCOEF6, 0x85 },
+ { STV090x_P2_SMAPCOEF5, 0x77 },
+ { STV090x_P2_TSCFGL, 0x20 },
+ { STV090x_P2_DMDCFG2, 0x3b },
+ { STV090x_P2_MODCODLST0, 0xff },
+ { STV090x_P2_MODCODLST1, 0xff },
+ { STV090x_P2_MODCODLST2, 0xff },
+ { STV090x_P2_MODCODLST3, 0xff },
+ { STV090x_P2_MODCODLST4, 0xff },
+ { STV090x_P2_MODCODLST5, 0xff },
+ { STV090x_P2_MODCODLST6, 0xff },
+ { STV090x_P2_MODCODLST7, 0xcc },
+ { STV090x_P2_MODCODLST8, 0xcc },
+ { STV090x_P2_MODCODLST9, 0xcc },
+ { STV090x_P2_MODCODLSTA, 0xcc },
+ { STV090x_P2_MODCODLSTB, 0xcc },
+ { STV090x_P2_MODCODLSTC, 0xcc },
+ { STV090x_P2_MODCODLSTD, 0xcc },
+ { STV090x_P2_MODCODLSTE, 0xcc },
+ { STV090x_P2_MODCODLSTF, 0xcf },
+ { STV090x_P1_DISTXCTL, 0x22 },
+ { STV090x_P1_F22TX, 0xc0 },
+ { STV090x_P1_F22RX, 0xc0 },
+ { STV090x_P1_DISRXCTL, 0x00 },
+ { STV090x_P1_DMDCFGMD, 0xf9 },
+ { STV090x_P1_DEMOD, 0x08 },
+ { STV090x_P1_DMDCFG3, 0xc4 },
+ { STV090x_P1_DMDTOM, 0x20 },
+ { STV090x_P1_CARFREQ, 0xed },
+ { STV090x_P1_LDT, 0xd0 },
+ { STV090x_P1_LDT2, 0xb8 },
+ { STV090x_P1_TMGCFG, 0xd2 },
+ { STV090x_P1_TMGTHRISE, 0x20 },
+ { STV090x_P1_TMGTHFALL, 0x00 },
+ { STV090x_P1_SFRUPRATIO, 0xf0 },
+ { STV090x_P1_SFRLOWRATIO, 0x70 },
+ { STV090x_P1_TSCFGL, 0x20 },
+ { STV090x_P1_FECSPY, 0x88 },
+ { STV090x_P1_FSPYDATA, 0x3a },
+ { STV090x_P1_FBERCPT4, 0x00 },
+ { STV090x_P1_FSPYBER, 0x10 },
+ { STV090x_P1_ERRCTRL1, 0x35 },
+ { STV090x_P1_ERRCTRL2, 0xc1 },
+ { STV090x_P1_CFRICFG, 0xf8 },
+ { STV090x_P1_NOSCFG, 0x1c },
+ { STV090x_P1_CORRELMANT, 0x70 },
+ { STV090x_P1_CORRELABS, 0x88 },
+ { STV090x_P1_AGC2O, 0x5b },
+ { STV090x_P1_AGC2REF, 0x38 },
+ { STV090x_P1_CARCFG, 0xe4 },
+ { STV090x_P1_ACLC, 0x1A },
+ { STV090x_P1_BCLC, 0x09 },
+ { STV090x_P1_CARHDR, 0x08 },
+ { STV090x_P1_KREFTMG, 0xc1 },
+ { STV090x_P1_SFRSTEP, 0x58 },
+ { STV090x_P1_TMGCFG2, 0x01 },
+ { STV090x_P1_CAR2CFG, 0x26 },
+ { STV090x_P1_BCLC2S2Q, 0x86 },
+ { STV090x_P1_BCLC2S28, 0x86 },
+ { STV090x_P1_SMAPCOEF7, 0x77 },
+ { STV090x_P1_SMAPCOEF6, 0x85 },
+ { STV090x_P1_SMAPCOEF5, 0x77 },
+ { STV090x_P1_DMDCFG2, 0x3b },
+ { STV090x_P1_MODCODLST0, 0xff },
+ { STV090x_P1_MODCODLST1, 0xff },
+ { STV090x_P1_MODCODLST2, 0xff },
+ { STV090x_P1_MODCODLST3, 0xff },
+ { STV090x_P1_MODCODLST4, 0xff },
+ { STV090x_P1_MODCODLST5, 0xff },
+ { STV090x_P1_MODCODLST6, 0xff },
+ { STV090x_P1_MODCODLST7, 0xcc },
+ { STV090x_P1_MODCODLST8, 0xcc },
+ { STV090x_P1_MODCODLST9, 0xcc },
+ { STV090x_P1_MODCODLSTA, 0xcc },
+ { STV090x_P1_MODCODLSTB, 0xcc },
+ { STV090x_P1_MODCODLSTC, 0xcc },
+ { STV090x_P1_MODCODLSTD, 0xcc },
+ { STV090x_P1_MODCODLSTE, 0xcc },
+ { STV090x_P1_MODCODLSTF, 0xcf },
+ { STV090x_GENCFG, 0x1d },
+ { STV090x_NBITER_NF4, 0x37 },
+ { STV090x_NBITER_NF5, 0x29 },
+ { STV090x_NBITER_NF6, 0x37 },
+ { STV090x_NBITER_NF7, 0x33 },
+ { STV090x_NBITER_NF8, 0x31 },
+ { STV090x_NBITER_NF9, 0x2f },
+ { STV090x_NBITER_NF10, 0x39 },
+ { STV090x_NBITER_NF11, 0x3a },
+ { STV090x_NBITER_NF12, 0x29 },
+ { STV090x_NBITER_NF13, 0x37 },
+ { STV090x_NBITER_NF14, 0x33 },
+ { STV090x_NBITER_NF15, 0x2f },
+ { STV090x_NBITER_NF16, 0x39 },
+ { STV090x_NBITER_NF17, 0x3a },
+ { STV090x_NBITERNOERR, 0x04 },
+ { STV090x_GAINLLR_NF4, 0x0C },
+ { STV090x_GAINLLR_NF5, 0x0F },
+ { STV090x_GAINLLR_NF6, 0x11 },
+ { STV090x_GAINLLR_NF7, 0x14 },
+ { STV090x_GAINLLR_NF8, 0x17 },
+ { STV090x_GAINLLR_NF9, 0x19 },
+ { STV090x_GAINLLR_NF10, 0x20 },
+ { STV090x_GAINLLR_NF11, 0x21 },
+ { STV090x_GAINLLR_NF12, 0x0D },
+ { STV090x_GAINLLR_NF13, 0x0F },
+ { STV090x_GAINLLR_NF14, 0x13 },
+ { STV090x_GAINLLR_NF15, 0x1A },
+ { STV090x_GAINLLR_NF16, 0x1F },
+ { STV090x_GAINLLR_NF17, 0x21 },
+ { STV090x_RCCFGH, 0x20 },
+ { STV090x_P1_FECM, 0x01 }, /* disable DSS modes */
+ { STV090x_P2_FECM, 0x01 }, /* disable DSS modes */
+ { STV090x_P1_PRVIT, 0x2F }, /* disable PR 6/7 */
+ { STV090x_P2_PRVIT, 0x2F }, /* disable PR 6/7 */
+};
+
+static struct stv090x_reg stv0903_initval[] = {
+ { STV090x_OUTCFG, 0x00 },
+ { STV090x_AGCRF1CFG, 0x11 },
+ { STV090x_STOPCLK1, 0x48 },
+ { STV090x_STOPCLK2, 0x14 },
+ { STV090x_TSTTNR1, 0x27 },
+ { STV090x_TSTTNR2, 0x21 },
+ { STV090x_P1_DISTXCTL, 0x22 },
+ { STV090x_P1_F22TX, 0xc0 },
+ { STV090x_P1_F22RX, 0xc0 },
+ { STV090x_P1_DISRXCTL, 0x00 },
+ { STV090x_P1_DMDCFGMD, 0xF9 },
+ { STV090x_P1_DEMOD, 0x08 },
+ { STV090x_P1_DMDCFG3, 0xc4 },
+ { STV090x_P1_CARFREQ, 0xed },
+ { STV090x_P1_TNRCFG2, 0x82 },
+ { STV090x_P1_LDT, 0xd0 },
+ { STV090x_P1_LDT2, 0xb8 },
+ { STV090x_P1_TMGCFG, 0xd2 },
+ { STV090x_P1_TMGTHRISE, 0x20 },
+ { STV090x_P1_TMGTHFALL, 0x00 },
+ { STV090x_P1_SFRUPRATIO, 0xf0 },
+ { STV090x_P1_SFRLOWRATIO, 0x70 },
+ { STV090x_P1_TSCFGL, 0x20 },
+ { STV090x_P1_FECSPY, 0x88 },
+ { STV090x_P1_FSPYDATA, 0x3a },
+ { STV090x_P1_FBERCPT4, 0x00 },
+ { STV090x_P1_FSPYBER, 0x10 },
+ { STV090x_P1_ERRCTRL1, 0x35 },
+ { STV090x_P1_ERRCTRL2, 0xc1 },
+ { STV090x_P1_CFRICFG, 0xf8 },
+ { STV090x_P1_NOSCFG, 0x1c },
+ { STV090x_P1_DMDTOM, 0x20 },
+ { STV090x_P1_CORRELMANT, 0x70 },
+ { STV090x_P1_CORRELABS, 0x88 },
+ { STV090x_P1_AGC2O, 0x5b },
+ { STV090x_P1_AGC2REF, 0x38 },
+ { STV090x_P1_CARCFG, 0xe4 },
+ { STV090x_P1_ACLC, 0x1A },
+ { STV090x_P1_BCLC, 0x09 },
+ { STV090x_P1_CARHDR, 0x08 },
+ { STV090x_P1_KREFTMG, 0xc1 },
+ { STV090x_P1_SFRSTEP, 0x58 },
+ { STV090x_P1_TMGCFG2, 0x01 },
+ { STV090x_P1_CAR2CFG, 0x26 },
+ { STV090x_P1_BCLC2S2Q, 0x86 },
+ { STV090x_P1_BCLC2S28, 0x86 },
+ { STV090x_P1_SMAPCOEF7, 0x77 },
+ { STV090x_P1_SMAPCOEF6, 0x85 },
+ { STV090x_P1_SMAPCOEF5, 0x77 },
+ { STV090x_P1_DMDCFG2, 0x3b },
+ { STV090x_P1_MODCODLST0, 0xff },
+ { STV090x_P1_MODCODLST1, 0xff },
+ { STV090x_P1_MODCODLST2, 0xff },
+ { STV090x_P1_MODCODLST3, 0xff },
+ { STV090x_P1_MODCODLST4, 0xff },
+ { STV090x_P1_MODCODLST5, 0xff },
+ { STV090x_P1_MODCODLST6, 0xff },
+ { STV090x_P1_MODCODLST7, 0xcc },
+ { STV090x_P1_MODCODLST8, 0xcc },
+ { STV090x_P1_MODCODLST9, 0xcc },
+ { STV090x_P1_MODCODLSTA, 0xcc },
+ { STV090x_P1_MODCODLSTB, 0xcc },
+ { STV090x_P1_MODCODLSTC, 0xcc },
+ { STV090x_P1_MODCODLSTD, 0xcc },
+ { STV090x_P1_MODCODLSTE, 0xcc },
+ { STV090x_P1_MODCODLSTF, 0xcf },
+ { STV090x_GENCFG, 0x1c },
+ { STV090x_NBITER_NF4, 0x37 },
+ { STV090x_NBITER_NF5, 0x29 },
+ { STV090x_NBITER_NF6, 0x37 },
+ { STV090x_NBITER_NF7, 0x33 },
+ { STV090x_NBITER_NF8, 0x31 },
+ { STV090x_NBITER_NF9, 0x2f },
+ { STV090x_NBITER_NF10, 0x39 },
+ { STV090x_NBITER_NF11, 0x3a },
+ { STV090x_NBITER_NF12, 0x29 },
+ { STV090x_NBITER_NF13, 0x37 },
+ { STV090x_NBITER_NF14, 0x33 },
+ { STV090x_NBITER_NF15, 0x2f },
+ { STV090x_NBITER_NF16, 0x39 },
+ { STV090x_NBITER_NF17, 0x3a },
+ { STV090x_NBITERNOERR, 0x04 },
+ { STV090x_GAINLLR_NF4, 0x0C },
+ { STV090x_GAINLLR_NF5, 0x0F },
+ { STV090x_GAINLLR_NF6, 0x11 },
+ { STV090x_GAINLLR_NF7, 0x14 },
+ { STV090x_GAINLLR_NF8, 0x17 },
+ { STV090x_GAINLLR_NF9, 0x19 },
+ { STV090x_GAINLLR_NF10, 0x20 },
+ { STV090x_GAINLLR_NF11, 0x21 },
+ { STV090x_GAINLLR_NF12, 0x0D },
+ { STV090x_GAINLLR_NF13, 0x0F },
+ { STV090x_GAINLLR_NF14, 0x13 },
+ { STV090x_GAINLLR_NF15, 0x1A },
+ { STV090x_GAINLLR_NF16, 0x1F },
+ { STV090x_GAINLLR_NF17, 0x21 },
+ { STV090x_RCCFGH, 0x20 },
+ { STV090x_P1_FECM, 0x01 }, /*disable the DSS mode */
+ { STV090x_P1_PRVIT, 0x2f } /*disable puncture rate 6/7*/
+};
+
+static struct stv090x_reg stv0900_cut20_val[] = {
+
+ { STV090x_P2_DMDCFG3, 0xe8 },
+ { STV090x_P2_DMDCFG4, 0x10 },
+ { STV090x_P2_CARFREQ, 0x38 },
+ { STV090x_P2_CARHDR, 0x20 },
+ { STV090x_P2_KREFTMG, 0x5a },
+ { STV090x_P2_SMAPCOEF7, 0x06 },
+ { STV090x_P2_SMAPCOEF6, 0x00 },
+ { STV090x_P2_SMAPCOEF5, 0x04 },
+ { STV090x_P2_NOSCFG, 0x0c },
+ { STV090x_P1_DMDCFG3, 0xe8 },
+ { STV090x_P1_DMDCFG4, 0x10 },
+ { STV090x_P1_CARFREQ, 0x38 },
+ { STV090x_P1_CARHDR, 0x20 },
+ { STV090x_P1_KREFTMG, 0x5a },
+ { STV090x_P1_SMAPCOEF7, 0x06 },
+ { STV090x_P1_SMAPCOEF6, 0x00 },
+ { STV090x_P1_SMAPCOEF5, 0x04 },
+ { STV090x_P1_NOSCFG, 0x0c },
+ { STV090x_GAINLLR_NF4, 0x21 },
+ { STV090x_GAINLLR_NF5, 0x21 },
+ { STV090x_GAINLLR_NF6, 0x20 },
+ { STV090x_GAINLLR_NF7, 0x1F },
+ { STV090x_GAINLLR_NF8, 0x1E },
+ { STV090x_GAINLLR_NF9, 0x1E },
+ { STV090x_GAINLLR_NF10, 0x1D },
+ { STV090x_GAINLLR_NF11, 0x1B },
+ { STV090x_GAINLLR_NF12, 0x20 },
+ { STV090x_GAINLLR_NF13, 0x20 },
+ { STV090x_GAINLLR_NF14, 0x20 },
+ { STV090x_GAINLLR_NF15, 0x20 },
+ { STV090x_GAINLLR_NF16, 0x20 },
+ { STV090x_GAINLLR_NF17, 0x21 },
+};
+
+static struct stv090x_reg stv0903_cut20_val[] = {
+ { STV090x_P1_DMDCFG3, 0xe8 },
+ { STV090x_P1_DMDCFG4, 0x10 },
+ { STV090x_P1_CARFREQ, 0x38 },
+ { STV090x_P1_CARHDR, 0x20 },
+ { STV090x_P1_KREFTMG, 0x5a },
+ { STV090x_P1_SMAPCOEF7, 0x06 },
+ { STV090x_P1_SMAPCOEF6, 0x00 },
+ { STV090x_P1_SMAPCOEF5, 0x04 },
+ { STV090x_P1_NOSCFG, 0x0c },
+ { STV090x_GAINLLR_NF4, 0x21 },
+ { STV090x_GAINLLR_NF5, 0x21 },
+ { STV090x_GAINLLR_NF6, 0x20 },
+ { STV090x_GAINLLR_NF7, 0x1F },
+ { STV090x_GAINLLR_NF8, 0x1E },
+ { STV090x_GAINLLR_NF9, 0x1E },
+ { STV090x_GAINLLR_NF10, 0x1D },
+ { STV090x_GAINLLR_NF11, 0x1B },
+ { STV090x_GAINLLR_NF12, 0x20 },
+ { STV090x_GAINLLR_NF13, 0x20 },
+ { STV090x_GAINLLR_NF14, 0x20 },
+ { STV090x_GAINLLR_NF15, 0x20 },
+ { STV090x_GAINLLR_NF16, 0x20 },
+ { STV090x_GAINLLR_NF17, 0x21 }
+};
+
+/* Cut 2.0 Long Frame Tracking CR loop */
+static struct stv090x_long_frame_crloop stv090x_s2_crl_cut20[] = {
+ /* MODCOD 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon 20MPoff 30MPon 30MPoff */
+ { STV090x_QPSK_12, 0x1f, 0x3f, 0x1e, 0x3f, 0x3d, 0x1f, 0x3d, 0x3e, 0x3d, 0x1e },
+ { STV090x_QPSK_35, 0x2f, 0x3f, 0x2e, 0x2f, 0x3d, 0x0f, 0x0e, 0x2e, 0x3d, 0x0e },
+ { STV090x_QPSK_23, 0x2f, 0x3f, 0x2e, 0x2f, 0x0e, 0x0f, 0x0e, 0x1e, 0x3d, 0x3d },
+ { STV090x_QPSK_34, 0x3f, 0x3f, 0x3e, 0x1f, 0x0e, 0x3e, 0x0e, 0x1e, 0x3d, 0x3d },
+ { STV090x_QPSK_45, 0x3f, 0x3f, 0x3e, 0x1f, 0x0e, 0x3e, 0x0e, 0x1e, 0x3d, 0x3d },
+ { STV090x_QPSK_56, 0x3f, 0x3f, 0x3e, 0x1f, 0x0e, 0x3e, 0x0e, 0x1e, 0x3d, 0x3d },
+ { STV090x_QPSK_89, 0x3f, 0x3f, 0x3e, 0x1f, 0x1e, 0x3e, 0x0e, 0x1e, 0x3d, 0x3d },
+ { STV090x_QPSK_910, 0x3f, 0x3f, 0x3e, 0x1f, 0x1e, 0x3e, 0x0e, 0x1e, 0x3d, 0x3d },
+ { STV090x_8PSK_35, 0x3c, 0x3e, 0x1c, 0x2e, 0x0c, 0x1e, 0x2b, 0x2d, 0x1b, 0x1d },
+ { STV090x_8PSK_23, 0x1d, 0x3e, 0x3c, 0x2e, 0x2c, 0x1e, 0x0c, 0x2d, 0x2b, 0x1d },
+ { STV090x_8PSK_34, 0x0e, 0x3e, 0x3d, 0x2e, 0x0d, 0x1e, 0x2c, 0x2d, 0x0c, 0x1d },
+ { STV090x_8PSK_56, 0x2e, 0x3e, 0x1e, 0x2e, 0x2d, 0x1e, 0x3c, 0x2d, 0x2c, 0x1d },
+ { STV090x_8PSK_89, 0x3e, 0x3e, 0x1e, 0x2e, 0x3d, 0x1e, 0x0d, 0x2d, 0x3c, 0x1d },
+ { STV090x_8PSK_910, 0x3e, 0x3e, 0x1e, 0x2e, 0x3d, 0x1e, 0x1d, 0x2d, 0x0d, 0x1d }
+};
+
+/* Cut 3.0 Long Frame Tracking CR loop */
+static struct stv090x_long_frame_crloop stv090x_s2_crl_cut30[] = {
+ /* MODCOD 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon 20MPoff 30MPon 30MPoff */
+ { STV090x_QPSK_12, 0x3c, 0x2c, 0x0c, 0x2c, 0x1b, 0x2c, 0x1b, 0x1c, 0x0b, 0x3b },
+ { STV090x_QPSK_35, 0x0d, 0x0d, 0x0c, 0x0d, 0x1b, 0x3c, 0x1b, 0x1c, 0x0b, 0x3b },
+ { STV090x_QPSK_23, 0x1d, 0x0d, 0x0c, 0x1d, 0x2b, 0x3c, 0x1b, 0x1c, 0x0b, 0x3b },
+ { STV090x_QPSK_34, 0x1d, 0x1d, 0x0c, 0x1d, 0x2b, 0x3c, 0x1b, 0x1c, 0x0b, 0x3b },
+ { STV090x_QPSK_45, 0x2d, 0x1d, 0x1c, 0x1d, 0x2b, 0x3c, 0x2b, 0x0c, 0x1b, 0x3b },
+ { STV090x_QPSK_56, 0x2d, 0x1d, 0x1c, 0x1d, 0x2b, 0x3c, 0x2b, 0x0c, 0x1b, 0x3b },
+ { STV090x_QPSK_89, 0x3d, 0x2d, 0x1c, 0x1d, 0x3b, 0x3c, 0x2b, 0x0c, 0x1b, 0x3b },
+ { STV090x_QPSK_910, 0x3d, 0x2d, 0x1c, 0x1d, 0x3b, 0x3c, 0x2b, 0x0c, 0x1b, 0x3b },
+ { STV090x_8PSK_35, 0x39, 0x29, 0x39, 0x19, 0x19, 0x19, 0x19, 0x19, 0x09, 0x19 },
+ { STV090x_8PSK_23, 0x2a, 0x39, 0x1a, 0x0a, 0x39, 0x0a, 0x29, 0x39, 0x29, 0x0a },
+ { STV090x_8PSK_34, 0x2b, 0x3a, 0x1b, 0x1b, 0x3a, 0x1b, 0x1a, 0x0b, 0x1a, 0x3a },
+ { STV090x_8PSK_56, 0x0c, 0x1b, 0x3b, 0x3b, 0x1b, 0x3b, 0x3a, 0x3b, 0x3a, 0x1b },
+ { STV090x_8PSK_89, 0x0d, 0x3c, 0x2c, 0x2c, 0x2b, 0x0c, 0x0b, 0x3b, 0x0b, 0x1b },
+ { STV090x_8PSK_910, 0x0d, 0x0d, 0x2c, 0x3c, 0x3b, 0x1c, 0x0b, 0x3b, 0x0b, 0x1b }
+};
+
+/* Cut 2.0 Long Frame Tracking CR Loop */
+static struct stv090x_long_frame_crloop stv090x_s2_apsk_crl_cut20[] = {
+ /* MODCOD 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon 20MPoff 30MPon 30MPoff */
+ { STV090x_16APSK_23, 0x0c, 0x0c, 0x0c, 0x0c, 0x1d, 0x0c, 0x3c, 0x0c, 0x2c, 0x0c },
+ { STV090x_16APSK_34, 0x0c, 0x0c, 0x0c, 0x0c, 0x0e, 0x0c, 0x2d, 0x0c, 0x1d, 0x0c },
+ { STV090x_16APSK_45, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x0c, 0x3d, 0x0c, 0x2d, 0x0c },
+ { STV090x_16APSK_56, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x0c, 0x3d, 0x0c, 0x2d, 0x0c },
+ { STV090x_16APSK_89, 0x0c, 0x0c, 0x0c, 0x0c, 0x2e, 0x0c, 0x0e, 0x0c, 0x3d, 0x0c },
+ { STV090x_16APSK_910, 0x0c, 0x0c, 0x0c, 0x0c, 0x2e, 0x0c, 0x0e, 0x0c, 0x3d, 0x0c },
+ { STV090x_32APSK_34, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c },
+ { STV090x_32APSK_45, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c },
+ { STV090x_32APSK_56, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c },
+ { STV090x_32APSK_89, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c },
+ { STV090x_32APSK_910, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c }
+};
+
+/* Cut 3.0 Long Frame Tracking CR Loop */
+static struct stv090x_long_frame_crloop stv090x_s2_apsk_crl_cut30[] = {
+ /* MODCOD 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon 20MPoff 30MPon 30MPoff */
+ { STV090x_16APSK_23, 0x0a, 0x0a, 0x0a, 0x0a, 0x1a, 0x0a, 0x3a, 0x0a, 0x2a, 0x0a },
+ { STV090x_16APSK_34, 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x0a, 0x3b, 0x0a, 0x1b, 0x0a },
+ { STV090x_16APSK_45, 0x0a, 0x0a, 0x0a, 0x0a, 0x1b, 0x0a, 0x3b, 0x0a, 0x2b, 0x0a },
+ { STV090x_16APSK_56, 0x0a, 0x0a, 0x0a, 0x0a, 0x1b, 0x0a, 0x3b, 0x0a, 0x2b, 0x0a },
+ { STV090x_16APSK_89, 0x0a, 0x0a, 0x0a, 0x0a, 0x2b, 0x0a, 0x0c, 0x0a, 0x3b, 0x0a },
+ { STV090x_16APSK_910, 0x0a, 0x0a, 0x0a, 0x0a, 0x2b, 0x0a, 0x0c, 0x0a, 0x3b, 0x0a },
+ { STV090x_32APSK_34, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a },
+ { STV090x_32APSK_45, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a },
+ { STV090x_32APSK_56, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a },
+ { STV090x_32APSK_89, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a },
+ { STV090x_32APSK_910, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a }
+};
+
+static struct stv090x_long_frame_crloop stv090x_s2_lowqpsk_crl_cut20[] = {
+ /* MODCOD 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon 20MPoff 30MPon 30MPoff */
+ { STV090x_QPSK_14, 0x0f, 0x3f, 0x0e, 0x3f, 0x2d, 0x2f, 0x2d, 0x1f, 0x3d, 0x3e },
+ { STV090x_QPSK_13, 0x0f, 0x3f, 0x0e, 0x3f, 0x2d, 0x2f, 0x3d, 0x0f, 0x3d, 0x2e },
+ { STV090x_QPSK_25, 0x1f, 0x3f, 0x1e, 0x3f, 0x3d, 0x1f, 0x3d, 0x3e, 0x3d, 0x2e }
+};
+
+static struct stv090x_long_frame_crloop stv090x_s2_lowqpsk_crl_cut30[] = {
+ /* MODCOD 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon 20MPoff 30MPon 30MPoff */
+ { STV090x_QPSK_14, 0x0c, 0x3c, 0x0b, 0x3c, 0x2a, 0x2c, 0x2a, 0x1c, 0x3a, 0x3b },
+ { STV090x_QPSK_13, 0x0c, 0x3c, 0x0b, 0x3c, 0x2a, 0x2c, 0x3a, 0x0c, 0x3a, 0x2b },
+ { STV090x_QPSK_25, 0x1c, 0x3c, 0x1b, 0x3c, 0x3a, 0x1c, 0x3a, 0x3b, 0x3a, 0x2b }
+};
+
+/* Cut 2.0 Short Frame Tracking CR Loop */
+static struct stv090x_short_frame_crloop stv090x_s2_short_crl_cut20[] = {
+ /* MODCOD 2M 5M 10M 20M 30M */
+ { STV090x_QPSK, 0x2f, 0x2e, 0x0e, 0x0e, 0x3d },
+ { STV090x_8PSK, 0x3e, 0x0e, 0x2d, 0x0d, 0x3c },
+ { STV090x_16APSK, 0x1e, 0x1e, 0x1e, 0x3d, 0x2d },
+ { STV090x_32APSK, 0x1e, 0x1e, 0x1e, 0x3d, 0x2d }
+};
+
+/* Cut 3.0 Short Frame Tracking CR Loop */
+static struct stv090x_short_frame_crloop stv090x_s2_short_crl_cut30[] = {
+ /* MODCOD 2M 5M 10M 20M 30M */
+ { STV090x_QPSK, 0x2C, 0x2B, 0x0B, 0x0B, 0x3A },
+ { STV090x_8PSK, 0x3B, 0x0B, 0x2A, 0x0A, 0x39 },
+ { STV090x_16APSK, 0x1B, 0x1B, 0x1B, 0x3A, 0x2A },
+ { STV090x_32APSK, 0x1B, 0x1B, 0x1B, 0x3A, 0x2A }
+};
+
+static inline s32 comp2(s32 __x, s32 __width)
+{
+ if (__width == 32)
+ return __x;
+ else
+ return (__x >= (1 << (__width - 1))) ? (__x - (1 << __width)) : __x;
+}
+
+static int stv090x_read_reg(struct stv090x_state *state, unsigned int reg)
+{
+ const struct stv090x_config *config = state->config;
+ int ret;
+
+ u8 b0[] = { reg >> 8, reg & 0xff };
+ u8 buf;
+
+ struct i2c_msg msg[] = {
+ { .addr = config->address, .flags = 0, .buf = b0, .len = 2 },
+ { .addr = config->address, .flags = I2C_M_RD, .buf = &buf, .len = 1 }
+ };
+
+ ret = i2c_transfer(state->i2c, msg, 2);
+ if (ret != 2) {
+ if (ret != -ERESTARTSYS)
+ dprintk(FE_ERROR, 1,
+ "Read error, Reg=[0x%02x], Status=%d",
+ reg, ret);
+
+ return ret < 0 ? ret : -EREMOTEIO;
+ }
+ if (unlikely(*state->verbose >= FE_DEBUGREG))
+ dprintk(FE_ERROR, 1, "Reg=[0x%02x], data=%02x",
+ reg, buf);
+
+ return (unsigned int) buf;
+}
+
+static int stv090x_write_regs(struct stv090x_state *state, unsigned int reg, u8 *data, u32 count)
+{
+ const struct stv090x_config *config = state->config;
+ int ret;
+ u8 buf[2 + count];
+ struct i2c_msg i2c_msg = { .addr = config->address, .flags = 0, .buf = buf, .len = 2 + count };
+
+ buf[0] = reg >> 8;
+ buf[1] = reg & 0xff;
+ memcpy(&buf[2], data, count);
+
+ if (unlikely(*state->verbose >= FE_DEBUGREG)) {
+ int i;
+
+ printk(KERN_DEBUG "%s [0x%04x]:", __func__, reg);
+ for (i = 0; i < count; i++)
+ printk(" %02x", data[i]);
+ printk("\n");
+ }
+
+ ret = i2c_transfer(state->i2c, &i2c_msg, 1);
+ if (ret != 1) {
+ if (ret != -ERESTARTSYS)
+ dprintk(FE_ERROR, 1, "Reg=[0x%04x], Data=[0x%02x ...], Count=%u, Status=%d",
+ reg, data[0], count, ret);
+ return ret < 0 ? ret : -EREMOTEIO;
+ }
+
+ return 0;
+}
+
+static int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 data)
+{
+ return stv090x_write_regs(state, reg, &data, 1);
+}
+
+static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg;
+
+ reg = STV090x_READ_DEMOD(state, I2CRPT);
+ if (enable) {
+ dprintk(FE_DEBUG, 1, "Enable Gate");
+ STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, I2CRPT, reg) < 0)
+ goto err;
+
+ } else {
+ dprintk(FE_DEBUG, 1, "Disable Gate");
+ STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, 0);
+ if ((STV090x_WRITE_DEMOD(state, I2CRPT, reg)) < 0)
+ goto err;
+ }
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static void stv090x_get_lock_tmg(struct stv090x_state *state)
+{
+ switch (state->algo) {
+ case STV090x_BLIND_SEARCH:
+ dprintk(FE_DEBUG, 1, "Blind Search");
+ if (state->srate <= 1500000) { /*10Msps< SR <=15Msps*/
+ state->DemodTimeout = 1500;
+ state->FecTimeout = 400;
+ } else if (state->srate <= 5000000) { /*10Msps< SR <=15Msps*/
+ state->DemodTimeout = 1000;
+ state->FecTimeout = 300;
+ } else { /*SR >20Msps*/
+ state->DemodTimeout = 700;
+ state->FecTimeout = 100;
+ }
+ break;
+
+ case STV090x_COLD_SEARCH:
+ case STV090x_WARM_SEARCH:
+ default:
+ dprintk(FE_DEBUG, 1, "Normal Search");
+ if (state->srate <= 1000000) { /*SR <=1Msps*/
+ state->DemodTimeout = 4500;
+ state->FecTimeout = 1700;
+ } else if (state->srate <= 2000000) { /*1Msps < SR <= 2Msps */
+ state->DemodTimeout = 2500;
+ state->FecTimeout = 1100;
+ } else if (state->srate <= 5000000) { /*2Msps < SR <= 5Msps */
+ state->DemodTimeout = 1000;
+ state->FecTimeout = 550;
+ } else if (state->srate <= 10000000) { /*5Msps < SR <= 10Msps */
+ state->DemodTimeout = 700;
+ state->FecTimeout = 250;
+ } else if (state->srate <= 20000000) { /*10Msps < SR <= 20Msps */
+ state->DemodTimeout = 400;
+ state->FecTimeout = 130;
+ } else { /*SR >20Msps*/
+ state->DemodTimeout = 300;
+ state->FecTimeout = 100;
+ }
+ break;
+ }
+
+ if (state->algo == STV090x_WARM_SEARCH)
+ state->DemodTimeout /= 2;
+}
+
+static int stv090x_set_srate(struct stv090x_state *state, u32 srate)
+{
+ u32 sym;
+
+ if (srate > 60000000) {
+ sym = (srate << 4); /* SR * 2^16 / master_clk */
+ sym /= (state->mclk >> 12);
+ } else if (srate > 6000000) {
+ sym = (srate << 6);
+ sym /= (state->mclk >> 10);
+ } else {
+ sym = (srate << 9);
+ sym /= (state->mclk >> 7);
+ }
+
+ if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0x7f) < 0) /* MSB */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRINIT0, (sym & 0xff)) < 0) /* LSB */
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_set_max_srate(struct stv090x_state *state, u32 clk, u32 srate)
+{
+ u32 sym;
+
+ srate = 105 * (srate / 100);
+ if (srate > 60000000) {
+ sym = (srate << 4); /* SR * 2^16 / master_clk */
+ sym /= (state->mclk >> 12);
+ } else if (srate > 6000000) {
+ sym = (srate << 6);
+ sym /= (state->mclk >> 10);
+ } else {
+ sym = (srate << 9);
+ sym /= (state->mclk >> 7);
+ }
+
+ if (sym < 0x7fff) {
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0) /* MSB */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0) /* LSB */
+ goto err;
+ } else {
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, 0x7f) < 0) /* MSB */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRUP0, 0xff) < 0) /* LSB */
+ goto err;
+ }
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_set_min_srate(struct stv090x_state *state, u32 clk, u32 srate)
+{
+ u32 sym;
+
+ srate = 95 * (srate / 100);
+ if (srate > 60000000) {
+ sym = (srate << 4); /* SR * 2^16 / master_clk */
+ sym /= (state->mclk >> 12);
+ } else if (srate > 6000000) {
+ sym = (srate << 6);
+ sym /= (state->mclk >> 10);
+ } else {
+ sym = (srate << 9);
+ sym /= (state->mclk >> 7);
+ }
+
+ if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0xff)) < 0) /* MSB */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */
+ goto err;
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static u32 stv090x_car_width(u32 srate, enum stv090x_rolloff rolloff)
+{
+ u32 ro;
+
+ switch (rolloff) {
+ case STV090x_RO_20:
+ ro = 20;
+ break;
+ case STV090x_RO_25:
+ ro = 25;
+ break;
+ case STV090x_RO_35:
+ default:
+ ro = 35;
+ break;
+ }
+
+ return srate + (srate * ro) / 100;
+}
+
+static int stv090x_set_vit_thacq(struct stv090x_state *state)
+{
+ if (STV090x_WRITE_DEMOD(state, VTH12, 0x96) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH23, 0x64) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH34, 0x36) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH56, 0x23) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH67, 0x1e) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH78, 0x19) < 0)
+ goto err;
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_set_vit_thtracq(struct stv090x_state *state)
+{
+ if (STV090x_WRITE_DEMOD(state, VTH12, 0xd0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH23, 0x7d) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH34, 0x53) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH56, 0x2f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH67, 0x24) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VTH78, 0x1f) < 0)
+ goto err;
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_set_viterbi(struct stv090x_state *state)
+{
+ switch (state->search_mode) {
+ case STV090x_SEARCH_AUTO:
+ if (STV090x_WRITE_DEMOD(state, FECM, 0x10) < 0) /* DVB-S and DVB-S2 */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x3f) < 0) /* all puncture rate */
+ goto err;
+ break;
+ case STV090x_SEARCH_DVBS1:
+ if (STV090x_WRITE_DEMOD(state, FECM, 0x00) < 0) /* disable DSS */
+ goto err;
+ switch (state->fec) {
+ case STV090x_PR12:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x01) < 0)
+ goto err;
+ break;
+
+ case STV090x_PR23:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x02) < 0)
+ goto err;
+ break;
+
+ case STV090x_PR34:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x04) < 0)
+ goto err;
+ break;
+
+ case STV090x_PR56:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x08) < 0)
+ goto err;
+ break;
+
+ case STV090x_PR78:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x20) < 0)
+ goto err;
+ break;
+
+ default:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x2f) < 0) /* all */
+ goto err;
+ break;
+ }
+ break;
+ case STV090x_SEARCH_DSS:
+ if (STV090x_WRITE_DEMOD(state, FECM, 0x80) < 0)
+ goto err;
+ switch (state->fec) {
+ case STV090x_PR12:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x01) < 0)
+ goto err;
+ break;
+
+ case STV090x_PR23:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x02) < 0)
+ goto err;
+ break;
+
+ case STV090x_PR67:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x10) < 0)
+ goto err;
+ break;
+
+ default:
+ if (STV090x_WRITE_DEMOD(state, PRVIT, 0x13) < 0) /* 1/2, 2/3, 6/7 */
+ goto err;
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_stop_modcod(struct stv090x_state *state)
+{
+ if (STV090x_WRITE_DEMOD(state, MODCODLST0, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST1, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST2, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST3, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST4, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST5, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST6, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST7, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST8, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST9, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTA, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTB, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTC, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTD, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTE, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTF, 0xff) < 0)
+ goto err;
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_activate_modcod(struct stv090x_state *state)
+{
+ if (STV090x_WRITE_DEMOD(state, MODCODLST0, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST1, 0xfc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST2, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST3, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST4, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST5, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST6, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST7, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST8, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST9, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTA, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTB, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTC, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTD, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTE, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTF, 0xcf) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_activate_modcod_single(struct stv090x_state *state)
+{
+
+ if (STV090x_WRITE_DEMOD(state, MODCODLST0, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST1, 0xf0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST2, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST3, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST4, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST5, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST6, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST7, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST8, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST9, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTA, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTB, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTC, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTD, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTE, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTF, 0x0f) < 0)
+ goto err;
+
+ return 0;
+
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_vitclk_ctl(struct stv090x_state *state, int enable)
+{
+ u32 reg;
+
+ switch (state->demod) {
+ case STV090x_DEMODULATOR_0:
+ mutex_lock(&demod_lock);
+ reg = stv090x_read_reg(state, STV090x_STOPCLK2);
+ STV090x_SETFIELD(reg, STOP_CLKVIT1_FIELD, enable);
+ if (stv090x_write_reg(state, STV090x_STOPCLK2, reg) < 0)
+ goto err;
+ mutex_unlock(&demod_lock);
+ break;
+
+ case STV090x_DEMODULATOR_1:
+ mutex_lock(&demod_lock);
+ reg = stv090x_read_reg(state, STV090x_STOPCLK2);
+ STV090x_SETFIELD(reg, STOP_CLKVIT2_FIELD, enable);
+ if (stv090x_write_reg(state, STV090x_STOPCLK2, reg) < 0)
+ goto err;
+ mutex_unlock(&demod_lock);
+ break;
+
+ default:
+ dprintk(FE_ERROR, 1, "Wrong demodulator!");
+ break;
+ }
+ return 0;
+err:
+ mutex_unlock(&demod_lock);
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_dvbs_track_crl(struct stv090x_state *state)
+{
+ if (state->dev_ver >= 0x30) {
+ /* Set ACLC BCLC optimised value vs SR */
+ if (state->srate >= 15000000) {
+ if (STV090x_WRITE_DEMOD(state, ACLC, 0x2b) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, BCLC, 0x1a) < 0)
+ goto err;
+ } else if ((state->srate >= 7000000) && (15000000 > state->srate)) {
+ if (STV090x_WRITE_DEMOD(state, ACLC, 0x0c) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, BCLC, 0x1b) < 0)
+ goto err;
+ } else if (state->srate < 7000000) {
+ if (STV090x_WRITE_DEMOD(state, ACLC, 0x2c) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, BCLC, 0x1c) < 0)
+ goto err;
+ }
+
+ } else {
+ /* Cut 2.0 */
+ if (STV090x_WRITE_DEMOD(state, ACLC, 0x1a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, BCLC, 0x09) < 0)
+ goto err;
+ }
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_delivery_search(struct stv090x_state *state)
+{
+ u32 reg;
+
+ switch (state->search_mode) {
+ case STV090x_SEARCH_DVBS1:
+ case STV090x_SEARCH_DSS:
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+
+ /* Activate Viterbi decoder in legacy search,
+ * do not use FRESVIT1, might impact VITERBI2
+ */
+ if (stv090x_vitclk_ctl(state, 0) < 0)
+ goto err;
+
+ if (stv090x_dvbs_track_crl(state) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, CAR2CFG, 0x22) < 0) /* disable DVB-S2 */
+ goto err;
+
+ if (stv090x_set_vit_thacq(state) < 0)
+ goto err;
+ if (stv090x_set_viterbi(state) < 0)
+ goto err;
+ break;
+
+ case STV090x_SEARCH_DVBS2:
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+
+ if (stv090x_vitclk_ctl(state, 1) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, ACLC, 0x1a) < 0) /* stop DVB-S CR loop */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, BCLC, 0x09) < 0)
+ goto err;
+
+ if (state->dev_ver <= 0x20) {
+ /* enable S2 carrier loop */
+ if (STV090x_WRITE_DEMOD(state, CAR2CFG, 0x26) < 0)
+ goto err;
+ } else {
+ /* > Cut 3: Stop carrier 3 */
+ if (STV090x_WRITE_DEMOD(state, CAR2CFG, 0x66) < 0)
+ goto err;
+ }
+
+ if (state->demod_mode != STV090x_SINGLE) {
+ /* Cut 2: enable link during search */
+ if (stv090x_activate_modcod(state) < 0)
+ goto err;
+ } else {
+ /* Single demodulator
+ * Authorize SHORT and LONG frames,
+ * QPSK, 8PSK, 16APSK and 32APSK
+ */
+ if (stv090x_activate_modcod_single(state) < 0)
+ goto err;
+ }
+
+ break;
+
+ case STV090x_SEARCH_AUTO:
+ default:
+ /* enable DVB-S2 and DVB-S2 in Auto MODE */
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+
+ if (stv090x_vitclk_ctl(state, 0) < 0)
+ goto err;
+
+ if (stv090x_dvbs_track_crl(state) < 0)
+ goto err;
+
+ if (state->dev_ver <= 0x20) {
+ /* enable S2 carrier loop */
+ if (STV090x_WRITE_DEMOD(state, CAR2CFG, 0x26) < 0)
+ goto err;
+ } else {
+ /* > Cut 3: Stop carrier 3 */
+ if (STV090x_WRITE_DEMOD(state, CAR2CFG, 0x66) < 0)
+ goto err;
+ }
+
+ if (state->demod_mode != STV090x_SINGLE) {
+ /* Cut 2: enable link during search */
+ if (stv090x_activate_modcod(state) < 0)
+ goto err;
+ } else {
+ /* Single demodulator
+ * Authorize SHORT and LONG frames,
+ * QPSK, 8PSK, 16APSK and 32APSK
+ */
+ if (stv090x_activate_modcod_single(state) < 0)
+ goto err;
+ }
+
+ if (state->srate >= 2000000) {
+ /* Srate >= 2MSPS, Viterbi threshold to acquire */
+ if (stv090x_set_vit_thacq(state) < 0)
+ goto err;
+ } else {
+ /* Srate < 2MSPS, Reset Viterbi thresholdto track
+ * and then re-acquire
+ */
+ if (stv090x_set_vit_thtracq(state) < 0)
+ goto err;
+ }
+
+ if (stv090x_set_viterbi(state) < 0)
+ goto err;
+ break;
+ }
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_start_search(struct stv090x_state *state)
+{
+ u32 reg, freq_abs;
+ s16 freq;
+
+ /* Reset demodulator */
+ reg = STV090x_READ_DEMOD(state, DMDISTATE);
+ STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f);
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, reg) < 0)
+ goto err;
+
+ if (state->dev_ver <= 0x20) {
+ if (state->srate <= 5000000) {
+ if (STV090x_WRITE_DEMOD(state, CARCFG, 0x44) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRUP1, 0x0f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRUP1, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRLOW1, 0xf0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRLOW0, 0x00) < 0)
+ goto err;
+
+ /*enlarge the timing bandwith for Low SR*/
+ if (STV090x_WRITE_DEMOD(state, RTCS2, 0x68) < 0)
+ goto err;
+ } else {
+ /* If the symbol rate is >5 Msps
+ Set The carrier search up and low to auto mode */
+ if (STV090x_WRITE_DEMOD(state, CARCFG, 0xc4) < 0)
+ goto err;
+ /*reduce the timing bandwith for high SR*/
+ if (STV090x_WRITE_DEMOD(state, RTCS2, 0x44) < 0)
+ goto err;
+ }
+ } else {
+ /* >= Cut 3 */
+ if (state->srate <= 5000000) {
+ /* enlarge the timing bandwith for Low SR */
+ STV090x_WRITE_DEMOD(state, RTCS2, 0x68);
+ } else {
+ /* reduce timing bandwith for high SR */
+ STV090x_WRITE_DEMOD(state, RTCS2, 0x44);
+ }
+
+ /* Set CFR min and max to manual mode */
+ STV090x_WRITE_DEMOD(state, CARCFG, 0x46);
+
+ if (state->algo == STV090x_WARM_SEARCH) {
+ /* WARM Start
+ * CFR min = -1MHz,
+ * CFR max = +1MHz
+ */
+ freq_abs = 1000 << 16;
+ freq_abs /= (state->mclk / 1000);
+ freq = (s16) freq_abs;
+ } else {
+ /* COLD Start
+ * CFR min =- (SearchRange / 2 + 600KHz)
+ * CFR max = +(SearchRange / 2 + 600KHz)
+ * (600KHz for the tuner step size)
+ */
+ freq_abs = (state->search_range / 2000) + 600;
+ freq_abs = freq_abs << 16;
+ freq_abs /= (state->mclk / 1000);
+ freq = (s16) freq_abs;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, CFRUP1, MSB(freq)) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRUP1, LSB(freq)) < 0)
+ goto err;
+
+ freq *= -1;
+
+ if (STV090x_WRITE_DEMOD(state, CFRLOW1, MSB(freq)) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRLOW0, LSB(freq)) < 0)
+ goto err;
+
+ }
+
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, EQUALCFG, 0x41) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, FFECFG, 0x41) < 0)
+ goto err;
+
+ if ((state->search_mode == STV090x_DVBS1) ||
+ (state->search_mode == STV090x_DSS) ||
+ (state->search_mode == STV090x_SEARCH_AUTO)) {
+
+ if (STV090x_WRITE_DEMOD(state, VITSCALE, 0x82) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VAVSRVIT, 0x00) < 0)
+ goto err;
+ }
+ }
+
+ if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0xe0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0xc0) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 0);
+ STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ reg = STV090x_READ_DEMOD(state, DMDCFG2);
+ STV090x_SETFIELD_Px(reg, S1S2_SEQUENTIAL_FIELD, 0x0);
+ if (STV090x_WRITE_DEMOD(state, DMDCFG2, reg) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x20) {
+ /*Frequency offset detector setting*/
+ if (state->srate < 2000000) {
+ if (state->dev_ver <= 0x20) {
+ /* Cut 2 */
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x39) < 0)
+ goto err;
+ } else {
+ /* Cut 2 */
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x89) < 0)
+ goto err;
+ }
+ if (STV090x_WRITE_DEMOD(state, CARHDR, 0x40) < 0)
+ goto err;
+ }
+
+ if (state->srate < 10000000) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4c) < 0)
+ goto err;
+ } else {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4b) < 0)
+ goto err;
+ }
+ } else {
+ if (state->srate < 10000000) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0xef) < 0)
+ goto err;
+ } else {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0xed) < 0)
+ goto err;
+ }
+ }
+
+ switch (state->algo) {
+ case STV090x_WARM_SEARCH:
+ /* The symbol rate and the exact
+ * carrier Frequency are known
+ */
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x18) < 0)
+ goto err;
+ break;
+
+ case STV090x_COLD_SEARCH:
+ /* The symbol rate is known */
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
+ goto err;
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_get_agc2_min_level(struct stv090x_state *state)
+{
+ u32 agc2_min = 0, agc2 = 0, freq_init, freq_step, reg;
+ s32 i, j, steps, dir;
+
+ if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
+ goto err;
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, 0x83) < 0) /* SR = 65 Msps Max */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRUP0, 0xc0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW1, 0x82) < 0) /* SR= 400 ksps Min */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW0, 0xa0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0) /* stop acq @ coarse carrier state */
+ goto err;
+ if (stv090x_set_srate(state, 1000000) < 0)
+ goto err;
+
+ steps = -1 + state->search_range / 1000000;
+ steps /= 2;
+ steps = (2 * steps) + 1;
+ if (steps < 0)
+ steps = 1;
+
+ dir = 1;
+ freq_step = (1000000 * 256) / (state->mclk / 256);
+ freq_init = 0;
+
+ for (i = 0; i < steps; i++) {
+ if (dir > 0)
+ freq_init = freq_init + (freq_step * i);
+ else
+ freq_init = freq_init - (freq_step * i);
+
+ dir = -1;
+
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c) < 0) /* Demod RESET */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, (freq_init >> 8) & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, freq_init & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */
+ goto err;
+ msleep(10);
+ for (j = 0; j < 10; j++) {
+ agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8;
+ agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
+ }
+ agc2 /= 10;
+ agc2_min = 0xffff;
+ if (agc2 < 0xffff)
+ agc2_min = agc2;
+ }
+
+ return agc2_min;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static u32 stv090x_get_srate(struct stv090x_state *state, u32 clk)
+{
+ u8 r3, r2, r1, r0;
+ s32 srate, int_1, int_2, tmp_1, tmp_2;
+
+ r3 = STV090x_READ_DEMOD(state, SFR3);
+ r2 = STV090x_READ_DEMOD(state, SFR2);
+ r1 = STV090x_READ_DEMOD(state, SFR1);
+ r0 = STV090x_READ_DEMOD(state, SFR0);
+
+ srate = ((r3 << 24) | (r2 << 16) | (r1 << 8) | r0);
+
+ int_1 = clk >> 16;
+ int_2 = srate >> 16;
+
+ tmp_1 = clk % 0x10000;
+ tmp_2 = srate % 0x10000;
+
+ srate = (int_1 * int_2) +
+ ((int_1 * tmp_2) >> 16) +
+ ((int_2 * tmp_1) >> 16);
+
+ return srate;
+}
+
+static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
+{
+ struct dvb_frontend *fe = &state->frontend;
+
+ int tmg_lock = 0, i;
+ s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq;
+ u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg;
+
+ reg = STV090x_READ_DEMOD(state, DMDISTATE);
+ STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, reg) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGCFG, 0x12) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0xf0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0xe0) < 0)
+ goto err;
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, 0x83) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRUP0, 0xc0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW1, 0x82) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW0, 0xa0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x60) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x30) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x99) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x95) < 0)
+ goto err;
+
+ } else if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x6a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x95) < 0)
+ goto err;
+ }
+
+ if (state->srate <= 2000000)
+ car_step = 1000;
+ else if (state->srate <= 5000000)
+ car_step = 2000;
+ else if (state->srate <= 12000000)
+ car_step = 3000;
+ else
+ car_step = 5000;
+
+ steps = -1 + ((state->search_range / 1000) / car_step);
+ steps /= 2;
+ steps = (2 * steps) + 1;
+ if (steps < 0)
+ steps = 1;
+ else if (steps > 10) {
+ steps = 11;
+ car_step = (state->search_range / 1000) / 10;
+ }
+ cur_step = 0;
+ dir = 1;
+ freq = state->frequency;
+
+ while ((!tmg_lock) && (cur_step < steps)) {
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5f) < 0) /* Demod RESET */
+ goto err;
+ reg = STV090x_READ_DEMOD(state, DMDISTATE);
+ STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x00); /* trigger acquisition */
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, reg) < 0)
+ goto err;
+ msleep(50);
+ for (i = 0; i < 10; i++) {
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2)
+ tmg_cpt++;
+ agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8;
+ agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
+ }
+ agc2 /= 10;
+ srate_coarse = stv090x_get_srate(state, state->mclk);
+ cur_step++;
+ dir *= -1;
+ if ((tmg_cpt >= 5) && (agc2 < 0x1f00) && (srate_coarse < 55000000) && (srate_coarse > 850000))
+ tmg_lock = 1;
+ else if (cur_step < steps) {
+ if (dir > 0)
+ freq += cur_step * car_step;
+ else
+ freq -= cur_step * car_step;
+
+ /* Setup tuner */
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_set_frequency) {
+ if (state->config->tuner_set_frequency(fe, state->frequency) < 0)
+ goto err;
+ }
+
+ if (state->config->tuner_set_bandwidth) {
+ if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ msleep(50);
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_get_status) {
+ if (state->config->tuner_get_status(fe, &reg) < 0)
+ goto err;
+ }
+
+ if (reg)
+ dprintk(FE_DEBUG, 1, "Tuner phase locked");
+ else
+ dprintk(FE_DEBUG, 1, "Tuner unlocked");
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ }
+ }
+ if (!tmg_lock)
+ srate_coarse = 0;
+ else
+ srate_coarse = stv090x_get_srate(state, state->mclk);
+
+ return srate_coarse;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static u32 stv090x_srate_srch_fine(struct stv090x_state *state)
+{
+ u32 srate_coarse, freq_coarse, sym, reg;
+
+ srate_coarse = stv090x_get_srate(state, state->mclk);
+ freq_coarse = STV090x_READ_DEMOD(state, CFR2) << 8;
+ freq_coarse |= STV090x_READ_DEMOD(state, CFR1);
+ sym = 13 * (srate_coarse / 10); /* SFRUP = SFR + 30% */
+
+ if (sym < state->srate)
+ srate_coarse = 0;
+ else {
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) /* Demod RESET */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0x01) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0x20) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGCFG, 0xd2) < 0)
+ goto err;
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0x00);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x30) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0)
+ goto err;
+ } else if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x49) < 0)
+ goto err;
+ }
+
+ if (srate_coarse > 3000000) {
+ sym = 13 * (srate_coarse / 10); /* SFRUP = SFR + 30% */
+ sym = (sym / 1000) * 65536;
+ sym /= (state->mclk / 1000);
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0)
+ goto err;
+ sym = 10 * (srate_coarse / 13); /* SFRLOW = SFR - 30% */
+ sym = (sym / 1000) * 65536;
+ sym /= (state->mclk / 1000);
+ if (STV090x_WRITE_DEMOD(state, SFRLOW1, (sym >> 8) & 0x7f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW0, sym & 0xff) < 0)
+ goto err;
+ sym = (srate_coarse / 1000) * 65536;
+ sym /= (state->mclk / 1000);
+ if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRINIT0, sym & 0xff) < 0)
+ goto err;
+ } else {
+ sym = 13 * (srate_coarse / 10); /* SFRUP = SFR + 30% */
+ sym = (sym / 100) * 65536;
+ sym /= (state->mclk / 100);
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0)
+ goto err;
+ sym = 10 * (srate_coarse / 14); /* SFRLOW = SFR - 30% */
+ sym = (sym / 100) * 65536;
+ sym /= (state->mclk / 100);
+ if (STV090x_WRITE_DEMOD(state, SFRLOW1, (sym >> 8) & 0x7f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRLOW0, sym & 0xff) < 0)
+ goto err;
+ sym = (srate_coarse / 100) * 65536;
+ sym /= (state->mclk / 100);
+ if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, SFRINIT0, sym & 0xff) < 0)
+ goto err;
+ }
+ if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x20) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, (freq_coarse >> 8) & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, freq_coarse & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0) /* trigger acquisition */
+ goto err;
+ }
+
+ return srate_coarse;
+
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_get_dmdlock(struct stv090x_state *state, s32 timeout)
+{
+ s32 timer = 0, lock = 0;
+ u32 reg;
+ u8 stat;
+
+ while ((timer < timeout) && (!lock)) {
+ reg = STV090x_READ_DEMOD(state, DMDSTATE);
+ stat = STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD);
+
+ switch (stat) {
+ case 0: /* searching */
+ case 1: /* first PLH detected */
+ default:
+ dprintk(FE_DEBUG, 1, "Demodulator searching ..");
+ lock = 0;
+ break;
+ case 2: /* DVB-S2 mode */
+ case 3: /* DVB-S1/legacy mode */
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ lock = STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD);
+ break;
+ }
+
+ if (!lock)
+ msleep(10);
+ else
+ dprintk(FE_DEBUG, 1, "Demodulator acquired LOCK");
+
+ timer += 10;
+ }
+ return lock;
+}
+
+static int stv090x_blind_search(struct stv090x_state *state)
+{
+ u32 agc2, reg, srate_coarse;
+ s32 timeout_dmd = 500, cpt_fail, agc2_ovflw, i;
+ u8 k_ref, k_max, k_min;
+ int coarse_fail, lock;
+
+ k_max = 120;
+ k_min = 30;
+
+ agc2 = stv090x_get_agc2_min_level(state);
+
+ if (agc2 > STV090x_SEARCH_AGC2_TH(state->dev_ver)) {
+ lock = 0;
+ } else {
+
+ if (state->dev_ver <= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARCFG, 0xc4) < 0)
+ goto err;
+ } else {
+ /* > Cut 3 */
+ if (STV090x_WRITE_DEMOD(state, CARCFG, 0x06) < 0)
+ goto err;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, RTCS2, 0x44) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, EQUALCFG, 0x41) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, FFECFG, 0x41) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VITSCALE, 0x82) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VAVSRVIT, 0x00) < 0) /* set viterbi hysteresis */
+ goto err;
+ }
+
+ k_ref = k_max;
+ do {
+ if (STV090x_WRITE_DEMOD(state, KREFTMG, k_ref) < 0)
+ goto err;
+ if (stv090x_srate_srch_coarse(state) != 0) {
+ srate_coarse = stv090x_srate_srch_fine(state);
+ if (srate_coarse != 0) {
+ stv090x_get_lock_tmg(state);
+ lock = stv090x_get_dmdlock(state, timeout_dmd);
+ } else {
+ lock = 0;
+ }
+ } else {
+ cpt_fail = 0;
+ agc2_ovflw = 0;
+ for (i = 0; i < 10; i++) {
+ agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8;
+ agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
+ if (agc2 >= 0xff00)
+ agc2_ovflw++;
+ reg = STV090x_READ_DEMOD(state, DSTATUS2);
+ if ((STV090x_GETFIELD_Px(reg, CFR_OVERFLOW_FIELD) == 0x01) &&
+ (STV090x_GETFIELD_Px(reg, DEMOD_DELOCK_FIELD) == 0x01))
+
+ cpt_fail++;
+ }
+ if ((cpt_fail > 7) || (agc2_ovflw > 7))
+ coarse_fail = 1;
+
+ lock = 0;
+ }
+ k_ref -= 30;
+ } while ((k_ref >= k_min) && (!lock) && (!coarse_fail));
+ }
+
+ return lock;
+
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_chk_tmg(struct stv090x_state *state)
+{
+ u32 reg;
+ s32 tmg_cpt = 0, i;
+ u8 freq, tmg_thh, tmg_thl;
+ int tmg_lock;
+
+ freq = STV090x_READ_DEMOD(state, CARFREQ);
+ tmg_thh = STV090x_READ_DEMOD(state, TMGTHRISE);
+ tmg_thl = STV090x_READ_DEMOD(state, TMGTHFALL);
+ if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0x20) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0x00) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0x00); /* stop carrier offset search */
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, RTC, 0x80) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, RTCS2, 0x40) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x00) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) /* set car ofset to 0 */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x65) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x18) < 0) /* trigger acquisition */
+ goto err;
+ msleep(10);
+
+ for (i = 0; i < 10; i++) {
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2)
+ tmg_cpt++;
+ msleep(1);
+ }
+ if (tmg_cpt >= 3)
+ tmg_lock = 1;
+
+ if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, RTC, 0x88) < 0) /* DVB-S1 timing */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, RTCS2, 0x68) < 0) /* DVB-S2 timing */
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, freq) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHRISE, tmg_thh) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGTHFALL, tmg_thl) < 0)
+ goto err;
+
+ return tmg_lock;
+
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
+{
+ struct dvb_frontend *fe = &state->frontend;
+
+ u32 reg;
+ s32 car_step, steps, cur_step, dir, freq, timeout_lock;
+ int lock = 0;
+
+ if (state->srate >= 10000000)
+ timeout_lock = timeout_dmd / 3;
+ else
+ timeout_lock = timeout_dmd / 2;
+
+ lock = stv090x_get_dmdlock(state, timeout_lock); /* cold start wait */
+ if (!lock) {
+ if (state->srate >= 10000000) {
+ if (stv090x_chk_tmg(state)) {
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
+ goto err;
+ lock = stv090x_get_dmdlock(state, timeout_dmd);
+ } else {
+ lock = 0;
+ }
+ } else {
+ if (state->srate <= 4000000)
+ car_step = 1000;
+ else if (state->srate <= 7000000)
+ car_step = 2000;
+ else if (state->srate <= 10000000)
+ car_step = 3000;
+ else
+ car_step = 5000;
+
+ steps = (state->search_range / 1000) / car_step;
+ steps /= 2;
+ steps = 2 * (steps + 1);
+ if (steps < 0)
+ steps = 2;
+ else if (steps > 12)
+ steps = 12;
+
+ cur_step = 1;
+ dir = 1;
+
+ if (!lock) {
+ freq = state->frequency;
+ state->tuner_bw = stv090x_car_width(state->srate, state->rolloff) + state->srate;
+ while ((cur_step <= steps) && (!lock)) {
+ if (dir > 0)
+ freq += cur_step * car_step;
+ else
+ freq -= cur_step * car_step;
+
+ /* Setup tuner */
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_set_frequency) {
+ if (state->config->tuner_set_frequency(fe, state->frequency) < 0)
+ goto err;
+ }
+
+ if (state->config->tuner_set_bandwidth) {
+ if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ msleep(50);
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_get_status) {
+ if (state->config->tuner_get_status(fe, &reg) < 0)
+ goto err;
+ }
+
+ if (reg)
+ dprintk(FE_DEBUG, 1, "Tuner phase locked");
+ else
+ dprintk(FE_DEBUG, 1, "Tuner unlocked");
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c);
+ if (state->delsys == STV090x_DVBS2) {
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ }
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
+ goto err;
+ lock = stv090x_get_dmdlock(state, (timeout_dmd / 3));
+
+ dir *= -1;
+ cur_step++;
+ }
+ }
+ }
+ }
+
+ return lock;
+
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_get_loop_params(struct stv090x_state *state, s32 *freq_inc, s32 *timeout_sw, s32 *steps)
+{
+ s32 timeout, inc, steps_max, srate, car_max;
+
+ srate = state->srate;
+ car_max = state->search_range / 1000;
+ car_max += car_max / 10;
+ car_max = 65536 * (car_max / 2);
+ car_max /= (state->mclk / 1000);
+
+ if (car_max > 0x4000)
+ car_max = 0x4000 ; /* maxcarrier should be<= +-1/4 Mclk */
+
+ inc = srate;
+ inc /= state->mclk / 1000;
+ inc *= 256;
+ inc *= 256;
+ inc /= 1000;
+
+ switch (state->search_mode) {
+ case STV090x_SEARCH_DVBS1:
+ case STV090x_SEARCH_DSS:
+ inc *= 3; /* freq step = 3% of srate */
+ timeout = 20;
+ break;
+
+ case STV090x_SEARCH_DVBS2:
+ inc *= 4;
+ timeout = 25;
+ break;
+
+ case STV090x_SEARCH_AUTO:
+ default:
+ inc *= 3;
+ timeout = 25;
+ break;
+ }
+ inc /= 100;
+ if ((inc > car_max) || (inc < 0))
+ inc = car_max / 2; /* increment <= 1/8 Mclk */
+
+ timeout *= 27500; /* 27.5 Msps reference */
+ if (srate > 0)
+ timeout /= (srate / 1000);
+
+ if ((timeout > 100) || (timeout < 0))
+ timeout = 100;
+
+ steps_max = (car_max / inc) + 1; /* min steps = 3 */
+ if ((steps_max > 100) || (steps_max < 0)) {
+ steps_max = 100; /* max steps <= 100 */
+ inc = car_max / steps_max;
+ }
+ *freq_inc = inc;
+ *timeout_sw = timeout;
+ *steps = steps_max;
+
+ return 0;
+}
+
+static int stv090x_chk_signal(struct stv090x_state *state)
+{
+ s32 offst_car, agc2, car_max;
+ int no_signal;
+
+ offst_car = STV090x_READ_DEMOD(state, CFR2) << 8;
+ offst_car |= STV090x_READ_DEMOD(state, CFR1);
+ offst_car = comp2(offst_car, 16);
+
+ agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8;
+ agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
+ car_max = state->search_range / 1000;
+
+ car_max += (car_max / 10); /* 10% margin */
+ car_max = (65536 * car_max / 2);
+ car_max /= state->mclk / 1000;
+
+ if (car_max > 0x4000)
+ car_max = 0x4000;
+
+ if ((agc2 > 0x2000) || (offst_car > 2 * car_max) || (offst_car < -2 * car_max)) {
+ no_signal = 1;
+ dprintk(FE_DEBUG, 1, "No Signal");
+ } else {
+ no_signal = 0;
+ dprintk(FE_DEBUG, 1, "Found Signal");
+ }
+
+ return no_signal;
+}
+
+static int stv090x_search_car_loop(struct stv090x_state *state, s32 inc, s32 timeout, int zigzag, s32 steps_max)
+{
+ int no_signal, lock = 0;
+ s32 cpt_step = 0, offst_freq, car_max;
+ u32 reg;
+
+ car_max = state->search_range / 1000;
+ car_max += (car_max / 10);
+ car_max = (65536 * car_max / 2);
+ car_max /= (state->mclk / 1000);
+ if (car_max > 0x4000)
+ car_max = 0x4000;
+
+ if (zigzag)
+ offst_freq = 0;
+ else
+ offst_freq = -car_max + inc;
+
+ do {
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, ((offst_freq / 256) & 0xff)) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, offst_freq & 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x18) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, PDELCTRL1);
+ STV090x_SETFIELD_Px(reg, ALGOSWRST_FIELD, 0x1); /* stop DVB-S2 packet delin */
+ if (STV090x_WRITE_DEMOD(state, PDELCTRL1, reg) < 0)
+ goto err;
+
+ if (zigzag) {
+ if (offst_freq >= 0)
+ offst_freq = -offst_freq - 2 * inc;
+ else
+ offst_freq = -offst_freq;
+ } else {
+ offst_freq += 2 * inc;
+ }
+
+ cpt_step++;
+
+ lock = stv090x_get_dmdlock(state, timeout);
+ no_signal = stv090x_chk_signal(state);
+
+ } while ((!lock) &&
+ (!no_signal) &&
+ ((offst_freq - inc) < car_max) &&
+ ((offst_freq + inc) > -car_max) &&
+ (cpt_step < steps_max));
+
+ reg = STV090x_READ_DEMOD(state, PDELCTRL1);
+ STV090x_SETFIELD_Px(reg, ALGOSWRST_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, PDELCTRL1, reg) < 0)
+ goto err;
+
+ return lock;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_sw_algo(struct stv090x_state *state)
+{
+ int no_signal, zigzag, lock = 0;
+ u32 reg;
+
+ s32 dvbs2_fly_wheel;
+ s32 inc, timeout_step, trials, steps_max;
+
+ /* get params */
+ stv090x_get_loop_params(state, &inc, &timeout_step, &steps_max);
+
+ switch (state->search_mode) {
+ case STV090x_SEARCH_DVBS1:
+ case STV090x_SEARCH_DSS:
+ /* accelerate the frequency detector */
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x3B) < 0)
+ goto err;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, 0x49) < 0)
+ goto err;
+ zigzag = 0;
+ break;
+
+ case STV090x_SEARCH_DVBS2:
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x79) < 0)
+ goto err;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, 0x89) < 0)
+ goto err;
+ zigzag = 1;
+ break;
+
+ case STV090x_SEARCH_AUTO:
+ default:
+ /* accelerate the frequency detector */
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x3b) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x79) < 0)
+ goto err;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, 0xc9) < 0)
+ goto err;
+ zigzag = 0;
+ break;
+ }
+
+ trials = 0;
+ do {
+ lock = stv090x_search_car_loop(state, inc, timeout_step, zigzag, steps_max);
+ no_signal = stv090x_chk_signal(state);
+ trials++;
+
+ /*run the SW search 2 times maximum*/
+ if (lock || no_signal || (trials == 2)) {
+ /*Check if the demod is not losing lock in DVBS2*/
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x49) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x9e) < 0)
+ goto err;
+ }
+
+ reg = STV090x_READ_DEMOD(state, DMDSTATE);
+ if ((lock) && (STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD) == STV090x_DVBS2)) {
+ /*Check if the demod is not losing lock in DVBS2*/
+ msleep(timeout_step);
+ reg = STV090x_READ_DEMOD(state, DMDFLYW);
+ dvbs2_fly_wheel = STV090x_GETFIELD_Px(reg, FLYWHEEL_CPT_FIELD);
+ if (dvbs2_fly_wheel < 0xd) { /*if correct frames is decrementing */
+ msleep(timeout_step);
+ reg = STV090x_READ_DEMOD(state, DMDFLYW);
+ dvbs2_fly_wheel = STV090x_GETFIELD_Px(reg, FLYWHEEL_CPT_FIELD);
+ }
+ if (dvbs2_fly_wheel < 0xd) {
+ /*FALSE lock, The demod is loosing lock */
+ lock = 0;
+ if (trials < 2) {
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x79) < 0)
+ goto err;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, 0x89) < 0)
+ goto err;
+ }
+ }
+ }
+ }
+ } while ((!lock) && (trials < 2) && (!no_signal));
+
+ return lock;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static enum stv090x_delsys stv090x_get_std(struct stv090x_state *state)
+{
+ u32 reg;
+ enum stv090x_delsys delsys;
+
+ reg = STV090x_READ_DEMOD(state, DMDSTATE);
+ if (STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD) == 2)
+ delsys = STV090x_DVBS2;
+ else if (STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD) == 3) {
+ reg = STV090x_READ_DEMOD(state, FECM);
+ if (STV090x_GETFIELD_Px(reg, DSS_DVB_FIELD) == 1)
+ delsys = STV090x_DSS;
+ else
+ delsys = STV090x_DVBS1;
+ } else {
+ delsys = STV090x_ERROR;
+ }
+
+ return delsys;
+}
+
+/* in Hz */
+static s32 stv090x_get_car_freq(struct stv090x_state *state, u32 mclk)
+{
+ s32 derot, int_1, int_2, tmp_1, tmp_2;
+
+ derot = STV090x_READ_DEMOD(state, CFR2) << 16;
+ derot |= STV090x_READ_DEMOD(state, CFR1) << 8;
+ derot |= STV090x_READ_DEMOD(state, CFR0);
+
+ derot = comp2(derot, 24);
+ int_1 = state->mclk >> 12;
+ int_2 = derot >> 12;
+
+ /* carrier_frequency = MasterClock * Reg / 2^24 */
+ tmp_1 = state->mclk % 0x1000;
+ tmp_2 = derot % 0x1000;
+
+ derot = (int_1 * int_2) +
+ ((int_1 * tmp_2) >> 12) +
+ ((int_1 * tmp_1) >> 12);
+
+ return derot;
+}
+
+static int stv090x_get_viterbi(struct stv090x_state *state)
+{
+ u32 reg, rate;
+
+ reg = STV090x_READ_DEMOD(state, VITCURPUN);
+ rate = STV090x_GETFIELD_Px(reg, VIT_CURPUN_FIELD);
+
+ switch (rate) {
+ case 13:
+ state->fec = STV090x_PR12;
+ break;
+
+ case 18:
+ state->fec = STV090x_PR23;
+ break;
+
+ case 21:
+ state->fec = STV090x_PR34;
+ break;
+
+ case 24:
+ state->fec = STV090x_PR56;
+ break;
+
+ case 25:
+ state->fec = STV090x_PR67;
+ break;
+
+ case 26:
+ state->fec = STV090x_PR78;
+ break;
+
+ default:
+ state->fec = STV090x_PRERR;
+ break;
+ }
+
+ return 0;
+}
+
+static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *state)
+{
+ struct dvb_frontend *fe = &state->frontend;
+
+ u8 tmg;
+ u32 reg;
+ s32 i = 0, offst_freq;
+
+ msleep(5);
+
+ if (state->algo == STV090x_BLIND_SEARCH) {
+ tmg = STV090x_READ_DEMOD(state, TMGREG2);
+ STV090x_WRITE_DEMOD(state, SFRSTEP, 0x5c);
+ while ((i <= 50) && (tmg != 0) && (tmg != 0xff)) {
+ tmg = STV090x_READ_DEMOD(state, TMGREG2);
+ msleep(5);
+ i += 5;
+ }
+ }
+ state->delsys = stv090x_get_std(state);
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_get_frequency) {
+ if (state->config->tuner_get_frequency(fe, &state->frequency) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ offst_freq = stv090x_get_car_freq(state, state->mclk) / 1000;
+ state->frequency += offst_freq;
+
+ if (stv090x_get_viterbi(state) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, DMDMODCOD);
+ state->modcod = STV090x_GETFIELD_Px(reg, DEMOD_MODCOD_FIELD);
+ state->pilots = STV090x_GETFIELD_Px(reg, DEMOD_TYPE_FIELD) & 0x01;
+ state->frame_len = STV090x_GETFIELD_Px(reg, DEMOD_TYPE_FIELD) >> 1;
+ reg = STV090x_READ_DEMOD(state, TMGOBS);
+ state->rolloff = STV090x_GETFIELD_Px(reg, ROLLOFF_STATUS_FIELD);
+ reg = STV090x_READ_DEMOD(state, FECM);
+ state->inversion = STV090x_GETFIELD_Px(reg, IQINV_FIELD);
+
+ if ((state->algo == STV090x_BLIND_SEARCH) || (state->srate < 10000000)) {
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_get_frequency) {
+ if (state->config->tuner_get_frequency(fe, &state->frequency) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ if (abs(offst_freq) <= ((state->search_range / 2000) + 500))
+ return STV090x_RANGEOK;
+ else if (abs(offst_freq) <= (stv090x_car_width(state->srate, state->rolloff) / 2000))
+ return STV090x_RANGEOK;
+ else
+ return STV090x_OUTOFRANGE; /* Out of Range */
+ } else {
+ if (abs(offst_freq) <= ((state->search_range / 2000) + 500))
+ return STV090x_RANGEOK;
+ else
+ return STV090x_OUTOFRANGE;
+ }
+
+ return STV090x_OUTOFRANGE;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static u32 stv090x_get_tmgoffst(struct stv090x_state *state, u32 srate)
+{
+ s32 offst_tmg;
+
+ offst_tmg = STV090x_READ_DEMOD(state, TMGREG2) << 16;
+ offst_tmg |= STV090x_READ_DEMOD(state, TMGREG1) << 8;
+ offst_tmg |= STV090x_READ_DEMOD(state, TMGREG0);
+
+ offst_tmg = comp2(offst_tmg, 24); /* 2's complement */
+ if (!offst_tmg)
+ offst_tmg = 1;
+
+ offst_tmg = ((s32) srate * 10) / ((s32) 0x1000000 / offst_tmg);
+ offst_tmg /= 320;
+
+ return offst_tmg;
+}
+
+static u8 stv090x_optimize_carloop(struct stv090x_state *state, enum stv090x_modcod modcod, s32 pilots)
+{
+ u8 aclc = 0x29;
+ s32 i;
+ struct stv090x_long_frame_crloop *car_loop, *car_loop_qpsk_low, *car_loop_apsk_low;
+
+ if (state->dev_ver == 0x20) {
+ car_loop = stv090x_s2_crl_cut20;
+ car_loop_qpsk_low = stv090x_s2_lowqpsk_crl_cut20;
+ car_loop_apsk_low = stv090x_s2_apsk_crl_cut20;
+ } else {
+ /* >= Cut 3 */
+ car_loop = stv090x_s2_crl_cut30;
+ car_loop_qpsk_low = stv090x_s2_lowqpsk_crl_cut30;
+ car_loop_apsk_low = stv090x_s2_apsk_crl_cut30;
+ }
+
+ if (modcod < STV090x_QPSK_12) {
+ i = 0;
+ while ((i < 3) && (modcod != car_loop_qpsk_low[i].modcod))
+ i++;
+
+ if (i >= 3)
+ i = 2;
+
+ } else {
+ i = 0;
+ while ((i < 14) && (modcod != car_loop[i].modcod))
+ i++;
+
+ if (i >= 14) {
+ i = 0;
+ while ((i < 11) && (modcod != car_loop_apsk_low[i].modcod))
+ i++;
+
+ if (i >= 11)
+ i = 10;
+ }
+ }
+
+ if (modcod <= STV090x_QPSK_25) {
+ if (pilots) {
+ if (state->srate <= 3000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_on_2;
+ else if (state->srate <= 7000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_on_5;
+ else if (state->srate <= 15000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_on_10;
+ else if (state->srate <= 25000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_on_20;
+ else
+ aclc = car_loop_qpsk_low[i].crl_pilots_on_30;
+ } else {
+ if (state->srate <= 3000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_off_2;
+ else if (state->srate <= 7000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_off_5;
+ else if (state->srate <= 15000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_off_10;
+ else if (state->srate <= 25000000)
+ aclc = car_loop_qpsk_low[i].crl_pilots_off_20;
+ else
+ aclc = car_loop_qpsk_low[i].crl_pilots_off_30;
+ }
+
+ } else if (modcod <= STV090x_8PSK_910) {
+ if (pilots) {
+ if (state->srate <= 3000000)
+ aclc = car_loop[i].crl_pilots_on_2;
+ else if (state->srate <= 7000000)
+ aclc = car_loop[i].crl_pilots_on_5;
+ else if (state->srate <= 15000000)
+ aclc = car_loop[i].crl_pilots_on_10;
+ else if (state->srate <= 25000000)
+ aclc = car_loop[i].crl_pilots_on_20;
+ else
+ aclc = car_loop[i].crl_pilots_on_30;
+ } else {
+ if (state->srate <= 3000000)
+ aclc = car_loop[i].crl_pilots_off_2;
+ else if (state->srate <= 7000000)
+ aclc = car_loop[i].crl_pilots_off_5;
+ else if (state->srate <= 15000000)
+ aclc = car_loop[i].crl_pilots_off_10;
+ else if (state->srate <= 25000000)
+ aclc = car_loop[i].crl_pilots_off_20;
+ else
+ aclc = car_loop[i].crl_pilots_off_30;
+ }
+ } else { /* 16APSK and 32APSK */
+ if (state->srate <= 3000000)
+ aclc = car_loop_apsk_low[i].crl_pilots_on_2;
+ else if (state->srate <= 7000000)
+ aclc = car_loop_apsk_low[i].crl_pilots_on_5;
+ else if (state->srate <= 15000000)
+ aclc = car_loop_apsk_low[i].crl_pilots_on_10;
+ else if (state->srate <= 25000000)
+ aclc = car_loop_apsk_low[i].crl_pilots_on_20;
+ else
+ aclc = car_loop_apsk_low[i].crl_pilots_on_30;
+ }
+
+ return aclc;
+}
+
+static u8 stv090x_optimize_carloop_short(struct stv090x_state *state)
+{
+ struct stv090x_short_frame_crloop *short_crl;
+ s32 index = 0;
+ u8 aclc = 0x0b;
+
+ switch (state->modulation) {
+ case STV090x_QPSK:
+ default:
+ index = 0;
+ break;
+ case STV090x_8PSK:
+ index = 1;
+ break;
+ case STV090x_16APSK:
+ index = 2;
+ break;
+ case STV090x_32APSK:
+ index = 3;
+ break;
+ }
+
+ if (state->dev_ver >= 0x30)
+ short_crl = stv090x_s2_short_crl_cut20;
+ else if (state->dev_ver >= 0x20)
+ short_crl = stv090x_s2_short_crl_cut30;
+
+ if (state->srate <= 3000000)
+ aclc = short_crl[index].crl_2;
+ else if (state->srate <= 7000000)
+ aclc = short_crl[index].crl_5;
+ else if (state->srate <= 15000000)
+ aclc = short_crl[index].crl_10;
+ else if (state->srate <= 25000000)
+ aclc = short_crl[index].crl_20;
+ else
+ aclc = short_crl[index].crl_30;
+
+ return aclc;
+}
+
+static int stv090x_optimize_track(struct stv090x_state *state)
+{
+ struct dvb_frontend *fe = &state->frontend;
+
+ enum stv090x_rolloff rolloff;
+ enum stv090x_modcod modcod;
+
+ s32 srate, pilots, aclc, f_1, f_0, i = 0, blind_tune = 0;
+ u32 reg;
+
+ srate = stv090x_get_srate(state, state->mclk);
+ srate += stv090x_get_tmgoffst(state, srate);
+
+ switch (state->delsys) {
+ case STV090x_DVBS1:
+ case STV090x_DSS:
+ if (state->algo == STV090x_SEARCH_AUTO) {
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ }
+ reg = STV090x_READ_DEMOD(state, DEMOD);
+ STV090x_SETFIELD_Px(reg, ROLLOFF_CONTROL_FIELD, state->rolloff);
+ STV090x_SETFIELD_Px(reg, MANUAL_SXROLLOFF_FIELD, 0x01);
+ if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x30) {
+ if (stv090x_get_viterbi(state) < 0)
+ goto err;
+
+ if (state->fec == STV090x_PR12) {
+ if (STV090x_WRITE_DEMOD(state, GAUSSR0, 0x98) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CCIR0, 0x18) < 0)
+ goto err;
+ } else {
+ if (STV090x_WRITE_DEMOD(state, GAUSSR0, 0x18) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CCIR0, 0x18) < 0)
+ goto err;
+ }
+ }
+
+ if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x75) < 0)
+ goto err;
+ break;
+
+ case STV090x_DVBS2:
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC, 0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, BCLC, 0) < 0)
+ goto err;
+ if (state->frame_len == STV090x_LONG_FRAME) {
+ reg = STV090x_READ_DEMOD(state, DMDMODCOD);
+ modcod = STV090x_GETFIELD_Px(reg, DEMOD_MODCOD_FIELD);
+ pilots = STV090x_GETFIELD_Px(reg, DEMOD_TYPE_FIELD) & 0x01;
+ aclc = stv090x_optimize_carloop(state, modcod, pilots);
+ if (modcod <= STV090x_QPSK_910) {
+ STV090x_WRITE_DEMOD(state, ACLC2S2Q, aclc);
+ } else if (modcod <= STV090x_8PSK_910) {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, 0x2a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC2S28, aclc) < 0)
+ goto err;
+ }
+ if ((state->demod_mode == STV090x_SINGLE) && (modcod > STV090x_8PSK_910)) {
+ if (modcod <= STV090x_16APSK_910) {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, 0x2a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC2S216A, aclc) < 0)
+ goto err;
+ } else {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, 0x2a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC2S232A, aclc) < 0)
+ goto err;
+ }
+ }
+ } else {
+ /*Carrier loop setting for short frame*/
+ aclc = stv090x_optimize_carloop_short(state);
+ if (state->modulation == STV090x_QPSK) {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, aclc) < 0)
+ goto err;
+ } else if (state->modulation == STV090x_8PSK) {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, 0x2a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC2S28, aclc) < 0)
+ goto err;
+ } else if (state->modulation == STV090x_16APSK) {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, 0x2a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC2S216A, aclc) < 0)
+ goto err;
+ } else if (state->modulation == STV090x_32APSK) {
+ if (STV090x_WRITE_DEMOD(state, ACLC2S2Q, 0x2a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ACLC2S232A, aclc) < 0)
+ goto err;
+ }
+ }
+
+ STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x67); /* PER */
+ break;
+
+ case STV090x_UNKNOWN:
+ default:
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
+ STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ break;
+ }
+
+ f_1 = STV090x_READ_DEMOD(state, CFR2);
+ f_0 = STV090x_READ_DEMOD(state, CFR1);
+ reg = STV090x_READ_DEMOD(state, TMGOBS);
+ rolloff = STV090x_GETFIELD_Px(reg, ROLLOFF_STATUS_FIELD);
+
+ if (state->algo == STV090x_BLIND_SEARCH) {
+ STV090x_WRITE_DEMOD(state, SFRSTEP, 0x00);
+ reg = STV090x_READ_DEMOD(state, DMDCFGMD);
+ STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 0x00);
+ STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0x00);
+ if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc1) < 0)
+ goto err;
+
+ if (stv090x_set_srate(state, srate) < 0)
+ goto err;
+ blind_tune = 1;
+ }
+
+ if (state->dev_ver >= 0x20) {
+ if ((state->search_mode == STV090x_SEARCH_DVBS1) ||
+ (state->search_mode == STV090x_SEARCH_DSS) ||
+ (state->search_mode == STV090x_SEARCH_AUTO)) {
+
+ if (STV090x_WRITE_DEMOD(state, VAVSRVIT, 0x0a) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, VITSCALE, 0x00) < 0)
+ goto err;
+ }
+ }
+
+ if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
+ goto err;
+
+ /* AUTO tracking MODE */
+ if (STV090x_WRITE_DEMOD(state, SFRUP1, 0x80) < 0)
+ goto err;
+ /* AUTO tracking MODE */
+ if (STV090x_WRITE_DEMOD(state, SFRLOW1, 0x80) < 0)
+ goto err;
+
+ if ((state->dev_ver >= 0x20) || (blind_tune == 1) || (state->srate < 10000000)) {
+ /* update initial carrier freq with the found freq offset */
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, f_1) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, f_0) < 0)
+ goto err;
+ state->tuner_bw = stv090x_car_width(srate, state->rolloff) + 10000000;
+
+ if ((state->dev_ver >= 0x20) || (blind_tune == 1)) {
+
+ if (state->algo != STV090x_WARM_SEARCH) {
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_set_bandwidth) {
+ if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ }
+ }
+ if ((state->algo == STV090x_BLIND_SEARCH) || (state->srate < 10000000))
+ msleep(50); /* blind search: wait 50ms for SR stabilization */
+ else
+ msleep(5);
+
+ stv090x_get_lock_tmg(state);
+
+ if (!(stv090x_get_dmdlock(state, (state->DemodTimeout / 2)))) {
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, f_1) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, f_0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x18) < 0)
+ goto err;
+
+ i = 0;
+
+ while ((!(stv090x_get_dmdlock(state, (state->DemodTimeout / 2)))) && (i <= 2)) {
+
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT1, f_1) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CFRINIT0, f_0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x18) < 0)
+ goto err;
+ i++;
+ }
+ }
+
+ }
+
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x49) < 0)
+ goto err;
+ }
+
+ if ((state->delsys == STV090x_DVBS1) || (state->delsys == STV090x_DSS))
+ stv090x_set_vit_thtracq(state);
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_get_feclock(struct stv090x_state *state, s32 timeout)
+{
+ s32 timer = 0, lock = 0, stat;
+ u32 reg;
+
+ while ((timer < timeout) && (!lock)) {
+ reg = STV090x_READ_DEMOD(state, DMDSTATE);
+ stat = STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD);
+
+ switch (stat) {
+ case 0: /* searching */
+ case 1: /* first PLH detected */
+ default:
+ lock = 0;
+ break;
+
+ case 2: /* DVB-S2 mode */
+ reg = STV090x_READ_DEMOD(state, PDELSTATUS1);
+ lock = STV090x_GETFIELD_Px(reg, PKTDELIN_LOCK_FIELD);
+ break;
+
+ case 3: /* DVB-S1/legacy mode */
+ reg = STV090x_READ_DEMOD(state, VSTATUSVIT);
+ lock = STV090x_GETFIELD_Px(reg, LOCKEDVIT_FIELD);
+ break;
+ }
+ if (!lock) {
+ msleep(10);
+ timer += 10;
+ }
+ }
+ return lock;
+}
+
+static int stv090x_get_lock(struct stv090x_state *state, s32 timeout_dmd, s32 timeout_fec)
+{
+ u32 reg;
+ s32 timer = 0;
+ int lock;
+
+ lock = stv090x_get_dmdlock(state, timeout_dmd);
+ if (lock)
+ lock = stv090x_get_feclock(state, timeout_fec);
+
+ if (lock) {
+ lock = 0;
+
+ while ((timer < timeout_fec) && (!lock)) {
+ reg = STV090x_READ_DEMOD(state, TSSTATUS);
+ lock = STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD);
+ msleep(1);
+ timer++;
+ }
+ }
+
+ return lock;
+}
+
+static int stv090x_set_s2rolloff(struct stv090x_state *state)
+{
+ u32 reg;
+
+ if (state->dev_ver <= 0x20) {
+ /* rolloff to auto mode if DVBS2 */
+ reg = STV090x_READ_DEMOD(state, DEMOD);
+ STV090x_SETFIELD_Px(reg, MANUAL_SXROLLOFF_FIELD, 0x00);
+ if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0)
+ goto err;
+ } else {
+ /* DVB-S2 rolloff to auto mode if DVBS2 */
+ reg = STV090x_READ_DEMOD(state, DEMOD);
+ STV090x_SETFIELD_Px(reg, MANUAL_S2ROLLOFF_FIELD, 0x00);
+ if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0)
+ goto err;
+ }
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+
+static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state)
+{
+ struct dvb_frontend *fe = &state->frontend;
+ enum stv090x_signal_state signal_state = STV090x_NOCARRIER;
+ u32 reg;
+ s32 timeout_dmd = 500, timeout_fec = 50, agc1_power, power_iq = 0, i;
+ int lock = 0, low_sr = 0, no_signal = 0;
+
+ reg = STV090x_READ_DEMOD(state, TSCFGH);
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream merger */
+ if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c) < 0) /* Demod stop */
+ goto err;
+
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x9e) < 0) /* cut 2.0 */
+ goto err;
+ }
+
+ stv090x_get_lock_tmg(state);
+
+ if (state->algo == STV090x_BLIND_SEARCH) {
+ state->tuner_bw = 2 * 36000000; /* wide bw for unknown srate */
+ if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc0) < 0) /* wider srate scan */
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, CORRELMANT, 0x70) < 0)
+ goto err;
+ if (stv090x_set_srate(state, 1000000) < 0) /* inital srate = 1Msps */
+ goto err;
+ } else {
+ /* known srate */
+ if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x20) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, TMGCFG, 0xd2) < 0)
+ goto err;
+
+ if (state->srate < 2000000) {
+ /* SR < 2MSPS */
+ if (STV090x_WRITE_DEMOD(state, CORRELMANT, 0x63) < 0)
+ goto err;
+ } else {
+ /* SR >= 2Msps */
+ if (STV090x_WRITE_DEMOD(state, CORRELMANT, 0x70) < 0)
+ goto err;
+ }
+
+ if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
+ goto err;
+
+ if (state->dev_ver >= 0x20) {
+ if (STV090x_WRITE_DEMOD(state, KREFTMG, 0x5a) < 0)
+ goto err;
+ if (state->algo == STV090x_COLD_SEARCH)
+ state->tuner_bw = (15 * (stv090x_car_width(state->srate, state->rolloff) + 10000000)) / 10;
+ else if (state->algo == STV090x_WARM_SEARCH)
+ state->tuner_bw = stv090x_car_width(state->srate, state->rolloff) + 10000000;
+ }
+
+ /* if cold start or warm (Symbolrate is known)
+ * use a Narrow symbol rate scan range
+ */
+ if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc1) < 0) /* narrow srate scan */
+ goto err;
+
+ if (stv090x_set_srate(state, state->srate) < 0)
+ goto err;
+
+ if (stv090x_set_max_srate(state, state->mclk, state->srate) < 0)
+ goto err;
+ if (stv090x_set_min_srate(state, state->mclk, state->srate) < 0)
+ goto err;
+
+ if (state->srate >= 10000000)
+ low_sr = 0;
+ else
+ low_sr = 1;
+ }
+
+ /* Setup tuner */
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_set_bbgain) {
+ if (state->config->tuner_set_bbgain(fe, 10) < 0) /* 10dB */
+ goto err;
+ }
+
+ if (state->config->tuner_set_frequency) {
+ if (state->config->tuner_set_frequency(fe, state->frequency) < 0)
+ goto err;
+ }
+
+ if (state->config->tuner_set_bandwidth) {
+ if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ msleep(50);
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (state->config->tuner_get_status) {
+ if (state->config->tuner_get_status(fe, &reg) < 0)
+ goto err;
+ }
+
+ if (reg)
+ dprintk(FE_DEBUG, 1, "Tuner phase locked");
+ else
+ dprintk(FE_DEBUG, 1, "Tuner unlocked");
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ msleep(10);
+ agc1_power = MAKEWORD16(STV090x_READ_DEMOD(state, AGCIQIN1),
+ STV090x_READ_DEMOD(state, AGCIQIN0));
+
+ if (agc1_power == 0) {
+ /* If AGC1 integrator value is 0
+ * then read POWERI, POWERQ
+ */
+ for (i = 0; i < 5; i++) {
+ power_iq += (STV090x_READ_DEMOD(state, POWERI) +
+ STV090x_READ_DEMOD(state, POWERQ)) >> 1;
+ }
+ power_iq /= 5;
+ }
+
+ if ((agc1_power == 0) && (power_iq < STV090x_IQPOWER_THRESHOLD)) {
+ dprintk(FE_ERROR, 1, "No Signal: POWER_IQ=0x%02x", power_iq);
+ lock = 0;
+
+ } else {
+ reg = STV090x_READ_DEMOD(state, DEMOD);
+ STV090x_SETFIELD_Px(reg, SPECINV_CONTROL_FIELD, state->inversion);
+
+ if (state->dev_ver <= 0x20) {
+ /* rolloff to auto mode if DVBS2 */
+ STV090x_SETFIELD_Px(reg, MANUAL_SXROLLOFF_FIELD, 1);
+ } else {
+ /* DVB-S2 rolloff to auto mode if DVBS2 */
+ STV090x_SETFIELD_Px(reg, MANUAL_S2ROLLOFF_FIELD, 1);
+ }
+ if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0)
+ goto err;
+
+ if (stv090x_delivery_search(state) < 0)
+ goto err;
+
+ if (state->algo != STV090x_BLIND_SEARCH) {
+ if (stv090x_start_search(state) < 0)
+ goto err;
+ }
+ }
+
+ /* need to check for AGC1 state */
+
+
+
+ if (state->algo == STV090x_BLIND_SEARCH)
+ lock = stv090x_blind_search(state);
+
+ else if (state->algo == STV090x_COLD_SEARCH)
+ lock = stv090x_get_coldlock(state, timeout_dmd);
+
+ else if (state->algo == STV090x_WARM_SEARCH)
+ lock = stv090x_get_dmdlock(state, timeout_dmd);
+
+ if ((!lock) && (state->algo == STV090x_COLD_SEARCH)) {
+ if (!low_sr) {
+ if (stv090x_chk_tmg(state))
+ lock = stv090x_sw_algo(state);
+ }
+ }
+
+ if (lock)
+ signal_state = stv090x_get_sig_params(state);
+
+ if ((lock) && (signal_state == STV090x_RANGEOK)) { /* signal within Range */
+ stv090x_optimize_track(state);
+
+ if (state->dev_ver >= 0x20) {
+ /* >= Cut 2.0 :release TS reset after
+ * demod lock and optimized Tracking
+ */
+ reg = STV090x_READ_DEMOD(state, TSCFGH);
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0); /* release merger reset */
+ if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0)
+ goto err;
+
+ msleep(3);
+
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* merger reset */
+ if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0)
+ goto err;
+
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0); /* release merger reset */
+ if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0)
+ goto err;
+ }
+
+ if (stv090x_get_lock(state, timeout_fec, timeout_fec)) {
+ lock = 1;
+ if (state->delsys == STV090x_DVBS2) {
+ stv090x_set_s2rolloff(state);
+
+ reg = STV090x_READ_DEMOD(state, PDELCTRL2);
+ STV090x_SETFIELD_Px(reg, RESET_UPKO_COUNT, 1);
+ if (STV090x_WRITE_DEMOD(state, PDELCTRL2, reg) < 0)
+ goto err;
+ /* Reset DVBS2 packet delinator error counter */
+ reg = STV090x_READ_DEMOD(state, PDELCTRL2);
+ STV090x_SETFIELD_Px(reg, RESET_UPKO_COUNT, 0);
+ if (STV090x_WRITE_DEMOD(state, PDELCTRL2, reg) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x67) < 0) /* PER */
+ goto err;
+ } else {
+ if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x75) < 0)
+ goto err;
+ }
+ /* Reset the Total packet counter */
+ if (STV090x_WRITE_DEMOD(state, FBERCPT4, 0x00) < 0)
+ goto err;
+ /* Reset the packet Error counter2 */
+ if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0)
+ goto err;
+ } else {
+ lock = 0;
+ signal_state = STV090x_NODATA;
+ no_signal = stv090x_chk_signal(state);
+ }
+ }
+ return signal_state;
+
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static enum dvbfe_search stv090x_search(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *props = &fe->dtv_property_cache;
+
+ state->delsys = props->delivery_system;
+ state->frequency = p->frequency;
+ state->srate = p->u.qpsk.symbol_rate;
+ state->search_mode = STV090x_SEARCH_AUTO;
+ state->algo = STV090x_COLD_SEARCH;
+ state->fec = STV090x_PRERR;
+ state->search_range = 2000000;
+
+ if (stv090x_algo(state) == STV090x_RANGEOK) {
+ dprintk(FE_DEBUG, 1, "Search success!");
+ return DVBFE_ALGO_SEARCH_SUCCESS;
+ } else {
+ dprintk(FE_DEBUG, 1, "Search failed!");
+ return DVBFE_ALGO_SEARCH_FAILED;
+ }
+
+ return DVBFE_ALGO_SEARCH_ERROR;
+}
+
+/* FIXME! */
+static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg;
+ u8 search_state;
+
+ reg = STV090x_READ_DEMOD(state, DMDSTATE);
+ search_state = STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD);
+
+ switch (search_state) {
+ case 0: /* searching */
+ case 1: /* first PLH detected */
+ default:
+ dprintk(FE_DEBUG, 1, "Status: Unlocked (Searching ..)");
+ *status = 0;
+ break;
+
+ case 2: /* DVB-S2 mode */
+ dprintk(FE_DEBUG, 1, "Delivery system: DVB-S2");
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ if (STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD)) {
+ reg = STV090x_READ_DEMOD(state, TSSTATUS);
+ if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) {
+ *status = FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+ }
+ }
+ break;
+
+ case 3: /* DVB-S1/legacy mode */
+ dprintk(FE_DEBUG, 1, "Delivery system: DVB-S");
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ if (STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD)) {
+ reg = STV090x_READ_DEMOD(state, VSTATUSVIT);
+ if (STV090x_GETFIELD_Px(reg, LOCKEDVIT_FIELD)) {
+ reg = STV090x_READ_DEMOD(state, TSSTATUS);
+ if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) {
+ *status = FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+ }
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+static int stv090x_read_per(struct dvb_frontend *fe, u32 *per)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+
+ s32 count_4, count_3, count_2, count_1, count_0, count;
+ u32 reg, h, m, l;
+ enum fe_status status;
+
+ stv090x_read_status(fe, &status);
+ if (!(status & FE_HAS_LOCK)) {
+ *per = 1 << 23; /* Max PER */
+ } else {
+ /* Counter 2 */
+ reg = STV090x_READ_DEMOD(state, ERRCNT22);
+ h = STV090x_GETFIELD_Px(reg, ERR_CNT2_FIELD);
+
+ reg = STV090x_READ_DEMOD(state, ERRCNT21);
+ m = STV090x_GETFIELD_Px(reg, ERR_CNT21_FIELD);
+
+ reg = STV090x_READ_DEMOD(state, ERRCNT20);
+ l = STV090x_GETFIELD_Px(reg, ERR_CNT20_FIELD);
+
+ *per = ((h << 16) | (m << 8) | l);
+
+ count_4 = STV090x_READ_DEMOD(state, FBERCPT4);
+ count_3 = STV090x_READ_DEMOD(state, FBERCPT3);
+ count_2 = STV090x_READ_DEMOD(state, FBERCPT2);
+ count_1 = STV090x_READ_DEMOD(state, FBERCPT1);
+ count_0 = STV090x_READ_DEMOD(state, FBERCPT0);
+
+ if ((!count_4) && (!count_3)) {
+ count = (count_2 & 0xff) << 16;
+ count |= (count_1 & 0xff) << 8;
+ count |= count_0 & 0xff;
+ } else {
+ count = 1 << 24;
+ }
+ if (count == 0)
+ *per = 1;
+ }
+ if (STV090x_WRITE_DEMOD(state, FBERCPT4, 0) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val)
+{
+ int res = 0;
+ int min = 0, med;
+
+ if (val < tab[min].read)
+ res = tab[min].real;
+ else if (val >= tab[max].read)
+ res = tab[max].real;
+ else {
+ while ((max - min) > 1) {
+ med = (max + min) / 2;
+ if (val >= tab[min].read && val < tab[med].read)
+ max = med;
+ else
+ min = med;
+ }
+ res = ((val - tab[min].read) *
+ (tab[max].real - tab[min].real) /
+ (tab[max].read - tab[min].read)) +
+ tab[min].real;
+ }
+
+ return res;
+}
+
+static int stv090x_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg;
+ s32 agc;
+
+ reg = STV090x_READ_DEMOD(state, AGCIQIN1);
+ agc = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD);
+
+ *strength = stv090x_table_lookup(stv090x_rf_tab, ARRAY_SIZE(stv090x_rf_tab) - 1, agc);
+ if (agc > stv090x_rf_tab[0].read)
+ *strength = 5;
+ else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read)
+ *strength = -100;
+
+ return 0;
+}
+
+static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg_0, reg_1, reg, i;
+ s32 val_0, val_1, val = 0;
+ u8 lock_f;
+
+ switch (state->delsys) {
+ case STV090x_DVBS2:
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ lock_f = STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD);
+ if (lock_f) {
+ msleep(5);
+ for (i = 0; i < 16; i++) {
+ reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1);
+ val_1 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD);
+ reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0);
+ val_0 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD);
+ val += MAKEWORD16(val_1, val_0);
+ msleep(1);
+ }
+ val /= 16;
+ *cnr = stv090x_table_lookup(stv090x_s2cn_tab, ARRAY_SIZE(stv090x_s2cn_tab) - 1, val);
+ if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) - 1].read)
+ *cnr = 1000;
+ }
+ break;
+
+ case STV090x_DVBS1:
+ case STV090x_DSS:
+ reg = STV090x_READ_DEMOD(state, DSTATUS);
+ lock_f = STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD);
+ if (lock_f) {
+ msleep(5);
+ for (i = 0; i < 16; i++) {
+ reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1);
+ val_1 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD);
+ reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0);
+ val_0 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD);
+ val += MAKEWORD16(val_1, val_0);
+ msleep(1);
+ }
+ val /= 16;
+ *cnr = stv090x_table_lookup(stv090x_s1cn_tab, ARRAY_SIZE(stv090x_s1cn_tab) - 1, val);
+ if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s1cn_tab) - 1].read)
+ *cnr = 1000;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int stv090x_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg;
+
+ reg = STV090x_READ_DEMOD(state, DISTXCTL);
+ switch (tone) {
+ case SEC_TONE_ON:
+ STV090x_SETFIELD_Px(reg, DISTX_MODE_FIELD, 0);
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+ break;
+
+ case SEC_TONE_OFF:
+ STV090x_SETFIELD_Px(reg, DISTX_MODE_FIELD, 0);
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+
+static enum dvbfe_algo stv090x_frontend_algo(struct dvb_frontend *fe)
+{
+ return DVBFE_ALGO_CUSTOM;
+}
+
+static int stv090x_send_diseqc_msg(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg, idle = 0, fifo_full = 1;
+ int i;
+
+ reg = STV090x_READ_DEMOD(state, DISTXCTL);
+
+ STV090x_SETFIELD_Px(reg, DISTX_MODE_FIELD, 2);
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+
+ STV090x_SETFIELD_Px(reg, DIS_PRECHARGE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+
+ for (i = 0; i < cmd->msg_len; i++) {
+
+ while (fifo_full) {
+ reg = STV090x_READ_DEMOD(state, DISTXSTATUS);
+ fifo_full = STV090x_GETFIELD_Px(reg, FIFO_FULL_FIELD);
+ }
+
+ if (STV090x_WRITE_DEMOD(state, DISTXDATA, cmd->msg[i]) < 0)
+ goto err;
+ }
+ reg = STV090x_READ_DEMOD(state, DISTXCTL);
+ STV090x_SETFIELD_Px(reg, DIS_PRECHARGE_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+
+ i = 0;
+
+ while ((!idle) && (i < 10)) {
+ reg = STV090x_READ_DEMOD(state, DISTXSTATUS);
+ idle = STV090x_GETFIELD_Px(reg, TX_IDLE_FIELD);
+ msleep(10);
+ i++;
+ }
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg, idle = 0, fifo_full = 1;
+ u8 mode, value;
+ int i;
+
+ reg = STV090x_READ_DEMOD(state, DISTXCTL);
+
+ if (burst == SEC_MINI_A) {
+ mode = 3;
+ value = 0x00;
+ } else {
+ mode = 2;
+ value = 0xFF;
+ }
+
+ STV090x_SETFIELD_Px(reg, DISTX_MODE_FIELD, mode);
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+
+ STV090x_SETFIELD_Px(reg, DIS_PRECHARGE_FIELD, 1);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+
+ while (fifo_full) {
+ reg = STV090x_READ_DEMOD(state, DISTXSTATUS);
+ fifo_full = STV090x_GETFIELD_Px(reg, FIFO_FULL_FIELD);
+ }
+
+ if (STV090x_WRITE_DEMOD(state, DISTXDATA, value) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, DISTXCTL);
+ STV090x_SETFIELD_Px(reg, DIS_PRECHARGE_FIELD, 0);
+ if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
+ goto err;
+
+ i = 0;
+
+ while ((!idle) && (i < 10)) {
+ reg = STV090x_READ_DEMOD(state, DISTXSTATUS);
+ idle = STV090x_GETFIELD_Px(reg, TX_IDLE_FIELD);
+ msleep(10);
+ i++;
+ }
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_recv_slave_reply(struct dvb_frontend *fe, struct dvb_diseqc_slave_reply *reply)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg = 0, i = 0, rx_end = 0;
+
+ while ((rx_end != 1) && (i < 10)) {
+ msleep(10);
+ i++;
+ reg = STV090x_READ_DEMOD(state, DISRX_ST0);
+ rx_end = STV090x_GETFIELD_Px(reg, RX_END_FIELD);
+ }
+
+ if (rx_end) {
+ reply->msg_len = STV090x_GETFIELD_Px(reg, FIFO_BYTENBR_FIELD);
+ for (i = 0; i < reply->msg_len; i++)
+ reply->msg[i] = STV090x_READ_DEMOD(state, DISRXDATA);
+ }
+
+ return 0;
+}
+
+static int stv090x_sleep(struct dvb_frontend *fe)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg;
+
+ dprintk(FE_DEBUG, 1, "Set %s to sleep",
+ state->device == STV0900 ? "STV0900" : "STV0903");
+
+ reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
+ STV090x_SETFIELD(reg, STANDBY_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_SYNTCTRL, reg) < 0)
+ goto err;
+
+ reg = stv090x_read_reg(state, STV090x_TSTTNR1);
+ STV090x_SETFIELD(reg, ADC1_PON_FIELD, 0);
+ if (stv090x_write_reg(state, STV090x_TSTTNR1, reg) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_wakeup(struct dvb_frontend *fe)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ u32 reg;
+
+ dprintk(FE_DEBUG, 1, "Wake %s from standby",
+ state->device == STV0900 ? "STV0900" : "STV0903");
+
+ reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
+ STV090x_SETFIELD(reg, STANDBY_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_SYNTCTRL, reg) < 0)
+ goto err;
+
+ reg = stv090x_read_reg(state, STV090x_TSTTNR1);
+ STV090x_SETFIELD(reg, ADC1_PON_FIELD, 1);
+ if (stv090x_write_reg(state, STV090x_TSTTNR1, reg) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static void stv090x_release(struct dvb_frontend *fe)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+
+ kfree(state);
+}
+
+static int stv090x_ldpc_mode(struct stv090x_state *state, enum stv090x_mode ldpc_mode)
+{
+ u32 reg = 0;
+
+ switch (ldpc_mode) {
+ case STV090x_DUAL:
+ default:
+ if ((state->demod_mode != STV090x_DUAL) || (STV090x_GETFIELD(reg, DDEMOD_FIELD) != 1)) {
+ /* set LDPC to dual mode */
+ if (stv090x_write_reg(state, STV090x_GENCFG, 0x1d) < 0)
+ goto err;
+
+ state->demod_mode = STV090x_DUAL;
+
+ reg = stv090x_read_reg(state, STV090x_TSTRES0);
+ STV090x_SETFIELD(reg, FRESFEC_FIELD, 0x1);
+ if (stv090x_write_reg(state, STV090x_TSTRES0, reg) < 0)
+ goto err;
+ STV090x_SETFIELD(reg, FRESFEC_FIELD, 0x0);
+ if (stv090x_write_reg(state, STV090x_TSTRES0, reg) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, MODCODLST0, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST1, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST2, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST3, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST4, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST5, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST6, 0xff) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, MODCODLST7, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST8, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLST9, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTA, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTB, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTC, 0xcc) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTD, 0xcc) < 0)
+ goto err;
+
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTE, 0xff) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, MODCODLSTF, 0xcf) < 0)
+ goto err;
+ }
+ break;
+
+ case STV090x_SINGLE:
+ if (stv090x_stop_modcod(state) < 0)
+ goto err;
+ if (stv090x_activate_modcod_single(state) < 0)
+ goto err;
+
+ if (state->demod == STV090x_DEMODULATOR_1) {
+ if (stv090x_write_reg(state, STV090x_GENCFG, 0x06) < 0) /* path 2 */
+ goto err;
+ } else {
+ if (stv090x_write_reg(state, STV090x_GENCFG, 0x04) < 0) /* path 1 */
+ goto err;
+ }
+
+ reg = stv090x_read_reg(state, STV090x_TSTRES0);
+ STV090x_SETFIELD(reg, FRESFEC_FIELD, 0x1);
+ if (stv090x_write_reg(state, STV090x_TSTRES0, reg) < 0)
+ goto err;
+ STV090x_SETFIELD(reg, FRESFEC_FIELD, 0x0);
+ if (stv090x_write_reg(state, STV090x_TSTRES0, reg) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, PDELCTRL1);
+ STV090x_SETFIELD_Px(reg, ALGOSWRST_FIELD, 0x01);
+ if (STV090x_WRITE_DEMOD(state, PDELCTRL1, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, ALGOSWRST_FIELD, 0x00);
+ if (STV090x_WRITE_DEMOD(state, PDELCTRL1, reg) < 0)
+ goto err;
+ break;
+ }
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+/* return (Hz), clk in Hz*/
+static u32 stv090x_get_mclk(struct stv090x_state *state)
+{
+ const struct stv090x_config *config = state->config;
+ u32 div, reg;
+ u8 ratio;
+
+ div = stv090x_read_reg(state, STV090x_NCOARSE);
+ reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
+ ratio = STV090x_GETFIELD(reg, SELX1RATIO_FIELD) ? 4 : 6;
+
+ return (div + 1) * config->xtal / ratio; /* kHz */
+}
+
+static int stv090x_set_mclk(struct stv090x_state *state, u32 mclk, u32 clk)
+{
+ const struct stv090x_config *config = state->config;
+ u32 reg, div, clk_sel;
+
+ reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
+ clk_sel = ((STV090x_GETFIELD(reg, SELX1RATIO_FIELD) == 1) ? 4 : 6);
+
+ div = ((clk_sel * mclk) / config->xtal) - 1;
+
+ reg = stv090x_read_reg(state, STV090x_NCOARSE);
+ STV090x_SETFIELD(reg, M_DIV_FIELD, div);
+ if (stv090x_write_reg(state, STV090x_NCOARSE, reg) < 0)
+ goto err;
+
+ state->mclk = stv090x_get_mclk(state);
+
+ /*Set the DiseqC frequency to 22KHz */
+ div = state->mclk / 704000;
+ if (STV090x_WRITE_DEMOD(state, F22TX, div) < 0)
+ goto err;
+ if (STV090x_WRITE_DEMOD(state, F22RX, div) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_set_tspath(struct stv090x_state *state)
+{
+ u32 reg;
+
+ if (state->dev_ver >= 0x20) {
+ switch (state->config->ts1_mode) {
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ case STV090x_TSMODE_DVBCI:
+ switch (state->config->ts2_mode) {
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ default:
+ stv090x_write_reg(state, STV090x_TSGENERAL, 0x00);
+ break;
+
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ case STV090x_TSMODE_DVBCI:
+ if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x06) < 0) /* Mux'd stream mode */
+ goto err;
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGM);
+ STV090x_SETFIELD_Px(reg, TSFIFO_MANSPEED_FIELD, 3);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGM, reg) < 0)
+ goto err;
+ reg = stv090x_read_reg(state, STV090x_P2_TSCFGM);
+ STV090x_SETFIELD_Px(reg, TSFIFO_MANSPEED_FIELD, 3);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGM, reg) < 0)
+ goto err;
+ if (stv090x_write_reg(state, STV090x_P1_TSSPEED, 0x14) < 0)
+ goto err;
+ if (stv090x_write_reg(state, STV090x_P2_TSSPEED, 0x28) < 0)
+ goto err;
+ break;
+ }
+ break;
+
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ default:
+ switch (state->config->ts2_mode) {
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ default:
+ if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ case STV090x_TSMODE_DVBCI:
+ if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0a) < 0)
+ goto err;
+ break;
+ }
+ break;
+ }
+ } else {
+ switch (state->config->ts1_mode) {
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ case STV090x_TSMODE_DVBCI:
+ switch (state->config->ts2_mode) {
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ default:
+ stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x10);
+ break;
+
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ case STV090x_TSMODE_DVBCI:
+ stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x16);
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGM);
+ STV090x_SETFIELD_Px(reg, TSFIFO_MANSPEED_FIELD, 3);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGM, reg) < 0)
+ goto err;
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGM);
+ STV090x_SETFIELD_Px(reg, TSFIFO_MANSPEED_FIELD, 0);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGM, reg) < 0)
+ goto err;
+ if (stv090x_write_reg(state, STV090x_P1_TSSPEED, 0x14) < 0)
+ goto err;
+ if (stv090x_write_reg(state, STV090x_P2_TSSPEED, 0x28) < 0)
+ goto err;
+ break;
+ }
+ break;
+
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ default:
+ switch (state->config->ts2_mode) {
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ default:
+ stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x14);
+ break;
+
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ case STV090x_TSMODE_DVBCI:
+ stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x12);
+ break;
+ }
+ break;
+ }
+ }
+
+ switch (state->config->ts1_mode) {
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_DVBCI:
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ default:
+ break;
+ }
+
+ switch (state->config->ts2_mode) {
+ case STV090x_TSMODE_PARALLEL_PUNCTURED:
+ reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_DVBCI:
+ reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_SERIAL_PUNCTURED:
+ reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ case STV090x_TSMODE_SERIAL_CONTINUOUS:
+ reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
+ STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+ STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
+ goto err;
+ break;
+
+ default:
+ break;
+ }
+ reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
+ goto err;
+
+ reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x01);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
+ goto err;
+ STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x00);
+ if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_init(struct dvb_frontend *fe)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ const struct stv090x_config *config = state->config;
+ u32 reg;
+
+ if (stv090x_wakeup(fe) < 0) {
+ dprintk(FE_ERROR, 1, "Error waking device");
+ goto err;
+ }
+
+ if (stv090x_ldpc_mode(state, state->demod_mode) < 0)
+ goto err;
+
+ reg = STV090x_READ_DEMOD(state, TNRCFG2);
+ STV090x_SETFIELD_Px(reg, TUN_IQSWAP_FIELD, state->inversion);
+ if (STV090x_WRITE_DEMOD(state, TNRCFG2, reg) < 0)
+ goto err;
+ reg = STV090x_READ_DEMOD(state, DEMOD);
+ STV090x_SETFIELD_Px(reg, ROLLOFF_CONTROL_FIELD, state->rolloff);
+ if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0)
+ goto err;
+
+ if (stv090x_i2c_gate_ctrl(fe, 1) < 0)
+ goto err;
+
+ if (config->tuner_set_mode) {
+ if (config->tuner_set_mode(fe, TUNER_WAKE) < 0)
+ goto err;
+ }
+
+ if (config->tuner_init) {
+ if (config->tuner_init(fe) < 0)
+ goto err;
+ }
+
+ if (stv090x_i2c_gate_ctrl(fe, 0) < 0)
+ goto err;
+
+ if (stv090x_set_tspath(state) < 0)
+ goto err;
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static int stv090x_setup(struct dvb_frontend *fe)
+{
+ struct stv090x_state *state = fe->demodulator_priv;
+ const struct stv090x_config *config = state->config;
+ const struct stv090x_reg *stv090x_initval = NULL;
+ const struct stv090x_reg *stv090x_cut20_val = NULL;
+ unsigned long t1_size = 0, t2_size = 0;
+ u32 reg = 0;
+
+ int i;
+
+ if (state->device == STV0900) {
+ dprintk(FE_DEBUG, 1, "Initializing STV0900");
+ stv090x_initval = stv0900_initval;
+ t1_size = ARRAY_SIZE(stv0900_initval);
+ stv090x_cut20_val = stv0900_cut20_val;
+ t2_size = ARRAY_SIZE(stv0900_cut20_val);
+ } else if (state->device == STV0903) {
+ dprintk(FE_DEBUG, 1, "Initializing STV0903");
+ stv090x_initval = stv0903_initval;
+ t1_size = ARRAY_SIZE(stv0903_initval);
+ stv090x_cut20_val = stv0903_cut20_val;
+ t2_size = ARRAY_SIZE(stv0903_cut20_val);
+ }
+
+ /* STV090x init */
+ if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c) < 0) /* Stop Demod */
+ goto err;
+
+ msleep(5);
+
+ if (STV090x_WRITE_DEMOD(state, TNRCFG, 0x6c) < 0) /* check register ! (No Tuner Mode) */
+ goto err;
+
+ STV090x_SETFIELD_Px(reg, ENARPT_LEVEL_FIELD, config->repeater_level);
+ if (STV090x_WRITE_DEMOD(state, I2CRPT, reg) < 0) /* repeater OFF */
+ goto err;
+
+ if (stv090x_write_reg(state, STV090x_NCOARSE, 0x13) < 0) /* set PLL divider */
+ goto err;
+ msleep(5);
+ if (stv090x_write_reg(state, STV090x_I2CCFG, 0x08) < 0) /* 1/41 oversampling */
+ goto err;
+ if (stv090x_write_reg(state, STV090x_SYNTCTRL, 0x20 | config->clk_mode) < 0) /* enable PLL */
+ goto err;
+ msleep(5);
+
+ /* write initval */
+ dprintk(FE_DEBUG, 1, "Setting up initial values");
+ for (i = 0; i < t1_size; i++) {
+ if (stv090x_write_reg(state, stv090x_initval[i].addr, stv090x_initval[i].data) < 0)
+ goto err;
+ }
+
+ state->dev_ver = stv090x_read_reg(state, STV090x_MID);
+ if (state->dev_ver >= 0x20) {
+ if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c) < 0)
+ goto err;
+
+ /* write cut20_val*/
+ dprintk(FE_DEBUG, 1, "Setting up Cut 2.0 initial values");
+ for (i = 0; i < t2_size; i++) {
+ if (stv090x_write_reg(state, stv090x_cut20_val[i].addr, stv090x_cut20_val[i].data) < 0)
+ goto err;
+ }
+
+ } else if (state->dev_ver < 0x20) {
+ dprintk(FE_ERROR, 1, "ERROR: Unsupported Cut: 0x%02x!",
+ state->dev_ver);
+
+ goto err;
+ } else if (state->dev_ver > 0x30) {
+ /* we shouldn't bail out from here */
+ dprintk(FE_ERROR, 1, "INFO: Cut: 0x%02x probably incomplete support!",
+ state->dev_ver);
+ }
+
+ if (stv090x_write_reg(state, STV090x_TSTRES0, 0x80) < 0)
+ goto err;
+ if (stv090x_write_reg(state, STV090x_TSTRES0, 0x00) < 0)
+ goto err;
+
+ stv090x_set_mclk(state, 135000000, config->xtal); /* 135 Mhz */
+ msleep(5);
+ if (stv090x_write_reg(state, STV090x_SYNTCTRL, 0x20 | config->clk_mode) < 0)
+ goto err;
+ stv090x_get_mclk(state);
+
+ return 0;
+err:
+ dprintk(FE_ERROR, 1, "I/O error");
+ return -1;
+}
+
+static struct dvb_frontend_ops stv090x_ops = {
+
+ .info = {
+ .name = "STV090x Multistandard",
+ .type = FE_QPSK,
+ .frequency_min = 950000,
+ .frequency_max = 2150000,
+ .frequency_stepsize = 0,
+ .frequency_tolerance = 0,
+ .symbol_rate_min = 1000000,
+ .symbol_rate_max = 45000000,
+ .caps = FE_CAN_INVERSION_AUTO |
+ FE_CAN_FEC_AUTO |
+ FE_CAN_QPSK |
+ FE_CAN_2G_MODULATION
+ },
+
+ .release = stv090x_release,
+ .init = stv090x_init,
+
+ .sleep = stv090x_sleep,
+ .get_frontend_algo = stv090x_frontend_algo,
+
+ .i2c_gate_ctrl = stv090x_i2c_gate_ctrl,
+
+ .diseqc_send_master_cmd = stv090x_send_diseqc_msg,
+ .diseqc_send_burst = stv090x_send_diseqc_burst,
+ .diseqc_recv_slave_reply = stv090x_recv_slave_reply,
+ .set_tone = stv090x_set_tone,
+
+ .search = stv090x_search,
+ .read_status = stv090x_read_status,
+ .read_ber = stv090x_read_per,
+ .read_signal_strength = stv090x_read_signal_strength,
+ .read_snr = stv090x_read_cnr
+};
+
+
+struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
+ struct i2c_adapter *i2c,
+ enum stv090x_demodulator demod)
+{
+ struct stv090x_state *state = NULL;
+
+ state = kzalloc(sizeof (struct stv090x_state), GFP_KERNEL);
+ if (state == NULL)
+ goto error;
+
+ state->verbose = &verbose;
+ state->config = config;
+ state->i2c = i2c;
+ state->frontend.ops = stv090x_ops;
+ state->frontend.demodulator_priv = state;
+ state->demod = demod;
+ state->demod_mode = config->demod_mode; /* Single or Dual mode */
+ state->device = config->device;
+ state->rolloff = STV090x_RO_35; /* default */
+
+ if (state->demod == STV090x_DEMODULATOR_0)
+ mutex_init(&demod_lock);
+
+ if (stv090x_sleep(&state->frontend) < 0) {
+ dprintk(FE_ERROR, 1, "Error putting device to sleep");
+ goto error;
+ }
+
+ if (stv090x_setup(&state->frontend) < 0) {
+ dprintk(FE_ERROR, 1, "Error setting up device");
+ goto error;
+ }
+ if (stv090x_wakeup(&state->frontend) < 0) {
+ dprintk(FE_ERROR, 1, "Error waking device");
+ goto error;
+ }
+
+ dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x\n",
+ state->device == STV0900 ? "STV0900" : "STV0903",
+ demod,
+ state->dev_ver);
+
+ return &state->frontend;
+
+error:
+ kfree(state);
+ return NULL;
+}
+EXPORT_SYMBOL(stv090x_attach);
+MODULE_PARM_DESC(verbose, "Set Verbosity level");
+MODULE_AUTHOR("Manu Abraham");
+MODULE_DESCRIPTION("STV090x Multi-Std Broadcast frontend");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/stv090x.h b/drivers/media/dvb/frontends/stv090x.h
new file mode 100644
index 000000000000..e968c98bb70f
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv090x.h
@@ -0,0 +1,106 @@
+/*
+ STV0900/0903 Multistandard Broadcast Frontend driver
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __STV090x_H
+#define __STV090x_H
+
+enum stv090x_demodulator {
+ STV090x_DEMODULATOR_0 = 1,
+ STV090x_DEMODULATOR_1
+};
+
+enum stv090x_device {
+ STV0903 = 0,
+ STV0900,
+};
+
+enum stv090x_mode {
+ STV090x_DUAL = 0,
+ STV090x_SINGLE
+};
+
+enum stv090x_tsmode {
+ STV090x_TSMODE_SERIAL_PUNCTURED = 1,
+ STV090x_TSMODE_SERIAL_CONTINUOUS,
+ STV090x_TSMODE_PARALLEL_PUNCTURED,
+ STV090x_TSMODE_DVBCI
+};
+
+enum stv090x_clkmode {
+ STV090x_CLK_INT = 0, /* Clk i/p = CLKI */
+ STV090x_CLK_EXT = 2 /* Clk i/p = XTALI */
+};
+
+enum stv090x_i2crpt {
+ STV090x_RPTLEVEL_256 = 0,
+ STV090x_RPTLEVEL_128 = 1,
+ STV090x_RPTLEVEL_64 = 2,
+ STV090x_RPTLEVEL_32 = 3,
+ STV090x_RPTLEVEL_16 = 4,
+ STV090x_RPTLEVEL_8 = 5,
+ STV090x_RPTLEVEL_4 = 6,
+ STV090x_RPTLEVEL_2 = 7,
+};
+
+struct stv090x_config {
+ enum stv090x_device device;
+ enum stv090x_mode demod_mode;
+ enum stv090x_clkmode clk_mode;
+
+ u32 xtal; /* default: 8000000 */
+ u8 address; /* default: 0x68 */
+
+ u32 ref_clk; /* default: 16000000 FIXME to tuner config */
+
+ u8 ts1_mode;
+ u8 ts2_mode;
+
+ enum stv090x_i2crpt repeater_level;
+
+ int (*tuner_init) (struct dvb_frontend *fe);
+ int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode);
+ int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency);
+ int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency);
+ int (*tuner_set_bandwidth) (struct dvb_frontend *fe, u32 bandwidth);
+ int (*tuner_get_bandwidth) (struct dvb_frontend *fe, u32 *bandwidth);
+ int (*tuner_set_bbgain) (struct dvb_frontend *fe, u32 gain);
+ int (*tuner_get_bbgain) (struct dvb_frontend *fe, u32 *gain);
+ int (*tuner_set_refclk) (struct dvb_frontend *fe, u32 refclk);
+ int (*tuner_get_status) (struct dvb_frontend *fe, u32 *status);
+};
+
+#if defined(CONFIG_DVB_STV090x) || (defined(CONFIG_DVB_STV090x_MODULE) && defined(MODULE))
+
+extern struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
+ struct i2c_adapter *i2c,
+ enum stv090x_demodulator demod);
+#else
+
+static inline struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
+ struct i2c_adapter *i2c,
+ enum stv090x_demodulator demod)
+{
+ printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+ return NULL;
+}
+#endif /* CONFIG_DVB_STV090x */
+
+#endif /* __STV090x_H */
diff --git a/drivers/media/dvb/frontends/stv090x_priv.h b/drivers/media/dvb/frontends/stv090x_priv.h
new file mode 100644
index 000000000000..5a4a01740d88
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv090x_priv.h
@@ -0,0 +1,269 @@
+/*
+ STV0900/0903 Multistandard Broadcast Frontend driver
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __STV090x_PRIV_H
+#define __STV090x_PRIV_H
+
+#include "dvb_frontend.h"
+
+#define FE_ERROR 0
+#define FE_NOTICE 1
+#define FE_INFO 2
+#define FE_DEBUG 3
+#define FE_DEBUGREG 4
+
+#define dprintk(__y, __z, format, arg...) do { \
+ if (__z) { \
+ if ((verbose > FE_ERROR) && (verbose > __y)) \
+ printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_NOTICE) && (verbose > __y)) \
+ printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_INFO) && (verbose > __y)) \
+ printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_DEBUG) && (verbose > __y)) \
+ printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
+ } else { \
+ if (verbose > __y) \
+ printk(format, ##arg); \
+ } \
+} while (0)
+
+#define STV090x_READ_DEMOD(__state, __reg) (( \
+ (__state)->demod == STV090x_DEMODULATOR_1) ? \
+ stv090x_read_reg(__state, STV090x_P2_##__reg) : \
+ stv090x_read_reg(__state, STV090x_P1_##__reg))
+
+#define STV090x_WRITE_DEMOD(__state, __reg, __data) (( \
+ (__state)->demod == STV090x_DEMODULATOR_1) ? \
+ stv090x_write_reg(__state, STV090x_P2_##__reg, __data) :\
+ stv090x_write_reg(__state, STV090x_P1_##__reg, __data))
+
+#define STV090x_ADDR_OFFST(__state, __x) (( \
+ (__state->demod) == STV090x_DEMODULATOR_1) ? \
+ STV090x_P1_##__x : \
+ STV090x_P2_##__x)
+
+
+#define STV090x_SETFIELD(mask, bitf, val) (mask = (mask & (~(((1 << STV090x_WIDTH_##bitf) - 1) <<\
+ STV090x_OFFST_##bitf))) | \
+ (val << STV090x_OFFST_##bitf))
+
+#define STV090x_GETFIELD(val, bitf) ((val >> STV090x_OFFST_##bitf) & ((1 << STV090x_WIDTH_##bitf) - 1))
+
+
+#define STV090x_SETFIELD_Px(mask, bitf, val) (mask = (mask & (~(((1 << STV090x_WIDTH_Px_##bitf) - 1) <<\
+ STV090x_OFFST_Px_##bitf))) | \
+ (val << STV090x_OFFST_Px_##bitf))
+
+#define STV090x_GETFIELD_Px(val, bitf) ((val >> STV090x_OFFST_Px_##bitf) & ((1 << STV090x_WIDTH_Px_##bitf) - 1))
+
+#define MAKEWORD16(__a, __b) (((__a) << 8) | (__b))
+
+#define MSB(__x) ((__x >> 8) & 0xff)
+#define LSB(__x) (__x & 0xff)
+
+
+#define STV090x_IQPOWER_THRESHOLD 30
+#define STV090x_SEARCH_AGC2_TH_CUT20 700
+#define STV090x_SEARCH_AGC2_TH_CUT30 1200
+
+#define STV090x_SEARCH_AGC2_TH(__ver) \
+ ((__ver <= 0x20) ? \
+ STV090x_SEARCH_AGC2_TH_CUT20 : \
+ STV090x_SEARCH_AGC2_TH_CUT30)
+
+enum stv090x_signal_state {
+ STV090x_NOCARRIER,
+ STV090x_NODATA,
+ STV090x_DATAOK,
+ STV090x_RANGEOK,
+ STV090x_OUTOFRANGE
+};
+
+enum stv090x_fec {
+ STV090x_PR12 = 0,
+ STV090x_PR23,
+ STV090x_PR34,
+ STV090x_PR45,
+ STV090x_PR56,
+ STV090x_PR67,
+ STV090x_PR78,
+ STV090x_PR89,
+ STV090x_PR910,
+ STV090x_PRERR
+};
+
+enum stv090x_modulation {
+ STV090x_QPSK,
+ STV090x_8PSK,
+ STV090x_16APSK,
+ STV090x_32APSK,
+ STV090x_UNKNOWN
+};
+
+enum stv090x_frame {
+ STV090x_LONG_FRAME,
+ STV090x_SHORT_FRAME
+};
+
+enum stv090x_pilot {
+ STV090x_PILOTS_OFF,
+ STV090x_PILOTS_ON
+};
+
+enum stv090x_rolloff {
+ STV090x_RO_35,
+ STV090x_RO_25,
+ STV090x_RO_20
+};
+
+enum stv090x_inversion {
+ STV090x_IQ_AUTO,
+ STV090x_IQ_NORMAL,
+ STV090x_IQ_SWAP
+};
+
+enum stv090x_modcod {
+ STV090x_DUMMY_PLF = 0,
+ STV090x_QPSK_14,
+ STV090x_QPSK_13,
+ STV090x_QPSK_25,
+ STV090x_QPSK_12,
+ STV090x_QPSK_35,
+ STV090x_QPSK_23,
+ STV090x_QPSK_34,
+ STV090x_QPSK_45,
+ STV090x_QPSK_56,
+ STV090x_QPSK_89,
+ STV090x_QPSK_910,
+ STV090x_8PSK_35,
+ STV090x_8PSK_23,
+ STV090x_8PSK_34,
+ STV090x_8PSK_56,
+ STV090x_8PSK_89,
+ STV090x_8PSK_910,
+ STV090x_16APSK_23,
+ STV090x_16APSK_34,
+ STV090x_16APSK_45,
+ STV090x_16APSK_56,
+ STV090x_16APSK_89,
+ STV090x_16APSK_910,
+ STV090x_32APSK_34,
+ STV090x_32APSK_45,
+ STV090x_32APSK_56,
+ STV090x_32APSK_89,
+ STV090x_32APSK_910,
+ STV090x_MODCODE_UNKNOWN
+};
+
+enum stv090x_search {
+ STV090x_SEARCH_DSS = 0,
+ STV090x_SEARCH_DVBS1,
+ STV090x_SEARCH_DVBS2,
+ STV090x_SEARCH_AUTO
+};
+
+enum stv090x_algo {
+ STV090x_BLIND_SEARCH,
+ STV090x_COLD_SEARCH,
+ STV090x_WARM_SEARCH
+};
+
+enum stv090x_delsys {
+ STV090x_ERROR = 0,
+ STV090x_DVBS1 = 1,
+ STV090x_DVBS2,
+ STV090x_DSS
+};
+
+struct stv090x_long_frame_crloop {
+ enum stv090x_modcod modcod;
+
+ u8 crl_pilots_on_2;
+ u8 crl_pilots_off_2;
+ u8 crl_pilots_on_5;
+ u8 crl_pilots_off_5;
+ u8 crl_pilots_on_10;
+ u8 crl_pilots_off_10;
+ u8 crl_pilots_on_20;
+ u8 crl_pilots_off_20;
+ u8 crl_pilots_on_30;
+ u8 crl_pilots_off_30;
+};
+
+struct stv090x_short_frame_crloop {
+ enum stv090x_modulation modulation;
+
+ u8 crl_2; /* SR < 3M */
+ u8 crl_5; /* 3 < SR <= 7M */
+ u8 crl_10; /* 7 < SR <= 15M */
+ u8 crl_20; /* 10 < SR <= 25M */
+ u8 crl_30; /* 10 < SR <= 45M */
+};
+
+struct stv090x_reg {
+ u16 addr;
+ u8 data;
+};
+
+struct stv090x_tab {
+ s32 real;
+ s32 read;
+};
+
+struct stv090x_state {
+ enum stv090x_device device;
+ enum stv090x_demodulator demod;
+ enum stv090x_mode demod_mode;
+ u32 dev_ver;
+
+ struct i2c_adapter *i2c;
+ const struct stv090x_config *config;
+ struct dvb_frontend frontend;
+
+ u32 *verbose; /* Cached module verbosity */
+
+ enum stv090x_delsys delsys;
+ enum stv090x_fec fec;
+ enum stv090x_modulation modulation;
+ enum stv090x_modcod modcod;
+ enum stv090x_search search_mode;
+ enum stv090x_frame frame_len;
+ enum stv090x_pilot pilots;
+ enum stv090x_rolloff rolloff;
+ enum stv090x_inversion inversion;
+ enum stv090x_algo algo;
+
+ u32 frequency;
+ u32 srate;
+
+ s32 mclk; /* Masterclock Divider factor */
+ s32 tuner_bw;
+
+ u32 tuner_refclk;
+
+ s32 search_range;
+
+ s32 DemodTimeout;
+ s32 FecTimeout;
+};
+
+#endif /* __STV090x_PRIV_H */
diff --git a/drivers/media/dvb/frontends/stv090x_reg.h b/drivers/media/dvb/frontends/stv090x_reg.h
new file mode 100644
index 000000000000..57b6abbbd32d
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv090x_reg.h
@@ -0,0 +1,2373 @@
+/*
+ STV0900/0903 Multistandard Broadcast Frontend driver
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __STV090x_REG_H
+#define __STV090x_REG_H
+
+#define STV090x_MID 0xf100
+#define STV090x_OFFST_MCHIP_IDENT_FIELD 4
+#define STV090x_WIDTH_MCHIP_IDENT_FIELD 4
+#define STV090x_OFFST_MRELEASE_FIELD 0
+#define STV090x_WIDTH_MRELEASE_FIELD 4
+
+#define STV090x_DACR1 0xf113
+#define STV090x_OFFST_DACR1_MODE_FIELD 5
+#define STV090x_WIDTH_DACR1_MODE_FIELD 3
+#define STV090x_OFFST_DACR1_VALUE_FIELD 0
+#define STV090x_WIDTH_DACR1_VALUE_FIELD 4
+
+#define STV090x_DACR2 0xf114
+#define STV090x_OFFST_DACR2_VALUE_FIELD 0
+#define STV090x_WIDTH_DACR2_VALUE_FIELD 8
+
+#define STV090x_OUTCFG 0xf11c
+#define STV090x_OFFST_OUTSERRS1_HZ_FIELD 6
+#define STV090x_WIDTH_OUTSERRS1_HZ_FIELD 1
+#define STV090x_OFFST_OUTSERRS2_HZ_FIELD 5
+#define STV090x_WIDTH_OUTSERRS2_HZ_FIELD 1
+#define STV090x_OFFST_OUTSERRS3_HZ_FIELD 4
+#define STV090x_WIDTH_OUTPARRS3_HZ_FIELD 1
+#define STV090x_OFFST_OUTPARRS3_HZ_FIELD 3
+#define STV090x_WIDTH_OUTPARRS3_HZ_FIELD 1
+
+#define STV090x_MODECFG 0xf11d
+
+#define STV090x_IRQSTATUS3 0xf120
+#define STV090x_OFFST_SPLL_LOCK_FIELD 5
+#define STV090x_WIDTH_SPLL_LOCK_FIELD 1
+#define STV090x_OFFST_SSTREAM_LCK_3_FIELD 4
+#define STV090x_WIDTH_SSTREAM_LCK_3_FIELD 1
+#define STV090x_OFFST_SSTREAM_LCK_2_FIELD 3
+#define STV090x_WIDTH_SSTREAM_LCK_2_FIELD 1
+#define STV090x_OFFST_SSTREAM_LCK_1_FIELD 2
+#define STV090x_WIDTH_SSTREAM_LCK_1_FIELD 1
+#define STV090x_OFFST_SDVBS1_PRF_2_FIELD 1
+#define STV090x_WIDTH_SDVBS1_PRF_2_FIELD 1
+#define STV090x_OFFST_SDVBS1_PRF_1_FIELD 0
+#define STV090x_WIDTH_SDVBS1_PRF_1_FIELD 1
+
+#define STV090x_IRQSTATUS2 0xf121
+#define STV090x_OFFST_SSPY_ENDSIM_3_FIELD 7
+#define STV090x_WIDTH_SSPY_ENDSIM_3_FIELD 1
+#define STV090x_OFFST_SSPY_ENDSIM_2_FIELD 6
+#define STV090x_WIDTH_SSPY_ENDSIM_2_FIELD 1
+#define STV090x_OFFST_SSPY_ENDSIM_1_FIELD 5
+#define STV090x_WIDTH_SSPY_ENDSIM_1_FIELD 1
+#define STV090x_OFFST_SPKTDEL_ERROR_2_FIELD 4
+#define STV090x_WIDTH_SPKTDEL_ERROR_2_FIELD 1
+#define STV090x_OFFST_SPKTDEL_LOCKB_2_FIELD 3
+#define STV090x_WIDTH_SPKTDEL_LOCKB_2_FIELD 1
+#define STV090x_OFFST_SPKTDEL_LOCK_2_FIELD 2
+#define STV090x_WIDTH_SPKTDEL_LOCK_2_FIELD 1
+#define STV090x_OFFST_SPKTDEL_ERROR_1_FIELD 1
+#define STV090x_WIDTH_SPKTDEL_ERROR_1_FIELD 1
+#define STV090x_OFFST_SPKTDEL_LOCKB_1_FIELD 0
+#define STV090x_WIDTH_SPKTDEL_LOCKB_1_FIELD 1
+
+#define STV090x_IRQSTATUS1 0xf122
+#define STV090x_OFFST_SPKTDEL_LOCK_1_FIELD 7
+#define STV090x_WIDTH_SPKTDEL_LOCK_1_FIELD 1
+#define STV090x_OFFST_SDEMOD_LOCKB_2_FIELD 2
+#define STV090x_WIDTH_SDEMOD_LOCKB_2_FIELD 1
+#define STV090x_OFFST_SDEMOD_LOCK_2_FIELD 1
+#define STV090x_WIDTH_SDEMOD_LOCK_2_FIELD 1
+#define STV090x_OFFST_SDEMOD_IRQ_2_FIELD 0
+#define STV090x_WIDTH_SDEMOD_IRQ_2_FIELD 1
+
+#define STV090x_IRQSTATUS0 0xf123
+#define STV090x_OFFST_SDEMOD_LOCKB_1_FIELD 7
+#define STV090x_WIDTH_SDEMOD_LOCKB_1_FIELD 1
+#define STV090x_OFFST_SDEMOD_LOCK_1_FIELD 6
+#define STV090x_WIDTH_SDEMOD_LOCK_1_FIELD 1
+#define STV090x_OFFST_SDEMOD_IRQ_1_FIELD 5
+#define STV090x_WIDTH_SDEMOD_IRQ_1_FIELD 1
+#define STV090x_OFFST_SBCH_ERRFLAG_FIELD 4
+#define STV090x_WIDTH_SBCH_ERRFLAG_FIELD 1
+#define STV090x_OFFST_SDISEQC2RX_IRQ_FIELD 3
+#define STV090x_WIDTH_SDISEQC2RX_IRQ_FIELD 1
+#define STV090x_OFFST_SDISEQC2TX_IRQ_FIELD 2
+#define STV090x_WIDTH_SDISEQC2TX_IRQ_FIELD 1
+#define STV090x_OFFST_SDISEQC1RX_IRQ_FIELD 1
+#define STV090x_WIDTH_SDISEQC1RX_IRQ_FIELD 1
+#define STV090x_OFFST_SDISEQC1TX_IRQ_FIELD 0
+#define STV090x_WIDTH_SDISEQC1TX_IRQ_FIELD 1
+
+#define STV090x_IRQMASK3 0xf124
+#define STV090x_OFFST_MPLL_LOCK_FIELD 5
+#define STV090x_WIDTH_MPLL_LOCK_FIELD 1
+#define STV090x_OFFST_MSTREAM_LCK_3_FIELD 2
+#define STV090x_WIDTH_MSTREAM_LCK_3_FIELD 3
+#define STV090x_OFFST_MSTREAM_LCK_2_FIELD 2
+#define STV090x_WIDTH_MSTREAM_LCK_2_FIELD 3
+#define STV090x_OFFST_MSTREAM_LCK_1_FIELD 2
+#define STV090x_WIDTH_MSTREAM_LCK_1_FIELD 3
+#define STV090x_OFFST_MDVBS1_PRF_2_FIELD 1
+#define STV090x_WIDTH_MDVBS1_PRF_2_FIELD 1
+#define STV090x_OFFST_MDVBS1_PRF_1_FIELD 0
+#define STV090x_WIDTH_MDVBS1_PRF_1_FIELD 1
+
+#define STV090x_IRQMASK2 0xf125
+#define STV090x_OFFST_MSPY_ENDSIM_3_FIELD 5
+#define STV090x_WIDTH_MSPY_ENDSIM_3_FIELD 3
+#define STV090x_OFFST_MSPY_ENDSIM_2_FIELD 5
+#define STV090x_WIDTH_MSPY_ENDSIM_2_FIELD 3
+#define STV090x_OFFST_MSPY_ENDSIM_1_FIELD 5
+#define STV090x_WIDTH_MSPY_ENDSIM_1_FIELD 3
+#define STV090x_OFFST_MPKTDEL_ERROR_2_FIELD 4
+#define STV090x_WIDTH_MPKTDEL_ERROR_2_FIELD 1
+#define STV090x_OFFST_MPKTDEL_LOCKB_2_FIELD 3
+#define STV090x_WIDTH_MPKTDEL_LOCKB_2_FIELD 1
+#define STV090x_OFFST_MPKTDEL_LOCK_2_FIELD 2
+#define STV090x_WIDTH_MPKTDEL_LOCK_2_FIELD 1
+#define STV090x_OFFST_MPKTDEL_ERROR_1_FIELD 1
+#define STV090x_WIDTH_MPKTDEL_ERROR_1_FIELD 1
+#define STV090x_OFFST_MPKTDEL_LOCKB_1_FIELD 0
+#define STV090x_WIDTH_MPKTDEL_LOCKB_1_FIELD 1
+
+#define STV090x_IRQMASK1 0xf126
+#define STV090x_OFFST_MPKTDEL_LOCK_1_FIELD 7
+#define STV090x_WIDTH_MPKTDEL_LOCK_1_FIELD 1
+#define STV090x_OFFST_MEXTPINB2_FIELD 6
+#define STV090x_WIDTH_MEXTPINB2_FIELD 1
+#define STV090x_OFFST_MEXTPIN2_FIELD 5
+#define STV090x_WIDTH_MEXTPIN2_FIELD 1
+#define STV090x_OFFST_MEXTPINB1_FIELD 4
+#define STV090x_WIDTH_MEXTPINB1_FIELD 1
+#define STV090x_OFFST_MEXTPIN1_FIELD 3
+#define STV090x_WIDTH_MEXTPIN1_FIELD 1
+#define STV090x_OFFST_MDEMOD_LOCKB_2_FIELD 2
+#define STV090x_WIDTH_MDEMOD_LOCKB_2_FIELD 1
+#define STV090x_OFFST_MDEMOD_LOCK_2_FIELD 1
+#define STV090x_WIDTH_MDEMOD_LOCK_2_FIELD 1
+#define STV090x_OFFST_MDEMOD_IRQ_2_FIELD 0
+#define STV090x_WIDTH_MDEMOD_IRQ_2_FIELD 1
+
+#define STV090x_IRQMASK0 0xf127
+#define STV090x_OFFST_MDEMOD_LOCKB_1_FIELD 7
+#define STV090x_WIDTH_MDEMOD_LOCKB_1_FIELD 1
+#define STV090x_OFFST_MDEMOD_LOCK_1_FIELD 6
+#define STV090x_WIDTH_MDEMOD_LOCK_1_FIELD 1
+#define STV090x_OFFST_MDEMOD_IRQ_1_FIELD 5
+#define STV090x_WIDTH_MDEMOD_IRQ_1_FIELD 1
+#define STV090x_OFFST_MBCH_ERRFLAG_FIELD 4
+#define STV090x_WIDTH_MBCH_ERRFLAG_FIELD 1
+#define STV090x_OFFST_MDISEQC2RX_IRQ_FIELD 3
+#define STV090x_WIDTH_MDISEQC2RX_IRQ_FIELD 1
+#define STV090x_OFFST_MDISEQC2TX_IRQ_FIELD 2
+#define STV090x_WIDTH_MDISEQC2TX_IRQ_FIELD 1
+#define STV090x_OFFST_MDISEQC1RX_IRQ_FIELD 1
+#define STV090x_WIDTH_MDISEQC1RX_IRQ_FIELD 1
+#define STV090x_OFFST_MDISEQC1TX_IRQ_FIELD 0
+#define STV090x_WIDTH_MDISEQC1TX_IRQ_FIELD 1
+
+#define STV090x_I2CCFG 0xf129
+#define STV090x_OFFST_12C_FASTMODE_FIELD 3
+#define STV090x_WIDTH_12C_FASTMODE_FIELD 1
+#define STV090x_OFFST_12CADDR_INC_FIELD 0
+#define STV090x_WIDTH_12CADDR_INC_FIELD 2
+
+#define STV090x_Px_I2CRPT(__x) (0xf12a + (__x - 1) * 0x1)
+#define STV090x_P1_I2CRPT STV090x_Px_I2CRPT(1)
+#define STV090x_P2_I2CRPT STV090x_Px_I2CRPT(2)
+#define STV090x_OFFST_Px_I2CT_ON_FIELD 7
+#define STV090x_WIDTH_Px_I2CT_ON_FIELD 1
+#define STV090x_OFFST_Px_ENARPT_LEVEL_FIELD 4
+#define STV090x_WIDTH_Px_ENARPT_LEVEL_FIELD 3
+#define STV090x_OFFST_Px_SCLT_DELAY_FIELD 3
+#define STV090x_WIDTH_Px_SCLT_DELAY_FIELD 1
+#define STV090x_OFFST_Px_STOP_ENABLE_FIELD 2
+#define STV090x_WIDTH_Px_STOP_ENABLE_FIELD 1
+#define STV090x_OFFST_Px_STOP_SDAT2SDA_FIELD 1
+#define STV090x_WIDTH_Px_STOP_SDAT2SDA_FIELD 1
+
+#define STV090x_CLKI2CFG 0xf140
+#define STV090x_OFFST_CLKI2_OPD_FIELD 7
+#define STV090x_WIDTH_CLKI2_OPD_FIELD 1
+#define STV090x_OFFST_CLKI2_CONFIG_FIELD 1
+#define STV090x_WIDTH_CLKI2_CONFIG_FIELD 6
+#define STV090x_OFFST_CLKI2_XOR_FIELD 0
+#define STV090x_WIDTH_CLKI2_XOR_FIELD 1
+
+#define STV090x_GPIOxCFG(__x) (0xf141 + (__x - 1))
+#define STV090x_GPIO1CFG STV090x_GPIOxCFG(1)
+#define STV090x_GPIO2CFG STV090x_GPIOxCFG(2)
+#define STV090x_GPIO3CFG STV090x_GPIOxCFG(3)
+#define STV090x_GPIO4CFG STV090x_GPIOxCFG(4)
+#define STV090x_GPIO5CFG STV090x_GPIOxCFG(5)
+#define STV090x_GPIO6CFG STV090x_GPIOxCFG(6)
+#define STV090x_GPIO7CFG STV090x_GPIOxCFG(7)
+#define STV090x_GPIO8CFG STV090x_GPIOxCFG(8)
+#define STV090x_GPIO9CFG STV090x_GPIOxCFG(9)
+#define STV090x_GPIO10CFG STV090x_GPIOxCFG(10)
+#define STV090x_GPIO11CFG STV090x_GPIOxCFG(11)
+#define STV090x_GPIO12CFG STV090x_GPIOxCFG(12)
+#define STV090x_GPIO13CFG STV090x_GPIOxCFG(13)
+#define STV090x_OFFST_GPIOx_OPD_FIELD 7
+#define STV090x_WIDTH_GPIOx_OPD_FIELD 1
+#define STV090x_OFFST_GPIOx_CONFIG_FIELD 1
+#define STV090x_WIDTH_GPIOx_CONFIG_FIELD 6
+#define STV090x_OFFST_GPIOx_XOR_FIELD 0
+#define STV090x_WIDTH_GPIOx_XOR_FIELD 1
+
+#define STV090x_CSxCFG(__x) (0xf14e + __x * 0x1)
+#define STV090x_CS0CFG STV090x_CSxCFG(0)
+#define STV090x_CS1CFG STV090x_CSxCFG(1)
+#define STV090x_OFFST_CSX_OPD_FIELD 7
+#define STV090x_WIDTH_CSX_OPD_FIELD 1
+#define STV090x_OFFST_CSX_CONFIG_FIELD 1
+#define STV090x_WIDTH_CSX_CONFIG_FIELD 6
+#define STV090x_OFFST_CSX_XOR_FIELD 0
+#define STV090x_WIDTH_CSX_XOR_FIELD 1
+
+
+#define STV090x_STDBYCFG 0xf150
+#define STV090x_OFFST_STDBY_OPD_FIELD 7
+#define STV090x_WIDTH_STDBY_OPD_FIELD 1
+#define STV090x_OFFST_STDBY_CONFIG_FIELD 1
+#define STV090x_WIDTH_STDBY_CONFIG_FIELD 6
+#define STV090x_OFFST_STDBY_XOR_FIELD 0
+#define STV090x_WIDTH_STDBY_XOR_FIELD 1
+
+#define STV090x_DIRCLKCFG 0xf151
+#define STV090x_OFFST_DIRCLK_OPD_FIELD 7
+#define STV090x_WIDTH_DIRCLK_OPD_FIELD 1
+#define STV090x_OFFST_DIRCLK_CONFIG_FIELD 1
+#define STV090x_WIDTH_DIRCLK_CONFIG_FIELD 6
+#define STV090x_OFFST_DIRCLK_XOR_FIELD 0
+#define STV090x_WIDTH_DIRCLK_XOR_FIELD 1
+
+
+#define STV090x_AGCRFxCFG(__x) (0xf152 + (__x - 1) * 0x4)
+#define STV090x_AGCRF1CFG STV090x_AGCRFxCFG(1)
+#define STV090x_AGCRF2CFG STV090x_AGCRFxCFG(2)
+#define STV090x_OFFST_AGCRFx_OPD_FIELD 7
+#define STV090x_WIDTH_AGCRFx_OPD_FIELD 1
+#define STV090x_OFFST_AGCRFx_CONFIG_FIELD 1
+#define STV090x_WIDTH_AGCRFx_CONFIG_FIELD 6
+#define STV090x_OFFST_AGCRFx_XOR_FIELD 0
+#define STV090x_WIDTH_AGCRFx_XOR_FIELD 1
+
+#define STV090x_SDATxCFG(__x) (0xf153 + (__x - 1) * 0x4)
+#define STV090x_SDAT1CFG STV090x_SDATxCFG(1)
+#define STV090x_SDAT2CFG STV090x_SDATxCFG(2)
+#define STV090x_OFFST_SDATx_OPD_FIELD 7
+#define STV090x_WIDTH_SDATx_OPD_FIELD 1
+#define STV090x_OFFST_SDATx_CONFIG_FIELD 1
+#define STV090x_WIDTH_SDATx_CONFIG_FIELD 6
+#define STV090x_OFFST_SDATx_XOR_FIELD 0
+#define STV090x_WIDTH_SDATx_XOR_FIELD 1
+
+#define STV090x_SCLTxCFG(__x) (0xf154 + (__x - 1) * 0x4)
+#define STV090x_SCLT1CFG STV090x_SCLTxCFG(1)
+#define STV090x_SCLT2CFG STV090x_SCLTxCFG(2)
+#define STV090x_OFFST_SCLTx_OPD_FIELD 7
+#define STV090x_WIDTH_SCLTx_OPD_FIELD 1
+#define STV090x_OFFST_SCLTx_CONFIG_FIELD 1
+#define STV090x_WIDTH_SCLTx_CONFIG_FIELD 6
+#define STV090x_OFFST_SCLTx_XOR_FIELD 0
+#define STV090x_WIDTH_SCLTx_XOR_FIELD 1
+
+#define STV090x_DISEQCOxCFG(__x) (0xf155 + (__x - 1) * 0x4)
+#define STV090x_DISEQCO1CFG STV090x_DISEQCOxCFG(1)
+#define STV090x_DISEQCO2CFG STV090x_DISEQCOxCFG(2)
+#define STV090x_OFFST_DISEQCOx_OPD_FIELD 7
+#define STV090x_WIDTH_DISEQCOx_OPD_FIELD 1
+#define STV090x_OFFST_DISEQCOx_CONFIG_FIELD 1
+#define STV090x_WIDTH_DISEQCOx_CONFIG_FIELD 6
+#define STV090x_OFFST_DISEQCOx_XOR_FIELD 0
+#define STV090x_WIDTH_DISEQCOx_XOR_FIELD 1
+
+#define STV090x_CLKOUT27CFG 0xf15a
+#define STV090x_OFFST_CLKOUT27_OPD_FIELD 7
+#define STV090x_WIDTH_CLKOUT27_OPD_FIELD 1
+#define STV090x_OFFST_CLKOUT27_CONFIG_FIELD 1
+#define STV090x_WIDTH_CLKOUT27_CONFIG_FIELD 6
+#define STV090x_OFFST_CLKOUT27_XOR_FIELD 0
+#define STV090x_WIDTH_CLKOUT27_XOR_FIELD 1
+
+#define STV090x_ERRORxCFG(__x) (0xf15b + (__x - 1) * 0x5)
+#define STV090x_ERROR1CFG STV090x_ERRORxCFG(1)
+#define STV090x_ERROR2CFG STV090x_ERRORxCFG(2)
+#define STV090x_ERROR3CFG STV090x_ERRORxCFG(3)
+#define STV090x_OFFST_ERRORx_OPD_FIELD 7
+#define STV090x_WIDTH_ERRORx_OPD_FIELD 1
+#define STV090x_OFFST_ERRORx_CONFIG_FIELD 1
+#define STV090x_WIDTH_ERRORx_CONFIG_FIELD 6
+#define STV090x_OFFST_ERRORx_XOR_FIELD 0
+#define STV090x_WIDTH_ERRORx_XOR_FIELD 1
+
+#define STV090x_DPNxCFG(__x) (0xf15c + (__x - 1) * 0x5)
+#define STV090x_DPN1CFG STV090x_DPNxCFG(1)
+#define STV090x_DPN2CFG STV090x_DPNxCFG(2)
+#define STV090x_DPN3CFG STV090x_DPNxCFG(3)
+#define STV090x_OFFST_DPNx_OPD_FIELD 7
+#define STV090x_WIDTH_DPNx_OPD_FIELD 1
+#define STV090x_OFFST_DPNx_CONFIG_FIELD 1
+#define STV090x_WIDTH_DPNx_CONFIG_FIELD 6
+#define STV090x_OFFST_DPNx_XOR_FIELD 0
+#define STV090x_WIDTH_DPNx_XOR_FIELD 1
+
+#define STV090x_STROUTxCFG(__x) (0xf15d + (__x - 1) * 0x5)
+#define STV090x_STROUT1CFG STV090x_STROUTxCFG(1)
+#define STV090x_STROUT2CFG STV090x_STROUTxCFG(2)
+#define STV090x_STROUT3CFG STV090x_STROUTxCFG(3)
+#define STV090x_OFFST_STROUTx_OPD_FIELD 7
+#define STV090x_WIDTH_STROUTx_OPD_FIELD 1
+#define STV090x_OFFST_STROUTx_CONFIG_FIELD 1
+#define STV090x_WIDTH_STROUTx_CONFIG_FIELD 6
+#define STV090x_OFFST_STROUTx_XOR_FIELD 0
+#define STV090x_WIDTH_STROUTx_XOR_FIELD 1
+
+#define STV090x_CLKOUTxCFG(__x) (0xf15e + (__x - 1) * 0x5)
+#define STV090x_CLKOUT1CFG STV090x_CLKOUTxCFG(1)
+#define STV090x_CLKOUT2CFG STV090x_CLKOUTxCFG(2)
+#define STV090x_CLKOUT3CFG STV090x_CLKOUTxCFG(3)
+#define STV090x_OFFST_CLKOUTx_OPD_FIELD 7
+#define STV090x_WIDTH_CLKOUTx_OPD_FIELD 1
+#define STV090x_OFFST_CLKOUTx_CONFIG_FIELD 1
+#define STV090x_WIDTH_CLKOUTx_CONFIG_FIELD 6
+#define STV090x_OFFST_CLKOUTx_XOR_FIELD 0
+#define STV090x_WIDTH_CLKOUTx_XOR_FIELD 1
+
+#define STV090x_DATAxCFG(__x) (0xf15f + (__x - 71) * 0x5)
+#define STV090x_DATA71CFG STV090x_DATAxCFG(71)
+#define STV090x_DATA72CFG STV090x_DATAxCFG(72)
+#define STV090x_DATA73CFG STV090x_DATAxCFG(73)
+#define STV090x_OFFST_DATAx_OPD_FIELD 7
+#define STV090x_WIDTH_DATAx_OPD_FIELD 1
+#define STV090x_OFFST_DATAx_CONFIG_FIELD 1
+#define STV090x_WIDTH_DATAx_CONFIG_FIELD 6
+#define STV090x_OFFST_DATAx_XOR_FIELD 0
+#define STV090x_WIDTH_DATAx_XOR_FIELD 1
+
+#define STV090x_NCOARSE 0xf1b3
+#define STV090x_OFFST_M_DIV_FIELD 0
+#define STV090x_WIDTH_M_DIV_FIELD 8
+
+#define STV090x_SYNTCTRL 0xf1b6
+#define STV090x_OFFST_STANDBY_FIELD 7
+#define STV090x_WIDTH_STANDBY_FIELD 1
+#define STV090x_OFFST_BYPASSPLLCORE_FIELD 6
+#define STV090x_WIDTH_BYPASSPLLCORE_FIELD 1
+#define STV090x_OFFST_SELX1RATIO_FIELD 5
+#define STV090x_WIDTH_SELX1RATIO_FIELD 1
+#define STV090x_OFFST_STOP_PLL_FIELD 3
+#define STV090x_WIDTH_SELX1RATIO_FIELD 1
+#define STV090x_OFFST_BYPASSPLLFSK_FIELD 2
+#define STV090x_WIDTH_BYPASSPLLFSK_FIELD 1
+#define STV090x_OFFST_SELOSCI_FIELD 1
+#define STV090x_WIDTH_SELOSCI_FIELD 1
+#define STV090x_OFFST_BYPASSPLLADC_FIELD 0
+#define STV090x_WIDTH_BYPASSPLLADC_FIELD 1
+
+#define STV090x_FILTCTRL 0xf1b7
+#define STV090x_OFFST_INV_CLK135_FIELD 7
+#define STV090x_WIDTH_INV_CLK135_FIELD 1
+#define STV090x_OFFST_SEL_FSKCKDIV_FIELD 2
+#define STV090x_WIDTH_SEL_FSKCKDIV_FIELD 1
+#define STV090x_OFFST_INV_CLKFSK_FIELD 1
+#define STV090x_WIDTH_INV_CLKFSK_FIELD 1
+#define STV090x_OFFST_BYPASS_APPLI_FIELD 0
+#define STV090x_WIDTH_BYPASS_APPLI_FIELD 1
+
+#define STV090x_PLLSTAT 0xf1b8
+#define STV090x_OFFST_PLLLOCK_FIELD 0
+#define STV090x_WIDTH_PLLLOCK_FIELD 1
+
+#define STV090x_STOPCLK1 0xf1c2
+#define STV090x_OFFST_STOP_CLKPKDT2_FIELD 6
+#define STV090x_WIDTH_STOP_CLKPKDT2_FIELD 1
+#define STV090x_OFFST_STOP_CLKPKDT1_FIELD 5
+#define STV090x_WIDTH_STOP_CLKPKDT1_FIELD 1
+#define STV090x_OFFST_STOP_CLKFEC_FIELD 4
+#define STV090x_WIDTH_STOP_CLKFEC_FIELD 1
+#define STV090x_OFFST_STOP_CLKADCI2_FIELD 3
+#define STV090x_WIDTH_STOP_CLKADCI2_FIELD 1
+#define STV090x_OFFST_INV_CLKADCI2_FIELD 2
+#define STV090x_WIDTH_INV_CLKADCI2_FIELD 1
+#define STV090x_OFFST_STOP_CLKADCI1_FIELD 1
+#define STV090x_WIDTH_STOP_CLKADCI1_FIELD 1
+#define STV090x_OFFST_INV_CLKADCI1_FIELD 0
+#define STV090x_WIDTH_INV_CLKADCI1_FIELD 1
+
+#define STV090x_STOPCLK2 0xf1c3
+#define STV090x_OFFST_STOP_CLKSAMP2_FIELD 4
+#define STV090x_WIDTH_STOP_CLKSAMP2_FIELD 1
+#define STV090x_OFFST_STOP_CLKSAMP1_FIELD 3
+#define STV090x_WIDTH_STOP_CLKSAMP1_FIELD 1
+#define STV090x_OFFST_STOP_CLKVIT2_FIELD 2
+#define STV090x_WIDTH_STOP_CLKVIT2_FIELD 1
+#define STV090x_OFFST_STOP_CLKVIT1_FIELD 1
+#define STV090x_WIDTH_STOP_CLKVIT1_FIELD 1
+#define STV090x_OFFST_STOP_CLKTS_FIELD 0
+#define STV090x_WIDTH_STOP_CLKTS_FIELD 1
+
+#define STV090x_TSTTNR0 0xf1df
+#define STV090x_OFFST_SEL_FSK_FIELD 7
+#define STV090x_WIDTH_SEL_FSK_FIELD 1
+#define STV090x_OFFST_FSK_PON_FIELD 2
+#define STV090x_WIDTH_FSK_PON_FIELD 1
+
+#define STV090x_TSTTNR1 0xf1e0
+#define STV090x_OFFST_ADC1_PON_FIELD 1
+#define STV090x_WIDTH_ADC1_PON_FIELD 1
+#define STV090x_OFFST_ADC1_INMODE_FIELD 0
+#define STV090x_WIDTH_ADC1_INMODE_FIELD 1
+
+#define STV090x_TSTTNR2 0xf1e1
+#define STV090x_OFFST_DISEQC1_PON_FIELD 5
+#define STV090x_WIDTH_DISEQC1_PON_FIELD 1
+
+#define STV090x_TSTTNR3 0xf1e2
+#define STV090x_OFFST_ADC2_PON_FIELD 1
+#define STV090x_WIDTH_ADC2_PON_FIELD 1
+#define STV090x_OFFST_ADC2_INMODE_FIELD 0
+#define STV090x_WIDTH_ADC2_INMODE_FIELD 1
+
+#define STV090x_TSTTNR4 0xf1e3
+#define STV090x_OFFST_DISEQC2_PON_FIELD 5
+#define STV090x_WIDTH_DISEQC2_PON_FIELD 1
+
+#define STV090x_FSKTFC2 0xf170
+#define STV090x_OFFST_FSKT_KMOD_FIELD 2
+#define STV090x_WIDTH_FSKT_KMOD_FIELD 6
+#define STV090x_OFFST_FSKT_CAR_FIELD 0
+#define STV090x_WIDTH_FSKT_CAR_FIELD 2
+
+#define STV090x_FSKTFC1 0xf171
+#define STV090x_OFFST_FSKTC1_CAR_FIELD 0
+#define STV090x_WIDTH_FSKTC1_CAR_FIELD 8
+
+#define STV090x_FSKTFC0 0xf172
+#define STV090x_OFFST_FSKTC0_CAR_FIELD 0
+#define STV090x_WIDTH_FSKTC0_CAR_FIELD 8
+
+#define STV090x_FSKTDELTAF1 0xf173
+#define STV090x_OFFST_FSKTF1_DELTAF_FIELD 0
+#define STV090x_WIDTH_FSKTF1_DELTAF_FIELD 4
+
+#define STV090x_FSKTDELTAF0 0xf174
+#define STV090x_OFFST_FSKTF0_DELTAF_FIELD 0
+#define STV090x_WIDTH_FSKTF0_DELTAF_FIELD 8
+
+#define STV090x_FSKTCTRL 0xf175
+#define STV090x_OFFST_FSKT_EN_SGN_FIELD 6
+#define STV090x_WIDTH_FSKT_EN_SGN_FIELD 1
+#define STV090x_OFFST_FSKT_MOD_SGN_FIELD 5
+#define STV090x_WIDTH_FSKT_MOD_SGN_FIELD 1
+#define STV090x_OFFST_FSKT_MOD_EN_FIELD 2
+#define STV090x_WIDTH_FSKT_MOD_EN_FIELD 3
+#define STV090x_OFFST_FSKT_DACMODE_FIELD 0
+#define STV090x_WIDTH_FSKT_DACMODE_FIELD 2
+
+#define STV090x_FSKRFC2 0xf176
+#define STV090x_OFFST_FSKRC2_DETSGN_FIELD 6
+#define STV090x_WIDTH_FSKRC2_DETSGN_FIELD 1
+#define STV090x_OFFST_FSKRC2_OUTSGN_FIELD 5
+#define STV090x_WIDTH_FSKRC2_OUTSGN_FIELD 1
+#define STV090x_OFFST_FSKRC2_KAGC_FIELD 2
+#define STV090x_WIDTH_FSKRC2_KAGC_FIELD 3
+#define STV090x_OFFST_FSKRC2_CAR_FIELD 0
+#define STV090x_WIDTH_FSKRC2_CAR_FIELD 2
+
+#define STV090x_FSKRFC1 0xf177
+#define STV090x_OFFST_FSKRC1_CAR_FIELD 0
+#define STV090x_WIDTH_FSKRC1_CAR_FIELD 8
+
+#define STV090x_FSKRFC0 0xf178
+#define STV090x_OFFST_FSKRC0_CAR_FIELD 0
+#define STV090x_WIDTH_FSKRC0_CAR_FIELD 8
+
+#define STV090x_FSKRK1 0xf179
+#define STV090x_OFFST_FSKR_K1_EXP_FIELD 5
+#define STV090x_WIDTH_FSKR_K1_EXP_FIELD 3
+#define STV090x_OFFST_FSKR_K1_MANT_FIELD 0
+#define STV090x_WIDTH_FSKR_K1_MANT_FIELD 5
+
+#define STV090x_FSKRK2 0xf17a
+#define STV090x_OFFST_FSKR_K2_EXP_FIELD 5
+#define STV090x_WIDTH_FSKR_K2_EXP_FIELD 3
+#define STV090x_OFFST_FSKR_K2_MANT_FIELD 0
+#define STV090x_WIDTH_FSKR_K2_MANT_FIELD 5
+
+#define STV090x_FSKRAGCR 0xf17b
+#define STV090x_OFFST_FSKR_OUTCTL_FIELD 6
+#define STV090x_WIDTH_FSKR_OUTCTL_FIELD 2
+#define STV090x_OFFST_FSKR_AGC_REF_FIELD 0
+#define STV090x_WIDTH_FSKR_AGC_REF_FIELD 6
+
+#define STV090x_FSKRAGC 0xf17c
+#define STV090x_OFFST_FSKR_AGC_ACCU_FIELD 0
+#define STV090x_WIDTH_FSKR_AGC_ACCU_FIELD 8
+
+#define STV090x_FSKRALPHA 0xf17d
+#define STV090x_OFFST_FSKR_ALPHA_EXP_FIELD 2
+#define STV090x_WIDTH_FSKR_ALPHA_EXP_FIELD 3
+#define STV090x_OFFST_FSKR_ALPHA_M_FIELD 0
+#define STV090x_WIDTH_FSKR_ALPHA_M_FIELD 2
+
+#define STV090x_FSKRPLTH1 0xf17e
+#define STV090x_OFFST_FSKR_BETA_FIELD 4
+#define STV090x_WIDTH_FSKR_BETA_FIELD 4
+#define STV090x_OFFST_FSKR_PLL_TRESH1_FIELD 0
+#define STV090x_WIDTH_FSKR_PLL_TRESH1_FIELD 4
+
+#define STV090x_FSKRPLTH0 0xf17f
+#define STV090x_OFFST_FSKR_PLL_TRESH0_FIELD 0
+#define STV090x_WIDTH_FSKR_PLL_TRESH0_FIELD 8
+
+#define STV090x_FSKRDF1 0xf180
+#define STV090x_OFFST_FSKR_DELTAF1_FIELD 0
+#define STV090x_WIDTH_FSKR_DELTAF1_FIELD 5
+
+#define STV090x_FSKRDF0 0xf181
+#define STV090x_OFFST_FSKR_DELTAF0_FIELD 0
+#define STV090x_WIDTH_FSKR_DELTAF0_FIELD 8
+
+#define STV090x_FSKRSTEPP 0xf182
+#define STV090x_OFFST_FSKR_STEP_PLUS_FIELD 0
+#define STV090x_WIDTH_FSKR_STEP_PLUS_FIELD 8
+
+#define STV090x_FSKRSTEPM 0xf183
+#define STV090x_OFFST_FSKR_STEP_MINUS_FIELD 0
+#define STV090x_WIDTH_FSKR_STEP_MINUS_FIELD 8
+
+#define STV090x_FSKRDET1 0xf184
+#define STV090x_OFFST_FSKR_CARDET1_ACCU_FIELD 0
+#define STV090x_WIDTH_FSKR_CARDET1_ACCU_FIELD 4
+
+#define STV090x_FSKRDET0 0xf185
+#define STV090x_OFFST_FSKR_CARDET0_ACCU_FIELD 0
+#define STV090x_WIDTH_FSKR_CARDET0_ACCU_FIELD 8
+
+#define STV090x_FSKRDTH1 0xf186
+#define STV090x_OFFST_FSKR_CARLOSS_THRESH1_FIELD 4
+#define STV090x_WIDTH_FSKR_CARLOSS_THRESH1_FIELD 4
+#define STV090x_OFFST_FSKR_CARDET_THRESH1_FIELD 0
+#define STV090x_WIDTH_FSKR_CARDET_THRESH1_FIELD 4
+
+#define STV090x_FSKRDTH0 0xf187
+#define STV090x_OFFST_FSKR_CARDET_THRESH0_FIELD 0
+#define STV090x_WIDTH_FSKR_CARDET_THRESH0_FIELD 8
+
+#define STV090x_FSKRLOSS 0xf188
+#define STV090x_OFFST_FSKR_CARLOSS_THRESH_FIELD 0
+#define STV090x_WIDTH_FSKR_CARLOSS_THRESH_FIELD 8
+
+#define STV090x_Px_DISTXCTL(__x) (0xF1A0 - (__x - 1) * 0x10)
+#define STV090x_P1_DISTXCTL STV090x_Px_DISTXCTL(1)
+#define STV090x_P2_DISTXCTL STV090x_Px_DISTXCTL(2)
+#define STV090x_OFFST_Px_TIM_OFF_FIELD 7
+#define STV090x_WIDTH_Px_TIM_OFF_FIELD 1
+#define STV090x_OFFST_Px_DISEQC_RESET_FIELD 6
+#define STV090x_WIDTH_Px_DISEQC_RESET_FIELD 1
+#define STV090x_OFFST_Px_TIM_CMD_FIELD 4
+#define STV090x_WIDTH_Px_TIM_CMD_FIELD 2
+#define STV090x_OFFST_Px_DIS_PRECHARGE_FIELD 3
+#define STV090x_WIDTH_Px_DIS_PRECHARGE_FIELD 1
+#define STV090x_OFFST_Px_DISTX_MODE_FIELD 0
+#define STV090x_WIDTH_Px_DISTX_MODE_FIELD 3
+
+#define STV090x_Px_DISRXCTL(__x) (0xf1a1 - (__x - 1) * 0x10)
+#define STV090x_P1_DISRXCTL STV090x_Px_DISRXCTL(1)
+#define STV090x_P2_DISRXCTL STV090x_Px_DISRXCTL(2)
+#define STV090x_OFFST_Px_RECEIVER_ON_FIELD 7
+#define STV090x_WIDTH_Px_RECEIVER_ON_FIELD 1
+#define STV090x_OFFST_Px_IGNO_SHORT22K_FIELD 6
+#define STV090x_WIDTH_Px_IGNO_SHORT22K_FIELD 1
+#define STV090x_OFFST_Px_ONECHIP_TRX_FIELD 5
+#define STV090x_WIDTH_Px_ONECHIP_TRX_FIELD 1
+#define STV090x_OFFST_Px_EXT_ENVELOP_FIELD 4
+#define STV090x_WIDTH_Px_EXT_ENVELOP_FIELD 1
+#define STV090x_OFFST_Px_PIN_SELECT_FIELD 2
+#define STV090x_WIDTH_Px_PIN_SELECT_FIELD 2
+#define STV090x_OFFST_Px_IRQ_RXEND_FIELD 1
+#define STV090x_WIDTH_Px_IRQ_RXEND_FIELD 1
+#define STV090x_OFFST_Px_IRQ_4NBYTES_FIELD 0
+#define STV090x_WIDTH_Px_IRQ_4NBYTES_FIELD 1
+
+#define STV090x_Px_DISRX_ST0(__x) (0xf1a4 - (__x - 1) * 0x10)
+#define STV090x_P1_DISRX_ST0 STV090x_Px_DISRX_ST0(1)
+#define STV090x_P2_DISRX_ST0 STV090x_Px_DISRX_ST0(2)
+#define STV090x_OFFST_Px_RX_END_FIELD 7
+#define STV090x_WIDTH_Px_RX_END_FIELD 1
+#define STV090x_OFFST_Px_RX_ACTIVE_FIELD 6
+#define STV090x_WIDTH_Px_RX_ACTIVE_FIELD 1
+#define STV090x_OFFST_Px_SHORT_22KHZ_FIELD 5
+#define STV090x_WIDTH_Px_SHORT_22KHZ_FIELD 1
+#define STV090x_OFFST_Px_CONT_TONE_FIELD 4
+#define STV090x_WIDTH_Px_CONT_TONE_FIELD 1
+#define STV090x_OFFST_Px_FIFO_4BREADY_FIELD 3
+#define STV090x_WIDTH_Px_FIFO_4BREADY_FIELD 2
+#define STV090x_OFFST_Px_FIFO_EMPTY_FIELD 2
+#define STV090x_WIDTH_Px_FIFO_EMPTY_FIELD 1
+#define STV090x_OFFST_Px_ABORT_DISRX_FIELD 0
+#define STV090x_WIDTH_Px_ABORT_DISRX_FIELD 1
+
+#define STV090x_Px_DISRX_ST1(__x) (0xf1a5 - (__x - 1) * 0x10)
+#define STV090x_P1_DISRX_ST1 STV090x_Px_DISRX_ST1(1)
+#define STV090x_P2_DISRX_ST1 STV090x_Px_DISRX_ST1(2)
+#define STV090x_OFFST_Px_RX_FAIL_FIELD 7
+#define STV090x_WIDTH_Px_RX_FAIL_FIELD 1
+#define STV090x_OFFST_Px_FIFO_PARITYFAIL_FIELD 6
+#define STV090x_WIDTH_Px_FIFO_PARITYFAIL_FIELD 1
+#define STV090x_OFFST_Px_RX_NONBYTE_FIELD 5
+#define STV090x_WIDTH_Px_RX_NONBYTE_FIELD 1
+#define STV090x_OFFST_Px_FIFO_OVERFLOW_FIELD 4
+#define STV090x_WIDTH_Px_FIFO_OVERFLOW_FIELD 1
+#define STV090x_OFFST_Px_FIFO_BYTENBR_FIELD 0
+#define STV090x_WIDTH_Px_FIFO_BYTENBR_FIELD 4
+
+#define STV090x_Px_DISRXDATA(__x) (0xf1a6 - (__x - 1) * 0x10)
+#define STV090x_P1_DISRXDATA STV090x_Px_DISRXDATA(1)
+#define STV090x_P2_DISRXDATA STV090x_Px_DISRXDATA(2)
+#define STV090x_OFFST_Px_DISRX_DATA_FIELD 0
+#define STV090x_WIDTH_Px_DISRX_DATA_FIELD 8
+
+#define STV090x_Px_DISTXDATA(__x) (0xf1a7 - (__x - 1) * 0x10)
+#define STV090x_P1_DISTXDATA STV090x_Px_DISTXDATA(1)
+#define STV090x_P2_DISTXDATA STV090x_Px_DISTXDATA(2)
+#define STV090x_OFFST_Px_DISEQC_FIFO_FIELD 0
+#define STV090x_WIDTH_Px_DISEQC_FIFO_FIELD 8
+
+#define STV090x_Px_DISTXSTATUS(__x) (0xf1a8 - (__x - 1) * 0x10)
+#define STV090x_P1_DISTXSTATUS STV090x_Px_DISTXSTATUS(1)
+#define STV090x_P2_DISTXSTATUS STV090x_Px_DISTXSTATUS(2)
+#define STV090x_OFFST_Px_TX_FAIL_FIELD 7
+#define STV090x_WIDTH_Px_TX_FAIL_FIELD 1
+#define STV090x_OFFST_Px_FIFO_FULL_FIELD 6
+#define STV090x_WIDTH_Px_FIFO_FULL_FIELD 1
+#define STV090x_OFFST_Px_TX_IDLE_FIELD 5
+#define STV090x_WIDTH_Px_TX_IDLE_FIELD 1
+#define STV090x_OFFST_Px_GAP_BURST_FIELD 4
+#define STV090x_WIDTH_Px_GAP_BURST_FIELD 1
+#define STV090x_OFFST_Px_TXFIFO_BYTES_FIELD 0
+#define STV090x_WIDTH_Px_TXFIFO_BYTES_FIELD 4
+
+#define STV090x_Px_F22TX(__x) (0xf1a9 - (__x - 1) * 0x10)
+#define STV090x_P1_F22TX STV090x_Px_F22TX(1)
+#define STV090x_P2_F22TX STV090x_Px_F22TX(2)
+#define STV090x_OFFST_Px_F22_REG_FIELD 0
+#define STV090x_WIDTH_Px_F22_REG_FIELD 8
+
+#define STV090x_Px_F22RX(__x) (0xf1aa - (__x - 1) * 0x10)
+#define STV090x_P1_F22RX STV090x_Px_F22RX(1)
+#define STV090x_P2_F22RX STV090x_Px_F22RX(2)
+#define STV090x_OFFST_Px_F22RX_REG_FIELD 0
+#define STV090x_WIDTH_Px_F22RX_REG_FIELD 8
+
+#define STV090x_Px_ACRPRESC(__x) (0xf1ac - (__x - 1) * 0x10)
+#define STV090x_P1_ACRPRESC STV090x_Px_ACRPRESC(1)
+#define STV090x_P2_ACRPRESC STV090x_Px_ACRPRESC(2)
+#define STV090x_OFFST_Px_ACR_PRESC_FIELD 0
+#define STV090x_WIDTH_Px_ACR_PRESC_FIELD 3
+
+#define STV090x_Px_ACRDIV(__x) (0xf1ad - (__x - 1) * 0x10)
+#define STV090x_P1_ACRDIV STV090x_Px_ACRDIV(1)
+#define STV090x_P2_ACRDIV STV090x_Px_ACRDIV(2)
+#define STV090x_OFFST_Px_ACR_DIV_FIELD 0
+#define STV090x_WIDTH_Px_ACR_DIV_FIELD 8
+
+#define STV090x_Px_IQCONST(__x) (0xF400 - (__x - 1) * 0x200)
+#define STV090x_P1_IQCONST STV090x_Px_IQCONST(1)
+#define STV090x_P2_IQCONST STV090x_Px_IQCONST(2)
+#define STV090x_OFFST_Px_CONSTEL_SELECT_FIELD 5
+#define STV090x_WIDTH_Px_CONSTEL_SELECT_FIELD 2
+
+#define STV090x_Px_NOSCFG(__x) (0xF401 - (__x - 1) * 0x200)
+#define STV090x_P1_NOSCFG STV090x_Px_NOSCFG(1)
+#define STV090x_P2_NOSCFG STV090x_Px_NOSCFG(2)
+#define STV090x_OFFST_Px_NOSPLH_BETA_FIELD 3
+#define STV090x_WIDTH_Px_NOSPLH_BETA_FIELD 2
+#define STV090x_OFFST_Px_NOSDATA_BETA_FIELD 0
+#define STV090x_WIDTH_Px_NOSDATA_BETA_FIELD 3
+
+#define STV090x_Px_ISYMB(__x) (0xF402 - (__x - 1) * 0x200)
+#define STV090x_P1_ISYMB STV090x_Px_ISYMB(1)
+#define STV090x_P2_ISYMB STV090x_Px_ISYMB(2)
+#define STV090x_OFFST_Px_I_SYMBOL_FIELD 0
+#define STV090x_WIDTH_Px_I_SYMBOL_FIELD 8
+
+#define STV090x_Px_QSYMB(__x) (0xF403 - (__x - 1) * 0x200)
+#define STV090x_P1_QSYMB STV090x_Px_QSYMB(1)
+#define STV090x_P2_QSYMB STV090x_Px_QSYMB(2)
+#define STV090x_OFFST_Px_Q_SYMBOL_FIELD 0
+#define STV090x_WIDTH_Px_Q_SYMBOL_FIELD 8
+
+#define STV090x_Px_AGC1CFG(__x) (0xF404 - (__x - 1) * 0x200)
+#define STV090x_P1_AGC1CFG STV090x_Px_AGC1CFG(1)
+#define STV090x_P2_AGC1CFG STV090x_Px_AGC1CFG(2)
+#define STV090x_OFFST_Px_DC_FROZEN_FIELD 7
+#define STV090x_WIDTH_Px_DC_FROZEN_FIELD 1
+#define STV090x_OFFST_Px_DC_CORRECT_FIELD 6
+#define STV090x_WIDTH_Px_DC_CORRECT_FIELD 1
+#define STV090x_OFFST_Px_AMM_FROZEN_FIELD 5
+#define STV090x_WIDTH_Px_AMM_FROZEN_FIELD 1
+#define STV090x_OFFST_Px_AMM_CORRECT_FIELD 4
+#define STV090x_WIDTH_Px_AMM_CORRECT_FIELD 1
+#define STV090x_OFFST_Px_QUAD_FROZEN_FIELD 3
+#define STV090x_WIDTH_Px_QUAD_FROZEN_FIELD 1
+#define STV090x_OFFST_Px_QUAD_CORRECT_FIELD 2
+#define STV090x_WIDTH_Px_QUAD_CORRECT_FIELD 1
+
+#define STV090x_Px_AGC1CN(__x) (0xF406 - (__x - 1) * 0x200)
+#define STV090x_P1_AGC1CN STV090x_Px_AGC1CN(1)
+#define STV090x_P2_AGC1CN STV090x_Px_AGC1CN(2)
+#define STV090x_WIDTH_Px_AGC1_LOCKED_FIELD 7
+#define STV090x_OFFST_Px_AGC1_LOCKED_FIELD 1
+#define STV090x_OFFST_Px_AGC1_MINPOWER_FIELD 4
+#define STV090x_WIDTH_Px_AGC1_MINPOWER_FIELD 1
+#define STV090x_OFFST_Px_AGCOUT_FAST_FIELD 3
+#define STV090x_WIDTH_Px_AGCOUT_FAST_FIELD 1
+#define STV090x_OFFST_Px_AGCIQ_BETA_FIELD 0
+#define STV090x_WIDTH_Px_AGCIQ_BETA_FIELD 3
+
+#define STV090x_Px_AGC1REF(__x) (0xF407 - (__x - 1) * 0x200)
+#define STV090x_P1_AGC1REF STV090x_Px_AGC1REF(1)
+#define STV090x_P2_AGC1REF STV090x_Px_AGC1REF(2)
+#define STV090x_OFFST_Px_AGCIQ_REF_FIELD 0
+#define STV090x_WIDTH_Px_AGCIQ_REF_FIELD 8
+
+#define STV090x_Px_IDCCOMP(__x) (0xF408 - (__x - 1) * 0x200)
+#define STV090x_P1_IDCCOMP STV090x_Px_IDCCOMP(1)
+#define STV090x_P2_IDCCOMP STV090x_Px_IDCCOMP(2)
+#define STV090x_OFFST_Px_IAVERAGE_ADJ_FIELD 0
+#define STV090x_WIDTH_Px_IAVERAGE_ADJ_FIELD 8
+
+#define STV090x_Px_QDCCOMP(__x) (0xF409 - (__x - 1) * 0x200)
+#define STV090x_P1_QDCCOMP STV090x_Px_QDCCOMP(1)
+#define STV090x_P2_QDCCOMP STV090x_Px_QDCCOMP(2)
+#define STV090x_OFFST_Px_QAVERAGE_ADJ_FIELD 0
+#define STV090x_WIDTH_Px_QAVERAGE_ADJ_FIELD 8
+
+#define STV090x_Px_POWERI(__x) (0xF40A - (__x - 1) * 0x200)
+#define STV090x_P1_POWERI STV090x_Px_POWERI(1)
+#define STV090x_P2_POWERI STV090x_Px_POWERI(2)
+#define STV090x_OFFST_Px_POWER_I_FIELD 0
+#define STV090x_WIDTH_Px_POWER_I_FIELD 8
+
+#define STV090x_Px_POWERQ(__x) (0xF40B - (__x - 1) * 0x200)
+#define STV090x_P1_POWERQ STV090x_Px_POWERQ(1)
+#define STV090x_P2_POWERQ STV090x_Px_POWERQ(2)
+#define STV090x_OFFST_Px_POWER_Q_FIELD 0
+#define STV090x_WIDTH_Px_POWER_Q_FIELD 8
+
+#define STV090x_Px_AGC1AMM(__x) (0xF40C - (__x - 1) * 0x200)
+#define STV090x_P1_AGC1AMM STV090x_Px_AGC1AMM(1)
+#define STV090x_P2_AGC1AMM STV090x_Px_AGC1AMM(2)
+#define STV090x_OFFST_Px_AMM_VALUE_FIELD 0
+#define STV090x_WIDTH_Px_AMM_VALUE_FIELD 8
+
+#define STV090x_Px_AGC1QUAD(__x) (0xF40D - (__x - 1) * 0x200)
+#define STV090x_P1_AGC1QUAD STV090x_Px_AGC1QUAD(1)
+#define STV090x_P2_AGC1QUAD STV090x_Px_AGC1QUAD(2)
+#define STV090x_OFFST_Px_QUAD_VALUE_FIELD 0
+#define STV090x_WIDTH_Px_QUAD_VALUE_FIELD 8
+
+#define STV090x_Px_AGCIQINy(__x, __y) (0xF40F - (__x-1) * 0x200 - __y * 0x1)
+#define STV090x_P1_AGCIQIN0 STV090x_Px_AGCIQINy(1, 0)
+#define STV090x_P1_AGCIQIN1 STV090x_Px_AGCIQINy(1, 1)
+#define STV090x_P2_AGCIQIN0 STV090x_Px_AGCIQINy(2, 0)
+#define STV090x_P2_AGCIQIN1 STV090x_Px_AGCIQINy(2, 1)
+#define STV090x_OFFST_Px_AGCIQ_VALUE_FIELD 0
+#define STV090x_WIDTH_Px_AGCIQ_VALUE_FIELD 8
+
+#define STV090x_Px_DEMOD(__x) (0xF410 - (__x - 1) * 0x200)
+#define STV090x_P1_DEMOD STV090x_Px_DEMOD(1)
+#define STV090x_P2_DEMOD STV090x_Px_DEMOD(2)
+#define STV090x_OFFST_Px_MANUAL_S2ROLLOFF_FIELD 7
+#define STV090x_WIDTH_Px_MANUAL_S2ROLLOFF_FIELD 1
+#define STV090x_OFFST_Px_DEMOD_STOP_FIELD 6
+#define STV090x_WIDTH_Px_DEMOD_STOP_FIELD 1
+#define STV090x_OFFST_Px_SPECINV_CONTROL_FIELD 4
+#define STV090x_WIDTH_Px_SPECINV_CONTROL_FIELD 2
+#define STV090x_OFFST_Px_FORCE_ENASAMP_FIELD 3
+#define STV090x_WIDTH_Px_FORCE_ENASAMP_FIELD 1
+#define STV090x_OFFST_Px_MANUAL_SXROLLOFF_FIELD 2
+#define STV090x_WIDTH_Px_MANUAL_SXROLLOFF_FIELD 1
+#define STV090x_OFFST_Px_ROLLOFF_CONTROL_FIELD 0
+#define STV090x_WIDTH_Px_ROLLOFF_CONTROL_FIELD 2
+
+#define STV090x_Px_DMDMODCOD(__x) (0xF411 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDMODCOD STV090x_Px_DMDMODCOD(1)
+#define STV090x_P2_DMDMODCOD STV090x_Px_DMDMODCOD(2)
+#define STV090x_OFFST_Px_MANUAL_MODCOD_FIELD 7
+#define STV090x_WIDTH_Px_MANUAL_MODCOD_FIELD 1
+#define STV090x_OFFST_Px_DEMOD_MODCOD_FIELD 2
+#define STV090x_WIDTH_Px_DEMOD_MODCOD_FIELD 5
+#define STV090x_OFFST_Px_DEMOD_TYPE_FIELD 0
+#define STV090x_WIDTH_Px_DEMOD_TYPE_FIELD 2
+
+#define STV090x_Px_DSTATUS(__x) (0xF412 - (__x - 1) * 0x200)
+#define STV090x_P1_DSTATUS STV090x_Px_DSTATUS(1)
+#define STV090x_P2_DSTATUS STV090x_Px_DSTATUS(2)
+#define STV090x_OFFST_Px_CAR_LOCK_FIELD 7
+#define STV090x_WIDTH_Px_CAR_LOCK_FIELD 1
+#define STV090x_OFFST_Px_TMGLOCK_QUALITY_FIELD 5
+#define STV090x_WIDTH_Px_TMGLOCK_QUALITY_FIELD 2
+#define STV090x_OFFST_Px_LOCK_DEFINITIF_FIELD 3
+#define STV090x_WIDTH_Px_LOCK_DEFINITIF_FIELD 1
+
+#define STV090x_Px_DSTATUS2(__x) (0xF413 - (__x - 1) * 0x200)
+#define STV090x_P1_DSTATUS2 STV090x_Px_DSTATUS2(1)
+#define STV090x_P2_DSTATUS2 STV090x_Px_DSTATUS2(2)
+#define STV090x_OFFST_Px_DEMOD_DELOCK_FIELD 7
+#define STV090x_WIDTH_Px_DEMOD_DELOCK_FIELD 1
+#define STV090x_OFFST_Px_AGC1_NOSIGNALACK_FIELD 3
+#define STV090x_WIDTH_Px_AGC1_NOSIGNALACK_FIELD 1
+#define STV090x_OFFST_Px_AGC2_OVERFLOW_FIELD 2
+#define STV090x_WIDTH_Px_AGC2_OVERFLOW_FIELD 1
+#define STV090x_OFFST_Px_CFR_OVERFLOW_FIELD 1
+#define STV090x_WIDTH_Px_CFR_OVERFLOW_FIELD 1
+#define STV090x_OFFST_Px_GAMMA_OVERUNDER_FIELD 0
+#define STV090x_WIDTH_Px_GAMMA_OVERUNDER_FIELD 1
+
+#define STV090x_Px_DMDCFGMD(__x) (0xF414 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDCFGMD STV090x_Px_DMDCFGMD(1)
+#define STV090x_P2_DMDCFGMD STV090x_Px_DMDCFGMD(2)
+#define STV090x_OFFST_Px_DVBS2_ENABLE_FIELD 7
+#define STV090x_WIDTH_Px_DVBS2_ENABLE_FIELD 1
+#define STV090x_OFFST_Px_DVBS1_ENABLE_FIELD 6
+#define STV090x_WIDTH_Px_DVBS1_ENABLE_FIELD 1
+#define STV090x_OFFST_Px_CFR_AUTOSCAN_FIELD 5 /* check */
+#define STV090x_WIDTH_Px_CFR_AUTOSCAN_FIELD 1
+#define STV090x_OFFST_Px_SCAN_ENABLE_FIELD 4 /* check */
+#define STV090x_WIDTH_Px_SCAN_ENABLE_FIELD 1
+#define STV090x_OFFST_Px_TUN_AUTOSCAN_FIELD 3
+#define STV090x_WIDTH_Px_TUN_AUTOSCAN_FIELD 1
+#define STV090x_OFFST_Px_NOFORCE_RELOCK_FIELD 2
+#define STV090x_WIDTH_Px_NOFORCE_RELOCK_FIELD 1
+#define STV090x_OFFST_Px_TUN_RNG_FIELD 0
+#define STV090x_WIDTH_Px_TUN_RNG_FIELD 2
+
+#define STV090x_Px_DMDCFG2(__x) (0xF415 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDCFG2 STV090x_Px_DMDCFG2(1)
+#define STV090x_P2_DMDCFG2 STV090x_Px_DMDCFG2(2)
+#define STV090x_OFFST_Px_S1S2_SEQUENTIAL_FIELD 6
+#define STV090x_WIDTH_Px_S1S2_SEQUENTIAL_FIELD 1
+
+#define STV090x_Px_DMDISTATE(__x) (0xF416 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDISTATE STV090x_Px_DMDISTATE(1)
+#define STV090x_P2_DMDISTATE STV090x_Px_DMDISTATE(2)
+#define STV090x_OFFST_Px_I2C_DEMOD_MODE_FIELD 0
+#define STV090x_WIDTH_Px_I2C_DEMOD_MODE_FIELD 5
+
+#define STV090x_Px_DMDTOM(__x) (0xF417 - (__x - 1) * 0x200) /* check */
+#define STV090x_P1_DMDTOM STV090x_Px_DMDTOM(1)
+#define STV090x_P2_DMDTOM STV090x_Px_DMDTOM(2)
+
+#define STV090x_Px_DMDSTATE(__x) (0xF41B - (__x - 1) * 0x200)
+#define STV090x_P1_DMDSTATE STV090x_Px_DMDSTATE(1)
+#define STV090x_P2_DMDSTATE STV090x_Px_DMDSTATE(2)
+#define STV090x_OFFST_Px_HEADER_MODE_FIELD 5
+#define STV090x_WIDTH_Px_HEADER_MODE_FIELD 2
+
+#define STV090x_Px_DMDFLYW(__x) (0xF41C - (__x - 1) * 0x200)
+#define STV090x_P1_DMDFLYW STV090x_Px_DMDFLYW(1)
+#define STV090x_P2_DMDFLYW STV090x_Px_DMDFLYW(2)
+#define STV090x_OFFST_Px_I2C_IRQVAL_FIELD 4
+#define STV090x_WIDTH_Px_I2C_IRQVAL_FIELD 4
+#define STV090x_OFFST_Px_FLYWHEEL_CPT_FIELD 0 /* check */
+#define STV090x_WIDTH_Px_FLYWHEEL_CPT_FIELD 4
+
+#define STV090x_Px_DSTATUS3(__x) (0xF41D - (__x - 1) * 0x200)
+#define STV090x_P1_DSTATUS3 STV090x_Px_DSTATUS3(1)
+#define STV090x_P2_DSTATUS3 STV090x_Px_DSTATUS3(2)
+#define STV090x_OFFST_Px_DEMOD_CFGMODE_FIELD 5
+#define STV090x_WIDTH_Px_DEMOD_CFGMODE_FIELD 2
+
+#define STV090x_Px_DMDCFG3(__x) (0xF41E - (__x - 1) * 0x200)
+#define STV090x_P1_DMDCFG3 STV090x_Px_DMDCFG3(1)
+#define STV090x_P2_DMDCFG3 STV090x_Px_DMDCFG3(2)
+#define STV090x_OFFST_Px_NOSTOP_FIFOFULL_FIELD 3
+#define STV090x_WIDTH_Px_NOSTOP_FIFOFULL_FIELD 1
+
+#define STV090x_Px_DMDCFG4(__x) (0xf41f - (__x - 1) * 0x200)
+#define STV090x_P1_DMDCFG4 STV090x_Px_DMDCFG4(1)
+#define STV090x_P2_DMDCFG4 STV090x_Px_DMDCFG4(2)
+
+#define STV090x_Px_CORRELMANT(__x) (0xF420 - (__x - 1) * 0x200)
+#define STV090x_P1_CORRELMANT STV090x_Px_CORRELMANT(1)
+#define STV090x_P2_CORRELMANT STV090x_Px_CORRELMANT(2)
+#define STV090x_OFFST_Px_CORREL_MANT_FIELD 0
+#define STV090x_WIDTH_Px_CORREL_MANT_FIELD 8
+
+#define STV090x_Px_CORRELABS(__x) (0xF421 - (__x - 1) * 0x200)
+#define STV090x_P1_CORRELABS STV090x_Px_CORRELABS(1)
+#define STV090x_P2_CORRELABS STV090x_Px_CORRELABS(2)
+#define STV090x_OFFST_Px_CORREL_ABS_FIELD 0
+#define STV090x_WIDTH_Px_CORREL_ABS_FIELD 8
+
+#define STV090x_Px_CORRELEXP(__x) (0xF422 - (__x - 1) * 0x200)
+#define STV090x_P1_CORRELEXP STV090x_Px_CORRELEXP(1)
+#define STV090x_P2_CORRELEXP STV090x_Px_CORRELEXP(2)
+#define STV090x_OFFST_Px_CORREL_ABSEXP_FIELD 4
+#define STV090x_WIDTH_Px_CORREL_ABSEXP_FIELD 4
+#define STV090x_OFFST_Px_CORREL_EXP_FIELD 0
+#define STV090x_WIDTH_Px_CORREL_EXP_FIELD 4
+
+#define STV090x_Px_PLHMODCOD(__x) (0xF424 - (__x - 1) * 0x200)
+#define STV090x_P1_PLHMODCOD STV090x_Px_PLHMODCOD(1)
+#define STV090x_P2_PLHMODCOD STV090x_Px_PLHMODCOD(2)
+#define STV090x_OFFST_Px_SPECINV_DEMOD_FIELD 7
+#define STV090x_WIDTH_Px_SPECINV_DEMOD_FIELD 1
+#define STV090x_OFFST_Px_PLH_MODCOD_FIELD 2
+#define STV090x_WIDTH_Px_PLH_MODCOD_FIELD 5
+#define STV090x_OFFST_Px_PLH_TYPE_FIELD 0
+#define STV090x_WIDTH_Px_PLH_TYPE_FIELD 2
+
+#define STV090x_Px_AGCK32(__x) (0xf42b - (__x - 1) * 0x200)
+#define STV090x_P1_AGCK32 STV090x_Px_AGCK32(1)
+#define STV090x_P2_AGCK32 STV090x_Px_AGCK32(2)
+
+#define STV090x_Px_AGC2O(__x) (0xF42C - (__x - 1) * 0x200)
+#define STV090x_P1_AGC2O STV090x_Px_AGC2O(1)
+#define STV090x_P2_AGC2O STV090x_Px_AGC2O(2)
+
+#define STV090x_Px_AGC2REF(__x) (0xF42D - (__x - 1) * 0x200)
+#define STV090x_P1_AGC2REF STV090x_Px_AGC2REF(1)
+#define STV090x_P2_AGC2REF STV090x_Px_AGC2REF(2)
+#define STV090x_OFFST_Px_AGC2_REF_FIELD 0
+#define STV090x_WIDTH_Px_AGC2_REF_FIELD 8
+
+#define STV090x_Px_AGC1ADJ(__x) (0xF42E - (__x - 1) * 0x200)
+#define STV090x_P1_AGC1ADJ STV090x_Px_AGC1ADJ(1)
+#define STV090x_P2_AGC1ADJ STV090x_Px_AGC1ADJ(2)
+#define STV090x_OFFST_Px_AGC1_ADJUSTED_FIELD 0
+#define STV090x_WIDTH_Px_AGC1_ADJUSTED_FIELD 7
+
+#define STV090x_Px_AGC2Iy(__x, __y) (0xF437 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_AGC2I0 STV090x_Px_AGC2Iy(1, 0)
+#define STV090x_P1_AGC2I1 STV090x_Px_AGC2Iy(1, 1)
+#define STV090x_P2_AGC2I0 STV090x_Px_AGC2Iy(2, 0)
+#define STV090x_P2_AGC2I1 STV090x_Px_AGC2Iy(2, 1)
+#define STV090x_OFFST_Px_AGC2_INTEGRATOR_FIELD 0
+#define STV090x_WIDTH_Px_AGC2_INTEGRATOR_FIELD 8
+
+#define STV090x_Px_CARCFG(__x) (0xF438 - (__x - 1) * 0x200)
+#define STV090x_P1_CARCFG STV090x_Px_CARCFG(1)
+#define STV090x_P2_CARCFG STV090x_Px_CARCFG(2)
+#define STV090x_OFFST_Px_EN_CAR2CENTER_FIELD 5
+#define STV090x_WIDTH_Px_EN_CAR2CENTER_FIELD 1
+#define STV090x_OFFST_Px_ROTATON_FIELD 2
+#define STV090x_WIDTH_Px_ROTATON_FIELD 1
+#define STV090x_OFFST_Px_PH_DET_ALGO_FIELD 0
+#define STV090x_WIDTH_Px_PH_DET_ALGO_FIELD 2
+
+#define STV090x_Px_ACLC(__x) (0xF439 - (__x - 1) * 0x200)
+#define STV090x_P1_ACLC STV090x_Px_ACLC(1)
+#define STV090x_P2_ACLC STV090x_Px_ACLC(2)
+#define STV090x_OFFST_Px_CAR_ALPHA_MANT_FIELD 4
+#define STV090x_WIDTH_Px_CAR_ALPHA_MANT_FIELD 2
+#define STV090x_OFFST_Px_CAR_ALPHA_EXP_FIELD 0
+#define STV090x_WIDTH_Px_CAR_ALPHA_EXP_FIELD 4
+
+#define STV090x_Px_BCLC(__x) (0xF43A - (__x - 1) * 0x200)
+#define STV090x_P1_BCLC STV090x_Px_BCLC(1)
+#define STV090x_P2_BCLC STV090x_Px_BCLC(2)
+#define STV090x_OFFST_Px_CAR_BETA_MANT_FIELD 4
+#define STV090x_WIDTH_Px_CAR_BETA_MANT_FIELD 2
+#define STV090x_OFFST_Px_CAR_BETA_EXP_FIELD 0
+#define STV090x_WIDTH_Px_CAR_BETA_EXP_FIELD 4
+
+#define STV090x_Px_CARFREQ(__x) (0xF43D - (__x - 1) * 0x200)
+#define STV090x_P1_CARFREQ STV090x_Px_CARFREQ(1)
+#define STV090x_P2_CARFREQ STV090x_Px_CARFREQ(2)
+#define STV090x_OFFST_Px_KC_COARSE_EXP_FIELD 4
+#define STV090x_WIDTH_Px_KC_COARSE_EXP_FIELD 4
+#define STV090x_OFFST_Px_BETA_FREQ_FIELD 0
+#define STV090x_WIDTH_Px_BETA_FREQ_FIELD 4
+
+#define STV090x_Px_CARHDR(__x) (0xF43E - (__x - 1) * 0x200)
+#define STV090x_P1_CARHDR STV090x_Px_CARHDR(1)
+#define STV090x_P2_CARHDR STV090x_Px_CARHDR(2)
+#define STV090x_OFFST_Px_FREQ_HDR_FIELD 0
+#define STV090x_WIDTH_Px_FREQ_HDR_FIELD 8
+
+#define STV090x_Px_LDT(__x) (0xF43F - (__x - 1) * 0x200)
+#define STV090x_P1_LDT STV090x_Px_LDT(1)
+#define STV090x_P2_LDT STV090x_Px_LDT(2)
+#define STV090x_OFFST_Px_CARLOCK_THRES_FIELD 0
+#define STV090x_WIDTH_Px_CARLOCK_THRES_FIELD 8
+
+#define STV090x_Px_LDT2(__x) (0xF440 - (__x - 1) * 0x200)
+#define STV090x_P1_LDT2 STV090x_Px_LDT2(1)
+#define STV090x_P2_LDT2 STV090x_Px_LDT2(2)
+#define STV090x_OFFST_Px_CARLOCK_THRES2_FIELD 0
+#define STV090x_WIDTH_Px_CARLOCK_THRES2_FIELD 8
+
+#define STV090x_Px_CFRICFG(__x) (0xF441 - (__x - 1) * 0x200)
+#define STV090x_P1_CFRICFG STV090x_Px_CFRICFG(1)
+#define STV090x_P2_CFRICFG STV090x_Px_CFRICFG(2)
+#define STV090x_OFFST_Px_NEG_CFRSTEP_FIELD 0
+#define STV090x_WIDTH_Px_NEG_CFRSTEP_FIELD 1
+
+#define STV090x_Pn_CFRUPy(__x, __y) (0xF443 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_CFRUP0 STV090x_Pn_CFRUPy(1, 0)
+#define STV090x_P1_CFRUP1 STV090x_Pn_CFRUPy(1, 1)
+#define STV090x_P2_CFRUP0 STV090x_Pn_CFRUPy(2, 0)
+#define STV090x_P2_CFRUP1 STV090x_Pn_CFRUPy(2, 1)
+#define STV090x_OFFST_Px_CFR_UP_FIELD 0
+#define STV090x_WIDTH_Px_CFR_UP_FIELD 8
+
+#define STV090x_Pn_CFRLOWy(__x, __y) (0xF447 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_CFRLOW0 STV090x_Pn_CFRLOWy(1, 0)
+#define STV090x_P1_CFRLOW1 STV090x_Pn_CFRLOWy(1, 1)
+#define STV090x_P2_CFRLOW0 STV090x_Pn_CFRLOWy(2, 0)
+#define STV090x_P2_CFRLOW1 STV090x_Pn_CFRLOWy(2, 1)
+#define STV090x_OFFST_Px_CFR_LOW_FIELD 0
+#define STV090x_WIDTH_Px_CFR_LOW_FIELD 8
+
+#define STV090x_Pn_CFRINITy(__x, __y) (0xF449 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_CFRINIT0 STV090x_Pn_CFRINITy(1, 0)
+#define STV090x_P1_CFRINIT1 STV090x_Pn_CFRINITy(1, 1)
+#define STV090x_P2_CFRINIT0 STV090x_Pn_CFRINITy(2, 0)
+#define STV090x_P2_CFRINIT1 STV090x_Pn_CFRINITy(2, 1)
+#define STV090x_OFFST_Px_CFR_INIT_FIELD 0
+#define STV090x_WIDTH_Px_CFR_INIT_FIELD 8
+
+#define STV090x_Px_CFRINC1(__x) (0xF44A - (__x - 1) * 0x200)
+#define STV090x_P1_CFRINC1 STV090x_Px_CFRINC1(1)
+#define STV090x_P2_CFRINC1 STV090x_Px_CFRINC1(2)
+#define STV090x_OFFST_Px_CFR_INC1_FIELD 0
+#define STV090x_WIDTH_Px_CFR_INC1_FIELD 7
+
+#define STV090x_Px_CFRINC0(__x) (0xF44B - (__x - 1) * 0x200)
+#define STV090x_P1_CFRINC0 STV090x_Px_CFRINC0(1)
+#define STV090x_P2_CFRINC0 STV090x_Px_CFRINC0(2)
+#define STV090x_OFFST_Px_CFR_INC0_FIELD 4
+#define STV090x_WIDTH_Px_CFR_INC0_FIELD 4
+
+#define STV090x_Pn_CFRy(__x, __y) (0xF44E - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_CFR0 STV090x_Pn_CFRy(1, 0)
+#define STV090x_P1_CFR1 STV090x_Pn_CFRy(1, 1)
+#define STV090x_P1_CFR2 STV090x_Pn_CFRy(1, 2)
+#define STV090x_P2_CFR0 STV090x_Pn_CFRy(2, 0)
+#define STV090x_P2_CFR1 STV090x_Pn_CFRy(2, 1)
+#define STV090x_P2_CFR2 STV090x_Pn_CFRy(2, 2)
+#define STV090x_OFFST_Px_CAR_FREQ_FIELD 0
+#define STV090x_WIDTH_Px_CAR_FREQ_FIELD 8
+
+#define STV090x_Px_LDI(__x) (0xF44F - (__x - 1) * 0x200)
+#define STV090x_P1_LDI STV090x_Px_LDI(1)
+#define STV090x_P2_LDI STV090x_Px_LDI(2)
+#define STV090x_OFFST_Px_LOCK_DET_INTEGR_FIELD 0
+#define STV090x_WIDTH_Px_LOCK_DET_INTEGR_FIELD 8
+
+#define STV090x_Px_TMGCFG(__x) (0xF450 - (__x - 1) * 0x200)
+#define STV090x_P1_TMGCFG STV090x_Px_TMGCFG(1)
+#define STV090x_P2_TMGCFG STV090x_Px_TMGCFG(2)
+#define STV090x_OFFST_Px_TMGLOCK_BETA_FIELD 6
+#define STV090x_WIDTH_Px_TMGLOCK_BETA_FIELD 2
+#define STV090x_OFFST_Px_DO_TIMING_FIELD 4
+#define STV090x_WIDTH_Px_DO_TIMING_FIELD 1
+#define STV090x_OFFST_Px_TMG_MINFREQ_FIELD 0
+#define STV090x_WIDTH_Px_TMG_MINFREQ_FIELD 2
+
+#define STV090x_Px_RTC(__x) (0xF451 - (__x - 1) * 0x200)
+#define STV090x_P1_RTC STV090x_Px_RTC(1)
+#define STV090x_P2_RTC STV090x_Px_RTC(2)
+#define STV090x_OFFST_Px_TMGALPHA_EXP_FIELD 4
+#define STV090x_WIDTH_Px_TMGALPHA_EXP_FIELD 4
+#define STV090x_OFFST_Px_TMGBETA_EXP_FIELD 0
+#define STV090x_WIDTH_Px_TMGBETA_EXP_FIELD 4
+
+#define STV090x_Px_RTCS2(__x) (0xF452 - (__x - 1) * 0x200)
+#define STV090x_P1_RTCS2 STV090x_Px_RTCS2(1)
+#define STV090x_P2_RTCS2 STV090x_Px_RTCS2(2)
+#define STV090x_OFFST_Px_TMGALPHAS2_EXP_FIELD 4
+#define STV090x_WIDTH_Px_TMGALPHAS2_EXP_FIELD 4
+#define STV090x_OFFST_Px_TMGBETAS2_EXP_FIELD 0
+#define STV090x_WIDTH_Px_TMGBETAS2_EXP_FIELD 4
+
+#define STV090x_Px_TMGTHRISE(__x) (0xF453 - (__x - 1) * 0x200)
+#define STV090x_P1_TMGTHRISE STV090x_Px_TMGTHRISE(1)
+#define STV090x_P2_TMGTHRISE STV090x_Px_TMGTHRISE(2)
+#define STV090x_OFFST_Px_TMGLOCK_THRISE_FIELD 0
+#define STV090x_WIDTH_Px_TMGLOCK_THRISE_FIELD 8
+
+#define STV090x_Px_TMGTHFALL(__x) (0xF454 - (__x - 1) * 0x200)
+#define STV090x_P1_TMGTHFALL STV090x_Px_TMGTHFALL(1)
+#define STV090x_P2_TMGTHFALL STV090x_Px_TMGTHFALL(2)
+#define STV090x_OFFST_Px_TMGLOCK_THFALL_FIELD 0
+#define STV090x_WIDTH_Px_TMGLOCK_THFALL_FIELD 8
+
+#define STV090x_Px_SFRUPRATIO(__x) (0xF455 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRUPRATIO STV090x_Px_SFRUPRATIO(1)
+#define STV090x_P2_SFRUPRATIO STV090x_Px_SFRUPRATIO(2)
+#define STV090x_OFFST_Px_SFR_UPRATIO_FIELD 0
+#define STV090x_WIDTH_Px_SFR_UPRATIO_FIELD 8
+
+#define STV090x_Px_SFRLOWRATIO(__x) (0xF456 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRLOWRATIO STV090x_Px_SFRLOWRATIO(1)
+#define STV090x_P2_SFRLOWRATIO STV090x_Px_SFRLOWRATIO(2)
+#define STV090x_OFFST_Px_SFR_LOWRATIO_FIELD 0
+#define STV090x_WIDTH_Px_SFR_LOWRATIO_FIELD 8
+
+#define STV090x_Px_KREFTMG(__x) (0xF458 - (__x - 1) * 0x200)
+#define STV090x_P1_KREFTMG STV090x_Px_KREFTMG(1)
+#define STV090x_P2_KREFTMG STV090x_Px_KREFTMG(2)
+#define STV090x_OFFST_Px_KREF_TMG_FIELD 0
+#define STV090x_WIDTH_Px_KREF_TMG_FIELD 8
+
+#define STV090x_Px_SFRSTEP(__x) (0xF459 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRSTEP STV090x_Px_SFRSTEP(1)
+#define STV090x_P2_SFRSTEP STV090x_Px_SFRSTEP(2)
+#define STV090x_OFFST_Px_SFR_SCANSTEP_FIELD 4
+#define STV090x_WIDTH_Px_SFR_SCANSTEP_FIELD 4
+#define STV090x_OFFST_Px_SFR_CENTERSTEP_FIELD 0
+#define STV090x_WIDTH_Px_SFR_CENTERSTEP_FIELD 4
+
+#define STV090x_Px_TMGCFG2(__x) (0xF45A - (__x - 1) * 0x200)
+#define STV090x_P1_TMGCFG2 STV090x_Px_TMGCFG2(1)
+#define STV090x_P2_TMGCFG2 STV090x_Px_TMGCFG2(2)
+#define STV090x_OFFST_Px_SFRRATIO_FINE_FIELD 0
+#define STV090x_WIDTH_Px_SFRRATIO_FINE_FIELD 1
+
+#define STV090x_Px_SFRINIT1(__x) (0xF45E - (__x - 1) * 0x200)
+#define STV090x_P1_SFRINIT1 STV090x_Px_SFRINIT1(1)
+#define STV090x_P2_SFRINIT1 STV090x_Px_SFRINIT1(2)
+#define STV090x_OFFST_Px_SFR_INIT_FIELD 0
+#define STV090x_WIDTH_Px_SFR_INIT_FIELD 8
+
+#define STV090x_Px_SFRINIT0(__x) (0xF45F - (__x - 1) * 0x200)
+#define STV090x_P1_SFRINIT0 STV090x_Px_SFRINIT0(1)
+#define STV090x_P2_SFRINIT0 STV090x_Px_SFRINIT0(2)
+#define STV090x_OFFST_Px_SFR_INIT_FIELD 0
+#define STV090x_WIDTH_Px_SFR_INIT_FIELD 8
+
+#define STV090x_Px_SFRUP1(__x) (0xF460 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRUP1 STV090x_Px_SFRUP1(1)
+#define STV090x_P2_SFRUP1 STV090x_Px_SFRUP1(2)
+#define STV090x_OFFST_Px_SYMB_FREQ_UP1_FIELD 0
+#define STV090x_WIDTH_Px_SYMB_FREQ_UP1_FIELD 7
+
+#define STV090x_Px_SFRUP0(__x) (0xF461 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRUP0 STV090x_Px_SFRUP0(1)
+#define STV090x_P2_SFRUP0 STV090x_Px_SFRUP0(2)
+#define STV090x_OFFST_Px_SYMB_FREQ_UP0_FIELD 0
+#define STV090x_WIDTH_Px_SYMB_FREQ_UP0_FIELD 8
+
+#define STV090x_Px_SFRLOW1(__x) (0xF462 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRLOW1 STV090x_Px_SFRLOW1(1)
+#define STV090x_P2_SFRLOW1 STV090x_Px_SFRLOW1(2)
+#define STV090x_OFFST_Px_SYMB_FREQ_LOW1_FIELD 0
+#define STV090x_WIDTH_Px_SYMB_FREQ_LOW1_FIELD 7
+
+#define STV090x_Px_SFRLOW0(__x) (0xF463 - (__x - 1) * 0x200)
+#define STV090x_P1_SFRLOW0 STV090x_Px_SFRLOW0(1)
+#define STV090x_P2_SFRLOW0 STV090x_Px_SFRLOW0(2)
+#define STV090x_OFFST_Px_SYMB_FREQ_LOW0_FIELD 0
+#define STV090x_WIDTH_Px_SYMB_FREQ_LOW0_FIELD 8
+
+#define STV090x_Px_SFRy(__x, __y) (0xF464 - (__x-1) * 0x200 + (3 - __y))
+#define STV090x_P1_SFR0 STV090x_Px_SFRy(1, 0)
+#define STV090x_P1_SFR1 STV090x_Px_SFRy(1, 1)
+#define STV090x_P1_SFR2 STV090x_Px_SFRy(1, 2)
+#define STV090x_P1_SFR3 STV090x_Px_SFRy(1, 3)
+#define STV090x_P2_SFR0 STV090x_Px_SFRy(2, 0)
+#define STV090x_P2_SFR1 STV090x_Px_SFRy(2, 1)
+#define STV090x_P2_SFR2 STV090x_Px_SFRy(2, 2)
+#define STV090x_P2_SFR3 STV090x_Px_SFRy(2, 3)
+#define STV090x_OFFST_Px_SYMB_FREQ_FIELD 0
+#define STV090x_WIDTH_Px_SYMB_FREQ_FIELD 32
+
+#define STV090x_Px_TMGREG2(__x) (0xF468 - (__x - 1) * 0x200)
+#define STV090x_P1_TMGREG2 STV090x_Px_TMGREG2(1)
+#define STV090x_P2_TMGREG2 STV090x_Px_TMGREG2(2)
+#define STV090x_OFFST_Px_TMGREG_FIELD 0
+#define STV090x_WIDTH_Px_TMGREG_FIELD 8
+
+#define STV090x_Px_TMGREG1(__x) (0xF469 - (__x - 1) * 0x200)
+#define STV090x_P1_TMGREG1 STV090x_Px_TMGREG1(1)
+#define STV090x_P2_TMGREG1 STV090x_Px_TMGREG1(2)
+#define STV090x_OFFST_Px_TMGREG_FIELD 0
+#define STV090x_WIDTH_Px_TMGREG_FIELD 8
+
+#define STV090x_Px_TMGREG0(__x) (0xF46A - (__x - 1) * 0x200)
+#define STV090x_P1_TMGREG0 STV090x_Px_TMGREG0(1)
+#define STV090x_P2_TMGREG0 STV090x_Px_TMGREG0(2)
+#define STV090x_OFFST_Px_TMGREG_FIELD 0
+#define STV090x_WIDTH_Px_TMGREG_FIELD 8
+
+#define STV090x_Px_TMGLOCKy(__x, __y) (0xF46C - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_TMGLOCK0 STV090x_Px_TMGLOCKy(1, 0)
+#define STV090x_P1_TMGLOCK1 STV090x_Px_TMGLOCKy(1, 1)
+#define STV090x_P2_TMGLOCK0 STV090x_Px_TMGLOCKy(2, 0)
+#define STV090x_P2_TMGLOCK1 STV090x_Px_TMGLOCKy(2, 1)
+#define STV090x_OFFST_Px_TMGLOCK_LEVEL_FIELD 0
+#define STV090x_WIDTH_Px_TMGLOCK_LEVEL_FIELD 8
+
+#define STV090x_Px_TMGOBS(__x) (0xF46D - (__x - 1) * 0x200)
+#define STV090x_P1_TMGOBS STV090x_Px_TMGOBS(1)
+#define STV090x_P2_TMGOBS STV090x_Px_TMGOBS(2)
+#define STV090x_OFFST_Px_ROLLOFF_STATUS_FIELD 6
+#define STV090x_WIDTH_Px_ROLLOFF_STATUS_FIELD 2
+
+#define STV090x_Px_EQUALCFG(__x) (0xF46F - (__x - 1) * 0x200)
+#define STV090x_P1_EQUALCFG STV090x_Px_EQUALCFG(1)
+#define STV090x_P2_EQUALCFG STV090x_Px_EQUALCFG(2)
+#define STV090x_OFFST_Px_EQUAL_ON_FIELD 6
+#define STV090x_WIDTH_Px_EQUAL_ON_FIELD 1
+#define STV090x_OFFST_Px_MU_EQUALDFE_FIELD 0
+#define STV090x_WIDTH_Px_MU_EQUALDFE_FIELD 3
+
+#define STV090x_Px_EQUAIy(__x, __y) (0xf470 - (__x - 1) * 0x200 + (__y - 1))
+#define STV090x_P1_EQUAI1 STV090x_Px_EQUAIy(1, 1)
+#define STV090x_P1_EQUAI2 STV090x_Px_EQUAIy(1, 2)
+#define STV090x_P1_EQUAI3 STV090x_Px_EQUAIy(1, 3)
+#define STV090x_P1_EQUAI4 STV090x_Px_EQUAIy(1, 4)
+#define STV090x_P1_EQUAI5 STV090x_Px_EQUAIy(1, 5)
+#define STV090x_P1_EQUAI6 STV090x_Px_EQUAIy(1, 6)
+#define STV090x_P1_EQUAI7 STV090x_Px_EQUAIy(1, 7)
+#define STV090x_P1_EQUAI8 STV090x_Px_EQUAIy(1, 8)
+
+#define STV090x_P2_EQUAI1 STV090x_Px_EQUAIy(2, 1)
+#define STV090x_P2_EQUAI2 STV090x_Px_EQUAIy(2, 2)
+#define STV090x_P2_EQUAI3 STV090x_Px_EQUAIy(2, 3)
+#define STV090x_P2_EQUAI4 STV090x_Px_EQUAIy(2, 4)
+#define STV090x_P2_EQUAI5 STV090x_Px_EQUAIy(2, 5)
+#define STV090x_P2_EQUAI6 STV090x_Px_EQUAIy(2, 6)
+#define STV090x_P2_EQUAI7 STV090x_Px_EQUAIy(2, 7)
+#define STV090x_P2_EQUAI8 STV090x_Px_EQUAIy(2, 8)
+#define STV090x_OFFST_Px_EQUA_ACCIy_FIELD 0
+#define STV090x_WIDTH_Px_EQUA_ACCIy_FIELD 8
+
+#define STV090x_Px_EQUAQy(__x, __y) (0xf471 - (__x - 1) * 0x200 + (__y - 1))
+#define STV090x_P1_EQUAQ1 STV090x_Px_EQUAQy(1, 1)
+#define STV090x_P1_EQUAQ2 STV090x_Px_EQUAQy(1, 2)
+#define STV090x_P1_EQUAQ3 STV090x_Px_EQUAQy(1, 3)
+#define STV090x_P1_EQUAQ4 STV090x_Px_EQUAQy(1, 4)
+#define STV090x_P1_EQUAQ5 STV090x_Px_EQUAQy(1, 5)
+#define STV090x_P1_EQUAQ6 STV090x_Px_EQUAQy(1, 6)
+#define STV090x_P1_EQUAQ7 STV090x_Px_EQUAQy(1, 7)
+#define STV090x_P1_EQUAQ8 STV090x_Px_EQUAQy(1, 8)
+
+#define STV090x_P2_EQUAQ1 STV090x_Px_EQUAQy(2, 1)
+#define STV090x_P2_EQUAQ2 STV090x_Px_EQUAQy(2, 2)
+#define STV090x_P2_EQUAQ3 STV090x_Px_EQUAQy(2, 3)
+#define STV090x_P2_EQUAQ4 STV090x_Px_EQUAQy(2, 4)
+#define STV090x_P2_EQUAQ5 STV090x_Px_EQUAQy(2, 5)
+#define STV090x_P2_EQUAQ6 STV090x_Px_EQUAQy(2, 6)
+#define STV090x_P2_EQUAQ7 STV090x_Px_EQUAQy(2, 7)
+#define STV090x_P2_EQUAQ8 STV090x_Px_EQUAQy(2, 8)
+#define STV090x_OFFST_Px_EQUA_ACCQy_FIELD 0
+#define STV090x_WIDTH_Px_EQUA_ACCQy_FIELD 8
+
+#define STV090x_Px_NNOSDATATy(__x, __y) (0xf481 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NNOSDATAT0 STV090x_Px_NNOSDATATy(1, 0)
+#define STV090x_P1_NNOSDATAT1 STV090x_Px_NNOSDATATy(1, 1)
+#define STV090x_P2_NNOSDATAT0 STV090x_Px_NNOSDATATy(2, 0)
+#define STV090x_P2_NNOSDATAT1 STV090x_Px_NNOSDATATy(2, 1)
+#define STV090x_OFFST_Px_NOSDATAT_NORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSDATAT_NORMED_FIELD 8
+
+#define STV090x_Px_NNOSDATAy(__x, __y) (0xf483 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NNOSDATA0 STV090x_Px_NNOSDATAy(1, 0)
+#define STV090x_P1_NNOSDATA1 STV090x_Px_NNOSDATAy(1, 1)
+#define STV090x_P2_NNOSDATA0 STV090x_Px_NNOSDATAy(2, 0)
+#define STV090x_P2_NNOSDATA1 STV090x_Px_NNOSDATAy(2, 1)
+#define STV090x_OFFST_Px_NOSDATA_NORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSDATA_NORMED_FIELD 8
+
+#define STV090x_Px_NNOSPLHTy(__x, __y) (0xf485 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NNOSPLHT0 STV090x_Px_NNOSPLHTy(1, 0)
+#define STV090x_P1_NNOSPLHT1 STV090x_Px_NNOSPLHTy(1, 1)
+#define STV090x_P2_NNOSPLHT0 STV090x_Px_NNOSPLHTy(2, 0)
+#define STV090x_P2_NNOSPLHT1 STV090x_Px_NNOSPLHTy(2, 1)
+#define STV090x_OFFST_Px_NOSPLHT_NORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSPLHT_NORMED_FIELD 8
+
+#define STV090x_Px_NNOSPLHy(__x, __y) (0xf487 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NNOSPLH0 STV090x_Px_NNOSPLHy(1, 0)
+#define STV090x_P1_NNOSPLH1 STV090x_Px_NNOSPLHy(1, 1)
+#define STV090x_P2_NNOSPLH0 STV090x_Px_NNOSPLHy(2, 0)
+#define STV090x_P2_NNOSPLH1 STV090x_Px_NNOSPLHy(2, 1)
+#define STV090x_OFFST_Px_NOSPLH_NORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSPLH_NORMED_FIELD 8
+
+#define STV090x_Px_NOSDATATy(__x, __y) (0xf489 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NOSDATAT0 STV090x_Px_NOSDATATy(1, 0)
+#define STV090x_P1_NOSDATAT1 STV090x_Px_NOSDATATy(1, 1)
+#define STV090x_P2_NOSDATAT0 STV090x_Px_NOSDATATy(2, 0)
+#define STV090x_P2_NOSDATAT1 STV090x_Px_NOSDATATy(2, 1)
+#define STV090x_OFFST_Px_NOSDATAT_UNNORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSDATAT_UNNORMED_FIELD 8
+
+#define STV090x_Px_NOSDATAy(__x, __y) (0xf48b - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NOSDATA0 STV090x_Px_NOSDATAy(1, 0)
+#define STV090x_P1_NOSDATA1 STV090x_Px_NOSDATAy(1, 1)
+#define STV090x_P2_NOSDATA0 STV090x_Px_NOSDATAy(2, 0)
+#define STV090x_P2_NOSDATA1 STV090x_Px_NOSDATAy(2, 1)
+#define STV090x_OFFST_Px_NOSDATA_UNNORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSDATA_UNNORMED_FIELD 8
+
+#define STV090x_Px_NOSPLHTy(__x, __y) (0xf48d - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_NOSPLHT0 STV090x_Px_NOSPLHTy(1, 0)
+#define STV090x_P1_NOSPLHT1 STV090x_Px_NOSPLHTy(1, 1)
+#define STV090x_P2_NOSPLHT0 STV090x_Px_NOSPLHTy(2, 0)
+#define STV090x_P2_NOSPLHT1 STV090x_Px_NOSPLHTy(2, 1)
+#define STV090x_OFFST_Px_NOSPLHT_UNNORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSPLHT_UNNORMED_FIELD 8
+
+#define STV090x_Px_NOSPLHy(__x, __y) (0xf48f - (__x - 1) * 0x200 - __y * 0x1)
+#define STv090x_P1_NOSPLH0 STV090x_Px_NOSPLHy(1, 0)
+#define STv090x_P1_NOSPLH1 STV090x_Px_NOSPLHy(1, 1)
+#define STv090x_P2_NOSPLH0 STV090x_Px_NOSPLHy(2, 0)
+#define STv090x_P2_NOSPLH1 STV090x_Px_NOSPLHy(2, 1)
+#define STV090x_OFFST_Px_NOSPLH_UNNORMED_FIELD 0
+#define STV090x_WIDTH_Px_NOSPLH_UNNORMED_FIELD 8
+
+#define STV090x_Px_CAR2CFG(__x) (0xf490 - (__x - 1) * 0x200)
+#define STV090x_P1_CAR2CFG STV090x_Px_CAR2CFG(1)
+#define STV090x_P2_CAR2CFG STV090x_Px_CAR2CFG(2)
+#define STV090x_OFFST_Px_PN4_SELECT_FIELD 6
+#define STV090x_WIDTH_Px_PN4_SELECT_FIELD 1
+#define STV090x_OFFST_Px_CFR2_STOPDVBS1_FIELD 5
+#define STV090x_WIDTH_Px_CFR2_STOPDVBS1_FIELD 1
+#define STV090x_OFFST_Px_ROTA2ON_FIELD 2
+#define STV090x_WIDTH_Px_ROTA2ON_FIELD 1
+#define STV090x_OFFST_Px_PH_DET_ALGO2_FIELD 0
+#define STV090x_WIDTH_Px_PH_DET_ALGO2_FIELD 2
+
+#define STV090x_Px_ACLC2(__x) (0xf491 - (__x - 1) * 0x200)
+#define STV090x_P1_ACLC2 STV090x_Px_ACLC2(1)
+#define STV090x_P2_ACLC2 STV090x_Px_ACLC2(2)
+#define STV090x_OFFST_Px_CAR2_ALPHA_MANT_FIELD 4
+#define STV090x_WIDTH_Px_CAR2_ALPHA_MANT_FIELD 2
+#define STV090x_OFFST_Px_CAR2_ALPHA_EXP_FIELD 0
+#define STV090x_WIDTH_Px_CAR2_ALPHA_EXP_FIELD 4
+
+#define STV090x_Px_BCLC2(__x) (0xf492 - (__x - 1) * 0x200)
+#define STV090x_P1_BCLC2 STV090x_Px_BCLC2(1)
+#define STV090x_P2_BCLC2 STV090x_Px_BCLC2(2)
+#define STV090x_OFFST_Px_CAR2_BETA_MANT_FIELD 4
+#define STV090x_WIDTH_Px_CAR2_BETA_MANT_FIELD 2
+#define STV090x_OFFST_Px_CAR2_BETA_EXP_FIELD 0
+#define STV090x_WIDTH_Px_CAR2_BETA_EXP_FIELD 4
+
+#define STV090x_Px_ACLC2S2Q(__x) (0xf497 - (__x - 1) * 0x200)
+#define STV090x_P1_ACLC2S2Q STV090x_Px_ACLC2S2Q(1)
+#define STV090x_P2_ACLC2S2Q STV090x_Px_ACLC2S2Q(2)
+#define STV090x_OFFST_Px_ENAB_SPSKSYMB_FIELD 7
+#define STV090x_WIDTH_Px_ENAB_SPSKSYMB_FIELD 1
+#define STV090x_OFFST_Px_CAR2S2_Q_ALPH_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_Q_ALPH_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_Q_ALPH_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_Q_ALPH_E_FIELD 4
+
+#define STV090x_Px_ACLC2S28(__x) (0xf498 - (__x - 1) * 0x200)
+#define STV090x_P1_ACLC2S28 STV090x_Px_ACLC2S28(1)
+#define STV090x_P2_ACLC2S28 STV090x_Px_ACLC2S28(2)
+#define STV090x_OFFST_Px_CAR2S2_8_ALPH_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_8_ALPH_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_8_ALPH_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_8_ALPH_E_FIELD 4
+
+#define STV090x_Px_ACLC2S216A(__x) (0xf499 - (__x - 1) * 0x200)
+#define STV090x_P1_ACLC2S216A STV090x_Px_ACLC2S216A(1)
+#define STV090x_P2_ACLC2S216A STV090x_Px_ACLC2S216A(2)
+#define STV090x_OFFST_Px_CAR2S2_16A_ALPH_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_16A_ALPH_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_16A_ALPH_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_16A_ALPH_E_FIELD 4
+
+#define STV090x_Px_ACLC2S232A(__x) (0xf499 - (__x - 1) * 0x200)
+#define STV090x_P1_ACLC2S232A STV090x_Px_ACLC2S232A(1)
+#define STV090x_P2_ACLC2S232A STV090x_Px_ACLC2S232A(2)
+#define STV090x_OFFST_Px_CAR2S2_32A_ALPH_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_32A_ALPH_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_32A_ALPH_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_32A_ALPH_E_FIELD 4
+
+#define STV090x_Px_BCLC2S2Q(__x) (0xf49c - (__x - 1) * 0x200)
+#define STV090x_P1_BCLC2S2Q STV090x_Px_BCLC2S2Q(1)
+#define STV090x_P2_BCLC2S2Q STV090x_Px_BCLC2S2Q(2)
+#define STV090x_OFFST_Px_CAR2S2_Q_BETA_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_Q_BETA_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_Q_BETA_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_Q_BETA_E_FIELD 4
+
+#define STV090x_Px_BCLC2S28(__x) (0xf49d - (__x - 1) * 0x200)
+#define STV090x_P1_BCLC2S28 STV090x_Px_BCLC2S28(1)
+#define STV090x_P2_BCLC2S28 STV090x_Px_BCLC2S28(1)
+#define STV090x_OFFST_Px_CAR2S2_8_BETA_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_8_BETA_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_8_BETA_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_8_BETA_E_FIELD 4
+
+#define STV090x_Px_BCLC2S216A(__x) (0xf49d - (__x - 1) * 0x200)
+#define STV090x_P1_BCLC2S216A STV090x_Px_BCLC2S216A(1)
+#define STV090x_P2_BCLC2S216A STV090x_Px_BCLC2S216A(1)
+#define STV090x_OFFST_Px_CAR2S2_16A_BETA_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_16A_BETA_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_16A_BETA_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_16A_BETA_E_FIELD 4
+
+#define STV090x_Px_BCLC2S232A(__x) (0xf49d - (__x - 1) * 0x200)
+#define STV090x_P1_BCLC2S232A STV090x_Px_BCLC2S232A(1)
+#define STV090x_P2_BCLC2S232A STV090x_Px_BCLC2S232A(1)
+#define STV090x_OFFST_Px_CAR2S2_32A_BETA_M_FIELD 4
+#define STV090x_WIDTH_Px_CAR2S2_32A_BETA_M_FIELD 2
+#define STV090x_OFFST_Px_CAR2S2_32A_BETA_E_FIELD 0
+#define STV090x_WIDTH_Px_CAR2S2_32A_BETA_E_FIELD 4
+
+#define STV090x_Px_PLROOT2(__x) (0xf4ac - (__x - 1) * 0x200)
+#define STV090x_P1_PLROOT2 STV090x_Px_PLROOT2(1)
+#define STV090x_P2_PLROOT2 STV090x_Px_PLROOT2(2)
+#define STV090x_OFFST_Px_PLSCRAMB_MODE_FIELD 2
+#define STV090x_WIDTH_Px_PLSCRAMB_MODE_FIELD 2
+#define STV090x_OFFST_Px_PLSCRAMB_ROOT_FIELD 0
+#define STV090x_WIDTH_Px_PLSCRAMB_ROOT_FIELD 2
+
+#define STV090x_Px_PLROOT1(__x) (0xf4ad - (__x - 1) * 0x200)
+#define STV090x_P1_PLROOT1 STV090x_Px_PLROOT1(1)
+#define STV090x_P2_PLROOT1 STV090x_Px_PLROOT1(2)
+#define STV090x_OFFST_Px_PLSCRAMB_ROOT1_FIELD 0
+#define STV090x_WIDTH_Px_PLSCRAMB_ROOT1_FIELD 8
+
+#define STV090x_Px_PLROOT0(__x) (0xf4ae - (__x - 1) * 0x200)
+#define STV090x_P1_PLROOT0 STV090x_Px_PLROOT0(1)
+#define STV090x_P2_PLROOT0 STV090x_Px_PLROOT0(2)
+#define STV090x_OFFST_Px_PLSCRAMB_ROOT0_FIELD 0
+#define STV090x_WIDTH_Px_PLSCRAMB_ROOT0_FIELD 8
+
+#define STV090x_Px_MODCODLST0(__x) (0xf4b0 - (__x - 1) * 0x200) /* check */
+#define STV090x_P1_MODCODLST0 STV090x_Px_MODCODLST0(1)
+#define STV090x_P2_MODCODLST0 STV090x_Px_MODCODLST0(2)
+
+#define STV090x_Px_MODCODLST1(__x) (0xf4b1 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST1 STV090x_Px_MODCODLST1(1)
+#define STV090x_P2_MODCODLST1 STV090x_Px_MODCODLST1(2)
+#define STV090x_OFFST_Px_DIS_MODCOD29_FIELD 4
+#define STV090x_WIDTH_Px_DIS_MODCOD29T_FIELD 4
+#define STV090x_OFFST_Px_DIS_32PSK_9_10_FIELD 0
+#define STV090x_WIDTH_Px_DIS_32PSK_9_10_FIELD 4
+
+#define STV090x_Px_MODCODLST2(__x) (0xf4b2 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST2 STV090x_Px_MODCODLST2(1)
+#define STV090x_P2_MODCODLST2 STV090x_Px_MODCODLST2(2)
+#define STV090x_OFFST_Px_DIS_32PSK_8_9_FIELD 4
+#define STV090x_WIDTH_Px_DIS_32PSK_8_9_FIELD 4
+#define STV090x_OFFST_Px_DIS_32PSK_5_6_FIELD 0
+#define STV090x_WIDTH_Px_DIS_32PSK_5_6_FIELD 4
+
+#define STV090x_Px_MODCODLST3(__x) (0xf4b3 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST3 STV090x_Px_MODCODLST3(1)
+#define STV090x_P2_MODCODLST3 STV090x_Px_MODCODLST3(2)
+#define STV090x_OFFST_Px_DIS_32PSK_4_5_FIELD 4
+#define STV090x_WIDTH_Px_DIS_32PSK_4_5_FIELD 4
+#define STV090x_OFFST_Px_DIS_32PSK_3_4_FIELD 0
+#define STV090x_WIDTH_Px_DIS_32PSK_3_4_FIELD 4
+
+#define STV090x_Px_MODCODLST4(__x) (0xf4b4 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST4 STV090x_Px_MODCODLST4(1)
+#define STV090x_P2_MODCODLST4 STV090x_Px_MODCODLST4(2)
+#define STV090x_OFFST_Px_DIS_16PSK_9_10_FIELD 4
+#define STV090x_WIDTH_Px_DIS_16PSK_9_10_FIELD 4
+#define STV090x_OFFST_Px_DIS_16PSK_8_9_FIELD 0
+#define STV090x_WIDTH_Px_DIS_16PSK_8_9_FIELD 4
+
+#define STV090x_Px_MODCODLST5(__x) (0xf4b5 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST5 STV090x_Px_MODCODLST5(1)
+#define STV090x_P2_MODCODLST5 STV090x_Px_MODCODLST5(2)
+#define STV090x_OFFST_Px_DIS_16PSK_5_6_FIELD 4
+#define STV090x_WIDTH_Px_DIS_16PSK_5_6_FIELD 4
+#define STV090x_OFFST_Px_DIS_16PSK_4_5_FIELD 0
+#define STV090x_WIDTH_Px_DIS_16PSK_4_5_FIELD 4
+
+#define STV090x_Px_MODCODLST6(__x) (0xf4b6 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST6 STV090x_Px_MODCODLST6(1)
+#define STV090x_P2_MODCODLST6 STV090x_Px_MODCODLST6(2)
+#define STV090x_OFFST_Px_DIS_16PSK_3_4_FIELD 4
+#define STV090x_WIDTH_Px_DIS_16PSK_3_4_FIELD 4
+#define STV090x_OFFST_Px_DIS_16PSK_2_3_FIELD 0
+#define STV090x_WIDTH_Px_DIS_16PSK_2_3_FIELD 4
+
+#define STV090x_Px_MODCODLST7(__x) (0xf4b7 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST7 STV090x_Px_MODCODLST7(1)
+#define STV090x_P2_MODCODLST7 STV090x_Px_MODCODLST7(2)
+#define STV090x_OFFST_Px_DIS_8P_9_10_FIELD 4
+#define STV090x_WIDTH_Px_DIS_8P_9_10_FIELD 4
+#define STV090x_OFFST_Px_DIS_8P_8_9_FIELD 0
+#define STV090x_WIDTH_Px_DIS_8P_8_9_FIELD 4
+
+#define STV090x_Px_MODCODLST8(__x) (0xf4b8 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST8 STV090x_Px_MODCODLST8(1)
+#define STV090x_P2_MODCODLST8 STV090x_Px_MODCODLST8(2)
+#define STV090x_OFFST_Px_DIS_8P_5_6_FIELD 4
+#define STV090x_WIDTH_Px_DIS_8P_5_6_FIELD 4
+#define STV090x_OFFST_Px_DIS_8P_3_4_FIELD 0
+#define STV090x_WIDTH_Px_DIS_8P_3_4_FIELD 4
+
+#define STV090x_Px_MODCODLST9(__x) (0xf4b9 - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLST9 STV090x_Px_MODCODLST9(1)
+#define STV090x_P2_MODCODLST9 STV090x_Px_MODCODLST9(2)
+#define STV090x_OFFST_Px_DIS_8P_2_3_FIELD 4
+#define STV090x_WIDTH_Px_DIS_8P_2_3_FIELD 4
+#define STV090x_OFFST_Px_DIS_8P_3_5_FIELD 0
+#define STV090x_WIDTH_Px_DIS_8P_3_5_FIELD 4
+
+#define STV090x_Px_MODCODLSTA(__x) (0xf4ba - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLSTA STV090x_Px_MODCODLSTA(1)
+#define STV090x_P2_MODCODLSTA STV090x_Px_MODCODLSTA(2)
+#define STV090x_OFFST_Px_DIS_QP_9_10_FIELD 4
+#define STV090x_WIDTH_Px_DIS_QP_9_10_FIELD 4
+#define STV090x_OFFST_Px_DIS_QP_8_9_FIELD 0
+#define STV090x_WIDTH_Px_DIS_QP_8_9_FIELD 4
+
+#define STV090x_Px_MODCODLSTB(__x) (0xf4bb - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLSTB STV090x_Px_MODCODLSTB(1)
+#define STV090x_P2_MODCODLSTB STV090x_Px_MODCODLSTB(2)
+#define STV090x_OFFST_Px_DIS_QP_5_6_FIELD 4
+#define STV090x_WIDTH_Px_DIS_QP_5_6_FIELD 4
+#define STV090x_OFFST_Px_DIS_QP_4_5_FIELD 0
+#define STV090x_WIDTH_Px_DIS_QP_4_5_FIELD 4
+
+#define STV090x_Px_MODCODLSTC(__x) (0xf4bc - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLSTC STV090x_Px_MODCODLSTC(1)
+#define STV090x_P2_MODCODLSTC STV090x_Px_MODCODLSTC(2)
+#define STV090x_OFFST_Px_DIS_QP_3_4_FIELD 4
+#define STV090x_WIDTH_Px_DIS_QP_3_4_FIELD 4
+#define STV090x_OFFST_Px_DIS_QP_2_3_FIELD 0
+#define STV090x_WIDTH_Px_DIS_QP_2_3_FIELD 4
+
+#define STV090x_Px_MODCODLSTD(__x) (0xf4bd - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLSTD STV090x_Px_MODCODLSTD(1)
+#define STV090x_P2_MODCODLSTD STV090x_Px_MODCODLSTD(2)
+#define STV090x_OFFST_Px_DIS_QP_3_5_FIELD 4
+#define STV090x_WIDTH_Px_DIS_QP_3_5_FIELD 4
+#define STV090x_OFFST_Px_DIS_QP_1_2_FIELD 0
+#define STV090x_WIDTH_Px_DIS_QP_1_2_FIELD 4
+
+#define STV090x_Px_MODCODLSTE(__x) (0xf4be - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLSTE STV090x_Px_MODCODLSTE(1)
+#define STV090x_P2_MODCODLSTE STV090x_Px_MODCODLSTE(2)
+#define STV090x_OFFST_Px_DIS_QP_2_5_FIELD 4
+#define STV090x_WIDTH_Px_DIS_QP_2_5_FIELD 4
+#define STV090x_OFFST_Px_DIS_QP_1_3_FIELD 0
+#define STV090x_WIDTH_Px_DIS_QP_1_3_FIELD 4
+
+#define STV090x_Px_MODCODLSTF(__x) (0xf4bf - (__x - 1) * 0x200)
+#define STV090x_P1_MODCODLSTF STV090x_Px_MODCODLSTF(1)
+#define STV090x_P2_MODCODLSTF STV090x_Px_MODCODLSTF(2)
+#define STV090x_OFFST_Px_DIS_QP_1_4_FIELD 4
+#define STV090x_WIDTH_Px_DIS_QP_1_4_FIELD 4
+
+#define STV090x_Px_GAUSSR0(__x) (0xf4c0 - (__x - 1) * 0x200)
+#define STV090x_P1_GAUSSR0 STV090x_Px_GAUSSR0(1)
+#define STV090x_P2_GAUSSR0 STV090x_Px_GAUSSR0(2)
+#define STV090x_OFFST_Px_EN_CCIMODE_FIELD 7
+#define STV090x_WIDTH_Px_EN_CCIMODE_FIELD 1
+#define STV090x_OFFST_Px_R0_GAUSSIEN_FIELD 0
+#define STV090x_WIDTH_Px_R0_GAUSSIEN_FIELD 7
+
+#define STV090x_Px_CCIR0(__x) (0xf4c1 - (__x - 1) * 0x200)
+#define STV090x_P1_CCIR0 STV090x_Px_CCIR0(1)
+#define STV090x_P2_CCIR0 STV090x_Px_CCIR0(2)
+#define STV090x_OFFST_Px_CCIDETECT_PLH_FIELD 7
+#define STV090x_WIDTH_Px_CCIDETECT_PLH_FIELD 1
+#define STV090x_OFFST_Px_R0_CCI_FIELD 0
+#define STV090x_WIDTH_Px_R0_CCI_FIELD 7
+
+#define STV090x_Px_CCIQUANT(__x) (0xf4c2 - (__x - 1) * 0x200)
+#define STV090x_P1_CCIQUANT STV090x_Px_CCIQUANT(1)
+#define STV090x_P2_CCIQUANT STV090x_Px_CCIQUANT(2)
+#define STV090x_OFFST_Px_CCI_BETA_FIELD 5
+#define STV090x_WIDTH_Px_CCI_BETA_FIELD 3
+#define STV090x_OFFST_Px_CCI_QUANT_FIELD 0
+#define STV090x_WIDTH_Px_CCI_QUANT_FIELD 5
+
+#define STV090x_Px_CCITHRESH(__x) (0xf4c3 - (__x - 1) * 0x200)
+#define STV090x_P1_CCITHRESH STV090x_Px_CCITHRESH(1)
+#define STV090x_P2_CCITHRESH STV090x_Px_CCITHRESH(2)
+#define STV090x_OFFST_Px_CCI_THRESHOLD_FIELD 0
+#define STV090x_WIDTH_Px_CCI_THRESHOLD_FIELD 8
+
+#define STV090x_Px_CCIACC(__x) (0xf4c4 - (__x - 1) * 0x200)
+#define STV090x_P1_CCIACC STV090x_Px_CCIACC(1)
+#define STV090x_P2_CCIACC STV090x_Px_CCIACC(1)
+#define STV090x_OFFST_Px_CCI_VALUE_FIELD 0
+#define STV090x_WIDTH_Px_CCI_VALUE_FIELD 8
+
+#define STV090x_Px_DMDRESCFG(__x) (0xF4C6 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDRESCFG STV090x_Px_DMDRESCFG(1)
+#define STV090x_P2_DMDRESCFG STV090x_Px_DMDRESCFG(2)
+#define STV090x_OFFST_Px_DMDRES_RESET_FIELD 7
+#define STV090x_WIDTH_Px_DMDRES_RESET_FIELD 1
+
+#define STV090x_Px_DMDRESADR(__x) (0xF4C7 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDRESADR STV090x_Px_DMDRESADR(1)
+#define STV090x_P2_DMDRESADR STV090x_Px_DMDRESADR(2)
+#define STV090x_OFFST_Px_DMDRES_RESNBR_FIELD 0
+#define STV090x_WIDTH_Px_DMDRES_RESNBR_FIELD 4
+
+#define STV090x_Px_DMDRESDATAy(__x, __y) (0xF4C8 - (__x - 1) * 0x200 + (7 - __y))
+#define STV090x_P1_DMDRESDATA0 STV090x_Px_DMDRESDATAy(1, 0)
+#define STV090x_P1_DMDRESDATA1 STV090x_Px_DMDRESDATAy(1, 1)
+#define STV090x_P1_DMDRESDATA2 STV090x_Px_DMDRESDATAy(1, 2)
+#define STV090x_P1_DMDRESDATA3 STV090x_Px_DMDRESDATAy(1, 3)
+#define STV090x_P1_DMDRESDATA4 STV090x_Px_DMDRESDATAy(1, 4)
+#define STV090x_P1_DMDRESDATA5 STV090x_Px_DMDRESDATAy(1, 5)
+#define STV090x_P1_DMDRESDATA6 STV090x_Px_DMDRESDATAy(1, 6)
+#define STV090x_P1_DMDRESDATA7 STV090x_Px_DMDRESDATAy(1, 7)
+#define STV090x_P2_DMDRESDATA0 STV090x_Px_DMDRESDATAy(2, 0)
+#define STV090x_P2_DMDRESDATA1 STV090x_Px_DMDRESDATAy(2, 1)
+#define STV090x_P2_DMDRESDATA2 STV090x_Px_DMDRESDATAy(2, 2)
+#define STV090x_P2_DMDRESDATA3 STV090x_Px_DMDRESDATAy(2, 3)
+#define STV090x_P2_DMDRESDATA4 STV090x_Px_DMDRESDATAy(2, 4)
+#define STV090x_P2_DMDRESDATA5 STV090x_Px_DMDRESDATAy(2, 5)
+#define STV090x_P2_DMDRESDATA6 STV090x_Px_DMDRESDATAy(2, 6)
+#define STV090x_P2_DMDRESDATA7 STV090x_Px_DMDRESDATAy(2, 7)
+#define STV090x_OFFST_Px_DMDRES_DATA_FIELD 0
+#define STV090x_WIDTH_Px_DMDRES_DATA_FIELD 8
+
+#define STV090x_Px_FFEIy(__x, __y) (0xf4d0 - (__x - 1) * 0x200 + 0x2 * (__y - 1))
+#define STV090x_P1_FFEI1 STV090x_Px_FFEIy(1, 1)
+#define STV090x_P1_FFEI2 STV090x_Px_FFEIy(1, 2)
+#define STV090x_P1_FFEI3 STV090x_Px_FFEIy(1, 3)
+#define STV090x_P1_FFEI4 STV090x_Px_FFEIy(1, 4)
+#define STV090x_P2_FFEI1 STV090x_Px_FFEIy(2, 1)
+#define STV090x_P2_FFEI2 STV090x_Px_FFEIy(2, 2)
+#define STV090x_P2_FFEI3 STV090x_Px_FFEIy(2, 3)
+#define STV090x_P2_FFEI4 STV090x_Px_FFEIy(2, 4)
+#define STV090x_OFFST_Px_FFE_ACCIy_FIELD 0
+#define STV090x_WIDTH_Px_FFE_ACCIy_FIELD 8
+
+#define STV090x_Px_FFEQy(__x, __y) (0xf4d1 - (__x - 1) * 0x200 + 0x2 * (__y - 1))
+#define STV090x_P1_FFEQ1 STV090x_Px_FFEQy(1, 1)
+#define STV090x_P1_FFEQ2 STV090x_Px_FFEQy(1, 2)
+#define STV090x_P1_FFEQ3 STV090x_Px_FFEQy(1, 3)
+#define STV090x_P1_FFEQ4 STV090x_Px_FFEQy(1, 4)
+#define STV090x_P2_FFEQ1 STV090x_Px_FFEQy(2, 1)
+#define STV090x_P2_FFEQ2 STV090x_Px_FFEQy(2, 2)
+#define STV090x_P2_FFEQ3 STV090x_Px_FFEQy(2, 3)
+#define STV090x_P2_FFEQ4 STV090x_Px_FFEQy(2, 4)
+#define STV090x_OFFST_Px_FFE_ACCQy_FIELD 0
+#define STV090x_WIDTH_Px_FFE_ACCQy_FIELD 8
+
+#define STV090x_Px_FFECFG(__x) (0xf4d8 - (__x - 1) * 0x200)
+#define STV090x_P1_FFECFG STV090x_Px_FFECFG(1)
+#define STV090x_P2_FFECFG STV090x_Px_FFECFG(2)
+#define STV090x_OFFST_Px_EQUALFFE_ON_FIELD 6
+#define STV090x_WIDTH_Px_EQUALFFE_ON_FIELD 1
+
+#define STV090x_Px_SMAPCOEF7(__x) (0xf500 - (__x - 1) * 0x200)
+#define STV090x_P1_SMAPCOEF7 STV090x_Px_SMAPCOEF7(1)
+#define STV090x_P2_SMAPCOEF7 STV090x_Px_SMAPCOEF7(2)
+#define STV090x_OFFST_Px_DIS_QSCALE_FIELD 7
+#define STV090x_WIDTH_Px_DIS_QSCALE_FIELD 1
+#define STV090x_OFFST_Px_SMAPCOEF_Q_LLR12_FIELD 0
+#define STV090x_WIDTH_Px_SMAPCOEF_Q_LLR12_FIELD 7
+
+#define STV090x_Px_SMAPCOEF6(__x) (0xf501 - (__x - 1) * 0x200)
+#define STV090x_P1_SMAPCOEF6 STV090x_Px_SMAPCOEF6(1)
+#define STV090x_P2_SMAPCOEF6 STV090x_Px_SMAPCOEF6(2)
+#define STV090x_OFFST_Px_ADJ_8PSKLLR1_FIELD 2
+#define STV090x_WIDTH_Px_ADJ_8PSKLLR1_FIELD 1
+#define STV090x_OFFST_Px_OLD_8PSKLLR1_FIELD 1
+#define STV090x_WIDTH_Px_OLD_8PSKLLR1_FIELD 1
+#define STV090x_OFFST_Px_DIS_AB8PSK_FIELD 0
+#define STV090x_WIDTH_Px_DIS_AB8PSK_FIELD 1
+
+#define STV090x_Px_SMAPCOEF5(__x) (0xf502 - (__x - 1) * 0x200)
+#define STV090x_P1_SMAPCOEF5 STV090x_Px_SMAPCOEF5(1)
+#define STV090x_P2_SMAPCOEF5 STV090x_Px_SMAPCOEF5(2)
+#define STV090x_OFFST_Px_DIS_8SCALE_FIELD 7
+#define STV090x_WIDTH_Px_DIS_8SCALE_FIELD 1
+#define STV090x_OFFST_Px_SMAPCOEF_8P_LLR23_FIELD 0
+#define STV090x_WIDTH_Px_SMAPCOEF_8P_LLR23_FIELD 7
+
+#define STV090x_Px_DMDPLHSTAT(__x) (0xF520 - (__x - 1) * 0x200)
+#define STV090x_P1_DMDPLHSTAT STV090x_Px_DMDPLHSTAT(1)
+#define STV090x_P2_DMDPLHSTAT STV090x_Px_DMDPLHSTAT(2)
+#define STV090x_OFFST_Px_PLH_STATISTIC_FIELD 0
+#define STV090x_WIDTH_Px_PLH_STATISTIC_FIELD 8
+
+#define STV090x_Px_LOCKTIMEy(__x, __y) (0xF525 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_LOCKTIME0 STV090x_Px_LOCKTIMEy(1, 0)
+#define STV090x_P1_LOCKTIME1 STV090x_Px_LOCKTIMEy(1, 1)
+#define STV090x_P1_LOCKTIME2 STV090x_Px_LOCKTIMEy(1, 2)
+#define STV090x_P1_LOCKTIME3 STV090x_Px_LOCKTIMEy(1, 3)
+#define STV090x_P2_LOCKTIME0 STV090x_Px_LOCKTIMEy(2, 0)
+#define STV090x_P2_LOCKTIME1 STV090x_Px_LOCKTIMEy(2, 1)
+#define STV090x_P2_LOCKTIME2 STV090x_Px_LOCKTIMEy(2, 2)
+#define STV090x_P2_LOCKTIME3 STV090x_Px_LOCKTIMEy(2, 3)
+#define STV090x_OFFST_Px_DEMOD_LOCKTIME_FIELD 0
+#define STV090x_WIDTH_Px_DEMOD_LOCKTIME_FIELD 8
+
+#define STV090x_Px_TNRCFG(__x) (0xf4e0 - (__x - 1) * 0x200) /* check */
+#define STV090x_P1_TNRCFG STV090x_Px_TNRCFG(1)
+#define STV090x_P2_TNRCFG STV090x_Px_TNRCFG(2)
+
+#define STV090x_Px_TNRCFG2(__x) (0xf4e1 - (__x - 1) * 0x200)
+#define STV090x_P1_TNRCFG2 STV090x_Px_TNRCFG2(1)
+#define STV090x_P2_TNRCFG2 STV090x_Px_TNRCFG2(2)
+#define STV090x_OFFST_Px_TUN_IQSWAP_FIELD 7
+#define STV090x_WIDTH_Px_TUN_IQSWAP_FIELD 1
+
+#define STV090x_Px_VITSCALE(__x) (0xf532 - (__x - 1) * 0x200)
+#define STV090x_P1_VITSCALE STV090x_Px_VITSCALE(1)
+#define STV090x_P2_VITSCALE STV090x_Px_VITSCALE(2)
+#define STV090x_OFFST_Px_NVTH_NOSRANGE_FIELD 7
+#define STV090x_WIDTH_Px_NVTH_NOSRANGE_FIELD 1
+#define STV090x_OFFST_Px_VERROR_MAXMODE_FIELD 6
+#define STV090x_WIDTH_Px_VERROR_MAXMODE_FIELD 1
+#define STV090x_OFFST_Px_NSLOWSN_LOCKED_FIELD 3
+#define STV090x_WIDTH_Px_NSLOWSN_LOCKED_FIELD 1
+#define STV090x_OFFST_Px_DIS_RSFLOCK_FIELD 1
+#define STV090x_WIDTH_Px_DIS_RSFLOCK_FIELD 1
+
+#define STV090x_Px_FECM(__x) (0xf533 - (__x - 1) * 0x200)
+#define STV090x_P1_FECM STV090x_Px_FECM(1)
+#define STV090x_P2_FECM STV090x_Px_FECM(2)
+#define STV090x_OFFST_Px_DSS_DVB_FIELD 7
+#define STV090x_WIDTH_Px_DSS_DVB_FIELD 1
+#define STV090x_OFFST_Px_DSS_SRCH_FIELD 4
+#define STV090x_WIDTH_Px_DSS_SRCH_FIELD 1
+#define STV090x_OFFST_Px_SYNCVIT_FIELD 1
+#define STV090x_WIDTH_Px_SYNCVIT_FIELD 1
+#define STV090x_OFFST_Px_IQINV_FIELD 0
+#define STV090x_WIDTH_Px_IQINV_FIELD 1
+
+#define STV090x_Px_VTH12(__x) (0xf534 - (__x - 1) * 0x200)
+#define STV090x_P1_VTH12 STV090x_Px_VTH12(1)
+#define STV090x_P2_VTH12 STV090x_Px_VTH12(2)
+#define STV090x_OFFST_Px_VTH12_FIELD 0
+#define STV090x_WIDTH_Px_VTH12_FIELD 8
+
+#define STV090x_Px_VTH23(__x) (0xf535 - (__x - 1) * 0x200)
+#define STV090x_P1_VTH23 STV090x_Px_VTH23(1)
+#define STV090x_P2_VTH23 STV090x_Px_VTH23(2)
+#define STV090x_OFFST_Px_VTH23_FIELD 0
+#define STV090x_WIDTH_Px_VTH23_FIELD 8
+
+#define STV090x_Px_VTH34(__x) (0xf536 - (__x - 1) * 0x200)
+#define STV090x_P1_VTH34 STV090x_Px_VTH34(1)
+#define STV090x_P2_VTH34 STV090x_Px_VTH34(2)
+#define STV090x_OFFST_Px_VTH34_FIELD 0
+#define STV090x_WIDTH_Px_VTH34_FIELD 8
+
+#define STV090x_Px_VTH56(__x) (0xf537 - (__x - 1) * 0x200)
+#define STV090x_P1_VTH56 STV090x_Px_VTH56(1)
+#define STV090x_P2_VTH56 STV090x_Px_VTH56(2)
+#define STV090x_OFFST_Px_VTH56_FIELD 0
+#define STV090x_WIDTH_Px_VTH56_FIELD 8
+
+#define STV090x_Px_VTH67(__x) (0xf538 - (__x - 1) * 0x200)
+#define STV090x_P1_VTH67 STV090x_Px_VTH67(1)
+#define STV090x_P2_VTH67 STV090x_Px_VTH67(2)
+#define STV090x_OFFST_Px_VTH67_FIELD 0
+#define STV090x_WIDTH_Px_VTH67_FIELD 8
+
+#define STV090x_Px_VTH78(__x) (0xf539 - (__x - 1) * 0x200)
+#define STV090x_P1_VTH78 STV090x_Px_VTH78(1)
+#define STV090x_P2_VTH78 STV090x_Px_VTH78(2)
+#define STV090x_OFFST_Px_VTH78_FIELD 0
+#define STV090x_WIDTH_Px_VTH78_FIELD 8
+
+#define STV090x_Px_VITCURPUN(__x) (0xf53a - (__x - 1) * 0x200)
+#define STV090x_P1_VITCURPUN STV090x_Px_VITCURPUN(1)
+#define STV090x_P2_VITCURPUN STV090x_Px_VITCURPUN(2)
+#define STV090x_OFFST_Px_VIT_CURPUN_FIELD 0
+#define STV090x_WIDTH_Px_VIT_CURPUN_FIELD 5
+
+#define STV090x_Px_VERROR(__x) (0xf53b - (__x - 1) * 0x200)
+#define STV090x_P1_VERROR STV090x_Px_VERROR(1)
+#define STV090x_P2_VERROR STV090x_Px_VERROR(2)
+#define STV090x_OFFST_Px_REGERR_VIT_FIELD 0
+#define STV090x_WIDTH_Px_REGERR_VIT_FIELD 8
+
+#define STV090x_Px_PRVIT(__x) (0xf53c - (__x - 1) * 0x200)
+#define STV090x_P1_PRVIT STV090x_Px_PRVIT(1)
+#define STV090x_P2_PRVIT STV090x_Px_PRVIT(2)
+#define STV090x_OFFST_Px_DIS_VTHLOCK_FIELD 6
+#define STV090x_WIDTH_Px_DIS_VTHLOCK_FIELD 1
+#define STV090x_OFFST_Px_E7_8VIT_FIELD 5
+#define STV090x_WIDTH_Px_E7_8VIT_FIELD 1
+#define STV090x_OFFST_Px_E6_7VIT_FIELD 4
+#define STV090x_WIDTH_Px_E6_7VIT_FIELD 1
+#define STV090x_OFFST_Px_E5_6VIT_FIELD 3
+#define STV090x_WIDTH_Px_E5_6VIT_FIELD 1
+#define STV090x_OFFST_Px_E3_4VIT_FIELD 2
+#define STV090x_WIDTH_Px_E3_4VIT_FIELD 1
+#define STV090x_OFFST_Px_E2_3VIT_FIELD 1
+#define STV090x_WIDTH_Px_E2_3VIT_FIELD 1
+#define STV090x_OFFST_Px_E1_2VIT_FIELD 0
+#define STV090x_WIDTH_Px_E1_2VIT_FIELD 1
+
+#define STV090x_Px_VAVSRVIT(__x) (0xf53d - (__x - 1) * 0x200)
+#define STV090x_P1_VAVSRVIT STV090x_Px_VAVSRVIT(1)
+#define STV090x_P2_VAVSRVIT STV090x_Px_VAVSRVIT(2)
+#define STV090x_OFFST_Px_SNVIT_FIELD 4
+#define STV090x_WIDTH_Px_SNVIT_FIELD 2
+#define STV090x_OFFST_Px_TOVVIT_FIELD 2
+#define STV090x_WIDTH_Px_TOVVIT_FIELD 2
+#define STV090x_OFFST_Px_HYPVIT_FIELD 0
+#define STV090x_WIDTH_Px_HYPVIT_FIELD 2
+
+#define STV090x_Px_VSTATUSVIT(__x) (0xf53e - (__x - 1) * 0x200)
+#define STV090x_P1_VSTATUSVIT STV090x_Px_VSTATUSVIT(1)
+#define STV090x_P2_VSTATUSVIT STV090x_Px_VSTATUSVIT(2)
+#define STV090x_OFFST_Px_PRFVIT_FIELD 4
+#define STV090x_WIDTH_Px_PRFVIT_FIELD 1
+#define STV090x_OFFST_Px_LOCKEDVIT_FIELD 3
+#define STV090x_WIDTH_Px_LOCKEDVIT_FIELD 1
+
+#define STV090x_Px_VTHINUSE(__x) (0xf53f - (__x - 1) * 0x200)
+#define STV090x_P1_VTHINUSE STV090x_Px_VTHINUSE(1)
+#define STV090x_P2_VTHINUSE STV090x_Px_VTHINUSE(2)
+#define STV090x_OFFST_Px_VIT_INUSE_FIELD 0
+#define STV090x_WIDTH_Px_VIT_INUSE_FIELD 8
+
+#define STV090x_Px_KDIV12(__x) (0xf540 - (__x - 1) * 0x200)
+#define STV090x_P1_KDIV12 STV090x_Px_KDIV12(1)
+#define STV090x_P2_KDIV12 STV090x_Px_KDIV12(2)
+#define STV090x_OFFST_Px_K_DIVIDER_12_FIELD 0
+#define STV090x_WIDTH_Px_K_DIVIDER_12_FIELD 7
+
+#define STV090x_Px_KDIV23(__x) (0xf541 - (__x - 1) * 0x200)
+#define STV090x_P1_KDIV23 STV090x_Px_KDIV23(1)
+#define STV090x_P2_KDIV23 STV090x_Px_KDIV23(2)
+#define STV090x_OFFST_Px_K_DIVIDER_23_FIELD 0
+#define STV090x_WIDTH_Px_K_DIVIDER_23_FIELD 7
+
+#define STV090x_Px_KDIV34(__x) (0xf542 - (__x - 1) * 0x200)
+#define STV090x_P1_KDIV34 STV090x_Px_KDIV34(1)
+#define STV090x_P2_KDIV34 STV090x_Px_KDIV34(2)
+#define STV090x_OFFST_Px_K_DIVIDER_34_FIELD 0
+#define STV090x_WIDTH_Px_K_DIVIDER_34_FIELD 7
+
+#define STV090x_Px_KDIV56(__x) (0xf543 - (__x - 1) * 0x200)
+#define STV090x_P1_KDIV56 STV090x_Px_KDIV56(1)
+#define STV090x_P2_KDIV56 STV090x_Px_KDIV56(2)
+#define STV090x_OFFST_Px_K_DIVIDER_56_FIELD 0
+#define STV090x_WIDTH_Px_K_DIVIDER_56_FIELD 7
+
+#define STV090x_Px_KDIV67(__x) (0xf544 - (__x - 1) * 0x200)
+#define STV090x_P1_KDIV67 STV090x_Px_KDIV67(1)
+#define STV090x_P2_KDIV67 STV090x_Px_KDIV67(2)
+#define STV090x_OFFST_Px_K_DIVIDER_67_FIELD 0
+#define STV090x_WIDTH_Px_K_DIVIDER_67_FIELD 7
+
+#define STV090x_Px_KDIV78(__x) (0xf545 - (__x - 1) * 0x200)
+#define STV090x_P1_KDIV78 STV090x_Px_KDIV78(1)
+#define STV090x_P2_KDIV78 STV090x_Px_KDIV78(2)
+#define STV090x_OFFST_Px_K_DIVIDER_78_FIELD 0
+#define STV090x_WIDTH_Px_K_DIVIDER_78_FIELD 7
+
+#define STV090x_Px_PDELCTRL1(__x) (0xf550 - (__x - 1) * 0x200)
+#define STV090x_P1_PDELCTRL1 STV090x_Px_PDELCTRL1(1)
+#define STV090x_P2_PDELCTRL1 STV090x_Px_PDELCTRL1(2)
+#define STV090x_OFFST_Px_INV_MISMASK_FIELD 7
+#define STV090x_WIDTH_Px_INV_MISMASK_FIELD 1
+#define STV090x_OFFST_Px_FILTER_EN_FIELD 5
+#define STV090x_WIDTH_Px_FILTER_EN_FIELD 1
+#define STV090x_OFFST_Px_EN_MIS00_FIELD 1
+#define STV090x_WIDTH_Px_EN_MIS00_FIELD 1
+#define STV090x_OFFST_Px_ALGOSWRST_FIELD 0
+#define STV090x_WIDTH_Px_ALGOSWRST_FIELD 1
+
+#define STV090x_Px_PDELCTRL2(__x) (0xf551 - (__x - 1) * 0x200)
+#define STV090x_P1_PDELCTRL2 STV090x_Px_PDELCTRL2(1)
+#define STV090x_P2_PDELCTRL2 STV090x_Px_PDELCTRL2(2)
+#define STV090x_OFFST_Px_FORCE_CONTINUOUS 7
+#define STV090x_WIDTH_Px_FORCE_CONTINUOUS 1
+#define STV090x_OFFST_Px_RESET_UPKO_COUNT 6
+#define STV090x_WIDTH_Px_RESET_UPKO_COUNT 1
+#define STV090x_OFFST_Px_USER_PKTDELIN_NB 5
+#define STV090x_WIDTH_Px_USER_PKTDELIN_NB 1
+#define STV090x_OFFST_Px_FORCE_LOCKED 4
+#define STV090x_WIDTH_Px_FORCE_LOCKED 1
+#define STV090x_OFFST_Px_DATA_UNBBSCRAM 3
+#define STV090x_WIDTH_Px_DATA_UNBBSCRAM 1
+#define STV090x_OFFST_Px_FORCE_LONGPACKET 2
+#define STV090x_WIDTH_Px_FORCE_LONGPACKET 1
+#define STV090x_OFFST_Px_FRAME_MODE_FIELD 1
+#define STV090x_WIDTH_Px_FRAME_MODE_FIELD 1
+
+#define STV090x_Px_HYSTTHRESH(__x) (0xf554 - (__x - 1) * 0x200)
+#define STV090x_P1_HYSTTHRESH STV090x_Px_HYSTTHRESH(1)
+#define STV090x_P2_HYSTTHRESH STV090x_Px_HYSTTHRESH(2)
+#define STV090x_OFFST_Px_UNLCK_THRESH_FIELD 4
+#define STV090x_WIDTH_Px_UNLCK_THRESH_FIELD 4
+#define STV090x_OFFST_Px_DELIN_LCK_THRESH_FIELD 0
+#define STV090x_WIDTH_Px_DELIN_LCK_THRESH_FIELD 4
+
+#define STV090x_Px_ISIENTRY(__x) (0xf55e - (__x - 1) * 0x200)
+#define STV090x_P1_ISIENTRY STV090x_Px_ISIENTRY(1)
+#define STV090x_P2_ISIENTRY STV090x_Px_ISIENTRY(2)
+#define STV090x_OFFST_Px_ISI_ENTRY_FIELD 0
+#define STV090x_WIDTH_Px_ISI_ENTRY_FIELD 8
+
+#define STV090x_Px_ISIBITENA(__x) (0xf55f - (__x - 1) * 0x200)
+#define STV090x_P1_ISIBITENA STV090x_Px_ISIBITENA(1)
+#define STV090x_P2_ISIBITENA STV090x_Px_ISIBITENA(2)
+#define STV090x_OFFST_Px_ISI_BIT_EN_FIELD 0
+#define STV090x_WIDTH_Px_ISI_BIT_EN_FIELD 8
+
+#define STV090x_Px_MATSTRy(__x, __y) (0xf561 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_MATSTR0 STV090x_Px_MATSTRy(1, 0)
+#define STV090x_P1_MATSTR1 STV090x_Px_MATSTRy(1, 1)
+#define STV090x_P2_MATSTR0 STV090x_Px_MATSTRy(2, 0)
+#define STV090x_P2_MATSTR1 STV090x_Px_MATSTRy(2, 1)
+#define STV090x_OFFST_Px_MATYPE_CURRENT_FIELD 0
+#define STV090x_WIDTH_Px_MATYPE_CURRENT_FIELD 8
+
+#define STV090x_Px_UPLSTRy(__x, __y) (0xf563 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_UPLSTR0 STV090x_Px_UPLSTRy(1, 0)
+#define STV090x_P1_UPLSTR1 STV090x_Px_UPLSTRy(1, 1)
+#define STV090x_P2_UPLSTR0 STV090x_Px_UPLSTRy(2, 0)
+#define STV090x_P2_UPLSTR1 STV090x_Px_UPLSTRy(2, 1)
+#define STV090x_OFFST_Px_UPL_CURRENT_FIELD 0
+#define STV090x_WIDTH_Px_UPL_CURRENT_FIELD 8
+
+#define STV090x_Px_DFLSTRy(__x, __y) (0xf565 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_DFLSTR0 STV090x_Px_DFLSTRy(1, 0)
+#define STV090x_P1_DFLSTR1 STV090x_Px_DFLSTRy(1, 1)
+#define STV090x_P2_DFLSTR0 STV090x_Px_DFLSTRy(2, 0)
+#define STV090x_P2_DFLSTR1 STV090x_Px_DFLSTRy(2, 1)
+#define STV090x_OFFST_Px_DFL_CURRENT_FIELD 0
+#define STV090x_WIDTH_Px_DFL_CURRENT_FIELD 8
+
+#define STV090x_Px_SYNCSTR(__x) (0xf566 - (__x - 1) * 0x200)
+#define STV090x_P1_SYNCSTR STV090x_Px_SYNCSTR(1)
+#define STV090x_P2_SYNCSTR STV090x_Px_SYNCSTR(2)
+#define STV090x_OFFST_Px_SYNC_CURRENT_FIELD 0
+#define STV090x_WIDTH_Px_SYNC_CURRENT_FIELD 8
+
+#define STV090x_Px_SYNCDSTRy(__x, __y) (0xf568 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_SYNCDSTR0 STV090x_Px_SYNCDSTRy(1, 0)
+#define STV090x_P1_SYNCDSTR1 STV090x_Px_SYNCDSTRy(1, 1)
+#define STV090x_P2_SYNCDSTR0 STV090x_Px_SYNCDSTRy(2, 0)
+#define STV090x_P2_SYNCDSTR1 STV090x_Px_SYNCDSTRy(2, 1)
+#define STV090x_OFFST_Px_SYNCD_CURRENT_FIELD 0
+#define STV090x_WIDTH_Px_SYNCD_CURRENT_FIELD 8
+
+#define STV090x_Px_PDELSTATUS1(__x) (0xf569 - (__x - 1) * 0x200)
+#define STV090x_P1_PDELSTATUS1 STV090x_Px_PDELSTATUS1(1)
+#define STV090x_P2_PDELSTATUS1 STV090x_Px_PDELSTATUS1(2)
+#define STV090x_OFFST_Px_PKTDELIN_LOCK_FIELD 1
+#define STV090x_WIDTH_Px_PKTDELIN_LOCK_FIELD 1
+#define STV090x_OFFST_Px_FIRST_LOCK_FIELD 0
+#define STV090x_WIDTH_Px_FIRST_LOCK_FIELD 1
+
+#define STV090x_Px_PDELSTATUS2(__x) (0xf56a - (__x - 1) * 0x200)
+#define STV090x_P1_PDELSTATUS2 STV090x_Px_PDELSTATUS2(1)
+#define STV090x_P2_PDELSTATUS2 STV090x_Px_PDELSTATUS2(2)
+#define STV090x_OFFST_Px_FRAME_MODCOD_FIELD 2
+#define STV090x_WIDTH_Px_FRAME_MODCOD_FIELD 5
+#define STV090x_OFFST_Px_FRAME_TYPE_FIELD 0
+#define STV090x_WIDTH_Px_FRAME_TYPE_FIELD 2
+
+#define STV090x_Px_BBFCRCKO1(__x) (0xf56b - (__x - 1) * 0x200)
+#define STV090x_P1_BBFCRCKO1 STV090x_Px_BBFCRCKO1(1)
+#define STV090x_P2_BBFCRCKO1 STV090x_Px_BBFCRCKO1(2)
+#define STV090x_OFFST_Px_BBHCRC_KOCNT_FIELD 0
+#define STV090x_WIDTH_Px_BBHCRC_KOCNT_FIELD 8
+
+#define STV090x_Px_BBFCRCKO0(__x) (0xf56c - (__x - 1) * 0x200)
+#define STV090x_P1_BBFCRCKO0 STV090x_Px_BBFCRCKO0(1)
+#define STV090x_P2_BBFCRCKO0 STV090x_Px_BBFCRCKO0(2)
+#define STV090x_OFFST_Px_BBHCRC_KOCNT_FIELD 0
+#define STV090x_WIDTH_Px_BBHCRC_KOCNT_FIELD 8
+
+#define STV090x_Px_UPCRCKO1(__x) (0xf56d - (__x - 1) * 0x200)
+#define STV090x_P1_UPCRCKO1 STV090x_Px_UPCRCKO1(1)
+#define STV090x_P2_UPCRCKO1 STV090x_Px_UPCRCKO1(2)
+#define STV090x_OFFST_Px_PKTCRC_KOCNT_FIELD 0
+#define STV090x_WIDTH_Px_PKTCRC_KOCNT_FIELD 8
+
+#define STV090x_Px_UPCRCKO0(__x) (0xf56e - (__x - 1) * 0x200)
+#define STV090x_P1_UPCRCKO0 STV090x_Px_UPCRCKO0(1)
+#define STV090x_P2_UPCRCKO0 STV090x_Px_UPCRCKO0(2)
+#define STV090x_OFFST_Px_PKTCRC_KOCNT_FIELD 0
+#define STV090x_WIDTH_Px_PKTCRC_KOCNT_FIELD 8
+
+#define STV090x_NBITER_NFx(__x) (0xFA03 + (__x - 4) * 0x1)
+#define STV090x_NBITER_NF4 STV090x_NBITER_NFx(4)
+#define STV090x_NBITER_NF5 STV090x_NBITER_NFx(5)
+#define STV090x_NBITER_NF6 STV090x_NBITER_NFx(6)
+#define STV090x_NBITER_NF7 STV090x_NBITER_NFx(7)
+#define STV090x_NBITER_NF8 STV090x_NBITER_NFx(8)
+#define STV090x_NBITER_NF9 STV090x_NBITER_NFx(9)
+#define STV090x_NBITER_NF10 STV090x_NBITER_NFx(10)
+#define STV090x_NBITER_NF11 STV090x_NBITER_NFx(11)
+#define STV090x_NBITER_NF12 STV090x_NBITER_NFx(12)
+#define STV090x_NBITER_NF13 STV090x_NBITER_NFx(13)
+#define STV090x_NBITER_NF14 STV090x_NBITER_NFx(14)
+#define STV090x_NBITER_NF15 STV090x_NBITER_NFx(15)
+#define STV090x_NBITER_NF16 STV090x_NBITER_NFx(16)
+#define STV090x_NBITER_NF17 STV090x_NBITER_NFx(17)
+
+#define STV090x_NBITERNOERR 0xFA3F
+#define STV090x_OFFST_NBITER_STOP_CRIT_FIELD 0
+#define STV090x_WIDTH_NBITER_STOP_CRIT_FIELD 4
+
+#define STV090x_GAINLLR_NFx(__x) (0xFA43 + (__x - 4) * 0x1)
+#define STV090x_GAINLLR_NF4 STV090x_GAINLLR_NFx(4)
+#define STV090x_OFFST_GAINLLR_NF_QP_1_2_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_1_2_FIELD 7
+
+#define STV090x_GAINLLR_NF5 STV090x_GAINLLR_NFx(5)
+#define STV090x_OFFST_GAINLLR_NF_QP_3_5_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_3_5_FIELD 7
+
+#define STV090x_GAINLLR_NF6 STV090x_GAINLLR_NFx(6)
+#define STV090x_OFFST_GAINLLR_NF_QP_2_3_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_2_3_FIELD 7
+
+#define STV090x_GAINLLR_NF7 STV090x_GAINLLR_NFx(7)
+#define STV090x_OFFST_GAINLLR_NF_QP_3_4_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_3_4_FIELD 7
+
+#define STV090x_GAINLLR_NF8 STV090x_GAINLLR_NFx(8)
+#define STV090x_OFFST_GAINLLR_NF_QP_4_5_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_4_5_FIELD 7
+
+#define STV090x_GAINLLR_NF9 STV090x_GAINLLR_NFx(9)
+#define STV090x_OFFST_GAINLLR_NF_QP_5_6_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_5_6_FIELD 7
+
+#define STV090x_GAINLLR_NF10 STV090x_GAINLLR_NFx(10)
+#define STV090x_OFFST_GAINLLR_NF_QP_8_9_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_8_9_FIELD 7
+
+#define STV090x_GAINLLR_NF11 STV090x_GAINLLR_NFx(11)
+#define STV090x_OFFST_GAINLLR_NF_QP_9_10_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_QP_9_10_FIELD 7
+
+#define STV090x_GAINLLR_NF12 STV090x_GAINLLR_NFx(12)
+#define STV090x_OFFST_GAINLLR_NF_8P_3_5_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_8P_3_5_FIELD 7
+
+#define STV090x_GAINLLR_NF13 STV090x_GAINLLR_NFx(13)
+#define STV090x_OFFST_GAINLLR_NF_8P_2_3_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_8P_2_3_FIELD 7
+
+#define STV090x_GAINLLR_NF14 STV090x_GAINLLR_NFx(14)
+#define STV090x_OFFST_GAINLLR_NF_8P_3_4_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_8P_3_4_FIELD 7
+
+#define STV090x_GAINLLR_NF15 STV090x_GAINLLR_NFx(15)
+#define STV090x_OFFST_GAINLLR_NF_8P_5_6_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_8P_5_6_FIELD 7
+
+#define STV090x_GAINLLR_NF16 STV090x_GAINLLR_NFx(16)
+#define STV090x_OFFST_GAINLLR_NF_8P_8_9_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_8P_8_9_FIELD 7
+
+#define STV090x_GAINLLR_NF17 STV090x_GAINLLR_NFx(17)
+#define STV090x_OFFST_GAINLLR_NF_8P_9_10_FIELD 0
+#define STV090x_WIDTH_GAINLLR_NF_8P_9_10_FIELD 7
+
+#define STV090x_GENCFG 0xFA86
+#define STV090x_OFFST_BROADCAST_FIELD 4
+#define STV090x_WIDTH_BROADCAST_FIELD 1
+#define STV090x_OFFST_PRIORITY_FIELD 1
+#define STV090x_WIDTH_PRIORITY_FIELD 1
+#define STV090x_OFFST_DDEMOD_FIELD 0
+#define STV090x_WIDTH_DDEMOD_FIELD 1
+
+#define STV090x_LDPCERRx(__x) (0xFA97 - (__x * 0x1))
+#define STV090x_LDPCERR0 STV090x_LDPCERRx(0)
+#define STV090x_LDPCERR1 STV090x_LDPCERRx(1)
+#define STV090x_OFFST_Px_LDPC_ERRORS_COUNTER_FIELD 0
+#define STV090x_WIDTH_Px_LDPC_ERRORS_COUNTER_FIELD 8
+
+#define STV090x_BCHERR 0xFA98
+#define STV090x_OFFST_Px_ERRORFLAG_FIELD 4
+#define STV090x_WIDTH_Px_ERRORFLAG_FIELD 1
+#define STV090x_OFFST_Px_BCH_ERRORS_COUNTER_FIELD 0
+#define STV090x_WIDTH_Px_BCH_ERRORS_COUNTER_FIELD 4
+
+#define STV090x_Px_TSSTATEM(__x) (0xF570 - (__x - 1) * 0x200)
+#define STV090x_P1_TSSTATEM STV090x_Px_TSSTATEM(1)
+#define STV090x_P2_TSSTATEM STV090x_Px_TSSTATEM(2)
+#define STV090x_OFFST_Px_TSDIL_ON_FIELD 7
+#define STV090x_WIDTH_Px_TSDIL_ON_FIELD 1
+#define STV090x_OFFST_Px_TSRS_ON_FIELD 5
+#define STV090x_WIDTH_Px_TSRS_ON_FIELD 1
+
+#define STV090x_Px_TSCFGH(__x) (0xF572 - (__x - 1) * 0x200)
+#define STV090x_P1_TSCFGH STV090x_Px_TSCFGH(1)
+#define STV090x_P2_TSCFGH STV090x_Px_TSCFGH(2)
+#define STV090x_OFFST_Px_TSFIFO_DVBCI_FIELD 7
+#define STV090x_WIDTH_Px_TSFIFO_DVBCI_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_SERIAL_FIELD 6
+#define STV090x_WIDTH_Px_TSFIFO_SERIAL_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_TEIUPDATE_FIELD 5
+#define STV090x_WIDTH_Px_TSFIFO_TEIUPDATE_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_DUTY50_FIELD 4
+#define STV090x_WIDTH_Px_TSFIFO_DUTY50_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_HSGNLOUT_FIELD 3
+#define STV090x_WIDTH_Px_TSFIFO_HSGNLOUT_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_ERRORMODE_FIELD 1
+#define STV090x_WIDTH_Px_TSFIFO_ERRORMODE_FIELD 2
+#define STV090x_OFFST_Px_RST_HWARE_FIELD 0
+#define STV090x_WIDTH_Px_RST_HWARE_FIELD 1
+
+#define STV090x_Px_TSCFGM(__x) (0xF573 - (__x - 1) * 0x200)
+#define STV090x_P1_TSCFGM STV090x_Px_TSCFGM(1)
+#define STV090x_P2_TSCFGM STV090x_Px_TSCFGM(2)
+#define STV090x_OFFST_Px_TSFIFO_MANSPEED_FIELD 6
+#define STV090x_WIDTH_Px_TSFIFO_MANSPEED_FIELD 2
+#define STV090x_OFFST_Px_TSFIFO_PERMDATA_FIELD 5
+#define STV090x_WIDTH_Px_TSFIFO_PERMDATA_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_INVDATA_FIELD 0
+#define STV090x_WIDTH_Px_TSFIFO_INVDATA_FIELD 1
+
+#define STV090x_Px_TSCFGL(__x) (0xF574 - (__x - 1) * 0x200)
+#define STV090x_P1_TSCFGL STV090x_Px_TSCFGL(1)
+#define STV090x_P2_TSCFGL STV090x_Px_TSCFGL(2)
+#define STV090x_OFFST_Px_TSFIFO_BCLKDEL1CK_FIELD 6
+#define STV090x_WIDTH_Px_TSFIFO_BCLKDEL1CK_FIELD 2
+#define STV090x_OFFST_Px_BCHERROR_MODE_FIELD 4
+#define STV090x_WIDTH_Px_BCHERROR_MODE_FIELD 2
+#define STV090x_OFFST_Px_TSFIFO_NSGNL2DATA_FIELD 3
+#define STV090x_WIDTH_Px_TSFIFO_NSGNL2DATA_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_EMBINDVB_FIELD 2
+#define STV090x_WIDTH_Px_TSFIFO_EMBINDVB_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_DPUNACT_FIELD 1
+#define STV090x_WIDTH_Px_TSFIFO_DPUNACT_FIELD 1
+
+#define STV090x_Px_TSINSDELH(__x) (0xF576 - (__x - 1) * 0x200)
+#define STV090x_P1_TSINSDELH STV090x_Px_TSINSDELH(1)
+#define STV090x_P2_TSINSDELH STV090x_Px_TSINSDELH(2)
+#define STV090x_OFFST_Px_TSDEL_SYNCBYTE_FIELD 7
+#define STV090x_WIDTH_Px_TSDEL_SYNCBYTE_FIELD 1
+#define STV090x_OFFST_Px_TSDEL_XXHEADER_FIELD 6
+#define STV090x_WIDTH_Px_TSDEL_XXHEADER_FIELD 1
+
+#define STV090x_Px_TSSPEED(__x) (0xF580 - (__x - 1) * 0x200)
+#define STV090x_P1_TSSPEED STV090x_Px_TSSPEED(1)
+#define STV090x_P2_TSSPEED STV090x_Px_TSSPEED(2)
+#define STV090x_OFFST_Px_TSFIFO_OUTSPEED_FIELD 0
+#define STV090x_WIDTH_Px_TSFIFO_OUTSPEED_FIELD 8
+
+#define STV090x_Px_TSSTATUS(__x) (0xF581 - (__x - 1) * 0x200)
+#define STV090x_P1_TSSTATUS STV090x_Px_TSSTATUS(1)
+#define STV090x_P2_TSSTATUS STV090x_Px_TSSTATUS(2)
+#define STV090x_OFFST_Px_TSFIFO_LINEOK_FIELD 7
+#define STV090x_WIDTH_Px_TSFIFO_LINEOK_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_ERROR_FIELD 6
+#define STV090x_WIDTH_Px_TSFIFO_ERROR_FIELD 1
+
+#define STV090x_Px_TSSTATUS2(__x) (0xF582 - (__x - 1) * 0x200)
+#define STV090x_P1_TSSTATUS2 STV090x_Px_TSSTATUS2(1)
+#define STV090x_P2_TSSTATUS2 STV090x_Px_TSSTATUS2(2)
+#define STV090x_OFFST_Px_TSFIFO_DEMODSEL_FIELD 7
+#define STV090x_WIDTH_Px_TSFIFO_DEMODSEL_FIELD 1
+#define STV090x_OFFST_Px_TSFIFOSPEED_STORE_FIELD 6
+#define STV090x_WIDTH_Px_TSFIFOSPEED_STORE_FIELD 1
+#define STV090x_OFFST_Px_DILXX_RESET_FIELD 5
+#define STV090x_WIDTH_Px_DILXX_RESET_FIELD 1
+#define STV090x_OFFST_Px_TSSERIAL_IMPOS_FIELD 5
+#define STV090x_WIDTH_Px_TSSERIAL_IMPOS_FIELD 1
+#define STV090x_OFFST_Px_SCRAMBDETECT_FIELD 1
+#define STV090x_WIDTH_Px_SCRAMBDETECT_FIELD 1
+
+#define STV090x_Px_TSBITRATEy(__x, __y) (0xF584 - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_TSBITRATE0 STV090x_Px_TSBITRATEy(1, 0)
+#define STV090x_P1_TSBITRATE1 STV090x_Px_TSBITRATEy(1, 1)
+#define STV090x_P2_TSBITRATE0 STV090x_Px_TSBITRATEy(2, 0)
+#define STV090x_P2_TSBITRATE1 STV090x_Px_TSBITRATEy(2, 1)
+#define STV090x_OFFST_Px_TSFIFO_BITRATE_FIELD 7
+#define STV090x_WIDTH_Px_TSFIFO_BITRATE_FIELD 8
+
+#define STV090x_Px_ERRCTRL1(__x) (0xF598 - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCTRL1 STV090x_Px_ERRCTRL1(1)
+#define STV090x_P2_ERRCTRL1 STV090x_Px_ERRCTRL1(2)
+#define STV090x_OFFST_Px_ERR_SOURCE_FIELD 4
+#define STV090x_WIDTH_Px_ERR_SOURCE_FIELD 4
+#define STV090x_OFFST_Px_NUM_EVENT_FIELD 0
+#define STV090x_WIDTH_Px_NUM_EVENT_FIELD 3
+
+#define STV090x_Px_ERRCNT12(__x) (0xF599 - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCNT12 STV090x_Px_ERRCNT12(1)
+#define STV090x_P2_ERRCNT12 STV090x_Px_ERRCNT12(2)
+#define STV090x_OFFST_Px_ERRCNT1_OLDVALUE_FIELD 7
+#define STV090x_WIDTH_Px_ERRCNT1_OLDVALUE_FIELD 1
+#define STV090x_OFFST_Px_ERR_CNT12_FIELD 0
+#define STV090x_WIDTH_Px_ERR_CNT12_FIELD 7
+
+#define STV090x_Px_ERRCNT11(__x) (0xF59A - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCNT11 STV090x_Px_ERRCNT11(1)
+#define STV090x_P2_ERRCNT11 STV090x_Px_ERRCNT11(2)
+#define STV090x_OFFST_Px_ERR_CNT11_FIELD 0
+#define STV090x_WIDTH_Px_ERR_CNT11_FIELD 8
+
+#define STV090x_Px_ERRCNT10(__x) (0xF59B - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCNT10 STV090x_Px_ERRCNT10(1)
+#define STV090x_P2_ERRCNT10 STV090x_Px_ERRCNT10(2)
+#define STV090x_OFFST_Px_ERR_CNT10_FIELD 0
+#define STV090x_WIDTH_Px_ERR_CNT10_FIELD 8
+
+#define STV090x_Px_ERRCTRL2(__x) (0xF59C - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCTRL2 STV090x_Px_ERRCTRL2(1)
+#define STV090x_P2_ERRCTRL2 STV090x_Px_ERRCTRL2(2)
+#define STV090x_OFFST_Px_ERR_SOURCE2_FIELD 4
+#define STV090x_WIDTH_Px_ERR_SOURCE2_FIELD 4
+#define STV090x_OFFST_Px_NUM_EVENT2_FIELD 0
+#define STV090x_WIDTH_Px_NUM_EVENT2_FIELD 3
+
+#define STV090x_Px_ERRCNT22(__x) (0xF59D - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCNT22 STV090x_Px_ERRCNT22(1)
+#define STV090x_P2_ERRCNT22 STV090x_Px_ERRCNT22(2)
+#define STV090x_OFFST_Px_ERRCNT2_OLDVALUE_FIELD 7
+#define STV090x_WIDTH_Px_ERRCNT2_OLDVALUE_FIELD 1
+#define STV090x_OFFST_Px_ERR_CNT2_FIELD 0
+#define STV090x_WIDTH_Px_ERR_CNT2_FIELD 7
+
+#define STV090x_Px_ERRCNT21(__x) (0xF59E - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCNT21 STV090x_Px_ERRCNT21(1)
+#define STV090x_P2_ERRCNT21 STV090x_Px_ERRCNT21(2)
+#define STV090x_OFFST_Px_ERR_CNT21_FIELD 0
+#define STV090x_WIDTH_Px_ERR_CNT21_FIELD 8
+
+#define STV090x_Px_ERRCNT20(__x) (0xF59F - (__x - 1) * 0x200)
+#define STV090x_P1_ERRCNT20 STV090x_Px_ERRCNT20(1)
+#define STV090x_P2_ERRCNT20 STV090x_Px_ERRCNT20(2)
+#define STV090x_OFFST_Px_ERR_CNT20_FIELD 0
+#define STV090x_WIDTH_Px_ERR_CNT20_FIELD 8
+
+#define STV090x_Px_FECSPY(__x) (0xF5A0 - (__x - 1) * 0x200)
+#define STV090x_P1_FECSPY STV090x_Px_FECSPY(1)
+#define STV090x_P2_FECSPY STV090x_Px_FECSPY(2)
+#define STV090x_OFFST_Px_SPY_ENABLE_FIELD 7
+#define STV090x_WIDTH_Px_SPY_ENABLE_FIELD 1
+#define STV090x_OFFST_Px_BERMETER_DATAMAODE_FIELD 2
+#define STV090x_WIDTH_Px_BERMETER_DATAMAODE_FIELD 2
+
+#define STV090x_Px_FSPYCFG(__x) (0xF5A1 - (__x - 1) * 0x200)
+#define STV090x_P1_FSPYCFG STV090x_Px_FSPYCFG(1)
+#define STV090x_P2_FSPYCFG STV090x_Px_FSPYCFG(2)
+#define STV090x_OFFST_Px_RST_ON_ERROR_FIELD 5
+#define STV090x_WIDTH_Px_RST_ON_ERROR_FIELD 1
+#define STV090x_OFFST_Px_ONE_SHOT_FIELD 4
+#define STV090x_WIDTH_Px_ONE_SHOT_FIELD 1
+#define STV090x_OFFST_Px_I2C_MODE_FIELD 2
+#define STV090x_WIDTH_Px_I2C_MODE_FIELD 2
+
+#define STV090x_Px_FSPYDATA(__x) (0xF5A2 - (__x - 1) * 0x200)
+#define STV090x_P1_FSPYDATA STV090x_Px_FSPYDATA(1)
+#define STV090x_P2_FSPYDATA STV090x_Px_FSPYDATA(2)
+#define STV090x_OFFST_Px_SPY_STUFFING_FIELD 7
+#define STV090x_WIDTH_Px_SPY_STUFFING_FIELD 1
+#define STV090x_OFFST_Px_SPY_CNULLPKT_FIELD 5
+#define STV090x_WIDTH_Px_SPY_CNULLPKT_FIELD 1
+#define STV090x_OFFST_Px_SPY_OUTDATA_MODE_FIELD 0
+#define STV090x_WIDTH_Px_SPY_OUTDATA_MODE_FIELD 5
+
+#define STV090x_Px_FSPYOUT(__x) (0xF5A3 - (__x - 1) * 0x200)
+#define STV090x_P1_FSPYOUT STV090x_Px_FSPYOUT(1)
+#define STV090x_P2_FSPYOUT STV090x_Px_FSPYOUT(2)
+#define STV090x_OFFST_Px_FSPY_DIRECT_FIELD 7
+#define STV090x_WIDTH_Px_FSPY_DIRECT_FIELD 1
+#define STV090x_OFFST_Px_STUFF_MODE_FIELD 0
+#define STV090x_WIDTH_Px_STUFF_MODE_FIELD 3
+
+#define STV090x_Px_FSTATUS(__x) (0xF5A4 - (__x - 1) * 0x200)
+#define STV090x_P1_FSTATUS STV090x_Px_FSTATUS(1)
+#define STV090x_P2_FSTATUS STV090x_Px_FSTATUS(2)
+#define STV090x_OFFST_Px_SPY_ENDSIM_FIELD 7
+#define STV090x_WIDTH_Px_SPY_ENDSIM_FIELD 1
+#define STV090x_OFFST_Px_VALID_SIM_FIELD 6
+#define STV090x_WIDTH_Px_VALID_SIM_FIELD 1
+#define STV090x_OFFST_Px_FOUND_SIGNAL_FIELD 5
+#define STV090x_WIDTH_Px_FOUND_SIGNAL_FIELD 1
+#define STV090x_OFFST_Px_DSS_SYNCBYTE_FIELD 4
+#define STV090x_WIDTH_Px_DSS_SYNCBYTE_FIELD 1
+#define STV090x_OFFST_Px_RESULT_STATE_FIELD 0
+#define STV090x_WIDTH_Px_RESULT_STATE_FIELD 4
+
+#define STV090x_Px_FBERCPT4(__x) (0xF5A8 - (__x - 1) * 0x200)
+#define STV090x_P1_FBERCPT4 STV090x_Px_FBERCPT4(1)
+#define STV090x_P2_FBERCPT4 STV090x_Px_FBERCPT4(2)
+#define STV090x_OFFST_Px_FBERMETER_CPT_FIELD 0
+#define STV090x_WIDTH_Px_FBERMETER_CPT_FIELD 8
+
+#define STV090x_Px_FBERCPT3(__x) (0xF5A9 - (__x - 1) * 0x200)
+#define STV090x_P1_FBERCPT3 STV090x_Px_FBERCPT3(1)
+#define STV090x_P2_FBERCPT3 STV090x_Px_FBERCPT3(2)
+#define STV090x_OFFST_Px_FBERMETER_CPT_FIELD 0
+#define STV090x_WIDTH_Px_FBERMETER_CPT_FIELD 8
+
+#define STV090x_Px_FBERCPT2(__x) (0xF5AA - (__x - 1) * 0x200)
+#define STV090x_P1_FBERCPT2 STV090x_Px_FBERCPT2(1)
+#define STV090x_P2_FBERCPT2 STV090x_Px_FBERCPT2(2)
+#define STV090x_OFFST_Px_FBERMETER_CPT_FIELD 0
+#define STV090x_WIDTH_Px_FBERMETER_CPT_FIELD 8
+
+#define STV090x_Px_FBERCPT1(__x) (0xF5AB - (__x - 1) * 0x200)
+#define STV090x_P1_FBERCPT1 STV090x_Px_FBERCPT1(1)
+#define STV090x_P2_FBERCPT1 STV090x_Px_FBERCPT1(2)
+#define STV090x_OFFST_Px_FBERMETER_CPT_FIELD 0
+#define STV090x_WIDTH_Px_FBERMETER_CPT_FIELD 8
+
+#define STV090x_Px_FBERCPT0(__x) (0xF5AC - (__x - 1) * 0x200)
+#define STV090x_P1_FBERCPT0 STV090x_Px_FBERCPT0(1)
+#define STV090x_P2_FBERCPT0 STV090x_Px_FBERCPT0(2)
+#define STV090x_OFFST_Px_FBERMETER_CPT_FIELD 0
+#define STV090x_WIDTH_Px_FBERMETER_CPT_FIELD 8
+
+#define STV090x_Px_FBERERRy(__x, __y) (0xF5AF - (__x - 1) * 0x200 - __y * 0x1)
+#define STV090x_P1_FBERERR0 STV090x_Px_FBERERRy(1, 0)
+#define STV090x_P1_FBERERR1 STV090x_Px_FBERERRy(1, 1)
+#define STV090x_P1_FBERERR2 STV090x_Px_FBERERRy(1, 2)
+#define STV090x_P2_FBERERR0 STV090x_Px_FBERERRy(2, 0)
+#define STV090x_P2_FBERERR1 STV090x_Px_FBERERRy(2, 1)
+#define STV090x_P2_FBERERR2 STV090x_Px_FBERERRy(2, 2)
+#define STV090x_OFFST_Px_FBERMETER_CPT_ERR_FIELD 0
+#define STV090x_WIDTH_Px_FBERMETER_CPT_ERR_FIELD 8
+
+#define STV090x_Px_FSPYBER(__x) (0xF5B2 - (__x - 1) * 0x200)
+#define STV090x_P1_FSPYBER STV090x_Px_FSPYBER(1)
+#define STV090x_P2_FSPYBER STV090x_Px_FSPYBER(2)
+#define STV090x_OFFST_Px_FSPYBER_SYNCBYTE_FIELD 4
+#define STV090x_WIDTH_Px_FSPYBER_SYNCBYTE_FIELD 1
+#define STV090x_OFFST_Px_FSPYBER_UNSYNC_FIELD 3
+#define STV090x_WIDTH_Px_FSPYBER_UNSYNC_FIELD 1
+#define STV090x_OFFST_Px_FSPYBER_CTIME_FIELD 0
+#define STV090x_WIDTH_Px_FSPYBER_CTIME_FIELD 3
+
+#define STV090x_RCCFGH 0xf600
+
+#define STV090x_TSGENERAL 0xF630
+#define STV090x_OFFST_Px_MUXSTREAM_OUT_FIELD 3
+#define STV090x_WIDTH_Px_MUXSTREAM_OUT_FIELD 1
+#define STV090x_OFFST_Px_TSFIFO_PERMPARAL_FIELD 1
+#define STV090x_WIDTH_Px_TSFIFO_PERMPARAL_FIELD 2
+
+#define STV090x_TSGENERAL1X 0xf670
+#define STV090x_CFGEXT 0xfa80
+
+#define STV090x_TSTRES0 0xFF11
+#define STV090x_OFFST_FRESFEC_FIELD 7
+#define STV090x_WIDTH_FRESFEC_FIELD 1
+
+#define STV090x_Px_TSTDISRX(__x) (0xFF67 - (__x - 1) * 0x2)
+#define STV090x_P1_TSTDISRX STV090x_Px_TSTDISRX(1)
+#define STV090x_P2_TSTDISRX STV090x_Px_TSTDISRX(2)
+#define STV090x_OFFST_Px_TSTDISRX_SELECT_FIELD 3
+#define STV090x_WIDTH_Px_TSTDISRX_SELECT_FIELD 1
+
+#endif /* __STV090x_REG_H */
diff --git a/drivers/media/dvb/frontends/stv6110x.c b/drivers/media/dvb/frontends/stv6110x.c
new file mode 100644
index 000000000000..3d8a2e01c9c4
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv6110x.c
@@ -0,0 +1,373 @@
+/*
+ STV6110(A) Silicon tuner driver
+
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+
+#include "dvb_frontend.h"
+
+#include "stv6110x_reg.h"
+#include "stv6110x.h"
+#include "stv6110x_priv.h"
+
+static unsigned int verbose;
+module_param(verbose, int, 0644);
+MODULE_PARM_DESC(verbose, "Set Verbosity level");
+
+static u8 stv6110x_regs[] = {0x07, 0x11, 0xdc, 0x85, 0x17, 0x01, 0xe6, 0x1e};
+
+static int stv6110x_read_reg(struct stv6110x_state *stv6110x, u8 reg, u8 *data)
+{
+ int ret;
+ const struct stv6110x_config *config = stv6110x->config;
+ u8 b0[] = { reg };
+ u8 b1[] = { 0 };
+ struct i2c_msg msg[] = {
+ { .addr = config->addr, .flags = 0, .buf = b0, .len = 1 },
+ { .addr = config->addr, .flags = I2C_M_RD, .buf = b1, .len = 1 }
+ };
+
+ ret = i2c_transfer(stv6110x->i2c, msg, 2);
+ if (ret != 2) {
+ dprintk(FE_ERROR, 1, "I/O Error");
+ return -EREMOTEIO;
+ }
+ *data = b1[0];
+
+ return 0;
+}
+
+static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data)
+{
+ int ret;
+ const struct stv6110x_config *config = stv6110x->config;
+ u8 buf[] = { reg, data };
+ struct i2c_msg msg = { .addr = config->addr, .flags = 0, . buf = buf, .len = 2 };
+
+ ret = i2c_transfer(stv6110x->i2c, &msg, 1);
+ if (ret != 1) {
+ dprintk(FE_ERROR, 1, "I/O Error");
+ return -EREMOTEIO;
+ }
+
+ return 0;
+}
+
+static int stv6110x_init(struct dvb_frontend *fe)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+ int ret;
+ u8 i;
+
+ for (i = 0; i < ARRAY_SIZE(stv6110x_regs); i++) {
+ ret = stv6110x_write_reg(stv6110x, i, stv6110x_regs[i]);
+ if (ret < 0) {
+ dprintk(FE_ERROR, 1, "Initialization failed");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int stv6110x_set_frequency(struct dvb_frontend *fe, u32 frequency)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+ u32 rDiv, divider;
+ s32 pVal, pCalc, rDivOpt = 0;
+ u8 i;
+
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz - 16));
+
+ if (frequency <= 1023000) {
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_DIV4SEL, 1);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_PRESC32_ON, 0);
+ pVal = 40;
+ } else if (frequency <= 1300000) {
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_DIV4SEL, 1);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_PRESC32_ON, 1);
+ pVal = 40;
+ } else if (frequency <= 2046000) {
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_DIV4SEL, 0);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_PRESC32_ON, 0);
+ pVal = 20;
+ } else {
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_DIV4SEL, 0);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_PRESC32_ON, 1);
+ pVal = 20;
+ }
+
+ for (rDiv = 0; rDiv <= 3; rDiv++) {
+ pCalc = (REFCLOCK_kHz / 100) / R_DIV(rDiv);
+
+ if ((abs((s32)(pCalc - pVal))) < (abs((s32)(1000 - pVal))))
+ rDivOpt = rDiv;
+ }
+
+ divider = (frequency * R_DIV(rDivOpt) * pVal) / REFCLOCK_kHz;
+ divider = (divider + 5) / 10;
+
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_R_DIV, rDivOpt);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG1], TNG1_N_DIV_11_8, MSB(divider));
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_TNG0], TNG0_N_DIV_7_0, LSB(divider));
+
+ /* VCO Auto calibration */
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_STAT1], STAT1_CALVCO_STRT, 1);
+
+ stv6110x_write_reg(stv6110x, STV6110x_CTRL1, stv6110x_regs[STV6110x_CTRL1]);
+ stv6110x_write_reg(stv6110x, STV6110x_TNG1, stv6110x_regs[STV6110x_TNG1]);
+ stv6110x_write_reg(stv6110x, STV6110x_TNG0, stv6110x_regs[STV6110x_TNG0]);
+ stv6110x_write_reg(stv6110x, STV6110x_STAT1, stv6110x_regs[STV6110x_STAT1]);
+
+ for (i = 0; i < TRIALS; i++) {
+ stv6110x_read_reg(stv6110x, STV6110x_STAT1, &stv6110x_regs[STV6110x_STAT1]);
+ if (!STV6110x_GETFIELD(STAT1_CALVCO_STRT, stv6110x_regs[STV6110x_STAT1]))
+ break;
+ msleep(1);
+ }
+
+ return 0;
+}
+
+static int stv6110x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ stv6110x_read_reg(stv6110x, STV6110x_TNG1, &stv6110x_regs[STV6110x_TNG1]);
+ stv6110x_read_reg(stv6110x, STV6110x_TNG0, &stv6110x_regs[STV6110x_TNG0]);
+
+ *frequency = (MAKEWORD16(STV6110x_GETFIELD(TNG1_N_DIV_11_8, stv6110x_regs[STV6110x_TNG1]),
+ STV6110x_GETFIELD(TNG0_N_DIV_7_0, stv6110x_regs[STV6110x_TNG0]))) * REFCLOCK_kHz;
+
+ *frequency /= (1 << (STV6110x_GETFIELD(TNG1_R_DIV, stv6110x_regs[STV6110x_TNG1]) +
+ STV6110x_GETFIELD(TNG1_DIV4SEL, stv6110x_regs[STV6110x_TNG1])));
+
+ *frequency >>= 2;
+
+ return 0;
+}
+
+static int stv6110x_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+ u32 halfbw;
+ u8 i;
+
+ halfbw = bandwidth >> 1;
+
+ if (halfbw > 36000000)
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL3], CTRL3_CF, 31); /* LPF */
+ else if (halfbw < 5000000)
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL3], CTRL3_CF, 0); /* LPF */
+ else
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL3], CTRL3_CF, ((halfbw / 1000000) - 5)); /* LPF */
+
+
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL3], CTRL3_RCCLK_OFF, 0x0); /* cal. clk activated */
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_STAT1], STAT1_CALRC_STRT, 0x1); /* LPF auto cal */
+
+ stv6110x_write_reg(stv6110x, STV6110x_CTRL3, stv6110x_regs[STV6110x_CTRL3]);
+ stv6110x_write_reg(stv6110x, STV6110x_STAT1, stv6110x_regs[STV6110x_STAT1]);
+
+ for (i = 0; i < TRIALS; i++) {
+ stv6110x_read_reg(stv6110x, STV6110x_STAT1, &stv6110x_regs[STV6110x_STAT1]);
+ if (!STV6110x_GETFIELD(STAT1_CALRC_STRT, stv6110x_regs[STV6110x_STAT1]))
+ break;
+ msleep(1);
+ }
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL3], CTRL3_RCCLK_OFF, 0x1); /* cal. done */
+ stv6110x_write_reg(stv6110x, STV6110x_CTRL3, stv6110x_regs[STV6110x_CTRL3]);
+
+ return 0;
+}
+
+static int stv6110x_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ stv6110x_read_reg(stv6110x, STV6110x_CTRL3, &stv6110x_regs[STV6110x_CTRL3]);
+ *bandwidth = (STV6110x_GETFIELD(CTRL3_CF, stv6110x_regs[STV6110x_CTRL3]) + 5) * 2000000;
+
+ return 0;
+}
+
+static int stv6110x_set_refclock(struct dvb_frontend *fe, u32 refclock)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ /* setup divider */
+ switch (refclock) {
+ default:
+ case 1:
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL2], CTRL2_CO_DIV, 0);
+ break;
+ case 2:
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL2], CTRL2_CO_DIV, 1);
+ break;
+ case 4:
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL2], CTRL2_CO_DIV, 2);
+ break;
+ case 8:
+ case 0:
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL2], CTRL2_CO_DIV, 3);
+ break;
+ }
+ stv6110x_write_reg(stv6110x, STV6110x_CTRL2, stv6110x_regs[STV6110x_CTRL2]);
+
+ return 0;
+}
+
+static int stv6110x_get_bbgain(struct dvb_frontend *fe, u32 *gain)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ stv6110x_read_reg(stv6110x, STV6110x_CTRL2, &stv6110x_regs[STV6110x_CTRL2]);
+ *gain = 2 * STV6110x_GETFIELD(CTRL2_BBGAIN, stv6110x_regs[STV6110x_CTRL2]);
+
+ return 0;
+}
+
+static int stv6110x_set_bbgain(struct dvb_frontend *fe, u32 gain)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL2], CTRL2_BBGAIN, gain / 2);
+ stv6110x_write_reg(stv6110x, STV6110x_CTRL2, stv6110x_regs[STV6110x_CTRL2]);
+
+ return 0;
+}
+
+static int stv6110x_set_mode(struct dvb_frontend *fe, enum tuner_mode mode)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+ int ret;
+
+ switch (mode) {
+ case TUNER_SLEEP:
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_SYN, 0);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_RX, 0);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_LPT, 0);
+ break;
+
+ case TUNER_WAKE:
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_SYN, 1);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_RX, 1);
+ STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_LPT, 1);
+ break;
+ }
+
+ ret = stv6110x_write_reg(stv6110x, STV6110x_CTRL1, stv6110x_regs[STV6110x_CTRL1]);
+ if (ret < 0) {
+ dprintk(FE_ERROR, 1, "I/O Error");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int stv6110x_sleep(struct dvb_frontend *fe)
+{
+ return stv6110x_set_mode(fe, TUNER_SLEEP);
+}
+
+static int stv6110x_get_status(struct dvb_frontend *fe, u32 *status)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ stv6110x_read_reg(stv6110x, STV6110x_STAT1, &stv6110x_regs[STV6110x_STAT1]);
+
+ if (STV6110x_GETFIELD(STAT1_LOCK, stv6110x_regs[STV6110x_STAT1]))
+ *status = TUNER_PHASELOCKED;
+ else
+ *status = 0;
+
+ return 0;
+}
+
+
+static int stv6110x_release(struct dvb_frontend *fe)
+{
+ struct stv6110x_state *stv6110x = fe->tuner_priv;
+
+ fe->tuner_priv = NULL;
+ kfree(stv6110x);
+
+ return 0;
+}
+
+static struct dvb_tuner_ops stv6110x_ops = {
+ .info = {
+ .name = "STV6110(A) Silicon Tuner",
+ .frequency_min = 950000,
+ .frequency_max = 2150000,
+ .frequency_step = 0,
+ },
+
+ .init = stv6110x_init,
+ .sleep = stv6110x_sleep,
+ .release = stv6110x_release
+};
+
+static struct stv6110x_devctl stv6110x_ctl = {
+ .tuner_init = stv6110x_init,
+ .tuner_set_mode = stv6110x_set_mode,
+ .tuner_set_frequency = stv6110x_set_frequency,
+ .tuner_get_frequency = stv6110x_get_frequency,
+ .tuner_set_bandwidth = stv6110x_set_bandwidth,
+ .tuner_get_bandwidth = stv6110x_get_bandwidth,
+ .tuner_set_bbgain = stv6110x_set_bbgain,
+ .tuner_get_bbgain = stv6110x_get_bbgain,
+ .tuner_set_refclk = stv6110x_set_refclock,
+ .tuner_get_status = stv6110x_get_status,
+};
+
+struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+ const struct stv6110x_config *config,
+ struct i2c_adapter *i2c)
+{
+ struct stv6110x_state *stv6110x;
+
+ stv6110x = kzalloc(sizeof (struct stv6110x_state), GFP_KERNEL);
+ if (stv6110x == NULL)
+ goto error;
+
+ stv6110x->i2c = i2c;
+ stv6110x->config = config;
+ stv6110x->devctl = &stv6110x_ctl;
+
+ fe->tuner_priv = stv6110x;
+ fe->ops.tuner_ops = stv6110x_ops;
+
+ printk("%s: Attaching STV6110x \n", __func__);
+ return stv6110x->devctl;
+
+error:
+ kfree(stv6110x);
+ return NULL;
+}
+EXPORT_SYMBOL(stv6110x_attach);
+
+MODULE_AUTHOR("Manu Abraham");
+MODULE_DESCRIPTION("STV6110x Silicon tuner");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/stv6110x.h b/drivers/media/dvb/frontends/stv6110x.h
new file mode 100644
index 000000000000..a38257080e01
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv6110x.h
@@ -0,0 +1,71 @@
+/*
+ STV6110(A) Silicon tuner driver
+
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __STV6110x_H
+#define __STV6110x_H
+
+struct stv6110x_config {
+ u8 addr;
+ u32 refclk;
+};
+
+enum tuner_mode {
+ TUNER_SLEEP = 1,
+ TUNER_WAKE,
+};
+
+enum tuner_status {
+ TUNER_PHASELOCKED = 1,
+};
+
+struct stv6110x_devctl {
+ int (*tuner_init) (struct dvb_frontend *fe);
+ int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode);
+ int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency);
+ int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency);
+ int (*tuner_set_bandwidth) (struct dvb_frontend *fe, u32 bandwidth);
+ int (*tuner_get_bandwidth) (struct dvb_frontend *fe, u32 *bandwidth);
+ int (*tuner_set_bbgain) (struct dvb_frontend *fe, u32 gain);
+ int (*tuner_get_bbgain) (struct dvb_frontend *fe, u32 *gain);
+ int (*tuner_set_refclk) (struct dvb_frontend *fe, u32 refclk);
+ int (*tuner_get_status) (struct dvb_frontend *fe, u32 *status);
+};
+
+
+#if defined(CONFIG_DVB_STV6110x) || (defined(CONFIG_DVB_STV6110x_MODULE) && defined(MODULE))
+
+extern struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+ const struct stv6110x_config *config,
+ struct i2c_adapter *i2c);
+
+#else
+static inline struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+ const struct stv6110x_config *config,
+ struct i2c_adapter *i2c)
+{
+ printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+ return NULL;
+}
+
+#endif /* CONFIG_DVB_STV6110x */
+
+#endif /* __STV6110x_H */
diff --git a/drivers/media/dvb/frontends/stv6110x_priv.h b/drivers/media/dvb/frontends/stv6110x_priv.h
new file mode 100644
index 000000000000..7260da633d49
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv6110x_priv.h
@@ -0,0 +1,75 @@
+/*
+ STV6110(A) Silicon tuner driver
+
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __STV6110x_PRIV_H
+#define __STV6110x_PRIV_H
+
+#define FE_ERROR 0
+#define FE_NOTICE 1
+#define FE_INFO 2
+#define FE_DEBUG 3
+#define FE_DEBUGREG 4
+
+#define dprintk(__y, __z, format, arg...) do { \
+ if (__z) { \
+ if ((verbose > FE_ERROR) && (verbose > __y)) \
+ printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_NOTICE) && (verbose > __y)) \
+ printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_INFO) && (verbose > __y)) \
+ printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
+ else if ((verbose > FE_DEBUG) && (verbose > __y)) \
+ printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
+ } else { \
+ if (verbose > __y) \
+ printk(format, ##arg); \
+ } \
+} while (0)
+
+
+#define STV6110x_SETFIELD(mask, bitf, val) \
+ (mask = (mask & (~(((1 << STV6110x_WIDTH_##bitf) - 1) << \
+ STV6110x_OFFST_##bitf))) | \
+ (val << STV6110x_OFFST_##bitf))
+
+#define STV6110x_GETFIELD(bitf, val) \
+ ((val >> STV6110x_OFFST_##bitf) & \
+ ((1 << STV6110x_WIDTH_##bitf) - 1))
+
+#define MAKEWORD16(a, b) (((a) << 8) | (b))
+
+#define LSB(x) ((x & 0xff))
+#define MSB(y) ((y >> 8) & 0xff)
+
+#define TRIALS 10
+#define R_DIV(__div) (1 << (__div + 1))
+#define REFCLOCK_kHz (stv6110x->config->refclk / 1000)
+#define REFCLOCK_MHz (stv6110x->config->refclk / 1000000)
+
+struct stv6110x_state {
+ struct i2c_adapter *i2c;
+ const struct stv6110x_config *config;
+
+ struct stv6110x_devctl *devctl;
+};
+
+#endif /* __STV6110x_PRIV_H */
diff --git a/drivers/media/dvb/frontends/stv6110x_reg.h b/drivers/media/dvb/frontends/stv6110x_reg.h
new file mode 100644
index 000000000000..93e5c70e5fd8
--- /dev/null
+++ b/drivers/media/dvb/frontends/stv6110x_reg.h
@@ -0,0 +1,82 @@
+/*
+ STV6110(A) Silicon tuner driver
+
+ Copyright (C) Manu Abraham <abraham.manu@gmail.com>
+
+ Copyright (C) ST Microelectronics
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __STV6110x_REG_H
+#define __STV6110x_REG_H
+
+#define STV6110x_CTRL1 0x00
+#define STV6110x_OFFST_CTRL1_K 3
+#define STV6110x_WIDTH_CTRL1_K 5
+#define STV6110x_OFFST_CTRL1_LPT 2
+#define STV6110x_WIDTH_CTRL1_LPT 1
+#define STV6110x_OFFST_CTRL1_RX 1
+#define STV6110x_WIDTH_CTRL1_RX 1
+#define STV6110x_OFFST_CTRL1_SYN 0
+#define STV6110x_WIDTH_CTRL1_SYN 1
+
+#define STV6110x_CTRL2 0x01
+#define STV6110x_OFFST_CTRL2_CO_DIV 6
+#define STV6110x_WIDTH_CTRL2_CO_DIV 2
+#define STV6110x_OFFST_CTRL2_RSVD 5
+#define STV6110x_WIDTH_CTRL2_RSVD 1
+#define STV6110x_OFFST_CTRL2_REFOUT_SEL 4
+#define STV6110x_WIDTH_CTRL2_REFOUT_SEL 1
+#define STV6110x_OFFST_CTRL2_BBGAIN 0
+#define STV6110x_WIDTH_CTRL2_BBGAIN 4
+
+#define STV6110x_TNG0 0x02
+#define STV6110x_OFFST_TNG0_N_DIV_7_0 0
+#define STV6110x_WIDTH_TNG0_N_DIV_7_0 8
+
+#define STV6110x_TNG1 0x03
+#define STV6110x_OFFST_TNG1_R_DIV 6
+#define STV6110x_WIDTH_TNG1_R_DIV 2
+#define STV6110x_OFFST_TNG1_PRESC32_ON 5
+#define STV6110x_WIDTH_TNG1_PRESC32_ON 1
+#define STV6110x_OFFST_TNG1_DIV4SEL 4
+#define STV6110x_WIDTH_TNG1_DIV4SEL 1
+#define STV6110x_OFFST_TNG1_N_DIV_11_8 0
+#define STV6110x_WIDTH_TNG1_N_DIV_11_8 4
+
+
+#define STV6110x_CTRL3 0x04
+#define STV6110x_OFFST_CTRL3_DCLOOP_OFF 7
+#define STV6110x_WIDTH_CTRL3_DCLOOP_OFF 1
+#define STV6110x_OFFST_CTRL3_RCCLK_OFF 6
+#define STV6110x_WIDTH_CTRL3_RCCLK_OFF 1
+#define STV6110x_OFFST_CTRL3_ICP 5
+#define STV6110x_WIDTH_CTRL3_ICP 1
+#define STV6110x_OFFST_CTRL3_CF 0
+#define STV6110x_WIDTH_CTRL3_CF 5
+
+#define STV6110x_STAT1 0x05
+#define STV6110x_OFFST_STAT1_CALVCO_STRT 2
+#define STV6110x_WIDTH_STAT1_CALVCO_STRT 1
+#define STV6110x_OFFST_STAT1_CALRC_STRT 1
+#define STV6110x_WIDTH_STAT1_CALRC_STRT 1
+#define STV6110x_OFFST_STAT1_LOCK 0
+#define STV6110x_WIDTH_STAT1_LOCK 1
+
+#define STV6110x_STAT2 0x06
+#define STV6110x_STAT3 0x07
+
+#endif /* __STV6110x_REG_H */
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c
index 2a8bbcd44cd0..11be4697cb3d 100644
--- a/drivers/media/dvb/frontends/tda10048.c
+++ b/drivers/media/dvb/frontends/tda10048.c
@@ -25,6 +25,7 @@
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/delay.h>
+#include <asm/div64.h>
#include "dvb_frontend.h"
#include "dvb_math.h"
#include "tda10048.h"
@@ -143,6 +144,15 @@ struct tda10048_state {
struct dvb_frontend frontend;
int fwloaded;
+
+ u32 freq_if_hz;
+ u32 xtal_hz;
+ u32 pll_mfactor;
+ u32 pll_nfactor;
+ u32 pll_pfactor;
+ u32 sample_freq;
+
+ enum fe_bandwidth bandwidth;
};
static struct init_tab {
@@ -271,6 +281,199 @@ error:
return ret;
}
+static int tda10048_set_phy2(struct dvb_frontend *fe, u32 sample_freq_hz,
+ u32 if_hz)
+{
+ struct tda10048_state *state = fe->demodulator_priv;
+ u64 t;
+
+ dprintk(1, "%s()\n", __func__);
+
+ if (sample_freq_hz == 0)
+ return -EINVAL;
+
+ if (if_hz < (sample_freq_hz / 2)) {
+ /* PHY2 = (if2/fs) * 2^15 */
+ t = if_hz;
+ t *= 10;
+ t *= 32768;
+ do_div(t, sample_freq_hz);
+ t += 5;
+ do_div(t, 10);
+ } else {
+ /* PHY2 = ((IF1-fs)/fs) * 2^15 */
+ t = sample_freq_hz - if_hz;
+ t *= 10;
+ t *= 32768;
+ do_div(t, sample_freq_hz);
+ t += 5;
+ do_div(t, 10);
+ t = ~t + 1;
+ }
+
+ tda10048_writereg(state, TDA10048_FREQ_PHY2_LSB, (u8)t);
+ tda10048_writereg(state, TDA10048_FREQ_PHY2_MSB, (u8)(t >> 8));
+
+ return 0;
+}
+
+static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz,
+ u32 bw)
+{
+ struct tda10048_state *state = fe->demodulator_priv;
+ u64 t, z;
+ u32 b = 8000000;
+
+ dprintk(1, "%s()\n", __func__);
+
+ if (sample_freq_hz == 0)
+ return -EINVAL;
+
+ if (bw == BANDWIDTH_6_MHZ)
+ b = 6000000;
+ else
+ if (bw == BANDWIDTH_7_MHZ)
+ b = 7000000;
+
+ /* WREF = (B / (7 * fs)) * 2^31 */
+ t = b * 10;
+ /* avoid warning: this decimal constant is unsigned only in ISO C90 */
+ /* t *= 2147483648 on 32bit platforms */
+ t *= (2048 * 1024);
+ t *= 1024;
+ z = 7 * sample_freq_hz;
+ do_div(t, z);
+ t += 5;
+ do_div(t, 10);
+
+ tda10048_writereg(state, TDA10048_TIME_WREF_LSB, (u8)t);
+ tda10048_writereg(state, TDA10048_TIME_WREF_MID1, (u8)(t >> 8));
+ tda10048_writereg(state, TDA10048_TIME_WREF_MID2, (u8)(t >> 16));
+ tda10048_writereg(state, TDA10048_TIME_WREF_MSB, (u8)(t >> 24));
+
+ return 0;
+}
+
+static int tda10048_set_invwref(struct dvb_frontend *fe, u32 sample_freq_hz,
+ u32 bw)
+{
+ struct tda10048_state *state = fe->demodulator_priv;
+ u64 t;
+ u32 b = 8000000;
+
+ dprintk(1, "%s()\n", __func__);
+
+ if (sample_freq_hz == 0)
+ return -EINVAL;
+
+ if (bw == BANDWIDTH_6_MHZ)
+ b = 6000000;
+ else
+ if (bw == BANDWIDTH_7_MHZ)
+ b = 7000000;
+
+ /* INVWREF = ((7 * fs) / B) * 2^5 */
+ t = sample_freq_hz;
+ t *= 7;
+ t *= 32;
+ t *= 10;
+ do_div(t, b);
+ t += 5;
+ do_div(t, 10);
+
+ tda10048_writereg(state, TDA10048_TIME_INVWREF_LSB, (u8)t);
+ tda10048_writereg(state, TDA10048_TIME_INVWREF_MSB, (u8)(t >> 8));
+
+ return 0;
+}
+
+static int tda10048_set_bandwidth(struct dvb_frontend *fe,
+ enum fe_bandwidth bw)
+{
+ struct tda10048_state *state = fe->demodulator_priv;
+ dprintk(1, "%s(bw=%d)\n", __func__, bw);
+
+ /* Bandwidth setting may need to be adjusted */
+ switch (bw) {
+ case BANDWIDTH_6_MHZ:
+ case BANDWIDTH_7_MHZ:
+ case BANDWIDTH_8_MHZ:
+ tda10048_set_wref(fe, state->sample_freq, bw);
+ tda10048_set_invwref(fe, state->sample_freq, bw);
+ break;
+ default:
+ printk(KERN_ERR "%s() invalid bandwidth\n", __func__);
+ return -EINVAL;
+ }
+
+ state->bandwidth = bw;
+
+ return 0;
+}
+
+static int tda10048_set_pll(struct dvb_frontend *fe)
+{
+ struct tda10048_state *state = fe->demodulator_priv;
+ int ret = 0;
+
+ dprintk(1, "%s()\n", __func__);
+
+ if ((state->config->clk_freq_khz == TDA10048_CLK_4000) &&
+ (state->config->if_freq_khz == TDA10048_IF_36130)) {
+ state->freq_if_hz = TDA10048_IF_36130 * 1000;
+ state->xtal_hz = TDA10048_CLK_4000 * 1000;
+ state->pll_mfactor = 10;
+ state->pll_nfactor = 0;
+ state->pll_pfactor = 0;
+ } else
+ if ((state->config->clk_freq_khz == TDA10048_CLK_16000) &&
+ (state->config->if_freq_khz == TDA10048_IF_4300)) {
+ state->freq_if_hz = TDA10048_IF_4300 * 1000;
+ state->xtal_hz = TDA10048_CLK_16000 * 1000;
+ state->pll_mfactor = 10;
+ state->pll_nfactor = 3;
+ state->pll_pfactor = 0;
+ } else
+ if ((state->config->clk_freq_khz == TDA10048_CLK_16000) &&
+ (state->config->if_freq_khz == TDA10048_IF_4000)) {
+ state->freq_if_hz = TDA10048_IF_4000 * 1000;
+ state->xtal_hz = TDA10048_CLK_16000 * 1000;
+ state->pll_mfactor = 10;
+ state->pll_nfactor = 3;
+ state->pll_pfactor = 0;
+ } else
+ if ((state->config->clk_freq_khz == TDA10048_CLK_16000) &&
+ (state->config->if_freq_khz == TDA10048_IF_36130)) {
+ state->freq_if_hz = TDA10048_IF_36130 * 1000;
+ state->xtal_hz = TDA10048_CLK_16000 * 1000;
+ state->pll_mfactor = 10;
+ state->pll_nfactor = 3;
+ state->pll_pfactor = 0;
+ } else {
+ printk(KERN_ERR "%s() Incorrect attach settings\n", __func__);
+ ret = -EINVAL;
+ }
+
+ dprintk(1, "- freq_if_hz = %d\n", state->freq_if_hz);
+ dprintk(1, "- xtal_hz = %d\n", state->xtal_hz);
+ dprintk(1, "- pll_mfactor = %d\n", state->pll_mfactor);
+ dprintk(1, "- pll_nfactor = %d\n", state->pll_nfactor);
+ dprintk(1, "- pll_pfactor = %d\n", state->pll_pfactor);
+
+ /* Calculate the sample frequency */
+ state->sample_freq = state->xtal_hz * (state->pll_mfactor + 45);
+ state->sample_freq /= (state->pll_nfactor + 1);
+ state->sample_freq /= (state->pll_pfactor + 4);
+ dprintk(1, "- sample_freq = %d\n", state->sample_freq);
+
+ tda10048_set_phy2(fe, state->sample_freq,
+ state->config->if_freq_khz * 1000);
+ tda10048_set_wref(fe, state->sample_freq, state->bandwidth);
+ tda10048_set_invwref(fe, state->sample_freq, state->bandwidth);
+
+ return ret;
+}
+
static int tda10048_firmware_upload(struct dvb_frontend *fe)
{
struct tda10048_state *state = fe->demodulator_priv;
@@ -289,7 +492,7 @@ static int tda10048_firmware_upload(struct dvb_frontend *fe)
TDA10048_DEFAULT_FIRMWARE);
ret = request_firmware(&fw, TDA10048_DEFAULT_FIRMWARE,
- &state->i2c->dev);
+ state->i2c->dev.parent);
if (ret) {
printk(KERN_ERR "%s: Upload failed. (file not found?)\n",
__func__);
@@ -486,6 +689,9 @@ static int tda10048_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
struct tda10048_state *state = fe->demodulator_priv;
dprintk(1, "%s(%d)\n", __func__, enable);
+ if (state->config->disable_gate_access)
+ return 0;
+
if (enable)
return tda10048_writereg(state, TDA10048_CONF_C4_1,
tda10048_readreg(state, TDA10048_CONF_C4_1) | 0x02);
@@ -523,6 +729,9 @@ static int tda10048_set_frontend(struct dvb_frontend *fe,
dprintk(1, "%s(frequency=%d)\n", __func__, p->frequency);
+ if (p->u.ofdm.bandwidth != state->bandwidth)
+ tda10048_set_bandwidth(fe, p->u.ofdm.bandwidth);
+
if (fe->ops.tuner_ops.set_params) {
if (fe->ops.i2c_gate_ctrl)
@@ -558,9 +767,15 @@ static int tda10048_init(struct dvb_frontend *fe)
/* Set either serial or parallel */
tda10048_output_mode(fe, state->config->output_mode);
- /* set inversion */
+ /* Set inversion */
tda10048_set_inversion(fe, state->config->inversion);
+ /* Establish default PLL values */
+ tda10048_set_pll(fe);
+
+ /* Establish default bandwidth */
+ tda10048_set_bandwidth(fe, BANDWIDTH_8_MHZ);
+
/* Ensure we leave the gate closed */
tda10048_i2c_gate_ctrl(fe, 0);
@@ -830,6 +1045,7 @@ struct dvb_frontend *tda10048_attach(const struct tda10048_config *config,
state->config = config;
state->i2c = i2c;
state->fwloaded = 0;
+ state->bandwidth = BANDWIDTH_8_MHZ;
/* check if the demod is present */
if (tda10048_readreg(state, TDA10048_IDENTITY) != 0x048)
@@ -840,6 +1056,10 @@ struct dvb_frontend *tda10048_attach(const struct tda10048_config *config,
sizeof(struct dvb_frontend_ops));
state->frontend.demodulator_priv = state;
+ /* Set the xtal and freq defaults */
+ if (tda10048_set_pll(&state->frontend) != 0)
+ goto error;
+
/* Leave the gate closed */
tda10048_i2c_gate_ctrl(&state->frontend, 0);
diff --git a/drivers/media/dvb/frontends/tda10048.h b/drivers/media/dvb/frontends/tda10048.h
index 0457b24601fa..ee07b50e90d1 100644
--- a/drivers/media/dvb/frontends/tda10048.h
+++ b/drivers/media/dvb/frontends/tda10048.h
@@ -43,6 +43,23 @@ struct tda10048_config {
#define TDA10048_INVERSION_OFF 0
#define TDA10048_INVERSION_ON 1
u8 inversion;
+
+#define TDA10048_IF_3300 3300
+#define TDA10048_IF_3500 3500
+#define TDA10048_IF_3800 3800
+#define TDA10048_IF_4000 4000
+#define TDA10048_IF_4300 4300
+#define TDA10048_IF_4500 4500
+#define TDA10048_IF_4750 4750
+#define TDA10048_IF_36130 36130
+ u16 if_freq_khz;
+
+#define TDA10048_CLK_4000 4000
+#define TDA10048_CLK_16000 16000
+ u16 clk_freq_khz;
+
+ /* Disable I2C gate access */
+ u8 disable_gate_access;
};
#if defined(CONFIG_DVB_TDA10048) || \
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index 7bd4d1dee2b3..f3e1cc733fe7 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -58,42 +58,6 @@ struct smscore_client_t {
onremove_t onremove_handler;
};
-struct smscore_device_t {
- struct list_head entry;
-
- struct list_head clients;
- struct list_head subclients;
- spinlock_t clientslock;
-
- struct list_head buffers;
- spinlock_t bufferslock;
- int num_buffers;
-
- void *common_buffer;
- int common_buffer_size;
- dma_addr_t common_buffer_phys;
-
- void *context;
- struct device *device;
-
- char devpath[32];
- unsigned long device_flags;
-
- setmode_t setmode_handler;
- detectmode_t detectmode_handler;
- sendrequest_t sendrequest_handler;
- preload_t preload_handler;
- postload_t postload_handler;
-
- int mode, modes_supported;
-
- struct completion version_ex_done, data_download_done, trigger_done;
- struct completion init_device_done, reload_start_done, resume_done;
-
- int board_id;
- int led_state;
-};
-
void smscore_set_board_id(struct smscore_device_t *core, int id)
{
core->board_id = id;
diff --git a/drivers/media/dvb/siano/smscoreapi.h b/drivers/media/dvb/siano/smscoreapi.h
index 548de9056e8b..d826ded926ec 100644
--- a/drivers/media/dvb/siano/smscoreapi.h
+++ b/drivers/media/dvb/siano/smscoreapi.h
@@ -1,26 +1,26 @@
-/*
- * Driver for the Siano SMS1xxx USB dongle
- *
- * author: Anatoly Greenblat
- *
- * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
- *
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __smscoreapi_h__
-#define __smscoreapi_h__
+/****************************************************************
+
+Siano Mobile Silicon, Inc.
+MDTV receiver kernel modules.
+Copyright (C) 2006-2008, Uri Shkolnik, Anatoly Greenblat
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+****************************************************************/
+
+#ifndef __SMS_CORE_API_H__
+#define __SMS_CORE_API_H__
#include <linux/version.h>
#include <linux/device.h>
@@ -28,14 +28,19 @@
#include <linux/mm.h>
#include <linux/scatterlist.h>
#include <linux/types.h>
-#include <asm/page.h>
#include <linux/mutex.h>
+#include <linux/wait.h>
+#include <linux/timer.h>
+
+#include <asm/page.h>
+#define SMS_DVB3_SUBSYS
+#ifdef SMS_DVB3_SUBSYS
#include "dmxdev.h"
#include "dvbdev.h"
#include "dvb_demux.h"
#include "dvb_frontend.h"
-
+#endif
#define kmutex_init(_p_) mutex_init(_p_)
#define kmutex_lock(_p_) mutex_lock(_p_)
@@ -46,13 +51,14 @@
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
-#define SMS_ALLOC_ALIGNMENT 128
-#define SMS_DMA_ALIGNMENT 16
+#define SMS_PROTOCOL_MAX_RAOUNDTRIP_MS (10000)
+#define SMS_ALLOC_ALIGNMENT 128
+#define SMS_DMA_ALIGNMENT 16
#define SMS_ALIGN_ADDRESS(addr) \
((((uintptr_t)(addr)) + (SMS_DMA_ALIGNMENT-1)) & ~(SMS_DMA_ALIGNMENT-1))
-#define SMS_DEVICE_FAMILY2 1
-#define SMS_ROM_NO_RESPONSE 2
+#define SMS_DEVICE_FAMILY2 1
+#define SMS_ROM_NO_RESPONSE 2
#define SMS_DEVICE_NOT_READY 0x8000000
enum sms_device_type_st {
@@ -83,13 +89,13 @@ typedef void (*onremove_t)(void *context);
struct smscore_buffer_t {
/* public members, once passed to clients can be changed freely */
struct list_head entry;
- int size;
- int offset;
+ int size;
+ int offset;
/* private members, read-only for clients */
- void *p;
- dma_addr_t phys;
- unsigned long offset_in_common;
+ void *p;
+ dma_addr_t phys;
+ unsigned long offset_in_common;
};
struct smsdevice_params_t {
@@ -116,10 +122,63 @@ struct smsclient_params_t {
int data_type;
onresponse_t onresponse_handler;
onremove_t onremove_handler;
-
void *context;
};
+struct smscore_device_t {
+ struct list_head entry;
+
+ struct list_head clients;
+ struct list_head subclients;
+ spinlock_t clientslock;
+
+ struct list_head buffers;
+ spinlock_t bufferslock;
+ int num_buffers;
+
+ void *common_buffer;
+ int common_buffer_size;
+ dma_addr_t common_buffer_phys;
+
+ void *context;
+ struct device *device;
+
+ char devpath[32];
+ unsigned long device_flags;
+
+ setmode_t setmode_handler;
+ detectmode_t detectmode_handler;
+ sendrequest_t sendrequest_handler;
+ preload_t preload_handler;
+ postload_t postload_handler;
+
+ int mode, modes_supported;
+
+ /* host <--> device messages */
+ struct completion version_ex_done, data_download_done, trigger_done;
+ struct completion init_device_done, reload_start_done, resume_done;
+ struct completion gpio_configuration_done, gpio_set_level_done;
+ struct completion gpio_get_level_done, ir_init_done;
+
+ /* Buffer management */
+ wait_queue_head_t buffer_mng_waitq;
+
+ /* GPIO */
+ int gpio_get_res;
+
+ /* Target hardware board */
+ int board_id;
+
+ /* Firmware */
+ u8 *fw_buf;
+ u32 fw_buf_size;
+
+ /* Infrared (IR) */
+ /* struct ir_t ir; */
+
+ int led_state;
+};
+
/* GPIO definitions for antenna frequency domain control (SMS8021) */
#define SMS_ANTENNA_GPIO_0 1
#define SMS_ANTENNA_GPIO_1 0
@@ -161,6 +220,7 @@ struct smsclient_params_t {
#define MSG_SMS_GET_PID_FILTER_LIST_RES 609
#define MSG_SMS_GET_STATISTICS_REQ 615
#define MSG_SMS_GET_STATISTICS_RES 616
+#define MSG_SMS_HO_PER_SLICES_IND 630
#define MSG_SMS_SET_ANTENNA_CONFIG_REQ 651
#define MSG_SMS_SET_ANTENNA_CONFIG_RES 652
#define MSG_SMS_GET_STATISTICS_EX_REQ 653
@@ -190,14 +250,31 @@ struct smsclient_params_t {
#define MSG_SMS_GPIO_CONFIG_EX_RES 713
#define MSG_SMS_ISDBT_TUNE_REQ 776
#define MSG_SMS_ISDBT_TUNE_RES 777
+#define MSG_SMS_TRANSMISSION_IND 782
+#define MSG_SMS_START_IR_REQ 800
+#define MSG_SMS_START_IR_RES 801
+#define MSG_SMS_IR_SAMPLES_IND 802
+#define MSG_SMS_SIGNAL_DETECTED_IND 827
+#define MSG_SMS_NO_SIGNAL_IND 828
#define SMS_INIT_MSG_EX(ptr, type, src, dst, len) do { \
(ptr)->msgType = type; (ptr)->msgSrcId = src; (ptr)->msgDstId = dst; \
(ptr)->msgLength = len; (ptr)->msgFlags = 0; \
} while (0)
+
#define SMS_INIT_MSG(ptr, type, len) \
SMS_INIT_MSG_EX(ptr, type, 0, HIF_TASK, len)
+enum SMS_DVB3_EVENTS {
+ DVB3_EVENT_INIT = 0,
+ DVB3_EVENT_SLEEP,
+ DVB3_EVENT_HOTPLUG,
+ DVB3_EVENT_FE_LOCK,
+ DVB3_EVENT_FE_UNLOCK,
+ DVB3_EVENT_UNC_OK,
+ DVB3_EVENT_UNC_ERR
+};
+
enum SMS_DEVICE_MODE {
DEVICE_MODE_NONE = -1,
DEVICE_MODE_DVBT = 0,
@@ -221,8 +298,13 @@ struct SmsMsgHdr_ST {
};
struct SmsMsgData_ST {
- struct SmsMsgHdr_ST xMsgHeader;
- u32 msgData[1];
+ struct SmsMsgHdr_ST xMsgHeader;
+ u32 msgData[1];
+};
+
+struct SmsMsgData_ST2 {
+ struct SmsMsgHdr_ST xMsgHeader;
+ u32 msgData[2];
};
struct SmsDataDownload_ST {
@@ -238,11 +320,12 @@ struct SmsVersionRes_ST {
u8 Step; /* 0 - Step A */
u8 MetalFix; /* 0 - Metal 0 */
- u8 FirmwareId; /* 0xFF � ROM, otherwise the
- * value indicated by
- * SMSHOSTLIB_DEVICE_MODES_E */
- u8 SupportedProtocols; /* Bitwise OR combination of
+ /* FirmwareId 0xFF if ROM, otherwise the
+ * value indicated by SMSHOSTLIB_DEVICE_MODES_E */
+ u8 FirmwareId;
+ /* SupportedProtocols Bitwise OR combination of
* supported protocols */
+ u8 SupportedProtocols;
u8 VersionMajor;
u8 VersionMinor;
@@ -276,10 +359,12 @@ struct SMSHOSTLIB_STATISTICS_ST {
s32 SNR; /* dB */
u32 BER; /* Post Viterbi BER [1E-5] */
u32 FIB_CRC; /* CRC errors percentage, valid only for DAB */
- u32 TS_PER; /* Transport stream PER, 0xFFFFFFFF indicate N/A,
+ /* Transport stream PER, 0xFFFFFFFF indicate N/A,
* valid only for DVB-T/H */
- u32 MFER; /* DVB-H frame error rate in percentage,
+ u32 TS_PER;
+ /* DVB-H frame error rate in percentage,
* 0xFFFFFFFF indicate N/A, valid only for DVB-H */
+ u32 MFER;
s32 RSSI; /* dBm */
s32 InBandPwr; /* In band power in dBM */
s32 CarrierOffset; /* Carrier Offset in bin/1024 */
@@ -287,8 +372,9 @@ struct SMSHOSTLIB_STATISTICS_ST {
/* Transmission parameters, valid only for DVB-T/H */
u32 Frequency; /* Frequency in Hz */
u32 Bandwidth; /* Bandwidth in MHz */
- u32 TransmissionMode; /* Transmission Mode, for DAB modes 1-4,
+ /* Transmission Mode, for DAB modes 1-4,
* for DVB-T/H FFT mode carriers in Kilos */
+ u32 TransmissionMode;
u32 ModemState; /* from SMS_DvbModemState_ET */
u32 GuardInterval; /* Guard Interval, 1 divided by value */
u32 CodeRate; /* Code Rate from SMS_DvbModemState_ET */
@@ -442,4 +528,4 @@ int smscore_led_state(struct smscore_device_t *core, int led);
dprintk(KERN_DEBUG, DBG_ADV, fmt, ##arg)
-#endif /* __smscoreapi_h__ */
+#endif /* __SMS_CORE_API_H__ */
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index ba080b95befb..9d6aab59a05e 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -1,23 +1,23 @@
-/*
- * Driver for the Siano SMS1xxx USB dongle
- *
- * Author: Uri Shkolni
- *
- * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
- *
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
+/****************************************************************
+
+Siano Mobile Silicon, Inc.
+MDTV receiver kernel modules.
+Copyright (C) 2006-2008, Uri Shkolnik
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+****************************************************************/
#include <linux/module.h>
#include <linux/init.h>
@@ -485,7 +485,6 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
client->coredev = coredev;
init_completion(&client->tune_done);
- init_completion(&client->stat_done);
kmutex_lock(&g_smsdvb_clientslock);
diff --git a/drivers/media/dvb/siano/smsendian.c b/drivers/media/dvb/siano/smsendian.c
new file mode 100644
index 000000000000..d79aa051269a
--- /dev/null
+++ b/drivers/media/dvb/siano/smsendian.c
@@ -0,0 +1,100 @@
+/****************************************************************
+
+ Siano Mobile Silicon, Inc.
+ MDTV receiver kernel modules.
+ Copyright (C) 2006-2009, Uri Shkolnik
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ ****************************************************************/
+
+#include <asm/byteorder.h>
+
+#include "smsendian.h"
+#include "smscoreapi.h"
+
+void smsendian_handle_tx_message(void *buffer)
+{
+#ifdef __BIG_ENDIAN
+ struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)buffer;
+ int i;
+ int msgWords;
+
+ switch (msg->xMsgHeader.msgType) {
+ case MSG_SMS_DATA_DOWNLOAD_REQ:
+ {
+ msg->msgData[0] = le32_to_cpu(msg->msgData[0]);
+ break;
+ }
+
+ default:
+ msgWords = (msg->xMsgHeader.msgLength -
+ sizeof(struct SmsMsgHdr_ST))/4;
+
+ for (i = 0; i < msgWords; i++)
+ msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
+
+ break;
+ }
+#endif /* __BIG_ENDIAN */
+}
+
+void smsendian_handle_rx_message(void *buffer)
+{
+#ifdef __BIG_ENDIAN
+ struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)buffer;
+ int i;
+ int msgWords;
+
+ switch (msg->xMsgHeader.msgType) {
+ case MSG_SMS_GET_VERSION_EX_RES:
+ {
+ struct SmsVersionRes_ST *ver =
+ (struct SmsVersionRes_ST *) msg;
+ ver->ChipModel = le16_to_cpu(ver->ChipModel);
+ break;
+ }
+
+ case MSG_SMS_DVBT_BDA_DATA:
+ case MSG_SMS_DAB_CHANNEL:
+ case MSG_SMS_DATA_MSG:
+ {
+ break;
+ }
+
+ default:
+ {
+ msgWords = (msg->xMsgHeader.msgLength -
+ sizeof(struct SmsMsgHdr_ST))/4;
+
+ for (i = 0; i < msgWords; i++)
+ msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
+
+ break;
+ }
+ }
+#endif /* __BIG_ENDIAN */
+}
+
+void smsendian_handle_message_header(void *msg)
+{
+#ifdef __BIG_ENDIAN
+ struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *)msg;
+
+ phdr->msgType = le16_to_cpu(phdr->msgType);
+ phdr->msgLength = le16_to_cpu(phdr->msgLength);
+ phdr->msgFlags = le16_to_cpu(phdr->msgFlags);
+#endif /* __BIG_ENDIAN */
+}
+
diff --git a/drivers/media/dvb/siano/smsendian.h b/drivers/media/dvb/siano/smsendian.h
new file mode 100644
index 000000000000..7fbedc6a6527
--- /dev/null
+++ b/drivers/media/dvb/siano/smsendian.h
@@ -0,0 +1,32 @@
+/****************************************************************
+
+Siano Mobile Silicon, Inc.
+MDTV receiver kernel modules.
+Copyright (C) 2006-2009, Uri Shkolnik
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+****************************************************************/
+
+#ifndef __SMS_ENDIAN_H__
+#define __SMS_ENDIAN_H__
+
+#include <asm/byteorder.h>
+
+void smsendian_handle_tx_message(void *buffer);
+void smsendian_handle_rx_message(void *buffer);
+void smsendian_handle_message_header(void *msg);
+
+#endif /* __SMS_ENDIAN_H__ */
+
diff --git a/drivers/media/dvb/siano/smsir.c b/drivers/media/dvb/siano/smsir.c
new file mode 100644
index 000000000000..a5f302c58fdb
--- /dev/null
+++ b/drivers/media/dvb/siano/smsir.c
@@ -0,0 +1,301 @@
+/****************************************************************
+
+ Siano Mobile Silicon, Inc.
+ MDTV receiver kernel modules.
+ Copyright (C) 2006-2009, Uri Shkolnik
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ ****************************************************************/
+
+
+#include <linux/types.h>
+#include <linux/input.h>
+
+#include "smscoreapi.h"
+#include "smsir.h"
+#include "sms-cards.h"
+
+/* In order to add new IR remote control -
+ * 1) Add it to the <enum ir_kb_type> @ smsir,h,
+ * 2) Add its map to keyboard_layout_maps below
+ * 3) Set your board (sms-cards sub-module) to use it
+ */
+
+static struct keyboard_layout_map_t keyboard_layout_maps[] = {
+ [SMS_IR_KB_DEFAULT_TV] = {
+ .ir_protocol = IR_RC5,
+ .rc5_kbd_address = KEYBOARD_ADDRESS_TV1,
+ .keyboard_layout_map = {
+ KEY_0, KEY_1, KEY_2,
+ KEY_3, KEY_4, KEY_5,
+ KEY_6, KEY_7, KEY_8,
+ KEY_9, 0, 0, KEY_POWER,
+ KEY_MUTE, 0, 0,
+ KEY_VOLUMEUP, KEY_VOLUMEDOWN,
+ KEY_BRIGHTNESSUP,
+ KEY_BRIGHTNESSDOWN, KEY_CHANNELUP,
+ KEY_CHANNELDOWN,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ }
+ },
+ [SMS_IR_KB_HCW_SILVER] = {
+ .ir_protocol = IR_RC5,
+ .rc5_kbd_address = KEYBOARD_ADDRESS_LIGHTING1,
+ .keyboard_layout_map = {
+ KEY_0, KEY_1, KEY_2,
+ KEY_3, KEY_4, KEY_5,
+ KEY_6, KEY_7, KEY_8,
+ KEY_9, KEY_TEXT, KEY_RED,
+ KEY_RADIO, KEY_MENU,
+ KEY_SUBTITLE,
+ KEY_MUTE, KEY_VOLUMEUP,
+ KEY_VOLUMEDOWN, KEY_PREVIOUS, 0,
+ KEY_UP, KEY_DOWN, KEY_LEFT,
+ KEY_RIGHT, KEY_VIDEO, KEY_AUDIO,
+ KEY_MHP, KEY_EPG, KEY_TV,
+ 0, KEY_NEXTSONG, KEY_EXIT,
+ KEY_CHANNELUP, KEY_CHANNELDOWN,
+ KEY_CHANNEL, 0,
+ KEY_PREVIOUSSONG, KEY_ENTER,
+ KEY_SLEEP, 0, 0, KEY_BLUE,
+ 0, 0, 0, 0, KEY_GREEN, 0,
+ KEY_PAUSE, 0, KEY_REWIND,
+ 0, KEY_FASTFORWARD, KEY_PLAY,
+ KEY_STOP, KEY_RECORD,
+ KEY_YELLOW, 0, 0, KEY_SELECT,
+ KEY_ZOOM, KEY_POWER, 0, 0
+ }
+ },
+ { } /* Terminating entry */
+};
+
+u32 ir_pos;
+u32 ir_word;
+u32 ir_toggle;
+
+#define RC5_PUSH_BIT(dst, bit, pos) \
+ { dst <<= 1; dst |= bit; pos++; }
+
+
+static void sms_ir_rc5_event(struct smscore_device_t *coredev,
+ u32 toggle, u32 addr, u32 cmd)
+{
+ bool toggle_changed;
+ u16 keycode;
+
+ sms_info("IR RC5 word: address %d, command %d, toggle %d",
+ addr, cmd, toggle);
+
+ toggle_changed = ir_toggle != toggle;
+ /* keep toggle */
+ ir_toggle = toggle;
+
+ if (addr !=
+ keyboard_layout_maps[coredev->ir.ir_kb_type].rc5_kbd_address)
+ return; /* Check for valid address */
+
+ keycode =
+ keyboard_layout_maps
+ [coredev->ir.ir_kb_type].keyboard_layout_map[cmd];
+
+ if (!toggle_changed &&
+ (keycode != KEY_VOLUMEUP && keycode != KEY_VOLUMEDOWN))
+ return; /* accept only repeated volume, reject other keys */
+
+ sms_info("kernel input keycode (from ir) %d", keycode);
+ input_report_key(coredev->ir.input_dev, keycode, 1);
+ input_sync(coredev->ir.input_dev);
+
+}
+
+/* decode raw bit pattern to RC5 code */
+/* taken from ir-functions.c */
+static u32 ir_rc5_decode(unsigned int code)
+{
+/* unsigned int org_code = code;*/
+ unsigned int pair;
+ unsigned int rc5 = 0;
+ int i;
+
+ for (i = 0; i < 14; ++i) {
+ pair = code & 0x3;
+ code >>= 2;
+
+ rc5 <<= 1;
+ switch (pair) {
+ case 0:
+ case 2:
+ break;
+ case 1:
+ rc5 |= 1;
+ break;
+ case 3:
+/* dprintk(1, "ir-common: ir_rc5_decode(%x) bad code\n", org_code);*/
+ sms_info("bad code");
+ return 0;
+ }
+ }
+/*
+ dprintk(1, "ir-common: code=%x, rc5=%x, start=%x,
+ toggle=%x, address=%x, "
+ "instr=%x\n", rc5, org_code, RC5_START(rc5),
+ RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
+*/
+ return rc5;
+}
+
+static void sms_rc5_parse_word(struct smscore_device_t *coredev)
+{
+ #define RC5_START(x) (((x)>>12)&3)
+ #define RC5_TOGGLE(x) (((x)>>11)&1)
+ #define RC5_ADDR(x) (((x)>>6)&0x1F)
+ #define RC5_INSTR(x) ((x)&0x3F)
+
+ int i, j;
+ u32 rc5_word = 0;
+
+ /* Reverse the IR word direction */
+ for (i = 0 ; i < 28 ; i++)
+ RC5_PUSH_BIT(rc5_word, (ir_word>>i)&1, j)
+
+ rc5_word = ir_rc5_decode(rc5_word);
+ /* sms_info("temp = 0x%x, rc5_code = 0x%x", ir_word, rc5_word); */
+
+ sms_ir_rc5_event(coredev,
+ RC5_TOGGLE(rc5_word),
+ RC5_ADDR(rc5_word),
+ RC5_INSTR(rc5_word));
+}
+
+
+static void sms_rc5_accumulate_bits(struct smscore_device_t *coredev,
+ s32 ir_sample)
+{
+ #define RC5_TIME_GRANULARITY 200
+ #define RC5_DEF_BIT_TIME 889
+ #define RC5_MAX_SAME_BIT_CONT 4
+ #define RC5_WORD_LEN 27 /* 28 bit */
+
+ u32 i, j;
+ s32 delta_time;
+ u32 time = (ir_sample > 0) ? ir_sample : (0-ir_sample);
+ u32 level = (ir_sample < 0) ? 0 : 1;
+
+ for (i = RC5_MAX_SAME_BIT_CONT; i > 0; i--) {
+ delta_time = time - (i*RC5_DEF_BIT_TIME) + RC5_TIME_GRANULARITY;
+ if (delta_time < 0)
+ continue; /* not so many consecutive bits */
+ if (delta_time > (2 * RC5_TIME_GRANULARITY)) {
+ /* timeout */
+ if (ir_pos == (RC5_WORD_LEN-1))
+ /* complete last bit */
+ RC5_PUSH_BIT(ir_word, level, ir_pos)
+
+ if (ir_pos == RC5_WORD_LEN)
+ sms_rc5_parse_word(coredev);
+ else if (ir_pos) /* timeout within a word */
+ sms_info("IR error parsing a word");
+
+ ir_pos = 0;
+ ir_word = 0;
+ /* sms_info("timeout %d", time); */
+ break;
+ }
+ /* The time is within the range of this number of bits */
+ for (j = 0 ; j < i ; j++)
+ RC5_PUSH_BIT(ir_word, level, ir_pos)
+
+ break;
+ }
+}
+
+void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len)
+{
+ #define IR_DATA_RECEIVE_MAX_LEN 520 /* 128*4 + 4 + 4 */
+ u32 i;
+ enum ir_protocol ir_protocol =
+ keyboard_layout_maps[coredev->ir.ir_kb_type]
+ .ir_protocol;
+ s32 *samples;
+ int count = len>>2;
+
+ samples = (s32 *)buf;
+/* sms_info("IR buffer received, length = %d", count);*/
+
+ for (i = 0; i < count; i++)
+ if (ir_protocol == IR_RC5)
+ sms_rc5_accumulate_bits(coredev, samples[i]);
+ /* IR_RCMM not implemented */
+}
+
+int sms_ir_init(struct smscore_device_t *coredev)
+{
+ struct input_dev *input_dev;
+
+ sms_info("Allocating input device");
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ sms_err("Not enough memory");
+ return -ENOMEM;
+ }
+
+ coredev->ir.input_dev = input_dev;
+ coredev->ir.ir_kb_type =
+ sms_get_board(smscore_get_board_id(coredev))->ir_kb_type;
+ coredev->ir.keyboard_layout_map =
+ keyboard_layout_maps[coredev->ir.ir_kb_type].
+ keyboard_layout_map;
+ sms_info("IR remote keyboard type is %d", coredev->ir.ir_kb_type);
+
+ coredev->ir.controller = 0; /* Todo: vega/nova SPI number */
+ coredev->ir.timeout = IR_DEFAULT_TIMEOUT;
+ sms_info("IR port %d, timeout %d ms",
+ coredev->ir.controller, coredev->ir.timeout);
+
+ snprintf(coredev->ir.name,
+ IR_DEV_NAME_MAX_LEN,
+ "SMS IR w/kbd type %d",
+ coredev->ir.ir_kb_type);
+ input_dev->name = coredev->ir.name;
+ input_dev->phys = coredev->ir.name;
+ input_dev->dev.parent = coredev->device;
+
+ /* Key press events only */
+ input_dev->evbit[0] = BIT_MASK(EV_KEY);
+ input_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0);
+
+ sms_info("Input device (IR) %s is set for key events", input_dev->name);
+
+ if (input_register_device(input_dev)) {
+ sms_err("Failed to register device");
+ input_free_device(input_dev);
+ return -EACCES;
+ }
+
+ return 0;
+}
+
+void sms_ir_exit(struct smscore_device_t *coredev)
+{
+ if (coredev->ir.input_dev)
+ input_unregister_device(coredev->ir.input_dev);
+
+ sms_info("");
+}
+
diff --git a/drivers/media/dvb/siano/smsir.h b/drivers/media/dvb/siano/smsir.h
new file mode 100644
index 000000000000..b7d703e2d338
--- /dev/null
+++ b/drivers/media/dvb/siano/smsir.h
@@ -0,0 +1,93 @@
+/****************************************************************
+
+Siano Mobile Silicon, Inc.
+MDTV receiver kernel modules.
+Copyright (C) 2006-2009, Uri Shkolnik
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+****************************************************************/
+
+#ifndef __SMS_IR_H__
+#define __SMS_IR_H__
+
+#include <linux/input.h>
+
+#define IR_DEV_NAME_MAX_LEN 23 /* "SMS IR kbd type nn\0" */
+#define IR_KEYBOARD_LAYOUT_SIZE 64
+#define IR_DEFAULT_TIMEOUT 100
+
+enum ir_kb_type {
+ SMS_IR_KB_DEFAULT_TV,
+ SMS_IR_KB_HCW_SILVER
+};
+
+enum rc5_keyboard_address {
+ KEYBOARD_ADDRESS_TV1 = 0,
+ KEYBOARD_ADDRESS_TV2 = 1,
+ KEYBOARD_ADDRESS_TELETEXT = 2,
+ KEYBOARD_ADDRESS_VIDEO = 3,
+ KEYBOARD_ADDRESS_LV1 = 4,
+ KEYBOARD_ADDRESS_VCR1 = 5,
+ KEYBOARD_ADDRESS_VCR2 = 6,
+ KEYBOARD_ADDRESS_EXPERIMENTAL = 7,
+ KEYBOARD_ADDRESS_SAT1 = 8,
+ KEYBOARD_ADDRESS_CAMERA = 9,
+ KEYBOARD_ADDRESS_SAT2 = 10,
+ KEYBOARD_ADDRESS_CDV = 12,
+ KEYBOARD_ADDRESS_CAMCORDER = 13,
+ KEYBOARD_ADDRESS_PRE_AMP = 16,
+ KEYBOARD_ADDRESS_TUNER = 17,
+ KEYBOARD_ADDRESS_RECORDER1 = 18,
+ KEYBOARD_ADDRESS_PRE_AMP1 = 19,
+ KEYBOARD_ADDRESS_CD_PLAYER = 20,
+ KEYBOARD_ADDRESS_PHONO = 21,
+ KEYBOARD_ADDRESS_SATA = 22,
+ KEYBOARD_ADDRESS_RECORDER2 = 23,
+ KEYBOARD_ADDRESS_CDR = 26,
+ KEYBOARD_ADDRESS_LIGHTING = 29,
+ KEYBOARD_ADDRESS_LIGHTING1 = 30, /* KEYBOARD_ADDRESS_HCW_SILVER */
+ KEYBOARD_ADDRESS_PHONE = 31,
+ KEYBOARD_ADDRESS_NOT_RC5 = 0xFFFF
+};
+
+enum ir_protocol {
+ IR_RC5,
+ IR_RCMM
+};
+
+struct keyboard_layout_map_t {
+ enum ir_protocol ir_protocol;
+ enum rc5_keyboard_address rc5_kbd_address;
+ u16 keyboard_layout_map[IR_KEYBOARD_LAYOUT_SIZE];
+};
+
+struct smscore_device_t;
+
+struct ir_t {
+ struct input_dev *input_dev;
+ enum ir_kb_type ir_kb_type;
+ char name[IR_DEV_NAME_MAX_LEN+1];
+ u16 *keyboard_layout_map;
+ u32 timeout;
+ u32 controller;
+};
+
+int sms_ir_init(struct smscore_device_t *coredev);
+void sms_ir_exit(struct smscore_device_t *coredev);
+void sms_ir_event(struct smscore_device_t *coredev,
+ const char *buf, int len);
+
+#endif /* __SMS_IR_H__ */
+
diff --git a/drivers/media/dvb/siano/smssdio.c b/drivers/media/dvb/siano/smssdio.c
new file mode 100644
index 000000000000..4f8fa59a995a
--- /dev/null
+++ b/drivers/media/dvb/siano/smssdio.c
@@ -0,0 +1,354 @@
+/*
+ * smssdio.c - Siano 1xxx SDIO interface driver
+ *
+ * Copyright 2008 Pierre Ossman
+ *
+ * Based on code by Siano Mobile Silicon, Inc.,
+ * Copyright (C) 2006-2008, Uri Shkolnik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ *
+ * This hardware is a bit odd in that all transfers should be done
+ * to/from the SMSSDIO_DATA register, yet the "increase address" bit
+ * always needs to be set.
+ *
+ * Also, buffers from the card are always aligned to 128 byte
+ * boundaries.
+ */
+
+/*
+ * General cleanup notes:
+ *
+ * - only typedefs should be name *_t
+ *
+ * - use ERR_PTR and friends for smscore_register_device()
+ *
+ * - smscore_getbuffer should zero fields
+ *
+ * Fix stop command
+ */
+
+#include <linux/moduleparam.h>
+#include <linux/firmware.h>
+#include <linux/delay.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+
+#include "smscoreapi.h"
+#include "sms-cards.h"
+
+/* Registers */
+
+#define SMSSDIO_DATA 0x00
+#define SMSSDIO_INT 0x04
+
+static const struct sdio_device_id smssdio_ids[] = {
+ {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR),
+ .driver_data = SMS1XXX_BOARD_SIANO_STELLAR},
+ {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_NOVA_A0),
+ .driver_data = SMS1XXX_BOARD_SIANO_NOVA_A},
+ {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_NOVA_B0),
+ .driver_data = SMS1XXX_BOARD_SIANO_NOVA_B},
+ {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_VEGA_A0),
+ .driver_data = SMS1XXX_BOARD_SIANO_VEGA},
+ {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_VENICE),
+ .driver_data = SMS1XXX_BOARD_SIANO_VEGA},
+ { /* end: all zeroes */ },
+};
+
+MODULE_DEVICE_TABLE(sdio, smssdio_ids);
+
+struct smssdio_device {
+ struct sdio_func *func;
+
+ struct smscore_device_t *coredev;
+
+ struct smscore_buffer_t *split_cb;
+};
+
+/*******************************************************************/
+/* Siano core callbacks */
+/*******************************************************************/
+
+static int smssdio_sendrequest(void *context, void *buffer, size_t size)
+{
+ int ret;
+ struct smssdio_device *smsdev;
+
+ smsdev = context;
+
+ sdio_claim_host(smsdev->func);
+
+ while (size >= smsdev->func->cur_blksize) {
+ ret = sdio_write_blocks(smsdev->func, SMSSDIO_DATA, buffer, 1);
+ if (ret)
+ goto out;
+
+ buffer += smsdev->func->cur_blksize;
+ size -= smsdev->func->cur_blksize;
+ }
+
+ if (size) {
+ ret = sdio_write_bytes(smsdev->func, SMSSDIO_DATA,
+ buffer, size);
+ }
+
+out:
+ sdio_release_host(smsdev->func);
+
+ return ret;
+}
+
+/*******************************************************************/
+/* SDIO callbacks */
+/*******************************************************************/
+
+static void smssdio_interrupt(struct sdio_func *func)
+{
+ int ret, isr;
+
+ struct smssdio_device *smsdev;
+ struct smscore_buffer_t *cb;
+ struct SmsMsgHdr_ST *hdr;
+ size_t size;
+
+ smsdev = sdio_get_drvdata(func);
+
+ /*
+ * The interrupt register has no defined meaning. It is just
+ * a way of turning of the level triggered interrupt.
+ */
+ isr = sdio_readb(func, SMSSDIO_INT, &ret);
+ if (ret) {
+ dev_err(&smsdev->func->dev,
+ "Unable to read interrupt register!\n");
+ return;
+ }
+
+ if (smsdev->split_cb == NULL) {
+ cb = smscore_getbuffer(smsdev->coredev);
+ if (!cb) {
+ dev_err(&smsdev->func->dev,
+ "Unable to allocate data buffer!\n");
+ return;
+ }
+
+ ret = sdio_read_blocks(smsdev->func, cb->p, SMSSDIO_DATA, 1);
+ if (ret) {
+ dev_err(&smsdev->func->dev,
+ "Error %d reading initial block!\n", ret);
+ return;
+ }
+
+ hdr = cb->p;
+
+ if (hdr->msgFlags & MSG_HDR_FLAG_SPLIT_MSG) {
+ smsdev->split_cb = cb;
+ return;
+ }
+
+ size = hdr->msgLength - smsdev->func->cur_blksize;
+ } else {
+ cb = smsdev->split_cb;
+ hdr = cb->p;
+
+ size = hdr->msgLength - sizeof(struct SmsMsgHdr_ST);
+
+ smsdev->split_cb = NULL;
+ }
+
+ if (hdr->msgLength > smsdev->func->cur_blksize) {
+ void *buffer;
+
+ size = ALIGN(size, 128);
+ buffer = cb->p + hdr->msgLength;
+
+ BUG_ON(smsdev->func->cur_blksize != 128);
+
+ /*
+ * First attempt to transfer all of it in one go...
+ */
+ ret = sdio_read_blocks(smsdev->func, buffer,
+ SMSSDIO_DATA, size / 128);
+ if (ret && ret != -EINVAL) {
+ smscore_putbuffer(smsdev->coredev, cb);
+ dev_err(&smsdev->func->dev,
+ "Error %d reading data from card!\n", ret);
+ return;
+ }
+
+ /*
+ * ..then fall back to one block at a time if that is
+ * not possible...
+ *
+ * (we have to do this manually because of the
+ * problem with the "increase address" bit)
+ */
+ if (ret == -EINVAL) {
+ while (size) {
+ ret = sdio_read_blocks(smsdev->func,
+ buffer, SMSSDIO_DATA, 1);
+ if (ret) {
+ smscore_putbuffer(smsdev->coredev, cb);
+ dev_err(&smsdev->func->dev,
+ "Error %d reading "
+ "data from card!\n", ret);
+ return;
+ }
+
+ buffer += smsdev->func->cur_blksize;
+ if (size > smsdev->func->cur_blksize)
+ size -= smsdev->func->cur_blksize;
+ else
+ size = 0;
+ }
+ }
+ }
+
+ cb->size = hdr->msgLength;
+ cb->offset = 0;
+
+ smscore_onresponse(smsdev->coredev, cb);
+}
+
+static int smssdio_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ int ret;
+
+ int board_id;
+ struct smssdio_device *smsdev;
+ struct smsdevice_params_t params;
+
+ board_id = id->driver_data;
+
+ smsdev = kzalloc(sizeof(struct smssdio_device), GFP_KERNEL);
+ if (!smsdev)
+ return -ENOMEM;
+
+ smsdev->func = func;
+
+ memset(&params, 0, sizeof(struct smsdevice_params_t));
+
+ params.device = &func->dev;
+ params.buffer_size = 0x5000; /* ?? */
+ params.num_buffers = 22; /* ?? */
+ params.context = smsdev;
+
+ snprintf(params.devpath, sizeof(params.devpath),
+ "sdio\\%s", sdio_func_id(func));
+
+ params.sendrequest_handler = smssdio_sendrequest;
+
+ params.device_type = sms_get_board(board_id)->type;
+
+ if (params.device_type != SMS_STELLAR)
+ params.flags |= SMS_DEVICE_FAMILY2;
+ else {
+ /*
+ * FIXME: Stellar needs special handling...
+ */
+ ret = -ENODEV;
+ goto free;
+ }
+
+ ret = smscore_register_device(&params, &smsdev->coredev);
+ if (ret < 0)
+ goto free;
+
+ smscore_set_board_id(smsdev->coredev, board_id);
+
+ sdio_claim_host(func);
+
+ ret = sdio_enable_func(func);
+ if (ret)
+ goto release;
+
+ ret = sdio_set_block_size(func, 128);
+ if (ret)
+ goto disable;
+
+ ret = sdio_claim_irq(func, smssdio_interrupt);
+ if (ret)
+ goto disable;
+
+ sdio_set_drvdata(func, smsdev);
+
+ sdio_release_host(func);
+
+ ret = smscore_start_device(smsdev->coredev);
+ if (ret < 0)
+ goto reclaim;
+
+ return 0;
+
+reclaim:
+ sdio_claim_host(func);
+ sdio_release_irq(func);
+disable:
+ sdio_disable_func(func);
+release:
+ sdio_release_host(func);
+ smscore_unregister_device(smsdev->coredev);
+free:
+ kfree(smsdev);
+
+ return ret;
+}
+
+static void smssdio_remove(struct sdio_func *func)
+{
+ struct smssdio_device *smsdev;
+
+ smsdev = sdio_get_drvdata(func);
+
+ /* FIXME: racy! */
+ if (smsdev->split_cb)
+ smscore_putbuffer(smsdev->coredev, smsdev->split_cb);
+
+ smscore_unregister_device(smsdev->coredev);
+
+ sdio_claim_host(func);
+ sdio_release_irq(func);
+ sdio_disable_func(func);
+ sdio_release_host(func);
+
+ kfree(smsdev);
+}
+
+static struct sdio_driver smssdio_driver = {
+ .name = "smssdio",
+ .id_table = smssdio_ids,
+ .probe = smssdio_probe,
+ .remove = smssdio_remove,
+};
+
+/*******************************************************************/
+/* Module functions */
+/*******************************************************************/
+
+int smssdio_register(void)
+{
+ int ret = 0;
+
+ printk(KERN_INFO "smssdio: Siano SMS1xxx SDIO driver\n");
+ printk(KERN_INFO "smssdio: Copyright Pierre Ossman\n");
+
+ ret = sdio_register_driver(&smssdio_driver);
+
+ return ret;
+}
+
+void smssdio_unregister(void)
+{
+ sdio_unregister_driver(&smssdio_driver);
+}
+
+MODULE_DESCRIPTION("Siano SMS1xxx SDIO driver");
+MODULE_AUTHOR("Pierre Ossman");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index 5e3f88911a1d..e162691b515d 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -1089,7 +1089,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
else {
int i, len = dc->x0-dc->color+1;
u8 __user *colors = (u8 __user *)dc->data;
- u8 r, g, b, blend;
+ u8 r, g = 0, b = 0, blend = 0;
ret = 0;
for (i = 0; i<len; i++) {
if (get_user(r, colors + i * 4) ||
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index 2210cff738e6..ce64c6214cc4 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -458,7 +458,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index);
if (av7110->analog_tuner_flags) {
- if (i->index < 0 || i->index >= 4)
+ if (i->index >= 4)
return -EINVAL;
} else {
if (i->index != 0)
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 855fe74b640b..8ea915227674 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1413,7 +1413,7 @@ static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{
dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index);
- if (i->index < 0 || i->index >= KNC1_INPUTS)
+ if (i->index >= KNC1_INPUTS)
return -EINVAL;
memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
return 0;
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 83e9e7750c8c..e48380c48990 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -47,6 +47,9 @@
#include "bsru6.h"
#include "bsbe1.h"
#include "tdhd1.h"
+#include "stv6110x.h"
+#include "stv090x.h"
+#include "isl6423.h"
static int diseqc_method;
module_param(diseqc_method, int, 0444);
@@ -425,6 +428,44 @@ static u8 read_pwm(struct budget* budget)
return pwm;
}
+static struct stv090x_config tt1600_stv090x_config = {
+ .device = STV0903,
+ .demod_mode = STV090x_SINGLE,
+ .clk_mode = STV090x_CLK_EXT,
+
+ .xtal = 27000000,
+ .address = 0x68,
+ .ref_clk = 27000000,
+
+ .ts1_mode = STV090x_TSMODE_DVBCI,
+ .ts2_mode = STV090x_TSMODE_SERIAL_CONTINUOUS,
+
+ .repeater_level = STV090x_RPTLEVEL_16,
+
+ .tuner_init = NULL,
+ .tuner_set_mode = NULL,
+ .tuner_set_frequency = NULL,
+ .tuner_get_frequency = NULL,
+ .tuner_set_bandwidth = NULL,
+ .tuner_get_bandwidth = NULL,
+ .tuner_set_bbgain = NULL,
+ .tuner_get_bbgain = NULL,
+ .tuner_set_refclk = NULL,
+ .tuner_get_status = NULL,
+};
+
+static struct stv6110x_config tt1600_stv6110x_config = {
+ .addr = 0x60,
+ .refclk = 27000000,
+};
+
+static struct isl6423_config tt1600_isl6423_config = {
+ .current_max = SEC_CURRENT_515m,
+ .curlim = SEC_CURRENT_LIM_ON,
+ .mod_extern = 1,
+ .addr = 0x08,
+};
+
static void frontend_init(struct budget *budget)
{
(void)alps_bsbe1_config; /* avoid warning */
@@ -566,6 +607,48 @@ static void frontend_init(struct budget *budget)
}
break;
}
+
+ case 0x101c: { /* TT S2-1600 */
+ struct stv6110x_devctl *ctl;
+ saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
+ msleep(50);
+ saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
+ msleep(250);
+
+ budget->dvb_frontend = dvb_attach(stv090x_attach,
+ &tt1600_stv090x_config,
+ &budget->i2c_adap,
+ STV090x_DEMODULATOR_0);
+
+ if (budget->dvb_frontend) {
+
+ ctl = dvb_attach(stv6110x_attach,
+ budget->dvb_frontend,
+ &tt1600_stv6110x_config,
+ &budget->i2c_adap);
+
+ tt1600_stv090x_config.tuner_init = ctl->tuner_init;
+ tt1600_stv090x_config.tuner_set_mode = ctl->tuner_set_mode;
+ tt1600_stv090x_config.tuner_set_frequency = ctl->tuner_set_frequency;
+ tt1600_stv090x_config.tuner_get_frequency = ctl->tuner_get_frequency;
+ tt1600_stv090x_config.tuner_set_bandwidth = ctl->tuner_set_bandwidth;
+ tt1600_stv090x_config.tuner_get_bandwidth = ctl->tuner_get_bandwidth;
+ tt1600_stv090x_config.tuner_set_bbgain = ctl->tuner_set_bbgain;
+ tt1600_stv090x_config.tuner_get_bbgain = ctl->tuner_get_bbgain;
+ tt1600_stv090x_config.tuner_set_refclk = ctl->tuner_set_refclk;
+ tt1600_stv090x_config.tuner_get_status = ctl->tuner_get_status;
+
+ dvb_attach(isl6423_attach,
+ budget->dvb_frontend,
+ &budget->i2c_adap,
+ &tt1600_isl6423_config);
+
+ } else {
+ dvb_frontend_detach(budget->dvb_frontend);
+ budget->dvb_frontend = NULL;
+ }
+ }
+ break;
}
if (budget->dvb_frontend == NULL) {
@@ -641,6 +724,7 @@ MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC);
MAKE_BUDGET_INFO(ttbs1401, "TT-Budget-S-1401 PCI", BUDGET_TT);
+MAKE_BUDGET_INFO(tt1600, "TT-Budget S2-1600 PCI", BUDGET_TT);
MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY);
MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY);
MAKE_BUDGET_INFO(fsact, "Fujitsu Siemens Activy Budget-T PCI (rev GR/Grundig frontend)", BUDGET_FS_ACTIVY);
@@ -653,6 +737,7 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
MAKE_EXTENSION_PCI(ttbs1401, 0x13c2, 0x1018),
+ MAKE_EXTENSION_PCI(tt1600, 0x13c2, 0x101c),
MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),
MAKE_EXTENSION_PCI(fsact1, 0x1131, 0x5f60),
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 5cf6c45b91fe..49c4aab95dab 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -49,7 +49,6 @@ struct fmi
int io;
int curvol; /* 1 or 0 */
unsigned long curfreq; /* freq in kHz */
- __u32 flags;
struct mutex lock;
};
@@ -57,7 +56,7 @@ static struct fmi fmi_card;
static struct pnp_dev *dev;
/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
-/* It is only useful to give freq in intervall of 800 (=0.05Mhz),
+/* It is only useful to give freq in interval of 800 (=0.05Mhz),
* other bits will be truncated, e.g 92.7400016 -> 92.7, but
* 92.7400017 -> 92.75
*/
@@ -142,7 +141,6 @@ static int vidioc_querycap(struct file *file, void *priv,
static int vidioc_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{
- int mult;
struct fmi *fmi = video_drvdata(file);
if (v->index > 0)
@@ -150,11 +148,10 @@ static int vidioc_g_tuner(struct file *file, void *priv,
strlcpy(v->name, "FM", sizeof(v->name));
v->type = V4L2_TUNER_RADIO;
- mult = (fmi->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
- v->rangelow = RSF16_MINFREQ / mult;
- v->rangehigh = RSF16_MAXFREQ / mult;
+ v->rangelow = RSF16_MINFREQ;
+ v->rangehigh = RSF16_MAXFREQ;
v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
- v->capability = fmi->flags & V4L2_TUNER_CAP_LOW;
+ v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
v->audmode = V4L2_TUNER_MODE_STEREO;
v->signal = fmi_getsigstr(fmi);
return 0;
@@ -171,8 +168,6 @@ static int vidioc_s_frequency(struct file *file, void *priv,
{
struct fmi *fmi = video_drvdata(file);
- if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
- f->frequency *= 1000;
if (f->frequency < RSF16_MINFREQ ||
f->frequency > RSF16_MAXFREQ)
return -EINVAL;
@@ -189,8 +184,6 @@ static int vidioc_g_frequency(struct file *file, void *priv,
f->type = V4L2_TUNER_RADIO;
f->frequency = fmi->curfreq;
- if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
- f->frequency /= 1000;
return 0;
}
@@ -347,7 +340,6 @@ static int __init fmi_init(void)
return res;
}
- fmi->flags = V4L2_TUNER_CAP_LOW;
strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name));
fmi->vdev.v4l2_dev = v4l2_dev;
fmi->vdev.fops = &fmi_fops;
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 935ff9bcdfcc..a11414f648d4 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -61,13 +61,12 @@ struct fmr2
int stereo; /* card is producing stereo audio */
unsigned long curfreq; /* freq in kHz */
int card_type;
- u32 flags;
};
static struct fmr2 fmr2_card;
/* hw precision is 12.5 kHz
- * It is only useful to give freq in intervall of 200 (=0.0125Mhz),
+ * It is only useful to give freq in interval of 200 (=0.0125Mhz),
* other bits will be truncated
*/
#define RSF16_ENCODE(x) ((x) / 200 + 856)
@@ -221,7 +220,6 @@ static int vidioc_querycap(struct file *file, void *priv,
static int vidioc_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{
- int mult;
struct fmr2 *fmr2 = video_drvdata(file);
if (v->index > 0)
@@ -230,13 +228,12 @@ static int vidioc_g_tuner(struct file *file, void *priv,
strlcpy(v->name, "FM", sizeof(v->name));
v->type = V4L2_TUNER_RADIO;
- mult = (fmr2->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
- v->rangelow = RSF16_MINFREQ / mult;
- v->rangehigh = RSF16_MAXFREQ / mult;
- v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
- v->capability = fmr2->flags&V4L2_TUNER_CAP_LOW;
- v->audmode = fmr2->stereo ? V4L2_TUNER_MODE_STEREO:
- V4L2_TUNER_MODE_MONO;
+ v->rangelow = RSF16_MINFREQ;
+ v->rangehigh = RSF16_MAXFREQ;
+ v->rxsubchans = fmr2->stereo ? V4L2_TUNER_SUB_STEREO :
+ V4L2_TUNER_SUB_MONO;
+ v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
+ v->audmode = V4L2_TUNER_MODE_STEREO;
mutex_lock(&fmr2->lock);
v->signal = fmr2_getsigstr(fmr2);
mutex_unlock(&fmr2->lock);
@@ -254,8 +251,6 @@ static int vidioc_s_frequency(struct file *file, void *priv,
{
struct fmr2 *fmr2 = video_drvdata(file);
- if (!(fmr2->flags & V4L2_TUNER_CAP_LOW))
- f->frequency *= 1000;
if (f->frequency < RSF16_MINFREQ ||
f->frequency > RSF16_MAXFREQ)
return -EINVAL;
@@ -279,8 +274,6 @@ static int vidioc_g_frequency(struct file *file, void *priv,
f->type = V4L2_TUNER_RADIO;
f->frequency = fmr2->curfreq;
- if (!(fmr2->flags & V4L2_TUNER_CAP_LOW))
- f->frequency /= 1000;
return 0;
}
@@ -406,7 +399,6 @@ static int __init fmr2_init(void)
strlcpy(v4l2_dev->name, "sf16fmr2", sizeof(v4l2_dev->name));
fmr2->io = io;
fmr2->stereo = 1;
- fmr2->flags = V4L2_TUNER_CAP_LOW;
mutex_init(&fmr2->lock);
if (!request_region(fmr2->io, 2, "sf16fmr2")) {
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
index bd945d04dc90..640421ceb24a 100644
--- a/drivers/media/radio/radio-si470x.c
+++ b/drivers/media/radio/radio-si470x.c
@@ -1214,7 +1214,6 @@ static int si470x_fops_release(struct file *file)
usb_autopm_put_interface(radio->intf);
}
-unlock:
mutex_unlock(&radio->disconnect_lock);
done:
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9d48da2fb013..94f440535c64 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -440,6 +440,24 @@ config VIDEO_ADV7175
To compile this driver as a module, choose M here: the
module will be called adv7175.
+config VIDEO_THS7303
+ tristate "THS7303 Video Amplifier"
+ depends on I2C
+ help
+ Support for TI THS7303 video amplifier
+
+ To compile this driver as a module, choose M here: the
+ module will be called ths7303.
+
+config VIDEO_ADV7343
+ tristate "ADV7343 video encoder"
+ depends on I2C
+ help
+ Support for Analog Devices I2C bus based ADV7343 encoder.
+
+ To compile this driver as a module, choose M here: the
+ module will be called adv7343.
+
comment "Video improvement chips"
config VIDEO_UPD64031A
@@ -694,7 +712,7 @@ config VIDEO_CAFE_CCIC
config SOC_CAMERA
tristate "SoC camera support"
- depends on VIDEO_V4L2 && HAS_DMA
+ depends on VIDEO_V4L2 && HAS_DMA && I2C
select VIDEOBUF_GEN
help
SoC Camera is a common API to several cameras, not connecting
@@ -758,10 +776,14 @@ config VIDEO_MX1
---help---
This is a v4l2 driver for the i.MX1/i.MXL CMOS Sensor Interface
+config MX3_VIDEO
+ bool
+
config VIDEO_MX3
tristate "i.MX3x Camera Sensor Interface driver"
depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
select VIDEOBUF_DMA_CONTIG
+ select MX3_VIDEO
---help---
This is a v4l2 driver for the i.MX3x Camera Sensor Interface
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 3f1a0350a569..f7d9a4c6f450 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -49,11 +49,13 @@ obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o
obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
+obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o
obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o
obj-$(CONFIG_VIDEO_BT819) += bt819.o
obj-$(CONFIG_VIDEO_BT856) += bt856.o
obj-$(CONFIG_VIDEO_BT866) += bt866.o
obj-$(CONFIG_VIDEO_KS0127) += ks0127.o
+obj-$(CONFIG_VIDEO_THS7303) += ths7303.o
obj-$(CONFIG_VIDEO_ZORAN) += zoran/
@@ -134,10 +136,6 @@ obj-$(CONFIG_VIDEO_CX18) += cx18/
obj-$(CONFIG_VIDEO_VIVI) += vivi.o
obj-$(CONFIG_VIDEO_CX23885) += cx23885/
-obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o
-obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
-obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
-obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
obj-$(CONFIG_VIDEO_OMAP2) += omap2cam.o
obj-$(CONFIG_SOC_CAMERA) += soc_camera.o
obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o
@@ -147,6 +145,11 @@ obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o
obj-$(CONFIG_SOC_CAMERA_OV772X) += ov772x.o
obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o
obj-$(CONFIG_SOC_CAMERA_TW9910) += tw9910.o
+# soc-camera host drivers have to be linked after camera drivers
+obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o
+obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
+obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
+obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
obj-$(CONFIG_VIDEO_AU0828) += au0828/
diff --git a/drivers/media/video/adv7343.c b/drivers/media/video/adv7343.c
new file mode 100644
index 000000000000..30f5caf5dda5
--- /dev/null
+++ b/drivers/media/video/adv7343.c
@@ -0,0 +1,534 @@
+/*
+ * adv7343 - ADV7343 Video Encoder Driver
+ *
+ * The encoder hardware does not support SECAM.
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed .as is. WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/ctype.h>
+#include <linux/i2c.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/videodev2.h>
+#include <linux/uaccess.h>
+#include <linux/version.h>
+
+#include <media/adv7343.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+
+#include "adv7343_regs.h"
+
+MODULE_DESCRIPTION("ADV7343 video encoder driver");
+MODULE_LICENSE("GPL");
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Debug level 0-1");
+
+struct adv7343_state {
+ struct v4l2_subdev sd;
+ u8 reg00;
+ u8 reg01;
+ u8 reg02;
+ u8 reg35;
+ u8 reg80;
+ u8 reg82;
+ int bright;
+ int hue;
+ int gain;
+ u32 output;
+ v4l2_std_id std;
+};
+
+static inline struct adv7343_state *to_state(struct v4l2_subdev *sd)
+{
+ return container_of(sd, struct adv7343_state, sd);
+}
+
+static inline int adv7343_write(struct v4l2_subdev *sd, u8 reg, u8 value)
+{
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+ return i2c_smbus_write_byte_data(client, reg, value);
+}
+
+static const u8 adv7343_init_reg_val[] = {
+ ADV7343_SOFT_RESET, ADV7343_SOFT_RESET_DEFAULT,
+ ADV7343_POWER_MODE_REG, ADV7343_POWER_MODE_REG_DEFAULT,
+
+ ADV7343_HD_MODE_REG1, ADV7343_HD_MODE_REG1_DEFAULT,
+ ADV7343_HD_MODE_REG2, ADV7343_HD_MODE_REG2_DEFAULT,
+ ADV7343_HD_MODE_REG3, ADV7343_HD_MODE_REG3_DEFAULT,
+ ADV7343_HD_MODE_REG4, ADV7343_HD_MODE_REG4_DEFAULT,
+ ADV7343_HD_MODE_REG5, ADV7343_HD_MODE_REG5_DEFAULT,
+ ADV7343_HD_MODE_REG6, ADV7343_HD_MODE_REG6_DEFAULT,
+ ADV7343_HD_MODE_REG7, ADV7343_HD_MODE_REG7_DEFAULT,
+
+ ADV7343_SD_MODE_REG1, ADV7343_SD_MODE_REG1_DEFAULT,
+ ADV7343_SD_MODE_REG2, ADV7343_SD_MODE_REG2_DEFAULT,
+ ADV7343_SD_MODE_REG3, ADV7343_SD_MODE_REG3_DEFAULT,
+ ADV7343_SD_MODE_REG4, ADV7343_SD_MODE_REG4_DEFAULT,
+ ADV7343_SD_MODE_REG5, ADV7343_SD_MODE_REG5_DEFAULT,
+ ADV7343_SD_MODE_REG6, ADV7343_SD_MODE_REG6_DEFAULT,
+ ADV7343_SD_MODE_REG7, ADV7343_SD_MODE_REG7_DEFAULT,
+ ADV7343_SD_MODE_REG8, ADV7343_SD_MODE_REG8_DEFAULT,
+
+ ADV7343_SD_HUE_REG, ADV7343_SD_HUE_REG_DEFAULT,
+ ADV7343_SD_CGMS_WSS0, ADV7343_SD_CGMS_WSS0_DEFAULT,
+ ADV7343_SD_BRIGHTNESS_WSS, ADV7343_SD_BRIGHTNESS_WSS_DEFAULT,
+};
+
+/*
+ * 2^32
+ * FSC(reg) = FSC (HZ) * --------
+ * 27000000
+ */
+static const struct adv7343_std_info stdinfo[] = {
+ {
+ /* FSC(Hz) = 3,579,545.45 Hz */
+ SD_STD_NTSC, 569408542, V4L2_STD_NTSC,
+ }, {
+ /* FSC(Hz) = 3,575,611.00 Hz */
+ SD_STD_PAL_M, 568782678, V4L2_STD_PAL_M,
+ }, {
+ /* FSC(Hz) = 3,582,056.00 */
+ SD_STD_PAL_N, 569807903, V4L2_STD_PAL_Nc,
+ }, {
+ /* FSC(Hz) = 4,433,618.75 Hz */
+ SD_STD_PAL_N, 705268427, V4L2_STD_PAL_N,
+ }, {
+ /* FSC(Hz) = 4,433,618.75 Hz */
+ SD_STD_PAL_BDGHI, 705268427, V4L2_STD_PAL,
+ }, {
+ /* FSC(Hz) = 4,433,618.75 Hz */
+ SD_STD_NTSC, 705268427, V4L2_STD_NTSC_443,
+ }, {
+ /* FSC(Hz) = 4,433,618.75 Hz */
+ SD_STD_PAL_M, 705268427, V4L2_STD_PAL_60,
+ },
+};
+
+static int adv7343_setstd(struct v4l2_subdev *sd, v4l2_std_id std)
+{
+ struct adv7343_state *state = to_state(sd);
+ struct adv7343_std_info *std_info;
+ int output_idx, num_std;
+ char *fsc_ptr;
+ u8 reg, val;
+ int err = 0;
+ int i = 0;
+
+ output_idx = state->output;
+
+ std_info = (struct adv7343_std_info *)stdinfo;
+ num_std = ARRAY_SIZE(stdinfo);
+
+ for (i = 0; i < num_std; i++) {
+ if (std_info[i].stdid & std)
+ break;
+ }
+
+ if (i == num_std) {
+ v4l2_dbg(1, debug, sd,
+ "Invalid std or std is not supported: %llx\n",
+ (unsigned long long)std);
+ return -EINVAL;
+ }
+
+ /* Set the standard */
+ val = state->reg80 & (~(SD_STD_MASK));
+ val |= std_info[i].standard_val3;
+ err = adv7343_write(sd, ADV7343_SD_MODE_REG1, val);
+ if (err < 0)
+ goto setstd_exit;
+
+ state->reg80 = val;
+
+ /* Configure the input mode register */
+ val = state->reg01 & (~((u8) INPUT_MODE_MASK));
+ val |= SD_INPUT_MODE;
+ err = adv7343_write(sd, ADV7343_MODE_SELECT_REG, val);
+ if (err < 0)
+ goto setstd_exit;
+
+ state->reg01 = val;
+
+ /* Program the sub carrier frequency registers */
+ fsc_ptr = (unsigned char *)&std_info[i].fsc_val;
+ reg = ADV7343_FSC_REG0;
+ for (i = 0; i < 4; i++, reg++, fsc_ptr++) {
+ err = adv7343_write(sd, reg, *fsc_ptr);
+ if (err < 0)
+ goto setstd_exit;
+ }
+
+ val = state->reg80;
+
+ /* Filter settings */
+ if (std & (V4L2_STD_NTSC | V4L2_STD_NTSC_443))
+ val &= 0x03;
+ else if (std & ~V4L2_STD_SECAM)
+ val |= 0x04;
+
+ err = adv7343_write(sd, ADV7343_SD_MODE_REG1, val);
+ if (err < 0)
+ goto setstd_exit;
+
+ state->reg80 = val;
+
+setstd_exit:
+ if (err != 0)
+ v4l2_err(sd, "Error setting std, write failed\n");
+
+ return err;
+}
+
+static int adv7343_setoutput(struct v4l2_subdev *sd, u32 output_type)
+{
+ struct adv7343_state *state = to_state(sd);
+ unsigned char val;
+ int err = 0;
+
+ if (output_type > ADV7343_SVIDEO_ID) {
+ v4l2_dbg(1, debug, sd,
+ "Invalid output type or output type not supported:%d\n",
+ output_type);
+ return -EINVAL;
+ }
+
+ /* Enable Appropriate DAC */
+ val = state->reg00 & 0x03;
+
+ if (output_type == ADV7343_COMPOSITE_ID)
+ val |= ADV7343_COMPOSITE_POWER_VALUE;
+ else if (output_type == ADV7343_COMPONENT_ID)
+ val |= ADV7343_COMPONENT_POWER_VALUE;
+ else
+ val |= ADV7343_SVIDEO_POWER_VALUE;
+
+ err = adv7343_write(sd, ADV7343_POWER_MODE_REG, val);
+ if (err < 0)
+ goto setoutput_exit;
+
+ state->reg00 = val;
+
+ /* Enable YUV output */
+ val = state->reg02 | YUV_OUTPUT_SELECT;
+ err = adv7343_write(sd, ADV7343_MODE_REG0, val);
+ if (err < 0)
+ goto setoutput_exit;
+
+ state->reg02 = val;
+
+ /* configure SD DAC Output 2 and SD DAC Output 1 bit to zero */
+ val = state->reg82 & (SD_DAC_1_DI & SD_DAC_2_DI);
+ err = adv7343_write(sd, ADV7343_SD_MODE_REG2, val);
+ if (err < 0)
+ goto setoutput_exit;
+
+ state->reg82 = val;
+
+ /* configure ED/HD Color DAC Swap and ED/HD RGB Input Enable bit to
+ * zero */
+ val = state->reg35 & (HD_RGB_INPUT_DI & HD_DAC_SWAP_DI);
+ err = adv7343_write(sd, ADV7343_HD_MODE_REG6, val);
+ if (err < 0)
+ goto setoutput_exit;
+
+ state->reg35 = val;
+
+setoutput_exit:
+ if (err != 0)
+ v4l2_err(sd, "Error setting output, write failed\n");
+
+ return err;
+}
+
+static int adv7343_log_status(struct v4l2_subdev *sd)
+{
+ struct adv7343_state *state = to_state(sd);
+
+ v4l2_info(sd, "Standard: %llx\n", (unsigned long long)state->std);
+ v4l2_info(sd, "Output: %s\n", (state->output == 0) ? "Composite" :
+ ((state->output == 1) ? "Component" : "S-Video"));
+ return 0;
+}
+
+static int adv7343_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
+{
+ switch (qc->id) {
+ case V4L2_CID_BRIGHTNESS:
+ return v4l2_ctrl_query_fill(qc, ADV7343_BRIGHTNESS_MIN,
+ ADV7343_BRIGHTNESS_MAX, 1,
+ ADV7343_BRIGHTNESS_DEF);
+ case V4L2_CID_HUE:
+ return v4l2_ctrl_query_fill(qc, ADV7343_HUE_MIN,
+ ADV7343_HUE_MAX, 1 ,
+ ADV7343_HUE_DEF);
+ case V4L2_CID_GAIN:
+ return v4l2_ctrl_query_fill(qc, ADV7343_GAIN_MIN,
+ ADV7343_GAIN_MAX, 1,
+ ADV7343_GAIN_DEF);
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int adv7343_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+ struct adv7343_state *state = to_state(sd);
+ int err = 0;
+
+ switch (ctrl->id) {
+ case V4L2_CID_BRIGHTNESS:
+ if (ctrl->value < ADV7343_BRIGHTNESS_MIN ||
+ ctrl->value > ADV7343_BRIGHTNESS_MAX) {
+ v4l2_dbg(1, debug, sd,
+ "invalid brightness settings %d\n",
+ ctrl->value);
+ return -ERANGE;
+ }
+
+ state->bright = ctrl->value;
+ err = adv7343_write(sd, ADV7343_SD_BRIGHTNESS_WSS,
+ state->bright);
+ break;
+
+ case V4L2_CID_HUE:
+ if (ctrl->value < ADV7343_HUE_MIN ||
+ ctrl->value > ADV7343_HUE_MAX) {
+ v4l2_dbg(1, debug, sd, "invalid hue settings %d\n",
+ ctrl->value);
+ return -ERANGE;
+ }
+
+ state->hue = ctrl->value;
+ err = adv7343_write(sd, ADV7343_SD_HUE_REG, state->hue);
+ break;
+
+ case V4L2_CID_GAIN:
+ if (ctrl->value < ADV7343_GAIN_MIN ||
+ ctrl->value > ADV7343_GAIN_MAX) {
+ v4l2_dbg(1, debug, sd, "invalid gain settings %d\n",
+ ctrl->value);
+ return -ERANGE;
+ }
+
+ if ((ctrl->value > POSITIVE_GAIN_MAX) &&
+ (ctrl->value < NEGATIVE_GAIN_MIN)) {
+ v4l2_dbg(1, debug, sd,
+ "gain settings not within the specified range\n");
+ return -ERANGE;
+ }
+
+ state->gain = ctrl->value;
+ err = adv7343_write(sd, ADV7343_DAC2_OUTPUT_LEVEL, state->gain);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ if (err < 0)
+ v4l2_err(sd, "Failed to set the encoder controls\n");
+
+ return err;
+}
+
+static int adv7343_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+ struct adv7343_state *state = to_state(sd);
+
+ switch (ctrl->id) {
+ case V4L2_CID_BRIGHTNESS:
+ ctrl->value = state->bright;
+ break;
+
+ case V4L2_CID_HUE:
+ ctrl->value = state->hue;
+ break;
+
+ case V4L2_CID_GAIN:
+ ctrl->value = state->gain;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int adv7343_g_chip_ident(struct v4l2_subdev *sd,
+ struct v4l2_dbg_chip_ident *chip)
+{
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+ return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7343, 0);
+}
+
+static const struct v4l2_subdev_core_ops adv7343_core_ops = {
+ .log_status = adv7343_log_status,
+ .g_chip_ident = adv7343_g_chip_ident,
+ .g_ctrl = adv7343_g_ctrl,
+ .s_ctrl = adv7343_s_ctrl,
+ .queryctrl = adv7343_queryctrl,
+};
+
+static int adv7343_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
+{
+ struct adv7343_state *state = to_state(sd);
+ int err = 0;
+
+ if (state->std == std)
+ return 0;
+
+ err = adv7343_setstd(sd, std);
+ if (!err)
+ state->std = std;
+
+ return err;
+}
+
+static int adv7343_s_routing(struct v4l2_subdev *sd,
+ u32 input, u32 output, u32 config)
+{
+ struct adv7343_state *state = to_state(sd);
+ int err = 0;
+
+ if (state->output == output)
+ return 0;
+
+ err = adv7343_setoutput(sd, output);
+ if (!err)
+ state->output = output;
+
+ return err;
+}
+
+static const struct v4l2_subdev_video_ops adv7343_video_ops = {
+ .s_std_output = adv7343_s_std_output,
+ .s_routing = adv7343_s_routing,
+};
+
+static const struct v4l2_subdev_ops adv7343_ops = {
+ .core = &adv7343_core_ops,
+ .video = &adv7343_video_ops,
+};
+
+static int adv7343_initialize(struct v4l2_subdev *sd)
+{
+ struct adv7343_state *state = to_state(sd);
+ int err = 0;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(adv7343_init_reg_val); i += 2) {
+
+ err = adv7343_write(sd, adv7343_init_reg_val[i],
+ adv7343_init_reg_val[i+1]);
+ if (err) {
+ v4l2_err(sd, "Error initializing\n");
+ return err;
+ }
+ }
+
+ /* Configure for default video standard */
+ err = adv7343_setoutput(sd, state->output);
+ if (err < 0) {
+ v4l2_err(sd, "Error setting output during init\n");
+ return -EINVAL;
+ }
+
+ err = adv7343_setstd(sd, state->std);
+ if (err < 0) {
+ v4l2_err(sd, "Error setting std during init\n");
+ return -EINVAL;
+ }
+
+ return err;
+}
+
+static int adv7343_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct adv7343_state *state;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+ return -ENODEV;
+
+ v4l_info(client, "chip found @ 0x%x (%s)\n",
+ client->addr << 1, client->adapter->name);
+
+ state = kzalloc(sizeof(struct adv7343_state), GFP_KERNEL);
+ if (state == NULL)
+ return -ENOMEM;
+
+ state->reg00 = 0x80;
+ state->reg01 = 0x00;
+ state->reg02 = 0x20;
+ state->reg35 = 0x00;
+ state->reg80 = ADV7343_SD_MODE_REG1_DEFAULT;
+ state->reg82 = ADV7343_SD_MODE_REG2_DEFAULT;
+
+ state->output = ADV7343_COMPOSITE_ID;
+ state->std = V4L2_STD_NTSC;
+
+ v4l2_i2c_subdev_init(&state->sd, client, &adv7343_ops);
+ return adv7343_initialize(&state->sd);
+}
+
+static int adv7343_remove(struct i2c_client *client)
+{
+ struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+ v4l2_device_unregister_subdev(sd);
+ kfree(to_state(sd));
+
+ return 0;
+}
+
+static const struct i2c_device_id adv7343_id[] = {
+ {"adv7343", 0},
+ {},
+};
+
+MODULE_DEVICE_TABLE(i2c, adv7343_id);
+
+static struct i2c_driver adv7343_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "adv7343",
+ },
+ .probe = adv7343_probe,
+ .remove = adv7343_remove,
+ .id_table = adv7343_id,
+};
+
+static __init int init_adv7343(void)
+{
+ return i2c_add_driver(&adv7343_driver);
+}
+
+static __exit void exit_adv7343(void)
+{
+ i2c_del_driver(&adv7343_driver);
+}
+
+module_init(init_adv7343);
+module_exit(exit_adv7343);
diff --git a/drivers/media/video/adv7343_regs.h b/drivers/media/video/adv7343_regs.h
new file mode 100644
index 000000000000..3431045b33da
--- /dev/null
+++ b/drivers/media/video/adv7343_regs.h
@@ -0,0 +1,185 @@
+/*
+ * ADV7343 encoder related structure and register definitions
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed .as is. WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef ADV7343_REG_H
+#define ADV7343_REGS_H
+
+struct adv7343_std_info {
+ u32 standard_val3;
+ u32 fsc_val;
+ v4l2_std_id stdid;
+};
+
+/* Register offset macros */
+#define ADV7343_POWER_MODE_REG (0x00)
+#define ADV7343_MODE_SELECT_REG (0x01)
+#define ADV7343_MODE_REG0 (0x02)
+
+#define ADV7343_DAC2_OUTPUT_LEVEL (0x0b)
+
+#define ADV7343_SOFT_RESET (0x17)
+
+#define ADV7343_HD_MODE_REG1 (0x30)
+#define ADV7343_HD_MODE_REG2 (0x31)
+#define ADV7343_HD_MODE_REG3 (0x32)
+#define ADV7343_HD_MODE_REG4 (0x33)
+#define ADV7343_HD_MODE_REG5 (0x34)
+#define ADV7343_HD_MODE_REG6 (0x35)
+
+#define ADV7343_HD_MODE_REG7 (0x39)
+
+#define ADV7343_SD_MODE_REG1 (0x80)
+#define ADV7343_SD_MODE_REG2 (0x82)
+#define ADV7343_SD_MODE_REG3 (0x83)
+#define ADV7343_SD_MODE_REG4 (0x84)
+#define ADV7343_SD_MODE_REG5 (0x86)
+#define ADV7343_SD_MODE_REG6 (0x87)
+#define ADV7343_SD_MODE_REG7 (0x88)
+#define ADV7343_SD_MODE_REG8 (0x89)
+
+#define ADV7343_FSC_REG0 (0x8C)
+#define ADV7343_FSC_REG1 (0x8D)
+#define ADV7343_FSC_REG2 (0x8E)
+#define ADV7343_FSC_REG3 (0x8F)
+
+#define ADV7343_SD_CGMS_WSS0 (0x99)
+
+#define ADV7343_SD_HUE_REG (0xA0)
+#define ADV7343_SD_BRIGHTNESS_WSS (0xA1)
+
+/* Default values for the registers */
+#define ADV7343_POWER_MODE_REG_DEFAULT (0x10)
+#define ADV7343_HD_MODE_REG1_DEFAULT (0x3C) /* Changed Default
+ 720p EAVSAV code*/
+#define ADV7343_HD_MODE_REG2_DEFAULT (0x01) /* Changed Pixel data
+ valid */
+#define ADV7343_HD_MODE_REG3_DEFAULT (0x00) /* Color delay 0 clks */
+#define ADV7343_HD_MODE_REG4_DEFAULT (0xE8) /* Changed */
+#define ADV7343_HD_MODE_REG5_DEFAULT (0x08)
+#define ADV7343_HD_MODE_REG6_DEFAULT (0x00)
+#define ADV7343_HD_MODE_REG7_DEFAULT (0x00)
+#define ADV7343_SD_MODE_REG8_DEFAULT (0x00)
+#define ADV7343_SOFT_RESET_DEFAULT (0x02)
+#define ADV7343_COMPOSITE_POWER_VALUE (0x80)
+#define ADV7343_COMPONENT_POWER_VALUE (0x1C)
+#define ADV7343_SVIDEO_POWER_VALUE (0x60)
+#define ADV7343_SD_HUE_REG_DEFAULT (127)
+#define ADV7343_SD_BRIGHTNESS_WSS_DEFAULT (0x03)
+
+#define ADV7343_SD_CGMS_WSS0_DEFAULT (0x10)
+
+#define ADV7343_SD_MODE_REG1_DEFAULT (0x00)
+#define ADV7343_SD_MODE_REG2_DEFAULT (0xC9)
+#define ADV7343_SD_MODE_REG3_DEFAULT (0x10)
+#define ADV7343_SD_MODE_REG4_DEFAULT (0x01)
+#define ADV7343_SD_MODE_REG5_DEFAULT (0x02)
+#define ADV7343_SD_MODE_REG6_DEFAULT (0x0C)
+#define ADV7343_SD_MODE_REG7_DEFAULT (0x04)
+#define ADV7343_SD_MODE_REG8_DEFAULT (0x00)
+
+/* Bit masks for Mode Select Register */
+#define INPUT_MODE_MASK (0x70)
+#define SD_INPUT_MODE (0x00)
+#define HD_720P_INPUT_MODE (0x10)
+#define HD_1080I_INPUT_MODE (0x10)
+
+/* Bit masks for Mode Register 0 */
+#define TEST_PATTERN_BLACK_BAR_EN (0x04)
+#define YUV_OUTPUT_SELECT (0x20)
+#define RGB_OUTPUT_SELECT (0xDF)
+
+/* Bit masks for DAC output levels */
+#define DAC_OUTPUT_LEVEL_MASK (0xFF)
+#define POSITIVE_GAIN_MAX (0x40)
+#define POSITIVE_GAIN_MIN (0x00)
+#define NEGATIVE_GAIN_MAX (0xFF)
+#define NEGATIVE_GAIN_MIN (0xC0)
+
+/* Bit masks for soft reset register */
+#define SOFT_RESET (0x02)
+
+/* Bit masks for HD Mode Register 1 */
+#define OUTPUT_STD_MASK (0x03)
+#define OUTPUT_STD_SHIFT (0)
+#define OUTPUT_STD_EIA0_2 (0x00)
+#define OUTPUT_STD_EIA0_1 (0x01)
+#define OUTPUT_STD_FULL (0x02)
+#define EMBEDDED_SYNC (0x04)
+#define EXTERNAL_SYNC (0xFB)
+#define STD_MODE_SHIFT (3)
+#define STD_MODE_MASK (0x1F)
+#define STD_MODE_720P (0x05)
+#define STD_MODE_720P_25 (0x08)
+#define STD_MODE_720P_30 (0x07)
+#define STD_MODE_720P_50 (0x06)
+#define STD_MODE_1080I (0x0D)
+#define STD_MODE_1080I_25fps (0x0E)
+#define STD_MODE_1080P_24 (0x12)
+#define STD_MODE_1080P_25 (0x10)
+#define STD_MODE_1080P_30 (0x0F)
+#define STD_MODE_525P (0x00)
+#define STD_MODE_625P (0x03)
+
+/* Bit masks for SD Mode Register 1 */
+#define SD_STD_MASK (0x03)
+#define SD_STD_NTSC (0x00)
+#define SD_STD_PAL_BDGHI (0x01)
+#define SD_STD_PAL_M (0x02)
+#define SD_STD_PAL_N (0x03)
+#define SD_LUMA_FLTR_MASK (0x7)
+#define SD_LUMA_FLTR_SHIFT (0x2)
+#define SD_CHROMA_FLTR_MASK (0x7)
+#define SD_CHROMA_FLTR_SHIFT (0x5)
+
+/* Bit masks for SD Mode Register 2 */
+#define SD_PBPR_SSAF_EN (0x01)
+#define SD_PBPR_SSAF_DI (0xFE)
+#define SD_DAC_1_DI (0xFD)
+#define SD_DAC_2_DI (0xFB)
+#define SD_PEDESTAL_EN (0x08)
+#define SD_PEDESTAL_DI (0xF7)
+#define SD_SQUARE_PIXEL_EN (0x10)
+#define SD_SQUARE_PIXEL_DI (0xEF)
+#define SD_PIXEL_DATA_VALID (0x40)
+#define SD_ACTIVE_EDGE_EN (0x80)
+#define SD_ACTIVE_EDGE_DI (0x7F)
+
+/* Bit masks for HD Mode Register 6 */
+#define HD_RGB_INPUT_EN (0x02)
+#define HD_RGB_INPUT_DI (0xFD)
+#define HD_PBPR_SYNC_EN (0x04)
+#define HD_PBPR_SYNC_DI (0xFB)
+#define HD_DAC_SWAP_EN (0x08)
+#define HD_DAC_SWAP_DI (0xF7)
+#define HD_GAMMA_CURVE_A (0xEF)
+#define HD_GAMMA_CURVE_B (0x10)
+#define HD_GAMMA_EN (0x20)
+#define HD_GAMMA_DI (0xDF)
+#define HD_ADPT_FLTR_MODEB (0x40)
+#define HD_ADPT_FLTR_MODEA (0xBF)
+#define HD_ADPT_FLTR_EN (0x80)
+#define HD_ADPT_FLTR_DI (0x7F)
+
+#define ADV7343_BRIGHTNESS_MAX (127)
+#define ADV7343_BRIGHTNESS_MIN (0)
+#define ADV7343_BRIGHTNESS_DEF (3)
+#define ADV7343_HUE_MAX (255)
+#define ADV7343_HUE_MIN (0)
+#define ADV7343_HUE_DEF (127)
+#define ADV7343_GAIN_MAX (255)
+#define ADV7343_GAIN_MIN (0)
+#define ADV7343_GAIN_DEF (0)
+
+#endif
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index d4099f5312ac..0b4a8f309cfa 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -1064,7 +1064,7 @@ static int ioctl_querymenu(void *arg,struct camera_data *cam)
switch(m->id) {
case CPIA2_CID_FLICKER_MODE:
- if(m->index < 0 || m->index >= NUM_FLICKER_CONTROLS)
+ if (m->index >= NUM_FLICKER_CONTROLS)
return -EINVAL;
strcpy(m->name, flicker_controls[m->index].name);
@@ -1082,14 +1082,14 @@ static int ioctl_querymenu(void *arg,struct camera_data *cam)
maximum = i;
}
}
- if(m->index < 0 || m->index > maximum)
+ if (m->index > maximum)
return -EINVAL;
strcpy(m->name, framerate_controls[m->index].name);
break;
}
case CPIA2_CID_LIGHTS:
- if(m->index < 0 || m->index >= NUM_LIGHTS_CONTROLS)
+ if (m->index >= NUM_LIGHTS_CONTROLS)
return -EINVAL;
strcpy(m->name, lights_controls[m->index].name);
diff --git a/drivers/media/video/cx18/cx18-audio.c b/drivers/media/video/cx18/cx18-audio.c
index 7a8ad5963de8..35268923911c 100644
--- a/drivers/media/video/cx18/cx18-audio.c
+++ b/drivers/media/video/cx18/cx18-audio.c
@@ -26,14 +26,18 @@
#include "cx18-cards.h"
#include "cx18-audio.h"
-#define CX18_AUDIO_ENABLE 0xc72014
+#define CX18_AUDIO_ENABLE 0xc72014
+#define CX18_AI1_MUX_MASK 0x30
+#define CX18_AI1_MUX_I2S1 0x00
+#define CX18_AI1_MUX_I2S2 0x10
+#define CX18_AI1_MUX_843_I2S 0x20
/* Selects the audio input and output according to the current
settings. */
int cx18_audio_set_io(struct cx18 *cx)
{
const struct cx18_card_audio_input *in;
- u32 val;
+ u32 u, v;
int err;
/* Determine which input to use */
@@ -52,9 +56,37 @@ int cx18_audio_set_io(struct cx18 *cx)
return err;
/* FIXME - this internal mux should be abstracted to a subdev */
- val = cx18_read_reg(cx, CX18_AUDIO_ENABLE) & ~0x30;
- val |= (in->audio_input > CX18_AV_AUDIO_SERIAL2) ? 0x20 :
- (in->audio_input << 4);
- cx18_write_reg_expect(cx, val | 0xb00, CX18_AUDIO_ENABLE, val, 0x30);
+ u = cx18_read_reg(cx, CX18_AUDIO_ENABLE);
+ v = u & ~CX18_AI1_MUX_MASK;
+ switch (in->audio_input) {
+ case CX18_AV_AUDIO_SERIAL1:
+ v |= CX18_AI1_MUX_I2S1;
+ break;
+ case CX18_AV_AUDIO_SERIAL2:
+ v |= CX18_AI1_MUX_I2S2;
+ break;
+ default:
+ v |= CX18_AI1_MUX_843_I2S;
+ break;
+ }
+ if (v == u) {
+ /* force a toggle of some AI1 MUX control bits */
+ u &= ~CX18_AI1_MUX_MASK;
+ switch (in->audio_input) {
+ case CX18_AV_AUDIO_SERIAL1:
+ u |= CX18_AI1_MUX_843_I2S;
+ break;
+ case CX18_AV_AUDIO_SERIAL2:
+ u |= CX18_AI1_MUX_843_I2S;
+ break;
+ default:
+ u |= CX18_AI1_MUX_I2S1;
+ break;
+ }
+ cx18_write_reg_expect(cx, u | 0xb00, CX18_AUDIO_ENABLE,
+ u, CX18_AI1_MUX_MASK);
+ }
+ cx18_write_reg_expect(cx, v | 0xb00, CX18_AUDIO_ENABLE,
+ v, CX18_AI1_MUX_MASK);
return 0;
}
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c
index cf2bd888a429..2b07b156340b 100644
--- a/drivers/media/video/cx18/cx18-av-core.c
+++ b/drivers/media/video/cx18/cx18-av-core.c
@@ -99,9 +99,39 @@ int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 and_mask,
or_value);
}
-static void cx18_av_initialize(struct cx18 *cx)
+static int cx18_av_init(struct v4l2_subdev *sd, u32 val)
{
- struct cx18_av_state *state = &cx->av_state;
+ struct cx18 *cx = v4l2_get_subdevdata(sd);
+
+ /*
+ * The crystal freq used in calculations in this driver will be
+ * 28.636360 MHz.
+ * Aim to run the PLLs' VCOs near 400 MHz to minimze errors.
+ */
+
+ /*
+ * VDCLK Integer = 0x0f, Post Divider = 0x04
+ * AIMCLK Integer = 0x0e, Post Divider = 0x16
+ */
+ cx18_av_write4(cx, CXADEC_PLL_CTRL1, 0x160e040f);
+
+ /* VDCLK Fraction = 0x2be2fe */
+ /* xtal * 0xf.15f17f0/4 = 108 MHz: 432 MHz before post divide */
+ cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, 0x002be2fe);
+
+ /* AIMCLK Fraction = 0x05227ad */
+ /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/
+ cx18_av_write4(cx, CXADEC_AUX_PLL_FRAC, 0x005227ad);
+
+ /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x16 */
+ cx18_av_write(cx, CXADEC_I2S_MCLK, 0x56);
+ return 0;
+}
+
+static void cx18_av_initialize(struct v4l2_subdev *sd)
+{
+ struct cx18_av_state *state = to_cx18_av_state(sd);
+ struct cx18 *cx = v4l2_get_subdevdata(sd);
u32 v;
cx18_av_loadfw(cx);
@@ -150,6 +180,26 @@ static void cx18_av_initialize(struct cx18 *cx)
cx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0x8000);
cx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0);
+ /*
+ * Disable Video Auto-config of the Analog Front End and Video PLL.
+ *
+ * Since we only use BT.656 pixel mode, which works for both 525 and 625
+ * line systems, it's just easier for us to set registers
+ * 0x102 (CXADEC_CHIP_CTRL), 0x104-0x106 (CXADEC_AFE_CTRL),
+ * 0x108-0x109 (CXADEC_PLL_CTRL1), and 0x10c-0x10f (CXADEC_VID_PLL_FRAC)
+ * ourselves, than to run around cleaning up after the auto-config.
+ *
+ * (Note: my CX23418 chip doesn't seem to let the ACFG_DIS bit
+ * get set to 1, but OTOH, it doesn't seem to do AFE and VID PLL
+ * autoconfig either.)
+ *
+ * As a default, also turn off Dual mode for ADC2 and set ADC2 to CH3.
+ */
+ cx18_av_and_or4(cx, CXADEC_CHIP_CTRL, 0xFFFBFFFF, 0x00120000);
+
+ /* Setup the Video and and Aux/Audio PLLs */
+ cx18_av_init(sd, 0);
+
/* set video to auto-detect */
/* Clear bits 11-12 to enable slow locking mode. Set autodetect mode */
/* set the comb notch = 1 */
@@ -176,12 +226,23 @@ static void cx18_av_initialize(struct cx18 *cx)
/* EncSetSignalStd(dwDevNum, pEnc->dwSigStd); */
/* EncSetVideoInput(dwDevNum, pEnc->VidIndSelection); */
- v = cx18_av_read4(cx, CXADEC_AFE_CTRL);
- v &= 0xFFFBFFFF; /* turn OFF bit 18 for droop_comp_ch1 */
- v &= 0xFFFF7FFF; /* turn OFF bit 9 for clamp_sel_ch1 */
- v &= 0xFFFFFFFE; /* turn OFF bit 0 for 12db_ch1 */
- /* v |= 0x00000001;*/ /* turn ON bit 0 for 12db_ch1 */
- cx18_av_write4(cx, CXADEC_AFE_CTRL, v);
+ /*
+ * Analog Front End (AFE)
+ * Default to luma on ch1/ADC1, chroma on ch2/ADC2, SIF on ch3/ADC2
+ * bypass_ch[1-3] use filter
+ * droop_comp_ch[1-3] disable
+ * clamp_en_ch[1-3] disable
+ * aud_in_sel ADC2
+ * luma_in_sel ADC1
+ * chroma_in_sel ADC2
+ * clamp_sel_ch[2-3] midcode
+ * clamp_sel_ch1 video decoder
+ * vga_sel_ch3 audio decoder
+ * vga_sel_ch[1-2] video decoder
+ * half_bw_ch[1-3] disable
+ * +12db_ch[1-3] disable
+ */
+ cx18_av_and_or4(cx, CXADEC_AFE_CTRL, 0xFF000000, 0x00005D00);
/* if(dwEnable && dw3DCombAvailable) { */
/* CxDevWrReg(CXADEC_SRC_COMB_CFG, 0x7728021F); */
@@ -195,50 +256,18 @@ static void cx18_av_initialize(struct cx18 *cx)
static int cx18_av_reset(struct v4l2_subdev *sd, u32 val)
{
- struct cx18 *cx = v4l2_get_subdevdata(sd);
-
- cx18_av_initialize(cx);
- return 0;
-}
-
-static int cx18_av_init(struct v4l2_subdev *sd, u32 val)
-{
- struct cx18 *cx = v4l2_get_subdevdata(sd);
-
- /*
- * The crystal freq used in calculations in this driver will be
- * 28.636360 MHz.
- * Aim to run the PLLs' VCOs near 400 MHz to minimze errors.
- */
-
- /*
- * VDCLK Integer = 0x0f, Post Divider = 0x04
- * AIMCLK Integer = 0x0e, Post Divider = 0x16
- */
- cx18_av_write4(cx, CXADEC_PLL_CTRL1, 0x160e040f);
-
- /* VDCLK Fraction = 0x2be2fe */
- /* xtal * 0xf.15f17f0/4 = 108 MHz: 432 MHz before post divide */
- cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, 0x002be2fe);
-
- /* AIMCLK Fraction = 0x05227ad */
- /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/
- cx18_av_write4(cx, CXADEC_AUX_PLL_FRAC, 0x005227ad);
-
- /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x16 */
- cx18_av_write(cx, CXADEC_I2S_MCLK, 0x56);
+ cx18_av_initialize(sd);
return 0;
}
static int cx18_av_load_fw(struct v4l2_subdev *sd)
{
struct cx18_av_state *state = to_cx18_av_state(sd);
- struct cx18 *cx = v4l2_get_subdevdata(sd);
if (!state->is_initialized) {
/* initialize on first use */
state->is_initialized = 1;
- cx18_av_initialize(cx);
+ cx18_av_initialize(sd);
}
return 0;
}
@@ -470,16 +499,23 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
{
struct cx18_av_state *state = &cx->av_state;
struct v4l2_subdev *sd = &state->sd;
- u8 is_composite = (vid_input >= CX18_AV_COMPOSITE1 &&
- vid_input <= CX18_AV_COMPOSITE8);
- u8 reg;
- u8 v;
+
+ enum analog_signal_type {
+ NONE, CVBS, Y, C, SIF, Pb, Pr
+ } ch[3] = {NONE, NONE, NONE};
+
+ u8 afe_mux_cfg;
+ u8 adc2_cfg;
+ u32 afe_cfg;
+ int i;
CX18_DEBUG_INFO_DEV(sd, "decoder set video input %d, audio input %d\n",
vid_input, aud_input);
- if (is_composite) {
- reg = 0xf0 + (vid_input - CX18_AV_COMPOSITE1);
+ if (vid_input >= CX18_AV_COMPOSITE1 &&
+ vid_input <= CX18_AV_COMPOSITE8) {
+ afe_mux_cfg = 0xf0 + (vid_input - CX18_AV_COMPOSITE1);
+ ch[0] = CVBS;
} else {
int luma = vid_input & 0xf0;
int chroma = vid_input & 0xf00;
@@ -493,26 +529,45 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
vid_input);
return -EINVAL;
}
- reg = 0xf0 + ((luma - CX18_AV_SVIDEO_LUMA1) >> 4);
+ afe_mux_cfg = 0xf0 + ((luma - CX18_AV_SVIDEO_LUMA1) >> 4);
+ ch[0] = Y;
if (chroma >= CX18_AV_SVIDEO_CHROMA7) {
- reg &= 0x3f;
- reg |= (chroma - CX18_AV_SVIDEO_CHROMA7) >> 2;
+ afe_mux_cfg &= 0x3f;
+ afe_mux_cfg |= (chroma - CX18_AV_SVIDEO_CHROMA7) >> 2;
+ ch[2] = C;
} else {
- reg &= 0xcf;
- reg |= (chroma - CX18_AV_SVIDEO_CHROMA4) >> 4;
+ afe_mux_cfg &= 0xcf;
+ afe_mux_cfg |= (chroma - CX18_AV_SVIDEO_CHROMA4) >> 4;
+ ch[1] = C;
}
}
+ /* TODO: LeadTek WinFast DVR3100 H & WinFast PVR2100 can do Y/Pb/Pr */
switch (aud_input) {
case CX18_AV_AUDIO_SERIAL1:
case CX18_AV_AUDIO_SERIAL2:
/* do nothing, use serial audio input */
break;
- case CX18_AV_AUDIO4: reg &= ~0x30; break;
- case CX18_AV_AUDIO5: reg &= ~0x30; reg |= 0x10; break;
- case CX18_AV_AUDIO6: reg &= ~0x30; reg |= 0x20; break;
- case CX18_AV_AUDIO7: reg &= ~0xc0; break;
- case CX18_AV_AUDIO8: reg &= ~0xc0; reg |= 0x40; break;
+ case CX18_AV_AUDIO4:
+ afe_mux_cfg &= ~0x30;
+ ch[1] = SIF;
+ break;
+ case CX18_AV_AUDIO5:
+ afe_mux_cfg = (afe_mux_cfg & ~0x30) | 0x10;
+ ch[1] = SIF;
+ break;
+ case CX18_AV_AUDIO6:
+ afe_mux_cfg = (afe_mux_cfg & ~0x30) | 0x20;
+ ch[1] = SIF;
+ break;
+ case CX18_AV_AUDIO7:
+ afe_mux_cfg &= ~0xc0;
+ ch[2] = SIF;
+ break;
+ case CX18_AV_AUDIO8:
+ afe_mux_cfg = (afe_mux_cfg & ~0xc0) | 0x40;
+ ch[2] = SIF;
+ break;
default:
CX18_ERR_DEV(sd, "0x%04x is not a valid audio input!\n",
@@ -520,24 +575,65 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
return -EINVAL;
}
- cx18_av_write_expect(cx, 0x103, reg, reg, 0xf7);
+ /* Set up analog front end multiplexers */
+ cx18_av_write_expect(cx, 0x103, afe_mux_cfg, afe_mux_cfg, 0xf7);
/* Set INPUT_MODE to Composite (0) or S-Video (1) */
- cx18_av_and_or(cx, 0x401, ~0x6, is_composite ? 0 : 0x02);
+ cx18_av_and_or(cx, 0x401, ~0x6, ch[0] == CVBS ? 0 : 0x02);
/* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
- v = cx18_av_read(cx, 0x102);
- if (reg & 0x80)
- v &= ~0x2;
+ adc2_cfg = cx18_av_read(cx, 0x102);
+ if (ch[2] == NONE)
+ adc2_cfg &= ~0x2; /* No sig on CH3, set ADC2 to CH2 for input */
else
- v |= 0x2;
+ adc2_cfg |= 0x2; /* Signal on CH3, set ADC2 to CH3 for input */
+
/* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */
- if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30)
- v |= 0x4;
+ if (ch[1] != NONE && ch[2] != NONE)
+ adc2_cfg |= 0x4; /* Set dual mode */
else
- v &= ~0x4;
- cx18_av_write_expect(cx, 0x102, v, v, 0x17);
+ adc2_cfg &= ~0x4; /* Clear dual mode */
+ cx18_av_write_expect(cx, 0x102, adc2_cfg, adc2_cfg, 0x17);
+
+ /* Configure the analog front end */
+ afe_cfg = cx18_av_read4(cx, CXADEC_AFE_CTRL);
+ afe_cfg &= 0xff000000;
+ afe_cfg |= 0x00005000; /* CHROMA_IN, AUD_IN: ADC2; LUMA_IN: ADC1 */
+ if (ch[1] != NONE && ch[2] != NONE)
+ afe_cfg |= 0x00000030; /* half_bw_ch[2-3] since in dual mode */
+
+ for (i = 0; i < 3; i++) {
+ switch (ch[i]) {
+ default:
+ case NONE:
+ /* CLAMP_SEL = Fixed to midcode clamp level */
+ afe_cfg |= (0x00000200 << i);
+ break;
+ case CVBS:
+ case Y:
+ if (i > 0)
+ afe_cfg |= 0x00002000; /* LUMA_IN_SEL: ADC2 */
+ break;
+ case C:
+ case Pb:
+ case Pr:
+ /* CLAMP_SEL = Fixed to midcode clamp level */
+ afe_cfg |= (0x00000200 << i);
+ if (i == 0 && ch[i] == C)
+ afe_cfg &= ~0x00001000; /* CHROMA_IN_SEL ADC1 */
+ break;
+ case SIF:
+ /*
+ * VGA_GAIN_SEL = Audio Decoder
+ * CLAMP_SEL = Fixed to midcode clamp level
+ */
+ afe_cfg |= (0x00000240 << i);
+ if (i == 0)
+ afe_cfg &= ~0x00004000; /* AUD_IN_SEL ADC1 */
+ break;
+ }
+ }
- /*cx18_av_and_or4(cx, 0x104, ~0x001b4180, 0x00004180);*/
+ cx18_av_write4(cx, CXADEC_AFE_CTRL, afe_cfg);
state->vid_input = vid_input;
state->aud_input = aud_input;
diff --git a/drivers/media/video/cx18/cx18-av-firmware.c b/drivers/media/video/cx18/cx18-av-firmware.c
index 49a55cc8d839..b9e8cc5d264a 100644
--- a/drivers/media/video/cx18/cx18-av-firmware.c
+++ b/drivers/media/video/cx18/cx18-av-firmware.c
@@ -24,15 +24,63 @@
#include "cx18-io.h"
#include <linux/firmware.h>
-#define CX18_AUDIO_ENABLE 0xc72014
+#define CX18_AUDIO_ENABLE 0xc72014
+#define CX18_AI1_MUX_MASK 0x30
+#define CX18_AI1_MUX_I2S1 0x00
+#define CX18_AI1_MUX_I2S2 0x10
+#define CX18_AI1_MUX_843_I2S 0x20
+#define CX18_AI1_MUX_INVALID 0x30
+
#define FWFILE "v4l-cx23418-dig.fw"
+static int cx18_av_verifyfw(struct cx18 *cx, const struct firmware *fw)
+{
+ struct v4l2_subdev *sd = &cx->av_state.sd;
+ int ret = 0;
+ const u8 *data;
+ u32 size;
+ int addr;
+ u32 expected, dl_control;
+
+ /* Ensure we put the 8051 in reset and enable firmware upload mode */
+ dl_control = cx18_av_read4(cx, CXADEC_DL_CTL);
+ do {
+ dl_control &= 0x00ffffff;
+ dl_control |= 0x0f000000;
+ cx18_av_write4_noretry(cx, CXADEC_DL_CTL, dl_control);
+ dl_control = cx18_av_read4(cx, CXADEC_DL_CTL);
+ } while ((dl_control & 0xff000000) != 0x0f000000);
+
+ /* Read and auto increment until at address 0x0000 */
+ while (dl_control & 0x3fff)
+ dl_control = cx18_av_read4(cx, CXADEC_DL_CTL);
+
+ data = fw->data;
+ size = fw->size;
+ for (addr = 0; addr < size; addr++) {
+ dl_control &= 0xffff3fff; /* ignore top 2 bits of address */
+ expected = 0x0f000000 | ((u32)data[addr] << 16) | addr;
+ if (expected != dl_control) {
+ CX18_ERR_DEV(sd, "verification of %s firmware load "
+ "failed: expected %#010x got %#010x\n",
+ FWFILE, expected, dl_control);
+ ret = -EIO;
+ break;
+ }
+ dl_control = cx18_av_read4(cx, CXADEC_DL_CTL);
+ }
+ if (ret == 0)
+ CX18_INFO_DEV(sd, "verified load of %s firmware (%d bytes)\n",
+ FWFILE, size);
+ return ret;
+}
+
int cx18_av_loadfw(struct cx18 *cx)
{
struct v4l2_subdev *sd = &cx->av_state.sd;
const struct firmware *fw = NULL;
u32 size;
- u32 v;
+ u32 u, v;
const u8 *ptr;
int i;
int retries1 = 0;
@@ -95,6 +143,12 @@ int cx18_av_loadfw(struct cx18 *cx)
}
cx18_av_write4_expect(cx, CXADEC_DL_CTL,
+ 0x03000000 | fw->size, 0x03000000, 0x13000000);
+
+ CX18_INFO_DEV(sd, "loaded %s firmware (%d bytes)\n", FWFILE, size);
+
+ if (cx18_av_verifyfw(cx, fw) == 0)
+ cx18_av_write4_expect(cx, CXADEC_DL_CTL,
0x13000000 | fw->size, 0x13000000, 0x13000000);
/* Output to the 416 */
@@ -135,6 +189,28 @@ int cx18_av_loadfw(struct cx18 *cx)
cx18_write_reg_expect(cx, v & 0xFFFFFBFF, CX18_AUDIO_ENABLE,
0, 0x400);
+ /* Toggle the AI1 MUX */
+ v = cx18_read_reg(cx, CX18_AUDIO_ENABLE);
+ u = v & CX18_AI1_MUX_MASK;
+ v &= ~CX18_AI1_MUX_MASK;
+ if (u == CX18_AI1_MUX_843_I2S || u == CX18_AI1_MUX_INVALID) {
+ /* Switch to I2S1 */
+ v |= CX18_AI1_MUX_I2S1;
+ cx18_write_reg_expect(cx, v | 0xb00, CX18_AUDIO_ENABLE,
+ v, CX18_AI1_MUX_MASK);
+ /* Switch back to the A/V decoder core I2S output */
+ v = (v & ~CX18_AI1_MUX_MASK) | CX18_AI1_MUX_843_I2S;
+ } else {
+ /* Switch to the A/V decoder core I2S output */
+ v |= CX18_AI1_MUX_843_I2S;
+ cx18_write_reg_expect(cx, v | 0xb00, CX18_AUDIO_ENABLE,
+ v, CX18_AI1_MUX_MASK);
+ /* Switch back to I2S1 or I2S2 */
+ v = (v & ~CX18_AI1_MUX_MASK) | u;
+ }
+ cx18_write_reg_expect(cx, v | 0xb00, CX18_AUDIO_ENABLE,
+ v, CX18_AI1_MUX_MASK);
+
/* Enable WW auto audio standard detection */
v = cx18_av_read4(cx, CXADEC_STD_DET_CTL);
v |= 0xFF; /* Auto by default */
@@ -143,7 +219,5 @@ int cx18_av_loadfw(struct cx18 *cx)
cx18_av_write4_expect(cx, CXADEC_STD_DET_CTL, v, v, 0x3F00FFFF);
release_firmware(fw);
-
- CX18_INFO_DEV(sd, "loaded %s firmware (%d bytes)\n", FWFILE, size);
return 0;
}
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c
index 82fc2f9d4021..8e35c3aed544 100644
--- a/drivers/media/video/cx18/cx18-controls.c
+++ b/drivers/media/video/cx18/cx18-controls.c
@@ -176,8 +176,10 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx,
return -EBUSY;
if (fmt != V4L2_MPEG_STREAM_VBI_FMT_IVTV ||
- type != V4L2_MPEG_STREAM_TYPE_MPEG2_PS) {
- /* We don't do VBI insertion aside from IVTV format in a PS */
+ !(type == V4L2_MPEG_STREAM_TYPE_MPEG2_PS ||
+ type == V4L2_MPEG_STREAM_TYPE_MPEG2_DVD ||
+ type == V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD)) {
+ /* Only IVTV fmt VBI insertion & only MPEG-2 PS type streams */
cx->vbi.insert_mpeg = V4L2_MPEG_STREAM_VBI_FMT_NONE;
CX18_DEBUG_INFO("disabled insertion of sliced VBI data into "
"the MPEG stream\n");
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 49b1c3d7b1a8..bc6a8f9abd3d 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -30,6 +30,7 @@
#include "cx18-irq.h"
#include "cx18-gpio.h"
#include "cx18-firmware.h"
+#include "cx18-queue.h"
#include "cx18-streams.h"
#include "cx18-av-core.h"
#include "cx18-scb.h"
@@ -312,7 +313,7 @@ static void cx18_process_eeprom(struct cx18 *cx)
CX18_INFO("Autodetected %s\n", cx->card_name);
if (tv.tuner_type == TUNER_ABSENT)
- CX18_ERR("tveeprom cannot autodetect tuner!");
+ CX18_ERR("tveeprom cannot autodetect tuner!\n");
if (cx->options.tuner == -1)
cx->options.tuner = tv.tuner_type;
@@ -546,6 +547,40 @@ done:
cx->card_i2c = cx->card->i2c;
}
+static int __devinit cx18_create_in_workq(struct cx18 *cx)
+{
+ snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
+ cx->v4l2_dev.name);
+ cx->in_work_queue = create_singlethread_workqueue(cx->in_workq_name);
+ if (cx->in_work_queue == NULL) {
+ CX18_ERR("Unable to create incoming mailbox handler thread\n");
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+static int __devinit cx18_create_out_workq(struct cx18 *cx)
+{
+ snprintf(cx->out_workq_name, sizeof(cx->out_workq_name), "%s-out",
+ cx->v4l2_dev.name);
+ cx->out_work_queue = create_workqueue(cx->out_workq_name);
+ if (cx->out_work_queue == NULL) {
+ CX18_ERR("Unable to create outgoing mailbox handler threads\n");
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+static void __devinit cx18_init_in_work_orders(struct cx18 *cx)
+{
+ int i;
+ for (i = 0; i < CX18_MAX_IN_WORK_ORDERS; i++) {
+ cx->in_work_order[i].cx = cx;
+ cx->in_work_order[i].str = cx->epu_debug_str;
+ INIT_WORK(&cx->in_work_order[i].work, cx18_in_work_handler);
+ }
+}
+
/* Precondition: the cx18 structure has been memset to 0. Only
the dev and instance fields have been filled in.
No assumptions on the card type may be made here (see cx18_init_struct2
@@ -553,7 +588,7 @@ done:
*/
static int __devinit cx18_init_struct1(struct cx18 *cx)
{
- int i;
+ int ret;
cx->base_addr = pci_resource_start(cx->pci_dev, 0);
@@ -562,18 +597,18 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
mutex_init(&cx->epu2apu_mb_lock);
mutex_init(&cx->epu2cpu_mb_lock);
- cx->work_queue = create_singlethread_workqueue(cx->v4l2_dev.name);
- if (cx->work_queue == NULL) {
- CX18_ERR("Unable to create work hander thread\n");
- return -ENOMEM;
- }
+ ret = cx18_create_out_workq(cx);
+ if (ret)
+ return ret;
- for (i = 0; i < CX18_MAX_EPU_WORK_ORDERS; i++) {
- cx->epu_work_order[i].cx = cx;
- cx->epu_work_order[i].str = cx->epu_debug_str;
- INIT_WORK(&cx->epu_work_order[i].work, cx18_epu_work_handler);
+ ret = cx18_create_in_workq(cx);
+ if (ret) {
+ destroy_workqueue(cx->out_work_queue);
+ return ret;
}
+ cx18_init_in_work_orders(cx);
+
/* start counting open_id at 1 */
cx->open_id = 1;
@@ -759,17 +794,17 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev,
retval = -ENODEV;
goto err;
}
- if (cx18_init_struct1(cx)) {
- retval = -ENOMEM;
+
+ retval = cx18_init_struct1(cx);
+ if (retval)
goto err;
- }
CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr);
/* PCI Device Setup */
retval = cx18_setup_pci(cx, pci_dev, pci_id);
if (retval != 0)
- goto free_workqueue;
+ goto free_workqueues;
/* map io memory */
CX18_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n",
@@ -943,8 +978,9 @@ free_map:
cx18_iounmap(cx);
free_mem:
release_mem_region(cx->base_addr, CX18_MEM_SIZE);
-free_workqueue:
- destroy_workqueue(cx->work_queue);
+free_workqueues:
+ destroy_workqueue(cx->in_work_queue);
+ destroy_workqueue(cx->out_work_queue);
err:
if (retval == 0)
retval = -ENODEV;
@@ -1053,11 +1089,19 @@ int cx18_init_on_first_open(struct cx18 *cx)
return 0;
}
-static void cx18_cancel_epu_work_orders(struct cx18 *cx)
+static void cx18_cancel_in_work_orders(struct cx18 *cx)
{
int i;
- for (i = 0; i < CX18_MAX_EPU_WORK_ORDERS; i++)
- cancel_work_sync(&cx->epu_work_order[i].work);
+ for (i = 0; i < CX18_MAX_IN_WORK_ORDERS; i++)
+ cancel_work_sync(&cx->in_work_order[i].work);
+}
+
+static void cx18_cancel_out_work_orders(struct cx18 *cx)
+{
+ int i;
+ for (i = 0; i < CX18_MAX_STREAMS; i++)
+ if (&cx->streams[i].video_dev != NULL)
+ cancel_work_sync(&cx->streams[i].out_work_order);
}
static void cx18_remove(struct pci_dev *pci_dev)
@@ -1073,15 +1117,20 @@ static void cx18_remove(struct pci_dev *pci_dev)
if (atomic_read(&cx->tot_capturing) > 0)
cx18_stop_all_captures(cx);
- /* Interrupts */
+ /* Stop interrupts that cause incoming work to be queued */
cx18_sw1_irq_disable(cx, IRQ_CPU_TO_EPU | IRQ_APU_TO_EPU);
+
+ /* Incoming work can cause outgoing work, so clean up incoming first */
+ cx18_cancel_in_work_orders(cx);
+ cx18_cancel_out_work_orders(cx);
+
+ /* Stop ack interrupts that may have been needed for work to finish */
cx18_sw2_irq_disable(cx, IRQ_CPU_TO_EPU_ACK | IRQ_APU_TO_EPU_ACK);
cx18_halt_firmware(cx);
- cx18_cancel_epu_work_orders(cx);
-
- destroy_workqueue(cx->work_queue);
+ destroy_workqueue(cx->in_work_queue);
+ destroy_workqueue(cx->out_work_queue);
cx18_streams_cleanup(cx, 1);
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index ece4f281ef42..f89b82367963 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -254,6 +254,7 @@ struct cx18_options {
#define CX18_F_S_INTERNAL_USE 5 /* this stream is used internally (sliced VBI processing) */
#define CX18_F_S_STREAMOFF 7 /* signal end of stream EOS */
#define CX18_F_S_APPL_IO 8 /* this stream is used read/written by an application */
+#define CX18_F_S_STOPPING 9 /* telling the fw to stop capturing */
/* per-cx18, i_flags */
#define CX18_F_I_LOADED_FW 0 /* Loaded firmware 1st time */
@@ -285,6 +286,7 @@ struct cx18_queue {
struct list_head list;
atomic_t buffers;
u32 bytesused;
+ spinlock_t lock;
};
struct cx18_dvb {
@@ -305,7 +307,7 @@ struct cx18_scb; /* forward reference */
#define CX18_MAX_MDL_ACKS 2
-#define CX18_MAX_EPU_WORK_ORDERS (CX18_MAX_FW_MDLS_PER_STREAM + 7)
+#define CX18_MAX_IN_WORK_ORDERS (CX18_MAX_FW_MDLS_PER_STREAM + 7)
/* CPU_DE_RELEASE_MDL can burst CX18_MAX_FW_MDLS_PER_STREAM orders in a group */
#define CX18_F_EWO_MB_STALE_UPON_RECEIPT 0x1
@@ -313,7 +315,7 @@ struct cx18_scb; /* forward reference */
#define CX18_F_EWO_MB_STALE \
(CX18_F_EWO_MB_STALE_UPON_RECEIPT | CX18_F_EWO_MB_STALE_WHILE_PROC)
-struct cx18_epu_work_order {
+struct cx18_in_work_order {
struct work_struct work;
atomic_t pending;
struct cx18 *cx;
@@ -337,7 +339,6 @@ struct cx18_stream {
unsigned mdl_offset;
u32 id;
- struct mutex qlock; /* locks access to the queues */
unsigned long s_flags; /* status flags, see above */
int dma; /* can be PCI_DMA_TODEVICE,
PCI_DMA_FROMDEVICE or
@@ -353,6 +354,8 @@ struct cx18_stream {
struct cx18_queue q_busy; /* busy buffers - in use by firmware */
struct cx18_queue q_full; /* full buffers - data for user apps */
+ struct work_struct out_work_order;
+
/* DVB / Digital Transport */
struct cx18_dvb dvb;
};
@@ -568,10 +571,14 @@ struct cx18 {
u32 sw2_irq_mask;
u32 hw2_irq_mask;
- struct workqueue_struct *work_queue;
- struct cx18_epu_work_order epu_work_order[CX18_MAX_EPU_WORK_ORDERS];
+ struct workqueue_struct *in_work_queue;
+ char in_workq_name[11]; /* "cx18-NN-in" */
+ struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS];
char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */
+ struct workqueue_struct *out_work_queue;
+ char out_workq_name[12]; /* "cx18-NN-out" */
+
/* i2c */
struct i2c_adapter i2c_adap[2];
struct i2c_algo_bit_data i2c_algo[2];
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index 3b86f57cd15a..e7285a1096f2 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -23,6 +23,7 @@
#include "cx18-version.h"
#include "cx18-dvb.h"
#include "cx18-io.h"
+#include "cx18-queue.h"
#include "cx18-streams.h"
#include "cx18-cards.h"
#include "s5h1409.h"
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index b3889c0b2697..29969c18949c 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -265,8 +265,13 @@ static size_t cx18_copy_buf_to_user(struct cx18_stream *s,
* an MPEG-2 Program Pack start code, and provide only
* up to that point to the user, so it's easy to insert VBI data
* the next time around.
+ *
+ * This will not work for an MPEG-2 TS and has only been
+ * verified by analysis to work for an MPEG-2 PS. Helen Buus
+ * pointed out this works for the CX23416 MPEG-2 DVD compatible
+ * stream, and research indicates both the MPEG 2 SVCD and DVD
+ * stream types use an MPEG-2 PS container.
*/
- /* FIXME - This only works for an MPEG-2 PS, not a TS */
/*
* An MPEG-2 Program Stream (PS) is a series of
* MPEG-2 Program Packs terminated by an
diff --git a/drivers/media/video/cx18/cx18-mailbox.c b/drivers/media/video/cx18/cx18-mailbox.c
index 2226e5791e99..afe46c3d4057 100644
--- a/drivers/media/video/cx18/cx18-mailbox.c
+++ b/drivers/media/video/cx18/cx18-mailbox.c
@@ -131,7 +131,7 @@ static void dump_mb(struct cx18 *cx, struct cx18_mailbox *mb, char *name)
* Functions that run in a work_queue work handling context
*/
-static void epu_dma_done(struct cx18 *cx, struct cx18_epu_work_order *order)
+static void epu_dma_done(struct cx18 *cx, struct cx18_in_work_order *order)
{
u32 handle, mdl_ack_count, id;
struct cx18_mailbox *mb;
@@ -191,29 +191,30 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_epu_work_order *order)
if (buf == NULL) {
CX18_WARN("Could not find buf %d for stream %s\n",
id, s->name);
- /* Put as many buffers as possible back into fw use */
- cx18_stream_load_fw_queue(s);
continue;
}
- if (s->type == CX18_ENC_STREAM_TYPE_TS && s->dvb.enabled) {
- CX18_DEBUG_HI_DMA("TS recv bytesused = %d\n",
- buf->bytesused);
- dvb_dmx_swfilter(&s->dvb.demux, buf->buf,
- buf->bytesused);
+ CX18_DEBUG_HI_DMA("%s recv bytesused = %d\n",
+ s->name, buf->bytesused);
+
+ if (s->type != CX18_ENC_STREAM_TYPE_TS)
+ cx18_enqueue(s, buf, &s->q_full);
+ else {
+ if (s->dvb.enabled)
+ dvb_dmx_swfilter(&s->dvb.demux, buf->buf,
+ buf->bytesused);
+ cx18_enqueue(s, buf, &s->q_free);
}
- /* Put as many buffers as possible back into fw use */
- cx18_stream_load_fw_queue(s);
- /* Put back TS buffer, since it was removed from all queues */
- if (s->type == CX18_ENC_STREAM_TYPE_TS)
- cx18_stream_put_buf_fw(s, buf);
}
+ /* Put as many buffers as possible back into fw use */
+ cx18_stream_load_fw_queue(s);
+
wake_up(&cx->dma_waitq);
if (s->id != -1)
wake_up(&s->waitq);
}
-static void epu_debug(struct cx18 *cx, struct cx18_epu_work_order *order)
+static void epu_debug(struct cx18 *cx, struct cx18_in_work_order *order)
{
char *p;
char *str = order->str;
@@ -224,7 +225,7 @@ static void epu_debug(struct cx18 *cx, struct cx18_epu_work_order *order)
CX18_INFO("FW version: %s\n", p - 1);
}
-static void epu_cmd(struct cx18 *cx, struct cx18_epu_work_order *order)
+static void epu_cmd(struct cx18 *cx, struct cx18_in_work_order *order)
{
switch (order->rpu) {
case CPU:
@@ -253,18 +254,18 @@ static void epu_cmd(struct cx18 *cx, struct cx18_epu_work_order *order)
}
static
-void free_epu_work_order(struct cx18 *cx, struct cx18_epu_work_order *order)
+void free_in_work_order(struct cx18 *cx, struct cx18_in_work_order *order)
{
atomic_set(&order->pending, 0);
}
-void cx18_epu_work_handler(struct work_struct *work)
+void cx18_in_work_handler(struct work_struct *work)
{
- struct cx18_epu_work_order *order =
- container_of(work, struct cx18_epu_work_order, work);
+ struct cx18_in_work_order *order =
+ container_of(work, struct cx18_in_work_order, work);
struct cx18 *cx = order->cx;
epu_cmd(cx, order);
- free_epu_work_order(cx, order);
+ free_in_work_order(cx, order);
}
@@ -272,7 +273,7 @@ void cx18_epu_work_handler(struct work_struct *work)
* Functions that run in an interrupt handling context
*/
-static void mb_ack_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
+static void mb_ack_irq(struct cx18 *cx, struct cx18_in_work_order *order)
{
struct cx18_mailbox __iomem *ack_mb;
u32 ack_irq, req;
@@ -308,7 +309,7 @@ static void mb_ack_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
return;
}
-static int epu_dma_done_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
+static int epu_dma_done_irq(struct cx18 *cx, struct cx18_in_work_order *order)
{
u32 handle, mdl_ack_offset, mdl_ack_count;
struct cx18_mailbox *mb;
@@ -334,7 +335,7 @@ static int epu_dma_done_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
}
static
-int epu_debug_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
+int epu_debug_irq(struct cx18 *cx, struct cx18_in_work_order *order)
{
u32 str_offset;
char *str = order->str;
@@ -355,7 +356,7 @@ int epu_debug_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
}
static inline
-int epu_cmd_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
+int epu_cmd_irq(struct cx18 *cx, struct cx18_in_work_order *order)
{
int ret = -1;
@@ -387,12 +388,12 @@ int epu_cmd_irq(struct cx18 *cx, struct cx18_epu_work_order *order)
}
static inline
-struct cx18_epu_work_order *alloc_epu_work_order_irq(struct cx18 *cx)
+struct cx18_in_work_order *alloc_in_work_order_irq(struct cx18 *cx)
{
int i;
- struct cx18_epu_work_order *order = NULL;
+ struct cx18_in_work_order *order = NULL;
- for (i = 0; i < CX18_MAX_EPU_WORK_ORDERS; i++) {
+ for (i = 0; i < CX18_MAX_IN_WORK_ORDERS; i++) {
/*
* We only need "pending" atomic to inspect its contents,
* and need not do a check and set because:
@@ -401,8 +402,8 @@ struct cx18_epu_work_order *alloc_epu_work_order_irq(struct cx18 *cx)
* 2. "pending" is only set here, and we're serialized because
* we're called in an IRQ handler context.
*/
- if (atomic_read(&cx->epu_work_order[i].pending) == 0) {
- order = &cx->epu_work_order[i];
+ if (atomic_read(&cx->in_work_order[i].pending) == 0) {
+ order = &cx->in_work_order[i];
atomic_set(&order->pending, 1);
break;
}
@@ -414,7 +415,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
{
struct cx18_mailbox __iomem *mb;
struct cx18_mailbox *order_mb;
- struct cx18_epu_work_order *order;
+ struct cx18_in_work_order *order;
int submit;
switch (rpu) {
@@ -428,7 +429,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
return;
}
- order = alloc_epu_work_order_irq(cx);
+ order = alloc_in_work_order_irq(cx);
if (order == NULL) {
CX18_WARN("Unable to find blank work order form to schedule "
"incoming mailbox command processing\n");
@@ -461,7 +462,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
*/
submit = epu_cmd_irq(cx, order);
if (submit > 0) {
- queue_work(cx->work_queue, &order->work);
+ queue_work(cx->in_work_queue, &order->work);
}
}
@@ -478,9 +479,10 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
u32 __iomem *xpu_state;
wait_queue_head_t *waitq;
struct mutex *mb_lock;
- long int timeout, ret;
+ unsigned long int t0, timeout, ret;
int i;
char argstr[MAX_MB_ARGUMENTS*11+1];
+ DEFINE_WAIT(w);
if (info == NULL) {
CX18_WARN("unknown cmd %x\n", cmd);
@@ -562,25 +564,49 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
CX18_DEBUG_HI_IRQ("sending interrupt SW1: %x to send %s\n",
irq, info->name);
+
+ /* So we don't miss the wakeup, prepare to wait before notifying fw */
+ prepare_to_wait(waitq, &w, TASK_UNINTERRUPTIBLE);
cx18_write_reg_expect(cx, irq, SW1_INT_SET, irq, irq);
- ret = wait_event_timeout(
- *waitq,
- cx18_readl(cx, &mb->ack) == cx18_readl(cx, &mb->request),
- timeout);
+ t0 = jiffies;
+ ack = cx18_readl(cx, &mb->ack);
+ if (ack != req) {
+ schedule_timeout(timeout);
+ ret = jiffies - t0;
+ ack = cx18_readl(cx, &mb->ack);
+ } else {
+ ret = jiffies - t0;
+ }
- if (ret == 0) {
- /* Timed out */
+ finish_wait(waitq, &w);
+
+ if (req != ack) {
mutex_unlock(mb_lock);
- CX18_DEBUG_WARN("sending %s timed out waiting %d msecs for RPU "
- "acknowledgement\n",
- info->name, jiffies_to_msecs(timeout));
+ if (ret >= timeout) {
+ /* Timed out */
+ CX18_DEBUG_WARN("sending %s timed out waiting %d msecs "
+ "for RPU acknowledgement\n",
+ info->name, jiffies_to_msecs(ret));
+ } else {
+ CX18_DEBUG_WARN("woken up before mailbox ack was ready "
+ "after submitting %s to RPU. only "
+ "waited %d msecs on req %u but awakened"
+ " with unmatched ack %u\n",
+ info->name,
+ jiffies_to_msecs(ret),
+ req, ack);
+ }
return -EINVAL;
}
- if (ret != timeout)
+ if (ret >= timeout)
+ CX18_DEBUG_WARN("failed to be awakened upon RPU acknowledgment "
+ "sending %s; timed out waiting %d msecs\n",
+ info->name, jiffies_to_msecs(ret));
+ else
CX18_DEBUG_HI_API("waited %u msecs for %s to be acked\n",
- jiffies_to_msecs(timeout-ret), info->name);
+ jiffies_to_msecs(ret), info->name);
/* Collect data returned by the XPU */
for (i = 0; i < MAX_MB_ARGUMENTS; i++)
diff --git a/drivers/media/video/cx18/cx18-mailbox.h b/drivers/media/video/cx18/cx18-mailbox.h
index ce2b6686aa00..e23aaac5b280 100644
--- a/drivers/media/video/cx18/cx18-mailbox.h
+++ b/drivers/media/video/cx18/cx18-mailbox.h
@@ -95,6 +95,6 @@ int cx18_api_func(void *priv, u32 cmd, int in, int out,
void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu);
-void cx18_epu_work_handler(struct work_struct *work);
+void cx18_in_work_handler(struct work_struct *work);
#endif
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index 3046b8e74345..fa1ed7897d97 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -23,8 +23,8 @@
*/
#include "cx18-driver.h"
-#include "cx18-streams.h"
#include "cx18-queue.h"
+#include "cx18-streams.h"
#include "cx18-scb.h"
void cx18_buf_swap(struct cx18_buffer *buf)
@@ -53,13 +53,13 @@ struct cx18_queue *_cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
buf->skipped = 0;
}
- mutex_lock(&s->qlock);
-
/* q_busy is restricted to a max buffer count imposed by firmware */
if (q == &s->q_busy &&
atomic_read(&q->buffers) >= CX18_MAX_FW_MDLS_PER_STREAM)
q = &s->q_free;
+ spin_lock(&q->lock);
+
if (to_front)
list_add(&buf->list, &q->list); /* LIFO */
else
@@ -67,7 +67,7 @@ struct cx18_queue *_cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
q->bytesused += buf->bytesused - buf->readpos;
atomic_inc(&q->buffers);
- mutex_unlock(&s->qlock);
+ spin_unlock(&q->lock);
return q;
}
@@ -75,7 +75,7 @@ struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q)
{
struct cx18_buffer *buf = NULL;
- mutex_lock(&s->qlock);
+ spin_lock(&q->lock);
if (!list_empty(&q->list)) {
buf = list_first_entry(&q->list, struct cx18_buffer, list);
list_del_init(&buf->list);
@@ -83,7 +83,7 @@ struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q)
buf->skipped = 0;
atomic_dec(&q->buffers);
}
- mutex_unlock(&s->qlock);
+ spin_unlock(&q->lock);
return buf;
}
@@ -94,9 +94,23 @@ struct cx18_buffer *cx18_queue_get_buf(struct cx18_stream *s, u32 id,
struct cx18_buffer *buf;
struct cx18_buffer *tmp;
struct cx18_buffer *ret = NULL;
-
- mutex_lock(&s->qlock);
+ LIST_HEAD(sweep_up);
+
+ /*
+ * We don't have to acquire multiple q locks here, because we are
+ * serialized by the single threaded work handler.
+ * Buffers from the firmware will thus remain in order as
+ * they are moved from q_busy to q_full or to the dvb ring buffer.
+ */
+ spin_lock(&s->q_busy.lock);
list_for_each_entry_safe(buf, tmp, &s->q_busy.list, list) {
+ /*
+ * We should find what the firmware told us is done,
+ * right at the front of the queue. If we don't, we likely have
+ * missed a buffer done message from the firmware.
+ * Once we skip a buffer repeatedly, relative to the size of
+ * q_busy, we have high confidence we've missed it.
+ */
if (buf->id != id) {
buf->skipped++;
if (buf->skipped >= atomic_read(&s->q_busy.buffers)-1) {
@@ -105,38 +119,41 @@ struct cx18_buffer *cx18_queue_get_buf(struct cx18_stream *s, u32 id,
"times - it must have dropped out of "
"rotation\n", s->name, buf->id,
buf->skipped);
- /* move it to q_free */
- list_move_tail(&buf->list, &s->q_free.list);
- buf->bytesused = buf->readpos = buf->b_flags =
- buf->skipped = 0;
+ /* Sweep it up to put it back into rotation */
+ list_move_tail(&buf->list, &sweep_up);
atomic_dec(&s->q_busy.buffers);
- atomic_inc(&s->q_free.buffers);
}
continue;
}
-
- buf->bytesused = bytesused;
- /* Sync the buffer before we release the qlock */
- cx18_buf_sync_for_cpu(s, buf);
- if (s->type == CX18_ENC_STREAM_TYPE_TS) {
- /*
- * TS doesn't use q_full. As we pull the buffer off of
- * the queue here, the caller will have to put it back.
- */
- list_del_init(&buf->list);
- } else {
- /* Move buffer from q_busy to q_full */
- list_move_tail(&buf->list, &s->q_full.list);
- set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags);
- s->q_full.bytesused += buf->bytesused;
- atomic_inc(&s->q_full.buffers);
- }
+ /*
+ * We pull the desired buffer off of the queue here. Something
+ * will have to put it back on a queue later.
+ */
+ list_del_init(&buf->list);
atomic_dec(&s->q_busy.buffers);
-
ret = buf;
break;
}
- mutex_unlock(&s->qlock);
+ spin_unlock(&s->q_busy.lock);
+
+ /*
+ * We found the buffer for which we were looking. Get it ready for
+ * the caller to put on q_full or in the dvb ring buffer.
+ */
+ if (ret != NULL) {
+ ret->bytesused = bytesused;
+ ret->skipped = 0;
+ /* readpos and b_flags were 0'ed when the buf went on q_busy */
+ cx18_buf_sync_for_cpu(s, ret);
+ if (s->type != CX18_ENC_STREAM_TYPE_TS)
+ set_bit(CX18_F_B_NEED_BUF_SWAP, &ret->b_flags);
+ }
+
+ /* Put any buffers the firmware is ignoring back into normal rotation */
+ list_for_each_entry_safe(buf, tmp, &sweep_up, list) {
+ list_del_init(&buf->list);
+ cx18_enqueue(s, buf, &s->q_free);
+ }
return ret;
}
@@ -148,7 +165,7 @@ static void cx18_queue_flush(struct cx18_stream *s, struct cx18_queue *q)
if (q == &s->q_free)
return;
- mutex_lock(&s->qlock);
+ spin_lock(&q->lock);
while (!list_empty(&q->list)) {
buf = list_first_entry(&q->list, struct cx18_buffer, list);
list_move_tail(&buf->list, &s->q_free.list);
@@ -156,7 +173,7 @@ static void cx18_queue_flush(struct cx18_stream *s, struct cx18_queue *q)
atomic_inc(&s->q_free.buffers);
}
cx18_queue_init(q);
- mutex_unlock(&s->qlock);
+ spin_unlock(&q->lock);
}
void cx18_flush_queues(struct cx18_stream *s)
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 0932b76b2373..41a1b2618aac 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -116,12 +116,16 @@ static void cx18_stream_init(struct cx18 *cx, int type)
s->buffers = cx->stream_buffers[type];
s->buf_size = cx->stream_buf_size[type];
- mutex_init(&s->qlock);
init_waitqueue_head(&s->waitq);
s->id = -1;
+ spin_lock_init(&s->q_free.lock);
cx18_queue_init(&s->q_free);
+ spin_lock_init(&s->q_busy.lock);
cx18_queue_init(&s->q_busy);
+ spin_lock_init(&s->q_full.lock);
cx18_queue_init(&s->q_full);
+
+ INIT_WORK(&s->out_work_order, cx18_out_work_handler);
}
static int cx18_prep_dev(struct cx18 *cx, int type)
@@ -431,14 +435,16 @@ static void cx18_vbi_setup(struct cx18_stream *s)
cx18_api(cx, CX18_CPU_SET_RAW_VBI_PARAM, 6, data);
}
-struct cx18_queue *cx18_stream_put_buf_fw(struct cx18_stream *s,
- struct cx18_buffer *buf)
+static
+struct cx18_queue *_cx18_stream_put_buf_fw(struct cx18_stream *s,
+ struct cx18_buffer *buf)
{
struct cx18 *cx = s->cx;
struct cx18_queue *q;
/* Don't give it to the firmware, if we're not running a capture */
if (s->handle == CX18_INVALID_TASK_HANDLE ||
+ test_bit(CX18_F_S_STOPPING, &s->s_flags) ||
!test_bit(CX18_F_S_STREAMING, &s->s_flags))
return cx18_enqueue(s, buf, &s->q_free);
@@ -453,7 +459,8 @@ struct cx18_queue *cx18_stream_put_buf_fw(struct cx18_stream *s,
return q;
}
-void cx18_stream_load_fw_queue(struct cx18_stream *s)
+static
+void _cx18_stream_load_fw_queue(struct cx18_stream *s)
{
struct cx18_queue *q;
struct cx18_buffer *buf;
@@ -467,11 +474,19 @@ void cx18_stream_load_fw_queue(struct cx18_stream *s)
buf = cx18_dequeue(s, &s->q_free);
if (buf == NULL)
break;
- q = cx18_stream_put_buf_fw(s, buf);
+ q = _cx18_stream_put_buf_fw(s, buf);
} while (atomic_read(&s->q_busy.buffers) < CX18_MAX_FW_MDLS_PER_STREAM
&& q == &s->q_busy);
}
+void cx18_out_work_handler(struct work_struct *work)
+{
+ struct cx18_stream *s =
+ container_of(work, struct cx18_stream, out_work_order);
+
+ _cx18_stream_load_fw_queue(s);
+}
+
int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
{
u32 data[MAX_MB_ARGUMENTS];
@@ -600,19 +615,20 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
/* Init all the cpu_mdls for this stream */
cx18_flush_queues(s);
- mutex_lock(&s->qlock);
+ spin_lock(&s->q_free.lock);
list_for_each_entry(buf, &s->q_free.list, list) {
cx18_writel(cx, buf->dma_handle,
&cx->scb->cpu_mdl[buf->id].paddr);
cx18_writel(cx, s->buf_size, &cx->scb->cpu_mdl[buf->id].length);
}
- mutex_unlock(&s->qlock);
- cx18_stream_load_fw_queue(s);
+ spin_unlock(&s->q_free.lock);
+ _cx18_stream_load_fw_queue(s);
/* begin_capture */
if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) {
CX18_DEBUG_WARN("Error starting capture!\n");
/* Ensure we're really not capturing before releasing MDLs */
+ set_bit(CX18_F_S_STOPPING, &s->s_flags);
if (s->type == CX18_ENC_STREAM_TYPE_MPG)
cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, 1);
else
@@ -622,6 +638,7 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle);
cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle);
s->handle = CX18_INVALID_TASK_HANDLE;
+ clear_bit(CX18_F_S_STOPPING, &s->s_flags);
if (atomic_read(&cx->tot_capturing) == 0) {
set_bit(CX18_F_I_EOS, &cx->i_flags);
cx18_write_reg(cx, 5, CX18_DSP0_INTERRUPT_MASK);
@@ -666,6 +683,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
if (atomic_read(&cx->tot_capturing) == 0)
return 0;
+ set_bit(CX18_F_S_STOPPING, &s->s_flags);
if (s->type == CX18_ENC_STREAM_TYPE_MPG)
cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, !gop_end);
else
@@ -689,6 +707,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle);
s->handle = CX18_INVALID_TASK_HANDLE;
+ clear_bit(CX18_F_S_STOPPING, &s->s_flags);
if (atomic_read(&cx->tot_capturing) > 0)
return 0;
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h
index 420e0a172945..1afc3fd9d822 100644
--- a/drivers/media/video/cx18/cx18-streams.h
+++ b/drivers/media/video/cx18/cx18-streams.h
@@ -28,10 +28,24 @@ int cx18_streams_setup(struct cx18 *cx);
int cx18_streams_register(struct cx18 *cx);
void cx18_streams_cleanup(struct cx18 *cx, int unregister);
+/* Related to submission of buffers to firmware */
+static inline void cx18_stream_load_fw_queue(struct cx18_stream *s)
+{
+ struct cx18 *cx = s->cx;
+ queue_work(cx->out_work_queue, &s->out_work_order);
+}
+
+static inline void cx18_stream_put_buf_fw(struct cx18_stream *s,
+ struct cx18_buffer *buf)
+{
+ /* Put buf on q_free; the out work handler will move buf(s) to q_busy */
+ cx18_enqueue(s, buf, &s->q_free);
+ cx18_stream_load_fw_queue(s);
+}
+
+void cx18_out_work_handler(struct work_struct *work);
+
/* Capture related */
-void cx18_stream_load_fw_queue(struct cx18_stream *s);
-struct cx18_queue *cx18_stream_put_buf_fw(struct cx18_stream *s,
- struct cx18_buffer *buf);
int cx18_start_v4l2_encode_stream(struct cx18_stream *s);
int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end);
diff --git a/drivers/media/video/cx18/cx18-version.h b/drivers/media/video/cx18/cx18-version.h
index bd9bd44da791..45494b094e7f 100644
--- a/drivers/media/video/cx18/cx18-version.h
+++ b/drivers/media/video/cx18/cx18-version.h
@@ -24,7 +24,7 @@
#define CX18_DRIVER_NAME "cx18"
#define CX18_DRIVER_VERSION_MAJOR 1
-#define CX18_DRIVER_VERSION_MINOR 1
+#define CX18_DRIVER_VERSION_MINOR 2
#define CX18_DRIVER_VERSION_PATCHLEVEL 0
#define CX18_VERSION __stringify(CX18_DRIVER_VERSION_MAJOR) "." __stringify(CX18_DRIVER_VERSION_MINOR) "." __stringify(CX18_DRIVER_VERSION_PATCHLEVEL)
diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c
index 1be3881be991..6a9464079b4c 100644
--- a/drivers/media/video/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/video/cx231xx/cx231xx-avcore.c
@@ -29,7 +29,6 @@
#include <linux/bitmap.h>
#include <linux/usb.h>
#include <linux/i2c.h>
-#include <linux/version.h>
#include <linux/mm.h>
#include <linux/mutex.h>
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c
index 94180526909c..e97b8023a655 100644
--- a/drivers/media/video/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/video/cx231xx/cx231xx-vbi.c
@@ -26,7 +26,6 @@
#include <linux/bitmap.h>
#include <linux/usb.h>
#include <linux/i2c.h>
-#include <linux/version.h>
#include <linux/mm.h>
#include <linux/mutex.h>
diff --git a/drivers/media/video/cx23885/cimax2.c b/drivers/media/video/cx23885/cimax2.c
index 9a6536998d90..08582e58bdbf 100644
--- a/drivers/media/video/cx23885/cimax2.c
+++ b/drivers/media/video/cx23885/cimax2.c
@@ -312,7 +312,7 @@ static void netup_read_ci_status(struct work_struct *work)
"TS config = %02x\n", __func__, state->ci_i2c_addr, 0, buf[0],
buf[32]);
- if (buf[0] && 1)
+ if (buf[0] & 1)
state->status = DVB_CA_EN50221_POLL_CAM_PRESENT |
DVB_CA_EN50221_POLL_CAM_READY;
else
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index beda42925ce7..9e4d37eb918e 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -1700,9 +1700,13 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id)
}
if (cx23885_boards[dev->board].cimax > 0 &&
- ((pci_status & PCI_MSK_GPIO0) || (pci_status & PCI_MSK_GPIO1)))
- /* handled += cx23885_irq_gpio(dev, pci_status); */
- handled += netup_ci_slot_status(dev, pci_status);
+ ((pci_status & PCI_MSK_GPIO0) ||
+ (pci_status & PCI_MSK_GPIO1))) {
+
+ if (cx23885_boards[dev->board].cimax > 0)
+ handled += netup_ci_slot_status(dev, pci_status);
+
+ }
if (ts1_status) {
if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB)
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index 1dc070da8652..07b76053a050 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -122,7 +122,9 @@ static struct tda10048_config hauppauge_hvr1200_config = {
.demod_address = 0x10 >> 1,
.output_mode = TDA10048_SERIAL_OUTPUT,
.fwbulkwritelen = TDA10048_BULKWRITE_200,
- .inversion = TDA10048_INVERSION_ON
+ .inversion = TDA10048_INVERSION_ON,
+ .if_freq_khz = TDA10048_IF_4300,
+ .clk_freq_khz = TDA10048_CLK_16000,
};
static struct s5h1409_config hauppauge_ezqam_config = {
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index b06b1275a9ec..5b7e26761f0a 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -1,5 +1,5 @@
cx88xx-objs := cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o \
- cx88-input.o
+ cx88-dsp.o cx88-input.o
cx8800-objs := cx88-video.o cx88-vbi.o
cx8802-objs := cx88-mpeg.o
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 6bbbfc66bb4b..1039757e2c4e 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1969,6 +1969,13 @@ static const struct cx88_board cx88_boards[] = {
},
.mpeg = CX88_MPEG_DVB,
},
+ [CX88_BOARD_HAUPPAUGE_IRONLY] = {
+ .name = "Hauppauge WinTV-IR Only",
+ .tuner_type = UNSET,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ },
};
/* ------------------------------------------------------------------ */
@@ -2382,6 +2389,10 @@ static const struct cx88_subid cx88_subids[] = {
.subvendor = 0x153b,
.subdevice = 0x1177,
.card = CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII,
+ }, {
+ .subvendor = 0x0070,
+ .subdevice = 0x9290,
+ .card = CX88_BOARD_HAUPPAUGE_IRONLY,
},
};
@@ -2448,6 +2459,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
case 90500: /* Nova-T-PCI (oem) */
case 90501: /* Nova-T-PCI (oem/IR) */
case 92000: /* Nova-SE2 (OEM, No Video or IR) */
+ case 92900: /* WinTV-IROnly (No analog or digital Video inputs) */
case 94009: /* WinTV-HVR1100 (Video and IR Retail) */
case 94501: /* WinTV-HVR1100 (Video and IR OEM) */
case 96009: /* WinTV-HVR1300 (PAL Video, MPEG Video and IR RX) */
@@ -2907,6 +2919,7 @@ static void cx88_card_setup(struct cx88_core *core)
case CX88_BOARD_HAUPPAUGE_HVR1300:
case CX88_BOARD_HAUPPAUGE_HVR4000:
case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
+ case CX88_BOARD_HAUPPAUGE_IRONLY:
if (0 == core->i2c_rc)
hauppauge_eeprom(core, eeprom);
break;
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 0e149b22bd19..a3548c7f9dbb 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -231,7 +231,7 @@ cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
* can use the whole SDRAM for the DMA fifos. To simplify things, we
* use a static memory layout. That surely will waste memory in case
* we don't use all DMA channels at the same time (which will be the
- * case most of the time). But that still gives us enougth FIFO space
+ * case most of the time). But that still gives us enough FIFO space
* to be able to deal with insane long pci latencies ...
*
* FIFO space allocations:
@@ -241,6 +241,7 @@ cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
* channel 24 (vbi) - 4.0k
* channels 25+26 (audio) - 4.0k
* channel 28 (mpeg) - 4.0k
+ * channel 27 (audio rds)- 3.0k
* TOTAL = 29.0k
*
* Every channel has 160 bytes control data (64 bytes instruction
@@ -337,6 +338,18 @@ struct sram_channel cx88_sram_channels[] = {
.cnt1_reg = MO_DMA28_CNT1,
.cnt2_reg = MO_DMA28_CNT2,
},
+ [SRAM_CH27] = {
+ .name = "audio rds",
+ .cmds_start = 0x1801C0,
+ .ctrl_start = 0x180860,
+ .cdt = 0x180860 + 64,
+ .fifo_start = 0x187400,
+ .fifo_size = 0x000C00,
+ .ptr1_reg = MO_DMA27_PTR1,
+ .ptr2_reg = MO_DMA27_PTR2,
+ .cnt1_reg = MO_DMA27_CNT1,
+ .cnt2_reg = MO_DMA27_CNT2,
+ },
};
int cx88_sram_channel_setup(struct cx88_core *core,
@@ -598,6 +611,7 @@ int cx88_reset(struct cx88_core *core)
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 188*4, 0);
+ cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0);
/* misc init ... */
cx_write(MO_INPUT_FORMAT, ((1 << 13) | // agc enable
@@ -796,6 +810,8 @@ int cx88_start_audio_dma(struct cx88_core *core)
/* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4;
+ int rds_bpl = cx88_sram_channels[SRAM_CH27].fifo_size/AUD_RDS_LINES;
+
/* If downstream RISC is enabled, bail out; ALSA is managing DMA */
if (cx_read(MO_AUD_DMACNTRL) & 0x10)
return 0;
@@ -803,12 +819,14 @@ int cx88_start_audio_dma(struct cx88_core *core)
/* setup fifo + format */
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], bpl, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], bpl, 0);
+ cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27],
+ rds_bpl, 0);
cx_write(MO_AUDD_LNGTH, bpl); /* fifo bpl size */
- cx_write(MO_AUDR_LNGTH, bpl); /* fifo bpl size */
+ cx_write(MO_AUDR_LNGTH, rds_bpl); /* fifo bpl size */
- /* start dma */
- cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
+ /* enable Up, Down and Audio RDS fifo */
+ cx_write(MO_AUD_DMACNTRL, 0x0007);
return 0;
}
diff --git a/drivers/media/video/cx88/cx88-dsp.c b/drivers/media/video/cx88/cx88-dsp.c
new file mode 100644
index 000000000000..3e5eaf3fe2a6
--- /dev/null
+++ b/drivers/media/video/cx88/cx88-dsp.c
@@ -0,0 +1,312 @@
+/*
+ *
+ * Stereo and SAP detection for cx88
+ *
+ * Copyright (c) 2009 Marton Balint <cus@fazekas.hu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/jiffies.h>
+#include <asm/div64.h>
+
+#include "cx88.h"
+#include "cx88-reg.h"
+
+#define INT_PI ((s32)(3.141592653589 * 32768.0))
+
+#define compat_remainder(a, b) \
+ ((float)(((s32)((a)*100))%((s32)((b)*100)))/100.0)
+
+#define baseband_freq(carrier, srate, tone) ((s32)( \
+ (compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI))
+
+/* We calculate the baseband frequencies of the carrier and the pilot tones
+ * based on the the sampling rate of the audio rds fifo. */
+
+#define FREQ_A2_CARRIER baseband_freq(54687.5, 2689.36, 0.0)
+#define FREQ_A2_DUAL baseband_freq(54687.5, 2689.36, 274.1)
+#define FREQ_A2_STEREO baseband_freq(54687.5, 2689.36, 117.5)
+
+/* The frequencies below are from the reference driver. They probably need
+ * further adjustments, because they are not tested at all. You may even need
+ * to play a bit with the registers of the chip to select the proper signal
+ * for the input of the audio rds fifo, and measure it's sampling rate to
+ * calculate the proper baseband frequencies... */
+
+#define FREQ_A2M_CARRIER ((s32)(2.114516 * 32768.0))
+#define FREQ_A2M_DUAL ((s32)(2.754916 * 32768.0))
+#define FREQ_A2M_STEREO ((s32)(2.462326 * 32768.0))
+
+#define FREQ_EIAJ_CARRIER ((s32)(1.963495 * 32768.0)) /* 5pi/8 */
+#define FREQ_EIAJ_DUAL ((s32)(2.562118 * 32768.0))
+#define FREQ_EIAJ_STEREO ((s32)(2.601053 * 32768.0))
+
+#define FREQ_BTSC_DUAL ((s32)(1.963495 * 32768.0)) /* 5pi/8 */
+#define FREQ_BTSC_DUAL_REF ((s32)(1.374446 * 32768.0)) /* 7pi/16 */
+
+#define FREQ_BTSC_SAP ((s32)(2.471532 * 32768.0))
+#define FREQ_BTSC_SAP_REF ((s32)(1.730072 * 32768.0))
+
+/* The spectrum of the signal should be empty between these frequencies. */
+#define FREQ_NOISE_START ((s32)(0.100000 * 32768.0))
+#define FREQ_NOISE_END ((s32)(1.200000 * 32768.0))
+
+static unsigned int dsp_debug;
+module_param(dsp_debug, int, 0644);
+MODULE_PARM_DESC(dsp_debug, "enable audio dsp debug messages");
+
+#define dprintk(level, fmt, arg...) if (dsp_debug >= level) \
+ printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
+
+static s32 int_cos(u32 x)
+{
+ u32 t2, t4, t6, t8;
+ s32 ret;
+ u16 period = x / INT_PI;
+ if (period % 2)
+ return -int_cos(x - INT_PI);
+ x = x % INT_PI;
+ if (x > INT_PI/2)
+ return -int_cos(INT_PI/2 - (x % (INT_PI/2)));
+ /* Now x is between 0 and INT_PI/2.
+ * To calculate cos(x) we use it's Taylor polinom. */
+ t2 = x*x/32768/2;
+ t4 = t2*x/32768*x/32768/3/4;
+ t6 = t4*x/32768*x/32768/5/6;
+ t8 = t6*x/32768*x/32768/7/8;
+ ret = 32768-t2+t4-t6+t8;
+ return ret;
+}
+
+static u32 int_goertzel(s16 x[], u32 N, u32 freq)
+{
+ /* We use the Goertzel algorithm to determine the power of the
+ * given frequency in the signal */
+ s32 s_prev = 0;
+ s32 s_prev2 = 0;
+ s32 coeff = 2*int_cos(freq);
+ u32 i;
+
+ u64 tmp;
+ u32 divisor;
+
+ for (i = 0; i < N; i++) {
+ s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2;
+ s_prev2 = s_prev;
+ s_prev = s;
+ }
+
+ tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev -
+ (s64)coeff * s_prev2 * s_prev / 32768;
+
+ /* XXX: N must be low enough so that N*N fits in s32.
+ * Else we need two divisions. */
+ divisor = N * N;
+ do_div(tmp, divisor);
+
+ return (u32) tmp;
+}
+
+static u32 freq_magnitude(s16 x[], u32 N, u32 freq)
+{
+ u32 sum = int_goertzel(x, N, freq);
+ return (u32)int_sqrt(sum);
+}
+
+static u32 noise_magnitude(s16 x[], u32 N, u32 freq_start, u32 freq_end)
+{
+ int i;
+ u32 sum = 0;
+ u32 freq_step;
+ int samples = 5;
+
+ if (N > 192) {
+ /* The last 192 samples are enough for noise detection */
+ x += (N-192);
+ N = 192;
+ }
+
+ freq_step = (freq_end - freq_start) / (samples - 1);
+
+ for (i = 0; i < samples; i++) {
+ sum += int_goertzel(x, N, freq_start);
+ freq_start += freq_step;
+ }
+
+ return (u32)int_sqrt(sum / samples);
+}
+
+static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
+{
+ s32 carrier, stereo, dual, noise;
+ s32 carrier_freq, stereo_freq, dual_freq;
+ s32 ret;
+
+ switch (core->tvaudio) {
+ case WW_BG:
+ case WW_DK:
+ carrier_freq = FREQ_A2_CARRIER;
+ stereo_freq = FREQ_A2_STEREO;
+ dual_freq = FREQ_A2_DUAL;
+ break;
+ case WW_M:
+ carrier_freq = FREQ_A2M_CARRIER;
+ stereo_freq = FREQ_A2M_STEREO;
+ dual_freq = FREQ_A2M_DUAL;
+ break;
+ case WW_EIAJ:
+ carrier_freq = FREQ_EIAJ_CARRIER;
+ stereo_freq = FREQ_EIAJ_STEREO;
+ dual_freq = FREQ_EIAJ_DUAL;
+ break;
+ default:
+ printk(KERN_WARNING "%s/0: unsupported audio mode %d for %s\n",
+ core->name, core->tvaudio, __func__);
+ return UNSET;
+ }
+
+ carrier = freq_magnitude(x, N, carrier_freq);
+ stereo = freq_magnitude(x, N, stereo_freq);
+ dual = freq_magnitude(x, N, dual_freq);
+ noise = noise_magnitude(x, N, FREQ_NOISE_START, FREQ_NOISE_END);
+
+ dprintk(1, "detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, "
+ "noise=%d\n", carrier, stereo, dual, noise);
+
+ if (stereo > dual)
+ ret = V4L2_TUNER_SUB_STEREO;
+ else
+ ret = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+
+ if (core->tvaudio == WW_EIAJ) {
+ /* EIAJ checks may need adjustments */
+ if ((carrier > max(stereo, dual)*2) &&
+ (carrier < max(stereo, dual)*6) &&
+ (carrier > 20 && carrier < 200) &&
+ (max(stereo, dual) > min(stereo, dual))) {
+ /* For EIAJ the carrier is always present,
+ so we probably don't need noise detection */
+ return ret;
+ }
+ } else {
+ if ((carrier > max(stereo, dual)*2) &&
+ (carrier < max(stereo, dual)*8) &&
+ (carrier > 20 && carrier < 200) &&
+ (noise < 10) &&
+ (max(stereo, dual) > min(stereo, dual)*2)) {
+ return ret;
+ }
+ }
+ return V4L2_TUNER_SUB_MONO;
+}
+
+static s32 detect_btsc(struct cx88_core *core, s16 x[], u32 N)
+{
+ s32 sap_ref = freq_magnitude(x, N, FREQ_BTSC_SAP_REF);
+ s32 sap = freq_magnitude(x, N, FREQ_BTSC_SAP);
+ s32 dual_ref = freq_magnitude(x, N, FREQ_BTSC_DUAL_REF);
+ s32 dual = freq_magnitude(x, N, FREQ_BTSC_DUAL);
+ dprintk(1, "detect btsc: dual_ref=%d, dual=%d, sap_ref=%d, sap=%d"
+ "\n", dual_ref, dual, sap_ref, sap);
+ /* FIXME: Currently not supported */
+ return UNSET;
+}
+
+static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
+{
+ struct sram_channel *srch = &cx88_sram_channels[SRAM_CH27];
+ s16 *samples;
+
+ unsigned int i;
+ unsigned int bpl = srch->fifo_size/AUD_RDS_LINES;
+ unsigned int spl = bpl/4;
+ unsigned int sample_count = spl*(AUD_RDS_LINES-1);
+
+ u32 current_address = cx_read(srch->ptr1_reg);
+ u32 offset = (current_address - srch->fifo_start + bpl);
+
+ dprintk(1, "read RDS samples: current_address=%08x (offset=%08x), "
+ "sample_count=%d, aud_intstat=%08x\n", current_address,
+ current_address - srch->fifo_start, sample_count,
+ cx_read(MO_AUD_INTSTAT));
+
+ samples = kmalloc(sizeof(s16)*sample_count, GFP_KERNEL);
+ if (!samples)
+ return NULL;
+
+ *N = sample_count;
+
+ for (i = 0; i < sample_count; i++) {
+ offset = offset % (AUD_RDS_LINES*bpl);
+ samples[i] = cx_read(srch->fifo_start + offset);
+ offset += 4;
+ }
+
+ if (dsp_debug >= 2) {
+ dprintk(2, "RDS samples dump: ");
+ for (i = 0; i < sample_count; i++)
+ printk("%hd ", samples[i]);
+ printk(".\n");
+ }
+
+ return samples;
+}
+
+s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core)
+{
+ s16 *samples;
+ u32 N = 0;
+ s32 ret = UNSET;
+
+ /* If audio RDS fifo is disabled, we can't read the samples */
+ if (!(cx_read(MO_AUD_DMACNTRL) & 0x04))
+ return ret;
+ if (!(cx_read(AUD_CTL) & EN_FMRADIO_EN_RDS))
+ return ret;
+
+ /* Wait at least 500 ms after an audio standard change */
+ if (time_before(jiffies, core->last_change + msecs_to_jiffies(500)))
+ return ret;
+
+ samples = read_rds_samples(core, &N);
+
+ if (!samples)
+ return ret;
+
+ switch (core->tvaudio) {
+ case WW_BG:
+ case WW_DK:
+ ret = detect_a2_a2m_eiaj(core, samples, N);
+ break;
+ case WW_BTSC:
+ ret = detect_btsc(core, samples, N);
+ break;
+ }
+
+ kfree(samples);
+
+ if (UNSET != ret)
+ dprintk(1, "stereo/sap detection result:%s%s%s\n",
+ (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "",
+ (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "",
+ (ret & V4L2_TUNER_SUB_LANG2) ? " dual" : "");
+
+ return ret;
+}
+EXPORT_SYMBOL(cx88_dsp_detect_stereo_sap);
+
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index ec05312a9b62..8a7c2bc457a6 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -91,6 +91,7 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
gpio=(gpio & 0x7fd) + (auxgpio & 0xef);
break;
case CX88_BOARD_WINFAST_DTV1000:
+ case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
gpio = (gpio & 0x6ff) | ((cx_read(MO_GP1_IO) << 8) & 0x900);
auxgpio = gpio;
break;
@@ -217,6 +218,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
case CX88_BOARD_PCHDTV_HD3000:
case CX88_BOARD_PCHDTV_HD5500:
+ case CX88_BOARD_HAUPPAUGE_IRONLY:
ir_codes = ir_codes_hauppauge_new;
ir_type = IR_TYPE_RC5;
ir->sampling = 1;
@@ -230,6 +232,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
break;
case CX88_BOARD_WINFAST2000XP_EXPERT:
case CX88_BOARD_WINFAST_DTV1000:
+ case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
ir_codes = ir_codes_winfast;
ir->gpio_addr = MO_GP0_IO;
ir->mask_keycode = 0x8f8;
@@ -459,6 +462,7 @@ void cx88_ir_irq(struct cx88_core *core)
case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
case CX88_BOARD_PCHDTV_HD3000:
case CX88_BOARD_PCHDTV_HD5500:
+ case CX88_BOARD_HAUPPAUGE_IRONLY:
ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
ir_dprintk("biphase decoded: %x\n", ircode);
/*
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 7dd506b987fe..e8316cf7f32f 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -163,6 +163,8 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
/* unmute */
volume = cx_sread(SHADOW_AUD_VOL_CTL);
cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, volume);
+
+ core->last_change = jiffies;
}
/* ----------------------------------------------------------- */
@@ -745,6 +747,7 @@ void cx88_set_tvaudio(struct cx88_core *core)
break;
case WW_BG:
case WW_DK:
+ case WW_M:
case WW_I:
case WW_L:
/* prepare all dsp registers */
@@ -756,6 +759,7 @@ void cx88_set_tvaudio(struct cx88_core *core)
if (0 == cx88_detect_nicam(core)) {
/* fall back to fm / am mono */
set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
+ core->audiomode_current = V4L2_TUNER_MODE_MONO;
core->use_nicam = 0;
} else {
core->use_nicam = 1;
@@ -787,6 +791,7 @@ void cx88_set_tvaudio(struct cx88_core *core)
void cx88_newstation(struct cx88_core *core)
{
core->audiomode_manual = UNSET;
+ core->last_change = jiffies;
}
void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
@@ -805,12 +810,50 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
aud_ctl_names[cx_read(AUD_CTL) & 63]);
core->astat = reg;
-/* TODO
- Reading from AUD_STATUS is not enough
- for auto-detecting sap/dual-fm/nicam.
- Add some code here later.
-*/
+ t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP |
+ V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
+ t->rxsubchans = UNSET;
+ t->audmode = V4L2_TUNER_MODE_MONO;
+
+ switch (mode) {
+ case 0:
+ t->audmode = V4L2_TUNER_MODE_STEREO;
+ break;
+ case 1:
+ t->audmode = V4L2_TUNER_MODE_LANG2;
+ break;
+ case 2:
+ t->audmode = V4L2_TUNER_MODE_MONO;
+ break;
+ case 3:
+ t->audmode = V4L2_TUNER_MODE_SAP;
+ break;
+ }
+ switch (core->tvaudio) {
+ case WW_BTSC:
+ case WW_BG:
+ case WW_DK:
+ case WW_M:
+ case WW_EIAJ:
+ if (!core->use_nicam) {
+ t->rxsubchans = cx88_dsp_detect_stereo_sap(core);
+ break;
+ }
+ break;
+ default:
+ /* nothing */
+ break;
+ }
+
+ /* If software stereo detection is not supported... */
+ if (UNSET == t->rxsubchans) {
+ t->rxsubchans = V4L2_TUNER_SUB_MONO;
+ /* If the hardware itself detected stereo, also return
+ stereo as an available subchannel */
+ if (V4L2_TUNER_MODE_STEREO == t->audmode)
+ t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
+ }
return;
}
@@ -847,6 +890,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
break;
case WW_BG:
case WW_DK:
+ case WW_M:
case WW_I:
case WW_L:
if (1 == core->use_nicam) {
@@ -872,20 +916,18 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
} else {
/* TODO: Add A2 autodection */
+ mask = 0x3f;
switch (mode) {
case V4L2_TUNER_MODE_MONO:
case V4L2_TUNER_MODE_LANG1:
- set_audio_standard_A2(core,
- EN_A2_FORCE_MONO1);
+ ctl = EN_A2_FORCE_MONO1;
break;
case V4L2_TUNER_MODE_LANG2:
- set_audio_standard_A2(core,
- EN_A2_FORCE_MONO2);
+ ctl = EN_A2_FORCE_MONO2;
break;
case V4L2_TUNER_MODE_STEREO:
case V4L2_TUNER_MODE_LANG1_LANG2:
- set_audio_standard_A2(core,
- EN_A2_FORCE_STEREO);
+ ctl = EN_A2_FORCE_STEREO;
break;
}
}
@@ -932,24 +974,39 @@ int cx88_audio_thread(void *data)
break;
try_to_freeze();
- /* just monitor the audio status for now ... */
- memset(&t, 0, sizeof(t));
- cx88_get_stereo(core, &t);
-
- if (UNSET != core->audiomode_manual)
- /* manually set, don't do anything. */
- continue;
-
- /* monitor signal */
- if (t.rxsubchans & V4L2_TUNER_SUB_STEREO)
- mode = V4L2_TUNER_MODE_STEREO;
- else
- mode = V4L2_TUNER_MODE_MONO;
- if (mode == core->audiomode_current)
- continue;
-
- /* automatically switch to best available mode */
- cx88_set_stereo(core, mode, 0);
+ switch (core->tvaudio) {
+ case WW_BG:
+ case WW_DK:
+ case WW_M:
+ case WW_I:
+ case WW_L:
+ if (core->use_nicam)
+ goto hw_autodetect;
+
+ /* just monitor the audio status for now ... */
+ memset(&t, 0, sizeof(t));
+ cx88_get_stereo(core, &t);
+
+ if (UNSET != core->audiomode_manual)
+ /* manually set, don't do anything. */
+ continue;
+
+ /* monitor signal and set stereo if available */
+ if (t.rxsubchans & V4L2_TUNER_SUB_STEREO)
+ mode = V4L2_TUNER_MODE_STEREO;
+ else
+ mode = V4L2_TUNER_MODE_MONO;
+ if (mode == core->audiomode_current)
+ continue;
+ /* automatically switch to best available mode */
+ cx88_set_stereo(core, mode, 0);
+ break;
+ default:
+hw_autodetect:
+ /* stereo autodetection is supported by hardware so
+ we don't need to do it manually. Do nothing. */
+ break;
+ }
}
dprintk("cx88: tvaudio thread exiting\n");
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 7724d168fc04..cc17272ed3b7 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -65,6 +65,8 @@
#define VBI_LINE_COUNT 17
#define VBI_LINE_LENGTH 2048
+#define AUD_RDS_LINES 4
+
/* need "shadow" registers for some write-only ones ... */
#define SHADOW_AUD_VOL_CTL 1
#define SHADOW_AUD_BAL_CTL 2
@@ -132,6 +134,7 @@ struct cx88_ctrl {
#define SRAM_CH25 4 /* audio */
#define SRAM_CH26 5
#define SRAM_CH28 6 /* mpeg */
+#define SRAM_CH27 7 /* audio rds */
/* more */
struct sram_channel {
@@ -232,6 +235,7 @@ extern struct sram_channel cx88_sram_channels[];
#define CX88_BOARD_TBS_8910 77
#define CX88_BOARD_PROF_6200 78
#define CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII 79
+#define CX88_BOARD_HAUPPAUGE_IRONLY 80
enum cx88_itype {
CX88_VMUX_COMPOSITE1 = 1,
@@ -350,6 +354,7 @@ struct cx88_core {
u32 input;
u32 astat;
u32 use_nicam;
+ unsigned long last_change;
/* IR remote control state */
struct cx88_IR *ir;
@@ -652,6 +657,7 @@ extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl);
#define WW_I2SPT 8
#define WW_FM 9
#define WW_I2SADC 10
+#define WW_M 11
void cx88_set_tvaudio(struct cx88_core *core);
void cx88_newstation(struct cx88_core *core);
@@ -665,6 +671,11 @@ struct cx8802_dev *cx8802_get_device(int minor);
struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype);
/* ----------------------------------------------------------- */
+/* cx88-dsp.c */
+
+s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core);
+
+/* ----------------------------------------------------------- */
/* cx88-input.c */
int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index ba3709bec3f0..ec2f45dde164 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -747,8 +747,14 @@ static const struct file_operations dabusb_fops =
.release = dabusb_release,
};
+static char *dabusb_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
static struct usb_class_driver dabusb_class = {
.name = "dabusb%d",
+ .nodename = dabusb_nodename,
.fops = &dabusb_fops,
.minor_base = DABUSB_MINOR,
};
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 7c70738479dd..7cb93fbbbbf8 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -1095,6 +1095,31 @@ struct em28xx_board em28xx_boards[] = {
.gpio = default_analog,
} },
},
+ [EM2880_BOARD_EMPIRE_DUAL_TV] = {
+ .name = "Empire dual TV",
+ .tuner_type = TUNER_XC2028,
+ .tuner_gpio = default_tuner_gpio,
+ .has_dvb = 1,
+ .dvb_gpio = default_digital,
+ .mts_firmware = 1,
+ .decoder = EM28XX_TVP5150,
+ .input = { {
+ .type = EM28XX_VMUX_TELEVISION,
+ .vmux = TVP5150_COMPOSITE0,
+ .amux = EM28XX_AMUX_VIDEO,
+ .gpio = default_analog,
+ }, {
+ .type = EM28XX_VMUX_COMPOSITE1,
+ .vmux = TVP5150_COMPOSITE1,
+ .amux = EM28XX_AMUX_LINE_IN,
+ .gpio = default_analog,
+ }, {
+ .type = EM28XX_VMUX_SVIDEO,
+ .vmux = TVP5150_SVIDEO,
+ .amux = EM28XX_AMUX_LINE_IN,
+ .gpio = default_analog,
+ } },
+ },
[EM2881_BOARD_DNT_DA2_HYBRID] = {
.name = "DNT DA2 Hybrid",
.valid = EM28XX_BOARD_NOT_VALIDATED,
@@ -1437,6 +1462,7 @@ static struct em28xx_hash_table em28xx_eeprom_hash[] = {
{0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
{0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
{0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
+ {0x9567eb1a, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
};
/* I2C devicelist hash table for devices with generic USB IDs */
@@ -1664,6 +1690,7 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
ctl->mts = em28xx_boards[dev->model].mts_firmware;
switch (dev->model) {
+ case EM2880_BOARD_EMPIRE_DUAL_TV:
case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
ctl->demod = XC3028_FE_ZARLINK456;
break;
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 192b76cdd5d7..7375353c04eb 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -938,7 +938,7 @@ int em28xx_init_isoc(struct em28xx *dev, int max_packets,
dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
GFP_KERNEL);
if (!dev->isoc_ctl.transfer_buffer) {
- em28xx_errdev("cannot allocate memory for usbtransfer\n");
+ em28xx_errdev("cannot allocate memory for usb transfer\n");
kfree(dev->isoc_ctl.urb);
return -ENOMEM;
}
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index fcd25511209b..c8188dc2b4b5 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -431,6 +431,7 @@ static int dvb_init(struct em28xx *dev)
case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
case EM2880_BOARD_TERRATEC_HYBRID_XS:
case EM2880_BOARD_KWORLD_DVB_310U:
+ case EM2880_BOARD_EMPIRE_DUAL_TV:
dvb->frontend = dvb_attach(zl10353_attach,
&em28xx_zl10353_with_xc3028,
&dev->i2c_adap);
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 4c4e58004f54..16f4c23f179b 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -102,6 +102,7 @@
#define EM2860_BOARD_KAIOMY_TVNPC_U2 63
#define EM2860_BOARD_EASYCAP 64
#define EM2820_BOARD_IODATA_GVMVP_SZ 65
+#define EM2880_BOARD_EMPIRE_DUAL_TV 66
/* Limits minimum and default number of buffers */
#define EM28XX_MIN_BUF 4
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index 00e6863ed666..480ec5c87d0e 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -168,6 +168,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = fpix_mode;
cam->nmodes = 1;
+ cam->bulk = 1;
cam->bulk_size = FPIX_MAX_TRANSFER;
INIT_WORK(&dev->work_struct, dostream);
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index a2741d7dccfe..ae0e14033d66 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -1,7 +1,7 @@
/*
* Main USB camera driver
*
- * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
+ * Copyright (C) 2008-2009 Jean-Francois Moine (http://moinejf.free.fr)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -47,7 +47,7 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
MODULE_DESCRIPTION("GSPCA USB Camera Driver");
MODULE_LICENSE("GPL");
-#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 5, 0)
+#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 6, 0)
#ifdef GSPCA_DEBUG
int gspca_debug = D_ERR | D_PROBE;
@@ -441,7 +441,7 @@ static void destroy_urbs(struct gspca_dev *gspca_dev)
* look for an input transfer endpoint in an alternate setting
*/
static struct usb_host_endpoint *alt_xfer(struct usb_host_interface *alt,
- __u8 xfer)
+ int xfer)
{
struct usb_host_endpoint *ep;
int i, attr;
@@ -449,7 +449,8 @@ static struct usb_host_endpoint *alt_xfer(struct usb_host_interface *alt,
for (i = 0; i < alt->desc.bNumEndpoints; i++) {
ep = &alt->endpoint[i];
attr = ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
- if (attr == xfer)
+ if (attr == xfer
+ && ep->desc.wMaxPacketSize != 0)
return ep;
}
return NULL;
@@ -467,37 +468,28 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev)
{
struct usb_interface *intf;
struct usb_host_endpoint *ep;
- int i, ret;
+ int xfer, i, ret;
intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface);
ep = NULL;
+ xfer = gspca_dev->cam.bulk ? USB_ENDPOINT_XFER_BULK
+ : USB_ENDPOINT_XFER_ISOC;
i = gspca_dev->alt; /* previous alt setting */
-
- /* try isoc */
while (--i >= 0) {
- ep = alt_xfer(&intf->altsetting[i],
- USB_ENDPOINT_XFER_ISOC);
+ ep = alt_xfer(&intf->altsetting[i], xfer);
if (ep)
break;
}
-
- /* if no isoc, try bulk (alt 0 only) */
if (ep == NULL) {
- ep = alt_xfer(&intf->altsetting[0],
- USB_ENDPOINT_XFER_BULK);
- if (ep == NULL) {
- err("no transfer endpoint found");
- return NULL;
- }
- i = 0;
- gspca_dev->bulk = 1;
+ err("no transfer endpoint found");
+ return NULL;
}
PDEBUG(D_STREAM, "use alt %d ep 0x%02x",
i, ep->desc.bEndpointAddress);
- if (i > 0) {
+ if (gspca_dev->nbalt > 1) {
ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, i);
if (ret < 0) {
- err("set interface err %d", ret);
+ err("set alt %d err %d", i, ret);
return NULL;
}
}
@@ -517,13 +509,13 @@ static int create_urbs(struct gspca_dev *gspca_dev,
/* calculate the packet size and the number of packets */
psize = le16_to_cpu(ep->desc.wMaxPacketSize);
- if (!gspca_dev->bulk) { /* isoc */
+ if (!gspca_dev->cam.bulk) { /* isoc */
/* See paragraph 5.9 / table 5-11 of the usb 2.0 spec. */
psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
- npkt = ISO_MAX_SIZE / psize;
- if (npkt > ISO_MAX_PKT)
- npkt = ISO_MAX_PKT;
+ npkt = gspca_dev->cam.npkt;
+ if (npkt == 0)
+ npkt = 32; /* default value */
bsize = psize * npkt;
PDEBUG(D_STREAM,
"isoc %d pkts size %d = bsize:%d",
@@ -617,7 +609,7 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
goto out;
/* clear the bulk endpoint */
- if (gspca_dev->bulk)
+ if (gspca_dev->cam.bulk)
usb_clear_halt(gspca_dev->dev,
gspca_dev->urb[0]->pipe);
@@ -630,7 +622,7 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
gspca_dev->streaming = 1;
/* some bulk transfers are started by the subdriver */
- if (gspca_dev->bulk && gspca_dev->cam.bulk_nurbs == 0)
+ if (gspca_dev->cam.bulk && gspca_dev->cam.bulk_nurbs == 0)
break;
/* submit the URBs */
@@ -661,6 +653,8 @@ static int gspca_set_alt0(struct gspca_dev *gspca_dev)
{
int ret;
+ if (gspca_dev->alt == 0)
+ return 0;
ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0);
if (ret < 0)
PDEBUG(D_ERR|D_STREAM, "set alt 0 err %d", ret);
@@ -1943,7 +1937,7 @@ int gspca_dev_probe(struct usb_interface *intf,
/* init video stuff */
memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template);
- gspca_dev->vdev.parent = &dev->dev;
+ gspca_dev->vdev.parent = &intf->dev;
gspca_dev->module = module;
gspca_dev->present = 1;
ret = video_register_device(&gspca_dev->vdev,
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 58e8ff02136a..bd1faff88644 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -44,8 +44,6 @@ extern int gspca_debug;
#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
/* image transfers */
#define MAX_NURBS 4 /* max number of URBs */
-#define ISO_MAX_PKT 32 /* max number of packets in an ISOC transfer */
-#define ISO_MAX_SIZE 0x8000 /* max size of one URB buffer (32 Kb) */
/* device information - set at probe time */
struct cam {
@@ -56,6 +54,9 @@ struct cam {
* - cannot be > MAX_NURBS
* - when 0 and bulk_size != 0 means
* 1 URB and submit done by subdriver */
+ u8 bulk; /* image transfer by 0:isoc / 1:bulk */
+ u8 npkt; /* number of packets in an ISOC message
+ * 0 is the default value: 32 packets */
u32 input_flags; /* value for ENUM_INPUT status flags */
};
@@ -168,7 +169,6 @@ struct gspca_dev {
__u8 iface; /* USB interface number */
__u8 alt; /* USB alternate setting */
__u8 nbalt; /* number of USB alternate settings */
- u8 bulk; /* image transfer by 0:isoc / 1:bulk */
};
int gspca_dev_probe(struct usb_interface *intf,
diff --git a/drivers/media/video/gspca/m5602/Makefile b/drivers/media/video/gspca/m5602/Makefile
index 9fa3644f4869..bf7a19a1e6d1 100644
--- a/drivers/media/video/gspca/m5602/Makefile
+++ b/drivers/media/video/gspca/m5602/Makefile
@@ -2,9 +2,10 @@ obj-$(CONFIG_USB_M5602) += gspca_m5602.o
gspca_m5602-objs := m5602_core.o \
m5602_ov9650.o \
+ m5602_ov7660.o \
m5602_mt9m111.o \
m5602_po1030.o \
m5602_s5k83a.o \
m5602_s5k4aa.o
-EXTRA_CFLAGS += -Idrivers/media/video/gspca \ No newline at end of file
+EXTRA_CFLAGS += -Idrivers/media/video/gspca
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h
index 8f1cea6fd3bf..1127a405c9b2 100644
--- a/drivers/media/video/gspca/m5602/m5602_bridge.h
+++ b/drivers/media/video/gspca/m5602/m5602_bridge.h
@@ -45,6 +45,15 @@
#define M5602_XB_SEN_CLK_DIV 0x15
#define M5602_XB_AUD_CLK_CTRL 0x16
#define M5602_XB_AUD_CLK_DIV 0x17
+#define M5602_OB_AC_LINK_STATE 0x22
+#define M5602_OB_PCM_SLOT_INDEX 0x24
+#define M5602_OB_GPIO_SLOT_INDEX 0x25
+#define M5602_OB_ACRX_STATUS_ADDRESS_H 0x28
+#define M5602_OB_ACRX_STATUS_DATA_L 0x29
+#define M5602_OB_ACRX_STATUS_DATA_H 0x2a
+#define M5602_OB_ACTX_COMMAND_ADDRESS 0x31
+#define M5602_OB_ACRX_COMMAND_DATA_L 0x32
+#define M5602_OB_ACTX_COMMAND_DATA_H 0X33
#define M5602_XB_DEVCTR1 0x41
#define M5602_XB_EPSETR0 0x42
#define M5602_XB_EPAFCTR 0x47
@@ -77,7 +86,18 @@
#define M5602_XB_GPIO_EN_L 0x75
#define M5602_XB_GPIO_DAT 0x76
#define M5602_XB_GPIO_DIR 0x77
-#define M5602_XB_MISC_CTL 0x70
+#define M5602_XB_SEN_CLK_CONTROL 0x80
+#define M5602_XB_SEN_CLK_DIVISION 0x81
+#define M5602_XB_CPR_CLK_CONTROL 0x82
+#define M5602_XB_CPR_CLK_DIVISION 0x83
+#define M5602_XB_MCU_CLK_CONTROL 0x84
+#define M5602_XB_MCU_CLK_DIVISION 0x85
+#define M5602_XB_DCT_CLK_CONTROL 0x86
+#define M5602_XB_DCT_CLK_DIVISION 0x87
+#define M5602_XB_EC_CLK_CONTROL 0x88
+#define M5602_XB_EC_CLK_DIVISION 0x89
+#define M5602_XB_LBUF_CLK_CONTROL 0x8a
+#define M5602_XB_LBUF_CLK_DIVISION 0x8b
#define I2C_BUSY 0x80
@@ -128,10 +148,10 @@ struct sd {
};
int m5602_read_bridge(
- struct sd *sd, u8 address, u8 *i2c_data);
+ struct sd *sd, const u8 address, u8 *i2c_data);
int m5602_write_bridge(
- struct sd *sd, u8 address, u8 i2c_data);
+ struct sd *sd, const u8 address, const u8 i2c_data);
int m5602_write_sensor(struct sd *sd, const u8 address,
u8 *i2c_data, const u8 len);
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c
index 1aac2985fee6..8a5bba16ff32 100644
--- a/drivers/media/video/gspca/m5602/m5602_core.c
+++ b/drivers/media/video/gspca/m5602/m5602_core.c
@@ -17,6 +17,7 @@
*/
#include "m5602_ov9650.h"
+#include "m5602_ov7660.h"
#include "m5602_mt9m111.h"
#include "m5602_po1030.h"
#include "m5602_s5k83a.h"
@@ -35,7 +36,7 @@ static const __devinitdata struct usb_device_id m5602_table[] = {
MODULE_DEVICE_TABLE(usb, m5602_table);
/* Reads a byte from the m5602 */
-int m5602_read_bridge(struct sd *sd, u8 address, u8 *i2c_data)
+int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data)
{
int err;
struct usb_device *udev = sd->gspca_dev.dev;
@@ -56,7 +57,7 @@ int m5602_read_bridge(struct sd *sd, u8 address, u8 *i2c_data)
}
/* Writes a byte to to the m5602 */
-int m5602_write_bridge(struct sd *sd, u8 address, u8 i2c_data)
+int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data)
{
int err;
struct usb_device *udev = sd->gspca_dev.dev;
@@ -80,6 +81,17 @@ int m5602_write_bridge(struct sd *sd, u8 address, u8 i2c_data)
return (err < 0) ? err : 0;
}
+int m5602_wait_for_i2c(struct sd *sd)
+{
+ int err;
+ u8 data;
+
+ do {
+ err = m5602_read_bridge(sd, M5602_XB_I2C_STATUS, &data);
+ } while ((data & I2C_BUSY) && !err);
+ return err;
+}
+
int m5602_read_sensor(struct sd *sd, const u8 address,
u8 *i2c_data, const u8 len)
{
@@ -88,9 +100,7 @@ int m5602_read_sensor(struct sd *sd, const u8 address,
if (!len || len > sd->sensor->i2c_regW)
return -EINVAL;
- do {
- err = m5602_read_bridge(sd, M5602_XB_I2C_STATUS, i2c_data);
- } while ((*i2c_data & I2C_BUSY) && !err);
+ err = m5602_wait_for_i2c(sd);
if (err < 0)
return err;
@@ -103,21 +113,25 @@ int m5602_read_sensor(struct sd *sd, const u8 address,
if (err < 0)
return err;
+ /* Sensors with registers that are of only
+ one byte width are differently read */
+
+ /* FIXME: This works with the ov9650, but has issues with the po1030 */
if (sd->sensor->i2c_regW == 1) {
- err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, len);
+ err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 1);
if (err < 0)
return err;
err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x08);
- if (err < 0)
- return err;
} else {
err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x18 + len);
- if (err < 0)
- return err;
}
for (i = 0; (i < len) && !err; i++) {
+ err = m5602_wait_for_i2c(sd);
+ if (err < 0)
+ return err;
+
err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
PDEBUG(D_CONF, "Reading sensor register "
@@ -206,6 +220,11 @@ static int m5602_probe_sensor(struct sd *sd)
if (!sd->sensor->probe(sd))
return 0;
+ /* Try the ov7660 */
+ sd->sensor = &ov7660;
+ if (!sd->sensor->probe(sd))
+ return 0;
+
/* Try the s5k83a */
sd->sensor = &s5k83a;
if (!sd->sensor->probe(sd))
@@ -409,8 +428,9 @@ MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
module_param(force_sensor, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(force_sensor,
- "force detection of sensor, "
- "1 = OV9650, 2 = S5K83A, 3 = S5K4AA, 4 = MT9M111, 5 = PO1030");
+ "forces detection of a sensor, "
+ "1 = OV9650, 2 = S5K83A, 3 = S5K4AA, "
+ "4 = MT9M111, 5 = PO1030, 6 = OV7660");
module_param(dump_bridge, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup");
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
index 7d3f9e348ef4..8d071dff6944 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
@@ -18,6 +18,23 @@
#include "m5602_mt9m111.h"
+static int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
+static int mt9m111_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
+static int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val);
+static int mt9m111_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val);
+static int mt9m111_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int mt9m111_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int mt9m111_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
+
static struct v4l2_pix_format mt9m111_modes[] = {
{
640,
@@ -32,6 +49,7 @@ static struct v4l2_pix_format mt9m111_modes[] = {
};
const static struct ctrl mt9m111_ctrls[] = {
+#define VFLIP_IDX 0
{
{
.id = V4L2_CID_VFLIP,
@@ -44,7 +62,9 @@ const static struct ctrl mt9m111_ctrls[] = {
},
.set = mt9m111_set_vflip,
.get = mt9m111_get_vflip
- }, {
+ },
+#define HFLIP_IDX 1
+ {
{
.id = V4L2_CID_HFLIP,
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -56,7 +76,9 @@ const static struct ctrl mt9m111_ctrls[] = {
},
.set = mt9m111_set_hflip,
.get = mt9m111_get_hflip
- }, {
+ },
+#define GAIN_IDX 2
+ {
{
.id = V4L2_CID_GAIN,
.type = V4L2_CTRL_TYPE_INTEGER,
@@ -64,21 +86,80 @@ const static struct ctrl mt9m111_ctrls[] = {
.minimum = 0,
.maximum = (INITIAL_MAX_GAIN - 1) * 2 * 2 * 2,
.step = 1,
- .default_value = DEFAULT_GAIN,
+ .default_value = MT9M111_DEFAULT_GAIN,
.flags = V4L2_CTRL_FLAG_SLIDER
},
.set = mt9m111_set_gain,
.get = mt9m111_get_gain
- }
+ },
+#define AUTO_WHITE_BALANCE_IDX 3
+ {
+ {
+ .id = V4L2_CID_AUTO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto white balance",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ .set = mt9m111_set_auto_white_balance,
+ .get = mt9m111_get_auto_white_balance
+ },
+#define GREEN_BALANCE_IDX 4
+ {
+ {
+ .id = M5602_V4L2_CID_GREEN_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "green balance",
+ .minimum = 0x00,
+ .maximum = 0x7ff,
+ .step = 0x1,
+ .default_value = MT9M111_GREEN_GAIN_DEFAULT,
+ .flags = V4L2_CTRL_FLAG_SLIDER
+ },
+ .set = mt9m111_set_green_balance,
+ .get = mt9m111_get_green_balance
+ },
+#define BLUE_BALANCE_IDX 5
+ {
+ {
+ .id = V4L2_CID_BLUE_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "blue balance",
+ .minimum = 0x00,
+ .maximum = 0x7ff,
+ .step = 0x1,
+ .default_value = MT9M111_BLUE_GAIN_DEFAULT,
+ .flags = V4L2_CTRL_FLAG_SLIDER
+ },
+ .set = mt9m111_set_blue_balance,
+ .get = mt9m111_get_blue_balance
+ },
+#define RED_BALANCE_IDX 5
+ {
+ {
+ .id = V4L2_CID_RED_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "red balance",
+ .minimum = 0x00,
+ .maximum = 0x7ff,
+ .step = 0x1,
+ .default_value = MT9M111_RED_GAIN_DEFAULT,
+ .flags = V4L2_CTRL_FLAG_SLIDER
+ },
+ .set = mt9m111_set_red_balance,
+ .get = mt9m111_get_red_balance
+ },
};
-
static void mt9m111_dump_registers(struct sd *sd);
int mt9m111_probe(struct sd *sd)
{
u8 data[2] = {0x00, 0x00};
int i;
+ s32 *sensor_settings;
if (force_sensor) {
if (force_sensor == MT9M111_SENSOR) {
@@ -117,16 +198,27 @@ int mt9m111_probe(struct sd *sd)
return -ENODEV;
sensor_found:
+ sensor_settings = kmalloc(ARRAY_SIZE(mt9m111_ctrls) * sizeof(s32),
+ GFP_KERNEL);
+ if (!sensor_settings)
+ return -ENOMEM;
+
sd->gspca_dev.cam.cam_mode = mt9m111_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(mt9m111_modes);
sd->desc->ctrls = mt9m111_ctrls;
sd->desc->nctrls = ARRAY_SIZE(mt9m111_ctrls);
+
+ for (i = 0; i < ARRAY_SIZE(mt9m111_ctrls); i++)
+ sensor_settings[i] = mt9m111_ctrls[i].qctrl.default_value;
+ sd->sensor_priv = sensor_settings;
+
return 0;
}
int mt9m111_init(struct sd *sd)
{
int i, err = 0;
+ s32 *sensor_settings = sd->sensor_priv;
/* Init the sensor */
for (i = 0; i < ARRAY_SIZE(init_mt9m111) && !err; i++) {
@@ -147,36 +239,154 @@ int mt9m111_init(struct sd *sd)
if (dump_sensor)
mt9m111_dump_registers(sd);
- return (err < 0) ? err : 0;
+ err = mt9m111_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
+ if (err < 0)
+ return err;
+
+ err = mt9m111_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
+ if (err < 0)
+ return err;
+
+ err = mt9m111_set_green_balance(&sd->gspca_dev,
+ sensor_settings[GREEN_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = mt9m111_set_blue_balance(&sd->gspca_dev,
+ sensor_settings[BLUE_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = mt9m111_set_red_balance(&sd->gspca_dev,
+ sensor_settings[RED_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ return mt9m111_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
}
-int mt9m111_power_down(struct sd *sd)
+int mt9m111_start(struct sd *sd)
{
- return 0;
+ int i, err = 0;
+ u8 data[2];
+ struct cam *cam = &sd->gspca_dev.cam;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ int width = cam->cam_mode[sd->gspca_dev.curr_mode].width - 1;
+ int height = cam->cam_mode[sd->gspca_dev.curr_mode].height;
+
+ for (i = 0; i < ARRAY_SIZE(start_mt9m111) && !err; i++) {
+ if (start_mt9m111[i][0] == BRIDGE) {
+ err = m5602_write_bridge(sd,
+ start_mt9m111[i][1],
+ start_mt9m111[i][2]);
+ } else {
+ data[0] = start_mt9m111[i][2];
+ data[1] = start_mt9m111[i][3];
+ err = m5602_write_sensor(sd,
+ start_mt9m111[i][1], data, 2);
+ }
+ }
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff));
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < 2 && !err; i++)
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 2);
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < 2 && !err; i++)
+ err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, 0);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA,
+ (width >> 8) & 0xff);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, width & 0xff);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0);
+ if (err < 0)
+ return err;
+
+ switch (width) {
+ case 640:
+ PDEBUG(D_V4L2, "Configuring camera for VGA mode");
+ data[0] = MT9M111_RMB_OVER_SIZED;
+ data[1] = MT9M111_RMB_ROW_SKIP_2X |
+ MT9M111_RMB_COLUMN_SKIP_2X |
+ (sensor_settings[VFLIP_IDX] << 0) |
+ (sensor_settings[HFLIP_IDX] << 1);
+
+ err = m5602_write_sensor(sd,
+ MT9M111_SC_R_MODE_CONTEXT_B, data, 2);
+ break;
+
+ case 320:
+ PDEBUG(D_V4L2, "Configuring camera for QVGA mode");
+ data[0] = MT9M111_RMB_OVER_SIZED;
+ data[1] = MT9M111_RMB_ROW_SKIP_4X |
+ MT9M111_RMB_COLUMN_SKIP_4X |
+ (sensor_settings[VFLIP_IDX] << 0) |
+ (sensor_settings[HFLIP_IDX] << 1);
+ err = m5602_write_sensor(sd,
+ MT9M111_SC_R_MODE_CONTEXT_B, data, 2);
+ break;
+ }
+ return err;
}
-int mt9m111_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
+void mt9m111_disconnect(struct sd *sd)
+{
+ sd->sensor = NULL;
+ kfree(sd->sensor_priv);
+}
+
+static int mt9m111_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
{
- int err;
- u8 data[2] = {0x00, 0x00};
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
- data, 2);
- *val = data[0] & MT9M111_RMB_MIRROR_ROWS;
+ *val = sensor_settings[VFLIP_IDX];
PDEBUG(D_V4L2, "Read vertical flip %d", *val);
- return err;
+ return 0;
}
-int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
+static int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 data[2] = {0x00, 0x00};
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
PDEBUG(D_V4L2, "Set vertical flip to %d", val);
+ sensor_settings[VFLIP_IDX] = val;
+
+ /* The mt9m111 is flipped by default */
+ val = !val;
+
/* Set the correct page map */
err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
if (err < 0)
@@ -186,34 +396,37 @@ int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
if (err < 0)
return err;
- data[0] = (data[0] & 0xfe) | val;
+ data[1] = (data[1] & 0xfe) | val;
err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
data, 2);
return err;
}
-int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
{
- int err;
- u8 data[2] = {0x00, 0x00};
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
- data, 2);
- *val = data[0] & MT9M111_RMB_MIRROR_COLS;
+ *val = sensor_settings[HFLIP_IDX];
PDEBUG(D_V4L2, "Read horizontal flip %d", *val);
- return err;
+ return 0;
}
-int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
+static int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 data[2] = {0x00, 0x00};
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
+ sensor_settings[HFLIP_IDX] = val;
+
+ /* The mt9m111 is flipped by default */
+ val = !val;
+
/* Set the correct page map */
err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
if (err < 0)
@@ -223,36 +436,62 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
if (err < 0)
return err;
- data[0] = (data[0] & 0xfd) | ((val << 1) & 0x02);
+ data[1] = (data[1] & 0xfd) | ((val << 1) & 0x02);
err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
data, 2);
return err;
}
-int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+static int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
{
- int err, tmp;
- u8 data[2] = {0x00, 0x00};
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_read_sensor(sd, MT9M111_SC_GLOBAL_GAIN, data, 2);
- tmp = ((data[1] << 8) | data[0]);
+ *val = sensor_settings[GAIN_IDX];
+ PDEBUG(D_V4L2, "Read gain %d", *val);
- *val = ((tmp & (1 << 10)) * 2) |
- ((tmp & (1 << 9)) * 2) |
- ((tmp & (1 << 8)) * 2) |
- (tmp & 0x7f);
+ return 0;
+}
- PDEBUG(D_V4L2, "Read gain %d", *val);
+static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ int err;
+ u8 data[2];
+
+ err = m5602_read_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2);
+ if (err < 0)
+ return err;
+
+ sensor_settings[AUTO_WHITE_BALANCE_IDX] = val & 0x01;
+ data[1] = ((data[1] & 0xfd) | ((val & 0x01) << 1));
+ err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2);
+
+ PDEBUG(D_V4L2, "Set auto white balance %d", val);
return err;
}
-int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
+static int mt9m111_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val) {
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[AUTO_WHITE_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read auto white balance %d", *val);
+ return 0;
+}
+
+static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
{
int err, tmp;
u8 data[2] = {0x00, 0x00};
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ sensor_settings[GAIN_IDX] = val;
/* Set the correct page map */
err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
@@ -275,8 +514,8 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
else
tmp = val;
- data[1] = (tmp & 0xff00) >> 8;
- data[0] = (tmp & 0xff);
+ data[1] = (tmp & 0xff);
+ data[0] = (tmp & 0xff00) >> 8;
PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp,
data[1], data[0]);
@@ -286,6 +525,89 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
+static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+ int err;
+ u8 data[2];
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ sensor_settings[GREEN_BALANCE_IDX] = val;
+ data[1] = (val & 0xff);
+ data[0] = (val & 0xff00) >> 8;
+
+ PDEBUG(D_V4L2, "Set green balance %d", val);
+ err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN,
+ data, 2);
+ if (err < 0)
+ return err;
+
+ return m5602_write_sensor(sd, MT9M111_SC_GREEN_2_GAIN,
+ data, 2);
+}
+
+static int mt9m111_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[GREEN_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read green balance %d", *val);
+ return 0;
+}
+
+static int mt9m111_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+ u8 data[2];
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ sensor_settings[BLUE_BALANCE_IDX] = val;
+ data[1] = (val & 0xff);
+ data[0] = (val & 0xff00) >> 8;
+
+ PDEBUG(D_V4L2, "Set blue balance %d", val);
+
+ return m5602_write_sensor(sd, MT9M111_SC_BLUE_GAIN,
+ data, 2);
+}
+
+static int mt9m111_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[BLUE_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read blue balance %d", *val);
+ return 0;
+}
+
+static int mt9m111_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+ u8 data[2];
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ sensor_settings[RED_BALANCE_IDX] = val;
+ data[1] = (val & 0xff);
+ data[0] = (val & 0xff00) >> 8;
+
+ PDEBUG(D_V4L2, "Set red balance %d", val);
+
+ return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN,
+ data, 2);
+}
+
+static int mt9m111_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[RED_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read red balance %d", *val);
+ return 0;
+}
+
static void mt9m111_dump_registers(struct sd *sd)
{
u8 address, value[2] = {0x00, 0x00};
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
index 00c6db02bdb7..b3de77823091 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
@@ -37,7 +37,6 @@
#define MT9M111_SC_VBLANK_CONTEXT_A 0x08
#define MT9M111_SC_SHUTTER_WIDTH 0x09
#define MT9M111_SC_ROW_SPEED 0x0a
-
#define MT9M111_SC_EXTRA_DELAY 0x0b
#define MT9M111_SC_SHUTTER_DELAY 0x0c
#define MT9M111_SC_RESET 0x0d
@@ -50,9 +49,6 @@
#define MT9M111_SC_GREEN_2_GAIN 0x2e
#define MT9M111_SC_GLOBAL_GAIN 0x2f
-#define MT9M111_RMB_MIRROR_ROWS (1 << 0)
-#define MT9M111_RMB_MIRROR_COLS (1 << 1)
-
#define MT9M111_CONTEXT_CONTROL 0xc8
#define MT9M111_PAGE_MAP 0xf0
#define MT9M111_BYTEWISE_ADDRESS 0xf1
@@ -74,8 +70,37 @@
#define MT9M111_COLORPIPE 0x01
#define MT9M111_CAMERA_CONTROL 0x02
+#define MT9M111_RESET (1 << 0)
+#define MT9M111_RESTART (1 << 1)
+#define MT9M111_ANALOG_STANDBY (1 << 2)
+#define MT9M111_CHIP_ENABLE (1 << 3)
+#define MT9M111_CHIP_DISABLE (0 << 3)
+#define MT9M111_OUTPUT_DISABLE (1 << 4)
+#define MT9M111_SHOW_BAD_FRAMES (1 << 0)
+#define MT9M111_RESTART_BAD_FRAMES (1 << 1)
+#define MT9M111_SYNCHRONIZE_CHANGES (1 << 7)
+
+#define MT9M111_RMB_OVER_SIZED (1 << 0)
+#define MT9M111_RMB_MIRROR_ROWS (1 << 0)
+#define MT9M111_RMB_MIRROR_COLS (1 << 1)
+#define MT9M111_RMB_ROW_SKIP_2X (1 << 2)
+#define MT9M111_RMB_COLUMN_SKIP_2X (1 << 3)
+#define MT9M111_RMB_ROW_SKIP_4X (1 << 4)
+#define MT9M111_RMB_COLUMN_SKIP_4X (1 << 5)
+
+#define MT9M111_COLOR_MATRIX_BYPASS (1 << 4)
+#define MT9M111_SEL_CONTEXT_B (1 << 3)
+
+#define MT9M111_TRISTATE_PIN_IN_STANDBY (1 << 1)
+#define MT9M111_SOC_SOFT_STANDBY (1 << 0)
+
+#define MT9M111_2D_DEFECT_CORRECTION_ENABLE (1 << 0)
+
#define INITIAL_MAX_GAIN 64
-#define DEFAULT_GAIN 283
+#define MT9M111_DEFAULT_GAIN 283
+#define MT9M111_GREEN_GAIN_DEFAULT 0x20
+#define MT9M111_BLUE_GAIN_DEFAULT 0x20
+#define MT9M111_RED_GAIN_DEFAULT 0x20
/*****************************************************************************/
@@ -85,16 +110,10 @@ extern int dump_sensor;
int mt9m111_probe(struct sd *sd);
int mt9m111_init(struct sd *sd);
-int mt9m111_power_down(struct sd *sd);
+int mt9m111_start(struct sd *sd);
+void mt9m111_disconnect(struct sd *sd);
-int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
-int mt9m111_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
-int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
-int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
-int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
-int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val);
-
-const static struct m5602_sensor mt9m111 = {
+static const struct m5602_sensor mt9m111 = {
.name = "MT9M111",
.i2c_slave_id = 0xba,
@@ -102,7 +121,8 @@ const static struct m5602_sensor mt9m111 = {
.probe = mt9m111_probe,
.init = mt9m111_init,
- .power_down = mt9m111_power_down
+ .disconnect = mt9m111_disconnect,
+ .start = mt9m111_start,
};
static const unsigned char preinit_mt9m111[][4] =
@@ -117,7 +137,14 @@ static const unsigned char preinit_mt9m111[][4] =
{BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
{SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0xff, 0xf7},
+ {SENSOR, MT9M111_SC_RESET,
+ MT9M111_RESET |
+ MT9M111_RESTART |
+ MT9M111_ANALOG_STANDBY |
+ MT9M111_CHIP_DISABLE,
+ MT9M111_SHOW_BAD_FRAMES |
+ MT9M111_RESTART_BAD_FRAMES |
+ MT9M111_SYNCHRONIZE_CHANGES},
{BRIDGE, M5602_XB_GPIO_DIR, 0x05, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT, 0x04, 0x00},
@@ -145,731 +172,42 @@ static const unsigned char init_mt9m111[][4] =
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d, 0x00},
- {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
{BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0xff, 0xff},
- {SENSOR, MT9M111_SC_RESET, 0xff, 0xff},
- {SENSOR, MT9M111_SC_RESET, 0xff, 0xde},
- {SENSOR, MT9M111_SC_RESET, 0xff, 0xff},
- {SENSOR, MT9M111_SC_RESET, 0xff, 0xf7},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xb3, 0x00},
-
- {SENSOR, MT9M111_CP_GLOBAL_CLK_CONTROL, 0xff, 0xff},
-
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x07, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x0b, 0x00},
{BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
{BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x05},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {SENSOR, MT9M111_CP_OPERATING_MODE_CTL, 0x00, 0x10},
- {SENSOR, MT9M111_CP_LENS_CORRECTION_1, 0x04, 0x2a},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_A, 0x00, 0x01},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_B, 0x00, 0x01},
- {SENSOR, MT9M111_CP_LUMA_OFFSET, 0x00, 0x00},
- {SENSOR, MT9M111_CP_LUMA_CLIP, 0xff, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_A, 0x14, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_B, 0x14, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xcd, 0x00},
-
- {SENSOR, 0xcd, 0x00, 0x0e},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xd0, 0x00},
- {SENSOR, 0xd0, 0x00, 0x40},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x02},
- {SENSOR, MT9M111_CC_AUTO_EXPOSURE_PARAMETER_18, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x07},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x03},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {SENSOR, 0x33, 0x03, 0x49},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
-
- {SENSOR, 0x33, 0x03, 0x49},
- {SENSOR, 0x34, 0xc0, 0x19},
- {SENSOR, 0x3f, 0x20, 0x20},
- {SENSOR, 0x40, 0x20, 0x20},
- {SENSOR, 0x5a, 0xc0, 0x0a},
- {SENSOR, 0x70, 0x7b, 0x0a},
- {SENSOR, 0x71, 0xff, 0x00},
- {SENSOR, 0x72, 0x19, 0x0e},
- {SENSOR, 0x73, 0x18, 0x0f},
- {SENSOR, 0x74, 0x57, 0x32},
- {SENSOR, 0x75, 0x56, 0x34},
- {SENSOR, 0x76, 0x73, 0x35},
- {SENSOR, 0x77, 0x30, 0x12},
- {SENSOR, 0x78, 0x79, 0x02},
- {SENSOR, 0x79, 0x75, 0x06},
- {SENSOR, 0x7a, 0x77, 0x0a},
- {SENSOR, 0x7b, 0x78, 0x09},
- {SENSOR, 0x7c, 0x7d, 0x06},
- {SENSOR, 0x7d, 0x31, 0x10},
- {SENSOR, 0x7e, 0x00, 0x7e},
- {SENSOR, 0x80, 0x59, 0x04},
- {SENSOR, 0x81, 0x59, 0x04},
- {SENSOR, 0x82, 0x57, 0x0a},
- {SENSOR, 0x83, 0x58, 0x0b},
- {SENSOR, 0x84, 0x47, 0x0c},
- {SENSOR, 0x85, 0x48, 0x0e},
- {SENSOR, 0x86, 0x5b, 0x02},
- {SENSOR, 0x87, 0x00, 0x5c},
- {SENSOR, MT9M111_CONTEXT_CONTROL, 0x00, 0x08},
- {SENSOR, 0x60, 0x00, 0x80},
- {SENSOR, 0x61, 0x00, 0x00},
- {SENSOR, 0x62, 0x00, 0x00},
- {SENSOR, 0x63, 0x00, 0x00},
- {SENSOR, 0x64, 0x00, 0x00},
-
- {SENSOR, MT9M111_SC_ROWSTART, 0x00, 0x0d},
- {SENSOR, MT9M111_SC_COLSTART, 0x00, 0x18},
- {SENSOR, MT9M111_SC_WINDOW_HEIGHT, 0x04, 0x04},
- {SENSOR, MT9M111_SC_WINDOW_WIDTH, 0x05, 0x08},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_B, 0x01, 0x38},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_B, 0x00, 0x11},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_A, 0x01, 0x38},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_A, 0x00, 0x11},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_B, 0x01, 0x03},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_A, 0x01, 0x03},
- {SENSOR, 0x30, 0x04, 0x00},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x05, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x07, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xa0, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0xf4},
- {SENSOR, MT9M111_SC_GLOBAL_GAIN, 0x00, 0xea},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x05, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x07, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x09},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x0c},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x04},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xb3, 0x00},
- {SENSOR, MT9M111_CP_GLOBAL_CLK_CONTROL, 0x00, 0x03},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT, 0x04, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x3e, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x07, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x0b, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x05},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {SENSOR, MT9M111_CP_OPERATING_MODE_CTL, 0x00, 0x10},
- {SENSOR, MT9M111_CP_LENS_CORRECTION_1, 0x04, 0x2a},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_A, 0x00, 0x01},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_B, 0x00, 0x01},
- {SENSOR, MT9M111_CP_LUMA_OFFSET, 0x00, 0x00},
- {SENSOR, MT9M111_CP_LUMA_CLIP, 0xff, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_A, 0x14, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_B, 0x14, 0x00},
-
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xcd, 0x00},
- {SENSOR, 0xcd, 0x00, 0x0e},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xd0, 0x00},
- {SENSOR, 0xd0, 0x00, 0x40},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x02},
- {SENSOR, MT9M111_CC_AUTO_EXPOSURE_PARAMETER_18, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x07},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x03},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {SENSOR, 0x33, 0x03, 0x49},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
-
- {SENSOR, 0x33, 0x03, 0x49},
- {SENSOR, 0x34, 0xc0, 0x19},
- {SENSOR, 0x3f, 0x20, 0x20},
- {SENSOR, 0x40, 0x20, 0x20},
- {SENSOR, 0x5a, 0xc0, 0x0a},
- {SENSOR, 0x70, 0x7b, 0x0a},
- {SENSOR, 0x71, 0xff, 0x00},
- {SENSOR, 0x72, 0x19, 0x0e},
- {SENSOR, 0x73, 0x18, 0x0f},
- {SENSOR, 0x74, 0x57, 0x32},
- {SENSOR, 0x75, 0x56, 0x34},
- {SENSOR, 0x76, 0x73, 0x35},
- {SENSOR, 0x77, 0x30, 0x12},
- {SENSOR, 0x78, 0x79, 0x02},
- {SENSOR, 0x79, 0x75, 0x06},
- {SENSOR, 0x7a, 0x77, 0x0a},
- {SENSOR, 0x7b, 0x78, 0x09},
- {SENSOR, 0x7c, 0x7d, 0x06},
- {SENSOR, 0x7d, 0x31, 0x10},
- {SENSOR, 0x7e, 0x00, 0x7e},
- {SENSOR, 0x80, 0x59, 0x04},
- {SENSOR, 0x81, 0x59, 0x04},
- {SENSOR, 0x82, 0x57, 0x0a},
- {SENSOR, 0x83, 0x58, 0x0b},
- {SENSOR, 0x84, 0x47, 0x0c},
- {SENSOR, 0x85, 0x48, 0x0e},
- {SENSOR, 0x86, 0x5b, 0x02},
- {SENSOR, 0x87, 0x00, 0x5c},
- {SENSOR, MT9M111_CONTEXT_CONTROL, 0x00, 0x08},
- {SENSOR, 0x60, 0x00, 0x80},
- {SENSOR, 0x61, 0x00, 0x00},
- {SENSOR, 0x62, 0x00, 0x00},
- {SENSOR, 0x63, 0x00, 0x00},
- {SENSOR, 0x64, 0x00, 0x00},
-
- {SENSOR, MT9M111_SC_ROWSTART, 0x00, 0x0d},
- {SENSOR, MT9M111_SC_COLSTART, 0x00, 0x18},
- {SENSOR, MT9M111_SC_WINDOW_HEIGHT, 0x04, 0x04},
- {SENSOR, MT9M111_SC_WINDOW_WIDTH, 0x05, 0x08},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_B, 0x01, 0x38},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_B, 0x00, 0x11},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_A, 0x01, 0x38},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_A, 0x00, 0x11},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_B, 0x01, 0x03},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_A, 0x01, 0x03},
- {SENSOR, 0x30, 0x04, 0x00},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x05, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x07, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xa0, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0xf4},
- {SENSOR, MT9M111_SC_GLOBAL_GAIN, 0x00, 0xea},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x09},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x0c},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x04},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
-
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xb3, 0x00},
- {SENSOR, MT9M111_CP_GLOBAL_CLK_CONTROL, 0x00, 0x03},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3e, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT_H, 0x02, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR, 0x07, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT, 0x0b, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
{BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x05},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
{SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
{SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
{SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
{SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {SENSOR, MT9M111_CP_OPERATING_MODE_CTL, 0x00, 0x10},
+ {SENSOR, MT9M111_CP_OPERATING_MODE_CTL, 0x00,
+ MT9M111_CP_OPERATING_MODE_CTL},
{SENSOR, MT9M111_CP_LENS_CORRECTION_1, 0x04, 0x2a},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_A, 0x00, 0x01},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_B, 0x00, 0x01},
+ {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_A, 0x00,
+ MT9M111_2D_DEFECT_CORRECTION_ENABLE},
+ {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_B, 0x00,
+ MT9M111_2D_DEFECT_CORRECTION_ENABLE},
{SENSOR, MT9M111_CP_LUMA_OFFSET, 0x00, 0x00},
{SENSOR, MT9M111_CP_LUMA_CLIP, 0xff, 0x00},
{SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_A, 0x14, 0x00},
{SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_B, 0x14, 0x00},
-
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xcd, 0x00},
{SENSOR, 0xcd, 0x00, 0x0e},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xd0, 0x00},
{SENSOR, 0xd0, 0x00, 0x40},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x02},
- {SENSOR, MT9M111_CC_AUTO_EXPOSURE_PARAMETER_18, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x07},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x03},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {SENSOR, 0x33, 0x03, 0x49},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
-
- {SENSOR, 0x33, 0x03, 0x49},
- {SENSOR, 0x34, 0xc0, 0x19},
- {SENSOR, 0x3f, 0x20, 0x20},
- {SENSOR, 0x40, 0x20, 0x20},
- {SENSOR, 0x5a, 0xc0, 0x0a},
- {SENSOR, 0x70, 0x7b, 0x0a},
- {SENSOR, 0x71, 0xff, 0x00},
- {SENSOR, 0x72, 0x19, 0x0e},
- {SENSOR, 0x73, 0x18, 0x0f},
- {SENSOR, 0x74, 0x57, 0x32},
- {SENSOR, 0x75, 0x56, 0x34},
- {SENSOR, 0x76, 0x73, 0x35},
- {SENSOR, 0x77, 0x30, 0x12},
- {SENSOR, 0x78, 0x79, 0x02},
- {SENSOR, 0x79, 0x75, 0x06},
- {SENSOR, 0x7a, 0x77, 0x0a},
- {SENSOR, 0x7b, 0x78, 0x09},
- {SENSOR, 0x7c, 0x7d, 0x06},
- {SENSOR, 0x7d, 0x31, 0x10},
- {SENSOR, 0x7e, 0x00, 0x7e},
- {SENSOR, 0x80, 0x59, 0x04},
- {SENSOR, 0x81, 0x59, 0x04},
- {SENSOR, 0x82, 0x57, 0x0a},
- {SENSOR, 0x83, 0x58, 0x0b},
- {SENSOR, 0x84, 0x47, 0x0c},
- {SENSOR, 0x85, 0x48, 0x0e},
- {SENSOR, 0x86, 0x5b, 0x02},
- {SENSOR, 0x87, 0x00, 0x5c},
- {SENSOR, MT9M111_CONTEXT_CONTROL, 0x00, 0x08},
- {SENSOR, 0x60, 0x00, 0x80},
- {SENSOR, 0x61, 0x00, 0x00},
- {SENSOR, 0x62, 0x00, 0x00},
- {SENSOR, 0x63, 0x00, 0x00},
- {SENSOR, 0x64, 0x00, 0x00},
- {SENSOR, MT9M111_SC_ROWSTART, 0x00, 0x0d},
- {SENSOR, MT9M111_SC_COLSTART, 0x00, 0x18},
- {SENSOR, MT9M111_SC_WINDOW_HEIGHT, 0x04, 0x04},
- {SENSOR, MT9M111_SC_WINDOW_WIDTH, 0x05, 0x08},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_B, 0x01, 0x38},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_B, 0x00, 0x11},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_A, 0x01, 0x38},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_A, 0x00, 0x11},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_B, 0x01, 0x03},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_A, 0x01, 0x03},
- {SENSOR, 0x30, 0x04, 0x00},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x05, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x07, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xa0, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0xf4},
- {SENSOR, MT9M111_SC_GLOBAL_GAIN, 0x00, 0xea},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x09},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x0c},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x04},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xb3, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_CP_GLOBAL_CLK_CONTROL, 0x00, 0x03},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x07, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x0b, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x05},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
-
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {SENSOR, MT9M111_CP_OPERATING_MODE_CTL, 0x00, 0x10},
- {SENSOR, MT9M111_CP_LENS_CORRECTION_1, 0x04, 0x2a},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_A, 0x00, 0x01},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_B, 0x00, 0x01},
- {SENSOR, MT9M111_CP_LUMA_OFFSET, 0x00, 0x00},
- {SENSOR, MT9M111_CP_LUMA_CLIP, 0xff, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_A, 0x14, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_B, 0x14, 0x00},
-
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xcd, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, 0xcd, 0x00, 0x0e},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xd0, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, 0xd0, 0x00, 0x40},
{SENSOR, MT9M111_PAGE_MAP, 0x00, 0x02},
{SENSOR, MT9M111_CC_AUTO_EXPOSURE_PARAMETER_18, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x07},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
{SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x03},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, 0x33, 0x03, 0x49},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
-
- {SENSOR, 0x33, 0x03, 0x49},
- {SENSOR, 0x34, 0xc0, 0x19},
- {SENSOR, 0x3f, 0x20, 0x20},
- {SENSOR, 0x40, 0x20, 0x20},
- {SENSOR, 0x5a, 0xc0, 0x0a},
- {SENSOR, 0x70, 0x7b, 0x0a},
- {SENSOR, 0x71, 0xff, 0x00},
- {SENSOR, 0x72, 0x19, 0x0e},
- {SENSOR, 0x73, 0x18, 0x0f},
- {SENSOR, 0x74, 0x57, 0x32},
- {SENSOR, 0x75, 0x56, 0x34},
- {SENSOR, 0x76, 0x73, 0x35},
- {SENSOR, 0x77, 0x30, 0x12},
- {SENSOR, 0x78, 0x79, 0x02},
- {SENSOR, 0x79, 0x75, 0x06},
- {SENSOR, 0x7a, 0x77, 0x0a},
- {SENSOR, 0x7b, 0x78, 0x09},
- {SENSOR, 0x7c, 0x7d, 0x06},
- {SENSOR, 0x7d, 0x31, 0x10},
- {SENSOR, 0x7e, 0x00, 0x7e},
- {SENSOR, 0x80, 0x59, 0x04},
- {SENSOR, 0x81, 0x59, 0x04},
- {SENSOR, 0x82, 0x57, 0x0a},
- {SENSOR, 0x83, 0x58, 0x0b},
- {SENSOR, 0x84, 0x47, 0x0c},
- {SENSOR, 0x85, 0x48, 0x0e},
- {SENSOR, 0x86, 0x5b, 0x02},
- {SENSOR, 0x87, 0x00, 0x5c},
- {SENSOR, MT9M111_CONTEXT_CONTROL, 0x00, 0x08},
- {SENSOR, 0x60, 0x00, 0x80},
- {SENSOR, 0x61, 0x00, 0x00},
- {SENSOR, 0x62, 0x00, 0x00},
- {SENSOR, 0x63, 0x00, 0x00},
- {SENSOR, 0x64, 0x00, 0x00},
- {SENSOR, MT9M111_SC_ROWSTART, 0x00, 0x0d},
- {SENSOR, MT9M111_SC_COLSTART, 0x00, 0x12},
- {SENSOR, MT9M111_SC_WINDOW_HEIGHT, 0x04, 0x00},
- {SENSOR, MT9M111_SC_WINDOW_WIDTH, 0x05, 0x10},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_B, 0x01, 0x60},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_B, 0x00, 0x11},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_A, 0x01, 0x60},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_A, 0x00, 0x11},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_B, 0x01, 0x0f},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_A, 0x01, 0x0f},
- {SENSOR, 0x30, 0x04, 0x00},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe3, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x87, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0x90},
- {SENSOR, MT9M111_SC_GLOBAL_GAIN, 0x00, 0xe6},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x09},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x0c},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x04},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xb3, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_CP_GLOBAL_CLK_CONTROL, 0x00, 0x03},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3e, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x07, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x0b, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x05},
{SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x29},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x0d, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_SC_RESET, 0x00, 0x08},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x01},
- {SENSOR, MT9M111_CP_OPERATING_MODE_CTL, 0x00, 0x10},
- {SENSOR, MT9M111_CP_LENS_CORRECTION_1, 0x04, 0x2a},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_A, 0x00, 0x01},
- {SENSOR, MT9M111_CP_DEFECT_CORR_CONTEXT_B, 0x00, 0x01},
- {SENSOR, MT9M111_CP_LUMA_OFFSET, 0x00, 0x00},
- {SENSOR, MT9M111_CP_LUMA_CLIP, 0xff, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_A, 0x14, 0x00},
- {SENSOR, MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_B, 0x14, 0x00},
-
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xcd, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, 0xcd, 0x00, 0x0e},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0xd0, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, 0xd0, 0x00, 0x40},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x02},
- {SENSOR, MT9M111_CC_AUTO_EXPOSURE_PARAMETER_18, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x07},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x28, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, MT9M111_CC_AWB_PARAMETER_7, 0xef, 0x03},
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
-
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
- {SENSOR, 0x33, 0x03, 0x49},
- {BRIDGE, M5602_XB_I2C_DEV_ADDR, 0xba, 0x00},
- {BRIDGE, M5602_XB_I2C_REG_ADDR, 0x33, 0x00},
- {BRIDGE, M5602_XB_I2C_CTRL, 0x1a, 0x00},
-
{SENSOR, 0x33, 0x03, 0x49},
{SENSOR, 0x34, 0xc0, 0x19},
{SENSOR, 0x3f, 0x20, 0x20},
@@ -898,25 +236,29 @@ static const unsigned char init_mt9m111[][4] =
{SENSOR, 0x85, 0x48, 0x0e},
{SENSOR, 0x86, 0x5b, 0x02},
{SENSOR, 0x87, 0x00, 0x5c},
- {SENSOR, MT9M111_CONTEXT_CONTROL, 0x00, 0x08},
+ {SENSOR, MT9M111_CONTEXT_CONTROL, 0x00, MT9M111_SEL_CONTEXT_B},
{SENSOR, 0x60, 0x00, 0x80},
{SENSOR, 0x61, 0x00, 0x00},
{SENSOR, 0x62, 0x00, 0x00},
{SENSOR, 0x63, 0x00, 0x00},
{SENSOR, 0x64, 0x00, 0x00},
- {SENSOR, MT9M111_SC_ROWSTART, 0x00, 0x0d},
- {SENSOR, MT9M111_SC_COLSTART, 0x00, 0x12},
- {SENSOR, MT9M111_SC_WINDOW_HEIGHT, 0x04, 0x00},
- {SENSOR, MT9M111_SC_WINDOW_WIDTH, 0x05, 0x10},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_B, 0x01, 0x60},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_B, 0x00, 0x11},
- {SENSOR, MT9M111_SC_HBLANK_CONTEXT_A, 0x01, 0x60},
- {SENSOR, MT9M111_SC_VBLANK_CONTEXT_A, 0x00, 0x11},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_B, 0x01, 0x0f},
- {SENSOR, MT9M111_SC_R_MODE_CONTEXT_A, 0x01, 0x0f},
+ {SENSOR, MT9M111_SC_ROWSTART, 0x00, 0x0d}, /* 13 */
+ {SENSOR, MT9M111_SC_COLSTART, 0x00, 0x12}, /* 18 */
+ {SENSOR, MT9M111_SC_WINDOW_HEIGHT, 0x04, 0x00}, /* 1024 */
+ {SENSOR, MT9M111_SC_WINDOW_WIDTH, 0x05, 0x10}, /* 1296 */
+ {SENSOR, MT9M111_SC_HBLANK_CONTEXT_B, 0x01, 0x60}, /* 352 */
+ {SENSOR, MT9M111_SC_VBLANK_CONTEXT_B, 0x00, 0x11}, /* 17 */
+ {SENSOR, MT9M111_SC_HBLANK_CONTEXT_A, 0x01, 0x60}, /* 352 */
+ {SENSOR, MT9M111_SC_VBLANK_CONTEXT_A, 0x00, 0x11}, /* 17 */
+ {SENSOR, MT9M111_SC_R_MODE_CONTEXT_A, 0x01, 0x0f}, /* 271 */
{SENSOR, 0x30, 0x04, 0x00},
+ /* Set number of blank rows chosen to 400 */
+ {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0x90},
+};
+static const unsigned char start_mt9m111[][4] =
+{
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -928,25 +270,6 @@ static const unsigned char init_mt9m111[][4] =
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe0, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00}, /* 639*/
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, MT9M111_PAGE_MAP, 0x00, 0x00},
- /* Set number of blank rows chosen to 400 */
- {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0x90},
- /* Set the global gain to 283 (of 512) */
- {SENSOR, MT9M111_SC_GLOBAL_GAIN, 0x03, 0x63}
};
#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c
new file mode 100644
index 000000000000..7aafeb7cfa07
--- /dev/null
+++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c
@@ -0,0 +1,227 @@
+/*
+ * Driver for the ov7660 sensor
+ *
+ * Copyright (C) 2009 Erik Andrén
+ * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
+ * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
+ *
+ * Portions of code to USB interface and ALi driver software,
+ * Copyright (c) 2006 Willem Duinker
+ * v4l2 interface modeled after the V4L2 driver
+ * for SN9C10x PC Camera Controllers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ */
+
+#include "m5602_ov7660.h"
+
+static int ov7660_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+
+const static struct ctrl ov7660_ctrls[] = {
+#define GAIN_IDX 1
+ {
+ {
+ .id = V4L2_CID_GAIN,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "gain",
+ .minimum = 0x00,
+ .maximum = 0xff,
+ .step = 0x1,
+ .default_value = OV7660_DEFAULT_GAIN,
+ .flags = V4L2_CTRL_FLAG_SLIDER
+ },
+ .set = ov7660_set_gain,
+ .get = ov7660_get_gain
+ },
+};
+
+static struct v4l2_pix_format ov7660_modes[] = {
+ {
+ 640,
+ 480,
+ V4L2_PIX_FMT_SBGGR8,
+ V4L2_FIELD_NONE,
+ .sizeimage =
+ 640 * 480,
+ .bytesperline = 640,
+ .colorspace = V4L2_COLORSPACE_SRGB,
+ .priv = 0
+ }
+};
+
+static void ov7660_dump_registers(struct sd *sd);
+
+int ov7660_probe(struct sd *sd)
+{
+ int err = 0, i;
+ u8 prod_id = 0, ver_id = 0;
+
+ s32 *sensor_settings;
+
+ if (force_sensor) {
+ if (force_sensor == OV7660_SENSOR) {
+ info("Forcing an %s sensor", ov7660.name);
+ goto sensor_found;
+ }
+ /* If we want to force another sensor,
+ don't try to probe this one */
+ return -ENODEV;
+ }
+
+ /* Do the preinit */
+ for (i = 0; i < ARRAY_SIZE(preinit_ov7660) && !err; i++) {
+ u8 data[2];
+
+ if (preinit_ov7660[i][0] == BRIDGE) {
+ err = m5602_write_bridge(sd,
+ preinit_ov7660[i][1],
+ preinit_ov7660[i][2]);
+ } else {
+ data[0] = preinit_ov7660[i][2];
+ err = m5602_write_sensor(sd,
+ preinit_ov7660[i][1], data, 1);
+ }
+ }
+ if (err < 0)
+ return err;
+
+ if (m5602_read_sensor(sd, OV7660_PID, &prod_id, 1))
+ return -ENODEV;
+
+ if (m5602_read_sensor(sd, OV7660_VER, &ver_id, 1))
+ return -ENODEV;
+
+ info("Sensor reported 0x%x%x", prod_id, ver_id);
+
+ if ((prod_id == 0x76) && (ver_id == 0x60)) {
+ info("Detected a ov7660 sensor");
+ goto sensor_found;
+ }
+ return -ENODEV;
+
+sensor_found:
+ sensor_settings = kmalloc(
+ ARRAY_SIZE(ov7660_ctrls) * sizeof(s32), GFP_KERNEL);
+ if (!sensor_settings)
+ return -ENOMEM;
+
+ sd->gspca_dev.cam.cam_mode = ov7660_modes;
+ sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov7660_modes);
+ sd->desc->ctrls = ov7660_ctrls;
+ sd->desc->nctrls = ARRAY_SIZE(ov7660_ctrls);
+
+ for (i = 0; i < ARRAY_SIZE(ov7660_ctrls); i++)
+ sensor_settings[i] = ov7660_ctrls[i].qctrl.default_value;
+ sd->sensor_priv = sensor_settings;
+
+ return 0;
+}
+
+int ov7660_init(struct sd *sd)
+{
+ int i, err = 0;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ /* Init the sensor */
+ for (i = 0; i < ARRAY_SIZE(init_ov7660); i++) {
+ u8 data[2];
+
+ if (init_ov7660[i][0] == BRIDGE) {
+ err = m5602_write_bridge(sd,
+ init_ov7660[i][1],
+ init_ov7660[i][2]);
+ } else {
+ data[0] = init_ov7660[i][2];
+ err = m5602_write_sensor(sd,
+ init_ov7660[i][1], data, 1);
+ }
+ }
+
+ if (dump_sensor)
+ ov7660_dump_registers(sd);
+
+ err = ov7660_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
+ if (err < 0)
+ return err;
+
+ return err;
+}
+
+int ov7660_start(struct sd *sd)
+{
+ return 0;
+}
+
+int ov7660_stop(struct sd *sd)
+{
+ return 0;
+}
+
+void ov7660_disconnect(struct sd *sd)
+{
+ ov7660_stop(sd);
+
+ sd->sensor = NULL;
+ kfree(sd->sensor_priv);
+}
+
+static int ov7660_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[GAIN_IDX];
+ PDEBUG(D_V4L2, "Read gain %d", *val);
+ return 0;
+}
+
+static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val)
+{
+ int err;
+ u8 i2c_data;
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ PDEBUG(D_V4L2, "Setting gain to %d", val);
+
+ sensor_settings[GAIN_IDX] = val;
+
+ err = m5602_write_sensor(sd, OV7660_GAIN, &i2c_data, 1);
+ return err;
+}
+
+static void ov7660_dump_registers(struct sd *sd)
+{
+ int address;
+ info("Dumping the ov7660 register state");
+ for (address = 0; address < 0xa9; address++) {
+ u8 value;
+ m5602_read_sensor(sd, address, &value, 1);
+ info("register 0x%x contains 0x%x",
+ address, value);
+ }
+
+ info("ov7660 register state dump complete");
+
+ info("Probing for which registers that are read/write");
+ for (address = 0; address < 0xff; address++) {
+ u8 old_value, ctrl_value;
+ u8 test_value[2] = {0xff, 0xff};
+
+ m5602_read_sensor(sd, address, &old_value, 1);
+ m5602_write_sensor(sd, address, test_value, 1);
+ m5602_read_sensor(sd, address, &ctrl_value, 1);
+
+ if (ctrl_value == test_value[0])
+ info("register 0x%x is writeable", address);
+ else
+ info("register 0x%x is read only", address);
+
+ /* Restore original value */
+ m5602_write_sensor(sd, address, &old_value, 1);
+ }
+}
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.h b/drivers/media/video/gspca/m5602/m5602_ov7660.h
new file mode 100644
index 000000000000..3f2c169a93ea
--- /dev/null
+++ b/drivers/media/video/gspca/m5602/m5602_ov7660.h
@@ -0,0 +1,279 @@
+/*
+ * Driver for the ov7660 sensor
+ *
+ * Copyright (C) 2009 Erik Andrén
+ * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
+ * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
+ *
+ * Portions of code to USB interface and ALi driver software,
+ * Copyright (c) 2006 Willem Duinker
+ * v4l2 interface modeled after the V4L2 driver
+ * for SN9C10x PC Camera Controllers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ */
+
+#ifndef M5602_OV7660_H_
+#define M5602_OV7660_H_
+
+#include "m5602_sensor.h"
+
+#define OV7660_GAIN 0x00
+#define OV7660_BLUE_GAIN 0x01
+#define OV7660_RED_GAIN 0x02
+#define OV7660_VREF 0x03
+#define OV7660_COM1 0x04
+#define OV7660_BAVE 0x05
+#define OV7660_GEAVE 0x06
+#define OV7660_AECHH 0x07
+#define OV7660_RAVE 0x08
+#define OV7660_COM2 0x09
+#define OV7660_PID 0x0a
+#define OV7660_VER 0x0b
+#define OV7660_COM3 0x0c
+#define OV7660_COM4 0x0d
+#define OV7660_COM5 0x0e
+#define OV7660_COM6 0x0f
+#define OV7660_AECH 0x10
+#define OV7660_CLKRC 0x11
+#define OV7660_COM7 0x12
+#define OV7660_COM8 0x13
+#define OV7660_COM9 0x14
+#define OV7660_COM10 0x15
+#define OV7660_RSVD16 0x16
+#define OV7660_HSTART 0x17
+#define OV7660_HSTOP 0x18
+#define OV7660_VSTART 0x19
+#define OV7660_VSTOP 0x1a
+#define OV7660_PSHFT 0x1b
+#define OV7660_MIDH 0x1c
+#define OV7660_MIDL 0x1d
+#define OV7660_MVFP 0x1e
+#define OV7660_LAEC 0x1f
+#define OV7660_BOS 0x20
+#define OV7660_GBOS 0x21
+#define OV7660_GROS 0x22
+#define OV7660_ROS 0x23
+#define OV7660_AEW 0x24
+#define OV7660_AEB 0x25
+#define OV7660_VPT 0x26
+#define OV7660_BBIAS 0x27
+#define OV7660_GbBIAS 0x28
+#define OV7660_RSVD29 0x29
+#define OV7660_RBIAS 0x2c
+#define OV7660_HREF 0x32
+#define OV7660_ADC 0x37
+#define OV7660_OFON 0x39
+#define OV7660_TSLB 0x3a
+#define OV7660_COM12 0x3c
+#define OV7660_COM13 0x3d
+#define OV7660_LCC1 0x62
+#define OV7660_LCC2 0x63
+#define OV7660_LCC3 0x64
+#define OV7660_LCC4 0x65
+#define OV7660_LCC5 0x66
+#define OV7660_HV 0x69
+#define OV7660_RSVDA1 0xa1
+
+#define OV7660_DEFAULT_GAIN 0x0e
+#define OV7660_DEFAULT_RED_GAIN 0x80
+#define OV7660_DEFAULT_BLUE_GAIN 0x80
+#define OV7660_DEFAULT_SATURATION 0x00
+#define OV7660_DEFAULT_EXPOSURE 0x20
+
+/* Kernel module parameters */
+extern int force_sensor;
+extern int dump_sensor;
+
+int ov7660_probe(struct sd *sd);
+int ov7660_init(struct sd *sd);
+int ov7660_start(struct sd *sd);
+int ov7660_stop(struct sd *sd);
+void ov7660_disconnect(struct sd *sd);
+
+const static struct m5602_sensor ov7660 = {
+ .name = "ov7660",
+ .i2c_slave_id = 0x42,
+ .i2c_regW = 1,
+ .probe = ov7660_probe,
+ .init = ov7660_init,
+ .start = ov7660_start,
+ .stop = ov7660_stop,
+ .disconnect = ov7660_disconnect,
+};
+
+static const unsigned char preinit_ov7660[][4] =
+{
+ {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
+ {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d},
+ {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x03},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x03},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
+
+ {SENSOR, OV7660_OFON, 0x0c},
+ {SENSOR, OV7660_COM2, 0x11},
+ {SENSOR, OV7660_COM7, 0x05},
+
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_EN_L, 0x00}
+};
+
+static const unsigned char init_ov7660[][4] =
+{
+ {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
+ {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d},
+ {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x03},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x03},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
+
+ {SENSOR, OV7660_OFON, 0x0c},
+ {SENSOR, OV7660_COM2, 0x11},
+ {SENSOR, OV7660_COM7, 0x05},
+
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
+
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x02},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+
+ {SENSOR, OV7660_AECH, OV7660_DEFAULT_EXPOSURE},
+ {SENSOR, OV7660_COM1, 0x00},
+
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
+
+ {SENSOR, OV7660_COM7, 0x80},
+ {SENSOR, OV7660_CLKRC, 0x80},
+ {SENSOR, OV7660_BLUE_GAIN, 0x80},
+ {SENSOR, OV7660_RED_GAIN, 0x80},
+ {SENSOR, OV7660_COM9, 0x4c},
+ {SENSOR, OV7660_OFON, 0x43},
+ {SENSOR, OV7660_COM12, 0x28},
+ {SENSOR, OV7660_COM8, 0x00},
+ {SENSOR, OV7660_COM10, 0x40},
+ {SENSOR, OV7660_HSTART, 0x0c},
+ {SENSOR, OV7660_HSTOP, 0x61},
+ {SENSOR, OV7660_HREF, 0xa4},
+ {SENSOR, OV7660_PSHFT, 0x0b},
+ {SENSOR, OV7660_VSTART, 0x01},
+ {SENSOR, OV7660_VSTOP, 0x7a},
+ {SENSOR, OV7660_VREF, 0x00},
+ {SENSOR, OV7660_COM7, 0x05},
+ {SENSOR, OV7660_COM6, 0x4b},
+ {SENSOR, OV7660_BBIAS, 0x98},
+ {SENSOR, OV7660_GbBIAS, 0x98},
+ {SENSOR, OV7660_RSVD29, 0x98},
+ {SENSOR, OV7660_RBIAS, 0x98},
+ {SENSOR, OV7660_COM1, 0x00},
+ {SENSOR, OV7660_AECH, 0x00},
+ {SENSOR, OV7660_AECHH, 0x00},
+ {SENSOR, OV7660_ADC, 0x04},
+ {SENSOR, OV7660_COM13, 0x00},
+ {SENSOR, OV7660_RSVDA1, 0x23},
+ {SENSOR, OV7660_TSLB, 0x0d},
+ {SENSOR, OV7660_HV, 0x80},
+ {SENSOR, OV7660_LCC1, 0x00},
+ {SENSOR, OV7660_LCC2, 0x00},
+ {SENSOR, OV7660_LCC3, 0x10},
+ {SENSOR, OV7660_LCC4, 0x40},
+ {SENSOR, OV7660_LCC5, 0x01},
+
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+ {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
+ {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
+ {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81},
+ {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},
+ {BRIDGE, M5602_XB_SIG_INI, 0x01},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x08},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x01},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0xe0}, /* 480 */
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
+ {BRIDGE, M5602_XB_SIG_INI, 0x00},
+ {BRIDGE, M5602_XB_SIG_INI, 0x02},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x27}, /* 39 */
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x02},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0xa7}, /* 679 */
+ {BRIDGE, M5602_XB_SIG_INI, 0x00},
+
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
+
+ {SENSOR, OV7660_AECH, 0x20},
+ {SENSOR, OV7660_COM1, 0x00},
+ {SENSOR, OV7660_OFON, 0x0c},
+ {SENSOR, OV7660_COM2, 0x11},
+ {SENSOR, OV7660_COM7, 0x05},
+ {SENSOR, OV7660_BLUE_GAIN, 0x80},
+ {SENSOR, OV7660_RED_GAIN, 0x80},
+
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
+ {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
+ {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}
+};
+
+#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c
index fc4548fd441d..e0ec7a6ffa6c 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c
@@ -18,12 +18,41 @@
#include "m5602_ov9650.h"
+static int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val);
+static int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val);
+static int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int ov9650_get_auto_exposure(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov9650_set_auto_exposure(struct gspca_dev *gspca_dev, __s32 val);
+
/* Vertically and horizontally flips the image if matched, needed for machines
where the sensor is mounted upside down */
static
const
struct dmi_system_id ov9650_flip_dmi_table[] = {
{
+ .ident = "ASUS A6VA",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "A6VA")
+ }
+ },
+ {
+
.ident = "ASUS A6VC",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
@@ -59,6 +88,13 @@ static
}
},
{
+ .ident = "ASUS A6K",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "A6K")
+ }
+ },
+ {
.ident = "Alienware Aurora m9700",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "alienware"),
@@ -68,7 +104,7 @@ static
{}
};
-const static struct ctrl ov9650_ctrls[] = {
+static const struct ctrl ov9650_ctrls[] = {
#define EXPOSURE_IDX 0
{
{
@@ -102,6 +138,7 @@ const static struct ctrl ov9650_ctrls[] = {
#define RED_BALANCE_IDX 2
{
{
+ .id = V4L2_CID_RED_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "red balance",
.minimum = 0x00,
@@ -116,6 +153,7 @@ const static struct ctrl ov9650_ctrls[] = {
#define BLUE_BALANCE_IDX 3
{
{
+ .id = V4L2_CID_BLUE_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "blue balance",
.minimum = 0x00,
@@ -182,7 +220,22 @@ const static struct ctrl ov9650_ctrls[] = {
},
.set = ov9650_set_auto_gain,
.get = ov9650_get_auto_gain
+ },
+#define AUTO_EXPOSURE_IDX 8
+ {
+ {
+ .id = V4L2_CID_EXPOSURE_AUTO,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto exposure",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1
+ },
+ .set = ov9650_set_auto_exposure,
+ .get = ov9650_get_auto_exposure
}
+
};
static struct v4l2_pix_format ov9650_modes[] = {
@@ -289,12 +342,6 @@ sensor_found:
for (i = 0; i < ARRAY_SIZE(ov9650_ctrls); i++)
sensor_settings[i] = ov9650_ctrls[i].qctrl.default_value;
sd->sensor_priv = sensor_settings;
-
- if (dmi_check_system(ov9650_flip_dmi_table) && !err) {
- info("vflip quirk active");
- sensor_settings[VFLIP_IDX] = 1;
- }
-
return 0;
}
@@ -316,7 +363,8 @@ int ov9650_init(struct sd *sd)
err = m5602_write_bridge(sd, init_ov9650[i][1], data);
}
- err = ov9650_set_exposure(&sd->gspca_dev, sensor_settings[EXPOSURE_IDX]);
+ err = ov9650_set_exposure(&sd->gspca_dev,
+ sensor_settings[EXPOSURE_IDX]);
if (err < 0)
return err;
@@ -324,11 +372,13 @@ int ov9650_init(struct sd *sd)
if (err < 0)
return err;
- err = ov9650_set_red_balance(&sd->gspca_dev, sensor_settings[RED_BALANCE_IDX]);
+ err = ov9650_set_red_balance(&sd->gspca_dev,
+ sensor_settings[RED_BALANCE_IDX]);
if (err < 0)
return err;
- err = ov9650_set_blue_balance(&sd->gspca_dev, sensor_settings[BLUE_BALANCE_IDX]);
+ err = ov9650_set_blue_balance(&sd->gspca_dev,
+ sensor_settings[BLUE_BALANCE_IDX]);
if (err < 0)
return err;
@@ -340,11 +390,18 @@ int ov9650_init(struct sd *sd)
if (err < 0)
return err;
- err = ov9650_set_auto_white_balance(&sd->gspca_dev, sensor_settings[AUTO_WHITE_BALANCE_IDX]);
+ err = ov9650_set_auto_exposure(&sd->gspca_dev,
+ sensor_settings[AUTO_EXPOSURE_IDX]);
if (err < 0)
return err;
- err = ov9650_set_auto_gain(&sd->gspca_dev, sensor_settings[AUTO_GAIN_CTRL_IDX]);
+ err = ov9650_set_auto_white_balance(&sd->gspca_dev,
+ sensor_settings[AUTO_WHITE_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = ov9650_set_auto_gain(&sd->gspca_dev,
+ sensor_settings[AUTO_GAIN_CTRL_IDX]);
return err;
}
@@ -360,7 +417,10 @@ int ov9650_start(struct sd *sd)
int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
int hor_offs = OV9650_LEFT_OFFSET;
- if (sensor_settings[VFLIP_IDX])
+ if ((!dmi_check_system(ov9650_flip_dmi_table) &&
+ sensor_settings[VFLIP_IDX]) ||
+ (dmi_check_system(ov9650_flip_dmi_table) &&
+ !sensor_settings[VFLIP_IDX]))
ver_offs--;
if (width <= 320)
@@ -406,6 +466,14 @@ int ov9650_start(struct sd *sd)
if (err < 0)
return err;
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 2);
+ if (err < 0)
+ return err;
+
err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA,
(hor_offs >> 8) & 0xff);
if (err < 0)
@@ -425,6 +493,10 @@ int ov9650_start(struct sd *sd)
if (err < 0)
return err;
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0);
+ if (err < 0)
+ return err;
+
switch (width) {
case 640:
PDEBUG(D_V4L2, "Configuring camera for VGA mode");
@@ -467,32 +539,15 @@ int ov9650_stop(struct sd *sd)
return m5602_write_sensor(sd, OV9650_COM2, &data, 1);
}
-int ov9650_power_down(struct sd *sd)
-{
- int i, err = 0;
- for (i = 0; i < ARRAY_SIZE(power_down_ov9650) && !err; i++) {
- u8 data = power_down_ov9650[i][2];
- if (power_down_ov9650[i][0] == SENSOR)
- err = m5602_write_sensor(sd,
- power_down_ov9650[i][1], &data, 1);
- else
- err = m5602_write_bridge(sd, power_down_ov9650[i][1],
- data);
- }
-
- return err;
-}
-
void ov9650_disconnect(struct sd *sd)
{
ov9650_stop(sd);
- ov9650_power_down(sd);
sd->sensor = NULL;
kfree(sd->sensor_priv);
}
-int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -502,7 +557,7 @@ int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -532,7 +587,7 @@ int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -542,7 +597,7 @@ int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
@@ -573,7 +628,7 @@ int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -583,7 +638,7 @@ int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
@@ -599,7 +654,7 @@ int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -610,7 +665,7 @@ int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
@@ -626,7 +681,7 @@ int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -636,7 +691,7 @@ int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
@@ -646,13 +701,20 @@ int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
sensor_settings[HFLIP_IDX] = val;
- i2c_data = ((val & 0x01) << 5) | (sensor_settings[VFLIP_IDX] << 4);
+
+ if (!dmi_check_system(ov9650_flip_dmi_table))
+ i2c_data = ((val & 0x01) << 5) |
+ (sensor_settings[VFLIP_IDX] << 4);
+ else
+ i2c_data = ((val & 0x01) << 5) |
+ (!sensor_settings[VFLIP_IDX] << 4);
+
err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1);
return err;
}
-int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -663,7 +725,7 @@ int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
@@ -673,6 +735,9 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "Set vertical flip to %d", val);
sensor_settings[VFLIP_IDX] = val;
+ if (dmi_check_system(ov9650_flip_dmi_table))
+ val = !val;
+
i2c_data = ((val & 0x01) << 4) | (sensor_settings[VFLIP_IDX] << 5);
err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1);
if (err < 0)
@@ -685,48 +750,38 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_auto_exposure(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
- *val = sensor_settings[GAIN_IDX];
- PDEBUG(D_V4L2, "Read gain %d", *val);
-
+ *val = sensor_settings[AUTO_EXPOSURE_IDX];
+ PDEBUG(D_V4L2, "Read auto exposure control %d", *val);
return 0;
}
-int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_auto_exposure(struct gspca_dev *gspca_dev,
+ __s32 val)
{
int err;
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
- PDEBUG(D_V4L2, "Set gain to %d", val);
-
- sensor_settings[GAIN_IDX] = val;
+ PDEBUG(D_V4L2, "Set auto exposure control to %d", val);
- /* Read the OV9650_VREF register first to avoid
- corrupting the VREF high and low bits */
- err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
- if (err < 0)
- return err;
-
- /* Mask away all uninteresting bits */
- i2c_data = ((val & 0x0300) >> 2) | (i2c_data & 0x3F);
- err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1);
+ sensor_settings[AUTO_EXPOSURE_IDX] = val;
+ err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
if (err < 0)
return err;
- /* The 8 LSBs */
- i2c_data = val & 0xff;
- err = m5602_write_sensor(sd, OV9650_GAIN, &i2c_data, 1);
+ i2c_data = ((i2c_data & 0xfe) | ((val & 0x01) << 0));
- return err;
+ return m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1);
}
-int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -735,7 +790,8 @@ int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val)
{
int err;
u8 i2c_data;
@@ -755,7 +811,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val)
+static int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
s32 *sensor_settings = sd->sensor_priv;
@@ -765,7 +821,7 @@ int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val)
return 0;
}
-int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
+static int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
@@ -780,9 +836,8 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
return err;
i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2));
- err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1);
- return err;
+ return m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1);
}
static void ov9650_dump_registers(struct sd *sd)
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h
index fcc54e4c0f4f..c98c40d69e05 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.h
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h
@@ -120,6 +120,10 @@
#define OV9650_SOFT_SLEEP (1 << 4)
#define OV9650_OUTPUT_DRIVE_2X (1 << 0)
+#define OV9650_DENOISE_ENABLE (1 << 5)
+#define OV9650_WHITE_PIXEL_ENABLE (1 << 1)
+#define OV9650_WHITE_PIXEL_OPTION (1 << 0)
+
#define OV9650_LEFT_OFFSET 0x62
#define GAIN_DEFAULT 0x14
@@ -137,29 +141,9 @@ int ov9650_probe(struct sd *sd);
int ov9650_init(struct sd *sd);
int ov9650_start(struct sd *sd);
int ov9650_stop(struct sd *sd);
-int ov9650_power_down(struct sd *sd);
void ov9650_disconnect(struct sd *sd);
-int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val);
-int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val);
-int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val);
-
-const static struct m5602_sensor ov9650 = {
+static const struct m5602_sensor ov9650 = {
.name = "OV9650",
.i2c_slave_id = 0x60,
.i2c_regW = 1,
@@ -167,7 +151,6 @@ const static struct m5602_sensor ov9650 = {
.init = ov9650_init,
.start = ov9650_start,
.stop = ov9650_stop,
- .power_down = ov9650_power_down,
.disconnect = ov9650_disconnect,
};
@@ -219,7 +202,7 @@ static const unsigned char init_ov9650[][3] =
/* Reset chip */
{SENSOR, OV9650_COM7, OV9650_REGISTER_RESET},
/* One extra reset is needed in order to make the sensor behave
- properly when resuming from ram */
+ properly when resuming from ram, could be a timing issue */
{SENSOR, OV9650_COM7, OV9650_REGISTER_RESET},
/* Enable double clock */
@@ -229,8 +212,7 @@ static const unsigned char init_ov9650[][3] =
/* Set fast AGC/AEC algorithm with unlimited step size */
{SENSOR, OV9650_COM8, OV9650_FAST_AGC_AEC |
- OV9650_AEC_UNLIM_STEP_SIZE |
- OV9650_AWB_EN | OV9650_AGC_EN},
+ OV9650_AEC_UNLIM_STEP_SIZE},
{SENSOR, OV9650_CHLF, 0x10},
{SENSOR, OV9650_ARBLM, 0xbf},
@@ -301,8 +283,11 @@ static const unsigned char init_ov9650[][3] =
{SENSOR, OV9650_VREF, 0x10},
{SENSOR, OV9650_ADC, 0x04},
{SENSOR, OV9650_HV, 0x40},
+
/* Enable denoise, and white-pixel erase */
- {SENSOR, OV9650_COM22, 0x23},
+ {SENSOR, OV9650_COM22, OV9650_DENOISE_ENABLE |
+ OV9650_WHITE_PIXEL_ENABLE |
+ OV9650_WHITE_PIXEL_OPTION},
/* Enable VARIOPIXEL */
{SENSOR, OV9650_COM3, OV9650_VARIOPIXEL},
@@ -312,26 +297,6 @@ static const unsigned char init_ov9650[][3] =
{SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},
};
-static const unsigned char power_down_ov9650[][3] =
-{
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- {SENSOR, OV9650_COM7, 0x80},
- {SENSOR, OV9650_OFON, 0xf4},
- {SENSOR, OV9650_MVFP, 0x80},
- {SENSOR, OV9650_DBLV, 0x3f},
- {SENSOR, OV9650_RSVD36, 0x49},
- {SENSOR, OV9650_COM7, 0x05},
-
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x06},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
-};
-
static const unsigned char res_init_ov9650[][3] =
{
{SENSOR, OV9650_COM2, OV9650_OUTPUT_DRIVE_2X},
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c
index eaddf488bad1..8d74d8065b79 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.c
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.c
@@ -18,6 +18,29 @@
#include "m5602_po1030.h"
+static int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_green_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
+static int po1030_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val);
+static int po1030_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val);
+static int po1030_set_auto_exposure(struct gspca_dev *gspca_dev,
+ __s32 val);
+static int po1030_get_auto_exposure(struct gspca_dev *gspca_dev,
+ __s32 *val);
+
static struct v4l2_pix_format po1030_modes[] = {
{
640,
@@ -27,11 +50,12 @@ static struct v4l2_pix_format po1030_modes[] = {
.sizeimage = 640 * 480,
.bytesperline = 640,
.colorspace = V4L2_COLORSPACE_SRGB,
- .priv = 0
+ .priv = 2
}
};
-const static struct ctrl po1030_ctrls[] = {
+static const struct ctrl po1030_ctrls[] = {
+#define GAIN_IDX 0
{
{
.id = V4L2_CID_GAIN,
@@ -45,7 +69,9 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_gain,
.get = po1030_get_gain
- }, {
+ },
+#define EXPOSURE_IDX 1
+ {
{
.id = V4L2_CID_EXPOSURE,
.type = V4L2_CTRL_TYPE_INTEGER,
@@ -58,7 +84,9 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_exposure,
.get = po1030_get_exposure
- }, {
+ },
+#define RED_BALANCE_IDX 2
+ {
{
.id = V4L2_CID_RED_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER,
@@ -71,7 +99,9 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_red_balance,
.get = po1030_get_red_balance
- }, {
+ },
+#define BLUE_BALANCE_IDX 3
+ {
{
.id = V4L2_CID_BLUE_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER,
@@ -84,7 +114,9 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_blue_balance,
.get = po1030_get_blue_balance
- }, {
+ },
+#define HFLIP_IDX 4
+ {
{
.id = V4L2_CID_HFLIP,
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -96,7 +128,9 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_hflip,
.get = po1030_get_hflip
- }, {
+ },
+#define VFLIP_IDX 5
+ {
{
.id = V4L2_CID_VFLIP,
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -108,14 +142,58 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_vflip,
.get = po1030_get_vflip
- }
+ },
+#define AUTO_WHITE_BALANCE_IDX 6
+ {
+ {
+ .id = V4L2_CID_AUTO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto white balance",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ .set = po1030_set_auto_white_balance,
+ .get = po1030_get_auto_white_balance
+ },
+#define AUTO_EXPOSURE_IDX 7
+ {
+ {
+ .id = V4L2_CID_EXPOSURE_AUTO,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto exposure",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ .set = po1030_set_auto_exposure,
+ .get = po1030_get_auto_exposure
+ },
+#define GREEN_BALANCE_IDX 8
+ {
+ {
+ .id = M5602_V4L2_CID_GREEN_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "green balance",
+ .minimum = 0x00,
+ .maximum = 0xff,
+ .step = 0x1,
+ .default_value = PO1030_GREEN_GAIN_DEFAULT,
+ .flags = V4L2_CTRL_FLAG_SLIDER
+ },
+ .set = po1030_set_green_balance,
+ .get = po1030_get_green_balance
+ },
};
static void po1030_dump_registers(struct sd *sd);
int po1030_probe(struct sd *sd)
{
- u8 prod_id = 0, ver_id = 0, i;
+ u8 dev_id_h = 0, i;
+ s32 *sensor_settings;
if (force_sensor) {
if (force_sensor == PO1030_SENSOR) {
@@ -139,28 +217,36 @@ int po1030_probe(struct sd *sd)
m5602_write_bridge(sd, preinit_po1030[i][1], data);
}
- if (m5602_read_sensor(sd, 0x3, &prod_id, 1))
+ if (m5602_read_sensor(sd, PO1030_DEVID_H, &dev_id_h, 1))
return -ENODEV;
- if (m5602_read_sensor(sd, 0x4, &ver_id, 1))
- return -ENODEV;
-
- if ((prod_id == 0x02) && (ver_id == 0xef)) {
+ if (dev_id_h == 0x30) {
info("Detected a po1030 sensor");
goto sensor_found;
}
return -ENODEV;
sensor_found:
+ sensor_settings = kmalloc(
+ ARRAY_SIZE(po1030_ctrls) * sizeof(s32), GFP_KERNEL);
+ if (!sensor_settings)
+ return -ENOMEM;
+
sd->gspca_dev.cam.cam_mode = po1030_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(po1030_modes);
sd->desc->ctrls = po1030_ctrls;
sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls);
+
+ for (i = 0; i < ARRAY_SIZE(po1030_ctrls); i++)
+ sensor_settings[i] = po1030_ctrls[i].qctrl.default_value;
+ sd->sensor_priv = sensor_settings;
+
return 0;
}
int po1030_init(struct sd *sd)
{
+ s32 *sensor_settings = sd->sensor_priv;
int i, err = 0;
/* Init the sensor */
@@ -185,47 +271,206 @@ int po1030_init(struct sd *sd)
return -EINVAL;
}
}
+ if (err < 0)
+ return err;
if (dump_sensor)
po1030_dump_registers(sd);
+ err = po1030_set_exposure(&sd->gspca_dev,
+ sensor_settings[EXPOSURE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_red_balance(&sd->gspca_dev,
+ sensor_settings[RED_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_blue_balance(&sd->gspca_dev,
+ sensor_settings[BLUE_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_green_balance(&sd->gspca_dev,
+ sensor_settings[GREEN_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_auto_white_balance(&sd->gspca_dev,
+ sensor_settings[AUTO_WHITE_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_auto_exposure(&sd->gspca_dev,
+ sensor_settings[AUTO_EXPOSURE_IDX]);
return err;
}
-int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
+int po1030_start(struct sd *sd)
{
- struct sd *sd = (struct sd *) gspca_dev;
- u8 i2c_data;
- int err;
+ struct cam *cam = &sd->gspca_dev.cam;
+ int i, err = 0;
+ int width = cam->cam_mode[sd->gspca_dev.curr_mode].width;
+ int height = cam->cam_mode[sd->gspca_dev.curr_mode].height;
+ int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
+ u8 data;
+
+ switch (width) {
+ case 320:
+ data = PO1030_SUBSAMPLING;
+ err = m5602_write_sensor(sd, PO1030_CONTROL3, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = ((width + 3) >> 8) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_H, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = (width + 3) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_L, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = ((height + 1) >> 8) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_H, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = (height + 1) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_L, &data, 1);
+
+ height += 6;
+ width -= 1;
+ break;
+
+ case 640:
+ data = 0;
+ err = m5602_write_sensor(sd, PO1030_CONTROL3, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = ((width + 7) >> 8) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_H, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = (width + 7) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_L, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = ((height + 3) >> 8) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_H, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = (height + 3) & 0xff;
+ err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_L, &data, 1);
+
+ height += 12;
+ width -= 2;
+ break;
+ }
+ err = m5602_write_bridge(sd, M5602_XB_SENSOR_TYPE, 0x0c);
+ if (err < 0)
+ return err;
- err = m5602_read_sensor(sd, PO1030_REG_INTEGLINES_H,
- &i2c_data, 1);
+ err = m5602_write_bridge(sd, M5602_XB_LINE_OF_FRAME_H, 0x81);
if (err < 0)
return err;
- *val = (i2c_data << 8);
- err = m5602_read_sensor(sd, PO1030_REG_INTEGLINES_M,
- &i2c_data, 1);
- *val |= i2c_data;
+ err = m5602_write_bridge(sd, M5602_XB_PIX_OF_LINE_H, 0x82);
+ if (err < 0)
+ return err;
- PDEBUG(D_V4L2, "Exposure read as %d", *val);
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0x01);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA,
+ ((ver_offs >> 8) & 0xff));
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (ver_offs & 0xff));
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < 2 && !err; i++)
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff));
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < 2 && !err; i++)
+ err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0);
+
+ for (i = 0; i < 2 && !err; i++)
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0);
+
+ for (i = 0; i < 2 && !err; i++)
+ err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, 0);
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, (width >> 8) & 0xff);
+ if (err < 0)
+ return err;
+ err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, (width & 0xff));
+ if (err < 0)
+ return err;
+
+ err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0);
return err;
}
-int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
+static int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[EXPOSURE_IDX];
+ PDEBUG(D_V4L2, "Exposure read as %d", *val);
+ return 0;
+}
+
+static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
+ sensor_settings[EXPOSURE_IDX] = val;
PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff);
i2c_data = ((val & 0xff00) >> 8);
PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x",
i2c_data);
- err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_H,
+ err = m5602_write_sensor(sd, PO1030_INTEGLINES_H,
&i2c_data, 1);
if (err < 0)
return err;
@@ -233,167 +478,256 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = (val & 0xff);
PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x",
i2c_data);
- err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_M,
+ err = m5602_write_sensor(sd, PO1030_INTEGLINES_M,
&i2c_data, 1);
return err;
}
-int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+static int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
- u8 i2c_data;
- int err;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_read_sensor(sd, PO1030_REG_GLOBALGAIN,
- &i2c_data, 1);
- *val = i2c_data;
+ *val = sensor_settings[GAIN_IDX];
PDEBUG(D_V4L2, "Read global gain %d", *val);
-
- return err;
+ return 0;
}
-int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
- err = m5602_read_sensor(sd, PO1030_REG_CONTROL2,
+ sensor_settings[GAIN_IDX] = val;
+
+ i2c_data = val & 0xff;
+ PDEBUG(D_V4L2, "Set global gain to %d", i2c_data);
+ err = m5602_write_sensor(sd, PO1030_GLOBALGAIN,
&i2c_data, 1);
+ return err;
+}
- *val = (i2c_data >> 7) & 0x01 ;
+static int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ *val = sensor_settings[HFLIP_IDX];
PDEBUG(D_V4L2, "Read hflip %d", *val);
- return err;
+ return 0;
}
-int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
+static int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
+ sensor_settings[HFLIP_IDX] = val;
+
PDEBUG(D_V4L2, "Set hflip %d", val);
- err = m5602_read_sensor(sd, PO1030_REG_CONTROL2, &i2c_data, 1);
+ err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1);
if (err < 0)
return err;
i2c_data = (0x7f & i2c_data) | ((val & 0x01) << 7);
- err = m5602_write_sensor(sd, PO1030_REG_CONTROL2,
+ err = m5602_write_sensor(sd, PO1030_CONTROL2,
&i2c_data, 1);
return err;
}
-int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
- u8 i2c_data;
- int err;
-
- err = m5602_read_sensor(sd, PO1030_REG_GLOBALGAIN,
- &i2c_data, 1);
-
- *val = (i2c_data >> 6) & 0x01;
+ s32 *sensor_settings = sd->sensor_priv;
+ *val = sensor_settings[VFLIP_IDX];
PDEBUG(D_V4L2, "Read vflip %d", *val);
- return err;
+ return 0;
}
-int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
+static int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
+ sensor_settings[VFLIP_IDX] = val;
+
PDEBUG(D_V4L2, "Set vflip %d", val);
- err = m5602_read_sensor(sd, PO1030_REG_CONTROL2, &i2c_data, 1);
+ err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1);
if (err < 0)
return err;
i2c_data = (i2c_data & 0xbf) | ((val & 0x01) << 6);
- err = m5602_write_sensor(sd, PO1030_REG_CONTROL2,
+ err = m5602_write_sensor(sd, PO1030_CONTROL2,
&i2c_data, 1);
return err;
}
-int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val)
+static int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[RED_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read red gain %d", *val);
+ return 0;
+}
+
+static int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
+ sensor_settings[RED_BALANCE_IDX] = val;
+
i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set global gain to %d", i2c_data);
- err = m5602_write_sensor(sd, PO1030_REG_GLOBALGAIN,
+ PDEBUG(D_V4L2, "Set red gain to %d", i2c_data);
+ err = m5602_write_sensor(sd, PO1030_RED_GAIN,
&i2c_data, 1);
return err;
}
-int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
+static int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
- u8 i2c_data;
- int err;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_read_sensor(sd, PO1030_REG_RED_GAIN,
- &i2c_data, 1);
- *val = i2c_data;
- PDEBUG(D_V4L2, "Read red gain %d", *val);
- return err;
+ *val = sensor_settings[BLUE_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read blue gain %d", *val);
+
+ return 0;
}
-int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
+static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
+ sensor_settings[BLUE_BALANCE_IDX] = val;
+
i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set red gain to %d", i2c_data);
- err = m5602_write_sensor(sd, PO1030_REG_RED_GAIN,
+ PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data);
+ err = m5602_write_sensor(sd, PO1030_BLUE_GAIN,
&i2c_data, 1);
+
return err;
}
-int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
+static int po1030_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[GREEN_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Read green gain %d", *val);
+
+ return 0;
+}
+
+static int po1030_set_green_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
- err = m5602_read_sensor(sd, PO1030_REG_BLUE_GAIN,
+ sensor_settings[GREEN_BALANCE_IDX] = val;
+ i2c_data = val & 0xff;
+ PDEBUG(D_V4L2, "Set green gain to %d", i2c_data);
+
+ err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN,
+ &i2c_data, 1);
+ if (err < 0)
+ return err;
+
+ return m5602_write_sensor(sd, PO1030_GREEN_2_GAIN,
&i2c_data, 1);
- *val = i2c_data;
- PDEBUG(D_V4L2, "Read blue gain %d", *val);
+}
- return err;
+static int po1030_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[AUTO_WHITE_BALANCE_IDX];
+ PDEBUG(D_V4L2, "Auto white balancing is %d", *val);
+
+ return 0;
}
-int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
+static int po1030_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 i2c_data;
int err;
- i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data);
- err = m5602_write_sensor(sd, PO1030_REG_BLUE_GAIN,
- &i2c_data, 1);
+ sensor_settings[AUTO_WHITE_BALANCE_IDX] = val;
+
+ err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
+ if (err < 0)
+ return err;
+
+ PDEBUG(D_V4L2, "Set auto white balance to %d", val);
+ i2c_data = (i2c_data & 0xfe) | (val & 0x01);
+ err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
return err;
}
-int po1030_power_down(struct sd *sd)
+static int po1030_get_auto_exposure(struct gspca_dev *gspca_dev,
+ __s32 *val)
{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[AUTO_EXPOSURE_IDX];
+ PDEBUG(D_V4L2, "Auto exposure is %d", *val);
return 0;
}
+static int po1030_set_auto_exposure(struct gspca_dev *gspca_dev,
+ __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ u8 i2c_data;
+ int err;
+
+ sensor_settings[AUTO_EXPOSURE_IDX] = val;
+ err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
+ if (err < 0)
+ return err;
+
+ PDEBUG(D_V4L2, "Set auto exposure to %d", val);
+ i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1);
+ return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
+}
+
+void po1030_disconnect(struct sd *sd)
+{
+ sd->sensor = NULL;
+ kfree(sd->sensor_priv);
+}
+
static void po1030_dump_registers(struct sd *sd)
{
int address;
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h
index c10b12335818..1ea380b2bbe7 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.h
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.h
@@ -25,98 +25,123 @@
/*****************************************************************************/
-#define PO1030_REG_DEVID_H 0x00
-#define PO1030_REG_DEVID_L 0x01
-#define PO1030_REG_FRAMEWIDTH_H 0x04
-#define PO1030_REG_FRAMEWIDTH_L 0x05
-#define PO1030_REG_FRAMEHEIGHT_H 0x06
-#define PO1030_REG_FRAMEHEIGHT_L 0x07
-#define PO1030_REG_WINDOWX_H 0x08
-#define PO1030_REG_WINDOWX_L 0x09
-#define PO1030_REG_WINDOWY_H 0x0a
-#define PO1030_REG_WINDOWY_L 0x0b
-#define PO1030_REG_WINDOWWIDTH_H 0x0c
-#define PO1030_REG_WINDOWWIDTH_L 0x0d
-#define PO1030_REG_WINDOWHEIGHT_H 0x0e
-#define PO1030_REG_WINDOWHEIGHT_L 0x0f
-
-#define PO1030_REG_GLOBALIBIAS 0x12
-#define PO1030_REG_PIXELIBIAS 0x13
-
-#define PO1030_REG_GLOBALGAIN 0x15
-#define PO1030_REG_RED_GAIN 0x16
-#define PO1030_REG_GREEN_1_GAIN 0x17
-#define PO1030_REG_BLUE_GAIN 0x18
-#define PO1030_REG_GREEN_2_GAIN 0x19
-
-#define PO1030_REG_INTEGLINES_H 0x1a
-#define PO1030_REG_INTEGLINES_M 0x1b
-#define PO1030_REG_INTEGLINES_L 0x1c
-
-#define PO1030_REG_CONTROL1 0x1d
-#define PO1030_REG_CONTROL2 0x1e
-#define PO1030_REG_CONTROL3 0x1f
-#define PO1030_REG_CONTROL4 0x20
-
-#define PO1030_REG_PERIOD50_H 0x23
-#define PO1030_REG_PERIOD50_L 0x24
-#define PO1030_REG_PERIOD60_H 0x25
-#define PO1030_REG_PERIOD60_L 0x26
-#define PO1030_REG_REGCLK167 0x27
-#define PO1030_REG_DELTA50 0x28
-#define PO1030_REG_DELTA60 0x29
-
-#define PO1030_REG_ADCOFFSET 0x2c
+#define PO1030_DEVID_H 0x00
+#define PO1030_DEVID_L 0x01
+#define PO1030_FRAMEWIDTH_H 0x04
+#define PO1030_FRAMEWIDTH_L 0x05
+#define PO1030_FRAMEHEIGHT_H 0x06
+#define PO1030_FRAMEHEIGHT_L 0x07
+#define PO1030_WINDOWX_H 0x08
+#define PO1030_WINDOWX_L 0x09
+#define PO1030_WINDOWY_H 0x0a
+#define PO1030_WINDOWY_L 0x0b
+#define PO1030_WINDOWWIDTH_H 0x0c
+#define PO1030_WINDOWWIDTH_L 0x0d
+#define PO1030_WINDOWHEIGHT_H 0x0e
+#define PO1030_WINDOWHEIGHT_L 0x0f
+
+#define PO1030_GLOBALIBIAS 0x12
+#define PO1030_PIXELIBIAS 0x13
+
+#define PO1030_GLOBALGAIN 0x15
+#define PO1030_RED_GAIN 0x16
+#define PO1030_GREEN_1_GAIN 0x17
+#define PO1030_BLUE_GAIN 0x18
+#define PO1030_GREEN_2_GAIN 0x19
+
+#define PO1030_INTEGLINES_H 0x1a
+#define PO1030_INTEGLINES_M 0x1b
+#define PO1030_INTEGLINES_L 0x1c
+
+#define PO1030_CONTROL1 0x1d
+#define PO1030_CONTROL2 0x1e
+#define PO1030_CONTROL3 0x1f
+#define PO1030_CONTROL4 0x20
+
+#define PO1030_PERIOD50_H 0x23
+#define PO1030_PERIOD50_L 0x24
+#define PO1030_PERIOD60_H 0x25
+#define PO1030_PERIOD60_L 0x26
+#define PO1030_REGCLK167 0x27
+#define PO1030_FLICKER_DELTA50 0x28
+#define PO1030_FLICKERDELTA60 0x29
+
+#define PO1030_ADCOFFSET 0x2c
/* Gamma Correction Coeffs */
-#define PO1030_REG_GC0 0x2d
-#define PO1030_REG_GC1 0x2e
-#define PO1030_REG_GC2 0x2f
-#define PO1030_REG_GC3 0x30
-#define PO1030_REG_GC4 0x31
-#define PO1030_REG_GC5 0x32
-#define PO1030_REG_GC6 0x33
-#define PO1030_REG_GC7 0x34
+#define PO1030_GC0 0x2d
+#define PO1030_GC1 0x2e
+#define PO1030_GC2 0x2f
+#define PO1030_GC3 0x30
+#define PO1030_GC4 0x31
+#define PO1030_GC5 0x32
+#define PO1030_GC6 0x33
+#define PO1030_GC7 0x34
/* Color Transform Matrix */
-#define PO1030_REG_CT0 0x35
-#define PO1030_REG_CT1 0x36
-#define PO1030_REG_CT2 0x37
-#define PO1030_REG_CT3 0x38
-#define PO1030_REG_CT4 0x39
-#define PO1030_REG_CT5 0x3a
-#define PO1030_REG_CT6 0x3b
-#define PO1030_REG_CT7 0x3c
-#define PO1030_REG_CT8 0x3d
-
-#define PO1030_REG_AUTOCTRL1 0x3e
-#define PO1030_REG_AUTOCTRL2 0x3f
-
-#define PO1030_REG_YTARGET 0x40
-#define PO1030_REG_GLOBALGAINMIN 0x41
-#define PO1030_REG_GLOBALGAINMAX 0x42
+#define PO1030_CT0 0x35
+#define PO1030_CT1 0x36
+#define PO1030_CT2 0x37
+#define PO1030_CT3 0x38
+#define PO1030_CT4 0x39
+#define PO1030_CT5 0x3a
+#define PO1030_CT6 0x3b
+#define PO1030_CT7 0x3c
+#define PO1030_CT8 0x3d
+
+#define PO1030_AUTOCTRL1 0x3e
+#define PO1030_AUTOCTRL2 0x3f
+
+#define PO1030_YTARGET 0x40
+#define PO1030_GLOBALGAINMIN 0x41
+#define PO1030_GLOBALGAINMAX 0x42
+
+#define PO1030_AWB_RED_TUNING 0x47
+#define PO1030_AWB_BLUE_TUNING 0x48
/* Output format control */
-#define PO1030_REG_OUTFORMCTRL1 0x5a
-#define PO1030_REG_OUTFORMCTRL2 0x5b
-#define PO1030_REG_OUTFORMCTRL3 0x5c
-#define PO1030_REG_OUTFORMCTRL4 0x5d
-#define PO1030_REG_OUTFORMCTRL5 0x5e
+#define PO1030_OUTFORMCTRL1 0x5a
+#define PO1030_OUTFORMCTRL2 0x5b
+#define PO1030_OUTFORMCTRL3 0x5c
+#define PO1030_OUTFORMCTRL4 0x5d
+#define PO1030_OUTFORMCTRL5 0x5e
-/* Imaging coefficients */
-#define PO1030_REG_YBRIGHT 0x73
-#define PO1030_REG_YCONTRAST 0x74
-#define PO1030_REG_YSATURATION 0x75
+#define PO1030_EDGE_ENH_OFF 0x5f
+#define PO1030_EGA 0x60
-#define PO1030_HFLIP (1 << 7)
-#define PO1030_VFLIP (1 << 6)
+#define PO1030_Cb_U_GAIN 0x63
+#define PO1030_Cr_V_GAIN 0x64
+
+#define PO1030_YCONTRAST 0x74
+#define PO1030_YSATURATION 0x75
+
+#define PO1030_HFLIP (1 << 7)
+#define PO1030_VFLIP (1 << 6)
+
+#define PO1030_HREF_ENABLE (1 << 6)
+
+#define PO1030_RAW_RGB_BAYER 0x4
+
+#define PO1030_FRAME_EQUAL (1 << 3)
+#define PO1030_AUTO_SUBSAMPLING (1 << 4)
+
+#define PO1030_WEIGHT_WIN_2X (1 << 3)
+
+#define PO1030_SHUTTER_MODE (1 << 6)
+#define PO1030_AUTO_SUBSAMPLING (1 << 4)
+#define PO1030_FRAME_EQUAL (1 << 3)
+
+#define PO1030_SENSOR_RESET (1 << 5)
+
+#define PO1030_SUBSAMPLING (1 << 6)
/*****************************************************************************/
#define PO1030_GLOBAL_GAIN_DEFAULT 0x12
#define PO1030_EXPOSURE_DEFAULT 0x0085
-#define PO1030_BLUE_GAIN_DEFAULT 0x40
-#define PO1030_RED_GAIN_DEFAULT 0x40
+#define PO1030_BLUE_GAIN_DEFAULT 0x36
+#define PO1030_RED_GAIN_DEFAULT 0x36
+#define PO1030_GREEN_GAIN_DEFAULT 0x40
/*****************************************************************************/
@@ -126,20 +151,8 @@ extern int dump_sensor;
int po1030_probe(struct sd *sd);
int po1030_init(struct sd *sd);
-int po1030_power_down(struct sd *sd);
-
-int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
-int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
-int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
-int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val);
-int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
-int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
-int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
-int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
-int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
-int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
-int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
-int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
+int po1030_start(struct sd *sd);
+void po1030_disconnect(struct sd *sd);
static const struct m5602_sensor po1030 = {
.name = "PO1030",
@@ -149,7 +162,8 @@ static const struct m5602_sensor po1030 = {
.probe = po1030_probe,
.init = po1030_init,
- .power_down = po1030_power_down,
+ .start = po1030_start,
+ .disconnect = po1030_disconnect,
};
static const unsigned char preinit_po1030[][3] =
@@ -159,248 +173,103 @@ static const unsigned char preinit_po1030[][3] =
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d},
{BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
{BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
-
- {SENSOR, PO1030_REG_AUTOCTRL2, 0x24},
-
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},
- {BRIDGE, M5602_XB_SIG_INI, 0x01},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x02},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xec},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x87},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
-
- {SENSOR, PO1030_REG_AUTOCTRL2, 0x24},
-
{BRIDGE, M5602_XB_GPIO_DIR, 0x05},
{BRIDGE, M5602_XB_GPIO_DAT, 0x04},
{BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
{BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
+
+ {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)},
+
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
{BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
{BRIDGE, M5602_XB_GPIO_DIR, 0x05},
{BRIDGE, M5602_XB_GPIO_DAT, 0x00}
};
-static const unsigned char init_po1030[][4] =
+static const unsigned char init_po1030[][3] =
{
{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
- /*sequence 1*/
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d},
-
{BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
{BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
- /*end of sequence 1*/
-
- /*sequence 2 (same as stop sequence)*/
- {SENSOR, PO1030_REG_AUTOCTRL2, 0x24},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- /*end of sequence 2*/
- /*sequence 5*/
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},
- {BRIDGE, M5602_XB_SIG_INI, 0x01},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x02},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xec},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x87},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
- /*end of sequence 5*/
-
- /*sequence 2 stop */
- {SENSOR, PO1030_REG_AUTOCTRL2, 0x24},
+ {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)},
{BRIDGE, M5602_XB_GPIO_DIR, 0x05},
{BRIDGE, M5602_XB_GPIO_DAT, 0x04},
{BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
{BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- /*end of sequence 2 stop */
-
-/* ---------------------------------
- * end of init - begin of start
- * --------------------------------- */
-
- /*sequence 3*/
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
- /*end of sequence 3*/
- /*sequence 4*/
{BRIDGE, M5602_XB_GPIO_DIR, 0x05},
{BRIDGE, M5602_XB_GPIO_DAT, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
- {SENSOR, PO1030_REG_AUTOCTRL2, 0x04},
+ {SENSOR, PO1030_AUTOCTRL2, 0x04},
+
+ {SENSOR, PO1030_OUTFORMCTRL2, PO1030_RAW_RGB_BAYER},
+ {SENSOR, PO1030_AUTOCTRL1, PO1030_WEIGHT_WIN_2X},
+
+ {SENSOR, PO1030_CONTROL2, 0x03},
+ {SENSOR, 0x21, 0x90},
+ {SENSOR, PO1030_YTARGET, 0x60},
+ {SENSOR, 0x59, 0x13},
+ {SENSOR, PO1030_OUTFORMCTRL1, PO1030_HREF_ENABLE},
+ {SENSOR, PO1030_EDGE_ENH_OFF, 0x00},
+ {SENSOR, PO1030_EGA, 0x80},
+ {SENSOR, 0x78, 0x14},
+ {SENSOR, 0x6f, 0x01},
+ {SENSOR, PO1030_GLOBALGAINMAX, 0x14},
+ {SENSOR, PO1030_Cb_U_GAIN, 0x38},
+ {SENSOR, PO1030_Cr_V_GAIN, 0x38},
+ {SENSOR, PO1030_CONTROL1, PO1030_SHUTTER_MODE |
+ PO1030_AUTO_SUBSAMPLING |
+ PO1030_FRAME_EQUAL},
+ {SENSOR, PO1030_GC0, 0x10},
+ {SENSOR, PO1030_GC1, 0x20},
+ {SENSOR, PO1030_GC2, 0x40},
+ {SENSOR, PO1030_GC3, 0x60},
+ {SENSOR, PO1030_GC4, 0x80},
+ {SENSOR, PO1030_GC5, 0xa0},
+ {SENSOR, PO1030_GC6, 0xc0},
+ {SENSOR, PO1030_GC7, 0xff},
/* Set the width to 751 */
- {SENSOR, PO1030_REG_FRAMEWIDTH_H, 0x02},
- {SENSOR, PO1030_REG_FRAMEWIDTH_L, 0xef},
+ {SENSOR, PO1030_FRAMEWIDTH_H, 0x02},
+ {SENSOR, PO1030_FRAMEWIDTH_L, 0xef},
/* Set the height to 540 */
- {SENSOR, PO1030_REG_FRAMEHEIGHT_H, 0x02},
- {SENSOR, PO1030_REG_FRAMEHEIGHT_L, 0x1c},
+ {SENSOR, PO1030_FRAMEHEIGHT_H, 0x02},
+ {SENSOR, PO1030_FRAMEHEIGHT_L, 0x1c},
/* Set the x window to 1 */
- {SENSOR, PO1030_REG_WINDOWX_H, 0x00},
- {SENSOR, PO1030_REG_WINDOWX_L, 0x01},
+ {SENSOR, PO1030_WINDOWX_H, 0x00},
+ {SENSOR, PO1030_WINDOWX_L, 0x01},
/* Set the y window to 1 */
- {SENSOR, PO1030_REG_WINDOWY_H, 0x00},
- {SENSOR, PO1030_REG_WINDOWY_L, 0x01},
-
- {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02},
- {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87},
- {SENSOR, PO1030_REG_WINDOWHEIGHT_H, 0x01},
- {SENSOR, PO1030_REG_WINDOWHEIGHT_L, 0xe3},
-
- {SENSOR, PO1030_REG_OUTFORMCTRL2, 0x04},
- {SENSOR, PO1030_REG_OUTFORMCTRL2, 0x04},
- {SENSOR, PO1030_REG_AUTOCTRL1, 0x08},
- {SENSOR, PO1030_REG_CONTROL2, 0x03},
- {SENSOR, 0x21, 0x90},
- {SENSOR, PO1030_REG_YTARGET, 0x60},
- {SENSOR, 0x59, 0x13},
- {SENSOR, PO1030_REG_OUTFORMCTRL1, 0x40},
- {SENSOR, 0x5f, 0x00},
- {SENSOR, 0x60, 0x80},
- {SENSOR, 0x78, 0x14},
- {SENSOR, 0x6f, 0x01},
- {SENSOR, PO1030_REG_CONTROL1, 0x18},
- {SENSOR, PO1030_REG_GLOBALGAINMAX, 0x14},
- {SENSOR, 0x63, 0x38},
- {SENSOR, 0x64, 0x38},
- {SENSOR, PO1030_REG_CONTROL1, 0x58},
- {SENSOR, PO1030_REG_RED_GAIN, 0x30},
- {SENSOR, PO1030_REG_GREEN_1_GAIN, 0x30},
- {SENSOR, PO1030_REG_BLUE_GAIN, 0x30},
- {SENSOR, PO1030_REG_GREEN_2_GAIN, 0x30},
- {SENSOR, PO1030_REG_GC0, 0x10},
- {SENSOR, PO1030_REG_GC1, 0x20},
- {SENSOR, PO1030_REG_GC2, 0x40},
- {SENSOR, PO1030_REG_GC3, 0x60},
- {SENSOR, PO1030_REG_GC4, 0x80},
- {SENSOR, PO1030_REG_GC5, 0xa0},
- {SENSOR, PO1030_REG_GC6, 0xc0},
- {SENSOR, PO1030_REG_GC7, 0xff},
- /*end of sequence 4*/
- /*sequence 5*/
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},
- {BRIDGE, M5602_XB_SIG_INI, 0x01},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x02},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xec},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x7e},
- {BRIDGE, M5602_XB_SIG_INI, 0x00},
- /*end of sequence 5*/
-
- /*sequence 6*/
- /* Changing 40 in f0 the image becomes green in bayer mode and red in
- * rgb mode */
- {SENSOR, PO1030_REG_RED_GAIN, PO1030_RED_GAIN_DEFAULT},
- /* in changing 40 in f0 the image becomes green in bayer mode and red in
- * rgb mode */
- {SENSOR, PO1030_REG_BLUE_GAIN, PO1030_BLUE_GAIN_DEFAULT},
+ {SENSOR, PO1030_WINDOWY_H, 0x00},
+ {SENSOR, PO1030_WINDOWY_L, 0x01},
/* with a very low lighted environment increase the exposure but
* decrease the FPS (Frame Per Second) */
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
- /* Controls high exposure more than SENSOR_LOW_EXPOSURE, use only in
- * low lighted environment (f0 is more than ff ?)*/
- {SENSOR, PO1030_REG_INTEGLINES_H, ((PO1030_EXPOSURE_DEFAULT >> 2)
- & 0xff)},
-
- /* Controls middle exposure, use only in high lighted environment */
- {SENSOR, PO1030_REG_INTEGLINES_M, PO1030_EXPOSURE_DEFAULT & 0xff},
-
- /* Controls clarity (not sure) */
- {SENSOR, PO1030_REG_INTEGLINES_L, 0x00},
- /* Controls gain (the image is more lighted) */
- {SENSOR, PO1030_REG_GLOBALGAIN, PO1030_GLOBAL_GAIN_DEFAULT},
-
- /* Sets the width */
- {SENSOR, PO1030_REG_FRAMEWIDTH_H, 0x02},
- {SENSOR, PO1030_REG_FRAMEWIDTH_L, 0xef}
- /*end of sequence 6*/
+ {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
+ {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
+ {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
};
#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index 4306d596056d..e5fed5b89ff4 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -18,6 +18,19 @@
#include "m5602_s5k4aa.h"
+static int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k4aa_get_brightness(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val);
+
static
const
struct dmi_system_id s5k4aa_vflip_dmi_table[] = {
@@ -46,6 +59,12 @@ static
DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
DMI_MATCH(DMI_PRODUCT_NAME, "GX700/GX705/EX700")
}
+ }, {
+ .ident = "MSI L735",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MS-1717X")
+ }
},
{ }
};
@@ -61,10 +80,22 @@ static struct v4l2_pix_format s5k4aa_modes[] = {
.bytesperline = 640,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0
+ },
+ {
+ 1280,
+ 1024,
+ V4L2_PIX_FMT_SBGGR8,
+ V4L2_FIELD_NONE,
+ .sizeimage =
+ 1280 * 1024,
+ .bytesperline = 1280,
+ .colorspace = V4L2_COLORSPACE_SRGB,
+ .priv = 0
}
};
-const static struct ctrl s5k4aa_ctrls[] = {
+static const struct ctrl s5k4aa_ctrls[] = {
+#define VFLIP_IDX 0
{
{
.id = V4L2_CID_VFLIP,
@@ -77,8 +108,9 @@ const static struct ctrl s5k4aa_ctrls[] = {
},
.set = s5k4aa_set_vflip,
.get = s5k4aa_get_vflip
-
- }, {
+ },
+#define HFLIP_IDX 1
+ {
{
.id = V4L2_CID_HFLIP,
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -90,8 +122,9 @@ const static struct ctrl s5k4aa_ctrls[] = {
},
.set = s5k4aa_set_hflip,
.get = s5k4aa_get_hflip
-
- }, {
+ },
+#define GAIN_IDX 2
+ {
{
.id = V4L2_CID_GAIN,
.type = V4L2_CTRL_TYPE_INTEGER,
@@ -99,12 +132,14 @@ const static struct ctrl s5k4aa_ctrls[] = {
.minimum = 0,
.maximum = 127,
.step = 1,
- .default_value = 0xa0,
+ .default_value = S5K4AA_DEFAULT_GAIN,
.flags = V4L2_CTRL_FLAG_SLIDER
},
.set = s5k4aa_set_gain,
.get = s5k4aa_get_gain
- }, {
+ },
+#define EXPOSURE_IDX 3
+ {
{
.id = V4L2_CID_EXPOSURE,
.type = V4L2_CTRL_TYPE_INTEGER,
@@ -117,7 +152,36 @@ const static struct ctrl s5k4aa_ctrls[] = {
},
.set = s5k4aa_set_exposure,
.get = s5k4aa_get_exposure
- }
+ },
+#define NOISE_SUPP_IDX 4
+ {
+ {
+ .id = V4L2_CID_PRIVATE_BASE,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Noise suppression (smoothing)",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1,
+ },
+ .set = s5k4aa_set_noise,
+ .get = s5k4aa_get_noise
+ },
+#define BRIGHTNESS_IDX 5
+ {
+ {
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Brightness",
+ .minimum = 0,
+ .maximum = 0x1f,
+ .step = 1,
+ .default_value = S5K4AA_DEFAULT_BRIGHTNESS,
+ },
+ .set = s5k4aa_set_brightness,
+ .get = s5k4aa_get_brightness
+ },
+
};
static void s5k4aa_dump_registers(struct sd *sd);
@@ -127,6 +191,7 @@ int s5k4aa_probe(struct sd *sd)
u8 prod_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const u8 expected_prod_id[6] = {0x00, 0x10, 0x00, 0x4b, 0x33, 0x75};
int i, err = 0;
+ s32 *sensor_settings;
if (force_sensor) {
if (force_sensor == S5K4AA_SENSOR) {
@@ -185,10 +250,20 @@ int s5k4aa_probe(struct sd *sd)
info("Detected a s5k4aa sensor");
sensor_found:
+ sensor_settings = kmalloc(
+ ARRAY_SIZE(s5k4aa_ctrls) * sizeof(s32), GFP_KERNEL);
+ if (!sensor_settings)
+ return -ENOMEM;
+
sd->gspca_dev.cam.cam_mode = s5k4aa_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k4aa_modes);
sd->desc->ctrls = s5k4aa_ctrls;
sd->desc->nctrls = ARRAY_SIZE(s5k4aa_ctrls);
+
+ for (i = 0; i < ARRAY_SIZE(s5k4aa_ctrls); i++)
+ sensor_settings[i] = s5k4aa_ctrls[i].qctrl.default_value;
+ sd->sensor_priv = sensor_settings;
+
return 0;
}
@@ -197,9 +272,45 @@ int s5k4aa_start(struct sd *sd)
int i, err = 0;
u8 data[2];
struct cam *cam = &sd->gspca_dev.cam;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) {
+ case 1280:
+ PDEBUG(D_V4L2, "Configuring camera for SXGA mode");
+
+ for (i = 0; i < ARRAY_SIZE(SXGA_s5k4aa); i++) {
+ switch (SXGA_s5k4aa[i][0]) {
+ case BRIDGE:
+ err = m5602_write_bridge(sd,
+ SXGA_s5k4aa[i][1],
+ SXGA_s5k4aa[i][2]);
+ break;
+
+ case SENSOR:
+ data[0] = SXGA_s5k4aa[i][2];
+ err = m5602_write_sensor(sd,
+ SXGA_s5k4aa[i][1],
+ data, 1);
+ break;
+
+ case SENSOR_LONG:
+ data[0] = SXGA_s5k4aa[i][2];
+ data[1] = SXGA_s5k4aa[i][3];
+ err = m5602_write_sensor(sd,
+ SXGA_s5k4aa[i][1],
+ data, 2);
+ break;
+
+ default:
+ err("Invalid stream command, exiting init");
+ return -EINVAL;
+ }
+ }
+ err = s5k4aa_set_noise(&sd->gspca_dev, 0);
+ if (err < 0)
+ return err;
+ break;
- switch (cam->cam_mode[sd->gspca_dev.curr_mode].width)
- {
case 640:
PDEBUG(D_V4L2, "Configuring camera for VGA mode");
@@ -231,8 +342,37 @@ int s5k4aa_start(struct sd *sd)
return -EINVAL;
}
}
+ err = s5k4aa_set_noise(&sd->gspca_dev, 1);
+ if (err < 0)
+ return err;
+ break;
}
- return err;
+ if (err < 0)
+ return err;
+
+ err = s5k4aa_set_exposure(&sd->gspca_dev,
+ sensor_settings[EXPOSURE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = s5k4aa_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
+ if (err < 0)
+ return err;
+
+ err = s5k4aa_set_brightness(&sd->gspca_dev,
+ sensor_settings[BRIGHTNESS_IDX]);
+ if (err < 0)
+ return err;
+
+ err = s5k4aa_set_noise(&sd->gspca_dev, sensor_settings[NOISE_SUPP_IDX]);
+ if (err < 0)
+ return err;
+
+ err = s5k4aa_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
+ if (err < 0)
+ return err;
+
+ return s5k4aa_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
}
int s5k4aa_init(struct sd *sd)
@@ -270,62 +410,28 @@ int s5k4aa_init(struct sd *sd)
if (dump_sensor)
s5k4aa_dump_registers(sd);
- if (!err && dmi_check_system(s5k4aa_vflip_dmi_table)) {
- u8 data = 0x02;
- info("vertical flip quirk active");
- m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
- m5602_read_sensor(sd, S5K4AA_READ_MODE, &data, 1);
- data |= S5K4AA_RM_V_FLIP;
- data &= ~S5K4AA_RM_H_FLIP;
- m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
-
- /* Decrement COLSTART to preserve color order (BGGR) */
- m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
- data--;
- m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
-
- /* Increment ROWSTART to preserve color order (BGGR) */
- m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
- data++;
- m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
- }
-
- return (err < 0) ? err : 0;
-}
-
-int s5k4aa_power_down(struct sd *sd)
-{
- return 0;
+ return err;
}
-int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
- u8 data = S5K4AA_PAGE_MAP_2;
- int err;
-
- err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
- if (err < 0)
- return err;
-
- err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1);
- if (err < 0)
- return err;
+ s32 *sensor_settings = sd->sensor_priv;
- *val = data << 8;
- err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1);
- *val |= data;
+ *val = sensor_settings[EXPOSURE_IDX];
PDEBUG(D_V4L2, "Read exposure %d", *val);
- return err;
+ return 0;
}
-int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
+ sensor_settings[EXPOSURE_IDX] = val;
PDEBUG(D_V4L2, "Set exposure to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
@@ -340,29 +446,26 @@ int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
-int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
- u8 data = S5K4AA_PAGE_MAP_2;
- int err;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
- if (err < 0)
- return err;
-
- err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
- *val = (data & S5K4AA_RM_V_FLIP) >> 7;
+ *val = sensor_settings[VFLIP_IDX];
PDEBUG(D_V4L2, "Read vertical flip %d", *val);
- return err;
+ return 0;
}
-int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
+ sensor_settings[VFLIP_IDX] = val;
+
PDEBUG(D_V4L2, "Set vertical flip to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
@@ -370,56 +473,48 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0)
return err;
- data = ((data & ~S5K4AA_RM_V_FLIP)
- | ((val & 0x01) << 7));
- err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
+
+ err = m5602_read_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0)
return err;
- if (val) {
- err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
- if (err < 0)
- return err;
-
- data++;
- err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
- } else {
- err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
- if (err < 0)
- return err;
+ if (dmi_check_system(s5k4aa_vflip_dmi_table))
+ val = !val;
- data--;
- err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
- }
+ data = ((data & ~S5K4AA_RM_V_FLIP) | ((val & 0x01) << 7));
+ err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
+ if (err < 0)
+ return err;
+ err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
+ if (err < 0)
+ return err;
+ data = (data & 0xfe) | !val;
+ err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
return err;
}
-int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
- u8 data = S5K4AA_PAGE_MAP_2;
- int err;
-
- err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
- if (err < 0)
- return err;
+ s32 *sensor_settings = sd->sensor_priv;
- err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
- *val = (data & S5K4AA_RM_H_FLIP) >> 6;
+ *val = sensor_settings[HFLIP_IDX];
PDEBUG(D_V4L2, "Read horizontal flip %d", *val);
- return err;
+ return 0;
}
-int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
- PDEBUG(D_V4L2, "Set horizontal flip to %d",
- val);
+ sensor_settings[HFLIP_IDX] = val;
+
+ PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
@@ -427,62 +522,116 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
if (err < 0)
return err;
+ err = m5602_read_sensor(sd, S5K4AA_READ_MODE, &data, 1);
+ if (err < 0)
+ return err;
+
+ if (dmi_check_system(s5k4aa_vflip_dmi_table))
+ val = !val;
+
data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6));
err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0)
return err;
- if (val) {
- err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
- if (err < 0)
- return err;
- data++;
- err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
- if (err < 0)
- return err;
- } else {
- err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
- if (err < 0)
- return err;
- data--;
- err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
- }
-
+ err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
+ if (err < 0)
+ return err;
+ data = (data & 0xfe) | !val;
+ err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
return err;
}
-int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[GAIN_IDX];
+ PDEBUG(D_V4L2, "Read gain %d", *val);
+ return 0;
+}
+
+static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
+ sensor_settings[GAIN_IDX] = val;
+
+ PDEBUG(D_V4L2, "Set gain to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
- err = m5602_read_sensor(sd, S5K4AA_GAIN_2, &data, 1);
- *val = data;
- PDEBUG(D_V4L2, "Read gain %d", *val);
+ data = val & 0xff;
+ err = m5602_write_sensor(sd, S5K4AA_GAIN, &data, 1);
return err;
}
-int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k4aa_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[BRIGHTNESS_IDX];
+ PDEBUG(D_V4L2, "Read brightness %d", *val);
+ return 0;
+}
+
+static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
- PDEBUG(D_V4L2, "Set gain to %d", val);
+ sensor_settings[BRIGHTNESS_IDX] = val;
+
+ PDEBUG(D_V4L2, "Set brightness to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
data = val & 0xff;
- err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1);
+ return m5602_write_sensor(sd, S5K4AA_BRIGHTNESS, &data, 1);
+}
- return err;
+static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[NOISE_SUPP_IDX];
+ PDEBUG(D_V4L2, "Read noise %d", *val);
+ return 0;
+}
+
+static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ u8 data = S5K4AA_PAGE_MAP_2;
+ int err;
+
+ sensor_settings[NOISE_SUPP_IDX] = val;
+
+ PDEBUG(D_V4L2, "Set noise to %d", val);
+ err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = val & 0x01;
+ return m5602_write_sensor(sd, S5K4AA_NOISE_SUPP, &data, 1);
+}
+
+void s5k4aa_disconnect(struct sd *sd)
+{
+ sd->sensor = NULL;
+ kfree(sd->sensor_priv);
}
static void s5k4aa_dump_registers(struct sd *sd)
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
index ca854d4f9475..4440da4e7f0f 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
@@ -47,8 +47,9 @@
#define S5K4AA_H_BLANK_LO__ 0x1e
#define S5K4AA_EXPOSURE_HI 0x17
#define S5K4AA_EXPOSURE_LO 0x18
-#define S5K4AA_GAIN_1 0x1f /* (digital?) gain : 5 bits */
-#define S5K4AA_GAIN_2 0x20 /* (analogue?) gain : 7 bits */
+#define S5K4AA_BRIGHTNESS 0x1f /* (digital?) gain : 5 bits */
+#define S5K4AA_GAIN 0x20 /* (analogue?) gain : 7 bits */
+#define S5K4AA_NOISE_SUPP 0x37
#define S5K4AA_RM_ROW_SKIP_4X 0x08
#define S5K4AA_RM_ROW_SKIP_2X 0x04
@@ -57,6 +58,9 @@
#define S5K4AA_RM_H_FLIP 0x40
#define S5K4AA_RM_V_FLIP 0x80
+#define S5K4AA_DEFAULT_GAIN 0x5f
+#define S5K4AA_DEFAULT_BRIGHTNESS 0x10
+
/*****************************************************************************/
/* Kernel module parameters */
@@ -66,25 +70,17 @@ extern int dump_sensor;
int s5k4aa_probe(struct sd *sd);
int s5k4aa_init(struct sd *sd);
int s5k4aa_start(struct sd *sd);
-int s5k4aa_power_down(struct sd *sd);
-
-int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
-int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
-int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
-int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+void s5k4aa_disconnect(struct sd *sd);
static const struct m5602_sensor s5k4aa = {
.name = "S5K4AA",
+ .i2c_slave_id = 0x5a,
+ .i2c_regW = 2,
+
.probe = s5k4aa_probe,
.init = s5k4aa_init,
.start = s5k4aa_start,
- .power_down = s5k4aa_power_down,
- .i2c_slave_id = 0x5a,
- .i2c_regW = 2,
+ .disconnect = s5k4aa_disconnect,
};
static const unsigned char preinit_s5k4aa[][4] =
@@ -179,30 +175,12 @@ static const unsigned char init_s5k4aa[][4] =
{SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
{SENSOR, 0x0c, 0x05, 0x00},
{SENSOR, 0x02, 0x0e, 0x00},
- {SENSOR, S5K4AA_GAIN_1, 0x0f, 0x00},
- {SENSOR, S5K4AA_GAIN_2, 0x00, 0x00},
- {SENSOR, S5K4AA_GLOBAL_GAIN__, 0x01, 0x00},
- {SENSOR, 0x11, 0x00, 0x00},
- {SENSOR, 0x12, 0x00, 0x00},
- {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
{SENSOR, S5K4AA_READ_MODE, 0xa0, 0x00},
{SENSOR, 0x37, 0x00, 0x00},
- {SENSOR, S5K4AA_ROWSTART_HI, 0x00, 0x00},
- {SENSOR, S5K4AA_ROWSTART_LO, 0x2a, 0x00},
- {SENSOR, S5K4AA_COLSTART_HI, 0x00, 0x00},
- {SENSOR, S5K4AA_COLSTART_LO, 0x0b, 0x00},
- {SENSOR, S5K4AA_WINDOW_HEIGHT_HI, 0x03, 0x00},
- {SENSOR, S5K4AA_WINDOW_HEIGHT_LO, 0xc4, 0x00},
- {SENSOR, S5K4AA_WINDOW_WIDTH_HI, 0x05, 0x00},
- {SENSOR, S5K4AA_WINDOW_WIDTH_LO, 0x08, 0x00},
- {SENSOR, S5K4AA_H_BLANK_HI__, 0x00, 0x00},
- {SENSOR, S5K4AA_H_BLANK_LO__, 0x48, 0x00},
- {SENSOR, S5K4AA_EXPOSURE_HI, 0x00, 0x00},
- {SENSOR, S5K4AA_EXPOSURE_LO, 0x43, 0x00},
- {SENSOR, 0x11, 0x04, 0x00},
- {SENSOR, 0x12, 0xc3, 0x00},
- {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
+};
+static const unsigned char VGA_s5k4aa[][4] =
+{
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -238,7 +216,7 @@ static const unsigned char init_s5k4aa[][4] =
{SENSOR, 0x37, 0x01, 0x00},
/* ROWSTART_HI, ROWSTART_LO : 10 + (1024-960)/2 = 42 = 0x002a */
{SENSOR, S5K4AA_ROWSTART_HI, 0x00, 0x00},
- {SENSOR, S5K4AA_ROWSTART_LO, 0x2a, 0x00},
+ {SENSOR, S5K4AA_ROWSTART_LO, 0x29, 0x00},
{SENSOR, S5K4AA_COLSTART_HI, 0x00, 0x00},
{SENSOR, S5K4AA_COLSTART_LO, 0x0c, 0x00},
/* window_height_hi, window_height_lo : 960 = 0x03c0 */
@@ -255,12 +233,9 @@ static const unsigned char init_s5k4aa[][4] =
{SENSOR, 0x12, 0xc3, 0x00},
{SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
{SENSOR, 0x02, 0x0e, 0x00},
- {SENSOR_LONG, S5K4AA_GLOBAL_GAIN__, 0x0f, 0x00},
- {SENSOR, S5K4AA_GAIN_1, 0x0b, 0x00},
- {SENSOR, S5K4AA_GAIN_2, 0xa0, 0x00}
};
-static const unsigned char VGA_s5k4aa[][4] =
+static const unsigned char SXGA_s5k4aa[][4] =
{
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
@@ -273,50 +248,42 @@ static const unsigned char VGA_s5k4aa[][4] =
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- /* VSYNC_PARA, VSYNC_PARA : img height 480 = 0x01e0 */
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe0, 0x00},
+ /* VSYNC_PARA, VSYNC_PARA : img height 1024 = 0x0400 */
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x04, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
{BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
{BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- /* HSYNC_PARA, HSYNC_PARA : img width 640 = 0x0280 */
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x80, 0x00},
+ /* HSYNC_PARA, HSYNC_PARA : img width 1280 = 0x0500 */
+ {BRIDGE, M5602_XB_HSYNC_PARA, 0x05, 0x00},
+ {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xa0, 0x00}, /* 48 MHz */
{SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
- {SENSOR, S5K4AA_READ_MODE, S5K4AA_RM_H_FLIP | S5K4AA_RM_ROW_SKIP_2X
- | S5K4AA_RM_COL_SKIP_2X, 0x00},
- /* 0x37 : Fix image stability when light is too bright and improves
- * image quality in 640x480, but worsens it in 1280x1024 */
+ {SENSOR, S5K4AA_READ_MODE, S5K4AA_RM_H_FLIP, 0x00},
{SENSOR, 0x37, 0x01, 0x00},
- /* ROWSTART_HI, ROWSTART_LO : 10 + (1024-960)/2 = 42 = 0x002a */
{SENSOR, S5K4AA_ROWSTART_HI, 0x00, 0x00},
- {SENSOR, S5K4AA_ROWSTART_LO, 0x2a, 0x00},
+ {SENSOR, S5K4AA_ROWSTART_LO, 0x09, 0x00},
{SENSOR, S5K4AA_COLSTART_HI, 0x00, 0x00},
- {SENSOR, S5K4AA_COLSTART_LO, 0x0c, 0x00},
- /* window_height_hi, window_height_lo : 960 = 0x03c0 */
- {SENSOR, S5K4AA_WINDOW_HEIGHT_HI, 0x03, 0x00},
- {SENSOR, S5K4AA_WINDOW_HEIGHT_LO, 0xc0, 0x00},
- /* window_width_hi, window_width_lo : 1280 = 0x0500 */
+ {SENSOR, S5K4AA_COLSTART_LO, 0x0a, 0x00},
+ {SENSOR, S5K4AA_WINDOW_HEIGHT_HI, 0x04, 0x00},
+ {SENSOR, S5K4AA_WINDOW_HEIGHT_LO, 0x00, 0x00},
{SENSOR, S5K4AA_WINDOW_WIDTH_HI, 0x05, 0x00},
{SENSOR, S5K4AA_WINDOW_WIDTH_LO, 0x00, 0x00},
- {SENSOR, S5K4AA_H_BLANK_HI__, 0x00, 0x00},
- {SENSOR, S5K4AA_H_BLANK_LO__, 0xa8, 0x00}, /* helps to sync... */
+ {SENSOR, S5K4AA_H_BLANK_HI__, 0x01, 0x00},
+ {SENSOR, S5K4AA_H_BLANK_LO__, 0xa8, 0x00},
{SENSOR, S5K4AA_EXPOSURE_HI, 0x01, 0x00},
{SENSOR, S5K4AA_EXPOSURE_LO, 0x00, 0x00},
{SENSOR, 0x11, 0x04, 0x00},
{SENSOR, 0x12, 0xc3, 0x00},
{SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
{SENSOR, 0x02, 0x0e, 0x00},
- {SENSOR_LONG, S5K4AA_GLOBAL_GAIN__, 0x0f, 0x00},
- {SENSOR, S5K4AA_GAIN_1, 0x0b, 0x00},
- {SENSOR, S5K4AA_GAIN_2, 0xa0, 0x00}
};
+
#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
index 42c86aa4dc8d..7127321ace8c 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
@@ -16,8 +16,20 @@
*
*/
+#include <linux/kthread.h>
#include "m5602_s5k83a.h"
+static int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k83a_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k83a_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
+
static struct v4l2_pix_format s5k83a_modes[] = {
{
640,
@@ -32,68 +44,77 @@ static struct v4l2_pix_format s5k83a_modes[] = {
}
};
-const static struct ctrl s5k83a_ctrls[] = {
+static const struct ctrl s5k83a_ctrls[] = {
+#define GAIN_IDX 0
{
{
- .id = V4L2_CID_BRIGHTNESS,
+ .id = V4L2_CID_GAIN,
.type = V4L2_CTRL_TYPE_INTEGER,
- .name = "brightness",
+ .name = "gain",
.minimum = 0x00,
.maximum = 0xff,
.step = 0x01,
- .default_value = S5K83A_DEFAULT_BRIGHTNESS,
+ .default_value = S5K83A_DEFAULT_GAIN,
.flags = V4L2_CTRL_FLAG_SLIDER
},
- .set = s5k83a_set_brightness,
- .get = s5k83a_get_brightness
+ .set = s5k83a_set_gain,
+ .get = s5k83a_get_gain
- }, {
+ },
+#define BRIGHTNESS_IDX 1
+ {
{
- .id = V4L2_CID_WHITENESS,
+ .id = V4L2_CID_BRIGHTNESS,
.type = V4L2_CTRL_TYPE_INTEGER,
- .name = "whiteness",
+ .name = "brightness",
.minimum = 0x00,
.maximum = 0xff,
.step = 0x01,
- .default_value = S5K83A_DEFAULT_WHITENESS,
+ .default_value = S5K83A_DEFAULT_BRIGHTNESS,
.flags = V4L2_CTRL_FLAG_SLIDER
},
- .set = s5k83a_set_whiteness,
- .get = s5k83a_get_whiteness,
- }, {
+ .set = s5k83a_set_brightness,
+ .get = s5k83a_get_brightness,
+ },
+#define EXPOSURE_IDX 2
+ {
{
- .id = V4L2_CID_GAIN,
+ .id = V4L2_CID_EXPOSURE,
.type = V4L2_CTRL_TYPE_INTEGER,
- .name = "gain",
+ .name = "exposure",
.minimum = 0x00,
- .maximum = S5K83A_MAXIMUM_GAIN,
+ .maximum = S5K83A_MAXIMUM_EXPOSURE,
.step = 0x01,
- .default_value = S5K83A_DEFAULT_GAIN,
+ .default_value = S5K83A_DEFAULT_EXPOSURE,
.flags = V4L2_CTRL_FLAG_SLIDER
},
- .set = s5k83a_set_gain,
- .get = s5k83a_get_gain
- }, {
+ .set = s5k83a_set_exposure,
+ .get = s5k83a_get_exposure
+ },
+#define HFLIP_IDX 3
+ {
{
- .id = V4L2_CID_HFLIP,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "horizontal flip",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 0
+ .id = V4L2_CID_HFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "horizontal flip",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0
},
.set = s5k83a_set_hflip,
.get = s5k83a_get_hflip
- }, {
+ },
+#define VFLIP_IDX 4
+ {
{
- .id = V4L2_CID_VFLIP,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "vertical flip",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 0
+ .id = V4L2_CID_VFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "vertical flip",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0
},
.set = s5k83a_set_vflip,
.get = s5k83a_get_vflip
@@ -101,9 +122,14 @@ const static struct ctrl s5k83a_ctrls[] = {
};
static void s5k83a_dump_registers(struct sd *sd);
+static int s5k83a_get_rotation(struct sd *sd, u8 *reg_data);
+static int s5k83a_set_led_indication(struct sd *sd, u8 val);
+static int s5k83a_set_flip_real(struct gspca_dev *gspca_dev,
+ __s32 vflip, __s32 hflip);
int s5k83a_probe(struct sd *sd)
{
+ struct s5k83a_priv *sens_priv;
u8 prod_id = 0, ver_id = 0;
int i, err = 0;
@@ -145,16 +171,36 @@ int s5k83a_probe(struct sd *sd)
info("Detected a s5k83a sensor");
sensor_found:
+ sens_priv = kmalloc(
+ sizeof(struct s5k83a_priv), GFP_KERNEL);
+ if (!sens_priv)
+ return -ENOMEM;
+
+ sens_priv->settings =
+ kmalloc(sizeof(s32)*ARRAY_SIZE(s5k83a_ctrls), GFP_KERNEL);
+ if (!sens_priv->settings)
+ return -ENOMEM;
+
sd->gspca_dev.cam.cam_mode = s5k83a_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes);
sd->desc->ctrls = s5k83a_ctrls;
sd->desc->nctrls = ARRAY_SIZE(s5k83a_ctrls);
+
+ /* null the pointer! thread is't running now */
+ sens_priv->rotation_thread = NULL;
+
+ for (i = 0; i < ARRAY_SIZE(s5k83a_ctrls); i++)
+ sens_priv->settings[i] = s5k83a_ctrls[i].qctrl.default_value;
+
+ sd->sensor_priv = sens_priv;
return 0;
}
int s5k83a_init(struct sd *sd)
{
int i, err = 0;
+ s32 *sensor_settings =
+ ((struct s5k83a_priv *) sd->sensor_priv)->settings;
for (i = 0; i < ARRAY_SIZE(init_s5k83a) && !err; i++) {
u8 data[2] = {0x00, 0x00};
@@ -187,87 +233,138 @@ int s5k83a_init(struct sd *sd)
if (dump_sensor)
s5k83a_dump_registers(sd);
- return (err < 0) ? err : 0;
-}
+ err = s5k83a_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
+ if (err < 0)
+ return err;
-int s5k83a_start(struct sd *sd)
-{
- return s5k83a_set_led_indication(sd, 1);
-}
+ err = s5k83a_set_brightness(&sd->gspca_dev,
+ sensor_settings[BRIGHTNESS_IDX]);
+ if (err < 0)
+ return err;
-int s5k83a_stop(struct sd *sd)
-{
- return s5k83a_set_led_indication(sd, 0);
+ err = s5k83a_set_exposure(&sd->gspca_dev,
+ sensor_settings[EXPOSURE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = s5k83a_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
+ if (err < 0)
+ return err;
+
+ err = s5k83a_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
+
+ return err;
}
-int s5k83a_power_down(struct sd *sd)
+static int rotation_thread_function(void *data)
{
+ struct sd *sd = (struct sd *) data;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
+ u8 reg, previous_rotation = 0;
+ __s32 vflip, hflip;
+
+ set_current_state(TASK_INTERRUPTIBLE);
+ while (!schedule_timeout(100)) {
+ if (mutex_lock_interruptible(&sd->gspca_dev.usb_lock))
+ break;
+
+ s5k83a_get_rotation(sd, &reg);
+ if (previous_rotation != reg) {
+ previous_rotation = reg;
+ info("Camera was flipped");
+
+ s5k83a_get_vflip((struct gspca_dev *) sd, &vflip);
+ s5k83a_get_hflip((struct gspca_dev *) sd, &hflip);
+
+ if (reg) {
+ vflip = !vflip;
+ hflip = !hflip;
+ }
+ s5k83a_set_flip_real((struct gspca_dev *) sd,
+ vflip, hflip);
+ }
+
+ mutex_unlock(&sd->gspca_dev.usb_lock);
+ set_current_state(TASK_INTERRUPTIBLE);
+ }
+
+ /* return to "front" flip */
+ if (previous_rotation) {
+ s5k83a_get_vflip((struct gspca_dev *) sd, &vflip);
+ s5k83a_get_hflip((struct gspca_dev *) sd, &hflip);
+ s5k83a_set_flip_real((struct gspca_dev *) sd, vflip, hflip);
+ }
+
+ sens_priv->rotation_thread = NULL;
return 0;
}
-static void s5k83a_dump_registers(struct sd *sd)
+int s5k83a_start(struct sd *sd)
{
- int address;
- u8 page, old_page;
- m5602_read_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1);
+ int i, err = 0;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- for (page = 0; page < 16; page++) {
- m5602_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1);
- info("Dumping the s5k83a register state for page 0x%x", page);
- for (address = 0; address <= 0xff; address++) {
- u8 val = 0;
- m5602_read_sensor(sd, address, &val, 1);
- info("register 0x%x contains 0x%x",
- address, val);
- }
+ /* Create another thread, polling the GPIO ports of the camera to check
+ if it got rotated. This is how the windows driver does it so we have
+ to assume that there is no better way of accomplishing this */
+ sens_priv->rotation_thread = kthread_create(rotation_thread_function,
+ sd, "rotation thread");
+ wake_up_process(sens_priv->rotation_thread);
+
+ /* Preinit the sensor */
+ for (i = 0; i < ARRAY_SIZE(start_s5k83a) && !err; i++) {
+ u8 data[2] = {start_s5k83a[i][2], start_s5k83a[i][3]};
+ if (start_s5k83a[i][0] == SENSOR)
+ err = m5602_write_sensor(sd, start_s5k83a[i][1],
+ data, 2);
+ else
+ err = m5602_write_bridge(sd, start_s5k83a[i][1],
+ data[0]);
}
- info("s5k83a register state dump complete");
+ if (err < 0)
+ return err;
- for (page = 0; page < 16; page++) {
- m5602_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1);
- info("Probing for which registers that are read/write "
- "for page 0x%x", page);
- for (address = 0; address <= 0xff; address++) {
- u8 old_val, ctrl_val, test_val = 0xff;
+ return s5k83a_set_led_indication(sd, 1);
+}
- m5602_read_sensor(sd, address, &old_val, 1);
- m5602_write_sensor(sd, address, &test_val, 1);
- m5602_read_sensor(sd, address, &ctrl_val, 1);
+int s5k83a_stop(struct sd *sd)
+{
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- if (ctrl_val == test_val)
- info("register 0x%x is writeable", address);
- else
- info("register 0x%x is read only", address);
+ if (sens_priv->rotation_thread)
+ kthread_stop(sens_priv->rotation_thread);
- /* Restore original val */
- m5602_write_sensor(sd, address, &old_val, 1);
- }
- }
- info("Read/write register probing complete");
- m5602_write_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1);
+ return s5k83a_set_led_indication(sd, 0);
}
-int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
+void s5k83a_disconnect(struct sd *sd)
{
- int err;
- u8 data[2];
- struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- err = m5602_read_sensor(sd, S5K83A_BRIGHTNESS, data, 2);
- if (err < 0)
- return err;
+ s5k83a_stop(sd);
+
+ sd->sensor = NULL;
+ kfree(sens_priv->settings);
+ kfree(sens_priv);
+}
- data[1] = data[1] << 1;
- *val = data[1];
+static int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- return err;
+ *val = sens_priv->settings[GAIN_IDX];
+ return 0;
}
-int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 data[2];
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
+
+ sens_priv->settings[GAIN_IDX] = val;
data[0] = 0x00;
data[1] = 0x20;
@@ -283,89 +380,69 @@ int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
/* FIXME: This is not sane, we need to figure out the composition
of these registers */
- data[0] = val >> 3; /* brightness, high 5 bits */
- data[1] = val >> 1; /* brightness, high 7 bits */
- err = m5602_write_sensor(sd, S5K83A_BRIGHTNESS, data, 2);
+ data[0] = val >> 3; /* gain, high 5 bits */
+ data[1] = val >> 1; /* gain, high 7 bits */
+ err = m5602_write_sensor(sd, S5K83A_GAIN, data, 2);
return err;
}
-int s5k83a_get_whiteness(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
{
- int err;
- u8 data;
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- err = m5602_read_sensor(sd, S5K83A_WHITENESS, &data, 1);
- if (err < 0)
- return err;
-
- *val = data;
-
- return err;
+ *val = sens_priv->settings[BRIGHTNESS_IDX];
+ return 0;
}
-int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 data[1];
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
+ sens_priv->settings[BRIGHTNESS_IDX] = val;
data[0] = val;
- err = m5602_write_sensor(sd, S5K83A_WHITENESS, data, 1);
-
+ err = m5602_write_sensor(sd, S5K83A_BRIGHTNESS, data, 1);
return err;
}
-int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k83a_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
{
- int err;
- u8 data[2];
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- err = m5602_read_sensor(sd, S5K83A_GAIN, data, 2);
- if (err < 0)
- return err;
-
- data[1] = data[1] & 0x3f;
- if (data[1] > S5K83A_MAXIMUM_GAIN)
- data[1] = S5K83A_MAXIMUM_GAIN;
-
- *val = data[1];
-
- return err;
+ *val = sens_priv->settings[EXPOSURE_IDX];
+ return 0;
}
-int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k83a_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 data[2];
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
+ sens_priv->settings[EXPOSURE_IDX] = val;
data[0] = 0;
data[1] = val;
- err = m5602_write_sensor(sd, S5K83A_GAIN, data, 2);
+ err = m5602_write_sensor(sd, S5K83A_EXPOSURE, data, 2);
return err;
}
-int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
{
- int err;
- u8 data[1];
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- data[0] = 0x05;
- err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
- if (err < 0)
- return err;
-
- err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1);
- *val = (data[0] | 0x40) ? 1 : 0;
-
- return err;
+ *val = sens_priv->settings[VFLIP_IDX];
+ return 0;
}
-int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k83a_set_flip_real(struct gspca_dev *gspca_dev,
+ __s32 vflip, __s32 hflip)
{
int err;
u8 data[1];
@@ -376,69 +453,83 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
if (err < 0)
return err;
- err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1);
- if (err < 0)
- return err;
+ /* six bit is vflip, seven is hflip */
+ data[0] = S5K83A_FLIP_MASK;
+ data[0] = (vflip) ? data[0] | 0x40 : data[0];
+ data[0] = (hflip) ? data[0] | 0x80 : data[0];
- /* set or zero six bit, seven is hflip */
- data[0] = (val) ? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK
- : (data[0] & 0x80) | S5K83A_FLIP_MASK;
err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1);
if (err < 0)
return err;
- data[0] = (val) ? 0x0b : 0x0a;
+ data[0] = (vflip) ? 0x0b : 0x0a;
err = m5602_write_sensor(sd, S5K83A_VFLIP_TUNE, data, 1);
+ if (err < 0)
+ return err;
+ data[0] = (hflip) ? 0x0a : 0x0b;
+ err = m5602_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1);
return err;
}
-int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+static int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
- u8 data[1];
+ u8 reg;
+ __s32 hflip;
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- data[0] = 0x05;
- err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
+ sens_priv->settings[VFLIP_IDX] = val;
+
+ s5k83a_get_hflip(gspca_dev, &hflip);
+
+ err = s5k83a_get_rotation(sd, &reg);
if (err < 0)
return err;
+ if (reg) {
+ val = !val;
+ hflip = !hflip;
+ }
- err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1);
- *val = (data[0] | 0x80) ? 1 : 0;
-
+ err = s5k83a_set_flip_real(gspca_dev, val, hflip);
return err;
}
-int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
+static int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
+
+ *val = sens_priv->settings[HFLIP_IDX];
+ return 0;
+}
+
+static int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
- u8 data[1];
+ u8 reg;
+ __s32 vflip;
struct sd *sd = (struct sd *) gspca_dev;
+ struct s5k83a_priv *sens_priv = sd->sensor_priv;
- data[0] = 0x05;
- err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
- if (err < 0)
- return err;
+ sens_priv->settings[HFLIP_IDX] = val;
- err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1);
- if (err < 0)
- return err;
+ s5k83a_get_vflip(gspca_dev, &vflip);
- /* set or zero seven bit, six is vflip */
- data[0] = (val) ? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK
- : (data[0] & 0x40) | S5K83A_FLIP_MASK;
- err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1);
+ err = s5k83a_get_rotation(sd, &reg);
if (err < 0)
return err;
+ if (reg) {
+ val = !val;
+ vflip = !vflip;
+ }
- data[0] = (val) ? 0x0a : 0x0b;
- err = m5602_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1);
-
+ err = s5k83a_set_flip_real(gspca_dev, vflip, val);
return err;
}
-int s5k83a_set_led_indication(struct sd *sd, u8 val)
+static int s5k83a_set_led_indication(struct sd *sd, u8 val)
{
int err = 0;
u8 data[1];
@@ -454,5 +545,55 @@ int s5k83a_set_led_indication(struct sd *sd, u8 val)
err = m5602_write_bridge(sd, M5602_XB_GPIO_DAT, data[0]);
- return (err < 0) ? err : 0;
+ return err;
+}
+
+/* Get camera rotation on Acer notebooks */
+static int s5k83a_get_rotation(struct sd *sd, u8 *reg_data)
+{
+ int err = m5602_read_bridge(sd, M5602_XB_GPIO_DAT, reg_data);
+ *reg_data = (*reg_data & S5K83A_GPIO_ROTATION_MASK) ? 0 : 1;
+ return err;
+}
+
+static void s5k83a_dump_registers(struct sd *sd)
+{
+ int address;
+ u8 page, old_page;
+ m5602_read_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1);
+
+ for (page = 0; page < 16; page++) {
+ m5602_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1);
+ info("Dumping the s5k83a register state for page 0x%x", page);
+ for (address = 0; address <= 0xff; address++) {
+ u8 val = 0;
+ m5602_read_sensor(sd, address, &val, 1);
+ info("register 0x%x contains 0x%x",
+ address, val);
+ }
+ }
+ info("s5k83a register state dump complete");
+
+ for (page = 0; page < 16; page++) {
+ m5602_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1);
+ info("Probing for which registers that are read/write "
+ "for page 0x%x", page);
+ for (address = 0; address <= 0xff; address++) {
+ u8 old_val, ctrl_val, test_val = 0xff;
+
+ m5602_read_sensor(sd, address, &old_val, 1);
+ m5602_write_sensor(sd, address, &test_val, 1);
+ m5602_read_sensor(sd, address, &ctrl_val, 1);
+
+ if (ctrl_val == test_val)
+ info("register 0x%x is writeable", address);
+ else
+ info("register 0x%x is read only", address);
+
+ /* Restore original val */
+ m5602_write_sensor(sd, address, &old_val, 1);
+ }
+ }
+ info("Read/write register probing complete");
+ m5602_write_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1);
}
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
index 819ab25272be..7814b078acde 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
@@ -21,20 +21,21 @@
#include "m5602_sensor.h"
-#define S5K83A_FLIP 0x01
-#define S5K83A_HFLIP_TUNE 0x03
-#define S5K83A_VFLIP_TUNE 0x05
-#define S5K83A_WHITENESS 0x0a
-#define S5K83A_GAIN 0x18
-#define S5K83A_BRIGHTNESS 0x1b
-#define S5K83A_PAGE_MAP 0xec
-
-#define S5K83A_DEFAULT_BRIGHTNESS 0x71
-#define S5K83A_DEFAULT_WHITENESS 0x7e
-#define S5K83A_DEFAULT_GAIN 0x00
-#define S5K83A_MAXIMUM_GAIN 0x3c
-#define S5K83A_FLIP_MASK 0x10
+#define S5K83A_FLIP 0x01
+#define S5K83A_HFLIP_TUNE 0x03
+#define S5K83A_VFLIP_TUNE 0x05
+#define S5K83A_BRIGHTNESS 0x0a
+#define S5K83A_EXPOSURE 0x18
+#define S5K83A_GAIN 0x1b
+#define S5K83A_PAGE_MAP 0xec
+
+#define S5K83A_DEFAULT_GAIN 0x71
+#define S5K83A_DEFAULT_BRIGHTNESS 0x7e
+#define S5K83A_DEFAULT_EXPOSURE 0x00
+#define S5K83A_MAXIMUM_EXPOSURE 0x3c
+#define S5K83A_FLIP_MASK 0x10
#define S5K83A_GPIO_LED_MASK 0x10
+#define S5K83A_GPIO_ROTATION_MASK 0x40
/*****************************************************************************/
@@ -46,20 +47,7 @@ int s5k83a_probe(struct sd *sd);
int s5k83a_init(struct sd *sd);
int s5k83a_start(struct sd *sd);
int s5k83a_stop(struct sd *sd);
-int s5k83a_power_down(struct sd *sd);
-
-int s5k83a_set_led_indication(struct sd *sd, u8 val);
-
-int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val);
-int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val);
-int s5k83a_get_whiteness(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val);
-int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
-int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
-int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
+void s5k83a_disconnect(struct sd *sd);
static const struct m5602_sensor s5k83a = {
.name = "S5K83A",
@@ -67,11 +55,18 @@ static const struct m5602_sensor s5k83a = {
.init = s5k83a_init,
.start = s5k83a_start,
.stop = s5k83a_stop,
- .power_down = s5k83a_power_down,
+ .disconnect = s5k83a_disconnect,
.i2c_slave_id = 0x5a,
.i2c_regW = 2,
};
+struct s5k83a_priv {
+ /* We use another thread periodically
+ probing the orientation of the camera */
+ struct task_struct *rotation_thread;
+ s32 *settings;
+};
+
static const unsigned char preinit_s5k83a[][4] =
{
{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
@@ -108,8 +103,6 @@ static const unsigned char preinit_s5k83a[][4] =
{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
{BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
{BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},
-
- {SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00}
};
/* This could probably be considerably shortened.
@@ -117,86 +110,8 @@ static const unsigned char preinit_s5k83a[][4] =
*/
static const unsigned char init_s5k83a[][4] =
{
- {SENSOR, S5K83A_PAGE_MAP, 0x04, 0x00},
- {SENSOR, 0xaf, 0x01, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
- {SENSOR, 0x7b, 0xff, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR, 0x01, 0x50, 0x00},
- {SENSOR, 0x12, 0x20, 0x00},
- {SENSOR, 0x17, 0x40, 0x00},
- {SENSOR, S5K83A_BRIGHTNESS, 0x0f, 0x00},
- {SENSOR, 0x1c, 0x00, 0x00},
- {SENSOR, 0x02, 0x70, 0x00},
- {SENSOR, 0x03, 0x0b, 0x00},
- {SENSOR, 0x04, 0xf0, 0x00},
- {SENSOR, 0x05, 0x0b, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x87, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR, 0x06, 0x71, 0x00},
- {SENSOR, 0x07, 0xe8, 0x00},
- {SENSOR, 0x08, 0x02, 0x00},
- {SENSOR, 0x09, 0x88, 0x00},
- {SENSOR, 0x14, 0x00, 0x00},
- {SENSOR, 0x15, 0x20, 0x00},
- {SENSOR, 0x19, 0x00, 0x00},
- {SENSOR, 0x1a, 0x98, 0x00},
- {SENSOR, 0x0f, 0x02, 0x00},
- {SENSOR, 0x10, 0xe5, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR_LONG, 0x14, 0x00, 0x20},
- {SENSOR_LONG, 0x0d, 0x00, 0x7d},
- {SENSOR_LONG, 0x1b, 0x0d, 0x05},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x87, 0x00},
-
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
+ /* The following sequence is useless after a clean boot
+ but is necessary after resume from suspend */
{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
{BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},
@@ -216,7 +131,7 @@ static const unsigned char init_s5k83a[][4] =
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x1c, 0x00},
+ {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
{BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
@@ -225,109 +140,34 @@ static const unsigned char init_s5k83a[][4] =
{SENSOR, S5K83A_PAGE_MAP, 0x04, 0x00},
{SENSOR, 0xaf, 0x01, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- /* ff ( init value )is very dark) || 71 and f0 better */
+ {SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
{SENSOR, 0x7b, 0xff, 0x00},
{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
{SENSOR, 0x01, 0x50, 0x00},
{SENSOR, 0x12, 0x20, 0x00},
{SENSOR, 0x17, 0x40, 0x00},
- {SENSOR, S5K83A_BRIGHTNESS, 0x0f, 0x00},
{SENSOR, 0x1c, 0x00, 0x00},
{SENSOR, 0x02, 0x70, 0x00},
- /* some values like 0x10 give a blue-purple image */
{SENSOR, 0x03, 0x0b, 0x00},
{SENSOR, 0x04, 0xf0, 0x00},
{SENSOR, 0x05, 0x0b, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
-
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
- /* under 80 don't work, highter depend on value */
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
- {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00},
-
- {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
{SENSOR, 0x06, 0x71, 0x00},
- {SENSOR, 0x07, 0xe8, 0x00},
+ {SENSOR, 0x07, 0xe8, 0x00}, /* 488 */
{SENSOR, 0x08, 0x02, 0x00},
- {SENSOR, 0x09, 0x88, 0x00},
+ {SENSOR, 0x09, 0x88, 0x00}, /* 648 */
{SENSOR, 0x14, 0x00, 0x00},
- {SENSOR, 0x15, 0x20, 0x00},
+ {SENSOR, 0x15, 0x20, 0x00}, /* 32 */
{SENSOR, 0x19, 0x00, 0x00},
- {SENSOR, 0x1a, 0x98, 0x00},
+ {SENSOR, 0x1a, 0x98, 0x00}, /* 152 */
{SENSOR, 0x0f, 0x02, 0x00},
- {SENSOR, 0x10, 0xe5, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR_LONG, 0x14, 0x00, 0x20},
- {SENSOR_LONG, 0x0d, 0x00, 0x7d},
- {SENSOR_LONG, 0x1b, 0x0d, 0x05},
-
- /* The following sequence is useless after a clean boot
- but is necessary after resume from suspend */
- {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
- {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
- {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
- {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
- {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
- {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
- {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
- {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
- {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},
-
- {SENSOR, S5K83A_PAGE_MAP, 0x04, 0x00},
- {SENSOR, 0xaf, 0x01, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
- {SENSOR, 0x7b, 0xff, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR, 0x01, 0x50, 0x00},
- {SENSOR, 0x12, 0x20, 0x00},
- {SENSOR, 0x17, 0x40, 0x00},
- {SENSOR, S5K83A_BRIGHTNESS, 0x0f, 0x00},
- {SENSOR, 0x1c, 0x00, 0x00},
- {SENSOR, 0x02, 0x70, 0x00},
- {SENSOR, 0x03, 0x0b, 0x00},
- {SENSOR, 0x04, 0xf0, 0x00},
- {SENSOR, 0x05, 0x0b, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
+ {SENSOR, 0x10, 0xe5, 0x00}, /* 741 */
+ /* normal colors
+ (this is value after boot, but after tries can be different) */
+ {SENSOR, 0x00, 0x06, 0x00},
+};
+static const unsigned char start_s5k83a[][4] =
+{
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -340,7 +180,7 @@ static const unsigned char init_s5k83a[][4] =
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
- {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00},
+ {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00}, /* 484 */
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
@@ -348,50 +188,10 @@ static const unsigned char init_s5k83a[][4] =
{BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
{BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
- {BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00},
+ {BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00}, /* 639 */
{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
-
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR, 0x06, 0x71, 0x00},
- {SENSOR, 0x07, 0xe8, 0x00},
- {SENSOR, 0x08, 0x02, 0x00},
- {SENSOR, 0x09, 0x88, 0x00},
- {SENSOR, 0x14, 0x00, 0x00},
- {SENSOR, 0x15, 0x20, 0x00},
- {SENSOR, 0x19, 0x00, 0x00},
- {SENSOR, 0x1a, 0x98, 0x00},
- {SENSOR, 0x0f, 0x02, 0x00},
-
- {SENSOR, 0x10, 0xe5, 0x00},
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR_LONG, 0x14, 0x00, 0x20},
- {SENSOR_LONG, 0x0d, 0x00, 0x7d},
- {SENSOR_LONG, 0x1b, 0x0d, 0x05},
-
- /* normal colors
- (this is value after boot, but after tries can be different) */
- {SENSOR, 0x00, 0x06, 0x00},
-
- /* set default brightness */
- {SENSOR_LONG, 0x14, 0x00, 0x20},
- {SENSOR_LONG, 0x0d, 0x01, 0x00},
- {SENSOR_LONG, 0x1b, S5K83A_DEFAULT_BRIGHTNESS >> 3,
- S5K83A_DEFAULT_BRIGHTNESS >> 1},
-
- /* set default whiteness */
- {SENSOR, S5K83A_WHITENESS, S5K83A_DEFAULT_WHITENESS, 0x00},
-
- /* set default gain */
- {SENSOR_LONG, 0x18, 0x00, S5K83A_DEFAULT_GAIN},
-
- /* set default flip */
- {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
- {SENSOR, S5K83A_FLIP, 0x00 | S5K83A_FLIP_MASK, 0x00},
- {SENSOR, S5K83A_HFLIP_TUNE, 0x0b, 0x00},
- {SENSOR, S5K83A_VFLIP_TUNE, 0x0a, 0x00}
-
};
#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h
index 0d3026936f2e..edff4f1f586f 100644
--- a/drivers/media/video/gspca/m5602/m5602_sensor.h
+++ b/drivers/media/video/gspca/m5602/m5602_sensor.h
@@ -21,13 +21,17 @@
#include "m5602_bridge.h"
+#define M5602_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 0)
+#define M5602_V4L2_CID_NOISE_SUPPRESION (V4L2_CID_PRIVATE_BASE + 1)
+
/* Enumerates all supported sensors */
enum sensors {
OV9650_SENSOR = 1,
S5K83A_SENSOR = 2,
S5K4AA_SENSOR = 3,
MT9M111_SENSOR = 4,
- PO1030_SENSOR = 5
+ PO1030_SENSOR = 5,
+ OV7660_SENSOR = 6,
};
/* Enumerates all possible instruction types */
@@ -61,9 +65,6 @@ struct m5602_sensor {
/* Executed when the device is disconnected */
void (*disconnect)(struct sd *sd);
-
- /* Performs a power down sequence */
- int (*power_down)(struct sd *sd);
};
#endif
diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c
index 2a901a4a6f00..30132513400c 100644
--- a/drivers/media/video/gspca/mr97310a.c
+++ b/drivers/media/video/gspca/mr97310a.c
@@ -321,6 +321,7 @@ static const struct sd_desc sd_desc = {
/* -- module initialisation -- */
static const __devinitdata struct usb_device_id device_table[] = {
{USB_DEVICE(0x08ca, 0x0111)},
+ {USB_DEVICE(0x093a, 0x010f)},
{}
};
MODULE_DEVICE_TABLE(usb, device_table);
@@ -347,8 +348,11 @@ static struct usb_driver sd_driver = {
/* -- module insert / remove -- */
static int __init sd_mod_init(void)
{
- if (usb_register(&sd_driver) < 0)
- return -1;
+ int ret;
+
+ ret = usb_register(&sd_driver);
+ if (ret < 0)
+ return ret;
PDEBUG(D_PROBE, "registered");
return 0;
}
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c
index 19e0bc60de14..6d9b102be70c 100644
--- a/drivers/media/video/gspca/ov534.c
+++ b/drivers/media/video/gspca/ov534.c
@@ -708,8 +708,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = vga_mode;
cam->nmodes = ARRAY_SIZE(vga_mode);
- cam->bulk_size = 16384;
- cam->bulk_nurbs = 2;
+ if (sd->sensor == SENSOR_OV772X) {
+ cam->bulk = 1;
+ cam->bulk_size = 16384;
+ cam->bulk_nurbs = 2;
+ }
return 0;
}
@@ -864,18 +867,16 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct gspca_frame *frame,
/* If PTS or FID has changed, start a new frame. */
if (this_pts != sd->last_pts || this_fid != sd->last_fid) {
- gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
- NULL, 0);
+ if (gspca_dev->last_packet_type == INTER_PACKET)
+ frame = gspca_frame_add(gspca_dev,
+ LAST_PACKET, frame,
+ NULL, 0);
sd->last_pts = this_pts;
sd->last_fid = this_fid;
- }
-
- /* Add the data from this payload */
- gspca_frame_add(gspca_dev, INTER_PACKET, frame,
+ gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
data + 12, len - 12);
-
/* If this packet is marked as EOF, end the frame */
- if (data[1] & UVC_STREAM_EOF) {
+ } else if (data[1] & UVC_STREAM_EOF) {
sd->last_pts = 0;
if (frame->data_end - frame->data !=
@@ -883,11 +884,16 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct gspca_frame *frame,
PDEBUG(D_PACK, "short frame");
goto discard;
}
-
frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
- NULL, 0);
+ data + 12, len - 12);
+ } else {
+
+ /* Add the data from this payload */
+ gspca_frame_add(gspca_dev, INTER_PACKET, frame,
+ data + 12, len - 12);
}
+
/* Done this payload */
goto scan_next;
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 153d0a91d4b5..cf3af8de6e97 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -877,6 +877,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = sif_mode;
cam->nmodes = ARRAY_SIZE(sif_mode);
}
+ cam->npkt = 36; /* 36 packets per ISOC message */
+
sd->brightness = BRIGHTNESS_DEF;
sd->gain = GAIN_DEF;
sd->exposure = EXPOSURE_DEF;
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index c72e19d3ac37..dc6a6f11354a 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -62,7 +62,6 @@ struct sd {
#define BRIDGE_SN9C105 1
#define BRIDGE_SN9C110 2
#define BRIDGE_SN9C120 3
-#define BRIDGE_SN9C325 4
u8 sensor; /* Type of image sensor chip */
#define SENSOR_HV7131R 0
#define SENSOR_MI0360 1
@@ -354,9 +353,9 @@ static const u8 sn_ov7648[0x1c] = {
static const u8 sn_ov7660[0x1c] = {
/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
- 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
+ 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
/* reg8 reg9 rega regb regc regd rege regf */
- 0x81, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
+ 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
/* reg18 reg19 reg1a reg1b */
@@ -757,6 +756,7 @@ static const u8 ov7660_sensor_init[][8] = {
{0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
{0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
{0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
+ {0xb1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
/****** (some exchanges in the win trace) ******/
{0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
/* bits[3..0]reserved */
@@ -1065,9 +1065,9 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
struct sd *sd = (struct sd *) gspca_dev;
const u8 *reg9a;
static const u8 reg9a_def[] =
- {0x08, 0x40, 0x20, 0x10, 0x00, 0x04};
- static const u8 reg9a_sn9c325[] =
- {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20};
+ {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
+ static const u8 reg9a_spec[] =
+ {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
static const u8 regd4[] = {0x60, 0x00, 0x00};
reg_w1(gspca_dev, 0xf1, 0x00);
@@ -1077,9 +1077,10 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
- switch (sd->bridge) {
- case BRIDGE_SN9C325:
- reg9a = reg9a_sn9c325;
+ switch (sd->sensor) {
+ case SENSOR_OV7660:
+ case SENSOR_SP80708:
+ reg9a = reg9a_spec;
break;
default:
reg9a = reg9a_def;
@@ -1104,7 +1105,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
reg_w1(gspca_dev, 0x17, 0x64);
reg_w1(gspca_dev, 0x01, 0x42);
break;
-/*jfm: from win trace */
case SENSOR_OV7630:
reg_w1(gspca_dev, 0x01, 0x61);
reg_w1(gspca_dev, 0x17, 0xe2);
@@ -1114,18 +1114,15 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
case SENSOR_OV7648:
reg_w1(gspca_dev, 0x01, 0x63);
reg_w1(gspca_dev, 0x17, 0x20);
+ reg_w1(gspca_dev, 0x01, 0x62);
reg_w1(gspca_dev, 0x01, 0x42);
break;
-/*jfm: from win trace */
case SENSOR_OV7660:
- if (sd->bridge == BRIDGE_SN9C120) {
- reg_w1(gspca_dev, 0x01, 0x61);
- reg_w1(gspca_dev, 0x17, 0x20);
- reg_w1(gspca_dev, 0x01, 0x60);
- reg_w1(gspca_dev, 0x01, 0x40);
- break;
- }
- /* fall thru */
+ reg_w1(gspca_dev, 0x01, 0x61);
+ reg_w1(gspca_dev, 0x17, 0x20);
+ reg_w1(gspca_dev, 0x01, 0x60);
+ reg_w1(gspca_dev, 0x01, 0x40);
+ break;
case SENSOR_SP80708:
reg_w1(gspca_dev, 0x01, 0x63);
reg_w1(gspca_dev, 0x17, 0x20);
@@ -1134,6 +1131,9 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
mdelay(100);
reg_w1(gspca_dev, 0x02, 0x62);
break;
+/* case SENSOR_HV7131R: */
+/* case SENSOR_MI0360: */
+/* case SENSOR_MO4000: */
default:
reg_w1(gspca_dev, 0x01, 0x43);
reg_w1(gspca_dev, 0x17, 0x61);
@@ -1280,6 +1280,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam = &gspca_dev->cam;
cam->cam_mode = vga_mode;
cam->nmodes = ARRAY_SIZE(vga_mode);
+ cam->npkt = 24; /* 24 packets per ISOC message */
sd->bridge = id->driver_info >> 16;
sd->sensor = id->driver_info >> 8;
@@ -1683,13 +1684,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
case SENSOR_OV7648:
reg17 = 0x20;
break;
-/*jfm: from win trace */
case SENSOR_OV7660:
- if (sd->bridge == BRIDGE_SN9C120) {
- reg17 = 0xa0;
- break;
- }
- /* fall thru */
+ reg17 = 0xa0;
+ break;
default:
reg17 = 0x60;
break;
@@ -1714,16 +1711,17 @@ static int sd_start(struct gspca_dev *gspca_dev)
reg_w1(gspca_dev, 0x9a, 0x0a);
reg_w1(gspca_dev, 0x99, 0x60);
break;
+ case SENSOR_OV7660:
+ reg_w1(gspca_dev, 0x9a, 0x05);
+ if (sd->bridge == BRIDGE_SN9C105)
+ reg_w1(gspca_dev, 0x99, 0xff);
+ else
+ reg_w1(gspca_dev, 0x99, 0x5b);
+ break;
case SENSOR_SP80708:
reg_w1(gspca_dev, 0x9a, 0x05);
reg_w1(gspca_dev, 0x99, 0x59);
break;
- case SENSOR_OV7660:
- if (sd->bridge == BRIDGE_SN9C120) {
- reg_w1(gspca_dev, 0x9a, 0x05);
- break;
- }
- /* fall thru */
default:
reg_w1(gspca_dev, 0x9a, 0x08);
reg_w1(gspca_dev, 0x99, 0x59);
@@ -2193,6 +2191,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
{USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
{USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
{USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
+ {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105, OV7660, 0x21)},
{USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
/* bw600.inf:
{USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
@@ -2211,7 +2210,12 @@ static const __devinitdata struct usb_device_id device_table[] = {
#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
{USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
#endif
+ {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/
/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
+ {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/
+ {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/
+ {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/
+ {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120, OV7630, 0x21)}, /*sn9c128*/
/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
{USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index 6f38fa6d86b6..8806b2ff82be 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -32,9 +32,6 @@ MODULE_LICENSE("GPL");
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
- __u8 packet[ISO_MAX_SIZE + 128];
- /* !! no more than 128 ff in an ISO packet */
-
unsigned char brightness;
unsigned char contrast;
unsigned char colors;
@@ -906,7 +903,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
{
struct sd *sd = (struct sd *) gspca_dev;
int i;
- __u8 *s, *d;
static __u8 ffd9[] = {0xff, 0xd9};
/* frames are jpeg 4.1.1 without 0xff escape */
@@ -930,22 +926,19 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
}
/* add 0x00 after 0xff */
- for (i = len; --i >= 0; )
- if (data[i] == 0xff)
- break;
- if (i < 0) { /* no 0xff */
- gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
- return;
- }
- s = data;
- d = sd->packet;
- for (i = 0; i < len; i++) {
- *d++ = *s++;
- if (s[-1] == 0xff)
- *d++ = 0x00;
- }
- gspca_frame_add(gspca_dev, INTER_PACKET, frame,
- sd->packet, d - sd->packet);
+ i = 0;
+ do {
+ if (data[i] == 0xff) {
+ gspca_frame_add(gspca_dev, INTER_PACKET, frame,
+ data, i + 1);
+ len -= i;
+ data += i;
+ *data = 0x00;
+ i = 0;
+ }
+ i++;
+ } while (i < len);
+ gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
}
static void setbrightness(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c
index 2e1cdf068fda..715a68f0156e 100644
--- a/drivers/media/video/gspca/sq905.c
+++ b/drivers/media/video/gspca/sq905.c
@@ -309,6 +309,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
struct sd *dev = (struct sd *) gspca_dev;
/* We don't use the buffer gspca allocates so make it small. */
+ cam->bulk = 1;
cam->bulk_size = 64;
INIT_WORK(&dev->work_struct, sq905_dostream);
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index 0bcb74a1b143..916892505432 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -206,6 +206,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->nmodes = 1;
/* We don't use the buffer gspca allocates so make it small. */
cam->bulk_size = 32;
+ cam->bulk = 1;
INIT_WORK(&dev->work_struct, sq905c_dostream);
return 0;
}
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c
index 69c77c932fc0..11a0c002f5dc 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c
@@ -80,12 +80,26 @@ static const struct ctrl vv6410_ctrl[] = {
.minimum = 0,
.maximum = 15,
.step = 1,
- .default_value = 0
+ .default_value = 10
},
.set = vv6410_set_analog_gain,
.get = vv6410_get_analog_gain
+ },
+#define EXPOSURE_IDX 3
+ {
+ {
+ .id = V4L2_CID_EXPOSURE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "exposure",
+ .minimum = 0,
+ .maximum = 32768,
+ .step = 1,
+ .default_value = 20000
+ },
+ .set = vv6410_set_exposure,
+ .get = vv6410_get_exposure
}
-};
+ };
static int vv6410_probe(struct sd *sd)
{
@@ -121,6 +135,7 @@ static int vv6410_probe(struct sd *sd)
static int vv6410_init(struct sd *sd)
{
int err = 0, i;
+ s32 *sensor_settings = sd->sensor_priv;
for (i = 0; i < ARRAY_SIZE(stv_bridge_init); i++) {
/* if NULL then len contains single value */
@@ -142,6 +157,16 @@ static int vv6410_init(struct sd *sd)
err = stv06xx_write_sensor_bytes(sd, (u8 *) vv6410_sensor_init,
ARRAY_SIZE(vv6410_sensor_init));
+ if (err < 0)
+ return err;
+
+ err = vv6410_set_exposure(&sd->gspca_dev,
+ sensor_settings[EXPOSURE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = vv6410_set_analog_gain(&sd->gspca_dev,
+ sensor_settings[GAIN_IDX]);
return (err < 0) ? err : 0;
}
@@ -318,3 +343,50 @@ static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val)
return (err < 0) ? err : 0;
}
+
+static int vv6410_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[EXPOSURE_IDX];
+
+ PDEBUG(D_V4L2, "Read exposure %d", *val);
+
+ return 0;
+}
+
+static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
+{
+ int err;
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ unsigned int fine, coarse;
+
+ sensor_settings[EXPOSURE_IDX] = val;
+
+ val = (val * val >> 14) + val / 4;
+
+ fine = val % VV6410_CIF_LINELENGTH;
+ coarse = min(512, val / VV6410_CIF_LINELENGTH);
+
+ PDEBUG(D_V4L2, "Set coarse exposure to %d, fine expsure to %d",
+ coarse, fine);
+
+ err = stv06xx_write_sensor(sd, VV6410_FINEH, fine >> 8);
+ if (err < 0)
+ goto out;
+
+ err = stv06xx_write_sensor(sd, VV6410_FINEL, fine & 0xff);
+ if (err < 0)
+ goto out;
+
+ err = stv06xx_write_sensor(sd, VV6410_COARSEH, coarse >> 8);
+ if (err < 0)
+ goto out;
+
+ err = stv06xx_write_sensor(sd, VV6410_COARSEL, coarse & 0xff);
+
+out:
+ return err;
+}
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
index 95ac55891bd4..487d40555343 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
@@ -173,6 +173,8 @@
#define VV6410_SUBSAMPLE 0x01
#define VV6410_CROP_TO_QVGA 0x02
+#define VV6410_CIF_LINELENGTH 415
+
static int vv6410_probe(struct sd *sd);
static int vv6410_start(struct sd *sd);
static int vv6410_init(struct sd *sd);
@@ -187,6 +189,8 @@ static int vv6410_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
static int vv6410_get_analog_gain(struct gspca_dev *gspca_dev, __s32 *val);
static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int vv6410_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);
+static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
const struct stv06xx_sensor stv06xx_sensor_vv6410 = {
.name = "ST VV6410",
@@ -242,12 +246,6 @@ static const u8 vv6410_sensor_init[][2] = {
/* Pre-clock generator divide off */
{VV6410_DATAFORMAT, BIT(7) | BIT(0)},
- /* Exposure registers */
- {VV6410_FINEH, VV6410_FINE_EXPOSURE >> 8},
- {VV6410_FINEL, VV6410_FINE_EXPOSURE & 0xff},
- {VV6410_COARSEH, VV6410_COARSE_EXPOSURE >> 8},
- {VV6410_COARSEL, VV6410_COARSE_EXPOSURE & 0xff},
- {VV6410_ANALOGGAIN, 0xf0 | VV6410_DEFAULT_GAIN},
{VV6410_CLKDIV, VV6410_CLK_DIV_2},
/* System registers */
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index c2b8c10c075a..9623f294bdac 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -32,9 +32,6 @@ MODULE_LICENSE("GPL");
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
- __u8 packet[ISO_MAX_SIZE + 128];
- /* !! no more than 128 ff in an ISO packet */
-
unsigned char brightness;
unsigned char contrast;
unsigned char colors;
@@ -1103,7 +1100,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
{
struct sd *sd = (struct sd *) gspca_dev;
int i, sof = 0;
- unsigned char *s, *d;
static unsigned char ffd9[] = {0xff, 0xd9};
/* frames are jpeg 4.1.1 without 0xff escape */
@@ -1177,22 +1173,19 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
}
/* add 0x00 after 0xff */
- for (i = len; --i >= 0; )
- if (data[i] == 0xff)
- break;
- if (i < 0) { /* no 0xff */
- gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
- return;
- }
- s = data;
- d = sd->packet;
- for (i = 0; i < len; i++) {
- *d++ = *s++;
- if (s[-1] == 0xff)
- *d++ = 0x00;
- }
- gspca_frame_add(gspca_dev, INTER_PACKET, frame,
- sd->packet, d - sd->packet);
+ i = 0;
+ do {
+ if (data[i] == 0xff) {
+ gspca_frame_add(gspca_dev, INTER_PACKET, frame,
+ data, i + 1);
+ len -= i;
+ data += i;
+ *data = 0x00;
+ i = 0;
+ }
+ i++;
+ } while (i < len);
+ gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
}
static void setbrightness(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index f63e37e2e4fd..404214b8cd2b 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -697,7 +697,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
return -EINVAL;
}
- if (sd->sensor != SENSOR_OTHER) {
+ if (sd->sensor == SENSOR_OM6802) {
reg_w_buf(gspca_dev, n1, sizeof n1);
i = 5;
while (--i >= 0) {
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index e4e933c400bc..26dd155efcc3 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -42,7 +42,7 @@ struct sd {
char bridge;
#define BRIDGE_VC0321 0
#define BRIDGE_VC0323 1
- char sensor;
+ u8 sensor;
#define SENSOR_HV7131R 0
#define SENSOR_MI0360 1
#define SENSOR_MI1310_SOC 2
@@ -159,17 +159,17 @@ static const struct v4l2_pix_format vc0323_mode[] = {
.priv = 2},
};
static const struct v4l2_pix_format bi_mode[] = {
- {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
+ {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240 * 2,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 2},
- {640, 480, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
+ {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480 * 2,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 1},
- {1280, 1024, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
+ {1280, 1024, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
.bytesperline = 1280,
.sizeimage = 1280 * 1024 * 2,
.colorspace = V4L2_COLORSPACE_SRGB,
@@ -2453,6 +2453,17 @@ static int sd_config(struct gspca_dev *gspca_dev,
struct usb_device *dev = gspca_dev->dev;
struct cam *cam;
int sensor;
+ static u8 npkt[] = { /* number of packets per ISOC message */
+ 64, /* HV7131R 0 */
+ 32, /* MI0360 1 */
+ 32, /* MI1310_SOC 2 */
+ 64, /* MI1320 3 */
+ 128, /* MI1320_SOC 4 */
+ 32, /* OV7660 5 */
+ 64, /* OV7670 6 */
+ 128, /* PO1200 7 */
+ 128, /* PO3130NC 8 */
+ };
cam = &gspca_dev->cam;
sd->bridge = id->driver_info;
@@ -2508,6 +2519,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
case SENSOR_MI1320_SOC:
cam->cam_mode = bi_mode;
cam->nmodes = ARRAY_SIZE(bi_mode);
+ cam->input_flags = V4L2_IN_ST_VFLIP |
+ V4L2_IN_ST_HFLIP;
break;
default:
cam->cam_mode = vc0323_mode;
@@ -2515,6 +2528,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
break;
}
}
+ cam->npkt = npkt[sd->sensor];
sd->hflip = HFLIP_DEF;
sd->vflip = VFLIP_DEF;
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 4fe01d8b6c87..08422d315e68 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6307,7 +6307,7 @@ static __u16 i2c_read(struct gspca_dev *gspca_dev,
retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
retval = reg_r_i(gspca_dev, 0x0095); /* read Lowbyte */
retval |= reg_r_i(gspca_dev, 0x0096) << 8; /* read Hightbyte */
- PDEBUG(D_USBO, "i2c r [%02x] -> %04x (%02x)",
+ PDEBUG(D_USBI, "i2c r [%02x] -> %04x (%02x)",
reg, retval, retbyte);
return retval;
}
@@ -6868,7 +6868,6 @@ static const struct sensor_by_chipset_revision chipset_revision_sensor[] = {
{0x8001, 0x13},
{0x8000, 0x14}, /* CS2102K */
{0x8400, 0x15}, /* TAS5130K */
- {0x4001, 0x16}, /* ADCM2700 */
};
static int vga_3wr_probe(struct gspca_dev *gspca_dev)
@@ -6904,12 +6903,15 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
retword |= reg_r(gspca_dev, 0x000a);
PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword);
reg_r(gspca_dev, 0x0010);
- /* this is tested only once anyway */
- for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
- if (chipset_revision_sensor[i].revision == retword) {
- sd->chip_revision = retword;
- send_unknown(dev, SENSOR_PB0330);
- return chipset_revision_sensor[i].internal_sensor_id;
+ /* value 0x4001 is meaningless */
+ if (retword != 0x4001) {
+ for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
+ if (chipset_revision_sensor[i].revision == retword) {
+ sd->chip_revision = retword;
+ send_unknown(dev, SENSOR_PB0330);
+ return chipset_revision_sensor[i]
+ .internal_sensor_id;
+ }
}
}
@@ -6980,12 +6982,12 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
reg_w(dev, 0x01, 0x0001);
reg_w(dev, 0x03, 0x0012);
reg_w(dev, 0x01, 0x0012);
- reg_w(dev, 0x05, 0x0001);
+ reg_w(dev, 0x05, 0x0012);
reg_w(dev, 0xd3, 0x008b);
retword = i2c_read(gspca_dev, 0x01);
if (retword != 0) {
PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword);
- return retword;
+ return 0x16; /* adcm2700 (6100/6200) */
}
return -1;
}
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index 3e6ffee8dfed..ccd47f57f42c 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -181,7 +181,7 @@ static int hdpvr_submit_buffers(struct hdpvr_device *dev)
buff_list);
if (buf->status != BUFSTAT_AVAILABLE) {
v4l2_err(&dev->v4l2_dev,
- "buffer not marked as availbale\n");
+ "buffer not marked as available\n");
ret = -EFAULT;
goto err;
}
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c
index 8e1463ee1b64..71c211402eb5 100644
--- a/drivers/media/video/hexium_gemini.c
+++ b/drivers/media/video/hexium_gemini.c
@@ -224,7 +224,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{
DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index));
- if (i->index < 0 || i->index >= HEXIUM_INPUTS)
+ if (i->index >= HEXIUM_INPUTS)
return -EINVAL;
memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input));
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
index 2bc39f628455..39d65ca41c62 100644
--- a/drivers/media/video/hexium_orion.c
+++ b/drivers/media/video/hexium_orion.c
@@ -325,7 +325,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{
DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index));
- if (i->index < 0 || i->index >= HEXIUM_INPUTS)
+ if (i->index >= HEXIUM_INPUTS)
return -EINVAL;
memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input));
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index db2ac9a99acd..e9ca9a064ae5 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -946,17 +946,14 @@ static int __devinit ivtv_probe(struct pci_dev *pdev,
if (itv == NULL)
return -ENOMEM;
itv->pdev = pdev;
- itv->instance = atomic_inc_return(&ivtv_instance) - 1;
+ itv->instance = v4l2_device_set_name(&itv->v4l2_dev, "ivtv",
+ &ivtv_instance);
retval = v4l2_device_register(&pdev->dev, &itv->v4l2_dev);
if (retval) {
kfree(itv);
return retval;
}
- /* "ivtv + PCI ID" is a bit of a mouthful, so use
- "ivtv + instance" instead. */
- snprintf(itv->v4l2_dev.name, sizeof(itv->v4l2_dev.name),
- "ivtv%d", itv->instance);
IVTV_INFO("Initializing card %d\n", itv->instance);
ivtv_process_options(itv);
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index c342a9fe983e..99f3c39a118b 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -709,7 +709,7 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
else if (itv->has_cx23415 && regs->reg >= IVTV_DECODER_OFFSET &&
regs->reg < IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
reg_start = itv->dec_mem - IVTV_DECODER_OFFSET;
- else if (regs->reg >= 0 && regs->reg < IVTV_ENCODER_SIZE)
+ else if (regs->reg < IVTV_ENCODER_SIZE)
reg_start = itv->enc_mem;
else
return -EINVAL;
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index 684f62fa7897..459c04cbf69d 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -75,53 +75,50 @@ struct mt9m001 {
unsigned char autoexposure;
};
-static int reg_read(struct soc_camera_device *icd, const u8 reg)
+static int reg_read(struct i2c_client *client, const u8 reg)
{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- struct i2c_client *client = mt9m001->client;
s32 data = i2c_smbus_read_word_data(client, reg);
return data < 0 ? data : swab16(data);
}
-static int reg_write(struct soc_camera_device *icd, const u8 reg,
+static int reg_write(struct i2c_client *client, const u8 reg,
const u16 data)
{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- return i2c_smbus_write_word_data(mt9m001->client, reg, swab16(data));
+ return i2c_smbus_write_word_data(client, reg, swab16(data));
}
-static int reg_set(struct soc_camera_device *icd, const u8 reg,
+static int reg_set(struct i2c_client *client, const u8 reg,
const u16 data)
{
int ret;
- ret = reg_read(icd, reg);
+ ret = reg_read(client, reg);
if (ret < 0)
return ret;
- return reg_write(icd, reg, ret | data);
+ return reg_write(client, reg, ret | data);
}
-static int reg_clear(struct soc_camera_device *icd, const u8 reg,
+static int reg_clear(struct i2c_client *client, const u8 reg,
const u16 data)
{
int ret;
- ret = reg_read(icd, reg);
+ ret = reg_read(client, reg);
if (ret < 0)
return ret;
- return reg_write(icd, reg, ret & ~data);
+ return reg_write(client, reg, ret & ~data);
}
static int mt9m001_init(struct soc_camera_device *icd)
{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- struct soc_camera_link *icl = mt9m001->client->dev.platform_data;
+ struct i2c_client *client = to_i2c_client(icd->control);
+ struct soc_camera_link *icl = client->dev.platform_data;
int ret;
dev_dbg(icd->vdev->parent, "%s\n", __func__);
if (icl->power) {
- ret = icl->power(&mt9m001->client->dev, 1);
+ ret = icl->power(&client->dev, 1);
if (ret < 0) {
dev_err(icd->vdev->parent,
"Platform failed to power-on the camera.\n");
@@ -131,49 +128,53 @@ static int mt9m001_init(struct soc_camera_device *icd)
/* The camera could have been already on, we reset it additionally */
if (icl->reset)
- ret = icl->reset(&mt9m001->client->dev);
+ ret = icl->reset(&client->dev);
else
ret = -ENODEV;
if (ret < 0) {
/* Either no platform reset, or platform reset failed */
- ret = reg_write(icd, MT9M001_RESET, 1);
+ ret = reg_write(client, MT9M001_RESET, 1);
if (!ret)
- ret = reg_write(icd, MT9M001_RESET, 0);
+ ret = reg_write(client, MT9M001_RESET, 0);
}
/* Disable chip, synchronous option update */
if (!ret)
- ret = reg_write(icd, MT9M001_OUTPUT_CONTROL, 0);
+ ret = reg_write(client, MT9M001_OUTPUT_CONTROL, 0);
return ret;
}
static int mt9m001_release(struct soc_camera_device *icd)
{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- struct soc_camera_link *icl = mt9m001->client->dev.platform_data;
+ struct i2c_client *client = to_i2c_client(icd->control);
+ struct soc_camera_link *icl = client->dev.platform_data;
/* Disable the chip */
- reg_write(icd, MT9M001_OUTPUT_CONTROL, 0);
+ reg_write(client, MT9M001_OUTPUT_CONTROL, 0);
if (icl->power)
- icl->power(&mt9m001->client->dev, 0);
+ icl->power(&client->dev, 0);
return 0;
}
static int mt9m001_start_capture(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
+
/* Switch to master "normal" mode */
- if (reg_write(icd, MT9M001_OUTPUT_CONTROL, 2) < 0)
+ if (reg_write(client, MT9M001_OUTPUT_CONTROL, 2) < 0)
return -EIO;
return 0;
}
static int mt9m001_stop_capture(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
+
/* Stop sensor readout */
- if (reg_write(icd, MT9M001_OUTPUT_CONTROL, 0) < 0)
+ if (reg_write(client, MT9M001_OUTPUT_CONTROL, 0) < 0)
return -EIO;
return 0;
}
@@ -222,28 +223,29 @@ static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd)
static int mt9m001_set_crop(struct soc_camera_device *icd,
struct v4l2_rect *rect)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
int ret;
const u16 hblank = 9, vblank = 25;
/* Blanking and start values - default... */
- ret = reg_write(icd, MT9M001_HORIZONTAL_BLANKING, hblank);
+ ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank);
if (!ret)
- ret = reg_write(icd, MT9M001_VERTICAL_BLANKING, vblank);
+ ret = reg_write(client, MT9M001_VERTICAL_BLANKING, vblank);
/* The caller provides a supported format, as verified per
* call to icd->try_fmt() */
if (!ret)
- ret = reg_write(icd, MT9M001_COLUMN_START, rect->left);
+ ret = reg_write(client, MT9M001_COLUMN_START, rect->left);
if (!ret)
- ret = reg_write(icd, MT9M001_ROW_START, rect->top);
+ ret = reg_write(client, MT9M001_ROW_START, rect->top);
if (!ret)
- ret = reg_write(icd, MT9M001_WINDOW_WIDTH, rect->width - 1);
+ ret = reg_write(client, MT9M001_WINDOW_WIDTH, rect->width - 1);
if (!ret)
- ret = reg_write(icd, MT9M001_WINDOW_HEIGHT,
+ ret = reg_write(client, MT9M001_WINDOW_HEIGHT,
rect->height + icd->y_skip_top - 1);
if (!ret && mt9m001->autoexposure) {
- ret = reg_write(icd, MT9M001_SHUTTER_WIDTH,
+ ret = reg_write(client, MT9M001_SHUTTER_WIDTH,
rect->height + icd->y_skip_top + vblank);
if (!ret) {
const struct v4l2_queryctrl *qctrl =
@@ -312,16 +314,16 @@ static int mt9m001_get_chip_id(struct soc_camera_device *icd,
static int mt9m001_get_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
return -EINVAL;
- if (reg->match.addr != mt9m001->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
reg->size = 2;
- reg->val = reg_read(icd, reg->reg);
+ reg->val = reg_read(client, reg->reg);
if (reg->val > 0xffff)
return -EIO;
@@ -332,15 +334,15 @@ static int mt9m001_get_register(struct soc_camera_device *icd,
static int mt9m001_set_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
return -EINVAL;
- if (reg->match.addr != mt9m001->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
- if (reg_write(icd, reg->reg, reg->val) < 0)
+ if (reg_write(client, reg->reg, reg->val) < 0)
return -EIO;
return 0;
@@ -416,12 +418,13 @@ static struct soc_camera_ops mt9m001_ops = {
static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
int data;
switch (ctrl->id) {
case V4L2_CID_VFLIP:
- data = reg_read(icd, MT9M001_READ_OPTIONS2);
+ data = reg_read(client, MT9M001_READ_OPTIONS2);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x8000);
@@ -435,6 +438,7 @@ static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_contro
static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
const struct v4l2_queryctrl *qctrl;
int data;
@@ -447,9 +451,9 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro
switch (ctrl->id) {
case V4L2_CID_VFLIP:
if (ctrl->value)
- data = reg_set(icd, MT9M001_READ_OPTIONS2, 0x8000);
+ data = reg_set(client, MT9M001_READ_OPTIONS2, 0x8000);
else
- data = reg_clear(icd, MT9M001_READ_OPTIONS2, 0x8000);
+ data = reg_clear(client, MT9M001_READ_OPTIONS2, 0x8000);
if (data < 0)
return -EIO;
break;
@@ -463,7 +467,7 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro
data = ((ctrl->value - qctrl->minimum) * 8 + range / 2) / range;
dev_dbg(&icd->dev, "Setting gain %d\n", data);
- data = reg_write(icd, MT9M001_GLOBAL_GAIN, data);
+ data = reg_write(client, MT9M001_GLOBAL_GAIN, data);
if (data < 0)
return -EIO;
} else {
@@ -481,8 +485,8 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro
data = ((gain - 64) * 7 + 28) / 56 + 96;
dev_dbg(&icd->dev, "Setting gain from %d to %d\n",
- reg_read(icd, MT9M001_GLOBAL_GAIN), data);
- data = reg_write(icd, MT9M001_GLOBAL_GAIN, data);
+ reg_read(client, MT9M001_GLOBAL_GAIN), data);
+ data = reg_write(client, MT9M001_GLOBAL_GAIN, data);
if (data < 0)
return -EIO;
}
@@ -500,8 +504,8 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro
range / 2) / range + 1;
dev_dbg(&icd->dev, "Setting shutter width from %d to %lu\n",
- reg_read(icd, MT9M001_SHUTTER_WIDTH), shutter);
- if (reg_write(icd, MT9M001_SHUTTER_WIDTH, shutter) < 0)
+ reg_read(client, MT9M001_SHUTTER_WIDTH), shutter);
+ if (reg_write(client, MT9M001_SHUTTER_WIDTH, shutter) < 0)
return -EIO;
icd->exposure = ctrl->value;
mt9m001->autoexposure = 0;
@@ -510,7 +514,7 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro
case V4L2_CID_EXPOSURE_AUTO:
if (ctrl->value) {
const u16 vblank = 25;
- if (reg_write(icd, MT9M001_SHUTTER_WIDTH, icd->height +
+ if (reg_write(client, MT9M001_SHUTTER_WIDTH, icd->height +
icd->y_skip_top + vblank) < 0)
return -EIO;
qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
@@ -529,8 +533,9 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro
* this wasn't our capture interface, so, we wait for the right one */
static int mt9m001_video_probe(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- struct soc_camera_link *icl = mt9m001->client->dev.platform_data;
+ struct soc_camera_link *icl = client->dev.platform_data;
s32 data;
int ret;
unsigned long flags;
@@ -542,11 +547,11 @@ static int mt9m001_video_probe(struct soc_camera_device *icd)
return -ENODEV;
/* Enable the chip */
- data = reg_write(icd, MT9M001_CHIP_ENABLE, 1);
+ data = reg_write(client, MT9M001_CHIP_ENABLE, 1);
dev_dbg(&icd->dev, "write: %d\n", data);
/* Read out the chip version register */
- data = reg_read(icd, MT9M001_CHIP_VERSION);
+ data = reg_read(client, MT9M001_CHIP_VERSION);
/* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */
switch (data) {
@@ -604,10 +609,13 @@ ei2c:
static void mt9m001_video_remove(struct soc_camera_device *icd)
{
struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
+ struct soc_camera_link *icl = mt9m001->client->dev.platform_data;
dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9m001->client->addr,
icd->dev.parent, icd->vdev);
soc_camera_video_stop(icd);
+ if (icl->free_bus)
+ icl->free_bus(icl);
}
static int mt9m001_probe(struct i2c_client *client,
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index cdd1ddb51388..fc5e2de03766 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -113,10 +113,10 @@
* mt9m111: Camera control register addresses (0x200..0x2ff not implemented)
*/
-#define reg_read(reg) mt9m111_reg_read(icd, MT9M111_##reg)
-#define reg_write(reg, val) mt9m111_reg_write(icd, MT9M111_##reg, (val))
-#define reg_set(reg, val) mt9m111_reg_set(icd, MT9M111_##reg, (val))
-#define reg_clear(reg, val) mt9m111_reg_clear(icd, MT9M111_##reg, (val))
+#define reg_read(reg) mt9m111_reg_read(client, MT9M111_##reg)
+#define reg_write(reg, val) mt9m111_reg_write(client, MT9M111_##reg, (val))
+#define reg_set(reg, val) mt9m111_reg_set(client, MT9M111_##reg, (val))
+#define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val))
#define MT9M111_MIN_DARK_ROWS 8
#define MT9M111_MIN_DARK_COLS 24
@@ -184,58 +184,55 @@ static int reg_page_map_set(struct i2c_client *client, const u16 reg)
return ret;
}
-static int mt9m111_reg_read(struct soc_camera_device *icd, const u16 reg)
+static int mt9m111_reg_read(struct i2c_client *client, const u16 reg)
{
- struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
- struct i2c_client *client = mt9m111->client;
int ret;
ret = reg_page_map_set(client, reg);
if (!ret)
ret = swab16(i2c_smbus_read_word_data(client, (reg & 0xff)));
- dev_dbg(&icd->dev, "read reg.%03x -> %04x\n", reg, ret);
+ dev_dbg(&client->dev, "read reg.%03x -> %04x\n", reg, ret);
return ret;
}
-static int mt9m111_reg_write(struct soc_camera_device *icd, const u16 reg,
+static int mt9m111_reg_write(struct i2c_client *client, const u16 reg,
const u16 data)
{
- struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
- struct i2c_client *client = mt9m111->client;
int ret;
ret = reg_page_map_set(client, reg);
if (!ret)
- ret = i2c_smbus_write_word_data(mt9m111->client, (reg & 0xff),
+ ret = i2c_smbus_write_word_data(client, (reg & 0xff),
swab16(data));
- dev_dbg(&icd->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret);
+ dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret);
return ret;
}
-static int mt9m111_reg_set(struct soc_camera_device *icd, const u16 reg,
+static int mt9m111_reg_set(struct i2c_client *client, const u16 reg,
const u16 data)
{
int ret;
- ret = mt9m111_reg_read(icd, reg);
+ ret = mt9m111_reg_read(client, reg);
if (ret >= 0)
- ret = mt9m111_reg_write(icd, reg, ret | data);
+ ret = mt9m111_reg_write(client, reg, ret | data);
return ret;
}
-static int mt9m111_reg_clear(struct soc_camera_device *icd, const u16 reg,
+static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg,
const u16 data)
{
int ret;
- ret = mt9m111_reg_read(icd, reg);
- return mt9m111_reg_write(icd, reg, ret & ~data);
+ ret = mt9m111_reg_read(client, reg);
+ return mt9m111_reg_write(client, reg, ret & ~data);
}
static int mt9m111_set_context(struct soc_camera_device *icd,
enum mt9m111_context ctxt)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
int valB = MT9M111_CTXT_CTRL_RESTART | MT9M111_CTXT_CTRL_DEFECTCOR_B
| MT9M111_CTXT_CTRL_RESIZE_B | MT9M111_CTXT_CTRL_CTRL2_B
| MT9M111_CTXT_CTRL_GAMMA_B | MT9M111_CTXT_CTRL_READ_MODE_B
@@ -252,6 +249,7 @@ static int mt9m111_set_context(struct soc_camera_device *icd,
static int mt9m111_setup_rect(struct soc_camera_device *icd,
struct v4l2_rect *rect)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
int ret, is_raw_format;
int width = rect->width;
@@ -296,6 +294,7 @@ static int mt9m111_setup_rect(struct soc_camera_device *icd,
static int mt9m111_setup_pixfmt(struct soc_camera_device *icd, u16 outfmt)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
int ret;
ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt);
@@ -357,12 +356,13 @@ static int mt9m111_setfmt_yuv(struct soc_camera_device *icd)
static int mt9m111_enable(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
- struct soc_camera_link *icl = mt9m111->client->dev.platform_data;
+ struct soc_camera_link *icl = client->dev.platform_data;
int ret;
if (icl->power) {
- ret = icl->power(&mt9m111->client->dev, 1);
+ ret = icl->power(&client->dev, 1);
if (ret < 0) {
dev_err(icd->vdev->parent,
"Platform failed to power-on the camera.\n");
@@ -378,8 +378,9 @@ static int mt9m111_enable(struct soc_camera_device *icd)
static int mt9m111_disable(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
- struct soc_camera_link *icl = mt9m111->client->dev.platform_data;
+ struct soc_camera_link *icl = client->dev.platform_data;
int ret;
ret = reg_clear(RESET, MT9M111_RESET_CHIP_ENABLE);
@@ -387,15 +388,15 @@ static int mt9m111_disable(struct soc_camera_device *icd)
mt9m111->powered = 0;
if (icl->power)
- icl->power(&mt9m111->client->dev, 0);
+ icl->power(&client->dev, 0);
return ret;
}
static int mt9m111_reset(struct soc_camera_device *icd)
{
- struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
- struct soc_camera_link *icl = mt9m111->client->dev.platform_data;
+ struct i2c_client *client = to_i2c_client(icd->control);
+ struct soc_camera_link *icl = client->dev.platform_data;
int ret;
ret = reg_set(RESET, MT9M111_RESET_RESET_MODE);
@@ -406,7 +407,7 @@ static int mt9m111_reset(struct soc_camera_device *icd)
| MT9M111_RESET_RESET_SOC);
if (icl->reset)
- icl->reset(&mt9m111->client->dev);
+ icl->reset(&client->dev);
return ret;
}
@@ -562,15 +563,14 @@ static int mt9m111_get_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
int val;
-
- struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff)
return -EINVAL;
- if (reg->match.addr != mt9m111->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
- val = mt9m111_reg_read(icd, reg->reg);
+ val = mt9m111_reg_read(client, reg->reg);
reg->size = 2;
reg->val = (u64)val;
@@ -583,15 +583,15 @@ static int mt9m111_get_register(struct soc_camera_device *icd,
static int mt9m111_set_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff)
return -EINVAL;
- if (reg->match.addr != mt9m111->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
- if (mt9m111_reg_write(icd, reg->reg, reg->val) < 0)
+ if (mt9m111_reg_write(client, reg->reg, reg->val) < 0)
return -EIO;
return 0;
@@ -672,6 +672,7 @@ static struct soc_camera_ops mt9m111_ops = {
static int mt9m111_set_flip(struct soc_camera_device *icd, int flip, int mask)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
int ret;
@@ -692,6 +693,7 @@ static int mt9m111_set_flip(struct soc_camera_device *icd, int flip, int mask)
static int mt9m111_get_global_gain(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
int data;
data = reg_read(GLOBAL_GAIN);
@@ -703,6 +705,7 @@ static int mt9m111_get_global_gain(struct soc_camera_device *icd)
static int mt9m111_set_global_gain(struct soc_camera_device *icd, int gain)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
u16 val;
if (gain > 63 * 2 * 2)
@@ -721,6 +724,7 @@ static int mt9m111_set_global_gain(struct soc_camera_device *icd, int gain)
static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
int ret;
@@ -737,6 +741,7 @@ static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on)
static int mt9m111_set_autowhitebalance(struct soc_camera_device *icd, int on)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
int ret;
@@ -754,6 +759,7 @@ static int mt9m111_set_autowhitebalance(struct soc_camera_device *icd, int on)
static int mt9m111_get_control(struct soc_camera_device *icd,
struct v4l2_control *ctrl)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
int data;
@@ -898,6 +904,7 @@ static int mt9m111_release(struct soc_camera_device *icd)
*/
static int mt9m111_video_probe(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
s32 data;
int ret;
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
index 2b0927bfd217..f72aeb7c4deb 100644
--- a/drivers/media/video/mt9t031.c
+++ b/drivers/media/video/mt9t031.c
@@ -76,64 +76,61 @@ struct mt9t031 {
u16 yskip;
};
-static int reg_read(struct soc_camera_device *icd, const u8 reg)
+static int reg_read(struct i2c_client *client, const u8 reg)
{
- struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
- struct i2c_client *client = mt9t031->client;
s32 data = i2c_smbus_read_word_data(client, reg);
return data < 0 ? data : swab16(data);
}
-static int reg_write(struct soc_camera_device *icd, const u8 reg,
+static int reg_write(struct i2c_client *client, const u8 reg,
const u16 data)
{
- struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
- return i2c_smbus_write_word_data(mt9t031->client, reg, swab16(data));
+ return i2c_smbus_write_word_data(client, reg, swab16(data));
}
-static int reg_set(struct soc_camera_device *icd, const u8 reg,
+static int reg_set(struct i2c_client *client, const u8 reg,
const u16 data)
{
int ret;
- ret = reg_read(icd, reg);
+ ret = reg_read(client, reg);
if (ret < 0)
return ret;
- return reg_write(icd, reg, ret | data);
+ return reg_write(client, reg, ret | data);
}
-static int reg_clear(struct soc_camera_device *icd, const u8 reg,
+static int reg_clear(struct i2c_client *client, const u8 reg,
const u16 data)
{
int ret;
- ret = reg_read(icd, reg);
+ ret = reg_read(client, reg);
if (ret < 0)
return ret;
- return reg_write(icd, reg, ret & ~data);
+ return reg_write(client, reg, ret & ~data);
}
-static int set_shutter(struct soc_camera_device *icd, const u32 data)
+static int set_shutter(struct i2c_client *client, const u32 data)
{
int ret;
- ret = reg_write(icd, MT9T031_SHUTTER_WIDTH_UPPER, data >> 16);
+ ret = reg_write(client, MT9T031_SHUTTER_WIDTH_UPPER, data >> 16);
if (ret >= 0)
- ret = reg_write(icd, MT9T031_SHUTTER_WIDTH, data & 0xffff);
+ ret = reg_write(client, MT9T031_SHUTTER_WIDTH, data & 0xffff);
return ret;
}
-static int get_shutter(struct soc_camera_device *icd, u32 *data)
+static int get_shutter(struct i2c_client *client, u32 *data)
{
int ret;
- ret = reg_read(icd, MT9T031_SHUTTER_WIDTH_UPPER);
+ ret = reg_read(client, MT9T031_SHUTTER_WIDTH_UPPER);
*data = ret << 16;
if (ret >= 0)
- ret = reg_read(icd, MT9T031_SHUTTER_WIDTH);
+ ret = reg_read(client, MT9T031_SHUTTER_WIDTH);
*data |= ret & 0xffff;
return ret < 0 ? ret : 0;
@@ -141,12 +138,12 @@ static int get_shutter(struct soc_camera_device *icd, u32 *data)
static int mt9t031_init(struct soc_camera_device *icd)
{
- struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
- struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
+ struct i2c_client *client = to_i2c_client(icd->control);
+ struct soc_camera_link *icl = client->dev.platform_data;
int ret;
if (icl->power) {
- ret = icl->power(&mt9t031->client->dev, 1);
+ ret = icl->power(&client->dev, 1);
if (ret < 0) {
dev_err(icd->vdev->parent,
"Platform failed to power-on the camera.\n");
@@ -155,44 +152,48 @@ static int mt9t031_init(struct soc_camera_device *icd)
}
/* Disable chip output, synchronous option update */
- ret = reg_write(icd, MT9T031_RESET, 1);
+ ret = reg_write(client, MT9T031_RESET, 1);
if (ret >= 0)
- ret = reg_write(icd, MT9T031_RESET, 0);
+ ret = reg_write(client, MT9T031_RESET, 0);
if (ret >= 0)
- ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
+ ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 2);
if (ret < 0 && icl->power)
- icl->power(&mt9t031->client->dev, 0);
+ icl->power(&client->dev, 0);
return ret >= 0 ? 0 : -EIO;
}
static int mt9t031_release(struct soc_camera_device *icd)
{
- struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
- struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
+ struct i2c_client *client = to_i2c_client(icd->control);
+ struct soc_camera_link *icl = client->dev.platform_data;
/* Disable the chip */
- reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
+ reg_clear(client, MT9T031_OUTPUT_CONTROL, 2);
if (icl->power)
- icl->power(&mt9t031->client->dev, 0);
+ icl->power(&client->dev, 0);
return 0;
}
static int mt9t031_start_capture(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
+
/* Switch to master "normal" mode */
- if (reg_set(icd, MT9T031_OUTPUT_CONTROL, 2) < 0)
+ if (reg_set(client, MT9T031_OUTPUT_CONTROL, 2) < 0)
return -EIO;
return 0;
}
static int mt9t031_stop_capture(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
+
/* Stop sensor readout */
- if (reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2) < 0)
+ if (reg_clear(client, MT9T031_OUTPUT_CONTROL, 2) < 0)
return -EIO;
return 0;
}
@@ -200,14 +201,16 @@ static int mt9t031_stop_capture(struct soc_camera_device *icd)
static int mt9t031_set_bus_param(struct soc_camera_device *icd,
unsigned long flags)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
+
/* The caller should have queried our parameters, check anyway */
if (flags & ~MT9T031_BUS_PARAM)
return -EINVAL;
if (flags & SOCAM_PCLK_SAMPLE_FALLING)
- reg_clear(icd, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000);
+ reg_clear(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000);
else
- reg_set(icd, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000);
+ reg_set(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000);
return 0;
}
@@ -235,6 +238,7 @@ static void recalculate_limits(struct soc_camera_device *icd,
static int mt9t031_set_params(struct soc_camera_device *icd,
struct v4l2_rect *rect, u16 xskip, u16 yskip)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
int ret;
u16 xbin, ybin, width, height, left, top;
@@ -277,22 +281,22 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
}
/* Disable register update, reconfigure atomically */
- ret = reg_set(icd, MT9T031_OUTPUT_CONTROL, 1);
+ ret = reg_set(client, MT9T031_OUTPUT_CONTROL, 1);
if (ret < 0)
return ret;
/* Blanking and start values - default... */
- ret = reg_write(icd, MT9T031_HORIZONTAL_BLANKING, hblank);
+ ret = reg_write(client, MT9T031_HORIZONTAL_BLANKING, hblank);
if (ret >= 0)
- ret = reg_write(icd, MT9T031_VERTICAL_BLANKING, vblank);
+ ret = reg_write(client, MT9T031_VERTICAL_BLANKING, vblank);
if (yskip != mt9t031->yskip || xskip != mt9t031->xskip) {
/* Binning, skipping */
if (ret >= 0)
- ret = reg_write(icd, MT9T031_COLUMN_ADDRESS_MODE,
+ ret = reg_write(client, MT9T031_COLUMN_ADDRESS_MODE,
((xbin - 1) << 4) | (xskip - 1));
if (ret >= 0)
- ret = reg_write(icd, MT9T031_ROW_ADDRESS_MODE,
+ ret = reg_write(client, MT9T031_ROW_ADDRESS_MODE,
((ybin - 1) << 4) | (yskip - 1));
}
dev_dbg(&icd->dev, "new physical left %u, top %u\n", left, top);
@@ -300,16 +304,16 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
/* The caller provides a supported format, as guaranteed by
* icd->try_fmt_cap(), soc_camera_s_crop() and soc_camera_cropcap() */
if (ret >= 0)
- ret = reg_write(icd, MT9T031_COLUMN_START, left);
+ ret = reg_write(client, MT9T031_COLUMN_START, left);
if (ret >= 0)
- ret = reg_write(icd, MT9T031_ROW_START, top);
+ ret = reg_write(client, MT9T031_ROW_START, top);
if (ret >= 0)
- ret = reg_write(icd, MT9T031_WINDOW_WIDTH, width - 1);
+ ret = reg_write(client, MT9T031_WINDOW_WIDTH, width - 1);
if (ret >= 0)
- ret = reg_write(icd, MT9T031_WINDOW_HEIGHT,
+ ret = reg_write(client, MT9T031_WINDOW_HEIGHT,
height + icd->y_skip_top - 1);
if (ret >= 0 && mt9t031->autoexposure) {
- ret = set_shutter(icd, height + icd->y_skip_top + vblank);
+ ret = set_shutter(client, height + icd->y_skip_top + vblank);
if (ret >= 0) {
const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
const struct v4l2_queryctrl *qctrl =
@@ -324,7 +328,7 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
/* Re-enable register update, commit all changes */
if (ret >= 0)
- ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 1);
+ ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 1);
return ret < 0 ? ret : 0;
}
@@ -417,15 +421,15 @@ static int mt9t031_get_chip_id(struct soc_camera_device *icd,
static int mt9t031_get_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
return -EINVAL;
- if (reg->match.addr != mt9t031->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
- reg->val = reg_read(icd, reg->reg);
+ reg->val = reg_read(client, reg->reg);
if (reg->val > 0xffff)
return -EIO;
@@ -436,15 +440,15 @@ static int mt9t031_get_register(struct soc_camera_device *icd,
static int mt9t031_set_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
return -EINVAL;
- if (reg->match.addr != mt9t031->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
- if (reg_write(icd, reg->reg, reg->val) < 0)
+ if (reg_write(client, reg->reg, reg->val) < 0)
return -EIO;
return 0;
@@ -528,18 +532,19 @@ static struct soc_camera_ops mt9t031_ops = {
static int mt9t031_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
int data;
switch (ctrl->id) {
case V4L2_CID_VFLIP:
- data = reg_read(icd, MT9T031_READ_MODE_2);
+ data = reg_read(client, MT9T031_READ_MODE_2);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x8000);
break;
case V4L2_CID_HFLIP:
- data = reg_read(icd, MT9T031_READ_MODE_2);
+ data = reg_read(client, MT9T031_READ_MODE_2);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x4000);
@@ -553,6 +558,7 @@ static int mt9t031_get_control(struct soc_camera_device *icd, struct v4l2_contro
static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
const struct v4l2_queryctrl *qctrl;
int data;
@@ -565,17 +571,17 @@ static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_contro
switch (ctrl->id) {
case V4L2_CID_VFLIP:
if (ctrl->value)
- data = reg_set(icd, MT9T031_READ_MODE_2, 0x8000);
+ data = reg_set(client, MT9T031_READ_MODE_2, 0x8000);
else
- data = reg_clear(icd, MT9T031_READ_MODE_2, 0x8000);
+ data = reg_clear(client, MT9T031_READ_MODE_2, 0x8000);
if (data < 0)
return -EIO;
break;
case V4L2_CID_HFLIP:
if (ctrl->value)
- data = reg_set(icd, MT9T031_READ_MODE_2, 0x4000);
+ data = reg_set(client, MT9T031_READ_MODE_2, 0x4000);
else
- data = reg_clear(icd, MT9T031_READ_MODE_2, 0x4000);
+ data = reg_clear(client, MT9T031_READ_MODE_2, 0x4000);
if (data < 0)
return -EIO;
break;
@@ -589,7 +595,7 @@ static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_contro
data = ((ctrl->value - qctrl->minimum) * 8 + range / 2) / range;
dev_dbg(&icd->dev, "Setting gain %d\n", data);
- data = reg_write(icd, MT9T031_GLOBAL_GAIN, data);
+ data = reg_write(client, MT9T031_GLOBAL_GAIN, data);
if (data < 0)
return -EIO;
} else {
@@ -609,8 +615,8 @@ static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_contro
data = (((gain - 64 + 7) * 32) & 0xff00) | 0x60;
dev_dbg(&icd->dev, "Setting gain from 0x%x to 0x%x\n",
- reg_read(icd, MT9T031_GLOBAL_GAIN), data);
- data = reg_write(icd, MT9T031_GLOBAL_GAIN, data);
+ reg_read(client, MT9T031_GLOBAL_GAIN), data);
+ data = reg_write(client, MT9T031_GLOBAL_GAIN, data);
if (data < 0)
return -EIO;
}
@@ -628,10 +634,10 @@ static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_contro
range / 2) / range + 1;
u32 old;
- get_shutter(icd, &old);
+ get_shutter(client, &old);
dev_dbg(&icd->dev, "Setting shutter width from %u to %u\n",
old, shutter);
- if (set_shutter(icd, shutter) < 0)
+ if (set_shutter(client, shutter) < 0)
return -EIO;
icd->exposure = ctrl->value;
mt9t031->autoexposure = 0;
@@ -641,7 +647,7 @@ static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_contro
if (ctrl->value) {
const u16 vblank = MT9T031_VERTICAL_BLANK;
const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
- if (set_shutter(icd, icd->height +
+ if (set_shutter(client, icd->height +
icd->y_skip_top + vblank) < 0)
return -EIO;
qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
@@ -661,6 +667,7 @@ static int mt9t031_set_control(struct soc_camera_device *icd, struct v4l2_contro
* this wasn't our capture interface, so, we wait for the right one */
static int mt9t031_video_probe(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
s32 data;
int ret;
@@ -672,11 +679,11 @@ static int mt9t031_video_probe(struct soc_camera_device *icd)
return -ENODEV;
/* Enable the chip */
- data = reg_write(icd, MT9T031_CHIP_ENABLE, 1);
+ data = reg_write(client, MT9T031_CHIP_ENABLE, 1);
dev_dbg(&icd->dev, "write: %d\n", data);
/* Read out the chip version register */
- data = reg_read(icd, MT9T031_CHIP_VERSION);
+ data = reg_read(client, MT9T031_CHIP_VERSION);
switch (data) {
case 0x1621:
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index 4d3b4813c322..be20d312b1dc 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -91,51 +91,49 @@ struct mt9v022 {
u16 chip_control;
};
-static int reg_read(struct soc_camera_device *icd, const u8 reg)
+static int reg_read(struct i2c_client *client, const u8 reg)
{
- struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- struct i2c_client *client = mt9v022->client;
s32 data = i2c_smbus_read_word_data(client, reg);
return data < 0 ? data : swab16(data);
}
-static int reg_write(struct soc_camera_device *icd, const u8 reg,
+static int reg_write(struct i2c_client *client, const u8 reg,
const u16 data)
{
- struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- return i2c_smbus_write_word_data(mt9v022->client, reg, swab16(data));
+ return i2c_smbus_write_word_data(client, reg, swab16(data));
}
-static int reg_set(struct soc_camera_device *icd, const u8 reg,
+static int reg_set(struct i2c_client *client, const u8 reg,
const u16 data)
{
int ret;
- ret = reg_read(icd, reg);
+ ret = reg_read(client, reg);
if (ret < 0)
return ret;
- return reg_write(icd, reg, ret | data);
+ return reg_write(client, reg, ret | data);
}
-static int reg_clear(struct soc_camera_device *icd, const u8 reg,
+static int reg_clear(struct i2c_client *client, const u8 reg,
const u16 data)
{
int ret;
- ret = reg_read(icd, reg);
+ ret = reg_read(client, reg);
if (ret < 0)
return ret;
- return reg_write(icd, reg, ret & ~data);
+ return reg_write(client, reg, ret & ~data);
}
static int mt9v022_init(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
+ struct soc_camera_link *icl = client->dev.platform_data;
int ret;
if (icl->power) {
- ret = icl->power(&mt9v022->client->dev, 1);
+ ret = icl->power(&client->dev, 1);
if (ret < 0) {
dev_err(icd->vdev->parent,
"Platform failed to power-on the camera.\n");
@@ -148,27 +146,27 @@ static int mt9v022_init(struct soc_camera_device *icd)
* if available. Soft reset is done in video_probe().
*/
if (icl->reset)
- icl->reset(&mt9v022->client->dev);
+ icl->reset(&client->dev);
/* Almost the default mode: master, parallel, simultaneous, and an
* undocumented bit 0x200, which is present in table 7, but not in 8,
* plus snapshot mode to disable scan for now */
mt9v022->chip_control |= 0x10;
- ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
+ ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
if (!ret)
- ret = reg_write(icd, MT9V022_READ_MODE, 0x300);
+ ret = reg_write(client, MT9V022_READ_MODE, 0x300);
/* All defaults */
if (!ret)
/* AEC, AGC on */
- ret = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x3);
+ ret = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x3);
if (!ret)
- ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480);
+ ret = reg_write(client, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480);
if (!ret)
/* default - auto */
- ret = reg_clear(icd, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1);
+ ret = reg_clear(client, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1);
if (!ret)
- ret = reg_write(icd, MT9V022_DIGITAL_TEST_PATTERN, 0);
+ ret = reg_write(client, MT9V022_DIGITAL_TEST_PATTERN, 0);
return ret;
}
@@ -186,10 +184,11 @@ static int mt9v022_release(struct soc_camera_device *icd)
static int mt9v022_start_capture(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
/* Switch to master "normal" mode */
mt9v022->chip_control &= ~0x10;
- if (reg_write(icd, MT9V022_CHIP_CONTROL,
+ if (reg_write(client, MT9V022_CHIP_CONTROL,
mt9v022->chip_control) < 0)
return -EIO;
return 0;
@@ -197,10 +196,11 @@ static int mt9v022_start_capture(struct soc_camera_device *icd)
static int mt9v022_stop_capture(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
/* Switch to snapshot mode */
mt9v022->chip_control |= 0x10;
- if (reg_write(icd, MT9V022_CHIP_CONTROL,
+ if (reg_write(client, MT9V022_CHIP_CONTROL,
mt9v022->chip_control) < 0)
return -EIO;
return 0;
@@ -209,8 +209,9 @@ static int mt9v022_stop_capture(struct soc_camera_device *icd)
static int mt9v022_set_bus_param(struct soc_camera_device *icd,
unsigned long flags)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
+ struct soc_camera_link *icl = client->dev.platform_data;
unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK;
int ret;
u16 pixclk = 0;
@@ -243,14 +244,14 @@ static int mt9v022_set_bus_param(struct soc_camera_device *icd,
if (!(flags & SOCAM_VSYNC_ACTIVE_HIGH))
pixclk |= 0x2;
- ret = reg_write(icd, MT9V022_PIXCLK_FV_LV, pixclk);
+ ret = reg_write(client, MT9V022_PIXCLK_FV_LV, pixclk);
if (ret < 0)
return ret;
if (!(flags & SOCAM_MASTER))
mt9v022->chip_control &= ~0x8;
- ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
+ ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
if (ret < 0)
return ret;
@@ -282,35 +283,36 @@ static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd)
static int mt9v022_set_crop(struct soc_camera_device *icd,
struct v4l2_rect *rect)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
int ret;
/* Like in example app. Contradicts the datasheet though */
- ret = reg_read(icd, MT9V022_AEC_AGC_ENABLE);
+ ret = reg_read(client, MT9V022_AEC_AGC_ENABLE);
if (ret >= 0) {
if (ret & 1) /* Autoexposure */
- ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH,
+ ret = reg_write(client, MT9V022_MAX_TOTAL_SHUTTER_WIDTH,
rect->height + icd->y_skip_top + 43);
else
- ret = reg_write(icd, MT9V022_TOTAL_SHUTTER_WIDTH,
+ ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH,
rect->height + icd->y_skip_top + 43);
}
/* Setup frame format: defaults apart from width and height */
if (!ret)
- ret = reg_write(icd, MT9V022_COLUMN_START, rect->left);
+ ret = reg_write(client, MT9V022_COLUMN_START, rect->left);
if (!ret)
- ret = reg_write(icd, MT9V022_ROW_START, rect->top);
+ ret = reg_write(client, MT9V022_ROW_START, rect->top);
if (!ret)
/* Default 94, Phytec driver says:
* "width + horizontal blank >= 660" */
- ret = reg_write(icd, MT9V022_HORIZONTAL_BLANKING,
+ ret = reg_write(client, MT9V022_HORIZONTAL_BLANKING,
rect->width > 660 - 43 ? 43 :
660 - rect->width);
if (!ret)
- ret = reg_write(icd, MT9V022_VERTICAL_BLANKING, 45);
+ ret = reg_write(client, MT9V022_VERTICAL_BLANKING, 45);
if (!ret)
- ret = reg_write(icd, MT9V022_WINDOW_WIDTH, rect->width);
+ ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect->width);
if (!ret)
- ret = reg_write(icd, MT9V022_WINDOW_HEIGHT,
+ ret = reg_write(client, MT9V022_WINDOW_HEIGHT,
rect->height + icd->y_skip_top);
if (ret < 0)
@@ -396,16 +398,16 @@ static int mt9v022_get_chip_id(struct soc_camera_device *icd,
static int mt9v022_get_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
return -EINVAL;
- if (reg->match.addr != mt9v022->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
reg->size = 2;
- reg->val = reg_read(icd, reg->reg);
+ reg->val = reg_read(client, reg->reg);
if (reg->val > 0xffff)
return -EIO;
@@ -416,15 +418,15 @@ static int mt9v022_get_register(struct soc_camera_device *icd,
static int mt9v022_set_register(struct soc_camera_device *icd,
struct v4l2_dbg_register *reg)
{
- struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
+ struct i2c_client *client = to_i2c_client(icd->control);
if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
return -EINVAL;
- if (reg->match.addr != mt9v022->client->addr)
+ if (reg->match.addr != client->addr)
return -ENODEV;
- if (reg_write(icd, reg->reg, reg->val) < 0)
+ if (reg_write(client, reg->reg, reg->val) < 0)
return -EIO;
return 0;
@@ -517,29 +519,30 @@ static struct soc_camera_ops mt9v022_ops = {
static int mt9v022_get_control(struct soc_camera_device *icd,
struct v4l2_control *ctrl)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
int data;
switch (ctrl->id) {
case V4L2_CID_VFLIP:
- data = reg_read(icd, MT9V022_READ_MODE);
+ data = reg_read(client, MT9V022_READ_MODE);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x10);
break;
case V4L2_CID_HFLIP:
- data = reg_read(icd, MT9V022_READ_MODE);
+ data = reg_read(client, MT9V022_READ_MODE);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x20);
break;
case V4L2_CID_EXPOSURE_AUTO:
- data = reg_read(icd, MT9V022_AEC_AGC_ENABLE);
+ data = reg_read(client, MT9V022_AEC_AGC_ENABLE);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x1);
break;
case V4L2_CID_AUTOGAIN:
- data = reg_read(icd, MT9V022_AEC_AGC_ENABLE);
+ data = reg_read(client, MT9V022_AEC_AGC_ENABLE);
if (data < 0)
return -EIO;
ctrl->value = !!(data & 0x2);
@@ -552,6 +555,7 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
struct v4l2_control *ctrl)
{
int data;
+ struct i2c_client *client = to_i2c_client(icd->control);
const struct v4l2_queryctrl *qctrl;
qctrl = soc_camera_find_qctrl(&mt9v022_ops, ctrl->id);
@@ -562,17 +566,17 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
switch (ctrl->id) {
case V4L2_CID_VFLIP:
if (ctrl->value)
- data = reg_set(icd, MT9V022_READ_MODE, 0x10);
+ data = reg_set(client, MT9V022_READ_MODE, 0x10);
else
- data = reg_clear(icd, MT9V022_READ_MODE, 0x10);
+ data = reg_clear(client, MT9V022_READ_MODE, 0x10);
if (data < 0)
return -EIO;
break;
case V4L2_CID_HFLIP:
if (ctrl->value)
- data = reg_set(icd, MT9V022_READ_MODE, 0x20);
+ data = reg_set(client, MT9V022_READ_MODE, 0x20);
else
- data = reg_clear(icd, MT9V022_READ_MODE, 0x20);
+ data = reg_clear(client, MT9V022_READ_MODE, 0x20);
if (data < 0)
return -EIO;
break;
@@ -593,12 +597,12 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
/* The user wants to set gain manually, hope, she
* knows, what she's doing... Switch AGC off. */
- if (reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x2) < 0)
+ if (reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x2) < 0)
return -EIO;
dev_info(&icd->dev, "Setting gain from %d to %lu\n",
- reg_read(icd, MT9V022_ANALOG_GAIN), gain);
- if (reg_write(icd, MT9V022_ANALOG_GAIN, gain) < 0)
+ reg_read(client, MT9V022_ANALOG_GAIN), gain);
+ if (reg_write(client, MT9V022_ANALOG_GAIN, gain) < 0)
return -EIO;
icd->gain = ctrl->value;
}
@@ -614,13 +618,13 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
/* The user wants to set shutter width manually, hope,
* she knows, what she's doing... Switch AEC off. */
- if (reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x1) < 0)
+ if (reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x1) < 0)
return -EIO;
dev_dbg(&icd->dev, "Shutter width from %d to %lu\n",
- reg_read(icd, MT9V022_TOTAL_SHUTTER_WIDTH),
+ reg_read(client, MT9V022_TOTAL_SHUTTER_WIDTH),
shutter);
- if (reg_write(icd, MT9V022_TOTAL_SHUTTER_WIDTH,
+ if (reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH,
shutter) < 0)
return -EIO;
icd->exposure = ctrl->value;
@@ -628,17 +632,17 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
break;
case V4L2_CID_AUTOGAIN:
if (ctrl->value)
- data = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x2);
+ data = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x2);
else
- data = reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x2);
+ data = reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x2);
if (data < 0)
return -EIO;
break;
case V4L2_CID_EXPOSURE_AUTO:
if (ctrl->value)
- data = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x1);
+ data = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x1);
else
- data = reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x1);
+ data = reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x1);
if (data < 0)
return -EIO;
break;
@@ -650,8 +654,9 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
* this wasn't our capture interface, so, we wait for the right one */
static int mt9v022_video_probe(struct soc_camera_device *icd)
{
+ struct i2c_client *client = to_i2c_client(icd->control);
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
+ struct soc_camera_link *icl = client->dev.platform_data;
s32 data;
int ret;
unsigned long flags;
@@ -661,7 +666,7 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
return -ENODEV;
/* Read out the chip version register */
- data = reg_read(icd, MT9V022_CHIP_VERSION);
+ data = reg_read(client, MT9V022_CHIP_VERSION);
/* must be 0x1311 or 0x1313 */
if (data != 0x1311 && data != 0x1313) {
@@ -672,12 +677,12 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
}
/* Soft reset */
- ret = reg_write(icd, MT9V022_RESET, 1);
+ ret = reg_write(client, MT9V022_RESET, 1);
if (ret < 0)
goto ei2c;
/* 15 clock cycles */
udelay(200);
- if (reg_read(icd, MT9V022_RESET)) {
+ if (reg_read(client, MT9V022_RESET)) {
dev_err(&icd->dev, "Resetting MT9V022 failed!\n");
goto ei2c;
}
@@ -685,11 +690,11 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
/* Set monochrome or colour sensor type */
if (sensor_type && (!strcmp("colour", sensor_type) ||
!strcmp("color", sensor_type))) {
- ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
+ ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
icd->formats = mt9v022_colour_formats;
} else {
- ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
+ ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 0x11);
mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
icd->formats = mt9v022_monochrome_formats;
}
@@ -735,10 +740,13 @@ ei2c:
static void mt9v022_video_remove(struct soc_camera_device *icd)
{
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
+ struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9v022->client->addr,
icd->dev.parent, icd->vdev);
soc_camera_video_stop(icd);
+ if (icl->free_bus)
+ icl->free_bus(icl);
}
static int mt9v022_probe(struct i2c_client *client,
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c
index 86fab56c5a20..2d075205bdfe 100644
--- a/drivers/media/video/mx1_camera.c
+++ b/drivers/media/video/mx1_camera.c
@@ -102,10 +102,10 @@ struct mx1_buffer {
* Interface. If anyone ever builds hardware to enable more than
* one camera, they will have to modify this driver too */
struct mx1_camera_dev {
+ struct soc_camera_host soc_host;
struct soc_camera_device *icd;
struct mx1_camera_pdata *pdata;
struct mx1_buffer *active;
- struct device *dev;
struct resource *res;
struct clk *clk;
struct list_head capture;
@@ -219,7 +219,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
int ret;
if (unlikely(!pcdev->active)) {
- dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n");
+ dev_err(pcdev->soc_host.dev, "DMA End IRQ with no active buffer\n");
return -EFAULT;
}
@@ -229,7 +229,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
vbuf->size, pcdev->res->start +
CSIRXR, DMA_MODE_READ);
if (unlikely(ret))
- dev_err(pcdev->dev, "Failed to setup DMA sg list\n");
+ dev_err(pcdev->soc_host.dev, "Failed to setup DMA sg list\n");
return ret;
}
@@ -338,14 +338,14 @@ static void mx1_camera_dma_irq(int channel, void *data)
imx_dma_disable(channel);
if (unlikely(!pcdev->active)) {
- dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n");
+ dev_err(pcdev->soc_host.dev, "DMA End IRQ with no active buffer\n");
goto out;
}
vb = &pcdev->active->vb;
buf = container_of(vb, struct mx1_buffer, vb);
WARN_ON(buf->inwork || list_empty(&vb->queue));
- dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
+ dev_dbg(pcdev->soc_host.dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);
mx1_camera_wakeup(pcdev, vb, buf);
@@ -366,7 +366,7 @@ static void mx1_camera_init_videobuf(struct videobuf_queue *q,
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct mx1_camera_dev *pcdev = ici->priv;
- videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, pcdev->dev,
+ videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, ici->dev,
&pcdev->lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_NONE,
@@ -385,7 +385,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
* they get a nice Oops */
div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
- dev_dbg(pcdev->dev, "System clock %lukHz, target freq %dkHz, "
+ dev_dbg(pcdev->soc_host.dev, "System clock %lukHz, target freq %dkHz, "
"divisor %lu\n", lcdclk / 1000, mclk / 1000, div);
return div;
@@ -395,7 +395,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
{
unsigned int csicr1 = CSICR1_EN;
- dev_dbg(pcdev->dev, "Activate device\n");
+ dev_dbg(pcdev->soc_host.dev, "Activate device\n");
clk_enable(pcdev->clk);
@@ -411,7 +411,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
{
- dev_dbg(pcdev->dev, "Deactivate device\n");
+ dev_dbg(pcdev->soc_host.dev, "Deactivate device\n");
/* Disable all CSI interface */
__raw_writel(0x00, pcdev->base + CSICR1);
@@ -550,7 +550,7 @@ static int mx1_camera_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat);
+ dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat);
return -EINVAL;
}
@@ -633,12 +633,6 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = {
.querycap = mx1_camera_querycap,
};
-/* Should be allocated dynamically too, but we have only one. */
-static struct soc_camera_host mx1_soc_camera_host = {
- .drv_name = DRIVER_NAME,
- .ops = &mx1_soc_camera_host_ops,
-};
-
static struct fiq_handler fh = {
.name = "csi_sof"
};
@@ -673,7 +667,6 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
goto exit_put_clk;
}
- dev_set_drvdata(&pdev->dev, pcdev);
pcdev->res = res;
pcdev->clk = clk;
@@ -707,16 +700,15 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
}
pcdev->irq = irq;
pcdev->base = base;
- pcdev->dev = &pdev->dev;
/* request dma */
pcdev->dma_chan = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_HIGH);
if (pcdev->dma_chan < 0) {
- dev_err(pcdev->dev, "Can't request DMA for MX1 CSI\n");
+ dev_err(&pdev->dev, "Can't request DMA for MX1 CSI\n");
err = -EBUSY;
goto exit_iounmap;
}
- dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chan);
+ dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chan);
imx_dma_setup_handlers(pcdev->dma_chan, mx1_camera_dma_irq, NULL,
pcdev);
@@ -729,7 +721,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
/* request irq */
err = claim_fiq(&fh);
if (err) {
- dev_err(pcdev->dev, "Camera interrupt register failed \n");
+ dev_err(&pdev->dev, "Camera interrupt register failed \n");
goto exit_free_dma;
}
@@ -746,10 +738,12 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
mxc_set_irq_fiq(irq, 1);
enable_fiq(irq);
- mx1_soc_camera_host.priv = pcdev;
- mx1_soc_camera_host.dev.parent = &pdev->dev;
- mx1_soc_camera_host.nr = pdev->id;
- err = soc_camera_host_register(&mx1_soc_camera_host);
+ pcdev->soc_host.drv_name = DRIVER_NAME;
+ pcdev->soc_host.ops = &mx1_soc_camera_host_ops;
+ pcdev->soc_host.priv = pcdev;
+ pcdev->soc_host.dev = &pdev->dev;
+ pcdev->soc_host.nr = pdev->id;
+ err = soc_camera_host_register(&pcdev->soc_host);
if (err)
goto exit_free_irq;
@@ -777,7 +771,9 @@ exit:
static int __exit mx1_camera_remove(struct platform_device *pdev)
{
- struct mx1_camera_dev *pcdev = platform_get_drvdata(pdev);
+ struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
+ struct mx1_camera_dev *pcdev = container_of(soc_host,
+ struct mx1_camera_dev, soc_host);
struct resource *res;
imx_dma_free(pcdev->dma_chan);
@@ -787,7 +783,7 @@ static int __exit mx1_camera_remove(struct platform_device *pdev)
clk_put(pcdev->clk);
- soc_camera_host_unregister(&mx1_soc_camera_host);
+ soc_camera_host_unregister(soc_host);
iounmap(pcdev->base);
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index 2d0781118eb0..4d47eeb14452 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -87,7 +87,6 @@ struct mx3_camera_buffer {
* @soc_host: embedded soc_host object
*/
struct mx3_camera_dev {
- struct device *dev;
/*
* i.MX3x is only supposed to handle one camera on its Camera Sensor
* Interface. If anyone ever builds hardware to enable more than one
@@ -431,7 +430,7 @@ static void mx3_camera_init_videobuf(struct videobuf_queue *q,
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct mx3_camera_dev *mx3_cam = ici->priv;
- videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, mx3_cam->dev,
+ videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, ici->dev,
&mx3_cam->lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_NONE,
@@ -599,7 +598,8 @@ static int test_platform_param(struct mx3_camera_dev *mx3_cam,
*flags |= SOCAM_DATAWIDTH_4;
break;
default:
- dev_info(mx3_cam->dev, "Unsupported bus width %d\n", buswidth);
+ dev_info(mx3_cam->soc_host.dev, "Unsupported bus width %d\n",
+ buswidth);
return -EINVAL;
}
@@ -614,7 +614,7 @@ static int mx3_camera_try_bus_param(struct soc_camera_device *icd,
unsigned long bus_flags, camera_flags;
int ret = test_platform_param(mx3_cam, depth, &bus_flags);
- dev_dbg(&ici->dev, "requested bus width %d bit: %d\n", depth, ret);
+ dev_dbg(ici->dev, "requested bus width %d bit: %d\n", depth, ret);
if (ret < 0)
return ret;
@@ -637,7 +637,7 @@ static bool chan_filter(struct dma_chan *chan, void *arg)
if (!rq)
return false;
- pdata = rq->mx3_cam->dev->platform_data;
+ pdata = rq->mx3_cam->soc_host.dev->platform_data;
return rq->id == chan->chan_id &&
pdata->dma_dev == chan->device->dev;
@@ -697,7 +697,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
- dev_dbg(&ici->dev, "Providing format %s using %s\n",
+ dev_dbg(ici->dev, "Providing format %s using %s\n",
mx3_camera_formats[0].name,
icd->formats[idx].name);
}
@@ -709,7 +709,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
- dev_dbg(&ici->dev, "Providing format %s using %s\n",
+ dev_dbg(ici->dev, "Providing format %s using %s\n",
mx3_camera_formats[0].name,
icd->formats[idx].name);
}
@@ -722,7 +722,7 @@ passthrough:
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
- dev_dbg(&ici->dev,
+ dev_dbg(ici->dev,
"Providing format %s in pass-through mode\n",
icd->formats[idx].name);
}
@@ -829,7 +829,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat);
+ dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat);
return -EINVAL;
}
@@ -866,7 +866,7 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (pixfmt && !xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
+ dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}
@@ -933,11 +933,11 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
+ dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}
- dev_dbg(&ici->dev, "requested bus width %d bit: %d\n",
+ dev_dbg(ici->dev, "requested bus width %d bit: %d\n",
icd->buswidth, ret);
if (ret < 0)
@@ -947,7 +947,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
if (!common_flags) {
- dev_dbg(&ici->dev, "no common flags: camera %lx, host %lx\n",
+ dev_dbg(ici->dev, "no common flags: camera %lx, host %lx\n",
camera_flags, bus_flags);
return -EINVAL;
}
@@ -1054,7 +1054,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF);
- dev_dbg(&ici->dev, "Set SENS_CONF to %x\n", sens_conf | dw);
+ dev_dbg(ici->dev, "Set SENS_CONF to %x\n", sens_conf | dw);
return 0;
}
@@ -1102,8 +1102,6 @@ static int mx3_camera_probe(struct platform_device *pdev)
goto eclkget;
}
- dev_set_drvdata(&pdev->dev, mx3_cam);
-
mx3_cam->pdata = pdev->dev.platform_data;
mx3_cam->platform_flags = mx3_cam->pdata->flags;
if (!(mx3_cam->platform_flags & (MX3_CAMERA_DATAWIDTH_4 |
@@ -1135,14 +1133,14 @@ static int mx3_camera_probe(struct platform_device *pdev)
}
mx3_cam->base = base;
- mx3_cam->dev = &pdev->dev;
soc_host = &mx3_cam->soc_host;
soc_host->drv_name = MX3_CAM_DRV_NAME;
soc_host->ops = &mx3_soc_camera_host_ops;
soc_host->priv = mx3_cam;
- soc_host->dev.parent = &pdev->dev;
+ soc_host->dev = &pdev->dev;
soc_host->nr = pdev->id;
+
err = soc_camera_host_register(soc_host);
if (err)
goto ecamhostreg;
@@ -1165,11 +1163,13 @@ egetres:
static int __devexit mx3_camera_remove(struct platform_device *pdev)
{
- struct mx3_camera_dev *mx3_cam = platform_get_drvdata(pdev);
+ struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
+ struct mx3_camera_dev *mx3_cam = container_of(soc_host,
+ struct mx3_camera_dev, soc_host);
clk_put(mx3_cam->clk);
- soc_camera_host_unregister(&mx3_cam->soc_host);
+ soc_camera_host_unregister(soc_host);
iounmap(mx3_cam->base);
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 3be5a71bdac2..35890e8b2431 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -453,7 +453,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{
DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index));
- if (i->index < 0 || i->index >= MXB_INPUTS)
+ if (i->index >= MXB_INPUTS)
return -EINVAL;
memcpy(i, &mxb_inputs[i->index], sizeof(struct v4l2_input));
return 0;
@@ -616,7 +616,7 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a)
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct mxb *mxb = (struct mxb *)dev->ext_priv;
- if (a->index < 0 || a->index > MXB_INPUTS) {
+ if (a->index > MXB_INPUTS) {
DEB_D(("VIDIOC_G_AUDIO %d out of range.\n", a->index));
return -EINVAL;
}
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
index 1cb6a260e8b0..341af4355c0c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
@@ -71,6 +71,7 @@ static const struct pvr2_device_desc pvr2_device_29xxx = {
.flag_has_svideo = !0,
.signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
.led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
+ .ir_scheme = PVR2_IR_SCHEME_29XXX,
};
@@ -284,6 +285,9 @@ static struct tda10048_config hauppauge_tda10048_config = {
.output_mode = TDA10048_PARALLEL_OUTPUT,
.fwbulkwritelen = TDA10048_BULKWRITE_50,
.inversion = TDA10048_INVERSION_ON,
+ .if_freq_khz = TDA10048_IF_4300,
+ .clk_freq_khz = TDA10048_CLK_16000,
+ .disable_gate_access = 1,
};
static struct tda829x_config tda829x_no_probe = {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.h b/drivers/media/video/pvrusb2/pvrusb2-devattr.h
index 3e553389cbc3..ea04ecf8aa39 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.h
@@ -69,6 +69,7 @@ struct pvr2_string_table {
#define PVR2_ROUTING_SCHEME_HAUPPAUGE 0
#define PVR2_ROUTING_SCHEME_GOTVIEW 1
#define PVR2_ROUTING_SCHEME_ONAIR 2
+#define PVR2_ROUTING_SCHEME_AV400 3
#define PVR2_DIGITAL_SCHEME_NONE 0
#define PVR2_DIGITAL_SCHEME_HAUPPAUGE 1
@@ -78,8 +79,10 @@ struct pvr2_string_table {
#define PVR2_LED_SCHEME_HAUPPAUGE 1
#define PVR2_IR_SCHEME_NONE 0
-#define PVR2_IR_SCHEME_24XXX 1
-#define PVR2_IR_SCHEME_ZILOG 2
+#define PVR2_IR_SCHEME_24XXX 1 /* FX2-controlled IR */
+#define PVR2_IR_SCHEME_ZILOG 2 /* HVR-1950 style (must be taken out of reset) */
+#define PVR2_IR_SCHEME_24XXX_MCE 3 /* 24xxx MCE device */
+#define PVR2_IR_SCHEME_29XXX 4 /* Original 29xxx device */
/* This describes a particular hardware type (except for the USB device ID
which must live in a separate structure due to environmental
@@ -162,19 +165,9 @@ struct pvr2_device_desc {
ensure that it is found. */
unsigned int flag_has_wm8775:1;
- /* Indicate any specialized IR scheme that might need to be
- supported by this driver. If not set, then it is assumed that
- IR can work without help from the driver (which is frequently
- the case). This is otherwise set to one of
- PVR2_IR_SCHEME_xxxx. For "xxxx", the value "24XXX" indicates a
- Hauppauge 24xxx class device which has an FPGA-hosted IR
- receiver that can only be reached via FX2 command codes. In
- that case the pvrusb2 driver will emulate the behavior of the
- older 29xxx device's IR receiver (a "virtual" I2C chip) in terms
- of those command codes. For the value "ZILOG", we're dealing
- with an IR chip that must be taken out of reset via another FX2
- command code (which is the case for HVR-1950 devices). */
- unsigned int ir_scheme:2;
+ /* Indicate IR scheme of hardware. If not set, then it is assumed
+ that IR can work without any help from the driver. */
+ unsigned int ir_scheme:3;
/* These bits define which kinds of sources the device can handle.
Note: Digital tuner presence is inferred by the
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 5d75eb5211b1..5b152ff20bd0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -200,6 +200,9 @@ struct pvr2_hdw {
int i2c_cx25840_hack_state;
int i2c_linked;
+ /* IR related */
+ unsigned int ir_scheme_active; /* IR scheme as seen from the outside */
+
/* Frequency table */
unsigned int freqTable[FREQTABLE_SIZE];
unsigned int freqProgSlot;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index add3395d3248..0c745b142fb7 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -142,6 +142,15 @@ static const unsigned char *module_i2c_addresses[] = {
};
+static const char *ir_scheme_names[] = {
+ [PVR2_IR_SCHEME_NONE] = "none",
+ [PVR2_IR_SCHEME_29XXX] = "29xxx",
+ [PVR2_IR_SCHEME_24XXX] = "24xxx (29xxx emulation)",
+ [PVR2_IR_SCHEME_24XXX_MCE] = "24xxx (MCE device)",
+ [PVR2_IR_SCHEME_ZILOG] = "Zilog",
+};
+
+
/* Define the list of additional controls we'll dynamically construct based
on query of the cx2341x module. */
struct pvr2_mpeg_ids {
@@ -2170,7 +2179,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
}
/* Take the IR chip out of reset, if appropriate */
- if (hdw->hdw_desc->ir_scheme == PVR2_IR_SCHEME_ZILOG) {
+ if (hdw->ir_scheme_active == PVR2_IR_SCHEME_ZILOG) {
pvr2_issue_simple_cmd(hdw,
FX2CMD_HCW_ZILOG_RESET |
(1 << 8) |
@@ -2451,6 +2460,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
GFP_KERNEL);
if (!hdw->controls) goto fail;
hdw->hdw_desc = hdw_desc;
+ hdw->ir_scheme_active = hdw->hdw_desc->ir_scheme;
for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx;
cptr->hdw = hdw;
@@ -4809,6 +4819,12 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which,
stats.buffers_processed,
stats.buffers_failed);
}
+ case 6: {
+ unsigned int id = hdw->ir_scheme_active;
+ return scnprintf(buf, acnt, "ir scheme: id=%d %s", id,
+ (id >= ARRAY_SIZE(ir_scheme_names) ?
+ "?" : ir_scheme_names[id]));
+ }
default: break;
}
return 0;
@@ -4825,65 +4841,35 @@ static unsigned int pvr2_hdw_report_clients(struct pvr2_hdw *hdw,
unsigned int tcnt = 0;
unsigned int ccnt;
struct i2c_client *client;
- struct list_head *item;
- void *cd;
const char *p;
unsigned int id;
- ccnt = scnprintf(buf, acnt, "Associated v4l2-subdev drivers:");
+ ccnt = scnprintf(buf, acnt, "Associated v4l2-subdev drivers and I2C clients:\n");
tcnt += ccnt;
v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) {
id = sd->grp_id;
p = NULL;
if (id < ARRAY_SIZE(module_names)) p = module_names[id];
if (p) {
- ccnt = scnprintf(buf + tcnt, acnt - tcnt, " %s", p);
+ ccnt = scnprintf(buf + tcnt, acnt - tcnt, " %s:", p);
tcnt += ccnt;
} else {
ccnt = scnprintf(buf + tcnt, acnt - tcnt,
- " (unknown id=%u)", id);
+ " (unknown id=%u):", id);
tcnt += ccnt;
}
- }
- ccnt = scnprintf(buf + tcnt, acnt - tcnt, "\n");
- tcnt += ccnt;
-
- ccnt = scnprintf(buf + tcnt, acnt - tcnt, "I2C clients:\n");
- tcnt += ccnt;
-
- mutex_lock(&hdw->i2c_adap.clist_lock);
- list_for_each(item, &hdw->i2c_adap.clients) {
- client = list_entry(item, struct i2c_client, list);
- ccnt = scnprintf(buf + tcnt, acnt - tcnt,
- " %s: i2c=%02x", client->name, client->addr);
- tcnt += ccnt;
- cd = i2c_get_clientdata(client);
- v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) {
- if (cd == sd) {
- id = sd->grp_id;
- p = NULL;
- if (id < ARRAY_SIZE(module_names)) {
- p = module_names[id];
- }
- if (p) {
- ccnt = scnprintf(buf + tcnt,
- acnt - tcnt,
- " subdev=%s", p);
- tcnt += ccnt;
- } else {
- ccnt = scnprintf(buf + tcnt,
- acnt - tcnt,
- " subdev= id %u)",
- id);
- tcnt += ccnt;
- }
- break;
- }
+ client = v4l2_get_subdevdata(sd);
+ if (client) {
+ ccnt = scnprintf(buf + tcnt, acnt - tcnt,
+ " %s @ %02x\n", client->name,
+ client->addr);
+ tcnt += ccnt;
+ } else {
+ ccnt = scnprintf(buf + tcnt, acnt - tcnt,
+ " no i2c client\n");
+ tcnt += ccnt;
}
- ccnt = scnprintf(buf + tcnt, acnt - tcnt, "\n");
- tcnt += ccnt;
}
- mutex_unlock(&hdw->i2c_adap.clist_lock);
return tcnt;
}
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 9af282f9e765..b88a61df1771 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -42,6 +42,18 @@ static int ir_mode[PVR_NUM] = { [0 ... PVR_NUM-1] = 1 };
module_param_array(ir_mode, int, NULL, 0444);
MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR");
+static int pvr2_disable_ir_video = 1;
+module_param_named(disable_autoload_ir_video, pvr2_disable_ir_video,
+ int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(disable_autoload_ir_video,
+ "1=do not try to autoload ir_video IR receiver");
+
+/* Mapping of IR schemes to known I2C addresses - if any */
+static const unsigned char ir_video_addresses[] = {
+ [PVR2_IR_SCHEME_29XXX] = 0x18,
+ [PVR2_IR_SCHEME_24XXX] = 0x18,
+};
+
static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
u8 i2c_addr, /* I2C address we're talking to */
u8 *data, /* Data to write */
@@ -559,6 +571,31 @@ static void do_i2c_scan(struct pvr2_hdw *hdw)
printk(KERN_INFO "%s: i2c scan done.\n", hdw->name);
}
+static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
+{
+ struct i2c_board_info info;
+ unsigned char addr = 0;
+ if (pvr2_disable_ir_video) {
+ pvr2_trace(PVR2_TRACE_INFO,
+ "Automatic binding of ir_video has been disabled.");
+ return;
+ }
+ if (hdw->ir_scheme_active < ARRAY_SIZE(ir_video_addresses)) {
+ addr = ir_video_addresses[hdw->ir_scheme_active];
+ }
+ if (!addr) {
+ /* The device either doesn't support I2C-based IR or we
+ don't know (yet) how to operate IR on the device. */
+ return;
+ }
+ pvr2_trace(PVR2_TRACE_INFO,
+ "Binding ir_video to i2c address 0x%02x.", addr);
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+ info.addr = addr;
+ i2c_new_device(&hdw->i2c_adap, &info);
+}
+
void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
{
unsigned int idx;
@@ -574,7 +611,9 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
printk(KERN_INFO "%s: IR disabled\n",hdw->name);
hdw->i2c_func[0x18] = i2c_black_hole;
} else if (ir_mode[hdw->unit_number] == 1) {
- if (hdw->hdw_desc->ir_scheme == PVR2_IR_SCHEME_24XXX) {
+ if (hdw->ir_scheme_active == PVR2_IR_SCHEME_24XXX) {
+ /* Set up translation so that our IR looks like a
+ 29xxx device */
hdw->i2c_func[0x18] = i2c_24xxx_ir;
}
}
@@ -597,15 +636,23 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
i2c_add_adapter(&hdw->i2c_adap);
if (hdw->i2c_func[0x18] == i2c_24xxx_ir) {
/* Probe for a different type of IR receiver on this
- device. If present, disable the emulated IR receiver. */
+ device. This is really the only way to differentiate
+ older 24xxx devices from 24xxx variants that include an
+ IR blaster. If the IR blaster is present, the IR
+ receiver is part of that chip and thus we must disable
+ the emulated IR receiver. */
if (do_i2c_probe(hdw, 0x71)) {
pvr2_trace(PVR2_TRACE_INFO,
"Device has newer IR hardware;"
" disabling unneeded virtual IR device");
hdw->i2c_func[0x18] = NULL;
+ /* Remember that this is a different device... */
+ hdw->ir_scheme_active = PVR2_IR_SCHEME_24XXX_MCE;
}
}
if (i2c_scan) do_i2c_scan(hdw);
+
+ pvr2_i2c_register_ir(hdw);
}
void pvr2_i2c_core_done(struct pvr2_hdw *hdw)
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 299c1cbc3832..6c23456e0bda 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -539,7 +539,7 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
&sfp->attr_unit_number);
}
pvr2_sysfs_trace("Destroying class_dev id=%p",sfp->class_dev);
- sfp->class_dev->driver_data = NULL;
+ dev_set_drvdata(sfp->class_dev, NULL);
device_unregister(sfp->class_dev);
sfp->class_dev = NULL;
}
@@ -549,7 +549,7 @@ static ssize_t v4l_minor_number_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%d\n",
pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
@@ -561,7 +561,7 @@ static ssize_t bus_info_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%s\n",
pvr2_hdw_get_bus_info(sfp->channel.hdw));
@@ -572,7 +572,7 @@ static ssize_t hdw_name_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%s\n",
pvr2_hdw_get_type(sfp->channel.hdw));
@@ -583,7 +583,7 @@ static ssize_t hdw_desc_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%s\n",
pvr2_hdw_get_desc(sfp->channel.hdw));
@@ -595,7 +595,7 @@ static ssize_t v4l_radio_minor_number_show(struct device *class_dev,
char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%d\n",
pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
@@ -607,7 +607,7 @@ static ssize_t unit_number_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%d\n",
pvr2_hdw_get_unit_number(sfp->channel.hdw));
@@ -635,7 +635,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
class_dev->parent = &usb_dev->dev;
sfp->class_dev = class_dev;
- class_dev->driver_data = sfp;
+ dev_set_drvdata(class_dev, sfp);
ret = device_register(class_dev);
if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
@@ -792,7 +792,7 @@ static ssize_t debuginfo_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
pvr2_hdw_trigger_module_log(sfp->channel.hdw);
return pvr2_debugifc_print_info(sfp->channel.hdw,buf,PAGE_SIZE);
@@ -803,7 +803,7 @@ static ssize_t debugcmd_show(struct device *class_dev,
struct device_attribute *attr, char *buf)
{
struct pvr2_sysfs *sfp;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
return pvr2_debugifc_print_status(sfp->channel.hdw,buf,PAGE_SIZE);
}
@@ -816,7 +816,7 @@ static ssize_t debugcmd_store(struct device *class_dev,
struct pvr2_sysfs *sfp;
int ret;
- sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+ sfp = dev_get_drvdata(class_dev);
if (!sfp) return -EINVAL;
ret = pvr2_debugifc_docmd(sfp->channel.hdw,buf,count);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 9e0f2b07b93b..2d8825e5b1be 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -90,7 +90,7 @@ static struct v4l2_capability pvr_capability ={
.driver = "pvrusb2",
.card = "Hauppauge WinTV pvr-usb2",
.bus_info = "usb",
- .version = KERNEL_VERSION(0,8,0),
+ .version = KERNEL_VERSION(0, 9, 0),
.capabilities = (V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_TUNER | V4L2_CAP_AUDIO | V4L2_CAP_RADIO |
V4L2_CAP_READWRITE),
@@ -267,7 +267,7 @@ static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
memset(&tmp,0,sizeof(tmp));
tmp.index = vi->index;
ret = 0;
- if ((vi->index < 0) || (vi->index >= fh->input_cnt)) {
+ if (vi->index >= fh->input_cnt) {
ret = -EINVAL;
break;
}
@@ -331,7 +331,7 @@ static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
case VIDIOC_S_INPUT:
{
struct v4l2_input *vi = (struct v4l2_input *)arg;
- if ((vi->index < 0) || (vi->index >= fh->input_cnt)) {
+ if (vi->index >= fh->input_cnt) {
ret = -ERANGE;
break;
}
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index bc0a464295c5..2876ce084510 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -1107,7 +1107,7 @@ long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg)
return -EINVAL;
if (buf->memory != V4L2_MEMORY_MMAP)
return -EINVAL;
- if (buf->index < 0 || buf->index >= pwc_mbufs)
+ if (buf->index >= pwc_mbufs)
return -EINVAL;
buf->flags |= V4L2_BUF_FLAG_QUEUED;
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index c639845460ff..2da5eef19b70 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -202,7 +202,7 @@ struct pxa_buffer {
};
struct pxa_camera_dev {
- struct device *dev;
+ struct soc_camera_host soc_host;
/* PXA27x is only supposed to handle one camera on its Quick Capture
* interface. If anyone ever builds hardware to enable more than
* one camera, they will have to modify this driver too */
@@ -261,7 +261,6 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
{
struct soc_camera_device *icd = vq->priv_data;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
- struct pxa_camera_dev *pcdev = ici->priv;
struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb);
int i;
@@ -278,7 +277,7 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
for (i = 0; i < ARRAY_SIZE(buf->dmas); i++) {
if (buf->dmas[i].sg_cpu)
- dma_free_coherent(pcdev->dev, buf->dmas[i].sg_size,
+ dma_free_coherent(ici->dev, buf->dmas[i].sg_size,
buf->dmas[i].sg_cpu,
buf->dmas[i].sg_dma);
buf->dmas[i].sg_cpu = NULL;
@@ -338,14 +337,14 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
int dma_len = 0, xfer_len = 0;
if (pxa_dma->sg_cpu)
- dma_free_coherent(pcdev->dev, pxa_dma->sg_size,
+ dma_free_coherent(pcdev->soc_host.dev, pxa_dma->sg_size,
pxa_dma->sg_cpu, pxa_dma->sg_dma);
sglen = calculate_dma_sglen(*sg_first, dma->sglen,
*sg_first_ofs, size);
pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc);
- pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->dev, pxa_dma->sg_size,
+ pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->soc_host.dev, pxa_dma->sg_size,
&pxa_dma->sg_dma, GFP_KERNEL);
if (!pxa_dma->sg_cpu)
return -ENOMEM;
@@ -353,7 +352,7 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
pxa_dma->sglen = sglen;
offset = *sg_first_ofs;
- dev_dbg(pcdev->dev, "DMA: sg_first=%p, sglen=%d, ofs=%d, dma.desc=%x\n",
+ dev_dbg(pcdev->soc_host.dev, "DMA: sg_first=%p, sglen=%d, ofs=%d, dma.desc=%x\n",
*sg_first, sglen, *sg_first_ofs, pxa_dma->sg_dma);
@@ -376,7 +375,7 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
pxa_dma->sg_cpu[i].ddadr =
pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc);
- dev_vdbg(pcdev->dev, "DMA: desc.%08x->@phys=0x%08x, len=%d\n",
+ dev_vdbg(pcdev->soc_host.dev, "DMA: desc.%08x->@phys=0x%08x, len=%d\n",
pxa_dma->sg_dma + i * sizeof(struct pxa_dma_desc),
sg_dma_address(sg) + offset, xfer_len);
offset = 0;
@@ -488,7 +487,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
ret = pxa_init_dma_channel(pcdev, buf, dma, 0, CIBR0, size_y,
&sg, &next_ofs);
if (ret) {
- dev_err(pcdev->dev,
+ dev_err(pcdev->soc_host.dev,
"DMA initialization for Y/RGB failed\n");
goto fail;
}
@@ -498,7 +497,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
ret = pxa_init_dma_channel(pcdev, buf, dma, 1, CIBR1,
size_u, &sg, &next_ofs);
if (ret) {
- dev_err(pcdev->dev,
+ dev_err(pcdev->soc_host.dev,
"DMA initialization for U failed\n");
goto fail_u;
}
@@ -508,7 +507,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
ret = pxa_init_dma_channel(pcdev, buf, dma, 2, CIBR2,
size_v, &sg, &next_ofs);
if (ret) {
- dev_err(pcdev->dev,
+ dev_err(pcdev->soc_host.dev,
"DMA initialization for V failed\n");
goto fail_v;
}
@@ -522,10 +521,10 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
return 0;
fail_v:
- dma_free_coherent(pcdev->dev, buf->dmas[1].sg_size,
+ dma_free_coherent(pcdev->soc_host.dev, buf->dmas[1].sg_size,
buf->dmas[1].sg_cpu, buf->dmas[1].sg_dma);
fail_u:
- dma_free_coherent(pcdev->dev, buf->dmas[0].sg_size,
+ dma_free_coherent(pcdev->soc_host.dev, buf->dmas[0].sg_size,
buf->dmas[0].sg_cpu, buf->dmas[0].sg_dma);
fail:
free_buffer(vq, buf);
@@ -549,7 +548,7 @@ static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev)
active = pcdev->active;
for (i = 0; i < pcdev->channels; i++) {
- dev_dbg(pcdev->dev, "%s (channel=%d) ddadr=%08x\n", __func__,
+ dev_dbg(pcdev->soc_host.dev, "%s (channel=%d) ddadr=%08x\n", __func__,
i, active->dmas[i].sg_dma);
DDADR(pcdev->dma_chans[i]) = active->dmas[i].sg_dma;
DCSR(pcdev->dma_chans[i]) = DCSR_RUN;
@@ -561,7 +560,7 @@ static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev)
int i;
for (i = 0; i < pcdev->channels; i++) {
- dev_dbg(pcdev->dev, "%s (channel=%d)\n", __func__, i);
+ dev_dbg(pcdev->soc_host.dev, "%s (channel=%d)\n", __func__, i);
DCSR(pcdev->dma_chans[i]) = 0;
}
}
@@ -597,7 +596,7 @@ static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev)
{
unsigned long cicr0, cifr;
- dev_dbg(pcdev->dev, "%s\n", __func__);
+ dev_dbg(pcdev->soc_host.dev, "%s\n", __func__);
/* Reset the FIFOs */
cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
__raw_writel(cifr, pcdev->base + CIFR);
@@ -617,7 +616,7 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev)
__raw_writel(cicr0, pcdev->base + CICR0);
pcdev->active = NULL;
- dev_dbg(pcdev->dev, "%s\n", __func__);
+ dev_dbg(pcdev->soc_host.dev, "%s\n", __func__);
}
static void pxa_videobuf_queue(struct videobuf_queue *vq,
@@ -686,7 +685,7 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
do_gettimeofday(&vb->ts);
vb->field_count++;
wake_up(&vb->done);
- dev_dbg(pcdev->dev, "%s dequeud buffer (vb=0x%p)\n", __func__, vb);
+ dev_dbg(pcdev->soc_host.dev, "%s dequeud buffer (vb=0x%p)\n", __func__, vb);
if (list_empty(&pcdev->capture)) {
pxa_camera_stop_capture(pcdev);
@@ -722,7 +721,7 @@ static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev)
for (i = 0; i < pcdev->channels; i++)
if (DDADR(pcdev->dma_chans[i]) != DDADR_STOP)
is_dma_stopped = 0;
- dev_dbg(pcdev->dev, "%s : top queued buffer=%p, dma_stopped=%d\n",
+ dev_dbg(pcdev->soc_host.dev, "%s : top queued buffer=%p, dma_stopped=%d\n",
__func__, pcdev->active, is_dma_stopped);
if (pcdev->active && is_dma_stopped)
pxa_camera_start_capture(pcdev);
@@ -747,12 +746,12 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev,
overrun |= CISR_IFO_1 | CISR_IFO_2;
if (status & DCSR_BUSERR) {
- dev_err(pcdev->dev, "DMA Bus Error IRQ!\n");
+ dev_err(pcdev->soc_host.dev, "DMA Bus Error IRQ!\n");
goto out;
}
if (!(status & (DCSR_ENDINTR | DCSR_STARTINTR))) {
- dev_err(pcdev->dev, "Unknown DMA IRQ source, "
+ dev_err(pcdev->soc_host.dev, "Unknown DMA IRQ source, "
"status: 0x%08x\n", status);
goto out;
}
@@ -776,7 +775,7 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev,
buf = container_of(vb, struct pxa_buffer, vb);
WARN_ON(buf->inwork || list_empty(&vb->queue));
- dev_dbg(pcdev->dev, "%s channel=%d %s%s(vb=0x%p) dma.desc=%x\n",
+ dev_dbg(pcdev->soc_host.dev, "%s channel=%d %s%s(vb=0x%p) dma.desc=%x\n",
__func__, channel, status & DCSR_STARTINTR ? "SOF " : "",
status & DCSR_ENDINTR ? "EOF " : "", vb, DDADR(channel));
@@ -787,7 +786,7 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev,
*/
if (camera_status & overrun &&
!list_is_last(pcdev->capture.next, &pcdev->capture)) {
- dev_dbg(pcdev->dev, "FIFO overrun! CISR: %x\n",
+ dev_dbg(pcdev->soc_host.dev, "FIFO overrun! CISR: %x\n",
camera_status);
pxa_camera_stop_capture(pcdev);
pxa_camera_start_capture(pcdev);
@@ -854,7 +853,7 @@ static u32 mclk_get_divisor(struct pxa_camera_dev *pcdev)
/* mclk <= ciclk / 4 (27.4.2) */
if (mclk > lcdclk / 4) {
mclk = lcdclk / 4;
- dev_warn(pcdev->dev, "Limiting master clock to %lu\n", mclk);
+ dev_warn(pcdev->soc_host.dev, "Limiting master clock to %lu\n", mclk);
}
/* We verify mclk != 0, so if anyone breaks it, here comes their Oops */
@@ -864,7 +863,7 @@ static u32 mclk_get_divisor(struct pxa_camera_dev *pcdev)
if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
pcdev->mclk = lcdclk / (2 * (div + 1));
- dev_dbg(pcdev->dev, "LCD clock %luHz, target freq %luHz, "
+ dev_dbg(pcdev->soc_host.dev, "LCD clock %luHz, target freq %luHz, "
"divisor %u\n", lcdclk, mclk, div);
return div;
@@ -884,12 +883,12 @@ static void pxa_camera_activate(struct pxa_camera_dev *pcdev)
struct pxacamera_platform_data *pdata = pcdev->pdata;
u32 cicr4 = 0;
- dev_dbg(pcdev->dev, "Registered platform device at %p data %p\n",
+ dev_dbg(pcdev->soc_host.dev, "Registered platform device at %p data %p\n",
pcdev, pdata);
if (pdata && pdata->init) {
- dev_dbg(pcdev->dev, "%s: Init gpios\n", __func__);
- pdata->init(pcdev->dev);
+ dev_dbg(pcdev->soc_host.dev, "%s: Init gpios\n", __func__);
+ pdata->init(pcdev->soc_host.dev);
}
/* disable all interrupts */
@@ -931,7 +930,7 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
struct videobuf_buffer *vb;
status = __raw_readl(pcdev->base + CISR);
- dev_dbg(pcdev->dev, "Camera interrupt status 0x%lx\n", status);
+ dev_dbg(pcdev->soc_host.dev, "Camera interrupt status 0x%lx\n", status);
if (!status)
return IRQ_NONE;
@@ -1259,7 +1258,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
- dev_dbg(&ici->dev, "Providing format %s using %s\n",
+ dev_dbg(ici->dev, "Providing format %s using %s\n",
pxa_camera_formats[0].name,
icd->formats[idx].name);
}
@@ -1274,7 +1273,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
- dev_dbg(&ici->dev, "Providing format %s packed\n",
+ dev_dbg(ici->dev, "Providing format %s packed\n",
icd->formats[idx].name);
}
break;
@@ -1286,7 +1285,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = icd->formats[idx].depth;
xlate++;
- dev_dbg(&ici->dev,
+ dev_dbg(ici->dev,
"Providing format %s in pass-through mode\n",
icd->formats[idx].name);
}
@@ -1315,11 +1314,11 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd,
icd->sense = NULL;
if (ret < 0) {
- dev_warn(&ici->dev, "Failed to crop to %ux%u@%u:%u\n",
+ dev_warn(ici->dev, "Failed to crop to %ux%u@%u:%u\n",
rect->width, rect->height, rect->left, rect->top);
} else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
if (sense.pixel_clock > sense.pixel_clock_max) {
- dev_err(&ici->dev,
+ dev_err(ici->dev,
"pixel clock %lu set by the camera too high!",
sense.pixel_clock);
return -EIO;
@@ -1347,7 +1346,7 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat);
+ dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat);
return -EINVAL;
}
@@ -1363,11 +1362,11 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
icd->sense = NULL;
if (ret < 0) {
- dev_warn(&ici->dev, "Failed to configure for format %x\n",
+ dev_warn(ici->dev, "Failed to configure for format %x\n",
pix->pixelformat);
} else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
if (sense.pixel_clock > sense.pixel_clock_max) {
- dev_err(&ici->dev,
+ dev_err(ici->dev,
"pixel clock %lu set by the camera too high!",
sense.pixel_clock);
return -EIO;
@@ -1395,7 +1394,7 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
+ dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}
@@ -1552,12 +1551,6 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops = {
.set_bus_param = pxa_camera_set_bus_param,
};
-/* Should be allocated dynamically too, but we have only one. */
-static struct soc_camera_host pxa_soc_camera_host = {
- .drv_name = PXA_CAM_DRV_NAME,
- .ops = &pxa_soc_camera_host_ops,
-};
-
static int pxa_camera_probe(struct platform_device *pdev)
{
struct pxa_camera_dev *pcdev;
@@ -1586,7 +1579,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
goto exit_kfree;
}
- dev_set_drvdata(&pdev->dev, pcdev);
pcdev->res = res;
pcdev->pdata = pdev->dev.platform_data;
@@ -1607,7 +1599,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
pcdev->mclk = 20000000;
}
- pcdev->dev = &pdev->dev;
pcdev->mclk_divisor = mclk_get_divisor(pcdev);
INIT_LIST_HEAD(&pcdev->capture);
@@ -1616,13 +1607,13 @@ static int pxa_camera_probe(struct platform_device *pdev)
/*
* Request the regions.
*/
- if (!request_mem_region(res->start, res->end - res->start + 1,
+ if (!request_mem_region(res->start, resource_size(res),
PXA_CAM_DRV_NAME)) {
err = -EBUSY;
goto exit_clk;
}
- base = ioremap(res->start, res->end - res->start + 1);
+ base = ioremap(res->start, resource_size(res));
if (!base) {
err = -ENOMEM;
goto exit_release;
@@ -1634,29 +1625,29 @@ static int pxa_camera_probe(struct platform_device *pdev)
err = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
pxa_camera_dma_irq_y, pcdev);
if (err < 0) {
- dev_err(pcdev->dev, "Can't request DMA for Y\n");
+ dev_err(&pdev->dev, "Can't request DMA for Y\n");
goto exit_iounmap;
}
pcdev->dma_chans[0] = err;
- dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
+ dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
err = pxa_request_dma("CI_U", DMA_PRIO_HIGH,
pxa_camera_dma_irq_u, pcdev);
if (err < 0) {
- dev_err(pcdev->dev, "Can't request DMA for U\n");
+ dev_err(&pdev->dev, "Can't request DMA for U\n");
goto exit_free_dma_y;
}
pcdev->dma_chans[1] = err;
- dev_dbg(pcdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]);
+ dev_dbg(&pdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]);
err = pxa_request_dma("CI_V", DMA_PRIO_HIGH,
pxa_camera_dma_irq_v, pcdev);
if (err < 0) {
- dev_err(pcdev->dev, "Can't request DMA for V\n");
+ dev_err(&pdev->dev, "Can't request DMA for V\n");
goto exit_free_dma_u;
}
pcdev->dma_chans[2] = err;
- dev_dbg(pcdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]);
+ dev_dbg(&pdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]);
DRCMR(68) = pcdev->dma_chans[0] | DRCMR_MAPVLD;
DRCMR(69) = pcdev->dma_chans[1] | DRCMR_MAPVLD;
@@ -1666,14 +1657,17 @@ static int pxa_camera_probe(struct platform_device *pdev)
err = request_irq(pcdev->irq, pxa_camera_irq, 0, PXA_CAM_DRV_NAME,
pcdev);
if (err) {
- dev_err(pcdev->dev, "Camera interrupt register failed \n");
+ dev_err(&pdev->dev, "Camera interrupt register failed \n");
goto exit_free_dma;
}
- pxa_soc_camera_host.priv = pcdev;
- pxa_soc_camera_host.dev.parent = &pdev->dev;
- pxa_soc_camera_host.nr = pdev->id;
- err = soc_camera_host_register(&pxa_soc_camera_host);
+ pcdev->soc_host.drv_name = PXA_CAM_DRV_NAME;
+ pcdev->soc_host.ops = &pxa_soc_camera_host_ops;
+ pcdev->soc_host.priv = pcdev;
+ pcdev->soc_host.dev = &pdev->dev;
+ pcdev->soc_host.nr = pdev->id;
+
+ err = soc_camera_host_register(&pcdev->soc_host);
if (err)
goto exit_free_irq;
@@ -1690,7 +1684,7 @@ exit_free_dma_y:
exit_iounmap:
iounmap(base);
exit_release:
- release_mem_region(res->start, res->end - res->start + 1);
+ release_mem_region(res->start, resource_size(res));
exit_clk:
clk_put(pcdev->clk);
exit_kfree:
@@ -1701,7 +1695,9 @@ exit:
static int __devexit pxa_camera_remove(struct platform_device *pdev)
{
- struct pxa_camera_dev *pcdev = platform_get_drvdata(pdev);
+ struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
+ struct pxa_camera_dev *pcdev = container_of(soc_host,
+ struct pxa_camera_dev, soc_host);
struct resource *res;
clk_put(pcdev->clk);
@@ -1711,12 +1707,12 @@ static int __devexit pxa_camera_remove(struct platform_device *pdev)
pxa_free_dma(pcdev->dma_chans[2]);
free_irq(pcdev->irq, pcdev);
- soc_camera_host_unregister(&pxa_soc_camera_host);
+ soc_camera_host_unregister(soc_host);
iounmap(pcdev->base);
res = pcdev->res;
- release_mem_region(res->start, res->end - res->start + 1);
+ release_mem_region(res->start, resource_size(res));
kfree(pcdev);
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 30f4698be90a..5323f0e62eae 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -77,6 +77,8 @@
#define MAX_CHANNELS 4
#define S2255_MARKER_FRAME 0x2255DA4AL
#define S2255_MARKER_RESPONSE 0x2255ACACL
+#define S2255_RESPONSE_SETMODE 0x01
+#define S2255_RESPONSE_FW 0x10
#define S2255_USB_XFER_SIZE (16 * 1024)
#define MAX_CHANNELS 4
#define MAX_PIPE_BUFFERS 1
@@ -178,9 +180,6 @@ struct s2255_bufferi {
struct s2255_dmaqueue {
struct list_head active;
- /* thread for acquisition */
- struct task_struct *kthread;
- int frame;
struct s2255_dev *dev;
int channel;
};
@@ -210,16 +209,11 @@ struct s2255_pipeinfo {
u32 max_transfer_size;
u32 cur_transfer_size;
u8 *transfer_buffer;
- u32 transfer_flags;;
u32 state;
- u32 prev_state;
- u32 urb_size;
void *stream_urb;
void *dev; /* back pointer to s2255_dev struct*/
u32 err_count;
- u32 buf_index;
u32 idx;
- u32 priority_set;
};
struct s2255_fmt; /*forward declaration */
@@ -239,8 +233,6 @@ struct s2255_dev {
struct list_head s2255_devlist;
struct timer_list timer;
struct s2255_fw *fw_data;
- int board_num;
- int is_open;
struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS];
struct s2255_bufferi buffer[MAX_CHANNELS];
struct s2255_mode mode[MAX_CHANNELS];
@@ -297,9 +289,10 @@ struct s2255_fh {
int resources[MAX_CHANNELS];
};
-#define CUR_USB_FWVER 774 /* current cypress EEPROM firmware version */
+/* current cypress EEPROM firmware version */
+#define S2255_CUR_USB_FWVER ((3 << 8) | 6)
#define S2255_MAJOR_VERSION 1
-#define S2255_MINOR_VERSION 13
+#define S2255_MINOR_VERSION 14
#define S2255_RELEASE 0
#define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \
S2255_MINOR_VERSION, \
@@ -1818,7 +1811,6 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
INIT_LIST_HEAD(&dev->vidq[i].active);
dev->vidq[i].dev = dev;
dev->vidq[i].channel = i;
- dev->vidq[i].kthread = NULL;
/* register 4 video devices */
dev->vdev[i] = video_device_alloc();
memcpy(dev->vdev[i], &template, sizeof(struct video_device));
@@ -1839,7 +1831,9 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
return ret;
}
}
- printk(KERN_INFO "Sensoray 2255 V4L driver\n");
+ printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %d.%d\n",
+ S2255_MAJOR_VERSION,
+ S2255_MINOR_VERSION);
return ret;
}
@@ -1929,14 +1923,14 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
if (!(cc >= 0 && cc < MAX_CHANNELS))
break;
switch (pdword[2]) {
- case 0x01:
+ case S2255_RESPONSE_SETMODE:
/* check if channel valid */
/* set mode ready */
dev->setmode_ready[cc] = 1;
wake_up(&dev->wait_setmode[cc]);
dprintk(5, "setmode ready %d\n", cc);
break;
- case 0x10:
+ case S2255_RESPONSE_FW:
dev->chn_ready |= (1 << cc);
if ((dev->chn_ready & 0x0f) != 0x0f)
@@ -2172,10 +2166,15 @@ static int s2255_board_init(struct s2255_dev *dev)
/* query the firmware */
fw_ver = s2255_get_fx2fw(dev);
- printk(KERN_INFO "2255 usb firmware version %d \n", fw_ver);
- if (fw_ver < CUR_USB_FWVER)
+ printk(KERN_INFO "2255 usb firmware version %d.%d\n",
+ (fw_ver >> 8) & 0xff,
+ fw_ver & 0xff);
+
+ if (fw_ver < S2255_CUR_USB_FWVER)
dev_err(&dev->udev->dev,
- "usb firmware not up to date %d\n", fw_ver);
+ "usb firmware not up to date %d.%d\n",
+ (fw_ver >> 8) & 0xff,
+ fw_ver & 0xff);
for (j = 0; j < MAX_CHANNELS; j++) {
dev->b_acquire[j] = 0;
@@ -2240,8 +2239,10 @@ static void read_pipe_completion(struct urb *purb)
return;
}
status = purb->status;
- if (status != 0) {
- dprintk(2, "read_pipe_completion: err\n");
+ /* if shutting down, do not resubmit, exit immediately */
+ if (status == -ESHUTDOWN) {
+ dprintk(2, "read_pipe_completion: err shutdown\n");
+ pipe_info->err_count++;
return;
}
@@ -2250,9 +2251,13 @@ static void read_pipe_completion(struct urb *purb)
return;
}
- s2255_read_video_callback(dev, pipe_info);
+ if (status == 0)
+ s2255_read_video_callback(dev, pipe_info);
+ else {
+ pipe_info->err_count++;
+ dprintk(1, "s2255drv: failed URB %d\n", status);
+ }
- pipe_info->err_count = 0;
pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
/* reuse urb */
usb_fill_bulk_urb(pipe_info->stream_urb, dev->udev,
@@ -2264,7 +2269,6 @@ static void read_pipe_completion(struct urb *purb)
if (pipe_info->state != 0) {
if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL)) {
dev_err(&dev->udev->dev, "error submitting urb\n");
- usb_free_urb(pipe_info->stream_urb);
}
} else {
dprintk(2, "read pipe complete state 0\n");
@@ -2283,8 +2287,7 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
for (i = 0; i < MAX_PIPE_BUFFERS; i++) {
pipe_info->state = 1;
- pipe_info->buf_index = (u32) i;
- pipe_info->priority_set = 0;
+ pipe_info->err_count = 0;
pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!pipe_info->stream_urb) {
dev_err(&dev->udev->dev,
@@ -2298,7 +2301,6 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
pipe_info->cur_transfer_size,
read_pipe_completion, pipe_info);
- pipe_info->urb_size = sizeof(pipe_info->stream_urb);
dprintk(4, "submitting URB %p\n", pipe_info->stream_urb);
retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL);
if (retval) {
@@ -2403,8 +2405,6 @@ static void s2255_stop_readpipe(struct s2255_dev *dev)
if (pipe_info->state == 0)
continue;
pipe_info->state = 0;
- pipe_info->prev_state = 1;
-
}
}
@@ -2542,7 +2542,9 @@ static int s2255_probe(struct usb_interface *interface,
s2255_probe_v4l(dev);
usb_reset_device(dev->udev);
/* load 2255 board specific */
- s2255_board_init(dev);
+ retval = s2255_board_init(dev);
+ if (retval)
+ goto error;
dprintk(4, "before probe done %p\n", dev);
spin_lock_init(&dev->slock);
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index fdb19449d269..0eced41443e8 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1669,6 +1669,39 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE1,
},
},
+ [SAA7134_BOARD_AVERMEDIA_CARDBUS_501] = {
+ /* Oldrich Jedlicka <oldium.pro@seznam.cz> */
+ .name = "AVerMedia Cardbus TV/Radio (E501R)",
+ .audio_clock = 0x187de7,
+ .tuner_type = TUNER_ALPS_TSBE5_PAL,
+ .radio_type = TUNER_TEA5767,
+ .tuner_addr = 0x61,
+ .radio_addr = 0x60,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0x08000000,
+ .inputs = { {
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x08000000,
+ }, {
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x08000000,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ .gpio = 0x08000000,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ .gpio = 0x00000000,
+ },
+ },
[SAA7134_BOARD_CINERGY400_CARDBUS] = {
.name = "Terratec Cinergy 400 mobile",
.audio_clock = 0x187de7,
@@ -4006,7 +4039,7 @@ struct saa7134_board saa7134_boards[] = {
[SAA7134_BOARD_BEHOLD_505FM] = {
/* Beholder Intl. Ltd. 2008 */
/*Dmitry Belimov <d.belimov@gmail.com> */
- .name = "Beholder BeholdTV 505 FM/RDS",
+ .name = "Beholder BeholdTV 505 FM",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.radio_type = UNSET,
@@ -4019,6 +4052,40 @@ struct saa7134_board saa7134_boards[] = {
.vmux = 3,
.amux = LINE2,
.tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .mute = {
+ .name = name_mute,
+ .amux = LINE1,
+ },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_505RDS] = {
+ /* Beholder Intl. Ltd. 2008 */
+ /*Dmitry Belimov <d.belimov@gmail.com> */
+ .name = "Beholder BeholdTV 505 RDS",
+ .audio_clock = 0x00200000,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0x00008000,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = LINE2,
+ .tv = 1,
},{
.name = name_comp1,
.vmux = 1,
@@ -4040,7 +4107,7 @@ struct saa7134_board saa7134_boards[] = {
[SAA7134_BOARD_BEHOLD_507_9FM] = {
/* Beholder Intl. Ltd. 2008 */
/*Dmitry Belimov <d.belimov@gmail.com> */
- .name = "Beholder BeholdTV 507 FM/RDS / BeholdTV 509 FM",
+ .name = "Beholder BeholdTV 507 FM / BeholdTV 509 FM",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.radio_type = UNSET,
@@ -4067,6 +4134,66 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
},
},
+ [SAA7134_BOARD_BEHOLD_507RDS_MK5] = {
+ /* Beholder Intl. Ltd. 2008 */
+ /*Dmitry Belimov <d.belimov@gmail.com> */
+ .name = "Beholder BeholdTV 507 RDS",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0x00008000,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_507RDS_MK3] = {
+ /* Beholder Intl. Ltd. 2008 */
+ /*Dmitry Belimov <d.belimov@gmail.com> */
+ .name = "Beholder BeholdTV 507 RDS",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0x00008000,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
[SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM] = {
/* Beholder Intl. Ltd. 2008 */
/*Dmitry Belimov <d.belimov@gmail.com> */
@@ -4101,9 +4228,9 @@ struct saa7134_board saa7134_boards[] = {
.gpio = 0x000A8000,
},
},
- [SAA7134_BOARD_BEHOLD_607_9FM] = {
+ [SAA7134_BOARD_BEHOLD_607FM_MK3] = {
/* Andrey Melnikoff <temnota@kmv.ru> */
- .name = "Beholder BeholdTV 607 / BeholdTV 609",
+ .name = "Beholder BeholdTV 607 FM",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.radio_type = UNSET,
@@ -4115,6 +4242,202 @@ struct saa7134_board saa7134_boards[] = {
.vmux = 3,
.amux = TV,
.tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_609FM_MK3] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 609 FM",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_607FM_MK5] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 607 FM",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_609FM_MK5] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 609 FM",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_607RDS_MK3] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 607 RDS",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_609RDS_MK3] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 609 RDS",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_607RDS_MK5] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 607 RDS",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ }, {
+ .name = name_comp1,
+ .vmux = 1,
+ .amux = LINE1,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_BEHOLD_609RDS_MK5] = {
+ /* Andrey Melnikoff <temnota@kmv.ru> */
+ .name = "Beholder BeholdTV 609 RDS",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
},{
.name = name_comp1,
.vmux = 1,
@@ -4209,8 +4532,7 @@ struct saa7134_board saa7134_boards[] = {
/* Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com> */
.name = "Beholder BeholdTV M6 Extra",
.audio_clock = 0x00187de7,
- /* FIXME: Must be PHILIPS_FM1216ME_MK5*/
- .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
@@ -4465,7 +4787,6 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
- .mpeg = SAA7134_MPEG_DVB,
.inputs = {{
.name = name_tv,
.vmux = 3,
@@ -4753,6 +5074,44 @@ struct saa7134_board saa7134_boards[] = {
.gpio = 0x01,
},
},
+ [SAA7134_BOARD_AVERMEDIA_STUDIO_507UA] = {
+ /* Andy Shevchenko <andy@smile.org.ua> */
+ .name = "Avermedia AVerTV Studio 507UA",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* Should be MK5 */
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0x03,
+ .inputs = { {
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x00,
+ }, {
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x00,
+ }, {
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ .gpio = 0x00,
+ } },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ .gpio = 0x01,
+ },
+ .mute = {
+ .name = name_mute,
+ .amux = LINE1,
+ .gpio = 0x00,
+ },
+ },
};
const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -5027,6 +5386,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice = 0xd6ee,
.driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS,
},{
+ /* AVerMedia CardBus */
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0xb7e9,
+ .driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS_501,
+ }, {
/* TransGear 3000TV */
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
@@ -5441,6 +5807,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
.driver_data = SAA7134_BOARD_AVERMEDIA_STUDIO_507,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0xa11b,
+ .driver_data = SAA7134_BOARD_AVERMEDIA_STUDIO_507UA,
+ }, {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x1043,
.subdevice = 0x4876,
@@ -5647,14 +6019,8 @@ struct pci_device_id saa7134_pci_tbl[] = {
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
.subvendor = 0x0000,
- .subdevice = 0x5051,
- .driver_data = SAA7134_BOARD_BEHOLD_505FM,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x0000,
.subdevice = 0x505B,
- .driver_data = SAA7134_BOARD_BEHOLD_505FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_505RDS,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
@@ -5666,13 +6032,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x0000,
.subdevice = 0x5071,
- .driver_data = SAA7134_BOARD_BEHOLD_507_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_507RDS_MK3,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x0000,
.subdevice = 0x507B,
- .driver_data = SAA7134_BOARD_BEHOLD_507_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_507RDS_MK5,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -5696,49 +6062,49 @@ struct pci_device_id saa7134_pci_tbl[] = {
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x5ace,
.subdevice = 0x6070,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_607FM_MK3,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x5ace,
.subdevice = 0x6071,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_607FM_MK5,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x5ace,
.subdevice = 0x6072,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_607RDS_MK3,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x5ace,
.subdevice = 0x6073,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_607RDS_MK5,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5ace,
.subdevice = 0x6090,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_609FM_MK3,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5ace,
.subdevice = 0x6091,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_609FM_MK5,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5ace,
.subdevice = 0x6092,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_609RDS_MK3,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5ace,
.subdevice = 0x6093,
- .driver_data = SAA7134_BOARD_BEHOLD_607_9FM,
+ .driver_data = SAA7134_BOARD_BEHOLD_609RDS_MK5,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
@@ -6114,7 +6480,6 @@ int saa7134_board_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_VIDEOMATE_DVBT_300:
case SAA7134_BOARD_VIDEOMATE_DVBT_200:
case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
- case SAA7134_BOARD_VIDEOMATE_T750:
case SAA7134_BOARD_MANLI_MTV001:
case SAA7134_BOARD_MANLI_MTV002:
case SAA7134_BOARD_BEHOLD_409FM:
@@ -6142,7 +6507,10 @@ int saa7134_board_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_BEHOLD_407FM:
case SAA7134_BOARD_BEHOLD_409:
case SAA7134_BOARD_BEHOLD_505FM:
+ case SAA7134_BOARD_BEHOLD_505RDS:
case SAA7134_BOARD_BEHOLD_507_9FM:
+ case SAA7134_BOARD_BEHOLD_507RDS_MK3:
+ case SAA7134_BOARD_BEHOLD_507RDS_MK5:
case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
case SAA7134_BOARD_REAL_ANGEL_220:
case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
@@ -6196,6 +6564,16 @@ int saa7134_board_init1(struct saa7134_dev *dev)
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff);
msleep(10);
break;
+ case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
+ /* power-down tuner chip */
+ saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x08400000, 0x08400000);
+ saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08400000, 0);
+ msleep(10);
+ saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x08400000, 0x08400000);
+ saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08400000, 0x08400000);
+ msleep(10);
+ dev->has_remote = SAA7134_REMOTE_I2C;
+ break;
case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
saa7134_set_gpio(dev, 23, 0);
msleep(10);
@@ -6253,7 +6631,14 @@ int saa7134_board_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_UPMOST_PURPLE_TV:
case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
case SAA7134_BOARD_HAUPPAUGE_HVR1110:
- case SAA7134_BOARD_BEHOLD_607_9FM:
+ case SAA7134_BOARD_BEHOLD_607FM_MK3:
+ case SAA7134_BOARD_BEHOLD_607FM_MK5:
+ case SAA7134_BOARD_BEHOLD_609FM_MK3:
+ case SAA7134_BOARD_BEHOLD_609FM_MK5:
+ case SAA7134_BOARD_BEHOLD_607RDS_MK3:
+ case SAA7134_BOARD_BEHOLD_607RDS_MK5:
+ case SAA7134_BOARD_BEHOLD_609RDS_MK3:
+ case SAA7134_BOARD_BEHOLD_609RDS_MK5:
case SAA7134_BOARD_BEHOLD_M6:
case SAA7134_BOARD_BEHOLD_M63:
case SAA7134_BOARD_BEHOLD_M6_EXTRA:
@@ -6635,6 +7020,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
switch (dev->board) {
case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
+ case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
{
struct v4l2_priv_tun_config tea5767_cfg;
struct tea5767_ctrl ctl;
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 9db3472667e5..097c2dfebd2c 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -491,11 +491,8 @@ static void empress_signal_update(struct work_struct *work)
if (dev->nosignal) {
dprintk("no video signal\n");
- ts_reset_encoder(dev);
} else {
dprintk("video signal acquired\n");
- if (atomic_read(&dev->empress_users))
- ts_init_encoder(dev);
}
}
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 8a106d36e723..450637517265 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -447,6 +447,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
+ case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA:
case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
case SAA7134_BOARD_AVERMEDIA_M102:
case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
@@ -506,7 +507,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_BEHOLD_407FM:
case SAA7134_BOARD_BEHOLD_409:
case SAA7134_BOARD_BEHOLD_505FM:
+ case SAA7134_BOARD_BEHOLD_505RDS:
case SAA7134_BOARD_BEHOLD_507_9FM:
+ case SAA7134_BOARD_BEHOLD_507RDS_MK3:
+ case SAA7134_BOARD_BEHOLD_507RDS_MK5:
ir_codes = ir_codes_manli;
mask_keycode = 0x003f00;
mask_keyup = 0x004000;
@@ -713,7 +717,14 @@ void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
ir->get_key = get_key_hvr1110;
ir->ir_codes = ir_codes_hauppauge_new;
break;
- case SAA7134_BOARD_BEHOLD_607_9FM:
+ case SAA7134_BOARD_BEHOLD_607FM_MK3:
+ case SAA7134_BOARD_BEHOLD_607FM_MK5:
+ case SAA7134_BOARD_BEHOLD_609FM_MK3:
+ case SAA7134_BOARD_BEHOLD_609FM_MK5:
+ case SAA7134_BOARD_BEHOLD_607RDS_MK3:
+ case SAA7134_BOARD_BEHOLD_607RDS_MK5:
+ case SAA7134_BOARD_BEHOLD_609RDS_MK3:
+ case SAA7134_BOARD_BEHOLD_609RDS_MK5:
case SAA7134_BOARD_BEHOLD_M6:
case SAA7134_BOARD_BEHOLD_M63:
case SAA7134_BOARD_BEHOLD_M6_EXTRA:
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index cc8b923afbc0..b8ff459d0d30 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -65,7 +65,7 @@ static int buffer_activate(struct saa7134_dev *dev,
/* start DMA */
saa7134_set_dmabits(dev);
- mod_timer(&dev->ts_q.timeout, jiffies+BUFFER_TIMEOUT);
+ mod_timer(&dev->ts_q.timeout, jiffies+TS_BUFFER_TIMEOUT);
if (dev->ts_state == SAA7134_TS_BUFF_DONE) {
/* Clear TS cache */
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 0cbaf90d4874..8229ab213223 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -252,7 +252,7 @@ struct saa7134_format {
#define SAA7134_BOARD_BEHOLD_505FM 126
#define SAA7134_BOARD_BEHOLD_507_9FM 127
#define SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM 128
-#define SAA7134_BOARD_BEHOLD_607_9FM 129
+#define SAA7134_BOARD_BEHOLD_607FM_MK3 129
#define SAA7134_BOARD_BEHOLD_M6 130
#define SAA7134_BOARD_TWINHAN_DTV_DVB_3056 131
#define SAA7134_BOARD_GENIUS_TVGO_A11MCE 132
@@ -280,6 +280,18 @@ struct saa7134_format {
#define SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS 154
#define SAA7134_BOARD_HAUPPAUGE_HVR1120 155
#define SAA7134_BOARD_HAUPPAUGE_HVR1110R3 156
+#define SAA7134_BOARD_AVERMEDIA_STUDIO_507UA 157
+#define SAA7134_BOARD_AVERMEDIA_CARDBUS_501 158
+#define SAA7134_BOARD_BEHOLD_505RDS 159
+#define SAA7134_BOARD_BEHOLD_507RDS_MK3 160
+#define SAA7134_BOARD_BEHOLD_507RDS_MK5 161
+#define SAA7134_BOARD_BEHOLD_607FM_MK5 162
+#define SAA7134_BOARD_BEHOLD_609FM_MK3 163
+#define SAA7134_BOARD_BEHOLD_609FM_MK5 164
+#define SAA7134_BOARD_BEHOLD_607RDS_MK3 165
+#define SAA7134_BOARD_BEHOLD_607RDS_MK5 166
+#define SAA7134_BOARD_BEHOLD_609RDS_MK3 167
+#define SAA7134_BOARD_BEHOLD_609RDS_MK5 168
#define SAA7134_MAXBOARDS 32
#define SAA7134_INPUT_MAX 8
@@ -364,6 +376,7 @@ struct saa7134_board {
#define INTERLACE_OFF 2
#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
+#define TS_BUFFER_TIMEOUT msecs_to_jiffies(1000) /* 1 second */
struct saa7134_dev;
struct saa7134_dma;
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index b5e37a530c62..d369e8409ab8 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -81,7 +81,6 @@ struct sh_mobile_ceu_buffer {
};
struct sh_mobile_ceu_dev {
- struct device *dev;
struct soc_camera_host ici;
struct soc_camera_device *icd;
@@ -617,7 +616,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = icd->formats[idx].depth;
xlate++;
- dev_dbg(&ici->dev, "Providing format %s using %s\n",
+ dev_dbg(ici->dev, "Providing format %s using %s\n",
sh_mobile_ceu_formats[k].name,
icd->formats[idx].name);
}
@@ -630,7 +629,7 @@ add_single_format:
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = icd->formats[idx].depth;
xlate++;
- dev_dbg(&ici->dev,
+ dev_dbg(ici->dev,
"Providing format %s in pass-through mode\n",
icd->formats[idx].name);
}
@@ -657,7 +656,7 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
+ dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}
@@ -684,7 +683,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
- dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
+ dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}
@@ -782,7 +781,7 @@ static void sh_mobile_ceu_init_videobuf(struct videobuf_queue *q,
videobuf_queue_dma_contig_init(q,
&sh_mobile_ceu_videobuf_ops,
- &ici->dev, &pcdev->lock,
+ ici->dev, &pcdev->lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
pcdev->is_interlaced ?
V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE,
@@ -829,7 +828,6 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
goto exit;
}
- platform_set_drvdata(pdev, pcdev);
INIT_LIST_HEAD(&pcdev->capture);
spin_lock_init(&pcdev->lock);
@@ -840,7 +838,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
goto exit_kfree;
}
- base = ioremap_nocache(res->start, res->end - res->start + 1);
+ base = ioremap_nocache(res->start, resource_size(res));
if (!base) {
err = -ENXIO;
dev_err(&pdev->dev, "Unable to ioremap CEU registers.\n");
@@ -850,13 +848,12 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
pcdev->irq = irq;
pcdev->base = base;
pcdev->video_limit = 0; /* only enabled if second resource exists */
- pcdev->dev = &pdev->dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) {
err = dma_declare_coherent_memory(&pdev->dev, res->start,
res->start,
- (res->end - res->start) + 1,
+ resource_size(res),
DMA_MEMORY_MAP |
DMA_MEMORY_EXCLUSIVE);
if (!err) {
@@ -865,7 +862,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
goto exit_iounmap;
}
- pcdev->video_limit = (res->end - res->start) + 1;
+ pcdev->video_limit = resource_size(res);
}
/* request irq */
@@ -885,7 +882,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
}
pcdev->ici.priv = pcdev;
- pcdev->ici.dev.parent = &pdev->dev;
+ pcdev->ici.dev = &pdev->dev;
pcdev->ici.nr = pdev->id;
pcdev->ici.drv_name = dev_name(&pdev->dev);
pcdev->ici.ops = &sh_mobile_ceu_host_ops;
@@ -913,9 +910,11 @@ exit:
static int sh_mobile_ceu_remove(struct platform_device *pdev)
{
- struct sh_mobile_ceu_dev *pcdev = platform_get_drvdata(pdev);
+ struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
+ struct sh_mobile_ceu_dev *pcdev = container_of(soc_host,
+ struct sh_mobile_ceu_dev, ici);
- soc_camera_host_unregister(&pcdev->ici);
+ soc_camera_host_unregister(soc_host);
clk_put(pcdev->clk);
free_irq(pcdev->irq, pcdev);
if (platform_get_resource(pdev, IORESOURCE_MEM, 1))
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 0e890cc23377..2014e9e32b35 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -16,19 +16,21 @@
* published by the Free Software Foundation.
*/
-#include <linux/module.h>
-#include <linux/init.h>
#include <linux/device.h>
-#include <linux/list.h>
#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/platform_device.h>
#include <linux/vmalloc.h>
+#include <media/soc_camera.h>
#include <media/v4l2-common.h>
-#include <media/v4l2-ioctl.h>
#include <media/v4l2-dev.h>
+#include <media/v4l2-ioctl.h>
#include <media/videobuf-core.h>
-#include <media/soc_camera.h>
/* Default to VGA resolution */
#define DEFAULT_WIDTH 640
@@ -279,7 +281,7 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
return ret;
} else if (!icd->current_fmt ||
icd->current_fmt->fourcc != pix->pixelformat) {
- dev_err(&ici->dev,
+ dev_err(ici->dev,
"Host driver hasn't set up current format correctly!\n");
return -EINVAL;
}
@@ -794,7 +796,7 @@ static void scan_add_host(struct soc_camera_host *ici)
list_for_each_entry(icd, &devices, list) {
if (icd->iface == ici->nr) {
- icd->dev.parent = &ici->dev;
+ icd->dev.parent = ici->dev;
device_register_link(icd);
}
}
@@ -818,7 +820,7 @@ static int scan_add_device(struct soc_camera_device *icd)
list_for_each_entry(ici, &hosts, list) {
if (icd->iface == ici->nr) {
ret = 1;
- icd->dev.parent = &ici->dev;
+ icd->dev.parent = ici->dev;
break;
}
}
@@ -952,7 +954,6 @@ static void dummy_release(struct device *dev)
int soc_camera_host_register(struct soc_camera_host *ici)
{
- int ret;
struct soc_camera_host *ix;
if (!ici || !ici->ops ||
@@ -965,12 +966,10 @@ int soc_camera_host_register(struct soc_camera_host *ici)
!ici->ops->reqbufs ||
!ici->ops->add ||
!ici->ops->remove ||
- !ici->ops->poll)
+ !ici->ops->poll ||
+ !ici->dev)
return -EINVAL;
- /* Number might be equal to the platform device ID */
- dev_set_name(&ici->dev, "camera_host%d", ici->nr);
-
mutex_lock(&list_lock);
list_for_each_entry(ix, &hosts, list) {
if (ix->nr == ici->nr) {
@@ -979,26 +978,14 @@ int soc_camera_host_register(struct soc_camera_host *ici)
}
}
+ dev_set_drvdata(ici->dev, ici);
+
list_add_tail(&ici->list, &hosts);
mutex_unlock(&list_lock);
- ici->dev.release = dummy_release;
-
- ret = device_register(&ici->dev);
-
- if (ret)
- goto edevr;
-
scan_add_host(ici);
return 0;
-
-edevr:
- mutex_lock(&list_lock);
- list_del(&ici->list);
- mutex_unlock(&list_lock);
-
- return ret;
}
EXPORT_SYMBOL(soc_camera_host_register);
@@ -1012,7 +999,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
list_del(&ici->list);
list_for_each_entry(icd, &devices, list) {
- if (icd->dev.parent == &ici->dev) {
+ if (icd->dev.parent == ici->dev) {
device_unregister(&icd->dev);
/* Not before device_unregister(), .remove
* needs parent to call ici->ops->remove() */
@@ -1023,7 +1010,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
mutex_unlock(&list_lock);
- device_unregister(&ici->dev);
+ dev_set_drvdata(ici->dev, NULL);
}
EXPORT_SYMBOL(soc_camera_host_unregister);
@@ -1130,7 +1117,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
vdev = video_device_alloc();
if (!vdev)
goto evidallocd;
- dev_dbg(&ici->dev, "Allocated video_device %p\n", vdev);
+ dev_dbg(ici->dev, "Allocated video_device %p\n", vdev);
strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
@@ -1174,6 +1161,57 @@ void soc_camera_video_stop(struct soc_camera_device *icd)
}
EXPORT_SYMBOL(soc_camera_video_stop);
+static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
+{
+ struct soc_camera_link *icl = pdev->dev.platform_data;
+ struct i2c_adapter *adap;
+ struct i2c_client *client;
+
+ if (!icl)
+ return -EINVAL;
+
+ adap = i2c_get_adapter(icl->i2c_adapter_id);
+ if (!adap) {
+ dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n",
+ icl->i2c_adapter_id);
+ /* -ENODEV and -ENXIO do not produce an error on probe()... */
+ return -ENOENT;
+ }
+
+ icl->board_info->platform_data = icl;
+ client = i2c_new_device(adap, icl->board_info);
+ if (!client) {
+ i2c_put_adapter(adap);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, client);
+
+ return 0;
+}
+
+static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
+{
+ struct i2c_client *client = platform_get_drvdata(pdev);
+
+ if (!client)
+ return -ENODEV;
+
+ i2c_unregister_device(client);
+ i2c_put_adapter(client->adapter);
+
+ return 0;
+}
+
+static struct platform_driver __refdata soc_camera_pdrv = {
+ .probe = soc_camera_pdrv_probe,
+ .remove = __exit_p(soc_camera_pdrv_remove),
+ .driver = {
+ .name = "soc-camera-pdrv",
+ .owner = THIS_MODULE,
+ },
+};
+
static int __init soc_camera_init(void)
{
int ret = bus_register(&soc_camera_bus_type);
@@ -1183,8 +1221,14 @@ static int __init soc_camera_init(void)
if (ret)
goto edrvr;
+ ret = platform_driver_register(&soc_camera_pdrv);
+ if (ret)
+ goto epdr;
+
return 0;
+epdr:
+ driver_unregister(&ic_drv);
edrvr:
bus_unregister(&soc_camera_bus_type);
return ret;
@@ -1192,6 +1236,7 @@ edrvr:
static void __exit soc_camera_exit(void)
{
+ platform_driver_unregister(&soc_camera_pdrv);
driver_unregister(&ic_drv);
bus_unregister(&soc_camera_bus_type);
}
@@ -1202,3 +1247,4 @@ module_exit(soc_camera_exit);
MODULE_DESCRIPTION("Image capture bus driver");
MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:soc-camera-pdrv");
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 1a6d39cbd6f3..2e5937047278 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -1137,7 +1137,7 @@ static int stk_vidioc_querybuf(struct file *filp,
struct stk_camera *dev = priv;
struct stk_sio_buffer *sbuf;
- if (buf->index < 0 || buf->index >= dev->n_sbufs)
+ if (buf->index >= dev->n_sbufs)
return -EINVAL;
sbuf = dev->sio_bufs + buf->index;
*buf = sbuf->v4lbuf;
@@ -1154,7 +1154,7 @@ static int stk_vidioc_qbuf(struct file *filp,
if (buf->memory != V4L2_MEMORY_MMAP)
return -EINVAL;
- if (buf->index < 0 || buf->index >= dev->n_sbufs)
+ if (buf->index >= dev->n_sbufs)
return -EINVAL;
sbuf = dev->sio_bufs + buf->index;
if (sbuf->v4lbuf.flags & V4L2_BUF_FLAG_QUEUED)
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 005f8a468031..80f1cee23fa5 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -20,20 +20,6 @@
* loudness - set between 0 and 15 for varying degrees of loudness effect
*
* maxvol - set maximium volume to +20db (1), default is 0db(0)
- *
- *
- * Revision: 0.7 - maxvol module parm to set maximium volume 0db or +20db
- * store if muted so we can return it
- * change balance only if flaged to
- * Revision: 0.6 - added tone controls
- * Revision: 0.5 - Fixed odd balance problem
- * Revision: 0.4 - added muting
- * Revision: 0.3 - Fixed silly reversed volume controls. :)
- * Revision: 0.2 - Cleaned up #defines
- * fixed volume control
- * Added I2C_DRIVERID_TDA7432
- * added loudness insmod control
- * Revision: 0.1 - initial version
*/
#include <linux/module.h>
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index d4a9ed45764b..1585839bd0bd 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -141,7 +141,6 @@ static const struct v4l2_subdev_ops tea6415c_ops = {
.video = &tea6415c_video_ops,
};
-/* this function is called by i2c_probe */
static int tea6415c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index ced6eadf347a..0446524d3543 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -112,7 +112,6 @@ static const struct v4l2_subdev_ops tea6420_ops = {
.audio = &tea6420_audio_ops,
};
-/* this function is called by i2c_probe */
static int tea6420_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
diff --git a/drivers/media/video/ths7303.c b/drivers/media/video/ths7303.c
new file mode 100644
index 000000000000..21781f8a0e8e
--- /dev/null
+++ b/drivers/media/video/ths7303.c
@@ -0,0 +1,151 @@
+/*
+ * ths7303- THS7303 Video Amplifier driver
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed .as is. WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/ctype.h>
+#include <linux/i2c.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/uaccess.h>
+#include <linux/videodev2.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-subdev.h>
+#include <media/v4l2-chip-ident.h>
+
+MODULE_DESCRIPTION("TI THS7303 video amplifier driver");
+MODULE_AUTHOR("Chaithrika U S");
+MODULE_LICENSE("GPL");
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Debug level 0-1");
+
+/* following function is used to set ths7303 */
+static int ths7303_setvalue(struct v4l2_subdev *sd, v4l2_std_id std)
+{
+ int err = 0;
+ u8 val;
+ struct i2c_client *client;
+
+ client = v4l2_get_subdevdata(sd);
+
+ if (std & (V4L2_STD_ALL & ~V4L2_STD_SECAM)) {
+ val = 0x02;
+ v4l2_dbg(1, debug, sd, "setting value for SDTV format\n");
+ } else {
+ val = 0x00;
+ v4l2_dbg(1, debug, sd, "disabling all channels\n");
+ }
+
+ err |= i2c_smbus_write_byte_data(client, 0x01, val);
+ err |= i2c_smbus_write_byte_data(client, 0x02, val);
+ err |= i2c_smbus_write_byte_data(client, 0x03, val);
+
+ if (err)
+ v4l2_err(sd, "write failed\n");
+
+ return err;
+}
+
+static int ths7303_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm)
+{
+ return ths7303_setvalue(sd, norm);
+}
+
+static int ths7303_g_chip_ident(struct v4l2_subdev *sd,
+ struct v4l2_dbg_chip_ident *chip)
+{
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+ return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_THS7303, 0);
+}
+
+static const struct v4l2_subdev_video_ops ths7303_video_ops = {
+ .s_std_output = ths7303_s_std_output,
+};
+
+static const struct v4l2_subdev_core_ops ths7303_core_ops = {
+ .g_chip_ident = ths7303_g_chip_ident,
+};
+
+static const struct v4l2_subdev_ops ths7303_ops = {
+ .core = &ths7303_core_ops,
+ .video = &ths7303_video_ops,
+};
+
+static int ths7303_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct v4l2_subdev *sd;
+ v4l2_std_id std_id = V4L2_STD_NTSC;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+ return -ENODEV;
+
+ v4l_info(client, "chip found @ 0x%x (%s)\n",
+ client->addr << 1, client->adapter->name);
+
+ sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+ if (sd == NULL)
+ return -ENOMEM;
+
+ v4l2_i2c_subdev_init(sd, client, &ths7303_ops);
+
+ return ths7303_setvalue(sd, std_id);
+}
+
+static int ths7303_remove(struct i2c_client *client)
+{
+ struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+ v4l2_device_unregister_subdev(sd);
+ kfree(sd);
+
+ return 0;
+}
+
+static const struct i2c_device_id ths7303_id[] = {
+ {"ths7303", 0},
+ {},
+};
+
+MODULE_DEVICE_TABLE(i2c, ths7303_id);
+
+static struct i2c_driver ths7303_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "ths7303",
+ },
+ .probe = ths7303_probe,
+ .remove = ths7303_remove,
+ .id_table = ths7303_id,
+};
+
+static int __init ths7303_init(void)
+{
+ return i2c_add_driver(&ths7303_driver);
+}
+
+static void __exit ths7303_exit(void)
+{
+ i2c_del_driver(&ths7303_driver);
+}
+
+module_init(ths7303_init);
+module_exit(ths7303_exit);
+
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 78c377a399cb..1dac524fc8f1 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -309,32 +309,6 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
}
}
-static void tuner_i2c_address_check(struct tuner *t)
-{
- if ((t->type == UNSET || t->type == TUNER_ABSENT) ||
- ((t->i2c->addr < 0x64) || (t->i2c->addr > 0x6f)))
- return;
-
- /* We already know that the XC5000 can only be located at
- * i2c address 0x61, 0x62, 0x63 or 0x64 */
- if ((t->type == TUNER_XC5000) &&
- ((t->i2c->addr <= 0x64)) && (t->i2c->addr >= 0x61))
- return;
-
- tuner_warn("====================== WARNING! ======================\n");
- tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n");
- tuner_warn("will soon be dropped. This message indicates that your\n");
- tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n",
- t->name, t->i2c->addr);
- tuner_warn("To ensure continued support for your device, please\n");
- tuner_warn("send a copy of this message, along with full dmesg\n");
- tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n");
- tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n");
- tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n",
- t->i2c->adapter->name, t->i2c->addr, t->type, t->name);
- tuner_warn("====================== WARNING! ======================\n");
-}
-
static struct xc5000_config xc5000_cfg;
static void set_type(struct i2c_client *c, unsigned int type,
@@ -490,7 +464,6 @@ static void set_type(struct i2c_client *c, unsigned int type,
tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
c->adapter->name, c->driver->driver.name, c->addr << 1, type,
t->mode_mask);
- tuner_i2c_address_check(t);
return;
attach_failed:
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index e24a38c7fa46..d0de03c6e68a 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -210,7 +210,7 @@ hauppauge_tuner[] =
{ TUNER_TEA5767, "Philips TEA5768HL FM Radio"},
{ TUNER_ABSENT, "Panasonic ENV57H12D5"},
{ TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05-4"},
- { TUNER_ABSENT, "TCL MNM05-4"},
+ { TUNER_PHILIPS_FM1236_MK3, "TCL MNM05-4"},
{ TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"},
{ TUNER_ABSENT, "TCL MQNM05-4"},
{ TUNER_ABSENT, "LG TAPC-W701D"},
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index d7056a5b7f9b..d03e5922d3b8 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -541,7 +541,7 @@ static int vidioc_enum_input (struct file *file, void *priv,
struct usb_usbvision *usbvision = video_drvdata(file);
int chan;
- if ((vi->index >= usbvision->video_inputs) || (vi->index < 0) )
+ if (vi->index >= usbvision->video_inputs)
return -EINVAL;
if (usbvision->have_tuner) {
chan = vi->index;
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index 2a80caa54fb4..ad7e64ff3add 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -46,6 +46,8 @@ static int uvc_v4l2_query_menu(struct uvc_video_device *video,
struct uvc_menu_info *menu_info;
struct uvc_control_mapping *mapping;
struct uvc_control *ctrl;
+ u32 index = query_menu->index;
+ u32 id = query_menu->id;
ctrl = uvc_find_control(video, query_menu->id, &mapping);
if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU)
@@ -54,6 +56,10 @@ static int uvc_v4l2_query_menu(struct uvc_video_device *video,
if (query_menu->index >= mapping->menu_count)
return -EINVAL;
+ memset(query_menu, 0, sizeof(*query_menu));
+ query_menu->id = id;
+ query_menu->index = index;
+
menu_info = &mapping->menu_info[query_menu->index];
strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);
return 0;
@@ -648,7 +654,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
case VIDIOC_S_INPUT:
{
- u8 input = *(u32 *)arg + 1;
+ u32 input = *(u32 *)arg + 1;
if ((ret = uvc_acquire_privileges(handle)) < 0)
return ret;
@@ -660,7 +666,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
break;
}
- if (input > video->selector->selector.bNrInPins)
+ if (input == 0 || input > video->selector->selector.bNrInPins)
return -EINVAL;
return uvc_query_ctrl(video->dev, SET_CUR, video->selector->id,
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index f576ef66b807..f96475626da7 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -746,6 +746,7 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
const struct v4l2_subdev_ops *ops)
{
v4l2_subdev_init(sd, ops);
+ sd->flags |= V4L2_SUBDEV_FL_IS_I2C;
/* the owner is the same as the i2c_client's driver owner */
sd->owner = client->driver->driver.owner;
/* i2c_client and v4l2_subdev point to one another */
@@ -897,8 +898,7 @@ const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type)
};
static const unsigned short tv_addrs[] = {
0x42, 0x43, 0x4a, 0x4b, /* tda8290 */
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x60, 0x61, 0x62, 0x63, 0x64,
I2C_CLIENT_END
};
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 94aa485ade52..772833b69bbf 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -49,6 +49,22 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
}
EXPORT_SYMBOL_GPL(v4l2_device_register);
+int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
+ atomic_t *instance)
+{
+ int num = atomic_inc_return(instance) - 1;
+ int len = strlen(basename);
+
+ if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
+ snprintf(v4l2_dev->name, sizeof(v4l2_dev->name),
+ "%s-%d", basename, num);
+ else
+ snprintf(v4l2_dev->name, sizeof(v4l2_dev->name),
+ "%s%d", basename, num);
+ return num;
+}
+EXPORT_SYMBOL_GPL(v4l2_device_set_name);
+
void v4l2_device_disconnect(struct v4l2_device *v4l2_dev)
{
if (v4l2_dev->dev) {
@@ -67,8 +83,21 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
v4l2_device_disconnect(v4l2_dev);
/* Unregister subdevs */
- list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list)
+ list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list) {
v4l2_device_unregister_subdev(sd);
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+ if (sd->flags & V4L2_SUBDEV_FL_IS_I2C) {
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+ /* We need to unregister the i2c client explicitly.
+ We cannot rely on i2c_del_adapter to always
+ unregister clients for us, since if the i2c bus
+ is a platform bus, then it is never deleted. */
+ if (client)
+ i2c_unregister_device(client);
+ }
+#endif
+ }
}
EXPORT_SYMBOL_GPL(v4l2_device_unregister);
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index b7b05842cf28..48c3ebdb415f 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -439,6 +439,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
}
req->count = retval;
+ retval = 0;
done:
mutex_unlock(&q->vb_lock);
@@ -454,7 +455,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
dprintk(1, "querybuf: Wrong type.\n");
goto done;
}
- if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
+ if (unlikely(b->index >= VIDEO_MAX_FRAME)) {
dprintk(1, "querybuf: index out of range.\n");
goto done;
}
@@ -495,7 +496,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
dprintk(1, "qbuf: Wrong type.\n");
goto done;
}
- if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
+ if (b->index >= VIDEO_MAX_FRAME) {
dprintk(1, "qbuf: index out of range.\n");
goto done;
}
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index 6109fb5f34e2..08d3e17c450a 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -182,19 +182,6 @@ static int __videobuf_iolock(struct videobuf_queue *q,
return 0;
}
-static int __videobuf_sync(struct videobuf_queue *q,
- struct videobuf_buffer *buf)
-{
- struct videobuf_dma_contig_memory *mem = buf->priv;
-
- BUG_ON(!mem);
- MAGIC_CHECK(mem->magic, MAGIC_DC_MEM);
-
- dma_sync_single_for_cpu(q->dev, mem->dma_handle, mem->size,
- DMA_FROM_DEVICE);
- return 0;
-}
-
static int __videobuf_mmap_free(struct videobuf_queue *q)
{
unsigned int i;
@@ -356,7 +343,6 @@ static struct videobuf_qtype_ops qops = {
.alloc = __videobuf_alloc,
.iolock = __videobuf_iolock,
- .sync = __videobuf_sync,
.mmap_free = __videobuf_mmap_free,
.mmap_mapper = __videobuf_mmap_mapper,
.video_copy_to_user = __videobuf_copy_to_user,
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index ea6c577b0eb3..ea9de8b47db3 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -1022,7 +1022,7 @@ zr36057_init (struct zoran *zr)
zr->vbuf_bytesperline = 0;
/* Avoid nonsense settings from user for default input/norm */
- if (default_norm < 0 && default_norm > 2)
+ if (default_norm < 0 || default_norm > 2)
default_norm = 0;
if (default_norm == 0) {
zr->norm = V4L2_STD_PAL;
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index de143deb06f0..7847bbc1440d 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -672,15 +672,14 @@ try_again:
msb->req_sg);
if (!msb->seg_count) {
- chunk = __blk_end_request(msb->block_req, -ENOMEM,
- blk_rq_cur_bytes(msb->block_req));
+ chunk = __blk_end_request_cur(msb->block_req, -ENOMEM);
continue;
}
- t_sec = msb->block_req->sector << 9;
+ t_sec = blk_rq_pos(msb->block_req) << 9;
sector_div(t_sec, msb->page_size);
- count = msb->block_req->nr_sectors << 9;
+ count = blk_rq_bytes(msb->block_req);
count /= msb->page_size;
param.system = msb->system;
@@ -705,8 +704,8 @@ try_again:
return 0;
}
- dev_dbg(&card->dev, "elv_next\n");
- msb->block_req = elv_next_request(msb->queue);
+ dev_dbg(&card->dev, "blk_fetch\n");
+ msb->block_req = blk_fetch_request(msb->queue);
if (!msb->block_req) {
dev_dbg(&card->dev, "issue end\n");
return -EAGAIN;
@@ -745,7 +744,7 @@ static int mspro_block_complete_req(struct memstick_dev *card, int error)
t_len *= msb->page_size;
}
} else
- t_len = msb->block_req->nr_sectors << 9;
+ t_len = blk_rq_bytes(msb->block_req);
dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error);
@@ -825,8 +824,8 @@ static void mspro_block_submit_req(struct request_queue *q)
return;
if (msb->eject) {
- while ((req = elv_next_request(q)) != NULL)
- __blk_end_request(req, -ENODEV, blk_rq_bytes(req));
+ while ((req = blk_fetch_request(q)) != NULL)
+ __blk_end_request_all(req, -ENODEV);
return;
}
@@ -1243,7 +1242,7 @@ static int mspro_block_init_disk(struct memstick_dev *card)
sprintf(msb->disk->disk_name, "mspblk%d", disk_id);
- blk_queue_hardsect_size(msb->queue, msb->page_size);
+ blk_queue_logical_block_size(msb->queue, msb->page_size);
capacity = be16_to_cpu(sys_info->user_block_count);
capacity *= be16_to_cpu(sys_info->block_size);
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 693e4b511354..fa9249b4971a 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -130,7 +130,7 @@ mpi_ioc.h
* 08-08-01 01.02.01 Original release for v1.2 work.
* New format for FWVersion and ProductId in
* MSG_IOC_FACTS_REPLY and MPI_FW_HEADER.
- * 08-31-01 01.02.02 Addded event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
+ * 08-31-01 01.02.02 Added event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
* related structure and defines.
* Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED.
* Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE.
@@ -190,7 +190,7 @@ mpi_ioc.h
* 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED.
* Added MaxInitiators field to PortFacts reply.
* Added SAS Device Status Change ReasonCode for
- * asynchronous notificaiton.
+ * asynchronous notification.
* Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event
* data structure.
* Added new ImageType values for FWDownload and FWUpload
@@ -623,7 +623,7 @@ mpi_fc.h
* 11-02-00 01.01.01 Original release for post 1.0 work
* 12-04-00 01.01.02 Added messages for Common Transport Send and
* Primitive Send.
- * 01-09-01 01.01.03 Modifed some of the new flags to have an MPI prefix
+ * 01-09-01 01.01.03 Modified some of the new flags to have an MPI prefix
* and modified the FcPrimitiveSend flags.
* 01-25-01 01.01.04 Move InitiatorIndex in LinkServiceRsp reply to a larger
* field.
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index a9019f081b97..79f5433359f9 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1277,8 +1277,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
/* do we need to support multiple segments? */
if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n",
- ioc->name, __func__, req->bio->bi_vcnt, req->data_len,
- rsp->bio->bi_vcnt, rsp->data_len);
+ ioc->name, __func__, req->bio->bi_vcnt, blk_rq_bytes(req),
+ rsp->bio->bi_vcnt, blk_rq_bytes(rsp));
return -EINVAL;
}
@@ -1295,7 +1295,7 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
smpreq = (SmpPassthroughRequest_t *)mf;
memset(smpreq, 0, sizeof(*smpreq));
- smpreq->RequestDataLength = cpu_to_le16(req->data_len - 4);
+ smpreq->RequestDataLength = cpu_to_le16(blk_rq_bytes(req) - 4);
smpreq->Function = MPI_FUNCTION_SMP_PASSTHROUGH;
if (rphy)
@@ -1321,10 +1321,10 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
MPI_SGE_FLAGS_END_OF_BUFFER |
MPI_SGE_FLAGS_DIRECTION |
mpt_addr_size()) << MPI_SGE_FLAGS_SHIFT;
- flagsLength |= (req->data_len - 4);
+ flagsLength |= (blk_rq_bytes(req) - 4);
dma_addr_out = pci_map_single(ioc->pcidev, bio_data(req->bio),
- req->data_len, PCI_DMA_BIDIRECTIONAL);
+ blk_rq_bytes(req), PCI_DMA_BIDIRECTIONAL);
if (!dma_addr_out)
goto put_mf;
mpt_add_sge(psge, flagsLength, dma_addr_out);
@@ -1332,9 +1332,9 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
/* response */
flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ;
- flagsLength |= rsp->data_len + 4;
+ flagsLength |= blk_rq_bytes(rsp) + 4;
dma_addr_in = pci_map_single(ioc->pcidev, bio_data(rsp->bio),
- rsp->data_len, PCI_DMA_BIDIRECTIONAL);
+ blk_rq_bytes(rsp), PCI_DMA_BIDIRECTIONAL);
if (!dma_addr_in)
goto unmap;
mpt_add_sge(psge, flagsLength, dma_addr_in);
@@ -1357,8 +1357,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
memcpy(req->sense, smprep, sizeof(*smprep));
req->sense_len = sizeof(*smprep);
- req->data_len = 0;
- rsp->data_len -= smprep->ResponseDataLength;
+ req->resid_len = 0;
+ rsp->resid_len -= smprep->ResponseDataLength;
} else {
printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",
ioc->name, __func__);
@@ -1366,10 +1366,10 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
}
unmap:
if (dma_addr_out)
- pci_unmap_single(ioc->pcidev, dma_addr_out, req->data_len,
+ pci_unmap_single(ioc->pcidev, dma_addr_out, blk_rq_bytes(req),
PCI_DMA_BIDIRECTIONAL);
if (dma_addr_in)
- pci_unmap_single(ioc->pcidev, dma_addr_in, rsp->data_len,
+ pci_unmap_single(ioc->pcidev, dma_addr_in, blk_rq_bytes(rsp),
PCI_DMA_BIDIRECTIONAL);
put_mf:
if (mf)
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index a443e136dc41..335d4c78a775 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -426,15 +426,9 @@ static void i2o_block_end_request(struct request *req, int error,
struct request_queue *q = req->q;
unsigned long flags;
- if (blk_end_request(req, error, nr_bytes)) {
- int leftover = (req->hard_nr_sectors << KERNEL_SECTOR_SHIFT);
-
- if (blk_pc_request(req))
- leftover = req->data_len;
-
+ if (blk_end_request(req, error, nr_bytes))
if (error)
- blk_end_request(req, -EIO, leftover);
- }
+ blk_end_request_all(req, -EIO);
spin_lock_irqsave(q->queue_lock, flags);
@@ -761,7 +755,7 @@ static int i2o_block_transfer(struct request *req)
break;
case CACHE_SMARTFETCH:
- if (req->nr_sectors > 16)
+ if (blk_rq_sectors(req) > 16)
ctl_flags = 0x201F0008;
else
ctl_flags = 0x001F0000;
@@ -781,13 +775,13 @@ static int i2o_block_transfer(struct request *req)
ctl_flags = 0x001F0010;
break;
case CACHE_SMARTBACK:
- if (req->nr_sectors > 16)
+ if (blk_rq_sectors(req) > 16)
ctl_flags = 0x001F0004;
else
ctl_flags = 0x001F0010;
break;
case CACHE_SMARTTHROUGH:
- if (req->nr_sectors > 16)
+ if (blk_rq_sectors(req) > 16)
ctl_flags = 0x001F0004;
else
ctl_flags = 0x001F0010;
@@ -800,8 +794,9 @@ static int i2o_block_transfer(struct request *req)
if (c->adaptec) {
u8 cmd[10];
u32 scsi_flags;
- u16 hwsec = queue_hardsect_size(req->q) >> KERNEL_SECTOR_SHIFT;
+ u16 hwsec;
+ hwsec = queue_logical_block_size(req->q) >> KERNEL_SECTOR_SHIFT;
memset(cmd, 0, 10);
sgl_offset = SGL_OFFSET_12;
@@ -827,22 +822,22 @@ static int i2o_block_transfer(struct request *req)
*mptr++ = cpu_to_le32(scsi_flags);
- *((u32 *) & cmd[2]) = cpu_to_be32(req->sector * hwsec);
- *((u16 *) & cmd[7]) = cpu_to_be16(req->nr_sectors * hwsec);
+ *((u32 *) & cmd[2]) = cpu_to_be32(blk_rq_pos(req) * hwsec);
+ *((u16 *) & cmd[7]) = cpu_to_be16(blk_rq_sectors(req) * hwsec);
memcpy(mptr, cmd, 10);
mptr += 4;
- *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT);
+ *mptr++ = cpu_to_le32(blk_rq_bytes(req));
} else
#endif
{
msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
*mptr++ = cpu_to_le32(ctl_flags);
- *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT);
+ *mptr++ = cpu_to_le32(blk_rq_bytes(req));
*mptr++ =
- cpu_to_le32((u32) (req->sector << KERNEL_SECTOR_SHIFT));
+ cpu_to_le32((u32) (blk_rq_pos(req) << KERNEL_SECTOR_SHIFT));
*mptr++ =
- cpu_to_le32(req->sector >> (32 - KERNEL_SECTOR_SHIFT));
+ cpu_to_le32(blk_rq_pos(req) >> (32 - KERNEL_SECTOR_SHIFT));
}
if (!i2o_block_sglist_alloc(c, ireq, &mptr)) {
@@ -883,7 +878,7 @@ static void i2o_block_request_fn(struct request_queue *q)
struct request *req;
while (!blk_queue_plugged(q)) {
- req = elv_next_request(q);
+ req = blk_peek_request(q);
if (!req)
break;
@@ -896,7 +891,7 @@ static void i2o_block_request_fn(struct request_queue *q)
if (queue_depth < I2O_BLOCK_MAX_OPEN_REQUESTS) {
if (!i2o_block_transfer(req)) {
- blkdev_dequeue_request(req);
+ blk_start_request(req);
continue;
} else
osm_info("transfer error\n");
@@ -922,8 +917,10 @@ static void i2o_block_request_fn(struct request_queue *q)
blk_stop_queue(q);
break;
}
- } else
- end_request(req, 0);
+ } else {
+ blk_start_request(req);
+ __blk_end_request_all(req, -EIO);
+ }
}
};
@@ -1082,7 +1079,7 @@ static int i2o_block_probe(struct device *dev)
*/
if (!i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) ||
!i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) {
- blk_queue_hardsect_size(queue, le32_to_cpu(blocksize));
+ blk_queue_logical_block_size(queue, le32_to_cpu(blocksize));
} else
osm_warn("unable to get blocksize of %s\n", gd->disk_name);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index ee3927ab11e0..61f0346650b3 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -241,6 +241,20 @@ config PCF50633_GPIO
Say yes here if you want to include support GPIO for pins on
the PCF50633 chip.
+config AB3100_CORE
+ tristate "ST-Ericsson AB3100 Mixed Signal Circuit core functions"
+ depends on I2C
+ default y if ARCH_U300
+ help
+ Select this to enable the AB3100 Mixed Signal IC core
+ functionality. This connects to a AB3100 on the I2C bus
+ and expose a number of symbols needed for dependent devices
+ to read and write registers and subscribe to events from
+ this multi-functional IC. This is needed to use other features
+ of the AB3100 such as battery-backed RTC, charging control,
+ LEDs, vibrator, system power and temperature, power management
+ and ALSA sound.
+
endmenu
menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 3afb5192e4da..f5f337143e69 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -40,4 +40,5 @@ obj-$(CONFIG_PMIC_DA903X) += da903x.o
obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
-obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o \ No newline at end of file
+obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o
+obj-$(CONFIG_AB3100_CORE) += ab3100-core.o
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
new file mode 100755
index 000000000000..13e7d7bfe85f
--- /dev/null
+++ b/drivers/mfd/ab3100-core.c
@@ -0,0 +1,991 @@
+/*
+ * Copyright (C) 2007-2009 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ * Low-level core for exclusive access to the AB3100 IC on the I2C bus
+ * and some basic chip-configuration.
+ * Author: Linus Walleij <linus.walleij@stericsson.com>
+ */
+
+#include <linux/i2c.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/notifier.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/workqueue.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/uaccess.h>
+#include <linux/mfd/ab3100.h>
+
+/* These are the only registers inside AB3100 used in this main file */
+
+/* Interrupt event registers */
+#define AB3100_EVENTA1 0x21
+#define AB3100_EVENTA2 0x22
+#define AB3100_EVENTA3 0x23
+
+/* AB3100 DAC converter registers */
+#define AB3100_DIS 0x00
+#define AB3100_D0C 0x01
+#define AB3100_D1C 0x02
+#define AB3100_D2C 0x03
+#define AB3100_D3C 0x04
+
+/* Chip ID register */
+#define AB3100_CID 0x20
+
+/* AB3100 interrupt registers */
+#define AB3100_IMRA1 0x24
+#define AB3100_IMRA2 0x25
+#define AB3100_IMRA3 0x26
+#define AB3100_IMRB1 0x2B
+#define AB3100_IMRB2 0x2C
+#define AB3100_IMRB3 0x2D
+
+/* System Power Monitoring and control registers */
+#define AB3100_MCA 0x2E
+#define AB3100_MCB 0x2F
+
+/* SIM power up */
+#define AB3100_SUP 0x50
+
+/*
+ * I2C communication
+ *
+ * The AB3100 is usually assigned address 0x48 (7-bit)
+ * The chip is defined in the platform i2c_board_data section.
+ */
+static unsigned short normal_i2c[] = { 0x48, I2C_CLIENT_END };
+I2C_CLIENT_INSMOD_1(ab3100);
+
+u8 ab3100_get_chip_type(struct ab3100 *ab3100)
+{
+ u8 chip = ABUNKNOWN;
+
+ switch (ab3100->chip_id & 0xf0) {
+ case 0xa0:
+ chip = AB3000;
+ break;
+ case 0xc0:
+ chip = AB3100;
+ break;
+ }
+ return chip;
+}
+EXPORT_SYMBOL(ab3100_get_chip_type);
+
+int ab3100_set_register(struct ab3100 *ab3100, u8 reg, u8 regval)
+{
+ u8 regandval[2] = {reg, regval};
+ int err;
+
+ err = mutex_lock_interruptible(&ab3100->access_mutex);
+ if (err)
+ return err;
+
+ /*
+ * A two-byte write message with the first byte containing the register
+ * number and the second byte containing the value to be written
+ * effectively sets a register in the AB3100.
+ */
+ err = i2c_master_send(ab3100->i2c_client, regandval, 2);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (write register): %d\n",
+ err);
+ } else if (err != 2) {
+ dev_err(ab3100->dev,
+ "write error (write register) "
+ "%d bytes transferred (expected 2)\n",
+ err);
+ err = -EIO;
+ } else {
+ /* All is well */
+ err = 0;
+ }
+ mutex_unlock(&ab3100->access_mutex);
+ return 0;
+}
+EXPORT_SYMBOL(ab3100_set_register);
+
+/*
+ * The test registers exist at an I2C bus address up one
+ * from the ordinary base. They are not supposed to be used
+ * in production code, but sometimes you have to do that
+ * anyway. It's currently only used from this file so declare
+ * it static and do not export.
+ */
+static int ab3100_set_test_register(struct ab3100 *ab3100,
+ u8 reg, u8 regval)
+{
+ u8 regandval[2] = {reg, regval};
+ int err;
+
+ err = mutex_lock_interruptible(&ab3100->access_mutex);
+ if (err)
+ return err;
+
+ err = i2c_master_send(ab3100->testreg_client, regandval, 2);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (write test register): %d\n",
+ err);
+ } else if (err != 2) {
+ dev_err(ab3100->dev,
+ "write error (write test register) "
+ "%d bytes transferred (expected 2)\n",
+ err);
+ err = -EIO;
+ } else {
+ /* All is well */
+ err = 0;
+ }
+ mutex_unlock(&ab3100->access_mutex);
+
+ return err;
+}
+
+int ab3100_get_register(struct ab3100 *ab3100, u8 reg, u8 *regval)
+{
+ int err;
+
+ err = mutex_lock_interruptible(&ab3100->access_mutex);
+ if (err)
+ return err;
+
+ /*
+ * AB3100 require an I2C "stop" command between each message, else
+ * it will not work. The only way of achieveing this with the
+ * message transport layer is to send the read and write messages
+ * separately.
+ */
+ err = i2c_master_send(ab3100->i2c_client, &reg, 1);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (send register address): %d\n",
+ err);
+ goto get_reg_out_unlock;
+ } else if (err != 1) {
+ dev_err(ab3100->dev,
+ "write error (send register address) "
+ "%d bytes transferred (expected 1)\n",
+ err);
+ err = -EIO;
+ goto get_reg_out_unlock;
+ } else {
+ /* All is well */
+ err = 0;
+ }
+
+ err = i2c_master_recv(ab3100->i2c_client, regval, 1);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (read register): %d\n",
+ err);
+ goto get_reg_out_unlock;
+ } else if (err != 1) {
+ dev_err(ab3100->dev,
+ "write error (read register) "
+ "%d bytes transferred (expected 1)\n",
+ err);
+ err = -EIO;
+ goto get_reg_out_unlock;
+ } else {
+ /* All is well */
+ err = 0;
+ }
+
+ get_reg_out_unlock:
+ mutex_unlock(&ab3100->access_mutex);
+ return err;
+}
+EXPORT_SYMBOL(ab3100_get_register);
+
+int ab3100_get_register_page(struct ab3100 *ab3100,
+ u8 first_reg, u8 *regvals, u8 numregs)
+{
+ int err;
+
+ if (ab3100->chip_id == 0xa0 ||
+ ab3100->chip_id == 0xa1)
+ /* These don't support paged reads */
+ return -EIO;
+
+ err = mutex_lock_interruptible(&ab3100->access_mutex);
+ if (err)
+ return err;
+
+ /*
+ * Paged read also require an I2C "stop" command.
+ */
+ err = i2c_master_send(ab3100->i2c_client, &first_reg, 1);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (send first register address): %d\n",
+ err);
+ goto get_reg_page_out_unlock;
+ } else if (err != 1) {
+ dev_err(ab3100->dev,
+ "write error (send first register address) "
+ "%d bytes transferred (expected 1)\n",
+ err);
+ err = -EIO;
+ goto get_reg_page_out_unlock;
+ }
+
+ err = i2c_master_recv(ab3100->i2c_client, regvals, numregs);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (read register page): %d\n",
+ err);
+ goto get_reg_page_out_unlock;
+ } else if (err != numregs) {
+ dev_err(ab3100->dev,
+ "write error (read register page) "
+ "%d bytes transferred (expected %d)\n",
+ err, numregs);
+ err = -EIO;
+ goto get_reg_page_out_unlock;
+ }
+
+ /* All is well */
+ err = 0;
+
+ get_reg_page_out_unlock:
+ mutex_unlock(&ab3100->access_mutex);
+ return err;
+}
+EXPORT_SYMBOL(ab3100_get_register_page);
+
+int ab3100_mask_and_set_register(struct ab3100 *ab3100,
+ u8 reg, u8 andmask, u8 ormask)
+{
+ u8 regandval[2] = {reg, 0};
+ int err;
+
+ err = mutex_lock_interruptible(&ab3100->access_mutex);
+ if (err)
+ return err;
+
+ /* First read out the target register */
+ err = i2c_master_send(ab3100->i2c_client, &reg, 1);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (maskset send address): %d\n",
+ err);
+ goto get_maskset_unlock;
+ } else if (err != 1) {
+ dev_err(ab3100->dev,
+ "write error (maskset send address) "
+ "%d bytes transferred (expected 1)\n",
+ err);
+ err = -EIO;
+ goto get_maskset_unlock;
+ }
+
+ err = i2c_master_recv(ab3100->i2c_client, &regandval[1], 1);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (maskset read register): %d\n",
+ err);
+ goto get_maskset_unlock;
+ } else if (err != 1) {
+ dev_err(ab3100->dev,
+ "write error (maskset read register) "
+ "%d bytes transferred (expected 1)\n",
+ err);
+ err = -EIO;
+ goto get_maskset_unlock;
+ }
+
+ /* Modify the register */
+ regandval[1] &= andmask;
+ regandval[1] |= ormask;
+
+ /* Write the register */
+ err = i2c_master_send(ab3100->i2c_client, regandval, 2);
+ if (err < 0) {
+ dev_err(ab3100->dev,
+ "write error (write register): %d\n",
+ err);
+ goto get_maskset_unlock;
+ } else if (err != 2) {
+ dev_err(ab3100->dev,
+ "write error (write register) "
+ "%d bytes transferred (expected 2)\n",
+ err);
+ err = -EIO;
+ goto get_maskset_unlock;
+ }
+
+ /* All is well */
+ err = 0;
+
+ get_maskset_unlock:
+ mutex_unlock(&ab3100->access_mutex);
+ return err;
+}
+EXPORT_SYMBOL(ab3100_mask_and_set_register);
+
+/*
+ * Register a simple callback for handling any AB3100 events.
+ */
+int ab3100_event_register(struct ab3100 *ab3100,
+ struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&ab3100->event_subscribers,
+ nb);
+}
+EXPORT_SYMBOL(ab3100_event_register);
+
+/*
+ * Remove a previously registered callback.
+ */
+int ab3100_event_unregister(struct ab3100 *ab3100,
+ struct notifier_block *nb)
+{
+ return blocking_notifier_chain_unregister(&ab3100->event_subscribers,
+ nb);
+}
+EXPORT_SYMBOL(ab3100_event_unregister);
+
+
+int ab3100_event_registers_startup_state_get(struct ab3100 *ab3100,
+ u32 *fatevent)
+{
+ if (!ab3100->startup_events_read)
+ return -EAGAIN; /* Try again later */
+ *fatevent = ab3100->startup_events;
+ return 0;
+}
+EXPORT_SYMBOL(ab3100_event_registers_startup_state_get);
+
+/* Interrupt handling worker */
+static void ab3100_work(struct work_struct *work)
+{
+ struct ab3100 *ab3100 = container_of(work, struct ab3100, work);
+ u8 event_regs[3];
+ u32 fatevent;
+ int err;
+
+ err = ab3100_get_register_page(ab3100, AB3100_EVENTA1,
+ event_regs, 3);
+ if (err)
+ goto err_event_wq;
+
+ fatevent = (event_regs[0] << 16) |
+ (event_regs[1] << 8) |
+ event_regs[2];
+
+ if (!ab3100->startup_events_read) {
+ ab3100->startup_events = fatevent;
+ ab3100->startup_events_read = true;
+ }
+ /*
+ * The notified parties will have to mask out the events
+ * they're interested in and react to them. They will be
+ * notified on all events, then they use the fatevent value
+ * to determine if they're interested.
+ */
+ blocking_notifier_call_chain(&ab3100->event_subscribers,
+ fatevent, NULL);
+
+ dev_dbg(ab3100->dev,
+ "IRQ Event: 0x%08x\n", fatevent);
+
+ /* By now the IRQ should be acked and deasserted so enable it again */
+ enable_irq(ab3100->i2c_client->irq);
+ return;
+
+ err_event_wq:
+ dev_dbg(ab3100->dev,
+ "error in event workqueue\n");
+ /* Enable the IRQ anyway, what choice do we have? */
+ enable_irq(ab3100->i2c_client->irq);
+ return;
+}
+
+static irqreturn_t ab3100_irq_handler(int irq, void *data)
+{
+ struct ab3100 *ab3100 = data;
+ /*
+ * Disable the IRQ and dispatch a worker to handle the
+ * event. Since the chip resides on I2C this is slow
+ * stuff and we will re-enable the interrupts once th
+ * worker has finished.
+ */
+ disable_irq(ab3100->i2c_client->irq);
+ schedule_work(&ab3100->work);
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_DEBUG_FS
+/*
+ * Some debugfs entries only exposed if we're using debug
+ */
+static int ab3100_registers_print(struct seq_file *s, void *p)
+{
+ struct ab3100 *ab3100 = s->private;
+ u8 value;
+ u8 reg;
+
+ seq_printf(s, "AB3100 registers:\n");
+
+ for (reg = 0; reg < 0xff; reg++) {
+ ab3100_get_register(ab3100, reg, &value);
+ seq_printf(s, "[0x%x]: 0x%x\n", reg, value);
+ }
+ return 0;
+}
+
+static int ab3100_registers_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ab3100_registers_print, inode->i_private);
+}
+
+static const struct file_operations ab3100_registers_fops = {
+ .open = ab3100_registers_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .owner = THIS_MODULE,
+};
+
+struct ab3100_get_set_reg_priv {
+ struct ab3100 *ab3100;
+ bool mode;
+};
+
+static int ab3100_get_set_reg_open_file(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
+}
+
+static int ab3100_get_set_reg(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ab3100_get_set_reg_priv *priv = file->private_data;
+ struct ab3100 *ab3100 = priv->ab3100;
+ char buf[32];
+ int buf_size;
+ int regp;
+ unsigned long user_reg;
+ int err;
+ int i = 0;
+
+ /* Get userspace string and assure termination */
+ buf_size = min(count, (sizeof(buf)-1));
+ if (copy_from_user(buf, user_buf, buf_size))
+ return -EFAULT;
+ buf[buf_size] = 0;
+
+ /*
+ * The idea is here to parse a string which is either
+ * "0xnn" for reading a register, or "0xaa 0xbb" for
+ * writing 0xbb to the register 0xaa. First move past
+ * whitespace and then begin to parse the register.
+ */
+ while ((i < buf_size) && (buf[i] == ' '))
+ i++;
+ regp = i;
+
+ /*
+ * Advance pointer to end of string then terminate
+ * the register string. This is needed to satisfy
+ * the strict_strtoul() function.
+ */
+ while ((i < buf_size) && (buf[i] != ' '))
+ i++;
+ buf[i] = '\0';
+
+ err = strict_strtoul(&buf[regp], 16, &user_reg);
+ if (err)
+ return err;
+ if (user_reg > 0xff)
+ return -EINVAL;
+
+ /* Either we read or we write a register here */
+ if (!priv->mode) {
+ /* Reading */
+ u8 reg = (u8) user_reg;
+ u8 regvalue;
+
+ ab3100_get_register(ab3100, reg, &regvalue);
+
+ dev_info(ab3100->dev,
+ "debug read AB3100 reg[0x%02x]: 0x%02x\n",
+ reg, regvalue);
+ } else {
+ int valp;
+ unsigned long user_value;
+ u8 reg = (u8) user_reg;
+ u8 value;
+ u8 regvalue;
+
+ /*
+ * Writing, we need some value to write to
+ * the register so keep parsing the string
+ * from userspace.
+ */
+ i++;
+ while ((i < buf_size) && (buf[i] == ' '))
+ i++;
+ valp = i;
+ while ((i < buf_size) && (buf[i] != ' '))
+ i++;
+ buf[i] = '\0';
+
+ err = strict_strtoul(&buf[valp], 16, &user_value);
+ if (err)
+ return err;
+ if (user_reg > 0xff)
+ return -EINVAL;
+
+ value = (u8) user_value;
+ ab3100_set_register(ab3100, reg, value);
+ ab3100_get_register(ab3100, reg, &regvalue);
+
+ dev_info(ab3100->dev,
+ "debug write reg[0x%02x] with 0x%02x, "
+ "after readback: 0x%02x\n",
+ reg, value, regvalue);
+ }
+ return buf_size;
+}
+
+static const struct file_operations ab3100_get_set_reg_fops = {
+ .open = ab3100_get_set_reg_open_file,
+ .write = ab3100_get_set_reg,
+};
+
+static struct dentry *ab3100_dir;
+static struct dentry *ab3100_reg_file;
+static struct ab3100_get_set_reg_priv ab3100_get_priv;
+static struct dentry *ab3100_get_reg_file;
+static struct ab3100_get_set_reg_priv ab3100_set_priv;
+static struct dentry *ab3100_set_reg_file;
+
+static void ab3100_setup_debugfs(struct ab3100 *ab3100)
+{
+ int err;
+
+ ab3100_dir = debugfs_create_dir("ab3100", NULL);
+ if (!ab3100_dir)
+ goto exit_no_debugfs;
+
+ ab3100_reg_file = debugfs_create_file("registers",
+ S_IRUGO, ab3100_dir, ab3100,
+ &ab3100_registers_fops);
+ if (!ab3100_reg_file) {
+ err = -ENOMEM;
+ goto exit_destroy_dir;
+ }
+
+ ab3100_get_priv.ab3100 = ab3100;
+ ab3100_get_priv.mode = false;
+ ab3100_get_reg_file = debugfs_create_file("get_reg",
+ S_IWUGO, ab3100_dir, &ab3100_get_priv,
+ &ab3100_get_set_reg_fops);
+ if (!ab3100_get_reg_file) {
+ err = -ENOMEM;
+ goto exit_destroy_reg;
+ }
+
+ ab3100_set_priv.ab3100 = ab3100;
+ ab3100_set_priv.mode = true;
+ ab3100_set_reg_file = debugfs_create_file("set_reg",
+ S_IWUGO, ab3100_dir, &ab3100_set_priv,
+ &ab3100_get_set_reg_fops);
+ if (!ab3100_set_reg_file) {
+ err = -ENOMEM;
+ goto exit_destroy_get_reg;
+ }
+ return;
+
+ exit_destroy_get_reg:
+ debugfs_remove(ab3100_get_reg_file);
+ exit_destroy_reg:
+ debugfs_remove(ab3100_reg_file);
+ exit_destroy_dir:
+ debugfs_remove(ab3100_dir);
+ exit_no_debugfs:
+ return;
+}
+static inline void ab3100_remove_debugfs(void)
+{
+ debugfs_remove(ab3100_set_reg_file);
+ debugfs_remove(ab3100_get_reg_file);
+ debugfs_remove(ab3100_reg_file);
+ debugfs_remove(ab3100_dir);
+}
+#else
+static inline void ab3100_setup_debugfs(struct ab3100 *ab3100)
+{
+}
+static inline void ab3100_remove_debugfs(void)
+{
+}
+#endif
+
+/*
+ * Basic set-up, datastructure creation/destruction and I2C interface.
+ * This sets up a default config in the AB3100 chip so that it
+ * will work as expected.
+ */
+
+struct ab3100_init_setting {
+ u8 abreg;
+ u8 setting;
+};
+
+static const struct ab3100_init_setting __initdata
+ab3100_init_settings[] = {
+ {
+ .abreg = AB3100_MCA,
+ .setting = 0x01
+ }, {
+ .abreg = AB3100_MCB,
+ .setting = 0x30
+ }, {
+ .abreg = AB3100_IMRA1,
+ .setting = 0x00
+ }, {
+ .abreg = AB3100_IMRA2,
+ .setting = 0xFF
+ }, {
+ .abreg = AB3100_IMRA3,
+ .setting = 0x01
+ }, {
+ .abreg = AB3100_IMRB1,
+ .setting = 0xFF
+ }, {
+ .abreg = AB3100_IMRB2,
+ .setting = 0xFF
+ }, {
+ .abreg = AB3100_IMRB3,
+ .setting = 0xFF
+ }, {
+ .abreg = AB3100_SUP,
+ .setting = 0x00
+ }, {
+ .abreg = AB3100_DIS,
+ .setting = 0xF0
+ }, {
+ .abreg = AB3100_D0C,
+ .setting = 0x00
+ }, {
+ .abreg = AB3100_D1C,
+ .setting = 0x00
+ }, {
+ .abreg = AB3100_D2C,
+ .setting = 0x00
+ }, {
+ .abreg = AB3100_D3C,
+ .setting = 0x00
+ },
+};
+
+static int __init ab3100_setup(struct ab3100 *ab3100)
+{
+ int err = 0;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(ab3100_init_settings); i++) {
+ err = ab3100_set_register(ab3100,
+ ab3100_init_settings[i].abreg,
+ ab3100_init_settings[i].setting);
+ if (err)
+ goto exit_no_setup;
+ }
+
+ /*
+ * Special trick to make the AB3100 use the 32kHz clock (RTC)
+ * bit 3 in test registe 0x02 is a special, undocumented test
+ * register bit that only exist in AB3100 P1E
+ */
+ if (ab3100->chip_id == 0xc4) {
+ dev_warn(ab3100->dev,
+ "AB3100 P1E variant detected, "
+ "forcing chip to 32KHz\n");
+ err = ab3100_set_test_register(ab3100, 0x02, 0x08);
+ }
+
+ exit_no_setup:
+ return err;
+}
+
+/*
+ * Here we define all the platform devices that appear
+ * as children of the AB3100. These are regular platform
+ * devices with the IORESOURCE_IO .start and .end set
+ * to correspond to the internal AB3100 register range
+ * mapping to the corresponding subdevice.
+ */
+
+#define AB3100_DEVICE(devname, devid) \
+static struct platform_device ab3100_##devname##_device = { \
+ .name = devid, \
+ .id = -1, \
+}
+
+/*
+ * This lists all the subdevices and corresponding register
+ * ranges.
+ */
+AB3100_DEVICE(dac, "ab3100-dac");
+AB3100_DEVICE(leds, "ab3100-leds");
+AB3100_DEVICE(power, "ab3100-power");
+AB3100_DEVICE(regulators, "ab3100-regulators");
+AB3100_DEVICE(sim, "ab3100-sim");
+AB3100_DEVICE(uart, "ab3100-uart");
+AB3100_DEVICE(rtc, "ab3100-rtc");
+AB3100_DEVICE(charger, "ab3100-charger");
+AB3100_DEVICE(boost, "ab3100-boost");
+AB3100_DEVICE(adc, "ab3100-adc");
+AB3100_DEVICE(fuelgauge, "ab3100-fuelgauge");
+AB3100_DEVICE(vibrator, "ab3100-vibrator");
+AB3100_DEVICE(otp, "ab3100-otp");
+AB3100_DEVICE(codec, "ab3100-codec");
+
+static struct platform_device *
+ab3100_platform_devs[] = {
+ &ab3100_dac_device,
+ &ab3100_leds_device,
+ &ab3100_power_device,
+ &ab3100_regulators_device,
+ &ab3100_sim_device,
+ &ab3100_uart_device,
+ &ab3100_rtc_device,
+ &ab3100_charger_device,
+ &ab3100_boost_device,
+ &ab3100_adc_device,
+ &ab3100_fuelgauge_device,
+ &ab3100_vibrator_device,
+ &ab3100_otp_device,
+ &ab3100_codec_device,
+};
+
+struct ab_family_id {
+ u8 id;
+ char *name;
+};
+
+static const struct ab_family_id ids[] __initdata = {
+ /* AB3100 */
+ {
+ .id = 0xc0,
+ .name = "P1A"
+ }, {
+ .id = 0xc1,
+ .name = "P1B"
+ }, {
+ .id = 0xc2,
+ .name = "P1C"
+ }, {
+ .id = 0xc3,
+ .name = "P1D"
+ }, {
+ .id = 0xc4,
+ .name = "P1E"
+ }, {
+ .id = 0xc5,
+ .name = "P1F/R1A"
+ }, {
+ .id = 0xc6,
+ .name = "P1G/R1A"
+ }, {
+ .id = 0xc7,
+ .name = "P2A/R2A"
+ }, {
+ .id = 0xc8,
+ .name = "P2B/R2B"
+ },
+ /* AB3000 variants, not supported */
+ {
+ .id = 0xa0
+ }, {
+ .id = 0xa1
+ }, {
+ .id = 0xa2
+ }, {
+ .id = 0xa3
+ }, {
+ .id = 0xa4
+ }, {
+ .id = 0xa5
+ }, {
+ .id = 0xa6
+ }, {
+ .id = 0xa7
+ },
+ /* Terminator */
+ {
+ .id = 0x00,
+ },
+};
+
+static int __init ab3100_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct ab3100 *ab3100;
+ int err;
+ int i;
+
+ ab3100 = kzalloc(sizeof(struct ab3100), GFP_KERNEL);
+ if (!ab3100) {
+ dev_err(&client->dev, "could not allocate AB3100 device\n");
+ return -ENOMEM;
+ }
+
+ /* Initialize data structure */
+ mutex_init(&ab3100->access_mutex);
+ BLOCKING_INIT_NOTIFIER_HEAD(&ab3100->event_subscribers);
+
+ ab3100->i2c_client = client;
+ ab3100->dev = &ab3100->i2c_client->dev;
+
+ i2c_set_clientdata(client, ab3100);
+
+ /* Read chip ID register */
+ err = ab3100_get_register(ab3100, AB3100_CID,
+ &ab3100->chip_id);
+ if (err) {
+ dev_err(&client->dev,
+ "could not communicate with the AB3100 analog "
+ "baseband chip\n");
+ goto exit_no_detect;
+ }
+
+ for (i = 0; ids[i].id != 0x0; i++) {
+ if (ids[i].id == ab3100->chip_id) {
+ if (ids[i].name != NULL) {
+ snprintf(&ab3100->chip_name[0],
+ sizeof(ab3100->chip_name) - 1,
+ "AB3100 %s",
+ ids[i].name);
+ break;
+ } else {
+ dev_err(&client->dev,
+ "AB3000 is not supported\n");
+ goto exit_no_detect;
+ }
+ }
+ }
+
+ if (ids[i].id == 0x0) {
+ dev_err(&client->dev, "unknown analog baseband chip id: 0x%x\n",
+ ab3100->chip_id);
+ dev_err(&client->dev, "accepting it anyway. Please update "
+ "the driver.\n");
+ goto exit_no_detect;
+ }
+
+ dev_info(&client->dev, "Detected chip: %s\n",
+ &ab3100->chip_name[0]);
+
+ /* Attach a second dummy i2c_client to the test register address */
+ ab3100->testreg_client = i2c_new_dummy(client->adapter,
+ client->addr + 1);
+ if (!ab3100->testreg_client) {
+ err = -ENOMEM;
+ goto exit_no_testreg_client;
+ }
+
+ strlcpy(ab3100->testreg_client->name, id->name,
+ sizeof(ab3100->testreg_client->name));
+
+ err = ab3100_setup(ab3100);
+ if (err)
+ goto exit_no_setup;
+
+ INIT_WORK(&ab3100->work, ab3100_work);
+
+ /* This real unpredictable IRQ is of course sampled for entropy */
+ err = request_irq(client->irq, ab3100_irq_handler,
+ IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
+ "AB3100 IRQ", ab3100);
+ if (err)
+ goto exit_no_irq;
+
+ /* Set parent and a pointer back to the container in device data */
+ for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) {
+ ab3100_platform_devs[i]->dev.parent =
+ &client->dev;
+ platform_set_drvdata(ab3100_platform_devs[i], ab3100);
+ }
+
+ /* Register the platform devices */
+ platform_add_devices(ab3100_platform_devs,
+ ARRAY_SIZE(ab3100_platform_devs));
+
+ ab3100_setup_debugfs(ab3100);
+
+ return 0;
+
+ exit_no_irq:
+ exit_no_setup:
+ i2c_unregister_device(ab3100->testreg_client);
+ exit_no_testreg_client:
+ exit_no_detect:
+ kfree(ab3100);
+ return err;
+}
+
+static int __exit ab3100_remove(struct i2c_client *client)
+{
+ struct ab3100 *ab3100 = i2c_get_clientdata(client);
+ int i;
+
+ /* Unregister subdevices */
+ for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++)
+ platform_device_unregister(ab3100_platform_devs[i]);
+
+ ab3100_remove_debugfs();
+ i2c_unregister_device(ab3100->testreg_client);
+
+ /*
+ * At this point, all subscribers should have unregistered
+ * their notifiers so deactivate IRQ
+ */
+ free_irq(client->irq, ab3100);
+ kfree(ab3100);
+ return 0;
+}
+
+static const struct i2c_device_id ab3100_id[] = {
+ { "ab3100", ab3100 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, ab3100_id);
+
+static struct i2c_driver ab3100_driver = {
+ .driver = {
+ .name = "ab3100",
+ .owner = THIS_MODULE,
+ },
+ .id_table = ab3100_id,
+ .probe = ab3100_probe,
+ .remove = __exit_p(ab3100_remove),
+};
+
+static int __init ab3100_i2c_init(void)
+{
+ return i2c_add_driver(&ab3100_driver);
+}
+
+static void __exit ab3100_i2c_exit(void)
+{
+ i2c_del_driver(&ab3100_driver);
+}
+
+subsys_initcall(ab3100_i2c_init);
+module_exit(ab3100_i2c_exit);
+
+MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
+MODULE_DESCRIPTION("AB3100 core driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index 386da1566fcc..cb73051e43db 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -35,7 +35,7 @@ struct pasic3_data {
*/
void pasic3_write_register(struct device *dev, u32 reg, u8 val)
{
- struct pasic3_data *asic = dev->driver_data;
+ struct pasic3_data *asic = dev_get_drvdata(dev);
int bus_shift = asic->bus_shift;
void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
@@ -50,7 +50,7 @@ EXPORT_SYMBOL(pasic3_write_register); /* for leds-pasic3 */
*/
u8 pasic3_read_register(struct device *dev, u32 reg)
{
- struct pasic3_data *asic = dev->driver_data;
+ struct pasic3_data *asic = dev_get_drvdata(dev);
int bus_shift = asic->bus_shift;
void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 11a6248cc1c1..082c197ab9b8 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -618,7 +618,7 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
pdev->dev.parent = pcf->dev;
pdev->dev.platform_data = &pdata->reg_init_data[i];
- pdev->dev.driver_data = pcf;
+ dev_set_drvdata(&pdev->dev, pcf);
pcf->regulator_pdev[i] = pdev;
platform_device_add(pdev);
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c
index 2fa2eca5c9cc..9ab19a8f669d 100644
--- a/drivers/mfd/pcf50633-gpio.c
+++ b/drivers/mfd/pcf50633-gpio.c
@@ -15,6 +15,7 @@
*/
#include <linux/kernel.h>
+#include <linux/module.h>
#include <linux/mfd/pcf50633/core.h>
#include <linux/mfd/pcf50633/gpio.h>
@@ -116,3 +117,5 @@ int pcf50633_gpio_power_supply_set(struct pcf50633 *pcf,
return pcf50633_reg_set_bit_mask(pcf, reg, mask, val);
}
EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index ec90e953adce..cd1008c19cd7 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -647,7 +647,7 @@ static inline int __init unprotect_pm_master(void)
return e;
}
-static void __init clocks_init(struct device *dev)
+static void clocks_init(struct device *dev)
{
int e = 0;
struct clk *osc;
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index aca2670afd78..bae61b22501c 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -255,7 +255,7 @@ static int twl4030_irq_thread(void *data)
* thread. All we do here is acknowledge and mask the interrupt and wakeup
* the kernel thread.
*/
-static void handle_twl4030_pih(unsigned int irq, irq_desc_t *desc)
+static void handle_twl4030_pih(unsigned int irq, struct irq_desc *desc)
{
/* Acknowledge, clear *AND* mask the interrupt... */
desc->chip->ack(irq);
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index 9a4cc954cb7c..7ccc1eab98ab 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -3186,7 +3186,7 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
/* read write volatile */
{ 0xFFFF, 0xFFFF, 0xFFFF }, /* R0 - Reset/ID */
{ 0x7CFF, 0x0C00, 0x7FFF }, /* R1 - ID */
- { 0x0000, 0x0000, 0x0000 }, /* R2 */
+ { 0x007F, 0x0000, 0x0000 }, /* R2 - ROM Mask ID */
{ 0xBE3B, 0xBE3B, 0x8000 }, /* R3 - System Control 1 */
{ 0xFEF7, 0xFEF7, 0xF800 }, /* R4 - System Control 2 */
{ 0x80FF, 0x80FF, 0x8000 }, /* R5 - System Hibernate */
@@ -3411,7 +3411,7 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
{ 0x0000, 0x0000, 0x0000 }, /* R224 */
{ 0x8F3F, 0x0000, 0xFFFF }, /* R225 - DCDC/LDO status */
{ 0x0000, 0x0000, 0xFFFF }, /* R226 - Charger status */
- { 0x0000, 0x0000, 0xFFFF }, /* R227 */
+ { 0x34FE, 0x0000, 0xFFFF }, /* R227 */
{ 0x0000, 0x0000, 0x0000 }, /* R228 */
{ 0x0000, 0x0000, 0x0000 }, /* R229 */
{ 0xFFFF, 0x1FFF, 0xFFFF }, /* R230 - GPIO Pin Status */
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index cf30d06a0104..7c21bf791569 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -265,7 +265,7 @@ static int wm8400_init(struct wm8400 *wm8400,
mutex_init(&wm8400->io_lock);
- wm8400->dev->driver_data = wm8400;
+ dev_set_drvdata(wm8400->dev, wm8400);
/* Check that this is actually a WM8400 */
ret = wm8400->read_dev(wm8400->io_data, WM8400_RESET_ID, 1, &reg);
diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
index 89fec052f3b4..9118613af321 100644
--- a/drivers/misc/eeprom/Kconfig
+++ b/drivers/misc/eeprom/Kconfig
@@ -48,6 +48,20 @@ config EEPROM_LEGACY
This driver can also be built as a module. If so, the module
will be called eeprom.
+config EEPROM_MAX6875
+ tristate "Maxim MAX6874/5 power supply supervisor"
+ depends on I2C && EXPERIMENTAL
+ help
+ If you say yes here you get read-only support for the user EEPROM of
+ the Maxim MAX6874/5 EEPROM-programmable, quad power-supply
+ sequencer/supervisor.
+
+ All other features of this chip should be accessed via i2c-dev.
+
+ This driver can also be built as a module. If so, the module
+ will be called max6875.
+
+
config EEPROM_93CX6
tristate "EEPROM 93CX6 support"
help
diff --git a/drivers/misc/eeprom/Makefile b/drivers/misc/eeprom/Makefile
index 539dd8f88128..df3d68ffa9d1 100644
--- a/drivers/misc/eeprom/Makefile
+++ b/drivers/misc/eeprom/Makefile
@@ -1,4 +1,5 @@
obj-$(CONFIG_EEPROM_AT24) += at24.o
obj-$(CONFIG_EEPROM_AT25) += at25.o
obj-$(CONFIG_EEPROM_LEGACY) += eeprom.o
+obj-$(CONFIG_EEPROM_MAX6875) += max6875.o
obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o
diff --git a/drivers/i2c/chips/max6875.c b/drivers/misc/eeprom/max6875.c
index 033d9d81ec8a..3c0c58eed347 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/misc/eeprom/max6875.c
@@ -3,7 +3,7 @@
Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
- Based on i2c/chips/eeprom.c
+ Based on eeprom.c
The MAX6875 has a bank of registers and two banks of EEPROM.
Address ranges are defined as follows:
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 3cf61ece71d7..348443bdb23b 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -119,7 +119,7 @@ enclosure_register(struct device *dev, const char *name, int components,
edev->edev.class = &enclosure_class;
edev->edev.parent = get_device(dev);
edev->cb = cb;
- dev_set_name(&edev->edev, name);
+ dev_set_name(&edev->edev, "%s", name);
err = device_register(&edev->edev);
if (err)
goto err;
@@ -255,8 +255,8 @@ enclosure_component_register(struct enclosure_device *edev,
ecomp->number = number;
cdev = &ecomp->cdev;
cdev->parent = get_device(&edev->edev);
- if (name)
- dev_set_name(cdev, name);
+ if (name && name[0])
+ dev_set_name(cdev, "%s", name);
else
dev_set_name(cdev, "%u", number);
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index b25e9b6516ae..98ffc41eaf2c 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -243,7 +243,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
brq.mrq.cmd = &brq.cmd;
brq.mrq.data = &brq.data;
- brq.cmd.arg = req->sector;
+ brq.cmd.arg = blk_rq_pos(req);
if (!mmc_card_blockaddr(card))
brq.cmd.arg <<= 9;
brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
@@ -251,7 +251,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
brq.stop.opcode = MMC_STOP_TRANSMISSION;
brq.stop.arg = 0;
brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
- brq.data.blocks = req->nr_sectors;
+ brq.data.blocks = blk_rq_sectors(req);
/*
* The block layer doesn't support all sector count
@@ -301,7 +301,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
* Adjust the sg list so it is the same size as the
* request.
*/
- if (brq.data.blocks != req->nr_sectors) {
+ if (brq.data.blocks != blk_rq_sectors(req)) {
int i, data_size = brq.data.blocks << 9;
struct scatterlist *sg;
@@ -352,8 +352,8 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
printk(KERN_ERR "%s: error %d transferring data,"
" sector %u, nr %u, card status %#x\n",
req->rq_disk->disk_name, brq.data.error,
- (unsigned)req->sector,
- (unsigned)req->nr_sectors, status);
+ (unsigned)blk_rq_pos(req),
+ (unsigned)blk_rq_sectors(req), status);
}
if (brq.stop.error) {
@@ -521,7 +521,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
sprintf(md->disk->disk_name, "mmcblk%d", devidx);
- blk_queue_hardsect_size(md->queue.queue, 512);
+ blk_queue_logical_block_size(md->queue.queue, 512);
if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {
/*
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 7a72e75d5c67..49e582356c65 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -55,7 +55,7 @@ static int mmc_queue_thread(void *d)
spin_lock_irq(q->queue_lock);
set_current_state(TASK_INTERRUPTIBLE);
if (!blk_queue_plugged(q))
- req = elv_next_request(q);
+ req = blk_fetch_request(q);
mq->req = req;
spin_unlock_irq(q->queue_lock);
@@ -88,16 +88,11 @@ static void mmc_request(struct request_queue *q)
{
struct mmc_queue *mq = q->queuedata;
struct request *req;
- int ret;
if (!mq) {
printk(KERN_ERR "MMC: killing requests for dead queue\n");
- while ((req = elv_next_request(q)) != NULL) {
- do {
- ret = __blk_end_request(req, -EIO,
- blk_rq_cur_bytes(req));
- } while (ret);
- }
+ while ((req = blk_fetch_request(q)) != NULL)
+ __blk_end_request_all(req, -EIO);
return;
}
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 264911732756..d84c880fac84 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -708,7 +708,13 @@ static void mmc_power_up(struct mmc_host *host)
*/
mmc_delay(10);
- host->ios.clock = host->f_min;
+ if (host->f_min > 400000) {
+ pr_warning("%s: Minimum clock frequency too high for "
+ "identification mode\n", mmc_hostname(host));
+ host->ios.clock = host->f_min;
+ } else
+ host->ios.clock = 400000;
+
host->ios.power_mode = MMC_POWER_ON;
mmc_set_ios(host);
@@ -855,61 +861,72 @@ void mmc_rescan(struct work_struct *work)
mmc_bus_get(host);
- if (host->bus_ops == NULL) {
- /*
- * Only we can add a new handler, so it's safe to
- * release the lock here.
- */
+ /* if there is a card registered, check whether it is still present */
+ if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
+ host->bus_ops->detect(host);
+
+ mmc_bus_put(host);
+
+
+ mmc_bus_get(host);
+
+ /* if there still is a card present, stop here */
+ if (host->bus_ops != NULL) {
mmc_bus_put(host);
+ goto out;
+ }
- if (host->ops->get_cd && host->ops->get_cd(host) == 0)
- goto out;
+ /* detect a newly inserted card */
- mmc_claim_host(host);
+ /*
+ * Only we can add a new handler, so it's safe to
+ * release the lock here.
+ */
+ mmc_bus_put(host);
- mmc_power_up(host);
- mmc_go_idle(host);
+ if (host->ops->get_cd && host->ops->get_cd(host) == 0)
+ goto out;
- mmc_send_if_cond(host, host->ocr_avail);
+ mmc_claim_host(host);
- /*
- * First we search for SDIO...
- */
- err = mmc_send_io_op_cond(host, 0, &ocr);
- if (!err) {
- if (mmc_attach_sdio(host, ocr))
- mmc_power_off(host);
- goto out;
- }
+ mmc_power_up(host);
+ mmc_go_idle(host);
- /*
- * ...then normal SD...
- */
- err = mmc_send_app_op_cond(host, 0, &ocr);
- if (!err) {
- if (mmc_attach_sd(host, ocr))
- mmc_power_off(host);
- goto out;
- }
+ mmc_send_if_cond(host, host->ocr_avail);
- /*
- * ...and finally MMC.
- */
- err = mmc_send_op_cond(host, 0, &ocr);
- if (!err) {
- if (mmc_attach_mmc(host, ocr))
- mmc_power_off(host);
- goto out;
- }
+ /*
+ * First we search for SDIO...
+ */
+ err = mmc_send_io_op_cond(host, 0, &ocr);
+ if (!err) {
+ if (mmc_attach_sdio(host, ocr))
+ mmc_power_off(host);
+ goto out;
+ }
- mmc_release_host(host);
- mmc_power_off(host);
- } else {
- if (host->bus_ops->detect && !host->bus_dead)
- host->bus_ops->detect(host);
+ /*
+ * ...then normal SD...
+ */
+ err = mmc_send_app_op_cond(host, 0, &ocr);
+ if (!err) {
+ if (mmc_attach_sd(host, ocr))
+ mmc_power_off(host);
+ goto out;
+ }
- mmc_bus_put(host);
+ /*
+ * ...and finally MMC.
+ */
+ err = mmc_send_op_cond(host, 0, &ocr);
+ if (!err) {
+ if (mmc_attach_mmc(host, ocr))
+ mmc_power_off(host);
+ goto out;
}
+
+ mmc_release_host(host);
+ mmc_power_off(host);
+
out:
if (host->caps & MMC_CAP_NEEDS_POLL)
mmc_schedule_delayed_work(&host->detect, HZ);
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index b4cf691f3f64..3eb87bda14f3 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -155,7 +155,7 @@ config MMC_ATMELMCI_DMA
config MMC_IMX
tristate "Motorola i.MX Multimedia Card Interface support"
- depends on ARCH_IMX
+ depends on ARCH_MX1
help
This selects the Motorola i.MX Multimedia card Interface.
If you have a i.MX platform with a Multimedia Card slot,
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index cf6a100bb38f..7b603e4b41db 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -177,6 +177,7 @@ struct atmel_mci {
* available.
* @wp_pin: GPIO pin used for card write protect sending, or negative
* if not available.
+ * @detect_is_active_high: The state of the detect pin when it is active.
* @detect_timer: Timer used for debouncing @detect_pin interrupts.
*/
struct atmel_mci_slot {
@@ -196,6 +197,7 @@ struct atmel_mci_slot {
int detect_pin;
int wp_pin;
+ bool detect_is_active_high;
struct timer_list detect_timer;
};
@@ -924,7 +926,8 @@ static int atmci_get_cd(struct mmc_host *mmc)
struct atmel_mci_slot *slot = mmc_priv(mmc);
if (gpio_is_valid(slot->detect_pin)) {
- present = !gpio_get_value(slot->detect_pin);
+ present = !(gpio_get_value(slot->detect_pin) ^
+ slot->detect_is_active_high);
dev_dbg(&mmc->class_dev, "card is %spresent\n",
present ? "" : "not ");
}
@@ -1028,7 +1031,8 @@ static void atmci_detect_change(unsigned long data)
return;
enable_irq(gpio_to_irq(slot->detect_pin));
- present = !gpio_get_value(slot->detect_pin);
+ present = !(gpio_get_value(slot->detect_pin) ^
+ slot->detect_is_active_high);
present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags);
dev_vdbg(&slot->mmc->class_dev, "detect change: %d (was %d)\n",
@@ -1456,6 +1460,7 @@ static int __init atmci_init_slot(struct atmel_mci *host,
slot->host = host;
slot->detect_pin = slot_data->detect_pin;
slot->wp_pin = slot_data->wp_pin;
+ slot->detect_is_active_high = slot_data->detect_is_active_high;
slot->sdc_reg = sdc_reg;
mmc->ops = &atmci_ops;
@@ -1477,7 +1482,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
if (gpio_request(slot->detect_pin, "mmc_detect")) {
dev_dbg(&mmc->class_dev, "no detect pin available\n");
slot->detect_pin = -EBUSY;
- } else if (gpio_get_value(slot->detect_pin)) {
+ } else if (gpio_get_value(slot->detect_pin) ^
+ slot->detect_is_active_high) {
clear_bit(ATMCI_CARD_PRESENT, &slot->flags);
}
}
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index f48349d18c92..a789db8eed28 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -97,6 +97,14 @@
*/
#define r1b_timeout (HZ * 3)
+/* One of the critical speed parameters is the amount of data which may
+ * be transfered in one command. If this value is too low, the SD card
+ * controller has to do multiple partial block writes (argggh!). With
+ * today (2008) SD cards there is little speed gain if we transfer more
+ * than 64 KBytes at a time. So use this value until there is any indication
+ * that we should do more here.
+ */
+#define MMC_SPI_BLOCKSATONCE 128
/****************************************************************************/
@@ -1366,6 +1374,10 @@ static int mmc_spi_probe(struct spi_device *spi)
mmc->ops = &mmc_spi_ops;
mmc->max_blk_size = MMC_SPI_BLOCKSIZE;
+ mmc->max_hw_segs = MMC_SPI_BLOCKSATONCE;
+ mmc->max_phys_segs = MMC_SPI_BLOCKSATONCE;
+ mmc->max_req_size = MMC_SPI_BLOCKSATONCE * MMC_SPI_BLOCKSIZE;
+ mmc->max_blk_count = MMC_SPI_BLOCKSATONCE;
mmc->caps = MMC_CAP_SPI;
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index c643d0fe118f..9d3cfa9909c9 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -620,9 +620,18 @@ static void mvsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
if (ios->bus_width == MMC_BUS_WIDTH_4)
ctrl_reg |= MVSD_HOST_CTRL_DATA_WIDTH_4_BITS;
+ /*
+ * The HI_SPEED_EN bit is causing trouble with many (but not all)
+ * high speed SD, SDHC and SDIO cards. Not enabling that bit
+ * makes all cards work. So let's just ignore that bit for now
+ * and revisit this issue if problems for not enabling this bit
+ * are ever reported.
+ */
+#if 0
if (ios->timing == MMC_TIMING_MMC_HS ||
ios->timing == MMC_TIMING_SD_HS)
ctrl_reg |= MVSD_HOST_CTRL_HI_SPEED_EN;
+#endif
host->ctrl = ctrl_reg;
mvsd_write(MVSD_HOST_CTRL, ctrl_reg);
@@ -882,3 +891,4 @@ module_param(nodma, int, 0);
MODULE_AUTHOR("Maen Suleiman, Nicolas Pitre");
MODULE_DESCRIPTION("Marvell MMC,SD,SDIO Host Controller driver");
MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:mvsdio");
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index b4a615c55f28..bc14bb1b0579 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -140,6 +140,8 @@ struct mxcmci_host {
struct work_struct datawork;
};
+static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
+
static inline int mxcmci_use_dma(struct mxcmci_host *host)
{
return host->do_dma;
@@ -160,7 +162,7 @@ static void mxcmci_softreset(struct mxcmci_host *host)
writew(0xff, host->base + MMC_REG_RES_TO);
}
-static void mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
+static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
{
unsigned int nob = data->blocks;
unsigned int blksz = data->blksz;
@@ -168,6 +170,7 @@ static void mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
#ifdef HAS_DMA
struct scatterlist *sg;
int i;
+ int ret;
#endif
if (data->flags & MMC_DATA_STREAM)
nob = 0xffff;
@@ -183,7 +186,7 @@ static void mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
for_each_sg(data->sg, sg, data->sg_len, i) {
if (sg->offset & 3 || sg->length & 3) {
host->do_dma = 0;
- return;
+ return 0;
}
}
@@ -192,23 +195,30 @@ static void mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
data->sg_len, host->dma_dir);
- imx_dma_setup_sg(host->dma, data->sg, host->dma_nents, datasize,
- host->res->start + MMC_REG_BUFFER_ACCESS,
- DMA_MODE_READ);
+ ret = imx_dma_setup_sg(host->dma, data->sg, host->dma_nents,
+ datasize,
+ host->res->start + MMC_REG_BUFFER_ACCESS,
+ DMA_MODE_READ);
} else {
host->dma_dir = DMA_TO_DEVICE;
host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
data->sg_len, host->dma_dir);
- imx_dma_setup_sg(host->dma, data->sg, host->dma_nents, datasize,
- host->res->start + MMC_REG_BUFFER_ACCESS,
- DMA_MODE_WRITE);
+ ret = imx_dma_setup_sg(host->dma, data->sg, host->dma_nents,
+ datasize,
+ host->res->start + MMC_REG_BUFFER_ACCESS,
+ DMA_MODE_WRITE);
}
+ if (ret) {
+ dev_err(mmc_dev(host->mmc), "failed to setup DMA : %d\n", ret);
+ return ret;
+ }
wmb();
imx_dma_enable(host->dma);
#endif /* HAS_DMA */
+ return 0;
}
static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd,
@@ -345,8 +355,11 @@ static int mxcmci_poll_status(struct mxcmci_host *host, u32 mask)
stat = readl(host->base + MMC_REG_STATUS);
if (stat & STATUS_ERR_MASK)
return stat;
- if (time_after(jiffies, timeout))
+ if (time_after(jiffies, timeout)) {
+ mxcmci_softreset(host);
+ mxcmci_set_clk_rate(host, host->clock);
return STATUS_TIME_OUT_READ;
+ }
if (stat & mask)
return 0;
cpu_relax();
@@ -531,6 +544,7 @@ static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req)
{
struct mxcmci_host *host = mmc_priv(mmc);
unsigned int cmdat = host->cmdat;
+ int error;
WARN_ON(host->req != NULL);
@@ -540,7 +554,12 @@ static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req)
host->do_dma = 1;
#endif
if (req->data) {
- mxcmci_setup_data(host, req->data);
+ error = mxcmci_setup_data(host, req->data);
+ if (error) {
+ req->cmd->error = error;
+ goto out;
+ }
+
cmdat |= CMD_DAT_CONT_DATA_ENABLE;
@@ -548,7 +567,9 @@ static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req)
cmdat |= CMD_DAT_CONT_WRITE;
}
- if (mxcmci_start_cmd(host, req->cmd, cmdat))
+ error = mxcmci_start_cmd(host, req->cmd, cmdat);
+out:
+ if (error)
mxcmci_finish_request(host, req);
}
@@ -724,7 +745,7 @@ static int mxcmci_probe(struct platform_device *pdev)
goto out_clk_put;
}
- mmc->f_min = clk_get_rate(host->clk) >> 7;
+ mmc->f_min = clk_get_rate(host->clk) >> 16;
mmc->f_max = clk_get_rate(host->clk) >> 1;
/* recommended in data sheet */
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index bfa25c01c872..e7a331de5733 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -822,7 +822,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
del_timer(&host->cmd_abort_timer);
host->abort = 1;
OMAP_MMC_WRITE(host, IE, 0);
- disable_irq(host->irq);
+ disable_irq_nosync(host->irq);
schedule_work(&host->cmd_abort_work);
return IRQ_HANDLED;
}
@@ -1593,7 +1593,6 @@ static int mmc_omap_resume(struct platform_device *pdev)
#endif
static struct platform_driver mmc_omap_driver = {
- .probe = mmc_omap_probe,
.remove = mmc_omap_remove,
.suspend = mmc_omap_suspend,
.resume = mmc_omap_resume,
@@ -1605,7 +1604,7 @@ static struct platform_driver mmc_omap_driver = {
static int __init mmc_omap_init(void)
{
- return platform_driver_register(&mmc_omap_driver);
+ return platform_driver_probe(&mmc_omap_driver, mmc_omap_probe);
}
static void __exit mmc_omap_exit(void)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index e62a22a7f00c..c40cb96255a2 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -680,7 +680,7 @@ static void mmc_omap_dma_cb(int lch, u16 ch_status, void *data)
host->dma_ch = -1;
/*
* DMA Callback: run in interrupt context.
- * mutex_unlock will through a kernel warning if used.
+ * mutex_unlock will throw a kernel warning if used.
*/
up(&host->sem);
}
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index 2db166b7096f..4eb4f37544ab 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -17,6 +17,7 @@
#include <linux/mmc/host.h>
#include <linux/platform_device.h>
#include <linux/cpufreq.h>
+#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/io.h>
@@ -789,7 +790,7 @@ static void s3cmci_dma_setup(struct s3cmci_host *host,
last_source = source;
- s3c2410_dma_devconfig(host->dma, source, 3,
+ s3c2410_dma_devconfig(host->dma, source,
host->mem->start + host->sdidata);
if (!setup_ok) {
@@ -1121,7 +1122,7 @@ static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
case MMC_POWER_OFF:
default:
s3c2410_gpio_setpin(S3C2410_GPE5, 0);
- s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_OUTP);
+ s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPIO_OUTPUT);
if (host->is2440)
mci_con |= S3C2440_SDICON_SDRESET;
diff --git a/drivers/mmc/host/sdhci-of.c b/drivers/mmc/host/sdhci-of.c
index 3ff4ac3abe8b..09cc597c6316 100644
--- a/drivers/mmc/host/sdhci-of.c
+++ b/drivers/mmc/host/sdhci-of.c
@@ -277,6 +277,7 @@ static int __devexit sdhci_of_remove(struct of_device *ofdev)
static const struct of_device_id sdhci_of_match[] = {
{ .compatible = "fsl,mpc8379-esdhc", .data = &sdhci_esdhc, },
{ .compatible = "fsl,mpc8536-esdhc", .data = &sdhci_esdhc, },
+ { .compatible = "fsl,esdhc", .data = &sdhci_esdhc, },
{ .compatible = "generic-sdhci", },
{},
};
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9234be2226e7..1432a35690dd 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1005,12 +1005,34 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
{
u8 pwr;
- if (host->power == power)
+ if (power == (unsigned short)-1)
+ pwr = 0;
+ else {
+ switch (1 << power) {
+ case MMC_VDD_165_195:
+ pwr = SDHCI_POWER_180;
+ break;
+ case MMC_VDD_29_30:
+ case MMC_VDD_30_31:
+ pwr = SDHCI_POWER_300;
+ break;
+ case MMC_VDD_32_33:
+ case MMC_VDD_33_34:
+ pwr = SDHCI_POWER_330;
+ break;
+ default:
+ BUG();
+ }
+ }
+
+ if (host->pwr == pwr)
return;
- if (power == (unsigned short)-1) {
+ host->pwr = pwr;
+
+ if (pwr == 0) {
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
- goto out;
+ return;
}
/*
@@ -1020,35 +1042,16 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
if (!(host->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
- pwr = SDHCI_POWER_ON;
-
- switch (1 << power) {
- case MMC_VDD_165_195:
- pwr |= SDHCI_POWER_180;
- break;
- case MMC_VDD_29_30:
- case MMC_VDD_30_31:
- pwr |= SDHCI_POWER_300;
- break;
- case MMC_VDD_32_33:
- case MMC_VDD_33_34:
- pwr |= SDHCI_POWER_330;
- break;
- default:
- BUG();
- }
-
/*
* At least the Marvell CaFe chip gets confused if we set the voltage
* and set turn on power at the same time, so set the voltage first.
*/
if ((host->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER))
- sdhci_writeb(host, pwr & ~SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
+ sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
- sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
+ pwr |= SDHCI_POWER_ON;
-out:
- host->power = power;
+ sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
}
/*****************************************************************************\
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 65c6f996bbd3..2de08349c3ca 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -255,7 +255,7 @@ struct sdhci_host {
unsigned int timeout_clk; /* Timeout freq (KHz) */
unsigned int clock; /* Current clock (MHz) */
- unsigned short power; /* Current voltage */
+ u8 pwr; /* Current voltage */
struct mmc_request *mrq; /* Current request */
struct mmc_command *cmd; /* Current command */
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 7d04fb9ddcaa..b8e35a0b4d72 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -154,7 +154,8 @@ config MTD_AFS_PARTS
You will still need the parsing functions to be called by the driver
for your particular device. It won't happen automatically. The
- 'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example.
+ 'armflash' map driver (CONFIG_MTD_ARM_INTEGRATOR) does this, for
+ example.
config MTD_OF_PARTS
tristate "Flash partition map based on OF description"
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index a49a9c8f2cb1..aaac3b6800b7 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -47,40 +47,41 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
unsigned long block, nsect;
char *buf;
- block = req->sector << 9 >> tr->blkshift;
- nsect = req->current_nr_sectors << 9 >> tr->blkshift;
+ block = blk_rq_pos(req) << 9 >> tr->blkshift;
+ nsect = blk_rq_cur_bytes(req) >> tr->blkshift;
buf = req->buffer;
if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
req->cmd[0] == REQ_LB_OP_DISCARD)
- return !tr->discard(dev, block, nsect);
+ return tr->discard(dev, block, nsect);
if (!blk_fs_request(req))
- return 0;
+ return -EIO;
- if (req->sector + req->current_nr_sectors > get_capacity(req->rq_disk))
- return 0;
+ if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
+ get_capacity(req->rq_disk))
+ return -EIO;
switch(rq_data_dir(req)) {
case READ:
for (; nsect > 0; nsect--, block++, buf += tr->blksize)
if (tr->readsect(dev, block, buf))
- return 0;
- return 1;
+ return -EIO;
+ return 0;
case WRITE:
if (!tr->writesect)
- return 0;
+ return -EIO;
for (; nsect > 0; nsect--, block++, buf += tr->blksize)
if (tr->writesect(dev, block, buf))
- return 0;
- return 1;
+ return -EIO;
+ return 0;
default:
printk(KERN_NOTICE "Unknown request %u\n", rq_data_dir(req));
- return 0;
+ return -EIO;
}
}
@@ -88,19 +89,18 @@ static int mtd_blktrans_thread(void *arg)
{
struct mtd_blktrans_ops *tr = arg;
struct request_queue *rq = tr->blkcore_priv->rq;
+ struct request *req = NULL;
/* we might get involved when memory gets low, so use PF_MEMALLOC */
current->flags |= PF_MEMALLOC;
spin_lock_irq(rq->queue_lock);
+
while (!kthread_should_stop()) {
- struct request *req;
struct mtd_blktrans_dev *dev;
- int res = 0;
-
- req = elv_next_request(rq);
+ int res;
- if (!req) {
+ if (!req && !(req = blk_fetch_request(rq))) {
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(rq->queue_lock);
schedule();
@@ -119,8 +119,13 @@ static int mtd_blktrans_thread(void *arg)
spin_lock_irq(rq->queue_lock);
- end_request(req, res);
+ if (!__blk_end_request_cur(req, res))
+ req = NULL;
}
+
+ if (req)
+ __blk_end_request_all(req, -EIO);
+
spin_unlock_irq(rq->queue_lock);
return 0;
@@ -373,7 +378,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
}
tr->blkcore_priv->rq->queuedata = tr;
- blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize);
+ blk_queue_logical_block_size(tr->blkcore_priv->rq, tr->blksize);
if (tr->discard)
blk_queue_set_discard(tr->blkcore_priv->rq,
blktrans_discard_request);
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index f2e9de1414df..6391e3dc8002 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -39,7 +39,6 @@
#include <mach/gpmc.h>
#include <mach/onenand.h>
#include <mach/gpio.h>
-#include <mach/pm.h>
#include <mach/dma.h>
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 4048db83aef6..1405b556c65a 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -380,7 +380,7 @@ static void free_user_volumes(struct ubi_device *ubi)
* @ubi: UBI device description object
*
* This function returns zero in case of success and a negative error code in
- * case of failure. Note, this function destroys all volumes if it failes.
+ * case of failure. Note, this function destroys all volumes if it fails.
*/
static int uif_init(struct ubi_device *ubi)
{
@@ -806,8 +806,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
mutex_init(&ubi->buf_mutex);
mutex_init(&ubi->ckvol_mutex);
- mutex_init(&ubi->mult_mutex);
- mutex_init(&ubi->volumes_mutex);
+ mutex_init(&ubi->device_mutex);
spin_lock_init(&ubi->volumes_lock);
ubi_msg("attaching mtd%d to ubi%d", mtd->index, ubi_num);
@@ -825,7 +824,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
if (!ubi->peb_buf2)
goto out_free;
-#ifdef CONFIG_MTD_UBI_DEBUG
+#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
mutex_init(&ubi->dbg_buf_mutex);
ubi->dbg_peb_buf = vmalloc(ubi->peb_size);
if (!ubi->dbg_peb_buf)
@@ -872,9 +871,15 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
ubi->beb_rsvd_pebs);
ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec);
+ /*
+ * The below lock makes sure we do not race with 'ubi_thread()' which
+ * checks @ubi->thread_enabled. Otherwise we may fail to wake it up.
+ */
+ spin_lock(&ubi->wl_lock);
if (!DBG_DISABLE_BGT)
ubi->thread_enabled = 1;
wake_up_process(ubi->bgt_thread);
+ spin_unlock(&ubi->wl_lock);
ubi_devices[ubi_num] = ubi;
return ubi_num;
@@ -892,7 +897,7 @@ out_detach:
out_free:
vfree(ubi->peb_buf1);
vfree(ubi->peb_buf2);
-#ifdef CONFIG_MTD_UBI_DEBUG
+#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
vfree(ubi->dbg_peb_buf);
#endif
kfree(ubi);
@@ -961,7 +966,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
put_mtd_device(ubi->mtd);
vfree(ubi->peb_buf1);
vfree(ubi->peb_buf2);
-#ifdef CONFIG_MTD_UBI_DEBUG
+#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
vfree(ubi->dbg_peb_buf);
#endif
ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num);
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index f8e0f68f2186..9a2b217941f7 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -113,7 +113,8 @@ static int vol_cdev_open(struct inode *inode, struct file *file)
else
mode = UBI_READONLY;
- dbg_gen("open volume %d, mode %d", vol_id, mode);
+ dbg_gen("open device %d, volume %d, mode %d",
+ ubi_num, vol_id, mode);
desc = ubi_open_volume(ubi_num, vol_id, mode);
if (IS_ERR(desc))
@@ -128,7 +129,8 @@ static int vol_cdev_release(struct inode *inode, struct file *file)
struct ubi_volume_desc *desc = file->private_data;
struct ubi_volume *vol = desc->vol;
- dbg_gen("release volume %d, mode %d", vol->vol_id, desc->mode);
+ dbg_gen("release device %d, volume %d, mode %d",
+ vol->ubi->ubi_num, vol->vol_id, desc->mode);
if (vol->updating) {
ubi_warn("update of volume %d not finished, volume is damaged",
@@ -558,7 +560,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
break;
}
- /* Set volume property command*/
+ /* Set volume property command */
case UBI_IOCSETPROP:
{
struct ubi_set_prop_req req;
@@ -571,9 +573,9 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
}
switch (req.property) {
case UBI_PROP_DIRECT_WRITE:
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
desc->vol->direct_writes = !!req.value;
- mutex_unlock(&ubi->volumes_mutex);
+ mutex_unlock(&ubi->device_mutex);
break;
default:
err = -EINVAL;
@@ -810,9 +812,9 @@ static int rename_volumes(struct ubi_device *ubi,
re->desc->vol->vol_id, re->desc->vol->name);
}
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
err = ubi_rename_volumes(ubi, &rename_list);
- mutex_unlock(&ubi->volumes_mutex);
+ mutex_unlock(&ubi->device_mutex);
out_free:
list_for_each_entry_safe(re, re1, &rename_list, list) {
@@ -856,9 +858,9 @@ static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
if (err)
break;
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
err = ubi_create_volume(ubi, &req);
- mutex_unlock(&ubi->volumes_mutex);
+ mutex_unlock(&ubi->device_mutex);
if (err)
break;
@@ -887,9 +889,9 @@ static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
break;
}
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
err = ubi_remove_volume(desc, 0);
- mutex_unlock(&ubi->volumes_mutex);
+ mutex_unlock(&ubi->device_mutex);
/*
* The volume is deleted (unless an error occurred), and the
@@ -926,9 +928,9 @@ static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
pebs = div_u64(req.bytes + desc->vol->usable_leb_size - 1,
desc->vol->usable_leb_size);
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
err = ubi_resize_volume(desc, pebs);
- mutex_unlock(&ubi->volumes_mutex);
+ mutex_unlock(&ubi->device_mutex);
ubi_close_volume(desc);
break;
}
@@ -952,9 +954,7 @@ static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
break;
}
- mutex_lock(&ubi->mult_mutex);
err = rename_volumes(ubi, req);
- mutex_unlock(&ubi->mult_mutex);
kfree(req);
break;
}
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index fe81039f2a7c..ac6604aeb728 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -100,6 +100,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
const struct ubi_vid_hdr *vid_hdr);
static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
int len);
+static int paranoid_check_empty(struct ubi_device *ubi, int pnum);
#else
#define paranoid_check_not_bad(ubi, pnum) 0
#define paranoid_check_peb_ec_hdr(ubi, pnum) 0
@@ -107,6 +108,7 @@ static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
#define paranoid_check_peb_vid_hdr(ubi, pnum) 0
#define paranoid_check_vid_hdr(ubi, pnum, vid_hdr) 0
#define paranoid_check_all_ff(ubi, pnum, offset, len) 0
+#define paranoid_check_empty(ubi, pnum) 0
#endif
/**
@@ -670,11 +672,6 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
if (read_err != -EBADMSG &&
check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
/* The physical eraseblock is supposedly empty */
-
- /*
- * The below is just a paranoid check, it has to be
- * compiled out if paranoid checks are disabled.
- */
err = paranoid_check_all_ff(ubi, pnum, 0,
ubi->peb_size);
if (err)
@@ -955,8 +952,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
* The below is just a paranoid check, it has to be
* compiled out if paranoid checks are disabled.
*/
- err = paranoid_check_all_ff(ubi, pnum, ubi->leb_start,
- ubi->leb_size);
+ err = paranoid_check_empty(ubi, pnum);
if (err)
return err > 0 ? UBI_IO_BAD_VID_HDR : err;
@@ -1280,4 +1276,74 @@ error:
return err;
}
+/**
+ * paranoid_check_empty - whether a PEB is empty.
+ * @ubi: UBI device description object
+ * @pnum: the physical eraseblock number to check
+ *
+ * This function makes sure PEB @pnum is empty, which means it contains only
+ * %0xFF data bytes. Returns zero if the PEB is empty, %1 if not, and a
+ * negative error code in case of failure.
+ *
+ * Empty PEBs have the EC header, and do not have the VID header. The caller of
+ * this function should have already made sure the PEB does not have the VID
+ * header. However, this function re-checks that, because it is possible that
+ * the header and data has already been written to the PEB.
+ *
+ * Let's consider a possible scenario. Suppose there are 2 tasks - A and B.
+ * Task A is in 'wear_leveling_worker()'. It is reading VID header of PEB X to
+ * find which LEB it corresponds to. PEB X is currently unmapped, and has no
+ * VID header. Task B is trying to write to PEB X.
+ *
+ * Task A: in 'ubi_io_read_vid_hdr()': reads the VID header from PEB X. The
+ * read data contain all 0xFF bytes;
+ * Task B: writes VID header and some data to PEB X;
+ * Task A: assumes PEB X is empty, calls 'paranoid_check_empty()'. And if we
+ * do not re-read the VID header, and do not cancel the checking if it
+ * is there, we fail.
+ */
+static int paranoid_check_empty(struct ubi_device *ubi, int pnum)
+{
+ int err, offs = ubi->vid_hdr_aloffset, len = ubi->vid_hdr_alsize;
+ size_t read;
+ uint32_t magic;
+ const struct ubi_vid_hdr *vid_hdr;
+
+ mutex_lock(&ubi->dbg_buf_mutex);
+ err = ubi->mtd->read(ubi->mtd, offs, len, &read, ubi->dbg_peb_buf);
+ if (err && err != -EUCLEAN) {
+ ubi_err("error %d while reading %d bytes from PEB %d:%d, "
+ "read %zd bytes", err, len, pnum, offs, read);
+ goto error;
+ }
+
+ vid_hdr = ubi->dbg_peb_buf;
+ magic = be32_to_cpu(vid_hdr->magic);
+ if (magic == UBI_VID_HDR_MAGIC)
+ /* The PEB contains VID header, so it is not empty */
+ goto out;
+
+ err = check_pattern(ubi->dbg_peb_buf, 0xFF, len);
+ if (err == 0) {
+ ubi_err("flash region at PEB %d:%d, length %d does not "
+ "contain all 0xFF bytes", pnum, offs, len);
+ goto fail;
+ }
+
+out:
+ mutex_unlock(&ubi->dbg_buf_mutex);
+ return 0;
+
+fail:
+ ubi_err("paranoid check failed for PEB %d", pnum);
+ ubi_msg("hex dump of the %d-%d region", offs, offs + len);
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
+ ubi->dbg_peb_buf, len, 1);
+ err = 1;
+error:
+ ubi_dbg_dump_stack();
+ mutex_unlock(&ubi->dbg_buf_mutex);
+ return err;
+}
+
#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 4abbe573fa40..2675207c5fe3 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -106,7 +106,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
struct ubi_device *ubi;
struct ubi_volume *vol;
- dbg_gen("open device %d volume %d, mode %d", ubi_num, vol_id, mode);
+ dbg_gen("open device %d, volume %d, mode %d", ubi_num, vol_id, mode);
if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES)
return ERR_PTR(-EINVAL);
@@ -196,6 +196,8 @@ out_free:
kfree(desc);
out_put_ubi:
ubi_put_device(ubi);
+ dbg_err("cannot open device %d, volume %d, error %d",
+ ubi_num, vol_id, err);
return ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(ubi_open_volume);
@@ -215,7 +217,7 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
struct ubi_device *ubi;
struct ubi_volume_desc *ret;
- dbg_gen("open volume %s, mode %d", name, mode);
+ dbg_gen("open device %d, volume %s, mode %d", ubi_num, name, mode);
if (!name)
return ERR_PTR(-EINVAL);
@@ -266,7 +268,8 @@ void ubi_close_volume(struct ubi_volume_desc *desc)
struct ubi_volume *vol = desc->vol;
struct ubi_device *ubi = vol->ubi;
- dbg_gen("close volume %d, mode %d", vol->vol_id, desc->mode);
+ dbg_gen("close device %d, volume %d, mode %d",
+ ubi->ubi_num, vol->vol_id, desc->mode);
spin_lock(&ubi->volumes_lock);
switch (desc->mode) {
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index c055511bb1b2..749007e9f1aa 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -305,9 +305,9 @@ struct ubi_wl_entry;
* @vtbl_slots: how many slots are available in the volume table
* @vtbl_size: size of the volume table in bytes
* @vtbl: in-RAM volume table copy
- * @volumes_mutex: protects on-flash volume table and serializes volume
- * changes, like creation, deletion, update, re-size,
- * re-name and set property
+ * @device_mutex: protects on-flash volume table and serializes volume
+ * creation, deletion, update, re-size, re-name and set
+ * property
*
* @max_ec: current highest erase counter value
* @mean_ec: current mean erase counter value
@@ -366,7 +366,6 @@ struct ubi_wl_entry;
* @peb_buf2: another buffer of PEB size used for different purposes
* @buf_mutex: protects @peb_buf1 and @peb_buf2
* @ckvol_mutex: serializes static volume checking when opening
- * @mult_mutex: serializes operations on multiple volumes, like re-naming
* @dbg_peb_buf: buffer of PEB size used for debugging
* @dbg_buf_mutex: protects @dbg_peb_buf
*/
@@ -389,7 +388,7 @@ struct ubi_device {
int vtbl_slots;
int vtbl_size;
struct ubi_vtbl_record *vtbl;
- struct mutex volumes_mutex;
+ struct mutex device_mutex;
int max_ec;
/* Note, mean_ec is not updated run-time - should be fixed */
@@ -444,8 +443,7 @@ struct ubi_device {
void *peb_buf2;
struct mutex buf_mutex;
struct mutex ckvol_mutex;
- struct mutex mult_mutex;
-#ifdef CONFIG_MTD_UBI_DEBUG
+#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
void *dbg_peb_buf;
struct mutex dbg_buf_mutex;
#endif
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 6b4d1ae891ae..74fdc40c8627 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -68,10 +68,10 @@ static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol)
sizeof(struct ubi_vtbl_record));
vtbl_rec.upd_marker = 1;
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
err = ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
- mutex_unlock(&ubi->volumes_mutex);
vol->upd_marker = 1;
+ mutex_unlock(&ubi->device_mutex);
return err;
}
@@ -109,10 +109,10 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
vol->last_eb_bytes = vol->usable_leb_size;
}
- mutex_lock(&ubi->volumes_mutex);
+ mutex_lock(&ubi->device_mutex);
err = ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
- mutex_unlock(&ubi->volumes_mutex);
vol->upd_marker = 0;
+ mutex_unlock(&ubi->device_mutex);
return err;
}
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index df5483562b7a..8e8d6fae7a02 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -198,7 +198,7 @@ static void volume_sysfs_close(struct ubi_volume *vol)
* %UBI_VOL_NUM_AUTO, this function automatically assign ID to the new volume
* and saves it in @req->vol_id. Returns zero in case of success and a negative
* error code in case of failure. Note, the caller has to have the
- * @ubi->volumes_mutex locked.
+ * @ubi->device_mutex locked.
*/
int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
{
@@ -232,8 +232,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
req->vol_id = vol_id;
}
- dbg_gen("volume ID %d, %llu bytes, type %d, name %s",
- vol_id, (unsigned long long)req->bytes,
+ dbg_gen("create device %d, volume %d, %llu bytes, type %d, name %s",
+ ubi->ubi_num, vol_id, (unsigned long long)req->bytes,
(int)req->vol_type, req->name);
/* Ensure that this volume does not exist */
@@ -358,7 +358,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
ubi->vol_count += 1;
spin_unlock(&ubi->volumes_lock);
- err = paranoid_check_volumes(ubi);
+ if (paranoid_check_volumes(ubi))
+ dbg_err("check failed while creating volume %d", vol_id);
return err;
out_sysfs:
@@ -403,7 +404,7 @@ out_unlock:
*
* This function removes volume described by @desc. The volume has to be opened
* in "exclusive" mode. Returns zero in case of success and a negative error
- * code in case of failure. The caller has to have the @ubi->volumes_mutex
+ * code in case of failure. The caller has to have the @ubi->device_mutex
* locked.
*/
int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
@@ -412,7 +413,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
struct ubi_device *ubi = vol->ubi;
int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs;
- dbg_gen("remove UBI volume %d", vol_id);
+ dbg_gen("remove device %d, volume %d", ubi->ubi_num, vol_id);
ubi_assert(desc->mode == UBI_EXCLUSIVE);
ubi_assert(vol == ubi->volumes[vol_id]);
@@ -465,8 +466,9 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
ubi->vol_count -= 1;
spin_unlock(&ubi->volumes_lock);
- if (!no_vtbl)
- err = paranoid_check_volumes(ubi);
+ if (!no_vtbl && paranoid_check_volumes(ubi))
+ dbg_err("check failed while removing volume %d", vol_id);
+
return err;
out_err:
@@ -485,7 +487,7 @@ out_unlock:
*
* This function re-sizes the volume and returns zero in case of success, and a
* negative error code in case of failure. The caller has to have the
- * @ubi->volumes_mutex locked.
+ * @ubi->device_mutex locked.
*/
int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
{
@@ -498,8 +500,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
if (ubi->ro_mode)
return -EROFS;
- dbg_gen("re-size volume %d to from %d to %d PEBs",
- vol_id, vol->reserved_pebs, reserved_pebs);
+ dbg_gen("re-size device %d, volume %d to from %d to %d PEBs",
+ ubi->ubi_num, vol_id, vol->reserved_pebs, reserved_pebs);
if (vol->vol_type == UBI_STATIC_VOLUME &&
reserved_pebs < vol->used_ebs) {
@@ -587,7 +589,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
(long long)vol->used_ebs * vol->usable_leb_size;
}
- err = paranoid_check_volumes(ubi);
+ if (paranoid_check_volumes(ubi))
+ dbg_err("check failed while re-sizing volume %d", vol_id);
return err;
out_acc:
@@ -635,8 +638,8 @@ int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list)
}
}
- if (!err)
- err = paranoid_check_volumes(ubi);
+ if (!err && paranoid_check_volumes(ubi))
+ ;
return err;
}
@@ -688,7 +691,8 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
return err;
}
- err = paranoid_check_volumes(ubi);
+ if (paranoid_check_volumes(ubi))
+ dbg_err("check failed while adding volume %d", vol_id);
return err;
out_gluebi:
@@ -868,6 +872,7 @@ fail:
if (vol)
ubi_dbg_dump_vol_info(vol);
ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
+ dump_stack();
spin_unlock(&ubi->volumes_lock);
return -EINVAL;
}
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index fbb371921991..393e4e711965 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -653,11 +653,11 @@ static int __init el3_mca_probe(struct device *device)
netdev_boot_setup_check(dev);
el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_MCA);
- device->driver_data = dev;
+ dev_set_drvdata(device, dev);
err = el3_common_init(dev);
if (err) {
- device->driver_data = NULL;
+ dev_set_drvdata(device, NULL);
free_netdev(dev);
return -ENOMEM;
}
@@ -721,12 +721,12 @@ static int __init el3_eisa_probe (struct device *device)
/* This remove works for all device types.
*
- * The net dev must be stored in the driver_data field */
+ * The net dev must be stored in the driver data field */
static int __devexit el3_device_remove (struct device *device)
{
struct net_device *dev;
- dev = device->driver_data;
+ dev = dev_get_drvdata(device);
el3_common_remove (dev);
return 0;
@@ -1451,7 +1451,7 @@ el3_suspend(struct device *pdev, pm_message_t state)
struct el3_private *lp;
int ioaddr;
- dev = pdev->driver_data;
+ dev = dev_get_drvdata(pdev);
lp = netdev_priv(dev);
ioaddr = dev->base_addr;
@@ -1475,7 +1475,7 @@ el3_resume(struct device *pdev)
struct el3_private *lp;
int ioaddr;
- dev = pdev->driver_data;
+ dev = dev_get_drvdata(pdev);
lp = netdev_priv(dev);
ioaddr = dev->base_addr;
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 1fc45431a620..d90177509bf6 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -2292,11 +2292,11 @@ static int rtl8139_close (struct net_device *dev)
other threads or interrupts aren't messing with the 8139. */
static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
- struct rtl8139_private *np = netdev_priv(dev);
- void __iomem *ioaddr = np->mmio_addr;
+ struct rtl8139_private *tp = netdev_priv(dev);
+ void __iomem *ioaddr = tp->mmio_addr;
- spin_lock_irq(&np->lock);
- if (rtl_chip_info[np->chipset].flags & HasLWake) {
+ spin_lock_irq(&tp->lock);
+ if (rtl_chip_info[tp->chipset].flags & HasLWake) {
u8 cfg3 = RTL_R8 (Config3);
u8 cfg5 = RTL_R8 (Config5);
@@ -2317,7 +2317,7 @@ static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
if (cfg5 & Cfg5_BWF)
wol->wolopts |= WAKE_BCAST;
}
- spin_unlock_irq(&np->lock);
+ spin_unlock_irq(&tp->lock);
}
@@ -2326,19 +2326,19 @@ static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
aren't messing with the 8139. */
static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
- struct rtl8139_private *np = netdev_priv(dev);
- void __iomem *ioaddr = np->mmio_addr;
+ struct rtl8139_private *tp = netdev_priv(dev);
+ void __iomem *ioaddr = tp->mmio_addr;
u32 support;
u8 cfg3, cfg5;
- support = ((rtl_chip_info[np->chipset].flags & HasLWake)
+ support = ((rtl_chip_info[tp->chipset].flags & HasLWake)
? (WAKE_PHY | WAKE_MAGIC
| WAKE_UCAST | WAKE_MCAST | WAKE_BCAST)
: 0);
if (wol->wolopts & ~support)
return -EINVAL;
- spin_lock_irq(&np->lock);
+ spin_lock_irq(&tp->lock);
cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic);
if (wol->wolopts & WAKE_PHY)
cfg3 |= Cfg3_LinkUp;
@@ -2359,87 +2359,87 @@ static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
if (wol->wolopts & WAKE_BCAST)
cfg5 |= Cfg5_BWF;
RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */
- spin_unlock_irq(&np->lock);
+ spin_unlock_irq(&tp->lock);
return 0;
}
static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
- struct rtl8139_private *np = netdev_priv(dev);
+ struct rtl8139_private *tp = netdev_priv(dev);
strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
- strcpy(info->bus_info, pci_name(np->pci_dev));
- info->regdump_len = np->regs_len;
+ strcpy(info->bus_info, pci_name(tp->pci_dev));
+ info->regdump_len = tp->regs_len;
}
static int rtl8139_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct rtl8139_private *np = netdev_priv(dev);
- spin_lock_irq(&np->lock);
- mii_ethtool_gset(&np->mii, cmd);
- spin_unlock_irq(&np->lock);
+ struct rtl8139_private *tp = netdev_priv(dev);
+ spin_lock_irq(&tp->lock);
+ mii_ethtool_gset(&tp->mii, cmd);
+ spin_unlock_irq(&tp->lock);
return 0;
}
static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct rtl8139_private *np = netdev_priv(dev);
+ struct rtl8139_private *tp = netdev_priv(dev);
int rc;
- spin_lock_irq(&np->lock);
- rc = mii_ethtool_sset(&np->mii, cmd);
- spin_unlock_irq(&np->lock);
+ spin_lock_irq(&tp->lock);
+ rc = mii_ethtool_sset(&tp->mii, cmd);
+ spin_unlock_irq(&tp->lock);
return rc;
}
static int rtl8139_nway_reset(struct net_device *dev)
{
- struct rtl8139_private *np = netdev_priv(dev);
- return mii_nway_restart(&np->mii);
+ struct rtl8139_private *tp = netdev_priv(dev);
+ return mii_nway_restart(&tp->mii);
}
static u32 rtl8139_get_link(struct net_device *dev)
{
- struct rtl8139_private *np = netdev_priv(dev);
- return mii_link_ok(&np->mii);
+ struct rtl8139_private *tp = netdev_priv(dev);
+ return mii_link_ok(&tp->mii);
}
static u32 rtl8139_get_msglevel(struct net_device *dev)
{
- struct rtl8139_private *np = netdev_priv(dev);
- return np->msg_enable;
+ struct rtl8139_private *tp = netdev_priv(dev);
+ return tp->msg_enable;
}
static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
{
- struct rtl8139_private *np = netdev_priv(dev);
- np->msg_enable = datum;
+ struct rtl8139_private *tp = netdev_priv(dev);
+ tp->msg_enable = datum;
}
static int rtl8139_get_regs_len(struct net_device *dev)
{
- struct rtl8139_private *np;
+ struct rtl8139_private *tp;
/* TODO: we are too slack to do reg dumping for pio, for now */
if (use_io)
return 0;
- np = netdev_priv(dev);
- return np->regs_len;
+ tp = netdev_priv(dev);
+ return tp->regs_len;
}
static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
{
- struct rtl8139_private *np;
+ struct rtl8139_private *tp;
/* TODO: we are too slack to do reg dumping for pio, for now */
if (use_io)
return;
- np = netdev_priv(dev);
+ tp = netdev_priv(dev);
regs->version = RTL_REGS_VER;
- spin_lock_irq(&np->lock);
- memcpy_fromio(regbuf, np->mmio_addr, regs->len);
- spin_unlock_irq(&np->lock);
+ spin_lock_irq(&tp->lock);
+ memcpy_fromio(regbuf, tp->mmio_addr, regs->len);
+ spin_unlock_irq(&tp->lock);
}
static int rtl8139_get_sset_count(struct net_device *dev, int sset)
@@ -2454,12 +2454,12 @@ static int rtl8139_get_sset_count(struct net_device *dev, int sset)
static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
{
- struct rtl8139_private *np = netdev_priv(dev);
+ struct rtl8139_private *tp = netdev_priv(dev);
- data[0] = np->xstats.early_rx;
- data[1] = np->xstats.tx_buf_mapped;
- data[2] = np->xstats.tx_timeouts;
- data[3] = np->xstats.rx_lost_in_ring;
+ data[0] = tp->xstats.early_rx;
+ data[1] = tp->xstats.tx_buf_mapped;
+ data[2] = tp->xstats.tx_timeouts;
+ data[3] = tp->xstats.rx_lost_in_ring;
}
static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -2486,15 +2486,15 @@ static const struct ethtool_ops rtl8139_ethtool_ops = {
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
- struct rtl8139_private *np = netdev_priv(dev);
+ struct rtl8139_private *tp = netdev_priv(dev);
int rc;
if (!netif_running(dev))
return -EINVAL;
- spin_lock_irq(&np->lock);
- rc = generic_mii_ioctl(&np->mii, if_mii(rq), cmd, NULL);
- spin_unlock_irq(&np->lock);
+ spin_lock_irq(&tp->lock);
+ rc = generic_mii_ioctl(&tp->mii, if_mii(rq), cmd, NULL);
+ spin_unlock_irq(&tp->lock);
return rc;
}
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index cca94b9c08ae..77547545509b 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -122,13 +122,13 @@ static char version[] __initdata =
#define ISCP_BUSY 0x00010000
#define MACH_IS_APRICOT 0
#else
-#define WSWAPrfd(x) ((struct i596_rfd *)(x))
-#define WSWAPrbd(x) ((struct i596_rbd *)(x))
-#define WSWAPiscp(x) ((struct i596_iscp *)(x))
-#define WSWAPscb(x) ((struct i596_scb *)(x))
-#define WSWAPcmd(x) ((struct i596_cmd *)(x))
-#define WSWAPtbd(x) ((struct i596_tbd *)(x))
-#define WSWAPchar(x) ((char *)(x))
+#define WSWAPrfd(x) ((struct i596_rfd *)((long)x))
+#define WSWAPrbd(x) ((struct i596_rbd *)((long)x))
+#define WSWAPiscp(x) ((struct i596_iscp *)((long)x))
+#define WSWAPscb(x) ((struct i596_scb *)((long)x))
+#define WSWAPcmd(x) ((struct i596_cmd *)((long)x))
+#define WSWAPtbd(x) ((struct i596_tbd *)((long)x))
+#define WSWAPchar(x) ((char *)((long)x))
#define ISCP_BUSY 0x0001
#define MACH_IS_APRICOT 1
#endif
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index ec3e22e6306f..21153dea8ebe 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -74,14 +74,8 @@ EXPORT_SYMBOL(ei_netdev_ops);
struct net_device *__alloc_ei_netdev(int size)
{
struct net_device *dev = ____alloc_ei_netdev(size);
-#ifdef CONFIG_COMPAT_NET_DEV_OPS
- if (dev) {
- dev->hard_start_xmit = ei_start_xmit;
- dev->get_stats = ei_get_stats;
- dev->set_multicast_list = ei_set_multicast_list;
- dev->tx_timeout = ei_tx_timeout;
- }
-#endif
+ if (dev)
+ dev->netdev_ops = &ei_netdev_ops;
return dev;
}
EXPORT_SYMBOL(__alloc_ei_netdev);
diff --git a/drivers/net/8390p.c b/drivers/net/8390p.c
index da863c91d1d0..d225c291fd93 100644
--- a/drivers/net/8390p.c
+++ b/drivers/net/8390p.c
@@ -79,14 +79,8 @@ EXPORT_SYMBOL(eip_netdev_ops);
struct net_device *__alloc_eip_netdev(int size)
{
struct net_device *dev = ____alloc_ei_netdev(size);
-#ifdef CONFIG_COMPAT_NET_DEV_OPS
- if (dev) {
- dev->hard_start_xmit = eip_start_xmit;
- dev->get_stats = eip_get_stats;
- dev->set_multicast_list = eip_set_multicast_list;
- dev->tx_timeout = eip_tx_timeout;
- }
-#endif
+ if (dev)
+ dev->netdev_ops = &eip_netdev_ops;
return dev;
}
EXPORT_SYMBOL(__alloc_eip_netdev);
@@ -97,16 +91,15 @@ void NS8390p_init(struct net_device *dev, int startp)
}
EXPORT_SYMBOL(NS8390p_init);
-#if defined(MODULE)
-
-int init_module(void)
+static int __init NS8390p_init_module(void)
{
return 0;
}
-void cleanup_module(void)
+static void __exit NS8390p_cleanup_module(void)
{
}
-#endif /* MODULE */
+module_init(NS8390p_init_module);
+module_exit(NS8390p_cleanup_module);
MODULE_LICENSE("GPL");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 214a92d1ef75..efa659f0fb53 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1,4 +1,3 @@
-
#
# Network device configuration
#
@@ -26,15 +25,6 @@ menuconfig NETDEVICES
# that for each of the symbols.
if NETDEVICES
-config COMPAT_NET_DEV_OPS
- default y
- bool "Enable older network device API compatibility"
- ---help---
- This option enables kernel compatibility with older network devices
- that do not use net_device_ops interface.
-
- If unsure, say Y.
-
config IFB
tristate "Intermediate Functional Block support"
depends on NET_CLS_ACT
@@ -927,6 +917,16 @@ config NET_NETX
To compile this driver as a module, choose M here. The module
will be called netx-eth.
+config TI_DAVINCI_EMAC
+ tristate "TI DaVinci EMAC Support"
+ depends on ARM && ARCH_DAVINCI
+ select PHYLIB
+ help
+ This driver supports TI's DaVinci Ethernet .
+
+ To compile this driver as a module, choose M here: the module
+ will be called davinci_emac_driver. This is recommended.
+
config DM9000
tristate "DM9000 support"
depends on ARM || BLACKFIN || MIPS
@@ -2351,7 +2351,7 @@ config UGETH_TX_ON_DEMAND
config MV643XX_ETH
tristate "Marvell Discovery (643XX) and Orion ethernet support"
- depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) || PLAT_ORION
+ depends on MV64360 || MV64X60 || PPC32 || PLAT_ORION
select INET_LRO
select PHYLIB
help
@@ -2362,6 +2362,14 @@ config MV643XX_ETH
Some boards that use the Discovery chipset are the Momenco
Ocelot C and Jaguar ATX and Pegasos II.
+config XILINX_LL_TEMAC
+ tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver"
+ select PHYLIB
+ depends on PPC_DCR_NATIVE
+ help
+ This driver supports the Xilinx 10/100/1000 LocalLink TEMAC
+ core used in Xilinx Spartan and Virtex FPGAs
+
config QLA3XXX
tristate "QLogic QLA3XXX Network Driver Support"
depends on PCI
@@ -2435,10 +2443,14 @@ menuconfig NETDEV_10000
if NETDEV_10000
+config MDIO
+ tristate
+
config CHELSIO_T1
tristate "Chelsio 10Gb Ethernet support"
depends on PCI
select CRC32
+ select MDIO
help
This driver supports Chelsio gigabit and 10-gigabit
Ethernet cards. More information about adapter features and
@@ -2471,6 +2483,7 @@ config CHELSIO_T3
tristate "Chelsio Communications T3 10Gb Ethernet support"
depends on CHELSIO_T3_DEPENDS
select FW_LOADER
+ select MDIO
help
This driver supports Chelsio T3-based gigabit and 10Gb Ethernet
adapters.
@@ -2506,6 +2519,7 @@ config ENIC
config IXGBE
tristate "Intel(R) 10GbE PCI Express adapters support"
depends on PCI && INET
+ select MDIO
---help---
This driver supports Intel(R) 10GbE PCI Express family of
adapters. For more information on how to identify your adapter, go
@@ -2668,6 +2682,7 @@ config TEHUTI
config BNX2X
tristate "Broadcom NetXtremeII 10Gb support"
depends on PCI
+ select FW_LOADER
select ZLIB_INFLATE
select LIBCRC32C
help
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 1fc4602a6ff2..774c2b45bdb8 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -2,6 +2,8 @@
# Makefile for the Linux network (ethercard) device drivers.
#
+obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o
+
obj-$(CONFIG_E1000) += e1000/
obj-$(CONFIG_E1000E) += e1000e/
obj-$(CONFIG_IBM_NEW_EMAC) += ibm_newemac/
@@ -95,6 +97,7 @@ obj-$(CONFIG_SH_ETH) += sh_eth.o
#
obj-$(CONFIG_MII) += mii.o
+obj-$(CONFIG_MDIO) += mdio.o
obj-$(CONFIG_PHYLIB) += phy/
obj-$(CONFIG_SUNDANCE) += sundance.o
@@ -102,7 +105,7 @@ obj-$(CONFIG_HAMACHI) += hamachi.o
obj-$(CONFIG_NET) += Space.o loopback.o
obj-$(CONFIG_SEEQ8005) += seeq8005.o
obj-$(CONFIG_NET_SB1000) += sb1000.o
-obj-$(CONFIG_MAC8390) += mac8390.o 8390.o
+obj-$(CONFIG_MAC8390) += mac8390.o
obj-$(CONFIG_APNE) += apne.o 8390.o
obj-$(CONFIG_PCMCIA_PCNET) += 8390.o
obj-$(CONFIG_HP100) += hp100.o
@@ -134,6 +137,8 @@ obj-$(CONFIG_AX88796) += ax88796.o
obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o
+ll_temac-objs := ll_temac_main.o ll_temac_mdio.o
+obj-$(CONFIG_XILINX_LL_TEMAC) += ll_temac.o
obj-$(CONFIG_QLA3XXX) += qla3xxx.o
obj-$(CONFIG_QLGE) += qlge/
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index da64ba88d7f8..f939e92fcf8a 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -71,6 +71,7 @@ static struct net_device * __init ipddp_init(void)
if (!dev)
return ERR_PTR(-ENOMEM);
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
strcpy(dev->name, "ipddp%d");
if (version_printed++ == 0)
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index 78cc71469136..b642647170be 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1220,7 +1220,7 @@ static int __init ltpc_setup(char *str)
if (ints[0] > 2) {
dma = ints[3];
}
- /* ignore any other paramters */
+ /* ignore any other parameters */
}
return 1;
}
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index a740053d3af3..b6d188115caf 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -456,7 +456,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
debug_desc(phys, desc);
BUG_ON(phys & 0x1F);
qmgr_put_entry(queue, phys);
- BUG_ON(qmgr_stat_overflow(queue));
+ /* Don't check for queue overflow here, we've allocated sufficient
+ length and queues >= 32 don't support this check anyway. */
}
@@ -512,8 +513,8 @@ static int eth_poll(struct napi_struct *napi, int budget)
#endif
napi_complete(napi);
qmgr_enable_irq(rxq);
- if (!qmgr_stat_empty(rxq) &&
- napi_reschedule(napi)) {
+ if (!qmgr_stat_below_low_watermark(rxq) &&
+ napi_reschedule(napi)) { /* not empty again */
#if DEBUG_RX
printk(KERN_DEBUG "%s: eth_poll"
" napi_reschedule successed\n",
@@ -630,9 +631,9 @@ static void eth_txdone_irq(void *unused)
port->tx_buff_tab[n_desc] = NULL;
}
- start = qmgr_stat_empty(port->plat->txreadyq);
+ start = qmgr_stat_below_low_watermark(port->plat->txreadyq);
queue_put_desc(port->plat->txreadyq, phys, desc);
- if (start) {
+ if (start) { /* TX-ready queue was empty */
#if DEBUG_TX
printk(KERN_DEBUG "%s: eth_txdone_irq xmit ready\n",
port->netdev->name);
@@ -708,13 +709,14 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
queue_put_desc(TX_QUEUE(port->id), tx_desc_phys(port, n), desc);
dev->trans_start = jiffies;
- if (qmgr_stat_empty(txreadyq)) {
+ if (qmgr_stat_below_low_watermark(txreadyq)) { /* empty */
#if DEBUG_TX
printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name);
#endif
netif_stop_queue(dev);
/* we could miss TX ready interrupt */
- if (!qmgr_stat_empty(txreadyq)) {
+ /* really empty in fact */
+ if (!qmgr_stat_below_low_watermark(txreadyq)) {
#if DEBUG_TX
printk(KERN_DEBUG "%s: eth_xmit ready again\n",
dev->name);
@@ -814,29 +816,29 @@ static int request_queues(struct port *port)
int err;
err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0,
- "%s:RX-free", port->netdev->name);
+ "%s:RX-free", port->netdev->name);
if (err)
return err;
err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0,
- "%s:RX", port->netdev->name);
+ "%s:RX", port->netdev->name);
if (err)
goto rel_rxfree;
err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0,
- "%s:TX", port->netdev->name);
+ "%s:TX", port->netdev->name);
if (err)
goto rel_rx;
err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
- "%s:TX-ready", port->netdev->name);
+ "%s:TX-ready", port->netdev->name);
if (err)
goto rel_tx;
/* TX-done queue handles skbs sent out by the NPEs */
if (!ports_open) {
err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0,
- "%s:TX-done", DRV_NAME);
+ "%s:TX-done", DRV_NAME);
if (err)
goto rel_txready;
}
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index 83a12125b94e..fc1092b835d2 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -220,11 +220,11 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
/* link down */
if (netif_carrier_ok(netdev)) {
hw->hibernate = true;
- atl1c_set_aspm(hw, false);
if (atl1c_stop_mac(hw) != 0)
if (netif_msg_hw(adapter))
dev_warn(&pdev->dev,
"stop mac failed\n");
+ atl1c_set_aspm(hw, false);
}
netif_carrier_off(netdev);
} else {
@@ -240,10 +240,10 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
adapter->link_duplex != duplex) {
adapter->link_speed = speed;
adapter->link_duplex = duplex;
+ atl1c_set_aspm(hw, true);
atl1c_enable_tx_ctrl(hw);
atl1c_enable_rx_ctrl(hw);
atl1c_setup_mac_ctrl(adapter);
- atl1c_set_aspm(hw, true);
if (netif_msg_link(adapter))
dev_info(&pdev->dev,
"%s: %s NIC Link is Up<%d Mbps %s>\n",
@@ -1242,9 +1242,7 @@ static void atl1c_set_aspm(struct atl1c_hw *hw, bool linkup)
AT_READ_REG(hw, REG_PM_CTRL, &pm_ctrl_data);
- pm_ctrl_data &= PM_CTRL_SERDES_PD_EX_L1;
- pm_ctrl_data |= ~PM_CTRL_SERDES_BUDS_RX_L1_EN;
- pm_ctrl_data |= ~PM_CTRL_SERDES_L1_EN;
+ pm_ctrl_data &= ~PM_CTRL_SERDES_PD_EX_L1;
pm_ctrl_data &= ~(PM_CTRL_L1_ENTRY_TIMER_MASK <<
PM_CTRL_L1_ENTRY_TIMER_SHIFT);
@@ -1254,19 +1252,11 @@ static void atl1c_set_aspm(struct atl1c_hw *hw, bool linkup)
pm_ctrl_data |= PM_CTRL_SERDES_PLL_L1_EN;
pm_ctrl_data &= ~PM_CTRL_CLK_SWH_L1;
- if (hw->ctrl_flags & ATL1C_ASPM_L1_SUPPORT) {
- pm_ctrl_data |= AT_ASPM_L1_TIMER <<
- PM_CTRL_L1_ENTRY_TIMER_SHIFT;
- pm_ctrl_data |= PM_CTRL_ASPM_L1_EN;
- } else
- pm_ctrl_data &= ~PM_CTRL_ASPM_L1_EN;
-
- if (hw->ctrl_flags & ATL1C_ASPM_L0S_SUPPORT)
- pm_ctrl_data |= PM_CTRL_ASPM_L0S_EN;
- else
- pm_ctrl_data &= ~PM_CTRL_ASPM_L0S_EN;
-
+ pm_ctrl_data |= PM_CTRL_SERDES_BUDS_RX_L1_EN;
+ pm_ctrl_data |= PM_CTRL_SERDES_L1_EN;
} else {
+ pm_ctrl_data &= ~PM_CTRL_SERDES_BUDS_RX_L1_EN;
+ pm_ctrl_data &= ~PM_CTRL_SERDES_L1_EN;
pm_ctrl_data &= ~PM_CTRL_ASPM_L0S_EN;
pm_ctrl_data &= ~PM_CTRL_SERDES_PLL_L1_EN;
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index fb57b750866b..adac06195c8f 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -1794,8 +1794,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
memcpy(use_tpd, tpd, sizeof(struct atl1e_tpd_desc));
tx_buffer = atl1e_get_tx_buffer(adapter, use_tpd);
- if (tx_buffer->skb)
- BUG();
+ BUG_ON(tx_buffer->skb);
tx_buffer->skb = NULL;
tx_buffer->length =
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 0ab22540bf59..13f0bdc32449 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -2207,8 +2207,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
nr_frags = skb_shinfo(skb)->nr_frags;
next_to_use = atomic_read(&tpd_ring->next_to_use);
buffer_info = &tpd_ring->buffer_info[next_to_use];
- if (unlikely(buffer_info->skb))
- BUG();
+ BUG_ON(buffer_info->skb);
/* put skb in last TPD */
buffer_info->skb = NULL;
@@ -2274,8 +2273,8 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
ATL1_MAX_TX_BUF_LEN;
for (i = 0; i < nseg; i++) {
buffer_info = &tpd_ring->buffer_info[next_to_use];
- if (unlikely(buffer_info->skb))
- BUG();
+ BUG_ON(buffer_info->skb);
+
buffer_info->skb = NULL;
buffer_info->length = (buf_len > ATL1_MAX_TX_BUF_LEN) ?
ATL1_MAX_TX_BUF_LEN : buf_len;
diff --git a/drivers/net/b44.h b/drivers/net/b44.h
index e678498de6db..d24158e7f309 100644
--- a/drivers/net/b44.h
+++ b/drivers/net/b44.h
@@ -97,7 +97,7 @@
#define B44_DMARX_STAT 0x021CUL /* DMA RX Current Active Desc. + Status */
#define DMARX_STAT_CDMASK 0x00000fff /* Current Descriptor Mask */
#define DMARX_STAT_SMASK 0x0000f000 /* State Mask */
-#define DMARX_STAT_SDISABLED 0x00000000 /* State Disbaled */
+#define DMARX_STAT_SDISABLED 0x00000000 /* State Disabled */
#define DMARX_STAT_SACTIVE 0x00001000 /* State Active */
#define DMARX_STAT_SIDLE 0x00002000 /* State Idle Wait */
#define DMARX_STAT_SSTOPPED 0x00003000 /* State Stopped */
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 5c378b5e8e41..ae2f6b58ba25 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -637,6 +637,22 @@ static void be_rx_stats_update(struct be_adapter *adapter,
stats->be_rx_bytes += pktsize;
}
+static inline bool do_pkt_csum(struct be_eth_rx_compl *rxcp, bool cso)
+{
+ u8 l4_cksm, ip_version, ipcksm, tcpf = 0, udpf = 0, ipv6_chk;
+
+ l4_cksm = AMAP_GET_BITS(struct amap_eth_rx_compl, l4_cksm, rxcp);
+ ipcksm = AMAP_GET_BITS(struct amap_eth_rx_compl, ipcksm, rxcp);
+ ip_version = AMAP_GET_BITS(struct amap_eth_rx_compl, ip_version, rxcp);
+ if (ip_version) {
+ tcpf = AMAP_GET_BITS(struct amap_eth_rx_compl, tcpf, rxcp);
+ udpf = AMAP_GET_BITS(struct amap_eth_rx_compl, udpf, rxcp);
+ }
+ ipv6_chk = (ip_version && (tcpf || udpf));
+
+ return ((l4_cksm && ipv6_chk && ipcksm) && cso) ? false : true;
+}
+
static struct be_rx_page_info *
get_rx_page_info(struct be_adapter *adapter, u16 frag_idx)
{
@@ -752,9 +768,7 @@ static void be_rx_compl_process(struct be_adapter *adapter,
{
struct sk_buff *skb;
u32 vtp, vid;
- int l4_cksm;
- l4_cksm = AMAP_GET_BITS(struct amap_eth_rx_compl, l4_cksm, rxcp);
vtp = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp);
skb = netdev_alloc_skb(adapter->netdev, BE_HDR_LEN + NET_IP_ALIGN);
@@ -769,10 +783,10 @@ static void be_rx_compl_process(struct be_adapter *adapter,
skb_fill_rx_data(adapter, skb, rxcp);
- if (l4_cksm && adapter->rx_csum)
- skb->ip_summed = CHECKSUM_UNNECESSARY;
- else
+ if (do_pkt_csum(rxcp, adapter->rx_csum))
skb->ip_summed = CHECKSUM_NONE;
+ else
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
skb->truesize = skb->len + sizeof(struct sk_buff);
skb->protocol = eth_type_trans(skb, adapter->netdev);
@@ -1626,10 +1640,12 @@ static void be_netdev_init(struct net_device *netdev)
netdev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_RX | NETIF_F_TSO |
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER | NETIF_F_IP_CSUM |
- NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
+ NETIF_F_IPV6_CSUM;
netdev->flags |= IFF_MULTICAST;
+ adapter->rx_csum = true;
+
BE_SET_NETDEV_OPS(netdev, &be_netdev_ops);
SET_ETHTOOL_OPS(netdev, &be_ethtool_ops);
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 44d015f70d1c..9578a3dfac01 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -1247,6 +1247,16 @@ static const struct ethtool_ops bmac_ethtool_ops = {
.get_link = ethtool_op_get_link,
};
+static const struct net_device_ops bmac_netdev_ops = {
+ .ndo_open = bmac_open,
+ .ndo_stop = bmac_close,
+ .ndo_start_xmit = bmac_output,
+ .ndo_set_multicast_list = bmac_set_multicast,
+ .ndo_set_mac_address = bmac_set_address,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
{
int j, rev, ret;
@@ -1308,12 +1318,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
bmac_enable_and_reset_chip(dev);
bmwrite(dev, INTDISABLE, DisableAll);
- dev->open = bmac_open;
- dev->stop = bmac_close;
+ dev->netdev_ops = &bmac_netdev_ops;
dev->ethtool_ops = &bmac_ethtool_ops;
- dev->hard_start_xmit = bmac_output;
- dev->set_multicast_list = bmac_set_multicast;
- dev->set_mac_address = bmac_set_address;
bmac_get_station_address(dev, addr);
if (bmac_verify_checksum(dev) != 0)
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index b0cb29d4cc01..c37acc1d10ac 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2630,14 +2630,15 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
tx_buf = &txr->tx_buf_ring[sw_ring_cons];
skb = tx_buf->skb;
+ /* prefetch skb_end_pointer() to speedup skb_shinfo(skb) */
+ prefetch(&skb->end);
+
/* partial BD completions possible with TSO packets */
- if (skb_is_gso(skb)) {
+ if (tx_buf->is_gso) {
u16 last_idx, last_ring_idx;
- last_idx = sw_cons +
- skb_shinfo(skb)->nr_frags + 1;
- last_ring_idx = sw_ring_cons +
- skb_shinfo(skb)->nr_frags + 1;
+ last_idx = sw_cons + tx_buf->nr_frags + 1;
+ last_ring_idx = sw_ring_cons + tx_buf->nr_frags + 1;
if (unlikely(last_ring_idx >= MAX_TX_DESC_CNT)) {
last_idx++;
}
@@ -2649,7 +2650,7 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE);
tx_buf->skb = NULL;
- last = skb_shinfo(skb)->nr_frags;
+ last = tx_buf->nr_frags;
for (i = 0; i < last; i++) {
sw_cons = NEXT_TX_BD(sw_cons);
@@ -2662,7 +2663,8 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
if (tx_pkt == budget)
break;
- hw_cons = bnx2_get_hw_tx_cons(bnapi);
+ if (hw_cons == sw_cons)
+ hw_cons = bnx2_get_hw_tx_cons(bnapi);
}
txr->hw_tx_cons = hw_cons;
@@ -6179,6 +6181,8 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
txbd->tx_bd_vlan_tag_flags = vlan_tag_flags | TX_BD_FLAGS_START;
last_frag = skb_shinfo(skb)->nr_frags;
+ tx_buf->nr_frags = last_frag;
+ tx_buf->is_gso = skb_is_gso(skb);
for (i = 0; i < last_frag; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 5b570e17c839..026ed1c84698 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6552,6 +6552,8 @@ struct sw_pg {
struct sw_tx_bd {
struct sk_buff *skb;
+ unsigned short is_gso;
+ unsigned short nr_frags;
};
#define SW_RXBD_RING_SIZE (sizeof(struct sw_bd) * RX_DESC_CNT)
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index a329bee25550..8678457849f9 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -965,6 +965,21 @@ struct bnx2x {
int gunzip_outlen;
#define FW_BUF_SIZE 0x8000
+ struct raw_op *init_ops;
+ /* Init blocks offsets inside init_ops */
+ u16 *init_ops_offsets;
+ /* Data blob - has 32 bit granularity */
+ u32 *init_data;
+ /* Zipped PRAM blobs - raw data */
+ const u8 *tsem_int_table_data;
+ const u8 *tsem_pram_data;
+ const u8 *usem_int_table_data;
+ const u8 *usem_pram_data;
+ const u8 *xsem_int_table_data;
+ const u8 *xsem_pram_data;
+ const u8 *csem_int_table_data;
+ const u8 *csem_pram_data;
+ const struct firmware *firmware;
};
diff --git a/drivers/net/bnx2x_fw_file_hdr.h b/drivers/net/bnx2x_fw_file_hdr.h
new file mode 100644
index 000000000000..3f5ee5d7cc2a
--- /dev/null
+++ b/drivers/net/bnx2x_fw_file_hdr.h
@@ -0,0 +1,37 @@
+/* bnx2x_fw_file_hdr.h: FW binary file header structure.
+ *
+ * Copyright (c) 2007-2009 Broadcom Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ * Maintained by: Eilon Greenstein <eilong@broadcom.com>
+ * Written by: Vladislav Zolotarov <vladz@broadcom.com>
+ * Based on the original idea of John Wright <john.wright@hp.com>.
+ */
+
+#ifndef BNX2X_INIT_FILE_HDR_H
+#define BNX2X_INIT_FILE_HDR_H
+
+struct bnx2x_fw_file_section {
+ __be32 len;
+ __be32 offset;
+};
+
+struct bnx2x_fw_file_hdr {
+ struct bnx2x_fw_file_section init_ops;
+ struct bnx2x_fw_file_section init_ops_offsets;
+ struct bnx2x_fw_file_section init_data;
+ struct bnx2x_fw_file_section tsem_int_table_data;
+ struct bnx2x_fw_file_section tsem_pram_data;
+ struct bnx2x_fw_file_section usem_int_table_data;
+ struct bnx2x_fw_file_section usem_pram_data;
+ struct bnx2x_fw_file_section csem_int_table_data;
+ struct bnx2x_fw_file_section csem_pram_data;
+ struct bnx2x_fw_file_section xsem_int_table_data;
+ struct bnx2x_fw_file_section xsem_pram_data;
+ struct bnx2x_fw_file_section fw_version;
+};
+
+#endif /* BNX2X_INIT_FILE_HDR_H */
diff --git a/drivers/net/bnx2x_init.h b/drivers/net/bnx2x_init.h
index 39ba2936c0c2..3ba4d888068f 100644
--- a/drivers/net/bnx2x_init.h
+++ b/drivers/net/bnx2x_init.h
@@ -1,4 +1,5 @@
/* bnx2x_init.h: Broadcom Everest network driver.
+ * Structures and macroes needed during the initialization.
*
* Copyright (c) 2007-2009 Broadcom Corporation
*
@@ -8,6 +9,7 @@
*
* Maintained by: Eilon Greenstein <eilong@broadcom.com>
* Written by: Eliezer Tamir
+ * Modified by: Vladislav Zolotarov <vladz@broadcom.com>
*/
#ifndef BNX2X_INIT_H
@@ -45,33 +47,71 @@
#define OP_WR_64 0x8 /* write 64 bit pattern */
#define OP_WB 0x9 /* copy a string using DMAE */
-/* Operation specific for E1 */
-#define OP_RD_E1 0xa /* read single register */
-#define OP_WR_E1 0xb /* write single register */
-#define OP_IW_E1 0xc /* write single register using mailbox */
-#define OP_SW_E1 0xd /* copy a string to the device */
-#define OP_SI_E1 0xe /* copy a string using mailbox */
-#define OP_ZR_E1 0xf /* clear memory */
-#define OP_ZP_E1 0x10 /* unzip then copy with DMAE */
-#define OP_WR_64_E1 0x11 /* write 64 bit pattern on E1 */
-#define OP_WB_E1 0x12 /* copy a string using DMAE */
-
-/* Operation specific for E1H */
-#define OP_RD_E1H 0x13 /* read single register */
-#define OP_WR_E1H 0x14 /* write single register */
-#define OP_IW_E1H 0x15 /* write single register using mailbox */
-#define OP_SW_E1H 0x16 /* copy a string to the device */
-#define OP_SI_E1H 0x17 /* copy a string using mailbox */
-#define OP_ZR_E1H 0x18 /* clear memory */
-#define OP_ZP_E1H 0x19 /* unzip then copy with DMAE */
-#define OP_WR_64_E1H 0x1a /* write 64 bit pattern on E1H */
-#define OP_WB_E1H 0x1b /* copy a string using DMAE */
-
/* FPGA and EMUL specific operations */
-#define OP_WR_EMUL_E1H 0x1c /* write single register on E1H Emul */
-#define OP_WR_EMUL 0x1d /* write single register on Emulation */
-#define OP_WR_FPGA 0x1e /* write single register on FPGA */
-#define OP_WR_ASIC 0x1f /* write single register on ASIC */
+#define OP_WR_EMUL 0xa /* write single register on Emulation */
+#define OP_WR_FPGA 0xb /* write single register on FPGA */
+#define OP_WR_ASIC 0xc /* write single register on ASIC */
+
+/* Init stages */
+#define COMMON_STAGE 0
+#define PORT0_STAGE 1
+#define PORT1_STAGE 2
+/* Never reorder FUNCx stages !!! */
+#define FUNC0_STAGE 3
+#define FUNC1_STAGE 4
+#define FUNC2_STAGE 5
+#define FUNC3_STAGE 6
+#define FUNC4_STAGE 7
+#define FUNC5_STAGE 8
+#define FUNC6_STAGE 9
+#define FUNC7_STAGE 10
+#define STAGE_IDX_MAX 11
+
+#define STAGE_START 0
+#define STAGE_END 1
+
+
+/* Indices of blocks */
+#define PRS_BLOCK 0
+#define SRCH_BLOCK 1
+#define TSDM_BLOCK 2
+#define TCM_BLOCK 3
+#define BRB1_BLOCK 4
+#define TSEM_BLOCK 5
+#define PXPCS_BLOCK 6
+#define EMAC0_BLOCK 7
+#define EMAC1_BLOCK 8
+#define DBU_BLOCK 9
+#define MISC_BLOCK 10
+#define DBG_BLOCK 11
+#define NIG_BLOCK 12
+#define MCP_BLOCK 13
+#define UPB_BLOCK 14
+#define CSDM_BLOCK 15
+#define USDM_BLOCK 16
+#define CCM_BLOCK 17
+#define UCM_BLOCK 18
+#define USEM_BLOCK 19
+#define CSEM_BLOCK 20
+#define XPB_BLOCK 21
+#define DQ_BLOCK 22
+#define TIMERS_BLOCK 23
+#define XSDM_BLOCK 24
+#define QM_BLOCK 25
+#define PBF_BLOCK 26
+#define XCM_BLOCK 27
+#define XSEM_BLOCK 28
+#define CDU_BLOCK 29
+#define DMAE_BLOCK 30
+#define PXP_BLOCK 31
+#define CFC_BLOCK 32
+#define HC_BLOCK 33
+#define PXP2_BLOCK 34
+#define MISC_AEU_BLOCK 35
+
+/* Returns the index of start or end of a specific block stage in ops array*/
+#define BLOCK_OPS_IDX(block, stage, end) \
+ (2*(((block)*STAGE_IDX_MAX) + (stage)) + (end))
struct raw_op {
@@ -118,292 +158,6 @@ union init_op {
struct raw_op raw;
};
-#include "bnx2x_init_values.h"
-
-static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
-static int bnx2x_gunzip(struct bnx2x *bp, u8 *zbuf, int len);
-
-static void bnx2x_init_str_wr(struct bnx2x *bp, u32 addr, const u32 *data,
- u32 len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- REG_WR(bp, addr + i*4, data[i]);
- if (!(i % 10000)) {
- touch_softlockup_watchdog();
- cpu_relax();
- }
- }
-}
-
-static void bnx2x_init_ind_wr(struct bnx2x *bp, u32 addr, const u32 *data,
- u16 len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- REG_WR_IND(bp, addr + i*4, data[i]);
- if (!(i % 10000)) {
- touch_softlockup_watchdog();
- cpu_relax();
- }
- }
-}
-
-static void bnx2x_write_big_buf(struct bnx2x *bp, u32 addr, u32 len)
-{
- int offset = 0;
-
- if (bp->dmae_ready) {
- while (len > DMAE_LEN32_WR_MAX) {
- bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
- addr + offset, DMAE_LEN32_WR_MAX);
- offset += DMAE_LEN32_WR_MAX * 4;
- len -= DMAE_LEN32_WR_MAX;
- }
- bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
- addr + offset, len);
- } else
- bnx2x_init_str_wr(bp, addr, bp->gunzip_buf, len);
-}
-
-static void bnx2x_init_fill(struct bnx2x *bp, u32 addr, int fill, u32 len)
-{
- u32 buf_len = (((len * 4) > FW_BUF_SIZE) ? FW_BUF_SIZE : (len * 4));
- u32 buf_len32 = buf_len / 4;
- int i;
-
- memset(bp->gunzip_buf, fill, buf_len);
-
- for (i = 0; i < len; i += buf_len32) {
- u32 cur_len = min(buf_len32, len - i);
-
- bnx2x_write_big_buf(bp, addr + i * 4, cur_len);
- }
-}
-
-static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr, const u32 *data,
- u32 len64)
-{
- u32 buf_len32 = FW_BUF_SIZE / 4;
- u32 len = len64 * 2;
- u64 data64 = 0;
- int i;
-
- /* 64 bit value is in a blob: first low DWORD, then high DWORD */
- data64 = HILO_U64((*(data + 1)), (*data));
- len64 = min((u32)(FW_BUF_SIZE/8), len64);
- for (i = 0; i < len64; i++) {
- u64 *pdata = ((u64 *)(bp->gunzip_buf)) + i;
-
- *pdata = data64;
- }
-
- for (i = 0; i < len; i += buf_len32) {
- u32 cur_len = min(buf_len32, len - i);
-
- bnx2x_write_big_buf(bp, addr + i * 4, cur_len);
- }
-}
-
-/*********************************************************
- There are different blobs for each PRAM section.
- In addition, each blob write operation is divided into a few operations
- in order to decrease the amount of phys. contiguous buffer needed.
- Thus, when we select a blob the address may be with some offset
- from the beginning of PRAM section.
- The same holds for the INT_TABLE sections.
-**********************************************************/
-#define IF_IS_INT_TABLE_ADDR(base, addr) \
- if (((base) <= (addr)) && ((base) + 0x400 >= (addr)))
-
-#define IF_IS_PRAM_ADDR(base, addr) \
- if (((base) <= (addr)) && ((base) + 0x40000 >= (addr)))
-
-static const u32 *bnx2x_sel_blob(u32 addr, const u32 *data, int is_e1)
-{
- IF_IS_INT_TABLE_ADDR(TSEM_REG_INT_TABLE, addr)
- data = is_e1 ? tsem_int_table_data_e1 :
- tsem_int_table_data_e1h;
- else
- IF_IS_INT_TABLE_ADDR(CSEM_REG_INT_TABLE, addr)
- data = is_e1 ? csem_int_table_data_e1 :
- csem_int_table_data_e1h;
- else
- IF_IS_INT_TABLE_ADDR(USEM_REG_INT_TABLE, addr)
- data = is_e1 ? usem_int_table_data_e1 :
- usem_int_table_data_e1h;
- else
- IF_IS_INT_TABLE_ADDR(XSEM_REG_INT_TABLE, addr)
- data = is_e1 ? xsem_int_table_data_e1 :
- xsem_int_table_data_e1h;
- else
- IF_IS_PRAM_ADDR(TSEM_REG_PRAM, addr)
- data = is_e1 ? tsem_pram_data_e1 : tsem_pram_data_e1h;
- else
- IF_IS_PRAM_ADDR(CSEM_REG_PRAM, addr)
- data = is_e1 ? csem_pram_data_e1 : csem_pram_data_e1h;
- else
- IF_IS_PRAM_ADDR(USEM_REG_PRAM, addr)
- data = is_e1 ? usem_pram_data_e1 : usem_pram_data_e1h;
- else
- IF_IS_PRAM_ADDR(XSEM_REG_PRAM, addr)
- data = is_e1 ? xsem_pram_data_e1 : xsem_pram_data_e1h;
-
- return data;
-}
-
-static void bnx2x_init_wr_wb(struct bnx2x *bp, u32 addr, const u32 *data,
- u32 len, int gunzip, int is_e1, u32 blob_off)
-{
- int offset = 0;
-
- data = bnx2x_sel_blob(addr, data, is_e1) + blob_off;
-
- if (gunzip) {
- int rc;
-#ifdef __BIG_ENDIAN
- int i, size;
- u32 *temp;
-
- temp = kmalloc(len, GFP_KERNEL);
- size = (len / 4) + ((len % 4) ? 1 : 0);
- for (i = 0; i < size; i++)
- temp[i] = swab32(data[i]);
- data = temp;
-#endif
- rc = bnx2x_gunzip(bp, (u8 *)data, len);
- if (rc) {
- BNX2X_ERR("gunzip failed ! rc %d\n", rc);
-#ifdef __BIG_ENDIAN
- kfree(temp);
-#endif
- return;
- }
- len = bp->gunzip_outlen;
-#ifdef __BIG_ENDIAN
- kfree(temp);
- for (i = 0; i < len; i++)
- ((u32 *)bp->gunzip_buf)[i] =
- swab32(((u32 *)bp->gunzip_buf)[i]);
-#endif
- } else {
- if ((len * 4) > FW_BUF_SIZE) {
- BNX2X_ERR("LARGE DMAE OPERATION ! "
- "addr 0x%x len 0x%x\n", addr, len*4);
- return;
- }
- memcpy(bp->gunzip_buf, data, len * 4);
- }
-
- if (bp->dmae_ready) {
- while (len > DMAE_LEN32_WR_MAX) {
- bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
- addr + offset, DMAE_LEN32_WR_MAX);
- offset += DMAE_LEN32_WR_MAX * 4;
- len -= DMAE_LEN32_WR_MAX;
- }
- bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
- addr + offset, len);
- } else
- bnx2x_init_ind_wr(bp, addr, bp->gunzip_buf, len);
-}
-
-static void bnx2x_init_block(struct bnx2x *bp, u32 op_start, u32 op_end)
-{
- int is_e1 = CHIP_IS_E1(bp);
- int is_e1h = CHIP_IS_E1H(bp);
- int is_emul_e1h = (CHIP_REV_IS_EMUL(bp) && is_e1h);
- int hw_wr, i;
- union init_op *op;
- u32 op_type, addr, len;
- const u32 *data, *data_base;
-
- if (CHIP_REV_IS_FPGA(bp))
- hw_wr = OP_WR_FPGA;
- else if (CHIP_REV_IS_EMUL(bp))
- hw_wr = OP_WR_EMUL;
- else
- hw_wr = OP_WR_ASIC;
-
- if (is_e1)
- data_base = init_data_e1;
- else /* CHIP_IS_E1H(bp) */
- data_base = init_data_e1h;
-
- for (i = op_start; i < op_end; i++) {
-
- op = (union init_op *)&(init_ops[i]);
-
- op_type = op->str_wr.op;
- addr = op->str_wr.offset;
- len = op->str_wr.data_len;
- data = data_base + op->str_wr.data_off;
-
- /* careful! it must be in order */
- if (unlikely(op_type > OP_WB)) {
-
- /* If E1 only */
- if (op_type <= OP_WB_E1) {
- if (is_e1)
- op_type -= (OP_RD_E1 - OP_RD);
-
- /* If E1H only */
- } else if (op_type <= OP_WB_E1H) {
- if (is_e1h)
- op_type -= (OP_RD_E1H - OP_RD);
- }
-
- /* HW/EMUL specific */
- if (op_type == hw_wr)
- op_type = OP_WR;
-
- /* EMUL on E1H is special */
- if ((op_type == OP_WR_EMUL_E1H) && is_emul_e1h)
- op_type = OP_WR;
- }
-
- switch (op_type) {
- case OP_RD:
- REG_RD(bp, addr);
- break;
- case OP_WR:
- REG_WR(bp, addr, op->write.val);
- break;
- case OP_SW:
- bnx2x_init_str_wr(bp, addr, data, len);
- break;
- case OP_WB:
- bnx2x_init_wr_wb(bp, addr, data, len, 0, is_e1, 0);
- break;
- case OP_SI:
- bnx2x_init_ind_wr(bp, addr, data, len);
- break;
- case OP_ZR:
- bnx2x_init_fill(bp, addr, 0, op->zero.len);
- break;
- case OP_ZP:
- bnx2x_init_wr_wb(bp, addr, data, len, 1, is_e1,
- op->str_wr.data_off);
- break;
- case OP_WR_64:
- bnx2x_init_wr_64(bp, addr, data, len);
- break;
- default:
- /* happens whenever an op is of a diff HW */
-#if 0
- DP(NETIF_MSG_HW, "skipping init operation "
- "index %d[%d:%d]: type %d addr 0x%x "
- "len %d(0x%x)\n",
- i, op_start, op_end, op_type, addr, len, len);
-#endif
- break;
- }
- }
-}
-
-
/****************************************************************************
* PXP
****************************************************************************/
@@ -567,111 +321,6 @@ static const struct arb_line write_arb_addr[NUM_WR_Q-1] = {
PXP2_REG_RQ_BW_WR_UBOUND30}
};
-static void bnx2x_init_pxp(struct bnx2x *bp)
-{
- u16 devctl;
- int r_order, w_order;
- u32 val, i;
-
- pci_read_config_word(bp->pdev,
- bp->pcie_cap + PCI_EXP_DEVCTL, &devctl);
- DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
- w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
- if (bp->mrrs == -1)
- r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12);
- else {
- DP(NETIF_MSG_HW, "force read order to %d\n", bp->mrrs);
- r_order = bp->mrrs;
- }
-
- if (r_order > MAX_RD_ORD) {
- DP(NETIF_MSG_HW, "read order of %d order adjusted to %d\n",
- r_order, MAX_RD_ORD);
- r_order = MAX_RD_ORD;
- }
- if (w_order > MAX_WR_ORD) {
- DP(NETIF_MSG_HW, "write order of %d order adjusted to %d\n",
- w_order, MAX_WR_ORD);
- w_order = MAX_WR_ORD;
- }
- if (CHIP_REV_IS_FPGA(bp)) {
- DP(NETIF_MSG_HW, "write order adjusted to 1 for FPGA\n");
- w_order = 0;
- }
- DP(NETIF_MSG_HW, "read order %d write order %d\n", r_order, w_order);
-
- for (i = 0; i < NUM_RD_Q-1; i++) {
- REG_WR(bp, read_arb_addr[i].l, read_arb_data[i][r_order].l);
- REG_WR(bp, read_arb_addr[i].add,
- read_arb_data[i][r_order].add);
- REG_WR(bp, read_arb_addr[i].ubound,
- read_arb_data[i][r_order].ubound);
- }
-
- for (i = 0; i < NUM_WR_Q-1; i++) {
- if ((write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L29) ||
- (write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L30)) {
-
- REG_WR(bp, write_arb_addr[i].l,
- write_arb_data[i][w_order].l);
-
- REG_WR(bp, write_arb_addr[i].add,
- write_arb_data[i][w_order].add);
-
- REG_WR(bp, write_arb_addr[i].ubound,
- write_arb_data[i][w_order].ubound);
- } else {
-
- val = REG_RD(bp, write_arb_addr[i].l);
- REG_WR(bp, write_arb_addr[i].l,
- val | (write_arb_data[i][w_order].l << 10));
-
- val = REG_RD(bp, write_arb_addr[i].add);
- REG_WR(bp, write_arb_addr[i].add,
- val | (write_arb_data[i][w_order].add << 10));
-
- val = REG_RD(bp, write_arb_addr[i].ubound);
- REG_WR(bp, write_arb_addr[i].ubound,
- val | (write_arb_data[i][w_order].ubound << 7));
- }
- }
-
- val = write_arb_data[NUM_WR_Q-1][w_order].add;
- val += write_arb_data[NUM_WR_Q-1][w_order].ubound << 10;
- val += write_arb_data[NUM_WR_Q-1][w_order].l << 17;
- REG_WR(bp, PXP2_REG_PSWRQ_BW_RD, val);
-
- val = read_arb_data[NUM_RD_Q-1][r_order].add;
- val += read_arb_data[NUM_RD_Q-1][r_order].ubound << 10;
- val += read_arb_data[NUM_RD_Q-1][r_order].l << 17;
- REG_WR(bp, PXP2_REG_PSWRQ_BW_WR, val);
-
- REG_WR(bp, PXP2_REG_RQ_WR_MBS0, w_order);
- REG_WR(bp, PXP2_REG_RQ_WR_MBS1, w_order);
- REG_WR(bp, PXP2_REG_RQ_RD_MBS0, r_order);
- REG_WR(bp, PXP2_REG_RQ_RD_MBS1, r_order);
-
- if (r_order == MAX_RD_ORD)
- REG_WR(bp, PXP2_REG_RQ_PDR_LIMIT, 0xe00);
-
- REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x18 << w_order));
-
- if (CHIP_IS_E1H(bp)) {
- val = ((w_order == 0) ? 2 : 3);
- REG_WR(bp, PXP2_REG_WR_HC_MPS, val);
- REG_WR(bp, PXP2_REG_WR_USDM_MPS, val);
- REG_WR(bp, PXP2_REG_WR_CSDM_MPS, val);
- REG_WR(bp, PXP2_REG_WR_TSDM_MPS, val);
- REG_WR(bp, PXP2_REG_WR_XSDM_MPS, val);
- REG_WR(bp, PXP2_REG_WR_QM_MPS, val);
- REG_WR(bp, PXP2_REG_WR_TM_MPS, val);
- REG_WR(bp, PXP2_REG_WR_SRC_MPS, val);
- REG_WR(bp, PXP2_REG_WR_DBG_MPS, val);
- REG_WR(bp, PXP2_REG_WR_DMAE_MPS, 2); /* DMAE is special */
- REG_WR(bp, PXP2_REG_WR_CDU_MPS, val);
- }
-}
-
/****************************************************************************
* CDU
@@ -695,128 +344,12 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
(0x80 | ((_type) & 0xf << 3) | (CDU_CRC8(_cid, _region, _type) & 0x7))
#define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80)
-/*****************************************************************************
- * Description:
- * Calculates crc 8 on a word value: polynomial 0-1-2-8
- * Code was translated from Verilog.
- ****************************************************************************/
-static u8 calc_crc8(u32 data, u8 crc)
-{
- u8 D[32];
- u8 NewCRC[8];
- u8 C[8];
- u8 crc_res;
- u8 i;
-
- /* split the data into 31 bits */
- for (i = 0; i < 32; i++) {
- D[i] = data & 1;
- data = data >> 1;
- }
-
- /* split the crc into 8 bits */
- for (i = 0; i < 8; i++) {
- C[i] = crc & 1;
- crc = crc >> 1;
- }
-
- NewCRC[0] = D[31] ^ D[30] ^ D[28] ^ D[23] ^ D[21] ^ D[19] ^ D[18] ^
- D[16] ^ D[14] ^ D[12] ^ D[8] ^ D[7] ^ D[6] ^ D[0] ^ C[4] ^
- C[6] ^ C[7];
- NewCRC[1] = D[30] ^ D[29] ^ D[28] ^ D[24] ^ D[23] ^ D[22] ^ D[21] ^
- D[20] ^ D[18] ^ D[17] ^ D[16] ^ D[15] ^ D[14] ^ D[13] ^
- D[12] ^ D[9] ^ D[6] ^ D[1] ^ D[0] ^ C[0] ^ C[4] ^ C[5] ^ C[6];
- NewCRC[2] = D[29] ^ D[28] ^ D[25] ^ D[24] ^ D[22] ^ D[17] ^ D[15] ^
- D[13] ^ D[12] ^ D[10] ^ D[8] ^ D[6] ^ D[2] ^ D[1] ^ D[0] ^
- C[0] ^ C[1] ^ C[4] ^ C[5];
- NewCRC[3] = D[30] ^ D[29] ^ D[26] ^ D[25] ^ D[23] ^ D[18] ^ D[16] ^
- D[14] ^ D[13] ^ D[11] ^ D[9] ^ D[7] ^ D[3] ^ D[2] ^ D[1] ^
- C[1] ^ C[2] ^ C[5] ^ C[6];
- NewCRC[4] = D[31] ^ D[30] ^ D[27] ^ D[26] ^ D[24] ^ D[19] ^ D[17] ^
- D[15] ^ D[14] ^ D[12] ^ D[10] ^ D[8] ^ D[4] ^ D[3] ^ D[2] ^
- C[0] ^ C[2] ^ C[3] ^ C[6] ^ C[7];
- NewCRC[5] = D[31] ^ D[28] ^ D[27] ^ D[25] ^ D[20] ^ D[18] ^ D[16] ^
- D[15] ^ D[13] ^ D[11] ^ D[9] ^ D[5] ^ D[4] ^ D[3] ^ C[1] ^
- C[3] ^ C[4] ^ C[7];
- NewCRC[6] = D[29] ^ D[28] ^ D[26] ^ D[21] ^ D[19] ^ D[17] ^ D[16] ^
- D[14] ^ D[12] ^ D[10] ^ D[6] ^ D[5] ^ D[4] ^ C[2] ^ C[4] ^
- C[5];
- NewCRC[7] = D[30] ^ D[29] ^ D[27] ^ D[22] ^ D[20] ^ D[18] ^ D[17] ^
- D[15] ^ D[13] ^ D[11] ^ D[7] ^ D[6] ^ D[5] ^ C[3] ^ C[5] ^
- C[6];
-
- crc_res = 0;
- for (i = 0; i < 8; i++)
- crc_res |= (NewCRC[i] << i);
-
- return crc_res;
-}
/* registers addresses are not in order
so these arrays help simplify the code */
-static const int cm_start[E1H_FUNC_MAX][9] = {
- {MISC_FUNC0_START, TCM_FUNC0_START, UCM_FUNC0_START, CCM_FUNC0_START,
- XCM_FUNC0_START, TSEM_FUNC0_START, USEM_FUNC0_START, CSEM_FUNC0_START,
- XSEM_FUNC0_START},
- {MISC_FUNC1_START, TCM_FUNC1_START, UCM_FUNC1_START, CCM_FUNC1_START,
- XCM_FUNC1_START, TSEM_FUNC1_START, USEM_FUNC1_START, CSEM_FUNC1_START,
- XSEM_FUNC1_START},
- {MISC_FUNC2_START, TCM_FUNC2_START, UCM_FUNC2_START, CCM_FUNC2_START,
- XCM_FUNC2_START, TSEM_FUNC2_START, USEM_FUNC2_START, CSEM_FUNC2_START,
- XSEM_FUNC2_START},
- {MISC_FUNC3_START, TCM_FUNC3_START, UCM_FUNC3_START, CCM_FUNC3_START,
- XCM_FUNC3_START, TSEM_FUNC3_START, USEM_FUNC3_START, CSEM_FUNC3_START,
- XSEM_FUNC3_START},
- {MISC_FUNC4_START, TCM_FUNC4_START, UCM_FUNC4_START, CCM_FUNC4_START,
- XCM_FUNC4_START, TSEM_FUNC4_START, USEM_FUNC4_START, CSEM_FUNC4_START,
- XSEM_FUNC4_START},
- {MISC_FUNC5_START, TCM_FUNC5_START, UCM_FUNC5_START, CCM_FUNC5_START,
- XCM_FUNC5_START, TSEM_FUNC5_START, USEM_FUNC5_START, CSEM_FUNC5_START,
- XSEM_FUNC5_START},
- {MISC_FUNC6_START, TCM_FUNC6_START, UCM_FUNC6_START, CCM_FUNC6_START,
- XCM_FUNC6_START, TSEM_FUNC6_START, USEM_FUNC6_START, CSEM_FUNC6_START,
- XSEM_FUNC6_START},
- {MISC_FUNC7_START, TCM_FUNC7_START, UCM_FUNC7_START, CCM_FUNC7_START,
- XCM_FUNC7_START, TSEM_FUNC7_START, USEM_FUNC7_START, CSEM_FUNC7_START,
- XSEM_FUNC7_START}
-};
-
-static const int cm_end[E1H_FUNC_MAX][9] = {
- {MISC_FUNC0_END, TCM_FUNC0_END, UCM_FUNC0_END, CCM_FUNC0_END,
- XCM_FUNC0_END, TSEM_FUNC0_END, USEM_FUNC0_END, CSEM_FUNC0_END,
- XSEM_FUNC0_END},
- {MISC_FUNC1_END, TCM_FUNC1_END, UCM_FUNC1_END, CCM_FUNC1_END,
- XCM_FUNC1_END, TSEM_FUNC1_END, USEM_FUNC1_END, CSEM_FUNC1_END,
- XSEM_FUNC1_END},
- {MISC_FUNC2_END, TCM_FUNC2_END, UCM_FUNC2_END, CCM_FUNC2_END,
- XCM_FUNC2_END, TSEM_FUNC2_END, USEM_FUNC2_END, CSEM_FUNC2_END,
- XSEM_FUNC2_END},
- {MISC_FUNC3_END, TCM_FUNC3_END, UCM_FUNC3_END, CCM_FUNC3_END,
- XCM_FUNC3_END, TSEM_FUNC3_END, USEM_FUNC3_END, CSEM_FUNC3_END,
- XSEM_FUNC3_END},
- {MISC_FUNC4_END, TCM_FUNC4_END, UCM_FUNC4_END, CCM_FUNC4_END,
- XCM_FUNC4_END, TSEM_FUNC4_END, USEM_FUNC4_END, CSEM_FUNC4_END,
- XSEM_FUNC4_END},
- {MISC_FUNC5_END, TCM_FUNC5_END, UCM_FUNC5_END, CCM_FUNC5_END,
- XCM_FUNC5_END, TSEM_FUNC5_END, USEM_FUNC5_END, CSEM_FUNC5_END,
- XSEM_FUNC5_END},
- {MISC_FUNC6_END, TCM_FUNC6_END, UCM_FUNC6_END, CCM_FUNC6_END,
- XCM_FUNC6_END, TSEM_FUNC6_END, USEM_FUNC6_END, CSEM_FUNC6_END,
- XSEM_FUNC6_END},
- {MISC_FUNC7_END, TCM_FUNC7_END, UCM_FUNC7_END, CCM_FUNC7_END,
- XCM_FUNC7_END, TSEM_FUNC7_END, USEM_FUNC7_END, CSEM_FUNC7_END,
- XSEM_FUNC7_END},
-};
-
-static const int hc_limits[E1H_FUNC_MAX][2] = {
- {HC_FUNC0_START, HC_FUNC0_END},
- {HC_FUNC1_START, HC_FUNC1_END},
- {HC_FUNC2_START, HC_FUNC2_END},
- {HC_FUNC3_START, HC_FUNC3_END},
- {HC_FUNC4_START, HC_FUNC4_END},
- {HC_FUNC5_START, HC_FUNC5_END},
- {HC_FUNC6_START, HC_FUNC6_END},
- {HC_FUNC7_START, HC_FUNC7_END}
+static const int cm_blocks[9] = {
+ MISC_BLOCK, TCM_BLOCK, UCM_BLOCK, CCM_BLOCK, XCM_BLOCK,
+ TSEM_BLOCK, USEM_BLOCK, CSEM_BLOCK, XSEM_BLOCK
};
#endif /* BNX2X_INIT_H */
diff --git a/drivers/net/bnx2x_init_ops.h b/drivers/net/bnx2x_init_ops.h
new file mode 100644
index 000000000000..32552b9366cb
--- /dev/null
+++ b/drivers/net/bnx2x_init_ops.h
@@ -0,0 +1,442 @@
+/* bnx2x_init_ops.h: Broadcom Everest network driver.
+ * Static functions needed during the initialization.
+ * This file is "included" in bnx2x_main.c.
+ *
+ * Copyright (c) 2007-2009 Broadcom Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ * Maintained by: Eilon Greenstein <eilong@broadcom.com>
+ * Written by: Vladislav Zolotarov <vladz@broadcom.com>
+ */
+#ifndef BNX2X_INIT_OPS_H
+#define BNX2X_INIT_OPS_H
+
+static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
+static int bnx2x_gunzip(struct bnx2x *bp, const u8 *zbuf, int len);
+
+static void bnx2x_init_str_wr(struct bnx2x *bp, u32 addr, const u32 *data,
+ u32 len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ REG_WR(bp, addr + i*4, data[i]);
+ if (!(i % 10000)) {
+ touch_softlockup_watchdog();
+ cpu_relax();
+ }
+ }
+}
+
+static void bnx2x_init_ind_wr(struct bnx2x *bp, u32 addr, const u32 *data,
+ u16 len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ REG_WR_IND(bp, addr + i*4, data[i]);
+ if (!(i % 10000)) {
+ touch_softlockup_watchdog();
+ cpu_relax();
+ }
+ }
+}
+
+static void bnx2x_write_big_buf(struct bnx2x *bp, u32 addr, u32 len)
+{
+ int offset = 0;
+
+ if (bp->dmae_ready) {
+ while (len > DMAE_LEN32_WR_MAX) {
+ bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
+ addr + offset, DMAE_LEN32_WR_MAX);
+ offset += DMAE_LEN32_WR_MAX * 4;
+ len -= DMAE_LEN32_WR_MAX;
+ }
+ bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
+ addr + offset, len);
+ } else
+ bnx2x_init_str_wr(bp, addr, bp->gunzip_buf, len);
+}
+
+static void bnx2x_init_fill(struct bnx2x *bp, u32 addr, int fill, u32 len)
+{
+ u32 buf_len = (((len * 4) > FW_BUF_SIZE) ? FW_BUF_SIZE : (len * 4));
+ u32 buf_len32 = buf_len / 4;
+ int i;
+
+ memset(bp->gunzip_buf, fill, buf_len);
+
+ for (i = 0; i < len; i += buf_len32) {
+ u32 cur_len = min(buf_len32, len - i);
+
+ bnx2x_write_big_buf(bp, addr + i * 4, cur_len);
+ }
+}
+
+static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr, const u32 *data,
+ u32 len64)
+{
+ u32 buf_len32 = FW_BUF_SIZE / 4;
+ u32 len = len64 * 2;
+ u64 data64 = 0;
+ int i;
+
+ /* 64 bit value is in a blob: first low DWORD, then high DWORD */
+ data64 = HILO_U64((*(data + 1)), (*data));
+ len64 = min((u32)(FW_BUF_SIZE/8), len64);
+ for (i = 0; i < len64; i++) {
+ u64 *pdata = ((u64 *)(bp->gunzip_buf)) + i;
+
+ *pdata = data64;
+ }
+
+ for (i = 0; i < len; i += buf_len32) {
+ u32 cur_len = min(buf_len32, len - i);
+
+ bnx2x_write_big_buf(bp, addr + i * 4, cur_len);
+ }
+}
+
+/*********************************************************
+ There are different blobs for each PRAM section.
+ In addition, each blob write operation is divided into a few operations
+ in order to decrease the amount of phys. contiguous buffer needed.
+ Thus, when we select a blob the address may be with some offset
+ from the beginning of PRAM section.
+ The same holds for the INT_TABLE sections.
+**********************************************************/
+#define IF_IS_INT_TABLE_ADDR(base, addr) \
+ if (((base) <= (addr)) && ((base) + 0x400 >= (addr)))
+
+#define IF_IS_PRAM_ADDR(base, addr) \
+ if (((base) <= (addr)) && ((base) + 0x40000 >= (addr)))
+
+static const u8 *bnx2x_sel_blob(struct bnx2x *bp, u32 addr, const u8 *data)
+{
+ IF_IS_INT_TABLE_ADDR(TSEM_REG_INT_TABLE, addr)
+ data = bp->tsem_int_table_data;
+ else IF_IS_INT_TABLE_ADDR(CSEM_REG_INT_TABLE, addr)
+ data = bp->csem_int_table_data;
+ else IF_IS_INT_TABLE_ADDR(USEM_REG_INT_TABLE, addr)
+ data = bp->usem_int_table_data;
+ else IF_IS_INT_TABLE_ADDR(XSEM_REG_INT_TABLE, addr)
+ data = bp->xsem_int_table_data;
+ else IF_IS_PRAM_ADDR(TSEM_REG_PRAM, addr)
+ data = bp->tsem_pram_data;
+ else IF_IS_PRAM_ADDR(CSEM_REG_PRAM, addr)
+ data = bp->csem_pram_data;
+ else IF_IS_PRAM_ADDR(USEM_REG_PRAM, addr)
+ data = bp->usem_pram_data;
+ else IF_IS_PRAM_ADDR(XSEM_REG_PRAM, addr)
+ data = bp->xsem_pram_data;
+
+ return data;
+}
+
+static void bnx2x_write_big_buf_wb(struct bnx2x *bp, u32 addr, u32 len)
+{
+ int offset = 0;
+
+ if (bp->dmae_ready) {
+ while (len > DMAE_LEN32_WR_MAX) {
+ bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
+ addr + offset, DMAE_LEN32_WR_MAX);
+ offset += DMAE_LEN32_WR_MAX * 4;
+ len -= DMAE_LEN32_WR_MAX;
+ }
+ bnx2x_write_dmae(bp, bp->gunzip_mapping + offset,
+ addr + offset, len);
+ } else
+ bnx2x_init_ind_wr(bp, addr, bp->gunzip_buf, len);
+}
+
+static void bnx2x_init_wr_wb(struct bnx2x *bp, u32 addr, const u32 *data,
+ u32 len)
+{
+ /* This is needed for NO_ZIP mode, currently supported
+ in little endian mode only */
+ data = (const u32*)bnx2x_sel_blob(bp, addr, (const u8*)data);
+
+ if ((len * 4) > FW_BUF_SIZE) {
+ BNX2X_ERR("LARGE DMAE OPERATION ! "
+ "addr 0x%x len 0x%x\n", addr, len*4);
+ return;
+ }
+ memcpy(bp->gunzip_buf, data, len * 4);
+
+ bnx2x_write_big_buf_wb(bp, addr, len);
+}
+
+static void bnx2x_init_wr_zp(struct bnx2x *bp, u32 addr,
+ u32 len, u32 blob_off)
+{
+ int rc, i;
+ const u8 *data = NULL;
+
+ data = bnx2x_sel_blob(bp, addr, data) + 4*blob_off;
+
+ if (data == NULL) {
+ panic("Blob not found for addr 0x%x\n", addr);
+ return;
+ }
+
+ rc = bnx2x_gunzip(bp, data, len);
+ if (rc) {
+ BNX2X_ERR("gunzip failed ! addr 0x%x rc %d\n", addr, rc);
+ BNX2X_ERR("blob_offset=0x%x\n", blob_off);
+ return;
+ }
+
+ /* gunzip_outlen is in dwords */
+ len = bp->gunzip_outlen;
+ for (i = 0; i < len; i++)
+ ((u32 *)bp->gunzip_buf)[i] =
+ cpu_to_le32(((u32 *)bp->gunzip_buf)[i]);
+
+ bnx2x_write_big_buf_wb(bp, addr, len);
+}
+
+static void bnx2x_init_block(struct bnx2x *bp, u32 block, u32 stage)
+{
+ int hw_wr, i;
+ u16 op_start =
+ bp->init_ops_offsets[BLOCK_OPS_IDX(block,stage,STAGE_START)];
+ u16 op_end =
+ bp->init_ops_offsets[BLOCK_OPS_IDX(block,stage,STAGE_END)];
+ union init_op *op;
+ u32 op_type, addr, len;
+ const u32 *data, *data_base;
+
+ /* If empty block */
+ if (op_start == op_end)
+ return;
+
+ if (CHIP_REV_IS_FPGA(bp))
+ hw_wr = OP_WR_FPGA;
+ else if (CHIP_REV_IS_EMUL(bp))
+ hw_wr = OP_WR_EMUL;
+ else
+ hw_wr = OP_WR_ASIC;
+
+ data_base = bp->init_data;
+
+ for (i = op_start; i < op_end; i++) {
+
+ op = (union init_op *)&(bp->init_ops[i]);
+
+ op_type = op->str_wr.op;
+ addr = op->str_wr.offset;
+ len = op->str_wr.data_len;
+ data = data_base + op->str_wr.data_off;
+
+ /* HW/EMUL specific */
+ if (unlikely((op_type > OP_WB) && (op_type == hw_wr)))
+ op_type = OP_WR;
+
+ switch (op_type) {
+ case OP_RD:
+ REG_RD(bp, addr);
+ break;
+ case OP_WR:
+ REG_WR(bp, addr, op->write.val);
+ break;
+ case OP_SW:
+ bnx2x_init_str_wr(bp, addr, data, len);
+ break;
+ case OP_WB:
+ bnx2x_init_wr_wb(bp, addr, data, len);
+ break;
+ case OP_SI:
+ bnx2x_init_ind_wr(bp, addr, data, len);
+ break;
+ case OP_ZR:
+ bnx2x_init_fill(bp, addr, 0, op->zero.len);
+ break;
+ case OP_ZP:
+ bnx2x_init_wr_zp(bp, addr, len,
+ op->str_wr.data_off);
+ break;
+ case OP_WR_64:
+ bnx2x_init_wr_64(bp, addr, data, len);
+ break;
+ default:
+ /* happens whenever an op is of a diff HW */
+#if 0
+ DP(NETIF_MSG_HW, "skipping init operation "
+ "index %d[%d:%d]: type %d addr 0x%x "
+ "len %d(0x%x)\n",
+ i, op_start, op_end, op_type, addr, len, len);
+#endif
+ break;
+ }
+ }
+}
+
+/* PXP */
+static void bnx2x_init_pxp(struct bnx2x *bp)
+{
+ u16 devctl;
+ int r_order, w_order;
+ u32 val, i;
+
+ pci_read_config_word(bp->pdev,
+ bp->pcie_cap + PCI_EXP_DEVCTL, &devctl);
+ DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
+ w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
+ if (bp->mrrs == -1)
+ r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12);
+ else {
+ DP(NETIF_MSG_HW, "force read order to %d\n", bp->mrrs);
+ r_order = bp->mrrs;
+ }
+
+ if (r_order > MAX_RD_ORD) {
+ DP(NETIF_MSG_HW, "read order of %d order adjusted to %d\n",
+ r_order, MAX_RD_ORD);
+ r_order = MAX_RD_ORD;
+ }
+ if (w_order > MAX_WR_ORD) {
+ DP(NETIF_MSG_HW, "write order of %d order adjusted to %d\n",
+ w_order, MAX_WR_ORD);
+ w_order = MAX_WR_ORD;
+ }
+ if (CHIP_REV_IS_FPGA(bp)) {
+ DP(NETIF_MSG_HW, "write order adjusted to 1 for FPGA\n");
+ w_order = 0;
+ }
+ DP(NETIF_MSG_HW, "read order %d write order %d\n", r_order, w_order);
+
+ for (i = 0; i < NUM_RD_Q-1; i++) {
+ REG_WR(bp, read_arb_addr[i].l, read_arb_data[i][r_order].l);
+ REG_WR(bp, read_arb_addr[i].add,
+ read_arb_data[i][r_order].add);
+ REG_WR(bp, read_arb_addr[i].ubound,
+ read_arb_data[i][r_order].ubound);
+ }
+
+ for (i = 0; i < NUM_WR_Q-1; i++) {
+ if ((write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L29) ||
+ (write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L30)) {
+
+ REG_WR(bp, write_arb_addr[i].l,
+ write_arb_data[i][w_order].l);
+
+ REG_WR(bp, write_arb_addr[i].add,
+ write_arb_data[i][w_order].add);
+
+ REG_WR(bp, write_arb_addr[i].ubound,
+ write_arb_data[i][w_order].ubound);
+ } else {
+
+ val = REG_RD(bp, write_arb_addr[i].l);
+ REG_WR(bp, write_arb_addr[i].l,
+ val | (write_arb_data[i][w_order].l << 10));
+
+ val = REG_RD(bp, write_arb_addr[i].add);
+ REG_WR(bp, write_arb_addr[i].add,
+ val | (write_arb_data[i][w_order].add << 10));
+
+ val = REG_RD(bp, write_arb_addr[i].ubound);
+ REG_WR(bp, write_arb_addr[i].ubound,
+ val | (write_arb_data[i][w_order].ubound << 7));
+ }
+ }
+
+ val = write_arb_data[NUM_WR_Q-1][w_order].add;
+ val += write_arb_data[NUM_WR_Q-1][w_order].ubound << 10;
+ val += write_arb_data[NUM_WR_Q-1][w_order].l << 17;
+ REG_WR(bp, PXP2_REG_PSWRQ_BW_RD, val);
+
+ val = read_arb_data[NUM_RD_Q-1][r_order].add;
+ val += read_arb_data[NUM_RD_Q-1][r_order].ubound << 10;
+ val += read_arb_data[NUM_RD_Q-1][r_order].l << 17;
+ REG_WR(bp, PXP2_REG_PSWRQ_BW_WR, val);
+
+ REG_WR(bp, PXP2_REG_RQ_WR_MBS0, w_order);
+ REG_WR(bp, PXP2_REG_RQ_WR_MBS1, w_order);
+ REG_WR(bp, PXP2_REG_RQ_RD_MBS0, r_order);
+ REG_WR(bp, PXP2_REG_RQ_RD_MBS1, r_order);
+
+ if (r_order == MAX_RD_ORD)
+ REG_WR(bp, PXP2_REG_RQ_PDR_LIMIT, 0xe00);
+
+ REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x18 << w_order));
+
+ if (CHIP_IS_E1H(bp)) {
+ val = ((w_order == 0) ? 2 : 3);
+ REG_WR(bp, PXP2_REG_WR_HC_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_USDM_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_CSDM_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_TSDM_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_XSDM_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_QM_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_TM_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_SRC_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_DBG_MPS, val);
+ REG_WR(bp, PXP2_REG_WR_DMAE_MPS, 2); /* DMAE is special */
+ REG_WR(bp, PXP2_REG_WR_CDU_MPS, val);
+ }
+}
+
+/*****************************************************************************
+ * Description:
+ * Calculates crc 8 on a word value: polynomial 0-1-2-8
+ * Code was translated from Verilog.
+ ****************************************************************************/
+static u8 calc_crc8(u32 data, u8 crc)
+{
+ u8 D[32];
+ u8 NewCRC[8];
+ u8 C[8];
+ u8 crc_res;
+ u8 i;
+
+ /* split the data into 31 bits */
+ for (i = 0; i < 32; i++) {
+ D[i] = data & 1;
+ data = data >> 1;
+ }
+
+ /* split the crc into 8 bits */
+ for (i = 0; i < 8; i++) {
+ C[i] = crc & 1;
+ crc = crc >> 1;
+ }
+
+ NewCRC[0] = D[31] ^ D[30] ^ D[28] ^ D[23] ^ D[21] ^ D[19] ^ D[18] ^
+ D[16] ^ D[14] ^ D[12] ^ D[8] ^ D[7] ^ D[6] ^ D[0] ^ C[4] ^
+ C[6] ^ C[7];
+ NewCRC[1] = D[30] ^ D[29] ^ D[28] ^ D[24] ^ D[23] ^ D[22] ^ D[21] ^
+ D[20] ^ D[18] ^ D[17] ^ D[16] ^ D[15] ^ D[14] ^ D[13] ^
+ D[12] ^ D[9] ^ D[6] ^ D[1] ^ D[0] ^ C[0] ^ C[4] ^ C[5] ^ C[6];
+ NewCRC[2] = D[29] ^ D[28] ^ D[25] ^ D[24] ^ D[22] ^ D[17] ^ D[15] ^
+ D[13] ^ D[12] ^ D[10] ^ D[8] ^ D[6] ^ D[2] ^ D[1] ^ D[0] ^
+ C[0] ^ C[1] ^ C[4] ^ C[5];
+ NewCRC[3] = D[30] ^ D[29] ^ D[26] ^ D[25] ^ D[23] ^ D[18] ^ D[16] ^
+ D[14] ^ D[13] ^ D[11] ^ D[9] ^ D[7] ^ D[3] ^ D[2] ^ D[1] ^
+ C[1] ^ C[2] ^ C[5] ^ C[6];
+ NewCRC[4] = D[31] ^ D[30] ^ D[27] ^ D[26] ^ D[24] ^ D[19] ^ D[17] ^
+ D[15] ^ D[14] ^ D[12] ^ D[10] ^ D[8] ^ D[4] ^ D[3] ^ D[2] ^
+ C[0] ^ C[2] ^ C[3] ^ C[6] ^ C[7];
+ NewCRC[5] = D[31] ^ D[28] ^ D[27] ^ D[25] ^ D[20] ^ D[18] ^ D[16] ^
+ D[15] ^ D[13] ^ D[11] ^ D[9] ^ D[5] ^ D[4] ^ D[3] ^ C[1] ^
+ C[3] ^ C[4] ^ C[7];
+ NewCRC[6] = D[29] ^ D[28] ^ D[26] ^ D[21] ^ D[19] ^ D[17] ^ D[16] ^
+ D[14] ^ D[12] ^ D[10] ^ D[6] ^ D[5] ^ D[4] ^ C[2] ^ C[4] ^
+ C[5];
+ NewCRC[7] = D[30] ^ D[29] ^ D[27] ^ D[22] ^ D[20] ^ D[18] ^ D[17] ^
+ D[15] ^ D[13] ^ D[11] ^ D[7] ^ D[6] ^ D[5] ^ C[3] ^ C[5] ^
+ C[6];
+
+ crc_res = 0;
+ for (i = 0; i < 8; i++)
+ crc_res |= (NewCRC[i] << i);
+
+ return crc_res;
+}
+
+#endif /* BNX2X_INIT_OPS_H */
diff --git a/drivers/net/bnx2x_init_values.h b/drivers/net/bnx2x_init_values.h
deleted file mode 100644
index 1f22c9ab66d4..000000000000
--- a/drivers/net/bnx2x_init_values.h
+++ /dev/null
@@ -1,16322 +0,0 @@
-#ifndef __BNX2X_INIT_VALUES_H__
-#define __BNX2X_INIT_VALUES_H__
-
-/* bnx2x_init_values.h: Broadcom NX2 10G network driver.
- *
- * Copyright (c) 2007-2009 Broadcom Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, except as noted below.
- *
- * This file contains firmware data derived from proprietary unpublished
- * source code, Copyright (c) 2007-2009 Broadcom Corporation.
- *
- * Permission is hereby granted for the distribution of this firmware data
- * in hexadecimal or equivalent format, provided this copyright notice is
- * accompanying it.
- *
- *
- * This array contains the list of operations needed to initialize the chip.
- *
- * For each block in the chip there are three init stages:
- * common - HW used by both ports,
- * port1 and port2 - initialization for a specific Ethernet port.
- * When a port is opened or closed, the management CPU tells the driver
- * whether to init/disable common HW in addition to the port HW.
- * This way the first port going up will first initializes the common HW,
- * and the last port going down also resets the common HW
- *
- * For each init stage/block there is a list of actions needed in a format:
- * {operation, register, data}
- * where:
- * OP_WR - write a value to the chip.
- * OP_RD - read a register (usually a clear on read register).
- * OP_SW - string write, write a section of consecutive addresses to the chip.
- * OP_SI - copy a string using indirect writes.
- * OP_ZR - clear a range of memory.
- * OP_ZP - unzip and copy using DMAE.
- * OP_WB - string copy using DMAE.
- *
- * The #defines mark the stages.
- *
- */
-
-static const struct raw_op init_ops[] = {
-#define PRS_COMMON_START 0
- {OP_WR, PRS_REG_INC_VALUE, 0xf},
- {OP_WR, PRS_REG_EVENT_ID_1, 0x45},
- {OP_WR, PRS_REG_EVENT_ID_2, 0x84},
- {OP_WR, PRS_REG_EVENT_ID_3, 0x6},
- {OP_WR, PRS_REG_NO_MATCH_EVENT_ID, 0x4},
- {OP_WR, PRS_REG_CM_HDR_TYPE_0, 0x0},
- {OP_WR, PRS_REG_CM_HDR_TYPE_1, 0x12170000},
- {OP_WR, PRS_REG_CM_HDR_TYPE_2, 0x22170000},
- {OP_WR, PRS_REG_CM_HDR_TYPE_3, 0x32170000},
- {OP_ZR, PRS_REG_CM_HDR_TYPE_4, 0x5},
- {OP_WR, PRS_REG_CM_HDR_LOOPBACK_TYPE_1, 0x12150000},
- {OP_WR, PRS_REG_CM_HDR_LOOPBACK_TYPE_2, 0x22150000},
- {OP_WR, PRS_REG_CM_HDR_LOOPBACK_TYPE_3, 0x32150000},
- {OP_ZR, PRS_REG_CM_HDR_LOOPBACK_TYPE_4, 0x4},
- {OP_WR, PRS_REG_CM_NO_MATCH_HDR, 0x2100000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_0, 0x100000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_1, 0x10100000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_2, 0x20100000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_3, 0x30100000},
- {OP_ZR_E1, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_4, 0x4},
- {OP_WR_E1H, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_4, 0x40100000},
- {OP_ZR_E1H, PRS_REG_CM_HDR_FLUSH_NO_LOAD_TYPE_5, 0x3},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_0, 0x100000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_1, 0x12140000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_2, 0x22140000},
- {OP_WR, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_3, 0x32140000},
- {OP_ZR_E1, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_4, 0x4},
- {OP_WR_E1H, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_4, 0x42140000},
- {OP_ZR_E1H, PRS_REG_CM_HDR_FLUSH_LOAD_TYPE_5, 0x3},
- {OP_RD, PRS_REG_NUM_OF_PACKETS, 0x0},
- {OP_RD, PRS_REG_NUM_OF_CFC_FLUSH_MESSAGES, 0x0},
- {OP_RD, PRS_REG_NUM_OF_TRANSPARENT_FLUSH_MESSAGES, 0x0},
- {OP_RD, PRS_REG_NUM_OF_DEAD_CYCLES, 0x0},
- {OP_WR_E1H, PRS_REG_FCOE_TYPE, 0x8906},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_0, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_1, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_2, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_3, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_4, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_5, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_6, 0xff},
- {OP_WR, PRS_REG_FLUSH_REGIONS_TYPE_7, 0xff},
- {OP_WR, PRS_REG_PURE_REGIONS, 0x3e},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_0, 0x0},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_1, 0x3f},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_2, 0x3f},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_3, 0x3f},
- {OP_WR_E1, PRS_REG_PACKET_REGIONS_TYPE_4, 0x0},
- {OP_WR_E1H, PRS_REG_PACKET_REGIONS_TYPE_4, 0x3f},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_5, 0x3f},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_6, 0x3f},
- {OP_WR, PRS_REG_PACKET_REGIONS_TYPE_7, 0x3f},
-#define PRS_COMMON_END 52
-#define SRCH_COMMON_START 52
- {OP_WR_E1H, SRC_REG_E1HMF_ENABLE, 0x1},
-#define SRCH_COMMON_END 53
-#define TSDM_COMMON_START 53
- {OP_WR_E1, TSDM_REG_CFC_RSP_START_ADDR, 0x411},
- {OP_WR_E1H, TSDM_REG_CFC_RSP_START_ADDR, 0x211},
- {OP_WR_E1, TSDM_REG_CMP_COUNTER_START_ADDR, 0x400},
- {OP_WR_E1H, TSDM_REG_CMP_COUNTER_START_ADDR, 0x200},
- {OP_WR_E1, TSDM_REG_Q_COUNTER_START_ADDR, 0x404},
- {OP_WR_E1H, TSDM_REG_Q_COUNTER_START_ADDR, 0x204},
- {OP_WR_E1, TSDM_REG_PCK_END_MSG_START_ADDR, 0x419},
- {OP_WR_E1H, TSDM_REG_PCK_END_MSG_START_ADDR, 0x219},
- {OP_WR, TSDM_REG_CMP_COUNTER_MAX0, 0xffff},
- {OP_WR, TSDM_REG_CMP_COUNTER_MAX1, 0xffff},
- {OP_WR, TSDM_REG_CMP_COUNTER_MAX2, 0xffff},
- {OP_WR, TSDM_REG_CMP_COUNTER_MAX3, 0xffff},
- {OP_ZR_E1, TSDM_REG_AGG_INT_EVENT_0, 0x2},
- {OP_WR_E1H, TSDM_REG_AGG_INT_EVENT_0, 0x20},
- {OP_WR_E1H, TSDM_REG_AGG_INT_EVENT_1, 0x0},
- {OP_WR, TSDM_REG_AGG_INT_EVENT_2, 0x34},
- {OP_WR, TSDM_REG_AGG_INT_EVENT_3, 0x35},
- {OP_ZR_E1, TSDM_REG_AGG_INT_EVENT_4, 0x7c},
- {OP_ZR_E1H, TSDM_REG_AGG_INT_EVENT_4, 0x1c},
- {OP_WR_E1H, TSDM_REG_AGG_INT_T_0, 0x1},
- {OP_ZR_E1H, TSDM_REG_AGG_INT_T_1, 0x5f},
- {OP_WR, TSDM_REG_ENABLE_IN1, 0x7ffffff},
- {OP_WR, TSDM_REG_ENABLE_IN2, 0x3f},
- {OP_WR, TSDM_REG_ENABLE_OUT1, 0x7ffffff},
- {OP_WR, TSDM_REG_ENABLE_OUT2, 0xf},
- {OP_RD, TSDM_REG_NUM_OF_Q0_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q1_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q3_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q4_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q5_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q6_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q7_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q8_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q9_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q10_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_Q11_CMD, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_PKT_END_MSG, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_PXP_ASYNC_REQ, 0x0},
- {OP_RD, TSDM_REG_NUM_OF_ACK_AFTER_PLACE, 0x0},
- {OP_WR_E1, TSDM_REG_INIT_CREDIT_PXP_CTRL, 0x1},
- {OP_WR_ASIC, TSDM_REG_TIMER_TICK, 0x3e8},
- {OP_WR_EMUL, TSDM_REG_TIMER_TICK, 0x1},
- {OP_WR_FPGA, TSDM_REG_TIMER_TICK, 0xa},
-#define TSDM_COMMON_END 96
-#define TCM_COMMON_START 96
- {OP_WR, TCM_REG_XX_MAX_LL_SZ, 0x20},
- {OP_WR, TCM_REG_XX_OVFL_EVNT_ID, 0x32},
- {OP_WR, TCM_REG_TQM_TCM_HDR_P, 0x2150020},
- {OP_WR, TCM_REG_TQM_TCM_HDR_S, 0x2150020},
- {OP_WR, TCM_REG_TM_TCM_HDR, 0x30},
- {OP_WR, TCM_REG_ERR_TCM_HDR, 0x8100000},
- {OP_WR, TCM_REG_ERR_EVNT_ID, 0x33},
- {OP_WR, TCM_REG_EXPR_EVNT_ID, 0x30},
- {OP_WR, TCM_REG_STOP_EVNT_ID, 0x31},
- {OP_WR, TCM_REG_STORM_WEIGHT, 0x2},
- {OP_WR, TCM_REG_PRS_WEIGHT, 0x5},
- {OP_WR, TCM_REG_PBF_WEIGHT, 0x6},
- {OP_WR, TCM_REG_USEM_WEIGHT, 0x2},
- {OP_WR, TCM_REG_CSEM_WEIGHT, 0x2},
- {OP_WR, TCM_REG_CP_WEIGHT, 0x0},
- {OP_WR, TCM_REG_TSDM_WEIGHT, 0x5},
- {OP_WR, TCM_REG_TQM_P_WEIGHT, 0x2},
- {OP_WR, TCM_REG_TQM_S_WEIGHT, 0x2},
- {OP_WR, TCM_REG_TM_WEIGHT, 0x2},
- {OP_WR, TCM_REG_TCM_TQM_USE_Q, 0x1},
- {OP_WR, TCM_REG_GR_ARB_TYPE, 0x1},
- {OP_WR, TCM_REG_GR_LD0_PR, 0x1},
- {OP_WR, TCM_REG_GR_LD1_PR, 0x2},
- {OP_WR, TCM_REG_CFC_INIT_CRD, 0x1},
- {OP_WR, TCM_REG_FIC0_INIT_CRD, 0x40},
- {OP_WR, TCM_REG_FIC1_INIT_CRD, 0x40},
- {OP_WR, TCM_REG_TQM_INIT_CRD, 0x20},
- {OP_WR, TCM_REG_XX_INIT_CRD, 0x13},
- {OP_WR, TCM_REG_XX_MSG_NUM, 0x20},
- {OP_ZR, TCM_REG_XX_TABLE, 0xa},
- {OP_SW, TCM_REG_XX_DESCR_TABLE, 0x200000},
- {OP_WR, TCM_REG_N_SM_CTX_LD_0, 0x7},
- {OP_WR, TCM_REG_N_SM_CTX_LD_1, 0x7},
- {OP_WR, TCM_REG_N_SM_CTX_LD_2, 0x8},
- {OP_WR, TCM_REG_N_SM_CTX_LD_3, 0x8},
- {OP_ZR_E1, TCM_REG_N_SM_CTX_LD_4, 0x4},
- {OP_WR_E1H, TCM_REG_N_SM_CTX_LD_4, 0x1},
- {OP_ZR_E1H, TCM_REG_N_SM_CTX_LD_5, 0x3},
- {OP_WR, TCM_REG_TCM_REG0_SZ, 0x6},
- {OP_WR_E1, TCM_REG_PHYS_QNUM0_0, 0xd},
- {OP_WR_E1, TCM_REG_PHYS_QNUM0_1, 0x2d},
- {OP_WR_E1, TCM_REG_PHYS_QNUM1_0, 0x7},
- {OP_WR_E1, TCM_REG_PHYS_QNUM1_1, 0x27},
- {OP_WR_E1, TCM_REG_PHYS_QNUM2_0, 0x7},
- {OP_WR_E1, TCM_REG_PHYS_QNUM2_1, 0x27},
- {OP_WR_E1, TCM_REG_PHYS_QNUM3_0, 0x7},
- {OP_WR_E1, TCM_REG_PHYS_QNUM3_1, 0x27},
- {OP_WR, TCM_REG_TCM_STORM0_IFEN, 0x1},
- {OP_WR, TCM_REG_TCM_STORM1_IFEN, 0x1},
- {OP_WR, TCM_REG_TCM_TQM_IFEN, 0x1},
- {OP_WR, TCM_REG_STORM_TCM_IFEN, 0x1},
- {OP_WR, TCM_REG_TQM_TCM_IFEN, 0x1},
- {OP_WR, TCM_REG_TSDM_IFEN, 0x1},
- {OP_WR, TCM_REG_TM_TCM_IFEN, 0x1},
- {OP_WR, TCM_REG_PRS_IFEN, 0x1},
- {OP_WR, TCM_REG_PBF_IFEN, 0x1},
- {OP_WR, TCM_REG_USEM_IFEN, 0x1},
- {OP_WR, TCM_REG_CSEM_IFEN, 0x1},
- {OP_WR, TCM_REG_CDU_AG_WR_IFEN, 0x1},
- {OP_WR, TCM_REG_CDU_AG_RD_IFEN, 0x1},
- {OP_WR, TCM_REG_CDU_SM_WR_IFEN, 0x1},
- {OP_WR, TCM_REG_CDU_SM_RD_IFEN, 0x1},
- {OP_WR, TCM_REG_TCM_CFC_IFEN, 0x1},
-#define TCM_COMMON_END 159
-#define TCM_FUNC0_START 159
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_0, 0xd},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_0, 0x7},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_0, 0x7},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_0, 0x7},
-#define TCM_FUNC0_END 163
-#define TCM_FUNC1_START 163
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_1, 0x2d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_1, 0x27},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_1, 0x27},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_1, 0x27},
-#define TCM_FUNC1_END 167
-#define TCM_FUNC2_START 167
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_0, 0x1d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_0, 0x17},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_0, 0x17},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_0, 0x17},
-#define TCM_FUNC2_END 171
-#define TCM_FUNC3_START 171
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_1, 0x3d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_1, 0x37},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_1, 0x37},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_1, 0x37},
-#define TCM_FUNC3_END 175
-#define TCM_FUNC4_START 175
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_0, 0x4d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_0, 0x47},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_0, 0x47},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_0, 0x47},
-#define TCM_FUNC4_END 179
-#define TCM_FUNC5_START 179
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_1, 0x6d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_1, 0x67},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_1, 0x67},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_1, 0x67},
-#define TCM_FUNC5_END 183
-#define TCM_FUNC6_START 183
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_0, 0x5d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_0, 0x57},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_0, 0x57},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_0, 0x57},
-#define TCM_FUNC6_END 187
-#define TCM_FUNC7_START 187
- {OP_WR_E1H, TCM_REG_PHYS_QNUM0_1, 0x7d},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM1_1, 0x77},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM2_1, 0x77},
- {OP_WR_E1H, TCM_REG_PHYS_QNUM3_1, 0x77},
-#define TCM_FUNC7_END 191
-#define BRB1_COMMON_START 191
- {OP_SW, BRB1_REG_LL_RAM, 0x2000020},
- {OP_WR, BRB1_REG_SOFT_RESET, 0x1},
- {OP_RD, BRB1_REG_NUM_OF_FULL_CYCLES_4, 0x0},
- {OP_SW, BRB1_REG_FREE_LIST_PRS_CRDT, 0x30220},
- {OP_WR, BRB1_REG_SOFT_RESET, 0x0},
-#define BRB1_COMMON_END 196
-#define BRB1_PORT0_START 196
- {OP_WR_E1, BRB1_REG_PAUSE_LOW_THRESHOLD_0, 0xb8},
- {OP_WR_E1, BRB1_REG_PAUSE_HIGH_THRESHOLD_0, 0x114},
- {OP_RD, BRB1_REG_NUM_OF_PAUSE_CYCLES_0, 0x0},
- {OP_RD, BRB1_REG_NUM_OF_FULL_CYCLES_0, 0x0},
-#define BRB1_PORT0_END 200
-#define BRB1_PORT1_START 200
- {OP_WR_E1, BRB1_REG_PAUSE_LOW_THRESHOLD_1, 0xb8},
- {OP_WR_E1, BRB1_REG_PAUSE_HIGH_THRESHOLD_1, 0x114},
- {OP_RD, BRB1_REG_NUM_OF_PAUSE_CYCLES_1, 0x0},
- {OP_RD, BRB1_REG_NUM_OF_FULL_CYCLES_1, 0x0},
-#define BRB1_PORT1_END 204
-#define TSEM_COMMON_START 204
- {OP_RD, TSEM_REG_MSG_NUM_FIC0, 0x0},
- {OP_RD, TSEM_REG_MSG_NUM_FIC1, 0x0},
- {OP_RD, TSEM_REG_MSG_NUM_FOC0, 0x0},
- {OP_RD, TSEM_REG_MSG_NUM_FOC1, 0x0},
- {OP_RD, TSEM_REG_MSG_NUM_FOC2, 0x0},
- {OP_RD, TSEM_REG_MSG_NUM_FOC3, 0x0},
- {OP_WR, TSEM_REG_ARB_ELEMENT0, 0x1},
- {OP_WR, TSEM_REG_ARB_ELEMENT1, 0x2},
- {OP_WR, TSEM_REG_ARB_ELEMENT2, 0x3},
- {OP_WR, TSEM_REG_ARB_ELEMENT3, 0x0},
- {OP_WR, TSEM_REG_ARB_ELEMENT4, 0x4},
- {OP_WR, TSEM_REG_ARB_CYCLE_SIZE, 0x1},
- {OP_WR, TSEM_REG_TS_0_AS, 0x0},
- {OP_WR, TSEM_REG_TS_1_AS, 0x1},
- {OP_WR, TSEM_REG_TS_2_AS, 0x4},
- {OP_WR, TSEM_REG_TS_3_AS, 0x0},
- {OP_WR, TSEM_REG_TS_4_AS, 0x1},
- {OP_WR, TSEM_REG_TS_5_AS, 0x3},
- {OP_WR, TSEM_REG_TS_6_AS, 0x0},
- {OP_WR, TSEM_REG_TS_7_AS, 0x1},
- {OP_WR, TSEM_REG_TS_8_AS, 0x4},
- {OP_WR, TSEM_REG_TS_9_AS, 0x0},
- {OP_WR, TSEM_REG_TS_10_AS, 0x1},
- {OP_WR, TSEM_REG_TS_11_AS, 0x3},
- {OP_WR, TSEM_REG_TS_12_AS, 0x0},
- {OP_WR, TSEM_REG_TS_13_AS, 0x1},
- {OP_WR, TSEM_REG_TS_14_AS, 0x4},
- {OP_WR, TSEM_REG_TS_15_AS, 0x0},
- {OP_WR, TSEM_REG_TS_16_AS, 0x4},
- {OP_WR, TSEM_REG_TS_17_AS, 0x3},
- {OP_ZR, TSEM_REG_TS_18_AS, 0x2},
- {OP_WR, TSEM_REG_ENABLE_IN, 0x3fff},
- {OP_WR, TSEM_REG_ENABLE_OUT, 0x3ff},
- {OP_WR, TSEM_REG_FIC0_DISABLE, 0x0},
- {OP_WR, TSEM_REG_FIC1_DISABLE, 0x0},
- {OP_WR, TSEM_REG_PAS_DISABLE, 0x0},
- {OP_WR, TSEM_REG_THREADS_LIST, 0xff},
- {OP_ZR, TSEM_REG_PASSIVE_BUFFER, 0x400},
- {OP_WR, TSEM_REG_FAST_MEMORY + 0x18bc0, 0x1},
- {OP_WR, TSEM_REG_FAST_MEMORY + 0x18000, 0x34},
- {OP_WR, TSEM_REG_FAST_MEMORY + 0x18040, 0x18},
- {OP_WR, TSEM_REG_FAST_MEMORY + 0x18080, 0xc},
- {OP_WR, TSEM_REG_FAST_MEMORY + 0x180c0, 0x20},
- {OP_WR_ASIC, TSEM_REG_FAST_MEMORY + 0x18300, 0x7a120},
- {OP_WR_EMUL, TSEM_REG_FAST_MEMORY + 0x18300, 0x138},
- {OP_WR_FPGA, TSEM_REG_FAST_MEMORY + 0x18300, 0x1388},
- {OP_WR, TSEM_REG_FAST_MEMORY + 0x183c0, 0x1f4},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x2000, 0xb2},
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x11480, 0x1},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x23c8, 0xc1},
- {OP_WR_EMUL_E1H, TSEM_REG_FAST_MEMORY + 0x11480, 0x0},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x23c8 + 0x304, 0x10223},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x1000, 0x2b3},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1020, 0xc8},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x1000 + 0xacc, 0x10223},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1000, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0xa020, 0xc8},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1c18, 0x4},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0xa000, 0x2},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1c10, 0x2},
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x1ad0, 0x0},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x800, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x1ad8, 0x4},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x808, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3678, 0x6},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x810, 0x4},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3670, 0x2},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x1fb0, 0x40224},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5000, 0x2},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x4cb0, 0x80228},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5008, 0x4},
- {OP_ZP_E1, TSEM_REG_INT_TABLE, 0x930000},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5018, 0x4},
- {OP_WR_64_E1, TSEM_REG_INT_TABLE + 0x360, 0x140230},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5028, 0x4},
- {OP_ZP_E1, TSEM_REG_PRAM, 0x324f0000},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5038, 0x4},
- {OP_ZP_E1, TSEM_REG_PRAM + 0x8000, 0x33250c94},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5048, 0x4},
- {OP_ZP_E1, TSEM_REG_PRAM + 0x10000, 0xe4d195e},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5058, 0x4},
- {OP_WR_64_E1, TSEM_REG_PRAM + 0x11e00, 0x5c400232},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5068, 0x4},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5078, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x4000, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x4008, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x62c0, 0x200224},
- {OP_ZP_E1H, TSEM_REG_INT_TABLE, 0x9b0000},
- {OP_WR_64_E1H, TSEM_REG_INT_TABLE + 0x398, 0xd0244},
- {OP_ZP_E1H, TSEM_REG_PRAM, 0x325e0000},
- {OP_ZP_E1H, TSEM_REG_PRAM + 0x8000, 0x35960c98},
- {OP_ZP_E1H, TSEM_REG_PRAM + 0x10000, 0x1aea19fe},
- {OP_WR_64_E1H, TSEM_REG_PRAM + 0x143d0, 0x57860246},
-#define TSEM_COMMON_END 297
-#define TSEM_PORT0_START 297
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x22c8, 0x20},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x2000, 0x16c},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x4000, 0x16c},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0xb000, 0x28},
- {OP_WR_E1, TSEM_REG_FAST_MEMORY + 0x4b60, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0xb140, 0xc},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1400, 0xa},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x32c0, 0x12},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1450, 0x6},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3350, 0x64},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1500, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x8108, 0x2},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x1500 + 0x8, 0x50234},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1500 + 0x1c, 0x7},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1570, 0x12},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x9c0, 0x4c},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x800, 0x2},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x820, 0xe},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x1fb0, 0x20239},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x2908, 0x2},
-#define TSEM_PORT0_END 317
-#define TSEM_PORT1_START 317
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x2348, 0x20},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x25b0, 0x16c},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x45b0, 0x16c},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0xb0a0, 0x28},
- {OP_WR_E1, TSEM_REG_FAST_MEMORY + 0x4b64, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0xb170, 0xc},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1428, 0xa},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3308, 0x12},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1468, 0x6},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x34e0, 0x64},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1538, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x8110, 0x2},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x1538 + 0x8, 0x5023b},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x1538 + 0x1c, 0x7},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x15b8, 0x12},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0xaf0, 0x4c},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x808, 0x2},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x858, 0xe},
- {OP_SW_E1, TSEM_REG_FAST_MEMORY + 0x1fb8, 0x20240},
- {OP_ZR_E1, TSEM_REG_FAST_MEMORY + 0x2910, 0x2},
-#define TSEM_PORT1_END 337
-#define TSEM_FUNC0_START 337
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b60, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3000, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x3000 + 0x8, 0x50248},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3000 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x31c0, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5000, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5080, 0x12},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x4000, 0x2},
-#define TSEM_FUNC0_END 345
-#define TSEM_FUNC1_START 345
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b64, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3038, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x3038 + 0x8, 0x5024d},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3038 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x31e0, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5010, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x50c8, 0x12},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x4008, 0x2},
-#define TSEM_FUNC1_END 353
-#define TSEM_FUNC2_START 353
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b68, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3070, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x3070 + 0x8, 0x50252},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3070 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3200, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5020, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5110, 0x12},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x4010, 0x20257},
-#define TSEM_FUNC2_END 361
-#define TSEM_FUNC3_START 361
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b6c, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x30a8, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x30a8 + 0x8, 0x50259},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x30a8 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3220, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5030, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5158, 0x12},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x4018, 0x2025e},
-#define TSEM_FUNC3_END 369
-#define TSEM_FUNC4_START 369
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b70, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x30e0, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x30e0 + 0x8, 0x50260},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x30e0 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3240, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5040, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x51a0, 0x12},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x4020, 0x20265},
-#define TSEM_FUNC4_END 377
-#define TSEM_FUNC5_START 377
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b74, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3118, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x3118 + 0x8, 0x50267},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3118 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3260, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5050, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x51e8, 0x12},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x4028, 0x2026c},
-#define TSEM_FUNC5_END 385
-#define TSEM_FUNC6_START 385
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b78, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3150, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x3150 + 0x8, 0x5026e},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3150 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3280, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5060, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5230, 0x12},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x4030, 0x20273},
-#define TSEM_FUNC6_END 393
-#define TSEM_FUNC7_START 393
- {OP_WR_E1H, TSEM_REG_FAST_MEMORY + 0x2b7c, 0x0},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3188, 0x2},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x3188 + 0x8, 0x50275},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x3188 + 0x1c, 0x7},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x32a0, 0x8},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5070, 0x2},
- {OP_ZR_E1H, TSEM_REG_FAST_MEMORY + 0x5278, 0x12},
- {OP_SW_E1H, TSEM_REG_FAST_MEMORY + 0x4038, 0x2027a},
-#define TSEM_FUNC7_END 401
-#define MISC_COMMON_START 401
- {OP_WR_E1, MISC_REG_GRC_TIMEOUT_EN, 0x1},
- {OP_WR, MISC_REG_PLL_STORM_CTRL_1, 0x71d2911},
- {OP_WR, MISC_REG_PLL_STORM_CTRL_2, 0x0},
- {OP_WR, MISC_REG_PLL_STORM_CTRL_3, 0x9c0424},
- {OP_WR, MISC_REG_PLL_STORM_CTRL_4, 0x0},
- {OP_WR, MISC_REG_LCPLL_CTRL_1, 0x209},
- {OP_WR_E1, MISC_REG_SPIO, 0xff000000},
-#define MISC_COMMON_END 408
-#define MISC_FUNC0_START 408
- {OP_WR_E1H, MISC_REG_NIG_WOL_P0, 0x0},
-#define MISC_FUNC0_END 409
-#define MISC_FUNC1_START 409
- {OP_WR_E1H, MISC_REG_NIG_WOL_P1, 0x0},
-#define MISC_FUNC1_END 410
-#define MISC_FUNC2_START 410
- {OP_WR_E1H, MISC_REG_NIG_WOL_P0, 0x0},
-#define MISC_FUNC2_END 411
-#define MISC_FUNC3_START 411
- {OP_WR_E1H, MISC_REG_NIG_WOL_P1, 0x0},
-#define MISC_FUNC3_END 412
-#define MISC_FUNC4_START 412
- {OP_WR_E1H, MISC_REG_NIG_WOL_P0, 0x0},
-#define MISC_FUNC4_END 413
-#define MISC_FUNC5_START 413
- {OP_WR_E1H, MISC_REG_NIG_WOL_P1, 0x0},
-#define MISC_FUNC5_END 414
-#define MISC_FUNC6_START 414
- {OP_WR_E1H, MISC_REG_NIG_WOL_P0, 0x0},
-#define MISC_FUNC6_END 415
-#define MISC_FUNC7_START 415
- {OP_WR_E1H, MISC_REG_NIG_WOL_P1, 0x0},
-#define MISC_FUNC7_END 416
-#define NIG_COMMON_START 416
- {OP_WR, NIG_REG_PBF_LB_IN_EN, 0x1},
- {OP_WR, NIG_REG_PRS_REQ_IN_EN, 0x1},
- {OP_WR, NIG_REG_EGRESS_DEBUG_IN_EN, 0x1},
- {OP_WR, NIG_REG_BRB_LB_OUT_EN, 0x1},
- {OP_WR, NIG_REG_PRS_EOP_OUT_EN, 0x1},
-#define NIG_COMMON_END 421
-#define NIG_PORT0_START 421
- {OP_WR, NIG_REG_LLH0_CM_HEADER, 0x300000},
- {OP_WR, NIG_REG_LLH0_EVENT_ID, 0x28},
- {OP_WR, NIG_REG_LLH0_ERROR_MASK, 0x0},
- {OP_WR, NIG_REG_LLH0_XCM_MASK, 0x4},
- {OP_WR, NIG_REG_LLH0_BRB1_NOT_MCP, 0x1},
- {OP_WR, NIG_REG_STATUS_INTERRUPT_PORT0, 0x0},
- {OP_WR_E1H, NIG_REG_LLH0_CLS_TYPE, 0x1},
- {OP_WR, NIG_REG_LLH0_XCM_INIT_CREDIT, 0x30},
- {OP_WR, NIG_REG_BRB0_PAUSE_IN_EN, 0x1},
- {OP_WR, NIG_REG_EGRESS_PBF0_IN_EN, 0x1},
- {OP_WR, NIG_REG_BRB0_OUT_EN, 0x1},
- {OP_WR, NIG_REG_XCM0_OUT_EN, 0x1},
-#define NIG_PORT0_END 433
-#define NIG_PORT1_START 433
- {OP_WR, NIG_REG_LLH1_CM_HEADER, 0x300000},
- {OP_WR, NIG_REG_LLH1_EVENT_ID, 0x28},
- {OP_WR, NIG_REG_LLH1_ERROR_MASK, 0x0},
- {OP_WR, NIG_REG_LLH1_XCM_MASK, 0x4},
- {OP_WR, NIG_REG_LLH1_BRB1_NOT_MCP, 0x1},
- {OP_WR, NIG_REG_STATUS_INTERRUPT_PORT1, 0x0},
- {OP_WR_E1H, NIG_REG_LLH1_CLS_TYPE, 0x1},
- {OP_WR, NIG_REG_LLH1_XCM_INIT_CREDIT, 0x30},
- {OP_WR, NIG_REG_BRB1_PAUSE_IN_EN, 0x1},
- {OP_WR, NIG_REG_EGRESS_PBF1_IN_EN, 0x1},
- {OP_WR, NIG_REG_BRB1_OUT_EN, 0x1},
- {OP_WR, NIG_REG_XCM1_OUT_EN, 0x1},
-#define NIG_PORT1_END 445
-#define UPB_COMMON_START 445
- {OP_WR, GRCBASE_UPB + PB_REG_CONTROL, 0x20},
-#define UPB_COMMON_END 446
-#define CSDM_COMMON_START 446
- {OP_WR_E1, CSDM_REG_CFC_RSP_START_ADDR, 0xa11},
- {OP_WR_E1H, CSDM_REG_CFC_RSP_START_ADDR, 0x211},
- {OP_WR_E1, CSDM_REG_CMP_COUNTER_START_ADDR, 0xa00},
- {OP_WR_E1H, CSDM_REG_CMP_COUNTER_START_ADDR, 0x200},
- {OP_WR_E1, CSDM_REG_Q_COUNTER_START_ADDR, 0xa04},
- {OP_WR_E1H, CSDM_REG_Q_COUNTER_START_ADDR, 0x204},
- {OP_WR, CSDM_REG_CMP_COUNTER_MAX0, 0xffff},
- {OP_WR, CSDM_REG_CMP_COUNTER_MAX1, 0xffff},
- {OP_WR, CSDM_REG_CMP_COUNTER_MAX2, 0xffff},
- {OP_WR, CSDM_REG_CMP_COUNTER_MAX3, 0xffff},
- {OP_WR, CSDM_REG_AGG_INT_EVENT_0, 0xc6},
- {OP_WR, CSDM_REG_AGG_INT_EVENT_1, 0x0},
- {OP_WR, CSDM_REG_AGG_INT_EVENT_2, 0x34},
- {OP_WR, CSDM_REG_AGG_INT_EVENT_3, 0x35},
- {OP_ZR, CSDM_REG_AGG_INT_EVENT_4, 0x1c},
- {OP_WR, CSDM_REG_AGG_INT_T_0, 0x1},
- {OP_ZR, CSDM_REG_AGG_INT_T_1, 0x5f},
- {OP_WR, CSDM_REG_ENABLE_IN1, 0x7ffffff},
- {OP_WR, CSDM_REG_ENABLE_IN2, 0x3f},
- {OP_WR, CSDM_REG_ENABLE_OUT1, 0x7ffffff},
- {OP_WR, CSDM_REG_ENABLE_OUT2, 0xf},
- {OP_RD, CSDM_REG_NUM_OF_Q0_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q1_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q3_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q4_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q5_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q6_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q7_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q8_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q9_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q10_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_Q11_CMD, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_PKT_END_MSG, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_PXP_ASYNC_REQ, 0x0},
- {OP_RD, CSDM_REG_NUM_OF_ACK_AFTER_PLACE, 0x0},
- {OP_WR_E1, CSDM_REG_INIT_CREDIT_PXP_CTRL, 0x1},
- {OP_WR_ASIC, CSDM_REG_TIMER_TICK, 0x3e8},
- {OP_WR_EMUL, CSDM_REG_TIMER_TICK, 0x1},
- {OP_WR_FPGA, CSDM_REG_TIMER_TICK, 0xa},
-#define CSDM_COMMON_END 485
-#define USDM_COMMON_START 485
- {OP_WR_E1, USDM_REG_CFC_RSP_START_ADDR, 0xa11},
- {OP_WR_E1H, USDM_REG_CFC_RSP_START_ADDR, 0x411},
- {OP_WR_E1, USDM_REG_CMP_COUNTER_START_ADDR, 0xa00},
- {OP_WR_E1H, USDM_REG_CMP_COUNTER_START_ADDR, 0x400},
- {OP_WR_E1, USDM_REG_Q_COUNTER_START_ADDR, 0xa04},
- {OP_WR_E1H, USDM_REG_Q_COUNTER_START_ADDR, 0x404},
- {OP_WR_E1, USDM_REG_PCK_END_MSG_START_ADDR, 0xa21},
- {OP_WR_E1H, USDM_REG_PCK_END_MSG_START_ADDR, 0x421},
- {OP_WR, USDM_REG_CMP_COUNTER_MAX0, 0xffff},
- {OP_WR, USDM_REG_CMP_COUNTER_MAX1, 0xffff},
- {OP_WR, USDM_REG_CMP_COUNTER_MAX2, 0xffff},
- {OP_WR, USDM_REG_CMP_COUNTER_MAX3, 0xffff},
- {OP_WR, USDM_REG_AGG_INT_EVENT_0, 0x46},
- {OP_WR, USDM_REG_AGG_INT_EVENT_1, 0x5},
- {OP_WR, USDM_REG_AGG_INT_EVENT_2, 0x34},
- {OP_WR, USDM_REG_AGG_INT_EVENT_3, 0x35},
- {OP_ZR_E1, USDM_REG_AGG_INT_EVENT_4, 0x5c},
- {OP_WR_E1H, USDM_REG_AGG_INT_EVENT_4, 0x7},
- {OP_ZR_E1H, USDM_REG_AGG_INT_EVENT_5, 0x5b},
- {OP_WR, USDM_REG_AGG_INT_MODE_0, 0x1},
- {OP_ZR_E1, USDM_REG_AGG_INT_MODE_1, 0x1f},
- {OP_ZR_E1H, USDM_REG_AGG_INT_MODE_1, 0x3},
- {OP_WR_E1H, USDM_REG_AGG_INT_MODE_4, 0x1},
- {OP_ZR_E1H, USDM_REG_AGG_INT_MODE_5, 0x1b},
- {OP_WR, USDM_REG_ENABLE_IN1, 0x7ffffff},
- {OP_WR, USDM_REG_ENABLE_IN2, 0x3f},
- {OP_WR, USDM_REG_ENABLE_OUT1, 0x7ffffff},
- {OP_WR, USDM_REG_ENABLE_OUT2, 0xf},
- {OP_RD, USDM_REG_NUM_OF_Q0_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q1_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q2_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q3_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q4_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q5_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q6_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q7_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q8_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q9_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q10_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_Q11_CMD, 0x0},
- {OP_RD, USDM_REG_NUM_OF_PKT_END_MSG, 0x0},
- {OP_RD, USDM_REG_NUM_OF_PXP_ASYNC_REQ, 0x0},
- {OP_RD, USDM_REG_NUM_OF_ACK_AFTER_PLACE, 0x0},
- {OP_WR_E1, USDM_REG_INIT_CREDIT_PXP_CTRL, 0x1},
- {OP_WR_ASIC, USDM_REG_TIMER_TICK, 0x3e8},
- {OP_WR_EMUL, USDM_REG_TIMER_TICK, 0x1},
- {OP_WR_FPGA, USDM_REG_TIMER_TICK, 0xa},
-#define USDM_COMMON_END 532
-#define CCM_COMMON_START 532
- {OP_WR, CCM_REG_XX_OVFL_EVNT_ID, 0x32},
- {OP_WR, CCM_REG_CQM_CCM_HDR_P, 0x2150020},
- {OP_WR, CCM_REG_CQM_CCM_HDR_S, 0x2150020},
- {OP_WR, CCM_REG_ERR_CCM_HDR, 0x8100000},
- {OP_WR, CCM_REG_ERR_EVNT_ID, 0x33},
- {OP_WR, CCM_REG_STORM_WEIGHT, 0x2},
- {OP_WR, CCM_REG_TSEM_WEIGHT, 0x0},
- {OP_WR, CCM_REG_XSEM_WEIGHT, 0x5},
- {OP_WR, CCM_REG_USEM_WEIGHT, 0x5},
- {OP_ZR, CCM_REG_PBF_WEIGHT, 0x2},
- {OP_WR, CCM_REG_CSDM_WEIGHT, 0x2},
- {OP_WR, CCM_REG_CQM_P_WEIGHT, 0x3},
- {OP_WR, CCM_REG_CQM_S_WEIGHT, 0x2},
- {OP_WR, CCM_REG_CCM_CQM_USE_Q, 0x1},
- {OP_WR, CCM_REG_CNT_AUX1_Q, 0x2},
- {OP_WR, CCM_REG_CNT_AUX2_Q, 0x2},
- {OP_WR, CCM_REG_INV_DONE_Q, 0x1},
- {OP_WR, CCM_REG_GR_ARB_TYPE, 0x1},
- {OP_WR, CCM_REG_GR_LD0_PR, 0x1},
- {OP_WR, CCM_REG_GR_LD1_PR, 0x2},
- {OP_WR, CCM_REG_CFC_INIT_CRD, 0x1},
- {OP_WR, CCM_REG_CQM_INIT_CRD, 0x20},
- {OP_WR, CCM_REG_FIC0_INIT_CRD, 0x40},
- {OP_WR, CCM_REG_FIC1_INIT_CRD, 0x40},
- {OP_WR, CCM_REG_XX_INIT_CRD, 0x3},
- {OP_WR, CCM_REG_XX_MSG_NUM, 0x18},
- {OP_ZR, CCM_REG_XX_TABLE, 0x12},
- {OP_SW_E1, CCM_REG_XX_DESCR_TABLE, 0x240242},
- {OP_SW_E1H, CCM_REG_XX_DESCR_TABLE, 0x24027c},
- {OP_WR, CCM_REG_N_SM_CTX_LD_0, 0x1},
- {OP_WR, CCM_REG_N_SM_CTX_LD_1, 0x2},
- {OP_WR, CCM_REG_N_SM_CTX_LD_2, 0x8},
- {OP_WR, CCM_REG_N_SM_CTX_LD_3, 0x8},
- {OP_ZR, CCM_REG_N_SM_CTX_LD_4, 0x4},
- {OP_WR, CCM_REG_CCM_REG0_SZ, 0x4},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM0_0, 0x9},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM0_1, 0x29},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM1_0, 0xa},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM1_1, 0x2a},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM2_0, 0x7},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM2_1, 0x27},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM3_0, 0x7},
- {OP_WR_E1, CCM_REG_QOS_PHYS_QNUM3_1, 0x27},
- {OP_WR_E1, CCM_REG_PHYS_QNUM1_0, 0xc},
- {OP_WR_E1, CCM_REG_PHYS_QNUM1_1, 0x2c},
- {OP_WR_E1, CCM_REG_PHYS_QNUM2_0, 0xc},
- {OP_WR_E1, CCM_REG_PHYS_QNUM2_1, 0x2c},
- {OP_WR_E1, CCM_REG_PHYS_QNUM3_0, 0xc},
- {OP_WR_E1, CCM_REG_PHYS_QNUM3_1, 0x2c},
- {OP_WR, CCM_REG_CCM_STORM0_IFEN, 0x1},
- {OP_WR, CCM_REG_CCM_STORM1_IFEN, 0x1},
- {OP_WR, CCM_REG_CCM_CQM_IFEN, 0x1},
- {OP_WR, CCM_REG_STORM_CCM_IFEN, 0x1},
- {OP_WR, CCM_REG_CQM_CCM_IFEN, 0x1},
- {OP_WR, CCM_REG_CSDM_IFEN, 0x1},
- {OP_WR, CCM_REG_TSEM_IFEN, 0x1},
- {OP_WR, CCM_REG_XSEM_IFEN, 0x1},
- {OP_WR, CCM_REG_USEM_IFEN, 0x1},
- {OP_WR, CCM_REG_PBF_IFEN, 0x1},
- {OP_WR, CCM_REG_CDU_AG_WR_IFEN, 0x1},
- {OP_WR, CCM_REG_CDU_AG_RD_IFEN, 0x1},
- {OP_WR, CCM_REG_CDU_SM_WR_IFEN, 0x1},
- {OP_WR, CCM_REG_CDU_SM_RD_IFEN, 0x1},
- {OP_WR, CCM_REG_CCM_CFC_IFEN, 0x1},
-#define CCM_COMMON_END 596
-#define CCM_FUNC0_START 596
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_0, 0x9},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_0, 0xa},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_0, 0x7},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_0, 0x7},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_0, 0xc},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_0, 0xb},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_0, 0x7},
-#define CCM_FUNC0_END 603
-#define CCM_FUNC1_START 603
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_1, 0x29},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_1, 0x2a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_1, 0x27},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_1, 0x27},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_1, 0x2c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_1, 0x2b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_1, 0x27},
-#define CCM_FUNC1_END 610
-#define CCM_FUNC2_START 610
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_0, 0x19},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_0, 0x1a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_0, 0x17},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_0, 0x17},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_0, 0x1c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_0, 0x1b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_0, 0x17},
-#define CCM_FUNC2_END 617
-#define CCM_FUNC3_START 617
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_1, 0x39},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_1, 0x3a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_1, 0x37},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_1, 0x37},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_1, 0x3c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_1, 0x3b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_1, 0x37},
-#define CCM_FUNC3_END 624
-#define CCM_FUNC4_START 624
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_0, 0x49},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_0, 0x4a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_0, 0x47},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_0, 0x47},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_0, 0x4c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_0, 0x4b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_0, 0x47},
-#define CCM_FUNC4_END 631
-#define CCM_FUNC5_START 631
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_1, 0x69},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_1, 0x6a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_1, 0x67},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_1, 0x67},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_1, 0x6c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_1, 0x6b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_1, 0x67},
-#define CCM_FUNC5_END 638
-#define CCM_FUNC6_START 638
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_0, 0x59},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_0, 0x5a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_0, 0x57},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_0, 0x57},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_0, 0x5c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_0, 0x5b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_0, 0x57},
-#define CCM_FUNC6_END 645
-#define CCM_FUNC7_START 645
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM0_1, 0x79},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM1_1, 0x7a},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM2_1, 0x77},
- {OP_WR_E1H, CCM_REG_QOS_PHYS_QNUM3_1, 0x77},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM1_1, 0x7c},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM2_1, 0x7b},
- {OP_WR_E1H, CCM_REG_PHYS_QNUM3_1, 0x77},
-#define CCM_FUNC7_END 652
-#define UCM_COMMON_START 652
- {OP_WR, UCM_REG_XX_OVFL_EVNT_ID, 0x32},
- {OP_WR, UCM_REG_UQM_UCM_HDR_P, 0x2150020},
- {OP_WR, UCM_REG_UQM_UCM_HDR_S, 0x2150020},
- {OP_WR, UCM_REG_TM_UCM_HDR, 0x30},
- {OP_WR, UCM_REG_ERR_UCM_HDR, 0x8100000},
- {OP_WR, UCM_REG_ERR_EVNT_ID, 0x33},
- {OP_WR, UCM_REG_EXPR_EVNT_ID, 0x30},
- {OP_WR, UCM_REG_STOP_EVNT_ID, 0x31},
- {OP_WR, UCM_REG_STORM_WEIGHT, 0x2},
- {OP_WR, UCM_REG_TSEM_WEIGHT, 0x4},
- {OP_WR, UCM_REG_CSEM_WEIGHT, 0x0},
- {OP_WR, UCM_REG_XSEM_WEIGHT, 0x2},
- {OP_WR, UCM_REG_DORQ_WEIGHT, 0x2},
- {OP_WR, UCM_REG_CP_WEIGHT, 0x0},
- {OP_WR, UCM_REG_USDM_WEIGHT, 0x2},
- {OP_WR, UCM_REG_UQM_P_WEIGHT, 0x7},
- {OP_WR, UCM_REG_UQM_S_WEIGHT, 0x2},
- {OP_WR, UCM_REG_TM_WEIGHT, 0x2},
- {OP_WR, UCM_REG_UCM_UQM_USE_Q, 0x1},
- {OP_WR, UCM_REG_INV_CFLG_Q, 0x1},
- {OP_WR, UCM_REG_GR_ARB_TYPE, 0x1},
- {OP_WR, UCM_REG_GR_LD0_PR, 0x1},
- {OP_WR, UCM_REG_GR_LD1_PR, 0x2},
- {OP_WR, UCM_REG_CFC_INIT_CRD, 0x1},
- {OP_WR, UCM_REG_FIC0_INIT_CRD, 0x40},
- {OP_WR, UCM_REG_FIC1_INIT_CRD, 0x40},
- {OP_WR, UCM_REG_TM_INIT_CRD, 0x4},
- {OP_WR, UCM_REG_UQM_INIT_CRD, 0x20},
- {OP_WR, UCM_REG_XX_INIT_CRD, 0xe},
- {OP_WR, UCM_REG_XX_MSG_NUM, 0x1b},
- {OP_ZR, UCM_REG_XX_TABLE, 0x12},
- {OP_SW_E1, UCM_REG_XX_DESCR_TABLE, 0x1b0266},
- {OP_SW_E1H, UCM_REG_XX_DESCR_TABLE, 0x1b02a0},
- {OP_WR, UCM_REG_N_SM_CTX_LD_0, 0x10},
- {OP_WR, UCM_REG_N_SM_CTX_LD_1, 0x7},
- {OP_WR, UCM_REG_N_SM_CTX_LD_2, 0xf},
- {OP_WR, UCM_REG_N_SM_CTX_LD_3, 0x10},
- {OP_ZR_E1, UCM_REG_N_SM_CTX_LD_4, 0x4},
- {OP_WR_E1H, UCM_REG_N_SM_CTX_LD_4, 0xb},
- {OP_ZR_E1H, UCM_REG_N_SM_CTX_LD_5, 0x3},
- {OP_WR, UCM_REG_UCM_REG0_SZ, 0x3},
- {OP_WR_E1, UCM_REG_PHYS_QNUM0_0, 0xf},
- {OP_WR_E1, UCM_REG_PHYS_QNUM0_1, 0x2f},
- {OP_WR_E1, UCM_REG_PHYS_QNUM1_0, 0xe},
- {OP_WR_E1, UCM_REG_PHYS_QNUM1_1, 0x2e},
- {OP_WR, UCM_REG_UCM_STORM0_IFEN, 0x1},
- {OP_WR, UCM_REG_UCM_STORM1_IFEN, 0x1},
- {OP_WR, UCM_REG_UCM_UQM_IFEN, 0x1},
- {OP_WR, UCM_REG_STORM_UCM_IFEN, 0x1},
- {OP_WR, UCM_REG_UQM_UCM_IFEN, 0x1},
- {OP_WR, UCM_REG_USDM_IFEN, 0x1},
- {OP_WR, UCM_REG_TM_UCM_IFEN, 0x1},
- {OP_WR, UCM_REG_UCM_TM_IFEN, 0x1},
- {OP_WR, UCM_REG_TSEM_IFEN, 0x1},
- {OP_WR, UCM_REG_CSEM_IFEN, 0x1},
- {OP_WR, UCM_REG_XSEM_IFEN, 0x1},
- {OP_WR, UCM_REG_DORQ_IFEN, 0x1},
- {OP_WR, UCM_REG_CDU_AG_WR_IFEN, 0x1},
- {OP_WR, UCM_REG_CDU_AG_RD_IFEN, 0x1},
- {OP_WR, UCM_REG_CDU_SM_WR_IFEN, 0x1},
- {OP_WR, UCM_REG_CDU_SM_RD_IFEN, 0x1},
- {OP_WR, UCM_REG_UCM_CFC_IFEN, 0x1},
-#define UCM_COMMON_END 714
-#define UCM_FUNC0_START 714
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_0, 0xf},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_0, 0xe},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_0, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_0, 0x0},
-#define UCM_FUNC0_END 718
-#define UCM_FUNC1_START 718
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_1, 0x2f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_1, 0x2e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_1, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_1, 0x0},
-#define UCM_FUNC1_END 722
-#define UCM_FUNC2_START 722
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_0, 0x1f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_0, 0x1e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_0, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_0, 0x0},
-#define UCM_FUNC2_END 726
-#define UCM_FUNC3_START 726
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_1, 0x3f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_1, 0x3e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_1, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_1, 0x0},
-#define UCM_FUNC3_END 730
-#define UCM_FUNC4_START 730
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_0, 0x4f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_0, 0x4e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_0, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_0, 0x0},
-#define UCM_FUNC4_END 734
-#define UCM_FUNC5_START 734
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_1, 0x6f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_1, 0x6e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_1, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_1, 0x0},
-#define UCM_FUNC5_END 738
-#define UCM_FUNC6_START 738
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_0, 0x5f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_0, 0x5e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_0, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_0, 0x0},
-#define UCM_FUNC6_END 742
-#define UCM_FUNC7_START 742
- {OP_WR_E1H, UCM_REG_PHYS_QNUM0_1, 0x7f},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM1_1, 0x7e},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM2_1, 0x0},
- {OP_WR_E1H, UCM_REG_PHYS_QNUM3_1, 0x0},
-#define UCM_FUNC7_END 746
-#define USEM_COMMON_START 746
- {OP_RD, USEM_REG_MSG_NUM_FIC0, 0x0},
- {OP_RD, USEM_REG_MSG_NUM_FIC1, 0x0},
- {OP_RD, USEM_REG_MSG_NUM_FOC0, 0x0},
- {OP_RD, USEM_REG_MSG_NUM_FOC1, 0x0},
- {OP_RD, USEM_REG_MSG_NUM_FOC2, 0x0},
- {OP_RD, USEM_REG_MSG_NUM_FOC3, 0x0},
- {OP_WR, USEM_REG_ARB_ELEMENT0, 0x1},
- {OP_WR, USEM_REG_ARB_ELEMENT1, 0x2},
- {OP_WR, USEM_REG_ARB_ELEMENT2, 0x3},
- {OP_WR, USEM_REG_ARB_ELEMENT3, 0x0},
- {OP_WR, USEM_REG_ARB_ELEMENT4, 0x4},
- {OP_WR, USEM_REG_ARB_CYCLE_SIZE, 0x1},
- {OP_WR, USEM_REG_TS_0_AS, 0x0},
- {OP_WR, USEM_REG_TS_1_AS, 0x1},
- {OP_WR, USEM_REG_TS_2_AS, 0x4},
- {OP_WR, USEM_REG_TS_3_AS, 0x0},
- {OP_WR, USEM_REG_TS_4_AS, 0x1},
- {OP_WR, USEM_REG_TS_5_AS, 0x3},
- {OP_WR, USEM_REG_TS_6_AS, 0x0},
- {OP_WR, USEM_REG_TS_7_AS, 0x1},
- {OP_WR, USEM_REG_TS_8_AS, 0x4},
- {OP_WR, USEM_REG_TS_9_AS, 0x0},
- {OP_WR, USEM_REG_TS_10_AS, 0x1},
- {OP_WR, USEM_REG_TS_11_AS, 0x3},
- {OP_WR, USEM_REG_TS_12_AS, 0x0},
- {OP_WR, USEM_REG_TS_13_AS, 0x1},
- {OP_WR, USEM_REG_TS_14_AS, 0x4},
- {OP_WR, USEM_REG_TS_15_AS, 0x0},
- {OP_WR, USEM_REG_TS_16_AS, 0x4},
- {OP_WR, USEM_REG_TS_17_AS, 0x3},
- {OP_ZR, USEM_REG_TS_18_AS, 0x2},
- {OP_WR, USEM_REG_ENABLE_IN, 0x3fff},
- {OP_WR, USEM_REG_ENABLE_OUT, 0x3ff},
- {OP_WR, USEM_REG_FIC0_DISABLE, 0x0},
- {OP_WR, USEM_REG_FIC1_DISABLE, 0x0},
- {OP_WR, USEM_REG_PAS_DISABLE, 0x0},
- {OP_WR, USEM_REG_THREADS_LIST, 0xffff},
- {OP_ZR, USEM_REG_PASSIVE_BUFFER, 0x800},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x18bc0, 0x1},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x18000, 0x1a},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x18040, 0x4e},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x18080, 0x10},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x180c0, 0x20},
- {OP_WR_ASIC, USEM_REG_FAST_MEMORY + 0x18300, 0x7a120},
- {OP_WR_EMUL, USEM_REG_FAST_MEMORY + 0x18300, 0x138},
- {OP_WR_FPGA, USEM_REG_FAST_MEMORY + 0x18300, 0x1388},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x183c0, 0x1f4},
- {OP_WR_ASIC, USEM_REG_FAST_MEMORY + 0x18380, 0x1dcd6500},
- {OP_WR_EMUL, USEM_REG_FAST_MEMORY + 0x18380, 0x4c4b4},
- {OP_WR_FPGA, USEM_REG_FAST_MEMORY + 0x18380, 0x4c4b40},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x5000, 0xc2},
- {OP_WR_EMUL_E1H, USEM_REG_FAST_MEMORY + 0x11480, 0x0},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1020, 0xc8},
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x11480, 0x1},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1000, 0x2},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x2000, 0x102},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x4640, 0x40},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x8980, 0xc8},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x57f0, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x8960, 0x2},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x57d8, 0x5},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3228, 0x4},
- {OP_SW_E1, USEM_REG_FAST_MEMORY + 0x57d8 + 0x14, 0x10281},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3200, 0x9},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1c60, 0x20},
- {OP_SW_E1H, USEM_REG_FAST_MEMORY + 0x3200 + 0x24, 0x102bb},
- {OP_SW_E1, USEM_REG_FAST_MEMORY + 0x2830, 0x20282},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3180, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5000, 0x400},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4000, 0x2},
- {OP_SW_E1H, USEM_REG_FAST_MEMORY + 0x4000 + 0x8, 0x102bc},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4000 + 0xc, 0x3},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x6b68, 0x2},
- {OP_SW_E1H, USEM_REG_FAST_MEMORY + 0x6b68 + 0x8, 0x202bd},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x6b10, 0x2},
- {OP_SW_E1H, USEM_REG_FAST_MEMORY + 0x74c0, 0x202bf},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x10800, 0x1000000},
- {OP_SW_E1, USEM_REG_FAST_MEMORY + 0x10c00, 0x100284},
- {OP_SW_E1H, USEM_REG_FAST_MEMORY + 0x10c00, 0x1002c1},
- {OP_WR, USEM_REG_FAST_MEMORY + 0x10800, 0x0},
- {OP_SW_E1, USEM_REG_FAST_MEMORY + 0x10c40, 0x100294},
- {OP_SW_E1H, USEM_REG_FAST_MEMORY + 0x10c40, 0x1002d1},
- {OP_ZP_E1, USEM_REG_INT_TABLE, 0xc30000},
- {OP_ZP_E1H, USEM_REG_INT_TABLE, 0xd20000},
- {OP_WR_64_E1, USEM_REG_INT_TABLE + 0x368, 0x1302a4},
- {OP_WR_64_E1H, USEM_REG_INT_TABLE + 0x3a8, 0xb02e1},
- {OP_ZP_E1, USEM_REG_PRAM, 0x314c0000},
- {OP_ZP_E1H, USEM_REG_PRAM, 0x31b60000},
- {OP_ZP_E1, USEM_REG_PRAM + 0x8000, 0x35ef0c53},
- {OP_ZP_E1H, USEM_REG_PRAM + 0x8000, 0x36500c6e},
- {OP_ZP_E1, USEM_REG_PRAM + 0x10000, 0x361319cf},
- {OP_ZP_E1H, USEM_REG_PRAM + 0x10000, 0x37591a02},
- {OP_ZP_E1, USEM_REG_PRAM + 0x18000, 0x7112754},
- {OP_ZP_E1H, USEM_REG_PRAM + 0x18000, 0x286127d9},
- {OP_WR_64_E1, USEM_REG_PRAM + 0x18ee0, 0x4e2402a6},
- {OP_WR_64_E1H, USEM_REG_PRAM + 0x1ff40, 0x401802e3},
-#define USEM_COMMON_END 842
-#define USEM_PORT0_START 842
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1400, 0xa0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x9000, 0xa0},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1900, 0x10},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x9500, 0x40},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1980, 0x30},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x9700, 0x3c},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x4740, 0xb4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x2450, 0xb4},
- {OP_WR_E1, USEM_REG_FAST_MEMORY + 0x1d90, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x2ad0, 0x2},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1b40, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3080, 0x20},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1b60, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x8000, 0x12c},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x5318, 0x98},
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x3238, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5000, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5100, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5200, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5300, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5400, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5500, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5600, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5700, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5800, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5900, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5a00, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5b00, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5c00, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5d00, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5e00, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5f00, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x6b78, 0x52},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x6e08, 0xc},
-#define USEM_PORT0_END 876
-#define USEM_PORT1_START 876
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1680, 0xa0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x9280, 0xa0},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1940, 0x10},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x9600, 0x40},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1a40, 0x30},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x97f0, 0x3c},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x4a10, 0xb4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x2720, 0xb4},
- {OP_WR_E1, USEM_REG_FAST_MEMORY + 0x1d94, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x2ad8, 0x2},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1b50, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3100, 0x20},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x1be0, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x84b0, 0x12c},
- {OP_ZR_E1, USEM_REG_FAST_MEMORY + 0x5578, 0x98},
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x323c, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5080, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5180, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5280, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5380, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5480, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5580, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5680, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5780, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5880, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5980, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5a80, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5b80, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5c80, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5d80, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5e80, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x5f80, 0x20},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x6cc0, 0x52},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x6e38, 0xc},
-#define USEM_PORT1_END 910
-#define USEM_FUNC0_START 910
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a30, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3000, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4018, 0x2},
-#define USEM_FUNC0_END 913
-#define USEM_FUNC1_START 913
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a34, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3010, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4028, 0x2},
-#define USEM_FUNC1_END 916
-#define USEM_FUNC2_START 916
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a38, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3020, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4038, 0x2},
-#define USEM_FUNC2_END 919
-#define USEM_FUNC3_START 919
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a3c, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3030, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4048, 0x2},
-#define USEM_FUNC3_END 922
-#define USEM_FUNC4_START 922
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a40, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3040, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4058, 0x2},
-#define USEM_FUNC4_END 925
-#define USEM_FUNC5_START 925
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a44, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3050, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4068, 0x2},
-#define USEM_FUNC5_END 928
-#define USEM_FUNC6_START 928
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a48, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3060, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4078, 0x2},
-#define USEM_FUNC6_END 931
-#define USEM_FUNC7_START 931
- {OP_WR_E1H, USEM_REG_FAST_MEMORY + 0x2a4c, 0x0},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x3070, 0x4},
- {OP_ZR_E1H, USEM_REG_FAST_MEMORY + 0x4088, 0x2},
-#define USEM_FUNC7_END 934
-#define CSEM_COMMON_START 934
- {OP_RD, CSEM_REG_MSG_NUM_FIC0, 0x0},
- {OP_RD, CSEM_REG_MSG_NUM_FIC1, 0x0},
- {OP_RD, CSEM_REG_MSG_NUM_FOC0, 0x0},
- {OP_RD, CSEM_REG_MSG_NUM_FOC1, 0x0},
- {OP_RD, CSEM_REG_MSG_NUM_FOC2, 0x0},
- {OP_RD, CSEM_REG_MSG_NUM_FOC3, 0x0},
- {OP_WR, CSEM_REG_ARB_ELEMENT0, 0x1},
- {OP_WR, CSEM_REG_ARB_ELEMENT1, 0x2},
- {OP_WR, CSEM_REG_ARB_ELEMENT2, 0x3},
- {OP_WR, CSEM_REG_ARB_ELEMENT3, 0x0},
- {OP_WR, CSEM_REG_ARB_ELEMENT4, 0x4},
- {OP_WR, CSEM_REG_ARB_CYCLE_SIZE, 0x1},
- {OP_WR, CSEM_REG_TS_0_AS, 0x0},
- {OP_WR, CSEM_REG_TS_1_AS, 0x1},
- {OP_WR, CSEM_REG_TS_2_AS, 0x4},
- {OP_WR, CSEM_REG_TS_3_AS, 0x0},
- {OP_WR, CSEM_REG_TS_4_AS, 0x1},
- {OP_WR, CSEM_REG_TS_5_AS, 0x3},
- {OP_WR, CSEM_REG_TS_6_AS, 0x0},
- {OP_WR, CSEM_REG_TS_7_AS, 0x1},
- {OP_WR, CSEM_REG_TS_8_AS, 0x4},
- {OP_WR, CSEM_REG_TS_9_AS, 0x0},
- {OP_WR, CSEM_REG_TS_10_AS, 0x1},
- {OP_WR, CSEM_REG_TS_11_AS, 0x3},
- {OP_WR, CSEM_REG_TS_12_AS, 0x0},
- {OP_WR, CSEM_REG_TS_13_AS, 0x1},
- {OP_WR, CSEM_REG_TS_14_AS, 0x4},
- {OP_WR, CSEM_REG_TS_15_AS, 0x0},
- {OP_WR, CSEM_REG_TS_16_AS, 0x4},
- {OP_WR, CSEM_REG_TS_17_AS, 0x3},
- {OP_ZR, CSEM_REG_TS_18_AS, 0x2},
- {OP_WR, CSEM_REG_ENABLE_IN, 0x3fff},
- {OP_WR, CSEM_REG_ENABLE_OUT, 0x3ff},
- {OP_WR, CSEM_REG_FIC0_DISABLE, 0x0},
- {OP_WR, CSEM_REG_FIC1_DISABLE, 0x0},
- {OP_WR, CSEM_REG_PAS_DISABLE, 0x0},
- {OP_WR, CSEM_REG_THREADS_LIST, 0xffff},
- {OP_ZR, CSEM_REG_PASSIVE_BUFFER, 0x800},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x18bc0, 0x1},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x18000, 0x10},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x18040, 0x12},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x18080, 0x30},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x180c0, 0xe},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x183c0, 0x1f4},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x5000, 0x42},
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x11480, 0x1},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1020, 0xc8},
- {OP_WR_EMUL_E1H, CSEM_REG_FAST_MEMORY + 0x11480, 0x0},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1000, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x1000, 0x42},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x2000, 0xc0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x7020, 0xc8},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x3070, 0x80},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x7000, 0x2},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x4280, 0x4},
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x11e8, 0x0},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x25c0, 0x240},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3000, 0xc0},
- {OP_SW_E1, CSEM_REG_FAST_MEMORY + 0x2ec8, 0x802a8},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x4070, 0x80},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x5280, 0x4},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6700, 0x100},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x9000, 0x400},
- {OP_SW_E1H, CSEM_REG_FAST_MEMORY + 0x6b08, 0x2002e5},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x10800, 0x13fffff},
- {OP_SW_E1, CSEM_REG_FAST_MEMORY + 0x10c00, 0x1002b0},
- {OP_SW_E1H, CSEM_REG_FAST_MEMORY + 0x10c00, 0x100305},
- {OP_WR, CSEM_REG_FAST_MEMORY + 0x10800, 0x0},
- {OP_SW_E1, CSEM_REG_FAST_MEMORY + 0x10c40, 0x1002c0},
- {OP_SW_E1H, CSEM_REG_FAST_MEMORY + 0x10c40, 0x100315},
- {OP_ZP_E1, CSEM_REG_INT_TABLE, 0x710000},
- {OP_ZP_E1H, CSEM_REG_INT_TABLE, 0x740000},
- {OP_WR_64_E1, CSEM_REG_INT_TABLE + 0x380, 0x1002d0},
- {OP_WR_64_E1H, CSEM_REG_INT_TABLE + 0x380, 0x100325},
- {OP_ZP_E1, CSEM_REG_PRAM, 0x32290000},
- {OP_ZP_E1H, CSEM_REG_PRAM, 0x32260000},
- {OP_ZP_E1, CSEM_REG_PRAM + 0x8000, 0x23630c8b},
- {OP_ZP_E1H, CSEM_REG_PRAM + 0x8000, 0x246e0c8a},
- {OP_WR_64_E1, CSEM_REG_PRAM + 0xc930, 0x654002d2},
- {OP_WR_64_E1H, CSEM_REG_PRAM + 0xcbb0, 0x64f00327},
-#define CSEM_COMMON_END 1014
-#define CSEM_PORT0_START 1014
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1400, 0xa0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x8000, 0xa0},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1900, 0x10},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x8500, 0x40},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1980, 0x30},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x8700, 0x3c},
- {OP_WR_E1, CSEM_REG_FAST_MEMORY + 0x5118, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x4040, 0x6},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x2300, 0xe},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x3040, 0x6},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x2410, 0x30},
-#define CSEM_PORT0_END 1025
-#define CSEM_PORT1_START 1025
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1680, 0xa0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x8280, 0xa0},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1940, 0x10},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x8600, 0x40},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x1a40, 0x30},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x87f0, 0x3c},
- {OP_WR_E1, CSEM_REG_FAST_MEMORY + 0x511c, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x4058, 0x6},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x2338, 0xe},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x3058, 0x6},
- {OP_ZR_E1, CSEM_REG_FAST_MEMORY + 0x24d0, 0x30},
-#define CSEM_PORT1_END 1036
-#define CSEM_FUNC0_START 1036
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x1148, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3300, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6040, 0x30},
-#define CSEM_FUNC0_END 1039
-#define CSEM_FUNC1_START 1039
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x114c, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3308, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6100, 0x30},
-#define CSEM_FUNC1_END 1042
-#define CSEM_FUNC2_START 1042
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x1150, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3310, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x61c0, 0x30},
-#define CSEM_FUNC2_END 1045
-#define CSEM_FUNC3_START 1045
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x1154, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3318, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6280, 0x30},
-#define CSEM_FUNC3_END 1048
-#define CSEM_FUNC4_START 1048
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x1158, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3320, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6340, 0x30},
-#define CSEM_FUNC4_END 1051
-#define CSEM_FUNC5_START 1051
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x115c, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3328, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6400, 0x30},
-#define CSEM_FUNC5_END 1054
-#define CSEM_FUNC6_START 1054
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x1160, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3330, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x64c0, 0x30},
-#define CSEM_FUNC6_END 1057
-#define CSEM_FUNC7_START 1057
- {OP_WR_E1H, CSEM_REG_FAST_MEMORY + 0x1164, 0x0},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x3338, 0x2},
- {OP_ZR_E1H, CSEM_REG_FAST_MEMORY + 0x6580, 0x30},
-#define CSEM_FUNC7_END 1060
-#define XPB_COMMON_START 1060
- {OP_WR, GRCBASE_XPB + PB_REG_CONTROL, 0x20},
-#define XPB_COMMON_END 1061
-#define DQ_COMMON_START 1061
- {OP_WR, DORQ_REG_MODE_ACT, 0x2},
- {OP_WR, DORQ_REG_NORM_CID_OFST, 0x3},
- {OP_WR, DORQ_REG_OUTST_REQ, 0x4},
- {OP_WR, DORQ_REG_DPM_CID_ADDR, 0x8},
- {OP_WR, DORQ_REG_RSP_INIT_CRD, 0x2},
- {OP_WR, DORQ_REG_NORM_CMHEAD_TX, 0x90},
- {OP_WR, DORQ_REG_CMHEAD_RX, 0x90},
- {OP_WR, DORQ_REG_SHRT_CMHEAD, 0x800090},
- {OP_WR, DORQ_REG_ERR_CMHEAD, 0x8140000},
- {OP_WR, DORQ_REG_AGG_CMD0, 0x8a},
- {OP_WR, DORQ_REG_AGG_CMD1, 0x80},
- {OP_WR, DORQ_REG_AGG_CMD2, 0x90},
- {OP_WR, DORQ_REG_AGG_CMD3, 0x80},
- {OP_WR, DORQ_REG_SHRT_ACT_CNT, 0x6},
- {OP_WR, DORQ_REG_DQ_FIFO_FULL_TH, 0x7d0},
- {OP_WR, DORQ_REG_DQ_FIFO_AFULL_TH, 0x76c},
- {OP_WR, DORQ_REG_REGN, 0x7c1004},
- {OP_WR, DORQ_REG_IF_EN, 0xf},
-#define DQ_COMMON_END 1079
-#define TIMERS_COMMON_START 1079
- {OP_ZR, TM_REG_CLIN_PRIOR0_CLIENT, 0x2},
- {OP_WR, TM_REG_LIN_SETCLR_FIFO_ALFULL_THR, 0x1c},
- {OP_WR, TM_REG_CFC_AC_CRDCNT_VAL, 0x1},
- {OP_WR, TM_REG_CFC_CLD_CRDCNT_VAL, 0x1},
- {OP_WR, TM_REG_CLOUT_CRDCNT0_VAL, 0x1},
- {OP_WR, TM_REG_CLOUT_CRDCNT1_VAL, 0x1},
- {OP_WR, TM_REG_CLOUT_CRDCNT2_VAL, 0x1},
- {OP_WR, TM_REG_EXP_CRDCNT_VAL, 0x1},
- {OP_WR_E1, TM_REG_PCIARB_CRDCNT_VAL, 0x1},
- {OP_WR_E1H, TM_REG_PCIARB_CRDCNT_VAL, 0x2},
- {OP_WR_ASIC, TM_REG_TIMER_TICK_SIZE, 0x3d090},
- {OP_WR_EMUL, TM_REG_TIMER_TICK_SIZE, 0x9c},
- {OP_WR_FPGA, TM_REG_TIMER_TICK_SIZE, 0x9c4},
- {OP_WR, TM_REG_CL0_CONT_REGION, 0x8},
- {OP_WR, TM_REG_CL1_CONT_REGION, 0xc},
- {OP_WR, TM_REG_CL2_CONT_REGION, 0x10},
- {OP_WR, TM_REG_TM_CONTEXT_REGION, 0x20},
- {OP_WR, TM_REG_EN_TIMERS, 0x1},
- {OP_WR, TM_REG_EN_REAL_TIME_CNT, 0x1},
- {OP_WR, TM_REG_EN_CL0_INPUT, 0x1},
- {OP_WR, TM_REG_EN_CL1_INPUT, 0x1},
- {OP_WR, TM_REG_EN_CL2_INPUT, 0x1},
-#define TIMERS_COMMON_END 1101
-#define TIMERS_PORT0_START 1101
- {OP_WR, TM_REG_LIN0_LOGIC_ADDR, 0x0},
- {OP_WR, TM_REG_LIN0_PHY_ADDR_VALID, 0x0},
- {OP_ZR, TM_REG_LIN0_PHY_ADDR, 0x2},
-#define TIMERS_PORT0_END 1104
-#define TIMERS_PORT1_START 1104
- {OP_WR, TM_REG_LIN1_LOGIC_ADDR, 0x0},
- {OP_WR, TM_REG_LIN1_PHY_ADDR_VALID, 0x0},
- {OP_ZR, TM_REG_LIN1_PHY_ADDR, 0x2},
-#define TIMERS_PORT1_END 1107
-#define XSDM_COMMON_START 1107
- {OP_WR_E1, XSDM_REG_CFC_RSP_START_ADDR, 0x614},
- {OP_WR_E1H, XSDM_REG_CFC_RSP_START_ADDR, 0x424},
- {OP_WR_E1, XSDM_REG_CMP_COUNTER_START_ADDR, 0x600},
- {OP_WR_E1H, XSDM_REG_CMP_COUNTER_START_ADDR, 0x410},
- {OP_WR_E1, XSDM_REG_Q_COUNTER_START_ADDR, 0x604},
- {OP_WR_E1H, XSDM_REG_Q_COUNTER_START_ADDR, 0x414},
- {OP_WR, XSDM_REG_CMP_COUNTER_MAX0, 0xffff},
- {OP_WR, XSDM_REG_CMP_COUNTER_MAX1, 0xffff},
- {OP_WR, XSDM_REG_CMP_COUNTER_MAX2, 0xffff},
- {OP_WR, XSDM_REG_CMP_COUNTER_MAX3, 0xffff},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_0, 0x20},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_1, 0x20},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_2, 0x34},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_3, 0x35},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_4, 0x23},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_5, 0x24},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_6, 0x25},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_7, 0x26},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_8, 0x27},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_9, 0x29},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_10, 0x2a},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_11, 0x2b},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_12, 0x2c},
- {OP_WR, XSDM_REG_AGG_INT_EVENT_13, 0x2d},
- {OP_ZR, XSDM_REG_AGG_INT_EVENT_14, 0x52},
- {OP_WR, XSDM_REG_AGG_INT_MODE_0, 0x1},
- {OP_ZR, XSDM_REG_AGG_INT_MODE_1, 0x1f},
- {OP_WR, XSDM_REG_ENABLE_IN1, 0x7ffffff},
- {OP_WR, XSDM_REG_ENABLE_IN2, 0x3f},
- {OP_WR, XSDM_REG_ENABLE_OUT1, 0x7ffffff},
- {OP_WR, XSDM_REG_ENABLE_OUT2, 0xf},
- {OP_RD, XSDM_REG_NUM_OF_Q0_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q1_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q3_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q4_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q5_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q6_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q7_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q8_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q9_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q10_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_Q11_CMD, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_PKT_END_MSG, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_PXP_ASYNC_REQ, 0x0},
- {OP_RD, XSDM_REG_NUM_OF_ACK_AFTER_PLACE, 0x0},
- {OP_WR_E1, XSDM_REG_INIT_CREDIT_PXP_CTRL, 0x1},
- {OP_WR_ASIC, XSDM_REG_TIMER_TICK, 0x3e8},
- {OP_WR_EMUL, XSDM_REG_TIMER_TICK, 0x1},
- {OP_WR_FPGA, XSDM_REG_TIMER_TICK, 0xa},
-#define XSDM_COMMON_END 1156
-#define QM_COMMON_START 1156
- {OP_WR, QM_REG_ACTCTRINITVAL_0, 0x6},
- {OP_WR, QM_REG_ACTCTRINITVAL_1, 0x5},
- {OP_WR, QM_REG_ACTCTRINITVAL_2, 0xa},
- {OP_WR, QM_REG_ACTCTRINITVAL_3, 0x5},
- {OP_WR, QM_REG_PCIREQAT, 0x2},
- {OP_WR, QM_REG_CMINITCRD_0, 0x4},
- {OP_WR, QM_REG_CMINITCRD_1, 0x4},
- {OP_WR, QM_REG_CMINITCRD_2, 0x4},
- {OP_WR, QM_REG_CMINITCRD_3, 0x4},
- {OP_WR, QM_REG_CMINITCRD_4, 0x4},
- {OP_WR, QM_REG_CMINITCRD_5, 0x4},
- {OP_WR, QM_REG_CMINITCRD_6, 0x4},
- {OP_WR, QM_REG_CMINITCRD_7, 0x4},
- {OP_WR, QM_REG_OUTLDREQ, 0x4},
- {OP_WR, QM_REG_CTXREG_0, 0x7c},
- {OP_WR, QM_REG_CTXREG_1, 0x3d},
- {OP_WR, QM_REG_CTXREG_2, 0x3f},
- {OP_WR, QM_REG_CTXREG_3, 0x9c},
- {OP_WR, QM_REG_ENSEC, 0x7},
- {OP_ZR, QM_REG_QVOQIDX_0, 0x5},
- {OP_WR, QM_REG_WRRWEIGHTS_0, 0x1010101},
- {OP_WR, QM_REG_QVOQIDX_5, 0x0},
- {OP_WR, QM_REG_QVOQIDX_6, 0x4},
- {OP_WR, QM_REG_QVOQIDX_7, 0x4},
- {OP_WR, QM_REG_QVOQIDX_8, 0x2},
- {OP_WR, QM_REG_WRRWEIGHTS_1, 0x8012004},
- {OP_WR, QM_REG_QVOQIDX_9, 0x5},
- {OP_WR, QM_REG_QVOQIDX_10, 0x5},
- {OP_WR, QM_REG_QVOQIDX_11, 0x5},
- {OP_WR, QM_REG_QVOQIDX_12, 0x5},
- {OP_WR, QM_REG_WRRWEIGHTS_2, 0x20081001},
- {OP_WR, QM_REG_QVOQIDX_13, 0x8},
- {OP_WR, QM_REG_QVOQIDX_14, 0x6},
- {OP_WR, QM_REG_QVOQIDX_15, 0x7},
- {OP_WR, QM_REG_QVOQIDX_16, 0x0},
- {OP_WR, QM_REG_WRRWEIGHTS_3, 0x1010120},
- {OP_ZR, QM_REG_QVOQIDX_17, 0x4},
- {OP_WR, QM_REG_WRRWEIGHTS_4, 0x1010101},
- {OP_ZR_E1, QM_REG_QVOQIDX_21, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_21, 0x0},
- {OP_WR_E1, QM_REG_WRRWEIGHTS_5, 0x1010101},
- {OP_WR_E1H, QM_REG_QVOQIDX_22, 0x4},
- {OP_ZR_E1, QM_REG_QVOQIDX_25, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_23, 0x4},
- {OP_WR_E1, QM_REG_WRRWEIGHTS_6, 0x1010101},
- {OP_WR_E1H, QM_REG_QVOQIDX_24, 0x2},
- {OP_ZR_E1, QM_REG_QVOQIDX_29, 0x3},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_5, 0x8012004},
- {OP_WR_E1H, QM_REG_QVOQIDX_25, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_26, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_27, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_28, 0x5},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_6, 0x20081001},
- {OP_WR_E1H, QM_REG_QVOQIDX_29, 0x8},
- {OP_WR_E1H, QM_REG_QVOQIDX_30, 0x6},
- {OP_WR_E1H, QM_REG_QVOQIDX_31, 0x7},
- {OP_WR, QM_REG_QVOQIDX_32, 0x1},
- {OP_WR_E1, QM_REG_WRRWEIGHTS_7, 0x1010101},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_7, 0x1010120},
- {OP_WR, QM_REG_QVOQIDX_33, 0x1},
- {OP_WR, QM_REG_QVOQIDX_34, 0x1},
- {OP_WR, QM_REG_QVOQIDX_35, 0x1},
- {OP_WR, QM_REG_QVOQIDX_36, 0x1},
- {OP_WR, QM_REG_WRRWEIGHTS_8, 0x1010101},
- {OP_WR, QM_REG_QVOQIDX_37, 0x1},
- {OP_WR, QM_REG_QVOQIDX_38, 0x4},
- {OP_WR, QM_REG_QVOQIDX_39, 0x4},
- {OP_WR, QM_REG_QVOQIDX_40, 0x2},
- {OP_WR, QM_REG_WRRWEIGHTS_9, 0x8012004},
- {OP_WR, QM_REG_QVOQIDX_41, 0x5},
- {OP_WR, QM_REG_QVOQIDX_42, 0x5},
- {OP_WR, QM_REG_QVOQIDX_43, 0x5},
- {OP_WR, QM_REG_QVOQIDX_44, 0x5},
- {OP_WR, QM_REG_WRRWEIGHTS_10, 0x20081001},
- {OP_WR, QM_REG_QVOQIDX_45, 0x8},
- {OP_WR, QM_REG_QVOQIDX_46, 0x6},
- {OP_WR, QM_REG_QVOQIDX_47, 0x7},
- {OP_WR, QM_REG_QVOQIDX_48, 0x1},
- {OP_WR, QM_REG_WRRWEIGHTS_11, 0x1010120},
- {OP_WR, QM_REG_QVOQIDX_49, 0x1},
- {OP_WR, QM_REG_QVOQIDX_50, 0x1},
- {OP_WR, QM_REG_QVOQIDX_51, 0x1},
- {OP_WR, QM_REG_QVOQIDX_52, 0x1},
- {OP_WR, QM_REG_WRRWEIGHTS_12, 0x1010101},
- {OP_WR, QM_REG_QVOQIDX_53, 0x1},
- {OP_WR_E1, QM_REG_QVOQIDX_54, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_54, 0x4},
- {OP_WR_E1, QM_REG_QVOQIDX_55, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_55, 0x4},
- {OP_WR_E1, QM_REG_QVOQIDX_56, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_56, 0x2},
- {OP_WR_E1, QM_REG_WRRWEIGHTS_13, 0x1010101},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_13, 0x8012004},
- {OP_WR_E1, QM_REG_QVOQIDX_57, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_57, 0x5},
- {OP_WR_E1, QM_REG_QVOQIDX_58, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_58, 0x5},
- {OP_WR_E1, QM_REG_QVOQIDX_59, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_59, 0x5},
- {OP_WR_E1, QM_REG_QVOQIDX_60, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_60, 0x5},
- {OP_WR_E1, QM_REG_WRRWEIGHTS_14, 0x1010101},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_14, 0x20081001},
- {OP_WR_E1, QM_REG_QVOQIDX_61, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_61, 0x8},
- {OP_WR_E1, QM_REG_QVOQIDX_62, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_62, 0x6},
- {OP_WR_E1, QM_REG_QVOQIDX_63, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_63, 0x7},
- {OP_WR_E1, QM_REG_WRRWEIGHTS_15, 0x1010101},
- {OP_WR_E1H, QM_REG_QVOQIDX_64, 0x0},
- {OP_WR_E1, QM_REG_VOQQMASK_0_LSB, 0xffff003f},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_15, 0x1010120},
- {OP_ZR_E1, QM_REG_VOQQMASK_0_MSB, 0x2},
- {OP_ZR_E1H, QM_REG_QVOQIDX_65, 0x4},
- {OP_WR_E1, QM_REG_VOQQMASK_1_MSB, 0xffff003f},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_16, 0x1010101},
- {OP_WR_E1, QM_REG_VOQQMASK_2_LSB, 0x100},
- {OP_WR_E1H, QM_REG_QVOQIDX_69, 0x0},
- {OP_WR_E1, QM_REG_VOQQMASK_2_MSB, 0x100},
- {OP_WR_E1H, QM_REG_QVOQIDX_70, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_71, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_72, 0x2},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_17, 0x8012004},
- {OP_WR_E1H, QM_REG_QVOQIDX_73, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_74, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_75, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_76, 0x5},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_18, 0x20081001},
- {OP_WR_E1H, QM_REG_QVOQIDX_77, 0x8},
- {OP_WR_E1H, QM_REG_QVOQIDX_78, 0x6},
- {OP_WR_E1H, QM_REG_QVOQIDX_79, 0x7},
- {OP_WR_E1H, QM_REG_QVOQIDX_80, 0x0},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_19, 0x1010120},
- {OP_ZR_E1H, QM_REG_QVOQIDX_81, 0x4},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_20, 0x1010101},
- {OP_WR_E1H, QM_REG_QVOQIDX_85, 0x0},
- {OP_WR_E1H, QM_REG_QVOQIDX_86, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_87, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_88, 0x2},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_21, 0x8012004},
- {OP_WR_E1H, QM_REG_QVOQIDX_89, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_90, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_91, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_92, 0x5},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_22, 0x20081001},
- {OP_WR_E1H, QM_REG_QVOQIDX_93, 0x8},
- {OP_WR_E1H, QM_REG_QVOQIDX_94, 0x6},
- {OP_WR_E1H, QM_REG_QVOQIDX_95, 0x7},
- {OP_WR_E1H, QM_REG_QVOQIDX_96, 0x1},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_23, 0x1010120},
- {OP_WR_E1H, QM_REG_QVOQIDX_97, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_98, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_99, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_100, 0x1},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_24, 0x1010101},
- {OP_WR_E1H, QM_REG_QVOQIDX_101, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_102, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_103, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_104, 0x2},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_25, 0x8012004},
- {OP_WR_E1H, QM_REG_QVOQIDX_105, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_106, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_107, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_108, 0x5},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_26, 0x20081001},
- {OP_WR_E1H, QM_REG_QVOQIDX_109, 0x8},
- {OP_WR_E1H, QM_REG_QVOQIDX_110, 0x6},
- {OP_WR_E1H, QM_REG_QVOQIDX_111, 0x7},
- {OP_WR_E1H, QM_REG_QVOQIDX_112, 0x1},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_27, 0x1010120},
- {OP_WR_E1H, QM_REG_QVOQIDX_113, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_114, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_115, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_116, 0x1},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_28, 0x1010101},
- {OP_WR_E1H, QM_REG_QVOQIDX_117, 0x1},
- {OP_WR_E1H, QM_REG_QVOQIDX_118, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_119, 0x4},
- {OP_WR_E1H, QM_REG_QVOQIDX_120, 0x2},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_29, 0x8012004},
- {OP_WR_E1H, QM_REG_QVOQIDX_121, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_122, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_123, 0x5},
- {OP_WR_E1H, QM_REG_QVOQIDX_124, 0x5},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_30, 0x20081001},
- {OP_WR_E1H, QM_REG_QVOQIDX_125, 0x8},
- {OP_WR_E1H, QM_REG_QVOQIDX_126, 0x6},
- {OP_WR_E1H, QM_REG_QVOQIDX_127, 0x7},
- {OP_WR_E1H, QM_REG_WRRWEIGHTS_31, 0x1010120},
- {OP_WR_E1H, QM_REG_VOQQMASK_0_LSB, 0x3f003f},
- {OP_WR_E1H, QM_REG_VOQQMASK_0_MSB, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_0_LSB_EXT_A, 0x3f003f},
- {OP_WR_E1H, QM_REG_VOQQMASK_0_MSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_1_LSB, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_1_MSB, 0x3f003f},
- {OP_WR_E1H, QM_REG_VOQQMASK_1_LSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_1_MSB_EXT_A, 0x3f003f},
- {OP_WR_E1H, QM_REG_VOQQMASK_2_LSB, 0x1000100},
- {OP_WR_E1H, QM_REG_VOQQMASK_2_MSB, 0x1000100},
- {OP_WR_E1H, QM_REG_VOQQMASK_2_LSB_EXT_A, 0x1000100},
- {OP_WR_E1H, QM_REG_VOQQMASK_2_MSB_EXT_A, 0x1000100},
- {OP_ZR, QM_REG_VOQQMASK_3_LSB, 0x2},
- {OP_WR_E1, QM_REG_VOQQMASK_4_LSB, 0xc0},
- {OP_WR_E1H, QM_REG_VOQQMASK_3_LSB_EXT_A, 0x0},
- {OP_WR_E1, QM_REG_VOQQMASK_4_MSB, 0xc0},
- {OP_WR_E1H, QM_REG_VOQQMASK_3_MSB_EXT_A, 0x0},
- {OP_WR_E1, QM_REG_VOQQMASK_5_LSB, 0x1e00},
- {OP_WR_E1H, QM_REG_VOQQMASK_4_LSB, 0xc000c0},
- {OP_WR_E1, QM_REG_VOQQMASK_5_MSB, 0x1e00},
- {OP_WR_E1H, QM_REG_VOQQMASK_4_MSB, 0xc000c0},
- {OP_WR_E1, QM_REG_VOQQMASK_6_LSB, 0x4000},
- {OP_WR_E1H, QM_REG_VOQQMASK_4_LSB_EXT_A, 0xc000c0},
- {OP_WR_E1, QM_REG_VOQQMASK_6_MSB, 0x4000},
- {OP_WR_E1H, QM_REG_VOQQMASK_4_MSB_EXT_A, 0xc000c0},
- {OP_WR_E1, QM_REG_VOQQMASK_7_LSB, 0x8000},
- {OP_WR_E1H, QM_REG_VOQQMASK_5_LSB, 0x1e001e00},
- {OP_WR_E1, QM_REG_VOQQMASK_7_MSB, 0x8000},
- {OP_WR_E1H, QM_REG_VOQQMASK_5_MSB, 0x1e001e00},
- {OP_WR_E1, QM_REG_VOQQMASK_8_LSB, 0x2000},
- {OP_WR_E1H, QM_REG_VOQQMASK_5_LSB_EXT_A, 0x1e001e00},
- {OP_WR_E1, QM_REG_VOQQMASK_8_MSB, 0x2000},
- {OP_WR_E1H, QM_REG_VOQQMASK_5_MSB_EXT_A, 0x1e001e00},
- {OP_ZR_E1, QM_REG_VOQQMASK_9_LSB, 0x7},
- {OP_WR_E1H, QM_REG_VOQQMASK_6_LSB, 0x40004000},
- {OP_WR_E1H, QM_REG_VOQQMASK_6_MSB, 0x40004000},
- {OP_WR_E1H, QM_REG_VOQQMASK_6_LSB_EXT_A, 0x40004000},
- {OP_WR_E1H, QM_REG_VOQQMASK_6_MSB_EXT_A, 0x40004000},
- {OP_WR_E1H, QM_REG_VOQQMASK_7_LSB, 0x80008000},
- {OP_WR_E1H, QM_REG_VOQQMASK_7_MSB, 0x80008000},
- {OP_WR_E1H, QM_REG_VOQQMASK_7_LSB_EXT_A, 0x80008000},
- {OP_WR_E1H, QM_REG_VOQQMASK_7_MSB_EXT_A, 0x80008000},
- {OP_WR_E1H, QM_REG_VOQQMASK_8_LSB, 0x20002000},
- {OP_WR_E1H, QM_REG_VOQQMASK_8_MSB, 0x20002000},
- {OP_WR_E1H, QM_REG_VOQQMASK_8_LSB_EXT_A, 0x20002000},
- {OP_WR_E1H, QM_REG_VOQQMASK_8_MSB_EXT_A, 0x20002000},
- {OP_ZR_E1H, QM_REG_VOQQMASK_9_LSB, 0x2},
- {OP_WR_E1H, QM_REG_VOQQMASK_9_LSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_9_MSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_10_LSB, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_10_MSB, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_10_LSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_10_MSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_11_LSB, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_11_MSB, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_11_LSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQQMASK_11_MSB_EXT_A, 0x0},
- {OP_WR_E1H, QM_REG_VOQPORT_0, 0x0},
- {OP_WR, QM_REG_VOQPORT_1, 0x1},
- {OP_ZR, QM_REG_VOQPORT_2, 0xa},
- {OP_WR, QM_REG_CMINTVOQMASK_0, 0xc08},
- {OP_WR, QM_REG_CMINTVOQMASK_1, 0x40},
- {OP_WR, QM_REG_CMINTVOQMASK_2, 0x100},
- {OP_WR, QM_REG_CMINTVOQMASK_3, 0x20},
- {OP_WR, QM_REG_CMINTVOQMASK_4, 0x17},
- {OP_WR, QM_REG_CMINTVOQMASK_5, 0x80},
- {OP_WR, QM_REG_CMINTVOQMASK_6, 0x200},
- {OP_WR, QM_REG_CMINTVOQMASK_7, 0x0},
- {OP_WR_E1, QM_REG_HWAEMPTYMASK_LSB, 0xffff01ff},
- {OP_WR_E1H, QM_REG_HWAEMPTYMASK_LSB, 0x1ff01ff},
- {OP_WR_E1, QM_REG_HWAEMPTYMASK_MSB, 0xffff01ff},
- {OP_WR_E1H, QM_REG_HWAEMPTYMASK_MSB, 0x1ff01ff},
- {OP_WR_E1H, QM_REG_HWAEMPTYMASK_LSB_EXT_A, 0x1ff01ff},
- {OP_WR_E1H, QM_REG_HWAEMPTYMASK_MSB_EXT_A, 0x1ff01ff},
- {OP_WR, QM_REG_ENBYPVOQMASK, 0x13},
- {OP_WR, QM_REG_VOQCREDITAFULLTHR, 0x13f},
- {OP_WR, QM_REG_VOQINITCREDIT_0, 0x140},
- {OP_WR, QM_REG_VOQINITCREDIT_1, 0x140},
- {OP_ZR, QM_REG_VOQINITCREDIT_2, 0x2},
- {OP_WR, QM_REG_VOQINITCREDIT_4, 0xc0},
- {OP_ZR, QM_REG_VOQINITCREDIT_5, 0x7},
- {OP_WR, QM_REG_TASKCRDCOST_0, 0x48},
- {OP_WR, QM_REG_TASKCRDCOST_1, 0x48},
- {OP_ZR, QM_REG_TASKCRDCOST_2, 0x2},
- {OP_WR, QM_REG_TASKCRDCOST_4, 0x48},
- {OP_ZR, QM_REG_TASKCRDCOST_5, 0x7},
- {OP_WR, QM_REG_BYTECRDINITVAL, 0x8000},
- {OP_WR, QM_REG_BYTECRDCOST, 0x25e4},
- {OP_WR, QM_REG_BYTECREDITAFULLTHR, 0x7fff},
- {OP_WR_E1, QM_REG_ENBYTECRD_LSB, 0x7},
- {OP_WR_E1H, QM_REG_ENBYTECRD_LSB, 0x70007},
- {OP_WR_E1, QM_REG_ENBYTECRD_MSB, 0x7},
- {OP_WR_E1H, QM_REG_ENBYTECRD_MSB, 0x70007},
- {OP_WR_E1H, QM_REG_ENBYTECRD_LSB_EXT_A, 0x70007},
- {OP_WR_E1H, QM_REG_ENBYTECRD_MSB_EXT_A, 0x70007},
- {OP_WR, QM_REG_BYTECRDPORT_LSB, 0x0},
- {OP_WR, QM_REG_BYTECRDPORT_MSB, 0xffffffff},
- {OP_WR_E1, QM_REG_FUNCNUMSEL_LSB, 0x0},
- {OP_WR_E1H, QM_REG_BYTECRDPORT_LSB_EXT_A, 0x0},
- {OP_WR_E1, QM_REG_FUNCNUMSEL_MSB, 0xffffffff},
- {OP_WR_E1H, QM_REG_BYTECRDPORT_MSB_EXT_A, 0xffffffff},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_0, 0x0},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_1, 0x2},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_2, 0x1},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_3, 0x3},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_4, 0x4},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_5, 0x6},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_6, 0x5},
- {OP_WR_E1H, QM_REG_PQ2PCIFUNC_7, 0x7},
- {OP_WR, QM_REG_CMINTEN, 0xff},
-#define QM_COMMON_END 1456
-#define PBF_COMMON_START 1456
- {OP_WR, PBF_REG_INIT, 0x1},
- {OP_WR, PBF_REG_INIT_P4, 0x1},
- {OP_WR, PBF_REG_MAC_LB_ENABLE, 0x1},
- {OP_WR, PBF_REG_IF_ENABLE_REG, 0x7fff},
- {OP_WR, PBF_REG_INIT_P4, 0x0},
- {OP_WR, PBF_REG_INIT, 0x0},
- {OP_WR, PBF_REG_DISABLE_NEW_TASK_PROC_P4, 0x0},
-#define PBF_COMMON_END 1463
-#define PBF_PORT0_START 1463
- {OP_WR, PBF_REG_INIT_P0, 0x1},
- {OP_WR, PBF_REG_MAC_IF0_ENABLE, 0x1},
- {OP_WR, PBF_REG_INIT_P0, 0x0},
- {OP_WR, PBF_REG_DISABLE_NEW_TASK_PROC_P0, 0x0},
-#define PBF_PORT0_END 1467
-#define PBF_PORT1_START 1467
- {OP_WR, PBF_REG_INIT_P1, 0x1},
- {OP_WR, PBF_REG_MAC_IF1_ENABLE, 0x1},
- {OP_WR, PBF_REG_INIT_P1, 0x0},
- {OP_WR, PBF_REG_DISABLE_NEW_TASK_PROC_P1, 0x0},
-#define PBF_PORT1_END 1471
-#define XCM_COMMON_START 1471
- {OP_WR, XCM_REG_XX_OVFL_EVNT_ID, 0x32},
- {OP_WR, XCM_REG_XQM_XCM_HDR_P, 0x3150020},
- {OP_WR, XCM_REG_XQM_XCM_HDR_S, 0x3150020},
- {OP_WR, XCM_REG_TM_XCM_HDR, 0x1000030},
- {OP_WR, XCM_REG_ERR_XCM_HDR, 0x8100000},
- {OP_WR, XCM_REG_ERR_EVNT_ID, 0x33},
- {OP_WR, XCM_REG_EXPR_EVNT_ID, 0x30},
- {OP_WR, XCM_REG_STOP_EVNT_ID, 0x31},
- {OP_WR, XCM_REG_STORM_WEIGHT, 0x3},
- {OP_WR, XCM_REG_TSEM_WEIGHT, 0x6},
- {OP_WR, XCM_REG_CSEM_WEIGHT, 0x3},
- {OP_WR, XCM_REG_USEM_WEIGHT, 0x3},
- {OP_WR, XCM_REG_DORQ_WEIGHT, 0x2},
- {OP_WR, XCM_REG_PBF_WEIGHT, 0x0},
- {OP_WR, XCM_REG_NIG0_WEIGHT, 0x2},
- {OP_WR, XCM_REG_CP_WEIGHT, 0x0},
- {OP_WR, XCM_REG_XSDM_WEIGHT, 0x6},
- {OP_WR, XCM_REG_XQM_P_WEIGHT, 0x4},
- {OP_WR, XCM_REG_XQM_S_WEIGHT, 0x2},
- {OP_WR, XCM_REG_TM_WEIGHT, 0x2},
- {OP_WR, XCM_REG_XCM_XQM_USE_Q, 0x1},
- {OP_WR, XCM_REG_XQM_BYP_ACT_UPD, 0x6},
- {OP_WR, XCM_REG_UNA_GT_NXT_Q, 0x0},
- {OP_WR, XCM_REG_AUX1_Q, 0x2},
- {OP_WR, XCM_REG_AUX_CNT_FLG_Q_19, 0x1},
- {OP_WR, XCM_REG_GR_ARB_TYPE, 0x1},
- {OP_WR, XCM_REG_GR_LD0_PR, 0x1},
- {OP_WR, XCM_REG_GR_LD1_PR, 0x2},
- {OP_WR, XCM_REG_CFC_INIT_CRD, 0x1},
- {OP_WR, XCM_REG_FIC0_INIT_CRD, 0x40},
- {OP_WR, XCM_REG_FIC1_INIT_CRD, 0x40},
- {OP_WR, XCM_REG_TM_INIT_CRD, 0x4},
- {OP_WR, XCM_REG_XQM_INIT_CRD, 0x20},
- {OP_WR, XCM_REG_XX_INIT_CRD, 0x2},
- {OP_WR_E1, XCM_REG_XX_MSG_NUM, 0x1f},
- {OP_WR_E1H, XCM_REG_XX_MSG_NUM, 0x20},
- {OP_ZR, XCM_REG_XX_TABLE, 0x12},
- {OP_SW_E1, XCM_REG_XX_DESCR_TABLE, 0x1f02d4},
- {OP_SW_E1H, XCM_REG_XX_DESCR_TABLE, 0x1f0329},
- {OP_WR, XCM_REG_N_SM_CTX_LD_0, 0xf},
- {OP_WR, XCM_REG_N_SM_CTX_LD_1, 0x7},
- {OP_WR, XCM_REG_N_SM_CTX_LD_2, 0xb},
- {OP_WR, XCM_REG_N_SM_CTX_LD_3, 0xe},
- {OP_ZR_E1, XCM_REG_N_SM_CTX_LD_4, 0x4},
- {OP_WR_E1H, XCM_REG_N_SM_CTX_LD_4, 0xe},
- {OP_ZR_E1H, XCM_REG_N_SM_CTX_LD_5, 0x3},
- {OP_WR, XCM_REG_XCM_REG0_SZ, 0x4},
- {OP_WR, XCM_REG_XCM_STORM0_IFEN, 0x1},
- {OP_WR, XCM_REG_XCM_STORM1_IFEN, 0x1},
- {OP_WR, XCM_REG_XCM_XQM_IFEN, 0x1},
- {OP_WR, XCM_REG_STORM_XCM_IFEN, 0x1},
- {OP_WR, XCM_REG_XQM_XCM_IFEN, 0x1},
- {OP_WR, XCM_REG_XSDM_IFEN, 0x1},
- {OP_WR, XCM_REG_TM_XCM_IFEN, 0x1},
- {OP_WR, XCM_REG_XCM_TM_IFEN, 0x1},
- {OP_WR, XCM_REG_TSEM_IFEN, 0x1},
- {OP_WR, XCM_REG_CSEM_IFEN, 0x1},
- {OP_WR, XCM_REG_USEM_IFEN, 0x1},
- {OP_WR, XCM_REG_DORQ_IFEN, 0x1},
- {OP_WR, XCM_REG_PBF_IFEN, 0x1},
- {OP_WR, XCM_REG_NIG0_IFEN, 0x1},
- {OP_WR, XCM_REG_NIG1_IFEN, 0x1},
- {OP_WR, XCM_REG_CDU_AG_WR_IFEN, 0x1},
- {OP_WR, XCM_REG_CDU_AG_RD_IFEN, 0x1},
- {OP_WR, XCM_REG_CDU_SM_WR_IFEN, 0x1},
- {OP_WR, XCM_REG_CDU_SM_RD_IFEN, 0x1},
- {OP_WR, XCM_REG_XCM_CFC_IFEN, 0x1},
-#define XCM_COMMON_END 1538
-#define XCM_PORT0_START 1538
- {OP_WR_E1, XCM_REG_GLB_DEL_ACK_TMR_VAL_0, 0xc8},
- {OP_WR_E1, XCM_REG_GLB_DEL_ACK_MAX_CNT_0, 0x2},
- {OP_WR_E1, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD00, 0x0},
- {OP_WR_E1, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD10, 0x0},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_CMD00, 0x2},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_CMD10, 0x2},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_UPD_VAL00, 0xff},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_UPD_VAL10, 0xff},
-#define XCM_PORT0_END 1546
-#define XCM_PORT1_START 1546
- {OP_WR_E1, XCM_REG_GLB_DEL_ACK_TMR_VAL_1, 0xc8},
- {OP_WR_E1, XCM_REG_GLB_DEL_ACK_MAX_CNT_1, 0x2},
- {OP_WR_E1, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD01, 0x0},
- {OP_WR_E1, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD11, 0x0},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_CMD01, 0x2},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_CMD11, 0x2},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_UPD_VAL01, 0xff},
- {OP_WR_E1, XCM_REG_WU_DA_CNT_UPD_VAL11, 0xff},
-#define XCM_PORT1_END 1554
-#define XCM_FUNC0_START 1554
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_0, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_0, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD00, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD10, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD00, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD10, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL00, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL10, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_0, 0x0},
-#define XCM_FUNC0_END 1563
-#define XCM_FUNC1_START 1563
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_1, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_1, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD01, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD11, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD01, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD11, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL01, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL11, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_1, 0x0},
-#define XCM_FUNC1_END 1572
-#define XCM_FUNC2_START 1572
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_0, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_0, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD00, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD10, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD00, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD10, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL00, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL10, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_0, 0x0},
-#define XCM_FUNC2_END 1581
-#define XCM_FUNC3_START 1581
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_1, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_1, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD01, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD11, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD01, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD11, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL01, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL11, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_1, 0x0},
-#define XCM_FUNC3_END 1590
-#define XCM_FUNC4_START 1590
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_0, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_0, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD00, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD10, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD00, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD10, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL00, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL10, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_0, 0x0},
-#define XCM_FUNC4_END 1599
-#define XCM_FUNC5_START 1599
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_1, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_1, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD01, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD11, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD01, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD11, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL01, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL11, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_1, 0x0},
-#define XCM_FUNC5_END 1608
-#define XCM_FUNC6_START 1608
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_0, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_0, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD00, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD10, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD00, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD10, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL00, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL10, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_0, 0x0},
-#define XCM_FUNC6_END 1617
-#define XCM_FUNC7_START 1617
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_TMR_VAL_1, 0xc8},
- {OP_WR_E1H, XCM_REG_GLB_DEL_ACK_MAX_CNT_1, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD01, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_SET_TMR_CNT_FLG_CMD11, 0x0},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD01, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_CMD11, 0x2},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL01, 0xff},
- {OP_WR_E1H, XCM_REG_WU_DA_CNT_UPD_VAL11, 0xff},
- {OP_WR_E1H, XCM_REG_PHYS_QNUM3_1, 0x0},
-#define XCM_FUNC7_END 1626
-#define XSEM_COMMON_START 1626
- {OP_RD, XSEM_REG_MSG_NUM_FIC0, 0x0},
- {OP_RD, XSEM_REG_MSG_NUM_FIC1, 0x0},
- {OP_RD, XSEM_REG_MSG_NUM_FOC0, 0x0},
- {OP_RD, XSEM_REG_MSG_NUM_FOC1, 0x0},
- {OP_RD, XSEM_REG_MSG_NUM_FOC2, 0x0},
- {OP_RD, XSEM_REG_MSG_NUM_FOC3, 0x0},
- {OP_WR, XSEM_REG_ARB_ELEMENT0, 0x1},
- {OP_WR, XSEM_REG_ARB_ELEMENT1, 0x2},
- {OP_WR, XSEM_REG_ARB_ELEMENT2, 0x3},
- {OP_WR, XSEM_REG_ARB_ELEMENT3, 0x0},
- {OP_WR, XSEM_REG_ARB_ELEMENT4, 0x4},
- {OP_WR, XSEM_REG_ARB_CYCLE_SIZE, 0x1},
- {OP_WR, XSEM_REG_TS_0_AS, 0x0},
- {OP_WR, XSEM_REG_TS_1_AS, 0x1},
- {OP_WR, XSEM_REG_TS_2_AS, 0x4},
- {OP_WR, XSEM_REG_TS_3_AS, 0x0},
- {OP_WR, XSEM_REG_TS_4_AS, 0x1},
- {OP_WR, XSEM_REG_TS_5_AS, 0x3},
- {OP_WR, XSEM_REG_TS_6_AS, 0x0},
- {OP_WR, XSEM_REG_TS_7_AS, 0x1},
- {OP_WR, XSEM_REG_TS_8_AS, 0x4},
- {OP_WR, XSEM_REG_TS_9_AS, 0x0},
- {OP_WR, XSEM_REG_TS_10_AS, 0x1},
- {OP_WR, XSEM_REG_TS_11_AS, 0x3},
- {OP_WR, XSEM_REG_TS_12_AS, 0x0},
- {OP_WR, XSEM_REG_TS_13_AS, 0x1},
- {OP_WR, XSEM_REG_TS_14_AS, 0x4},
- {OP_WR, XSEM_REG_TS_15_AS, 0x0},
- {OP_WR, XSEM_REG_TS_16_AS, 0x4},
- {OP_WR, XSEM_REG_TS_17_AS, 0x3},
- {OP_ZR, XSEM_REG_TS_18_AS, 0x2},
- {OP_WR, XSEM_REG_ENABLE_IN, 0x3fff},
- {OP_WR, XSEM_REG_ENABLE_OUT, 0x3ff},
- {OP_WR, XSEM_REG_FIC0_DISABLE, 0x0},
- {OP_WR, XSEM_REG_FIC1_DISABLE, 0x0},
- {OP_WR, XSEM_REG_PAS_DISABLE, 0x0},
- {OP_WR, XSEM_REG_THREADS_LIST, 0xffff},
- {OP_ZR, XSEM_REG_PASSIVE_BUFFER, 0x800},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x18bc0, 0x1},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x18000, 0x0},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x18040, 0x18},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x18080, 0xc},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x180c0, 0x66},
- {OP_WR_ASIC, XSEM_REG_FAST_MEMORY + 0x18300, 0x7a120},
- {OP_WR_EMUL, XSEM_REG_FAST_MEMORY + 0x18300, 0x138},
- {OP_WR_FPGA, XSEM_REG_FAST_MEMORY + 0x18300, 0x1388},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x183c0, 0x1f4},
- {OP_WR_ASIC, XSEM_REG_FAST_MEMORY + 0x18340, 0x1f4},
- {OP_WR_EMUL, XSEM_REG_FAST_MEMORY + 0x18340, 0x0},
- {OP_WR_FPGA, XSEM_REG_FAST_MEMORY + 0x18340, 0x5},
- {OP_WR_EMUL, XSEM_REG_FAST_MEMORY + 0x18380, 0x4c4b4},
- {OP_WR_ASIC, XSEM_REG_FAST_MEMORY + 0x18380, 0x1dcd6500},
- {OP_WR_EMUL_E1H, XSEM_REG_FAST_MEMORY + 0x11480, 0x0},
- {OP_WR_FPGA, XSEM_REG_FAST_MEMORY + 0x18380, 0x4c4b40},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3d60, 0x4},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x11480, 0x1},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3d60 + 0x10, 0x202f3},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x29c8, 0x4},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3000, 0x48},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x29c8 + 0x10, 0x20348},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x1020, 0xc8},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2080, 0x48},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x1000, 0x2},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x9020, 0xc8},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3128, 0x8e},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x9000, 0x2},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x3368, 0x0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x21a8, 0x86},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3370, 0x202f5},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2000, 0x20},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3b90, 0x402f7},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x23c8, 0x0},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3e20, 0x202fb},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x23d0, 0x2034a},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x1518, 0x1},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2498, 0x4034c},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x1830, 0x0},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x2c20, 0x0},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x1838, 0x0},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x2c10, 0x0},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x1820, 0x202fd},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2c08, 0x20350},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x4ac0, 0x2},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x3010, 0x1},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x4b00, 0x4},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x4040, 0x10},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x1f48, 0x202ff},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x4000, 0x100352},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x6ac0, 0x2},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x6b00, 0x4},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x8408, 0x20362},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x10800, 0x0},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x10c00, 0x100301},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x10c00, 0x100364},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x10800, 0x1000000},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x10c40, 0x80311},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x10c40, 0x80374},
- {OP_WR, XSEM_REG_FAST_MEMORY + 0x10800, 0x2000000},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x10c60, 0x80319},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x10c60, 0x8037c},
- {OP_ZP_E1, XSEM_REG_INT_TABLE, 0xb50000},
- {OP_ZP_E1H, XSEM_REG_INT_TABLE, 0xbd0000},
- {OP_WR_64_E1, XSEM_REG_INT_TABLE + 0x368, 0x130321},
- {OP_WR_64_E1H, XSEM_REG_INT_TABLE + 0x3a8, 0xb0384},
- {OP_ZP_E1, XSEM_REG_PRAM, 0x33660000},
- {OP_ZP_E1H, XSEM_REG_PRAM, 0x34060000},
- {OP_ZP_E1, XSEM_REG_PRAM + 0x8000, 0x38b30cda},
- {OP_ZP_E1H, XSEM_REG_PRAM + 0x8000, 0x37960d02},
- {OP_ZP_E1, XSEM_REG_PRAM + 0x10000, 0x3bb11b07},
- {OP_ZP_E1H, XSEM_REG_PRAM + 0x10000, 0x3bc31ae8},
- {OP_ZP_E1, XSEM_REG_PRAM + 0x18000, 0x2a2629f4},
- {OP_ZP_E1H, XSEM_REG_PRAM + 0x18000, 0x382629d9},
- {OP_WR_64_E1, XSEM_REG_PRAM + 0x1d6c0, 0x45280323},
- {OP_ZP_E1H, XSEM_REG_PRAM + 0x20000, 0x124537e3},
- {OP_WR_64_E1H, XSEM_REG_PRAM + 0x22220, 0x3bbc0386},
-#define XSEM_COMMON_END 1741
-#define XSEM_PORT0_START 1741
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3ba0, 0x14},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0xc000, 0xfc},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3c40, 0x24},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x24a8, 0x14},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x1400, 0xa},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2548, 0x24},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x1450, 0x6},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2668, 0x24},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3378, 0xfc},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2788, 0x24},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x3b58, 0x0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x28a8, 0x24},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3d78, 0x20325},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0xa000, 0x28},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3d88, 0x100327},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0xa140, 0xc},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x1500, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x29e0, 0x20388},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x1508, 0x1},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x3000, 0x1},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5020, 0x2},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5030, 0x2},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5000, 0x2},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5010, 0x2},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x5040, 0x0},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x5208, 0x1},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x5048, 0xe},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x6ac8, 0x2038a},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x50b8, 0x1},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x6b10, 0x42},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x4ac8, 0x20337},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x6d20, 0x4},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x4b10, 0x42},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x4d20, 0x4},
-#define XSEM_PORT0_END 1775
-#define XSEM_PORT1_START 1775
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3bf0, 0x14},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0xc3f0, 0xfc},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3cd0, 0x24},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x24f8, 0x14},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x1428, 0xa},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x25d8, 0x24},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x1468, 0x6},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x26f8, 0x24},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x3768, 0xfc},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2818, 0x24},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x3b5c, 0x0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x2938, 0x24},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3d80, 0x20339},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0xa0a0, 0x28},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x3dc8, 0x10033b},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0xa170, 0xc},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x1504, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x29e8, 0x2038c},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x150c, 0x1},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x3004, 0x1},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5028, 0x2},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5038, 0x2},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5008, 0x2},
- {OP_ZR, XSEM_REG_FAST_MEMORY + 0x5018, 0x2},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x5044, 0x0},
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0x520c, 0x1},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x5080, 0xe},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x6ad0, 0x2038e},
- {OP_WR_E1, XSEM_REG_FAST_MEMORY + 0x50bc, 0x1},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x6c18, 0x42},
- {OP_SW_E1, XSEM_REG_FAST_MEMORY + 0x4ad0, 0x2034b},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x6d30, 0x4},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x4c18, 0x42},
- {OP_ZR_E1, XSEM_REG_FAST_MEMORY + 0x4d30, 0x4},
-#define XSEM_PORT1_END 1809
-#define XSEM_FUNC0_START 1809
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7e0, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x29f0, 0x100390},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x5048, 0xe},
-#define XSEM_FUNC0_END 1812
-#define XSEM_FUNC1_START 1812
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7e4, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2a30, 0x1003a0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x5080, 0xe},
-#define XSEM_FUNC1_END 1815
-#define XSEM_FUNC2_START 1815
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7e8, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2a70, 0x1003b0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x50b8, 0xe},
-#define XSEM_FUNC2_END 1818
-#define XSEM_FUNC3_START 1818
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7ec, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2ab0, 0x1003c0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x50f0, 0xe},
-#define XSEM_FUNC3_END 1821
-#define XSEM_FUNC4_START 1821
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7f0, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2af0, 0x1003d0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x5128, 0xe},
-#define XSEM_FUNC4_END 1824
-#define XSEM_FUNC5_START 1824
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7f4, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2b30, 0x1003e0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x5160, 0xe},
-#define XSEM_FUNC5_END 1827
-#define XSEM_FUNC6_START 1827
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7f8, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2b70, 0x1003f0},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x5198, 0xe},
-#define XSEM_FUNC6_END 1830
-#define XSEM_FUNC7_START 1830
- {OP_WR_E1H, XSEM_REG_FAST_MEMORY + 0xc7fc, 0x0},
- {OP_SW_E1H, XSEM_REG_FAST_MEMORY + 0x2bb0, 0x100400},
- {OP_ZR_E1H, XSEM_REG_FAST_MEMORY + 0x51d0, 0xe},
-#define XSEM_FUNC7_END 1833
-#define CDU_COMMON_START 1833
- {OP_WR, CDU_REG_CDU_CONTROL0, 0x1},
- {OP_WR_E1H, CDU_REG_MF_MODE, 0x1},
- {OP_WR, CDU_REG_CDU_CHK_MASK0, 0x3d000},
- {OP_WR, CDU_REG_CDU_CHK_MASK1, 0x3d},
- {OP_WB_E1, CDU_REG_L1TT, 0x200034d},
- {OP_WB_E1H, CDU_REG_L1TT, 0x2000410},
- {OP_WB_E1, CDU_REG_MATT, 0x20054d},
- {OP_WB_E1H, CDU_REG_MATT, 0x280610},
- {OP_ZR_E1, CDU_REG_MATT + 0x80, 0x2},
- {OP_WB_E1, CDU_REG_MATT + 0x88, 0x6056d},
- {OP_ZR, CDU_REG_MATT + 0xa0, 0x18},
-#define CDU_COMMON_END 1844
-#define DMAE_COMMON_START 1844
- {OP_ZR, DMAE_REG_CMD_MEM, 0xe0},
- {OP_WR, DMAE_REG_CRC16C_INIT, 0x0},
- {OP_WR, DMAE_REG_CRC16T10_INIT, 0x1},
- {OP_WR_E1, DMAE_REG_PXP_REQ_INIT_CRD, 0x1},
- {OP_WR_E1H, DMAE_REG_PXP_REQ_INIT_CRD, 0x2},
- {OP_WR, DMAE_REG_PCI_IFEN, 0x1},
- {OP_WR, DMAE_REG_GRC_IFEN, 0x1},
-#define DMAE_COMMON_END 1851
-#define PXP_COMMON_START 1851
- {OP_WB_E1, PXP_REG_HST_INBOUND_INT + 0x400, 0x50573},
- {OP_WB_E1H, PXP_REG_HST_INBOUND_INT + 0x400, 0x50638},
- {OP_WB_E1, PXP_REG_HST_INBOUND_INT + 0x420, 0x50578},
- {OP_WB_E1H, PXP_REG_HST_INBOUND_INT, 0x5063d},
- {OP_WB_E1, PXP_REG_HST_INBOUND_INT, 0x5057d},
- {OP_WB_E1H, PXP_REG_HST_INBOUND_INT + 0x20, 0x50642},
-#define PXP_COMMON_END 1857
-#define CFC_COMMON_START 1857
- {OP_ZR_E1H, CFC_REG_LINK_LIST, 0x100},
- {OP_WR, CFC_REG_CONTROL0, 0x10},
- {OP_WR, CFC_REG_DISABLE_ON_ERROR, 0x3fff},
- {OP_WR, CFC_REG_INTERFACES, 0x280000},
- {OP_WR, CFC_REG_LCREQ_WEIGHTS, 0x84924a},
- {OP_WR, CFC_REG_INTERFACES, 0x0},
-#define CFC_COMMON_END 1863
-#define HC_COMMON_START 1863
- {OP_ZR_E1, HC_REG_USTORM_ADDR_FOR_COALESCE, 0x4},
-#define HC_COMMON_END 1864
-#define HC_PORT0_START 1864
- {OP_WR_E1, HC_REG_CONFIG_0, 0x1080},
- {OP_ZR_E1, HC_REG_UC_RAM_ADDR_0, 0x2},
- {OP_WR_E1, HC_REG_ATTN_NUM_P0, 0x10},
- {OP_WR_E1, HC_REG_LEADING_EDGE_0, 0xffff},
- {OP_WR_E1, HC_REG_TRAILING_EDGE_0, 0xffff},
- {OP_WR_E1, HC_REG_AGG_INT_0, 0x0},
- {OP_WR_E1, HC_REG_ATTN_IDX, 0x0},
- {OP_ZR_E1, HC_REG_ATTN_BIT, 0x2},
- {OP_WR_E1, HC_REG_VQID_0, 0x2b5},
- {OP_WR_E1, HC_REG_PCI_CONFIG_0, 0x0},
- {OP_ZR_E1, HC_REG_P0_PROD_CONS, 0x4a},
- {OP_WR_E1, HC_REG_INT_MASK, 0x1ffff},
- {OP_ZR_E1, HC_REG_PBA_COMMAND, 0x2},
- {OP_WR_E1, HC_REG_CONFIG_0, 0x1a80},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS, 0x24},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x120, 0x4a},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x370, 0x4a},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x5c0, 0x4a},
-#define HC_PORT0_END 1882
-#define HC_PORT1_START 1882
- {OP_WR_E1, HC_REG_CONFIG_1, 0x1080},
- {OP_ZR_E1, HC_REG_UC_RAM_ADDR_1, 0x2},
- {OP_WR_E1, HC_REG_ATTN_NUM_P1, 0x10},
- {OP_WR_E1, HC_REG_LEADING_EDGE_1, 0xffff},
- {OP_WR_E1, HC_REG_TRAILING_EDGE_1, 0xffff},
- {OP_WR_E1, HC_REG_AGG_INT_1, 0x0},
- {OP_WR_E1, HC_REG_ATTN_IDX + 0x4, 0x0},
- {OP_ZR_E1, HC_REG_ATTN_BIT + 0x8, 0x2},
- {OP_WR_E1, HC_REG_VQID_1, 0x2b5},
- {OP_WR_E1, HC_REG_PCI_CONFIG_1, 0x0},
- {OP_ZR_E1, HC_REG_P1_PROD_CONS, 0x4a},
- {OP_WR_E1, HC_REG_INT_MASK + 0x4, 0x1ffff},
- {OP_ZR_E1, HC_REG_PBA_COMMAND + 0x8, 0x2},
- {OP_WR_E1, HC_REG_CONFIG_1, 0x1a80},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x90, 0x24},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x248, 0x4a},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x498, 0x4a},
- {OP_ZR_E1, HC_REG_STATISTIC_COUNTERS + 0x6e8, 0x4a},
-#define HC_PORT1_END 1900
-#define HC_FUNC0_START 1900
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P0, 0x0},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P0, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT, 0x2},
- {OP_WR_E1H, HC_REG_VQID_0, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_0, 0x0},
- {OP_ZR_E1H, HC_REG_P0_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x120, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x370, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x5c0, 0x4a},
-#define HC_FUNC0_END 1915
-#define HC_FUNC1_START 1915
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P1, 0x1},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P1, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX + 0x4, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_VQID_1, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_1, 0x0},
- {OP_ZR_E1H, HC_REG_P1_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK + 0x4, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x90, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x248, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x498, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x6e8, 0x4a},
-#define HC_FUNC1_END 1930
-#define HC_FUNC2_START 1930
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P0, 0x2},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P0, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT, 0x2},
- {OP_WR_E1H, HC_REG_VQID_0, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_0, 0x0},
- {OP_ZR_E1H, HC_REG_P0_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x120, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x370, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x5c0, 0x4a},
-#define HC_FUNC2_END 1945
-#define HC_FUNC3_START 1945
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P1, 0x3},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P1, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX + 0x4, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_VQID_1, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_1, 0x0},
- {OP_ZR_E1H, HC_REG_P1_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK + 0x4, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x90, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x248, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x498, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x6e8, 0x4a},
-#define HC_FUNC3_END 1960
-#define HC_FUNC4_START 1960
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P0, 0x4},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P0, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT, 0x2},
- {OP_WR_E1H, HC_REG_VQID_0, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_0, 0x0},
- {OP_ZR_E1H, HC_REG_P0_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x120, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x370, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x5c0, 0x4a},
-#define HC_FUNC4_END 1975
-#define HC_FUNC5_START 1975
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P1, 0x5},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P1, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX + 0x4, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_VQID_1, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_1, 0x0},
- {OP_ZR_E1H, HC_REG_P1_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK + 0x4, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x90, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x248, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x498, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x6e8, 0x4a},
-#define HC_FUNC5_END 1990
-#define HC_FUNC6_START 1990
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P0, 0x6},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P0, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT, 0x2},
- {OP_WR_E1H, HC_REG_VQID_0, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_0, 0x0},
- {OP_ZR_E1H, HC_REG_P0_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_0, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x120, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x370, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x5c0, 0x4a},
-#define HC_FUNC6_END 2005
-#define HC_FUNC7_START 2005
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1080},
- {OP_WR_E1H, HC_REG_FUNC_NUM_P1, 0x7},
- {OP_WR_E1H, HC_REG_ATTN_NUM_P1, 0x10},
- {OP_WR_E1H, HC_REG_ATTN_IDX + 0x4, 0x0},
- {OP_ZR_E1H, HC_REG_ATTN_BIT + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_VQID_1, 0x2b5},
- {OP_WR_E1H, HC_REG_PCI_CONFIG_1, 0x0},
- {OP_ZR_E1H, HC_REG_P1_PROD_CONS, 0x4a},
- {OP_WR_E1H, HC_REG_INT_MASK + 0x4, 0x1ffff},
- {OP_ZR_E1H, HC_REG_PBA_COMMAND + 0x8, 0x2},
- {OP_WR_E1H, HC_REG_CONFIG_1, 0x1a80},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x90, 0x24},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x248, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x498, 0x4a},
- {OP_ZR_E1H, HC_REG_STATISTIC_COUNTERS + 0x6e8, 0x4a},
-#define HC_FUNC7_END 2020
-#define PXP2_COMMON_START 2020
- {OP_WR_E1H, PXP2_REG_RQ_DRAM_ALIGN, 0x1},
- {OP_WR, PXP2_REG_PGL_CONTROL0, 0xe38340},
- {OP_WR, PXP2_REG_PGL_CONTROL1, 0x3c10},
- {OP_WR_E1H, PXP2_REG_RQ_ELT_DISABLE, 0x1},
- {OP_WR_E1H, PXP2_REG_WR_REV_MODE, 0x0},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_0, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_1, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_2, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_3, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_4, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_5, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_6, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_TSDM_7, 0xffffffff},
- {OP_WR_E1, PXP2_REG_PGL_INT_USDM_1, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_USDM_2, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_USDM_3, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_USDM_4, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_USDM_5, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_USDM_6, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_USDM_7, 0xffffffff},
- {OP_WR_E1H, PXP2_REG_PGL_INT_XSDM_1, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_XSDM_2, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_XSDM_3, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_XSDM_4, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_XSDM_5, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_XSDM_6, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_XSDM_7, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_0, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_1, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_2, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_3, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_4, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_5, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_6, 0xffffffff},
- {OP_WR, PXP2_REG_PGL_INT_CSDM_7, 0xffffffff},
- {OP_WR_E1, PXP2_REG_PGL_INT_XSDM_0, 0xffff3330},
- {OP_WR_E1H, PXP2_REG_PGL_INT_XSDM_0, 0xff802000},
- {OP_WR_E1, PXP2_REG_PGL_INT_XSDM_1, 0xffff3340},
- {OP_WR_E1H, PXP2_REG_PGL_INT_USDM_0, 0xf0005000},
- {OP_WR_E1, PXP2_REG_PGL_INT_USDM_0, 0xf0003000},
- {OP_WR_E1H, PXP2_REG_PGL_INT_USDM_1, 0xf0008000},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ6, 0x8},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ9, 0x8},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ10, 0x8},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ11, 0x2},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ17, 0x4},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ18, 0x5},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ19, 0x4},
- {OP_WR, PXP2_REG_RD_MAX_BLKS_VQ22, 0x0},
- {OP_WR, PXP2_REG_RD_START_INIT, 0x1},
- {OP_WR, PXP2_REG_WR_DMAE_TH, 0x3f},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD0, 0x40},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD1, 0x1808},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD2, 0x803},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD3, 0x803},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD4, 0x40},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD5, 0x3},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD6, 0x803},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD7, 0x803},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD8, 0x803},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD9, 0x10003},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD10, 0x803},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD11, 0x803},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD12, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD13, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD14, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD15, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD16, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD17, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD18, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD19, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD20, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD22, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD23, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD24, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD25, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD26, 0x3},
- {OP_WR, PXP2_REG_RQ_BW_RD_ADD27, 0x3},
- {OP_WR, PXP2_REG_PSWRQ_BW_ADD28, 0x2403},
- {OP_WR, PXP2_REG_RQ_BW_WR_ADD29, 0x2f},
- {OP_WR, PXP2_REG_RQ_BW_WR_ADD30, 0x9},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND0, 0x19},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB1, 0x184},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB2, 0x183},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB3, 0x306},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND4, 0x19},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND5, 0x6},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB6, 0x306},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB7, 0x306},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB8, 0x306},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB9, 0xc86},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB10, 0x306},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB11, 0x306},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND12, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND13, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND14, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND15, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND16, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND17, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND18, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND19, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND20, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND22, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND23, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND24, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND25, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND26, 0x6},
- {OP_WR, PXP2_REG_RQ_BW_RD_UBOUND27, 0x6},
- {OP_WR, PXP2_REG_PSWRQ_BW_UB28, 0x306},
- {OP_WR, PXP2_REG_RQ_BW_WR_UBOUND29, 0x13},
- {OP_WR, PXP2_REG_RQ_BW_WR_UBOUND30, 0x6},
- {OP_WR, PXP2_REG_PSWRQ_BW_L1, 0x1004},
- {OP_WR, PXP2_REG_PSWRQ_BW_L2, 0x1004},
- {OP_WR, PXP2_REG_PSWRQ_BW_RD, 0x106440},
- {OP_WR, PXP2_REG_PSWRQ_BW_WR, 0x106440},
- {OP_WR_E1H, PXP2_REG_RQ_ILT_MODE, 0x1},
- {OP_WR, PXP2_REG_RQ_RBC_DONE, 0x1},
-#define PXP2_COMMON_END 2137
-#define MISC_AEU_COMMON_START 2137
- {OP_ZR, MISC_REG_AEU_GENERAL_ATTN_0, 0x16},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE1_NIG_0, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE2_NIG_0, 0x55555555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE3_NIG_0, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_NIG_0, 0xf0000000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE1_PXP_0, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE2_PXP_0, 0x55555555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE3_PXP_0, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_PXP_0, 0xf0000000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE1_NIG_1, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE2_NIG_1, 0x55555555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE3_NIG_1, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_NIG_1, 0xf0000000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE1_PXP_1, 0x0},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE2_PXP_1, 0x10000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE3_PXP_1, 0x5014},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_PXP_1, 0x0},
- {OP_WR_E1H, MISC_REG_AEU_CLR_LATCH_SIGNAL, 0xc00},
- {OP_WR_E1H, MISC_REG_AEU_GENERAL_MASK, 0x3},
-#define MISC_AEU_COMMON_END 2156
-#define MISC_AEU_PORT0_START 2156
- {OP_WR_E1, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0, 0xbf5c0000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0, 0xff5c0000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE2_FUNC_0_OUT_0, 0xfff51fef},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE2_FUNC_0_OUT_0, 0xfff55fff},
- {OP_WR, MISC_REG_AEU_ENABLE3_FUNC_0_OUT_0, 0xffff},
- {OP_WR_E1, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_0, 0x500003e0},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_0, 0xf00003e0},
- {OP_WR, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1, 0x0},
- {OP_WR, MISC_REG_AEU_ENABLE2_FUNC_0_OUT_1, 0xa000},
- {OP_ZR, MISC_REG_AEU_ENABLE3_FUNC_0_OUT_1, 0x5},
- {OP_WR, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_2, 0xfe00000},
- {OP_ZR_E1, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_3, 0x14},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_3, 0x7},
- {OP_WR_E1, MISC_REG_AEU_ENABLE1_NIG_0, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_4, 0x400},
- {OP_WR_E1, MISC_REG_AEU_ENABLE2_NIG_0, 0x55555555},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_5, 0x3},
- {OP_WR_E1, MISC_REG_AEU_ENABLE3_NIG_0, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_5, 0x1000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE4_NIG_0, 0x0},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_6, 0x3},
- {OP_WR_E1, MISC_REG_AEU_ENABLE1_PXP_0, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_6, 0x4000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE2_PXP_0, 0x55555555},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_7, 0x3},
- {OP_WR_E1, MISC_REG_AEU_ENABLE3_PXP_0, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_0_OUT_7, 0x10000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE4_PXP_0, 0x0},
- {OP_ZR_E1H, MISC_REG_AEU_INVERTER_1_FUNC_0, 0x4},
- {OP_WR_E1, MISC_REG_AEU_INVERTER_1_FUNC_0, 0x0},
- {OP_ZR_E1, MISC_REG_AEU_INVERTER_2_FUNC_0, 0x3},
- {OP_WR_E1, MISC_REG_AEU_MASK_ATTN_FUNC_0, 0x7},
-#define MISC_AEU_PORT0_END 2188
-#define MISC_AEU_PORT1_START 2188
- {OP_WR_E1, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0, 0xbf5c0000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0, 0xff5c0000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE2_FUNC_1_OUT_0, 0xfff51fef},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE2_FUNC_1_OUT_0, 0xfff55fff},
- {OP_WR, MISC_REG_AEU_ENABLE3_FUNC_1_OUT_0, 0xffff},
- {OP_WR_E1, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_0, 0x500003e0},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_0, 0xf00003e0},
- {OP_WR, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_1, 0x0},
- {OP_WR, MISC_REG_AEU_ENABLE2_FUNC_1_OUT_1, 0xa000},
- {OP_ZR, MISC_REG_AEU_ENABLE3_FUNC_1_OUT_1, 0x5},
- {OP_WR, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_2, 0xfe00000},
- {OP_ZR_E1, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_3, 0x14},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_3, 0x7},
- {OP_WR_E1, MISC_REG_AEU_ENABLE1_NIG_1, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_4, 0x800},
- {OP_WR_E1, MISC_REG_AEU_ENABLE2_NIG_1, 0x55555555},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_5, 0x3},
- {OP_WR_E1, MISC_REG_AEU_ENABLE3_NIG_1, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_5, 0x2000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE4_NIG_1, 0x0},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_6, 0x3},
- {OP_WR_E1, MISC_REG_AEU_ENABLE1_PXP_1, 0x55540000},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_6, 0x8000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE2_PXP_1, 0x55555555},
- {OP_ZR_E1H, MISC_REG_AEU_ENABLE1_FUNC_1_OUT_7, 0x3},
- {OP_WR_E1, MISC_REG_AEU_ENABLE3_PXP_1, 0x5555},
- {OP_WR_E1H, MISC_REG_AEU_ENABLE4_FUNC_1_OUT_7, 0x20000},
- {OP_WR_E1, MISC_REG_AEU_ENABLE4_PXP_1, 0x0},
- {OP_ZR_E1H, MISC_REG_AEU_INVERTER_1_FUNC_1, 0x4},
- {OP_WR_E1, MISC_REG_AEU_INVERTER_1_FUNC_1, 0x0},
- {OP_ZR_E1, MISC_REG_AEU_INVERTER_2_FUNC_1, 0x3},
- {OP_WR_E1, MISC_REG_AEU_MASK_ATTN_FUNC_1, 0x7},
-#define MISC_AEU_PORT1_END 2220
-
-};
-
-static const u32 init_data_e1[] = {
- 0x00010000, 0x000204c0, 0x00030980, 0x00040e40, 0x00051300, 0x000617c0,
- 0x00071c80, 0x00082140, 0x00092600, 0x000a2ac0, 0x000b2f80, 0x000c3440,
- 0x000d3900, 0x000e3dc0, 0x000f4280, 0x00104740, 0x00114c00, 0x001250c0,
- 0x00135580, 0x00145a40, 0x00155f00, 0x001663c0, 0x00176880, 0x00186d40,
- 0x00197200, 0x001a76c0, 0x001b7b80, 0x001c8040, 0x001d8500, 0x001e89c0,
- 0x001f8e80, 0x00209340, 0x00002000, 0x00004000, 0x00006000, 0x00008000,
- 0x0000a000, 0x0000c000, 0x0000e000, 0x00010000, 0x00012000, 0x00014000,
- 0x00016000, 0x00018000, 0x0001a000, 0x0001c000, 0x0001e000, 0x00020000,
- 0x00022000, 0x00024000, 0x00026000, 0x00028000, 0x0002a000, 0x0002c000,
- 0x0002e000, 0x00030000, 0x00032000, 0x00034000, 0x00036000, 0x00038000,
- 0x0003a000, 0x0003c000, 0x0003e000, 0x00040000, 0x00042000, 0x00044000,
- 0x00046000, 0x00048000, 0x0004a000, 0x0004c000, 0x0004e000, 0x00050000,
- 0x00052000, 0x00054000, 0x00056000, 0x00058000, 0x0005a000, 0x0005c000,
- 0x0005e000, 0x00060000, 0x00062000, 0x00064000, 0x00066000, 0x00068000,
- 0x0006a000, 0x0006c000, 0x0006e000, 0x00070000, 0x00072000, 0x00074000,
- 0x00076000, 0x00078000, 0x0007a000, 0x0007c000, 0x0007e000, 0x00080000,
- 0x00082000, 0x00084000, 0x00086000, 0x00088000, 0x0008a000, 0x0008c000,
- 0x0008e000, 0x00090000, 0x00092000, 0x00094000, 0x00096000, 0x00098000,
- 0x0009a000, 0x0009c000, 0x0009e000, 0x000a0000, 0x000a2000, 0x000a4000,
- 0x000a6000, 0x000a8000, 0x000aa000, 0x000ac000, 0x000ae000, 0x000b0000,
- 0x000b2000, 0x000b4000, 0x000b6000, 0x000b8000, 0x000ba000, 0x000bc000,
- 0x000be000, 0x000c0000, 0x000c2000, 0x000c4000, 0x000c6000, 0x000c8000,
- 0x000ca000, 0x000cc000, 0x000ce000, 0x000d0000, 0x000d2000, 0x000d4000,
- 0x000d6000, 0x000d8000, 0x000da000, 0x000dc000, 0x000de000, 0x000e0000,
- 0x000e2000, 0x000e4000, 0x000e6000, 0x000e8000, 0x000ea000, 0x000ec000,
- 0x000ee000, 0x000f0000, 0x000f2000, 0x000f4000, 0x000f6000, 0x000f8000,
- 0x000fa000, 0x000fc000, 0x000fe000, 0x00100000, 0x00102000, 0x00104000,
- 0x00106000, 0x00108000, 0x0010a000, 0x0010c000, 0x0010e000, 0x00110000,
- 0x00112000, 0x00114000, 0x00116000, 0x00118000, 0x0011a000, 0x0011c000,
- 0x0011e000, 0x00120000, 0x00122000, 0x00124000, 0x00126000, 0x00128000,
- 0x0012a000, 0x0012c000, 0x0012e000, 0x00130000, 0x00132000, 0x00134000,
- 0x00136000, 0x00138000, 0x0013a000, 0x0013c000, 0x0013e000, 0x00140000,
- 0x00142000, 0x00144000, 0x00146000, 0x00148000, 0x0014a000, 0x0014c000,
- 0x0014e000, 0x00150000, 0x00152000, 0x00154000, 0x00156000, 0x00158000,
- 0x0015a000, 0x0015c000, 0x0015e000, 0x00160000, 0x00162000, 0x00164000,
- 0x00166000, 0x00168000, 0x0016a000, 0x0016c000, 0x0016e000, 0x00170000,
- 0x00172000, 0x00174000, 0x00176000, 0x00178000, 0x0017a000, 0x0017c000,
- 0x0017e000, 0x00180000, 0x00182000, 0x00184000, 0x00186000, 0x00188000,
- 0x0018a000, 0x0018c000, 0x0018e000, 0x00190000, 0x00192000, 0x00194000,
- 0x00196000, 0x00198000, 0x0019a000, 0x0019c000, 0x0019e000, 0x001a0000,
- 0x001a2000, 0x001a4000, 0x001a6000, 0x001a8000, 0x001aa000, 0x001ac000,
- 0x001ae000, 0x001b0000, 0x001b2000, 0x001b4000, 0x001b6000, 0x001b8000,
- 0x001ba000, 0x001bc000, 0x001be000, 0x001c0000, 0x001c2000, 0x001c4000,
- 0x001c6000, 0x001c8000, 0x001ca000, 0x001cc000, 0x001ce000, 0x001d0000,
- 0x001d2000, 0x001d4000, 0x001d6000, 0x001d8000, 0x001da000, 0x001dc000,
- 0x001de000, 0x001e0000, 0x001e2000, 0x001e4000, 0x001e6000, 0x001e8000,
- 0x001ea000, 0x001ec000, 0x001ee000, 0x001f0000, 0x001f2000, 0x001f4000,
- 0x001f6000, 0x001f8000, 0x001fa000, 0x001fc000, 0x001fe000, 0x00200000,
- 0x00202000, 0x00204000, 0x00206000, 0x00208000, 0x0020a000, 0x0020c000,
- 0x0020e000, 0x00210000, 0x00212000, 0x00214000, 0x00216000, 0x00218000,
- 0x0021a000, 0x0021c000, 0x0021e000, 0x00220000, 0x00222000, 0x00224000,
- 0x00226000, 0x00228000, 0x0022a000, 0x0022c000, 0x0022e000, 0x00230000,
- 0x00232000, 0x00234000, 0x00236000, 0x00238000, 0x0023a000, 0x0023c000,
- 0x0023e000, 0x00240000, 0x00242000, 0x00244000, 0x00246000, 0x00248000,
- 0x0024a000, 0x0024c000, 0x0024e000, 0x00250000, 0x00252000, 0x00254000,
- 0x00256000, 0x00258000, 0x0025a000, 0x0025c000, 0x0025e000, 0x00260000,
- 0x00262000, 0x00264000, 0x00266000, 0x00268000, 0x0026a000, 0x0026c000,
- 0x0026e000, 0x00270000, 0x00272000, 0x00274000, 0x00276000, 0x00278000,
- 0x0027a000, 0x0027c000, 0x0027e000, 0x00280000, 0x00282000, 0x00284000,
- 0x00286000, 0x00288000, 0x0028a000, 0x0028c000, 0x0028e000, 0x00290000,
- 0x00292000, 0x00294000, 0x00296000, 0x00298000, 0x0029a000, 0x0029c000,
- 0x0029e000, 0x002a0000, 0x002a2000, 0x002a4000, 0x002a6000, 0x002a8000,
- 0x002aa000, 0x002ac000, 0x002ae000, 0x002b0000, 0x002b2000, 0x002b4000,
- 0x002b6000, 0x002b8000, 0x002ba000, 0x002bc000, 0x002be000, 0x002c0000,
- 0x002c2000, 0x002c4000, 0x002c6000, 0x002c8000, 0x002ca000, 0x002cc000,
- 0x002ce000, 0x002d0000, 0x002d2000, 0x002d4000, 0x002d6000, 0x002d8000,
- 0x002da000, 0x002dc000, 0x002de000, 0x002e0000, 0x002e2000, 0x002e4000,
- 0x002e6000, 0x002e8000, 0x002ea000, 0x002ec000, 0x002ee000, 0x002f0000,
- 0x002f2000, 0x002f4000, 0x002f6000, 0x002f8000, 0x002fa000, 0x002fc000,
- 0x002fe000, 0x00300000, 0x00302000, 0x00304000, 0x00306000, 0x00308000,
- 0x0030a000, 0x0030c000, 0x0030e000, 0x00310000, 0x00312000, 0x00314000,
- 0x00316000, 0x00318000, 0x0031a000, 0x0031c000, 0x0031e000, 0x00320000,
- 0x00322000, 0x00324000, 0x00326000, 0x00328000, 0x0032a000, 0x0032c000,
- 0x0032e000, 0x00330000, 0x00332000, 0x00334000, 0x00336000, 0x00338000,
- 0x0033a000, 0x0033c000, 0x0033e000, 0x00340000, 0x00342000, 0x00344000,
- 0x00346000, 0x00348000, 0x0034a000, 0x0034c000, 0x0034e000, 0x00350000,
- 0x00352000, 0x00354000, 0x00356000, 0x00358000, 0x0035a000, 0x0035c000,
- 0x0035e000, 0x00360000, 0x00362000, 0x00364000, 0x00366000, 0x00368000,
- 0x0036a000, 0x0036c000, 0x0036e000, 0x00370000, 0x00372000, 0x00374000,
- 0x00376000, 0x00378000, 0x0037a000, 0x0037c000, 0x0037e000, 0x00380000,
- 0x00382000, 0x00384000, 0x00386000, 0x00388000, 0x0038a000, 0x0038c000,
- 0x0038e000, 0x00390000, 0x00392000, 0x00394000, 0x00396000, 0x00398000,
- 0x0039a000, 0x0039c000, 0x0039e000, 0x003a0000, 0x003a2000, 0x003a4000,
- 0x003a6000, 0x003a8000, 0x003aa000, 0x003ac000, 0x003ae000, 0x003b0000,
- 0x003b2000, 0x003b4000, 0x003b6000, 0x003b8000, 0x003ba000, 0x003bc000,
- 0x003be000, 0x003c0000, 0x003c2000, 0x003c4000, 0x003c6000, 0x003c8000,
- 0x003ca000, 0x003cc000, 0x003ce000, 0x003d0000, 0x003d2000, 0x003d4000,
- 0x003d6000, 0x003d8000, 0x003da000, 0x003dc000, 0x003de000, 0x003e0000,
- 0x003e2000, 0x003e4000, 0x003e6000, 0x003e8000, 0x003ea000, 0x003ec000,
- 0x003ee000, 0x003f0000, 0x003f2000, 0x003f4000, 0x003f6000, 0x003f8000,
- 0x003fa000, 0x003fc000, 0x003fe000, 0x003fe001, 0x00000000, 0x000001ff,
- 0x00000200, 0x00000001, 0x00000003, 0x00bebc20, 0x00000003, 0x00bebc20,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0x00000000, 0x00007ff8, 0x00000000, 0x00003500,
- 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000003,
- 0x00bebc20, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff,
- 0x00000003, 0x00bebc20, 0x00002000, 0x000040c0, 0x00006180, 0x00008240,
- 0x0000a300, 0x0000c3c0, 0x0000e480, 0x00010540, 0x00012600, 0x000146c0,
- 0x00016780, 0x00018840, 0x0001a900, 0x0001c9c0, 0x0001ea80, 0x00020b40,
- 0x00022c00, 0x00024cc0, 0x00026d80, 0x00028e40, 0x0002af00, 0x0002cfc0,
- 0x0002f080, 0x00031140, 0x00033200, 0x000352c0, 0x00037380, 0x00039440,
- 0x0003b500, 0x0003d5c0, 0x0003f680, 0x00041740, 0x00043800, 0x000458c0,
- 0x00047980, 0x00049a40, 0x00008000, 0x00010380, 0x00018700, 0x00020a80,
- 0x00028e00, 0x00031180, 0x00039500, 0x00041880, 0x00049c00, 0x00051f80,
- 0x0005a300, 0x00062680, 0x0006aa00, 0x00072d80, 0x0007b100, 0x00083480,
- 0x0008b800, 0x00093b80, 0x0009bf00, 0x000a4280, 0x000ac600, 0x000b4980,
- 0x000bcd00, 0x000c5080, 0x000cd400, 0x000d5780, 0x000ddb00, 0x00001900,
- 0x00000000, 0xffffffff, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x00000000, 0x00007ff8,
- 0x00000000, 0x00001500, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x00000000, 0x00007ff8, 0x00000000, 0x00001500, 0x00001000, 0x00002080,
- 0x00003100, 0x00004180, 0x00005200, 0x00006280, 0x00007300, 0x00008380,
- 0x00009400, 0x0000a480, 0x0000b500, 0x0000c580, 0x0000d600, 0x0000e680,
- 0x0000f700, 0x00010780, 0x00011800, 0x00012880, 0x00013900, 0x00014980,
- 0x00015a00, 0x00016a80, 0x00017b00, 0x00018b80, 0x00019c00, 0x0001ac80,
- 0x0001bd00, 0x0001cd80, 0x0001de00, 0x0001ee80, 0x0001ff00, 0x10000000,
- 0x000028ad, 0x00000000, 0x00010001, 0x00350804, 0xccccccc1, 0xffffffff,
- 0xffffffff, 0x7058103c, 0x00000000, 0xcccc0201, 0xcccccccc, 0x00000000,
- 0xffffffff, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x00000000, 0x00007ff8, 0x00000000,
- 0x00003500, 0x000e01b7, 0x011600d6, 0x0000ffff, 0x00000000, 0x0000ffff,
- 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff,
- 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff,
- 0x00000000, 0x00100000, 0x00000000, 0x007201bb, 0x012300f3, 0x0000ffff,
- 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff,
- 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff,
- 0x00000000, 0x0000ffff, 0x00000000, 0x00100000, 0x00000000, 0xfffffff3,
- 0x320fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c,
- 0xcdcdcdcd, 0xfffffff1, 0x30efffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xfffffff6, 0x305fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xfffff406,
- 0x1cbfffff, 0x0c30c305, 0xc30c30c3, 0xcf300014, 0xf3cf3cf3, 0x0004cf3c,
- 0xcdcdcdcd, 0xfffffff2, 0x304fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xfffffffa, 0x302fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xfffffff7,
- 0x31efffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0020cf3c,
- 0xcdcdcdcd, 0xfffffff5, 0x302fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xfffffff3, 0x310fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1,
- 0x310fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c,
- 0xcdcdcdcd, 0xfffffff6, 0x305fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xfffff406, 0x1cbfffff, 0x0c30c305,
- 0xc30c30c3, 0xcf300014, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2,
- 0x304fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c,
- 0xcdcdcdcd, 0xfffffffa, 0x302fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xfffffff7, 0x30efffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xfffffff5,
- 0x304fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c,
- 0xcdcdcdcd, 0xfffffff3, 0x31efffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1, 0x310fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xfffffff6,
- 0x305fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0002cf3c,
- 0xcdcdcdcd, 0xfffff406, 0x1cbfffff, 0x0c30c305, 0xc30c30c3, 0xcf300014,
- 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2, 0x304fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xfffffffa,
- 0x302fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0010cf3c,
- 0xcdcdcdcd, 0xffffff97, 0x056fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cc000,
- 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xfffffff5, 0x310fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xfffffff3,
- 0x320fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c,
- 0xcdcdcdcd, 0xfffffff1, 0x310fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xfffffff6, 0x305fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xfffff406,
- 0x1cbfffff, 0x0c30c305, 0xc30c30c3, 0xcf300014, 0xf3cf3cf3, 0x0004cf3c,
- 0xcdcdcdcd, 0xfffffff2, 0x304fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xffffff8a, 0x042fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cc000, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xffffff97,
- 0x05cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cc000, 0xf3cf3cf3, 0x0020cf3c,
- 0xcdcdcdcd, 0xfffffff5, 0x310fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xfffffff3, 0x300fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1,
- 0x300fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c,
- 0xcdcdcdcd, 0xfffffff6, 0x305fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xfffff406, 0x1cbfffff, 0x0c30c305,
- 0xc30c30c3, 0xcf300014, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2,
- 0x304fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c,
- 0xcdcdcdcd, 0xfffffffa, 0x302fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300,
- 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xffffff97, 0x040fffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cc000, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xfffffff5,
- 0x300fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0002cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0010cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0000cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0004cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0020cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0001cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0008cf3c,
- 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc,
- 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c,
- 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xffffffff,
- 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0040cf3c,
- 0xcdcdcdcd, 0x00100000, 0x00070100, 0x00028170, 0x000b8198, 0x00020250,
- 0x00010270, 0x000f0280, 0x00010370, 0x00080000, 0x00080080, 0x00028100,
- 0x000b8128, 0x000201e0, 0x00010200, 0x00070210, 0x00020280, 0x000f0000,
- 0x000800f0, 0x00028170, 0x000b8198, 0x00020250, 0x00010270, 0x000b8280,
- 0x00080338, 0x00100000, 0x00080100, 0x00028180, 0x000b81a8, 0x00020260,
- 0x00018280, 0x000e8298, 0x00080380, 0x00028000, 0x000b8028, 0x000200e0,
- 0x00010100, 0x00008110, 0x00000118, 0xcccccccc, 0xcccccccc, 0xcccccccc,
- 0xcccccccc, 0x00002000, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0xcccccccc,
- 0x00002000, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0x00002000
-};
-
-static const u32 init_data_e1h[] = {
- 0x00010000, 0x000204c0, 0x00030980, 0x00040e40, 0x00051300, 0x000617c0,
- 0x00071c80, 0x00082140, 0x00092600, 0x000a2ac0, 0x000b2f80, 0x000c3440,
- 0x000d3900, 0x000e3dc0, 0x000f4280, 0x00104740, 0x00114c00, 0x001250c0,
- 0x00135580, 0x00145a40, 0x00155f00, 0x001663c0, 0x00176880, 0x00186d40,
- 0x00197200, 0x001a76c0, 0x001b7b80, 0x001c8040, 0x001d8500, 0x001e89c0,
- 0x001f8e80, 0x00209340, 0x00002000, 0x00004000, 0x00006000, 0x00008000,
- 0x0000a000, 0x0000c000, 0x0000e000, 0x00010000, 0x00012000, 0x00014000,
- 0x00016000, 0x00018000, 0x0001a000, 0x0001c000, 0x0001e000, 0x00020000,
- 0x00022000, 0x00024000, 0x00026000, 0x00028000, 0x0002a000, 0x0002c000,
- 0x0002e000, 0x00030000, 0x00032000, 0x00034000, 0x00036000, 0x00038000,
- 0x0003a000, 0x0003c000, 0x0003e000, 0x00040000, 0x00042000, 0x00044000,
- 0x00046000, 0x00048000, 0x0004a000, 0x0004c000, 0x0004e000, 0x00050000,
- 0x00052000, 0x00054000, 0x00056000, 0x00058000, 0x0005a000, 0x0005c000,
- 0x0005e000, 0x00060000, 0x00062000, 0x00064000, 0x00066000, 0x00068000,
- 0x0006a000, 0x0006c000, 0x0006e000, 0x00070000, 0x00072000, 0x00074000,
- 0x00076000, 0x00078000, 0x0007a000, 0x0007c000, 0x0007e000, 0x00080000,
- 0x00082000, 0x00084000, 0x00086000, 0x00088000, 0x0008a000, 0x0008c000,
- 0x0008e000, 0x00090000, 0x00092000, 0x00094000, 0x00096000, 0x00098000,
- 0x0009a000, 0x0009c000, 0x0009e000, 0x000a0000, 0x000a2000, 0x000a4000,
- 0x000a6000, 0x000a8000, 0x000aa000, 0x000ac000, 0x000ae000, 0x000b0000,
- 0x000b2000, 0x000b4000, 0x000b6000, 0x000b8000, 0x000ba000, 0x000bc000,
- 0x000be000, 0x000c0000, 0x000c2000, 0x000c4000, 0x000c6000, 0x000c8000,
- 0x000ca000, 0x000cc000, 0x000ce000, 0x000d0000, 0x000d2000, 0x000d4000,
- 0x000d6000, 0x000d8000, 0x000da000, 0x000dc000, 0x000de000, 0x000e0000,
- 0x000e2000, 0x000e4000, 0x000e6000, 0x000e8000, 0x000ea000, 0x000ec000,
- 0x000ee000, 0x000f0000, 0x000f2000, 0x000f4000, 0x000f6000, 0x000f8000,
- 0x000fa000, 0x000fc000, 0x000fe000, 0x00100000, 0x00102000, 0x00104000,
- 0x00106000, 0x00108000, 0x0010a000, 0x0010c000, 0x0010e000, 0x00110000,
- 0x00112000, 0x00114000, 0x00116000, 0x00118000, 0x0011a000, 0x0011c000,
- 0x0011e000, 0x00120000, 0x00122000, 0x00124000, 0x00126000, 0x00128000,
- 0x0012a000, 0x0012c000, 0x0012e000, 0x00130000, 0x00132000, 0x00134000,
- 0x00136000, 0x00138000, 0x0013a000, 0x0013c000, 0x0013e000, 0x00140000,
- 0x00142000, 0x00144000, 0x00146000, 0x00148000, 0x0014a000, 0x0014c000,
- 0x0014e000, 0x00150000, 0x00152000, 0x00154000, 0x00156000, 0x00158000,
- 0x0015a000, 0x0015c000, 0x0015e000, 0x00160000, 0x00162000, 0x00164000,
- 0x00166000, 0x00168000, 0x0016a000, 0x0016c000, 0x0016e000, 0x00170000,
- 0x00172000, 0x00174000, 0x00176000, 0x00178000, 0x0017a000, 0x0017c000,
- 0x0017e000, 0x00180000, 0x00182000, 0x00184000, 0x00186000, 0x00188000,
- 0x0018a000, 0x0018c000, 0x0018e000, 0x00190000, 0x00192000, 0x00194000,
- 0x00196000, 0x00198000, 0x0019a000, 0x0019c000, 0x0019e000, 0x001a0000,
- 0x001a2000, 0x001a4000, 0x001a6000, 0x001a8000, 0x001aa000, 0x001ac000,
- 0x001ae000, 0x001b0000, 0x001b2000, 0x001b4000, 0x001b6000, 0x001b8000,
- 0x001ba000, 0x001bc000, 0x001be000, 0x001c0000, 0x001c2000, 0x001c4000,
- 0x001c6000, 0x001c8000, 0x001ca000, 0x001cc000, 0x001ce000, 0x001d0000,
- 0x001d2000, 0x001d4000, 0x001d6000, 0x001d8000, 0x001da000, 0x001dc000,
- 0x001de000, 0x001e0000, 0x001e2000, 0x001e4000, 0x001e6000, 0x001e8000,
- 0x001ea000, 0x001ec000, 0x001ee000, 0x001f0000, 0x001f2000, 0x001f4000,
- 0x001f6000, 0x001f8000, 0x001fa000, 0x001fc000, 0x001fe000, 0x00200000,
- 0x00202000, 0x00204000, 0x00206000, 0x00208000, 0x0020a000, 0x0020c000,
- 0x0020e000, 0x00210000, 0x00212000, 0x00214000, 0x00216000, 0x00218000,
- 0x0021a000, 0x0021c000, 0x0021e000, 0x00220000, 0x00222000, 0x00224000,
- 0x00226000, 0x00228000, 0x0022a000, 0x0022c000, 0x0022e000, 0x00230000,
- 0x00232000, 0x00234000, 0x00236000, 0x00238000, 0x0023a000, 0x0023c000,
- 0x0023e000, 0x00240000, 0x00242000, 0x00244000, 0x00246000, 0x00248000,
- 0x0024a000, 0x0024c000, 0x0024e000, 0x00250000, 0x00252000, 0x00254000,
- 0x00256000, 0x00258000, 0x0025a000, 0x0025c000, 0x0025e000, 0x00260000,
- 0x00262000, 0x00264000, 0x00266000, 0x00268000, 0x0026a000, 0x0026c000,
- 0x0026e000, 0x00270000, 0x00272000, 0x00274000, 0x00276000, 0x00278000,
- 0x0027a000, 0x0027c000, 0x0027e000, 0x00280000, 0x00282000, 0x00284000,
- 0x00286000, 0x00288000, 0x0028a000, 0x0028c000, 0x0028e000, 0x00290000,
- 0x00292000, 0x00294000, 0x00296000, 0x00298000, 0x0029a000, 0x0029c000,
- 0x0029e000, 0x002a0000, 0x002a2000, 0x002a4000, 0x002a6000, 0x002a8000,
- 0x002aa000, 0x002ac000, 0x002ae000, 0x002b0000, 0x002b2000, 0x002b4000,
- 0x002b6000, 0x002b8000, 0x002ba000, 0x002bc000, 0x002be000, 0x002c0000,
- 0x002c2000, 0x002c4000, 0x002c6000, 0x002c8000, 0x002ca000, 0x002cc000,
- 0x002ce000, 0x002d0000, 0x002d2000, 0x002d4000, 0x002d6000, 0x002d8000,
- 0x002da000, 0x002dc000, 0x002de000, 0x002e0000, 0x002e2000, 0x002e4000,
- 0x002e6000, 0x002e8000, 0x002ea000, 0x002ec000, 0x002ee000, 0x002f0000,
- 0x002f2000, 0x002f4000, 0x002f6000, 0x002f8000, 0x002fa000, 0x002fc000,
- 0x002fe000, 0x00300000, 0x00302000, 0x00304000, 0x00306000, 0x00308000,
- 0x0030a000, 0x0030c000, 0x0030e000, 0x00310000, 0x00312000, 0x00314000,
- 0x00316000, 0x00318000, 0x0031a000, 0x0031c000, 0x0031e000, 0x00320000,
- 0x00322000, 0x00324000, 0x00326000, 0x00328000, 0x0032a000, 0x0032c000,
- 0x0032e000, 0x00330000, 0x00332000, 0x00334000, 0x00336000, 0x00338000,
- 0x0033a000, 0x0033c000, 0x0033e000, 0x00340000, 0x00342000, 0x00344000,
- 0x00346000, 0x00348000, 0x0034a000, 0x0034c000, 0x0034e000, 0x00350000,
- 0x00352000, 0x00354000, 0x00356000, 0x00358000, 0x0035a000, 0x0035c000,
- 0x0035e000, 0x00360000, 0x00362000, 0x00364000, 0x00366000, 0x00368000,
- 0x0036a000, 0x0036c000, 0x0036e000, 0x00370000, 0x00372000, 0x00374000,
- 0x00376000, 0x00378000, 0x0037a000, 0x0037c000, 0x0037e000, 0x00380000,
- 0x00382000, 0x00384000, 0x00386000, 0x00388000, 0x0038a000, 0x0038c000,
- 0x0038e000, 0x00390000, 0x00392000, 0x00394000, 0x00396000, 0x00398000,
- 0x0039a000, 0x0039c000, 0x0039e000, 0x003a0000, 0x003a2000, 0x003a4000,
- 0x003a6000, 0x003a8000, 0x003aa000, 0x003ac000, 0x003ae000, 0x003b0000,
- 0x003b2000, 0x003b4000, 0x003b6000, 0x003b8000, 0x003ba000, 0x003bc000,
- 0x003be000, 0x003c0000, 0x003c2000, 0x003c4000, 0x003c6000, 0x003c8000,
- 0x003ca000, 0x003cc000, 0x003ce000, 0x003d0000, 0x003d2000, 0x003d4000,
- 0x003d6000, 0x003d8000, 0x003da000, 0x003dc000, 0x003de000, 0x003e0000,
- 0x003e2000, 0x003e4000, 0x003e6000, 0x003e8000, 0x003ea000, 0x003ec000,
- 0x003ee000, 0x003f0000, 0x003f2000, 0x003f4000, 0x003f6000, 0x003f8000,
- 0x003fa000, 0x003fc000, 0x003fe000, 0x003fe001, 0x00000000, 0x000001ff,
- 0x00000200, 0x00000001, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00007ff8,
- 0x00000000, 0x00003500, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
- 0xffffffff, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff,
- 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000003,
- 0x00bebc20, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff,
- 0x00000003, 0x00bebc20, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
- 0xffffffff, 0x00000003, 0x00bebc20, 0xffffffff, 0x00000000, 0xffffffff,
- 0x00000000, 0xffffffff, 0x00000003, 0x00bebc20, 0xffffffff, 0x00000000,
- 0xffffffff, 0x00000000, 0xffffffff, 0x00000003, 0x00bebc20, 0xffffffff,
- 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000003, 0x00bebc20,
- 0x00002000, 0x000040c0, 0x00006180, 0x00008240, 0x0000a300, 0x0000c3c0,
- 0x0000e480, 0x00010540, 0x00012600, 0x000146c0, 0x00016780, 0x00018840,
- 0x0001a900, 0x0001c9c0, 0x0001ea80, 0x00020b40, 0x00022c00, 0x00024cc0,
- 0x00026d80, 0x00028e40, 0x0002af00, 0x0002cfc0, 0x0002f080, 0x00031140,
- 0x00033200, 0x000352c0, 0x00037380, 0x00039440, 0x0003b500, 0x0003d5c0,
- 0x0003f680, 0x00041740, 0x00043800, 0x000458c0, 0x00047980, 0x00049a40,
- 0x00008000, 0x00010380, 0x00018700, 0x00020a80, 0x00028e00, 0x00031180,
- 0x00039500, 0x00041880, 0x00049c00, 0x00051f80, 0x0005a300, 0x00062680,
- 0x0006aa00, 0x00072d80, 0x0007b100, 0x00083480, 0x0008b800, 0x00093b80,
- 0x0009bf00, 0x000a4280, 0x000ac600, 0x000b4980, 0x000bcd00, 0x000c5080,
- 0x000cd400, 0x000d5780, 0x000ddb00, 0x00001900, 0x00000028, 0x00100000,
- 0x00000000, 0x00000000, 0xffffffff, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x00000000,
- 0x00007ff8, 0x00000000, 0x00001500, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x00000000, 0x00007ff8, 0x00000000, 0x00001500, 0x00001000,
- 0x00002080, 0x00003100, 0x00004180, 0x00005200, 0x00006280, 0x00007300,
- 0x00008380, 0x00009400, 0x0000a480, 0x0000b500, 0x0000c580, 0x0000d600,
- 0x0000e680, 0x0000f700, 0x00010780, 0x00011800, 0x00012880, 0x00013900,
- 0x00014980, 0x00015a00, 0x00016a80, 0x00017b00, 0x00018b80, 0x00019c00,
- 0x0001ac80, 0x0001bd00, 0x0001cd80, 0x0001de00, 0x0001ee80, 0x0001ff00,
- 0x10000000, 0x000028ad, 0x00000000, 0x00010001, 0x00350804, 0xccccccc5,
- 0xffffffff, 0xffffffff, 0x7058103c, 0x00000000, 0xcccc0201, 0xcccccccc,
- 0xcccc0201, 0xcccccccc, 0xcccc0201, 0xcccccccc, 0xcccc0201, 0xcccccccc,
- 0xcccc0201, 0xcccccccc, 0xcccc0201, 0xcccccccc, 0xcccc0201, 0xcccccccc,
- 0xcccc0201, 0xcccccccc, 0x00000000, 0xffffffff, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000,
- 0x00000000, 0x00007ff8, 0x00000000, 0x00003500, 0x000e0232, 0x011600d6,
- 0x00100000, 0x00000000, 0x00720236, 0x012300f3, 0x00100000, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000,
- 0x0000ffff, 0x00000000, 0xfffffff3, 0x320fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1, 0x30efffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd,
- 0xfffffff6, 0x305fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0002cf3c, 0xcdcdcdcd, 0xfffff406, 0x1cbfffff, 0x0c30c305, 0xc30c30c3,
- 0xcf300014, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2, 0x304fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd,
- 0xfffffffa, 0x302fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0010cf3c, 0xcdcdcdcd, 0xfffffff7, 0x31efffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xfffffff5, 0x302fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd,
- 0xfffffff3, 0x310fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1, 0x310fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xfffffff6, 0x305fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd,
- 0xfffff406, 0x1cbfffff, 0x0c30c305, 0xc30c30c3, 0xcf300014, 0xf3cf3cf3,
- 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2, 0x304fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xfffffffa, 0x302fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd,
- 0xfffffff7, 0x30efffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0020cf3c, 0xcdcdcdcd, 0xfffffff5, 0x304fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xfffffff3, 0x31efffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd,
- 0xfffffff1, 0x310fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0001cf3c, 0xcdcdcdcd, 0xfffffff6, 0x305fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xfffff406, 0x1cbfffff,
- 0x0c30c305, 0xc30c30c3, 0xcf300014, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd,
- 0xfffffff2, 0x304fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0008cf3c, 0xcdcdcdcd, 0xfffffffa, 0x302fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xffffff97, 0x056fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cc000, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd,
- 0xfffffff5, 0x310fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0040cf3c, 0xcdcdcdcd, 0xfffffff3, 0x320fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1, 0x310fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd,
- 0xfffffff6, 0x305fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0002cf3c, 0xcdcdcdcd, 0xfffff406, 0x1cbfffff, 0x0c30c305, 0xc30c30c3,
- 0xcf300014, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2, 0x304fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd,
- 0xffffff8a, 0x042fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cc000, 0xf3cf3cf3,
- 0x0010cf3c, 0xcdcdcdcd, 0xffffff97, 0x05cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cc000, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xfffffff5, 0x310fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd,
- 0xfffffff3, 0x316fffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0000cf3c, 0xcdcdcdcd, 0xfffffff1, 0x302fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xfffffff6, 0x305fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd,
- 0xfffffff6, 0x30bfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf314, 0xf3cf3cf3,
- 0x0004cf3c, 0xcdcdcdcd, 0xfffffff2, 0x304fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xfffffffa, 0x302fffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd,
- 0xfffffff7, 0x31cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf300, 0xf3cf3cf3,
- 0x0020cf3c, 0xcdcdcdcd, 0xfffffff0, 0x307fffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf300, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0001cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0008cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0040cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0000cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0002cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0004cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0010cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0020cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0000cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0001cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0002cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0004cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0008cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff,
- 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3, 0x0010cf3c, 0xcdcdcdcd,
- 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3, 0xcf3cf3cc, 0xf3cf3cf3,
- 0x0020cf3c, 0xcdcdcdcd, 0xffffffff, 0x30cfffff, 0x0c30c30c, 0xc30c30c3,
- 0xcf3cf3cc, 0xf3cf3cf3, 0x0040cf3c, 0xcdcdcdcd, 0x00100000, 0x00070100,
- 0x00028170, 0x000b8198, 0x00020250, 0x00010270, 0x000f0280, 0x00010370,
- 0x00080000, 0x00080080, 0x00028100, 0x000b8128, 0x000201e0, 0x00010200,
- 0x00070210, 0x00020280, 0x000f0000, 0x000800f0, 0x00028170, 0x000b8198,
- 0x00020250, 0x00010270, 0x000b8280, 0x00080338, 0x00100000, 0x00080100,
- 0x00028180, 0x000b81a8, 0x00020260, 0x00018280, 0x000e8298, 0x00080380,
- 0x000b0000, 0x000100b0, 0x000280c0, 0x000580e8, 0x00020140, 0x00010160,
- 0x000e0170, 0x00038250, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0xcccccccc,
- 0x00002000, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0x00002000,
- 0xcccccccc, 0xcccccccc, 0xcccccccc, 0xcccccccc, 0x04002000
-};
-
-static const u32 tsem_int_table_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x51fbff00, 0x03f0c0cf, 0x19d9458a, 0x1138fc18,
- 0x5980a1fc, 0xd8181998, 0x88039880, 0x81b8803d, 0x91a18191, 0xdafd7891,
- 0xbf760862, 0x6ec30330, 0x0211e620, 0x1082239a, 0xf354029f, 0x0f5fc806,
- 0x6512b315, 0x3a263860, 0x06a77ef0, 0x298d2ade, 0xc1124536, 0x1e4586de,
- 0x93476f19, 0xca8922ff, 0xff4041df, 0x65296340, 0x229dbe54, 0x04a65e84,
- 0xe4d1a5a1, 0xd7f2a1ed, 0x5192fea1, 0x0dee6ec6, 0xf8003ca8, 0x6065495c,
- 0x00606549
-};
-
-static const u32 tsem_pram_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x7dedff00, 0xd554780b, 0x733ef0b5, 0x49999cce,
- 0x424e4cce, 0x4c22f212, 0x21a08812, 0x8a80af0c, 0x2201277f, 0x282039f5,
- 0x4201d458, 0xd4837908, 0xcdedaf4b, 0x11102484, 0x0547f435, 0x5088768b,
- 0x340da2d1, 0x0ec160d2, 0x6d7b1420, 0xc0faf06f, 0x480bf5ea, 0xb12f3141,
- 0xcbc57e20, 0xe7dad6bf, 0x264ce664, 0xafdbd880, 0xb4fdffff, 0xece7d9b8,
- 0xebdaf7b3, 0x7b5ad7b5, 0x75923ded, 0xc7bf9302, 0x03fc45d8, 0x8c4d4fe5,
- 0xf2c109b1, 0x80f66667, 0xc9b18727, 0x473afebd, 0x6d55633c, 0x9da23b19,
- 0x99ec258c, 0x50281421, 0x2c23d5fe, 0xbfdf8250, 0xf097c365, 0x4219b6ff,
- 0xd0977c3e, 0xc3e611e9, 0x02d5e4fb, 0x933a876b, 0xea0c319c, 0x4b19b98c,
- 0x126b2c64, 0x4b223fa3, 0xe0ff828d, 0x8f392573, 0x27fc34b1, 0x61467574,
- 0xc678c0ae, 0x5c531e32, 0x38a9d0d4, 0x843f7815, 0xbcd2c67f, 0x0731b725,
- 0xbc03cf63, 0xbcf071c9, 0x61de3a5a, 0xc22eefe5, 0x3af3a1df, 0xae58cd6a,
- 0x32773e30, 0x416589a7, 0xf3e33ebf, 0x3d6346ac, 0x4fe3d99b, 0xec3fc346,
- 0x8c517ecc, 0xb1138f30, 0xcb3c018c, 0x632f0e54, 0x5467b2bd, 0x6a9b1f10,
- 0x2c32a258, 0x852f0f58, 0x56338765, 0xed975e03, 0xf8165c16, 0x2f6c39fe,
- 0xbed7e631, 0x15ead66b, 0xa362593e, 0xb50404a1, 0x67eff4e4, 0x11bfcb11,
- 0x2b30fef1, 0xea4ab2a0, 0xaf805595, 0xfb765aaa, 0x67edfe95, 0x54e88933,
- 0x5bf6b929, 0x5adefc61, 0xf1866ae6, 0x02d59997, 0x91fb2fac, 0x7a83e5d3,
- 0x21476366, 0x36d0fa83, 0xc1198981, 0x9e00afef, 0x007f91db, 0xa52b2a1e,
- 0x740642de, 0xb02bddec, 0x871c0ce6, 0x776cbbf7, 0x0c65f306, 0x6658e70c,
- 0x32e73826, 0x74893a41, 0xd2073071, 0xf324bcc1, 0xcea84289, 0xb0f3dc54,
- 0x9de29f7f, 0xe7f4ed87, 0x38e60b49, 0xf25700bd, 0x57a06650, 0x9d3ab5b1,
- 0xea563265, 0xbe442969, 0x8decb538, 0x9e025855, 0xf7c02413, 0x08a78b7c,
- 0x5798a9fb, 0xa780cd9d, 0x8d1859e6, 0xff2db43f, 0x0cf80933, 0xc4c5f3ba,
- 0x76313f21, 0xf04f843c, 0x5a11f1cf, 0xde981c5d, 0xb08b2b97, 0x05f1091f,
- 0x1f011772, 0x26a0423f, 0x544d28e0, 0x29fc573a, 0xd0a0d86b, 0xc3595bfa,
- 0xe50069c6, 0x3f0cbc11, 0x0843ac61, 0x1cbd4be5, 0xb0ff3bba, 0x3c303b94,
- 0x04f3d3ff, 0xab7e1274, 0x1fc8b700, 0xbfd97615, 0xca61f812, 0xf7c0e6ab,
- 0x362a3f80, 0xd40b7e0b, 0xe8dbaf4d, 0x5e26f77d, 0x3765d80f, 0x16d74ff2,
- 0xbdf00ba8, 0x1bf1fda5, 0x155ebf91, 0x3b763359, 0xfa84ca22, 0x3b06a4e5,
- 0xc0750f1b, 0x578db147, 0xbbef362b, 0x692fbf1f, 0xf41b30b3, 0xf17bb157,
- 0x7d42371d, 0xc33361f1, 0x6b5b1526, 0x2fa814e5, 0x582d0bf1, 0xf0e029ef,
- 0xfe8976f9, 0xc7bed0ad, 0x1b389ed1, 0xc6ba73e8, 0x63329cca, 0xc4f6f675,
- 0xa567c059, 0xf8851dfe, 0xc176e95d, 0xf29f6885, 0xc943d6ea, 0xb917af38,
- 0x8b6d977c, 0x7f1d4e66, 0xab64f7f0, 0xbc1ef818, 0x64f3065f, 0xd662efd0,
- 0xb07a8854, 0xd93aeb62, 0xebe20f69, 0xe34a8d74, 0x8bdfc9f4, 0x577c0e30,
- 0xc2e08af9, 0x989a5629, 0x7bb0e517, 0xf3ce6db7, 0x56afce0a, 0xbce3b6ce,
- 0x6ed8cb56, 0x2efe7fb1, 0xfea5cd54, 0xbc2172cd, 0x59b4dd2f, 0xdb910e2e,
- 0x8c836db2, 0x1ac86d70, 0xd7208dec, 0xd7807841, 0x52f583b2, 0x0fa803d4,
- 0x233cbf25, 0x852acf84, 0xb2cbe258, 0x1a73226d, 0xddd388f8, 0x13fc2ef7,
- 0x6bdbe5f0, 0x74eabc27, 0x1aa7d3eb, 0x1aa8cedd, 0xbcdea51d, 0xf8f81119,
- 0xc003a471, 0x827884d3, 0x9f06ad72, 0x97cb3263, 0x9b877fa0, 0x3cbb02a9,
- 0xd999365f, 0xf563067c, 0xd2dd07b0, 0xd99750f5, 0xf582e652, 0x7bb1fa50,
- 0x0493d42a, 0x9f3867ef, 0xc25bc17a, 0x2496abd7, 0x9579e00f, 0xfce0e6c0,
- 0x30d0218f, 0xc0c955af, 0xa6f7809f, 0x8bcf7969, 0x3c7b0682, 0xb17f8bd6,
- 0x39fa8326, 0xa198fd43, 0xf7cbac9f, 0x324e16a3, 0x9616a3f4, 0x8dfcfde8,
- 0x595db1fa, 0x37854d3f, 0x2c29e118, 0x0491fbd5, 0xbf6f5768, 0x37a979b2,
- 0x73c2364f, 0x13f53973, 0xbcc5d53b, 0x1ae7ae0a, 0xb776b03f, 0xed95ef08,
- 0xb0d763b1, 0x5028be50, 0x0edb8005, 0x17ca1252, 0x0ca29331, 0x8eeb187c,
- 0x27a1d433, 0x4175e4f5, 0x958813fd, 0x45397c69, 0x9f90bd26, 0x43faa562,
- 0x85e90a29, 0x5ef06e87, 0x8e20eb83, 0x2ea192cd, 0x11ab477b, 0x14e01af8,
- 0x60961258, 0x7ff52417, 0xf1ccdabf, 0x217a9050, 0x5f7c18fb, 0x8ecdea65,
- 0xa635fa85, 0x6f116bfc, 0xe5eb812e, 0x63559128, 0x230b28bb, 0x233ab4fd,
- 0x085f79ef, 0x00871a9e, 0xbf6085fd, 0x126f668d, 0xdaf8d7f2, 0xc0127c67,
- 0xcc086ab7, 0x12ba0527, 0x60f8099e, 0xa43d5a3d, 0x69f10938, 0x43be4191,
- 0xfc6197c7, 0x06ff1a1c, 0xc71ba3c4, 0xbe3fe84f, 0x61927325, 0x897a6b7c,
- 0x0cab7c61, 0x4fbf03e3, 0xc6d66dad, 0xc0ddfc07, 0x99a134d8, 0x97a4b7c6,
- 0x65abf8d0, 0x3f186256, 0x5bfc6faa, 0x819efe70, 0x83799fe6, 0xa5e9fe71,
- 0x7ccbf9c6, 0x5f6ab3fe, 0xa28fc6d2, 0x5e16cff9, 0x2f4ff3e2, 0xf0b7f3e5,
- 0x77c6fb7e, 0x5effe1f4, 0x8077bf9c, 0x93592df1, 0x5a1ff38d, 0x85bf9c6e,
- 0xbb545f8f, 0xa15f1b53, 0x3b0917f1, 0x9687fcf9, 0xc5b2f8d3, 0x923e42eb,
- 0xfdaaa353, 0x81a44f68, 0x1d260c40, 0x0472a6e5, 0x1fa00518, 0x04990a86,
- 0x9c5143c7, 0x0145ceef, 0x7d4129bf, 0x5120fcc7, 0x352acfa0, 0x9edb2f9e,
- 0xa59ea32f, 0x376889f7, 0x6d453ff1, 0x6c37ad22, 0x1c3fc5bd, 0x136eede0,
- 0x5a2f587d, 0xa45f937f, 0xe5db8ef5, 0xf005c660, 0x1c9e5ff9, 0xaf3a1cd5,
- 0x935172f0, 0x418764f9, 0xbe3c388e, 0x1aa23602, 0x26476be0, 0x9fac1098,
- 0xc60a3d04, 0x7a0e3b2f, 0x6653cb14, 0x009c8f6e, 0x50e4cb3d, 0xf6e5a9b9,
- 0x93bd8f88, 0x5bbaf303, 0xc4a4ff83, 0xb9727df1, 0x9ffc47e0, 0x4654b75b,
- 0x09a8b4fd, 0x7910e98c, 0xd4e8d2af, 0x6fe2dbbb, 0x4e9f0816, 0x243dcfc4,
- 0x97fd8c8a, 0xde2fd766, 0xddf0c830, 0x486fe63c, 0xd70bf682, 0xc2a21fce,
- 0xc7307ffc, 0x53ed1632, 0x13548490, 0x354b31c9, 0xa7316f81, 0x15399d75,
- 0x31ccf72a, 0xb9faec1b, 0x07fd635e, 0xb77ac625, 0xa1366fd9, 0x6044b1bd,
- 0xfbdfa19b, 0xf5ef8daa, 0x71093671, 0x78daae9c, 0x78722777, 0x2c72c3ef,
- 0xae89563e, 0x5bfcabf7, 0x87aa9e1d, 0xeb402ccd, 0x43024765, 0xc812fa3a,
- 0x7caaf35e, 0xdef0e1de, 0x3dbab66f, 0x3ffdcf00, 0xe19f0912, 0x1ebc77f0,
- 0x1d8136ed, 0x4be1b1d7, 0xe1b7da33, 0xff8709f3, 0xf3e11581, 0xf7d46551,
- 0xcfe17df3, 0xf3849f39, 0xfe5b5553, 0xed2113a0, 0x3fbe5a2a, 0x7f0844e8,
- 0x619b6d95, 0xcff12fa8, 0xbc5fb435, 0xfde1be61, 0x8625a6a2, 0x971b0bf7,
- 0x7df3ea1a, 0x7fb4323f, 0xe1ad4560, 0x8fd57dfd, 0xa0ffde18, 0x3ea19d64,
- 0xd0d1bbd7, 0x9b399efe, 0xaf4def0d, 0xe513bc8f, 0x915deea8, 0x5671bae1,
- 0xda38f939, 0xc9156783, 0xb4f8f485, 0xe0e48926, 0xca938d74, 0x5671b6ee,
- 0xc583d72f, 0x5e9c4c0c, 0x71af9ce1, 0x4665ea32, 0xc2aff3fa, 0xea0f9f05,
- 0x849c137f, 0xcc83713f, 0x02c2c002, 0xe3e3eb8b, 0x7de4315e, 0x6fde65c7,
- 0xd71f4100, 0x11d8bdff, 0xf35579f9, 0x046aa1fc, 0xb72821ff, 0xb9d7152c,
- 0x0f7d6d1e, 0x302e5f7f, 0xc673e84f, 0xd79c9256, 0xb94ceb69, 0xf941f5cc,
- 0xf402e4ce, 0x40e5cbbf, 0xc6a5f576, 0xa2a4016b, 0x3ceb449e, 0xa401f901,
- 0x592fc0c0, 0xdceef906, 0x955c1227, 0xaf4013a8, 0xc19e63ae, 0x8133d426,
- 0x8d77e903, 0x49dc3842, 0xa04b6f54, 0x66b3bd75, 0x1213a0fa, 0xe543c7d2,
- 0xa87335a7, 0xa5e3593c, 0x094d44f2, 0xaa6bc795, 0x59a8eca9, 0x35c7e541,
- 0xaa3f2a3e, 0xcff2a469, 0x1e544d35, 0xe540d9ad, 0x2a7e357b, 0x54dc6bbb,
- 0xba2bf9f6, 0xecd78dfe, 0x80afcd55, 0x67ea8795, 0x43d4b9b4, 0x739276db,
- 0xf9ca1257, 0x365ce519, 0x8e67e3da, 0x31996382, 0xf9c2be30, 0xba3a606d,
- 0xf6295ec9, 0xf5c7fd03, 0xe28b6f7f, 0xd899b274, 0xd9a67074, 0xe17fc323,
- 0x7543905a, 0x16065909, 0x7b0cd724, 0xed617e84, 0x8e5d7a43, 0x9bddcc4e,
- 0x71e8133b, 0xe5bf99f2, 0xda75bf61, 0x407517fa, 0x059875a4, 0xbd21779e,
- 0xeb46f042, 0x9aabef5a, 0xfe0cbfbe, 0xd7f0faba, 0xfbfe8e9e, 0xfea54141,
- 0x985ab4cf, 0x13dc7884, 0x67e607ed, 0xef3f0e67, 0x965c7940, 0x444f5264,
- 0x565e83c0, 0x4aa864b4, 0x66d3fae8, 0x12699fac, 0x7ad0b7a6, 0x35998cec,
- 0x554af90a, 0xfa430c4f, 0xf7a95127, 0x56492cb3, 0x9ebc804f, 0xc31596de,
- 0x5f3f6fd7, 0x12c7b707, 0x485f82bf, 0xf0deffed, 0x0e8fd40c, 0xecad630f,
- 0x03ea2b13, 0xedf59778, 0xfd2672fd, 0x6c57e295, 0xda1cf98f, 0x7bf8160b,
- 0x1207e291, 0xab7ef5d5, 0x659f445a, 0x6edf3e34, 0x73be0f18, 0xc5f73eea,
- 0xadf14bcc, 0xc4864ec4, 0xf169d611, 0x366db2c6, 0xc4aeb8d5, 0x6d55ea1a,
- 0x9d61aac9, 0xfc807fc1, 0x42416ab3, 0xb8d729be, 0x1a5247a8, 0xdcaf8005,
- 0xab7ea4e4, 0xc2aede04, 0xe17b21da, 0xa72b5751, 0x9df040db, 0x94ec39ae,
- 0xac4bde40, 0x7c0201e0, 0xa7232d25, 0x6aeb9ea2, 0x7b444bad, 0xf33c4cb0,
- 0xf7c22790, 0x8d024d3b, 0xee6fc4b7, 0x1aa3ae35, 0x57e8307f, 0x167e4e7f,
- 0xd4864e53, 0xcedc4d3b, 0x80f7ef0e, 0xf0e5efd6, 0x48fdb953, 0xfece8de1,
- 0xfb6caa78, 0x1c92f642, 0x82f2ffc1, 0x57f1d278, 0x401cf26e, 0xedba5a7d,
- 0x9fa3d918, 0x0fd97d9a, 0xf53f425f, 0x44929f9f, 0x5e7d5271, 0x6129303e,
- 0x7c5a059c, 0x9ef7f817, 0xfd3d610f, 0x6ccddfec, 0x2ec7c00d, 0x6f782b40,
- 0x13335fd6, 0xa17d4133, 0x5ad05b56, 0xcfdd7146, 0x2a8edc4c, 0xd1071e62,
- 0xa1e53581, 0x4cc5d91d, 0x5d4f11d3, 0xb8c76dec, 0x329c3a10, 0x1667a4c9,
- 0x18ed1a36, 0xf50d7fb0, 0xf58c1bc5, 0x11333662, 0x7af149f5, 0x340bf333,
- 0xf7fbc33f, 0x7fe12a4d, 0x855eab31, 0xf9a4aaeb, 0x26540b23, 0x157c02a5,
- 0x6f3679bf, 0x4c5fc63e, 0xe3d10fdc, 0x38e24b23, 0x7ef1a5fc, 0x3fef0dd9,
- 0xf7771d69, 0x8b06488d, 0x89c6157f, 0x6d730c58, 0xfbf1fd65, 0x870fe16d,
- 0xfbaf5f57, 0x383469c5, 0xdb826dc4, 0x2f7f811f, 0xeba67c68, 0xd5445beb,
- 0x8ddc17e0, 0x21bf10f5, 0xb2e2d446, 0xee911322, 0x67d5aa5d, 0x14f7a18a,
- 0xb4edf7b7, 0xde80eab8, 0x0679373f, 0x4ec81389, 0xed2165c8, 0xd2f26e7e,
- 0xade14ef3, 0x995bb462, 0x3b45c814, 0xe218d614, 0x07e35953, 0x8b91ca31,
- 0x833b66f1, 0x6fe81475, 0x9fa0f841, 0xdb92f655, 0xbbc62e58, 0xbfa1de41,
- 0x87851cc7, 0x94dba805, 0x59fd8656, 0x7cf18c92, 0xaf58d39b, 0x1d207fc2,
- 0x3f8a3046, 0xc2908f45, 0xa86018f0, 0xe32eed0f, 0x84e851f3, 0x201fdd91,
- 0x8b10763e, 0x02556943, 0x26cf8c22, 0xfe7d9d49, 0x7bfa2656, 0x2f8a7e1c,
- 0x2ae5fb40, 0xc5a95f6f, 0x507f97cf, 0x12ee3830, 0x3ceaa8fa, 0x21419068,
- 0x7fbe3d75, 0x71fe625e, 0x3a6f41df, 0xd10d5561, 0xde4d739b, 0xd40f4869,
- 0x009f0893, 0x760d78e3, 0x2a1a9a60, 0xf8c20be7, 0x88e1aae3, 0x5dfd0667,
- 0x2ddef26e, 0xe387f426, 0xea4ffbaa, 0x4882ffd7, 0xfeeabcf3, 0xbfebf587,
- 0x15ff5232, 0x977979bf, 0xf4a9f80f, 0x803a4f57, 0x5267d999, 0xe80ba253,
- 0xc1b5be5e, 0xa9f97281, 0x5d2073e4, 0xd38bf33f, 0x16e7c923, 0xb74f9751,
- 0xff11e422, 0x7e9d1f10, 0xd03bd1e9, 0xd5b73aae, 0x607c52ac, 0x0160259b,
- 0x5d6caca6, 0x9b63e5c2, 0xafaf18e5, 0xb3f902fe, 0x2fa8cdaa, 0x32785f4a,
- 0x40cde311, 0x0e7fcd49, 0xb9507f90, 0x68852fe5, 0x5eb15577, 0xdfe17bd2,
- 0xe3e7f8e1, 0x2f981ec8, 0xaf7ff4c7, 0x6955f3ef, 0x7d6aa978, 0x84910bf4,
- 0xcdfc83a5, 0x9a25f6f0, 0x68a4ffbd, 0xdf38a78f, 0xf9113644, 0xf307c74c,
- 0xeebf7b73, 0x8f73a7c5, 0x5b9d3c01, 0xe421ddfe, 0xd727f284, 0x165a677b,
- 0xe735fcfe, 0x0dd4f2c0, 0xaed4317a, 0x6767d7d6, 0xeca7e69b, 0x39b965e1,
- 0xb03f40e0, 0xe5d9b37c, 0xfcbeba43, 0xc19e2ffc, 0x1607ccb8, 0xbfe870d7,
- 0xef83e5ec, 0xb2f500dd, 0xdbf8e61d, 0x211434f8, 0x2a974831, 0x6c62bbf8,
- 0xbfa50e90, 0x473b283e, 0x8e3fe7f1, 0x6ca3d20b, 0x8d993ec7, 0x298f8fea,
- 0x0ee4fb2d, 0x5a5d0225, 0x3fa2158e, 0x57e2f751, 0xcfafea32, 0xe0d8175e,
- 0xdcf8088c, 0x62ec907c, 0x51d113c4, 0xdd1f53a3, 0x0157dac2, 0xeabf505d,
- 0xff7f0a74, 0xc7fe9a2f, 0xc4399cfe, 0x86bcafcf, 0xb67f28fb, 0x25fe70b8,
- 0xc0e83caf, 0xaa929c79, 0xdb3f5f39, 0x7186e890, 0x44becc4b, 0xbcfe4a95,
- 0x121fb9e4, 0xf23e2dbf, 0x7f8a44c3, 0x89b27730, 0x325f056c, 0xa6d16fce,
- 0x62bf34d9, 0x2bbe25e6, 0xe0f45679, 0x8959e0fe, 0x4111df4d, 0xae24522e,
- 0x5b354f8f, 0xa7654d70, 0x7dc0e170, 0xff45b785, 0x2dff8a56, 0x0fcaf8a5,
- 0xb620fdf5, 0xad67ea8c, 0x885f4e9c, 0xac1abefa, 0xbafca13c, 0xd23b7565,
- 0xf710f4e7, 0x571b8c60, 0xe1a7c931, 0xfd08b843, 0x0da6478a, 0x4e61f4e6,
- 0x0efb4f29, 0x7c14fdf4, 0xcddbed8e, 0xe1ae5b6e, 0x2331763b, 0x6d72fe38,
- 0x0a3b807c, 0x8953d5ed, 0x9845ff60, 0xafa4a15f, 0x85576037, 0x7c8857f0,
- 0xf2df7973, 0x5d6f9708, 0xa633fdde, 0xbebffbe3, 0xbf07e5c3, 0xe0057b43,
- 0xf7a60c0a, 0xa40966fb, 0x102c2c0f, 0x98b7ae49, 0xbe36b935, 0xe004f9d7,
- 0xeddd7096, 0x3fec17e3, 0x764ff08e, 0xf87af16c, 0x565f442e, 0xfe8e78e1,
- 0xbb72e9fd, 0x04ff9358, 0x6cff28c9, 0x81fb9713, 0x8f1f09fd, 0xbffd984b,
- 0x15e50678, 0xaff713e4, 0x7b365fcb, 0x6f9fde70, 0xbddef03f, 0xb79fa720,
- 0xd46a72e8, 0x5a72e19f, 0x8b0273b2, 0x639fa724, 0x3924421a, 0xe511e785,
- 0x3e20e954, 0x4fe947fe, 0x85377f1d, 0x87d74fe1, 0x5c31e103, 0x7459fe1f,
- 0xf087d446, 0xd7961de7, 0xbe74ff9f, 0xf4adf9d3, 0x29431597, 0xa5f3a63e,
- 0x7c7d77ce, 0xbf5df3a9, 0x7f01a378, 0x182defe1, 0x3cb80183, 0x4714cdbb,
- 0xf7c3df28, 0x43bbe17f, 0x4f09e3a9, 0x58c65a6e, 0xf8d4a1d3, 0xac3fbad0,
- 0xded612de, 0x84f7561d, 0xd586f7b5, 0xcbed0dab, 0x3cc80edb, 0x686025af,
- 0x8678ae27, 0x1228327d, 0x5fb9fabf, 0xec85fada, 0x7a50be43, 0x4af37be9,
- 0x3c63b3e6, 0xf148af7c, 0xf1c01e91, 0x67a7182a, 0xf31f867b, 0x3c6c1a24,
- 0xf6a3d4ee, 0x6c5ed03a, 0xdef5e588, 0xea157904, 0xaf79fd3d, 0x7af5c78d,
- 0xd88ebd3c, 0xd8edfb10, 0x76f4911e, 0x8f4d9f87, 0x8ac267e4, 0xc1d47242,
- 0xe3cf7a06, 0x2544d3fd, 0x5fc6057d, 0x8617449a, 0xef6a8a74, 0x419e6071,
- 0x3bac9ecf, 0x45f3c0e7, 0x8db48a6f, 0x7b7683d8, 0x2dc7920c, 0x77f88725,
- 0x53df329f, 0xbf7e3193, 0x4579fb87, 0x11ecc36b, 0xa9f896b6, 0xa32e5958,
- 0xecbf053e, 0x82ff71b8, 0xd6a945cb, 0xe326c95f, 0xdc7bfd7b, 0xbdfb45c1,
- 0xbdf18b74, 0x34078b57, 0x863272eb, 0x71fcd18d, 0xf4d28f1e, 0xe73134f2,
- 0x8f4039ce, 0xc322c39e, 0x7b33fbfd, 0x99c7a244, 0x9ebf7ced, 0x23d7f6e2,
- 0x3e92f77f, 0x89d4f1d4, 0xac0f24f2, 0xfd5f3aaf, 0x9187bcaf, 0x987d766f,
- 0x3b2833fb, 0xfd907d77, 0xe6ffac5b, 0x590ff4fd, 0x5e53f6ff, 0x493ed1b7,
- 0xe276ebcf, 0x7fbd9ef7, 0xeb187f4c, 0x9f142dbb, 0xabfd79ee, 0x9e9fe45c,
- 0xd4129695, 0x80433d77, 0xec1f68fe, 0x83b72afd, 0xa27ad7d6, 0x99251fdb,
- 0xfe7b47db, 0x8f10b1f6, 0xed0acc25, 0x49a3d786, 0xb35eaa9e, 0x67ad3c51,
- 0xa17957ef, 0x9d77ff76, 0x7fb6a54f, 0x736763d9, 0xb17c2276, 0xeaa7df7c,
- 0x5f3fd7b7, 0xad17f98b, 0xf085e4fb, 0xbeefca7e, 0xda3d45c9, 0x43db93b3,
- 0xe78ee6dd, 0x68ee7f70, 0x6695dcfd, 0x0a3773c0, 0x9bac0a55, 0xa014cf0d,
- 0xcbc7f4dc, 0xbc271437, 0xfcf47c52, 0xc10f835f, 0xdd9df5cd, 0xde70156f,
- 0x21fc7f5f, 0x2dd785ea, 0x7cfa97c4, 0x25a96f3f, 0xf372e57b, 0x9c799876,
- 0x799dffe4, 0x992b810b, 0x3ff328f7, 0x2d7fbd37, 0xe12e8939, 0xcf9fd072,
- 0xf5443ef7, 0x822eed97, 0xfdf90af7, 0xf9f27ff6, 0xefba6b7f, 0x2e3bba04,
- 0x7ff2ef3f, 0x4c0f79f2, 0xd7ef37f7, 0x7e62aee8, 0xbeefd54b, 0xadbef821,
- 0x4ffb5b9e, 0xcd03ef2e, 0xd7ebb75f, 0x994d5c98, 0xaf439f18, 0xc569d601,
- 0xc311b33e, 0xcc466b85, 0x14ced154, 0xf52bf6c3, 0xfb99af72, 0x5bee224d,
- 0x086f9c62, 0xcd31f38f, 0x3d2da28f, 0x8a525a18, 0x94958ec9, 0x96bedc55,
- 0xc06eed5c, 0x176b9acb, 0x887728b8, 0xc5ea3d8d, 0x1764da7a, 0xfcc3afc5,
- 0xb9817ac9, 0xa56fb005, 0x8c396f6b, 0x84798dfe, 0xa5c96029, 0xab9618f2,
- 0x59a4b8b5, 0x8f7e0d95, 0xdbac6392, 0x45bac69c, 0x38cacfeb, 0xe624d6fc,
- 0x38b4f8c7, 0x798abf72, 0x8918e26d, 0xb1b75009, 0x17fa1f26, 0xf7e32496,
- 0x1ec0311b, 0x5abdcf12, 0xe1f6f63c, 0x1bbb6c71, 0x44d238f1, 0x2e4a6b71,
- 0xfcb8bc25, 0x8d9e786b, 0x55d788d5, 0x094f88ed, 0x7f6e5ffd, 0x34ccdf91,
- 0xbad2597f, 0xdc984690, 0xcd3b6336, 0x9d2cbe4f, 0xcbd25d38, 0x332d3a35,
- 0x43a745d0, 0xe818fa04, 0xdbf9e3a2, 0x2e9c27d2, 0x6fdff8e1, 0x07fe1276,
- 0x974e97a2, 0x50cdc534, 0xbf9acd5e, 0x49fd1530, 0x1879a7ac, 0xfe6b33ed,
- 0x66ef1482, 0xea93a43e, 0xf42f4862, 0xb7e002db, 0xf3fb7efd, 0x7aea2714,
- 0x081dd8e9, 0x456fd94f, 0x75fc0566, 0x00b3b76f, 0x65f92f7e, 0x5b4b43f4,
- 0x33fb8a45, 0x57779029, 0x6eafbec8, 0xcafd97f7, 0xdd29f34e, 0x06dff169,
- 0xfaee97df, 0xb0ec9724, 0xd7e4bd95, 0x38125ef8, 0xb91d7ddd, 0x2a5bafb8,
- 0x9c23ff71, 0x9e65625f, 0x3bb9d027, 0x6dc60e7a, 0xdf3c6d84, 0x1ee5b4b6,
- 0x7f90c5b3, 0x91dbd666, 0x28bdf05e, 0xc213be50, 0xa9e79a17, 0x2f9d1dfb,
- 0x36be1c0a, 0x76f31fb3, 0xe8edb74b, 0xe953f8c6, 0xc30b8b51, 0xbedb55d2,
- 0x298dfda0, 0xd1d97abf, 0x68b6fe41, 0xf3f43f88, 0xc489b7fb, 0x15ad951f,
- 0x9d4087e4, 0x25b2a2f8, 0x72ebfc72, 0xafd969fe, 0x01f2eef6, 0xfd7ecb0a,
- 0x5be30382, 0x3ab7dba7, 0x76dfffc8, 0x3f5bb8e9, 0x91e5bf3f, 0xa7f9fa4b,
- 0xbfe01ff1, 0xc58720dc, 0x220db649, 0xcbe0047f, 0xadef948b, 0xcbd95bf3,
- 0x38c39f67, 0xcfcee774, 0xcb78439f, 0xe7cbfbff, 0xaf609fd0, 0x88add4db,
- 0xa5de9797, 0xddfe9e38, 0x9dc7992c, 0x817c5fbb, 0x1fdd9fe2, 0x7f01df80,
- 0x4a9ef7ba, 0x7bb27f47, 0x1889d7c7, 0x77be592f, 0xef9c60da, 0x0ca757f2,
- 0x88f41166, 0xfadf225e, 0x1afe20af, 0xad03af4e, 0xe9efc807, 0xdfa37a02,
- 0x69b717d9, 0x3071e0a9, 0xd9af16a7, 0xddce391e, 0x7ad33e2f, 0x8d379dd7,
- 0x72ecd2c7, 0xd3882bb2, 0x1c7403bc, 0xdbf4057d, 0x7fe688fe, 0x175fa646,
- 0xb4e803fe, 0x677e8c2c, 0xfcfd175b, 0x3ad77c19, 0x4d38c068, 0xa6f00ae0,
- 0x27bfd1c7, 0xa3227fbb, 0x25fced7c, 0x6e90c5c5, 0xbb44c1b7, 0x8e9b3e5f,
- 0x9a9f0ffb, 0xe7e7ef7b, 0xc62a2c32, 0xbef74a1b, 0xfdd3f24f, 0x538a11ea,
- 0xdd9e2d33, 0xf0fefacd, 0x5396a3f8, 0xcec5b559, 0xfe1a3be3, 0x74e3fe31,
- 0xce2d73d0, 0x8f58f9c3, 0xf7140cff, 0xde799569, 0xafdf1e88, 0x16a1f2d8,
- 0x4bd2094f, 0x3a748498, 0x08fdc976, 0xe22a0f1d, 0x1c686261, 0xad7c7233,
- 0xd1adde2f, 0xf187e90b, 0x2538becb, 0x6e30d3d4, 0x67de17e5, 0xf741f411,
- 0xecff1e66, 0xa3ce4736, 0xbf9ae3d2, 0xff53970a, 0x2f33c595, 0xc5b7ff07,
- 0x52765f8f, 0xea78e1bf, 0x8f5910bc, 0x75f32dbf, 0xc5f7aaff, 0xbe4305ca,
- 0x7bc9b941, 0xa2b1f904, 0xcfcc98f5, 0x52f3f0a5, 0xb53b7cfa, 0x97ced1bc,
- 0xad778a44, 0x7a40396a, 0xe85f5c3c, 0xf0e1a6fb, 0xade0d09e, 0x44ebe36c,
- 0x5fbb4ee7, 0xf73a7e81, 0xae7e26ef, 0xe28c7edc, 0xfdb6876d, 0x5908ee5a,
- 0xf09d7157, 0xf9dfc087, 0x1e5cbeca, 0xec79e5b7, 0xd19ce3e1, 0x9ed561f4,
- 0x6d54e3c8, 0x4e30c2ff, 0xe645af99, 0xc7a5fdeb, 0xefb92d3b, 0xb74efec1,
- 0x79e6199b, 0xa7116e9e, 0xf5173a47, 0xea6eb6ae, 0xbd707ee7, 0x23fd7ca4,
- 0xf8cc5cfc, 0x1f28a3b7, 0xe991f97e, 0x63c4c61f, 0xfe878409, 0x9f396b5a,
- 0x9dc4feb6, 0x3d6ef48a, 0xeb88af72, 0x6fc42ed4, 0xf79f9d88, 0x3b14f54e,
- 0x8fbc85e8, 0x5d91e33c, 0xc4cdf5c3, 0xfc0326a3, 0x5c60ce30, 0x1fa1ea07,
- 0xf982a73c, 0xe88f086e, 0xf08e9c28, 0xb549aa88, 0x61e7fd09, 0x5e743c56,
- 0xacd7ef40, 0xb003cf1a, 0xd89ce30b, 0x1e4cd24f, 0x8bbe4c47, 0x3cfd3e97,
- 0xbf94714e, 0xa059e60e, 0xf02cd378, 0x7d7d927d, 0xe78641c6, 0xde5126bf,
- 0x78c59676, 0x554bac6e, 0xdfd0267c, 0x596ce4cf, 0xf949d937, 0x4258d707,
- 0x20580ff3, 0x6f51f917, 0x587defd7, 0x7e1a427e, 0x1a88fd02, 0x7e5a597c,
- 0x21d610c2, 0xc9bd7da0, 0x0e27cfce, 0xf84de255, 0xbd9af3fd, 0xec3f9fa9,
- 0xec315e77, 0xcee5e29c, 0xc94fc627, 0x05d43a5f, 0xcf7ab4fc, 0x8f5fcc14,
- 0x477f27bf, 0x12798aaa, 0xe7829e7f, 0xc85fe257, 0xf50c931f, 0x9c1fab13,
- 0xc8fff54a, 0xf50e931f, 0x8dff1a6f, 0xca04cbd7, 0x3d582d57, 0xebf22a7a,
- 0x2cf9cb55, 0xce5188c0, 0x75bc40ef, 0x7bba3e79, 0x1ff31391, 0x5f8e657a,
- 0x4376c1e6, 0xa5bc7126, 0x40ed1f29, 0x75350d3c, 0xfe7f22d4, 0xb157ef7c,
- 0x4c9c17a8, 0xaca8fc25, 0xc1fa455e, 0x2f1749a3, 0x9e174791, 0x93eba64f,
- 0x01f78acd, 0xf991e384, 0xe05ce823, 0xad332533, 0x98cf5f3c, 0x78d4c0c7,
- 0x469167a2, 0x1ad3844f, 0x58bf8f92, 0x5cfcc9f4, 0xafa6934c, 0x9e38aaa6,
- 0x2f172be0, 0xe1edf75e, 0x4be7507a, 0xc8695ced, 0x1087c679, 0x7de29f5e,
- 0xffd092c8, 0x161de33c, 0x9f7c0acf, 0x1d3e7c5c, 0x9f3f5bf9, 0x91ce7e18,
- 0x48a6bd49, 0x76b35ff6, 0x782071ce, 0x2aef563d, 0x77f3371c, 0x41879dce,
- 0xc91746be, 0x1ccd4c2e, 0x827c62bd, 0x5215cfc4, 0x4695439e, 0x971324bf,
- 0xa310f643, 0x8b1ed67d, 0xb9bf46e0, 0xf49541e7, 0x6dd15a77, 0x44f557e4,
- 0x3e60b467, 0xfcc3cf50, 0x4c66295c, 0xd90d1ca3, 0xbf401313, 0x5ce0e40f,
- 0x339c1c98, 0x71c673ae, 0xdb3a2e7b, 0x553fa83a, 0xb00c0feb, 0xe0b9e0c4,
- 0xe5eb911e, 0xc1271a9e, 0xf6f98431, 0xa57efae1, 0x18b56de3, 0xde02fdcf,
- 0xe8bc405f, 0xc0e5ff78, 0xa3457bf4, 0xe8912bdf, 0x74fe7e17, 0x6bfbc5be,
- 0xf8aa7f6c, 0x15742ad0, 0x869dcfc3, 0x6a4ab5d3, 0x78ae88da, 0x682f9ee2,
- 0x36e9d19d, 0x412b857a, 0xe3a0641a, 0xe8efd8eb, 0x10985f3d, 0x4f7e9d5e,
- 0xfdef900f, 0xcf5f0b07, 0x9c4bc7c2, 0x8de291d3, 0x1060feb4, 0xcf58212e,
- 0xf8d1e6b5, 0xde3c4d83, 0x10bdbfd3, 0x7fd03e71, 0x30f2a5e6, 0x2fde5573,
- 0x50fdffe0, 0xf110ffbe, 0xfe22223f, 0x03bc463f, 0xf6c63ffe, 0x4fff8057,
- 0xdd7f852e, 0xf4d32fae, 0x2bee1942, 0xc5fcff01, 0x13313339, 0x15142dc6,
- 0x5b25ffe2, 0xd21f6d45, 0x62725b7d, 0xb92c8f50, 0x199f7abe, 0xb3c970f8,
- 0x9169f102, 0x73fd5e76, 0x784b5ced, 0x1cf15f5e, 0xcbc9e91f, 0x49f9f7e7,
- 0x336d950f, 0xe410bf3e, 0xc7ca74db, 0x93f3f1f5, 0xe11726a2, 0x68a33ff8,
- 0xd628a2fa, 0x0e9c2ed0, 0x864daa43, 0x29e4f03c, 0x9f90fd7d, 0xbe726497,
- 0x3fb5f14f, 0x07c61998, 0xf8fc52dc, 0xbc63e200, 0xcdfb1530, 0xef56e4d7,
- 0xe30ae86f, 0x33e19f3a, 0x6acbfb9e, 0x1bfb9e34, 0x686294de, 0x4c86cd7f,
- 0xfe91fbc3, 0xafef0d6b, 0x50d636db, 0x8372d51f, 0xb6e8fda1, 0x4c7d4302,
- 0xfb4316e0, 0x1a678771, 0xefda13ea, 0x789fb435, 0xfde18174, 0x86a51df5,
- 0xba7e37f7, 0xa9bf50cc, 0xed0d5ff7, 0x5eb88b03, 0x94935fdc, 0x740ae786,
- 0x2a5fecbc, 0xbe7c549b, 0xe6a4db34, 0x744f3e86, 0xccb1733b, 0x357fa373,
- 0xb14cbc90, 0xae85a726, 0x6cccf9cf, 0xac536bd0, 0x55817ac6, 0xe07497e3,
- 0xcdfe2017, 0xa55ca356, 0x026bcf56, 0x2ca59bb3, 0xd2f94619, 0x58b75f20,
- 0xc5bb7eb9, 0xedfa657a, 0xaa7f6c4e, 0xece74032, 0x444be5c3, 0xd2a2caf9,
- 0xcca9fb47, 0x1b96f945, 0x4d3e466d, 0xccaf401a, 0xc3cf1ab3, 0x9b61ea8b,
- 0xfd139064, 0xd0a8f9f9, 0xdbe2c2e7, 0xa0676f28, 0x05a4e57e, 0x7d016eb7,
- 0xa97b2729, 0x9aaf9fd4, 0x97988a63, 0x3bf590f7, 0xfa1b49fa, 0x210f4fd9,
- 0xde92bb7e, 0xccf30a7e, 0x92f5e72a, 0x316c94bf, 0x775825e2, 0x5479e60d,
- 0x508e7e4e, 0x54dcffe5, 0xae2b78d3, 0x173cfaf7, 0x1133307d, 0x06d203f3,
- 0xd55e9ff0, 0x4d5cf1e6, 0xc345adc9, 0x14d53fb0, 0x7a45bf7a, 0xfd10aaa0,
- 0x1e5aa198, 0xc8a653f4, 0xd53f4af9, 0x0a8c19fa, 0x5503ed14, 0xaba0fb21,
- 0x048723f8, 0x9377f8f3, 0x17c8a7f7, 0xe7b7460b, 0x6ecb73f1, 0xabb24cd7,
- 0xd75f8254, 0xe78ae943, 0xe92bd429, 0x66731249, 0xf06787f4, 0x06636f3c,
- 0x338fafbc, 0xf7aa14b9, 0xe59e380a, 0x820d8cc7, 0x5bffeaf1, 0xf7eaf824,
- 0x3cf94f5f, 0xe29aa516, 0x993cfaa7, 0xc7afdfb6, 0xcd26cf8b, 0xd63c418a,
- 0x6e77db5f, 0xacfd6187, 0x7ec76de2, 0xd337aecf, 0x8205f5b8, 0x6f3ebde1,
- 0x741dc369, 0xe15d2b1e, 0x79862ef3, 0x3496dc23, 0x73fd570e, 0xb8234b02,
- 0x43d2f7fe, 0x8aecbfe8, 0x0dbc6176, 0xe889b1f0, 0x6738ceed, 0xf30f27d2,
- 0x34a418aa, 0x25fb21af, 0x96fa1fb2, 0x4cdbaf95, 0xf688959d, 0x4635f254,
- 0x66f5c5b8, 0xc51707f2, 0xe0af942a, 0xd1a159af, 0x55ef38d5, 0x9cef3349,
- 0xbdd4f00b, 0xfd4c3223, 0x2d347671, 0x15df043d, 0xfcbb46b7, 0xef78fece,
- 0x01387272, 0x6e10b7ee, 0xcd214371, 0xdc21da9b, 0x33d8173f, 0xde77c819,
- 0x14ff44e9, 0x977dc313, 0xd3fff870, 0xefc4e3ca, 0x879a5558, 0xeb7c549c,
- 0x16584196, 0xb51ddc91, 0x7fceb80e, 0xfcebe568, 0xeb08d687, 0xfdeee5fc,
- 0x7ed39f28, 0x6dd14b08, 0xeadaecd2, 0x197b50ec, 0xec49d6f4, 0x318baf57,
- 0x7ec5ce3f, 0x3ccbb607, 0x9719d94d, 0x1ed0cbb7, 0xedd3fe43, 0x8d5abfb1,
- 0x9e886476, 0xb3d34afd, 0x9ea15d5f, 0x4eed80bd, 0x68881bdd, 0x91c824c7,
- 0x1b38dcf5, 0x2a957fc7, 0x1be3ca33, 0x6d9f9e20, 0x0e1f6c8b, 0xce5d0eb4,
- 0xd68cc8cf, 0xefd754f9, 0xc560dfdc, 0x9c2fed32, 0x247fe0d9, 0xe329f71b,
- 0xedde5187, 0xaea4fd40, 0xf10d83f8, 0x886de3ab, 0xc04f88cd, 0xf9c6d3a3,
- 0x648b69c4, 0x1e03960f, 0x0e3c064d, 0xd903f6c7, 0xdfad5783, 0x6ee78c4b,
- 0x837c35ba, 0xbc71979e, 0xce3ebbae, 0xe545b8c3, 0xe7a473ec, 0x399c7aaf,
- 0xf74475c6, 0x011c61bf, 0xd77ddfe7, 0xb7716b7f, 0xd5178a0e, 0x0c4d7abd,
- 0x0a2aa7c6, 0x9586f4fa, 0xa49985db, 0x5976bb07, 0x576708dc, 0xece7cf1c,
- 0x10f135da, 0xaf3e39c6, 0x85299c39, 0xaf5d2dd8, 0x4333c91c, 0x8f3b5d7f,
- 0x209449e4, 0xd17e27e7, 0xfc5c57df, 0x128f3ccf, 0xc7d0273c, 0x0ebe566f,
- 0xf8f1b7ad, 0xc798d3c9, 0xf7b19a36, 0xfaf963a3, 0x1c7a6891, 0xe3bf479f,
- 0x7f7ea1f3, 0xc7e57054, 0xdd262b00, 0xab664c55, 0x00a68de5, 0x6e0a8f96,
- 0xbe55e311, 0x4d3cfc91, 0x911b1652, 0x4728fd01, 0x8e0803db, 0x8dd7a3a3,
- 0xa7ea29db, 0x0b2c3eea, 0xc402ef14, 0x2baf5c7b, 0x37fc7d09, 0xa1b38d87,
- 0xe14d215f, 0x7e77b77a, 0x29ef1f94, 0x8fb9344a, 0x6767aa80, 0xc58c2f0e,
- 0xe68b7ff7, 0xd258f2f2, 0x8e5c2689, 0x38a03970, 0x5a669bd4, 0x710d96df,
- 0xef822f27, 0xe7884d97, 0x9805e97e, 0x9639c87d, 0x0967e3c7, 0x00b90714,
- 0x14e78178, 0xb53e02fa, 0x3317cc4b, 0x89b0f416, 0x0bf055b9, 0xee4293ec,
- 0x68ffc1d9, 0x4d60fc76, 0x4d38f6ff, 0x45e0333e, 0xd5db1976, 0x5c0cee09,
- 0xfc81774f, 0xb4fa030d, 0x7ca958d5, 0x184d46ad, 0xa7b8f206, 0xafea8926,
- 0x0ca938d7, 0xe7a08cd4, 0x545c6bfb, 0xa7b5368f, 0x552c7ad3, 0xfe879baf,
- 0x0b12fdf5, 0xbc23b7bd, 0x8e567bc4, 0x97f9c887, 0x0093e62e, 0x3d352fae,
- 0x38d6fb52, 0xc6a7afe2, 0xfd31d400, 0x8ad9ffbf, 0x054d643f, 0xa3fa983d,
- 0x415359c3, 0x78129f8e, 0x181e02fe, 0x552e748e, 0xb7329f2f, 0xf0a9a2c4,
- 0x4df31b6b, 0xc8bcc24d, 0x8e153fde, 0xe8f6cc61, 0x1d4ea69f, 0xfdc7f309,
- 0xf6c614fe, 0xc7abdeda, 0xfba9d873, 0x818bab3f, 0xfc6dc8f9, 0x82899f3e,
- 0x7d4056a7, 0x0bf39b33, 0x98b53c93, 0x3773d9cf, 0xbefee273, 0x1b5ece3e,
- 0xdb7613b7, 0x51399db8, 0xe6c1fce0, 0x411e5aca, 0xbae86e6f, 0xef3ede11,
- 0x8f74d7c0, 0x2fb78c0f, 0x2f5e30d5, 0xfa0711c5, 0xd7ff752e, 0xe95c8eb4,
- 0x491f3d77, 0xc4847cfc, 0xe6ba2bf3, 0xfda66e26, 0xba1f6878, 0x4723da8f,
- 0xd2ded7b6, 0xed0681d6, 0x659fb7be, 0xa68372f0, 0xf5c62457, 0x05d16bff,
- 0x61b947bf, 0x5fda38de, 0x09e2d3aa, 0xe57a3a93, 0x2f7e76f9, 0x13d43e5c,
- 0x3c04784e, 0xd1a5d70f, 0x1e605533, 0x6048ffcc, 0x28028433, 0xdbcf36dd,
- 0xc2d24fd8, 0xd197be4d, 0x7165d85e, 0xe3a3d9a2, 0xd903eeab, 0x6121fa8a,
- 0x8fda31cf, 0x643a13aa, 0x8f97f7a4, 0xcb714d7c, 0x3275733a, 0x1b176dd5,
- 0xbdb4feb0, 0x99d6237a, 0x6fa9ebef, 0xd60c3f00, 0x13e3e1ce, 0x90bb63d4,
- 0x3b5829e8, 0x7e06ef57, 0xf5e665d8, 0x4b391f2f, 0x5ccbb1fc, 0xe18d9f3d,
- 0xef987af5, 0xaa6f58ae, 0x52905409, 0xe1fd65fb, 0xb7aeb09b, 0x77da92ff,
- 0x3f6e54db, 0xa40cde2a, 0x855d5f7f, 0x2ea43dba, 0xf2b33af1, 0xc55f9f52,
- 0x7f29af81, 0xe70f72b8, 0xce1bc447, 0xc3cdef13, 0x7a8ce975, 0xa4eb51d4,
- 0xd73673b8, 0x9f0301d7, 0xb753e7e9, 0x2a2cbc98, 0x085ecf44, 0xce42ff5b,
- 0x84a8b1d9, 0x38b4fe90, 0xbb033a76, 0x6f182b34, 0x2a2e64cd, 0x950f3187,
- 0xee96dbd9, 0xbb2db447, 0x7a89d5af, 0xfad73e2b, 0x68e89780, 0xd09e1ff4,
- 0xe8fae2f4, 0x01a31bfc, 0x7782f59e, 0xf17a888d, 0xe74ab365, 0xb2243a2f,
- 0x35b53b37, 0x5330ad8c, 0xf73b5cbd, 0x5de95e6d, 0xeef51233, 0x19ab9322,
- 0x4f0cb3d7, 0x2fbe19be, 0xaae19ddb, 0xe7bcc165, 0xc496d8b2, 0xef304ab1,
- 0xaa3faf59, 0xb546d9f1, 0xd2f786c9, 0x9543fbe8, 0x71d2eb6d, 0x7db3fb7f,
- 0xbd3c901f, 0x7c41951f, 0x447ad15c, 0xbf69daf6, 0x29f3c64c, 0xd6fad99f,
- 0xbef75a3f, 0x0b74196c, 0xeb2ff5ea, 0x79b8744d, 0x06f43d20, 0x38373fe8,
- 0xac6a87c8, 0x5dc2fe54, 0xde9a2d7d, 0xd3295105, 0xbfb4606c, 0x9156e990,
- 0xb9ade68f, 0x7c0ac1a6, 0x8eac82f4, 0x179b3e44, 0x5b7c4b95, 0xbe722b16,
- 0xdd07b964, 0x0dcfb692, 0x6535d4f5, 0x3c53bed3, 0x6f68c8be, 0x88526d54,
- 0xc80ec00f, 0xdca83e47, 0x7ee1f260, 0x4edac9a2, 0x45e77de7, 0x368fcd31,
- 0xaf5c4f9e, 0x6cdf3be9, 0xdcbddf1e, 0xf392c539, 0x511e7451, 0xe51fbfaf,
- 0x9128be24, 0x55ffb47c, 0xe741de72, 0x38fbbf18, 0xc879c356, 0x0428e3fe,
- 0x794e3e87, 0x57d21c70, 0x27ec1fe5, 0x6b8df83f, 0x4dd67b75, 0x3be5ac71,
- 0x9b05fcb4, 0xf3f6307b, 0x1827a6b4, 0x7780b1fa, 0xeeafa329, 0x1ccf4093,
- 0xf933d3ec, 0x90d3530d, 0x6cf7c1be, 0xb90f4192, 0xc1d3a025, 0xfbeead28,
- 0x51f6e47e, 0xf533ed61, 0xa986ccfa, 0xf3c3fb93, 0xb7582db4, 0x1be97b42,
- 0xe11d5f4b, 0xa1f573a3, 0xe3e9c5fd, 0xe9fd4bdf, 0xb51a97fc, 0xf80fa0f0,
- 0x27ac60ef, 0x7a7cf31f, 0xca273367, 0x8d4966e1, 0x21d08572, 0x37af8a35,
- 0x35afe725, 0xf7883fe0, 0x4ffd035c, 0xfb0d38d5, 0x968b8b8a, 0x549879d1,
- 0xc7cc5e9d, 0xca6d77cf, 0xfe27ec32, 0x16ae387f, 0x7000f70e, 0xc307fd4c,
- 0x5e30c231, 0x031c8e10, 0x870b577c, 0x7a6b3b18, 0x8f6bda06, 0x280f2898,
- 0x66b3e4d1, 0x6ff65da2, 0x0ca78a26, 0x880f3c67, 0xfb0de329, 0x2c7b99b4,
- 0x9efe31f3, 0xd2c3b129, 0xb7279458, 0xa9d716b3, 0x5f64489f, 0x39ab73c1,
- 0x726e870e, 0x204ffde3, 0x665fd495, 0x1f82b7b9, 0x82fbe6f2, 0x70d33efa,
- 0xbde3e595, 0xe7a39ba0, 0xfb8d18df, 0xaa1e7366, 0xe7983cc2, 0x352ff195,
- 0x92bc8330, 0x2c20d21d, 0xabe33b25, 0x701b87a8, 0x147076bf, 0xf6045bb7,
- 0xe4e1c370, 0xbcb9ef48, 0xf0f35b9e, 0x341b8c34, 0x8b5e74af, 0xcdb353fe,
- 0xf31fb2df, 0xe8531e76, 0x47acd6de, 0x50998dfd, 0x6899d717, 0xfd6314bd,
- 0xdf719adb, 0x176cc9fd, 0x68cd11da, 0x47fb60bf, 0x566bf214, 0xf0d338d5,
- 0x6d3a927e, 0x76b2d81d, 0xc1798ab2, 0x87148af5, 0x732addeb, 0x773c5cf5,
- 0x8dd1ee31, 0x51ebd60d, 0x071ab98f, 0x949ebca9, 0x339aeb8c, 0x7b463ad3,
- 0xae68c80f, 0xb1a8a675, 0x6ff0fac1, 0x3d20fac0, 0x9dc1b1b3, 0x2b2efd86,
- 0x883bfad5, 0xe2178a71, 0xef68bc34, 0xd2f4fb33, 0xcbcc06c6, 0xf5836b12,
- 0xaddf30a9, 0x353d72cf, 0xfb47fa18, 0xc3e3e60b, 0x877b057b, 0xca4e744b,
- 0x603b6306, 0x9991b67e, 0x0cd7dfb4, 0x2bef117a, 0xdfc91dee, 0xf234fbeb,
- 0xd3ed1370, 0x6f5c7b60, 0xbdbcc96c, 0x57df833c, 0x8a15db20, 0x307ac037,
- 0x149ef315, 0xf371ffa6, 0x8fb6a4b8, 0x01f78511, 0x75a3f084, 0xf73a32ed,
- 0xdc661d69, 0x8cd3979f, 0x16798975, 0xaa27bfa0, 0x4637e7c6, 0x8341f96b,
- 0x6dda0a58, 0x133e4dc3, 0xfcc91bb6, 0x02c75e54, 0x628d8f64, 0x8d1f541d,
- 0x1e16635e, 0x41d2725b, 0x2dcc71ab, 0x47aa38f2, 0x71313b44, 0xf2471eae,
- 0x74be414e, 0x61766b47, 0x7e3fef0a, 0xf7ca2cc6, 0xcdef69f5, 0x313d8633,
- 0x7eb5e60d, 0x50ceddc6, 0x2f5f4efb, 0x48adfb75, 0x68cbf983, 0xa0bda221,
- 0x364575db, 0xe5984f5e, 0xc6147a7e, 0x26cddb11, 0x58ad9fbc, 0x6f16638b,
- 0xbb444fc8, 0x5cdf68ac, 0x44d787b2, 0xd16cbb73, 0x77b219fa, 0x9af79e14,
- 0xfe7f764f, 0x183109ba, 0xb9b06fa7, 0xfe47ae62, 0xdfbf23fd, 0xb1ed4af5,
- 0x0a6bc4e6, 0xc19b1e50, 0x8ffbc6af, 0xcadd9a0e, 0x758be418, 0x6ccec8c3,
- 0xc7d6f28e, 0xffcdbf42, 0x41d574ea, 0xf73667fd, 0x4e3823f8, 0x8f7f1443,
- 0x6f2126f7, 0x3ff7edf6, 0x1e8c5c2f, 0xfdf0fc78, 0x91b183fe, 0x43bdf1ef,
- 0xfed05fc3, 0xd9dd90f0, 0xdcc4f660, 0xcbbdf087, 0xead679e7, 0x112f5189,
- 0x86b4fb67, 0xd67603e7, 0xe64058b8, 0xbd62d1f7, 0xdd3f68a4, 0x22d25caf,
- 0x097cdc50, 0x3a3d226b, 0xeed5894c, 0xc5e631a7, 0x4dbd1696, 0x795b4bed,
- 0x42d632fb, 0xe17a75ed, 0x8301b5bd, 0xf0ce3a1d, 0xdcd11dfd, 0x78acdd6f,
- 0xfffb431f, 0xc4d91991, 0x1167c04f, 0x07e22df3, 0x31b977d8, 0x371faf9a,
- 0xf6c8db62, 0xb863f128, 0xe05cb87d, 0xc207b3e7, 0x9379d553, 0xde0a3d61,
- 0x7ad3219f, 0x49f9add4, 0xeb7c9387, 0x7ff9846f, 0x244af59f, 0x23bddaa7,
- 0x425f8275, 0x33befaf9, 0x2d1bdeec, 0xa6ba680f, 0xcb43fe25, 0x6b3ef9ef,
- 0xfd0dc379, 0xf402cedc, 0x9eed61dd, 0x48a41412, 0xafd01979, 0x3adc1f41,
- 0xddbf58c2, 0x39dfac65, 0x7d3df229, 0xb4d46b6b, 0xd6aa7bd0, 0xf38e700e,
- 0x575e8d2d, 0x0b12df7f, 0x0b7bebcf, 0xf9815ee9, 0xc17fb494, 0x1b14faf3,
- 0xd91ea0f3, 0xfb46cfbf, 0xbc8a5521, 0x55164319, 0xbde2efe0, 0x9f9d8af0,
- 0x17ff4037, 0x998a05e3, 0x97de0fb7, 0x1251f7c4, 0x3c5a493c, 0x633495c3,
- 0x1b87b7d4, 0x0bca2afd, 0xdc46d896, 0x27e60d77, 0xe8edef1a, 0x0f38fe8a,
- 0xcf9863fd, 0xe84f8c6c, 0x3e7d5a71, 0x2c7f28ff, 0x39cfbb5a, 0x346b6e9c,
- 0xa30ba8f9, 0x39d23d73, 0xb973df07, 0x87bb52f9, 0x43c129ff, 0x26896879,
- 0xb3ac171e, 0x9c528eb9, 0xea0ff344, 0xf306b8b4, 0x56ef5d7d, 0x1095ecc2,
- 0xed7d22ff, 0x39f5f5d7, 0x38f377e4, 0x156a2d88, 0x360dc3ae, 0xfaa66ebd,
- 0x00a6e6d3, 0x5aaffdf9, 0x831f189c, 0x6718ddef, 0x411dcdf3, 0x065d5d7e,
- 0x0e7bc14b, 0xb4cbb0de, 0x6abdd6fe, 0xd8f5c669, 0xdb76f36d, 0xba49f242,
- 0xf9d1efec, 0xf9fd08a6, 0xf90dfd0c, 0xf8c1fd76, 0xfd7788ad, 0xa7f61bfd,
- 0xceff2202, 0x691bf949, 0xa17b1fed, 0x42cbb89e, 0xf7fd4f71, 0xe7cfca0f,
- 0x7a8cfdd1, 0x4e14137f, 0xd51ace87, 0x8e5d8f90, 0xe507377a, 0x67f49da0,
- 0x8320cb45, 0x69f5d4de, 0x681bf9c5, 0x57482cbf, 0xb5212e2d, 0x38aa5e93,
- 0xbc68bfff, 0x349e903b, 0xf7e9124e, 0x3549c781, 0x38e0e3e8, 0xf7700c93,
- 0xc132671f, 0xdac38fa1, 0x9fe70ca2, 0xae3ccceb, 0x33986672, 0x1e823626,
- 0x83714bd1, 0x60ff70c9, 0x62b2e49d, 0x4eca75ff, 0x287f3435, 0xef005f7c,
- 0xf02164c5, 0x867ac1d5, 0xf30b72c1, 0x3d405e52, 0x072213f6, 0x62a5d9a2,
- 0xf8c262bf, 0xc62ef9e9, 0xbdb945fe, 0x33727d10, 0x8bd82df2, 0x7e3b583f,
- 0x49ec0f95, 0x4769ecc9, 0x93764aba, 0x6b68f313, 0x45c51315, 0x64ac92eb,
- 0xca12adff, 0xbd739455, 0x2243a95f, 0x8f7df438, 0x9f29e681, 0xc33cd077,
- 0x9ffb3bef, 0x76a14f1b, 0x3b57eefd, 0x0f93d730, 0x93545bfd, 0x4e5d450b,
- 0x2127d853, 0x47ef0ff4, 0xec4520da, 0x8e9dbc27, 0x6ce901ff, 0x3d2070ee,
- 0x88a5e3ba, 0x951b1079, 0x310798ef, 0x271f4c2f, 0xe00ecd1c, 0x238742f7,
- 0xe5f48323, 0xa5f50546, 0xdc9fccfd, 0xb4cbd24e, 0x7fafadef, 0x56a984e6,
- 0xbc6c4f9e, 0xfe206f57, 0x7d62f1d3, 0xf3c641f3, 0x7f94bd53, 0x483c3972,
- 0xfb43cb82, 0xe2297600, 0x425836be, 0x4938fc86, 0x354fe631, 0x63e21e48,
- 0x56d54df3, 0x5b4927da, 0x927dc569, 0x063392d5, 0x37ded8fd, 0xf983fec1,
- 0xbe793a35, 0x6bff786a, 0xb4661ef0, 0xc4531573, 0x06a379fb, 0x34baafb0,
- 0x77d9acfa, 0xf501fe69, 0x3775c1e1, 0x71524e2a, 0x399b35dd, 0x4bad03bc,
- 0xe103bf7a, 0xfc7dd1eb, 0x392c1bf7, 0xffae3f56, 0x4a35e3e1, 0xbc3e4f1e,
- 0x7078046f, 0xcd31acdf, 0x546df84d, 0xd5fd1525, 0xcc5111e8, 0x656fea1a,
- 0x67f7a2cc, 0xccf1e3e2, 0x8f8c6b22, 0xe3a3979c, 0x1df2b769, 0x186f1ded,
- 0x8f7f0e5f, 0x7c21e8e2, 0xe84ca9d9, 0x91bb97cf, 0xfc381317, 0x5aa6f7a1,
- 0xbc458633, 0x7f1fb27f, 0xde4df186, 0xf7e74664, 0x19b94306, 0xeed56efa,
- 0xb5c0aa43, 0xf2f4fc0b, 0xc2a6147b, 0xe477e6fa, 0xc939405f, 0xcfcfdf6b,
- 0xf026b4d1, 0xefb51e7b, 0x625dc7c3, 0x12c8fee7, 0xcc654abb, 0xf12ff751,
- 0xdb5a37f7, 0x5e789ca3, 0xb22e35b1, 0xd763931f, 0xb49a68f3, 0xb41d0873,
- 0xcfb7a14f, 0xcddcc79b, 0x1b3dc50a, 0x257fe0ad, 0xa9ffb5f4, 0x82023fb6,
- 0xf9dce30b, 0xf99aebdb, 0x7f3e51f9, 0xfb62ab8c, 0x5c8ec4c4, 0x740efc41,
- 0xf70cc6db, 0x3b5855db, 0xe7ce51b2, 0x7699bc9a, 0x68eaa718, 0x5bd62247,
- 0x4e9d3edf, 0xb71d6f7e, 0x47777b37, 0x3fa0dc53, 0x79f96a7d, 0xcc29f3f2,
- 0xdd3fa837, 0xad00a5ca, 0xd3e7e5ab, 0xcd1c6f99, 0x0b8d67db, 0xc2d3bfbe,
- 0xc8b1a4d8, 0x884f1c00, 0x30f4489f, 0x7a064ddb, 0x675e3c80, 0x7881e8d7,
- 0x76b7a3ea, 0x76a74bef, 0xcd71e0bf, 0xf72a615f, 0xa5fbf5d7, 0xe5f7678e,
- 0x5b7dd05b, 0x13f736e5, 0x3b0b4f78, 0xe6be5222, 0xfefc29c2, 0x771685c4,
- 0x0b57da0c, 0x6a1453ff, 0xf3937f69, 0x7f0d22fd, 0xf745cc9d, 0xdad6f80e,
- 0x984ebef8, 0x54f1967f, 0xc23fb8fe, 0x44da8bf7, 0x305f1bca, 0xbf61f145,
- 0xbf05ed79, 0xe2f9fdc4, 0x773a68c6, 0xae7bf0be, 0x2dd76893, 0xc4e6c27c,
- 0xfe597bdf, 0x327e6641, 0xc9fcbbf4, 0xdf07d50c, 0x24f0af45, 0x27a05d59,
- 0x8853db1f, 0x3083457e, 0x0630be7f, 0x0ec7cafc, 0x98b8c2ac, 0xcf94cdf4,
- 0xf47f506d, 0x615677b1, 0x18b7e9bc, 0xf63b26e7, 0x63b442dd, 0xf4d0425f,
- 0xc1c03ffd, 0x5a4d874b, 0xa9aac4fd, 0x4daff2a0, 0x2a293568, 0x562765fa,
- 0xc4d939e1, 0x1318f738, 0xfd8ef78c, 0x6fec42b3, 0xcea313c1, 0xe7f7806d,
- 0xbec817ed, 0xdf693a00, 0x014f370b, 0xb278bbbb, 0x582d975e, 0x86668f8f,
- 0x3339be38, 0xd9da3e38, 0x8b7c7aad, 0x718cdd45, 0xd505e3f7, 0x3fe82453,
- 0xceaea1c3, 0xc4d8c919, 0x1baaf9f5, 0xc476cfc6, 0x98f18cdd, 0x837dbed6,
- 0x1f18d5f8, 0x03de656b, 0xd37f7866, 0xb66e43e3, 0x07e36202, 0x30a8c679,
- 0x29d641ff, 0xf4dfa7ab, 0x4463e41d, 0x0d59f3bf, 0x939204f6, 0xf4d28843,
- 0xc2defc15, 0xe34ef93e, 0x1f57db7c, 0xc3cfc1d1, 0x5e24f5e8, 0x59195d6f,
- 0xc312dc5f, 0x2a35baf9, 0x4d66fbf2, 0x03be003f, 0x8b6d7f14, 0x08cf0ff6,
- 0x1f900fea, 0xa79224eb, 0x807f5c75, 0x93b4cd1c, 0xefec46dc, 0xab6bcadb,
- 0xab79af76, 0xf8c68ee4, 0x30c7ae82, 0xcce38682, 0xfa0d3bb5, 0x017daf39,
- 0x3151d7e9, 0xc9c7872a, 0xc53093f1, 0xb59847a8, 0xdf743b3d, 0x3cda77fe,
- 0xe3d3ae33, 0x7439013f, 0x8ef969df, 0x9f9e4bfc, 0x7f38c72d, 0x9c1dbd88,
- 0x678a54c7, 0xfa17ebf4, 0xbbfd6a73, 0x5f04ae72, 0x15f065ea, 0xdcbaf84f,
- 0x19fd833c, 0xfbfd2fe3, 0xc17db593, 0x223ae326, 0xa4f38647, 0x7f8027ce,
- 0x2cfe8853, 0x9ea9f4d6, 0x6bbdd107, 0x064fe524, 0x31e7e5c7, 0xc4bfbe81,
- 0x81f25ddf, 0x963d453e, 0xc56fb927, 0x71ed79f6, 0xc0efda2a, 0xbf1af56f,
- 0x3a6fc849, 0xaae35b9d, 0xebbe69f3, 0xfa4bb204, 0x3ada41d9, 0xd024d79a,
- 0x9e0d99ef, 0x87e715e7, 0x7beba7c0, 0xeb55bfe8, 0xe7e73c7f, 0xf9f8fb67,
- 0xcd1f943e, 0x0eae679f, 0x1c3d5fba, 0x732885fe, 0xd5eb2109, 0xeb8a36ab,
- 0x5abb78eb, 0x85edd7fe, 0x25d701f2, 0xf8377d07, 0x84e1c068, 0x1e518b76,
- 0x7cb55f50, 0xb664f742, 0x7f0c89b6, 0x8de700b2, 0xd74f237a, 0x8795be93,
- 0x5bb2240a, 0x49d97a82, 0x37ae8bf6, 0xb06b5603, 0x2bb5b9fd, 0xaf51eb0b,
- 0xc7ecf76a, 0xc7c5a08b, 0x7348e106, 0x9277bb70, 0xddfc4597, 0x5dbb1cb8,
- 0x8f3423d7, 0xe80a2b8d, 0x6d2a855e, 0xe1d49d3d, 0x345378a3, 0x104271e2,
- 0x7d7afa1f, 0x15e3a5a7, 0x8197bced, 0xd83af51f, 0xaca69525, 0x7ef8ff60,
- 0xe7df0866, 0x841f3839, 0xeabbe7d3, 0x0f83c027, 0x0d43f0f1, 0xc75009ef,
- 0x04982d7b, 0xfde617eb, 0x6b5c50cc, 0x56e04232, 0x104e3eb8, 0x5d8f5c4d,
- 0x07e22e46, 0x58f7ed31, 0x41cf24ec, 0xe5bb707c, 0xe7168701, 0x3f29eed5,
- 0xa1390268, 0xcf3e367d, 0xd4c95dee, 0xddad6cef, 0x6f2f4bdf, 0x7496f2d6,
- 0xb5e2b17b, 0xf846cdd4, 0x1cbb7f79, 0x47792f1c, 0x8ed063dd, 0x5c51ee19,
- 0xb5e41fe8, 0xf98fdccf, 0xf07bd924, 0x7c820407, 0xe5c2dd9e, 0xc34bb814,
- 0x43db9bcb, 0xd874adfb, 0xbbfb3975, 0x28fb23cc, 0xcba457e7, 0x5a72217d,
- 0xbe3850e3, 0xc4167e60, 0xa3d464a7, 0x83f7f97a, 0xcf1fb3c3, 0x3e039525,
- 0x78eb6d50, 0xbf996d6b, 0x7c7286d2, 0x8e50b994, 0x9be65bbb, 0x315d2146,
- 0xa219cc11, 0x79f3d61f, 0xf02876e8, 0xe5f20b65, 0x1a10c73a, 0x7751f86f,
- 0x1fbc0e74, 0xc613768e, 0x7eec5b7d, 0x0efc23f4, 0xe2072eef, 0x14ef5673,
- 0x8cad4fdc, 0x85b5aeae, 0xdf6bef3c, 0x8f89ed06, 0x1fee22bd, 0xf8c03f95,
- 0x7cdaf1bd, 0x02cfa9a0, 0x20c855e3, 0x0f5459a7, 0x655ade20, 0x3ef7bede,
- 0x5611a5fa, 0xf97bf229, 0x95befd60, 0x536df3f8, 0xfd17d21c, 0xcb93b424,
- 0xee1a4f45, 0x16c1b27b, 0xe003ae17, 0x1fbf1077, 0x06c931b4, 0x4a1efffd,
- 0xc4d3d3d4, 0x6b8e74a5, 0xfb40965a, 0x8f7fba44, 0xa4fd0b7a, 0x4d17bf3b,
- 0x3c2ec8fc, 0xd3e30c38, 0x4e9cd109, 0xeb558fd0, 0x1b1d6ac7, 0x48ffbf94,
- 0x8efe491f, 0x141dbebe, 0xe0e7ea04, 0xd735d74d, 0xd841f885, 0x83ffea1f,
- 0xa5b48cc2, 0x1f9affc8, 0x7c61f647, 0x7b45dd70, 0xce21ac65, 0xebe0d3e6,
- 0x0a3e4748, 0x3ed147b5, 0x7d67b3ed, 0x0cdf57f3, 0xf4e2767a, 0x715e0096,
- 0x6e8acb5f, 0x6fe817fe, 0x36b3d81a, 0x8d3ec3c0, 0xf8660e2f, 0x3d4fdc44,
- 0xfba05c38, 0x79450fdc, 0xe095aa73, 0x5c5a8938, 0x33cb5120, 0xe5e28c4f,
- 0x1eb8620f, 0xaf863cfc, 0xbca837d7, 0x1c88e89e, 0xbdad9847, 0xeb89a9ff,
- 0x91f935f7, 0x684fd1f3, 0xedaaf5fa, 0xfc211cde, 0x8e13eebe, 0xdd7dda09,
- 0xe3c76f94, 0xfe340bfd, 0xe8873b06, 0xf8abb414, 0x876e9d7e, 0x4d9f6d9e,
- 0xf78213f5, 0x2c047bbd, 0x9f904f3d, 0xf148aef4, 0x6f58e2a1, 0x55a5e622,
- 0xcb8e4544, 0xf4f0d20c, 0x38a30d59, 0xcfdc29ef, 0xb7bfe6cb, 0x1b25f585,
- 0x1d7ba49e, 0xe29f994a, 0x1a1b45bd, 0xc8aebf68, 0x80a7302f, 0xc78799fe,
- 0x943a3581, 0x710d116e, 0xb552c5e7, 0xe4139b1c, 0xae1dfc5b, 0x9b25f7d0,
- 0x57ea19c6, 0x1816976f, 0x7a823bf2, 0xbfec90a7, 0x3e757ef0, 0x8f4fb70f,
- 0xf10d38d7, 0x861b05ee, 0x78cdf217, 0x73217ede, 0x36177cd1, 0x11ef1966,
- 0xb2b84c6e, 0x1ec1827b, 0x538445f5, 0x3fa8fd26, 0xf7f80e3f, 0x17f7c485,
- 0xe08c3a7c, 0x7bc38bf8, 0x8e018c5d, 0xc433e668, 0xdff326cf, 0xf8f1b429,
- 0xef8ff023, 0x7e407652, 0x07f577cc, 0x1fc01dae, 0xfa87fdc8, 0xb9937903,
- 0x024d65fe, 0x9c4ce0e5, 0x66cfb46a, 0x6e75f0c7, 0xc1b44c76, 0x679a2b3e,
- 0x6b57376c, 0x776b5737, 0xa84a38b9, 0xa164265d, 0xe9fde33e, 0x71951fbf,
- 0xffca6dfa, 0xedc310dc, 0x6eaa9fd7, 0xbbf40c6f, 0xd0773b56, 0xefdade6f,
- 0xf735ad4a, 0x5e5285e5, 0x1e6fe6e0, 0x09dfc3ac, 0xf601dde9, 0xfcc1e83f,
- 0x7ba0df67, 0x6eeff4ba, 0xb432d15f, 0xa954f008, 0x8bb973c9, 0x15dcafcf,
- 0x3f418790, 0xae1ce529, 0x827d96b4, 0x5a5df214, 0x22b76f09, 0x2ff06cc6,
- 0xffd5a27f, 0x6549c635, 0x1840495a, 0x3652ed06, 0xec24116d, 0x0b577f0f,
- 0x66a949e0, 0x93dfd0fe, 0xedcf194a, 0x6fc7db9a, 0x04e61616, 0x9a68d0f1,
- 0x5c62a391, 0x85da3135, 0xaa47cceb, 0x50f10eb7, 0xce8051fe, 0xa8fc4c49,
- 0xbdbb425d, 0x23d7755b, 0x7078eb7f, 0xae0a6a8a, 0x711fd1a3, 0xfcfa9b38,
- 0x30bebe62, 0x4766a8f6, 0xe976eb37, 0x42edc661, 0x5712a75a, 0x3efc308e,
- 0xb69c6261, 0xef32244e, 0x37da854e, 0xa327a232, 0xccae24f9, 0x2c76e66e,
- 0x2cb4f7a7, 0x3e7c16cf, 0xb1c8f06d, 0xd647df78, 0xbf8480da, 0x26dafe3b,
- 0x51fbc453, 0xc3fc359a, 0xf9c59e3c, 0x9cb8f3e9, 0x99dbd05e, 0xe84f8807,
- 0x3d3d10f2, 0xd8c1dfb2, 0xff3ef4e3, 0xe97bf8d9, 0x997acafe, 0xc74e4f7e,
- 0x69eab77f, 0xb4a6bc41, 0x3708166c, 0xdc7a78da, 0x5ca39f0e, 0xe78d971e,
- 0xfb94073a, 0x16873b15, 0xbd7dca85, 0x1cd9f44c, 0xdbafe796, 0xe1887ff7,
- 0x5890eaeb, 0x4bc43ecf, 0x8a3adb65, 0xc2d92cef, 0x4067f77f, 0xfe215cfc,
- 0x07ee1284, 0xfbe1cf94, 0x4acff95e, 0x7ab2ff44, 0xe5acfbfe, 0xb8f077db,
- 0x0b998fce, 0xcb7943f5, 0x0728a10e, 0x8773077f, 0x9f0428b0, 0xca7ee5a9,
- 0xaec6bf83, 0x5bd71fcb, 0x718efce1, 0x0e53b462, 0xe87eb8d9, 0xb87c57cc,
- 0xf669dc1f, 0xcebb6396, 0xe61768e4, 0xfff8e977, 0xe99b8efd, 0xa77db5dc,
- 0xa3658025, 0x8ac939a9, 0xcad70efb, 0x6eabe42e, 0xe9127bd5, 0x5a792713,
- 0x78d8fbf1, 0xbe16abbb, 0x58d85a75, 0x3c72b955, 0x8fe30c4c, 0x72e63f89,
- 0xf43aa493, 0x24b186bc, 0xeb9daa37, 0x67d7132d, 0x1e7ccc87, 0xf787193b,
- 0xb3ee3107, 0xe3878724, 0xf294dc68, 0xca1f9d00, 0x70d3bd38, 0x5fc830ce,
- 0x1b7dbfee, 0x2c3fff7e, 0x00284ba1, 0x0000284b, 0x00088b1f, 0x00000000,
- 0x7dd5ff00, 0xc5547c7b, 0xbddcf8f5, 0x0dd90afb, 0xdc3bf79b, 0x24280c10,
- 0x01049e6c, 0x878424d9, 0x28026e20, 0x47796bc8, 0xd2026c92, 0x6dfad0fe,
- 0xe5318316, 0x16d46b6b, 0x882ea945, 0x835ab696, 0xb80d06a2, 0x47d62228,
- 0x2d8aa523, 0x2220a5da, 0xfb1b6484, 0x6fcb56c0, 0xec9999ce, 0x0f0d9bde,
- 0x7cf9fb6b, 0xdcc98fe1, 0xe6739f79, 0x9ce7339c, 0xb5331d99, 0x228ca8cd,
- 0x389aa6a4, 0xfd2d34bc, 0x84e90ee9, 0xf00b9085, 0x8321226f, 0xf121326c,
- 0xbd3ca484, 0x582c524d, 0x1c5a7fbe, 0x052627d6, 0xaed84bbe, 0xa0af9686,
- 0x84225ba9, 0xa0e4258c, 0x31cc7881, 0x2ae8b484, 0xfd68d947, 0x7b488496,
- 0x663b2d13, 0x68db4573, 0x9d63967f, 0xeab4ac07, 0xa33e6398, 0xda4bf68b,
- 0x4264c7e9, 0x121230de, 0x8c1ddb41, 0x6dd3ed60, 0x42229074, 0x07891b26,
- 0x233d1bbf, 0xc1dfda14, 0xbfb083a1, 0xa6eab797, 0xc37b697a, 0x19d8b220,
- 0x9b74ef32, 0x6ca5db0e, 0xe8e921dd, 0x5a48b8f7, 0x513f321e, 0x595b01ef,
- 0xcc67cc26, 0x43844ed4, 0xae3d56dd, 0x1ce8c2a7, 0xb05466b6, 0x8fe868de,
- 0xe6ed7bd6, 0xfa7e8c4f, 0xbd2fc7fd, 0xbf50246f, 0xc1b47255, 0x37df5bfc,
- 0xa9a1c9ce, 0x4932e7e7, 0x613a6420, 0xf0bf36ff, 0xdfa151be, 0x70a6efa7,
- 0x76eaf5a2, 0xa32fd2ef, 0xc5a95769, 0x24268d23, 0x8b6bccf3, 0xdefd2148,
- 0x74112266, 0x5736dd6e, 0xfbce8d91, 0x0e535dcd, 0x58845149, 0x20f9339f,
- 0xc421f015, 0x06b4e19f, 0x3a5225e7, 0x722fce30, 0x10b3fd2a, 0x55ef46b2,
- 0x95ddf099, 0xb7eb4559, 0xccf830c6, 0x42e0cc1f, 0x157bec2c, 0x0b80975f,
- 0x8c0a7f1d, 0xdce5915f, 0x2454fd01, 0x329bd846, 0xaff99e61, 0xebdc2999,
- 0x823d92ec, 0x672b8d56, 0x579d0cf0, 0x79b84e65, 0xe2f1c06d, 0x44f8d963,
- 0x7180cfef, 0xefb2f109, 0xf9216932, 0x3873f6c1, 0x1f77e9be, 0x3a864efb,
- 0xd7f38273, 0x4d836fe2, 0xe861fac2, 0xa3ac116c, 0xc7cf98f6, 0x0f53ace8,
- 0xe6799674, 0xd043e230, 0xeab6cfcd, 0xd5fd1531, 0x5fd88cd9, 0x708f4d9d,
- 0x1a780cd9, 0x2c03534c, 0xcc1ba69a, 0xc7850f5e, 0x1f26f39b, 0x7e297292,
- 0x20fa316e, 0xb4b7437d, 0x48dfca16, 0xe8b7e361, 0xdf216b74, 0x34859772,
- 0x6e1d5e21, 0x376bcf98, 0x6a7e2147, 0x26bd1ae7, 0x9f8fcfda, 0x63de5897,
- 0x67fa12f1, 0x72f66bad, 0x22e24768, 0xfe024fec, 0x738c075c, 0x4ae9fdac,
- 0x51bf6e79, 0xb7a7dfa1, 0xf027fdb1, 0xe8c6db50, 0x0107ec4b, 0xbd3c20d7,
- 0xf024fdaa, 0x8db07f31, 0x17a505d1, 0xcecd7780, 0x3349db08, 0x0102eb1b,
- 0xe5568cfa, 0x6d93dbeb, 0xf3044727, 0xd007f035, 0x81620ec1, 0x79f2d679,
- 0xeeb9d3ce, 0x6755fd83, 0x50341ff6, 0x0d1f16d4, 0x881f7ee0, 0xffd66b7e,
- 0x0164fb3a, 0x0e93ab21, 0xadf62a61, 0x7f7aa861, 0x6f78e56f, 0x7bb69482,
- 0x4d4dd382, 0xcbee1b61, 0xb80d939a, 0x19532d9f, 0x231cb35f, 0x133c508e,
- 0xdebe43f2, 0x457db17b, 0x9964db64, 0x71e2bdc2, 0xfa44d6c9, 0xaba44fcf,
- 0xa36ce224, 0xf5b67dfd, 0x0025a8f5, 0xc82eafdf, 0x37ae98a4, 0x3777ad82,
- 0x3b5d3be7, 0xde91c029, 0xcc248c1b, 0x3fb72f7a, 0x01223be2, 0xec386b3c,
- 0x1f2e9ebb, 0x17a529fb, 0xf6c1cecf, 0xcf92e8ab, 0xf6eb3d3e, 0xbbbce94f,
- 0xcbb44c76, 0x4e4d3640, 0x7c409fa4, 0xa53b7d84, 0x4c99389f, 0x37de2895,
- 0x351ebdb4, 0xfcfbb68e, 0x81f3a397, 0xf7cdbf6f, 0xe5e799fd, 0xbb9700f5,
- 0x75ecf67e, 0x95e35e50, 0xce304d62, 0x95ffc7ce, 0xdea9fb42, 0x26100f51,
- 0xd57cbf4d, 0x74f5a7e8, 0xfbec6dde, 0xa836c1ce, 0xf713f9f7, 0x6ef0075f,
- 0xf2c26b6a, 0xc36c4f33, 0x7b3f6bfc, 0x683fdf76, 0x94675abd, 0x799dea1d,
- 0xa5e23f7e, 0xc077a5d6, 0xeba2077a, 0x33f6bbcd, 0xe126d97e, 0x1973237e,
- 0x2d74131f, 0x9ff3f7e8, 0x2a1b1e2d, 0x16f7c437, 0x833b9723, 0xcb391c98,
- 0x994d6ff7, 0xb3d205a5, 0x85cc44cf, 0xfe8dbaf5, 0xcf9868ec, 0x1f174628,
- 0xb6d47871, 0x2db831ad, 0xf9fb1ed8, 0x487bee80, 0x9e7d2873, 0x6b4ef4a2,
- 0x0050b8ed, 0xeb0afde3, 0x11257ad3, 0x2f37be14, 0x7cc12e38, 0x18354722,
- 0xbf9e706a, 0xd574e564, 0xebc5e5a1, 0xe96a3d18, 0x059b0be0, 0x907d8beb,
- 0x4d32bbb2, 0xb2603e41, 0xd6ce3e33, 0x6aed5297, 0xd7efd2b2, 0x65d973af,
- 0x4f97c78a, 0x4a9c9e1f, 0x211b3ff3, 0x65fe2015, 0x8f39c989, 0x5ba9c705,
- 0xd04e465f, 0xd9a2eaf9, 0x11b0497e, 0x07c8b5fd, 0xd7ba31b6, 0xf205bd13,
- 0x89f200fa, 0x072e16ba, 0x1279b077, 0x96632073, 0xae59db15, 0x83ce098d,
- 0x3058b3b6, 0x29b8c81f, 0x678ee407, 0xc51dca2e, 0x233df388, 0xe4f101f8,
- 0xee09cc2e, 0x711d04b7, 0x8c13fe01, 0x7e30b534, 0x4ffb4953, 0x8a4d2e8f,
- 0x09a60a2e, 0x16b95883, 0xf2f0b74e, 0x923b451f, 0x3b5e01a2, 0x60f25563,
- 0xdaf2be20, 0x6e4cddcd, 0xe91c72bf, 0x08740dd0, 0xaa4ebbe3, 0x6472f6e4,
- 0xf70e94ae, 0x5c3a471c, 0xabf8cede, 0xb8d4bdbb, 0x259ba68c, 0xefe61732,
- 0x7404f4e6, 0x9bf9a764, 0x7d71a3a2, 0xd9fcebee, 0x39baa7c0, 0x61ef75dd,
- 0x4e86f6f4, 0xbcf801e7, 0x36e47db1, 0xf95a0790, 0x113b5528, 0x6f8a6edf,
- 0xd67a0493, 0x67a0c3ba, 0x3b1355d5, 0x6ef757ec, 0x081a1fbe, 0x7b7707ee,
- 0x2fe872e5, 0x5d9a6e35, 0x992f5096, 0xeef34a9c, 0xfb04525a, 0xd96b652d,
- 0xd20ba01e, 0x20ab912e, 0x0ddced5f, 0xab8fafed, 0x2099cbb3, 0x9927b6f7,
- 0x47ebfd69, 0xcdfb6314, 0xf4294ae9, 0xb620a9e7, 0x706f2127, 0x9cdb3ca1,
- 0xf20ed23c, 0x88daedce, 0x0651177a, 0xb89ca1d9, 0xbea16bf4, 0x6c80b3db,
- 0xe3ecc292, 0xcb03923d, 0x08de91bd, 0x3b7a7eda, 0xeddc7fd3, 0x139f1f6c,
- 0xa1a911f0, 0xd78c1173, 0x788982fd, 0xbd9d20a4, 0x930a67b9, 0x509a2fb3,
- 0x746d9ece, 0x34541390, 0x10568c8f, 0x358e02af, 0xa03a99ad, 0x9966425b,
- 0xf8cb1e60, 0x4c0d5a3c, 0x3973446e, 0x9b2f7590, 0x1fbe72c7, 0x78eb4796,
- 0xaffbe46a, 0x9b05c995, 0xe0e41727, 0x921e3e39, 0x73970245, 0xe5bae874,
- 0xb527dc3e, 0xe2feb34f, 0xdbbc8e4c, 0xe855e842, 0x6c7a5a47, 0x6ca6e3e2,
- 0x3301203d, 0xa55ad949, 0x57d7e7da, 0x5d3d5f13, 0x755bf5e7, 0xa8b989be,
- 0xfc82dd37, 0x6c91837c, 0x77f7fa97, 0x5be3344f, 0x3cceb115, 0xcdd7e409,
- 0xfa3fd416, 0x8720e9f6, 0xb8f4022e, 0x84dec97c, 0xea1670ab, 0x09d3bd68,
- 0xede03b56, 0x5a8e1c47, 0xbdafab7d, 0xd19c0f46, 0x4325c9ea, 0x4186e969,
- 0x549e0173, 0xa198b75f, 0xa7b68d9d, 0x8fb612f5, 0xf213627b, 0xf7ec26ab,
- 0xeb1b68f6, 0xd859d627, 0xcb2e2c00, 0x27c98eb9, 0x7adc3dab, 0x9e85a3d2,
- 0x074f28bd, 0x82db33f4, 0xafc7e1fb, 0xbd194b48, 0x01284151, 0x41fdb23d,
- 0x5278fee8, 0x3d447a41, 0xf4e0ddca, 0xb647a786, 0xaf54dc5f, 0xd29b3d02,
- 0x27a65ae3, 0x4fdb085b, 0xa7232e8c, 0x7c007932, 0x159f542b, 0xefbb54fb,
- 0xedf6fd05, 0xefdccbfb, 0x1fb606dd, 0x801c29bb, 0xfce8fbde, 0x9be74665,
- 0x48fdd036, 0xfdd137cb, 0xffc214d8, 0x981fe7b5, 0x04079c27, 0x73663dbf,
- 0x745f0076, 0x19ab7f6f, 0x47f396c9, 0xc83fcbf7, 0x65de98be, 0x5fb4ca86,
- 0xa1afdd33, 0xe0a663f4, 0xea63e6b6, 0xb9113901, 0x8947ad5e, 0x266883f4,
- 0xdeb1bebf, 0xa3d24238, 0x55f1c3de, 0x007d73ab, 0x46f41e7c, 0x6324114a,
- 0x131bd33d, 0xde00e640, 0x417a47b6, 0x20484e3f, 0xccc2e7ae, 0x67df3f67,
- 0xfce29f02, 0xeac51090, 0xff7df2f7, 0x4ff7af29, 0x4b9c869e, 0x3a283f70,
- 0x0f2271d7, 0x3b448f2c, 0x172c2f3a, 0xd73be9f3, 0x137cd998, 0xbedecaee,
- 0xc18f0429, 0x3e75757d, 0x5eeb37e0, 0x25a97e9f, 0x8b908e38, 0xf981ba5a,
- 0xf581fc83, 0xb81a8e54, 0x7e7eeb5e, 0x71d0d33e, 0x7b5fdf04, 0xb482b8a8,
- 0x2bfbe0d5, 0x5635c7ee, 0x2522fa02, 0x9d2c4707, 0xe1befd57, 0x088d1f6c,
- 0xeafb4364, 0x314dd758, 0x9331dfb4, 0xdfa0fef8, 0xa09ce0ab, 0x0c531e27,
- 0xf5e0dde0, 0xd3f9e087, 0x8f7fd618, 0xe991ecd5, 0xd623b8fe, 0x3ded0d15,
- 0x03eec465, 0xe5077339, 0x896fb027, 0x4df808af, 0x0147f13d, 0x5d58c79c,
- 0xbf4031f1, 0xc9366772, 0xf257fca2, 0x63f7c2e7, 0x84b95111, 0xfb71f3f6,
- 0x85799f6f, 0xcaf85ab6, 0x03df85b9, 0x22317afa, 0x18e2e803, 0x513b97d5,
- 0x830656df, 0x944bddbe, 0xfc30b6c1, 0xcc0ba457, 0x20beb33a, 0x55663f98,
- 0x7a442f9f, 0x6fc30c4d, 0xe214f9fd, 0x09fe8589, 0x627bbf9e, 0x1f5df614,
- 0x56ea8230, 0x78833e7f, 0xeb1f7f68, 0x985b7548, 0x30c53771, 0xc84ddb7a,
- 0xf7e570d4, 0x0f7671f1, 0xb030fb65, 0x7f02f24d, 0xe1bf5eac, 0x07e532cf,
- 0x3eacebd5, 0xe831694c, 0x8f36d56f, 0xc7f3474f, 0xd11f8c0c, 0xc5cdb37f,
- 0xeb47b941, 0x0e03c7e9, 0x4b20f43c, 0x2e52e0f9, 0xbc3596b7, 0x13d825f9,
- 0x3cc4f5aa, 0xdcb3f69e, 0x4a983cec, 0x2cb33e8b, 0xbfb6028f, 0x25b73bf2,
- 0x5c4a5c80, 0x32eccad0, 0xf40d9264, 0x4331c95e, 0x317910be, 0xfa8f4b3d,
- 0xe29fe231, 0xe7188beb, 0x82f7c04c, 0x80f504c1, 0x7a45b705, 0xd07c213d,
- 0xa5a1e1cc, 0x7eb84f9b, 0x767feda5, 0xfe81196c, 0x739ca23a, 0xdc163e81,
- 0xcfc54e76, 0x53ff25ba, 0xad5d028f, 0x649fdab1, 0x433865dd, 0x623bfee8,
- 0xc43af3bc, 0x675e4f53, 0xa04cfaf6, 0x87c640df, 0x30eacf60, 0x940a3cd9,
- 0xa2cf111b, 0x291a9fdd, 0xe60ecbe3, 0x361e9e97, 0x196be819, 0xde0337b1,
- 0x1244b597, 0x033f084f, 0xc3e81805, 0x3f609e7d, 0x3cde3b4b, 0xaddcfc0a,
- 0x2c9d23f7, 0x8f105b35, 0x9c7af3ee, 0x74316907, 0x8a7b45f9, 0x8e5123fb,
- 0x9e7d60db, 0x9f47c67b, 0x263f491a, 0x7eb8efd2, 0xfdf0edd7, 0xe228c8a1,
- 0x4b78fa00, 0xf3a70ef6, 0x832b35ef, 0xeabc2863, 0x460e948d, 0x734e3763,
- 0xd243fe88, 0x77fc6aac, 0xcc25f5bc, 0x65d9b967, 0xc2be3904, 0x32a7cf41,
- 0x6457c9e0, 0xef8a151b, 0x9185f2f1, 0x45ef8f97, 0x6c7fbf7c, 0x661ff4a4,
- 0xe1c7dd1f, 0xa5ea23df, 0x71f27db0, 0x0e7ea906, 0x4a686bd2, 0x943c7ddb,
- 0x3e79f3e7, 0x604bd79b, 0x9f7c1df9, 0xeacb9c7c, 0xc5f1c769, 0x3b36fe30,
- 0xe015b1d6, 0x8cf9db45, 0x22fb1740, 0x16b7a8bc, 0xfc077e52, 0xea3a6d6d,
- 0xedaf94ad, 0xc4d97ac0, 0x4cf58d17, 0x03485728, 0xcfb07be5, 0xcf84148b,
- 0x274a52a6, 0xd7b03cb4, 0x04aedb64, 0xa9f02af1, 0x8c7b63c5, 0xc3c9eff4,
- 0xd43e9251, 0x61e5428e, 0xa3b30c7b, 0xd27f6118, 0x9e991899, 0x85f10c36,
- 0x3e5f2274, 0x608c6ebe, 0xf4fba078, 0x7bd418b5, 0xfba1397d, 0x97c704e5,
- 0x0f1f67e0, 0x8ab5e352, 0x5e6de1e3, 0x8d8c516f, 0x007b4fc9, 0x31c7ddf7,
- 0x165c7eac, 0x0f424393, 0xcb8703ff, 0xc8549a4d, 0xd5533195, 0x1c4dc5fa,
- 0x44c5379f, 0x087ebc09, 0x88f215f3, 0x345f17f2, 0x5e0b0fdd, 0x217f2135,
- 0xb0d9031b, 0x63bd68ff, 0x2c0a6e58, 0xe472a58a, 0x18dfaa26, 0x22ddb1f3,
- 0x3cefdf68, 0x85d04a3f, 0x3e9c8095, 0x1853d625, 0xe54f7e40, 0x296bae1d,
- 0xba437ca1, 0xd037fe34, 0xd694c93a, 0xd8560c87, 0x03a64ef9, 0x208fed02,
- 0xe147f40a, 0xb850e7fe, 0xc63bc76b, 0x319fe0e9, 0x96f11e92, 0x9f70f247,
- 0x7585ffbd, 0x9cf2ed21, 0x51d1eccd, 0xceb8ffbe, 0xe9fa0175, 0xd42dfdba,
- 0x7d198fcb, 0x3096add9, 0x63df46e5, 0xf2c1490f, 0x3d973fc5, 0x762fca46,
- 0xe4fd7677, 0xa5eeba66, 0x861db29d, 0x5fe77a5c, 0x7a031ddf, 0x0ec1a775,
- 0xdf2a46e7, 0xbcc3d5ef, 0x791e981b, 0x83a6a74c, 0x9f55dfb3, 0x1962d273,
- 0x83dea8be, 0x3be09cfa, 0x4adf7e42, 0x5c81577c, 0x461c465f, 0x66b4ff48,
- 0xe1420cd5, 0x0eb2c2b7, 0x6be7d1f9, 0xbc1ea1a7, 0x7cb07892, 0x4fe18b59,
- 0x4561f2a1, 0xeabf3aab, 0x56fe7561, 0x67df3aaf, 0x2f0f2e7f, 0x32c7a7df,
- 0xd94b3e3a, 0xb03fe03e, 0x3d05e4c1, 0x98af5b48, 0x3ca4cbd7, 0x24f813b1,
- 0x4760fb95, 0x48e11758, 0x6ebebe04, 0xc5e2696f, 0xe7f57cec, 0x10de21af,
- 0x37a8237d, 0x6c6f12e4, 0x63cb7eff, 0xf4238415, 0xe071f0ab, 0x2cb671bc,
- 0xc6263afc, 0x10653d0a, 0x8bbe27f6, 0x45e3827e, 0xcfea3ce1, 0x8f98079b,
- 0x5d9fdb05, 0x1b9c7e19, 0xa9b1c6fa, 0x7db064e4, 0xfc6b931c, 0xa3e82d1c,
- 0x7e127cfe, 0x07a17917, 0x31a5db07, 0xd9a48afd, 0xf906454e, 0x8b63b094,
- 0x224270fd, 0x3bb464e6, 0xebcfcfdd, 0x5fb05cf6, 0x083d009f, 0x6514e3f6,
- 0x714e9f9f, 0x66c6f7d9, 0xf70687eb, 0x941d768b, 0x43f8ceae, 0x58b2eef8,
- 0x6b8e1c6b, 0x57187627, 0xdba2fbd0, 0xe8bb062b, 0x6778ff7c, 0x546ba279,
- 0x30f53f28, 0xe85189bf, 0x9c95165f, 0xbc391a25, 0xd42dfdac, 0x95bea8bb,
- 0xd3e74c0d, 0xbd23b7bd, 0x04ce24af, 0xbd9ef3a0, 0xff5c33c3, 0xf315fc86,
- 0x6259e599, 0x9ba79820, 0x2abfee98, 0x1d599f3e, 0x99d3ef4c, 0xc71c061d,
- 0x025b1441, 0x7cd9a51e, 0xd3d4f329, 0xf9be84fc, 0x908e9183, 0x12fe7cf1,
- 0x9df0a7b4, 0xd4b253c0, 0x36f30495, 0xbc74b8c1, 0x824de208, 0x5dac69b4,
- 0xe4a27481, 0x3079b3d4, 0x0d264f3c, 0x675f5069, 0x9d6ccbf6, 0xd0090674,
- 0x985e0fbe, 0xc6fcf2b7, 0x568bbdd9, 0x158b77c0, 0xcf9188f9, 0xe52c4763,
- 0x2fe46687, 0xc9b75866, 0xfd1cfbe2, 0x94f53c64, 0x3d8fb829, 0x3bda0943,
- 0x02369106, 0xe72c5ae3, 0x1b58b03c, 0x8f9049b1, 0xe0faf5b0, 0x66ce70fc,
- 0x2346e8f1, 0x0b19dc9f, 0x677a527c, 0xf285e025, 0x19ff6665, 0xc3ef5ca8,
- 0x73e0b773, 0x4d7e7c31, 0x1325cf9c, 0xe2588706, 0xb01ef1c0, 0x40419cae,
- 0x49d65984, 0xd44b7ed0, 0x25eff454, 0x7969e000, 0x8abd54ec, 0xd53bc56f,
- 0xeab9c4f9, 0x9d4bb27c, 0x3f93d337, 0xcf928be8, 0x16217499, 0xc02359cf,
- 0xfce062de, 0xebcf99a2, 0x3d74a408, 0xfd3e71ef, 0xbb13f58d, 0x8eeebcfa,
- 0xe3b41231, 0xd0cd9825, 0xde57d53f, 0xcafa658b, 0x97281e27, 0xf3cfc803,
- 0xc0f9b626, 0x837cd3ae, 0x7e8bbf64, 0x1b2ab66f, 0x3d5494f4, 0xc76624d3,
- 0xf54adbd1, 0x865b7cb4, 0xe689becd, 0x1d7ec1eb, 0xd5b7f30b, 0x49f68d3c,
- 0x0247ab13, 0xdc8fe0cd, 0x8366c9b6, 0x81e5717a, 0x8bd046c9, 0x76db1057,
- 0xbfbe8612, 0xce86fba2, 0x53c809f7, 0x5e9c48bc, 0xf3290f22, 0x7cbc0d71,
- 0xc59dfc07, 0xe18b13f2, 0x65feca5c, 0x3a75e475, 0x90e0eec0, 0x77d62e51,
- 0xa16ebde4, 0xcecd65e3, 0xb3bc3b43, 0x0973f99c, 0x3463f7df, 0x905c6afb,
- 0x8f3cb1ce, 0x707587e7, 0x899c6ebb, 0x746d6bf9, 0x36666288, 0x8c71fac0,
- 0xfc44edfe, 0x5af2fb63, 0xfd07fc12, 0x47fb0795, 0x5829343e, 0x7467dc1c,
- 0xbdb37ca8, 0x1bd696a9, 0x87edf7a3, 0xa78e3c7d, 0xa37d3c79, 0xbf9406f4,
- 0x628b3a9d, 0x6d7db1d4, 0x861302ce, 0x14b80653, 0x04d07edb, 0x7c904cfd,
- 0xbd4c6698, 0x5fa609bf, 0xd147edc5, 0x06ef4649, 0x12a68eba, 0x77b4678a,
- 0xd820f9fc, 0x4907e5a5, 0x88e9e001, 0x0739c841, 0x7a15d39e, 0x3a1afb1c,
- 0xfd406c98, 0x2a932ffc, 0xd5013bf0, 0xd2bbce8c, 0xbe2116c6, 0x755f2c0f,
- 0xe36a3f28, 0xb337e464, 0x6abf32a6, 0x57b35cfd, 0x10ce4092, 0xbbd277e6,
- 0xb10a6f32, 0xc43f0897, 0x773206fb, 0x44f39857, 0x4fd31c6d, 0x3b3066ab,
- 0xa346fd6f, 0x1d537fca, 0x335eecc7, 0x8c8f26e3, 0xfcc47943, 0x5c7179a7,
- 0x46411b6f, 0xe10a9f00, 0xaf504523, 0x81edf4ab, 0x9cba8cf8, 0x8e3999f3,
- 0xfdea0302, 0xbe08df9c, 0xf6c41cee, 0xd2423cf3, 0x9367ae81, 0x87ffe406,
- 0x7e456f4b, 0x18f11373, 0x951f6f00, 0x310278b1, 0xd55359ef, 0xa71cd27a,
- 0x5cf37f3a, 0xf0c51ead, 0xe79dc621, 0x09579752, 0x5aaa783d, 0xfff05e0f,
- 0xb9468abe, 0xdd54f89a, 0xe7e02185, 0xc000f660, 0xe873f30b, 0x1bdc6e91,
- 0xbebc3f99, 0x388def3d, 0x127767d8, 0x4976cfbe, 0xb2ffd1cb, 0x82115a4b,
- 0xaf5ad4ff, 0xb8647204, 0x987dd855, 0x7934e4de, 0xc3df83f7, 0x91128359,
- 0x49e3cebc, 0x493c400e, 0xadbe907e, 0x57165665, 0x30b51c41, 0xa45b349f,
- 0x16fef41d, 0x65da3e5d, 0x2aaca25b, 0x0da6fa3b, 0x13d4054a, 0x44c558f6,
- 0x6e9c6df2, 0xd7779dc2, 0xbafe31c5, 0x71766259, 0x9e333ccf, 0x9cb3e32b,
- 0xbc413f2a, 0x9d828e4c, 0x229c6470, 0x63fda3ea, 0x5c95c1b3, 0x44af5340,
- 0xd2171197, 0xd11b265e, 0x4fe1a8ae, 0xb476b1f1, 0xce0fc7eb, 0x9cfd3b41,
- 0x2fb43c8e, 0xfd844b12, 0xffd8292a, 0xf4dbd99c, 0xdf53a710, 0xdcbf4db1,
- 0x7bbba412, 0x8d5cb8e2, 0xaf409124, 0xe7ba767d, 0x7ba7684c, 0x5ffce75c,
- 0xa35acba0, 0x2171ed0f, 0x07df8af4, 0x38ab8b92, 0x9cca18bd, 0xf9d056f3,
- 0xb46bbcf5, 0x1d19f9c3, 0xe7ffb46d, 0x9da344f7, 0x50455f51, 0x652c6d3e,
- 0xec07a47c, 0x9f1d745f, 0xf9e35745, 0x8ad4a360, 0x663ba3f2, 0x6af1d232,
- 0x073c01cb, 0x74a56f57, 0x569f2218, 0x6be750ef, 0xdf9e2748, 0x47ee9f6b,
- 0x0517c8cf, 0x56ef761f, 0xd4c323b7, 0xcb8f377c, 0x7da77c8b, 0x7d4c0556,
- 0x9d8b3dae, 0x8641e9c3, 0x1de8a3ae, 0x2eefb723, 0x008a9db0, 0x7494fb56,
- 0xc7adfd31, 0xfb665a7a, 0x2283c99f, 0x6e568e3e, 0xedbd7115, 0xe0bfca3a,
- 0xb0f42afc, 0x07f2c222, 0x92721d74, 0x42df382e, 0x7fe84ede, 0x7c084e42,
- 0x52109695, 0xa743f742, 0xc9434fe0, 0xed37c050, 0x0489f71f, 0xd8314391,
- 0x7dce07bf, 0x9478f8e3, 0xb7203c1e, 0x17b33a3d, 0x6a59abe8, 0x06693940,
- 0x9ba69f3d, 0x83ca1724, 0x323daa97, 0x692c7bc0, 0xd6833598, 0x8cee6f1b,
- 0x3a513804, 0x3f4a1239, 0xb197c44d, 0x11d1524b, 0xbf457796, 0x848e961d,
- 0xc47df33c, 0x74e998f4, 0x054fd0c5, 0x7a687e38, 0xc8e76240, 0xeb1f9629,
- 0xbadbfda1, 0x53274869, 0xf30f5789, 0xf1a9b0ab, 0x9d49253f, 0xa3f4a69f,
- 0x70c38c0f, 0x1f4e7870, 0x08772ea1, 0xfcd4477e, 0x857c932e, 0xc1f9187a,
- 0x5d80efc1, 0x193d7221, 0xd50dfa01, 0x6a1f7144, 0xb8ebe0e9, 0xf26fdd6f,
- 0xbf185c75, 0x13b70f49, 0x2bfc4b5f, 0xd3fa969f, 0xeb1bf759, 0x7a10a4e5,
- 0x65e2fb14, 0x907f8b03, 0xa9fe655e, 0xe5193312, 0x642afa03, 0x3fb14576,
- 0x8cfa05ae, 0x315dd209, 0xcf119eff, 0x19086ce9, 0xa1367402, 0x5327c23d,
- 0xfef1e4bc, 0xcbba05ae, 0xe223ea0f, 0xd254d15c, 0xa532be8f, 0x705fd42c,
- 0xa47d09df, 0xd26b6a40, 0xb91f0267, 0x1be609a7, 0xe3434f42, 0x512f808b,
- 0xda7dc27a, 0xcbaace4f, 0xf026f435, 0x52e5f42e, 0x367480d2, 0xea60a75b,
- 0xf2855cab, 0x5b32dcb5, 0xacdfed0f, 0x0936f462, 0xea0b31e8, 0xdca5e9ab,
- 0xe96bceac, 0x0ba88e91, 0x9f4b571d, 0x10dbd103, 0x5f2137a0, 0x6f4d2f63,
- 0x75bfe3d3, 0x7f1e9b7a, 0xd2d37a11, 0xbb5fe099, 0xa0e56c22, 0x4b57d73f,
- 0xde0a0f28, 0xf904d61d, 0xa89975e1, 0xb68aef4f, 0xdf5d7ea3, 0x3b0bcac0,
- 0xbdc4321d, 0xe5e3ad64, 0xc872ce99, 0xe5a7afd7, 0x23a2ebb4, 0xd8662e2c,
- 0xef3cac9d, 0xadd786ae, 0x587867a0, 0x6f3f97fb, 0xb968a396, 0x2fb799b7,
- 0x7c872d6d, 0xff6b0b7d, 0x46a9f819, 0xb79a7c43, 0x7d5fbe09, 0x1d9da66f,
- 0x3efe99ab, 0x9777af91, 0xd8ebdcf4, 0x5bb595ae, 0x883cd075, 0xe99ff9e0,
- 0x75f1d7e5, 0xd6cadc4e, 0xfae27719, 0x8ba50aa9, 0xea0f0115, 0xb574a76f,
- 0x06dfc8c5, 0x4a973f38, 0x4e9069ad, 0x5217eca1, 0x22ded987, 0xcc7e650f,
- 0x7b8874ed, 0x45fd99e2, 0xce20fff8, 0x9f4432a0, 0xd99e27b8, 0x84bd4563,
- 0xa0018a18, 0xa8ac4787, 0xa4ff0b5f, 0x812221ef, 0x723587bc, 0xbfac243d,
- 0x03564a72, 0x865311ea, 0x5fa53f08, 0x9b8e94bf, 0xc98be177, 0x3f43ece1,
- 0xe69ee3e2, 0x7a7d1371, 0x075337b2, 0x880bb174, 0xf4800524, 0x7f41afde,
- 0x487e05db, 0xa43ca426, 0xf2caf004, 0xbd7fe35b, 0x853c65a9, 0xef41aeaf,
- 0x2196a101, 0xccc9dc61, 0x1c1be24e, 0x53fe7fd5, 0xc467c4f4, 0xff362638,
- 0x1e544d95, 0x7e31d123, 0x8fe38736, 0xe90abf8c, 0xd3c73677, 0x2a7f05cf,
- 0x9fc00520, 0xddbc70e6, 0x347aa664, 0x8356c3f2, 0x133c6f86, 0xcb6a720f,
- 0xbabbfa80, 0xaa57c35c, 0xb92bb8f9, 0x092b7ede, 0x4a727ea0, 0x7a7a62f2,
- 0x6bdbd30b, 0xbf50472c, 0xe98479e9, 0x8fc4b5ed, 0xbed68ffa, 0x9d53b359,
- 0xe7536baf, 0xf9d5dbeb, 0x8e0f1c9e, 0xaea5b3d3, 0xd58aec18, 0x768bbf0f,
- 0x5fc16aec, 0x42fe6abc, 0x5fc67115, 0xed06ba1e, 0x6f98df51, 0x6f4f4d3c,
- 0xd0b8aac5, 0xfa9c02df, 0xb22f35ec, 0x613714f8, 0xeb1e8276, 0x4e70f988,
- 0xa4791a25, 0x9c7927e5, 0x86fb089f, 0x84792fe0, 0x8e7a23c9, 0x8241d77d,
- 0xd7ab5c7c, 0xbd73c4f5, 0x84d39f97, 0xfa0793fe, 0x35d3d00f, 0x4164480d,
- 0xdb7f6439, 0x9fc88724, 0xc0668579, 0xee99be73, 0x6c978067, 0x545971c9,
- 0xca05f0f4, 0x7bcf8199, 0xbd0d72ea, 0x2dd6f388, 0x81665e9c, 0xff8e8527,
- 0xe781c97b, 0x32b7c3ba, 0x5963997a, 0xd1faf487, 0xe22f466a, 0xe7e577dc,
- 0x4dfc873c, 0x747d79ce, 0x5ef54112, 0x17491e9a, 0x8fe67ce7, 0x1d1897af,
- 0xf87d55d4, 0x82cfe818, 0x246e1c2f, 0x3e10faf1, 0x64cd34d1, 0x934a3b06,
- 0xaa839d81, 0xbc5c7fa6, 0x38cf8434, 0x13134a22, 0x88ee5940, 0x5d6cfb47,
- 0x669c7aa4, 0x7fbbf3a9, 0x4fd2f380, 0xd44ed123, 0x954130fb, 0x70eb77a4,
- 0x6b3edb8c, 0x31527e60, 0x7707559f, 0x7ec3f3ee, 0x08ebff5c, 0x359f953d,
- 0x5ac5f792, 0xe4c4b65a, 0x6a7186ca, 0xb3233e74, 0x5fa27663, 0xb03b8c57,
- 0xf283d65d, 0x931af8d5, 0x106901c3, 0xefd2e1c6, 0xb5fea1d9, 0x4f8c89d1,
- 0x2aeb11df, 0xca0f8848, 0xa43f614b, 0xc6a49652, 0xc126fd04, 0x376606f8,
- 0x5c710bf9, 0x6361be32, 0xb69e7d88, 0x568f1b0f, 0xf5f8c096, 0x61ce29f7,
- 0x1da307de, 0xd39f30e5, 0x9a7b8fdc, 0x474efdfb, 0xcce03f31, 0x752cfabe,
- 0xf734f4f1, 0x518e9e13, 0xbd4487fb, 0x8ecc09a5, 0x6cd1b272, 0xbf07a8de,
- 0x1c6f313a, 0x21ec4946, 0x93c60353, 0xea78602c, 0x6dbd13d9, 0xa5ff8853,
- 0xfbf4a12e, 0xd87f9f30, 0xba43379c, 0x31b8f5bc, 0x23df0ed4, 0x0f77f3b1,
- 0x089e97a7, 0xeb718a96, 0x0fbf2a12, 0xe799ec78, 0xe5f63c47, 0x13bc8ac7,
- 0xc099effb, 0xfe5f6bf8, 0xb84f2c3b, 0xf5d843dd, 0x69f7f207, 0xd0547bfd,
- 0x044073b0, 0xfd6bcfb3, 0x3f050bf3, 0x05f9fee3, 0xec2d1f9c, 0x45827e60,
- 0x4a9cd266, 0x247717cb, 0x946e73b2, 0x9fe55b27, 0x515e44f7, 0xcba0863c,
- 0x3ecef49e, 0x2123f67f, 0xee3aecfe, 0xeb13accf, 0xdf5eaddb, 0xbadf0903,
- 0x8481fb3f, 0x6d6cfe30, 0xa08bc3dc, 0xe20b0c47, 0xc18dad61, 0x2dae42ad,
- 0xef6f7b07, 0xe8718272, 0xd65adf6b, 0xb5e0f604, 0x2a0b003f, 0xa7d431f2,
- 0x079c38eb, 0x53bc575a, 0x9d951447, 0x4251107d, 0x8aec9fe6, 0x4351e551,
- 0x4d03890f, 0xb5514ead, 0xaa186f4f, 0xfd643faa, 0x4cf2aa35, 0x9f2abe4f,
- 0xaaad72d5, 0x65ad55fe, 0x87f0fcaa, 0xcfd557af, 0xa3074323, 0x0c90ecfd,
- 0xb57221b6, 0x3e554ab7, 0xaa2de772, 0x86919ff6, 0xbd69e3cd, 0x79fe42dd,
- 0x8aa39d1c, 0x39ce7183, 0xed554b6d, 0x62b6a49b, 0x9f46f01f, 0xbd6893e4,
- 0xcb5f1c15, 0x62ff993b, 0x556afb74, 0xd8a367ff, 0x5fad183d, 0xa32e7696,
- 0x912ed61e, 0x7efea447, 0xfb8eeada, 0xa8ee219b, 0xf296bfbf, 0x356eda4d,
- 0xfe80bf3d, 0x8e6fd5a6, 0x5d3f7026, 0x7461490a, 0x0b0ba5ad, 0x5bbd7fea,
- 0xe627b465, 0xc687ec91, 0xc40cbc23, 0x5fc7f4ab, 0xae76612f, 0x76ada7de,
- 0xf559ff88, 0x47a432d6, 0x2e9a9253, 0x5d351422, 0xd3508e44, 0xa6aed585,
- 0x6a25c183, 0x3dc2d03a, 0x0ba6a1da, 0x43ffa7e2, 0x2ae02de0, 0x553b1ee0,
- 0x785a374d, 0xda0093e7, 0xc95eddd9, 0xfc6123ee, 0x70dbede2, 0x1fd2975d,
- 0xf86a89f5, 0x34701c16, 0x2c6e1059, 0x61e84cbe, 0x68ffae26, 0xaf4213fd,
- 0x7ae44b89, 0xf847ef15, 0x0f259a17, 0xfe7d51ea, 0x865f12c2, 0xa7f4132f,
- 0x44ecc206, 0xf0c4a4ce, 0x3efc4676, 0xc0519d90, 0x2620f675, 0x03886b2f,
- 0x882be1ed, 0xc9ddf90b, 0x3ed15bca, 0x63f2cab4, 0xad9ebbf4, 0x35527a62,
- 0xbf9f22f1, 0xaa02b8e2, 0xfb109287, 0x528e16ab, 0x02b3e487, 0x20f2e1bf,
- 0x79087485, 0x1378c2e0, 0x62e6864a, 0xad471f95, 0x30df82e7, 0xbd097f84,
- 0xe0278c57, 0x189af829, 0xe41a44cf, 0x1a17d824, 0x6846473e, 0x3b6a48fd,
- 0xe0f3b08d, 0x22fe2160, 0x44265dad, 0xe9916e0f, 0xcc90f238, 0x57f14226,
- 0xdda07360, 0xce7488af, 0xe625ef87, 0xc2bd26b6, 0x935713ed, 0x80c4fb3e,
- 0xfe12eaf2, 0xc91e59e8, 0x7f6668ff, 0x6bf0b43f, 0xf89fe5d3, 0x5e3c6d03,
- 0x55ef1052, 0x078f0f2f, 0xa76fea7a, 0x857d1fb4, 0x02eb23f6, 0xc3f6a1b1,
- 0x9206fbbe, 0x1373d71f, 0x424ddc71, 0x693710f4, 0x133f3c9b, 0x4e54c4ec,
- 0xecca4146, 0xab5da458, 0x8ed1eb07, 0x012ba3ac, 0x2121afba, 0x60ccda7e,
- 0xfee5e639, 0x74371179, 0x42e27d29, 0x3fc78da2, 0xc22778b0, 0x5f38a0f9,
- 0x139e740e, 0xcf701471, 0x2221fc16, 0x9139a84e, 0x4973839f, 0xf74ff42e,
- 0xb444a6db, 0x29fdd01f, 0xbec7ee85, 0xef2c22b8, 0xeb351fb7, 0xb2147117,
- 0x42ed10b5, 0x7bd742cb, 0x7a10f019, 0x3ea86fcb, 0x1234f780, 0x0dd7a615,
- 0x0381f63a, 0x553b0b8a, 0x46f59e71, 0x7b01807a, 0x8e3c8bc1, 0xafad4daf,
- 0xe3c89b3f, 0xe739f893, 0x181af052, 0x4eee3c1f, 0xf532e3e0, 0x27771130,
- 0x7f42f8e0, 0xc151efb8, 0xd8bcefb5, 0xe13df707, 0x72e02ee0, 0x29f3a8ae,
- 0x3d6c97c0, 0xeef00092, 0x83ee7288, 0xfd47e9fa, 0x705d24a7, 0x1772155e,
- 0xb6f6cbc6, 0xcf3f78cb, 0x5bc5813d, 0xc8c8f7b9, 0x4c3bba1a, 0x6ead37e8,
- 0xc2f51d7f, 0x68ca46ae, 0xa6761ea9, 0xbfa90e91, 0x0340bd88, 0x47ce81ef,
- 0x681f3d62, 0x75e22fd6, 0x7f7f3ae8, 0x3efc3809, 0xe42a1c1c, 0x9ee18351,
- 0x919c5f57, 0x1551903e, 0x75da1f42, 0xb0f4e66c, 0x013cef56, 0x4cef1dfd,
- 0x55fd0cdb, 0x53071dc8, 0x24eb3e00, 0xd1357fbc, 0x26cbeec4, 0x2574fbf3,
- 0xdc3b06fe, 0xb34a4e37, 0xe1a9fde0, 0xe09d91df, 0xdd78fe17, 0x4f70316d,
- 0x5c3ff44c, 0x4efde1d2, 0xe4fb9e42, 0x57f0428e, 0xa26fb02e, 0x162685b9,
- 0xddf99197, 0xe5165f48, 0x891aaf23, 0x61a3f619, 0x6bde0368, 0x68cb4409,
- 0xc9938cb7, 0x313ba024, 0x561f716f, 0xfafb877c, 0x7c52ef70, 0x2814d89f,
- 0x0ed34b58, 0xdd620f4e, 0x0503cb13, 0xfc20960d, 0x16a65c45, 0x3c385b3e,
- 0x66c6f1dc, 0xcdbb17d0, 0x52c9fce2, 0x9f23d362, 0xfb666759, 0xe255d8e6,
- 0xc2b3edfc, 0xe11dd4b9, 0xf6063c18, 0x7932fbdf, 0xb17f2692, 0xe3470639,
- 0xc7d415fa, 0xbb58d9d7, 0xbf071e6e, 0x44b2a3ee, 0x6f8e5f88, 0xa66f1f0a,
- 0x5c73b124, 0x8beff72d, 0x1f7ab5ef, 0x42d58dc6, 0xf04176bc, 0x6bc695fb,
- 0x01fc788b, 0x27ad10e1, 0xef78d1fa, 0x7ab179dc, 0x0e4bfcaf, 0x3ebebe7b,
- 0x0fe22749, 0xcf4defd1, 0x0be3615b, 0xf9d8934b, 0xe807182a, 0x7dc37bc7,
- 0x4a7b85f1, 0xce45c913, 0x0ef3eefb, 0x889fdc55, 0x9f9f7737, 0xfd7e7184,
- 0x29fda5fa, 0xe15c6096, 0x92dff040, 0x86e5e6c8, 0xd082bf78, 0xdefb0aef,
- 0x8f1c4e37, 0xc147f3df, 0xbb45fd3e, 0x7feaf78c, 0x75374871, 0xd779987b,
- 0x5db83127, 0x7dc7af13, 0x1c47d233, 0x2f8cc2db, 0x35fb89ea, 0x76aa9ee2,
- 0xfccbbb7e, 0x10fe608b, 0xbc6e1c47, 0xc48e9ca5, 0x30c777bc, 0x99f7b87c,
- 0xed059ef0, 0x77bde317, 0xe257f8c7, 0xf1a9b0be, 0xd7b73b7c, 0x9fdebeec,
- 0xa6bcf781, 0x40c33b31, 0x728de0f4, 0xd8f504fd, 0x4a65699b, 0x06fac53f,
- 0xffb216c9, 0x410f452e, 0x7854ebb8, 0x23770fed, 0xfbf457e2, 0x4fbe61f9,
- 0xe702c389, 0xbe5c25b7, 0x8351d92d, 0x1f38affa, 0x8cb0fe7d, 0x139f17f1,
- 0xbcf927e6, 0xcff3c255, 0xeb211752, 0xf95a1f29, 0x88334164, 0x844925b9,
- 0xbec3175c, 0x46e909df, 0xf97c9fb5, 0x87ecfdbd, 0xaeae5424, 0x57280d20,
- 0xdd58fe56, 0xfbdc9aae, 0xb49fd067, 0xdce1fbfe, 0xb1d6272e, 0x479e8939,
- 0x2629ef40, 0xd61f20c5, 0x3185f93e, 0x1f78194a, 0x777ca69c, 0xaff81e98,
- 0x46aed319, 0x48bfa61b, 0x44963c72, 0xc927b7f1, 0x9ed20db5, 0xbdff59f7,
- 0x7e4cbdb5, 0xb9438d6c, 0x2efd64d5, 0x087975f2, 0xc0f7ebe3, 0x1e14093b,
- 0x97d31326, 0x720d7412, 0x5e2dea14, 0xf1e387a4, 0x6266aa6b, 0x74049ede,
- 0x29cbf71f, 0xefce3153, 0x800e9197, 0x4752a6f7, 0x3625d81e, 0x997bb255,
- 0xb3f31366, 0xf6317f7b, 0x0c837035, 0x0cbfbb6b, 0x8eb6c1ce, 0xf7b03efd,
- 0x7cfee8b4, 0x5a57e210, 0x8bf163ae, 0xfeff3a09, 0xe2f190d4, 0xe049bd23,
- 0x691f8f87, 0x388f38c4, 0x21af34b9, 0xcdca5e24, 0x9edbd171, 0x1ec27685,
- 0xb61bb083, 0xa8bde045, 0x8183a1da, 0x18435c8f, 0x1bdc459e, 0xdf5421cc,
- 0x8470a2ed, 0xbf914ba0, 0x19f24da6, 0x12fdf0a2, 0xded4e3f4, 0x0f984be5,
- 0x7ae7ea72, 0xf98983f4, 0x5c9abdc5, 0x212efe06, 0x364be69f, 0xfae34766,
- 0xfe223cfc, 0x5cd97f31, 0xb8f3274e, 0x923f3f1e, 0xb1297bc1, 0x5bbb4067,
- 0x474a24cc, 0xf2fcd4b7, 0x675c22b6, 0xf41a218d, 0x19f7e105, 0x6f08cf58,
- 0x653f72ff, 0xa58df765, 0x72743640, 0x62e7c286, 0xf9c030fb, 0xdd9b3bb2,
- 0x88c323bb, 0xee8cfc03, 0x81b7c37d, 0x8834c27d, 0x7f29aff9, 0xa3e49732,
- 0x73866d5e, 0x44afadd4, 0x2f22f8f0, 0xc8ec4fbf, 0xfa9cf883, 0x8c7cb4aa,
- 0xc01a3913, 0x0dba3777, 0xc7dc0cfe, 0x5448ef94, 0xf2da0e36, 0xb87a19fd,
- 0xf54299af, 0xd92f9a35, 0x0fcb2f72, 0xd1d4aff5, 0x4f2d92fc, 0xfdd3d0cd,
- 0x7fc6bee1, 0x5b35f20a, 0xbe7cb176, 0xf34ca57f, 0x655e5bcd, 0x4960e1f5,
- 0x2dc1ec09, 0x68786707, 0xb9a267ff, 0xf1fbb7bc, 0xe5fbb59e, 0x3b50bae1,
- 0xe332636b, 0x9db8675b, 0x59264cf8, 0x1ef0055c, 0xb2febe11, 0x5a0f1d64,
- 0xac54c569, 0x4927b457, 0xf325dbe1, 0xf7e56e71, 0x924627a3, 0xb7e60896,
- 0x3c5144f3, 0x8e18e81c, 0x93afc77e, 0x6e9e9862, 0x38fbe3f3, 0x4f011fa2,
- 0x77189fd1, 0xe067c835, 0xac789acb, 0x3f8664ec, 0x1c46ce3a, 0xdd839867,
- 0xcb4aae2b, 0xbc51fc03, 0xf4de39e9, 0x8dbbfcec, 0x1bf68fcd, 0xa0728b9d,
- 0x07f8ec00, 0x33f5a2be, 0xd2d6f383, 0x93324149, 0x3136b72f, 0x3a206b7f,
- 0x6269e90b, 0xa5677f24, 0x668ebd50, 0xe4c6870e, 0x466f7e68, 0xc2512bc0,
- 0x1c389a71, 0xcf78fcd3, 0x5dd74af2, 0x775a1ff1, 0xf01cbe08, 0xf681ca5e,
- 0xf5b3b7ab, 0xcd7bf0c4, 0xd4188cfe, 0xf557eef7, 0xa6836677, 0xb8c1097d,
- 0x164c7736, 0x8227bfb6, 0xd93bf198, 0x332ed7de, 0xa0ade997, 0x2c778acf,
- 0x123ae788, 0x7bec47ea, 0xc58da2af, 0x39d70667, 0xd3af90a3, 0x6369d7c6,
- 0xe8aaf4eb, 0x64091c95, 0xa7f6b6cc, 0xf7f83ee3, 0x9f2a37f5, 0xe7daa7f7,
- 0x7d83fae1, 0xd65e103d, 0xd6f93a73, 0xa9e622f0, 0x9c1f6781, 0xf013f335,
- 0xed8dfd84, 0x52e9a946, 0x5926b3cc, 0xfb35939c, 0x8e1bf33b, 0xd5daca57,
- 0xb9e2cedd, 0xeba6a289, 0x3a99ddba, 0xed102b88, 0x1027c16a, 0x3dffb41f,
- 0x89edcc9a, 0x806d2469, 0x93c7c4f8, 0x0ddac28b, 0x9cf6bbf1, 0xe2cd13d8,
- 0x8af6b5d5, 0x277b789e, 0x9cf4afdc, 0x8c0aef63, 0xc06fd8d3, 0x259cf4cf,
- 0x5f282ed8, 0x9c73f9d4, 0x3fb7f63f, 0x7e603205, 0xe7b2a685, 0x47d53b15,
- 0x7e431cb6, 0xecb8385d, 0x7f9a4cb6, 0xc88ff935, 0xcb530bcf, 0xfca4c8be,
- 0x9fb27f7c, 0x7d9647e5, 0x5bf21431, 0x44feacfc, 0xefc0f3c7, 0x633fc789,
- 0xaf507252, 0x41592d78, 0x3ae5c9b8, 0x02647402, 0xc7ae8625, 0xe309aaf4,
- 0x075c04f6, 0xba4d0b4a, 0x6ff77086, 0x07a3eedf, 0x812957e6, 0xf3b0153f,
- 0x5f803b71, 0xf403b2af, 0xdf7bb144, 0x8eff7b3d, 0x483e5df7, 0x1e027576,
- 0x16bb23ea, 0x5dfcd265, 0x1fa09f91, 0x3dd0724f, 0xc515f601, 0xf9d01646,
- 0x9c9b5d4a, 0xd5913fa0, 0xe11eb376, 0x745eedca, 0xfc28178d, 0xf3f7d95e,
- 0x61b2a5ef, 0xb18f309c, 0xefd40f9c, 0xe06ff2fb, 0x633fadf7, 0x7af983b1,
- 0xdb96c76c, 0xdb1aff40, 0x4c97f6f1, 0x39fbb30e, 0xc163de62, 0x97bf49ae,
- 0xfe709bb4, 0x5eae3b63, 0xfdc7f501, 0xe80b23b6, 0x5f31c264, 0x9e85b013,
- 0xaaa52fbd, 0xcf90e5ee, 0x39d71a2e, 0xc04ddfa0, 0x54aa53e3, 0xf478460d,
- 0x857c7832, 0xf1dd67f1, 0x68fd9b87, 0x7fdf54fc, 0xfa3afaa2, 0x20c97b91,
- 0xc433f83b, 0xbdad7a7d, 0x5d2568f4, 0x213efd1f, 0xa2106740, 0x6f3c4f4f,
- 0x98248ca6, 0xaad1252f, 0x5939b97c, 0x96c2bf55, 0x929f2aa9, 0x7caab574,
- 0xcaa7929a, 0x56311f4f, 0x7b06ff55, 0x637f2aa9, 0xfd5534c9, 0x2aa5474a,
- 0x536be79f, 0xd4382fd5, 0x423f2eae, 0xfe43c064, 0x90ebfb51, 0xa0749d16,
- 0x74f8b5d9, 0x8e90ebc3, 0x87030bfd, 0xed7c5ed6, 0xe1d7b6f9, 0x6b17b0bb,
- 0xfb0933ef, 0xc5b2cdf1, 0x276f0c6b, 0x0567d24e, 0x75901fdf, 0x18d33eec,
- 0x94eaebab, 0xa67de0a2, 0xa62f6089, 0x7c58a848, 0x00e347ee, 0x3d980b4f,
- 0x062028ed, 0x68adbee3, 0x686a3c87, 0x2c0fe678, 0xf81d200e, 0x5cc084de,
- 0x9e27bad5, 0x5dd6a977, 0xe0d56e4a, 0x5f2a8d69, 0x555dbb61, 0x06d24a7f,
- 0xe534f955, 0xdd3c1a07, 0x60dfcaaf, 0xd3c1a2df, 0x7e9e0d36, 0xf4172aae,
- 0x5aedc1dd, 0x451ec0fb, 0xcefef1d3, 0x75c3c072, 0x8f8803a7, 0x72d6ce92,
- 0x47b5d3c0, 0x855f10db, 0xb039673e, 0x0d43e2cb, 0xa3ea43af, 0xf76831e7,
- 0xa612635a, 0xb4151a07, 0x1c6c1d6b, 0x46a1e981, 0x75ff7e3b, 0xefa60963,
- 0x7d303a34, 0xa62a71af, 0x4c4e8d9d, 0xb0db1adb, 0xed8d73fe, 0xdb162ecc,
- 0x3a45def7, 0x75ba07d8, 0x8278377e, 0x77923f17, 0xeecbf003, 0xc86efe41,
- 0x37ec45df, 0x25f9a24c, 0xbee844c0, 0x374f29fc, 0x80023aa4, 0xca1c3757,
- 0x18f1828a, 0x1e473a6d, 0xa477e1e8, 0x3ea1f84c, 0x37bb909d, 0xd16c9338,
- 0x79a66f2c, 0xb3c63644, 0x83a1f84d, 0x2033d712, 0x33a9d04a, 0xf7c806e1,
- 0x7772b044, 0x401b84ca, 0xfec6ff0f, 0xff3f4773, 0x61291df9, 0x9ccfe7fc,
- 0xd760ac56, 0x70d5fc39, 0x30e3c02b, 0x48396fb7, 0x4d09619e, 0x0679f54b,
- 0x0747b390, 0x80f0b7b8, 0xe009b4ae, 0xcfb3a6d0, 0xebef78c1, 0xb7e8040d,
- 0x5fe7624a, 0xca95cf51, 0x0dcf41e4, 0x1d4f3c26, 0x605639d1, 0x7814995c,
- 0x3dbce00c, 0xdee112a5, 0x00640d63, 0x4e29bcfc, 0x3c0f8f96, 0xf243d926,
- 0x079f0606, 0xb6fc6e52, 0x3858f3e1, 0x62913cf8, 0xcfb6fa63, 0x807a0e91,
- 0x74a91fc8, 0x3e7ec1d4, 0x0ab8ea52, 0x4d38cfef, 0xad3aff6c, 0x3ed0abde,
- 0x139a28e4, 0x9219e762, 0xd1f7606a, 0xd82262e1, 0x71916f3b, 0x39e16b9f,
- 0x7be99521, 0xce702748, 0xe789179c, 0xf63a2382, 0xfeb6819e, 0xb3d70e02,
- 0xe3dbc283, 0xbd32a616, 0xdd566ca2, 0xfed02f33, 0x6045d67a, 0xe1ce3dd7,
- 0x34f58fa8, 0x342ae850, 0x8e70dd3d, 0x1cec9b95, 0x9dbfe824, 0xf2d17f0f,
- 0xfb6e3a67, 0xfd68efeb, 0xda45d64f, 0xaed88651, 0xc2ddf841, 0x358c2f2b,
- 0xb0b4fea3, 0xe40cbd2a, 0x07ee7ce2, 0x27d5645c, 0x1f503ba0, 0x1727846d,
- 0x9af25b97, 0xcac90429, 0x3c234ab8, 0xb69d5525, 0xd5d219a6, 0xc237eec3,
- 0xa3b52913, 0x1a833576, 0x70b7475b, 0xff3ff211, 0x5e748dbb, 0x0acbd78b,
- 0xfb89cf3b, 0x145735ae, 0xf7e822cf, 0xa23b8f08, 0xeaf3c040, 0xd16f0e22,
- 0xd787116e, 0x3fae1489, 0x0b9c90e6, 0x67d63f6a, 0x0b5def40, 0xc01ecddf,
- 0xe72ea0cf, 0x4607e3fa, 0xfdf6ae36, 0xe2ee3112, 0x3afe7654, 0x0994a462,
- 0x4c2de4fa, 0xfdcee40e, 0xba22aee2, 0x9b0edcfe, 0x1615e30e, 0x7800bdd7,
- 0x78e76de8, 0xd8769034, 0x4b3cb34f, 0x221df93e, 0x8f754e26, 0xd2f252f7,
- 0x0f2b69de, 0x7e859795, 0xbca87967, 0x96b4092c, 0xf2145c83, 0x7d4ff851,
- 0x2f9cd58d, 0x3d3f2037, 0xf31eb8d0, 0x983d1b07, 0xe16c6a1e, 0xcb15b97c,
- 0x987c69df, 0xe72f65f3, 0x7bf13bcb, 0x4c5ce347, 0x58ba35f7, 0x9519ca3e,
- 0xecc4fb0a, 0x37c4f8c2, 0xf80898b6, 0x4c3b7ae7, 0x77419f18, 0xc68f63c4,
- 0x0991fc41, 0xe36a71ef, 0xbe7cb490, 0xf7761e8f, 0x0525377b, 0x1f8be9c6,
- 0xc8717d02, 0x9874f4c0, 0x4be05628, 0xe4fe8ff9, 0x0fafd006, 0xf4158a2b,
- 0xcdd482e9, 0xac50ef2c, 0x7c2f9a06, 0x8a5de794, 0x22ac04d5, 0x5be421f5,
- 0x358a3d87, 0x1f8be682, 0x7b95887d, 0xc7f33a09, 0x06f5ba3d, 0x2259f00f,
- 0x51fd801d, 0x449cce6e, 0xd79505c5, 0x5f6007a5, 0x325a494c, 0xcec5f609,
- 0x63e90514, 0x00e1b29a, 0xd88fa7e4, 0xfaab87a6, 0x46de4b0e, 0x57165768,
- 0x937687a9, 0x846cd6d2, 0xdd879376, 0x376d0faf, 0x8daed475, 0xdf619f90,
- 0x74fd07a6, 0xf8b1f027, 0x2f223f60, 0x169f05ca, 0x3ba37271, 0x720f289c,
- 0x0f289ddb, 0x66ca5c04, 0xf60dde57, 0xc976facf, 0x663cc126, 0x0a417d4b,
- 0x86e89310, 0xbf2949f7, 0x97f53ebe, 0x5db40dd6, 0xc5afe43d, 0x7c370ffc,
- 0xa6fbfcbb, 0xfbfc30d4, 0x41dfbe43, 0xfbdc43de, 0x0ef64687, 0x2e1c33cc,
- 0xac4b1df5, 0x712a8ef8, 0x7acf4159, 0x97f3cb9e, 0x9fe5a520, 0x7f8bb4f1,
- 0x70e7407f, 0x52ab38c1, 0x3fb21fb9, 0x6549a87f, 0x8f735ffb, 0xce728064,
- 0x6d52ea1f, 0xea3cf7aa, 0x76bfbb08, 0x6d3b38a9, 0xee36b89c, 0x3b693564,
- 0x1fecc8e8, 0xf70b526f, 0xc7fab2dc, 0x6a788b7f, 0xdf781c6d, 0xe3106ab9,
- 0xd78173a7, 0x496eba50, 0xde4f901d, 0xdc38097b, 0xfd0e0e1b, 0x9c5843d6,
- 0x2438bf7b, 0x5daeef1e, 0xb3c57117, 0xfc798d77, 0x827d76bb, 0xafaffa2e,
- 0xcf5fc195, 0xbbf54fe0, 0x157e60c7, 0xec04ad8b, 0xe7fca156, 0x3fe11777,
- 0x6df67e5a, 0x179bc9f1, 0x65bbe1d7, 0xf3d8f861, 0xb898f8e1, 0x854dafcf,
- 0xf3f70a9e, 0xde121e20, 0x7e738239, 0x1f6ba265, 0x1653d3f4, 0xce0e9bf8,
- 0xddec71a1, 0xaed183f0, 0x325df0fd, 0x1106b8b2, 0xe75a7c97, 0x6de815f9,
- 0x19fa3def, 0x106eb3f2, 0xbc8f7416, 0x97a0f341, 0x7ce6c3fd, 0x4647e013,
- 0xefa18df8, 0x7f140f8f, 0xff2e1bfb, 0xdf6ca7fa, 0x9ed43889, 0xa0665f6d,
- 0xfb12eefd, 0x54782062, 0x70fde3c8, 0x24b7a43f, 0x9767e512, 0xdef07c44,
- 0x02695771, 0xe95d2dea, 0xdfa43d46, 0x2bb8b9f6, 0xd7fb1b3d, 0x92bb8f9e,
- 0xdc6ccc4b, 0x7d2153c9, 0x2154f92f, 0xf0dfbdc8, 0xa376cbf8, 0xb03de0a7,
- 0x408d8f0f, 0x928dfeff, 0xa0e010bf, 0xbd77573d, 0xc94ca0b5, 0xa6be7fed,
- 0xeb049beb, 0xbbae3dab, 0xe95dbe1b, 0xfd76bb79, 0xb9c408df, 0x15ff5b8f,
- 0xaeeff781, 0x19ddfcfc, 0x5e80ab93, 0x12026ae1, 0xf545d319, 0x54bf9a09,
- 0x8939d6fc, 0x4333d39e, 0x6f25e5ce, 0x9e2e38b3, 0xfde7cf6a, 0xed5c09de,
- 0x960dc751, 0x5e308afa, 0xe147f645, 0x7b1d60bd, 0x73c4436f, 0xf3cfc9bd,
- 0x243ebcf4, 0x9d70ed0d, 0xfaf3aa19, 0xfa2d1f1d, 0x0881f21e, 0xa678ef8c,
- 0xcc3c44fd, 0xf19d8ff5, 0x0945793f, 0xedbd77d2, 0x9df4246f, 0xbdf5dac0,
- 0x86d77caa, 0x7056fbe0, 0x5ff6ab1f, 0x2a25ca32, 0x4f105ac7, 0xdae335e4,
- 0xda4af910, 0xef07dcfe, 0x55df94d1, 0xbe50c002, 0xd074cf36, 0x3cfc9576,
- 0x8de44844, 0x92aeda0e, 0x67891f9f, 0xe78f2b25, 0xb09f3df5, 0xff28ba7c,
- 0x7fac4ce3, 0x1c6fe895, 0x79164f2b, 0x22d5dfde, 0x9623789f, 0x25f68a67,
- 0xc6239f2c, 0xaded64af, 0xade4feac, 0x7a099cff, 0x33f7e08d, 0xe09cb8d2,
- 0xfe5152ef, 0xba2b4cef, 0xba8ebc68, 0xf107cb9c, 0x1dc5550e, 0x85df22d3,
- 0x6126dc7d, 0x9ded61ec, 0x9fe7b406, 0x0dcb698d, 0xe22f2fbd, 0x56e59c7a,
- 0x7baaf38c, 0x9976f871, 0x1e813bc7, 0xe9fb9cb3, 0xfa0b642b, 0x65ef7a61,
- 0x3d207e7c, 0x97fae570, 0x57ecf855, 0x46d3dfce, 0xef1d2547, 0xf1130fdc,
- 0xd619027e, 0xee02f189, 0x27c44934, 0x116abde0, 0x45971757, 0x8e7e701c,
- 0xbd82297b, 0x13b27aa7, 0x97caeff9, 0x6ebb7d98, 0xef28ebcb, 0xda0aca96,
- 0xea1ebe97, 0xe9f0075a, 0x2f77b2b6, 0x87dfae57, 0xc531f4fb, 0x8160fdc6,
- 0xbcf0a151, 0x3dfc3fb3, 0x8517f169, 0x3ffcbabf, 0x5dad7f0c, 0x5fd7dc5d,
- 0x7ff1857d, 0x07e656dd, 0xfd3c73b6, 0x7314a749, 0xf0023d78, 0x33a2b73a,
- 0x20865a3b, 0x778c4eee, 0x29df90ab, 0x6f56f382, 0xde009583, 0xdccea5bb,
- 0x5fe0c30f, 0x9f38ae7b, 0x69715441, 0xf7c3fb3b, 0xf7d04be9, 0xfa4dffd3,
- 0x8dfbd44e, 0x1f1bf076, 0x15e5ef65, 0x18c9fe77, 0x4ef41f1a, 0x0f073b1a,
- 0x317e676e, 0x2c171711, 0x713c32b7, 0xd55d53ff, 0xffc1e33b, 0xc4c3f624,
- 0xfe06d248, 0x76d74a04, 0xa076d74e, 0x41bf416b, 0x176d143f, 0xfa41be06,
- 0x912e2c25, 0xfdb7e9c3, 0x25e1fae1, 0x7fe1fae0, 0xa9bbae13, 0xdbfe8c3e,
- 0x4ed02217, 0x3ff385a3, 0xbc055c38, 0x0e2fd323, 0xfff4c8e7, 0xd3239c0c,
- 0x439d9515, 0xf9207bc0, 0x988fc5a4, 0x5a7d9877, 0xe9f64df4, 0x4f9c1923,
- 0x8f18fde9, 0x4c7bc5ab, 0x27bc3f7a, 0xef1c5fa4, 0x30fff2ea, 0xd370b5de,
- 0x9fdcb5a6, 0x985efdab, 0xfbbf203e, 0x7ff8e056, 0xb0b04fcd, 0x7caabf61,
- 0x54b7faf1, 0xef3c4be5, 0x415f965f, 0x5bfffbd8, 0x57e105fe, 0x2afcf998,
- 0xb51ff81d, 0xc43741f2, 0xc7a023f9, 0x7afe5f1b, 0xf93087d4, 0xb78c6cea,
- 0xe5af8dba, 0xff7ff18b, 0xbe947be4, 0xf66068be, 0x3ffb63d6, 0xfd392837,
- 0x79e165e9, 0xd084711d, 0xeff5c2d9, 0x5acf401b, 0x54fbd848, 0xa60ffada,
- 0xc6307b33, 0x30be5149, 0x710c4cd7, 0x9dcc1f94, 0xcf4beecb, 0x0c630705,
- 0x2d173ea6, 0x3e27a99f, 0xd2bb8f78, 0xd099f7a2, 0xffbea9ef, 0x75efe26e,
- 0xd558b893, 0x21d9783d, 0x9cdf9c63, 0xbd2fe612, 0xf786d2c5, 0xba1de787,
- 0x60f7dceb, 0x14f46f2f, 0x7177b8b1, 0xbaf7f0ff, 0x3e83f12b, 0x9c2a7a08,
- 0x5fee24fb, 0xff40635f, 0x2addb6ba, 0xca669fbe, 0xd9a38b12, 0xc533e2c3,
- 0x3beba4fe, 0xf767ca64, 0x48f7e060, 0xbe0c1b2a, 0x67a0b9e1, 0xbb3d47ef,
- 0x2e4364be, 0x927eafe0, 0x1b94dc74, 0xafd4ef3c, 0xd7b60bff, 0x7a6d67f2,
- 0x4fd5f6b9, 0xbd210f1a, 0xb1d17388, 0xb5e61f46, 0x1305d6f6, 0x93fd17ff,
- 0x6de2ff63, 0x57dc7482, 0xd0c70f8e, 0x3b1bfb75, 0x827b2dff, 0xbb0823b0,
- 0x214ed682, 0xbf7888f8, 0xe36e97d2, 0xa296b2ef, 0x59e883df, 0xc1edf82a,
- 0xd7f9fcfe, 0x27d717e9, 0x61ffe5d5, 0xf4b97cfe, 0xe4c49b5f, 0x8fee96aa,
- 0xed0cfd56, 0xb5be82cf, 0x6200bff4, 0x0bf8e852, 0x27bc25ea, 0xab55773e,
- 0xcdf49c61, 0xe5b57de9, 0x9b830664, 0xb15c2e46, 0x3c78503c, 0x0be78c87,
- 0x0ec6bc93, 0x87810f76, 0xefd5d3af, 0x48bc5303, 0xab971719, 0xfafff2ea,
- 0xa2e4e039, 0x8917266f, 0xcb489f4a, 0xe56eb7e8, 0xfe56eb12, 0xb90eeb9b,
- 0xd648b4a7, 0x40e3ef05, 0x81c435fc, 0xfdd978f6, 0x56ccead4, 0x5203ddfc,
- 0x7e028812, 0x995eeb77, 0xde8e9efd, 0x790e4fa1, 0xf88bad3f, 0x5c7a003e,
- 0x3bbd9e35, 0x769b8da4, 0xd5ea78f3, 0xbf78dd96, 0x9a0efb51, 0xf376cb88,
- 0xa1efb4fe, 0x9de2f689, 0x687bed03, 0x1c783253, 0x67c93e76, 0xe7172971,
- 0xcf20dda3, 0xdd35fc43, 0x5da2355f, 0x4ac7c6e1, 0x05a4f3ee, 0xa32732f1,
- 0x9799df1f, 0xa3be7171, 0xd32fff2e, 0x81dd6caf, 0x94aed8f7, 0x3a64477e,
- 0x827f40dc, 0x9bf1f72f, 0x6fc84c57, 0x3df33bc4, 0xf7c19e6b, 0x24be7a87,
- 0xd4bd97e8, 0xbb13e33b, 0x09c435d8, 0x564dbd27, 0xc771d78a, 0x1baf683c,
- 0xf785c47b, 0xe3bcc776, 0x927f8880, 0xc329c077, 0x233e85bc, 0xff209bf4,
- 0x78d9f7e2, 0xf2e5d59c, 0x37f52bb9, 0x8cfca7fe, 0xb75d5ee2, 0xbf0457c1,
- 0x13d9e0e7, 0xa103bf81, 0x1993ff9d, 0x93be8bba, 0x7ae511dc, 0x8b34f012,
- 0x5ef109cb, 0xdecc8572, 0x94edef49, 0xeeb85ed1, 0xabfb7e7f, 0xdb4b9547,
- 0xbd6dea15, 0x2265cf61, 0x7bb1d7ad, 0x0ae5f92d, 0x79c249c6, 0xc287ec0d,
- 0x7fada89e, 0x297b294a, 0xe35bed03, 0xdeda3df1, 0x067cd987, 0xfafd57c2,
- 0x603f8e00, 0x7ebf1f39, 0xf42d916f, 0x19f3959d, 0xdb43e77d, 0xdf107329,
- 0xff174b97, 0x332dced7, 0xa891e265, 0xbc91cd7c, 0x4c25ef4c, 0x3a405dff,
- 0x02445d31, 0xbb08ba98, 0xd894b0cf, 0x9c4e5d31, 0x5c55ae98, 0x3718195d,
- 0xf8c04814, 0x39ff17d3, 0xdce6e80a, 0x215ae375, 0xf2dbf146, 0xbef56923,
- 0xbd853c9e, 0x3fc2f497, 0xd9f4077f, 0xcb863ff3, 0xa2471be2, 0x1848641c,
- 0xa57bd33f, 0x54d7bb32, 0x17dc5df2, 0x325dfde2, 0x96e1f989, 0xfee26627,
- 0xc4cdf209, 0x826f826d, 0xb8e7393f, 0xdcc3c58e, 0xc67be12a, 0x6e1d7eed,
- 0x99159cb1, 0xb9ddf85e, 0x3cacddf6, 0x2bda2ea7, 0xd8ce7cd1, 0x26be5608,
- 0x4ff70bda, 0xee3f1216, 0xfb70c5cb, 0x4bfb8644, 0xdf8a2f8c, 0x8227a00b,
- 0xbf6d12a1, 0xeeccc3a2, 0x30ff1051, 0x70b9ffe0, 0x4f170a7e, 0xf1f18433,
- 0xbf1943d1, 0xb6a65d1f, 0xe5e50c87, 0xdf6529f7, 0x0cb47807, 0x810d6471,
- 0x9b9d31fa, 0x3b042c1e, 0x9f808e90, 0xb7b1b3e6, 0xb4535fa3, 0x1b29517b,
- 0x959ff501, 0x67bfbc58, 0x4c6fbf2f, 0xfea10902, 0x794ab5b1, 0x1a2bd42e,
- 0x40d3f8c2, 0x51df8570, 0x2f398674, 0xd1d1f88a, 0xbb436670, 0xd277c13c,
- 0x7e58959e, 0x6f5be3f2, 0x5f4168dc, 0xe3f40782, 0x44d71517, 0x91b46f18,
- 0xffcc0b10, 0x1b7efca7, 0xbb00c869, 0x4cc7aae8, 0x3e2fd03a, 0xee18e2a2,
- 0x9e81fcf7, 0x98fd21b7, 0xfd219b9e, 0x43373d23, 0x9b9e9c7a, 0xcf413d21,
- 0x38ae90cd, 0xccc7876f, 0x8e2189c9, 0xf0bfd0b9, 0x5be769f7, 0xd7f18439,
- 0x1af7f1be, 0x14fbfc71, 0x0fb7c217, 0xfe087bdf, 0xd1b3edde, 0x8b989481,
- 0xdecf5bd0, 0x749fa3bf, 0xff08b820, 0x0a7cb6a3, 0x6eee6bc7, 0xdcffca3d,
- 0xcad47f76, 0x872b7a90, 0xce7db118, 0xa0a3270b, 0x1f5b6eff, 0x5d121d7c,
- 0xcb1d4cf2, 0xb9fc7caf, 0x828e371b, 0x0fbe3bf9, 0xf9f74174, 0xdb73486a,
- 0xfc00fb7f, 0x1fed2a5e, 0xa47a24e3, 0x2f3c66c0, 0x85a1d668, 0xb3d75883,
- 0xa09b9dd1, 0x0c2fb3fd, 0xbe509585, 0x01bed843, 0xadc2923a, 0xe7ae0377,
- 0x10a05346, 0x78dd0bee, 0xa71b0e41, 0x8a529f7d, 0x7a064e70, 0xcaddfe43,
- 0x025f4653, 0x7f74df6f, 0xe223fb6b, 0xa5e015fd, 0xafa5c80a, 0xac2f40a2,
- 0xed04f1e4, 0x06fd87bb, 0x2439e9d6, 0xdabdf813, 0xfdea31d1, 0x49e38bb7,
- 0x8d7b39a4, 0xb3d7c04e, 0x830d4f7b, 0x7e2989f7, 0xc57bc186, 0x455c86db,
- 0x31ef7f42, 0x8f97ec67, 0xf587183c, 0xe769f7f1, 0x10156d91, 0xbcdf3337,
- 0xd2580dff, 0x0af1db42, 0x9c599b88, 0x74841d24, 0x19399289, 0x7dc465e2,
- 0x4a236583, 0x9a96c20f, 0x7d44af61, 0x4c9814ae, 0x37287c88, 0xd847f247,
- 0x558a3c85, 0xa524a7e5, 0x534feaaa, 0xd3e554b2, 0x95548c47, 0xd867718b,
- 0x46f5540b, 0xc28604c7, 0x83ae8e79, 0xa4ff03bd, 0x3986f18c, 0x7eb91c2f,
- 0x7ccfcd24, 0x43be0e6a, 0x9f2f2cf9, 0x17b95cf9, 0xe143d1f0, 0xd50aa469,
- 0x6c1f92e9, 0xd33a107e, 0xf76a179c, 0xa1d0713e, 0xe179c65c, 0x8184e712,
- 0xed164fde, 0xca04e7b5, 0xbe001f37, 0xd9c5fa39, 0x3edbf036, 0x14cbf63b,
- 0xcdfd4788, 0x0caefe10, 0x440c3f3f, 0x43fb7d37, 0xbcdd1852, 0xc3279325,
- 0xf2440dd0, 0xe9643a32, 0x7eecc3cc, 0xb5f295de, 0xa1af814f, 0x4243c0bd,
- 0x6b577f7f, 0xb46d1bdf, 0xb036e6ff, 0xc32bbd47, 0x7bbea50d, 0x6fe12b93,
- 0x64ef4839, 0x93bbb6f9, 0x07bbf0e3, 0xb73761f4, 0xb8520df7, 0xffbb553e,
- 0x60c2e4ee, 0x5c775939, 0x29dc9f55, 0x1bf2ab35, 0x7bf9d533, 0xdb439b4b,
- 0xad8fa40f, 0xd189787c, 0x6ef70395, 0x37bfb0a5, 0xfff3e62c, 0xd5800901,
- 0x00800020, 0x00000000, 0x00088b1f, 0x00000000, 0x19b5ff00, 0x6554540b,
- 0xcef7bbfa, 0x7860190b, 0x77421028, 0x840a4498, 0xb0285789, 0xd71ea08d,
- 0x8f4c1ada, 0xe5935654, 0xe04d7903, 0xe3d8f4b6, 0xb68fad18, 0x695b6d07,
- 0x9656356b, 0xb139e4e7, 0x36254644, 0xeb495bae, 0x66a254d6, 0x42d899e4,
- 0x7a26704c, 0xf75a9d6d, 0x5efffefb, 0x5b602e67, 0xe74ed69d, 0xffffef9f,
- 0x27ef7ffb, 0x70ca1490, 0xf60800ce, 0x9970ccac, 0xd6f70601, 0x8018e41a,
- 0xe2eff4d3, 0xf9b8daf0, 0xcf03837a, 0x3a380057, 0x01cfe3cc, 0x031401d6,
- 0x7b81295c, 0x5914f3a2, 0xff60e760, 0x2fbdf165, 0x00490801, 0xde8d179e,
- 0xe38456ed, 0x6e67065c, 0xf08d9ef8, 0xd918064e, 0xbfefff72, 0x25f5c22a,
- 0x8c0ee3b0, 0xbd0d43c4, 0x5c75d79b, 0x9fcd7114, 0x77d1d704, 0x98809679,
- 0x55706b80, 0x00e207b4, 0x3c636a9a, 0x679e3e62, 0x2e990e86, 0xa6f1c804,
- 0x01529bb5, 0xc0228a8e, 0x78074439, 0xe3ef14a0, 0x245f041b, 0xa4ef39a7,
- 0x67c8b9df, 0xe7c72fcc, 0x35b03245, 0xe99432bf, 0x7ed77bc6, 0xbf1ce787,
- 0xce91a203, 0x8f4a803f, 0x2e5c4c03, 0x19bdbb04, 0x3f233ffe, 0x1812bd4d,
- 0xf0619f90, 0x605aba1d, 0x25a9ccd7, 0xa7e92b00, 0x061dfb4c, 0x196fd890,
- 0xb2957f70, 0xe57cb2bf, 0xf08b10a5, 0x2040fd56, 0xa70fbd9b, 0x7fd5fff1,
- 0xf198376f, 0xda53f57c, 0x530f427d, 0xfbe52f90, 0x77b3f03a, 0x3de277eb,
- 0x235ef853, 0x8499fddc, 0x697636ef, 0xc7245fbf, 0xe0e60d24, 0x3828028f,
- 0x916db12d, 0xf1366bde, 0xdf4ae6f7, 0xea097bbd, 0xc925e9b1, 0xd1adc46e,
- 0x00e2d3dd, 0xa83983f9, 0xf2f1d4e4, 0x7a8cda6b, 0xa7c30c2a, 0xbdf34b76,
- 0xca175f74, 0x5e319ea8, 0xe2c960ce, 0x5f1c2cf8, 0x0bd7c573, 0xf735f101,
- 0x7ed0d0e8, 0x1146cf00, 0xcf3c08e4, 0xf2ae31ed, 0x07f4c39a, 0xfcc79c2d,
- 0x66132f9e, 0x1d75f2e7, 0x1ced01d1, 0x98bf702f, 0x093e8021, 0x60b541f1,
- 0x5f4b8edf, 0xc925724f, 0x9f004fbf, 0x589ec05c, 0x5cfd4264, 0x7da39fc1,
- 0x8fe02433, 0xe11d6c94, 0xfdc8a859, 0x7c7fd28a, 0x8b77e023, 0x434f167b,
- 0xd750e00a, 0x0cd43eb2, 0x0c6d906c, 0xe8f012df, 0xf17d2f49, 0xa416f4ce,
- 0x604932f3, 0x1f17dff6, 0x7f10161a, 0xd0b4455f, 0xeff7b026, 0xbe55f7a4,
- 0x74cef4fa, 0x8e6be337, 0x26f51065, 0x4e902e38, 0x47978f47, 0x183aae58,
- 0x712bf554, 0x9c7f2177, 0xfb3edd2b, 0xd1dbf412, 0x223160a5, 0x684b97bd,
- 0xabc30838, 0x49ab8fdc, 0xae5133d6, 0xe8813f82, 0x6e17966c, 0xe4bbf191,
- 0x97417bd6, 0x1d372118, 0x2f5533f7, 0xd3c71caa, 0xf72de2a1, 0xd1bf903b,
- 0x9fb3021d, 0xecccbb46, 0xe4fcb1b3, 0x7f104b83, 0x0bb25fa3, 0xeeb2cf48,
- 0x7e4847bd, 0x403b6b1d, 0xe7401e77, 0x2eb66eda, 0x527d9933, 0xd98be31e,
- 0x414688ad, 0x6056ad7c, 0x7c35a7c6, 0x0c7be61e, 0x7c3f51bc, 0x3804ce06,
- 0x9e7ceb18, 0xfbf35bf8, 0x1096fbcf, 0xe3ca1bb5, 0xad901f99, 0x3fa61b9d,
- 0x466000df, 0xa3db43fa, 0x3c304fbd, 0x6125af68, 0x27b13d7b, 0x9e0b70eb,
- 0xcf53789f, 0xc55f75cc, 0x416ea7c3, 0x68f6cd78, 0x0913e726, 0xf3a549e0,
- 0x3d7ba627, 0x18a56178, 0xb9216fea, 0xb7d8c677, 0x47f1f9e3, 0x13bb3fa7,
- 0xa767dae1, 0xf24c89d9, 0x7de5191f, 0xda011d3c, 0x7d953e7f, 0xef1c2907,
- 0xa52fc50a, 0x57dc6667, 0x24cfe74e, 0xaa8f09da, 0xa347a1bf, 0xfaf2801c,
- 0x16797c12, 0x8293bd34, 0x87c45067, 0xc79dc4eb, 0xdbcbb404, 0xc483ae0c,
- 0xfe47eaf7, 0xf90ca87a, 0x37e67aa9, 0xfa44cf0f, 0x0c9bdf6a, 0xaf584ef4,
- 0x6c40e2e3, 0xdffc9720, 0x915ffdc6, 0x288edd4f, 0x7111c7cb, 0x5e23a1a6,
- 0xa7753703, 0x888e3e5a, 0x65c07537, 0x8e82f50c, 0xfc57a9f8, 0x1d745eaa,
- 0x201aba25, 0x8422e3c0, 0x0557640c, 0x78a0e092, 0xc8c7ba10, 0xced63fe4,
- 0xd1916546, 0x8b822f51, 0x224179e2, 0x6fc85298, 0xc17e5c5d, 0x713fa67b,
- 0x9266ca17, 0xfbf54135, 0x223385ac, 0xf1bfb3ed, 0xcdcfb215, 0xc39f6646,
- 0x8d2f3c51, 0x391ff3c5, 0xc2bf7d9e, 0x87f305f4, 0xf5a4f933, 0x17385adf,
- 0x0aef141c, 0x9bc2e4da, 0xf4516d70, 0x29c52c72, 0x1dee4958, 0xc03aeff7,
- 0xe6f5b9e4, 0xbf7784a3, 0x0e0fe999, 0x0507b970, 0xf7d5279e, 0xa0429856,
- 0xb77a242b, 0xfdd57a31, 0xf3872dc1, 0xe0fef85c, 0x8079390b, 0xf24cbcf6,
- 0xe505fe0f, 0x7fc62a73, 0x3b5c36ec, 0x853bbff7, 0x7a58e0f2, 0xd9475beb,
- 0x2c3c2a7b, 0x4f5438f0, 0xf7fee07c, 0xa264ce99, 0x8b08c313, 0xcd77030f,
- 0x2b9bf260, 0xfe91c6e5, 0xf4b42783, 0x7d53a58d, 0x7d4fa55f, 0xcd37bd5f,
- 0x8e39322a, 0x9479fc18, 0x90cc5ff7, 0xc48d7c35, 0xcde2f3fa, 0x75e16fb4,
- 0x11c20244, 0x3f4356f6, 0x2635bf51, 0x5f48db8c, 0x6f608d4d, 0xa1efb603,
- 0xcfab89b8, 0x29f5e785, 0x03722b2f, 0x78ed09a7, 0x906762b1, 0x6eecc894,
- 0x5ebb7011, 0xabedc4ac, 0xe80f43a0, 0x75c4472f, 0xfda035bf, 0xa03c770d,
- 0x5dc64577, 0x74f151cf, 0xbb8f4fce, 0xa6c84a9e, 0x31623df8, 0x9e66bab3,
- 0x7bb1d055, 0xf74e90e9, 0x43eedcf0, 0x1a74f03b, 0xcf486ded, 0x8173a2e3,
- 0x6f53e515, 0x1f91e5f0, 0x2e3ddfa8, 0xb0fed8ba, 0xe9056070, 0x3cbe741b,
- 0x1bc4ef56, 0x233ac040, 0x77eed938, 0x25f65d50, 0xd412b8b0, 0xe2274d43,
- 0xdd12aa2d, 0x3c70e69d, 0x5167e354, 0x5ca3ee0e, 0xf55f682b, 0xa29bb457,
- 0x30fded7c, 0xb8f85a3f, 0x515dfb95, 0x98eee8a2, 0x576e5fc0, 0x1d06dcf4,
- 0x9e67f712, 0xb914cb47, 0x4522dd63, 0x4a8d2dd6, 0x9ac60f9c, 0x53f2123c,
- 0x82f51bb6, 0xb7ce9970, 0x028c5697, 0x9dfa8ad0, 0x5efe3e05, 0x539e36b7,
- 0xf2ca590e, 0xcbcb0e72, 0xaf7514b3, 0x7a40dc17, 0xc2fe5135, 0x2fc12ef5,
- 0x082bfad1, 0x1601d5b1, 0x06a8ad1d, 0x2701ceb6, 0x9b81e75b, 0x9da1f3ad,
- 0x83a00bad, 0x9f8297ad, 0xaf8170ad, 0xb83e580d, 0xf98832dd, 0x52bd7e18,
- 0xb45cbca4, 0xfc7ae264, 0x675e4571, 0xf9460797, 0x8f2f9f92, 0x614ae079,
- 0x2e4d9d74, 0xdd99b353, 0x923172ab, 0x5177e27d, 0xb5a14de0, 0x9dec0202,
- 0xf190c98b, 0xeb20d99d, 0x0702ae08, 0x48fee783, 0x5c069479, 0x04ee573a,
- 0xd89aa972, 0x7628764e, 0x5d364c52, 0x87d7d61c, 0x54171e56, 0x49d201bd,
- 0x3ebc60f9, 0x2ce88321, 0x5cfcae8a, 0xdaf190c6, 0x3a9df7b6, 0x8545a38c,
- 0x84362d95, 0xe53f590f, 0xf3e55970, 0xd91f0899, 0x9ba9d276, 0x595e7649,
- 0x1563b7a8, 0x39d86eba, 0x184dcf07, 0x4e50a3fc, 0x52824d92, 0xb1515d5c,
- 0x677e8079, 0x74ebac94, 0xdbc657e8, 0x5719c580, 0xd59f8014, 0xe46568b3,
- 0x7ebc3527, 0x7ae1635d, 0xbd706bdb, 0x60da7e4a, 0xc8cac5f2, 0x73759ad3,
- 0x6e5f2993, 0x3ff7f030, 0xbce72c9a, 0x22327282, 0x9841533e, 0x44f73c4f,
- 0xe4101c21, 0x186b5696, 0xf7c08fff, 0x77c21fcf, 0x5deb8a6b, 0x594dcf16,
- 0x534ffa40, 0x676779f2, 0x245d8a59, 0x3f8616fc, 0xd2d59310, 0x5207478a,
- 0x7bd21f9c, 0x776e18c1, 0x5eb95a1f, 0x329ab6ce, 0x27581f1d, 0xfbae0fd8,
- 0xe28f977a, 0x084827d0, 0xd599f3be, 0x34744035, 0x428c8189, 0xd11dd7d4,
- 0x27640cc7, 0xa80b1daa, 0x7fc8a5bc, 0x06bc039b, 0x96e51fe6, 0x2d98f533,
- 0xe5c107ec, 0xa5ca1ef8, 0xd2ace9c8, 0x8d4971e3, 0xa5ad1f7b, 0x3c2af6ae,
- 0xa2413c21, 0xad0a49a7, 0x1538bb20, 0x13e19eff, 0xb953a7e6, 0xabf12a3d,
- 0x6def4f67, 0x42741c69, 0xed361f84, 0x0fabe6f9, 0xa34ddf50, 0x0f5d3b66,
- 0x1696dffb, 0x1ab00bea, 0xd517c4d4, 0x1b75672f, 0x955fd47d, 0x397f3eed,
- 0xaf78abdd, 0xfa7146df, 0x1b40fee2, 0x9ec1cb95, 0x2fdc69c3, 0x6bfe3ad4,
- 0x93e4e7e1, 0x750512b9, 0x905ecbac, 0xabe446bc, 0x050bea99, 0xdc7c20f6,
- 0x47137684, 0xa9bf79f7, 0xbd0d95f6, 0x2fa819af, 0xc43c67c1, 0xff42ad6f,
- 0x5c37adaa, 0xad62f54a, 0xd62fdb57, 0x13d77bf5, 0xb43b75dd, 0xd9bf6afb,
- 0x4f5f7ca4, 0xea8d9af5, 0x26bded3e, 0xa8f337ea, 0x67eed3fe, 0xa6fd2a66,
- 0xa940ff92, 0x772a5733, 0xeb333f88, 0x235e0cff, 0x68fcd6f2, 0x7042dd8b,
- 0xe2ced9ba, 0x6606fd6d, 0xd87deac7, 0x446cc89a, 0x8ddadbf5, 0x5567eac0,
- 0x1b4ff98e, 0xfc8fa41d, 0x5d5993a7, 0xab3cf58c, 0xf09e3047, 0x22651efe,
- 0x173ddda0, 0x1114ca1f, 0xd93d73cf, 0x5fb7aa76, 0x7f80eb5e, 0x4fa6179d,
- 0x4ae7f7ad, 0xd40cab3b, 0x7d88dd47, 0xf7356e14, 0x4266d93e, 0xd01379b8,
- 0x3b2d240d, 0xe2a6ea8e, 0xe97812fd, 0x503ef01d, 0x1a976b8e, 0xbeb0524f,
- 0x9447908f, 0x09e4093c, 0xa2a379fa, 0x04ece8b7, 0xfd8c79cd, 0x71f7cd1c,
- 0xefda99a5, 0x6e7f0e3d, 0xfe73c509, 0x02e3bc7d, 0xc136fdcd, 0xcd91f76d,
- 0xbc3ff004, 0xb188ae57, 0xcd82bfc2, 0x17e7121d, 0x886fee68, 0xec9fb79d,
- 0xdd0bfcbb, 0x4b703b18, 0x01657764, 0x2f504780, 0xe7b586b3, 0x21db07c5,
- 0x1d47f116, 0x57998dd4, 0x16ea8078, 0x5fddaca3, 0x54c5daae, 0x4399aa98,
- 0xb73b919c, 0x9121d1fb, 0x9c0945d9, 0x117970f7, 0x5e0f59c9, 0x46dcbc79,
- 0x66fba569, 0x598bf303, 0x8a762dbd, 0x5a9d9347, 0x68d727f9, 0xd2ea9fe5,
- 0x956d3bca, 0x6ee9de56, 0x6dcfbcad, 0xead7cad5, 0xb6cfcad1, 0xfee69671,
- 0x0d4af6b4, 0x02f37d3c, 0xbdf3fdcd, 0xce70350b, 0xf734ab8e, 0xd32c7467,
- 0xaf77e79c, 0x76ab9cd6, 0x2e0ed636, 0xb18f35f4, 0x08c41133, 0x567aabfd,
- 0xff70a0ed, 0xff3c1aad, 0x1f6ffd6f, 0xc8a7ffa3, 0xbdde31d7, 0x37743b15,
- 0xd165ebb9, 0x999dae3c, 0x59eb9427, 0x9cb6f6bf, 0x77431558, 0x54e6fc95,
- 0xff941bf2, 0x0e16c391, 0x7df6fddb, 0x8e0acf14, 0xae88ab38, 0x1f7b80a2,
- 0xa192f385, 0xba38aaf6, 0x32d900ef, 0xe89c8f85, 0x02a5e5fe, 0x857e34e8,
- 0x3cb094f0, 0x93acf0af, 0xd972f0e2, 0x1636de77, 0x4be9c96e, 0xa120f3c2,
- 0x6a85e794, 0x22e81447, 0xeca152e4, 0x29e92503, 0xf3abf961, 0xc007ec23,
- 0x6880fd40, 0x2759b6f2, 0x9bec77aa, 0xb98f5625, 0x86f67d58, 0xa57362e0,
- 0x067f2645, 0x25dff7c5, 0xc4cedebb, 0xb44a76b8, 0x139eaccb, 0x54c46d02,
- 0xa4a31890, 0x76afa9e5, 0xed871f50, 0xff2bcd2c, 0xb56d4774, 0x6f919727,
- 0xb6f09409, 0x67f5fe99, 0xa2648eba, 0xcb0407fc, 0xf6fc42fa, 0x332759ad,
- 0x25197f28, 0xcd014494, 0xe9471c4f, 0x24dcccfc, 0x78c3f919, 0x0f65101b,
- 0xab73c289, 0x9390fac0, 0x08ccd8f4, 0x67a8ddff, 0xbe940b79, 0x5e451aec,
- 0x54b65f6a, 0x4f803fc1, 0x7e78c2ac, 0x4c1bf74d, 0xc329752e, 0x6dca1cca,
- 0x37fbe0b7, 0x5017354c, 0x428e0a5f, 0xd5e7ef3b, 0xfa4d2d3e, 0xed557929,
- 0xbf76cf6b, 0xd348652e, 0xc4cec32f, 0x6391e709, 0xbe615ee7, 0x9b03fbf9,
- 0x1a1e59a2, 0xe6ce94d8, 0x4ff7e18b, 0x71aff7b1, 0x93b1a3bf, 0xd7df5aeb,
- 0x9ef5dfd8, 0x81e7348f, 0x0d3e90a4, 0x4aec0ff9, 0xca35779d, 0x6305e46f,
- 0xa8abf509, 0x715b38b7, 0x3dc0fdf8, 0xbe10e7d3, 0xa7e7cdff, 0x6bfdbe4c,
- 0xa6ee6cfd, 0xed6c79f2, 0xd6070611, 0x963ad806, 0x55bfb54f, 0x20dfc357,
- 0x90e5ea9b, 0xd13ec930, 0x1b31e6bc, 0x67fa83ef, 0x7ca4a94f, 0xd06e9fdc,
- 0xc38b35f1, 0x0e26a5a9, 0x6b4f9bcf, 0x48de6f50, 0x00bf6dfd, 0x61ed010e,
- 0xec7ce0a9, 0x3abbe47a, 0xa36b95d9, 0x2875727a, 0xd0fe874f, 0x56b81f94,
- 0x1ebe7d40, 0xfe27caef, 0x53062c05, 0x599d1813, 0x890c37d4, 0x63013c9e,
- 0x764f4dc1, 0x3ffd5357, 0x8a73c934, 0xadad7632, 0x83fa9aab, 0x8ff70321,
- 0x847c9e5b, 0x16b7c3f9, 0xe77a4cd7, 0x31f24113, 0xf0497e7b, 0x16f6676e,
- 0xf88c2c30, 0xaf3a82bb, 0xfa9b7ea1, 0x5f14609b, 0xdff8db67, 0xacc72a5f,
- 0xae3c6d4b, 0x316b42dd, 0x2ceee5e9, 0xe8ca7bfa, 0x5f902366, 0x48873e20,
- 0x5cf87af8, 0x40f20a76, 0x6f560d75, 0x78285fac, 0xf8a3e8d5, 0x1675cea1,
- 0xbdecacdb, 0xd79f1b24, 0xf467dd24, 0xeefcb1b6, 0x3a46a8cf, 0xef58f5db,
- 0x1070df50, 0x846d1cd8, 0x7a1161e6, 0xfde36c59, 0xc008dc17, 0xd1b793cf,
- 0xc0ef4379, 0xdf278a31, 0x24aeba67, 0x72880c39, 0x8693c509, 0xdeacbdd8,
- 0xecc9b66b, 0xf197a43b, 0x4ee1718f, 0x382fcfd2, 0xfa455c0f, 0x7805306d,
- 0x03ccaadd, 0x91b726cf, 0x7287fee5, 0x9ecbfcd9, 0xf4a9f441, 0xb6cdfd22,
- 0x4a9db988, 0x1f9df87f, 0xae750bf6, 0x5b83c2a5, 0x9f916436, 0xbcf85ea1,
- 0x5bae1251, 0x0ff7c138, 0x963efa2a, 0xfe10f4e2, 0xf73e6ed5, 0xfb4ddb0b,
- 0xcf4947cd, 0x271666bd, 0x58fdf6cf, 0xf4f61b3e, 0x9f207932, 0x117f12d7,
- 0xc91bde7c, 0xe1cf48e7, 0x9fe57287, 0x9d305fcf, 0xb8291dff, 0x190c9bed,
- 0xfdd86fbf, 0xbbb211c6, 0xdf1e7506, 0x18339da5, 0x9aff6127, 0x1d1cd130,
- 0x5d444fb3, 0x9fbf5466, 0x8f7ed3aa, 0xa9cd3905, 0xa9dfc9bb, 0xbff0717e,
- 0xb8f9a98b, 0x846be94b, 0x1f2cebc0, 0x87f23e10, 0xe58782f5, 0xd18e7545,
- 0x23de6026, 0x585abadd, 0x35ce909e, 0xbb9ec9db, 0xe4fd06d0, 0x34473a07,
- 0xe98f5f9b, 0xb835bfa3, 0xd6fc9176, 0x4c9953bc, 0x9be7767d, 0x8d7e940b,
- 0xc562a9e7, 0x3f098b2e, 0xc71b9fd1, 0xa148b5ec, 0xf584c4af, 0x7c852650,
- 0x15e7c48f, 0xd363fcca, 0xef3e9aeb, 0x685932bf, 0x001e0053, 0x00000000
-};
-
-static const u32 usem_int_table_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x51fbff00, 0x03f0c0cf, 0x1915c58a, 0x19d44418,
- 0x18344c18, 0x20685618, 0xb58969c4, 0x9fd329b8, 0x90c0c2c9, 0x40b9c40d,
- 0x7cc40f9c, 0xfc0c0c4c, 0x17ebc44c, 0xf5b04514, 0x84181904, 0x026ffc80,
- 0x85d70c0c, 0x8bbe1818, 0x03083030, 0xf1402ef9, 0x01ce2004, 0x58a06f62,
- 0x045e900b, 0x2c40ddc4, 0x7cdf8a22, 0x6bf20251, 0x37f95185, 0x847bf8d1,
- 0x1057ebf0, 0x47af2fc1, 0x161b1e40, 0x3e3f22d1, 0x3bd02922, 0x015f5810,
- 0xc7265f95, 0x0f27d0c0, 0xb8a87f8c, 0x4bfc9201, 0x0e5cbb20, 0x6096f6c2,
- 0xf2062860, 0x9bb0150d, 0x2f9403eb, 0x857dca01, 0xcc0003ca, 0x688cbacc,
- 0x00688cba
-};
-
-static const u32 usem_pram_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x7de5ff00, 0x4514780b, 0x74f570b6, 0x9924ccf7,
- 0xf2124c99, 0x00493de0, 0x210e0311, 0x9970c044, 0x46a2c024, 0x141a020d,
- 0x84920275, 0x7e889790, 0x33feaeec, 0xa8a08901, 0x17acb9f1, 0x376141dd,
- 0x0c06e8b2, 0x60e03518, 0xba2eb300, 0xe7c045c1, 0x36bc8026, 0xb9f04324,
- 0x9d6f5ecb, 0xdd33d553, 0xc7c4099d, 0xffef7fde, 0xa55f9f8f, 0x71ebaaba,
- 0xe9d4e7de, 0x278f3242, 0xdf210a64, 0x9f968fc1, 0xf890848b, 0x206f5950,
- 0x8841922e, 0x6df466d7, 0x88cfa64c, 0x68e67a23, 0xd11d985a, 0xef435837,
- 0x9ed5cbe9, 0x186934a4, 0x1c790f21, 0x23e21258, 0x5ab54e84, 0x16f50520,
- 0xe0933ba8, 0x213e3a7d, 0x0ff8e8fd, 0x30f8e246, 0x1a18992d, 0xe0311067,
- 0xf9ad537b, 0x421eb089, 0xc3e6476a, 0x213b16fc, 0x9f9f7bfd, 0xa7eb888e,
- 0xf7c10def, 0xb59efa24, 0x6529efef, 0x13fd0e57, 0xf66ddff6, 0xf108146d,
- 0x71c7fcef, 0x8699ef58, 0x5d130e39, 0xd9b7766f, 0xbeea053f, 0xb6899f6c,
- 0xc0fb6ee7, 0xe5fed126, 0xda0944db, 0xf0233b0d, 0x8275cefd, 0xa695ea0f,
- 0xa4ae47d6, 0x9136c0f5, 0xf8d30f3c, 0x4092062d, 0x613371c8, 0xeb15873f,
- 0x5aac1145, 0x6dd77ebe, 0xa3495f30, 0xf7d04489, 0x2e88378f, 0x28d92fa8,
- 0xaf9d08f8, 0x8c07b5fc, 0xc578e803, 0xc23ea13e, 0x1f1beb41, 0x3ee83a33,
- 0xd8fcef97, 0x7ce146d6, 0x0e2663da, 0xa4a3ee23, 0x52908d3e, 0x03e996df,
- 0x9ba5fbe8, 0xbe802705, 0x4ed9dd74, 0x83695f58, 0xe3a45c3c, 0x228bae2d,
- 0xee6c918e, 0xd7cc08ef, 0xdbe7147c, 0xf9830f26, 0x65dfce4a, 0x6ee52404,
- 0xca2e9193, 0xdf603ae9, 0x3da7bcca, 0x053e716b, 0xd22fe59e, 0x8abf68f9,
- 0x6c270597, 0xdc40c2b1, 0xd7ce8eb0, 0xb05e0a22, 0x8daafec0, 0x7deaac23,
- 0x7d876e14, 0x1bd6fa94, 0x7d605ba7, 0x69458deb, 0xd716f1a1, 0x7d76a7fd,
- 0xdd13536b, 0xf3e3bd69, 0x748287b4, 0x4a5ea844, 0x4fe90b88, 0x8e8119f2,
- 0x85e7e795, 0xe2f7c418, 0xcc38913a, 0x3a15f1a1, 0xe9c07ef0, 0xf1958774,
- 0x12dbc701, 0x842ce03b, 0xc73b6eb7, 0x54c814a3, 0x8f94af8f, 0x7ae83e00,
- 0x2c763d6a, 0x6124f71f, 0x81c7a4f9, 0x33da7b70, 0x1eb5cb12, 0xc67f3e27,
- 0x75cb0133, 0xcf96171e, 0xe9606679, 0xbf63e4f3, 0x58053de7, 0xf1b8f06e,
- 0x253d6ff9, 0xaa79d658, 0xcf26f9f0, 0x7b372c32, 0x65fcf8bc, 0xeb2c2acf,
- 0x6e58b53d, 0xb2d17c05, 0x7ec3e3c1, 0x58753ddb, 0xf1ea7a36, 0x469eebf9,
- 0x3870d72c, 0xb648b2da, 0x7360e144, 0x3b453b11, 0x6573cd89, 0x9b1eb4cb,
- 0xf309eacf, 0x5a46d9bc, 0x3ad3704f, 0x3280cb85, 0xd689b67f, 0xf6b15407,
- 0x1c92f721, 0xf10fad33, 0x3594f6b2, 0x5a089cae, 0xed65a94f, 0x7379d623,
- 0x847d6922, 0xda8fb58f, 0xa289cfec, 0xacf551f5, 0xc9134c7d, 0x18fad0b5,
- 0xefa7ab3f, 0x695ae573, 0xd595bd3d, 0xe6f13f33, 0xb33d68da, 0xa93fbd8d,
- 0x2c3a27c3, 0x55b0f13d, 0x14202c76, 0xb9de4d57, 0x9bca892e, 0x5dc746ad,
- 0x7bc849c4, 0x892ef9de, 0xd90687ca, 0xde6ded85, 0x746eacc5, 0x77b77b61,
- 0x2edff629, 0xaa5db1bb, 0xb7db0fbe, 0x9ed8dd1b, 0xed835d50, 0xdb17b28d,
- 0x8a3f5647, 0x2f468ded, 0x5eaa4fb6, 0x65d7f58b, 0x55e7b61f, 0xaffec7af,
- 0xfed87d1b, 0x5c9bfdf8, 0x05fd6953, 0xe41dbdc1, 0x5dc10ade, 0x9e815242,
- 0xee4093ea, 0xf9f970d5, 0x6d1d101c, 0x446fe9af, 0x6efadc3e, 0xbfc00be6,
- 0xf507ebf8, 0x983edfa2, 0x89bce38c, 0x1c74c8e3, 0xa4e3e2f1, 0x334137bf,
- 0x257bfa4e, 0x382d38ca, 0xc6df444e, 0x24defad9, 0x2bde7aed, 0x0fd9c655,
- 0xdac2b4fc, 0xffa57db7, 0x9ebb4b39, 0xe329973f, 0x89eb847c, 0x1a7adbe9,
- 0xa7c2d03e, 0x7c2083e1, 0xf138e28e, 0xc64f5b7d, 0x327c2d41, 0xd3e1060e,
- 0xeff4e381, 0x070d38db, 0x3869f0b5, 0x97cf8418, 0x7dc19f08, 0x21c657db,
- 0x0e327c2d, 0x5ff3e105, 0xbee49eb8, 0x53fdb38d, 0x7fb67c2d, 0x498f841a,
- 0xef0cf580, 0x3f32bedb, 0xf327c2d3, 0xec7c20b3, 0x7da5ce38, 0x67fb671b,
- 0xff6cf85a, 0xfe9f082c, 0xbee8ce38, 0xaff32bed, 0xfe64f85a, 0x149f0835,
- 0xb633e001, 0xfc69eb6f, 0xc69f0b5c, 0xb9f083cf, 0xdf19c70c, 0x384cf5b7,
- 0x84cf85ae, 0x64f841e3, 0xf626bee0, 0xe3c69c6d, 0x1e34f85a, 0x3267c20f,
- 0x6fb9338e, 0x42709afb, 0x27099f0b, 0x8e99f082, 0xebbb64e3, 0xc7465198,
- 0xce3ef6b1, 0xf0b467eb, 0x104cfd79, 0x38e3d73e, 0xa938e8d3, 0x52671f17,
- 0x933e16a7, 0x29f0833a, 0xeaae71c0, 0x77af38db, 0x7af3e16a, 0x853e1067,
- 0x7db5ce38, 0x2ea4d7db, 0x75267c2d, 0x3b8cf831, 0xa36b9550, 0x3a1754ed,
- 0x95cafa45, 0x40972e1d, 0xd59da2eb, 0x8093bb45, 0xf62a225d, 0x89756906,
- 0xe6cb7df4, 0x8907f498, 0xb9c8eeda, 0x4ac7e813, 0xddb531ad, 0x52213d11,
- 0xb8c4e763, 0xb8f53562, 0xfd340319, 0x3453f3e3, 0xa30589ed, 0xddfded34,
- 0xc0fa9ae9, 0xfe9a4992, 0x3472ab83, 0xaecba1f5, 0xf64ff4d6, 0xa7a9a0de,
- 0xd359baae, 0x7ced787f, 0x6b25fb4d, 0x97ed354b, 0xea6896fa, 0x42fdd597,
- 0xfd747fd3, 0xe5fb4d72, 0xda6a0f8d, 0xd71ffac7, 0x3cb5c7d4, 0xbe3fe9a3,
- 0xfb4d79f5, 0x69378715, 0x6db627da, 0x3cafd4d5, 0xcecebaf9, 0x5f8fd8b3,
- 0xd022ebc6, 0x7f76613d, 0xf8f7e67f, 0x1bac46ad, 0x8ed05807, 0x722d65df,
- 0x35f8a31c, 0xd1c0b5be, 0x7017e28f, 0xf6457e0a, 0xda4b9280, 0x267bf3e8,
- 0xd3b12fb9, 0xdd18f7e7, 0xd8c3db97, 0x041e94a7, 0xc3a50492, 0xfdbea500,
- 0x63d19901, 0x23f3c0ce, 0x95fbe9da, 0x1888c086, 0xb312cf5a, 0x777e811b,
- 0x8a2fcc0a, 0xf4154914, 0xf411348b, 0xce481e0b, 0xa2abc17c, 0x298355d7,
- 0x71a10a1f, 0x24eec957, 0xaade33b0, 0x1d82f76e, 0xee983352, 0xcd21006b,
- 0x4bdfbb42, 0x0607b4fd, 0xe9b92517, 0xb5232678, 0x1bf3d5d3, 0x3869fce9,
- 0xebd00b7f, 0x7c7f307b, 0x294df9cf, 0x9bf33413, 0xe6689487, 0xfce91b37,
- 0xafde4276, 0xa7e7c53e, 0xc8449848, 0x3853845f, 0x094869bf, 0x9180ffce,
- 0xf9ea2bfa, 0x1ff38323, 0xd67ffd86, 0x2653fedb, 0xa43ff769, 0x237fbb54,
- 0xea91ffdb, 0x48fe7cb3, 0xe151ffdc, 0x90ffdb2c, 0x137fb652, 0xbf38371b,
- 0x93ff082d, 0x2f677f30, 0xb3529bf3, 0x5a1ffbb4, 0x89bfdda6, 0xfd5ddfcd,
- 0x82df9f2d, 0xbe139ff3, 0x5a1ffb65, 0x4d1bf386, 0x8fd0276e, 0x95646071,
- 0x1d4fce8f, 0x04490761, 0x40f3a172, 0xfd163239, 0x148497e4, 0x913dc75c,
- 0x8abede8c, 0xf286f4a4, 0x58fccbc6, 0x996c951f, 0xb4e2efd4, 0xb67378be,
- 0xb612e411, 0x21657f53, 0x8d1dea5f, 0x7937d222, 0x4e1be4d2, 0x28d9dbd7,
- 0xc77ea17a, 0x207d9393, 0xe44d2aff, 0x4f787cf6, 0xfe787e22, 0x9fa353f9,
- 0x5f4bef57, 0x8f95ac2e, 0x2df8a9b7, 0x90e547e8, 0x98165591, 0x1fa9aed7,
- 0xa1107ea1, 0xd427c5fe, 0x249420cf, 0xbe6cca8f, 0x04bfa8cf, 0x2fea36f5,
- 0xd5213b41, 0x75e25fb8, 0xae8c307d, 0x3f289f3f, 0x26f3ee17, 0x9e3a2964,
- 0xc8f7f8c4, 0xf807c11a, 0x14597db8, 0x3d687e05, 0x4d38de85, 0xfb0fee9d,
- 0x7c12ae07, 0x86380bcf, 0x9333e01b, 0xbd60478f, 0x67605eb4, 0xe8a21cef,
- 0xb0514fef, 0x8a40d560, 0xb338d08b, 0xa44e4b88, 0x5a59cfef, 0xa2e84328,
- 0x2f061055, 0x2059fa01, 0xe0119753, 0x69278de7, 0x7ae8389c, 0xf1b3b66f,
- 0x63e4ba67, 0x14f5aa6d, 0x3e5766c8, 0xa1414f5d, 0x359feb88, 0xd1fedb43,
- 0x619728ce, 0x3d572d0c, 0xc9ccf381, 0x54dfb6d7, 0x75cfada0, 0xef54eb6b,
- 0x6ef7a0c9, 0xa73fd129, 0x9cfba160, 0x5d2b8417, 0xade75d28, 0x56b70e1c,
- 0x5e0d5ec9, 0xda556dc1, 0x26e0a021, 0x5f7c2fb8, 0xf6ffd9ec, 0xa17ada65,
- 0xb05f5b57, 0xa73e374a, 0xff1ce39b, 0x683e8047, 0x83e80279, 0xa718f3c2,
- 0xd55c908f, 0xc18dc7d2, 0x50fa306d, 0x625c71f6, 0x8ebe3828, 0xdac2c7d1,
- 0x50f4f0a8, 0x9707a418, 0x7a14be9a, 0xc3d38db8, 0x8a1e9ca7, 0x6ae96ad7,
- 0x4cadf12e, 0xb2dfefa2, 0xe9e21766, 0xe8c850a0, 0x3d0a97e1, 0xc1e869b4,
- 0x8f41e9cd, 0x3d38dbbf, 0x4673f6dc, 0xb67c7a0f, 0x5b687a71, 0x29264e7b,
- 0xf14af13d, 0x3c53a9a0, 0x376ef0e8, 0x7c503d02, 0xf987a584, 0x8dd37dc1,
- 0xde02fad3, 0x9c5f03d6, 0x053db01e, 0x4e104ec0, 0xcf6a7ef8, 0x684e54fe,
- 0xc36bc5ea, 0x31b2bfe3, 0x6a98ee3b, 0x57f5e55d, 0xf5531dc5, 0x53375c5b,
- 0x9be45f53, 0xbc5fe9ab, 0xbed350b6, 0xa69176b0, 0x3baac17d, 0xef42f535,
- 0x6ffd35cf, 0x69ad565f, 0xb56ab5bf, 0x9296fda6, 0xb9f534c7, 0xfa6b5fee,
- 0x5eb054df, 0xff273ed3, 0xacfb4d45, 0xf5345b19, 0x34d7ae99, 0x2f3b0dfd,
- 0x31e81ebd, 0xc048a0eb, 0x71e638fe, 0xf71fdd20, 0xa4f2c48c, 0x717c89c7,
- 0xcb0133da, 0x4fcd8d7d, 0x7cbb495c, 0x26882819, 0x91167f4c, 0x2cf64218,
- 0xcaaf5777, 0x504e7d02, 0x7971feef, 0x1077b551, 0x07065395, 0xad6f39c2,
- 0x11c7f891, 0xe2528022, 0x50c407f3, 0x6d1b567b, 0x3dbdeb8f, 0xb614ad6f,
- 0x0a4dab3d, 0xe3e56e3b, 0x61ed4385, 0x7e2133e2, 0x3ec10326, 0xb9f6e2ea,
- 0x204cbdbe, 0x84e7eaf9, 0x8ffe472c, 0x5cfd3031, 0xa2726466, 0x1cff6b6c,
- 0x7fba8362, 0xe685d544, 0x95cca7ab, 0xaa91f408, 0xb5e2e3e1, 0x3ce46997,
- 0x3c6de881, 0xcd38d9d0, 0x5775c5f3, 0xd8ebde6a, 0x2bbae225, 0x7d508640,
- 0x07e48c3d, 0xfd97a00c, 0x8d6643cd, 0xceba7586, 0x355e401a, 0xd8fda3c6,
- 0x771199e1, 0xe63c024c, 0x53d27963, 0x8f71e580, 0x9e63cb1b, 0x788f2c12,
- 0xf36cb0aa, 0x33f2c32c, 0x4fcb178f, 0xfcb0ab3c, 0xe58b53c8, 0x2c5acf61,
- 0x587c7a0f, 0x61d4f01e, 0x1ea7bef9, 0x234f56cb, 0x171e9d96, 0x29bf0a96,
- 0xddd3d0f0, 0x4fa7ae49, 0x805dfd03, 0x07c4e2ce, 0x0a0d57aa, 0x8ae259d1,
- 0x59bdab87, 0xd6f371a1, 0x249d389a, 0x0861e868, 0x81e364f8, 0x5e9c4c5e,
- 0xade7b7c2, 0x9ed82f95, 0x1d8726d5, 0x7ff9f2bf, 0xf9cdbd0d, 0xa216f491,
- 0x7a3a81a7, 0x3d18bd4a, 0x87c7124d, 0xc18e69e8, 0xa71ff4ce, 0x1f6087a7,
- 0x628ffc61, 0xabc6ea30, 0x14573aec, 0x73f3678b, 0xb2d16a07, 0x7b9f3678,
- 0x15ae1d05, 0x48df3fed, 0xc8f773c0, 0x78808fbf, 0xaa61f77d, 0xdf7b9328,
- 0x7a5e9e9f, 0xfd0bbb87, 0x551f22a0, 0xb67ae3a2, 0xb8324447, 0x0cc81846,
- 0xeac84e92, 0xce75bfe1, 0x44bac34f, 0x9f7de162, 0xf3986673, 0x4f670228,
- 0xeb871789, 0x6357eb0a, 0xcfe3bc60, 0xca1323fc, 0xe6148639, 0x688b34df,
- 0x0bff13df, 0x506f804e, 0x499c991f, 0x0c0f0710, 0x3ed1da37, 0xf0b459f0,
- 0x667ad2f3, 0x29ab7e08, 0xdf515a8c, 0xfc2126d7, 0xa2357d86, 0x77e01f7f,
- 0x317f3931, 0x0df7ce78, 0xf3c097f8, 0x62f1f262, 0x1cb89172, 0xfdd2372f,
- 0x9d1ced77, 0xe403a0fe, 0xade185e0, 0xd7e95f9c, 0x7d28bcf3, 0x4aee3a2f,
- 0x75b8e850, 0x88f3a108, 0xefc71da2, 0xc984b86e, 0xdbeec52f, 0x05f5f266,
- 0xb59267af, 0xf9c53de3, 0xbbaf194f, 0xf81b05e5, 0x0c924b5b, 0xf06163f6,
- 0xf5e594a0, 0xda8b76c9, 0xd6d46cfe, 0x19856bbb, 0x3a2768f5, 0x068f67a2,
- 0x1fb7613d, 0x3b72061b, 0x9c654b09, 0xfb464925, 0x4ef72a31, 0x3346a5d7,
- 0xe4c7cf3f, 0x9418e6c1, 0x663da717, 0xaf53ffec, 0x9471b7a7, 0x40d210f5,
- 0x1e419a8e, 0xded4b6d3, 0xcf4af7fb, 0x3c4617d2, 0xbf926df7, 0x4cd0fb02,
- 0xfc0effff, 0x5d61220d, 0x5eb2b719, 0x872e9af4, 0xf3359be7, 0xca1cf7d1,
- 0x2977eb19, 0x891be217, 0x96e8571c, 0x5c638bea, 0x8bae2c9f, 0xcfed6bb0,
- 0xb2bd4d18, 0x635dbfb1, 0x541fc28f, 0x412a92fe, 0xe329fa02, 0x5925d3e4,
- 0x7d740956, 0x1090426f, 0xfd6056e8, 0x466dcdca, 0x95ce03b7, 0x5b7ade19,
- 0x4cdfc51f, 0x897c9289, 0x61cf16b9, 0x9d2fea4b, 0x4ce67a0a, 0x88048ac3,
- 0xbb162c1b, 0xf30fc9ef, 0x79312cbe, 0x0727c8bf, 0xa73df6b4, 0x55c7420f,
- 0x945c639e, 0xeaab8e58, 0x8f16061d, 0x009b8fd1, 0x1c5fc6e3, 0xf79b153e,
- 0x413b074f, 0xc68aa70f, 0xca3746b3, 0x665ffa45, 0xfc0a4e08, 0x13f314de,
- 0x697e3a24, 0x2dc63b5d, 0x11deca4e, 0xbc80bcbf, 0x4b3fb9ec, 0xd528f1d2,
- 0x15a4bcbe, 0x813f99e6, 0x371c444f, 0xf8e54c7d, 0x04c93fa9, 0x4f3910e4,
- 0x4862657b, 0x063bfb86, 0xf90cc862, 0x161bf33b, 0x4fbc01e7, 0xe547bf81,
- 0xdf241de6, 0xb5207886, 0x9cdfe099, 0x00198621, 0x7de433a7, 0x1e1538db,
- 0x87232572, 0x94829533, 0xf1c14c1e, 0xefc1fddd, 0xb4d41532, 0xb9e0638a,
- 0xc23ff8a4, 0x72471877, 0x50b7980b, 0x897b9ec0, 0x97e81ab9, 0x3f1a51fa,
- 0x9a51fa8d, 0x34a3f53a, 0x437222f5, 0x1425e402, 0x9f13293d, 0xb4d27080,
- 0x88ec928f, 0x555262c7, 0xafd1f603, 0xbe6dfc79, 0xe903489d, 0x7d5fcb3e,
- 0xee90b336, 0xc5896ae7, 0xf57394fd, 0x0e0cb145, 0xa33e25a5, 0x7f73d2cb,
- 0xddc61b47, 0x8c3f2548, 0x6fcfcec7, 0x051e6236, 0xdc994ab4, 0x7de949f4,
- 0xa20d89ff, 0xfd06c22b, 0xbd6573e8, 0xff7fdfc9, 0xf212fdfa, 0xb4a3ee38,
- 0xfa01266e, 0xc02791eb, 0x09d723f7, 0x7e185f2e, 0xaf74e42a, 0x013ba7e8,
- 0xf143e37e, 0xf574fbac, 0x4abe1cd5, 0xfb5d29fd, 0xfd2f960f, 0xbcbe4688,
- 0x93efba29, 0x027933c6, 0x00a417f0, 0x1e0fd7f2, 0xf8c7a93f, 0x7f1f81ab,
- 0x6907f1b2, 0xff8e9ef9, 0xfeba4fd4, 0xbfd63d61, 0xcbfadc3e, 0xbb697d5f,
- 0xd297ea97, 0x23653c3f, 0x494edf94, 0x8a4e09b5, 0x2b8db2f7, 0x3b902e6d,
- 0x7c06d792, 0xce27ca71, 0x870f4708, 0x06a57cb8, 0x78804588, 0xc749fc2b,
- 0xa1e9bd3f, 0xf89ec0eb, 0xc76ca36a, 0xc99d6a38, 0x5cf4a26f, 0x8f28b0d1,
- 0x3b7ac18c, 0x16703fab, 0x51b2bfe8, 0xd3a6a23e, 0x953ddfd2, 0x94357900,
- 0x921a0652, 0x7fa3f4a0, 0xf3e1b152, 0x546f60e9, 0xabf20092, 0xff983dfe,
- 0x87d4589b, 0x9ee8c685, 0x499818ed, 0xafd9f780, 0xb3a1e1b2, 0x6afe0da2,
- 0xbe9038c3, 0x37f7097f, 0x3f6b245a, 0x82b9273c, 0x54f2015c, 0x31f10781,
- 0x8bc5637f, 0x4ed31abf, 0xe1b1d3d7, 0x0541364f, 0xea4fc527, 0x9bf05fae,
- 0xcbbd1dd7, 0x87ca4eef, 0xd156bb6a, 0xee468e4f, 0xb2b13527, 0xaedbf64c,
- 0x6ca4f2a4, 0xd2f4ecbd, 0xbd2f65c7, 0x2067dbf0, 0xc9a1fd7e, 0xbf8e9c39,
- 0x073da5f8, 0xe2fad127, 0x3cbf722d, 0x908b0db6, 0x254bc210, 0x7a597ffd,
- 0xafa50f08, 0x463a31ec, 0xc6f7e7b3, 0x78b1f086, 0x19232ecb, 0xb91e13dd,
- 0x6d8cbbf5, 0xa9783096, 0x760e9f6f, 0xbf178adf, 0x3bbc8236, 0x892053b5,
- 0xb9e061c9, 0x85da0f7e, 0x23c42700, 0x6f1053c7, 0x1495feba, 0x145fa02f,
- 0x37dbe93c, 0xe3027971, 0x9e90d239, 0xce9d7e5f, 0xc991f25f, 0x792ffb09,
- 0xec1b2ef9, 0xc55484e3, 0x95d9fae8, 0x4adf2009, 0x1d826f64, 0xe4bcf64b,
- 0xde91bbb9, 0x9ddff78a, 0xae92e2c0, 0x95d406fe, 0xbfb0fede, 0xe0e6eb85,
- 0x1b888afe, 0x59e4aee9, 0xcb47df31, 0x6332252f, 0xb8be184b, 0xf2726656,
- 0x2354f3c4, 0x509dfdd0, 0x22fbc0f4, 0x627703d7, 0xbe6ef3dc, 0x62316a17,
- 0xc3334bfd, 0xc0d930d3, 0x2bd32ce5, 0xf0dd7a41, 0xd38bea00, 0x70895d83,
- 0xd21956be, 0xc437a80f, 0x1912d3fd, 0xc19e987e, 0xc99ea8f7, 0xbfd0e785,
- 0x8c457655, 0x7a87bcd1, 0x297f9945, 0x3bae9f9f, 0x13b5ec12, 0x8ffde109,
- 0xdf0acb9f, 0x4542bb53, 0x66fe2a5f, 0x3561befc, 0xdf856fe3, 0x4067337d,
- 0x180717fb, 0xa07bc0ff, 0xfcbae967, 0x6bbed889, 0xc0f280b6, 0xf8e1fc44,
- 0xf9cc837a, 0xd0aedb5a, 0x24b75d09, 0x05e8ab44, 0xf8458fc6, 0x7a2f5ea3,
- 0x92a7be92, 0x9f309597, 0x0a78e7ad, 0xfe7316df, 0xf96b219f, 0xef8bac9f,
- 0x99653e53, 0x33edfbec, 0x3f94afc0, 0x57e00ebd, 0xfdf61f39, 0x07cdcdb7,
- 0xfa7ca66f, 0x4f857ab7, 0xcf53f2b5, 0xef5b25a7, 0x7a9f4026, 0xa0dbfd3e,
- 0x4f96122a, 0x7cb0f3e9, 0x7feda83a, 0xf02a7e54, 0x45f802ab, 0xc8a7e085,
- 0xa8e0dec3, 0xd9568797, 0xd21e5611, 0xd99201df, 0xba14fe93, 0xf4ade853,
- 0x4143e5f7, 0x52e904ee, 0x5d20bba1, 0xdfa7742a, 0xfa7e16af, 0xc13249f6,
- 0x26bfe575, 0xd65cffa3, 0xe942f2c4, 0x66077b7b, 0xa85c9c20, 0xdeed48c6,
- 0x75d4fd81, 0xaf5eae9f, 0xd5d2efeb, 0xddfd75f3, 0xa6957aba, 0xb363597f,
- 0xfdfe2091, 0xb2e27e9a, 0xb8d1c867, 0x63eaf470, 0x59c3597e, 0xc2e817a3,
- 0xe5f7c012, 0x790bc4e5, 0x221d8186, 0x28ba05c6, 0x7e206b8c, 0xe7d939b1,
- 0x656372a5, 0x743f8b04, 0x58b603d9, 0x618cae5a, 0xb1bc40f5, 0xf29ee406,
- 0xe2c1103c, 0x01f95d8a, 0x9fca8c5b, 0x51126f6a, 0xc8f9b76e, 0x167e708c,
- 0x47c828d5, 0x76b7a46d, 0x4d35ee76, 0x06590cb4, 0xd15aa571, 0x1df83609,
- 0xe0d937d5, 0x29aba9dc, 0xfa02faf5, 0x451fe17c, 0x8ae97b4c, 0x75818db4,
- 0xea4baf11, 0x4e6ff2af, 0x59d3ef12, 0x9a0b7f74, 0xc7739f98, 0x423d9d1a,
- 0x153d20d6, 0x411a9659, 0xe27f529e, 0x86bcf688, 0x1f2945f1, 0xb69d64af,
- 0xd29f795d, 0xa5f3fa01, 0x6eedb41b, 0xa07f0fee, 0x3258c9f0, 0x2ca3fb96,
- 0xf2e5c30e, 0xfaed3134, 0xae8f8a02, 0x68989116, 0x4449bbbd, 0x166f747c,
- 0x234f107c, 0xb7e478de, 0x7940120a, 0x03a9c0a8, 0xbbd8c9f8, 0xf6d8eabc,
- 0x812fe669, 0x3c7fb66e, 0xd9693fe6, 0x11c3fdb1, 0xd5fd406f, 0x263e4343,
- 0xeee7fb3d, 0xff73c08c, 0xa4569dae, 0xef1daef7, 0xd425f90e, 0x6139335f,
- 0xbf3b5d9d, 0xd3f4031e, 0x0254dcb5, 0x306baef2, 0xd8aec78b, 0x3698f5f1,
- 0x33f7afd4, 0xfe6461fd, 0x3fd37761, 0x41fa133e, 0x76057749, 0xe428cec3,
- 0x23d7caa7, 0x6bbbdf30, 0x6e99d7c7, 0x9fb74fcb, 0xd1e79e0a, 0x5b052565,
- 0x2c317d61, 0x8df2a18f, 0xd3542f89, 0x761bcbf9, 0xf6d01719, 0x39ff37dc,
- 0xd768e406, 0x750f6656, 0x41cf6dca, 0xf194431e, 0xe29972dc, 0x8a9813ab,
- 0x33bfcd3a, 0xdf02e466, 0x3fcb84f4, 0x57d63e31, 0xaffca478, 0x62e08781,
- 0x33eacef2, 0x6fefb00b, 0xe318fb3f, 0x4ba4269a, 0xab7fbf65, 0xe57b46af,
- 0xfecefb62, 0x82df6e7f, 0x76fb2fbf, 0xfbef9bff, 0x7abbd738, 0xe749e83e,
- 0xfac1ee3b, 0xae27564b, 0xeef48fb7, 0xffc7fd85, 0x7bffeefb, 0xc52b7de3,
- 0xfbe2edbb, 0x5affcdfe, 0x36f1ffbc, 0x7e3b778e, 0x3fe6f3d7, 0x57df7d71,
- 0x6ff9bdce, 0xf6def78e, 0xadf5d8af, 0x067b2a86, 0xa9015f5d, 0x316182b5,
- 0x92dbbe37, 0xd76c80e1, 0x8f30fd73, 0xc34bce0e, 0x23014df8, 0x904d0bf3,
- 0xfb7e0747, 0x0b89411c, 0x1d751fa2, 0x1bae1fb7, 0xc8768254, 0x9987ae75,
- 0xb55520dd, 0xadfed366, 0x989c0b39, 0x0fd24973, 0x7b3ea1bb, 0xfd6baf32,
- 0xe204f7c9, 0x7f1da812, 0x2d35ce5d, 0xef5ed760, 0xa5eed112, 0x1fbbda25,
- 0x9ece990c, 0x3dfad04f, 0xfadadd73, 0xfada054d, 0x8dde3e1c, 0xc6ffad84,
- 0x7107c17c, 0x13f65355, 0x356710f1, 0x9089942d, 0x5542f90c, 0x98bfc12b,
- 0x7f7daf93, 0xe3c1f81f, 0x531c3c7f, 0x971c0a4d, 0xb6485c20, 0xfa48dce8,
- 0xeebe4700, 0x7d63d9d6, 0x244ccf90, 0x8de38327, 0x838c4ee5, 0xe65b7f73,
- 0x5596cbef, 0xb2cfc0ad, 0xfc56cfce, 0x4de0dee5, 0xe38dffb8, 0x2fe084a4,
- 0xbff444bb, 0xadff9d65, 0xe2fbe5e0, 0x8fe3c143, 0x3a97cbc5, 0xb8b20cbc,
- 0xccabf008, 0x16a985fd, 0xca0fab27, 0xc8de7827, 0x9fa905fd, 0x42d3788b,
- 0xcc8bdf79, 0x5f386ce6, 0x30148f33, 0x1afd71de, 0x3983f511, 0xe575c04d,
- 0x8f31904f, 0x7e4373f8, 0x6f3be026, 0xbf1515dc, 0x0270cb60, 0xb871173c,
- 0xb42a9117, 0xeff9c95f, 0x84cacbbe, 0xf6820673, 0x211722ef, 0xadbf52d7,
- 0x47f04b28, 0x4b157852, 0x0e9d1bc4, 0x1c816f71, 0xb5bdc4d1, 0x47fdf875,
- 0x8b9c6842, 0xbe4deff5, 0x5fe5d4fc, 0x323b3ca9, 0x1e41fa8c, 0x5849bb9e,
- 0xaff156dc, 0x70626f6f, 0x7c132cac, 0x7e774829, 0xee755f39, 0x83e71cf8,
- 0x0e3bdebf, 0xa3f664e5, 0xefd1a3a3, 0x6fd03977, 0x437ee4a8, 0x0d11d7b7,
- 0xa6eeae71, 0x9b3e7e54, 0x55cb536b, 0xfdcfdca5, 0x7e40bfee, 0xa6bb2d21,
- 0xf822b50a, 0xf1802471, 0x08d4ef5c, 0xfe4c31b2, 0x1931ffeb, 0x6154fd38,
- 0x627e001c, 0xfd91e026, 0xd1abe98a, 0xadbc2ab1, 0x3494f6b9, 0xe01e27a6,
- 0x0e754477, 0x0be163f9, 0x75c03e7e, 0xf4db447f, 0xadfb30fc, 0x5638b135,
- 0xe2df5bde, 0x34379c77, 0x9700cb25, 0x9a8aa61b, 0x2655fb73, 0x238d97ee,
- 0x795d60e3, 0x9b655d6f, 0x11697808, 0x66ddf09d, 0xa359d365, 0xb079cc3b,
- 0x3e309e1e, 0xca8fd5c4, 0xe78022ce, 0x082387d1, 0xf2efd1f8, 0xf834c673,
- 0x430d226e, 0x2b882e3a, 0xb5c39afe, 0x72c764d3, 0x1cb65e56, 0x6b4de74f,
- 0xa3858fb0, 0x7fbc01d4, 0xe3211827, 0xbd878921, 0x501bf4a7, 0x1bb5fac6,
- 0xf6e115ed, 0xed823c3f, 0xef3898bf, 0xfbfc2099, 0x51fb2de1, 0xec073fab,
- 0xae3ca983, 0x09ae83d2, 0x0cf747f2, 0x1bfa07c1, 0xe7ac61fc, 0xdf84efb1,
- 0xbeb3be55, 0x8559e981, 0xde70f5ee, 0xccace1cb, 0xe2c4dc7f, 0xfce27faf,
- 0x8159c0a5, 0x4abd7eaf, 0xa6af2a7f, 0xd751e3a8, 0x197d8e37, 0x268a9bec,
- 0x43a06ec1, 0x466d4855, 0xc6cac3e0, 0x6f3864c7, 0xe360eb99, 0x8c7f2912,
- 0xd3a09f3a, 0x9a3bf2c4, 0x0dbcafd3, 0x1adce4e8, 0xe242e813, 0x0dace3ba,
- 0x06bbf0e4, 0x7be19fe7, 0x227bef6a, 0x790178d9, 0xcea7b1f5, 0x8f525535,
- 0x9ceb8c9b, 0x432d9655, 0xb296ecf8, 0x8aa2725d, 0xb14d3a9e, 0x1f3caed8,
- 0x8748e650, 0x5c3e74e7, 0x1311f787, 0xd242ef81, 0xfbf15bea, 0x62aa5bd4,
- 0xd4961d18, 0x3d6232ef, 0xf32bfb19, 0xf9e8f329, 0x369e7669, 0x6e4178ef,
- 0x4b8020db, 0xd4bfc99e, 0x1f4e8619, 0x8ee72b33, 0xb84f53df, 0xf98edd28,
- 0x2c4f48ff, 0x1b44f455, 0xef2bb9e6, 0x3e3335cf, 0xc489e957, 0x49627a70,
- 0xf01123b5, 0x6a4764b0, 0x92c93022, 0x084b4e3f, 0xf03e27a7, 0x43e373b0,
- 0xaeeebbfc, 0x5c4f54d9, 0xb313d2ae, 0xf44e9023, 0x959ae5ef, 0xe88b8d73,
- 0xff6f0509, 0x03e6f2c3, 0xf86113d0, 0x56b346fb, 0x54d8dc4f, 0xc6e27a88,
- 0xfbe6a2d9, 0x17cd6baa, 0x09d913d3, 0x3b2eb173, 0xcfd0c2a3, 0x39bfdc07,
- 0x61fbf3c4, 0x6b17d01e, 0x9b8476cc, 0x26f46f5e, 0x55f6c7d7, 0x825fffae,
- 0x97d722b3, 0x43f761cc, 0x8243a4f4, 0x2e64bcf4, 0xd002eb95, 0x4beb9323,
- 0x4e71e56e, 0x07cd9c9d, 0x96a19b39, 0x0afdecb3, 0x950bd337, 0x9abfc98d,
- 0xae6fdb47, 0xda669d95, 0xdc90e6ff, 0xddcb54cd, 0xe1096635, 0x96ee43dc,
- 0xae7bb930, 0x4fda1c69, 0x53efedbd, 0x3ca96f2e, 0x430ce61b, 0xa2f3051f,
- 0x1ddfdf34, 0xda76fb1d, 0xef2fc02b, 0xfb7e788a, 0xf603b739, 0x033b7d8d,
- 0x7c53e9ec, 0xfcb8db3d, 0x5cf8f4eb, 0xc81ca953, 0xd3d983bd, 0x84459be5,
- 0xe303455f, 0x91618aff, 0x4fad073e, 0xcf16ff4f, 0x60ef1761, 0x0774b0e7,
- 0xfc2ad979, 0xadb77e2f, 0x1605ce06, 0x1cf017af, 0x005fbe19, 0x78731678,
- 0xe3173916, 0xdaf14a39, 0xe53fe7f0, 0xa6a2dfbc, 0x5f0f18f5, 0x2bf6d3e4,
- 0x29f5761f, 0x4cf247f0, 0xaf790f0c, 0xc9f5be08, 0xeba0cf90, 0xe78d5ce7,
- 0xdaf5e547, 0x7ef907e7, 0xb4fe8a17, 0xe4fbe857, 0xd3bfcccf, 0x1ea0fbc3,
- 0x123f252e, 0x5c29fb2e, 0x70f5fe32, 0xd40e0de9, 0x01f3c7be, 0x2b0e3c3d,
- 0x649d2572, 0x6e7e1f00, 0xf15ca170, 0x42e143be, 0xb1e3bbe7, 0x40fb9ae1,
- 0xbcb8738e, 0xf4d7706b, 0x02157e87, 0xb75e2bf6, 0xad024f65, 0x6327abcf,
- 0x78a178e1, 0x070f56ad, 0x03837ef5, 0xaabcfaf5, 0xc7e4022d, 0xfbdfe42e,
- 0xc31ef895, 0x5d6e547b, 0xed3cf546, 0xe4dd20bf, 0xfdf07386, 0x9b940111,
- 0x47c6dd0a, 0x8e25fb30, 0x03a3a1cb, 0x3f515302, 0xe4760a35, 0xd3047f47,
- 0x704f1457, 0xc4f34bbf, 0xbc73a7af, 0x2352b8b0, 0xc52563c3, 0xf4f3f01b,
- 0x63af5e26, 0x4a2de076, 0x39f05ebd, 0xbbab9004, 0x8c5f7664, 0x8e04e240,
- 0x847e9504, 0x04ecd5f3, 0xb4779e15, 0x28dffa33, 0x8f81f138, 0xf043f7fe,
- 0x33dd2bdc, 0xf4afa63b, 0x3e29c0ae, 0xfde78b42, 0xe379ad11, 0x9bf9c1fa,
- 0x737bc4e0, 0x9cf0629a, 0xbb2d58e8, 0xbf9525ff, 0xf00be7a7, 0xd1f7d43b,
- 0x438584cc, 0x088cf37e, 0x79c50fcc, 0xa65d9853, 0x7bfa4f96, 0xfe6fbe80,
- 0x45692551, 0xc7942c7b, 0x04de7ee8, 0x3410cde3, 0x09104ef9, 0x09ff3a03,
- 0x7cd5bfc6, 0x9249f181, 0xef96f31d, 0xedcf2bb2, 0x5e2cbbec, 0x799c1e6f,
- 0xef851e68, 0x13a255b9, 0x0c9ba85c, 0x2059838e, 0x09941e6f, 0x7db9cbf0,
- 0x81e98bb2, 0x853bd428, 0xefc51eef, 0x0e590ad9, 0x8fbc291a, 0x7ca397e9,
- 0xbd511f3d, 0x0a5882ed, 0xf70f1fa9, 0xee76cce0, 0x7880e69a, 0x95fec64b,
- 0x2b39ce70, 0x20f07ed7, 0xbb3573e0, 0xaac8e907, 0xeed3f45c, 0x7e4053ba,
- 0x06f14c3b, 0x9d99cfef, 0x9d20f07c, 0xf155d6f7, 0xcf396e78, 0x9c237f15,
- 0x27dbce63, 0xdfb41d3a, 0x16adeb82, 0x66bcc738, 0x2adc48a4, 0x5a4adcf8,
- 0xaf33be31, 0xb039ceea, 0x0faa12ee, 0xf72864c5, 0xfa844b4f, 0xafdf013a,
- 0xf08dbaf4, 0xdaeb66bd, 0x3a0cc6b3, 0x07ed117f, 0xc75caf60, 0x106e55fa,
- 0x5dfa909c, 0xca18f4d4, 0x020da2cb, 0x4ad3345e, 0x1b335fed, 0xe3a667d7,
- 0xefa3aeb6, 0xbc317ad3, 0x886ee30f, 0x27ce11b9, 0xf13ae92b, 0x78d509fd,
- 0xdf445d2e, 0x75a4cda3, 0xde389dc3, 0x810275a2, 0x264b03ef, 0x01323f24,
- 0x3b27dbc6, 0xaed0fda1, 0xdd611b5f, 0xfaf9d1b7, 0x8817f1d3, 0x3fa0d36d,
- 0xc760a5f9, 0x46ea87fb, 0x0baddc60, 0x542f0c36, 0xe63ac70d, 0x0c103b13,
- 0x651f3a92, 0x4efb0447, 0x755968b8, 0xcdabec0d, 0x406c9f1b, 0x046b3aba,
- 0xc28c7e3d, 0x3c874ddb, 0x2e79646a, 0xc6a3decd, 0xfd1c9536, 0xdf152228,
- 0x1b31a3bf, 0x921626f3, 0x709bcc7c, 0xa47b3357, 0x0f84657d, 0xb2ed6ae2,
- 0x6f3c087d, 0xe7c2695e, 0xfd312f9d, 0x0db839d3, 0xd627dbe3, 0x5fbe04c9,
- 0xf52eb15c, 0x89e3c069, 0x9bd232cd, 0x1bcb2cf8, 0xc5897e28, 0xb1d79ac9,
- 0x352c4f71, 0xa0b57bb2, 0x5f8bd69d, 0xb40af254, 0x51c8ac72, 0x2f4a728a,
- 0x6b72f497, 0x46d593d1, 0xf21ed920, 0x9474e96a, 0xef54a557, 0x90f5a100,
- 0x306a8357, 0x5797aa6e, 0xc8a2c495, 0x5f8874a9, 0xbe0f9616, 0xf1d02d6d,
- 0x8183ecad, 0x5f6bff56, 0xb77a053e, 0x49e04acc, 0x5a7f6485, 0x80417460,
- 0x6d35e65f, 0xa0f812f9, 0xde045e64, 0xf01c75c7, 0x26b37c00, 0x8bafcf0e,
- 0x6f08857c, 0x78b72f25, 0x95ce96ad, 0xb75ce3f8, 0xfd6a5c48, 0x5c451255,
- 0xee877eaa, 0xe74af4a3, 0xf051bdb9, 0x743ca881, 0xbbdefb5f, 0xc76eb033,
- 0xf6e32d75, 0xd22b1ac1, 0x9f9fa1f3, 0x7af4095d, 0x0102bddb, 0xdd789d7b,
- 0x2b0fa035, 0x880e0ad6, 0xcbdf170f, 0xefa62fde, 0xfd0fbac3, 0xa515d19a,
- 0x7fd0076f, 0xf6c7bac5, 0x820dff62, 0xb43fc603, 0x89ed10be, 0xb048af12,
- 0xfa3b437d, 0x614f540f, 0x57b3599e, 0xaffa004c, 0x0764dfb8, 0x23a14953,
- 0xf9db2e85, 0xecc4087d, 0xbe8b331c, 0x15160ab7, 0xc51e93df, 0x4fa82102,
- 0xbd2a4e81, 0x5fdace8c, 0x36409d92, 0xf64ba717, 0xae09fc1d, 0xe767c55f,
- 0x74ef874c, 0x047ea98a, 0x975e6d3a, 0xe23b046b, 0xfcc04f84, 0x49749e8a,
- 0x4a3b6a2c, 0x0567cba1, 0xd07baf26, 0x7b0e8ea3, 0x4ba71dd0, 0x5128fe85,
- 0xb6595fa3, 0xfdf0264f, 0xdd1e9ebd, 0x908dfd72, 0x32f851ff, 0x6f5d0fdd,
- 0xd1cfcd6e, 0x48e0575e, 0x2f5009eb, 0x8fde5892, 0x12e50fc2, 0xdefb0fcb,
- 0xbfcdd3eb, 0x87e78229, 0x2c883f01, 0xe74fc97f, 0x0bf37b7d, 0x66792f98,
- 0x6875fb53, 0xe941bcdf, 0xd9bfe000, 0x7fe8fc4a, 0x950e50f8, 0x6f988836,
- 0xe67f244d, 0xaedf952c, 0xfe2cbfe4, 0x5de11583, 0xcbe4d5ba, 0x6e97efa3,
- 0xf3063a3f, 0x30079611, 0x49bbc7bf, 0xde1fe760, 0xfdf031b6, 0xf2c4a950,
- 0xc176f470, 0xe71648f0, 0xaa2d78ea, 0xa136ec00, 0x57b3dd8e, 0x6c937f5a,
- 0x0775c552, 0x2f38ca45, 0x63e787ed, 0xb8678a5e, 0xa7d6011f, 0xc94ddfbe,
- 0x9178e9bf, 0xa3695fd1, 0x695cf68c, 0xc84e96dd, 0x6c3d2cc3, 0xb2b73f42,
- 0xfc11acee, 0xbc3fdcd8, 0x55f3f784, 0x3c9a8a36, 0x6ff91ebc, 0x04dfa275,
- 0xe50d5bf9, 0xeb437e78, 0x0faf58ed, 0xb17a079f, 0x7fc5ad3c, 0x4bddb1d8,
- 0x95f8b841, 0xbef0d9df, 0x368dd6be, 0xeea9eefc, 0x3da7f9c2, 0x57eaddf2,
- 0xeddf305f, 0x0941fc34, 0x5d48baeb, 0x931d60be, 0x997d746b, 0xc4e261f9,
- 0xa5eb7b41, 0x7c839f2f, 0x7fad8eec, 0x5bd60e7b, 0x9ee75ff6, 0xb21abc83,
- 0xf60ec233, 0x0fa6e548, 0x79559f30, 0xd99224af, 0xfe2f9d7f, 0x3b80f30e,
- 0x6139343f, 0x271dceb4, 0xd1bd8086, 0x04dbe5b9, 0xba5defc8, 0x73c61a63,
- 0x4dcb6e96, 0x05e26124, 0xeb74094a, 0xb21e43eb, 0x0dcd5f1e, 0x73ff98cd,
- 0xe41be286, 0xb17f3043, 0x83e59cbe, 0xe2de783a, 0xdef9f0e6, 0x1b14f23d,
- 0x193f5d66, 0xb30362e4, 0xaf9a2e0b, 0xf1e28078, 0x6fe03ef2, 0x4f2e6af3,
- 0x0cefe3c2, 0x54f141fc, 0x57cda913, 0xe161b2fc, 0xb6819e6f, 0xf35eb886,
- 0x807dfd15, 0x3e4f929b, 0x58f5d22b, 0xd6cdf024, 0x287e63df, 0x01cf2de0,
- 0x21cbf9f2, 0x293e1710, 0x10fe3007, 0xefc261d8, 0x1c774b2c, 0xdce9fe42,
- 0xb5f31fb6, 0xeeebcf09, 0xcb1fc124, 0x9eb1e5c3, 0x96560dca, 0x0fe1c8e7,
- 0x1b0e9079, 0x8ef9e73e, 0x3c958e8c, 0x1ff2dec8, 0xf853225b, 0x4f2c2a7d,
- 0xc7c37cb3, 0x8430af3c, 0xe002612f, 0x7982fda9, 0xec1c0aa5, 0xd42b8700,
- 0xf3e1bcf9, 0xdf79834c, 0x3f805f1c, 0x7cc1d390, 0x041f5a5d, 0xe13e9bf9,
- 0x0f230910, 0x3cb3d73a, 0xfc394ee0, 0x7e4accf7, 0x4f9eb36f, 0xebcb7d7d,
- 0xbffad8bd, 0x221a7c2f, 0x1eae381d, 0xc3e71d4e, 0x9ce3f1cb, 0xf7f07fef,
- 0xfe826521, 0x81cf93fb, 0xda1bcb1e, 0x899f788d, 0xfdf13fe2, 0x5a78f076,
- 0xf31126c7, 0x9bea6b3e, 0xe5eb8e51, 0x273f0545, 0x1bf7afd1, 0x468adebe,
- 0xb63a27a6, 0x3a167d5a, 0xaf5bc74e, 0x6c573d21, 0xd3bcc76e, 0x18af75bd,
- 0xcbe754db, 0xaa7c27a0, 0xbcbc77f5, 0x6dca0c6b, 0x7e98bf7e, 0x9b14631e,
- 0xfc29b2a7, 0xcf9b953c, 0xec59e66a, 0x2dda37ad, 0xb4ef9f17, 0xc609bae4,
- 0xeccadd3b, 0xe2f5d3a5, 0xf9985f0c, 0x49bd714f, 0x0f3b2d48, 0xef12faa5,
- 0x7bb2b359, 0x245b44d5, 0xad4b5fda, 0xf7470e13, 0x7988d283, 0x79aa2b2f,
- 0xce7dcc9e, 0x0af7c024, 0xd604d5eb, 0xabe012bb, 0xbb65e3f2, 0x26dd809b,
- 0xa867e527, 0xf59459cf, 0x8819fb1b, 0xa5ff854f, 0xe08919d6, 0x3bc9127f,
- 0x5d71d608, 0xe812d7ca, 0x8b0f56bf, 0x47f393df, 0x56f3c187, 0x8e27bec9,
- 0x553adb8e, 0xb5e84270, 0x34fbdd27, 0x2e998671, 0xf8b17ded, 0x5fdd1c0d,
- 0xf680d3b7, 0xb7e0d5a0, 0x1ac42ed3, 0x0e849ad1, 0xa43883ac, 0x0214fc04,
- 0xf41e21f3, 0xfdc16798, 0xcd4236c8, 0x94e7e853, 0x449ff734, 0xf774904f,
- 0xc30390a1, 0x385abd28, 0x39712abd, 0x8e9bfb2b, 0xacf786db, 0x6a91a4c4,
- 0x5635df20, 0x4f0dda37, 0xe869fbf0, 0x41e4246f, 0xa74892c4, 0x3a26fefa,
- 0x38fbe6af, 0x1ea6af3a, 0xe3d6d2e3, 0xc2c74866, 0xbe3897e9, 0x05a2e98e,
- 0xcd3310e1, 0x796bf8a0, 0xeb4213c3, 0x4e27898e, 0x6b5fb43f, 0x2801efc1,
- 0xfbd5797b, 0xebb458b0, 0xc8d3eba6, 0x36b4e889, 0x53ad81af, 0x1c4edcf3,
- 0xa5dfee02, 0xabd74e7d, 0x714617a9, 0x09112779, 0xdcc59de4, 0xbbfc384a,
- 0x5fbef035, 0x013837da, 0x5fb843f0, 0xcf9025ed, 0x41f7cd12, 0xb7f4d7e7,
- 0xcd807443, 0x0c871daf, 0x43bfabb2, 0xbfeb9cbd, 0x25fc9651, 0x329e9451,
- 0x62615687, 0x49125676, 0x9ba5efc3, 0x4a7ca1fa, 0x79839659, 0xa32d4227,
- 0x086b61ab, 0x00b0cdf2, 0x3fba9bcf, 0x9351ed12, 0xd2237899, 0xe2367be1,
- 0x1661d395, 0x7043cf1f, 0xa1d0372c, 0xd69455a4, 0x814d7be8, 0x8a42c31c,
- 0xa2687a84, 0xb94657e3, 0x9f28a3aa, 0x2774ccd6, 0xf6c2c619, 0x3bb95ede,
- 0x52f6b90b, 0xaa1a0888, 0x1969eef7, 0xef04228c, 0xbdde20f1, 0x6bc6807b,
- 0xec153a95, 0x6d7f9df0, 0x32eeb064, 0x9b5f7953, 0x3e8feac2, 0xdc2577b4,
- 0xcf6e9337, 0x49f6147f, 0x7851f6cc, 0xd58fe5de, 0x9bddf3dc, 0x39d6517e,
- 0x173f8372, 0x3abe05ee, 0x1df5eec0, 0x777e0d6e, 0xa3787a8f, 0xd1fba945,
- 0xd86fc88f, 0xbcad728f, 0x1bb63f7e, 0xa1cb4ea0, 0x81dcfe71, 0x472f9f74,
- 0x74969a1d, 0xa1af1d29, 0xd93e0930, 0xd0ea357f, 0x30eef81e, 0x578f8704,
- 0x82141eee, 0xc3fcb483, 0xd5932d3d, 0x0f70f870, 0x857d21d8, 0x7d0fabc3,
- 0xebe87088, 0x6c5d29be, 0x935cbc07, 0xd6fbc06d, 0xc16c38ae, 0x45fd0af8,
- 0xe3e23ea0, 0xbbe5efac, 0xa11fc56c, 0xd354ece3, 0x429ef297, 0x4dd1bd57,
- 0x628fb12a, 0xe96a6cf7, 0xf5ca2ba7, 0x25abac36, 0x358f75ca, 0xf78ff71e,
- 0x76e35c00, 0x0b8ea73b, 0xb8b135d1, 0xeefdc1c7, 0x5bf32ca3, 0xf2f254a3,
- 0x6225ec9a, 0x81c9c40a, 0xfb43e217, 0x8de65f89, 0x19f74118, 0xde6032ef,
- 0xfb8b28fc, 0x2b63cc20, 0x7721f808, 0x1ee20aec, 0xbe218827, 0xd9abe650,
- 0x9af5fcc1, 0x396f8342, 0x6015ef3b, 0xb47d10bc, 0xc023e8e9, 0x1db1a3e8,
- 0xa9a2a3e9, 0x6347d19d, 0x06644e75, 0x3f03373b, 0xc60496bf, 0xa23bde02,
- 0x51269abe, 0x151a1ffa, 0x91ba01a8, 0xe5a6e7bd, 0x3d708a5d, 0x7c3f161d,
- 0x7abeca7d, 0x4b6d6fc3, 0xe06943ca, 0xe033ee4f, 0x37029779, 0x858c5fa5,
- 0x58b6c5e5, 0xfc035fdd, 0xedb4272a, 0x6d6fed85, 0x36f31f79, 0xd86efb6c,
- 0x66dbef05, 0x42390c53, 0x5beed6f3, 0xd767f78e, 0xd87dd806, 0x05e024d1,
- 0x3c3bdebd, 0xe104ff18, 0x1a4f7601, 0xf91da3c0, 0x5eff1365, 0x7051ab2c,
- 0x1a1f9e81, 0x890deec5, 0xebf3b0b4, 0xd7111621, 0xcec2c439, 0xbdf7e259,
- 0x95bf8225, 0xfb01bf75, 0xa69943c7, 0xbcfdffde, 0xaf89a4bf, 0xe854f82b,
- 0x28d24a89, 0x4ce47fb8, 0xa2d13b8c, 0xa8d89fa1, 0xca78d514, 0x88788f7b,
- 0x47aa0ef3, 0xff3dd8af, 0x94abd02e, 0xfc00be7e, 0x968dfb04, 0x4a6e0023,
- 0x70cfa07f, 0x0defa1f8, 0x1e60f987, 0xecb617b0, 0x3de2225e, 0x6bc47d1a,
- 0x491bdc26, 0x914667fb, 0xfdf4adaa, 0x425a68cc, 0x13d78e3d, 0x2b207d79,
- 0x1a713f53, 0x3d7cfa04, 0xb64ebb8f, 0xc931fcf0, 0xd186ea3e, 0x5c766750,
- 0xea245256, 0xe16f8505, 0xb738080e, 0x75f9f896, 0x00c5204a, 0x58f85378,
- 0x56fc180a, 0x2452b4aa, 0x18f20187, 0x7dd0f1de, 0x9dcbbd4b, 0xdf652fab,
- 0xcf9fea71, 0xc1f9ebe4, 0x3d17f5f6, 0x099eefbe, 0xb7372df0, 0xad03723d,
- 0x0e7a5c57, 0x479707cf, 0xa1795c55, 0xebf42f7b, 0xdbfce77f, 0x4d874051,
- 0x7ec298df, 0xe1c3550f, 0xc029e2d6, 0xbdf932f7, 0xc951242e, 0xb1e55633,
- 0xcbb71b42, 0xf8299510, 0xffaced1c, 0xf8081140, 0xf0b14af4, 0x9e32547e,
- 0xe5d14e1f, 0x9f87fead, 0xc132f9c5, 0x71250030, 0xcf3628c9, 0x324ecc37,
- 0x9ce0ffd3, 0x173f1a69, 0xaf72477b, 0xdef1d2b0, 0x357cec21, 0x19aaae33,
- 0xc6c4c4ea, 0xfbda26cf, 0x6b13320a, 0xb8c2c6a7, 0xdf18c9d1, 0xdaeb35ca,
- 0xc812bd53, 0x8c9a9269, 0x88d38979, 0x7a633eca, 0x08eeed03, 0xe3902eba,
- 0x742c8cd7, 0xe7ede54e, 0x4d43ffe8, 0x2a99f6e4, 0xc72ae37f, 0x8d54e75c,
- 0xf78b52fd, 0x9fe9fd01, 0xf2e1ede2, 0xfce33e2c, 0x77c9e2df, 0x1eb3f9c2,
- 0xe10e399e, 0x27a3ab7e, 0xd470f5dc, 0xab815dc3, 0x9fd98e1e, 0x86c6a738,
- 0x2e1e9381, 0x48ed48d3, 0xdc0a63d0, 0xc77970f5, 0x9de2e8cc, 0xabde1334,
- 0xe0c48ef8, 0x23350ef8, 0x9ba41ea1, 0x01ef1168, 0xf5e28cce, 0xbab04737,
- 0x64a8ef82, 0xae1eb7c4, 0xc666387a, 0x58e3f7f1, 0x2f00bdff, 0xe202e509,
- 0xcc9ba147, 0x31ddaad4, 0xec507a2a, 0x2e1c69eb, 0xfb46bed4, 0x8ade3739,
- 0xafb02671, 0xe08425a7, 0xd6ce5b96, 0xf2dc3b95, 0xf4a9f83c, 0x72bfbc75,
- 0xff3fe10a, 0xca2f3c14, 0xce0555e4, 0xdad1be53, 0xa69ad3c9, 0xc338829f,
- 0x7efb9350, 0x1080cfa0, 0x1475e783, 0x707447ee, 0xd767bed7, 0xf870f5d6,
- 0xb131fc03, 0x3a14bc27, 0xe3c2c0fb, 0x20c8034e, 0xbcc797b0, 0xf20d1196,
- 0x86c5349b, 0x715c4b8d, 0x0e383f38, 0x63a457a7, 0xcf83b881, 0x423fa9ed,
- 0x5aa3ed8e, 0x36c72552, 0x96d3ee8b, 0x4c729ef8, 0x8e64d3c1, 0xbbc4c987,
- 0x934be20b, 0xd045f489, 0xed0e481f, 0xe7d95bbf, 0xf6103240, 0xc1c58379,
- 0x67df3fe4, 0xbcd4df70, 0xf8b3f984, 0x0b6659fc, 0x02435f7e, 0xce104752,
- 0x91df7829, 0x5a1b18d7, 0x4fbf9287, 0x66115486, 0x7bc3cdcf, 0xc85c29ae,
- 0x75a15177, 0x8482ac98, 0x75f0fdf7, 0x7b33a99c, 0x5bad8f21, 0x9d814774,
- 0x1bec21d7, 0xfc93fb83, 0xe9ff4023, 0xee35cfdb, 0xda7680ae, 0xf1fb08af,
- 0x59162ff5, 0xc3b021fc, 0xb93e7be4, 0xb2953b77, 0x8509ea35, 0xfbe0b37e,
- 0xde81cbd4, 0xdd6103fd, 0xd1d54053, 0xf659e772, 0x6376431d, 0xecf304ba,
- 0xff7966e9, 0x8125c439, 0xdfa7ab7d, 0xa1a74bef, 0x08604578, 0x5d8a29f8,
- 0x1eead536, 0x57cfa569, 0x9b66eff3, 0x05188ece, 0xf4c1f978, 0x4f4b4074,
- 0xba511d0a, 0xecf00f1a, 0x69fcf8ca, 0xcddfc730, 0x7a009738, 0x43dfb151,
- 0x026b8a76, 0x3b37a7ac, 0x3dd5897e, 0x3b017ac5, 0x2e67b15e, 0xdd9087e6,
- 0x74a641d4, 0xcbc71b74, 0xccab733c, 0x600fcdee, 0x48eafdfe, 0x473b5ee5,
- 0xb791d824, 0x54d94ead, 0xd586e707, 0x6b7efe2c, 0x83f1ac95, 0x86dd90dd,
- 0x66fbb3ef, 0x6da65f6f, 0xfe604cff, 0xfb57a17e, 0x3412589c, 0x9cf6edf7,
- 0xc035e0d7, 0x3123c3bc, 0xaf3f413f, 0x79fa7f7e, 0xe6adf3f5, 0x636ad57e,
- 0xcaa748ed, 0x6560592e, 0xaaf750f6, 0xcae0ebc7, 0xe7e0deba, 0x93480f36,
- 0xb5abf754, 0x082c8ead, 0x328c6f77, 0x79ef029e, 0x00e2cfc4, 0xc3dff255,
- 0xe59b83dd, 0xde81f166, 0x98161de6, 0xe1a0768a, 0xf608bf49, 0x4100b0fc,
- 0xe02b3bfb, 0xf8d02c32, 0xee4fcc01, 0xbdc007e1, 0xd65eb426, 0x01f98bb0,
- 0x4fe8d5f5, 0x027f5194, 0x387accf4, 0x17c01e9b, 0x41fe8694, 0xfc85dfd0,
- 0xcfb82ca9, 0x12c3fb92, 0x5ad497a5, 0xf5a37fd6, 0x096ae35d, 0x927755fc,
- 0xe363294c, 0x98d7efc3, 0x93555fa9, 0xf508224c, 0xf8785eab, 0xc06be9fd,
- 0x09758e5f, 0xad287f70, 0xf7fa58d7, 0xf8debfdd, 0xb81afef0, 0x65fa946f,
- 0x7f2aaceb, 0x78fe37b7, 0x0b918c04, 0x3dba47f0, 0xa1f0237f, 0x8a68af12,
- 0x111f7ce0, 0x8068bba4, 0x57274297, 0x7e8f9b2f, 0xe725c445, 0x589e4087,
- 0x16ffc716, 0x46c38f2b, 0x129ff7b1, 0xbf905bdd, 0x023f3adf, 0x8cefcbe2,
- 0x5cfe8a3c, 0xe7c59593, 0xd04a79f7, 0xb9f0527e, 0x3f702acb, 0xf8103fc9,
- 0xcdf1daed, 0x6497e071, 0x43de02c9, 0x9efb24da, 0x7900cf4c, 0x82bedb34,
- 0xa26b296e, 0x6b13bf11, 0xbc0ff08a, 0x35a7655b, 0x9b4cfbf1, 0xa81deece,
- 0x661e63ce, 0x4565ddcd, 0x308bf3fa, 0xeec6567e, 0x7befa0c3, 0xfd212fd3,
- 0x7f4012e1, 0x13fbf390, 0x61a8fcf0, 0x42e20d8f, 0x827efc1d, 0x09cd0d33,
- 0xbe5969f3, 0xf0362fe5, 0x70e7ded7, 0xe2b52338, 0xdb654a3d, 0x83ffbc44,
- 0x0b709bce, 0x161ba7c4, 0xf7efb264, 0x8a6777d8, 0x67ff4cfe, 0x167cc0f3,
- 0xc8efc434, 0xb2727b14, 0xf583ebd9, 0x188b5535, 0xbbac9e2f, 0xbf0a6c37,
- 0x5f6f4c37, 0x712ab49e, 0x87cc04e9, 0xf3676a5a, 0x594fc6f4, 0x9f12c4df,
- 0x24b2df8a, 0xcfeb08bf, 0xc08126fa, 0x5a679715, 0x03c89e52, 0xcec89e3f,
- 0x44ac30e1, 0xcafda376, 0x6fe89fcf, 0xbe43dc37, 0x6cde5793, 0x4aeb3738,
- 0xfdfb6624, 0x77600997, 0xe0b1fbb9, 0x8a07d322, 0x1be5377d, 0x6f557c6d,
- 0x8d34e6e7, 0x41207fbd, 0xa77fb378, 0x55eec022, 0x06ff61eb, 0x7bb587a6,
- 0xe10c7909, 0xf52dbe90, 0x2947b81a, 0x3b068ffd, 0x7c02dbcc, 0x3cf80f11,
- 0x54fcf787, 0xd08dff10, 0xda20d15e, 0x927eb0fd, 0x95f01971, 0x70283762,
- 0x6cdf3c69, 0x91d7431e, 0x5f60d675, 0x3378874e, 0xcffa05f0, 0x2fbcfee3,
- 0x5357f40e, 0x8273c240, 0xa3bbb3ac, 0x60e4a816, 0x3e0379d3, 0x5bfcf37f,
- 0xd881e7da, 0x2dbde0cb, 0xef17e606, 0x28f7fbde, 0x9e6f4b90, 0x82f1c6ef,
- 0xbb4f4376, 0x6b91e118, 0x67718315, 0xc44c5db5, 0xb79003ac, 0xaa9a2d35,
- 0xbb77a131, 0x7213fb37, 0xb4f495bf, 0x1ec0721f, 0x11d8c311, 0x3e74ce1c,
- 0x6f48f809, 0xe36e5c57, 0x24c1e6f1, 0x6ca3ee1d, 0x18b71f3c, 0x8a6e1fbf,
- 0x7d472fb2, 0xaea5eccc, 0xbf1fa7dd, 0x13ef9e06, 0xe711fdd9, 0xb7a7e445,
- 0xda1e2e76, 0x2a5be2a6, 0x5f4f1139, 0xf9db3ff5, 0xd5ffed06, 0x4716489e,
- 0xa9979c97, 0xf50877bf, 0xf97871f7, 0x38f3b007, 0xd7b800ef, 0x2fdb07e9,
- 0xfafc3d1d, 0xc3da1b3c, 0x1ea0e981, 0x376bac46, 0xac5bfe02, 0x90d9d7f9,
- 0x00a3eadf, 0x33925e2e, 0xf3804c90, 0x7403927a, 0x7626a815, 0xb5b627f0,
- 0x97800c18, 0x98c98d8c, 0x9f89b3a7, 0xafaa2e57, 0xe8ab2635, 0xef3f1162,
- 0x877b293a, 0x1f9eaac4, 0x72f931b0, 0x6fe94f72, 0x43e34f30, 0xc61e1913,
- 0x31b06cde, 0xd18afb7d, 0xe866cd7b, 0xdf80c477, 0xfbdeed0d, 0xcfb85efa,
- 0xc761d178, 0x3dff8858, 0xbf607362, 0x6a9b7dc6, 0xf1b7cf20, 0x5452d013,
- 0x14286caf, 0x37de740d, 0xefc58388, 0x1fd0180e, 0x893dc60f, 0xf9f60e2b,
- 0x1bcf5f10, 0xf9cd062d, 0xdefc1bd8, 0x326d7bdd, 0x89b12fb6, 0x2dadc788,
- 0x37a07139, 0xbbeeac5a, 0x8e2fa06d, 0x12c0d5b5, 0x629f7894, 0xb03c4daf,
- 0xf4d19af5, 0x061d89cf, 0x71dba03b, 0xf61179e0, 0x484938eb, 0xd87a408c,
- 0x8f3c746f, 0x3a37bc7a, 0x1d7478d8, 0x2abf016f, 0xff9aa7f0, 0x7f5a34a1,
- 0x858a55a3, 0xfe052efc, 0xf9943eca, 0xb5c4f51d, 0xe4ac82de, 0xb8817ada,
- 0x3a5f92b3, 0x7f944ece, 0xd2e9012f, 0x6a3d7368, 0xda0ef663, 0x30f727d7,
- 0xae15e8bb, 0xe1524947, 0x829f8050, 0x8b1b7aa7, 0xe9eb2a33, 0xdbdffe6d,
- 0xca549e98, 0x9bd74bef, 0xe9178764, 0x0fcb1b66, 0xe6fd7877, 0x6b23c854,
- 0xcf7fc54c, 0xfb679549, 0x93e7a47b, 0x1b057bda, 0xf8060cdb, 0x8762ac0e,
- 0x6de68310, 0x20ebed1f, 0x48f5499d, 0x09878d7f, 0xdd6971f2, 0x48ee2c9d,
- 0x7fbf0de5, 0x81d1cf0d, 0x7a79f87f, 0x1396817f, 0x18afd69b, 0xdbf5f088,
- 0x7042af80, 0x65037ca2, 0xe811ad55, 0x5652d175, 0xe973f316, 0xc8dd6b45,
- 0x58eb459f, 0x5b1ee17e, 0x0ce7ae32, 0x886257a7, 0x27f9001c, 0x657f0e2e,
- 0x6e9c79dd, 0xd13c354f, 0xfa52f30c, 0x73e013fa, 0x4f63e352, 0x7a1572c3,
- 0xc641b53d, 0xb5224a71, 0x7cadf6e7, 0x18076dbc, 0x20dc4fbd, 0x5ffdc0e7,
- 0x0ec4bd13, 0x3637ec71, 0x7e41146c, 0x9cf401bf, 0xf41cf8cc, 0x0f3dc9ed,
- 0xf402fd46, 0x4081bb5c, 0x2315fcbc, 0xe2a2d929, 0x5febdd8b, 0x696ff0d5,
- 0x1835f55d, 0x158b6f97, 0x7c2bce40, 0x15fdc0ab, 0xe42af3a3, 0xfc74ebff,
- 0x2fbd953f, 0xdfb03b47, 0x9fff9c13, 0x9ff94198, 0x10d98a3e, 0xaf38c023,
- 0x07dfc318, 0xa40ff5f7, 0x6d5ca0bf, 0xbf5721eb, 0xcdb57266, 0xafe74a96,
- 0xe31bb6b8, 0x71f5c10c, 0xaa6279ba, 0x02c93742, 0x6296bfc0, 0x8bc01870,
- 0x99e815c2, 0xdfb7cdda, 0xd95c8690, 0x0f39e122, 0xf9e2473f, 0x0277ca1f,
- 0xe486bf0a, 0x6eb7c299, 0xd5d83473, 0x8056ab53, 0xe7971f5d, 0x253cfa45,
- 0x52c687b8, 0xf80a767d, 0x383c8c38, 0x57c7e5c1, 0xf762fbb2, 0x7a000fee,
- 0x221ea12e, 0x13ac87ec, 0xa51780ec, 0xdd8eb1dd, 0x5a3c3ac3, 0x2bbf9cd0,
- 0xef0c1ff5, 0x41fb8f40, 0x7c634787, 0x3c84603a, 0xa63e11d5, 0x839088c7,
- 0x570c40fc, 0x5b3e000f, 0xcdd7f544, 0x4a75fd2a, 0x553a45ae, 0x347970e0,
- 0xc55f5f93, 0x95ff7db0, 0xe21585d3, 0x2f73aa85, 0x024890ea, 0x605167e3,
- 0xf8c22e7c, 0xba4cf6a7, 0xdafde90a, 0x076ef4f0, 0xfe162aff, 0x48f5a73d,
- 0xec33319f, 0x13cb1df8, 0x46223392, 0xb0f91f63, 0x57f1bddc, 0xfd01d7e8,
- 0x46f7bf02, 0xff4025ff, 0xfbdd0c24, 0xf0abdd28, 0xa501d0a7, 0x55a26b8b,
- 0x174f41f2, 0x02a379ca, 0xe7745797, 0x33474f95, 0x9780b079, 0x66f25e8e,
- 0x60fcfd94, 0x81ec9f3c, 0xcf0cf9e7, 0x7c02be21, 0x67e1f22b, 0x3dafe117,
- 0xaf6c76d1, 0xe60174f9, 0x73f2d4a9, 0x9f3e7aab, 0xd1a5eeb2, 0x4b7ce682,
- 0xca34ee7f, 0x5a2bbee2, 0x48ea3e77, 0x34c7d10b, 0xd92ecf6e, 0xff73c268,
- 0x7802d02d, 0xbdfecddb, 0xbb3de56c, 0x0a4f0d44, 0x4cd115ea, 0xe1f42b8e,
- 0xc3246658, 0x55f2ffa8, 0xc86ee172, 0xab59f9ff, 0xdd346f37, 0x77a316c7,
- 0x07e8b5f6, 0xf182af38, 0xd833caaf, 0xc6241f21, 0xde201765, 0x7c0a2481,
- 0x33cd8fb8, 0x1979d52e, 0xe70ec9fa, 0x0f079038, 0xf8297c73, 0x9bd0e055,
- 0xaf0deb9e, 0xe27c387b, 0x8e5ebb79, 0x9efe7314, 0x5c5dfbc2, 0xe045788e,
- 0x2f711b27, 0x59fd6117, 0xe505fe4c, 0x73c11648, 0x727597c9, 0x5e9fe5e4,
- 0x91acbc8e, 0xc2da1323, 0x0bfa11ca, 0x1bf1ffcb, 0x4b1da216, 0x63b7870e,
- 0x3d334677, 0x93fa0f1c, 0xb2f78bf6, 0x3987def3, 0xc48a52dd, 0x0ddac9bc,
- 0x5713cc26, 0x366d90e4, 0xaf7f81c9, 0x16fa06d9, 0x1f76cd7a, 0xc5e70c9e,
- 0x9c074649, 0x03929f5f, 0xd453f788, 0xfa45af01, 0xc7fbc7c8, 0x0223c8c3,
- 0x47ef12f1, 0x9cefd083, 0x9f213626, 0x5046992c, 0x78deee7f, 0x4955d205,
- 0x74008a5e, 0x23175a5b, 0x54ec7b40, 0x94e401bb, 0x962b8fb2, 0x71b0c819,
- 0xd40707c8, 0x6f0ae472, 0xcdbbfe15, 0x49dce343, 0x47210c72, 0x33fb3d1f,
- 0x8da8bc75, 0x22f1d5d6, 0xfbe07f5a, 0x468e8bc4, 0x78801e07, 0xae6c3fd1,
- 0x94779876, 0xea28ff25, 0x912ac4b7, 0xc5d6e4a8, 0x4a1fb7ec, 0x2e3c952f,
- 0x34a95a45, 0x81c4d04e, 0x6073ab6f, 0x582bf81c, 0xe380c54f, 0x7870c34f,
- 0x7b5846af, 0x1fa3ad9b, 0x13e40b97, 0x97e8f882, 0xfc42255f, 0x063b9145,
- 0x2fe2ac7b, 0xa197900b, 0x037fdbf0, 0xd7b57d1c, 0x00008000, 0x00088b1f,
- 0x00000000, 0x7dcdff00, 0xd5947809, 0xe77df0d5, 0x24cb2d9d, 0x7642c993,
- 0x03bbec26, 0x4eb1ab09, 0x04906008, 0x8d441007, 0xb0900938, 0xd2910364,
- 0x208196d6, 0x2b188a06, 0x0eb154b5, 0x4551fa14, 0xdb1ab61b, 0x1a4013a0,
- 0xad563414, 0x61a5afd8, 0x80891d91, 0xe58ad3fd, 0x7bdce73b, 0x264ef333,
- 0xe79f6a02, 0xcdcf0f0f, 0xcf7bde5d, 0x773dfb3d, 0x79632d49, 0x9b19223b,
- 0xed50b390, 0xccc9a906, 0x831b163c, 0x43632f1f, 0x087a3e79, 0x6b9859e6,
- 0xf26b6320, 0x01de7975, 0x9fc75d8c, 0xa269fd3b, 0x678e3e15, 0x30d6fe6c,
- 0xb53349eb, 0x7fe1d767, 0x268c5d79, 0x649f595f, 0x9fc7d93d, 0x24bf8f9f,
- 0x4c33ffc1, 0x2b1812cf, 0xe1a7e263, 0x70ffdfcb, 0xdfc7b418, 0x54dec655,
- 0x805689dd, 0x12dcdca7, 0xd8ceddd5, 0x13c7f933, 0x52d491dc, 0x223ddf87,
- 0xb97178c6, 0x71debde3, 0x55de798c, 0x0fc816d9, 0x4a3d1936, 0x64e2fc34,
- 0xe8826b76, 0x06947e0f, 0x041967c5, 0x55437ff9, 0xfe97632c, 0xc5f4a3ad,
- 0x32f2b89f, 0x7a8afbe0, 0xb439639d, 0x185068ab, 0xd1cc62cb, 0x19cd7995,
- 0x4785d58c, 0x5fd0620d, 0xa748bece, 0x292fca01, 0x8329af66, 0x870800d1,
- 0xa23fc241, 0xd41b7d35, 0xd8983757, 0xca5ec86a, 0xe119ac61, 0xd9a23bd5,
- 0x077e3f00, 0x0fa67e1d, 0x6bca00cc, 0x630b2e1d, 0xff78c29b, 0x7b64c29b,
- 0xb483347b, 0xecd192db, 0xd7a7c004, 0xf40d1633, 0x6983c481, 0x036e92f6,
- 0x1f3099f4, 0x8018f33d, 0x3eadd94e, 0xadd2f115, 0x9163aed5, 0xadf471fe,
- 0x4ddbe68c, 0x6039d76f, 0xf7813afc, 0x543b4d9d, 0xd873e03d, 0x156ada98,
- 0xf728d2d2, 0xa8f3c458, 0x2c6aaaec, 0xa8f7cd8f, 0xa59f686e, 0x00b3ed54,
- 0xe678d85e, 0xcce502d8, 0x848f8307, 0x18d616fa, 0x2398d905, 0x2828ce2d,
- 0xd9c6751f, 0x1de60038, 0xf60a62ed, 0x1a32d8c7, 0xcba45fbf, 0x38b2fd85,
- 0xfd0052a7, 0x2307fb0c, 0x767ec8bc, 0xec568d36, 0xf35c6f00, 0xc01ec518,
- 0xe24d305f, 0xfeccf5ab, 0x73d7ec53, 0xba40e748, 0x7398ebda, 0xfaefb423,
- 0x2c31bf72, 0xd2bedfca, 0xb778d0aa, 0x46b9ddbb, 0xd879f346, 0x9c8fdf0a,
- 0x0067ddee, 0xf1cf8678, 0x03da33ec, 0x519733e6, 0x1e2d297f, 0x11d2479a,
- 0x8ba60e77, 0xcfd4312d, 0xc6be33a8, 0x4baed001, 0xca07cc15, 0x543f9ad3,
- 0x5569af10, 0x71d20acd, 0x825ed367, 0x3f79b537, 0xea11814f, 0x7201dd20,
- 0x8f301755, 0xcd1d16c5, 0xa145b163, 0x99c5e574, 0x7fa82e89, 0x6c5eeac4,
- 0xc79fea19, 0x62771cca, 0xbebff415, 0x7cfb5ba9, 0xb7bc027b, 0x278867c1,
- 0xab72dfd9, 0xb269fa91, 0xf3847fb8, 0x72de9cab, 0x476f7900, 0x48a39fd3,
- 0x88e21a2e, 0x8e8709be, 0x96123d13, 0x78a0ce00, 0x0a85a1fd, 0x85f5aa83,
- 0x23a53340, 0xddb8279e, 0x8899318e, 0xf89f806f, 0x09311ac7, 0x8c62f2f8,
- 0x91c706bb, 0xd91427ed, 0xb45f5022, 0xcf77c5e7, 0x598e652e, 0xfbcf003d,
- 0x6eb2778b, 0x12f77748, 0xbb7b7ba4, 0x21878f81, 0xb38b313f, 0xa4bbfb16,
- 0xce38e9b0, 0xf942984b, 0x979e064b, 0x95abfaf8, 0xeb11ebe3, 0x7896c5a4,
- 0xf02b278e, 0xbc614bf1, 0x7a1eb05d, 0xb3bfcad7, 0xcd617e0b, 0x1e705f9c,
- 0xbb64bfa8, 0xdbdfa2dd, 0x3d5cee9d, 0x08cd93e7, 0xde11c8e7, 0xc3b7c87d,
- 0x90fb3cf3, 0xe098d3ff, 0x27ce3c93, 0xcfbefcc1, 0x467ea36a, 0x8865699d,
- 0xb9852cf7, 0xd32ee902, 0xa1ae10d7, 0x89a3dfc8, 0xb61e407f, 0x52c378e3,
- 0x800354aa, 0x13acc712, 0xdec67758, 0x5da9dab6, 0x3ee708e6, 0xd3ab37e4,
- 0x207cf245, 0x2be54ac2, 0xc07f3833, 0xfc407ff7, 0x2ed3cb05, 0x7e01a394,
- 0x7e438a39, 0x8fc8ec8c, 0xbcf013bf, 0x63a5e42d, 0x613feeff, 0x3acd71ff,
- 0x0c9d02a7, 0x65e9123f, 0xa2f874d0, 0x8fe1152a, 0x00ffc063, 0x358e6da0,
- 0xa52ce507, 0x5d20a1cc, 0x875c229b, 0x230fd4ad, 0x4732b9bd, 0xef86ade7,
- 0x893b46e6, 0x3ed8df7e, 0x366667ec, 0xc01f6fcc, 0xe115fc1e, 0xb6b07b03,
- 0x6ff4f508, 0x3d4469ff, 0xd7f2976a, 0x38a22434, 0x48ae3f80, 0xf7a7e0bd,
- 0x410bd271, 0x73d60ef4, 0xebf6f4c1, 0x039ead05, 0xf4e05d7c, 0x9f226770,
- 0x522f35c5, 0xead07eb9, 0xd1e8ceb5, 0x3a083f41, 0x7e708a5c, 0x0c5cf881,
- 0x7ae38832, 0x583eb346, 0x0e1d99de, 0x76a4898b, 0x1c3b45ff, 0xd1df1316,
- 0xadcceb0e, 0x47c01507, 0x576a8379, 0x8fd50a61, 0xff489cd9, 0x8714eb17,
- 0x41a4e509, 0x71787e25, 0x4bd93865, 0xbb67ef09, 0xdbb107a3, 0xcff21520,
- 0x8ec9dddc, 0xf188c656, 0xf18790ed, 0xd679592f, 0xc5277568, 0x1793e804,
- 0x4308be1b, 0x644ff73c, 0x62c64e03, 0x0ed6a70b, 0xf0290883, 0x537f09bd,
- 0x6b83af10, 0x69ac1454, 0x95269dee, 0xfb1dd6e8, 0xfe5ace1b, 0xbd700d9c,
- 0xceb46dbc, 0xf537c81d, 0x05ec6757, 0xb8232bf8, 0xf7b4be5d, 0x33e42f5a,
- 0x92f77f59, 0x3f7bd262, 0x13192b07, 0xeedf1fa0, 0x61eb8273, 0xd53d6856,
- 0x2a76871f, 0x850023d7, 0x7a3ee651, 0x70d427f4, 0x27f5aa87, 0x7baa3988,
- 0x7f107e02, 0xbf84e18d, 0x77209eea, 0x48e70419, 0xc5bf7fec, 0xfca092c8,
- 0xb623c80a, 0x037f7093, 0xe2074778, 0xaa6f0fd1, 0xe08454f5, 0x5f0fd50b,
- 0x0e905d3b, 0xd16abfd0, 0xb12e3cd3, 0xb3d20770, 0x4864e8ce, 0xe151cf7f,
- 0x55ba081f, 0xd4bb9e08, 0x1b88f430, 0x91e2f7e6, 0x7f7e0754, 0x984afea9,
- 0x46fd122e, 0x979c14f7, 0x851ad69a, 0xc35f70f6, 0x032dbe95, 0xc54dbf48,
- 0x4e872bf2, 0xbe03dcd8, 0x8466fcd1, 0x7e7687a6, 0x9ac8fa95, 0x6150ff40,
- 0x7cc17e7c, 0xfe3434a4, 0xf244194b, 0x7a1f50c7, 0x1ab799d2, 0xa072bde6,
- 0x997ba7e0, 0x983ee51d, 0xabab46de, 0x6e402622, 0xaaed15ff, 0x9c70b842,
- 0xcf342194, 0x741f9885, 0x41a66678, 0xc31bf387, 0x7f4a6ed0, 0xb0effd0f,
- 0x4eff7e21, 0xfe7dafce, 0x3a0daf3d, 0x3fbe68c4, 0xf80071c6, 0xaf803ae5,
- 0xeac18c12, 0xfb79c08c, 0x62e51e88, 0x48e6e57e, 0x61f30a9f, 0x5a170cbb,
- 0xd6e81ea4, 0x4fa07e11, 0x19e7c20d, 0x46e238ed, 0xd235fefa, 0xd1f88d51,
- 0x5fd15b37, 0xc6acf985, 0x28a2367a, 0x2fdfe711, 0xf505b9d2, 0x18cb4bfc,
- 0x57a5f3f1, 0x4c137798, 0x1d7efb76, 0xd646cbf1, 0x9fbef88f, 0x570cf2ee,
- 0x3af3c924, 0xb9ab3b84, 0xb77a8756, 0x43aed7a7, 0xb9b7da7d, 0x3e23a74e,
- 0x8622ff70, 0x5799e4fc, 0xff5f00f4, 0x37ea556d, 0x686f07e4, 0xaf40ef7e,
- 0x92f481cd, 0x7c16cb78, 0x43788d90, 0xbfaad083, 0xe3f662d0, 0x52c3e80d,
- 0x63fb1d6c, 0xf11d25ac, 0xe9faf8d4, 0x5fd02d5e, 0x67a71bc5, 0xfe2a5e20,
- 0x18262260, 0xd1be87f3, 0xe59fefc8, 0x2e67f684, 0xe872ad2c, 0x257a9fc1,
- 0x85d91ba6, 0x446cd632, 0x6ebca13f, 0xa01f4381, 0x76ffa5cf, 0x8f9cd0c8,
- 0xaa1a1ffd, 0xe78065b2, 0x5de18e2b, 0xd13b0858, 0xbfa12fee, 0x472fb006,
- 0xafcf11d8, 0xff734567, 0x20f646d1, 0xa5a1fdb8, 0x7a631c73, 0xa1dfde74,
- 0xbdd361c1, 0x907e7df0, 0x8634741f, 0x18b6b5db, 0x2141876e, 0x8bce113b,
- 0x3d78b7bf, 0xc8717450, 0xfd0c5147, 0x641f5dcc, 0x2e8f807a, 0xfe47e6b2,
- 0x35767288, 0xf971d692, 0x5cca3f83, 0xe5cbf166, 0xdcf8231d, 0x70ed78ef,
- 0xe7da1d94, 0xe717df6f, 0x1ddfc009, 0x9db57f4c, 0x5c7033af, 0x7d33e346,
- 0x07a42f4b, 0x04d9e3fb, 0xaff9a43b, 0xf9c715bf, 0x74874120, 0xdbf4245e,
- 0xc028b0ef, 0x525fcedf, 0xf3247c41, 0xe6666de5, 0xebc80d8d, 0x04b88d9b,
- 0x648b6f2e, 0x37b7685e, 0x7a4712c6, 0xa3259926, 0x5f14e99e, 0xe0cf8937,
- 0x43cf8972, 0xa3a6cf83, 0x2759f15f, 0x1b6f70fe, 0xf7ced76f, 0xd74fc14b,
- 0x7ceff3fb, 0x0aec3ea5, 0x8d845df1, 0x638ae9d3, 0xf7f41764, 0x1ebe8df2,
- 0xe4ed10d6, 0x4f1832fa, 0x8d2b5f6f, 0xdf7f7ec0, 0x050bca66, 0xfba6de97,
- 0x21ca7e76, 0x1fc02a80, 0x53baa6dc, 0x9c1fc26d, 0xbe8af90c, 0xbad1c657,
- 0xd08bf25a, 0x4f30777b, 0x306fca23, 0xf77a487f, 0xfadd01b0, 0x296672a3,
- 0x318bb748, 0x4237ce76, 0x047ca41e, 0x9d3831e3, 0x50ee6460, 0x62af80eb,
- 0x98c35e24, 0x23e1f407, 0xdf640d1b, 0xf8fb5f0f, 0xf7e04cde, 0xd60c1bd3,
- 0x9ce430e5, 0x3ea5f617, 0x0673f503, 0xe40aac9b, 0x3d7ddb4f, 0x5f4bee50,
- 0x0fc85d50, 0x923c37a7, 0xf3d21330, 0x0065bf20, 0x0346e947, 0xf8d9cf95,
- 0x159f9528, 0x42fa5d72, 0x97d47f7c, 0x4eaff787, 0xf9ce3a40, 0x486989ea,
- 0x6b46ed97, 0x9690c1ff, 0x631c536d, 0x6f3df002, 0xbf269873, 0xe0e6c75d,
- 0x995d243c, 0x47af6ee2, 0xa6d53f13, 0x1f7176fb, 0x04dfd69f, 0xa0aa72ff,
- 0x3029c4e3, 0x57a18aef, 0x77dfafc8, 0xc9ec9c20, 0xf92a919b, 0xffc1be8f,
- 0x20db9def, 0xde95fb9f, 0xa09dbe41, 0x674158f3, 0xb7a45cb0, 0x9f3ccc4b,
- 0xfc9ebafb, 0x4a8b5ccf, 0x91f686f8, 0x7bfea163, 0xf40fbda2, 0x5321ca2c,
- 0x848dd7b3, 0x0da36376, 0xf7d0ed0c, 0x19f2f37c, 0xdb3bc9d8, 0x025bc7f4,
- 0xd59a33e6, 0x387f41f6, 0xca821987, 0xcf2c7a9d, 0xc7cb6b35, 0x2cfbb8f6,
- 0xad630ffa, 0x77c972da, 0xfab4d88f, 0x7381df62, 0xf3009b3f, 0x92a4392b,
- 0x7d237cff, 0xafc22efc, 0x5dbf3a47, 0x3bbe0db8, 0xf872b02c, 0x4915e9da,
- 0x142357c8, 0xd3acf186, 0xe3cb42d7, 0x665ea41f, 0x7e3edf40, 0xe63816fa,
- 0xdc51e7b6, 0xa0b119ef, 0xdff08f3d, 0x7afb1ebc, 0x8d9b753d, 0xed8233c7,
- 0xfcdcb046, 0xfe46ecb7, 0x3dd2b7e0, 0x837f4a16, 0x5ced85e9, 0x89eb06ef,
- 0xe1213b60, 0xbcb7860a, 0x0fb1a74d, 0x191ea15f, 0x8c27681a, 0xc3be2764,
- 0x6d8370f5, 0x30f5c768, 0x2f8431f8, 0xad3d30cf, 0x6adfc1c3, 0x220376c4,
- 0x0039b1ed, 0xb76b0ad2, 0x167fb208, 0x405b7ef7, 0xb6ffaa1c, 0x8dea1d5a,
- 0x418cf8f6, 0xeb91a71b, 0x9d8477d5, 0x1cfa13a8, 0xceb4abd6, 0x4eee18df,
- 0xc9b8e3d4, 0x8c96c746, 0x48f9f88e, 0xcfccefb4, 0xbeac7e95, 0x8fb1fb86,
- 0x389a5d58, 0xa893eb19, 0x5fa2fb89, 0xd9edf28e, 0xfcf34e1b, 0x420d7154,
- 0xe733d439, 0xf4016ddf, 0xf87036a9, 0x8f89e183, 0x319276e5, 0xb207f917,
- 0xd0e8f67c, 0xd5895c7a, 0x679cfb53, 0xff474fef, 0x07c6d3ed, 0x7ebf51d2,
- 0xede7141a, 0x169e1e4c, 0xb0a4faf2, 0x2e223123, 0x11ca14f0, 0x9dda41e4,
- 0x55fbe1db, 0x57245d4b, 0x9d3a5d3f, 0x2e9667d2, 0xb613faa1, 0x9adf1a0c,
- 0x775767f3, 0x35c9d3c0, 0xd989d92a, 0x18af5746, 0x59a4eef8, 0x1385f147,
- 0xbb799155, 0xd19cb122, 0xb3f6727a, 0x0278b613, 0x6c277ee2, 0x6743a27a,
- 0xfd8f8cf3, 0x9cbdfa66, 0xbda144b5, 0x23d7e76a, 0x2db5ec1d, 0xac7fe316,
- 0x55db0125, 0xb6bdcd2a, 0xb7c71d29, 0x2c7c6732, 0xf59197f2, 0x0ba9b947,
- 0xb828f6e7, 0xe72c4a5d, 0x1fa1bfc3, 0x8a7efd0b, 0x9e842b76, 0x2f3a0bb1,
- 0xb1ed38b4, 0xc922efa4, 0x81b8275f, 0x728cbe5f, 0x60b84776, 0xd313d65d,
- 0x7c785d61, 0x2ac5b16e, 0xf0a9c3f8, 0x5fab8e75, 0x5bf8886c, 0x609ef167,
- 0x7811de38, 0xc9038e0d, 0x8681c654, 0xbcf9f2c6, 0xe26ab36d, 0x0eff1842,
- 0x79f9ff15, 0x1ba3d72c, 0x2a3c5bc3, 0x7c03c3ca, 0xdb25de3d, 0x2b7c60a3,
- 0x0736bf25, 0xc5775fe3, 0x2da5b8f2, 0xeb889dcf, 0xa344e4f6, 0x3736e303,
- 0xea038f2b, 0xc05f7c9c, 0xd63823ad, 0x7ac27b37, 0xcd095c01, 0xa4231cee,
- 0x0d317153, 0xaac2edf8, 0xa0dd2196, 0x6b23211d, 0x9157b87f, 0x92686c8b,
- 0x4028f429, 0x6772861a, 0x454f728c, 0x559b0cba, 0xfa718d55, 0xffbe3294,
- 0x77715670, 0x9c9f01b5, 0xa43c2b7d, 0xe8225c3f, 0xc9d194cf, 0x36b3fa68,
- 0xacae081b, 0x819f3fcd, 0xf9b59f7c, 0xa012bd2e, 0x1ac79687, 0xdf67fe68,
- 0xe295d79a, 0x58989f16, 0xea7a10cf, 0x1e5f8287, 0x69d87410, 0x8b7fcd0c,
- 0xac6fbb45, 0x55405bcf, 0xe2f9f569, 0x5b3880d8, 0xd265f945, 0xed6393e7,
- 0xfaf3ce34, 0x80c903ba, 0x3167e7cf, 0xe68a0787, 0xf148dd6d, 0xbac69dd7,
- 0xe4efb8f1, 0xa431d0a9, 0x7f03fefb, 0x7e8c9038, 0x60fb2ce4, 0xbfda23f4,
- 0x4ad2f43f, 0x0e7e7f2c, 0x4ff88c1b, 0x60ad3ef2, 0x619fe63c, 0x7faf84b5,
- 0x65b1316e, 0xbf7db718, 0x210ffc6e, 0xc74cbebf, 0xcf04bf50, 0xe832461b,
- 0x19f53112, 0xfd382374, 0xba4a0f51, 0x91190303, 0x886e921e, 0xee90edbf,
- 0xc11af2df, 0x2a9ae12f, 0xb6f3dee2, 0x7c8f1f6e, 0x53665c92, 0xe1204e30,
- 0x793d91ba, 0xd9dbf631, 0x0ed0ef93, 0x221b12bf, 0x0ec21d2e, 0x610d88ef,
- 0x2fed8387, 0x637738b3, 0xe1d91bbb, 0x36ff82e1, 0x7fed06c6, 0x08597ee0,
- 0xed8d0dba, 0x1fdf0f10, 0xe3ff621b, 0xdef0f146, 0x43ff72b1, 0xc97f0f1b,
- 0xad6ff5c8, 0x293c3d8d, 0x1374bc84, 0xb5d6ebe3, 0xc67ed11a, 0xf5212835,
- 0x518b62d9, 0x1c7e1fee, 0x125fb01b, 0xe0438fac, 0xefb628f7, 0x17b7cdbb,
- 0xe9890d5b, 0x5bee8111, 0xdeb0ebbf, 0x29ce310d, 0x22fb3f81, 0xf6a6fb46,
- 0x0afa462a, 0x141e5ef2, 0x371429f4, 0x934f38b0, 0xbec1badd, 0x1cd69dd5,
- 0x3ee483f2, 0xd6ab54d5, 0x938b8c4f, 0x239f9ced, 0xd89d699c, 0x3c097f89,
- 0x70dbfcc1, 0x4c45b8dc, 0xf7231fb3, 0x3caae261, 0xcd0b318a, 0x6af8a311,
- 0x32f758d7, 0x1d6bb403, 0x209b1cc9, 0xcd685d1f, 0x9b6a7d41, 0xfdc468e3,
- 0x7917959a, 0x02e57e3c, 0xfd4e5de6, 0x7732f9f0, 0x17ca2f37, 0x2e302dd2,
- 0xe1c71110, 0x72e38888, 0x1cd27606, 0x8f0ae1c7, 0x9293b00b, 0x3e75ba1e,
- 0x1adae895, 0xd0054eda, 0x77df46d5, 0x50efd742, 0x3771ed2e, 0x8cf71fe7,
- 0x19be05bb, 0x7c737718, 0x4b4c14f3, 0x8f04dfec, 0x0ff38997, 0x2cf80f1e,
- 0xf826ee2b, 0xee2deaec, 0x50881e8f, 0xa5dc5dbe, 0xc4275e23, 0x6b77d085,
- 0x487d75f2, 0x4770b35f, 0x233abb28, 0x7dbff22e, 0xa086645e, 0x179d2df7,
- 0x2d27f179, 0xdcb3a446, 0x06f090f7, 0xe591139f, 0x264a0d15, 0xf6733fae,
- 0xc075a35d, 0xd37fc6a5, 0x79e3a03a, 0x42ee3e0f, 0x678003e4, 0xcea03aac,
- 0x7977f207, 0xea56919b, 0x22ffb32a, 0x4df6e31b, 0x53b5e606, 0xefb6337b,
- 0x7efb78c7, 0x633656db, 0xd31faadc, 0x547ac47b, 0xa8fdceb9, 0x7ee39468,
- 0x8d5b2a4d, 0xbebcadf9, 0x6197998a, 0x847a3a5c, 0xf003d98e, 0x670ce319,
- 0xc67c00f6, 0x7934d9e6, 0x2f9e4eb9, 0x25778dc6, 0x32efbe6b, 0x7da69bbd,
- 0xa69fbb92, 0x10ce653e, 0x6aad3e4d, 0x577da694, 0xf981cfb0, 0x9addcf0c,
- 0x266bddf6, 0x6b3df26b, 0x3fb4d01f, 0xcd9eaacd, 0x9c7a79c6, 0xce003dcd,
- 0xdece0259, 0xdf358beb, 0x0dd5d7f5, 0xf920a1f3, 0xffee1f14, 0x326c16cd,
- 0xfa73c44b, 0xfa69e77a, 0x5e6aff3d, 0x9df80293, 0x19386b5d, 0x7c219f18,
- 0xea4b7e00, 0x8c1cf615, 0x5b5eba5b, 0xe9e1a73f, 0xce902995, 0xe7cb6af5,
- 0x829cbee1, 0xdf2dadfc, 0x823d73ad, 0x71ed9deb, 0xe228ce22, 0x7f03ac3d,
- 0x97b8d244, 0x9778f037, 0xc41de9ea, 0xb13a5a1f, 0x762fc96f, 0x44a62fc1,
- 0xd984bf2d, 0x7a52fcb5, 0x1f30e770, 0x88ff88eb, 0xe47c413e, 0x78017f81,
- 0xf895f897, 0x7cb438b7, 0x9de15df5, 0xdb91af31, 0x3ff96d0d, 0xb5f1b4e2,
- 0xe3ee917e, 0xd4aeb7a8, 0xbf71522f, 0x7df1e58d, 0x57f52bfb, 0x6bb21d07,
- 0xdb3ad7f6, 0x17173a4f, 0xfb175718, 0x3f709749, 0x137636f1, 0xfefb89fb,
- 0xd900f885, 0x1f801b77, 0xb98708d8, 0xcc30ff7d, 0xac147fbf, 0x760a6537,
- 0xb238cbe3, 0xd77dfe27, 0x587af86a, 0x085c5ff4, 0x9387dcaf, 0xf9e472e7,
- 0xe7c91621, 0x3c01fb29, 0xf143f1a8, 0x022d9ffc, 0xf7dbadd7, 0x96f5a42f,
- 0xc4c43f3c, 0x7e10bfb9, 0x3aefe93f, 0xfc8935fc, 0x6e78f081, 0x6d3123cf,
- 0xf9c407f7, 0x3bcf692e, 0xb7ee47eb, 0x7b2a9675, 0x6c3fda55, 0x9b1dc255,
- 0x5e93d842, 0xfd72dff1, 0x1c43a675, 0xe07c57ba, 0x2bd1ebfa, 0x00aed007,
- 0xb962fbde, 0x5af602c5, 0x5febdbf1, 0xbf114444, 0xbd541eb6, 0xb2e0a1bd,
- 0x036d1ed9, 0x6984363c, 0xab4c88ed, 0xf403c9cc, 0x3daf58b1, 0x11f727e7,
- 0x6367db83, 0x27fd80fb, 0x8fe34ef8, 0xfdc21cac, 0x6e78ecb5, 0xe488bfdf,
- 0x9114c1fe, 0x175a0caf, 0xbf70d655, 0xe9f8236c, 0x4cfd010d, 0xfb50b789,
- 0x533911a5, 0xc08e29e2, 0x332bbbd7, 0x5627f214, 0x21f90a2a, 0x5347a267,
- 0x9cb8b5fd, 0x623fc4c9, 0xbbe8299c, 0x6edaffc1, 0x38bb1e1c, 0x37fb238f,
- 0xe6f6f3c7, 0x4e94d1f8, 0xb88ab789, 0xf21fb5b3, 0x93846547, 0xa1aa35fa,
- 0xc7a6a5f7, 0xb5ad79f3, 0x6a27e930, 0x84e3fee2, 0xbf38c4de, 0xf9a3fb89,
- 0x71fc1363, 0x7f66a67e, 0xf1138c68, 0x773e857d, 0x53ba9ea2, 0x78b3bdd0,
- 0x758fb3bf, 0x75276e3f, 0x12fbf78c, 0x1dfbc643, 0x0fde28e3, 0x5e71ea5f,
- 0xa47f71c1, 0x2fcd8443, 0xb7c48f3f, 0xd45483db, 0x7746f54f, 0x5abbae35,
- 0x0eff8377, 0x2dbc7dc5, 0xf0301fb4, 0xae077750, 0xb06656af, 0xb7e416bd,
- 0x7fa18c65, 0x5ba2df5f, 0x6bf5061e, 0xf58acc3c, 0x75f03723, 0xbb7ae95b,
- 0x8069a703, 0x8865b075, 0x8bac1f5f, 0xd7bc218f, 0xc46e4cb7, 0xf73581fd,
- 0xa19a1b32, 0x1b9b565a, 0x06d0fe85, 0xf8dd7216, 0x09b39094, 0xd4557b39,
- 0xdfe8f117, 0x53d3a087, 0x0fa04e82, 0x879d22d6, 0xf0afbab7, 0x4fae38fd,
- 0xfae22548, 0x1bcebf74, 0x373f3d6a, 0xf21d773a, 0xe86f40c1, 0x0b5ac3f5,
- 0x1175b7e7, 0xdda8e7ae, 0xb5ee7e2e, 0x59dfea54, 0xba07a63a, 0x9d74114f,
- 0xdf9f81b2, 0x5faed760, 0xc89fa557, 0x7a867fa8, 0x8b5ef4a5, 0xa543e317,
- 0x821e190d, 0x7a38a5cb, 0x7868bea2, 0xd2f985df, 0xc62b2cac, 0x657f9c23,
- 0xe43ea9ca, 0xbfae3262, 0xd494ecf4, 0xe3c76427, 0xb269df68, 0x16b5b7e0,
- 0x0d473f3b, 0xfc008e28, 0xb6586e97, 0x7cefcf17, 0xfb466bf4, 0xd6d4474b,
- 0x54d9d861, 0x2192ce40, 0x2159ea98, 0xfef82bc5, 0x1fa2bdd5, 0x5c61bfcf,
- 0xa9dc7fb3, 0x3e69070d, 0x63cc0c47, 0xb4ba3e06, 0xfa3b3ee7, 0xcde32bdb,
- 0xfb93c714, 0xf75547b2, 0xf48464e3, 0xda0815ad, 0x56110dfd, 0x43fc7f8c,
- 0x82465df0, 0xc7d21f7b, 0x057c7cbd, 0x6596c1da, 0xa3c474a6, 0x1a92797b,
- 0xd7ba7007, 0xd1ef342a, 0x788c93cb, 0x8ae6617e, 0x4f50e3c1, 0x95ce610d,
- 0x2879df18, 0xd3948596, 0x9d7cf1f3, 0x60655c58, 0x849a68c6, 0x172fe311,
- 0xbf8a146b, 0x015bfee0, 0x988e67d0, 0xf7aaf95f, 0xec3f88a3, 0x1e186ff0,
- 0x733fe5cb, 0x1e494aaa, 0xe46bcec1, 0x19d58ca7, 0x799fa093, 0xdb39606b,
- 0xf1fdec8d, 0xc043fe0e, 0x3af2ef79, 0x5b257d6d, 0x7f9d39f3, 0x5befe061,
- 0xeb682ed0, 0xe8f2953f, 0xaba40e60, 0x8cc5b17b, 0x0b4684e7, 0x51ad14bc,
- 0x665fa8ac, 0xbf8c68ae, 0x9b33f20f, 0xb4f20754, 0xe8eb0bc4, 0x8f39d3ef,
- 0x693d4dcb, 0x6ed9703d, 0xdced82ef, 0x2bff5c51, 0x2c70f77a, 0x3dd6287f,
- 0xadf1d71c, 0x9e18589f, 0x06d6399b, 0x1ec618fe, 0xc5106ccd, 0xd06cac1f,
- 0x5a3b00a4, 0x6026b064, 0x16c3dfbc, 0xb7be3226, 0x779c0e65, 0xf90d79a5,
- 0x07e89581, 0x1f91f9f2, 0x672c50f8, 0x15d7d6d5, 0xeac39f3a, 0x9a07e40d,
- 0xd6781f85, 0xae009b5e, 0x6e3d7317, 0xde2d3920, 0x687e4316, 0x235c8af1,
- 0xaef16ff2, 0xe043d218, 0x63d87e07, 0xc78e9f98, 0x481e6456, 0xeb8b7e84,
- 0x96aa1c32, 0xb8ff5a7e, 0x5ba498e6, 0x4b4fbf47, 0xe8a193b7, 0x94d2f406,
- 0xff0824a7, 0x3d8bd04e, 0x477e4b16, 0x7ab782e1, 0xcb9e019a, 0xee746155,
- 0x83ff33a8, 0xbed1c6a5, 0xe6175c9e, 0xdfafb725, 0xcafcdf68, 0xb744a19a,
- 0xfde57a60, 0xb470e667, 0x16afec27, 0xa1ec7a86, 0xc9e1ecee, 0xc2b0fe50,
- 0xeaa1ebe5, 0xa72879f1, 0x6f5c0959, 0x6614b7be, 0xfdec6468, 0xece666a5,
- 0x4b07d8c5, 0x68ff94ad, 0x3fe52269, 0xf4a76a5e, 0x287da593, 0x68e2293d,
- 0x0180ce52, 0x25475f88, 0x951af970, 0x6cdee220, 0x8caa2251, 0x307cffbc,
- 0xa1c56754, 0x4d8c27d2, 0x271eec63, 0xdfc02320, 0x046f7e99, 0xdf3db912,
- 0x4b8eb062, 0x9571ff44, 0xd8befa42, 0x3da6bb75, 0x3c4625f8, 0x64facdff,
- 0x9ce9cbfa, 0x1938dd98, 0xfcfef0f8, 0x69fb4d58, 0xfc9a2935, 0xcd3b04e4,
- 0x775e527b, 0x8503f94d, 0xa2f935fd, 0x9e024036, 0xf8db302f, 0xb7d8aafe,
- 0xd7c6cc67, 0xf6de56eb, 0x2ef0d56a, 0xaf7807df, 0x7d50321e, 0x5d243d30,
- 0x31d7ad67, 0x73368037, 0xfa0dcc3d, 0x933b593d, 0x11fceae4, 0x95fdd90b,
- 0x1ddf32db, 0xdb63f901, 0x7ebfb40c, 0x5aec456c, 0xb63e3fdc, 0x418a3e2d,
- 0x32a95eea, 0x7ac1fa1f, 0xe80591ab, 0xcb15dcb7, 0x9156fce8, 0xf940e4d7,
- 0xf9efda2f, 0xd1dbcc95, 0x5120441f, 0xbd543e3e, 0xe7e8853e, 0x14befc24,
- 0xf902dde6, 0xf1afa033, 0x16ccf8c8, 0x8519d70e, 0xd9fcc0ad, 0xfaf5bfb0,
- 0xb171c03e, 0x8744b6a0, 0x50f501eb, 0x1dcbe93c, 0x2dbe432a, 0xfda0605c,
- 0xa91fb9bb, 0x94cf311b, 0xde9c2921, 0x64479d2a, 0x7fa8992f, 0x021c0ad6,
- 0xd6fd16ed, 0x77d689b4, 0x0f77e44c, 0xfc16aef4, 0x26747c89, 0x08633986,
- 0x3de08558, 0x46fc7ef7, 0xd3e3f7ac, 0xfde7083b, 0x32b5dea5, 0x5cebf801,
- 0xe9107789, 0x49e2c7b5, 0x7ef182ae, 0x96f5c8d2, 0xf140e507, 0x9cbf4beb,
- 0x9d3e272d, 0x38247069, 0x25655f48, 0xb93abea1, 0x98e740c6, 0x3519de99,
- 0x3b3fd689, 0x38e58f88, 0x71f6f527, 0x9ac9df08, 0x96fb860c, 0xf2546bc5,
- 0x78ff9007, 0xffe72f7b, 0x1b3755a7, 0x28d6fd0e, 0x23a5d66e, 0x60b23cdf,
- 0x9a639d38, 0xc141d621, 0x9033e07a, 0x7f2f7755, 0x7e1ede7e, 0xb56586ce,
- 0x181defe8, 0x7c158f38, 0xbfde44bc, 0xd650073c, 0xd1474fed, 0xd4dcbee5,
- 0xf0ed1a3d, 0xe2550fd9, 0x6addb3b3, 0x3d022587, 0x0ef6e82f, 0xcfe43efb,
- 0xe94e7817, 0xb854ff21, 0xae02677b, 0xd26b7457, 0x3e786e95, 0xdbdac4f6,
- 0xaf73bbe1, 0xe6241c18, 0x7f49e24b, 0x6e697bcc, 0x8ef3c0d7, 0x2f97f51d,
- 0x38bfef99, 0xe7c01493, 0x38dd7b7c, 0x775c00eb, 0xe21d84bb, 0xe6e3b1f8,
- 0xbac5e02a, 0xc343c14e, 0xcb50c4ec, 0x3d773c6a, 0x3024c413, 0xec42784e,
- 0x7a101f8f, 0x1109fa45, 0xa67e785d, 0x7b37f38e, 0x0dbf2155, 0xbffa347e,
- 0x944f9c52, 0xebea5f7a, 0xfb4b5632, 0xf81247c1, 0x8ab9c639, 0xe055da97,
- 0xa8a82ece, 0x420f2b12, 0x79356d97, 0x97d419bd, 0x480fd035, 0xfbe762ee,
- 0x9e57c643, 0x652db645, 0x417e7ccd, 0xbc19ceed, 0x1d19cd25, 0x75894ded,
- 0xf51b0ae3, 0xfc60706f, 0x69c854a4, 0xf5e2ad79, 0xdd9079f1, 0xd98af194,
- 0xdb066ec2, 0x28f60ea7, 0x0ecd0ec8, 0x56acb3b2, 0xde01576b, 0xc2471c48,
- 0x2ba70c1b, 0x987842c2, 0xbda17007, 0x0f7b712d, 0x15b8244c, 0x03b25007,
- 0x35cca53c, 0x01e70626, 0x477b3ef5, 0xd5e782f8, 0xcf315e01, 0x1c4bb860,
- 0xff70fb9f, 0x5187cf18, 0x1e6829bc, 0xfec11e92, 0x894ba49a, 0xa4b7e387,
- 0x7e7a2141, 0x3207eeda, 0x7e491b8a, 0x9d500581, 0x44d77bf6, 0xeba567d4,
- 0xf866ff40, 0xd3f247f9, 0x8517563c, 0x7cc152fc, 0xbe50932b, 0x46d3757c,
- 0xe1bedfa2, 0x49ca237d, 0x53d7cda1, 0x5c288317, 0xb4bcd3fb, 0x1044f580,
- 0xd7446f9e, 0x9c378a6f, 0xbdc65e95, 0x37b34f00, 0x41b0ceab, 0x1ce2769a,
- 0x60e48791, 0xc463c78e, 0xb11cc6f8, 0x9c11bfee, 0x6e7e7a95, 0x76f086fc,
- 0x5b7d27e2, 0x68baf3b8, 0x9fbf62fd, 0x943a33d5, 0xaff76a9e, 0xdffaec82,
- 0x217e3c0c, 0xbd55f1f5, 0x5025e293, 0x2aaefc2e, 0x079b8f2b, 0x2cb4f1e9,
- 0xc225e3d2, 0x4e71cbae, 0xf149dfad, 0xf768d9b7, 0x5d3fca03, 0xfee293b7,
- 0x476657c6, 0x6a7dffa1, 0x78b5ccfd, 0xb6d4ebbe, 0x4be76499, 0xde76939f,
- 0x1ff40c6d, 0xbd17d772, 0xdfe463f8, 0x9f1461ad, 0x16efd92f, 0xabd01eeb,
- 0x9ebeced0, 0x8eb651eb, 0xb452d5eb, 0x1ec80387, 0x8b76c6f6, 0x51bddc4b,
- 0xc9ca020e, 0xe99e2e4e, 0xe81eddfe, 0x11cbf177, 0xc2a10f0e, 0xdf91d3ea,
- 0x3da1f56e, 0xf1f85f2c, 0x0ee73c51, 0x1fa3fff6, 0xd90ffb48, 0x92f77a8d,
- 0xc26f282e, 0x1bab97ee, 0x27e8add3, 0x5ff13b08, 0x3439bfc0, 0xfe1087fe,
- 0x01ff118b, 0x6bc720fb, 0x06679e38, 0x1ac4ffe1, 0xdb95974e, 0xfae147ba,
- 0x774d78f1, 0x6f8eb3f2, 0x9ff849eb, 0xcff01ab5, 0x3f5a5fe3, 0x8ff006ab,
- 0x3fc408eb, 0xdfbc5bc0, 0xe0eff02e, 0x78e1aff8, 0x3a786b67, 0x3d9e03ab,
- 0xf1618e74, 0xf40e4daf, 0xf984ce1b, 0xb33a9fc8, 0x01d5655d, 0x83f4987e,
- 0xbfb560be, 0xe24d7f42, 0xe6af6e7f, 0x0a7fa841, 0x1453fe9f, 0x76ee61d2,
- 0x80efa41e, 0x82ece67f, 0xfc7fb8fe, 0x95e9bf76, 0x7e01f12e, 0xa9d24dd3,
- 0xd918b982, 0x1d3f86c5, 0xe28375c1, 0x786d4f84, 0xd7dc468f, 0xd7ded7a8,
- 0x851933c0, 0x382f8c36, 0x278466cc, 0x8a1ef835, 0xf91c619b, 0x9f3f3d9f,
- 0xbce490b1, 0x6dbe7355, 0xba19f322, 0xa758ffa0, 0xf2c6fdd0, 0x39513945,
- 0x55d4e30c, 0x2ee9c704, 0x78fce68a, 0xff23aab9, 0xfdc8ccb1, 0xf93fb948,
- 0xde0ff0ae, 0x25d7c2ed, 0xd2b175ef, 0x18c29777, 0x164b81d9, 0x23ef17a3,
- 0x112a7ac0, 0x31ecf7c7, 0x228edd11, 0xd57f804c, 0x6036e228, 0x1f4f9102,
- 0x1f4f9c64, 0x38a26c8c, 0x5e54ac39, 0xd0f8bb40, 0xfc839312, 0x8a68b8da,
- 0xf4203ed7, 0x2b9183dd, 0x1e1f685d, 0x313a348a, 0x783d7e85, 0x1a30ce88,
- 0x0df18786, 0xafba46c9, 0x796e6853, 0x0fbe9705, 0xd4789e27, 0x06dea00c,
- 0x55c637ee, 0xd75dd7e0, 0xc5d23b63, 0x9c6d1f4f, 0x743c32a7, 0xe055a3dc,
- 0x293a714b, 0xbe82639e, 0x2b8e01c3, 0xdcb12f68, 0x9df1e56e, 0x8b27400d,
- 0xe5c1be9f, 0x03f7c3cc, 0xe35cf0ca, 0x6419c628, 0x935fe104, 0xfaf2332f,
- 0x26afc4f0, 0xec66cbac, 0x103ecccf, 0x3a8656e9, 0x45f7d704, 0x978c5ed1,
- 0x25f183df, 0xe27aa61b, 0xe67ac997, 0x26b4f1d1, 0x89cccf12, 0x8144d378,
- 0x9823a9cf, 0xeef01a2f, 0x778da83b, 0xf9d3e7dd, 0xef7e037a, 0x911afbd1,
- 0xbb66753f, 0xb8e30ac1, 0xb82194f2, 0x7e5b292e, 0x25a6f073, 0xa5d7f39a,
- 0xcfc75e42, 0x80feb585, 0x041e21c7, 0xcdbc4561, 0xeafdb3d0, 0x8807ce10,
- 0xdd9b4a97, 0x2816ed43, 0x71950f14, 0xc1ff4936, 0x1d207dd0, 0x41f0141f,
- 0xf851353f, 0xbd3431bd, 0xf5ca26fa, 0xabad1d73, 0x9bb90be7, 0x9b6de52f,
- 0x27c6de56, 0x82bda9da, 0xede0307e, 0x26769141, 0xff44e317, 0x5cb912e3,
- 0x78e2dd64, 0x9d35b22c, 0x7908b7ce, 0xfef13729, 0x88f7f8e5, 0x8da24c74,
- 0x00f095fa, 0x7ec71ebf, 0x9001a074, 0x56d64f5f, 0x87347f93, 0x33b5c405,
- 0x5f24edfc, 0xebb7cc77, 0x4c75dd11, 0x10b3ad8d, 0xc2f7caf5, 0x1f47a81c,
- 0xacf5d634, 0x4ed8ec8a, 0xb214dbee, 0x3d230366, 0xc261e229, 0x23558cfe,
- 0xa1407ce9, 0x5e0fefc2, 0x7478b1ca, 0x31a718d1, 0x630b6910, 0xf13f3a14,
- 0xf27fb137, 0x89e2f450, 0x5185d728, 0x33a63d46, 0xfbf52b58, 0xe8b76b77,
- 0x33de18fb, 0x0e763156, 0x77c88f03, 0xa8d5b8c2, 0x8d7e7877, 0x4aa29b33,
- 0x21c77f22, 0xdee1e027, 0xca7f406b, 0x09df2f7f, 0x4b7a5ffd, 0xe93bb3d4,
- 0x0b8f4bfb, 0xf2e4f63e, 0x7d65cffc, 0x92afcf1e, 0xff3cf9f5, 0xe45feca4,
- 0x5faa0e9f, 0x4bff5416, 0x3ebc5f9e, 0x7e83df3f, 0xd2ce68eb, 0xd214a385,
- 0xbe847b53, 0x23ee5c28, 0xf6ea16fc, 0xf33474f2, 0xdc6eb2e9, 0x6ba2536e,
- 0xd51fda0f, 0xf682d272, 0x2764d5f7, 0x704f9fe5, 0x75c44b2f, 0x63c524d4,
- 0xa1fb7d44, 0xc4c1ec97, 0xed1fce4e, 0xf8e3c2e9, 0xbfa0929b, 0x05fb7ea1,
- 0x8c4eacfd, 0x1c7ef5bf, 0x80ae1c49, 0x26f99e7e, 0x23a7fcf0, 0x49be1b3c,
- 0xb592b33f, 0x487f48fd, 0x86be7549, 0xe32763f3, 0xe645e734, 0x8d11c4ff,
- 0xe78627f1, 0xf3f50045, 0x67a5d797, 0x5ff3ff42, 0x04bd3d7d, 0xe76125fd,
- 0xcc74da2b, 0xdb34f789, 0x1be7a518, 0x7de2313f, 0x8d5d8ab3, 0xaed071c6,
- 0x00dcd212, 0x9c04cab8, 0x93f4e760, 0x8373ec03, 0x3d8c1bd0, 0x5f37f7cd,
- 0x7a47ab3d, 0x9dd5d7ce, 0xf6ed0e7a, 0x3ee42528, 0xddf166cd, 0x17ce4ed1,
- 0xe87a15ef, 0x11b39a6a, 0x8c6bf9e7, 0xb73e4021, 0x60fb93ba, 0x855f1c49,
- 0x1ccdeec2, 0x01db3166, 0xe43f43cf, 0x1b2554fb, 0x3c608632, 0xd184cdf8,
- 0x6d7e24ef, 0xc795b53c, 0x3c781b53, 0xbcd6d0b5, 0x33379408, 0x31ad9526,
- 0x84d8c1df, 0x0339485f, 0xf36f8591, 0x9d5f324c, 0xc79b263f, 0x767f30bb,
- 0x506b63fd, 0xb9c29a6e, 0xf0d0fb1f, 0x17a8e181, 0x7422325a, 0x37e79056,
- 0x498c8be3, 0x8efcb143, 0x639e5871, 0x222af4b2, 0x8be232fc, 0xc75de337,
- 0x3db05f90, 0x46dc41c6, 0x307dfc5f, 0x2adbf70f, 0x0f75a79d, 0xda87708a,
- 0xc087fa77, 0x4ac931ab, 0x19901369, 0x870917fd, 0xf9fc1f1c, 0xdfd0cd45,
- 0x8349e5c9, 0x9f71db57, 0x3490c725, 0x467e3fd4, 0xe072fb82, 0xac7527f8,
- 0x6e292e17, 0x024b8e16, 0x5dee030e, 0xd95dbe03, 0xac06732a, 0x898f26f3,
- 0xcdefe4d0, 0xc0ce658f, 0x29bded38, 0xc2f4fc9a, 0x0ff69aee, 0xa9afeacc,
- 0x6735302f, 0xb1f80555, 0x1e49fb9d, 0x62d2a782, 0xee7f4709, 0xfc5f0def,
- 0xfff441e5, 0xf40eab36, 0xd9eee755, 0xa1db97f2, 0x4e3c65d5, 0x3b47f145,
- 0xc9cecbc5, 0xa77a28f3, 0xe85f703e, 0xf3a66b22, 0x03ed9d3e, 0x7cee75c9,
- 0x773a7eeb, 0x03ef5df6, 0xeb124af5, 0x086c21dd, 0x55cbc3da, 0xaebc511f,
- 0xefcf9222, 0x8cc7ebe2, 0xfb8a0fb8, 0xdf81d78a, 0xd10fc2ef, 0x50f36c3f,
- 0xfeb73b3c, 0x1d9bed18, 0xba7ae448, 0x1e817522, 0x42551def, 0x1c68768a,
- 0xe068abe8, 0x3646e697, 0xbbee1770, 0x1fb85866, 0xb19936de, 0x1e2be458,
- 0x884a69df, 0xf3d77ba1, 0xbca8f26b, 0xfa9c2da2, 0x1e6d4f7f, 0x5f09e747,
- 0xa1ff6853, 0xe5a1e520, 0x29b87e78, 0x11e033dc, 0x77e0b718, 0xde21e577,
- 0xf3f1762a, 0x9fea05b5, 0x5a4016b3, 0xdf479b56, 0x49aca817, 0x42617f01,
- 0x05bfb72e, 0xaf21f368, 0x46acb30e, 0x7d1aabbb, 0x3d479ebd, 0x9e90b463,
- 0x807b6e89, 0x336cafc6, 0x24f7f7d3, 0xd0d77f71, 0xdb1ae1c2, 0xc972a2e6,
- 0xba93530f, 0x860fd669, 0x7c7acdf8, 0xc2d0c397, 0x6dddfda8, 0xf39528fd,
- 0xafcfbb7d, 0x21ae3ee9, 0x14b8eafe, 0x71dbf798, 0x90dc958a, 0xa57c3d20,
- 0x0b34786a, 0xc7daa7a1, 0xf4e7e369, 0xdcfc6d4c, 0x738a615e, 0x31c0127e,
- 0x3d16b1f1, 0x48b107ee, 0x35f115b3, 0x7b60c471, 0xa97c8049, 0x2237ef7b,
- 0xdeeb0c7d, 0x369da237, 0x501b9a41, 0x33ce2e5f, 0x05e9eb04, 0x2f4f5249,
- 0x1dda54a3, 0xf9067576, 0x82ac33a9, 0xccfc8501, 0x7e54fa10, 0x1a6b4cdf,
- 0x1e6ee3a0, 0xc5347fc7, 0x45f502bd, 0xbe9b0e73, 0x7366f483, 0x7cc3ee3a,
- 0x9d03f057, 0x89f90acd, 0x751e742d, 0x0ebb08e2, 0x04abffe3, 0x6f8e525c,
- 0xa2c58f34, 0x5b2a7bfd, 0x77befd82, 0x4ecd9de7, 0x47f1afe8, 0x0f689999,
- 0x25cfb8e4, 0xcc297bf1, 0xd70d7ada, 0x446f9583, 0x0bde51d8, 0xfb863170,
- 0xb44c7b9d, 0xda72814e, 0xc37ca8cf, 0x89ef09b4, 0x7ac14654, 0x7dcfc615,
- 0x7c87cc33, 0x9866f8dc, 0xef46ed1e, 0x4873f774, 0x7b37dccf, 0xa1f5c18f,
- 0x67a4c1b3, 0x9f38f7e4, 0x09db3d27, 0x5bd237bc, 0xe5267cc1, 0xe5c35dd3,
- 0x69f048a5, 0xb73f90b1, 0x552ba390, 0xaf0e485d, 0xe340063c, 0xca63e93e,
- 0x27e85dc0, 0x7ef42dd8, 0x02cb9493, 0x79410f5c, 0x3a18ff41, 0x8dfd2bff,
- 0x6b2c3960, 0xe5bf52b3, 0xef21766d, 0xb94bca36, 0x6372162b, 0x2cc67e12,
- 0x53bbe7c1, 0x5e20efdc, 0xee41aa0a, 0x3f1f68a3, 0xcfc9e50b, 0xf22b4637,
- 0x624df017, 0x54fc8049, 0xd0cfde37, 0xb9c5313f, 0x41666f88, 0xcc9fe81a,
- 0xac4ff76e, 0xfe0012e3, 0x74322b89, 0x9da9df78, 0xe6f9db7f, 0x8f7ff8e6,
- 0x48e29790, 0x67f44f5f, 0x0e61550d, 0x397e873c, 0x2cf7ef8e, 0xb8f1c55c,
- 0x45cae0d0, 0x2fe162ff, 0xa1978a15, 0x697a81df, 0x632a91d8, 0xfee51c60,
- 0x0ecc41b6, 0xd6d29878, 0x1337d283, 0x0f1147dc, 0x04d36d45, 0xa37d06be,
- 0x4ea1c5fd, 0x7832471e, 0x198d8e4d, 0xab724718, 0x6933e748, 0xe04cfacc,
- 0x1d7ade7e, 0xbee4c3c5, 0x992b8ca3, 0x807cbcf0, 0x5f42fd1d, 0x37ef4e9b,
- 0x7299c704, 0xb0bfddb8, 0xbf7640d9, 0xc3cff1ac, 0x2e7f5074, 0xed05d9c3,
- 0x777a97c9, 0xbcf5f21b, 0x0d57dec9, 0xe4ff9f90, 0x7691a8ce, 0xf4eb3e3f,
- 0x47689ebe, 0x188f00eb, 0xa35baaef, 0xbfb979e6, 0xc9f7c113, 0x7e4b7f38,
- 0x79f3e60e, 0x9f88dd6d, 0xc89954ae, 0xbe015d0e, 0x48760165, 0xe7a91dda,
- 0x7c91fda5, 0xfae7ae5d, 0xda323cab, 0xb408c9eb, 0x395c933b, 0xf87d77c8,
- 0xddbf1a79, 0x1476b4d9, 0x38a5c1ca, 0xed28b73a, 0xbc1cb046, 0xd31c14b6,
- 0x8eed1d5e, 0xcf52ebd4, 0xfa35bb4b, 0xfe772fe5, 0x8a55cd15, 0xe032407b,
- 0xb73d6eeb, 0x2deb775f, 0xe3633fc4, 0x6f91e926, 0x1e8f5e6e, 0x98f47a13,
- 0x74568f46, 0x27060762, 0x741c9adf, 0x4cf3ed15, 0x3d447fdc, 0xa3dfd81f,
- 0xe0c7a329, 0x7327c63c, 0xc15dfb3b, 0x1ffe99dd, 0xfa6b7c9f, 0x88b2587f,
- 0xff40ddf7, 0xfd732617, 0x99efac1f, 0x73a7bf95, 0x2f5f4f69, 0x0ca383da,
- 0xc1da03ec, 0x16fb0886, 0x5ec80f61, 0xbf7b4784, 0x4d5c1ece, 0x7888599b,
- 0x1e0f610a, 0xf616fe4a, 0x94a1f240, 0x5227291b, 0x48e5822e, 0x9f84c5ca,
- 0xe9113ac2, 0x57bf1ef4, 0x6cf7ae50, 0x7b46fda3, 0xcf9460c4, 0x976e3f76,
- 0xc1d6f242, 0xf1f9084e, 0x6ed68bcb, 0xf290b948, 0x5ca7e522, 0x20ecc5c8,
- 0xd6a7d8b9, 0xf70a333d, 0x6bdd92cb, 0x72fde393, 0xd823b652, 0x57ca743e,
- 0xb3645918, 0xf218aae3, 0x81a43955, 0x44ea657c, 0xbe499e1e, 0xd968bf35,
- 0x6fd3f24d, 0xf4fcfbfe, 0xe9f84e9b, 0x3f0dbe7f, 0x3f63f475, 0x3c03b2ce,
- 0xdf40b257, 0x6df9f866, 0xfb8c3bc2, 0x7af9dd0f, 0x0497d600, 0x8d319377,
- 0xae133ee2, 0x2f8a2ab3, 0x7494be0a, 0x6cc0fe96, 0x93387711, 0xe1077ae2,
- 0x82c0f5c5, 0x447bd39b, 0xb35c5367, 0xb327d711, 0x03f40d21, 0x9b7ff33a,
- 0xbdef516f, 0x3e749371, 0xfb9dfc96, 0x4392c78d, 0xb1c78dfb, 0xb5d29bfc,
- 0xf8899720, 0x300b8fde, 0x29e138de, 0x0acb6791, 0x46d38f10, 0x3c9ffac8,
- 0xfa81ece9, 0x38b8c981, 0x53de39c5, 0xf4b3de45, 0x3f6818f0, 0x8fe619e1,
- 0xd8fd439b, 0xb8f6e8ec, 0xedfcc288, 0x3b1fe795, 0x51e886bc, 0xddcce5cb,
- 0x3ffbe7a2, 0x79059f22, 0x447e404b, 0x6f037e50, 0x616fa51f, 0x9045e781,
- 0x9c21949f, 0xff00aece, 0x7fdf8601, 0x5585ed05, 0xa8d71861, 0xd6f8db8c,
- 0xf56bd415, 0xb545ed0a, 0x14d581e3, 0xfbc55338, 0x735f94b9, 0xc23e09d8,
- 0xbe78bb03, 0x93ed4a4f, 0x37e8bd1e, 0xa1bddce0, 0xb9d2714e, 0xb78a1183,
- 0x7c47465b, 0xdad149f7, 0x6bd1fc27, 0x1e7867bf, 0x6fbe56ef, 0x8dd6cfbf,
- 0x6e99f7be, 0xb2fbfc61, 0xfe7f9f43, 0xefe70a5e, 0x21d15931, 0xa8a5c7eb,
- 0x37111fbc, 0x68a1f1a0, 0x7be85d4a, 0xb8c513b0, 0x425fb8cd, 0x24f6dcf8,
- 0x28d9b7e2, 0x93f2fdf1, 0x196377c8, 0x60cfc4d3, 0x9fdfca7c, 0x8d4172f2,
- 0x19d74f9e, 0x9bafaf84, 0xa91480ef, 0xf2f8fdbf, 0xf4cbd104, 0x8476f835,
- 0xfb5db7c0, 0xe8ebefbd, 0xf7c3ac35, 0x48e76f82, 0xf86a763e, 0x22ef5a3d,
- 0x538e8cfe, 0x5747e8ac, 0xe0d6c2b8, 0x9f2fc17a, 0x6cbe27bf, 0x1d03fb96,
- 0x02b5efe4, 0x890abf94, 0x4febcf47, 0x74bafca2, 0x3cb9eded, 0x7335f3b6,
- 0x52bc01f6, 0x7fbe0fc8, 0x27faf9e4, 0x7c092e31, 0xd794f541, 0x2c1dc007,
- 0xf941758f, 0x15f920ec, 0x03fa47f2, 0xa9e001ed, 0xb8b7ea27, 0x007b4663,
- 0xd04cfc9f, 0x27b8a2e9, 0xfb9a3cda, 0x78ddcd93, 0xfb8523ba, 0x7c09cf8f,
- 0x9bed126e, 0x90f003c3, 0x1f1fe1aa, 0xe6025bae, 0x3fba784d, 0x93fbce4e,
- 0x63d07c82, 0xbf5e36cd, 0x27a3e52d, 0x7cfed93d, 0xa6af7f70, 0x7880527c,
- 0xf1fff7f1, 0xee23f461, 0x91db7817, 0x27b0e472, 0xc139d052, 0xf0214eff,
- 0x5163bd07, 0x74a1fc8e, 0x761f8fe4, 0xd04f4fe4, 0x774ef4f7, 0x3a7bdf67,
- 0xfa0cef7e, 0xea3de19e, 0xd05eff9b, 0xae883f2d, 0x1d744179, 0x942f9413,
- 0xff46af79, 0x5c5cbd4a, 0x09e3f4ff, 0x54df1871, 0x9fbf38e8, 0xbd934f9f,
- 0xfc956f99, 0xf230e67b, 0xcf9f9fab, 0xd7279e12, 0xce79ba09, 0x787a893d,
- 0x51e1ea12, 0xd414fcfe, 0x5f3f9443, 0x7e61fb80, 0xea81757b, 0xed91abef,
- 0x7afd922f, 0xefec8560, 0x3a4bca33, 0xb225cf32, 0xbd0bf777, 0xa4ad3cc3,
- 0xf035e7f7, 0xfe7d3fef, 0x2b5fc3f3, 0x7841b50f, 0xf79410d9, 0x775fb504,
- 0x22b6fb03, 0x82c7fbe8, 0xe504d7ea, 0x6be507d7, 0xcd17dfb4, 0x8b0e4852,
- 0xc9fdf046, 0xe60cb960, 0xda522f8f, 0xf6ed63e3, 0xff24895c, 0x1357234e,
- 0xfafe79aa, 0xa829fff3, 0xa7c80c89, 0xb21e89b0, 0xc05a30ef, 0xb9d041fd,
- 0xc1f8151e, 0xbcde89d0, 0xecde99d8, 0x79ef6c13, 0xd7f03ffd, 0xd22fda24,
- 0x54fb25f8, 0x9551be6d, 0xbbbd4770, 0x5f603228, 0xe2265995, 0xfdf3baba,
- 0x6389889b, 0x22fc0352, 0x6744f84f, 0xfb653cc0, 0x575d5f71, 0xd4f8bc71,
- 0x719b89f0, 0xd8b4687f, 0x14f1b4d7, 0xf68aa5ec, 0x6fc452ba, 0x5d39e1c6,
- 0xebee176c, 0x0fd030b9, 0x70bd7562, 0x523f8d9e, 0xd550bbf9, 0x53c01f40,
- 0x79d3b311, 0xea7899d3, 0x47d43bbe, 0x0df92f47, 0x47efb77c, 0xd3b412ea,
- 0xd2c49747, 0xa945a639, 0x17dcefdc, 0x366135dd, 0x1e231be4, 0xf8db7d26,
- 0xf74a58c4, 0xad95ceaa, 0x353ae856, 0x5f646279, 0x3c268fac, 0x4fc43639,
- 0x9dfc065c, 0x38276a99, 0x426b36dc, 0xabdbfa3d, 0x085fb40d, 0xfc457e2d,
- 0x3069a4f3, 0x968bb7ae, 0xb0fda7f5, 0x1a4f9fe2, 0x8ab0f787, 0x3ed0371f,
- 0x4ace8b49, 0xeaf72271, 0x6a2e74b1, 0x7a910ad6, 0xcdf4a2ee, 0x1abafcff,
- 0xbeb569ef, 0x0efbd0a0, 0x7bad5c77, 0x9b9e1067, 0xf74ee9ac, 0x7580de2e,
- 0x3efb9e00, 0x17b7bebe, 0x089f21cf, 0xa473a2ab, 0x8bee9ed0, 0xbfb35e95,
- 0xdb0b313b, 0xd0e5d6ab, 0xa39414fe, 0x956a7cff, 0x41ef09ba, 0xc2594515,
- 0xa9f6fcf1, 0x75c518af, 0xa26e3d4e, 0x478e2277, 0x8fac67ba, 0xe8b8fba3,
- 0x8a53b3e9, 0x3c014a3d, 0x67d0da4c, 0x96126262, 0xfb7d049b, 0x1e011544,
- 0xfced748a, 0x24a4f643, 0xa527e786, 0x05b899f6, 0x97ea71e6, 0xd87ce9bd,
- 0xe4e754c1, 0x2fd7c054, 0x52539cd2, 0x6e5e11e3, 0x0ffcdeb7, 0xe3fc8fdf,
- 0xe404e285, 0x395287af, 0x56d1bf5f, 0xbef8109c, 0x3d45c977, 0x469bc1f1,
- 0x277a22fb, 0xc14d3c30, 0x41f03675, 0x67cdc62c, 0xf00b7589, 0x219d92f3,
- 0xa9e1abfc, 0xf1abd12a, 0x48d9f1a7, 0x0f5f3f5f, 0x19f5177f, 0x5f2037ad,
- 0x2d7321b1, 0xa693b9da, 0x0f44ec25, 0x91fe7ed6, 0x3c230bed, 0x7985b619,
- 0x7e3032c3, 0xfc871cea, 0x7aeb12cd, 0xc804b64d, 0x77ff68a1, 0xfbe73f0f,
- 0xeb8f6877, 0xfe7bbfbe, 0x9fb812d7, 0x4697db21, 0x5ce83c59, 0xf458b69c,
- 0xfaa38f48, 0x3cf0a7a5, 0x060bc95a, 0x2f2503b2, 0x8ad63fc4, 0x06f807fa,
- 0xf3c16be3, 0x81aa63fa, 0x933a31c7, 0xad18cf4b, 0x1331b25c, 0xc99dbe71,
- 0xdc86cd65, 0x3b239b89, 0x2b52cb97, 0x5ee34fd7, 0x9651efe0, 0x71e8b50e,
- 0x0bf4737f, 0x7ba16d6f, 0x86c20b74, 0xd289bde0, 0xaf444c17, 0x63c58b16,
- 0x13ef0dbd, 0x9031f458, 0xedca9b3e, 0x9f90bd69, 0xcde9955c, 0x7ba52843,
- 0xf0df7212, 0x9e6792ec, 0xe797e3c5, 0x70da7798, 0x2765dfc0, 0xbbcbd3e7,
- 0x063f8a54, 0x1f9623ef, 0x61cc69dc, 0x788fb137, 0x32c3fd83, 0xdfde22d6,
- 0xf07dfd0d, 0xa9abe1fe, 0x0687fbc1, 0x2a5e4fba, 0x37730ff6, 0xe9770428,
- 0x3fcf7e12, 0x8dc79637, 0xfa052e4f, 0x1ede691b, 0x0f3c10eb, 0x294eedcd,
- 0xf866bc53, 0x0b0daef5, 0x13d98e28, 0x6e7184f1, 0x89e26ef1, 0xae3a4730,
- 0x085e4bf3, 0xfe96fc23, 0x7e5fee6a, 0xfaf78599, 0xd702e20a, 0x2f91fbd5,
- 0xde197e38, 0x9cfd941f, 0x7a63f65e, 0x45f731a7, 0x7cc31f58, 0xabd8634a,
- 0xbd2067f7, 0x9f71d292, 0x5d2bb653, 0xbc5ea3fe, 0x61afac1d, 0x4ab45d1d,
- 0xecc7efe5, 0x041d9136, 0x01644f59, 0xad672cf7, 0x72346838, 0x8712c63b,
- 0xeedaff09, 0x1c769fbf, 0x6eeaf1ea, 0x2687b8a5, 0x51ef27f1, 0xfbf8e915,
- 0x853a8574, 0x268157ee, 0x97497ba3, 0x7b5fb953, 0x679f953a, 0xd0774a28,
- 0xb5f29cfd, 0x0cf2c726, 0x7dfb4fde, 0x95df584f, 0x684b9aeb, 0x26f7f33f,
- 0xae54ab8a, 0x45867308, 0x3b17f3f1, 0x6af9d006, 0x51f011bd, 0xe2fae766,
- 0xa56f98b2, 0x745dd27d, 0x8ecf419f, 0xdcbea1e8, 0x7963f5c2, 0x923de00c,
- 0x186e8a33, 0xe8c767be, 0x9bf624dc, 0x7c602834, 0x3f439445, 0xbf7f28f6,
- 0x83563a4d, 0xdf6c1b71, 0x31e21077, 0x8474da76, 0xe49515ef, 0x76b49019,
- 0xaf7dfa04, 0xdeb899a8, 0x6fb55a2e, 0xf9dfea1c, 0x8de307db, 0xeaf45609,
- 0xe63f6407, 0x88b7fa0b, 0x90c56773, 0x22b677c7, 0xb93cb8d2, 0x8a2f1e55,
- 0xef345348, 0xf2fac910, 0xbf1e0655, 0x8a8f3d07, 0xc7d97ca5, 0xa5b96fd4,
- 0x6ff50139, 0x30c36ef9, 0x6951d3d4, 0x978b2e5c, 0x011f65a5, 0x44362abe,
- 0x6583bbd3, 0xe623029e, 0xca156acb, 0x4f8bbffb, 0xbf3d3e47, 0xe428b5e2,
- 0xbe61139f, 0x5a97689e, 0xe8398417, 0xc795a1de, 0xe8afceeb, 0x6695f749,
- 0xf82d9b59, 0x45acc19e, 0xbfa86ddd, 0x467d5a8f, 0x975a3fac, 0xd3bcc3a1,
- 0xbcc6cd6a, 0xe51b7f53, 0x2df38bcf, 0xa57c83f4, 0x6d973a70, 0xbfc467db,
- 0xcc44324f, 0x1f2be2f7, 0x4ff8c2f4, 0x2f737a79, 0x07c02bb4, 0xcf1052bd,
- 0x9764292f, 0xf3f1b62b, 0x2a0f92ee, 0xee400f90, 0xa83e09e6, 0xf7daf5d8,
- 0x902a1e51, 0xf23a43fe, 0x7ef3f011, 0x71b1df2a, 0xefdfe31c, 0x76913e47,
- 0x0c2bf20c, 0xf1df8c36, 0xa71a667c, 0xe18f943f, 0xfc019ee5, 0x39fb5d1c,
- 0x741c8d04, 0x1a575f46, 0xcbc587b7, 0x5d6fa44c, 0x5a1e5c69, 0x428eed56,
- 0x657c5dfa, 0x67dc01df, 0x5601df29, 0x1e421eda, 0x712a3e04, 0x3f0451fe,
- 0x389517f9, 0xfcff28df, 0xc85ef9db, 0xf3e32561, 0xd4adf393, 0x7acbf98b,
- 0xc124fdf1, 0xe04c652f, 0x2e6f576b, 0x50ce4277, 0x0ebde98e, 0x4db73f31,
- 0xf7e50efb, 0x22dcfcc5, 0x28bad665, 0x17d20fc4, 0x103e0ff5, 0x04fa9469,
- 0xbedc5c9a, 0x4bf1ce91, 0x57f8497a, 0xdf403809, 0x7e6c6339, 0xf274b63a,
- 0xe095644e, 0x778f639b, 0xfc07af49, 0xcf4adf9d, 0xeabf116c, 0x7c93c603,
- 0x7dcbc723, 0x38ddd279, 0x87dfe86f, 0x8f71cbfd, 0xd8f4227a, 0xe5c651cf,
- 0xe52fc243, 0xa1fab732, 0x614707bb, 0xee968bbb, 0x9cde7003, 0xacd2ab8e,
- 0xfd13bdf4, 0x59def805, 0xfadc50af, 0x1fe75898, 0xa8b5fc7b, 0x7e7e01e2,
- 0x277c427f, 0x307f0cf9, 0x6de1263e, 0x7038f1b2, 0x0f52dc30, 0x9f73b849,
- 0x2c6eefb8, 0xbee3f097, 0x4a9f2051, 0x957e4a3c, 0xf982f5f7, 0xda4e7896,
- 0xfe73b54f, 0x463d4cae, 0x943a77e7, 0xfc27f707, 0x5ce213a2, 0xe33c6b79,
- 0x8915ff71, 0x8af735fb, 0xb40c8b18, 0xc08ed23f, 0x807d1acf, 0xa7bf69fd,
- 0x8b3ce716, 0xd690bb74, 0xc73ffa8d, 0xd0398cea, 0xe699d96f, 0x9dcef871,
- 0xb8ef43f4, 0x31a353ea, 0x9f8bb55e, 0x52fc9377, 0xc93f6176, 0xffb8b941,
- 0x83eab454, 0xefc8e182, 0xbed035bf, 0x63e3d14e, 0xcfdfe88d, 0x187332dd,
- 0x41ef01a2, 0xbb3f5ea0, 0xbf266879, 0x984d6059, 0x3621f786, 0x01ed333f,
- 0xaf559f28, 0xd80dbbd2, 0xd16fca0f, 0x5f1499a3, 0x52d6113d, 0xf8fd0a30,
- 0xf456a81f, 0x32df6fe3, 0x7f6c31f4, 0x0c6ba5bb, 0x39b1b63d, 0x7d4ef296,
- 0xe907d934, 0x8073caf7, 0xc7dee2d5, 0x3fde845f, 0xe22a9edc, 0x2f755ffc,
- 0xdd6f8fdc, 0xacef4618, 0x75ed1a14, 0x4f6f1c3e, 0x54675a17, 0x23eaf11a,
- 0xbf255bdd, 0x99918e6c, 0xb9508693, 0x0fca0939, 0x451f9a1a, 0x51f0723b,
- 0x3f7c60cb, 0x86d7a992, 0x9a7f7315, 0x6ac63bef, 0x70912ddf, 0x0fc6247c,
- 0xdf7e4fee, 0x1b08eb84, 0xefa44fdd, 0xedf8aecf, 0x6783b434, 0xe1b4f6b7,
- 0x09ef4fbc, 0xa703fba3, 0xcf77da0d, 0x57def56e, 0x79297df0, 0x9a74f56f,
- 0xfc938fd6, 0x377bc37e, 0x839ed37f, 0xa5b9d1bc, 0xdd194b0b, 0x8d397efb,
- 0x2263f7d1, 0xe789dabe, 0x4d6a4b08, 0x7307bc56, 0xf71ef912, 0xfcab76b3,
- 0xcb99a5fe, 0x99ddc9c1, 0xe4b7bf74, 0x525f3c6f, 0x3ef178a7, 0x9fa7fef2,
- 0xb30af3a0, 0xabc4cfc1, 0xf3feed09, 0xa1a7a7ba, 0xb8765c38, 0xfe7de257,
- 0xf9f95bcb, 0x32ef0e8a, 0x2079dc1c, 0xdfb9dec9, 0xcbfb5dfc, 0x9f110e32,
- 0x2fcfbdae, 0x4fd72cf1, 0x8c3f026f, 0xdbc7e218, 0x90e74b67, 0xa9617cbf,
- 0xca4bd29b, 0x23b7b5b1, 0xe9a25b1f, 0xeb1fc0be, 0xbdf1519f, 0x835df2a8,
- 0x783ae1af, 0xbd346454, 0xd2d9f293, 0x7a8fb425, 0xa5156961, 0x0e32de92,
- 0x46aec777, 0xfab3eefa, 0x9fbc06cc, 0xb46446fb, 0x90b603b0, 0xdeeced74,
- 0xb9d79cb1, 0x4afa701f, 0x9d6dcfb8, 0x6af38519, 0x61b63e7c, 0x2235d224,
- 0x5f7e8ada, 0x724738a9, 0xabf73d6a, 0x7fa398cf, 0x3df40f93, 0x024a61b3,
- 0xbb3737be, 0x5869def1, 0xb147b25e, 0xb1c07ae2, 0xae145267, 0xb7d53edb,
- 0xa8fde144, 0x7bcbd74f, 0x3bfa5e55, 0xd8f2a354, 0xca3f6c14, 0x0cf667a7,
- 0x7c8d75be, 0x9e82f232, 0x879ebfee, 0x5c938a72, 0x0938a70b, 0xb9e2c4fc,
- 0xf3afd991, 0x3afb4af8, 0x6ef3ac57, 0x347ef317, 0x31f726dd, 0x04773ca8,
- 0x61bd3f2f, 0xefec44e7, 0x158366ec, 0xb36cfee1, 0x079ffa81, 0xc01d33eb,
- 0x5f2b667b, 0xd71e60f7, 0xf2b767cb, 0x3abccdf5, 0x5f29bebe, 0xfbf27060,
- 0xcc7e5aa2, 0xef47680d, 0x5ef274fb, 0x9f273cc8, 0x97b03cdf, 0xbe60df38,
- 0x7475618d, 0x9e9bec8f, 0xdbe60d17, 0x855f92f9, 0xd7e7687e, 0xe044f8ce,
- 0xf91de513, 0xbcc3f255, 0xdedf7cf5, 0x07383756, 0x47f24ef9, 0xd5593bf0,
- 0x57dfc646, 0x7bd385d4, 0xed2293b8, 0x530fb406, 0x20c65ae2, 0xe74e3e5a,
- 0xab9a807e, 0x37bde273, 0xf90a6d56, 0x748acece, 0x744557ee, 0xdeefc465,
- 0xcf3f2b74, 0xc97fee29, 0x86922614, 0x84527b76, 0x343b0bed, 0xaefd3a79,
- 0xcfc0f47b, 0x3db76e93, 0xd8c1ddda, 0xee0bd32f, 0x267cc3d1, 0x7776da65,
- 0xbff3fc83, 0xb7f3c09a, 0x201a86d9, 0x78994cbf, 0xd7c818cf, 0x4a9f3ba7,
- 0xece7180f, 0x38692e96, 0x19ff283f, 0xbbc5d796, 0xa5698e7f, 0x49760fb8,
- 0x24b41d69, 0xfdfedfc3, 0x7fa3963d, 0x2df3fbb4, 0x18ee9606, 0x7f097980,
- 0xdd25b4e8, 0xf8f4abf9, 0x8cc5e58e, 0xf5e74e3d, 0x0e1efc3c, 0x09ccb8fc,
- 0xf38a4f78, 0x97bcb15b, 0x2f741353, 0x9fefc1c7, 0xf252fbc9, 0xff5f543e,
- 0xb70db27d, 0x92ec9f72, 0x2a1dff81, 0x0fbda9c5, 0x89fc34a6, 0xf6a9f9de,
- 0xa23096b0, 0x4d9ef683, 0x7753be39, 0xa20bdd1b, 0x6f4c87fb, 0x57337d27,
- 0xac683bfa, 0x29dff987, 0xfcfc8960, 0x1f82a3c1, 0x3d652f4f, 0x9fe8807a,
- 0xca39b77f, 0x985c700e, 0xfa85ebe8, 0xfddc3220, 0xe9d7c427, 0x0ba9d50d,
- 0xaa1ef0e3, 0xed0f91c9, 0x7df978cf, 0xb7e132ce, 0x42f1cdb2, 0x3bbea82f,
- 0x46535da1, 0x87684ddf, 0x757c17de, 0xfe97c321, 0x192bd423, 0xed049d7c,
- 0xde5d3ce8, 0xb1e2bbf2, 0x4fed85dd, 0x700d98f4, 0xbc06009b, 0xfa1e35a7,
- 0xf7a3611c, 0xfb4a98aa, 0x7efe5ecf, 0xa2799e92, 0xd5eef86c, 0x3ee2e933,
- 0x9413dd11, 0xeff89274, 0x1a181740, 0x999d59fd, 0xbeee1019, 0xfdfd036c,
- 0xf91f492f, 0xddc2e2ce, 0x7742fe3c, 0xe31e4524, 0xe2cda748, 0xb0759fef,
- 0xbf916f8b, 0xd1e9620a, 0x330d9fe8, 0x11c9db43, 0xf5d88d1b, 0xff2f6d77,
- 0x92fc2e9d, 0xe0706cc1, 0xa2a5923b, 0xd0b558cd, 0x2d5bef8e, 0x7bd3378c,
- 0xe85f0b25, 0x96c1fc4e, 0xb60590fc, 0x89621b63, 0xa866565f, 0xf5b9ff84,
- 0x2a1dde8c, 0xf3a64fa8, 0x36f5f994, 0x12daa34a, 0x6fecfca9, 0x7ae2c9de,
- 0xe0a7d389, 0xa68cba7f, 0xd3ff4b73, 0xd9d6529b, 0x6691a77b, 0xf0bbcfba,
- 0x0b6bb720, 0xc7bfcaa7, 0xbbafefc2, 0xc8ae3804, 0xb90b8a1a, 0xe753dc3a,
- 0xf0ba57ef, 0xe77e00be, 0x677d5034, 0xfc4a57ef, 0x82dd049a, 0x7a9cb3df,
- 0xde913330, 0x59ef147f, 0x9aed174e, 0xceb3bdc5, 0x4fbcb5de, 0x6a227bb4,
- 0xddf2135c, 0xc8696774, 0x9ef52d77, 0xcffa0730, 0x7a48d486, 0x373ee147,
- 0xf59a97f8, 0xf11e8b4c, 0xbf9b2d30, 0xba753973, 0xfd90deb6, 0x4373e939,
- 0x92778776, 0x4d8fa80c, 0xecfb6d2e, 0xf50ec2ae, 0xf6bf7d65, 0x2354d15d,
- 0xbe3d4fd9, 0x69f90b3b, 0xf4515de2, 0xbfffd10f, 0xff10b4ec, 0xb83bc49b,
- 0x112b2ccd, 0xbeadc2f5, 0xdbfffb27, 0xefc1b1fb, 0x03bf06c4, 0x42eb7fdb,
- 0xdd607e4d, 0x6fed350f, 0xa9ae5fab, 0xad5bec1f, 0xfa6ccfa9, 0xb43f2699,
- 0xfb4d39f9, 0x693647e1, 0xbcb647ea, 0xfdbfa9a4, 0xfe4d0ecc, 0x683fd68e,
- 0xb6d9dfda, 0x61cf9357, 0xe7da68ef, 0xe4d03f9a, 0x57ff5ac7, 0xc4aefed3,
- 0xf1fa9a13, 0xfa9af3f6, 0x68ae7d09, 0x2f8e05f2, 0x373fed35, 0x457757ba,
- 0x0cea22bf, 0x433aadf1, 0xf944f861, 0x6629a6e5, 0xba6b07d4, 0xf8247d0a,
- 0xd3b0b96f, 0x7ba307ac, 0x6cd563ac, 0x3d5ff11f, 0xc1a0bbff, 0xde7f4f76,
- 0x1ff8c4e5, 0x6bdf8d7b, 0x527f068b, 0x8c7e301f, 0xff02ccd3, 0x9e6c5dee,
- 0x778f9355, 0x77da6a25, 0xd4d76e99, 0x68fbb927, 0x38e653ea, 0xaab4f934,
- 0x5df69a11, 0xf9353897, 0xa69e4f0c, 0x971af77d, 0x76b3df26, 0xef7da6ba,
- 0x7d4d6ef5, 0x4d1cef5f, 0x55adff7d, 0xbac0fc9a, 0xb7f69a25, 0xf5347bd5,
- 0x9a357d83, 0x5aa6ccfa, 0xf3687e4d, 0xe1fb4d7a, 0xfa9abc47, 0x355b2d91,
- 0xa99fb7f5, 0x68efe4d3, 0xbfb4d7ad, 0xc9a7cdb3, 0x9a83b0e7, 0xf7e6b9f6,
- 0xd6b1f935, 0xefed344f, 0xa9a63c4a, 0xab3f6f1f, 0xce7e97a9, 0x6b9f3e84,
- 0x53df85cb, 0xe697f8e0, 0x6ef7f6fb, 0x1f742877, 0x6ed75cea, 0x96c57df2,
- 0x24fd1530, 0x6c99c517, 0xf5111078, 0xb727de15, 0x8539f3f1, 0x238aaf14,
- 0x944c887f, 0x810bcf1d, 0xab8510df, 0xf40c8cb6, 0xfefc23ab, 0xccf5ea5b,
- 0xdadff79b, 0xd5dcff84, 0xf288beee, 0xfb6eaf31, 0x989f7a38, 0x1c225679,
- 0x77bffdf2, 0x956dde83, 0x19f378e9, 0x17f00fa6, 0xa6d5860f, 0x389af90e,
- 0x05f378c1, 0xb6c1ef86, 0x22e22bf7, 0x17bdc7f8, 0x16bff406, 0xf7f817d6,
- 0x9a976b23, 0xffc76fe9, 0xf295a96c, 0x522696eb, 0x3a00fffe, 0x0047bf29,
- 0x000047bf, 0x00088b1f, 0x00000000, 0x7dedff00, 0x4554780b, 0xeedd7096,
- 0x9d248fdb, 0x777579d0, 0x493cdc9e, 0xf09d0848, 0x3a3e00d8, 0xc0406021,
- 0x490435e6, 0x41a8c1a4, 0xf881ba43, 0xbb75744f, 0xb2021031, 0x10d191b3,
- 0x0186c195, 0x099d1964, 0x09d1a32e, 0xe09af09a, 0x1c604c3a, 0x3719d9c5,
- 0x8ee2a3a0, 0xcfe31e10, 0x7fc38fee, 0x937ba9ce, 0x380e9dbe, 0xf7ff3afe,
- 0xb4fbfa3f, 0xab755538, 0x739d554e, 0x2aaa3cea, 0x89895ead, 0xde6d6322,
- 0xf39f4a1c, 0xc99899da, 0x316f36d8, 0x0ebddbc1, 0x72defd82, 0x9d7a774a,
- 0x5bcbbf94, 0xaf1ef041, 0xdebdd28b, 0x79f74a1a, 0x92fe543d, 0x9fe081b7,
- 0xb6947d7a, 0xff299b7b, 0xc10b6f15, 0x046dbc07, 0x53f5eabf, 0x4bdde1da,
- 0x76de1be9, 0x76f4ef2a, 0xb7a6fc10, 0x6f2ee08b, 0xbc87c10f, 0xf11f04bd,
- 0x98f8269e, 0x1ed28fb7, 0xbe9467ef, 0xf2a7eded, 0x0957bc77, 0xdbbf8ebe,
- 0xcd2afc19, 0x2631e49f, 0x7ae69730, 0xc9ccc21e, 0x00f63226, 0xff824bfe,
- 0xcc8846e2, 0x8cfdd8c2, 0xb0d73eff, 0x9413769a, 0x3ff2fe77, 0x74c60285,
- 0x1f8d8ca5, 0xf662690f, 0xc634c6ce, 0xe675b026, 0xd318724f, 0x63d75740,
- 0x4e09fb07, 0xd6191319, 0x2d75dfc3, 0x58c7dffe, 0x94bffc3c, 0x834c78e5,
- 0x14095369, 0x55befb42, 0x1a777f82, 0x3e20d755, 0xbf1c8dab, 0x95135a69,
- 0xf82c3e57, 0x5563020d, 0x8be9f322, 0x587dfb18, 0xc11b0154, 0x2e8f25d8,
- 0x2172c447, 0x04830edc, 0x443a8ff8, 0x2c5d7e0e, 0x9da5b18e, 0xd29b1d86,
- 0x84aaf106, 0xfdf035ef, 0x0c1a562b, 0x3a3d64ab, 0x1df203c4, 0x9ec618da,
- 0x4ba6b8b7, 0x8a60ff90, 0xf687a7c6, 0xed9fc999, 0x2dec648c, 0xe6066b8b,
- 0x77dcf25f, 0xc07f1b0c, 0x7ec6cf6c, 0xe2ba1b66, 0xfdff4117, 0x9df6b5c7,
- 0xe1f3f0d2, 0x6c67296e, 0xdfca0ddc, 0x02ec973c, 0xa2ffca3c, 0x9ffce175,
- 0xf85645d0, 0x492f01f3, 0x1a4a78e0, 0xeadb3a55, 0x7cf8825a, 0x47b9e919,
- 0xe5f85303, 0xacf6ab6d, 0xae552181, 0x82e11aca, 0x2582eeef, 0xcd8c1963,
- 0x418e9265, 0x38e67cf9, 0x2d4d069a, 0x17822e64, 0x6fa51f31, 0xb1aabbc5,
- 0x4fccc59d, 0x21b26bb0, 0x82b8d435, 0x78cb72f1, 0x947c65b9, 0xabab71f4,
- 0x20e5e38e, 0xba4c4ebc, 0xa5c71b23, 0x5596f5e0, 0x58737aa2, 0xefc476ff,
- 0x3f1783cb, 0xd2863211, 0x174077c7, 0xeb1e6826, 0x73ac3d31, 0xf7d18ea3,
- 0x7e088f8d, 0x2e856ba4, 0xb791992a, 0x0be418fb, 0xf4027481, 0xd2fc8451,
- 0x92373a9f, 0x0949e4e8, 0x92707c1a, 0x0b1fa7d6, 0xb3f8d4e3, 0x87d12d05,
- 0x1efc005e, 0x48fa0388, 0xea0e9e1f, 0xe00d219a, 0x67afa01f, 0xaff3bdb0,
- 0xce0e5dff, 0x49cdfb97, 0xa357ce12, 0xe801d606, 0xd6b6f7d8, 0x99925bbe,
- 0x94ed6014, 0x6ba47e31, 0x73edda26, 0xb17ae0c7, 0xdfa84ea5, 0xfb0d65ad,
- 0xfbf687f3, 0xb417ae2a, 0x2ba6c27f, 0x9cbb53f7, 0x9ff295cf, 0x63c5fae2,
- 0x5eadebca, 0x16ad69f5, 0xe8713ff0, 0x131a5e9c, 0x6f0d1c62, 0xe00666e7,
- 0x3338eeef, 0xe44261dd, 0x45e7f2fa, 0x949fe60e, 0x1fa144e9, 0xb5d23ead,
- 0x178814c3, 0xf9e817ef, 0xd13744e7, 0x4419cf40, 0xe0f89fcf, 0x690639d3,
- 0xfb4822c4, 0x20ba6a60, 0xd660bd75, 0x672cdd23, 0x99ab4a76, 0x6007d293,
- 0x9d7e91f9, 0x38f4a7be, 0x76b20fef, 0xbe2bafca, 0x7cf482d7, 0x8a95c6bf,
- 0xa5eb2d70, 0x2feb377c, 0x2dfcc1b3, 0xd47b5e6c, 0x6fcf5806, 0x025a6a79,
- 0xff3cefcc, 0xce98a3b2, 0xe27c25dd, 0x7a3f8893, 0xc13eaf10, 0xfa113eb3,
- 0x92a5fbbf, 0x3f9049f5, 0x85d7cb47, 0x175f2bfd, 0x8f047e45, 0x97a1f81b,
- 0xe341cb8f, 0xab9546d2, 0x09f2a1f8, 0x9da010e6, 0xff0683fe, 0xfe00b4ce,
- 0xdfe87e28, 0x898e5093, 0x7ae0f7fd, 0xc434dfbb, 0x083f7ae0, 0x29c71be2,
- 0x806b1838, 0x2ad690fe, 0x882a8863, 0xe1621fde, 0xb9f7ac76, 0xa79fdf4c,
- 0xcfefa230, 0x4060e605, 0xa67417bf, 0x5ae50166, 0x0456cbaa, 0xbe60acf8,
- 0x6ee50626, 0x38054bcd, 0xd725234f, 0x1fd744a7, 0xa61537b5, 0xa7f7fca1,
- 0xf7ff280a, 0x698dec19, 0x5d84fdaa, 0xe321408f, 0x3f9f3861, 0x0ec776c0,
- 0x3e284bc5, 0x14429ff6, 0xf33d0663, 0xbf888b19, 0xebe444d9, 0x57f13d44,
- 0x066d4e23, 0x3c94e3f6, 0x9feda1a6, 0xf9edf190, 0xef744b4a, 0x16ecf183,
- 0xf7c3f542, 0x60f8432b, 0x2c3f243f, 0xa7d1fa8c, 0xfa563e71, 0x64bea663,
- 0x6a75d027, 0x86974b84, 0xc716c182, 0xcb998be5, 0x4fb49e97, 0xe67d7133,
- 0xc8a8de4c, 0xdd8f6a65, 0x09d1e5c6, 0xf843e49d, 0x1d9a4944, 0x9c80d724,
- 0x97f8abbd, 0xbb8f11a7, 0x2d2ea68c, 0xdd16eca4, 0x7d94fa9f, 0xff707d30,
- 0x7fd94bbd, 0xeffbe16f, 0xefb5991c, 0xf1babb12, 0x3aecc67b, 0xfd972fc4,
- 0x6d8f995e, 0xf22adfb8, 0x0b7ec871, 0xf9c5eb03, 0x832b2513, 0xc7c0b574,
- 0xdc253abf, 0x36c47c8f, 0xf4f8d2e7, 0xfe0cfcb2, 0x58c15ade, 0x13c651a6,
- 0x19704bfe, 0x20ce6659, 0x5663549c, 0x9b1e29c1, 0x06c8feaa, 0xe69e5549,
- 0x679551cb, 0x7055db34, 0xaab14b56, 0x8736a8fe, 0x97f5ce0a, 0xede7eaab,
- 0x31e0aa75, 0xfaaa15ed, 0xaa5c3b63, 0x1aaec2f2, 0x1eb8f955, 0xd09e0a8f,
- 0xffaaa0db, 0xaa7da777, 0xcd7d49f2, 0x9f29f2aa, 0x5be0a8b5, 0xf554dbfb,
- 0x57eabf6f, 0x7fb09795, 0x354f9556, 0xd3c157ee, 0xeaabafcc, 0x16fb80bf,
- 0xb61dcff0, 0x0cfe556e, 0xbbeab8e9, 0xaa4e733b, 0x75e417e0, 0x270e2df6,
- 0xe72d68be, 0xfb6cd1fb, 0x5876aa07, 0xfebe68e7, 0x7b6f3c61, 0x510b1fcf,
- 0xf4d76e4e, 0x4add21a7, 0xf222735a, 0xdcf16671, 0x2c664043, 0x14aab1db,
- 0xf94e5bc5, 0x1d308753, 0x8a5fdced, 0x715f926c, 0x05a610f2, 0xd0a58bae,
- 0x44d7b31c, 0xc8b4c61f, 0x8ad53853, 0x3dcc34a8, 0xdf44e98c, 0x5728a9aa,
- 0x3f5c785f, 0x2a28f91a, 0x074fa146, 0x827d67d1, 0x7eb9f886, 0xf28fc9b1,
- 0x24c532c7, 0x96139032, 0xb1d65a1f, 0x9a8b4c02, 0x1af66d31, 0xfa0f5f99,
- 0xba519780, 0xfe666bc9, 0xaf67206c, 0x93fae08d, 0x43a795f7, 0x44ab233b,
- 0xe699aa33, 0x48258f51, 0xe5f5bed0, 0x765d9c96, 0xb0edd6c6, 0x42e5d7cf,
- 0xc59e19ff, 0x4e01a23b, 0x30058e63, 0x2398167f, 0x25b19936, 0xfa76df3b,
- 0x97c287f2, 0x244d9d33, 0x5cf6c417, 0x7694ffd4, 0x6e7e9637, 0xdf2198d7,
- 0x11e74bf7, 0xf1adf798, 0xc21df4e1, 0xa75f9925, 0xb60b475d, 0xf69ef90b,
- 0x4cfc7c10, 0x977fdf1a, 0x0a7d73a4, 0x66eb8487, 0xacc6cbe5, 0x808ca7a0,
- 0xa93adcb9, 0xf0ea0ce1, 0xa027d9a2, 0xe0d7627c, 0x892b907b, 0xe0832958,
- 0x4e01c3db, 0x6c625840, 0xc7eb967f, 0xc5d5afd8, 0xfa00d9d8, 0xc351a849,
- 0xcf9e615b, 0xa3e20e66, 0x89f1aa5b, 0x8fdd0630, 0xf43b769d, 0xc60aadb3,
- 0x3d56f00b, 0x7a9437d7, 0xf68c34a3, 0xf8d32ff7, 0xcdaece7e, 0xf49ea3b7,
- 0xe79e3ca5, 0x3e8bfdbc, 0xeb7b44ce, 0x3589a52a, 0xf205c11e, 0xb4e95acd,
- 0xae9ea0fb, 0x8423e611, 0x348bf2de, 0x1dd7be91, 0xa090447e, 0x1269a7de,
- 0x7e9589c1, 0x0d52771a, 0xbf801bb4, 0x6609f44d, 0xe63db7c8, 0x9b3f1013,
- 0xf06769d9, 0x885a331d, 0x3cc8d7fe, 0xcbf86b61, 0x0f418fa2, 0x769d79d3,
- 0x13bba7ac, 0x271f33e8, 0xb86663d4, 0x47e3c94e, 0xa3eb10b0, 0x0d3e86a4,
- 0x9f40dc73, 0xd47d4a8f, 0xddc5fb43, 0xe80b2926, 0xa6c585fb, 0xda211d8a,
- 0x9f9e54fb, 0xfeea310d, 0x1f3e5a2d, 0x6cbedc8a, 0xf0a8ebe6, 0xa6689af1,
- 0x526be392, 0x846f5bc6, 0xc8cdb5af, 0x6ef8015c, 0xd0cc7e85, 0x55abe1be,
- 0xe83f1c66, 0x4fea4ed0, 0xc764f2e4, 0x6ec8728f, 0x21c75e0a, 0x3f9408f4,
- 0xa3e908a2, 0x7c08dfcf, 0xdbd2a868, 0xfeb26f51, 0x7b809343, 0x116b2273,
- 0x5358be50, 0xdc447aca, 0xae5744d7, 0x793e8433, 0xd654ba33, 0x839fd94f,
- 0x3d774bd7, 0x9c12fde3, 0x31d57fef, 0x1f56c7d4, 0x05718f8f, 0x3a4c53d0,
- 0xd662cba7, 0x98fe45a2, 0xbd29dacc, 0x7a52f585, 0xd4a7eb1b, 0xa622ccc1,
- 0x694ecca5, 0x3a527319, 0x2d28799d, 0xce942d67, 0xce94ed64, 0x8294bd62,
- 0x93a9433d, 0x9aeec999, 0xa637fb07, 0xd293980b, 0xa50f31ef, 0x7e9ce999,
- 0xc10b582b, 0x4a76b377, 0x24ef803b, 0x8c01fa3d, 0x9c827694, 0x904df4c3,
- 0x79769873, 0xa3652625, 0xd287201f, 0xa53b5e23, 0x94c5bcc7, 0x541d78f6,
- 0x396f6def, 0x9d78efa5, 0x56f09e94, 0x75ebda50, 0xde53bd51, 0xf5df4a1a,
- 0xcf7d287a, 0x69e940db, 0xdfd28faf, 0x1d299b79, 0xc67e07a5, 0x2be9cdf9,
- 0xf53e7d44, 0x0243bd23, 0xe591ecf9, 0xe68761d2, 0xb8f1dc99, 0x40661a6e,
- 0x235b283a, 0x7359fd20, 0xa43f0e34, 0x0b56729b, 0xe1ba42f7, 0x0cdfd704,
- 0x0fd248d6, 0x82f56dad, 0x0876ed04, 0x5808da7d, 0xa9e9e9cb, 0x9f208d73,
- 0xbad93a4b, 0x19c23b08, 0xee81194f, 0xfd3ce876, 0x64bca03b, 0x08d734a7,
- 0xc8e4d67b, 0x8fb1ff53, 0xe93e54c3, 0x03346b08, 0xfb3d2b3c, 0xe38138a9,
- 0x7befc281, 0xaee6733b, 0x253c44cd, 0x34c5f3c2, 0xbf512c30, 0xfa44c47e,
- 0xd9db6175, 0x93c00d42, 0x68454c1a, 0xebd40617, 0xae1fba42, 0xf2b9705e,
- 0x9655b6dd, 0x0d879c46, 0x0e5a809f, 0x7d19a959, 0xd5f3ab85, 0x5ebe6aed,
- 0x837b4cff, 0x09eb03fe, 0x7f6f6837, 0x7d32a396, 0x3a7effc2, 0xdd6fa60f,
- 0x6bf68ff5, 0x8e640fc8, 0x5774fdc1, 0xfd339734, 0x04ee9fa0, 0xc8c577bc,
- 0x1a4cc6f0, 0x5c43ca17, 0xd29b0db7, 0x77803efd, 0x1f573985, 0xd47ff2c7,
- 0xd14277d8, 0xa6d770ae, 0xc933825c, 0xc621b13f, 0x8f931393, 0x97df3cfa,
- 0x0d1f935a, 0xbff80293, 0xafcb9d39, 0xe95cb7ad, 0x447681dd, 0xc16586b3,
- 0x979b3b77, 0x7681cc6f, 0xf419bc7e, 0xdc478007, 0x0b31bd5a, 0x6a37d3ca,
- 0x19656a26, 0x78fc7887, 0x4d9ef573, 0x8f255fa8, 0x7686c98e, 0x99796433,
- 0xb857db1a, 0x55bce806, 0x95a7b6af, 0x7e649ff4, 0xce6686a9, 0x954d6c82,
- 0x3a1df4ed, 0xdfb81156, 0xefc64cfd, 0xd53c5957, 0x57fdcedd, 0xfee19186,
- 0x25fc6027, 0xc3bfb923, 0xfe48ceb2, 0x7ff24b0e, 0xca03bc9d, 0x7634db2d,
- 0x6b44e954, 0xea1d5aed, 0x3b598bfb, 0x810ee3f2, 0xe14bef7f, 0x0a28217a,
- 0xec0373e9, 0xd3deadf2, 0xfc03328b, 0x9f0ab684, 0xc97bf680, 0x0fa15ac8,
- 0x07e49ff7, 0x2dfbb405, 0x15c12e15, 0x8781f689, 0xb965cfca, 0xf80e927e,
- 0xfbe12ad9, 0xb992fd40, 0xa15d7012, 0xd2768adf, 0x605158f3, 0xf8b3a77f,
- 0x3b07ac3c, 0x75d5f499, 0x782bc27a, 0x97654ebe, 0x95f6c01e, 0xff2e0c75,
- 0xabb7067e, 0x5d013d77, 0xe24c1f20, 0xdd89f376, 0xce3fa489, 0xa0770d69,
- 0xa9e274fd, 0x6f0465d1, 0x3d40ec99, 0xc9eec4f2, 0xb39d31d3, 0x3bd52665,
- 0xb41eb021, 0xb96ce787, 0xd4fcc45b, 0xdb0bc00c, 0x7a27a33b, 0x41e5b39c,
- 0xcb47fbf9, 0xe358bcb0, 0x91da09fb, 0x22fb8dc5, 0x1c9e4ed0, 0xa6124af9,
- 0xf57d3427, 0x5dffd0dd, 0xdc2bf666, 0xe31b9d9e, 0xfe1cb1fe, 0x74a9f731,
- 0xbfd7ea1d, 0xf5a74f4b, 0xc41ccf9c, 0xec835007, 0xf6f65bba, 0x8a4d061e,
- 0x3fded6dd, 0xe65ccc15, 0xc11f30e8, 0x5ecbb4b4, 0xd657d386, 0xe9823ce3,
- 0x194f5ef4, 0xa7e52faa, 0xba608e5b, 0x3bf5d724, 0xff179f9c, 0xbcaf7be1,
- 0xc7c8f008, 0x07a8cdeb, 0x37d13e65, 0xebf92763, 0x21f90c74, 0x45a7926b,
- 0x746c048b, 0x787ca0c6, 0x835169f6, 0xad21b9fb, 0xc3610c25, 0xb41ae97d,
- 0xb745770b, 0xb3b8d0d4, 0xe3ce19c2, 0x210fb0db, 0x3b45645d, 0x809f9063,
- 0x3e1d692f, 0x10d3e993, 0x634731ed, 0x1fcf187e, 0xe1ce17a8, 0x5af503f3,
- 0x27ea04c2, 0x13fb2046, 0xbfdc06d4, 0xddfef26d, 0x38093cc6, 0xcf48d61f,
- 0x64ebf40e, 0x67fe7095, 0xb02e9c91, 0xfa44d37a, 0x96cd9c84, 0xb89dcf16,
- 0xe897560e, 0x3ba40beb, 0xf40706d8, 0x19827491, 0x055bd7da, 0x219c830e,
- 0x7e87f0bc, 0x42c98b0c, 0xbf828d7a, 0x0bda02b5, 0x1c7033d0, 0xdf834cf3,
- 0x9b177429, 0x4235c7c1, 0x65acbfa6, 0xdf053dbc, 0x9f2e0cb8, 0x83496f01,
- 0x7c6568f8, 0x009a1c60, 0xd1ea027c, 0x66f006f8, 0x05d21b76, 0xa7817a48,
- 0xc703124c, 0x8471ad5f, 0x7a645da1, 0x4fe8fbf5, 0x02394289, 0xf753fe78,
- 0x69f22324, 0x327238f0, 0x46df08d2, 0x6f5187d0, 0xfce2e99f, 0x11e958db,
- 0x18423ec8, 0x3a2c9fc7, 0x35681fd0, 0x017416ad, 0xf326b5e3, 0xa5667a7d,
- 0xcae51ba7, 0x3b08e2cc, 0xac9df7d2, 0xf3999d7d, 0xc04c91f7, 0xf81b146f,
- 0x41c4d899, 0x4f47f0bd, 0x97127bbf, 0x97b59934, 0xf9fee2e4, 0x70b3fdf8,
- 0x3a3eb6fd, 0x4ff107b3, 0x3baa79cc, 0x5e741a06, 0x197dd794, 0x6ca4ebf7,
- 0x1c0e3f13, 0xe0079247, 0x8d44bf40, 0x41e81cba, 0x65742b05, 0x71a21a13,
- 0xe444d1bf, 0x7a819ccf, 0xe486944a, 0x6129c83b, 0x33fd4841, 0xf9e4ae88,
- 0xaee7d657, 0x375a4c8c, 0x03af89ab, 0x171bb7eb, 0x5583ca46, 0x6dfa09d6,
- 0x011f3604, 0xa658df74, 0xd7680bf5, 0xac28fd62, 0x919de2cf, 0x8769d743,
- 0x03399a4e, 0x1ac3f4e5, 0x74366ef3, 0x7edc815e, 0xc3ed7a4b, 0xf90e5471,
- 0x7dfc91a2, 0x436af801, 0xb8f5eac1, 0xac6dfd59, 0xb48cee6b, 0xc989f9a1,
- 0x3ee2660b, 0x68cb589b, 0x47cb83fd, 0x575ea63d, 0xa3c737b2, 0xbbf988ff,
- 0xce7ac1be, 0x8655de4c, 0xbaf07cfa, 0x1a97742a, 0x105f7a1b, 0xa65f3933,
- 0x954fd846, 0x92215e93, 0x114ce09e, 0xa2ed03e3, 0x1f7c190d, 0x1335fdba,
- 0x23ec43ed, 0x5cb71fa3, 0x93ef577b, 0xa50eb0b9, 0xae683457, 0x1cefa3b0,
- 0x484ce1fa, 0xddeafda7, 0xf50affd5, 0x1a657da6, 0xb06ff987, 0x10e819be,
- 0x9d80f5f1, 0x2fdaf001, 0xa3a0b4f6, 0xd992b1a4, 0xfa55df71, 0xf3f723d9,
- 0x49df9d0b, 0x645735f2, 0x820e493b, 0x2f401e65, 0x7e896900, 0x56731978,
- 0x68dd90b6, 0x5907cccd, 0xf6bd6e8d, 0xfe5fb425, 0xefd0cf49, 0xd242af38,
- 0xe7f8c095, 0x65ba4a55, 0x5917c7e8, 0xf311ea39, 0x3f94ec2b, 0xf3ced2bf,
- 0x417f3c8d, 0x17f28385, 0xbe783a54, 0x3e61f209, 0x7bf85616, 0x42eed0bd,
- 0x41a48c53, 0x93a5783f, 0x50355f97, 0x0f603bf9, 0x87c90264, 0xde49f987,
- 0xe1a67cb7, 0xb84f12f1, 0x0d5c005f, 0x123d4591, 0x1a7ddfce, 0x8624167b,
- 0x01999114, 0xe9c2b67e, 0xf3f942d7, 0x13809fcc, 0x6af546f9, 0xbfe43667,
- 0x719a2c91, 0xc0386f7c, 0xabf9c66e, 0xe9de6915, 0x351bf007, 0xd8cf14c9,
- 0x7dadfb21, 0x67e48c2b, 0xfc875d05, 0xa2456cac, 0xf2f0c7ac, 0x7ecdcb6d,
- 0x0e40c7d4, 0xdff63ad2, 0x001e9227, 0x1cedf0f2, 0xca5e8bd4, 0x484987b4,
- 0xb37e6ab7, 0xa12f2f54, 0x19992af6, 0x9559f2ed, 0x97c6bdbc, 0xea0d7e34,
- 0x3379a655, 0xf71a0e91, 0xafda3b32, 0x2a9f56cf, 0x9b78458b, 0x87e5cedd,
- 0x56342e5a, 0xe12e396f, 0x731a3c78, 0x7ee7d516, 0xe94f46ad, 0xc830ad2e,
- 0xd2deb4cf, 0x2a18fca0, 0xd83dec6f, 0xa955424e, 0xb3d4137d, 0x8fd138c0,
- 0xf3cf4dbd, 0x1488f77d, 0x8b54b067, 0x4182e65d, 0xa7914efe, 0x187c82d0,
- 0xc545f245, 0x525fa35f, 0xf9923fc3, 0xc45df814, 0x3176f971, 0x5d95c93b,
- 0x27207aea, 0x52af2835, 0x67f9d4da, 0x2fc504b2, 0xe0879aa5, 0xb87ab679,
- 0xe71e0bdc, 0xc2bab8e0, 0x34b8d146, 0xd7285c7c, 0x74d73f20, 0x2b73f288,
- 0xa124bb45, 0x853f6bbc, 0x92f51fe3, 0x9e00bac8, 0x13345d55, 0x66d669e9,
- 0x6643b90d, 0x0b925eb3, 0xe2b71b37, 0x671e08df, 0x6436f8f0, 0x1cdf6968,
- 0x1bd707d0, 0x7d6c1f49, 0xb8c1a4c4, 0xe15be822, 0x973857e8, 0x099e1a55,
- 0x532230f3, 0x6bafd7d6, 0x34693cb9, 0xacea9d11, 0xfa04e58f, 0xa5d1841f,
- 0xeebeb023, 0x72bcec7a, 0x68e91b8a, 0xac72c1dc, 0x93639658, 0x2a7c60fa,
- 0x933873ff, 0xd6f7e602, 0x7c1518fe, 0x5544d5fb, 0x2e1012fd, 0x8d53e581,
- 0x69f2aa79, 0xf82a71e6, 0x5514db0e, 0x54d219fd, 0xce677c15, 0xb3faaa9d,
- 0xf055f3ed, 0x544bc55d, 0xee3ae7f5, 0x2fcf9555, 0xbe55487f, 0x0546b9d0,
- 0x7bf8aa2f, 0xaec5fd55, 0x92f95546, 0xe555279a, 0x9293f6c1, 0x3f726696,
- 0xe79b56cf, 0x8be483a4, 0x0e46704b, 0x14a967ad, 0x3dd703fb, 0x53eb822a,
- 0xe51af5c1, 0xe04178f5, 0x48feb1fd, 0xe29df20d, 0x91ed637f, 0xd75cff2a,
- 0x3ec6c9e4, 0xec72fa13, 0xb2dd23ef, 0xc51fdc13, 0xc53bfcfc, 0x04fdd57f,
- 0x56f683d4, 0x715ba647, 0xabbf43bf, 0xf9fd0f4b, 0xb7bfe435, 0xb40bd736,
- 0xe7ae6e0f, 0x7aab957e, 0xc00d8ae6, 0x7ef38583, 0x828e78e5, 0x70447327,
- 0xcf1860ff, 0x95fb26df, 0x52bf439e, 0xb03f6336, 0x17787e28, 0xac509bb5,
- 0x467fa1f7, 0x7a08f6a8, 0x662e5b94, 0x07284836, 0x97ff5397, 0x5823ec2b,
- 0xd2567988, 0x398daf56, 0xbd5b7da0, 0xc61ead6f, 0x69399756, 0xbcd0b3cb,
- 0x1fc8c3cd, 0x94e668f3, 0xe7816b2d, 0xa25321ff, 0xf9104975, 0xf75f3f3c,
- 0xd03db9c6, 0xa5956b5f, 0x706ae508, 0xf3bb9279, 0x941bb1e2, 0xd5f2bf3f,
- 0xd1bfee0f, 0x671d75f7, 0x87ca029a, 0x24568bf5, 0x1d004732, 0x7ed08648,
- 0x74c81ff9, 0x27ac9ee5, 0x5a33d63f, 0xcfc893d7, 0xd7ff2617, 0xddf0bdc4,
- 0x3dcae979, 0xfe43a7a8, 0xea1f300f, 0xcf9ebcd1, 0x29e744bc, 0xbf40f352,
- 0x2c3bfd47, 0x941edd34, 0x95ad17db, 0x5a07e8fd, 0xd097a91d, 0x7e324fce,
- 0x0eea7e46, 0x83abb71d, 0x07e7f7ed, 0xb276edec, 0xedcbf7bf, 0xad5396ec,
- 0x8ccf7f99, 0xe45a263e, 0xf98840f8, 0x09b546d0, 0xab12af28, 0xf9024fc5,
- 0x4f523ba2, 0x498b047e, 0x6a983bf6, 0xc5017e54, 0x791dd06f, 0x6f7480bf,
- 0x7e415ae9, 0x6017f47a, 0x75e5077b, 0x2417f609, 0xe8b4ff19, 0xb51bd8e3,
- 0x23f206cf, 0x04fd1084, 0x27f8a1e1, 0xa3f1fb82, 0xccfb813e, 0x27d270ca,
- 0x397dc782, 0x6650e4b3, 0xff48f23c, 0x7e503bc9, 0x7ed1d29f, 0x84bd1c38,
- 0x1fcce149, 0x266f7ed0, 0x7223efb7, 0x91f95462, 0x0fe644f6, 0x64b35ff4,
- 0x321127f3, 0x48cc5b0c, 0x51c6df7d, 0xbcdbdfd8, 0xbb3a13bf, 0xd841f48d,
- 0x7bfed0f6, 0xeee7e64f, 0xab69465c, 0x01b7976c, 0x9cfa631f, 0xd9fa4cd7,
- 0x843fe036, 0x4a257bb7, 0x4a1cdefd, 0x54ed7a77, 0x4c5bcbbe, 0x83af1ef0,
- 0x72debde0, 0x9d79f74a, 0xb792ff94, 0x7a9fe082, 0x7bb6945d, 0x15ff286b,
- 0x03e087af, 0x5f8206de, 0x44507d45, 0xa533753f, 0xa85b786f, 0x46dbd3bc,
- 0x3f5e9bf0, 0xbdde5da5, 0xdbc87f94, 0x6f11f04e, 0xbcc7c107, 0x78f7045d,
- 0xdb7d287b, 0xeff94bdb, 0xdc134f78, 0xb1938f2b, 0xfa2f5ee6, 0x84a25c2b,
- 0xaeb3ddfa, 0xd7ea336a, 0x331a65b6, 0x9736f38a, 0x39fa0566, 0x78f255b6,
- 0x86956d9f, 0x87a040fc, 0xb39f51fa, 0xf8fa7b2d, 0x405f2a34, 0x49b15be5,
- 0xabac4a30, 0x56cafeb8, 0x159ea9ea, 0x77c1020f, 0xfd2b6adb, 0xb25b805a,
- 0xbadca9c3, 0xedbb244a, 0x3a278d79, 0x245deb9b, 0xae3aadbf, 0x1074283f,
- 0x22e9fb21, 0x974a44b2, 0xa3fc7365, 0x23ef4232, 0xfc4a5919, 0xc707b9a4,
- 0xf182ab67, 0xf555be21, 0x5a5f8c46, 0x49f183ef, 0x3aae3fa4, 0xc3247804,
- 0xc07f1178, 0x6cc2fc87, 0xad97d719, 0xaf08eb55, 0x94f365e4, 0xda346778,
- 0xfa9e6de9, 0xa56f84b9, 0x36cd7e48, 0xfbe8a1d7, 0xe7ca4e50, 0xe1f1ac7c,
- 0x50fe7f4e, 0xf082327c, 0xddb8c6df, 0xd2fa0c90, 0x00e310fe, 0xc7a9478b,
- 0x198f78fd, 0x26f1fa43, 0xb2627acb, 0x3d8ff9c0, 0x6dff122c, 0xc1f7a067,
- 0x7e81cf77, 0x503943e7, 0xfa156fba, 0x72cd1eab, 0x3c02cc4d, 0x3f8d247e,
- 0x531c0224, 0xaf4fdbce, 0x1ea0f717, 0xae7deb0d, 0x3e37f209, 0xb689d9b8,
- 0x6966ec71, 0xdb5bb22d, 0xd01357b2, 0xa82c95ff, 0xcb4947d7, 0x3bb63c65,
- 0xd5cf7b78, 0xb64fe48b, 0x76903aae, 0x865bf784, 0xfa8e26fd, 0x61ba187d,
- 0x1a481632, 0x55c91914, 0x2fec45e2, 0xe5cda1ec, 0x66fc5fd8, 0x215fd287,
- 0xe775f7f6, 0x65e3e469, 0xbc085756, 0x37279386, 0xb38b2393, 0x8e48e322,
- 0x9424b124, 0xb8ebcf23, 0xe49df2dc, 0x861d24fa, 0x1fb43499, 0xc4ae7e25,
- 0xe8e383d3, 0x243d3235, 0x61c74219, 0xfde80d57, 0xddb7aa3e, 0xe749c9b1,
- 0x0b3e304b, 0x6c75ab45, 0xeaf3ae05, 0xdaf37092, 0xa4a0f410, 0x018e505b,
- 0x468bdfdf, 0xb9b3b523, 0xe1a3b79c, 0x56cadced, 0x32625c11, 0x6bc842fb,
- 0x6e5a7d25, 0x4e2c81e7, 0xbe0f49b7, 0xae18f1b4, 0x3a3adbef, 0xc69cf413,
- 0x04ed11bf, 0xc92d09df, 0xfb6d44d7, 0x78013d8e, 0x79e3cb35, 0xb5cfef4e,
- 0x7b40ff23, 0x915728f9, 0x7fc9f25f, 0xcc0566c1, 0x5addf2bb, 0xa3fd8fd9,
- 0x29a21b6b, 0x2eb55cbe, 0x36a3f50c, 0xb07a2466, 0x85d13cea, 0x4560f401,
- 0x1f410cba, 0x4af4b2fb, 0x3254d53c, 0x7c32e311, 0x728a9e5f, 0x583ef009,
- 0xe1fb451d, 0xdeef65d4, 0x5be01639, 0xd47688ae, 0xe5ab9ecb, 0xfd2713e7,
- 0x26e74351, 0xdb9c7cde, 0xb7fdb77d, 0x7bf41eb2, 0xb3e9c827, 0x7a41e768,
- 0x77b3334b, 0x52dcbac1, 0xcdff226d, 0xb3c557ad, 0xb91a7681, 0x7da3c7a4,
- 0x5335fdc1, 0x803ca1fa, 0xa67d26fe, 0xaa330fae, 0xa1233d45, 0xab6f9d4f,
- 0x1a66703a, 0xcb56d3f4, 0xf6bb6e3f, 0x7d8471fe, 0x93f21af5, 0xf429f500,
- 0x4dfe4093, 0xe78097d1, 0x191a3716, 0x32eb73c9, 0x41e519a3, 0xe49c25b7,
- 0x1362db5f, 0x321ba1e9, 0x9ea18757, 0x8faaa86c, 0xdea474c6, 0xa77d03b7,
- 0x7dffbbdd, 0xe4812d9e, 0x817f3f2d, 0xfa0c5984, 0xae7abdc0, 0xb6faf8e4,
- 0x7944cb4c, 0xc3f2a1a9, 0x8b7dffbb, 0xac077d0f, 0x3490f085, 0x7e0f912c,
- 0xe29bbe00, 0x2fdf02d4, 0x444e6740, 0xabae74f8, 0x4243e507, 0x8b1baf9c,
- 0x56ce9ab6, 0xcae2f9d2, 0x5d33e238, 0x31e987b5, 0x18c8b2bf, 0x9f0ae7c8,
- 0xfffcb5fc, 0xbbe71cb4, 0x59b81c99, 0xf7e337bb, 0xbe73a59f, 0x369ece19,
- 0x154f230c, 0x9acf18fb, 0x4b6c8a63, 0x7d59eafb, 0xf6eafd48, 0xc567ce6c,
- 0x643e7e7a, 0x72f4c54e, 0xfaf8c38a, 0x96c73c44, 0xa9f9cd93, 0x714912cd,
- 0xd674b6e2, 0xdf037185, 0xf7f70d72, 0xdafff1c4, 0x3fc9d32a, 0xa2782ad4,
- 0x3e78197d, 0xeb8695c2, 0x147306d7, 0xa6b7fd09, 0xfcceb972, 0xabc6331e,
- 0x409a9da1, 0xf3dec1fc, 0x9198e9a9, 0x0bfe4c3e, 0xa49ef12d, 0xa3b7f00f,
- 0x17fd1c5f, 0xdadddfc1, 0xbf6f86af, 0x984b86aa, 0x354f054e, 0x6669e1aa,
- 0xe6c96c35, 0x361dfa7a, 0x490cfe75, 0x1ca7270d, 0x73f0d309, 0x7f01a6ed,
- 0xbbf044b3, 0xa07e0199, 0x01769a0d, 0xafa525e7, 0xadb2fc96, 0x93dfdca9,
- 0x73f6af5c, 0xb596b224, 0x6df90231, 0xfcb6f954, 0x73fa0255, 0x7cead56c,
- 0x8c150798, 0xbff48acb, 0x9f95d724, 0x02e9718d, 0x4b3aee7e, 0xc5cde9eb,
- 0x238b6875, 0xcf934a3e, 0x1fdd0d05, 0x95b8d0b7, 0x7c0f9076, 0xfa45e301,
- 0xe62f840f, 0xc76726ba, 0x05f03e73, 0x7df997ee, 0xa503e43a, 0x41f8e1bf,
- 0x3962c7e1, 0xab9ca26e, 0xa5b722b9, 0x97a9ab9c, 0x0475c7cf, 0x92b9c79d,
- 0x81e7465c, 0x09aef4ae, 0xc877c50f, 0xce6cbe67, 0x946e9877, 0xdf20d7cf,
- 0xef9cf4f9, 0xd5f0df30, 0xfd28672a, 0xafbcbcf0, 0xcc37b43c, 0xf8c071fc,
- 0xab47b656, 0x82477760, 0xd3bcf039, 0x740ff843, 0x3a3337ba, 0x0f2b5a47,
- 0xbf338be7, 0xe908d3db, 0x0b975a5b, 0xd66567d7, 0x338f3d59, 0xfe51ebf5,
- 0xdff7979e, 0x38dd820d, 0xdb94c05a, 0xbb668da5, 0xccbdfd11, 0x57f2a19f,
- 0xd5877e28, 0x31acd22b, 0x0188ff80, 0x4cd3823f, 0x33e34de7, 0x35118fc9,
- 0x2b3771d5, 0xccf73c04, 0xa2046f98, 0x554e85dc, 0x658fc790, 0x97d0fd97,
- 0x035e383c, 0xce02abfa, 0x0f441923, 0x3573b923, 0xe7014995, 0xff655bca,
- 0x9b1f00c5, 0x7f609796, 0x7896cc3f, 0xd679863c, 0xda9fff72, 0x6ab8665f,
- 0xd833b553, 0xdfaab27e, 0x722fd956, 0xfed5f6f3, 0xf4d5c337, 0x0ecfda61,
- 0xb21cdf6a, 0xd576c1fd, 0x11afbc7e, 0x3e436f1f, 0xb5ffce18, 0x1ba7965f,
- 0xf45e9e6c, 0xd818e97f, 0x06071495, 0x6a8898fa, 0xc369ff23, 0x5d5379f9,
- 0xa60fdab2, 0x1f927e63, 0x90d647cf, 0x3e6048fc, 0x9859df8a, 0x47d7f287,
- 0xbbf1e74d, 0x1371b960, 0x8798c179, 0xfd00dea1, 0x3f57f2a9, 0x46d3f7c2,
- 0x3c42eec1, 0xfff3c783, 0x89abdd8a, 0xfa4bdf1c, 0x64b84a73, 0xdbde81b8,
- 0xe32575ea, 0x3dc21bf7, 0xfeeb1835, 0x762ebb3c, 0x1b3de83d, 0x7c08c630,
- 0x71bb3576, 0xfb84cfbe, 0xf58fa724, 0x27a21a71, 0x1d96ddcb, 0xb27a00da,
- 0xa8695de8, 0xf2345af7, 0xa1fc2f39, 0x65bd6cbf, 0xfd10a6e7, 0x029bfa2b,
- 0x8f002b5b, 0x956dba00, 0xfe81e6f5, 0xd0ee2496, 0x3163b406, 0x3fa90ab8,
- 0xd2a35ce5, 0xeb37d35f, 0xf7ecab6f, 0xdeb3fa52, 0x559f1ea3, 0x59f1a1ef,
- 0xe947fde5, 0x2f8e2b6f, 0xb4dd5f04, 0x1e8ed93f, 0x7aa96fe8, 0x8783567c,
- 0x72d567c6, 0x7f40e1ff, 0xbfacdf4d, 0x931ef936, 0xe1d3e64d, 0x0e37fdce,
- 0x1a76ab9c, 0x29b4ae51, 0x7f7940fe, 0xbfb414bb, 0x37f796ad, 0x714bfbe5,
- 0xbddfe4e9, 0x18df33d4, 0xfdc35f6a, 0x247ac98c, 0x2648f593, 0xcf0891eb,
- 0x3ea67a99, 0xf0b0e81e, 0x22f9b6c5, 0x1e73e3ec, 0x153e333a, 0xf62f19e0,
- 0x5f6117cf, 0x99e2f39a, 0xc9f04903, 0xccbe2fcb, 0xe6787fcb, 0x9b94324a,
- 0x2fcdef7c, 0x962a3803, 0xde0ac7ef, 0x8db7bf4a, 0xbba37ae2, 0xbfee73e1,
- 0xfb8af904, 0x87aa6356, 0x42f17fa1, 0x32d47f72, 0xe94eefa8, 0x310f2cb7,
- 0x6eea4a2f, 0x467e4f38, 0xff287914, 0x40bfe1e6, 0xee53cfb4, 0xefab9467,
- 0x6d454467, 0x8c2ffd22, 0xef28cdf9, 0xba0e8c22, 0x28d6f84f, 0x642c1fbe,
- 0x376e0af6, 0x39f25948, 0x31cfba0d, 0xd76e58bf, 0xb1cfcb7c, 0xb1c6a17c,
- 0xdfd9ed1e, 0x478aaa4e, 0x173958f5, 0x7f783797, 0x1bf5d772, 0xbe0e1f9c,
- 0x23e7393f, 0x23c2eb81, 0x3ba5bfb8, 0xb9f7e257, 0xa886fc02, 0x9f370ef7,
- 0x7db8a3b5, 0x0e9f383f, 0x0e319f3e, 0xfee69f3e, 0xfeb0b5a8, 0xcb7ee8ee,
- 0x5d9fc413, 0xc86be721, 0x5fcd06bc, 0xd8a628fd, 0xb7a45a79, 0x32b7cd9b,
- 0xc1f9caaf, 0xa2ca4146, 0x794feafd, 0x3183fd2a, 0x8e2a14bb, 0xb819f483,
- 0x4e6deabf, 0x5d19fe86, 0xcf073d9c, 0x45fe3795, 0xde5cf21b, 0xd63e796e,
- 0xb9d38546, 0x3d28c6ce, 0x51dddbd9, 0x97fa1933, 0x9a74d345, 0x72a8b297,
- 0x8da96f3a, 0x8f68ed65, 0xd7239f06, 0xce9bb88e, 0x68ad6901, 0x703a4041,
- 0xa461d92e, 0xe8b989f8, 0xc5c8e786, 0x8f239d9b, 0x91cfc999, 0x7425e947,
- 0xea45b459, 0x7f239e43, 0xf7df146c, 0x713c71bb, 0x278c3f88, 0xa21c706d,
- 0x31d1c799, 0xf5f2023f, 0x7f231766, 0xc7de3cba, 0xea5075e4, 0x861ecc1b,
- 0xb7ab40f2, 0x68a7a84b, 0x613ef9c3, 0x4e5869b0, 0xf7c8bf08, 0xfbe8e947,
- 0x34cd724f, 0xd7231aaf, 0x5afce7cb, 0x7a4fe908, 0x4fe29475, 0xc3674d0a,
- 0x0d3cc9d1, 0xf0a7473f, 0x9e9302e1, 0x302df7ce, 0x0fd14ad9, 0xef0800b2,
- 0xfa8098b3, 0xf7e22db7, 0x0dbb4581, 0x5337e7e9, 0x6ff9ff6e, 0xb9f9ba18,
- 0x43353e7c, 0x4ee3f747, 0x8f61cc09, 0xd57e7a19, 0x869e8ce9, 0x66bb9a6e,
- 0xec87599d, 0xeff2e2f7, 0x867b6115, 0x167553e3, 0x779fec89, 0xa85ca146,
- 0x0f1f5b4e, 0x42caa2f0, 0x94dfdd1d, 0x08ee44e3, 0xd19fc72e, 0xa28e4eba,
- 0x51e7d178, 0x624748a5, 0xa3e22a7f, 0xea0289c4, 0x9e2a37bd, 0xd7e1cdea,
- 0x18dea0c5, 0x7f67d394, 0x1eb462ef, 0x127a50b6, 0x302c4fda, 0x07cb236e,
- 0xf302a3b4, 0x01627ed1, 0x2f2c27eb, 0x9085f6b6, 0x609a4a17, 0x0d5292db,
- 0xd0909e7c, 0xff92a942, 0xee5b43ac, 0x57aeb10f, 0xc6fd75e5, 0x601b4c76,
- 0x8ed0713b, 0x2ae5fb01, 0xd517dbce, 0x61e32ca7, 0x17657548, 0xe9b18ec9,
- 0x88933e15, 0x1e6106bf, 0x45fb04af, 0xd5b0de75, 0xfba14beb, 0x6d38f2fe,
- 0xa346d62b, 0x1c55031d, 0xbcdb9f48, 0x9965296d, 0xcec8e383, 0x8d13e991,
- 0x17a889b6, 0x5c725ff3, 0x97f40ccb, 0x74349b24, 0x5326013e, 0x6e612f75,
- 0x38b4f459, 0xccdd4534, 0x2ed0926e, 0x3f3d25ef, 0xf896bae1, 0x62f0e120,
- 0xa4ab7186, 0xef0176b8, 0x23f40d03, 0x97ae6fdf, 0x5c57b9e3, 0x048e3465,
- 0xcefec0eb, 0xf38d0ec8, 0x747945cd, 0x518e69e5, 0xe5d58fc2, 0xdcfc71c9,
- 0xe1d5fdc2, 0x3ae8097e, 0x4057b6a9, 0x380c0138, 0x5c27c5f4, 0x426b4c6f,
- 0x045af279, 0x6db58bf9, 0xf207cc99, 0x45745527, 0xfb3ce0e5, 0xc9a6ffa5,
- 0xdf0b0790, 0x9c207cad, 0xa136b3f4, 0x25d90665, 0x285869f7, 0x1c98cf3f,
- 0xc828c7ee, 0x609ffce1, 0x1ea94d6b, 0x44d3e987, 0xcf975f37, 0x1db39067,
- 0x9f11d9f4, 0x1c58fa2d, 0x759a7bd4, 0x9b73e9a1, 0x7ec0efdc, 0x185fcf21,
- 0x7f911973, 0x3b9382b5, 0xdbeef739, 0xce82cfb7, 0x55e74613, 0x8d7ac936,
- 0x4e444ed2, 0xd846153b, 0x45cf0c1d, 0xdf07660a, 0x9b3ecc07, 0xf9abd60f,
- 0x7b486d2b, 0x791cc1eb, 0xb26b491f, 0x4cb2fd61, 0x94fd0dbb, 0x1a55f7c1,
- 0x70da26d3, 0x0c671a7d, 0x7031a9d0, 0xcb4ee85f, 0x53cf1f7e, 0x2c747a99,
- 0x70591cf0, 0x2173c7aa, 0x972837b1, 0x1d3797cf, 0x9b42e7e2, 0x78bd454c,
- 0x14c9a10e, 0xfec74457, 0xa99cfc4c, 0x3a64df52, 0x64def246, 0x1356f1e7,
- 0xa2020fee, 0x3ba1e7c7, 0x83cd18ed, 0x0e5a6f52, 0x7b26ab97, 0x5bfbc317,
- 0xd53f76e1, 0x3e9d130b, 0x161fe00d, 0x4ffee8c7, 0x55f39198, 0x318fac04,
- 0x7e95ef80, 0xd1d1cb6f, 0x172535bc, 0x7e1096f5, 0x6704de22, 0x1b22b64d,
- 0xdf38dbed, 0xb4636fd0, 0xaf9cdf42, 0x5be7971f, 0x3e51a769, 0x434f7aff,
- 0x58b2fcce, 0xd73913f4, 0xa6bb60e4, 0x83b446e5, 0x6fe391b4, 0x6186ded8,
- 0x285e6bdb, 0xf238f7b7, 0xc8b23685, 0x50e9ed8c, 0xc3a0845e, 0xfe76e467,
- 0x30ede357, 0x97df74b3, 0x9f305a60, 0xa3de942d, 0xa38c46a4, 0xddfa1b8f,
- 0xebbf9637, 0x90247ed4, 0xfc717bbf, 0x1ecf932b, 0xee1ca12b, 0xdb2eda3f,
- 0x619d8a27, 0x2ededb91, 0x3ee87bf0, 0xef4edc21, 0x8776c836, 0x0f3d4c25,
- 0xf941f783, 0xe0ae5c3a, 0xc72ee6e7, 0x046b8a31, 0x77e5f3f3, 0xb40e8a3e,
- 0x73ef504f, 0x04bb7364, 0x1c4bb453, 0x610d9fb2, 0x9da01bf4, 0x80fdf0a2,
- 0xfa42b75f, 0x3f005ba7, 0x0d6fc803, 0x7b242bb4, 0xc90dbe88, 0xe7c8697d,
- 0x053bf2a9, 0x5cd7f643, 0x4785a72e, 0xfe434b3f, 0x4feb8b2e, 0xf982efc0,
- 0xae4785fc, 0x5e78e026, 0xce703198, 0xab43e286, 0x7bf3a717, 0x1cffc7d9,
- 0xfed10aed, 0x457feecd, 0x86b4dd9d, 0x5ce5c0f4, 0xdf5bfc0f, 0x8cbedb07,
- 0x821d9deb, 0xcda4efda, 0x5fe77ae5, 0x7acc7de4, 0x2df7a455, 0x2eb965ce,
- 0x0ab61f20, 0x7f28e5e6, 0xe7e11f53, 0x5e3f56e6, 0x2103d9ff, 0xed1841f8,
- 0x804e73fa, 0xacdc5c3d, 0xa35a3f27, 0x8dc47d29, 0xafc31ce2, 0x71cb87b3,
- 0x1e4b7d79, 0x24f3f235, 0x5b17ae2e, 0x39d3f75c, 0x23f3e095, 0x243bd5c3,
- 0xbea53dcb, 0x7947db01, 0xfe479a62, 0x23684b80, 0x964dbfa0, 0x7678c17b,
- 0xf3c864e2, 0x12b90463, 0x18456875, 0xed93abb6, 0x3f8aedb1, 0xe8c8a2a3,
- 0xb75ef808, 0x1a58c8b8, 0x8c8d2f40, 0x6e0ddf9f, 0x01dcceff, 0xafa55a7d,
- 0x459f70e8, 0xf89c50df, 0x433901a7, 0xcab8658a, 0x0ffa518e, 0x70163f3e,
- 0xf38c2c5e, 0x5a67b729, 0xe818dcf1, 0x962b6bb7, 0x6df9c48f, 0x582f5d15,
- 0x3ffa1e61, 0xe739d030, 0xecbe650f, 0xb872f993, 0x43b1f3f5, 0xf6318ca0,
- 0x97823b04, 0xc64e80d6, 0x68fe408f, 0xfb94d4cc, 0x5cb38c43, 0xfd08671e,
- 0xafdcd6fa, 0xe6975fa7, 0x51afd086, 0xc504767f, 0xd461021f, 0xf4211d9b,
- 0xec8213eb, 0xedcf900f, 0x1d49d09c, 0x270f307d, 0x6f611d6e, 0x919ee894,
- 0xf6045ec3, 0x32678bc3, 0x239f6f51, 0x23c7bc0c, 0x608c31db, 0x221623b0,
- 0x6799735e, 0xc50203df, 0x48ee5a51, 0x5c04eea3, 0xa7ad9b8f, 0x3711fb24,
- 0xdc613ac2, 0xb2daf5a1, 0x0ce2a119, 0x274038ff, 0xef02ba28, 0x042ac007,
- 0xc48695c4, 0x63e282cb, 0x38194e18, 0x5a1dabff, 0x7562aeff, 0x35e36afc,
- 0xac30bfee, 0x0427fe60, 0x2eaa1f3c, 0x0bae5f9f, 0xe2a9cf8e, 0xba9d0b5a,
- 0x887c7c60, 0x6f8cb26f, 0x2907b6ca, 0x452d3e0e, 0x64acfde4, 0xc707cf64,
- 0xbd850cbd, 0xc3ea2d0e, 0xf7f48c15, 0x9e363f60, 0x5eff2517, 0x09cf6305,
- 0x7d5ade74, 0x59e9e4df, 0x1cfbf8e7, 0x8fd8e52d, 0x50c3532d, 0xafbe0e3f,
- 0xf09bc4a0, 0x7de04c98, 0x22dde569, 0xe10d62cb, 0x53b77cc7, 0x8797e2b9,
- 0x4b12a6fa, 0x55eeb9c0, 0xdd3ea06c, 0x1e85f2a3, 0x59d6d6f7, 0x1c4fef14,
- 0x82ec29ef, 0xa33b24a2, 0x66aa4879, 0x3cc00764, 0x86fae2a8, 0xce345d94,
- 0xc58c354b, 0xaaa038f2, 0x7076013c, 0xbf184fa4, 0xe30fce2a, 0x76c1c154,
- 0x4deccde7, 0x0de64a43, 0xfccdf9e5, 0x5e39068d, 0x646e46f8, 0x633be91c,
- 0x77d418d8, 0xa69f8b2c, 0xeb04b8f5, 0x34597e81, 0x03c54284, 0x68fb4337,
- 0x5f90ba07, 0xc4dfd1e2, 0x30caef54, 0xc9f74887, 0xb38e6284, 0xf1e4eb10,
- 0xfc467ce1, 0x9507086d, 0x9859f80b, 0xbce0706c, 0xc3000c1b, 0x333d0590,
- 0x56be4026, 0x15af37f6, 0x33308898, 0x4fdc8ddb, 0xe36bbca8, 0x866d77a7,
- 0xff7407eb, 0xcfec30be, 0xfa53bfc7, 0xdb8ef219, 0xfb27be0d, 0x7dfc1ccd,
- 0x951df919, 0xff9b87fe, 0xfb6ddee1, 0x2777d4c3, 0x3267bf70, 0x20e56bd1,
- 0x4cbc12bd, 0x1efc47a6, 0x4abdc2e5, 0x0c77adb1, 0xfb3c37de, 0xfd1d8470,
- 0xf0e303e0, 0xefe5a9dd, 0xed75fdd1, 0x9361e00d, 0x8c0fbe48, 0xafef6e4b,
- 0x02fd171d, 0xbc06dae4, 0x4fe78434, 0x279d192a, 0xcf4ab8b0, 0x000e7489,
- 0x1392a0c6, 0x4013ef01, 0xf10e1b7b, 0xf15baf73, 0xb0710b9d, 0xd02bd45f,
- 0x4255b06e, 0x483b087e, 0xbf19ab49, 0xd5e0ac1f, 0x1a3d07a8, 0xf5c352e9,
- 0x3ea6d9e8, 0xe935cf11, 0xe445fae2, 0x2e68e71f, 0x37e807c7, 0x0bf9d19e,
- 0xce7c926d, 0xdfc4a471, 0xfbe4cb4d, 0x84cfd29b, 0xfe591ad1, 0x47fbd2f7,
- 0xd54e23b3, 0xf2c6764b, 0x442fc5f6, 0x11ecfcff, 0x00d3eaa7, 0xe167d82e,
- 0x2ba9d270, 0xecc66669, 0xd10bacfb, 0xef3b3f9f, 0x807495d4, 0x78d9f68b,
- 0x464614f9, 0x097df8ce, 0x319fd10b, 0xd559b461, 0xd7385bfe, 0xd53cdff1,
- 0xcf21341a, 0x5a36df63, 0xe8c94f39, 0xf3b3ad3e, 0x2e31a797, 0x47f654e9,
- 0xdf482e87, 0xde0b2281, 0x717f9323, 0x9d0f1451, 0x9dd9d329, 0x1452eef8,
- 0x68bb2dfa, 0xfa0d477e, 0x6bfe9fe9, 0x4382f4fc, 0xccca9779, 0x1bff812a,
- 0x2c2b981b, 0x99ee8023, 0x9f9d7343, 0x81b8a603, 0xffd28f82, 0x6960bc10,
- 0xbc4098c5, 0x0a3b51b6, 0x0d0a175e, 0xc70587a4, 0xfd082e87, 0x549cf1db,
- 0x2fd6cfc4, 0x10ba75c2, 0x002a9fd9, 0x9eb79e1c, 0x7c42edd6, 0x1ec176ff,
- 0x3af8eb00, 0xa22bef56, 0xd6a3fc75, 0x027a3d51, 0xdfc5dbbe, 0xe396686f,
- 0xbbc64f50, 0x019f687c, 0x32b9d1dd, 0xfc9e8a5f, 0x05e36548, 0xb03fa047,
- 0xcbf7346e, 0x69d3925c, 0x49cf1686, 0x01f74ba0, 0xfa85ad81, 0xf5976bee,
- 0xeecc9fa8, 0x3d47a33c, 0x19c0eeba, 0xad4bde3d, 0xa9da1843, 0x8477a6db,
- 0x32feffd2, 0x97f2ab5a, 0xd1d77629, 0xe8f5ec94, 0x16abab77, 0xeade1ee8,
- 0x6e1fb9d7, 0x251c32f5, 0xb2df7763, 0x55b8fc9f, 0x98f5eece, 0x477d652e,
- 0xc588ddf1, 0xdceaad2e, 0x089a92c0, 0xcabe3c55, 0x9782ab13, 0xc0eac0b6,
- 0x21b4bb3e, 0xc31df549, 0xef82cf5d, 0xd0fe0e28, 0xd790affe, 0x736db171,
- 0x16bbfa2f, 0xcc7ad4bb, 0x62b5ceec, 0x11ede20c, 0xfece1aec, 0x84b77e12,
- 0x00d2108f, 0x7de60abd, 0xa3d7075a, 0x648c2aea, 0x0c22549f, 0xab595af3,
- 0x7393e3f5, 0x54f45347, 0xa810eeee, 0xbb972ddc, 0x576e046b, 0xa975f2cb,
- 0x8392e38c, 0x75d1a727, 0x37a39f52, 0xa5df0033, 0x88e7e515, 0x437d651e,
- 0xc4855719, 0x290d8df5, 0xddb0e9ef, 0x5817dfa5, 0x4b8d1a6c, 0xa92d47a5,
- 0x1e55c351, 0xd59e905d, 0xbdf943a7, 0xff9d41b4, 0xbef2d1f3, 0x90f2c79e,
- 0x2d18de9f, 0x07189f88, 0xbca53fe1, 0x81ef0277, 0x0f3ad25d, 0xead67d22,
- 0xdf700abb, 0x1175a4bb, 0x7e4394ac, 0xb8afdf1d, 0xce01a2be, 0x751befc3,
- 0xa7de330e, 0x8814adf5, 0x00b0976e, 0xb06d27bd, 0xa1dac13e, 0x7722bf70,
- 0xe4f59cc3, 0x98283d0f, 0x13286f51, 0x83de221d, 0x8fc61c6f, 0x83e6517e,
- 0x1f2fac13, 0x2246caf1, 0x9eca7585, 0x99f6823f, 0xf996b7ec, 0x3d948e30,
- 0xc4bf204e, 0x4371809d, 0xc922a611, 0x37b03991, 0xad9a4184, 0xf920af6d,
- 0xe66f563e, 0x58da62ef, 0xfc70bca0, 0xbe701333, 0x0bb27510, 0xfde87b93,
- 0x9b6d39bd, 0xcc5ca22f, 0x3d1470cc, 0x193df805, 0xf27ffbc6, 0x16bfc175,
- 0x3fcba9da, 0x0ad3f246, 0xd6fd81e4, 0xda3964d9, 0x5acff6a1, 0xc121ae51,
- 0x7ea7cacc, 0x32f89413, 0xc3ed15d0, 0x9fa4a55d, 0x9f7ee558, 0xddb8942d,
- 0x2e7ca0fc, 0xe2d6f98d, 0xd1befaf9, 0xf495f28c, 0xcaabfb1b, 0x5e283104,
- 0xe61a3750, 0x4fada579, 0x5be9de75, 0xe901bf6c, 0x187db82c, 0x395e2abe,
- 0x8a2d7b4d, 0xcc1d77ee, 0xfee8deb0, 0x3ea8d694, 0x8733a4b7, 0x53bbdd07,
- 0xf6d99fcb, 0x777ba0a4, 0xeef74119, 0xddee82f2, 0x2df9efa9, 0xba094e74,
- 0xe7bea777, 0x54cdb067, 0xe6930fd5, 0x9c88e0a9, 0x23f555bb, 0xe7d5cbed,
- 0xbcff8eae, 0x77c74842, 0x2e7d7d06, 0xe0668798, 0xc198e28d, 0x0a2f247d,
- 0x3e1a432a, 0x6984cc2e, 0x0ba1a173, 0x9139a4e9, 0xe386e7db, 0xa0badb0f,
- 0x9788e31d, 0xfc6fe88c, 0x452fe089, 0x9f28c4fb, 0x18fd1953, 0xaf33ed53,
- 0x52be7015, 0x5cf2dbd2, 0x7d61f3b3, 0x494af7f2, 0xdee01dfc, 0x463eb8d1,
- 0xf9036c7c, 0xaf7e55e6, 0x476cac78, 0x5f3ced28, 0x0f353258, 0xcc7fcfbe,
- 0xece28331, 0xf07efc1d, 0xa78f3d4e, 0xe7e55ef8, 0xfa3bf35b, 0xfe008e34,
- 0xf5c7993e, 0xa59c6790, 0xeba91f14, 0xf9165d84, 0x1eaceda9, 0x75d465ef,
- 0x7ee14776, 0xab3ce056, 0x60c9bf47, 0x89cfbcbe, 0xaf68e1fd, 0x743dacff,
- 0x9e6d6d3c, 0x98e3f89e, 0x1eabd72c, 0x91bb72d6, 0xb9e16639, 0x575e4571,
- 0xabe3e7ed, 0xe7e7a85a, 0x1d1a3160, 0x9c836e42, 0xc396ab3e, 0x707ef50e,
- 0xca3d7f8b, 0xaadf900e, 0x4c174b7a, 0x12b7bb27, 0x31f236e4, 0x797573c8,
- 0x17c91372, 0x7caae790, 0x3c80de77, 0xdf0ebfcf, 0x426a769d, 0x8170f38e,
- 0xda78f348, 0xffe69535, 0xf4479819, 0x64333da7, 0xde7cf8de, 0xc65ebe6c,
- 0xb7580fb5, 0x2ebf7ae0, 0xf2f6ebe0, 0x7dfaf230, 0x0a775d79, 0x4c2845bd,
- 0xa270cedd, 0x634625db, 0x387b9e09, 0x1365f296, 0x7eaae1c6, 0xfd3dd02e,
- 0x6e3eeb7f, 0xbf5ffd41, 0xfd05a8ff, 0xa3f6ee61, 0x594db016, 0x8b5a4ead,
- 0x85d03c7a, 0xba9ef51d, 0x7fc22e8e, 0x6eb8fb65, 0x21d95fcc, 0xee3dfbd0,
- 0xd3a71703, 0x135f5938, 0x0e770bc6, 0xf28fd783, 0x37befeb8, 0x307ee24f,
- 0xfb89f417, 0xdf8301fd, 0x801d202f, 0x5ebc425c, 0x35e5f017, 0xb1a373b6,
- 0xf51e9422, 0x1f7cf26f, 0xe867a8d9, 0xef85afaf, 0x52c71c71, 0x488de98e,
- 0xb205fb47, 0x27edddb5, 0xfb604617, 0xfa863af5, 0x17df8285, 0xe21fbd29,
- 0xd6a83ff8, 0x3580a7a1, 0xbe696b56, 0x52d7a83f, 0x74fbda3b, 0xc15e2f04,
- 0xae1c55cf, 0x0929a8fe, 0x56a0fdda, 0x530c7ba0, 0x31f3fbef, 0xe0af1784,
- 0x3d305afa, 0x4c1af42b, 0x3bf4c19f, 0xbe6b4e84, 0xc91e9d19, 0xe4d5ef93,
- 0xe7dc02b1, 0x59a7dd61, 0xe11e7e91, 0xae2be3f7, 0x7fa1d61d, 0x6cc9bd33,
- 0x31e0027f, 0x0b7aff5a, 0xbcc389ca, 0x8776b0bc, 0x748de5c0, 0x5261f237,
- 0xbda19eb3, 0x971e7efb, 0x7ae3ef4b, 0xfad0e3c5, 0x31af8c05, 0xe51d37b1,
- 0x4f1c9a52, 0x2ac7457a, 0x905c53f6, 0xaf319bcb, 0x96ef54d9, 0xbd71e537,
- 0x40839143, 0xe4fdaee6, 0xc44f6d97, 0xcb2f147b, 0xe55341e7, 0xfa32b2f6,
- 0xf485cfa7, 0x672f4caa, 0xf8143c64, 0x6cff4cb2, 0x1f68cfdb, 0x59c72d9f,
- 0xd1743666, 0x833ccc79, 0x879453eb, 0xabdf52b3, 0x39ae7dc5, 0x3a7cedfd,
- 0x25378d67, 0xc9fbe226, 0xd27877fc, 0x60d6dba7, 0x9c372fdc, 0xe0ec31d6,
- 0x381e7453, 0x35bc6b2c, 0x49439c54, 0x7a2557dd, 0x6aeeb08f, 0x3c0aa53a,
- 0x7d39d0f7, 0x1701d91f, 0x5c9f13a7, 0x2ddea9b5, 0x7bc654fc, 0x5d3ef28c,
- 0x80f3f727, 0x8b8b169c, 0xf329eb06, 0x1c659e80, 0x2ed6586f, 0xab35af5a,
- 0x75a92158, 0xcefe29ec, 0x0149ed66, 0xa458bddf, 0x304ce873, 0x608defdf,
- 0xfc8b1f25, 0x3657241d, 0x748c4dc6, 0xd784fb2f, 0xd7af704c, 0xaf29f046,
- 0x61ade944, 0x687c88ce, 0x4f11e167, 0xe1dbce16, 0xde275694, 0x8ef0bc57,
- 0x336ba64e, 0xd32e2fbf, 0x2d4ee5da, 0xeb9c6233, 0xc2e3e800, 0x5cf7fe20,
- 0xddfba44d, 0xa0fec3bf, 0xbf0d959f, 0xaf677921, 0xed1d38b9, 0x33dac2a2,
- 0x1bbb084d, 0xf51d3cfe, 0xff610f89, 0xf41ebd20, 0x72809b7b, 0xd3bd24e4,
- 0x8635795d, 0xd35979da, 0xcbf91d3f, 0xf740a6f7, 0xb8ec3e6f, 0xfdf2b7a8,
- 0x7873dc89, 0xf2fd1c2f, 0xb9a3f2b3, 0xd42ce91c, 0x243afad0, 0xddeb3bd5,
- 0x0a2bffa3, 0x20d8c3d7, 0x7e0a7afd, 0xc865a3df, 0xfb4a9bbf, 0xe421cca3,
- 0xdff469ef, 0xb071f365, 0x15e5a1ec, 0x9e165f7a, 0xe990ac93, 0x3cbcb838,
- 0xa13fc07f, 0xebefca73, 0xa1fe0108, 0x3fdfc62a, 0x2ba7bb05, 0xaab8f81c,
- 0x67f92a73, 0x0dc23caa, 0xd1c333fd, 0xeb4dd7e1, 0x28cff718, 0x818dda30,
- 0x1bb44d7e, 0x1f7faa99, 0x252b077f, 0x74f786f3, 0x14897ddc, 0x666bafcf,
- 0x795aef14, 0xe7a53475, 0x2120df5f, 0xfbc318ff, 0x6b7ee95b, 0x8cec86b6,
- 0xfeb53e95, 0xcb80a533, 0x7c052985, 0x60f95cde, 0x01b0e52f, 0xa2ec097b,
- 0x5db9f37b, 0xa9887514, 0x7ce0a5ec, 0xf28c97b2, 0x13101d3d, 0xe04257ae,
- 0x6941477d, 0xca977e0d, 0xd9ce885a, 0x72fefc3b, 0xe4d738f0, 0xf8553e73,
- 0x35f2317a, 0xe7076fd2, 0xe776e0eb, 0x41ac9415, 0x4c38da3e, 0xe65cab7c,
- 0x8c6d95fb, 0x16ddcbe6, 0x05f4f343, 0x0296736b, 0x78017e5d, 0x0bd23de0,
- 0x3444674e, 0xe5c17f7c, 0x3df3c08c, 0x6ba81c8a, 0x36efa70b, 0xc58bce66,
- 0x48cda373, 0xf9ded0f7, 0x9c46a98e, 0x38da7be7, 0x7dfd29ff, 0x1638b5d8,
- 0xae8269f9, 0xf2876f5f, 0x5133cee4, 0x784df7a8, 0xf22c7e7d, 0xfe7870e1,
- 0xcf1918fd, 0x1e12c486, 0x70bd8797, 0x004f6ca2, 0xba27ee7e, 0x87fa9de8,
- 0x6fd1181a, 0x56ffabf7, 0xbe7c7c87, 0xfb8cc233, 0x230717e6, 0x0bcabde8,
- 0x3de81a6f, 0x7df95a9a, 0x7d742fd5, 0x7cbf4873, 0x22f74b5d, 0x47fe6fdd,
- 0xfba3f22b, 0x3b9d0355, 0xc373a87c, 0x6af7dc45, 0xc39c673b, 0x5f6b5677,
- 0xc3f2dbfa, 0xd25486ca, 0x3ff8148b, 0xbe2746bc, 0xe45e7bf3, 0x8ea1e272,
- 0xf77d217f, 0x0b976ba1, 0x17ca7cf0, 0x44c7ff07, 0xb7ee6b94, 0x79444f2e,
- 0xe5c5fee6, 0x7eee5889, 0x4a13c22d, 0xc05eb95f, 0x7eca3efd, 0xa8aef699,
- 0x90ad0ff2, 0x5d6d23e9, 0x3d07bd0b, 0x7b02e4e1, 0x130fbbe0, 0xac4e34b2,
- 0x65b7e13f, 0x7c05f7b1, 0xa457aeb7, 0x93f8e338, 0x01d51165, 0x814f7974,
- 0x7e2ff14e, 0x930ebf23, 0xf019c7df, 0x77f2f4e3, 0x8af6367f, 0x1aa37dfc,
- 0x83a1ee81, 0x5ee432fe, 0x8affad1a, 0x88df7a58, 0xc73bce89, 0x8b38478c,
- 0x3e6205de, 0x00ccd1e3, 0xaf71693d, 0x7400cba6, 0xe869d154, 0x57befd22,
- 0xacb0433c, 0xf173dd3f, 0x2134c8d3, 0xe7267f84, 0xe39434d4, 0xf81a7ec1,
- 0x8ade2245, 0x71e955be, 0xc1fe20a5, 0x15a59bfe, 0x287f9077, 0xd6937fd8,
- 0x8f666a2b, 0xe9dff7c7, 0xf78c2f3a, 0x8bf22369, 0xfae287a2, 0xffc1081d,
- 0x3970c66b, 0xbad5f0a6, 0x5dff1e5e, 0xcc6a5bd7, 0xe656b484, 0x9db003ab,
- 0x75fda0fa, 0xa377f39d, 0xb5dd611f, 0x60631145, 0x3bbdd6be, 0xfc813d8f,
- 0x66352e6f, 0xeed777e1, 0x1fcc2e30, 0xfee097a4, 0xf2e18ca6, 0x184f4072,
- 0x97cbdf66, 0xed5bfaf1, 0xe463397f, 0x87ff6cf3, 0x87607fef, 0xedc31d8f,
- 0x4fdc25f0, 0xe0f0edc2, 0xc791437d, 0x792ebb4a, 0x63ca879d, 0xc04877fe,
- 0xec79265e, 0xbd51231a, 0xb1b9cee4, 0xbbbf4764, 0x0d325620, 0xb4433f6d,
- 0x87f2626b, 0x71e8afb6, 0xa8e39f6e, 0x871ced11, 0x1749fb96, 0x99bef408,
- 0x9db9f7a2, 0xeee3e902, 0xeb1f9d4a, 0x2ef57829, 0x85d57ee0, 0x4c3f9d0e,
- 0x150fd418, 0xdca071fd, 0xa2b9502e, 0x637a2a4f, 0x71fb93af, 0xe5e78c17,
- 0x16b986b7, 0xd87d7ce1, 0x13f94615, 0xc67cf126, 0x0093479c, 0x813df45e,
- 0xfacbff11, 0xc1a742a4, 0xcea5e6fa, 0xd7be1b8c, 0x4fa64db3, 0x8352cf85,
- 0xbfd943f8, 0xdd39f39a, 0x1dfee1d7, 0x7ff7fb8b, 0xe0f2f4aa, 0x7eff6176,
- 0x466ff108, 0x1fbe121d, 0x19d15bff, 0x4aff3eca, 0x5efe0bd6, 0x23debf59,
- 0x72af8825, 0x7db8764e, 0x6fd64eb5, 0xce6f2b86, 0xbcfc7aff, 0xdfdf1e47,
- 0x8e779f8a, 0x9f43bff9, 0xf50bd01d, 0x4779c7a1, 0xc64fc941, 0x6b86bcc0,
- 0x739e743d, 0x1ecdf7b8, 0xb055f595, 0x7c745573, 0x41af4534, 0xc35dc8bb,
- 0xd1cd03fd, 0x7ec9afd2, 0xf7a5ae39, 0xef921e57, 0xd5783e73, 0xea2d694c,
- 0xd92e90c9, 0xd9de927b, 0xc6a3525d, 0xb77d19bf, 0x34aafdf8, 0xb157eb8a,
- 0x552bf232, 0xf19b4675, 0x7c737fbc, 0x2be431fb, 0xb4ad6edf, 0xc6feb03b,
- 0x237d72d1, 0x44d5b7f7, 0x618fdfd3, 0x95407a41, 0x57df5827, 0x645305eb,
- 0xfa70d13f, 0xc3ba2fc1, 0xd1e95cb8, 0x39d79f12, 0xd055dff9, 0xe0b97277,
- 0xbf23086e, 0x886bda09, 0x820d67d7, 0x5f3ddf1f, 0x4cfbd729, 0x13ff25ec,
- 0xcaa0d3c5, 0x2ca7ceb9, 0xd4dfb20e, 0xbb95a3f1, 0x33724b7e, 0x73148e38,
- 0x0d0b8e40, 0xd2268dc4, 0x60959079, 0xbc9fe24f, 0x5dd24b72, 0x1f80ff38,
- 0x71dc93f3, 0x9730fca8, 0xfb223e7a, 0x3cebc973, 0x7e2433fe, 0xc7933cd4,
- 0x95ddf08f, 0xa5c87e10, 0xc51d8f23, 0xb374a3bf, 0xc75d51b8, 0x3247ba49,
- 0xd208ff44, 0x518dae3b, 0x8a4719fb, 0xb23b8fdc, 0x7fa33053, 0x8f3ca46a,
- 0x9c31b77f, 0x7fe9eaf4, 0x79458ea8, 0xf9d3aca0, 0xcf5e7cb9, 0x04a5707f,
- 0x07f89bbf, 0xe3061cd1, 0xf507c5fa, 0xb0e249bf, 0xbbf09464, 0x63b408fa,
- 0x7561ffce, 0x2febce04, 0x2fbfc520, 0x3169daf1, 0x2bd23fa4, 0x0fd82dcb,
- 0xbfc80ba3, 0x45a5fb2c, 0x07230fd8, 0xdfc139fd, 0x6bbf976d, 0xfc853306,
- 0xf8f3af98, 0x6b82737e, 0xa6cfc126, 0xa61efe33, 0xffcefc83, 0xfe8d7402,
- 0x2c183ca2, 0x1a7f9fc6, 0xbc61d6ce, 0xf5de39a8, 0xb3d1f136, 0x08f9091a,
- 0x9338a7be, 0xfb44bf6f, 0xc6194e23, 0xfcf40a73, 0x0cea465d, 0xbcb46bd6,
- 0xc760098e, 0xb0093c62, 0xe6f18059, 0x53ae393c, 0x6c44ce10, 0x6b9d49ff,
- 0xf997be13, 0x5f68b764, 0x8f604c4b, 0x83bf77c5, 0x83824be3, 0x3895c5c7,
- 0x1f1f1293, 0x6024ce2e, 0xee9c053f, 0x8715b9f8, 0x25737180, 0xe7bec49e,
- 0x635720a4, 0xf7ce87b1, 0x48c8533f, 0x718b7fae, 0x21f9259e, 0xc83548e2,
- 0xd5cf2463, 0x394dc571, 0xfe9d10af, 0x3dc4f1b5, 0x1cb7d863, 0x13f3e2ff,
- 0xe8f8f78c, 0xb7b2164b, 0x51effabe, 0x5e76cfb4, 0x42f0fda6, 0x8fbe41bf,
- 0xecfdc7d0, 0x2ff23a9d, 0x2dbb005c, 0x3d9f603e, 0x3ddbcf9a, 0xe89539d4,
- 0x596f40ff, 0x2f3fd604, 0x777c6fe7, 0x48d9fcc1, 0xbd22bd97, 0xe3e78b07,
- 0xd03b0ed0, 0xbd404e2b, 0x975c5be5, 0xb1098fef, 0xd0f0c62e, 0xcbe44cef,
- 0xc05f947c, 0x07ea63e9, 0xd772fedc, 0x598a38f3, 0x72ee0b96, 0x63c1c93d,
- 0xf1411629, 0xc5435b9f, 0xa7ef5e59, 0x856aa37d, 0xbe1cf740, 0xa3a59c71,
- 0x82b7de5b, 0xd3e5d3fc, 0xe70e6e49, 0x9b880eb7, 0x15b7caab, 0x23879c0c,
- 0x815475ff, 0xe31dc699, 0xb3c12c29, 0xbff8ca87, 0x73b875c5, 0xfb3a086c,
- 0x695fdb16, 0x9fdb6eff, 0xb6ddf792, 0x6e3be6bf, 0x77de6d7f, 0xf1dee71b,
- 0xf57fe31d, 0xccff6e3b, 0xaf3f3c77, 0x73ffffe5, 0x70700300, 0x5cf83f9c,
- 0xdfbc7040, 0x1f3efc70, 0x36106d96, 0x6a4177f7, 0x42b57a8c, 0x462d5100,
- 0x0877a2ef, 0x71e24d66, 0x46658db0, 0xf0610eff, 0x5f32807c, 0x1db90b4b,
- 0xe8bfce61, 0x4e79858b, 0xc596f475, 0x126c9fa2, 0x82fd877f, 0x132acefc,
- 0x18cef4cd, 0xfbc04cd4, 0xa161cdf1, 0x7261aae3, 0x23edc37b, 0xdc9617cf,
- 0xfe9e3631, 0xfbc8436c, 0xfec82f1d, 0x23077347, 0xa51324bf, 0xafd47984,
- 0xd0fa8094, 0x3f3c2388, 0x76398baa, 0xda525e10, 0xa507b23c, 0x8b6fc434,
- 0x998def1c, 0xfe869d99, 0x0bd018e8, 0x14f81e31, 0x8e2905c6, 0x4a7aa665,
- 0xe58c1f7f, 0x31d16dfd, 0xe55bee81, 0xac4cf3f2, 0x9e2aa0f9, 0xebae8ef7,
- 0xc50265e3, 0xfe2396f3, 0xe574d2bf, 0x89934cef, 0xff37e618, 0x8ce29980,
- 0x48bd2627, 0x8956777f, 0xf331adef, 0x6ed1872a, 0x1cd63c06, 0xbbf4471c,
- 0xf7a4d0e4, 0x7733e9f1, 0x750f68a6, 0x17f1514f, 0x1dfd969c, 0x8940bf8a,
- 0xf65efd6b, 0xfe887c93, 0x221fba17, 0xab1dea51, 0x27f7b6f9, 0xfc10d8ef,
- 0xfee045bf, 0xb8afdf21, 0xde9c687f, 0x6e78119e, 0xaf3cb372, 0xdc78bacb,
- 0xecf7f142, 0xee33c793, 0x01976d11, 0x4d71d2f6, 0xcfb8f463, 0x094a6b8f,
- 0xe1c0b4c7, 0xf07de0d7, 0x35fbd5c5, 0xa285faca, 0xb2b1d6a3, 0x9fa7a31f,
- 0x12ff7ae2, 0x60ffe714, 0x30bf3f2c, 0xf1e390af, 0x0824d801, 0x1b12c9af,
- 0x711c7d51, 0x2a1b598b, 0x7605549e, 0xacb9e231, 0xccade399, 0x34975577,
- 0x7339fb15, 0xd309bfb4, 0xa9b49aa2, 0xbdaf6fe4, 0x9bfa84d8, 0x63e5dafb,
- 0x4cbf93b7, 0x713da12f, 0xefda9f4f, 0xa5a30ab6, 0xfd2784f1, 0x0cdf5a9d,
- 0x71e3ec91, 0x9fa24433, 0xb230aa98, 0x4c74635f, 0x2e78426b, 0xca8a8bd7,
- 0xcc22a6e3, 0x3e934416, 0x4523d458, 0xe83f97df, 0x51998b07, 0x74f38f1f,
- 0xe2aaf8b3, 0xcc35bb4f, 0xe7ae1af1, 0x5d5f1b5f, 0x74bbcef9, 0x971954ae,
- 0x9c4a2f32, 0xaaf8b874, 0x5dc1ce72, 0x2e75457e, 0x4ff62dc3, 0xb8e3ff47,
- 0xf2f46783, 0xfe334b39, 0xfe25611d, 0x8bf5ee3a, 0xe2557714, 0x45cf6eac,
- 0x3be1abd2, 0x0e3f7e3d, 0x06213f96, 0xf1e217df, 0x9ef157d7, 0xffef1e94,
- 0xd4bee999, 0xc5fdf21b, 0xe63f184e, 0xa1cde9bf, 0xa76bcbb4, 0x98b790f4,
- 0x45e77752, 0x387ed78a, 0x53ef1d56, 0xb49779e2, 0xd56333ce, 0x0e0923e7,
- 0xc369f78e, 0xddc6bfb9, 0x97bfa3a3, 0x48c77ee1, 0x73a4bbf2, 0xfaebdd19,
- 0x246ba4f2, 0xf1875de2, 0x38ba00b6, 0xe187b0ef, 0x9de7613b, 0xb38c30f6,
- 0xa73eeb8d, 0x752ff3c7, 0xfd1eaf62, 0x12718061, 0x1f744d1e, 0xf7cfc8b8,
- 0xdfd09676, 0x5c69bae3, 0x136fe3ac, 0xe59ffb17, 0x00210141, 0x00002101,
- 0x00088b1f, 0x00000000, 0x17b5ff00, 0x67534c5d, 0xb7b77cf4, 0x0bdf96e5,
- 0x72223f2a, 0xa29862c1, 0xa740c2dc, 0xac741631, 0x4a8a5c13, 0x66b50102,
- 0x2d09922e, 0xcbc2ccd9, 0x01893ad2, 0xb8b2c3dd, 0x26a9f364, 0x87b6e883,
- 0x6ead93fa, 0x840b0b55, 0xc3e22e25, 0x52c9719c, 0xba33330d, 0xd8dc6281,
- 0xdf39d85c, 0xd8bdb5bd, 0xa4da2cbd, 0xdf3f3d39, 0xfff9df39, 0x0730000a,
- 0xb956e7da, 0xf84ce706, 0xffc6cfa5, 0x4fa43d0f, 0xbddde38c, 0x1726eb4b,
- 0x3ebbf1c4, 0x036935c9, 0xce9c5df8, 0xf6002b94, 0x1c5ace87, 0xaccf1f04,
- 0xedfc2176, 0x4ab5dfc2, 0xd2f7803a, 0xee202d4c, 0x96a666fd, 0xd2afdef8,
- 0x4fe9027a, 0x8ed77bdb, 0x70045e97, 0x106b4196, 0xc12e55f9, 0xb8e08271,
- 0x4546fac3, 0x25c06e5c, 0x80fce938, 0xe89b34ad, 0xd9a55cc7, 0xf5f4137b,
- 0x00674539, 0xdaaf39e9, 0x09f489ac, 0x06a019bb, 0xc15c0ce9, 0x556bf624,
- 0x7fdfdb81, 0x4a4f2ad2, 0xdbf11c7a, 0xe036cc1d, 0x3c8150de, 0xf7c71e59,
- 0xfc028fd3, 0xd422666e, 0xb9e97402, 0xd77264b8, 0x3bafa8aa, 0x52816a3f,
- 0x5c5b4ca2, 0xdf5e30ab, 0x12acfd4b, 0xbefcf860, 0x170568e2, 0xa0172095,
- 0xe0373f4d, 0xb19c5bdc, 0x3d7fc010, 0x4698ca05, 0x4adf9113, 0x2a8e143f,
- 0xa769da22, 0xb6e5785f, 0x4c27f7fc, 0xcdba11ab, 0xbdc268fe, 0xc3829dda,
- 0x2eedc99a, 0x7920ce6d, 0x212fce31, 0xb74bd3a5, 0x51cc22ad, 0xf413e428,
- 0x025ac217, 0x36ada8d2, 0x0406ef6e, 0x7ca1b07e, 0xa488539b, 0x70d69da0,
- 0x6f50044a, 0xdf045395, 0xcd7b088b, 0x7c461281, 0x2be726f1, 0xbf11366f,
- 0x042aae4f, 0xcbe7e3f4, 0x09417916, 0x3464dfbf, 0xf3aa8e21, 0x3c52fed3,
- 0x953176af, 0x34ef6adc, 0x4193f1f2, 0xe3d6ee7e, 0xfc3433b2, 0x5ff72172,
- 0xcb9e0136, 0x8e38031d, 0x18f67776, 0x756eedcf, 0x3f7461de, 0x337fa0f8,
- 0x904d81ca, 0x6bde8907, 0x3b3aa394, 0x001ff18d, 0x43d62670, 0x0d41d537,
- 0xe7e1c641, 0x45d513e8, 0x582a0615, 0xbf373f11, 0xf974467e, 0xf062faf9,
- 0x5117f10c, 0xd80d567d, 0x024dbf28, 0xf5e10194, 0x9f412d92, 0x9eb9155f,
- 0xfc01650f, 0xde17d728, 0x7e30c83e, 0x915f8f7d, 0x4a6e505a, 0xd2ca97ae,
- 0x32f7b8e3, 0x401653d6, 0x036cf0f5, 0x9858fbc5, 0x794d1581, 0x28bef1f3,
- 0x6eb17d57, 0xbc4ead9c, 0x31dfe6a7, 0x3a44f9cc, 0x0d9a81d5, 0x61205f9a,
- 0x5817fcbc, 0x55ed1060, 0x491c3d35, 0xb2b9f8a3, 0xec8532d5, 0x23a50ed8,
- 0x6b126dee, 0x3c2ee118, 0x160ef840, 0xf6e7f090, 0x005b9d2b, 0xd8b754ed,
- 0x5bdc52af, 0x15aacc3a, 0x40dade88, 0x50596bf4, 0xff122937, 0xc4a97bc4,
- 0x55aa672f, 0x9eb3be21, 0x445f8df8, 0xade7aa44, 0x7865a514, 0x8d28cbb7,
- 0xeac1b37d, 0x551f500e, 0xf411a337, 0x3587476f, 0x84b5fe40, 0xce90cd9b,
- 0xbea041eb, 0xedcf5b7b, 0x328f45b7, 0x099f48a3, 0x5f916757, 0x16d3cc0b,
- 0xea356115, 0x7841c82e, 0xb005bee1, 0xb4e2bc1f, 0x73b94645, 0x05ac4c3e,
- 0xc49f4be0, 0x8327c861, 0xd7c03963, 0xc30e7cbe, 0x2fd3853e, 0x8c39cafa,
- 0x470e54f8, 0xa8356b7c, 0x959e3cca, 0xdd02fbe1, 0x7059a727, 0x7e6f9b25,
- 0xf9623ebd, 0x29ef0baa, 0xba3e7ba6, 0x93962eea, 0x5a20c7c8, 0x6ad6142c,
- 0x6730c9fd, 0x06c3e75e, 0xe881e3b2, 0x60a73a61, 0x460d61be, 0xef308421,
- 0xaa6febbf, 0xd96f9b52, 0xf193b802, 0x04faf467, 0x3cd02287, 0xfad24b7a,
- 0x5fc5787f, 0x48529e3c, 0xf31eb2b9, 0x413719e6, 0xd48fd20a, 0xbe7f736b,
- 0x4f18eb9e, 0xc0ddb8c0, 0xcf9c1278, 0xcbf8b56f, 0x74ad1f28, 0xa7e7248f,
- 0x0ac4faf4, 0xb432bb30, 0x4fbc329c, 0x600e6c47, 0x8f30b220, 0x4916211d,
- 0x19df3ec5, 0x244774de, 0x96e0c3d8, 0xd73c7e71, 0x46e6d87d, 0xb6f389a5,
- 0xf9268d33, 0xd54a5c13, 0x34592ce2, 0xf6d56fd8, 0x8b5d935a, 0xb56e0c73,
- 0x9471756b, 0xfbeb059a, 0x381679e8, 0xa9e7fd88, 0x734ebb18, 0xd001cf2c,
- 0x93c7c38b, 0xd1311e9f, 0xef990f3c, 0xd8e3993d, 0x0c8a791f, 0x3794391d,
- 0x41f6260c, 0x24077e81, 0x63946dc0, 0x6e611c91, 0x192dca25, 0x9f7d259f,
- 0x2f6e15d8, 0x01905777, 0xfe0450ba, 0x465f3483, 0x1a77502d, 0x639d77ed,
- 0x3bfa9070, 0xf70502e0, 0x1bf1e8fd, 0xdd214f87, 0xb4c98e73, 0x5783ba8e,
- 0x16ef9ef9, 0x78ff7827, 0xbc2d77c2, 0x3537831e, 0x0239887a, 0x403af249,
- 0x6eed1dfb, 0x6e687f46, 0x05301f74, 0xc36ed052, 0xbdafad39, 0x41404b0e,
- 0x1de8ac7c, 0xe79df091, 0x1cd1e419, 0xa5162653, 0x1980ff11, 0xafdc2502,
- 0xfd84baa6, 0xfc855f84, 0xd8cfed8e, 0xf4c0f1fe, 0x6bd52158, 0x0a235327,
- 0x8cb73fdf, 0x922f05fb, 0xed2fdf1b, 0xcd3361a1, 0x0643dc1b, 0x868eddb9,
- 0x713f343b, 0x4be918cf, 0xf9e7df0e, 0x53af2880, 0x7e062fdc, 0xe1633d8d,
- 0x58092c6d, 0x38731509, 0xca5536cf, 0x6eaddf3c, 0x1f18dcc6, 0x91757049,
- 0xc991709f, 0xc7e76f34, 0xf5aed1ab, 0x419fa341, 0xc877e62f, 0xd0c7d5a2,
- 0xa3f0163a, 0x94a2237c, 0x7b8ba1f7, 0x1cfd0cfc, 0x40aa62aa, 0x8c2120f1,
- 0x3e3d16c7, 0x6e1f802f, 0x70a9fc4b, 0xe01aae6c, 0x2b61ac35, 0x5ea353d6,
- 0x6e01000f, 0xd4e3f9a7, 0x8e23bd08, 0x2af9839a, 0xf9f8977f, 0xe055677d,
- 0xe814d4fc, 0x6bafd649, 0x6ab375ec, 0xf33dc90d, 0x7b2ed3f7, 0x47d3f792,
- 0x3b2276f8, 0x244ced7b, 0x2bbe30bf, 0x15efbfa9, 0x411ccb5d, 0xb5c981f4,
- 0x5975ce8f, 0xbea9ab22, 0x1cdc981f, 0xee91f18f, 0x8b82fda1, 0x91f516ef,
- 0x87cf8c00, 0xcc67e523, 0xa2769794, 0x125beec7, 0xe9b8e397, 0x0aa1fc69,
- 0xa1efdacf, 0xfda79aca, 0x17fa867e, 0x7f57cfab, 0x1dbcb26e, 0xa497f9a2,
- 0xe7d27e7e, 0x9912c01f, 0x3893cbf7, 0x6487b683, 0xaa3c75e0, 0xa67ef5ef,
- 0xc87b48fc, 0x06199dff, 0xed5cf895, 0x7ff4d0cf, 0xc18beba6, 0x9bf61d51,
- 0xf6f9b935, 0xfc39f427, 0x8a71c98b, 0xa4f2bdee, 0xdf824a00, 0xa0a982ab,
- 0x195df824, 0xf6e031ca, 0x7c8362c8, 0x81a978f5, 0xc2b1335f, 0xbd735fc0,
- 0x14bf80ca, 0x5f90675d, 0x01bd6bff, 0xc5bd30df, 0xcff1bf20, 0xd63c066d,
- 0xb95875bf, 0x4936e789, 0x0ae41baf, 0x157e8d3b, 0x2afd18f5, 0x15fa35ee,
- 0x37e25bd3, 0xdfacb7fa, 0xf64e5fe8, 0xde855c83, 0x91fcffa1, 0x2060fb49,
- 0x34f3c33c, 0x13029d35, 0xa8c44734, 0x66c21fb6, 0xf0a617be, 0x84a2e2ff,
- 0xd7a72c3c, 0x0919da3f, 0xb9d2b32f, 0x2b369d0f, 0x512edbbd, 0xfe3e600d,
- 0x2e76d705, 0x000ee017, 0x00000000
-};
-
-static const u32 csem_int_table_data_e1[] = {
- 0x00088b1f, 0x00000000, 0xe3e3ff00, 0x51f86066, 0xb8d3c10f, 0x72361818,
- 0x0143f821, 0x684333b7, 0x0606163e, 0xc77e2001, 0x9ef0c0c8, 0x38330491,
- 0x207eec10, 0x27880abb, 0x7dcf5071, 0xe52f1143, 0x5f5d9fa1, 0x153d76a0,
- 0x837f7818, 0x031083b0, 0x03309b83, 0x8408b483, 0x55045fbf, 0xc10851de,
- 0x99412e7e, 0xfa819f5d, 0xbbeb8d01, 0x00038031, 0x00000000
-};
-
-static const u32 csem_pram_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x7de5ff00, 0xd5547c0b, 0x733ef7b5, 0x9993331e,
- 0x420f264c, 0x084f0042, 0x21842a20, 0x38880840, 0x8d069009, 0x8808089a,
- 0x420100ca, 0xa9113248, 0x676d5e97, 0x6ad11422, 0xa36d2d1b, 0x4101da97,
- 0x180d45a3, 0x1d0340e8, 0x5abc414c, 0x5b4a0a8d, 0x3c3141b5, 0xe878490a,
- 0xef5bd6c5, 0x33ef6b5e, 0x42667399, 0xfddfb6a2, 0x7f17dfbe, 0xecfb36fe,
- 0x7b5ef673, 0x7b5affad, 0x231fb5ed, 0xd313c659, 0x057c8415, 0x7213d77f,
- 0xf4842448, 0x0b3b4eeb, 0x108e3a68, 0xb0398e7f, 0xb4242055, 0x24edefef,
- 0x4db39085, 0x267355b3, 0x98c7fb21, 0xf2d3d743, 0x80fc81b3, 0xdd4f9699,
- 0xd121c479, 0x514ed57c, 0x3ed37282, 0xb1df7e2b, 0xde400851, 0xf1fd6e6b,
- 0xb5df34b5, 0x699b2453, 0x376424d5, 0xda425491, 0xa9fd842d, 0x6a5f98f1,
- 0x4daad965, 0xf682effb, 0x626683ca, 0x37b7dfa5, 0xafc86e89, 0x08042adc,
- 0xf76aaf6d, 0x5a00ca83, 0xd080b2df, 0x7e695568, 0x1a8a63eb, 0xfb03c84f,
- 0xb368ecfe, 0x67da7213, 0xfd82aa21, 0x491c6f28, 0x7b604548, 0x7dfa00e1,
- 0x65c136c5, 0x6c57f5a2, 0xf401d73c, 0xc3c93455, 0x8adf5a44, 0x47511b06,
- 0x22bfb6b0, 0x07cb5ed0, 0x794eded8, 0xfe57b428, 0x110a3de5, 0x1bb29fa1,
- 0x74a2abbe, 0x76b5bf40, 0xb1eafb4f, 0x559f8d3d, 0xe8f6d1cf, 0x0a2fd57b,
- 0xb562e82e, 0x8e807889, 0xb9d6dd8e, 0x7fa1db4f, 0xf8f0cab5, 0xdc2c7ec8,
- 0x08a8fd05, 0xed0a526c, 0x6526df40, 0xfaeec8e9, 0x87fc3456, 0xacfabe9e,
- 0x72889efe, 0x47da7a63, 0x3bbc3a59, 0xbb88415f, 0xa44bd691, 0xaa3a5280,
- 0x4207f9fb, 0xa1e32122, 0x96a8917e, 0xe4a9faee, 0x23fe0711, 0x0f949ff4,
- 0x81f1bdfe, 0x72dd99ad, 0x9904e95b, 0xbcedcb75, 0xea51cb93, 0x5fac8dca,
- 0xf20c7f4b, 0xf9d4f4a0, 0xee3e989c, 0x8374c34b, 0xfdbe454f, 0xd30237dc,
- 0x9f0b9f7a, 0xc3cbe93f, 0x8dcfa374, 0x22be53e9, 0x12be034c, 0x6fb36f7c,
- 0x7c5ba62e, 0x8cfe7c1e, 0x06d31caf, 0x7f3e0d5f, 0xd31ab7de, 0x3e3f3e6d,
- 0x1eb7d17f, 0x1d5f46d3, 0x5e403ba6, 0x05f26d34, 0xbe5dbdf0, 0xbe834c06,
- 0xc7be7c46, 0x11f4c417, 0x64c747ce, 0x3e512f92, 0x49c4dc38, 0x8a924ec5,
- 0xcd32f9dd, 0x7cb09527, 0x7cfe1dea, 0x3d53e685, 0x32f94f34, 0x6f9432a0,
- 0x3501f9a6, 0xfdf07cac, 0xf342c0a4, 0x7cacfd83, 0x02ee23c8, 0xa90fcd2b,
- 0x37c3e563, 0x68e20bfa, 0x9580787e, 0x542dbd5f, 0xabf9a360, 0x7679591b,
- 0xa76a9933, 0xcb10ecf9, 0x9ee1bce7, 0x39f34f1a, 0xfb9f2cad, 0x83aa7f81,
- 0xd8db73e6, 0x04ce93f7, 0x2d1ed544, 0xbab21d87, 0x6d595098, 0x4b70cff4,
- 0x515e6913, 0xca2e21ef, 0x6eadff1f, 0x43f29d29, 0xc8796376, 0x9bcb1f3f,
- 0xbf963714, 0xfcc32fe3, 0xe583d92e, 0x2c55fdc7, 0xfcb078af, 0x98bdff73,
- 0x2c7eca0f, 0x58fad4b7, 0xf963f15e, 0x58f5da80, 0x80391eff, 0x1f6b23e5,
- 0x4a3df2c3, 0x5f1fcb00, 0x1a7ba4fb, 0x3c11afcd, 0xd23c073f, 0x01649cb4,
- 0x4ad31a9e, 0x09d69e28, 0xf7e02e64, 0x8a3a0007, 0x0ae975cb, 0x3f8ee1ea,
- 0xfa0d3ee4, 0x90297f8b, 0xc3ccfa5f, 0xaffdf899, 0xd6991eb0, 0x4f5ef623,
- 0xba799bce, 0x2cde727a, 0x8069ead7, 0xfb58d6f7, 0x378ecf56, 0x79e9e927,
- 0x67ab42b3, 0xdf13d23b, 0xbce57eb7, 0xcf4f5935, 0x3d5a955b, 0xc49e907b,
- 0x74d3d1be, 0xa69fcf44, 0xb4fe6123, 0xfafd3d20, 0xf7b8cf46, 0xf719fcf4,
- 0x6f3f985e, 0x7de93d60, 0x3de9a7ab, 0xde9a7f3d, 0x08e7f30b, 0xdf506bf6,
- 0x7dee35fa, 0xbdc67f3d, 0x47cfe61f, 0xdf664f48, 0xa1f5d9ea, 0x3ebb3f9e,
- 0x04e7f30c, 0x6fac33d6, 0x48fdcafd, 0x8fdc9fcf, 0xc2e9fcc2, 0x5beaae7a,
- 0xd23ebb3d, 0x47d767f3, 0x817cfe61, 0x5bea8cf5, 0xa2ff72bf, 0x5fee4fe7,
- 0x0931fcc2, 0xbe98cf50, 0x54fc13d1, 0xa7e09fcf, 0xb0d8fe61, 0xa37df19e,
- 0xcf5daf27, 0x30f6bc9f, 0x9004527f, 0xd5bec4fb, 0xf3d76c13, 0xe61ed827,
- 0xe7ac20cf, 0x2bf5beba, 0x3f9e84ef, 0xfcc22779, 0xcafd8e19, 0xf40f7aa7,
- 0x7c4f5a10, 0x39ecf5cf, 0x9ecfe7ab, 0x8cfe61b3, 0xd3a67ac6, 0xaf7ab27a,
- 0x9e875267, 0xc23a933f, 0x7ac3c9fc, 0x9eadf466, 0xfe7a1d3d, 0xf308e9ec,
- 0x73f91f27, 0x35fadf53, 0x9fcf53a9, 0x3f8c9d49, 0x4cd70f63, 0x3a72d075,
- 0xfa44ba16, 0xdc67b5c9, 0x45e6816e, 0x4e8bcb27, 0x44bf0117, 0xd20dfcd4,
- 0xf7e916ea, 0x39896df6, 0xbf48930f, 0xfa14a0a3, 0xb1bd4f15, 0x2123bf48,
- 0xe7e74e2f, 0x7493ba24, 0x01a2e4f9, 0x95fbf7ba, 0xf795d10c, 0xaeb57b9f,
- 0xa393dd3c, 0x4f9467cb, 0xa83fbdd2, 0xbf9740a6, 0xba0df562, 0xb7fd33f7,
- 0xeb59f2ea, 0x3fbdd76f, 0xae916eac, 0x0afacafc, 0x8155f95d, 0x35fcba95,
- 0x7baeff0d, 0x03e3547f, 0xc1d1f2ba, 0x63e57587, 0xf2eb8f42, 0xa93d0f63,
- 0xeb7c7f7b, 0x84f95d66, 0xcaebcfa3, 0xd0edb627, 0xb93dafe5, 0xd9e7e0c7,
- 0xf0d7ed9d, 0x27b808bc, 0x574fefcc, 0xc50bdfd0, 0x0657982b, 0xdf8fd1d8,
- 0x3d54bf1f, 0xbcabe54e, 0xa14d58b2, 0x129905f2, 0x0fe7ae3a, 0x8db2bf28,
- 0x9277bf3e, 0x7d274ae7, 0x19e2af7e, 0x9fe18ced, 0x24083c52, 0x04d5520d,
- 0x41fcb1a9, 0x20b1e199, 0xc7e1cbe3, 0x535ef7e8, 0x9a44f0d7, 0xd7e62fef,
- 0x129e5e03, 0x38d3884c, 0x7bc0d491, 0xf3826671, 0x73330782, 0xe047f69f,
- 0xaa20fd75, 0xbd774287, 0x1a4f65eb, 0x6b9b19f8, 0x1f83f6df, 0xed106eb2,
- 0x9e4200d7, 0xf90ede16, 0x07efd287, 0xd0f34d2d, 0xf50accfa, 0x57db23d3,
- 0xb123fb68, 0xff6806fd, 0x37da1ec5, 0xb5d3c90f, 0xae5c196f, 0xd0a2df6b,
- 0x1fd49df6, 0x6f23fda8, 0x12610a9f, 0x7f0b2f21, 0x83cdf6c4, 0x07fdb1cb,
- 0x895f3a15, 0xdc2e3f6c, 0x77f4107e, 0x3e3fb41f, 0x4c87ff46, 0x707ff7d2,
- 0x0affbe85, 0xb52bffeb, 0x71fb78c7, 0xe116ffd8, 0xe0ffeb18, 0x337fd60a,
- 0xbedc37ab, 0x43ffcc23, 0x7b37ffd0, 0x64d67fea, 0xa8afff7d, 0xccdff7d4,
- 0xf6a77fda, 0x8edf6f14, 0x9c2bbfed, 0xa2bffd62, 0xcc57db12, 0x47e0171e,
- 0x09ab88c9, 0x40c9f6d0, 0x03fa986a, 0x903b685c, 0xa0a2488e, 0x6151e426,
- 0x6f71d208, 0xe7dbc31c, 0x686f1471, 0x9cf8fc6f, 0xcb65a804, 0x8e2ef3a5,
- 0xf2db15f5, 0x584bb015, 0x4b2be74e, 0x4165a938, 0x364df111, 0x28c30398,
- 0xd1411dbd, 0x0db2f90f, 0xfec005d7, 0x4164cd79, 0x91277c09, 0xf4ff3c10,
- 0x4736a367, 0x2e98cbf6, 0xdbdb93a9, 0x3c2df422, 0x23202a8f, 0xd37d286a,
- 0xbbe30401, 0x79d31ff3, 0x8bf3a110, 0x833ce80f, 0x227e4850, 0xa23ef6b3,
- 0xb7c825f3, 0x9412f9d1, 0xdf8b5213, 0xa70eead1, 0x384bfa51, 0x4c4b1ffd,
- 0x43be3f5f, 0x7ea9f808, 0x31bdfe7e, 0xb05d4f38, 0xde9946da, 0x7f42c74d,
- 0xfb4f2eb2, 0x753907e5, 0x360736ed, 0x155fc80b, 0xaa8a55f8, 0xf5e2c849,
- 0xddd79419, 0xc54fbfef, 0x7f594e9e, 0xfdcb711b, 0xae77fbe9, 0x69390612,
- 0xe6ddb3bb, 0xb84e361c, 0xd7a84c33, 0x4794c324, 0x634dadc8, 0x29035a64,
- 0xb71fcb75, 0xb33bb445, 0x5d9f9f48, 0xc877cfa2, 0xe944d96e, 0xc81528ea,
- 0x9cef5a26, 0xad72fab9, 0x8929bb1d, 0x57b799c9, 0x9be8ca92, 0x3c0e6903,
- 0xe79ca276, 0x1ab7d93a, 0x32c5de3d, 0x3c82c29d, 0xc808fdfd, 0xef829fd5,
- 0xfd64eedd, 0x573bd236, 0x684bb8b6, 0x142ee73f, 0x236f8003, 0x67da7ffd,
- 0x69b29b73, 0x32a7feba, 0xc7f74531, 0x8f3cff48, 0x328d3fb1, 0xcbf3c38c,
- 0x6e19cf8d, 0x3ffcb9da, 0xf4d07c06, 0xd283e004, 0xa3e39c7f, 0x7c32aedb,
- 0x9b9ecd78, 0x4f5d0f01, 0xcae50488, 0xc71b72f1, 0x3d3a92cb, 0xc8f1082e,
- 0x7365c720, 0x23879c85, 0xe3873070, 0x1ebd5960, 0xbf127737, 0x2e431e9c,
- 0xfa6c36f3, 0xdd1a9a61, 0x6e390fbf, 0x1fb23fe6, 0x4fdd13f9, 0xb8bba726,
- 0xd1acee9c, 0xe5c6df97, 0xeb97277a, 0x0ec7fadc, 0x6e41f350, 0xe8320357,
- 0x4d3ef7bb, 0x793a6d9e, 0x8d3cb87a, 0xe5c5de74, 0x98f7d779, 0xb6f48d3c,
- 0xd5b67971, 0x90c9905f, 0xf48d7a68, 0xd51d582d, 0xb9e4051f, 0x9e5b1fd0,
- 0xf27e60de, 0x55e788f1, 0x8f92338d, 0x8ad9e847, 0x7e5d5286, 0xee9e6079,
- 0x0bf565fd, 0xea4be575, 0x17caeb96, 0x975bbfaf, 0x9effe85f, 0xab05fdee,
- 0x77e5756b, 0x2ba43cd6, 0x98fe5f9f, 0xf3cf3f2e, 0x39fdee84, 0xcae93773,
- 0xa73c9767, 0xb4599f2b, 0x752f975d, 0x6fbdd6ef, 0x2dd577da, 0x8e37cf80,
- 0x89fc0488, 0x30275ccf, 0x4b99f82e, 0xc73bc176, 0xbae22a7d, 0xd30237dd,
- 0xe2173e93, 0x0f2fb4fe, 0x8b608ed3, 0x3a09c61d, 0x89252e2e, 0x6e9bccd4,
- 0x103f5dae, 0xe38269c6, 0xacd316e9, 0x4264ff5a, 0x91526d7e, 0x0af5c5df,
- 0x44258d09, 0xd386c180, 0x944625d1, 0x5e52f5b7, 0x727f0d4f, 0x5b717974,
- 0xc7dee7ec, 0x8ce15e17, 0xd6e97711, 0x7e019253, 0xbbf7274f, 0x0295e58d,
- 0x4e7c8929, 0xd7a803c8, 0x5bb8f8e7, 0xaffd30a9, 0x405e91dc, 0x0d0f901c,
- 0x7b5cb9af, 0xfde4148d, 0x3a592701, 0x7f565e3d, 0x13bece8d, 0x03f6ca88,
- 0x3dd58dbc, 0xad70d15f, 0xfb33bbee, 0x1abba445, 0x1844c56c, 0x375e4b16,
- 0xb50e1d81, 0x0a399e0c, 0x61bf74e8, 0xd82a7182, 0x33c2fd0f, 0xe3e4a2be,
- 0x04afc812, 0xb9be93d3, 0x3cfbb698, 0x95f71e98, 0xafb1fa63, 0xdf36d306,
- 0xf23f4c6a, 0xc0fd31f9, 0x3fd31eb7, 0x3d30eaf9, 0xf4c7abea, 0xd3005f3d,
- 0x4c06bec3, 0x6235f1df, 0x620beada, 0x6373e1da, 0x6f5de9aa, 0xc7c93bb8,
- 0xbf80d3e1, 0x78eb3818, 0xfaed5560, 0x3b38ddc9, 0xd6afba6f, 0xcf9bb03f,
- 0x8e66f5c5, 0x1e1d5487, 0x336080be, 0xf297ace2, 0xb0e3997a, 0x9763efa7,
- 0x6bff377b, 0xc4de36f0, 0x8a6fccfc, 0x653c6eb7, 0xd594f018, 0x89fa9e1b,
- 0x34f1bbe3, 0x7e64e4de, 0x8fd3c70f, 0xe6311fa0, 0x84e00515, 0xd7f08bf4,
- 0xa71636dc, 0xd409ebe6, 0x6a716553, 0xfa1af6de, 0x75fa2b6e, 0x6e301181,
- 0xb7f11f9c, 0x3f8710e1, 0x274cd47f, 0xcff73d7d, 0xf99e9388, 0xcdf9c6ee,
- 0xbc1d00d2, 0x5b9746c6, 0xad5f18e3, 0xe8445226, 0xb0d0f6b8, 0x468b5c67,
- 0x49225e62, 0x55c07df0, 0x5ea31f1a, 0x7f032bea, 0x9aebe37b, 0xa1b3cff8,
- 0xff27f6be, 0x78e90b9e, 0xe397f313, 0xdbf4445a, 0x1769e849, 0x2e3c37f0,
- 0x10695d99, 0xa61aeedf, 0x086fd138, 0xf3fcf5d8, 0x376e7cd3, 0x3ca21eff,
- 0xb771c56a, 0x37f90d2e, 0xe9e1f3f4, 0x6f5fe07d, 0x7e37bdf6, 0xf80c0a2e,
- 0x37b3f097, 0x5d9bd8fb, 0xc5f56e24, 0xe77fed20, 0x0f3951be, 0x870760ab,
- 0x0f5a79b0, 0xa5d6d6fc, 0xff7cf48c, 0x33b8e26b, 0xeb71c355, 0xf9db4260,
- 0xf9cbeb88, 0x40132ba6, 0x9c1eb42e, 0xe4ed741f, 0x722f7e7e, 0xafa99b3d,
- 0x2fac6bcf, 0x68c22141, 0xa2bc6eda, 0x6a420490, 0x22a3cf44, 0x6d5c6fce,
- 0xec1b887e, 0xa8d6b9b3, 0xfd3c6f30, 0x1a854866, 0xf385f1f5, 0xc0769e87,
- 0x9a656c3c, 0x863c79c9, 0xaab4b51c, 0x8f69d331, 0xf504af9c, 0x4275f3f9,
- 0xe7ce2351, 0xa35984d4, 0x3a719c60, 0xbb050f8f, 0x56a9869f, 0xc534cacf,
- 0xddda9c79, 0x09590dd3, 0x6017fe6c, 0x225b64f6, 0x3ed39bda, 0xcfffbe0b,
- 0x7aa7a7a6, 0x69087a34, 0xc0589f22, 0xacb2d39e, 0x51efdf9e, 0x0a8ba41f,
- 0xb34937c4, 0x37cc39fc, 0xaffff4ad, 0x12bd4086, 0xbd7ab5e6, 0x3cdfa28d,
- 0xd36f9e1a, 0x53bf47b5, 0xf857b5b5, 0x93bd67ae, 0x7b86bb48, 0xf957bf2a,
- 0x068af0fa, 0xc7ef53ab, 0xdef2ea26, 0xe753ba60, 0xc03fc2d7, 0x2411af71,
- 0x87255fc0, 0x5f64a75f, 0x0cda780f, 0xbf9843c1, 0x2abdec08, 0x51e29b4b,
- 0x015a5d51, 0x34f28b9f, 0xfe73abfc, 0xa9d4ed4c, 0x7a0265d7, 0x54a4be46,
- 0x20a9f2e5, 0x4c44cde2, 0xbf98bf34, 0x4569a8bd, 0xa75b8c31, 0x50fe6c4c,
- 0x301c4a46, 0x75272e3f, 0x3d4f10b9, 0xa0454c4b, 0x3bc9679f, 0xfa11b18e,
- 0xb0544e78, 0xf5ebc5d2, 0xdf9d3c7e, 0xeacbf2eb, 0xe4a5f9f5, 0x075854d6,
- 0x2641ba5f, 0x86ec0101, 0xe898fcbe, 0x91977ac4, 0x6e30759a, 0xbbc79cff,
- 0x94893916, 0xfaabe941, 0x17732fcd, 0x892e3a52, 0xd6d5fc6c, 0x31279771,
- 0x05662bfa, 0xff7d3714, 0xb7b1a693, 0xbf440b51, 0x7583ac0f, 0x71297f6d,
- 0xf2d1256d, 0x1bf4bafb, 0x81fcd5e9, 0x4e64f5a8, 0xe0834a47, 0x63b0c40e,
- 0x3d30248a, 0x6aeef6e3, 0x838ba9c9, 0x223e42e4, 0xf18df20e, 0x78744294,
- 0x067a2cda, 0x7e19e34b, 0xd4820f00, 0x4dbe78a5, 0xf55169fd, 0xfbf52d5f,
- 0x903fd627, 0xabab9fd6, 0x4a9ff73f, 0xfa28d0ff, 0x5fd5620b, 0x76179bf5,
- 0xa93da9f9, 0x0e67e978, 0x53c9c742, 0x8baa5d52, 0xeb72b5ca, 0x9a6e1d0f,
- 0x0efc949e, 0x80a9ebc0, 0xde4b1458, 0x76f2c3ab, 0xbb8805db, 0xfd693fc1,
- 0x11ff9fa7, 0xdf3e23c6, 0x9e313b2a, 0x990e60d6, 0x37563ea9, 0xd9262f2d,
- 0xf2c63f98, 0x21139e0f, 0xafe3d41f, 0xa59fd9e2, 0x8a0afec2, 0x0a5f1e14,
- 0xbd5b3fa1, 0x1c42d3e5, 0xea17489f, 0x683bf191, 0xda1252ff, 0x424a85bf,
- 0x13a53974, 0xce5e04e3, 0x8fd36f17, 0xf80e89ce, 0xdfce1b57, 0x7397ef8d,
- 0x14b974ff, 0xa36ed29f, 0x26409eff, 0xf8d43d80, 0x3fcc0241, 0x2fdcf35d,
- 0x7a518fb2, 0xdd796cce, 0x49f04421, 0x8df3a3d3, 0x47b57f8b, 0x76ded9ed,
- 0xf48b3d50, 0x4af1b483, 0xbabf720d, 0x7295a599, 0xd52d71c8, 0xb24dcafb,
- 0x571f4fcb, 0x33f4f0be, 0xf31c424f, 0x30d7668f, 0x178aff5a, 0x8937bc0e,
- 0x976c57e6, 0x37598a53, 0xb76a42ec, 0xfff4bc5c, 0x72dd39d5, 0x80f978a8,
- 0xcf628ea2, 0x96ea4fef, 0xfbed8ac7, 0x9a2a3215, 0xf71b531f, 0x18f66d2b,
- 0x563c6972, 0x9ac27e08, 0x814bfee7, 0x7da9e2f8, 0x199fe902, 0x0e9b9f83,
- 0x7c001fa0, 0x39723942, 0x7866e585, 0x02e54bdf, 0x93935af6, 0x6e46fcb1,
- 0x753ea04f, 0xc5f9e224, 0xf2fdb43d, 0xd05d993f, 0xef17f2ff, 0x4e3f4071,
- 0xd70c3548, 0x2a61fcbf, 0xd972afd8, 0x94c4ea9f, 0xea7f2f3d, 0x65b788bb,
- 0x15377f6f, 0x9dc449e3, 0xc7b1c26e, 0x5bfd0e9f, 0xf63671b2, 0x20f1296f,
- 0x297fcaee, 0xfa680496, 0xb68a4499, 0x0e8bd0c7, 0x362717ae, 0xf68c4753,
- 0x1fcc04ef, 0x23bf5ec1, 0x422abee2, 0xffa026ee, 0xa17de5df, 0x3fe6021e,
- 0x1d3930b3, 0xaf5c4c90, 0x8919b7a8, 0xb60f2dd7, 0x0f4e7c82, 0x7587f772,
- 0xfc912f16, 0x57c21f9c, 0xedf15eb4, 0x7c99fde9, 0xf2e52a88, 0x3f38e8ef,
- 0xfbc39e15, 0x9adbb2ad, 0x7c8efbad, 0xfeddd995, 0xa53ede2a, 0xe7c60e3b,
- 0xfdb1a913, 0xa6b201d5, 0x8e9c74f7, 0x7e8457c0, 0xf2df7d33, 0x4d6fd310,
- 0x45a503df, 0x30f17e50, 0x0ef81fd3, 0x574a3fc6, 0xef963fa8, 0x3da0259f,
- 0x58e6f3a0, 0xe645bd7a, 0xd72fad7a, 0x96e94270, 0xbc088484, 0xc849fd40,
- 0x595f5c7f, 0x177e81ba, 0xd0bd2f61, 0x3eba239e, 0x71976f4d, 0xfa053ffd,
- 0xfeb74d7f, 0xef4c8d93, 0xfc9ff67b, 0x07236e2c, 0xf412799e, 0x5fa7ea95,
- 0x4b957d05, 0xdd7fdfa0, 0xeddef2d6, 0xdaff4f54, 0xdea9e9a8, 0xb4f51a7e,
- 0x1278c77c, 0x6aff4f4b, 0x7a989177, 0xd4c79f4a, 0xe21b7b53, 0xfd94fff8,
- 0x2897f8d4, 0xd9a7f9eb, 0x68f89ec3, 0x4a2f87b4, 0x68d3f22a, 0x61dfe90f,
- 0x3f8d1b92, 0xde1a770d, 0x755d7e2a, 0x309dd805, 0x85dc352e, 0x2ee1a971,
- 0xe3ab7e2a, 0xcffcb19f, 0x74a26b10, 0x4fd4b7cd, 0xa5847981, 0x2bbce08b,
- 0xeb88967f, 0x048b96a6, 0xc880bef5, 0x7df06fb8, 0xf078cd53, 0xfdfca743,
- 0x52f7b3b6, 0xbf13e77a, 0xebe5d6cc, 0xbfebf464, 0xc9abeafc, 0x73b73fb4,
- 0xeca7cefe, 0x63ca89be, 0xe28424ae, 0x24f39d28, 0x82484fe2, 0x3e40acf8,
- 0x7e63a08e, 0x7f0f3eb9, 0xebbb5253, 0xaffdede9, 0xa6f90f3b, 0xb63edbe9,
- 0xa42ef576, 0x2979b143, 0x20a54f12, 0xef3fca57, 0x04302138, 0x549b52ed,
- 0x7aaf3112, 0xb79ddb9c, 0x0f1ccda7, 0x9cfe4bfe, 0xe70c0951, 0xeb7e7183,
- 0xbcebf6e5, 0xbb004d5f, 0x0b39be7e, 0x0fe7afe7, 0xb58f8e2d, 0xe385b26f,
- 0x575f00ec, 0x750bb4e9, 0x277dc522, 0xc5ff42e9, 0xad92b76f, 0xbefdd631,
- 0xe4f89b2f, 0xfe8dcb83, 0x736e5489, 0xd1e70e39, 0x2272134f, 0xa6eb36e4,
- 0x5a239253, 0x71f7f00e, 0xdbeb3cc4, 0x0d7017f2, 0xb6b16dfc, 0x88c49615,
- 0xf384fdd7, 0x5f2bca6f, 0x69d5fee0, 0xf012f9cd, 0xd45d9a71, 0xd41e39c5,
- 0x192475f4, 0x794d7409, 0xe3a3f965, 0x87bd8e29, 0x57ec1744, 0x539f36f5,
- 0xbbe6313c, 0xfd427e46, 0x901e47e0, 0x23afc89d, 0xe012c972, 0x56d991eb,
- 0xef96eb02, 0x58aaae2a, 0xb3374e74, 0x523cc878, 0xe138d9f2, 0xe6fe3eff,
- 0x150f89cf, 0xb79c7e50, 0xd1c0fdb3, 0x7f7a63f8, 0x6a0429de, 0xc8a1c005,
- 0x004229f2, 0xc48564e2, 0x0164e8f3, 0x48fafdf5, 0x2c1f95fb, 0xd5f6017d,
- 0x4e0b3754, 0x96af2d13, 0xb1c014da, 0x025db837, 0x9546fcff, 0x20de31b8,
- 0x159a8cd5, 0x203ad711, 0x96afc84b, 0x277eddbf, 0x2cc2f7f0, 0xdcba0133,
- 0x6039cf23, 0x3cd0bfdc, 0xa7a0f516, 0x47c1fd7e, 0xa0934ca6, 0x30f8821e,
- 0xc530a1e2, 0x9ecfcba6, 0xa8ba064a, 0xdb98a6dc, 0x90c571ee, 0xe18532df,
- 0xcdf6cfac, 0x7d99fff2, 0x1bed4c9b, 0x691cb5c3, 0x512b46df, 0x2c7fadf6,
- 0x56b2b6fb, 0x58b80fed, 0x3fab37b9, 0x6be575c8, 0xb2c5fa4b, 0xd8faaf6f,
- 0xbe35fdfc, 0x2073bb0f, 0x23a36fb5, 0x6a40dbec, 0x6dc462df, 0xffcd15d3,
- 0x59bec5ec, 0xeff477fe, 0x316fb055, 0xd1523bfa, 0xe6a2b7db, 0x456fb45a,
- 0x7edd4503, 0xcf852ca8, 0x6fb47ae7, 0x1b367f0b, 0x16cbb2f3, 0x57c03f03,
- 0x71af6fb0, 0x80ed073b, 0x38a45b9d, 0xdabefdb1, 0xdabed2b9, 0x3e25ffb9,
- 0xe56e766b, 0x239e7620, 0xcecc871a, 0x7664ccad, 0x665ee56e, 0x630e56e7,
- 0xdf68ce76, 0x1beca20a, 0x047abefb, 0x8be71efd, 0x83b8bf99, 0x95cf1796,
- 0x7efa165d, 0x5f9daab1, 0x691f19a8, 0x122916ef, 0xdeca39f2, 0x39e1ceb9,
- 0xddecde90, 0x86ef605b, 0x0a1b1da2, 0xc7c4647a, 0xba6d430d, 0xbe4772fd,
- 0x4bf5ff68, 0x107f2fa0, 0xbefd9e71, 0xf68bcd89, 0x163ed17d, 0xa7376ef4,
- 0xc98551e7, 0x47e7c3b3, 0x24753a7b, 0x43aaf7d3, 0x544e3871, 0xbfac0937,
- 0x15010bf7, 0x5dbf81c6, 0x9df2f9c2, 0x797cd97b, 0x83f1998e, 0xcec89bfc,
- 0x2c16505d, 0xdcc3c08c, 0xd718154b, 0x0b112b9c, 0x0e0baff8, 0xfc0a70dd,
- 0xd69705d6, 0x00bbbfa3, 0x89bec39e, 0x32eb6ded, 0x2e77bb68, 0xa1de7017,
- 0x1798efed, 0x3f7a97b6, 0xec737e76, 0x38531a7d, 0x13ee533d, 0xa72fb002,
- 0x2f107db7, 0x239bfd72, 0xc8bf21b6, 0xf8cc625b, 0x985ef6a4, 0x97c62e4f,
- 0x6fcc55aa, 0xf289f30e, 0xf9a2154d, 0xbc5d2544, 0x2f9bb530, 0xfda4ee77,
- 0xbfb9e94d, 0xf7a2df1a, 0x3e71b8e1, 0xd7bf80b3, 0x3e341f13, 0xf39ff547,
- 0xb8a9fa9d, 0x8fc8c79f, 0x5ccecd46, 0x5e814643, 0x3cf26fbe, 0xf4701e3a,
- 0x942f949f, 0x0de6dbce, 0xd9e79dd3, 0x9372f9c5, 0x54b4d8e7, 0x6a48f815,
- 0x97b76700, 0x4a903f6f, 0x3b8b77fb, 0xe6420733, 0x78a6ffb3, 0x62d0fe20,
- 0xa83b42ed, 0xcccd30e1, 0x8e57f870, 0x9c0323c3, 0x09bc70d3, 0xafd44e0a,
- 0xf1cec190, 0xca5e647d, 0x6f5fd067, 0x144f8f90, 0x859fa09f, 0x720578da,
- 0xa9bcffa1, 0x5bc5c999, 0x6e5ca023, 0x81075d26, 0x8229d5ef, 0x2aab442b,
- 0x21ff6e0c, 0xd57ab7ec, 0x9e839f4a, 0xcdae0b97, 0xf4f61d8c, 0x963898d4,
- 0x3718e162, 0x9b8c4609, 0x24bde00b, 0xc668b7d8, 0x1efceff6, 0x3f4647b3,
- 0xf5b98a65, 0xe533d008, 0x09b264df, 0x7fe8061e, 0xfa303811, 0xf07a5131,
- 0xa4fdf735, 0x2afdfb72, 0xfc0ec1c8, 0x1fc052ee, 0xf8d886f2, 0x257b95a3,
- 0x4df21a75, 0x8e904393, 0x1c98e32f, 0xc8dfa960, 0x3cb45be7, 0x6fde1fe0,
- 0x7ef86416, 0x324f9506, 0xfa6a9a2d, 0x7786a0e2, 0x2fcd1ab3, 0x47a42788,
- 0x6fb00dd8, 0xd596eb91, 0x4f91b7c1, 0xeea2ac37, 0x27cd1a99, 0x07603e4d,
- 0x28afc72f, 0x8fee09fd, 0x9bea7fb9, 0x599a4fea, 0xacfb3faf, 0x868faf5d,
- 0x015eda38, 0x4e690aed, 0xf20fc5d4, 0xd65e6ccc, 0xce20f562, 0x5d935ebb,
- 0xfb68d59b, 0x0b971573, 0xcf2257cc, 0x0e854def, 0xd3b1bac1, 0xfad13e4a,
- 0x2ce1843d, 0xd5783c72, 0xf5f941ea, 0x5e04ff54, 0x98fe4f7f, 0xb40eff96,
- 0x5516fb07, 0xf1c67b7d, 0xf5278b48, 0x6669afd6, 0x69be3f66, 0xbe76b4bf,
- 0x9783baee, 0x4dfc62b4, 0x2cd87f5b, 0xc32e7e7a, 0xd048b8fc, 0xca5073ad,
- 0x9ff2fd71, 0xe558ff50, 0xfc43f532, 0xfcf94428, 0x31a7b6ea, 0xf9f67d5e,
- 0xfe833763, 0x48adf8ac, 0x3a9f542c, 0x1093c5b6, 0x80a207db, 0x24d1509f,
- 0x91167ae2, 0x2333b942, 0xd6420cfc, 0x14bc7e30, 0x62a7768f, 0x4c503987,
- 0xf5d8afbf, 0xddc43649, 0xf6601e3a, 0xc73cffcf, 0x1b2dbfa3, 0x242bfbd6,
- 0x946f8eb6, 0x9f1cbdcf, 0xe6db7667, 0x1a16fd82, 0x8ad779d8, 0x39b239c6,
- 0x6550ce22, 0x7b5c5996, 0x59f70db7, 0x70139ffb, 0x17d0329f, 0xdb52ce79,
- 0x39e679ff, 0x822b9766, 0xcdce0072, 0xef6c3456, 0xc5783880, 0xaffa3351,
- 0x0a7386de, 0x5f53a7f8, 0x23fd017a, 0xc5d4506f, 0x8fe2a341, 0x0cc8620d,
- 0x2aa6b3f1, 0x7f3403b4, 0xb18df30c, 0xc5bdf0e3, 0xb4bc56c9, 0xb29f9777,
- 0xcfcbc570, 0x6cdcf03a, 0xc60756eb, 0x1f2e1b21, 0x378a8fff, 0xd9743e36,
- 0x8e69e378, 0xf5995f8f, 0x21a435eb, 0x9490e319, 0x1892dcbe, 0xee308b71,
- 0x29ecf85f, 0xb33b0f58, 0x014fafe3, 0xb8ff95bd, 0xe07dd4f0, 0x3ab3ed8f,
- 0x3ef6bc61, 0x13d7047f, 0x7376efb4, 0xee78ef3d, 0xe9875c59, 0x05d9a3f8,
- 0x3dec75b5, 0x23d61831, 0x917fb63a, 0x55db710a, 0x3ce3a77b, 0xa9ced56d,
- 0x798c49fd, 0x6e029680, 0x07587d03, 0xa5abca32, 0xd03065a9, 0x1bca9679,
- 0xfc70b65c, 0xc58ab1b8, 0x371e55e3, 0xbd7b16de, 0xdc4e2a2d, 0xeb96f334,
- 0x926efc60, 0x43e92a5d, 0x9530f8bc, 0xc83ee8e3, 0x9a43db6f, 0xbf298fbd,
- 0x2a0ff0b3, 0xf20df7a7, 0xc969acfb, 0xb2849eaf, 0xe31ee4a6, 0xf03ea1c5,
- 0xdbcf5b4d, 0x6c7f7662, 0xf1d9bd06, 0x83cf8c6b, 0x835ce8dc, 0xd9f0bc74,
- 0x9cb38860, 0xc2eebb94, 0xcd7b33fd, 0x62aa2fb8, 0x3fa8fbef, 0xc6df3b1d,
- 0xd7c232f5, 0xf8483ad5, 0xf083ad8f, 0x4b779c39, 0x73338b3c, 0x5a1c43fe,
- 0x1e73e075, 0xd638666f, 0xc53dd0e2, 0x6c2dd39f, 0xceb6913f, 0xcfe5b558,
- 0xf5c4310a, 0xd3903c85, 0x8baecbb1, 0x02707c6a, 0xae44261f, 0xf38ec4a7,
- 0xb8ddd787, 0xe07e40bc, 0x4bd7857f, 0xc4207e68, 0xfbc203cf, 0xe83d8624,
- 0x61d6c4d8, 0xfbd8e43a, 0x95f5b50f, 0x4f418b14, 0x575b7d03, 0xaffe8de9,
- 0x26191fcb, 0xf9a3e39b, 0xd8cbe674, 0x45827c76, 0x61fb76f8, 0xf5a8852a,
- 0xcfac0b7f, 0x60531d37, 0x638da1fe, 0xf0cf7f5a, 0xe799f279, 0xb1ef3c45,
- 0xed05b1ae, 0x545ed1b8, 0x341f1613, 0xd3833bd2, 0xe3641d5b, 0xf11d99c4,
- 0xe7ad3b01, 0x11bb2bcc, 0x8edbd5cf, 0xdf5a7e29, 0x959786c1, 0x52fd88b6,
- 0x22044e30, 0xe2f33fe8, 0x7eb66cfe, 0xc6e5e6c4, 0x76f0e676, 0xdbb1cdbc,
- 0xa73b6ef1, 0xbf85676b, 0x77e76151, 0x69dedf2e, 0xea073dc9, 0x132add3b,
- 0xba7fbfd8, 0xc40a2c51, 0x45927f68, 0x4cf2e2d6, 0x8978e86f, 0xd9e31de7,
- 0x493146f9, 0x557aff41, 0x84d1de7c, 0x15154814, 0x6a6b14e2, 0x35d2fed9,
- 0x81a577df, 0xde24d7bc, 0x756deb86, 0x533afe06, 0xbf10f99c, 0x192b4e70,
- 0xda357007, 0x49b7449b, 0xf8aaff47, 0x1e70fea2, 0xc7f72d7f, 0xf3c2e488,
- 0xb0a3a297, 0x3a23fa08, 0x8c6b4e4d, 0x5ed905f5, 0x7c113c42, 0xf3fa9d91,
- 0xb1cbe492, 0xeda3d42a, 0xb4b4a9a3, 0xa742c41e, 0x4b0ab71b, 0xfcddec79,
- 0x77ec4e59, 0x4f3e36e7, 0x99d51370, 0xc183f6ca, 0x23b9d1b8, 0xc68c9b21,
- 0xe29b890f, 0x0b9fc6d1, 0x07eff6db, 0x41d6b47b, 0xcf5489dc, 0x31555728,
- 0x8e8dce0b, 0x805908b1, 0xfe6f73d3, 0x6d6bd696, 0xd0fe7116, 0x85f6d769,
- 0xcf4113ba, 0xdc11e46c, 0xfe5007ff, 0x4e9bb92a, 0x0240bee3, 0xdf76a4af,
- 0xb45d312b, 0xfce7bce3, 0x10071646, 0x98bfd5c9, 0x2470e2cc, 0xf1f3f400,
- 0xf3a70564, 0x7ef0a43c, 0x3ae78299, 0x72f6bd96, 0x3930886e, 0xb92bf244,
- 0xb4be7f48, 0x86c8eade, 0x77e27975, 0x9939c2b7, 0xbf5f5e32, 0x53b9fd12,
- 0xd07e7eaa, 0x4f5c25d3, 0xf0b4baff, 0x32bfd810, 0xebb452cf, 0xcfeae7fd,
- 0x59f71aa5, 0x2fb0bd21, 0x93ddea8c, 0xabbef442, 0xd6c7e6f2, 0x7a397cc1,
- 0x011915ff, 0x482ac9fb, 0xe7ce0b9c, 0x97d068ac, 0x79bb03ef, 0xd893b015,
- 0xebef172f, 0xc36dbf95, 0xdc79317f, 0x0aebf965, 0xe2dbfbc1, 0xecb2ae31,
- 0x9f68c5b5, 0xfe7a69cc, 0x7f3d555a, 0x7c8c236d, 0xde39f3d4, 0x369be7a5,
- 0xcf89ecff, 0xf3fa7909, 0x4b3e46be, 0x021bc784, 0xb5110e2c, 0x09b82dbf,
- 0xd9f236e9, 0x0b76d7c8, 0x7ce2f75f, 0x96257fa5, 0x81b26654, 0x842974ee,
- 0xa3d4617a, 0x80487b0c, 0x094a0f7f, 0xae57e2d4, 0x69efb478, 0x19423fbc,
- 0x7a06cefb, 0x2ebd0224, 0xd13823d4, 0x46de7607, 0x5bb6703e, 0x909f5841,
- 0x59e9aeaf, 0xfe94f79e, 0xfa22d8fe, 0xefc046d5, 0x762bd468, 0x0489376e,
- 0x9e8264d6, 0x6e309cba, 0x6a2cfa37, 0x9ff70499, 0x286cb510, 0xc4e27bdc,
- 0x1f7cc7f4, 0x8248e74a, 0x431b82fb, 0x3ec15317, 0xeba738fd, 0xde7bb066,
- 0xec04a425, 0x6c71cde0, 0xa798b29e, 0xdc2ab77f, 0xed7b4eae, 0x59bef87a,
- 0x785ce156, 0xcb56f367, 0x4507c830, 0x9bc47fbc, 0xb4157758, 0x332cd1df,
- 0x812ccaba, 0xd8bf1061, 0x1dbb632b, 0x7cf19365, 0x6b6fd865, 0x3a40fb66,
- 0x2c713f9b, 0x1de7b08e, 0x055e9fc1, 0x4c27acf1, 0x0c9ff7b1, 0xfdf89ab7,
- 0xfc70df35, 0x7fda8c6d, 0xf6cadc37, 0x0878fdc7, 0xe97547ed, 0x330e3e79,
- 0xcb96b87d, 0x6f4bf7f9, 0x6ceffec0, 0x47185416, 0x6e3bc50a, 0x39fb451c,
- 0xe3c488f1, 0x392e2c30, 0x9bbfbf8e, 0x1f80d2b8, 0x0223af13, 0x3fc4f3e8,
- 0x35b7dc12, 0xce2966ae, 0xa0eb7eab, 0x7586cf38, 0xb05b8a52, 0xe8ec6773,
- 0x956f8fbf, 0x9c4cb874, 0x798169e6, 0x04a384e6, 0xa384eded, 0x123cf2fa,
- 0x369db110, 0x4f6bf3fd, 0x5605f3ea, 0x49076f8e, 0xf86f7c05, 0x3aba4452,
- 0x01eb88bb, 0xd9676f5a, 0xa6efbc00, 0xda9c22f3, 0x6297e9a5, 0x7e71ac51,
- 0xf281e026, 0xe08509eb, 0x52c4f2f8, 0x5fefc63b, 0x05715a59, 0x7f9feb8c,
- 0xac4573cf, 0x7611e073, 0xafed8129, 0xe2502772, 0x0ad7ae29, 0xe975df8c,
- 0xebf63125, 0x70d6386b, 0x7d39e1ad, 0xd6279c69, 0xad0fc4be, 0x58290fcc,
- 0x6050423a, 0x204fb65e, 0x078ed7c0, 0x373d973c, 0x640f27e3, 0xe0de3d00,
- 0x2db3f405, 0x963b82cd, 0xeacab19f, 0x07bef360, 0x1fb0b5fc, 0x94aa5eef,
- 0xae7b1f60, 0xabce0377, 0x2ba0876e, 0x5ba9677c, 0x9770e788, 0x8866c858,
- 0xe9754b67, 0xee03c6b7, 0x4758cea7, 0xc4b27de9, 0x427e7284, 0xfefd2176,
- 0xbe30422a, 0x03b5e3c0, 0x229b266f, 0xc0ff23cf, 0x95b0ff9a, 0xd5b0fbd6,
- 0xf6497289, 0xdfa004b8, 0xe5ffdff5, 0xbceebd00, 0x0e394664, 0xed1ff3e0,
- 0x4f9cadbb, 0x6bdce3a3, 0x3ca4ff01, 0xe5c3f505, 0xc965a871, 0xe5012f70,
- 0x54758c7b, 0xf24d2fcd, 0xe946db50, 0xf09bb249, 0x76e22e7e, 0xdf6d4eab,
- 0x45efe119, 0x090903e8, 0x69a5f604, 0x166854f6, 0xff14f142, 0x10f62ce3,
- 0xca9233cc, 0x0929bf69, 0xf5616256, 0xc2674ab5, 0x9f71aae7, 0x2e65c53b,
- 0xb8226e1c, 0xd2360daf, 0x9d9afd42, 0xdaf3ecd5, 0x66f68244, 0x605263ed,
- 0xa367ad0d, 0xf88566d4, 0x2d5ba649, 0x4944ad80, 0xbde78a92, 0x7d339507,
- 0x32fd65b4, 0x50afec31, 0x0ff31f65, 0xf5ac4171, 0xfcc38fba, 0xfc00bcf2,
- 0xf5d43eca, 0x2e35b80a, 0x75cf6b2b, 0x79fe82c0, 0x3f706ed8, 0xbb8f90ac,
- 0xb1353f13, 0xeba102fd, 0xb69dbf71, 0x1bb4668e, 0x15de0f54, 0x953eaf41,
- 0x75cf9e08, 0xb572ffd3, 0xf611772d, 0xb9938f83, 0xf4169ac1, 0x2d91c4dd,
- 0x5f6bc780, 0xa238bbc7, 0x3784c8ec, 0xde806b3c, 0x8c3f6a6f, 0xa2131878,
- 0x33e5c8fa, 0x2a7b8552, 0x943ce19c, 0xfcf95ab7, 0x949bdb8e, 0xd1fd71d2,
- 0x3338e5af, 0x6bd357f2, 0xace7bea3, 0xb198b576, 0xc13200d6, 0xba110ed8,
- 0xc0b350e9, 0x8221bd1e, 0x4f99df7f, 0xbae942f1, 0xfc0ef417, 0x19818bf3,
- 0xcd0d9b80, 0x7e82b1df, 0xa3f1e37c, 0xb11d7e99, 0xa227fabf, 0xf6cac3a7,
- 0x0f803b87, 0xf22ffbd5, 0x728423f1, 0xea95cb0e, 0x443c6447, 0xe711bdc3,
- 0x81ac5e9a, 0xf0b2330b, 0xf9011c7c, 0x0a234288, 0x3a364cd6, 0x7f9aaf81,
- 0xcfec26bd, 0x9eb9e226, 0xded64e55, 0xcbf3591a, 0xefe8165d, 0xfe82f8aa,
- 0xf5175b97, 0x97f3a25e, 0x5e30f388, 0x67e70ba9, 0x090a4bde, 0x7e0b7f24,
- 0xb9eb6905, 0xc4a57e3a, 0x0757e0c5, 0xfff8d1e8, 0x6d93fb27, 0x6a83cfec,
- 0x25ae7f77, 0x51b6df9e, 0x4f7b90bb, 0x05c33a7d, 0x89169c39, 0xd95ebe0b,
- 0x51e77e93, 0x2dd706fd, 0x7a0d9f4a, 0xea99b13c, 0x8f5a29b1, 0xde09725d,
- 0x6bdae75b, 0xd4677b43, 0x5fbc8beb, 0x7be31b5e, 0x1199e88d, 0x5371f307,
- 0x5dc060d7, 0x8b924ab6, 0x41d9b129, 0xb6afad91, 0x91c6eb26, 0x8fddf1e8,
- 0x2ff35276, 0xf8d2bf35, 0xe4afd85e, 0xcf1686e3, 0xff148214, 0xc7f7dfb4,
- 0x5f01e679, 0xfcd938d7, 0x829a0e13, 0xab03fcbf, 0xcfa00ee7, 0x0710fb46,
- 0x42231aeb, 0x125e2c99, 0x4f5be9d2, 0xe83365fa, 0xc248634f, 0xc74fcc71,
- 0xcf4261b1, 0x4b8bf4f4, 0xab52f464, 0xc0ca7e02, 0xab1ac25c, 0x7bafb826,
- 0x47bb3660, 0xbb0e6066, 0xe3dff1f7, 0x7dcc7ad8, 0xd0dc6c71, 0x4b581fd2,
- 0xc97e81ee, 0x739bf112, 0x40dd39be, 0xef0fc42a, 0x0ddf738f, 0xb914b0fc,
- 0x4e191fb1, 0xde2812e2, 0x0146a432, 0x552437f6, 0x1b8b02aa, 0x40ee3612,
- 0x28cbeb4a, 0xdc61f356, 0x16b6a0ca, 0xcd1920e2, 0x6cf5cfb1, 0x5dbf9388,
- 0xea29abbc, 0x3886ca3c, 0x541f6fe6, 0x8b937f68, 0x709479d9, 0x0f9286dc,
- 0xbf88edfc, 0xf1db3b0d, 0xf50f5b19, 0x1b3e3227, 0x30205fe7, 0xf3c497e8,
- 0x6488543f, 0x91f9c24d, 0x99df04df, 0xb23f382c, 0xd8235711, 0x58e297cf,
- 0xe09d755c, 0x9ff90f5a, 0xb8165d48, 0xffc3476f, 0xeadf278f, 0x8e2be892,
- 0xc367ceeb, 0xc3ea959c, 0x8eaf20f3, 0xaf87e7c9, 0x0d741ec5, 0x8b737866,
- 0x9aeffdba, 0x4eb282dc, 0x8788566e, 0x78ebda44, 0x1df7e705, 0xe60b9c42,
- 0x05cb1d43, 0xe160a746, 0x7d2403e7, 0x43db869c, 0x27781c6d, 0xb7e9132e,
- 0xbc18ff11, 0xb2e2cc1f, 0xfd1a3d00, 0x86a473e1, 0x73c69e73, 0xe15969a0,
- 0xee3a4db8, 0xe0512d93, 0xbe722f8e, 0x97fe86d9, 0xdff4c1d7, 0x60fe8788,
- 0x6e732e3c, 0x15abf292, 0xae5fdbe4, 0xdb7b0449, 0x0ee3ceff, 0x0f91af90,
- 0xcc7f829d, 0xfadf5841, 0x9f731c83, 0xa5a69688, 0x7f05280d, 0x0d3d2d34,
- 0xbd79ed53, 0x07198a5d, 0xeef5cd3c, 0x9eb5e31b, 0xc3f30c58, 0xb39fd0d3,
- 0x73de779e, 0x6177baa3, 0x8e3ebc7c, 0xd15ebbf1, 0x8026a8f8, 0x5de7759e,
- 0x927eec09, 0x90ff7644, 0x8373c993, 0x492a52cf, 0xd1b9ef91, 0xdc47e91f,
- 0x1181e633, 0xad9320d8, 0xbf166b88, 0x5065ced1, 0x97e4c743, 0xb9fae8c8,
- 0xec294c6f, 0xcc6d919f, 0x30dc5d2e, 0x254bdb1d, 0x5387580f, 0x312d2ebe,
- 0x73ae20b9, 0x1c9fd176, 0x517c1470, 0xe02e6b46, 0x91e888fd, 0xd431e36d,
- 0x65b7f38d, 0x88409573, 0x9ea52a42, 0x9726241a, 0xb8eeb819, 0xff7314d0,
- 0xe6c6ddb3, 0x4e71cddf, 0x06d2d34c, 0x8d8d9697, 0x39440fcc, 0x7aa47869,
- 0xae365e98, 0xc5309cfb, 0x6fb40a47, 0x994ea7d4, 0x40dd6104, 0x9c2987b3,
- 0xd63d9aff, 0xf40521f4, 0x4b01d60c, 0xe4d47da8, 0x9abf8439, 0xfc4af18a,
- 0xfd5f9a13, 0x8e03e602, 0xded00aeb, 0x8f5ffd51, 0xd98232fa, 0xd3d82b6f,
- 0xe7653888, 0xc107f7de, 0xdf87dffa, 0xeb0f10bf, 0xba917f40, 0x9e7ec1e2,
- 0x78ddffbc, 0xe1f43738, 0x715e2cfd, 0x351e6197, 0xfaecc6c1, 0x6c92b6a3,
- 0xdf02d7e8, 0x227ae77f, 0xb3564970, 0x01e58d75, 0x5c9e70d1, 0x554f2f7f,
- 0x9ee1b263, 0x5bd63f1e, 0x32e7efc5, 0xcb92a1ca, 0x4db6f961, 0xed0a864a,
- 0x7eb6dc7b, 0xa08f6e70, 0x14d93cbd, 0x8d11f38f, 0xc6db459e, 0xfa773028,
- 0xaf99b34b, 0x6ccab77f, 0xc317705c, 0xf387967a, 0xc1e748cd, 0x6fac367d,
- 0xfed8cfc9, 0xadb48594, 0x7abed4d5, 0x0b79d99a, 0x7c963f63, 0xa7f616a8,
- 0x90f25bc2, 0x7862f380, 0x4e3a7eff, 0x883f5679, 0x7ec65eeb, 0x31cdef1a,
- 0xe6d55f9e, 0xfcb8cb53, 0xf50788cb, 0x6b5cea2f, 0x369f5b33, 0x1fceffc6,
- 0xff61b2ca, 0x91fe3c6d, 0x79c0264b, 0x86871de8, 0x3eee5c24, 0x1efc33e5,
- 0x1a57b826, 0x823e93d2, 0x654db669, 0xbf3464f7, 0xaae02f7d, 0xef1db83a,
- 0xf6bafb19, 0x94f9aaa6, 0x6b30f603, 0x91fa8776, 0xa43f01ab, 0x97f9d04c,
- 0x282e9bd5, 0xf8cbbe6c, 0x7e7f0770, 0x1b37f407, 0x3fab59f6, 0x7ce54c9a,
- 0x317ca547, 0xbf321ef2, 0xa6ee7f4d, 0xfad5fdaf, 0x2b5bf5a9, 0xd1fbe2af,
- 0xf869df8c, 0x2c78e6cf, 0x6eba52db, 0x9ad16500, 0xf30627bd, 0x4e7868f3,
- 0x1197c347, 0x4948cb3f, 0x8110ba61, 0xb147e693, 0xcb3c9a5f, 0xfef216ea,
- 0xbaf8d3fb, 0x8fc41a5e, 0x118dc37a, 0xdb721d1f, 0x2367d060, 0xb87a3a3e,
- 0x3627e45f, 0xa99427e6, 0x678842ee, 0x9d763751, 0x394fc233, 0xbc1dd529,
- 0x0b6cf40f, 0xf8c479c3, 0xd7b99ccb, 0x57cf1c65, 0xe1fdabc6, 0xdb943d3e,
- 0x6017d844, 0x5a7bc3f6, 0xb73eed3b, 0x7c04a86b, 0xb4f4c22f, 0x7435c4af,
- 0xd2f97768, 0xc0382e27, 0x411cee8f, 0x11d38e30, 0x77f7a7af, 0xf9e91136,
- 0xa543971d, 0x3f8ffad4, 0xd2da8d83, 0xda1dfb8a, 0xa071e4bf, 0xb145cd2f,
- 0xfe27f9fa, 0x86f7e11d, 0x4cf5c5dd, 0xe02c979b, 0x99abbb72, 0xda2f67ad,
- 0x30f28a58, 0x437ad7ee, 0xd0661670, 0x638d3caa, 0x51bf9014, 0xdf5c4b3e,
- 0x51607dc1, 0xf08f2272, 0xdc1e017d, 0x2f5653a7, 0x28c3dc62, 0x93bb7cbf,
- 0x6b57a39d, 0x42b71e70, 0x790ebd8a, 0xb5f4dda5, 0xc7ec63fa, 0xed0126c2,
- 0x65fe91a4, 0x0dd76a5b, 0xd67fd020, 0x847ee8bf, 0xe25da206, 0x55fad4fd,
- 0xff785c46, 0x50fad440, 0x7224f5db, 0xe6f2f53f, 0xbf2fb8c5, 0xb09ff69a,
- 0x85c61238, 0x7a35fa34, 0x1428fd8d, 0x8816c8cf, 0x5c16aee3, 0xefa39f60,
- 0xeeeb7327, 0xb0d85c3f, 0xafc8207f, 0x66fb625d, 0xce02fddb, 0x203f3b0b,
- 0xbd607d6c, 0x3d69eb80, 0xed99afca, 0x8e59ea07, 0xe7dc0a35, 0x8851b657,
- 0xf565c729, 0x11a1aef9, 0x60796a76, 0x8ea86b86, 0x1fdc46de, 0x54a1a2b2,
- 0x9d807cf7, 0xfdb893c7, 0x48df4dee, 0x38cc624d, 0x9a5fa693, 0x97fa69be,
- 0x3cd9576f, 0xcc1c0a47, 0xfebb04c8, 0xa84bce18, 0xcedabe5d, 0xd1e607d7,
- 0xb89faa57, 0x581f5ba0, 0xb3e4c792, 0xe7c62c44, 0xca57d93d, 0x1e7d9d07,
- 0x7fefd767, 0xd1fdb6f8, 0x85e9a1fa, 0x5ea33fd6, 0xc5aff918, 0x30728cd5,
- 0x82e81ff2, 0x7b1bc1f9, 0x0407816d, 0xa74677d0, 0xe915af7f, 0x702b48ec,
- 0x3fc839c1, 0xce9407c0, 0x31dbf4ea, 0x9496235f, 0xc75e71da, 0xfae34de7,
- 0xe1c83f16, 0xab4ed67e, 0x473b2c7b, 0xb80c9254, 0x36db5298, 0xf8a4e2d3,
- 0x2174647c, 0xe53a2bdc, 0x1099b6b1, 0xc8f25efa, 0x5fb84298, 0xb6d6ca7e,
- 0xea2e2d77, 0x2d8ed5d7, 0x57e5fb84, 0xf680dd80, 0x10db9607, 0x89e53d57,
- 0x9579f2e7, 0x5cce3fbd, 0xcbdd9f32, 0x292bcacc, 0x3c742d8f, 0xfc3c3cab,
- 0x959fa0f7, 0x1045c5ad, 0x8884a9b7, 0xaacf1d37, 0x2d908edc, 0x93e78d9b,
- 0x6cdb7be8, 0xf076559e, 0xc5ad2eeb, 0xb0f2adf1, 0x0e44fa84, 0x44a8b8b1,
- 0xdfa56afb, 0x7ea38dad, 0xdaefe52f, 0xe60b8b24, 0x1fb9f4af, 0x936bb5e6,
- 0xf11aaadc, 0x7c1f935c, 0x35ac7407, 0xfdfb75b1, 0x684f0daf, 0xbf78ccbb,
- 0xc32647df, 0x67c5a43c, 0x9e58d4c1, 0x7cf138af, 0xc589be44, 0xbfe58c35,
- 0x512cecd2, 0xd5170033, 0xaf161487, 0x4fe07fa6, 0x17a61156, 0xeb9d84d5,
- 0xf04c3aaa, 0xa1f54b1c, 0x02c73c42, 0xd63ffcfb, 0x735ff0e1, 0x571ba58e,
- 0x92054f8c, 0xc08a5930, 0x55bb34f5, 0x9bfb1797, 0x887f4046, 0x7382e718,
- 0xa9866218, 0xbfed0766, 0x294d0578, 0x4ba7243f, 0xea5afb84, 0xe1114ea6,
- 0x3235a9be, 0x62623fdf, 0xf6b5cce7, 0xb47f389a, 0x64bdb4f4, 0xecfdc807,
- 0x36b9ad5b, 0xf3817eb6, 0x6bbfad61, 0x60113704, 0xe08075de, 0x149c80f9,
- 0xb3fc02d2, 0xe01e7711, 0x127b3ded, 0x375b37e7, 0x90197fa6, 0x97a6ccba,
- 0x57f78a55, 0xfa84591f, 0xdd304ae0, 0x6ff34993, 0x7cb197d9, 0x2642e986,
- 0xf6dbf085, 0xc6bf9672, 0xcd086174, 0xce5f6bbf, 0x49c0b0f2, 0xf623b607,
- 0x48ff428a, 0x7de38768, 0xc01afb9b, 0xf16264b7, 0x0515e917, 0x7db453d7,
- 0x44e96b21, 0x1ef8f00b, 0xa7884dd8, 0xdafc16d4, 0x02eaf106, 0x3dfb0ab7,
- 0x837bf336, 0xf1aa69be, 0x7099b455, 0xf02903fe, 0x4fce43ff, 0xc9a42e4d,
- 0x8bec0d7d, 0x6bee8d25, 0xb4ed1d60, 0xf606d3dd, 0xad1bec66, 0x377ec053,
- 0x5ca7f3bd, 0x0afc9fbc, 0x37d8cf56, 0xf6909ce8, 0x066fece7, 0x8f5c8a6d,
- 0xffcf6d3e, 0x62a3be14, 0x5054ff40, 0xaa0ee49d, 0x44dc6b87, 0xbe60b255,
- 0x362f9fac, 0xb69f6611, 0x82ce4ad9, 0x10c0c95c, 0xf6455b8e, 0x6bc84e92,
- 0x26b49cf6, 0x9b5f69f5, 0x845abd92, 0x23293971, 0xd8117478, 0x7bb1dfff,
- 0x1bb7043d, 0x14be73f7, 0xed8cd7be, 0xfec1b10f, 0x177fd010, 0xf2a7f349,
- 0x2f8b17f8, 0x88dc9493, 0x07ef3079, 0xec1a7efd, 0x63609f37, 0xbf6807fb,
- 0x63abb044, 0x58e98a88, 0x81656788, 0xdf983d28, 0xde8f1a43, 0xdc7feb47,
- 0x9649e2ca, 0x0f8ba206, 0x38b3c766, 0x8b074ccb, 0x8dc9c60f, 0x10ff82b7,
- 0xc1388e77, 0xa5fce87f, 0x22fee122, 0xae2379c9, 0x11341d8f, 0x3959f7a0,
- 0x99f584e0, 0x7524abae, 0xafaee933, 0xab5bcb93, 0xbd4571f7, 0x7372e20a,
- 0x7d3fcc1d, 0x7ee09f36, 0x4a53aee8, 0x934dd600, 0x91352c32, 0xf92b9ff1,
- 0x0b390f77, 0xfe21e332, 0x408e37bc, 0xc5f613fb, 0xbf0e4099, 0x056396de,
- 0x3c04bc3c, 0x32487ca2, 0xfa86ef3b, 0x7a502e92, 0xdb39f133, 0x63a92f27,
- 0x277f2812, 0xe15760dd, 0xad67a9be, 0x7ee0378d, 0x784c17d0, 0x8a4beebf,
- 0x2ff214ab, 0x609d579d, 0x6ccd9f7f, 0xbcfec38c, 0xbcfec260, 0xf575d714,
- 0xc3f74a4a, 0x4a7c5823, 0xec0911b2, 0x502a64b2, 0x73cfa6ef, 0x493cd9e3,
- 0xe3cbd3b3, 0x2e3cfe99, 0x200f3c10, 0x7f51f299, 0x9d3afdb4, 0xebf7045d,
- 0x2ad59bf4, 0x4ae38e02, 0x4851b8b5, 0xe4cf7884, 0xdb7e8212, 0xe78cbb64,
- 0x307f6072, 0xc29b1b9c, 0x0f94efed, 0x813d712a, 0xdc30e04a, 0xe762d97f,
- 0x75f168f7, 0x4e39ebc5, 0x226d23ae, 0x5dd791f8, 0x07882e22, 0x8a497f5d,
- 0xe74e47e9, 0x10233ef5, 0x97be8129, 0x0095517f, 0xef44f977, 0x2faf4de7,
- 0xe0e3053c, 0x39e18b54, 0x8f4889f8, 0x4ff7cf1b, 0x4fee1a77, 0xd6f3e78e,
- 0xe47064c1, 0x1d6d313e, 0xf238ba68, 0x8b53f409, 0x65f01714, 0x3efdddbb,
- 0x5bfa7bac, 0x38b97265, 0xb63e33e2, 0xa5c46f9f, 0xa1ff5c38, 0x2e03b4f8,
- 0xf3afaeae, 0xafbf695b, 0x07eaca1e, 0xb95d821c, 0xc92997f2, 0xf1cde760,
- 0xa968decc, 0x97c03b86, 0xcbe18133, 0x3f5bba39, 0xe267c557, 0x01be9a7b,
- 0x3d9ea0ee, 0xac7e6072, 0xd78a6575, 0xedd78055, 0xb3f38276, 0xe65ba51f,
- 0xed699e82, 0xf86789ec, 0x6aeba637, 0x7587ee57, 0x6c67ff1d, 0xe03698bc,
- 0xde391292, 0x3864e87f, 0x3375aaf3, 0xf3fda66f, 0xbf5c65da, 0x8be7e549,
- 0x1e92f122, 0x770d1781, 0xef16761d, 0x7533f0d1, 0x3c22bbf7, 0x2119fa9f,
- 0x9e124cce, 0x99f86887, 0x9c3867e2, 0x138d8872, 0xddc7e1bd, 0xe6069ce5,
- 0x87370a31, 0x280a6e18, 0xb7f7f03e, 0x118fc07a, 0x8af54f37, 0x3cf12f9b,
- 0x53bdaafc, 0x186ebb2f, 0x7df7e9f4, 0xb689d31a, 0x8f82fbd8, 0x56ef7e72,
- 0x06cc6eea, 0x8993717b, 0x48937f9d, 0xe714adc6, 0x7bb4e3bb, 0x20b26be5,
- 0xf6625dbf, 0x19b37b67, 0xbb76cfed, 0xd77183c7, 0xcb9e0b34, 0x0da79226,
- 0x06bbf5f6, 0xdfc8d458, 0xc72ef8d1, 0x9a1ca361, 0xeffc0278, 0xf3fc98d7,
- 0x1b81ca6e, 0x197a48ec, 0x93b8c393, 0xe21126ca, 0xfdfc8e42, 0xe04faf80,
- 0xc3c02d4e, 0x25ef0571, 0xa0ae3eaa, 0xbecdfc5d, 0xbe210bb7, 0x9e1feda9,
- 0xc2ede7b0, 0x3ef09182, 0xdc6bd9c3, 0x3c796aae, 0xd276014a, 0xc4fd2f70,
- 0xfd2679f0, 0x8025f2bd, 0x72eeec9f, 0x73eb7de3, 0x1d1784e0, 0x736d6e77,
- 0x60b3074d, 0x4e7d6fbc, 0x9b1f9d88, 0x1d3dd47d, 0x7dd4654c, 0xb70f1ceb,
- 0x715dd691, 0xdffdf462, 0x163e7c74, 0xd7fbf10f, 0xc1c40a43, 0x6b9a951b,
- 0x26a27cd8, 0xa68fec0b, 0xf947f877, 0x08e1f8d6, 0xc3ff7ddd, 0x88f3f8f8,
- 0x38f7624b, 0x4eb829b5, 0xdf6128f8, 0xeb71f235, 0x39f7ae2b, 0x0f9c5eab,
- 0xb96c70f6, 0x576dd71b, 0xfe7c4539, 0x64b21213, 0x125cbc81, 0xca3477ae,
- 0x4213d4ea, 0x2a447bf7, 0xe5a76119, 0x8dc5fa7b, 0x70eff685, 0xf00e4c78,
- 0x43aea42b, 0x4984ddf0, 0x6ec16339, 0x4dacc7db, 0xa34c7186, 0xb455d29b,
- 0x874dded5, 0xc7275746, 0x858e1dc9, 0xf678c726, 0xe0a1d81d, 0x7c0b76b1,
- 0x71a0e1af, 0xff2639ef, 0xfc803c08, 0x2c20f1bb, 0x07c6bc80, 0xfcb54f1b,
- 0xa10f1f3f, 0x1e9f2081, 0x087100f1, 0x43c2b7c7, 0xc355f016, 0xaed7f503,
- 0xfe68fe02, 0xf6c2a35a, 0x0d796a1d, 0x7cf64507, 0x10a5cf7c, 0xf6443fdc,
- 0x6d39d959, 0x57ae224f, 0x6d64ecbc, 0x3ed87e74, 0x6498ba98, 0xebf983b2,
- 0x8c89efda, 0x57e80909, 0xe106a18e, 0x06e3f40e, 0x71743da2, 0x4176917e,
- 0x71377b80, 0xf806796f, 0xd064a197, 0xe2e6318b, 0x877fe010, 0xf8064a6d,
- 0xc9b63987, 0x5daf8059, 0x0ebd5623, 0x01aed643, 0x516f2fe5, 0xcd27fdbb,
- 0x6af0b5ee, 0x746ff6b5, 0xbd74fb30, 0x020f9d9b, 0x87491dbb, 0x2c41ff66,
- 0x9a108740, 0x86cafa63, 0x0db9baf6, 0x41d039ec, 0x205fbaf9, 0xe41fe04d,
- 0x5329dc9b, 0x17ebcfc1, 0xcece8092, 0x860c5fbd, 0xf3716538, 0xde8147ab,
- 0xd43d6d62, 0x350f5fa5, 0xbf9ad1fa, 0x342bcda3, 0xcf9b487f, 0xe504df82,
- 0xd3b9fcd9, 0x26add6cc, 0x6e782c87, 0xeaf3f1f9, 0xbfae6e55, 0x3147ed12,
- 0xa42dc7ef, 0xeed2e915, 0xf399b91d, 0x9d10f8a3, 0x39436687, 0x3e513721,
- 0x1defc4dc, 0xbfa5c9b9, 0xbc96e157, 0x688ef7d8, 0xbef6f4f5, 0xd6b87c71,
- 0x6df46eb0, 0x763e43d3, 0xfa7fc8cf, 0xd2773cd8, 0xc12fd110, 0xce979a80,
- 0x327069ee, 0x62521c3e, 0xb9fb578f, 0xb5324efe, 0xe5b9c365, 0x8efe7bfd,
- 0x7b2be3e3, 0xf81efefe, 0x494f1389, 0x4eb5f604, 0x012e353a, 0xd2f3e7d7,
- 0xab593d70, 0x9369fbd7, 0x88e7b08d, 0x5777ed1f, 0xdc7a520e, 0xc167d00a,
- 0x1e67b7f4, 0x77d429ff, 0x2244b8f1, 0x2a144dcf, 0xc710a19e, 0xbfbfe42d,
- 0xfe605073, 0x907e5692, 0xf3c5eeff, 0x21b0b71c, 0xc48fbb42, 0x9be7211c,
- 0x9a193df8, 0x593a6f5c, 0x8eca4a74, 0xfdfc0f96, 0x5a0be233, 0xf399a15c,
- 0x11fcb48f, 0xa77cb7cf, 0xfc096ee9, 0x89a4eff3, 0xeed11dc4, 0xe0ce950c,
- 0x2f1ce223, 0x4a7e0c3b, 0xbd3f73cb, 0xde2b8e99, 0x4adc4437, 0xfede6de8,
- 0x5be4367a, 0x8ff798c5, 0x9dfbf918, 0xfef1bbe6, 0x2a092191, 0xfb5bd3d2,
- 0x38a6ae93, 0x27720d19, 0x65cbcfcc, 0xe51877f7, 0xff9ecafb, 0xd91b6e48,
- 0x927bbf33, 0xbf0e51bf, 0xeb80533d, 0xc3c9bd4e, 0xb47ddb88, 0xbfda7e9f,
- 0x9fa7ed10, 0xf8af63fa, 0xbdff989c, 0x1af30d2f, 0x9f7bbd5e, 0x4e7f064e,
- 0x64f4e9c3, 0xbb899b86, 0xec4c9a7f, 0xf232f2dd, 0xf30773ed, 0xd710e66b,
- 0x3fe99bec, 0x78ae0a77, 0xd27e17b4, 0x4ab3fb0a, 0x0e738d38, 0x41ffa217,
- 0xe31079f8, 0x1c473638, 0x7bdee789, 0xa19bddfd, 0x5b9832f9, 0xbf0578e3,
- 0x36b802c7, 0x6f45538e, 0xb2e049d4, 0x98ab4a15, 0xba7ee31d, 0xce519746,
- 0xf6094847, 0x8d3a27a3, 0xabd23038, 0xefdae7f9, 0x4c7e50c0, 0xddf5a24f,
- 0xff63e6aa, 0xce61c6a2, 0xdfc69e97, 0x9c95fa9e, 0x1cdee3c0, 0x4e4e17ff,
- 0xdbd80b7b, 0xe519be93, 0xecd72c66, 0x90342147, 0xfc1fa983, 0xa9092191,
- 0x97850fa8, 0xe3a6e214, 0x3fa8190c, 0xaf8a4eff, 0xe3ddbc40, 0xc27acf64,
- 0x1325f55b, 0xe37724f1, 0x663e0e4e, 0x96eddc03, 0x1f106cea, 0xba5ecebd,
- 0xda6f5406, 0xf0b305a7, 0x1336879e, 0xf4d99081, 0x102d73e6, 0x251ef047,
- 0xa0a03e78, 0xc054ff79, 0x56a5efe9, 0x5e75479c, 0x08b1e424, 0xbcd8333f,
- 0x587e06c6, 0x6f9d8530, 0x7448983b, 0x27f790fb, 0x8f06bc30, 0x1dd9bf9f,
- 0x2f12fca3, 0x29dc499f, 0xc72e38d9, 0x70a3fc63, 0x3ffb09bd, 0x481d704d,
- 0x9e65bf01, 0xce85f380, 0xa40e13bd, 0xee3b7a50, 0x333b444c, 0xdde0f83d,
- 0xc6882a4e, 0xcf8b1eff, 0x780a16bb, 0xeaa140cf, 0x59617cc2, 0x98dfee26,
- 0x99e48ff0, 0x433e50c5, 0x74cdf9c6, 0x788252b1, 0x2134d9d4, 0x7b8be607,
- 0xf85ab684, 0x297f5c1d, 0xfd38876b, 0x7cff30c9, 0x0c7938a7, 0xaa9c76fe,
- 0xefe187e5, 0x3cc31203, 0x0bced56d, 0x7cb4cdfb, 0xf7016cd5, 0x66774eef,
- 0x7e047f10, 0x7953d70a, 0x6cb8a58e, 0xb8005fee, 0x3fa4599e, 0xc4bb3837,
- 0xeb910246, 0xef138216, 0xf7c83b21, 0xfc097769, 0xe7ae7c5e, 0xcfbc7037,
- 0xfbac9b99, 0x3f3094ae, 0x6453bbd3, 0xb3e471f7, 0xf4d6a1df, 0x87ae46eb,
- 0xf1f9f037, 0x8e864f3c, 0xd288628e, 0x5b3f4088, 0x62e5be47, 0xa5cf0e1b,
- 0xe78707e2, 0x1c6ef6d3, 0x8ad79861, 0x17116b95, 0x6f1d6c69, 0x1382ec36,
- 0xdfea6ec1, 0x9f4f25bb, 0x97c7a18f, 0x3d9a13b5, 0xc457bd98, 0xf9d9c375,
- 0x8902cf94, 0xaebfd3f2, 0x726098bd, 0xd078801d, 0x78dc97ad, 0xbd944e8f,
- 0x1be8a0f8, 0x50df8bd9, 0x7aa3cc1d, 0x1f0264fd, 0x41910737, 0x8ba63760,
- 0x380a7edb, 0xa6e3a4ea, 0xb48e0639, 0xef9b4771, 0x063d5217, 0x6c3390dc,
- 0xa5fa659d, 0xa4efdc34, 0x76c3f7cd, 0xae25fa84, 0x6fd2fe18, 0xf774b212,
- 0x4aed847a, 0xe7225f84, 0x64bf7b7e, 0x9547f53a, 0x206fa01c, 0x7b458ff1,
- 0x42c97186, 0xf10518d8, 0x1873b4c1, 0x744af1e7, 0xf3e38afe, 0xb02f88d3,
- 0xb752427f, 0x15fd187e, 0xd63cce2d, 0x7a53f9a9, 0x8de3849c, 0xa57dd8b3,
- 0x810a4e1a, 0xb3ffa09f, 0xf4eb8c44, 0xfdad1b86, 0xa212f0de, 0x564c08f6,
- 0xfae1788f, 0xf2f175f7, 0x197c6d17, 0x05f6864a, 0x343e1a27, 0x9bc718bc,
- 0x83c434ff, 0xba6f1a7a, 0x0e6f197a, 0xaed1908c, 0x7cd7e6f7, 0xeaf3e4ea,
- 0x37a62704, 0x7f1b355c, 0xd82c6897, 0xf937f011, 0x6b8e15b8, 0x1c9c33d5,
- 0xc1245b68, 0xec1791fa, 0x1cb76647, 0xfff078b4, 0x81c4c600, 0x008000d5,
- 0x00000000, 0x00088b1f, 0x00000000, 0x7cbdff00, 0xd5547c0b, 0x67b7efb9,
- 0x332479ef, 0x49926649, 0x1d843c32, 0x09212108, 0x11bc210e, 0x11084937,
- 0x88a80ca2, 0x1f01d68f, 0x4d092060, 0x6f53d5ad, 0x52812133, 0xbd583d6c,
- 0xf4f47bd6, 0x41ed5837, 0x0108750d, 0x26702783, 0xd0f098a0, 0x7ac0f820,
- 0x452968da, 0x5a18921b, 0xf5cf6a0f, 0xf6b7df7c, 0x8326664e, 0x73def7a5,
- 0xd62e9f87, 0xf5af6b5e, 0x5ff9efad, 0x4a9b5adf, 0x500a9fc0, 0x982015b3,
- 0xe1f95006, 0x06484a86, 0x01203be8, 0x96d40314, 0xfe1b41c9, 0xb1fdb4b5,
- 0x0cdd45c7, 0x51df8956, 0xf5c02661, 0x950b7e20, 0x06e6c50e, 0xbc95e658,
- 0xd6801672, 0xe1bfde2e, 0x62a82592, 0xf9af7afd, 0xe89b1ee3, 0x5fff35fb,
- 0xb800c803, 0x197f7f51, 0x2ffb0ffd, 0x1860a4d3, 0x3b365d5f, 0x978dffba,
- 0xa6913fca, 0x62d72c02, 0x3e4fc39e, 0x22f2a793, 0xac24becc, 0x8fb74457,
- 0xcfb92673, 0xe32ff1d9, 0x32d7fc61, 0x65f3c5c0, 0xaff7516f, 0xc8ed77e9,
- 0x523d48f2, 0xace80166, 0xdb1971b7, 0x7f016e5e, 0x4d2581c8, 0x0065c450,
- 0x9d0a0152, 0x581998b8, 0x0d0164bf, 0x136308f9, 0x3ab9f7e0, 0xdf86131d,
- 0x07e3883f, 0x8e30dc70, 0x3801c81f, 0xfae4ef54, 0xae1ef56b, 0x2f82935f,
- 0x877fe3a4, 0xb8a8b0bf, 0xdfedc59e, 0xdf38fc51, 0x8f0a4be2, 0x93d69b3b,
- 0x71830b4f, 0xf73f9eb4, 0x0de3fd16, 0xb6bfdc30, 0xbf8b33fd, 0xf9ebf2f0,
- 0xa7e7f35b, 0xcd3f3ca8, 0xcf0c15ab, 0x180144bb, 0x9a5ceb83, 0x635fcd1b,
- 0xc6f9589e, 0xfeb96fca, 0x56fcac7e, 0x90c7acc4, 0x32a2f40f, 0xffc38a8d,
- 0xa6d0264b, 0x437e5e5f, 0xb3f8b1f2, 0xdb2305bd, 0x72c97e01, 0x974f1e1a,
- 0xbe2b7417, 0x19974142, 0xb752baf5, 0x40efd40b, 0xb2b9ca0a, 0x4889c213,
- 0x2be7f5d8, 0xf4a8513e, 0x9471f04a, 0x6c7c033e, 0x1e1e5bc8, 0xe425d17f,
- 0xbcf0da6b, 0x7764148b, 0x0b1f3d11, 0xa8eb3881, 0xea1471a1, 0x6c39601f,
- 0x155a61d9, 0x635c75c2, 0x547d3b81, 0xe0328a26, 0x937db894, 0xf6e3c4d3,
- 0x8266c5ff, 0x3e5e01ab, 0x48025998, 0x3cead79f, 0x42011306, 0xbff7e066,
- 0xdfb9524e, 0x240824e6, 0x74a0fce0, 0x945ec8db, 0xb45c8012, 0x25b4653b,
- 0x364388d8, 0xd91f612b, 0x8157bf61, 0x2fdbb406, 0x050ef78d, 0xc914076e,
- 0x4c738fe6, 0x7ef4598d, 0xf61e7bb8, 0xa8a4559b, 0xcb8bb0db, 0xda877eaa,
- 0x9d580efb, 0xfeff5ef4, 0x699877ef, 0x1780bf9c, 0x0ed78429, 0xe7da8158,
- 0xf241cc3b, 0xe3e48b1f, 0xfdeb09b2, 0xec560003, 0xb8557f3f, 0xd76e5014,
- 0x13a37740, 0xc724b9cb, 0x8d7bf238, 0xfece9bd6, 0xe50a31c3, 0xd39740b4,
- 0x956fdd02, 0x8fd9901e, 0x41c92694, 0x53f61ac8, 0x5a32ead7, 0x3a256c80,
- 0x7ae1b416, 0x4bdafdb1, 0xb4bf5c4a, 0xe1771f48, 0x9321419f, 0x7ad1085c,
- 0xf84da8bb, 0x14d012a3, 0x6d4b29c0, 0x97e4ed31, 0xce459e90, 0xc973e7e8,
- 0xef5ea277, 0xf84bf18e, 0xf7bcd133, 0x8bbcc53b, 0xf726bfe4, 0xb65ffae0,
- 0x43cdef68, 0x9a4e077a, 0x0e7c59e1, 0x6732b1e7, 0xd0da5f24, 0x973983ae,
- 0x07fd8bb7, 0xe9153513, 0xc7f49979, 0x9ad1f541, 0xfdf2f53a, 0x940cf6a7,
- 0xb9787760, 0x13028579, 0x7b4f1d58, 0x3df98632, 0xff3aaf82, 0x22d9f963,
- 0xf91d9341, 0x5bddb0bc, 0x0465ae46, 0x8f913b1f, 0x80c95ef8, 0x295cf3c6,
- 0x78fb0d1f, 0x46a25cf9, 0xb9f2fefa, 0xffcd1ad1, 0xfa6be92a, 0x3feffeb0,
- 0xfe48983b, 0x2aa8f913, 0x2e0317a8, 0xd659f79b, 0xa1f7a15f, 0x6dc13951,
- 0xf5d16f58, 0x81c4e5fc, 0xefc4f9a3, 0x67de4deb, 0xe3651a69, 0xe48515c4,
- 0x9c96b737, 0x0d2477c5, 0x7ed107a4, 0x7709d524, 0xfb401960, 0xa40b7d21,
- 0x1993eb02, 0x36f34042, 0x9534f06a, 0x29abe60b, 0x1c41efc4, 0xe341dbb3,
- 0xe7a429a9, 0x338bd7f0, 0xf923857d, 0x0a8f52de, 0xd6b4f385, 0x1b2534db,
- 0x93bd5f60, 0x1ef56deb, 0x57ad5f2e, 0x2c74dcb9, 0x8e20c1f9, 0x3459ab53,
- 0x7df86d25, 0x8fb0aa57, 0x8867e805, 0x052005ae, 0x0b73a803, 0x5ef5d61e,
- 0x249b8291, 0x27ae1392, 0x97289f82, 0x08dc9ec1, 0x4d2936fe, 0x35b26693,
- 0xf28bbcb0, 0x063efc4d, 0x59f3e0ff, 0xdca3fb23, 0x4baaeaa3, 0xbae67e62,
- 0x961724b4, 0x52f8743f, 0x6e916ca8, 0xb8017c39, 0x5bf512ee, 0xfe380be5,
- 0x7842f0f4, 0x74c3e310, 0x15f10c14, 0xfd13b77f, 0x402c3a33, 0xca80c1f2,
- 0xd3a45976, 0x492e7da3, 0x323e70e7, 0xe0c7af9d, 0x30cad67b, 0xe83ed1e9,
- 0x17be2349, 0xb4767cdb, 0xc843a428, 0xf66e9355, 0x9cde3848, 0x26578b74,
- 0xa6fa26d2, 0x75fe446f, 0xd884e3a4, 0x6323a3bf, 0xa6f68aac, 0x4fbc6f29,
- 0x1cd9ad76, 0xcc2b8161, 0x71113dbd, 0x719e133c, 0x9f22bc52, 0xbdf235f6,
- 0x01c977f3, 0x73886bf6, 0x9e758fc8, 0x7186f64a, 0xd92e6b9e, 0x7fd256bc,
- 0xf5ed117a, 0x54f26260, 0x5dd0cff2, 0xd6b8ebc6, 0x6f91d626, 0xd8bb17f6,
- 0x9f0f859f, 0x6dfef7c0, 0xe9fc8010, 0xca1fdd35, 0x9a94f480, 0x907b32f2,
- 0xe4d2c3ce, 0xfc9f2a14, 0x9701725d, 0x897b92a7, 0x764d073f, 0xa77de695,
- 0x46ce2d5e, 0x72ded17d, 0xd61d0098, 0x0a1cb782, 0xa1ea2795, 0xe5f51b38,
- 0x971b7aad, 0x5c9deb27, 0x70f7aa9e, 0x49db1879, 0x76c75e9f, 0xb037b7d2,
- 0xd85dea9d, 0x1c31e54e, 0xdba2ca97, 0x96bc7893, 0xb42c92db, 0xd0c9838e,
- 0xfa4fcc6c, 0xb70c4e14, 0x3fe01782, 0xab6afb1e, 0x978c2aed, 0x34a17f56,
- 0xb3f4f90d, 0xac142aaf, 0xee3c5b1f, 0xbb60bfa1, 0x1fa667f9, 0x9bde90db,
- 0x8f5a394e, 0xaa9edd63, 0xfa41d8fc, 0x9d112c79, 0xb9b59923, 0xa63a434b,
- 0xcd1c6f93, 0x3660d76c, 0x7af4d3d6, 0xd95d7cc0, 0xa595807c, 0x42e0f93d,
- 0xaf597125, 0x577f21b3, 0xa3dffdda, 0xabb025ba, 0xaa2aeca2, 0x7b248863,
- 0xb641cc97, 0x7b92b1f7, 0x95bbc605, 0x127fff0e, 0xd17b0dbf, 0x91a43fa4,
- 0x49a9987f, 0xbcb372e0, 0xe1a49383, 0x95bf46e7, 0x49ff458e, 0x25debafa,
- 0x98cd7db3, 0xc741692f, 0xfa35fb48, 0x96ab38cd, 0x9e66fc91, 0x72a26f2f,
- 0xeb8b8559, 0x9ab355be, 0x1ccbfec8, 0x94bf7b97, 0x65d07fdf, 0x512dbd66,
- 0x389c5fb0, 0x8e9bf468, 0x7bb8464a, 0xf8312ba0, 0x69f5e92c, 0xd612637f,
- 0x8ab27917, 0x0337dd64, 0xb63b5dd7, 0xebe57b51, 0xde576cad, 0xf2e12f24,
- 0x6990a899, 0x21d0bed8, 0x2a64c379, 0x4a6a3ff3, 0xe4a776a3, 0xd42db625,
- 0xa6289da6, 0xbbd96cf6, 0xd5a7ea90, 0xa7510a32, 0x2ef38594, 0xb9c5bf60,
- 0xbe1b5e29, 0xd0fc2a77, 0x85dfd245, 0x04de49b9, 0xf04af3f2, 0x7baa1ae9,
- 0x9506dead, 0x6958f1d6, 0x4aa38d32, 0x5bd6135e, 0x1ffd286e, 0x2f894744,
- 0xda892405, 0xd7e10a5d, 0xc3f77f27, 0x6bf62732, 0xd9012719, 0xde70a9cf,
- 0x85fe889f, 0x026a899d, 0xb38b69f9, 0xb16bde8c, 0x5c4dce48, 0xff5295f7,
- 0x7d598e40, 0x7e3dc71e, 0x41e39d9b, 0x8c055be5, 0x36df8e83, 0xe542e386,
- 0xa84bf35b, 0x78126e3c, 0xcaadf2bd, 0x41376e0a, 0xe54a9c98, 0xf7e2dfed,
- 0xb0fe97b6, 0x1fe38dcc, 0xdf62ef1b, 0x562a7282, 0xf624fc22, 0xbfde8907,
- 0x77fb9abd, 0x9d0f9948, 0x0b17fec5, 0x38ac8a52, 0x213bb97f, 0x58c57faa,
- 0x497d5457, 0x2562a8f6, 0x16564fc2, 0x6fd54564, 0xb38a9628, 0xe6fbfa23,
- 0x57d54427, 0xb38ab994, 0x54dffa23, 0xbeaa2a39, 0xa8aca6f2, 0x1cd342fa,
- 0x61ea3fe1, 0xf3b0997e, 0x20d965f9, 0xa9fc898c, 0x037df453, 0x3b26efdb,
- 0xa9f812ef, 0x09f885c8, 0x55d652e5, 0xd8b971cc, 0x00affbae, 0x92667b74,
- 0x2ebf17ff, 0x83de8f1c, 0x4999fe20, 0x16fc4878, 0x201e2376, 0xdc60a47c,
- 0xcca7a08e, 0x2bc71d11, 0xff27cd40, 0x84b9d15b, 0x67b954f1, 0x319a1979,
- 0xbdfa31f2, 0x8161f90a, 0x2ee86243, 0xa5c732ea, 0xf46c62b7, 0xabae06fb,
- 0x316be9d0, 0x09529bf9, 0x6eb4058b, 0x7ac635c2, 0xb72e3a0c, 0x8ef90a9e,
- 0xdfff1432, 0xfd2c575c, 0x7f791b00, 0xa0d74b11, 0x8881c74b, 0x760718a7,
- 0xc43e32a6, 0x3e1e3b9f, 0x254f7030, 0xa45737fa, 0xee48737f, 0xf79785e5,
- 0x97b8c66f, 0xb8c67bc3, 0x2cd0fbc6, 0xfbc6fcf3, 0x2955cf43, 0xd89df3fe,
- 0x73ce293f, 0xf9ff14b7, 0x17fdd173, 0x03a36a28, 0x4828f8ed, 0xfbf100de,
- 0x2410aab8, 0x35ad3d2b, 0x43e8b951, 0x747842bf, 0x1340d9f1, 0x837af395,
- 0xfeb8adc7, 0x956572eb, 0x1e060df2, 0x8cd75d8a, 0x3a4fb154, 0xabb5497a,
- 0x5012ded8, 0x68bfb4ed, 0xd3b55879, 0x8345aa3e, 0x6a2fda0a, 0x691b4d13,
- 0x63e5a1bf, 0x549cf589, 0x52f3e7e1, 0xca318e05, 0x5e7f6567, 0xb6d5962a,
- 0x8b09479e, 0x60317cd4, 0x94703021, 0x48c15e70, 0x0954779c, 0xa3be683a,
- 0xbe1d070f, 0xa57e3f08, 0x29146f38, 0xa7e93a5b, 0x91fa45a4, 0x16825b52,
- 0x391637e9, 0xaff5515d, 0xc7d8aa9c, 0xbd45467b, 0x159a9d77, 0x6bf10fd5,
- 0x46a0e12e, 0xe42ae40b, 0x5e894d47, 0x7cb177c2, 0xfd7d17fc, 0xe093875e,
- 0xaadd9813, 0x97138fec, 0x7f82a5bc, 0xa457cfb1, 0x6fea7d8a, 0x6e583d68,
- 0x35f4154f, 0xe2013ec9, 0x3e933710, 0x4f71d6c4, 0xc3c68aba, 0x77a43d91,
- 0x22e9bb5e, 0x4ef86f42, 0x29d7d5ea, 0xe9decfa8, 0xc44eefa6, 0x8ba923fa,
- 0x699e7d44, 0xffac04cf, 0xd45cb534, 0x374d36af, 0x057e017b, 0xc32baf8b,
- 0xe7dbba7a, 0xfb79c54f, 0x12ad8ecd, 0x24c519e2, 0x787b9141, 0x0588fbff,
- 0x160a29e3, 0x21734c95, 0xd8ab76ad, 0xa024d72f, 0x25fea3ff, 0xaafc4a9a,
- 0xdce43049, 0x1d714193, 0x9134ceee, 0x6ff630bf, 0x87be0b76, 0xfcd8e7ef,
- 0xc25f42b5, 0xa5fa2ac9, 0xca2ff7fb, 0x9ed8bd24, 0xe7f5e4ea, 0x21e799ef,
- 0x7d74857f, 0x7ffdfa97, 0x3c536ba4, 0x62cc9aba, 0xfc96de9e, 0xf9bb8a52,
- 0xd21c51e3, 0xbb70bcb0, 0x4213cfcf, 0xcb8c2ba8, 0xf5848f35, 0x4bc59746,
- 0x90fb7d38, 0x6cacaf7c, 0xb213f3d4, 0x9c8de85d, 0x1bb8da62, 0xfaeb9fcb,
- 0x3bcd14f2, 0x1819e683, 0x01f51cb7, 0x56e3039c, 0xe93a8a14, 0x0d172c83,
- 0xf81ede10, 0xf7979256, 0x7e0763c7, 0xbfac03fb, 0x97be4777, 0x8907f470,
- 0x82ab3f82, 0xb07b1a13, 0xbc1acd3e, 0x3e748c2a, 0x967fe694, 0x6b36e0f4,
- 0x9beb1270, 0x8d126363, 0xfbc0692f, 0x877f6310, 0x32d538fb, 0x1fee2471,
- 0x88d82f39, 0x11ccb7cf, 0x45e6367c, 0xee28da9e, 0x3c5b37bc, 0xf9c0e837,
- 0x06ff885b, 0xc074433d, 0x03c72758, 0x45a47910, 0x61e443b2, 0xbce260ff,
- 0x1f192d49, 0x359cf7d6, 0xcfaebef1, 0xe68057d8, 0x9b933d58, 0x27399e78,
- 0x6c4cc936, 0xd4ccff00, 0xb6af4859, 0xfa7de7ad, 0x7de8ee8c, 0x7f4eacfa,
- 0x9bdf03a9, 0x7cfc7ef5, 0xdc7d3cc8, 0x299410d9, 0x89e9cf5e, 0xdf4f37ee,
- 0x1f3bcfa7, 0x54cdfcfd, 0x868dbe3d, 0x8e7991d1, 0x33ff7d3a, 0x0a427c78,
- 0x3af929e9, 0x516ef919, 0x3a9d9865, 0xeb5a37ec, 0xf90e5fb1, 0x85971b47,
- 0x11779da7, 0xa8f56dfd, 0x93f216d0, 0x7b0d2e1e, 0x770d3c2a, 0x7988d4c2,
- 0xf837bd74, 0xe0bef838, 0xdc9eb4e3, 0xbac7cf9f, 0x410cd3b9, 0x739d7875,
- 0x820d3e75, 0xd3a0f3e0, 0xd99e7cc2, 0x61e9cbf5, 0x98f5647c, 0x5f588d40,
- 0x6a089a82, 0xe7b53f84, 0x65d546a6, 0xce3a3e43, 0x9f8fae98, 0x351d1de4,
- 0x0c37818e, 0x5a9abdf9, 0x643849de, 0xe31d63ba, 0x13d9948e, 0x3e2dc6a2,
- 0x64272b1e, 0x2476e11c, 0xd7089ff2, 0x70a2569f, 0x80772cc6, 0x3fb30038,
- 0xc9706254, 0x68ec9976, 0xe7e8d9ee, 0xc8cbb4e6, 0x84fc72ed, 0xef9f3fa9,
- 0xe9f9fbfe, 0x99f9a2d2, 0xcfcd1156, 0x3f345f74, 0xf3455733, 0x9a3f946d,
- 0x4dd6632f, 0x6abf6a89, 0x7d545163, 0xa37383fc, 0x006167fa, 0xdc4fac8c,
- 0xffaa24ba, 0xa22beda4, 0xba9f93ea, 0x5e7faa2d, 0x7b544d70, 0x2baacefe,
- 0xa8617f92, 0xb11faa2e, 0xf20df4d7, 0x1fedbabf, 0xeff9e6a2, 0x34a2ff96,
- 0xcbaf2f3d, 0x438e997f, 0xc7fa1a5c, 0x4538e1a2, 0x93f215e9, 0xbe37f6ae,
- 0xa04bfca0, 0x53bce544, 0x1b780960, 0xd909edb1, 0x1b5f9127, 0xa136ac83,
- 0xc13268df, 0x8ff7f23a, 0x879c4c9a, 0x2abcec34, 0xaa8be04d, 0x9ff7e134,
- 0xf8a69b46, 0xeccff066, 0x78449ede, 0xa0993643, 0xe29ae29b, 0xc671bf65,
- 0x716be101, 0x7034793e, 0x7934ab5e, 0xa899b2f6, 0x329bf287, 0xd1e51fef,
- 0x7d71507e, 0x3f1fc78d, 0x8b9ff941, 0xfa4a9b0e, 0x03faa72a, 0x7d70b714,
- 0x2461e7a1, 0x3eaf795e, 0x49f6893c, 0x67957d46, 0xbfea66e3, 0x93858eea,
- 0xf43aff68, 0x498e8efc, 0x88721165, 0x388adf5c, 0x697be8f8, 0xc4673f22,
- 0x6aacdb87, 0x6bca0f63, 0x3ffc2c9a, 0xa5ef85c6, 0x903ffae1, 0x9c0b361e,
- 0xbad33015, 0xde724e31, 0xba8085df, 0xe194cb0e, 0x8d7ea478, 0x84c1f54a,
- 0x26f9dc68, 0x08fb4411, 0xffc72a5b, 0xbb7f0d5b, 0x36f98f2e, 0x3fee88e8,
- 0xc144f778, 0xd7236fcf, 0x2c67df90, 0xdd061d62, 0xfc3f75e7, 0x7b87eea9,
- 0xe446ffc9, 0x78edd79b, 0xf5f0893c, 0xa7815c99, 0xe8cfe78d, 0x4d267d72,
- 0x3bf5e9e0, 0x79919c13, 0x2b90eac7, 0x36db5eaa, 0x423679ca, 0xeb1bd70f,
- 0xad0a4bf0, 0x3f6e8363, 0xc93d9dd5, 0xf1e301b7, 0xdc70d3a7, 0xbf171d9a,
- 0x37de8fbd, 0x3888640d, 0x6ef9e01a, 0xd7180f79, 0x4415f2df, 0xd297d2e1,
- 0x25e57e44, 0x95cb0ba2, 0xdf513858, 0x776c6256, 0xfcc6f951, 0x7c3bb272,
- 0xbeb0961e, 0x84cc13ac, 0xb3fb96d3, 0x53f4c4cc, 0x2f677de0, 0x9a5f6d2e,
- 0x04dcf3ca, 0xc5c5333e, 0x9d5dbf77, 0xc686fd44, 0x4319c633, 0x2bd459b9,
- 0x419cc057, 0x246b9af9, 0x9f380dc6, 0xeefb9e8d, 0xe299b318, 0xbbdf31af,
- 0x0ef0bfe0, 0xf00ac5ea, 0xf8c6b8f2, 0x7e51a900, 0x90cb03f8, 0xbf24ed1c,
- 0x98532eba, 0x677539f2, 0xd1fe7cac, 0xebf030df, 0xdfce9007, 0x57b17d55,
- 0xbb7fba42, 0xfb57e07a, 0x4fadf9f0, 0xb5c5dfa1, 0x87fddb66, 0xc3ce22d3,
- 0x917ddcce, 0xc8f10ced, 0x33924ff3, 0x25eac97a, 0xeaa0f8fb, 0xbc489ca5,
- 0x616d227f, 0xb307bd27, 0x479ee2d3, 0xab2beec4, 0x6ed93f48, 0x8699c655,
- 0xeba7de5e, 0x930bdd65, 0xd25d79f9, 0xfd447ad0, 0x57f39979, 0xbcac0775,
- 0xd7477fbf, 0xbf17aa87, 0x9f991998, 0x54bd416b, 0x7274a873, 0x2a9ce749,
- 0xf1cf66f2, 0x6fd4a9c1, 0x21efeca3, 0xe978393d, 0xefaa64e3, 0x5e4bf379,
- 0x6574dc0f, 0xf323f7f4, 0x9b5cf922, 0xf92ef034, 0x567dea93, 0xa550f295,
- 0xdd8ef2fb, 0x4e9af58e, 0x9eb83bf4, 0x239eae0b, 0x6a7ed34f, 0x979404bf,
- 0xb02709aa, 0x9569af73, 0xaac79482, 0x65bddb6a, 0x9aabd60c, 0xba931797,
- 0x3f0b26d6, 0x0522d356, 0xa7f03c69, 0x748a7f31, 0x357d28db, 0xb00b1fef,
- 0x18a8efbd, 0x787d5cff, 0x4ff459ea, 0x9d9f2d7d, 0xb4363a23, 0x763f3959,
- 0x196c292e, 0xd85ef383, 0xea02852d, 0xb9f6ddb0, 0x5d6a3ec4, 0xcd0b31e8,
- 0xe5b9eebb, 0xfb0f04d9, 0x90b49df6, 0xfad75c7f, 0xbcfeb958, 0x20fb8458,
- 0x9dfac5db, 0xf322931d, 0xfc21f749, 0x81f8c883, 0xf70805f4, 0x09e39082,
- 0xdaab3e5d, 0xbb123627, 0x7dedafd0, 0xe6bf625a, 0x3bdf9374, 0xffdfebb8,
- 0xffdde695, 0xff98932f, 0x7fc657c5, 0x4f1805f0, 0xc0f3e8d4, 0xda1653f9,
- 0x9ab4d61f, 0x173bc5cf, 0x77dbbefa, 0xf0c67b95, 0x571636fe, 0x3880b16f,
- 0xc10099b7, 0x381e29e7, 0x91ab2c06, 0x07511f9e, 0x0e7147a4, 0xdd60d658,
- 0x71467646, 0xc608e3c2, 0xb9d717db, 0xf70f9e15, 0x9de31b08, 0xedead657,
- 0x858f6aa5, 0x9e3570f2, 0x75e90b5e, 0x7113f84d, 0x51f6df5e, 0xbf6716b9,
- 0x7e16ed5c, 0xc303d0d3, 0xa7d2ebde, 0x87985db0, 0xc6c860e2, 0x66b85f76,
- 0xdd53e280, 0xda0ed47e, 0x03fcb817, 0x6f607744, 0x2beb4a82, 0xccc9f7dd,
- 0xfe79889e, 0x5187dba4, 0xa3f979af, 0xe7e266a9, 0x2aa68f9e, 0xfbcfc349,
- 0xe2eb1c32, 0xddaa55e5, 0x4e6f4e22, 0xb68f9df6, 0x186f0483, 0xb769ade7,
- 0xda07f9f3, 0xe28e96c1, 0x75b83b48, 0xf3d20edd, 0x168bd976, 0xcb6d3501,
- 0x3fdc0dfd, 0x91e24bc9, 0x480616db, 0x8fa7650f, 0x8afe13f5, 0xcfd4cdf3,
- 0xae52267d, 0xe91b7fdb, 0x4f08e291, 0xd46bcc8a, 0xd17e7a98, 0xb75c9121,
- 0xaf9a266b, 0xc96fd808, 0xef0f5f0e, 0x54338a9f, 0x9e1ec7da, 0xa7c40e51,
- 0x38901e9f, 0xf54e6b5f, 0xf922cd6f, 0xbfb9951e, 0x010bf0e5, 0x9bee973a,
- 0x9f44c506, 0x4e9fdeb1, 0xe38c830b, 0x2f042e6c, 0xff79bb4d, 0xdfd21e2d,
- 0x611fa69f, 0x86f7617c, 0x234afc80, 0xe7ca06e2, 0x61420bd8, 0xd721271a,
- 0x3ce32c57, 0xf3276e79, 0x7bf562cb, 0x4d941f29, 0x4d875c75, 0xfa23adf1,
- 0xb144ee6c, 0x657b1e9f, 0xb23eba79, 0x1bce857f, 0xe92f9cfd, 0xed3d0b33,
- 0x5f180abb, 0x399d1df3, 0xbe09a4d4, 0x6b2e76c1, 0x46a63adb, 0xf044dbc6,
- 0xdf79e8db, 0x44bc5bfe, 0xd75139bf, 0xb6448cf7, 0xfff9d88b, 0xe499f499,
- 0x35b35a6e, 0x7c4cf88b, 0x7bf64753, 0xf067ef5a, 0x2e7f1403, 0xaa922bd9,
- 0x8d0fcbc5, 0x4e3c9777, 0xea9cdd72, 0xf01575cb, 0xc300acf1, 0x76b8c49e,
- 0x57fffd87, 0xe91fff64, 0xf8a2dcfc, 0x4ddfc46d, 0xf16cdd7a, 0x7fb64ea9,
- 0x0ff34a9f, 0xfc746fad, 0xf6e9b5f5, 0xff8265ba, 0x4fb7d71b, 0x15399f5f,
- 0x4bc68df5, 0x4e67ee06, 0xff48060e, 0x78a0929a, 0xec3e3e13, 0xdd90f72a,
- 0xc5f4396d, 0xa6f7b238, 0x2807af24, 0xd66075af, 0x2dfbb22a, 0xfd636fa3,
- 0xbc85f4ff, 0x9e623922, 0xad256913, 0x697ebfe4, 0xcfe2cbac, 0x42fc75a5,
- 0x5d6323d7, 0xabdf6ee9, 0x11bc88ee, 0x915f758c, 0x9fbe80fe, 0x17f1eaf3,
- 0xff9c73f7, 0x2f4487eb, 0xd6ee279d, 0x3e02b771, 0x783b1bd6, 0x1a55c655,
- 0x1f7ba31c, 0xd8261d8d, 0xe4a6cb46, 0x5d39c454, 0x36326cb2, 0xb70d9a7d,
- 0x4c6c74e6, 0xebba6fed, 0xbd213496, 0x0b2021fb, 0xaf9d167c, 0xa4d24d00,
- 0x6bc53cc8, 0x14f3f155, 0xc91bf8cf, 0x9e56ff2e, 0xb4d84e62, 0xf7f292da,
- 0xbace2be7, 0x9f3df7a3, 0x2a2655ba, 0x31f42b94, 0x8a0c4e14, 0xa74c17bc,
- 0xf133537d, 0x067bff12, 0x2df6cad7, 0x5cdae5f5, 0xfbee4f68, 0x8b1d6db7,
- 0xd62d9776, 0xfa46f54f, 0x3dc0a77b, 0xd78ff943, 0x46ee30a6, 0xfef3273f,
- 0x12d3a9df, 0xc462b723, 0x88f7c06b, 0x27f2a352, 0x265f23e1, 0x4aed7e93,
- 0xb922df55, 0x7cc9740c, 0xe941244f, 0xd8e2b8b1, 0x03c23ed9, 0xd38bf7e8,
- 0xd6c43ec5, 0x6d17ce26, 0x317ec6aa, 0x269ce9c1, 0x79c5d847, 0x579fc8b7,
- 0x9c60f91f, 0x05dc3105, 0x02e4f1d3, 0xdec37f1c, 0xc34a6496, 0xf6f33fad,
- 0x5392ba4c, 0xe91df8a2, 0xa54ffeb8, 0xc236391d, 0x53835ba9, 0xf0a13f89,
- 0x93f21484, 0x94040a85, 0xf1f138a2, 0x14de22a9, 0x87c53cd7, 0x3ed850ff,
- 0xe5e12d7d, 0x2f58b0da, 0xa6c661cd, 0x7ae036bc, 0x2a635b5f, 0x6ffb578d,
- 0xbf934607, 0xe05d297a, 0x4d2f179a, 0xa02bef11, 0x74acff50, 0x41e7ae97,
- 0x5f0be513, 0x7d8cf3d2, 0xcfdc4c97, 0x6db0bf98, 0x3d44eca1, 0x3f6f0828,
- 0x76cd79c4, 0x4df24aab, 0x3f040e78, 0x771813da, 0x0c5c1ed6, 0x5dfae714,
- 0x7db095e0, 0x6fc0e257, 0x0e061f49, 0x773a5558, 0x876e704d, 0x977f1c54,
- 0x0f2b4f7e, 0x31c5b215, 0x2f98dcfc, 0x94e7fda1, 0xe0bd2413, 0x6504dff3,
- 0x88e35c3b, 0xd31277e4, 0xd5eba25d, 0x89b0c4ae, 0x260645ce, 0xe9875ee1,
- 0x7813a61a, 0x3cce835e, 0x2cbbfbf6, 0xe07ee703, 0xa49cba66, 0xe8207907,
- 0x2ac9f684, 0xa704d1f9, 0x7048ebc6, 0x3480deaa, 0xa9daae92, 0x6ed0fc08,
- 0x35e7251e, 0x6baed877, 0x36eb8713, 0x135d85b4, 0xff8f3f40, 0x8f3a36d5,
- 0x8393aa1f, 0xfefc3d99, 0x6c2fe92d, 0xf9cb1a6b, 0xa28c80bd, 0x949963b6,
- 0x7954eb4a, 0xb545e87d, 0x07c122f4, 0xb767afba, 0xfea1f689, 0xaa0ee7a8,
- 0xaf3f443b, 0x925f69d5, 0x8742f6c5, 0xf07843d7, 0xee7c297e, 0xded7b45a,
- 0x05297cc7, 0xd35eaeb8, 0xb19a07a1, 0x87569fdf, 0xe93ee872, 0x1aff5673,
- 0x3e57cfd2, 0x2148f35c, 0x665ddbf9, 0x9df9256f, 0x18cfc09e, 0x5668bf87,
- 0x1dd845b7, 0xe0c81d8c, 0xf33180fb, 0xf4d99ed4, 0xfdd7c233, 0xce9525fb,
- 0x03cdfbbd, 0x9aee88e3, 0xe85a3ff6, 0xfeed64be, 0x4b4f188f, 0x9a1afe19,
- 0x035b766f, 0x039b6bdf, 0x1b5ef9db, 0x9fbe43fa, 0x7f08f218, 0xe73a7832,
- 0x390886d9, 0xec2e913c, 0xe3fc060d, 0xebb55e29, 0xf6907af6, 0xedee58dd,
- 0x8d2275b8, 0x07cf57bf, 0xc035ef18, 0xf7c431a1, 0x971af04d, 0xa0fef3c6,
- 0x967a4152, 0x4eedaeff, 0xa3ffa22d, 0x3dbf02e9, 0x66702e9a, 0x89bf8676,
- 0xf1df5de8, 0xd69925b1, 0x8e343679, 0x4521b9f6, 0xf1c6714d, 0x1bf64323,
- 0xcab54f63, 0xd7fa8580, 0x2bf6079e, 0x14a6ef28, 0xef4bdf94, 0x8d594db6,
- 0x4ca2f7cf, 0xe2ae2852, 0xefe294fe, 0x0c6fb35e, 0xe7786ff5, 0xc7e4a9f3,
- 0xe74f481e, 0x607e7ff5, 0x1be278fd, 0x22497fea, 0x606ed9d9, 0x69d866bf,
- 0xbe29d901, 0x5ffa405f, 0xf63cf54c, 0xdd2cbbcb, 0xf72ed84b, 0x12ec809a,
- 0x01ed9ff5, 0xf849dff5, 0xf689c0ae, 0x664fefc0, 0x6dd5df3b, 0xa32718d2,
- 0xf5c49f5f, 0xbea91b92, 0xc9ccbbab, 0x05f74e76, 0xc35ec88a, 0x109c7887,
- 0x9d1224c0, 0xfca8be04, 0xe9993b88, 0xe7e5fc36, 0x86e3d06e, 0x75c5e29a,
- 0xca3965d8, 0xa4e2223e, 0xf4711ba8, 0x9edb33c9, 0xee817b40, 0x0fdc28d4,
- 0xffbf0bef, 0xd5563d5d, 0x59773ebd, 0xeeb3ae33, 0x07edcc84, 0x585e7df5,
- 0x7a4393d7, 0x86e2867e, 0xefdc5d3a, 0xb033e7a5, 0x675df74e, 0x094b1b6a,
- 0xd8aecd63, 0xb9ca987e, 0x412950be, 0xbaabf9c8, 0x99859b0f, 0xb5fe93e7,
- 0x9f2eba1e, 0x9ff5cdee, 0x920242b1, 0xc0e5fad8, 0xb5c45f6f, 0xf910703d,
- 0xe14e271f, 0x10ff5872, 0xcf018d6f, 0xc97ef6c8, 0x4bbd23f0, 0x5afb1f48,
- 0x123ae1e5, 0x4d8a8352, 0x3fd277f5, 0xbac016dd, 0x9f7b433f, 0x99c7e254,
- 0x3f49f7fe, 0x997e4ffb, 0xf7b96641, 0xb7c7d8b4, 0xd27cb45a, 0xb809d69f,
- 0xa7a38db5, 0x3c8ba5af, 0xe215b14f, 0xa57e4b9e, 0x009cc1c7, 0xfef1223c,
- 0x5106765c, 0x655a17ee, 0xe7f882cd, 0xce56043c, 0xe7a37f23, 0xfd01ef6f,
- 0x941fe1a7, 0xf57abdcf, 0x182bc21e, 0x627deeb7, 0x89bfb9c4, 0xbb6d69f4,
- 0x6b84ff04, 0xfc4cf75f, 0x5e46097b, 0x1db6beeb, 0x3ca0c647, 0xee8b9eab,
- 0x9ee861b7, 0xbdf7887b, 0xefa39a1b, 0xae957c1b, 0x308996e3, 0xea0b7091,
- 0xb307fb13, 0xd4569d02, 0xfd3257df, 0x7e5e109f, 0x84f824c9, 0xf2ed957e,
- 0x671eb713, 0x1a3f844a, 0x8f7c00b8, 0xe8676f28, 0x99d7dd30, 0xa5e59cdb,
- 0xa22ae639, 0x165b6e7d, 0x825019c7, 0x9837dd32, 0x19cbf9ad, 0xd3b4075f,
- 0x9d642f74, 0x89c127ee, 0xa3bf287f, 0x8e9d6baf, 0x460beee7, 0x82073dd3,
- 0xdacf348d, 0xd1fee29d, 0xbff19dfa, 0xc7d5a813, 0xc9d4f0d9, 0xac0e9423,
- 0xabf7450e, 0xdb53f9d5, 0x05bcfd16, 0x9f181278, 0xfccf7d11, 0xfc43ef4a,
- 0xc5f02cc9, 0x4638fadb, 0xc219b5fb, 0x7920d67f, 0x410ddf24, 0xb37a4839,
- 0x0b240a4e, 0xd58e0b7c, 0x865df748, 0x65f7e8be, 0x73f9d6ef, 0xbc2fae97,
- 0xfabf7c2e, 0xe7482919, 0x24ff7780, 0x427bfe9a, 0x1f49cbab, 0x5d6af562,
- 0x6df199b3, 0x10b46c15, 0xabd58dbe, 0xd97d21aa, 0x1638a16e, 0x7e354fab,
- 0x0b7432e9, 0x4b7ffe5c, 0x98737af7, 0xffeb4cf3, 0x3ca5e4a7, 0xdfadbdd4,
- 0x745e50b1, 0xf9087da4, 0xa27a1956, 0x5defebaf, 0x7c86edcf, 0x9614c0a7,
- 0x15da456f, 0xf1a283ee, 0x50cb6ef4, 0x7cf3929e, 0x38139d83, 0x51e86e3f,
- 0x3ae538ec, 0x14fc5f2e, 0xada17970, 0xa2f84ed4, 0x2bc9b8ff, 0x4c7f9ca9,
- 0x4c3e442e, 0xe103203f, 0x89f6fe8d, 0xfe90078f, 0x37c513a2, 0xfa7cbe52,
- 0xd83f8c09, 0xf8b3a7be, 0x115fe457, 0x7d91a4e1, 0x4ecaec2f, 0xc783bdfb,
- 0x7fddf8e1, 0x4af1e8bc, 0xcbc7c3f2, 0x095c698a, 0x787ee9db, 0x1a871e91,
- 0x7bd9178e, 0xfdd1e222, 0xbedf2219, 0x47fbf3c5, 0x78b05f69, 0xf94bd9b7,
- 0xff66c58e, 0xafa404a6, 0xdbc905e8, 0xe91db380, 0x8d24f43e, 0x52a4f68b,
- 0xeef166be, 0xf6a21def, 0xd3125dda, 0x28bedfdf, 0xc7c5177f, 0xb8a5eca0,
- 0x577edfd7, 0x7384bdc1, 0x7053dc0e, 0x477cc457, 0x595f8552, 0xe399957c,
- 0xfb68ef71, 0xcf292b2f, 0xff60eda9, 0x1eeafbd0, 0xb0577f0b, 0xae0f024b,
- 0xf0e788f3, 0xbd0f89af, 0x085a4efb, 0x9eb697e4, 0xf1c4f4b4, 0x017946cf,
- 0xce6171b7, 0xf0b76ebf, 0x7fbdca3d, 0x6b7ad0b0, 0xf388fb9e, 0x126d5569,
- 0x67aaa7fb, 0x794aa0e4, 0x58af039e, 0x9a6b3f48, 0x8accc825, 0x3b73376c,
- 0xffaa51f9, 0x65f859b1, 0xe8d7ef43, 0xbde86e7a, 0x746b0761, 0xd6d775ff,
- 0x17bf3d68, 0xf1a32db4, 0x579a7bfd, 0x7ba03df3, 0x5ff7c7b6, 0x4b5c1f86,
- 0x2b8c52fb, 0xee8a9f6b, 0x7e90df77, 0xc7bfd807, 0x3257c9fa, 0x3cd8f3f4,
- 0x1efd23c8, 0xaf19af0c, 0x7e7d3da0, 0xc43c6ab2, 0xd71e3bc9, 0x8f1180f1,
- 0x8e26c307, 0xfafdb167, 0x285a2eda, 0xfe76d68e, 0x796bf199, 0x872c67fb,
- 0xbe0ef6ca, 0xf83d7aaf, 0xaf1f1037, 0x093bb76f, 0x08f65747, 0x6ed25fbb,
- 0x6a25060d, 0x7c91350f, 0xef8a0ffb, 0x4aaf023b, 0xf740a38c, 0x7e756b7f,
- 0xb7f9d5ae, 0x6367f716, 0xbe8adee8, 0x772fbeff, 0xe2ba11c7, 0xdf3fa351,
- 0x993875d0, 0x8404b8f8, 0x12125a7f, 0x8790c9fe, 0xc6465f11, 0x936f81d1,
- 0x5bb7d73c, 0x52f8bef9, 0x6d2d3fdd, 0xc593df16, 0x51fe8bfa, 0xddff9176,
- 0x8d8de82b, 0xd1ad35a7, 0xd232bbfd, 0xea0fdfd9, 0xc313f878, 0xa8f2e8df,
- 0xe53b001c, 0xb2a897e7, 0x756fc837, 0xe77f342b, 0x63cf8954, 0x2989d53b,
- 0x194beef1, 0xce3a9be5, 0x28cbea37, 0x43fd864f, 0xc88eedce, 0x998dfc7d,
- 0xcd54af02, 0xcf240391, 0xb2cf7d88, 0xfbb8aca2, 0xba44c81e, 0xd77b18df,
- 0xee45a64f, 0x391db47b, 0xf23f67a4, 0xf7495e3c, 0x859b6a8c, 0x8d9be87f,
- 0x8e10a6e3, 0xb5c5c607, 0xed20d6cd, 0x4f516a4f, 0xd2307bf8, 0x76bfb20f,
- 0x07e91169, 0x991c1bee, 0x3a72cf48, 0x2ff5c4aa, 0x8e38c36f, 0xfb2f2fc3,
- 0x2baaf58c, 0xf91bac5b, 0x1f6f1996, 0x6a1fec61, 0x6a9c092e, 0x7a51af3c,
- 0xd3511f78, 0xb749ee2e, 0x5c62fa1e, 0x7fdbd216, 0xadc63fe0, 0xa64172c6,
- 0x25adbf88, 0xbee98fa1, 0x6cbbe7cf, 0x90e8f171, 0xd89a97bf, 0x3dcc6a0e,
- 0xf6578c19, 0x859c2e23, 0x4fedf37e, 0x7ad1df79, 0xca4ee128, 0xf1adf5c7,
- 0x837e778f, 0x13601a9c, 0xd04ddae3, 0x9ee125c4, 0xd6b81c48, 0xdd0fee29,
- 0xaa49c7ab, 0x7d7a8c3f, 0x505df62f, 0x03eecf14, 0x2349e65b, 0x1bf0dded,
- 0xafbebad5, 0x85b1d82f, 0xf163e08e, 0x476eb551, 0x2e39fc88, 0x1ba2e2c6,
- 0xb4f5a333, 0xc644ede1, 0xb25dfdb9, 0xc8c47293, 0x268c5fd7, 0x7ef887dc,
- 0xeb3c9c42, 0xf65ebaa7, 0x0dbee7ea, 0x9be665b3, 0x0d288e69, 0x63fc851c,
- 0xe93fe97d, 0xcb1c5208, 0x04caf83f, 0x9dfaff92, 0x2445e7d1, 0xdfdf3f3f,
- 0xaafcb20a, 0x433e7643, 0x3a5fda32, 0xd214caf8, 0xbfb786b3, 0xf97211cc,
- 0xbee2c722, 0x29467d3c, 0x6bff6249, 0x77fec492, 0x4c93d2af, 0xfddaaefb,
- 0xfef22fb2, 0xbbe721bc, 0x4501fd75, 0x65d7f3ec, 0x686f5caa, 0x3a617a17,
- 0x7f9c4a20, 0x98f3c8a5, 0xed11fe79, 0xdf2fa825, 0xe880b710, 0x9ad7d942,
- 0x6aef5807, 0x9e989a4f, 0x198393da, 0x05ef11d9, 0xf24cdc68, 0x801b0d7b,
- 0xc81d88fd, 0xefa52ebf, 0xf4beb10f, 0x59c604fd, 0x523c2647, 0x64adce29,
- 0xc0f5bf20, 0x239355db, 0x3d05fffd, 0xc1f103ee, 0x09e72843, 0x87cebf31,
- 0xcf42b04d, 0xae3d0813, 0xee2c71d2, 0x8ec89aaf, 0x5757f763, 0x0e1b938a,
- 0xc7f28158, 0xf9581fb5, 0x07e7d03e, 0x1dfef2d6, 0x9327f92e, 0xffbf019f,
- 0x381f2a6a, 0x3d3276b8, 0x7de0fcff, 0x53de7357, 0xaf9514da, 0x1e7d1008,
- 0x797f51c2, 0x97c276f7, 0x90e30a5d, 0xefd3aea2, 0x9eeaf9d2, 0x9b7f3356,
- 0xc677bd59, 0xc22481e3, 0xe94b454f, 0x9d3d9dbb, 0xe21feb0a, 0xd947032a,
- 0x289d4719, 0xe3851c66, 0x165c82f8, 0x71a4ab1f, 0x5314944f, 0xc9db0937,
- 0x1c274d9f, 0x55c618e5, 0x9cff3d06, 0xdfd9f829, 0x13f9c091, 0x3d082609,
- 0xba28ec83, 0xcebeb437, 0x9b436438, 0x86bdf51c, 0x4ceedef1, 0xd7b0ae71,
- 0xa490b3d0, 0x16ed1eb1, 0x3db686e5, 0xf58eb419, 0x49eb10e6, 0xb459b343,
- 0xd02512ef, 0xfe0ccdf9, 0xfc4038d8, 0x508f4639, 0xc12c4b2e, 0x77db84b1,
- 0xea079d0f, 0xe28239f7, 0xe7635d5e, 0x686efe44, 0x3b8f73b0, 0x4e39fc5e,
- 0xda4833e7, 0xcfb12cd1, 0xf3af6d89, 0xd1c67c88, 0x1e2fc233, 0x1c9fe85d,
- 0xa0063fcf, 0x25fbec44, 0xe6ad7e5d, 0x86e7788a, 0xdf223d1b, 0xe06c73b4,
- 0xef71e928, 0x373e04ee, 0xfc8975ec, 0x974b696c, 0xac9fdf42, 0x5066956f,
- 0xfb9f5a3c, 0x829f7f1e, 0x83f662f5, 0x6e7cfde1, 0xbbbcdd5a, 0xc7438b5c,
- 0x1f111eb5, 0x01dfe897, 0xbd57d08f, 0xd37814fd, 0x23da7df5, 0xaa735e74,
- 0xdf14ecd2, 0x4aef8999, 0xf9fdd06f, 0x199bd78d, 0xd5029d37, 0xc43fce2c,
- 0xdd32c539, 0xfba0df2f, 0x3bdf11f9, 0xe99b033f, 0x7bf6229c, 0xdfafc367,
- 0x02bf8fac, 0xf6371e34, 0x759bf5bb, 0x2fb3783c, 0x4ca5f9fa, 0x40e6071d,
- 0x10f3f90e, 0x1fbe17c6, 0x71c09791, 0xa4e1697a, 0xbe8338b8, 0xeff55703,
- 0xe434a9c0, 0x1ef790de, 0x1da3bfc7, 0xdfcd7e67, 0x80499c13, 0xc5ce7109,
- 0xe19fe386, 0xf2126e3f, 0xaa2dcfd6, 0x4346829d, 0x077017ee, 0x331f9916,
- 0xe7463ee4, 0x3df1ffff, 0x22505ca0, 0xcacf25f3, 0x3a1e31fe, 0x32f5b09f,
- 0x7015c6fe, 0x8d75c41c, 0xce35d7d3, 0x2edf111a, 0x571d5a8c, 0x97d7877f,
- 0xc471101a, 0x9e4765cd, 0x75627195, 0xfbefe248, 0x5f62c3aa, 0xf6265d5b,
- 0x02ad39b5, 0x49bcaea7, 0xbb126a0a, 0x9f44d3c3, 0x6ccb3fa1, 0x7a180f02,
- 0x5d2fc432, 0xf09da87f, 0x3e3a0dc1, 0xc9a3d588, 0xf94e5dd0, 0xc9345be6,
- 0x472af74b, 0x6abf3f7c, 0xeee4ebda, 0xa83fa72f, 0x22effc6f, 0xf7d1eac4,
- 0x0f12fe3d, 0x07bad3e5, 0xb8e21657, 0x38fef347, 0xe6a6f48e, 0x2df37632,
- 0x3b13888f, 0x7ca3811d, 0x3f45a4df, 0x6bc96fef, 0x747e21eb, 0x5ec7e302,
- 0x3a96f757, 0xbcf9ab81, 0xc09c3abf, 0xb75643df, 0xb0bbf9db, 0xc486d6ea,
- 0xdb7fe429, 0xeb1daf65, 0xcb27ad95, 0xc5959f88, 0xad4a3ee2, 0xb38bdc5d,
- 0x10b7fdb9, 0x3b7bd77d, 0x2df9cfa2, 0xfba8bf3d, 0xf58f3d06, 0xa3091b6b,
- 0xf9f7ffa5, 0x5f3a8d9b, 0x662ebaea, 0xfea9c14c, 0x26afe690, 0xfd7fec7d,
- 0xd71d0b45, 0xa5794ed5, 0x6d88ae9c, 0xefdca8f4, 0x268ee6fa, 0xf41af34a,
- 0xf93a6477, 0x707351f9, 0x82d2e32c, 0xd30fbb2b, 0xa98dffb0, 0x3afaa714,
- 0x225aa6ba, 0x0eb7bbf4, 0xf91c73fd, 0xb7498035, 0x494b855b, 0x25e3a15a,
- 0x07b5c761, 0x3e50670e, 0xb7ec97a2, 0x9277ca80, 0xdeacb1b3, 0x12792a7d,
- 0xa2bd96e1, 0xed19c21c, 0xa503f732, 0xa4e6e727, 0x3336fa48, 0x6242177d,
- 0x9c9e801c, 0xdb230b1b, 0xdb5fff1b, 0x27a4d3ff, 0x289eb6d5, 0x84f837fb,
- 0x3efe7cbb, 0xcad07037, 0xbce808f7, 0xc72115c6, 0x347f7457, 0x644b370b,
- 0x7ce873a7, 0x3b41227a, 0xbaa0ee05, 0x95256102, 0xb2c38bce, 0x96377fb8,
- 0x7d4cf7fd, 0xb84a59fe, 0xcee9ee83, 0xe737cfd1, 0x5bf73742, 0x6a5c0300,
- 0x8befe4e0, 0xe5cbc04b, 0x29785b6c, 0x5082f1c1, 0x099fbf88, 0x73ae2867,
- 0xe63bfd36, 0xe61ef238, 0x0ce7029b, 0x0e74c87e, 0xc51bee26, 0xd75ba7ae,
- 0xf09a59c7, 0xe81d043b, 0x086cee7e, 0x35fbb9f1, 0xbf9fa3d0, 0x3cc75fc7,
- 0xb9d1f7dc, 0x3b6835db, 0x208fcc89, 0xeb4f9ff7, 0xa7ade391, 0x198b2967,
- 0x9f449cca, 0x7d30ce14, 0x75f2bf6d, 0x4d6dd3f4, 0x35df57ca, 0xe283f7d0,
- 0x6f4b73e1, 0xd3ef1bfb, 0xd349627d, 0x97b1bef8, 0x7da6c7be, 0x1de9584e,
- 0x001363f2, 0xe6b3ddfe, 0xc66f6437, 0x07e01af7, 0xfb11e7be, 0xf72d06bd,
- 0x3df0c67c, 0xedfee335, 0x950ae0ce, 0x72ac6fee, 0xaddff8db, 0x9b8db229,
- 0x87ca794e, 0x21bffcd2, 0x6a40fabd, 0x2883c49e, 0x638c19c1, 0x83b2bd75,
- 0x2fd69b36, 0x22f7c669, 0xf432fac0, 0x006401ef, 0xb763b77f, 0x1e69ef8a,
- 0xa5b43d41, 0x74abf6b2, 0x2e1e1a0f, 0x6f2f0955, 0xf4bcd971, 0xe895ae5d,
- 0xdbd30fb5, 0x2ff71368, 0xb16bfb8c, 0x19b46c7c, 0x8daf4a79, 0x77cc7671,
- 0xfcda773e, 0xbfe89bff, 0x9324a93f, 0xcbfe6070, 0x3f7c3df3, 0x7758c129,
- 0xc3eb8d89, 0x37191af7, 0x6a7dd136, 0x1d31aba4, 0xe1e21ef8, 0xba149ca4,
- 0x25d8d51f, 0xa63753ee, 0x9b7fd807, 0xf3fb12fd, 0x4ed2cec6, 0x0e83078a,
- 0x6eabdf0b, 0xaa34f974, 0x4421d207, 0x3ef89ffe, 0x69bbe0df, 0xfd21ef98,
- 0xed91505e, 0xde5157d7, 0x4a1b9a7f, 0x6169bde9, 0xc0f1126d, 0xe5061ef8,
- 0x4e9519e0, 0x7befa3cf, 0xfbe4e281, 0x501c8617, 0x9d995831, 0xb90d7cba,
- 0xf8ef8d38, 0x3bea2535, 0x8f5e437e, 0x98b90a24, 0x44cc26e9, 0x71a5577e,
- 0xf061e563, 0x8f00bffd, 0x30b1ae40, 0x0030b1ae
-};
-
-static const u32 xsem_int_table_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x243bff00, 0xa3f0c0c3, 0x4aef811e, 0xf1303031,
- 0x12d18aa2, 0x6064e3ef, 0x6062e010, 0xfbe20530, 0x330c0c3c, 0x204cf480,
- 0x6066e516, 0x1ae20310, 0xc40dde20, 0x19f8807b, 0x1039fc50, 0x1be200ef,
- 0xbefd103c, 0xfe0c0c4c, 0xc4081c40, 0x95fc40c1, 0x1be18181, 0x73f6f103,
- 0x4c30330a, 0x2ff04715, 0x249fd903, 0xc1ffe7e9, 0xe90c4386, 0xa071df6b,
- 0x10acf37d, 0x7b20467c, 0x9aaa15be, 0xcdf85605, 0xbf268858, 0x18bf8d08,
- 0x0372fe8f, 0x4d5afe54, 0x81b5b334, 0xcd4909e9, 0x6efc4d3a, 0x40aac741,
- 0x3101a9ff, 0x5ff1ad00, 0x000368ca, 0x00000000
-};
-
-static const u32 xsem_pram_data_e1[] = {
- 0x00088b1f, 0x00000000, 0x7de5ff00, 0xd5947809, 0xe77df0d5, 0x9926665d,
- 0x6c81bc99, 0x44d84eac, 0x4242740b, 0x61db101a, 0x8311688b, 0x9817054b,
- 0x264f6408, 0xdac7f520, 0x0040cfef, 0x8b435151, 0x03b45a35, 0x341b0504,
- 0x024180d8, 0x2d82e00e, 0x5d6ad8d5, 0xc8a0d2da, 0x1b80931a, 0xcefc5dfe,
- 0xc9bef739, 0x82264efb, 0xf5ffffb5, 0xf8f8fefb, 0xf77bee5c, 0xce73ddb3,
- 0xe28ef73d, 0x8b94c718, 0xff12fb18, 0xdd98c7be, 0xd71b18c6, 0x2356329d,
- 0xcf2d4ad2, 0x03d058cd, 0xac62ccff, 0x9785addc, 0x653633a7, 0x5ef91a87,
- 0x4837e412, 0x6de43b61, 0xde549d7b, 0x23e79ebe, 0xa0cfcd6e, 0xc83aa3fc,
- 0xdeded04b, 0x5065c0f2, 0x6643b9de, 0x91dbb11b, 0xc2963671, 0xe30731d8,
- 0xcf90597f, 0xc9c0ac66, 0xf61be5b3, 0x45f6c5cd, 0x84e6764d, 0x1577cafe,
- 0xf20cbcce, 0x86550785, 0x2f37ca55, 0xbe43fad3, 0x60352c38, 0x9f3263be,
- 0x1ca7685f, 0x3bf50cde, 0x37292d3c, 0x553b18b8, 0x8d5e60e5, 0x4b776ab1,
- 0x18a3f5ca, 0xcf6f092b, 0xf52576c5, 0x3a970f92, 0x97e6c765, 0xb6bae1fb,
- 0x97bb3e4a, 0xf12dd2b1, 0xcf923bcc, 0xfff84be1, 0xf91ca358, 0x862f941e,
- 0xb7e83275, 0x32e4d590, 0xab5fc719, 0xf0dddd79, 0xd3a5553b, 0x7cbe4638,
- 0xed038c2b, 0x7c969e2a, 0x1b0ac4b8, 0xf8c0340b, 0xb39cbbed, 0x7d70b937,
- 0x6e11b4cb, 0x1addd75c, 0xe70c2bd6, 0x717a74ef, 0x5cb41b7e, 0xbf592f28,
- 0xd5182b41, 0x96e95fdd, 0xd579d6be, 0x980d4d0e, 0x53d3a3ca, 0x47798c55,
- 0x184be774, 0xbf4037f3, 0xb36b094c, 0xff7f7746, 0x96322580, 0xcccbfd8c,
- 0x1feee8eb, 0x43df4920, 0x013fc16f, 0x6e3da15e, 0xb781ab82, 0xdbfc3ac5,
- 0xb3b78ddb, 0xd2a3c0ba, 0xdfee6d99, 0x3c401f48, 0x106a7cc0, 0x11ae904e,
- 0x644cf3f3, 0xdfe81493, 0xc4ba67e3, 0x918f5f7a, 0x9f2ca8d6, 0x420b58c1,
- 0x78cafda3, 0x116c6bc8, 0x93f631f3, 0xa9fed915, 0x059fbf90, 0x57bce2e6,
- 0xc4228148, 0x690d6313, 0x24abbf48, 0xffd71b36, 0x94349c03, 0xf407eaaf,
- 0x99af7009, 0x9649bd96, 0x3093dcc4, 0xbdc4f05f, 0x214fd4e9, 0x3f42a3f5,
- 0x8fdfcf43, 0xe9639b9e, 0x322dcf47, 0x7ea4a9fa, 0x4fd6179c, 0xeb04ee4d,
- 0x8c4b727c, 0x7ea4ee7e, 0x2eb617dc, 0xd6898afd, 0x46515cf9, 0xf54e24fd,
- 0x97d400b1, 0x2d607a0d, 0x5dca197e, 0xef6389f5, 0x98ba6665, 0xdff912bc,
- 0xa6625c0d, 0x389c848b, 0xfa261d0b, 0xd0f258fb, 0x5bec7e93, 0x44830f22,
- 0x5f1a3512, 0x5c91afeb, 0x41dfd498, 0xbbfa3bf9, 0x31dc2e48, 0x0eb17021,
- 0x59b1c0f3, 0x816bc83f, 0xe831eb6f, 0xb129e61a, 0x36bd4c34, 0xefcba34c,
- 0x261c3956, 0x88dbf80f, 0x683ed023, 0x08911ceb, 0xa4d2f5f9, 0x365c205f,
- 0x27c11b33, 0x5895664e, 0x48cece2f, 0x9e9ddd3e, 0x826429bd, 0x8041ead3,
- 0xdfbba97f, 0x0d206ad5, 0xbb2b6be9, 0xb6f48421, 0xa7ac106a, 0x854f633f,
- 0x14848fae, 0x20a83f68, 0xd769e10d, 0xe3cdbf80, 0x28fe306b, 0x1c19ff1a,
- 0x3f8e0777, 0xf6f8e7ae, 0xf1963921, 0x2c8b831d, 0x18343be3, 0x177de81f,
- 0x0f8c55bb, 0xd8c09bf0, 0x685ba1f3, 0x22e0fb7c, 0x8d6eff1a, 0x8fc65915,
- 0x05ff1aeb, 0xdea5f71c, 0x82643fd6, 0x4b83fd75, 0xf8d7ebac, 0x0b655ffa,
- 0xb471f8c5, 0x16875ffe, 0x2e0ff5f0, 0xf3b7ebe1, 0xf7c6bb7e, 0x75ffc174,
- 0xdeadf71c, 0xa2743fd6, 0x9517fd75, 0xe76fd759, 0xcacbbfe3, 0x1a2ef8c5,
- 0x1950bdff, 0x6545ff5f, 0x0f66be34, 0xb48e90f8, 0x61957101, 0x040d9f18,
- 0x19254886, 0x6474a7e5, 0xfda0c61f, 0xe084363a, 0xa71c4770, 0x80e2cfbb,
- 0xf2dd5cde, 0xa381858e, 0x08559e40, 0x9fad2f9a, 0xa59ca1a4, 0x0b7b9072,
- 0x341754c5, 0xb0dfb4c9, 0x70f0f675, 0x937b6f98, 0x82fcc21c, 0x65879775,
- 0xbcd8efda, 0xb0a76c3c, 0xf0ff7e08, 0xcd1bd1a1, 0x174e8aeb, 0x5ac7a8d6,
- 0xe7c47c2d, 0x46cc9a13, 0xa6fcc256, 0xeb8c1121, 0x39031fce, 0xbe7e40ca,
- 0xd314720f, 0x078c2ae3, 0x9c828fdf, 0x6f999a65, 0x3c7df196, 0x991cdec4,
- 0xff827282, 0xbc38531d, 0xc2912d8f, 0xd6cfff08, 0x3e50d22e, 0x0789ac2d,
- 0x23cf77a0, 0xb9d4f028, 0x28de1ecb, 0x08bd3c11, 0x15891b9f, 0xa033fb19,
- 0xb6801fb5, 0xa5afb6b0, 0xbc2c2ddd, 0xcfea0d32, 0x483f935f, 0x3cdff587,
- 0xc6563edb, 0x07f983fd, 0xd98f88d8, 0x630e5b00, 0xaad71bb3, 0xe3732003,
- 0x56fdf56c, 0x0139fb53, 0x22e6fe6b, 0x0d5dbe6b, 0x37d436ab, 0x01b6258a,
- 0xd2b5bdfa, 0x938c6e5a, 0x78e1f528, 0x20fde315, 0x56f7cf85, 0x67e2c74c,
- 0x573af09d, 0xf98d6de7, 0x5952ef04, 0xd6cbf684, 0x4ff84664, 0x9d017aa6,
- 0xbe7a3baf, 0x3f875573, 0xf733e60f, 0x19e0994e, 0xbdd6ff3d, 0x18db7ef1,
- 0x563f6b48, 0xd7a30491, 0x79ff3d13, 0xa3d7a34b, 0x1f961e93, 0xe9cefe8a,
- 0x829e9a24, 0x1efa934d, 0x6f2bd535, 0x51efb2b8, 0x6e957d13, 0x17c96599,
- 0xea58e787, 0x5be6d617, 0x14d617ca, 0xafe7ca5b, 0xe7c9645e, 0xd4b4ee87,
- 0x9974b79f, 0xcad6fca5, 0x37e52c7b, 0xe4b5ad17, 0xb11e04e7, 0xf671bfd4,
- 0x6db94b06, 0x20d725ef, 0x25bf551f, 0x3e37dc33, 0x007b1d75, 0x5d4fc1f5,
- 0x71f10f8a, 0xf88d2aa2, 0x979554e0, 0x4ca6f6d2, 0xc1cb8047, 0x16715402,
- 0xad086b2e, 0x9972889e, 0x5e2cfc91, 0x1a1433b6, 0xe4adda08, 0xb5c9f825,
- 0x09008b1a, 0x174fac4b, 0xa6ca771d, 0x94f3d6f2, 0x67a302d7, 0x5b972cf6,
- 0x6e0f7f63, 0xe508bfcc, 0x00f26f4e, 0x3ee006fe, 0xf7f621d7, 0x8932f2e8,
- 0x33bf99e5, 0xfcf89cb6, 0x65b3909c, 0x6507971a, 0xcc9bf6cf, 0x8c8f983c,
- 0xf1aafca8, 0x28a8001a, 0x4f3b5127, 0x2e007a46, 0x50cbd0b0, 0xedb77f0b,
- 0x155e6993, 0xa3c61328, 0x235bc9c8, 0x1c899ca1, 0x68dd7c18, 0x7eff879c,
- 0x29aef909, 0xb6f5f699, 0x8f7de9aa, 0x3c9f882a, 0xcd544f4a, 0x5558f4a6,
- 0x55a3d280, 0x5fbe9445, 0x6b694955, 0x0f4a52d5, 0xfd288557, 0x4a6ad553,
- 0xa1aaabdf, 0x5aaa9df4, 0x1550ff4a, 0xcabdb4a6, 0x0fc1a94f, 0x4937f25d,
- 0xaec2abe8, 0xf2879d80, 0x565ac567, 0xe216dd40, 0xf21a5f73, 0x67d759f9,
- 0x3f1f5023, 0xa19d8efb, 0xbc1bdfbe, 0x77ade9a2, 0x5f49fa3c, 0xfe030829,
- 0x3b967b33, 0x9c9e38e3, 0x819d3636, 0xf867ba3c, 0x46dbbe13, 0x92415e51,
- 0x37c90d81, 0xdfa31dcb, 0x75f08c61, 0x7f313c3e, 0x016b98e7, 0xfd1ec71f,
- 0x7bf6366b, 0x717fec4e, 0x87da6407, 0x0f936459, 0x1b8265f1, 0x3b9d6bed,
- 0x0f3fbc84, 0x82ea3efc, 0x0660cb5f, 0x274904e9, 0x68db3bfa, 0xb1c20a67,
- 0xc40c3e39, 0xdc1ececf, 0x5c7e41e4, 0x8fd3669c, 0x918380c6, 0xeba43796,
- 0xd3fef32e, 0xad9fcd64, 0x9037a691, 0x5c26f63c, 0x4ae91a3f, 0x430e8fd7,
- 0x6a51a7fc, 0x4d38b3f4, 0xbf028fd3, 0x3432da9e, 0x61dfef81, 0x27d60fbe,
- 0x5d82bd12, 0xd5fff548, 0x1fade9f3, 0x358c3e63, 0x281c0fb2, 0xe86ca00f,
- 0x1e9dedf9, 0xd13e5778, 0xcd5f10f2, 0x2fa867ea, 0x5fffc1c4, 0x157ec10e,
- 0x06fd1bca, 0xfd90e41b, 0xdebdf8db, 0xf3b41e32, 0xb637361a, 0x156e9deb,
- 0x2ba0cc76, 0x1a1a5790, 0x3a2764cb, 0x92beeb75, 0x9b07c968, 0x7d96e9fa,
- 0xfc01ff06, 0x4152820f, 0x541329ba, 0x56b8a1d4, 0x23bf304b, 0x2f013f28,
- 0x2bd78941, 0x016ab477, 0x0b63912f, 0xe5b719ea, 0xbde77418, 0xef208ff1,
- 0x6546fe4f, 0xdff962f7, 0xae505660, 0xf720c51a, 0x2f9f906c, 0x9635b772,
- 0x77b940ce, 0xf9f7c6d2, 0x83cf2c05, 0xab114f46, 0xe73d46c9, 0x8e9b6623,
- 0xfb11fff4, 0x64d3279d, 0x1a6cf86f, 0x6afe73ad, 0xfa0b3eeb, 0x585f2599,
- 0xb017cd6b, 0xde90536b, 0x2ca9d60b, 0x5a5f212c, 0x9d36bdcb, 0x95642dfa,
- 0x41dec8ab, 0xbdc6057b, 0x00ca674d, 0x73f95f98, 0x43e7658f, 0xae363bfe,
- 0x7bf61ba7, 0xff3e1f71, 0xe6b0a492, 0x1a0ff287, 0x19707f33, 0x55e1f6c3,
- 0x6e42a728, 0x7accdbe6, 0xceebefe2, 0xc6be7a3f, 0x8fc3d27e, 0x6f21e620,
- 0x18e1fc91, 0x9b34da76, 0x10adf424, 0xbae037a5, 0xbe6b7a4d, 0x2f918380,
- 0x19dfca8f, 0xe9a7ff95, 0xe859892d, 0xc81488ed, 0xfa7325b7, 0x52417d42,
- 0x37c0b53a, 0x47ad3fe9, 0xd2ffe5ff, 0xff4207fe, 0xeffe96d9, 0x3ff697fc,
- 0x57fcc7ac, 0xfcbfeac6, 0x433b6db9, 0x9e4a6f20, 0x60c3c879, 0xd4a93a1f,
- 0xef00f8a4, 0x7a579b65, 0x284e0e90, 0xf3d20f21, 0x3d3cb0c9, 0x46ec3d16,
- 0xa23f207a, 0x5da125df, 0xfe84ff85, 0xdf753d4f, 0x3e67dc4c, 0x64eaacdb,
- 0x47b16d2f, 0x15afc0ec, 0xd833c58d, 0xe11fca18, 0xc8cfbbf9, 0xd2b26f98,
- 0x0f93c967, 0x0dffa0a5, 0x13d84528, 0x2a97d211, 0xc5cc3eea, 0x3ac8287d,
- 0xdba2cf89, 0xfae7f8e1, 0xd7cc7c90, 0xc3967a12, 0x0fcf493c, 0x1b04b80a,
- 0xa3233bef, 0x72b593ef, 0xfd54683f, 0xd4ffa122, 0xc749dcdb, 0xdf6274c0,
- 0x7941df61, 0x8583c069, 0xbd53feb9, 0x4731e1f5, 0x756d3e60, 0x2648f1bf,
- 0x767c1938, 0x2ffe61b6, 0x2ef6f79e, 0x9d85db8f, 0x4c2eddd7, 0x424dbced,
- 0x69e66b6f, 0xa0f11a99, 0x41b65c5e, 0x73e085f5, 0x4f4db6d9, 0xea768a3c,
- 0x70df76bb, 0xdb74bfe8, 0x00987f4b, 0x6aedd2f9, 0x0cbe0cd2, 0x8dd29497,
- 0xbffc2097, 0x1e376c74, 0x92f57e4a, 0xbfcd1de6, 0x374fb8ff, 0xefb74a3e,
- 0x9ee8d8d3, 0xb0d298f0, 0xc5756b4f, 0x91c34bc0, 0xaaafd45c, 0xa1ae7eb7,
- 0xaf72793d, 0x63d352c4, 0x4bc373c0, 0x9c2027a4, 0x4f028f08, 0xaa8b785d,
- 0xa0bc041f, 0x14f0373c, 0x9080fe5d, 0x779fd83f, 0xd3f3d114, 0xf95fa3cf,
- 0xd70fbb3d, 0xedf4f45f, 0x71c75c1e, 0xf5d392a5, 0xfc532b63, 0x1a916e30,
- 0xe529d14a, 0xff1e8bdf, 0xe15bd121, 0xe14c3f1b, 0x9fbfa0f6, 0x50a6f68d,
- 0xc2df5c3f, 0xfad037f5, 0xe880580a, 0x3931e8ae, 0xa7e90c2f, 0x3dbe9b0a,
- 0xc8645f06, 0x6f8e2f9c, 0xd60b8504, 0x12ed1c77, 0x4efeb3f4, 0x7f266f0e,
- 0xfc8622c8, 0x3fc343ff, 0xfe5316ce, 0x93c70753, 0xbe09b643, 0x4ccf6d02,
- 0xb77775af, 0x0d4e7e20, 0x1fa2a7f2, 0x9094c82d, 0x25f48780, 0x31bf2bf4,
- 0x87e3952d, 0xd16c9579, 0x2980f40e, 0xb7eb1df8, 0x18e77ea8, 0x65f63b4b,
- 0x4bf8f77a, 0xef30f8c4, 0x8fbfdc38, 0x86a2b0a7, 0x55bbeb18, 0xf61ef836,
- 0x997d1371, 0x7bf39bf8, 0xbf9c3ddd, 0xcf0f7e0d, 0x9fe58e9a, 0x07f9c9bc,
- 0x08fee1db, 0x52a48af3, 0x25ebbef9, 0x16760792, 0x75d7c589, 0x6b6be0aa,
- 0x302741b9, 0x304a456f, 0xdff60bd1, 0xfe4fe087, 0xd07582b3, 0x832f24ce,
- 0x67a79e38, 0x16df067f, 0x251ffe0a, 0xad9ff95b, 0xbbdf7ce7, 0x7da2157e,
- 0x3f0d4cae, 0x2bf228f1, 0x8bc867f0, 0xe1e6aafc, 0x1fd74fba, 0xc04dc3f8,
- 0x0c1ba7a7, 0xcfcab53e, 0x7a2d3e68, 0xf484b376, 0xa7a7cd19, 0x891b408b,
- 0x3df0a7c5, 0xb5169f26, 0x9f953ffe, 0x8faefc06, 0x0f219f82, 0xb463837b,
- 0xf3633c3c, 0xe5a33c12, 0xc9bdfc21, 0x9fd27bb2, 0xbd067741, 0xfcb2fc95,
- 0x1817f222, 0x5dd06974, 0x741a5d17, 0x62ffc3d7, 0xf9745f81, 0xa005a460,
- 0x2a5dbc93, 0xcd6555d9, 0xda0c3cfc, 0x8b203cbd, 0x6da7e4e0, 0x3cbcd58c,
- 0x0f9cc920, 0xa21be547, 0xf2a3fbea, 0x03f55179, 0x4b4af951, 0x03a6b2fd,
- 0x47fc231a, 0x4becf52c, 0xc41f651f, 0xfd8c87b0, 0x4678d826, 0x0c5d210b,
- 0xde50d4ec, 0x0541cba9, 0x1ee0ff45, 0x0ec5ec99, 0x182af180, 0x3d3ea3a7,
- 0xb1b9021c, 0xf0edc9d2, 0xd3d3bd0e, 0x8995d207, 0xac99df3c, 0x67b942ad,
- 0x7274ef7c, 0x5e47473f, 0xe4d127a7, 0x2cd238a7, 0x0d6edc93, 0xfcb1e9b3,
- 0x10a3b020, 0x6f595bde, 0x39ffdce5, 0x5e0d764d, 0x8d68f68a, 0x771343ec,
- 0x3d1bb2c1, 0x68e92ae8, 0x6ccd7a1e, 0x55f0bef8, 0x3a558e99, 0x70633ce2,
- 0x57e42c5e, 0x89ec99fa, 0xb3f42c13, 0x6ccfe889, 0x82c576e6, 0x08fa5135,
- 0x54f4435b, 0xa1a25ae0, 0xe03b053c, 0x973fab7d, 0xe88945f3, 0xb5bd68af,
- 0x278f68dc, 0x95df685a, 0x03cb59d4, 0x65da3ec2, 0xcb0649f0, 0x86833920,
- 0x42e7da0f, 0x47934f2e, 0xf01b335d, 0x665071d1, 0xb6799e78, 0x9c7c2659,
- 0x97e7e7ad, 0xfc4c942c, 0x493ac156, 0x6a701a1e, 0x7ad27e43, 0x3b6d5797,
- 0x177d9cfe, 0x3fcecdd2, 0xa439f98e, 0x1ddf3b6d, 0xcff31bb1, 0x8ff83dbd,
- 0x29fd67ac, 0x37e49d7b, 0x26ebd8ee, 0xf3d8ef7a, 0x6177c1db, 0xfc9d977e,
- 0x3f7b1d75, 0xd7f4831f, 0x845edcb1, 0x1063aef2, 0xf7aa87b7, 0x95a63e7c,
- 0x8415d7f6, 0xc6b2a3b7, 0xbfe6a3f5, 0x3092961e, 0xdea15585, 0xf89e37b0,
- 0x93bcf829, 0x7b1d0bfc, 0xb80ecf3e, 0xa9eb75fe, 0x1d39e710, 0x59fb366e,
- 0xf7225f9c, 0x8f770783, 0xcf0cb4df, 0x69f71ba3, 0xca7ca1f3, 0x831f7f0b,
- 0x59e3b472, 0xabb50fae, 0x79e38fad, 0xe1fc8745, 0xdce01532, 0x9fd54c8e,
- 0x1194fbb1, 0x62a34393, 0xe4efe5c1, 0x7850b937, 0x4fb70a68, 0x21e1fdff,
- 0x73bcb9f9, 0xae121d87, 0x7fc38bfb, 0xd7b0b944, 0xac69744e, 0x32c374f7,
- 0xb7ce57d2, 0x7fcae1ee, 0xd0b83a17, 0x0b914b75, 0x7fd4f759, 0x5aff7c73,
- 0xa2fcd2f6, 0x9d27a0f9, 0xf283b9ef, 0x9a3edcdb, 0xfbd205ef, 0x7869ff82,
- 0xeef0167f, 0xabbaff39, 0xddd7cdff, 0x9d5fde3b, 0xe3aef02b, 0x85f07f79,
- 0xbefcd3bf, 0xf4db9cae, 0x0dee94df, 0x9b15febd, 0xa80ccdf7, 0xb8d59d3f,
- 0xb2b8b150, 0x19abff7c, 0xc0cafa50, 0xdf388903, 0x37e751c9, 0xc2a6fa46,
- 0x92c9a6ed, 0x9641ec8d, 0x907b0928, 0x840351db, 0x496030fe, 0x0321e901,
- 0xf5cfde06, 0x0ebbc506, 0x195f1fcf, 0xb147df3c, 0x3bec6c14, 0x97ebcc01,
- 0x9ed5bc8b, 0xfcc4b9fc, 0x603a3478, 0xa20ff7f0, 0xa0703b5e, 0xa42f7a4c,
- 0xe8beefa4, 0x97bfce99, 0xe7bb1669, 0x0ed5af4a, 0xdab24dca, 0x7f45534b,
- 0xff9f18d3, 0x0e149734, 0x0f261c03, 0xfa1269fa, 0x570f2747, 0x5cf90499,
- 0xf6815816, 0xb59754c5, 0xc33c06bf, 0xe1cdf719, 0x380d5768, 0x8797590e,
- 0x93241c70, 0x70bcf49f, 0xdc1379c4, 0x2f18c232, 0x871f14c3, 0x1f729f63,
- 0xbd859df9, 0x904d474d, 0x5aab5c57, 0xb4159f90, 0xc81c3997, 0xe5ec36ce,
- 0x84cde0de, 0x2188adfd, 0x032bf80d, 0xdad3bf65, 0x06dfd91f, 0x3e2ebe5e,
- 0x537e3c0c, 0x851bbcbc, 0x45ae8197, 0x74ebf20a, 0x62fa17b4, 0x1f9e0cfd,
- 0xdce85218, 0x570bd84d, 0xa4291778, 0x50cc0cf7, 0x8e855f10, 0x1cf0aba6,
- 0x6893e1c4, 0xd9b7171e, 0x64707f68, 0x91f70449, 0xdfe50ab5, 0x10e3e9b0,
- 0x7b2f33df, 0x0c9df4ee, 0x8d7ee6fd, 0xf1e53dc7, 0x7dbf8ff3, 0x8c44e5f9,
- 0x2c781417, 0x46afff84, 0x167aff3f, 0x2d380389, 0xa1285854, 0x25bdfa0f,
- 0xefc5bef6, 0xdfe3cd6d, 0xfbba5377, 0xdefd5f39, 0x3abfcae4, 0xd8e40e7d,
- 0x5df300fb, 0xe1a30e98, 0xfd5db315, 0xaf0e669d, 0x1e1621e0, 0xe42ae3c2,
- 0xe139d33c, 0x9ffe821d, 0x99b3d3fb, 0xea4ed768, 0xe5c09518, 0x17b230eb,
- 0x385ec282, 0x3e09bccb, 0xa1d7ca17, 0x79fe7409, 0x8ac77650, 0xec2adc2b,
- 0x7c625fed, 0x751da409, 0xfb4646ac, 0x1f92758d, 0x60e75437, 0xb7c4639b,
- 0x9f86abe4, 0xfe0de04a, 0x8f3c6ce4, 0x842fe3e1, 0xbc6609a6, 0xa938cdb5,
- 0x0789e98c, 0x74df7bfc, 0xe14df51e, 0xc23df68b, 0x35b3ab77, 0xfc862f37,
- 0x6fc05db8, 0xc82ffee6, 0xf36979ff, 0xefd21b06, 0xcb3675a5, 0x2aa96af9,
- 0x6cb1b1ec, 0xe66bce2c, 0x0b3ba77e, 0xf65072f1, 0xb0673c61, 0x88168cf9,
- 0x0d182e71, 0xfd1fec4f, 0x9d555be9, 0xdab76bf8, 0xbae11f30, 0x430723fb,
- 0x56977a3b, 0x9e6b1a53, 0x9e7cec03, 0xedc3590b, 0xfdffd263, 0xc3a93be0,
- 0xf68c9915, 0x7e131d67, 0x63fa688f, 0xb767c744, 0xafee30b0, 0x5ca2af68,
- 0x68cf5b38, 0xdc90077f, 0xf037768f, 0x7eccf7fb, 0xb69b8b9c, 0x82f512ff,
- 0xc749668a, 0xa50a8623, 0x6d3f4355, 0xc65129b0, 0x6bc3387d, 0xa3eabbc4,
- 0xc5f137af, 0xf8215556, 0xfbb0981e, 0xe3f71c66, 0x9ea18d36, 0xd3b17fe2,
- 0xc7f8fb83, 0x07c499cd, 0x57ebadbd, 0xa9aaec55, 0x972a3748, 0x30f4d187,
- 0x92ce3eaa, 0xf40e4cbf, 0x699afe47, 0x8be25d6f, 0x6befbf81, 0xbc173892,
- 0xfe16f940, 0xbdbe4cff, 0x80b7c869, 0xa3e2679c, 0xf90f5abe, 0xbe4b1a96,
- 0xa9bc962d, 0x7bc5f708, 0x5e22a686, 0x26aabf17, 0xdb6f92c7, 0xe739f8aa,
- 0xb94e2233, 0xdbe411a3, 0xadf24db7, 0x8c5be411, 0x5fbf9078, 0xff0b7ca8,
- 0x36dff0d7, 0xd6316f94, 0xf9566bab, 0x08f9a636, 0x8d31b7c9, 0xaf3c4b36,
- 0x7c9f3b5d, 0x47af9293, 0xeaa0f8fd, 0x3f418f8b, 0xfe3e84db, 0xc44b888c,
- 0xe5ce5071, 0x7f8d3a6a, 0xe2ee72a1, 0xff73950b, 0xe4367045, 0x8c1de2dc,
- 0xd27b9ce2, 0x8b739721, 0x939c8177, 0x9cb91e90, 0x7187bc5b, 0x7c945cbf,
- 0xbe43d91b, 0x115faa31, 0x4d83ede1, 0x02df0fe9, 0xabf58dfd, 0x1fd4073e,
- 0xc6ef2ddb, 0xae5de599, 0x7adc10a6, 0x1783bbc8, 0x0876ef26, 0x6c720779,
- 0x68d7ca08, 0x5b35f0fa, 0x8f77c1e3, 0x2bff5e3f, 0xcadf97e4, 0x86f8de74,
- 0xbd0f9f8d, 0x1678fe36, 0x6263d7d2, 0xdc848b3e, 0x510aaf6b, 0xe45e53ff,
- 0xf1772beb, 0x468af138, 0xd4561fae, 0xfc2f614b, 0x17c27733, 0x78bfce1a,
- 0x2152c48f, 0xebcecb3f, 0xf38d27b3, 0xc3233632, 0x720b0f44, 0xbfcfc94a,
- 0xf40e6140, 0x72ba97e3, 0x5bfea24f, 0xfefdc39a, 0xf17be2a5, 0xd0abadab,
- 0x88fc5dff, 0x46a5e744, 0xe711ab7c, 0xa26e23db, 0x77f91979, 0x6627e3a3,
- 0x99a9b88a, 0x1bc294bf, 0x947fc462, 0x7fe6b16e, 0x966ff822, 0x62f04adc,
- 0xe331cbaf, 0x5d7a8c38, 0xe0283a70, 0x7ed32754, 0x802705da, 0x27bd379b,
- 0x33d3009c, 0xe1ba5232, 0x585bfc52, 0xebef566f, 0xbd16e035, 0x5d7fc36e,
- 0x0de9fa2a, 0x7b9c060e, 0x1dc05fac, 0x939202ec, 0xa758f0d1, 0x33b5f975,
- 0xe8094e31, 0xe84ce486, 0x181700d7, 0x70d26f2f, 0x47977dcb, 0xd664fd05,
- 0xe1829a4c, 0xae30b30c, 0x6a0bca1c, 0x0fdcbd17, 0x1dee31e0, 0x4edc58ef,
- 0x0f609b2f, 0x56ec39e0, 0x41c92767, 0x35db0e83, 0x141c07ae, 0xbfddddf0,
- 0xf9d93272, 0x7a8e924d, 0x24e23048, 0xae0106b8, 0xa828ff78, 0x8106fc70,
- 0x0eff911e, 0x8719f23c, 0x8bc91ee3, 0x635c9dfe, 0x40bc42bf, 0x8e66ccfd,
- 0x22586097, 0x4eb164bc, 0xa8a97f3a, 0x84117c95, 0x8206d35f, 0xe19f219f,
- 0x93c665cf, 0x58957e89, 0x4c954bf4, 0xa8a965fb, 0xf35ed337, 0x99e7a407,
- 0x036caa4f, 0xfbfe1b81, 0x4f3e7a2a, 0x9e34501c, 0xb6bc04da, 0x085d3c21,
- 0x77ae4eb7, 0xfba0be45, 0x50794650, 0x39e05909, 0x5f73d1e5, 0x0671af09,
- 0x518e90bc, 0xcbe735be, 0x92682f98, 0x9ef4df58, 0x50f3c5eb, 0xef17bf33,
- 0x7ffbc239, 0x18b1f24c, 0xba60beeb, 0x8b9e85ee, 0xbcf16e80, 0x8eba37a4,
- 0xd23b5386, 0xe9bab7f3, 0xe76735f9, 0xe7a44ca1, 0x43f7123d, 0xce5a2734,
- 0x1e763d35, 0x09d5b5f7, 0xeeeb0f74, 0x6df5557c, 0xcb90c6f4, 0x7ed1ee82,
- 0xbb37df30, 0xf1821704, 0x141c5ba2, 0x18f347ef, 0xb353f5c2, 0x64e6de7c,
- 0xf567d7c9, 0x2edbbfde, 0x37278cc5, 0x3f2323f4, 0xf8c3c71a, 0x6f1826f9,
- 0xd178f764, 0x2fe183fb, 0xfabadf38, 0xbad9bfdb, 0x6ebe718c, 0xb590543c,
- 0xb88d5e10, 0xe05223a8, 0x73ea2a47, 0xfc4b25d3, 0xc85ccc15, 0x7fdc6fad,
- 0x7bdc96aa, 0xa74d2cff, 0xebb774fb, 0xe89d77c6, 0xe2674f33, 0xdbe26f7c,
- 0xec7fefb8, 0x5998e7e7, 0x44d6f636, 0xab263fdc, 0xe3eae90c, 0xa1f92a43,
- 0xe3ca9e3f, 0xedf9af6e, 0x3e5d0501, 0x3898f0d7, 0x8938cd76, 0xb037acec,
- 0x87a8f1eb, 0x047f983b, 0xef132fc1, 0xd5d465ed, 0x5f02f14c, 0xae12dd8f,
- 0xa537d4c6, 0xc435e933, 0x219924db, 0x7dfc5ade, 0x7f20b8a7, 0x032c87fb,
- 0x1fa0a05d, 0x07b1fb50, 0x9bd63259, 0x33264fe0, 0x27e37c66, 0xf3075e6f,
- 0xf6487f18, 0xacdea179, 0x03172e03, 0x7ae47a7d, 0xe0980b1b, 0xab858135,
- 0xfe34dfd1, 0x9c3affa8, 0x3be81177, 0xa8a44f78, 0x07b54379, 0x6a25ebf3,
- 0x72050c1f, 0x6d9eb03d, 0xbf7267b5, 0xea017285, 0xf5c13761, 0x4eb05ebc,
- 0x728861f2, 0x8a5af341, 0x93a82a2f, 0xb6e142e8, 0xbc1cc4b0, 0xfa03b0df,
- 0xda1eb6dd, 0x05fee167, 0xbadfb1ed, 0x875e6f33, 0x49e60772, 0xb9f9ebed,
- 0xf3b4017c, 0x2dd4bf22, 0xd78afea2, 0xb3ef0c4b, 0x7df3d514, 0xea90e8a9,
- 0x7dc6f2c3, 0x3b7ed08f, 0x97ebc603, 0x6450fb8e, 0xca0bdd2a, 0x2fba7494,
- 0xf84c1a19, 0x7f1c60eb, 0xf220fa6c, 0xabbc520b, 0x98a0c097, 0x64fe63e3,
- 0xb3f2421f, 0xeb4cb7c0, 0x96bcfd0b, 0x236e9c93, 0xe7433aba, 0xde0147ed,
- 0x1bf78001, 0x40e55e22, 0xab5a07ce, 0xc2fc5f69, 0x9b9f943e, 0x38a24d34,
- 0x8f2c858e, 0x8e6638e2, 0xebe6fae7, 0xe8c33b97, 0xed5d7be7, 0x0fdf881c,
- 0xefa76e5c, 0x1cb8dbed, 0x4ad41f6e, 0xebe3f6fe, 0x58f78655, 0x24cbd7aa,
- 0xabd78e2f, 0x7e563f74, 0x1431c78c, 0xc7fae36e, 0xdfbcf581, 0xe1b7a8e3,
- 0x439607b9, 0x11ab70be, 0xb4e5c0e7, 0xe8167f61, 0x90c2fe3c, 0xdd62e5bb,
- 0x75a1f63d, 0xd92434cb, 0x2e5b7968, 0x8b0971e4, 0x2d1cbd90, 0x1cf1cb77,
- 0x197c83dd, 0xeae6271d, 0x0e9063b6, 0x5d105f22, 0x19521c57, 0x07d231da,
- 0x9714b96d, 0x73a247b6, 0x92cdf18b, 0x8a1ae31f, 0x4987b1de, 0xcfe70eff,
- 0x2fee11fb, 0x8619daef, 0x3c431f2c, 0xb1ca9c80, 0xa7e9fe77, 0x1be4fdf0,
- 0x02088c0e, 0xb827c9ba, 0x59be711b, 0x4f3c799b, 0x52eb1bd6, 0x9b2f3ef0,
- 0x40e497da, 0x02ccad61, 0x52713926, 0x13775ff2, 0xd4741fdf, 0x667c0c77,
- 0xb8053569, 0xc1cb7ebf, 0x66ef55f7, 0xd8646315, 0x043d84ef, 0xf51f81f6,
- 0x6b5de29b, 0x1d133453, 0x9b59ef14, 0x55f7c322, 0x1aa61e22, 0x576857f7,
- 0x8a71f1ac, 0x06fa4af7, 0x3f4638d3, 0x2edabf46, 0x1ee86ede, 0x7fd6f69e,
- 0xd68fce31, 0xf286a9f9, 0x1e9fba22, 0x4fd2f7e3, 0xadcfefce, 0x395e6093,
- 0xac14cbaf, 0x8cc1f39e, 0x1d73e6a1, 0xcafc3523, 0x98da6fd9, 0x9cbf04df,
- 0xbf31c53f, 0xe38ddf09, 0x7f01ef80, 0x61493757, 0x23f984a7, 0xe516795a,
- 0x0af3e475, 0x98ae7fe1, 0x1aebcfca, 0x8158de33, 0x4b233f7c, 0xa1607a22,
- 0x8937d680, 0xfa2f35f4, 0x78b30bfd, 0x8f6842fb, 0x08f8d8fc, 0x13904fe7,
- 0x1523945e, 0x52e6d7eb, 0x8bc93afd, 0xc86e37fd, 0x28a47d27, 0x5e546647,
- 0xa3f48477, 0x4923a6a2, 0xb7c0c7c8, 0xa81f50eb, 0x51d76898, 0x68fc1b8e,
- 0xe2ebf7f0, 0xe8732b3e, 0xc67ef1a3, 0x8be646ff, 0x21f2d7c1, 0xf583d72e,
- 0x39831f9c, 0xdf5f5f9c, 0x2f0ae2a6, 0x9f89bf84, 0xfce16f8f, 0x43763f2a,
- 0x2f87de2e, 0xc3efccdc, 0x453f581f, 0x78fa7d43, 0xa6fda258, 0xbd737f27,
- 0xabbf9a35, 0x7defbe25, 0xe0d2fd5d, 0xe18f836f, 0xaf1c6aef, 0xef14f80c,
- 0xf5f3464f, 0x0fe1b54c, 0xaf7cc3b7, 0x03d61a79, 0xddf29df3, 0x26ad3d3b,
- 0x14f90939, 0x3c2817cc, 0x2b90cb9e, 0xfb8f0ae5, 0x8bf3dafb, 0xb76c3f1a,
- 0x677e47fa, 0xebf1e44f, 0xfdd12a75, 0x07b3f8f9, 0x7f205d9f, 0x9d5f285e,
- 0xf18d3f8f, 0x7ed63de5, 0x2de8277e, 0x8076bfba, 0xfae0046b, 0x8a26fd4a,
- 0xa9e8fdf3, 0x3f113323, 0xce81bba5, 0xddeabe91, 0x4e72822c, 0x557ed309,
- 0x3dd328d2, 0xb244a601, 0xf99b73af, 0x956dc798, 0x7a26e33e, 0x1ed6792a,
- 0x4bed019e, 0x86307e76, 0x779668e2, 0xe85a5c52, 0x872fa129, 0x1f20c75a,
- 0x7e3c2894, 0x042e5a2c, 0xd70fdc1c, 0x367e2bb6, 0xc2da4fae, 0x69288fdf,
- 0x9bb551b8, 0x746e25ce, 0x3a3d46a8, 0x1d010dd7, 0x9c5dfde3, 0x02ddf99f,
- 0x6dac6e23, 0x2513972b, 0x81d92a4d, 0xb7b65b25, 0xc970fc63, 0x77f2763b,
- 0xa19cb705, 0x9e5310fb, 0x94fe46d9, 0x396c9360, 0xb711eb7f, 0xd88e45b9,
- 0xb1b0ee31, 0x211dce9c, 0x0df2847f, 0xcf97e3b1, 0xfa585f17, 0x219d9ecc,
- 0xafe96100, 0x7ca0f49e, 0xd9b2d539, 0x7e877083, 0xba6e32bf, 0xc3669c47,
- 0xa7195f3d, 0x01ff0a79, 0x438f738c, 0x9c4635d8, 0xa4be96eb, 0xb2fcc247,
- 0x739c62f3, 0xdbe5e974, 0xef1c7d3e, 0x7b3db411, 0x6f9c71fa, 0x7e3e3fd9,
- 0xd8c1e31c, 0x77ed275e, 0xa2dea7c1, 0xdda36c38, 0xb5dfb126, 0xe2927d6f,
- 0xb5dfdbd7, 0xf6b7b0fb, 0x6307c73d, 0xf6fb603c, 0x6fd0522f, 0x34cf64b9,
- 0xd92eebf2, 0xc5952531, 0x148c2fd8, 0x017c36e9, 0xf8d1f3f1, 0x8078d03a,
- 0x023ed6e2, 0xebfca37c, 0x286dbb8a, 0x5ecc71e7, 0x1f5b6f11, 0x8f429efb,
- 0xebc6daf8, 0xe51cb9ae, 0x1fd7237e, 0xfb671bcf, 0xdbf1e026, 0x7abf8017,
- 0x1b102fc3, 0x3fe11f7f, 0xa2fb4f00, 0xe369f7f0, 0x8a3c5fc2, 0x7b7d8d65,
- 0x5c8db38d, 0x7b8cdc00, 0xfc380f10, 0x88c91c87, 0x5c525fe7, 0x866de233,
- 0x4f9ff717, 0x91fde307, 0x5ce76a13, 0xc7b85fba, 0x68bc63ae, 0x89b79ec9,
- 0xbc77da7f, 0x26687e41, 0xb3b423ee, 0x3f1e3fae, 0xd675892e, 0xae7c79b9,
- 0xefc63f80, 0x5df43d7a, 0x3a72e9c4, 0x7b77e236, 0x9d95db8b, 0xee36cf5c,
- 0xfdd79467, 0x76c3c451, 0x41ca4be3, 0xcaf91d3c, 0x0e036878, 0xddc390ba,
- 0xe3b1e871, 0x2beebba3, 0xfe217c08, 0x8aea1f70, 0xc0fc8733, 0x7a37e4b1,
- 0x0790c59b, 0xfc781bed, 0xfb1abb7a, 0x9711b05e, 0x3e688ffe, 0x3c585f0d,
- 0xffe6f9fa, 0x81d3e175, 0x4f724fca, 0x2dfdb538, 0x774f1cb6, 0x9eecdf4a,
- 0x7d149961, 0x1cebca6f, 0x473b7187, 0xbb83b434, 0xdeb16cec, 0x6f57e136,
- 0x78a64a7b, 0x070d55e5, 0xcb478e48, 0x2f7c0a8b, 0x337cc625, 0x9a2b7cc5,
- 0xf6d13ef8, 0x82ec3bac, 0xeff6da7e, 0xa8ae7a22, 0xd2f1423f, 0x95f96f2f,
- 0x8b8a6ad6, 0x6c227dc0, 0xd3db7f9a, 0xdc90c6fb, 0x44b2ef16, 0x8c49338f,
- 0x3d8e6c13, 0x8cfeb04e, 0x50d29c65, 0xcebba683, 0xc529de3f, 0x77f6237f,
- 0x83eb85aa, 0xe9e41aa7, 0x0fe318e1, 0x77d6aa73, 0xa4bf60a1, 0xfcdc67f7,
- 0x13d919bd, 0x12e5fa47, 0x093bce77, 0x146a9849, 0x4cbd55af, 0x87fd77c4,
- 0x5df10d2f, 0xe18abeed, 0x7c22577c, 0x551e7e4d, 0x4bd4300f, 0x2cbcb4d5,
- 0xcb442bf4, 0xc6c92d1b, 0x2ffc26c2, 0xf54f4f71, 0x644779d2, 0x70f3e220,
- 0xfb1571c6, 0x9f944bfd, 0x5b0a2fea, 0xfbf30a95, 0x2df2484b, 0xdfd97e83,
- 0xe794183e, 0x977fd9ee, 0xd963f11e, 0xb0aa57e2, 0xbb461e77, 0xa4e0bd84,
- 0xaf7906f8, 0x08f9de93, 0xf5a4ee3e, 0xf9f1d81e, 0xff5fa413, 0xb9f8cec2,
- 0x202f580f, 0xde750aaf, 0x9f1df1c7, 0xd457fe3f, 0x8c31b19f, 0xd438f85f,
- 0x3ea1bb47, 0x8e9cec9e, 0xa0c61367, 0x85f0a45f, 0x3ca266bb, 0xf4e78c2b,
- 0x6a4cf858, 0x3bfa1ab8, 0xc7f3cc96, 0x77a20db6, 0x759f4a25, 0x81e8dc53,
- 0xe055cf1d, 0x4cfed4be, 0xa97dc33c, 0xe7a105fd, 0x53bc52ff, 0xcd7aab55,
- 0x4cc5e3f1, 0xf3ef9af1, 0x12de6294, 0x2fc8c4af, 0xfe847c41, 0xba04a6aa,
- 0xaffa0407, 0xd48f9fa5, 0x447c3bce, 0xfcfea1c7, 0x3fa453fe, 0x7ae883ca,
- 0xcebdf946, 0x395ee221, 0xd77573b4, 0x059d6a0f, 0x9fd35f3c, 0xaa1693cb,
- 0xf853b0ff, 0xcf79458f, 0x87fd797e, 0xeeeefc84, 0x10afb787, 0xd344d0ef,
- 0x6fd146ef, 0x5fbf96e9, 0x959deb1c, 0xefa7f318, 0xc858943f, 0x76ca7a86,
- 0x857fbd27, 0x7de028ef, 0x3f1a9d85, 0x44f32ad7, 0xdd9b9de8, 0xc5971e42,
- 0x9ddde845, 0x581e62fe, 0xd1ccf31f, 0x9fbd34fa, 0x61939cf6, 0x0bf9595c,
- 0xbbe23f6e, 0xc7e7e77c, 0x71859e7e, 0x1714f189, 0xffc2fe5f, 0xb7283a22,
- 0x3f22e647, 0xb3b76e74, 0xdbe7c88d, 0xfc8c1d5f, 0x0646a6da, 0xf38af9f7,
- 0xbb06f2ba, 0x58bffef5, 0xdaaaa9c7, 0xbbbef0cb, 0xa4b6af71, 0x57f33917,
- 0x5fa3d727, 0x725ffa71, 0xdf5bbf12, 0x35553a73, 0x59df133b, 0x3897ea30,
- 0x77c5cb62, 0x137c5e51, 0x71eaee39, 0x9c5df53f, 0x25ac47cf, 0x153efd05,
- 0x3ca377a0, 0x3e92d92f, 0xfb04fd10, 0x043bc69d, 0x8fdc04de, 0xb25eabf6,
- 0xef3531a7, 0x7caa2733, 0xf430ca99, 0x54cc8cdf, 0x1b1d1d60, 0x67f414ce,
- 0x9cea4718, 0x9dee4b1d, 0x3ad3c676, 0x98f61c4a, 0x09cf9df7, 0x8d0f7aba,
- 0x1e3e64fe, 0xee3187f2, 0x724c357e, 0x2f388ef8, 0xbb012bd5, 0x6e97bf08,
- 0x79699399, 0xa1a9457f, 0x04a7c07a, 0x4eb662cf, 0x6fc932cb, 0xa5e2bc63,
- 0x264a9959, 0x4ffe577e, 0xddcabd17, 0x24a16678, 0x01150bd2, 0x9faeb663,
- 0xa2887ee5, 0x7e1039e6, 0x15d3cb1a, 0x86a54919, 0x358e3df8, 0x7502ea50,
- 0x5653bf8b, 0x9e4e50c9, 0xe8f6e710, 0x1bb4c2ef, 0xdc92775e, 0x6c620d0f,
- 0x07be3a78, 0x4dd04de1, 0x10f153f0, 0x5763e61e, 0x1797192a, 0x93b47433,
- 0x7d8050a5, 0x5d54f409, 0xe9133d35, 0x18fcfe11, 0x07a64907, 0xbfa3cfcc,
- 0x41ea05fc, 0x3dfca740, 0x70b2efbf, 0xc3188035, 0x3aafc981, 0xe877f199,
- 0xccc3bf56, 0x71a5c6f6, 0x68e77892, 0x1731c91f, 0x84ebfeeb, 0x94558a3c,
- 0xff09d5b7, 0x4473c1c8, 0xa822ce97, 0x58bbc617, 0xd7521e24, 0x9994e528,
- 0x90593dff, 0x3ea9d137, 0xcd1e5ad1, 0xa2d72017, 0xf8206dc6, 0x449fbf41,
- 0x5449fbf5, 0x557c9fbf, 0x829c06bf, 0x7c3e8d8e, 0x556562a7, 0x1f1b809e,
- 0x06e021cf, 0xef8919f0, 0x9c5b31e8, 0x13879c4f, 0x6cc4e35c, 0xf01f58ec,
- 0x4e971e5a, 0x612fb978, 0x41c6276f, 0x865aa4b3, 0x890aef76, 0x97f0d3ef,
- 0x63b532e7, 0xf0f883ba, 0xb94e311e, 0xc30af380, 0xbea3d53f, 0x1eaff493,
- 0xd5bd9df5, 0xdf5d8b8f, 0xe27cdbdd, 0xb127cf63, 0xe26bfe97, 0x75fff663,
- 0x0bc552e5, 0xe786bf6f, 0x49f25db6, 0xf55bd007, 0xd438f2cc, 0xfd8f1333,
- 0x70be95a3, 0xd031d33d, 0xa438ef8a, 0xb8b7a06f, 0xd1efd661, 0x7d1bd274,
- 0x40758be5, 0xe00fd5de, 0x7f189370, 0xf73f1d6a, 0xf70965be, 0xe87981d3,
- 0x8b37fac7, 0x0a3937fa, 0xc470dfc9, 0xbabfdfc6, 0x91eb96a5, 0xa658fcb7,
- 0xef1ee9f3, 0x803fe151, 0x2a5d6edf, 0xb1e92385, 0x7562d7de, 0x9e6e3f78,
- 0xbdfa3f18, 0xe6f300aa, 0xbd6396ae, 0xd2e9c557, 0xfd1757b8, 0x9602c54e,
- 0xb321de27, 0xd4eb3f7e, 0xcd67e4bb, 0x2c7deea8, 0x1ee816b4, 0x7ba04ff5,
- 0xebc7973c, 0xe2171462, 0x485c78d1, 0x4f3a20cb, 0xd9dfe433, 0xdc04de91,
- 0x307f99af, 0xeff3aeff, 0xa6f4af8b, 0x2a1def9a, 0xef2ce2e7, 0xbeab54f5,
- 0xea6f9434, 0xc15fd039, 0x0dced654, 0x39535e61, 0xfcc4ade8, 0x7249be18,
- 0xa3094d2a, 0x3cf4545c, 0xaf7a8856, 0xa8c3ef78, 0xd55d25af, 0x0ebe67a5,
- 0x4b8e6fff, 0xbc5cbe26, 0xb6f74bd6, 0xdbcf8b3f, 0x7b24f489, 0x57017c72,
- 0xed087a4f, 0xc6aeebe0, 0x5cf7a775, 0xf3e6b54f, 0x157dbe91, 0x6ffc8080,
- 0x4fce073e, 0xf6df7bb6, 0xa37efce2, 0xf4bbf432, 0x44ef8f84, 0x86cfca18,
- 0x887c5007, 0x0463309c, 0xbc46bf8e, 0x6ababa6f, 0xaa2ba524, 0xbc794898,
- 0xaf2a8adc, 0xea447348, 0xaa74e917, 0x1a556f77, 0xf95557e5, 0xebe03528,
- 0xfbd0d5f0, 0x7c618e93, 0xf02e877c, 0xf0136497, 0xe5fe900b, 0x73a4ab48,
- 0x195ea745, 0xd8df77c1, 0x7077d840, 0xc10d7a59, 0xf919d357, 0xe53ea135,
- 0x548798ed, 0xf8419dad, 0x564af452, 0xc56fe508, 0x5c228e07, 0x2d4bde9d,
- 0xd3da5aef, 0x7fbd46c6, 0x836f051a, 0xb871b6de, 0x7a712fdf, 0xfdfb868b,
- 0xe3178b6a, 0xb2bfee22, 0x82295deb, 0x1c43983b, 0xe7e6bfee, 0xdee13db4,
- 0x09be7b32, 0xe9eceeee, 0x04fbf704, 0x7016ef9c, 0xa87816ad, 0x46acf016,
- 0xa47e53b8, 0x3a44fbc8, 0xc47bd29d, 0x112bb7fb, 0x08ca901f, 0x7d878077,
- 0x30c98854, 0xf179ba1e, 0x7412eecf, 0x1fc8dbab, 0xfcf2bb2a, 0x127b7708,
- 0x05c3bb87, 0x06ba2078, 0x3cb17bb8, 0x5d54f044, 0x9f50ce1c, 0x15e441e3,
- 0x7e267b84, 0xb800f8e7, 0x871f8df7, 0x058270f2, 0xe4d25ace, 0x23fb830b,
- 0x124b7f7c, 0xbf0d1e7c, 0xafbf8d24, 0x6f77f06b, 0x88b571fa, 0xef16aeb7,
- 0x511c2227, 0xe00879af, 0x4f0e34c3, 0xc8a47dfe, 0x164d28fb, 0xe0357ff6,
- 0x161fcb01, 0x19c210fa, 0x73c51fd3, 0x56c93cfb, 0x38454fb9, 0xf2efe1f5,
- 0x1b10a4b0, 0x6878cd98, 0x85a5fe2f, 0xc6f31798, 0x4ad7aff9, 0x44aeb23f,
- 0x7de903bd, 0xdd6de918, 0xcf0daaab, 0x57a5e43f, 0xcb67ee59, 0x5e89fdb3,
- 0x42407f82, 0xc13ee6bd, 0x5e916b87, 0x1edc7e68, 0xe0e8295e, 0xeefef16e,
- 0xee7e823d, 0xa0fcfc17, 0x7e3e3741, 0x74cd643f, 0x9498c71e, 0x20ef1361,
- 0x4e399846, 0xc0d7d130, 0xd9179834, 0xe94a5e36, 0x8ef64b9d, 0x7e36f89d,
- 0x7d23f314, 0x6773be25, 0x9b43bf98, 0xa1f50fd7, 0xd9dde344, 0x39c4de89,
- 0xa23d3174, 0x6520f788, 0xc4b64f6e, 0xdab5df7c, 0x7e81dfb7, 0x13e6de99,
- 0xafa7f3ef, 0x6be2f184, 0xf54764dd, 0x59cde40d, 0x2d577908, 0xcb0c55d8,
- 0xc1707cb9, 0xf44d0bbc, 0x5f8bdf11, 0x595d7547, 0xf64af480, 0xa93fa438,
- 0xf844ea1d, 0xe8bdac02, 0xcd487abf, 0xc1fb87eb, 0xfdb18943, 0xb9e2b370,
- 0x7593c4bf, 0xb09fc5a9, 0x3b53f54e, 0xde55a27d, 0x43fb13ac, 0xfe56a99f,
- 0xcb83f630, 0xc59f7f44, 0x0f147e07, 0x6e729674, 0xa4cfc92a, 0x0fef636b,
- 0xc216aad5, 0x47aa39f7, 0xe50ebe73, 0xee6f5c6b, 0x9d187721, 0x8c0d9c83,
- 0x2ffe88d8, 0x3396be83, 0x8c42e72e, 0xbac693eb, 0x3ef4867e, 0x9d01f702,
- 0x01f71ee8, 0x34c3cbcc, 0x5b949ba2, 0x587fe46c, 0x5eecf825, 0x046b5fc1,
- 0x7c803d5f, 0x81df0235, 0x13fa51f6, 0x90eb4fc1, 0x12dd20ff, 0x78f5ce9f,
- 0x6197bef1, 0x8c772cc7, 0xab1cf7a5, 0x0fda365d, 0x61ed7794, 0xfb05da17,
- 0xf7e8ebc6, 0x7a59dd91, 0x59e58dc0, 0x43c03f0e, 0x91d2cc4a, 0x2f733e5e,
- 0xe2abe8b8, 0xf4fd015b, 0x72a2b0ae, 0x949ea47f, 0x451fdec7, 0x9ef453a7,
- 0xcb5faa80, 0x70fd3fd0, 0xe113a552, 0x8f3c70fc, 0xcfcdaad3, 0x3e03b826,
- 0xe29bc5b6, 0x5f6752a5, 0x1f1ef5d5, 0x2f70ff76, 0x12ec12ef, 0x0c0d82f2,
- 0xf92661b1, 0x7bde2b50, 0x1b10de64, 0xcb139269, 0xf432e787, 0x0f94f5eb,
- 0xcdcbc8bd, 0x90ae5e5c, 0x434bcb62, 0x65e4377f, 0xd2315cb4, 0xb74d1795,
- 0x5d54a7dc, 0x66f2463e, 0xc1ff6c64, 0xfcede3ef, 0xf3e66a1d, 0x2cf7a7e5,
- 0xdefd7807, 0x83d42f0c, 0xf7c57f0c, 0x5a27ac62, 0xcab89e3e, 0xf40357d8,
- 0xcd02d03e, 0xaff8f0fb, 0xfbad57dc, 0xd5b9e141, 0x9c140fa4, 0xa8b4a1cb,
- 0x11f13a76, 0x9318d3c3, 0xfd7c7c9d, 0xdf883d0f, 0x7ce2b5e3, 0xc61abd7c,
- 0x1b7da4b8, 0x0e607aef, 0xe3c175c0, 0xe38f9d32, 0x14d90d3d, 0xbcb2c2df,
- 0xef1ba7a4, 0xdf0f1e23, 0x31c731ee, 0xe9d4fc14, 0x37bffd47, 0x1f582c7a,
- 0x8d537fdb, 0x83bb44ff, 0x5da246f9, 0x675dfa01, 0x9fbff504, 0x18dde938,
- 0x18da1f23, 0x8fc733ef, 0xf15be918, 0xdc21ced3, 0x33f78adf, 0xab9dd217,
- 0xf4d79d0f, 0xdc7c17ce, 0xc733e863, 0x4547d273, 0x7dc0359c, 0xca7fc596,
- 0x098f49cf, 0xf473187f, 0xca271e52, 0x7b94bdbd, 0xd3133c78, 0xd3ff9763,
- 0x3d51a47e, 0xb821b4ec, 0xd3daf2fe, 0x2fa5deab, 0x6280f3d6, 0x60bdc711,
- 0x79787c63, 0x2059be0c, 0x102f07ee, 0x7d065de7, 0xd0df7f15, 0x465d39b3,
- 0xd4f4add3, 0x1fa74425, 0x5fc9541f, 0x87f4015b, 0xd4f4987a, 0x698f7a78,
- 0x3d9713d9, 0xf9c00b78, 0x95324393, 0x10739d97, 0x87ffb65d, 0x3bfce28f,
- 0xefd2ab7f, 0x70727c26, 0xb7ebc51a, 0xbb9ef78b, 0xedc5cef8, 0x5c5c1bda,
- 0xbb9c14ae, 0x8bbbe897, 0x35f3c2ae, 0x7382dbe4, 0x565e900f, 0x4ebdef80,
- 0x788f75c0, 0xe8229279, 0x1fb60277, 0xea1cbb92, 0x3e72b615, 0x15431361,
- 0x10de8fe4, 0x0637bbef, 0xf2e0df3f, 0x0b45e25a, 0xff50d75b, 0x24c3f40c,
- 0x02c85c53, 0x8507fbf1, 0xe584b878, 0x21a5887a, 0xd6f908df, 0x77d6ff4d,
- 0xd69ddbb0, 0xc2e91a75, 0xb04e75ae, 0xebdd61d8, 0x73e72efc, 0xb6146fa1,
- 0x7579f0e6, 0xe3e7e7ad, 0x7ba7ad63, 0x7da9131d, 0xf1ec627b, 0x1fe317ef,
- 0x9bc22aab, 0xbc44ac5b, 0xbe105bb7, 0xd5f7c35d, 0xf627d60a, 0x2aeb4c91,
- 0xc4b52dac, 0xe6d4152b, 0x857afbd3, 0xdbb5f3eb, 0x1753fb4c, 0x97fe425e,
- 0xc6eb0d27, 0x2e6bfdcb, 0xaea8bc23, 0x7e913bbc, 0x7c553d8f, 0xec5e7bc7,
- 0x84e9e397, 0x49531a16, 0x4f76eaf2, 0xf74dfbac, 0x56a9e347, 0x80ec09e0,
- 0x0c9e132c, 0x3fb744fc, 0x8efcb9b6, 0xe21cf0f7, 0x509afe11, 0x0a2bf2ef,
- 0xe1b1e97f, 0xd7a0a4f7, 0x040fa063, 0xdf7e082e, 0xf5cbc4b2, 0x6f813f0a,
- 0x77c63e03, 0x08c2e7d0, 0x379127b7, 0x4e3fb193, 0x5b83e70f, 0x1e82f8f7,
- 0xcf5ec526, 0x59eb5d6b, 0xc7a042ca, 0x3eb8d49c, 0xee7afbd1, 0x05c72162,
- 0x4f8ba7ac, 0xfa7c2df3, 0x385b9ada, 0x9ffc0a9f, 0xd10f7fdc, 0xbc70b1f5,
- 0x7a54e30f, 0x486bcf5b, 0xd062e307, 0x1b10b0c1, 0x8f7ffd95, 0xfe684e0e,
- 0x3ee08f11, 0xee15fb02, 0xde4fc5d3, 0xbf3cc63f, 0xfd27e2b7, 0x9aa5f69e,
- 0x0ea73b0b, 0xf41df64d, 0xfb277ed2, 0x434961aa, 0x633f815d, 0xa3cf12fb,
- 0x6e9fa19f, 0xc6cfe245, 0x578bd2c4, 0xc72e0556, 0xaaea8bf3, 0x8fd1cba2,
- 0x973d0aaa, 0xce9b9ea1, 0xd623177f, 0xcdcc7d7b, 0xaab2bbf1, 0x983fce92,
- 0x94f4c423, 0xd80077ee, 0x47f24c89, 0x7eab2e2b, 0x1d01a9a6, 0x789adffd,
- 0x025540a7, 0xd0b3d3ab, 0x1194945f, 0x1fefc132, 0xb2ee7e2e, 0x8ebf6d26,
- 0xe8761ae7, 0x8e60fd1f, 0x8b59ca81, 0x6545ecff, 0x93c05f41, 0x1c731cf1,
- 0x124bf06b, 0x46cf13f9, 0x5acf13f9, 0xf30491e6, 0x5b3b0afe, 0x1ce87871,
- 0x8fc26152, 0x5f01e02c, 0x5bbb1f68, 0x1e5cebe7, 0x607d21ef, 0xb23645d5,
- 0xff09d6eb, 0x2fd0cff4, 0xe851704d, 0xe0c301bc, 0xc096beb0, 0x73c4e1d7,
- 0xaded190c, 0xf8dde508, 0x4f4c9762, 0x4f984a1f, 0xf3095e64, 0x1564597d,
- 0x931d0fda, 0x3f20ef5a, 0xe69033a0, 0xd67ebc06, 0x84b0e5af, 0x817912e7,
- 0xb5ce118b, 0x0bc32872, 0x77217ff5, 0xc1bd6066, 0x1f4ef450, 0xf7845e9e,
- 0xf3a60212, 0x8eb421ce, 0x33dcbcee, 0x2552d17f, 0x6feffcea, 0x5fcb9b17,
- 0xc62ffa71, 0xf93b5479, 0x1f4960fb, 0x57be7448, 0x94ee75dd, 0x64f2fb47,
- 0xd123c737, 0x41d5d205, 0x559d37ae, 0xc87d09bc, 0xf3323d9f, 0x7c3ccb45,
- 0xec22bc96, 0x53a03ad1, 0xe832a73c, 0xb7e29863, 0xaf0d1d21, 0x3c66ef81,
- 0xfb77d0c6, 0xf079e8b8, 0x31b9fa98, 0xe897183f, 0xcb973e55, 0x7a28e3f7,
- 0xf9f12dd8, 0xdced8a87, 0x1921646e, 0x20c73af1, 0xcf05653c, 0x8fe33227,
- 0x8d77b5ec, 0x82b62773, 0x0b9e75e7, 0xb9cfc6de, 0xa733e7a3, 0x3c16eef9,
- 0xdcd399ef, 0x7b9e3e6f, 0xf8ba29ce, 0xab774c43, 0x51e3fb9d, 0x2250fc5e,
- 0xb7a6f67d, 0x21e3545e, 0x46e6f1dd, 0xae609f7a, 0x73bfef9b, 0xf88aa759,
- 0xe35d300f, 0x5a6156e7, 0x27cc6ddf, 0xfa2a0df2, 0x84896e1d, 0x721ab86f,
- 0xbe18beb7, 0xb9bdd51a, 0x425f3b07, 0xf41a05b4, 0x321b3a5c, 0x5ef935da,
- 0xaede79e6, 0xf14e0e0b, 0x838a47fb, 0x6ebdd5d6, 0x58c1c107, 0x7c24d427,
- 0xbc49c174, 0xa5c066cf, 0x37f1dd6b, 0xf8fe855f, 0x1cdce4de, 0x790fe8c7,
- 0x579f3c9c, 0xc13e9c34, 0x0b939022, 0xb91ffedd, 0xb77afca1, 0xcb4c2eff,
- 0x95839d1c, 0x5537c421, 0x0390af98, 0x1c00a517, 0xb8141a3e, 0xd1e11938,
- 0xf482f7d2, 0x2e4ec3fe, 0x1ba70e0f, 0x1bab6d7a, 0xc8bd9be9, 0xf7e35af5,
- 0x38ed5632, 0x008dff7e, 0xe55e8f9f, 0xcb95cdef, 0x22ee6bde, 0x62ccb2ff,
- 0x7a4621d9, 0x1e0df858, 0x7bc4db76, 0xf39d7cd1, 0x79ef0e14, 0xcf74f18d,
- 0xd952de6e, 0xbcfdbef2, 0x957e3ca5, 0xae632d29, 0x2b09d8b7, 0xecf75d04,
- 0xd11afd07, 0x3a5fccfd, 0xd92dde99, 0xc893e9a9, 0xa738f1cf, 0xfd53f9b3,
- 0x4ffdc632, 0x1f912d58, 0x6f51fc69, 0xe7e42b53, 0xc87d1387, 0x5ceff3ae,
- 0x97ef899c, 0x3f70b454, 0x28bcaa67, 0x7d203fe3, 0xefdf3f68, 0xe108bf31,
- 0x5d7bf2e4, 0x369af3a6, 0x474332b5, 0xe5d5be7a, 0x7f907947, 0xc45dffbd,
- 0x30e7e1a7, 0x40e7ddf6, 0xce38c00f, 0x39bc5bfc, 0x0df91f48, 0x0ea53f4e,
- 0x5c81c4a6, 0x039857cb, 0x298d54d3, 0x98e34c4e, 0xe5ecd303, 0x9daa7f42,
- 0x2783fa45, 0xf7c34f27, 0x9f9bf3c4, 0x17db14fc, 0x927d912a, 0x9bf29e89,
- 0xee82fd5f, 0x28f3f9c3, 0x5b5bf74e, 0x39dd8b34, 0xff9ac1ba, 0x9f359376,
- 0x33e6b111, 0x03f35a0f, 0x7d266d70, 0x1e1eff73, 0x9a7a529f, 0x1e7defdf,
- 0x3c22a060, 0x3e49d9b6, 0xce6d294e, 0xd38778c6, 0x586dbb4f, 0xdceffbbe,
- 0xeadceeee, 0xf72577a4, 0xe2c717bd, 0x6a1df092, 0x3f2c46e7, 0x8d90d71d,
- 0x4fa845fe, 0xbbb04b71, 0x71bb408e, 0xbd06a5e7, 0x69be2986, 0xfdf83fe7,
- 0xf6adce94, 0x9c51c630, 0xd3e4f5de, 0xb7a79f48, 0xec7d200e, 0xc3642979,
- 0x70f7437e, 0xf3884ffc, 0xe954e458, 0x7e3dab16, 0x1d01e842, 0xe879b527,
- 0xd6b8ba17, 0xc24beeba, 0xa8a77cd6, 0x7d331b7f, 0x10f8c74f, 0xdc34aaef,
- 0x7ec53767, 0xc173fdbf, 0xa53d4f17, 0x8b2b7419, 0x37991ef7, 0xe2befba5,
- 0xdb73eeee, 0x8e800325, 0x4316114a, 0x4697bfba, 0x0f85db8d, 0x38927fd1,
- 0xadfceb2f, 0x5539f04c, 0xef896455, 0xaafbd2e8, 0x4d53697c, 0xed4151fb,
- 0xd27c94be, 0xdca5f757, 0xca67da66, 0xb9481eb6, 0xdb6bfa19, 0xebefd0a2,
- 0xe279cd95, 0xf8490981, 0xf9c06e5d, 0xe7fa3962, 0xf25e1ada, 0x8bd03d60,
- 0xbde39ac7, 0xa5c76b0a, 0xe9f1354d, 0x834ba5d7, 0x0e74ca9f, 0x5a72e79f,
- 0x461ef172, 0x1dff2d69, 0x1b86d2be, 0xe11abbae, 0x4fdf9ebe, 0x9e5856cf,
- 0xb653fc0c, 0x8fef86fd, 0xc7c1ef86, 0x3e70f9c6, 0x2d24f8d9, 0x3fadbbde,
- 0xee76f743, 0x44ff71b5, 0x7b465c34, 0xfdef7e38, 0xe508ab81, 0xa2f7f412,
- 0x3fb52c6d, 0xe47d0368, 0x6bd0e4c4, 0xd3954337, 0x570fe1ac, 0x95965c53,
- 0x253e809e, 0x373ab7d4, 0xf48dbe4b, 0xb5f67975, 0x97fb5aa8, 0x943a3c51,
- 0x8a37b4c7, 0xa27ed6c3, 0x47a57cf1, 0x68f77e32, 0xa25e99a4, 0x119df5eb,
- 0x2ab7dfa2, 0xcd720a5b, 0x1d97efa4, 0xd878a1ad, 0x19c871e8, 0xc13b8a68,
- 0x7c4bd1fd, 0x027a14ec, 0x22d91c93, 0xcf287c5e, 0x48a7bbd3, 0xa5104097,
- 0x5ea9b297, 0x6cb5eb84, 0x4bcfa63a, 0x99640791, 0x33f203cb, 0x79278b6d,
- 0x3eb7a6d0, 0xa3a473f1, 0x1e74d1fa, 0xefdc5fd6, 0xe846f36e, 0x77e358bd,
- 0x9e74da71, 0x5276692f, 0x8fe9d53c, 0xcb979234, 0xeb138e30, 0xd9b4ed3f,
- 0xbd3b5f40, 0x8c64efbd, 0xe06b6e0b, 0x6a9f8aef, 0xfb593be8, 0x9a37fd8a,
- 0xf17d8def, 0xdf13fe08, 0x8bf8f54f, 0xacdfb83d, 0xa9d371e0, 0x2a332b7d,
- 0x68c9e063, 0x6655a497, 0x79d2bda0, 0x91b7cbab, 0x0ae953eb, 0xc8d3ddf9,
- 0xfc2f92af, 0x79e9f749, 0xbea07877, 0xe1faea1b, 0xe5073eff, 0xfc77e88d,
- 0xa1ddf640, 0x1f3eed0f, 0xa015905f, 0x03f4e3fb, 0x7cfe3036, 0xa0144585,
- 0xafb8f9b7, 0xc93ca18c, 0x25ebf9cf, 0xb05c238a, 0x7c1ebac6, 0x1fbcdae7,
- 0x292fe116, 0xb0b8c50e, 0xd68b4a06, 0x718bcb5b, 0xbc50f0ff, 0x94cbc517,
- 0x19cb59d4, 0xad1f908b, 0x7b4bfeac, 0xca7db82c, 0x6bf9f58c, 0xa3b9163c,
- 0x50f9dc92, 0x95f5a3ce, 0xd20037a2, 0x1cfec49b, 0x6d2733bc, 0x4b1da401,
- 0xc82da427, 0x7cee7bc4, 0x8ed3231f, 0x8fbf98f8, 0x45953a57, 0x7177f106,
- 0xa58fee18, 0x346452cd, 0xe42c1de6, 0xe3bfcb19, 0x6eb820fb, 0x63313df3,
- 0xf35eb8dd, 0xc726f677, 0x10cf71ab, 0x2f2e6bd7, 0xab287013, 0x3afc5bb7,
- 0x90a5ea13, 0x7f78dbfb, 0x55da95a9, 0xb7697e34, 0x5ff62bf4, 0x1399b7d8,
- 0x68a135f0, 0x798b8c83, 0x878e4ba8, 0x0f75892f, 0xdf80b0e5, 0xf4143743,
- 0x107d7e43, 0x02fecff5, 0x9f2439c0, 0x45809f84, 0x5c5e301c, 0xca9e5766,
- 0xfcf397b3, 0x8ae04f3e, 0xaf6081da, 0x873a01a9, 0xbde72f9a, 0x471bf78c,
- 0x425e0626, 0xf9b7ccbc, 0xb7c42b07, 0x17e411fe, 0xf0e1ca5d, 0x4bcad8f0,
- 0xc5d9632a, 0x933fbf02, 0x3e5ce81a, 0xa3ef8bb4, 0xd54eacee, 0x8bfef7ec,
- 0xfb094790, 0x4f5ee95b, 0xee890ee7, 0x1d223f13, 0x8fb6fba1, 0x6865e95c,
- 0x9e01a7c7, 0x223eee50, 0x5ef815b1, 0xace3565e, 0x9e212f45, 0x787ce2b3,
- 0x38de5fde, 0xd1772e49, 0x15beb9fa, 0xcf01b95f, 0x8de75283, 0x0e748b1c,
- 0x2d779eeb, 0xe3d0ff7c, 0xb9faf1a5, 0x96d3de38, 0x8f17d287, 0x16f3f1c2,
- 0x387c84bd, 0xa1ee8e3a, 0xdcac02a7, 0x8d5d287d, 0xcb1a547a, 0x60fa87d8,
- 0x58ef0cda, 0xe43fb9f4, 0xdb24e3e1, 0x50b379e4, 0xf3cb1bcf, 0xf92c7e7d,
- 0xae111237, 0xed5271a5, 0x17ce3a6c, 0xe85ea3bf, 0xcb823f40, 0x9529ef84,
- 0xea7e3819, 0x69269e50, 0x3c0f8a11, 0x99bde064, 0xd12de9c7, 0x25e9c919,
- 0x454a4c5f, 0x1b50ee3b, 0xbf20d418, 0xec340d0e, 0xf48b88cc, 0x792361f0,
- 0x2df7617d, 0x5ff7e0c9, 0xfa1b0692, 0xa1d7af0f, 0x513213fa, 0xf5c1beae,
- 0x7e5c4ff1, 0xa65f57f2, 0x4fbf8ec5, 0x0a78e048, 0x61638b9e, 0x3838ff93,
- 0x13d233fb, 0x2c3ce783, 0xf027da6c, 0x1c734dbd, 0x7ed15977, 0x72841dfa,
- 0x01f742d6, 0x71ac1bca, 0xc5c597e7, 0xf3a0d71e, 0x0b1b39e0, 0x1e3225f5,
- 0x21d7f688, 0xc2d573a9, 0x4b17ba24, 0x73c13be7, 0xc6990b1a, 0x63eb9e0f,
- 0x33cd77cd, 0xaee9fa85, 0x9af5acc7, 0x2c7aa73e, 0xe383d5a7, 0xb4adebb4,
- 0x29cf048f, 0x6fd8ced4, 0x90b6c23a, 0xeedcfc0a, 0xe21de5e5, 0x6fa8cf3c,
- 0x5b3ed7f4, 0xf8def713, 0x556de8bb, 0x2e007820, 0x219f368f, 0xf359747f,
- 0x418b823e, 0x89f0dd0f, 0x7c132167, 0x225baa52, 0x69ede036, 0x7bb86e0f,
- 0xc990d814, 0x871f05fb, 0x9feddd36, 0xbbf8e508, 0x8ebe260f, 0x73e2eacf,
- 0xd90f3312, 0x42172e64, 0x9d4f7775, 0xfa8bca68, 0x9b43ed5d, 0x340a98af,
- 0xb78a3595, 0x27c1e6bf, 0x4e4e595e, 0xdf111a8b, 0xcf3839df, 0xa23bca6d,
- 0x8fc82ef2, 0xa8f5e536, 0xf2a8a4f2, 0x40fca8b4, 0x1dcdbf5e, 0x40fb2c19,
- 0xd4f83fde, 0x9efbf815, 0x7322fd6d, 0x358f05f1, 0xf02bb6f2, 0xb3cb7cf7,
- 0x56d3eff8, 0xc93e4b34, 0xba2b3f24, 0xb55bf3ce, 0x0e10a3f9, 0x1ca32f2d,
- 0x74926b28, 0x0d5debd4, 0xc79423db, 0xbb535e76, 0x963f6e06, 0x76a11c35,
- 0xd23ff6bd, 0xef7c7c46, 0xdea9f7c8, 0xd89fcef9, 0x5befeb0c, 0x751e76f5,
- 0x4e2c0a44, 0x7f7eee48, 0xdbfb6dbd, 0x0a2fbfdd, 0xf9fbdbdf, 0x8d1c900f,
- 0xc41e07ba, 0xf9bab8f9, 0xbde380c4, 0x7bd2cf23, 0xdd1c7fb4, 0x03aa16fc,
- 0x2cce4bf1, 0x9fdda053, 0x438f8fcb, 0xb4df0b7d, 0x67e37dc5, 0xdc12f852,
- 0x81651e8f, 0x5bdc704b, 0xc3ef87cb, 0xac384c9f, 0xef863eb6, 0xf0786f95,
- 0x98142be5, 0xeb7761df, 0xb709fc20, 0xf06f094d, 0x7f2b727c, 0x1dff4551,
- 0xa0f0e7e1, 0xc83641d6, 0xa6c0993f, 0xeb787e53, 0x3d7f9863, 0x3faf04e1,
- 0xac9075ba, 0xf27209a3, 0xdf90a98a, 0xf7e6c7ac, 0x37ae04da, 0x369bf31b,
- 0x8453ffdc, 0xfbe32b0b, 0x76335e0d, 0x5b9d3c80, 0x66db6a72, 0x1fdcc780,
- 0xdb9c93c5, 0x55dd76dc, 0x50870479, 0xa611c61e, 0x7ed3780a, 0x215d7248,
- 0xee1fa27d, 0xf1ba7d81, 0xe2dc1ee9, 0xd2e2fda5, 0x37a8edca, 0x451dcea4,
- 0xc7a145fb, 0xddc9e92f, 0x52193869, 0x3ae92fa8, 0x8db2eb97, 0xef5223e2,
- 0xf51e9372, 0x033df8a0, 0x0fa23be0, 0x36cbc097, 0x096d9eb1, 0x80f6bfdc,
- 0xf3f51a67, 0xc47fe49e, 0x42ca6321, 0xc5a7f24e, 0xf372be91, 0x202b9006,
- 0x7989d7d7, 0x097b5baf, 0x466e29f9, 0xfc28f13f, 0x67d7efee, 0xbffeb754,
- 0xaef2032e, 0xdd6ebb6e, 0xf33f7f2c, 0x0dbaf6b9, 0x5b90dcbc, 0x7b79d2eb,
- 0xad4abf63, 0x3ea4e3e6, 0x5c46c978, 0x28c2bc47, 0xece17b7e, 0xd1971b11,
- 0xad2d7ffe, 0xfdfdf99f, 0x5a3f0ed0, 0x7a86c43c, 0xc29f81a9, 0x1257fee1,
- 0x89373d60, 0xf035efdf, 0xb74f8c64, 0x907f51e2, 0x3b407f41, 0xeb403135,
- 0x0c627d07, 0xfae06e0f, 0x3316d204, 0xad2997c1, 0xfffbf0e3, 0xfdb53820,
- 0x4ff4e02b, 0xc947779f, 0x0c379021, 0x7a5f2ffb, 0xedff72dc, 0x23d1013f,
- 0x8000702a, 0x00008000, 0x00088b1f, 0x00000000, 0x7dc5ff00, 0xd554780b,
- 0x733ef0b5, 0x9992bcce, 0x924c2664, 0x84e3c849, 0x71100840, 0xf0444312,
- 0x51888431, 0xd4503b69, 0x20717ad8, 0x9926023c, 0x4b62d5a8, 0x79120cff,
- 0x22341809, 0x0281c150, 0x06f55bc5, 0x701a8c45, 0xaf7a8a44, 0xb7ad8ef6,
- 0xff7f6c57, 0x4a8f8808, 0xd2f5a232, 0x5ad7fd97, 0xce64ef7b, 0xb6b4a924,
- 0xdc3ef9bd, 0xd9cfb3ee, 0xd7b5ed7b, 0xf6b5af6b, 0x4cf5a61e, 0xd8c05c0a,
- 0xce6a2566, 0x7c2c64ae, 0x61edf148, 0x67cf07f0, 0xf7fb193b, 0x95d5a0b4,
- 0xf19fd8c9, 0xe6c60aef, 0x2729bf7e, 0x8ded0658, 0x61cb1823, 0xcfbbf52c,
- 0xd500ded4, 0x7a3f4bb9, 0x3f7c0f7c, 0x8ca97bf7, 0x43ef03e9, 0xf7c18c8f,
- 0x5b6dbcef, 0xd2842ecf, 0x793519d2, 0xf986bca0, 0xef7bc056, 0x27435898,
- 0xbe0ef7f4, 0x5563097a, 0x35e5bbdf, 0xdbb19136, 0x93632a5d, 0xf8ab5b18,
- 0x258a9873, 0xbbe0db0b, 0x644b2cf0, 0x7d63114f, 0x0cd85311, 0x23b875fd,
- 0xb8c1175b, 0xf995d71d, 0x1f5fd0c2, 0xef867e63, 0xf7a54b2d, 0x4c3ddc3a,
- 0x744bf6c3, 0x0ec24017, 0x19faa17e, 0x5a37e3d4, 0x7814bb22, 0x76c2ce5e,
- 0x3e325f6c, 0xf3fa8612, 0x7f7d0e30, 0x0f644a63, 0x8f82cfb6, 0xa371dea0,
- 0xfe861237, 0x47622cec, 0xfa763a78, 0x8c1c3273, 0x05acaae5, 0x8228efe1,
- 0x2b59943a, 0x0701cdd9, 0x713fcfe2, 0x0f007396, 0x6899775f, 0x3d95a93e,
- 0xf437ff4f, 0x7ddbd6c7, 0xe1b0a063, 0xcf6f58ab, 0x3b997826, 0x66f88558,
- 0xb803fc1a, 0x89c81fea, 0xcce7c3ac, 0xb1eb8557, 0x479fe9da, 0x5520fff0,
- 0xb61ff847, 0x0ab635b3, 0x66d61528, 0x0bfc00cb, 0x43fb5878, 0x37630c00,
- 0x978000e3, 0xd670d7ff, 0x2bf3c3a9, 0x07ad0a5d, 0x556df9fc, 0xbc67cd8c,
- 0xd4f2fe7d, 0x58899577, 0x1a6b51aa, 0xa5735b3c, 0xef46c7bf, 0xe28f3fb1,
- 0x0bfa0da5, 0x25b7f132, 0x09ba44ee, 0xd86977e2, 0xba9defff, 0xfdf0eb03,
- 0xf8765c44, 0xfbe074be, 0xf9a3173a, 0xfc3955cf, 0x475535ac, 0xc8fc4afc,
- 0xd7c24eb2, 0x713f90fe, 0x724e393c, 0xfcbaf7bf, 0x00be2237, 0x0f74d1ef,
- 0x75a545e2, 0x63d7864d, 0x43b06f89, 0xd556dcfb, 0x33e0377d, 0xf349ccb8,
- 0x9cdef095, 0x158cbf1d, 0x74ffee0f, 0x8695736a, 0xe9c65ff3, 0x02b72d9d,
- 0x62f112e2, 0x5d03a819, 0x63f1642c, 0xe7886526, 0x8445f45a, 0xc247517f,
- 0x2fdff4f7, 0x49ef89ac, 0x92ba617e, 0x2ba0bf04, 0xdd70d15d, 0x375f0a82,
- 0x373e258b, 0x6e183650, 0x82d5cf89, 0x245d24ee, 0xe2357be3, 0x7c60d27b,
- 0xf93d2c7b, 0x99706fd8, 0xdc94f095, 0xfa11633f, 0xf03b21ee, 0x16ddd00f,
- 0xdd7a2145, 0x646a5772, 0x3da7f225, 0x19f117be, 0xad157c3a, 0x1492ef77,
- 0xdb2bc19d, 0x9441302c, 0x9c9d8733, 0x4a7a4b8f, 0x617a9f90, 0x9f587ece,
- 0x9dd5d7de, 0xc1024561, 0xeaebf358, 0xdeffa42e, 0xfde6af67, 0x19d548ac,
- 0x618843d4, 0xfe143718, 0xbc032b43, 0x2cc5349e, 0xe0175e34, 0xff09c257,
- 0x435fe17a, 0xe8bc80c5, 0xbf1c06c3, 0x9807cb8b, 0xe71a12e1, 0x1d6c29db,
- 0x526cdb8c, 0x6f6826fc, 0xb23e3a5e, 0x4361c392, 0x20146a3e, 0x9b589b35,
- 0xf7c03152, 0x2513a6cd, 0x36f195b7, 0x85bbde0d, 0xf78175f1, 0x5f002a8e,
- 0x4c7d6da3, 0xfa45ba45, 0xd8a5f687, 0xff80345e, 0xf9bff5e6, 0x7cdfc213,
- 0x8d1748c0, 0xb1e7198f, 0x8a9e9134, 0xb524e806, 0xd589e392, 0x8018c8b0,
- 0xa9ea29d7, 0x8a88b1b5, 0xcd565a78, 0x66e9024e, 0x8199e91e, 0xecace3f4,
- 0x0ca1f364, 0x11fcc07d, 0xf74a7b80, 0xc24697ce, 0x58daeefb, 0xb4374e3e,
- 0x4e8bb6ec, 0xbeb0345d, 0xba4bce12, 0x41cca937, 0x0077d1e3, 0x83bf7f8a,
- 0xfb371bde, 0x6ef2c482, 0xa4d32efa, 0xe0f6bd12, 0xcd1be423, 0x38c0a39f,
- 0x328c979b, 0x82a67ae1, 0xbcb9437c, 0xaeec7db0, 0x7f678415, 0x07b7ca09,
- 0x09ce80d3, 0x942abe9f, 0xeaeea52f, 0xbfa0bb5f, 0xffd5dca7, 0x138e258d,
- 0x47f4e270, 0xa648be90, 0x23bd64e7, 0x6e2ecbdf, 0x0c716f29, 0x17f01eff,
- 0x35be2de1, 0x4d0fcb9d, 0xffa2faa1, 0x475cef30, 0x374469f0, 0x222f6db7,
- 0xdac0dc79, 0x591ade89, 0xbbf482c4, 0x69c2c6c8, 0xe08b1740, 0x172874b5,
- 0x3d32b16f, 0x4496fd61, 0x2146f58c, 0x31616e0f, 0x7d96fefa, 0x2c35ed49,
- 0x26f684ea, 0x62a68b1b, 0x6f6c69d9, 0xef417166, 0x3e26b67f, 0xbe7c1d67,
- 0x77758b37, 0x20d444d7, 0x1dab7bcc, 0xbe065774, 0x33eb4ed0, 0x5a4ef965,
- 0x7f0af4cf, 0x4fa83dd1, 0x76fb355e, 0x27bedd01, 0xe7e24bd6, 0xbbf5575e,
- 0xd514f788, 0xdf8ff344, 0x9cfc2563, 0xeb8dbd02, 0xdd9b9f7f, 0xdeca1b3c,
- 0x7a3bdd56, 0x55c9a234, 0x1839db30, 0xb39eebcf, 0xb8dd2037, 0xb7c226dd,
- 0x65cc7e7c, 0xddd57aa6, 0x522bff02, 0x088abb23, 0x9e9113dd, 0x7d4946aa,
- 0x82ce26ca, 0x5666bbfa, 0xe6f509d7, 0xec411deb, 0x07ed07af, 0xb9b817a8,
- 0x5b7028de, 0x2eb27e68, 0x06e92be7, 0x52fea1c6, 0x84a5e22e, 0xc85b8c63,
- 0x7f89b641, 0xe6eff427, 0x493b2925, 0xafd3f6ff, 0x96fd1189, 0xd7882c05,
- 0x795c84e7, 0x3695ca4e, 0x9a2b972b, 0xa832ee6b, 0x9941f73f, 0x95e01d6f,
- 0x83de8295, 0x4a3f1bef, 0x5e9e91d1, 0xef5fe8f9, 0x9fb419fd, 0x5ba2c0fd,
- 0xd2017da1, 0x73dbac18, 0x6047970a, 0x8fd4307f, 0x38f6c08d, 0xb1c1e36e,
- 0xb41c7f64, 0xc846fb08, 0xe0b4c6cf, 0x4fd085d6, 0x3e9993e3, 0xbcf664a0,
- 0x5ee8f239, 0xf7643f6c, 0x1b7e81ed, 0x1b5e3853, 0xdf491b9f, 0x4e0f613f,
- 0x733cc377, 0x3c9f91ad, 0x05e37281, 0x677bd92b, 0xc2117459, 0xaed3b67f,
- 0x70277be0, 0x4250e95e, 0xeaf3829b, 0x043d9276, 0x10b39a7c, 0x36b93bbe,
- 0xe04bcf9b, 0x0986e4e9, 0xcd9b17c4, 0xb3f0bc7c, 0xc27fbd0a, 0x0391981c,
- 0x974f13f5, 0x534056fb, 0xb512c05f, 0xee873d00, 0xbd5e76e3, 0x7881df49,
- 0x09538762, 0xa11eb95e, 0x62678b8d, 0xf2e9687b, 0x1c7ca3af, 0xde51cf8e,
- 0xd9b904b3, 0xc805e2cb, 0x461adb4f, 0x9f514675, 0x91f38f74, 0x585e655a,
- 0x171ba07c, 0x9994f77f, 0xc87e35e3, 0xbe7cf44c, 0xb57ce3fd, 0x707fae2a,
- 0x65c8109c, 0xe48ff926, 0x1d5d4272, 0xfec8ceaa, 0x2d973d0c, 0xfb633aec,
- 0x1de0ceeb, 0xe6bfa06e, 0x9de7fffb, 0x38df8465, 0x9ed645c9, 0xca797c49,
- 0x748b9fec, 0x5a89aeeb, 0xf3e827e6, 0xeaaf820d, 0x63fec2ad, 0x1f224b51,
- 0x6aaaf6ca, 0x72cbdd23, 0x677fa0bd, 0xc1f7cb8c, 0x1fc126ed, 0x1ea2b4df,
- 0x6641c29b, 0x1c47a885, 0xfd4ebfd8, 0x6a20f94f, 0xe17a87a9, 0x9165a8f2,
- 0x004f9128, 0xcc1b51df, 0x2756d4fb, 0x03406fe7, 0x3268b3f6, 0x48b97d23,
- 0x02b5fb05, 0x3d5deb9f, 0x9fa72eb0, 0xfafa7376, 0xf0056023, 0xf7898f3d,
- 0x82ef60ac, 0x4da67b1c, 0x607ee289, 0x2eeb16de, 0xb5f2117b, 0x7ae2755f,
- 0x8e48576e, 0x569b6bcd, 0x4bea15b2, 0xeb405c0f, 0xd399369f, 0x9b88d2e5,
- 0x2114e2f4, 0x11adeb1f, 0x3fdfd90b, 0x01f21851, 0x74764ff4, 0x53947c23,
- 0x280f1831, 0x10f40dd7, 0x5d83a849, 0xcb93a534, 0x9cf20655, 0x524bd825,
- 0x671ca3de, 0x919ff649, 0x1f52c23e, 0xf4c7b971, 0x527b946c, 0x0aebdf2e,
- 0xae49b974, 0xf5c6ce8d, 0x72e4f585, 0x7842bf73, 0xa42d626d, 0xe81ea44f,
- 0x91e8571f, 0xeb986ad3, 0x2a26eb2b, 0xd117775f, 0x27594b78, 0x57a913e9,
- 0xd783a386, 0x7e0e84bf, 0xed007486, 0xe8b01f8d, 0xe35e3065, 0x9a6d1672,
- 0x44e74bc8, 0x4f5c8fd2, 0xc49eb8da, 0xf43ce532, 0x4c7eb265, 0x7ac987d6,
- 0xf5c2db30, 0x69675c9d, 0xe74f64cf, 0xe594c076, 0xfcc19511, 0x3ff9a636,
- 0x60349cce, 0xb2de84d7, 0xb10bf4d9, 0xe0a3601e, 0xd369c5bd, 0xf686ca6e,
- 0xc8fcc690, 0x9780a957, 0xbb7cf09d, 0xb36b7bb0, 0x2d7bdd39, 0x5acd7e9c,
- 0x703b9580, 0xcfb4625d, 0x1732678d, 0xe7c4a3d2, 0x577c2776, 0xfd71df81,
- 0x8dbdffd4, 0x7c24a5b5, 0x9d9cfd5f, 0xcfe7eae4, 0xb256233a, 0x6e858247,
- 0x57eb2fe8, 0x7b53b256, 0x3e92739f, 0xd0fa15ed, 0xd128f683, 0x5fae2acb,
- 0x21275d71, 0x648f5535, 0x35cafb48, 0x4a045123, 0xcdc9acfb, 0xf6c1aced,
- 0x8a2f6890, 0xcae9cf5d, 0xcfccfb4a, 0x62773ddd, 0x6861e01d, 0x588fff9f,
- 0xe981d0e7, 0xe787dfe5, 0xc7c380a1, 0x472c1fb1, 0xdfaab57a, 0xf406deb9,
- 0x1e5d4335, 0xd1e60bbf, 0xa170ef94, 0xfc29ab9e, 0x846f2ff5, 0xcc0787fa,
- 0xbceb8acc, 0x1b1d7a67, 0x5dfcbc35, 0xe89f3112, 0x5b97e049, 0x4deb19f6,
- 0xa87ac69d, 0xc82f58cb, 0x4f4e7a70, 0xfbe1d920, 0xd5b5d033, 0x4ec1f2da,
- 0xbcfad780, 0xa7d1f495, 0x067160ee, 0xfc535bca, 0x5ad9e218, 0xf444f1f8,
- 0x3fba846f, 0x02b4b051, 0x38cac4ed, 0x3faf91fe, 0x742bcfb7, 0x01b7810d,
- 0x899b31fc, 0x3ad60cf0, 0x85ce492f, 0x2c789f04, 0x845f0ffe, 0x9d9a2ff9,
- 0x9e9bbae2, 0xaa4e67f8, 0x60927b42, 0x572da164, 0x2dfb887f, 0xae096f78,
- 0xf059e9ff, 0xb0d5c01e, 0x46c3eb85, 0xbe434b16, 0xd3bb066d, 0x477c4b06,
- 0x5b875f06, 0x5155e2da, 0x8c8edff8, 0xa70871da, 0x802d27f6, 0xfb1ab1f4,
- 0xaf93b04d, 0xe07ae0cd, 0xd7767d96, 0xdd1e0329, 0x2ba87a86, 0x912a75c7,
- 0x61fc84ff, 0xb8968a79, 0x09577a1f, 0x6bf88b5e, 0xa658f5b2, 0xfc57f8c1,
- 0xf79233e9, 0xa7cd978b, 0x5d80c47d, 0xb4f9256d, 0x3d20aef8, 0xdf2b697f,
- 0x6ade9e17, 0xa7ef11d7, 0xe3fdf3b7, 0xc4473ce2, 0x857bff06, 0x8bdbdb9b,
- 0x19453be1, 0xbc64c78c, 0x55f0ffbd, 0xf7a3a45e, 0xdc2f1f19, 0xf78fedc9,
- 0x62af805d, 0xf7f60efe, 0xefd8177e, 0xaaf9e20a, 0x2e2e510f, 0xd0faaede,
- 0x9c87604e, 0xbc598fe4, 0x0b71cafd, 0xa7dfd81d, 0x5fa1a623, 0xe895c768,
- 0x02f7c289, 0x89d7ee11, 0xb5cf015d, 0x1d93171d, 0x95bb7477, 0xedb6e9c3,
- 0xf15c79c5, 0x4af89527, 0xda20b133, 0xff161dc7, 0xfd67e438, 0x70333de1,
- 0x959fde5d, 0x1ff7a26b, 0xf10b9857, 0x85965ee1, 0x5a2b17cf, 0x61b7f900,
- 0x899992cb, 0x866a4ef6, 0xad35eb4a, 0x8f567970, 0x7ae9f883, 0xdb4da3d4,
- 0xfc707f81, 0xf2ff6fd9, 0x3f224f46, 0x4cc55edd, 0xc3cbf609, 0xc27a235f,
- 0x6be028bf, 0x57d7c0b1, 0xaa6b2be5, 0x12968be4, 0xef8ba394, 0x0d71296e,
- 0xf3f45761, 0x0f9cc3c5, 0xb850cbef, 0xc32f20ff, 0x6e18cfb0, 0x3528e65f,
- 0xf9b15e91, 0x940f7f98, 0xc62db0d9, 0x0c81f7fd, 0x640fda8d, 0xfb5f7b70,
- 0x5efb6ddd, 0xcd4d7987, 0x80cf6e08, 0x97f3217a, 0x71ebbae3, 0xb1983557,
- 0xbbb26288, 0x6e56c3d8, 0x8edc6ac7, 0xf6c99cde, 0x8fd84bae, 0x997f6277,
- 0x62f61724, 0xffc7bd3f, 0xdaf10c78, 0x44f1f05c, 0xe7420fb4, 0x1fa0b33e,
- 0x90add1cd, 0x02f8773c, 0xd425e90c, 0x282d8b3d, 0x21c3901b, 0xc913d71f,
- 0x0653faf3, 0x3c84efdf, 0xfde7ea71, 0x3b7f9c11, 0xb73e9cdc, 0x3f214b2d,
- 0xc44f36e4, 0xb5ff408e, 0xa5ed2a7c, 0x67efc225, 0x5f94fddb, 0x288efa45,
- 0xd75831ae, 0x35f47f39, 0x30a88dcc, 0x8bbb87ce, 0x77d9dfc9, 0x854f9a60,
- 0x1feec736, 0x788519ad, 0xf0fb32ea, 0x27af877d, 0xe1f7e70d, 0x386993ee,
- 0x2add86bf, 0xf221bbcd, 0xb2c2d649, 0x33f0b901, 0xca3af825, 0x1c52e601,
- 0x0f94be38, 0x34feee1f, 0xfb83816b, 0x567f480b, 0xa7978d0e, 0x8e7ed3dc,
- 0x39715fdf, 0x1e8f975f, 0xee5046b7, 0xfd07647d, 0x3f6f2096, 0x777d7272,
- 0xefee432a, 0xdf500b3a, 0x2a6fd7f4, 0xf89ca135, 0xdfcf8b8e, 0x402ce963,
- 0x628dfc7e, 0x1ae967ec, 0x6c808b13, 0x5006b25f, 0xa3e8f203, 0x40299f47,
- 0x9ee1ff79, 0x27e60a67, 0x9dfc97c0, 0x78e57b2c, 0xfd266fc2, 0x344b1ea8,
- 0xef9bc70f, 0xe57f72b3, 0xf9547e30, 0xfdc2db3e, 0xab3e7da1, 0xbf28748e,
- 0xf1486beb, 0xc7db7da3, 0xe6ff246c, 0xacbf0b77, 0x83da3fdf, 0x7df918fb,
- 0x1e15ff52, 0x974a4f4e, 0xd483fe42, 0xe3c938b2, 0x7bde59bf, 0xe4133d60,
- 0xbff3ac3d, 0xd9345f21, 0x3246c7e2, 0xe20b0fa2, 0xd0ecd2cd, 0xad653f50,
- 0xbf15f4e4, 0x2afb44c3, 0x81d7ae4b, 0x928aecf2, 0x30133694, 0x6d2527a2,
- 0xf201c622, 0xfde94b73, 0xfba73570, 0x7f231670, 0x516b0e5b, 0xb8bb5e48,
- 0x326f3edf, 0xea83ad73, 0x9edc11ac, 0x16df32f1, 0x5dd698b5, 0xc490ff41,
- 0x480bd487, 0x3f1f283f, 0x3f446c52, 0x7642b74a, 0x9cea6aa7, 0x470efd8b,
- 0xc847134f, 0xa7a73ffd, 0x893ffafe, 0x188f269e, 0x3a829e8e, 0x36d793d1,
- 0x3f093d34, 0xcfbf79f1, 0xbfdc01c2, 0xdd7c0b66, 0xfc4ee427, 0x9bf49b0e,
- 0x99df382b, 0x3699bfa2, 0xfd455447, 0x9c7f33e1, 0x187dffe8, 0x27dc5fec,
- 0x0efda0e5, 0xf395c8e5, 0x16375a74, 0x417f41eb, 0xd236c5ea, 0x629af78f,
- 0x64af6845, 0x8fd96f8f, 0xb73d9174, 0xed2562ac, 0xa8dcf2ff, 0x92b7500f,
- 0x7559741f, 0x0488d4e0, 0xdf10e17b, 0xe5df34cf, 0xbbd3e7a7, 0x1a107db9,
- 0x387b216d, 0x7184a5d4, 0x96039b9d, 0x6b41da08, 0x095fee15, 0x3cebb06f,
- 0xa0afa3ee, 0x740fcfb8, 0x488a171e, 0x8ecf6fff, 0x35bd23ef, 0x91efc838,
- 0xf83a3f1c, 0x1fc7ca85, 0x8efc68c3, 0xeaaf1e72, 0xfee75ab8, 0x1d7eb115,
- 0x6e39fcb3, 0x18d607b4, 0x85c659f9, 0x18809cfa, 0x7afe6f18, 0xae43ad3b,
- 0xd2ccf1ca, 0x0cff5c6d, 0x67e40b96, 0x162c9ace, 0xfa6fc446, 0x05241cf9,
- 0xbb4573d6, 0xcb39378c, 0x79684502, 0xb7e9bbbf, 0xbd00a4af, 0x8e9fa166,
- 0x68c2ca6f, 0x987f93f7, 0xfc7dc9d7, 0xc90009a0, 0x5cffd6c5, 0x42697357,
- 0xf03fbc5d, 0x6b6bdcfd, 0xf6ef48f2, 0xa0d823b7, 0x6fdd658f, 0x351e31d7,
- 0xbd81aed0, 0xf852eb6b, 0xb5c761f7, 0x3c068e57, 0xfffc7228, 0x7f47eb5c,
- 0xc6199da1, 0x4b4f844b, 0xfd0cdfea, 0x7ef9743b, 0x784af6bc, 0x590ac1e1,
- 0x1fad66bf, 0x6ccfbbe0, 0x2a508fec, 0x1c8ac7be, 0x6dacd6ef, 0x0de7d6eb,
- 0x276005d8, 0x39911aec, 0x7eac1f60, 0x85fb667b, 0xebaa5630, 0x5dea0b53,
- 0x1e43e7a9, 0x648fec85, 0xe4203d7e, 0x572cdfc3, 0xf47641f5, 0x57241181,
- 0x4b20667b, 0xe483fec2, 0x80796876, 0xf6073da1, 0xdbc21748, 0xd3e3fc7b,
- 0xef7b422f, 0x1b1fdfec, 0xb77be3a9, 0x37bb45ce, 0xba234e74, 0x2353ed0d,
- 0x4dadd00a, 0x71e80bf0, 0x7a480b8a, 0x7412ea5a, 0x8c330eea, 0x521c7473,
- 0xbe898526, 0x83ae0a5a, 0xf8f7ccb5, 0xe438425f, 0xde7932be, 0xf7c11ebf,
- 0xead2a10f, 0xffd825ad, 0x9da1856e, 0x44f4aeb0, 0x37da02d6, 0x30b59bbd,
- 0x5d25bbe1, 0x973e120f, 0x890f33ec, 0xe08f5fc7, 0x67e6de71, 0xdca3f69f,
- 0x90a228f8, 0x22d0684c, 0xbd40a76b, 0x9684c1a1, 0xcc8cab20, 0x1ce291bb,
- 0x06361675, 0xed0477e6, 0xdf638426, 0x7053c337, 0x814ff0de, 0x8b02db47,
- 0xab6e9f48, 0x4e2839b3, 0x56ff3a54, 0xc52b83c2, 0x5758788f, 0xe3839d5a,
- 0xe19acf34, 0xd808f8a2, 0x7cded871, 0x2fc8b7d7, 0xd75ae124, 0x3b45ae65,
- 0xb9ec0aa7, 0xfcee00a7, 0x7d6a6b8c, 0xd523c7c0, 0x3bb7e5fd, 0xb43e5e30,
- 0x266eff1c, 0x25368ba7, 0x2546fe10, 0xa25941f9, 0x8bb0b35f, 0x8d9f8ddb,
- 0x2be218b0, 0xf6e08d9f, 0xd8e1a5ec, 0xc39f2474, 0xda2a4f5a, 0xffe621d3,
- 0x2ccff704, 0xd0f7d0e0, 0xe479713a, 0x3fc9d569, 0xdcf4f366, 0x5fb6217b,
- 0x85fed1aa, 0xe00f3d69, 0x3d6bbdb8, 0xf04c75be, 0x2aefd601, 0xbd4f7da3,
- 0x3278a827, 0x7d70bcf9, 0xaabd9f7b, 0xd288fd1c, 0xa8fb5aee, 0x5ae6f49d,
- 0x2d7f7ea7, 0x69dfd3ca, 0x16c01f3c, 0x7e874d8f, 0x833efe96, 0x8f6b5dc6,
- 0x0ff5c5ac, 0xbda954ef, 0x607411d8, 0xb9be4bbf, 0x2bd22265, 0x504a4473,
- 0xed3d9a8f, 0xb618e90c, 0xb12fe42b, 0xe30c0279, 0xf3c3d3c4, 0x45f50534,
- 0x1d333d92, 0x5fb455fd, 0xb6bf90f1, 0x18c7f05a, 0x36d382a0, 0x3fb68562,
- 0x6fb0188f, 0x1ce3f95e, 0xbb4a1f0d, 0xfee364c7, 0x14ba9af3, 0x5b2df686,
- 0x42663f15, 0xc627bd7f, 0xea6e0ed0, 0xa69c6854, 0xb82d27d2, 0x93a5b96f,
- 0xec4877f3, 0x057f0033, 0xf18c5768, 0xa07b0aa4, 0x5839fb8d, 0xc448d8ec,
- 0x3d7c63f3, 0x12f78319, 0xad8cabfc, 0xf440f2e0, 0x86711167, 0x0257e126,
- 0x3eed484d, 0xef5bb48f, 0xf3b7fd16, 0x59bb8c52, 0xc455f989, 0xf062b96b,
- 0x2af2cb87, 0x91fa7df1, 0xdfe40cf8, 0xfa17d038, 0xb32ab697, 0xcc29fd6e,
- 0xf1a4eb6f, 0xbcc1343e, 0x056a4e40, 0x0452073e, 0x7d7657bc, 0x86e90332,
- 0xd7e232d5, 0x6a69aee6, 0x6fc78393, 0x4ec85ed0, 0xed89d96d, 0x929737d9,
- 0xc8f8c67e, 0x35fe786c, 0x1cb3e70f, 0x79d7f707, 0x61170eef, 0x48fd33bc,
- 0xe29fd6e0, 0x90a417f8, 0xd61b35bf, 0xe54199c6, 0x796ff41a, 0xa88bf959,
- 0xf533bd7f, 0xc647840a, 0x382e30f5, 0x38e48cab, 0x8a7c33d5, 0x3794177f,
- 0x0e34dc78, 0x116aefec, 0x711e7c5e, 0xd119c40c, 0x62e3876f, 0xdecb0f1c,
- 0x7e46a89c, 0x7be7d07e, 0xacbb4e90, 0xccd7c42e, 0x42df97ae, 0xc6d33b7d,
- 0x9aee293a, 0xd3c4b764, 0x3a4419be, 0x7a733bed, 0xd7083dc7, 0x947d0775,
- 0x8f6492cf, 0xb739715c, 0x93da3fcb, 0xec3f23aa, 0xec1b7212, 0x797f1e47,
- 0x9323ef9c, 0xf6efc8ed, 0x23b72faf, 0x777febfb, 0x17c3923b, 0x28f3c3de,
- 0x890f7ca4, 0xc35f5f7d, 0x5fd434d9, 0xaed23d2b, 0xd8f7ca4d, 0xba3df22d,
- 0xd0f7ce87, 0x0ff8f276, 0xee494186, 0xae222dba, 0x43cef7e5, 0x84bb87ff,
- 0x7b2bc0e4, 0x3748c353, 0x64ed3b67, 0x4b6e6997, 0x7b6ae114, 0x3cc11ada,
- 0xe0453688, 0x578890eb, 0x2c1c4459, 0x834744a3, 0x4025a0e2, 0xa4fc3f72,
- 0xd2abc799, 0x85ee8f22, 0x1ce1e37a, 0xd462cf11, 0x54d9f87f, 0x8a6377c2,
- 0x37fd8e9e, 0x8608fbfe, 0x183eaa71, 0x09f9d70f, 0x87bb707b, 0x7fbc5ae2,
- 0xe75582f6, 0x8968b3f1, 0x33b0f01b, 0x93bfedc2, 0x05a8a6a5, 0x8993bde6,
- 0x32f59f3c, 0xd9e7c5ae, 0x8f2461b7, 0x8231a0cb, 0xdcb5b2fb, 0xe32f545f,
- 0x1fb98755, 0xa5c45eae, 0xf45ece4e, 0xb458a608, 0xb8b52d29, 0xdd7cfb4f,
- 0xdf9ff234, 0x2a2cff79, 0xfd18d7eb, 0x3fd08bfd, 0x3f103c5f, 0xf9f77e96,
- 0xf6e167cc, 0xd0ff80f3, 0xbe8cf604, 0xfd46ab46, 0x775cc459, 0xc3d03ea3,
- 0x43177ab0, 0x1a2506d9, 0x19600af1, 0x7ad6d3de, 0x57bd7052, 0x6f4899b7,
- 0x7e4cdb85, 0xcbd24f7c, 0x67ae1eab, 0xbd70f5df, 0xe08ea803, 0x336cb238,
- 0xe883788b, 0x4533056f, 0xbc2934b1, 0x6ad2ed5c, 0xb2dfd287, 0x8b7336bf,
- 0xcdda1a6d, 0x77f226f9, 0xd7f16e7f, 0xa338bf91, 0xcda9d684, 0x96a6b2d9,
- 0x7d2f13b7, 0xa8078f6e, 0x1b8d32fd, 0x40cf4c96, 0x8782fa79, 0xf19217c7,
- 0x58ddb0b6, 0x2cc38e4f, 0xf5eb1889, 0xa736382c, 0x120dc798, 0xf420bf9f,
- 0x8aebe7c4, 0x167dbe04, 0xfe72bb94, 0xde38f22b, 0x1cbcf94c, 0x875d5f95,
- 0xe30a3074, 0x725845ca, 0x84cc2abf, 0x99751fe0, 0x48fa2147, 0xcdcdb782,
- 0x96bc29e9, 0x5aff21fb, 0xfee193f8, 0xf82593d0, 0xb8c5efd8, 0x42cbbd65,
- 0xf5f3e871, 0x1a64a497, 0xf5fdb7f7, 0x96feffbf, 0xaad7e7ef, 0x45c6bf22,
- 0x8bbe6972, 0xe2a4e5cf, 0xe7c51bdb, 0x701fb00e, 0x0ad56b1e, 0xbfd32394,
- 0x3479a0e9, 0x8239061f, 0x3de5ac71, 0x9bd7a805, 0x304a7bab, 0x5f8c935e,
- 0xf2935684, 0xef9bde0c, 0xda08fd81, 0xf18c6b0d, 0x55f1c1b8, 0x2666617f,
- 0xee4e7bee, 0xd7f5197f, 0x2fe93b7e, 0xad17bff8, 0x16cfffc8, 0x388b5c91,
- 0x2e316383, 0xee894a14, 0xda1171f8, 0x6a8edc31, 0x44eeb6ea, 0x5b7e713b,
- 0xff0f7c42, 0xef18deb3, 0xc8326b63, 0x8c3aceef, 0x4e1e1bcf, 0xfc506efa,
- 0x65d69daf, 0x0e3825b3, 0x10f41df9, 0x599c1de5, 0xbeb86262, 0x116faaf5,
- 0x7633a92a, 0xc67e7da3, 0x466bd7c9, 0x3e3fd4a6, 0xebfabfb2, 0x57d9d683,
- 0x6f5ceb82, 0x7ec4c162, 0x619d709a, 0x3ac51b7d, 0xe2fa799f, 0x8fe75c12,
- 0x825c5ff7, 0xdcd9bceb, 0x29be47ee, 0x41af0775, 0x32ba9cfc, 0xe615f640,
- 0x9d1f20ef, 0x94de3d2f, 0xfd378f44, 0x2eb1e8e3, 0x59321f31, 0xe3f4363f,
- 0x3d1fa8cb, 0xe50f3d16, 0xf59b7cc1, 0xfc49ea2f, 0x679fd21b, 0xe3ff92b3,
- 0xdd3f1ff0, 0xdd18f948, 0xb227d92a, 0xb05ac3bf, 0xc3a3ed18, 0x617d796f,
- 0xd3fef865, 0xb5e5fd85, 0x59fa30b1, 0xda40bee4, 0x78f2c997, 0x03cf98b9,
- 0x8cdffe99, 0x3ce21bf8, 0x20dc7fd2, 0x3e45b1de, 0x6eef76e5, 0xc7fdc7c5,
- 0x6e4fe49d, 0x85cf343e, 0x220fe2fe, 0xfcdc7fdc, 0x8ff93974, 0x8a5e4497,
- 0xeb193e62, 0x1fb85c56, 0xddfbb259, 0x9003cc34, 0xe7d85efb, 0xf9499fde,
- 0xeffdc635, 0x69939107, 0x70003798, 0xa7708fbf, 0xa416e27a, 0xffd866fb,
- 0xb360de61, 0xfd863f16, 0xd9187b36, 0xc65d9505, 0xef8ca0fd, 0x48580b6e,
- 0x56eb6eee, 0xb3af2822, 0x3ca2c12c, 0xcf2c6bd4, 0x80753a75, 0xfe9922cf,
- 0x077e9017, 0x5dfeeae2, 0xa7fe9758, 0x44e9ad9e, 0xe6663dbf, 0xdb3ca177,
- 0x4cf214ea, 0xdbf6f923, 0x7591dd87, 0x6fc37609, 0x584edc23, 0x34c1f322,
- 0xbd60d516, 0x1ff1cd16, 0x7946f5c7, 0xf7924d1f, 0xaf197589, 0x494585bf,
- 0x9eb1352f, 0xc4b0bcfe, 0xf9e392f7, 0xf4370718, 0x75ca5ac3, 0xe4dd93f4,
- 0xab9c51f0, 0x6356cfeb, 0x9bef987b, 0x55961f81, 0x5cafd00c, 0xcdbf4907,
- 0x6a1d1fc2, 0xe90ab138, 0xb8a5d437, 0xe8dd7f70, 0x08dbf4e3, 0x9bcc2ffb,
- 0xd677e64d, 0x1d13cc69, 0xdd7fff8e, 0xff9c77cf, 0x9cac3d7f, 0x5bf8c7fa,
- 0x3f97efdf, 0xfce5ef9c, 0x7fbeffa5, 0xe70add9e, 0x2579a4cb, 0xfd935bef,
- 0x79df72ee, 0x8bf0f2be, 0xf17c7c24, 0x70c7c60f, 0x6b2530f2, 0x7242fde8,
- 0x96afe35c, 0xf8e0ff87, 0x1e8723c6, 0xa881334a, 0xf6145258, 0x6fcebb72,
- 0x50cf1788, 0x371e7e1d, 0x453e7955, 0x9f5ddc72, 0x9ceee221, 0x5a7a5f9f,
- 0x126af5a5, 0x43a6e1f1, 0xdabe1f4e, 0xf14c58e0, 0xe9f8e4d9, 0x067fb652,
- 0x1c72512e, 0xb8f911b5, 0xa9e3cbf8, 0x3d396517, 0x56749f24, 0xc90a7984,
- 0x392f5a79, 0x4c111d3e, 0x32eaef58, 0x410c08d8, 0xcc2d36d7, 0x4f9e1232,
- 0xf4f6e2cb, 0xc89f224b, 0x05e7e16b, 0xfaa673ee, 0x35e31f71, 0x7ca77cf1,
- 0xd67a604f, 0x02ef9424, 0xc0decf9f, 0x4797804c, 0x4f249dcc, 0x1f0e4dc2,
- 0xc7e93fca, 0x10effd91, 0xa5f38b71, 0x19676ff3, 0xfebfbce9, 0x85fbe24f,
- 0xdaffbe92, 0xc016ddb8, 0x181f818d, 0x186befd1, 0x4c1a2a67, 0x33f5c3b7,
- 0xcb2efd1c, 0x459edc0a, 0xa44ff178, 0x94f3e6fc, 0xf195a92f, 0x622fe893,
- 0xfa3aac07, 0xfce26d37, 0x239f5b0b, 0xaabeebf6, 0xcd979459, 0x73c88fcf,
- 0x8fd9c336, 0x9ff9fb1b, 0xf5fd8fdb, 0xc8fd93bf, 0x9c7681dc, 0x7e69a9e7,
- 0xed5ffbca, 0x5f71f804, 0xc875a8f8, 0xdcf22cf3, 0x5df997c5, 0xcdc3f6f6,
- 0xb0ef6ae9, 0xe563ff70, 0x34ff93e7, 0x34fbf9f9, 0xdf0ea3f4, 0x7be4584f,
- 0x9e22fcc6, 0xf82576c6, 0x9e3143b7, 0x8092f7af, 0x447f3e57, 0x6cf4c5e8,
- 0xa75c51ff, 0x6cdb8f8f, 0x9e4c1d2c, 0x9b172e4a, 0x2f8a0e03, 0xbcf27734,
- 0x8ce5e697, 0xfa3377e4, 0xafd0cb4f, 0xbda18b38, 0xf8233537, 0xf57efc33,
- 0x9ab08edb, 0xd9f77e8e, 0xdebbed0c, 0xa9febce3, 0x6c73f83b, 0xa1ef2d0f,
- 0xecc74678, 0xaaef288f, 0xae9fcfea, 0x7824adaa, 0xb1e08fc9, 0x7cadcf1a,
- 0x0fe3c591, 0xbf43fcb2, 0x5f93f13c, 0x9e06e3ff, 0xf8f21d9f, 0x908fe85d,
- 0x3d54f17e, 0xe6a67e46, 0xab68dc03, 0xd87cf952, 0x9e88f3f7, 0x2b4c0f9a,
- 0xeb29ff47, 0x9da397b4, 0x072bf55b, 0xbe3ef7ed, 0x24f2972b, 0x0fc13dea,
- 0x2b3a3e51, 0x5da35723, 0xa0e3085a, 0xfef1fbbd, 0x6e11cbab, 0xa336ff29,
- 0xdfc61cff, 0xc7fa34ec, 0xd9e78d99, 0x4f9bdd2f, 0x4762cbfb, 0x6fec53f0,
- 0x11c39db3, 0xa3ce23de, 0x3279bf08, 0xcfbe4bff, 0x4e344d56, 0x146db7f6,
- 0x6172972f, 0x6d0599b3, 0xe4f203c5, 0xf22e9678, 0x635e444c, 0xa79e2cf7,
- 0x8f0eea22, 0x81f3bf31, 0x238f2bcc, 0xb4b3c73c, 0xe61f96af, 0x402f9418,
- 0x187e62fd, 0x9c5805c5, 0xe7a92dfc, 0xca3d1db8, 0x727a2165, 0x9c51df02,
- 0xed09e806, 0xb1e34bf9, 0x6b9e78e9, 0x52f44774, 0x73e1f3c4, 0x3693c226,
- 0xd38a35eb, 0xbc7c2ba4, 0x6b3df5e2, 0xc61fa2c7, 0xb865e6f5, 0xabbb7aa4,
- 0x353a511a, 0x4d9f9023, 0x52968cfb, 0xbffaaf1c, 0xf29f3ccc, 0x17f92a50,
- 0x291a0a3a, 0x6df7b29f, 0x4e3ce1ab, 0x77661972, 0xa8e4fe53, 0xbc505fae,
- 0x194079c0, 0x72762f32, 0xd6f083b6, 0xa0cd8e1c, 0x3d4b9b1c, 0x43b56724,
- 0xb538a2bf, 0x094356b6, 0x7eccdac4, 0x0b439e13, 0xefe460af, 0x32e1d31c,
- 0x8a157ae1, 0xc3be98fc, 0xa418987f, 0x0f8c8afd, 0x937e7844, 0xee1567b9,
- 0x3d15b4c3, 0x3d718797, 0xcd4db80e, 0xbc5fd865, 0x872dfc99, 0x4fd21952,
- 0xddf15761, 0xb85ea153, 0xb0f145c6, 0x296ee7be, 0xcc2aff24, 0xf310cc73,
- 0xf336ca2c, 0x9aa50ffe, 0x9b699f50, 0xd5470f98, 0x04d559dc, 0x875083f7,
- 0x3c8a467e, 0x453f1955, 0xa9ea143f, 0xd7e0ecf4, 0xffb63f30, 0x14b2d21c,
- 0xe3490e7e, 0xb2e712fe, 0xf3c71fb7, 0xfc2c3b3d, 0xc391e79c, 0xdf936613,
- 0xe0a6ad6f, 0xe6ee7c3a, 0x663794f9, 0x42e70c9b, 0x847ff006, 0x1d4756f2,
- 0x6bd705fa, 0xaff61630, 0x68bd3999, 0xd13b3d6b, 0x2d38b8bf, 0x97ba7948,
- 0x8a5545b5, 0x3d4eb99f, 0xec27ab50, 0x3d70b673, 0xef8fbcd3, 0x35f793cb,
- 0x6e5fa65f, 0x2dda36cb, 0x927ff5fd, 0xfe83f2dd, 0xfdc6fff1, 0xf3ee330a,
- 0xe497ed92, 0x3b20dd7d, 0xe1bfa93c, 0x8f9918ec, 0x0e303d52, 0xd29da7b7,
- 0xf21b0a4e, 0xe21daa75, 0xd8cda17c, 0x5c23e5ff, 0xbf995f34, 0x5f52b593,
- 0xf1fa7981, 0xd7f2301f, 0x70a23cc9, 0x09f7cf35, 0xee746c9b, 0x29dacbd0,
- 0x8b24687f, 0xd3f90a2a, 0x6d7ce87a, 0xc111e636, 0x47b2eb77, 0x99dbbf51,
- 0xf24a8d6f, 0x6e105752, 0x509fe63b, 0xeb646abe, 0x3ae71c22, 0xc7638d07,
- 0x308b93fc, 0x15bfc085, 0x06f4ebe5, 0x05c85f1e, 0x9bf48c7d, 0xa1d39a3b,
- 0xa1e78ebd, 0x99133cc8, 0x50f12217, 0x3b9bf02d, 0xca115176, 0xf04ab5c1,
- 0x99ae7151, 0x4e0dffcb, 0xec195e71, 0x79c0cf6b, 0xfbc63ee4, 0xf898370f,
- 0xaf376479, 0xf9d18c77, 0xf82fa079, 0x728ebb39, 0x2832779e, 0xaf09253f,
- 0xc9e53f32, 0xe411e0b4, 0xcbf3e497, 0xd6124e92, 0x6f47ce8f, 0xfaedc43b,
- 0xcd0b06ea, 0x35c96fa3, 0x5bec97e4, 0xffa86262, 0x9cadbbab, 0xdbc692ee,
- 0x51616756, 0xd88b57ec, 0xf5ca7e51, 0x16bb32ff, 0xfd14b5d6, 0x6b5a47be,
- 0x38053a2f, 0xa01ada3e, 0x74aecfb2, 0xf9d217aa, 0xa928b9d2, 0xf9f2d89e,
- 0xe60e5ab5, 0x140bc4db, 0xb7e79920, 0xea93347e, 0xb077f199, 0xcf16eafe,
- 0xc39034d7, 0x3be2637d, 0xffff7814, 0xdbc47f79, 0x19731691, 0x87a1f77b,
- 0x5f1d8666, 0x91fddf41, 0x9c71e725, 0xc4d3bd41, 0xc8c5567a, 0x5df4245f,
- 0x5e879725, 0x25ec8587, 0x653fc8af, 0x151f2235, 0x5f503b23, 0x714e5399,
- 0x0fd3077b, 0x8f3db0c4, 0x7682cf9f, 0x6395ffa2, 0x26da7fb8, 0x49e582e8,
- 0x184f54bf, 0x22cadbe5, 0x2fdf7d37, 0x23580f8f, 0xc7c63fdc, 0x0be9e37f,
- 0xf325be28, 0xe573196a, 0xf280b9cf, 0xfbf50c6c, 0xa61ce2ec, 0x73c7cae6,
- 0xc2cd2bec, 0x36f515ee, 0x8bc53067, 0x043e44f3, 0x2b8dee7b, 0x7c865bbf,
- 0xf7e0e674, 0xbb5ca347, 0x82fb02ca, 0xeed8e421, 0xfac72e1c, 0x0a358ecc,
- 0x0ce3577c, 0xfac2f08e, 0x773a95bf, 0xa8291e06, 0x82cd311b, 0xf8581747,
- 0x9af11551, 0x3dc4e829, 0xaee7c387, 0x77982809, 0xc7ced2ba, 0x7e6a0ccd,
- 0x9c10f73a, 0x70075ca3, 0xbcb854af, 0xc9d28f86, 0xd3d52a8e, 0xa3611cf1,
- 0x0aaad738, 0xe74971b9, 0xf5ed1526, 0x35beb79f, 0xe006d355, 0x878885fb,
- 0x78c8a2ff, 0xcbdca23e, 0xce5962ed, 0x900bf556, 0xf0ad56fe, 0x12f336bc,
- 0xf8e9ce7c, 0x9565b4ca, 0x557da798, 0xfa254b6a, 0x4f3d0769, 0x0965e787,
- 0xaf7f2b75, 0xc02f16d1, 0xed0be673, 0x8f8849c1, 0x7bbde7cf, 0x3b87ca27,
- 0x0778df73, 0x30de24f3, 0xaf91390b, 0x98eef588, 0x79eb069e, 0xf22dd8ac,
- 0x0f446c3c, 0x3f72c6c7, 0xdb1e7f64, 0xfaf28538, 0xe7e1ce66, 0xb165af49,
- 0x9ef81eb6, 0x3ed0159c, 0xd9117263, 0xde453391, 0x02b78cc5, 0x9817e869,
- 0x435c4371, 0x5d9c3a39, 0xacd79574, 0xc3f024f7, 0x7eb1bad5, 0xfeb1a96d,
- 0xfeb19f35, 0x1a7fc98d, 0xd97f589b, 0xf48d9fee, 0xf3c2bcf4, 0x3097c33e,
- 0x47bdd117, 0x32fda309, 0x715c99e1, 0x27e7970e, 0x77d8abfe, 0x5199333d,
- 0xdb3ed67b, 0x20373c2e, 0x68aad7fd, 0xb665e09f, 0xef7e0cc2, 0xb8bbea03,
- 0x3d1cf222, 0x0761d314, 0x3f71756f, 0x816bbc2e, 0xd3ce0e7e, 0x46aa3f89,
- 0x4e9052da, 0x76261cb2, 0xa552f239, 0x239aec8d, 0xb9e4ee82, 0x058d2aea,
- 0x8602cf30, 0x1be5839c, 0xe88bd766, 0xc87f0ea7, 0x69dbe718, 0x8a5be51a,
- 0x415b1831, 0x5d0487f5, 0xfff2911f, 0x57589a07, 0xef1840e0, 0x1e5cfaec,
- 0x74652e87, 0x656cfe5e, 0xdd25d509, 0xae01fe4b, 0x41a18d1e, 0xe927f445,
- 0x0b4ea7f9, 0xbf7a83d1, 0x34bbf849, 0xea590213, 0xb8807092, 0xc93d42c9,
- 0x7195fec8, 0x6c9b7cba, 0x7ef8fcd7, 0x7e75930e, 0xd44b2bde, 0xaa6a29a1,
- 0xf2fcfd40, 0x3b7f48ef, 0x879c417c, 0xe746cd25, 0xa3e38693, 0x767f825d,
- 0x4b91f125, 0xe8f89abb, 0x3b92cea7, 0x9c6bee08, 0xa5afd42e, 0x0cba9730,
- 0x2a23fd2a, 0x4fce3bf0, 0x474f8a6a, 0xed66f9be, 0x825aa9f1, 0x9bef869c,
- 0xc6a9f7f8, 0x7df0bdef, 0x69f7c246, 0xe0d97df0, 0x6d3b77ef, 0xec44d351,
- 0x21ef4aa7, 0xc9a5187d, 0xade6235e, 0xaeeff166, 0xa3b17911, 0xd47de0d3,
- 0x3cc6a55b, 0x67d93613, 0xa4e4fca3, 0x94ab92bc, 0x57c839e5, 0xba9adb57,
- 0x97bfa07b, 0x655e3ac5, 0x82e67e0a, 0x2dcf2fe7, 0x57fc8a39, 0x98688b6b,
- 0x8b2d77d7, 0xedc5c2ae, 0xc47c169b, 0xe1f24c5d, 0x6693e459, 0x03363835,
- 0xedcc67ea, 0x222d6fa3, 0x9bce79fe, 0x495e1839, 0xa45e1227, 0x493fa417,
- 0xf770c92f, 0x3bd7e7af, 0x3b6f1129, 0x4a5851d8, 0x16b18abb, 0xe7ad779e,
- 0x880bcc0f, 0x65ad8668, 0x2f35da34, 0xdc93092f, 0x00fdcab8, 0x9cbd65e5,
- 0x944ffc1b, 0x7e177567, 0xcbe1a052, 0x716379de, 0xc6f000df, 0x95e137fe,
- 0xbca0e3f6, 0x862d0fe3, 0xf8e1e3bc, 0x421b8e4c, 0xfcc550bb, 0x47949de4,
- 0xf0e39a1c, 0x109179e1, 0x5256c1e6, 0xc2ec8afc, 0x6f6e14e7, 0xb09b1587,
- 0x3f37cee3, 0xaf7b7199, 0x33dedfa9, 0x9477d7e4, 0x6e3bb873, 0x35fde5d5,
- 0xc79c5edc, 0x4b393db8, 0x51742fb4, 0xefc3ccbb, 0x86fdc9d8, 0xd58f4f1d,
- 0x03b05fb1, 0xe9607ec9, 0x322ccec2, 0x7f839bde, 0xde40d64a, 0xb73366f8,
- 0x7c99b75f, 0x62e79455, 0x9ce2f7e1, 0x318cfe91, 0xff64fc7c, 0x628e6e62,
- 0xd7f74f88, 0xc5fe4eff, 0x3f307752, 0x585bfa07, 0x4c502fe6, 0x33f71708,
- 0x1c3e7d02, 0xd6fe9863, 0xfeed1a32, 0x9bcb59ab, 0xcfa262a6, 0xcfa41ce2,
- 0xc59f4009, 0x9d1cfa06, 0x24e5c993, 0xb3e925c2, 0x934b2e9f, 0x1782caf3,
- 0xee1d3f60, 0xa3355fce, 0xf56ddcbd, 0x9e5abcf1, 0x072c9827, 0xa059e012,
- 0xaa3c7871, 0xc24cf04a, 0x39e19371, 0xa4493e1f, 0xf9c66ccf, 0xc97e3861,
- 0x59d858d6, 0x2f2fc031, 0x083583db, 0xacdf3f7f, 0x41a3fbe2, 0xa20eab70,
- 0xe46febaf, 0x2a509471, 0x4f1847d7, 0x67f181c9, 0x5faff189, 0xfaf0e9cb,
- 0xdd10b17f, 0x8451f802, 0x9f68b67f, 0x7944ddd5, 0xcc6bb354, 0x00ed1227,
- 0x13a9b719, 0x94f1cdef, 0xe605919b, 0x4bc634cc, 0xf1e26eea, 0x8b58eb9a,
- 0x7ebde119, 0x3a9fb18e, 0xcc13feb6, 0xc9bbab0b, 0xd3983cf8, 0x8b19671f,
- 0xc2a39671, 0xfc07d08f, 0xd3f4fc82, 0xdf0fc5cc, 0xf63bf40a, 0xe8156587,
- 0x6b32ba77, 0x504deec9, 0xf1b6f1ff, 0xd669ff54, 0x06f3bfb7, 0xa128efb6,
- 0xb9260d7a, 0xf9083ee1, 0xd54df511, 0xc114d78d, 0xa2ed47b8, 0x39f95bdf,
- 0xb04a6f02, 0xe7bc1663, 0xf28a389d, 0xbc846b21, 0xdbc85be9, 0xc9d0bdaf,
- 0xd66f5e53, 0x9358dfc9, 0x79f5efc2, 0x2bbffcad, 0x66b73f30, 0x3c57a894,
- 0x47eb1e3f, 0x1ee84f95, 0x8726de80, 0xce6ff886, 0x09da7ee5, 0x1c744aa5,
- 0x4326a5e0, 0xe7c4dff4, 0xd1e2b335, 0x9a8fe45c, 0x04cfde6a, 0xc5b5b4df,
- 0x2ce99ef8, 0x6d737bd5, 0x250f2869, 0x70e7b59f, 0xa9ed2cfd, 0x67fbe080,
- 0x8db6effc, 0x36037e80, 0x0c5387c5, 0xdf977e4c, 0xe7e0e55f, 0x22fe02cb,
- 0xd3bcfd0d, 0xb37f3cfd, 0x0722b6da, 0x0f5fe7f7, 0x5e712a5a, 0x51f95b2e,
- 0x27d26fb4, 0xf9449b4f, 0x466636be, 0xdf74073d, 0xf1787c41, 0x48690527,
- 0xdd230e6c, 0x259aba4b, 0x48c6bde9, 0xdbafc0d7, 0x5cbf3272, 0xdae81b5e,
- 0xc3d7403e, 0xd700b9d9, 0xa9ae098f, 0x3fd5fd46, 0x265f124e, 0xbc9c3b8f,
- 0x7944bfc0, 0x275f003a, 0x661e5ff1, 0x7f2315c5, 0xecfe4bb6, 0xa62c3842,
- 0x29b39d18, 0xe9e37c54, 0x7630ea60, 0x1f2f8486, 0x8315ae7d, 0x4d3fc2e1,
- 0xcffc7fda, 0x3cf2fb83, 0xf9df0ed1, 0x5c00c659, 0x242bfe30, 0x7871570f,
- 0x5c2d2bb6, 0x5c7b08be, 0xe59be7ee, 0xf38cbb7c, 0xe7e14aad, 0x77e8bdde,
- 0xf97bdf21, 0xcfb87ef8, 0x7ce41d63, 0xcf6f4242, 0x169c05b1, 0xee75db98,
- 0x1b9fa27a, 0xb469f858, 0x8339968f, 0x74f117ff, 0x843e14c4, 0xcc859cfb,
- 0xa057f14f, 0x1272778f, 0x6f090dec, 0x879a9e32, 0xf3c9a791, 0xc0cfc649,
- 0xbec8c5ba, 0xfad8e793, 0xf39e7be7, 0xc7897694, 0x6577f462, 0x8654ff08,
- 0x452147f0, 0xc99e7ea1, 0x2fb87c52, 0xc853ee98, 0x6cc998be, 0xd6679724,
- 0xe19e7d72, 0xd487f6e0, 0xc7f1c3fb, 0x92339715, 0x991b3357, 0xe7c73738,
- 0xd9874c95, 0x2c0ee7ac, 0xadf4da67, 0xd1ef900b, 0xe007d14e, 0x7ee0e99f,
- 0x215cecec, 0x24cf583f, 0xf5fdf3d4, 0x67be7a41, 0xe49fca12, 0x9e66c9fb,
- 0x8cd2fee3, 0x99ca8c73, 0xa12777be, 0xeda8cf9e, 0xcc728499, 0x737bf2e9,
- 0x1fdc0d27, 0xd1c78c98, 0x871926b9, 0x4cfa2f3b, 0x3f191fe6, 0xc706736b,
- 0xcfd238e2, 0x55894671, 0x1e154be1, 0x583fe897, 0x76ec7484, 0xff434d15,
- 0xe81b1cc5, 0xcbba1823, 0x1730bc15, 0x008fede9, 0xf10e6e0f, 0x75e3c055,
- 0x347bc135, 0xe1e12c3e, 0x2b878136, 0xfb3d5e85, 0x89f14ab0, 0x43e97f1a,
- 0xbd084218, 0xe2116662, 0x45e93f57, 0x59d8bf79, 0xf8a2a030, 0xb24e63fe,
- 0x5abf1633, 0xb195f14f, 0x4f4c4c5b, 0x22e393d0, 0x327b8629, 0x30cbec26,
- 0xcce82fd4, 0x617fbc35, 0x7b4328d7, 0xa1bc7479, 0x2a57a2fd, 0xb149f50c,
- 0x2ff78629, 0x50daab7e, 0x1ae7a4bf, 0x3f53fbc3, 0x83a86d98, 0xde70d0c6,
- 0xd8559f7b, 0x65f79836, 0xbe196ff1, 0x19b6cdff, 0xf3bc60af, 0xb2f7d8a4,
- 0x0a563fb0, 0xe9205878, 0x637cdcf6, 0xaa25517f, 0xf3df2154, 0x79eb05bf,
- 0xc034f6be, 0x0bbf625c, 0xc4f68ddb, 0x7ac62de2, 0x55a6f743, 0xe7071b28,
- 0xe354b479, 0x79c93955, 0x79ae351e, 0x50cfa426, 0xe317d82e, 0x62ec1110,
- 0x8e1b33cc, 0xfd6cbfcf, 0x2fe8d84b, 0xfefe7f5b, 0xf5d90b16, 0xaa7d5f8b,
- 0xac8f0a2a, 0xdbfae35e, 0xa7fae375, 0xdfd71a96, 0x7fae33e9, 0xfae364fa,
- 0xf5c6fdbb, 0x5c6b511f, 0x7180ccff, 0x8cebb3fd, 0x34139feb, 0x06c8ffae,
- 0xb7e7fae3, 0x70bbd718, 0x8b3d7199, 0xed0d4bc2, 0xe52febc9, 0xdb9af165,
- 0x7a01ef8c, 0x2074094d, 0xa04168e9, 0xc677f281, 0x30cf7fb4, 0xc03d324e,
- 0xf744d1be, 0x6e3ec1bf, 0xf4fe729b, 0xfc8ad201, 0xf1f4c9bd, 0xeec2b96f,
- 0xfa017414, 0x0ae513a8, 0x614f17d8, 0xd8563759, 0xeda181fb, 0x12bf290b,
- 0xbee279f5, 0x36b93878, 0x7d894f48, 0x0a7ab0f2, 0x81f6c9f7, 0xf470f27d,
- 0x8fb31c7b, 0x4f5a8ec8, 0x5d1ba57e, 0xf14f8e1c, 0xcfe825d1, 0xf2f4827d,
- 0x32700071, 0xe71c7bc0, 0x4f1fe303, 0x8dfe4099, 0xd928b36f, 0x1982ffed,
- 0xcdd83096, 0xe2ada898, 0x953a4f3d, 0x2f6f42f5, 0x858ffe14, 0xb95be0f6,
- 0x9851efdc, 0xc5e6e385, 0x7b14bce8, 0xdd79c46d, 0xe3027123, 0x4f782008,
- 0xca011c61, 0x9ba73b5e, 0xf8ae52d3, 0xc049ee99, 0x4ae9fce7, 0x6ab5d929,
- 0xcd3de50a, 0xfd2141bf, 0x787fff34, 0x2cfa1719, 0x4cb95cb9, 0xd85db3e2,
- 0x482edc03, 0x149ac3c7, 0x07416277, 0xc2e7cde1, 0xb8fe8675, 0xfc47ff1f,
- 0x0ae3cd7c, 0xd06726d3, 0x675a3331, 0x0f3c6f5c, 0x9c38daa5, 0x0d999b8f,
- 0x058139f1, 0x57bc0ec9, 0xfbc6d103, 0x7bfbcf1b, 0xd3fa1463, 0x7cfff554,
- 0xcfe306ad, 0x9ffa2e38, 0xfe863e1d, 0x63ebd566, 0xf41abfe8, 0xba14c0fc,
- 0xcebfa324, 0x87f87bf8, 0xc27e9178, 0xbb2f413c, 0xbdfb8c9d, 0x2386fc92,
- 0x98c09055, 0xe7e663bf, 0x16dabdc3, 0xe63c9fbe, 0x984d635b, 0x37666337,
- 0x32fbe79e, 0x6df3087b, 0xc7e4274f, 0x790cbac3, 0x3cb4e98f, 0xb657efae,
- 0x71865c36, 0x07115ea2, 0x7835a7bb, 0xaab7ae19, 0x0e2f28f9, 0x277257ef,
- 0x40f16f7c, 0x6a9f027b, 0xdd43068e, 0x5e1008ec, 0x10b6b556, 0x3dc598dd,
- 0x6ef3ab50, 0xfc130573, 0x148e1712, 0xcc2d86f6, 0x984c595c, 0xc1f7f0c6,
- 0x55f38674, 0xc4e9da5d, 0x0bd5a87d, 0x2bca25fd, 0xfa2590ad, 0xb6b4d7ad,
- 0x94abdc10, 0xb33b1060, 0x3b51668e, 0xe1aadbe0, 0xbe785459, 0x67922af5,
- 0x3e6de716, 0x3867f7bc, 0xdabd59fc, 0xc87289e7, 0x8728d23f, 0x5db56fee,
- 0xd95af88e, 0x93c68cba, 0x756f6b78, 0x8df58e5d, 0xbed15ead, 0xb54dda82,
- 0x71f482ba, 0x8621681a, 0xc7ad1671, 0xb03d7189, 0x03c61933, 0x045b5ecd,
- 0xe1eac899, 0x05a3b2f0, 0x5d731f44, 0x8df4061c, 0xbc7d03e5, 0xfb4cccb3,
- 0x1df3dbd3, 0xafedfef4, 0x0fd1798f, 0x1e01607c, 0xf98aff51, 0xf0238ff4,
- 0x88721167, 0xf200c169, 0x23572595, 0x6b86747f, 0xdfe3ad36, 0xbbc49fda,
- 0x1f28cec5, 0x20ef92d4, 0xe17cebbb, 0xf7148d0c, 0x27bc0950, 0x44f00fe3,
- 0x8176f472, 0xe2efdba7, 0xefdbbe7e, 0xcec79460, 0xd55fc196, 0x148d5d00,
- 0x059b25f2, 0x056f6ca8, 0xeb8252c1, 0x0b416365, 0x49d675e8, 0xbfd1db2f,
- 0xcd7eed83, 0x4deaa18d, 0x58599e35, 0xaa7c9c6e, 0xbef1d91d, 0x618b3f4b,
- 0xc474be89, 0x4581ab97, 0xc51fccf0, 0x1d783d8e, 0x89a7af35, 0x5e3ab4f6,
- 0xe9ed174f, 0xf7cf5e01, 0x20d4a93f, 0x97f14960, 0xd5c6477c, 0x2dbe51a3,
- 0xb27cfc60, 0x3b60e7b8, 0x91c2f213, 0xdb06ab31, 0xbe74626f, 0x50ffb640,
- 0x4e38e7b4, 0x394629ac, 0xfdf8c73c, 0x6c878156, 0xe9f689c7, 0xb6319f14,
- 0xa64af8cb, 0xf42bece3, 0xfdb1997d, 0xd3bdf141, 0x1d363671, 0xc71b47db,
- 0x53da20df, 0x08ef3c1d, 0x473f21c4, 0x15efda2f, 0xc76c76ed, 0xed8d4bf1,
- 0x2bf8c56b, 0x43ad0095, 0xf8899f3f, 0x9d568ee4, 0xf67cc9ea, 0x7e0cc8ea,
- 0x99f0598e, 0xf21b196b, 0x23abfcdc, 0x9a4cbe79, 0x0ff7e3de, 0x7b650f21,
- 0xb8a34b86, 0x10b5eaaf, 0x421d591d, 0xec3e088e, 0x8b4a2397, 0xf717138f,
- 0x3d197f97, 0x8e7ee103, 0xfe00acf2, 0xbef39e90, 0x04c16263, 0x98db9679,
- 0xef0982c2, 0x1864177b, 0xe53759ea, 0xccf7de1a, 0x77686519, 0xb4378e54,
- 0xf13e58b3, 0xae826dc7, 0x0c2aca52, 0x02bef2ed, 0x923e73a6, 0xf479b576,
- 0x677bc314, 0xa474f54b, 0xcb57d3ed, 0x367cabfb, 0x39b70b94, 0x1f236547,
- 0x3275a4fe, 0xef20df1a, 0x8974a26c, 0xc9474bd2, 0xa2eab656, 0xc7f54a5e,
- 0x7aaf3cdc, 0xd78fab65, 0x6f9d188b, 0x4b5ad95e, 0x2f81c7f5, 0x56d7fcb1,
- 0xa07b953f, 0xfb0e160e, 0x43aff411, 0x7fa13b3f, 0xfd023fac, 0xfa1db963,
- 0xd087f2c7, 0x856fb63f, 0x10feb17e, 0x83e585c0, 0x7f3e0fd0, 0xfac7fa00,
- 0xd500d6a6, 0xa3ad6bef, 0x20d686fa, 0x36b6f795, 0xadb5f3d0, 0xdd5f542d,
- 0x7bca8cba, 0xae54c35a, 0xed435d6c, 0x1f37a116, 0x1f1fe713, 0x7dcfc69b,
- 0x467faf27, 0xeed5f29e, 0x4504a8bb, 0x93c8655e, 0x7dc3c8c8, 0x2f31a775,
- 0x7047f110, 0x931e39d8, 0xe02b18e1, 0x2b62cf18, 0xa0dcb952, 0x2e98eb38,
- 0xc0a9dddf, 0xf85b23a7, 0xc57517ba, 0x81a73da9, 0xcc56378f, 0x2cc27993,
- 0xef1f8aaf, 0x957af7c5, 0x8f2a7558, 0x831f9337, 0x553f0179, 0x9133dce2,
- 0x7084c479, 0x7f419369, 0x1fb3cc27, 0x270e6e5f, 0x78286de2, 0x7c78f22b,
- 0xe4ecad43, 0xb6d49bf7, 0x52cd9147, 0xbf742dfc, 0x102ead89, 0x04f4a0d5,
- 0xc24f7482, 0x603373f8, 0xed720593, 0x874ce5dc, 0xb8d1af32, 0x505dcaff,
- 0xa8e7d861, 0xfd3236e7, 0xccb7e822, 0x194a4fb8, 0x3be19b7d, 0x0cf7de5b,
- 0xddcf16ed, 0xb7f9f686, 0x22f2ad14, 0x8a32473e, 0xafd7593b, 0xd7003960,
- 0x044d8ec2, 0xbde05057, 0xfdf9d157, 0xefc5fbed, 0xfffb0844, 0x2f812ec7,
- 0xd7da7adb, 0x6af3758e, 0x84d87a49, 0xa7e3e7fa, 0xee8e49d2, 0xfe44c47d,
- 0x622c71ed, 0x01337942, 0xbf6c48cc, 0x56726f00, 0x151ccae9, 0x574ce5eb,
- 0x8b117eb1, 0xec08bed3, 0x17a43aff, 0xb11fffb0, 0x7e4cfd43, 0xbf3cc7f0,
- 0xba7a4a2b, 0x8967ac44, 0xd16d07dc, 0x73c3fd92, 0x635fc8f3, 0x26d6073c,
- 0xdc2b01f6, 0xef18d955, 0xff261ded, 0xd6fde9ce, 0x1eb005d4, 0x2a3a9cce,
- 0xba0df3e5, 0xd173c869, 0xbf2abecb, 0x623d016c, 0x086597e4, 0x9fca99ff,
- 0xaabba167, 0xf89c7479, 0xe52ccda6, 0x728e9e98, 0x4beea06c, 0x3ba2bb27,
- 0x89a3f087, 0x1adbd9f5, 0x3900fca4, 0xd377ed4f, 0x560f985c, 0xf74ff222,
- 0xb53adeb5, 0x661f2126, 0x52dfa0b7, 0x3d45ab16, 0xf2665a5a, 0xaf27a845,
- 0x1f617fc1, 0x73c7eedd, 0xf3055afa, 0xc71e18a1, 0xbabce9da, 0x794a85f6,
- 0x4b91da40, 0xb0760e98, 0xe16511c3, 0x997e81b2, 0x477c83f0, 0x5ccff5c8,
- 0xad0f3435, 0x3e47da40, 0x33ecddd4, 0x74863f87, 0x998759f7, 0x6309e5b3,
- 0x9183a97b, 0x6a545b9e, 0xa60ae889, 0x3dd3b423, 0x850eda8b, 0x1c2115e5,
- 0x50f3bdd3, 0x254c1f8f, 0x52dd4dba, 0x7bc35745, 0x79f5c14c, 0x1e99c700,
- 0x1a49a0fd, 0xd35ef057, 0xb42ecb04, 0x5e22c71b, 0xa5d19c70, 0x6285c784,
- 0x575afbbe, 0x159e9e10, 0xefcb68f3, 0x87873bc7, 0xcf78fcf9, 0xe90ea2e9,
- 0x73ce31bf, 0x37f56543, 0x95c6def0, 0x74d85531, 0x33ae7c46, 0x53ce26c7,
- 0x3802e006, 0x5538459f, 0xbffc9b84, 0x8f4d7e7c, 0xc819bf70, 0xbb8a5ab1,
- 0xc4b1324e, 0xa32cabb8, 0xc8cdfe42, 0x4ebc1173, 0x0ba9dcef, 0xdfac4a2e,
- 0xb8fd7444, 0x761fe7c2, 0xcd2f3c6a, 0xfd13d7ef, 0x7ee4ebc4, 0x487f9c59,
- 0xdff6f011, 0xe79e36e3, 0x6c583a61, 0x0d2de60b, 0x25fe1fb7, 0xc4a4ca2e,
- 0x18e830fd, 0x649d5718, 0x759f3ca3, 0x7f4b8f32, 0x337cc743, 0x8afcf12c,
- 0x6ae9d04d, 0xe4af31a7, 0x77b71e5c, 0xe8f589ce, 0xc6be71b3, 0x567964b8,
- 0xdd17bdc2, 0x91ffe4f5, 0x6ebecc71, 0xfd2e0f9e, 0x09044b6b, 0x78e51df4,
- 0xa5587be8, 0xee92e5f8, 0xa17df96b, 0x7ba01e87, 0x1d2fa156, 0xbc5ea1e9,
- 0xe8c6bf5f, 0x3bb059ef, 0x1f452ab0, 0xc45a57ec, 0x48d7e4c2, 0xfb2527f6,
- 0x279b7e91, 0x563e69f6, 0x93ca718e, 0xa58f8beb, 0x88a67ee0, 0x91dbb9d1,
- 0x8f7493ea, 0xedfb5831, 0x2b294f78, 0x24f4f7e3, 0x0525fbaf, 0x3ef3c216,
- 0x1c63aeb9, 0x37d867e4, 0xbefff389, 0x7d7ecf17, 0x96f3f40c, 0x81ce18ae,
- 0x099ba5bc, 0xae81e38f, 0xac64ecb1, 0xa0fba876, 0x5f4df3b2, 0xa5c0bced,
- 0x68d7dfc6, 0x9639eaea, 0xcbbc93aa, 0xfa7807ca, 0xad3efd8e, 0x4e27f88c,
- 0x575107bf, 0xb841e1c4, 0x7ecbfcf1, 0x137327d3, 0xbe7c60e9, 0x7c83edc6,
- 0xbf9357d3, 0xceb84635, 0x7599bd94, 0x1c6b870d, 0x3d1bd5c2, 0xb7689591,
- 0x0ff6b848, 0xa5fabf73, 0x934f155f, 0x0120fa8d, 0x12ff534f, 0x865bf69e,
- 0xc0966786, 0xf28e4fcf, 0xb70642fb, 0xd5fd457f, 0xccf78461, 0x51ebb163,
- 0xb3bc023c, 0x53de7f08, 0x15331459, 0x14acebf8, 0xe42959f4, 0xa8ce8f8e,
- 0x17dbd0b0, 0xa75e7e53, 0x7743dbc6, 0x79e08a2e, 0x0b8bdf02, 0xe0dfd10a,
- 0x7ba56e3c, 0x7949429e, 0x2f5cb222, 0x573fb1e6, 0xab0f1219, 0x78bcb9f3,
- 0xd4f9b5f1, 0x596fbddf, 0xed83ca19, 0x5ef5df22, 0xef0da757, 0xc47895ef,
- 0x2194057a, 0x2a117c4b, 0x3f2b7bba, 0x218ee9b3, 0xf1f133c6, 0x1be24bee,
- 0x572c9e39, 0xbb7297e4, 0xe2aa3954, 0x2efb8739, 0xd9ee937d, 0x2352afba,
- 0xe337fb99, 0xfe127d7f, 0x7d666fa3, 0x8acbd39d, 0x2aa3f47c, 0x037da5ef,
- 0xfe2521ea, 0x9fc432b3, 0x0ff34825, 0x3b656dbd, 0x6a78c195, 0xe72bf414,
- 0xe12fe727, 0x80b65e76, 0x7ae099ce, 0xc5abe020, 0xa44f52fb, 0xf387bd0b,
- 0xa9713d22, 0x4c89cfc6, 0xef5d68d2, 0xce853c9b, 0xf917ecf5, 0x2c4bf114,
- 0xc32efe43, 0xf76f0233, 0x0c45fb9e, 0x770da9ef, 0x055ee99b, 0xbf78f5a6,
- 0x7a147409, 0x9a7ba35d, 0xf16a9e81, 0x5f17a8de, 0xfb869b3b, 0x66f903e8,
- 0x3e40fb82, 0xe77d8797, 0x6f3a5ad4, 0x2e67daf3, 0x9ffe8135, 0x5d8557ce,
- 0x39e18b12, 0xfc158d9a, 0xd84380dc, 0x4ed78e01, 0x8efc2035, 0x2ab3dfc9,
- 0x4f767a09, 0xdbbe95be, 0xf9678968, 0x48740e30, 0xdfee5165, 0xfaeffba1,
- 0x38ba0bcf, 0x8f2b9a1e, 0xe8e09d92, 0x3de2f7e6, 0x5c13af9d, 0x7841f708,
- 0x33ee329e, 0x57b63d57, 0x06a378c2, 0xf8ba77be, 0xe24ca67a, 0x77dcd0f7,
- 0x785dcfe9, 0xc2ba5eef, 0x4be8fee8, 0x3906cc0a, 0xd7c45f5e, 0x1632b3a1,
- 0xe5fc851b, 0xb6af28d2, 0x0d9b7a33, 0x17c97aed, 0xf4a947a3, 0x97916add,
- 0x29727abe, 0xe3a499f1, 0x57c105b9, 0x02366e91, 0x76493c5f, 0x9d302c4e,
- 0xc72ae3f0, 0x95c7e3fc, 0x3fb71d58, 0x2fd42e2c, 0x819326a5, 0x380b8adf,
- 0xec12c8dd, 0xee77b252, 0xf52cb410, 0xc6c45b7d, 0xb7ffbf30, 0xa3a566e7,
- 0x2796da5d, 0x0dbf3ced, 0x095db5f1, 0x38e117a4, 0xbed2a5ff, 0x4ed7c5ef,
- 0x6db8e034, 0xdbe42f30, 0x58ea7e7b, 0x9b49f68f, 0x2a7c4fcb, 0x26dcd7c7,
- 0x9fbc1eb1, 0x2bff16fd, 0xbb8c6fe8, 0x47447df9, 0x43635ca6, 0x4cf787fa,
- 0xad7bcfd8, 0xd81a0bf8, 0x07f90d4f, 0xcf66ba16, 0xb116efc0, 0x6bb42ae0,
- 0x86a87517, 0x11ee177b, 0xb9e162f2, 0xd84d1614, 0xfc9c2c1f, 0xb6373a2d,
- 0x8b1a5cf0, 0x8f75bd82, 0x8f7d1738, 0x0ac45738, 0x443b3d38, 0xdfe515e9,
- 0x24bef7cc, 0xcbf995bd, 0xdf39f3bd, 0xb7e802b3, 0x14b1e949, 0xa71b10c1,
- 0xebce9efc, 0x62ead7bc, 0x780492d1, 0x0473cd07, 0xd38c268b, 0x1b39deff,
- 0x7d6067cd, 0xcc0efd39, 0x787841d7, 0x784bd5af, 0x91ffbe1c, 0xf40e3c06,
- 0xc780ca3f, 0xd097fdc1, 0x96b5eff8, 0x13ff497e, 0x375fe986, 0xefd03fc0,
- 0xf7b71a68, 0xa71ffcc8, 0x891ddf02, 0xf9edbdde, 0x331dfc4a, 0x017efd2b,
- 0xa6aceaeb, 0x338f8473, 0xe77a673a, 0x83bddfe1, 0xee779af9, 0x8c70f8b2,
- 0xae7c733e, 0x333d086f, 0x78c2b99a, 0xc72c979f, 0x7cd31417, 0xb4db9f92,
- 0x32f30b88, 0x0b9aa56d, 0xc6d11f7f, 0x71bb9162, 0x236952df, 0x42e32739,
- 0xe53fdfb2, 0x3b3cf2a9, 0x6f7907c9, 0x979112cb, 0x5e08ec57, 0xd4beeb81,
- 0x13fcded4, 0xd283f6f8, 0xcc373a36, 0x33f69b98, 0xe1a36e32, 0xa315bf2f,
- 0xf0c0305f, 0x7a13cdfc, 0xf77e0670, 0x18271043, 0xd82f51c7, 0xb5bcc41d,
- 0xb8df620d, 0xfaf31ec1, 0x0de6e412, 0xb357da05, 0xe893da17, 0xf72fd276,
- 0xdedd3946, 0x227e8050, 0xfcc4f635, 0xedb7cc22, 0xe976f711, 0x55778a16,
- 0xfefba31e, 0xff7dcbe6, 0x8ebce49a, 0xd1da377c, 0x8694ce32, 0x6b687779,
- 0xbef7e46c, 0x7af2a7d5, 0xa08c7ffd, 0xffb01073, 0xf9432d49, 0xfee55fb2,
- 0x3adf1120, 0x67d0e62b, 0xf94058db, 0xe41f22f7, 0x744bf76c, 0x35d9e4af,
- 0xebfd6863, 0xdd3ef85f, 0x973fb70b, 0x43beb1eb, 0xf563d24e, 0xde155f56,
- 0x973fb85b, 0x5a9dabdb, 0xc122ad34, 0x579d5d7e, 0xe3f9f24d, 0x894c6335,
- 0x0aef8ff1, 0xfa51b079, 0x1578b537, 0xb8f9679e, 0xd233fa32, 0xf4ec07a3,
- 0x83a6513b, 0xfba2abbf, 0xe95a372d, 0x0faa0177, 0x875cdb8e, 0x8d34c3fb,
- 0x074d91f2, 0x99cf04ed, 0x2d7efc75, 0x5de516fc, 0xf491c1d3, 0xa9f556fb,
- 0x6c27ca71, 0x6095f14a, 0xe0feafdc, 0xffd7ba54, 0x057186e4, 0x644eff28,
- 0xaf7405ea, 0xf43c06f1, 0x6343f509, 0x17b5f3f9, 0xe75579d3, 0x50e0d4c6,
- 0x8fa9107e, 0xdaefef92, 0xdbde5b9f, 0x6719f885, 0x7dfca1f3, 0xb8f1f14f,
- 0xd9f12bef, 0xf915c53a, 0xd77ad2f9, 0xbc7dfa69, 0x6f778efa, 0x43dcf462,
- 0x73f72b74, 0x0bd5e3c9, 0x12dfb57d, 0x4bbf8b9f, 0xe052bf56, 0x624efc5d,
- 0x7e9ca9bd, 0x7de24faf, 0xb73dd263, 0x24fd084f, 0x69af93cb, 0xd8205f74,
- 0x1fe80511, 0x4ad8793a, 0xe3727674, 0x2eaf3a04, 0x9c07abc7, 0x4f2f80b8,
- 0x7113e864, 0xf2169f5d, 0xdf257eaa, 0x30e7caa7, 0xe77f0c7e, 0xa5487e30,
- 0x573eaebc, 0x92e30d3c, 0xef593df2, 0x4ab74f9f, 0x3fb597bf, 0x6f5a45f7,
- 0xf48627a0, 0x49c17a64, 0x82f43a7a, 0xe7ae1775, 0x8c2c95c7, 0x5bf0cffe,
- 0x8ec7f7fc, 0xfd92b21c, 0xef9c77dc, 0x9fdd076f, 0xe01788e6, 0x17a1a1fd,
- 0xeb1c9246, 0xe0ef8fcb, 0xdf9db6f6, 0xf046f8ab, 0xcdff1162, 0xe611f711,
- 0xf9f79da0, 0xed147b21, 0x9e29283c, 0xbdbb6610, 0x2a70fcf4, 0x940fff43,
- 0xca63cf14, 0xeefd2f01, 0xdf176b0c, 0x3bfbe8c7, 0x5163820b, 0x0c59df2e,
- 0xfbf03bfd, 0xe7def453, 0x521782a3, 0x5cb18a0c, 0xf52e5e31, 0xa42c1f9b,
- 0x5e67cae7, 0xed2a7bfe, 0xed463da2, 0x62f06b21, 0x9cafc79a, 0xf310e76c,
- 0xeef7aafc, 0x41182d1d, 0x06e128eb, 0x98dd933c, 0x05b3978c, 0x3b7bf126,
- 0x74c91f1c, 0x5f9ebfd9, 0x5ffa1f02, 0x21f6bce8, 0xc6eb8ebe, 0x591cb859,
- 0x63ec813b, 0xc86296d6, 0x88715b9f, 0xbbd0c3df, 0xdceb49c1, 0x843ff667,
- 0x86fe28fa, 0xed7bf199, 0x3f4022c0, 0xf9a1e4c5, 0x4f9123e5, 0xcf2d64bf,
- 0xd1e8fbb3, 0x39e60bf7, 0xfbf25cf0, 0xd2c97386, 0xa49d085f, 0xe1c63fa1,
- 0x97e6d3d3, 0x255d7b71, 0x7aeff8f8, 0xf4eb346d, 0x0de16bbb, 0x711fc8e3,
- 0xa41fa2d2, 0x775b87df, 0x4ae90981, 0x77f2172d, 0xbc9f9f13, 0x7bde4b2f,
- 0x8a9f8c95, 0x7f9262c2, 0x33782c4d, 0x827ea1de, 0x61c259e9, 0x91fff746,
- 0x6984df7b, 0xe29f9a88, 0xf485acb6, 0xf67be0c2, 0xbbf25f2c, 0xf5bbff6c,
- 0xf42b5c2a, 0xd38795ef, 0xe07eaf50, 0x3a46fbe2, 0x5d7a8f7d, 0xc36cf3e5,
- 0x83af300f, 0x4e14a605, 0x879276a2, 0x5dbc281f, 0xf341b9ca, 0x7ec17a47,
- 0xebe83df0, 0x7fee429a, 0x710cae63, 0xc16c2bc8, 0x9fa94d3c, 0xc2668a42,
- 0xdca7f373, 0xe3d21a7a, 0x19c5b5a9, 0xc60f302b, 0xda2567ad, 0x8ca3a1d5,
- 0x78eb8bce, 0xf8c5f8df, 0x89fe32fb, 0x9fdbf7e8, 0x243bf461, 0xb4e4f3c3,
- 0xed89b99e, 0x9eb90a73, 0xf6285f9b, 0xe44c8599, 0x8de32657, 0xb162fbaf,
- 0xf0796aee, 0x2687da72, 0x4b78b7bd, 0xa487a0ba, 0x7fcfede7, 0x1ea0f297,
- 0x4913de36, 0xef185fb1, 0x612c5783, 0x532c42e5, 0x61bdaf28, 0x0d739713,
- 0xb92cceaf, 0x5ee9d78b, 0xef3b6985, 0x59e3dfa1, 0x12caebb0, 0xad16e5c6,
- 0x05c7a483, 0xb412fe05, 0x555be2e3, 0xc345f217, 0x51e09516, 0x56d73ecd,
- 0x8b7a7e78, 0x06bbec99, 0xbce9cf01, 0x9bad1a60, 0xe00b34c6, 0x4c16b4fd,
- 0xab75fb23, 0xa4a1ddf8, 0x6f7bc079, 0xe043156a, 0x99d7c6c7, 0x043c53f0,
- 0xa261bc1d, 0xbf805a75, 0xec70890b, 0x79bfc854, 0x33783f3a, 0xfec14fd6,
- 0xabe9cf1f, 0x7dd0969b, 0x3ef8c936, 0x7d120b6d, 0x91f3162e, 0x471e4cf8,
- 0xf10fb3e2, 0x2bd2f689, 0x85ef4853, 0x6291541e, 0x9fdd8bd9, 0xda7cbed2,
- 0x99df2ba1, 0x8137cf8a, 0x9ea3a2dd, 0x6fb3f51d, 0xa35b9ea3, 0xfe7a8c52,
- 0x962ce2a1, 0xff71afa4, 0x39f5ff39, 0x3d04a669, 0xf1c83ea9, 0xa4e73aa4,
- 0xcff7a42d, 0xebe91d7e, 0xaacbee84, 0xf1ef7848, 0x83b8fec2, 0x37eabd61,
- 0xc70d21fd, 0xa66f5869, 0xe975c979, 0x7ca079c3, 0x208d4f6b, 0xc5e5f7fd,
- 0x4eb95fa9, 0xeb8df4fd, 0xde09e920, 0x9742affb, 0xf24c2718, 0xb05154e8,
- 0x9d0437ca, 0xc6007a2c, 0x38b6fec5, 0xf3d2fee9, 0xa3e2571d, 0x5f05bd7f,
- 0x71d71d53, 0xd1f91147, 0x74686f4d, 0xfb44e0c8, 0xc7c80555, 0xd02fa0f5,
- 0xc4af516f, 0x647ba1df, 0x1ee9590f, 0xb74dfae6, 0xd5e38cdc, 0xb09ab71f,
- 0xabe1d4fd, 0x495c1226, 0x2a780aeb, 0xfbde8a18, 0xbe05e28a, 0x3d81fc04,
- 0xe72dfc41, 0xc1370093, 0xba29fb01, 0x08afa88f, 0x0e4133d6, 0xedc859bc,
- 0x65df782e, 0xf7e6fa21, 0xd7cff561, 0x575f3495, 0x64df7cd2, 0x17ccdf44,
- 0x782cf9a4, 0xe7c26adb, 0xb6bfee0b, 0xa73df704, 0x79a74dd6, 0x4ff0ca9d,
- 0x553afe44, 0x210ffd00, 0x0fdc172f, 0x0bfb2cf3, 0xd3b76cf3, 0xcf3b0d7a,
- 0xf60ef88c, 0x89f9e617, 0xcf3943a0, 0x0d3d34f7, 0xcf43f9f3, 0x2efd0caa,
- 0xc6c0fca1, 0xbf4ebca9, 0x73321713, 0x4a6d087a, 0xdedf7ca5, 0x04fbfe6e,
- 0x78c00e52, 0x260f49e7, 0xd55387a2, 0xd0c9e6fa, 0x3f07ffdf, 0x00b71737,
- 0x0000b717, 0x00088b1f, 0x00000000, 0x7dcdff00, 0xd554780b, 0x733effb5,
- 0x64932666, 0x08124c92, 0x3c984081, 0x49849009, 0x768a8802, 0x02d10478,
- 0x89794f0d, 0x42100793, 0x69b5a05e, 0x0240cd6b, 0x350d45a2, 0x01d45a2a,
- 0x0da2a281, 0xbc150a0a, 0x45622a03, 0xb68b57c5, 0x514026e5, 0x5ea0c679,
- 0xffd7b5ae, 0x4e7dadfa, 0x5490ce72, 0x7dfbdedb, 0xdf1f7cff, 0x5afd9f66,
- 0xd7b5ed7b, 0xe7bdaf5e, 0xcbaa3dc2, 0xe4e216ef, 0xff6f05dd, 0xf7a517bc,
- 0xfc812eaa, 0x02cddf58, 0x2cc38ff9, 0x934a14fe, 0xfe70a68b, 0xa56b9b65,
- 0xa689c422, 0xa141fdbf, 0x367d85fc, 0x0bf2a0b7, 0xcef74529, 0xea8f7e46,
- 0x2fed415a, 0x259f680c, 0xd8b97386, 0x5deae544, 0x2e509a23, 0xcae61e1e,
- 0x0df2f2a0, 0x09644261, 0x6856fbfe, 0x3be9237f, 0x6ba50b52, 0x34786f55,
- 0xfd2f4da5, 0x6fa5c944, 0x578f3756, 0xf724abf3, 0xb97e34dd, 0xf9ed5855,
- 0x399edca8, 0xf388472d, 0x03136d7b, 0x233f32d9, 0xb03fcb87, 0x5d8d7952,
- 0x7bf85af8, 0x0e6a7dad, 0xd2b6e28f, 0x0fa98b38, 0xfae94a91, 0xea60ef18,
- 0x938d317f, 0x8b7de342, 0x0e5c1fbf, 0xe7cb0edf, 0x9fa88a0b, 0xf6626d7b,
- 0xf55dd973, 0x4ddb34f4, 0x6d46f61d, 0x553b577b, 0x3cc62588, 0x2422a1e1,
- 0x477914bf, 0xa432be57, 0x7ca42abc, 0xa7cfbf47, 0x1f2f3914, 0x1fc6037f,
- 0x12c785d1, 0x2c3b8f0d, 0x72eb1df4, 0x44d8128f, 0xbab12dff, 0xfe09cbed,
- 0x9b88c6e7, 0x55a94fd1, 0x47cdae38, 0x5f9e0ebd, 0x86345589, 0x87bbe3e5,
- 0xa6f3e9eb, 0xe2c31afe, 0xced11f28, 0x89bd53e3, 0xda9e4376, 0xab9ae09b,
- 0x4ba7a3c1, 0x4ebb85b7, 0x7fa0f3ea, 0xa6b12d55, 0xbeeecd7c, 0x7c0693ae,
- 0xfa7fc52f, 0x3449bfd2, 0x8bc091fb, 0xdddaabfc, 0xe892307a, 0xcdf14da7,
- 0x17bf5375, 0x9d1d7e0e, 0x1f75e6ed, 0x9beb4459, 0x7f3ea6af, 0xbedbe698,
- 0x426cf547, 0xfdd86fbf, 0xe7fd0c4a, 0x6e0f8b9b, 0x2fd5efa7, 0xddbb89a7,
- 0xc50ff35d, 0x17dd85e3, 0xfbe953a3, 0x08f643f9, 0xb9e68c31, 0x9dac7e37,
- 0x5c4762e8, 0xaf78b77b, 0xef5dd6d5, 0x35b5bcef, 0xdea1aa7a, 0x3d1ad179,
- 0x252f40cd, 0x8bd62fbb, 0x5f9fc65c, 0xefc2efcd, 0xc7bd7d89, 0xf4bdf4aa,
- 0x5ac6fdf7, 0xc35fbd28, 0xf736bddb, 0x6e096b13, 0xcf309eff, 0xfcfb8216,
- 0x682db31b, 0x728dfe7f, 0xcbcdbd2d, 0x244f5fe9, 0x8b68fc63, 0xbc7d77a4,
- 0xf70b6e35, 0x7b696a53, 0x8fda1aec, 0x93ebbfa5, 0x55d290d2, 0xcfc96a5e,
- 0xb76f3ac4, 0xdc002fb5, 0x46b115e7, 0xe7eaeb89, 0xdb9bb77e, 0xc9f3df9f,
- 0x270fe063, 0x4f901dee, 0x41f94d64, 0x3f2a3eb9, 0xa64151ff, 0x7f3dfa8b,
- 0xf80f5f4f, 0xfb9b76c2, 0xbbb7a636, 0xf7d83ca2, 0xa7187f7a, 0xb9effd16,
- 0xe90fa462, 0xca5e1247, 0xb8e4fae7, 0xabbf257e, 0xfb8b68df, 0x17e0d1be,
- 0xb679b7bf, 0xeffcb250, 0x31627d69, 0x6ee7ec3f, 0x4d74a1d6, 0xf89b7098,
- 0xbb864ac9, 0x22ec7844, 0x030b964d, 0x228995bd, 0xc9b0befe, 0xf1117dfc,
- 0xbc5f7c09, 0x5cbdfcde, 0xa56ead34, 0x98092df9, 0x3fda0bbf, 0x6bec04fe,
- 0x5ec5affd, 0xff7a0514, 0x4f54cc36, 0x40fe35f8, 0x255f091f, 0xc7c11fb4,
- 0x8102519e, 0xbbdf5895, 0xe8679e54, 0xa775debc, 0x2287bb70, 0xab4167ff,
- 0x5b8f5d61, 0xf0913584, 0x1c2edc7a, 0x47e8f989, 0xf5fa8508, 0x6c0b0bef,
- 0x0f7726a1, 0x04b92afe, 0xc231af7c, 0x5bbe0822, 0x427ce05d, 0x49f7d8ac,
- 0x5d29fa32, 0x356de853, 0xe6c177c0, 0xd4e7e87d, 0xe25dfdbe, 0xf8ef54d7,
- 0x58d340d8, 0xddf8eb82, 0x1ba1a7aa, 0xb1af4eb8, 0xe1014088, 0x02212ee3,
- 0xf27f94f1, 0x5a62e493, 0x7cb6cf97, 0xa4625c92, 0x36cc457f, 0x129ea3d2,
- 0xef3ebc24, 0xfcd2ef61, 0x305cd38e, 0x5d7ad09f, 0x57866beb, 0x2ab867c7,
- 0x87a3bb6a, 0x54f740cf, 0x5577f59e, 0xf7efb178, 0xcfa002d9, 0x3c5f8dc8,
- 0xb9f40f38, 0xa14ae6d7, 0xa9f66bb1, 0x2de6955e, 0x0c81a8f6, 0x4f7b639c,
- 0x9ce05744, 0x52e053d9, 0xd9aef30d, 0x7ce116a3, 0x62fbbf39, 0xf7366942,
- 0x44edc533, 0xa03c07fb, 0xf8e09edf, 0xf7fd5b9b, 0xccd79ff8, 0x7f65ceff,
- 0xf8037090, 0x9953c6c0, 0x07c4efe0, 0x79a6e6ff, 0xc6fccf9e, 0xad10bc8e,
- 0x047f4123, 0xe09bb45f, 0x2af810bc, 0x8e5c105a, 0xd037aabd, 0xa5443acd,
- 0xff4f19d8, 0x09137c32, 0xf82e84be, 0x94a89e08, 0x56705d11, 0x38eddbbb,
- 0xa2382f67, 0x694fc173, 0x12f29342, 0x0dc9f3b4, 0x493a5afe, 0xbf1d7f10,
- 0x70cae167, 0x8a4d0bc8, 0x97be8c27, 0xdcf955ed, 0x191bdb2a, 0x3f1816c0,
- 0xd2f9c9c8, 0x1840d547, 0xa3a827e5, 0xea9b30ff, 0xf547be2f, 0xfb148ed0,
- 0x07f6de37, 0x8375d61b, 0x881ca04d, 0x344b5c03, 0xfdec96b8, 0x8d0a67e1,
- 0x2ddf78b3, 0xe2ce3007, 0x170f1407, 0xe8edf3a8, 0x8a43c977, 0x67405788,
- 0x3a46e3b6, 0xce64d85b, 0x0bad122f, 0xc1fc1554, 0x9ef09dfc, 0x96fd415c,
- 0xdd730eef, 0xa102f18d, 0x4abc42e5, 0xff68d4f0, 0x3b58cacf, 0xcfd500f7,
- 0x3c6768da, 0xe2170f9c, 0xb5abf608, 0x0d204135, 0x1d6326b6, 0x6bf9efcf,
- 0xe6b1d632, 0x2995ff77, 0xcebf59ba, 0xaa37b4fd, 0x2148a9d7, 0xc4514eae,
- 0xfba0a9b7, 0xba8a538b, 0x201b6fa9, 0x9b36c5f7, 0xca879fbf, 0x8afc6c0f,
- 0x3d85c1f9, 0x6eae81be, 0xbf6bb7e8, 0x892dc3fa, 0x02e18348, 0xd716f0e9,
- 0x2427d80d, 0x35be620f, 0xdb4f569b, 0x97f0f944, 0x44b9386c, 0xf793864d,
- 0x42c7f60b, 0x3efabf43, 0x80be06d9, 0x0fe48474, 0x1cf201b6, 0x7b9daa3d,
- 0x4c77f6db, 0x9e06e8c9, 0xd71b6ea3, 0x5c100db3, 0xd17759ef, 0x845bd05c,
- 0xbe0d1fc5, 0x775ebc2d, 0xa2b3c22f, 0x5d4357d1, 0x89ef82ad, 0xfed389a2,
- 0x47d385a2, 0x5139f085, 0xc05c785f, 0x620310b3, 0xf3de3f81, 0xccbecf8c,
- 0xadac7f37, 0xe8357821, 0x022b1fc4, 0xeaffe85b, 0x63508746, 0x46b5ed20,
- 0xce5451a3, 0x5206fbb4, 0xd503edb9, 0x1dde40a2, 0xc7a7afa0, 0xa5f7fd85,
- 0x718c4673, 0x2e1ff6fd, 0xaafe8899, 0x8c22a976, 0xd3b73bfa, 0xd44e8226,
- 0x7c02fda7, 0x9ec2fe1c, 0x57b4be02, 0x6b979011, 0x35ef8f28, 0x80deada3,
- 0xa4772f01, 0xd50f18d8, 0x9cf29929, 0x4d0f7ab6, 0xbbcf7ea2, 0xeb90ec4a,
- 0x26cb876d, 0x25b1bce2, 0xd701d896, 0x1d63c3fe, 0x58b75829, 0xd59bef2b,
- 0x8f71f57b, 0x547fd0b8, 0x6f0c07ec, 0x4445b663, 0xa3c6bb53, 0xa6460161,
- 0x30a1f243, 0xc18daf0d, 0x37770ef1, 0xe317e3eb, 0x2a28c493, 0x044ea9df,
- 0x255ce79c, 0x2da3ac2e, 0x0aeee896, 0x4ef36f6a, 0x0dfa9abc, 0x078b8d8b,
- 0xd2526b7c, 0x8abf3d78, 0xbf3865ad, 0xcfc2f122, 0x08b6b7fb, 0x65fec6f9,
- 0xe9bee32a, 0x35cfde21, 0xd47e390e, 0x51cf953e, 0xe343a571, 0x4abbefdb,
- 0xc9059c69, 0x0f4147be, 0xc46dfc9d, 0x39fc02ab, 0xf96162cb, 0xe735f1ac,
- 0xbd21f05a, 0xa48a6cfc, 0x563d7d37, 0xc0bab2f5, 0xe8d51e3f, 0xc8ab9573,
- 0xa7986f91, 0xc345b7ad, 0x78039157, 0x3a2f61da, 0x9da5f384, 0x3cdce3be,
- 0x01cd3890, 0x59ea853d, 0x7aa9cfd0, 0xf47631da, 0xfc01c33b, 0x3255ea2e,
- 0x8b16ed01, 0x6fd8d5da, 0x22abd78b, 0x8dabe068, 0xa2ee3936, 0x1822114b,
- 0x22ee35df, 0x7f6e3f5a, 0xe9045a29, 0x970c6ddc, 0xe4a31af5, 0x452379fe,
- 0xb50f9fee, 0xf969b4f9, 0x7baf997f, 0x5cfd7ccc, 0x96b61fec, 0x46fefe48,
- 0xa55bf50a, 0xa1484eb4, 0xec4eadf9, 0xa7bf03b0, 0x98225dea, 0xb2f78069,
- 0xa08bc679, 0x7acedc61, 0x9f3c1c97, 0x3370f5ae, 0x75f35dfc, 0xd54e1e32,
- 0x7b1e3227, 0x84c93fee, 0x53feaec7, 0xbcbc784d, 0xff1e4cff, 0x77d67d54,
- 0x87b43ff4, 0xf826ddfe, 0xe74dfabb, 0xdf6ec571, 0x3b97f040, 0x980fc45d,
- 0x505f886e, 0x3df15db9, 0xdbe4357e, 0xe404c28f, 0x7dc2afbe, 0xfe065c83,
- 0x65ce0df0, 0x4982e7d6, 0xd17eb7e0, 0xeecd69cc, 0xded0138b, 0xfb017c4d,
- 0x11af2f49, 0xf8270ced, 0x3583e885, 0x7cb9bab4, 0xf4106fb7, 0x4e8e1d22,
- 0xa775e679, 0x20fb42df, 0xa3dfdf6c, 0x582f8fb1, 0x2878a7db, 0x46abd96d,
- 0x7c75f71a, 0xb1a7a4aa, 0x6dc8be03, 0x68d5efa5, 0xb6ef7c47, 0x020e9797,
- 0xdac3aa7e, 0x81f70173, 0x8b96ff97, 0x7dabe473, 0xfbe2074b, 0xf2cfaa36,
- 0xdabdbd87, 0x5d2fe863, 0x5196fcb8, 0x5533a95d, 0xefd0ffee, 0xf435f6db,
- 0x89db1c03, 0x0b9209bd, 0x0a2aebab, 0x0d83c64e, 0xff07ef79, 0x58b7c412,
- 0x5d3dda1f, 0xeef9031d, 0x28799243, 0x948f7c3f, 0x100f861b, 0xe40a4b01,
- 0x83670fbe, 0xb08f544f, 0x470aa0bb, 0x79611de4, 0xc384623b, 0xbffd50a5,
- 0xdbe397f7, 0xa1a42f21, 0xe83c617d, 0xf164caf9, 0x1b6dc9ef, 0xf04ff642,
- 0x34edeabd, 0x3ada955e, 0xfbc29c65, 0x7c153f28, 0xde2fadfb, 0x04d7f4d6,
- 0x9c01cfac, 0xfbcf046b, 0xa9653f5a, 0xcf502bbe, 0xe7bd68e7, 0x7337aa0a,
- 0xe864df56, 0x7e9ac547, 0x52112626, 0x947e64ae, 0xe5c83b03, 0x83d4b6e7,
- 0x3e7c525e, 0xd7dfc1e0, 0x35f9c1e1, 0xfa384934, 0x62455e12, 0x8d1a7520,
- 0xa2d5213b, 0xc0140fdb, 0xe39b443d, 0x965afd33, 0x1939f2c7, 0xfd1d0388,
- 0x4b4ee3b3, 0xfc064ef5, 0x670ffd7a, 0x75f1cbcd, 0xf2e86e73, 0xb2deddbc,
- 0x57b6700c, 0xfc7f5939, 0xeed44500, 0x41615989, 0x8a7a1a35, 0xf9f40d73,
- 0x0e0b91a3, 0x8c7c26f6, 0x43cdf28f, 0xbc6fb3ff, 0xcaf2357e, 0x72f77881,
- 0xeb7173d0, 0xc2efd648, 0xbca3377d, 0x981be1d2, 0x373c5340, 0x062837c0,
- 0xbc517c87, 0x9451275c, 0xfc2dd453, 0x45629e12, 0xe518df8e, 0xc53f472b,
- 0x5d8f2396, 0x23d66f81, 0x8d106f6c, 0x739fb9bd, 0x9dde5176, 0xe1e3affc,
- 0xfd8f3698, 0x25ed7136, 0x75fedf9a, 0x82069e31, 0x1bceecb7, 0xba50d417,
- 0x109452d0, 0xdf704d54, 0x575d4a96, 0xf6078bfa, 0x9cee7925, 0x4ebb834d,
- 0xcaeadb83, 0x50e7ee34, 0x79741bb8, 0xeb0a17e5, 0xf947fc83, 0x81b1fd17,
- 0x661f29bb, 0x74c1f8b9, 0x16395b9c, 0x886c93b6, 0x7a45bda0, 0x9c1a3be4,
- 0x73bed28f, 0x35f7f1c4, 0x21189ef8, 0x683e27db, 0x507ec009, 0xaf0f7634,
- 0x4ed513d3, 0x15634a8f, 0x721db70b, 0xb2f0a950, 0x31d7fcfe, 0x4ad7db7f,
- 0xf54e6af3, 0xddbc07dd, 0xfe496f1c, 0x0df0e180, 0x6b790a9d, 0x3fc79cb4,
- 0x1e793790, 0xc6cb84d3, 0x6b589942, 0xcd31fc81, 0x50b2a725, 0xba63fb91,
- 0xde30daf0, 0x7ae3e14c, 0x7bb79def, 0x07bc4fa1, 0xbee0885d, 0xfbf9f851,
- 0x74e0111c, 0xfd72089e, 0xe72b449b, 0x7d137c75, 0xd24bdcdc, 0x547d27c7,
- 0xc056ffc6, 0xee646efd, 0xc79a3a80, 0x650687d4, 0xdcd57eb0, 0x5df3f19b,
- 0xe8d54f70, 0x6feff686, 0xbfd88eb1, 0x699fa833, 0xdfec8437, 0xf5f5bdf1,
- 0xfb47f8cc, 0xa74748e8, 0x4bece4fe, 0x5b4eb878, 0x4bbcebd2, 0xc2127f59,
- 0x8fd1f2c5, 0xa85b7db4, 0x5a2f453a, 0xd26e239f, 0x89960897, 0x62259663,
- 0x10afafbe, 0x3ad0156f, 0x15463ebe, 0xcbd35c0d, 0xfd68a6ed, 0xe13fe94d,
- 0x0f5bd833, 0xe1af608b, 0x92f0aed4, 0x8218d5ef, 0xbdba8a7b, 0x27ca9631,
- 0xc6bd27f6, 0xefaeefc0, 0xfd0ac3b5, 0xf37486ee, 0x66d949f7, 0x68b267fd,
- 0x94fe3152, 0xfb7ae6e1, 0xb3a22781, 0xfea553f7, 0x21888622, 0x0b7af2df,
- 0x1d3e718b, 0x2fda2e93, 0x69111c10, 0x2eb18fbe, 0x75ff27cb, 0x5615c601,
- 0xb7ea9f39, 0x1debb655, 0x288b7927, 0xa7ac9c50, 0xca532293, 0x4a7fc825,
- 0xd3d203f2, 0xcf4e6ef5, 0xf28f79d2, 0xce1ef5f3, 0x9d15a417, 0x6b25bf40,
- 0x7d62b73e, 0xf8970cee, 0x9a696f2e, 0x762ab000, 0x5a441cb7, 0x809a2c16,
- 0xa1d17663, 0xef4883da, 0x6adbd4ec, 0xe1d3be59, 0xd3a345be, 0xfda6a25b,
- 0xe1d68730, 0x87aa3d96, 0x4da603f3, 0x790bdc9f, 0xa27be71b, 0x444baaa3,
- 0x54572433, 0x012fdeab, 0xdb6f7797, 0xdf9a78c1, 0x18a3f527, 0xbdeacfee,
- 0xfa99f70c, 0x4a4e9c89, 0xe81bfa2b, 0x673e2bcc, 0xf6f26c79, 0xd5126b36,
- 0x5e2af42f, 0xbd6bdbec, 0xfda01022, 0xcf26deb7, 0x0e74f581, 0xc98f1f60,
- 0xade8f699, 0x67da7c02, 0x6671a34b, 0x10a4b0de, 0x55194ce3, 0x1bbd456c,
- 0x201921bf, 0xbf4e8ba5, 0xf9f5ee8b, 0x76eb6957, 0xf18565ee, 0x2d33b1d8,
- 0xf2c17206, 0x907d695d, 0xf5d4bf12, 0xade048dd, 0xe18592e3, 0xc11a38ec,
- 0x6ede86fa, 0xe648aef9, 0xd807cb3b, 0xb760c203, 0x2ceb433c, 0x99e6f20c,
- 0x36e27e67, 0xe2672b9e, 0x18fabe5a, 0x922fedfc, 0x736491bf, 0xbff011ea,
- 0xa03cfdfe, 0x9c9af393, 0x24467a4d, 0xcd6abfce, 0x84fe08ae, 0x690899fc,
- 0x6cf91dcf, 0x2fec58d2, 0x4e1c478c, 0xf32bfce8, 0x7f5287d9, 0x6f1aeeee,
- 0x8fc2cb5b, 0xb9fca11f, 0xa36fc580, 0x689ce9f3, 0xf03bff39, 0xb64ecddf,
- 0x10a9ddeb, 0xb77f383c, 0x967ce3f4, 0xc3a88d62, 0xbc022bf9, 0xb714b3bf,
- 0x55f88eb5, 0xf70f73e5, 0x44bdfd03, 0xe5451838, 0x648bad2f, 0xcd92f67e,
- 0xfd0eac73, 0xfbfb2a3d, 0x3d3fbdcd, 0x3de91bbe, 0xc53ff955, 0x31c5a4f2,
- 0xb57ecbfe, 0xd3da0864, 0x52fa2ef9, 0xa8bf4f7f, 0x3f69c304, 0x5fef34e7,
- 0x1be097d9, 0xd2cda1b6, 0xcdbcd28f, 0xa1d2034a, 0x04386e03, 0x690df3bb,
- 0xb05f6e6e, 0xc24d453d, 0xf817ec36, 0xee7c07f8, 0xec81e59b, 0xf6c7cfe6,
- 0xc1725d13, 0xf4e5a510, 0x2c358246, 0x8fbe68f9, 0xf3c4d7f1, 0xfa77b5d9,
- 0xe604f3fb, 0xe0071241, 0xf87bb62e, 0x37f80a1c, 0xf9cf3d62, 0xd7ac3cb2,
- 0x061ff915, 0x25f39d9d, 0xbd2e7078, 0x55fc7a40, 0xcacc7fa8, 0xf3717cf3,
- 0xebb0d1bb, 0x1c7e90c4, 0x5e487f0e, 0xafd404fb, 0x7e16e01a, 0xb1e03f6a,
- 0x3f0226eb, 0x6d773bd5, 0x1d2a7ee4, 0xe5b9e81e, 0x4c1e2ebb, 0xbd789c82,
- 0x0e8064f0, 0x2ffcca77, 0x2a3d7bc7, 0xe37cb54d, 0xa47f3297, 0xa445f388,
- 0xbf515a75, 0x0f47ca54, 0x689fe769, 0xc8fe65cd, 0x5aeeeda4, 0x31525faf,
- 0xf8a7d7ca, 0xadaec2fb, 0xde749b9f, 0xab61a555, 0x23fb65d8, 0x3325e763,
- 0x79e7be5e, 0x2dced767, 0xec87bfbd, 0xfd4e1fc2, 0x3b036cc0, 0x3cbb06fa,
- 0x7f10b7a7, 0xe7e8bd01, 0x0bfb8d34, 0xef6a5fec, 0x524d3f05, 0x849d9c95,
- 0xc287a48f, 0xbef8ce58, 0x598ecfe3, 0x2eb6e7cd, 0x4844d567, 0x0567c83e,
- 0xe5185fb5, 0x5bf30bbb, 0xc2f39da8, 0x1c86ceea, 0x7bca2332, 0x3a57be37,
- 0x073193da, 0x45ef3f3a, 0xb9255abe, 0x7720cd2b, 0xd7bee339, 0xe51759f9,
- 0xbe7cc66d, 0x91b1fd6f, 0x520c6704, 0xad22cf5d, 0x9c7e5ba3, 0xfc05bdba,
- 0xc93081f8, 0x980aa38f, 0x0bf3e91f, 0xda15ffed, 0x33e23ef7, 0xe279d1af,
- 0x738fdc23, 0x7af2b18e, 0x3ca96abe, 0xa170e748, 0x6c84011c, 0x79ce1d8d,
- 0x6fe1146f, 0xbe1553bc, 0x3d45f46e, 0x1e7af5a5, 0x2bd099f8, 0xb0af54d2,
- 0xfb1dac57, 0x5bcefbf7, 0x8d47d6d5, 0xbba9f9d0, 0x37767097, 0x5bcf396f,
- 0x01f447c2, 0xdf2ac65e, 0x5b0ebe6f, 0xc3ac41d1, 0x9f1e6738, 0x539ce38b,
- 0xc304f98f, 0x43df187f, 0x1f3a19e7, 0xf27ef8e1, 0xe1158fd2, 0x7dff60b7,
- 0xdafb676e, 0xd3eb5b5e, 0xee7c25bf, 0x81ed925d, 0xf005e89d, 0x68cff05e,
- 0x7bb3cb3b, 0x7c1f84a3, 0x84d4ef65, 0x2f45ec00, 0xdf044f41, 0x79642de8,
- 0x77bfacb8, 0x7f53950e, 0x5f68c2fd, 0x2f345ec0, 0x069feb42, 0x7d15fb46,
- 0x52837db8, 0xda0e66fb, 0xbe6488af, 0xf9203473, 0x706c7378, 0x9bdf4a9e,
- 0xa814cf3f, 0xd6045477, 0xeddea2a4, 0xe5435fd2, 0x6fd43549, 0x122192f3,
- 0xf951ffce, 0xf3ce68dc, 0x32738df6, 0x4cfb671f, 0x5f6f54f3, 0x697aaff8,
- 0x51bcd5eb, 0x3d83f796, 0x9429e514, 0x9b63f4a7, 0xab573fac, 0x974691f7,
- 0x0f99cfb4, 0x5a44a6f8, 0xd2fde741, 0x99d2c24b, 0xc2fb7929, 0x5948f3ef,
- 0xe728db06, 0xc29f5c56, 0xcbd9a3f4, 0x5b7c6b66, 0x1c0d0fef, 0xcb2f2123,
- 0xb70b39bf, 0x679e8384, 0x41b78796, 0xbe5a3bee, 0xfb7a0a32, 0x0c1a9f4c,
- 0xa3395c83, 0xaf29dbd0, 0xaf5c62a5, 0xd74cb71c, 0xc0a582ff, 0x0eedcbeb,
- 0xf7cb3771, 0x3ea302c1, 0x556fafa5, 0xa37898cb, 0x27615cde, 0x2cf042fe,
- 0x9a6df6d1, 0x7d3bd7d3, 0xebe9f404, 0xf4fa8de3, 0xe40f65a7, 0xc6d2fef2,
- 0x8def5b3b, 0xb90e993f, 0xfaa7226d, 0x0f7a9d78, 0x57e74dd6, 0x25db97a0,
- 0xfb6b08bd, 0xdf298b47, 0x07887b30, 0xd389eaf6, 0x1d6f4c1c, 0x1f2ce12d,
- 0xf08ecc37, 0xb0d76ec2, 0x06ed8c2b, 0x83fb6b37, 0x1ba628f4, 0xee28beff,
- 0xf32ed2a7, 0x3065cf95, 0x0f60bcdd, 0xe515b93c, 0x7fb3872f, 0x8e5a32b6,
- 0x24bbf95b, 0x29bd2e8d, 0x5fb17aab, 0x32a5e98e, 0xe5c31dc2, 0x7a678fbf,
- 0x57dc367a, 0x7d127c00, 0xd2bc5db2, 0x258ccc1e, 0xe8d31ffc, 0xfb237a0f,
- 0x98a36af5, 0xf796856e, 0xf59e3cfd, 0x797f9238, 0x437ddf3c, 0x7bb3ef39,
- 0x3ec42efb, 0xf0c91e5a, 0xf2c9731c, 0xbcb19563, 0xb7dfe60f, 0xc5fc30f4,
- 0xbcec8ac7, 0x55ed8e5f, 0x73fade59, 0x9f841a9d, 0x9acfa75b, 0x86dfc725,
- 0xe1baa8f9, 0xd4dde4a3, 0x5595fccf, 0x7e6ed093, 0x7053edc5, 0xf69af6de,
- 0x4369fb29, 0x4afcf3f7, 0x97d47fb3, 0xf98c9dee, 0x760764d5, 0x1e7ea41c,
- 0x116a739c, 0xee9fd3d6, 0x3ef5869b, 0xe17d6f6f, 0xeb77044f, 0x5eb23f8a,
- 0x6fb47d74, 0xd85fbe26, 0x5fae1bf3, 0x16bff2bd, 0xb6afce41, 0xcfd17a4a,
- 0x7e8d1ae3, 0x1e6f8645, 0x7cae57ea, 0xc881f59d, 0x7f9223ec, 0xf8fdfede,
- 0x5bbde9ce, 0xdda8505e, 0xd5bd88d2, 0x5c81aa9c, 0x94676b9c, 0x0692b460,
- 0xed3d4a7c, 0x8d182bac, 0xa459f175, 0x5b74b89c, 0x4b181f88, 0x7fd9a091,
- 0x16d2dda8, 0xf242bf19, 0x19f41d82, 0x7d297f5a, 0xf3df7ae7, 0x9168857b,
- 0xdf7763df, 0xf75cb57b, 0xfc387060, 0xb09b19ae, 0xfd76e7ee, 0x77e8d326,
- 0x872f4d0d, 0xacffce57, 0xeace5fb6, 0xbdb665fb, 0xb9005ed3, 0x7d33fceb,
- 0xfe76744c, 0x3f9cc1c9, 0x112bb4ad, 0x577f974a, 0x72465a78, 0x65b78d7c,
- 0x07e7e424, 0xe34befb5, 0xaf82465b, 0x384e7ce9, 0xff59725a, 0x85c96acf,
- 0x47f3abbe, 0xc992d451, 0x992d03df, 0x4582ff68, 0x8ff853da, 0x3a78a8e0,
- 0xd2dde369, 0x0cb7e10f, 0x26e87e47, 0x1a71f5e4, 0xe91f25c2, 0xa58fbe69,
- 0xf9e63b4b, 0xbd9bf639, 0x7ad07f54, 0x707ca9bb, 0x9adf9cc0, 0x03e7ed2e,
- 0xfa6fe243, 0xc3fbeda9, 0x213c8e70, 0x3fd7f5ba, 0xd4f38da3, 0x3c719d53,
- 0x0acfa6aa, 0x6e1f4eb7, 0x80dbdf29, 0xf13a8fef, 0xf1126b7d, 0x6398a5e5,
- 0x9e5fcf2a, 0xfb494f67, 0xbe790bcd, 0xe7179c24, 0xff821781, 0x67ca5885,
- 0x7892be43, 0x3e3af3d5, 0xf2bfe743, 0xb04945a3, 0xae947edf, 0x7d3cf9db,
- 0xde3a9740, 0xefa46c1a, 0x2e3f4364, 0x8569382f, 0x2c49ecde, 0xdaec1ab3,
- 0xd81cf3eb, 0xe4378b57, 0xd6748c39, 0x10e0adb0, 0xece21c49, 0x2007ab36,
- 0xf7035837, 0xd86f7e42, 0x05f8b6a6, 0x54bc3b97, 0xc0f3acff, 0x68b7a8db,
- 0xe43e6c43, 0xe2fdbd6d, 0xcb1223f5, 0xdd0e700c, 0x9c875e66, 0xd87e7316,
- 0x04fe736e, 0xffde80ce, 0xa0bcbb7c, 0xc8705f39, 0x83e4ff9c, 0x9c81675b,
- 0xbdff55cb, 0x3f89f42a, 0xf384384d, 0x5e17d3f1, 0x2cfac68c, 0x41d94bfd,
- 0x71a149e8, 0x0a6eb422, 0x56ff08f4, 0xb2e3e985, 0xf81e9178, 0x810f1e81,
- 0x93a4619d, 0x683fe10a, 0xfebcb94d, 0xcb32d119, 0x5955744b, 0x64e0bcb7,
- 0x57bf5741, 0x43b3acb6, 0xb71d0bce, 0x9c2ffda7, 0x6aec375e, 0xd964a3c5,
- 0xc5637555, 0xd62df809, 0xf4013bbe, 0x854bfc57, 0xe7e28ae5, 0xbe0abd07,
- 0xce63b6df, 0x9ace9c0d, 0xedd0f8c8, 0x2af78b7d, 0xbbca28c1, 0x5dba4946,
- 0x7d615eb8, 0x1cd1a4bd, 0x36b65747, 0xd9a6de24, 0xf778be5c, 0x9f86fffe,
- 0x18f1dcbe, 0x1e5c33c7, 0x05781827, 0xa7c55b7a, 0x153ded82, 0x330dbf9b,
- 0x2d79cb97, 0xbfe1e7d4, 0xaee1e396, 0xcf3a5592, 0xd0c893b7, 0x574bf0f9,
- 0xe1066a51, 0x8de6aafd, 0xbd9b94aa, 0x7597ecc5, 0xb0ce39da, 0x918221ca,
- 0x28a1cf04, 0xdf45d7bb, 0x628fae2f, 0x18516179, 0x9cf99fc9, 0x438e708a,
- 0xdda0c4f4, 0x965477a9, 0x25e2aa83, 0x571eaa1e, 0x56c5b002, 0xfc8a48c1,
- 0x04bf3213, 0xd25526de, 0x3f00d78f, 0x1798cdd6, 0xab6f524d, 0x03f706b4,
- 0xc0e79d2f, 0x4abd7336, 0x38d1e79a, 0xefe659c8, 0xeb9da2d5, 0x36feecd7,
- 0x60ddf8cc, 0x527d65df, 0xc8556bd7, 0x7aa70433, 0xb3cb0447, 0x402398c4,
- 0xef14ab57, 0x29150ec3, 0xefa0e39d, 0x2f964e25, 0xe7946ee6, 0x838c3347,
- 0x0dd78390, 0xae67b966, 0xbe04cde2, 0xd670bac4, 0x1fdca9a7, 0x64e58bde,
- 0x4e484396, 0x7daa3966, 0x12e39d8e, 0x825af39b, 0x1f9ac790, 0x0ad0f148,
- 0xf3e47f32, 0x96709ee8, 0x4aa79a7b, 0x5d79a7b9, 0x31ff6e1f, 0x390beb40,
- 0xf9b9e25a, 0xb71e1c9e, 0x89db2a9f, 0x200f523e, 0x7a133ab9, 0x41e5c102,
- 0x67472eb9, 0xb04afac5, 0x9bfcfaee, 0xe0a3db63, 0xf1e512c7, 0xd86e4bdf,
- 0xed879da2, 0xf003c2eb, 0x8a549c53, 0xf60c5a0e, 0xe4325ba9, 0xac7231f9,
- 0x8f56ab77, 0x966519fd, 0x80ff77a9, 0xd07b29e0, 0xe9486ee2, 0xf5e1075a,
- 0x27fe6266, 0x83e785d7, 0x958e46ee, 0x7963a7f6, 0x0e479f92, 0x73bf1c17,
- 0xedefd6bb, 0x9a531619, 0x48f44118, 0x942c9cfd, 0xe1a8edf6, 0xa4076c45,
- 0xbbb9ba35, 0x19359038, 0xb32a9cf2, 0x9afefd17, 0xa4e9e06e, 0xde52f18b,
- 0xd94cb93d, 0x72f2e124, 0x5fc8dfbc, 0xf0fdb385, 0xe8de76a4, 0x347441eb,
- 0x8d71cf82, 0xe8d3ad9f, 0x74cf5d66, 0xb98ba263, 0x3741b790, 0xd8b9e473,
- 0xfada5749, 0x7af0dd12, 0x485d13b7, 0x6be211ba, 0x4b742fb4, 0xdf443b79,
- 0x7bb7d4ea, 0x0e88b7d0, 0x6de8c89e, 0x074217a8, 0xf1181ac2, 0x252cfc8f,
- 0x2a4762a3, 0x564904b4, 0x2cdc47e1, 0xd7c646ce, 0x4ac0d65d, 0x55bfa782,
- 0xab00cbae, 0x653a3ba4, 0x5cf911fc, 0xd9f88bdf, 0x0b17fbe2, 0x4e2fd52f,
- 0x4ab76c12, 0x2626f927, 0xa409db8e, 0xb0aa0770, 0xf68a50e7, 0xffb231c5,
- 0xc46fa262, 0x5e7f51b3, 0xdcc69c4b, 0x2a7fc246, 0xfb407e58, 0xef6e7ce8,
- 0x5ef6c8b7, 0xd303a52b, 0x5f6a3ee4, 0x2bf8c615, 0x264073be, 0x58d264e8,
- 0x66249d33, 0x4f41394a, 0xbadd331b, 0x7e0890dc, 0x9838d250, 0xf08699cf,
- 0xd85daaa2, 0x7d48cfa7, 0x4df578a3, 0xbe004793, 0xd83de367, 0xeca7a7c2,
- 0x494aff60, 0x7f1f9ce3, 0x5b653d08, 0x98df7f38, 0x780f7be9, 0x17b8ad3f,
- 0x250fa2ec, 0x27b15f33, 0xcb5f7b52, 0xa3bf73d4, 0xc77f8a74, 0xa62390db,
- 0xfeb950cc, 0xb9ed2114, 0x338e51a2, 0x35b9ffd9, 0x3c9bfa91, 0x94f0e15a,
- 0xf25770b6, 0xb455f832, 0xd1a63df5, 0x98b84377, 0x70139cfd, 0xcd4cc80d,
- 0x24821f86, 0xe4e46ed4, 0xfd5a9901, 0xc806ca31, 0xc9c70343, 0x47d7a7fd,
- 0x2d37e83f, 0xcfb7ee53, 0xe7a77db4, 0xbf5caf09, 0x5b584d6c, 0x5b52345a,
- 0xf3a51070, 0x039ec6b2, 0x2a94999f, 0xde07ac26, 0x4d8aaa7f, 0x317b6f0c,
- 0x4ca885f3, 0x8f82f837, 0xfba65914, 0xee99836d, 0xb7b4c6db, 0xb6f949dd,
- 0x7ed2392d, 0x0bf3e9a7, 0x82e5825d, 0xef9231b6, 0x64896fb5, 0xd5cc73fe,
- 0xed27151a, 0x97dfac5d, 0xd7f1246a, 0xe17b86ba, 0xda752e37, 0x2c7e70db,
- 0xfb3a607c, 0x499b4bfb, 0xfd5c47bf, 0x4f7eb35a, 0x6658787a, 0xa87afa37,
- 0x019a0e5e, 0x55ad951d, 0x36070e98, 0x997dec78, 0xcc2e29cf, 0x4c19ccaf,
- 0xf32fff07, 0xf05c7384, 0x37fb7a65, 0xb091f784, 0xba0e0b1f, 0xd7c83a1a,
- 0x3716e30b, 0x1a7eb315, 0xfe63ed99, 0xbc255035, 0xd4cf1d10, 0xec126fe8,
- 0xd64be0a0, 0x97d8bed6, 0xdf6865af, 0x4e995ce3, 0xbe70eba6, 0x7366d06f,
- 0xb6be0265, 0x9c16e155, 0x4a5693b7, 0xe77da6fa, 0xbb80bdc0, 0xfc0222ac,
- 0x7ed6b8e0, 0xd16b0afe, 0x77f7ca46, 0x1c546b08, 0xe98f2be8, 0xfbe5903b,
- 0xe9f7eb0c, 0xc828c42f, 0xd76ba50d, 0xfa34b849, 0xe323d610, 0x4f9c69e3,
- 0xc3e4a4b7, 0x53d3a0ae, 0x766c6b20, 0x5d0308e6, 0x1e9850cc, 0x60873e68,
- 0x55979d9f, 0xfa728f92, 0x32f41fbe, 0x1d306c69, 0x6a85d871, 0x76abc725,
- 0xe20f0a24, 0x3b443a87, 0x241d23cb, 0xea3f808f, 0x27e7467c, 0x475e1744,
- 0xeb7ad742, 0x3d6b657c, 0xde784681, 0xf4e0ef56, 0xb0977aa9, 0x5ed84f12,
- 0x67f9c89f, 0xb69cddeb, 0xf7f167d4, 0x9c3deae7, 0x8a3f59df, 0x7bd42ff3,
- 0x7ebbbf39, 0xabbfa722, 0x84efe22f, 0x3a4be61f, 0x93f9d1df, 0x9f3a5f4e,
- 0x05aba50a, 0x33dc6684, 0x0fccf6a0, 0x79883e75, 0xf8bbf258, 0xa9cebe93,
- 0x113f914a, 0xceb450fc, 0x5428ff01, 0x22f33ecf, 0xdca3b9e1, 0x1da1f1c9,
- 0x0ec1f242, 0x8dcf83a7, 0x0dd8bb64, 0x32c340fb, 0x869ddb6f, 0xb95e7873,
- 0xba06ac22, 0x5c36a9bd, 0x7d740d58, 0x29ac5d73, 0xfdeebf3f, 0xff50fad7,
- 0x2df18b3f, 0xbb1cfac2, 0x7fa3d4e3, 0xdf8fefa4, 0xeb033a71, 0x796c704e,
- 0x1edee308, 0x2ad1c1a1, 0xceddbae1, 0x08c0d2f2, 0xcfe14fa9, 0x2d738861,
- 0xfb7d894e, 0x31e70437, 0xda061d6d, 0xc146b35d, 0x754ab32e, 0x1f2aa4ad,
- 0xfbe8bd63, 0x2af5b59f, 0x7c630ba9, 0xfb6a3496, 0x4cff18d4, 0x57de3cf8,
- 0x78a75cb0, 0xe91f8085, 0x41ec2ff8, 0x71c41192, 0x685011c5, 0xad94851c,
- 0xae17b0f9, 0xe428fd79, 0x10eea574, 0x873ed5cb, 0x8428e393, 0xd8d676df,
- 0x9077529f, 0xfed689eb, 0xc8c838a6, 0xf83b5ee1, 0xeb1b6805, 0x40759256,
- 0x268b9f60, 0x94f1ef85, 0xd6cbdf69, 0xe2f8a628, 0xe655337b, 0xac32878b,
- 0x14ca0e9c, 0x89a5139a, 0x5e9d29cf, 0x3c707f89, 0x9e535963, 0x2f81917d,
- 0x4bdf6897, 0x78a62cb3, 0x321943c7, 0x98106a2e, 0x6777a505, 0x3217daa5,
- 0xdc7373df, 0x24bf5ebd, 0xea757f2b, 0xe883f470, 0x8ff6aea0, 0xddb95a64,
- 0x84970ca1, 0x59e741c7, 0x74e9c714, 0x72e82e7b, 0xeff8a7cc, 0xeb3f0c95,
- 0x3ecf1559, 0x7bfc2cfd, 0xe30a7f15, 0x9862a9f3, 0x0ec8df66, 0xf2ce9c8c,
- 0x8ca9d78f, 0xd72dfc84, 0x7fd3fc7f, 0x547c4689, 0x57694ecd, 0x690db4a5,
- 0x6ce5edf5, 0xd0f6ab57, 0x9f0388fe, 0x5fcdfb35, 0xd14ff67d, 0xf897acad,
- 0x5bf8b493, 0xdeaaf78e, 0xc0e38279, 0xd0afb8f4, 0x37ca3576, 0x71eaa7ac,
- 0xb63fba01, 0xf78d9f70, 0x851ecd4d, 0x5d9a98f5, 0xe7c01317, 0x4aadf66a,
- 0x272e2ee8, 0x5e3d5fb4, 0xd5bfb740, 0xc39fb588, 0xc384487f, 0xffad0ff8,
- 0xaf546676, 0x62054353, 0x3b60aed5, 0x1c705588, 0x8e2d72c7, 0xc19023b3,
- 0xe49ee17e, 0xc4f59aed, 0xedbf49f0, 0x1063bab0, 0x88417caf, 0x53addd89,
- 0x7e7920fc, 0x047da39f, 0xed85f0bf, 0x1791cb2a, 0x7ef147b6, 0xff7edea8,
- 0x55dbc441, 0x8dd8566f, 0x308e2557, 0xaa77aade, 0x0fe061c2, 0xc50bb035,
- 0xd2e70cf7, 0x416aa3a7, 0x145a4b5f, 0xadf816ef, 0xde98ee1d, 0x35da7806,
- 0xd61a5afa, 0x45d79232, 0xf814ff83, 0x5cce419a, 0x8e7ef7b2, 0xe77aa413,
- 0x6df9ae59, 0x51b3c724, 0xce036f0f, 0xd80a1b33, 0x65a4bd4f, 0x05cb3547,
- 0x105d23db, 0xccdb4e69, 0xd1be29f7, 0x9346fbc6, 0x4fc0ced3, 0xaacff682,
- 0x4e030f2c, 0x5ad3cbec, 0xcedeab3c, 0xb3b64832, 0x0dfb7868, 0xae88e7f6,
- 0xda5a4bfa, 0xfea9d3a2, 0xe7dfbb27, 0xee4839d4, 0x23ce25e3, 0x3f4738b9,
- 0xf7c919d9, 0xf9d93eed, 0xd12f09eb, 0xc65ae778, 0xfb0c52f4, 0x1b20e06c,
- 0x41b73fd7, 0x25f301c6, 0x5a0fd611, 0xb6673e78, 0x27ac2927, 0x9f84df03,
- 0x8f9f3b33, 0xf63ef0b6, 0xab717bff, 0xc86b15b3, 0xb2eb847d, 0x5bfe8047,
- 0xed11fbb5, 0x7fe5fd9a, 0xed6affa7, 0xa4529b7b, 0x3bef238d, 0xc20e3d08,
- 0xd53beda5, 0x796efbc9, 0x2fef9d94, 0xbee6182c, 0xe8f81e71, 0x518e329b,
- 0x043f77f4, 0x3bc16ffd, 0x596f6cf1, 0x41f7736e, 0x36c38bfe, 0x282c13f6,
- 0xa1f51cf0, 0xed9d8c7e, 0x75b1224a, 0x6dadec04, 0xa8be5229, 0x933b435c,
- 0xe88fdc50, 0xacf84fcd, 0x8f84580c, 0xa50793f2, 0x523ebaf2, 0xd9daf16e,
- 0xfbe413ff, 0xc2ecc792, 0xfe2f7b8f, 0x5d7ea4e7, 0x0efd2a99, 0x517f608f,
- 0xcc17195a, 0x4edd878c, 0x69ca9ba3, 0x9fa06e54, 0x4cc14dca, 0xed674fc8,
- 0x72891ed2, 0xf9954de8, 0x46835eb2, 0xfd07e8a7, 0xceb8a5b6, 0x2bbbbcb3,
- 0xb0ef404a, 0xed2518bc, 0xdf09bf21, 0xaf386614, 0xe9241a6f, 0x07f341b8,
- 0xf848b7fa, 0xf8e41700, 0x4ca6f625, 0xb8fab9c8, 0x789ba24b, 0x78dab3bc,
- 0xa49a224b, 0xc78b44ff, 0xdf1e7d43, 0xd3bfd826, 0xcb1864fe, 0x1efba7cb,
- 0x9fe30179, 0xc730727e, 0x04a5b411, 0xf2e6ed16, 0xaee38e70, 0x082c2a78,
- 0x327b3f78, 0x9f58ed8a, 0xf61ca4d9, 0xcb025459, 0x1ea28761, 0x3afe805c,
- 0xe0298736, 0xc2299fa3, 0x2df2889e, 0xa80e59bd, 0x3f63afa8, 0x17b10549,
- 0x4e94afc8, 0xd9f7dc84, 0x276cc196, 0x950decfa, 0xf7d0292f, 0x13eef835,
- 0xc67e0b4d, 0x3ff4bff2, 0x6fea7e9e, 0xaff3bb83, 0xdb366c54, 0xd7f5f4c3,
- 0x2418efcb, 0x0c7703ed, 0xcac97a92, 0x7fe92e41, 0x30796c8b, 0xf929e795,
- 0xeb03ad03, 0x131fb47f, 0xd63f6f60, 0x714127b2, 0xccc1cf02, 0xdbef035f,
- 0x7a759ea4, 0x42fd8dbb, 0x79462f15, 0xe774fed9, 0xb0ef7c15, 0x78729542,
- 0xdbde4585, 0x99eed0ab, 0xb2674456, 0xcdf08b7d, 0x16fb6d7a, 0x8e471b55,
- 0x01d6d9fb, 0xd4109fd2, 0xf0e42ff2, 0x7149b83d, 0x2c69e6e2, 0x05c86d5f,
- 0x8e6e2f5e, 0x1a79f8e4, 0x87b88bc7, 0x5cfd9f8a, 0x116633e2, 0xae7407eb,
- 0xd4ae7f31, 0x9dd573f8, 0x5ee0c757, 0xe5477881, 0xad1712fb, 0xbfe03e9e,
- 0x4f7af8a1, 0x5f4b63e3, 0x41f99478, 0xc417ed25, 0xfcd52d59, 0x529f4bcb,
- 0xba5c9e58, 0x9887eafa, 0x136dbeef, 0xb6705fb8, 0xe368fee5, 0xf8d5ec7a,
- 0x0f7b5767, 0xf54a5fd7, 0xa337fb65, 0x36ad9e19, 0x5d09e00f, 0xfeddefc7,
- 0x6a5ff529, 0xf242d15f, 0xf3e5ee45, 0xdc8e28bf, 0x95f027f6, 0x676ce1ed,
- 0x7be7f5a3, 0x2d6c6746, 0x33ff308b, 0xbf3384cf, 0xf72b1339, 0x9e7427fd,
- 0xe780edfa, 0x5db1f787, 0x02e9bded, 0x80e2d0e7, 0xae1d5fb9, 0xafdf1afd,
- 0xc0c4f78a, 0xeb45534f, 0x7d68fe81, 0xdfedc47e, 0xd0fb71b1, 0x768e3cf9,
- 0xf4fb0c23, 0x9ba64899, 0xbae4fd33, 0x1076799c, 0xb16d679f, 0xde09de92,
- 0x674be864, 0x1b8a6562, 0x0a87a03e, 0x3387a497, 0x1ed85a63, 0xc1d94670,
- 0xb64d9b69, 0xfcd3a8ab, 0x897f44da, 0x26d01fa0, 0xb58ea9ec, 0x80c72047,
- 0xe7cc8fcf, 0xcefb8834, 0xd07376a1, 0xbebfce29, 0x84dcf259, 0xcf3e0578,
- 0xe3f61b7e, 0x733df0b4, 0x564f269f, 0x4fdcbf6e, 0xdcaa7588, 0xeb3fb0ae,
- 0x02fe7692, 0xddba5eea, 0xa972e89f, 0x6e22f15f, 0xb2e3696b, 0xa5fba025,
- 0x81e6ebb5, 0x2c79f5ee, 0xb75feed5, 0xd3c32a29, 0x27fb4e16, 0x74f1f2fb,
- 0x8a59aafc, 0x5c279f1e, 0x7b45f9fa, 0x2dcb2c38, 0x4db288e9, 0xa3655fd4,
- 0x49c796b2, 0x395bf5d1, 0xb84f1d3f, 0x5efb02cd, 0xb9df769b, 0x70ebf9a7,
- 0x524f04f6, 0x6d4fe496, 0x6f9ef229, 0xbef25bfb, 0x0a6fc5f6, 0x81fee262,
- 0xfa91c83c, 0x7f047f7a, 0x72106816, 0x96e7c68f, 0x704eaec2, 0xfb306e66,
- 0x9b36b273, 0x9bb643f3, 0xcd3bd9f3, 0xe6bddcf9, 0x7355e7bc, 0x7b7185de,
- 0xfa09e177, 0xa103e236, 0xbe85236f, 0xfa94ceed, 0xb7d0f236, 0xc6df4291,
- 0xc8dbe877, 0x1e46df43, 0xd0f236fa, 0xdf4291b7, 0x1a39f7c6, 0x7b352a9e,
- 0xe381d629, 0xeb84f6d4, 0x5fbc00f1, 0x6049cc2e, 0x52ac2a3e, 0x24b0bd1f,
- 0x4ec7e59b, 0x0754d33b, 0x38f499db, 0x7ca2b7a7, 0xc37ab2e3, 0x75647b7f,
- 0xc76e14df, 0xdf9ae7f6, 0x6573fb49, 0xf613b87e, 0x9f55d68e, 0x13d886ac,
- 0x444df288, 0xf6b60bfd, 0x556fc0ad, 0x6fec2bdd, 0x7ee15d6f, 0xfd7207e7,
- 0xc7a2eed8, 0xdce3152d, 0x7d26df03, 0x7b6fc649, 0x6a3b461c, 0xac485fa8,
- 0x3f21e435, 0xa1f39b35, 0x35f0207e, 0x355f69af, 0x6e3c1d31, 0xbe0bef6b,
- 0x0749e27f, 0xa13af3df, 0x6cc4edd9, 0xba63cb17, 0x8f29df3c, 0xc26ca3dd,
- 0x2b24bdf9, 0x1c77db8e, 0xd3dd30ca, 0x2f4b4d0b, 0xdabcb3e5, 0x58ab5f99,
- 0x8cd94e30, 0xaf59fb15, 0x73e68c4e, 0xb60d16e9, 0x0dff9041, 0x440e0f70,
- 0xe868e898, 0xbf10b8b6, 0xfd533f65, 0x4353bb61, 0x4c4396fc, 0x16d7d3e5,
- 0x17b5ef98, 0x1f2a6d5d, 0x878cef68, 0x96ff4873, 0xd64b9f06, 0xe7cce8b9,
- 0x4bd686f9, 0x847f3c56, 0x25bc56bf, 0x9a32d3e5, 0x7b40b787, 0xfe1f239f,
- 0xe014ef39, 0x16c5bcaf, 0x54bef38b, 0x9d44873b, 0xb72e5cf9, 0xae2bbf0a,
- 0x5dcaee8b, 0xed4b1bc2, 0x2536b4bf, 0x71dd1d33, 0x14255934, 0x2472192d,
- 0xe57d0837, 0x8246278d, 0x8dd4aaae, 0xbf2a2ec9, 0xc56c0955, 0x71d3ec45,
- 0xa4ae123b, 0xf8b4fff2, 0x75a2c91e, 0xef05b64a, 0xba3e0f9d, 0xbde04d23,
- 0x9f6b1391, 0x3cb8e68f, 0x6d92fe8d, 0xc1d008ae, 0xf59526c6, 0xd4cdd814,
- 0xd93a2eb8, 0x011f14d8, 0x8c7ca6bd, 0x717297e2, 0x0bdf49b4, 0x9aa147c5,
- 0xe69b8efd, 0x2a90f17b, 0xf36a40ef, 0xf592ee5c, 0xaf6cba45, 0xe7d7b3df,
- 0x47d3527b, 0x96be362b, 0x3f7d0b79, 0x2e7f783b, 0xd65784ae, 0x2f79e6ef,
- 0xdadf6cb5, 0x1d7bd297, 0xd7985dbe, 0x45c6b7f2, 0x7ce3495f, 0x87c65db9,
- 0x89f9b5ff, 0x4fc4fcc7, 0xc27a6cef, 0x8541fb0e, 0x1e876035, 0x46e4fe5c,
- 0xae18e23b, 0xbf91b6db, 0xcc56da2f, 0xbefd00f6, 0x7c7aa7da, 0xf28f86b3,
- 0x1706cab1, 0x60ffb3cd, 0x23ca4fc9, 0xa14b1c64, 0xdc35fa3a, 0x4db8b813,
- 0x66bcc3c9, 0xe3b0ed14, 0x1a3bff1e, 0x37dd09df, 0x17a7871d, 0xabbd86f6,
- 0xdf20f145, 0x89993ed3, 0x0f4472cb, 0x39b92fd3, 0x0869719d, 0x0a1fd5eb,
- 0x8e70bed2, 0xd7e88764, 0xcf695587, 0xad123c43, 0xd83db973, 0x85e43a6b,
- 0x0ffbe597, 0x8d0e7455, 0x2ede87ca, 0x169455c4, 0x744d568d, 0xd23e335e,
- 0x0b660fb4, 0xfea2bec3, 0xa67e8966, 0x69498cfc, 0xce37faa6, 0x67e21a18,
- 0x672aefce, 0xe99575fe, 0xdbaa975d, 0xe3856efd, 0xbf9ac67b, 0xd33b7a53,
- 0xf6a60dd9, 0xe99a6255, 0x9b25975d, 0x133c65df, 0x8fa1d995, 0x41f76b95,
- 0xb4dafb66, 0x9dfcadef, 0xafda6226, 0x7f3cd303, 0x8da5e794, 0x1dba08fd,
- 0x9ffe367d, 0x1979ddd6, 0x898f19d1, 0x3bd85bf8, 0xe479667c, 0x42a9eb08,
- 0x669543ae, 0x92caaa8f, 0xff2aa8f6, 0x9be23b11, 0x24d6ff09, 0x93754942,
- 0xaa46f6c2, 0x938a48ef, 0x7df1dbf9, 0x075ef9a7, 0xf284bbfa, 0xf6316a43,
- 0x35796857, 0x42e71bcd, 0xb047ec35, 0x6bfde983, 0x19f4eafd, 0xb43ecf7a,
- 0x3760df1f, 0x6d8ae7ef, 0x23f60e3b, 0x8a2f4cbc, 0x497c43cd, 0x5b54cb65,
- 0x74e5f671, 0x8bfdf3a6, 0x7fb616e5, 0x857e1c75, 0xdca3ace9, 0xddf191ea,
- 0xd51f18ff, 0x0d6f695e, 0x3445bfa5, 0x1799f81f, 0x013c54ed, 0x5e03d645,
- 0x432e81fa, 0x0dd492f0, 0x753c74be, 0x7ca42de2, 0x1c33fe31, 0x004a11f1,
- 0xbc32f27c, 0xfad478e8, 0x2c13e45f, 0x013c1267, 0x3fa42786, 0xff742a31,
- 0x20efc2dd, 0x84506c74, 0x3c6ef94b, 0xed24bb4c, 0xe4d30336, 0x2977dbbc,
- 0xb3ebc81e, 0x7bf9592e, 0xc914bd27, 0x9319f538, 0x93b3fbcc, 0x7ee48a7e,
- 0x81297999, 0xd36ffddb, 0x8fd177d1, 0x8d099fee, 0x5defd6ff, 0xddac1a2d,
- 0x46211a4b, 0xc44ffb7c, 0x4072ebaf, 0xe749e74f, 0xf0d2e379, 0xf6ed4cef,
- 0x951e5e1c, 0x3edaf1ca, 0xf3a88ecd, 0x4ed69f63, 0xca98b71f, 0xefa005dd,
- 0x17b009fe, 0x4b4c6eaf, 0xe317be36, 0x3b63655b, 0x788af26f, 0x5dc38b4e,
- 0x8a473809, 0x4d77c857, 0x27d5df8e, 0xe388fe01, 0x26bd6cab, 0x7fc7d751,
- 0xe4593c3a, 0xe9c85f20, 0xb3617589, 0x3d78768d, 0xed2c1a6d, 0x7e39fa35,
- 0x7a3872ce, 0xaadff636, 0x0508d15d, 0xfdeaba5a, 0xcf3a2e91, 0x8f7c5957,
- 0xef7f660f, 0x85cf3e46, 0xec2e636b, 0x513cba70, 0x0fb0aab1, 0xffcafdce,
- 0x9c31e579, 0xb615befb, 0x9fa3c804, 0x840aa07d, 0xc679d0ce, 0xe1a7c472,
- 0xdd3fae92, 0x10f7c912, 0x1784553f, 0xea25a6fe, 0xe9975cfe, 0x0b3bdd5c,
- 0x41deffe3, 0xb8c08ee3, 0x1889ad81, 0xc4cfe3d7, 0x1915beb8, 0x57d9dd31,
- 0xbd66b4f4, 0xeab6f394, 0xeecd64f6, 0x791ef90c, 0x6270f7c8, 0x1e47be41,
- 0xc8523df2, 0x4dbef8f7, 0x6c0c2ff3, 0x7e83cf68, 0xb22b1fea, 0x75bcf96a,
- 0xbf7e4166, 0x80f08945, 0x78a2dcff, 0xc1bc70fa, 0xc4def966, 0xd57590f2,
- 0x49da6bd3, 0xedd03306, 0x84392e0f, 0x8c6e6e31, 0xc7e53588, 0xea9afa39,
- 0x4c52ba17, 0x0e25d7e5, 0xef5f9536, 0x7fe533ce, 0xa9a57598, 0x18cf64fe,
- 0xa347fe53, 0x9fd537ae, 0xca6a9dea, 0xc7389f4f, 0x51667f54, 0xc6fca9b1,
- 0xe54c4bd9, 0x4ccb7c73, 0x3fe579f9, 0xa9bfd535, 0xdca98576, 0x9c565c2b,
- 0x77a17b77, 0x865fde11, 0x2de945de, 0x8d38656f, 0x9c7a3aeb, 0x7977dba5,
- 0x5072694e, 0x36dea1bf, 0xd7ee25d0, 0x68070e80, 0xc0be67f7, 0x7e1bd2b9,
- 0xf522a0c9, 0x417d23de, 0x42f5a137, 0x1e4747cb, 0x35a6e8b8, 0x7a2a7a2c,
- 0xc4f895a6, 0x140e2be8, 0xf57e51a4, 0xad338553, 0x5f465fc4, 0x54f9e07d,
- 0xb53d37ca, 0x3b0f964a, 0x51e51170, 0xf320df4f, 0x1a8b05d3, 0x7af90c8f,
- 0x31e69f86, 0x6ba907fa, 0xd26ed23d, 0xa769bc6d, 0x80f0883d, 0x01e04d78,
- 0x13e89069, 0x4fa201e9, 0x7d12afa4, 0x710ba596, 0xe913e890, 0xf13fd221,
- 0x7fa4f7fd, 0xfa4c3d22, 0x49b7d227, 0x847a44ff, 0xefa44ff4, 0xf4e6cfd5,
- 0xb71f7a83, 0x397d43fb, 0x6beb47a7, 0xf5c7fbf9, 0xb9fe9c75, 0x5ddfcfde,
- 0x433b7443, 0xba31ed90, 0x7e1aabff, 0x76edd847, 0xfd1acedb, 0x9e578ac2,
- 0xb2bfbaa7, 0x46b456a1, 0x5ab69f62, 0xba394f63, 0xf33d90fc, 0x6538ab5b,
- 0x0f5ebf90, 0xe10d26f7, 0x98bbfbf1, 0x8fdf6b6f, 0xf203e989, 0x520a9d69,
- 0x9f28297d, 0x2aba5f99, 0x0fc7f886, 0x81b5a9be, 0x74b43e5e, 0x0bfb7f7f,
- 0x87da4e8d, 0x8c873378, 0xebbbf2e8, 0xf8ceef7e, 0x1e5f831a, 0x8e3d6cfe,
- 0xf3c7f747, 0x473e219f, 0xf1eb93f7, 0xef6ad741, 0x707ee923, 0xef47fe3d,
- 0x6092f0b7, 0x1acd77be, 0x512dcb2b, 0x38c41156, 0x35cf9c7a, 0xc43c968e,
- 0xe9535c3b, 0x3eb738e4, 0x23ef1df4, 0xde2f3d52, 0x25fcdb99, 0xf2edcfd5,
- 0xe6d1f7bb, 0x8f3ce541, 0xb63e4bc2, 0xc5a35ed7, 0x43bda01d, 0x753bf396,
- 0xfc831188, 0xe1db2941, 0x7da8551e, 0x001c577e, 0xfaca47ea, 0xfe97f441,
- 0xdd178d15, 0xc4068fb5, 0x6e21e4b5, 0x93b5406c, 0x8c36c6e3, 0xb9bdf209,
- 0xded7b1e9, 0x4e22aad3, 0xd8c7e638, 0xfaa74f47, 0xefcf0266, 0xf00f73ee,
- 0x5c5a7e50, 0x53a46f5a, 0xebb5de43, 0x62e67d66, 0xe97c755d, 0x4bd7d778,
- 0x9e21b7c7, 0x5dfcf18a, 0x6eba17eb, 0xafa5eba1, 0x2ea5e153, 0x977f03fc,
- 0xfad74faf, 0xfffb3ec1, 0xb70cfacb, 0xcc7df0b6, 0x07874ab0, 0x7ad77d70,
- 0x262edcdd, 0xf1783ee0, 0xa441f725, 0x5f7cd24b, 0x8a967f80, 0xc05c1331,
- 0x81cd4b91, 0xdeb4279d, 0xef59eff2, 0x077a90e1, 0x7cd60ae2, 0xbd79769d,
- 0x1af521dd, 0x7ed60b62, 0x374ced2d, 0xe43d7ce2, 0xed1fb1b6, 0x1e3d70cd,
- 0xa3ccebc3, 0xf1a71c75, 0x96a243a3, 0xd7120fcf, 0xf1df58fc, 0xcb8f52da,
- 0xee72cc5e, 0x6e59a778, 0x514df09c, 0xd09dc623, 0xd68e442b, 0x6837e1fc,
- 0x9a275efd, 0x7bd0dfb8, 0xf26837f2, 0xf93de869, 0xf26886e7, 0x01488a65,
- 0x3c2f1a9f, 0xbded2e12, 0xd92ef183, 0x2f46926f, 0x8c556e69, 0x9f083d06,
- 0x55f1cc15, 0x8b9077bc, 0xbf9cfd71, 0xfd38045e, 0x3f7208a1, 0x22918993,
- 0x6c2123ff, 0x79039df2, 0xf55ab33f, 0x2ce427fd, 0xc2e65efd, 0xd8abdf70,
- 0x4e44af77, 0x28f78f99, 0x4b8c15c6, 0xe303bb47, 0x1c9f2cdd, 0xbcb1a470,
- 0x8b657d84, 0x6f7fdaeb, 0x6e92f9d0, 0x9106f795, 0x3a60dee2, 0xe9d7966d,
- 0x86fe41fc, 0xed0215ac, 0x71cdb826, 0x1ffb7a38, 0x6b0ac6ba, 0xfdfccf41,
- 0xfa7bb987, 0x66f3aec3, 0xb0f1a0ec, 0x7b19bf83, 0xf7cc78c5, 0x163ed8cd,
- 0x39d98699, 0xbd3179cd, 0xa74e793b, 0x26f1aee7, 0xcf7c6b08, 0x1af1d678,
- 0xcf1d4f8a, 0x2f5e02ff, 0x2fd78774, 0x37290b06, 0xa23e4a47, 0xac2ab7e3,
- 0x1f671ef3, 0xa5445c63, 0x33e9e243, 0xb87b8c80, 0x3cf15775, 0xfd17a93e,
- 0x7545ef81, 0xd43cb8a3, 0xc736250e, 0xc77f5e70, 0xef83ccec, 0x7c122746,
- 0xea7c39d7, 0xd9cbc250, 0x492660fc, 0x0d93e230, 0xfaef7c0d, 0x07aab3dc,
- 0xeaa57ff2, 0x4f01eb5e, 0x3f655379, 0x95e6f8a0, 0xc509f864, 0xa3e3eee6,
- 0xaf121d2b, 0x32b3feba, 0xa7f788ad, 0xca241570, 0x3de4d5f7, 0xe81e5d72,
- 0x8be3261f, 0x3dccfbf5, 0x232307c9, 0x1feb1f24, 0xbeaef926, 0xf38ed49e,
- 0x48cfd449, 0xf74953e2, 0xb03eb045, 0x1a4de5db, 0x78ca7f0a, 0x75a79261,
- 0x97a3bfbd, 0x5af03f7c, 0x68d0f991, 0x643f8fca, 0xef2a0113, 0xf14c2f18,
- 0x946f8564, 0xfa16bbf2, 0x44b098fd, 0xfc0cafd2, 0x611ddc20, 0x32346f7a,
- 0x8f94ce2b, 0xd533f4f2, 0x6a95198f, 0x0ef58f2a, 0x4fc79531, 0x7be537cc,
- 0xaa655d17, 0x58f667df, 0xefafbe53, 0xa4fd5306, 0xbca669f2, 0xe49297ce,
- 0x76a03127, 0xc0fda9ae, 0xfd5312ba, 0xf9857f14, 0xf7bf54fd, 0x9e025648,
- 0x697f9477, 0xbc87966b, 0x96116aaf, 0x90ef5d91, 0xde5a3afc, 0x5ce89907,
- 0x6491efc4, 0x0cccfd34, 0x8a8dfa8f, 0x46292673, 0xae24f7e1, 0x60f99b73,
- 0x3f39a261, 0x2af795de, 0x2b9c6e96, 0xa828fe34, 0x6a929e80, 0xf3efa6ad,
- 0x347c6a86, 0x9eb2e457, 0xefeb5dfe, 0xff5a621b, 0x4e5d7c50, 0x05e7cf0f,
- 0x6f9ed2dd, 0xf9ec179c, 0x9ec0bc46, 0x9ec3cc6f, 0x7b0fac6f, 0xf61cb1be,
- 0xc179637c, 0x8c1d3321, 0x83a66238, 0xe99a8e2b, 0xd0cfa740, 0xd5b2baf5,
- 0xa7c21f4c, 0xb07f94f8, 0x6a7f575e, 0xf5d09fa6, 0xd78b0921, 0x1153826f,
- 0xfbfca48f, 0x642eb5eb, 0x87d73abd, 0xf6f90df0, 0xbe50e0da, 0x48785b27,
- 0xe4b77815, 0xd79e6d51, 0x27e5ad0d, 0x7d5bb6c3, 0xae7de6bf, 0x5f4355d1,
- 0x871d5749, 0x1f070f9e, 0xffa4347d, 0x02f9fbd7, 0xfe3b3fa8, 0xf41db262,
- 0x45df2ed1, 0xee1f036b, 0x49b715dd, 0x77bcba7a, 0xe39533f2, 0x9a598e18,
- 0x82ebf014, 0xf036df18, 0x6bb39bcb, 0x1367f815, 0x458ed145, 0x8ff9cb88,
- 0x17e464b0, 0x77f7940c, 0xdf2b7645, 0xe2f9d07f, 0x17192482, 0xf35432d8,
- 0xdc647af3, 0xa543f3ce, 0xe3ca24dd, 0xe2e338e2, 0x83bf796c, 0x05e499d4,
- 0xe1c7c039, 0x47c041f0, 0x69df85b3, 0x39b9b56c, 0x86ffc46e, 0x83f7e02a,
- 0x72f90b1c, 0x35df2680, 0x0070e47c, 0x85eb41fe, 0x1c1d9ce9, 0x5be29870,
- 0x99736e87, 0x892d39f2, 0x76c3faa6, 0x79e54dbb, 0x79532cc1, 0x298f21c1,
- 0x28c8e23f, 0x8e2bfd53, 0x2bf94d7a, 0xea9a275b, 0x9169fd5f, 0xda249f29,
- 0x077e061f, 0x3e8f522a, 0xe2553433, 0x7e382dc9, 0xb19dc16f, 0xa6a7def2,
- 0xba72eb5f, 0xd3ecf71e, 0xde5439e8, 0x71f7681f, 0x5f43751c, 0x187be1e1,
- 0x129f4d0e, 0xa7c03d66, 0xde772dc5, 0xe39bf0a3, 0xe578f596, 0xd3417d4e,
- 0xdd39740f, 0x35ecaf10, 0x082f2bc6, 0xe03dfeeb, 0x3dd6d2ff, 0x7681fe14,
- 0x9f86df39, 0x88def9da, 0x3c28570e, 0xda38b533, 0xefee8e2d, 0x25b2d8f5,
- 0x1465259d, 0xfef41dfd, 0xcad3cd98, 0x365fdd6f, 0x4fd5a79e, 0x0bf0d5f4,
- 0xfba567bb, 0x305bc7bb, 0xbe67ce4c, 0xd4f372c5, 0x32cf8e6c, 0x3bdf83bd,
- 0x51fdea5b, 0xf3b74ab9, 0xe323105b, 0xdd8c44a7, 0x79edfa0d, 0x44cf893c,
- 0xfbe468bb, 0xff9c5a47, 0xee5b6b4d, 0xf3454419, 0x7bda4ded, 0xe81b0160,
- 0x9258d261, 0xd884f2c3, 0xb35765b6, 0xc7a2e493, 0x3f6cacea, 0x35ddbfe9,
- 0xceb8248b, 0x49031bfb, 0x407d01ef, 0xb4be81b6, 0x71e54721, 0x1b9ec1ae,
- 0x4df6fd81, 0xfb3d9c67, 0xced08405, 0x754fa90b, 0x874c6f43, 0xaffe3cfa,
- 0xf143ede3, 0x42adeba4, 0xd74c338b, 0xd7f1d2e0, 0xf0d07769, 0x707fdfa7,
- 0x6d15b32f, 0x8a3df272, 0xd2db8889, 0x4725afd7, 0x86ad65d2, 0x3f03d40f,
- 0xa15ea9ea, 0xfb031d9a, 0xc7708772, 0x43a1bab8, 0xc2bffd3d, 0x9eff8e8b,
- 0xc4f557ee, 0xc2f9421f, 0xeab7dd77, 0xd9ff4e89, 0x3e06577b, 0xb468e321,
- 0x5ba40975, 0x677d3fd8, 0x6f3f7994, 0x8d7696cc, 0xa2beda71, 0x6799ddf3,
- 0xf60217e6, 0xaa5586f1, 0x39e42fc6, 0xc4529c5e, 0x3a8b11ef, 0xe533cb17,
- 0xcfd62f1a, 0xc80f85d7, 0xf5aee0f7, 0x455c2516, 0x9b6692f9, 0x15a048d8,
- 0xf38fbbfb, 0x1b93bf66, 0x449efe71, 0x3726cdc0, 0x49b4b71a, 0xb94fec09,
- 0xc5ecbdfc, 0x5c7ef94e, 0x8bd9bbe8, 0x2f17fd35, 0x86df602a, 0xcfee65fa,
- 0x8f6bced6, 0xe12b7cf0, 0x0ba5bd67, 0x02de8d7e, 0xe8311df2, 0xf3b4aac3,
- 0x8e969c70, 0x24fc3737, 0xc2795df1, 0xce16446f, 0xb76b46f3, 0xf89d7471,
- 0x9d2afdd5, 0x1cc3c27e, 0x171a1faf, 0x4affd670, 0x1a7e7774, 0xd3d37fdd,
- 0xdff4e83e, 0xa85f877c, 0x1e8969c3, 0xff043e05, 0x57e8dbbf, 0x8248f3f9,
- 0x3127fd90, 0x6ab48ff0, 0xb98d89fd, 0xf44fdddd, 0xf1c5d8ad, 0xbe2cab10,
- 0xf25c40ff, 0xef1fea19, 0x3ce5deb0, 0xf8fb8090, 0xd3bb3493, 0xe4d6f3e5,
- 0x7ef2d1b0, 0xe55f8740, 0x2898eef5, 0x1f1373ef, 0xba77d815, 0x08aa7f1f,
- 0xfbaa42f6, 0x466b7c49, 0x3f75fe31, 0x14707149, 0x61b339c3, 0x484f0db1,
- 0x7b7c3eb6, 0xcbbb8461, 0x403ad27f, 0xe4f4e7c6, 0xc97e9947, 0xb8cdfdc3,
- 0x73f71574, 0xca453b2c, 0x2cf78d6b, 0xd90d9d03, 0x67986c26, 0xdffbadab,
- 0x23929819, 0xf852d1f7, 0xe21b7bd2, 0xac28567e, 0x84572c07, 0x7cc4071e,
- 0x6c5fcf5e, 0x3285f2d2, 0x992acb7f, 0xc5ded56f, 0x3bd9aada, 0x98a44f30,
- 0xedf0f40f, 0xf3043d9a, 0xe0798a40, 0xf21af83b, 0x83c86be0, 0xbe0f21af,
- 0x0d7c1486, 0x51444bdf, 0xfd2a9e72, 0xfb0de33d, 0xf19efe03, 0xfe09b906,
- 0xfe1e631e, 0xf87d631e, 0xf0e58c7b, 0xe1cb18f7, 0xe1e631ef, 0x87d631ef,
- 0x8798c7bf, 0x1f58c7bf, 0x1e631efe, 0x7d631efe, 0xe58c7bf8, 0xcb18f7f0,
- 0xe631efe1, 0xd631efe1, 0x58c7bf87, 0x629d737e, 0xacdd07f2, 0xba503bbd,
- 0xa3e98e3e, 0x2928b539, 0x3ff7d687, 0xc7e7ff23, 0xf3ac54b6, 0x6efc25de,
- 0x47845560, 0x44d373ae, 0x2116eeb9, 0x0e7db9d7, 0x76edf3af, 0xf1942f99,
- 0x03f4a1c2, 0x74f8cabf, 0x0a4157e9, 0xf8520abf, 0xafc29055, 0xfd2ade32,
- 0x57e1482a, 0x55f877c1, 0x82afc290, 0xa4157e14, 0x8520abf0, 0xfc29055f,
- 0xbf07682a, 0x55f8520a, 0x157e1df0, 0xe0abf0a4, 0x038231fb, 0x2e1d15fe,
- 0x26e9f9c8, 0xd0e8943d, 0x4cba87a4, 0xc6f9c879, 0x8df390fa, 0x8df390e5,
- 0x8df390e5, 0xc6f9c879, 0x8df390fa, 0x88f11bf9, 0xef296f71, 0xde41db1b,
- 0x9a73e637, 0x86c1affc, 0xf9c37935, 0x46b69157, 0x2e298f29, 0x9e72eb92,
- 0x58ff059a, 0x1c92b86b, 0x763921eb, 0x8d676fc5, 0x89f892bf, 0x2b976f16,
- 0x6f582dda, 0xbad37bf6, 0xe38282f9, 0x3bfe7383, 0x7f75cb91, 0xbad1ff2b,
- 0xac14ede7, 0x90cb6c37, 0x3dede970, 0xd522a5c2, 0xbbe577eb, 0xbe3a17af,
- 0xa5f98f5e, 0x28520e01, 0x910710f3, 0x1f33bb77, 0x2d5bedf1, 0x5d0b8c8a,
- 0x4372e329, 0xe349aae9, 0x3b2d5b4b, 0xbb50440e, 0x83c562f6, 0x5699077b,
- 0x0f96c871, 0x43e6d53c, 0x89cba89e, 0x6b83e2d5, 0x903c42af, 0x7f6eb70e,
- 0xf7c13e24, 0x0bb746dd, 0x738d197b, 0x8ec217cd, 0x64985bdf, 0xda04f297,
- 0xea1cdf41, 0x0c9bbc57, 0x4732bdf4, 0xff3e7b9e, 0xe8caabb2, 0xb5edd0fb,
- 0xdd1ee157, 0xeed908a4, 0x33478f37, 0x2a34a71e, 0xc9fef09b, 0x8bc2ede8,
- 0xd4bfb1fb, 0xddba1ee0, 0x71e32f65, 0x4eff7c5d, 0x4378b7ef, 0x2c17df32,
- 0x13e3ad16, 0xf0a127d9, 0xde3ae6fb, 0x62af7e68, 0x0fe2c47e, 0x2ffc8ec1,
- 0x7121c3df, 0xc3dcfbf1, 0x6c7866b9, 0xc4dbe221, 0xe40ef95e, 0xabc5e1e4,
- 0xbe5c137a, 0xf2077c80, 0x5f6a2f9a, 0xf966fce3, 0xcf93240e, 0xcf8f8648,
- 0x857e41c3, 0xe298ffdf, 0xe5e968df, 0x15e0bdc6, 0xdfd404b6, 0x0b503c2e,
- 0xaf790906, 0xb6579f55, 0x57096238, 0x95e22f40, 0x11fd0378, 0x7a0198e7,
- 0xf8d8f3c9, 0x56a9907d, 0x46fc0d97, 0x5d8a7397, 0x7542ec72, 0xf7df0c74,
- 0x2e13910b, 0xb8e6f636, 0x8e3d7f8d, 0x93ef83a4, 0xce15df2f, 0xf88f8572,
- 0xb9e6f807, 0x5977193c, 0x91c3ecb9, 0x38aed496, 0x8129d392, 0xf3df78ad,
- 0xe88eea74, 0x11cb0a51, 0xdb5fc087, 0x7be79f1a, 0x5eabc582, 0x1710fbe3,
- 0x96881f1b, 0x7fa4aaf7, 0x9bc34ca5, 0xa85a6f6e, 0x16994fad, 0x5ebc743f,
- 0xe74bcfbe, 0x71f7bf30, 0x72c6d1b1, 0x28bca846, 0x880feb84, 0xb46f2b73,
- 0xc5d3ddf1, 0x27578b6b, 0x777eee8a, 0xcfe32bc5, 0x349771b5, 0xa84e38da,
- 0x2b477b5c, 0x965877f4, 0xd2e8726a, 0x27efe66d, 0x4fe44272, 0xad44fdfd,
- 0xaf5bf14e, 0xa83964cc, 0xee71c6d6, 0xb94857f3, 0x0110ec48, 0xbf9867dc,
- 0xef059c62, 0xe5dfcc58, 0xd0dd28f5, 0x7c9a3bd1, 0x12830934, 0x8a5ea7de,
- 0xed32be60, 0xcfce3f52, 0xe9c894ba, 0xe4b2978d, 0xd11dac77, 0xbca16b4b,
- 0x26beff5f, 0x1c44cd17, 0xb2e40165, 0x1dd74c3e, 0x2218d744, 0x4357e357,
- 0x302bcabc, 0xf9b24fc3, 0x734e2156, 0xf7c146d2, 0x7e432691, 0x90d982a2,
- 0x2fb00aa7, 0x3ef90a52, 0xef8544c6, 0xbe1e4cb7, 0xb407db4c, 0x11f3042f,
- 0x37c3f77e, 0xf1006a7e, 0x3b7db337, 0x7d77582c, 0x6dfcf83f, 0x64e60efc,
- 0x7bc762bf, 0xcf4d3e81, 0x743de9d6, 0xd4882c5f, 0x694e63ec, 0x8fb4eaff,
- 0x9c7e5801, 0xc446f227, 0x2d802eb3, 0xb0b69fb3, 0x6ca8aa84, 0x1b9c9e59,
- 0x94236379, 0x6ed37fac, 0x9162df32, 0xfe489ff7, 0x717578e3, 0xe50fb0a4,
- 0xf92ad78b, 0xe1d79788, 0xd8d87afa, 0x777ac349, 0xe74941d1, 0x03eeccfe,
- 0x5df960bd, 0x4cff2619, 0xf84a5a68, 0x105a3ec6, 0xfc63fad3, 0x5c84d0d2,
- 0x889f1de1, 0xf9f5c877, 0x02e2208a, 0xdbf96ae7, 0x8ff2bd9e, 0x278c9c6b,
- 0xedcd8fce, 0x3fe22377, 0x38fe65fe, 0x7f1ab15f, 0xf14daa37, 0x3de57379,
- 0xdf5809c8, 0x7e76ecc8, 0xa66660c7, 0x212f9e4b, 0x72db9676, 0x845df2dd,
- 0x694b7b10, 0x846f3cb6, 0x8f3c9dd5, 0xb66e3afd, 0x3ef3ea57, 0x33df336e,
- 0x5cead3d5, 0xbff83769, 0xa0f127ba, 0x7ffbde45, 0xf1d812c4, 0xa06bd122,
- 0xe6016fb7, 0xbde208fb, 0xcf1f7e19, 0xa3477f4f, 0xef694f93, 0x74f4e865,
- 0xdf22eeac, 0xda712897, 0x9e81aadd, 0x7c28d6ca, 0x4ea4b11f, 0xadf627de,
- 0xfcbde451, 0x8f57ec1e, 0xdf9af9cf, 0x17fc7a51, 0xc350b211, 0x91fb7cef,
- 0x5d291cd7, 0xdd53fdf8, 0x7f926caf, 0x6f103306, 0x9c36b73f, 0x7afe41df,
- 0x018fd158, 0x87b6647f, 0xf11269d7, 0x1a9fd434, 0xbe29fbe3, 0x07238897,
- 0xf05c6f61, 0x7df8b7f3, 0x29bd9ae1, 0xf161eefc, 0x78d5bcee, 0x61ebe547,
- 0x89723bbe, 0x2e9d8b7e, 0xea90e43b, 0x973e58c6, 0xeed1f417, 0xf6768ba9,
- 0xf3ebe9e7, 0x0794ae60, 0x9c723c8a, 0x453e9a0b, 0x354db308, 0x7fe793d5,
- 0xedd43ee8, 0x95f6a1a2, 0xbe2af7d0, 0x7b029ecb, 0x5760dd89, 0xb631edd5,
- 0x7073e3ac, 0x77b7cf9e, 0xaf8dbbff, 0x4d4776eb, 0xa9d85d9f, 0xe84f66cf,
- 0x9d7fb903, 0xbd1d82e2, 0x11bee9cc, 0x8765f5f1, 0x14f0886c, 0xf2dce293,
- 0xe4bb92dd, 0xb72525bb, 0x9b3f31e6, 0xc7c9358f, 0xbc5187bd, 0x9402cb8f,
- 0xdfbcf7c6, 0x657bade7, 0x53d01ec0, 0xe0f7cbd0, 0x7b5e5ccb, 0x2a2e419c,
- 0xef4c526d, 0x17f9e818, 0x721da573, 0xc019a93e, 0xa6b74ddf, 0xd086f1d8,
- 0x108f127c, 0x46baf837, 0xaa3b7a27, 0x932571c7, 0xf941c552, 0x9dc114ae,
- 0xfe33c722, 0x9349514e, 0xaa063df9, 0xfedd72cf, 0xafee28dc, 0x4ef345d8,
- 0x3862ea41, 0xa78c0f09, 0x3fa87bf6, 0xebc38f37, 0xd80c1a51, 0x8f983760,
- 0xcfca1678, 0x186c0575, 0xbe51a4a7, 0x2b5be28f, 0x89adf1c7, 0x2e40e7b5,
- 0x03ecbab0, 0xa360f28c, 0xbe78cf7c, 0x0411fbf6, 0x65cbcb2f, 0xf3dc2784,
- 0x867defd2, 0x8358abe2, 0xd629acbf, 0xad365f2c, 0xe67d61b3, 0xc35ef0f4,
- 0x971d1a97, 0xfbe18e34, 0x2f5665f5, 0x69f097df, 0xb2ebfef8, 0x27e1bbf0,
- 0x90fcd399, 0x8d79052d, 0x3c097d2f, 0x829e06f7, 0xd23efc19, 0x678e70b2,
- 0xe26ae39e, 0xfbe276f9, 0xe40fc201, 0xe3115715, 0x8fc4e89b, 0x66b2c038,
- 0xc176faf3, 0x65df2513, 0xfde62e6f, 0xb3eac8b7, 0xac708cbb, 0xfb819fdf,
- 0xdf68735b, 0xe127fde3, 0xcc7df1f2, 0xc8dc0f53, 0x3806fbbf, 0x8f28e781,
- 0x3bde027b, 0xba61ba22, 0x4167e9d6, 0xfacfdc81, 0xacc35178, 0xec3f0ed2,
- 0xf7a9f6bb, 0x06f3e420, 0xffd86f5a, 0x76a7da7b, 0x71a4005c, 0xddf265ed,
- 0xab7dd0ba, 0x9f7d57ef, 0xdf56fbea, 0x8ad98fcf, 0x174a8982, 0xbdf3a1df,
- 0xf06eb9f6, 0x77834934, 0x84aeb6ae, 0xc18557d7, 0x986237ae, 0x53f3dfdc,
- 0xfd1ffbcd, 0xbd54dfa1, 0x03306c7c, 0xfaf53df7, 0xe3f3b8fa, 0x03ec3b64,
- 0x30ea5bd0, 0xe5fd674b, 0xe262df5c, 0xfc9da51f, 0x04aafb63, 0x0a1d8ff0,
- 0xdf96e1fb, 0xe5bee523, 0xe17bc8cf, 0xf8bf9667, 0x77aa2cf6, 0x0b8dc1fa,
- 0xca2ff78c, 0x2c5f9282, 0xfc0b7924, 0x0f269163, 0xe5f4cc6c, 0xe7ec330d,
- 0xc99ffbb2, 0xdb98fec4, 0x6f0a7792, 0xf9bcd1a8, 0x3f3fa3bd, 0x5787d2f3,
- 0x5dcebbb9, 0x6b251e7d, 0x3b15b5de, 0xf493788d, 0x0756777e, 0x38a55b9f,
- 0x6953e8b7, 0x61f33163, 0x8f7a4891, 0xa1eeb5d2, 0xa8dc50f4, 0x5a579cb0,
- 0xfea03237, 0xd2ebf22f, 0x8df953b5, 0xf4bd7d28, 0x73f45f77, 0xa67f8757,
- 0x35734eb6, 0x4c3d9e7a, 0xe5b9c3ee, 0xbc45f629, 0xf8ec53ff, 0x5a39cdbd,
- 0xf3329cf9, 0x72f5cef7, 0xd5fbf275, 0x9fb827d8, 0x58eaf584, 0xcbf6936b,
- 0x57ad97ed, 0x1d02e432, 0x9d9ac58e, 0x6f66a172, 0xcbc9a45c, 0x8d8b5eb4,
- 0x71f8b5eb, 0xcfa55eb9, 0xbc17f5be, 0xd3f34653, 0xef93a3de, 0xecb4940a,
- 0xb39b75e0, 0x852d9d66, 0x5864fdea, 0xa8fe298a, 0x05cf36b4, 0x35dcfd3b,
- 0x07e06d1b, 0xf126193f, 0xf3f74a16, 0x1d62f8b5, 0x148f38af, 0xaf473f83,
- 0x83b83e0f, 0x5975b9c6, 0x77f1b478, 0x3d1a02ed, 0xc6c6d697, 0xdad2bc61,
- 0x7fa17be2, 0xe840e7e9, 0x2e113bfe, 0xf50945f7, 0x6279fd87, 0x55ef878c,
- 0x377ed7cf, 0x43feb42f, 0xdafddd1a, 0x4cbfdf26, 0x92796c8a, 0x226a3be3,
- 0xe913e03c, 0x8c01ade9, 0xdc067a0b, 0x2f7c8b76, 0xf5b2bd33, 0xa241c073,
- 0x20f5c73c, 0x105b7bc5, 0xbf2813ed, 0x79ef22c9, 0xdd32aaa5, 0xa607e1a7,
- 0x5e8b9437, 0x5f1efcad, 0x2151bbe7, 0x9b176af4, 0x1fdde0d7, 0xefc12f7b,
- 0xa9f4e9a6, 0xa7d3a3f7, 0xcd3dbf4e, 0x9cf7d76f, 0xcd1489df, 0x49e592ce,
- 0x0bb8d076, 0xbfc41bee, 0xf35df16b, 0x35ef6bb4, 0x4c37ce76, 0x65c7defe,
- 0xfa974df3, 0x6df3cf52, 0x66e84c2e, 0xd4f3a1be, 0x431e89f7, 0x694fe9df,
- 0x1394fe92, 0xd4639d0a, 0x70b2c4ee, 0xe7d3ab8e, 0xbff5dba5, 0x8f87bdef,
- 0xf669c586, 0xc828d6aa, 0xdfb5f397, 0x99411151, 0x86a9f7c7, 0xaff9faef,
- 0xf3a75fbf, 0xdab593e9, 0xef5a28f9, 0x75167ec1, 0xf50f7c69, 0x2889d358,
- 0x627313bc, 0x6f4f848c, 0xde4dab77, 0x76511673, 0xbbcfde37, 0xfe3cd6e9,
- 0x8d8594bd, 0xbd9f587d, 0xf98d2ea9, 0x587e4dc2, 0x1ea74517, 0x83e348b0,
- 0xaf16b791, 0xd7f502be, 0xc2eff0a7, 0x4e7a742d, 0x43f6e7ad, 0x2313903d,
- 0x53daa79b, 0xfa961e59, 0xbb17ee82, 0x7c451155, 0x127c0d4f, 0x3fb2cbfb,
- 0xe2cfe71d, 0x983f52f5, 0xe06b1164, 0x50d81d3f, 0xf82fa134, 0xfc8ac3c4,
- 0xe60d9a3d, 0x0e86bcf7, 0x7c02fa2a, 0xbc5df426, 0x5e2d6d5b, 0xe482a7e8,
- 0x16d1d80e, 0x9e588b3a, 0x93e345bf, 0xf8db9ac7, 0xaf1d7ebd, 0x78bfe08f,
- 0x7ec42aa7, 0x1a276a14, 0xff07d9a8, 0x7b8faf1f, 0x0080003d, 0x00000000,
- 0x00088b1f, 0x00000000, 0x7cb5ff00, 0x65545c0b, 0xce7bf8da, 0xc0cc2b99,
- 0x1245c880, 0x85848b87, 0xd780c034, 0x508151da, 0xb9bba0bb, 0x658e21ba,
- 0x500665ca, 0xd7775ddb, 0xa6a18cfe, 0x45fa7d66, 0x80ed65a6, 0x76c36a97,
- 0xa8283448, 0x59990bc9, 0x6a37627f, 0x5b63b92f, 0xba402de6, 0x6dbfedfc,
- 0xbcf3cf7d, 0x511730e7, 0x6fbefddb, 0x797bf9fc, 0x9f5ef3df, 0xcfbcf3fb,
- 0x8c346339, 0x63181b75, 0x418e8b2a, 0x89486839, 0x8d8c9964, 0x615f6909,
- 0xf6c3894c, 0xc645db25, 0x7cfb4046, 0x1962c893, 0xfa31d72b, 0x1fbf8f7d,
- 0x3c1f7631, 0x42f3c337, 0x07d634a9, 0xcc37d7fd, 0xd6c972a0, 0xf1ae6dc2,
- 0x2509258c, 0x606393b1, 0xb66ae3c0, 0xce258a07, 0x2b307719, 0x8da4d3cc,
- 0x73c325d2, 0xc7292bb5, 0x496f9fe0, 0x0c4943e3, 0xd4699dc6, 0x7b4377cf,
- 0x414e6981, 0xba5f8c14, 0x325b2a33, 0x6f5dfbfb, 0xc91b1811, 0x4673a558,
- 0xcc614b1c, 0x67e1ddf1, 0x1fb0a94c, 0xf304d398, 0x7709e57f, 0xa38ba0bb,
- 0x82492dae, 0xb3aa3c23, 0x7fa058a7, 0x6f31d895, 0x4e73cc12, 0xa04def70,
- 0x5338e6fe, 0xe5a1fac0, 0xccc63ae9, 0xff398ce9, 0xcf3487cf, 0x3b89e2e7,
- 0x8778c016, 0xce047f73, 0x1ff8f553, 0x6c3201f2, 0xb2cf689d, 0x8dbce1e4,
- 0x1c124d7b, 0x56637b74, 0xbee39c09, 0xda46c7c7, 0xf79f2f33, 0xa8b668b6,
- 0xdbcbda04, 0x6957c118, 0xd48ee85f, 0x5eeddc20, 0x696131a6, 0x28689a62,
- 0x956c48cf, 0x52dbca07, 0x06b9a2d8, 0xe10dbb7f, 0x899eeb00, 0x025492dc,
- 0x9f7b15ed, 0x79433248, 0xa5ebc8d6, 0x9c7a7f7b, 0xddff4045, 0xd5e20d5a,
- 0x0b1a62ae, 0x25d7bb8c, 0xb250dcd8, 0x12c668f2, 0x7d6ea310, 0x59b19199,
- 0xaf9a7096, 0x630e7b62, 0xc17dfeb9, 0xab3f6a73, 0x8fb8c562, 0xd903f531,
- 0x8bfca1cb, 0xe21f7bca, 0x7ab52ff3, 0xf1192b8b, 0xfcbc2662, 0x84548b65,
- 0x05fbaeed, 0xfac05636, 0xac1a637e, 0x6ac9165f, 0xf4a17c71, 0xcf049b57,
- 0xb2101c57, 0x787b30b5, 0x1ee6b766, 0xd1169103, 0xd389b559, 0x75768ad9,
- 0x7fe02251, 0x2d408b45, 0x3357950e, 0x2f2abe1c, 0x80e6664d, 0xb6b656fd,
- 0x8eb0cc68, 0x09ce19a3, 0x539e1dfd, 0x5e78a59a, 0x7cb185b6, 0x89fe27c0,
- 0xa53e6bf8, 0x3f0037b9, 0x2e1cadd5, 0xbede56ce, 0x3b900338, 0x1362b699,
- 0x26dea0d2, 0x6b3ebd50, 0xaa35fcc2, 0xfcfe7ac0, 0x9a586935, 0x354c4e08,
- 0xf0025490, 0xa3d194dc, 0xd73bfc41, 0x5d42f3ca, 0x0d5eb01d, 0xde48e512,
- 0xf1c06a9e, 0x3caf1a66, 0xd146b677, 0x6c33af78, 0x3609bb03, 0x61506d51,
- 0x4434ef59, 0x56b3b960, 0x715950cc, 0x09166173, 0x1611dfe0, 0x6122c591,
- 0x3d5eaaca, 0x3b501240, 0xf6845870, 0x83fb48dc, 0x0c719f48, 0x33e802b8,
- 0x06057991, 0xf9dfdff4, 0x7fce2e59, 0x17df18cb, 0x5eaeb60c, 0x017e7d33,
- 0x8b26c3d0, 0x5f4c8e7c, 0xc8f1d22e, 0xb0af4043, 0x6cd5a7bf, 0xcf073e83,
- 0x42e6c257, 0x08c2cc3b, 0xb984dfcf, 0xafdfc0f7, 0xce226f31, 0x54de74cf,
- 0xcc9af71c, 0xc35a25a7, 0xf5f60106, 0x63fb149b, 0x053b8fb8, 0x116cf8f5,
- 0xc58d2071, 0xfe6afd7e, 0xc2796d9c, 0x4ffc03a6, 0xa367e8e7, 0x4062e645,
- 0xf1519aa2, 0xc163a406, 0x60ab6366, 0x0f3307fd, 0x2e80cbdd, 0x31d01e1e,
- 0x5eaf9c2d, 0x7d3dcfcf, 0x0094ec20, 0x2a8f46fd, 0xf4165916, 0x2958ab37,
- 0x29943ff4, 0x9fd8557a, 0x9fd8dce9, 0xbe6d0ae9, 0x8196590c, 0x7a88d0fc,
- 0x78eff51b, 0xca011bf3, 0xe1e2e944, 0xe2573848, 0x3d4b052f, 0x3c1b29f4,
- 0x85fff4fd, 0x5352f4b2, 0xfca1efcb, 0x19bda475, 0xb0727751, 0x501d94f8,
- 0xa3c9b0f6, 0xf9f264b3, 0xf1dff702, 0xa2226fab, 0xfabeff45, 0x7bef4e07,
- 0xcea58ad9, 0xe9b8c022, 0x9b57921d, 0xfa7ef975, 0xa9e361e3, 0x39e18fd4,
- 0x5ba20dfb, 0xe1ffb010, 0xd37f710f, 0x14af0675, 0x17d4e381, 0x38ff3a7c,
- 0x751d1e66, 0x284646fa, 0xb1913ef8, 0x8c3cdc58, 0x7068b81f, 0x6fb9c137,
- 0xa14ff991, 0x488b1eaf, 0xf191e9f8, 0xe991c0a4, 0x7e9122b2, 0x5e8ad5eb,
- 0x4cb385f0, 0xe8d67f3f, 0x5e0cff38, 0xff386d12, 0xcdd6b960, 0x8ec18a60,
- 0x5727d254, 0x007fa792, 0xd740ca79, 0xfb6a97bc, 0xf90fc233, 0x78fc074a,
- 0xc02f0c97, 0x25f9c33f, 0x64bbfe79, 0x1065ddb8, 0x127e9c39, 0x6e992702,
- 0xf650ba14, 0x5863982f, 0x9f1fb469, 0x47ddd7ec, 0x8f099323, 0xe383ffe3,
- 0xdfc213ef, 0x01d62737, 0xff51b11b, 0xfc784598, 0x579fc05f, 0xf80bfeb4,
- 0x9fc50eeb, 0xe23d7f57, 0xd2d171ef, 0x0880fc84, 0x26d2a1c8, 0x0658f9c2,
- 0x932ffe23, 0xe09b2cc2, 0xffe4767c, 0x8fef889b, 0xfc2bdf22, 0x37d8a63e,
- 0x49e4f51e, 0x7dc19ec6, 0xb50f44f9, 0x10a766a7, 0xbac75f9f, 0xf01db013,
- 0xf117379c, 0xe876d82e, 0xfb7d2c24, 0x5df5865e, 0x1ecb0615, 0x5bbf6f38,
- 0xfe61a974, 0x8ef72886, 0xc36eb0a5, 0x1716995d, 0xd59633b6, 0x3ca07286,
- 0xbe7a82cc, 0x85cb8a21, 0xa4e90586, 0x277e0f87, 0x73c2ad25, 0x34b3082c,
- 0x6c86ff41, 0xa01323df, 0x6cd630de, 0x57d74171, 0x1dbe9605, 0xd1d1cfc7,
- 0x38730d3a, 0x323c36dd, 0x057a8dda, 0x7af3cff4, 0x1e593fa8, 0x0d9cf0c6,
- 0x6884b68d, 0x2297cba0, 0x61b3a3ec, 0x4e24a3ff, 0xd0c90dd7, 0xa136e50e,
- 0x387dc164, 0x6fbe78df, 0x17b082df, 0xfa2cc2f7, 0xd0591034, 0xb195727e,
- 0x42a5e509, 0x73a57797, 0x75c63779, 0xc9c2076a, 0xd4659d35, 0x937ffcc2,
- 0xbb814be9, 0x556c6360, 0x0afe1fb4, 0x70c8c59d, 0x7a735617, 0xe5974d73,
- 0xd7733562, 0xe65f080b, 0x96f8070b, 0x42414169, 0xadd93469, 0xe5faefb8,
- 0xf7091780, 0x527fe1cf, 0x619ee564, 0x2847e7f8, 0x4c88f32c, 0x328fe404,
- 0x0ca3f9c6, 0x6fe908e9, 0x0051d015, 0x75df31fd, 0x65c3a751, 0x6bf1823a,
- 0x70d3258d, 0x3f85cfbd, 0x89e363e4, 0x87f34a7f, 0x3656675b, 0xf40b0397,
- 0x9fd899f6, 0x51148eed, 0xf130ae5f, 0x7f644ef5, 0xc5f51a36, 0x79bd5fc9,
- 0x23c7961d, 0x86cb6e4a, 0x7c16dbfe, 0xfce2845d, 0x353e096f, 0x0b6fe39e,
- 0xb468fffe, 0xbf56ca43, 0x43fef449, 0x192859f7, 0xaf4e5032, 0x15a67d04,
- 0xb074e4b0, 0x74463ef2, 0x896ac890, 0xfd65e36e, 0x47a30c05, 0x00f37539,
- 0xbcca8ed8, 0x9747fff0, 0xce896c74, 0xa2c69f5f, 0x7433ea82, 0x0bfd4109,
- 0xcf41c94d, 0x171f8d6f, 0x39a67cf4, 0x3b3ea83b, 0xff505263, 0x82d32ddb,
- 0x9c4e77ea, 0x8e7fd419, 0xdd504e6d, 0x1f244cc6, 0x738aea3a, 0xe1bb013f,
- 0xdc92bab5, 0xe397544f, 0xd0f6aa63, 0xe805b37e, 0x5f3bdb24, 0x91ea0935,
- 0x43265687, 0x11cb537d, 0xf43c4f5e, 0x66e03245, 0xf9d1cb73, 0x53dbd02a,
- 0x45f43c6f, 0x6d1fd40a, 0xa7cfe2e9, 0x40a362c0, 0x39bcb6ac, 0x9af805df,
- 0x8adf629b, 0xa9779af8, 0xf98a28f6, 0xbdccd7f7, 0xb942592f, 0x06746730,
- 0xc53727ec, 0xbf3e10fe, 0x759ef62b, 0x1ffb0091, 0x46ab5b7d, 0x5d98bf3c,
- 0xa1e915b2, 0xf3a722ff, 0x91978853, 0x96097eff, 0x8a61d903, 0x3c92bd9c,
- 0x03adf854, 0x1512c6f4, 0xa54749c2, 0xe544ceb7, 0x2a78baa1, 0xd999d48f,
- 0x57638012, 0xc795065d, 0x7ed42cea, 0x95226ebc, 0x546cea27, 0x4c575bbe,
- 0x095d7765, 0xb2ff0a95, 0x6a0d96bd, 0x2a974224, 0x4fceb4ea, 0x63d2578f,
- 0x69d92820, 0xf9d09f05, 0x39adbd4d, 0x9d75ce9b, 0x6959e909, 0x81f9da3f,
- 0x9dfa0459, 0x3d11d56a, 0x9b74354f, 0x475e5675, 0x22fbb8b9, 0xbc118af3,
- 0x5fb02a9f, 0xfd1b278c, 0x030ea998, 0x841b4bf5, 0xefd8597e, 0xf79404cd,
- 0x16356b53, 0x509e63b4, 0xf61e9733, 0x90df146f, 0x20e31d70, 0x05d86cca,
- 0x903ad518, 0x6ba07157, 0x63f439f1, 0x0f77283a, 0x4746f5f2, 0xf9472ed7,
- 0x60ccba34, 0x95f2e7a9, 0x08e24be4, 0x2fee026f, 0xda86a571, 0x198f628d,
- 0x9d5f60e5, 0x69d21677, 0x0ae72c81, 0x30ef5c34, 0x80bde411, 0x576dfb7c,
- 0xedf3da22, 0xd02f9edc, 0xfa44ec96, 0xfe7156ae, 0xf77a3165, 0xd5475c1e,
- 0xf42cf15d, 0xb44d89eb, 0xc568426c, 0x6069641f, 0x14d617b7, 0xeddca267,
- 0xaf885b61, 0x13fd5ec1, 0x338fdbd2, 0x9945df81, 0xf89e6048, 0x4da6f0e2,
- 0xd7adda02, 0xce5d21e7, 0x300f9ad5, 0xf65f07e0, 0xdcfbd100, 0x7a1e7348,
- 0xafecbe0a, 0x7cce3d79, 0x26e78040, 0x00bf3036, 0xe9cf55ea, 0xf0049f4d,
- 0x1513d3a9, 0x4b69af54, 0xc0127d30, 0x07f855a7, 0x09b747fa, 0x0ebb942a,
- 0x04a72b79, 0xb7c405fb, 0x0d73f8b3, 0x0680dfdf, 0xd98bd8ed, 0xb06fa266,
- 0x0fef4997, 0x9bba34cc, 0x2371bf60, 0xa057b36a, 0xce6994fd, 0xea497ec3,
- 0x63f40881, 0x1555bffa, 0x19efc9bb, 0x78c9f888, 0xd33d7d3f, 0x287b5121,
- 0x70e6b5dd, 0xcd26af7f, 0x50f119b0, 0x51d3af1d, 0x88b171d9, 0x92569d91,
- 0x4db97686, 0xd0cbfdc3, 0xb8737bf1, 0xaf5e491e, 0xa240b921, 0x0b6cb608,
- 0xc5dd4a63, 0xf8d63226, 0xbf21b08b, 0x34c9c007, 0xc83f6563, 0x41476235,
- 0x1b7f505a, 0x8e7a1ff6, 0x8ff31cf6, 0xbb49794f, 0x5e4aad63, 0x2965e90f,
- 0x183fa373, 0x72abc72a, 0xc0b965a3, 0x8c74fcf1, 0x9cf111be, 0xe77d0126,
- 0x504cc950, 0xb2338626, 0xd75f1337, 0x773e91bb, 0xa7fd39eb, 0x2ddcbc89,
- 0x309afef2, 0x577a42e6, 0xb94d87fc, 0x79b929f6, 0xe6978f34, 0x91b25a91,
- 0x879813ae, 0x24ec57d6, 0x43d81fa5, 0xaa02127a, 0xd7c47481, 0x161c4954,
- 0xa672279e, 0x448ce515, 0x4fb1b0fe, 0x5f77e403, 0x40aac478, 0x78e355fc,
- 0xe9b8e043, 0xef194e34, 0x4fb2255c, 0x245c9047, 0x89a6723a, 0x4b562fe4,
- 0xfe8088ec, 0xa0d6eb16, 0xf5c6539e, 0x14fc1c82, 0x9047f0f0, 0x087e588b,
- 0xffd710f2, 0x2c43c833, 0x10f20aff, 0x3c824fdb, 0xf207d2c4, 0x063fdb10,
- 0xbce58879, 0xe4568dbb, 0x69b69a9f, 0x7e20d3ec, 0x017ddb50, 0xc369def5,
- 0xa64391d3, 0xe1e4dea3, 0xe1cbaf9f, 0x2def457e, 0xa0fd9f1c, 0x00ffd1bf,
- 0x8a6b5cba, 0xef1eb2be, 0x1ef9b237, 0x7cb6d380, 0x27f4876e, 0x1cd2faf0,
- 0x226dd535, 0xb7e38edb, 0xfaf86be5, 0x3e396229, 0x79f345b7, 0xb245d37b,
- 0x9e4ea69f, 0x9e0724b6, 0x3da162db, 0xbdef5fc7, 0x8db73f81, 0x7a43ede2,
- 0x253e7e56, 0xeff8a4d7, 0x652fdce9, 0xbd012764, 0xff4afcd3, 0x3e7226f7,
- 0x4eefed0c, 0xc3dd8b13, 0x992de3c0, 0xd02f896f, 0x483e469e, 0x6a8be00e,
- 0x4285f133, 0x55fd0a87, 0xa73872e5, 0x073a6569, 0x43f042dd, 0x3a72831d,
- 0x25f64f4e, 0xe0c6c5c0, 0x9905bb3c, 0x01f9425f, 0x0a07d44a, 0xa07c283f,
- 0xf0227bd0, 0x3fed1099, 0xf421cdc7, 0xca8f94aa, 0x358ee8e7, 0xdaf09cfe,
- 0xdfa136a1, 0x87cc3377, 0xc1c513e3, 0xfe46ef77, 0xd19a358c, 0xc87c2cf5,
- 0x1c9c3b50, 0xc2effaeb, 0x570b9143, 0x7065c780, 0x5ff2f0d0, 0x39c90385,
- 0xbf48e394, 0xfdadc8c3, 0x5db2d139, 0x44f7e9ce, 0xd21f6d8e, 0x57a0bf51,
- 0xafd0dfa1, 0xd9dac367, 0x7f39f2db, 0x05547428, 0x89eb103a, 0xcbd4ce78,
- 0x9e729ee5, 0x632e73a1, 0xc2d2ff24, 0x9e287b78, 0xc8057395, 0x0139c3bf,
- 0xb8c61ff1, 0xd81d717d, 0x4d4fe817, 0x3ed335c9, 0x567e47fa, 0xcff995b6,
- 0x6f0e477f, 0x88944a7f, 0x32fd141e, 0x8b482ed4, 0xe90664e6, 0x3f42661d,
- 0xfc4b53af, 0xe67f05ee, 0x3e871825, 0x3fe49b21, 0x71e320bf, 0x1158fe70,
- 0xafbebbed, 0x63d42e0d, 0x4e06a37d, 0x6fbe300a, 0x6436183b, 0x136ed897,
- 0x07deef40, 0xd4f5063a, 0x2c7b9005, 0x7273b19d, 0x73cfa11c, 0x73fa24f1,
- 0xa6243b35, 0x3b4a5003, 0xf4879abe, 0x6d53b4b4, 0xf6d0b8a2, 0x3d218ec7,
- 0xcc156e9e, 0xb5f49768, 0xbfa1f1c2, 0xd6e8c1b3, 0xa822ff43, 0x0665ff63,
- 0xd7ccdb8d, 0x4383f8a3, 0x7d53ef5e, 0x85c60a75, 0x1350ec66, 0x2f3e97dc,
- 0x3b3ed1b9, 0x0aa57dbc, 0x02dda7eb, 0x4571838b, 0x04aeead2, 0x2d3e57a8,
- 0xce30b458, 0x8b3a2861, 0xe7ca82f1, 0xf30bc599, 0xc918b657, 0xa0da5dcf,
- 0x6017d8fe, 0xb7bb945f, 0x29eed06a, 0x5edc19df, 0x0eb83bb9, 0xeff922f8,
- 0x00f68668, 0x8e6dfcf9, 0xcdec8631, 0xed1b2c71, 0xe3c0d64d, 0xbf7c8ab9,
- 0x71756edc, 0xcb82ba39, 0x8cbec66d, 0xea5f7f45, 0x63e92afc, 0x91cfaf03,
- 0xfea0a7eb, 0x2f1c57f9, 0xe5aa5c0a, 0x604f3fb5, 0xb79c0f56, 0x426f53ba,
- 0xfdbabfff, 0xb71811ef, 0x51f309af, 0x22bd9f7c, 0xdbded099, 0x10b926d8,
- 0xfd0ecebe, 0x56e0112e, 0x8d3de07d, 0x5f7088d9, 0xadcaf64e, 0xe31eb5cc,
- 0x64515edc, 0xdd4744dd, 0xb666a714, 0x4f38a581, 0x84debb5f, 0x2bf54076,
- 0x8ddd741f, 0xd30203f5, 0xfb471e23, 0xee964e88, 0x2da58640, 0xfbe426dd,
- 0xbc4244e9, 0x913d9e22, 0x8865af84, 0xe033c477, 0x212cf11d, 0x51bc713e,
- 0x2274e6e3, 0x73f4fd51, 0xde0abf1c, 0x1acda48b, 0xe46caf6c, 0x63b19e78,
- 0xa230b6cf, 0xe9933503, 0x7a7ef080, 0xa6bbc727, 0x14669d73, 0x08636fd2,
- 0x876bb41d, 0x77f700e8, 0xe0841d19, 0x8df002bf, 0x0e942072, 0x93dff142,
- 0xd806e5c3, 0x429fa7df, 0x7e08dbfb, 0x23c7f301, 0x1ef55646, 0xcaf5818d,
- 0x973bcfa2, 0xf8d8fb43, 0x08da5897, 0xe4157f8a, 0xe66bfc62, 0x5d10eb3b,
- 0xc85eb33d, 0x57a97a46, 0x813cf6fb, 0x70a88b71, 0x27f4e38a, 0x32f9d9cf,
- 0xfa20bb9c, 0xd816a49b, 0x5a6bcd7f, 0xc928deba, 0x35ec8715, 0xf129978c,
- 0xc533c074, 0x5a1d9cc9, 0x2d6b171e, 0x73fa05b4, 0x5cfc09fd, 0xb2819a85,
- 0xc017e8e5, 0x608eb87c, 0x555e7ee3, 0x28178f07, 0x1295597e, 0x8e0e6837,
- 0x77a6081b, 0x2e455fa8, 0xc6a55f8f, 0x3b466cdd, 0xb3017ebc, 0x4d5ea587,
- 0xcc78f03f, 0x74dfb2d3, 0x0af1fb45, 0x1bb1427a, 0x6e382b99, 0x65a9c8a1,
- 0x8f1ef913, 0x6ab8e2fe, 0x76fdc604, 0x8a8f840b, 0x704f900e, 0xdab70ade,
- 0xf802166d, 0x19ffee49, 0xedc01bd2, 0xa0f6ab8c, 0x19dd2128, 0x990ebf68,
- 0x8e91ab3e, 0xd695bce0, 0x9cf02237, 0x38ae590e, 0x7f148dda, 0x8a5b64ab,
- 0x612aee90, 0xf430ef3d, 0x0b5cf954, 0xa2d729f9, 0xaccec527, 0xb7ee0d6e,
- 0xce487731, 0xe01eff8c, 0x396401bb, 0x992e7bd7, 0xf12332fe, 0x99906fde,
- 0x879f9123, 0xedc09ff4, 0x5cfe4537, 0x3c581dbf, 0x6e71de60, 0xac05531d,
- 0xa673e37f, 0x4f78faa0, 0x9bff507c, 0xcf41ccda, 0x4119bdb3, 0x598f73cf,
- 0xdd79ea82, 0x4ffa8313, 0x5416d0f8, 0x0e2be49f, 0x4ce53fea, 0x307d5049,
- 0x9573ce13, 0xe35bc1fb, 0x33fea085, 0xf9a0facd, 0x05446767, 0x320d07d5,
- 0x52bb647c, 0xce5f77b1, 0x686ef6e5, 0x76f7c0a9, 0x8a3af04b, 0xc4e77ebf,
- 0xd8e6f5e0, 0xa1fbd782, 0xfa0bd978, 0xc27e0554, 0xb15fa073, 0x13f81dfc,
- 0x9a13f02a, 0xfac09fc1, 0x604fe08b, 0x027f01e9, 0x7f025fdb, 0xe0adeb02,
- 0x20fd604f, 0x6f583ff8, 0xf2a62bab, 0x6a12ba95, 0xbafc16bf, 0xc98f75e4,
- 0xd7971eeb, 0x74e177fd, 0x5def9e42, 0x9c6ebe79, 0xdcffcd2f, 0xbc563c59,
- 0x2d3cfc04, 0x87c6acfa, 0x5f0ac37e, 0x062dc611, 0xc61892de, 0x7ddd99a5,
- 0xf5062eac, 0x338a08d9, 0xb78192b3, 0x7d52ae31, 0xc9b4d520, 0x0fecfa8c,
- 0xbef3e2ef, 0x7c8cc956, 0xefeda879, 0x85cf3811, 0x5f74614b, 0xef107a4a,
- 0x5461bf1b, 0x31cf04df, 0x05b33a0e, 0x37e90804, 0x0bb7e90f, 0x4ddd4a69,
- 0xcd25bdf7, 0x53c41a2d, 0x3c29f215, 0x0ea3cb7f, 0x635cfe7e, 0xf61373d0,
- 0xe54ab287, 0xb9c238a6, 0x2f3e6536, 0xf1a477f5, 0xcf73cf7b, 0x053f5e1d,
- 0xe2cb6ff5, 0x5e7f7811, 0xec5efcd5, 0xc7c157bd, 0xc85f07e7, 0x76cafba4,
- 0x9fe0cf98, 0x96aed9cf, 0x8eff7ceb, 0x68a296b4, 0x02cd1c54, 0x05c50b1b,
- 0x5fee85b6, 0x38f6daaa, 0x65556e50, 0x0066addc, 0x248f7e9f, 0xbdf837c7,
- 0xb8c4c391, 0x22f9e71d, 0x5f57ef02, 0xc3bd1cf7, 0x38edf886, 0xf6eb811c,
- 0xfe414ab7, 0xb72b68d3, 0x355b478f, 0xad0bbf84, 0x5ef02387, 0x30e7a377,
- 0x4bcabb87, 0xd7243fe7, 0x7824a1fb, 0xfe7449b7, 0xd0624b8a, 0x5586763d,
- 0xb66679a2, 0xb9e2358d, 0xbd7c3c7a, 0xb799ab1c, 0x825e2da7, 0xbf1e3ffb,
- 0x7b224f20, 0xca350410, 0xef661bf1, 0xcaa43b41, 0xf386d923, 0x79e40aef,
- 0x4e9cd4bb, 0xdfdb4adf, 0x78f8f285, 0xd26c88f1, 0x699f8a11, 0x916f76e5,
- 0x7a869ec6, 0x3660c7a4, 0x583f9d22, 0xfc446a9c, 0xdb12c21e, 0xec69778b,
- 0xe6c7bc06, 0xba98f5eb, 0x7aee9023, 0xb425735a, 0xf2f99477, 0xe88775e5,
- 0x2e6f087b, 0xbbb953c2, 0xf8f380d1, 0x73dbc7f1, 0x7fea26ac, 0x3cdefddc,
- 0x327aabb4, 0xe92ec9c2, 0xa7f230d2, 0x5db99aab, 0xd891d3dc, 0x924f7818,
- 0xf2fd9563, 0xdaf0910c, 0xfb96a6d7, 0x0587bddd, 0x39d353f5, 0xde0eec2f,
- 0xea7dc98f, 0x1dc7b451, 0xf50c4b4f, 0x1b5d43a2, 0x6cffe78b, 0xcafef067,
- 0xd43b3865, 0x00d8d8de, 0x0fb4757a, 0xe8818df1, 0x13e15dbc, 0xc153e133,
- 0xb7064f63, 0xf9e27ae7, 0x65a3a4bd, 0xe5f5d10f, 0x64eea4f1, 0x7f121ff4,
- 0xe778a3a9, 0xc567fcb5, 0xaff0086e, 0xea8bfa18, 0x313cd4e2, 0xbc1f6fc5,
- 0xb6ab6b96, 0xabbf448e, 0x1ecafc84, 0xac2cf606, 0x3a7b44e9, 0xb61ff292,
- 0xad83bae1, 0x76bfba6a, 0x7d66daea, 0xa0d97602, 0xf6051805, 0x2d53b83d,
- 0x0cd97bdf, 0x952ed768, 0xcccfdaed, 0xf4097cf6, 0x488d73af, 0x866473e7,
- 0x27d31f91, 0x5bcfbdcb, 0xbb24ef92, 0x426498e1, 0x8786687f, 0x668ec1db,
- 0x7b56d76e, 0x2a63ff92, 0x6acdedda, 0x8a60d4cc, 0xed94e21d, 0xddb2d390,
- 0x80cd7a7b, 0x4e9bfc86, 0x8c963d81, 0xbb5b2a79, 0x33b9e112, 0xb3d91673,
- 0xec99a94e, 0x83db6589, 0x6fb007ed, 0xcf55ea82, 0x7217da85, 0xdc13cb7c,
- 0xdb87f8ae, 0xc67643ac, 0x0a67f438, 0xc871a9a5, 0x78c82f0f, 0x959bfc55,
- 0xb7942de3, 0x9e6551b3, 0x1021c4a5, 0xfb9d355e, 0x6edf702b, 0xfc859847,
- 0x10af558d, 0xe4bffb5c, 0x3c7f4c7e, 0x33f47823, 0x36fedf0e, 0x6a35e74e,
- 0x48f98dc1, 0x34b64035, 0xaf704e9f, 0x6bb338c1, 0x13e48230, 0x17c8c563,
- 0x7f70162b, 0x5f3186d5, 0x7e156b28, 0xb7abd108, 0x54527ca8, 0xb3689c80,
- 0x02bf50a6, 0x3ea3b30d, 0x90b4695b, 0xe3a31b7e, 0x6ae17a76, 0xc3d2364f,
- 0xb5c7f018, 0x31f8f101, 0xfb010186, 0xc7807eed, 0xc27895ff, 0x1d49951c,
- 0x191fa015, 0x95fd435b, 0xf0a241f9, 0xdf9ad7f1, 0xfc1bf304, 0x23bc03f3,
- 0x585fde11, 0x93b7a42d, 0xfff728e6, 0xca97c4b5, 0xbd002e79, 0x63181c61,
- 0xc7378834, 0x9fc837ce, 0xf5eeb273, 0x8228ae38, 0xf708a3ef, 0x5e30f583,
- 0xe79651fe, 0xbcbc79b1, 0xf9152e4d, 0x7b6790d5, 0x95f50adf, 0x593ff679,
- 0x8899ae49, 0xb4ca573e, 0x9c4cf602, 0xbbf9186f, 0xf0891de2, 0x03f005fa,
- 0x5ac2fbf2, 0x64169cc1, 0xaf3a712f, 0x3cec4de1, 0x454ef4f3, 0xdd6cb838,
- 0xc6d79819, 0x5a2d7f38, 0x05a737a5, 0xbd2007de, 0x0251ffa3, 0x2fd1f2ff,
- 0x5372bfe3, 0x57946dc5, 0x8cd62ab5, 0xc83517f7, 0xa6d7290f, 0x87ba50ff,
- 0xb7a44edf, 0xa0b5a66a, 0x0b69a97e, 0xa1516e7d, 0x084dfe3d, 0x74c9245f,
- 0xe81768da, 0x5bf1bd7e, 0x95a38f15, 0xbb37140a, 0x4e911a0b, 0xcafd87e9,
- 0x7e71b9a7, 0xfba0b3cc, 0x391886ae, 0xee862bef, 0x9f227ee1, 0xf7952eff,
- 0xa3efe40d, 0xc6324f6a, 0xf93a8e71, 0xe602d53d, 0x52dd7ba1, 0x6f654dd6,
- 0x2f01f578, 0x8d1aee4d, 0x7607f87e, 0x1a91c52d, 0x511936d7, 0xb5b166ce,
- 0x031fbc26, 0xfbee7936, 0x1bdb2bdc, 0x9468f7a1, 0xc7e7959f, 0x92bccaf3,
- 0x83a03cf8, 0xf8a38033, 0x57c7cb9c, 0x02207fbd, 0xfefe7ee1, 0xca7ef3fd,
- 0xb9020fd0, 0xd654f305, 0xbdd064b6, 0x67758b8c, 0xabf1fbe4, 0x1fc153e0,
- 0xf08399b4, 0x0eb9670a, 0x0d9f33e0, 0xd36e63e4, 0xc0a9f0b5, 0xf03d4939,
- 0xe8250463, 0xa1439231, 0x5ee05678, 0x3cd56acd, 0xeefb56fe, 0xb3ffe802,
- 0xed19a2b5, 0x7ef0cbca, 0xf578fc0d, 0x28d791fc, 0x257b3f90, 0x5a78297c,
- 0xff54bcc8, 0xfb8f8a30, 0xf144a170, 0x7c69ffc3, 0x4bd9e435, 0xb7c2aef2,
- 0x257a7ca1, 0x2ab45cbe, 0xf8437f84, 0x2d2f8874, 0x7f002ff0, 0xc41155f6,
- 0x1d7e0a8f, 0x5193f066, 0x2d1875ff, 0x3e39766e, 0xfdc5dfd1, 0xec0ab654,
- 0xf087e149, 0xe3fc8fab, 0xad017c50, 0x541f50d8, 0xa9f305e7, 0xc92bc782,
- 0x7dee452d, 0x4d47bcc4, 0x7067dd02, 0x9685fe3e, 0xfb94e9f2, 0xe2dee50c,
- 0x6fae3cd1, 0xc08fcb42, 0xa27bc16e, 0x233d194d, 0xd5ebded1, 0x7bf0f328,
- 0x74d68fd7, 0xcd7cc68f, 0xb2f1a68f, 0x4cf3c357, 0x8c2dba94, 0x4a3f03c7,
- 0x6e10bad0, 0xa6e3091f, 0x91f01da3, 0x783bcbf0, 0xc6634e3d, 0xe9b882fa,
- 0xaaf7a826, 0x83e1f895, 0x5376fcb2, 0x0982d1f9, 0x604fd405, 0x661e1047,
- 0x3ad09581, 0x0c5d1082, 0xe7e8f9fb, 0x5ef07363, 0x03ff3940, 0xf48e3c79,
- 0x431cf91b, 0x095ff6f1, 0x045f6f14, 0xf784c3aa, 0x289fd302, 0x93f6814e,
- 0xa6cd4ebf, 0xc115cafb, 0x4dfea3eb, 0x56e538a6, 0x4b96e79a, 0x99c5ea03,
- 0xe90d7dfe, 0xbc8b82cd, 0xa0d8c97d, 0xf45b667c, 0xbb27ee38, 0x8f512353,
- 0xf06d7a29, 0x60437ed8, 0x1cacf51c, 0x8faa1e77, 0x5029247b, 0xf7b1be2f,
- 0xa79c74e1, 0xb2cae35c, 0xf98f3018, 0x1fb424a9, 0x943ef7ca, 0xdeed764e,
- 0x9fe8e98d, 0x9c3d3794, 0xb87aa36e, 0x1523fc9d, 0x7df9f73f, 0x0a6d7693,
- 0x9d6fa3b0, 0x52fbedc0, 0x68851bdd, 0xf1bacedf, 0xb71875f3, 0x816bfb1f,
- 0x590b70e2, 0xb7d43af7, 0xaf9c1965, 0xe48e8358, 0xf747cc3f, 0xddc67ba4,
- 0xfee51bbe, 0xabbf8cf1, 0xcdfea097, 0x657cd153, 0x0e39bdcc, 0x041b6fe3,
- 0xfbf9bf8a, 0xd77ba68f, 0x4d056bc5, 0x51ea0c7c, 0xc7fd779e, 0xe38228bc,
- 0xbbb21b3d, 0x356cbdb0, 0x75a59f6f, 0x3ce0f6b7, 0xcf28684f, 0x4a65140a,
- 0xf63dc049, 0x3df8f31f, 0x72cda2dd, 0xcebcb1be, 0x8db16dd8, 0xa3fce781,
- 0xfe567f8c, 0x3b83c901, 0xb6dcbc65, 0xf123bdfa, 0xdaa46f30, 0x2b9467fe,
- 0x3a7e3eef, 0x4159e50d, 0xa44cd9f4, 0xfb1ab1f3, 0xee781593, 0x2bc52d26,
- 0x528959ad, 0xb9cff41c, 0x5863da7f, 0xf8bd5a2e, 0xfb8c0ac9, 0x1f91d76e,
- 0x856feca6, 0x5fd11660, 0xd3f8dc3d, 0x676e107b, 0xa479e71e, 0x8faf1a2b,
- 0xe2fe5abb, 0x1f3c75b3, 0x1d3af9fc, 0x99d42f95, 0xb88e1998, 0xea9e2eaf,
- 0x5333afbf, 0xfa73e6c9, 0xaea6f252, 0xa5ee5f34, 0xb65bca30, 0x1e51d06e,
- 0xf6d6ae7d, 0x6bc01e55, 0xa6ce0dec, 0xc6b9f28d, 0x576cf8c2, 0x83840cf2,
- 0x2ef2e375, 0xe54f6134, 0xedeaff71, 0x64490d9e, 0xf53eaf87, 0xcf3c054c,
- 0x0ef92fcc, 0x5e76ebc7, 0xe1c178a4, 0x10ca87f6, 0x5a4de5de, 0xdcf93e7e,
- 0x8f4f1e67, 0xbce3127b, 0x7fc9a96f, 0xea79d9af, 0xde508d99, 0x26b979bb,
- 0xe87fde90, 0xf795bf79, 0xbabe2d73, 0x75fe1c12, 0x89387abe, 0xf809a7f8,
- 0xe7dff32a, 0x6bd59aab, 0xf3737e08, 0xc3e6c64b, 0x5da8cffe, 0x674fc849,
- 0x744cddc6, 0x0814eaee, 0x571c8afe, 0xf3e6a7c6, 0xd12ae8fb, 0x48ec99b3,
- 0x057f8e59, 0xf7c2239e, 0xd2cff68d, 0xaafe8ed1, 0xcf55c16d, 0x3d0eb07d,
- 0xe99b8c22, 0x9e7d0ca8, 0x62a7b1af, 0xc8be715e, 0xe7d0e7ed, 0x712be7b7,
- 0xc5b71e78, 0xa790109f, 0x458d84e2, 0x13fea346, 0x972061bc, 0x9eb76d9d,
- 0x06ffa155, 0xc1c7e17e, 0x38fb2876, 0x695faf40, 0xab2ad7bf, 0x5f951e71,
- 0x50f84eee, 0x3d00de64, 0xc617c93e, 0x0eeb01bc, 0xa6d02bf9, 0x049efba1,
- 0x37880b92, 0x6bea87cc, 0xf584d71f, 0xc78e1ab3, 0x97e083be, 0x930cb8f1,
- 0x3ce7fdf2, 0x0b3e7edb, 0x79e86ce5, 0x4f395fab, 0x7b68e1f4, 0xe740a2e8,
- 0x9556799f, 0xbff3ed75, 0x167cf7b1, 0xdaacefe2, 0x57fe8f97, 0x8597c69f,
- 0x957ea878, 0x157ff3cb, 0xc57b4a0e, 0x138f0d06, 0x23f2260a, 0x140ba50b,
- 0xc63be807, 0xedd500e3, 0x0e9e48bb, 0x4c78f076, 0x145dd88d, 0xda8bf187,
- 0xcf285d53, 0x5fb9e306, 0x28dbf306, 0xd65521cf, 0xa481aa83, 0x1ed72039,
- 0xee07a219, 0xfe419e0f, 0x1e3ce0d5, 0x6561e507, 0x2bb43385, 0x433f21ce,
- 0xe4aad97b, 0x67e748f5, 0x507323dc, 0xf59dbe3e, 0xdf8a6a8f, 0x926e1ebd,
- 0x30958ec8, 0x4e0878c7, 0x4b70e743, 0x2987d13c, 0xb3387176, 0xd1abf405,
- 0xbf24ef98, 0x9fbf38fa, 0xf381b9ab, 0xf3857b13, 0x1bed7393, 0xf980f89a,
- 0x93f3257e, 0x7ace4f62, 0x97c41ffd, 0x9edae70f, 0x470cbe40, 0xc5f38859,
- 0xb51e5247, 0x72871ef2, 0x90e8691f, 0x8962f8fd, 0x49b4d79e, 0x58e5ef0c,
- 0x0af291bc, 0xca16d98a, 0x3cc59cb7, 0x8f5e7953, 0xf029d1ef, 0x52ebf67c,
- 0x81a1e62e, 0xdbf74d3d, 0x34f66145, 0x15ead3cc, 0x1eae1905, 0x7d009ceb,
- 0xf73e7ef6, 0x024aa757, 0x8481b1e9, 0x6653b270, 0xe29677ce, 0x5a7e957e,
- 0x9833eb91, 0xe62cec87, 0x7bc2c81e, 0xc81de655, 0xa556fbc2, 0xc3d7bcdf,
- 0x322f496b, 0xc05e758f, 0x79f3a73a, 0xbc0bf3bc, 0x5279071f, 0x16c3df23,
- 0x436edf4a, 0x27456b7f, 0x15ec7fbf, 0x3cc03f93, 0x19c01733, 0xf01e7af1,
- 0x63fd436a, 0xf21b3667, 0x6e91f8cf, 0x7d9a9fe4, 0xbd7cc302, 0x136d76ea,
- 0xd5aa85c6, 0xe7a458be, 0x6bef6d8d, 0xf06b9e90, 0x8e3c765e, 0xdcbc7267,
- 0x35bf7944, 0xf5efc626, 0x00ffaeda, 0x63ce76e3, 0x553a8b5c, 0x003c51ef,
- 0x57ae36e5, 0xfe42dad5, 0xc97983bf, 0x073477ff, 0x3c60cdd3, 0xf287e78f,
- 0x737ce9c9, 0xdccc7f10, 0x1e63f9ce, 0x681b73e6, 0x675fc538, 0x5d91c7c6,
- 0xf1c71fe2, 0xafce9360, 0x3fa63b43, 0xfc7ca045, 0x5ad730fe, 0xe95c8fb4,
- 0x7fe9aedc, 0xbd2b05ed, 0x5b73a3f7, 0x3cf98c7f, 0x733bddb2, 0x149556c3,
- 0x1d999fb0, 0x1fd8de3c, 0x120fcac6, 0x21d7edde, 0x25b97c3e, 0xbe31f267,
- 0x777819a3, 0x4483c60a, 0x3d0d1f1e, 0x6b8e5d87, 0xfdfc671c, 0xb3df6528,
- 0x3cb91313, 0xa3a26e63, 0x5bbf392e, 0xc651d7c9, 0x504132df, 0x9fb8d1ee,
- 0xfaae5824, 0xd7de1a5e, 0xde2b9e60, 0x3bf960d7, 0xef161f39, 0xa2feb06b,
- 0xf78b0f9c, 0xf78ed835, 0x956f5835, 0xbef161f3, 0x5f78eb06, 0x722be583,
- 0xdc71ec3e, 0x6df1e52a, 0xa2e90a7c, 0x946d790b, 0x1d1bdebf, 0xdc151f52,
- 0x085a37bf, 0xa8128fae, 0xc6c269bf, 0x78ff30a7, 0xc52f9293, 0xc3b446cc,
- 0xfbf9c22a, 0x7b06a91a, 0xf3f404ec, 0x45ed778b, 0x9bf81e7f, 0x882b9fde,
- 0xef4a505e, 0x1968c497, 0x27dba3ca, 0x804f47d8, 0xcd8ec7f1, 0x724adb48,
- 0xecf74f52, 0x31bb3fbd, 0x6f7ae292, 0x25824c49, 0xaee465a7, 0x9a7d42b5,
- 0x85fa2041, 0x512a6ef9, 0x67984cfc, 0xab62c746, 0x1307cb8a, 0x9285cbda,
- 0xb3ae0963, 0x8b9f4122, 0xd588f872, 0x51fb819e, 0x6a345de0, 0x45da1a59,
- 0x07f36a5d, 0xbd759f18, 0x57e866a3, 0xa53c7129, 0x69d693df, 0x99bfb8f9,
- 0x736ba919, 0x36607e70, 0x0d367794, 0xd9fdc66b, 0x9ea170c4, 0x855997e4,
- 0x027f20f2, 0x66e99ba7, 0x357b1f6e, 0xfa345566, 0x62d361f5, 0x4bb75ef0,
- 0x1931f3c6, 0x3c65c7cf, 0x81573de3, 0x6173df8a, 0x585cf789, 0x2da3e686,
- 0x4db12fcf, 0x240f7820, 0xcdb3e605, 0x0097df92, 0xd4f7a10a, 0xf31c729c,
- 0x34ee594b, 0xcadc95e6, 0x9e6879c7, 0x778e392a, 0x6f7c1d5e, 0x8ff38ca8,
- 0xbdce5467, 0x166bcb89, 0xbf79e1a9, 0xe61731d7, 0x397dcf15, 0x7d50e281,
- 0x06a5d16e, 0x5e05cfbc, 0x5ec67947, 0x8b2efee6, 0x77337ce7, 0xabf51c7f,
- 0xcea9e397, 0x7c74eee8, 0xe64fa3af, 0xf07ea52f, 0xe4979e3b, 0x81ba81cc,
- 0xf3a123de, 0xa776e739, 0x4fbd4147, 0x5f488bd0, 0xbcfe26ce, 0x673fe647,
- 0x7c9f3c8a, 0x24f3a61e, 0x3bfa3e21, 0xf7c24e5f, 0xbc193710, 0xf7fcb94b,
- 0x66dc93a6, 0x6fcc74de, 0x4e782f3a, 0xadf1be62, 0x98a5296d, 0xed5e7f6f,
- 0xb3eb0679, 0x5d78d2db, 0x0a693968, 0x93d23e7c, 0xb7c8f984, 0x6296a5b6,
- 0x91f9f23e, 0x5944cf2d, 0x97eaea02, 0xcd73e24e, 0x98a56983, 0xeb5b3c9f,
- 0x7487563e, 0x5f4e7bf3, 0x4e077dfa, 0xdaaa7c23, 0x7d3efdb9, 0x2f0b81df,
- 0x603e7ea1, 0x7582bca4, 0xdf099213, 0x6ecfedf5, 0x6beb7a46, 0x6c3f1351,
- 0x99ff7e6a, 0x2d3f50df, 0x6b665985, 0xc90c563d, 0xba1db494, 0x3b35f71b,
- 0xd625f3dc, 0x89bc4f17, 0x047b31f6, 0x13a5ebe7, 0x4f914a73, 0xfbec0efb,
- 0xd9b3ea05, 0xe2d86091, 0x13d05e7e, 0x8ff72a7e, 0x40b8c02b, 0x0cbbb19f,
- 0x9dfeafe7, 0xec1fe796, 0x718e9b8f, 0xc09cff82, 0x6e2a31f3, 0xfa8492d8,
- 0xf9e57c56, 0xf8c1bfbd, 0x74f4efe6, 0xcd1353df, 0xa94abded, 0xe1397f31,
- 0xcc5ed76f, 0x5e7be95b, 0x15aff74f, 0xe2b39318, 0x2963ac7b, 0x3feaff3e,
- 0x78865eff, 0xee769428, 0x772ff6c5, 0x438445eb, 0x7916c68f, 0x8f61f233,
- 0x0acefc9a, 0x3bd15eb9, 0xdc27ef82, 0x8bf84457, 0xfa8492d9, 0xafc472b6,
- 0xcf7dc0ee, 0x833cb696, 0x567b0f7e, 0x670e774b, 0xc1b8079f, 0xd47bb3b8,
- 0xfb034998, 0x5e90aa30, 0xca5b0bce, 0xf7f9c49e, 0xf5e77ef0, 0xae9e085b,
- 0x5c33d73d, 0xd431fa0f, 0xad85e7c7, 0xf767ed41, 0x7e859b3c, 0xcddfb9e9,
- 0xa154ff26, 0x2a5f8573, 0xf4836b77, 0x58824922, 0x3fca5b8c, 0x02198b93,
- 0x0ee759e2, 0x927be8ee, 0x6b9fc7f9, 0x00357b56, 0x5b2d0aa3, 0x0acdf98b,
- 0xde26543f, 0xabe78c5a, 0xd1d31b14, 0xf5c8a97e, 0x9c5f2195, 0x3c5d33d5,
- 0xd65b7bf4, 0x6bad955b, 0x7c1da0e6, 0x45fcfda5, 0xc95f4796, 0x9b55f87c,
- 0xdf781dde, 0xb5fe5a18, 0xa84f998e, 0xb585f5fc, 0x95e5b25a, 0x78d6def9,
- 0x55afe81c, 0x71f97347, 0x8337fa12, 0xac93fb1c, 0x0aad16ef, 0x04eeffee,
- 0xad594f9e, 0xfea3a5f1, 0x7b7fe653, 0x87db8982, 0xca3a5f2a, 0xb371d0ab,
- 0xbcde5925, 0xa9bc9020, 0xd14e156c, 0xd20824fb, 0x2b3c3f58, 0xe6372e75,
- 0x87870d13, 0x0f197cf8, 0x70f1e612, 0xd66caabe, 0x4f30f4db, 0x022f9855,
- 0xd18725ed, 0x50768117, 0x6b122bdf, 0xa317d192, 0x5fe29fcc, 0x5653894f,
- 0xfd36d478, 0x71c1eb70, 0x865e4fd0, 0x5628037f, 0x537ce44f, 0xeb4e16de,
- 0x1f2f9331, 0x677cb6e9, 0xa73c38f0, 0xfb1f8029, 0x06c576da, 0xf70cebfa,
- 0xa751f74d, 0xfffa6f88, 0x07bd31f9, 0xb5b2295e, 0x4e794f78, 0x4083efe0,
- 0x3907de9d, 0x5677df27, 0x43086d7e, 0x95f739fa, 0x4fb8f883, 0x7b9c91f0,
- 0x7246cdb1, 0x23ed4fac, 0x626bb739, 0xf947af11, 0xbd6e50ca, 0x24a7f138,
- 0x7c12fa3f, 0xd29ef865, 0x2f8ea566, 0xd01d81cc, 0xe490b6d1, 0xe7896cc9,
- 0x6a5db051, 0x71138f13, 0xe1932f78, 0xde86d8c4, 0xd443f23a, 0x3a97b466,
- 0x42f72a27, 0x25f9ff1a, 0x31f53f3f, 0xe456bef3, 0xc50372cf, 0x6abec07d,
- 0xc0ed097e, 0x8c16b105, 0x4dc287a7, 0x898c5fb9, 0xe22966fe, 0x7da31de9,
- 0xbc3cc4ec, 0x9f91f4cf, 0xf64ed401, 0x5a6bf57c, 0xd5fb37f2, 0x7e517b03,
- 0x71f68db9, 0x0e9e0113, 0x547af74d, 0xbed41771, 0x67ed342e, 0x1c91bd21,
- 0x97d6f4e1, 0x07bf8bb9, 0x4e4fdf22, 0xfa00f192, 0x7d22358c, 0x87cf1c08,
- 0x409ff6db, 0x9dd7d379, 0x943a724a, 0x3db6ce9f, 0xe3728116, 0xaeefd043,
- 0x87c07880, 0x7ca59f8b, 0x0798f980, 0x6b3de502, 0xf837cf83, 0x2fc98fed,
- 0xda039b64, 0x821b1e91, 0x4170a1eb, 0xf106f4ba, 0x7df68b81, 0xc01bf23f,
- 0x777a6aa7, 0xa861c235, 0x52ea173e, 0x4850fd40, 0x2b3fa43d, 0xfdc3f6e1,
- 0xebcd1813, 0x25eded18, 0xcf1f7e3f, 0xbd07adef, 0xe103f546, 0xee2d3f74,
- 0xc315bd03, 0x8bea16f5, 0x8a6e88aa, 0xd01df55f, 0x83cabdd2, 0xe1259fed,
- 0x291e81f9, 0xfed5534e, 0xf7fa2c72, 0x699826eb, 0xb18fd07e, 0xa0731794,
- 0x11fd163d, 0x7a21dda5, 0x0cf7e5d2, 0x287e50b2, 0x9bc94eed, 0x42e5794e,
- 0x5f3e1677, 0x8719cb27, 0xeb097508, 0x10e1ce8c, 0x76b3df38, 0x287ce489,
- 0xf4c956de, 0x8b21f20a, 0xe15e39f2, 0x1e4503f1, 0xe572c854, 0x7267b610,
- 0xf72937fe, 0x84cf7852, 0x9c8c3f7c, 0x23815af8, 0xcef8a5ab, 0xbccd13fd,
- 0x79a78f2e, 0xe789fc79, 0x3e7abded, 0xc713252b, 0x45f79599, 0xd528f2fd,
- 0x0e505f2f, 0x781c93c4, 0xe70b1d50, 0xb0467caa, 0x8a90c3d4, 0xd04535d2,
- 0x2d532d9d, 0x1ab8a22f, 0x2e1ae7e6, 0x1d2857df, 0xf8e44e45, 0x1fb914ad,
- 0xa057b95e, 0x6a73a5fb, 0xf2076f7e, 0x580fde86, 0x08a6b056, 0x18beeff9,
- 0x5fd026a7, 0x4bfcd6be, 0xcbeb821b, 0xc514d76a, 0x95e7c30d, 0x8d76b6ab,
- 0x57cf9764, 0x8a2c6f61, 0xaede5f35, 0x5e9cfbec, 0xf574e7d9, 0xcc7840c8,
- 0x1234535f, 0x7fba65ca, 0xdcfc1e17, 0x5eb5dae7, 0x5d2d57ca, 0xb7c4f743,
- 0x8a0daa5c, 0xbe6b5eb3, 0x7ba6e60a, 0x3fed2b90, 0xde0874b4, 0x312b8c5e,
- 0xc43dafe0, 0x0137c067, 0xf4cbc5eb, 0x289f143a, 0xfd063c5f, 0x3c5f6653,
- 0x113e3026, 0x339be25a, 0xb88ae522, 0x2c3e04a8, 0x0f030cb3, 0x89d1ffa5,
- 0x3f1ace3c, 0xa8f1d391, 0x5e3b55d9, 0xe9d71462, 0xa57bf941, 0x22fe4cf7,
- 0xbf07efef, 0x9c233267, 0x9bd4ebf7, 0xdfd3fe30, 0x87c50df9, 0xe619d7fb,
- 0x03077bf3, 0x5de7804b, 0x029be3f1, 0x26abc0e3, 0xdc243b71, 0x9a9dedca,
- 0xe3d5f50c, 0xa1c6994b, 0x1bd912f8, 0xdf74e199, 0x05f6d7d2, 0x8efeb7e9,
- 0x8bde133c, 0x0dbb75f4, 0xff356fc8, 0xa8b17ffc, 0x3e3afb87, 0xbeb4bca5,
- 0x7ca33f6f, 0xde728db5, 0x3936a1e0, 0x6cdbabdf, 0xe2fef6c4, 0xbf6117bf,
- 0x8fe9724d, 0x98f8f02f, 0x83f12a52, 0x3bf9ff00, 0x4c7b53d4, 0x54c51f1b,
- 0x2db0ca99, 0x7fc0bf24, 0xe1bd468e, 0xe3982b8f, 0x04c38b86, 0x54d215c6,
- 0x2580ae3c, 0xd2d215c6, 0xeb015c78, 0x12c05718, 0x8ed80ae3, 0x63ac0571,
- 0x18eb015c, 0xc63ac057, 0xb8c4b015, 0x297fb602, 0x0fd1e7bf, 0x3dc78b82,
- 0x57f7240d, 0xc0337e62, 0xbf27656f, 0x47b95abf, 0x7c617ba2, 0xdff503cf,
- 0xad3b7965, 0x678ede72, 0xd607dd2b, 0x882c901c, 0xc41f7c22, 0x3bf98e95,
- 0x1e314703, 0x5822d354, 0x7db198d6, 0x6363ed3e, 0xa507de47, 0x6d47bed8,
- 0x4f44cd11, 0x828d9f1c, 0xd57c8f5b, 0x57e287b1, 0x949d7105, 0x2cd35fef,
- 0xcebb8c30, 0xd93f72d3, 0x0e6b4129, 0x1d92abdd, 0x9376d4ed, 0x9cf552ff,
- 0xef7c0e60, 0x45e266bb, 0x7dca1392, 0x88fe52f5, 0xf37a3d39, 0x6b3d2092,
- 0xf85779e3, 0x29c7ec27, 0x1d9377e7, 0x2d176012, 0x6c6c7bc5, 0xf7a5be97,
- 0xe0e09c4d, 0x9dae108e, 0xd1d95577, 0xb5f31eb2, 0x55fe687e, 0xdef924e1,
- 0x47bf9b3a, 0x92f8fc52, 0xbd60077d, 0xb25a2dc1, 0x609f6e53, 0x1e526dbf,
- 0x28d819e6, 0x53b472ee, 0x27d67e4f, 0x8a0faf5b, 0xd74a14bb, 0x8563dc51,
- 0x7dfd205a, 0x3b9f6ac4, 0x4672e809, 0x6f14bdf1, 0x246f1199, 0xf0e8563e,
- 0x4fc96b49, 0xe315de70, 0x0a9877f9, 0x34e7ecb5, 0xa5cf9c9f, 0x5eb0a9e0,
- 0x2cf7e370, 0xbd0b3316, 0xc008b03f, 0xe5517187, 0x188b1ffb, 0xe850afcf,
- 0x8156c56a, 0xbcbe8ae8, 0x84bdf010, 0x103df845, 0x6af77fd0, 0x289bfdb9,
- 0xc4f27bf2, 0xe28f3c4d, 0xfca7663e, 0x7d486591, 0xd7d7e912, 0x0f6ed07c,
- 0xdb892ebf, 0x9c38e6f7, 0x3571f17f, 0xc61707e5, 0x276e9edd, 0xf9405f3d,
- 0x6ef78213, 0xaf1bfbe9, 0xf3833f26, 0xb9aa8e27, 0x927801dc, 0xf485d59f,
- 0x3b1ef14a, 0xcaebc795, 0xbf229ca9, 0x5efa161f, 0xcbe77f43, 0xb0be382d,
- 0xf84160c6, 0xc03df15f, 0xffbfabb0, 0xebf394e6, 0x5c9ec512, 0x6be3c233,
- 0x51e10583, 0xef49d718, 0xf3caa589, 0xb25b9c3f, 0x8b69f109, 0x1f5c2e60,
- 0x00b669ef, 0x40f08b7c, 0x3dd1c602, 0x66cf7c36, 0x513053a0, 0x7265f53e,
- 0xcc3aeb74, 0x1349a953, 0x2daf184c, 0x1852db0a, 0xa517f30b, 0x7677d324,
- 0x1c78da6a, 0x4e4a0fb6, 0x92dc5307, 0x62aac7c0, 0xf1cf7e31, 0x3fb5cbe8,
- 0xdfcf293d, 0xb3e65b3e, 0x782f8efe, 0xe3b5f11e, 0xfbe9bbb4, 0xef4f4c1c,
- 0xf60fd3af, 0xd1c6fb35, 0xe855af14, 0xae39b068, 0x45a8e909, 0xa5a513d6,
- 0x8ed1a9ef, 0x37b3cc68, 0x96ca1c23, 0x4b175c5c, 0x4e3e1ce7, 0x87dfe4a6,
- 0xe502c9c6, 0xde46ffed, 0x5aba89fd, 0x5baddf2a, 0x9d776545, 0xe8079e8b,
- 0xbf08238b, 0x7d6f101f, 0xf130d27b, 0x4733a656, 0xbe05be92, 0x90edf1e7,
- 0xbbf02af8, 0x33efc018, 0xd9eea23a, 0x8348f680, 0xcdf782c6, 0xd2bcff98,
- 0xfde1f240, 0x59c6c349, 0x2819f815, 0xf4c83b2e, 0xe9878839, 0x112aa919,
- 0x926dff9e, 0x44e71410, 0x2273c1be, 0x7c8960df, 0xf9f952a3, 0xa30d69e6,
- 0x7da194ef, 0x40fb22e0, 0xbf5df84f, 0xd40ae406, 0x20a665ef, 0x442172b9,
- 0xf32380ae, 0xac5f7a33, 0x0936cb43, 0xe9cffcfe, 0x19ca5c50, 0xb878ce46,
- 0xe61d199c, 0xb3be9e79, 0xf9461d50, 0x44efc0c5, 0xf2374767, 0xac25bdbc,
- 0x461dd684, 0x3e7bd0de, 0x38188ef7, 0xbff414f9, 0xd90361f7, 0x9613eb39,
- 0xe477ffe6, 0x71279fcd, 0xdf813c78, 0xed5d5073, 0x059b0e7b, 0xb15d8fbc,
- 0xbe236590, 0xc439ef95, 0x7bf218c1, 0x39eff5ff, 0x123c988c, 0x0ae0e7bf,
- 0xdc439efa, 0x30e7be15, 0x6171b26a, 0x461cf7e0, 0x30b11e4d, 0xc60e7bf8,
- 0xb29df885, 0x39efc1ff, 0xbbce4fa4, 0x370e7bfc, 0xa0ff364e, 0x3d8039ef,
- 0x4fe3899b, 0x63c6d8e4, 0x3b9f2899, 0xe3e5fdf4, 0x97643df2, 0xb2c52f68,
- 0xa2a5c228, 0xc56dd176, 0x73d16df2, 0x5f03b63f, 0x1578444c, 0x037d963d,
- 0x5125977e, 0xf2bca1eb, 0x49b6ad27, 0xb96bff38, 0x3cf8c9b6, 0x2f5fde34,
- 0x73f60f9f, 0xcd0bf60b, 0xe2e8531f, 0x0e5cc9ae, 0xa9cb93cd, 0xc7bfc3f5,
- 0xbf326f3f, 0xbed6be4f, 0xe077bf61, 0xd9feca7a, 0xdc56c596, 0x4ef7ec0f,
- 0xb7ec27dc, 0x88664b04, 0xf80f7a0e, 0xc9757a72, 0x2e7462fb, 0x3fb38f90,
- 0x9528f6e1, 0x14772ae9, 0x1ea30dda, 0x7ee14770, 0xe80e3547, 0xdf907df1,
- 0x68f406ba, 0xf576fc3f, 0x7fdb1e80, 0xdaf9e36b, 0x9f6ff3a1, 0xf491fdcc,
- 0x7e3403a9, 0x4dddfc0c, 0x1440c1fe, 0xe5e96dda, 0x14ae3447, 0xf66d4f7a,
- 0x93764127, 0x8c7bf899, 0x01e636dc, 0x8c3d2191, 0x1e78c1d9, 0xe90c4163,
- 0xef1d4ab9, 0xfdc0f95a, 0x38d1d222, 0x803bec37, 0xaedfaefe, 0xaf7e0c1a,
- 0xaae34bd7, 0x5ec025e4, 0x64ee7a0b, 0x9474bf3c, 0x5ed08f2c, 0x39d9efc4,
- 0x77d08fcb, 0x0b8ec0a6, 0x79be8f99, 0x594f9430, 0xe6bfb3ad, 0x62be5333,
- 0x77a5bf50, 0xfa3d66ff, 0x5ba5e5b5, 0x2f17e435, 0xa58f5969, 0x269ef1c3,
- 0x197d918e, 0xcbec1fd4, 0xfb65faa0, 0xf547d90c, 0xc7d717fd, 0xd02eb30d,
- 0x13a456c1, 0xaa8e0e85, 0x4fd0e33d, 0xb30cea3d, 0x3c1df7f0, 0x269a5df4,
- 0x5df4bdf9, 0xcadd39ff, 0x5d3965f3, 0x3f1df8c0, 0xa9ea8e8c, 0xaf1df2bf,
- 0x1c8a956b, 0x8dcefa1c, 0x5e28b986, 0x7248cb39, 0xfff646ae, 0xc89897aa,
- 0xbaf8511e, 0xb539e55a, 0x18c5fb1e, 0x8a9bfe79, 0x7aabf7d1, 0xcf9451c4,
- 0xcfac3f4d, 0xacfba54a, 0x178f7ad8, 0x5db81de7, 0x15b9efa0, 0x5ab97384,
- 0x9e389628, 0x4447e785, 0xa7815dfe, 0x98487e51, 0x37bfc147, 0xbf972530,
- 0xf8cf103f, 0xca98db77, 0x369df21c, 0xed7a1e39, 0xeff1b4ef, 0xf7e7cd92,
- 0x25510d72, 0xf9f1cba5, 0xf9e81b82, 0x1f52efc1, 0x2afee2b1, 0x71b4ef94,
- 0x4e61bf7b, 0x557f3d06, 0x3d41af30, 0x5d807ae1, 0x7a6d3be9, 0xef80fbe4,
- 0xf887bdb3, 0xd9f7d6ba, 0x1c0fef94, 0x23c3705d, 0xbd1c397b, 0x3355ef78,
- 0xafe418cb, 0x3c3117ff, 0x56c0d29e, 0x000056c0
-};
-
-static const u32 tsem_int_table_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x51fbff00, 0x03f0c0cf, 0x3370278a, 0x45e39c30,
- 0x8381e9f0, 0x5fd32918, 0x50c0cec6, 0x4055c401, 0x3f880bbc, 0x7c3032b1,
- 0xff5e2566, 0xdb042935, 0x21818248, 0x88d7881e, 0x49a83031, 0xa41dc422,
- 0x03261819, 0xb150a1f9, 0x5f3a4047, 0x0f77328a, 0x80a69c16, 0x872ae629,
- 0x9163a760, 0x6819c647, 0x50e54bf2, 0xf40499f9, 0xa2be340f, 0xa2ffca8e,
- 0xa013a10a, 0xe4d157e2, 0x3be542bf, 0xa6bafea0, 0x4edcdd8e, 0xc35dfd32,
- 0xfc01a102, 0x9847b099, 0x009847b0
-};
-
-static const u32 tsem_pram_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x7dedff00, 0xd554780b, 0x733ef0b5, 0x7993331e,
- 0x31e424e4, 0x1e4e1081, 0x03086820, 0xb78a8884, 0xf6301027, 0xd57876d2,
- 0xaf0e2d58, 0x6b86f210, 0x7fb6bd2d, 0x78490806, 0x111fc1a8, 0x29e1d5ad,
- 0x311d82f6, 0x0388b622, 0xbdabd228, 0x557c5837, 0x0bd11feb, 0x2a44908a,
- 0xe5b5ef6a, 0x3ef6b5ee, 0x09939cc9, 0xafdb7b04, 0x7cfdffff, 0xc7ecee9f,
- 0xf5ed7bd9, 0xfdad6bda, 0x8131c918, 0xe4230da4, 0x06fbfc22, 0x109d9221,
- 0x9d37a132, 0xd72120e3, 0x66924218, 0x92ddfd2f, 0xbadc4214, 0xa349bfe2,
- 0xe4febba9, 0x5f5f9a1a, 0xa4aff0ec, 0x4d1f5b4d, 0x2d096a78, 0x2fa1efbf,
- 0x7cd04fc3, 0xad79ecfa, 0xce7eb4c5, 0x5d0fc924, 0x10ab1a1d, 0xd8e7ed02,
- 0x520176c2, 0x9097e581, 0x927fa130, 0x45f8e8af, 0x9fe8b884, 0x37fe9724,
- 0xa5b21c89, 0xd1e43e60, 0x99029ea0, 0x31364846, 0x7e6055fe, 0xf509fc36,
- 0xd0677744, 0x779e75ef, 0x7fec13e5, 0xdb0a5f8e, 0xf27347e9, 0x4dc87203,
- 0x6d08c6d3, 0xfb1dc749, 0xf908395d, 0xe4990cc0, 0xd8b68763, 0x0fca6ffe,
- 0xd214754c, 0x080b67fe, 0x49d9f9ff, 0xcc82da36, 0x3be1eda6, 0x1a1f4e22,
- 0xd99f67cc, 0xe0dfb8e8, 0x40dfdddf, 0x5fc0a7ff, 0xe5a1094b, 0x9e0c1ccb,
- 0xc5d9d9e4, 0x1989ce30, 0xbf4316d7, 0x3213a673, 0x9d4d5688, 0x4490f63d,
- 0x891aebf3, 0xcddb4edf, 0xcf1c0d29, 0xcbf8d981, 0xe80293a7, 0x60ee8e97,
- 0xffc45f7d, 0x64ef38eb, 0xcc3fde3e, 0xfa102b1e, 0x8a97f641, 0xa0725da9,
- 0x4bd153f9, 0x2d056a48, 0xee53191f, 0xd09a769f, 0xe6e9e4f2, 0x721340f6,
- 0xc425211d, 0x1aea7293, 0xc91677fa, 0xad4228ba, 0xee8c0b6a, 0x4a6b0fe5,
- 0x22f9fdff, 0x12fa01d0, 0x6a1fd6fb, 0xa0e9e99c, 0x7b375af8, 0xf4d08796,
- 0x0f2cc0f5, 0xd9f5efe0, 0xd68f10b3, 0x676673f6, 0xfb5e0227, 0x06feef1b,
- 0xfa08d03a, 0xb5b3c73d, 0xea48907e, 0x39fbf423, 0x31c3d13a, 0x9301dffd,
- 0x0964254d, 0xb34d1b30, 0xd2a6d525, 0xe88d6cfa, 0x95e33891, 0x3b69b102,
- 0x28994992, 0x0ff352e3, 0x2637bb61, 0x71c34ad9, 0xef0773e6, 0xb81a55c7,
- 0x6fa50e67, 0x751274d6, 0x2912ba51, 0x75e2c6aa, 0x1a548a5d, 0xddc7038e,
- 0x68425e1c, 0xe1c0cf7b, 0x02d86571, 0x47329fd0, 0xf5c2c40c, 0x42678003,
- 0x4ca24a6f, 0x18f8e6ee, 0xfbbf72fd, 0x338f506c, 0x8e00bb8f, 0xecaa9009,
- 0x0c8f0e3b, 0xb201937c, 0x43fc8296, 0xe02463c2, 0xb91eccfb, 0xe5070124,
- 0x17f0a18f, 0xa42dae15, 0x1412d47b, 0x47ec56b2, 0x0324a4f4, 0xde1157bd,
- 0x4f51290f, 0x42157e51, 0xd78b84ab, 0x129e6a5c, 0x35f06539, 0x193ba9f0,
- 0x5e1cbfc7, 0xe518a048, 0x88d43152, 0xe307c078, 0xed4df92b, 0xbacba502,
- 0x947ee5d1, 0x90218a6f, 0xe17e4333, 0x3bf457df, 0xbdccff37, 0xca91d29c,
- 0xd3396b91, 0x2cdf8a8f, 0x8e92eb67, 0xc82008b5, 0x0f49b964, 0x40241210,
- 0xeb6f0377, 0xbc78a2be, 0xfb5bbf04, 0xe7c86fdd, 0xc9983260, 0x053f9327,
- 0x79bd07fa, 0xf0077ed3, 0x5edf3af5, 0x5d6bcc07, 0x7a825efe, 0xe8c7d38a,
- 0x5daf95d7, 0x81d6ce52, 0xee808d7c, 0x9ea748c3, 0xc6a7d1f2, 0xa6767e02,
- 0x748bf72a, 0x08933b7e, 0x6b75d9ea, 0xd02b7848, 0xb5e594b5, 0xb5e1696f,
- 0x9d3b8e74, 0xd698bebc, 0xed06bcd3, 0x3adbbea9, 0x68870b49, 0x8d8b6b7e,
- 0x85ab1fb5, 0x311f9a45, 0x8a148491, 0xc2c56d4f, 0xbe5a4e95, 0x17eaa375,
- 0x34fd5eb5, 0x2d6725a2, 0xdeb2dfb4, 0xbdf00aa6, 0x3b23ad8f, 0x443849f3,
- 0x39b1dfc7, 0x69239bf9, 0xf9b2143e, 0xf24fd387, 0xd945faf8, 0x022844a5,
- 0x9c3a31b4, 0xae5c7921, 0xa9e50204, 0x7ecb7cbc, 0xa48ebfff, 0x5d363df0,
- 0x45a0aff2, 0x4ccfd63b, 0x769e28d0, 0x3f048168, 0xc0f07f4d, 0xccefcc7c,
- 0xdd00260c, 0x9f9c6e76, 0xc0f14c00, 0x461b99e6, 0xd2617b41, 0x6ce91d61,
- 0x1f47ffd6, 0x00ec3a28, 0x9e994b38, 0x7e0d6a4f, 0xbcf9a253, 0x89b91249,
- 0xadcf214e, 0x1fdbdc21, 0x4f5811b2, 0x8b6de8fb, 0xcdd44ebe, 0xb4eb5779,
- 0x5d7f818f, 0x2009160f, 0x86353bda, 0x923741e7, 0xbeec8af0, 0xc85cefe3,
- 0x5d2913ea, 0xbf2e0e80, 0x96675962, 0x4756f85a, 0x3c717079, 0x1c755ab9,
- 0x897a488f, 0x578bd690, 0x62469ffa, 0xf07ae9f0, 0xe9f58128, 0x8163e78a,
- 0x7ca05d27, 0x9cab830f, 0x1c1eb9ef, 0x6357caf7, 0x21b1f1e3, 0x7fa01eef,
- 0x6177c522, 0x50eb0424, 0x0a24617a, 0x57c9e2fc, 0x9a0bb034, 0xc5c93109,
- 0x7cfbd1a1, 0x1337201d, 0xaf583e22, 0x837e8dd7, 0x81568fc9, 0x6fe630f8,
- 0xb7e4f7b4, 0xc1fb5893, 0xf87287a8, 0x697853ce, 0xcb87bb39, 0x847f4f59,
- 0x732447ad, 0x4f75c21c, 0x5e7561e1, 0xc84c7d1c, 0x97cb940a, 0x817ae049,
- 0xedcddea6, 0x6c06a751, 0x7900dfae, 0x910240b7, 0x134ddf38, 0x42d27ad8,
- 0xe9a05d74, 0x162f44a3, 0x664b9d70, 0x2eb2d7fa, 0xbc9fd1f5, 0x16e9165d,
- 0xd468df40, 0x8734803e, 0x23cd31f8, 0x92474c01, 0x26af4c56, 0x49f34c11,
- 0xa405a63b, 0xaf43531b, 0x422a89f8, 0xfac4c47e, 0xa4e720c9, 0xe58b63da,
- 0x3264d0bb, 0x3cce3eb2, 0x73782d9a, 0xf8ebf890, 0xe75f021d, 0xfc8aa648,
- 0xf17af843, 0xe818b06e, 0xfc2854c5, 0xefccdbbb, 0x0ebe24e2, 0x693dea38,
- 0xdd335780, 0xcd54548d, 0xf06d5a7c, 0x1c2444a9, 0xc41f32c7, 0xd6b8cc63,
- 0xfb7356fe, 0x9c9f98c6, 0x491f23a2, 0x50cf666e, 0x71bdf438, 0x0828d1f0,
- 0xab419e7c, 0x29b23adc, 0xb6494bbf, 0x6b9a5ac8, 0xe8764f74, 0x893f2f38,
- 0x7ceb6747, 0xbe2af0ac, 0xa9b3c181, 0xcb0a9e07, 0xc297fa3a, 0xfea64ff3,
- 0x1db24ca4, 0x86a20bd6, 0xbc56de70, 0x42def9f6, 0xd2e4fe8f, 0x57d66991,
- 0x02d78a4a, 0x069f8587, 0xe37c7f68, 0xe47fea4b, 0x211bfac3, 0xa9ec2a41,
- 0xe60101f9, 0x1a40ad7f, 0xc85e2913, 0xa0eda268, 0x6af5cd70, 0x698b8ecc,
- 0x91f41937, 0x74c90b66, 0xee92cfbe, 0xe43ed023, 0xf41d9127, 0x6df367b3,
- 0x7d695ba5, 0x63b69faa, 0x1e4005fd, 0x0b6d1dae, 0x9fd1b940, 0xf5329e4e,
- 0x112efd47, 0xe836e1f0, 0xe4c3f163, 0x1fb436b1, 0x6fa27c95, 0xc75f2389,
- 0x1d157cb9, 0x9eb0ea71, 0xb094cab8, 0x8ffa1b33, 0xb53e4314, 0x5d61f89a,
- 0xe6cdd49f, 0x30e1c651, 0x59fa9de6, 0x6a7e0040, 0xc03b31f7, 0x3fd04855,
- 0x74da3254, 0xb4dd1ff0, 0x7e42f50e, 0x50531754, 0xd83fa23f, 0x5f3d9e1f,
- 0xd00bed3d, 0xb9d47d7e, 0x92be076a, 0x9fa0e9fc, 0xc8568f57, 0xf8bdfa60,
- 0xfff63b3b, 0x1862a7b9, 0x47cf9989, 0x0bb1d10d, 0xa670c1a9, 0x67a618e1,
- 0xed31da1b, 0xd30b786c, 0x594ae9fe, 0xebceda8e, 0xc0d7e27e, 0x3f0f101e,
- 0xc00f3447, 0x5c75d51d, 0x12a21c17, 0x82802eb3, 0xd36fff06, 0xdaf0bcd8,
- 0x086bc46c, 0x67d54de6, 0xe0367878, 0x9e000a5b, 0xc2223887, 0x77867cd2,
- 0x01d03fc0, 0x3c8e8bca, 0x5cf102b7, 0x9e02c64d, 0x0ca4c937, 0x13e03cf4,
- 0x827d89d6, 0x03800eed, 0xfe69f3f2, 0xc1fa8ffa, 0xf78659fb, 0x9e29978c,
- 0x4b494e00, 0x8eadc664, 0x913b95f2, 0x27d7120b, 0xf9927abd, 0xbdf6bdd9,
- 0xcf00eff6, 0xac894696, 0x68a6bc85, 0xf7b7114a, 0x15824a41, 0xdcdfc1d3,
- 0x28fd3e56, 0xe2b90bd8, 0x5a648757, 0x3a5eb43e, 0x4f2311d9, 0xfd746559,
- 0xb0c276a4, 0xecf2e6e5, 0x074f3990, 0xb7347f40, 0xc43e5cc5, 0x87aef5c6,
- 0xad1e4078, 0xe8b65af3, 0xd3fd7157, 0xea240d55, 0x02f26396, 0x1791a7c3,
- 0x423b13bc, 0x46cb7e74, 0x4c038c11, 0xb3f5b1b7, 0x7ca3be15, 0xd74f2f71,
- 0x5231fa5b, 0x46dba269, 0x193d30c6, 0xddba7d6f, 0x46ce3c56, 0x4db06bfb,
- 0x72a3671e, 0x042292e4, 0x5b9777ec, 0x93f9e3d1, 0x8e126dd3, 0xebb5209f,
- 0xfbab8522, 0x4adfe23a, 0xee4cbef1, 0x2c7c828e, 0x21fcd62b, 0x30fe4750,
- 0xd51263ca, 0x15f66261, 0x700253c1, 0x6c4a7850, 0xfb044e38, 0x0738a6e9,
- 0xcc997dfb, 0x4a365dfa, 0xf6376823, 0x3655e703, 0xd80ce119, 0x34fd0904,
- 0x1555974e, 0xa34df739, 0x9f554ed9, 0x2667fd05, 0x78c16705, 0x7e6fb946,
- 0x1963fa29, 0x2bf4ccc3, 0x0167d477, 0x2206547f, 0x4e7f80d3, 0x926c5f7b,
- 0x36b7bce9, 0xf144bf10, 0x702b9eff, 0x7357f41b, 0xb008fd7b, 0x5e06df7f,
- 0x3b2a0098, 0xa5ac7a80, 0xa25fa564, 0x148972e5, 0xca3f2995, 0x25bf0f13,
- 0x2a1a4017, 0x938b3886, 0x477d33d4, 0x35224bf5, 0xf5231cbd, 0xa27e218f,
- 0x72d03c80, 0x60256f55, 0xdba8380f, 0xef863270, 0x1e734c94, 0x7cd8fa6c,
- 0x72e37a7f, 0x27e79829, 0x09fe0387, 0x49dde9da, 0x26927fcc, 0xde000bfa,
- 0xa6ffaf7b, 0xc4fcf006, 0x67f93366, 0x5a4d7f56, 0x79696ffe, 0xfee26810,
- 0xd5fcb4b6, 0x80f1bcb4, 0x979c5697, 0x9432ca63, 0x24f0050b, 0xbf07f932,
- 0xe41d67be, 0xcf5bf878, 0x572f58db, 0xf835bc37, 0xa720e1c3, 0xa43f831d,
- 0x052d59c4, 0x3e42ff91, 0x1c28b5f0, 0x098f9992, 0x62134f78, 0x18176e52,
- 0x5a9c9bf6, 0xdc947488, 0x988ea9d2, 0x8fc0ddf5, 0xc1ddfcb2, 0xf4878e1f,
- 0x78ad4c6d, 0x0120a455, 0xd768d03f, 0xe018b713, 0xe234effa, 0x1fc479a9,
- 0xa47338a5, 0x7a6a78b0, 0xf30a285e, 0x09fd5272, 0x233dd3eb, 0xf0c56b5f,
- 0x3b0fc581, 0x3f20ad94, 0x61b68cb4, 0x7865b35c, 0xf90290e4, 0xd1406a0c,
- 0x5dca677a, 0x4c6d8821, 0xe37c63cd, 0xd4f5b3f4, 0x7e8c3c35, 0xbdbfa198,
- 0xad5e1f1c, 0x67b3f51c, 0x31ded9a2, 0x2b2701d6, 0xdb36f4a2, 0xa694ce51,
- 0xbe82c54f, 0x9b539a7e, 0x69e51a76, 0x233fb9a4, 0xe36ed1de, 0xc96b8bf1,
- 0x593768b5, 0xe1fd12e2, 0x71f86bcd, 0xdcbcd913, 0xfc1849d3, 0x5189f4e6,
- 0xcfd79bc4, 0x9bd866f0, 0x9bbf3e1e, 0xfc04234a, 0xf3f89ebe, 0xeb6f0ccd,
- 0x7fa28baf, 0x29ec7eb7, 0x85bd67b4, 0xce3f261d, 0xa1ca1ef8, 0x76c4fcfe,
- 0x18f6a1a8, 0x23711bcb, 0x19e9a78a, 0x61ebbd69, 0xaddbb72b, 0x92275374,
- 0x4763d062, 0x8315a747, 0x84b7bede, 0x3cab4ec2, 0x6297587a, 0x7ef2adf0,
- 0xdf867cd4, 0x7cd8cb7b, 0xd3f47b69, 0x93989def, 0xf266e304, 0x7f11b0f8,
- 0xebcbf1ee, 0x284f78cd, 0x2d85c4b4, 0x67eab77e, 0xcc4b52f4, 0x5f39abe5,
- 0x57a7222b, 0xe8ce192a, 0x4f3e3035, 0x84bcf832, 0xdf3279f1, 0xd12f4837,
- 0x921d010e, 0x4dff994a, 0x4df37e2c, 0x5e8c1d29, 0x00c88f37, 0xa9fefc3f,
- 0x97663edd, 0x7126ba30, 0xc6efbc7e, 0x71c80211, 0x40268972, 0xc33e727d,
- 0x13c53253, 0xa5c977ac, 0x4ef6efcc, 0x525db0d4, 0x0b5ba309, 0x5fe14c7c,
- 0x898a7403, 0x5b4b3b1f, 0x6b7fa075, 0x741d4ef1, 0xe1c53259, 0xd4cf0a20,
- 0xd81b0a52, 0x805fb49d, 0xc51853d7, 0x49525ab8, 0xfca5d870, 0x82a2427a,
- 0x10f887cd, 0xe94b686c, 0x7e58253c, 0x20b26268, 0xa7ef7ed0, 0x80f1c07c,
- 0x8f173c71, 0x785fdfa3, 0xfddcf512, 0xc8364df0, 0x1cebf6a9, 0x36a5279a,
- 0xf707f83f, 0xf108e697, 0xbcc6e7e2, 0x2acb83fb, 0x35f812c7, 0x9572fc31,
- 0x16dee3c8, 0x22475dfe, 0x57c82e6a, 0xa5f76f48, 0x830feaf5, 0x65e47aff,
- 0xfecbe312, 0x87a189f4, 0xb21824dd, 0x1fd5f765, 0xdef8ce92, 0x7940179e,
- 0x24ef03eb, 0x8a52afc6, 0x9136fcb9, 0x5e867fdb, 0x140792d1, 0x00a12727,
- 0xd72277ae, 0x02da4f4f, 0xf054c50b, 0x4eb8c3bb, 0xae74c8b8, 0xca9f1937,
- 0xe6a6ff9c, 0x4ae2bd33, 0x9776b089, 0x903aa78d, 0xa834d6df, 0xc65a1fa8,
- 0x439ed5de, 0x7866b0f1, 0x73be1f93, 0xb9196b8c, 0x3cdbf68d, 0x2b70797c,
- 0x30fdc00c, 0xac22bfd4, 0x8d5f8c83, 0x0e03307d, 0x61d21992, 0x7e09cc9f,
- 0x2467e011, 0x24905fdb, 0xeb8fb512, 0x4795df1d, 0x6967cde1, 0x0dc19f28,
- 0xb6ebc9fe, 0x6f9c2ae0, 0xa2946b7e, 0xc99bce9b, 0x42216acb, 0xebcc225c,
- 0xb21e7c72, 0x9f8ebe31, 0x025df7f6, 0xe1c4d3ec, 0xdb22dddf, 0x472d59a7,
- 0x7e085088, 0xf289ed1b, 0x6a6ceac9, 0xa381c797, 0xd56bf391, 0xc3f8672e,
- 0x89ab7e18, 0x75f29924, 0x1fc233fb, 0x7711fac6, 0x514fb80a, 0x4358d1cd,
- 0xcf00b23a, 0xf61a29ef, 0x48eb6b57, 0xe9177c83, 0x78025b4e, 0x8b8f0310,
- 0x5277fd74, 0x90b8c4be, 0xd6eb607b, 0x81a7f0e5, 0x4085d10c, 0x0fa9e4cb,
- 0x178e9879, 0x69e307dc, 0xd2bf2b2a, 0xf5f0e371, 0x4d7cb10b, 0x6a5957c4,
- 0x147f6be5, 0x129ddaf9, 0x9fb77ac5, 0x8fc1b5f1, 0xad1f9c89, 0xbf8c687c,
- 0xd6afc79e, 0x335f3e72, 0x708549a1, 0x9b51dadf, 0x2ce69e30, 0x7c015cda,
- 0x25aa32de, 0x64de7c0c, 0x17df35f0, 0xdb2efea1, 0xa35ad31f, 0x72264eb0,
- 0xeed456be, 0xeb7b9006, 0x38935d7c, 0xbe0534bc, 0x5f39b806, 0x93f807bf,
- 0xae08ddfd, 0x076bd7c1, 0x45bad7cc, 0xfed39b6f, 0xc2d927fc, 0xf1891ed7,
- 0xd7c067e7, 0xb30a4f00, 0x963edc63, 0xdfea7eca, 0x06e7e9c7, 0x6b99f989,
- 0xe5ac1cb9, 0x1fb6b072, 0x223ff839, 0x9afe03f3, 0xc98b3072, 0xe5a24381,
- 0x8cae9389, 0xd3b0251f, 0x9e7bc8e3, 0xe1b5fc24, 0xbc4334de, 0x27fe3c72,
- 0xbe84cd30, 0xcfd234f4, 0xe4c0e744, 0x73c98f3b, 0x76be727f, 0xfe387c68,
- 0xa7f46453, 0x26922ef8, 0xffbe395c, 0x7215705a, 0x43f0367e, 0xb728c582,
- 0x3a667a31, 0x86a92bc0, 0xd304799e, 0x28ad79a9, 0x81be86a7, 0x2bfa0a58,
- 0x3bc62b6a, 0x68ad999c, 0x98f3399f, 0x24fc31be, 0xb88d7ceb, 0x33d71378,
- 0x02217949, 0x853d9feb, 0x9eaa3f70, 0xcc9951f9, 0xd5e2301f, 0x18a8fd86,
- 0xbbd0d47e, 0x79a79f70, 0x97da3d78, 0x3bd637cd, 0x36c3ede2, 0xf077eefb,
- 0x3ed35f4d, 0x0e5a1aeb, 0xbbc9aefd, 0xc3b3c49f, 0xfb18798c, 0x6e3e4e46,
- 0xa8b51e73, 0x32df5c60, 0xc76adefc, 0xfeb26734, 0x7ae7be7a, 0xbbd1ee57,
- 0x54768f2c, 0x6f9f8c6e, 0x03e0c7e9, 0xa343e885, 0xe4183710, 0x4ce7091e,
- 0x3f04849a, 0x924dc7d8, 0x90729d20, 0x5aa97b1e, 0xff401689, 0x9cbc6627,
- 0x3db2f685, 0xbce406b8, 0x0380abe9, 0x53aba9e2, 0x96c6f35e, 0xe6f19d9f,
- 0xa56cc1b7, 0x7ee2d5df, 0xb148838e, 0xdc2763fb, 0x4b7ed1db, 0xe9c737c8,
- 0x09ae149c, 0xcc13c402, 0xbf8f0ae5, 0x72e69928, 0xa45fc799, 0xe7394b14,
- 0xbe34b90f, 0xeb93795e, 0x7602df15, 0x1cc4e74e, 0x713bd716, 0x30674f2b,
- 0xdbc73efe, 0xc234f375, 0x535feef5, 0xf6e5251f, 0xe29befc2, 0x9922f8c7,
- 0x3ebb4765, 0x2b9d852b, 0x26e7b120, 0xa26b5fe0, 0xccfc6244, 0xff9781a1,
- 0x61d4f108, 0x06cabe0b, 0xea156b3c, 0xdb465861, 0xc79c6ca5, 0x28f74263,
- 0x3ae6cf18, 0x02f5fb8b, 0x6a72e345, 0xdbf40b12, 0xef8521db, 0x3a52c0bd,
- 0x91057b8f, 0x37c0ecbf, 0x8c29d022, 0xb1448ba9, 0x303a43de, 0xe61b089f,
- 0x5187e0b9, 0x33c44bbf, 0xc61b614c, 0xf6cc7e8d, 0x7888d643, 0x03a8836e,
- 0xedc9bfb4, 0x4297f82a, 0x1ae77e88, 0x40be77f8, 0xc4c8316b, 0xc608b2e0,
- 0x7cedad93, 0xa039d853, 0xaffb7a3e, 0x5237df4f, 0x548f8173, 0x1ce8372c,
- 0x694ef514, 0x5ff2df42, 0x12f38189, 0xdc58abc6, 0x2a5f5acd, 0xde4017e9,
- 0x0bc2e5ac, 0x7e053a7f, 0x6467aaf4, 0x3ca7a3f4, 0x41bf4723, 0x045b35f3,
- 0x076d53f4, 0x770fe89d, 0x51f2c23e, 0xfb43a28f, 0x8c05db73, 0xdbd9d507,
- 0xe201bdef, 0x0488cf8a, 0x19708dfd, 0xe29d8bee, 0x59fb2673, 0x80079cbe,
- 0x9a1cb66a, 0xec57df0b, 0x77d813b7, 0xf16e79a8, 0xf9a06fb7, 0xf464c7c5,
- 0xac766a51, 0x657f6050, 0x40885849, 0xc1326bbe, 0xc4fb43f1, 0xbeda0ef0,
- 0x369edbcb, 0x2bfb0dc7, 0x455da20e, 0xa7b4f6e1, 0xa9f4a6cd, 0x0d353f0c,
- 0x2ddcabbe, 0x98ffc1f8, 0xa38eccf2, 0x9abbf419, 0xa73c0427, 0x45cbb550,
- 0x9cba18b4, 0xdfa3136a, 0x9d33f880, 0x8bc5f827, 0xc034eb49, 0x0d8ecd7b,
- 0xb713168a, 0x9230d33c, 0x7cdef668, 0x1c7413cd, 0x93ed5dfa, 0x58a61f82,
- 0xe041236b, 0x9ce7ce8f, 0x30dcdb65, 0x08ca15bf, 0x59abcc0f, 0xc38b7681,
- 0x7ec1f6f3, 0x8b78657a, 0x57d68d32, 0x2945b23e, 0xaaa7e18f, 0x2d10d75d,
- 0x6d4e3f86, 0xd4bf4dce, 0xae867b7a, 0x54f0b15b, 0x88b7a612, 0xc4665614,
- 0xc8767bec, 0x453f9c49, 0xdf06ff53, 0x18275e87, 0xef3d0ac7, 0x741abc41,
- 0xbd32a65b, 0xbcedd060, 0x7528e9ca, 0xb388cd17, 0xd02f7aaf, 0x2af10ec1,
- 0x1bfbd315, 0x6c6e987c, 0x9b3e90d0, 0xe1577f00, 0x7b9606be, 0x88629127,
- 0xa275788b, 0x3c9f52c2, 0x21962f5d, 0xf960124e, 0x8283dbb4, 0x1bf98976,
- 0x383926e9, 0xb75c820f, 0x964c4fc9, 0x49bebae8, 0x7e252e09, 0x77b4be3a,
- 0x6075c972, 0xc8e705a7, 0x1d9fb0a9, 0xe8f160ac, 0xa2e40f88, 0x7ccbef89,
- 0xd6f2664b, 0x7c60a194, 0x8bf7d364, 0x41eda1b6, 0x7d365e18, 0xec277cbf,
- 0xe67ed1ab, 0x1aae54ca, 0xee4fda65, 0x9b49fbe5, 0x4fd4d13b, 0xa30adcda,
- 0x8fd8c59f, 0x6cfd6073, 0x19bd7b9a, 0x4695b99e, 0x8fd8f53f, 0x4af36067,
- 0x199263bb, 0xb1aa3b9e, 0xfddbf49f, 0x06881f68, 0xdc7690ff, 0x4eef7517,
- 0xc496b71a, 0x1fe4d1f2, 0x2a1e78c3, 0x947cb155, 0x24c13138, 0xb27a494f,
- 0x74a83f29, 0x6a7da9b0, 0x9f54c720, 0x85b5765e, 0xbfa8dd2f, 0x8a814f31,
- 0xab38b126, 0xbd415832, 0x81d83c53, 0xbb06bbf9, 0x75dcef51, 0xb02af07d,
- 0xd05600f7, 0xc12977f3, 0xbe1c6a31, 0x0812f3a1, 0x1b34cfc6, 0x32ec7da4,
- 0x7939efbe, 0xde2357c8, 0xd9d7dfa7, 0xd12447ba, 0xf14a43fc, 0xadef3023,
- 0x8de3b332, 0x9d824338, 0xce6bfea0, 0x8a16da2e, 0x50cb6bc1, 0x6f422fca,
- 0xd0722dbf, 0x73b8fc07, 0x4a576ff5, 0xa1a6be14, 0x7a6e1e0a, 0xe1edfe5c,
- 0x9b99b510, 0x00fb9687, 0xea8576ff, 0x15f1d88f, 0x8e3e7e3a, 0xdfc61bbf,
- 0xd93b332b, 0x673dbe3a, 0x477c69a2, 0x7c698556, 0xa7c74287, 0xf56fb1f2,
- 0x8a7c7c3b, 0x7909ebbf, 0xc7077e56, 0xe05567b7, 0xa90acdf8, 0xd09f8d30,
- 0x9001fe33, 0xcdfdc39f, 0xf37ae73f, 0xcd2ab3fc, 0xfcd857f3, 0x80feae8f,
- 0xf3809f8f, 0x80fe597f, 0x92ab3fcd, 0xfacedfcd, 0xdbdf19ed, 0x6157ff83,
- 0x37f5affe, 0xe649dcff, 0x36ab0ff9, 0xc6cedfcf, 0x27f5637f, 0x8e377c7c,
- 0x09fca6ff, 0x6ab0ff9b, 0x07b15f1c, 0xca47c0fd, 0xf07a8490, 0xa461a99f,
- 0xa35d4061, 0x923a40e3, 0xc837a9c5, 0x5dc70839, 0x3eef8c09, 0xe6fca04f,
- 0x24a7d5ee, 0xea90254c, 0xd3ce5acb, 0x158bbb55, 0xd0842fe6, 0x41c4585f,
- 0xc45fb85d, 0xb46c8cf5, 0x78538787, 0x218bf73b, 0x78dc2fc8, 0xac5b9e23,
- 0x77dc13b3, 0xfa3056a7, 0xc0f1ff1f, 0xf3b1ade8, 0x5a8ba6b2, 0x13fecb65,
- 0xef38c783, 0xa6ab2454, 0xa78829fc, 0x127c3d50, 0x9e9a1ffc, 0xb478e996,
- 0x83f043fc, 0x1b958aae, 0x768c2e76, 0xce9f2277, 0xfe1cbbeb, 0xf7c31253,
- 0xdc053ba9, 0xc37cf847, 0xd9f40552, 0xc99756a2, 0x74e3a86f, 0x8ece7eea,
- 0x79c68dfb, 0x14505bbe, 0xc1fdf909, 0xbb051d6f, 0x41e6f171, 0x276eefa6,
- 0x1470d5e1, 0x79fac173, 0xff3a5543, 0xe3eccadb, 0xeb6b8c44, 0x9c1c5843,
- 0x49b8810c, 0x7906db59, 0x52dccd08, 0xf9ec9b26, 0xfce6835b, 0x7ce6156d,
- 0x6d961ca7, 0x112ccf60, 0xefda16c8, 0xcb65ebf7, 0x8e3600b9, 0x76e64957,
- 0xbbef1b25, 0xb4198694, 0x8e90fbe8, 0xe9156283, 0xdf65573a, 0xddd4f01a,
- 0xae28932d, 0xb8a91dc7, 0x454a140f, 0xb2a82dbf, 0x9de15b79, 0x00f43b2b,
- 0x8fee6785, 0x15a7c444, 0x2e838efe, 0xf3ed46dd, 0x907fcd8e, 0x9d6c7e21,
- 0x3bfe158f, 0xa3e75b96, 0xcc3eb02a, 0x19cb590b, 0xa9f9589f, 0x36f17f6e,
- 0xf37b3db3, 0xb5fb58b6, 0x530cd76a, 0x56f8497e, 0x9bc5fb53, 0x17ea99e7,
- 0xd5312eb5, 0x6a59682f, 0xfd0bcfca, 0x8efed4c8, 0xf54c2be5, 0x635fafdf,
- 0x62adbfaa, 0x6b7f2983, 0xfb5321f0, 0x98b6ca5b, 0x47076dea, 0x68e4077d,
- 0x9e22ebd5, 0x3ee0bdfd, 0x9bd82f75, 0xee12dc17, 0xed447e73, 0x33839015,
- 0xb4815ed4, 0xf478ff73, 0x2c1ea9a7, 0xf9a24d87, 0x2d5598ca, 0x0997a099,
- 0x6572cfea, 0x24d0aac2, 0xd7b0178a, 0x9b887ca9, 0x041d1215, 0x0f724cce,
- 0x318b771f, 0xa9971df5, 0x7d054cdf, 0xb17adf7c, 0xdd797e23, 0xd4c379d6,
- 0xaf6a7e38, 0xb02192dc, 0xce5975ce, 0xb569189f, 0xb1a73ce5, 0xeb817dbf,
- 0xe9856ad9, 0x19bdea83, 0x86736193, 0xe223e5fa, 0xf9ec9b9d, 0x0db0223e,
- 0x53feb048, 0x98861f81, 0x76aa6bf6, 0xfbe49ae5, 0xe11121ec, 0x409d05aa,
- 0x5217eaf5, 0x72028d60, 0x35923d16, 0xa1c0346b, 0xef4055af, 0x75c54fec,
- 0xe9436cfd, 0x3fafd836, 0xf4c010d3, 0x4c3286a3, 0x3104354f, 0x02a1b0fd,
- 0xf50d93d3, 0x2c347698, 0x86bdf4c7, 0x36efa610, 0xbbfa60b4, 0xdf4c5686,
- 0xe98cd86a, 0x4c610d1b, 0x4c741b3b, 0xd1e8790d, 0x0f6e01bf, 0x84d71b1b,
- 0x2e7cc3db, 0xe73da98d, 0xf7ff70c2, 0x11f3fbbc, 0x7f9fef60, 0x6cfb8ecb,
- 0xcacbe1fd, 0x51d3fd6f, 0x3ca57b47, 0x639d083c, 0x8133bd6b, 0x2369c9d1,
- 0xec1c64a5, 0xcff4ecff, 0xc4bcc7cf, 0xfd84f52e, 0xfa713c33, 0xfa5d7885,
- 0xf444e9e5, 0x949982ee, 0xfe1ea71e, 0xf7e822af, 0x607fac02, 0x71111c07,
- 0x6dd1261d, 0x95d7a07e, 0xe1784de2, 0x2f1059f7, 0xbf83d73b, 0x8b882cf6,
- 0xd8a8ab5d, 0x3b36f9ff, 0xf9d2f881, 0xcfbc2e03, 0x36d8fe75, 0x32e3c82f,
- 0x3d8e189f, 0x6b4d6147, 0xb761d922, 0xe736efc9, 0xa50ab7cf, 0x689a1e78,
- 0x0347b389, 0x3861a95f, 0xe0d9d20f, 0x67e8d4c3, 0x71c14f99, 0x65caecce,
- 0x5e7e3371, 0x424eec83, 0x277ea57e, 0x869fffb6, 0x0c7ebfa7, 0x23690878,
- 0x5e08381f, 0xdb98bb71, 0xf97efb7f, 0x814cfa49, 0x20392af8, 0x82f60e7f,
- 0x1177fe9d, 0x6122651c, 0x2eb7e8de, 0x63ec8622, 0x69b77ca0, 0x669dfa3c,
- 0x7317f4f8, 0xe6b7c52e, 0x042234fb, 0x9c46bf68, 0x80fe0aa4, 0x02f530f3,
- 0x788cabc6, 0x6ee49749, 0xc6f4c611, 0xbc78ea4b, 0xa1d1c6b8, 0xb9d16904,
- 0xee4bdcb6, 0x38699e9f, 0xaf39c2a6, 0x02ab470a, 0x64454fce, 0xb9e80954,
- 0xd2ab6d73, 0x12ac1ec0, 0x2f15dfcf, 0x67679b7e, 0x6125bd71, 0x8ebcdbb9,
- 0xb420fe72, 0x1d9ca35f, 0x8a9f7472, 0x31b59fc9, 0xefdadb3b, 0xf6c0fb04,
- 0x1f776a2d, 0xd683769f, 0xfbb54f17, 0x3e30553f, 0x5c53112e, 0x7bdfc0c9,
- 0x9d82604a, 0xd772a9e2, 0x7e8f68fb, 0xdc468724, 0xd4fd097d, 0x9f6e7e77,
- 0x88727ce9, 0xf338c3b4, 0x8881f227, 0x743bcb76, 0x15f8fd3d, 0xe4db9d99,
- 0xf67b80e7, 0xfebef995, 0xdf9b9e02, 0x84e78556, 0x8ff7de3e, 0x242dff68,
- 0x81d22f01, 0x1d8116b4, 0x4ad88e79, 0xc8e74f01, 0x31f1de6b, 0x3a95b874,
- 0x05ef404a, 0x863b662d, 0xfca6bfda, 0x7ce6cde2, 0x06999939, 0xa37ca4fa,
- 0xce02c24c, 0xb37f54cf, 0x177ec55d, 0x5826fa93, 0x8fee2557, 0x348957cc,
- 0x9ad5ea84, 0x34567f67, 0xb411c28f, 0x88c83f33, 0x66492cbf, 0x4a656076,
- 0xc27d8158, 0x7fc6da0f, 0x832006f7, 0x7104dc3d, 0xfc489228, 0xfc5f483b,
- 0x56fc295e, 0xbaf58d78, 0xc3881c4f, 0xe212ee21, 0xdad603ee, 0x86cf6e05,
- 0xe7c03d30, 0xc705f86d, 0x7615f92c, 0x2452de7e, 0x9cfdd022, 0x12d908ea,
- 0x851fdeb1, 0xbb5edc78, 0x7106957f, 0x7b6ac0fc, 0xdfdc6f6a, 0x0f649768,
- 0xe159f962, 0xf73c72d5, 0xf00b4520, 0xef8f21de, 0xc41f9c2b, 0x9c016f04,
- 0xdc40f523, 0x3a75ce1e, 0xdf215bbd, 0xf3c0a9e4, 0xef20751f, 0xbc7bbfb4,
- 0x9c418ed3, 0xa35a41da, 0xbb5fe53a, 0xa01fb2cf, 0x902ef399, 0x5067d04b,
- 0x09a2e780, 0x235cb9c6, 0x7e3cedcd, 0x2e31fe73, 0x4381748f, 0xdf39ee3e,
- 0xe14770e6, 0x2899093c, 0xb7f1ed9d, 0x63dfc072, 0x56fdc3f0, 0xcaa77f68,
- 0x7df2d7da, 0x9edf3bdd, 0x097c9e9c, 0xa5f7547d, 0xeb31c240, 0xadd49d48,
- 0x7dd61f00, 0xd7f96129, 0x5d1a9bd6, 0xe6f46355, 0x59f04a2b, 0x27a604fb,
- 0x8e813e01, 0x64dfbb13, 0x027087bd, 0x2f4261f8, 0x386d7c3f, 0x7f498852,
- 0x8f04a7bf, 0x6be383c5, 0xd3ebeff7, 0xbbe009ff, 0xf3feb1ff, 0x11dff4fa,
- 0x679afe0f, 0xd10becf7, 0x17f2b5f5, 0x10e1780f, 0x6b52c7d3, 0xacef9c1a,
- 0x0bdab1de, 0x1491f972, 0x3f5d02f2, 0xef718b0e, 0x0c3ba6e7, 0x70ddd3be,
- 0xf396b08f, 0xaf9f99dd, 0x2ff836fb, 0x5590ef9f, 0xb2ec0f8c, 0x2994ed47,
- 0x3096db6b, 0x7f65d8f9, 0xf19be59f, 0x7edd53bc, 0x7ca8beb3, 0x0d3481fc,
- 0xb885550f, 0xff451cff, 0x7ffb76a0, 0xabbb034c, 0xdea3748e, 0xe3077eb3,
- 0xf68c997f, 0xb1253cc0, 0x0e71bd6f, 0xa5e38eab, 0xde1d6dae, 0xbb6baf13,
- 0x9a1334f9, 0xad3bf40e, 0xbb7055df, 0x9f30e1df, 0x42f034df, 0x5feeccc2,
- 0x0583c4f5, 0xceb853ef, 0x2bc57f6e, 0x29f2c7e4, 0x23e77fd3, 0xa5fb1e0b,
- 0x755cbfd6, 0x6b18fd52, 0xb4eb1b5f, 0x2bfb9fb6, 0x2d5a5807, 0x0fe0bd47,
- 0xf1916f56, 0x9ef57bbc, 0x861f3b6d, 0x76dbccf8, 0x7fda70ff, 0xde979ed5,
- 0xabe69eb8, 0xa653929e, 0xe1b869b3, 0x9f41a29e, 0xf2dffa3a, 0xa8f4bd71,
- 0x4525fa7c, 0x7fcacd1b, 0x974bdc9c, 0x290ea7aa, 0x7c5f7464, 0x521c894c,
- 0x85b67ed8, 0xa7f7913e, 0xeab15f81, 0xd0142f89, 0x141f1f5f, 0x1c767a48,
- 0x09796e7c, 0x13c063ed, 0xabd393d2, 0xf6967e87, 0xa82e9475, 0xb2f42d17,
- 0xaf98fbb6, 0xc42fd007, 0x3f7f29e3, 0xb7d84bf9, 0x0fdd9df9, 0xf278a878,
- 0x9f30bc9f, 0xe33d52d3, 0x4ead9ff3, 0x1520fb83, 0xc54d2872, 0x3c579594,
- 0xbfe403fa, 0x907fc7c5, 0xeac5cec6, 0x575cfc19, 0xd173cc06, 0x9e707323,
- 0x7c8824e5, 0x7633f158, 0x4482fccf, 0x238a9f4a, 0xd839f727, 0xab7a763a,
- 0x4f11371d, 0xfb0242c3, 0xe189af18, 0x640f181d, 0x607f0de7, 0x65913fec,
- 0x60e0bf98, 0x30e45af4, 0xa5d1f1ee, 0xb77f9624, 0x9d03b737, 0xd3d50cce,
- 0x475c8e21, 0x87c710a4, 0x2bf69170, 0xce9a9f1e, 0x52681dcf, 0xea8eff11,
- 0x0e5029ff, 0xdd65dbed, 0x8efa6059, 0x1deecc5c, 0x3e3e4eff, 0xec013b85,
- 0xd469d3d7, 0xbf338c1e, 0x9d630e03, 0x0c5676a6, 0x3bc8c59f, 0x6bedff93,
- 0xf21bbc98, 0x0a519e1f, 0x609d9ff5, 0x81df0472, 0x8ae142fd, 0xa1fd63a6,
- 0x07ea02d9, 0x93c6893b, 0x9732edf3, 0x95bd7373, 0x12fc285f, 0x7c3dc7ac,
- 0x2324e303, 0x2dbed01d, 0x8fbf48df, 0xae30abd5, 0x86bf6fb7, 0xfae62f1c,
- 0x1f45ad60, 0x07524790, 0x2d5b7fb4, 0x0c3e7787, 0x35e54bf2, 0xcafc81a4,
- 0x27c15ef8, 0xf1bc8fbb, 0x9fb72a3d, 0x35b90c44, 0xdcab55eb, 0x409dec56,
- 0x27edc9e2, 0x2b893f6e, 0xae3cb4b7, 0x903bbadc, 0x7ad6ff9f, 0xd3e3c0d5,
- 0x7a1a3c16, 0x5a7c3fb2, 0x1db7e4f5, 0x493d5c5a, 0x45209dff, 0xe0d1f97d,
- 0x2aff8343, 0xcf06a5ff, 0xa9f0f50b, 0x7c3d87c1, 0x9f61f06a, 0x8f09a478,
- 0xe1bbfad6, 0xc0853a6f, 0xcfc63273, 0xfdb00fab, 0xd1ddfa67, 0x2f888521,
- 0xd239971d, 0x4a48747a, 0xc96c3e6c, 0x75ed2c47, 0x69603e4b, 0xebe4b41f,
- 0xf7abed4d, 0xb9d8511f, 0x9da9a89e, 0xe4a7fcb8, 0x01f13883, 0x6baa1d63,
- 0x010954fb, 0xf1bbb87f, 0x0925797b, 0xfe5e2079, 0xf2f188bc, 0x26e38a2e,
- 0xeed74e3a, 0x608f7c6c, 0x57c593b5, 0x2f6ed4ba, 0x93ab93d8, 0x553bbe58,
- 0x683d0269, 0x593b7794, 0xd02bafdc, 0xb18a4ded, 0x203fdeef, 0x08ef1ea2,
- 0x7e78d293, 0xa140de28, 0xfd20edf8, 0x80fdb3d5, 0x61d7b02e, 0x30ac84bc,
- 0xd154e3f0, 0xe21cb59d, 0xde22ad35, 0xe2b85b6b, 0x239c2f16, 0xfb903ae9,
- 0xbe5a329d, 0xdb22d7e8, 0x52e90ca6, 0xf81f8c46, 0x9a6d0911, 0xf5fec024,
- 0x059fe47a, 0xb85f9807, 0x797c7d70, 0x95dfe4a8, 0x4054efbb, 0xee7f52ef,
- 0x87beec64, 0x23c54fd1, 0xff03f296, 0x15a6e5c8, 0xdb951fe3, 0x1e41f5cd,
- 0xe4ec183f, 0x92c7bee7, 0xb77fdcb1, 0x9e0fdec5, 0xa77fe62a, 0xeba7d28c,
- 0x3ce04898, 0x2203f9c1, 0x6efce7d2, 0xe3007e76, 0xbf01d7fc, 0xe7b12b77,
- 0x7c82cea9, 0x1ebfd55d, 0xefccfb3b, 0x3e06ee8b, 0xc14ef7da, 0x767a694f,
- 0x7e23dbdf, 0xdf67f905, 0xf4877acc, 0xa0e53f6d, 0xba55f713, 0xff907a0e,
- 0x4dff9ebb, 0x7f90ddd6, 0xecf18ece, 0x145f83ae, 0xad753f00, 0x1e8057b4,
- 0xefe7e2ec, 0x45ff3d56, 0xbfae0741, 0xa9c7488d, 0x9f4fe64e, 0xef5ff03f,
- 0xf381fdc1, 0xc0ace807, 0x42e838be, 0xa5fbaaf9, 0x5d6fe313, 0x14517fcf,
- 0xa5fc27eb, 0xfbe5a9f3, 0x521e5d9d, 0x4be017b6, 0x7544fb62, 0x1b6ebabf,
- 0xd3512fbc, 0x40594876, 0xf0bca7eb, 0xafd002a7, 0xdd997b5d, 0x3c7729d4,
- 0x8179fb0a, 0xca340f35, 0x209d5e94, 0xff698364, 0x0128de6b, 0x978bea39,
- 0x715c613f, 0xfc58f8a0, 0x043e0d7f, 0x4f3fe99d, 0x29854c18, 0xdef8ff07,
- 0x0e27a03b, 0x8d2f91da, 0x59127ef9, 0xe5ccf681, 0xfff4dde6, 0xe885bcdc,
- 0x03bde640, 0xefe13de6, 0xc0d7de77, 0xbed4a1a1, 0xcf97d072, 0xf30bbf9f,
- 0x847e3c7b, 0xfefc8077, 0xfcf9dfd2, 0x7bee98af, 0x97bddd29, 0x7f87f79f,
- 0x9feef3e7, 0xcb9ebfee, 0x79c2aee9, 0xfe17ba98, 0xa95df084, 0xfe12939e,
- 0xbfbde5be, 0xfef61bf9, 0x35bf9b5a, 0x93cf1b27, 0x70b0c03a, 0x40b6667b,
- 0xc8ed7178, 0x9dd82a99, 0xd5ef3f62, 0x7e60484c, 0xf7b02895, 0x1650c821,
- 0xcfdc240f, 0xf80d6382, 0xdd9b880e, 0x4ddc933b, 0xc9137768, 0xbc53aedf,
- 0xbe7abdac, 0x911acf1f, 0x21056f71, 0x8fc9399f, 0xbf8b6ef1, 0x5d1028d9,
- 0x74aef6a0, 0x818f37f5, 0xb48f23df, 0x9805ed45, 0x33690fbe, 0xaaca638f,
- 0xdc87f262, 0x53bce6f9, 0xbcede733, 0xf061073f, 0x0c247c3b, 0xd4716cf1,
- 0xd3ce1561, 0x02256389, 0x4938a54f, 0x0efc086b, 0x7dfccfbb, 0x7ee10252,
- 0xc7865fef, 0xa716048a, 0xed718512, 0x9471e03a, 0x78dce30d, 0xe2f11b48,
- 0x08baf7c7, 0xf17baff7, 0xf80ed4da, 0x663fc094, 0xd5fa17f6, 0x12d3fb84,
- 0x691a42ef, 0x76e69dd3, 0x2cbe8fdc, 0xb25d189d, 0x969d39aa, 0xd062e899,
- 0x4c7d0e21, 0x7cf03174, 0xd2b1f4a5, 0xebff8ac5, 0xf75f1813, 0x2e832f47,
- 0xef1d6e99, 0x7fdcc9d7, 0x133f0128, 0x820199f2, 0x7fdcabfb, 0xbc745290,
- 0x7eaa24a7, 0x7e0097bc, 0xe01a945c, 0x86deef2f, 0x3f73a4f1, 0x00dbff7f,
- 0x44afd54f, 0xebf8a0e2, 0x5121eddc, 0x2b0a5ef8, 0xb6569fe0, 0x404fb889,
- 0xacd168a4, 0xc3627d98, 0x85faa80f, 0xb953e707, 0x4e9e1ed7, 0xf7dcafbf,
- 0x61da0141, 0xcfd1bb2b, 0x605cfd09, 0x14750f74, 0xa5703ec0, 0x2b11fcc4,
- 0x6049acbf, 0xcfb396f1, 0xae20cab9, 0xe762ec23, 0xb7232b7f, 0x7398f6c8,
- 0x9904a14d, 0x739e9bc5, 0x3d085ea1, 0x28f9e021, 0xdcf62f80, 0x9c87e1a9,
- 0xf060427d, 0x9df197ed, 0x4f5dca98, 0xaa7c4275, 0x1fbb2df2, 0x5dbaf8cc,
- 0xc87ee29f, 0xf1ec5f94, 0x2e1fa076, 0x7d12e29a, 0x44bb01e2, 0xb6da8fe4,
- 0x6843f41a, 0x36a2f91e, 0x2beffdc2, 0x7eab57f4, 0xb83efcf1, 0xf4f55670,
- 0x7f885ee3, 0xe1df699d, 0xaec0b8c5, 0xfae7c74b, 0x3591fff8, 0xd6ffffdc,
- 0x3b4f7669, 0x067fffbe, 0xf176a0fe, 0xfb9609d3, 0xb106bbab, 0xb44914f7,
- 0x71ef52e8, 0xf0b9ed55, 0xcfafc428, 0x51e4fdee, 0xcffabb80, 0xfc14787f,
- 0xa9d0720a, 0xba827dc2, 0xf18ebf9f, 0xdfbbe33e, 0xf9d03d70, 0x2f18e3c4,
- 0xfa9b7ced, 0xe75ff41f, 0xc0b3a7f3, 0xea7ceccf, 0x4f10698f, 0xa9f9f3b9,
- 0x9dce6ef8, 0x27494ccf, 0x9189f471, 0x0786ff02, 0xd2b5af10, 0x11db48ed,
- 0x51ce7ff4, 0xd9ff83ba, 0xd489d713, 0xc69978b0, 0xe3bb39e3, 0xc4fbc7c7,
- 0x7d66da6f, 0x4842c6e7, 0x0646bf65, 0x4139c710, 0x006639e9, 0xe3cddc74,
- 0x5d6f9175, 0x0e738e32, 0x3af4a0fe, 0x85e3a16b, 0x3d8f45b6, 0x836d750c,
- 0x44e38dfa, 0x233f8007, 0x413fbefe, 0xe40122ff, 0x60bfef68, 0x37e80cfc,
- 0x73b84e9d, 0xd82c85cf, 0xee48f8bf, 0x85ef8b9e, 0x21576f3c, 0xfcf9511e,
- 0x9d4f289b, 0xf8c71ccf, 0xf071e136, 0x8ff3d24e, 0x99f92bc5, 0x1eedbacc,
- 0x74e1ff16, 0xe690f880, 0x071e72c5, 0xc46d7c62, 0x0b8bfa87, 0x73b1718d,
- 0x40bec627, 0x7877f6cd, 0x6e97a5bc, 0xd7a044c2, 0xcfdc97fb, 0x02a0f030,
- 0x8d8dae1e, 0xc38fc67b, 0x2d3dc4f5, 0x427a0374, 0xae27b3bc, 0x7b13d849,
- 0xcde16175, 0xcef47178, 0xda5e2c2d, 0x8f3fc729, 0xaf41c465, 0x9fe25976,
- 0x3fc581e1, 0x2b8f372f, 0x9760d3c5, 0xf15afd86, 0xf8abf675, 0xae5bfdfa,
- 0xe85f9d81, 0xdaad7f77, 0x3de61f7c, 0x05dd3825, 0xef6d6bfb, 0xa7cf042b,
- 0x2b73b374, 0xf967be7c, 0x3fb3d3f9, 0xd62e3117, 0xfa823914, 0x8c3faadd,
- 0xbc2b57fd, 0x6b787077, 0xe3f5b3f7, 0xd84f5eec, 0x7b39fb4d, 0xebe439f8,
- 0x63efddda, 0xaee8ee5c, 0x988e95a7, 0x8fd616f5, 0xce7ccc70, 0x80a8793e,
- 0xdfe379c5, 0x3171ab1b, 0x40eeb37b, 0x76ea71fc, 0xa71a6a7f, 0x9851142a,
- 0xf1e9701d, 0x2dfa48ce, 0x7699dfd0, 0x3a4ddf19, 0xbee31113, 0xc9701c17,
- 0x95a11f7c, 0x475d0fc9, 0x71c09ef1, 0xf0a77f76, 0x573c04b5, 0xd2f1e77f,
- 0xb7fde077, 0x8358a93b, 0x82b6dfdd, 0x4fdb69f1, 0xef4021f4, 0x13dfe3b6,
- 0x07dafd61, 0xffb18df8, 0x4fd44e8b, 0x50fd50f1, 0x10a06ef4, 0x77aad5d8,
- 0x66cb7dae, 0x938e9f82, 0x2342eb0e, 0x83ee07ed, 0xbc39b9c0, 0x569dee57,
- 0xaa88f00a, 0x7d0a754d, 0xf9bb21e7, 0xafde557d, 0x21ef9aac, 0x6bc6af90,
- 0x266f8fd0, 0xcc664b8b, 0x9f165232, 0x87f7190c, 0xabc213ca, 0xaf7f7ce8,
- 0x28bb3706, 0x8d9e7c5e, 0x78112fd9, 0x06a26a27, 0x2e63d3f6, 0x4bc1de7e,
- 0x83bcecbc, 0x7aa3643b, 0xf6ff61fd, 0x9e08930d, 0x7c06d867, 0x819e73d9,
- 0x2f800b44, 0xea7d768d, 0x321de72d, 0x5a2a13e1, 0x17338722, 0xfd5025ee,
- 0x77866ab2, 0xf11fe42b, 0xb2cdf7b0, 0x3821f748, 0xdb8db0df, 0x1560d9a3,
- 0xe77df6e7, 0x6fbeebec, 0x78a53296, 0x853f30e9, 0x535ff5d3, 0xca7c5ce1,
- 0x0d4fc52d, 0x2d856951, 0xa3dc1a63, 0x78bc7949, 0xcfcd066c, 0x34f4ff5f,
- 0xe2f7ffac, 0xff3459b1, 0xb20e7b93, 0xcf012afa, 0xaeb0bec1, 0xeff01a76,
- 0xd9fb96d7, 0xb9663314, 0x77f0057f, 0x77eef02e, 0xae706917, 0xefe15ba2,
- 0xdda00465, 0x7f0c89d0, 0x9f77ee99, 0x98657f02, 0xf00563ad, 0x7fcf63eb,
- 0x16f78491, 0x2aa1fbf9, 0xdce15469, 0x789a2d15, 0xf3e712f1, 0xccfbbcfa,
- 0x498dcbf5, 0x3f8177c1, 0xbc8de79a, 0xef1d1a6f, 0x0e718ae1, 0xf2d00e76,
- 0x829aa34e, 0xe9c85d74, 0xcb3df84a, 0x8b3e7c45, 0x02c290c5, 0x7f5caddf,
- 0x5751ef19, 0x1ef4578b, 0xdbab8735, 0x67fbefd5, 0x3378007f, 0x007f8293,
- 0x3fdf59fc, 0xb815c57b, 0xe519f500, 0x5c7de25f, 0xeb333de3, 0xea4468bb,
- 0xfb3efb8e, 0x5a2efe56, 0x9bfef07f, 0x69ba283b, 0x682f39ff, 0x39518f7b,
- 0xf150b31b, 0x31cfd1c3, 0xd2fd0bcb, 0x0426c220, 0x1fa71076, 0xf788cf3c,
- 0xb822ee1f, 0x1765db5f, 0xbbaff074, 0x7d4549fe, 0x3a70b99e, 0xae5d5ffa,
- 0x339c08ec, 0xc35bbaea, 0x018a3d7d, 0xe869e401, 0xf828c481, 0x3e1e5487,
- 0xe7c3c8b7, 0x8f37fe66, 0xdb5175db, 0xa9fd81df, 0xa06a3fbc, 0xed8bdcc5,
- 0xee9e9912, 0x8e10d06a, 0x087424a1, 0x8e81fdd6, 0xebe6e397, 0x46cfa737,
- 0x9eeb9e9b, 0xee1ff880, 0x28ffc18e, 0xcc74bf77, 0xe63a3377, 0xd1d0e3bb,
- 0x7bdd6efa, 0x6858e0ae, 0x28fcba77, 0x7d675fbe, 0xdf4aceaf, 0x21f5a93a,
- 0xed2b3b78, 0xfeb8a7c0, 0xb31bf418, 0x29d22c7c, 0x00939e86, 0x3e07318e,
- 0x06bc01b5, 0xe7ec1f1d, 0x9ba9793c, 0xf1d673ad, 0x063acad2, 0x9fb4e307,
- 0xf74cd6e5, 0x451c0a0e, 0x69ca897e, 0x87c58dba, 0xb7efb6fa, 0x9d4b9cff,
- 0x59502cf3, 0x73ff14bf, 0xfe064f00, 0xfbf3756f, 0x7ff17dea, 0xf8a3b43b,
- 0x3fe61dbf, 0xbbcffc00, 0xfb0dfe14, 0x87eb8abf, 0xa29fd82a, 0xda1ff47c,
- 0x3a1cb4cc, 0x8dd134ee, 0x8764b072, 0xd931f7c8, 0x3e865ffb, 0xfd5d7259,
- 0xb917b821, 0xf20267e4, 0xfefe42eb, 0xfdfc27e5, 0xc1b9eb4b, 0xea10b2f2,
- 0x1f9fcbcb, 0xaa3ea30c, 0xff2e65da, 0xbbcf7767, 0xde785997, 0xad352417,
- 0x2b4ebdf7, 0xb9bbcffe, 0xb4e858de, 0xd72f7bc5, 0xdbd68748, 0x33cce74c,
- 0x83f4f4a6, 0xa6cfa0fe, 0xb8f189bd, 0xc409957f, 0xa5297413, 0x2019de10,
- 0xf4094285, 0xd7e5cc5b, 0x72d86fe8, 0x1d9ffaf3, 0xcc43df32, 0x43df316d,
- 0xbe6ade1c, 0x66d57887, 0x51c43df3, 0xc43df361, 0x338d766b, 0xae4747e5,
- 0xb31fb537, 0x3f29b27f, 0x534dfa36, 0x66c7f1fb, 0xda13f29a, 0x7f6a67bf,
- 0x4df35bed, 0x5475d7f5, 0xf86fea9a, 0x7f299968, 0x9b3ff763, 0x311747da,
- 0x61b878fd, 0x5bdc1179, 0x7872f030, 0xa15362a9, 0x9b08e97c, 0x9e5b105a,
- 0x90056ba6, 0x7fe0e916, 0x532f27f5, 0x8a2a3f1c, 0x898ba75d, 0x536fd26c,
- 0xd47ce61c, 0x8f7dfe6d, 0x35722c97, 0xcb527ea4, 0xbc1d9a08, 0x63cf0f24,
- 0xc63af953, 0x01b1dbf5, 0xa0dfb7ea, 0x9b46d57c, 0x2f956f20, 0x9a01bde3,
- 0xad8fd886, 0x1f9f77b0, 0xd4f99a72, 0xf95e8fd7, 0x0738db9d, 0x53facad4,
- 0x264bc6cb, 0x3fca3139, 0x172d8c2a, 0x73c74f16, 0xabf5fd40, 0xb35c16f8,
- 0x3bbc107d, 0xa3530f3c, 0x16cca9bc, 0x67dfdcf7, 0x7fd0bfee, 0x8ec7dcda,
- 0x7cf00cfa, 0x26daf7ce, 0x7b56bf38, 0x51fa377b, 0x5e337619, 0x5decf37a,
- 0x479e0363, 0xac3e481a, 0xb6fdc6f7, 0xebe13445, 0xd177ce36, 0xe0d333db,
- 0x3f66419c, 0x87a155fe, 0x1b47ebe9, 0x042cd742, 0xe98711c2, 0xb456795e,
- 0x39f81a6e, 0xeb79f8c3, 0xe7f8b64d, 0x0c3c92a0, 0x48a0e92f, 0xdd505ec1,
- 0x2b9c2f68, 0x4f0bd77f, 0x0f68dcc7, 0x38e87926, 0x17b4c7f3, 0xbad4fbb1,
- 0x5ee8e67f, 0x947d0db8, 0x026c0ee5, 0x93e592fd, 0x17dd9688, 0x83dbf49e,
- 0x788ef02d, 0xefcdb263, 0x00b77cc6, 0x4c7fd9e3, 0x5e3a20c8, 0x84459fe3,
- 0x75f0f1af, 0xeec83e78, 0xabb8c7ae, 0xcfc24f31, 0xe6711809, 0x89d9be0b,
- 0xabc6cf80, 0xe107ee7b, 0xdc17907b, 0xf7e876c1, 0xc71946c2, 0x982c9c6d,
- 0x4b798dea, 0xf78dbf9b, 0x6cdcb2be, 0xde74e5de, 0x933db700, 0xa8f8d5c1,
- 0xae113240, 0x28f4bdff, 0x5cfb35f8, 0xc507def8, 0xc7c010c7, 0x73fb3d39,
- 0x3a79319b, 0xee419aaf, 0x9ed16bad, 0x4ea7ef89, 0x8fa1e637, 0xe33bd134,
- 0xe2fc332a, 0xc6fd1946, 0x3c6e4945, 0x886e10ef, 0xe79afa72, 0xf99be4df,
- 0x5c295b9d, 0xf8884eab, 0xd1d6b6de, 0xfd28f4ba, 0xe5cdbcae, 0xf17d6b0f,
- 0xf0634e7f, 0x7ba7f852, 0x4f36de40, 0x79e3f9c3, 0x31ff806a, 0x0d9c3c81,
- 0x452c17fc, 0x236c183e, 0xc7d36fb0, 0x7930f04e, 0xd951ed9e, 0x72be357b,
- 0x85be8726, 0xfda76cd7, 0x5dfa7995, 0xb0f36ff7, 0x4f36ff75, 0x72ff759c,
- 0x975707ef, 0x54851fb5, 0x37b445d4, 0x111fa908, 0x3d53476b, 0x1bfd0e56,
- 0xc7f13179, 0xff6fd005, 0x65bf9a76, 0xede5f644, 0x80cfb034, 0xecfb0d0f,
- 0xaed98f4e, 0x3fbbd18c, 0xfbbd30f4, 0xf4c0cf43, 0xfda18fee, 0xe345efe9,
- 0x4aa935da, 0xb4f7bd7c, 0xac1fdd87, 0xe7821553, 0x0fd9fb03, 0xdae5c9d8,
- 0xd6feef3a, 0x1ff9cba5, 0x4f832e39, 0xfcfefacd, 0xf4112d31, 0x4207ca54,
- 0x86b777dc, 0x3c6dbf2c, 0xad9b6bd0, 0xf7cc3378, 0x78fe1667, 0xf59f4d68,
- 0x18f1cc2b, 0x6ac78b8e, 0x099b478a, 0x973c3b8f, 0xb6bf0fb0, 0xdf30afbe,
- 0xf8e4e9f3, 0x09bf7aa6, 0xeb373bc6, 0x6b8822bd, 0x1cf9ced4, 0x1ed7fef5,
- 0xaebccca7, 0x1d397e18, 0xa1e00567, 0x799fd673, 0xe303ae7c, 0xb99eab4a,
- 0x58e2112a, 0x7a0d9335, 0xaa7df044, 0x4839f9f3, 0xecfb7397, 0x2e79c03a,
- 0x3d139d99, 0xa3daefb7, 0xa4f8f710, 0x2c7258e1, 0x793dcf7d, 0xfda648bc,
- 0xbc7bdb9d, 0x7703c248, 0xd43bd361, 0x5b7f1735, 0xdef77014, 0x37e1e84b,
- 0x368f5b07, 0xe57c593a, 0x37173841, 0x6abfda86, 0x7a65f212, 0x285eed9a,
- 0x1dbf1d17, 0x395c21fc, 0xa62fe63f, 0xd04ab259, 0x7ec11633, 0xee373cd3,
- 0xc972f967, 0x9dfa6cc8, 0xe387ad12, 0x6af9c4cc, 0x04efc098, 0xf1444eb8,
- 0xef3c02f7, 0x3ef86076, 0x02b243f1, 0xbdffc29e, 0x78093c1a, 0x09ab3a4f,
- 0x77c41a89, 0x471e6e8a, 0xd30a6953, 0x3ab7ddbf, 0x848cf7f0, 0x53aaaf05,
- 0x3cdafea8, 0xdd8efd93, 0x920b63f9, 0x55691fc0, 0x0df2de99, 0xb463e1eb,
- 0x6be7078b, 0xe6231737, 0x40577c75, 0x921d1955, 0x8a6b6c33, 0xf9c78c35,
- 0x25fe98f3, 0x3dff1a52, 0x1eb7ca29, 0x1c43a6cd, 0xc5cef8d8, 0xfc522bbf,
- 0x7803cebf, 0xf0fcdb46, 0xabfb8f4e, 0x92ca386f, 0x28ccfb69, 0x945e5fbe,
- 0xc39de1c0, 0xfbef07de, 0xd345e34e, 0xd4b5187d, 0x27b74efc, 0xe214b4d0,
- 0x6defd0fc, 0x8bcef8c9, 0x38a29eb9, 0x0bbb9691, 0x0aaee5cd, 0x47e18f9a,
- 0xf6d677eb, 0xae925f86, 0x37f63832, 0xbf0f1038, 0x79fd506c, 0x340e8f94,
- 0xb07f30f8, 0xda34c341, 0x0fcb1230, 0x2f31f837, 0x986cf4da, 0x7faffa4f,
- 0xeebb1490, 0x9d54efc2, 0x75c3e18c, 0xf9ade472, 0x88df8f80, 0xaf15af88,
- 0xdefe478e, 0x3a8e9a34, 0x7367bd86, 0xfefec632, 0xd257f2e9, 0x0d5f284a,
- 0xd3afd1f9, 0xefc3c64a, 0x17f3b096, 0xf63a4170, 0x257aee1e, 0xe093f9a0,
- 0x34c63477, 0xfbc2863b, 0xc95bc1a4, 0xfd239458, 0xbbf089c5, 0x6c337b0b,
- 0x949a7eb4, 0x07f8ecd7, 0x64deab80, 0xe7e7afe7, 0x6c9f1f33, 0xbce3afd6,
- 0x0a66ff4c, 0x71bce3c5, 0x537e09f8, 0x39acfd00, 0x3307b9c6, 0xbf54891e,
- 0xeb8a76e1, 0xdfb3efe6, 0xc754485f, 0xf7bde1fb, 0xcec35ecd, 0xbec5f7a9,
- 0xff99bee7, 0xe1e2440e, 0x29176825, 0x103bf63e, 0x0f7b0a29, 0x4d930489,
- 0xe5cdedef, 0x0606ccfd, 0x1f57d09a, 0x15fde6cf, 0xfb0e791d, 0x8897df83,
- 0xf087eff5, 0xccd8c3df, 0x3574d3f5, 0xed4dec50, 0x5bd4676d, 0x7759ebbf,
- 0x0bd1216d, 0x890143f6, 0xed04bd80, 0xd4bb698a, 0xdc02030f, 0xd7ce33ef,
- 0xcdf80b3e, 0x93ddfdef, 0xebc3027d, 0x8a7d3c93, 0xd4494eff, 0xe3079813,
- 0x123c16fb, 0xca7603da, 0x6206bb3e, 0x8fe47452, 0xf8947ef8, 0xe701c53b,
- 0xbc0f53fc, 0xd9e5eecf, 0xbf38143a, 0x7c5bd2b8, 0x4551c413, 0xf3033ea5,
- 0x816f4ef7, 0xfa9e83fc, 0xdda3d887, 0x1f0137c5, 0x06f7f3a4, 0x01000408,
- 0xe1aa080e, 0x43fd638f, 0x64654eb3, 0x2bf2cc9f, 0x873637bd, 0x3f5f2132,
- 0xf208f80f, 0x7dbfb48d, 0xc021c149, 0x86e16e47, 0x423763e6, 0x037f68de,
- 0x5789ffb6, 0x3b8ffe65, 0x4af60d98, 0x79a55e4f, 0x625e4c4f, 0xa960e279,
- 0x239abf31, 0xd073c47f, 0x3bd807b5, 0x6607a95d, 0xd4cf3008, 0xff1033fd,
- 0xbcb7d5e7, 0x878c342b, 0x04eb608f, 0xf41b978b, 0xa6e1ee30, 0x79f783d9,
- 0x9d61f863, 0xc4c76cd7, 0x0fbc27dc, 0x1fd3ddf0, 0x36cbaf8f, 0xf74a9ef6,
- 0xc6efd88f, 0x547b030d, 0x86b9b884, 0xa3dc2e69, 0x70c1fea7, 0x98395c12,
- 0xcde35fd6, 0xb55e3a41, 0xa9cdfb3b, 0xa75f2f5a, 0x80772964, 0xf8b54e3e,
- 0x3f5cd935, 0x7f8b508f, 0x372b4893, 0xf0b5c10a, 0x8f686c9e, 0x937de2ac,
- 0x4728195d, 0x228eb967, 0x5f3183f5, 0xcbbfefcd, 0x476b832b, 0xc4591e81,
- 0x76556ef4, 0xdfa658a0, 0x8d973d57, 0xf0670bbf, 0x2452555d, 0xf7bb9c6d,
- 0x3791b75c, 0x21e4477e, 0xef09d5b5, 0x5afb18f2, 0x6437fbb5, 0xc7fd3ec1,
- 0x3b46de87, 0x36624971, 0x76d359c2, 0x69df815c, 0x7ca36da9, 0xd8fbbf47,
- 0xa3c763d9, 0xc887f25f, 0xbe026fa0, 0xc368d0fe, 0xd9fdddcb, 0xfd522f55,
- 0xea85d3a6, 0xd3038368, 0xd5fd7a9d, 0xf09c0ae0, 0x49c9b82e, 0x1cf1e9f9,
- 0xeafe055d, 0xf51eb7bc, 0x3a8ae3d8, 0xd3aff80a, 0xe066c3fb, 0x9124aae7,
- 0x5f0febf3, 0x7ef8f3d6, 0xb9efcd3d, 0xbfa6edb7, 0xa160df68, 0x7ba9fed9,
- 0x41fc8dc4, 0x02df92ed, 0xb66ed51f, 0xb3fd6085, 0xbef1da39, 0x1be82773,
- 0xfbe65fd4, 0xa6051b99, 0x5873430f, 0xf772fa1c, 0x74be2b34, 0xfd8c7091,
- 0xe99124bd, 0x84290aab, 0x5f1576fb, 0x2ffeb17a, 0xba69c71f, 0x1c77da0f,
- 0xe31bd637, 0x838ef754, 0xf6fd527c, 0x5fcff461, 0xafb0dabc, 0x77ffd475,
- 0x61cfc53e, 0xe874f538, 0xd0d941e7, 0xa4cfd427, 0x1ee78678, 0xf9243e79,
- 0x47a97908, 0x2e6dacff, 0xf6fa04c9, 0x7eb313d6, 0xb74a25d2, 0x3e781297,
- 0xc9737f74, 0x13ed38a4, 0x8c73ed2c, 0x7fb14ffc, 0x3a0f3c2b, 0xda0ef37b,
- 0xbd93fa5e, 0x6df00f27, 0x4bfa59b0, 0x86dfc636, 0xb7fc19fd, 0x65fbbbc7,
- 0xa5e9ef78, 0x10f140a4, 0x2068df66, 0x15245b87, 0xc0d1877f, 0x3ebe1ef3,
- 0x8d797c55, 0x78bdff09, 0x9f95302f, 0xfb4cd06e, 0x2e178ba1, 0x7b3f7bc3,
- 0x41563af8, 0xdb3eec42, 0x7da6b923, 0xc70fffd0, 0xb8a385d7, 0xfe4a381f,
- 0x328c70c6, 0x385e81e9, 0x5fe54df2, 0x69310e17, 0xec366976, 0xa1b1ad53,
- 0x0b66909f, 0x6ec07239, 0xf7ec5ffb, 0x0734201a, 0x61a899e7, 0xce57da6c,
- 0x079f6039, 0x448e79c6, 0x40e3498e, 0x056d749e, 0x913f53ac, 0xe5a1afd0,
- 0x8619390e, 0xfde1d56e, 0xd8952a2b, 0xb0754e5f, 0xe6f51986, 0xab876277,
- 0xe5a258a4, 0xb879d5e3, 0xdd94e5ee, 0xfdf60755, 0xcfe17736, 0xbc931357,
- 0x5ab27da2, 0xc7f68a58, 0x9b17c49a, 0x3d38df61, 0x0233d981, 0x58f9b179,
- 0x267abc46, 0xbdf72daf, 0x31c41378, 0xaed4aeb6, 0xab6e7f06, 0x0c391c33,
- 0x6e3df9eb, 0xdcaa3dfc, 0xf816e175, 0x83710abd, 0x314bd70d, 0x2b6bbc29,
- 0x6078179c, 0x8bec1f84, 0x40d760ad, 0x5c6e35fb, 0x421a5bff, 0xe2af2f68,
- 0xf5f6c0eb, 0xe7385493, 0x9296e8dc, 0x916bbd61, 0xb8056feb, 0x64efba5e,
- 0xd03ae3b3, 0x4196fe63, 0x80cbef3c, 0x71cb4d75, 0x14f5e58c, 0x68575b19,
- 0x3485c183, 0x44ffc3f2, 0x33d412ad, 0x6b0ed127, 0x04ab2f74, 0xbfd68e3b,
- 0x7a78a0ec, 0x85e3993c, 0xe8f4e7d7, 0xa0cd93a5, 0xbd15c507, 0xef3a12f9,
- 0x7a633f1d, 0x3fda09ea, 0xe7452bbc, 0x18778213, 0xe84947bb, 0xc1242587,
- 0x74d0c76f, 0x9dfb0e74, 0xbd17aa5b, 0x3849c7e8, 0x491f635f, 0x0f7ec519,
- 0x7ac3da1d, 0x83919093, 0x0cca98fb, 0xe2835ef6, 0x66fde371, 0xdd5677e3,
- 0xb3a7f8c4, 0x67df2978, 0x43de5971, 0x895fae70, 0x784ee99b, 0x4f862137,
- 0x0b7bcb15, 0x07cc0912, 0xcd544b7b, 0xe449bfe5, 0xd8834afb, 0xb70eadef,
- 0xa32ed085, 0x35e98452, 0xd9f68a24, 0xf981d268, 0xe66de031, 0x0d2c35c2,
- 0x278d8e2f, 0xbbe2c8ba, 0xc7ec1101, 0x788d5bb4, 0x44f5f04c, 0x96bfdeba,
- 0xfc36e3c8, 0x66538c77, 0x7d7ee214, 0x5fab1266, 0x0fbbc815, 0x338dbcec,
- 0xc69c61a6, 0xf58cefb0, 0x16dfb0d2, 0xab579872, 0xc17b5c42, 0x3a16ebb0,
- 0xb6753e59, 0x8868e0fe, 0x0b53b66b, 0x2fee1b34, 0xf96af8b3, 0xb034e2e6,
- 0xba1e16cb, 0x4ce4ed15, 0x8b65d995, 0x8250ce36, 0xdadee1a3, 0x8a07f43c,
- 0x84484c37, 0x4ed5847d, 0x8575e27f, 0xfbe267e8, 0xc7b503b9, 0x355da6b6,
- 0xab71e419, 0xca90128d, 0xeeb24bfb, 0xb17c0b1e, 0xcced0f21, 0xc6c109ad,
- 0xd6efda24, 0xabfcd67f, 0x4ea7fe68, 0x8c38f0bd, 0xd5813ab3, 0xc051bbc3,
- 0x12e73d9b, 0xc9bbe1b6, 0x3d6f8dfd, 0x1252f097, 0xa8ca7f7b, 0x7e536fff,
- 0x80007d7c, 0x00008000, 0x00088b1f, 0x00000000, 0x7dbdff00, 0xd5947c0b,
- 0x66fdf895, 0x666579be, 0xf263c992, 0xc2130922, 0x9e4e5e4b, 0x124c2280,
- 0x4cb443c2, 0xe8202a10, 0xa79034f0, 0xbadc5d48, 0x30040cff, 0x5706b650,
- 0x84ea2b11, 0xbbaac562, 0x351ba341, 0xb88080ea, 0xda446dd6, 0x8ffd16d2,
- 0x4810154a, 0xfed2b58a, 0x39cf65dd, 0x7cccdef7, 0xb5f01993, 0x3efeb4ff,
- 0xe7ddf7ee, 0xce73df79, 0x12e973bd, 0x2c614dfc, 0x5630a494, 0x51c1d8ca,
- 0x618cf58c, 0x24dea98c, 0x064dcf06, 0x34e2d26f, 0xa37efac6, 0xf5e1bb67,
- 0x926f6617, 0x25d8c6c3, 0x79fa2ed1, 0xa0b199aa, 0xcdb3b189, 0xc11c166e,
- 0x336699d8, 0x1f966b95, 0x9fa0c698, 0xb9850e9a, 0xc55b19f2, 0x3f6336da,
- 0x69923baf, 0x3d0155dc, 0xf4648e0b, 0x5bfe0977, 0xd528fcbd, 0xebc9dd5f,
- 0xaa0eb2d7, 0x4f3192bf, 0xf76b3c07, 0x1cd0595a, 0x51df5fae, 0x4a1f69ac,
- 0xd7bf51d2, 0x3b06fb25, 0x5bdd8c9c, 0x2abefc3d, 0x5d569f78, 0xfae1f662,
- 0x13e38e58, 0x87afa8ab, 0xebe63af7, 0x77aeb188, 0x49de5c04, 0xac4e8a82,
- 0x32b1d0ed, 0xe03ad6c6, 0x1ec62e9f, 0x6c7cd850, 0x15f7f6b7, 0xc2632919,
- 0x9e2ad6ed, 0xf898c70c, 0xa8bc6a70, 0x88d48167, 0xc467dab2, 0x345e35f5,
- 0x0ef3fbd2, 0x63075fb3, 0x3ff4c91e, 0x7fac2d70, 0x1953eb26, 0x909f53cc,
- 0xcd5d8e38, 0x71258b58, 0xba673e37, 0x08a17d0c, 0x53333038, 0xf8337e71,
- 0xc4ebf62b, 0x71944769, 0xed403ed8, 0xa98ed967, 0xc473400c, 0x8303735e,
- 0x90b037f7, 0xce060aca, 0x28fdfa0f, 0x2359dfb2, 0xdd1be5b5, 0x09ecf2da,
- 0x7e6332da, 0x9a4fd782, 0x1a4eca9b, 0x04fefdc2, 0x0311d6a6, 0x5802b72e,
- 0x5eed7eb1, 0x0464e04b, 0x923beb1e, 0xaec6e535, 0x88c9c0ac, 0x1ff16a71,
- 0x135ff059, 0x589d775f, 0xdf4607f7, 0x5bc00ead, 0x71190b3d, 0x46c140dd,
- 0xacc658ef, 0x7c45e616, 0xf16fd81d, 0xcfe812b0, 0x00b76e66, 0xabbb1b7c,
- 0xdef02595, 0x30ef876a, 0xe196273f, 0xfaf03569, 0x0e88058c, 0x39da8fe0,
- 0x5bed99bd, 0xb713e415, 0xcdfedaab, 0xff00dde7, 0x4f0293dd, 0x24ac3d95,
- 0x0ea3ac46, 0x5e1e91d6, 0x07eb39c7, 0x582f8865, 0xa5ec6fcf, 0xa6461748,
- 0xf3d78524, 0x5cb5e1ad, 0x5dc6af0b, 0x1837a236, 0x1844bde7, 0xcea761a7,
- 0xceb2846f, 0x7e4463dc, 0x3ce917b9, 0x1c72de06, 0x6f3c4c4a, 0xe0c73c43,
- 0xfcaceda7, 0x1cc7e43e, 0xc7181fe4, 0x6527eeb6, 0x8f818b27, 0xfa1737aa,
- 0x054dbea0, 0x547186fe, 0x08a9bff8, 0x6d3bd9c8, 0xe9d03255, 0xc3e73b29,
- 0x7a2e890d, 0x0abc50ee, 0xe75d35e2, 0xd5fa47c9, 0xcc43b827, 0x66a3f1c1,
- 0xcb601942, 0xf962c1ae, 0xefe81ebd, 0xcb1b9821, 0xf0098416, 0xcbc2c878,
- 0xefca392f, 0x6ee308dd, 0x0de5e64a, 0xd5b9bd3f, 0x16ca093f, 0xe5439e59,
- 0x416d0c87, 0xffdde03d, 0x44f5c982, 0x28f7b53e, 0x32305e58, 0x4d4c04f0,
- 0x2365843f, 0x4226a65e, 0xf4b720e7, 0x9b769a2f, 0xeed05ea0, 0xa78427fb,
- 0xfb39ff5c, 0x26363cf1, 0x4d7e7f66, 0xacdf797f, 0x53bf183f, 0xfbf87577,
- 0x419dc4d4, 0xc2e76f3d, 0xe7a72c76, 0x9ff43f03, 0x6d89a2fe, 0x0623e285,
- 0xda179b76, 0x632c5dd5, 0xd43908c1, 0xb679f023, 0x5b7241d9, 0xf943afbe,
- 0xa9f9063d, 0x7d70e487, 0xfe46aa47, 0x7f5cb94a, 0x7f4d5af1, 0xc27c8e39,
- 0x43dabd57, 0xe2feadf2, 0x121efa64, 0x736cf4f2, 0xf889e926, 0xc8d20ce3,
- 0x1338f0f5, 0x72f8b059, 0xefa24ce3, 0xcbe61c72, 0x06bdb922, 0xa4240ce7,
- 0x87bc8237, 0x750c2e71, 0x465f2525, 0x0276d99f, 0x67ac4591, 0x63341a9b,
- 0x07dcdbff, 0xfc18be1c, 0xb844e520, 0x1edb51bd, 0x811b23f4, 0x4863edf4,
- 0x7aacffb7, 0xd4fa91cc, 0x5038f066, 0x8af6a86f, 0x34372e23, 0x86647e4d,
- 0x5169280a, 0xd97f3d39, 0xd1e881b6, 0x411f706e, 0x3aeddafc, 0xafbe1f97,
- 0x483ce9b7, 0x730e2d27, 0x51bdf100, 0x7281c1b9, 0x076bf643, 0xb8f38f31,
- 0x7a421b60, 0xd57ade3d, 0x0f54898b, 0xa9199266, 0xc6f7ff1f, 0x0f17c583,
- 0x31bd8f1c, 0xfa0b88f1, 0x6e744b57, 0x910be00b, 0x1d0471fa, 0xdf63f744,
- 0x779cc6a9, 0xff093d74, 0x8436f8b8, 0xe7fe1112, 0x8119ba6d, 0x4d2ef318,
- 0x9e9bbe56, 0xdf25145a, 0x3c3b7f93, 0xd095ed88, 0x49f20a0f, 0xa32696fe,
- 0x90bc2dfc, 0x3922e958, 0x73b5ee9f, 0xb6e385b1, 0x7d9a8ed8, 0xed988fa4,
- 0x3ebfd913, 0xb849fd3e, 0x64aade18, 0x04601f88, 0x4ae37a86, 0x412bb070,
- 0x1597e22f, 0xd3e50caa, 0xa76f3a40, 0x77d7f4f9, 0xeb11e743, 0x0edd516f,
- 0x75fd6ba4, 0x99ca331e, 0xe6398ef5, 0xaa379410, 0x20f9d9ae, 0x02defa87,
- 0xb7d6127b, 0x1cc8ad29, 0xc15a8f8b, 0x2df9c46e, 0xd669d64d, 0x1d669f23,
- 0xf7e8dfe7, 0x9eb9925b, 0xb13fdd68, 0x9f1253c7, 0x79d2407e, 0xcb9b8f51,
- 0x5856c754, 0xe7c0de9f, 0x0763896b, 0xc1e37eca, 0x0b7ecb6b, 0xa87569c9,
- 0x44f68039, 0x549b78f4, 0xbe078f77, 0xf8f9826f, 0xc7c39cb1, 0x3aa254df,
- 0x16d74376, 0x47330257, 0x4b3837d4, 0x6c17fe08, 0xdf0f4c69, 0xc63d2137,
- 0xd3849798, 0x68efe4bc, 0xe8a2f93f, 0xc3b7f732, 0x5d0d10d9, 0xcba2c6b6,
- 0x4b37a879, 0x3999fcf9, 0x9343fe72, 0x8c7c8ebe, 0x49b29ba6, 0x977c83cc,
- 0x5876cf01, 0x66caa76f, 0x807d43ec, 0x9844d6b6, 0xe636cddf, 0x393e9900,
- 0x32677cb5, 0xe7acb7ac, 0x3f219180, 0x1d693a74, 0xf47da275, 0x8e14a6b8,
- 0x838a533f, 0x3dc7499e, 0xf8014f4f, 0xb824f676, 0x99d4f814, 0x0630fa02,
- 0xbc088f7c, 0x9fc6d633, 0xf21c686a, 0xb65fac8f, 0xc3767988, 0x6b0250f3,
- 0xb2bd8335, 0xc607c84f, 0x154fe7ee, 0x99c61718, 0xdde8cafd, 0xf58a2f64,
- 0x80b5021f, 0x43d3d3f5, 0x77fd14e3, 0x585edbc0, 0xeade047d, 0xdbc221cd,
- 0x6bdf46db, 0xe3c69f08, 0x772c74a1, 0x87933d1e, 0x70b670f8, 0x25efb5fb,
- 0x6ee9006b, 0xd3d67e20, 0x0e2eeafc, 0x81e2fe62, 0x8353ab78, 0x2eeb5fa4,
- 0x5877d1e6, 0x129cdfb7, 0x6c1b3efe, 0x2eb00986, 0x4270e666, 0x47c2c4f8,
- 0x896be0bb, 0xa3eb500f, 0x081f02ed, 0x3ec48fa7, 0x4eef1fa7, 0x780666e3,
- 0xefe66b3f, 0xdf246799, 0xfe7d0987, 0x005e4251, 0x0d1f33f7, 0x7a46ce07,
- 0x91e95d50, 0xe2cea77a, 0xac3e6fb9, 0x67abbd9b, 0x5963c04f, 0xed15ada5,
- 0x4f2665ab, 0xcb5dda12, 0xeb2bd3de, 0xc48409f3, 0x3c042b07, 0x5df732cf,
- 0x36ff3f88, 0xc209e38b, 0x97ff769f, 0xf8bca3bf, 0xa2bf681d, 0x9346ef4b,
- 0xcda56971, 0xf596fd8f, 0x876d3c54, 0xad5b2bf7, 0x2efd062e, 0x04fee29b,
- 0xf765bded, 0xf21b5c59, 0xa438bf71, 0x5dfa0b3c, 0x03be60fb, 0x9d7581e5,
- 0x06ecd337, 0xeb7ee093, 0x6de02b4c, 0x8964b293, 0x7dac0852, 0x1516ca7f,
- 0x57feacf0, 0x281667e5, 0xc17f755f, 0x8c75f316, 0x1cb282bd, 0xd0ff59ed,
- 0xfedf6899, 0xf646a712, 0x7f6fb72e, 0xca274479, 0x82a65bc5, 0xece5180a,
- 0xce60d9d4, 0xb78a532b, 0xf4fc6198, 0x0ea14f14, 0x32935bc6, 0xb7f62661,
- 0x7fb1bef4, 0x77df09dd, 0xa99acca4, 0x44de13e6, 0xcaccef7b, 0x926ed0a1,
- 0x54b3cf2c, 0x56697f42, 0x27a7b616, 0x090fbf00, 0x77f68f8f, 0xbdfdbf67,
- 0x1cd4e660, 0x53454bc0, 0xbffd0aa5, 0x96db729e, 0x36315731, 0x877281fe,
- 0x983fc607, 0x15a664b2, 0x9469dff0, 0xf16d97f5, 0xcc9d58c0, 0xbe0186f7,
- 0xbafef1ff, 0x9fa86699, 0x742dea96, 0xcd53fac0, 0x91996ff7, 0x65f81dfb,
- 0x4fbd12a4, 0x1271482c, 0x90461cdf, 0x33ebade6, 0xf82afd72, 0x71d3873d,
- 0x9424797f, 0x4ce511ed, 0x10dcee5e, 0x4e9c7e5b, 0x33b972e5, 0x8f77f621,
- 0xef004b90, 0xb3e90ea0, 0x96181acb, 0xc027961f, 0xc409e64f, 0x3cb9db5f,
- 0x639abe01, 0xd98e3e27, 0x5fe537df, 0xd3f53b80, 0xe8ac7aa9, 0x0d7290bf,
- 0x71c56666, 0x69764cbe, 0xcf5975e4, 0xbfb79252, 0xeb7c154a, 0x5671f0e2,
- 0x330ae56a, 0xb8470cf7, 0xc58b76c8, 0x4b47f33a, 0x88d052ff, 0xe2d6b9fc,
- 0xacf9c0c9, 0xc19e57dd, 0xd787632e, 0xf8d72c5d, 0x98ebc24b, 0xf407ef4a,
- 0x44b9fd0b, 0x5f31eeff, 0x57c95e07, 0x7d1a5780, 0xc33ad2bf, 0x3bfd69fd,
- 0x7ee3fb03, 0xc57a019e, 0x1b9e7b18, 0x415eb853, 0xe422ebf8, 0x5f214ada,
- 0x3d916a41, 0xabc5fe7e, 0x8fcd6f76, 0xf503771c, 0x7a7df80f, 0x412fee0a,
- 0x2b1ca2be, 0xb0b33d53, 0x8a4f597e, 0xa079ed03, 0xde828db7, 0x8937a454,
- 0xa694cee7, 0x76ef5a72, 0x863bb1c5, 0x3913f81d, 0x83c536af, 0x22c649f6,
- 0xc4497e9f, 0x87fca4fc, 0xff453bfe, 0x1f9e9c25, 0xc5e7a7ed, 0x2fc23fc8,
- 0xdf40dcc4, 0x5fce0763, 0x08ce36c1, 0x2582f5fd, 0x7091f380, 0x2ff4b6fb,
- 0xb8ba87ed, 0xda912a7a, 0x260f1c65, 0x219ea0ba, 0xb9f9c5c5, 0x6bc4e3e3,
- 0xe9755f51, 0xebe2e299, 0x2651b946, 0xe7bfa4e5, 0x764a8548, 0xbb2e584c,
- 0x72919ec8, 0x87366833, 0xbdbfdfeb, 0x9446c667, 0x2fbe26ab, 0x1483d34f,
- 0xe3cf0a2f, 0x2fae14e5, 0x2798f827, 0x24781d96, 0x08e52ed9, 0x75e1e3ad,
- 0x5863ec95, 0xd7e85d9f, 0xf93f2109, 0x664c9eb3, 0xf0e13ec2, 0xb67bfa90,
- 0xdcaff429, 0x47a5a64f, 0xa53b0659, 0xee105741, 0x89cfbf1f, 0x8263fba0,
- 0xf3f1a20e, 0xc013e55d, 0x48708fc1, 0xc872e14d, 0xed056509, 0x17f4150b,
- 0xb55cffc0, 0x3f35bdcd, 0x2e36de62, 0x1d7a9d8f, 0xe0576397, 0xfe54b48b,
- 0x3b25efbd, 0x1e1873f1, 0x2ff98edc, 0x1d76f701, 0xc17dc1ab, 0x09f01d21,
- 0xaf8da2d2, 0x598bfcf3, 0x29e7efd4, 0xeffeb93a, 0x1bb72e45, 0xd7ce3c61,
- 0xbfd63f64, 0x3b5da83c, 0xdcdfde7f, 0x658f4e54, 0x68853dc7, 0xdaf30cc7,
- 0x285fb8dc, 0xc07399eb, 0xdde1e500, 0x4b6b038a, 0xc1de1f3a, 0x4ba814f9,
- 0x67ade5c0, 0xa5b5fb22, 0xbefa3a72, 0x38fc31d6, 0xcbc457a7, 0xcd3e08e2,
- 0x7871b54d, 0x084cfac1, 0x472b554f, 0x9bfbf3e5, 0x0180f787, 0xf0075bd6,
- 0xe12db140, 0x64b1d9d6, 0xf8f90583, 0x1f237338, 0xa258ef9f, 0xdd788b1b,
- 0xebbec8c9, 0xf00f0f97, 0x147b4875, 0xe903b2e8, 0x5cd4eaf2, 0x71d86f1a,
- 0x7c0c758f, 0x1376861f, 0xec3b95fa, 0x4c57dc01, 0x4dcdf54e, 0xedce7845,
- 0x4a2064ab, 0xeb4dac1a, 0xfbef112d, 0x7d4177eb, 0x7e9f63a2, 0x36f3ce2c,
- 0xc2bab6c6, 0xfaa981eb, 0x6f5a1fd1, 0xa02d3e04, 0xd6e11072, 0xfbf5e469,
- 0xcf8a3316, 0x8cfbe834, 0xf7f41df8, 0xa3cfa22c, 0x2fc414ba, 0x6ed09bee,
- 0x737bd3ae, 0x67d7dc14, 0x07a8dc98, 0xf4421f60, 0x54c2c87e, 0x26fff40b,
- 0x574e513c, 0x8fd8efe9, 0x502aaaf0, 0xae242ddc, 0x60dc85da, 0xcd37dc41,
- 0x7a25629e, 0x39dd5f64, 0xbff51ab4, 0xfa09e395, 0xcc7e8b31, 0xff30a2e6,
- 0x2aef3afd, 0xfd48ffda, 0xa8514876, 0x8dd7439f, 0xb112ddde, 0x50fec22f,
- 0xaa521ffe, 0xfa40ee73, 0xb23afb17, 0x7ac2d30f, 0x2295ed17, 0xfdde245b,
- 0x3ca17e62, 0x7b48a3a4, 0x7ed3ed14, 0xb1dfd67b, 0xd9c83a65, 0x823a33f1,
- 0xd152073a, 0x01ff33f3, 0xf60551d6, 0x70e005ac, 0x33972a5b, 0xfafdf287,
- 0x30df9c44, 0x3abc3f58, 0xd31be09c, 0x938f0b64, 0xe90ffc2e, 0x482fee46,
- 0xbfcfe04f, 0xe73b72a7, 0x1e5c6927, 0x978d21fe, 0xfb6313d3, 0xf510be2b,
- 0x1f971354, 0xfcb9cb5b, 0x41b7ae8f, 0xedadfbf4, 0x668a31de, 0xef760f7f,
- 0xf76e5486, 0x885fb91a, 0x0a9613c7, 0x873b06fa, 0xabb614f0, 0xda503c78,
- 0xccf45fa1, 0xf372f2a3, 0xbfe8d97b, 0xe69fedbf, 0xb6f487dd, 0xf27a37f2,
- 0xf1149c57, 0xbec99582, 0xbfdc64f4, 0xabf6c427, 0x75d6273c, 0x1f9199ba,
- 0x1b8c53f8, 0x893dec82, 0xaf284371, 0x34e0f9da, 0x2cd5bfe4, 0xe5e0fe40,
- 0x5c51373b, 0x61407970, 0x69f7052e, 0x1627ee5e, 0x47bd58f8, 0xdf4bf1af,
- 0x931936ae, 0x77e984c7, 0x6e369b45, 0x58abb358, 0xf6f6fe53, 0x440b2569,
- 0xfcb0a1c8, 0xa3ef4699, 0x1ef495fb, 0xd47ea76d, 0xc3f8d2ec, 0x461cee97,
- 0x97f597eb, 0x77ad3731, 0x66816b59, 0xf395acde, 0x49f9bc49, 0xd4bb45ba,
- 0x469e731f, 0x008ffbcd, 0xff08fefe, 0x4353d2ff, 0xa92d1e69, 0xba40ffbe,
- 0xcac3cf09, 0xdabf1afc, 0xb027c724, 0x7ee16656, 0xff23a049, 0x5081ece5,
- 0x6fffa72a, 0x71d1f70f, 0xfee305f6, 0xca0beebf, 0xcc397126, 0x0c3614da,
- 0x6aa7e31e, 0xa0bfb4ed, 0xa7c52bbe, 0x616beb95, 0xa45f2d47, 0xd45177ad,
- 0x5dea28bb, 0x6912bfc9, 0x2805299f, 0x0d7f78d7, 0xcff38f82, 0xa0ba351c,
- 0x6e34f8de, 0x3d3916c7, 0x6cef5097, 0x438e24b3, 0x4b36ca7f, 0x52f5005e,
- 0x38bafaff, 0x48336d1d, 0x033b8a3f, 0x5ffed6e1, 0x88a8b677, 0x0fb07dc7,
- 0xfe587900, 0x8a1641e8, 0xae375390, 0x01cb3c53, 0xef2176de, 0x7d7cdcea,
- 0x71a0ee75, 0x5d93f428, 0xd395e7c7, 0x23515fb1, 0x08d4e5da, 0x419a5f7f,
- 0xc1cccfb3, 0x8d254e32, 0x9a9ce3cb, 0xea1432a0, 0xa3daef65, 0x875fd8a8,
- 0xbb337a42, 0x41130009, 0xdc25d957, 0xa4b1b9be, 0x2636595d, 0x5d56870c,
- 0xe00718f5, 0xeadd35a7, 0x8f737d46, 0x0d2437d3, 0x182279e7, 0xf8fcedc4,
- 0xda2a3d13, 0x7a753fef, 0x619cd20a, 0x8ef4b838, 0xd6a7d46c, 0x6d9e7c13,
- 0xae63fbfd, 0x4da22867, 0xdcddabfe, 0x23b3d19e, 0xa487db8c, 0x8c37d2af,
- 0xe727bd24, 0xf4229e97, 0x3df33a45, 0xadfaa367, 0x68c9f08c, 0x861be93d,
- 0x2cf6e6ef, 0x815577c7, 0xafbe0f77, 0xa8aab8ca, 0x6c17de05, 0xa14baa0b,
- 0x62bbcbdd, 0x85cb83fb, 0x4c75813e, 0x75c9f5c2, 0xc82e495c, 0x7e38867a,
- 0xd60fc90a, 0x1ff7b119, 0x2f7d2230, 0x216d347f, 0xa36eb7ce, 0x30949991,
- 0xf4ea7ffc, 0x64f9c6ce, 0x082bb477, 0x93dfe91b, 0x1dff4ae3, 0xfcfe477e,
- 0x96f928c8, 0xfe5c5fd3, 0x2cf7a75f, 0x1b67948f, 0x6927848d, 0xc7e7873f,
- 0x69d5fded, 0xeabecf5c, 0xf9c12ef4, 0x276d7434, 0x3daacf7f, 0xf9631a1f,
- 0xe2f9a3ab, 0x6a54704a, 0x6ea0bef8, 0xeb8039be, 0x25547f2f, 0x68dda83a,
- 0xdd5938a4, 0x9fb8fb33, 0x46e61ee7, 0xb1d75139, 0xe30e594f, 0x4fb33ed6,
- 0xd7011159, 0x05017541, 0x2ec233e7, 0xafcb90f9, 0x3f47ba68, 0x872dda32,
- 0x9c4e5c2d, 0x15f9b72d, 0x8359eb80, 0x9deb0eaf, 0xfdbab2cd, 0xbc3c61f9,
- 0x11fa6fb9, 0x3fb037cc, 0xb3e20a67, 0xd33bb755, 0x475af50c, 0x5f48dd19,
- 0x36fa753f, 0x54525c23, 0x4fb6276f, 0xd7bbb34e, 0x89975b43, 0xfbbca115,
- 0x1f1870ba, 0xefe32745, 0x85d3fce1, 0x91db8872, 0x813fc845, 0xa7b4bb34,
- 0x361dae48, 0xc73c75f0, 0x9eff7cf8, 0xe89079ea, 0x8d0a48f8, 0x54175d9b,
- 0x7f9d9fd0, 0x6b9239e6, 0x9d30ffb2, 0xe4891e79, 0xb3cf2bdf, 0x56f488c3,
- 0xf950e42b, 0x8f947ba3, 0x4bfde623, 0x6e91f430, 0xba019fb2, 0xfdf7d1b4,
- 0x3ea8d333, 0xbdf0b933, 0xe16aed42, 0x79088afb, 0x4311d723, 0xf5c3ecee,
- 0x1cf44ed8, 0xc82772e4, 0xbe628dfd, 0x157cf8d1, 0x9a7c1fe5, 0xde99ea06,
- 0x3123fd1b, 0x48787a2e, 0xe527f502, 0xbedf3440, 0xe51ce82a, 0xfe46cea5,
- 0xe52bb25a, 0x22bd64fc, 0x34fec567, 0xc10f4382, 0x4a977ea1, 0x7a32a9eb,
- 0xc111de87, 0xfd16bf0f, 0x03f9b81d, 0x07fdca23, 0xa25dfdfe, 0x8536fac7,
- 0xedacf1e2, 0xd43ce35d, 0xf4a7fe47, 0xe2ce6768, 0xf1db0126, 0xa784bbc2,
- 0x2e5c9d59, 0x53ee77d7, 0x74c2d997, 0xc0e67f9a, 0xf56748ad, 0xfb86261d,
- 0xdfbfa022, 0xe9a27c20, 0xca47c254, 0xb4f878dd, 0x9472e0ce, 0x47e48df9,
- 0x3e54fd85, 0xdca429fa, 0x4eaa7bfe, 0xfbf809f8, 0x1cbc690b, 0xa7df1fa6,
- 0xdcb08f08, 0xe45f10b5, 0x603a299f, 0x5bb87dc6, 0x5a7f3f21, 0xe4678725,
- 0xc6c7aabc, 0x54ce9b97, 0x50d437a1, 0x587b1cde, 0x7fcbf7be, 0x810bfed1,
- 0xe41f786f, 0xd410d9ef, 0xd1fe72f3, 0x7277cbf8, 0xce831b7d, 0x11d71bfe,
- 0x3da4dfad, 0xc9e6e920, 0x8f46aa5d, 0xea469dd8, 0x731b0ecf, 0x728ec79c,
- 0x61d8cf1e, 0xc76cfae0, 0xe500737a, 0x780b9bc9, 0xa17d995e, 0x43cf8831,
- 0xf875a5ba, 0x1f3650fd, 0x5ba755bf, 0x0dd6e583, 0x7842d636, 0x4b3a24f5,
- 0x19127e91, 0x1e5c8f97, 0x973cf03e, 0x5b7e7567, 0xeb3fc180, 0x5397737c,
- 0xe2cd39dc, 0xf333b8c6, 0xb3ce341d, 0xd72ba40f, 0x2e8dfb73, 0x83ab3f78,
- 0x03c49ff3, 0x2fa253c8, 0xae120fc9, 0xb8727861, 0xf8927e4b, 0x67f4bbf8,
- 0xa77cbd03, 0xda3daabc, 0x46dbdc78, 0xbe4ed5df, 0x706c3acf, 0xc7869fa1,
- 0x6fd1e217, 0xb3b7baed, 0xb51d824f, 0x7a2df33a, 0xfd85be4a, 0x27bf86ac,
- 0x3817bc09, 0x74afbeb9, 0x2da9ba72, 0xacbe20e9, 0xfc44d93d, 0xe5c19b6c,
- 0x5684ed9a, 0xcff6331e, 0xa8dbbd62, 0x63b5955d, 0x5477e61a, 0x7038ae3d,
- 0x6e4f1fbf, 0xfcf0aede, 0xbd774fb8, 0x72f98891, 0xf2b02bec, 0xe1629e31,
- 0xe4eb9deb, 0x5eece272, 0x7bd13800, 0xf672f193, 0x63fa95fb, 0xc20a63c1,
- 0xfac056b3, 0x139533ec, 0xec7e84ff, 0x61ee49bd, 0x9ecfe4b0, 0x3feee9b9,
- 0xeecfbcc1, 0xf746e299, 0x978b5a65, 0x69cfa7e8, 0x037ee371, 0xf40cf7c4,
- 0x78efae17, 0x685af123, 0xabe9fa77, 0xd76e508b, 0x799e798a, 0xe10ebf5e,
- 0x7fc9e1b2, 0x6bdf8c9b, 0x09aa4a03, 0xf8fbd9c7, 0xbe63677f, 0xf2469eea,
- 0xfd3cb517, 0x17f311ba, 0xfe768174, 0x03926f7e, 0xf9fe9deb, 0xef08c9f6,
- 0xfa168e96, 0xede7e67e, 0xe4f03e54, 0x77f6bdbf, 0x1378e3f4, 0xccef58dd,
- 0x2f09fbf3, 0xf2953e75, 0xf5d1e2db, 0xb9fb7d8e, 0x8f3d44bc, 0xcb9f307c,
- 0x92d74931, 0x793f4f7e, 0xbd48c4db, 0x0ab7df21, 0x026b4e7f, 0x099f23d7,
- 0xe0adadfe, 0x9ecfcef1, 0xfda7ccb5, 0x1c343181, 0x6375c5f7, 0x2ddc5d38,
- 0x71d751e0, 0x46c1a187, 0xdf9fa9ed, 0x73e3df02, 0x27e7d02c, 0x64852923,
- 0xd7ca25cf, 0x0faa57f9, 0xbfa026f5, 0x1f45e6e7, 0xeb1f382a, 0x2d432698,
- 0xfe69f3cd, 0xf91d561d, 0x6c6d6cbd, 0x38bffb3f, 0xe02ec26d, 0x59dd907c,
- 0x3922e39d, 0x8b0f7260, 0x6bb387b0, 0x27182d7c, 0xcfad7ebe, 0xbe3c07ad,
- 0xb4e8ea7c, 0x727e5041, 0xf84c52a4, 0xcf5c2bd7, 0x4e346df9, 0x81c1fa3d,
- 0x3e0b768f, 0xf5307749, 0xdc03921a, 0x32a5501f, 0xaa7e46d5, 0xf513923e,
- 0xee0f42ad, 0x736e7e11, 0x764dde5f, 0x26bb676a, 0xed061f62, 0xf72a366c,
- 0xf310fde5, 0xe7f8674a, 0x1971de93, 0xa467be69, 0xf27e603c, 0x8b7e4a7b,
- 0xbca11bf6, 0x57d1fcc1, 0x285de59d, 0x3d33e51f, 0xefe4bf8e, 0x74b8fbe2,
- 0x15ca174f, 0xa35537b6, 0x95c9e20f, 0xe79f3703, 0x0f95fb7a, 0x901b0e89,
- 0xdf7c710e, 0x5ede8d49, 0xe815c24e, 0x890fa5f0, 0x7177970e, 0x55d0daf9,
- 0xd4fdc46e, 0x69d7e10e, 0x7484f410, 0xbfe8fb84, 0x9c69933a, 0xe1a1c986,
- 0x0bcea728, 0x12ff3bba, 0x3a43b7a7, 0x0e01f91d, 0xdedd1eed, 0x8fd40ca2,
- 0xf0978d4a, 0xe6f800dd, 0xa3daf376, 0xd7d56768, 0x6bf23730, 0x07e0a743,
- 0xbe117bb0, 0xcbd55d0d, 0x6941bfb1, 0x0ddfc933, 0x41b4c976, 0x63a86e50,
- 0xd96fc8a5, 0x425e2abb, 0x7c5d60ba, 0x035d9e3f, 0x4dd22cf6, 0x9f5bbd5a,
- 0xdb8f7a8f, 0x2c8fd7bd, 0x723bf6a3, 0xf2e7145d, 0xf38a3157, 0x19fb40ef,
- 0x68d65df5, 0x36fb3f6e, 0x5cc5dd92, 0x6537e409, 0xd60d753e, 0x622ff06f,
- 0xcd11d794, 0xb4292fc7, 0x5808680f, 0x56681f29, 0x1a7fb717, 0x9f1f38ba,
- 0x4f91f093, 0xe4adcf43, 0xc4c17f8f, 0xd0fe11fc, 0xce9a5f37, 0x268becf5,
- 0x359fb3d2, 0xb0c7d87b, 0xbc85b7a0, 0x6dac7097, 0xdd21d7cb, 0x09937632,
- 0xcc4cb1e7, 0xf5c0cda3, 0x03d0b246, 0x3cf8db05, 0x77e174d4, 0xa789d74c,
- 0xe2e79b51, 0xe17f93f0, 0xc88f189c, 0x39e85d22, 0x797eba18, 0xeea4f890,
- 0x9a5fde19, 0x677853c9, 0xfb4abd04, 0x0b1e9a28, 0xbbd9b8c4, 0x4c282a0e,
- 0xd1cd77b2, 0x35f5f9f0, 0xeb08d82c, 0x2e977ebc, 0xd91c6538, 0x9e490b4d,
- 0x58b237af, 0xd2232af9, 0x9556fdb9, 0xbf442dea, 0x36cdd576, 0xb93fa477,
- 0xb3a3c12a, 0x24571da0, 0x12ded8fd, 0x4a9d1b8c, 0x6f11bbb7, 0xd25dd2e3,
- 0x5bd8d30e, 0xdcdff703, 0xcda1bc0e, 0x1ff70e3f, 0xf309f581, 0xda09ae29,
- 0x0edcfc8d, 0xf7fb8f68, 0x9cfed7dd, 0xb85bdfef, 0x070402ff, 0x6f5499c9,
- 0x9d8ffa09, 0x5cb5de05, 0xb1ddd93f, 0x93aaf3d6, 0xcdc0e7af, 0x3ee216b7,
- 0x8dae61b1, 0x5781e1f8, 0xde9ca594, 0xbee21140, 0x83f9c7da, 0xe13c7f01,
- 0x3b247a22, 0x1bc9a1aa, 0x9c8f4d88, 0xaec01a5f, 0xe81b3b42, 0x93b70d71,
- 0x13f38c6d, 0xbfb94ba7, 0x6915b947, 0x8d3e4acf, 0xbf497be6, 0x35ff7cfd,
- 0x81bcfdf9, 0x8079e3f3, 0x3f7bd203, 0xe9ccbf9d, 0xe07aeb7c, 0x15bef847,
- 0x4225b1f8, 0x7fef47fe, 0x1fb89e70, 0x1ef6f290, 0x3a5177a7, 0x6fdda1ca,
- 0xab50c66d, 0x2f0d8f94, 0x397e196f, 0x958ccbbb, 0xf0335fa1, 0x60fd246b,
- 0x445ed68c, 0x09ea3f4f, 0xfed8baeb, 0x6dd2bb8f, 0x3f3fcddf, 0xaee52f30,
- 0x7981d2f4, 0x73a8e929, 0xadbb6f10, 0xa58fb401, 0x3e7a291f, 0x499f044b,
- 0x03fdca7c, 0xfeb021c6, 0x37ef82fd, 0x888f7a89, 0x84bec467, 0xf3a5c1f8,
- 0xf679487d, 0x6c91f471, 0xb5f97df7, 0x2f5238e4, 0x8c8dd346, 0xaa7ae0a3,
- 0xd7afc4c7, 0xcfec5fb6, 0x29f8e8a2, 0x800b5fc1, 0x6dde7037, 0xc417e086,
- 0x19d8778f, 0x99f813e5, 0x71e31527, 0x7ce08daf, 0x386fb234, 0xfa66b7b6,
- 0x92ba44be, 0x8f7c5d7e, 0x115aaa71, 0x6bddacbf, 0x7f9e4408, 0xd18337b9,
- 0xb376bd38, 0x91fc0f5f, 0x87dbe99b, 0xcc15fded, 0xf33d441d, 0x2b8a168f,
- 0x8a5b8181, 0x8591a6f2, 0xefce1112, 0x205efb25, 0x0cf7d5fa, 0x39e3bf47,
- 0xdf0e3425, 0xdafe109f, 0xfb5fc213, 0xcf7bd77e, 0x17ad02be, 0xf16e72bf,
- 0x5ece918f, 0x7d21e4b4, 0xe7f4b09c, 0xdda125bf, 0x92b9817d, 0x690e772e,
- 0x55ef5991, 0x2767fc23, 0x7ffdb1ec, 0x373c0b6f, 0x532b788a, 0xb7c3ed19,
- 0x19f97067, 0xe3c4bf3e, 0xb4ebefad, 0x1cf937fe, 0xdfe1c193, 0x501ce719,
- 0xd7df0661, 0xfce10e74, 0x50aed7d8, 0xdd66afbc, 0x41eb3ffa, 0xb5acd42e,
- 0x9f09e907, 0x71ab8ed1, 0x283a83f8, 0xb970309f, 0xcd737f04, 0x07fd6165,
- 0xc849d4f5, 0xc5077e33, 0xfd0a96bf, 0xcde9acb5, 0xa15fa1bf, 0x49e66546,
- 0xf2c71845, 0x9f041e1e, 0x4f2db53e, 0xf2bff144, 0xa3a67747, 0xd458ca7e,
- 0xa6c1f226, 0x55fed03a, 0x2fe8373c, 0x6f672f59, 0x132764a9, 0x1ede001d,
- 0x22f6f0cc, 0xe24a2f1f, 0x7745c17e, 0x08fe035a, 0xf057b879, 0x7cfd3461,
- 0xcdbce710, 0x01151997, 0xaa616fec, 0xefd46ff7, 0x7234e79d, 0xfa12bced,
- 0x5f4823c5, 0x4fddd877, 0x22f2eef0, 0x05d263f3, 0x0e316bfc, 0xb7b1a204,
- 0xbaf867b0, 0xbee3a47c, 0x5fa1dfbc, 0xf0e4dbab, 0x91bbf0bb, 0xf176cbbe,
- 0xe3f141e2, 0xd2232e40, 0x8545c347, 0xf76961e8, 0xae51c79b, 0xa221a837,
- 0x1b66a593, 0xa2e1b1e1, 0xd5a9e9ca, 0xdb243670, 0xa4d7ee03, 0x6032d27a,
- 0x277bfe9e, 0x093c5325, 0x17c389f8, 0xe39c452a, 0x37c332f8, 0xf7e00328,
- 0x36f13590, 0x305d7fdc, 0x8f3092bb, 0xf408d1ad, 0xe7753570, 0x43d84735,
- 0xa5aec72c, 0xfeb7ee83, 0x6e5af386, 0xaf5119f6, 0xd134f0af, 0x4945b179,
- 0x98c752c1, 0xd24fbc48, 0xf5fd1a5f, 0xc8497ef1, 0x3c8df797, 0x9d20646f,
- 0xcf6c3c73, 0x39b2f510, 0xc79fbcbf, 0xe7c39e6a, 0xbb427828, 0x728887f7,
- 0x170f2891, 0x7979d2f5, 0xf797e09a, 0xd17af1c7, 0xe3152ce3, 0x99e1997c,
- 0x7682708c, 0xc7d22341, 0x673a166b, 0xfe404ac4, 0x935bbca1, 0xc82c764b,
- 0x770869b9, 0x4c982718, 0x67a44cf5, 0x41c81358, 0xa96f67c0, 0xb5b3e08b,
- 0xe305e81c, 0x289aaf41, 0x2bf1241e, 0xcf8d1af1, 0x77ca1985, 0x181f4fcb,
- 0x51985ebf, 0xcd7e303a, 0x17c250d8, 0xf38c4bd1, 0xf5f0f11f, 0x03c73b6b,
- 0x0cf2ebf0, 0xb1c183d2, 0x49b37c91, 0xb5ca51c0, 0x78b413f7, 0xe39d3cfd,
- 0xbbd45ea1, 0xda1f7684, 0xe23eeed1, 0x7853f7bf, 0xae02b4fd, 0xfe5da497,
- 0x5f2e024f, 0x529f6ba6, 0xd1fb44cf, 0xe2f214bf, 0x47ee74cb, 0x8ddebc07,
- 0x09fa95f3, 0x19304ce4, 0xebd178f8, 0x6c339226, 0xd5e51f63, 0x83ffbd40,
- 0xea645af0, 0xf41535bb, 0xdec10fca, 0xbb511631, 0x0647284b, 0x48c7efec,
- 0xd433b0ba, 0x0e19addb, 0xf4941f6e, 0x48d7b8f1, 0x0ca5aebe, 0x657287e4,
- 0x210c63fc, 0x6bf0e40b, 0xc142bf22, 0x6214aebc, 0x07f61767, 0x8c97ff70,
- 0xa3dc30d2, 0xe8213bc7, 0x450cd1e0, 0xb215bc25, 0xaddbc442, 0x5f6e7eef,
- 0x139e5d0c, 0x4d9365e7, 0xe7ec76be, 0x916fddec, 0x18c27e9d, 0x8b66de1c,
- 0x7c18ddf1, 0xfc2521ec, 0xf4a7b6fd, 0x98d5e37e, 0xc1f67e7f, 0x4bdd619b,
- 0x1c6ef47b, 0x5f3de972, 0xed1e33bc, 0xc5031eec, 0x6fdf406b, 0x4dde7153,
- 0xa13caedc, 0x67c1d2d3, 0x3df76977, 0x907a0baf, 0xdca572e7, 0x157cfa91,
- 0x93797373, 0xcb1bb890, 0x3b71dd1f, 0xce5dcb9d, 0x003d87bc, 0x666bd3f7,
- 0x3b7c5d92, 0xcf5e51f3, 0x39ed56b2, 0xda6d15db, 0x073bedf2, 0x3925c39c,
- 0xfd102abc, 0x2ba5f85e, 0xf3fbeb63, 0x333f2e82, 0x7afdf88a, 0xfdf8cc53,
- 0x09fc85ef, 0xb4fbd9c7, 0x2f57fbf1, 0x8c6fbf1f, 0xed87df8a, 0x3df8e888,
- 0x6113f7ef, 0x91bf606f, 0x2acffc71, 0xa3e3af62, 0x58b7690c, 0x9f19f935,
- 0x125bb00c, 0x45e37be9, 0xd8f99c4b, 0x2b67fde8, 0xd7d38f63, 0x5f368e3f,
- 0xe79edc20, 0xb5fdc809, 0x8bc693a4, 0x6567a459, 0xe1c7da59, 0x3df43976,
- 0xf4babcfa, 0xf8be4b6f, 0x2ce66158, 0x176d47f2, 0xf29bbc76, 0xbb463f33,
- 0xba72f908, 0x4c10b5eb, 0x278fd971, 0x8487570e, 0x1d7a26f9, 0x42675f40,
- 0x98d8f211, 0xfd234f69, 0x3a6e66eb, 0xfee82797, 0xe8abbbd6, 0xbdffcf7c,
- 0x322332a7, 0x53f72a6e, 0x8f69460d, 0x96fa34d9, 0x65e3e945, 0x1d916f5d,
- 0x70d7f606, 0x7a7f3e14, 0xc3d26ef5, 0x1d37992b, 0xd5f7bde9, 0xe56e7411,
- 0x3961eadb, 0x4bfc9b9f, 0x35bf3c0c, 0x3987ec8d, 0x75373e62, 0x67503b73,
- 0x1c6818f6, 0xd239730f, 0xe7cd8b69, 0x8554420b, 0xf3fd75f2, 0x631de747,
- 0x15fcc493, 0xbdf00f6c, 0x52d93c4e, 0xdbce265f, 0x31eae384, 0x8990260d,
- 0x6e8996cf, 0x28a73e17, 0x83cf955e, 0x6b1a79e3, 0x3afac1ca, 0xd7cf4873,
- 0xc7483309, 0xa2f0fdf6, 0x37945db2, 0xeb70bdce, 0xb36f7c0a, 0x8a313c93,
- 0x04cf4c79, 0x6dfc88b9, 0xb75c6666, 0x4d3c16c9, 0xf4f133f1, 0x8f88b857,
- 0xf91843fd, 0x07581241, 0xd9b53f9d, 0xb171f9ce, 0xb050e60e, 0x085c716c,
- 0x9ce27ee2, 0xf3c7e6c3, 0x672f20c4, 0x5f3fa265, 0xc44ad5f9, 0xee67c80b,
- 0x5df78a17, 0x11f3f20d, 0x88a5de42, 0x7908b5f9, 0x8adcc597, 0xe480c7b8,
- 0x95f6fddd, 0x267ee037, 0xa3f7798d, 0x71387bbc, 0x32fdc506, 0x93e68f98,
- 0xc8d5433a, 0x5b57a72d, 0x46af98ce, 0xe7053bcb, 0xbed3e597, 0x9413b337,
- 0xbd04a497, 0x69529799, 0xfd12361f, 0x37210631, 0x3e78598e, 0xcf3166c2,
- 0x8853333b, 0x78598e6e, 0xb6b7c25e, 0x7ddadc5b, 0x3f0a437d, 0xdd3e7fbf,
- 0xc0f1c66c, 0xe113b98e, 0x07cc7607, 0xdfce167e, 0x41d29c2c, 0x6f9b0279,
- 0xe01bdc54, 0x6bbb66fd, 0xeba40abd, 0x7f70a99f, 0xc728ea8f, 0x3cf69c7c,
- 0x44f31b87, 0xf7be451b, 0xf6a38b66, 0x9a63f219, 0xb7d63d78, 0xed96e319,
- 0xac0e1d5b, 0x37d95697, 0xaafb88cd, 0x9bb1cc15, 0xaff7a0c5, 0xbe608f80,
- 0xe032c73f, 0x63f41149, 0x85bae23d, 0xefbe20d6, 0xf0177fc1, 0xdc3294f2,
- 0x82bff2bf, 0x773a42ee, 0xd27a3cc9, 0x85dd8d97, 0xbc60d86f, 0xe485b982,
- 0xf256f7af, 0x72132fb8, 0x571cbc60, 0x61b5d9f0, 0x85efa7ba, 0x5bb43ca2,
- 0x4cd37ff8, 0x80ebae3c, 0x91c4ca21, 0xc69fac43, 0xe4cdc1f9, 0x6bd3e71f,
- 0xfb0ff858, 0x4ff70cab, 0xf86a6972, 0x60ef9873, 0xbbb322a8, 0x8dea0ea5,
- 0x91fb8357, 0xcf15afaf, 0x543cf142, 0xe5e9237e, 0x65cd9d1e, 0x373e71d4,
- 0xc3aba017, 0x94b847ab, 0x60b4b639, 0x4129d73f, 0xd8cde67a, 0x9fd382de,
- 0xc94cfc23, 0x9e00c699, 0x00996b37, 0xc8bf2678, 0xffa30f9f, 0xac2fff5a,
- 0xcc74f118, 0x279ef520, 0xb9ffe789, 0x0ed53d68, 0xce97593e, 0xc22e7b33,
- 0xcf3f28f9, 0x8b74d0c6, 0xa997fef8, 0xd7974955, 0x300f3cbb, 0xe5cf4b25,
- 0x871e0ce3, 0xa66f9c6d, 0x7146e5bc, 0x7d53030f, 0xf08c3ff9, 0xc5b8c8af,
- 0x7f3606bb, 0x46fd8c5f, 0x07b7164a, 0xfdc0dce6, 0x1f228dc2, 0xcc4f7e47,
- 0xbfb27ee2, 0x377b4e64, 0x1e3dec93, 0x949dfd6f, 0x48d9235f, 0xf2115f94,
- 0x5f248fe5, 0x278edfca, 0x85dfb47f, 0x29e799fc, 0x40bed036, 0xef2921c8,
- 0x68ef22bd, 0x1018f301, 0x1ee23d4f, 0xabe5a395, 0xccdd0e48, 0xf7fef47c,
- 0x00ff3c15, 0xfd80d308, 0x6b4334dd, 0x6af3cd3f, 0x8fcf37cb, 0x3e38afb6,
- 0x7c0bb8e4, 0xa473efda, 0x6b433c9d, 0x87fa2f27, 0xcf4992af, 0xfea2fc67,
- 0x3e70e0d2, 0x3e546351, 0x27c88351, 0x3c2aec6a, 0x4f911694, 0xf3cdd8d4,
- 0xaeba1a89, 0xedc44f94, 0xb029af29, 0xde24e31f, 0xec94d25a, 0x727f910d,
- 0x8a4ff310, 0xaf6e74c2, 0x0c3cf3b0, 0xa2bca1e6, 0xce95871c, 0x8aeab45d,
- 0x9adb8fc8, 0xddf8d768, 0x5577aeb7, 0xbfe93d61, 0x4843f995, 0xc3f6b137,
- 0x5f7c59d9, 0x7ee143b3, 0x3302ff74, 0x059d3bed, 0xc15c4d5e, 0xd1c767a9,
- 0xa66ef8af, 0x3f27d64b, 0x2f830ec9, 0x019e18ab, 0x8979d185, 0xb67af6fe,
- 0x5190fc91, 0xea99ca72, 0x338038a6, 0xf5f92c69, 0x921775e7, 0x2cd9923f,
- 0xb84a61ee, 0xdb7379ff, 0x69ebcc55, 0x97576eec, 0x3774c2db, 0x43ec4b36,
- 0xf48accac, 0x7bd7efda, 0xbd7e44ce, 0x30b79364, 0x19d7da0b, 0x8bbfe483,
- 0x1f7a57a0, 0x2ede5f4f, 0xe150c5e8, 0xe602b05d, 0xd18efbd7, 0x0a6bfb8d,
- 0xcfff41cc, 0x7e4c94bf, 0x230e7549, 0x9cb1b53d, 0xf45e93cb, 0x3e3ac193,
- 0xfaf7e64d, 0xa466ac6c, 0x4ca7cf5f, 0xc55e3a23, 0xe83d8702, 0x7405db47,
- 0xd2cf7918, 0x8eb96d1e, 0xa9fe9075, 0x3d00667b, 0xf2947c93, 0xf4b99eb8,
- 0x741b8c06, 0xa1b3db6a, 0x285c395a, 0xbcf147f4, 0xff982da9, 0xf2e3ac50,
- 0x0f772d91, 0xf5fb439a, 0x2c4f8e45, 0xa17f7228, 0xebaece5c, 0x73d29fb5,
- 0xa17ae7fe, 0xad1ff454, 0x3d854abf, 0x17e41937, 0x7da56fee, 0x7ca9f506,
- 0xcfadd750, 0x59e785d4, 0xbb49da22, 0x890bea50, 0x8c09f2af, 0xbbb579e1,
- 0x1a7c84b2, 0xbe2086c2, 0x13e27fa1, 0x29583705, 0xf71fbfd4, 0xf18ad785,
- 0xa8fc1e80, 0x733afdbf, 0xb36be900, 0xd2fa44d2, 0x3c3ff68c, 0xd23e2ab7,
- 0xe35eff0b, 0x4c7d23d7, 0xdd374d64, 0x9926f500, 0xb728ac7b, 0x31fe4e80,
- 0x585a7e92, 0xa29f6f30, 0x7efa23a1, 0x98edf936, 0x5af52474, 0x9edcf7f0,
- 0x74bcc599, 0x0fe793cf, 0xa83aeedc, 0xd8267df0, 0xeed1079f, 0x93375b7a,
- 0x2c2664e8, 0x3955eb03, 0x9e9ff8b4, 0xdf472da9, 0x5ad0c50f, 0x48744328,
- 0x9c540678, 0x51bdf44f, 0x98f7291e, 0xb3e5ee56, 0xf8de78af, 0x423fc396,
- 0x1d7583ff, 0x0ef6891b, 0x8fc4aa58, 0x27b0f4d1, 0xb78f7beb, 0x118ac9ec,
- 0x7e15e96f, 0x68586be5, 0x40ca33e5, 0x687f3b7a, 0x82333e9d, 0xbc7f252e,
- 0x1379e06c, 0xae3cebca, 0xc6ccc135, 0x252e1104, 0xf928ffdc, 0xd3a41ae3,
- 0x95fd3094, 0xa487f789, 0x06cc197c, 0xd75dbd23, 0x01ea0965, 0xbfa2853f,
- 0x8afe906b, 0xdc89f6c2, 0x184cb477, 0x98f96740, 0x4cf60e17, 0xb495d201,
- 0x8e958a4f, 0xfde73c16, 0xb6f74bfc, 0xe8237ce0, 0xc3842dea, 0x8ae80559,
- 0xf4036afc, 0x147bf6ad, 0x4bfc49dd, 0x359cba7b, 0x6e677ed1, 0xc1b3d702,
- 0xcf49dbea, 0xba24b882, 0xa70e737b, 0x21e62abb, 0x5a672bba, 0x6b34a97a,
- 0x0974d1cb, 0x74b4ea23, 0x8bba23e7, 0x7478d7a6, 0x4ee91837, 0x2bd4dbea,
- 0x48e7ddd3, 0x8fc5df77, 0x3eee9039, 0xa7c672cf, 0x937a68bb, 0xc59f6cf2,
- 0x75768951, 0xfa428d63, 0xa19df8a1, 0x511e582d, 0xf6764f9f, 0xd93764be,
- 0xfc4d8ddd, 0x478f497b, 0x0533798f, 0x7cf7c56b, 0x1b96256f, 0xe877c1d7,
- 0xcf18f4ba, 0x0f7a19ab, 0xa1b85eff, 0xbfbc0de9, 0xdbcfd1a0, 0x337a7cbf,
- 0x6c0a879d, 0xdbcbed16, 0xd8dcb12a, 0x8a7fdbca, 0x31abae71, 0x82d02dbf,
- 0x96daafef, 0x6fdbe6ef, 0x114fd76e, 0x3ca7ddeb, 0x6bb506f7, 0x3f6eede3,
- 0xe4604e6c, 0xfaf6e027, 0x29ceb164, 0xd33af8bb, 0x867ebe3e, 0x4563e80b,
- 0xb9ec9f9f, 0x6575744f, 0xece2ef24, 0xb695cbb3, 0x474e7c1c, 0xbc47a639,
- 0x43f55bbb, 0x37741c78, 0x3675710c, 0xf8c8d3f7, 0x5429e621, 0x5717d847,
- 0x443b7367, 0x614f4bd6, 0xfd8d7e74, 0x72fe4ecc, 0x3e0cdf19, 0x07d414c4,
- 0x976146b8, 0x4e778cc4, 0xbb22682f, 0x1960fa62, 0x4ba90ce7, 0x4bc2dc61,
- 0xe58b4f9f, 0xe6cb2a47, 0x9129f3f6, 0xd7df2177, 0x4875f204, 0x4890fb17,
- 0x90f0fce8, 0xdb9ed077, 0xe734cc97, 0xf3e5f6dc, 0xbcecd4f2, 0x01cd6e7f,
- 0x549aeaf8, 0xe58bf7bc, 0xf2b79429, 0x4c161e83, 0xff381c4a, 0x1a0b2ae9,
- 0xcf8a0f29, 0x518b657f, 0xe5c257dc, 0x3f813cda, 0xd1186936, 0xa7815cef,
- 0x17a16cea, 0xca31598b, 0x6f0279a9, 0x1937343f, 0x336ebeb8, 0x798fc944,
- 0x1e3f28d9, 0x6bcf6b8e, 0x97c947bf, 0x4aee311a, 0x62afc761, 0xfd3fe47d,
- 0xa7f1d844, 0xfc76e61e, 0xfe41d66a, 0x719fded3, 0x961ebe3b, 0xed12f487,
- 0xabddad07, 0x6877d72d, 0xdea00dcb, 0xaec6ffb1, 0x8633b928, 0x1f7ba5fb,
- 0x3f432fae, 0x77cecd64, 0x235dffc8, 0x2b404ce5, 0xe740c067, 0x51a1e672,
- 0xd6fabfe4, 0xd819e3f2, 0xf26995d5, 0x76c9ef4b, 0x5e77f846, 0x0d2e79e4,
- 0x7a11fb8c, 0xc16f23ed, 0xd28b2c7d, 0xa572d14f, 0xe915c850, 0x5bf290ff,
- 0xc6429bca, 0x77ec14f5, 0x9b60f1df, 0xe1ef3b28, 0xc4afa16c, 0x4dfa4dfe,
- 0x88547da4, 0xd7d211f6, 0xba2226a8, 0xbf727eb0, 0xe847d26d, 0x662505a5,
- 0x19917bc4, 0xa6e11bf8, 0xd9f58db7, 0x68f1f434, 0x83f7e5f6, 0xf451efda,
- 0x0b63f723, 0x84dcfd05, 0xff181891, 0xb81f720f, 0x5ccfd38a, 0xf4843de6,
- 0x9cd5fbf3, 0xf0bee47e, 0x3d03ef9b, 0xa07dc8fa, 0xdd7e4fdc, 0xdd3f60fd,
- 0x863ec058, 0xe95cb1e7, 0xfdf1e017, 0x45d38546, 0x3ddf9cfd, 0xf2c2c556,
- 0x733368e2, 0xb97086ab, 0x8cc9a665, 0x0316977e, 0x99cd2fdf, 0xd2d97ef5,
- 0xb413f908, 0xb8401f97, 0xf9276eb1, 0xdaadeb77, 0x3d2b3671, 0xf711fd77,
- 0xc95a8f55, 0x08e174af, 0xc2e59323, 0x0f9411ae, 0xc78199fe, 0x6e7ce55b,
- 0xb5f7bc3f, 0xb95bd410, 0xcc6296ee, 0x0255a82f, 0xb7c1d62f, 0x77beac0f,
- 0x756bbf91, 0x672f7141, 0xe427c50f, 0xbafdf1b8, 0xc6c7927e, 0xf73f5c03,
- 0xdf940929, 0x4787ef0b, 0x38fee9c6, 0xdcefcb88, 0xb807df4c, 0x5b47a91e,
- 0xf827f3fa, 0x1b30b413, 0xa7ce1294, 0x704de708, 0x985fcb7f, 0x13798ae7,
- 0x04e2231b, 0xbe663ed0, 0xcf2179db, 0x01726147, 0xba6567cc, 0x7fd717a7,
- 0x4f85c44a, 0xa9e23889, 0xfc571e44, 0xfe7d7f7b, 0x7ae20db4, 0x3b8894e8,
- 0xc6d14a9e, 0x44bd649b, 0x6cd93cf1, 0x60346ef6, 0x37799ebc, 0x3d70fe82,
- 0x7ca26a64, 0x5f1c4595, 0x6b252fbd, 0x1ac811ee, 0x106a3e54, 0xd399fbb4,
- 0xe3041fab, 0x9ed36f2c, 0xf715ea83, 0xba0af6db, 0xa7f0b5e9, 0x506b371c,
- 0xd76c28f5, 0xb3df80bb, 0x289e5fda, 0xbfea5ecb, 0xc910baf7, 0x8ff2fea3,
- 0x3a9ce242, 0xf8c893f7, 0x61f8bc40, 0xfa30bc74, 0xbc74699c, 0x37e4b17f,
- 0x245fef11, 0x6ee2d4e4, 0xd5b86f1e, 0x820f36cc, 0x6775b7ef, 0x26b8fc50,
- 0x135c3fd1, 0xbf5bf7ef, 0xa4879e51, 0x9edcdecf, 0xcff8f8fe, 0xf5e3e222,
- 0x2f5a3e22, 0x5da9d7d7, 0xcf0164df, 0x3e3e31ef, 0x60739079, 0x9f3a3c7c,
- 0x33b445e2, 0xac3c610c, 0x55b87071, 0xd12aebe9, 0x39617c4f, 0x35f73ca3,
- 0x416b2d6f, 0x2d9af23f, 0x615596e2, 0x380bd777, 0xd3975bc7, 0x8d2e63ab,
- 0xb9813ebf, 0xe593d622, 0xc994d14b, 0x33c88f92, 0xad93541d, 0x34db9f69,
- 0xf07f5344, 0xef9a51ba, 0x4d22fef9, 0x1af5a0b9, 0x6d61fd4d, 0x88f29a15,
- 0xea6bd79d, 0x4921b217, 0xa23b6fe4, 0xbb125f47, 0xf347302a, 0x85def47d,
- 0xb29ff69a, 0xa0931da6, 0x7b45a75e, 0x7bf3332f, 0x8594c67a, 0x76c7a9f3,
- 0xc3f4d52c, 0x29504a82, 0xf633df0b, 0x79a7b899, 0x878f0f79, 0x5ab5dd5c,
- 0xbead4e33, 0x1d18f08e, 0x7d622def, 0x086e37e4, 0x1b20ee28, 0xd55dff18,
- 0xaeed4ed5, 0x78c8f764, 0x2241c6c8, 0xb2cd97de, 0xd3475d39, 0xc3ec8d85,
- 0xe4f4bb0b, 0xc3642c7f, 0xf0449a1f, 0x6b80b032, 0x302efe20, 0xf0bb17ee,
- 0x798ddd8c, 0xb5bfb745, 0xca63e68c, 0xde05d2d4, 0x5eb9181f, 0x5d2d48eb,
- 0x3a5addd8, 0xa5a09a48, 0x27786883, 0xc174b47b, 0xcbbff042, 0x86753bc0,
- 0xb7fe6e96, 0xf081dce0, 0x5be186b5, 0x62d3d07c, 0xbcf1b823, 0x999f6935,
- 0x1d143d84, 0x4e7690d7, 0xbbb09070, 0x2e323f45, 0x93f159b1, 0x771fd55d,
- 0x0bcc109c, 0xd53da3e6, 0xc95fb8c4, 0x6fe5107b, 0xbd24bf0c, 0x9497e78f,
- 0xc09b9d70, 0xf32d67f5, 0x663efc92, 0x93a4fee1, 0x9fc8abd5, 0x913592b4,
- 0x9cd9fddd, 0xe8efc2e9, 0xca577aa7, 0x9f901853, 0x8b29f600, 0x06aed7f0,
- 0x1fef1a8b, 0xd2a7868a, 0x78ed04ad, 0x4b75986e, 0xfca3e07d, 0xedde0f15,
- 0x68ff89a9, 0x51e65fed, 0xb497e522, 0x1278e587, 0xc9ae529e, 0x49ac4c71,
- 0x117c899f, 0xc8d8e725, 0xd693f8e8, 0x41fd239f, 0xe3238e32, 0x9bfed14c,
- 0x55b8bb08, 0xc1d2718f, 0xce782df9, 0x21e1d8b7, 0xeb29613f, 0x4fdf05b9,
- 0xa8b47730, 0xb8bfe12e, 0x2ffbf58a, 0x2babeae2, 0xf26fb5c4, 0xf247a12b,
- 0x65b3c607, 0xff961c7c, 0xf1a11ff1, 0x8b95c524, 0xf2f398f3, 0xd3d22708,
- 0xfba6bf40, 0x8fd02bf8, 0x8a97d75e, 0x3130aaf5, 0xfdde223d, 0xf5a212a6,
- 0x367990fc, 0x6fdb9e45, 0x6ed31d60, 0xe8327f21, 0xa727bc49, 0x58bbfb93,
- 0xac3db457, 0x0759bf92, 0xafba412b, 0xde711165, 0x2a77f0fc, 0x659607eb,
- 0xec95d21e, 0x82f1a789, 0xe0a3ca72, 0xc84c53f9, 0x8cffb941, 0xf993cfb7,
- 0x4f7ef218, 0x94547799, 0x1c75f823, 0x03fd871b, 0x94e595bf, 0xf8017fa2,
- 0xc7e48953, 0xfa253cfe, 0xa31f803e, 0x31f32fd6, 0xf212f6f4, 0x5c8b2d1b,
- 0x8780d7ef, 0x9c7e5bb4, 0xc8e9e8c3, 0x3eb3d171, 0x3d6fc4e1, 0x47a4b9f8,
- 0x68da3f93, 0xfa0d0d84, 0x79145e13, 0xbb5a1d81, 0x9d1c96fd, 0xf7df1b80,
- 0xf15e095c, 0xf8f221f1, 0xaebe3e04, 0xf8f3261d, 0x0c971c24, 0x0d0afb84,
- 0x8ff7fb5c, 0x115f70fd, 0x2e12ee0b, 0x7e7b4ae7, 0xdbd2f881, 0xbc23a58f,
- 0x577aa617, 0xe3dcfd63, 0x5d144fa1, 0xfa555e78, 0x7b8794b3, 0xe74f4ba1,
- 0xe3ae1aff, 0x25e1b072, 0xf386893d, 0xb38a26dd, 0x41bd74d6, 0x66d9e176,
- 0xfc06b410, 0x72180cbd, 0x08fc65d8, 0xb78ef051, 0xd9eb924f, 0xe5f62390,
- 0xef32fd62, 0x39b9d607, 0x475e6627, 0xdfb41c3f, 0xf4aa1c05, 0x1cf09263,
- 0x92be7f59, 0x791797da, 0x3af45f5f, 0xfe78722a, 0xf7b329db, 0xc3efec3e,
- 0xd81d9c9e, 0xfbbe955f, 0x67c23670, 0xbbe742ad, 0x79f898a6, 0x5e712cdc,
- 0xc9a8426f, 0x3399e78d, 0x667df873, 0xf7a47e23, 0xfdf91c62, 0xe0a677b5,
- 0xffd93439, 0xe7474508, 0xee7b1947, 0xc12c7f83, 0x3722e6f8, 0xd8bf6fde,
- 0xba2fee24, 0x002c1acb, 0x91baf239, 0x186547df, 0x66e744d2, 0xe4f592fa,
- 0xb3d34cd7, 0x727748a9, 0xadbcf2de, 0x01f78f7c, 0x7cb15e60, 0xafa5a53f,
- 0x7bfa0d78, 0x75c83d04, 0x2beca94f, 0xe185b26e, 0xa33cf32f, 0xf82553e1,
- 0x1b43ee43, 0xd05b5ef0, 0xbccde7bf, 0x6daf7d1c, 0x5874feff, 0xf6363dff,
- 0x837eb8c8, 0x1e3493c5, 0x6bdc51f9, 0x278717fb, 0xa477df89, 0xbcf6a7bd,
- 0xbf97b7c8, 0xdeef1253, 0x51ccff9b, 0x827b97be, 0xcb85e5e2, 0x7078ffbc,
- 0x99564869, 0x739d357a, 0xdeae5ef7, 0x8fadff2b, 0x28bedfb9, 0xd3dff7be,
- 0xbcec6af9, 0xceb15ec5, 0x88617e70, 0xe7f729ce, 0x7e54be2d, 0x1a477bd9,
- 0x08d23ef0, 0xf6bcc838, 0xb48fbc06, 0xd0bf4638, 0xe576cb9f, 0xc4aa877b,
- 0x8f301abc, 0x3df23530, 0x38f0b7a7, 0x302f2269, 0xfb7c8894, 0x9d3d2ecb,
- 0x11e5ffe3, 0x31dd8cdd, 0xcb9b9de6, 0xa9ca32e1, 0x0e8d1f12, 0xe3b5fbf2,
- 0x79e793d5, 0xe8d8b9e4, 0x845675f9, 0x63f9c56e, 0xf1ac729e, 0x3f7cb91c,
- 0x99dde72b, 0xf0d1f1c2, 0x9bdf899a, 0xf27cf2aa, 0x4ad094ce, 0x168713e2,
- 0x1e04c3cf, 0xe50faf3b, 0x99b2b9d1, 0x8f10efdc, 0xfaa7261e, 0xc8be51ca,
- 0xd4caee7b, 0xc111c526, 0x87a2578f, 0x1af5dc30, 0xbb840ebc, 0x7ecbbe91,
- 0x7c151f4f, 0xdc363ccb, 0xfa112dcf, 0x5a9ec96e, 0x7ee587b2, 0x3d4ef4e9,
- 0x669c6fe5, 0xba72ae3c, 0xd0fda14d, 0xeb631f52, 0x7cad2e40, 0xaa3378a2,
- 0xb09925ae, 0x1efe1496, 0xe9661f7f, 0xbaf8a8c6, 0xbd495fd8, 0xbe5fc72a,
- 0xd7176b4d, 0x467f6db0, 0x51f4e9fb, 0xb0563f2e, 0x2b3fd226, 0x57f6d01f,
- 0xa7d667b3, 0xbce8cf38, 0x8fc21180, 0xec572d37, 0x1958ca57, 0x4f358fea,
- 0x9fc46e7c, 0x17c78960, 0x434ffbf8, 0x7ddff187, 0x8efe27c2, 0xc96f3e08,
- 0x1720fcf5, 0xf2ef3efd, 0xf5ceaef9, 0x7f45c9cd, 0x7e7cbbc9, 0x702eea17,
- 0x8d2bb33d, 0xfd8b5bf4, 0xfaff922e, 0xdffe5cc1, 0x0035f78b, 0x71264c9c,
- 0x49aeba6f, 0x4df6489f, 0x43ece880, 0x7e731de7, 0x26776540, 0xd3da43f2,
- 0xbf6067d3, 0x1eada7ce, 0x72d6df5c, 0x2ffa214f, 0xf3f356b6, 0x8f1366a1,
- 0x397e07df, 0x538600f1, 0xaf6c7686, 0xa39d1740, 0xfd107f7b, 0x3fbaad42,
- 0x98bcc61f, 0x5f3cc9d6, 0xda175d32, 0x3c62283f, 0x899035a7, 0x68e77df1,
- 0x9a4e6f7e, 0xcb90bcbe, 0x36276e7f, 0xe85c5c08, 0x627f202a, 0x17fa41af,
- 0x2e742c3b, 0x2eff8eab, 0xf1c628c6, 0x70eaf32f, 0xf176910e, 0xf9a666d9,
- 0x1d51869d, 0x4890d04a, 0x3c50a8f7, 0x30436ea8, 0x67d416fd, 0x4f14a94f,
- 0x7b4bf393, 0xe302ab3d, 0xdd8f5266, 0xbfb838a2, 0x0bfdd84d, 0x71e3fc98,
- 0x9e82f9b7, 0xff7b0816, 0xf7872b16, 0xc3cee652, 0x2ccd0b76, 0x76ac0751,
- 0x2947654b, 0x90d6b3ad, 0x8c85768c, 0x47b7c51f, 0x1ac9fb62, 0xe7e7617e,
- 0xe1be959e, 0xf419c9d8, 0x3f865d41, 0x693c85db, 0xffcfce18, 0x83cca1b1,
- 0xd786caf1, 0x30efd046, 0x3c781299, 0x1996e41c, 0x843a11ef, 0xbdd61efa,
- 0xc88b15ea, 0x73880a5b, 0xd8defccd, 0x453939c6, 0x78f11e74, 0x71ffdd1f,
- 0x23ca10de, 0x847906fe, 0x92bea637, 0xe01fbbfb, 0xd90debbd, 0xf941d760,
- 0x789fee74, 0x25684879, 0x92991bde, 0x47978977, 0x72c13e85, 0x6cc25e4e,
- 0x5685172a, 0x3e3ca1ea, 0x7197932f, 0x36040a03, 0x6cf06f35, 0xc92dda3f,
- 0x87702ec2, 0xc377bce8, 0x917423cb, 0x1e7758fe, 0x84676797, 0x3e4cf93f,
- 0xc20e6dbb, 0xfaec647b, 0xded27969, 0xc9f5a36e, 0x2cf6caf5, 0xffbb7633,
- 0x957e7210, 0xc53da738, 0x3c2d5aca, 0x044fe7fe, 0x1eec1c3c, 0x7fcbf141,
- 0xfde14dcd, 0x4f74423b, 0xfa27ec8f, 0xb8e41c77, 0x7bfe15ab, 0xf2a3e759,
- 0xcb977ebc, 0xb38c2be5, 0xea19c691, 0xe79be7e1, 0xfe2214e4, 0xc0aa6f00,
- 0xc9f7ca9b, 0xd07e7ced, 0x13fefe2f, 0xf46287e8, 0x0afc1ffb, 0xe787e7ea,
- 0x27274d1d, 0x5aab38c5, 0x2fb6dc78, 0x69e880b9, 0xf7dc558a, 0xc75da252,
- 0x9f6e3cf8, 0xc592f3ba, 0xaf091d79, 0x69c6850c, 0x09cc7011, 0xf6339f0d,
- 0xaffbaf9b, 0x8eeb4bff, 0xef0797c0, 0xc5d8396d, 0x9f1e37ef, 0xf485f1c7,
- 0xe076429c, 0x677f4d76, 0x9fb547d6, 0xae5f28c0, 0xda80a521, 0x6fee2bdf,
- 0x61d9f795, 0xdc71fcbb, 0x57bb45be, 0xfcc1a7de, 0x1c645993, 0x8cdeffb2,
- 0x70bf710e, 0x286f3aff, 0x8874eb11, 0xef223a75, 0xcfe7ec33, 0x73797d63,
- 0xb8e903ed, 0xfdfdfe1f, 0xfd12298d, 0x563cf869, 0xf1d7c87f, 0x1e5572f0,
- 0x1bdf2797, 0xa33ce45e, 0xe70fd9e0, 0x7849f9a8, 0xbb537f22, 0x94ba5a31,
- 0xf411ccf3, 0xf3bf8039, 0xe278e5bf, 0xbbfad97e, 0x7338be79, 0xbebae969,
- 0xf9875f33, 0x07ddb209, 0x34a0c078, 0x21bc27ec, 0x7327ec4f, 0xbc9c4e58,
- 0x339e6f47, 0xde917fa6, 0x7b27ef47, 0xd9efe593, 0xbd1afd69, 0x397bfe4e,
- 0x7efc73fe, 0xfca36b83, 0x7a8f183c, 0x176e16ce, 0xf2da2fd6, 0x037e0263,
- 0x797d54fd, 0x5312bf38, 0x3bf8f3c5, 0x4af3ab5b, 0x7760ab67, 0xdc552494,
- 0xa6e50f99, 0xfc93c6c7, 0xf154192e, 0xf3c83e79, 0xe04d8f35, 0x7c5747df,
- 0x79cb043e, 0x8a797913, 0xf79479e7, 0x9eccb460, 0x2bb6159a, 0xd173ccee,
- 0x1d4afab8, 0x42676bdd, 0x63d60623, 0xf944dd7a, 0xf1ae1280, 0x5d26259e,
- 0xbff3ac53, 0x03d3f4f7, 0xc04cbf8f, 0x1fd0ba7f, 0x2105fc28, 0xe82fe355,
- 0xcfe7e44d, 0x92fd5f7b, 0x9bdcd7ce, 0x079f5be7, 0x67ad1bed, 0xf287cd6f,
- 0x1407eb06, 0x603c53ef, 0xc61fa087, 0x608b60e5, 0xadd9cabe, 0xd89fb45e,
- 0x2559b76a, 0x18ff0ab8, 0xf007a9de, 0xa7b5e57b, 0x0f883c7e, 0x4c79c5e3,
- 0xf1a07214, 0x15fdbfb5, 0x678dc4e3, 0x1b346e6c, 0x7c3f7627, 0x135fda27,
- 0x1bfedfbb, 0x3cfcc3d7, 0x44f79c90, 0xfbc27ff4, 0x9a265d09, 0xabeec4ff,
- 0x6bfd6056, 0x402eebdf, 0x44eeb93a, 0x42c505b0, 0x3effabef, 0x880e7348,
- 0x7cd97a7d, 0x39f1b8d1, 0x013f8f09, 0x1e0893a0, 0xf8f0e73f, 0xced9f28a,
- 0x0e6e8f3b, 0x7b549391, 0x78ec0ade, 0x605f3b8a, 0x7b8c6e09, 0xd1fd73c8,
- 0xd5e3d57e, 0x7f783eb0, 0x20cc1f5d, 0x729e9ec2, 0x24820cd1, 0xc9672e5c,
- 0x39a5729a, 0xcabf534b, 0x3ef9af91, 0xcd2af33d, 0x42ae99f7, 0xc8d6794d,
- 0x37fa9a89, 0xe535cbba, 0x6a6613d9, 0xaa7b57ea, 0x60c2e535, 0xf17ea687,
- 0xf7ed2e91, 0x788f4c63, 0x7eee3a28, 0x27a59f03, 0x2d9ee43d, 0x06f4d53b,
- 0x85fe273e, 0xafda2383, 0x8ec5cd7c, 0xf4bdf037, 0x9f9f472b, 0x9be67e92,
- 0x3180b6f5, 0x53393fb6, 0x83df082d, 0xf3f1d7a0, 0xfb25ef53, 0x937880fe,
- 0xa0a6a7e7, 0x5090195f, 0x9fb9db75, 0x5c32efe2, 0x6efdc458, 0x943111c7,
- 0x7f276e4f, 0xd34371e5, 0x79e47fb3, 0xf728b903, 0xaf9bebae, 0x8b94f759,
- 0xcbbacd3e, 0x3c28aad9, 0x5729a1dd, 0xd4d6ee39, 0x5eb99e9f, 0x6ba67df3,
- 0xb69e144b, 0xba37ca6b, 0x53c28e1f, 0x9e9e147b, 0xf4977cd2, 0x5ffc2ddd,
- 0x0adfa1af, 0x3d42939e, 0xc9878895, 0x1f08faa7, 0x2ada7a13, 0x1cd74f11,
- 0x957c20ef, 0x2895bd04, 0x348ecb2e, 0x20cf81bd, 0xddb0cbec, 0x7a4ce681,
- 0x91766c1e, 0xf370ebff, 0x691e7a48, 0xfffbd376, 0xcf409e68, 0xe87b355f,
- 0x33cd9ff9, 0xecd3d9e8, 0x734767a5, 0xae7fd507, 0xcffb8bb9, 0xddeffb52,
- 0xc1bf45c8, 0x01a85d79, 0xc18ec623, 0x9e9e495b, 0xc79d084f, 0xeb7f06f2,
- 0x3420a9ec, 0x901d67f0, 0x9e207f2f, 0xfb4f2e45, 0x1e0e7860, 0x19fdf8cc,
- 0x43a37f22, 0x3b4429e7, 0x0fe3f47c, 0x32e6a7de, 0x37bd69b6, 0x183a7f13,
- 0x132866cb, 0x90f7e9b2, 0x93cfbc1e, 0xa8b3d8c3, 0xf7bee84a, 0xb9636707,
- 0xe79efc57, 0x241fc7e0, 0xc75bfc3b, 0xe2033dd9, 0xc707a3ec, 0x7b3fb388,
- 0x7f4765ca, 0x46afd1cf, 0x471e11d8, 0xc3cbdf85, 0x3bf80d0a, 0xa16ae51c,
- 0xf1ecf501, 0x5421e738, 0xe0c97953, 0x7bb75c52, 0x5f91e51e, 0xe1dfa06f,
- 0xfdf0a39b, 0xec97acaf, 0xf7a0fae2, 0xa7ed1346, 0x2b3ce98e, 0x957a3f90,
- 0xce10c7be, 0x14fe3d37, 0x7b5ea9e9, 0xafc21e5f, 0xbcbdf1fa, 0x4c7becec,
- 0x0d944771, 0x8f953e1c, 0x6fdb393f, 0x33e15efb, 0x0d11d71b, 0x1d83b99f,
- 0xf4115f7c, 0x201da2e4, 0x3daac7cb, 0x2c5714f5, 0x75c30cf7, 0x389af51c,
- 0x81ed7aff, 0xf237e461, 0xf08bce94, 0x360cf4ff, 0xa2e7fad0, 0xe83f44de,
- 0xd6207d42, 0x1f9e15ef, 0xa23dedcc, 0x2e67dc13, 0xe0bed2b0, 0xa3df8e98,
- 0xeedf5d10, 0xcfa3fbe2, 0x9c87dce2, 0xdc57be28, 0x0becff54, 0x5aef5fd0,
- 0xebdd750b, 0x58f6411d, 0x1740136f, 0x54f7ba68, 0xddfe39d3, 0xa12016e4,
- 0xf82def38, 0x6cfef82f, 0xfc5f9df7, 0xb07fea06, 0x1d26ead6, 0xf04518e2,
- 0x2f2a285b, 0xfd93354e, 0x6e4e78b4, 0x5bc5ea05, 0x56f0bc44, 0x614e9abb,
- 0xe8d93543, 0xdb967e80, 0x0403370a, 0x6ab4cad9, 0x5364fe23, 0x9b1dce4d,
- 0xe87ab9f1, 0x58f22376, 0x9b7d98dd, 0x07ad8cd1, 0xf9252e16, 0x19a77a17,
- 0x3adb75e6, 0xe7ef8bbd, 0xdadaf9e4, 0x22f7946f, 0xc898f7e9, 0xd020024f,
- 0xa5c9357e, 0x4949f668, 0x181f4e82, 0x6331e22c, 0xda4bd8d9, 0xe44ed778,
- 0xdf8bb3a3, 0x1e271e19, 0xec2efda1, 0x7b8adfc7, 0x4fefa39e, 0x5c3ae391,
- 0xcc75ff7c, 0xf6899408, 0x07ae42e4, 0x7cffcdc6, 0x7fac2943, 0x4743b75c,
- 0xd5b70d79, 0xb87880bf, 0x68f025d0, 0x4fc85d60, 0x7c97f937, 0x4c421bf0,
- 0xf0dce69a, 0xbba5f495, 0xa91951c7, 0xde424b2f, 0x397d48ca, 0x12adafa1,
- 0x8fd4a2f5, 0x211ae6c1, 0x8e489b8f, 0x475e6c1e, 0x7ecdc3e5, 0x6e691e7a,
- 0x8db8f215, 0x79aaffbe, 0x01c790a7, 0xd2f78f21, 0xf9e6eefb, 0xd9ad7cf4,
- 0xa985cf47, 0x6e11d7be, 0xd73b8e32, 0xdcbca3ec, 0x189b0f43, 0x742ef1c6,
- 0x038f289b, 0x47b1e238, 0xc94f30d2, 0xa344e744, 0xe5a295f3, 0x743d3f7c,
- 0xe5b7b80e, 0xfef7e46d, 0x17b4233c, 0xa7a7c707, 0x4765cca3, 0xe0f1f4b9,
- 0x8e8724f3, 0xb4765cba, 0x2e3e4fa7, 0xdd971eca, 0x0d3fe500, 0x71fd25ee,
- 0x9bb2e7d4, 0xe3c9fca0, 0xdfbbfcbd, 0xf940b765, 0xfc7dc1d3, 0xd051807b,
- 0x2fe0ecff, 0x33958e48, 0x47f220e5, 0x2a7f39a5, 0xd7d00ba8, 0x2f9107e5,
- 0x992e67a6, 0x60b17c8a, 0x72e88bb0, 0x41fd6ba6, 0xd91acf2c, 0x1515e2ae,
- 0x46e15b1e, 0x5691576c, 0xa9bb62ad, 0xc46c7739, 0x6e86d376, 0xcddb2357,
- 0x236fb318, 0xb7706f96, 0x2e9f68ab, 0x1a563940, 0xe59647ee, 0x65a72977,
- 0xddd5dd3e, 0xe307d25e, 0x0fa4bcba, 0xe62a5c24, 0xff426f56, 0xe2976367,
- 0xa9a5dfc0, 0x27f4ab98, 0x62ee6033, 0x0a93de03, 0x3dfffaf2, 0x87ac77ae,
- 0xf9623675, 0xadb72a1a, 0xedfa06ff, 0xe2f6007f, 0x8000e831, 0x00008000,
- 0x00088b1f, 0x00000000, 0x3cd5ff00, 0xe5547809, 0x9dcee7b5, 0x4c92642d,
- 0xe2420836, 0x96249964, 0x26b6432c, 0x0c486410, 0xf90130ee, 0x10196544,
- 0x044816c2, 0x7eab17eb, 0xe0171a19, 0xd16b8d69, 0xb5c46faa, 0x61e4b6af,
- 0x1d0958d4, 0x87d252aa, 0xb410553a, 0x88a47479, 0x119099f0, 0xc7d278dc,
- 0xf7fce73b, 0x24cee666, 0xbefd1480, 0xff938607, 0xcfd9fbfe, 0x005ffff9,
- 0xb3f85380, 0x34607f02, 0x3d2538fe, 0x0468048c, 0xd1bf67f1, 0x0395b26d,
- 0x8c0734ac, 0x412fa3a0, 0x6010aba3, 0x76960eaf, 0x24a40014, 0x0b7afcc3,
- 0x74b08d96, 0x5de7960b, 0x05480368, 0x20bada68, 0xda85816e, 0x6066e3bb,
- 0xe21745fb, 0x52ce38af, 0xe0546e05, 0x9bd40a93, 0x4f34899c, 0x1fd24d9a,
- 0x856fc7ca, 0x064a7850, 0x3d9ab7e8, 0x448004ba, 0x0dac7b93, 0xfb9bedc7,
- 0x8758834e, 0x31d688af, 0xeb1ebd6c, 0x6c3200e3, 0xca1f1e56, 0x5e541982,
- 0xc846ed09, 0xcff5b846, 0xda22a4fb, 0x2327c597, 0x5f434e84, 0xf9ec5f20,
- 0x63fe1654, 0xe0543d06, 0x6e03e97a, 0x70d79969, 0xea566020, 0x743967f1,
- 0x226670ec, 0x7ed45ede, 0x18bf046f, 0x7dfb43bf, 0xbe8de215, 0xbf697537,
- 0x0f5b5403, 0x0230438d, 0xd9dfb8cb, 0x855efe12, 0x878f0dff, 0xc3c06749,
- 0x10f0a1a4, 0x1af01fb5, 0xd7de8e41, 0xa66ecb0a, 0xc0bee473, 0xd1fcca9d,
- 0xf7218108, 0xf445f2a7, 0xfe05dafe, 0x25ff02f5, 0x5a74e736, 0x38fcdd5f,
- 0x8e005390, 0x4d79356d, 0xa9ffdc99, 0x1744293d, 0x2d837593, 0x5b5b3e9a,
- 0x00de8367, 0xcdd5adb0, 0x14bad7d0, 0x3f8076f4, 0xf97336b5, 0x2e16d6ad,
- 0x30f568ef, 0x8ebad9dc, 0xdb5a5fe1, 0xeb577eb9, 0xdbbf2e46, 0x6fe865ea,
- 0x5fbf917d, 0x86657f3b, 0xff4d12db, 0x45cec9d5, 0x7b9e8fc4, 0x3e9913aa,
- 0xc853f7b8, 0xc81a9eab, 0xc344b66f, 0x9d658301, 0x8f65c094, 0xd9e1f711,
- 0xc36de316, 0x8c73fd7d, 0x19c689bb, 0xad7e09a8, 0x4a437c43, 0x30d0f180,
- 0xbe9abdd2, 0x3a1c464b, 0xe4f56689, 0xeb0efe12, 0x6407bf3c, 0xd39b56d9,
- 0x383e47a5, 0x17558f1a, 0x6582dc00, 0x78f3ce0f, 0xfa85abaa, 0x48c07e41,
- 0x3fa29ce3, 0x097c7193, 0x3af07766, 0x0e1ca210, 0xb1e808c4, 0xd18f2c49,
- 0x40ddc850, 0x60f99fba, 0x1913e9e0, 0xcb3382b6, 0xa8f870c5, 0x9e03ab93,
- 0x6567a432, 0xd584c3ac, 0xa4f8127d, 0x46538412, 0xd38e00d6, 0x13d46e97,
- 0x5644149c, 0x9fc3c750, 0x6322dfc9, 0x14cbf186, 0x6b94d448, 0xed35a3cd,
- 0x9a99aceb, 0x5cf4befa, 0xb4d2ff1e, 0xfaed348b, 0xc59a5746, 0x232f53bc,
- 0x6f7465d8, 0x0974805c, 0x9b1c9956, 0x98bdfeb0, 0x062822f8, 0xbf1b1698,
- 0x317be089, 0x376a5e19, 0x14c9c0ed, 0x934e7dc0, 0x108b237d, 0xc6db9755,
- 0x99edc76b, 0x76c36353, 0x6957e657, 0x25c121d7, 0x1dabdfb4, 0xa7df3453,
- 0xe9ae5e57, 0x93fb32ef, 0xcef5ad08, 0xc6f7cd7a, 0x9f41af96, 0xe5b1300c,
- 0x014be824, 0x343afbc6, 0xecee94e3, 0xbf1fb4d2, 0xeb12641b, 0x378e7d92,
- 0x741f9609, 0x152ac4ca, 0x24df9b87, 0x3fa5f558, 0x4e01f683, 0x9f5159b0,
- 0x83dc8a4b, 0x963d0247, 0xcae52927, 0x812db7a0, 0xf21270e8, 0x89bf48f5,
- 0x6321c230, 0xbff2a963, 0x4c1f104e, 0x32002052, 0x16abf607, 0x3a79804b,
- 0x4598d78b, 0x1be5056a, 0xc906c1f5, 0x3847a691, 0x50540e47, 0x8a0428f9,
- 0x973aca08, 0x2a6bf89e, 0xb2a58f34, 0x0469dc09, 0xbf74483f, 0x2fdc7c4f,
- 0xe2c4da05, 0xcfc4c982, 0x68ff3f75, 0x17ac6dde, 0x5c261c62, 0xfebaefdf,
- 0xfd6b4a91, 0x91f53fbb, 0x7e216c37, 0xcd7eb26f, 0x8dcb5278, 0x7f19c72d,
- 0x2d6fb96a, 0x92e177cc, 0x9f680ddb, 0xaffe3610, 0xed0a76cc, 0x53a23ada,
- 0xb8c9fc23, 0x1ed420ba, 0xc418be3a, 0xbfea3177, 0x04d35a7a, 0x5ddfd7c2,
- 0x6f576c4e, 0x9e087210, 0x1c4ef545, 0x29463ea7, 0xa7d44f83, 0xb2a1ed2a,
- 0x6ae9cb9e, 0x6f68957d, 0x587bc757, 0x96ad1fb4, 0x522ef195, 0x9ca2cdcb,
- 0xa0f7cea9, 0xe5aa1728, 0x397170ff, 0x613fb44e, 0x29ef559b, 0x53ffe908,
- 0x0f18ddaa, 0xa06ec9e3, 0xc933903d, 0x1abb481e, 0xeda21f98, 0xb15eb685,
- 0x237ff317, 0x44c58c7b, 0xdf63cb8f, 0x90eeb921, 0xf1bae480, 0x8bd38376,
- 0xd49e7ff3, 0x12c6b451, 0xb7e7dfc2, 0x6abb7c08, 0xb6329ce3, 0xde6af95f,
- 0x3923e226, 0x85c8f76e, 0x563addf8, 0x4ea77ac7, 0xe88138b6, 0xfbd0af7b,
- 0xd848ff6a, 0x8686f2d0, 0xb2f5519e, 0x6cc1f3c4, 0xfaf9c1fc, 0xf4f51bef,
- 0x8e59c206, 0x9370973f, 0xdcf42999, 0x95add448, 0xea36f3f8, 0x3dd23359,
- 0x3a9c1b25, 0x1af29f6c, 0xf1a267ea, 0xc7d0bf41, 0x24f8c5af, 0x8f959c14,
- 0x6ff6c9bd, 0x8e528ca1, 0xcf2d7bf8, 0x7c89979d, 0x9fce347a, 0xd0db7c4b,
- 0x75d78db2, 0xe3cadd8d, 0x10583583, 0xcce2cf8e, 0x9e97fc28, 0x3fa5ff01,
- 0x8271fe26, 0x75cfa403, 0xbeb47428, 0x78b796e5, 0xef95cbbf, 0x43325fac,
- 0x472cb8ed, 0x39c68f97, 0x0e1f0832, 0x74074e85, 0x5f050ab6, 0xfabe1357,
- 0x1373fb17, 0xf9f0ecb1, 0x3ed9ba47, 0x88972aec, 0x4071cdee, 0xf92a3f74,
- 0x410ef68b, 0x0ed68eff, 0x5a5bcbb6, 0x84be18bb, 0x55bad073, 0x8d10dd7c,
- 0xc067f9df, 0x131ffcef, 0x01f4a3bf, 0xadfb03a3, 0x4e3c07da, 0x1180ff85,
- 0x2b4cf4c2, 0x27e225f1, 0xfae24ba1, 0x2120b93a, 0x138fa9a0, 0x738e52fe,
- 0xcae9f13c, 0x37aabb19, 0x98792148, 0x311d0b1c, 0x0ed7cc49, 0xc41daf85,
- 0x22ff2ad7, 0x11ea963f, 0xc49d6fcf, 0x37e0437e, 0xf3c0bfc4, 0x3bba78a8,
- 0x881baf1a, 0xabc1a78e, 0xc607feb6, 0xc7fa276b, 0xaf8237a4, 0x653778c4,
- 0x77f9e346, 0x7c555e0a, 0x7fe4536f, 0x236f3c38, 0x7f9ea73c, 0xb4cb6f3c,
- 0xf891b8f1, 0x453ece1e, 0xf75d47d2, 0x7e5a7210, 0x2d3a722e, 0xdff8aadb,
- 0x461677e8, 0xa26dfdd3, 0xf74359bb, 0x53c8339e, 0x4f298fcf, 0x848b7891,
- 0x3ab8128d, 0x3fdfd12c, 0xdf561ccb, 0x4e3c179d, 0xf8d6ce0a, 0x75bf9367,
- 0x29b3fc6b, 0xfd696118, 0xe5349bd8, 0x9aadeb3a, 0xada697f6, 0x6e5fd4d5,
- 0xbfa9af5b, 0x4d01ff32, 0x63c76af9, 0xd3e67e11, 0xe77afa9a, 0x73f5346f,
- 0xea6bb79b, 0x68f4b7e7, 0xfe7817ea, 0x78ab29aa, 0x1c0adadc, 0x356b6d2f,
- 0x65d3f12b, 0xfe03ab0c, 0x8b83125a, 0xdfd9070f, 0xd7b7f4ac, 0xafb24bb2,
- 0x32d1fd83, 0xc296ab9f, 0xcd9d8aaa, 0xb5f4126f, 0x2d78955a, 0xad5be18d,
- 0x3befd636, 0xee19f35a, 0xf128756c, 0x5dc3255a, 0x4e254ead, 0xb48c3173,
- 0xbb66af0b, 0x3d2164a7, 0x44bcbda6, 0xe980b807, 0xc167f87f, 0x77bc5a5e,
- 0xdce28ebc, 0x8e5eca35, 0xffb37f57, 0xe3afe436, 0x950726cd, 0x311fb77b,
- 0xf9a30ad8, 0x32b7ee65, 0x6cf8c338, 0x0d5fcb6e, 0x45cd67e4, 0x0863ba0f,
- 0xa59a9d39, 0xf7207e63, 0xcc2f5003, 0x05218336, 0xd9ecc1f5, 0xf80da392,
- 0x189207bb, 0x3f58dcfa, 0x133e0f4d, 0x7a2deb96, 0x979e299f, 0x3fa332e6,
- 0x132c4b3d, 0x50f07a4c, 0x7324a43d, 0x7d0d7e9c, 0x383ca1b4, 0xbf18b865,
- 0x1c3f22cf, 0xe96f5dfb, 0xbddd9030, 0xfa2fe76e, 0xb87ac36f, 0xf1ce53d3,
- 0x25625c3d, 0x3e792dfd, 0x371a9dd6, 0x3520bcbc, 0x5f1850e1, 0x4e19254f,
- 0xe1d1f8a5, 0x7adc5277, 0x9cf1c193, 0x05dfba2d, 0xc9a77eca, 0xc16ffb12,
- 0x4dde4dd7, 0x713e4852, 0xb84d3b7f, 0x01e226cf, 0xc1b367da, 0x7e445797,
- 0xb3f676f6, 0x16d72a9b, 0x2e9a9d11, 0x15313e91, 0xa69de285, 0x8fd92f96,
- 0x91cfd48f, 0x90f14cf0, 0xfe656fc3, 0x93badfdb, 0x8b8d45f9, 0x5c7d5b7a,
- 0x6ab80b2e, 0x39a3e3c3, 0xa64dff93, 0x4beaa7b8, 0x3c4cff11, 0x53fbdce9,
- 0xd5a077dc, 0x17e52fff, 0x9a82bcd4, 0x5bcc8867, 0xde647aa8, 0x6e0975ad,
- 0x2c9aefdc, 0x94f30651, 0x5ea3a674, 0xdedf5540, 0x9765159a, 0xbd3ac8ef,
- 0xffd6d67e, 0x6cf9fac0, 0x4d31bff9, 0xbe48d5d8, 0x05e337df, 0xe553ad03,
- 0x9ffe48ef, 0xfe707d43, 0xd7924d39, 0xf67a7a83, 0x44c37692, 0x7df9dce9,
- 0x88a0e5b9, 0xc2ed238b, 0x3607b6f7, 0x2b5c9ba6, 0x92617c73, 0x1e50726f,
- 0x4743a544, 0xcf3add34, 0x1fceb740, 0x76d16e93, 0x73bce0f1, 0xf1a08bb3,
- 0x8acbdfcf, 0xc83e27f2, 0xa91fbd3a, 0xf781ffad, 0x636b1d6d, 0xef4472b8,
- 0xea27593c, 0x01627c45, 0x80eff21d, 0x74b8e657, 0x3c7b6669, 0x195033c5,
- 0xb77d278c, 0xf2065bac, 0xd4ef410f, 0x5cfe468f, 0x1f67f0a2, 0x7e243ef8,
- 0x7ef7055c, 0x25980941, 0x22ae4bd5, 0x09f4b73d, 0xfc4f0843, 0x27f393af,
- 0xcb7e94ab, 0xda469d2d, 0xb567f2ef, 0x1a71d4ed, 0x1fc88a5f, 0x19fa5f57,
- 0x73f0ddb0, 0xa7556fde, 0x5977dfb6, 0x62872971, 0x084b1659, 0xa7d267ef,
- 0x1baec947, 0x5b27cac2, 0x3f20bf39, 0x9e03e0f3, 0xc4fa21b1, 0x71f14764,
- 0xf9e9f65c, 0x23ff5b58, 0xf71cb1f3, 0xf9e891ac, 0xbf78f97d, 0xeb4599dd,
- 0xa0f3f556, 0xc4c379de, 0xdca0677a, 0x37a4f226, 0x9e2daefd, 0x3804e4f8,
- 0x2a161d88, 0x6a85d2f9, 0x369d74be, 0xcfb93a5f, 0x49b979c7, 0x716dbd07,
- 0xbd89f748, 0x55dbce1e, 0x59b776ed, 0x5dd3fcb0, 0xa3fc994e, 0x64b96ff1,
- 0xdfeab75a, 0x484efea8, 0xbeb0e58f, 0xf66bbce3, 0xd53bebd9, 0x30f6aa2e,
- 0x06560ed2, 0xfec96bdb, 0xe3b6f84d, 0x2be7824d, 0xf7691eaf, 0x7a138bde,
- 0x57c1a8e2, 0x8cfc97be, 0xcf1c63d7, 0xaffaf441, 0xc67e16cb, 0x0302cf4c,
- 0x1f091fcb, 0x450cdbca, 0x764fae6e, 0xf54d975f, 0x99d0bd8a, 0xa3b2069d,
- 0x23df7275, 0xf95f12d7, 0xde1bce65, 0xbf07c77c, 0xccedb5ff, 0xeb2685f9,
- 0x863ff671, 0x749a338b, 0xa2f8a6e0, 0x4a56d6a4, 0x6dc50c7e, 0xf3544794,
- 0x9fed918a, 0xc8acd7b0, 0xb5573ce6, 0xd9eb49df, 0x1c33d628, 0xbe5a9abd,
- 0x8731e4d0, 0xbba9bf9b, 0x4c30badc, 0x16ca5e3e, 0xdbd22ef1, 0xa21cc87a,
- 0xc5f2d9f7, 0x65f8b7ff, 0x091e0c9a, 0xe4a16ced, 0x082ffe15, 0xf80e783f,
- 0x2083ce19, 0xf9583743, 0x38216a7c, 0x17022e18, 0xdbbb7cc3, 0x60337c4b,
- 0xbe248e08, 0xbbf57fea, 0xfe9be202, 0x57b6278b, 0x5f3bf9c1, 0x06fff48a,
- 0xfe78dbc6, 0xdbbe5781, 0x7039fc43, 0xf4ace187, 0x6764eac6, 0xe451f127,
- 0x53bbcb79, 0x01d73e64, 0x8b967afd, 0x03e8ab7a, 0x1b72a497, 0xe64cd8eb,
- 0x1cde908b, 0x37aab4f5, 0xc2bf6017, 0xd7ac744f, 0xb5e49960, 0x80aed363,
- 0x70ac458e, 0xa657a671, 0x2fa8a772, 0x95e8995c, 0x15585cb0, 0x4a6fea23,
- 0xc52642f4, 0xcb960143, 0x0fac00f9, 0x8bd08017, 0xf7938237, 0x96419189,
- 0x6f17fd84, 0x3e709735, 0xa4390216, 0x8e288bff, 0xb74e221a, 0x2f7908e6,
- 0xbefa12ce, 0x179b46b8, 0xc95b30f9, 0x4a6bdb1b, 0xe7561072, 0x1d12f738,
- 0x1bfc938b, 0x7ca32a1e, 0xa1360e90, 0x75567d7c, 0xaa779f2b, 0x35ed1afd,
- 0xcdbf84bd, 0xe2bc7012, 0x9f7936e9, 0x238ce713, 0xf2cdcfc3, 0xa807b5ed,
- 0x7b5a11dd, 0xc578f0f9, 0x47f71c7e, 0xd78795cb, 0x1bb14c57, 0x43f1fbe7,
- 0xe5cbcf25, 0xebe679ff, 0xf80b3bfa, 0x7e43c14c, 0x7ddda372, 0x046fd79c,
- 0x9ffad0b0, 0x40147114, 0x47e50673, 0xd2653c97, 0x11f19f91, 0x03c8639a,
- 0xddc61bf8, 0xe31bff04, 0xc77f8267, 0x27e099f8, 0xfc133f18, 0x04cfc607,
- 0x1e3b7f17, 0x8d802283, 0x4e4b4e39, 0x301ce879, 0x1c86bd72, 0xf9c1cf81,
- 0x7f3c8dbb, 0xf8cddd9d, 0xebf7a41d, 0x9973a5e0, 0x0bc189cd, 0x6fc34e92,
- 0xf0dfdd03, 0x7870e9f9, 0x2325cf51, 0xe853bfeb, 0x67a9d45a, 0x15d45ffb,
- 0x6b086f88, 0x918e4177, 0x395f0beb, 0x1fe34f18, 0xd7e20eb5, 0xa796e129,
- 0x82f944e9, 0x08332d67, 0x677675bf, 0xe51bed09, 0x51f6833c, 0x83c1f5d4,
- 0x7c78cb13, 0x75a364ab, 0xb8e51f04, 0x911f6221, 0xb5f75078, 0x81bfd139,
- 0x257e6ffa, 0x7a82768b, 0x10dc8407, 0xed43491f, 0xcff32d77, 0xccb05374,
- 0x7e9deb8a, 0x0a1e6e4a, 0x29f675ff, 0x5477e78c, 0xc7cf537e, 0xe952fe15,
- 0x1df2ae76, 0x6b901e39, 0x6ae77e84, 0xb236a5d2, 0xc9e3274b, 0xee57ac2f,
- 0xe6757419, 0xf4fb47bc, 0x6ec194ec, 0xc8d63e63, 0x5f8562df, 0x6dd85854,
- 0x36bd1174, 0x59ca1f77, 0xe4fa6164, 0xb3f6c62c, 0xbc9aec72, 0x89d56167,
- 0xe14a1fc7, 0xea9a56f6, 0xceba783a, 0x60dfe38a, 0x6d36fede, 0x93f5ae69,
- 0xcf2c44ba, 0x1076934f, 0x9ccb605c, 0xe5a3649a, 0x37fd797a, 0x41d94fe6,
- 0xa3957522, 0x29b9fd9e, 0xecc264a4, 0x9639ad43, 0xcb071f0e, 0x4d64d675,
- 0x31b4d2f9, 0xdb97f69a, 0x57f535b2, 0xd4d38fe6, 0xe55ef3ab, 0x2bb4d528,
- 0x51660a4e, 0x60fb875c, 0x64e780b9, 0x7da25daf, 0x1c62beef, 0x3f3da796,
- 0xca6e41cb, 0xda7ea566, 0xd12f5a96, 0x69f10063, 0x70ea8744, 0x1f47fae5,
- 0xe222c1a2, 0x67eec686, 0xe76d3876, 0x130c3710, 0x7100ac2f, 0xdc5c3f8e,
- 0xa02f1910, 0xf4907cfe, 0xd7abf167, 0xdc70db58, 0x2e2755cd, 0xef3ee1b0,
- 0x8238c1cc, 0x47128dec, 0x833fc70c, 0x04d92272, 0xf0c8f4ff, 0x03fc10dc,
- 0x1f850bf0, 0x3ef69c05, 0xdf0533fa, 0x4a7dbf5f, 0x07f38dfa, 0x57efc51e,
- 0xafbe4460, 0x6f78e8d8, 0xdea7e50d, 0xf9ce8191, 0x03ae24e1, 0x77e81beb,
- 0xb0f7c439, 0x46bbe9e8, 0x0f77f0a7, 0x94aba6b9, 0x731fdffc, 0x71aabf14,
- 0xcba35dfb, 0xf370f542, 0x70f69a27, 0xa6b774bb, 0xb6a6677c, 0xbb94ef7c,
- 0xe70ffbc3, 0x5c6c3597, 0x9ca37460, 0x392c3c36, 0x8be843bd, 0x28a4f5c1,
- 0x097ba1fa, 0xdb43dbeb, 0x716d1997, 0xe157edd1, 0x6cb79478, 0xaadec618,
- 0x193aea7a, 0x7faa879a, 0x71cf9d47, 0x08fbe77e, 0xcdf64f71, 0xc3b09af3,
- 0x8db8251f, 0x2fb27ce1, 0xf47b9c47, 0x1dc0f63f, 0xee79d35f, 0xeabe22eb,
- 0xa3f6144f, 0x9d33f3a8, 0x08f1610e, 0xd6455fc1, 0xd2ec8e80, 0x0f58d2c0,
- 0x2d359ca0, 0x8ae8f38b, 0x7e088fc9, 0x5e4f1e68, 0x9a0f2dc7, 0xeb1fce91,
- 0x3cbb1a74, 0x9616c140, 0xd9fd9efb, 0xf7e93b8c, 0xe92f7102, 0x2fb3ed7c,
- 0xad7d8407, 0x1e637a11, 0xb7629ff1, 0xd3565500, 0xc768305d, 0x5e10cf48,
- 0xbf6b9ca8, 0xc987fdf5, 0x7a11efcf, 0x370af283, 0xb4e05fb0, 0x1d0df368,
- 0xbbf8e72c, 0xd73efc2d, 0xb78feb59, 0xf3968dda, 0xd84647a8, 0x218779b5,
- 0x57fbc5f4, 0x5e9b3d22, 0xd05ef997, 0x04f6adb1, 0x911fd308, 0x28da6c78,
- 0xe5ab9cb3, 0xcbe55ba3, 0x830f6cbc, 0xd185f519, 0x83a706f8, 0x55b57fe5,
- 0xd27ab7cc, 0x4ec83337, 0x8bd6eeaf, 0xcdc32f4b, 0x5b064eb3, 0xb79b3cd8,
- 0x5d929699, 0x603fd753, 0xf749f455, 0x0a534957, 0x843b5c04, 0xc0bf457d,
- 0x417e4290, 0xecf1c4bd, 0x3551ee9e, 0x123da784, 0x3c256cf8, 0x5c6635c4,
- 0x1c314cdf, 0x5e50b77d, 0xf9f2d214, 0xd71aa59e, 0xacecf1aa, 0xf27659ee,
- 0x5cec3f63, 0x072907b8, 0xccd9ec93, 0x8782d74f, 0x893deefd, 0x93ca74ae,
- 0x3fee534c, 0xf60c49ec, 0x67bdbf91, 0xf744ac52, 0x3bfc7019, 0x5f757c69,
- 0xf4ae0c7b, 0x9297de66, 0x44fe752f, 0xf67b153e, 0x67aaa271, 0xa7dbe4eb,
- 0xf7e7495c, 0xf14ac073, 0xf85974ec, 0x2147f0d5, 0x6d5eaacf, 0x6c49fc92,
- 0xa633edaa, 0xa34f11db, 0xe4a97e5a, 0xf735db7d, 0xafd6cf00, 0x5fa38c1e,
- 0x567f9894, 0xb1bc4439, 0x47f3faaa, 0x57f9c5ae, 0xfe4fbc61, 0xedaec2dd,
- 0x917f08fb, 0x7c60fdf1, 0x7be62ff5, 0xd733e3a3, 0xcddfda32, 0x73df1c77,
- 0x69c7442d, 0xea817183, 0xcb173e5f, 0x58a8d6e7, 0xfc287c85, 0xee5b647a,
- 0x7f5835de, 0x66062fe4, 0xfd2737d7, 0x58ade8ea, 0x58b9f9be, 0x2491f3c6,
- 0x391d90f0, 0xebcf29b2, 0x744b06c1, 0x6fb25ec1, 0xcf8e25b0, 0x327b3e69,
- 0x512fb7ef, 0x76b7f27e, 0x7e4843f6, 0x7cc2e86c, 0xe88ff746, 0xb9a3cbfb,
- 0xbcc5b81f, 0xca5c8a0d, 0x5fde142f, 0x242ff54d, 0xa5427e73, 0x6327e1df,
- 0x7dac149c, 0x2b22be05, 0x92e7deb2, 0x5bdd10e7, 0x697ba15c, 0xf97c84bf,
- 0x06f708d5, 0xc7f2f7da, 0x89c3f3ff, 0x17da9fb8, 0x1555feae, 0x07d96fae,
- 0x84e340a9, 0xdfb43ae8, 0xb66b6c70, 0x3f057f90, 0xf18c5e2b, 0x27d30c1e,
- 0x35123b2b, 0xd1aea6e5, 0x7a6183de, 0x729ef068, 0x04e7c4a3, 0xed5c8a8d,
- 0xeddbba37, 0xfba5d794, 0x713f4ca9, 0xce84b51f, 0xf7ff08ab, 0x91ff1899,
- 0x5da2f67c, 0xf3566739, 0x4e60c93c, 0x0b75b923, 0x97dc0dfc, 0x31e289b7,
- 0xf1493d9f, 0x33b9823b, 0xb3f9c30a, 0x9c1bd577, 0x7b8931e7, 0x9f43318f,
- 0x13da77eb, 0xf9837db9, 0x699e4d4b, 0x4d09cb55, 0x015567fe, 0xd2501fb0,
- 0x89bd2b66, 0xba1487ce, 0x7aee9fdc, 0xf1def18d, 0x18bbabc0, 0xf2dc4f9f,
- 0xd3bbcd31, 0x5d83f4c2, 0x11163c4a, 0xbf98356f, 0x69efe450, 0xe87e7f8d,
- 0x9445bdb1, 0xcaf438ff, 0xd3ca22b8, 0x87fd942e, 0xf7c99d7e, 0x86dff69c,
- 0xf7cecb70, 0xb91e2f39, 0x0c7ba8de, 0x8d43d092, 0xba648fb4, 0xc77ae3ff,
- 0xf42e72ce, 0x850d81c3, 0x1f353f8c, 0xe864703d, 0xa75d5078, 0x3ebabe3a,
- 0xddb57c75, 0x5f22ecdf, 0x17f46fd0, 0x415ffd91, 0xfb6130e7, 0x17f78fea,
- 0xbbe85a25, 0x4913f855, 0xb7e30e58, 0x2abcf57f, 0xf06a7cf2, 0x47c9565c,
- 0xfdadd3ed, 0xaff91199, 0x8321e3af, 0x7eef5c3b, 0x752a73cf, 0xdafdeabd,
- 0xfd85ab7e, 0x2576939b, 0xe90e9f1f, 0x1deb0ed4, 0xb7bff23e, 0xc7e41c98,
- 0x905c9a27, 0x3469f88b, 0x9afef8fa, 0xe4d12fda, 0x7991efe6, 0x234481f9,
- 0x81e5bdd0, 0xf7fce554, 0x42bd602b, 0x9c16e871, 0xd756acb7, 0xd212c5bc,
- 0x2cfeaa87, 0x0bdf871b, 0x3ea91ee8, 0xdf2027e4, 0xdb6b1594, 0x2da3f687,
- 0xa0ae7bff, 0x6eb25963, 0x24b938c8, 0x1b65c857, 0x9e42c874, 0xa89d1d85,
- 0xbf0d1de0, 0xacd7ee1c, 0x40fcf452, 0x0743d9bc, 0x8ab713bb, 0xf513ab7b,
- 0x5104edbe, 0x124b400b, 0x89f4995d, 0xfab4baf1, 0x1cc86c9c, 0xd8e3cbb6,
- 0xc8504f2e, 0xccd4b77d, 0xf7435bf7, 0xc132fd5c, 0xd0c8218b, 0x413d5609,
- 0x4bc30324, 0x2a70c5c0, 0x0cbc3334, 0x015e19da, 0x02af0c1d, 0x89f8433f,
- 0x1ed80daf, 0xff656edc, 0x3a25f2e9, 0xd765cbb2, 0xcf97ed0e, 0x3c35f052,
- 0x57cb503e, 0xa63e3b9c, 0x8772f72a, 0x7cd8cbc5, 0x2f157be6, 0xec4fe226,
- 0x34de0317, 0xc0209382, 0x46264ce3, 0xdd78a6ce, 0x6b7ef7c6, 0xbae5c9c1,
- 0x6547c4b3, 0x1777adc0, 0xda97810c, 0x9e64f9a1, 0xb90327c2, 0xe951f8c0,
- 0x8dae48f5, 0x30dd2acb, 0x7b234c50, 0xc84f4d10, 0xc59675a0, 0xa7a71cd6,
- 0x5f3fb722, 0x7a8f5336, 0x66b4acb4, 0x5f90a90d, 0xe5154ee6, 0xd32f3589,
- 0xf3fb7d51, 0x71728a97, 0x81c1a94d, 0xcbdae85e, 0xfa825e66, 0x27dcadd9,
- 0xa011a337, 0xb672637b, 0x2b761738, 0x724dcaf7, 0x2fba5ae6, 0x580dba66,
- 0x0063b8df, 0x22d7ecfc, 0xb8bc91b7, 0xb37b1c45, 0x3aafd055, 0x2e4b7dd6,
- 0x2fb333d9, 0xb87486de, 0x28dd6d79, 0x18f79bb2, 0xa49ff8c5, 0x81bdc6da,
- 0xc49932f8, 0xbf7556bd, 0xc189ef58, 0xadb24072, 0xad0cc969, 0x59c75d4b,
- 0xe9d77bcc, 0x774fcde6, 0x023d206f, 0x15c70736, 0xbefb1463, 0x34c4cb65,
- 0x1d7030f4, 0x20475e56, 0x0b4d772e, 0xee91dd56, 0x1bc6847a, 0xf87c1388,
- 0x7529d108, 0x75cbe878, 0xc43b943e, 0xdfb581f7, 0xbd23eabc, 0x042e29f4,
- 0xae4df9c7, 0x475a71fb, 0x51902e93, 0x45fbf48a, 0x05007a2c, 0x9096be21,
- 0x0f107398, 0x1af04e6d, 0x77945e59, 0x99f9ca36, 0x8b03172a, 0x4fc43c71,
- 0x8b55cb99, 0xcc5422ee, 0x60937e6e, 0x16bdbba5, 0x179e686b, 0x724d3d68,
- 0xe4f881b0, 0xc607e268, 0xc76e594f, 0xf454fe0a, 0x9eb6f759, 0xa288c6db,
- 0xb2e4c20b, 0xaf89db69, 0x6f7486ff, 0x5071663a, 0x3e3c90f3, 0xe79c46b6,
- 0x46fa345a, 0x5d09d395, 0x9c383e26, 0xc5a2f5b8, 0x07d26ed4, 0xb7a4d9bd,
- 0xda06f727, 0xe81e7dc8, 0xc8463bde, 0x7fd7ea89, 0x7d8b9d23, 0xfc8cccf9,
- 0xf9104091, 0x839c5e23, 0x8af4fc73, 0xad5f0738, 0xeca93de4, 0x788b7de1,
- 0x573b8d54, 0xde2dbcf6, 0x6ff07985, 0x122bbd05, 0x713e967f, 0x6fc455e3,
- 0xd48bef91, 0x6949b478, 0x7bd7a2b7, 0xf227ed37, 0xc51351bd, 0xbfc345a3,
- 0xa27a6a37, 0xc8d1e396, 0xb9bd46f7, 0xb14afe4a, 0xa1f8a08f, 0xb436944b,
- 0x87c70b3f, 0xf709af46, 0x35c9fab6, 0xd3952b0e, 0xc7d60e2d, 0xe10e3d57,
- 0x6489e1ed, 0x9e5519e6, 0xd893ad97, 0x5af156bf, 0x49c9bcfc, 0x7e7e28eb,
- 0xe8cdfb14, 0xe97b8bef, 0xde913e4a, 0x837bd012, 0x2cc189cd, 0xb9ba67ba,
- 0xfe41df3b, 0x9d5a1ff8, 0x68430ff0, 0x503c6a7d, 0x4b54bf27, 0x2d8e87ef,
- 0x3f0b38c2, 0xa679eead, 0xd5e58ccd, 0x1055e9eb, 0x13f384a5, 0xdf2aafc8,
- 0xc6978329, 0xd543ef01, 0x39153b08, 0xc0e9a537, 0x188f8616, 0x0db008db,
- 0x29300f91, 0x4fcd8bf4, 0x39c7d4d2, 0x4ff4d02e, 0xd4d2cca8, 0xf788c5b7,
- 0xfa71e032, 0xef422a0b, 0x3f9d1248, 0x0083f4d1, 0xbd08adfe, 0x7e27b917,
- 0x4f7e4eea, 0x3ce06fe2, 0x2565f245, 0x7926f69a, 0x5dfc4cab, 0x435ea5fd,
- 0xa6529fcf, 0xb956f11b, 0x9c1cfd1b, 0xb69f4267, 0x01e0263e, 0x5bb317ea,
- 0x984bc9af, 0x85f2da6c, 0x629e4a79, 0xe4d58c2c, 0x2ef10629, 0x61d8fef8,
- 0x0545f31d, 0xbaaafce4, 0x006cf08c, 0x6f1a2daf, 0x5df840c7, 0x1c5ac6c7,
- 0x426a96f4, 0xc932cbcf, 0x8b4baa41, 0xb5b351ff, 0xd6ed1ff8, 0x52cc7be2,
- 0x9bd3be2d, 0xb0bef8b5, 0x4cd78b45, 0xd96f168f, 0xda6826eb, 0x346bdbdb,
- 0x578dbce5, 0xe45fda68, 0x8f29a19d, 0x4d7af17b, 0x858ec2fb, 0xaee2fa9a,
- 0x957a9ae5, 0x83e386cf, 0x11d5bef1, 0xdd03a6fc, 0x74a0f869, 0xf335cfe7,
- 0x9ff450fd, 0x05e8a79f, 0x2bd7fe85, 0xf8dde576, 0xb892f7c3, 0x7a158b4e,
- 0x50df3070, 0xee78e06d, 0x6d725b3d, 0xc505e91c, 0x7b14b9de, 0x894f3907,
- 0x1d9455b2, 0xa2bf717e, 0x36ab9f64, 0x2cf746de, 0x8a8afdc4, 0x09b5edc3,
- 0x1de23ed4, 0x494af4d6, 0xf91dde73, 0x67a66b2e, 0xd1209cad, 0x3f7144bd,
- 0x841ef231, 0xdeab3efa, 0x2739a319, 0x96bdee1f, 0x78c25f9a, 0x2f148c01,
- 0x3efccce8, 0x721fda31, 0x5fd9946c, 0xf6ffb373, 0x79cdc967, 0xfecc6ba7,
- 0xecefe20c, 0x79f5eeb1, 0x3aa3b788, 0x3dfd8d87, 0x00d6fde5, 0x2fdf8c6d,
- 0x3ca4ccf5, 0xbb8600e9, 0xdfd4d794, 0xbd2663b3, 0x5be5c45b, 0xac221503,
- 0xe68f3fa6, 0x71a41fb9, 0xbbd6480e, 0xbbefb14b, 0x20cf3e13, 0x73a2667b,
- 0xff3e12fe, 0xfc2f387e, 0xee147bfc, 0x406df50f, 0x79f0f367, 0x8e25cfee,
- 0xc1a73e53, 0x77e4c2aa, 0x4f79419d, 0xb9b6e22a, 0xb8d4be0a, 0xff328e6d,
- 0x29621c01, 0x5db9f3ea, 0xacbc667f, 0xe253eb48, 0x158766bd, 0xac71bfc7,
- 0x7bef84a5, 0x221d4b39, 0xb8e357de, 0xb1f7f231, 0x87ba67b3, 0x88ed22b5,
- 0x97869e26, 0x57cc8792, 0x42c5e646, 0x1fe316fb, 0x76cb1f58, 0x74fac0e8,
- 0xc6863fce, 0x85f9ca3f, 0xfbdacdb9, 0x3e5bf3dd, 0x02dff0d2, 0xfa9a27cf,
- 0x30d04a40, 0x781ff706, 0x1bd4f475, 0xaffd7f10, 0x9e282a98, 0xe4f5ba45,
- 0x0fc68795, 0x897797dc, 0xb4ce1bf0, 0x1d79cfcf, 0x5afdcabd, 0x5bfb9f75,
- 0xd03971f7, 0xefb8881a, 0xbfc4d1e4, 0x09fe342a, 0x0e8fc9f2, 0x431c234a,
- 0xe76673e5, 0x57a9388b, 0xabda7779, 0x55ed3bbc, 0x2af689de, 0x957b42ef,
- 0xbbeaa177, 0x9c095edd, 0x8e64bf74, 0x816a7ae4, 0x0f76efc4, 0x969b3ed1,
- 0x5de88b07, 0x60715363, 0xbbf3249e, 0x7df423dd, 0x45bb7788, 0x69f49592,
- 0x6ef435ea, 0xcf08f0f7, 0xd9d8b251, 0x50d789f9, 0x28d870bc, 0xc5f4a3e4,
- 0x7bd2666f, 0xdd53c7bd, 0x3fbf89c7, 0xf31f6495, 0x9f12ebf3, 0x6033832b,
- 0xef16719c, 0x13cbbf7a, 0xf32734e7, 0x0a89b9c4, 0xbd0be647, 0x9cb04a56,
- 0x2e6f72e8, 0x68dabbbf, 0x385777e2, 0x7617539f, 0x7df2221f, 0x4d1fc95c,
- 0x6a1fd23e, 0x5f2127de, 0xbbd3379c, 0xca675a39, 0x6ef126fd, 0xa0cfe02e,
- 0x0f747677, 0xbdf245ca, 0x1de29c1b, 0xf0a6de5e, 0xf90930f7, 0x45bd3dca,
- 0xb7a779a0, 0x7ec0e7b2, 0xe5af27d2, 0x53f393b9, 0x56c7ef43, 0x7f676fc6,
- 0xc6df20af, 0x797ae2f3, 0xee17a8ff, 0xc79cfa24, 0x7e56617c, 0xd7fff479,
- 0xf5bc3860, 0x5a3ff62f, 0xf77a1990, 0xaddef616, 0xaf2c3f20, 0x343faea7,
- 0x42e5e9ce, 0xe5a97bcd, 0x93dd8f43, 0x7486724b, 0x5948f911, 0x88633f9a,
- 0x05f3d3fe, 0x774feffd, 0x97f9a04d, 0x60bc8b37, 0x6fda6f88, 0xdce898f9,
- 0x3ef21963, 0x723fdabf, 0xf5b72b9f, 0x9f703e30, 0x617f68f3, 0xf08cbcfb,
- 0xbfb3eea5, 0x05a3ef7b, 0xdfdf73b6, 0x6e777df7, 0x6d71811a, 0x767950d2,
- 0x7e613eb4, 0x3fed4999, 0x8fedaf56, 0xb1e5390e, 0xd1de48bb, 0xe254e96f,
- 0xc4cbb21e, 0xee5daa17, 0x2920e254, 0x02ed83b0, 0x71724bcd, 0xfb61e4b7,
- 0xda3be6a8, 0x947fb424, 0x61af7057, 0x685f217b, 0x775f1071, 0x49f9ef22,
- 0x58cef41e, 0xc44773ce, 0x758b3fd7, 0xbc7844df, 0xa335aff9, 0xf2defe28,
- 0x38942b97, 0x72abd84e, 0x69cb3f85, 0x4147da7e, 0x996df302, 0x730abeb2,
- 0x55c9fb33, 0x5e4591e0, 0xac93c943, 0xdff1c1df, 0x141a01ff, 0x43d0aaaf,
- 0x000043d0
-};
-
-static const u32 usem_int_table_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x51fbff00, 0x03f0c0cf, 0x1894738a, 0x18357a18,
- 0x326b3618, 0x31686830, 0x20318830, 0xaf8568e4, 0x9fa65371, 0x8181959b,
- 0x81f98817, 0xd7881058, 0x6c303133, 0xff5e2260, 0xfb045111, 0xc303209e,
- 0x197f2051, 0x6614ee90, 0x64055860, 0x2fe2031f, 0x1080be40, 0x100c8303,
- 0x606115ff, 0xc1d20530, 0xc4036c40, 0x9bf145c7, 0x7c80827f, 0xbf2a08bc,
- 0x279f8d1b, 0x25ff5f8c, 0x0ff2fc11, 0xc363c808, 0xc7e41632, 0x7a052247,
- 0x29370207, 0xca8ff2a2, 0x543c3033, 0x51d06060, 0x919bf082, 0x6280ede4,
- 0xec21e4c7, 0xb8c09229, 0x28b5ca07, 0x2a773762, 0x5004fe50, 0x34894bce,
- 0x41d3dcf7, 0x8434afe5, 0x3ebc00d0, 0x03a8e414, 0x000003a8
-};
-
-static const u32 usem_pram_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x7de5ff00, 0xc5547c0b, 0x3d9cf8b9, 0x926eece7,
- 0x2126cddd, 0x26c2bc21, 0xb80d4401, 0x41a00c40, 0x94520f37, 0xa2a1e1a8,
- 0x24786c22, 0xf622ef21, 0xddbf1f62, 0x52c488f0, 0xd4c51f1b, 0xb051768b,
- 0x40368bd1, 0x5c1758d0, 0x6d8b459e, 0xd5a045e8, 0x5e40137a, 0xa540b206,
- 0xcffd45b6, 0xdd9ccdf7, 0x26364e73, 0xf6ffef6a, 0x9fdbfffe, 0xcccce61d,
- 0x7cdf3337, 0x9be6bdf3, 0x91be6489, 0xf21387d8, 0x256efc25, 0x108951e4,
- 0x9b4e1892, 0x9fc6933c, 0xedb10994, 0x3bea247e, 0x9e0c8499, 0xd146706b,
- 0x64085fa2, 0x21064b4e, 0x758d65c9, 0x793dfa46, 0xe8bc7d91, 0x9819c308,
- 0xbdbae47c, 0x720c8409, 0x8266f6d3, 0x7fe92fbf, 0xc637b73f, 0x79c87491,
- 0xe131a285, 0xbc9a4afa, 0x877bfa48, 0x149bbeaa, 0x48dda675, 0xfd51fbfb,
- 0x9085b720, 0x4678c31f, 0x40cba942, 0x78b8e8b2, 0xfd2e6f5d, 0xaf0e3a3f,
- 0x295be8cd, 0x1c1a2210, 0x242444b1, 0xa0482326, 0x679fbe9d, 0x49d7ed3c,
- 0xaa36a708, 0x49e74ac8, 0x0896b4c8, 0x808972f5, 0x76cd8878, 0x78e97b25,
- 0xe22e7d57, 0x220d57bc, 0x27d69da4, 0x684ed392, 0x61c4953a, 0x232dc7bd,
- 0xd57e4206, 0x07123fae, 0x199b1b85, 0xdc155e24, 0x0e210f06, 0xc7afc513,
- 0x8f2ae98c, 0xc4c9a79d, 0xab210d71, 0x574c0e3d, 0xfa634679, 0xdb27d0d8,
- 0xf9d00673, 0xe9d8320c, 0x63834848, 0x1191dda6, 0x2dc72786, 0x0938e730,
- 0xae2926c9, 0x2f5a54c4, 0x4dc840d1, 0xf342dc84, 0x19082375, 0x5084ec49,
- 0xbc933dfc, 0x019dca2c, 0x45e60779, 0x7cc37103, 0x2e033263, 0xc62de291,
- 0x1c95cf69, 0x1bf8efe1, 0x785fdf80, 0xc1d6152c, 0xefcc1b7d, 0xf0ece219,
- 0x46dd9e02, 0x7f5a26e7, 0x5e4ceca5, 0x468ae14a, 0xad832eda, 0x1e1094bb,
- 0x1fc04cdf, 0xc9cc8fed, 0x30d7acd5, 0xb4224718, 0xeb05dc73, 0x75b27164,
- 0x1574095a, 0xf2e61d61, 0x77655875, 0x38fd19d9, 0x11fa2449, 0xb1fa5aed,
- 0x8fe96864, 0xba9fb17e, 0xbf69e79e, 0x3bed424d, 0xbd3ce953, 0x4dce0c4b,
- 0xa160dbf4, 0x0af80051, 0x80c425bc, 0x41f92afd, 0x63a05265, 0x179e1ab4,
- 0xf6f7e9cb, 0xefcf730e, 0x52e2062d, 0x2a5372e8, 0xcec4777c, 0x6626e3a0,
- 0x6b4cec47, 0xe987f1cf, 0xc925d924, 0x4c0eef40, 0xac47041b, 0x477ce300,
- 0x9c049b24, 0xf6a4727f, 0x08edd3ff, 0x377ae1f1, 0xda5475f0, 0x3d203c51,
- 0x468b1f79, 0x3450883c, 0x17e70c39, 0xad17cf1c, 0x4a434f45, 0x5868e348,
- 0x875f9a5f, 0x79a663f4, 0xb09be62b, 0x3fca1edc, 0xacc9e58b, 0xba5e5d3e,
- 0x55e3bd18, 0x6eda1759, 0x4291c203, 0x38445e70, 0x9bbf5096, 0x94203f30,
- 0x1fd625ff, 0xb7f7eaca, 0xceed251f, 0xf9c29e0d, 0x003b2ebf, 0xd6dbc29f,
- 0x2e94adc0, 0x7c106e0e, 0xec0f9a26, 0x75fe418c, 0x9f0cfd7e, 0xd767e289,
- 0xea0b9338, 0x8398df9f, 0xefedbcf9, 0x5e5a24db, 0x20945db5, 0xd679d86f,
- 0x5bf141d6, 0xfc7f6a63, 0xb83dfa66, 0x602f245d, 0x9f71d377, 0x48b4e29d,
- 0x92f9633e, 0xdaad9628, 0xc01e6bb0, 0x91336b2d, 0xeaa70a28, 0x6f3bd2cd,
- 0x03d2f9a6, 0x552a8132, 0x838cea9b, 0x4f897e69, 0x8afc8168, 0x3f601f9d,
- 0x0ca4b9dd, 0xe039f7f6, 0x752f945b, 0xee93dadb, 0x7dcbdfa6, 0x7ea00a5b,
- 0x09c166f9, 0x7ebe5c4b, 0xbf0087d7, 0x211e55bc, 0xcd15f852, 0xdaa1c431,
- 0x17db792f, 0xade309df, 0x9426477a, 0xabb291ed, 0x1891190f, 0xe02346a4,
- 0x13d36ab5, 0xe79be046, 0x1fb0073c, 0x2f559f05, 0xbb687ed3, 0x2704d7ea,
- 0xc0daad4c, 0x3785cdf8, 0x68bce6a3, 0x19d57981, 0x37fb4147, 0xbd42351f,
- 0xebf15f52, 0xdf180e51, 0x8c016306, 0x6306fd73, 0x566f8a89, 0x3356ff34,
- 0xe94d53ae, 0xbd19dd03, 0xce39e7af, 0x397c95b7, 0xdf484015, 0x4338cf92,
- 0x339e87c5, 0x57fd21c4, 0x11c48b34, 0xdf781f81, 0x8760fbe7, 0xbe03f195,
- 0xc0ed4b5e, 0x75ebc21a, 0x4fd7cec9, 0x88cd660a, 0xe71ee7c0, 0xcb91a3f2,
- 0x7e41278f, 0x2e69f4d0, 0xf971d63f, 0xe271e4d1, 0x933d67f7, 0x71ef5d30,
- 0x67bcfa61, 0x4f3ea61a, 0xc17bd611, 0x8dd30733, 0x7f7e371e, 0x698653c9,
- 0xbf16a7b3, 0x8e59e2bf, 0x178f66e9, 0x59e6bfbf, 0xa78b6983, 0x9eadd311,
- 0x3d5b4c26, 0xbaf7ac3e, 0x36d319a7, 0xff7e0b4f, 0x530da7b5, 0xe98027bf,
- 0x9a5f584e, 0x98ed3c06, 0xc31cf6ee, 0x03a7af74, 0x9cf7eddb, 0xc72d74c1,
- 0xe49b2dbb, 0x366f1448, 0x18394117, 0x91cae85f, 0x88be3e69, 0x7ae693e5,
- 0x9f348c73, 0x8a79a6e4, 0x8195c1c7, 0x0fcd131c, 0x29e565ae, 0x66b9243f,
- 0xb2f14f9a, 0xaeb5b4f2, 0x4f9a28dc, 0xa3e5646b, 0xa3737bd6, 0x8f947e69,
- 0x39b75f95, 0xf3431b90, 0xf2b0b5d7, 0x67927eb1, 0x01b1f9a1, 0xd07f1f96,
- 0xf9a56795, 0x9f2cedf1, 0xcf37a1f5, 0x1d59f346, 0x5d4dfdac, 0x9a58bc81,
- 0xcac829bf, 0xf24ab96f, 0x2e4003ed, 0xb5cf980b, 0xd1c7e4e4, 0xe59dae7c,
- 0x4b16860b, 0xb7f4088e, 0x0858ee53, 0xb0867c22, 0x7e5125d1, 0xf1d8d3b3,
- 0x647d1510, 0x4baaf0a1, 0x2033fca2, 0xfe504593, 0x963af0b0, 0x19648c07,
- 0xbc2a3f94, 0x65bbe58d, 0x5cff9607, 0x46f2c038, 0x87ff9607, 0x7bf30870,
- 0xef961765, 0xf2c4fe10, 0xff961746, 0xf981385e, 0xcb1bb2fd, 0x962e853b,
- 0xfcb1ba37, 0x5753e949, 0xdf2fed3e, 0xdc2e9ee0, 0x5ddb7208, 0x6a597286,
- 0x597e0649, 0x04fff9cf, 0xaf2d0640, 0x3944641f, 0xacf3f3b8, 0xd3814517,
- 0x97c800f6, 0x05fa04bc, 0x485b3385, 0xc2827d04, 0x7386fb11, 0x349317cb,
- 0xa2f96e70, 0x20f3814c, 0x1fea89c2, 0xdc5f9d9c, 0x17cf1da4, 0x129c0ae5,
- 0x7fb5979c, 0xcbe5baf3, 0xbe78ed6c, 0xd4e054ac, 0xfeb89c20, 0x4f20278d,
- 0xc809c0d4, 0xe59c0aa5, 0x7fb12708, 0x271971e3, 0x8cb8e06b, 0x7538144b,
- 0xff506708, 0x378c04e0, 0xac63c76b, 0x863ce050, 0xbfd61e78, 0x534cb979,
- 0x5531e3b4, 0xc29e7029, 0x0ff6a4f1, 0x16ab6ece, 0x21adbb3f, 0x3847acfc,
- 0xaf37fb23, 0x3f169b5c, 0x7e10b6b9, 0x6b9c2136, 0xb76707fb, 0xdd9f8b4d,
- 0x5e7e10b6, 0xe98cfc43, 0x6372bcdf, 0x8dc9f8b5, 0x0de7e10d, 0xfeb8cf1c,
- 0xa26f678d, 0x137b3f16, 0x2009f843, 0x37fb1b9c, 0x2d24fc9e, 0x4293f27e,
- 0xe10779f8, 0x9c1fee4c, 0xfc5a49bd, 0xe10a4dec, 0x67080fe7, 0x95e6ff4a,
- 0x9f8b503f, 0xfc2181fc, 0x7270807c, 0xa94ccddc, 0xbdac70a4, 0x4c3fd9c3,
- 0xc3fd9f8b, 0x8939f842, 0x3852a670, 0x29c37de9, 0xa7e2d148, 0x9f842520,
- 0xb6e708f3, 0x9fd9c1fe, 0xfecfc5a2, 0xae7e1094, 0xfa3b9c20, 0xe182af37,
- 0x0c14fc5a, 0x55b9f867, 0x8672871a, 0xd8274eca, 0x9a19dfe7, 0xc13212e3,
- 0xd179624e, 0xf7a024ee, 0x433e8a88, 0xad225dda, 0x371cd96f, 0xd6a231fe,
- 0x068d726b, 0xaa56cf4a, 0x9af5a9e5, 0x1ad149d8, 0x15ce2a3d, 0x4c27c9af,
- 0x9fa9ac1b, 0x29a69458, 0x3ae7381f, 0xf720f94d, 0x487e4d78, 0xfa9a4dd9,
- 0x35736ac3, 0x6fcbe1f9, 0xf54fd4d7, 0xd3e4d4ce, 0xa9afdcd7, 0x8171b23f,
- 0xa69afca6, 0xb5f94d72, 0xfc9aa5be, 0xd7dfcdf5, 0xb2d31fd4, 0x437e5342,
- 0xf29a63db, 0x35278171, 0x9e0709f9, 0xb1bfd4d5, 0xf94d05fd, 0x68af63c4,
- 0x6c7727ca, 0x3e6fe4d5, 0xfd4d6bf3, 0x9addc129, 0xbd9fadfc, 0x439fa9ab,
- 0x6fab53fe, 0xd4d03f9b, 0xa13f6a9f, 0xf24eff29, 0x553d3a27, 0xccaf1f6b,
- 0x32afcc21, 0x01afd988, 0xc6f311ab, 0xa76616c1, 0x271c4b58, 0x7718fd29,
- 0xa00c742f, 0x033403f4, 0xe0ce5176, 0xe83a6bb2, 0xe4ddeff7, 0xbf4ec6be,
- 0xbee8cf7f, 0xbf411ec1, 0x9026f4a1, 0x061d4864, 0x8fe5f548, 0x73de8cca,
- 0xd51d5c87, 0x18d7db49, 0x68e2a382, 0xe73123fe, 0xf9c7a03e, 0x83ee0306,
- 0x42d49168, 0x411368bd, 0xd4d1e9bb, 0xaabd17ac, 0x1866b0fd, 0x308433d5,
- 0x3bb235dc, 0xc328f519, 0x9bd03af8, 0x79d187ea, 0xd164260d, 0xbcbb718a,
- 0x61fb6823, 0x8fe0c925, 0x3f991930, 0x91bfd424, 0xfd819ff6, 0x6bfe812f,
- 0x94dfe97a, 0xbfd34936, 0xd34ca539, 0xfb48d9bf, 0x90f213b7, 0xbfde26e1,
- 0xcb36fd19, 0xfec64c56, 0xd865294d, 0x6a46a3ff, 0x8ffba977, 0x88fff50e,
- 0x31ebf681, 0xc7b9bb30, 0xd26ed3fc, 0x5ca53fce, 0x9b237f3b, 0x2e434aff,
- 0xe71a3fef, 0x0e456abf, 0x394a7f9b, 0xc189bf9b, 0x0b6ff50d, 0xfa01bfe1,
- 0xfd2f69ff, 0xb5b3d29b, 0xa95e1ff3, 0xf589bf9d, 0x76e194ff, 0xfb05bfde,
- 0x6dc57a7f, 0x2bc3fe6c, 0xc9a37fb1, 0x31fa04ed, 0xf5ae890e, 0x50c9fed1,
- 0x040d256a, 0x40fda172, 0xfd1e3a3a, 0xd21a7708, 0x8bdf1c70, 0x2576f466,
- 0xf21bd29a, 0xc3b32f33, 0x5273947d, 0xd39aaabb, 0x1ce6c57a, 0x2c3df023,
- 0x3164224f, 0x36a2ea1f, 0x3c9be911, 0xa48df26d, 0x26d0bde3, 0xe8bf217a,
- 0xe03e29e9, 0x322635af, 0x49da08bf, 0x3fdf0024, 0x1798d9fe, 0xa7d2f3d4,
- 0x53e51b8b, 0xde45fc91, 0x96ba325c, 0x1002ef8e, 0x9c7f2a81, 0x186071da,
- 0x1eed487f, 0x139fed42, 0x23efeb32, 0xbe41ef6a, 0x687bda83, 0xe63a9338,
- 0xdebaf357, 0x5fc7411f, 0x0b9f9444, 0x6e2f79e7, 0x624f0a29, 0x5af8f7fb,
- 0x31eb07c1, 0x450c797f, 0xc53c787e, 0xbe4d04de, 0x07eac4c6, 0x2f7c136f,
- 0x0dc30808, 0xe1c199f8, 0xcd2f1811, 0x36b3b1cf, 0xb1de7747, 0x7dd1b05f,
- 0x5d0866b4, 0x599c308b, 0xa40f25c4, 0x565eefed, 0xa76b832c, 0x8186105d,
- 0xa166b09f, 0x3768024c, 0x0649137b, 0xde3a0e27, 0xfe0cedfb, 0x527c970c,
- 0x239b47ed, 0x74455d9b, 0x458a733c, 0x69acff1c, 0xed3ff2da, 0xc619718c,
- 0x53cd74d2, 0x45ddcfd8, 0xe77bf2da, 0xb9f7f368, 0x572a79b5, 0x0fab9065,
- 0x53bfe994, 0xdf8124b4, 0x001bf431, 0xe3907ce3, 0xd95ac1e1, 0x6a5759ab,
- 0x72951b76, 0x09b88470, 0x8bdb0bce, 0x5fcfeb3d, 0x7b17cdae, 0x6b85f9b5,
- 0xdd39f074, 0x7febe29c, 0xa683e81c, 0x283e81a7, 0xfa724f3e, 0x2d55f308,
- 0x9a13dc7d, 0x650fa306, 0xb624a71e, 0x33d6a704, 0x18dc58fa, 0x8a1e9913,
- 0x52e0f443, 0x0f4297d3, 0xfc3d38f3, 0x6943d399, 0xeeae9693, 0xc9d5be23,
- 0x6b03fdb4, 0x1d3ae177, 0x3d198a11, 0x87a140fc, 0xb83d0d0e, 0xd7e83d39,
- 0x87a71e6f, 0x7a308f79, 0x0767afd0, 0xa68e87a7, 0xeb4932cb, 0x1d74aeb9,
- 0x0eba7934, 0xa3b775ba, 0x47ae8a1f, 0x10587a44, 0x389d379a, 0x65e42fcd,
- 0xd38bd63d, 0x01a79603, 0x09e209da, 0xacf7a7db, 0x2684f94f, 0x7914da5f,
- 0x36da6bfd, 0xfaa93dac, 0xf2f2d55e, 0xbb7fb55a, 0x268b79a2, 0xa6f7c4bf,
- 0xd3697ea6, 0x717e4d2e, 0xfa9a3be3, 0xd21cd70b, 0x7fbd8be4, 0xbf9fd4d4,
- 0xfe5353bc, 0x4d59ed60, 0x176503f9, 0xdcfbf935, 0xbfd4d37f, 0x13f08e77,
- 0xa2eefe75, 0xeba89fa8, 0xa7169acf, 0x0d70cfc9, 0xec37d4d2, 0xa02ef6bc,
- 0x8bef83c7, 0x4f8ff404, 0xffd1a79d, 0x7653a9f9, 0x1e939d42, 0x5383ee07,
- 0x9e98d19e, 0x9f7138f1, 0xc24cf39c, 0x1edb42f4, 0x2a15c80b, 0xc8e04b47,
- 0x96e574a6, 0x20d935ba, 0xdfca09d7, 0xd46f958a, 0xb2128779, 0x8a639414,
- 0x2326c2ef, 0x44204c09, 0xc7c4e100, 0xe5551415, 0x37947d1d, 0xd0914151,
- 0x23b0bcb3, 0x279af7f2, 0x23db878b, 0xf7847f9c, 0x7a021935, 0xe72f7752,
- 0x29029524, 0x64277f52, 0xad81f205, 0x34a94f5c, 0xb9517e32, 0xb12e5075,
- 0xaa303e41, 0x6bfaabf6, 0x206c9ba1, 0x66ba49d0, 0x5d36973f, 0x04f7e1af,
- 0x4089cfbc, 0xdf34136f, 0xd66f9a2b, 0x25daebb4, 0x81abb8e2, 0xfdb95097,
- 0x527a292a, 0xd8153e04, 0x0c6b3293, 0x14f5d38c, 0x5112dbe6, 0x34f2ec8f,
- 0xc7f385af, 0x4c169e73, 0x30da78cf, 0xac09e53d, 0x93c07385, 0x1e98039e,
- 0xda63b4f7, 0xe98639e1, 0x4c0e9e47, 0xc19cf43f, 0x209e4ff4, 0x9f3cc7a6,
- 0x43c47a61, 0x0e70027e, 0xfe98cc7b, 0xb4c763c1, 0xe98c93dd, 0xfb0f8f05,
- 0x5f5df651, 0xcb867774, 0x7f4073ed, 0xbb6ce811, 0xcd6eac78, 0xbd9d30d0,
- 0xa423f2b9, 0x85cf0533, 0x0f4e264d, 0x087a1a49, 0x2377ed80, 0xe51f4bd0,
- 0xc3a7324d, 0x2e47dade, 0xbfe179af, 0x7caede87, 0xd30b7a4b, 0x3d1d10d3,
- 0x4f45f7a5, 0xe9e9aa1f, 0xe4cec18a, 0x1fa7a720, 0x7d6b73f3, 0x3b1251bf,
- 0x77e90ca7, 0x800cdbae, 0xdcfca5aa, 0x98699084, 0x5efbc4bf, 0xa3b5c149,
- 0x0d1be81e, 0xe8d2eb72, 0x73828fbf, 0xe8c74b87, 0x3ef6a7e2, 0xf49d3d3f,
- 0xda17778e, 0xba3e2543, 0xc61109e8, 0x1af0cd1b, 0xc8d32065, 0x461a4278,
- 0x905ce4be, 0xc4897981, 0x739f7b43, 0x3af38446, 0xc06b7542, 0x5d785f6f,
- 0x1632bd69, 0xf67a9de0, 0x5e90591f, 0xf475fae1, 0x7cf5111e, 0x09d17812,
- 0x25c90df8, 0xfc193393, 0x4691c1f3, 0x6409ea3b, 0xde7f16ba, 0x6bf835db,
- 0xcfce5548, 0x7f11931b, 0x1a8cae23, 0xf5fc0fd4, 0xc2fbdfc5, 0xf79802e7,
- 0xfb3e037f, 0xf17d8fe2, 0xbc72e245, 0xdfe746d6, 0xf8cc73bd, 0x07c01cc7,
- 0xcadf1abf, 0x3c7e9c79, 0xb5f492f9, 0x493bb8e8, 0x14f6e3a1, 0x24d85b88,
- 0xa5fe11da, 0x61626bd6, 0xfa70425d, 0xede14f58, 0xbd80a73f, 0x0b553e7f,
- 0xef074b2f, 0x6d1781d2, 0x4d2d7760, 0x3270d85e, 0x69283ac2, 0x835d4b55,
- 0xb687ad45, 0x1a97f369, 0x382d6985, 0xecec472e, 0x6a272031, 0x5edf181b,
- 0x6702a98e, 0xf6097269, 0x3d39ae73, 0x3e7bd996, 0xc7360fc6, 0xe738bf21,
- 0xfffac329, 0x06f4f1ec, 0x210f1947, 0x1984e4ad, 0x4b2d31f8, 0xaf7ebdef,
- 0xc5fd2cf4, 0x7edde788, 0x89e80af9, 0x97dffa66, 0x09107760, 0x9adc0af3,
- 0xba6bd116, 0xd66fbe01, 0x39db47f4, 0x2fe23394, 0xdf6abed3, 0x4294e448,
- 0xd45e54b7, 0xe780bd83, 0xd41a4b9b, 0xcb55597a, 0x9af93577, 0xd41a47b6,
- 0xfc055c7a, 0x525ff283, 0x3740482b, 0xba8c9c95, 0x811acb25, 0x8218af8e,
- 0x088f804f, 0xb9955eac, 0x9fa6e8c3, 0x75b2b7ce, 0xe77c6deb, 0x8854e63c,
- 0x3733283b, 0x597239e2, 0x20f9b5cb, 0xaeb7ce67, 0x5bf9024c, 0x5efa5e21,
- 0xbff68451, 0x5f2e0494, 0xcf56a0e4, 0x2841f4e7, 0xe9bcd55c, 0x17c212cf,
- 0x981977cd, 0xb70f465f, 0xbe91cb8d, 0xf9bd53f0, 0x8ecdc150, 0x6eaa789e,
- 0x237468bb, 0xcbffa45f, 0xc149e30a, 0xd454b15f, 0x9771d126, 0xffa27737,
- 0x1dec8ce2, 0xe0af83f5, 0x67e73d97, 0xa3153e49, 0xb497979a, 0x260b3f43,
- 0xe3888ef1, 0x1f280fde, 0x995bfb3f, 0x57221f00, 0x742cad69, 0xc7bb70cd,
- 0x61590c40, 0x6b4167bb, 0xfbe02145, 0xd1d3ebec, 0x8a445bee, 0xa40eb86c,
- 0x9cec0b31, 0x7180c4f3, 0x1fc9e755, 0xeb54136c, 0xe464b1f0, 0x305ca678,
- 0x1034bb89, 0xd8107bbe, 0xf539a65f, 0xf858e2ed, 0x9076292e, 0x15ca25f0,
- 0x17f180b7, 0x2f77d873, 0xfd01d731, 0x634a7b52, 0x4a7b51af, 0x94f6a793,
- 0x66425f26, 0x453c4126, 0xf132d3c9, 0x4d278809, 0x8ec941f9, 0xb5252be3,
- 0xfd1fa0f5, 0x16e1fb9c, 0x843489d8, 0x37aa87ca, 0xa62acb9e, 0x9892e9f3,
- 0x0f894bff, 0xc5654258, 0x5e5e5a20, 0x2cba33e6, 0xa277e73d, 0x943dc275,
- 0x163c03f3, 0xd1bf7007, 0x886be2c7, 0xaae2ca43, 0xf3ef5a4f, 0xba2ad81f,
- 0x8f506ca2, 0x9bc6577e, 0xafe7f5fa, 0x4f212f9f, 0x9bca3ce2, 0x561c6067,
- 0x3e07788f, 0x7059b91f, 0x27ec22f9, 0xf1341651, 0xc332092e, 0x1ad7e29f,
- 0x0f5fcbae, 0x6bdf9579, 0x1bfcaea2, 0x440197f3, 0x258a5fc3, 0x913970f7,
- 0xbfc013f1, 0x7f710520, 0xc9f8637d, 0x2f5fe03d, 0x844ff8df, 0xefbb543f,
- 0xff89fc29, 0xe88ff1d4, 0x48bcfe31, 0x78deabf0, 0x778875f5, 0xcfd5ff2c,
- 0xb7ee846c, 0x926352b3, 0xe57bae93, 0x1736d5a6, 0x6bc91df0, 0xd6717d83,
- 0x448b4e27, 0x7997df0f, 0x59711fdc, 0xc2bbf004, 0x73fc293f, 0x4ef8fcaf,
- 0x6caea3b0, 0x4fe8ed92, 0x4c05366d, 0x5bab9e94, 0xb1921497, 0xf964ef98,
- 0xfd022f47, 0xc7c9b4d7, 0xfe5a74d5, 0x41259fcb, 0x94a5107c, 0x48648621,
- 0x549f6803, 0x00b8fc6f, 0x121a8df4, 0x6faafdc4, 0x167ffd07, 0xd8b0f28f,
- 0x1cb3db18, 0xd049341d, 0x5a6afd9e, 0xb4517c7f, 0x69db7a41, 0xb2d46fe0,
- 0xbe90bf44, 0x3bb7195d, 0x00eb642a, 0xc913abe4, 0x0aabe044, 0xd98f885e,
- 0x7e5f2b1d, 0x1d276c66, 0xdfc6d757, 0xbe1504da, 0x52e97b14, 0xfc5fc2cb,
- 0x1f3bd1da, 0xa3f740bf, 0xe455bf5a, 0xdb8da394, 0x56967e4b, 0xc41b01ca,
- 0x906e5573, 0xb9fa5e9d, 0x5f17d5f2, 0xd9fc167a, 0x4739347f, 0xaf15f852,
- 0x13723bee, 0x916c57cd, 0x69b21407, 0xf0a48458, 0xffd0d4fa, 0xaf0f8f96,
- 0x7db6f947, 0xf618c746, 0xe1f187fd, 0xb2d8a975, 0xf4c648cb, 0xcb5e47c4,
- 0x2587632e, 0x74b4fac2, 0xb7fe8016, 0x1abfe5f2, 0xdd9def81, 0xa9819029,
- 0x61b9f011, 0x8087ea1f, 0xbe4f5c27, 0xd3f5a15e, 0xeba1afd5, 0xbf467202,
- 0x857afa5e, 0x5c00bf9c, 0xf4a1b388, 0x21afdafd, 0x264fee0e, 0xeca1e027,
- 0x306c87b5, 0x2d52d39f, 0x56e7f3a3, 0x2bbf0127, 0x7649bd93, 0xb2f7d94c,
- 0xfa461fe7, 0x70f43d2b, 0xba57f312, 0x76501906, 0x3cc1077a, 0x1bbfaf17,
- 0xdc4259e7, 0xcf658748, 0x9a3e4589, 0x69912a7e, 0x93ec225b, 0x9c9f7c4b,
- 0x2e2e817e, 0x4569e79d, 0xe441fc2e, 0xe8bbe172, 0xcf987d0f, 0x98906a85,
- 0xd6ccd4ff, 0xd06c80eb, 0xfd10d1c8, 0xe5147c6e, 0xae61b9c7, 0x56ee7081,
- 0x28179613, 0x5343c447, 0x6275b207, 0x51db0772, 0xdf0793b9, 0xecbb7ea1,
- 0x69ab1a8a, 0xe9467287, 0x9fef197f, 0xf41a3b8e, 0x9149d3b7, 0x46e191ed,
- 0x3d500f85, 0xaa674543, 0xfff6cefd, 0xdfb606c6, 0x9beffd95, 0xffca0d31,
- 0x23ed9872, 0x97720768, 0x10302b8e, 0x16cd77cb, 0x48983f90, 0xdf3ed220,
- 0xae7df328, 0x0bd3d72d, 0xc424bf1d, 0xfa06e8aa, 0x4075c789, 0x34f25f79,
- 0xa3e2af6d, 0xadafd035, 0x1f655c27, 0x707e7297, 0xf5c1f81e, 0xd6407e61,
- 0x5e2bf627, 0xbdf652b4, 0x5fec2cf4, 0x0ebd5fba, 0x1172bfd8, 0xcd93ffcc,
- 0x4fdc8e7b, 0x2d27edf7, 0xf2d5beca, 0x2dbefd55, 0xc630fadb, 0xedf7eb9f,
- 0x496b4327, 0xbf4b7dc4, 0x43b7dc47, 0xf847fe3b, 0x24c782aa, 0x2aaf96a3,
- 0x7c37b27c, 0x16e4f9ea, 0xd57881d9, 0x3bfa49f3, 0xd27ab24c, 0x0a8742a3,
- 0x47ff95fd, 0x47e070d5, 0xe8553a21, 0x0aa74430, 0xade7ea1d, 0xfcbea3c5,
- 0x522df023, 0x537a297a, 0x4a95f3c6, 0xa6038b3f, 0xc90ff6ed, 0x50b97c44,
- 0xfdc691cc, 0xf3a80643, 0x45be5d3e, 0xcba5df57, 0xbbeae917, 0x4d5af975,
- 0x3db6cafd, 0x10748246, 0x9713d4d0, 0x31393bff, 0xfadd1221, 0xf5a1bf98,
- 0x39ee11a2, 0xd88258d4, 0xbc415e5e, 0xdc191f10, 0x51b9e221, 0x3d71c537,
- 0xa73637f8, 0x8f94bcfa, 0x7e628eac, 0xd07b6e85, 0xd5d34f16, 0x4c1f2c71,
- 0x1f03d634, 0xa307be54, 0xbbb1df98, 0x538b6828, 0x7e9d5bd9, 0x8778f911,
- 0x0dbdf22f, 0xdd70692a, 0xd7b97a3b, 0x758f9ca1, 0x62c6db47, 0x3e29d17f,
- 0xa2a9c7a0, 0xf8396525, 0x27451aa1, 0xea8bece8, 0x79c1b5ee, 0xfd3fb755,
- 0xfbf439ae, 0x164477e2, 0x4975e38e, 0xd0765483, 0x975de219, 0xf05c402d,
- 0x859fa45a, 0x2d17667e, 0x3f791b5a, 0x2576f394, 0xe0466596, 0x390ed4bb,
- 0x51ef3eae, 0xd7ad94e0, 0xe74ff77d, 0xed11a6fb, 0xda8df2ff, 0x9fb73772,
- 0xfce4647f, 0xc7191c67, 0xbfe657ed, 0xaa7b7ce1, 0x1cd77198, 0x07dd3eba,
- 0xf9a26244, 0xd7117e4b, 0xc166d2e7, 0xe237fe07, 0x57fdc44d, 0xf546824d,
- 0xd82e887d, 0xcef4d75f, 0xffb6bac7, 0x4007eb39, 0x307faf47, 0xda69dff6,
- 0x471ffaf5, 0x37f905bd, 0x407ca68e, 0xdbcfd67a, 0x02f18519, 0x48ad3bdd,
- 0xde3bddff, 0xe401f94b, 0x613934df, 0xff3bdd9c, 0xa9e8163a, 0x0ca9857b,
- 0x30f760f8, 0xb95dbfe6, 0x3b63afe3, 0xc2aefe50, 0x1a366c75, 0xffc99f99,
- 0xdee08f8f, 0x9d3f25c2, 0x3c17e815, 0xd7e6beae, 0xf0823e51, 0xbea59aff,
- 0xe76df40f, 0x43e3cd53, 0xce64adba, 0x1c5f1856, 0x79a87f8b, 0x758bf26b,
- 0xd6aaffb4, 0xb485c65d, 0xcfedef3c, 0xfd1c62c7, 0x5d37a656, 0x879e3b90,
- 0xc66d87f8, 0x2994acef, 0x26c02f9e, 0x5df646a3, 0xb07935a6, 0xe5e27a8f,
- 0xf5a7f473, 0x1aef1f17, 0xaffd7d99, 0xc5c10f8f, 0x67d59ff8, 0x7fde6016,
- 0xf403e8fb, 0x2e909a83, 0xd27ef995, 0x4cfa8752, 0xfb3ef35f, 0xfa0e86bf,
- 0xd0216f3b, 0x4d9b799f, 0xfdebdaff, 0xeb81d1b8, 0x3d07dfa2, 0xf7c77ce9,
- 0xd5aaff30, 0x27ede389, 0xfd368fbd, 0x5beeb63f, 0xfadbbae9, 0xfe77f79e,
- 0xfbdde7c5, 0x8f33bfba, 0xce1dbbaf, 0xfede6b53, 0x75f7c71c, 0xffe95cf9,
- 0xf457ba52, 0xad4376fd, 0x6f8e933d, 0x82b4690e, 0xe25f7162, 0x03a64b25,
- 0x0f2f70a2, 0x383bf8c0, 0x57608d5f, 0xbf989935, 0x581824cd, 0x82dddabc,
- 0x3b4447e2, 0x5fae4eeb, 0x0cb439dc, 0x5d3b90f5, 0x827d413f, 0x39edb548,
- 0xee7b7eb4, 0x6ac62742, 0xdcc7f192, 0x853d9f90, 0xe6f6b5e7, 0x12e204ef,
- 0x677f7ea8, 0xa003f4ee, 0x12e5dee7, 0x29a60f51, 0xa7efbfea, 0x93efb014,
- 0x7dd0f6b4, 0xdefe6d6e, 0xddfcda39, 0x843dde1c, 0x229eff8d, 0x587e07c1,
- 0x8953ce53, 0x2d3597e0, 0x0a908996, 0xabb54671, 0xbbb8eec1, 0x197edb48,
- 0x7f2a6728, 0xe3c537e3, 0x5c78436f, 0x3921788a, 0xed03de22, 0xdc7c8f13,
- 0xf9c7b3ed, 0x489ace20, 0x7bc7864e, 0x37e89caa, 0xccb8f6e7, 0x3596cbdb,
- 0x659fb0ed, 0xd8ae1d9d, 0x9be1bdd3, 0xe11cfb70, 0x2ff185a4, 0xcfb444bb,
- 0xae7d9d65, 0x5dd7cbac, 0xbf1d650f, 0x073cbaed, 0x786372eb, 0x5c5a865d,
- 0xccabf604, 0x8b7c87ed, 0x1687e593, 0xe8ae7611, 0x00d2fac3, 0x8466f117,
- 0x9897d1e3, 0x9ce02b8b, 0x405a3ccc, 0x6b5dc87f, 0xe60f9445, 0x55c7010c,
- 0xf8c64934, 0x450d8fe3, 0x85deb059, 0x7f562613, 0x09c30d9f, 0xf1c25cf8,
- 0x516a425e, 0xbf57257f, 0x0b3b32fc, 0xea0825ce, 0x845c4bbf, 0xb8ed41dc,
- 0x10216c92, 0x126af10d, 0x078ec6f1, 0x8e40b93f, 0xdae4fc6b, 0x496efc3c,
- 0xabe9c30a, 0xe5fc6f7e, 0x17fe9d9f, 0x29c767e5, 0x3a427491, 0xd497bb12,
- 0x3f7cf776, 0xa54d63c3, 0xba434be0, 0xfbeac80b, 0xb66605d3, 0x87ebfe0f,
- 0xe64f9013, 0x2c4c74fc, 0xe26407f3, 0x6e1ac47d, 0x3af25c37, 0x760fc162,
- 0xcfce9fc9, 0x6a6cf373, 0x87a4aabe, 0x9ffe1db8, 0xd3489710, 0x51a17cee,
- 0x048b3b04, 0xcdebffd1, 0xc57bc28f, 0xcca376fa, 0x6bafbe06, 0x3f002fd1,
- 0xf2afee11, 0xa6d29479, 0x75aaf1b1, 0x59c77b5b, 0x75cf6c69, 0xd571df80,
- 0xc5b7ddf9, 0x80fdd82f, 0x1d5143d7, 0xe6114505, 0xafe3893b, 0xf0dff770,
- 0x7f4ceafe, 0x99780caa, 0xce6a2f99, 0xee669df9, 0x264098cf, 0x770ab8c0,
- 0x0c9b66df, 0x744072eb, 0x1ad57dc2, 0x3ba345ff, 0x1eb1f9c2, 0xfc1f009f,
- 0x676427f0, 0xc4f3e009, 0xd808a24f, 0x73f1efd5, 0xcfb80cc9, 0x1eae8191,
- 0x731df817, 0xb84fcccc, 0x74c76cce, 0x9c8e6156, 0x68cdfb48, 0x50838fb5,
- 0xfebcc1b5, 0xcb03b33a, 0x4a76f087, 0xac95c1bd, 0x5ed1a75e, 0xbffe691d,
- 0x79f8128b, 0x937bf399, 0x75bd7f84, 0x35a9f9cb, 0x41fa0b90, 0xd167e2be,
- 0xfdc135d3, 0xe09a6971, 0xf60df903, 0x050be630, 0x53de1fd4, 0x64cfafee,
- 0x7ba15672, 0xcdab9e3d, 0x1e02f7da, 0x887f78e7, 0x678287d3, 0xf1fabf05,
- 0xbf29f52a, 0x9fed55ba, 0xdc6dabba, 0x54dfa06b, 0x81bb05fb, 0x3a96aa82,
- 0x6b0fb08c, 0xe1909eda, 0x073ee67c, 0xa2a44b83, 0x83f8eab1, 0x0f166675,
- 0xcdfc67b2, 0x2e4e80f3, 0x2c8135af, 0x1745ae24, 0xdf87c06d, 0x0f7f3833,
- 0xdfde6c71, 0x57d36489, 0x3c0fabf0, 0x597cf2f6, 0xe715370d, 0x4732ab33,
- 0x03da7706, 0x81e4bb95, 0x675a7a2a, 0xe572c78e, 0x074ae0fb, 0xfb420fbe,
- 0x1f7871c3, 0x4fb81137, 0x8ed2d192, 0xa81f6cf7, 0x5874638d, 0x88cbb2d6,
- 0x7bcd54f9, 0xfa3f4a22, 0x50bb34fd, 0x30bcaf1b, 0xe02863af, 0x5814d0a5,
- 0xa7408ce6, 0x7394a393, 0x2729afca, 0xc76e945c, 0x27247ffe, 0xa2722996,
- 0x95e3e303, 0xe7df02f6, 0x3031392a, 0x5a589c92, 0xeb0818e7, 0xfa4774b0,
- 0x4b24d840, 0x149a99df, 0xefbc4e49, 0x47cce761, 0xeef67df9, 0xdc4e54d9,
- 0xb31392a0, 0xf44e90a3, 0xf6513eed, 0x42725f49, 0xcbffb759, 0x907de6fc,
- 0xf7f61113, 0x71393a17, 0xe518bf8f, 0x45b33dc4, 0x4facbdcd, 0x391394fb,
- 0x5e61f749, 0xa044c676, 0x7db9f79f, 0x0bdf9473, 0x5e407e80, 0x11d94664,
- 0xd1b97a6f, 0x53ff5f1b, 0xfffaf97f, 0xbe159e10, 0x3fda94be, 0x7448d4a6,
- 0x979e9048, 0xbaf947de, 0xf8c8f400, 0xb907d2fa, 0x67c7539f, 0x66cf808b,
- 0x6b2cf9aa, 0x7266ed5f, 0xf52da6a1, 0xfcb4b999, 0x09d946fe, 0x30fef2a2,
- 0xf352cddf, 0x5ea8ccdd, 0xe3196ef8, 0x13fd97bb, 0x6dea7f50, 0xfce67f7e,
- 0x11b3f296, 0x31f408ce, 0xe68c6e67, 0x7189dede, 0x06d8c9bf, 0x113de5fb,
- 0xe63f79cf, 0x71c1c07a, 0x7d04c9bf, 0x9e3e49fa, 0x2f3d7c79, 0x3e794878,
- 0x22de5fc5, 0x6d574fa6, 0xd57f1116, 0x57ff6cad, 0x073e0b37, 0xff8c17cd,
- 0x56d79e1b, 0xb5e760ec, 0x39850674, 0x78aff5aa, 0xce1ea3af, 0x08362a09,
- 0xf70cde78, 0xa59f001e, 0xce259f1c, 0x29573c0a, 0xc1fad26d, 0x2f6da21b,
- 0x1e101b90, 0x78abc3fa, 0x105342fd, 0x7f0a1dcf, 0x20373829, 0xabb6d49f,
- 0x59fb711a, 0x9a2a4fb0, 0x0d9ddf75, 0x3704ae78, 0xadaf41d4, 0x7b96d16a,
- 0x8b17bcf8, 0x146d8c81, 0xb33df93e, 0xf778f4f3, 0xf653f1e8, 0x8873f12d,
- 0x9ff327e2, 0xfe259f87, 0xf05e785d, 0xc7a2f175, 0x3f145d47, 0x324f181f,
- 0x6c7e3f61, 0xf17f2170, 0xbbe22bbe, 0x189e8b4e, 0xe50f79a9, 0xef2f1ca7,
- 0x83f5dc19, 0x80b55ea0, 0x6fd74af5, 0xf34497d9, 0x38c85b73, 0x6d286638,
- 0x90e3cad2, 0xa0756ffc, 0xbb5b9f7c, 0xdab88045, 0x60befcc5, 0x7c09ef99,
- 0xe5c1e63f, 0xfad3de54, 0xdc9bc70b, 0x287e5e70, 0x53fc882a, 0x409ddfa1,
- 0xfa6f94bf, 0x0c4e38f9, 0x9ca3e60e, 0xb8ec136a, 0x4c51032f, 0x8275d16e,
- 0x4cf66d77, 0x5f016bfe, 0x6a5fe617, 0x4358eb63, 0x75f60dd7, 0x5be79f81,
- 0x80f83e98, 0xe73b22ff, 0xd992eff4, 0x490238fb, 0x44e77e40, 0x8f915cfb,
- 0x939aee70, 0x1ddf5aa4, 0x37fe8c9d, 0xe0fc4e09, 0x36fbffa3, 0xbacbdbeb,
- 0x7f4cfa2a, 0xd3c157d7, 0x1f3add4e, 0x9c2f6a8a, 0x8272e780, 0xf20bdf13,
- 0xd179e1c7, 0xfef646c9, 0x1fae41cd, 0xd805f7e9, 0x78f7ea1f, 0x21c0c066,
- 0x145a7a2e, 0xbf6295c6, 0x533f4c69, 0x3bfd29f3, 0x6e375f48, 0xa3b486a9,
- 0x7f8e165e, 0x066edf74, 0xd04d3fb9, 0x19d149c4, 0x27ffbee1, 0xbea397c0,
- 0x36493e02, 0xc8797ca3, 0x19eebece, 0x1ef02466, 0x3235e5da, 0x06bdd1d2,
- 0xe06c91c7, 0x04c98f2f, 0x83e5c7f6, 0x3b9d1e37, 0xa445ca00, 0x26f7e28f,
- 0xa56b8354, 0x91aac598, 0x5c9847e2, 0xfffbc13a, 0xaed79513, 0xa097786b,
- 0x7ce27b07, 0xb674bf70, 0x0754d773, 0x0f325bf8, 0xcf7386ad, 0x23f67959,
- 0x1b1d6047, 0xc74fbbd8, 0x9da1e4d7, 0x0577d0f6, 0xe8c767dc, 0xbb9c017a,
- 0x391ea767, 0xe0f7c742, 0xb73c449a, 0xbc4aeb9c, 0xe731ce07, 0x0e9d141e,
- 0x5de16f5a, 0x7f9c0b56, 0x122d1f4e, 0x0f2f0ab7, 0xeff47692, 0xeefdadcc,
- 0xca4fb0dd, 0xf7843ca8, 0x87fcca9c, 0xfc840ea6, 0xd7db017a, 0xb846dd78,
- 0x74ded9e7, 0xfb4998d1, 0x00f5a12f, 0x59eb35dd, 0x028d9abd, 0xe25817be,
- 0x64f9027f, 0x1f0146c9, 0xfaa769c4, 0xf5c199af, 0xbed12981, 0xf9a7b69e,
- 0x700f6852, 0x03ddc637, 0x743593e7, 0x527ed89c, 0x97539e1d, 0x98b476d0,
- 0x2efc6fb4, 0x5eb25bc2, 0xb0af7020, 0xe3ea526c, 0x41de0093, 0x47e509d9,
- 0x08dcfd77, 0xfb479ee3, 0x2fe1441b, 0x42a63b14, 0xc103f27d, 0x152eef8e,
- 0xbafb8b5e, 0x623bef9b, 0x14e2cd1f, 0xefdca204, 0x2af1d493, 0xb869d125,
- 0xd7964a9f, 0x3abcc3d5, 0x06a989bc, 0x468ba7a4, 0x2927e390, 0x7f54ddbe,
- 0x7164613d, 0x27bc7b30, 0xfe2a1d8c, 0x1d3a32b9, 0xcb6a2fdb, 0x98b33e41,
- 0x853c6114, 0x23e98ebb, 0x7ca3ab9d, 0x94eb57e0, 0x7df029ed, 0x7e136acf,
- 0x932af0bf, 0x7586173b, 0xf4fb7fa0, 0xbdc0997a, 0xd3eb95c7, 0x9e3ac1d7,
- 0xe13b2cde, 0x8e7c40dc, 0xbe9411c5, 0x7b64fcca, 0xa7b833d6, 0xcb7f199b,
- 0x02eeee7b, 0x94a5dbe0, 0x7e70994f, 0xe2563e5a, 0xf53e4728, 0x4be3145c,
- 0xe7a57e7a, 0x1b8d6553, 0x65a1cb22, 0xd0e59105, 0x37ee7ad0, 0x6b9f2c8d,
- 0xbbe98588, 0xf078c9e3, 0x0d571663, 0xf404d79b, 0x70bb20fc, 0xf3781ed0,
- 0xdc819fd3, 0x3be2b4ad, 0x7d92d565, 0x83e8c09d, 0xeb9fff00, 0xec29f2df,
- 0x51b9b287, 0x29d90ef8, 0x47d80f58, 0x1cf0136b, 0x8c57c4bb, 0x79e25778,
- 0xf4b49b4b, 0xef21f8ae, 0xa5c48b73, 0x31655f96, 0x77aaa5c4, 0x6e9447f4,
- 0xdbf33f69, 0xcab01f04, 0xdcea3fa3, 0xe62670ff, 0xe5ae38ed, 0x6b583f5c,
- 0xfa3eba45, 0x40d5c5c8, 0x287ef3b7, 0x89dbd010, 0xf20f5dd7, 0x7049bab0,
- 0xf4b89f80, 0x297dac87, 0x3ee30f6d, 0x5f4673fa, 0xb01dce94, 0x3fd7aa0f,
- 0x6feb1fb1, 0xff001c14, 0xd46286e8, 0x22bcca27, 0x9d8df2c1, 0x79504768,
- 0x7b68f185, 0xec1262bc, 0x2655ea83, 0x1562b83b, 0xb3e8527a, 0x40a7bf93,
- 0xb3b1cecc, 0xb4673b68, 0x9eb2f903, 0x4239c52e, 0xfd029e48, 0xbd1978d4,
- 0x3b2abe75, 0x4df48b61, 0xbd1eec9f, 0xd0227f42, 0xfe98665f, 0x33cfacf6,
- 0xf69e3d02, 0x91671809, 0xf40bf407, 0x9fe2b2f9, 0x1eb51621, 0xea7d17d5,
- 0xfd07b0e9, 0xe958cbc1, 0xe854fa61, 0xc7874f51, 0x8c0f7225, 0x51d5a1fb,
- 0xfabc8f38, 0xce59ef37, 0xcf9e19f6, 0x923fd5e5, 0x44bafb04, 0x0a407162,
- 0x1624ab5e, 0x5c63d637, 0x0719d74f, 0xba7c67f5, 0x0e8acc71, 0x20f1edc9,
- 0x4a3ea9b7, 0xdf9fb402, 0xe3117e6c, 0xd2bfcf2b, 0x37ea2779, 0x003a516f,
- 0x92b66ffc, 0x3e21da00, 0xade547e4, 0x1369c622, 0x4b359029, 0x712bbf65,
- 0xb2bf1531, 0xb7cbbe22, 0xb4857c9a, 0x27ebf97d, 0xc25c62c6, 0x7b7fa60a,
- 0x39d8115f, 0x2c63b788, 0x972a3bdc, 0x5e8e7c58, 0x345df82f, 0xdebbc3b3,
- 0x7a03998c, 0xdeccd09b, 0xb96f2c17, 0xfca93657, 0x65a2fbbb, 0x939e1ea5,
- 0xc33ae979, 0x3e300afb, 0x4a76fbf5, 0xcbd74e5c, 0xdbcafe8c, 0xcae7d464,
- 0x805cb79b, 0x63f2cd78, 0x6b77b426, 0xc11a2f9a, 0xd5fbcd9e, 0xc41decab,
- 0xa7135136, 0xae3e23d7, 0x20980c59, 0x0ab5abae, 0xbe6871cf, 0x3c2df313,
- 0xc66bed1e, 0x6afc556f, 0x8a5eebc7, 0xbf6d8ac2, 0x857be1b4, 0x786c9bed,
- 0xabf9aa5f, 0xc47b55e3, 0xf034b5c3, 0x4e3bb878, 0x918fe413, 0xc1cee1e3,
- 0x7d21283f, 0x878dad16, 0xbf8ccd23, 0x456671d1, 0xa4350f7a, 0xe9fabd77,
- 0xddcf10f3, 0xe793f5b5, 0x5f95dc61, 0xe21e7e5c, 0x6882a86c, 0xe6a53d07,
- 0xfe31f795, 0x1f176955, 0x97a0edc3, 0xc3f1897f, 0x7268fe17, 0x3b0bb402,
- 0xfe80a74e, 0xdfcb6171, 0x782e2092, 0xe8a98ed9, 0x3db659df, 0xedbddf0f,
- 0xfa059ecd, 0x7e23f5f5, 0x7b6ebf59, 0x3c60f75a, 0xeeba79d0, 0x714227c0,
- 0x2c552d8e, 0xe3c1d47e, 0x8e47371b, 0xcf11ef17, 0xaeeb3ad8, 0x5b1fc029,
- 0x67d09e99, 0xba61e35c, 0x63f4379e, 0xf8f3371d, 0xbe3b96d5, 0x3cf1ae32,
- 0xd7ae83fc, 0x7c6d18b8, 0x8bada7e8, 0x942cf17f, 0x1af426b5, 0x07e818d7,
- 0xf47894fe, 0xd95da3cf, 0xdeb08931, 0xa4f181ff, 0x0e857eb0, 0xa69fd7e0,
- 0x8cf8bf80, 0x44bf441c, 0xef098770, 0x38ef966b, 0xc2e9fb8a, 0xef1843f6,
- 0xf85c784d, 0xb1fa1205, 0x03ee5df8, 0x6568d9aa, 0x1d7c90f1, 0x61d25e20,
- 0x2e3cefc3, 0x12b5d192, 0x9c5bd92f, 0x3498b2e4, 0x8b0b3efe, 0xf8daace7,
- 0x0c3f8f01, 0x09309baf, 0x2bf3abd6, 0x3c1550e3, 0x130f01d8, 0x91c071d5,
- 0x714352e3, 0x8375bac0, 0x1e3e04f5, 0xf9a5f38a, 0xe9ef10a1, 0x8a468e13,
- 0x81b0bf2b, 0x905f0fc5, 0x568fdf23, 0x626b82e2, 0xd7d6fb74, 0xbee078bf,
- 0xf175f1e6, 0xa1c63f34, 0x5f051ba1, 0xf323575d, 0x846327f7, 0x85b7646f,
- 0x0a549bee, 0x4f2cfbfa, 0x997dc0c4, 0xbe234ed6, 0x55d8a293, 0xdc5dbe7c,
- 0x8af5d6df, 0xf5a27188, 0xbf907b2d, 0x3547f9eb, 0x8fd1473f, 0x6f1f2377,
- 0x1f931b75, 0x3ead5b5d, 0xb5d3850b, 0xeba44dfb, 0x189dcdea, 0x79bfbaa7,
- 0x7543b19b, 0xc3f20cfe, 0xd77f1aa7, 0x22c6bb6b, 0xa2efe73f, 0xcad9fbe9,
- 0x3f8d63f9, 0x9b353f72, 0xa9fa6a2f, 0xed18b6f0, 0x3bfbbe96, 0x05eeb927,
- 0x99dae778, 0x45ae751e, 0xd08be69c, 0x6462cfff, 0x3237576e, 0xa395383f,
- 0x959c3ef8, 0xda2707bd, 0x5b2f51a2, 0x0c749d66, 0x665d21de, 0xcc5c6235,
- 0x471e3aca, 0x326723f3, 0xeb4af7ac, 0xbbc604ed, 0xb2abf01a, 0x9bbb65ef,
- 0x27273e80, 0xcfaa6517, 0x1bf19461, 0x4f881807, 0xd3ad8fbd, 0x4a7d8206,
- 0x1850ef24, 0x7f699dc7, 0xb62e4095, 0x9f7f987b, 0x02313d5c, 0xf64bb7be,
- 0x6e14097d, 0x04e0be7b, 0xba4f6cd7, 0x7e43f067, 0x1df69706, 0x4753bc5d,
- 0x69c977e7, 0x6ad13d40, 0x1569d808, 0x4f6a8d62, 0x41d70346, 0x5e12521c,
- 0x8978c0a5, 0x11e63cc7, 0x46d43f70, 0xf50adaa8, 0x5de6929c, 0x9249d895,
- 0x72159dee, 0x57a50478, 0xc557a70b, 0xff65675f, 0xf03b70a6, 0x0cb896fd,
- 0xbbe40752, 0x7d46ead6, 0x0b9b29e2, 0xdfd23fef, 0x88938868, 0xf54ed127,
- 0x5fb450bb, 0xda3b7dcd, 0xe71f26af, 0xa613e6d2, 0xc9232749, 0x8e3e049b,
- 0x7882d102, 0xe06a9b88, 0x70abb2fa, 0xdc785264, 0x19c48971, 0x2c3bf280,
- 0x6e808f78, 0x1e7aaf2f, 0xdc768b16, 0x3e1a7c74, 0xe1d19b11, 0x6a71b035,
- 0x0389dbbe, 0xe3a747df, 0xaf1bae3d, 0x70b56f26, 0x0911277e, 0xdcc59df8,
- 0x2ffe384e, 0x4abdf069, 0x224f8a2a, 0x38c2644c, 0xde2130e9, 0x83cf9625,
- 0x6fa9aff6, 0xeb01ef07, 0x0c870b5f, 0xb5efabb5, 0xe0e5c0de, 0x8a514b11,
- 0xac93ee85, 0xb818b5e1, 0xb82c9d9d, 0x65a04e4e, 0x9fc801fe, 0x61e796d2,
- 0xc8d08a5c, 0x5ac46ae8, 0x4466fb82, 0xad55c790, 0xd53d468a, 0xa8de2664,
- 0x8e3f70f1, 0xd0f1e578, 0x3f9f8f8b, 0x28185639, 0xa50d6928, 0x1fceda35,
- 0xa62c35cc, 0x4502d08b, 0x8b10fe14, 0x5ff40c6b, 0x6c9dc33f, 0x1bd30718,
- 0x2877bf56, 0xc16bdaee, 0x1ba86863, 0x14c0ffba, 0x2ef82164, 0xdd0ef108,
- 0x51b8720f, 0x0ec653c9, 0x463406ef, 0x332ef287, 0x698df7e5, 0xdaf37f2c,
- 0x7ef0f5a1, 0xe8bda74d, 0xc78c0b66, 0xcf0ebf6c, 0x9af102c3, 0x937bd5f7,
- 0x4738ca2f, 0xc1e40c6f, 0x07b7c7fb, 0x23c5fbd9, 0xfc7ba1ad, 0x59378f28,
- 0xed007c94, 0x43d6a28b, 0x5aaad7c8, 0x01b9610e, 0x9e1d34f2, 0x421bc810,
- 0x65bf79e7, 0xb5f2414c, 0x716b5e14, 0xb1c13c32, 0xbf6632d0, 0xb8c3c1a4,
- 0x61d9bdfa, 0x6e2b483c, 0x86e1e1d0, 0x858785af, 0x87a86f6b, 0x3bfa55f7,
- 0x0b174a6f, 0x73d35f00, 0xdb8ef80c, 0xf41663c4, 0x145fd0bf, 0x670e23ca,
- 0xbcf72f43, 0xc2853b15, 0x97d35729, 0xaba14ed2, 0x9d26e8de, 0xef63afd8,
- 0xe7e96a83, 0x87ae2ddf, 0x8b32de00, 0x8896dd2b, 0x0577c7f3, 0x8b8bbba6,
- 0x74c213f2, 0x09ee2c4d, 0x11feaef0, 0x5a1f82cb, 0xe9dafe54, 0x34c54b39,
- 0x011fde3a, 0x3c31b823, 0xdee5c49f, 0x9e7451a8, 0xc6032e89, 0xb8b11fd5,
- 0xdb3b4057, 0x6200609c, 0xf71226cb, 0xf70c4104, 0xfa8feca3, 0xaf8ecc1d,
- 0x56f8362f, 0xfc60f3b0, 0xfa611dbb, 0x47d1d0e8, 0x5b47d190, 0xb547d227,
- 0x47d193bf, 0x346e5d5b, 0x3b03573f, 0xc70491ba, 0x5937bac1, 0x61a40b0a,
- 0x82626e94, 0xb23740f5, 0xc282b6f7, 0x3aebc428, 0xf58f5f18, 0xe652e3e1,
- 0x36fadbd5, 0x71fb481e, 0x0799d806, 0xa61e780d, 0xb7a94de0, 0x46e2c2c3,
- 0x7ee6cdff, 0x99a9fa11, 0x961fb1d4, 0x3f81eb6f, 0xed875c60, 0xd05dcce0,
- 0xae9b36de, 0x6fdc2390, 0xf815c1e3, 0x7f23784e, 0x04963bd7, 0x7bd720bd,
- 0x3fdb07c7, 0xde807c21, 0xe8f80193, 0x0af2fdc4, 0xdd9667bf, 0xce40b826,
- 0xef618f0f, 0x616ebc90, 0x16bbf576, 0xaf4ca791, 0x5bb83c49, 0x7b2bfb04,
- 0x27eb0195, 0x9ea19a42, 0x5f5e2aff, 0x95ddf8d2, 0x89e85575, 0x7818d272,
- 0x78f9e4cf, 0xfd2d1ef7, 0xa9a4c7c4, 0x1eed29e0, 0x45a290f7, 0xee265094,
- 0xc810f05d, 0x3e3f4a55, 0x7231bb4d, 0x442de014, 0x233e943f, 0x776d0fad,
- 0x7c6bad88, 0x5b0be80c, 0xf1152ef6, 0xae7e8e5d, 0x47bc166b, 0xc567eb49,
- 0xb4adda90, 0x4d2c567d, 0xf3c09f21, 0x087e7903, 0x743fd34b, 0x7dfa041a,
- 0x9ecbf703, 0x922578e5, 0x6399bafd, 0xb8f4cf20, 0x9418e4ec, 0x85beca0b,
- 0x5ce05467, 0xdbe7e25b, 0x0334c169, 0x8fb29bac, 0x6021a0a5, 0x4d2b42a5,
- 0xce201872, 0xbb8f5de1, 0x7b0bce08, 0x5fb73be3, 0xea81eecb, 0xc7ce7fbf,
- 0xebf58df3, 0x2fb8f4bf, 0xb7e039fe, 0xf8f1dcca, 0xbeaf9a4c, 0x69fa32f6,
- 0xdf54c457, 0x68ef55fc, 0xeeffc7e8, 0x00c4dfd5, 0x333ffa1d, 0x353fbc45,
- 0xf1e8cace, 0xb60e6780, 0x04efe2cb, 0x1c4a8192, 0x15ce2ab2, 0x865eb8ca,
- 0xdf86994b, 0x05bacf51, 0xa7ac2059, 0xf6878a57, 0xae78a931, 0xae2eab78,
- 0xbb2f3955, 0x80fcc025, 0x42beb159, 0x74faefec, 0x3e49f7f6, 0x9992fa63,
- 0xa1ce0ffe, 0x3373f2a6, 0x5efb31d7, 0x09598710, 0x3f08f98d, 0x5afd1536,
- 0xfefb4439, 0xaf40d641, 0xf4f28064, 0x67978454, 0x13a795d6, 0x6b915bf4,
- 0x4df9c3ae, 0x0cfd2a25, 0x13a346e5, 0xd1f4f1f8, 0xf7f9fe94, 0xe1bff4cb,
- 0x867f3226, 0xcdb8ceca, 0xbe515f71, 0xc4696f46, 0xfb7e8577, 0x523f38b9,
- 0x2163c5fc, 0x4115173c, 0x8f1e803c, 0x95610eb9, 0xdf13d1d5, 0xf1e9fc7a,
- 0x8f51e0ad, 0x9d0f9cb7, 0x9e8ef1f9, 0x23e3d1f8, 0x5be97e7c, 0x7530eb0b,
- 0x4bf288b4, 0xfc4f7bc1, 0xedfaf5b0, 0x009eb4b5, 0x0df142f4, 0x30174cf8,
- 0x862b27be, 0x3a6c4fd3, 0x140b37e2, 0x0f4801c0, 0x55e3d798, 0x04acc78f,
- 0xd5813ede, 0x1af80fdf, 0xed00fc89, 0xb2dd6521, 0xc6f76bd2, 0xe8c4de41,
- 0xa7abd14c, 0xbd50bc72, 0xbce6f51a, 0x9bfa2b44, 0x9a9eaf40, 0x5e5bc614,
- 0xde571b15, 0x600bcb48, 0xfc0afe9f, 0x0608b1d1, 0x95bcc5df, 0x56e05ff0,
- 0xe2ca5f3c, 0xb7df0559, 0x93d5a67e, 0xce0bfaa7, 0xdc3dfe82, 0x05655ee4,
- 0x87108c7f, 0xff1479e7, 0xd7f875c7, 0xf36bb3b6, 0x0afc7c7a, 0x27b931fe,
- 0xab7a14de, 0x7cfd72b3, 0xfa0a1930, 0x3337d8f2, 0x137f8163, 0xbf447c7f,
- 0x4563c4c4, 0x6e9c3821, 0xe2059e91, 0xa7b77d0e, 0x763e0b7f, 0x15494a90,
- 0x7253bb1f, 0xd8deb3af, 0xeb298f93, 0xc7af8535, 0x05dde214, 0x4429a67e,
- 0x1ec84bfa, 0xffcf0d48, 0xb3f72b79, 0x6043210d, 0x1c585f9e, 0x79f3ff8c,
- 0xd54de686, 0x9b3fe84b, 0xb66d9ff7, 0x121bfde0, 0x7842ba94, 0x93f7c34e,
- 0xf0f8c6bc, 0xbd656438, 0xd3096a53, 0xfbe2e6e7, 0xe42f14d9, 0x38f098cb,
- 0x090559b6, 0xe3e20fdf, 0xf66cdf38, 0xd3db9c42, 0x2b0dfb92, 0x83843df8,
- 0x527e7163, 0x3fc81460, 0xb6e5f97d, 0x4e50d5bd, 0x3d6095eb, 0x910afe3e,
- 0x3b821ff9, 0x5217be4c, 0xe953d77b, 0xa13946f6, 0xdc3671d0, 0xe801bd7b,
- 0xb8c2283e, 0x655cfcfd, 0xcf7645e7, 0xabec45c1, 0xf6f0a7ae, 0x02f7625d,
- 0x81db28f2, 0xedfa7a7a, 0x49f34e8b, 0xd3b41e70, 0xcf22abd3, 0x5bfdf81b,
- 0x68bb3f45, 0xeb0fbf75, 0xe3efc0de, 0xba8e2ffa, 0x1be7d60e, 0x2d61d5d3,
- 0x44f4295d, 0xf438ebe9, 0xf1f99dd3, 0xdfcb503a, 0x049cbccb, 0xe3d151f2,
- 0xeb8afac3, 0x9bd7a863, 0xe6dc3f3e, 0x857eb2ee, 0x35e8af3e, 0x6423d97d,
- 0xd34644af, 0xebe3ce71, 0x2edcd733, 0x41c68bb3, 0x886fd38c, 0x73cbde56,
- 0x393e8344, 0x95ed21af, 0xac573866, 0x07f97e63, 0x3d8d656b, 0xbedb86ec,
- 0x67bd9ed8, 0xb6b97f3b, 0xef8a23fc, 0xcef8f141, 0x868ed6ad, 0x7e1491fd,
- 0xbf67b7cf, 0xc9c82f06, 0x31a32379, 0xafdf4e7e, 0x7efa7e7e, 0x7035fdf5,
- 0xd8c1aafb, 0xd2a9da38, 0x1636ec4f, 0xcd697d47, 0x14f0cd93, 0x73f86f5e,
- 0xd4b8879b, 0xa3ae6f7f, 0xa44e7a21, 0x781468f7, 0xc2e7be0a, 0x0fe098cb,
- 0x1eff95a8, 0x6cdd9de9, 0xf413f337, 0x6088efd6, 0x8683ea3e, 0xe82203a7,
- 0x048223f5, 0xa0ecf0f5, 0x6350b0cb, 0xb97b300f, 0xef003d87, 0x657cd0a4,
- 0x0f662eeb, 0x5da1d4b4, 0x0aed4951, 0xe01b3b90, 0x7cc1901d, 0x27681940,
- 0x885eec84, 0x7786caaf, 0x0c5db932, 0x37a5a74f, 0x1f33fab2, 0x8c35374f,
- 0x9dd5bb00, 0xce932f0c, 0xa8fb5db4, 0xf557da99, 0x508a24a9, 0x76c8aafb,
- 0x4ed677ed, 0xde3bdca2, 0xa4bbc025, 0x65a8ff34, 0xecedff72, 0x8fd1b699,
- 0xda81bf82, 0x54d9b767, 0xfb6f6f76, 0x039b66e3, 0xfedbd9f1, 0xcd17b4e8,
- 0xdf8a3804, 0xe421f282, 0xbe28fe07, 0xf442a3ff, 0x53780b17, 0xe5f6e5e8,
- 0x88ced10b, 0x0a6ae6ba, 0x736593c4, 0xb8db703a, 0xc186365f, 0x706189a9,
- 0x376e4a26, 0xfbbdd3f4, 0x3bf028ea, 0x04fa3bbf, 0x2b7e79da, 0xf41fdbf3,
- 0xe3a91594, 0x026d6bdb, 0x10c097a7, 0xdc777fd8, 0xec0127b8, 0xc0596c95,
- 0xb2fd4ef7, 0x99f1e9ef, 0xdb669fc0, 0x6629d257, 0xfde2364f, 0x60547f32,
- 0x3d2ac3c8, 0x4ddfcfce, 0x3fdc5ff5, 0xdcff1d44, 0xb5abcd6e, 0xc022f831,
- 0x7bdccecf, 0xde80f40c, 0xae584ee4, 0x2b9004b8, 0x24a1eae4, 0xdd6a5f3c,
- 0x689f0367, 0xe0e77f17, 0xa49eeb7c, 0xdaad3405, 0xb0369ff2, 0x3e38eae3,
- 0xf8ed4bce, 0x76e5535e, 0xa113df11, 0x003d26fd, 0x85d6eb7e, 0x1fdeec59,
- 0xc8a6afbb, 0xef9ff1d5, 0x9cc45219, 0x4cff7889, 0x98a737d1, 0x9f183ebd,
- 0x1dfd8ebf, 0xf7ba29cc, 0xefe56ec9, 0xcff5e993, 0xe2b26c67, 0xa9f8c32f,
- 0x4fd67665, 0xfb2bfb6f, 0x53e204b3, 0x296cbfed, 0xb3f8c220, 0xefc24b3f,
- 0x3da40fe7, 0x3df60855, 0x01239d91, 0xa2f644ac, 0xa7cfcb7e, 0xbc2f6fe8,
- 0x6793be7b, 0x3cbd6ede, 0x6e2466eb, 0xd004d72a, 0x9803dcc7, 0x07c991d3,
- 0xf5bbff45, 0x55dfad33, 0x722b07af, 0x6e3fd732, 0x780210d5, 0xfbc2cc77,
- 0x8c240713, 0xc9ebd2f7, 0xbd058353, 0x204fc3e8, 0x4d6d6d7d, 0xfe7b018f,
- 0x009f60df, 0xc65eb6dd, 0x49aa83f7, 0xc7781ee0, 0xb455baa9, 0x24fc6007,
- 0x67d87af3, 0xe0a13e8a, 0x1eeaeda5, 0x7fda58f3, 0x7d8345f6, 0x76f10505,
- 0x57682ff0, 0xc1fdf84f, 0xfe679004, 0x07e784a0, 0xc6f717d9, 0x45f1542c,
- 0x7e0355ff, 0x6eeafb7f, 0xfc60f7ed, 0x8b6ed0f5, 0x7bcbd981, 0x063dfff7,
- 0x57dbd4f8, 0x90bc212f, 0x6f53d13e, 0xcf3bfd46, 0xd1fc862a, 0x8899bd6a,
- 0xde2187d9, 0x152c6a6b, 0xfaef426b, 0x6487ce70, 0xd4f49595, 0x2778422b,
- 0xd0f0092e, 0xf0561f43, 0x3e33d3ac, 0x773d71b2, 0xef0f1918, 0x4d5db65e,
- 0xc77bc0a8, 0x0afb18fe, 0x8f4ccf94, 0xee7bdeea, 0xfdf0e9c9, 0x9ddec8a0,
- 0x7ee22ab8, 0x62b3bdda, 0xdf6a8778, 0xeb8a4e52, 0xc5d06576, 0xfad16f0b,
- 0x3345f657, 0xbce4baff, 0x224f7d5e, 0xf1c7df5c, 0xcecc1815, 0xe183bce9,
- 0xac6fa8bd, 0xb0f574cf, 0x4361fff7, 0x0058393d, 0xfad462e2, 0xffac234e,
- 0x3e8ad9bf, 0x25a5fc67, 0x978bf806, 0xb4210ee4, 0x9268b2df, 0xac15740b,
- 0x33b07623, 0x18301fb6, 0x37325d60, 0xcf5c62a5, 0x731cfc2b, 0x31a34b49,
- 0x4b174555, 0x19d839f8, 0xaf129bd9, 0x9632befa, 0xfb3397f1, 0x71817fca,
- 0x91347f1d, 0xd0f41191, 0xfe4cb185, 0xa77a336e, 0xc77a866f, 0x68df780d,
- 0xef5ffeef, 0x97937787, 0x038c731c, 0x5894e0bf, 0x0eda0fb6, 0x710f52be,
- 0x821f6dc1, 0x6672a2d4, 0xa068b163, 0x1c45befd, 0x9877afcc, 0x90d6bdfd,
- 0x12b8943f, 0xc5379e60, 0xd6fdbe32, 0xdce68301, 0xbefe2dec, 0x8cb1f5ef,
- 0x32c6a50f, 0x03d6dabf, 0x700b09b9, 0xc447b9ff, 0x64f01f82, 0x456c3d47,
- 0xe8a80fc5, 0x6f0f936f, 0xfe863e9d, 0xc1977273, 0x38edcb0e, 0xf30882fc,
- 0x24219c75, 0xf43d204e, 0xac6f0a39, 0x5d5bde1a, 0xc71d1e0c, 0x0aafd86e,
- 0xfe04a9fe, 0xbfcd0671, 0x43c52ed5, 0x7f82983c, 0xff4a1e65, 0xdae2168e,
- 0xe4adc160, 0xfe15fada, 0x31efe568, 0xe513b04c, 0x5d2033ef, 0x6eb9b76e,
- 0x6f72c589, 0xeccfe40a, 0x36d27a63, 0x72494f2e, 0x9fc070f1, 0x79f34eb2,
- 0xb7a78caa, 0xe3e7effe, 0x4bafd254, 0x0ec8afd7, 0x76cdd22f, 0xf0ee4f16,
- 0x10e9cc06, 0x8e96d677, 0x154a9f7f, 0x8e3f7b97, 0xfdf68cff, 0x830eb6c2,
- 0x558fee01, 0x50e210ef, 0xbea7eddd, 0xa933a21d, 0xedafe905, 0x5c7dc118,
- 0xe65dfcde, 0x9f72a48f, 0xe786ebbf, 0xf87fb0eb, 0x8120fb39, 0x1bfd93a6,
- 0xfc410e56, 0xafb06c06, 0xfba278c2, 0x46dad206, 0x92ebd023, 0xe52d2c65,
- 0x9a4bd5e7, 0x4b3fb8dc, 0xc478b3d6, 0x4ca9b165, 0x257a733e, 0xf8c1e886,
- 0x7b4dbade, 0x5c1ff08f, 0x7d6d9e7e, 0x4bf40f6a, 0x80fbebe9, 0x9eda9b8f,
- 0x55c30758, 0x46ecf5e8, 0x4594e119, 0x3df3cf6b, 0xb8cfccb1, 0xf7a330fd,
- 0x5ce51bc9, 0xb26c4f78, 0xbfc1d897, 0x4dc6d6fd, 0xb7eff022, 0xd9539e80,
- 0x7b79073e, 0x3163df66, 0xd6f907df, 0x47e02069, 0x652466df, 0x62fb545b,
- 0x343786ef, 0xb9bcb7fb, 0xebfa3a6e, 0xe005e23b, 0x55becaf3, 0xe8cdbef0,
- 0xfff70dbc, 0x9ffdba9d, 0xc2b7dacf, 0x4f7ad0ba, 0xd4fffdf1, 0xe9ffba34,
- 0x718db8a7, 0x66d9c002, 0xdccefc8c, 0xfe90df4b, 0xa3b57c42, 0x297d5f07,
- 0x6c1ff996, 0xeaffb4e9, 0xffa12e3b, 0x4e3e3421, 0x2be54f37, 0x002a9374,
- 0x0ae91bfe, 0x517c008e, 0x533d02bc, 0xccfe7a3d, 0x0795dc0c, 0xe1ff3c24,
- 0x2e3c4be7, 0x6a947704, 0x99f986bf, 0x6fdd6fb2, 0xf2b238c0, 0x9e82576b,
- 0x45e8509f, 0xb82b3cfa, 0x7953c787, 0x71f61676, 0x8eb07e04, 0xec8ae3e3,
- 0xff7debee, 0x65cf40c1, 0xf98462d4, 0x1d82f590, 0x772945d6, 0xbdef67ac,
- 0x94f0e61e, 0x2dbf87ef, 0xde3d83be, 0xf0cc3d21, 0x5c42341d, 0x931f28eb,
- 0xc5c84463, 0xb70c40fd, 0xb67d860f, 0xfbafca84, 0xacebf255, 0xaa7488dc,
- 0xce23e1e0, 0xb1c4aeb7, 0xc7ce3f79, 0x5d1f07e9, 0x82ff0aa2, 0x3f6c0924,
- 0xe7db028b, 0xbb3fc022, 0x90dba6ef, 0x4c88efde, 0xb7b076ef, 0x47efe1e2,
- 0x8cfa406d, 0x7bc7669b, 0xce494f2f, 0x7e8d38a8, 0xef74c3e4, 0xced067a6,
- 0xfd85fa03, 0x97fd1bde, 0x0893fd01, 0x74a3ef74, 0x853f5aaf, 0xfc5d280e,
- 0x7ca5f01d, 0x7285d3d7, 0x65e0a90e, 0x731cee9b, 0xe9e19daa, 0x8d5200ff,
- 0x8000b56e, 0x00008000, 0x00088b1f, 0x00000000, 0x7dbdff00, 0xd5547c09,
- 0xf37df8d5, 0x3332c966, 0xb2764c99, 0xa00c4930, 0x80490e2c, 0x084ed8b0,
- 0xc3884a20, 0x93a0d752, 0x364b0900, 0x94569510, 0x8b062081, 0xb62d1518,
- 0xef858320, 0x106d1b43, 0x268358a8, 0x622d1110, 0xa57fb1dc, 0x41459041,
- 0xed1fa822, 0xe73bf587, 0x33337bdc, 0x6a02266f, 0xefc7e1ff, 0xdf77dee6,
- 0xcf7ece5d, 0x6ec5f739, 0x843631d3, 0xae630731, 0x7d8c01e6, 0xf4bf3f8f,
- 0xa12d8c97, 0xcf3773e7, 0x8224715e, 0xf0f7cfd1, 0x5e79babf, 0xc776bd50,
- 0xe91c57af, 0xc5cfafe7, 0xffe0525f, 0x8967a671, 0x47f1558c, 0x89ef4cac,
- 0xfbc025b5, 0x6cd69d11, 0xe266b498, 0x03846319, 0x8319789f, 0x1c636ff6,
- 0x6faa3e54, 0x1f2bd3de, 0xe9cc31ca, 0x9b39a685, 0x998f1533, 0x1b3605b1,
- 0x27f967ad, 0xb0dd93d3, 0xc6c646de, 0xc59bbae3, 0xd9dd727c, 0x99c68536,
- 0x8f7329e0, 0x66678389, 0xa07b9e4f, 0x6607f9ff, 0x886d964f, 0x70a13ebf,
- 0x4018eabe, 0x7ec48c4b, 0x0c985563, 0xc9bf9fe6, 0x326533e4, 0xc49f05b6,
- 0xa3db2ac3, 0xfd329b7c, 0xccf4d9ef, 0x9633b7a5, 0x75a4cb6b, 0xb15aeac1,
- 0x646858ee, 0xdfbcc197, 0x9bb59666, 0x1dd5d1e1, 0xb081e2de, 0xef462d8f,
- 0x389989d4, 0x1c1af398, 0x9d629aff, 0x6a5801ed, 0x38a6cbac, 0x6992d007,
- 0xcf8fb65e, 0xeced9793, 0xeea1b2cf, 0x2db9e670, 0xf8128d8c, 0xc930ad62,
- 0x421c3f70, 0xd9e1c6f1, 0x20175e13, 0x1750867c, 0xd5e27e7a, 0x667d1ba8,
- 0x0144f3ff, 0x78632fbf, 0xd3c1adf9, 0x1d0e66db, 0x553e6027, 0xcacc6649,
- 0x5c554b3c, 0xdb6628ff, 0x773ff0e4, 0x1c2e628c, 0x57189a7f, 0x8ffacbb6,
- 0x10aeafa6, 0x78869afa, 0x22e88ead, 0xd053eaba, 0xbcc07469, 0x8bdd194c,
- 0xee98fac1, 0x80ac5eda, 0xbd71eaba, 0x29554800, 0xf6c7ebe0, 0xd7338d84,
- 0x01d99e23, 0x0cc9cb13, 0xcdb567dd, 0xd1b6e1c0, 0xe866fa30, 0xb865e097,
- 0x838bc003, 0xde3585e3, 0xdc6bf88a, 0xd7886268, 0xdc39636f, 0x68d953ac,
- 0x42b7f403, 0xc6f7247f, 0x57039ea9, 0xd931bd41, 0x9e6050e8, 0xc22e8613,
- 0xa0ab89fb, 0xadc3e88d, 0xbc4fbe20, 0xdf9ae23a, 0xa277bb40, 0x8bc0e58e,
- 0x05b08d5b, 0xa7bfc3a4, 0x482936f9, 0x27c42da7, 0xc1b2c7f3, 0xbede7826,
- 0xd5d11869, 0x052ce2ac, 0xe6ce76e9, 0xdb9f0558, 0x2a74d8c7, 0xd863eff3,
- 0x13e89542, 0x16dea0f8, 0xde618f80, 0xd5e1153a, 0x6c93ce3b, 0x11ec6588,
- 0x23e335db, 0x32ce81d2, 0xcc1b2459, 0x5f5043d8, 0xb46b7009, 0x4b1614bb,
- 0x0a7306f5, 0x236321f1, 0x0cadae08, 0xd518d4f0, 0x6045775d, 0x7f5e2cff,
- 0x86eaf1a4, 0x9ec63486, 0x22357189, 0xbb303e9e, 0x87f9c11f, 0x44a9d526,
- 0x7fae82e7, 0x127ece80, 0x2c2ed4bd, 0xe0f38762, 0x0e660ef7, 0x47901ba4,
- 0xf8066eb7, 0x9b3de895, 0xbd355d70, 0xc38e3e8e, 0x657cb6d5, 0x7ba184f4,
- 0x21788eb9, 0x8cc7d817, 0xaeef11f0, 0x7ecdcb53, 0x66c5b3b9, 0x52ed4c17,
- 0xfcfc5b26, 0x79eb7286, 0x593b9733, 0x98229a50, 0x7ec762d7, 0xac23a23e,
- 0xe5fae4c7, 0xdd62cad1, 0x3e185f78, 0xeb890d7e, 0xaccf9467, 0xf2ff7fe5,
- 0x1fd0a19b, 0x9f89577f, 0xc4fce35e, 0xc5a3f5e5, 0x3c22269f, 0xbdf09390,
- 0xeb1cc5db, 0xeadf3a97, 0x5fb9748b, 0x3ea09b65, 0x2af464d8, 0xe66db831,
- 0xf18a25b0, 0x945b0d90, 0xa820cb56, 0x2e614bff, 0x7fe9c3c0, 0xbfae54a9,
- 0x133e3dd7, 0xa1d9afde, 0x7e852e73, 0xf10a2d35, 0xf337b383, 0x371d0045,
- 0x31075947, 0xb770af18, 0xf68065d9, 0xc9044ad3, 0xd7009c65, 0x2feb9061,
- 0x8268cae8, 0xc02df5e7, 0x5d3d507f, 0xf5c6a808, 0x6c319dea, 0x83be1f80,
- 0x1fb47cde, 0x1bda00ec, 0x4f67c89d, 0x9ff1f245, 0x81f0cc8a, 0xbe528310,
- 0x4a0188e7, 0x6e825961, 0x62c67af4, 0x78504f00, 0x30b51cb1, 0x3c07a5db,
- 0x35e67a2b, 0x7546be00, 0x9f08aab5, 0x8e872eac, 0xe9f3fd99, 0x3bed18bb,
- 0x39d0ef4b, 0xd6d5f403, 0x7aabcfbd, 0x31d0eb80, 0x942af58d, 0x6f9e3189,
- 0x4623de10, 0x7b63d5d5, 0xf557b15c, 0xa57cff40, 0xe905b76e, 0x44e61aec,
- 0x24f92ab9, 0xc1b593ae, 0x81ec5972, 0xda15974e, 0xb5771c47, 0xc7fd800d,
- 0xe38299b8, 0x7c0dfd49, 0x0e9162c6, 0x44ca5de3, 0x3fe86718, 0x8e47c118,
- 0x68ef75b3, 0xbe3ef905, 0x18e28c63, 0x6be74a10, 0x38b7e398, 0xce9f77ae,
- 0x3475f889, 0x9406d733, 0x62ba7f13, 0xf64bc20c, 0xf5cb1def, 0xa78f48ca,
- 0xee154408, 0x1de70627, 0xb76fa37e, 0x6c33d601, 0xd1b77796, 0xd99fb011,
- 0xed4bc68c, 0x523ed2f4, 0xb10a780e, 0xd2c6b6cc, 0xb78e2338, 0x7e800db6,
- 0x1fb07549, 0x78ef4f68, 0xa6b8414f, 0x882875d7, 0x777badcf, 0x3ad37ad1,
- 0xf82979da, 0x176179eb, 0x5603db74, 0xdb23ed1d, 0xf2cdf5ca, 0x666f5c53,
- 0xadb27ac7, 0x2c7dfe09, 0xd724f42f, 0xf66bf8c1, 0x17ef7566, 0x2895eee5,
- 0x52e403e4, 0xc691ac6e, 0xe9eacbb9, 0xbdabfb8f, 0xd20f73b1, 0xdf7bf3e0,
- 0xb47f12b1, 0x137e13c4, 0xf84a7df7, 0xba485c48, 0x37d9ad98, 0xb179415f,
- 0xa67014a6, 0xca59c284, 0x7eb8358d, 0xf45b1fa2, 0x27cfa024, 0xd8829eed,
- 0xcca57b40, 0x20159d1e, 0x8f7be497, 0x19ee662f, 0xed6190b0, 0x16595be5,
- 0xb17ef7c9, 0xc27df201, 0x9122fbc0, 0x2e2c9a9e, 0x569fb617, 0xcf388dd8,
- 0xfb425833, 0x975e0633, 0xe0407af0, 0x52763b33, 0x870875b6, 0xf8e80d93,
- 0x4fde4899, 0x8dee8f2b, 0x83bb09d5, 0xe0eb0bd3, 0x08fb82f4, 0xc666bfb4,
- 0x748c3c72, 0x9cf48a79, 0xfee2a64e, 0x76f81786, 0x1b0edd23, 0xf48dddef,
- 0x9d04ce9f, 0xa274e78c, 0x63dbf7a5, 0x711d7cb9, 0xdc218bbc, 0x0ee615f3,
- 0xc654ef67, 0xbe29bb72, 0x0fd13463, 0xce1943f0, 0x4eb53437, 0x66dca035,
- 0x7fa809b6, 0xa0eb137e, 0xae05797e, 0x366f48dd, 0x79f89b97, 0xe9c6d9be,
- 0x07d39326, 0x1c273fbc, 0x3e436d3f, 0xa3e7e01a, 0x7347a478, 0x26de3d28,
- 0x011bf4e0, 0x3df1d0df, 0xf1f8e177, 0x02973a1d, 0x603b0c83, 0x3ae831f6,
- 0x49e8016c, 0xf40653e4, 0xcfb40b0f, 0x9f2215b2, 0x153956a5, 0xb302ebc4,
- 0xd7dc1efb, 0xf98d9472, 0x5f3acf48, 0x6c97bc3d, 0x7efe1173, 0x67689eb4,
- 0x90686c11, 0x2c40f59d, 0x9557e3b7, 0xfa7ebca1, 0x53ca235b, 0xbdbfe487,
- 0x01e5d1b9, 0x50c7f1f4, 0x0e123f7c, 0xa7395adf, 0x2e5fb7c5, 0x8039cb04,
- 0x0f8e5ad7, 0x77c7e76e, 0x7cb9502c, 0x3d6b9608, 0x3e4423e1, 0xc1fc3c08,
- 0xeb84daec, 0x4045c6cc, 0xfacd1de9, 0xfa4f7b61, 0xf358c5f8, 0x2f67b34f,
- 0x8c5f8fac, 0xc7d5084d, 0xd7ae88ba, 0x75478015, 0x6150ea8b, 0xec8bf50b,
- 0xfaffc42e, 0x7689c566, 0x9516eee1, 0xf2fd61e8, 0x729bd228, 0x8f6e5fbd,
- 0x84aec419, 0x6b3ff052, 0x5a7d258f, 0x5fe62b1b, 0xfcc0bf06, 0xbabc6da7,
- 0x3d79e6dd, 0x6fad0e50, 0xe11226f9, 0x71593fdc, 0x4abb411d, 0x85818fab,
- 0x84df7814, 0xd70829bf, 0x322a0dc1, 0xad9ef5d6, 0xf6f09526, 0x8c378e2e,
- 0x0a33be75, 0xa6a7f5d6, 0x7b40bad1, 0xaf8eeceb, 0xeb05dd6f, 0xfae68daf,
- 0xeb9a36b9, 0xcebbd3e7, 0xbb7a41f7, 0x9274e176, 0x9ef4c37b, 0xdce5038f,
- 0x730efd1b, 0x6d4acc39, 0xd4e3fb47, 0x68fbe52e, 0xa235a100, 0x0aed1e9f,
- 0x06a9ca35, 0x1c4415db, 0x1f0039f5, 0x145b5f84, 0x073eafc1, 0xd6932ef8,
- 0xd9d70279, 0x14b2316e, 0xfc0b3f68, 0xbae4fd88, 0xcf7ac47f, 0x9a6f5f84,
- 0xa0b468ed, 0xbebfd50b, 0x1e20bc6e, 0xa2d57c60, 0x669c7da7, 0x67c44e51,
- 0x10c5d1b3, 0xc283deff, 0xab78103e, 0xba773411, 0x0f01c865, 0x81fd6fec,
- 0x7fbe2734, 0x48d9c77a, 0x47ed199d, 0x7d876a8f, 0x565de9a9, 0x5bbb87d4,
- 0x39de5ece, 0xc19be480, 0xbb3beb0e, 0x33ddb0ef, 0xcfed47e0, 0xfd88bf6a,
- 0x0dcdead5, 0xaa227681, 0x1a945259, 0xda5a523a, 0x220ca9fe, 0x0f2863fe,
- 0x57cc19bd, 0x3e5efb0f, 0x54d3d050, 0xd7be40e6, 0xcdbb7be2, 0xe00f619d,
- 0xb736cddb, 0xf385d703, 0x3ed2e6a4, 0xe83eb0b3, 0x0679e9cd, 0x0c6fee1d,
- 0xed29bd43, 0xb44fb93d, 0xfd7323c7, 0x5ef693fb, 0xce73fef7, 0x68c7da0f,
- 0x74ec83df, 0xc52c740e, 0x282d5a73, 0x03320785, 0x784adff7, 0xacfb16a9,
- 0xaab7308e, 0xcdb62fb0, 0xca53b270, 0x7dd0ac83, 0xf3869e00, 0x780f387d,
- 0x377fcf10, 0x4e11eb3b, 0xda1b0efa, 0x91afb0af, 0x50560fb8, 0xf8708c96,
- 0x8c9aecc0, 0x2599fef2, 0xf4fae88c, 0x14f7ccb3, 0xbb4b7a6c, 0x0366e88e,
- 0xffe882bb, 0x5b99dd0a, 0xebe266dd, 0x7e7ef8b1, 0xe50ea347, 0xa1cf8e6f,
- 0x797ab943, 0x474eb347, 0x2f19e0f4, 0x0f5674e0, 0x54dfebeb, 0xba48fea7,
- 0x2e9e1498, 0xabf6f042, 0xb849bc40, 0x30f4128d, 0x3286e10a, 0xb27f4bb9,
- 0x370fc233, 0xb54b0bc0, 0x58c78e87, 0xa9c20667, 0x7d63c5ed, 0x9abc613a,
- 0x8add8f97, 0xabf9a970, 0xcc618889, 0x418f2f5f, 0x30b2ffba, 0x72735dbc,
- 0x0f5b9d71, 0x3dab78c4, 0x157be48b, 0xbda230eb, 0xaddd7200, 0xd2eb900f,
- 0xe867db8e, 0xf7f1c628, 0x12d9510d, 0xe759f380, 0x461624b0, 0x3f72c85f,
- 0x00396dda, 0xe155f47f, 0xfcc5e4f9, 0xda476e18, 0xb25afc83, 0x9678b7dc,
- 0xe7a18c7b, 0x8e0df6f1, 0xb14e7f24, 0xc87a1ec6, 0xa78dedce, 0x81cf5ced,
- 0x3ae17660, 0xe2c5fd4f, 0xa9d342f3, 0x0cadf7dc, 0xdb6a74e0, 0xa05e79bb,
- 0xe3ac53a3, 0xdf9097f6, 0xb9d336be, 0xfbf078ae, 0x7e2c4b79, 0xfb8abcfe,
- 0x2f55d852, 0x407569bc, 0xbb2de2ff, 0xf001bde3, 0xbfe98abb, 0x4ceba6ee,
- 0x8fef979c, 0x20fb3be9, 0x274bd83e, 0x16501d12, 0x3c6af8bf, 0x373803a7,
- 0x14ff450d, 0x633f8fe7, 0x5ddd8053, 0x3dc6b0bc, 0x1fc02f26, 0xf9922e73,
- 0x0efaeb02, 0xab891e23, 0xfda999cf, 0x9e25bb76, 0xd62f4de4, 0x8f4de50b,
- 0x7848baf0, 0x3c25db6a, 0x913e0df7, 0x97c5f681, 0x07c5d83d, 0xaf7ec1ec,
- 0xdc7b1637, 0xf5fc7263, 0xdea77dbf, 0x5ef30ee6, 0xacff188b, 0xda127873,
- 0xd6c6c57d, 0xe1f9c2cb, 0x0b5339e4, 0x57ce37a7, 0x7fb8e346, 0x1f1a6739,
- 0xeddb5d6e, 0x3fe69fba, 0x0aab07d8, 0xf44b0bb0, 0xdced379e, 0x326ab05f,
- 0x3f2e6bd4, 0xd9ce8e3b, 0xdc845e92, 0xdb798abb, 0xf4b57f90, 0xbefdf121,
- 0x4b2a5bc4, 0x693dbc45, 0x11ba7077, 0x43f920fc, 0x396d470b, 0xe13cc8c1,
- 0x75cf03ce, 0x799235c3, 0xbede1e41, 0xfe7a40c1, 0x4e1ff3cd, 0x3f7a03cd,
- 0x5b60d6b6, 0x5ace530a, 0x51ed3bb7, 0x360da7f4, 0x1fa814d9, 0x865eb473,
- 0x4eb95f7c, 0x1c3d2375, 0xe27b7b5b, 0x00bf2874, 0x7582adfe, 0x50306e54,
- 0x770dacfb, 0xc109fb50, 0x12eb95d7, 0x7cbca3fa, 0x4481fdb3, 0xeface3c4,
- 0xf11ebfee, 0xeb68c5b2, 0xaaca183f, 0x263dc526, 0x3673de00, 0xb7d50646,
- 0xdc2cd8e8, 0x532bc487, 0x1dcfdd3c, 0xdc631eb0, 0x6b63c44f, 0x18d51f88,
- 0x92ccedc7, 0x9aefb029, 0xbec96721, 0x8a27bddf, 0x662bc9f4, 0xd6c8ec95,
- 0xb7f3ffc1, 0xf45ea12b, 0x3649de9d, 0x58f3c09e, 0xce866781, 0x8a8fa040,
- 0x7a2f5e08, 0x68764f51, 0x78254591, 0x1d5c82b7, 0x65de4a43, 0x7efd0b1e,
- 0x4753df21, 0xfd0e1ead, 0x1818c6c6, 0xb45fa1ea, 0xa06629ce, 0x4e797f27,
- 0xc06769ff, 0x9733467e, 0x42e2ed1e, 0x5f6a0866, 0x0a7d6511, 0x4c185aed,
- 0x28b0fa8f, 0xd8f9f822, 0x813daecb, 0x5b58c4f6, 0xbfa4bb70, 0xbfa0389c,
- 0xb1b97efe, 0x8fe7cf7b, 0x567d804c, 0x9ec953ec, 0xde5c90be, 0x41cafb8f,
- 0xda51bf7c, 0x29bdef04, 0xf9e6f3a0, 0x9052cb63, 0x86140abe, 0xe763ae7e,
- 0x5ce5f3c3, 0x018c9f41, 0xf1f9fb9e, 0xbb39d13c, 0x7f6c8ebb, 0xeebcc15d,
- 0xe2ffae3a, 0xcb0fd9e5, 0xf73b4eab, 0x87f5686f, 0x53fe7f96, 0xf078a3fa,
- 0x0b5e19ab, 0xe585ff95, 0xfe5c2dc9, 0x5685e56a, 0x6975c85f, 0x4e7d5bd7,
- 0xcf13d20d, 0xd7e27909, 0xfe7a4617, 0x6b8f9e33, 0x9e8486e2, 0x219ec18f,
- 0xea877978, 0x760e5ce9, 0x6fd8edd7, 0x5711d980, 0x665a4b08, 0xb9468acb,
- 0xdcf164d6, 0x97e01719, 0xa8d4dfea, 0xedd1f943, 0xfb0431af, 0xf5f9e46d,
- 0xffbe389e, 0x875e38f2, 0xfb9d2bf3, 0x92794437, 0x2f6f38f5, 0x7e3033a3,
- 0x85fbcb25, 0xaf7690fc, 0x9da577b4, 0x7d59ed2b, 0xb367b703, 0x7e41dd63,
- 0x5fafd633, 0xed183f90, 0xef73e474, 0xe7da28ae, 0x107b8a67, 0x731569f2,
- 0xa017143d, 0x7c0deb07, 0xbcf5dafd, 0x13ec2716, 0x413b26e6, 0x1d1ccfb6,
- 0x8d6f9e5e, 0xc2ff53d3, 0x40ca6fc7, 0xb6b3ee3b, 0xce50339b, 0xfff1a67e,
- 0x0f0fc4f6, 0x507d7e0b, 0xe15893e8, 0xf9087827, 0xedc0ea08, 0xfef02dae,
- 0xe26ec58a, 0xbe2edfab, 0x1747ca91, 0x8fe7a42f, 0xfcd265c5, 0xdc77c2b6,
- 0x23a700d9, 0x17d2552b, 0x3eee8d33, 0x91def0b1, 0x1bf91d08, 0xc799d70e,
- 0x3b63336f, 0xcce5f3a3, 0xf26c27c7, 0x1f01f806, 0xe90c7dc3, 0x09af9f79,
- 0x9d2a5ebc, 0x2b4eb356, 0x7a6eadea, 0xb7a2103d, 0xa72f11db, 0xf6226759,
- 0xfa3a55ab, 0xf3a12934, 0xaf5cc83f, 0x2366bf61, 0xd37c8feb, 0x92f5c51c,
- 0x029bdfb6, 0x9ed0ab7f, 0xd433f285, 0xcce4615f, 0x7b5e823b, 0xc4ef5d5b,
- 0x9333bc91, 0x56eb4edd, 0x3ef44e29, 0xb4e707ce, 0xc639f10f, 0x975fd089,
- 0xc775b56d, 0xc779f855, 0x185c71fd, 0xfe4f5c7f, 0xee3aed1f, 0xd570e789,
- 0x296485fa, 0xc4c742fd, 0xd9c5167e, 0xe844fc82, 0x0fe70f0f, 0x48de3aba,
- 0xd510dbfb, 0xa8b8c5e9, 0x3e7e66f7, 0x55e51a4f, 0x5a95dfd0, 0xfe8858dc,
- 0x71c67fb0, 0xbc7da63f, 0xf1cf1927, 0x4e8d92bd, 0x2c5ce3f4, 0x76680e3f,
- 0x478138f1, 0xd358eb47, 0x03ec8de1, 0xf0ec4aeb, 0x34a11a14, 0xf8d226c4,
- 0x096eac49, 0x11fa0de2, 0xa3dbf230, 0x743c8a7c, 0x213c9743, 0x91a56147,
- 0xaddb77c8, 0xbc3c531e, 0x5d467437, 0x53edfa3d, 0xe23c78ab, 0x6de9e284,
- 0x1b8d0ecf, 0x5e3932cb, 0xbb88aff0, 0xd0346fe6, 0x3e37f2ba, 0xfcd1f146,
- 0x95eb578d, 0x1f943900, 0x27fea06f, 0x9bd39d5e, 0x851f18fc, 0x880ebf8f,
- 0x4662f4e7, 0x8a10e11f, 0xbfa58687, 0x313ff17e, 0xf609dcae, 0xef3cb050,
- 0x20243f17, 0x0cfaa16f, 0x3c7d73c9, 0xc07f23d7, 0xd358057c, 0x7cc8661f,
- 0x8fe40d85, 0xbe6c6add, 0xde51e306, 0xbc431d1a, 0x2bf9efb7, 0xcd676bc5,
- 0xb6bc5070, 0xcf7dfdfb, 0x3ff6c72c, 0x118362cc, 0x87be29fe, 0x7ccff415,
- 0xc9e3c91b, 0xb1326edf, 0xd9a5b025, 0x3c53376f, 0x8e954d78, 0xeed17ca1,
- 0xe832661b, 0xa0db5c78, 0x47f8e02b, 0x0ef12839, 0x7c446404, 0xfc21bc48,
- 0x6e3198b6, 0x5fad02fc, 0x7e80cbae, 0xc7dc04f0, 0x4e906b96, 0x15d9557a,
- 0x75c817f4, 0x4c9f485d, 0xfa69ff8a, 0xc3d467e4, 0x9c5fc5b7, 0x74819e1e,
- 0x5ac3d5ae, 0x7164dbfd, 0x0bbf6255, 0x4213e1e9, 0xd7894dfe, 0x7e3043c4,
- 0xc76f0616, 0xf00c1c84, 0xff19df8f, 0x1fe3fc23, 0xe3091ca1, 0xc8c67f1f,
- 0x9da36fe5, 0x0c2936dd, 0xe627bcbf, 0x32eeadd7, 0x6f8cfea2, 0xb3cac251,
- 0xc651ab6c, 0xfae05713, 0x2b44fc64, 0xb7c0c38f, 0xde5ffb11, 0x7b0bbad4,
- 0x165ec6e5, 0x15dbe68d, 0x37b9c3df, 0x046b3ccc, 0x30163b9f, 0xea3aa38a,
- 0xa82bc918, 0xb093b8fb, 0x0023f295, 0xb8e04f1f, 0x9d638a17, 0x1d9215b6,
- 0x8656e324, 0xf8f3e0d8, 0xcfd9789e, 0x6fc447f5, 0xe27a0f7a, 0xb05d624f,
- 0x5fb067ff, 0x141602fc, 0x9971919f, 0x62af3af8, 0xc47547cc, 0x3bdadfc8,
- 0xf304b3ce, 0x3386ba3f, 0x8f5053e7, 0xa215b529, 0x72cfb53c, 0x66fc61b6,
- 0x9fee29f9, 0xf98f3e5f, 0x79012a96, 0xca2c9e05, 0x05bc4203, 0x0a7607fa,
- 0xac53b6f9, 0x5fe4f41b, 0x5abaf9e3, 0xa4f403e2, 0x756e87c4, 0xed784aab,
- 0x02a7af0a, 0x43fedaf0, 0xf919fd78, 0xe48b9df2, 0x852f0fcb, 0x9171fe6e,
- 0x8c4bf374, 0x3b090c6f, 0x578867df, 0x67407ced, 0xbef88347, 0x78db3a07,
- 0xf9d2f189, 0xa7a89fe6, 0x5dfae142, 0x5c28427c, 0xfaeb1657, 0x5166bc91,
- 0xd57a70ce, 0x4ffe6096, 0x12d891e7, 0x1e7a5c86, 0x3b7bfac9, 0x1967888d,
- 0xd5eb9107, 0xf6c88fe6, 0x0f25169a, 0xbb859fcf, 0xe039d3cf, 0xe8bfdb74,
- 0x079a101c, 0x0f9de7c2, 0x39fc8de4, 0xdcd01d56, 0xa677fc0a, 0x752748c9,
- 0x377e3995, 0x7bf7fd0a, 0xa0e7cc0d, 0xffd811fe, 0x5ffbc60a, 0x03bcb4d1,
- 0x305757fd, 0x479c57bd, 0x1db9ef95, 0x7c7c8315, 0xf2955ec5, 0xfe66d8bf,
- 0x2c458ebc, 0x4c74ff41, 0x02398e81, 0x8aeb19e0, 0x78008e62, 0x07b78dc6,
- 0x7939e5d5, 0xc13798ae, 0xfde82bdd, 0x82b31ba4, 0xae78a7fa, 0x3a9e7a08,
- 0x9ea8372b, 0xa822375e, 0xa385ef7f, 0xde99ea83, 0x67fa836b, 0xaa0e4c37,
- 0x1cde34e7, 0xab18ffd4, 0xec147c7b, 0x5bfa3fb3, 0xebcc3f00, 0xd60cb8ea,
- 0xb7ac433b, 0xa0f29aef, 0x5afd81f7, 0x53381e31, 0xcf17c990, 0x00abdf8d,
- 0xff08671c, 0x39bee5ce, 0x55cfe341, 0x677e88ab, 0x048e1a36, 0xacf469fa,
- 0xc02a4f6b, 0x38a7c6b9, 0xb95ea15b, 0xecf9f826, 0xbde81b1d, 0xf6e0bed9,
- 0xeb839bb9, 0xd29cde83, 0xb901e79f, 0x4672bf29, 0x87dfb042, 0x9989d085,
- 0xb599f4e4, 0x7aa5ffdc, 0x24e86afb, 0x27ec5f18, 0xd0438dd2, 0x9839298d,
- 0xc11d226e, 0xfaf95374, 0x0708a1d6, 0xfba3fc2d, 0x0bc9e869, 0xfe007eff,
- 0x7d306716, 0xfb4ee169, 0xec567583, 0x95efd850, 0x6acfb850, 0x2a797879,
- 0x633b850b, 0x1fd7233e, 0x688fedc1, 0xd981fde0, 0x89ca18f3, 0xa8163bb3,
- 0xe3638718, 0xecff3c79, 0xed07af8e, 0x2f898473, 0x97c484e5, 0xf80425d6,
- 0xe97c647f, 0xaf19c634, 0x67111764, 0x844ffddc, 0x8f00c807, 0x0b11f301,
- 0x71dd119c, 0x3c7f48c5, 0x653f2b49, 0xb9e3fa09, 0xfe2bd204, 0xbc3d6c78,
- 0x03e6343d, 0xc653ae37, 0x8ebe64e5, 0x930a2bcc, 0x8497fc9f, 0xb40fcc04,
- 0x75f9e347, 0x3a7cfb4b, 0x22bcc977, 0xc302f226, 0x4fa4ffd8, 0x14d7f19a,
- 0x26760bb2, 0x0afebd70, 0x176dd78e, 0xa92fbc88, 0x471a7bd7, 0x2a7adfc6,
- 0xc52a5d95, 0x2894bb13, 0xf46153e7, 0x3f0947ca, 0xe685bf51, 0xa8147f8f,
- 0x38ee6a47, 0x0bf507bb, 0x6c63fdc0, 0x6f4058b7, 0xfdbd7e2b, 0xd12b68bb,
- 0xaaebd76b, 0x9c342faf, 0xd8c47089, 0x222d8e01, 0xe445afdf, 0xd6f5c9fb,
- 0xf4baa445, 0x9c1ed879, 0x8ae327ff, 0xc28dfdda, 0x3afe71fe, 0x976417bc,
- 0x76e5cf2c, 0x870169db, 0x276e160d, 0x9db91318, 0x1f39ab50, 0xfb7036d5,
- 0xacd7a40c, 0x8c718096, 0xdfea1689, 0x4c685cdf, 0xdf8471c4, 0x42a67965,
- 0x4572c576, 0x77e47b21, 0xfcf4d1b6, 0x868509cf, 0x6fffe844, 0x6011af31,
- 0x16636588, 0x93438f5f, 0xe892fe17, 0x68c252ff, 0x36898d2a, 0x5db67fe1,
- 0x6a91f481, 0x5da91976, 0x8aa71f0d, 0x1afbe44e, 0xb464f229, 0x42718071,
- 0xdfdfa26e, 0xe2d2edc4, 0xfe4189b1, 0xf18cf7fe, 0xd0afdfc2, 0x53942eeb,
- 0xef7814bf, 0xeaefffc9, 0xf1476b67, 0xaffff5ad, 0x7ffee48c, 0xf1081f19,
- 0x85c73bff, 0x1e23fff5, 0xfe7eeda2, 0x2dd893e9, 0x3e50d29f, 0xea7a30ed,
- 0xb5d5fcf1, 0x6878ec1d, 0xa4ebe7ee, 0x7dc0c0b8, 0x673c4ed9, 0xbb64cf2d,
- 0x4b6f482c, 0x7f3b4318, 0x696ea747, 0xe95f3c24, 0x3e7c3665, 0xbf3f2d7c,
- 0x3871ae55, 0x0e529b71, 0xfdc89d5c, 0x1f380687, 0xbdf1725b, 0x27186dc9,
- 0xd9953958, 0xb2350d51, 0xda2b22c6, 0xd8596b45, 0x4168e3f3, 0x770a134f,
- 0x4276fe51, 0x0fb7cf17, 0x7693a7ed, 0x73e2217e, 0x2ce79758, 0x7971cf8f,
- 0xcf112242, 0x5f3aeda9, 0xb27d73b8, 0xa46ae8ad, 0xf0be81af, 0xc29188e7,
- 0xbb32e64f, 0x03f8e227, 0xd87cf1b7, 0x677f294a, 0xf01e98e8, 0x75e0453e,
- 0xd79e5aca, 0xff7fcec1, 0x45ed2abd, 0x9433e346, 0x2d53952b, 0x5513f43e,
- 0x697a64b6, 0x99c56e5d, 0xe5a2f283, 0x2bd6376d, 0xe86df3f3, 0x9dfd7097,
- 0x91fb4729, 0xfcb8c9a9, 0x52a3b3d2, 0x8f1e909e, 0x64d438a7, 0xf1236f41,
- 0x72409cb0, 0xc034657e, 0x92ed72bb, 0xf3d7985d, 0xc5191ffe, 0x5da80e9b,
- 0x5fb07143, 0xe6167001, 0xa567a962, 0xa648b7e4, 0x718aa671, 0x7982ffbc,
- 0xfef3fc23, 0xda75e5aa, 0xf30301cf, 0x9d1d0046, 0x038379de, 0x09e5eeed,
- 0x93cfe411, 0xaa83da71, 0x42523ee7, 0x5c1aaefa, 0xd12d4dda, 0x9c83f436,
- 0x3a61f9de, 0xb93e4dc6, 0xed05ace7, 0xbbe87fd8, 0x7c2f982c, 0x16bbd17c,
- 0x93f1c017, 0x9de52a45, 0x86f42add, 0x897dfb84, 0x271fee1c, 0xdc2117ba,
- 0xddfc5b6f, 0x2a3cc0d0, 0xe88130b6, 0xa54fb679, 0x9cb75c90, 0x168d1cdd,
- 0xbabd774a, 0x2ea82e39, 0x89b540f5, 0xbf3b85d5, 0x69e824bc, 0x6306d376,
- 0xf7e703aa, 0x38fa42ac, 0x7474e7ae, 0xe7c59b7c, 0xa7aff4cd, 0x11b069bc,
- 0xb47f83ed, 0xea2b5898, 0x81877d33, 0x8abb49e7, 0x8f0ba015, 0x9d76bfc0,
- 0xa68e5e7b, 0xc63e66f1, 0xcc1947e5, 0xebe010b5, 0x724d9969, 0x998fbb41,
- 0x25c6389f, 0xae675c01, 0xe3fa1850, 0xc022ffb0, 0xfde1679f, 0xa5fda15f,
- 0x379967dd, 0xf9480e58, 0x3cf02955, 0x79f821bd, 0x696fcb65, 0x43cc199c,
- 0x27602079, 0x735f9e69, 0xd80af50c, 0x67ed4147, 0x519b66f6, 0x14496f8f,
- 0x6ca1edf1, 0xfef0f7d8, 0x18ec88ae, 0x927e184f, 0x36c5c9e5, 0x17cfd622,
- 0x7c795047, 0x5172a331, 0xaae3a722, 0x44efb796, 0xc766a97b, 0x738e2316,
- 0x9681f1c9, 0x999bd613, 0xe896ef5f, 0x1e21af3d, 0x28252cd9, 0xe1b3504e,
- 0x32ec91ac, 0xd1529f01, 0x00f08a5e, 0x1cc2dc3c, 0x503cf1ab, 0xc7f0655a,
- 0x5bffe0e9, 0x60c3bf72, 0xd1da80bf, 0xb5173991, 0xb94fb95f, 0x5abcf96f,
- 0xf30c7a05, 0x4583e4be, 0xd8cd1f42, 0x2f796938, 0xcefd5100, 0xfc9d1963,
- 0x78f649bc, 0x516bc091, 0x8f64fdc4, 0xe3d88517, 0xb7dc3dec, 0xe64ac7a4,
- 0xa5a23d24, 0xcc07493b, 0x23f7a06c, 0x4ddebd84, 0x120f2d6f, 0xcc3d245c,
- 0xe4685d5c, 0xc8c79be6, 0xb26f4aed, 0xa326d7f0, 0x30e816bf, 0xba063ec8,
- 0xed6baa0b, 0x9d0d2ff1, 0xb41f2819, 0xe7ccb876, 0x60e7c2d4, 0x9a5fcf22,
- 0xb38d70e1, 0x8073c00d, 0x85f9397b, 0x10ca46f1, 0x3dc6dbe4, 0x6edf2377,
- 0x0ff37ce4, 0x92b30f41, 0xf049113c, 0x9af4b3dc, 0xe77fc41a, 0xf2065312,
- 0x8a6967b3, 0x3dfd0f1a, 0xc39214ab, 0x18a697a3, 0x97d3ce11, 0x7c871e0d,
- 0x345ccb9d, 0x1638b4fe, 0x9c186ed6, 0x7947e5c4, 0x6319819d, 0xf4462908,
- 0x506a9f0b, 0x9a8c2fc8, 0x6be02264, 0xf557c096, 0xa4adb78a, 0x6ff01caf,
- 0xe01f5e28, 0x2aeab33f, 0xee701f09, 0x52c7cb08, 0x66b154af, 0x3b8c0a63,
- 0xd11b6567, 0x82479c31, 0x95b2d7fa, 0x66eaaf84, 0xd5dd7b4d, 0xb9d83f84,
- 0xb589cf11, 0xf79f823b, 0x8276124f, 0xbe913993, 0x225a773d, 0xb471af30,
- 0x4ad94f80, 0x6b7286c5, 0x84b6b2fa, 0x7d3ea01b, 0xed84eaaf, 0x8587c374,
- 0x1f2823fa, 0x1cdecced, 0x719c57f2, 0x9fb09238, 0x52edcac7, 0x8619ef45,
- 0x3ce2d3ed, 0xd8cfd0c3, 0x618591f5, 0x73a1df7e, 0x11e4732a, 0xfca20f95,
- 0x341b1b2a, 0x2fbec029, 0x3112d833, 0xf365e91e, 0xb83dc593, 0xd4f84088,
- 0x7e24ac46, 0x887e45a8, 0x34c3f3f0, 0xdda17b8c, 0x7942a2f3, 0x30476c84,
- 0x34709fbd, 0x9091c226, 0x9033efb9, 0x8a6f2e9c, 0xf971f3a5, 0xea2322b2,
- 0xb16df2d5, 0xf9c11f64, 0x86cbbdf4, 0x6879f1fa, 0x649ede59, 0x39bcb718,
- 0xe306a9d3, 0x19dcf431, 0x0d39ceb0, 0x8efe2487, 0x23bf80f4, 0x7807f0e1,
- 0x4f2f6a0b, 0xe0497212, 0x238a2d8d, 0xef3a5abd, 0x58089cd5, 0x48ba99d7,
- 0xe9ec93ca, 0x8c66c47c, 0xe903fca0, 0xabdf1abf, 0x7944cfdb, 0x0e57673e,
- 0xf169fc21, 0xd3dffe36, 0xcbbda187, 0x68616efe, 0x66cb4d67, 0xf6864db7,
- 0x6fce14db, 0x19afead3, 0xddc4768f, 0xbd9e5c49, 0xd5d07205, 0x41b7b197,
- 0x0e40ba0e, 0x11f20bbe, 0x4e2fefeb, 0x8b87faa6, 0xb47e541d, 0x47951fb8,
- 0xf25fbf84, 0xd102101d, 0x2e2492ed, 0xc9249717, 0x6482faf8, 0xffc66934,
- 0x3a21ddfb, 0x6c67de1b, 0x9d36309b, 0xc15cebb1, 0xa9c6f7fa, 0xd3b5fac1,
- 0x8c971b60, 0x0a15dbe7, 0xeee5a3d9, 0xe1fd4191, 0x7bc464dc, 0x9e5fac2b,
- 0x86f49dbf, 0xe81938c3, 0xb8e2a6f1, 0x37d7fea0, 0x9fd506a4, 0xfad07248,
- 0x0ecf8d26, 0xb4b9bf6a, 0xecbd507f, 0xa431919c, 0xf1014777, 0x679102cf,
- 0x8e770704, 0xfbef1b17, 0xa4b0dd75, 0x5fbd60bb, 0x73d033ef, 0x5e243e2d,
- 0x9951ac67, 0xbe9bc607, 0x2c1fe406, 0x74e348f1, 0x0e2fafe2, 0xb25ce858,
- 0x7f6f29bc, 0x350fd401, 0xe80f2819, 0x55b8b2d0, 0x6a1daf68, 0x2832b04a,
- 0x6155cb3d, 0x2c8cd8d7, 0x2d15de40, 0xa6f9425b, 0x93933e65, 0xef7697ec,
- 0xc0eeb293, 0x122e2af3, 0xd53de4f9, 0xfe10aad7, 0x67df045c, 0xe15ee922,
- 0xf127b071, 0x4ef4e12a, 0x0ae3aebe, 0x13f5865b, 0xb9f71f91, 0x6a71d60b,
- 0x0e856362, 0xbeea15fd, 0xcf9f9204, 0xb6e90cab, 0xf2819e74, 0xafbf660c,
- 0x533ac06e, 0xbe395372, 0x66a3ca55, 0x7c6898cf, 0x021405d6, 0x6d3c16fd,
- 0xae01ea7a, 0xfb7d78ff, 0x8203df40, 0x8e8e913e, 0x2c5732c7, 0xf5a1562d,
- 0xc276fe7e, 0x87ee7c06, 0xee106fa7, 0xfdc1bd7b, 0xefe01266, 0x20df0af3,
- 0x128b6f92, 0x70b4af88, 0xf2e4623f, 0xa07c8bcb, 0x9fa6e5f8, 0x7e9296cf,
- 0x26706e98, 0xe56e493a, 0x3adca0a7, 0x7640d2b2, 0xacbbd330, 0x3e8f4893,
- 0xe72c744f, 0x8c77a239, 0x691df5c3, 0x5f9864c8, 0xa552be51, 0x1fd20af3,
- 0xe7e3efef, 0x0f5587d4, 0xdbcc24d8, 0x525878a0, 0x3edcdd28, 0x5de5186f,
- 0x596ded6a, 0xeabc097e, 0xe64bb009, 0x8179e4ec, 0x3f53bf2c, 0x3ee06075,
- 0x3cf9f196, 0x4af94105, 0x1daf5955, 0x2ec8eb34, 0xc273c18c, 0xa254f789,
- 0x8d5913b3, 0x9f019343, 0x86bb7527, 0x2ff505de, 0xea8f7a26, 0xda223ea1,
- 0xeb842ff3, 0x0ccadd5c, 0xfaf30b25, 0x091aaf0f, 0xacfe7def, 0x2e6c49c1,
- 0xcf39fcec, 0x43fdeecc, 0x1bd815f6, 0xe1ddb8bd, 0xcffbc14a, 0x1acd1d73,
- 0xc7c3807b, 0x00204981, 0x056adb17, 0x7876376d, 0x3c01e588, 0x31d74f57,
- 0xe079e04f, 0xb1e3c8b0, 0xa873f324, 0x24a61bb4, 0x5d333973, 0xbd9be9c7,
- 0x037a70ac, 0x0f502afb, 0x173db948, 0xbf55aaf3, 0xbb72901e, 0xfe52358a,
- 0xdb99238a, 0x1f15b32f, 0x9835ddd9, 0x2bfd0289, 0x56683c6c, 0xf3e4d9b5,
- 0xb698d265, 0x7a60fb40, 0x73279732, 0x8e3ecf8c, 0x3ac95be4, 0xfd353ef8,
- 0x2af8373e, 0xf543323a, 0xc36d854f, 0x6f8d3b32, 0xb79fa270, 0x756bf052,
- 0x256be2a3, 0x51eb853b, 0x299d57e9, 0x3f56a8f4, 0x8d25e885, 0xd1a99a3e,
- 0x5831acbb, 0xe97ac2cf, 0xaf5cb2de, 0x68ee9d76, 0x0e61c10b, 0x6ff50bac,
- 0xa7b7c785, 0x38add684, 0xeb21a301, 0x31ee64a9, 0x780fb8b1, 0x5d08eade,
- 0x215f769f, 0xd4fb15eb, 0xf9c2bbae, 0xbbe62b55, 0x04293554, 0x243eed2f,
- 0x9c76b43e, 0x97854bc4, 0x45a2b7c3, 0xd67e7c21, 0xf2321f6d, 0x61ba4b6f,
- 0xe02ff0cd, 0xb047497d, 0x6f9412af, 0x1e41ab95, 0xd3d28667, 0x456cd61c,
- 0xad61a9ba, 0xdf9053cb, 0x1faf9b5a, 0xb5867e8e, 0xa9f9d36f, 0xa39aded4,
- 0x7a50058b, 0xbf8e5773, 0x17e74fca, 0x5cfc278a, 0xe9ddc3f0, 0xe01e9fa5,
- 0xeaa37335, 0xd4141c8a, 0x7a3fe44f, 0xbcb38e09, 0x63fa235e, 0xe53f0967,
- 0xab59d685, 0x2e5ff7e7, 0xcf015eb8, 0x0fdd7b9f, 0x7764f727, 0x76173f85,
- 0x3d1a5bdb, 0xfb81b1ff, 0xfe7ca55b, 0xff22ef5a, 0x3b0bb42e, 0xe3c6ceac,
- 0x9eb91a7d, 0xbd724f9e, 0x3979e842, 0x5b35d1cf, 0x13305e29, 0xf68080ed,
- 0xa56f56cf, 0xd9f1a578, 0xcbb45699, 0xbe99ae8f, 0x8f52f30a, 0xbd274d36,
- 0xa97bf95f, 0x40c63df7, 0x4d68a27b, 0x907bfad9, 0x5247378e, 0xdda2b15c,
- 0x2045ce23, 0x639fa167, 0x6cab970d, 0x95b39735, 0x90071fa8, 0xfd8bec7e,
- 0xf4f0acee, 0x68087e45, 0xe779bd27, 0x779fcf74, 0xfe77b8c2, 0x25e9da29,
- 0x755ad850, 0x5adbcf64, 0xcf563f51, 0xde20f0ff, 0xe07b01d3, 0x7b4b5ffd,
- 0x0645aa00, 0xea325b4f, 0x54076121, 0x6c321bab, 0xbd083768, 0x7f801ff1,
- 0xe7f87844, 0x11cbfc12, 0xdbf101fe, 0x9c381b4f, 0x7fe06ba7, 0xcbc72578,
- 0x2b6ca6f2, 0x6d3f2f9e, 0xebbb26c8, 0x821ca6d3, 0x00078cff, 0x1f5fdcfe,
- 0x0035776c, 0x817cf1fc, 0x96f587f0, 0xfc043bb7, 0x0dfe1c9d, 0x256cee1c,
- 0xc084672f, 0x57f94bd9, 0xe4d1fe77, 0x78e23b44, 0x57d92b64, 0xaca8b7c7,
- 0x932ec03e, 0xac37d176, 0xdfb449f1, 0xf767fc24, 0xf28418e9, 0xd7e1f4a7,
- 0xd98788ac, 0x3150785b, 0x95ccfe04, 0xeec7f144, 0xa8edbbf9, 0xdd5f116f,
- 0xe245d476, 0x19b986a9, 0xd796c7e9, 0x4239e00e, 0x45bf7171, 0xb66fbc8d,
- 0x19bef823, 0xda9592e6, 0x8ce2c5d1, 0xa4f5c088, 0x79d3ef69, 0xbebdc618,
- 0xd6eaf9cd, 0x5de7c4f9, 0x25b97941, 0xfe80d5ac, 0xd0acd636, 0x05eaed3d,
- 0x8642d685, 0x5a3ab571, 0x09453387, 0x56aecbca, 0x564f6475, 0x447c4519,
- 0x892455e4, 0xdc29497e, 0x629c902f, 0x2474f2a3, 0xda707d23, 0x7de1f462,
- 0x255f382a, 0x9ddefce3, 0x41dbc226, 0x5fc0135c, 0x333f0a35, 0xb7a442a8,
- 0xd3a7185b, 0x297bcc5b, 0x972707ae, 0xa71fa875, 0xc939342d, 0xa18f8dce,
- 0x42cdd2f8, 0x5e62ddde, 0x313d46ee, 0x61746ccd, 0x317ae309, 0x1a30d7f9,
- 0x0df987a6, 0xef748cbd, 0xf3a234b0, 0xdf123c59, 0x8ef87c96, 0x95ea5808,
- 0x1fa38e60, 0xf6dd7e18, 0x5e285c7d, 0xf609f8fc, 0x8546d74b, 0x170c8bf7,
- 0x2e5c5070, 0x609b3ff2, 0xc75828ec, 0x6f0714a8, 0x3fb8d877, 0xc9e02d7a,
- 0xb6afc7e2, 0xfc79799d, 0xb1f30ab2, 0xbc58f7f9, 0x5d541f24, 0xc8cabd50,
- 0x62794f9f, 0x34eaf143, 0x8e61dec6, 0x2ab78881, 0xee782194, 0x61f18b2f,
- 0xf43aef7c, 0xd4b1db87, 0xd64cbd13, 0x978eaf33, 0x0e3b660d, 0x25e3fdc7,
- 0x2abf9e02, 0x0031ad60, 0x83d7d6f7, 0xb437f3fd, 0x02fb5aea, 0xb7d3af7c,
- 0xea7d21b6, 0x1b061c22, 0xaf1ee3cc, 0xa539e2e4, 0xadc5e96a, 0xa689e2b7,
- 0xa0a3d5e2, 0xacf9e3ae, 0xfee6bf5d, 0x59805b89, 0xeab76e11, 0xcb9abb59,
- 0x52e100e9, 0xa978776b, 0xe2853cdf, 0x202e3237, 0x86183ff1, 0x2de3c40f,
- 0x4e307d62, 0x37df1583, 0x7cd7c786, 0x8ccc2f81, 0x15cfb846, 0xf257377c,
- 0xbf30535b, 0x0478823d, 0x2ed0553e, 0x22ddb806, 0xe2f89eca, 0x476e14a1,
- 0xcfc2943f, 0xe25cf7ef, 0x95dccc7c, 0x82797941, 0x7c4daa5f, 0x75ff397c,
- 0xc5307ca2, 0xf5cbe34e, 0x8a7ebd00, 0x0240e8e3, 0x691ebd20, 0x68fb27ac,
- 0xc3880b16, 0x49fbfa65, 0x77ad0eba, 0xf7dd11cb, 0x66bb1a58, 0x5f95e820,
- 0x8e513a44, 0xce6c62de, 0xf68733a9, 0x52e67193, 0xefa061d6, 0x993f4903,
- 0x55633fd0, 0x9535e533, 0xf41efc2a, 0x578b42e9, 0xc7e27607, 0x067bbe22,
- 0xa79c46ec, 0xfca15634, 0x773169af, 0x975f2096, 0x2c7a8d5a, 0xdff1163f,
- 0x8d17595b, 0x2b2d89ff, 0xdf8606e6, 0xe631504d, 0xa4f80b07, 0xadfb05d8,
- 0xebc3f947, 0xe4695d2b, 0x4ff5128d, 0x665c61f7, 0x03a079ea, 0x762e1faa,
- 0x5fa7bcc1, 0x91d9cf15, 0xfa7e7c62, 0xdecf413e, 0xe9de34e3, 0x53f3e4c7,
- 0xf90af9fc, 0x7f5e2bfc, 0xea2f8e50, 0x2f9e6b0f, 0x827f3cd1, 0xf89f5bd7,
- 0xf68bd8aa, 0xda4e68eb, 0x921423a5, 0x37214657, 0x12b6974a, 0xbb754b9c,
- 0xb59a3978, 0xdc2ff2ea, 0xdb8a64ef, 0xf7809298, 0x50588fce, 0xd533ff0f,
- 0x7e814c65, 0xfe79269f, 0x499ce586, 0x7288d78a, 0xe91f3df7, 0xf21e9285,
- 0xae428d27, 0xa6e5ea9f, 0x831ea5f7, 0xf1c3de71, 0xbb9c752f, 0xe4f9c743,
- 0x4d738cc7, 0x4738c86a, 0xfebecc7f, 0x24e1ca9c, 0x517691c7, 0xe94bba71,
- 0x663afc85, 0x70bf9064, 0x18cebdee, 0xcc314bf4, 0xcfd00377, 0x919cda5d,
- 0x7dcfe307, 0x0a8cc5ee, 0xbe849bb4, 0x32a739af, 0xdaa3c817, 0x5f950a73,
- 0xc4647db4, 0xdb35b37b, 0xa0e38cda, 0x45942d5f, 0x12aaeb01, 0xa77d04eb,
- 0xa7a01c9f, 0x4274bd8d, 0xf3cc3c6e, 0xa13b9e32, 0xd5ce7c47, 0x3dfd1f35,
- 0x4a11efea, 0x97f2f8d8, 0x7b077f62, 0xee611fb8, 0x6151e5c5, 0xee34576f,
- 0x390614f3, 0xfaa2fc60, 0xbf02f9f0, 0x1528eb12, 0x50fa6ffa, 0xe003844b,
- 0x1e3de43c, 0x9b58af5f, 0x62fe8b99, 0x04e8f263, 0x7e8f5b82, 0x67ee2ed6,
- 0xd67ee16d, 0x02c77b52, 0xbb994efc, 0xf883ec57, 0xbf09b2dd, 0x2c067c93,
- 0x378eef0b, 0x89bf7ac9, 0x3f714663, 0x7ef3d618, 0xf220f99f, 0x6e28decd,
- 0x361b4ecf, 0x43e50a30, 0xceb46667, 0x4facfc06, 0x4af7732a, 0xc6abf6c0,
- 0xc9a17b61, 0xe08ca7d2, 0xf42e88cb, 0xb8feee49, 0xfe8fec4e, 0x35b18f11,
- 0x87d806e1, 0xee950de7, 0x45067803, 0xcbc5c27b, 0xe5c5ef2f, 0x8d97bbb9,
- 0x0757b1e0, 0xaff5cceb, 0x760fce43, 0x180e82fd, 0x94d2c8ef, 0x30380fc1,
- 0x5d78531e, 0xfcff04af, 0xa33c92b3, 0xa23fe702, 0x68f07d63, 0x18ebb171,
- 0x1d71f02e, 0xf74a06c2, 0x80b7a028, 0x31e4def3, 0xa9f541d1, 0x15cc71c5,
- 0x9a9dbfe8, 0xb1bf541a, 0xffa83b34, 0x07fa33cd, 0xea689f3d, 0xb00bafc8,
- 0x97b67b67, 0x5a9f04bc, 0xed0a258b, 0xbe5a4fba, 0xb416e0f9, 0x4eaa3703,
- 0xef6759b4, 0x48c1f4dc, 0xf00675e8, 0x497e471b, 0x3ed1f907, 0x7a747997,
- 0x7e303e97, 0x50758a74, 0xd73ca2be, 0x68dc6c5e, 0xf29dadae, 0x78ae7f09,
- 0xe25ebcd1, 0x72cb9bfc, 0xa99e3f51, 0x79fc9f7b, 0xcfbe6635, 0xe21e2f53,
- 0xbd442ddf, 0x357f7402, 0xe2f688be, 0xc0fc1039, 0x0e3b45ff, 0x86cd9c51,
- 0xf7b44dc1, 0xf1e9e6d3, 0x942d64fe, 0x81c65fa8, 0xba018adc, 0x036368e9,
- 0x48de61b7, 0xe5db85a6, 0xbf90a6e7, 0xf7146f7c, 0x8c4decfb, 0xcc48efa5,
- 0xda86b86d, 0xd345ce6b, 0x1da96ff8, 0xfa2f28e3, 0x13e28505, 0x2da75313,
- 0x8decfdc5, 0x1db80ef2, 0xe7f89de6, 0xdc23c7ab, 0x7bf1b66a, 0x77d51302,
- 0x5941e7f2, 0xbd0d78d5, 0x7b65513f, 0x621fb015, 0xe342ddce, 0x001b444e,
- 0xcb50eaea, 0x5597a803, 0x3f9f6b63, 0x5a31bca0, 0x9ed4de48, 0x26f7a48b,
- 0xfdfd7114, 0x0c4f217b, 0x635d7c9d, 0xe7a24dcf, 0xbd7c2e92, 0xf7f282b2,
- 0xf51b090d, 0x4321bdf8, 0xaffd42a7, 0x4a9fd73d, 0xfa37dfb9, 0x2fbe91fd,
- 0x7af84860, 0xbe8de61c, 0xc8d8af11, 0xe3c8d12c, 0x62c375b3, 0xd5791858,
- 0x9e39cf3d, 0xc73a6c6f, 0x3bff8ff3, 0xe417f5cd, 0x9d4592c3, 0x31178c7a,
- 0xe10d8473, 0xd8305255, 0x67c01151, 0x8c9baeea, 0xeac31f88, 0xafa88db7,
- 0x0516504d, 0xf916af3c, 0xdd795a58, 0xfc83e422, 0x3fd49b8e, 0xd106792c,
- 0x4136ade7, 0x9e8f82a0, 0xdf2c7c16, 0x0e33a0ef, 0xf73b71e0, 0x79a6b7f3,
- 0xd13942de, 0x7c6ec851, 0x4767e49e, 0x7e69c606, 0x9e03f5ae, 0x1bb21423,
- 0xbeaf293b, 0xc3a1c0a4, 0xdd7bc0f8, 0xf3f3877a, 0x26d1f685, 0xca96fdf6,
- 0x6fb8e216, 0x1d97f2fd, 0xedaf182e, 0xd43cbcee, 0xcfde720b, 0x0b7bf17a,
- 0x1e75d6cc, 0x2fb587cf, 0xef903b47, 0x0ce1e227, 0x4d3ba2e3, 0x76816e74,
- 0xbed4778a, 0xef0a7a6c, 0xe15ad5bb, 0x17f30afc, 0x8ad912bd, 0x4af6dc74,
- 0xc7f51ea4, 0x9f3dbd1d, 0x5e8a7c21, 0xcf063be9, 0x9316ae8b, 0xe3fd919e,
- 0xb6f24a3a, 0x485ef587, 0x4ce9697e, 0x81a7a7f2, 0xa0994bf3, 0x7fc172d3,
- 0x6747c11e, 0x0f8892eb, 0x45822ecf, 0x91753c63, 0xda1b7032, 0x7d0b0e0b,
- 0xe5f24e97, 0x411f3c44, 0xb1fec4fb, 0xeaa18f74, 0x1f106c5c, 0x14cb9f56,
- 0xed471dfc, 0x05cadf92, 0x7d84989f, 0xb5d04331, 0x3f245bb4, 0x624f74b2,
- 0x6263ec2a, 0x95bdf03d, 0xc8f9fee2, 0x31ba7e4f, 0x80be90da, 0x022b926e,
- 0xedbea7f8, 0x8a768626, 0x744dde29, 0x40ca0333, 0xb766653b, 0x971b629d,
- 0x592feb08, 0x7bc3a996, 0x6a79f29b, 0x7fd1a5ea, 0x27c8aa44, 0xa0e6b730,
- 0x8ba86b5d, 0x9a7de274, 0x1e3cf133, 0x87057f34, 0xbb837ce3, 0xf98ced08,
- 0x3fe4284f, 0xe503fb43, 0x7503d0d2, 0xcabf40c6, 0x5106e74d, 0xb9ca7d3c,
- 0x2634a8cb, 0x38472e7b, 0x5ebb9d94, 0x8fd06be0, 0x710e3f8a, 0xc192bf71,
- 0xc86e7267, 0x4792bf44, 0x4f1f3c45, 0x0347b667, 0x546b7de3, 0xb8c98ff2,
- 0x9933f4a4, 0x804fdef0, 0xdf46fd3e, 0xa3df4198, 0x0a9dfad1, 0xb93ffeb9,
- 0xbffa40d1, 0xa19dedaa, 0x79fe783a, 0xf5092ba6, 0xa7837ac9, 0x6733f708,
- 0x0339efb2, 0xb83ee7d4, 0xe1dc3ad5, 0xbeb36787, 0x69f50735, 0xfd11c033,
- 0xd52bcd5f, 0xf76e3ef1, 0x1a38f344, 0xcf496fa7, 0x739f3a5a, 0x73e09b2e,
- 0x7a44ceb6, 0x2dd02ce8, 0x5243d00b, 0x2f3948ef, 0xeba48ff5, 0x5f973d6a,
- 0xca18e6d5, 0x9debf323, 0xa442ee49, 0x1f3c7ebb, 0x9e77afd0, 0xf902355a,
- 0xe53c74e0, 0x21bd4b5d, 0xc585e0f9, 0x244794c9, 0x03e492f5, 0x7ca5cf29,
- 0xf52f7497, 0xfd3fe8d6, 0xc3bfd6ef, 0x3cd293af, 0x7d02a577, 0xfae7ab5d,
- 0x85bd5aeb, 0xfc6c67e8, 0xcdd23d24, 0x43d1cbc5, 0x0a1e8e42, 0x3d35a392,
- 0xa94581e8, 0x1c5e7e52, 0x7c11cc1f, 0xedc4de33, 0x81f39448, 0x8da6b5e3,
- 0xb1f7087e, 0xd9eb953a, 0x3ddd6b9f, 0xa9d5ffc9, 0x97ff2697, 0xfc9c5ea4,
- 0xfe54efff, 0xbcad0a9d, 0xa3710fc7, 0xf3bd3fbc, 0x83ea1f72, 0x03f40c83,
- 0x6896c1ea, 0x0fa126c7, 0xc5445f48, 0x1f487ef8, 0xfe9ef614, 0xf5e1a9df,
- 0xff6c66c1, 0xd240fab1, 0xc91be497, 0xb42f9227, 0x62f9247c, 0xbce16fc2,
- 0x8b7a7888, 0xd6aa8fdf, 0x0e289b7b, 0x8c1e88e9, 0xc76dd9fc, 0xdf88536d,
- 0xe084f442, 0x04bf3f1f, 0x1fc90deb, 0xff245f92, 0x98fe0b54, 0xf243f829,
- 0xf9b56ec5, 0x0a9811d1, 0x08f9e690, 0x93e488e5, 0xfab5e7aa, 0x42ba47a1,
- 0x199b234f, 0xae90c75f, 0xa40ca1aa, 0xfc0f532b, 0xf512f070, 0xa48bbec2,
- 0xf3feafa7, 0x0f55f4f4, 0xa7e674f4, 0x1da853d0, 0x03be61fb, 0x1f3673d6,
- 0x9fa66de4, 0x8dfc26de, 0x9b21fb71, 0x46f6079f, 0x35ee7df1, 0x67ff93a6,
- 0xcf3cf7c2, 0x3303da57, 0xd241bf85, 0x01d81e69, 0xf8fc4369, 0xbcc0f3c7,
- 0x847b938b, 0x877c5367, 0x3327cf11, 0x03b40ca1, 0x537fb27a, 0xee4d2ed3,
- 0x17fe8a45, 0xb480f3c2, 0x1c6edd9f, 0xaf1e1690, 0x027ed303, 0xa262275e,
- 0xb22bf92a, 0x00a35c4b, 0xba890f3f, 0xc2094fb7, 0xf902faf1, 0x2e55b2fc,
- 0xd607ca3d, 0xf475ddfd, 0xcaa5bc77, 0x31fece7a, 0x8f099eb0, 0x1d1fbf32,
- 0x151d8f9e, 0x511fedd3, 0x717fbf98, 0x95fed65a, 0x451be7a4, 0x9ea74ade,
- 0x3d4483c7, 0x8096ea1f, 0xbea6817a, 0xeab7f796, 0x3e60593b, 0x928dd209,
- 0x0eecf1cb, 0xfa601fb0, 0x2fa8b3f6, 0xff430a6c, 0x86fc6d46, 0x5ca2cf57,
- 0x6c50a1db, 0xde0e1baa, 0xfa070481, 0x07d5383e, 0xc65d77ef, 0x78dbcdd8,
- 0x43b5f6fd, 0x132f7956, 0x1bdc06e3, 0x2e2b3432, 0x502847ca, 0xa199597c,
- 0x4d3dbef0, 0x1eb913ca, 0x0214f746, 0xaf9867de, 0x77ef2977, 0xd1674de7,
- 0x4ba6adfb, 0x5186ff98, 0xac6fefe1, 0xe4c6fd10, 0xfe7d84c7, 0xe1ca9a70,
- 0x3406fc2f, 0x694d343f, 0xff9f7f0e, 0x1d2fc109, 0x78213f18, 0xfe855a4e,
- 0x84a30eed, 0xc2157bb7, 0x41632c7b, 0x9f98347e, 0xbad71bea, 0x7cf41a4b,
- 0xbc0d2ebb, 0x77bf687e, 0x03db05a5, 0x5f069bf4, 0xf7801fa6, 0x77de61dd,
- 0xfadfbf04, 0x125af843, 0xdba0bef2, 0x5d8e9259, 0xa31ef441, 0xc67d1377,
- 0xb4362bc4, 0x91dc6ba3, 0xe0bcf12b, 0x12d2cfe7, 0x138c9b82, 0xb4dff084,
- 0xc8033192, 0x6fcf124e, 0xebfc855b, 0xe7f775d6, 0x1ae928fc, 0x5c0136af,
- 0xef07f5c9, 0xeb769cbf, 0x024ff42a, 0xaa73d05d, 0xadd603eb, 0x4d66c7e5,
- 0x7f86947d, 0xfc91ff05, 0x70007d40, 0x16f941ca, 0x08e8c87f, 0x044f93a0,
- 0x7c894e9c, 0xdcd18ef2, 0xe2c8ec9e, 0x3c6977e5, 0xa099f52e, 0x9e9253cb,
- 0x90e002a2, 0xf43f4416, 0xf60221f7, 0x29ba704d, 0xbdf3f25e, 0xbfc0c525,
- 0xfcfe761d, 0x66fed67f, 0x5fcd3795, 0xcff78ed7, 0x2096f7b5, 0xf7c7ba5c,
- 0x768fda2e, 0x6e024dc4, 0x67bdaddf, 0xc08077bf, 0xbbffa273, 0xf41f40ab,
- 0xa46a9e3d, 0x3e94250f, 0x2fa50d5e, 0xfa7de6af, 0xbd3d043b, 0x7950b7ff,
- 0xcfbcd2e0, 0x17107bf0, 0x5bc0beff, 0xe3af06b1, 0xa31d7835, 0xbaca97a9,
- 0x4afe482f, 0xe3be5cb9, 0xe312fbe1, 0xd0a9afd1, 0x3d3f2475, 0x3cf4483f,
- 0x77e926d7, 0x4fd5c115, 0x47ed0fcf, 0x2cdc9dfa, 0xf491b5e9, 0xc39424cf,
- 0x29f5fc23, 0xfea88728, 0xc5c60970, 0x91eafafc, 0x6fb72855, 0x1ffd9068,
- 0x2f37fea5, 0xa6ade393, 0x8c8f12e7, 0xeefa463d, 0xafa97ca6, 0x3fb9271e,
- 0xefbf85a7, 0xfeddff4c, 0x4687e41f, 0x6ad65c0d, 0xff4d5eea, 0x6fd017d5,
- 0x2fef34cb, 0xa95f3cd2, 0xd4d1afa9, 0x2fdf821b, 0x1f10a19b, 0x38f01596,
- 0xb52f96a5, 0xef4ae1f4, 0xf5ba73b6, 0xfb2662b9, 0x26af882e, 0xb5faf3d4,
- 0x1a4b1be9, 0x75f501cc, 0x5f384a9b, 0xf7016cc0, 0x7ae6419f, 0x4307a055,
- 0x20b3720f, 0xd9b907bd, 0xf9efab4f, 0xafe07ff3, 0x0a371429, 0xab764bb2,
- 0x5536f5c1, 0x75bbdbac, 0x810182ff, 0x4be7d5f1, 0x63dd5cf0, 0x5cdbc71c,
- 0x2ed02632, 0xae25cd62, 0xfeca7d80, 0x5efbbee3, 0xeb3cf9c5, 0xd1b25cfe,
- 0x114f718c, 0x12f3b4df, 0xfa8aa5f4, 0x6ff856ba, 0x2f1e61c6, 0x5aa293c6,
- 0x080fe673, 0xee6b27d8, 0xbb6cfb83, 0xb7dfe55b, 0x00fc07ab, 0x8398ca9c,
- 0x33a750f2, 0xb6a5e517, 0xfc2cc4c5, 0xf76f782f, 0xd442eadd, 0xc61707d3,
- 0x2bd35e51, 0xb17cfce9, 0xe277a63b, 0x45b7a84c, 0xb6f246df, 0x54b1feed,
- 0xcb5d52ee, 0x2d8c6cbb, 0x894af75e, 0x1e7c72f9, 0x3bba7043, 0x2592a5fd,
- 0xa6f7ef40, 0x8f7de83b, 0x03b896dd, 0x0c07eded, 0x0e043714, 0xe7e89278,
- 0x3c60d341, 0xe92d976f, 0xf2b1714f, 0xc38d26c7, 0xf7e5a47b, 0xd25e2819,
- 0x9f91b3a9, 0x58c0f3c8, 0xb19a93ca, 0xabde944c, 0xdfe57ca9, 0x7bc7ac7f,
- 0x14eb5da6, 0x55cd4efa, 0x6dff375f, 0x1b2bd410, 0xc67ee9b2, 0x9474e7cb,
- 0x9ae9fe17, 0x53cc3ebe, 0x47591c3e, 0x9fd0a5f9, 0x9e56bbee, 0xc92fec77,
- 0x0daafec7, 0x428e3853, 0x47cfda3b, 0xe14fa857, 0xab32ce3d, 0xbbf30a25,
- 0xc8c77e8f, 0x3ef473af, 0xe6ef7d13, 0xd6e7b353, 0x8f74f135, 0x767d2d09,
- 0x15587154, 0xf4dac380, 0x29c925fd, 0xf8126ed8, 0x032d6fdc, 0x75d32f3e,
- 0x93e90fd3, 0x5f5e588a, 0x92cdeebb, 0xa38fb04d, 0x7ca5f44f, 0xd70c84b1,
- 0xd78074ba, 0x93d70ce1, 0xd9fb8a54, 0xc79bfcaf, 0x593a5f25, 0xb5f4889e,
- 0xcbf5d059, 0x0313cae7, 0xc5416eff, 0xc1d13d29, 0x02c7462b, 0x5469eefa,
- 0x6ce782ba, 0xf43883a0, 0xe710cf9b, 0x85e7a016, 0x57d8c35b, 0x3db9d34b,
- 0x84dbf6d6, 0xba208e51, 0x29e498fe, 0xfea0379d, 0xa447fa62, 0x16988ee7,
- 0x77752e62, 0x1ddb243e, 0x34327049, 0x3322fa45, 0x1aea7fd1, 0x4ff3a2e7,
- 0x96c99f73, 0xfd143e00, 0xfcf2f13f, 0x3fa04fdf, 0xf13efb9e, 0x604b3ffe,
- 0xaff6433c, 0x68bc5ab4, 0x58b31c5c, 0x838f88f4, 0x3147c5fa, 0x9d62ad3f,
- 0xc540f481, 0x5d4584ba, 0x6e807f28, 0xdda6bfd0, 0xc0c32997, 0xc63d18fd,
- 0x192f3f57, 0x5e781693, 0xbbf24139, 0x377cbe27, 0xc6c944fd, 0x65f33d01,
- 0xa7cb8da5, 0xf7f8eb71, 0x58872b75, 0x7bbf74f4, 0xe89babdd, 0xc8bcf01e,
- 0x5157bc5c, 0xf844ceb9, 0xbc58b4ea, 0xbef12bb6, 0x0b1f4581, 0xae74a1e5,
- 0x0e19f54f, 0xca9147c2, 0x54b911f4, 0x190a3dd2, 0xf0b13c3f, 0x1d31c7d1,
- 0xbbe673f3, 0xefc0187e, 0xe9d38b8c, 0xf92a6d99, 0xc4f1b51f, 0x1ab7d7ea,
- 0x888fd90b, 0x4710f627, 0xe29d62ac, 0xe3e1e2bb, 0xe238da89, 0xbdc5d2bf,
- 0xa238eeb3, 0x5187be81, 0x4588e229, 0x7f5a156b, 0xbdfe42e5, 0xee38a292,
- 0x18b23e3f, 0xed2fa0e8, 0xc5cb6bdf, 0x7fae693c, 0x8be2992a, 0x5eaf5f80,
- 0x99fc8f3b, 0x5e1ce975, 0xb03be265, 0x199d2387, 0x58afde78, 0xae704917,
- 0x07f6727c, 0x7de3e44f, 0x81f189c0, 0xa09b6be7, 0xe19f180f, 0xce39683d,
- 0xd0f725b1, 0xd68b6777, 0xf31939c3, 0x73d963b4, 0xde226537, 0xde303252,
- 0x2e55fb29, 0xef0fbbbd, 0xd86ce707, 0x950ad977, 0xbb6b0f7f, 0xf021f489,
- 0xb80b327c, 0xd9633e2f, 0xd72346eb, 0xa8792c67, 0xfe1db3b0, 0xc29f6cfb,
- 0x4104fc73, 0x26b7b8ad, 0x5bef27e1, 0xf7f8e995, 0x0a754b36, 0x8902c3dd,
- 0x7e97f746, 0xa3fdc191, 0xcedc1979, 0xd270cb2d, 0x55ea9e3d, 0x4cd2e726,
- 0xbdf74e3e, 0x55e73875, 0x282a3aeb, 0x1317f9ae, 0x976a57f9, 0xad22ba45,
- 0xf9e31f3c, 0xad779401, 0xaa3c0237, 0xfc6e5c1c, 0xad63d042, 0x94d5d263,
- 0x0767ae9f, 0x5607eff0, 0xac9cb85b, 0x9bb8058e, 0x86e90139, 0x1939f7e2,
- 0xb8e253e5, 0xe6028329, 0x8c3b4457, 0xc7fab0e3, 0x0d63abdd, 0xfec1a7e8,
- 0x38420f97, 0x237f5dc6, 0x9559efae, 0xb4801af8, 0xbfed00aa, 0x3c3cd567,
- 0xd8ad9777, 0xf0e50e3d, 0xf1832ddc, 0x7b2b0546, 0x23d25dee, 0x3bfe0573,
- 0x395a3e45, 0x81bbf1d4, 0xb9706437, 0xdfb951e9, 0x2f0106e8, 0x79f20749,
- 0xf7030af5, 0x47bc83e3, 0xe4bd5301, 0xdab71a43, 0x728891d2, 0x81bb7ab8,
- 0x8cdf87ee, 0x973806eb, 0x751f492f, 0xdcaae800, 0x51df4310, 0x344ef2ad,
- 0x51aabd62, 0xbdffbaa1, 0xd3a40c84, 0x60bd962f, 0x1c39fa45, 0xfa839ad9,
- 0xa45e6ba9, 0xda29ee93, 0x8beedfb8, 0xaf743965, 0xc3ad8669, 0x9965df82,
- 0x8edb20b1, 0xada0fc72, 0x0fcf88d5, 0xb0ea6736, 0x46d9b2ee, 0xbfa5dd61,
- 0x885fea92, 0x41fa177c, 0x9e3852ba, 0x1b769aab, 0xdd2feff1, 0xd4e2e82b,
- 0x41f6efb3, 0x4675503f, 0x2fd41f47, 0x527d0740, 0x28cfce11, 0x9a6b9fa4,
- 0xa4bc1e78, 0x03a41a83, 0x8239bbe0, 0xbdb66a0e, 0x43f21770, 0x373fe20d,
- 0x9e808e94, 0xf9fda9db, 0x7f18e30d, 0x44e91dbf, 0x2fa833ea, 0xce3fa033,
- 0x058bebc8, 0x0c7da1fe, 0xe00ef76f, 0xf9dd75f9, 0xd07c4108, 0x66d77e13,
- 0x4c3e04e8, 0x8ad77724, 0xd8ae76fd, 0x9dfc456e, 0x1ef7767a, 0x3f54b78c,
- 0x11dada0f, 0x3c041f86, 0x56ff716a, 0x19d93f5a, 0xab5fb8b5, 0x74ddff7f,
- 0x96b0f82f, 0xfdc9fdf1, 0xfec5ead6, 0xfef173e5, 0x2acfb13a, 0xadb5e026,
- 0xc13be72f, 0xf4c7c867, 0x3fb121dd, 0xbbf83d8f, 0xfec5bbba, 0x6cc9449a,
- 0x0f8456cd, 0x0fe517e2, 0x28cb8fd0, 0x397409e5, 0xe50365b5, 0xc97c4bf7,
- 0xd7efbff5, 0x93fc2e2b, 0x9d8f1254, 0xb6f77c3d, 0xa1c9f045, 0x763292fb,
- 0xd8befc00, 0x240d9f4c, 0xcc07d57a, 0xce46e927, 0x49a7f457, 0x61bee2d7,
- 0x5f1c56fc, 0x1bd07bce, 0x0e71c7ad, 0x721fce32, 0x8b2f92fd, 0x3b5da7ea,
- 0x4efd8ad8, 0x5ed1b259, 0x3f7c7811, 0xbbef46c3, 0xf7806ed0, 0xf2143b5d,
- 0xe7121f5f, 0xbdf743fd, 0xe01f2d60, 0xc577f7a7, 0xe19d25ba, 0xe4c9fa0f,
- 0xb9daf77a, 0x6ebb583f, 0xbae48729, 0xe1bfee8b, 0xeb976c5a, 0x2051f8c7,
- 0x4a384a9d, 0xfaf7957a, 0x344b74b4, 0xdaaaf527, 0xa6d77d33, 0x9dfca21d,
- 0x78ed7690, 0x2c3a3ec2, 0x9ebbcdf2, 0xe77df956, 0x41edc965, 0x33188ef7,
- 0x259fea07, 0x15b6aef3, 0x49b73c62, 0x521e7ba1, 0x4acfc0af, 0x923e807d,
- 0xdef0c1f6, 0x36a57f3c, 0xf10275de, 0x63bc7559, 0x44927e1c, 0x7d57a5da,
- 0xa0c6aadd, 0xcf1b6aff, 0x53749383, 0xf89db275, 0x93dc5aa1, 0xeef15b2a,
- 0xf74861c4, 0xce281b4f, 0x58df7653, 0xb3fbda23, 0x8a1f4d37, 0x127bc0e0,
- 0x6c4fdf28, 0xe047921c, 0xebc4b661, 0xc6c4bef1, 0xbfc7af47, 0x87633a5f,
- 0xc1a1df4a, 0xcb8f9071, 0x7f23c8ee, 0xcec8e1eb, 0xaed02389, 0x436ab5ff,
- 0xa6e47ebb, 0xffb08b21, 0x58ef4b48, 0xc6d078fa, 0xf4bbaa38, 0xa427a431,
- 0x03f32c1d, 0x90bdc5eb, 0xaf9cdeec, 0x8a97757a, 0xefac0bc8, 0xaef9f183,
- 0xddf4910d, 0xa3a352a8, 0xdbe715b9, 0x8ee74499, 0x2526385a, 0x2b9ee9db,
- 0x8cb369d9, 0x9725222c, 0x453023da, 0xc74375f9, 0x5e4fa81d, 0x1832c3bf,
- 0xd4cb8bbf, 0xb9cb43f3, 0x90e3cd7d, 0x61dfc171, 0xeac8eb92, 0x3b57e9cd,
- 0x2f7f7c9e, 0x74ec2b9e, 0x3fde919f, 0xebe9ecb1, 0xd89e1f51, 0x7dc7639c,
- 0x4919db1f, 0x198e0bf7, 0x78e7bf82, 0xb4c2f7a9, 0x3de4a9f7, 0xc1defcd7,
- 0xfba49cf6, 0xb9cbde0b, 0x98f2d2ec, 0x74662e4e, 0x065cfc4f, 0xe8e4fee3,
- 0x7e62b6ef, 0xc9a34561, 0x8e64f786, 0x7c63fd20, 0xdf4abb6b, 0xdfbba201,
- 0xdb23af80, 0x703ee8f3, 0x5ebcc7c5, 0xf0f8acd1, 0xc3fb72fe, 0xc2fe53f7,
- 0xf137b04c, 0x3db7796a, 0xebe1fabd, 0x38ce0d91, 0x3bf1cb3d, 0xf3366700,
- 0xef908b7c, 0x75bebc3a, 0xffe38a4f, 0xfd2cfdbf, 0x077bd313, 0xf09347df,
- 0x57aae796, 0x720a2e80, 0x72fbf0fd, 0x9fb22cf1, 0x50f62e4f, 0xb4395a79,
- 0xb3d2246a, 0x15ee8625, 0x51e3b4bc, 0x5373bf15, 0x79f06dbd, 0x308f1f3c,
- 0x9ff7d0c7, 0x90bc5cbe, 0x17279a82, 0x8a3f89d7, 0x15f854b6, 0xb55e547c,
- 0xfbde8dad, 0x0b5e4772, 0xd97debde, 0x9ac5c31c, 0x3be820ab, 0x3dbf1299,
- 0xfb9657dd, 0x1cd7fcfa, 0x9fdd72cf, 0xc56e9e6f, 0x21fdb57d, 0xe23865ae,
- 0x86c63a37, 0xc8a56076, 0x86ba392f, 0x23c7d9db, 0x18abfe62, 0xed7c7cf0,
- 0x0efc4494, 0xa9b6ccd1, 0xc57b63d7, 0xe786c54e, 0x49cee703, 0x7dcf3c56,
- 0xe2b4efa6, 0xd6cfaa3d, 0x3e57fbc8, 0x237bbbfa, 0xd829b3c6, 0x9eab447f,
- 0x84293239, 0xfc32f44c, 0xcbee9ea4, 0xe4ed017e, 0x451f393f, 0x89f813fe,
- 0x99927cc3, 0x4bbf722f, 0x9c57f9f7, 0x7d8a46ff, 0xcbb6f7b7, 0x17b506f8,
- 0x63f6f015, 0xd096b76b, 0x68de4fdf, 0xbfbae1b0, 0xf1a068dc, 0x4db9c0e7,
- 0xbe3deb07, 0xb0839f99, 0x13e8e78e, 0x6779f99b, 0xef3f334e, 0xb833cf54,
- 0x60d2fdf8, 0xe80a2cba, 0xeb2ddf47, 0x7323bbe1, 0x737f7c5c, 0x7ee27f40,
- 0xb1bf442f, 0x9fee99ac, 0xa93e6a5d, 0xaaff7e96, 0x74dd1791, 0x08bd13db,
- 0x23ff22b8, 0x98ba4add, 0xf5c786b3, 0x0b83cded, 0x9d24fe91, 0x5803bf68,
- 0x3bfc646f, 0xfa28bab2, 0xb324f7ee, 0x62fa80c3, 0x18e77c4a, 0x075f4f04,
- 0x916aaf97, 0xe4f785ce, 0xec29bd58, 0x15dec477, 0xbc1a78f2, 0x7abbf74b,
- 0xcff7f8db, 0x59317dc4, 0x474abe82, 0xda293e7d, 0xba038dfe, 0xf2ffae74,
- 0xf5d03d3a, 0x3bf691a4, 0xd7809db2, 0x7af35ff5, 0x167b7d9e, 0x7def3fd4,
- 0xec3d3af6, 0xf695d26f, 0x2fa80621, 0x75cdf259, 0xc9b9e063, 0x3bd83ae1,
- 0x9b139e60, 0x7f71d292, 0xdb087ed0, 0x8e7a27a7, 0xee2b5960, 0xba569d8f,
- 0xf4cc2d06, 0xa77b7ff7, 0x0e4be0e5, 0xc0d3bd7f, 0xa73bbbe8, 0x87f5cb7b,
- 0xd70e9d2f, 0xa109dea9, 0xdd8ce5ed, 0x5e7cf947, 0x7e076f7e, 0x788911dc,
- 0x5dd38aaf, 0xd3c7bcb9, 0xe3c7b9a0, 0xe4d5f7e4, 0x7f792afd, 0xfdff72ea,
- 0x7297b5b3, 0x00ffecff, 0x4fb2f369, 0x00008000, 0x00088b1f, 0x00000000,
- 0x7de5ff00, 0x5554740b, 0x55b9e896, 0x2a493eb7, 0x54842549, 0xaa84a925,
- 0xc0902b7c, 0x310c7c25, 0x0403e548, 0x6a285888, 0xa205a0d4, 0x01148280,
- 0x55f4741d, 0x9a7c3061, 0x179f8ee9, 0x102d4622, 0xdd787195, 0x866db1d1,
- 0x3220538f, 0xb40e9afc, 0xd38ceb63, 0x68d1d01d, 0x38311b63, 0x6f360cf4,
- 0x4dce7def, 0x802a56ea, 0x6f7be7be, 0xf65e97ad, 0xee739f61, 0xffb3ecf9,
- 0x5f5bdf67, 0xa5eb2c19, 0x0f24c664, 0xa153ab63, 0x63595a74, 0xff7b9419,
- 0x68d2cfe9, 0xac839ac6, 0xc18f2e3b, 0xd3f5a35f, 0x7ccf5051, 0x2e504bba,
- 0xcd1a484b, 0x139960c6, 0x996fd062, 0x12aeb189, 0x6d3b26e8, 0x12d8c2cc,
- 0x019dfe09, 0x19caf9ff, 0x956c674b, 0x44edfe15, 0xf08742b8, 0x7f466683,
- 0x3f98059f, 0x1fd8c0df, 0x3925744f, 0x9d9d8cf5, 0xbb0c2e1d, 0xbc65fb18,
- 0x009ce6cf, 0x8ecd1ded, 0xbec634a6, 0xd4a4c37c, 0xd09eff43, 0x60f927df,
- 0xe67aa5fc, 0x6d9284ef, 0x24d8ce1f, 0xc3ea2f28, 0x61dfa053, 0x8db6f157,
- 0xa9cbbcf0, 0x3f9e0c63, 0xfce70aeb, 0x82c678f5, 0x32f2932e, 0x32777ea3,
- 0x9f1eeb80, 0x9dfb1c3e, 0xfe5d7d7d, 0x936eb03d, 0xec1258cc, 0x598c067b,
- 0x0030780e, 0x07c32fac, 0xb40e3442, 0xbea09307, 0x0e74f5c5, 0x2f307c23,
- 0x0dd8c89b, 0x06ebef8c, 0xf11fbc39, 0x196494c5, 0x6f9b37f7, 0x3283db0f,
- 0x3333a38c, 0x98bbae03, 0x4d3f5875, 0x8eb19800, 0x7f60c34b, 0x3263c066,
- 0x24c78096, 0xa1eaa6c6, 0xe9afac13, 0x0990fa97, 0x7884d7d6, 0x85d07014,
- 0xd72c7a23, 0xc58bf8c3, 0xbc8ecbbc, 0x58c1c46b, 0xeb07fe10, 0x5de62259,
- 0x3d7771dc, 0x9092cb9e, 0xc0b74ce1, 0x7ffa25f5, 0x72c79d0f, 0xf2feefd1,
- 0xe29c46ad, 0x7eda1dfe, 0xafa6d9cb, 0x52fcf0f5, 0xfdc46dd6, 0x6a8ceb2e,
- 0x0cf9a8ef, 0x977cbbd7, 0x99debeb6, 0xc2748698, 0x97b1b2c6, 0xe74d54f4,
- 0x99f448bd, 0xca746faa, 0x66e19fb8, 0x371304c5, 0xf4479f3d, 0xb00cdec2,
- 0x63ac7ec8, 0x8b4fd118, 0xb1e74f4b, 0x9cc49764, 0x7ebb18e3, 0x42731657,
- 0x61aefd53, 0xc85d2654, 0x5fcffaa0, 0x57de3639, 0xd75e7032, 0xc6ab6abf,
- 0x6aff5df5, 0x3aea9511, 0x4e1d049a, 0x867497d5, 0x2ce71d61, 0x9b800eb0,
- 0x8162c08e, 0xd66e9a7e, 0x99e11887, 0x57bfb199, 0x596bc72c, 0x424fa5df,
- 0xfd8a0e58, 0x3a24974a, 0x1f3c6484, 0x433d61ef, 0x031e627a, 0x79993bb5,
- 0xa05ca5cd, 0x398ebb1b, 0x24dfe063, 0x19ce2fce, 0x81ee9ccf, 0xfc583976,
- 0x87584ab3, 0x0941ae61, 0x5c737b41, 0x33e436d2, 0xe574f416, 0xe20d73c3,
- 0x4e38aeb9, 0x54ee0937, 0x1d2af3cd, 0xadfa2adc, 0x18769a4b, 0xb3c1b2e9,
- 0x5121e888, 0xc7acd4c9, 0x406a5fa4, 0x67d5b9fa, 0x623ba4f8, 0x585fa21c,
- 0x295e0dc7, 0x7378fc84, 0x50ddb683, 0x44ad75f9, 0x8e47d425, 0xfbf6d5e7,
- 0xd003d229, 0x717e103b, 0x9c0c3d24, 0xc3a3c583, 0x1224f073, 0xb9cccbbd,
- 0x5be012b9, 0xee181b0e, 0xf7cf14df, 0x97310e79, 0x0f80fd86, 0x8875e260,
- 0x2e4fa817, 0xc537e2d7, 0xb0e7c5a3, 0x867e2d3a, 0xb7fbb57b, 0xda6ae435,
- 0x35237c33, 0xcb8b59ed, 0xbfb67034, 0xc47fd342, 0xec0d6aea, 0xf4d4ce0a,
- 0xa37f5bcf, 0xbd682e06, 0xa8bfd35d, 0xbda6817d, 0xa69f7438, 0x268ed47d,
- 0xf9da5c0d, 0x98ffa688, 0xda6b8f5d, 0x6a3786c7, 0x7e1dc7da, 0xe84f034a,
- 0x7fe9a2da, 0x34db07cd, 0x5fba93ed, 0xdb5fb4d3, 0x9e0686f3, 0xd35bbbdc,
- 0x0385ca7f, 0x1d8ab81a, 0x31aff4d3, 0x4f0356ff, 0xa6abfeb5, 0xc7fb74ff,
- 0xce19f69a, 0x67da6a3f, 0xd2d1bfb9, 0x93973c6b, 0xa5ff2bd7, 0x9359ee79,
- 0x5f50dfef, 0xdd954b34, 0xebf48641, 0x35ba3e24, 0x0184a74d, 0x972a83fe,
- 0x1c9e1d04, 0xc1392561, 0xb78e59f2, 0x32b0e914, 0x6e7c7c8c, 0xe0f24497,
- 0x28bd28ab, 0x91ebd1ff, 0x4afd9da0, 0x22765e52, 0xc45d41dd, 0x331e29fc,
- 0x39d62393, 0x81aaceac, 0x9aed7b87, 0xa706b6fe, 0xe7c33da6, 0x2d67b4d6,
- 0xb6703456, 0x7fd35cbf, 0x068f6ac4, 0x34eb0576, 0x7bd6f3fd, 0x6b417035,
- 0x517fa683, 0x5ed34fbb, 0x69ac5a1c, 0xafc3b51f, 0x573b4b81, 0xd98ffa6b,
- 0x8fb4d415, 0xb4d7af0d, 0xaadc3b8f, 0xb5742781, 0xf35ffa6b, 0x3ed34841,
- 0xa6877ba9, 0x4e9edafd, 0x77b93c0d, 0x94ffa697, 0x5c0d610b, 0xfa688ec5,
- 0x6a4f98d7, 0x0fd6a9e0, 0xdba7fd35, 0x67da6b4f, 0xb4d73f38, 0x2cd076ab,
- 0x7adad7f7, 0xaf5d1761, 0x7cf359fc, 0x90c3dab0, 0x486f823e, 0xd613b34a,
- 0x3fe102eb, 0x777ce49c, 0x28ed1e9c, 0x8c14182f, 0x41ad2901, 0x420c92fd,
- 0x480ae90c, 0xe2a6358c, 0x20ac4028, 0xc15549b7, 0x4f68c9f3, 0x73aa9000,
- 0x1fa0fcb9, 0xeb5ad813, 0x1bb266a7, 0xdf40971c, 0x29bfc25d, 0xa0944b83,
- 0x85ebaa9f, 0x4ea166f9, 0x726f3a02, 0x582e3cf9, 0xaf9d7dcf, 0x6862cb4f,
- 0x705b0427, 0x9307a01d, 0x9e6f41bb, 0x79776388, 0x378f064b, 0x89780cc3,
- 0x5c48ef98, 0x32cca3ab, 0xcc33fcf4, 0xff7fa967, 0xae3e06b8, 0x8a6bfb04,
- 0xa0a7ff18, 0xfbb065ee, 0x37c0035a, 0x153d8c05, 0x4cfc12b0, 0x5b704ec0,
- 0x7b6549c0, 0x96e54dc0, 0x1ded4280, 0x5f827281, 0x0e087808, 0xdca8ea05,
- 0xfd52f016, 0xc10340f6, 0x547c04af, 0xa62c08ee, 0x9f80b5f2, 0x560677da,
- 0x40f3fc13, 0xc0ceca90, 0x237faa7a, 0x9bf04ad0, 0xdf827681, 0xdca8840a,
- 0xe541d815, 0xb52740ee, 0x22ec0def, 0x9840edf8, 0x30e070e0, 0x5d0207c1,
- 0x7c0c1f04, 0x40a1f040, 0x03879537, 0x0d1e543d, 0xf1fb52f4, 0x078205c0,
- 0x576b4bce, 0x2e576133, 0xd2c07412, 0x2f793db8, 0x85f6523f, 0xbb462d8e,
- 0x43a09177, 0x87983543, 0xcc867740, 0x2ecd6dc2, 0x13a06a3c, 0x71c9d137,
- 0x96af2fb4, 0x4070d04e, 0x33560d7a, 0x5a9bd237, 0xc9e954b6, 0x90ae0cfe,
- 0xbb732f42, 0x336feb88, 0xb537f553, 0x85283e37, 0x079b9ed0, 0xf811b276,
- 0x9f6123e6, 0xe5c7147c, 0xc1bf39f5, 0xa35f768d, 0x66c0af14, 0xb277fe01,
- 0x8c2fe03b, 0x5ed77fa4, 0x9fb456d3, 0xc235f5d4, 0xe7183a38, 0x5a2eecbf,
- 0x6c3b2357, 0xbd40f5c0, 0x72fc0f47, 0xe2dbe6c6, 0x2fbeba02, 0x2234175b,
- 0x85425913, 0x8cc644de, 0x48f3df76, 0xf7fce7e7, 0x17c1c21c, 0x9c429559,
- 0x78537ae7, 0x7f30adf8, 0xb2bd11ef, 0x5e3439cd, 0x00ceb796, 0xf6997de1,
- 0xa0773fb7, 0x17f75f1d, 0xe1cf0fbd, 0x21b12184, 0xe9dd7404, 0x3acf8892,
- 0xd94d3a5d, 0x02fdf766, 0xa26df9d7, 0xa01d4eff, 0x56ebdbf2, 0xb612b2bc,
- 0x20a2b8d4, 0xf055ed19, 0x5f680c0f, 0x034e61cf, 0x989b87ca, 0xea1c5de7,
- 0xf823e666, 0x52a41656, 0xe176f9b6, 0x21636ebe, 0xa6157d82, 0x8afb589c,
- 0x383bd75e, 0x752c70d8, 0xdd90f29a, 0xfbc70077, 0xeb43d136, 0x7a69313a,
- 0x5d4bee21, 0x49c33997, 0xdeb366fd, 0xdf7d7017, 0x53fafbee, 0x9d306f29,
- 0x61f488fc, 0x3fb06981, 0x3779c233, 0x38e0ef03, 0x214b0fcd, 0x3e9573a4,
- 0xa74cc11a, 0x7a851ff1, 0x805e9229, 0x4b7fd04e, 0x9399cdeb, 0x4dd2f448,
- 0x3e926ff2, 0xfa7b0468, 0x28542e84, 0x8c4e89e9, 0x5173ac12, 0xee49d01a,
- 0xc0f0f4d0, 0xe423287a, 0x17d9d020, 0xfe9fde38, 0xe2371ae1, 0x93dbf96d,
- 0x66b7889c, 0xd0079c1d, 0x9ea8f073, 0x442604ec, 0xd2dafebb, 0xb207f910,
- 0xc529cca2, 0x7172e373, 0x7ead9ebf, 0x4ddc863d, 0x74f4e5c8, 0x0ba86ec2,
- 0xef9cb8d1, 0x2e7d76d5, 0x2e7d473f, 0x15a6df3f, 0xc3d52d9f, 0xf81c4ffa,
- 0x8d2ce8dc, 0x3fd58fb1, 0x823f2879, 0x3aef97ae, 0x7e83cd3d, 0xb92eeb17,
- 0xbea07131, 0xd2abcc50, 0xe898de91, 0x5c896adb, 0xc75d3f57, 0xa75d22e7,
- 0x11e75d00, 0x768a7f5d, 0x33936cf9, 0xbb2856f9, 0x28613501, 0xc95a2f7d,
- 0x14c05c7f, 0x2f32172a, 0x0c808b95, 0xc1bd8e90, 0xf7888d27, 0xd52758fb,
- 0x777e503f, 0xbdf5d23a, 0xd9f91f3a, 0xd517594b, 0xb5bd672f, 0xaf37b478,
- 0x1daef35f, 0xeb537d56, 0x44915393, 0x7fcd0c6f, 0xdb39cb17, 0x4e834fa5,
- 0x5cec93e2, 0xe4b747c0, 0xe613227f, 0xd5677dbf, 0x3f505913, 0x85cfcf5b,
- 0xa2e7e31d, 0x7de891ca, 0xe0145f03, 0x78a6dff3, 0xa4fa5f68, 0x345f0d3a,
- 0x123cce3e, 0xcfbbd38c, 0x8ae6da14, 0xfbf293e0, 0xf28590ff, 0x13bdee4c,
- 0xdbf97bcf, 0xef3c54a6, 0xfbd718fb, 0xaf8d4792, 0x119efaa8, 0xe2cfdfbd,
- 0x85f7ec15, 0xb22fefa0, 0x17f7d119, 0x658a3812, 0xcb287603, 0xf2cbd9f1,
- 0x72f6f406, 0x88d1cedd, 0x95ebd027, 0x7df70e78, 0xd632d9dc, 0x9420fa85,
- 0xe1887683, 0xecd29335, 0x7617e8d2, 0x8d850129, 0x7f3e219f, 0x198ee38a,
- 0xfca92ebc, 0xeed19fd0, 0xd0591930, 0xce7c465c, 0x677f2226, 0x9abf891a,
- 0x3879b511, 0xb7e9d78f, 0x84ff1e0c, 0xefe1ef58, 0x841d3fb8, 0xc52cbcfd,
- 0x2feb879a, 0x3cc0fc53, 0x19d24724, 0x2e4773cd, 0x3e7563e7, 0xa076e966,
- 0xc1347e9d, 0x8f9e3b77, 0xfd52471a, 0xcfaec3c8, 0x667cf1f2, 0xe5506c57,
- 0xaec78d33, 0x84e972e3, 0xf84419c1, 0x014b9544, 0x6f2fd609, 0xa7ff286f,
- 0x371d700f, 0x8c612d98, 0xc34ab077, 0x35ff7ed9, 0xdf1f4077, 0xcae3eaa0,
- 0x1a8ef8a8, 0x018a61f7, 0x3ecc57d7, 0xf141f152, 0x0e4e551d, 0xb1b0bfd2,
- 0x889fc42e, 0x79c7f597, 0xce3fb9fe, 0x8d79c3a3, 0xe6328e42, 0xf8237b77,
- 0xae00d6d4, 0x307fc68b, 0xff8d7cb3, 0xd9c0d560, 0xffa6bb7e, 0x4d4ed588,
- 0xd6e82bbb, 0x57ade7b4, 0x6b417034, 0x517fa6b9, 0x170347bb, 0xfd34ea87,
- 0x6af0ed47, 0x06ced2e0, 0xbb31ff4d, 0xb1f69a7c, 0xf69ac5e1, 0x1afd8771,
- 0x6ad74278, 0x3e6bff4d, 0x27da6a08, 0xb4d7af75, 0xaad3db5f, 0xb6f72781,
- 0xb94ffa6b, 0x57b4d210, 0xb4d5bfb1, 0xd75f98d7, 0xf1c62fc0, 0xeb54e778,
- 0x9b9e683f, 0x81afdf6e, 0xf1e7885f, 0x23ce199a, 0xf9c5e7da, 0x278b6f06,
- 0x3ee5987e, 0xffdf69a9, 0x8dcdc8c8, 0x47a12fc0, 0xb67fe474, 0xc53d71d5,
- 0x1d39aa1a, 0xd7bef1c4, 0xe66a1f2b, 0xbaf7d1cb, 0x7a9d8e90, 0x75f2266b,
- 0x039cf97e, 0xd0ac7640, 0xc51aa2b3, 0xc9eebb9d, 0xf48e5803, 0x6c8d5ebe,
- 0xf270d253, 0x7da39600, 0x1903575f, 0xca716533, 0xf996583b, 0x70d8d6c7,
- 0xbce7ab89, 0xe0c4e583, 0xb3941a8a, 0xb17e2660, 0x3e7dd608, 0x846d9238,
- 0xaa652575, 0xd10f5e71, 0x1d0caaed, 0xdbaaf9f1, 0x4b37142c, 0xa322d6bf,
- 0xe81cdf3e, 0xec10791a, 0xd3a7f4dc, 0x69dc62d7, 0xa1f9d83d, 0xc017b022,
- 0x59f2c7ee, 0xe043ebb0, 0xbb046d1c, 0x604dcb1f, 0x73fd63f7, 0x9c23f760,
- 0x7ad974fe, 0xc9d56e7c, 0x6172ea7b, 0xca0f11fc, 0xd7533456, 0x0e2b7539,
- 0x0fec7ac0, 0x4b28ad1a, 0xe267ae8c, 0xec8eb09c, 0x0a8eb065, 0x51078b42,
- 0x3052ecfd, 0x1c39321c, 0x2becfd07, 0x1db81a74, 0x2eb045ff, 0x97cf8b58,
- 0xaedee93e, 0xb6f9f630, 0x8a1937b3, 0x5d799f61, 0x014d6db7, 0xe6799738,
- 0xf1d3be02, 0x93fc602c, 0x09cd8f79, 0x97860c96, 0x48ff7a14, 0x2cee4972,
- 0x16b53e46, 0xeb81947d, 0x85fd50da, 0x3ce2b3a2, 0x0839cc8f, 0x787e7eeb,
- 0x23e758bc, 0xaff2aa73, 0x79cf5c66, 0xef50ef94, 0x47218cef, 0xffe853fe,
- 0x2f5c7993, 0xe5159fc3, 0x08938d93, 0x949d81b3, 0xf376f20c, 0xd1a7d5a4,
- 0x41ad90a7, 0xbb23e509, 0x144fcf08, 0x7823c828, 0x1e44fc4a, 0x537947b2,
- 0xe733e454, 0x1f3678c1, 0xf1914ed8, 0x785ac5b1, 0x19e79c33, 0x0c7ac0c3,
- 0x3282e977, 0x92f0c1ec, 0x9e605157, 0x5fb0798e, 0xb51b3780, 0x8e9165fe,
- 0x9f717d91, 0x378beeba, 0xdda76829, 0xf0f5c797, 0xecbb8096, 0x7ffa0313,
- 0x4027d94a, 0xfd8b9947, 0xabe40f92, 0x04abd1ad, 0xd2e19fa1, 0x2237efdf,
- 0x3ac5df61, 0xfd639f51, 0x27bb089a, 0xb86b8c47, 0x19bc27a4, 0x6a4abd9a,
- 0xbd06fcc4, 0x618cefe4, 0xc9e69577, 0x4666b9fc, 0x1e7786ed, 0x5f309c96,
- 0xba486366, 0x4bf1c687, 0xc2dbd40a, 0xb1ab3ebc, 0xf0085a53, 0x3a4e791d,
- 0xac9c7507, 0x08feb0c5, 0xa0e5d93c, 0xede78564, 0xc425068f, 0x55eadd83,
- 0xdae22258, 0x52bdfc4b, 0xf57db4f0, 0x864fb2c4, 0x8abdbae1, 0xa59be717,
- 0xcadf9bf2, 0x2b1f3d70, 0xbd42a9bf, 0xc33d1bf6, 0x9c6f8cfb, 0x8c5a724a,
- 0xa9a5a87d, 0x973ccf5b, 0x729267f1, 0x9e93f11e, 0x2ce2ddbc, 0xf17dfe00,
- 0xd6c34b36, 0x47767418, 0x75b3a71e, 0xe2deaa99, 0x73d749eb, 0xeafaa93c,
- 0x1fa72b1b, 0x4cad6e55, 0xce3ab0e1, 0x24f1ecca, 0x8f5a8637, 0xf98e3dad,
- 0x19bbd622, 0xfde2b1e6, 0xac2b77cc, 0x21f03788, 0xcc9f34bc, 0xe7d6e9e5,
- 0x4637e4dd, 0x3e20cfd3, 0x5c9bd100, 0x1dd97486, 0x31ba066a, 0x682a33cd,
- 0x5bfeda2f, 0x2472848b, 0x284ab593, 0xb5d96d47, 0xe7d46587, 0x1bd8afb2,
- 0x12be8ec3, 0xa9e7a83f, 0xcf8325da, 0x2abbf9cf, 0x0c0d43b2, 0xe5c9b6e9,
- 0xa9f9e1b4, 0x6474da74, 0xe22faa78, 0x3a0bd73c, 0x7aad672e, 0xd60ad3e4,
- 0xeb256549, 0xd63af2a2, 0x5987a54b, 0x99ab2c65, 0xf32d6542, 0xf98d3952,
- 0xad63aca9, 0x9d64ce54, 0x2eb3d654, 0xa3bfc12a, 0xe4accbd2, 0x7608de87,
- 0x9973960c, 0x985bca97, 0x482dca9f, 0xfef013df, 0xdbe095a1, 0xbb952759,
- 0x459dff80, 0x53311f18, 0x39e417b9, 0x3c836f96, 0xf20c32c7, 0xf8c269dc,
- 0x83ca9b88, 0x43ca8501, 0x0f2a7281, 0xefd43c07, 0xca8ea068, 0x952f01e3,
- 0x540d0227, 0xd47c0576, 0x316054ef, 0xfc05ef95, 0x581fbe54, 0x8107e54d,
- 0x12ff9520, 0x91654f58, 0xe20ae411, 0x163ddddb, 0x8f9c9afd, 0xe8271e8d,
- 0x84f34fa3, 0xfdd1ebff, 0x78f1e2f7, 0x83ba3a8e, 0x94aed5b1, 0x6e6d1e90,
- 0xe504279d, 0x74937746, 0x4eeb9437, 0x64d63b70, 0xd93b244b, 0x724abed6,
- 0xa4bbb8c2, 0x9c027d6e, 0x0fbcdeed, 0x4f4198e7, 0x6b65ed54, 0x7f841413,
- 0xe819a4ff, 0xdfc1ab70, 0x7fda15bb, 0xcebfd2f5, 0xaece8331, 0xc7f53c48,
- 0xed4c38d7, 0x66b20e93, 0xf207c02b, 0x26993f4e, 0x10a075f1, 0xc7d2fe3e,
- 0xe3e4d673, 0x791cb93a, 0x368e05d5, 0x5b0f19fa, 0xdb18cfc8, 0x0eac667e,
- 0x2dab49e0, 0x471fe865, 0xf5b8a3f4, 0xdba2fd50, 0x563ae7d5, 0x1e2337a4,
- 0xee0a7dd6, 0x65e51389, 0xcf8c58f7, 0xbbab8e45, 0xfe99f9ba, 0xf647f332,
- 0x5e332e93, 0x54e79151, 0x7403ffde, 0x86df4d1e, 0xaebf1f4b, 0x3598f8a3,
- 0xf6faf515, 0x7a772e14, 0xdb43e3b3, 0x53dbdd60, 0x9f21bc05, 0x610eb5f6,
- 0x8dbad7d8, 0x6fc764b9, 0x1d36f38f, 0xd1bff6c1, 0x69a0db29, 0x636fbc7b,
- 0x14f9c131, 0xea9759af, 0xca5ea377, 0xb1fae049, 0x9c48f1cd, 0xffff8233,
- 0xe6eee422, 0xadaebeca, 0xd7ad4fe8, 0x6e7802b1, 0x1b05fadb, 0x4bce30dc,
- 0x022ec09b, 0xc2f27938, 0x9ed0050d, 0x513741bb, 0xae1e642f, 0x0b4da5e3,
- 0xe128d95f, 0x0b5323b8, 0x213cdc61, 0x7586733f, 0x74095d8f, 0xc6d466de,
- 0x63f5fa15, 0x8597e73e, 0xd019cc30, 0x5e2239bf, 0x1ac0d5b1, 0x4166f522,
- 0x35b7973e, 0x4c34bc45, 0xd33cf1e1, 0xe3d0f888, 0x11aaffb0, 0xbe93fe3c,
- 0x9ff14cd6, 0x9e7fc774, 0xe9ed0e9c, 0x4d053a1d, 0x74b6d95a, 0x9efd018d,
- 0xf22758db, 0x3f8956e3, 0x76e6cc1f, 0xb92c1832, 0x1efc2273, 0xf2ca37b0,
- 0xf6a7e223, 0x7184a086, 0x4b11aa8c, 0xa7378c25, 0x3093ee3b, 0xe0de91fe,
- 0xe8897c93, 0xfda9f927, 0x2b9f22ae, 0x6f67d61f, 0xf735e784, 0x3c0cbeb1,
- 0x81b79857, 0x566409f2, 0xecdf3916, 0x27878e22, 0xb43d2064, 0x691ad7df,
- 0x9af8d15d, 0x991eaee5, 0x1ce07c3f, 0xccbfdba3, 0xfdb8e7e7, 0xf9029871,
- 0x1f8f1260, 0x9339789c, 0x6dd9e5ec, 0x23f41ef1, 0xb2393c4f, 0x2aa7e096,
- 0x9eff683c, 0x1a62b978, 0x9a9fb396, 0x484efd49, 0x05c630ec, 0xbb753f66,
- 0x7939f58c, 0xef1c2eb0, 0x71e891b4, 0x89f753f6, 0xc5a91fe7, 0xf05d72f6,
- 0x2e9fd0ef, 0x012d7e6f, 0x891505e3, 0x7961646f, 0x6abdd742, 0x837fcc3f,
- 0xd51afd95, 0xda4377b5, 0x3fc1d4df, 0x6b993ce6, 0x378c78c0, 0xf3ce973f,
- 0xf031e626, 0xf92f077c, 0xba3b95b7, 0x8e8b01de, 0x5bd9d75d, 0x9ebad783,
- 0x5883d65d, 0x34158756, 0x61ed59a3, 0xa72c41ef, 0xd16bf975, 0xa0fba9bc,
- 0xdd9620f5, 0xc45e7d23, 0xedffabff, 0x055e3796, 0xab63c478, 0xe68768ac,
- 0x633dde3f, 0x0d2fc51b, 0x60a1f90c, 0x8f55bf92, 0xa6f66c04, 0xf6787ca2,
- 0xfa875919, 0x8d6ae4dd, 0x4f74d843, 0x4ce30eae, 0x175a53db, 0xe20bbed3,
- 0x28f1e219, 0x8ba421e8, 0x2a6f1482, 0x25f013f2, 0x829dc39d, 0x7e294d3e,
- 0x8bd60a6b, 0x7efe8e7b, 0xd85e1cf1, 0x4e35afdf, 0xa55279a2, 0x08cdc4a0,
- 0x42ec23b4, 0x7f33b79f, 0x96c3e206, 0xf18adfe8, 0xce2a82ad, 0xd3912cff,
- 0x996f7605, 0x10508f48, 0x3fd5bd3e, 0xe6c1cf0b, 0xe01bcfeb, 0xb06a0774,
- 0x25c93edf, 0x367fee98, 0x39061c4b, 0x3fc2eb43, 0x5ba4e78c, 0x51cec9d2,
- 0x806b6fd7, 0x0eec22f1, 0x968dc7dc, 0xba54e781, 0xf5f620db, 0xe60b2884,
- 0xf5d4f1f3, 0x7ae7cc6e, 0xd4edd61d, 0x62f47ae1, 0x5d0fb03d, 0xfa227ac4,
- 0xd7fafed1, 0xd23b14cd, 0x897e6305, 0x4729cc97, 0xcea17fee, 0xd71a3713,
- 0x615fd6ff, 0xe509295c, 0x67f3ac08, 0x919927fb, 0xf1f7a34f, 0xfb88be42,
- 0xfe8cbd80, 0xe71f4cc3, 0xbf46e6df, 0x0d94fe84, 0x43bfdc61, 0xd45c60f6,
- 0x0c926966, 0x39b5fb11, 0xd99e9eb8, 0x728fdfe8, 0x82796665, 0x8b3df482,
- 0x72b5ae75, 0x0f983efe, 0xfd622beb, 0x7136167f, 0xfe7c4ec0, 0xe24ef799,
- 0x67583a91, 0xcfea3155, 0xbca5eec7, 0xcc8fcd89, 0xcfeb8c3c, 0x3fb93f74,
- 0x7ef40615, 0x3e7dce2d, 0x77656f8f, 0x87bc9ac8, 0xc9acbf2c, 0xac58c88b,
- 0xd07a076d, 0xd95d2ac0, 0xa829d5a5, 0x2509746f, 0x9da06733, 0xf923a492,
- 0x9a4a720e, 0x8d1ed31b, 0x7f812ba2, 0xcdde7cf5, 0xb373a7cf, 0xb039f859,
- 0x737cc55e, 0x7aacd8a2, 0x336f304e, 0xd03279b0, 0x3ead737d, 0x8f1fa124,
- 0xb232f1fd, 0x26f70d97, 0xada73e0e, 0x19cce706, 0xd41fa728, 0x2aaf2959,
- 0x67a0af0a, 0x94fc99fe, 0x1da8d307, 0xc53365ea, 0xabd6233d, 0xcf6b058f,
- 0x3bfd4ae3, 0x0cce7858, 0x4cfae0d7, 0xa899dcc7, 0x32973367, 0xf6e8ff3a,
- 0xe7b547a2, 0x78ef7e4a, 0x50b1a38c, 0xe79c07f8, 0x5af6c74c, 0xcfa3efb4,
- 0x9cbba555, 0xc2f5b161, 0x2f5c0523, 0xa72824e4, 0x90aec8ea, 0x66f04ec9,
- 0xfd23c3cb, 0xb9f2efa4, 0x57e5301f, 0xec43d216, 0x1f087363, 0x3f5dc255,
- 0xa8738629, 0xfba1d3ee, 0x7e3ddec2, 0x5099e9e0, 0x7bf5fd4e, 0xdfa0c74d,
- 0xe32cefd4, 0xeb377eb0, 0xa081819e, 0xf90361e0, 0x7cbe6b8d, 0x440315a5,
- 0x414c8dcd, 0xe3ceabbd, 0x6efae028, 0x25e4218f, 0xb32c5af9, 0xd907246d,
- 0xf4114bc5, 0xe89e9002, 0x6f31b787, 0x91f92b63, 0x8612fcb6, 0xaccd3c79,
- 0x97d20ef3, 0xe30c8d67, 0x383637af, 0xffb0550d, 0x869d1b1b, 0x219f78f9,
- 0x23b43ab3, 0xa8506a6e, 0x8546a6fe, 0xfd799bd7, 0xd50f06dc, 0xf0f46dcf,
- 0x5bd40b7a, 0xd4290f30, 0x6f718015, 0x753aa4b6, 0xe8d01f78, 0x4c17ede5,
- 0xfc1c7ed4, 0x8c27cc01, 0xbc910b8f, 0xf1d1ed6f, 0x7c7f237b, 0x9ab58248,
- 0x3b0ecb12, 0xe8f77f11, 0xcc175014, 0x2b332d94, 0x7836cfc0, 0x7f687a43,
- 0x1032858e, 0x3617bb91, 0x7ea10b79, 0xe2b643b7, 0x7b8376fe, 0xc147f98b,
- 0x9de132a5, 0xbdde00fe, 0x3af741d8, 0x3efc455b, 0xf14cc4b8, 0x2875b066,
- 0x6496ccde, 0xb7863b0a, 0x86b02c77, 0x39031ed0, 0x7bd8e748, 0x00764c8f,
- 0x6ea3c3c8, 0xe6768bb4, 0xca9f182b, 0xb7e5aa5c, 0xaa0b85f4, 0x6646bc68,
- 0xbebd3f45, 0xbcd78f91, 0xa1d21753, 0x71b9655d, 0xf341d226, 0x3fa0a60e,
- 0x53c2ecfb, 0xee10c3b5, 0x3f2e1450, 0x79a172b4, 0x9c4753e1, 0xcebf1fb8,
- 0x79fd405a, 0x5fd9af1c, 0x0d2f5dbd, 0xb79d33f0, 0x0c7e4073, 0x61ca3796,
- 0x5e63271c, 0xc1f182b5, 0xc627d874, 0xbc8c3bf3, 0x4ca7783e, 0x0be92df7,
- 0xf475b0e5, 0x0b677f00, 0x1f23a614, 0xd17c9126, 0x9dc8d7f0, 0xc179f85a,
- 0x32efc0a7, 0x9db82bee, 0xd1673e51, 0x903f6d76, 0x57943a93, 0xfadaedd9,
- 0xe3fa8b5b, 0x443c1a02, 0xe7e6d9e3, 0x9f7a2f72, 0xc70afb03, 0x74bed115,
- 0xd7285f7c, 0x72d8bea0, 0x1b8bea80, 0x44e9c565, 0x0a79d779, 0x53b45ff7,
- 0xeb806166, 0x44cd9617, 0xa4dfaa7a, 0xf5c8f0a3, 0xc2e48bac, 0xc6adf695,
- 0x19f7a23b, 0xf2efbfbd, 0xa88e5cf5, 0x6613e0f6, 0x1edb07b2, 0x9ef0e8b6,
- 0x78adec15, 0x55dc2b8c, 0x402c1d54, 0x1dc8407b, 0x973d25c3, 0xa216cd27,
- 0x51ed8353, 0xa1fc6477, 0x13f55465, 0xd86fd405, 0x6e3c758d, 0x968efb41,
- 0xe3173f63, 0xe6d6ea4d, 0x13db5de3, 0xa63f951f, 0x729bc7cd, 0x7f2a3321,
- 0x7f2a2f2c, 0x7da6946c, 0x545c75aa, 0x51b5d8fe, 0x1a3563f9, 0x967b9678,
- 0xcaf5ffa6, 0x86f81a4d, 0xfd343bf2, 0xd6ee78e7, 0x7754dfb4, 0x66fda6bf,
- 0x7c0d4aef, 0x6b5fc36b, 0x6be6dffa, 0xb1dfb4d6, 0xf69a27f8, 0x2d49ff68,
- 0xf9701577, 0x3feed9be, 0xd06c0149, 0x3df791f7, 0x28de996a, 0x7b9e46f7,
- 0xa7b70252, 0xb9fdfba2, 0x8bfbd380, 0x058f9f12, 0x1c789aed, 0xf135d8f3,
- 0x854570ba, 0x71c61bb9, 0x21df951a, 0x0ee262dd, 0x6bb6bfbf, 0x3ff6d9ee,
- 0xbc60fd0e, 0x1b5cc4a6, 0xff8c3bea, 0x37b940fa, 0x5f747487, 0x4abf5b61,
- 0x69b83d22, 0x5cab8f15, 0xaf3c5230, 0x8eac1d7f, 0xdc46fbc6, 0xeceba96b,
- 0x2da47110, 0x85424718, 0xfd4199e4, 0x7ef1c656, 0xe3574d3f, 0x371a3e8e,
- 0xa418dca3, 0x7e85bcfc, 0xcdc0e309, 0x7bc5663e, 0x02cb7493, 0x069bff9a,
- 0x265d9925, 0xb016da2e, 0x67cc0f33, 0x635c155f, 0x527dbd84, 0xb3d4f7d0,
- 0xcfddbcf0, 0x5bd31e28, 0x1853edf0, 0xe143e98f, 0x219d7408, 0xf73f3c73,
- 0x5fcfeec0, 0xe6daf981, 0x5ca197a5, 0x5acf6e8d, 0x43ebf7be, 0x6e7f6997,
- 0xde1f5bd9, 0x1fe7b97b, 0x25ba75d8, 0x38c87da2, 0xf3264369, 0xe001d044,
- 0x80fde62c, 0xf9f5c85c, 0xc5230af2, 0xfc01aeb1, 0xbfbe0215, 0x89cff8aa,
- 0x3fb9e03b, 0x44eefb39, 0x65ea1d3b, 0x847e87ac, 0x9fe53fd7, 0x9c92fca3,
- 0xa3df6051, 0x9b171dfd, 0x7215c76e, 0x8d6d95ba, 0x6a0718bd, 0xd13a344a,
- 0xbb32cfcf, 0x07193eca, 0x7ee06d74, 0xfeffb475, 0xddbfbf5c, 0x9177fe49,
- 0x944b2718, 0x9e7f2b7a, 0x4e4c8399, 0x3114f717, 0x6a4fa1f0, 0x655e5097,
- 0x8d3f942e, 0x89fd8be4, 0xa4238a46, 0xc1dc445b, 0x171358b2, 0xfb06e350,
- 0x9095ef13, 0x4bc3d3ee, 0xf18f9e28, 0x5c6f1c02, 0x11d693a1, 0x32c82f1d,
- 0x86bad3e7, 0xd7f59f1e, 0xe6314827, 0x1a875a89, 0x279e889f, 0xea04f684,
- 0x64f16599, 0x7bef444f, 0x79556149, 0xd7e470e1, 0x51d393de, 0x90329f7e,
- 0x5e8a1c3e, 0x143ccf30, 0x42b4fe31, 0xfe63dfee, 0xe63d6478, 0xe3228787,
- 0xef41ccd9, 0x2a0c102b, 0x7bb18466, 0x77ce1143, 0xc277cf94, 0x1ec9d8a0,
- 0xfe87b504, 0xd7217d5f, 0x9730d303, 0x19f2386d, 0x81dbcbf7, 0x12dcb1af,
- 0xd67d92b0, 0xf087fc01, 0x9527010b, 0xca9b80a1, 0xda85016d, 0x09ca07b7,
- 0x21e0257e, 0x8ea04778, 0x5e02d7ca, 0x6819dfaa, 0x01e7f820, 0x819d951f,
- 0x46ff54c5, 0x9bf04fc0, 0xbf04d581, 0x0160f685, 0x53d7a9c6, 0x4ad03bb9,
- 0xed037bed, 0x081dbf04, 0xec0e1951, 0x8103faa0, 0x060f824e, 0x287c1176,
- 0x70f82610, 0x479530e0, 0x7f545d03, 0xc101f03c, 0xc93ee337, 0x15df58ae,
- 0x4f8578c0, 0xf77da276, 0x15a16fac, 0x7cfb6bed, 0x79c5159d, 0x04b74fbb,
- 0x8d1d1ce3, 0xef131efc, 0x040e3123, 0xed086876, 0x67fcfb39, 0xf6a54c8e,
- 0x19bed4b9, 0xc4a70487, 0xafdb82b6, 0xfa91996c, 0x0a2130d9, 0xda58eb9e,
- 0xdc03d218, 0xed4f185a, 0xf93215b6, 0xfce9cf6d, 0xeedc8529, 0x336df922,
- 0xa541fb70, 0x5c853583, 0xe429aede, 0x161f5cf7, 0xca4a73f1, 0x9e47ad8b,
- 0xa6ed542d, 0x7f7187f5, 0x3fb079f6, 0x55bcef5c, 0xb597bc66, 0x72b3a3dd,
- 0xcbdf937b, 0xb8bf603a, 0xc50f587e, 0x6e7cd985, 0xade6db2f, 0xe63975a5,
- 0xd6ed48df, 0xd05347a2, 0xaff76f4f, 0x6deb439a, 0xd9ae2994, 0x82903bee,
- 0x89cf6cf7, 0xf0db277c, 0x64a86f78, 0x8d9e7af0, 0xe3077f5a, 0xec03837e,
- 0xec63d7a5, 0x496ed303, 0xc71130cf, 0x331cd47b, 0xe829d78e, 0xfe7121d7,
- 0xc4ca0f63, 0xb0302f7f, 0x2db9e0fb, 0x5105df60, 0xb6bf540e, 0xbd55e302,
- 0x289dbe85, 0x8e779f37, 0x9c03203f, 0xcfc7c75a, 0x82bf255d, 0xf79c3476,
- 0xbf502de7, 0x5e4dbee1, 0x4db0ea5c, 0x6ec835ce, 0xcadff3ed, 0x4397f8c0,
- 0x5a8f9ed2, 0xf9f62dbe, 0xb78f8782, 0xf14c9565, 0x378adb64, 0xbcf9075d,
- 0x33ff91bb, 0xc38a3e8b, 0x5cde4c30, 0x86450ea7, 0x35fc9e63, 0xff7717ce,
- 0xcd423aa6, 0xdf3a8f26, 0x6aef9c58, 0xb1e234f1, 0xc62f9b5a, 0x279286ba,
- 0xbf239257, 0x81ef1429, 0x942cb164, 0xb819cf23, 0xe49e0adc, 0x052524f6,
- 0x8f3c1a4d, 0xe6a02f9a, 0x0be7440f, 0x29e05efc, 0xde62c4cb, 0x4fd67ee7,
- 0xd73a41bf, 0xbd1b3c17, 0x92e36794, 0x35874931, 0x7a12d819, 0xde2aa7ef,
- 0x3d0626ba, 0x2853e5a8, 0x1fc100c7, 0x2e713216, 0x38f8ea9b, 0x64ce3e3a,
- 0x2ae082b6, 0x4318358b, 0x33e5ab5e, 0x2b7f9c62, 0x759b74e4, 0x870dcedf,
- 0x1a8f7cf0, 0x8b6a3728, 0xfd01b42e, 0x3d09e084, 0x7d4cd7c9, 0x2257d6e7,
- 0x4117f5d6, 0xa18c5b9f, 0x6e87bc62, 0x504af187, 0x94bf22ae, 0xd582fc50,
- 0x7d5de047, 0x1d843fee, 0x75c5fcf0, 0x3cff7429, 0xda1c6d6f, 0x4ccced47,
- 0xf83360f4, 0xd046c653, 0x32e90d83, 0x8b387d06, 0xfc0e348c, 0xe226aa59,
- 0xcbd70cbd, 0x60972835, 0x2616fbdd, 0x99ac3e91, 0x31acdeff, 0xc9f65700,
- 0x65b2cf94, 0x9cd3cf29, 0xca3aeff4, 0x31fb7913, 0xf75df7ee, 0x9fbd2d50,
- 0x67ca2194, 0xb283cfd1, 0xc2533d72, 0x0b952e70, 0x99bf142d, 0x133e417c,
- 0x4851a7e9, 0x17fa3c7a, 0x6d735e3c, 0x0f79acaf, 0xb68f526d, 0x8f54603f,
- 0xb7464676, 0xef3edeb6, 0x6153d3cd, 0xfca5f69e, 0xbf8bf6e1, 0x7070823b,
- 0x24e28e95, 0x5064fbea, 0x4df14193, 0xf9819839, 0x8ccc1b9b, 0xbe6db9e4,
- 0x60f28ad9, 0xc93c7a7f, 0x2cdbf6bf, 0xcbae8764, 0x3b438a6f, 0x556f34d9,
- 0x8c23960a, 0x3b18adc1, 0x2dd5e6bd, 0x9127d937, 0x55f355bc, 0xec1cac82,
- 0xdc8dbb81, 0xf73e09c8, 0xe51954f4, 0x9967cf25, 0xa796eaf4, 0xadd8f983,
- 0xd4e1d695, 0xf9be4cb1, 0xba76f87e, 0xbeb896b7, 0x1da11a70, 0x7ca379e0,
- 0x7b4115d7, 0x3f705a46, 0x9cb66d36, 0x6b7ca469, 0xf982324c, 0xccfd0b0d,
- 0x658df588, 0x573e48e6, 0xf2fbe4f9, 0x87c63c7f, 0x0e595f87, 0x2bdc695c,
- 0x3e417bf1, 0xfca19be7, 0xf210d369, 0x1f8ff554, 0x8bfce029, 0xf57a4b6c,
- 0x7da6318c, 0xce22abf5, 0x9e46e567, 0x61bb32a7, 0xc3dd1d5a, 0xcc65bb04,
- 0xdc517be7, 0x27a7b50b, 0x7b713dd2, 0xbde30b2e, 0x8e817041, 0xf8d27bc7,
- 0xb98ded7f, 0x936a1f14, 0x3cc129fc, 0xb9f097cc, 0x01dafcf0, 0x7f308947,
- 0xeb970e5b, 0xe2b7e42c, 0xb38c357d, 0xe0fd7238, 0x74b505ef, 0xa61ec8cc,
- 0x789e85f8, 0x888c69cf, 0x1c5c63b7, 0xcfd117e3, 0xc2d5ee4d, 0xe1682e53,
- 0xc0d0662a, 0x3c2d6635, 0x3785aad5, 0x7d3b7115, 0x3f5b5dba, 0x1d85a9c3,
- 0x74e307d9, 0xc2dfcf3c, 0xf049e222, 0x447e5ef7, 0x68dd681c, 0x765f3efe,
- 0xcb8a52f7, 0x78f0e5b6, 0x3695638f, 0x42c591ce, 0x732fe212, 0xd63c5469,
- 0x863f66bd, 0xa30bed97, 0x5efc41e3, 0xa9a1f002, 0x7c8a3147, 0x9e68eaf0,
- 0xd23dde87, 0xce08bdb7, 0x5f0c60b3, 0x4d1dabc7, 0xdac53f74, 0x5caf88d3,
- 0xb0695f22, 0xe88a7cbe, 0xf90f1d40, 0x7fb11822, 0xf84887e4, 0x37be51a1,
- 0x8be41e70, 0x2cfea460, 0xfbd036e9, 0xa1be62ab, 0xcfe543f8, 0xa28f7172,
- 0x89f4dde6, 0x9bbcd4b1, 0x705f2255, 0x4ebe5457, 0x1936a39f, 0xaebee7fd,
- 0xf8b1f195, 0x682ef910, 0xe5887ce2, 0x837f9106, 0xe22c187c, 0xa6f5887c,
- 0x637856ef, 0x050b8bd9, 0x63bfdc5d, 0x224f86c9, 0x73acb7f6, 0xbe5e0685,
- 0x910de1eb, 0xe3f751f9, 0xbf08303f, 0xed7e519e, 0x2f9db152, 0x2bcbff4f,
- 0x48cd0ccd, 0xcf2807df, 0x319c1596, 0x5ea77bf2, 0x42eb9e23, 0xcc99ff61,
- 0x2fd1f2b3, 0xf2e211db, 0x37889d6c, 0x33155b34, 0x3b9981c6, 0x50c71355,
- 0x4b4d11e3, 0xd854b65c, 0x7c7f7247, 0x7ca56bc1, 0x14f9e1dc, 0xf1aa48df,
- 0x32c6cedc, 0x9c6453d6, 0xdd62066b, 0xc056c18e, 0xd957f9e9, 0xc0c74133,
- 0xf8174dbe, 0xb0fdc97b, 0x8f2467ec, 0xea68e42e, 0xa39c44db, 0x0b2dbf9f,
- 0x8b3e70aa, 0xb0fb49db, 0x1e1aff31, 0xd1c6d417, 0xe73de24c, 0x343be3c1,
- 0x7e226df5, 0xb5f1e572, 0x85d33971, 0x2fc621bc, 0x1adf1a8c, 0x7181fc73,
- 0xabbdf1b5, 0x714f37b8, 0x2e3a184f, 0xe9cdd236, 0xdfdd9d69, 0x83317185,
- 0x06667fe0, 0xf288993a, 0xe3e9ff80, 0xc1ae7e79, 0x198f8da1, 0xfa0baf30,
- 0x98b8973f, 0x3efa8ae4, 0x0599fdb5, 0x27cbca12, 0xa4e8fdf0, 0x5a24f2c1,
- 0xde44d88e, 0x811cb47c, 0xd37034f9, 0x36cf5cc3, 0xe50f8a4b, 0xfe7ef473,
- 0x7587f17f, 0xc8bbe389, 0x778eceae, 0x0f632e9a, 0x638205b7, 0xf175b9f1,
- 0x0778c5fe, 0x918ef77e, 0xe3944f69, 0xf88ceb7b, 0x298ec56c, 0xb60f3173,
- 0x13ebf04d, 0xa7a23a69, 0xb7d3dbf4, 0x29e823ea, 0xa173e8dd, 0x13ae9c3d,
- 0x87f85ff9, 0xd227b471, 0x318c6db7, 0xa9d76abf, 0xd601adb0, 0x6d8e7111,
- 0x9fee9ec2, 0xadcc8eef, 0xd27188fa, 0x34b1be4d, 0xa3fe7f5f, 0x87e5af98,
- 0xc459b7cd, 0x6cf9d4c3, 0x67f76a77, 0x7f69fa33, 0xd487a136, 0xfee336f9,
- 0x15d5f062, 0x75fe13e7, 0x69777cff, 0xf93367f7, 0xf5367f69, 0x7cea1b3b,
- 0x3e6c3f2d, 0x76cfe0bb, 0x3d97def1, 0x64377f9e, 0x9a23f7a8, 0xbdccf3fb,
- 0xed2f9466, 0xe850bc6a, 0xfa5173bb, 0x3be849ae, 0x6973f9f5, 0x3dff14b9,
- 0x7326f877, 0xfa873d2c, 0x933b098d, 0x09933b09, 0xd9e1133b, 0x0d57a735,
- 0xbbfc7a07, 0x95cf371d, 0xbecfaf41, 0x1cf8f4ff, 0xf1d9df80, 0xe832b98b,
- 0x9eafd9a9, 0x1e0b337e, 0xfbdbfe29, 0xe9f4fc38, 0x5bb4073e, 0xadcccf82,
- 0x18693805, 0xbaeacfd7, 0xb97779d5, 0x7cb95db9, 0x6f8f1e75, 0x3d459c82,
- 0x67e39cd6, 0xcafc7f18, 0x1f349bd1, 0xeecf2ffa, 0x03105f4d, 0x7cb96a2f,
- 0x1e7f2175, 0x9889c0ad, 0xaf48c6cf, 0xc7bea8dd, 0x8f7da752, 0x23692925,
- 0x2c7187d9, 0x96394564, 0xfbd0f660, 0x7316d797, 0x533370bd, 0xe15fb81a,
- 0x1c79102c, 0x4dcbdef4, 0x6b5c62e5, 0xfdb12fe5, 0x09e79d66, 0x79ff77f4,
- 0x68e1bcd2, 0x7379ab3e, 0x3bde06a3, 0xde7dfedd, 0xb1fd9e4f, 0x64e56dc4,
- 0x36998f1e, 0x7bdfc9ca, 0xa22b888b, 0x3e143c5d, 0xff73753f, 0x1e9f007e,
- 0x0f54cf8e, 0x37b5a7c7, 0xff9c0d69, 0xf4de94f2, 0xc34f89c7, 0x0835f131,
- 0xfbf851af, 0x7ea99b93, 0x88ed1ea0, 0xc55be12b, 0xd85f9aab, 0xc80b392c,
- 0x9a19675e, 0x14c660fc, 0x1e7bac67, 0x3d48cfa4, 0x197bb46b, 0x3486a3da,
- 0xeff98dc5, 0xc7d17fcd, 0x1573dbcc, 0x525ef88b, 0x367de53c, 0x1fc91927,
- 0x93349fdf, 0xb659fc61, 0xd4bc234c, 0x3e51d526, 0xeb187ea6, 0x3a357f44,
- 0x7c9f5d0f, 0xe909e53b, 0x4061e86d, 0xecc79fd9, 0xe95f2331, 0x5d92563f,
- 0x99570048, 0x295f2e87, 0x26753d0f, 0x324f43cf, 0xd85e313a, 0x998c689e,
- 0x9badfe87, 0x71fb5dfb, 0x1fb8697f, 0x886eff23, 0xe56c97d8, 0x9f58eef7,
- 0xab46f500, 0x5dfc518f, 0x615bffec, 0x4dfda907, 0xf9433f56, 0x4e2a37a0,
- 0xa9f45fb4, 0x77e07f5c, 0xe231dc5b, 0x0dbb5f28, 0xa3fdfcf4, 0x99cf5cac,
- 0xfb3eddb9, 0x27dfb137, 0x44962b28, 0xdd3624bc, 0x3737450d, 0x9dde78ea,
- 0x2d7397ca, 0x9c07ca46, 0xf7d3b16b, 0x2102e66c, 0xf446a4f6, 0xfe56eebf,
- 0xd8acb53e, 0x7b7e9e91, 0xfe5f94ed, 0x00b5e196, 0x66a7db97, 0xc2bde818,
- 0x28f31253, 0x5df383a9, 0xa994debd, 0xea1bccb8, 0x7645af4f, 0xc8c3182c,
- 0xc1757a4e, 0x4e95ad43, 0x8aea8ff2, 0x737d9e91, 0x770fa2a6, 0x77d8c363,
- 0x04f2ffb1, 0xfbd5cf2e, 0xfc09e5a5, 0x646bde7d, 0xffec6cdf, 0x4917c555,
- 0x725f48d5, 0x2bae0e6f, 0x33dd3fa2, 0x5b9ff445, 0xcffa813c, 0xf5ddafe6,
- 0xce3977d2, 0xc8f99da5, 0xec7ce8c7, 0xf429ecb1, 0xbde458b7, 0xe81f9086,
- 0xa3d64577, 0xce22c5bf, 0x6e505a53, 0x4f218eeb, 0x3ec332d4, 0xa042e46e,
- 0xb18c8cd7, 0xcff5aa54, 0xa175f47a, 0x90fce718, 0xec1fe738, 0x6ac3b4f7,
- 0x3df80e27, 0x843cefe0, 0xe172f8f8, 0xb0f1f4a9, 0xbf6a07a5, 0x6ec7bf26,
- 0x16ceffec, 0xb00371f9, 0x2db3bef6, 0xdf8c5bd0, 0x87886019, 0x8bf91189,
- 0x25f6bf62, 0xefd0526b, 0x20f4b381, 0xbc0476dd, 0x030d6b23, 0xe42cbfcf,
- 0xd2160b08, 0x2eb106f3, 0x0ceb5a47, 0x2c38bb8c, 0x6073ca3a, 0x6791aacc,
- 0xa6536a73, 0xbb0ba1a6, 0x2716299c, 0xe45df7fa, 0xfbe06417, 0x7c9f180d,
- 0xf78636e7, 0x9d69595f, 0xfd75da12, 0xc6f788f3, 0xe17b8957, 0xed2d5f3e,
- 0xefd6c327, 0x5ff23197, 0x507382d3, 0xc33df56e, 0x92f19457, 0xc691ddb6,
- 0x5dee1ff3, 0x02721f18, 0xed2d67bd, 0xb04f4fc2, 0x30f8700c, 0xa9719fa6,
- 0x7282d5d9, 0x140957e6, 0xe7b7d677, 0xfbc820b3, 0x1bfbecb0, 0xf9c877c2,
- 0x6c4f2e90, 0xb65b9e16, 0xb9ec9e28, 0x0675a976, 0xe8f731f9, 0xd178ac58,
- 0xa7ee62ce, 0x2b628ffc, 0x4fb5cfbf, 0x1f63f4e4, 0xb8e1723f, 0x77ffe7ab,
- 0x49f99e84, 0x7fde93b2, 0x4da3ed52, 0x8e47f843, 0x5f213a91, 0xf8115e84,
- 0x199f3333, 0x792f45f9, 0xc774b079, 0x96bdaf6b, 0x5b53e8ce, 0x841b4748,
- 0x138ea3fd, 0xc6a21f9f, 0xf243c578, 0xb87ab252, 0xedfab0be, 0x75af3841,
- 0xce63e9df, 0xfba085ff, 0xd90fd935, 0xd3ad7fb1, 0xfa32c6e7, 0x9c96983d,
- 0x3e78dd7b, 0xe9fb332d, 0x96baec95, 0x61dfce33, 0x28f0563e, 0x9fd837cf,
- 0xefc3685d, 0x1b0e5941, 0xe265d364, 0x27d046f1, 0x19d8cbce, 0xdeaf9146,
- 0x99e78072, 0xbaca58b6, 0xc5a1af30, 0x6a465692, 0x56f3c2d8, 0xcb16fed5,
- 0x1607d221, 0x5adfdf85, 0xb8487f50, 0x0947c04c, 0xe110ebae, 0x5077ed43,
- 0x128b5dc8, 0x5a5ef866, 0xfd4ad29c, 0x83d7b2cc, 0x34e6ca79, 0x6644f746,
- 0xe217f02b, 0xccc75f35, 0xbec9f431, 0x5a4fae62, 0xaabaca4a, 0x7e327d69,
- 0xd8b58eb9, 0xe7a4eccb, 0x7cf0ef11, 0xcf968673, 0x577813bf, 0xf91669c7,
- 0x4eae77b4, 0xc38ed609, 0x1bf79338, 0xcb16e7a4, 0xf5107302, 0xcbf8e25a,
- 0x391a678e, 0xd7fb78d4, 0x43bef18a, 0x2c4fae79, 0x0678e2b3, 0x8d15f7c6,
- 0x9c62e1f7, 0x7bfbd5ff, 0x47bd2cc0, 0x581d304d, 0x7deb1ed8, 0x13f3feac,
- 0xcfd1f2f7, 0xbc7960fd, 0x02871b56, 0x091eec79, 0x72565afb, 0xd53550e6,
- 0x0bd3f8f0, 0xfd519fc2, 0xf6317492, 0xbf7f120b, 0x2bc5283f, 0xe10c5df4,
- 0x69c7a4a7, 0x3ef030f1, 0x6f873f2d, 0xde1e781a, 0x7c4c6937, 0xd7cb4e87,
- 0x38ff1cdf, 0x059f9345, 0x7131ec7c, 0xde23c63f, 0x3888f5a7, 0x6f18c21d,
- 0x049d17a0, 0x89c7f7ff, 0xc33f9c1b, 0x4099acef, 0x5c60eb8e, 0xfa27e1c9,
- 0x5dba3936, 0xe239efc8, 0x78d10ffb, 0x2e48c9fe, 0x7a47a5af, 0x51af785c,
- 0x119bd69b, 0x7c5fdf8b, 0xee0642f8, 0xfd19c5e7, 0xdf743b79, 0xe769e2f4,
- 0xcbc402e6, 0x6ffbed11, 0x474df8ea, 0x22f8a7ce, 0xe5c0a5fd, 0x3a4b2fdf,
- 0xd92571b3, 0xddb80b8d, 0x7dfa7ff8, 0x73e617b3, 0xa497753b, 0x084fcf95,
- 0xfc141cb9, 0xd320bb60, 0x2aee43f7, 0x3a40adf2, 0x0bac936a, 0x3ce72e50,
- 0x9af2f3cc, 0xb3d55b1e, 0xb47f0628, 0xd5fdf28c, 0xbabf08c8, 0xe491bd7c,
- 0x3725b35e, 0x28f772f9, 0x9fbb9f43, 0xde7a94e4, 0x79988f55, 0xdb8f8abe,
- 0x7bbee9d1, 0x3a260f29, 0x7ea8653f, 0x449d23d5, 0x137f6a0f, 0xc5f28f8e,
- 0x15c52372, 0x818fa1ce, 0xb72b3b71, 0x59d7a233, 0xc098c889, 0x7d0663f1,
- 0x49607499, 0x106b8e1c, 0x6a0bdcfe, 0xcca1a45c, 0xde7889ec, 0xb9995b70,
- 0x9a4e823a, 0x8e0fcf19, 0x2337ff1e, 0xac22fb55, 0xa80c63b1, 0x94c6317f,
- 0x97ed9f26, 0xf278643b, 0x0395b4fc, 0x0ee3cc7c, 0xc5a3e743, 0x232dbe71,
- 0xf30dac7b, 0x5e0ec0d2, 0x0460b0d3, 0xf64db7e2, 0x3c0368bd, 0xa2687ef4,
- 0x0bdfea3c, 0x7c16ed3e, 0x05f9d43a, 0xd23001d9, 0x1d9c7b18, 0x80e297c4,
- 0x2327c64e, 0xebe7345f, 0xf63142ea, 0xf3ec5c79, 0x7878f632, 0xc7b3f7e4,
- 0x1afe890f, 0x6ded1c7b, 0x46fdd44f, 0xb6768c24, 0x7e3d8627, 0x05f11242,
- 0xc2742791, 0x0dd5dce0, 0x39313978, 0x5697be99, 0x5defc090, 0x527fa04e,
- 0xabc87e06, 0x7ed1f3a7, 0x7ff52d99, 0x43f84917, 0x47f0608c, 0x62f905fe,
- 0xb6bff30e, 0xe23e2248, 0x1b7835f7, 0x73e57e9f, 0xd19236de, 0xf9c036ba,
- 0xdb46fde1, 0x6233f9c5, 0x8ea467dd, 0x5037fd52, 0x13ef1165, 0x889d3c33,
- 0xf741acfb, 0x72f75174, 0x9fd36d78, 0xdc1fac77, 0xed7286ff, 0x8b86d9bd,
- 0x5a622e3c, 0x4b8f42c2, 0x6daa9798, 0x10cea9bf, 0xb9a82f7d, 0x6bd9bb4f,
- 0x7d0f5e88, 0xd621d417, 0x1f71dd9b, 0xcd4fbfdd, 0xa644f9e6, 0x04e28c65,
- 0xa66df7d1, 0x3d1e5db1, 0x8c0dcfda, 0x38e8fdec, 0x52a9e639, 0xb181b0fc,
- 0x79e5122d, 0x7973df6b, 0xfe73fea6, 0x3ad6947d, 0x760ec79c, 0xd1d3da10,
- 0xf7a849ef, 0x51f7ea5a, 0xdfab3c55, 0x4dbf4a8f, 0xc163eb47, 0xc6aed429,
- 0xb87bf1fd, 0xf911e955, 0x7f582be4, 0x2b7f7a7f, 0x9bdf7b18, 0xcf29eadb,
- 0x7fbc7320, 0xb29a186c, 0xc8784614, 0x6fc8c85a, 0xf2683c00, 0xdbd94c09,
- 0x16e79f69, 0x224c3633, 0x33da683c, 0xfdd3d340, 0x7e6d42c0, 0x0353ec01,
- 0x57abfb47, 0xd94d53f2, 0xf39597f9, 0x9a638a57, 0x94e4bdc4, 0x97fbe251,
- 0xed14aca5, 0x9edbf4a2, 0x0738f3a1, 0x5f7181e7, 0xdd629c74, 0xf1826e3b,
- 0x77fc8fd1, 0xe2cd2fc1, 0xaefd5b6e, 0xf4c8f30f, 0xce549b1e, 0xf30d2cd7,
- 0x12e97bf2, 0x8a6e7c46, 0x8fcc6667, 0x1e4c2a97, 0x04c9bbc4, 0x32596c30,
- 0xd4067332, 0x7b3c45eb, 0x8464c48d, 0xf3315599, 0x5dfaa3f8, 0x577d10a1,
- 0xd479a868, 0x20b22bef, 0x679d4e7f, 0x2ef577d0, 0x7bf93cf3, 0x6be7e8d6,
- 0xcea99e29, 0x87fe143f, 0xbfde8efa, 0x8137bcd5, 0x441d53c7, 0xf4038daf,
- 0x417cf04a, 0xca3cf88f, 0x66d5bb85, 0xfa29577b, 0x4c1e670f, 0x114a3650,
- 0xd2ce08fb, 0x7e03eff3, 0xd7faf1bf, 0xbc927761, 0x1897dfef, 0x8beefbef,
- 0xdae422fe, 0x09597c3a, 0x191a5ef3, 0xfba431e5, 0x29973faa, 0xa0f600ff,
- 0xdf111391, 0xd6f18049, 0x1fefce3d, 0x3e77e336, 0xc0e7fef0, 0x13edfe40,
- 0xd1f76c16, 0xbcd43677, 0x5da3cc5c, 0x3ef0325b, 0x837df472, 0x89c611bd,
- 0x99b26f98, 0x9f401305, 0x0531f4a4, 0xb9ecf3bf, 0x03a65468, 0xa07d6c7e,
- 0x93bf0150, 0xa5ee8999, 0x337ead2a, 0x0ae10eff, 0xef676916, 0xefa56e97,
- 0x64bf86bd, 0x3e14bf94, 0xc3ee88cf, 0x70c4c39f, 0xddf8ff2e, 0xcbe47afb,
- 0x7a5d7da9, 0xfb93f3d4, 0xf67fa4fc, 0xed3d4fd9, 0x9962e7e2, 0x751f9111,
- 0xcf545b1d, 0x979f8ae9, 0x5f27ea2c, 0xfdf86a30, 0x46a35eda, 0x5b17c81e,
- 0x65fd46be, 0x67aa89ea, 0xe3e33fd3, 0x2dde28f9, 0x53edb5db, 0xdbd03e44,
- 0xc35fdf2a, 0xbc73a1ae, 0xcf331698, 0xd5dce06e, 0x71e26e73, 0x79c7c674,
- 0x9ff7946e, 0xff404d46, 0xe87147c0, 0xd82fc464, 0xdd952917, 0x58798ecc,
- 0x8e994ce5, 0xf3b2bd72, 0xe487a41d, 0x3c0f3cb3, 0x5ffdfc7a, 0x7e8595be,
- 0x9dc99ec3, 0xed2f6859, 0x3d15f2f9, 0xd3d5578e, 0x193eb0cb, 0x58a41e4a,
- 0x10aa784c, 0xcf5033b4, 0xf59144e3, 0xe74a9eb4, 0xcfe4e565, 0x871a4e50,
- 0xd933df6e, 0x87e4c2c2, 0x3da02675, 0xfe7c7cc7, 0x57cab364, 0x70972fec,
- 0x9f81845e, 0x52ea54f6, 0x7b9f616a, 0x6c15919e, 0x46f3d3dc, 0xe7bfce02,
- 0x7acd39ec, 0xf322fe98, 0x5afbac45, 0x2b53ee71, 0x7efec97b, 0xf92bac4a,
- 0xa1c52f6c, 0x30de9553, 0xc3d4dbea, 0x37fefa7a, 0xc8bcf0b3, 0x38a14c61,
- 0xfc5eba9a, 0xd73e2a6e, 0x88de7282, 0x5632b3fb, 0x287eec28, 0x55832a33,
- 0xcc9a8f98, 0x6b484a76, 0x417d2b53, 0xa5e4e7a4, 0xad939e9c, 0xbf18c3fe,
- 0xa3af5e4f, 0x59f24538, 0xcbf406df, 0x0565cb92, 0xf84ae4c9, 0xb7f310ec,
- 0xf9d4f98a, 0xa88cf5d5, 0x7ee84bf4, 0x62e3b324, 0x132aaefe, 0xcc5abf8e,
- 0x59eb14ef, 0x2c3be8c5, 0x55ad67c9, 0x83272fe8, 0x33df419d, 0x9a79e2b8,
- 0xb745f335, 0x99d94f27, 0xb1e0e745, 0xe30ad91e, 0x365b64a5, 0xceb94154,
- 0x32ff23a1, 0x3c5187a9, 0x9d27a93d, 0x4f527de4, 0x8a2728a1, 0x0f4269fa,
- 0xd4933970, 0xaf2d50f3, 0xa4d2a16f, 0x3f8717ca, 0xda98fb8c, 0x717cb8cb,
- 0x98be4978, 0x517cb8d2, 0x9556b8e9, 0x325acc2b, 0x0ff7ea1f, 0x06b5acff,
- 0x73f77b9e, 0xbbe5fefe, 0xbcbe5cd9, 0xfbf725fb, 0xd3bf694d, 0x42aa5ca3,
- 0x4dfa05c3, 0x33edc0bb, 0xbaab1f95, 0x48113625, 0xe7839a63, 0xc8ba1f87,
- 0xd9843b9f, 0x63af00d5, 0x9529c912, 0xdd056b6e, 0x83eab3ae, 0x81fed849,
- 0x3477de89, 0x98e5ce39, 0x83fe1ec1, 0x7c41f7ae, 0x33f7f8ef, 0x415def7a,
- 0x437e82f5, 0x9a2e494b, 0xe4396c84, 0x3e416058, 0xae487984, 0xe918721e,
- 0x3a080ebc, 0xe9af673e, 0x5b3fc308, 0x69fcdfcc, 0xc1ffd43e, 0x9340eb9e,
- 0x1e973d4c, 0x885f2f41, 0xe82b3bf3, 0x7bdd29a6, 0xfc04c953, 0xcd1e62fe,
- 0x0dfece7b, 0xdcb27fbd, 0xc69f1ff6, 0x3aa72efa, 0x4f7cfa8e, 0xcf19a568,
- 0x1f9bd0f5, 0xabb4409f, 0x7b235fe3, 0x7ee3e4ef, 0xd0f89a33, 0x78cf3b12,
- 0xadf3fc90, 0x8b7f9688, 0xc80f864a, 0x91667abf, 0xe7121e79, 0x1e4259eb,
- 0xddb8554d, 0xe7e56f5e, 0x5fb25f55, 0x8b8afea6, 0xd2af55f6, 0x5ae4f28d,
- 0xf29b7fe4, 0x7d4bd124, 0xbd97a73e, 0x0a0f9e82, 0x63ecce7c, 0xed97e89d,
- 0x196e982f, 0xe23ef80b, 0x1cff13d2, 0x52c6bb19, 0x291dcf06, 0x024bf095,
- 0xd6c97a6c, 0xcf00a9b5, 0xa7a22452, 0x1dad92fa, 0x967fd04d, 0x03a94135,
- 0xb3f9e8f8, 0x0eaf3416, 0x9784bc05, 0xe3f872e9, 0x1b9e1754, 0xcaccd3c7,
- 0x4ffe8cb0, 0x8cbf63bd, 0xc46df6fa, 0x2ee311ab, 0x7567c11e, 0x6a571f04,
- 0x238fb82c, 0x2f2126a5, 0x5e51e33d, 0xd537cace, 0x7c75a18f, 0x1a4c6c7d,
- 0x506f77be, 0xa73c95f8, 0x7e82c9ff, 0x6b27ccea, 0xccdfa053, 0xd7196692,
- 0x912cd47b, 0xd7da3cfc, 0xc793f944, 0xd2ac393b, 0x74073d2d, 0x5b6fbc79,
- 0x6fb61273, 0xd53e4897, 0xe21d2f2b, 0xa7d38fea, 0x0b0f7e3a, 0x3077e1b6,
- 0xb7af29cf, 0xb1f53e60, 0xcccf05be, 0x7f1c3c01, 0xb8c43f53, 0xc0ad1f4d,
- 0x244cdf71, 0x356d9e3a, 0x8cb1f469, 0x5e84694e, 0xd36f1ead, 0x0d4af5c0,
- 0x29cfd3c5, 0x7806e592, 0xad5df3de, 0xd191397b, 0xbd77da52, 0xe14c7be8,
- 0xa1cc797c, 0xd63cbe23, 0x8a9cb8f7, 0xfb4659f0, 0xde769991, 0xb21a92fa,
- 0x5b29ceaf, 0x826744f5, 0x54f1d50f, 0x4f8a3e3a, 0x9ced1e23, 0x6df68fff,
- 0x1dbd20b3, 0xe323bf75, 0x89675d39, 0xa1d0571a, 0x5df0dfaa, 0xda9fa471,
- 0x7ef3fb51, 0x3851eb86, 0xd7946bfe, 0xd57d238f, 0xa7a2643b, 0x9afecaa3,
- 0x27bf8614, 0xffecd262, 0x9ac91dfe, 0xda7597f1, 0x5db47034, 0xdbfdcfb5,
- 0x0ec4cba7, 0xd847a466, 0x3ec2f947, 0xe0771fd2, 0x1768aefa, 0xf7e8eb29,
- 0x45d90649, 0x8a2edcf9, 0xbe5487b6, 0xb889d66e, 0x65c78eac, 0x58dff9a3,
- 0xf1eec3fa, 0x8e492ad8, 0xc65bbfbc, 0xbe9073ba, 0x8612a3e6, 0x75d01ef1,
- 0x15fc23a7, 0x078b6deb, 0xccad7c39, 0xbfbf6976, 0x3f37bfca, 0x1e77d4be,
- 0x367495e5, 0x6561df4c, 0x07e518ab, 0x9e786be8, 0xad665e11, 0x258bd488,
- 0x8d2df1fd, 0xd84ba45d, 0xac78859b, 0xf1e46b38, 0x38e89e8f, 0x851fea97,
- 0xae2bf225, 0x93ea2e52, 0xe67bb8f9, 0x7f6778f0, 0x938f3379, 0xe5fc0915,
- 0x5d691a94, 0xdcf7808a, 0xb59efb16, 0x41fa54a4, 0x07dfa2f9, 0xef8029df,
- 0x61e690af, 0xb1553d9e, 0xca5291d7, 0x9777b5e3, 0xa14af278, 0x15f12a2c,
- 0x3d5e2296, 0x77d35f60, 0x9f643dc5, 0x33bce3a9, 0xfd16e3ca, 0xbcc96146,
- 0xee8f0edc, 0x6863ed07, 0xe3d8869c, 0x7a38fb40, 0xf6ec6e7e, 0xfc39b843,
- 0x30fb237d, 0x0c0643d2, 0x52f2a664, 0x16e5e32a, 0x8846aefa, 0x1e0de7fb,
- 0x9146f3d2, 0x103788af, 0xf4c7fc91, 0x1cbe34f5, 0x58f7419e, 0x8325d82d,
- 0x7691f9fb, 0x6a84ac94, 0x6aade322, 0xdf94a8b9, 0x1528ce73, 0x604cf3ef,
- 0xa8afc813, 0xea3cfcbc, 0xc3cd43f3, 0xc85765ec, 0x63f35e7b, 0xc3fa49d3,
- 0xa55f27e4, 0x4a0e607d, 0x1f39df91, 0x4a89bf6a, 0xc28a1c94, 0x5cf350d3,
- 0x22dc79ed, 0xd76af6e8, 0xcc7a655d, 0x2ed1f94e, 0x056b07ce, 0xd5dbf57d,
- 0xbe3f1e3f, 0xfe861f3f, 0xfefbd9ca, 0x4a7ef893, 0x37a56842, 0x145e7ec6,
- 0xe531f9fb, 0xce70d3c1, 0xfba18c1b, 0x0799ded1, 0xd20263a7, 0xf1f2c77b,
- 0x9eb005f0, 0x2dfcc537, 0x6feb9596, 0x1c5b4785, 0x1ef998ba, 0x7a78fe6f,
- 0xd93f0da2, 0xdce395ff, 0xa7206dfb, 0xd07d1e5b, 0x7581b0ac, 0x15d96b30,
- 0xe347f9ce, 0x6d5d7513, 0x625e305b, 0xf7aabd4d, 0xaf5c5a14, 0x697de024,
- 0x764de7ed, 0xb4460efc, 0x43c6a03d, 0xc6a5bd54, 0xa4bb544d, 0x1fe3c1c2,
- 0x7bfced33, 0x69f6153d, 0xb20fdfa4, 0xaff21aae, 0x226d3b30, 0x19fd0ab1,
- 0xe4fb5add, 0x4657bf3a, 0x9eda2a3b, 0x45334da8, 0x7abd07d9, 0x1715df94,
- 0xfe54fdb5, 0xc454acf8, 0x17795451, 0xcf9a4765, 0xbb40499f, 0x670bedeb,
- 0x8d142e28, 0x5c2eeb9f, 0xaebd9fde, 0x83f74f5d, 0xb7ad71d1, 0xfdd2e42f,
- 0x1baf11a0, 0xcccad4c1, 0x808cc43f, 0x6b7b4c97, 0x18ec1195, 0xf82983a3,
- 0x58fc36dd, 0x8d0dc633, 0x7c9c7817, 0xd7fb9d84, 0x2fc18b89, 0x95335185,
- 0x78c17da0, 0xef48ce7c, 0xef5d99d3, 0x09bdbd91, 0x9e2186ea, 0xa6199ec7,
- 0x5307118b, 0xc08a63cf, 0xb7e66eef, 0x4d81efe3, 0xf7f78bb1, 0x59db462e,
- 0xa22d3cfc, 0x2d62e27f, 0x3ce22d3e, 0x435b8327, 0xd3ec79df, 0xe7116f3e,
- 0xfb1a596b, 0x63a3ec1c, 0x7aa2439f, 0xc5b6130e, 0x596c39e1, 0x758a4dbc,
- 0x2f8b990e, 0x845b0e7f, 0xefd2a95f, 0xb204acb4, 0xe8a6f7af, 0x7b41fbe8,
- 0xcb59c313, 0xb2fdfe31, 0xaccfde99, 0xb4367110, 0x6b9f10a4, 0x84bf97b7,
- 0xa371db71, 0x7b8e74f5, 0xbcffd125, 0x60feff8e, 0x1fea78cf, 0xf883b327,
- 0xfb0780bb, 0x1bbbe9aa, 0xd3bbfcd1, 0x33dd007a, 0x3db9ceb6, 0x839c016b,
- 0x9980fb25, 0xcf839bfb, 0x4a3fef07, 0x7b4bbe05, 0xa654b9f8, 0xbda3d49d,
- 0xec66f25e, 0x8fe351f3, 0x3a9da47b, 0xaa362b20, 0x98fc8baf, 0xeca33b91,
- 0x642db3e9, 0x47c65b67, 0x39c0f7d5, 0x9f8ebdd1, 0xa1d916ec, 0x87ebaf3d,
- 0x114aa738, 0x7d7f3087, 0xfb65e28a, 0x7e714efa, 0x25c6d1e9, 0xfe5df727,
- 0xe7135e9c, 0xa1c453b4, 0x00e22e7e, 0x7e7fc29d, 0xf2a4e023, 0xea9b80cd,
- 0x04280adf, 0x0b940aef, 0x77cfc161, 0x47cb3e56, 0x84aaaf17, 0xcf47edfb,
- 0x7f7dbf73, 0xbe83a862, 0x42de74ef, 0xbda417df, 0xdbbf144d, 0x2c727c07,
- 0x1fbf49ce, 0x4cdb3478, 0xa5a3b3f1, 0x8a7bfbbf, 0xd16b7cbb, 0xc70bb8f1,
- 0xeb4e7ab3, 0x6f184e70, 0xee8b855d, 0x47e036a5, 0xeeffa114, 0xffbe8932,
- 0x040e1b34, 0x3a5445ef, 0xf169f537, 0x65ff0f59, 0x1ddff195, 0x617f42c8,
- 0xa4e88b8c, 0x2273ef42, 0x4fba373e, 0x571e5f91, 0x871beed8, 0x7af18071,
- 0x14fbbe26, 0x3bac4534, 0xe0426f0e, 0x44895379, 0x0a1a73df, 0x86e5d1bf,
- 0xa32fae54, 0x3475ffeb, 0xdd1b83d7, 0x773ce8db, 0x50b2ba3b, 0xf913efaf,
- 0x2964b310, 0x285fbf48, 0x1cb1dd77, 0x65915bf6, 0xc011bb1f, 0x6853a32d,
- 0x4f4afbfd, 0xd8f81c53, 0x21c65785, 0x76b31dfd, 0x79ce305a, 0x53dfc9cc,
- 0xf9951387, 0xf29db77b, 0xa4f2312d, 0xe958f2d5, 0x95fdfa22, 0xef7cfc7f,
- 0xdf7cd1da, 0x0af5524c, 0xfb815b8c, 0xdef9424d, 0xc3f902b2, 0xfc83b998,
- 0xaa73e8cc, 0x88b35f70, 0xfc64f3de, 0xb6bf4f7b, 0x3f782c86, 0x0267ed1c,
- 0xff426c7d, 0x3d04f778, 0x5eadaf7d, 0xe782e7e6, 0x1fa4e788, 0x997e13a3,
- 0x65667c76, 0xc0fa633e, 0xde1d6079, 0xf13ad0d7, 0xadefaa3e, 0xf86292bf,
- 0xc9d683b5, 0xf9589efc, 0xcdcfd1b0, 0x9a20b276, 0x1615b386, 0x709fa176,
- 0x99c69f30, 0xcce3e56d, 0x9b7c7112, 0x1759ffa0, 0x81df9475, 0xcf80d6f4,
- 0x7927cc95, 0x50f5cc72, 0xb7ac1d57, 0x41c6ce1e, 0x569346fe, 0x5b39090e,
- 0xf745525f, 0x07dcc7bd, 0xbfbea3c6, 0xe1e574be, 0x9fc22732, 0xb74154d4,
- 0xd52fa529, 0x945a5d20, 0x4c2f8a2e, 0x5d74cb76, 0x36b97d78, 0x17afd14e,
- 0xb44bf4a3, 0x928fa8be, 0x54f7113b, 0xf9c4434e, 0x4b9f72cf, 0xab83a488,
- 0x2f1ccbc7, 0xd67baf7e, 0x1da71e05, 0xe9f7978c, 0x7803a573, 0xd8ef3e89,
- 0xa73e8978, 0xeaad3c01, 0x8c1dcbaa, 0xbf6f155f, 0x1ac9792e, 0x8d1be799,
- 0xaf8a1fb7, 0x4156d1e6, 0x579e5caf, 0x3b7dbe08, 0xb771443b, 0xeff94bb7,
- 0xff731d4b, 0xb3bfe296, 0x0d63a858, 0xcbe045ca, 0xe8f94239, 0x344ce423,
- 0xf4f8061e, 0xbf2e283f, 0x28b7f3fb, 0x21caaa2e, 0xea25f213, 0xea1fc113,
- 0x1f9099b9, 0xf02f6f91, 0x2d5e87ef, 0x457ca87f, 0x383f21eb, 0x1fcc8fa4,
- 0x5fc5dffc, 0x18cd717b, 0x52167617, 0xd1cab83c, 0xac7bc7a5, 0x3dd250c9,
- 0xd27f8892, 0xf5919c3a, 0x591c6e3c, 0xa12f714f, 0xa6b8d4f7, 0xbb3ebeda,
- 0x5518412b, 0xc24d47a4, 0xc4fd51de, 0x64538e7d, 0x54faaa7f, 0x57fef716,
- 0x08f74fab, 0xfb543a7d, 0x79bb73de, 0x43cbe7dc, 0x1c800f3d, 0xa46f9c9f,
- 0x0e4cb8ef, 0xa3dfcc3f, 0xfe498470, 0x9137746f, 0x69fb0c1f, 0xe604a346,
- 0xf3e64475, 0xf3bee5a9, 0xefd60a6d, 0x0af4bb95, 0x16ff07f5, 0x568603e0,
- 0x0d869dfa, 0x137d738f, 0xd651f457, 0xba83dee5, 0xe6994fb3, 0x61efc24a,
- 0xdf835f6f, 0x8c2a0b01, 0xb598ebbe, 0xee458bb4, 0xdc31a5f7, 0xff9c9daf,
- 0x68071dd6, 0x69ea1fdd, 0x035768dd, 0x9d964f9d, 0xcfe7050e, 0xfd23dbf6,
- 0xf7d97dec, 0xb7009dda, 0x086c697c, 0xa3c37ad1, 0xecf3017e, 0x078d5733,
- 0x73ed8d4b, 0x0bf5181f, 0x7346c7c0, 0xa3cc04d5, 0xdbdfb6ac, 0xdae51f3e,
- 0x60265bd9, 0xbcec1bfc, 0x83b7d456, 0xcdb7dff6, 0x5d3bbf8c, 0xd69f78ed,
- 0xabafa231, 0x5abfbf06, 0x48f7e0ed, 0x87bed1be, 0x7b404cc6, 0x73c1ec39,
- 0x0c9f344f, 0x164cdd22, 0x2f1765eb, 0xbd41fc51, 0x9e73d997, 0xf8ff47d3,
- 0x8fb80f40, 0x455cbf6b, 0x7db922f7, 0xa026f9ba, 0x3c7d75d5, 0xf1db0c7f,
- 0xbf58e07b, 0x001d8628, 0x4be75cf3, 0xcaebf3c6, 0xde8637ba, 0x36fbedcd,
- 0xf6e783e0, 0x44bc7064, 0xc31e6fb7, 0xafb882ed, 0x9272cfde, 0x7ff5c03d,
- 0xf312c0b0, 0xa9b7553b, 0x3b1ad2fa, 0x552d450f, 0x23daa579, 0x21b35f80,
- 0xc69bbf02, 0x7cfdff70, 0xf103a7a9, 0x7fe77df7, 0xe50b710a, 0xf6cf52f1,
- 0xae91c331, 0x97ad5f04, 0xee01c663, 0xc5a3f31c, 0x13416e2b, 0x73beabef,
- 0x86e96fe9, 0x7441dba6, 0xf8e95065, 0xffe3a221, 0xe27bf48b, 0x20efd0fb,
- 0x14fe7479, 0xd347c3dd, 0x03bf4ab1, 0x9be6c874, 0x79e80692, 0x7ec1ba28,
- 0xe806928b, 0xfb7ea87a, 0x931fbfce, 0xe9c607de, 0xabdd2cbd, 0xd059b7f4,
- 0x540f7a91, 0xfd79ce29, 0xfeec8cd7, 0xf5463da3, 0x7e35c677, 0xca3fe811,
- 0x72b0aea3, 0x37b47fb9, 0x3d19fb97, 0x9a9fba66, 0xbe295ee9, 0x235d0dbb,
- 0xf211adc6, 0x75dba67e, 0xeaaf3959, 0xfddf550b, 0x43777c4f, 0x00800098,
- 0x00000000, 0x00088b1f, 0x00000000, 0x7dedff00, 0xc754740b, 0xeebd6095,
- 0x91a93fd7, 0x16883e9e, 0xc085a092, 0xeb404616, 0x7d3d05ff, 0xa71f3210,
- 0x900b18c1, 0x04e08b4c, 0x60dd491b, 0x9e3d90e2, 0x123231a1, 0x1f62cd9f,
- 0xbd6678cc, 0x8c030d39, 0xc077b19d, 0x0b611c56, 0x3837e2dc, 0x71c6ec4b,
- 0x3c4c9c18, 0x6c0843c2, 0xc718d36c, 0xbc4ab243, 0x0f7adef7, 0x0b756bf5,
- 0xcceb43db, 0x40e75764, 0xaabd5ea9, 0xfeeb75ba, 0x7ad3d56f, 0xcecc6333,
- 0x53f817d8, 0x08acbc3d, 0x65cb191a, 0xfc05f3f4, 0xebf2e2db, 0xdf632b25,
- 0xb4cbeeb9, 0x2c93f943, 0x1e670adf, 0x355faf63, 0xb188acca, 0xf6e3a9ae,
- 0xfa87b3ea, 0x8c08758f, 0x127b4315, 0xef768674, 0x0077c154, 0x27d1311e,
- 0x7d1e9d2e, 0xfd4c9fde, 0x8795cdae, 0x9d32fab3, 0xaf7a6863, 0x59b18d3e,
- 0xca0e9bf8, 0x332d9320, 0x5aedcca0, 0xcca012c7, 0x9636f92c, 0xb12e624c,
- 0xf2933184, 0x6bcae99e, 0x39f015df, 0xfe831993, 0x56f595eb, 0x0d5d7f30,
- 0xcccf31c0, 0x3889f1bc, 0xc9c9d37a, 0x97cd5ed0, 0xd769e30a, 0xfe9fde1d,
- 0xe4f329a5, 0x572e3630, 0xfbcdf5a0, 0xf04cf98c, 0xeb6e756b, 0xe7033602,
- 0xd1cc7187, 0x1e60a9c7, 0x1d01e999, 0x2adb5ee5, 0xaa6b3fe8, 0xafe5e1c9,
- 0x6cdef84b, 0x3e1bdfc6, 0x4ac67ace, 0xe2d9c686, 0x54fac809, 0x4c498ec6,
- 0x6f5b2fe9, 0xf8e767c1, 0xb2857ac3, 0xcd6e533e, 0xebcbc455, 0x07e1c792,
- 0x860f6778, 0xcb1d6f8d, 0x55633a58, 0x8b9f699f, 0x387d6d0e, 0x58fb305c,
- 0x5f4fe5fa, 0x33467cc0, 0x5d398fc7, 0x5d79f847, 0x3e90fa32, 0xeed4ae2a,
- 0x4b189362, 0xfc87ec96, 0x992adcf0, 0x36053e1d, 0x7e53f633, 0x0402b8af,
- 0xc29fed04, 0x738014bf, 0x5aef6e9b, 0x16ddd027, 0xa21f4c6c, 0x4c0b2597,
- 0x2e96381a, 0x9bd4d449, 0xea69c79a, 0xd44f57cb, 0xdb736fec, 0x43fa9add,
- 0xea6a661b, 0x354a27ae, 0xd59d55f5, 0xef56f19a, 0xff69ab9c, 0x686feed6,
- 0x7f9e6bea, 0x747f5350, 0xe911caff, 0x885f1a22, 0x89e991b6, 0xd23b0579,
- 0x3a4d88bf, 0x9cc5cffc, 0xf7f7a3d3, 0x7ec27f21, 0xb7af6ebd, 0xd5fe82ad,
- 0xe78d3f57, 0xc5f4b4fd, 0xf90072bc, 0x17d956a3, 0x402bc798, 0xad528d7b,
- 0xf445be95, 0x4536635e, 0xee951be4, 0x11560ab6, 0xda66afc7, 0x6db0aafd,
- 0x7e47aebd, 0xebd01a2e, 0x3759be61, 0x2157fcb5, 0xc706fc35, 0xc7afcc67,
- 0xa5cb84f5, 0x9318eeff, 0x609e397a, 0xfc017fb5, 0x8cc9acc4, 0xa3c74795,
- 0x5db7a74a, 0x6f5f6337, 0xeafccadd, 0xa0582b7a, 0xda3ee90e, 0xfc3b67ba,
- 0x516b927a, 0x5ebe1dd6, 0x6feffe15, 0xef815f86, 0xf323ff5f, 0xdb1013ed,
- 0xe6fc88b2, 0xcfeb5ddf, 0x02402bb5, 0x7a1527bc, 0x278291a8, 0x0e908b12,
- 0x83650398, 0x51f99071, 0xc133d40e, 0x9652846f, 0x38af041c, 0x3034ef68,
- 0x7e71eb2a, 0xa6861071, 0x35eb45d2, 0x288dca0e, 0xa92c456f, 0xebc79cee,
- 0x875e068e, 0xd52ea8f7, 0x3ee7baf2, 0xea92875e, 0x43af275e, 0x5aefaa3f,
- 0xb8cef58c, 0x014489c0, 0x5825beeb, 0x5a1e0e37, 0x05ff4bca, 0xe4994a81,
- 0x5de83896, 0xec7ea7a7, 0x3707af22, 0xf2d0fa71, 0xf65e3183, 0x5f19b3f9,
- 0x813f3c3d, 0xfdc24dbf, 0x006fd75c, 0x828ad43c, 0xd5ef0ec3, 0x3f87320c,
- 0xe4d5f715, 0xe097d990, 0x3133a033, 0x8ccf886d, 0x4ab1982c, 0x0f793e20,
- 0xedcaadf1, 0xe968e3e1, 0x5af51eab, 0xfc3bec01, 0xe51931be, 0xfaa7a730,
- 0x2c12e0b2, 0xd013f9f1, 0xfc327b3e, 0x1f4e1e4b, 0x32a25c2a, 0x5fb5a55f,
- 0x32b6aa8f, 0x59b72618, 0x8559d117, 0xd92c9d79, 0x716dcb87, 0x2e2fe550,
- 0x56e1c22f, 0x1f39ade5, 0xfb1a6cf8, 0xb9967c3a, 0xaeb36a0a, 0xd9f0abbe,
- 0x933e30ba, 0x8496f7ad, 0x321019f0, 0xb7d9f0d3, 0x276e9e89, 0x83094e5f,
- 0x4f182675, 0x23e80cf6, 0xc05499ca, 0x3e244243, 0xb21bfb9b, 0x97c8a21f,
- 0x5817f037, 0x987e6e67, 0x5cf4519c, 0xfee7aab5, 0xdda2b3a8, 0x117a67e2,
- 0xc87c70cb, 0xd2313b2c, 0xbe3cb573, 0x6bba0609, 0x90f80ea8, 0x63be810f,
- 0x06dc151f, 0xcec99bcf, 0x805ab862, 0x31e2aac7, 0x71ad6e8c, 0xec909d2f,
- 0xecf505bc, 0x4e6e8518, 0xdf11a766, 0xc7bd76c3, 0xb59de442, 0x01f1cbe8,
- 0xc70937cd, 0xbf226673, 0xc6db40d5, 0x33fde182, 0x99f00fb1, 0x3e7cc835,
- 0x08eacf78, 0x46af5808, 0xf48d9efd, 0xfe51eacf, 0xe8095f57, 0xe5a5ea25,
- 0x00745b97, 0xa4013fbf, 0x517c8b57, 0x642e9c30, 0x7ee3d3e6, 0xaffdd57c,
- 0x90341fb6, 0xffdb0ebc, 0xcfb0419a, 0xd5394e00, 0x1afa20e4, 0xc8cf6464,
- 0x48c7c14e, 0xbc21acbe, 0xade3f6a8, 0x176826f6, 0x622e91e8, 0xf640b37b,
- 0xb36ca7d0, 0xf305f381, 0x867a55fa, 0x30afcbe7, 0x34ed1139, 0x7ed4f3cb,
- 0xfa23136c, 0x3c97b6a8, 0xb8476755, 0x44cc7606, 0x0abd24b8, 0xc7153f97,
- 0x70e260bd, 0x7f08daf9, 0xe4fe0ad5, 0x43331d41, 0x694fbfbb, 0xff5fa30f,
- 0xfcd3b720, 0x702bc44f, 0x43f0c8dd, 0x4ed007bf, 0xe5689306, 0x43ff03dd,
- 0x69dcf784, 0x01df3f77, 0xf028ae5d, 0x6e856ffc, 0x5124da3f, 0xf5cd3eb9,
- 0xc7a07cfd, 0x7c6e917f, 0x0fc866e2, 0xd5f74439, 0x9027cff6, 0xd9f1521e,
- 0x10f48637, 0xe8f84dc2, 0xdb8344b3, 0x387510aa, 0xe5bf0abc, 0x2a57c88c,
- 0x577c2a9c, 0x0bab7a7c, 0xe7b37bc6, 0xf61c135f, 0x454bf821, 0xfb847ee7,
- 0x674fc1cd, 0x92ef88b8, 0x34667635, 0xfc5266f9, 0x964ca488, 0x3ea2a62b,
- 0x85cc7388, 0x74cb8c75, 0x364cbad1, 0x02fd1da3, 0xf393274b, 0x82734860,
- 0xf7f08ccf, 0xd2ec37a7, 0xa9d6fb43, 0xfbc13322, 0x36bcb35b, 0x09fea75a,
- 0x9399eb86, 0xd60361e9, 0x6577f3e8, 0x9c11293e, 0xbf475083, 0xa2f1c6c7,
- 0xf8f4689f, 0xc75fb9e0, 0xc10a1cd6, 0xee02c1cb, 0xe7cd9d8f, 0x1e17dae5,
- 0x842976d9, 0xad0fda3f, 0xbdddd4d3, 0x2976dbdf, 0x106ede54, 0x3697dc44,
- 0xd9db8e85, 0x5ff404c0, 0xe13b455a, 0x903743a1, 0x2c6bf586, 0xae0a7e78,
- 0x008fe70f, 0x5be73fff, 0xd2ff3d62, 0x8ff650a9, 0xff69fee1, 0x0df91f24,
- 0x2b1ffcea, 0x5f38ffeb, 0xa6387317, 0xb3ba1e01, 0x9f70c5bf, 0x3f7c6c6a,
- 0x7a72504d, 0xf54372e6, 0x739e8677, 0x3ea55179, 0x73de3a0f, 0x1ce91d12,
- 0x994c76a8, 0x7de911f6, 0x71bbd227, 0x48b5bea8, 0xf08be8d7, 0x220573fe,
- 0x16c07bc1, 0xa15b3db9, 0x5c139d97, 0xdfe8d9dd, 0x6c73ab3f, 0xcbce2586,
- 0xe51e3adc, 0x7adb56fd, 0xe2e653a2, 0x38c058eb, 0xf4cbcebf, 0xd1e81978,
- 0x82b7fe79, 0x8dd62a42, 0xf886c2cc, 0xe70bf557, 0x01d13e89, 0xd7f2bbfd,
- 0x5ddd7199, 0x1c66f5b6, 0x82d684cf, 0xea3c386e, 0xe6ec0fba, 0xf4cbcef3,
- 0xb2e9e089, 0xc57bb9b9, 0xa33fa801, 0xee5e7bac, 0x6aaf6a3a, 0x09149ff4,
- 0x4367e07f, 0xf568e8dd, 0x87263ce2, 0x3ac246bd, 0xb2c66c73, 0xec89784f,
- 0x0dbf5513, 0x9dad4fe9, 0x91bafa72, 0x15d763e4, 0xf244cf9d, 0x07305e53,
- 0xbcaf9fde, 0x7b720d6d, 0xa3bf6bbe, 0x1cf7c45f, 0xf3e3f902, 0x764dbf73,
- 0x2e77359d, 0x56b3e7b7, 0x98549179, 0x3fa1f04f, 0x5bc54f31, 0x195f569e,
- 0xa0b7171d, 0xd4de30fa, 0x2c59d1ea, 0x2abe90c0, 0x70f3fcc2, 0x40bb3b7d,
- 0x5972d7b1, 0x2d2bda31, 0xc863df26, 0x420d960f, 0xe2a1c23a, 0x8e814575,
- 0x7c8620e8, 0x942667b0, 0xb465d95d, 0xd3ccfaaf, 0x5f980417, 0x4366df17,
- 0x8cdbd0be, 0xb31bc47e, 0xa80d1f8a, 0xffc24df3, 0xb7b22533, 0x2f848eb0,
- 0xfc79397d, 0x86c7966e, 0xb032eceb, 0xa7f248a6, 0xfdf380b6, 0x927e5907,
- 0x8ddad10f, 0x7bd2041b, 0x66377caa, 0xc237d932, 0x5c8cdb78, 0xd25f80ce,
- 0x3ebf402b, 0xffa017a4, 0xf7b35a17, 0x7ba205e9, 0xadf1e519, 0x12efb152,
- 0xfe1fb90b, 0xca898166, 0x547eca93, 0xc336717f, 0xaffc8235, 0x8430f2aa,
- 0xc7ca94df, 0xf1f26533, 0x732f224c, 0x2e3f7195, 0x5cdc7ce2, 0x5fb97b14,
- 0xfb7a339a, 0x8d7a4b1c, 0x90285287, 0x98dd79e8, 0xc52e4987, 0xa3396f12,
- 0x5da33788, 0xa7073fa1, 0x73fdb513, 0xaaffde45, 0xb274e620, 0xe51472b4,
- 0xa4e92c41, 0xde83cfe2, 0x79ff97cf, 0x68da47ec, 0x99a3e3ae, 0xe042d4f2,
- 0x2e9cbf93, 0x96e583df, 0xbbdb23d7, 0x772f63f3, 0x72801ed3, 0x37df04f1,
- 0x79b3e923, 0xfb97b185, 0x48bed14b, 0xf845f6e1, 0x3d15cbfc, 0xd2794b14,
- 0x11b36504, 0xff011fd6, 0xfcc28e8f, 0xef5073cb, 0xe5817b72, 0x0fa4b99e,
- 0x67e1dfb1, 0x3ec42eb2, 0x1c147b06, 0x0543b441, 0xeddd9239, 0x2d7efd8d,
- 0x643f487d, 0x5c61ccaf, 0x2ff3a81f, 0x7af8e12c, 0xb0e0147a, 0x25eade00,
- 0xc29baf6e, 0xbfcb50e0, 0x7dbd8c2d, 0xe043e92a, 0x1fbb0548, 0x444205cb,
- 0xd0a7af7b, 0x1a7e7318, 0xe2d9780b, 0xe4918d60, 0xefd8c9c9, 0xca0d9a4b,
- 0xd3cee9aa, 0x4b96d728, 0x5c60e787, 0x1ff8fbf9, 0x79d21be6, 0xc1a561be,
- 0xaeff45e5, 0xbc3bb24b, 0xac478c76, 0x7ccafaa2, 0x52af43bb, 0x94dfb63e,
- 0x6c05db7c, 0xe57d51d7, 0xda1f24ef, 0xd617dfc3, 0xf1c6c99d, 0xfb1deb36,
- 0x959dc618, 0xe78d837c, 0x9e36ac1b, 0x3c6d109f, 0x29b560ef, 0xcf1b0779,
- 0x4a6d583b, 0xf3c6c1de, 0x929b560e, 0xbcf1b077, 0xe4a6d583, 0xef3c6c1d,
- 0x7929b560, 0x3bcf1b07, 0xde6a6d58, 0x1538d3c1, 0x9e3691e3, 0x78dab077,
- 0xe36ac1de, 0x97980779, 0x3c6c1de7, 0xf17000ef, 0x722d83bc, 0x943ac1de,
- 0xf1ff2077, 0x67a49618, 0x547f5fb8, 0x7b06cfa9, 0x786334dd, 0xe76ab55e,
- 0x17182dfe, 0xfc7209ab, 0x5e783955, 0x77b414d9, 0x457e300a, 0x04dfb066,
- 0x114565fe, 0xb0d5f0c3, 0x13f3c3f9, 0xbde7d9dd, 0xb0a3fa02, 0x03bc2997,
- 0x18ea29e5, 0xfe7c3f7f, 0x3b577161, 0x65d6e78f, 0x3bf08b7e, 0x78482cbb,
- 0x8718e7c3, 0x13f253ad, 0xffad56b5, 0xb2e67f2a, 0x995f71f9, 0xf80899d4,
- 0xbb6d4590, 0x8c2ff988, 0xd7f15ebb, 0x6ab7dc61, 0x15771b50, 0xb8d41b33,
- 0x844bcf3c, 0xe1df39c1, 0x6b045f1c, 0x2a7f016a, 0xc1cfe601, 0x53ae15a4,
- 0xa45e7c12, 0x881bddb7, 0x453bbcbe, 0xaa6814c7, 0x9e606404, 0x6a2012a5,
- 0xc654d286, 0xf24cd2ac, 0xfe9d389b, 0xf1bdd4d7, 0x030f28d9, 0x6c04467a,
- 0xf9a83c23, 0xbf580485, 0x2bfc8334, 0x332aeff2, 0x3a47bffd, 0xcc82eb50,
- 0x5d8238f3, 0x2f80cd62, 0x5c266ef9, 0xceab9336, 0x45eb6f90, 0x73c335e6,
- 0x9b37e941, 0x2d4e2905, 0x76f28933, 0x6541ccb5, 0x695774d1, 0xcea3f011,
- 0x7ae175ec, 0x0966ecaa, 0xee3d85f9, 0xf148db3c, 0x32e97ae4, 0xf60049e0,
- 0x48da62f8, 0x2ec88a76, 0x451cf8ab, 0x2f1f48bb, 0xadc92278, 0x61ebd88a,
- 0x0a2a83b2, 0x2dc7c919, 0x7cfcb22c, 0xcfcb84ac, 0xdf5d4b37, 0xfbd73c44,
- 0x878fd516, 0xd0be8f2e, 0x6d9b794a, 0x5bc2f161, 0x6f628afd, 0x90e72447,
- 0xe901b93d, 0x8f04f17a, 0x1688e10d, 0xf62a78c7, 0x1b49ecf0, 0x767baec1,
- 0xd45aec14, 0x2aecb743, 0xfa9399fb, 0xb1ca3b50, 0xd0ba4f0e, 0x9092baef,
- 0xc3ddaa38, 0x8d67143c, 0x6979af1c, 0x9920e214, 0xfe13bfa8, 0xea639d0b,
- 0x87fb023a, 0x54bcfbe5, 0x428ef8e1, 0x634be387, 0xa0d317cf, 0x613e27d4,
- 0x771b8d0b, 0x970e0459, 0xf5c0d041, 0xfdff62b9, 0x78f624a0, 0x7d72812a,
- 0xf22efca9, 0xf974d561, 0x7caa5867, 0xbae1df3b, 0x2d29fc40, 0xf9024faa,
- 0x767f66bc, 0x0689ea01, 0x2ae35edb, 0x52d5f780, 0x3a22fdf9, 0x5b1ff46f,
- 0x1eb16e1e, 0xf7bc478f, 0xa3cb22b9, 0xc50911bb, 0x28de4fe4, 0x67e4fee2,
- 0xfe288784, 0x638bafe4, 0xea7b2fbe, 0xc9fc8673, 0x5b1ffe70, 0x639de3cc,
- 0x068e0147, 0xf1465728, 0xc28ca6eb, 0xbf5a8dfc, 0x443ebf6e, 0x854110ce,
- 0xdc6c69e6, 0xfc1163af, 0xba35973d, 0x147b37bf, 0xf310b1d6, 0xf591b571,
- 0x31c57dda, 0x7e96aff7, 0x3307ca03, 0xd0a9fd5b, 0x6f30bcc4, 0xb2be50da,
- 0x0fafd5c9, 0x383f738d, 0xe537e0e1, 0xb37e7008, 0xf272e638, 0xf91e9c7c,
- 0xe119bd75, 0x7e066ae9, 0x255fb08d, 0x9bffdc25, 0x9611e13b, 0x3a637688,
- 0xe411f743, 0x3637cf09, 0x83637e29, 0x2a767fa2, 0x2c53d472, 0xe52ce952,
- 0xe851b9f5, 0xfbcad7fa, 0xb69c4a8d, 0x2bf26251, 0xec7ff491, 0x38fce6e9,
- 0x71c6e728, 0xf30def38, 0xf453dfcf, 0xd3d89ec4, 0xa00c9ecf, 0x91b5b993,
- 0xf63075f1, 0x0274b174, 0xf6d4bfcc, 0xf8901cf4, 0x0d9b2fb0, 0x2e9c5f94,
- 0xef0c58bf, 0x57c28b6d, 0x69782b9f, 0xb03a3e86, 0x34a05bfb, 0x9010f942,
- 0xfa405481, 0x6fec55ed, 0x14308e01, 0xf1de0420, 0x3af4e7e8, 0xce7c1ee4,
- 0x7fe46d5c, 0xca1bc884, 0x3999569f, 0x83a774df, 0x0efe88ff, 0x9339d333,
- 0x9fcf20ae, 0xfcf26576, 0x6a3c3868, 0x456ff4fe, 0x71cf198f, 0xc4166577,
- 0xebddf285, 0x6f26989b, 0xe78575dc, 0x8a4fc185, 0xc949fad3, 0x8f8527e4,
- 0x74b9909f, 0x247fa85e, 0x021fdcc8, 0x5c50267f, 0xa917e43c, 0x7c98cffe,
- 0x7ff15cf9, 0xcd1dfd02, 0x4947119f, 0x07308b0f, 0x74ddff3e, 0x8f10dff9,
- 0x1fd3d023, 0x9fd3d0a3, 0x347fdfb0, 0x11cc627a, 0xf0cc68b7, 0x1eb2bb71,
- 0x708eb5b7, 0xd321203f, 0x54ce9119, 0x9b7a02fa, 0xe8763250, 0xb4f3217d,
- 0x4b136f4a, 0xbd3ebf8a, 0xf0bec05d, 0xafe1acef, 0xd149d6ec, 0x7ab59dfb,
- 0xfa0f28cc, 0xf19bd732, 0x99d4c49e, 0x6bce072e, 0x006c9911, 0x3e5cbb38,
- 0x007b9e33, 0x64bf2f3b, 0xcdc1bc84, 0x7e3f2e22, 0xdcffecad, 0x2aff9c09,
- 0x7dbe0b96, 0x6c4d7fc0, 0x4df70197, 0x4958ff7d, 0x7b88fdec, 0x35ee4872,
- 0xf7208c96, 0xe2f8565e, 0x2b5f0573, 0xe729d6da, 0xfb445899, 0xfdec5567,
- 0x942b348c, 0x45d75273, 0x745be3a4, 0x2285e787, 0xe21467ac, 0xe4c7e7e0,
- 0xcd4c3ce0, 0xfc406d2b, 0xf1c4563e, 0x7dfecd17, 0xb3fc146a, 0x4ad70089,
- 0xfd0199f6, 0xc7ff5969, 0x11e748ac, 0x39d9158e, 0x0390069c, 0x5995df80,
- 0xfc31b7ba, 0xb5a495d9, 0x67f7d487, 0x67aefe2b, 0x5267e414, 0xf1c3ce0e,
- 0x4c0e7e1a, 0x3ec5cf2d, 0x88b4b01e, 0x80ffb9fb, 0x73fc0efc, 0xe358a4a8,
- 0x64a8fee7, 0xb5f73f64, 0x1adc8f7f, 0xcba8e850, 0x7d9ed911, 0x40fbf621,
- 0xdd60e0e7, 0xb9157cef, 0xaa6f6e11, 0xdbd89ee5, 0x7a59697b, 0xd1c3879c,
- 0x24e7b4c8, 0x28dff16e, 0x8f5d2de0, 0x77e968f3, 0x5ffae325, 0x1a58c385,
- 0xe78c73f3, 0xff31e867, 0x7d79f9c3, 0x94be2ba9, 0x198f36ec, 0x07d837f5,
- 0xb95f6714, 0xcd1f2539, 0x6b67d82a, 0x93be96a9, 0xefa6474a, 0x403bd2e4,
- 0xfc9caadf, 0x534c6117, 0xa899bca8, 0xa5699bc8, 0x29afdfb1, 0x8e48af18,
- 0x632baf2c, 0x73dbe71f, 0x79744e77, 0xfb379eac, 0x4f1b4147, 0x8f25bd6e,
- 0x69474e63, 0x7921faa9, 0x7087eaac, 0x5e868d3c, 0x0bd10c48, 0xcce4510d,
- 0x3631c068, 0x9db51f04, 0x98afe502, 0xc0a6f98d, 0x39d89daf, 0x96c7dee4,
- 0x4f138851, 0xc87f8d0f, 0xa047af60, 0xb1a5dde3, 0xbca37fcf, 0xdb7c37e9,
- 0x47f9d236, 0x28c5d5a3, 0x3173623f, 0xb19fec3b, 0xf6f295b3, 0x94ad05c6,
- 0x029d6687, 0xf498fde5, 0xab79f92e, 0x30a7de6c, 0x9e5c367d, 0x5e398d6c,
- 0x97d8728b, 0x28c537f6, 0xf8ebcd7e, 0x37f93a4a, 0x153ca3af, 0xb347ee24,
- 0xf74ecc0d, 0xb97cafa4, 0x202f58fb, 0x9a2f3012, 0x763ee8c4, 0x7ac7e1a7,
- 0x051b47cc, 0xe65cfe3e, 0x974ff9e7, 0xf0a3fc77, 0x31a0e59e, 0x7f543b7f,
- 0xfb4d9a51, 0xcfe569de, 0xf39bf6bb, 0x9ea5849f, 0xc19e15b6, 0xa753e1f3,
- 0xec1c5327, 0x6b8f03c5, 0xbc5aecec, 0xdf7e80c7, 0x7e861e0b, 0x35d329a2,
- 0x9c3b2471, 0xae927f31, 0xa89a508c, 0xfa5e7a94, 0xf86d9d05, 0xf7f73bfb,
- 0xbd67e848, 0x724cc078, 0x9e81ea7f, 0xe32155f8, 0x3e719627, 0xfe3d06b6,
- 0x35af0019, 0x093273d3, 0xf92b1def, 0xce799173, 0x632bc2d4, 0x0f9d00a4,
- 0x6b5791df, 0x2ebba50e, 0x794cd6a9, 0x639d5ce4, 0xfceb1d8a, 0xf4fc431c,
- 0x4082fdda, 0x112edd7e, 0xe19aef50, 0xec7a86ba, 0xc3eb890d, 0x496b53a9,
- 0xe72a75ab, 0x2de4761e, 0xc7ef8039, 0xf1a7af4f, 0x7b64593b, 0xe5c658cc,
- 0x99068bf0, 0x80f17de6, 0x55c8e748, 0x7c69debc, 0x0f30cbd6, 0xa6dea3e0,
- 0xa7d87ba7, 0xe5114e8d, 0x8134e9d0, 0xdf2d82ed, 0xee8578e9, 0x0288ec99,
- 0xb94a2fef, 0xa96cca9f, 0xf7a77f44, 0x748f2e77, 0xbfa55f7e, 0xa96433c9,
- 0x49c0ed0c, 0xff94269e, 0x36e4b6cc, 0xdf24f17c, 0xe68743bf, 0xcffc03cf,
- 0x227fc17d, 0x6b21f70e, 0xf75c78cf, 0x6a76a507, 0x1f0f45bf, 0xb0f442bd,
- 0xe3efc8c5, 0x8e717578, 0x858eb003, 0xcf1101d6, 0x8352184f, 0x2a6de794,
- 0x8b74f2e3, 0x81630fca, 0x7d3de01f, 0xc507bf06, 0xcea9da26, 0x84270726,
- 0x559ea3de, 0x0597aca6, 0xc2f9f132, 0xd83777f8, 0xf6158c1d, 0xb08b37a6,
- 0xef8985fe, 0x7a86c86e, 0x5e78ef49, 0xb3f778cf, 0xb2b1896c, 0x9f5e0cde,
- 0x9367eef6, 0x9bd15ea0, 0x3095ebc9, 0x9bb078d4, 0xbd9ab37a, 0xa4be3879,
- 0x0f15bf19, 0xfd7f1472, 0x45d26f52, 0x28355f8c, 0x031f87eb, 0xfbece3ce,
- 0xe2ef3a47, 0x78fd5b34, 0x86c9832e, 0x3419f8b0, 0x6077dc85, 0xff2409a9,
- 0xf30bfbd4, 0xf63f7f45, 0x84fd99d7, 0x2759bbdf, 0xad8073d9, 0x7e145fdd,
- 0x5c2e7b79, 0xc8d96dee, 0x8c4e785c, 0xef0966b1, 0xd64c0833, 0x78e3c17d,
- 0x855f9c4e, 0x187f9d47, 0xc8b5b05c, 0x3d70439f, 0x70a8e34f, 0x7937cb5d,
- 0x6b7ade51, 0x0427ae59, 0xe084d74f, 0x456c180f, 0x0f1dacda, 0x1b5d3ee1,
- 0x40209c13, 0x1b7cb93d, 0xb1b5dbed, 0x8e081fc1, 0xef81ba90, 0x096f5b63,
- 0x289763ed, 0x9b9d21b7, 0x216ed68c, 0xb8eeb191, 0xe60c1984, 0xe5d631d9,
- 0x406e7bc5, 0xd8ef7477, 0x1c74659b, 0x8beb3800, 0xc7a1f9b4, 0x83fb3a15,
- 0x98e60f22, 0x01ce7976, 0x047bba5d, 0xdc70f786, 0xa88c3783, 0x5df616ff,
- 0xa4be6234, 0x11a2e7a3, 0xeb03bee9, 0xf3c74e30, 0x6ff988c6, 0xbd5eb963,
- 0x91e74a2f, 0x4f1c4bd6, 0x7aeeb2a7, 0xe9e0152a, 0xbdd02d58, 0x9247f5bc,
- 0x7d7d60e6, 0xb192ae2b, 0xe78755e5, 0x38b4b920, 0x72c29ffb, 0x95381b25,
- 0xccb4240a, 0x10f667a5, 0x4d62b93d, 0xe887b33c, 0x8a4f16c9, 0x1772bea6,
- 0x280cceec, 0xfa686637, 0xeafee531, 0x83f43632, 0x949a98e7, 0xdb665c7d,
- 0xeeb8c019, 0x3bc19732, 0xc2de3210, 0x3262cdbe, 0x1c11edc2, 0xcbd28d74,
- 0xe0ad3fcf, 0x1c52842b, 0xf7cf1f7a, 0xefc40af4, 0xba7a6d1d, 0xcbdcd3c7,
- 0x35e6aeed, 0x202ecf82, 0x0dbdf81e, 0xed40af77, 0xeba7deee, 0x1bef1193,
- 0x47000f00, 0x7d84f8da, 0x9347112c, 0x4ad5dce9, 0xdf775605, 0xb38e0339,
- 0xdd023be2, 0x9bbf5567, 0xb2bfc2a0, 0x91ce91a9, 0xa45e7c01, 0x4d9d754f,
- 0x5ce947f6, 0x9789cad5, 0x6187a80d, 0x3406977d, 0x5bd6d4f8, 0xcafada3c,
- 0xd1fada8d, 0xf29ee532, 0xf90d3634, 0x209978e9, 0xb52439e2, 0xf9d651fe,
- 0xe75ef1b7, 0x0a79d16e, 0xe8cdb3e9, 0x7efa819f, 0xbaa2e8b7, 0x3bcf0eda,
- 0xf89df118, 0xb1f100e1, 0xc5b9fc40, 0xf8354b20, 0x8176973d, 0xb60576e8,
- 0x0f67f3ab, 0xfd754fbd, 0x554dfaf0, 0x1b9c5aee, 0x4730bbe8, 0x90ed0905,
- 0x9316517a, 0x222f88f3, 0xbdf9779e, 0xa36f07c2, 0xeeb803f6, 0x7d852242,
- 0x44feebba, 0xbde6179f, 0x3a56cdeb, 0x215776e7, 0xf91d81d0, 0xd6e7475e,
- 0x2f79e3e6, 0x7903ef28, 0x2ef28168, 0x9226a1fd, 0x128d33ef, 0x9ce577c9,
- 0xe42f2a97, 0xb6e7b517, 0x219e67e6, 0xe7beeb3b, 0xb579d276, 0xc17239c9,
- 0x2d0fa8d3, 0x471dfe7c, 0x1866df04, 0x34ef23a7, 0x3271cfc9, 0x61d72f3f,
- 0x2f68e453, 0xfd7551c8, 0x50e3bfb0, 0x692261ae, 0x9bcd1e41, 0x5da9566e,
- 0xf8283926, 0xffe8756b, 0xdde6538e, 0x75a76d5f, 0x487a3da7, 0x316775c0,
- 0xe60166ef, 0x7c3a82bb, 0x55f950ec, 0xf8b5d7ed, 0x565de80b, 0x5b63b5af,
- 0x65e3d745, 0x6dbb5f30, 0x2dcfc8c0, 0x1fa88d06, 0xdef8e0ee, 0xf2c3e348,
- 0x50ee7475, 0x4730fbe2, 0x7680983f, 0x39a3face, 0xf608d8e3, 0xd3acde8d,
- 0x148311c8, 0xf33791a7, 0x67f2b573, 0x772b43a1, 0xa39651be, 0x4f245f69,
- 0xdfdfb4d3, 0x3fa9a858, 0xbcd4ace0, 0x9d5360ff, 0xcdb26ea6, 0xb16fbcd3,
- 0xe3d4d62f, 0xde6b9773, 0xa558e31f, 0xf5bd3769, 0xed0126a3, 0xc077b371,
- 0x06e87805, 0x1e4b28de, 0x12d323d2, 0xe32865e0, 0x2c562d0a, 0x744df3bb,
- 0x3c7bb64e, 0xec4497e8, 0x773a1dff, 0xc97c4e69, 0xdfe5035c, 0xfc5abe0b,
- 0xc9a00e7e, 0x3ddbf685, 0xf0e3684f, 0x5f38abc7, 0xb94365a9, 0x280ac1eb,
- 0x67b05ef3, 0x81e97bf0, 0xcc7f707b, 0x45db8c71, 0x2ec999af, 0x5376899a,
- 0xb071bf88, 0x397e66ba, 0xbe427bf6, 0xf582f917, 0xbc0a6932, 0x3b08cfb7,
- 0x35ee7a8b, 0xebcbf523, 0xe685d01d, 0xce597ff7, 0xceb3c1e5, 0xfc717bda,
- 0xb2d03e8e, 0x7dcf4fc8, 0xaebf4468, 0x013fafa3, 0xe70cd9f5, 0xcfb44687,
- 0x7a2b9e87, 0x61c60c4e, 0x0e1fe39c, 0x63de23e9, 0xa46e5edd, 0x722b4ff1,
- 0x7a3be5bd, 0xf78b4f3a, 0x864a6b37, 0xe1cb73e4, 0x63ef1fa0, 0x7bf3b4b7,
- 0x368e789b, 0xf9069c92, 0xbca861fc, 0xf41d367d, 0x4f1a4cc1, 0x97960fa3,
- 0x3edee9f9, 0xfbcd6fc8, 0x5c34972b, 0xc8257cc5, 0x4cf3ed71, 0xb1961e7e,
- 0x73fa0301, 0xed35d720, 0xfb95cb1b, 0xde58d39c, 0x2e072017, 0xdbdf2338,
- 0x9f8abb7d, 0xaae0b833, 0x16787da3, 0x47e789f0, 0x3f861d9f, 0xe1dbd78e,
- 0x81a465ed, 0x661bfd90, 0xff7157ff, 0x7228e5ea, 0xbfb2a2fb, 0x014084fb,
- 0x33b7550a, 0x8577e88e, 0xa5ed75b9, 0xcf97dc42, 0xdebfa2b7, 0xee8123f2,
- 0xffb2ffc1, 0xac3b34ad, 0x54f878df, 0x7697de1a, 0x86953a1f, 0x0cdb89f7,
- 0xcf68cdf6, 0x3dd07d03, 0x3f5e8ee4, 0xa87edfc1, 0xb79f1fb0, 0x140e0af7,
- 0xeb9eeec9, 0x364eb40d, 0xa3fd15b0, 0x3ae0517d, 0xabedce58, 0x2a76e5c3,
- 0x13982edd, 0xc98f7ef5, 0x1e9013e7, 0x5c213e40, 0x820fc047, 0xe66dbefa,
- 0xd4f648a6, 0x27df0565, 0xde1919b7, 0xfe836dfb, 0x59d38eb8, 0xbdf88da7,
- 0xb0c39685, 0x71d7012e, 0x1c7881ee, 0xa181837f, 0xf7c2a19d, 0x03e05671,
- 0xabfbff5c, 0x2dcf0c0d, 0x27ad596f, 0x81bfbf7c, 0x87fa27db, 0x0335bd7f,
- 0x2e80cbea, 0x270f3bf1, 0x9d38df56, 0xbfbee301, 0x7569db86, 0x2f881b0f,
- 0x6e13ad97, 0xa50e4bdd, 0xff6e956b, 0x70d3a146, 0xdba70dfa, 0xe6baf461,
- 0xdbebd1eb, 0x90ecb7e5, 0x61f7a819, 0x438ce7ff, 0x731efa3a, 0x1a7e401c,
- 0x0718613c, 0x2ada4f70, 0x63c3c039, 0xa7bef5d3, 0x9c6e50d2, 0x6df9ede0,
- 0x7f2e057b, 0x7d71cbec, 0x8646dd19, 0x2a2e08f7, 0xd95176fb, 0x0a0b3b37,
- 0x62cfc8f1, 0xa9ca1260, 0xf9ce256c, 0x1d35818a, 0xe452ff46, 0x8ffa67f2,
- 0x87b77b6d, 0x2b7fefd0, 0xcaab74e7, 0xe64669c5, 0xf7c56c3a, 0x045f8d0f,
- 0xe06cbce3, 0x282735e7, 0x09c94de3, 0x52822c36, 0xe4e5c157, 0xd438156f,
- 0x3e149ffa, 0x437f2760, 0xe6685cf8, 0xd1b79ff8, 0xf8eb8cdf, 0xbd75c999,
- 0x305fde1c, 0xea1b7ce1, 0x3f49eebd, 0xb9dfe3c9, 0xee1d9073, 0xa27ff056,
- 0x63cf37fc, 0x3532cfee, 0x72d7f68e, 0xe90969f4, 0x68a532d9, 0x30f148dc,
- 0xe66ccdf7, 0xbaba014a, 0x5aa54399, 0xaafc745f, 0x82fc8071, 0x2fc40deb,
- 0xb9e9d337, 0x0553efda, 0x8e46e9ee, 0x4a97d607, 0xb6e41b7a, 0x67921658,
- 0xfaa0f150, 0xfb2996e3, 0x5b1ebf69, 0xcfee28c7, 0x8f84d3d8, 0x84e76d15,
- 0x41e71856, 0x02b06c83, 0x3627cfbe, 0x8534bdad, 0x626c9fb1, 0x3a0b05cc,
- 0x5cccc9bb, 0x6c7d0377, 0xd81ea892, 0xbbfaa364, 0x5e54ec9b, 0xa2c738b6,
- 0xa4e079fe, 0xede20a67, 0x671ed644, 0xed73cc2d, 0x41f081ac, 0xfdf4063b,
- 0x376b4298, 0x0cccf4fa, 0x947a37ed, 0xf028adef, 0x8333743f, 0xfcbe40b9,
- 0x8e83e702, 0x467f1bed, 0xe6b1cf72, 0x49fa037a, 0xb7176df9, 0xf1bddd62,
- 0x5f680d77, 0x04fa007c, 0x7eec0ce9, 0x9e501366, 0x81da339c, 0xa66f9a0e,
- 0xeb2f38d0, 0x77c80d82, 0x430263de, 0xf7a0fcfa, 0xd71c71ba, 0xe12d7457,
- 0xe6744df9, 0x48ad2d9f, 0xfbb8fc22, 0x7f7c75f2, 0xf7a1748b, 0xf9effa29,
- 0x87ee0243, 0x9dfda379, 0x467fec4a, 0xb7af90cf, 0xa41306d7, 0x02f87208,
- 0xa3978b8c, 0x86581d70, 0xbd1937b7, 0x413cf053, 0xe1c74293, 0xfa158bed,
- 0x941b4c04, 0x213229ef, 0xc1239f8d, 0x5258169f, 0x41f93262, 0xe7e038fe,
- 0xabbabe96, 0x811e9622, 0xcff5a87d, 0x762187d8, 0xfc3a347c, 0x437e25b2,
- 0x4329c3e6, 0x4323f475, 0x1fa07fef, 0x82fbe919, 0xe3c9aca6, 0xb9778a46,
- 0x83bec007, 0xc300eafd, 0xf4829ec9, 0x4fca8d3e, 0x91d9748e, 0xc171cc7f,
- 0xd82fa83d, 0x3bf23a5d, 0x7b5abdda, 0x87e141a8, 0x7a1ec506, 0x3feb42b4,
- 0x5ed49f81, 0x84a4fdc1, 0x3fe34ce3, 0xff273f85, 0x057c8cc9, 0xfd834ef3,
- 0xfed22579, 0xc7aed554, 0x2ed8137e, 0x740673a2, 0xbe15f48e, 0xe0a8bfce,
- 0xebe5547a, 0x48d7c865, 0xaf9cbdbf, 0xa96dc7c3, 0x1c0bf9aa, 0x7b945b77,
- 0xf157f710, 0x139fdaf1, 0xe7ee5f08, 0x1f4f0852, 0xb59ce7b3, 0x031f9740,
- 0x2e80fb1c, 0xf19d39af, 0x9affd049, 0x6c9f19cb, 0x1d03921d, 0xbf53c5cf,
- 0xa717936d, 0x19fd42b4, 0xef187ba4, 0x8a3ade93, 0x1cf43e6f, 0xbe753fe7,
- 0x52cbfc0f, 0x0d8a9f90, 0xda03a341, 0x262efb33, 0x7c581da0, 0xe414fee4,
- 0x6e7068c3, 0xdce054ad, 0x4bdad8f8, 0xf01e9c29, 0x455aee1c, 0xf49fb9bf,
- 0x6bff111b, 0xdfa23237, 0xd97ed7fe, 0x49fc7c81, 0xfa84bc5f, 0xf1a3e3f0,
- 0xd7ff945e, 0x3a7c998e, 0x6f10fc81, 0x8fb5c822, 0x91f7030d, 0x2f4479bd,
- 0x3ee8ffa1, 0xc83ddbf6, 0x4cd7ee8f, 0xb5b1f968, 0x51d75d7d, 0xddf5b5ef,
- 0xf2c4557b, 0x87e5d1a5, 0xd38f8df6, 0x6ffad57a, 0x28ed9937, 0xb9113f47,
- 0xfbdb589c, 0x6bbfd92a, 0xc0cc6f07, 0x47c7ea38, 0xca094fff, 0x379bf735,
- 0xb99e504a, 0x8251b8df, 0xc71feeed, 0x2dd9227b, 0x84f4b371, 0x665f5557,
- 0xe26a27bf, 0xfa141b45, 0xd5dceec8, 0x57f00938, 0x03896e7c, 0x7b6ab6f3,
- 0x139d14f1, 0x79fe2fdf, 0x21c3ca7d, 0x22033afd, 0xce8a8de5, 0x0eafc7d5,
- 0xaa47cba1, 0x94ef9a0c, 0x0f38d57d, 0x2df7e2b6, 0x0275c56f, 0xec0efa3a,
- 0xbfc880b6, 0xf046bb2f, 0xf601bfa1, 0xb23f784b, 0x923daea7, 0x9910f742,
- 0xbd3f9ce8, 0x1c53eb08, 0x5628eddb, 0x8726a7cc, 0x02cb4bd8, 0xe809bf3a,
- 0xe4cfa9a8, 0x203f7b27, 0x62baa45e, 0xfd743d47, 0x85b26337, 0xdc9a7108,
- 0x1ca0e777, 0xc0d78f0f, 0x5b8418cf, 0xa7ceafb5, 0xa651f8f3, 0x042dd247,
- 0x993b9ab8, 0x161d7884, 0x4b9a69d7, 0xf8f0a2f1, 0xdbb03d8e, 0x93ecfd8c,
- 0xabc21275, 0x8fb8a5da, 0xc0e4113d, 0x7972565f, 0x6757f2a6, 0x3af5e780,
- 0xc9e6b503, 0x69577e50, 0xcc7491ef, 0xece9780b, 0xc600ffbb, 0x1f073a17,
- 0xf30e9f8c, 0x98b7be74, 0x9ae79e61, 0x829e6b54, 0x9ae706fd, 0xa21bc81f,
- 0x1af9f09b, 0x345db92a, 0xd6442f64, 0x5f0aa57f, 0x2c1e968f, 0xd0f3fcac,
- 0x579fe083, 0x7cff7254, 0x709f8f05, 0x7f5c3cff, 0x1d5972a8, 0xef82ad77,
- 0x2af972e1, 0x47e039d9, 0x5b5e5c93, 0x32f7a769, 0x90a516fb, 0x92defd7f,
- 0xf875bb14, 0x43a239f8, 0x7c379c97, 0x739ed57c, 0x6653e57b, 0x3d647bf4,
- 0x897ba7f1, 0x97fcc3e0, 0x9db9ff6a, 0xeee5d902, 0xdf0f8366, 0x2c0ae153,
- 0x07d8f1e1, 0x22cf8364, 0xaa89d90c, 0xddab791d, 0x6abb5021, 0x63f6aa57,
- 0xbbe3c9c0, 0xfb788a4b, 0x556b8b65, 0xa75c58e5, 0x97179e85, 0x398ce7f3,
- 0xf55fa14f, 0x918152e0, 0x4aec501c, 0xedc34e95, 0x72fb4fce, 0x438a4712,
- 0xa7d0af3d, 0xc21367ca, 0x63d543f8, 0x7e7054cf, 0x5e3d40eb, 0xf7fc7a88,
- 0x7c3cfb1a, 0x8fe3d05c, 0x463f5257, 0x2e7e8bfd, 0xebf9233a, 0xadfc6566,
- 0x4e05feea, 0x59bc20d6, 0xfd19b02c, 0xf5fa68cc, 0x139d8a7b, 0xc519fdad,
- 0x3f1dbc7e, 0xc8e4561f, 0xcbf3f168, 0x70f2b795, 0xf9f9a9ff, 0x8c687d96,
- 0xd557bf62, 0x1ffb86bc, 0x6a04f7a7, 0x97feff90, 0xe1eee281, 0xfaa53def,
- 0xecd3229f, 0xa32ca9cf, 0xf723fd0e, 0xe83f1e1a, 0x43bfb24e, 0x7a5bcc7e,
- 0x05ace386, 0xb8ed107f, 0x51266f47, 0x32f686d9, 0x385e2b94, 0x1588f947,
- 0x77f0b46b, 0xfb174c63, 0xf3a6cbaf, 0x9eac2d03, 0x7d2d4ce2, 0x5016d249,
- 0x0f63dd0a, 0xf2be469d, 0x0fdbd01e, 0x88ffbe84, 0xc799befa, 0xfba636e1,
- 0x661af728, 0xc278b40f, 0x7dad7eed, 0x8dc4a950, 0x6f09d9a2, 0x5cb85bf4,
- 0x3e27a339, 0xd378c0ef, 0x7d8cc64c, 0x37b82e5c, 0x474938f2, 0xfc04e6df,
- 0xd2bb6a08, 0x500c457e, 0x6bf28a1c, 0xbed5eaf0, 0x3ee8d3a7, 0x27cdac97,
- 0x39ffefb5, 0xbcf0cbc9, 0x970f7252, 0xbd36ee4b, 0xa12a4792, 0x83b797ef,
- 0xed0e393f, 0x1bfdbb4b, 0x8b807788, 0xc8de48f9, 0x3ecbb89a, 0xe9f4af25,
- 0x3f257f99, 0x2891c574, 0x79eea479, 0x7ca48f3c, 0x1e787727, 0x0ca9f4e9,
- 0x48f3edfb, 0xe8e7bd1d, 0xf2edcb1e, 0x5baaa649, 0x3b8a1c71, 0x7c79144e,
- 0x209f6277, 0x626abc61, 0xe9775f1f, 0xafb238b6, 0x3ab57e1b, 0xba81e505,
- 0xe22c9f4f, 0xfde4fdf8, 0x5fb06acf, 0xc944afc9, 0xe37aeb02, 0xcb3f0dfd,
- 0xd9bb75e0, 0xc436fd8e, 0xc9f33fa3, 0x23c7d6af, 0x1280df7e, 0x17c7e7f7,
- 0xc9f1c8c4, 0x667578a1, 0x959dc515, 0xfa08b578, 0x5c50cc70, 0x8bdfbc27,
- 0x746e5c55, 0x7142bb83, 0xef3c23cd, 0x9aee9ddf, 0x9ebff547, 0x29dff8c4,
- 0xfd1e2990, 0xc635d02a, 0x62c1a68d, 0x3ffd2f31, 0xe62758e3, 0xbac7ba91,
- 0xf47c427e, 0xf23b3ad7, 0xfca7f411, 0x9db0f793, 0x6a8623f4, 0x0333cf31,
- 0xf7405b3f, 0xdf295231, 0x8fb28f73, 0xa2cfe0e9, 0x2cd0095f, 0x34f43cc1,
- 0x2333df25, 0xfe38898e, 0xfb6b830e, 0xf52fcc54, 0xc4cd8e8b, 0x3c148e04,
- 0x779e196f, 0x2f9e6412, 0x6a4ff357, 0xfe5a3cde, 0x9479c049, 0xf3f056ef,
- 0xf980b296, 0xc4cf3574, 0xf9293a96, 0x43cca5b5, 0x807c42f7, 0xde73afb3,
- 0xcffc846b, 0xf21115c3, 0x982beb3f, 0xf3699f62, 0x5f73db8d, 0xaafd3a21,
- 0x78c3c679, 0xe68ee2ae, 0x0fdcecc5, 0x28bb830d, 0xf234d3e9, 0x6ff8febb,
- 0xfb67a409, 0xbc3e906e, 0x00b13416, 0x78071fc5, 0x40cfbddc, 0xe06b8671,
- 0xd10d8dbf, 0xf054efb3, 0xd5f78f71, 0x04f7fd11, 0xfdf1e3ea, 0xb7cf2bdf,
- 0x7ee4b7bd, 0x01bdf7b4, 0xc60b1dfe, 0x13d63fb8, 0x6ed18b10, 0xf2fb83b9,
- 0xf5846564, 0x7eb8e399, 0x52a3e70a, 0xab4aff85, 0xdeeb9e38, 0x7b987ee7,
- 0x48afcf03, 0x7b705c8a, 0x74fd5e78, 0xc6a09a56, 0xca45c7d3, 0x92091cbf,
- 0x447968de, 0x7cc9efa0, 0x33cbfcd9, 0xf1f391e9, 0x462f7a2b, 0x3634bfce,
- 0x168cfc90, 0x638f0ecf, 0xff2a9dff, 0x7638f3a6, 0xeb44957a, 0xd7e4f64e,
- 0xeb43638c, 0xb0fb83bf, 0x7d845674, 0x6fe383b8, 0xf1db1d9c, 0x3b63caeb,
- 0x1e3113fe, 0xc78c7b7f, 0x6c7961ff, 0x8abaebf3, 0xdbffc2d8, 0x1fdfc318,
- 0x57fffe09, 0xe78407cf, 0x0bcfc3ff, 0x30039f84, 0x17b0f5bd, 0x9d84badb,
- 0xefc33f41, 0x24d6bf8d, 0x93141c80, 0xce7dd3f6, 0x1f3ce505, 0xecdeadb6,
- 0x9d0c2bdb, 0xf5f1501b, 0x23f73568, 0x5eebbca5, 0x04d45efc, 0x829f5039,
- 0xfe72b2f1, 0x59ae4377, 0x898c5e78, 0xc9e63a52, 0xc5f4cde0, 0x5b749760,
- 0x5359e722, 0xe9a2f195, 0x35d58391, 0xe315678b, 0x7c8a3d1f, 0x4a87ff0e,
- 0xe5ea521c, 0x6899e9f7, 0xf34c5f4f, 0x1ed1d3da, 0x9fc93c4a, 0xbc99f827,
- 0x67b2e097, 0xdc7fe62f, 0x7be11b20, 0x26ffc946, 0x1b2bbbcf, 0x60c9d2e3,
- 0xf05e6217, 0x920fcc69, 0x7bd12b3f, 0x66977cea, 0x19ea3f71, 0x9f301303,
- 0xcfca9deb, 0xdf9eb139, 0xe6a6fd91, 0xfc1acef5, 0xca055a97, 0xfc23b5eb,
- 0xf3f9d53f, 0x442b65f6, 0xebcdf80c, 0xf8df2891, 0xe5dff976, 0x9e1e68ba,
- 0xe24c7be7, 0xbf409caf, 0xec78e019, 0xefd12168, 0xffe5e38a, 0xc7fe8cd4,
- 0x3cf09164, 0xe254afcc, 0x78941705, 0x502f1a87, 0xacff5bf3, 0xc03e49c4,
- 0x03940bf8, 0x72810f18, 0x9ddd2cfb, 0x67db4fd6, 0x67ffe045, 0xf21f1e04,
- 0x87c794fe, 0x9c8e8d0a, 0x7f94f3d0, 0x63ef8b35, 0x2fe79fab, 0x0fcf78d4,
- 0x7e14f595, 0xefc7ef4f, 0x9d6e15a1, 0x5f3d446e, 0x0e2b35b8, 0x4fb219cb,
- 0x5ef80697, 0x4eb0fab6, 0x7448bfdd, 0xe75957b4, 0xca4133b6, 0x961abdef,
- 0x8b34bff7, 0xa968679f, 0x097bfbe6, 0xd418a0ff, 0x6e229b1f, 0xb131f341,
- 0xca47d24a, 0x5f80b52b, 0x76b6708c, 0x7c55b873, 0x75edf8b7, 0x53c5cf38,
- 0x1658adc1, 0xa3aec9ac, 0xf5db7bb8, 0xb9bf68ad, 0xae9c6f07, 0xd19978a6,
- 0x43c4fe8e, 0xdbb8da03, 0xfe3cd513, 0xe01a2afe, 0x457bb788, 0xef0b8ff2,
- 0x927e8915, 0xbfe42c5b, 0xde981b26, 0xdc45f58a, 0x4c682a2e, 0x5b3ac3ad,
- 0x60f64492, 0xd27b19c1, 0x714379c3, 0x377be4b0, 0xdd3c458c, 0xc6aacf2e,
- 0xe45b2ed3, 0x5f9fb8e3, 0x7edacf35, 0x6f3a3df6, 0xc54baeaa, 0x8d2f9a8b,
- 0xcf556796, 0x3f1bb83d, 0x70d39cd3, 0x8c06c18b, 0xbd1e163f, 0x5fce5468,
- 0xa1ecb64a, 0x91e16c3c, 0x557f94eb, 0xcf6eadf3, 0xa1abb275, 0xf7fb119f,
- 0xd7f9e26c, 0x2c0e00d7, 0xb2dd617b, 0xdba1ef09, 0x7583eca8, 0x9b63f3e3,
- 0x6ff4a972, 0x7c795072, 0xf8951953, 0x64f4c999, 0xa75edbcc, 0x59d5edbc,
- 0x524dcec3, 0xe8b76f5e, 0x15f108fc, 0x7aa3f792, 0x1f4fde78, 0xee35e3c7,
- 0xbefa0633, 0x99acfba1, 0x5f4d77e4, 0x0ff444eb, 0x9ae73f3e, 0x60777088,
- 0x2e842dde, 0x961d913e, 0x9d83f424, 0xdbe60b0e, 0x1aaffb0a, 0x874c3cf1,
- 0x3c623018, 0xc0cf200c, 0x9eee8b23, 0x6fdcfceb, 0xf1058d5f, 0x58fcdb7b,
- 0x8fcfffef, 0x58fc957d, 0x273f3577, 0x0291caad, 0x8bde4ea7, 0xf2d919e5,
- 0xd89c8870, 0x94f9e4e6, 0x1127936d, 0x4e76ee1f, 0x321d5a4a, 0x8f23675e,
- 0x3bdf245f, 0xfcfa12d9, 0x1f3cd597, 0x67302c96, 0x33567924, 0xc7ddebfb,
- 0xd76e411b, 0x3ffbb244, 0xe5d029f9, 0x238ba04c, 0x90389edf, 0x343f19c7,
- 0x71adb71e, 0x2831c4f5, 0xd8982e9f, 0xd3af1e14, 0x5858e3c4, 0x5c5a2e5e,
- 0x4ea3456e, 0xa179d0b6, 0xdbd404e0, 0x2633f1e1, 0xbd702706, 0xbde0672e,
- 0x83319814, 0xf961b195, 0xdf305fb9, 0xfbc327cf, 0xa4751acb, 0x5d3cd42f,
- 0x36c8a341, 0x6c167d01, 0x3f28f834, 0xa45e28d7, 0xec6fc576, 0x90320a94,
- 0x6b383fce, 0x16ae3094, 0x34731f1e, 0x049eefee, 0x026d1dfd, 0x5dba0bdd,
- 0x073d4f1e, 0x3fdbd2de, 0xf96de307, 0x3d77576c, 0xac9fcff4, 0xf4fcf093,
- 0x3f1e7cf0, 0xd8a05dff, 0x3671e139, 0x4bb433a4, 0x1bf0e3c2, 0x38d83a15,
- 0xd7adeb9b, 0x1d537f14, 0x4e17ed47, 0xcd9d3f3f, 0xb8b46df5, 0xbc6551fe,
- 0x6d82c6ce, 0x177f7193, 0x93ea18e8, 0xf35ac6ce, 0x76f190e4, 0xdbe7e6cc,
- 0x60fcc19e, 0x907e686a, 0xf3c301e7, 0x2b9caa82, 0x037dffec, 0xc8377be2,
- 0x6e63d46b, 0x141fcf1b, 0x8339ab1e, 0x4e086372, 0xc377b7ae, 0xbec8079e,
- 0xbe312473, 0x457bfa2e, 0xc502a3de, 0x7c160ae7, 0xea1e3c76, 0xf74499cc,
- 0x2767dcb0, 0x3ca2b16f, 0xe316205a, 0x53b71ebd, 0xc26795b8, 0xeffdd27c,
- 0xbcefa1ac, 0x7f903e16, 0x81e5f70e, 0x0f9d0366, 0xfddef554, 0xf03534ef,
- 0xc64fbdf6, 0xe0ae7b61, 0x79f1d8b0, 0x763f7d23, 0xfa7e4bfe, 0x110b58bb,
- 0x81e7903a, 0xe44497b3, 0xd716cb9b, 0x151f23df, 0x4cf2522e, 0x3f4f5ccd,
- 0xc0c8b7d0, 0xead3cec8, 0x9f5913cd, 0x46e83c53, 0x8fe5215f, 0x43fcf052,
- 0x29be90de, 0x6c7a0a3c, 0x63d39dcc, 0x112d9d3f, 0x1e82673e, 0x17927843,
- 0xf87d3cf1, 0xf650effe, 0x8a5e9a3f, 0xff518726, 0xde63fbf0, 0x5c36c10c,
- 0xee31db8f, 0x3af68a53, 0xd3a2e394, 0x71661fdf, 0x628a4eba, 0xa149fdcf,
- 0xa7e7a8df, 0xcf27477a, 0x7fd987f4, 0xd563791e, 0x4df352ff, 0xa0f6bfaa,
- 0x65ab0f62, 0xbbfe5293, 0x72a037ef, 0x21bf788d, 0x86fdf239, 0x68090e87,
- 0x1bf7a8a7, 0xcd59194e, 0x4f3c54e1, 0xf277dcab, 0xe93b222d, 0x62fcdfd4,
- 0x78a98beb, 0x509049df, 0x3a1fb51d, 0x1dbe7a47, 0xa7b223ec, 0xe3cb7efa,
- 0xf9f887ad, 0xc8def6f0, 0xaddbdddf, 0x32f5dfd8, 0xaed1b923, 0xe86db79c,
- 0xb744f251, 0x8b8f96e2, 0xb74b71a1, 0x3d56303d, 0x7f23ebc7, 0x8cc71b4f,
- 0x60ecb716, 0xdbb73a41, 0xa07046b1, 0x39ddb87e, 0x79ca5ddc, 0x4c71a8dd,
- 0xb973e479, 0xb94c71e1, 0xb9c79b5a, 0xf7c4966f, 0x680825db, 0xce759aef,
- 0x7fb73a36, 0x9d22904c, 0xcd5a5ef3, 0x257cf4e5, 0xc8d0720f, 0x8560e3e9,
- 0xf06ff740, 0xfbee1e1e, 0x1efc63c1, 0x7e02c1ce, 0x7bcd470f, 0xa66bf7a8,
- 0xe83de50e, 0x2f7a9dfe, 0xc367bd47, 0x5ae08f98, 0x7d1c5cf4, 0xe1876bc7,
- 0xbddb8d90, 0x1a3f7e5e, 0x43e61065, 0x8913cc4d, 0x6bab6b5f, 0xef7a6ac4,
- 0x8f4fdb8e, 0x7bf04754, 0xe91f8a7d, 0x2fea8eae, 0xfad6afac, 0xf70f540b,
- 0xde54ee17, 0xecd98be3, 0x87fbfb4e, 0x9e8f1c63, 0xf1b63b32, 0xfb48ecc4,
- 0xfda2c5b6, 0x5e5aaf1e, 0xb0dfe456, 0xbb0dc5ef, 0x7af5c92f, 0xa7ff60b7,
- 0x1ba7ca4a, 0xcaae9f28, 0x7c31eed5, 0xe3291ffc, 0x294065a9, 0xd77ca3bb,
- 0xbc4a97f9, 0x7b944bac, 0x2f69ee10, 0xd397e368, 0x97e3690f, 0x35937b33,
- 0x78ff7cf5, 0x6785fbcd, 0x8bda6926, 0xda68f703, 0x68142f4b, 0x1503e5ea,
- 0xaf2bf79a, 0xb3ea6ad4, 0x65f8da82, 0x61c5cdf5, 0xb47d38f7, 0xdca01abe,
- 0xe6757ed0, 0xcbde6a6f, 0x575da358, 0xaebb4796, 0xebb51b89, 0xf6cdc752,
- 0xd397d76a, 0x325f5dad, 0xbef2e3e6, 0x7f2e3e7e, 0xc7c95db6, 0xdfb058e5,
- 0x2d938d33, 0xf7a9b768, 0xfef7d5a9, 0x5866372f, 0x007f40df, 0x00000000
-};
-
-static const u32 csem_int_table_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0xe4b3ff00, 0x51f86066, 0xb97bc10f, 0x726e1818,
- 0x0143f821, 0xd08667cf, 0x0c0c2c6a, 0xc6cc401a, 0xcec0c0c4, 0x717ebc44,
- 0x1d7b044e, 0x4cc30307, 0x31c8de20, 0x481afef0, 0x7e879d7c, 0x42f3a976,
- 0x81c15968, 0x570837f7, 0xb430310a, 0xc430330a, 0x0cf84088, 0x55f2a8a2,
- 0xa9b60842, 0x39766524, 0x0003f502, 0x3471cc24, 0x00000380
-};
-
-static const u32 csem_pram_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x7de5ff00, 0xd554780b, 0x733ef0b5, 0x7993331e,
- 0x0f20f264, 0x0084f102, 0x021842a2, 0x27088784, 0x01a8c421, 0x54bc8083,
- 0x48433c26, 0xbfa81132, 0x2677bd6d, 0xb5ad1104, 0xbc1b6951, 0x14101de8,
- 0xd1a07515, 0x40e81c06, 0xdbdab114, 0xd5a8f8a8, 0x40445076, 0x8bcbc248,
- 0xaf7fd52d, 0xe649cfb5, 0xd4484c9c, 0xffffbff6, 0xdbf3f1fd, 0xd9cfb3ec,
- 0xdaf5ed7b, 0xf6bdad6b, 0x9a32c11e, 0xe4224e24, 0x65a3f85b, 0xf4842784,
- 0x0adb2ce9, 0x64918fda, 0x8b2ffc42, 0x108e36f2, 0xf08e77ee, 0xbc8451a4,
- 0x980b99b5, 0xcfbc3d69, 0x9fad0846, 0x603d34de, 0xff6422ce, 0xef02b308,
- 0x8f9ade9f, 0xbd2fc9f5, 0x7b6814e7, 0x00bc4bd5, 0x13bed375, 0x109d88ce,
- 0xa1e5b9af, 0xf6f3e96b, 0x85b27897, 0x93fc450e, 0x9085244d, 0xfec21663,
- 0x52fab22e, 0x6d56ab2b, 0xf4077fde, 0x2664de5b, 0xd54fda56, 0xaed365ee,
- 0x8765f5a5, 0x54af0244, 0xfa95ab6d, 0x00f2fad2, 0x9afa8417, 0x71c67f7d,
- 0x79480ada, 0x27212870, 0x5f22167d, 0x96ceeb49, 0x79f45994, 0x11676045,
- 0x83b15fbc, 0xfbe89b73, 0x7ff69b15, 0x3457fd0c, 0xda79038a, 0x36ed8aff,
- 0x63610f22, 0x1e604b7f, 0xbc01a64b, 0xc4886f55, 0x97e5eb4c, 0x70044956,
- 0xa54bd424, 0x61ff180e, 0x38c07649, 0x0d1c7087, 0xd0cf559f, 0xd577e871,
- 0x986e702f, 0x7889b55a, 0xddd69e00, 0xda4f39d6, 0xd2b55e61, 0xf77ef860,
- 0xb7bc127d, 0xb2f6502c, 0x36f80655, 0xe700454b, 0xd2d2cda6, 0xadfd9da1,
- 0x0ea6fed8, 0xd90d63ae, 0x76a89ea9, 0x47d27963, 0xacee6c88, 0x04a21057,
- 0x407700ed, 0xf3ac3e9a, 0x812e79f9, 0x3fd0d190, 0x674b644f, 0xc83094ff,
- 0xe8f7fe07, 0xf60f813f, 0xb2db023a, 0xd2b5e93a, 0x772dff45, 0x4bacebd2,
- 0x9ed09fa5, 0x56bfdd17, 0xa074043e, 0x5cfbd4f0, 0x4be23e58, 0x4f8372c3,
- 0xcafdbc46, 0x06cb0437, 0x3f9f1b9f, 0xe58b1be6, 0xe5829f26, 0x2c62be13,
- 0x7c52be03, 0x0e6f8b6f, 0x1e7d5b96, 0xaf94fe7c, 0xbeedcb1c, 0xacfe7c1a,
- 0x772c6eef, 0xfcf8fcf8, 0x2c7adf05, 0x2c7abe83, 0xb01af977, 0xf005f46c,
- 0xdb7d97bd, 0x05f26cb1, 0x5f1ef9f1, 0x5f219613, 0x407dcb18, 0x7d865a5f,
- 0xf01e582d, 0xabe5887d, 0x777e08be, 0xcb1c77d0, 0x3bbc5507, 0x817c9027,
- 0x10a9cde2, 0x92171517, 0x8be4a258, 0xca589eb4, 0xf9b729ea, 0x4f5a25f3,
- 0xc53ad0f1, 0x70cadf63, 0xfbd699be, 0xccf6b0d6, 0x8581487b, 0xacfd33d6,
- 0x4a83c07d, 0x07d69581, 0xc1f6b3d4, 0x7105fc9b, 0xc0383eb4, 0x11deafda,
- 0xfad1b02e, 0x9ed641d5, 0xed932213, 0x66139eb4, 0x94b7dcf5, 0xcf5a0ec9,
- 0xbcf5616d, 0x9d93fd8f, 0x61179eb4, 0x153f8fdf, 0xeb4f1c9e, 0xfb59dbe3,
- 0xd0a44bc4, 0x0913eb45, 0x7b02f587, 0xad02617e, 0xbd58b817, 0x20995fa8,
- 0x7dbfe0c7, 0xa1116462, 0x7fddb0bc, 0xd3a422b3, 0x455914ba, 0xfe9f14dc,
- 0x8b0f5839, 0xbfb43164, 0x84532fe5, 0x912eb471, 0x17fed0d5, 0x1fb6057f,
- 0x6f6c6510, 0xf6c2aff7, 0xed8c9203, 0xb07bdaa6, 0x60a8aafe, 0xbded727b,
- 0x92abfef8, 0x6b83ed82, 0x41fac21f, 0x63ed83d1, 0xef8d7f6b, 0xd83c941f,
- 0x80dac8fe, 0xffeb4852, 0x00b679c1, 0x9e71d75f, 0xfc0d9272, 0xa52b4c1a,
- 0x238ebafc, 0x1e3e4073, 0xf2a6a600, 0x525d2eb0, 0xfbedbf40, 0x3c93de47,
- 0x3276f2a7, 0xf53e97d4, 0xf3f61640, 0xd223f61c, 0xfb9ef87e, 0x58cdf899,
- 0xbf133f5d, 0x69fad729, 0xaceaf784, 0xdf67ebbd, 0xf0f5e337, 0xf5a1537c,
- 0x71fb17b3, 0x135e6ef4, 0x87a09dbf, 0xad4adbe7, 0x4fd8839f, 0x09e0ef42,
- 0xfd74638b, 0x5a65c584, 0x7ec47f3f, 0x1e0ef4fa, 0xeba71a45, 0x6b969147,
- 0xfd887cfd, 0x9faef7a4, 0x1ead74b0, 0xd685691e, 0xa7ec11cf, 0xa5e6ef7f,
- 0xc3d3af98, 0xfad2ae63, 0xcf748939, 0x073f5dea, 0x1cfc7a1c, 0xe7e07470,
- 0xa833c21c, 0x702af377, 0xe053f1ea, 0x25cfc0ec, 0xdeaae7ec, 0xa9c073f5,
- 0x6701cfc7, 0x0e447e07, 0x77ac35e6, 0xd7882af3, 0xbe20a7e3, 0x0e4e3f03,
- 0x3bd119e0, 0xa3ed5e78, 0x7dabcfc7, 0x8a93f03a, 0x1dee8cf0, 0x7a29853c,
- 0x74a614fc, 0x784647e0, 0x9faef5c6, 0xf8f45357, 0x03a53579, 0x3f61573f,
- 0x5e6ef5d7, 0xfc7aa985, 0xe076a614, 0xc9fb1727, 0x78476cf7, 0xd1c7ed08,
- 0xfb073f7d, 0xb073f1eb, 0xae7e077f, 0xd0a67ec5, 0xee7bb27e, 0x8f5328a7,
- 0x0ecca29f, 0x9e2214fc, 0x3f5de86f, 0xf8f53307, 0x81d99839, 0xcfd8a99f,
- 0xabcdded4, 0x7e3d0ae8, 0xf860ae8a, 0xc08c2499, 0x9dae8675, 0x727e9e6e,
- 0x857cbf7d, 0x2ef3efa3, 0x6e5de756, 0xaf0f7602, 0x45a433d9, 0xf6fbe9e1,
- 0x0fb9091d, 0xa6bb6890, 0x8fc076e0, 0xd1795a83, 0xd8fc4d76, 0x951d9d38,
- 0xeaea24a0, 0x757dc549, 0x1d29f7ef, 0x9d4f6ba0, 0x3daeb573, 0xabab93dd,
- 0xd78f9467, 0xa6bfdfbd, 0xe2bf5740, 0xef751bee, 0xd16ff967, 0xcfd7b3d5,
- 0xa83fbdd3, 0xfdaea17e, 0x5d0a86ca, 0x958155fb, 0xdb35faba, 0x7f7ba27f,
- 0xae8d7058, 0x03d3787d, 0xe111f6ba, 0x91f57447, 0xbdd31e87, 0x8b65ba3f,
- 0x87cc7dae, 0xc7daeacf, 0xeae97645, 0xa3df1ed7, 0xf6baff7b, 0xa4faba03,
- 0xbdd7bf8b, 0xd5de4f9f, 0x3f96dbdb, 0xe29fdeeb, 0x7ed74cfa, 0x0697da7d,
- 0x3aeed53b, 0xe75a8d76, 0xfa08ae41, 0x0974fe25, 0x43b0d5ed, 0xd7d4bac2,
- 0xc714fcce, 0xe528f952, 0x22c0e91f, 0x92f91939, 0x21bb51fe, 0x95f96fbf,
- 0xaefcfa11, 0x5d2b9ef1, 0x925df9f4, 0x862bb867, 0x8df9437d, 0xca506923,
- 0xed8d2826, 0xdf8c89f7, 0x0d2e320b, 0xf7bf423e, 0x2707da9a, 0x3e70fad0,
- 0xf1f2083f, 0xbb426732, 0x35278e3a, 0x999c5ef0, 0x5f74dfa0, 0xfe93de56,
- 0xdf587928, 0x5c19da9f, 0x45ebbf67, 0x51da1a4f, 0xc1f89fb5, 0x9fd759ce,
- 0x212fabce, 0x849f70af, 0xf7e903fd, 0x79a697fd, 0x89667f68, 0xe3d119fa,
- 0xa1fc744b, 0xe4187e38, 0x3f8c20e1, 0xe6f8ebba, 0xe3756301, 0x75cb325b,
- 0x3a245be3, 0xdf908bbe, 0x8eae7ed7, 0x9e30894f, 0xcfb93790, 0x66737c71,
- 0x9f7f8e39, 0xe8aefd44, 0xc63ae3f1, 0xbff9816f, 0x07fcdddf, 0x3fcfd78c,
- 0x7f3f42b3, 0xa3ffcd89, 0xf8ead3da, 0x3fff3871, 0xfcd9a773, 0xfcd82b33,
- 0x8edfaccd, 0xf81d9df1, 0xc7f8c08f, 0x9cdf19ba, 0xff3f413d, 0xf3f52a2b,
- 0x4ff1b337, 0xc7505ed6, 0x5ff8e3b7, 0xfcd81772, 0xf1c4a8af, 0x0dc7b325,
- 0xc46523fc, 0xf8e804d5, 0x7c551fa4, 0x742ec0a9, 0x2487281c, 0x6421a152,
- 0xe100371b, 0xf18e2bb8, 0x947157db, 0xf99f50df, 0x500939f1, 0xfd4799cd,
- 0x57d79546, 0x4097c8ec, 0xf53b61ef, 0xa0a896b7, 0x91e26e2e, 0x7306c9bf,
- 0xb7851060, 0x43f789b5, 0xeb86f17d, 0xbd5fa002, 0x14a0b266, 0x184813be,
- 0xcbfe7f9e, 0xe7a25b61, 0xd4972c65, 0x5122c78b, 0x07e1d6f2, 0x35219016,
- 0xc029be14, 0xeb3ba304, 0x0e3f529f, 0xa98fe31c, 0xffa843df, 0xc6c899f3,
- 0xf7f50bfb, 0xfea11ea0, 0xa4ce3a1e, 0xdda3bf16, 0xf0a34e1d, 0x7ff0aa97,
- 0xfd79302a, 0xe02e36f4, 0xd5f9f2a7, 0x7fa0478f, 0x1b6ee0bd, 0x1c277a45,
- 0x5d24fe65, 0x0fcbce9d, 0x6ddf6a74, 0x10e16c0e, 0x6be032bf, 0x21268a3a,
- 0x5067d68b, 0xffbe775c, 0x07a9bec1, 0xb7212739, 0xa54c4512, 0x9abedfef,
- 0xe3a2efeb, 0xb9cc52ce, 0x32521d6c, 0x24d7284c, 0x909634c3, 0x88471a5b,
- 0x5d3207b4, 0x448d3f11, 0x58a33b8d, 0xaa559f5f, 0x8a8ab7af, 0xb570a268,
- 0x66c8e74e, 0x39ecefda, 0x9c6d76fa, 0x4644a681, 0x52bc7567, 0xfa74938a,
- 0xb9943668, 0x7485d8f0, 0xdf62e39e, 0x1778f06a, 0x7e8c2489, 0x010fbfbc,
- 0xf193faba, 0x362e79bd, 0x73bc236f, 0x4a528b44, 0x8ca739e7, 0x1b7f000f,
- 0x9f68ffe1, 0xd0e5314d, 0x22a3fd72, 0x8f9d7531, 0x1eb9fe11, 0x22827ce3,
- 0xcbf3f3ac, 0xdf19cf8d, 0xffe9531c, 0x2d07f029, 0xa0fe00bf, 0xf9551ff0,
- 0x32af53a3, 0x3d9af0fe, 0xda1f80d3, 0xe904f237, 0xadcbf2aa, 0xa92cbf2a,
- 0x2105f3d7, 0xb8e8111e, 0xfb970e6c, 0xcc1f1440, 0x5960f956, 0x6e6f9e83,
- 0x3d317e27, 0x6ee65d06, 0x9a6f7cd8, 0x9f7e75dc, 0xff337ca8, 0x9f88fdc1,
- 0x7464f3ae, 0xd3a543ba, 0xf6fa35ed, 0xdeba555b, 0x4e75d2ae, 0x51afc3c3,
- 0xc9e641f5, 0xdde41101, 0x9e8d53fb, 0x3d3d1d11, 0x708d3d2a, 0xf3d2a1de,
- 0x7a331f8e, 0xa88de11a, 0x9c348cf4, 0xae80c913, 0x5be11af0, 0xf9977770,
- 0xccab5c60, 0xde9e9b1f, 0x4755fca6, 0x05579ea3, 0x3475586f, 0x6c56ce4a,
- 0x2fabae9f, 0xbdd5cc0f, 0x4ca1acbf, 0x7ea4bed7, 0xd17daeb9, 0xf5753bfa,
- 0x758fff32, 0xbbb82fef, 0x7b7ed756, 0xf6bafdcd, 0xeb0fe5f9, 0x1b3d73ea,
- 0x9ecfef75, 0x3ed759b3, 0x5d19f4ab, 0x9de28cfb, 0x6574faba, 0xd37deeb7,
- 0x066eabbe, 0x3deb7cfe, 0x713d809e, 0xc605fdc1, 0x45b82f33, 0xd473bc37,
- 0x1f5f2327, 0xf2c10df3, 0x7c8dcfb8, 0x1637d27f, 0x66a6d6cb, 0x7413ac3b,
- 0x124a5c5d, 0xcd326908, 0x0fdf5dab, 0xeb8269d6, 0xa9e4c869, 0xb37ad3f5,
- 0x28794649, 0x78489069, 0x2c1c2124, 0xed1c2a36, 0xa47b547c, 0xaa06f687,
- 0xb6ba93f8, 0x3f624497, 0x76523ef7, 0x7765f005, 0xcbfd03eb, 0x4da7bb00,
- 0xed8debb5, 0x8d291c95, 0x1ac84e7e, 0x626ac384, 0xc4a54776, 0x5772bfe4,
- 0x4271017a, 0xe6b83c3d, 0x2905e372, 0x9f02a793, 0x78e4eb64, 0x3a35c359,
- 0x9a204efd, 0x6df807dc, 0x8af9eea4, 0xbeead7ed, 0x479fb53b, 0x5741abb8,
- 0xb165838c, 0xe81333f4, 0xe67370e1, 0xa700618c, 0x4deb1472, 0x3c2ed07d,
- 0x755e2be5, 0xafd01074, 0xbee3cb14, 0xf31e5839, 0xea3cb079, 0x53f2c72b,
- 0x11960d5f, 0xfe58dddf, 0xf2c7e7c5, 0x2c7adf63, 0x63d5f23f, 0x01afa1f9,
- 0x017df7cb, 0xb6fb0f2c, 0x2f8ef963, 0xaf8b6588, 0x9f56cb09, 0x7726a582,
- 0x71ddf13d, 0x093e1d75, 0xcf8317fc, 0xed7f3aa4, 0x7c9d09fa, 0x87dfc716,
- 0xb9e1a67c, 0xf2acc1a4, 0x1f8e8a43, 0x4397c012, 0xbda1eb3e, 0xb0f95441,
- 0xb763efbb, 0x6bfcb77b, 0x0fea6df8, 0x7e4eb7e4, 0x53f030ca, 0x34fc4f76,
- 0xa7e28f8c, 0xb31726a9, 0xfa7e547b, 0x8623cc19, 0x8c0f315f, 0xf6513e90,
- 0x826f929a, 0xbaa56c75, 0x601f420f, 0x763aacfd, 0x05b77d1d, 0x10c0baed,
- 0x0ece3758, 0xd860dbf9, 0x21fb3847, 0xf7567e25, 0x49f233f3, 0xd05778f7,
- 0xa01a59bf, 0xdaea4f44, 0x78638d6e, 0x31489ab5, 0xfddaeba1, 0x2f729e83,
- 0x81758a1c, 0x01f7c224, 0x8c4774f7, 0x0cada97e, 0xaf09edf8, 0x72af8e75,
- 0x8f63bfa0, 0xca0f3dfd, 0x2f6626a9, 0x68f335c7, 0x93f093b7, 0xc76fc06e,
- 0xa77664ba, 0x7dbdbc41, 0xbb42e490, 0xe3d64c81, 0xc3a05fcf, 0x4714fddf,
- 0xd6eeb82d, 0x06fe21a7, 0xbd38357e, 0x49ebf817, 0xcf84f7bf, 0x7fef3085,
- 0xd27b3e01, 0x45e93d8f, 0x342fc8a2, 0xedb7f9d1, 0x80fb961b, 0x1e5ee30c,
- 0x9afedadf, 0x7e5f9e11, 0x4b6e3e47, 0x25b8f8d1, 0xa41f8093, 0xc6d9cbca,
- 0x2e81e32b, 0x40f4fd1d, 0x9f77ee4f, 0x7eff8264, 0xdfdf4b3a, 0xe2fec67d,
- 0xa70dc225, 0x89243ae3, 0x92bf53c4, 0xd1e36cf7, 0xfc47719f, 0x67d83710,
- 0xe0c9d773, 0xaffc9e37, 0xeb3d0cb0, 0x0f670be3, 0x3f04e93d, 0x5f1a656c,
- 0x1d063473, 0x982ab2b5, 0xf68f6355, 0xf5f49a57, 0x715cf5b3, 0xc725e710,
- 0xeb061ccf, 0xa8e6ab8c, 0x0d3f7a08, 0x959fad4b, 0x738e1269, 0x3c767b72,
- 0x4c02fff3, 0x4048ec9f, 0x67d2737d, 0xd9fff7c1, 0x8fd774f0, 0x8d210f06,
- 0xe80b33e4, 0xdd96da73, 0xcaddfbfd, 0x825e7083, 0x890929f8, 0x69bf815f,
- 0x3b7fffa5, 0xb015fa00, 0x0debf5ae, 0x70f37ef2, 0x3743be78, 0xd64efd1e,
- 0xbbe18cf6, 0x204ee5ee, 0xa7be34c7, 0xbaabfbf4, 0xbb62bdbf, 0xc76f46b5,
- 0xdeeae826, 0x9d1af4a6, 0x00ff0b5d, 0x1386bdc3, 0x54ab0960, 0xb04db0d9,
- 0xda7e07af, 0xf049c103, 0x5ef6385f, 0x79222595, 0x16971464, 0x6385d3e0,
- 0x6797fe35, 0xa9ea99ff, 0x048a6f13, 0xa25c8ce4, 0xaea9e550, 0x899bf220,
- 0x917d6898, 0xc6c2f6fa, 0x6eb02515, 0x26f9789d, 0x931643f4, 0xc7f82752,
- 0x0f3ea4e5, 0x89a7b5e2, 0xf3e418a9, 0x39c77934, 0xad1e4a32, 0x2e9d8482,
- 0xe3b7af5a, 0xabaf7fa9, 0xd7d06b2f, 0x525b9297, 0xe97edf60, 0x38049106,
- 0xf6fa1bd0, 0xf61779af, 0xacd48cbb, 0x57fb7583, 0xa16bbc6a, 0x5419088b,
- 0xf6fd556f, 0x0a32bcf1, 0x71604b87, 0x7a1f6d16, 0x7ff32279, 0x2406662a,
- 0x59ffbe85, 0xa95bc8e3, 0x07dfa206, 0xbc7ec1d6, 0x6f713a7f, 0xf7e95d23,
- 0xc237e15d, 0x5d03d9ab, 0x3855c3f6, 0x4a73b792, 0xcb1e8620, 0x67263814,
- 0x102bbeaa, 0xc7b8ba5c, 0x7bfd4334, 0xd13253f3, 0xde1ed3f1, 0x668c2793,
- 0xc0fc03fc, 0xe792ed09, 0xd69ff487, 0x7f82ffa5, 0x68fdff6a, 0xfeba79ff,
- 0xfb53fda7, 0xfe05d81f, 0xaffab179, 0x2ff3edfa, 0xa93ea9fb, 0x4e97f178,
- 0x13c9d742, 0x9b8a7d42, 0xdb72b5d2, 0x96854ebd, 0x13bf05c7, 0x8044f5f8,
- 0xef458e2f, 0x154e0587, 0x41cec542, 0x49fe0ddc, 0xecf93ffb, 0xf11e30cf,
- 0x85d136d5, 0xe6edb4f1, 0x61ca99b0, 0x12f2e375, 0x23f58392, 0x19df7eac,
- 0x7a4dea1e, 0xfa78abfe, 0x1f902997, 0x8d453942, 0x9ed1852f, 0x79fadead,
- 0x5e4fac11, 0x64728ed2, 0xbfc60efc, 0xaffa8898, 0xdaef8a4c, 0x38c4e14e,
- 0x8bc55781, 0x6767f1b7, 0x37942778, 0x82fa017c, 0xc7e8227a, 0x572bbf1b,
- 0x8235d4ed, 0x8d98f923, 0x190c7bfe, 0xc3517a03, 0x3b30090b, 0x5f99eeb5,
- 0x70a11ce7, 0xa6fada9d, 0x97c28b93, 0x83674f26, 0x8f73fe8b, 0x6ddebddc,
- 0x6d16f2a5, 0x96eb690f, 0xd7daa4dc, 0x8a565621, 0xf3e42761, 0xdd166e54,
- 0xf2b8fa7e, 0x7a9f27f9, 0x7f99e20c, 0xd107bb32, 0xff3c57fe, 0x69e3fbda,
- 0x314ec57d, 0xc34d84b9, 0xd274a5ce, 0xbfff4bc7, 0x1e93b73b, 0x4d79bf15,
- 0xe7b18792, 0xd27624f7, 0xfdcec565, 0x15d61912, 0xfb83931f, 0x063d88a5,
- 0x8a47827d, 0x7ba85ec0, 0x8825bfe6, 0xc7d89e33, 0x18acd491, 0x1afcdcf8,
- 0x278003da, 0xaf4aa7a4, 0xde19fa0e, 0x80ba52f7, 0xcbd236de, 0x5522def8,
- 0x90bf40bf, 0xfbf94167, 0x07903d85, 0x0dd991f5, 0x617f2878, 0xf3e61395,
- 0xf8c35085, 0x537bf1fc, 0x8b959f40, 0x961714fe, 0x13f979ec, 0x5bfe423f,
- 0x528ff6f6, 0x9444be30, 0x45ae1374, 0xe79874fe, 0x70b34d92, 0x07894b9e,
- 0x71fcb0f9, 0xcb4034be, 0xde29020b, 0xac4e4319, 0x2f939322, 0xd2e250b6,
- 0xfe017e79, 0x77efe824, 0xb436c0f8, 0xa024efbb, 0xcea47e0f, 0x580c5a85,
- 0xf46160bf, 0x2ebaabfa, 0xa33eb010, 0x7deb77f9, 0x93a7402d, 0xd85495fd,
- 0xc112f177, 0xfb83e2af, 0xbfcbf696, 0xd195253d, 0x9e42c889, 0xf75d1dfa,
- 0x7873c327, 0xac5445bf, 0xc8efba39, 0xe39d59b7, 0xa7c756af, 0x7ac1c770,
- 0x6c4a45fd, 0xd44f35fb, 0xb75d00f4, 0x4a2cf8a3, 0x6ffc99de, 0xbbc99fbd,
- 0xe981ff26, 0xfe7ed0c5, 0xf8239330, 0x0a43d60e, 0xdb153857, 0x50e4cff7,
- 0x3a3f503f, 0x156f9c96, 0xb7d73955, 0xc285f91b, 0x51f1702f, 0x24e3037c,
- 0xdf701d22, 0xfa06e965, 0xf51e947d, 0xaeceb8c2, 0xbc726afd, 0x455bf34c,
- 0x9b203ebd, 0xdee81e98, 0x9e23f2ae, 0x53c0c52a, 0x52fc818f, 0x20cbf579,
- 0xcc2962bf, 0xcd1dcbff, 0x72a3cfef, 0x935065fb, 0x355ebd5b, 0xaef96dca,
- 0xdc9624d1, 0x9377697e, 0x9f4b7298, 0x7b5b94c7, 0xfff9f904, 0xf0d55eb4,
- 0x78f00c38, 0x351e274d, 0x3e1dd93d, 0x90f27a8d, 0x8d5e2320, 0x1dfe927a,
- 0xf95d7926, 0x8d43e351, 0xab9e2aff, 0x51f402ba, 0x7c6a9f07, 0x1aa7c1d8,
- 0xef89761f, 0x6c68f0ea, 0x34fb00bf, 0x96f9ae14, 0x528ed38d, 0x4ed2d257,
- 0x7f26df70, 0xaafb8f26, 0xe584f396, 0xf3111081, 0xd5303f43, 0x753b068c,
- 0x3d6fdfe2, 0x7785177d, 0x2c8bf13e, 0x445ea02f, 0xb7d2ffbb, 0xf3a04edf,
- 0x79e2a799, 0x54fb453e, 0x0239974a, 0x70a38e17, 0x3f8815ce, 0xb7e2113e,
- 0x0a34f91c, 0xfae5f98e, 0x4c4dfc3a, 0xa7a7ece9, 0x9fabbff7, 0xb7cb7df2,
- 0x1d3f5d29, 0x50bbc844, 0x10bc388a, 0x81d357cd, 0xde7f14ae, 0x00605c51,
- 0x5088a9ea, 0xbd77e51a, 0xf3fb3220, 0xa319c2ed, 0x9fc9bec1, 0xf19e2c3d,
- 0x7bf460fb, 0x3b3eaabd, 0x41e397eb, 0x650d9fcf, 0xf67b7fa3, 0xac4722d0,
- 0x9566d0bc, 0xf7535ecf, 0x5cecda5d, 0xbff94f3d, 0x7da3b48d, 0xc95bb7e3,
- 0x82fb18b6, 0x5f4d451b, 0x7fa374ab, 0x8e7f1d3c, 0xe97387ca, 0x51b9f1a7,
- 0xf5399b74, 0x4aece084, 0x34fbf807, 0xa1fb0fca, 0x06be05f8, 0x235b36fc,
- 0xe231a545, 0xf8a9cf79, 0x6be0789b, 0x0c2dcfcc, 0xc7800be5, 0x8baf3b42,
- 0xc9a93c83, 0x143250eb, 0x60789ae0, 0x5347cff9, 0xe21ef63e, 0xeb8f90dd,
- 0x3c919d0d, 0x2361fc31, 0xb07fa13e, 0x2e888f33, 0x627bd7c4, 0xebc012e9,
- 0x04acb37b, 0x95df35f6, 0xe0b155dc, 0xf5b3332c, 0xbd292e66, 0xbffb8a30,
- 0xb3f9bf0f, 0x8a02e11d, 0x9676b38f, 0xff95ddf7, 0x759fdc98, 0x0e5a8171,
- 0xf56790f8, 0x71002e64, 0xf9e222b4, 0xe50e04f9, 0xfeb4527d, 0xfe9a6fca,
- 0x54f5e43c, 0x89973887, 0x110b57b6, 0xdbd8f809, 0xfb0053b4, 0x289926fd,
- 0x6a108f18, 0x8a8ccd86, 0x05111d7b, 0xdff357c4, 0xf80edde6, 0x4cd3373d,
- 0xe8652e00, 0x01d82719, 0x512342e7, 0xd79bba0e, 0x5a647c1f, 0x10fd08a1,
- 0x3f230fe4, 0x74db2514, 0x499359f5, 0xdba5373f, 0x95647344, 0xeafd063b,
- 0xbd67c624, 0xff966fd6, 0x04dbf4cf, 0x5f18dfaa, 0xedfad18b, 0x7df18926,
- 0x8d4b7e94, 0xd656dfa5, 0x17c0a9ca, 0xa766f72b, 0xbe575d02, 0x2c4fa4b1,
- 0x8fbaf6fd, 0xa86ff7f9, 0xfd6de679, 0x1e1b7ea8, 0x51fadfa5, 0xae2316fd,
- 0xa5ea5a3b, 0xcffcb37e, 0xa0ebdfc8, 0xb7cc62df, 0xa69fc558, 0xb5438adf,
- 0xfb8adfa8, 0xa97cbaf1, 0xfa4f5249, 0xb397ecad, 0x6dba2eb0, 0xf007f831,
- 0x0dedfa0a, 0x38c1cf55, 0x5dfee7a0, 0x3d277d72, 0x3d5bd557, 0x67843ff7,
- 0xecadcf4d, 0xd33da1cf, 0x9e990f95, 0xf4c5995b, 0x4cbdcadc, 0xc41cadcf,
- 0xbf519cf4, 0x6fd17415, 0x21eafbec, 0x23f47bf4, 0x1b7d7eb3, 0x23992f6d,
- 0xfdf42dba, 0x9f3b5912, 0x5a3a3351, 0xd4bbfddf, 0x9f73be8d, 0x3d2e73c1,
- 0x823fbbe9, 0x7a841bbe, 0x91c8206c, 0x1c6e3f91, 0xd3e5d368, 0xb1f5f7bd,
- 0x79045ee7, 0xfe8f03f9, 0xe62607f7, 0xfafbed27, 0xbb9048d8, 0xaa1e00f7,
- 0xf9519eef, 0x47e7d5af, 0x28793a7d, 0x7baaf793, 0x1baafe18, 0xd5df3639,
- 0x7586407c, 0xd1176fe0, 0x2f7dbe8f, 0x9b67a3f3, 0xc0d8fa5b, 0x225fffcf,
- 0x2bfd25ca, 0x87e28b29, 0x302b1739, 0xce2bb9ee, 0xccfc05b9, 0x80b10239,
- 0xd0e0bb1d, 0x7ec0278d, 0x3d71705d, 0xe00bbdda, 0xc8e92279, 0xa1db98fb,
- 0xebf6f527, 0xaf9da6bc, 0xf9ae9065, 0x8ccd1310, 0x7157132e, 0x5d59cd81,
- 0x5da823f3, 0xc62df986, 0xabdf893c, 0x47cd9ff3, 0x8fe45f10, 0xe5f8cc7c,
- 0x72788def, 0xad54bc33, 0xaa78f5e6, 0x89e262e1, 0x2ca4ba52, 0xb72f13a5,
- 0x975914bf, 0x39cbed01, 0xf38cb7f4, 0x9c66f0d6, 0xcd4786bf, 0xbea059bf,
- 0x24743f3f, 0x86889e66, 0x22f92ee7, 0xf80dde1a, 0x33d34b78, 0x206190d7,
- 0x3c981f97, 0x7c0d1f3f, 0x178a7bf4, 0x73ade70a, 0x2bcee907, 0x65e2a3bd,
- 0x6148e7aa, 0x24780c8a, 0xf367c035, 0x96be77ca, 0xb377e742, 0x210b9592,
- 0x937f59f5, 0x688f103c, 0x1ea3b6b6, 0x9470f8d4, 0x5985c999, 0xf5ef2bd5,
- 0x7ae21575, 0x50b9c4d3, 0x3d06c2be, 0x7999e6a7, 0xd7f261ef, 0xbaf7fdcc,
- 0x6788518c, 0x91482e58, 0x5d015eb6, 0x86a73fe8, 0x40bc5d18, 0x69cffa17,
- 0xe020fda4, 0x73993abd, 0xa6fde187, 0x3f02f79d, 0xcfa56ebd, 0x39cbce41,
- 0x0e8616f7, 0x65ca7a7b, 0xc58858f9, 0xc8cc18c7, 0x173f5ceb, 0x5d897bc0,
- 0xe68993ed, 0x8e00f796, 0x366e5489, 0xfd00c3c3, 0x46fe8a2f, 0x07c8c5fb,
- 0x7503e53d, 0x2ab9efc7, 0x3a075f9e, 0xeddf01d8, 0xde43d812, 0xb47f5b30,
- 0x1720af76, 0x3a34de22, 0x65f5d134, 0x2983a314, 0xd66f9e06, 0xbd9e2aea,
- 0xef844e21, 0x6ffea06f, 0x7ebb0712, 0xf8d41f5f, 0xc5772cdd, 0xd215c413,
- 0xe806f4a3, 0xcd7de8b7, 0x11b7a6ea, 0xa6ae375f, 0x15dc99e6, 0x407d1a5f,
- 0x6f0e5e0f, 0xd34fcadd, 0x61799891, 0x467e55df, 0xb3f2f599, 0xe6fedacf,
- 0xedab8870, 0x90af50e5, 0x7e2e8250, 0xecccd330, 0x07ab6696, 0x0dfdbcf9,
- 0xee45bdd1, 0xa8a67faa, 0x257f0174, 0x64e27cfa, 0x4de80898, 0xa67c9597,
- 0xe3007bcd, 0xe0f5e8b7, 0xe907ab75, 0x33ff5dd7, 0xedfecccc, 0xead31ece,
- 0x9078c3d7, 0xc7eb28d7, 0x5a47ae33, 0x79a7a95c, 0xbf71d479, 0x71b4bcef,
- 0x84beebbe, 0x3c60b497, 0xd89fdb4e, 0x89767bc3, 0x73163f60, 0x0a107dba,
- 0xfe6fee39, 0x59bffa13, 0xff7ddd1a, 0x530a3f10, 0xe3bebf3c, 0x9f638c49,
- 0x34c8f67e, 0xaf159f90, 0xe542c4f0, 0x838775af, 0x889e5984, 0x45427604,
- 0x5dfb8f23, 0xcde70844, 0xa833b288, 0xf1f0c327, 0x5ef503a2, 0xa0732ec5,
- 0xf15f7e84, 0x103967f2, 0xc35d6b7f, 0x59ff9ff4, 0x91fd1f95, 0xa807c81c,
- 0xbcfed810, 0xa88f3e91, 0xb76a79fc, 0x6fe80e6d, 0xc73b3b6e, 0x2d9c115b,
- 0x0ce2a39a, 0x16459bf7, 0xc36ddee7, 0x33ff6c3c, 0x0331e61c, 0x48e7d17c,
- 0x53d0fcb5, 0x5cbd30cf, 0xe00624d1, 0xf6c5703c, 0x1710ad9d, 0x8cd0f8af,
- 0xfb77abf6, 0xd3ec0919, 0xcf3e2fc9, 0xf1371bce, 0x976878ba, 0x3e76e438,
- 0x59f8866c, 0x01ea1563, 0xf5823f5a, 0xfbf71aa0, 0x15b2718e, 0xd97dee2f,
- 0xe2b8514f, 0xf13b4f37, 0x36cb705c, 0xb723c627, 0xa05f7e5f, 0x7831dc4b,
- 0x9c771abf, 0xf5c105fa, 0xf1dc7621, 0x2127caa4, 0x48ee3eb3, 0x3c6127b6,
- 0x5799c292, 0xd17e231a, 0x5fcfffc1, 0xcdf60278, 0xf2faed4e, 0xf2bb8009,
- 0xfc4f739b, 0x2a93e294, 0xdbac1720, 0xc3df67de, 0xbbed067d, 0xd27d55f7,
- 0xb8d3ccfa, 0x27fad34f, 0x6b7a1bb3, 0x2645fbdd, 0xeeb453ec, 0xe2053afc,
- 0x4ef7abb8, 0xf56d7f41, 0x4953934b, 0x2b407f0c, 0xbd037f81, 0xd23227d8,
- 0x39b1b9ad, 0x4d3ce013, 0x77eb0ee9, 0x58393c47, 0xb2f4e2c5, 0x11de471a,
- 0x4bae5f7b, 0xc671b8dc, 0x3ac1d7cd, 0x65ba28de, 0xf1f88bd2, 0xe1cf4a61,
- 0x0ee3a0bd, 0x38209f75, 0xe3f1b2f5, 0x4a0ff0d3, 0x7d660baf, 0xe342fe1c,
- 0x0c7cff92, 0xba931ada, 0x7b871f8d, 0xdf6d3f81, 0x2159bf6f, 0x5da39016,
- 0x1edc61cf, 0x0f7d47e8, 0x85fcfad2, 0x1cbb884c, 0xc0efdb17, 0x66bdebfc,
- 0xd8aaa3cc, 0x53ca01fb, 0xe36f4beb, 0xf7511abe, 0xc7495adf, 0x5127db1f,
- 0x56ef3a7d, 0xab3b8b07, 0xb4b88074, 0x6ae7c4ec, 0xb5f199fc, 0x2eee9716,
- 0x32d63d1e, 0xabbfed80, 0x5b5591fb, 0x43112cff, 0x0b1b9fbc, 0xd9723af4,
- 0x0f0d547d, 0x98c3c02e, 0xd896fde8, 0xfd8efff1, 0x80dd0316, 0x758f609e,
- 0x7ad0a7ec, 0x07ab883f, 0xed620fb8, 0x666eb5df, 0x62ad34fb, 0x6d45bcec,
- 0xc5a465ff, 0xe812efb0, 0x4f4bbedd, 0x78aef8f3, 0xb42706ca, 0x9d7c574f,
- 0xbf5b14ba, 0xd4e16adf, 0xe7be037b, 0x67257ebe, 0x05981bcc, 0x78d5597c,
- 0x4a7b0244, 0xf9b4df5b, 0xe7fd529e, 0x78f2cf53, 0xb05d644e, 0x51bbf519,
- 0x1613547f, 0x5bc23437, 0xab7a616e, 0x1fad89ba, 0x023976a7, 0xa9cfda76,
- 0xaf91bb03, 0x911c77ab, 0x83bfb4fc, 0x45237fdb, 0x60acf2a2, 0xc14408fd,
- 0xfd85ea7f, 0x897f6c39, 0x71c6ebf9, 0xf1c752ee, 0xe38f6286, 0x374671dd,
- 0x507f0ace, 0x2e7ee762, 0x4149de3f, 0x9dfd0d99, 0xe409116c, 0xf20c9ffd,
- 0xe31881c5, 0x5a88b5cf, 0x0fc98b3c, 0x1cf1475d, 0xbb9d83a6, 0xb42513e4,
- 0xc63b57bb, 0xfde7087e, 0x19243b57, 0xb57517e2, 0xeeb52f2c, 0x4069dcdf,
- 0x5b84baef, 0xdeae3f71, 0xb2575f80, 0x1ae21f2b, 0x51d2c2ae, 0xbd46aec0,
- 0x7498a093, 0x1476aff0, 0xce14caa7, 0x469daab5, 0x0b9e3704, 0xc5459de5,
- 0x65de1f30, 0xec635972, 0x52f6883b, 0x8bc289e2, 0xe39fd2e8, 0xca469724,
- 0x7f968fd0, 0x39696953, 0x052e8d88, 0xb1858c53, 0x99fcddec, 0xdb779c2e,
- 0x507fd50e, 0x614aec88, 0x8eb06479, 0xcf8aedb4, 0x43f1c321, 0xb47e50a2,
- 0x1db9cfa9, 0x5e83f7fb, 0x4a24eb5a, 0x8a339502, 0x86cf9955, 0x2c23acf3,
- 0xe9f0365c, 0x857aff99, 0xf10d6bf6, 0xd9b457e8, 0x25527cb5, 0x46cce401,
- 0x41bcc41e, 0x936fe560, 0xe634e13a, 0x25781213, 0x298d3eea, 0xa1fd1dbc,
- 0x7c589bb3, 0xff572780, 0xcf8b027a, 0xafc00091, 0x542b2fae, 0xe212cf38,
- 0x3bfbc30e, 0x580f181c, 0x9422c6f6, 0x3443a01f, 0xf58a92be, 0xac1b5ee7,
- 0x67f01cce, 0xbf555a36, 0xc0b4afc6, 0x6ac59b39, 0xf54a7dbf, 0x18a962e7,
- 0x975e41fa, 0xe5faf2a8, 0x9843a2d2, 0x8a59e68f, 0x8e753e7a, 0x31acdcfe,
- 0xaa204b4f, 0xfe601c9f, 0xadbc9773, 0xb708cda6, 0xc56b7f31, 0xc35d7d76,
- 0x37a027e3, 0x127402af, 0x80e2e5fb, 0x3237e23d, 0x4613d7f8, 0x9afc777d,
- 0xb5f8f4d3, 0xdafc7aca, 0xa7f11886, 0xadc3afc7, 0x97e697c7, 0xf8df8776,
- 0xc873fab1, 0x8afc2aff, 0x548ed556, 0x4aff4af1, 0x654c292d, 0x42e9dc03,
- 0x28c2e518, 0x30f61947, 0x9feeff07, 0xafc5a81c, 0xefd40edc, 0xb87cea69,
- 0x1b3becc5, 0xf00f11c8, 0xe08e51ba, 0x79e82024, 0x75d8f91b, 0xfac40acc,
- 0x4d7b7c8c, 0x355cf4f7, 0x0b23d5fd, 0x809b57e9, 0x3f23877f, 0x89bef3b0,
- 0x05975024, 0xc176ea72, 0x59f41dfa, 0xb8458bdc, 0x17b885f7, 0x5efb820f,
- 0xa43e585c, 0x0db4abe6, 0x306e7825, 0x029f3e18, 0xdca1e9fa, 0xf7a069f6,
- 0x29484bbc, 0xc51fc1e8, 0x0f03f3b1, 0x38bf65a8, 0x85abd549, 0xef824c6f,
- 0xe70ca243, 0xdb42dbd5, 0xdea0832c, 0x2a3de3c4, 0xabfa84de, 0x90d6fc60,
- 0x6c5ae0c8, 0x38820c09, 0xc7115ec8, 0x013c5d6d, 0xd87665cf, 0x2f96216f,
- 0xccfa16d2, 0x9f4a28b9, 0x7a3d36b7, 0x36b9c415, 0xa9e7629a, 0x7e9ab14c,
- 0xec1bfad8, 0xc537b792, 0x1eeaf2ca, 0x51e7401a, 0xbaacfd3d, 0xb879330e,
- 0xabf3a556, 0xf9c46f4b, 0x64e214bf, 0xf88a4758, 0x461a6edb, 0x3dee39e7,
- 0xb0cf8d41, 0xf528e578, 0x2fd03afd, 0xdfeb5fa8, 0xddc3e9e5, 0xe7020547,
- 0x2cd546f4, 0x15eb7f45, 0xca73e527, 0x704a7917, 0x616df024, 0xcdef0128,
- 0xd04c7ef1, 0x22dd1fae, 0x4f33f8e8, 0x22f3575d, 0x44c05e54, 0x3edf50f9,
- 0xec18222e, 0xfc0f00a0, 0xfd71ed75, 0xd55685f3, 0x149272ee, 0x970df3e0,
- 0x5ef20e78, 0x7b89dadb, 0x6dbb850d, 0xa3845f71, 0xfa9c3ced, 0xbe25e5a5,
- 0xbf7ad638, 0x62f8caca, 0x9d7044a3, 0x8ed4b8d9, 0x4b03c5f1, 0xf580ae2b,
- 0x7b1fabfd, 0x8e7588ae, 0xc53f4a3c, 0x252c7cb3, 0xfe058c9e, 0xbc31cb5e,
- 0xc697a7d7, 0xf8d7f7c8, 0x8d6fe359, 0xc697d3af, 0x35e56279, 0x7665637e,
- 0x21d2c15a, 0xdafe049c, 0xe38f0e3e, 0x5cf1aeb6, 0x9f8ddcf6, 0x7800c9ac,
- 0xd0e74dbc, 0x3884b6ee, 0xb1bd9625, 0xfec4eac1, 0x6bf8d75b, 0x2eef8f21,
- 0x27a09c2a, 0x0377efbb, 0x813f5bfa, 0x677c2ca0, 0x73c32fa9, 0x642c4bbc,
- 0x85bbc40b, 0x1c5bf4fa, 0x6f93ffc0, 0x7de14758, 0xeb84d4ac, 0x8dd146eb,
- 0x08abfbf0, 0x1a83f8c1, 0x8d37edcf, 0xcf3e8e6c, 0xff3584fc, 0xc7a52b59,
- 0xd21756b3, 0xe6e3c925, 0x3ff77e00, 0xf209dbfe, 0x8cd176dd, 0xfaabec74,
- 0xaf77da43, 0x36dd9959, 0x0ad94e33, 0x64f293df, 0xc7b71394, 0x123c5ee9,
- 0x78a04dee, 0x4ea3928f, 0xbbf1f9fa, 0x71d50f44, 0xbb449e14, 0x2892f909,
- 0xc5d2ec8a, 0x4728fd29, 0x30905c9a, 0x4d8f2047, 0x885cabd3, 0x1ca83b0b,
- 0xc3d8b28c, 0x962477e0, 0x105379d3, 0xfac2c4ac, 0x754e116b, 0x3cc6cb9c,
- 0x7997ca79, 0x608a3870, 0x71121448, 0xdf4d7fa1, 0x6d7a7a6a, 0x59794102,
- 0xa810b0fb, 0x126cfda3, 0xaf885622, 0x01722964, 0x0a251aa4, 0xef179e32,
- 0xff304e5f, 0x78fd96d2, 0x42dd8742, 0x37c47e85, 0xfb5882fc, 0x869c7c79,
- 0x401fcf2f, 0x6a1ce46f, 0x8de6003f, 0x73c6cadb, 0x3b4166bf, 0xa87f43bd,
- 0xba9158f6, 0xdcfb8efe, 0xc209f2c4, 0x3ef44893, 0x687f519b, 0xebb8c9f6,
- 0xbf606b22, 0x189fdc68, 0x055bb49c, 0xcead1bbe, 0xa89f43b7, 0x1098e6eb,
- 0xfbf427d5, 0x66c8d0dc, 0xf72b07b8, 0x5dc72663, 0x3f21c9f4, 0xbefbf80f,
- 0x17c8c47a, 0x2e54c223, 0x32a1f6d5, 0xeae1a7dc, 0x19fb43a8, 0x9e49de83,
- 0xed152a3e, 0x8cdf955c, 0xdbe4d678, 0x77b9f728, 0x0ccd9bbb, 0x1a47e62e,
- 0x275c21c6, 0xe836721c, 0xb078b7a5, 0x29f2dbf7, 0xbf5c281e, 0xf4a3f902,
- 0xb81f384b, 0x21bfe601, 0xe415bd74, 0x27af7be4, 0x5475fa21, 0xbcd3f69e,
- 0x0fae3e27, 0xc04e27ae, 0xf3fef543, 0x46127aea, 0x01c8777a, 0x78e89395,
- 0x46ffc689, 0xa3e4d77e, 0xc8de2e0e, 0x047673c6, 0x0b9e59d6, 0x663065e2,
- 0x7805c9b2, 0x3aedecd5, 0xfe25bed5, 0x56ffb474, 0x1eba88bb, 0x4f800665,
- 0x5ecd44ea, 0xe3a25b77, 0x051dab53, 0x4fdb97a9, 0xfea45ef5, 0x1b39d459,
- 0xfe8ed0af, 0x84a2f79b, 0xfe37bfcf, 0x7914289a, 0x898dfc3a, 0x7f15dd1b,
- 0xb08471f1, 0x9ffec2fb, 0x230cdf9f, 0x7727dc7f, 0xe25aefce, 0xf5422579,
- 0xf5aade47, 0x3f193675, 0xd7969c39, 0xfb682f55, 0x01e9dd9f, 0xa98fbca3,
- 0x70c66fac, 0xeef20f4b, 0x25f8a9b5, 0xb3e80664, 0xb76a61f1, 0xff957564,
- 0xbcfceaf3, 0xb6f78636, 0x8307db5b, 0x3de7ad3c, 0x2f687135, 0xb0264c46,
- 0xb413762b, 0x8ffbdc7b, 0x5bde513a, 0x4feb7492, 0x8fc0bb57, 0xa7d9a9f2,
- 0x7c6a5d9a, 0x552ec3af, 0x3e2d1bd7, 0x795135ca, 0x193cf0a1, 0x1c03f1e7,
- 0xbfe62e75, 0xd05701c2, 0x3d584f63, 0x365fc075, 0xd838973a, 0xce12192f,
- 0xb096f162, 0x93bb3e4e, 0xde419b47, 0xb03f1482, 0xfae9f9fe, 0x1eeb8837,
- 0x0971b19e, 0x85aa5e0c, 0x97e9bec0, 0xd560d847, 0xfbc7f304, 0x6bfbb0e5,
- 0xfbb2e5fa, 0x31c73732, 0xa18b65fb, 0xfa5ac27c, 0x144bcc18, 0xfb9cdf88,
- 0x5006e1fd, 0x64f90e21, 0xf800d29c, 0x382b14b0, 0x71170c8f, 0x19de9473,
- 0xbc839042, 0x994ac489, 0xd247f163, 0xfb48ffb9, 0xf39128cb, 0x06323f81,
- 0x9a373c12, 0x9e7d8a11, 0xf13895e8, 0x8debd987, 0xbcc1ce5d, 0x41cfcaa2,
- 0xa937ce89, 0xe9839d84, 0xf050fb88, 0x8eadbf01, 0xadb2715b, 0xab3ed817,
- 0xd9e1813f, 0xc101bfe8, 0x5a825e60, 0x822257bf, 0x2bfd1135, 0xdfaff03f,
- 0xcaff4164, 0xd041dc46, 0xb1c41fb7, 0xce3aecf8, 0xbfea1ebd, 0x702dda10,
- 0x37268fcf, 0x343c3c9a, 0x40b716e1, 0x775e755f, 0x5f7c0736, 0x00ef172a,
- 0x9c275b9e, 0x6716bc1d, 0xf8c99ed2, 0xf975e14e, 0x9afd1af6, 0xacfd1d44,
- 0xd6895710, 0x08690ef3, 0x5cadedd8, 0xaafc1b9c, 0x831ce5d6, 0xe7a8b397,
- 0x3cdd0411, 0x1fcc6cd3, 0xe7f55369, 0x90b2e3df, 0x84f5b51f, 0xc63d6fce,
- 0xe8f30d7f, 0x386a8738, 0x973c6a77, 0x11dd969a, 0x7cc74a07, 0xee0952dc,
- 0x43672332, 0xbce3b436, 0x124cf6ce, 0x6a64bce3, 0x5cf31ac4, 0xbc5256b0,
- 0x4b780d7d, 0x40126b15, 0xcedea71f, 0x1f1188f4, 0xc47f9c6d, 0xfb47d841,
- 0x1f331883, 0xd2d32b45, 0x4c584a6e, 0xbf4b4fdf, 0x79ed4b01, 0x19885d83,
- 0x71b24c57, 0x64dcec3f, 0xfc18b103, 0xed1b24cd, 0x9de7b4ef, 0xff1415f7,
- 0x37bb8c76, 0x37bc31c4, 0x37bc31c4, 0xe53e1a48, 0xcebf9078, 0xf7975bba,
- 0x4967c1b4, 0xd10f2010, 0xb9f28e9f, 0xdde8c5c4, 0xf682bef9, 0xdca21f4d,
- 0xc4941730, 0x436c9106, 0x21f167be, 0xafc87ced, 0x4024cf7c, 0x96db94be,
- 0x16fbfaa5, 0x0604df46, 0x530df9f7, 0xb214dc70, 0xe2983ac6, 0xc9a96979,
- 0xd3a3710d, 0xc2723f0b, 0x1985e991, 0x0f20792d, 0x1b8f79a7, 0x984a97e6,
- 0x8e6cb85f, 0x2ed30814, 0xc2a81b93, 0x01ba7462, 0x4ccb3bf7, 0xc7aef331,
- 0xe9fed8d8, 0x961738d1, 0x90d36969, 0x92f59d4e, 0x8c4bf004, 0x35e54a7c,
- 0xcea8f17d, 0x6f94cc73, 0x790c5b14, 0x1349136b, 0x185beb87, 0xb1ac95f1,
- 0x35b7aab3, 0x39064979, 0x52ab7d84, 0x3a3547aa, 0x4d5f500f, 0xfe28b8c1,
- 0xbfd7a171, 0x79c37f06, 0x45ea015d, 0x10c88e4d, 0xa0ade7a6, 0xa1e2a377,
- 0xe83f7b6d, 0x9f8efb0f, 0x0739dbfc, 0x55fd3bec, 0x9e807768, 0xbbcf7e3d,
- 0xf4c7380e, 0x2e2c3dc9, 0x4fc18772, 0xfa63645b, 0x74ad8f7f, 0x8177e01e,
- 0x9e791fef, 0x77257e28, 0xe593fdb3, 0xde70de01, 0x506f7f5d, 0x70c93055,
- 0xf11f908f, 0x1fdea55a, 0x46c7a466, 0x2cb78b1b, 0xca59b1df, 0x4f7c6190,
- 0x5c7f8c25, 0x378f43f5, 0xd1dfd03a, 0x63b859e0, 0xd9be0484, 0x7566435f,
- 0x6445bdff, 0x025287eb, 0x151e67fb, 0x0f38466f, 0x2f6af7aa, 0x8fcb25f9,
- 0xdd63a329, 0x27b0f54d, 0x187bcec4, 0x13e4b1e7, 0x129528b9, 0x1cfdc96f,
- 0xfef0ddfa, 0xf33d743d, 0xee1f7ddc, 0xd9e719b3, 0x051f5ef5, 0x2a65b3fd,
- 0x6de78dbd, 0x3ed88597, 0x41e262f8, 0xfe72ecf9, 0xc5cec436, 0x678de318,
- 0x00db650f, 0xa9b0bf0f, 0x323cc4f1, 0xef6dce06, 0xfe20343a, 0x9f56f772,
- 0x828bef52, 0x3ca1bb7b, 0xce5823ee, 0xe2902303, 0xf6f432bf, 0xd55fc05d,
- 0x3ef13b4d, 0x8faaefb4, 0x9c2742aa, 0xe9ad4b90, 0x6e876a25, 0x8b20f903,
- 0x5a7d9d39, 0xc49cf9bd, 0x9f866afc, 0xb7e7d4db, 0x20723e01, 0xd9fe5bdf,
- 0xdbef4a04, 0xd1f3c52a, 0x6f3da5f7, 0xf7c3efd3, 0x3cdabe76, 0xed6b79b5,
- 0x9c5e6a55, 0x0e4d3bf1, 0xb97ca9e6, 0x75f4eb78, 0xea8a297d, 0xa9917ef6,
- 0xf3c3939e, 0x2d9f1a42, 0xe945a523, 0xa349f831, 0x84df076f, 0xd3f38e7e,
- 0xbeb8bae8, 0x3f83c54c, 0x4c4fdd4d, 0x91957883, 0xa73a7a8f, 0x32462add,
- 0x7c8dbe41, 0x7dcddad2, 0xb31b2128, 0x4acb162f, 0xa8cfc411, 0x15cebbf9,
- 0x171cdf65, 0x14fe0fea, 0xe32b6ee4, 0x083d0efb, 0xf7e8314e, 0xff5c4537,
- 0x54e43a57, 0xe90fffb8, 0x13f20e37, 0x4f787ecc, 0x4f98e71b, 0x808a0651,
- 0x4f2c62ff, 0x81954afa, 0x97db3a83, 0x04e73c6e, 0x086dbbfb, 0xab51b8c1,
- 0x69ef0f43, 0xe37a8f1b, 0x4a8f4ab4, 0x3f9be5a1, 0xdadace83, 0xc7177982,
- 0xa771a92e, 0x58e2e64b, 0x39d8b4f3, 0x7778bddd, 0xf9a872a8, 0xfa540b35,
- 0xfb6211dd, 0x4d370be9, 0xc9747a47, 0xa1fd54bf, 0xf50e46b2, 0x4b3e918e,
- 0x3e63d7dc, 0x3e40a2da, 0x5e85df7e, 0xbba441e4, 0xda776e91, 0x371eec5d,
- 0x7b8246a1, 0xe26d8eed, 0x8571ff70, 0x73ff7b10, 0x9df4ddb6, 0x479c63e6,
- 0xdb2ff077, 0x2faebb5a, 0x908ff981, 0xf08dcf80, 0x425ff36b, 0xd4a7a614,
- 0x2f3776f9, 0xf2c49912, 0x7f75d434, 0x815b9c39, 0x790793fd, 0xc6adcf96,
- 0x35f834a1, 0x28f38d78, 0x7cf12be2, 0x8f035b41, 0xf877d979, 0x77067dd9,
- 0xfd70e5ac, 0x9a4e8eed, 0x7bf6d15e, 0x30ca9baa, 0xfb43cb6f, 0xedb63b01,
- 0x29f6c263, 0xcf7873d6, 0x0cf4b75b, 0xeea57cb1, 0xa30849e8, 0x374a62db,
- 0xdebb3ff0, 0x0caf909f, 0x0a27de8c, 0x8c0ca0dc, 0x4122b7de, 0xb15957cc,
- 0xf9eeba7d, 0x8e35768d, 0x9ef5eaa5, 0x24d48fe4, 0x696f8cc4, 0x9fc9a6f2,
- 0xda778f26, 0x0a6f6665, 0x59198381, 0xd1879f80, 0x7afaa1bf, 0x3df99d9e,
- 0xafa5cd0f, 0xa73c6f54, 0x3258a7db, 0x096bd196, 0xbbcf825f, 0x0f14bbd3,
- 0xd8bdbd3a, 0xf8c3cfae, 0xe6d1f3a1, 0x3689c9a1, 0x189ca33f, 0x43d237bf,
- 0xe919ef8b, 0xc007a462, 0x5bc67e09, 0x35816d7b, 0x38b7ce14, 0xaf7fb706,
- 0x4d6ee115, 0xb9c0ac9b, 0xf9f4eacd, 0x3e01fe58, 0xb0fb074c, 0x768eceb4,
- 0x8d87eaae, 0x225c5dea, 0x5ecbb557, 0xd9232ab2, 0x24d2a7b9, 0xb58993e0,
- 0x17161991, 0x583e8f21, 0xa4f7045c, 0x32387c4e, 0xbff14203, 0x5646f07e,
- 0xd77916df, 0xfcfb86e2, 0x690a8a4b, 0x2fd071fd, 0x95fa2fa0, 0x6efbe0db,
- 0xf973c4eb, 0x1fdeccba, 0xcf9d2e65, 0xed66b1ee, 0xb33ed495, 0xf2aef5d0,
- 0x4157e0f0, 0x4a5b2b7e, 0x542e218a, 0xba781109, 0xce2955de, 0xad872db0,
- 0x7be9e3fb, 0x4f3cd91f, 0x76ee21d9, 0x8bae2d71, 0x94058795, 0xc588722f,
- 0x573a0567, 0x6d6efd2b, 0x2993b51c, 0x5a26d77e, 0xd317e0dc, 0x97f07ee7,
- 0xb22a26d7, 0xa35cf51c, 0x70077c1f, 0x7cb135ac, 0x0c6ffd82, 0xc65c8f8e,
- 0x23efd82e, 0x34cfe025, 0x1a582cfb, 0x1725f3db, 0x37c8e79e, 0xb18978b1,
- 0x76bb6dfd, 0x00ce49ae, 0x243ea8be, 0x1fc3fca1, 0x84559fd8, 0x613549c9,
- 0x0eaad0e7, 0x53773c13, 0xcf08a87d, 0x84b9c0dd, 0xe07a754f, 0xa6ee735f,
- 0x9e18af93, 0x44ae040a, 0xd0b71a88, 0xf9d5d56e, 0x9810d354, 0xdce3e10f,
- 0xcf846e70, 0xa2ecd530, 0xa0afe7f3, 0xe087c525, 0xff70f372, 0x89e4fd4c,
- 0x559fdc3c, 0x2d79aa27, 0xbe3e7626, 0xe557dd63, 0x39fb2b4f, 0xdd028f4a,
- 0x25b1ff4f, 0x53f6c6cf, 0xe6d6afd0, 0x8429c75b, 0x35ed7f03, 0x7219e782,
- 0xe0334993, 0xb19446cf, 0x47166fc0, 0x6c97caa2, 0x65fe9b3f, 0x9b36e940,
- 0x7e53237e, 0x9fc1faff, 0xe3bbff22, 0x68b2ab4d, 0x59f8739d, 0x2e74c33d,
- 0xef30b28b, 0x6bf565a8, 0xd006e74c, 0xc358e8ba, 0x4af1b0ea, 0xa3b33e17,
- 0x143fc8ae, 0xba3171c6, 0x01ae50ee, 0x2c4c16fe, 0x901c23ae, 0xcb477f70,
- 0x794b5957, 0xe2d1f806, 0x5d747a60, 0x3673c16d, 0x28179b88, 0xec4fe432,
- 0xfa41ef51, 0x5786a5be, 0x7f4266de, 0x7fc04a09, 0x53e183bc, 0x54690ba3,
- 0x5e3c81ae, 0x81ae5412, 0x0e7ebd7d, 0x7e83a24f, 0x96adf23f, 0x1bcfa089,
- 0x0f28f9df, 0x82bf73ef, 0x2df233f5, 0xf9d243ea, 0xff6dfe9c, 0xe4fbd1cd,
- 0xa9f91cfd, 0x03251df0, 0xec9cafda, 0x3951b722, 0x2c8853ac, 0xad9f8365,
- 0x091b2ff7, 0xd91f4fd3, 0xa070af4a, 0x3ae3093e, 0x67bb13f6, 0x7e8dd400,
- 0xec496933, 0x949dde55, 0x17ee3773, 0x7d346625, 0x85d610b8, 0x4a7bb1df,
- 0xfcc14538, 0xee3b17d3, 0x9718236b, 0x373891b2, 0x9b898dc4, 0xd453f9a4,
- 0xf1899af8, 0x945e7255, 0x87ceacff, 0x79085f7e, 0x2c6c63f2, 0x8fce81bf,
- 0x823afd07, 0x848e58c8, 0xa0365938, 0x3df583d8, 0x4fe1f824, 0x588fff69,
- 0xb2ca7c59, 0x8fe2e89d, 0xb7160e65, 0xe2c9c079, 0xf062718f, 0xe22bb016,
- 0xd81710ce, 0x4b8f6d15, 0x0bcfee02, 0xdf709bae, 0xe309a0ee, 0x018b4fdc,
- 0xb517ec17, 0x5bc8255f, 0x6d7f6748, 0x7eb5dd2a, 0xabe4911f, 0x0bf7ee20,
- 0x9d3fab27, 0xbb8f304f, 0x801484fd, 0x0cc4dcfd, 0x3c744d4b, 0xd9839e69,
- 0x1573bfbb, 0x043a04cc, 0x1811c6f7, 0x38becc7f, 0xb9e3d013, 0xe056b91d,
- 0x4701178b, 0x66890f14, 0x5fd09dd7, 0x6f0a39e2, 0xf9673e16, 0x223c82fd,
- 0xfc77e29e, 0xee19768d, 0x1ada7ad1, 0x56f311bc, 0xbde1379f, 0xee4a2fc1,
- 0xf17f50e9, 0x3d02ecac, 0x305674fc, 0xbcf3e70e, 0x62f3e709, 0x2bd5fb5c,
- 0x0c0fdc29, 0xc12ef161, 0xcfd00446, 0xbe40a982, 0xae5f3e93, 0xafa6b1f2,
- 0xd11c8137, 0xc11c23fa, 0x29820c73, 0xcb48e51f, 0x276b6a27, 0x67d44f98,
- 0xfc0f0b66, 0x8b5d371c, 0x8879853b, 0x25284d17, 0xb04dcf68, 0x05ce788b,
- 0xbce199f2, 0x0f5544db, 0xb2b8fc4f, 0xbb07e584, 0x9ebdc30f, 0x7ef576cd,
- 0x739f7530, 0xd727ca92, 0xa16f0891, 0x245dd7ed, 0x4d27886e, 0x8fdfa8ba,
- 0x5f60ca78, 0x57fb514e, 0xf0855dda, 0xede89f38, 0x450d29bf, 0x2c3d6027,
- 0xfc008a20, 0x6862d934, 0x09d23b07, 0x9febf0f7, 0xfd50e03f, 0x19924cdc,
- 0xeda6c79d, 0x87e14d43, 0xb5fb446e, 0x5e037258, 0x0f95da76, 0xdfc03f20,
- 0xc5cb9222, 0xb1f29f25, 0x1721c37c, 0x2cae046d, 0x8769fca4, 0x50dd5cf9,
- 0x79d2b7ef, 0xf5903d5f, 0xfa087c0f, 0x93c7cae5, 0x8fdf4093, 0x95a5e957,
- 0x7f01df1a, 0x7f19e2b9, 0xca7786b9, 0x2c8ed3e7, 0x37934f7c, 0x67e83be0,
- 0x1f98188f, 0xf29bbf6b, 0xafc0d3eb, 0xfd04ed3b, 0x5ba59fb8, 0x699c80e6,
- 0x7caab4e3, 0xd5d72c6d, 0xbf0fdcae, 0xc0bfe4fb, 0xbec28dd6, 0x75e8a517,
- 0x83024fbf, 0xcfd72bd7, 0x68790698, 0xccf31176, 0x5173d452, 0x1e92fcd1,
- 0xdf1a2fc5, 0x9c59dab5, 0xc99fe348, 0xe1e5dfbb, 0x840be4f9, 0x8748b2b8,
- 0xcff1a2bf, 0xf7187f44, 0xe6122781, 0x67f9189f, 0x93fc3757, 0x40165e7f,
- 0x9fe1756f, 0xba7f8c43, 0x0fda1be3, 0xe4616bde, 0xaa1c779f, 0xff2dddbd,
- 0xfcf3c25c, 0xbe4ef7ab, 0x93657eec, 0x6a9f9f4f, 0x62d9c72c, 0x54bb2fe7,
- 0xea96efbc, 0xbd01ca6f, 0xcec4d531, 0xe32409ef, 0xeeef0a16, 0xfcdeed38,
- 0xefa86c9a, 0xda1e9814, 0x1ea33219, 0x78f769da, 0x669b7e30, 0x0557e761,
- 0x23ce044f, 0xe45afbb8, 0xd921dfe8, 0x587660ee, 0xfb8f0c50, 0x37f1ec02,
- 0x9d8c1f18, 0x2a43cb9a, 0xa662fa5a, 0x971d4617, 0xcfefc336, 0xbfccea3d,
- 0x06967c00, 0x79dfa3b8, 0xcf784a8f, 0x0951f552, 0xf76fe3f5, 0xf1045dbd,
- 0x79cf2d51, 0x8bb79ecc, 0xfbc2860a, 0xa1fedf8c, 0x8ead65ea, 0x5f404047,
- 0x1fddee1a, 0x4b1e71d7, 0x297e6f7f, 0x674e51f0, 0xf93ef1bb, 0x3fdb1c60,
- 0x11644d99, 0xb4719886, 0xdeb85ef4, 0xfcaf78cc, 0xff3b30ec, 0x27b0f336,
- 0x2af2bdf6, 0x37ef187f, 0x8a77f6a7, 0xe7efec13, 0x6841f65a, 0xdd6cc884,
- 0xd7354a0e, 0x26a33f30, 0x9349f81b, 0xf8a3fc43, 0x44327e0b, 0xb706bbf7,
- 0xd07ff3a9, 0xa9fbb02d, 0x4bee1222, 0xefb09cfe, 0x363aea82, 0x40f4c9ca,
- 0xe617eaee, 0xcb239c03, 0xcba06695, 0xd7162eb3, 0x5b0905f9, 0x6e6e81b2,
- 0x8253f701, 0x0bf93ca2, 0x223df3ae, 0xd3b10e94, 0xe27d3df6, 0x8ff8c246,
- 0x9c633d3a, 0xed099f60, 0x31bbe087, 0x824773e3, 0x588fb71e, 0x9aeb049b,
- 0xab853706, 0x13bd9b78, 0x81ae0d0e, 0x8f97c64e, 0x00c6cb3a, 0xd03be01e,
- 0x8e474d4b, 0x8d7be059, 0xcf7b821f, 0xe2883e30, 0x4e83e00b, 0x4016e0be,
- 0xa283c35d, 0xfdb7cfae, 0x8b42f88b, 0x17c8f46b, 0x7e70b710, 0x0b98be2f,
- 0x05f23578, 0xce3ce7b5, 0x505cf618, 0xc6937962, 0xe7b13fe7, 0x896efbe3,
- 0xd913de60, 0x6bbf6567, 0x7dc049e8, 0xd8b8df90, 0x1c9f6d98, 0x28a6a4cb,
- 0x7664e559, 0x2a3bf6bd, 0xda1cc223, 0xa2a8239f, 0xbced0db8, 0xdd27a87e,
- 0x31c8fe2a, 0x46fb838e, 0x033e3731, 0x1270d0ec, 0xcc236bd8, 0x87906125,
- 0x1989b65d, 0xdae63f60, 0xfcc36426, 0xfab21e5f, 0x5ed2584d, 0x9bfe5bee,
- 0x7da772ad, 0x66c3e9a5, 0xfc6d5bb5, 0x4c7f2a35, 0x2779d852, 0x70d1ebd0,
- 0x9003eb68, 0xc2e0e009, 0xdadf4db3, 0x22878f50, 0x00936f14, 0xfd878a0e,
- 0xfb04691c, 0x24a4df21, 0xb03b064f, 0x3800584f, 0x9d7ef6db, 0x92cef109,
- 0x021febd0, 0x3eda25bc, 0x0fbf5bac, 0x35b7b46b, 0x3ff3487b, 0xf3497b34,
- 0x82aec17b, 0x1fd532f6, 0xbed99971, 0x05b084d8, 0xe47853ef, 0xa2957cac,
- 0xe740b3ca, 0xe3cea251, 0x7082d266, 0x4ca9f769, 0x7251f153, 0x39abfa88,
- 0x54c84ed0, 0xeaa9878a, 0xdd532a7d, 0x6e22fbfa, 0x3efb1b1e, 0x9e9fad15,
- 0x1bae37de, 0xa3f61ad7, 0xc879687e, 0xf94feec7, 0xc3f98fbd, 0x7ef007e3,
- 0xb1dfd601, 0x09feec59, 0x21c3c317, 0x763af629, 0xf1eb9551, 0x9c0e48a6,
- 0xe7bfdec7, 0x1e6eb8ef, 0xf7f7f3d8, 0x771c8ec1, 0x97902042, 0xa8c4fe3b,
- 0x180fcc78, 0x695f232b, 0x6f3f7afd, 0x9cf611b4, 0xccdeff44, 0x728f0a41,
- 0xc167c025, 0x8f5395f2, 0x9dfd0a3c, 0xe8902a3f, 0x92451f73, 0xe5c42067,
- 0x1ddfd48b, 0x7b31c83a, 0xa83f6b4a, 0x11c7defe, 0x21216f95, 0xc567bb43,
- 0xa9e7451c, 0x1a1ffdea, 0x2f1ea75d, 0x74e4213e, 0xfdfc0fa5, 0x5a10e233,
- 0xaa9ce1fc, 0x9ff3490f, 0xf5ce7cf0, 0x600a778d, 0xc69f5fbf, 0xdc6a2513,
- 0xe9ea641b, 0x4e21c547, 0x6ff60d3a, 0x4e8f33f3, 0xb7e5bc83, 0xf4814c78,
- 0x99be7686, 0x3e16f503, 0x462abde6, 0xba1f5efc, 0x9955ef13, 0xa3e4cf1b,
- 0x5fc7f1a7, 0x3864f94d, 0x3b309dd0, 0x4bdd8f30, 0x81efa462, 0x1491ff3d,
- 0xbe3dda19, 0x91bfa3bb, 0x2a9caf0e, 0x9eac7dc0, 0xdbe461e8, 0xfe9e747d,
- 0x5377e12b, 0xbf8fc42d, 0xfac2ea9b, 0xac34beab, 0xddeafc6b, 0xd81264fb,
- 0x4e9f1a79, 0x337c6249, 0x49a3f76e, 0x2f49dec4, 0xc586de23, 0xc97ffe33,
- 0xee25d9aa, 0xa3e8d359, 0x843ae977, 0x2d27ea8c, 0xaa563790, 0x70fb3ac2,
- 0x4425da11, 0x5c62cf3d, 0xb7f366df, 0xda75014d, 0xccfeefd3, 0xf57acb94,
- 0x6fc5397b, 0x0eb00bd5, 0x99ab0916, 0x78ed531e, 0x9d231e0d, 0x08a523df,
- 0x19f0777f, 0xe708c0f9, 0xf6f91d4b, 0xda07ae0a, 0x18cce0ef, 0xc6262598,
- 0x8f868798, 0xc7ae8499, 0x8f5fbdd9, 0xdbd78c6f, 0x178ee7ef, 0xdad011fe,
- 0xe919bc9d, 0xf4d76c66, 0x900c1147, 0xec1fa58b, 0x29f1b993, 0x8ba2df48,
- 0x3ae85112, 0xcfe9fa43, 0x2b9293f5, 0xb956df91, 0xf8eeb3d8, 0x4f22faad,
- 0xf93b233c, 0xd87a6c4e, 0x5bb77c06, 0x1c41b7a8, 0xf4fb3af5, 0xc2bd103a,
- 0xe2660bcf, 0x131115fd, 0x94dad081, 0x886699d0, 0x243f7833, 0x20a1be78,
- 0xf0327fb4, 0x0b42abe9, 0xe76d59fa, 0xca387909, 0xd50a6cee, 0x6b2ec0d9,
- 0xf3e7664a, 0x5d10260e, 0x78c5f4fe, 0x8e9a6fa6, 0xc4a69d9e, 0x62ee1f68,
- 0x28833cfc, 0x9ff439c9, 0x7f29eb45, 0xc7dc1f80, 0x42927181, 0x325afdce,
- 0x39732dd8, 0xf6da23f4, 0x992d798e, 0x7b7adbc2, 0x2999ea02, 0xe9ddf74d,
- 0xfe0884a2, 0x6f3e2463, 0xfef0e32f, 0x8dd92284, 0x59c5a2f5, 0xf98df7e8,
- 0x09466926, 0xa220dfb4, 0xaf8533df, 0x755e2014, 0xabc38d3a, 0x9170f63c,
- 0x623df85a, 0x0e3674ff, 0xc093f971, 0x24a77d3f, 0x66fe0469, 0x07d5ac9e,
- 0x122eefe1, 0xfab6ff83, 0xcdfb73a5, 0x2cf57db4, 0xa78df30e, 0x3f8832b8,
- 0xd68a7f8a, 0x5baf384b, 0xc005a942, 0xf58a33d7, 0xaac31ee7, 0xd4ab393d,
- 0xfbd10246, 0xe50b9cf9, 0xfdb5a0fa, 0xf11dfc56, 0xf98122bd, 0xa37e7269,
- 0xe7b3efca, 0x9bbee924, 0xa9dd984e, 0xaa4dd5c9, 0xfaa8ddfc, 0x193d73cd,
- 0x094bf1ba, 0x40fe87b3, 0x64810bda, 0x7ed8b8f7, 0x96f6b4f4, 0x25e1f3c3,
- 0xd068dfbe, 0x310d3787, 0xe57cbdf8, 0x348be45a, 0xc8f78dce, 0x37edf5b8,
- 0x8dd7d58f, 0x0fd46bf2, 0x8f8b20b3, 0x3427aaef, 0x2f6b307d, 0x683c422f,
- 0x33c53e56, 0xbb7ac5da, 0x317d27bd, 0x7d1bae26, 0x17be4971, 0xfa2e90cc,
- 0xefe2e3e2, 0x4b7e2fa5, 0x54b196dd, 0x578edfae, 0xa4fecdd7, 0x298de83f,
- 0x81478efc, 0xbae8da8f, 0x47c18e69, 0xc5a3bada, 0x1ca88a01, 0xc5381ea3,
- 0x5ca663f6, 0x91fe274c, 0x0e80719d, 0x12ed423d, 0xa97b0c77, 0xe51b3e35,
- 0x68ef43ab, 0x2eca257a, 0xb87ef311, 0xda85325d, 0xc02e52a3, 0x2be10fd7,
- 0x2925ef52, 0x882b8482, 0xc19da61f, 0xa0579038, 0xcfae2cfe, 0x817f224f,
- 0x3b12e3fe, 0xaf68c3e5, 0x0ae87168, 0xe94f6697, 0x1e23a5f9, 0xc3dd9339,
- 0x1149f1aa, 0x7fe413e0, 0x04fb8f26, 0x7fd41bff, 0x8000b303, 0x00008000,
- 0x00088b1f, 0x00000000, 0x7cc5ff00, 0x55547809, 0xf579f096, 0x55492d5e,
- 0x146caa92, 0xb612f08b, 0x84582484, 0x5916ec80, 0xa014a358, 0x8168cb80,
- 0x9a126b0b, 0x69ee9c71, 0x0242a6ff, 0x83b74343, 0xe8cedad2, 0x3ad857f4,
- 0x08b41a83, 0xd09d0301, 0x584c5015, 0xf82e0834, 0x1a6d1ad9, 0x84490ed1,
- 0xbfbb46d6, 0x739cffcf, 0x2aaa4bef, 0xffff4d85, 0xb49fdf3f, 0xdeefb97d,
- 0x67b9ef77, 0x979ee73f, 0xb3559bdb, 0xf6e008ad, 0x14078a99, 0x77f1d000,
- 0xe042c022, 0xadacc37f, 0xc78ef016, 0x69fcd7be, 0xe7f80d87, 0x9c2ffc3b,
- 0xa42cfc90, 0x900bcf50, 0xce54b009, 0x7d57fc5f, 0x3c5e3d33, 0x52fe7a27,
- 0x92b9fd98, 0xf81b700c, 0xf71c30cd, 0xff8ec5f3, 0xc7154bec, 0x7e8b2e97,
- 0x4a4ce99e, 0xff8790bf, 0xbe230118, 0xd4ca0153, 0x22b79dba, 0x5527ddbc,
- 0x334c558f, 0x390ffed1, 0x350ffec5, 0x7c800c97, 0x1674df80, 0x3db1f8a7,
- 0x1c2111b6, 0xd1bad00d, 0xec71edc6, 0xefc5f107, 0x3c66e7e8, 0x21fc059f,
- 0x52b4b607, 0x4801b721, 0xc4ed1805, 0xff602745, 0x0d3f9e2a, 0xc02486c7,
- 0x5c2473ef, 0xe7af00d9, 0xf104e798, 0x5eb8c3bd, 0xe30dd700, 0xf75c01fa,
- 0xf72746c8, 0xe6e8db5f, 0x442e0dfe, 0xfac0066a, 0x37af2714, 0x8776f72f,
- 0xe35bdf1f, 0x50e7e6cc, 0xf844da3e, 0x7b2fe036, 0x1004086a, 0xac77afdf,
- 0x807494d0, 0xb1e2b72a, 0x01d1f566, 0x8e58e34f, 0xbe25cbf3, 0x102ab72b,
- 0x1fe5e7c4, 0xc4072bae, 0xee33575f, 0x2aa9f887, 0xfc368355, 0x63d34967,
- 0x0cdf453b, 0xdefa08d6, 0x33028e22, 0x86cd16b5, 0x28f02cfb, 0xf1f7151e,
- 0x6ff78936, 0x1d412af5, 0x278b79ff, 0x63871e9a, 0xae58bee8, 0x0ffe80b3,
- 0x47305bdf, 0x9d718609, 0xdfa29305, 0xd6757c5b, 0xfed8cae7, 0xe898b47c,
- 0xbf3fb63e, 0xb7744edc, 0xc1863fe3, 0x95fba230, 0x8d6fa58b, 0xc5ba3e85,
- 0x8e74b1b6, 0x9d16bf1d, 0x673a27ef, 0xc6ce9b5c, 0xce8b7ffb, 0x904e110f,
- 0x1bf470be, 0x30049e8b, 0x1a07e9bb, 0x55f679d1, 0x32add78d, 0x861433ce,
- 0xd4fe79d2, 0xb76ff859, 0xaafcdf42, 0xfe2d2fa6, 0xe79f6b82, 0x22bfed6f,
- 0x69fde745, 0xdf7e6f5f, 0x8034f3be, 0xf9ce78c1, 0x8df8d139, 0xbd2c6ba5,
- 0x62f7ca16, 0xe635b5e9, 0xa05d061c, 0x60689913, 0x555fbc1c, 0xd16b8e19,
- 0x162e97ad, 0x7e4f08ff, 0x5f8071ff, 0xd6fab9f3, 0x76827493, 0xe02057cd,
- 0x03c84732, 0x052075f2, 0x0ade5be9, 0xec0444e1, 0x3e738b96, 0x28f5a8d7,
- 0x39c469f0, 0x8353e7e8, 0xfadf6ace, 0xb2075765, 0x96fb19fc, 0x14b01069,
- 0x972173d2, 0xd255f0b1, 0x7e69233a, 0xcb68f980, 0x10b2d32e, 0x05ba639e,
- 0x9b51f5ee, 0x4e03da28, 0x9d1a07a1, 0xfbb75e26, 0x6e099b2b, 0xf0e57804,
- 0xf8406280, 0x09e7563c, 0x33218bd2, 0xc945fbf0, 0x9cdfcf3a, 0xdc048104,
- 0x9b76b41f, 0x2b44f90f, 0x3941c806, 0x825906d3, 0x9d64b835, 0xdc91f616,
- 0xa8347b75, 0xd1bbb946, 0xe048ef78, 0x6c92402e, 0xa99474fe, 0x0fde8b26,
- 0x79c54fb7, 0xfa6a1537, 0xb2e29c36, 0xf1a03fea, 0x93ab66ae, 0xf83eebde,
- 0x5a662dcf, 0x20f02be7, 0x335af084, 0x4f8e1532, 0xa4839873, 0x93d4ca37,
- 0xddfb09aa, 0x8fa4003d, 0x970b2da6, 0x3a6dd200, 0xb138d7b4, 0x8c74429d,
- 0xd0bfbf43, 0xde843379, 0x9a74881a, 0x4334e921, 0x6692abea, 0x4946f595,
- 0xac841a92, 0xb374fd3e, 0x408cd1a4, 0xee0a497b, 0x3c53433b, 0xf9bfd835,
- 0x8fc516aa, 0xba3e932f, 0x951f4fb1, 0x3dbdf5c9, 0x019686ba, 0xff344266,
- 0x3d0a3596, 0x798b6254, 0xbe0fed2e, 0xe6557cc9, 0x429f1e8c, 0xfbf913ba,
- 0x825e8c62, 0xa653fb18, 0x03b935fe, 0xc58af0f1, 0x8454defb, 0x19b4e7bb,
- 0x70e7c59e, 0xfb933b11, 0xc631a7e3, 0x07b6c51e, 0x757a270f, 0xe215eb84,
- 0x07f50723, 0xd7b1f579, 0xa3b63f9e, 0xf18e98a7, 0x0d22dd4a, 0xcf2d99b2,
- 0xf0fb33ba, 0x92bf0fde, 0xad78b10e, 0xdbde7a97, 0x8e8d7ce8, 0xad8f0fdb,
- 0x979ed8b3, 0x48d749fc, 0xf8bdfdf5, 0x95e5e434, 0xe25e890b, 0x0c2e57ff,
- 0x4afdb2f2, 0x0c3e59d2, 0xfe783879, 0x51e92272, 0x21aea7c4, 0x6cb8f49f,
- 0x9f99679e, 0x06841c85, 0xc36e0a8e, 0xc12485fe, 0xf624aff7, 0xbc23cf1c,
- 0x3cf262df, 0xeb68db4b, 0x202a2f87, 0xd175b9fd, 0xe2803379, 0x2887e505,
- 0x84ee8a4f, 0xa00db1bb, 0x05ff113c, 0x72482152, 0xd0108662, 0x785e35be,
- 0xd319da9a, 0xfbc214f4, 0xddb35c65, 0x29e9eb41, 0xd7f0f7c4, 0x057d132b,
- 0xbf5ff1fd, 0xee1a7c11, 0xe6d1b0d3, 0x1c2f50d3, 0x7ee4e8d8, 0xb73746e3,
- 0xdcea3687, 0xfc913a6e, 0xaa1ff243, 0x169f16bc, 0xa5e657a1, 0x0330fd0a,
- 0x35c10ef5, 0x00609403, 0x23c66f79, 0x7288f2c0, 0x10a4dc10, 0x393cf0bd,
- 0xfa44f87d, 0xe888ee5c, 0x3b56ad43, 0x82a59321, 0x67985ee9, 0x09d1f7e2,
- 0xd59f3e08, 0x3fd23e7f, 0xfc8cbfaa, 0xefc38416, 0xb0b996f2, 0xb37c390d,
- 0x7adf885d, 0x4bd1e965, 0xf4b9fdc0, 0x43b95ebc, 0x8feb84bd, 0x1f84cf0f,
- 0x8f18bda2, 0xe2bc2184, 0xff045dcf, 0x100b1684, 0xb2b0d07d, 0xf21a167c,
- 0x5ca2b5f9, 0x8448fdc0, 0xef8c1bbe, 0xc4c3cb59, 0x23a0074f, 0x645ef08d,
- 0x7e49d9f3, 0x3f04b997, 0xdddb9578, 0x3937ae0a, 0x0951e2c3, 0xf1bee1b4,
- 0x2d7f11eb, 0xce21b819, 0x1cc9696f, 0xb713e7a2, 0xc93ef1bd, 0x08e6d7b7,
- 0xcc986cab, 0xf6111d9d, 0xe33c007c, 0x74927f24, 0x476877dc, 0x0e4e3f5a,
- 0x6abb9eb0, 0x6b5e9209, 0x09ec933d, 0xafd33ee3, 0xacbfd8da, 0x6e5117a7,
- 0x8f26270f, 0x42133d65, 0x63f2430d, 0x6d98e713, 0x3c23aff6, 0x7a3e65a0,
- 0xedfbdf0a, 0xafd20065, 0x543fdbd3, 0x312d0fc9, 0x40e80ee5, 0xa32a8f38,
- 0xf27da853, 0x6e7ce4e3, 0x127724cf, 0xec9b0e7e, 0xcefbed3a, 0x0474bd46,
- 0x8da9cbf2, 0xf9023a50, 0x368dade3, 0x746f4f6e, 0xa3667b72, 0x38a3db9b,
- 0x3af3fc4e, 0xbd7f138e, 0x6fd4e381, 0x4f6a71c3, 0x7ad43ae0, 0x489872df,
- 0xe5bc677e, 0xbc2da8d0, 0xfadb892b, 0x742c933b, 0x50c9c38e, 0xfc4fec67,
- 0x370c4e14, 0x2ee50780, 0xdb53fdd5, 0xad3f680d, 0x1c6502fe, 0xf754d4c0,
- 0xae3a6d5c, 0x8fe87b3b, 0x19f1c2be, 0x6a7ec3a9, 0x3b6f7843, 0x893868e3,
- 0xf5c7d2fd, 0x3f883a9f, 0x92a2244f, 0xb7643c24, 0xc7365179, 0xc418d293,
- 0x24c2f768, 0xfd19a7ec, 0xc8a5b9ec, 0x3a4a4b0a, 0xb005c0f2, 0x73e1b1f3,
- 0x25df886d, 0x513fff76, 0x9b6812df, 0xfa9d3a53, 0xbc927010, 0xcb20e62b,
- 0x7d2510fb, 0xadbfda11, 0xd4c4ff0e, 0xabc07f08, 0xf48d21fc, 0x02af44c3,
- 0x77a674ae, 0xf7d2a470, 0xd5b798dc, 0x15313651, 0x2ed7f7f9, 0xc269f995,
- 0x741bc534, 0x635f97f4, 0x7af384de, 0xe26fd129, 0xd4b559c5, 0xe2e3982e,
- 0x4dd96fbe, 0xa5ff24b5, 0x5fbd6b8e, 0x5c87efc2, 0xc547d666, 0x638bce1a,
- 0xe3798d17, 0xffc8c991, 0x0c4b69ee, 0x7d7c4b3e, 0x84935fd6, 0x567732fd,
- 0x34752aa1, 0x6bb5df70, 0xbf978d1b, 0xe572c0de, 0x59e8f249, 0xa5ed8ac4,
- 0xd33e3869, 0x24c278a1, 0xa93ed32a, 0xa771a34d, 0xcdb421e2, 0x553b8ef4,
- 0x5423e344, 0x9fea4ccf, 0xd89d4bd5, 0x4e66d19e, 0x66f384bd, 0x6c78a4e7,
- 0xf099def8, 0xff10ae8f, 0xf249ccce, 0x1714e824, 0xa4ae9f04, 0xa9eac7be,
- 0x8f1ce9d6, 0x3ad32495, 0x6131e2ba, 0x92d6febf, 0x147045ff, 0x514052fb,
- 0x91a5dc68, 0xc7e4fb1f, 0xe275293f, 0x0aa1fabc, 0x099cfc90, 0xe091fee7,
- 0xa89ad99f, 0xf5402027, 0xbd296716, 0x9c516f57, 0x2befb89b, 0x5181f9a1,
- 0x5c79fd66, 0x769de4f7, 0x6fe507b6, 0x745fb3e5, 0x6cc1cef2, 0x9adfca17,
- 0x49ed4c56, 0xcbdbf093, 0xc39f2adf, 0x930826e3, 0xebbf2952, 0x1dbdf81f,
- 0x4d293f25, 0x0c4ff5c7, 0x416eb173, 0x116a953a, 0x83e70d7a, 0x55dfef42,
- 0x945bf3c1, 0x8f3a3f01, 0xa7e4aff3, 0xff715a14, 0x5109e959, 0x710ce7f3,
- 0x8de7f545, 0x45aa5818, 0xfcf2b1d8, 0xadfea8ac, 0x88e94a45, 0x69bef988,
- 0x45fd5109, 0x11d2aea5, 0x2b6ff311, 0x5fd5181f, 0x54565b72, 0xb269a67f,
- 0xa11b1fd0, 0x7dc854bc, 0x9bfb2979, 0x0a87acd9, 0x1bee629d, 0x8e3f7e38,
- 0x7f09b617, 0xfe85d0aa, 0xb4a5d214, 0x80fd88ad, 0xc68f7c36, 0x8f52ec8b,
- 0x3ddda005, 0xfc80ec91, 0xf62fe209, 0x6677658b, 0x6305fa3b, 0xb768ae89,
- 0x752fe023, 0xfaf1db44, 0xcc27e144, 0x0bad7f01, 0x75a739e9, 0x6557fb1e,
- 0x6145d5e9, 0xbf467c20, 0x2a370b1f, 0x13779dd1, 0xac6ab61f, 0x890ce737,
- 0xd4adafd9, 0xf48c7ec1, 0xb7c8e6ef, 0xe0217d8c, 0xc6ff276d, 0xffb18738,
- 0x4733ceb5, 0xe17ec69d, 0xacd73adf, 0xa9a5859c, 0xcf5fe171, 0x9c2c4cfe,
- 0x4f32a979, 0xfb15fe81, 0xeca9ad85, 0x7a4fe22f, 0xf0c13f3c, 0xcf51ca7f,
- 0x9cf522b9, 0x585f4943, 0x673d6d70, 0xff2d7bac, 0x78d758cf, 0xde54ea1f,
- 0xf7bf78df, 0x7fc4aeb9, 0x27e71bbe, 0xae9e79c5, 0x5cfe7fc4, 0x9a19fcf4,
- 0x7940e35e, 0x278a0e3e, 0xa93f7840, 0x959ae46b, 0x52d6f59c, 0x5fa1f65b,
- 0xf670b723, 0xb52d40f9, 0x27833b53, 0xb9fe78ad, 0xf94eaa39, 0xea2fc307,
- 0x0aa56717, 0x55f8e47f, 0x78e3aedd, 0x53b7407d, 0x88ff51dc, 0xaaf8a76e,
- 0x28730bde, 0x370ef48e, 0xc438a7ad, 0xf62d879b, 0xfa154def, 0xdf7c857e,
- 0xfea90f68, 0x857f0415, 0xf251e3ad, 0xe9bf2a49, 0x1c5f10b1, 0xbf2f7f27,
- 0x5c77bfbf, 0xbf683a0b, 0x1d048fe3, 0x7e7d08be, 0x22defebd, 0xe20ca662,
- 0xa917c553, 0x096c4a4f, 0x51fd48be, 0xf54574e6, 0x83ff93c7, 0x0f76cdef,
- 0xae6f7a8c, 0x0f35159e, 0xf21cd8fd, 0x902c6a87, 0x353e91a3, 0xcfc87a25,
- 0xefe3c58b, 0x0e3df9e5, 0x6051b927, 0x7f55d74e, 0x29e4fb1c, 0x7d8bf811,
- 0xc4553dbe, 0x9ec88373, 0x52273ae3, 0x556b6e75, 0xd0e6709f, 0x887e267f,
- 0xbaac63ed, 0x95c3d68c, 0x1e77c4dd, 0xba0ae9bb, 0xe3d2f0e0, 0x686ae7f3,
- 0x4de33dff, 0xfb1c38ff, 0x215f1ec7, 0xfb4d53fa, 0xfadfb1b2, 0x7fa27df8,
- 0xd9bc69a3, 0xb819ec83, 0xf9296e7f, 0x7fbee90b, 0x9b75fa27, 0xd4155b1d,
- 0xa8099503, 0x4cd5b0d7, 0xf7a6140a, 0x2ddbc7c5, 0xc0915f68, 0x175e6cc8,
- 0x156ec0d2, 0xc26574f1, 0x13d920d0, 0x13abd8ad, 0x0c132ade, 0x9264777a,
- 0x09da879d, 0xdd9d7151, 0xfbe1ef82, 0x0bff3665, 0xc9c26f82, 0x87a5ea3a,
- 0x200d960e, 0xea9138fe, 0xede43c64, 0x7d26ea9b, 0x21edf085, 0x01fffefb,
- 0xf078e6be, 0x3ec59ad5, 0x2579f59d, 0x86f38f64, 0x3e947921, 0x3a6a15fa,
- 0x21084f3f, 0xeebfb0ef, 0xb1fe5375, 0x90f165c6, 0xf2427eff, 0x35b6f5ef,
- 0xdaa18f32, 0x29a91f05, 0xb17bf5a6, 0xcff25b7d, 0x6a2fb919, 0x910ba1be,
- 0x33d9c03f, 0xe8815174, 0x6aa87f13, 0xe1f90f61, 0xe490ff3d, 0x83f9f8a1,
- 0x183f8144, 0x8fd1f3d2, 0x777bf9f1, 0xf1b679e7, 0x65a78173, 0x0e9aecc1,
- 0x06b38fec, 0xe3fca06f, 0x47ff34a1, 0xad3b8784, 0x87cc91c1, 0xb449f58e,
- 0x8e05e28f, 0x0ff88c53, 0x32dd3ce3, 0x705c7fbc, 0x46c1fded, 0x64e96576,
- 0x7f637781, 0xe88db1c4, 0xf124def1, 0xe10780dc, 0x303e26e8, 0x0785eae0,
- 0x8f393886, 0xd4ff2200, 0x2e8be325, 0xa7ec8f5a, 0xdc7910ea, 0xff38983f,
- 0x8ac24552, 0x4de77dfd, 0x791a0f1c, 0xfb1022e0, 0x49b53e4d, 0xf803e065,
- 0x96a2513b, 0xcb5c695e, 0x7684fdf1, 0xf6fe262d, 0x2a9d3db2, 0xd5a9bfdf,
- 0xf6a0e25f, 0x5379e8fd, 0x093f1c65, 0x59c52a82, 0xc6623b93, 0x467fe71b,
- 0x18bd4feb, 0x4d293cfd, 0x3041c3da, 0xb24f3228, 0x974dc641, 0x10a7664f,
- 0x2b186b1f, 0x8b0f48a8, 0xd4a4c2ae, 0xb0d33d3e, 0x4959e711, 0x2db8da9f,
- 0x8fbceb38, 0x88dc69f6, 0xf49a3f0c, 0x435b9baa, 0xc2ce0aee, 0x623630bd,
- 0x0617291f, 0x2fbf2f1e, 0x23ae38f0, 0xb0d397e7, 0x43356e6f, 0xc3c3ef50,
- 0x0c2f8914, 0xbbfe38df, 0xf6c1d17c, 0x62db626b, 0xead9e495, 0x711e8136,
- 0x113d04be, 0x6c7d08f4, 0xea8d49cf, 0xb59e92ab, 0xca7ed109, 0x924fb978,
- 0x7ad45067, 0xd062bf86, 0xacea50f3, 0xc663f256, 0xdfb1563b, 0x3b293292,
- 0x93a2fd6a, 0x042ef8d1, 0x63e2979f, 0x71c087cf, 0x5ab3c4c0, 0x29327f94,
- 0x63f983bc, 0xcfd187d2, 0xee8f9ca7, 0xfcc9a697, 0xaedd2c56, 0xfb184f85,
- 0x7fe969cb, 0xde5d3e3f, 0xcda67c68, 0x8667c689, 0x039f1a2f, 0x6be34596,
- 0x1f1a3fa0, 0x898d5783, 0x7d61bf1a, 0xd87f5461, 0xcd44a70f, 0x198342cf,
- 0x75be1fd9, 0x91fcd45e, 0xf545163b, 0x67753f47, 0xe0dcfcd4, 0xbcf1a88a,
- 0x2efe6bdd, 0x368417fa, 0x3427cd44, 0xfe87be9b, 0x4bfe3637, 0x53ff7ed4,
- 0xa18daff4, 0xe7d256ff, 0xa85e8813, 0xecfb0b37, 0xa425b919, 0x6f4d5d3f,
- 0x9b79437c, 0xf9ceb140, 0xf03cc0aa, 0x2fd8e0d4, 0x7a429f54, 0xdaa2306e,
- 0xd6a37a84, 0x1ec8ab04, 0x71326a3c, 0xf390d31e, 0x3f84d317, 0xc89a62f2,
- 0x7b78197b, 0xd922ed1a, 0x43ea5541, 0x248efa73, 0x935453f2, 0xfec9da09,
- 0x1fd61e69, 0xbe101ce7, 0x0755f719, 0x4ac5e701, 0x982d2792, 0xbea8fc88,
- 0xa9fc72a9, 0x8e83f20e, 0xe4e6a4f6, 0x9f8453ce, 0x4e9b0e2b, 0xfaa6ab7c,
- 0xf0df6403, 0xa1e7a19c, 0xdef39fbf, 0xf1495846, 0xe65fd196, 0xe699bf5e,
- 0xe67bbb2f, 0x7b7f8a48, 0xacaddf9f, 0x43a08d2c, 0xc51739e4, 0xa40eabf1,
- 0xd867fb09, 0xdc7ec313, 0x3a6bd569, 0x538c3ed0, 0xbb407d85, 0xf10d2071,
- 0x88f281f1, 0x0169f859, 0xed1f9d33, 0xb827df2a, 0x80df21d0, 0xdd9f4a6d,
- 0xe643bfd2, 0xda3b20fa, 0x00937d6f, 0xf74438a3, 0x1de33df0, 0x955dfe86,
- 0xecbbf8cb, 0xf97f9e88, 0xaf02e1fe, 0x90f620f7, 0xe22ce70e, 0x17fc063c,
- 0x42fe5ea5, 0xd24ee5ea, 0xebf911c7, 0x2676bb55, 0x2e7e7f91, 0xc6e3f847,
- 0x3a49dff3, 0xe54d2eff, 0x9dddaff3, 0x047cfeb0, 0xae422ade, 0xe3557ea8,
- 0xf991f5c0, 0x39c6b5cd, 0xe7468afc, 0xa8e52758, 0xf923b5a2, 0xfe7f604e,
- 0xb75c34c3, 0x7b95d772, 0xa6fbd00e, 0x67614c9e, 0xd2dfbc03, 0x82e380f7,
- 0x28817fa5, 0xcd33b6bf, 0xa67570cc, 0x09613889, 0xbbe44e36, 0xb803e825,
- 0xda637da8, 0x7c3fe22c, 0xbfb0561e, 0xa4cc15a0, 0xb3fa16bf, 0x33f484cc,
- 0x3f6779e0, 0x69cfed1e, 0x1b73ef3a, 0xfb7ef8f8, 0x922a7bdd, 0xd6340fd8,
- 0x8141d633, 0x3def3f20, 0x499cc057, 0x0ae99f79, 0x9fb817fb, 0xeefb9e8d,
- 0xec99bc1e, 0xbbdfb1b0, 0x0ef4bfe0, 0xf022c5f2, 0xfac6baf0, 0x1134d740,
- 0x4b03f97a, 0x44ed1d2f, 0xa66d0dbf, 0x3685e530, 0xbdf2b39c, 0xcf75774a,
- 0x9c230fcb, 0x66f9af1f, 0x7f7082bf, 0xbfe7bcb4, 0x3bf3e00e, 0x4741529e,
- 0xfdd9f1be, 0xbc447a5a, 0x2bfeee79, 0xafe86f2c, 0x2924ff3c, 0x1eac97a5,
- 0xd60f9392, 0x322a34bc, 0x9f4e485e, 0xf74e9099, 0xe2d2933b, 0xc6c46fde,
- 0x3f886ba5, 0xf6757e59, 0x5cbe0d4b, 0xc372f92d, 0xf9f9a30b, 0xf3dea486,
- 0x2af3fe88, 0x3436c1e7, 0xf1af395b, 0x3587e48e, 0x31337e2f, 0x8f57cf32,
- 0xa95ba97c, 0xf74b7275, 0x09fa3aa6, 0x1e5e4efb, 0xeaab71cb, 0x1e73a2cf,
- 0x3269fabe, 0xf9bdf7f5, 0x6e079f2d, 0xbbf83ebb, 0x78917911, 0x79ea4aae,
- 0xc54af497, 0xf94eab01, 0xb90392ac, 0x7ec2ee27, 0x1fea2b65, 0x5725cf3c,
- 0x29a7b1c7, 0x00a83b1e, 0xc32ab7e5, 0x2be4ac09, 0xe520941b, 0xee34d6c3,
- 0xfb1832dd, 0x1616ea6b, 0x2556bb11, 0x59567d0b, 0xb13704af, 0xe9873e1f,
- 0xa365285c, 0xbfee50e4, 0xd778e3e5, 0x85feb171, 0x3cf6b08d, 0xf55d9dc6,
- 0x38205e5f, 0x395a35d6, 0x292176cf, 0xfb8c196c, 0x84abda5e, 0xdc9f7a02,
- 0x1c44b976, 0x98f42ab6, 0xf55df685, 0xe411c2dc, 0x381d7636, 0xb93d216d,
- 0x59b1e1aa, 0x309179f2, 0x8b9641ff, 0x9595bbb5, 0xd5ac7991, 0xa4420ee8,
- 0x02f842fd, 0x40eafb13, 0x2cfa494e, 0x435e1a6b, 0xb6bd42e8, 0xf58569ff,
- 0x97e242da, 0xf9ef0e0f, 0xdf686fdd, 0x923dff83, 0x7d745ff1, 0x805f07f8,
- 0xb94a8bfd, 0x633c5c0f, 0xb2b2f8a1, 0xde217cc1, 0xba6352fd, 0xcfda1eef,
- 0xfd638f88, 0x10162dee, 0x10d93ff7, 0x82ec9e7c, 0x1cb2c7a3, 0x9a57f9e1,
- 0xce68f080, 0xec0acb1e, 0xc8ce48db, 0xc11db85e, 0xbef57178, 0x84f18d74,
- 0x78fac4b1, 0x3921a0f7, 0x5877a25e, 0xe9579f28, 0x5f10b4ee, 0x173f8657,
- 0x9f8dfff7, 0x89c6f2cc, 0x574e5fb7, 0x273f33a4, 0x6437de4a, 0x30b9618c,
- 0x90c3daf7, 0x60bee58d, 0xa9d90f45, 0x3b91070d, 0xbfb7a214, 0xec0ee087,
- 0x7ce9d04f, 0x9f3e0725, 0xcfb111d8, 0xf47ca51f, 0xf95e59e6, 0xf099ac64,
- 0xb193efb9, 0xf3df525a, 0xaac74cae, 0x97997978, 0xdedd85d3, 0x18bbec9c,
- 0x9e09072d, 0xd95bee30, 0x147be764, 0x2d2d8394, 0x70729145, 0xc45daac7,
- 0x07aa4de7, 0x1b2a0225, 0x79abfa17, 0xc887927e, 0x0cce36a3, 0x4eaa1f10,
- 0xfc27f31f, 0x289bf715, 0xff508fef, 0x3ff74dcd, 0x39ac724d, 0x1e646560,
- 0xf1d4d2a4, 0xe88516ab, 0xa26bc3ba, 0xf5810afd, 0x75f0ea96, 0x94553c70,
- 0x7bdc53a9, 0x202cc274, 0x59bcfd3c, 0x39afbce1, 0x8b35bfd5, 0xe55c7be8,
- 0x2fa396f9, 0xbbbee804, 0x11141c6b, 0x7f79c67c, 0x2a0c2e3e, 0x00b9b3ae,
- 0xe6edb43c, 0xc4dd4b83, 0x38cf3fbf, 0xdd867ec6, 0x2bd20213, 0x503fe835,
- 0x1f9ec7de, 0x093ad30a, 0x1522be39, 0xee9359f7, 0x58b4be64, 0x27ca1efd,
- 0x36fb203d, 0xe08ab7cd, 0x8a27a5b3, 0xf5c87bf8, 0x48baf9e5, 0x6f74cdfe,
- 0x4b7ce7e9, 0x69f05997, 0x71c00dd7, 0x4cfcd722, 0xe32f21a6, 0xb83b06cd,
- 0xd6546aad, 0x44d7da46, 0x79e8dbf0, 0x1ea5c1d7, 0x2d9cdf82, 0x91333df9,
- 0xff7622e5, 0xa99f888f, 0x62b4c0ce, 0x99e1166b, 0x9ff7a6f0, 0x7be4a1f7,
- 0xf9a01f03, 0x115e4873, 0xfcbc6f54, 0xf8bd3f92, 0x7375d12c, 0x95c72faa,
- 0xc2bcd7cf, 0xc6277629, 0xff9c3b95, 0x31b7c901, 0x89f095bf, 0xfcd16fef,
- 0x51efc236, 0xc5b35f89, 0xfe593ba7, 0xdfed3a7d, 0xf141be7b, 0x3c8df7cf,
- 0xff6c96df, 0xcfef9ef7, 0x54e67cf2, 0x2f5a37e4, 0x399e7819, 0xfe201839,
- 0xa2824dab, 0xa8f8f84d, 0xe49b966b, 0x6f91cb6e, 0xd7bc9286, 0x40dc7926,
- 0x9be6b179, 0x6fdc9196, 0xf3277419, 0xe42f17ff, 0xfb11aa16, 0x7f17a724,
- 0x2f3be745, 0xe2c5b1cf, 0x7c73a1cf, 0x9c69cf2c, 0xefba496b, 0xf911e92f,
- 0x7e921826, 0xd7b3fc5d, 0x7194d7b8, 0x61da479e, 0x8f38f38c, 0x5c890dd8,
- 0xfa57b67f, 0x98f81ae1, 0xd1e0ec7f, 0xc2f2bfd9, 0xa92baa09, 0x36c13169,
- 0xb5253e3a, 0x92fdee22, 0x0c119355, 0xb2186d7a, 0x8d3435d3, 0x39d89f3b,
- 0x3ee116af, 0xf8550108, 0x0cf9d169, 0x255e2af0, 0xdaf18f32, 0x63cbeb9a,
- 0x21afe33c, 0x63cd8d79, 0x969b0e4c, 0x23ae525b, 0xbcdaf19f, 0xd18cf9b8,
- 0x5171d119, 0xc0ce8641, 0x7f047285, 0x4189c286, 0xf1833791, 0x26eabf94,
- 0x9fe3855b, 0xde5999e3, 0x9b1cae95, 0x13e0ed0b, 0x3adb6c4f, 0x8470e50d,
- 0x6bf503c0, 0xf1f5c988, 0xe6f507ec, 0xc31b5e47, 0x3dea387e, 0x4e02f395,
- 0x1d0c4b09, 0x137fd08b, 0x2a27a541, 0xf63e12bf, 0xdbf1326d, 0x2dfd549e,
- 0x9b4f4fa2, 0x092875ca, 0x15c5875a, 0x900eee47, 0xe076807f, 0x3e84339f,
- 0x7b8a35b7, 0x65ee9b4b, 0x74e0993d, 0xe423538e, 0xd8432f24, 0x1f638aa5,
- 0x2ca0b50c, 0x4c9d325d, 0xd7f5c7ce, 0xa64fafed, 0x73dade34, 0xd2a44f6f,
- 0xff353b9f, 0xff3c0c82, 0x51aeca17, 0xb75bf236, 0x7e12c706, 0xae6ce142,
- 0x20d02ccf, 0x87f615a0, 0x3c29eaa7, 0x9504ba14, 0x5b71a54f, 0x257e34d0,
- 0x58555ff1, 0x30f6979c, 0x6dcc8aa3, 0xd5dfb854, 0xeb4a9358, 0x79b6fd55,
- 0x97afe910, 0xf39f8432, 0xf13cd5e2, 0xcd1a06be, 0x25c33fbf, 0xa2682a99,
- 0x324be37c, 0x5575d94f, 0xfec679e5, 0x55338d05, 0x7e41f227, 0xce11c778,
- 0x7559368b, 0x73c26fa2, 0x94d1f020, 0xd5687ec0, 0x7640d9e1, 0x1e05dbaf,
- 0x24f7c705, 0xfc447cf6, 0xd56cd3d0, 0xc1373ee9, 0x715203b9, 0x1eb23dfd,
- 0xb619172c, 0xdcf7d1de, 0xe9a12fd8, 0x24439497, 0xe57be0be, 0x4c076d04,
- 0x3be24477, 0xc959d849, 0xc3127b57, 0xe967ba26, 0x59efdf41, 0x4e0fab86,
- 0x380d7de0, 0xec0ed973, 0xf85cf4b1, 0xe5c33a71, 0x05c83e24, 0x8d342701,
- 0x26af49d6, 0x8e7cbd38, 0x09eea704, 0xaae1fd28, 0x208e8b1a, 0xa4a3cfca,
- 0xc9f4a6cc, 0x5f625577, 0xb0b286df, 0xfca41b27, 0x9d2b6eb7, 0x8547d916,
- 0xfdefa933, 0xf8e278ff, 0x9c21dab6, 0x48a80bff, 0x49b63b7f, 0x214e74a9,
- 0xde122857, 0x0781428c, 0xdbb40baa, 0x7cef78c4, 0x2a4773e4, 0xe79e7fdb,
- 0xf3ed3ab1, 0xf85e58b2, 0x0ff0d17e, 0x17c2521f, 0x76d2466e, 0xc94be63e,
- 0x9a7573c7, 0x875c3c8e, 0x3cb8fef3, 0xfd8c2a34, 0x79ffab16, 0x3f57cfe2,
- 0x80bdb15c, 0xb31eeff4, 0x4ff49ca7, 0xf671e047, 0xeb345fcb, 0x0ee422db,
- 0x7264f486, 0x3ecc61dd, 0x3d36e755, 0xf776fe4e, 0xfba74541, 0xcf736ef4,
- 0xb2bb8250, 0xd50b33e9, 0xfc1d5663, 0xb2ebfd84, 0xda5eff4c, 0x3563526f,
- 0x864dcfd7, 0x873f5c1d, 0x20eb917a, 0x4fa16e43, 0xf51d9f2e, 0x1d04756c,
- 0x06f293de, 0x6461fe3d, 0xbca49abf, 0x1c38a61e, 0x772dfddb, 0xf7f5a70c,
- 0xf180fccb, 0x191c355e, 0x04df784c, 0x3c6b71af, 0x5c6a0eef, 0xaef79cbf,
- 0xc46f5eed, 0xfe52d3fc, 0x56fdcb4f, 0x20dffa67, 0x7cb6d778, 0xc2d2a16a,
- 0xa1a1f3aa, 0x3486f714, 0x4719c53d, 0x6fcaf48f, 0x69553c8c, 0x5f9a163d,
- 0xaf581175, 0x536bbd20, 0xbd2f7e90, 0x396638db, 0x348fdf3e, 0x8b3b2149,
- 0xe3d92af1, 0x60df66fd, 0xcefd5f9a, 0x8f4963d7, 0xf020241d, 0xaf375f7f,
- 0x4378461d, 0x244e2ffe, 0xac0bdb39, 0xcd390cd7, 0xf7c53927, 0x8bff89f3,
- 0x7acb9fa8, 0x7da58f79, 0x7ee5cb1e, 0x225c9013, 0x203cb3ff, 0xdfc93bff,
- 0x3ca277cb, 0x59a3fbf0, 0x9bb4f7ce, 0xa337ecbc, 0xfdc91f5e, 0xdfd4c5e2,
- 0x64ea5ed3, 0x843aa739, 0xf0d79242, 0x04275e11, 0x45f2d740, 0xfd22f80a,
- 0x648cbcff, 0xf1242f71, 0xd8433939, 0x9e8e5083, 0xd873c1e2, 0x3e4a3555,
- 0xe8a5ec22, 0x9a5a7b4b, 0xbf6d97f9, 0x26524698, 0xda5384ed, 0xd678ff49,
- 0x6d28fffb, 0xa7d786d5, 0x73c3a82c, 0xf2a5386e, 0xf71961f8, 0x1c9f2585,
- 0xb21af991, 0xa89a7a1b, 0x13e7a61f, 0xe5f54fb0, 0x4bebbd13, 0x9a4d1cc8,
- 0xb528e3b3, 0x12a17c53, 0x2da6db72, 0x166a3f6b, 0xfc479e62, 0x6e6470d7,
- 0x75e3d51e, 0x0242b39f, 0x6df0d882, 0x222f47cf, 0x8c3e1e1e, 0xa7638ff8,
- 0x7fcc38f0, 0x060d7fe8, 0x6ef1ff77, 0x4091ea45, 0xc7e27cd2, 0xafb506ae,
- 0x2254808f, 0xfddf5363, 0x007b7da4, 0x677fe76d, 0x2267077a, 0xf00ccf3e,
- 0xfa7ddb73, 0xcb124cdb, 0x5c4567fd, 0xe6f160df, 0x6434ff11, 0x871ba863,
- 0x2299ad4f, 0x856453ef, 0x379cf7b8, 0x18390a67, 0x0aed8015, 0x33aaebc7,
- 0xd4bf7488, 0xe82d7aa0, 0xc0845d2f, 0x6fa4a992, 0x01f75e64, 0xfc5e3f90,
- 0x283cfa45, 0xdf900fbb, 0xc1eb7682, 0x11d6c45f, 0x316fd978, 0xeb0058f2,
- 0x2b5fc44d, 0x0ff8149b, 0x67aac5c4, 0x93afe7a2, 0x1babf275, 0x8c1b1d77,
- 0x5cf35d74, 0x2df938cc, 0xe211ff7c, 0x5d5d7878, 0xcdc33d74, 0x197fd299,
- 0x7fc9c30e, 0x3d62be41, 0xd5a0d661, 0x60ac7c8a, 0xf6224314, 0x0be04992,
- 0x67cb2bf5, 0x8a6f61be, 0xb9ea5e85, 0x94a75c04, 0x94743bbb, 0xd4a681ea,
- 0x8f687965, 0x9f189a29, 0xee2598d2, 0x4aa0b4a7, 0xbc930c75, 0x77ec59fe,
- 0xa967bc07, 0xd49564de, 0x5fc4e097, 0xd3c8fbca, 0xddfe92af, 0x9d6c60ea,
- 0x9553c0a8, 0x8219379c, 0xcaefb435, 0x69dea2dd, 0xf9e8eeed, 0xeb4f1255,
- 0x8c7d3a9e, 0xa11585d2, 0xa7897198, 0x3a98c6aa, 0xdc38b116, 0xadef299f,
- 0xf5fb7d64, 0xd1fc5bd6, 0xb78dfc2c, 0xf8c63ae5, 0xef914ce6, 0x1063c4ad,
- 0xd505d77d, 0x2ad1f120, 0xfc2c9025, 0xc72c705e, 0xb067ddf3, 0xbdcfac81,
- 0x3ee9e25f, 0x7e7c3fc9, 0x19e2bf7c, 0xfdc57df1, 0x7f868b3f, 0x832cf80d,
- 0x0d83f9f1, 0xde50b03f, 0x56df9631, 0xffd999d5, 0x13f1235d, 0x7a6b5fcb,
- 0x858767f9, 0x7f2c5bec, 0x6b95fa55, 0xf6fc2fc0, 0x0df85bff, 0xcb91af3a,
- 0x398735ac, 0x09f6b53f, 0xabf943c5, 0xf7ab9d6b, 0x7f7cf23c, 0x359eb9ef,
- 0xc6063de8, 0xa4e7bd30, 0x63bd175d, 0x96bdedfd, 0xe726bcde, 0x66b72f05,
- 0xe0dd3e73, 0x6675d8ab, 0xf67dbf49, 0xbd7fc253, 0x276258d4, 0xa4fba3ff,
- 0x9ce8a3c9, 0xc02e4caf, 0x566f8ff3, 0xee91fc81, 0x033be1a6, 0xa9e17f08,
- 0x5f94c5a2, 0xed0a7f1f, 0xb707dd13, 0x0257fd16, 0xd27b07df, 0xb667ee48,
- 0xbdfb488d, 0xfb61d783, 0x70b27dde, 0xe9e93967, 0xb445a593, 0x54e382ae,
- 0xed285e9f, 0x42c9f554, 0xbd84477b, 0xc8a64dfa, 0xff716fcf, 0x1b8a51fe,
- 0x7b35ef66, 0xdb323f28, 0x8094dfec, 0xa0be15f0, 0xb771aa78, 0x9e47ed63,
- 0xbe5175a4, 0xf38acd28, 0x8d08e9fe, 0x1851ed57, 0xb2a6eefe, 0x3f643dbc,
- 0xec87aa83, 0x7dd37762, 0x1f920ff9, 0xfe40fcd4, 0x1dfb117d, 0x66fa154b,
- 0xb6660df6, 0xec839dd7, 0xbca72ebf, 0xeb1777a8, 0xfb43ce8d, 0xc37dfc2c,
- 0x78dc051e, 0xa3ee63ce, 0x3a1e132f, 0x50b69c0f, 0x70d25010, 0x4711d2da,
- 0x25ed1b7f, 0x9cc2f30c, 0xe161ddaf, 0x7ffdcdfa, 0x2b79d0b0, 0xf384fb9f,
- 0x7e286b6f, 0x19ef3f20, 0x3a77bf95, 0x85aafcda, 0x4eb2b4f8, 0x91590181,
- 0x271e66e3, 0xcffd4afd, 0x369e84ea, 0xe4857ff8, 0x0dff8377, 0xf5215879,
- 0xe35b7dda, 0xffa1bbf3, 0x96ef041e, 0x03deb841, 0x0eb9cb75, 0xd11d81e9,
- 0xfc5257f3, 0x17cd237a, 0xa9f2befc, 0xbdd5f1e8, 0xfd601e7c, 0xbf47ab1f,
- 0x2e7ff433, 0x5f9f12e4, 0xa618af0e, 0x7d7d3ca1, 0x8830cd7a, 0x293caf93,
- 0x6ec306fd, 0xd89b0e5f, 0xebcec5ee, 0x2162bc6a, 0xfad55b7b, 0x6773f627,
- 0xf4c97d35, 0xe16a6f28, 0xc05bd97a, 0x79f08ebf, 0x49dd934b, 0x877976fe,
- 0x9af303d0, 0x42a0c1ac, 0xa25aa1e3, 0xf161f773, 0x90e049bd, 0x4816fec2,
- 0xe252b8bd, 0xe3c4a575, 0x06e38c4a, 0x8c8c7d53, 0xbc652be3, 0xd7673abe,
- 0xa9292a31, 0xdaebe394, 0x1e13268e, 0x5bd081e7, 0x6f4242f3, 0xec31f419,
- 0x40beac50, 0xd10f770b, 0x95936d77, 0x4be7d6eb, 0x0ebf35bd, 0x5fd296f5,
- 0xb40f747f, 0x7ef1fc8b, 0xddac7701, 0x9e886cad, 0xfc201aef, 0x7fd2cbd8,
- 0x4d101c2e, 0xb01ef297, 0x9e7f7e53, 0xfc827aae, 0xfb46bb56, 0x7e458eb7,
- 0xf55bf5c3, 0xeaf129e1, 0x4df68cb5, 0xfd181719, 0xc3679405, 0x0ee721f9,
- 0xffdc6447, 0x7f84039f, 0x1ab266b3, 0xc446ba20, 0xb30a0b49, 0x7349c6e2,
- 0x8637f409, 0x71b3f7dc, 0x77927191, 0xb7e228d7, 0x2cef757f, 0xaaa6baa7,
- 0xba2fa13a, 0x29bae126, 0xfb03f7e4, 0xd67555d1, 0x5533c520, 0x7dfc2fc8,
- 0xc909f11a, 0x46529363, 0xc671827c, 0x42feb4ed, 0xf3c4eaba, 0xfb446c2f,
- 0x2c2fcb8e, 0xabf992fd, 0x3738846d, 0xbc406de2, 0x3788c3b8, 0xbf0aaf2a,
- 0xa95e78d6, 0x51dc7075, 0xb5ea24d9, 0x337c8e1b, 0xede10b34, 0xd0f3fe6e,
- 0x3e4f54e5, 0x86e7d840, 0x54a7d0e2, 0x1ef5f457, 0xb5ff5c5b, 0xb52bff57,
- 0xe6950f2c, 0x6bf64c8e, 0x791fa20e, 0xb7d1ea13, 0xa538e0bf, 0xbdc248e1,
- 0x5aebcf94, 0xfce61fe1, 0xc3553a1e, 0x3783f626, 0xe4b72d41, 0x8dfa451f,
- 0x4ea29d2b, 0x3f6941e9, 0xf208ffa9, 0x773883f5, 0xf97f6146, 0x8549f437,
- 0x10d5ebe4, 0xe95532d8, 0xa42a07af, 0xdfcdacdc, 0xf6ae85b5, 0x0aa7fd63,
- 0x31184f29, 0xf58cbdb0, 0x8633fe9f, 0x4edfab5f, 0xbbb8ff64, 0xae52754d,
- 0xabfbf119, 0x6227e441, 0x271d905c, 0xe485fb5f, 0x7f794ecf, 0x65493d5c,
- 0x8b2699fc, 0x10b7f0d6, 0xdd37cc8f, 0xb2411da7, 0x5f87796f, 0x583e26cd,
- 0xdefa3bbb, 0xe7e8e889, 0xc8a0b1ba, 0x7cec8547, 0xbf8c6517, 0x31d5f874,
- 0x6fd56fc4, 0xd04a3b7f, 0x96519be7, 0x67c36bf4, 0xe2228ab4, 0xe2229366,
- 0x475afde6, 0x556bc532, 0x645f5507, 0xef41bf3d, 0x813ca597, 0xf503f226,
- 0xabe67403, 0x1fc126ea, 0xe2d166a6, 0x7e444bfe, 0xf7fbccc8, 0xbe462f1b,
- 0x067b1ef9, 0x40f21704, 0xf987b995, 0x89b4eaaf, 0x7d3aa9e1, 0xc4447339,
- 0x775a017b, 0xeabfe900, 0xc4fac075, 0xe76fa40e, 0xd891f7d3, 0x027eff9f,
- 0xb2c761fb, 0xfb8b97b7, 0x7f48152f, 0x9af6fc3d, 0x60f691d1, 0x2f7100e2,
- 0x3707840e, 0x10bf3f79, 0x6c3c4bfb, 0xbf324582, 0xaf79f820, 0x2e309b8c,
- 0x9c40737b, 0xfd7aecb8, 0x2b66eae9, 0xeab9fe50, 0x19d72b03, 0x92bcdd7d,
- 0xeab87ee3, 0x06fa4d1f, 0xa91bfefc, 0xcaf0f87d, 0xebfcf4d1, 0xe46fabc3,
- 0x29b2a97c, 0x2011cf2a, 0x5fe4dcf8, 0x5deef57d, 0x69b67fe4, 0xb6149fec,
- 0xee977d9d, 0x9835f769, 0x8ad1dbf9, 0x067613fd, 0x2aafc892, 0x11df4f9c,
- 0x98d56bed, 0x32dfd0ff, 0xfb3b2bfc, 0xd88aa757, 0x7c75c2bf, 0x4e8b6e41,
- 0xa7bad394, 0x9a688b8a, 0xd7a4e382, 0xe57f93c6, 0x0cb7f3e8, 0xf8933e78,
- 0xe0496eec, 0xd9028bbc, 0x4460cf82, 0x1aebdc14, 0x64ff675e, 0xf51aa35d,
- 0xdef188fd, 0x7b88065f, 0x3e0cef87, 0xe65e290b, 0x5da2bda3, 0x932fb8d7,
- 0x1cd6b1ce, 0xaea93e62, 0x3df18b33, 0x07ba05a2, 0x411fc09a, 0x273f0807,
- 0x65d211e8, 0x8438259e, 0xbdbdfafc, 0x2eb28af7, 0xf5ea2824, 0xf3875a6a,
- 0x5b974c77, 0xb3c7a5f7, 0x9ee92743, 0xe3be1d07, 0x8a1e2259, 0x5badff1d,
- 0x9f8e41e4, 0xf8f1fa13, 0x78e8ff4c, 0xc500327a, 0x48a05f22, 0xef8835fa,
- 0x35e763ed, 0xfe787ad3, 0xc70243dd, 0xf73b8f89, 0x63fdf026, 0x75e44ba7,
- 0x34dbea4b, 0x6d661efa, 0xec813283, 0xf79cdad2, 0xec197bf8, 0x5c9e9117,
- 0xf7c83e1b, 0x7b7515af, 0xc0e37967, 0xec2dddb1, 0x9df93cc3, 0x7cf8ec72,
- 0x3c067e39, 0xdb9e3219, 0x673ef74e, 0xf14ecdca, 0xeef89bdd, 0xd7a956f5,
- 0x6662df17, 0xe80cea3f, 0x227f7166, 0x481639ee, 0xd4ab7dbd, 0x63dfb1f7,
- 0x76fdfa1b, 0x67c2ceb9, 0x73dd3360, 0x7d9f7ec4, 0x170ff4bb, 0xefd79781,
- 0xf4bd5df7, 0xfeff6313, 0xea5b8942, 0x8a3051f5, 0xed087af4, 0xe45bd70d,
- 0x9eddb026, 0xae32305f, 0xa9df41df, 0x753bf2eb, 0x57fa0d6a, 0xf6c7bee7,
- 0xb9cb78f0, 0x86fbf997, 0x1d900973, 0xcfad9ee7, 0xe47a1a1e, 0x79774136,
- 0x14e151ef, 0xbff41a30, 0x645a1184, 0xffa0cd7e, 0xff0e9283, 0x394575c7,
- 0x63e645a0, 0x07fea90e, 0x475419dd, 0x38fec9dd, 0x21ed809e, 0x3ca86b9e,
- 0x846b50d7, 0x7034bb9d, 0xee3e5c79, 0x406a5f3b, 0x6e7493d8, 0xecad725b,
- 0x14845637, 0x22b0eefe, 0x9b7fa20c, 0x51caf9c2, 0xbf5c2d0d, 0xf154a4b1,
- 0x3c5a8578, 0x7c19f04b, 0xfc26c0b4, 0x7a5f8303, 0x88f925f1, 0xb85fc9c6,
- 0xb10bfa55, 0xda1a34fc, 0x4bfad167, 0xea878abd, 0x47c9af36, 0x4ebdc6cb,
- 0xf8b5eee1, 0x4cd2f908, 0x9f96317a, 0x1ffb735e, 0xb775fc25, 0x80525e5f,
- 0xfdcf1feb, 0x4ff1286c, 0xe8e435e5, 0xddbf4945, 0xae71c08e, 0x7597a963,
- 0x8db9f504, 0x5697841d, 0xd3b2bf60, 0x8365bed5, 0x8eb9b7f0, 0xc09c22a0,
- 0x4d15a5f5, 0xad6efe76, 0x713aa1a2, 0x26e3e90c, 0x7ec763d5, 0x52e9c379,
- 0x179423ca, 0x2a973a89, 0xabbba8bb, 0xbbba8bb2, 0xe7fee9b9, 0xeff813dc,
- 0x11d74403, 0xb57e3a58, 0x3ef87be1, 0x9335df56, 0x7fe1370f, 0x4b350f4e,
- 0xbb686cfc, 0xc4863992, 0x887fdd34, 0xfd7eeee0, 0x8a7d0b45, 0xd5e63551,
- 0xd6825459, 0xde79d6ec, 0xb52d752d, 0xe0365694, 0x429dbbb7, 0x43839aef,
- 0xbfcd6fd8, 0xea9b7abe, 0x258c6f83, 0xd2d5d5fb, 0xc112d636, 0x501b9def,
- 0x63a1c76f, 0x1ca49835, 0xca2adc6b, 0x0947e922, 0x3e6aaeb9, 0x8bf9499a,
- 0x7ce7924e, 0x1e49df6a, 0xdec56d81, 0xc923c933, 0x5a2fd99f, 0x4d4bbd63,
- 0xad03cf2a, 0x49edd463, 0x666df091, 0xc4852ef8, 0xa31d003a, 0x8e441716,
- 0xd6bffcd7, 0x3e851707, 0x07d288e8, 0x16429e06, 0x0388efe0, 0xa75cad87,
- 0xae3ff740, 0x036a3a08, 0xc26efd05, 0x76e48a60, 0x0f7bdd32, 0x834f9727,
- 0x41afa9bb, 0xfba54b58, 0xea2ab0e9, 0xbeb086fb, 0xbff7289f, 0x50b70b49,
- 0x7964f03d, 0xda053a5f, 0xe80cde79, 0x4e0bd6e1, 0x18ba0efe, 0xb24edc3c,
- 0x5a53e785, 0xe2143f2b, 0x99c27bef, 0x4d82eb9a, 0x871d6f7e, 0xd3787dde,
- 0x0f8182e0, 0x44d5ee95, 0x79ec533d, 0xfc28186e, 0x42bc9bbc, 0x414b910f,
- 0x2093c0f5, 0xd3f9f7c4, 0xebde43a1, 0x54c73fc7, 0x1ee90b8c, 0x31ba3a6f,
- 0x208f8c89, 0xe7469fcf, 0xa79de351, 0x19933e63, 0x9f049d4a, 0x7d34ce12,
- 0x73febf67, 0x28355374, 0xebefbde5, 0x5171fae9, 0xa7a83ddf, 0xa9f78de9,
- 0x7af1597e, 0x43d9beb9, 0xfc538ddf, 0x7b3ad613, 0xc03659f5, 0x722b8198,
- 0xfbe84e06, 0xc0fc046e, 0xdfb12475, 0x277c448d, 0xfe231702, 0xe751922e,
- 0x48b83bbb, 0x65913aa7, 0x7bfe36e9, 0xa1b6853b, 0x79af29e3, 0x339fcd28,
- 0x7dea8330, 0x62f246eb, 0xfb02705a, 0xecbf92b9, 0x78449de0, 0xf7c6bc50,
- 0xd37cc02b, 0x320bf7fb, 0xb227bf81, 0x3e77c55b, 0x6d1f91db, 0x3a052ca9,
- 0x23c35fd5, 0xd3f93a25, 0x0f365c5b, 0x256c477d, 0x707dedb8, 0x1d44d8d7,
- 0xd44d8d48, 0x72f51879, 0xb1ad78b1, 0x8f4e7919, 0x98f1fd8d, 0x627e90ef,
- 0x7842dff3, 0x98a9287a, 0xde530eff, 0x5cdcd32b, 0x7fbf250f, 0xf03049aa,
- 0xe7e36c50, 0xec94f57d, 0x3d52d667, 0x9359c237, 0x78ff5c01, 0x0a546934,
- 0xb4d565d5, 0x9aee7a89, 0x77eb008c, 0x7d615fb3, 0xd25ad35f, 0xb2e2f64a,
- 0xdd75c2c3, 0x07512e35, 0xd080c81f, 0x3d347af3, 0xa0f419a6, 0x8f594bfb,
- 0x5c65d064, 0x7bd0943a, 0x91dec2e3, 0xdb429384, 0xfdd037cb, 0x7470b8c2,
- 0x69d2197d, 0xf7a9d135, 0xc9cd1e3b, 0x7d061ef5, 0xd9987190, 0x06ee929d,
- 0xdfc69cbd, 0x516af023, 0xa0c08f7f, 0x4144f6e3, 0xe055332f, 0x7577e70c,
- 0x4e96375a, 0x14e11bff, 0x4bb0bac1, 0x00004bb0
-};
-
-static const u32 xsem_int_table_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x93cbff00, 0x51f86065, 0xd2f9c08f, 0xbcde0c0c,
- 0xc4b462a8, 0x0c0c5c0c, 0x0e5c4041, 0x7b401ac4, 0xdbe9016f, 0xcdce1c40,
- 0xc40110c0, 0x1ff881fb, 0x6207ff10, 0x04d6200d, 0x79405fe2, 0x5b1ba845,
- 0xda181898, 0x8803b880, 0x875880bb, 0x97418191, 0x93fb7891, 0xde181984,
- 0x7af82389, 0xcd0c0c12, 0xfff3f452, 0x5631c360, 0x29efb5f4, 0x174e3ed0,
- 0x19c73f04, 0x505c2498, 0xe0bb70d5, 0x4d078337, 0xcf8d179e, 0x9e7f4787,
- 0x5cbf2a21, 0x4d3f950b, 0x23e18187, 0x2d0a9a92, 0xc7416efc, 0x0c0c468a,
- 0xabc4464a, 0xca8c60df, 0xd081300f, 0xb1adf900, 0x0003a809, 0x00000000
-};
-
-static const u32 xsem_pram_data_e1h[] = {
- 0x00088b1f, 0x00000000, 0x7de5ff00, 0xd5547c09, 0xf37df0f5, 0x66499996,
- 0x0d909326, 0x8a027108, 0x081380a8, 0xc3b44069, 0x8e22a222, 0x260dc55b,
- 0x1037d902, 0xfdaff0fd, 0x2d361032, 0x4682d0d6, 0xa0c0748b, 0x0d0482c1,
- 0x00e02418, 0xd52ff82e, 0x5b7bbfd8, 0x16c34a0c, 0x7e1b8092, 0xce7fe5b5,
- 0xef25f7b9, 0x6d80264d, 0xfdfb5fbf, 0xe6f169bf, 0x5ddf7bbc, 0x3dcf76ce,
- 0x14fbdcf7, 0xf89628db, 0xe0cec663, 0x2cabd20f, 0xdd51b18c, 0xa0db6ce9,
- 0x74fa87a1, 0x6559ffe7, 0x4287ead3, 0x6ed0ab1e, 0x9cfdd61e, 0x7e5485b1,
- 0x386b8c40, 0xf4d31cbb, 0x8f0e1b10, 0x9616c96d, 0x6e7dd8cc, 0x0901bf46,
- 0x912974be, 0x5615ceb1, 0x780cbaf7, 0x085c7aae, 0x20c8f7df, 0xf7c25077,
- 0x1652c93c, 0xbaa23fe4, 0xbecc01d7, 0x6cb3233f, 0xe0da66c6, 0xc3fc0f6f,
- 0x7cbea07a, 0x63106cac, 0x059969ea, 0x77ea7fa0, 0x3403a512, 0x00efc336,
- 0x6c2df978, 0xfeeed0dc, 0xecfd13b9, 0xe8b78073, 0x5b7e89f9, 0x097f90c0,
- 0xecffa893, 0x5faa4afb, 0xf2f16f6f, 0x073e6c5b, 0x8d941636, 0x7f963bcf,
- 0x8be7c2e9, 0x7aa16e9b, 0xd82c5318, 0xc8b772cf, 0x635cfc4f, 0xbbfaee96,
- 0x76a214f1, 0x04d3d874, 0x3188feed, 0xb6bfb5e9, 0xd543c032, 0x0563d556,
- 0xaad84cbc, 0x700c7f86, 0x84295ae9, 0x9d9765b0, 0xfb4bc031, 0x9d870e6a,
- 0x9fcb0f9a, 0xaa1805a8, 0xff36b728, 0xdbc40afc, 0xa3ad9956, 0xf784fc66,
- 0x3bc71b56, 0x9e70e46b, 0x6ba5839d, 0xf7c74f77, 0xccad1a0b, 0x6e95f50e,
- 0x057a9fcf, 0x54fbf9c0, 0xd74a4586, 0x01fad02f, 0xea92185c, 0xcf18ee11,
- 0x36e0fda8, 0xca1eb439, 0x939ab877, 0x1ff1836f, 0xcf31b4ab, 0x676fd0c5,
- 0x80adf273, 0x96d0a287, 0xd15ef849, 0x2c8bc946, 0xfaeb6134, 0x7bc2fb37,
- 0xaf241ba5, 0x5c52f015, 0x433ccb17, 0xc0ce1f78, 0x3906d6bf, 0x9fc863fc,
- 0x1964e30b, 0x49ead748, 0x57f6c64c, 0x37671e68, 0x0e558e9e, 0x376b1e61,
- 0xda01ba5c, 0x5ecaf781, 0xc438bc94, 0x200b0b32, 0xb76fb65f, 0x81d67b4f,
- 0x0da05be3, 0x96b8e276, 0x3f2e586a, 0xeecdbb94, 0xd5adfec1, 0xd17e4126,
- 0x9e5ab5ea, 0x75c5fe81, 0xcd8f3197, 0x419aafd0, 0x88fe4629, 0x9b018f4c,
- 0xc453fb18, 0xf91eaf98, 0x37690944, 0x9fa2e419, 0x2ef44f14, 0xf54d93ae,
- 0x4b192603, 0x007eff82, 0x82be027f, 0x57849d3b, 0x05736e9d, 0x3b74e91f,
- 0x2987e425, 0xfac6d99d, 0x48e7f4f5, 0x754fe807, 0x5fd29ba5, 0xba52a654,
- 0xf443d2b2, 0x07f10279, 0x6fd172e9, 0x4e3658d7, 0x3e5d7681, 0x4b3146e6,
- 0xa71be298, 0xe7e09c02, 0x01ddf270, 0xf19673c9, 0x6a13e9eb, 0x72651720,
- 0x53e49b15, 0x05ac02fa, 0xb42f30e6, 0x9be8dcaf, 0xd7b19a38, 0x1c71e059,
- 0x502922ff, 0xac657480, 0x740fd53e, 0x1e812259, 0xc52d7c01, 0x961e0241,
- 0x067e05f4, 0x4f713d3a, 0x24b2b3f6, 0x70889ac6, 0x668f73de, 0x54353d50,
- 0x0cf50a8f, 0xc93d773a, 0xf54c73d3, 0xd02f4f24, 0xf54b59eb, 0x9eafcfd8,
- 0x318fa627, 0x917a67f7, 0x580bcf5e, 0xfcf3916e, 0x633c95c6, 0x333fb9ac,
- 0x949ea84a, 0x002cbdbb, 0x7f9d65e5, 0x864fb358, 0xf8c6c77c, 0x23328f11,
- 0x86df8d1f, 0xaa4139f5, 0x97147c8c, 0xa7926313, 0x09825f78, 0x9fb933ee,
- 0x7f927ca9, 0x653f29a0, 0x7c11a5da, 0x5eb770e9, 0x54e86026, 0xfea35e38,
- 0xd234fd6a, 0xd9fae33b, 0x9fa07e08, 0x03cef483, 0xbb170263, 0x57d8dfa1,
- 0x407ff406, 0x8eee5c0b, 0x2e3037c2, 0xea62a589, 0x991a60b1, 0x78e554bf,
- 0xfbffdf1b, 0xfde107c1, 0xe0e74b72, 0x4bff8078, 0x8e21f71a, 0x4ca88ffb,
- 0x32316e81, 0x3172c0ab, 0x6ffa4656, 0xb3f64669, 0x975e0341, 0x917e000d,
- 0xa65debba, 0x1f915206, 0x4115825b, 0x3025cfe4, 0x8c7eb041, 0xe115641d,
- 0xfef085e0, 0xc454bc80, 0xfd0355bf, 0x835f6c61, 0xfb5287f6, 0x5b7ed8ad,
- 0x075bed2f, 0xb7da98e6, 0xda9817a5, 0x3ed069b7, 0x706747c8, 0xf01f68be,
- 0x93b18637, 0x6fb53e6c, 0xf6a02f4d, 0xc0ac6a97, 0x574c7ed4, 0xbb60dffb,
- 0x49fb63df, 0x703fc651, 0xe9fc798c, 0x6bf1e645, 0x416cfc7c, 0x431fb450,
- 0x20a497e3, 0x117a7f1f, 0xd795bf1f, 0xabbed5db, 0x049aff0b, 0x5ea43aed,
- 0xac683fc6, 0x9417fc79, 0xe56fc798, 0x2c17bbed, 0xa83bed13, 0x196978fd,
- 0x2505ff1f, 0x0d66bed4, 0xb48f9178, 0x211531fe, 0x40d34f9c, 0x07485280,
- 0x921d28fa, 0x93e818c0, 0x8481b2df, 0x38620787, 0x03137ddf, 0xd6e8e6fc,
- 0x12042ca7, 0x9970f308, 0x8de2e9e0, 0x3f3e34e3, 0x9f5e6907, 0xab3aba2d,
- 0x8cf9a651, 0x2e86b4ad, 0x37b6fe82, 0x678441ca, 0x2432bcad, 0x760a7cd3,
- 0xb0a7be02, 0xf3ff3e30, 0x8ceb61aa, 0x674c8ae3, 0x2dadab57, 0xd2eab906,
- 0x90d9e3ef, 0x055fe80a, 0x6ea8c132, 0x34f415b8, 0x39fc3d03, 0x0f4c63e8,
- 0x392edcab, 0x5d9c7a04, 0x059b946c, 0xb2092edc, 0xff4087f7, 0xdffa227f,
- 0xb77c70aa, 0x884293ce, 0xcc566fff, 0xcd9f50d1, 0xa4058eae, 0x5ca3f777,
- 0xbb73a9d0, 0x14f64435, 0x9f88074c, 0x191449db, 0x1baed3fb, 0x305c94de,
- 0x31f4d63f, 0x0b3777bd, 0xf2854e2d, 0x0ee79733, 0xeff8c370, 0x211d669a,
- 0x7cc4fce3, 0xc7242dfd, 0x8725bfac, 0x2b0d69b1, 0xdc00fed4, 0xbcfd4d3e,
- 0x1dfef0c5, 0x577c3301, 0x576e1981, 0xed05aa43, 0xad894299, 0xa9ef7a85,
- 0xedebe730, 0x3812964c, 0x3f7b455d, 0x85f41c01, 0x3a60f747, 0x89bb1f02,
- 0xfcddd3ae, 0xe53fbd5d, 0x4c2ca90f, 0x124b71f3, 0x5127fa23, 0x8f9b80b9,
- 0xd3bfb23b, 0x0fcf9b55, 0xa0fe99fd, 0xec8cf84c, 0x58aecb7f, 0xd9ec059f,
- 0x552f9a96, 0xf1c8c164, 0xc67ff644, 0xb8f1c8fc, 0x721f9c35, 0x39cf9183,
- 0x53f2449f, 0x5fb8e379, 0x53f0321e, 0xbfb5fd69, 0xaf78643c, 0x1326eeb8,
- 0xc3ba185c, 0x26bf3e54, 0xbb3f94d7, 0x3f94d0ba, 0x131cd973, 0xd07c1b9c,
- 0xfcc67e54, 0x7bfca605, 0xe5311e2a, 0xc2b055df, 0x7811df04, 0xf6fe54ca,
- 0xf94d6b69, 0xdc975d96, 0xf5547288, 0xde70cc81, 0xfad1daf8, 0xbf37b473,
- 0xa45e2876, 0x57b011c7, 0x818e0e50, 0x7b6982bd, 0xabb248e3, 0x31e60f41,
- 0x4b56a130, 0xc6cb83fb, 0xa4665ea2, 0xefd2433f, 0xc634c183, 0x843c979e,
- 0x6346b93f, 0x89616061, 0x71f17425, 0x6fc86ca7, 0x0d7e4739, 0x9ec8fa08,
- 0xf44b72f9, 0x72ebe5e7, 0xd3bd402f, 0x5f803e9b, 0x3ae79c7f, 0x99103d84,
- 0xbf31225f, 0x7ebeb9f1, 0x7ae25cba, 0x53ac44be, 0x3bea5e4a, 0x0e10b99e,
- 0x5b38ae0f, 0x5480f57b, 0xfd6893d4, 0x803f2127, 0x51e81814, 0x24c8375c,
- 0x65bb6ddf, 0xea1957ea, 0x99abd004, 0x4257bfcc, 0x9bde133d, 0xec30cb7e,
- 0xd475ef87, 0x8931acfb, 0xcab6f5e6, 0xa43cbfc9, 0x94fc7d22, 0x469ca91e,
- 0x80656b69, 0x059543d2, 0x595e7e94, 0xe54b6941, 0x540f4a7c, 0x63fd2906,
- 0x3f4a32e5, 0xf4a6acad, 0x4a1acae3, 0x510cac3f, 0xa3e95eda, 0x2e879754,
- 0xf617ebfd, 0xc0b758b0, 0x8b0f6e03, 0xb2822cb1, 0xdee724cd, 0x53f39454,
- 0xa3066f8e, 0x63ea7fbd, 0xde8ca260, 0x6fc915f1, 0x47d1d3bd, 0x085e4af6,
- 0xcf4fa798, 0xa70c7b7c, 0x26c2dd93, 0x8f47d033, 0xf79cf45c, 0x2b04a1de,
- 0xa9c032c8, 0x519c9bde, 0x0fb985ea, 0x3a2e75e9, 0x70e75f31, 0x3eb7675c,
- 0xac6c97fd, 0x206972f7, 0xcaf7879f, 0xf0b30f34, 0xd7a45eb3, 0xf49bc50f,
- 0x5bd29fda, 0x2e89dca0, 0x33a735fc, 0x6e48e748, 0x8354ffaa, 0xc7882995,
- 0x2e10d8a6, 0x7bed4f8d, 0x38f285d6, 0x3eae5537, 0x7c77b234, 0x5467d695,
- 0x29e30c3b, 0xa7c3346f, 0xdcc9a5aa, 0xbb89e07f, 0x95f21875, 0x45d0fabb,
- 0x4a54ff48, 0xa6e67af5, 0xb1ced46a, 0x7c7141ba, 0x79f10efe, 0xf13c6370,
- 0xa93bac2b, 0x3fbb3ffc, 0xf7a3d5bd, 0xf606b187, 0x01f50d85, 0xf73a0de4,
- 0xdd07a8fa, 0x3f34af95, 0xfd49abd2, 0x1885ed06, 0x206677f8, 0xac10abd6,
- 0x2f5e5bd7, 0xe397ad07, 0xf6a68df3, 0xbe8f3de0, 0x7af7c7a6, 0xb5855be7,
- 0x7d04e3ea, 0xe7f0a575, 0xabd9d714, 0xbc4af3cd, 0xec6f2e09, 0x679a6d5b,
- 0x7f900ff0, 0xc8292156, 0x9b82253f, 0x32c7143a, 0x6a97fa09, 0xe5bd50f1,
- 0x6a572f12, 0x1e02d16b, 0xb466c762, 0xd1cdee33, 0xfb73cff9, 0x1fdf401f,
- 0x1ecaadfd, 0xd7e17cc5, 0xb06cf551, 0xe7e82d6f, 0x0dbdd011, 0xef5053c5,
- 0x3d76dd1d, 0x98b327d9, 0xa48b85df, 0x8d9d5602, 0x6609ce76, 0x7ffc8c99,
- 0x35defd82, 0xc8deb0d2, 0x9fd468b7, 0xf3cccb99, 0x2667d82c, 0x0cc6bf38,
- 0x939bb1e7, 0x56f3df91, 0xa0b730aa, 0x6ff39a5c, 0xbe49b8b7, 0x12c559f2,
- 0x3f08ef5a, 0xa66ebdd8, 0x2fb907f4, 0xec99e57d, 0x87e8a1dc, 0xf75bfae0,
- 0x7026140f, 0x3128a53b, 0xff20f9a4, 0x3f91868b, 0xfbe182b9, 0xa7a825a1,
- 0x5de64e82, 0xefd27acf, 0xb23ff687, 0xd27cfabf, 0xfa214fc3, 0xbe49d721,
- 0xda759450, 0xd84916c3, 0x974a415b, 0x76eb718b, 0x5c044d6b, 0x47d7011b,
- 0xbf377fc0, 0xbf133225, 0x35025aa5, 0x5fce2496, 0x4a482f68, 0x47f816a7,
- 0x51ed4fea, 0xb53fed7f, 0x3fa834fe, 0xfd7f54db, 0x0bfeb53f, 0x29bff47b,
- 0xafa5fd5a, 0x0416da6c, 0x79b4537d, 0x3cc18b95, 0x4ea95474, 0x4bdd02f6,
- 0x21762fd6, 0x82511c1f, 0xa3e7e42e, 0x34727921, 0x22d2f87e, 0xe7cca2fc,
- 0x855d7090, 0xc7fd427f, 0x54d9f85e, 0x59bee7b4, 0xbd69baaf, 0x5b0d6754,
- 0x1acb4e41, 0xdfa0a70a, 0x1c83e017, 0x46527a5e, 0x9fccd1b8, 0x4aafcf45,
- 0x701eff46, 0x844f588a, 0xab2a5ec9, 0x9c24f3fd, 0x2759ca87, 0x7be459c9,
- 0x04e9fed8, 0x5ab98fd2, 0xe87ccf5c, 0xe5f9d927, 0x0de52f02, 0xbb293b3f,
- 0x30f6bd30, 0x4cb013ea, 0x7c8f0ec8, 0x41d840af, 0xc4ce2c87, 0xb1425856,
- 0xa11fb11f, 0xc2f1d4de, 0xaa0edc42, 0xf0e4f0da, 0xb6afd083, 0x24badfda,
- 0x7974be03, 0xf33f553b, 0x7a7aafd7, 0x62edcbd7, 0x5efdd7bd, 0x34f3de88,
- 0x89adfb0a, 0xd86a25a7, 0xc971f685, 0x841bd55a, 0x9e9b25c7, 0x5c69ee7d,
- 0xf5627eaf, 0x17f5045e, 0xc3e37a6f, 0x6f170031, 0xf0a71351, 0xe4a43861,
- 0xc394fa6e, 0xba23f9bf, 0xf2f451e9, 0x18679a1b, 0x4270fe7f, 0xb78a5d37,
- 0xb0d8d6ec, 0x5098f89e, 0x716b5bbf, 0xfd4fa144, 0x676849c1, 0x56f86d55,
- 0xd1e575c3, 0xc94b125d, 0xb5cf8288, 0x80bd906f, 0x0a7a2278, 0x2fd1757a,
- 0xd0397ca2, 0x247af505, 0xbdcb22bd, 0x1465fa81, 0x93fd17af, 0xbe2fdfc0,
- 0x4fec7e8a, 0x43c45ead, 0xb9f78bc1, 0x95873c70, 0xcfe7ce0a, 0x3f464e2c,
- 0x4c1a817d, 0x9fca5376, 0x9fb9ac17, 0xbdff2ff8, 0xfaf993fb, 0x42d7d7d0,
- 0x2fb05573, 0xeaf6738e, 0x799c68db, 0x587c402c, 0x0fec8cf0, 0xc2b5fa41,
- 0x22896f26, 0x9732c527, 0x80ebc393, 0xc3ce30b8, 0xbf414eb8, 0xd0e5efee,
- 0xcc8ff27a, 0xee0fa861, 0x6cf1fdd7, 0x8b5fc12e, 0xb27184fd, 0xdae75f45,
- 0xbb5bfc4c, 0x74e919b4, 0x052f806c, 0x4ce56afd, 0x487c0a09, 0xf95ea067,
- 0x3853abbd, 0xc947989d, 0x5d81ef16, 0x639f0130, 0x67d566f9, 0x8f7a6e1f,
- 0x6ee8c99d, 0x1f689e7f, 0xf3831dfa, 0x5664e1f9, 0x7c651f50, 0x07aeb235,
- 0xf0375e60, 0xb9de4199, 0xc23ed7fc, 0xff975de5, 0x31934dd0, 0xb9f7abff,
- 0x387be11c, 0xc2bf425f, 0xfbbf9429, 0x83f48956, 0xc9a38595, 0xe42aad79,
- 0xc91f9cdc, 0x457fd02f, 0x0df0338a, 0x744093b6, 0xde5abf20, 0xa8df784a,
- 0x575db157, 0x39757acf, 0x20fa17ce, 0x707d064f, 0x603eb759, 0xe81eb9ab,
- 0xf20aeedd, 0x7a1a9bf5, 0x5f9469ee, 0x07a0d790, 0xe3f557e5, 0xdc6f8ff8,
- 0x209de1fb, 0x75ebc7b7, 0xd5eb35b9, 0x782db948, 0x7c84bd69, 0xc7b7291a,
- 0x894ac00b, 0x3cf0b726, 0xb416dcaa, 0xaaf44bfc, 0x65c7c78e, 0xf5d55eb3,
- 0x8cf86f64, 0xca9793d4, 0x127aa89e, 0xecb3ef7e, 0xf3a8fc9e, 0x457fcea1,
- 0x80bd29bf, 0x9f3a09fc, 0xc5d87cea, 0xf61f3aa7, 0xf098cff0, 0x3b7f9918,
- 0xc10c04f2, 0x7f255dbf, 0xdf134962, 0xdef7838f, 0xf8459fec, 0xc734d1f2,
- 0x9fecdfaa, 0x11438468, 0x79447d70, 0x8fec045f, 0x80881f28, 0x4be54c2b,
- 0x8c6af71a, 0x2a6c20f8, 0x2bff9d67, 0x759445f6, 0x950f3eac, 0x82d49c37,
- 0x9d691fc8, 0x753fea1a, 0xe8a89821, 0x9329dc3f, 0x7003b0ff, 0xe9da04bc,
- 0x0a1198d8, 0x6c591e82, 0x0ecdebe7, 0x012ba777, 0x1cf1c5d2, 0x96d24cee,
- 0x9fd41ea0, 0x1fb9da77, 0xe9dfc3a4, 0x31f8378a, 0xa4c9360e, 0x6c425bc7,
- 0x093f3472, 0xdf8434cc, 0x3e5bd616, 0xe0768ff7, 0x87b633be, 0xcf40cefb,
- 0xfa4765ab, 0x56bf5c7c, 0x23605ecb, 0xedc16b36, 0x77a1742e, 0x71ba0d34,
- 0xfd9f3c1a, 0x6db7ccb6, 0xafa53e82, 0x8471dd61, 0x2b189f05, 0x72de7ee1,
- 0x4d999fe2, 0x6b321d7c, 0x28797479, 0x39e5ef12, 0x77a869e6, 0xb9f0fd61,
- 0xd7ac0fd1, 0xe23ab053, 0x42f5d379, 0x3d69aa6e, 0xce6b5458, 0xd4f5880f,
- 0xc9feba37, 0x7fa49964, 0xeb84a170, 0xafb7a17a, 0x38de8796, 0xb1d3e80d,
- 0xbfb8664f, 0x2649aa7a, 0xc8da9cfa, 0x305953f7, 0x8cafe489, 0xd4be9275,
- 0xf286d6f1, 0x7aef7175, 0x9feb6dac, 0x3e421fb2, 0xe187f6da, 0x6db482bf,
- 0x778327db, 0x47cafc20, 0x3d607fe9, 0x65d84fcb, 0xc7733f27, 0x7ff1272e,
- 0xa5dfcec7, 0x76f0843f, 0x3af7f92b, 0x1c3b7d76, 0xa163b1f9, 0x60f500b5,
- 0x7ebe00c7, 0xedf9daaa, 0x7f9a16f0, 0x331d1117, 0x7de88d14, 0x072fe9aa,
- 0x54e02e30, 0xed0a8c13, 0x24b15d8b, 0xdaafe55f, 0xb1d11fc9, 0x80ecdbf3,
- 0x9e379fe3, 0xd3ffb132, 0x5ed364e1, 0x73c5fec2, 0x8ef979bf, 0xc02ecfd1,
- 0xdd86f1fd, 0x9fc84cda, 0x875fdaf0, 0x78ed7ea3, 0xed4ddb89, 0xdc1acb6a,
- 0x48ba18df, 0xbd02a85e, 0xfac851da, 0xd16fb631, 0x4728f1c4, 0x57f2f13d,
- 0x2f9cb3f2, 0x7c28263e, 0x8feffb3d, 0xf5c7c90f, 0x9364339f, 0x1ddfdc70,
- 0x89ea03f8, 0x4be2565d, 0xebc7bc7d, 0x733d9017, 0xfbdf71ae, 0x52dc6e3f,
- 0xbdc67cf8, 0xff9cdfe0, 0xfa878aad, 0x3d072917, 0x03e77cf9, 0x7a726f04,
- 0xc9e7bfa9, 0xa7ff6bef, 0xa025fdd1, 0xe3dcebbb, 0x4b3fff0e, 0x0ba7b7f7,
- 0x3e31bbba, 0xbfb5fca0, 0xa87eff52, 0x37f96b9e, 0xe36f7ba7, 0xb7fdedd7,
- 0x33f79e2c, 0x5664fca1, 0xe2c340ed, 0x6f3dd2da, 0x5bee4267, 0xb1e37b69,
- 0xf623e3bf, 0x5e34f47b, 0xf1b6fee5, 0xed03efb8, 0xac4978b2, 0xab3af917,
- 0xfa2fb0bf, 0x3b23cbcf, 0x63da7fa4, 0xc5304f64, 0x2bf712b3, 0xe99f4adf,
- 0x360bd8a5, 0xc200e3e2, 0x6c052bee, 0x4afe6f5e, 0x4adc3e62, 0xfd7e9fed,
- 0xd373b43e, 0x83b264d2, 0xf7fb2521, 0xfe64d775, 0xad3344bc, 0x98f5ae87,
- 0x129347d7, 0x89a8ebcd, 0x19abbea2, 0x0ed5ffef, 0x3c021429, 0xcbf01f8c,
- 0x8ea7f444, 0x126548bf, 0x605893c0, 0x263bae11, 0x9df5cc3a, 0x836c7dc0,
- 0xc5eff1bf, 0x3c2ec4e3, 0x47e95c0e, 0xc9900e3c, 0x3c4e7aaf, 0x6f09bf62,
- 0xc78c2199, 0xe3978a61, 0x4bd4a131, 0x1eb16a7e, 0x1da26ec7, 0x349638a3,
- 0xb82b3ca3, 0xa078e69e, 0x9ebeb875, 0x4cdf0dee, 0xd115cfac, 0x257f8ea4,
- 0xcdd9f64d, 0x5cfad1f5, 0xa50fcba7, 0x7fc74e87, 0xaac92e94, 0x8e692e99,
- 0xebca0a39, 0x8c3f5c64, 0x1c99f2c4, 0xb42a0b4e, 0x0fd624df, 0x28e678d7,
- 0xa4278041, 0xaf482a65, 0x22f6db7c, 0x79b51f8c, 0xc5c7ea25, 0x1f9a166d,
- 0xe112596c, 0x428d487d, 0xf7167bf0, 0xd4f7a428, 0xfe395e2b, 0xbb3f4320,
- 0xba06e34f, 0x7c97ef9f, 0xd8cce67f, 0xf0c7f46c, 0xde7fc61f, 0x59b7eb00,
- 0x063859ab, 0x615b34f0, 0xf404b8c1, 0x73ec4b93, 0x0cdc9f93, 0xe4aaefe3,
- 0x55ce7aee, 0xf2bd37be, 0x015f4ecf, 0x45f9f63d, 0x94c76d8c, 0xc6288a6f,
- 0x9a8ff6f5, 0xf7cabe38, 0x1e40d0b3, 0x0dfb2187, 0xab2f8afb, 0xcaf33fdc,
- 0x891a5f1f, 0x1d71dceb, 0x7eb8e343, 0xa971e2cd, 0x8a70bd62, 0x0ebce279,
- 0xe283afd4, 0x9f74bf68, 0xe7168cec, 0xbfac41b8, 0x28f1837f, 0xb2d47690,
- 0x57d7196a, 0xbefc93ac, 0x5b1b5ac1, 0x661e251f, 0x7e116a8d, 0xf8374122,
- 0x7fb8d9c9, 0x0d9fdbc3, 0xe919c6af, 0xa8e536d6, 0x1d27bc32, 0x61b9f7f0,
- 0xc51feaff, 0x11f7ae2f, 0x2dec1bbf, 0xf451fc93, 0xdfc0bd47, 0x91df3dd4,
- 0xa6d2f49f, 0xdfe416b5, 0xa62d6b4b, 0x553ad8fd, 0xb04631f8, 0xa9afd811,
- 0x2cceec7b, 0xd93ecba4, 0xe5a5f18b, 0x40b5274d, 0x48c47d94, 0xe8fd627c,
- 0xdd556f7f, 0xb50eeed4, 0x75e2267e, 0xc31b09c7, 0xad76f575, 0x3f5a38ba,
- 0x7ef2b4ef, 0xf7f566ce, 0xf7f8cf0d, 0x0eb8efc3, 0xae3c7847, 0xf0996b3f,
- 0x1ff24483, 0x553e3e23, 0xbf3842c7, 0xf5157ae2, 0x8c8da9c2, 0xc94077e6,
- 0x06feb863, 0xd1b1ff79, 0xe37173af, 0x5da0df96, 0xb924d650, 0x4ca24b71,
- 0x8fd0d169, 0x2f18de5b, 0xe99c3ce3, 0xdd6fe3d1, 0xc8356ec3, 0x10aaab45,
- 0xd98ef6be, 0xfbb61771, 0xd0c69b65, 0xdebdf14e, 0xfc79c2e9, 0x2491a6cb,
- 0xeb8dbd07, 0x34564ae5, 0x841ce311, 0x87e48c3e, 0x4c631ba1, 0xa07215f0,
- 0x54d7ca1f, 0x6f3ccb6b, 0xd32dfa14, 0x788fb124, 0xf42dfa9e, 0x7b7e99ff,
- 0x016fd75f, 0x23906fd9, 0x419bc0bf, 0xd344a5bf, 0x4f25736f, 0xee7de20a,
- 0x482941ce, 0xab6fb9d7, 0xdbf4d149, 0x2fbe4aa6, 0x4dc459ba, 0x7e803477,
- 0xdfa0dcbb, 0x45bf401a, 0xa3191f89, 0x73fa7ee9, 0xbfd0b7e8, 0xa136fe46,
- 0xde328b7e, 0x74fe041b, 0xe9bc36fd, 0xe1b7e920, 0x3c53160d, 0xf84d44f0,
- 0x6fd57a9b, 0x68add252, 0xbd53ef1f, 0x67f851b1, 0x37c7b093, 0x6c46388b,
- 0x955cf507, 0x5cf4c3f6, 0xb9eaf9de, 0x759e117f, 0x2b77373d, 0x9ee8b8a3,
- 0xdcf5c87c, 0xe7a0eddc, 0xae47e424, 0x64eee6e7, 0xa1172fdc, 0xd0f486df,
- 0x97ca8c6f, 0xe5fbf985, 0xde4f198d, 0xf08df50d, 0x941b5ea9, 0xefadd11f,
- 0x5df51946, 0xbe8bd695, 0xfa7e77db, 0x77d0ab6e, 0xa206c7a0, 0x0fe48d7e,
- 0xde39936f, 0xc3e8c77c, 0x79465f1b, 0xfb4c9df9, 0xf859ef92, 0xa33bd1fe,
- 0x7f21670f, 0xf3fa2a7d, 0xd9e9c6a2, 0xfaa4195e, 0xc7cebc27, 0xfb91ba57,
- 0xb81acbcb, 0x2b56587d, 0xe7f03c87, 0x69df31a4, 0x9dc2ffd8, 0xf8014b12,
- 0x13f56b26, 0x9febb40e, 0x1f589957, 0xf034c94d, 0x629cacc3, 0xd957fbf2,
- 0xfcf0eb5d, 0xd9852cd1, 0xec5fbfd0, 0xed147498, 0xbe1ce2e0, 0x9e2c501f,
- 0xb3b071eb, 0x4464f4bb, 0x9ce3483c, 0x9eb3fb37, 0xad531671, 0x9f53ae9c,
- 0xb7184295, 0x22ee33da, 0xb8a17a44, 0x5dfcfcce, 0xc9377f21, 0xf62f842d,
- 0xee351cae, 0x85d72f43, 0x4f027da7, 0x9e131780, 0x3c545242, 0x64a7a501,
- 0xa5e37726, 0x4b2d77f0, 0xf0a05f70, 0x91f68929, 0xe3adc723, 0x3afc722d,
- 0x773f751e, 0xbf2fa8b1, 0x6b9d2d69, 0x8e8bc48a, 0x747c48e7, 0x1f023de1,
- 0x7e5d69ef, 0xd71891ed, 0x7a437c04, 0x809ff826, 0x3fc76817, 0xf9d322ee,
- 0x5e048f9b, 0x9b8f5646, 0x370fe180, 0xe43a1c61, 0x79ccd5e7, 0x63e02fb3,
- 0x119ec7d4, 0x315e9d38, 0x7dc01ac6, 0x4ef60dda, 0x1f3a83d2, 0x3e72b30e,
- 0xd95e84d4, 0x3c62afd1, 0x251bf3ad, 0xe521da37, 0xb5e13b61, 0x0ed1f81c,
- 0xf53ef645, 0x578124cd, 0x6aaf9d37, 0xd013f314, 0x26eb82c1, 0xf10abe7d,
- 0x9b2358f3, 0xebca5d38, 0x58b25d38, 0x94c7ed27, 0x30de48d5, 0x71aca78c,
- 0xeba1c50e, 0x0e7e19fa, 0xf0a29d23, 0x7f8d12af, 0xb39b3a19, 0x62cde7bb,
- 0xb5aa6e51, 0xe7dc43fa, 0xb1f20a99, 0xfe10d896, 0x3efe1677, 0x2450fc57,
- 0x78132ebd, 0x757884db, 0xb93afe20, 0x8efe15fd, 0xf9e969ce, 0x84d04ae5,
- 0x9f4f09d7, 0x53b7fce6, 0xac5fa0f2, 0xcfc86f0b, 0xc74a3f90, 0xd233f21b,
- 0x465729a1, 0xddf00f38, 0x78e7a327, 0x28d4bf71, 0x0f3b85f7, 0x919ffaf2,
- 0xb8ca2cbc, 0xff7f307f, 0x4deebe40, 0xc55987de, 0xf7f0413a, 0xfdcef63b,
- 0x77bf9123, 0xd12fdc4a, 0xf7da6f14, 0xd7cac1bc, 0x20ec1b4d, 0xf6dfb807,
- 0xe75deab6, 0xae1fa9e9, 0xc03972b2, 0xe0c784f5, 0x0704baf7, 0x75a6f182,
- 0xa4178a36, 0xf6e40c7e, 0x6f5f51aa, 0x5ba4b3b2, 0x7faf7ab3, 0x37bfa88a,
- 0x8787497b, 0x47a87b61, 0x21bda11b, 0xce45eddd, 0xe0ffba17, 0x43bae35c,
- 0x3bdfcff0, 0x1f9dbd2e, 0xce554f1a, 0x4c5f699a, 0xb54aab8f, 0xd1515e04,
- 0x992c9bbe, 0xe7a0b7e2, 0x70ffce82, 0xa36ab7fd, 0xa59faf7a, 0xd08ec8da,
- 0x2d5ecbcf, 0xf010583b, 0x254fa5f6, 0xe32b0179, 0x7f38b183, 0x1079878c,
- 0x8ff72f92, 0xca6ee8fa, 0xed9f6997, 0x29f5dfc6, 0x1bc87dc5, 0xbb1d0c79,
- 0xfb225331, 0x6cac3de1, 0x36e1da34, 0x268ab3e6, 0x47e73f21, 0xd73c21f1,
- 0x3d5b5992, 0x3d7203c1, 0x85542ea2, 0x674277a9, 0xaf483be2, 0x7a433271,
- 0x4cfafb35, 0xbef7f9c0, 0xdc4cb33f, 0x813b078a, 0x8fb119ea, 0x31b96125,
- 0xce5a24be, 0xeaf86e8c, 0x7fa05bfd, 0x5ecbf7a3, 0x69bb940f, 0x7281c3af,
- 0x85b56436, 0x19780c05, 0xe85542c3, 0xc87d1a77, 0x83ea0b77, 0xf07bb002,
- 0xd341497c, 0xc2172ada, 0xbf7a25ab, 0xe498183c, 0xaa6dfe82, 0x32e93939,
- 0x0e500bd4, 0xcd5f29ab, 0x4ad795cb, 0xce710c5e, 0xf1415a6b, 0x12b57948,
- 0x14dc601d, 0xd78d9892, 0xbd41b21b, 0xfbc3569b, 0xc17f3859, 0xed6f58fb,
- 0x416ff7c9, 0xa4fd03bd, 0xfdf237f7, 0xcf783cfa, 0x3b527283, 0x5c2bea87,
- 0x073c312d, 0xcf91b053, 0x55fb054f, 0xec37e62f, 0xdde68a7e, 0xdf5ed029,
- 0xc28f9c0c, 0xd13ce913, 0xe74dc948, 0x80be1f38, 0x0e0756f4, 0xa5f05f18,
- 0x4909f8f3, 0xa3fd62c0, 0x6dfd7fdb, 0x9e535cfc, 0x07d68177, 0x272779ea,
- 0xfc42c329, 0xe1f69274, 0x03be010f, 0x79379c56, 0x9cdecb3c, 0xc316b42f,
- 0x1b6398fc, 0x6acfef44, 0x1e71471c, 0xe29f99b3, 0xe68ea63c, 0x57bbe776,
- 0xefe843da, 0x4ced577b, 0xaf7be7c3, 0xf6f3d2b4, 0xb70f5c4d, 0xbf21680f,
- 0x2ad5e1fb, 0x552ff3c3, 0x13d265ab, 0x74aa3787, 0x867e576e, 0x6fe437c7,
- 0xdec876e2, 0xc3debcd5, 0x9b7edc75, 0x936dccf0, 0x5fce1e70, 0xeaf9cfcf,
- 0x875f5a7a, 0x4d0bb9e6, 0x9ea45bf3, 0xa970f5d5, 0xf54147c0, 0x8f4fda5a,
- 0xfaa5bbd4, 0x6fa1187c, 0x9d9f714b, 0x24c3d3f6, 0x91f5a547, 0x6e8e65f1,
- 0x43f20dbf, 0xefe23bf8, 0xc32afdb2, 0x45f48d75, 0x678a24db, 0xf21ef9c3,
- 0x3e493747, 0xf8287b8c, 0x7b221ad8, 0xe33b943c, 0xf99e703f, 0xc8f0cac4,
- 0x03d22b48, 0xb58e54f4, 0x84bf8ff3, 0xb3df47e7, 0xf010e461, 0x5fe12e4f,
- 0x5ace138f, 0xb27ee3cf, 0x8c995bde, 0xc4d98de7, 0xf207a43e, 0x3016646b,
- 0x92a38de8, 0xf93b96ef, 0xfb46e0fc, 0x966ba747, 0xf3879d56, 0xeb8d916c,
- 0x957acf47, 0x0bc78bce, 0x3e0bd618, 0xb70a77b4, 0x0cd648af, 0x73b850fc,
- 0x0ea83245, 0xcbc444b6, 0xe6738954, 0xa76f1a85, 0x5ee49770, 0xaf47686b,
- 0xdb57af47, 0xb41bdfce, 0xd5bda793, 0xa3fd885f, 0xa1ad7e71, 0xa7ac88de,
- 0xd4bdfb47, 0xa75ff393, 0xffb9e257, 0x0a65779c, 0x62f9cf76, 0x3ee320ca,
- 0x7eea9e8f, 0x2df7ece6, 0x5fc067cc, 0x98631fce, 0x86ef40cf, 0x40ff2051,
- 0xb91a1bbf, 0xea30d73d, 0x459a56a0, 0xbde51bb0, 0xcba3f84c, 0xbbfdf226,
- 0x16f7cc86, 0xc94ffca1, 0x581f8892, 0x49f5a030, 0x83cdfb24, 0x59f900fb,
- 0x787cfdfc, 0xe1b2e51f, 0xa0a72e29, 0x4fa83c2f, 0x98af56ca, 0x256be544,
- 0xb0dfd60f, 0x92ec9736, 0x51991c82, 0xb241ed7e, 0x0f1a0a93, 0x833ca226,
- 0x7b44aefc, 0xd5ac6ca0, 0x9758ea8d, 0xdfce5d4b, 0x9961e715, 0xcf0c3dcd,
- 0x5876e077, 0xf796f934, 0x72b76133, 0xe1cf2cb9, 0x26eefb72, 0x3e784715,
- 0xad724e72, 0x728cb1cb, 0xc72dd59c, 0xd04f577b, 0x870fae50, 0x99a38a24,
- 0xe5007a80, 0xe71e837c, 0xf3d8edc4, 0xd973f395, 0xbf20a599, 0x72ea5f38,
- 0xa475cbae, 0x2d2b373c, 0xee3f62b7, 0xe34ed2bb, 0xf6d57098, 0xfae3ef0f,
- 0x275ff68a, 0x3260f55c, 0x853cc7ea, 0x78e979c7, 0x5c78552d, 0xad7e8f60,
- 0x3df5a05c, 0xf445fe9f, 0xd9ab33e3, 0x8b6f125f, 0xb5eff1e7, 0xb9fdf12a,
- 0x9c87b3e4, 0x9e7ca79d, 0x4b9d5caf, 0xe5f6f53e, 0xe27ae69d, 0xf5476991,
- 0xf01dafac, 0xbe3c0618, 0x8a59f1b5, 0xc2f13e0f, 0x8748a9c1, 0xe7c01de2,
- 0x9d1b5fc8, 0x4e7a8c2c, 0x55bcd109, 0x39d320d4, 0xb384a603, 0xe51a716f,
- 0x1575c798, 0x3f12766f, 0x0d64bd15, 0x8bf7814d, 0x9c317db6, 0x76166ae2,
- 0xf05adc52, 0x072f6105, 0x1ca3865b, 0xbe3c2914, 0xfc2f522c, 0xe7edc6da,
- 0xd3b1edb6, 0x1d527c70, 0xa8a2dfbf, 0x6ad576fe, 0xc278a7d8, 0x50bb52a6,
- 0x8379f68e, 0xfe78c7c0, 0xbc67fb17, 0x2b8f4157, 0xf5c0db6b, 0x1aa35144,
- 0x8a327bc2, 0x63b4b6ea, 0xc7d171bc, 0x957ff256, 0xf3a49dd7, 0x6f361314,
- 0x794aff22, 0x8fda6ca3, 0x59df11eb, 0x18ad8727, 0x4a50d897, 0x1f0090fb,
- 0xc45eb824, 0xf8c0fe53, 0x3bcde2c3, 0x850105b7, 0xef3f2fc5, 0xac72fd42,
- 0xf10bbd79, 0x359ef50e, 0x3c47bade, 0x2223fd67, 0xc386f39e, 0x2f4b6f74,
- 0xf0c79cf1, 0xb794100f, 0x4e78e66d, 0xec87d756, 0xb667e84b, 0x47feca3f,
- 0xe9be7d97, 0x1e7835eb, 0xe3a5eda1, 0x25dfb06b, 0x0d72fb7f, 0x5db189c6,
- 0xcaf79a76, 0xe280f85f, 0xbef7f5b7, 0xc87f09b0, 0xfe29e786, 0xab13fdbd,
- 0xdf6b6b17, 0xe31d3879, 0x7cb7db06, 0xccfe8c97, 0x26af3b79, 0xadbcef7f,
- 0x94585213, 0x914f4379, 0x11e7437f, 0xb7491f7f, 0x297b0dbd, 0xd004ed9e,
- 0x5760f51d, 0x297d6e9c, 0x88f67f8f, 0xd18ddcf8, 0x88f43bcf, 0xe5b86dc7,
- 0xff512bc6, 0xf27b7037, 0xefb9719c, 0x3f2f3d03, 0x146e3a0f, 0x37f5d7f1,
- 0xf72e359c, 0xf401fe04, 0x74cdd8b2, 0xf661bafc, 0xbcc69faf, 0xc6bd3e86,
- 0x03cf86e5, 0x8a79fa7f, 0xa73e6c77, 0xa5e8e51d, 0x343c50df, 0x078a6fd2,
- 0xd3afa3e7, 0x11ca3cf1, 0xce3a73b5, 0xad3b9d3f, 0xd14fdf74, 0x9e488fce,
- 0x47beb7da, 0xce266a7e, 0xaeb3b435, 0x973f8f1f, 0x9d6b78c4, 0xd0579e3c,
- 0x3d7de301, 0xe22e7a2e, 0xeb5f397a, 0xc5bdbef1, 0x1f6d5ef9, 0xe00fee28,
- 0xb5a5c8f1, 0xb3f1107f, 0x729374dd, 0xcf075e90, 0xe3ad471a, 0x72f42dc1,
- 0xf47b1c77, 0x38aeeab8, 0x21ba08f6, 0xea9e713d, 0x3807538a, 0x49f9046d,
- 0x2e768a3e, 0x8f2d7da2, 0xa3576f7f, 0xe3d6379f, 0xf4117dda, 0x9bdbc7d6,
- 0x7b72e8bc, 0x50fc71ae, 0x4266d13c, 0xb57c4f52, 0xbf5d1f7d, 0x7f4bb4cf,
- 0xebbefad7, 0x148954bc, 0x5eeb1e79, 0x86d2cbe4, 0xeccfe483, 0xf18b7f5a,
- 0x7bff09b6, 0xc5320bdb, 0xdfa92f39, 0x523dfa4b, 0xbde1947f, 0x7bfa512d,
- 0xe7d85dbf, 0x68fe7c8d, 0x7219c97b, 0x7b6d3d40, 0x975f13b6, 0x71483c6d,
- 0xbdd66fd6, 0xe218b5ac, 0x08fe7027, 0xf6d3c619, 0xa4e1eee2, 0x30fdc5cf,
- 0x8954ed91, 0xa29bca76, 0xf1be53b7, 0xe29da9a4, 0x76e6bd60, 0x63bdbb9c,
- 0xac76ef8a, 0xb73358ef, 0xcbd58f13, 0xf6d14393, 0xd8aaec69, 0x29e6afef,
- 0x0f74a3cc, 0x7bdf938e, 0xc862bb23, 0xcce79cee, 0x112e38f9, 0xbae28d53,
- 0x388816aa, 0x537a9fb0, 0xce55de91, 0x77f618eb, 0xe0d7e231, 0x01dd51ff,
- 0x9aaaf686, 0xbf42cfea, 0xd1dea443, 0x642c2d12, 0xe73cf7a0, 0xed0f14e4,
- 0x90d3848b, 0x0f32079e, 0x67ef58ab, 0xcfabfe11, 0x0524b614, 0x5059f7fa,
- 0x7a802ef2, 0x0c5ff7d9, 0xd67b3bf0, 0x8781c3af, 0xa9bf9365, 0x0079dacc,
- 0x35ec2bd7, 0xc847ed3b, 0x7f74ecbb, 0x3b1af948, 0xd6ef778d, 0xbb239f6f,
- 0xc656d7fb, 0x556087f7, 0xb996f783, 0xb7871d79, 0x2fe6bb7e, 0xcbe35768,
- 0x1afe7ed0, 0x89eb8f28, 0xfeb4b18d, 0x8e2978e9, 0x7fcb51ee, 0xa8a9a1ed,
- 0x3963f2d7, 0x4e6fe63f, 0x7d415509, 0x6e1c49ad, 0xee8034dd, 0xc97e28ab,
- 0x7ba5f149, 0x8652beb7, 0xe6fb54f3, 0x60330c58, 0xfb09afed, 0x7ee237ff,
- 0x63d51aad, 0x642f338c, 0x2e78c78a, 0x536118a8, 0x3f23135c, 0xfa11c906,
- 0xe8e31ab1, 0xc5d8113c, 0xa84e7aa6, 0x89780f9d, 0xf8fd838f, 0x3f70aa39,
- 0xe59107d4, 0x76fdfcf4, 0xdcbd8e7e, 0xba39ef0a, 0x9d6b97cb, 0xeeae1c79,
- 0x3349f5c7, 0xe744ff95, 0xb3df9173, 0x23fe5e5e, 0x7aaedebd, 0xe265fbf8,
- 0xfe489b7e, 0x57a5d43d, 0xb4717afe, 0xf4a25bfb, 0x2fdf9e9f, 0xed05a0b1,
- 0xba762d96, 0x67ef0bb7, 0xdb0e73c0, 0x55ffbe34, 0xfdd30ae2, 0x3e843b39,
- 0xd309892e, 0x44fd3e7d, 0xc23cb03f, 0x22f2d6cc, 0x15f4bdd2, 0xb3f8c33b,
- 0x3e9cd7d2, 0xb6e977a4, 0x957f5b6f, 0xb18bf185, 0x7d2bd7e4, 0x1f117fed,
- 0xd3c35a94, 0x2dbcfee9, 0xe7f78656, 0x3b796db5, 0x4db5e51d, 0x9c27a70d,
- 0xb4af5f65, 0x57be6ade, 0x58e38c40, 0xbc42e865, 0xaf3f4177, 0x9e8bd45b,
- 0xdb8632b9, 0x9f18f6d7, 0xdde48635, 0xb1d44f7c, 0xc641c6ca, 0x9e45fbf3,
- 0x7fb17ae8, 0x9d8ffa8c, 0x38f47743, 0x263fdaf7, 0xe699ed09, 0x96407464,
- 0xfa8e3d81, 0xe4eea8bc, 0x7c1ff430, 0x6fdfa316, 0xf9c389e0, 0x73ad33e8,
- 0xcfbfea18, 0x19873bd2, 0x952399e7, 0x92a28f36, 0x8ed2875f, 0xfaf327b5,
- 0xb5378c31, 0xf7a68b4f, 0x12c4c586, 0x8e1e8afe, 0x7a8e7a8d, 0xabe70c4c,
- 0x531f6834, 0x43e5176c, 0x2d33f76f, 0x31b87a44, 0x49ebc3c6, 0xbcf8690b,
- 0x20fb6eb8, 0x950a1e23, 0x72072a6a, 0x642cf84a, 0x832cb52b, 0x2bdbd6fe,
- 0x28f0ef9c, 0xf2813f74, 0x55f8ba7f, 0x3933a6ee, 0x518e3191, 0x5c6614e0,
- 0xe7eb33f2, 0x6fd51448, 0xcc69fc43, 0x646456ef, 0xf7926a95, 0xa94f5618,
- 0x7e2ecc03, 0x43055a5f, 0xec44793d, 0x0c1fa3ef, 0x3d7c6ed3, 0x383f7a48,
- 0x328bb180, 0x4f09bef0, 0xbf80db9c, 0x3eb3706b, 0x2b69e309, 0x5317d718,
- 0x488f68dc, 0x033b00c1, 0x595554fc, 0x03df8837, 0x2f187cc2, 0xf42c2649,
- 0xf37ee5cf, 0x8083b43b, 0x843df94f, 0x1550b157, 0x86c318a0, 0x9e3aefc9,
- 0x96f3fbf1, 0xeb8ccc7d, 0x0741128f, 0x7a4ddc16, 0x7fbac1cc, 0x5aa3009d,
- 0x155b7d45, 0xdc1cb7f7, 0x59b8739f, 0x58c3ed18, 0x42c70b07, 0x1caa18ea,
- 0x2bbfca33, 0x5f03600b, 0xf39ac7ba, 0xf402e523, 0xf5bb445a, 0xf7a83f84,
- 0xbf7a88ab, 0xabf7a88a, 0xe3abd5b3, 0x2836dca9, 0x58a5ef03, 0xf02f595c,
- 0x09b3dbc6, 0x867e01bc, 0xcc7f3de0, 0xfb15e312, 0x18d784e6, 0x962b1bd1,
- 0x8e6eba07, 0xfa7e20c9, 0x4eaedc59, 0x8966978c, 0xc3d70c35, 0xbefd248b,
- 0x1877e64f, 0x1b6e63de, 0xa223e1c9, 0xcf02cd9d, 0x55bf748b, 0xb276f28f,
- 0xb7947abf, 0x263e56f7, 0x6f67797a, 0xde8d89fd, 0xea5ef89f, 0x5a8d8eaf,
- 0x4bd50fff, 0xf47daf65, 0x76efee0e, 0xa03727e9, 0x6e676cde, 0x1a54fd46,
- 0x16b7fadf, 0x4cedc27a, 0xde999a5b, 0xc0dfc831, 0x9a17316f, 0x49f2479f,
- 0xf472fe14, 0x29df7185, 0x61f3bbda, 0xe74d5e7e, 0xbe315c83, 0x9f7cb589,
- 0xdc79eefc, 0x46cb078f, 0x25dfe61f, 0xe1aeeff2, 0x0fdde3f6, 0x1b0fb4cb,
- 0xc1d5bf79, 0xe1efcdff, 0x801f07b8, 0x5f33ddbc, 0xa233850a, 0xdec5dbdd,
- 0x677a878f, 0xde44fe88, 0x9e601583, 0x68e4cb49, 0xbe7160f7, 0x45e1cfd4,
- 0x8b317fde, 0x66fdc5f9, 0x3159e7e6, 0x22dbe26e, 0x0f55a425, 0x82c79eed,
- 0xd1ef802b, 0xc7be04fe, 0x9c592ffd, 0x8d2e66c7, 0x9adfd7c7, 0xa77fd260,
- 0x70e27886, 0x8baf66be, 0x7cfe6ee7, 0x149eb5ee, 0xe54579e3, 0x1ee9ac74,
- 0x9bd52aa0, 0x3d4dfa8a, 0x80f33d7d, 0x07a76a1c, 0x1f218f31, 0x7e1256ec,
- 0x3d24f30c, 0x5084aa95, 0x3f6e2a2f, 0x37bb47cb, 0x5eb3f39e, 0xaebc4b5e,
- 0x177ccecb, 0xe6461dfe, 0x5dcfff81, 0xdff3a1e1, 0xa7fc3957, 0x5d95fe71,
- 0xa380de39, 0xb7043f27, 0xe15771f2, 0x8e7a33b8, 0x7af34aa7, 0x0ebedec9,
- 0xcbf245e6, 0x3fd86d79, 0xc8f9ead9, 0xadfbfd83, 0xd30fd0ca, 0x23de3f13,
- 0x153fc821, 0x24714fea, 0xc194dc72, 0xbc72fed8, 0xfff4146f, 0xe8bf7132,
- 0x52264aa2, 0x08b7571e, 0x34a51fef, 0x913ea447, 0x8f72a64e, 0x974a7b8a,
- 0xd5297a54, 0x56f36bf1, 0xb6983dd3, 0x36fb790b, 0xa25fa0b7, 0x402fe045,
- 0xb52d97f6, 0xed1df682, 0xde308aee, 0x60d2c727, 0xb961c1de, 0x9abf09ab,
- 0x13bf919b, 0x456c13ca, 0x66b55218, 0x7149d10a, 0xc87cb057, 0x0604754f,
- 0xe37da2c7, 0x6987df31, 0xd6711d4d, 0xf8bb31fb, 0xfbc7136d, 0xb7e71263,
- 0xa63fbc48, 0x6e307b36, 0xbb6bb1e2, 0xbc22abee, 0xe38872c3, 0x7ef93ffd,
- 0x37bc4f6e, 0xc0699b4f, 0x327b33bb, 0x0267fde1, 0x5e054bcf, 0xaa1d04ab,
- 0xc4ab3e04, 0xe255afbd, 0x812adcde, 0x3bc42adf, 0x7b888fa4, 0x3d23177b,
- 0xef119520, 0xa1d6bfc0, 0x7b432641, 0x520f0f7c, 0xb75be087, 0xb2a4fc85,
- 0xbc43efc3, 0xde39135b, 0x03a00e6d, 0xdde035f1, 0xc241f983, 0x78e0eaa7,
- 0x0e9cf286, 0xef105602, 0xa739f123, 0xb6fde007, 0x87d424d8, 0xd6784c63,
- 0x1f9fc712, 0xf3e29fde, 0xf390a25b, 0x6a25fc48, 0x5d605efc, 0x8fb37bbe,
- 0x765c44ab, 0x1197b895, 0xcd7688f1, 0xbb0fc02a, 0x3f93e398, 0x2f60221f,
- 0xfd6249a5, 0xc074055f, 0x3d8527fc, 0x74c67884, 0xb75f2c67, 0x762a5a24,
- 0x04a788ab, 0x4b0fdf7e, 0x6cb4b20c, 0xf18043c6, 0x1e641a97, 0xe1fdf584,
- 0xc8ff335a, 0x7ee2256e, 0xc893cf49, 0x56df2b6f, 0x2f7fb82d, 0x74debfcf,
- 0xe69e5bae, 0xfe10f78b, 0x35da1203, 0xb872133f, 0xfa85f902, 0x8bc3d7c7,
- 0x152c1f05, 0x223f06f7, 0x2131e7f8, 0x7ceb8fcf, 0x48e7e5e3, 0xf1e64f96,
- 0x1699898e, 0x9862bf71, 0xe309e319, 0x834cf5bd, 0xc6dad17e, 0x9fdd2943,
- 0x92b63ec9, 0x650ec6dc, 0xf8afe43e, 0xf10c1f8f, 0x7dfd70fb, 0xd78a1ed1,
- 0xeb1dbfef, 0x0e83bf89, 0x711587b4, 0xd7cca4cf, 0xef51cd93, 0xeef2ad8d,
- 0xa65fa1b1, 0xbeecfeb7, 0x73f11b69, 0x1e44e5de, 0xbfe027d6, 0x8ec03663,
- 0xc157581a, 0xc81bd62f, 0xa57a8c5e, 0xebfc49c6, 0x1be7fe80, 0x17b624f8,
- 0xc754ceff, 0x5f501bb5, 0x240680bc, 0x6a2fc130, 0xcf11d906, 0xfa0f7380,
- 0xfea956b1, 0xac2f38be, 0x8fee8f8a, 0xdf2c65fb, 0x5d657087, 0xac2bf26a,
- 0x9ef47d54, 0xef59ac7b, 0x44f314ac, 0x9cb344c2, 0x4fc2f3e8, 0x39577d45,
- 0x5fb13b02, 0x9227a7c9, 0x1cde273c, 0x52a89e7d, 0xf7de20b5, 0xcb8c3551,
- 0xe3573077, 0xfd0f73f6, 0xe49f68c3, 0x3af06054, 0x7ce983f4, 0x7d7190b6,
- 0xaedc6417, 0x04f5c7d4, 0xe715bdf2, 0x3ff13703, 0xcb0807ce, 0xdefc6a17,
- 0xe42dbbe3, 0xe4225887, 0x672151ed, 0xfd7c85cb, 0x8acbe51c, 0x297b58f7,
- 0xab9085fd, 0x90872895, 0xe0cd8f1e, 0x3fb8bcf6, 0x2ccf5f4c, 0xfba08db4,
- 0x161cab22, 0x4f94179a, 0xae0721ac, 0x768f760f, 0x7647ffa3, 0x4e03b966,
- 0xfba2cfcc, 0x2cf8a5dc, 0x37cdf237, 0x9c1759ce, 0xc8161e2d, 0x2b16f74f,
- 0xea4bf72a, 0x8957c8f7, 0xf75408fb, 0xd5fd0ccd, 0xd856264f, 0x9635de29,
- 0xe4d787c7, 0x81de1366, 0x86b19d1e, 0xb4ca5a75, 0xfbeebaeb, 0xec9feac3,
- 0xef835ee5, 0x6960de85, 0x41a17641, 0xfb88d44f, 0xc8279924, 0xc5f41886,
- 0x31268bc2, 0xd4f5eff4, 0xcde8bd13, 0x2e6f5cf5, 0x4deba292, 0xf5d78edd,
- 0xd17ea466, 0x4c17c5d3, 0x54bf9d36, 0x7a465e1d, 0x3f744867, 0xcac3b242,
- 0xd7992ff7, 0x33d19b9b, 0xec95f01f, 0xed0be030, 0xf16fdd21, 0x89e328e3,
- 0xae4793d4, 0x00d7e7d3, 0x4b343bdd, 0xfa393cf3, 0x79abf3ac, 0xfd3fc85e,
- 0x794fcd08, 0x5a5347a7, 0xd92d7350, 0x69770c23, 0x1c2ef70c, 0x0bbf7d5e,
- 0x46b87be9, 0x56af9fec, 0x74bf1843, 0x197166b8, 0x0f76d5c1, 0x2fdc66d2,
- 0x3de1741e, 0xc8d6b34d, 0x247e9fb4, 0xf14e9826, 0x399fdf9f, 0x63e21b23,
- 0x9a5dac16, 0x6b38fc8e, 0x373a52dd, 0x37c1247b, 0x59806fd8, 0x79ec8796,
- 0xbcc6fefd, 0xb43ead67, 0xdbe37bc7, 0xfdd1d5bc, 0x27f8553d, 0x779853ae,
- 0x7643ae08, 0x8674c6bb, 0xfc8e0f81, 0x82eb4ec2, 0x8ed82d2a, 0x58bad570,
- 0x2555837c, 0x280fbf44, 0x0fb571d5, 0xf0ea94e9, 0x73298b5d, 0x4f7ed024,
- 0xdbc472ef, 0x3b5f456f, 0x2d3ebbee, 0x3a0245ee, 0xbbf264dd, 0x56d77df2,
- 0xb66347e1, 0x4463f25e, 0x7c97a7be, 0x62938f17, 0x7ff9e8ee, 0x6869ffb7,
- 0x315df58f, 0xe6b4bf8e, 0xe84f92f8, 0xa11f7989, 0xcf8bc450, 0x5a1b175a,
- 0x66ce4518, 0xb3c7f389, 0xce997ec4, 0xebd7858f, 0xe3e739f6, 0x5e973e48,
- 0xfaf884b8, 0xcd2a7dcb, 0xafc0656b, 0x17a5efa8, 0x507dd346, 0xe2bb9e0b,
- 0xfc0b8c71, 0xf94cbf6a, 0xc4eda725, 0xf53fedc7, 0xce8239d2, 0x9df4a9df,
- 0x5df6af88, 0xda01e74d, 0x3ad3fdc5, 0x7c9cd29e, 0xc1c6bc3d, 0xe9de50f5,
- 0x743c919f, 0xa66857f1, 0x779e7286, 0x5e5ce7fa, 0x31d9fef0, 0xdeebec38,
- 0xe0a1771c, 0x2cd7806b, 0x2169349f, 0xc2df9bd4, 0x0d8d8ae5, 0x7b1f9196,
- 0xd1f7ac6d, 0xc6bff228, 0xb5f931e1, 0xf3965bf2, 0x4caec0f7, 0xcc99c434,
- 0xc87bdf12, 0x65efcd3f, 0x4b20ee65, 0xfa127945, 0xcc0e5bb0, 0xdbb772f7,
- 0xd3d4e3cd, 0x79c6bb17, 0xd6fd6985, 0xe8abce3d, 0x53b09e79, 0x13465bf2,
- 0x5f9e3ddc, 0x9e368e8d, 0xa58c71ee, 0xd1f1edf2, 0xb450ffdb, 0xc0595adf,
- 0x8b4fa07c, 0x79bffdc4, 0xd434fba1, 0xe3ab791f, 0xb8c32413, 0x4d8a6bf2,
- 0x35794ff1, 0x5fdf74b9, 0xed5ceafe, 0x76bc835e, 0x36cd85d1, 0x4743e5d1,
- 0xd532e880, 0x40e3dfe1, 0xf0a17cb9, 0x583d4f81, 0x11d3a72f, 0x82bc382d,
- 0xae7ddbf4, 0x3ea7e768, 0x8d53a48c, 0x1fac13a0, 0xd2740cb2, 0x7ef913e9,
- 0x07d2faeb, 0x8bfdc53e, 0x45edf8a7, 0x08b1ebbd, 0xc74465fa, 0xf383a75f,
- 0x0fd82b6b, 0xdfc2f381, 0xbbf8a665, 0xe827f15e, 0x7f47e3ad, 0x51dff60e,
- 0x944efb94, 0x1f5851cd, 0xe17387e7, 0xc17dbbad, 0x8fa2e30f, 0xf3a9c527,
- 0x04167cc3, 0x71aa3e01, 0xf1f7a3fb, 0xb682c43c, 0x974f18f3, 0xf1362e9c,
- 0x01738a43, 0xff415397, 0x211e7ba3, 0xc50d6ebe, 0xbd19ed7a, 0xd9c5278f,
- 0x185c1f0b, 0xffb34364, 0x11c1f1ef, 0x29f837cd, 0xde60479c, 0xf0bd79c2,
- 0x1b86c7f9, 0x18ea97fb, 0x79c4e697, 0xf6fcfaa9, 0xbde383b7, 0x1e1d70fb,
- 0xab7b275c, 0x8e254860, 0xbf7c60c0, 0x37f4f5c8, 0x145bdfe8, 0x68f0c4ff,
- 0xcae2f476, 0xdfa0977d, 0x99b2aab5, 0xc5d85552, 0x0ce2ed0c, 0x688f5dfe,
- 0x2b5e05f7, 0xcae2ebf4, 0xb5b7ee66, 0x70db9905, 0x323b00cf, 0x8ad8fc92,
- 0x69cf6cc3, 0x7e8dc06a, 0x83dc4d73, 0x65812aa0, 0x67e85919, 0x1a0ccc4a,
- 0x938d77f0, 0x4f2cd7ef, 0xfdc6e3dd, 0x8fd42b10, 0x9a5b33fe, 0x77e4ca72,
- 0xe5995d7b, 0xd7e93a04, 0x7ab0c744, 0x1f91249f, 0x1f8454f2, 0x1fa994f2,
- 0x7da6cd89, 0x28bc488a, 0x281dfe36, 0xb3ff0985, 0x9dfe87c0, 0x3e6ea5a4,
- 0x8fc295ce, 0xaffa04fd, 0x363b022f, 0xc1f645d6, 0x7c2c0b92, 0xe853687d,
- 0x3c6b2bbe, 0xf1c5af2f, 0xff71d871, 0x59f5c643, 0xde276098, 0xd5d32610,
- 0xf1c2128b, 0xdc2123cc, 0xe0978587, 0x5c63a37a, 0xfcf803cb, 0xd7207b79,
- 0xa6ff7809, 0x0901f36f, 0x81fc33f7, 0x35cf118b, 0x03d33072, 0x772d7fe5,
- 0x74b96266, 0x8138fac8, 0x39e017a7, 0x9f618087, 0xdcd7df94, 0xe13dcb0d,
- 0x112be60b, 0x5fdf86fb, 0xc7b7cc6c, 0x1fb02af8, 0x4acbdf91, 0xfda242fc,
- 0x074cfc41, 0x34fdff9f, 0xf2772f3f, 0x07f10575, 0x6e3ed7f2, 0x3c529d3f,
- 0x87efb871, 0xb4dd79d8, 0xbcf363ef, 0x114f686e, 0xe05ad8eb, 0x4fb0c557,
- 0xb3e2a177, 0x545d3f20, 0xfd8dcf0d, 0x2727628d, 0xf2dae838, 0xdebd76a8,
- 0x83af3c3f, 0x4f4f94f8, 0x92247b22, 0xed74762f, 0x69eff027, 0x9e33a1dd,
- 0xf1c388b2, 0xfad1ff4c, 0xfdae93ee, 0x761c45aa, 0x5efca873, 0x69fe3fbe,
- 0x99c51c6e, 0xa3b8fdea, 0xda336969, 0xf53477c5, 0xbcf8899d, 0x3fe2e0a3,
- 0xed43ba63, 0xfa8b13dc, 0xce897ee2, 0xc1f9dd97, 0xa42c6aeb, 0x475fdf5b,
- 0x2f3c1ff7, 0xeb3a71e4, 0x01fe9154, 0x7ef8d6e6, 0x47df8857, 0xae02bcc5,
- 0x715fd157, 0xdb743877, 0xf3dd000d, 0x3406e87a, 0xebefa6f7, 0x43d5037c,
- 0x893ddea0, 0xf7f494f6, 0x726fbd1a, 0x35d7bf98, 0xe346c57e, 0x8daf1ee9,
- 0x0f8fafc6, 0xeff84a7a, 0xf7b88fc2, 0xf8c7c74d, 0x77dc7c99, 0x1d75dec4,
- 0xe03acb3b, 0x3fb0db0e, 0xde3e78f3, 0x7cfc489f, 0x1fa05985, 0xf6fa745f,
- 0xe33e3f20, 0xbd45edf4, 0x4ceb6257, 0xbc920657, 0xcbcf85bc, 0xc905c0e4,
- 0x0313fe30, 0x21271702, 0x9cfb9a1e, 0xc07fbd97, 0x80fbf9ce, 0x81f7f39d,
- 0x5baf9d0c, 0xecd7c89c, 0x538d2274, 0x92c77eff, 0xbb1f87ad, 0xc4fbf81d,
- 0xbb3efcdb, 0xe373d952, 0x9697e443, 0x3e2e3199, 0xfc203d32, 0x7c5d2d0c,
- 0x433bc7c8, 0xa332f2e1, 0xc1ce9621, 0x9b2f98cc, 0x319fdbee, 0x32c3c79f,
- 0xadf879a5, 0x22c275a6, 0xb3d2d711, 0x4483f41e, 0xfe7333d6, 0x6517ba04,
- 0x471ee69b, 0x9c35917e, 0xf44e66cf, 0x608e78c9, 0xf68932cc, 0xf21f47f1,
- 0x3c00b634, 0x45ef1433, 0xe0f99d31, 0xfbc20d7f, 0xb99aca51, 0x9e45347f,
- 0x4853f993, 0xf3e1ed57, 0x1073c23d, 0xc79f0e4f, 0x69cfd861, 0xdd322b53,
- 0x38f7cfc8, 0x7207a87c, 0x827df56f, 0x22fdd574, 0x0afbbcfa, 0x171801d8,
- 0x27b77b9a, 0xb724f907, 0xd4a3eede, 0xd01894c6, 0xb30ab96b, 0x31a29a61,
- 0x0c698ec5, 0xbd9a61b3, 0x354fd850, 0xe0fd9137, 0x786bf1ca, 0xd36e79bf,
- 0xfbe35ff3, 0xb7784af9, 0xdcabe064, 0xa3bfb7a6, 0x3f3e7673, 0x565efdc5,
- 0x9fd699a7, 0xf0cdeac3, 0x38668de5, 0x47866c33, 0x65c333ee, 0x67683638,
- 0xe11ef88c, 0x86569d9e, 0xde2b2bdf, 0xf438a56c, 0xa0ae7157, 0xe93b5e78,
- 0x4dc509c5, 0x712718d9, 0x05a745fc, 0xfe3b95fd, 0x59c532fa, 0x658a6e74,
- 0xfbb86718, 0x831618d3, 0xed9bbc71, 0x18bf30eb, 0xd9fe8768, 0xb5f6cde2,
- 0xedb34f18, 0x434f9d52, 0xedb50f14, 0x4bbcfc6f, 0x086b06e7, 0x6f8e2ee3,
- 0xe445fe7f, 0xfa1be3cb, 0xaaf61d93, 0x7d60b414, 0xdd3847c1, 0x3ebd08c7,
- 0xe2f5e846, 0xfc7af33a, 0xaf6e970a, 0xfce287ba, 0xe3812637, 0x2fb2b5bb,
- 0x2577c587, 0x8c6dfb74, 0x40dd67b0, 0x7687cfcf, 0xd08879d3, 0x7ba179cf,
- 0x6bd11f35, 0xb3ea0c41, 0x0cdaa38e, 0x5c5d4bf4, 0xcea3c663, 0xcc8497df,
- 0x24ba27cf, 0xcf0ce7a1, 0xc55e3033, 0xe71524b3, 0xdfa367ef, 0x8bbd7f53,
- 0xbc2f19db, 0x20f2e9a0, 0x992a7b8b, 0xb2ae70c7, 0x79b3ef5b, 0x089e31fd,
- 0xfbb035e9, 0xbb447179, 0x2eb1fd7a, 0xda5fcf2e, 0x448279f8, 0x95638781,
- 0xe86ec8fb, 0x7d2b23b2, 0x380689be, 0x727766af, 0x776fe12e, 0xf986bdf2,
- 0xdec364aa, 0x4e30bbe4, 0x8f414eae, 0xe3b92b36, 0x498f9fb9, 0x3d72e7c4,
- 0x11f313f6, 0x6ff56d8f, 0xd81cb0b8, 0x718c23d9, 0x5735f967, 0xe41a26fb,
- 0xb9f287fe, 0x3712b74e, 0x392bcbc7, 0x9cf093cd, 0xff0d7148, 0xfd71618e,
- 0x80dcb76d, 0xcfcd5ef8, 0xcc2b67d3, 0x963c832f, 0xfaedb96c, 0xfcbcf061,
- 0xec5e5199, 0x2b71540f, 0x78de2f3e, 0x3d15ce92, 0x8efee16a, 0x0504fa48,
- 0x13fa3d9f, 0x39ea0147, 0xcb75efa8, 0x9f7f7a08, 0x239bec05, 0xdcef83e3,
- 0xb38e4505, 0xa06f0ffa, 0x9f3330f8, 0x684bdf02, 0x97ae75bf, 0xe9e8ebbc,
- 0xd19becc2, 0xa02df754, 0x8fc87978, 0x0c297eba, 0xa489eb99, 0x6fc16aef,
- 0xe4621bf0, 0x7d72c893, 0xdce904a6, 0xd07cc974, 0x43ff0693, 0x8a6aa1c9,
- 0x076c8dcf, 0xc1985823, 0xe181da0e, 0x9b972875, 0xfc169c78, 0x88b65b24,
- 0x61c41f63, 0xf915c7ba, 0xf8a21811, 0x83d13652, 0x4d99bd78, 0x37d754c6,
- 0xc3f5396d, 0x52abfcb1, 0xa2bf73cb, 0xe7249cfa, 0xdd30ee6d, 0x9c4fdb6f,
- 0x70f36f47, 0x8feeff58, 0x64d45f9e, 0xe3aeb8a7, 0xbfd23427, 0x149e300b,
- 0xb768bfcb, 0x3d68c058, 0x78cfa5be, 0xab6e538c, 0x1fa5f7e7, 0x5e33efab,
- 0x1ebccb3b, 0xf9f44fa9, 0x39fe20f6, 0xbe7afd1a, 0x83ce1726, 0x771c788b,
- 0xcc8a9f4a, 0xd274288a, 0x2ad44bdf, 0xd3fd7132, 0xbbc38f79, 0xcc14f08e,
- 0x9fefc850, 0x5c9a7e4a, 0xe83a9fe1, 0x02edbff6, 0xaca139ba, 0xec25fe0f,
- 0xdfa1d793, 0xfbd90bf3, 0xf7507b80, 0xacacfd3e, 0xa3df9d00, 0xfb40f40f,
- 0x56161533, 0xe266df80, 0x609c353c, 0xae674f9a, 0x719e2896, 0x78f372d6,
- 0xe36ebef0, 0xaac05afc, 0x5622dea9, 0x6ac1694f, 0xce217e73, 0x273c2e47,
- 0x8a76e3c7, 0xfaf9cd6a, 0x8d92c0b9, 0xf0d1ac67, 0xc7d335f6, 0xc702fbe7,
- 0xa36cdd27, 0x2ab7ddfe, 0x6977ef8e, 0x6df387cc, 0xe9272ae7, 0xa01662ff,
- 0xe629dc7e, 0x7307f2fd, 0xed20b37d, 0x37d33f98, 0xcb9e0fab, 0x2d23f3e7,
- 0xf99e4919, 0x13c57ebd, 0xbf007859, 0xbce187cf, 0x8524dc5b, 0x036c2187,
- 0x9fc11d51, 0x3826bde3, 0x3679e37e, 0x6e38fc7d, 0x3ef673e3, 0x9e116fa7,
- 0xb8f9929b, 0x0225f98d, 0xad1b251f, 0x98d17f26, 0x79d0528d, 0x6aaf9e39,
- 0x1acaf7a1, 0xf54d58ce, 0xec1d798a, 0xba076601, 0x2b58298d, 0x755660e3,
- 0x25d0f1e9, 0x1ccbced1, 0x755c7810, 0x945f5e5b, 0xbed1c7db, 0x9d1027ed,
- 0xf84a7a43, 0x06d858a3, 0xec8cc5ed, 0x7b3f2982, 0xe2938721, 0x26a6bd1e,
- 0x4a2fbe8d, 0x653361fb, 0x0e789bff, 0xd03e32b3, 0x99da0e37, 0x2ba5f169,
- 0xc1bebf24, 0xcf9d6fe4, 0x88e4f0f1, 0xa22a4b8a, 0x3a75b7ac, 0x53d5213f,
- 0x3b70409c, 0x599da79f, 0x20c06a9d, 0xb8e32317, 0xd3db8cbe, 0x3a8fe742,
- 0xfe744ab7, 0x20e929f9, 0xea7e0f9d, 0xff430f5a, 0x09d02a40, 0x1253eff5,
- 0xfcf7845b, 0x34dc3565, 0x73a40de7, 0xe3178c56, 0xc61b4a0f, 0x1a0ea5c9,
- 0x62e3b73f, 0xbee2d62b, 0x218cca54, 0x61df9023, 0x866e33dc, 0x3ce3a3e7,
- 0x075f5ed4, 0xc2ea7ba7, 0xa1dcc660, 0xce7fbed8, 0xc38f281b, 0x7cbce862,
- 0x99cae00a, 0xb432e940, 0xe65952cf, 0x5333b46e, 0xa04678a7, 0x8b957f4f,
- 0x916493b7, 0xf684dc67, 0x270e08e3, 0xd6f92c3c, 0xa0ae1311, 0xfcac5276,
- 0x1cf87a93, 0xfa1b4ded, 0x7a061c27, 0xc4c8a84f, 0xf10653f6, 0xa70b5134,
- 0xbbfb3d61, 0x75a01ee8, 0x23373cc8, 0xbbef3d7d, 0x2eb82971, 0x0b06dfdc,
- 0xfb63d075, 0x97fdf4d3, 0xfbec83b0, 0xf2f0870b, 0x97994ec2, 0x24e7cfc9,
- 0x15f6eba6, 0xfaa1d72f, 0x5ea246e2, 0xf9db8f7d, 0xe47c395f, 0xeb42bf07,
- 0xa0803ce5, 0x58e9f953, 0x0bcc3216, 0x21bed3e5, 0xb4fcb3fb, 0xef1cf4cb,
- 0x95c63509, 0xa1ec1497, 0xb2943bef, 0x509f3a66, 0x838e6f5a, 0x7a2622bf,
- 0x979f3abb, 0x3059969f, 0xf99abb6a, 0x2c3ee9f9, 0xb95a27d8, 0xd3f3f364,
- 0xfc6e1992, 0xe8539456, 0x7169cb39, 0x0a71fae1, 0x67a847ce, 0x7aa09642,
- 0xda5d3779, 0x79a62ddd, 0xe1c3dda8, 0xa8bfb10e, 0xb7f5ebe7, 0x39c4d34f,
- 0x7bcf7e3d, 0x2028255b, 0x4dd3cfc0, 0x5ddfc927, 0xf09bb4d2, 0x3745f3a3,
- 0xd059629e, 0xaae4a780, 0x6405b0e6, 0xfdb8e9fc, 0x025e874b, 0xcba3d924,
- 0x7d4b3bf3, 0xbf1f2163, 0xef90616b, 0x792eacd8, 0xcab37527, 0xf0fd0b22,
- 0x6389d2ee, 0xdf2f308d, 0x35f37efd, 0xb2b78113, 0x6bf7f286, 0x6b7bdee3,
- 0x7506c621, 0x4ce83b9d, 0xb00d3bf7, 0x0076022d, 0xbb00cc3c, 0x2313f223,
- 0xe02353f2, 0xcdbe5e34, 0xbd974e19, 0xfb8e6d8c, 0xf4051ae0, 0xf0df5b5c,
- 0x6479bc74, 0xd747d579, 0x4b8ef7e0, 0x7bf7f8b3, 0xaf249acb, 0x65a3d064,
- 0xe4871e5e, 0x3368b6f0, 0x9a1e2287, 0x507d44df, 0x71b928d2, 0xdfa8e0fd,
- 0xdf182612, 0xabde18f3, 0x92d3ebe7, 0x5ef483fa, 0xb10ff5af, 0x3a3f3c90,
- 0x772a73e4, 0x362dfdae, 0xaf3dfcc5, 0x52bbf6de, 0x50b7812d, 0xc7f7eadf,
- 0xa8f96db7, 0x20aa7bfb, 0x7d7ded7f, 0x469f497b, 0xc72f5b9c, 0xe5ba38fe,
- 0xa3e3c745, 0x7dd14e43, 0xd6187fba, 0x079a01f4, 0x2e4ef3b1, 0xff75abc0,
- 0x14787a54, 0x27785fda, 0x4f1fce2f, 0x704ba148, 0x059a7a5e, 0xef76c12e,
- 0x3768bd29, 0x80ec6a7e, 0x5e0cf2da, 0xdc4df309, 0x01ffc249, 0xfc00cb67,
- 0xc7e9dd64, 0xa4e1c2ff, 0xe609ba16, 0xafefeab6, 0x1ecdefc1, 0xc032d018,
- 0x8ff7f002, 0xe0993a5f, 0x419e5a8b, 0x04eac2f8, 0x196b0f0e, 0x03fbc320,
- 0x23267d83, 0xa3bbd6fd, 0xa109fdcb, 0xc5fef46f, 0x891df60e, 0x84aafb43,
- 0x2c783bcf, 0x757a06da, 0x4db1d17a, 0xd31f01eb, 0xf49623ff, 0x5bb6fadd,
- 0x1e13f3ae, 0x6f8c7e82, 0xa6f8114c, 0xbbf49179, 0x5f44f642, 0xba130b9c,
- 0x6f4ce9e9, 0x71bcd0f6, 0xb416c569, 0x0fa6521f, 0x55e379a5, 0xee27ef97,
- 0xe9e9dd51, 0xc4fe9e24, 0x5bfae6ed, 0x46bc50b6, 0xb24e43ca, 0xdf171eab,
- 0x23b90067, 0xba0870fe, 0x3c7cdc58, 0x73190dff, 0x80001bd1, 0x00008000,
- 0x00088b1f, 0x00000000, 0x7dddff00, 0xc594780d, 0xbbbcf0b5, 0x26effeef,
- 0xb24d9bbb, 0xf379f909, 0x71100843, 0xa9189313, 0x18884dd6, 0x220bb531,
- 0x49716b62, 0xc93049f8, 0x2d16ad46, 0x544859bd, 0x46d10882, 0xe1b80a04,
- 0xfd2b6202, 0x1a8c4582, 0xf68882e8, 0x72dfbd2b, 0xbd3fadeb, 0x8a7e1bd7,
- 0xb4564288, 0xeb6dea5c, 0x2666739d, 0x5c9377d9, 0x9f7b7aa8, 0xbe8f8be7,
- 0xcef33bce, 0xfe73399c, 0xb3339ce6, 0x9086bb1a, 0x258e4264, 0x4ec730dc,
- 0xe631df9f, 0x224c9d15, 0xf433bba4, 0xc84b499c, 0xc421127b, 0x09f04845,
- 0x0e7b6853, 0xd1eddf21, 0xb4897504, 0x734de1de, 0x44b2d116, 0xc345bd7c,
- 0xd57fbde5, 0xd2b3e5de, 0xd32d3172, 0x9912abe7, 0xbd33f58b, 0xfe5a0e69,
- 0xa7aefe02, 0x9f561ee5, 0x58ad25ae, 0x7fbec39f, 0xe5dc84aa, 0x76d4cfa3,
- 0x7d296e3a, 0xb5b89dae, 0x916b8e9d, 0x0bca1789, 0x5d6c16e7, 0x736a614e,
- 0x897842cc, 0x51269bd7, 0xe6364ef8, 0x76d1566a, 0xc8afa7bf, 0x515c8435,
- 0x97b0cde0, 0xff40f9d1, 0x44d21c74, 0x3c369527, 0x37981cfe, 0x7ad7afad,
- 0xcf3a64b3, 0x39fe1ddb, 0xe35ebed0, 0xd0b4429d, 0x77c0b789, 0x8823b405,
- 0x3b76399f, 0x40f227b6, 0xffffbc19, 0xb8954f08, 0x4f115fee, 0x7534ef77,
- 0xf8242c9d, 0xb7fd05f7, 0x2aa1d7b9, 0xbad2fa07, 0xcb871a4e, 0xd0ffc377,
- 0x24ad4871, 0x2c3a1493, 0x8d6e22ab, 0xbfe836ff, 0x7a07e979, 0x513781a2,
- 0xf02ff43d, 0xeb0a4ebe, 0x82fce952, 0x76cf24fb, 0xb2cfdec2, 0xe8959211,
- 0x21e613bf, 0xc3f79ee0, 0xd17f34e6, 0x3f2c7cf0, 0x76e6a978, 0xe4b79c5a,
- 0xf4edaecc, 0x590f79fb, 0xdb865108, 0x9d711ed3, 0xb8cf7fdf, 0x9f495c9a,
- 0x86b0defa, 0x19fdebe2, 0xb69cb3c4, 0x1a435f7b, 0x73efff00, 0x743f95bc,
- 0x853211f7, 0xb5d95f90, 0xd0499df8, 0xbddbe483, 0x53b7e288, 0xd0234122,
- 0xd23d4cc3, 0xd28860c3, 0xfeb095c3, 0xfbe87d74, 0x872707ee, 0x067d7482,
- 0x619100c9, 0xbec4153e, 0xbfa9895d, 0x29eb00a3, 0xb44d049d, 0x0e68da3e,
- 0x5e80956d, 0x50a5a028, 0x5feb093f, 0x07fad895, 0x38e230ef, 0x1d1933dd,
- 0x433a3776, 0xb6001cc1, 0xc6de008b, 0x7694a3a2, 0x64487482, 0xb69994ef,
- 0xe36c7c61, 0x3a52c172, 0xb4dbe2f0, 0xe4dab23f, 0xb01f4f19, 0xbb943284,
- 0x4a3c7152, 0xbe91ab0f, 0xfd470664, 0xab42d38f, 0x394f5c70, 0x36a3cbac,
- 0x1f787cef, 0x014591fd, 0xc89937f8, 0x7d09634a, 0xe8c3a44a, 0xe1c0eba4,
- 0x134f5d21, 0x60bb83a0, 0x7f878a00, 0x536f386f, 0xd89ffbe8, 0x08038425,
- 0x484e58cd, 0x75f5611d, 0xa4c72ccb, 0x86d4f029, 0xddf4090d, 0x03bc1bca,
- 0xd972be82, 0xf3fb48d3, 0xeb22ba73, 0x83c036a3, 0x804bbe1f, 0x29b73ffe,
- 0xefd32856, 0xd3f2c0a7, 0xbf870bef, 0x7df039ff, 0xe0c7c019, 0x65166d27,
- 0x1f8c34bb, 0x80b9fcf1, 0x6f69ebaf, 0x9c6278ec, 0xd98f7ef8, 0xf007ffbd,
- 0x4e1ef145, 0xb45e0174, 0xf0f1aeb8, 0xc7d1f4ba, 0x5e7eb44d, 0x82b1d69b,
- 0xd4bfd3e2, 0xf015f386, 0xbd1a95de, 0xec8de48e, 0xa5a594ff, 0x2ff9865c,
- 0x964f7465, 0x62e22819, 0x2e1fa2f1, 0x485dd253, 0xd23587a2, 0xf0e5ef28,
- 0x517f8001, 0xf8f7cc77, 0x621abfdf, 0x21be09db, 0x3f07148a, 0x92452ba7,
- 0x12fcdd61, 0x3ebd375b, 0x56e40f3a, 0x9f02dc3c, 0x8de5c6ff, 0x7c788ba0,
- 0xbbe01bff, 0x5dbe246c, 0xe84c81fa, 0x80d4bfd7, 0x9fef8a78, 0xf77e1090,
- 0x4d0489b4, 0x4bd6ee94, 0xfaebd212, 0x90212d07, 0xe8a6839b, 0x6067c00e,
- 0xdeb88dff, 0x0acd1ae7, 0xea364da1, 0xf705bf19, 0x171f18db, 0xdc80140c,
- 0xece7473b, 0xee73eba5, 0xa09eda37, 0xa4208024, 0xadda37e5, 0x5ee7ff40,
- 0xb3f589be, 0x5a10a2dc, 0xe986000e, 0x7fe081b8, 0x578a11b6, 0xc7119669,
- 0x0a57b13f, 0x8fbea019, 0x5e4639e2, 0x36ffa39e, 0x8dcb0c94, 0x3800a841,
- 0x07082cfa, 0x8e23699d, 0x59335df7, 0xd16fc745, 0xad0d5e48, 0x2932596f,
- 0x31e0ced4, 0x16d5cac6, 0x4a90e90d, 0x45bff986, 0xdee0bc73, 0xa7275622,
- 0x60ac7970, 0x851243bb, 0x3ab8c9b3, 0x05fa05a2, 0x4bf5a03e, 0x78673ea0,
- 0x7f565a1d, 0x479817f4, 0x7d351ecb, 0x9eaf3d34, 0xba5892c7, 0x17a619ca,
- 0x17c3294b, 0xf1a126a9, 0x2f1b5e14, 0x21226a5b, 0xe963e02d, 0x2ae27234,
- 0xc0e0f4da, 0x5b23a074, 0xa3a92f69, 0xe269c0cf, 0xa7b8510d, 0x36bcf7f6,
- 0xd477b68e, 0xba613244, 0xcdbfa581, 0xf0d5793b, 0xaf380b3a, 0x4b427fe9,
- 0x7e1e38ac, 0xeef14147, 0x89bb62b6, 0x7d88aeb3, 0x92efc0ae, 0x0f2f4c35,
- 0x1fe02bc0, 0x75cde999, 0xfd526f5c, 0x617af28a, 0xafd404d7, 0xce40ffa0,
- 0xf4c0953d, 0x903dc831, 0xaa8e6d33, 0x9e741cab, 0x14d56766, 0xc71b1947,
- 0x27e98367, 0xa788fea1, 0x243d78eb, 0xb5e6a5da, 0xc75ab716, 0x0cf9476e,
- 0x90dd16f1, 0x2c88e4c8, 0xafd17961, 0x10ab3d75, 0xe6e9193e, 0x2839cdde,
- 0x97481b97, 0x89bce81e, 0xc740f484, 0x98248c8b, 0x1162e940, 0x9f48966d,
- 0x881bd78b, 0x8d7eb312, 0x89b97521, 0x49bb85cb, 0x7bbfbf04, 0x357d5c67,
- 0x7d68db09, 0x2d8491b3, 0xd755ecf0, 0x8e7d50b7, 0x85f7d67c, 0xe93df621,
- 0x8bbdf366, 0x3aa3bbaf, 0x79d3f5a4, 0xdd51306f, 0x5d0684ea, 0x97533eb8,
- 0x267ae0f5, 0x1e737896, 0x2bf2bd06, 0xa52b679d, 0xf5f03fdb, 0x6639f812,
- 0xbc00aaaf, 0x9c1ab59b, 0x0361f47f, 0xd524e7e2, 0x6bfeb0e3, 0x59aee41d,
- 0x8dae79f4, 0x8075f378, 0x2cd67b26, 0xaf3c48db, 0x00d4c57a, 0xd0e0d374,
- 0xd32ae8a8, 0xf972c3a1, 0xe5ff8e0a, 0x1cd6d096, 0xa014f744, 0xa15cf2a7,
- 0x9994c957, 0x474c7cb4, 0x6e5a3bed, 0x43f56399, 0x4f60037f, 0x0efdf2d0,
- 0x77eecf26, 0x453d71e8, 0xd057cc59, 0xfb071d0d, 0x9ec55f33, 0x43658e02,
- 0x74609fed, 0xbaf0f5c3, 0xea0f7346, 0xd5fa21e1, 0x22dfa410, 0xfaf01e9f,
- 0xf32b970a, 0xf8a16ec1, 0x1412857e, 0x2f608fc8, 0x3e295fb3, 0xe5a52de6,
- 0x79174e57, 0x67402956, 0xf2bcde4c, 0x4159331d, 0xccf37c87, 0x27fb1f4f,
- 0xb4fe7f5a, 0xfad0315e, 0x746b4005, 0x88915efd, 0xbe0bc617, 0xbe810868,
- 0x7b33d26c, 0x15ff69b4, 0xfbd19ecc, 0x71842c37, 0xc079d05e, 0x084a69de,
- 0xeb03b73d, 0xa2943cd3, 0x863aabc9, 0x16cbe0cf, 0xf439bdf6, 0xa0bb9fb3,
- 0xa413d53e, 0xff26a3ed, 0x74d75846, 0x7a889283, 0xc25ad7f9, 0x381709c6,
- 0x878f5e28, 0x9c7ddd98, 0x4e304956, 0xa1fb0dbf, 0x90b69a7c, 0x33a273f6,
- 0xe543e715, 0x2759da2f, 0x82b618d6, 0x34375dfc, 0x8fed84ae, 0xd3d37ceb,
- 0x8bf8f968, 0xb4e59ec5, 0x0fa7d06a, 0x073d29eb, 0xafbb32d6, 0x016ca35e,
- 0x16fd90fc, 0x8f58879c, 0xb5c59ac0, 0xb2581f50, 0x8f9016ec, 0xc839f163,
- 0x3723127b, 0x166891cf, 0x86c6d3f0, 0xe830dedc, 0x1e89fe95, 0x4dc4af54,
- 0x8dd29f17, 0xa93db59d, 0xee8df863, 0x5f3d21d3, 0x1740ff6e, 0x43d33972,
- 0xca804e30, 0x0ff82265, 0x594c72e5, 0xad995a3b, 0x5495e063, 0xeba9df6e,
- 0x47fc1253, 0x9e5a5d60, 0x97f78ffc, 0x145e302a, 0x4ae922e5, 0xa93cbe46,
- 0xba03cef3, 0xf5875475, 0xfd7a3175, 0x99d983a4, 0x076e06f5, 0x963eb092,
- 0x797d450f, 0xc5ee9a95, 0x7fa704f3, 0xf7c9845b, 0xce1af591, 0x401ab71f,
- 0x20654d8f, 0x23d06c93, 0xc15fe856, 0x0e9ea7fe, 0x3969ebeb, 0xbf58597b,
- 0x4f813f88, 0x46c3be28, 0x1b93ef3a, 0x29bf8c6c, 0x459fa01a, 0xe5f50415,
- 0x63b52d22, 0xd2bde04b, 0xe5d74037, 0xa40e8bd4, 0x8a67f22f, 0xf9ef8a15,
- 0x5033b784, 0xb1ca97bb, 0x30a43a97, 0xafe60bec, 0xe5356c37, 0xb57b5f00,
- 0xcdcf5836, 0xf9b1ca12, 0x1b05951d, 0x9ec97968, 0x13fd702b, 0x2e5d182a,
- 0x2f503909, 0xb1f2e54e, 0xa3d210de, 0x8933fe1d, 0xf6883ec0, 0x1374f68f,
- 0x64ad28fd, 0xae401e24, 0x1421e8ab, 0xd1f6a653, 0x57265ed4, 0x24e79509,
- 0xf2126ec6, 0x8938e41e, 0xf4d503b3, 0x88fa1411, 0xa4a23dc9, 0x7213dc82,
- 0x97dd98f9, 0x3e3b44e8, 0x97d6153f, 0x9b9327ae, 0x6bc425bb, 0x7d456933,
- 0xd0c0f422, 0x9c8f5cb8, 0xbe9906d2, 0xcf813c32, 0xae0e677c, 0x8bd212eb,
- 0x95e844fa, 0xdf20e8b1, 0x88fbe1a9, 0xbc60e9d1, 0x9afec153, 0x75f0934e,
- 0x65a6bc74, 0x853cdc24, 0x50536d3d, 0x693d323f, 0x9e127a64, 0x97d0cbe6,
- 0x5e31faf1, 0xc1ebc61f, 0x77d33d54, 0x3d859d62, 0xd98d3a93, 0x85975301,
- 0xfc08a4b4, 0x94eade35, 0x26bb61e4, 0xa8d18ef0, 0x1f65095c, 0x9ef905c9,
- 0x2a62f950, 0xc4c80fad, 0xa1657c0b, 0xefa1e978, 0xb7fb7337, 0xd7cd9527,
- 0xabf467ad, 0xd8a47d93, 0xc112eb0a, 0x99346f7d, 0x051e81d8, 0xe8db373e,
- 0x1df02577, 0xefa1b7e3, 0x1cc3a48d, 0x2bd57df3, 0x173fd426, 0x0c85b65e,
- 0xb3f88f68, 0x94bfb41d, 0x4ed01bdf, 0x0d8af73d, 0xae39e9f5, 0xefc25d0f,
- 0x7e611e40, 0x41aebe16, 0x008e3552, 0xc6334bed, 0xf6140881, 0xd983b359,
- 0x21ed2359, 0x99139f5e, 0x80cae8c3, 0x8e0bcdfb, 0x4ca00781, 0x7fa021e1,
- 0x7e32716e, 0x5699ec0f, 0x3efa43fc, 0x187ab3e0, 0x40c5fdf6, 0xf7ed06af,
- 0x7d2918e7, 0x8b2ed74d, 0xd1e7483e, 0x83b5699c, 0xfeceab7e, 0x41dddfd7,
- 0xd1ee1fcb, 0xf3ac0311, 0x497369f6, 0xb7f2d8ee, 0x3e3ba431, 0x772fc310,
- 0x9b9754ef, 0x40e5d57b, 0xbf7cba9f, 0x653ae6d3, 0xf9e1d941, 0xc1b5d282,
- 0x87ba7ad0, 0xd5786bc2, 0x8668fa80, 0x1390ffd3, 0x7a26ade4, 0xc86cf018,
- 0xf80a78fe, 0x9ffd023b, 0x5034f048, 0x31148a36, 0x5f5f03fc, 0xb6cfcd30,
- 0x61b7828f, 0x06a311fc, 0x75ad4cf1, 0x173944f6, 0xd2e27ce0, 0x403c3f7b,
- 0x9668bfe7, 0xdf02bed9, 0xcacb6b78, 0x18449ec1, 0x4dfd6049, 0x8bbec21f,
- 0xf5846bb6, 0xb693353f, 0xac3570a3, 0x89b0fa67, 0x6f801244, 0x69dda85b,
- 0x1bfc4ba4, 0x77776fce, 0xf4c3cb44, 0x359dbb7f, 0xf94e0113, 0xe80fb22f,
- 0x37e851e3, 0xeade4ec6, 0x4bfc7264, 0x463299fb, 0x02b699f8, 0x038d9afe,
- 0xfe3a4afa, 0x0cf97ff5, 0xa5e2fde5, 0x823ee1af, 0xb33e63ce, 0xc80a4dab,
- 0x1e0fc5a7, 0xdf62f7c0, 0x8ad32a76, 0x36d7b6fb, 0xa1d95818, 0xcda9f2c7,
- 0xb8b95f6c, 0x3cc10a57, 0x931759a5, 0x6c2f412a, 0x640dd9d6, 0xf1e35e24,
- 0xb7a6c1f8, 0xf5efc013, 0xf61d2201, 0xc7b3127b, 0xb809adec, 0x135a507f,
- 0xac0cbec0, 0x9043f1bf, 0x6b378b8f, 0x902f603d, 0xcff4367d, 0xc37cde2c,
- 0xe85685c4, 0x4aa4d3e7, 0xb96d13f0, 0xd0543c01, 0x7e6217ce, 0xf4f5c89e,
- 0x6ae5bcbd, 0xd0f1f805, 0x62ff0666, 0xd0077187, 0xd17ff5d1, 0x1ac97f22,
- 0xb93b07e2, 0x089def5b, 0xda6cad7c, 0xe7d61d3e, 0x1ae99983, 0x224bbf6c,
- 0x638bc076, 0x5fbc0a69, 0xe03ec92c, 0x8df586e3, 0x4f76b1b5, 0xc7f9939d,
- 0xa597b32a, 0xaf91580c, 0x6d3e80e6, 0x08f94cde, 0xdef59fc6, 0x0d70eeef,
- 0x6b3495f3, 0xa1532dfd, 0x1e7567ff, 0x7b21bbe0, 0x90b7d366, 0x4c2fe0be,
- 0xe398b5f1, 0x99f2abeb, 0xa4f822c1, 0xeae400b5, 0x05ad15e2, 0x8cec51f6,
- 0x44d93e21, 0x213272f9, 0xf9129da7, 0x1993fc02, 0x63bed54e, 0xb59a7dac,
- 0xc67a8350, 0xedde21e8, 0xb74a99f4, 0xb71fb0c9, 0x6f58c925, 0x7d23d24b,
- 0x77ba7fcb, 0xbce86fe7, 0x2ffa749e, 0x26ccbe80, 0x6bd062de, 0x455ed44a,
- 0x35405acd, 0x136461da, 0xcc89afb3, 0x92eb85fc, 0x31558ec9, 0x125373fb,
- 0x39504fdb, 0x73f405f1, 0x1f3fddee, 0x64b6fc06, 0xec053c7d, 0xcfc5c085,
- 0xb35fe0f4, 0xdf284bf6, 0x011f1ead, 0xcff409ba, 0x868a0b24, 0xc3c072e5,
- 0xbcfc46f4, 0x98e924e6, 0xb145751c, 0x82974a9f, 0x41076ee5, 0xd4b8da7a,
- 0x46fef68c, 0x4004c857, 0x2b7cadff, 0xee46a7ec, 0xfb6e340f, 0x740b5785,
- 0xe3ec921e, 0xfe30aca1, 0x17986c18, 0x3e71d2d2, 0xc41796dc, 0x8f4a9ef2,
- 0xb759d696, 0x5ccae3fd, 0xce9f53c0, 0x9eaded03, 0xdf980481, 0x244edb87,
- 0xb61afcc0, 0x0dde7169, 0x16524fa1, 0x09cb0d16, 0x905fc69d, 0x5d827604,
- 0x42f8c2b2, 0xedb87c5e, 0x560594d3, 0x7d403fe6, 0x5e3a3a5a, 0xc9cacecc,
- 0xdff5fdf0, 0x6672eb64, 0x72042197, 0xf9898cf0, 0x33bb45f7, 0xaeffa636,
- 0xcdfe124b, 0x3fd02cde, 0xa2796543, 0xf7c4e406, 0x2efe6ced, 0xf0166f7d,
- 0xba9247e5, 0xb52b259f, 0x52e54424, 0x84894ae3, 0xf33fcca8, 0x20594bdc,
- 0xfedc3fff, 0x0c5d5652, 0x89dff17c, 0x6a498de7, 0xaff09a7f, 0x0ce1f4ba,
- 0x63ceaf18, 0x31cc7e60, 0x3da2abfc, 0xa4fccf59, 0x816b9483, 0x8377c50e,
- 0xd82f660d, 0x18c483bb, 0x5d5b9702, 0x7ad7f73f, 0xd82ef9bd, 0xe3ef88d7,
- 0xf40d5ffa, 0xfa92e144, 0x5827f424, 0x9f28a28a, 0x77fcb4bf, 0x918cf5d1,
- 0x8d9d74ff, 0xc6cd4eb0, 0x0471e1e8, 0x780f43e9, 0x6558b7d3, 0xed2957d0,
- 0xf7a2be8c, 0xe59f706b, 0x814c2732, 0xdd3e80b8, 0x76f9056d, 0x43b9817d,
- 0xb3ef0893, 0x333ed042, 0x0bbf10bd, 0x0ffa3156, 0xc3f410a6, 0x095691a5,
- 0xe676b4fd, 0x20a8cfe7, 0xf8b455f6, 0xe76624b3, 0xbd6789b8, 0x5fd70f36,
- 0xc70738c2, 0x400fd08b, 0xcf2f2047, 0x23a44648, 0x7b425fa9, 0x9de9ab54,
- 0x458efd07, 0xbac52b57, 0x2a1aba72, 0xeae89dff, 0x23c74149, 0x20afcae8,
- 0xa38db95d, 0x23f715d3, 0x127b765f, 0x36bec1f4, 0x2d6be395, 0xfbd13f97,
- 0x2eafc28d, 0x796b7cc1, 0x6b46b57f, 0xc47a0b58, 0xd638fba3, 0xda89bc3f,
- 0x4a7fb0c5, 0x3e9ebb03, 0x57cfb5c7, 0x6448dd70, 0x9608fc00, 0x2fa88dab,
- 0x7244d31f, 0x9d498ec0, 0xe81bbad4, 0x515e7523, 0x0bee3b49, 0x17a01c33,
- 0x7fa2d740, 0x1f34e974, 0x1c5823b3, 0x8f533a28, 0x07969cfb, 0x8ecc7d2b,
- 0x097e41a8, 0xa02936ac, 0xe7f5a707, 0x08fa072c, 0x031e232c, 0x86cf71d2,
- 0x9dcfe045, 0xac80f56d, 0xb225f113, 0x9d77cd52, 0x05538b12, 0x0f18226f,
- 0x0d338e1b, 0xe821f96c, 0xf422c6ff, 0x8ff90c9b, 0x8dea09f3, 0xd6438dcb,
- 0xde2136ad, 0xd068fc45, 0x25741146, 0x3fb191fa, 0x7a646892, 0x407ca468,
- 0x054a73ff, 0xa1eb7f11, 0x3cca2e9c, 0x5ff823de, 0x456ca3c4, 0xc8b01cbe,
- 0xbf399c2b, 0x049c4332, 0xb36c77fc, 0x00fd8416, 0x19598dfa, 0x694fcadd,
- 0x50e92028, 0xaaab9ffb, 0xbcca6233, 0xc1f7d0fd, 0x5f573755, 0xa877fa8b,
- 0x7aa6c01e, 0x26bd9459, 0xc355e205, 0x83b532f5, 0xff127d8d, 0x1be6e2be,
- 0x941eaaa8, 0xee7ff8c4, 0xd11f82f4, 0xc5e35444, 0xf5c727c2, 0x5bfda3af,
- 0x383ede15, 0xefe826ee, 0x7e5112a9, 0xe14bd3a0, 0xf753ab5b, 0xdfe52887,
- 0xf78c4143, 0xaf0e537f, 0x6c319d5a, 0xe17b501f, 0xc36549cf, 0xefa3c276,
- 0x495d76d5, 0x3fd8b2c7, 0x15fe83d5, 0x92e03efa, 0xe7890ed0, 0xf49704d7,
- 0x656becd5, 0xe09d7d84, 0x74f5f662, 0x2fba4960, 0x581df941, 0xdf6023e6,
- 0xe9c4bb52, 0xe3e4bb42, 0xfd680753, 0x1f9f59b9, 0xbb40a71e, 0xbec1e67b,
- 0x4651702a, 0xa9d81bf9, 0x6f94490d, 0xaeccfd8c, 0xe31cfaa6, 0x967e8205,
- 0x38fd39d8, 0x97fc0482, 0x32a4fbdd, 0x5a4277a0, 0x6ba36eb3, 0x379703f9,
- 0xfbe1c713, 0x9779f8cd, 0x205f98bb, 0xa1b55850, 0x26dffa00, 0x5617b011,
- 0x594f1e15, 0x63a9fb80, 0xbe630b29, 0x0a7bec6b, 0x53b8d9f1, 0xcb1e2a37,
- 0x7804e1a9, 0x45f9796c, 0x338dc82f, 0x42650921, 0x04ea1c83, 0x41a1b6bb,
- 0x29211603, 0x03bfcd0d, 0xf5731fe3, 0x5f9d3c64, 0x8177d706, 0xa706b79d,
- 0xbfe9bcc2, 0xd1b57d12, 0xc4e508b7, 0x2b46b9c6, 0xeb0a91c6, 0xd83c41ee,
- 0xc3c05ecd, 0x34aac2aa, 0xe665a718, 0x4dc63b74, 0xf5073da8, 0x077e0f2d,
- 0xae0245fd, 0x1aba7d55, 0xa9ca77b0, 0x0a0bf75d, 0x4673a677, 0xf5f2878d,
- 0xe2eeed38, 0x5710acfb, 0xff8e5d1f, 0x174664bf, 0xf82f921d, 0x8ff452ed,
- 0x677f5892, 0x1fb31f76, 0x55e9716f, 0x5c5bf1fe, 0x36bdaecc, 0xe4069918,
- 0xb01e5fb2, 0x201d5d80, 0x5f604fde, 0x65567c4d, 0x9313ae3b, 0x0536ae5f,
- 0xd74666fd, 0x425763c0, 0xee32b5fd, 0xf03c8867, 0x5cf71863, 0x8ab3cba7,
- 0xf2803e70, 0x90214583, 0xfe5cfbc7, 0x96fac2ef, 0xdcf57b73, 0x831637cb,
- 0x5fd8517f, 0x5099cf9d, 0x94da766f, 0x4e406b27, 0x796649fe, 0x6468c603,
- 0xc967ed1a, 0xb71c4ee7, 0x84ea14d3, 0x68f60ff5, 0xeac9beb1, 0xdbf4045f,
- 0x29faeb78, 0x0d608798, 0xd51e8015, 0xd008bab9, 0xa0bedd31, 0xf2e8c51f,
- 0x4f238811, 0x2597ce0b, 0x767117d0, 0x63f034cd, 0x85c5bee1, 0xce2adc7e,
- 0x1529e31f, 0x2b22329c, 0x34917c74, 0xf9bce76c, 0xbc32d9e7, 0xc68ff614,
- 0xd5eefcc8, 0xec04cd73, 0xf448f25c, 0xf8fc06b0, 0x7b0108ae, 0xc257b9b8,
- 0x5f0b9a71, 0xe5fec3d0, 0xdfc65eee, 0xa0dfbe01, 0x78c2cbf8, 0xedc2cb94,
- 0x67460e81, 0x1c787224, 0xb679f9e0, 0x76d0849e, 0x42577e31, 0xc0793396,
- 0xf8f3d3fb, 0x37f73343, 0xf5884d51, 0xcec25cab, 0x5b8ea158, 0x49d771f0,
- 0xf016af11, 0xfca92c5a, 0xc3d9e2e4, 0x183c4fbf, 0x1bfc0e9d, 0x7e05f4a5,
- 0xccd20da7, 0xf3a75e7b, 0xc93650db, 0x9b98a603, 0x04b69392, 0xa45253de,
- 0xfbed2f78, 0x0dd03a64, 0xafc821a9, 0xda957d2d, 0xeb8b2b66, 0xa58c5e60,
- 0x53ea07b5, 0xfd442aef, 0x5993710c, 0x1cb3fdf4, 0xe65669af, 0x08af73c7,
- 0x341c40e6, 0x9eefa0f1, 0x2bfc61d7, 0x4d87e8cc, 0x73636ba5, 0xf82573e2,
- 0xf8a4dcbd, 0x7767e800, 0xf00252ad, 0xc41f7888, 0x0d16670b, 0x3d38e3e7,
- 0x7d2b7792, 0x983976ee, 0x6a40cedf, 0x1f785e00, 0x1fc70eb2, 0xe3079fc1,
- 0x9e0f7c42, 0x32c2d2e7, 0xc0c9fffa, 0xefb8ed96, 0x483e6037, 0xef1bdf6d,
- 0x35adfe80, 0xc78c5e92, 0xd52dd9c6, 0x02beb789, 0xf6783ff4, 0x018796d4,
- 0x7af6dbae, 0xce25ef30, 0x9bfeb91e, 0xb33f3ecc, 0x3f00a2dd, 0x9b72e56c,
- 0x27c88fda, 0x3f6c5dc1, 0x1e476f19, 0x27f7a975, 0xddafe543, 0x05f0648e,
- 0x0b3cb3b7, 0x7c03df21, 0x70d837ff, 0xd7f4013e, 0x13c10dbf, 0x8db20f97,
- 0x8ff483e7, 0xe6f20f9e, 0xe8104b0e, 0x09af7ce1, 0x8f3292fd, 0x45b59d7b,
- 0x7524001f, 0x01cf0e38, 0x72581b79, 0xca1ae7e6, 0x8b0f727f, 0x8f12c923,
- 0x4b4afd33, 0x6bcc5c58, 0x808bff07, 0x774c765b, 0x3e408b7b, 0x713779b2,
- 0xb39351bf, 0x2ef16140, 0x94d43796, 0x7b002e10, 0x87ae55ea, 0x5e2ccc9a,
- 0x87d0e835, 0x26a35d61, 0x185d1fff, 0x93df62d7, 0xd8941a5f, 0x884f56b8,
- 0x0a2775d9, 0x9d3d6135, 0x07d80f67, 0x59ab6eb0, 0x9f286b7c, 0xc7a1bf60,
- 0x5890e2c0, 0x41ccec1e, 0xe22f5939, 0x3f99fb56, 0xa7c79eae, 0xf45acc4e,
- 0x745ca40c, 0xb035ad48, 0xaab0bb3f, 0x0fe8fd12, 0x9f13393c, 0x7ed52bf5,
- 0xa7e045ff, 0x238e1bcf, 0x1d7bff0b, 0xbd99e8f1, 0xd447ec3c, 0x5945fb50,
- 0xbe815729, 0x15f621cc, 0x2095ff20, 0xe9abad5d, 0xc13e83b3, 0x12349768,
- 0xa77239d8, 0xfbeb0ccb, 0xf5068768, 0xe343b054, 0xcf027685, 0x8fccc939,
- 0xf3324d74, 0x0aa5d06b, 0xd9e238c1, 0x0771e3a1, 0xa272dfde, 0x2353c309,
- 0x76a3e7b1, 0x7d3466b9, 0xd0ebfa2d, 0x4fc11ab5, 0xa0d4cd17, 0xde82fbdf,
- 0xc6fd173b, 0x790202ce, 0xd6b61d54, 0x1eac3595, 0x2982e779, 0xebfac3ea,
- 0x12486664, 0x33f209c5, 0xcbe79935, 0x616de1c5, 0x1f1cba97, 0xa90c698f,
- 0x3fc4f5cb, 0xc58f2d21, 0xa7df620f, 0x75f93326, 0xc70e5561, 0xe3f307b7,
- 0x6797fcc4, 0x3269bc30, 0xb33733d9, 0x41d02e6a, 0x7397c42e, 0xabfcc9e0,
- 0x7f082674, 0x092e75ee, 0xde0e23e9, 0x80da300e, 0x3c593abe, 0x3f856ff4,
- 0xe4caee1e, 0xbc1fae14, 0xd65f886e, 0x8f18f5db, 0x493f5cbe, 0x0e5ab25d,
- 0xfebf950d, 0x27db2cfd, 0x9e796a75, 0x50e51d8d, 0xe5cd9d9d, 0x11d9e484,
- 0x6a56f786, 0x3a3cc02f, 0x3f6025b5, 0x8ad5bb4c, 0x6fd968f3, 0xf3703f42,
- 0xd02c81b2, 0x03552de3, 0x89b71005, 0x2b402fc7, 0xdb45f90b, 0xfee8b9d5,
- 0xd884ec03, 0x4b5f3c76, 0xfef5671d, 0xf60cb920, 0xbf762739, 0xb76afa01,
- 0xfd15f509, 0xf00603bf, 0x839cbcb3, 0x3687ccf6, 0x0bb41b7f, 0x9e5bc398,
- 0x85bb01cd, 0xfdcd4dd9, 0x0bb01e86, 0xe2623aeb, 0xd59ff07c, 0x591fb8ea,
- 0x3bff44e9, 0x6fbf56e9, 0xddf714d8, 0x17603888, 0xbd3af3ae, 0x3bf0227f,
- 0x7f983bd5, 0x8351b670, 0x5af50379, 0xb79022cf, 0x7b6a4d67, 0xad8dacfc,
- 0x75a196d7, 0xb5bda0f6, 0xf675cc65, 0xd73ac014, 0xb63f886b, 0x6758669f,
- 0x7c4dbeba, 0x78becf9d, 0xf3ac0175, 0x2eafbbc7, 0xa75e7580, 0xdf02f2eb,
- 0x5bfc39b4, 0x27bf6993, 0x3da1f06f, 0x2f58f225, 0x24f71e97, 0x432bfdab,
- 0xff21ffe5, 0x30fa58ca, 0x5a87043c, 0x4af4ba1f, 0x3a83c806, 0xd5bfe1a3,
- 0xaa37f08b, 0x4068cf1f, 0x3ffec77f, 0x0766ba7f, 0x2d7e81c8, 0xbfa223da,
- 0x0f3fb2fd, 0xeffda1ec, 0x69413db8, 0xb91bfeec, 0x246dd85f, 0x88abf041,
- 0x27b0807d, 0x5bf1e5e3, 0x251f3e7c, 0xbb006f7b, 0x8dfacbe6, 0x633bf81b,
- 0xe76653e8, 0xcc3c936e, 0x7e8bdc6f, 0xf37d96e4, 0x3e27e0ed, 0xe37e621d,
- 0xd18b1796, 0x7a18dc6f, 0x65790c2d, 0xc3b25fa4, 0xdb71a3fe, 0x07c804b1,
- 0xba5cfb10, 0x8c933daf, 0xefdea8f4, 0x489d0e9e, 0x0a01fc80, 0x71e82577,
- 0x07aa2b8b, 0xfba16fba, 0x6c23c83d, 0xa187a391, 0xc11716df, 0x3ed2973c,
- 0xc44ffef5, 0xf4fa3779, 0xf6377728, 0xd790214b, 0x4e7f7a29, 0x9235e806,
- 0x2078c761, 0xc98bb3e7, 0xb294d4de, 0xf7baf8d8, 0xe1e4e4f3, 0x0d81b07c,
- 0x03bf4889, 0x83b5e23a, 0xe360db3c, 0xf9464cf2, 0x8e4dc7f6, 0x630fcb10,
- 0x6218ffed, 0xc8a34276, 0x5849930b, 0x68b5eba6, 0x585df7b6, 0xe1f7906f,
- 0x5b1f7938, 0xbbfb7116, 0x52f51849, 0xca181933, 0x176d8b0f, 0x7887d71f,
- 0xd21faab8, 0x1f80ac5a, 0x07ab4eec, 0xb8f881e0, 0xf6c83eba, 0x961f94eb,
- 0xafd30c96, 0xbf410758, 0x1d0fdc2d, 0x08fe3868, 0x4fa06fd0, 0xd77d83b2,
- 0xdbf461e4, 0x905bf744, 0xefcf1b47, 0x379d57a4, 0x97ff163a, 0xd1f5a8a6,
- 0xe4eff950, 0x453ebd5f, 0xfe62f7cd, 0x343f6fc2, 0xf1897ecf, 0xe2bcdc65,
- 0xfef1a9f7, 0xbccfb176, 0x2738795c, 0x870f2d45, 0x79677fca, 0x2eb43758,
- 0x1d50f2f1, 0xe59bf8cf, 0x5c70ffe1, 0x4f7d99e3, 0x03bec027, 0xa7d878ec,
- 0x63aedcac, 0xfd1413f9, 0xe9e2f1b1, 0xc597ab5a, 0x5ea2b54f, 0xa657871d,
- 0xe33c38f3, 0xd45ed7eb, 0xf335bae2, 0x3ef37138, 0x369a079b, 0x9c631758,
- 0xba7e3e36, 0x0e9eec84, 0x471f154b, 0xce7e026d, 0x753c74bb, 0x8f8b0a75,
- 0x20725852, 0x6f3e216f, 0xa7eb35eb, 0x7598fe49, 0x1ba22aaf, 0xdbe85182,
- 0x33890728, 0x14c6fde6, 0xc6bf5766, 0x7adc8bf3, 0xad608e76, 0xfd85e2cd,
- 0xf2c35b8c, 0xf2e07e9f, 0x18bc826d, 0xfaf1c2a3, 0x4344edf2, 0xae8cf2f1,
- 0xb04ae517, 0x3901ead9, 0xa237fc28, 0x5e3c8bff, 0x3ffad971, 0xfcf7de8e,
- 0x3c7bd30f, 0xf18bf67e, 0xddb8d6fe, 0x151b8a7a, 0xe3a4105f, 0xca5f1023,
- 0x63bf4919, 0x1d1633f5, 0x1df14d1f, 0xfe766149, 0xb857cc14, 0x2963394c,
- 0x3f009e8d, 0x5063d911, 0x7e09afc0, 0xab8fd412, 0xaa3e78d3, 0xe6267ca7,
- 0x2573b369, 0x58ce1ce2, 0x4307e476, 0xc8ecc3eb, 0x9f5cc60f, 0xde47672f,
- 0x087df0ee, 0xd2b27674, 0x1e01e78b, 0x61f851b5, 0x619cf87f, 0xe22e73d4,
- 0xfca5c63c, 0xd1c45f2d, 0x4bff17d5, 0x3a92d472, 0x75f95d96, 0x13cfd1cb,
- 0x763a7fc0, 0xff9e413f, 0x45bc4119, 0x6b6449f7, 0x103b5f8c, 0x197bf961,
- 0xfef15e1c, 0xa1bef83f, 0x999bd521, 0xfc7fdf4a, 0x1248d1ae, 0x652e9ea9,
- 0x67c5b172, 0x4b42b8c5, 0x697fcb2f, 0x8e504659, 0xb4df80b7, 0x3389fc08,
- 0x4f7dd809, 0x2013fd3a, 0xf7d1ee8f, 0x226d41ac, 0x1167dbf8, 0xbdcef3b0,
- 0x9c33cacb, 0x6798c9fe, 0xe3006cb7, 0xceb3dd18, 0xf9561e60, 0x523e9f17,
- 0xa2f08a53, 0x5065c13f, 0x3db9679f, 0xf133c995, 0x6f843d9c, 0x3ff3fa2f,
- 0xdaf9606e, 0x0ed79701, 0x0fe1097e, 0x8c1128b7, 0x61ecb42b, 0x96b95bc6,
- 0x30fc87cd, 0x65a9e903, 0xf831654f, 0xa9af494d, 0xf2ddec18, 0xdf715bdf,
- 0xe983f1f7, 0xcfb12798, 0x7c02afe5, 0x37434ad8, 0x4d9a7d81, 0xf7bb01c7,
- 0x1537dde3, 0xfe42dc03, 0x39bf03ad, 0x4d9d7f1d, 0x462717ed, 0x64bf7796,
- 0x33ee2647, 0x5afeac9b, 0x133aff98, 0x9db82383, 0xfee14f9f, 0x17fe78f2,
- 0xd5aa9f7c, 0xdfa938e0, 0x5c9c6235, 0x3a7585c8, 0x0de637e2, 0x9e1293cb,
- 0xf1701867, 0x99fec73c, 0x97854f2c, 0xbe752ead, 0x37c947e7, 0x253c0094,
- 0x8b57f2a9, 0xe4475967, 0xb2a4940b, 0x5cea9678, 0xb322e5a2, 0x7aed73a7,
- 0x4adb27a4, 0x9454e2c2, 0xbfaec09e, 0x06991a36, 0xbbf2bce7, 0x9e02d7c3,
- 0x20d45ff7, 0x4799e49e, 0x28933e30, 0x56f2f1b1, 0x004e740f, 0xadfd8c7f,
- 0x954960eb, 0xa0157b2e, 0xefa749f4, 0xffe45481, 0xaf1842d6, 0x2c745fea,
- 0x059f72bf, 0x59dd0cfd, 0x795f984d, 0xea833dee, 0x33fc4e7c, 0x3e605648,
- 0x6fdf6e65, 0xdb604e31, 0x279a8d23, 0x15aa44fb, 0x1825a6f9, 0x36398e99,
- 0xce50bad7, 0x1f7efbca, 0xee43bb04, 0x91024194, 0x03579d0e, 0xcb82d3e7,
- 0xc7f5fa09, 0xb035db77, 0x3f3cd95e, 0x7fff7066, 0xbee3f14e, 0x4205c445,
- 0x3749bf2c, 0xc7ec08f0, 0xdf03e5e4, 0xec7ac20c, 0xc05a6871, 0xb68baa7f,
- 0x9f65dfa0, 0xd9acfd05, 0xbe2b797d, 0x2bd9cb41, 0x1b0718ed, 0x6ceee57c,
- 0xf3a7e7cc, 0x3cca3f1c, 0xf9654a1f, 0x8b3ef248, 0xfc99f406, 0xa8c0f104,
- 0x0aa523b2, 0x968a7ee1, 0x07df3f69, 0x8e1e4a7a, 0x0a3f829b, 0xaa4354f4,
- 0xcdd0077f, 0xa5a4b9d0, 0x892e7666, 0x2db5a79f, 0x9c176f7d, 0xfdc2d9f7,
- 0x4ff707b9, 0xbffe859e, 0x7582594e, 0xf960e0b8, 0xb2a42f95, 0xfc48e278,
- 0xd63cc41f, 0x65bf7ddc, 0x02e28d7a, 0x8c7597fa, 0x574ee45e, 0x5f19f80f,
- 0xde63f049, 0x611d75ee, 0xeccdc62d, 0xa35c7f27, 0xd677ecc4, 0xb2d33d33,
- 0xe3cfed93, 0xd29737f7, 0x921ebf2f, 0x0cbf4c33, 0x764eff95, 0xf4e2efcb,
- 0x6fbcdfca, 0x5efdea21, 0xbf12fdbc, 0x8f611bbf, 0x9637f5c7, 0x50f2231d,
- 0x61c786aa, 0xd84db4f6, 0x9e554149, 0x9f95954e, 0xfbaa343b, 0x47649f5f,
- 0x3b79107a, 0x72caed29, 0xfe8fdbc8, 0x4edfa088, 0x3c8915e4, 0xcb1560a2,
- 0x8c6a09f7, 0x4dd12e78, 0x687f30ba, 0x124b091c, 0xf006d7fa, 0xe42a6dfc,
- 0x4fefd111, 0xff62e6a4, 0xa567899b, 0x22a6e516, 0xc826fc01, 0xb802493f,
- 0xc1161b43, 0x7159b778, 0x9fe4133c, 0x033ee124, 0xc7dd39f9, 0x35a756f2,
- 0x3a43b8b0, 0x4e50cfd5, 0x697467cf, 0x3cc7ab9a, 0x22579156, 0x5e044ff2,
- 0xd3be38aa, 0x01ca2c27, 0x54f228b9, 0xe53d99d6, 0x39c11760, 0x1cbf3868,
- 0xbcf3346c, 0x776fd613, 0x4f9e2e63, 0x2979b2fe, 0xf91678f1, 0x7f44fa29,
- 0xe46cbba6, 0x37416739, 0x7089eb31, 0xecc7dc6d, 0x3d06aafc, 0x71b063ce,
- 0x072bfa06, 0xec04351b, 0x037eaa81, 0xf1b8c3a3, 0x93d5ce36, 0x872bf430,
- 0x054f204c, 0xceca5c3d, 0x085beba5, 0x6d83e0fe, 0x524ef33b, 0xd6d43fde,
- 0x9341cf8b, 0x12bdabd4, 0x03cea1cf, 0xb48df5c9, 0x1af95afc, 0x6689b7c8,
- 0x6a849449, 0x96faafd3, 0x60c4f54c, 0x287df472, 0x7be1bedf, 0xba3e3cac,
- 0x9beda245, 0xed623ed3, 0xa9d33681, 0xefff5ed8, 0x57eb41b5, 0x267f7fd0,
- 0x351cf9f1, 0xebf464ee, 0x3f41123c, 0xa57fd712, 0xadba3e4c, 0xdc9fb47a,
- 0x54951f3c, 0x8854fcf3, 0x7b72d0f8, 0xefc6315a, 0x13d944ad, 0x030cfa81,
- 0xe30827b3, 0xccf1f687, 0xf4e46d6f, 0xbf843240, 0xf208206a, 0x81c73dae,
- 0xe7c90fdf, 0xf310863d, 0x8ff1b19b, 0x9e0578be, 0xb679124b, 0x6733d884,
- 0x36f9815f, 0x135af2aa, 0xdb29a73f, 0x7bbce133, 0xc1db8ebb, 0xe6c47cbc,
- 0x04f3885f, 0xddf6a4be, 0x507e1bd1, 0x7674fc04, 0x41f30fef, 0xa7a8ddce,
- 0xe45184fb, 0x933a595a, 0xeb3a836b, 0xb77e894a, 0x016fe6c6, 0x32c77c3a,
- 0x311c3a6f, 0xa9549b9a, 0xc1bc0077, 0xd780b4e7, 0x8e274e64, 0x473e0cd9,
- 0x3c824fb5, 0x1b1376d4, 0x7b2fd937, 0x7f845cf1, 0x851b74b6, 0xf2625dbb,
- 0x88947e9b, 0x92a15576, 0x26c87108, 0xcb55ee7e, 0xcb9688e5, 0x1b6e7f91,
- 0xc1a997c8, 0x13ef4d78, 0x7fe7b05a, 0xbfe2e3cb, 0x9f9f51cd, 0xb83371e8,
- 0x569673c5, 0xcfe802b9, 0x523aaba5, 0xab40e94b, 0xfd7084f7, 0x37186d32,
- 0x772b603e, 0xa5efd00f, 0x42951fec, 0xe67b773e, 0xbe214a8f, 0xdc7a75a7,
- 0x8f7298be, 0x357fd19b, 0x59bc03b4, 0xefc14b5a, 0x97f5b5fb, 0xfa2bfb48,
- 0xf50dfdf2, 0x35706063, 0x7059a319, 0x9359fe6e, 0xffac3b7f, 0x30c7f985,
- 0xfa40fc2e, 0xaf21f7d1, 0xd18ea8e3, 0xe793305d, 0x69ee93e3, 0x0eee9409,
- 0x5e7839e7, 0x1ebf8b0a, 0xa8fcc09e, 0xfcb17e54, 0xe61289d1, 0x66ced621,
- 0x266f62e7, 0xfa018e91, 0x68593a3d, 0x1c8af4fd, 0x796b7fb4, 0x77f4c89e,
- 0x7eb0097c, 0xca8f6fd3, 0xb2c7f720, 0xeb746ee7, 0x3e188194, 0x975149be,
- 0x97542e6f, 0x9751e5bf, 0x97f15dbf, 0x9365b109, 0xe8107bd9, 0xdf8955f5,
- 0xb10d7147, 0xa4ba7f23, 0x935dd820, 0xe7e74a5f, 0xe53e5989, 0xf17ef94f,
- 0xf5820aa5, 0x5b8d3b29, 0xfdcf508d, 0x3f5e5aef, 0xd98c4dd9, 0xea07c44e,
- 0xf3c4a8e9, 0x93185d32, 0xb1ef7b22, 0x6d343f33, 0xecfda7ab, 0x1f20af9d,
- 0xe43558a7, 0xa5ebc09b, 0x04c3b446, 0x289bb45f, 0x963c537d, 0x819a338f,
- 0x9e75dbde, 0xd697d0f5, 0x2f40506c, 0xb1182657, 0xc83fed6f, 0x9b96d7a8,
- 0xcb4ec40c, 0x63371f07, 0x3e265cb9, 0x20a123c8, 0x51e786ce, 0x0ad4279d,
- 0x60eda5f3, 0x160eedbe, 0xeb96d757, 0x7ed3cf51, 0x3e0f5d71, 0x9c1109a1,
- 0xf98ca57f, 0xc1661ca6, 0x7c247477, 0x6be734ff, 0x518486ad, 0x7bb3a58e,
- 0xfed10e39, 0xbf83dfa1, 0xdfa0f6d2, 0x13b950ae, 0x271bcfea, 0xc0a8b9e0,
- 0x592f79d0, 0xda15c003, 0x67e87cb9, 0x3f04f2e7, 0xa542f90b, 0x852bbe5e,
- 0xf8149030, 0x053b050f, 0xfb8204ec, 0xccb71100, 0xd97a8a34, 0x0da6fd0b,
- 0xe0e767b5, 0x56997852, 0x60253585, 0x27f1bca7, 0xe4b1c3a0, 0x931a6145,
- 0xe429e213, 0xc3c316c5, 0x19af6a47, 0xef0a3d6d, 0x9b0cf2c7, 0x84c7ad9d,
- 0xad4be00c, 0xe8064279, 0x478776cd, 0x0b94c5f1, 0xae6a76e9, 0xdb45f013,
- 0x35adf2d1, 0x18e5f2c7, 0xc69854fd, 0xe76d00e4, 0x1ef0a24d, 0xc0192934,
- 0xdb8ca3bf, 0x7cb5c6cc, 0xe9bae3bd, 0x41ddb4b8, 0xb6971d1b, 0x843266db,
- 0x8da30935, 0x78c0a15f, 0xa2971a97, 0x833f911d, 0x93a503af, 0x0ec1f820,
- 0xaf4834da, 0xf2be7833, 0x1e3664c1, 0xffe75429, 0xf8e99be4, 0xcea65f98,
- 0xda51b9f7, 0xfa7a01d4, 0x56c25369, 0x3837cfa0, 0xfcb61cdd, 0x69d83e43,
- 0x382bcc6f, 0x71267284, 0xd1100779, 0xf28bd20c, 0x0bc1c846, 0xa1cac769,
- 0x8de1e54c, 0x0fde7469, 0x079d1ee4, 0x3c721f9d, 0xa5f68f9d, 0x56935bd9,
- 0x417e1236, 0xa06e029f, 0x218be053, 0x5f838d3a, 0xa5b91bd0, 0x37251317,
- 0x9e173b53, 0xa425eec2, 0x2bc5e595, 0xa3f3c399, 0xd8dd3e44, 0x18d1e6ca,
- 0x746fb844, 0xe6f318fc, 0xffe718ee, 0xf735c01e, 0xbef04fca, 0x3f9ee222,
- 0x1477f601, 0xc96979de, 0xc6f07bff, 0xca97f9db, 0xcf8b1f0f, 0xacd2f8c5,
- 0x1e1f989d, 0x7cc56d98, 0x3f3c69f1, 0xc1a0d036, 0x0fdd00b8, 0x85a23ee2,
- 0x97204318, 0x5cbb72a7, 0x45785b9c, 0xe0d6fe62, 0x7d45068b, 0xde7c513f,
- 0xe97982b8, 0xbf2c65c1, 0x6f7ec87c, 0x1f7ed056, 0x9cfc73d2, 0x93317744,
- 0x28f7dded, 0xe689fbea, 0x44fdf513, 0x7121ed0b, 0x32948a6f, 0xdddfbf9c,
- 0xbbfe9043, 0x9f58b96d, 0x88fa65ae, 0xa3e9837c, 0xbaa21cee, 0x399d691f,
- 0x94f31134, 0x46c15e78, 0x6ff83fc8, 0x9a7e0bf2, 0xc2fca926, 0xc9afe543,
- 0xf0e6dc2f, 0x5b3a02ef, 0x92cde458, 0xebd63d28, 0xd2987f99, 0x8108a6eb,
- 0x7cd6c574, 0x44dda7d8, 0xe4d2df5a, 0x02febd21, 0xa53275e9, 0xbd153cd7,
- 0x15fc61ee, 0xe82d2144, 0x0b4e8875, 0xfd00f3e3, 0x6edc60fb, 0x5befef47,
- 0x6fd35f60, 0x683cb0f0, 0x2f19d796, 0x59e0621f, 0x5c783320, 0xf3c22d5a,
- 0x0f13f43a, 0x4df0e5cf, 0x12a69d2c, 0xf1631fc6, 0x824caa4f, 0xfe6192b6,
- 0x6ffd9931, 0x7c43b8c1, 0xcfdb08f4, 0x6b5b808e, 0x739a7a45, 0x057f8b07,
- 0x802ecc2c, 0x1d1a5838, 0x7f1f267f, 0xdaafa74e, 0x4a66ed01, 0xfa610f0c,
- 0x167f850f, 0xdfd99faf, 0xb370798c, 0x63c775aa, 0x2f2120ed, 0x2e6ddc45,
- 0x7dab7f6f, 0xd2f20ea6, 0xe3aad767, 0x64ef735d, 0xb339b6f1, 0x25ccfdd5,
- 0x7cc13fab, 0x03aad24d, 0x53bdcdfc, 0xda49ff5d, 0x026c9c50, 0x710ec9c4,
- 0xe520d03f, 0xd7a3e013, 0xba6f1793, 0x84f9d287, 0x8095149f, 0x9486f0df,
- 0xd04f6dc6, 0x271bb3f2, 0x94f5f961, 0x28ff7eef, 0xc0296fd4, 0xe25c3572,
- 0xe056fb04, 0x8567ca43, 0xc8cc77e5, 0xc27d0049, 0xe087bdfb, 0xdfd9b77b,
- 0x73b6933d, 0x3cc5c94f, 0xd7ee6ad6, 0xeac85c18, 0xc6d2be6f, 0x52ef9552,
- 0x6d5c5fd0, 0x1d35f766, 0x04bb7e29, 0x73abaaf2, 0xd5e4b979, 0x243e5049,
- 0x3af7827d, 0xcab66b9c, 0xe92d0eb0, 0xb93ecfcc, 0xa44f0a50, 0xf276a978,
- 0xbcd99bfe, 0x4b9e4b6a, 0xaea93e07, 0xf64cfd62, 0x41e67654, 0x2c79cd3b,
- 0x26374b9f, 0xbf05fe00, 0x957df0e5, 0x5c7d2bb0, 0x3de4bc4e, 0xfb4491d6,
- 0x0f2519f5, 0x7157d14c, 0x664bdd8c, 0x7d03e765, 0xfc191cde, 0x2cbcd3f4,
- 0xb8cab6ef, 0xe1e40d3c, 0x297d7e2d, 0x2c6ecbcc, 0x1179043e, 0x65951589,
- 0x246da798, 0xfe94beb8, 0x3f03a7c7, 0x5649fd5e, 0x559d1002, 0xbe82ff4d,
- 0xafba0a66, 0xe537d356, 0x65e9c9db, 0x2adf9697, 0xd30d36fa, 0x3ef658f7,
- 0xe102ab85, 0xaf5a86fa, 0xc7138d0d, 0x8ee3f19f, 0x2fe03725, 0xc30efe56,
- 0x987c8bd7, 0x798dd901, 0x825da7c0, 0x38026f4f, 0x9e089af4, 0x3c96ca8f,
- 0x7180f093, 0x7a88c785, 0x055f8e2f, 0x33e0997c, 0x1709192f, 0x6ec2c9fc,
- 0xf02e7f65, 0x7af064a3, 0x38979dfa, 0xe3a2e187, 0x7a0e91df, 0xcf0611fc,
- 0xc995a966, 0x112fbe19, 0x311697fe, 0x7cf53edf, 0x1eeccdcb, 0xcbf83703,
- 0x3c527630, 0xcbee0869, 0x9f310758, 0xb3e7d700, 0x9e9b3e8d, 0x4736edce,
- 0xedcfd23d, 0x283aa354, 0xff74c25e, 0xd41e700f, 0x7ec1f704, 0x62f1216f,
- 0x47d29cfc, 0x6ec63d20, 0xe3c6f012, 0xb90c65a9, 0x789f3f1a, 0x5baf0cfc,
- 0xe29e0d24, 0x7cd0e1fc, 0xf19e732f, 0xaf4b8af6, 0xb93a5bf6, 0xec39d17f,
- 0xfa842c4f, 0xa0f6625a, 0xe123d13f, 0xda96af7e, 0x6ba7201f, 0x71fa086b,
- 0xfa0d569c, 0x321d8513, 0xff5c9f16, 0x6ab7264d, 0xf73f089b, 0x4f17e6c8,
- 0xe064a98f, 0x1ad6787e, 0x800b0d95, 0xaaac1bff, 0x56b50673, 0x4e788f16,
- 0x503211c8, 0xa87f7a06, 0x0fef423c, 0x8a1c8194, 0xf6ae7fbf, 0x3b7bf322,
- 0xacf84a2f, 0x032b1cf5, 0x19acefbd, 0x56790328, 0x14fef767, 0x13dc55d6,
- 0xbdcf8f19, 0x97911ae9, 0x1a745972, 0x0e2247cf, 0x7fe6c47a, 0x3fc63d39,
- 0xa08a5675, 0xcbb5759f, 0xcfe7e7ce, 0xd8767a01, 0xefc12a73, 0xaad8db34,
- 0xd138bb03, 0xce903fe1, 0x5f17e8e4, 0x9a17e6c0, 0x56de3c52, 0x66587fed,
- 0xee1e22c3, 0x81b878e5, 0x9bf3d9eb, 0xa90fb8b4, 0x0d3e16f6, 0x9bc0a0a1,
- 0xbe42123a, 0x147ea2f5, 0xa79dc6f7, 0xda185506, 0x7d436f3f, 0xf557f8bb,
- 0xb09b2718, 0x1894435e, 0x6431397d, 0x327fdd56, 0x5553a779, 0x5d37a2be,
- 0xbecafed5, 0x717d555c, 0xfeaa9278, 0x544b37aa, 0x54c8b2e5, 0xdfabfb55,
- 0xaf9552a9, 0x6aa19819, 0x3df403bf, 0x4e37e3c5, 0xffbd52cf, 0x37f4e368,
- 0x5d7d3e21, 0xefaa3bf4, 0x043f704f, 0x85237a09, 0x040bfe74, 0x53ac5ebd,
- 0x9acd4f7d, 0x7c0e54b0, 0xac16fecf, 0x95f77966, 0xfdb16314, 0xdb52ec2d,
- 0x28903713, 0x84b62be6, 0x40984f24, 0xbeba9dde, 0xf107afb1, 0x0f7ba97a,
- 0x6be6b826, 0xc69754c0, 0x22633b51, 0x0d5c8220, 0xf1638379, 0xbfd6a5fb,
- 0xa97fe480, 0xd5b837f5, 0xd4526feb, 0x54296feb, 0xa3cdbfaf, 0x0ac4ff5e,
- 0xbc3bfaf5, 0xaa4ff5ea, 0xb27faf51, 0xa9febd4f, 0x9febd573, 0xffaf57e6,
- 0xbaf506b8, 0xd7aab667, 0x7aa97b3b, 0x4b82735d, 0x74f1f554, 0xc849e820,
- 0xf795bccf, 0xa453dbaa, 0x42e86268, 0x5f02d9d0, 0x8d63e603, 0x35487aef,
- 0x4c7d3c5e, 0xf48f3c20, 0xe547d22b, 0x727f6e38, 0xa97aa0ba, 0xda325c6a,
- 0x73c03719, 0xff6e04ee, 0x33b746fb, 0xd58afc84, 0xe6fbb1eb, 0x08dae4b1,
- 0xd1f7c57d, 0xd82bea63, 0xf7869b47, 0xefd163d1, 0x59ea84bb, 0xfa357c1c,
- 0x33b0eecf, 0x999a0e38, 0x5429ff3d, 0xd1db435d, 0xde141536, 0x743e6177,
- 0x93cd77fc, 0x1df20fd1, 0x7183abd2, 0x7c1124ef, 0x7c5123ce, 0x755d89fa,
- 0xf10165be, 0x645fb9e9, 0xc9a9e009, 0x7a0e5038, 0xa3fcc2ff, 0xee7c63ef,
- 0xdd65d248, 0xe21c7207, 0x3909e33f, 0x49c9e5c5, 0xf2d10388, 0x27f71339,
- 0x8ae2897a, 0xee29e7c1, 0x269bacf7, 0x5a259ea1, 0xd5b1e633, 0x9ea12edd,
- 0xf60ffbaa, 0xf4c71f6c, 0x52e788da, 0x6e2ed781, 0xa13b301f, 0x62dd0e0f,
- 0xadf890fc, 0xec7a8f68, 0x3fb4deb0, 0x47f98716, 0xdbb17f76, 0x25dce0c8,
- 0x89c2b911, 0xdd7106c7, 0x7ce1fd61, 0xe0c8db9b, 0x4623a5db, 0xe264efc0,
- 0x31f0fb47, 0xd63c8a99, 0xefd624ef, 0x17f05cd1, 0x7e6fcd9a, 0xa9f21aab,
- 0xf472e0e5, 0xa88f7fdf, 0xb677f7fd, 0xffbfe84a, 0x3e9b851e, 0x1b8f76dd,
- 0xef28b2f4, 0x1e21b802, 0xfbe8ed00, 0x04ab7754, 0xadafb1fe, 0xb10f3dbf,
- 0xbfb25f76, 0x83087ea1, 0x3d60fe0b, 0x83367f85, 0xd281b7d2, 0x11efb6cb,
- 0xfbc61ff4, 0xa969c76b, 0x31fc8106, 0xc097bb1d, 0xfb67af2d, 0xbb1ec3e2,
- 0x7444cfca, 0x7a47380e, 0xf20e7b29, 0x9cc54fbe, 0x3474a0d3, 0x1fbafdea,
- 0xa47cb065, 0x44c8b6f6, 0xe39e4b88, 0xdb87d771, 0x56b2c4de, 0x265e60f6,
- 0x88e5f7dc, 0xa2ef5ef9, 0x4e7231f5, 0x63efd2b6, 0xeace8de4, 0x1e6bcbc3,
- 0xbc608b69, 0x25efc753, 0x5ee3347b, 0xbfc63fbb, 0x6e38cef2, 0xc4831927,
- 0x69b8429e, 0x4f4eff4f, 0x5a3f4023, 0x762a7cbb, 0xd3706d1f, 0xeef562fe,
- 0x1b1264c5, 0xf6d9587f, 0x88fdc20e, 0x6743f7e4, 0x36127c86, 0x641b7c51,
- 0xdf4d0338, 0xe511b86f, 0xaf76deaf, 0x1aa1ee07, 0xb7067f0b, 0x7e56217c,
- 0xdf8e387e, 0xe7e5c5cf, 0xc9d16d93, 0xdb7b4e30, 0x5d6f0a80, 0xfdf1176d,
- 0xc452369a, 0x7ac43fea, 0xf4828d4d, 0x42d28a73, 0xf27ae204, 0xc1fc0d80,
- 0x10263ed4, 0x8db9d67f, 0xb8306f18, 0xa2e4bc18, 0x9e63e90b, 0x3e00c19d,
- 0x1f4a4cbf, 0xe1d52fef, 0x4cbefafe, 0xefbfb62b, 0x780fe337, 0x29eadf29,
- 0xc37fb41a, 0x61c7867c, 0xf973d3f8, 0x0fbf6449, 0x5d3e80e4, 0xd38538c6,
- 0xf1d70b3e, 0xf027f6cb, 0xcc1137ae, 0x5a67d647, 0x5cb85ed1, 0x6a19dd38,
- 0x8fe3c7bc, 0xffe509e2, 0xf74f1c7d, 0x93fcc83d, 0xf04fddf7, 0x4a59053c,
- 0xe987caff, 0x87971c6a, 0xcf87c4a9, 0x082a36ae, 0x465eb00d, 0xed409fe2,
- 0x8d8bd211, 0x82a7e04d, 0x80ecaf7a, 0xaa2788d4, 0xb9e1335d, 0x1764e2a6,
- 0x6bdae3b0, 0x13c08b3f, 0x2f801162, 0xc109037b, 0xab98bc55, 0xf877c740,
- 0xd7813959, 0xe565cc27, 0xe89f5e44, 0xef4ce563, 0x0035520b, 0xcb471716,
- 0xca6f3ab4, 0x80bc7907, 0xfcf173b0, 0x84cd8d7e, 0x73ab0bcb, 0xdfd43566,
- 0x8b9cf049, 0xaf09ffa8, 0x5f1eb34f, 0x637a0799, 0x0dfbfab6, 0xd6a90f1c,
- 0x30d35de3, 0x17aea6de, 0xeb64acf1, 0xfbf137f9, 0x53fd7522, 0xf59b7bfc,
- 0xd41a647c, 0x7fc7abe7, 0xac5bd79c, 0xca8def2c, 0x037f767e, 0xd78c7faf,
- 0xc61ea09b, 0x5af5642f, 0x6f09df71, 0x18e1c9d7, 0x431e33e2, 0xbf33260c,
- 0x233696f2, 0xbf3c57f2, 0x73f707dd, 0x9bf30d95, 0xf519297d, 0x32fb86de,
- 0x5049dc98, 0x51debc06, 0x77a8a2e4, 0x37cc65da, 0x48f5bad0, 0x972b064f,
- 0x871f9c27, 0xead489e4, 0xe4c64461, 0x9ae8a5f4, 0x9005f012, 0x0ff4596b,
- 0xfbe33ae8, 0x918fe21a, 0x664de973, 0x83e58fe2, 0x39554e05, 0x5574cee5,
- 0x5cecd77b, 0x74b5bd55, 0xcc9eaa92, 0xdc9f2276, 0x5ccbe9cb, 0x17aaa254,
- 0x6d9065f7, 0xb59d9dbc, 0x554fe5d3, 0xa85f3bb5, 0x9f8d0224, 0xa3dc49ba,
- 0x7c8231e6, 0x9b96d7b8, 0xb3f8fc0a, 0x4e440ab6, 0xf627e53b, 0x1ba7f3b4,
- 0x54fa598c, 0xcb10b978, 0x7e583bcf, 0x879b7b7f, 0x9e087395, 0xab6f6faf,
- 0xca2ef2c1, 0x69fcf09f, 0xdb9f179b, 0xcfa15969, 0x2bfda47f, 0xda1e9fb4,
- 0xa19f943f, 0x3373c3fd, 0x3f9e1fed, 0xfd43fda1, 0x942fda06, 0xc170a69f,
- 0x0fda29f3, 0xed31ffbc, 0xb44fca1f, 0xb6bcb0f9, 0x1f962e6d, 0xf3e3f36f,
- 0x7c06b6b1, 0x8ad6d9df, 0x96db47e5, 0xb6e1f3e2, 0xdbdb3e20, 0x2f7d6256,
- 0xf9e793a7, 0x2be7dc79, 0xf103bdd9, 0x219fdfeb, 0x9d2fbb61, 0x154a539f,
- 0x3f2ab97a, 0xfc033fa7, 0xfceabd02, 0xc21fc054, 0x8c786261, 0x0668e387,
- 0x91270fb3, 0x930b72c8, 0x1f07181f, 0x6159e7df, 0xae35fca1, 0x4e7bad95,
- 0xd3eb145f, 0x4778d81a, 0x5c409db9, 0xce519241, 0xbb439b8e, 0xcaa45273,
- 0xd007f2c2, 0x14dc430f, 0x5aece53f, 0x21e64672, 0x5725c00d, 0x331e3d50,
- 0x397c21af, 0xb7809c18, 0x57fde0d1, 0x696d378e, 0xa75fbb2f, 0x6c0c2ba6,
- 0xe2b6f666, 0xb9c63afd, 0x9f4cb0be, 0xef1f9f2e, 0x717498e9, 0x5224dd3a,
- 0x9bf176f9, 0x8ccfa144, 0x31fef526, 0x6a89417d, 0xb8bda67f, 0xd1572886,
- 0xfbd48b7e, 0xbdfe733c, 0x198cefaa, 0xf5eaa90f, 0xfaaa15ae, 0x1e73bbba,
- 0xc73e0371, 0x6199b8b1, 0x210272f5, 0x4fdd85e4, 0x4ce65c20, 0x92738f36,
- 0x605f7ec2, 0x133dff37, 0xd6797fbe, 0x5c65f1ce, 0x09f2fb8d, 0x482c560e,
- 0x0f406a0c, 0x448bfc7d, 0x9e3b7f94, 0x7e9fa0d1, 0x40690922, 0xe6a64cde,
- 0x015fd424, 0xf16b8c37, 0x942d26aa, 0x85a2898b, 0x8a2455f2, 0x7fba3afb,
- 0xf5d264d1, 0x9ffad16b, 0xd9f2d131, 0x2cb3ff4c, 0xfa8c30bf, 0x67af80ba,
- 0xadc7d881, 0xdcfde397, 0x37f44cc6, 0x7625cfa9, 0x874bfdf0, 0x970df989,
- 0xc153ca3b, 0x46373e0e, 0x7dcda83e, 0x14058de2, 0x63b4b6df, 0x1fef14f8,
- 0x9ea33457, 0x94cbcfd7, 0xf75e5abe, 0xd44faa7a, 0xf307937c, 0xcffa5b38,
- 0x6b76e029, 0xff228fc9, 0x3c84e874, 0x9e411253, 0x893d970d, 0x3b1e6624,
- 0x93c9deda, 0x11fa2151, 0x375f326f, 0x4ff95f31, 0x4bc87695, 0xd179e02c,
- 0xf2d2db3b, 0x7f0fc7ab, 0x5074e3ef, 0xa0352248, 0x348b0b5f, 0xe074109e,
- 0x31fcabb5, 0x2f2efca6, 0x4b930b9c, 0xf2c40788, 0xf785d244, 0xd57fc829,
- 0x7c9a3e62, 0x50a21af0, 0x0d6ad8fb, 0x70d16093, 0x75fb84bf, 0xfce5cfbe,
- 0x9c6af667, 0xec259c8f, 0x74e80f26, 0x1bd599f2, 0xacfc3a01, 0xf4d8c75b,
- 0xd0bebab8, 0x2def504a, 0x1487d42a, 0xebcbee09, 0xe5407bc2, 0xc8c9122d,
- 0xb9a63801, 0xdf7e83e7, 0xb63a416b, 0x9fc72fac, 0xe359b830, 0x0efc40af,
- 0xc2357b28, 0x9aeda2e8, 0x82b7eb27, 0xf001393d, 0xdcbc0562, 0x430d5f91,
- 0x1e2217e7, 0x2f79f217, 0xc8e8f3e4, 0x833fc21c, 0x70bc7887, 0x6ea2ef1f,
- 0xcf528fe1, 0xaad2f1f3, 0xa2bdc36f, 0xff2d11ed, 0x3e352299, 0x5322e957,
- 0x70c34be6, 0x66173851, 0xb8015c82, 0xd80f82af, 0x919f9afc, 0x941cc6c8,
- 0x6f68356b, 0x3f306994, 0x9b2e9e3d, 0x8fdc9932, 0x7dd9d866, 0x4853eee4,
- 0x93e5c3cf, 0xc2482c6f, 0x5bb333fd, 0x8fcb326c, 0x58957af4, 0xe12af7bf,
- 0x72e7e45f, 0xa1de1ccc, 0xb127057b, 0x892b60bc, 0xb4bc87ac, 0x2bf5f6b1,
- 0xdc707332, 0xb53d7de1, 0xa53f205d, 0x5c7988cc, 0xa13e44ab, 0x69995472,
- 0x57384f63, 0xfa74e465, 0xf79d4da8, 0x6fcf9db3, 0x418f5f3b, 0xf27bc8a3,
- 0x9cc716d6, 0xafeba9f3, 0x88963f47, 0xff720ed3, 0x1d59a0e1, 0xa4e46d57,
- 0xaba87830, 0xc1f10cca, 0x6da7162e, 0xdd99bfec, 0xc7efbb6b, 0xed302f78,
- 0xa87a0153, 0x57ebede7, 0x0b58fdaa, 0x5f91fa77, 0xf164fde3, 0x398a317e,
- 0xe31fec3d, 0x335b62fd, 0x43c27ef9, 0x7b0e218a, 0x61de7562, 0x7277ec33,
- 0x1f0f9e08, 0xef017da7, 0x81bba6dd, 0x974fb82e, 0xa3fbb114, 0x54ffd7e2,
- 0xb2f11e96, 0x78efac53, 0x3ba5da2b, 0xd81c98cb, 0x2dfce079, 0x2b3f69e3,
- 0xf9d52473, 0x3a399580, 0x29b7a75c, 0x97b3c37d, 0xeed19a90, 0xa9943b29,
- 0xef726af9, 0xc1eff55a, 0x1c0df734, 0xff2828b6, 0x1fba035e, 0x4279fc3c,
- 0x1451f211, 0x08c4bf7f, 0xc19930c2, 0x76b3e70d, 0x17993e6b, 0x676f0f4b,
- 0x36ff58ca, 0x0d2f8ba7, 0xae1ab557, 0xa56f45b3, 0xfd7060cc, 0xb9c6e40e,
- 0x5894f1f0, 0xb5c0467b, 0x03df8c7b, 0xe2abf0f8, 0x1fad42a9, 0xfa74f062,
- 0x6ed3c3bf, 0xfcf0e8fd, 0xb3f3c395, 0x9b5eec43, 0x515ff591, 0xe1ab759f,
- 0x647cfb3d, 0x0a49880e, 0x7f115fef, 0x182993ee, 0xebf8e613, 0x59f4e52d,
- 0x078fe5ca, 0xc09150cf, 0x1e63577b, 0x924caf66, 0xbe5ca16a, 0x2cf77f00,
- 0x02c3ef93, 0xbf9e3f1a, 0x4619ef21, 0x64d77f95, 0x9ddeba31, 0x878a8d2e,
- 0xcf362cd2, 0xb2ea4703, 0xd8f1bfc1, 0x7202063b, 0xbfcf3361, 0x6bdecc7e,
- 0x05a67b84, 0x425ca11e, 0x747d019f, 0xc7bc2811, 0x2a333f4a, 0xd3c651d6,
- 0xc6d6f1b0, 0x4f188df1, 0x1564a73c, 0x3a557b32, 0x387385a4, 0x0b7daf6b,
- 0x5b5b7fef, 0xfdeca32a, 0x1d5ff8d2, 0x5bf0ff87, 0x7a30b729, 0xe1459299,
- 0x90fe916b, 0x0e5a6df0, 0x2a7fd148, 0xbd157c82, 0xa01fe71f, 0x4691ec78,
- 0x8b2d29e2, 0x9f988bd1, 0xdb80bf98, 0x5c02dd76, 0x06bbdb07, 0xbca51a54,
- 0x8917d0bd, 0xbcc1ff5c, 0x2b5c5f50, 0x654c73b3, 0xdafbae32, 0xee78a98a,
- 0x17cf376c, 0x1fa35e89, 0x164477f5, 0x763dbc70, 0xb811b7f1, 0xafd83947,
- 0x883ffbc3, 0x15bee03c, 0x8dff1fee, 0x5389f78c, 0xfb81aa7a, 0x391c0ecc,
- 0xebfb009f, 0x843a59f9, 0x87973e7b, 0x35b51783, 0xc8ec1e78, 0x0c6d7667,
- 0x6965d7fd, 0x89127db9, 0x35af39c0, 0x8b3cec25, 0xd603db95, 0x001b2723,
- 0x43c56b7e, 0xde862906, 0x10196566, 0x68fa35ae, 0x17f6878a, 0x6125a7d8,
- 0x7bc1ffe6, 0xb3ce8719, 0x5a1e19da, 0xbda10f4a, 0xf767ed60, 0x2965d635,
- 0xb852ce4c, 0xe6f7d2f7, 0xebd99f89, 0x8e94bea1, 0xbdfc3b97, 0xd3d6cecd,
- 0x4beec65c, 0x3fed7b5a, 0xc83ee1db, 0x471df844, 0x79f2efd8, 0x7292b80a,
- 0x48dfbc35, 0xcbf81724, 0x5abe632e, 0x235ef86f, 0x2f82fbd8, 0x62d5cade,
- 0x39f947bb, 0x0a2b4789, 0x4cae7043, 0xdb35b1d0, 0xcc1640ff, 0x0bc5f28f,
- 0x7c44ef68, 0xf63f10d3, 0xdf33c862, 0x32e64525, 0x076f443b, 0x68d42c3e,
- 0xe116fc54, 0x549e26eb, 0x73dda3fd, 0xa15da73f, 0x46423bf7, 0xfe4de702,
- 0x22667178, 0x191da7d8, 0x1af3dec2, 0x259b5f01, 0x8c0e625f, 0xdc5a2ff3,
- 0x72381e0f, 0xedc601bc, 0xbe02f3a0, 0xeb75f87d, 0x3a53b06a, 0x53e45eec,
- 0xd0ecbe31, 0xfd60f5f0, 0xdf7bd6ec, 0xd4647f04, 0x3acdeec1, 0x11867538,
- 0xd3b69fe8, 0xa07f3f40, 0x04f0f7fb, 0xfd1aa7e8, 0xb3ed0b06, 0x8b77c3a6,
- 0xb011ff88, 0x6b75176f, 0x3c83f755, 0xc2c5e5cc, 0x8e12168b, 0xac2c2fd9,
- 0x6b9e0ef8, 0x0131785c, 0xcfcc3fdf, 0xcfcc3fed, 0xf8e2edbd, 0x5f3f9978,
- 0xfb8afacf, 0xde9c4f6f, 0x8eddfe4a, 0xbbf7c63a, 0xa59afd60, 0xfaa83d01,
- 0xc73f5335, 0x687f64f3, 0x21b093b3, 0xf311de06, 0x98e1224c, 0x5dda8771,
- 0x52709134, 0xfa32faec, 0x15af9e1d, 0xe6d0ffeb, 0xdd8e3c46, 0x1e1538ff,
- 0x53cffb87, 0xff6471e1, 0x87ff5805, 0xf44bc2b6, 0xfe8c793f, 0x0ff05473,
- 0xef8f9bf7, 0x7bac1dcf, 0xeef942d6, 0xc6c57860, 0xf7e14b57, 0x7bf80cf7,
- 0xb7afa41b, 0xeeb9cf0a, 0xfa0e7822, 0x7a7ffd81, 0x1f52f21f, 0xc0f7aad8,
- 0xe8ba8318, 0x7a28cf3c, 0x83d89f26, 0x789cef70, 0x87959dbe, 0xdeff1ceb,
- 0x90ec8728, 0x942c6a67, 0x8ce7a0ed, 0x015a1224, 0x235297fb, 0xdf1139ca,
- 0x34fefd12, 0xb392ab53, 0x46a17ee2, 0x68d87f9e, 0x26aff161, 0xac2cffab,
- 0x574d12ff, 0x1f68cfcb, 0xf03b0ba7, 0x0e213b7c, 0xf888d7dc, 0xc5fb0c8e,
- 0xf97d703c, 0x9b0b9c08, 0x0cffe397, 0x1509fbbe, 0xd1ef102b, 0x0fcdb15e,
- 0xf38f79f9, 0xa6e3e47d, 0x2313db88, 0xf2d9753f, 0xba1bb357, 0xecb7e8e2,
- 0x8cc23b77, 0x40d9757e, 0xcfc8dabf, 0x7ce072eb, 0x67bf00e3, 0xb9fb414e,
- 0xde30f4ae, 0xfc275947, 0xf3e32b02, 0x601d3256, 0x54788b4f, 0x8217e402,
- 0xdd86b0dd, 0x616f5853, 0x275ffae5, 0xba17b9e1, 0x8114b21f, 0x65add99c,
- 0x071e22fe, 0x1e61cf3b, 0x02c9ae34, 0x7cf20efc, 0xaffdf397, 0xe7a7bde1,
- 0x3a478e57, 0x0fe5ffa8, 0xddc31ef1, 0x0d9f4ce9, 0x3ea1b3ee, 0xca7837ab,
- 0xddcd5ee1, 0xed6ecce9, 0x2509c395, 0xa3ec7631, 0xa7285519, 0x5e395e3f,
- 0x19271b13, 0xc2e4cd9f, 0x94ffe11a, 0xce70e5a3, 0xf0d2e3ea, 0xdd3ea13f,
- 0x1bdfc263, 0x53fdecd3, 0xbabfde39, 0x63bf80c6, 0xe277b551, 0x5fb0b9ba,
- 0x1f31904c, 0x84d7b35b, 0xc55d9cf0, 0x6f8383ee, 0xef35ee41, 0xcbbf871d,
- 0x62896f56, 0xd9b364de, 0xc1f10053, 0xc0dfbdfa, 0xf1389fdf, 0x902cc4f8,
- 0x9593c783, 0xfb6fbc2c, 0x3a748a71, 0x26fbe3ef, 0x579df7b0, 0xdb6ab9e3,
- 0x347f8b1a, 0x4bd088ff, 0xedcdf7f1, 0xd73e2f4e, 0x6899f807, 0x5e1c80f4,
- 0x675fe438, 0xbfd607f7, 0x24a59d19, 0xf306ffa0, 0xa7edea17, 0xeb1df7f0,
- 0x49dd8fbb, 0x42e93e30, 0xbcfb15fa, 0xb9eb71f8, 0x8faddafe, 0xd5df83ce,
- 0xf8e76fab, 0x59f7bfe7, 0xdfc629af, 0x5ff8149b, 0xf31f7713, 0xc5de38f7,
- 0x1911c4f3, 0x76a4b9ef, 0x8ff81645, 0x2037ec4e, 0x33589dbd, 0x1057ef19,
- 0x5853d5e3, 0x8f4f94ed, 0xb029953b, 0x15b20bbe, 0xb676ff36, 0xe9ef157f,
- 0xbdf811f8, 0x2d3ee8ce, 0xda0dafe6, 0xc71009a3, 0x7944ed14, 0x5afd3e68,
- 0xddb7bdfc, 0xdd7007e9, 0xa0115d29, 0x6d2fcd2b, 0xbf03b7a8, 0xf71bbf64,
- 0x82092971, 0x8ef8349f, 0x077bf701, 0x9ed019f7, 0x9d977c1e, 0xef711fcf,
- 0x059a359f, 0x7e06dcf7, 0xdae50e39, 0x0b746660, 0x784dbfb3, 0x51e0e4cf,
- 0x5e3cd5ff, 0xd1efc69c, 0xefbb034c, 0x18533ec2, 0xc4fa3eec, 0x6c9043b8,
- 0xfdfbe373, 0x882fbc16, 0x24f9d93e, 0x7f1b8f69, 0xf1748937, 0xfdf823ef,
- 0x09fe5903, 0xc81fa720, 0xe15bfda3, 0xeed893fb, 0x4affae42, 0x9211598c,
- 0xc74bc7ce, 0xd9fd337e, 0xccfa5ef8, 0xa80f7ecd, 0xb047d78b, 0x5ff0603e,
- 0xbdf8f38d, 0x328cf48d, 0x5f7aafcf, 0x49d97de4, 0x6e028eb8, 0x23b4678a,
- 0x93d2f1e3, 0x029ff6cd, 0x3974f11f, 0x80979eb4, 0x7832fc0f, 0xb63ec0bf,
- 0xea26ab8e, 0x9ce93c99, 0xde32f68c, 0x27931430, 0x07df7cb8, 0x3a839748,
- 0x97a0d3ef, 0x847547a2, 0x2d48c3dd, 0x5457f003, 0x16f576b0, 0x7010f7e6,
- 0x07e7e19c, 0x1e593b1a, 0x3ee799e1, 0x856f9ac8, 0xa81ff3f3, 0xff0bcfce,
- 0x0124ed21, 0x8f5633fc, 0xc4575092, 0xc22d76ec, 0x6e8f7ec5, 0xdfc14e8d,
- 0x3e3e0c0b, 0x2712fd11, 0xbc5ecaf4, 0x15d57607, 0x6d27a01a, 0x4fbf9731,
- 0xfb8979b0, 0x6d3dc4dd, 0xc81978f1, 0x99b2fa66, 0x3b82eff8, 0x25138ffe,
- 0xf14b0785, 0xff744abe, 0x52cd206b, 0x7e589af6, 0x9185ea3b, 0x2fea42f7,
- 0xff827bf1, 0xb053e5bb, 0x9f806556, 0xd5e80260, 0x7fb676d3, 0x40225bc4,
- 0x3cd96bbf, 0xb803e03b, 0x4ef882ff, 0x5bc45e83, 0x4e1e2825, 0x9e3eac4b,
- 0x1bbc84ce, 0x1ba00f81, 0xa3be17e8, 0x9d9e7f7d, 0x763ff6c3, 0x17943f27,
- 0xaa5e43d4, 0x490157d0, 0x0f7dc0d6, 0x024a1d27, 0xcec9e5d0, 0xc872e73c,
- 0x292871f7, 0xe076f6b1, 0x0e7bc110, 0x73ff3814, 0x922efc35, 0x05f80a77,
- 0xfed53b77, 0x5e787888, 0xfd401ca8, 0xc6985ff3, 0x800053c5, 0x00008000,
- 0x00088b1f, 0x00000000, 0x7db5ff00, 0xd554780b, 0x733effb5, 0x79332666,
- 0x84841e4e, 0xe4249840, 0x09308401, 0x0741410f, 0x68151048, 0x85280978,
- 0x42100793, 0x17b6881e, 0x240cdb5b, 0x41b45a20, 0x768bd151, 0xb4544140,
- 0x03414141, 0x58a50077, 0x56d56351, 0x880dcb6d, 0xa8311fbc, 0xadadff97,
- 0xfb5bf5ff, 0x90ce649c, 0xf9b7b5a8, 0x67d9d83e, 0x7b5ad7bf, 0x3bdaf5ed,
- 0x3f437cdf, 0x756109d7, 0x10f4422b, 0x116dce22, 0xa3109862, 0x42f382dc,
- 0x11c885d8, 0xca8df3fc, 0x5c3adb89, 0x8df88588, 0xdaf9aaaa, 0x2bc89eb5,
- 0x1f5c2deb, 0x774675e3, 0xb5f1bdf1, 0x28f250ff, 0x084c21b3, 0x5d3dfe87,
- 0x1e310f88, 0x90ea7b8d, 0x460ca7dd, 0x09ac2e1a, 0x75ac5442, 0xa51a45fa,
- 0xbacc4e6f, 0x4285e653, 0x5c6cc775, 0xe34ad899, 0xca2a6f96, 0x1fb29112,
- 0xd0aaf341, 0xea9e55e7, 0x0a8752cd, 0xeaa8f6d1, 0xebf684da, 0x6a8f9e55,
- 0xa51eb8f3, 0xdbd627ef, 0x9fa9cb5c, 0x273e7d0a, 0xc5d16b7a, 0x0ab794b9,
- 0xf280bdab, 0x45da2d56, 0x54782efd, 0xb177f62d, 0x81f7aa3e, 0xf80ba0b5,
- 0x3a894d60, 0x1ea8327c, 0xe39469d6, 0x7268f7bf, 0xc2fcd157, 0x63cc77e9,
- 0xd1f7e2a3, 0xd1f44efc, 0xfc7f21e6, 0x82b13093, 0x45daeaf2, 0x2bdceed1,
- 0xa1c27de1, 0x01727b45, 0x031eb95f, 0x18e3a19e, 0x7808bcf0, 0xbabd20c6,
- 0xabf04bc5, 0xa0f5487d, 0x4be6bece, 0x98df80d1, 0xae47453d, 0x61b5f7c1,
- 0xecda8c22, 0xcefe9c3b, 0x8b8f34ad, 0x3d4155ab, 0x193dd28a, 0xdbc68289,
- 0x2e7cf96e, 0x4dbf73e0, 0xd2917acc, 0x47a7b7d2, 0x46fd285b, 0x21f51fa7,
- 0x6a352709, 0xae7cf47a, 0x98b93edf, 0x9edcc7f2, 0x7aa082c4, 0x2ce9d63f,
- 0x6b655f14, 0x718d16ff, 0x78d8d62a, 0x2e5e065d, 0xbf341d62, 0xfe118d8b,
- 0x8b9704e5, 0x5fb8dbbd, 0xbf464f03, 0x4183c015, 0xa56f544f, 0xe38fa5db,
- 0x114717b3, 0xe1b4d35c, 0x64e82e9e, 0x2e3483c1, 0xe51f5bfa, 0xff7de675,
- 0x74780d71, 0x25969be0, 0x8f03fc0c, 0xbc6da44f, 0xde59be97, 0x93d10ab3,
- 0x7d78d0e0, 0xcbdf42aa, 0x850984f6, 0xda532bfa, 0x9c09288e, 0xac14fb77,
- 0x8c3cf17f, 0x9871f657, 0xf7c7e505, 0xf3c79f5e, 0xc12bc10a, 0x7a2bb529,
- 0x96d698bf, 0xdf8209ea, 0x736d3ec5, 0x7d06be79, 0xe79bce74, 0x4c37bb51,
- 0x4c5c5f60, 0x76467c23, 0xf801b1c2, 0x5df5c619, 0x6f6fa676, 0xb1d7e01e,
- 0x7ac8575e, 0xfdeb215d, 0x0b7d3040, 0x29ebc68f, 0x82cc24ff, 0xdc0fe5ef,
- 0x71a6e594, 0x8e3bdf8e, 0xce3c75d7, 0x75fd879b, 0xcffa953c, 0xe59d72bd,
- 0x733ad00f, 0x8d9d65bf, 0xb757c64e, 0x7b6b8ceb, 0x3acb7c42, 0x6874ea37,
- 0xab33f3ac, 0xfa8ada3b, 0x9cb155bb, 0x14fb6a8a, 0xcc8d7fdf, 0xd0d056bb,
- 0x0f4936b5, 0xfc236bb5, 0x6685d7c0, 0x6e7f04db, 0xf1a01f27, 0x583d27be,
- 0x8f8e1e98, 0x023c3f75, 0xea9f75f4, 0x9701b9f2, 0x9cfcef21, 0x57efc7f2,
- 0xb1f9025d, 0x0fc47e12, 0xc70fe02c, 0x73278b53, 0xb5cdaf7e, 0xb4f9fa82,
- 0x047f6ff1, 0x63dc5cfd, 0x5f5e0b73, 0x90b3fdf1, 0xaf82f9a7, 0xc66e5c11,
- 0xebce54b8, 0xd619ef57, 0xe8f17288, 0xbba65760, 0x0214be0b, 0xaa358ae7,
- 0x01d21f69, 0x3ed5e3c1, 0x3ac6e290, 0x8713380c, 0xa83a9acd, 0x4fc81e13,
- 0x9709d41f, 0x9ad0bb5a, 0xfb12fbf8, 0xfc414194, 0x9749f00c, 0x3cff44e7,
- 0xa2d2c7c9, 0xc873f683, 0x8ff942fc, 0xff48cf51, 0xcc57c1d2, 0x705178fc,
- 0x1950e09e, 0xc21c5f92, 0xca42aa37, 0xb7ca43ab, 0xf99cfaf7, 0x13f8e840,
- 0x31bee4d3, 0xc3aa58e0, 0x9145bb71, 0xc53ee47c, 0x2d7e89bf, 0x4bedbab5,
- 0x8e2ffe69, 0x4fd0f311, 0xae385599, 0xced97de5, 0x8ab52beb, 0x7c02b086,
- 0x633d70f7, 0x435fd4dd, 0xc3e51c58, 0x7aa21f25, 0x7941ec13, 0xf31adf83,
- 0xf0934f09, 0x5bc5d230, 0x83c78d9d, 0x14dd59e0, 0xeed7ca6b, 0xee3c6e4a,
- 0xc62fcce8, 0x6ff4c92f, 0x387ead22, 0xaa7f22e0, 0x8c1eb577, 0xb249fa20,
- 0xd469e168, 0xff83c5ef, 0x66eb9d1b, 0x262f0fbc, 0xe9a816fc, 0xf5a61d2f,
- 0x3d56edb6, 0x9befd09b, 0x5f11fcf2, 0x1b787a5f, 0x9bd9af7d, 0x7775ee21,
- 0x8e143fae, 0x8a5d7717, 0x17efa74e, 0x05c3d90e, 0xcda501c9, 0xd1ed63f1,
- 0x84babfbc, 0xbb875bbb, 0x6b05dfd1, 0xa094f46b, 0x6b44177a, 0x7a20d4f4,
- 0xa975dd29, 0xfc31e44e, 0x1f106a7c, 0x8f4f74ff, 0x2f7d2ab1, 0xb1af7dfb,
- 0xe9c74a16, 0x736fdefd, 0xe686b93f, 0xe61ddbed, 0xbef34cd9, 0x0b2ce6f0,
- 0xb3785fda, 0xea7f4f42, 0x4fb3f4e5, 0xb47e3153, 0x31bbd245, 0x293488de,
- 0x8e59954f, 0xfc1a313e, 0x699ed5ff, 0xe59d69f5, 0x2c829665, 0xad9b79e0,
- 0x7de62e6d, 0x95ab1141, 0xc67eceb8, 0xfdb9b9a5, 0x9f27dd85, 0xf4f87f00,
- 0x60053efe, 0x6776172b, 0x7e5469e7, 0x5921e3e1, 0xc2f7ea2e, 0xf01ec97d,
- 0xf7366d85, 0xeede994f, 0xdf60f289, 0x9c61fd1b, 0xf77fe825, 0xa435c355,
- 0x52f9cb1f, 0xe3934f3e, 0xce8294fa, 0xee2da37e, 0xbf028f5f, 0xb3cdbdf8,
- 0x7fa59299, 0x8b19e8cf, 0x773f61f5, 0xd5b28781, 0xe26dc261, 0xde782b27,
- 0x8763c2a5, 0x1172841c, 0xa2e55f44, 0x6fcfbf98, 0x405f7f34, 0x17df027c,
- 0xaf7f37ae, 0x5aab8d10, 0xfc8b7d69, 0xf682efe6, 0xfb112f8f, 0xe269f8da,
- 0xd6f17ef3, 0xf54cc26f, 0x0fe74f84, 0xa5c7e60e, 0xc7c11fb4, 0xfefc579e,
- 0x3defc015, 0x7433af2a, 0xd2d3cb5d, 0x448f1d78, 0x6b6e63fc, 0x598f5e10,
- 0xe0893584, 0x1c2ecc7a, 0x47e80549, 0xbeab9c08, 0xcdfe613d, 0xfedee4d4,
- 0x3296a55f, 0xe0b24bdf, 0x05c3b83c, 0xedfd47ce, 0x7e8a9939, 0x791756ca,
- 0x77e6835b, 0xe47de6d1, 0xdf5790e7, 0xf54d7e23, 0x37f58d8e, 0x1d79a58e,
- 0xd4f557bb, 0x33af3177, 0xe3f99f24, 0x28f71e09, 0xf2843fc2, 0x2d4c9ccf,
- 0xde9cbc21, 0x34b5327c, 0x3115fe98, 0x8d1e982b, 0xebc26694, 0xf489ac82,
- 0xeb05ad18, 0x89d7ad09, 0x0d7cf35f, 0xb1553a78, 0x787a2ba4, 0xe54f7414,
- 0x05577f39, 0x3d9acee4, 0x33e83f36, 0x0f17e362, 0x6cfa0adf, 0xda40b9b6,
- 0x2f547bb5, 0x5bb174e4, 0x1ce267f5, 0xba34fe6b, 0xeecce712, 0x68352e21,
- 0x170e74dd, 0xb0b97ce3, 0x596252eb, 0x1933f72e, 0x9eed44f2, 0xdfa03c87,
- 0x5cf1e6ee, 0xf1affa9a, 0xff99af3f, 0x20fdcf9d, 0x81f046f1, 0xc0b2278d,
- 0x3e0f89df, 0x99fd8697, 0x791db5f5, 0x83875a21, 0x2c7e68fe, 0x7ff45fbf,
- 0xa3a5f2c5, 0xbbfaf559, 0x349ec3c0, 0x07ffc33b, 0xcd026fcf, 0x7e73b12f,
- 0xe03d9f34, 0x6b3cc6cb, 0x9c766ddc, 0xd11d17b3, 0xb4a7e079, 0x89f989a0,
- 0x06e4f9fa, 0x289b2d7f, 0xee16bf88, 0x09c2bf9e, 0xf151a179, 0x6f280f40,
- 0x2adcf956, 0xddfaa0df, 0xecc29784, 0x213bf6bb, 0xe5443e9f, 0x3abc74d4,
- 0xa8b38fea, 0x54fbc2fe, 0xf8dbefce, 0x80da3fd3, 0x11360dd7, 0x47863c06,
- 0x63c7d26f, 0x3e916879, 0x37cd45bf, 0xb7a0569d, 0x013d51ec, 0xe51cdfb4,
- 0xd5b2f7c1, 0xf4c163b6, 0x50bf1f35, 0x2bd7f37f, 0xf81a40fe, 0xc2fcb984,
- 0x27ce9f30, 0x5c6fbe42, 0x027f7535, 0x89eb2b52, 0x72e6fc8b, 0xf34ebcfc,
- 0xdf7fd5a9, 0x17a6b99a, 0x29c173f0, 0xabf60b44, 0x1df595b5, 0x054d6811,
- 0xfeec2f1e, 0xac78152c, 0xb27ff57d, 0xebf81744, 0x51cd4fd8, 0x84222709,
- 0xc6e74b38, 0xfdd01637, 0x5dc5c9a5, 0x8fb17fd4, 0x6d5b17dc, 0x63905ebe,
- 0x8afc6ff7, 0xddc5c1f9, 0x17575f5a, 0x5fb9dbf4, 0x124b4e7d, 0x205380d2,
- 0xbae4da1d, 0xe484fb11, 0x1f417bc1, 0xdd4d569b, 0x6be77944, 0xa2424836,
- 0xf7923336, 0xfcc7f60b, 0x7d8d7ea0, 0x017c15b2, 0x1fc930e9, 0xe523ec5e,
- 0xbcbad584, 0xfb5f75b0, 0xe62ecce4, 0x26cd3ab3, 0x923edbcf, 0x2b4dcc6f,
- 0x9c874f0e, 0x0345f161, 0x75ebc21f, 0x157c1027, 0x97eabe9d, 0x3df0512d,
- 0xda723449, 0xfa71345b, 0x245a10b8, 0x0b8f0bea, 0x4fa21670, 0x7bc7e02c,
- 0x31abd79e, 0x8e89fcdf, 0xd06af03b, 0xf8562f83, 0xeaefd337, 0x63508746,
- 0x46b5ed20, 0xa0d451a3, 0x4beebfa9, 0x540fb6e5, 0x3ed49fd6, 0x2e3d3e06,
- 0xc8cbf7e0, 0xf8c131e9, 0x74b877db, 0xdeabfa02, 0xf52e7a49, 0x4d877e77,
- 0x5957a004, 0x3d50bf69, 0xec2fe1db, 0xcd4be069, 0x5cbc808a, 0xaf7c794b,
- 0xfaf5651d, 0x9792e083, 0x9a91e12e, 0xbb70c59e, 0x9a1ef560, 0x9573fa08,
- 0xdbd721da, 0xc04f970e, 0x2a4b6379, 0xfb5e63b5, 0xa4758f0e, 0x56b16f01,
- 0x9aab37de, 0x5c5b718d, 0xf62a3fe8, 0x436f9e03, 0x534445ae, 0xc28f86bb,
- 0x874c0cfc, 0x3a6143e4, 0x85021b5c, 0xf817770e, 0x14c289f1, 0x77ca8231,
- 0xcf3013a8, 0x1752aef3, 0x958b68f0, 0x9b308776, 0x9af40277, 0x78b8d8b0,
- 0x7a446fcc, 0xabffcf06, 0xcf3c25d8, 0x80bc48af, 0x7af241be, 0xbd0df231,
- 0x7d8655cb, 0x8fbc23e3, 0xfc721d6b, 0x9f2a3da8, 0x43a462a3, 0xbbefdbe7,
- 0xc89c68ca, 0xd024dabe, 0xa89f3183, 0xf00baf61, 0x858b1ce7, 0x3786b3e5,
- 0x2f80d722, 0xd21be518, 0xf819bd25, 0x75609958, 0xae3c7f81, 0x574ae7d3,
- 0x6820a3b1, 0x161eb69d, 0x0ec55e1d, 0xbdbb69c0, 0x97ce10f8, 0x738efa36,
- 0x54d27f73, 0xaa14f407, 0x273f4167, 0x64c768ea, 0x0ee9dfa3, 0x424177c0,
- 0x5bb478e9, 0xc2ac9628, 0x5eb85b7e, 0x3e208115, 0xe39360db, 0x211cb82e,
- 0xc73a4302, 0xe3f8405d, 0xf9a397f6, 0xd653837b, 0xfb92886b, 0x2974cee7,
- 0xd3d4ae2f, 0x83fa7ab5, 0xccc7baf9, 0xfec7cfd7, 0xe4a94b71, 0x53a677ef,
- 0xeb4ad5bf, 0xab268878, 0x80edda92, 0x973a89ef, 0xcd058408, 0xc6758af7,
- 0x38d0408b, 0x3b2ef51d, 0x183e2045, 0x47c66e1f, 0xb9237ae7, 0x125d44fc,
- 0xfefbb1c3, 0xec704c53, 0x04c33fec, 0xcffb2bc7, 0x7513f2e2, 0xffd1df39,
- 0x4ffa6ec0, 0xb3bfcd33, 0x5dfc7edf, 0x82fad2ec, 0x22eddcbf, 0xd374c07e,
- 0xbb2676ca, 0x7606fda2, 0x9871f12f, 0x95f7dc80, 0x0576cb53, 0xe96d87f1,
- 0x0b9f5d76, 0xfadf80a4, 0x6b4e3ac4, 0x8f1a5d77, 0x0be26ef6, 0xcbd0e76c,
- 0xcf1b456b, 0xfa02fc13, 0xbab648bd, 0x96977cb9, 0x98c8bd0d, 0xf33c8747,
- 0x859f48bb, 0x9ed841f6, 0x1f6347bf, 0x4db6b45f, 0xa9aa7d86, 0xde088d59,
- 0xfdf407d7, 0x17cfb631, 0xd5d7b079, 0xbdf11da0, 0x9c5dee9f, 0x84d4f80d,
- 0xde61e5b5, 0x2dfef7fb, 0x57c8e70f, 0xc5f7167b, 0x9f54adf7, 0x5b7b0fe5,
- 0xbfa8278d, 0xb3e5c27e, 0x9b4ce88c, 0xfa1ffdf5, 0xfa9eeb7d, 0x36c7985e,
- 0x2e483dd8, 0x56f659ac, 0xb078f1c6, 0xe083ef21, 0x16f8825f, 0xa6bb43eb,
- 0xdf2063a9, 0x0f32487d, 0x96ee87e5, 0x3ed0c372, 0x83496fc2, 0x2ce1f7dc,
- 0x619a89f0, 0xe1541776, 0x9616fcf0, 0x3987c3b7, 0x9f9f385c, 0xebc193ed,
- 0xc84e43b3, 0x78a2fb40, 0xf154e7a6, 0x1b6dc9af, 0xe04ff642, 0x68db350f,
- 0x75b56abc, 0xf78538f2, 0xa9f031d1, 0x78bfb79a, 0x135fd747, 0x8c5a9f81,
- 0x5f78f04b, 0x432127ef, 0x9a7a893b, 0xabbef5a3, 0x9b8cdea8, 0x1fa15393,
- 0x99fae895, 0x19404898, 0x1068fcc9, 0x9e5720ec, 0x7a0f52db, 0xc034d14d,
- 0xf0ec97c1, 0x981afce0, 0x71c91c22, 0xf4fed0d8, 0x57ee34a9, 0x2ec316e9,
- 0x03de60aa, 0xdf3d35f4, 0x2c6969ab, 0x38fe939f, 0x3b3fd1d0, 0xfbc325ae,
- 0xa30bf077, 0xdf3787fe, 0xe2eb483a, 0x79e430dc, 0x36e9bdbb, 0x3aadb3cc,
- 0x9847f592, 0xc9eed0f3, 0x2a02c39b, 0xc8b68aec, 0x3fe7d0d5, 0xb07b988a,
- 0xfee3c107, 0x83222d28, 0x799acdda, 0x95e42ac3, 0xa5eef1fd, 0xd692e7a0,
- 0xd3e7c0e1, 0x83262d4e, 0x6872afc6, 0x8969137d, 0xd968fbe7, 0x8be43831,
- 0x449e25e3, 0x2ee2a0f1, 0x53e72fe7, 0x0ff1c8a2, 0xe8496947, 0xf2d2c4a7,
- 0x66f855c4, 0x837b616d, 0xfdc1e868, 0x8a8bb79c, 0x037fe4ae, 0x75f4470e,
- 0x6b89b3ec, 0xf6fad32f, 0xd4f18dad, 0xefcb7cd3, 0x96b7399e, 0xe296f9d2,
- 0x9a6a80c4, 0x55d61677, 0x9be92be5, 0x79f3f24c, 0x65ef3e9b, 0xaeadbcfa,
- 0x1cfde0ac, 0x437aef3a, 0xc285f95e, 0x50ff20fa, 0xac5f15fe, 0x87ca5eff,
- 0x307d2e59, 0x20d6e70d, 0x3649db0b, 0x22ded384, 0x7d5df23d, 0xbed38f9e,
- 0xf7f1c473, 0x149ef8d5, 0x3d27db2e, 0x7ec3f16c, 0x37763c50, 0x9ac9e9e3,
- 0x634a8f48, 0x1db70895, 0xf0995072, 0xd9fc5cb2, 0x69edbf98, 0x661575a5,
- 0x6e01d768, 0xa92de2f3, 0xb43cf01f, 0x6f205381, 0xf8eb928d, 0xd7937916,
- 0x6cb85531, 0x3589942c, 0x531fc816, 0xf329725d, 0xa63fb915, 0xe30daf09,
- 0xd71a10cd, 0xbb05c3fb, 0x1fc4fa17, 0xbcd10ba0, 0x7f1f0a67, 0x9cfc2d9f,
- 0x5c022ade, 0x95a2c7ff, 0x89bc06f3, 0x4825e63e, 0x53d938fa, 0x8cdff865,
- 0x9117bf79, 0xad1967d7, 0xd923ca63, 0xad5fac99, 0xf9f0c1eb, 0xd14f79ae,
- 0xeff686e9, 0xfd83f43c, 0x99fa9d3b, 0xfec8637a, 0xe061ec2d, 0xf6dbf333,
- 0x877b4b51, 0x4c9914fe, 0x475eb870, 0xc5def5e9, 0xa9153fac, 0xf847c291,
- 0xfaa51969, 0xf21c7721, 0xa0484f2e, 0xb9fddc75, 0xb77e83d4, 0x843dbc5c,
- 0x46377fca, 0xd2dcf515, 0x64d4f2cb, 0xbdc99fbd, 0x9d869fc7, 0x2408b0f5,
- 0x17b9a50c, 0x8f5ed65d, 0x564ef9a1, 0x52c435b7, 0xa4de84f9, 0xbdf104c7,
- 0x5bb6121b, 0xd8ddd7a1, 0x627dfccf, 0x99df59ae, 0xc0551a24, 0x7350f279,
- 0x0f807dbd, 0x0c8ad7d1, 0x0188b7a9, 0xdfee8062, 0x47fbb963, 0x13ed1f7a,
- 0x0be1d92f, 0xbb433579, 0x3a5c7007, 0x18b9b3e9, 0x7ae55857, 0xd951de6a,
- 0xe48c779e, 0xdf9d2f2c, 0x84e8ebc7, 0x08f29308, 0x6e48a7f2, 0xcea67a40,
- 0x3a39e9cd, 0xa17e51e7, 0x67eb23ce, 0x7d803f14, 0x73faba56, 0xb772f02b,
- 0x6ef9c253, 0x761faa67, 0xc6a68ab5, 0xe55e98f1, 0x4883a6ae, 0xe3c503cb,
- 0x382ecc71, 0xd220e4b4, 0xb6f43bbb, 0x5fdd0e25, 0x5dbff3c0, 0xa3dbd3a7,
- 0x8834dea6, 0xbbedc9f6, 0xf6ebdfa5, 0x4da7533e, 0xc6de404a, 0xa8e8eef9,
- 0x3422b2fa, 0xa8cf22da, 0xb758cdde, 0xc1e8f9b7, 0xc9e75a78, 0xff3c11ba,
- 0x9e5e75d3, 0x09bad9ff, 0xa33dfe9c, 0x27ae39f8, 0x6c79673e, 0xd6a3b6d2,
- 0xe45faa14, 0xb7d8bc55, 0xdf857ad7, 0xdeb1744f, 0xf581cf26, 0x1f600e74,
- 0xf534198f, 0xe9303bf1, 0xda276d0c, 0x5171b8cf, 0x3c99c611, 0x7a8ac4a2,
- 0x2216bf33, 0x4e93ad3e, 0x8dee8bbf, 0xf8eb57f5, 0x6157bf3b, 0x1bdf9e78,
- 0xdf6cf0cb, 0xf9031191, 0x8ccee960, 0x6f89489e, 0x046f7a1a, 0xd97ed7e0,
- 0xff6df3c2, 0x8ef59c28, 0x774bf6d0, 0x7a89ec0e, 0x22df0967, 0xfb3cde48,
- 0x83b87ffc, 0x71b395cf, 0x027d5f4d, 0xc957f6fe, 0x39b248df, 0x5ff818f1,
- 0xd01e5eef, 0xce5d05cb, 0x02233d26, 0x6e8d5fe7, 0x427f0457, 0xb4b86cfe,
- 0x217f0ee7, 0x17f62c65, 0x9c1373c6, 0xb9191cc3, 0x7f7087c7, 0xfd467e47,
- 0x9258fcbd, 0xb9effa07, 0x63a48fed, 0xf34dadfc, 0xfa8c793f, 0xf8b7ef3f,
- 0x9d4e746c, 0x5e174d17, 0x2a7e1f05, 0x777bed92, 0x9c2f342b, 0x717b9bc3,
- 0x86b1473e, 0x2c39c32f, 0x73cfbcfc, 0x1975b714, 0x17aaadf1, 0x7a05ed1f,
- 0x30608d7c, 0x5b5fca82, 0xed7cc11b, 0xc8e79b35, 0xb8f7f432, 0xfbe9efec,
- 0x0bb63cef, 0x05d57de9, 0x65fa5277, 0xa1e31c46, 0x034581fc, 0x79ce9ed0,
- 0x3dfd4c91, 0x80128af7, 0xbad06abf, 0x69922b7d, 0x1c37837e, 0x34a2f4b5,
- 0x1ea529ff, 0x373ec0e9, 0xf9fd821e, 0x6e6e196f, 0x9a5b643f, 0xd96d829a,
- 0x75c9ffcb, 0xe59bfe7c, 0x9f75dc82, 0x3a25ed8f, 0x4a0183e5, 0x348d99d3,
- 0x8fd4b0d7, 0x6386340a, 0x6767af23, 0x6ff7b4f3, 0x49075815, 0x8977981e,
- 0x91e7c3dd, 0x7811b7df, 0x78e5af3e, 0xf62bbf58, 0x3b7a0a3d, 0x707a25af,
- 0xfa4cbd3e, 0x7fa8d5fc, 0x7cebcac4, 0xa2f7a9e5, 0x2189df61, 0xbf09d93d,
- 0x78db7e48, 0xe3eeafd4, 0xf587f016, 0x09fae279, 0x8ecd4f80, 0x9fb91b9d,
- 0xfa07872a, 0x4bcec56e, 0x2f205307, 0x993c20de, 0x321dc7a0, 0xaf42abff,
- 0x56a5a547, 0xe652fc6c, 0x5f398a5b, 0xfc27da4c, 0xca4ca2fe, 0xe7e88f49,
- 0x63cd68a0, 0xee24c97e, 0xafd7c4ee, 0xebe518a8, 0xb0c97cd3, 0x27e71b6f,
- 0xfda97b9d, 0xb2ec65b0, 0x5bd8cb7d, 0xdf2e1953, 0xebb3dcf3, 0xdfd197e7,
- 0x73e17623, 0xdf303f52, 0xc1be9ec0, 0xcdebcf2e, 0x2f4067c4, 0xe34d79c6,
- 0xed93f5e6, 0x29afe0bd, 0x076832aa, 0x91e523c1, 0xbe379630, 0x62b3f8ef,
- 0x6df9f156, 0xe1b55bc8, 0xd9f22f92, 0x885fed41, 0x37eeaed2, 0x7932760c,
- 0x3bab0bde, 0xe3c8f217, 0xfa6bde51, 0x96d5bcb1, 0x39d0358a, 0x53e61d7a,
- 0x95fc92a3, 0x457f2411, 0x73af7dc6, 0x2de51034, 0x5beffb42, 0xcd046c7f,
- 0xf1290633, 0x86a468ef, 0x485a45de, 0x7d39fc97, 0xf3f8135b, 0x3f926143,
- 0xbe610d47, 0x7433ac64, 0x07c4039c, 0x6f3be234, 0x11a339d0, 0x3917183f,
- 0x7d78cac6, 0x907552dd, 0x3922e5ce, 0x1ada0802, 0xdef3943b, 0x61638228,
- 0x2eb42aa4, 0x252347f4, 0x3ac7cdbc, 0x984427c7, 0xc42515ea, 0xbf8fb1da,
- 0x1d55faef, 0x3cb86a4f, 0x8370d4bf, 0x7413babf, 0xfac87dbf, 0x776f7ae5,
- 0x3abe630e, 0xeb7ef956, 0xdf15b22e, 0x8b8f3c09, 0x7373e7cc, 0x2394e45c,
- 0xd475e09a, 0x7ae87be1, 0x1c25d743, 0xfa8e4fdf, 0x167c2289, 0xedcfc7ec,
- 0xb66b776c, 0x5bf73eb5, 0xa2f36b82, 0x47ec0f5c, 0x70bed32f, 0xb54e9f80,
- 0x0cdb9cb3, 0x37ea92d9, 0x5c7170f7, 0xdfba6bcb, 0x6f5b37dc, 0xbe7c14ef,
- 0xc5eecf34, 0x615ef47e, 0x48ec1034, 0xd26fd2f5, 0x16f25b6c, 0xe5e6ebce,
- 0x819a1e29, 0x69efc150, 0x97e47ccb, 0x095ebcfc, 0x817f0adc, 0x40bb73ef,
- 0xfeb175fd, 0x5f94e9d5, 0x9e0c8bf7, 0x8fa447cf, 0x8abc62d7, 0xeb5be670,
- 0x71c9bd62, 0xff979f04, 0xb279f2a1, 0x91f29f2e, 0x6ed9d7cc, 0x378a6eb3,
- 0x04ad7e19, 0x36eb6f1d, 0xb05ef2ca, 0x4d3ca293, 0x26c4ffb6, 0xd7a2dfeb,
- 0xfbf1d04b, 0xb4a74eb1, 0x683f99ff, 0xa0ac2393, 0x95fb77ff, 0x46fbc6be,
- 0x17e19378, 0x933cac7a, 0x54b7986d, 0xf4c690de, 0x66d3dba4, 0xe8dcfce9,
- 0xc31c0d17, 0x9fcb4f21, 0x3b37f3d9, 0x2a33df41, 0x1f21479c, 0x22b1547e,
- 0x0cfd7a0a, 0x21840d4d, 0x917a6abe, 0x4bae43b7, 0x395eb8c7, 0x1fa1b96e,
- 0xdf00ca06, 0x710e6dbd, 0x81ffcb2f, 0x96fac121, 0xfa45e781, 0x1a6eadbe,
- 0x7eb060f3, 0xfe27695d, 0x72e51833, 0x6a45573f, 0xd57d07bf, 0xc1e1baee,
- 0x54fbbd60, 0xbc7943f9, 0xcf71f4ef, 0x3c1f79d5, 0x6f39099e, 0xb8c6a702,
- 0xf011fa1d, 0xd5f6fd49, 0xefda73cf, 0xdaf00b3e, 0x92fa94e4, 0x85e3edb5,
- 0x359faf94, 0x09f7cf80, 0xd85e1d53, 0x8477daf5, 0xadaf61f9, 0xc5ee159f,
- 0x44f7eaba, 0x985761f9, 0xd21befa7, 0x6fbbf8bb, 0xade98dbb, 0x667feeca,
- 0xdaabb50b, 0x89e99fdb, 0x96ed95e8, 0x642357be, 0x6d37b479, 0xf79450e5,
- 0xcd79fa64, 0xf2e18ee6, 0xe5c15537, 0x58ac81e1, 0x539b7782, 0x1375853b,
- 0xbcfdb2bd, 0x1fbf2eca, 0xfa12e9d1, 0x96fffb25, 0x42bf7144, 0x8f3f6bcf,
- 0x584f7d67, 0x91f3c9bd, 0xaf207dbf, 0x7dcbb347, 0x7ea46a21, 0xe725c478,
- 0x9e39a475, 0x8f4185f7, 0xdcb78a47, 0xef809593, 0xfcd2af24, 0x0d4cb2fe,
- 0xd06e1fc0, 0xf2f5329f, 0xbb5157db, 0xd9555f4f, 0xd7e7336f, 0xfbe30f8b,
- 0x13d5159c, 0x6bbcad39, 0xf5cb9f32, 0xa2eea71f, 0xa7a984f2, 0xe06bbfd8,
- 0xd9954e7f, 0xe9989a9f, 0xdf813355, 0x83f6ff5c, 0xd9e1ff54, 0xaf001627,
- 0x473533c3, 0xf6dbec26, 0x4cff97d6, 0xfe5d6df3, 0x36a3d627, 0xf8116b44,
- 0xd3f7717e, 0xc566bf5c, 0x7e802cff, 0x74956350, 0xb5db9c63, 0x91bf3d3a,
- 0xffa2c5a9, 0x63bf15aa, 0xb722223d, 0xbbd7f245, 0x3a3f1fbe, 0x65f9bcd3,
- 0x0e2dda85, 0x54e1ae6f, 0xfce1e7f5, 0xa204ab3b, 0x2b860c95, 0x5ce775eb,
- 0x47e06881, 0x72b948b3, 0xbf10d6f1, 0xa8925031, 0xdda88bdb, 0x8f5526e2,
- 0x41dbf457, 0x17f5a1a7, 0xf7ae77d3, 0x8a57bf3d, 0x763df926, 0x30d7fdd7,
- 0xfe0045fe, 0x64cf33ae, 0x9c3d026e, 0x5674f9df, 0x34369fb0, 0x72be72bd,
- 0x7df4e7fd, 0xd8be8e73, 0xc2db6f40, 0x0b85f64c, 0xf4eb24cf, 0xc2e9e926,
- 0xe7ecd933, 0xd9f7d44e, 0x0967c505, 0x085fbb47, 0x9e10678e, 0x971ce1a6,
- 0x0e1a6de3, 0x9d61fbb9, 0x6f8e2e2f, 0x67be0e1a, 0x68e141f0, 0x41bb63ca,
- 0xf41e534e, 0x8a7f8364, 0xfe2ca6e2, 0x42ca6fee, 0xd22d97fb, 0xa7cc630e,
- 0x8e14b9f2, 0xf0b5a27b, 0x6e7caefe, 0x8de426e0, 0x929dea71, 0x253bd4ef,
- 0xb75d097f, 0xe8ed2996, 0x1ee64fa4, 0x3ea4b3a7, 0x5c82f496, 0xde6593e4,
- 0x370bf329, 0x6fe1d894, 0xbcc9b7af, 0xfd897d6b, 0x35f7e618, 0x4fc4b569,
- 0xc5bf7473, 0xdda97f02, 0xfafefb0b, 0x3f1ce1e5, 0xcf3edb31, 0x7af6694b,
- 0x035c69bb, 0xe6fdfd0f, 0xf9f48bef, 0x0b890df4, 0xedb6a5ea, 0xf639c30b,
- 0x8e32e8a4, 0xb4a64960, 0x6cfb3ee3, 0xaa917c47, 0x6dc2dbeb, 0xea5ba1d0,
- 0x8fd78c1b, 0xef5e06ed, 0x2ff9a148, 0x5ea5e3d6, 0xfab848b6, 0xe37c959e,
- 0x052d7ce5, 0xc005d5e7, 0x2c5ce71d, 0xef2173e5, 0x7919bc49, 0xf0a15f03,
- 0x82f1f15d, 0x9f95d814, 0xc7f694c8, 0x8f2c7c50, 0xe513de1a, 0xd4cf5c06,
- 0xdc00ca1d, 0xa89d758d, 0x68e97af3, 0xafbfb4eb, 0x8c6877cf, 0x30477c8f,
- 0x1d6fd77d, 0x20248872, 0xd5ab6e71, 0x5bd42583, 0xbf43f7fd, 0x36aadfa8,
- 0x3b9704f9, 0x91739780, 0xbd41dffb, 0x0b621b05, 0xed180fa0, 0xf22fae17,
- 0x7bcd0796, 0x5e3356e0, 0xf3993506, 0xf3997783, 0x0d06715b, 0xe5dbe7fb,
- 0x21f9cc07, 0x93f9cc87, 0x3371dc1f, 0xea854fb6, 0xbe855fbb, 0x87f1e7f3,
- 0x7a9f4e70, 0xe06895f9, 0xcb5ff16b, 0x0b8f420f, 0x3c21678d, 0x7c73d02a,
- 0x97a6145b, 0xba5ae22b, 0xdc4643e1, 0x30627606, 0xdf0a54dd, 0x95da6b41,
- 0xa68acff5, 0x6744bd9b, 0xcfdecb55, 0xecb37a90, 0x5ad36477, 0xd0cee43b,
- 0x3be3bb71, 0xc6ebd222, 0x21192a3e, 0x365eaecb, 0xfe8a7c4e, 0x1e37bcd6,
- 0x2bf258f4, 0x929be585, 0x075fb297, 0x3edd1cdd, 0x6f4e46fb, 0x30f0c09e,
- 0x9b0b92ec, 0xe5144095, 0x8744235d, 0x8bf11f7f, 0xf1210da5, 0xe2426b9f,
- 0xcb99d682, 0xf7daee17, 0x504710ff, 0xe38278e1, 0x678cae2e, 0x5e801ff4,
- 0xb04a7959, 0xa9f2aa7d, 0xe5ccc26f, 0xf5f35d72, 0xade71875, 0xf1cb5df0,
- 0xaacb577b, 0xa3fe38e2, 0x4ba8e973, 0xcb73853b, 0x5eaf7738, 0xf29551b7,
- 0xfd84b7bc, 0x8e7691c8, 0x8876ac8b, 0xebcd0440, 0xebdd9450, 0xd697efa2,
- 0xb2bcb147, 0xe85ce480, 0x270a948b, 0x627a4dc7, 0xbbc4eed0, 0xd565cb2a,
- 0xd51e12f1, 0xb0fc51bf, 0xa8c3571d, 0x3293fc8b, 0xd80448bf, 0xf23a0bbe,
- 0xf803ad06, 0x468bce0b, 0x59565fa9, 0x9f00fb03, 0xab68738e, 0xad155eb9,
- 0xc838a3f3, 0x35efe67b, 0xd7eb8da2, 0x2c26faee, 0x3d907bf8, 0x435ef59a,
- 0xf97556ff, 0x3865fd4a, 0x20744fcb, 0x6cbe8384, 0xeebedcba, 0x6823921e,
- 0x7b0d2b7d, 0xdf295af8, 0x9e51b2dd, 0x679f2463, 0xd6eb4e01, 0xef867c92,
- 0xce206fa4, 0xf70a2c44, 0xea5ef94b, 0x6766eb0b, 0xf2f45cb1, 0x400a5e3f,
- 0x487b691f, 0xbad2bb61, 0xbaefd97c, 0x3973fafb, 0xe3c2a7f8, 0xb61cb184,
- 0xde518a6e, 0x4f91f587, 0xc864c530, 0x1ef7faf9, 0x4bdefe6e, 0x3ec166f5,
- 0xb2741e22, 0xfb90c47d, 0x2ebeb90d, 0x1ac9cb56, 0x75feb9d6, 0xf0516db1,
- 0xf88a89bb, 0x6cb725ef, 0x36e3cfd6, 0x2afc3f5a, 0x83e295c7, 0xf5198ff0,
- 0x73c96646, 0xef58f865, 0xfb1ebd16, 0x532dca5f, 0xe68ebdee, 0xc5b0fe55,
- 0x81a17b0d, 0x66f5e107, 0xd7c70e01, 0x77400b3a, 0x7b4ac7c3, 0xc97c91d9,
- 0x0a8623e7, 0xab1a378e, 0xcb363bf7, 0xc2934a62, 0x9fa91e89, 0x1ed245e3,
- 0x98b4351f, 0x132496ed, 0x6e2aebcc, 0x4fdeb265, 0xf7f8bdb9, 0x4f98bba3,
- 0x4a145d07, 0x6df8fbf9, 0x2f3926ca, 0x0e27c72f, 0xf6c9c07f, 0x39fae3ce,
- 0xe881e064, 0x0fcb1868, 0x0d8b5f3a, 0xa0b59ba1, 0xa0879c07, 0x6e982507,
- 0x8b7174cc, 0xee2be122, 0xbaf7f293, 0xe8379958, 0xf13ff482, 0x229ba0bf,
- 0x4eeff0c1, 0xdbd6340f, 0x74481e9d, 0xd07408b0, 0x0e842f51, 0xec3fd584,
- 0xa542fcdb, 0x2b876223, 0xab148284, 0x17ce21f0, 0xebc32467, 0xb11fab1e,
- 0x12adbd78, 0x92ac7d2f, 0xf1b4e8ee, 0x7d701785, 0x4b7de22f, 0xbc285c1e,
- 0x4524bf54, 0x1fad7db0, 0x713155c9, 0x45204edc, 0xbb0a8e58, 0x5f68a513,
- 0x2ffb2312, 0xfe3829e9, 0x5af3fa8e, 0x36e674e2, 0xc15efe1c, 0x47da0572,
- 0x9f7b7017, 0x5af7b645, 0x219bed29, 0x95b698f5, 0x5cbf1c61, 0x2c9f7772,
- 0xb1c4c9d0, 0xa2393a66, 0xde9195d3, 0x8dd6ed94, 0xf0249e75, 0xfe86d283,
- 0x3bd4de7c, 0x0277ab8b, 0xb047cf9f, 0xeab259fc, 0x618693c7, 0x7bc42f7e,
- 0x9333c280, 0xa83fb3b7, 0x4ff661b4, 0xb4be843e, 0x2bdfc9d5, 0x59f5b5b2,
- 0xf715ff90, 0xa1f49ddc, 0x7b01c674, 0x9ad7b512, 0x957f9ca6, 0xedbec9d2,
- 0x989e40ef, 0xfae55d3c, 0x3fb48593, 0xce39068b, 0xd6e7df24, 0xd26fea24,
- 0x69c38528, 0xa95d3a8e, 0xa40fc1b7, 0x2ca9f7e3, 0xe47f9745, 0x5592813d,
- 0x73d2b27d, 0xc9213fe1, 0xfd390bb8, 0x18fea353, 0xa5e40365, 0xfee4e3be,
- 0x1fa3ea33, 0x4b3a7bf4, 0xd5bf55ca, 0x09e462e1, 0x7cbf5cae, 0x8cd1d875,
- 0x40b6a468, 0xfde9a536, 0x7584bec7, 0xe3174c4e, 0x77ee03d7, 0xcf1362aa,
- 0xf984adb7, 0x1b965442, 0x4291abf4, 0xd6e3facd, 0x8f27ccfe, 0x7a3b698e,
- 0x6e8fe537, 0x8ced241e, 0xbe617dba, 0x707cb04b, 0x77e48c74, 0x98239b6d,
- 0x5ab88ffe, 0x3da4e2a3, 0x650ded8e, 0xb67c493a, 0xf87efeac, 0xed22cbb9,
- 0xcc7e7147, 0xc71a687f, 0x53ad9427, 0x07b86103, 0x6f6cc6b0, 0xded48aa8,
- 0xb5087ec6, 0x07da841b, 0xa3a03340, 0xd30a35f2, 0x8f7adf61, 0x9cf9993d,
- 0xcafac2e2, 0x70fd0323, 0x9c7b940e, 0x857cc71c, 0x826be0fd, 0xb9d870fb,
- 0xb5890705, 0x009f6b67, 0x258d254e, 0xe446efac, 0xfabfcc6a, 0xec1704aa,
- 0x26fe9d17, 0xbe0b5ec2, 0xc64d6d64, 0x9655fcbe, 0x3130f19b, 0xc91595ce,
- 0xfbe4ed74, 0xae6d4711, 0xe8efcc2c, 0xe705a74a, 0x9215c4ed, 0x39df69be,
- 0x1ee18f70, 0x3f0708ab, 0xfb259ad8, 0x5adcb39d, 0xbdf291bc, 0x151ac21d,
- 0x67cafa07, 0x5fd85efa, 0x75e62dfb, 0x046217ea, 0x35b289e4, 0x74bce56b,
- 0x96d610fa, 0xe71a78c2, 0x02b4e6d4, 0xe43a01d8, 0xdb63fedb, 0xba0ec701,
- 0x3d30ae98, 0xc10e7ad0, 0xbfde9c8e, 0xe9ca32f4, 0xcbd03efb, 0x7e81b1c4,
- 0x522f1b88, 0xb6be38ab, 0xe078493d, 0x6d176c77, 0x93b48f2c, 0x67be023c,
- 0x9f8319f0, 0x1d785d10, 0xdef89d89, 0x22534752, 0xceb5be1e, 0x75b3e9c1,
- 0x7825612e, 0xe24bab6f, 0x6e750bfc, 0x72ea9b4e, 0x758bfbf8, 0xa8efce1e,
- 0x97f9c11b, 0xdf9cbceb, 0xd3813755, 0xf98aeb57, 0x08afc1bb, 0x0c97cc3e,
- 0x27f063be, 0x3e0cbe83, 0x73574a15, 0x17b8cc09, 0x1f99ed41, 0xeb107c1a,
- 0xf27414b0, 0xe9cf0327, 0x092fb14a, 0xceb450fc, 0x5228ff06, 0x0aff3dcf,
- 0x22bdb9c1, 0xed22ed92, 0xf6c1f242, 0x079f0748, 0x0bb176a9, 0xdbfa89f6,
- 0x0eef47bc, 0xad6f873a, 0x88358450, 0xc4bc7f8e, 0x7441ac29, 0xac596f3c,
- 0xd9673f29, 0xa4f46ffb, 0xd18ddffe, 0x1e69b372, 0xe2797e47, 0xf7d13ff1,
- 0x4cf2fcdf, 0xf34ef026, 0xc608fcd8, 0x9f5c2bbd, 0xd79cab47, 0x9796765d,
- 0x7d4b86fa, 0xd4b86fab, 0x08e3f0b7, 0xa23dcf8a, 0x2d24a3e3, 0xb1a79df6,
- 0x9baeec6f, 0xb44ec047, 0xfa4bde52, 0xf2a3f804, 0x2bf8e8bf, 0x70c6165d,
- 0xf7d06d2d, 0x36dc706b, 0xb258f5c1, 0xf14ef960, 0xd7bf010a, 0x03d85fb1,
- 0x63882b24, 0x40afc38a, 0x6be52276, 0xab98ec0e, 0xe411f77f, 0x21d96576,
- 0x4735b396, 0x087fc724, 0x705ced9f, 0x83b2ca7f, 0xf6b44f5c, 0x466fc536,
- 0xc1daf50c, 0xc0e34037, 0x7ece695f, 0x1a2efd81, 0x547fbe15, 0x5f2f7fae,
- 0xa2e298ad, 0xf2ab6467, 0x959645de, 0x4259f3d3, 0xf91a473f, 0x96e832bc,
- 0x61c708f8, 0xdbe63796, 0xe7f10417, 0x597bfd52, 0xa714c58e, 0x9d967f79,
- 0xcd8f39fb, 0x9bdefd49, 0xcf9f6e93, 0xf7cdcffc, 0xa5fa8c05, 0x60ab0539,
- 0x835d2e4f, 0xf6cea6a8, 0x7d56d925, 0x7fa92e5e, 0x8b5ce839, 0x2ea2f8e2,
- 0x9e4307cf, 0x475f8539, 0xef59fcf2, 0xb9e17caa, 0xac8fe017, 0x9f1873fc,
- 0x75839553, 0x7fae4afb, 0x839634f8, 0x70ca91bc, 0xff12e1c8, 0x35fdcf85,
- 0xb55d711a, 0x97bda43b, 0x6b48a3d2, 0xfb60aaee, 0xf6878d5e, 0xadf81c49,
- 0xfaffefd9, 0xfbe67f0b, 0x14b0849d, 0xe3986e3d, 0x7c766ad4, 0xb06bf1ca,
- 0x7286f9c7, 0x1d5f1c7f, 0xf956beda, 0x4257f59a, 0x68a7c32c, 0x3c8997cf,
- 0x12979d8f, 0xf76ae7c1, 0x2aec4cac, 0x1fb4288e, 0xb0c1ce23, 0x358ad5ff,
- 0x59cfc39f, 0x9384d77b, 0xff65de92, 0xca1eeda1, 0x31384a8e, 0xeec62050,
- 0x5893b62a, 0x2c9fc705, 0xed38edd5, 0x63f64cfe, 0xd7772777, 0x2446a7ae,
- 0xdd5bb592, 0xbeb38831, 0xae84c428, 0xb649f4f0, 0xd3cf6b94, 0xfb3f823e,
- 0xe59536e2, 0xa2db8bca, 0x6cd43f78, 0xe220f07b, 0x529e6b04, 0x2d58edd8,
- 0xafce385a, 0x1c2a8766, 0xec1de7c1, 0xcfddf147, 0x5173f173, 0x8b5f404b,
- 0x66ef149a, 0xc3bb4f9a, 0x6823d31d, 0xbe80af3e, 0x87173488, 0xff470d35,
- 0x079ffcc6, 0x37920b7f, 0xc83f3517, 0xef548df1, 0xbf37cb02, 0x3c38e08d,
- 0xc1dec93a, 0x186ecf3c, 0x45f5fec2, 0x586bdb4d, 0xe116d83e, 0x8ce9e982,
- 0xe40f7ccd, 0x81de3e80, 0x9c8f296c, 0x67d1edd5, 0x1f59505f, 0x2fb13cc2,
- 0xb871e8cf, 0xf537bb46, 0x4b666f76, 0x5b26a7f9, 0xfea34fee, 0xd1a3a6a2,
- 0xc9fea8fd, 0xfa73ef5d, 0x166fbebe, 0x3df0b645, 0x223b93cf, 0xc9e09ef8,
- 0xfe39ff1d, 0x7cef1a35, 0x250498d3, 0xc89d9f68, 0xba7dc9b6, 0xf32fc641,
- 0x13d61725, 0x673d789a, 0xac28a5b7, 0xa4de032f, 0xf1dd9fb7, 0x3643df12,
- 0x1c1febe4, 0xb14b382f, 0x18a3dc86, 0x8d72083d, 0xd7bf55a3, 0x63dba6d1,
- 0xaffa6ffe, 0x5927bfd1, 0xe471f58a, 0xc4610d3d, 0xbd64b86f, 0x27b73522,
- 0xc1dcddf6, 0x97b899ee, 0x7192de2d, 0xfbb7a297, 0x737fe811, 0xbb678ddf,
- 0xbb9b52cb, 0x1c5ff227, 0xe0958526, 0xce887733, 0x875a9257, 0x347bbec1,
- 0x8615ca4d, 0xb56aad3f, 0xbf04bc22, 0x3e67445e, 0xd0aafde4, 0x49c90760,
- 0x563d7c67, 0x71daf161, 0x99d9463e, 0x3bb7ea2e, 0x75bec137, 0xec7c2ec4,
- 0x29d17b7f, 0xd2e927fd, 0xf618f20f, 0x7155a517, 0xd878ac81, 0xa9ba74f1,
- 0x41e54a9a, 0x29b553f4, 0xea390590, 0x2bda5d9c, 0xa9fd0e51, 0xabd640aa,
- 0xfd14e9d7, 0x69a3dfa0, 0xf72c0bae, 0xd0128cee, 0x44af2c3f, 0xd3c8bb49,
- 0x41614dce, 0x1cbf76e7, 0xc777118b, 0x66df4afe, 0x0bcc3f39, 0x7b22fcf2,
- 0x5de41663, 0xd145dc63, 0x39de3c8d, 0xe145bc7d, 0xa39fd28d, 0x3ea211c7,
- 0xec136f8f, 0x267b6a77, 0x33e6e58c, 0x632f2dc9, 0xf4cf33fc, 0xa387b8e7,
- 0xbb05fe69, 0xf1c9dcb8, 0x86cf95e7, 0xd3df3005, 0x5db144cf, 0xca4db4eb,
- 0x12a3a763, 0x143b1e59, 0xf65cf0f5, 0xa6153d63, 0x5a742ec0, 0x9424f611,
- 0xf2c1ee6f, 0x32dd6540, 0x1254d7f6, 0x4b1c817b, 0x7fc804e9, 0x67f737a7,
- 0x37e9d17b, 0x415cbe55, 0xbbe357df, 0xfee71a26, 0x0880f58c, 0x799e23b6,
- 0x83fd6ff6, 0x5a463bfd, 0x3ed994f9, 0x5183d066, 0xf923945e, 0xd48e5160,
- 0x71c86e53, 0xd11d5a71, 0xaf3a70f4, 0xc207f253, 0xb481eb03, 0xef61131f,
- 0x3bb4d23f, 0x9c048951, 0x09ff5903, 0xfa956fb8, 0x366d99d6, 0xbe5553f6,
- 0x3b65e512, 0xf157ddd4, 0x554ac97d, 0x1695e3ca, 0xf950df79, 0xffb656e5,
- 0x2ce33fd4, 0xde083c00, 0x6db6dfac, 0xe471f556, 0xf4b7a7b8, 0x808d7e91,
- 0x10797f9e, 0xc62635fb, 0x59537989, 0x0790dace, 0x2a7a5eb8, 0x69fee382,
- 0x34e22f1c, 0x73f67f2a, 0x0598cf09, 0xc1d027ac, 0x4ab9fccd, 0x77d5cfe7,
- 0xfb83135f, 0x955de210, 0xb25c79ef, 0xff827a7a, 0xd1ebc286, 0xbf3f9d1c,
- 0x83f338fc, 0x8837da2a, 0xfbac5b0f, 0xab3f1713, 0x78b95cb0, 0x308f35d5,
- 0x26c77ddf, 0x5ce22f70, 0xc1d183d3, 0x91cfa8f8, 0xbdb3b0fc, 0xa62feb87,
- 0x5bfdb2fa, 0x2d9f3cd1, 0x13e60f36, 0xddefc78a, 0x07f559fe, 0x226cafb5,
- 0xcaef22f9, 0x2d125ff5, 0xf833fd3f, 0xfb2736cb, 0x7cff0951, 0xadacea3f,
- 0x7fd60169, 0xf32779f6, 0x72b1b39d, 0xf3a49fdf, 0xf98d97d4, 0xb66bf4dc,
- 0x9a61fccb, 0xd0b439c0, 0x98d7ee6f, 0x9b1cead7, 0x4f78b7a4, 0xd544fc0c,
- 0x47f40f84, 0xb711f9f8, 0xedc6d77f, 0x40b3d743, 0x4fb1d76f, 0xba608f9f,
- 0xe24bdb39, 0xd90bece5, 0x8d1d9e7c, 0xf34ef495, 0x74de854d, 0xb8a65636,
- 0xa87a0499, 0x387a4974, 0xed89a63b, 0xed956702, 0xc9b51e9c, 0x74cb9576,
- 0x5fd13b7f, 0xb407e812, 0x63aabb09, 0x19e40b4d, 0x05e1f9f0, 0x4f70069c,
- 0x0e8ed43b, 0xd7f9c53a, 0xe333efaa, 0xebf6051d, 0x89a79fb0, 0xba6bc7ef,
- 0xedb5593c, 0xf0257f4a, 0x614db554, 0x197fda7f, 0x13acd0fd, 0xd1003f0c,
- 0xc29f62e5, 0x6e2c22ef, 0xfb116db8, 0xbdac96d3, 0xac6f7415, 0x6f7eb163,
- 0xf2a2a8fc, 0x693a8e7c, 0x395ee4ff, 0xdfdf019e, 0xef1d28e7, 0xf38cb875,
- 0x3bf0f68b, 0x47496e39, 0xfea46d94, 0x35941aaa, 0xa19a4e3c, 0x19f5cae7,
- 0xd8b02270, 0xaa3be761, 0x6eeed3df, 0xbb3cc6fd, 0x9d31cf9b, 0x934d1fcf,
- 0xdedb93f7, 0x2fccf796, 0x26243d7d, 0x41e45bee, 0xf46061be, 0xd063b887,
- 0x22f3f520, 0x35f61cf8, 0xcf34ebec, 0xff660dac, 0xe653ce4e, 0xe66d80fc,
- 0x730eee7c, 0x9cd9af3e, 0xce6ebcf7, 0x0ee309ff, 0xf41384eb, 0x4235c46f,
- 0xfd0a46ff, 0xf5261ddb, 0x7fa1e46f, 0x8dfe8523, 0x91bfd0ef, 0x3c8dfe87,
- 0xa1e46ff4, 0xfe85237f, 0xfeeeef8d, 0xba554e12, 0xe07814bd, 0x4eddbab8,
- 0xf7813e23, 0x89d9c5cb, 0x558547cc, 0x1717a5ea, 0xd8fcb2e5, 0xe29a6f61,
- 0x11937b60, 0xad18958f, 0x1c47f785, 0x2ab2d280, 0xb1db8d39, 0x55f6ba1d,
- 0x2aae8769, 0xeec24670, 0xe4f2bad1, 0xa73d882a, 0xd418b4a3, 0xdb6b68bf,
- 0x2f56f802, 0xff7ec03b, 0x77eee5d6, 0x63f893af, 0x5f118bfb, 0x0f738255,
- 0x25f49b7c, 0x71ee7719, 0x4353db04, 0x4d6244fd, 0xd3f21e50, 0xd43e733a,
- 0xe6be042f, 0x46abed35, 0x6c6fc7c6, 0xfbe0c96d, 0xe0e33e9f, 0xea9f69fb,
- 0xcb313bf6, 0x2198f2c1, 0x1bce23cf, 0x9f7a5970, 0x95e709b2, 0xc31c7fa7,
- 0xa650fdb9, 0x68617ee9, 0x0879765a, 0xf91df3cb, 0xe3058a35, 0xbe5f4f94,
- 0xcd6af58f, 0xedd2e7cb, 0xd7b2dcfa, 0xeef34c5b, 0xd1370fef, 0x71adc0d1,
- 0x5ecc7e21, 0x7783faa6, 0x31f887a5, 0xa7ca9807, 0xbe6219ad, 0x8d7c5f8f,
- 0xbdafbca9, 0xa1cf6e23, 0xfce4b9fb, 0xa5ceb25c, 0x6f5e02c8, 0xc554bd68,
- 0x6ff827f3, 0x4e52dbc5, 0xc673a72d, 0x2bbfaf1b, 0x9d7f0052, 0x57e03277,
- 0x858b64d1, 0x3f4cad9d, 0xf332c487, 0x15615cb9, 0x275c573e, 0x84b855dd,
- 0x7fda9637, 0x654c6d69, 0x47e5fa3a, 0x68812aa9, 0x3c9680d1, 0xde8bafe8,
- 0xe838727c, 0x98dd5aaa, 0x3bf2a2ea, 0x5c16ff14, 0xb7133f20, 0x9524713d,
- 0x495aa927, 0xaa73c27f, 0x1cff702d, 0x19edd1f0, 0x7ca4ef02, 0x68a5e6ba,
- 0xe9d41f8e, 0x0ae6d52f, 0x6c6c1d07, 0x814f5954, 0xeb8d4cfd, 0x8d8d93a4,
- 0x6bd0e1f1, 0x3e28c62a, 0x5c06c7c8, 0x8508fa0c, 0xefefc907, 0x97bd69ba,
- 0x94f7c90e, 0x752e758c, 0x41a2fac9, 0x07de37b6, 0x5c7bd630, 0x372b47d7,
- 0x3b7591be, 0x7fd73f7d, 0x7e1b9e5f, 0xbc5dbadc, 0x6d96c5ee, 0x7d29925b,
- 0x85dda1c7, 0x7b7d2d75, 0x1a48f45c, 0x326dcbe7, 0x75b3fdae, 0x23e13e4f,
- 0xe3777a7e, 0x0fe87693, 0x9dbf5695, 0x6679cddf, 0x0ef11da3, 0xc8dd6fd7,
- 0x2d6c17df, 0x71807b61, 0x1194eecf, 0xa3c3ad97, 0xc1b2ac62, 0xde3ceb45,
- 0x1585ca5f, 0xa69e32e1, 0x46f51d48, 0x55b5d602, 0xa6bac7c9, 0xe3b76f17,
- 0xf58781fd, 0xa6fba17a, 0xa2b4f0fd, 0x357bb01e, 0xd4c71c29, 0x11993edd,
- 0x64fbcfe8, 0x4e34e5da, 0xc81e5fa7, 0x8287de7a, 0x239c2fb4, 0xf5fa21b9,
- 0xf5da5561, 0x4ef9559a, 0x30903d98, 0x5ec2f20d, 0x35456ef9, 0x0a23439d,
- 0x710bb7a0, 0xa3c5a535, 0xd79d1354, 0xf6984616, 0xb4112cc1, 0x9bbfa8af,
- 0x7e532f45, 0x530cc4fa, 0x07d399fd, 0x0b9df886, 0x7f99cb3a, 0x8f7a6d5d,
- 0x9f2efaa6, 0xc7bb615b, 0x4a77f358, 0xbb3a62ef, 0x5abed4d1, 0x47bd354c,
- 0xf7a9e8b3, 0x6544ce18, 0x54e1c476, 0x6658f7e8, 0xeff54769, 0x169dfcad,
- 0x7dafda62, 0x927f3c33, 0xfd8da5e7, 0x7d3d8609, 0xe8cf7e16, 0xef0cbcea,
- 0xbc451788, 0x9a1dec30, 0x61691e59, 0x3c48553d, 0xa8f6eb54, 0x8f691cea,
- 0xd8b5f6aa, 0xf04d8f11, 0x4810a6b7, 0xb6151a6a, 0x477d5237, 0xdfcc9c4a,
- 0xcc3bef85, 0xdfd052f7, 0x521f9465, 0x42bfb04b, 0xdd686bcb, 0x606a1738,
- 0xd83b6247, 0x076c9384, 0xfbd1c633, 0xf434e837, 0xfed0807d, 0x33700c06,
- 0xbadcaeff, 0x822f60fd, 0xd8e2b4cf, 0x549dc47c, 0x95b14d35, 0x6f495ee4,
- 0x54bfff06, 0x7ebf6161, 0x4c03e1fb, 0x5615ed6f, 0xff4b8c8f, 0x78d4b876,
- 0x9435dda5, 0xbad0170e, 0xb05e7fe0, 0x15f8f143, 0xe9f00f59, 0x810cfa05,
- 0x70174a4f, 0x01d5e033, 0x7e7290bf, 0xe2286e3f, 0x0a7be426, 0x1425c057,
- 0x0b38fa9e, 0x2772c134, 0xf3cfcbcd, 0x8c57e90a, 0xb78fdd08, 0xb0ffd9db,
- 0xe52e1141, 0xf531e1bb, 0xf4e3b4b2, 0x6feb90cd, 0x2078a9db, 0xd97cdfbf,
- 0xe83bdfca, 0xd9c658a7, 0xde689f4f, 0x54f41daf, 0x8ccff72c, 0xeedc89cb,
- 0xdf5745df, 0xff864f45, 0xdd7e3426, 0x19e647b8, 0x1ab7dfa0, 0xf37d8626,
- 0x1be1c44f, 0xe77741f2, 0xe439c74c, 0x9910f1d2, 0xbcf9e5de, 0xe39d2a34,
- 0xbedd35cc, 0x4d69f068, 0x5b8c676f, 0x78eee542, 0x7e6f7bd0, 0x43557167,
- 0xfbf06a46, 0x1b4ada37, 0x975381db, 0xe25a73c7, 0x7ce22574, 0xdf2e5929,
- 0x4f763969, 0x29f844cf, 0x25b4ad8e, 0x8faea44c, 0x553439dd, 0x88be420c,
- 0x86d74fd3, 0xcfb60acd, 0x032de91b, 0x9c61f9e4, 0x872de7ef, 0x3f6167a3,
- 0x8d19dcae, 0x2bc5a190, 0xa2ee1fdf, 0xa2d9be73, 0xfec01a2d, 0xce7c8de0,
- 0x3cc6d70b, 0x390ce7d8, 0x516572a3, 0x5503c84f, 0x04f038ff, 0xb96d01e4,
- 0xea72112d, 0x81540fe9, 0xe73a1ad0, 0xe538be58, 0x6a7df494, 0xabdf0473,
- 0x2f08a53c, 0xd48b51fc, 0xd32e797d, 0x337cdb79, 0xd2708fc6, 0xae30c3b8,
- 0xc6124b7f, 0x30b2f8f5, 0x333cb6ae, 0x8bbb2ba6, 0x97aed691, 0xc316dff2,
- 0xa3dbacce, 0x0f23f721, 0x4b645fb9, 0xc8791fb9, 0xf72148fd, 0xfc0d7be3,
- 0xd71bf00e, 0x6f43e5b7, 0x39158df5, 0x8e1cf84b, 0x7f5c81cc, 0x01ee12bb,
- 0xf15dba3f, 0x8478e4f4, 0xf9e5620f, 0x2357821b, 0xb246dd1d, 0x5edd1059,
- 0x8221d977, 0x88c6ebe3, 0x9c7e5358, 0xbf54d923, 0x2a6695c8, 0xbfa93ebf,
- 0x7706fca9, 0x537f29be, 0xfd5348ce, 0xa6319e49, 0xdc468ffc, 0xc53faa60,
- 0x9f94c53b, 0xa9b66136, 0x12e28cfe, 0x59ccf953, 0xb3e54c8b, 0xf94cdbb5,
- 0x34ee2b5b, 0x92f1ffd5, 0xaf72a6e5, 0x0e715970, 0x231f4336, 0x3e85efb8,
- 0x6fede946, 0xe3064667, 0x4b38d475, 0x350cef97, 0x56fa900d, 0x39f7ae74,
- 0x09ee25d0, 0xe8fb0e81, 0xe2f680f7, 0xbf06199c, 0xfa914065, 0xe8324b70,
- 0x685eb426, 0xfd88a8f9, 0x6594f097, 0x9f6ee7ff, 0x313e2561, 0x43fdaaea,
- 0xfb7f2832, 0x5619e6c0, 0xaea32fe2, 0x3a52ffd9, 0xdcf17fe5, 0xf07cb237,
- 0x57284bfe, 0xfccbf772, 0xc822c134, 0x9bce06af, 0x8c75a3e1, 0x8d7d2eba,
- 0xba53da47, 0x5235538c, 0x9d7101c0, 0x00d20380, 0xfdd227d1, 0x5f489f44,
- 0xb72cfa27, 0xe8907109, 0xd221e913, 0xf7fdf14b, 0x3d2297a4, 0xd2297a4c,
- 0x452f4877, 0x297a42da, 0xcdd43fd2, 0x3a83f4e2, 0xb1fddb8d, 0x8fd382ae,
- 0xf7f096ea, 0x7196ea4f, 0x1f3a97fa, 0x8064ff7f, 0xb0087f61, 0x8bf0c69d,
- 0x091fc0d5, 0xdb2ede7b, 0xb1bf60b9, 0xabe795e2, 0x5facc7e1, 0xb0235a22,
- 0xb1ad5b4f, 0xfe9d1c27, 0xadf9eec9, 0x92089c55, 0xdee19ccb, 0xf8f006cf,
- 0xb7cc5dbd, 0xc447eff5, 0x84053eb4, 0xb5d34fa7, 0x3307e0b3, 0xc656ca0a,
- 0xeeb8ff10, 0xd03625eb, 0xae9687cb, 0xd5efa3ef, 0x03a7dbf9, 0xf7e86dbd,
- 0xa65dfd5a, 0xae321d6b, 0x6b6b5af0, 0xbfdbdb3d, 0x03c46e14, 0xefec33ed,
- 0x5ef958f7, 0xe085f2b1, 0xc104e8fc, 0x5b2ffaf9, 0x5af10e38, 0xcf892797,
- 0xc46f3d1d, 0xfdf87505, 0xef1413f1, 0x8de1f863, 0x2fc29f78, 0x3e41c75a,
- 0x77691d18, 0x0dc48587, 0x2fbedfc0, 0xbcc68fea, 0xc3277df8, 0x97d4ffbf,
- 0xf2f78022, 0xb5fe3f0c, 0xd834968e, 0xe1df4615, 0x33c704f0, 0xe57afe19,
- 0xe715168b, 0x64af1189, 0x3bcc638c, 0x15fd4aca, 0x5d23c674, 0x47ca6aeb,
- 0x757d465c, 0x93d7f724, 0x49dde3be, 0xb955e7aa, 0xec3e535d, 0x22aba3c7,
- 0x8ce9423d, 0xafa9e813, 0x3af1ea9b, 0x38d0bf0b, 0x1eb4624e, 0x1c7e8127,
- 0x01df9cb2, 0x48109d1c, 0xa39ffbc6, 0xb03dd897, 0xb88e3e83, 0xb8ce82b3,
- 0x088fd405, 0x2798c7da, 0x15f7edfa, 0xbcf217cd, 0x9df0cbd7, 0x29f492e6,
- 0x3f5e7adc, 0x2c6385af, 0x3d54bbdb, 0xfae61c5f, 0xcfd1046b, 0x90da19ad,
- 0x1fdfd481, 0x7ccc8c94, 0x7a3217d6, 0x094fdf60, 0x0bb04779, 0xf03119fa,
- 0xbc7e84ff, 0x05bdef12, 0xe942e1db, 0x418fc0c8, 0xbbde064f, 0x0e832ba3,
- 0x18d0e282, 0x65711def, 0xf4a17f7a, 0x199d1dd6, 0x43ad75f4, 0x8cf001d2,
- 0xae8320f8, 0xf89a2f94, 0x2ae8eb1e, 0x067f9f07, 0xc5d2855d, 0xe9257495,
- 0x0e27feb4, 0xba4aefee, 0xc007a4ea, 0x55d387e5, 0xf8f38a8b, 0x79a7a59f,
- 0xee3c626d, 0x765c97ff, 0xabda441f, 0x7c17b69f, 0x198c4ca6, 0x2e13120f,
- 0x62ec1075, 0xba32f5a1, 0x7f4a17a9, 0xbc6eeda1, 0x6e465da2, 0xfa71bb70,
- 0xaeda1959, 0x047aed12, 0x71c21bb7, 0xf7e96f11, 0x1a72de08, 0x999e2d71,
- 0xb90e5390, 0x2f2df26d, 0x27cc8de1, 0xf3a719ba, 0x096243f3, 0xee24bf9f,
- 0x854f40fa, 0xcb8d693a, 0x42fac85d, 0x71d76461, 0xedea3705, 0xdc5d7fc7,
- 0x4f8cf980, 0x37e3cb30, 0xf5fcf2ea, 0x0ffb91a2, 0xc6e1477d, 0xce59ebdc,
- 0x61477d0f, 0xfe3d40f3, 0x81a44d20, 0x8f0a17df, 0x0efe9f9c, 0xcfbea146,
- 0xc9ba7453, 0x5462ab70, 0x6a9bee1c, 0xaf321c56, 0x3c8c1de3, 0xfce3eb8c,
- 0xe9cfc20d, 0xfdc0224d, 0x0903a24c, 0x61091ff9, 0xc85fef93, 0xaa35bafb,
- 0x5790dff6, 0x4fba7b8d, 0xb057b53b, 0x4c440fcf, 0x4a77839e, 0xd7190dc6,
- 0x17f6ed0f, 0xdbce59ba, 0xb960c8ef, 0x16d2fb13, 0xde27c9d7, 0x5fba73a4,
- 0x8a37bca6, 0xfb46f714, 0x3bfa79d1, 0xbf91c73a, 0x40b96731, 0x736ef1bb,
- 0xfed193bc, 0x6138d726, 0x9cfeef8d, 0x776f29bc, 0xdecdd86f, 0x042ecd8a,
- 0xbd8adf7e, 0x7deb10aa, 0x45a7b62b, 0x4e7661a6, 0xafd2bd07, 0xa0d8b92b,
- 0xc6f1cefb, 0xc1dd78f3, 0x286b80d9, 0xff380d3c, 0xeb1eb800, 0x077bae0a,
- 0xaa379608, 0xad5f2423, 0xd57c908e, 0x58757380, 0x9ede7dc7, 0x5527f1c1,
- 0xf9af090e, 0x5611aecb, 0x2c17f512, 0x93f9c91b, 0xb807c275, 0x6092c69f,
- 0xf7b10f10, 0xce58eb09, 0x9ddcef1b, 0xe8bdf87d, 0x2ae79a24, 0x983ff687,
- 0x4082b9df, 0xe2844916, 0xbe7a86e4, 0x05fe7f8f, 0xaa7d03d5, 0xf1af754a,
- 0x96facec0, 0x7d71ef2a, 0xfe15207d, 0xd754f158, 0x0e55e8f1, 0x9f435f09,
- 0x98afd21c, 0x5fb1adf7, 0x80befe85, 0x0ef55f21, 0xc6dcf193, 0xe4eef73d,
- 0x92e1e1ad, 0x930ef5af, 0xebc0d8fc, 0xee7ebb06, 0x89c33f53, 0x3afca68f,
- 0x98abf59c, 0x2e4c6f58, 0xc28583ec, 0x76189fa4, 0xf904f695, 0x22b5ca7e,
- 0x945191eb, 0x13643c2f, 0x076f2a7e, 0x92794043, 0x1fb6b3f4, 0xef82a4ba,
- 0xfc294517, 0x6f71863e, 0x22c92c29, 0xc27c41dc, 0xbd370ee9, 0x13911b4b,
- 0x7947ca67, 0xc7ea997a, 0x9537488c, 0x98077ac7, 0x1427e3ca, 0x8a3df298,
- 0xefd536af, 0x29ac6b39, 0x68ddac9f, 0x31529faa, 0xf83794d5, 0x24fc8a58,
- 0xc5b92cfa, 0xb2efbed4, 0x34fd5352, 0x5ca9a55f, 0x319b3bc5, 0x25b7ab40,
- 0x81cf1127, 0xd58c9fca, 0xe3de434b, 0xf0cb08b5, 0xfe6b77ce, 0xcbde5a33,
- 0x80b91099, 0x6cc9afdf, 0x9e7999fc, 0x2c6b44ea, 0xcdbbd7a5, 0xc928b17c,
- 0xb9171f9c, 0x71df814f, 0x9fcccb9c, 0x4d589653, 0xeae51ff9, 0xe44f34fc,
- 0xbbe3ddb1, 0x300daff0, 0x4e143fe1, 0x7efc0f44, 0xef9d3b68, 0xcdebcc3e,
- 0x070f7e32, 0x75e0937e, 0x0c126fc0, 0x824df807, 0x049bf0f3, 0x24df87d7,
- 0x937e1cb8, 0x8721f2e0, 0xd61ff8cc, 0x55ffc662, 0x6ff1991f, 0x787765d0,
- 0xa66ad91a, 0x9a29a10f, 0xba782df2, 0x7e9994e6, 0x1d73f142, 0x09b15b89,
- 0x09e287c0, 0xbe387fb8, 0x8be08656, 0x37f7c3f0, 0x31477bdb, 0xd7d71e7e,
- 0x20606d75, 0x3a2e97df, 0x6fbc0aa4, 0x71f3ac63, 0x6d3fdcfd, 0x89731ad5,
- 0x5dcefccf, 0x763e0490, 0xdb7e909d, 0x4f1655f1, 0x207fba80, 0x29d99c64,
- 0x3fa843da, 0xaa52fe2b, 0x26d2741d, 0x0e7bcfdf, 0x95d8797c, 0x123eb2f1,
- 0xf6bef84f, 0x27be54cf, 0xa8d2c475, 0x8eaf8f80, 0x9f009ed1, 0x84bb9799,
- 0x8a249bd7, 0x5c402fb7, 0xa5857fd4, 0xafb73f22, 0x722dc7bc, 0x89fef95b,
- 0xa6e727c1, 0x2da9b8c8, 0xdd7fbab9, 0x9ea7e323, 0x777295c9, 0x71c5c794,
- 0xf2b925de, 0x8ba90d7e, 0x010773a9, 0xd99d873e, 0x0b3acf80, 0x8ad9ebbf,
- 0x9d09e47b, 0x0f21c8f7, 0xa3ecfe43, 0x1ff57fcb, 0x47581c3b, 0x3a617af6,
- 0x1dfbfb7f, 0x81e2f8a6, 0xfca65d5b, 0x5324a6a0, 0xdcbbc1fd, 0x40fcf2a6,
- 0xc87ca98e, 0x3f298f21, 0xa98465ac, 0x791f55fe, 0xad91f94d, 0xaff54c13,
- 0xca6c5539, 0x47b688a7, 0x8abedf01, 0xcd1c53b4, 0xb9fa974d, 0xe4dc705b,
- 0xe563bbdc, 0x7edd5f7d, 0x46fbc861, 0xd3a6b9dc, 0xd11ea875, 0xe8e52ed7,
- 0xf52164fa, 0x1fae8746, 0xa13eb30a, 0x1de371e9, 0xe67c58f7, 0x5e2371b8,
- 0xd0ef43bc, 0x7b8e8af5, 0xe2f19d34, 0xf178e0de, 0xbf5d61b9, 0xc75e7d1f,
- 0xfbfce87b, 0xeb7ae5da, 0xbdf3b4ef, 0xa15e631d, 0x96c949f3, 0xd1d9bb74,
- 0xbfaabdf5, 0x46fb4ae5, 0x25f1666b, 0x3613fdd0, 0x6dff2b4f, 0xf3c62b84,
- 0xb75e22b4, 0xcf7617fe, 0x8f77f70a, 0x5cb07737, 0x658b1ccf, 0x8e5c94de,
- 0xddfd338b, 0x92418884, 0x7583adbe, 0x78c84afb, 0xdc646373, 0xbbb1889a,
- 0x8fddbf41, 0x6499e127, 0xff7c0d17, 0xf167bf4b, 0xf74d35e3, 0xbd8e68a1,
- 0xce3f7f51, 0x4c3d036f, 0x59f24b1c, 0x5b13c93e, 0x49143d7a, 0xcb13ca72,
- 0x8a9f6cac, 0x3757fe7b, 0xde75fafb, 0xfa4be99f, 0xb203e810, 0x07a8f40e,
- 0xb72954f2, 0x2beb920c, 0xb8eebf52, 0x187ec0e7, 0x43f3f421, 0x174fbc70,
- 0x6874c6f4, 0x75dfe3ac, 0xdba0c1ef, 0xfa193850, 0x3be3d0af, 0xd2f319fb,
- 0x07ec67e1, 0xfdc67e03, 0xb66df713, 0x7c914de2, 0xe202658f, 0x6dfc0ce5,
- 0xc6f693c9, 0x503c3a05, 0xbba8fc0f, 0x6e6a457a, 0xedf7ec0c, 0xeae31dc2,
- 0xea3b0e82, 0x62e09bff, 0xfbbbbfc0, 0x87f1dd6d, 0x5df0be50, 0xa3baddf7,
- 0xdef67fd3, 0x909f105b, 0x5e3a4bf1, 0x1c2cfdfc, 0x94777017, 0x323f3f79,
- 0x9189f248, 0xe4fdf483, 0xccd6fd23, 0x0ffc042f, 0x9d552bf5, 0xbcf3c85f,
- 0xdf98ad24, 0x8af9c6af, 0x37f35bfb, 0x8847f94a, 0x87abc4e2, 0xe36f8fc2,
- 0x7ad7cbfb, 0x4a6ddb05, 0xde3f151b, 0x75f12af9, 0x9fb30fad, 0x0772cdcf,
- 0x26c83bbf, 0x46576a4d, 0x5da5f6ed, 0xc2facef9, 0x60eef948, 0x0beafbe8,
- 0x2f19bd75, 0x86df606a, 0x19eebdfa, 0x3cb1fba4, 0x9cf2c3c2, 0xa150d71e,
- 0x37a0e9d7, 0x0e6f7cbf, 0x31f6327a, 0x671f1ca5, 0x3f0dcdc0, 0x3cce90d4,
- 0x073c37c1, 0xb58379e7, 0x0ec5f8cb, 0xab7e1af8, 0x61ecbf0e, 0x1a1127be,
- 0x77ce718f, 0x3f2bba20, 0xeb1fe198, 0xf8741f6e, 0xefc3bec7, 0x89691ed6,
- 0x69f1dfc6, 0x67df26df, 0xfd5bf4e9, 0x22cbb865, 0xf03153fd, 0xfdeab53f,
- 0x5d798d89, 0x96d50fdd, 0x9438e4ef, 0x73b68b66, 0x2cefad10, 0x7b778ff5,
- 0x9fdc89ef, 0x26117788, 0x2ba976ea, 0xcdcbadd7, 0x8fe914a3, 0xef8ca9f6,
- 0x5ef209f6, 0x8151f13d, 0x4fc4677d, 0x0481114c, 0x4a1f86a4, 0xe1923d5b,
- 0x4aa1f86f, 0x9e792302, 0xda17ea33, 0xeb68e4f0, 0x851577a3, 0x53fd3bbb,
- 0x5c647dad, 0xaa7e7754, 0xb9f39769, 0xaf97e9bf, 0x183e7ee1, 0xb6e52694,
- 0x036efb86, 0x2ad80d9d, 0xab67586c, 0x4bbfebad, 0xabf3a851, 0x3d9ae812,
- 0x96ade282, 0x962fbc2b, 0xbf88c22a, 0xe46f3e62, 0xf9ea352f, 0x7dbf9922,
- 0xeab7cca5, 0xd16da7ef, 0x275820ed, 0x7a07ac52, 0x4edd36f9, 0xc5207582,
- 0x7c1df03a, 0x35f0790d, 0x90d7c1e4, 0x0a435f07, 0xa5ef86be, 0x761538a2,
- 0x0ad3f85b, 0xfc07f683, 0x72418569, 0xc169fc13, 0x82d3f879, 0x169fc3eb,
- 0x5a7f0e5c, 0x69fc3970, 0xd3f879c1, 0x9fc3eb82, 0x3f879c16, 0xfc3eb82d,
- 0xf879c169, 0xc3eb82d3, 0x0e5c169f, 0x39705a7f, 0x79c169fc, 0xeb82d3f8,
- 0x5c169fc3, 0x62996f3e, 0xd3cdb7f2, 0x5b287fdf, 0x51f4cf1f, 0x9b1c5198,
- 0xeffdf847, 0xc4fc7f88, 0x373c0e96, 0x2edd022f, 0x48f70ead, 0x904e373c,
- 0x8908b778, 0x8cd9b6e7, 0x32ecbbe7, 0xb4e3245f, 0x7e07e943, 0xf49b42ab,
- 0xdf85215b, 0x56fc290a, 0x2ab7e148, 0x2b7e94cc, 0xe15bf0a4, 0x4856fc3b,
- 0x0a42b7e1, 0xf85215bf, 0x6fc290ad, 0x2b7e1485, 0x0adf83b4, 0xf856fc29,
- 0x5215bf0e, 0xfdf0adf8, 0xfe03cd08, 0x905e632b, 0xf499fbf3, 0x9343a252,
- 0xe532ea5e, 0xd707e721, 0x5c1f9c87, 0xb83f390e, 0x707e721c, 0x707e721e,
- 0xc1f9c87d, 0xdc8349f9, 0xef20bfbc, 0xbc83b707, 0xd41f9c1f, 0xb6037be8,
- 0x2e1b49ab, 0x35b48ebc, 0x7142794a, 0x2f353109, 0x8bfc2673, 0x35254ead,
- 0x6d8423d6, 0x859980f9, 0x38f4d794, 0x66d13cc7, 0xae39be01, 0x05a6f080,
- 0x0f65c704, 0x5cc97ffa, 0xf9b3f86e, 0xbf9ef087, 0x50deb043, 0x35afdfa3,
- 0x4b847bda, 0xefd46a45, 0x2f5d77cc, 0x1ea37c74, 0x79a0cbf3, 0x8f996290,
- 0xbbfc9378, 0xaf700b22, 0x91458b60, 0x642bb8f1, 0x5d28743c, 0xe793caad,
- 0xf6cb16fb, 0x5388e1fd, 0xb83c5129, 0x156591ef, 0x80056c87, 0x7e0292d3,
- 0x562f2af7, 0xab92d75f, 0xcc658711, 0x124bb0db, 0x867be09f, 0xbd84daa3,
- 0xfd19c69c, 0xefe3b085, 0x4bb44c73, 0xa0ed0279, 0x29f40e6f, 0xf4414dde,
- 0x9e4f2cbd, 0xb6ef9a7b, 0xfbe9cbab, 0xae4b6dc0, 0x89c5fdc6, 0xd3ddb2e1,
- 0x386689bf, 0xf8506e4e, 0x6da8ce9e, 0xc9fb8bc2, 0x3a7e75cb, 0x5ecb9b70,
- 0xf8bae3ce, 0x6fd1a3de, 0xbe5486c9, 0x5a2259a7, 0x450f710b, 0x3df8550c,
- 0xb46e037c, 0xbeb1d7be, 0xb02ada2c, 0xfbe0ff2f, 0x7e2e244f, 0xa34ffb9f,
- 0x2116c687, 0xcb3450ae, 0x0d2742f7, 0x83d9592d, 0xe5f9a5e6, 0xbfa3a17b,
- 0xe706f258, 0x85ef929f, 0xe70cf932, 0x9879f1f9, 0xfdf853ed, 0x8dbec995,
- 0xee370496, 0x25b72f65, 0xe136fea2, 0xf5055881, 0x8d8af708, 0x168ae575,
- 0xbd01538b, 0x41f10388, 0x639c47f4, 0xdf25e83a, 0x59f7e363, 0x365d58a6,
- 0xce431bf0, 0xb1c97129, 0x3151d48b, 0x4432cf7c, 0xd0d4b84e, 0x7e62e383,
- 0x3b4e9c78, 0xba5fe7df, 0x8572c9d3, 0xbe615eb6, 0xc65f3e79, 0xf6dd56bb,
- 0x7a4b70e1, 0x99ce9c67, 0xbc16ff34, 0x7d267b03, 0x8508f47b, 0x79bd88e5,
- 0x0da3d704, 0xcd3df12f, 0xf06f9592, 0x0d4b943d, 0xfbcb450f, 0x52ffd26c,
- 0xb0cdc3ae, 0xf1d7cd3b, 0x69c7ae53, 0xef93ab1d, 0xcc39d33a, 0x6a5caeef,
- 0x119cb1b0, 0xf21a2f2a, 0x911ef1a7, 0xc23fae10, 0x60d153ce, 0x0bc03be3,
- 0x4aac94d7, 0x91ca5712, 0x7339758b, 0xe38d8351, 0xf7f42ab2, 0x6eff42d4,
- 0x1e3d62cf, 0xf356f16b, 0x42f24ff7, 0x7de350e4, 0xc94ebd4d, 0xb06607db,
- 0xc6c4b43c, 0xcb39cdfe, 0xb6247ca5, 0x93ee3f0b, 0xce3e59cc, 0xe666f782,
- 0x947af4ec, 0x5de9e82e, 0xd89a4e5d, 0x4ff864ea, 0xfcc11cb9, 0x14e5ea65,
- 0x397cdfce, 0x9799d399, 0xee2adc65, 0x5a6e8122, 0x073be48b, 0xd1f2ebef,
- 0xc6b1c40c, 0xc9eb3e43, 0xf44eddf4, 0x74f2218d, 0xabc035be, 0x3878801c,
- 0x44ada6d1, 0x8dc4ec9c, 0x4d83ef82, 0xfd451c82, 0x155c82cf, 0x5691fd8f,
- 0x2661f7c4, 0x68bf7c28, 0xf4dbd0d2, 0x43fb40fd, 0xf7e13f30, 0x29c2b457,
- 0xcd39c47e, 0x805bb6d2, 0x685f637f, 0x5efca3be, 0x629f24ea, 0x9a923bc7,
- 0x741b6fae, 0xe63fba1f, 0xb276e846, 0xeb076948, 0xb26193b0, 0xb7c92478,
- 0xd3e4266a, 0xf66db0b9, 0x608109d2, 0xcb2b951f, 0xd576fc7b, 0x419206cc,
- 0xc9fb55ff, 0xde458b1c, 0x9039233f, 0x96880bef, 0x2f949ea2, 0x4014a359,
- 0xf5e6323f, 0x38ec67b9, 0x3a4eb0cf, 0xa7d8ed28, 0xd2e51ef2, 0x7e4d327b,
- 0x8cb4d09b, 0x34fd8de0, 0x27f5a637, 0xf468610a, 0x1c2de160, 0x85ebf781,
- 0x005428f1, 0xe8b798f1, 0x3bc1eaf9, 0x973ab4ff, 0x91f9c4e1, 0xa6687dbf,
- 0xe05ff22f, 0x6b147393, 0x4b1bdff0, 0x0d5768b2, 0x50f7c1ee, 0x11bf03c7,
- 0x9efc6db9, 0x4bb64a44, 0x7b10a9f2, 0x8960f54b, 0x4bbb50c7, 0x773cae59,
- 0x7a9dd584, 0xdc7bfb2b, 0xd634b76c, 0xbe66cc7d, 0xf3a46be7, 0x5ee7eb07,
- 0x9ee7bfdd, 0xf916c3ca, 0x1663c2fe, 0x8857f6ff, 0xd0f72f5e, 0x8fbd6066,
- 0xe79ede21, 0x8cfaf1af, 0xf83a4cf7, 0x896efe95, 0x96474f41, 0x2afbe25d,
- 0xb77691a5, 0xe54f441a, 0x0fbe15ab, 0xde4cba5a, 0x2b56d6e7, 0x6e845df2,
- 0x99bf58ec, 0x9efcbffd, 0x117e6fd5, 0xf8750b2e, 0xbcb7b1ce, 0x84eb48e1,
- 0x3d979fef, 0x347c9360, 0x0efb8990, 0xf2712cb7, 0x7b9fd9bb, 0x0f06ab8a,
- 0x8c3c9e03, 0xe5d871a7, 0x8c4b7f54, 0x4bdf04b6, 0xd841cb45, 0xfcfee71d,
- 0xba8f7e6d, 0xdf8d39b6, 0x95d92cbf, 0xd9ef0abf, 0x7ed1ee7c, 0x4497f582,
- 0x4790ecba, 0xf9621a6a, 0x53db9e7c, 0xda2bcfbf, 0xe067cfd8, 0xd2c1bee7,
- 0xbe7d778e, 0xaea2e71c, 0x6cc01157, 0xbaf54c53, 0xf61a63b6, 0x4b3b50d1,
- 0xdf21bbe8, 0xdd815765, 0x5f641ec4, 0xb632ec35, 0x71b3639c, 0x77b1cfae,
- 0xf73ef7fd, 0xf437f3ea, 0x7a1df9da, 0x9ef8ee6d, 0x2ad7ff90, 0xcbd3d82e,
- 0x7133dd23, 0x90fca1bf, 0x62b4910d, 0xbe5b9c62, 0x7c8f731f, 0x8ef4a63f,
- 0x7367e67c, 0xdc029380, 0xfbc9193b, 0xe94fdcb8, 0xfbf7ee90, 0xf40f6bad,
- 0x0a7a0dd9, 0x821df978, 0x1ed79772, 0x951f2417, 0x77a62a35, 0x0bfc8c24,
- 0x97c95583, 0xfc00dd48, 0x9a477c7e, 0xcd396f1d, 0xf1093121, 0x27417b99,
- 0x51db3ac3, 0x993f8e3d, 0xca0e2e98, 0xfe14bdf7, 0x2f18e4bb, 0x955beff8,
- 0xc3df9a36, 0xdf2cfaa0, 0xc51c1aed, 0x68b895fd, 0x5d4869dd, 0x03824f3c,
- 0x3eeda9c3, 0xe3cdcfea, 0x02ca3e30, 0x07ec1b7e, 0x42f71073, 0x7e5c5bf9,
- 0x6d29c61b, 0x68d4ef90, 0xda38e46b, 0x20fb58ea, 0x975607c8, 0x5cb04fbd,
- 0xbddf20d8, 0xddffa39e, 0xcb2f9a11, 0x2704e5cd, 0xee33b3dc, 0xabc286dd,
- 0x797f9f44, 0xce59ac63, 0x036b5c6c, 0xf377667e, 0xdd39c65e, 0x30da5d0e,
- 0x2837df86, 0xbef97ab7, 0xfbc3a68a, 0xf79cdbb3, 0x7b325fc2, 0x34b623dd,
- 0xb065ffca, 0xe9cf6b94, 0x7a6271fb, 0xa9df9320, 0xf1c9cdba, 0x8d5db3e3,
- 0x780edebc, 0x81f0443f, 0x662ae2dc, 0xf89d1378, 0xbe596f10, 0xcedf8cce,
- 0x77c944f9, 0xf095d7fc, 0xd5605bfe, 0x79e0aeec, 0x8997dfac, 0xb4d9a1f8,
- 0x970ef1ef, 0x1f7c6970, 0x3343c4f6, 0x6205eff9, 0xe6cf1c9e, 0xbbc78f71,
- 0x4c374453, 0x18fd06d7, 0xf18df3f7, 0xb4ab1eac, 0x6bbe7bc7, 0x420f7a9f,
- 0x7c27af4e, 0xddd00fc3, 0x02e3b53e, 0x2f6b8d26, 0x5e07ef97, 0xfdf4efc1,
- 0x6a01fffa, 0x00d36c91, 0x0000d36c, 0x00088b1f, 0x00000000, 0x7dedff00,
- 0x65555c7b, 0xd6bbf0ba, 0xc0d857da, 0x51b08b66, 0x62020dc0, 0x10106d11,
- 0x80a17515, 0x636a735b, 0x8dc42937, 0x910150b7, 0xf39fa8ac, 0xa96f0db1,
- 0x962a2695, 0x8da6b675, 0xb2707595, 0xd99b1b46, 0x0f5d9a6a, 0x39d38d3a,
- 0x32cdb653, 0x34d209bb, 0x99d37d9f, 0xde79e7be, 0x0daf60b5, 0xf9a675a4,
- 0x3efcefce, 0x7df5e3fc, 0xee7d7bd7, 0x765ef3cf, 0xb24c6322, 0x98783631,
- 0x8c81b183, 0x45931819, 0x77a13fc8, 0x6302edfb, 0xbeac7195, 0x28d2132d,
- 0x0b6bff56, 0xdfe3df63, 0xa2749ef8, 0x8f2c6453, 0x5da0dbb1, 0x10af7c1b,
- 0xd6ccabd9, 0x29d33df3, 0x148af7d0, 0xd41dd336, 0x7ec3fb1e, 0x13efd5e3,
- 0x338b69fc, 0xe3abea7b, 0xbb78d856, 0x9a7ed0a9, 0xdd8beb05, 0x3ea81bf5,
- 0x26e9b3cf, 0x3632c591, 0x87ff04db, 0x7b4894a5, 0x32e6c456, 0x7057b0d6,
- 0xe1a8a11a, 0x18b18941, 0xf08b9f48, 0xbec664b1, 0x3bcdf868, 0xcfbd40b7,
- 0x64af6f37, 0x35e67b43, 0x398a3fc7, 0xf7363046, 0x0c733652, 0xa5de6c60,
- 0x0f569431, 0x073864f3, 0xf8dbd506, 0xc607ba5c, 0xfb2dadbf, 0x5a307fdc,
- 0x30e59fb7, 0xbf73fef6, 0xe868e3fd, 0xde9f3197, 0x3acf4d7d, 0xa13ead66,
- 0xc304b2af, 0x4d73af8d, 0x83155746, 0x18b6ce79, 0xcd14121c, 0x64c55e5e,
- 0x33b32798, 0x13e41a67, 0x422bcc75, 0x16fd6cbf, 0xf3eb04d9, 0xb557fe30,
- 0x5da9905c, 0x824fbe63, 0x7a860cf5, 0xdf5e1cc6, 0x58f7f00c, 0x4884670c,
- 0x912de8a8, 0xcdbc1903, 0xf83d29f7, 0x21a90c1d, 0x89ef07a7, 0x5ecc1d0a,
- 0x7b6d0657, 0x330305f0, 0x65eb0f96, 0xfceaae1c, 0xbff32aa7, 0xfb20bd6d,
- 0x4e0ddea0, 0x2757cf07, 0x7ac1e61b, 0x364face7, 0x5cb486cc, 0x473e5ef9,
- 0x2f8dde5b, 0xccaf8aab, 0x4f587695, 0x57c71b57, 0xe13d3ad7, 0x2f4f6bab,
- 0xa931257c, 0x00771e67, 0x8e00d8be, 0xe382362f, 0x57c0530b, 0xa82f33a5,
- 0x7c70bfde, 0xedfe7ecd, 0xd0765e0f, 0xceffa8fa, 0x1dbe8d07, 0xb6acffd0,
- 0xf2b784bd, 0xc9f41bd5, 0x99ceaf50, 0xdb51704c, 0xb6cfaecf, 0x6de78032,
- 0x1debb7ab, 0xe8eefc16, 0x9521ee93, 0x413f1059, 0x6790099e, 0x3bbc40ba,
- 0x397ea7a2, 0x9c617ba4, 0x91cd8b25, 0x719edaec, 0x3cf428b6, 0x86da3ebb,
- 0xafaecde3, 0x7165887a, 0xf66777fa, 0x66b3bfe6, 0xa0b317ce, 0xb3cfe43f,
- 0xe424ce45, 0xd4510a8b, 0x3e9a9bf0, 0x79837884, 0x35e0063d, 0xdbc3fe23,
- 0x0c38469e, 0x6ce6145e, 0xa9a94f86, 0x8b8e1f01, 0x36f38cf4, 0x826bcc88,
- 0x8135a97a, 0x548f388b, 0x876c28a0, 0x528d8469, 0x1df90b16, 0x4802ed30,
- 0xee9e2453, 0xc3f5f273, 0x677e3f77, 0x5c3c8131, 0xa1cf4abf, 0x3b606af4,
- 0xfe00a757, 0xd9cc310d, 0x4fa1e8ec, 0x3e951fb5, 0x6fedfa55, 0x70ae7b7d,
- 0x3993677d, 0x3386593c, 0x56e304c9, 0xb9cc3c3e, 0x3afcb846, 0x0f00610d,
- 0x817ad05b, 0x7d6c0b58, 0x903537ac, 0x0fcd7657, 0x24a5b7ad, 0x86f58fb6,
- 0x93e553ae, 0xc3ce2639, 0x015127c0, 0xfad77798, 0xf10c51a1, 0xca2f302d,
- 0xcd8bb39d, 0x5d5bce22, 0x504d53d7, 0xbbb6e619, 0x33e944c9, 0xc368c04d,
- 0x764d3e00, 0xe4df3fca, 0x29adb4a0, 0x9ddbca83, 0x633f9a36, 0x80698881,
- 0x85308aa7, 0x8f3cfdff, 0xe54165e5, 0xee9c6d53, 0x11035b4e, 0xfd3920b6,
- 0x0d79bd71, 0x0efa428b, 0xccfc883c, 0x5db2871a, 0xf5e9d430, 0x4cc42367,
- 0x3f3e4fa4, 0x7d12ddb5, 0x163fc927, 0x02ec7061, 0x24b19b96, 0xe02374fb,
- 0x38f2ee6b, 0x9b129027, 0xe49438d1, 0xb46f0cc2, 0x7eb00093, 0xcc78430b,
- 0xf860e453, 0x2395aa92, 0xb26b7eb1, 0xe6718055, 0x5ae79c5a, 0xced5fda9,
- 0x4b7bf1fb, 0x93252199, 0x9026caaa, 0x72287763, 0xdcc0896c, 0xa07787c8,
- 0x12fe449c, 0xfea2a50f, 0xf055a3b9, 0x56cf291b, 0x21d7000b, 0x78d2eecd,
- 0x055b1394, 0xbb6c0ee7, 0xa9a9e40d, 0x0d769e47, 0x7a817f73, 0xf4077d81,
- 0x255ffd07, 0x5d710220, 0xca1c726d, 0x75824df1, 0xb979c317, 0x059f080d,
- 0x6e9c9d0a, 0xc8e11339, 0xa3eb81ec, 0x65105ff8, 0x288b23cc, 0x3d141b6f,
- 0x79406486, 0x310e4e45, 0xca41f870, 0x3a3f11da, 0xa0e909a7, 0xc51292cb,
- 0x886f28fa, 0xf2c38948, 0xc912ad39, 0xaa9e9545, 0x7c2835d5, 0xa3be1733,
- 0x2a912bde, 0x56be9162, 0x74a44cb6, 0xcd9286ce, 0x24e3a05e, 0x9a3b1dc1,
- 0xb867a3d6, 0x13b5399e, 0x55bc47af, 0x9b4630ef, 0x7a496f00, 0x104e526f,
- 0xbed9ce3f, 0xbb41892a, 0xd3cddbf3, 0x5b17fe51, 0xa1a38acb, 0xd16dbcfd,
- 0x1e9052d9, 0x7ae6ca49, 0xc4ed4164, 0xacf00638, 0x2791fbf9, 0xe78fa0ac,
- 0xe8569f42, 0x70b69bff, 0xd4aa179f, 0x924fed34, 0x31dee780, 0xa1b3e279,
- 0xe0f142fe, 0x1f50a32d, 0xe2a7be08, 0xce23bea9, 0x503c87da, 0x0fc073d3,
- 0xdaf7a00e, 0xf51ef5ff, 0xd6f895f3, 0xbed0e5f5, 0x4885f6a6, 0xa6e167ec,
- 0xa15be43f, 0x49e8a0fc, 0x173ffec3, 0x45653fb6, 0x9edd6c02, 0xee7c7a85,
- 0x4f28b4a6, 0xf917f21f, 0xbd51f100, 0xaaf8205f, 0x517c33e5, 0xc7bb8406,
- 0x4c560ccf, 0xf480ccad, 0x8d625e7e, 0xf6a80f68, 0x323e5a8c, 0xf3adcb9b,
- 0x9093eb51, 0xb53fe64e, 0xccf50925, 0x5f3c1167, 0x6fadd4f1, 0xecf2dca0,
- 0xaf101a34, 0x38331d1e, 0x41799f51, 0x551d22bf, 0x93c6ff03, 0x04ae61dd,
- 0x0eca2a7a, 0x6fceb827, 0x51fa411d, 0xa77c179d, 0xcc74cff2, 0xd218f385,
- 0x748d99dc, 0x7f9d67ff, 0xcff3e22e, 0x17a766f5, 0xf5cd99f1, 0x4bd79fdb,
- 0x05ee58a5, 0xe47b4186, 0x885febcf, 0xd8f4b548, 0xfbd2256f, 0xd67684b2,
- 0xea36428b, 0x76ccf0ed, 0x1bb22cc3, 0x9d59d118, 0xc359d395, 0xe0e97d01,
- 0xa8c7b218, 0x37e746a4, 0x05af85f4, 0x9dd5bd8a, 0x80d7b7df, 0x87b3527c,
- 0x6d3511db, 0x508ec867, 0x855a92ed, 0x39ee179f, 0xda857643, 0x871f6eae,
- 0x5e3eed4b, 0xc801955e, 0x80e5cd1d, 0x0aba4200, 0xfbf905f1, 0xd3d7f5fe,
- 0x7bf26997, 0xb5df7f29, 0x750f2e56, 0xb7a8499d, 0x349c64d6, 0x976bfe20,
- 0x5e42fd2b, 0xbcde341f, 0x2f0481ec, 0xc16a1f2c, 0xfd8d0ef6, 0x9a2fbb50,
- 0xc36bfbda, 0x97bea356, 0x4c3a2ceb, 0xa42d6b9b, 0x8bd5b7ff, 0x9c5cba19,
- 0xed13985c, 0x916183b9, 0x07472859, 0x06653c2e, 0x3b6a0248, 0xbe50888f,
- 0x2f73ca3a, 0x031c67d2, 0x6f5090ae, 0x5fb405f8, 0x74f95e3b, 0x6e3ff604,
- 0x066be048, 0xbf0bd753, 0xf20c5e9b, 0x2d981964, 0x06671f64, 0x0f1d2046,
- 0xf4e5cc3c, 0x1ab67ae3, 0xb9d31bf5, 0xf72834d9, 0x3c42dca3, 0xdbe61b7f,
- 0x1dffff05, 0xfec60ff3, 0x143fc999, 0xd0a4bddb, 0x5968dba7, 0xaebcc02d,
- 0x8359ea1e, 0xd041be4b, 0x222d935f, 0xac34a40e, 0xdfe7a1d7, 0x82757b55,
- 0xc113a722, 0xc8bb408e, 0x416ec830, 0xf3366e3a, 0xccb209f5, 0xf71e611a,
- 0x8d9e1e67, 0xa76d7a7a, 0x9d611989, 0xc8c33a13, 0xe41c4d7e, 0x6cd6bd22,
- 0x2dbd224e, 0x02ac7438, 0x14ce1fea, 0xcfac3afd, 0xcfac3e4c, 0xae76214c,
- 0x9db19668, 0x6fb5f070, 0x960fbe51, 0x82891e2e, 0x47be0df5, 0x9d433670,
- 0x8f73aeca, 0x15a41bff, 0xfdec7697, 0x2dff4857, 0xe113b3ca, 0x75cbba7a,
- 0x5ba803c6, 0x39336d6b, 0xc160deb9, 0xef7838eb, 0xb13691b7, 0x9d1d7e67,
- 0x4dfb9ee7, 0x2726a62e, 0x07099fea, 0xa11fd225, 0xc3b0e9f3, 0x3d5287c4,
- 0x2c3b3bb2, 0xb0104fa2, 0x70f791fe, 0x164c137e, 0xbaf684bf, 0xb065ff49,
- 0xc48e617e, 0x935773e8, 0x83df614a, 0x938b1091, 0xd1747d47, 0x38eb7642,
- 0x3a550f85, 0xdb9b2b7b, 0x72296f8f, 0x73338555, 0xaf582cc8, 0xd66cf0a8,
- 0x1022faab, 0xf87b32ce, 0xaf529176, 0x932892eb, 0xf46d5e1d, 0xebb2e831,
- 0x33d250e0, 0x3fd9c9fd, 0xf601dda0, 0xf954f2c4, 0x5327845d, 0x0acdeef4,
- 0x2dfd54fc, 0xacdffd29, 0x8b66f1c0, 0x5376e1c8, 0x7a14dc08, 0x1e97a50a,
- 0xdb41887a, 0xeccf1ba3, 0x51a3f6be, 0x6bdf84c9, 0xfd78e61e, 0xedfaf090,
- 0xcd802b5b, 0x4dbfa0d8, 0x0cfefc21, 0xb98bf578, 0xedaf023f, 0x9bf578a1,
- 0x375e2187, 0xa0676489, 0xa376881d, 0xb5c0e507, 0x60f6e794, 0x51392306,
- 0xd7398529, 0x8077e324, 0x87c91643, 0x541f28a3, 0x15c430b9, 0xe9f506b8,
- 0x71e57069, 0x8db1017e, 0x10a4e797, 0xf6b0245d, 0xbc072c78, 0x277da1e7,
- 0x7e668699, 0xe5b7720c, 0xdfdedf01, 0x82cd3f40, 0x983ceb6f, 0x8b66f78f,
- 0x0eb7ed13, 0xc3d5e89f, 0x59a25a3c, 0xbf187ed6, 0x4e55fe65, 0x4533962f,
- 0xf8374c6e, 0xef837ed0, 0xbdf88d49, 0xe97f7f9c, 0x441f67ef, 0x8d33acfb,
- 0xb25abad1, 0x67da3a59, 0xf419652d, 0xdcaab7fd, 0xb7823079, 0xddf4e32f,
- 0x43e6df32, 0xa3e8f43d, 0x27a8e1be, 0xf1cbb65a, 0x510d4836, 0x981cf89e,
- 0xd38920ff, 0x94324b7d, 0x7059ba43, 0x7ec5cf97, 0x0df3e1ae, 0xff3d8794,
- 0x4e657414, 0xe506d105, 0x76231ba7, 0xe9555ca0, 0x2e30f074, 0xcf7887df,
- 0x7938456c, 0x7a8cb027, 0x8543ffe8, 0x0bf854de, 0x008d36c0, 0x3c1098f7,
- 0xa31774a8, 0xca585fc0, 0x413bcfe9, 0xf31d4f59, 0x0091bfa1, 0x38070953,
- 0xf0c11a57, 0xd5967483, 0x6ff38d93, 0x91f80c5e, 0x0f1c1d70, 0xdd5645a7,
- 0x155f07d6, 0x0df128e6, 0xa6f90218, 0xa9be7192, 0x7a42ba44, 0x0aba046c,
- 0x481647a2, 0xae173e88, 0x83ca15d0, 0x1cb8f708, 0xc257e758, 0xf0b1f21f,
- 0xa694ffad, 0xa4ce35f7, 0x1e2f2e1c, 0x734a7b33, 0xd04def48, 0x656f9dd8,
- 0xfa889a7f, 0xafbdf4e5, 0x149a6025, 0xeb8c9ee5, 0xd7fe5cd8, 0x1fff1452,
- 0xb8f407c6, 0xffcb0f8e, 0x2dda224f, 0x235f4b95, 0x79d2bffa, 0x37989996,
- 0x5d1ee01c, 0x00fd382c, 0x462d79bf, 0x16f824e7, 0x0c755c57, 0x6ad659e1,
- 0x56911874, 0x1c8d62d8, 0x408f2b3b, 0xda1d8a37, 0x39ba246a, 0xf4894bf7,
- 0x8b92b9c1, 0x0f800eaf, 0x4e0856e7, 0x32d657ac, 0x3790256c, 0xa816292b,
- 0xa057995e, 0x1ca9657a, 0x051a275f, 0xaf4037a2, 0xde283b25, 0x8ef5a731,
- 0x13df88a9, 0xa40f5fc5, 0x187ac1f8, 0x2e63e547, 0x959e48de, 0x56abf529,
- 0xbb47911b, 0xacb597bf, 0x3ffc88ba, 0xde521bd3, 0xec53e93a, 0x5b51acb7,
- 0x8235c6ee, 0x4e57771d, 0x07ca0c44, 0xefce64e6, 0x40f24811, 0x93fa0ff2,
- 0x447140bb, 0xc20f30cf, 0x61bc89c3, 0x99eba47a, 0xdba05708, 0xdd7ca5e8,
- 0xbe0aa733, 0x99ceb049, 0x1f67ce16, 0xfbbe0996, 0x09ff3e05, 0x5065ef40,
- 0x5d740b1e, 0x38e4c316, 0xe626dd48, 0x2e79c70f, 0xca09f61d, 0xd438d3db,
- 0x8fefaa28, 0xf75ca1b4, 0xb78911e8, 0xe5a52f32, 0xede947cc, 0x98f34fcc,
- 0x74933ac1, 0xfc93af90, 0xf38e312b, 0x0367b32b, 0x8b5fd7d2, 0xe0169c4e,
- 0x4239ddfb, 0x439428de, 0xdd68038d, 0x701f5b97, 0x067680a5, 0x5fac41aa,
- 0x147ee396, 0x4ccab3fb, 0x74ab718f, 0x995a8e95, 0x17d61537, 0x9be2debb,
- 0x6b8beb04, 0xf5c21cf5, 0x38374fa6, 0x1383ef10, 0x74133af8, 0x543f9fdc,
- 0x81a3606e, 0x183f360e, 0xdb3a43e6, 0xda2035bc, 0x03e6fea1, 0x97cc0180,
- 0xf0bc14af, 0x4e61eadd, 0x7559d38c, 0xfeed111e, 0x188f56a2, 0xe1a7e208,
- 0x394441b2, 0x23d3be91, 0x5ab49ea2, 0x353d53d7, 0x4fd4ac5f, 0x59067937,
- 0x4e9e4ec9, 0xa15c33f4, 0xd49fb51f, 0x045f8356, 0x4ac917b8, 0x57b7997d,
- 0x9e8a61fb, 0x3961db56, 0xab7a67d2, 0x453f4fa3, 0x3f505b4d, 0x08f88f83,
- 0x7bd205c6, 0xfd711fca, 0x1bf084da, 0x36abf378, 0x2103374c, 0x9d1c71f8,
- 0x79e34cc7, 0x15d33cf8, 0xbfbf87da, 0x63e38f7f, 0xb9bbf01e, 0xe422fef5,
- 0x1f00cda3, 0x9de6f3c4, 0xcfd4ccb3, 0x799a59f4, 0xf286a931, 0x4b070825,
- 0xa23c75ef, 0xd53d2fcc, 0xbd695a23, 0xe76843ce, 0xe28ccba5, 0x763f6a01,
- 0xf405741d, 0x857a776a, 0x90cbcc7a, 0x47b8945a, 0x4eb38e3a, 0x5d31ff40,
- 0x6b4957c1, 0xf63361fd, 0x5f1466e3, 0xfe85cf4c, 0x8426fea1, 0xfc37a183,
- 0x5e99e742, 0x4273e7cc, 0xf18edfa9, 0xe76c7494, 0x74431158, 0xd5d7e7c5,
- 0x1c6214ea, 0xa08fb197, 0x7e90c9fd, 0x0cb8c29e, 0x7e4ecfa4, 0xb42e4a6d,
- 0x97d1fe7f, 0x52d0b476, 0x0fb33e0e, 0xf5ab56e5, 0x9c709be6, 0xff9f2283,
- 0x5de2724d, 0x206ddf98, 0x53be9a3d, 0x7944db4e, 0xebfd1393, 0x55df56ae,
- 0x2cbd422f, 0xeb64c618, 0x0a138f3d, 0x3a15da9c, 0xcb793938, 0x53ef5c20,
- 0x582c7745, 0x5f87ed02, 0x3b8d38f7, 0x94fcca7c, 0x9b0fc816, 0x30abcbf8,
- 0xc78e5f7f, 0xfee4023c, 0xde5fd2b0, 0x6ae50fb6, 0x821cfce9, 0x4576c597,
- 0xda39a9f2, 0xbf02f5e3, 0x52dc4737, 0xd2b8fc8e, 0x24487066, 0xfa19eb77,
- 0x7711cd59, 0xe5bfb1db, 0x4c26f9d1, 0x36bfd60d, 0x6e3c9ca1, 0x1e2131c9,
- 0x18132d9a, 0x0aaceb96, 0x4f1bbe9e, 0x885240fa, 0x73847772, 0xe5744cba,
- 0x0c272864, 0xbcad0609, 0x2f7971d6, 0xb43e1dd9, 0xf5acba9f, 0x60cc8148,
- 0x7ca05409, 0x69795493, 0x3c717a71, 0xa3b4e2c9, 0x9142b4bf, 0xaf862c37,
- 0xf73960d3, 0x5eaf389f, 0x962e63fd, 0x867f4b50, 0x4128ccb0, 0x9bda3ff9,
- 0x573e10c6, 0xbbc58353, 0x6844f518, 0x70205d7f, 0x4fa38e50, 0x7e337647,
- 0x5eddee48, 0x7a341bb2, 0x7a5e5ba4, 0xf221f5a2, 0x7a811e52, 0x792058a2,
- 0x0ceb61e9, 0x0c12feb8, 0x3c5c00b2, 0x545eb8db, 0xce267bf9, 0x49e5f005,
- 0x5e5c9165, 0x2673e4e9, 0xd1efc60e, 0x452a5cae, 0x5e021e22, 0xc3e9e0c9,
- 0x9378f79f, 0x9d1e507f, 0xa987fa41, 0x21fe9007, 0x0fe144fd, 0x6f078a8f,
- 0x50a3f5d9, 0xd912cb5f, 0x85cb9503, 0xe2cfb436, 0x6947d1bc, 0x2edcc5be,
- 0xa6bf9768, 0x892a1cf5, 0x7979444b, 0xc799d962, 0xbebd41ef, 0xfff49c29,
- 0x5667a5a4, 0xa66e3c60, 0x211a7057, 0x7d1a59ef, 0x6f987bf7, 0x905d3a34,
- 0x81f0ab3f, 0x914597fb, 0xb8084f68, 0x759e8cce, 0x83321656, 0xf139e29b,
- 0x3b409633, 0x34e0a34f, 0xa1e07a3b, 0xef527ac7, 0x37bc05f5, 0xfad0fe46,
- 0xa8d7bc3f, 0x3e7759c8, 0xc6a2d9ca, 0x700a87e4, 0x7cf5eb5d, 0xd7d18d9e,
- 0x3927de53, 0x1cb97639, 0x3fd8a99e, 0x57b3a59e, 0xc0f7c3c6, 0xcef9416a,
- 0xc8a956f1, 0x88e340e5, 0x0d3f1863, 0x3e48172c, 0xa252bc79, 0x5ccdda1f,
- 0xef784d9e, 0x5d900a28, 0xb43de5d8, 0x722b5a92, 0x3674a3de, 0x94588c17,
- 0xe3dfa76f, 0xfe479ffe, 0x9bb62563, 0x83b5a2d3, 0x0cfd0226, 0x67bcb840,
- 0xf1e9fd26, 0xefbad196, 0xea6945f0, 0xd38ead55, 0x8bab3de4, 0xe7b0c7ae,
- 0x52277bac, 0x3992af3c, 0x2ade9122, 0xc1376e65, 0xe61b259f, 0x4f9d5733,
- 0x2ac7b731, 0xa27ec18b, 0xb07b5aef, 0x3389fec7, 0x78a8df20, 0x3a13f154,
- 0x19765eef, 0xacd076e3, 0xdd7ada75, 0x16301076, 0xe5caba8a, 0x32bf76da,
- 0xb9459fbb, 0xe038dee8, 0xaeabf21b, 0x80821e50, 0x266e7f21, 0xa61f71e3,
- 0xced543e8, 0x517a592f, 0x6668728f, 0xc23d45e3, 0x1fd2e673, 0x385fa7e6,
- 0xa1bef3b5, 0x3ebb4a20, 0xbf934e39, 0x534435d1, 0x30f766ff, 0xa75bf7cd,
- 0x5ef9ab5f, 0xc9a919ee, 0x5e3d5edf, 0xfd467f53, 0x7a1cad24, 0xa3d69a37,
- 0x79bfa7e2, 0xa3e8a5bf, 0x12ec4277, 0xe23a9d35, 0xbf91133f, 0xe4672c3f,
- 0x33787cbf, 0x1d31f8d3, 0xe7822423, 0xf93d5c80, 0xc8e5f731, 0xbf208fef,
- 0xa1f44fc9, 0x7343f3c2, 0xa228c9a1, 0x7ee4627f, 0x725fa879, 0x5e503990,
- 0xfdb1d4ce, 0xff8f5442, 0x9cf30e67, 0xe3bafec7, 0xf10f4b0d, 0x1f884378,
- 0xff78a573, 0xbfcc0670, 0x4d79790f, 0x16c3f72e, 0xffaf36ee, 0xb58e0838,
- 0xfc9ad16d, 0xebf1fda2, 0x3bd60e3f, 0xae1d044b, 0x93e146b3, 0x7da0165a,
- 0xa0e8bb52, 0x40c4eafe, 0x583be62c, 0xf4b46c67, 0x0a8b838f, 0x258f800f,
- 0xa9de2837, 0x193fc3fa, 0x9e0a453e, 0x1a70b4cb, 0x90e3cb93, 0x29108f5f,
- 0xc7239cdd, 0xf103fee7, 0xf49eb41c, 0xdc7fbcdc, 0xc847227a, 0x9f9f0859,
- 0xe3dfaf1b, 0x17940f1e, 0x7f0b908e, 0xfe4cb826, 0x47a5c247, 0xd82f47cf,
- 0x72a3fa0d, 0xfdfb819d, 0xbf5c33de, 0xfefd7237, 0xf68fb47c, 0x44f39b87,
- 0xed070ee7, 0xe93ed297, 0x618d7ba1, 0x59df1819, 0x797d23a1, 0x8190997a,
- 0x2126c2fe, 0x0f36fc8c, 0xc81648ab, 0xc878b9be, 0xaa31fd48, 0x3afded07,
- 0x0551f390, 0xe4096b3e, 0x71e5ccdf, 0x716e35b1, 0xf5038a4a, 0x1eac1ff6,
- 0xe27a8b8a, 0xfd9e1e11, 0x696be130, 0x2bee45df, 0x6bd0127e, 0x8512d1e5,
- 0xd5cc5f8f, 0x2e1f3ad1, 0x949db914, 0x1f70ba2a, 0xa9d81563, 0x96065768,
- 0x915f28eb, 0x6d59e9c7, 0x9d0a1ff7, 0x14dd94c7, 0xda88f386, 0x7d7dba24,
- 0x2e51fb8c, 0x793d0f8f, 0xb3ed1857, 0x68742a01, 0xd6bddbef, 0xaf582e69,
- 0x8d96d0bd, 0xdcdadfb6, 0x4d6fea68, 0xcf159746, 0x748cfca1, 0xfe8eca78,
- 0x8cfac0a0, 0xe655cd33, 0x580feeab, 0xe936fe94, 0x9da2bf41, 0x1e289822,
- 0xf91af161, 0xb16715f9, 0x1ccade26, 0xa76e0b02, 0xf428f3d6, 0x1b42c76a,
- 0xeff697e1, 0x5db178d5, 0x1ba417a1, 0xcf4abbc4, 0x8983fda1, 0xe9cc8dec,
- 0x15d9f389, 0xe51a8e52, 0x8f748dd9, 0x1f90eafd, 0x07fe5cbc, 0xe3c4be6e,
- 0xded7de2c, 0xe18879c3, 0x0c9c525f, 0x5fce4aec, 0xbee2434b, 0x024f913f,
- 0x40cf0e66, 0xde1e5684, 0xdac9d0ab, 0x48de827f, 0x3ebc02ba, 0x8fe5cb9c,
- 0x36fdc0ab, 0xb2c73bca, 0xfba230d4, 0x96270b1f, 0x51384560, 0x3872ba5e,
- 0x1f3df379, 0xcc749e10, 0x7f71b46f, 0x72e1f90b, 0x31c2a47c, 0xbe9e6449,
- 0x3c88f2f4, 0xca1bfbe5, 0x6ab7ae7e, 0x61d90fc8, 0x02c57728, 0xcc2cd2c6,
- 0xffb6bc61, 0x8f9c0e7a, 0x396ae885, 0x96aee5d2, 0xcfe43094, 0xcabc6564,
- 0x0ca7d29b, 0x205fa077, 0x040ed018, 0xe3c0c3bf, 0x574edc3f, 0xb94f7ae5,
- 0x72c47ed6, 0x1f8f664f, 0xeaf7daa6, 0x82973c77, 0x59f3aae3, 0xfd61d8a5,
- 0x125577cd, 0xdca2724b, 0x808f765a, 0x5ab1dcf0, 0x717df8d4, 0x0325615e,
- 0x7fce3e3f, 0x8efd13af, 0xcdafb038, 0xf575cf28, 0x5e083382, 0x0a817b81,
- 0xf8871338, 0xe24fe02b, 0x8967bd3a, 0x57c7425e, 0x85abb1d7, 0x5de71b8f,
- 0x9f90c82c, 0xa02f5154, 0x9956b7df, 0xa3055c7f, 0x3e9969ef, 0x9e21e301,
- 0xe38a5616, 0x03335655, 0x332af5c6, 0xf2865399, 0x7443c6ca, 0x02b9edde,
- 0x206f2539, 0x4f3a4fc9, 0xa4f02ae3, 0x4d1d01e7, 0x7643284d, 0x864bb867,
- 0x167f89f1, 0x4cb5a71d, 0x59efa2f0, 0x843ce2d4, 0x11d001fe, 0x2d3c7dc5,
- 0xe75f1a01, 0x5d7271e5, 0x80e9c18b, 0x658d4875, 0x5521ffb4, 0xd4329c1b,
- 0xdf29b63b, 0x2d95f18f, 0x0ddfdc8d, 0xd67493f5, 0xd1c3d7fa, 0x9910ab5f,
- 0x790a0144, 0x5659fa2a, 0x30562e85, 0xf7ee3b77, 0x41fe1933, 0xdca548bb,
- 0x2a6f3d5a, 0xd0e52266, 0x13dc8378, 0x6b9e409f, 0xd3b240dc, 0x678daa94,
- 0xc92b2d48, 0x7d6233af, 0x890faca8, 0xa5d54877, 0xac971714, 0xf35bf2da,
- 0x8e086222, 0x9e1e3c59, 0x8d88ef73, 0x727cc2b7, 0x1fe3797f, 0x41873d30,
- 0xfe5b8033, 0x4c073bb2, 0xac16ff87, 0xa62378d8, 0xe8cebc4f, 0xe08fc19c,
- 0xfa8c6657, 0xe8fafcf1, 0xb2abf295, 0xb9d00f26, 0xd27dafc2, 0x094f1abf,
- 0xfe954fe5, 0x4d4ef943, 0x7f865ed7, 0x120526d7, 0xdf4f0f91, 0xdb03323b,
- 0x73de3657, 0x5f88c7c8, 0x77d00705, 0x117177a5, 0x5660ba23, 0x5e5bd097,
- 0x490b3784, 0x1f37bfec, 0x3b7c863f, 0x13e7effe, 0x95df087f, 0x63ce8c09,
- 0xf649fd81, 0xdfaa9a9c, 0x3eb9f223, 0x246790bd, 0xc1464ebc, 0x053bac0a,
- 0xc7bee0da, 0x2b4e6078, 0xf02e7fa4, 0x4de38b3c, 0xef9e3c81, 0x6b40fd7b,
- 0x4b37ae0c, 0xa78ef5c7, 0x76e68edb, 0xa8ffb748, 0x06590fd8, 0xdced0536,
- 0x771126c0, 0xc0e0596e, 0xe2d63be7, 0xc9b96bbe, 0xcaeb0699, 0xf448dfba,
- 0xf68a0484, 0xa7689651, 0xb6aee5b8, 0x9f69cb8f, 0xd2c0d1b1, 0x0ee06e28,
- 0x006473c3, 0x4caab0cf, 0xacc357b2, 0x857aaf68, 0x1e88aaa4, 0x22f5087b,
- 0xef2cb40a, 0x30ac53ad, 0xb042aefe, 0xec7b3347, 0x59fed51c, 0xeb4c9f9c,
- 0x6820ed57, 0x8fddb0c7, 0x0b4aa7e5, 0x19bb224b, 0xf7fb83e6, 0x90264cb6,
- 0xff5213ed, 0xd92332f4, 0x7baf76af, 0x5bb470ca, 0xa0e6a797, 0x9ae30add,
- 0xfd7f6e24, 0xbb67ca3b, 0x285ef94e, 0x49b9e0e6, 0x05801f75, 0x8718d174,
- 0xfeaaed53, 0xe763a5e7, 0x9505b954, 0x9f2f9b7f, 0x59ff7ec1, 0x5563dd72,
- 0x634d4de8, 0xe9e079f8, 0xcf8dbd0a, 0x9e9a5337, 0x73dbb3ff, 0xfe93aea7,
- 0x39feeb79, 0x9ffae1d7, 0xffd88eb1, 0x3cd8f821, 0x3ac67ff9, 0x4ff2996e,
- 0x5f37875c, 0x43cfc86e, 0xe746d679, 0x7e2eec88, 0xdee41c2e, 0xcb9cbc3d,
- 0x09938b39, 0x74ffc764, 0xfd84d779, 0x1c1f419d, 0x7778a1cf, 0x67183a08,
- 0x88a1a588, 0x8ca5cdec, 0x2c8681f6, 0x4340fbe5, 0x224d3a96, 0x6e1603da,
- 0xec520e27, 0xb94b41ce, 0x9ca719dd, 0x118b882b, 0x3fd4327d, 0xca5bcbf6,
- 0xbee0c6e7, 0xd5ec9190, 0xf5dd36e6, 0x5e53d416, 0x868fce89, 0xd2d289da,
- 0x5f9c4a95, 0xf6aa9f6b, 0x79e31a68, 0xb4b3b2fd, 0xa3daa74f, 0xb4f29443,
- 0x603f7ca5, 0x1ed68b48, 0xdad6ab8d, 0x1082fa8f, 0xbaa9733b, 0xeb49d07f,
- 0xe9d72dd3, 0xa87ffcf1, 0xb07b89dd, 0xab0714a8, 0xfeb4067a, 0xf630d74d,
- 0xf9f77e74, 0x1fdc1c8c, 0xd05ab99a, 0xcf5539e8, 0x7e282402, 0x43e3e2a4,
- 0x3f8873d4, 0x5fb534f7, 0xaf3e6fd2, 0x2e4c7048, 0x539cd74f, 0x1e7eec62,
- 0x3a73712f, 0x11eaf5fa, 0xddaed16b, 0x37c6eeb7, 0xfd697d31, 0x04e5e19d,
- 0x6f54f5af, 0xebc6cb7f, 0x7650ff30, 0xe6123dbb, 0x53a8d0f5, 0xefd009ef,
- 0x85e33c6a, 0x2978b3eb, 0x9e14b68f, 0x7ab3d08b, 0xa4dbdfda, 0x0d9f4c0f,
- 0x45122be5, 0x23be911c, 0x1832981d, 0x59309f9d, 0x35f57e78, 0x30e3ee8c,
- 0x1a9f5ce5, 0xd73d0987, 0xc7c3cab7, 0xc4f00559, 0x18963573, 0x39a91f7e,
- 0x08e9fee1, 0x818766ef, 0x8b3939e1, 0x624fee72, 0xa82aaed5, 0xbf7edc77,
- 0x0bee167d, 0x7e881867, 0x26ce98a4, 0x9ed993c4, 0x71c2af63, 0xcd35e242,
- 0x2037e929, 0xfbb5bc59, 0x20679ef0, 0xc9cf7b7d, 0x2a9d312f, 0xf3c3efb5,
- 0x88465225, 0xbf6bd29f, 0x9bdc1198, 0x4a5f3387, 0x6e3b9632, 0x754e9110,
- 0x869a6feb, 0x50c154fe, 0x4f581ae7, 0x1bf30258, 0xbd611e60, 0x7b7989f6,
- 0xce9c20a9, 0xf59648d5, 0xdfd80d15, 0x7fba08a8, 0xae03bec0, 0x4df3a7cb,
- 0x80f657f4, 0x0e3a47a8, 0xc38ff653, 0x1fed7b32, 0x30c2fcd3, 0x3b59e14d,
- 0x7a15c3e4, 0xca7b635f, 0x6b77fb87, 0x106e5213, 0x69f53d1d, 0xbbd6195f,
- 0xab1bbbf2, 0x26fd5f68, 0x9fcf1593, 0xcafb2985, 0xa574e3a1, 0x43675b3a,
- 0x6418b46a, 0x55f11673, 0xe0725f0f, 0xe68353d8, 0x9cfaf501, 0x736e3aa7,
- 0xda83c71e, 0x64c2d19f, 0xf74323b4, 0x81fb43ad, 0x56be7079, 0x31fda9ea,
- 0x01e746d6, 0x518b8874, 0xa7abb57d, 0xe9df0db9, 0xff1fbb24, 0xcc82e382,
- 0x35fc431a, 0xcedb55ac, 0x0dcfca9c, 0x2a18f4a8, 0xfdd0a52f, 0x6f7ad4f7,
- 0x9f81e138, 0x1fad0827, 0xf6d0d70a, 0x5833b7f0, 0xe160ddde, 0xa95d88fb,
- 0xac22b99d, 0x473da57b, 0xbf5a7f33, 0xef7fd3d0, 0xbe6d3cfd, 0xb9f6364c,
- 0x7d07943e, 0x4e8277cd, 0x6c596fbb, 0x8d2fb6d1, 0x25777ed1, 0x4592f368,
- 0x6d91dfe9, 0x8e1af3a2, 0xf79e137c, 0x18d8f953, 0x8af7efe2, 0x2efa2adf,
- 0x1e74c991, 0x79de9375, 0xe3c4e50e, 0x01d24033, 0xf82c3c7d, 0x552e58cc,
- 0x0f515bb4, 0x93d3adc6, 0xaefc7a9c, 0xbde0ce5b, 0x6ba016a0, 0xf771e584,
- 0xc56e9b47, 0xf148b17c, 0x70fb9b0d, 0xcb51d239, 0x37bf5f77, 0x3a9fcf1b,
- 0x5bce740d, 0x75b1b73d, 0x1e2b61ac, 0x94cb8a0b, 0xfdf069cd, 0x84e62aa1,
- 0x6323b099, 0xfc712363, 0x15a2d12d, 0xd1f3ddf5, 0x718efff5, 0x8c19e694,
- 0xe14219f6, 0x46d23757, 0x756e3672, 0x5bf780b6, 0x5f9b1e1e, 0x06317289,
- 0xaf9465fc, 0xc57dca90, 0xf015c717, 0xc5b6c0f8, 0xbe23c52f, 0xdb0f5837,
- 0xa2159e69, 0x52d8a713, 0x8b7fe5c1, 0x7b3ed185, 0x3752a8f3, 0x72ec4d1e,
- 0x8b3c0ec9, 0x41dee2d8, 0x2d595ef3, 0x9cacd972, 0xc8580197, 0xbe9c3951,
- 0xfd4a360c, 0xb3346e98, 0x972839f8, 0x7ce8c292, 0x81f67f50, 0x57cb84b4,
- 0xe9cc6f6c, 0x1143debf, 0x5cc8f18d, 0x9fe467cb, 0x6dfd0b9f, 0xf299b19d,
- 0x538d3caa, 0xdfbbbbe8, 0x1bba3d10, 0x36724bf0, 0x9e2ce41a, 0x878e63c7,
- 0xf575b789, 0x3a20b4c2, 0x7c8055d5, 0x2ee7e2cd, 0xbebb7e30, 0x87e334a8,
- 0x9b9d4cfc, 0x5518e5cb, 0x97ebbb1e, 0xda05dc61, 0x635f51fb, 0x0fce783f,
- 0xb7d71952, 0x443fa851, 0x830cf37e, 0xe839ef03, 0x430e402a, 0x56825d7b,
- 0xc9181c4f, 0xc1fb35f1, 0xa09eccbb, 0x728c4d38, 0xbea3661e, 0xeb069cde,
- 0x744338d9, 0x6c78076e, 0xfa1068a9, 0x55c4c78a, 0x0d997e70, 0xde6fd1f5,
- 0x1b139152, 0x8c669ebc, 0x36d0c073, 0xdb9f0fd7, 0xbfc885d3, 0xbc79235d,
- 0x1cdd67bd, 0x3f4071be, 0x479a87a8, 0x6ae6ae97, 0x557241da, 0x6d6de567,
- 0x073a7aae, 0xcfc155d9, 0xf813ad5d, 0xc4a4827e, 0xf28b9bcb, 0x4bf4bf49,
- 0x492b152f, 0x57e2849f, 0xe5fd3f9d, 0x9911e907, 0x8719f1f1, 0x4cceb49b,
- 0xda07e1fa, 0x4af9743b, 0x1e0bd47d, 0x62ba7f6d, 0xf8e33651, 0xaf105fa8,
- 0x7bc5e63a, 0x95fda193, 0x3a16fc2a, 0xe069c91f, 0x8d9db1ed, 0xdbf48bf8,
- 0xc8e00169, 0xa1ce82e9, 0x3c38f7b3, 0x7c3a24b7, 0x2e01f86b, 0xae7487d2,
- 0x78f7a52b, 0x658e098f, 0x7de8efb8, 0xe7f3a25d, 0xcd4f7aa1, 0xb13070ab,
- 0x3e9ce736, 0x0f9c4dec, 0xa76935ea, 0x01fa89d7, 0xed8a97d0, 0x094b2a36,
- 0x5cd4b3bb, 0xd7ade8e0, 0xab6d5cba, 0x937282af, 0x03f69983, 0x99534c3c,
- 0x79c0307f, 0x1ccf33ed, 0x3df58abf, 0xf803ae0e, 0xe6bce099, 0xe63347f9,
- 0xedf37b40, 0xb9b426ad, 0xf5a1cf43, 0x76a4ef6e, 0x4cab4b71, 0x23c519d3,
- 0x86b95465, 0xafd90b08, 0xe48674cc, 0xc6c934b3, 0x3d10a7ed, 0x50f80eb9,
- 0x644af08f, 0x38d0af04, 0x49f8e871, 0xdefcc905, 0x1a52e2e4, 0xa7454377,
- 0x5d90e31e, 0x4ec57aae, 0xefa9f4f2, 0x7bb1fb42, 0xff23a73a, 0xc81a1577,
- 0xc1f87e1e, 0xcf119349, 0xc51265de, 0x7bd17ad1, 0x233dbac8, 0x1cae9cf5,
- 0x7f28cd8b, 0xdbb9ccb7, 0xfec3e8ec, 0x8b3152d8, 0x965a2fce, 0xa5633b70,
- 0x88e481bd, 0xe7b942a5, 0x71cbd8a2, 0xa213bfaa, 0x3754b727, 0x9bdef198,
- 0x8590de7a, 0xed97dbd8, 0xbbbd1fbf, 0xf18bf961, 0x2aee4fa8, 0x79c78869,
- 0x4ff0896f, 0xd5df1377, 0xf2029f93, 0xf1e51e38, 0x920e91a2, 0x7ff2dd2f,
- 0x0e3b39c6, 0x5569181e, 0x43db8af8, 0x417fe25f, 0x928d66bf, 0x1c6014a7,
- 0x8e44b52d, 0x74bc6076, 0x00d3bbdf, 0x7abd93ae, 0xfb8d63f2, 0x2fc1f481,
- 0x49382632, 0x681e9e5f, 0xac9d22b0, 0x8f46fc6a, 0xe2ce6bf7, 0x7fe855e9,
- 0x87b70255, 0x9818c556, 0xa1f342df, 0x2e754f45, 0xf5a7a866, 0x0137dc09,
- 0x798fc5bf, 0xfd102316, 0xbaf18e4c, 0x298700ad, 0x30bbbe31, 0xd7ac4aad,
- 0x129c60d9, 0xf080b447, 0xc563a29d, 0x9daf1e06, 0x115cf385, 0x59c511f3,
- 0xd1c5a727, 0xc5a3547d, 0xc9fbc3ad, 0xf6d5677a, 0x8bce8cb5, 0xb015bc51,
- 0x8ce1f74a, 0xb6bdc718, 0xeeab8e27, 0xdcf1a913, 0x04290575, 0xffc1212f,
- 0xcb23e22d, 0x1ef1101a, 0x403e987e, 0x46aaf8f6, 0xcd41f913, 0x91da3b09,
- 0xf823323d, 0x3e7aa43e, 0xb163e017, 0x0c567c02, 0x95d69bbc, 0x17bb1494,
- 0x91faa5e7, 0x50af20f1, 0xcc2565de, 0x4beb8a9b, 0x4aedc37a, 0x0cc67a86,
- 0x1660365d, 0xa2b9eae0, 0xc61eac78, 0xd8583c21, 0xabfb4c38, 0x40d122bf,
- 0xf2d0d8f1, 0x5c780b27, 0x21050b32, 0x135eebae, 0x755dcfdd, 0xaaf7bee0,
- 0x301e7e50, 0x6767c939, 0xffbc1481, 0x66771dde, 0xaeddff7c, 0xdbb5bf9c,
- 0xa63f740d, 0xf8ccbe3b, 0xe71abcbe, 0xd9e51a88, 0x31f2788c, 0xc7f421c7,
- 0x8f71abfe, 0x4fca461b, 0x6dac7f60, 0x63c515c0, 0x68eac6c2, 0x8529279f,
- 0x05f78279, 0x5feb2956, 0x7a870dd5, 0x75f5ea3b, 0xf6079428, 0x378d870f,
- 0x2226bbe7, 0x88ec46dd, 0x47dafd47, 0x171343bc, 0x79287bc1, 0xfa6204b1,
- 0x9c79aa93, 0x3cea6624, 0x5348778a, 0x0ad93ef9, 0xdcfc6016, 0x7c84c0a0,
- 0xfd4beaba, 0xe887700d, 0x927accd7, 0x90ae9193, 0x7f2f48b8, 0x6576e645,
- 0xa2dbdc88, 0x02f1f9f0, 0xcf91ee25, 0x93e7bff2, 0x5228bb25, 0x1889f7d9,
- 0xe8724295, 0xd90a5711, 0x411cc443, 0x9d9cbef0, 0x87b15073, 0x8f9ca77e,
- 0x83e72bf7, 0x83e72b0f, 0x0b77c55f, 0x863f90c0, 0x7a4016ef, 0xe549c9bc,
- 0x2815346f, 0x6fe399ca, 0x4892ee45, 0xf9941fb2, 0xadf994e9, 0x25734eb0,
- 0x6d567e03, 0x5879d3d3, 0xe984c263, 0xaf32cf68, 0xdb119edc, 0x7587ef73,
- 0x9efcbfc2, 0x095da773, 0x3a4f3a1e, 0x3ff7cac7, 0x542d7c55, 0xb612afea,
- 0xc75f9019, 0x36e16a76, 0xc6a452fe, 0xda622cae, 0x4d1397f3, 0x4bf53443,
- 0x97f3daac, 0x6ad7ec93, 0x68764fbe, 0x975e5fcf, 0x1f643e31, 0x0b574b56,
- 0x806e8013, 0x7d33aa4e, 0xd685ff34, 0xcd7b8a52, 0x74c7b90d, 0x3f36ab47,
- 0x2fcda7df, 0xabcdaddc, 0x46c3c9e7, 0x9230f429, 0xf131fc8d, 0x0cf7e44e,
- 0x0107ef85, 0x3ab36fbf, 0xcfda1199, 0xf8bf7816, 0x1b00c61e, 0x76c94bed,
- 0xe3ac238c, 0x5cb09ff7, 0xc3bdcbc7, 0xbe7af695, 0xdb8ec56f, 0x4b1dbee8,
- 0x06ede1cc, 0xfc7eeff0, 0x72f1a48e, 0xfe87af0e, 0xa21bd612, 0xe5c353f4,
- 0xfe459c93, 0x33ec9b82, 0x62b36b23, 0xc2fe016a, 0xe9399a34, 0xab0c759e,
- 0x9075bf27, 0x51327f72, 0x43bca4e8, 0x3e6186b0, 0xf0a67045, 0xe48f85f8,
- 0xfe4950c3, 0x89f12a75, 0xf447745b, 0xb90d97e6, 0xaaf007ba, 0x910286f8,
- 0x5623e2e4, 0xd8f9ef46, 0xbf13f75c, 0xb016c36e, 0x8f6b336e, 0xf87a1549,
- 0x61bcede7, 0x5c135fc4, 0xb52fda0e, 0x780b2415, 0x8588a52e, 0x4536cb9c,
- 0xc4a3e869, 0x5f42171a, 0x4be84243, 0x9d7f7f4b, 0x3945d5ec, 0xe842ce90,
- 0xe5be2ff0, 0xaf182c51, 0x05fa8f4c, 0x7689d58f, 0xca9e054a, 0x754f9602,
- 0xee319b46, 0x73d18b67, 0x3fd8a579, 0xab9f4aa5, 0xb2eb59e4, 0x566bfbe1,
- 0xf6e649d1, 0xf13d2dba, 0x96df1825, 0xea35f600, 0x5c919963, 0x1fd3b07d,
- 0x7fd43576, 0x65fffc04, 0xeb1bfd0c, 0x65efbc64, 0x5f10e4b5, 0x7949623f,
- 0xd05ef300, 0x437f58e8, 0xe5aff731, 0xef826ce8, 0x05bea151, 0xc23da5ef,
- 0xc1a94cf2, 0xfebc2df5, 0x5164597a, 0x31189f90, 0x9dbfea82, 0xcef86667,
- 0xd9a07781, 0x63ec7187, 0xdd77acf2, 0x7b7feb41, 0xaf07d714, 0xa8f11c19,
- 0x7c991e0f, 0xd287a677, 0x685f8d74, 0xbee4104b, 0x8f8517ce, 0x92bd7236,
- 0x78c7e25b, 0x34c2747c, 0xfd039957, 0xe90bb71d, 0xf112e742, 0xfd375be8,
- 0xa87e2b44, 0x0fc106e4, 0x5d749b4b, 0xe3ff430e, 0x35770b11, 0xd59e291e,
- 0x02f98652, 0xd903ee91, 0xd9ebe25c, 0x7e02aeb8, 0xe54af0fe, 0x181ea871,
- 0xbfdb9a32, 0x3c448693, 0xdffa1430, 0xb15a2450, 0x2b7a0dff, 0x4ef1e7dd,
- 0x1757e466, 0xe097eabb, 0x11096dbc, 0xda6fcf0c, 0xbe781a0a, 0x00ccc0d8,
- 0xbd6b934f, 0x4a69f117, 0xf6c08cf5, 0x7a7e0747, 0x5b19ed1c, 0x703a4882,
- 0xaef9cba2, 0x2817eb1b, 0x79e29df1, 0x9b3c70eb, 0x599ab445, 0xb9541c0f,
- 0xcbc99ebe, 0x0ab2ffc9, 0x0accdef4, 0xce0d436b, 0x708491e7, 0xae6df3b2,
- 0x79e20b06, 0xd13d40c3, 0x7f224941, 0xc2556a57, 0xffcc0ab4, 0x7191a062,
- 0x1f2ff3be, 0x5381fe8a, 0x5b3575a0, 0xc75e681a, 0xc139892e, 0xa9a896ef,
- 0xcf85a1d9, 0xf8f146ef, 0xf1e30990, 0xf5b79f80, 0x8b9a9ccc, 0x78a7a3f4,
- 0x6b7c7f53, 0x7ece5d73, 0x2afe61fb, 0x110b0394, 0xc29785be, 0xfa404f98,
- 0xfe61293d, 0x5b017f77, 0x60d9d680, 0x6e41fec1, 0xbfa2fabb, 0x7e9cd188,
- 0x4b0e0b9b, 0xd7824ef8, 0x341f1021, 0x444e4e5b, 0xb528783e, 0xa1e8e88c,
- 0x899a8f82, 0xfcf3862f, 0xeef779db, 0x137a3c41, 0xe77f69c3, 0x315982a1,
- 0x60bef4c1, 0x32f44894, 0x4e616fee, 0x9463e23f, 0x91fbf881, 0x8c56c708,
- 0xccf3794f, 0x824bbf64, 0x986cd975, 0x2862c4e7, 0x5da2fe87, 0x7ef13e62,
- 0x0b8f0575, 0xd57e302b, 0xf8843b65, 0x31664a90, 0x3949ae7e, 0xef9114f7,
- 0xb435435c, 0x25956ffa, 0xd8cfde97, 0x4270d092, 0xbb20b6d9, 0x5722906a,
- 0x45889406, 0x5906df28, 0xeb655db8, 0xbb940594, 0xaa47fba1, 0xed29d7be,
- 0xa65b328c, 0x371b54a3, 0x7d7015d2, 0xe97f6a1b, 0xc35edc2c, 0xae8fbc3f,
- 0x893f35cf, 0x317438e7, 0x197f7ada, 0x0a739ca5, 0x3a54afb1, 0x7ae560df,
- 0xd1ae4362, 0xa1bd7487, 0x2a59db98, 0x47f2ab1f, 0x872abf85, 0xef7e7bd4,
- 0x5195f628, 0x87365e4e, 0xe599eae4, 0xd4076f78, 0xc317739e, 0xfa56897b,
- 0x1f72aefe, 0x6f6294f1, 0x5bd8a7bd, 0x5bd8a1ff, 0x05bda3ef, 0x835186f9,
- 0x1437bf08, 0x08dd762e, 0x20901af3, 0x3a14df11, 0xedc44c4e, 0x271971af,
- 0x61d97d2c, 0x0ea2d111, 0x348f05e3, 0x36497bf2, 0x1598ed97, 0x95cf59f1,
- 0x766b2cf9, 0xbcbb3469, 0x7ae3f27c, 0xe43ed1d2, 0xb9557beb, 0x994c794f,
- 0xfe6571ff, 0x57f3286f, 0x43498fed, 0xbca132be, 0xefaf10df, 0xfc297e47,
- 0xb9d0a729, 0xb57950a8, 0xe908c401, 0xfc9122eb, 0xe778209f, 0x25bde46a,
- 0x4ef5f720, 0x1e68c959, 0x7660dbbf, 0x7c462c57, 0xa714664e, 0x27aae89d,
- 0xb90365b9, 0xf8b37245, 0xca6ceb5c, 0xe5833847, 0x6381519e, 0x8e5acbb1,
- 0x4638be72, 0x24571f4f, 0x5bbdd0a4, 0x1d0efed5, 0x0cf072f7, 0x82a66795,
- 0xf3e25ef5, 0x6c7247ff, 0x8ee3e32c, 0xfd3a24bd, 0x4f1cde5c, 0x91237926,
- 0x5fed0a7c, 0x636f3795, 0xbe2064cc, 0xfba1644f, 0x610a7700, 0x9de7844e,
- 0x3f307c28, 0xff7dd197, 0x673d8ac1, 0x01d1de57, 0xceb8a14e, 0xf5b04ed8,
- 0xfc7af883, 0x1bf75325, 0x8f8edc6c, 0x9a27e4d6, 0x4bf535e2, 0xef9ac9ac,
- 0x35c3ec93, 0xb23b27df, 0x32ebf935, 0xffea6946, 0xc9a459c2, 0x593050df,
- 0x2e4cbf53, 0x6665e4d3, 0x0e4877a5, 0xfa1eed36, 0xa7fd1eb1, 0xa71fa1b6,
- 0xa14f86f5, 0x0e0bf0f1, 0xa3b5e160, 0x00e8678b, 0x87518546, 0xfc864cef,
- 0x6793d1c6, 0x0aef80e8, 0x3afe1f07, 0xd3685819, 0x7f3c29e8, 0x53afe1f5,
- 0xf465bf20, 0x863f3c75, 0x3adcf091, 0x2f0cea7a, 0xea1c59e0, 0xd0347479,
- 0xea972df1, 0xf83da28f, 0xe6d365c7, 0x4ef84b26, 0x06625940, 0x8a6ce7cc,
- 0x7efc61e7, 0x15acec73, 0xfc761178, 0x8f74f577, 0x79a337ed, 0xfc8b8ebb,
- 0x8b8e8d5d, 0xbb0d1dfc, 0x53f6f1c8, 0xcbbef553, 0x7e9a0e04, 0x64115fdf,
- 0xfd05af7e, 0xdc6939cd, 0xfd14c4df, 0xdfd14c4d, 0xcdfd14c4, 0x6fee7a39,
- 0x26fe8a62, 0x89bfa396, 0x324d5be9, 0xb934efa5, 0x726f6d28, 0xbf7dda53,
- 0x6ae729e0, 0xef380a3d, 0x985b8b4f, 0x1117e4c3, 0x4ae7a14e, 0x4f9df43a,
- 0x45ca7ed0, 0x12fbc0e6, 0x394e2287, 0x39acbf70, 0x2e7444cf, 0x4c3bb674,
- 0x9730bdf0, 0xb62f9be7, 0x617e503b, 0x8e9eed1e, 0x946cb6e8, 0x16b5cdbf,
- 0x35bbee27, 0x23c7f45f, 0x1bd6149f, 0x714cdee8, 0xe9c52767, 0xbdfc2d0a,
- 0xc7114384, 0x91e3288e, 0x9179da5c, 0x277c45f9, 0xb0eedcc7, 0x3f60e32a,
- 0xea326e30, 0x3025c2b7, 0xbf5bf52e, 0xb0a9fa98, 0x842b8f74, 0xe1fa6b8c,
- 0x410a2771, 0x3176a6e3, 0xc701177a, 0xf5c66875, 0xfc3f744b, 0x78c25fa2,
- 0xd3b44761, 0x354d718e, 0x21df8c5f, 0xdfcf45bf, 0xf8742c5f, 0xb893d425,
- 0x5bef89bd, 0x33d881c6, 0x1f0d79d3, 0x47a865c9, 0x5d9db971, 0x9a179d7c,
- 0x9f900bfc, 0x6077958a, 0x7ba58cc0, 0x730c4c9b, 0x9128bea2, 0x38363bbe,
- 0xe339df17, 0x1b15a0ef, 0x1f90dbdd, 0xde5c74eb, 0xdf3318b0, 0xcfb5d057,
- 0x3bd415ff, 0xec983b19, 0x4bfb0495, 0xb404752c, 0x44cae45f, 0x5b24e3bb,
- 0x7568724f, 0x8f7fe794, 0x31be7a06, 0xf4505eb3, 0x7763f527, 0xfdc0ef85,
- 0x86578e88, 0x4d1f21e5, 0x645e3a33, 0x1f7fbfc0, 0x3cfc44dd, 0x8791ca2d,
- 0x7dfdac2f, 0x8f9e0af4, 0x3788bc73, 0x69acad83, 0x8ffc7146, 0xf1452f3f,
- 0xa79a740d, 0x7fb43a0a, 0x765373d4, 0x063613d1, 0xfaeb54e0, 0xd7e7c0ca,
- 0x7078c069, 0xc10718d4, 0x4661e06f, 0x273a98e7, 0xe076f847, 0xfa80df7e,
- 0xb2878c6c, 0xd61e474c, 0xd277d24b, 0xef8ef27d, 0xa827fdf8, 0x50537919,
- 0x8389fefc, 0xf8afab92, 0xdc31c9e3, 0x6a945d4e, 0xa8788759, 0x944c9bb3,
- 0xe748bc1e, 0x9dce9982, 0xd96bf18a, 0xa97bf7d0, 0xfae18eaf, 0x41a57921,
- 0x74410231, 0x30e594c2, 0x0cbde6a6, 0xbbf6d0f4, 0x8bdfbac3, 0x43327003,
- 0xdef3c89a, 0xeb178f1d, 0xac65f534, 0xe31dfddf, 0xbda7acf4, 0x8fcddbfc,
- 0xc6554f2f, 0xc7997a43, 0xd50c7fc8, 0x6d0b6b3b, 0x843f3bea, 0xcc63c7e7,
- 0x523de9db, 0x14877949, 0x4e315aea, 0x3de8ce11, 0x37bfc1ae, 0x9e819afb,
- 0x3d399a76, 0xdd3c8aa7, 0xeafaf229, 0xbbeaa53b, 0x7a14cf6b, 0xa3cc2b6e,
- 0x8fd4fc7e, 0xdf1b37b4, 0x6d6788cb, 0x6efabe34, 0x012f5a94, 0x2b0920f4,
- 0xe23a675d, 0xfb1250ab, 0x63e7e784, 0x1d20e68a, 0xb2f2685c, 0xcdf4824f,
- 0xc6c8f085, 0x49d5fc60, 0x3f5af7da, 0xda81331f, 0x1b6beda9, 0x284fb227,
- 0x3a27e978, 0x69154daa, 0x624ebd1f, 0x9c3be2af, 0xa80d5920, 0xa776d597,
- 0x78e2de40, 0xc5fc82ef, 0xbb903df4, 0x3ed1e89f, 0xfbe94e9d, 0x3f2a1e4d,
- 0x694d54dd, 0xca9ea9a0, 0xa46a6a3f, 0x23db96f4, 0x167f9172, 0x3ec65fed,
- 0xdaf7a209, 0x1027bd36, 0xd4553f94, 0x51ad1d37, 0x7254e8e8, 0x1c9fdfdf,
- 0x53bbedc3, 0x3b3e38e3, 0xf7c0dec0, 0x972e80da, 0xdbfd6d5b, 0xfdca1d1d,
- 0xf9e3a3ae, 0x3c4765fe, 0xc31f2fcf, 0x64596efd, 0xe8fed8ad, 0x3fef0378,
- 0xefc6ac45, 0x7bf78db2, 0x77a45d2a, 0xb1357ea4, 0x5831fee8, 0x73ca163f,
- 0xaea7f27a, 0x41e5dfe2, 0xaf9d5cbc, 0x42b6fdfa, 0x61eefaab, 0x8fcf7f3a,
- 0x7a02f7df, 0xfad5fea7, 0x3e702663, 0x4befad0c, 0x43c9e7e5, 0xc2a9f1e1,
- 0x6817c4b7, 0x241f2367, 0x9d45f107, 0xa542f883, 0xd6fe9543, 0xa7387216,
- 0x0f3a151a, 0x07eee7e7, 0x76842ea3, 0xb4cce383, 0xbbe3208f, 0x9d9eb0cb,
- 0xa12fc282, 0x63bca0fc, 0xca83f2ac, 0x0fbd2a07, 0xefe33e06, 0x8c75f334,
- 0x5f79fa95, 0x7b475958, 0x845dc46c, 0x2b7a83d7, 0x12b1adea, 0xb0792f7f,
- 0xedcef5d8, 0x11b19fc8, 0x96918c0e, 0xf7d4b2ac, 0xfe3ec725, 0x9543c2af,
- 0xa3c0fd0b, 0xca0c1c17, 0x123fc3bb, 0x50e7240e, 0xf6fd238e, 0x8c4eb721,
- 0x177629b1, 0xc7cfdfa7, 0x1d226fc8, 0x1d660875, 0x30e87bde, 0xf05f7df7,
- 0x0ebe78e8, 0x16d68e95, 0xe3074a32, 0x96f6873a, 0xba7aea7b, 0x230779d7,
- 0xc61a97f9, 0xacf143cb, 0xfe482bae, 0xa979c19d, 0xec0c64f0, 0xa127e81f,
- 0xe8ef42c6, 0xe0e856dd, 0xd3f036fc, 0x67ac0dca, 0x3e8a35fd, 0xf8944c7b,
- 0x7e8ac87b, 0xa4172ee9, 0x1a996599, 0xcf4743bd, 0xefe15f3a, 0x5645fb8a,
- 0xa372ef8d, 0x171c1d6f, 0xe5c8521f, 0x3cf4d743, 0x2f13f711, 0xf742d5fc,
- 0xea0c2f8b, 0xcef68d3c, 0x533d5685, 0x2a9b23de, 0x8b9dde80, 0xf90c133e,
- 0xf39ef2a5, 0x0ef7e8e7, 0x176d7a83, 0xb5bda34f, 0x4cc4ab68, 0xeb609e78,
- 0x3d20b737, 0x4f457bcd, 0x5b9a99e7, 0x7a471e37, 0xc04fb73c, 0x85d96fe7,
- 0x31c5027d, 0x7c225b6b, 0x0a5fa866, 0xc77fac79, 0xe3c7c96e, 0x39c5328b,
- 0x3ef1946a, 0xa0a5d731, 0xeb713e5d, 0xfb843a5d, 0x8b02edbc, 0xb48f7e83,
- 0xdf0c79de, 0x8db7391d, 0x366b2fdf, 0xf9c0ee47, 0x0ceb4a97, 0xc17ca083,
- 0x635e5e76, 0xf70cfd29, 0xcd3c1743, 0x60b3fe28, 0x8ff9046f, 0x1ff45af3,
- 0x8eec8205, 0xfcda6dea, 0x4066d67c, 0x53b0583a, 0x07b35e5b, 0x79f241f2,
- 0x2f12a150, 0x29b2ce19, 0xe3c2d25e, 0xef7caa07, 0xb97b5f6d, 0xde506d1c,
- 0x897f66ff, 0x5f0ff7a5, 0x23e926f9, 0x2997cf0b, 0xff9033f9, 0x178e1bea,
- 0xca752e15, 0xb3c55fd8, 0x675836dc, 0x2b662bdd, 0x0775edfa, 0x79e246ce,
- 0x016145b0, 0xbd99177a, 0xded1592c, 0xe4bf607b, 0x1ed6f845, 0xfb893f34,
- 0x9e2f7598, 0xa13c6030, 0xb262df74, 0xef312657, 0xfd9bf44a, 0x89dac8a2,
- 0x7de9da8e, 0xce77265f, 0x1c2e7ec3, 0x0ed15b30, 0x4ff97ba8, 0xfcc76ec7,
- 0xa7dd028b, 0x201890bc, 0x55b7993a, 0x0c437ba2, 0x1efcb42d, 0xaf10913a,
- 0x28b6e788, 0x0ee58f7a, 0x19e23bc4, 0x4648eef0, 0xd071e13a, 0xf44b4f79,
- 0xd9b5b9bd, 0xf9cff580, 0xbc557e38, 0x094b4a97, 0xe71e0bcf, 0x75b89cf8,
- 0xa430e6d7, 0x64f5a783, 0x76811f8f, 0x0d3b7883, 0xe15e181d, 0xc5d85ffd,
- 0xd37791cf, 0x376301c1, 0x2f3ce01d, 0xa7c00747, 0x472ff7a4, 0x97e89d07,
- 0xddffbf92, 0x0ed0c7b9, 0x87e7e08f, 0xd51b77d5, 0x2e071a77, 0xdf14753c,
- 0xbfb34ae7, 0xa5777640, 0xc5da8bed, 0x9d09de8c, 0x4be78853, 0x02bdbf26,
- 0xca7277d1, 0x2f14d9b3, 0x6d7607d5, 0x744378c1, 0x3ac7c538, 0xe1b6cb92,
- 0xb6c598fb, 0xc2f6936f, 0xcefd163a, 0xeb11e748, 0x3fc67e15, 0xbea2073c,
- 0xa7780c4b, 0x07b519f3, 0xc65cfc8d, 0xe1fbed3e, 0xce9cf11d, 0x959d0c4b,
- 0x804fd18b, 0x411c70fe, 0xc2e9fee6, 0x451dfc83, 0xa85c9fd5, 0x47b8a7be,
- 0x60836efb, 0x3dea9b7d, 0x70429850, 0xd6371a18, 0x73797681, 0x0d84f339,
- 0xc17d21fd, 0x5c7ca9df, 0xb5fa8bf1, 0x1bd1fb27, 0xbcc91daa, 0x15daf721,
- 0x014775b9, 0xbbd1e39f, 0x7be1d0df, 0xf93b1d8c, 0x3fcc3bef, 0x062af208,
- 0x1af519f7, 0xd4a753b9, 0x0fe914ff, 0x5bde76e0, 0x052892ff, 0x8bf797cb,
- 0xa79a9fb1, 0x48753f79, 0xf5571457, 0xfe830e6f, 0x33d36cbe, 0x4c0597e4,
- 0x23fb3791, 0x4bd46e28, 0xbedcecbe, 0x50f7cd12, 0x76085aba, 0x94222e26,
- 0x69f6eabe, 0xa85d3deb, 0x670e7bec, 0xfff9e0d7, 0x90e031af, 0xba5f23d7,
- 0x8e67e9df, 0x6eefe428, 0xef68287d, 0x056b0fef, 0x77ea0f96, 0x63c4cfb8,
- 0xeafe4aa4, 0xfe4d56dd, 0xa6bb369a, 0x1dfbb5fe, 0xfed9ef9a, 0x11f7cd0c,
- 0x7c9a9dc7, 0xa6817b5e, 0x64f7c8fe, 0xc0547e4d, 0xe63fa9a5, 0xef935bbc,
- 0xf4f584ca, 0xe9a8cf61, 0xa9a0bb24, 0xd661d93f, 0x465d7ff4, 0x65df26b4,
- 0xd8a3e051, 0xfbfdaa99, 0xff6e42a7, 0x7c2aa686, 0x8ed4e17f, 0x37edfaa3,
- 0x2bc76814, 0x5de3b593, 0x1df05e29, 0xff9e9d41, 0xf8a6027e, 0x34ba09fb,
- 0x9809fbfe, 0xc04fdfc7, 0x013f7f14, 0xe4dd7fcb, 0xa6befca4, 0x04bfca02,
- 0xf7e6097e, 0xe9829f83, 0x609fe0cb, 0x77e0e5f9, 0xb8f7194c, 0xca1bee32,
- 0x4e153fb8, 0xbdfd296f, 0xef87f4a3, 0x3df4ea0d, 0x795d6bdf, 0xe3e025e2,
- 0x7467db22, 0x086e595f, 0xa31c6294, 0xe18975f3, 0xf1e667f9, 0x418a6f1d,
- 0xa18036fd, 0x9ddcc49d, 0x6e3ee26f, 0xad438bdd, 0x81efae78, 0x07787ffd,
- 0x27d85fbf, 0xf0e6bc51, 0xd891b3fe, 0xc29797cf, 0xe90a30e9, 0x7cd7c845,
- 0x0d7e502b, 0x6773c77c, 0xca4af793, 0xa46d67bb, 0x554cbeef, 0x2fba3ef3,
- 0xd7b3deed, 0xb85a7880, 0x7f7d2f7b, 0xf35af81d, 0xcd76f77d, 0x87d62b77,
- 0x47cea174, 0xf7cf8571, 0xa9f9fdab, 0x7f2a4d7e, 0xddf3fe3f, 0x418e5647,
- 0x6ab7bc7d, 0x17b5c600, 0x3b1139ee, 0xf1f007fb, 0x66cf4bd5, 0x3da81ea2,
- 0xd1e72920, 0x07b57f78, 0xcf9e4af4, 0x6f7526bf, 0x63379e29, 0xb3ba047b,
- 0x4f5b25f4, 0xee16c4e7, 0x728355df, 0xedc66176, 0xb57f8a7a, 0x83bc4a49,
- 0x6350d3bf, 0x6baedc65, 0xdf123afb, 0xdb7dffa9, 0x1ef1ebd1, 0x23c1c774,
- 0xc74c5ef4, 0x4fe3493e, 0xf1cb1d8d, 0xf72c763b, 0x77dcbeff, 0x09cf1224,
- 0x8476d03e, 0xa7e75dc3, 0xf2561ff5, 0xbc12901d, 0xfeb44bf7, 0xcd2497f9,
- 0xc0b801ef, 0xcdfba171, 0x7022d3fb, 0xf8db275d, 0x7d40d378, 0xd56a7950,
- 0x1bff9c1c, 0xe53cf2f6, 0xddfa327d, 0xaeab8ea1, 0x767285db, 0xe7d49b61,
- 0xd839f779, 0x98efcc2f, 0xebe9d39e, 0x1b1c2fa9, 0xc37f7004, 0x749b2035,
- 0x62af5284, 0xa59bd72c, 0xea2a4f06, 0x47169391, 0xfdf9d204, 0x8811a1ae,
- 0x6298c3df, 0xba49ebb9, 0x1f60be07, 0xb5a4ef1f, 0xeee9123d, 0x5211bee4,
- 0x2dcbfef0, 0xe9ba7aca, 0x5e6f1bbb, 0x6fb553c2, 0xe9fb05bb, 0x9f2f1fc1,
- 0xf54ad636, 0xb89df0df, 0x93aced05, 0xc0ddfc19, 0xfe460663, 0xdc3dc2f5,
- 0x70793e4e, 0xfbe0f6f0, 0x7c14d359, 0x7df06474, 0xf5fb0bf5, 0x77dbbd4a,
- 0x3d3d4d31, 0xed4ed7c7, 0x33beac7c, 0x5e7da10f, 0x6744b8f3, 0xf5f46a1d,
- 0x4ffeb8b1, 0x57e769b7, 0x46b9c0ad, 0x0d8d8fef, 0x039ad7a2, 0x21637cdd,
- 0xf2a03f3a, 0xa9f08389, 0x8664f1e2, 0xe765e7c4, 0xecd5f8ef, 0xdd7445dd,
- 0xe3c4be3b, 0x31ef83b7, 0x74be2939, 0xb55a7f19, 0x2dfc821b, 0xbd23bdfa,
- 0x989e686b, 0x9c1f63d2, 0x1a1f942e, 0x987e879b, 0x93ccfc9b, 0x185bec0c,
- 0xebed16b3, 0x891dfa28, 0xd76e38cd, 0xffbd3d3e, 0xb03a6b5f, 0xef23df00,
- 0xc0a30272, 0xe9b6bbbc, 0x4667dfbb, 0x629e773b, 0xf0ea7ee7, 0x7fa04be4,
- 0xb489976b, 0x923d9abe, 0x5c17cf0f, 0x57dee450, 0x406f937b, 0x2e39ad7a,
- 0x9a3fd159, 0x70fc96d8, 0x77e92e61, 0xdaeb57b2, 0xb75c9db8, 0x58bb205b,
- 0x156a43b5, 0x629ce43b, 0xd65b9f07, 0x57e3edc9, 0xea11b604, 0x7b030dad,
- 0x9b5de604, 0xdaec8539, 0xcadd695a, 0x473c0ec1, 0xe61bb5a5, 0xe7443c1f,
- 0xd1cec0ae, 0xaddc2f94, 0x69b6d7cd, 0xf8bfaaf3, 0x3b6ed8d2, 0x37fa3863,
- 0x1c615225, 0x0a9bc3f2, 0xe77f555e, 0xf49c6bce, 0xe80f27fb, 0xb8d4531c,
- 0xd16bc204, 0xc7cc2f2b, 0xc26afb79, 0x347fe49c, 0xdae096fe, 0xd7ee17f1,
- 0x1bdee074, 0xf0e333f2, 0xe9cfd8ed, 0xf05e917c, 0x2cbaefe1, 0xfd815d42,
- 0x32df0499, 0xbb7b3b8c, 0x293e4922, 0xca1a08e7, 0x632affb9, 0xb2a6180c,
- 0xe7f72c7e, 0x38eaf543, 0x0e8a405d, 0xb1811392, 0xd8af5429, 0xde57cfc0,
- 0xfd24e119, 0xedc4c436, 0x6e2621f5, 0x75d10faf, 0x85dfa32e, 0x7df02418,
- 0x6997ac8e, 0x9d6d60ff, 0x0417f685, 0xe10e957b, 0x955076b1, 0x887de90e,
- 0xfd032db5, 0x8c5f353a, 0xec7b33df, 0x478b5283, 0x8cece387, 0x047d9417,
- 0x74cb4fae, 0x90747d56, 0x996c657e, 0x3dea7e66, 0x7e7d9fcc, 0xa59f9856,
- 0xef807e67, 0x75ff6c28, 0x86ec93ae, 0xf7f532a4, 0x2e49ea1a, 0x12fcf0a8,
- 0x7018bde8, 0x816c7745, 0x1db66a6e, 0x96b2ff22, 0x76c4afb5, 0x1d7c91a5,
- 0xbefe06a5, 0x4f186951, 0xfcb8e375, 0xa5d2512a, 0xc3f6b4e3, 0x7eb27191,
- 0xc63ba41c, 0xf2e34db9, 0x79953f68, 0x6f0d7d61, 0x43d677f3, 0x13943ee5,
- 0x7c0d7d3d, 0x466ff288, 0xd54d60bd, 0xbf9c69d8, 0x6ea2f116, 0xf6f85a3e,
- 0xea27c493, 0xc66acc39, 0xa3667bf9, 0xc41a9ad9, 0xdf908b17, 0xc377ded0,
- 0x138c7cbf, 0xeb6abff0, 0xe9973a7c, 0xa2b58c69, 0xfa48b75f, 0x7e25f692,
- 0xda2ddf2c, 0xcdfbcdaf, 0x11fdfe9c, 0x1949f902, 0x0de3bae3, 0x0a498fc4,
- 0x08f76c7f, 0xfb600e74, 0xcf1e3a77, 0x7e2810ab, 0x36143377, 0x624994da,
- 0xba22eabd, 0xe333724f, 0x4b596347, 0x3dbbf28c, 0x796fb431, 0x9beeb293,
- 0x2843fe75, 0xdbea8e57, 0x749e3192, 0xc4e4d6b4, 0x1b59cbfe, 0xc15a6fbd,
- 0x153d29da, 0x9fa2f75e, 0x2226f73a, 0x63c9fddd, 0xf6d678a4, 0x50223be5,
- 0xe5b167be, 0x044fdc56, 0xb7c6ec50, 0x73b3fb01, 0xd51df742, 0x2f60c4fb,
- 0x027d21c7, 0x1d2127fe, 0xd8dc079c, 0x5fb77a73, 0x2317c7f8, 0x2c5f7f11,
- 0x5b96e179, 0x9d5ffa19, 0xa82d47e4, 0x5df7465f, 0x33da9c81, 0xaaf07bf2,
- 0x5bc55de2, 0xf01d5e37, 0xb0af182f, 0x938404a6, 0xc91965f4, 0xe8917fa5,
- 0xf0e5d69c, 0xbc7dc2aa, 0x0e3b9f82, 0x8a15f970, 0xb70f156f, 0x43f5bbe2,
- 0x236eef49, 0xc923313c, 0xb87a50cb, 0x3080be1c, 0xc4d93ce9, 0xa1f92318,
- 0x4f2e4583, 0x2813cf07, 0xf33b795e, 0xf48012bc, 0xf5f7f096, 0xc70adefc,
- 0xb782855b, 0x2fdf313f, 0x71ff9232, 0xce323b78, 0x606e34dd, 0xe50dbe6f,
- 0xb2f8fed3, 0x37fce1c6, 0x18fa5f55, 0x3f0863f2, 0x376bf087, 0x2ff09d1e,
- 0xc69e8f08, 0x6ecbe248, 0xae7b4b7c, 0x7fe22f4c, 0x5fb58e30, 0xaf93f9f0,
- 0x46055f80, 0xf8f8bfbf, 0x54dead38, 0xa5c2a6f1, 0x07e0b8bf, 0x2ad47fcc,
- 0xe70abed0, 0x748dbbe3, 0x57dd43ff, 0x5e4ff751, 0x5cf5c719, 0xd801fa68,
- 0xb55fb84b, 0x40e4e326, 0x194f33b4, 0xfef87ed4, 0xdacb07ef, 0xb6f7f113,
- 0xe9e2283e, 0xddff0329, 0x872f350f, 0x07e4b8f1, 0xc22f46f1, 0xf86103e9,
- 0x1f33d404, 0xcf5cf708, 0x070671f3, 0x26e3cbe6, 0x53903de0, 0x798e357a,
- 0xf07f12bf, 0x8f9479f1, 0x027aa62c, 0x074a5dff, 0xf61ddefe, 0x1736082b,
- 0xbb83e7cc, 0x9d7de8d2, 0x718d7dee, 0x467f0edc, 0xdc774759, 0xe2815eff,
- 0x355133fe, 0x84c4fee1, 0x877c2e2d, 0x437df4f3, 0xb4df69b3, 0xea3e3b41,
- 0x978a64fd, 0xfee7e06e, 0xabea752e, 0xb75bf482, 0xc8be2dbe, 0xd1e4e7cb,
- 0xbfa88cef, 0x86db2747, 0xc7dcff73, 0xd550df7f, 0x5fc75d67, 0x73c704b0,
- 0xdfe2533f, 0x0fe1f9dd, 0xc3eb0526, 0x4dad4f43, 0x0daa7ec7, 0x05a72cde,
- 0xb1ee877f, 0xaa5bb424, 0x4e955a9f, 0x0f53f4f6, 0x545fa3a4, 0xba6d63bd,
- 0x0f70f94c, 0xbe3a65f9, 0x1b9e2fee, 0xd4f3e745, 0xdccaf6fe, 0x1d30a8af,
- 0x3dbd412a, 0x56afeae5, 0xda41fee0, 0xffc5027d, 0x15f6b066, 0x332b67a8,
- 0x16b15f38, 0xe87fc913, 0x776bf68f, 0x4ec5ff0d, 0x646f0794, 0x81cfd59c,
- 0x203e127a, 0xd5df1035, 0xdfa3adf2, 0x7fcd5c09, 0x7ea7b027, 0x56ffed22,
- 0x9de8172d, 0xfcf519ab, 0xf1a4f377, 0x59c704d1, 0xd18fb3ab, 0x794b57fb,
- 0x6fa314f9, 0x67ec49df, 0x3fdf818b, 0xe094ee64, 0xb29270fb, 0x9d73385f,
- 0xca717bf2, 0x639b6938, 0x53af07b7, 0x591df652, 0xdf2477ea, 0x32f0506e,
- 0x5789e975, 0x54efd0ed, 0x1e3cc7bd, 0xe9b3bfbe, 0x619faa5c, 0x3a33f41c,
- 0xf066985f, 0xd71f3a3c, 0x7148c3bd, 0xc1acdcd2, 0xcfd41c52, 0x11b45259,
- 0xab4b99d3, 0x728f9d1e, 0xcd94d5b8, 0xf9f2358f, 0x114e0835, 0xed91f4e5,
- 0xb842ceb7, 0x7fc4df9d, 0xfb61abff, 0xc2ddfa30, 0xafdee4fe, 0xf9eff89a,
- 0xa264dd3d, 0x2b26d9f4, 0xcfeba3c3, 0xff29d935, 0x4a0e4daf, 0xcd3cf4d9,
- 0xd7f4d8ef, 0xe14b88df, 0xb973bbf4, 0x3bf4cdab, 0x39460d88, 0x2bc03c75,
- 0x1ddaaaed, 0xc2eb280f, 0xbdb2b8f7, 0x0e1113c9, 0x3e2c0fb9, 0x75b3a686,
- 0x7d97df3c, 0x24eae4f3, 0x2c77d614, 0x7cc4f33d, 0x78fb7ef8, 0x270835f7,
- 0x148bb6d3, 0x607238a7, 0xbbc22555, 0xaf91877a, 0xf9f7594f, 0x8f71e94d,
- 0x75f97c62, 0x160dc53d, 0xc4f33b6d, 0x877f0c03, 0x9821b177, 0xbd74afde,
- 0x7ee78f57, 0xaaf8e5e6, 0x78fc383f, 0x449b5abe, 0xf803b3fc, 0xf3a7f32a,
- 0xcba5a2d5, 0xc6cb7e08, 0xb8426fbb, 0x937bd79d, 0x0fce9f90, 0xee744b1f,
- 0xf820457d, 0xdbbc72ab, 0xbfe056af, 0x575b6c50, 0xc723dc98, 0x04b961bf,
- 0x3e0743df, 0xf9fb474d, 0x3fe5fd9b, 0x6097eeb8, 0x1861fedd, 0x1a5133af,
- 0xe0df3dfa, 0xf584ea19, 0x3ef3f7e5, 0x6af1d2e8, 0x539f9ffc, 0x36213fc0,
- 0xe6219df8, 0xd4f9828d, 0x61fc141c, 0x26cfa859, 0xbf43a67d, 0x8fcffc11,
- 0x198ce734, 0x9f4828fb, 0xcbdf37f7, 0x4fd875a5, 0x1ddc8f5a, 0xfcc89ef9,
- 0x547b7a41, 0x83f98c20, 0x73f6edc6, 0xfb40cca0, 0x1724f14e, 0x2e786f10,
- 0xe181c2ec, 0x99ff303b, 0xc2f1e381, 0xf14f604b, 0xf2931078, 0xd9f9d67b,
- 0x50b22f81, 0xb7ae86ce, 0x882fe5ee, 0xaff66a3e, 0xfad028ba, 0xcba67f27,
- 0x0ffafcba, 0x1645f53d, 0x7d33efe2, 0xb6fd1f20, 0x1640860b, 0xb7eea1e2,
- 0x58ff9e5c, 0xf3e5a838, 0xf7e81b57, 0x1304eb3a, 0xf48949d1, 0x2e1fc525,
- 0x87f1e71c, 0x924f03ba, 0xc83aed3c, 0xc48b40e3, 0x8c38d2f6, 0x399fd49b,
- 0xcbacf286, 0xe831fdce, 0x2b71de9f, 0x41e8aa1c, 0xde12675d, 0x4dd83bf7,
- 0x3c8fdc0f, 0x0c3bfc8f, 0xf3a369fb, 0x9c2b2cbd, 0x39f15da1, 0x7c30f3f2,
- 0x257930bf, 0xdf79f9d2, 0x8f941cc0, 0xadfd666f, 0xbf86e28e, 0xb27ba70f,
- 0xe6926db5, 0x3af7799c, 0x703f127c, 0x29fb54c4, 0xe7c1c99c, 0x1b8e0cb9,
- 0x837e6ec8, 0xba2e13ef, 0x7b13f38a, 0xed53f399, 0x7b0643f2, 0x15bb7f50,
- 0xc8ed527e, 0x1bffbf29, 0x85b3e5f1, 0xd504fd32, 0xffc7a54f, 0x4cf7fe9f,
- 0x33412fff, 0x800063ec, 0x00008000, 0x00088b1f, 0x00000000, 0x5aa5ff00,
- 0x5554700d, 0xbdef3e96, 0xdd2749fe, 0x12421349, 0x42068408, 0x03621a88,
- 0xc4d67281, 0x206efce9, 0x6b01bb33, 0x8d08c42d, 0x749d2422, 0x6aece882,
- 0x021a6eb9, 0x367564ac, 0x1d47598c, 0x809f9b47, 0x9476ec28, 0x0da0c040,
- 0x6ba2cb0a, 0x3a26aa45, 0xab545b55, 0xa6e00eac, 0xd63b8223, 0x3be7b8e2,
- 0x1dddb5ef, 0xa6ed4fe2, 0xee7dba8a, 0x9ee7b9cf, 0xce77ce7b, 0x52b48f3d,
- 0x6a22ca22, 0x2a08cdcf, 0x6ea6ff0a, 0x6d4445a2, 0xf67f2429, 0xaf1f4541,
- 0x7dbc64d3, 0x58c9a340, 0xce08eb93, 0x4754419e, 0x459a26dd, 0x654284b4,
- 0x29bf71a4, 0x795bcbf2, 0x6d0dfebc, 0x61931741, 0xb06aad1b, 0x7aa6d513,
- 0x1314360b, 0xaacaab0d, 0x0bcc6286, 0x4b9d2e95, 0x7efe0df4, 0x879b744a,
- 0x2a224f99, 0xf60f14d3, 0x169c9d1b, 0x8b5dc9dc, 0x491bfb97, 0xeaa7984d,
- 0x534f98f3, 0xa3827c08, 0xd81d4b25, 0x9964b468, 0x8eef3e23, 0x07d6d237,
- 0xd2a14e31, 0xf9f6123b, 0x68858f4b, 0xcb17d121, 0x650faa17, 0xdaae79f2,
- 0x51337403, 0x29ed768d, 0x70ddf785, 0x05564ccc, 0xafbc67fc, 0x670239f2,
- 0xfa65ea34, 0x790a4752, 0x4bceccac, 0x1bcf0f1e, 0xd8293b99, 0x3f6fe7c5,
- 0xe78990a0, 0xeeb11db5, 0x6d79e14c, 0x9bb648e6, 0xf036ddf7, 0xdb878b3b,
- 0x2cf7fef6, 0xcf58b9ae, 0x9e433647, 0x6dfa1514, 0x174ff277, 0xce607f91,
- 0x3f3177fb, 0xf44d69ff, 0x67bd37ed, 0x05d7d621, 0x5afd8f9e, 0x82d5f60e,
- 0x56f0a56e, 0x3cfdda27, 0x9bbf48af, 0xe5dff86f, 0xb386575c, 0xf8be7e38,
- 0xa7a25d39, 0x69f8bd18, 0xd602f73e, 0x43eb468b, 0x21ee5976, 0x6e717b96,
- 0x252e8ece, 0x5fae9d71, 0x4b69768f, 0x9d15cb0e, 0x6615b8a9, 0x6c0d4d15,
- 0x851f4276, 0x1797b38a, 0xb97f5f47, 0x9bf42d74, 0x9dbd2c12, 0x90b517cf,
- 0xc7e2c7dc, 0x04b49bb6, 0x6a0f1679, 0x3443dc1e, 0xc90e9a95, 0xe2a77bbd,
- 0x61bca83e, 0xd61267a9, 0x2b7bbe8d, 0x7955196f, 0x73fafdbd, 0x7975ca04,
- 0xc9a9b0ce, 0xd7721b7d, 0x80ede5e7, 0xc400d9fe, 0xfaa94e8e, 0xc7951efe,
- 0xbfd7c7e7, 0x46a79c68, 0xf089ce2b, 0x9dc506f8, 0x9f671ce3, 0xf587bb58,
- 0xe9ef86be, 0xb46fbe45, 0x6938752f, 0xfda26ccd, 0xff42b91d, 0xda4b8773,
- 0xf4914750, 0x16e1d2bf, 0x2dc760fa, 0xf0ea1f42, 0x51d03d08, 0x8ed1ed27,
- 0x033fe906, 0x708cff51, 0xe2ec20a0, 0x4a6d7c14, 0x1cce1e9c, 0x9e494f43,
- 0x24a99c3f, 0x991453d3, 0x3cb870ff, 0xa5fa6018, 0x939ca732, 0xc0d1ca8d,
- 0x4b4e68fa, 0xb40ca12f, 0x674a41f9, 0x037bb1bb, 0x3ffbb61e, 0x43daedd4,
- 0x4bcfc533, 0xf33aaf30, 0xdbf846ce, 0x692b2ce5, 0x1ec3cfac, 0xde63dfef,
- 0x0555d3e9, 0x683fd1db, 0xfef95b73, 0x94dc5787, 0xff47bd01, 0xb78d234d,
- 0xb05a28ae, 0x0ae994b9, 0xcc7622bb, 0xc86e6efc, 0x4fc6bb66, 0xb83553e6,
- 0xe3a4d4ba, 0x02b67384, 0xc1aeb7fd, 0xdb261b3e, 0xfc795816, 0x57f7b94a,
- 0xf7a627d8, 0x0aeb29da, 0xd98bd0bc, 0xf3cabef5, 0xa66eff02, 0x80f79e5e,
- 0xdf649dc3, 0x822bcb47, 0x45c59bb0, 0x07cf36b3, 0xd9ba767f, 0xf5bb3fbc,
- 0x51e7c87e, 0xc14e94d3, 0xb8099731, 0xf3fdc410, 0x452e953e, 0x716c30ec,
- 0x7f993299, 0x2b22b538, 0x194eebc0, 0xb8da7df7, 0x7dc633ef, 0xd5fdc3bf,
- 0xfdcbbedc, 0x1fb88768, 0x9e988aed, 0xd085a34d, 0x0da7f05f, 0xef44792f,
- 0xa3a0f9a3, 0x3b0e5a66, 0xd33f025c, 0x81bf27f1, 0x5ca278e5, 0x036ee397,
- 0x6b6e867f, 0x85d7d3e8, 0x858b4f84, 0x4bffb0bc, 0x9f609f58, 0xf5f175b1,
- 0x9bb2ed24, 0xe7c29029, 0x20b6c3a0, 0x895344f4, 0x0ecb5f80, 0x692e08e7,
- 0xcf8ab329, 0x017a644f, 0xabd29e09, 0xae5e7d56, 0x85fc216b, 0x8cfb2475,
- 0x9980d504, 0x399fc4ed, 0xf2c99854, 0x167e188e, 0x49fd0fa3, 0xcff6fc13,
- 0xd7db9a67, 0xfe7cfd14, 0x13854365, 0xa9b15eb0, 0x4eff33b0, 0xe1acfc7d,
- 0x0699fe87, 0x943ce33f, 0x7dc7ca12, 0xce1d8f44, 0x2ee987bf, 0x1ead787b,
- 0x8285c207, 0x5c2e14df, 0x42549c06, 0xd44dc8e7, 0xaf7dfc77, 0x47d027e9,
- 0xfdd079e8, 0xd3af7fc7, 0x6739df4a, 0x50a4f8e2, 0xfd04e2be, 0x3df74181,
- 0x409dc13f, 0x87395f9b, 0xdfa6cb71, 0x3327ab7b, 0xa783586e, 0xff37603b,
- 0xed97dba2, 0xd027ff40, 0x2b11cb5b, 0x0f2b2ec1, 0x0af67ff4, 0x3bf4b78f,
- 0xa8fb80dc, 0xbbe88667, 0xc7dec8f3, 0x7d236f61, 0xae87f166, 0xfe7bbffd,
- 0x25679911, 0x35bd5b98, 0xcfbc4a54, 0xe37fe3d1, 0xb49f6135, 0x6fd015d0,
- 0x39179c57, 0xfeea27ea, 0xa9f1543d, 0xf5bd0037, 0xc46bf81f, 0x0a0cfab5,
- 0x65e96ec0, 0xe46647be, 0x6a86f57b, 0xc771e12a, 0x6ff04ad0, 0x86eac97b,
- 0xcd5efa9d, 0x5f1f84a9, 0xfb14ccf3, 0x3bb1be6b, 0x3d57711f, 0x23cf6fba,
- 0x23679859, 0xc99edbc8, 0xf57ac476, 0xdd163b69, 0x6bb7f72f, 0xf7206fcf,
- 0x64ed1b3e, 0x03cccd3e, 0x99ef35fb, 0xd1f00c1d, 0xe3fafb5e, 0x1a87b895,
- 0xe83db9ed, 0xa6dbb2bf, 0x2d670f42, 0xf8728c9e, 0xbbb359e1, 0xba0ceb17,
- 0x2ea27879, 0x56a45a4f, 0x3bab2fee, 0x37d7711f, 0x80bfe1f1, 0xf75af5dc,
- 0x3ce2cff3, 0x3884ad7b, 0xeb1f6171, 0xe85dd78d, 0x2dc7cf35, 0x9873ec8f,
- 0x94972f60, 0x82cf95ee, 0xef3eaf7f, 0xf45bad92, 0x439de819, 0x11e78fd8,
- 0x6525f2e2, 0x85ff527b, 0x5e25bdde, 0x97c5dfd6, 0x09bd8bea, 0x17f31bf6,
- 0x526b6edf, 0x6024147c, 0xbf19f25c, 0x3b2019c9, 0x8366dfc7, 0x99e878bc,
- 0xbe296791, 0x737ee2fe, 0x6a3ac2d8, 0x94e6d2b6, 0xf83fb8cc, 0x0ebcfef2,
- 0x3ba9f3e7, 0x34c7910a, 0x84ac882f, 0x51b05c5f, 0x7bcf2e4a, 0xbe5f88db,
- 0x2a971b83, 0x4f2ddf25, 0xc7ee854d, 0x38f57357, 0x16c07576, 0x1ddf280c,
- 0x83a3fe8f, 0x8eccef9c, 0x67af77d3, 0x7e71297e, 0xad425b6f, 0x2db7de6e,
- 0x738fc753, 0xe33f7f3c, 0xcfb19558, 0xe79287aa, 0x299152df, 0x8966d3f6,
- 0xc60e2214, 0x88ac2ff8, 0x10a45ae1, 0x5d763578, 0xe013d23d, 0xe08acbc8,
- 0xf2a0ef88, 0xa86e96a1, 0x4fae3b34, 0xa8204a5f, 0x0f7f8c95, 0x7b8c8bb9,
- 0x55ef5e60, 0xdbe57ee8, 0x98d8f36f, 0x246a4b4f, 0xab53791d, 0x7c8e9223,
- 0x46a8e468, 0xcbeb8d3b, 0x199ff18a, 0x4649afdf, 0xf6643fb8, 0x8fdbc6d8,
- 0x6f3c438f, 0x2ab37e1d, 0xfdd0a93e, 0x4d2069a6, 0x646723f6, 0xe9b6ec11,
- 0x3875e4b9, 0x1fc133a7, 0x65760647, 0x8fe2137b, 0xaa3b90cf, 0x137e287c,
- 0x7ca3fafd, 0xa54f81d8, 0xf6ab0acd, 0x65b1af22, 0x3a294d0a, 0xe5b1b01d,
- 0xa7b4befb, 0x5e2e7ec2, 0x1e3f156d, 0x73822251, 0x0aae27b9, 0x23988c3e,
- 0xca8e7382, 0x18fc11ff, 0x09591099, 0xb4adcadc, 0xc9f196af, 0x1e2e9591,
- 0xa0c2b2ff, 0x03e491a7, 0x57322785, 0xb5ea4f03, 0x3711b7d1, 0x09d99769,
- 0x7be9893f, 0xa227a19d, 0x783b86c7, 0xb3410ffc, 0x4e61f10b, 0x0be462a5,
- 0xb5f9f896, 0x908d3fb8, 0xf841c0eb, 0xdddd9367, 0xfdc1a32b, 0xbc1f20af,
- 0xe5dddb33, 0x326f5eba, 0xcacae587, 0xee2d6afc, 0xfbdd3b29, 0xdfcc158f,
- 0x07c91c5f, 0x4bb5b1ce, 0xdd7b6a1c, 0x47fb13ba, 0x807ba3cd, 0xde1c175f,
- 0x9f582b27, 0xada196ad, 0x67d22ca5, 0xa429c8e6, 0x6f604bf8, 0xbdba2382,
- 0xb2ef148d, 0x561e9f08, 0x9767eb2a, 0x4b940f71, 0xa1f603b4, 0xe6fcf7e8,
- 0x00efabc0, 0x6686466f, 0xf58f4e09, 0x4f030ba7, 0x3e3703a6, 0x981ef8e0,
- 0x60ffef13, 0xfa0b5ef5, 0xc3b8bf97, 0x9ef6e112, 0xbbe7c9cd, 0x0cf6ed7c,
- 0x9e3d0bf8, 0xec7b0fd0, 0xeac7a649, 0x4e197605, 0xe88083f2, 0x29c79cfd,
- 0x0e54b7f2, 0xdf0f41b5, 0xd698cbd2, 0x6313e812, 0xa9f331e8, 0xce1fcf41,
- 0xb6f84879, 0x430f0b4e, 0xcc07236f, 0xe4ef7c04, 0x7f7426b8, 0x1aef105a,
- 0xadc700f5, 0x216e3d2c, 0x0fa4b45e, 0x8cbdc4ad, 0x989d5bf4, 0xa7c8e9bf,
- 0xdb3f38f9, 0xdbce3e63, 0x3670e472, 0xf78dcec1, 0x6cc7c704, 0x1ff4b78c,
- 0x24bbc6c9, 0x86aadfd6, 0x4717210a, 0x47e012b8, 0x85afdfac, 0x8b7f210b,
- 0xf1825432, 0xf996e428, 0x49a06b4c, 0xe8aad1ce, 0x34474f7e, 0xf7b1f9c1,
- 0x6e8551f6, 0x250f8caf, 0x1d3707c8, 0xb11254bd, 0xd9a0f1c7, 0xe81395c0,
- 0xdffdd62f, 0x09c0c8b9, 0xbf0cda5e, 0xbc27071f, 0xf5a3dc31, 0xae7dc816,
- 0xb63b9742, 0x3bcaf85e, 0x6de32023, 0x992a5daf, 0xc6758c59, 0xa3c04a3c,
- 0x017c7159, 0x0e0ae40e, 0xf367326c, 0x2bcf7cb9, 0xd25e4eee, 0x96b1b8dc,
- 0xd33ad3a7, 0x6bd0b5fd, 0x5de40513, 0xb1ae5637, 0x8570f476, 0x553ebf7e,
- 0xf6fb8f7f, 0x964ec128, 0x7d6322eb, 0x9bc17cee, 0x5d67f030, 0xf85ac6f5,
- 0x7e597ddf, 0xf9bbe24b, 0xedaff887, 0xadd7a649, 0x339b58df, 0x1efb9f8e,
- 0x126a7eda, 0xd9afcf5d, 0xdb36a3bb, 0x4c7f7d75, 0x98b68bee, 0x49e6959c,
- 0xbe58fa89, 0xb71276b1, 0xaffe52eb, 0x7dcfd0fa, 0x8c3588f1, 0xb5facbb8,
- 0xfdb7fce0, 0x0925bd71, 0x5f807fb7, 0x9d6b0533, 0xfe5bbe33, 0x12ab6db1,
- 0x4f80561e, 0xe2bd5fec, 0x0937ec67, 0x18aa6dfb, 0x5a68a753, 0x37791d3d,
- 0x4f4f5779, 0x6d8c53ac, 0xa8a72819, 0x49bd88b7, 0xd2b87ecb, 0x623e8e3d,
- 0xd4ae6ff3, 0x864d9f64, 0x6fa94f1d, 0x1e15e679, 0x53ccb97f, 0x557ec956,
- 0xbf92a9ae, 0xa6a7dd8f, 0x860fcf52, 0x80bf1db2, 0xcd07453d, 0xb949f84e,
- 0x4f33eba6, 0xfc2efcbd, 0xe1db2f31, 0x357e64ea, 0xbcfa6955, 0xea273663,
- 0x5f63d140, 0xffe07be5, 0xa5cbec5b, 0xd3b262ce, 0x953f1e64, 0x3df0573b,
- 0xc6c7cfb6, 0x7aa5693e, 0x645ed3be, 0x533afefe, 0x3adbe3b1, 0xc51be493,
- 0x12d9c169, 0xf890bf87, 0xe85c1d16, 0xf7c05cd4, 0xd6fe1da0, 0x677ff5fe,
- 0x0c8f0e23, 0x0bba67fe, 0xd3ed75b8, 0xb6cfd874, 0x81d38f81, 0x6606270f,
- 0x1d9ed039, 0x1fd03972, 0x16b8fbad, 0x368cbaf3, 0x8b30675e, 0xf636b19c,
- 0x13d58e7e, 0xcdd1de12, 0x73af6bd0, 0x614b2fdb, 0x82dda9ef, 0xce8efc63,
- 0xd788fc44, 0xe3395c19, 0xeb1265d5, 0xf5b3050c, 0xd45a033a, 0x7acc0a19,
- 0xea34019d, 0x6751680c, 0x0cea3f40, 0x006751a0, 0x68033a8d, 0xa2d019d4,
- 0x2bfe80ce, 0xbcb16ba8, 0x50de4e51, 0xecd1aadf, 0xf40fff82, 0xf5e4416a,
- 0x74d31c0f, 0xc412877a, 0xfbc67f7d, 0xaf460e23, 0x28b075e8, 0xe77953c7,
- 0xfbcb341f, 0x5eda1a20, 0xd6f71337, 0x5571b9af, 0xd9371117, 0xa3cddb14,
- 0x6a1f5127, 0x1bdc53ef, 0x2e5fe85d, 0x5c1b6c72, 0xfa237ef8, 0xd56ecd7b,
- 0x9abafb85, 0x6f97fa8d, 0x58ea57b0, 0x2cc739d5, 0x15fbcf72, 0xeffde1ca,
- 0x64efeab0, 0x2cbdc6bf, 0x9545b0f7, 0x1d6fda3c, 0xcb4bf792, 0x4d738a8b,
- 0x7eda1e42, 0x1382e7cb, 0x9df4b69d, 0xb21fd790, 0xc524d739, 0x7de48f57,
- 0xc174fc7e, 0x45433c8d, 0xa7d5af4c, 0x7b5edf90, 0xf9213801, 0xb47e4248,
- 0x33fcd9d6, 0x5da467e4, 0x7efce133, 0x644ee87e, 0x6d3dd6f9, 0xb09228fe,
- 0x9930737f, 0x6df60df6, 0x99c823cd, 0x034a8fdc, 0x943fb2e2, 0x74aa1fdc,
- 0xc6927d64, 0x3cd1e63f, 0xff755be4, 0x3f40e6b4, 0xdbb977ef, 0x61caf92a,
- 0x2570f78f, 0xb349f1fb, 0x272fea47, 0xbde4d98f, 0x9cfb7e75, 0x8d4bfaa4,
- 0x1fea5536, 0xc48acc1b, 0xdee52bf1, 0xaacbb063, 0xeea57bba, 0x10eb9552,
- 0xe1d98e7f, 0x3786f2d1, 0x5cc377c0, 0x6abfd497, 0xe10bf4ac, 0xf72f7ec7,
- 0x7f16683c, 0x8254e9ab, 0xc9abd32a, 0xad7f816d, 0x3d8a7562, 0x298fed99,
- 0x78ab0fec, 0xbb04c6af, 0x915db0da, 0x100a42bc, 0x8695e7ac, 0xfe0d573e,
- 0xfb0a57eb, 0x3d56bdcb, 0x5553ce0f, 0xc5d79fe1, 0xdfe78b71, 0xfc0b5e47,
- 0x55c71d66, 0x5f671cb4, 0x37bf708f, 0x9ebe6a6d, 0xc072bbe7, 0x3319f57f,
- 0x726a4f01, 0x95e85e7e, 0xfced5f78, 0x095bef84, 0x737da5df, 0xa8e1f7d3,
- 0xc8493e89, 0x759a4f6b, 0xca7d61fc, 0xec14eb7b, 0x5e3eea55, 0x3474cf69,
- 0x8ca2bb49, 0x340bffc4, 0xe02f6f3d, 0x4a6672bb, 0xeb0fa2dd, 0x6eedda6b,
- 0x0b863fe8, 0xbefc8dbb, 0xe796e540, 0x5bd54eed, 0xdc29d30b, 0xca5b8d3f,
- 0xe7617e14, 0x5c71d47c, 0x3d4f3fc2, 0x7d05c0bb, 0x4377697c, 0xc739351f,
- 0x31dde1e6, 0x72ffe0cb, 0xdc55c359, 0x029d2797, 0x438f9fd8, 0x5adfacdd,
- 0x5d41481c, 0x50d1e43d, 0x38a63f27, 0x1ebfaef1, 0x716fb74f, 0x140acfc2,
- 0xb5b7ea27, 0xd935dda9, 0xe676bfcc, 0x9cf0370c, 0x61ea55f1, 0x76eadc23,
- 0x53506b70, 0x6ca6b5f4, 0xff0df3d4, 0x54a6f729, 0xd7f78a4d, 0x1d147e1b,
- 0xf11d22fc, 0x6dd447f5, 0x807f8377, 0x835eee6c, 0xfea0ec3f, 0xbf5269a6,
- 0xe5d1d98d, 0x613b39fd, 0xf4ab5347, 0xef8d8d75, 0x0c4f9199, 0xc1cde6dd,
- 0x7cd72bfe, 0xce5b25be, 0x8cbd7e39, 0xb8033771, 0x165eb63b, 0x463df1c3,
- 0x6b781dfd, 0x26baea32, 0x326baea3, 0xa326baea, 0xea326bae, 0xaea326ba,
- 0xbaea326b, 0x6baea326, 0x26baea32, 0x97ae13a9, 0x878eddf6, 0x08ea1da4,
- 0xbc4278c8, 0xc7eab9b8, 0x55175dd5, 0xa577538d, 0xc4865714, 0xbd7bf65d,
- 0xcea63dde, 0x26aefeca, 0xe0d57bf8, 0x431e7b84, 0x7163d25e, 0x6b5438b3,
- 0x603c16f1, 0x54f07c17, 0x8d6f5b8d, 0xf52ecfe9, 0x9b64cbd9, 0x2ca87b8f,
- 0x5152659a, 0x23ee34c7, 0xdf84ef56, 0x1bf09ce0, 0xd31bf0b4, 0xfcdfb8ec,
- 0x5daec2d6, 0x0109e7aa, 0x726c13c9, 0x32375bbf, 0x2f7d30ae, 0xe5709339,
- 0xc2b831b3, 0x90159a0f, 0x95a0ed63, 0x233f74ba, 0x37254ff8, 0x0e3f9c7f,
- 0x9c7484ce, 0xda1a9699, 0xb5a67d87, 0x1791baa5, 0x9d8bbfb3, 0x88a6dc9d,
- 0x06a1afbf, 0xbc1c77d9, 0x7c9e4749, 0x73d1c4ef, 0xf7f9e1bf, 0xf25d83fe,
- 0xd793ad9d, 0xe0fffa2e, 0xae954d4d, 0x84775f8f, 0x9659e77d, 0x43b654ea,
- 0x16d5578e, 0xb8ba922a, 0x50fe2a9a, 0x58ae3da3, 0xd377a380, 0xb577dc3c,
- 0xc839e1b5, 0x2efec399, 0xa32cdfef, 0x6a1a6bbe, 0xd9f4cbde, 0xbe373cec,
- 0x3dcd4dab, 0x800b0544, 0xb0c57547, 0xadd4b3ab, 0x1963dd60, 0xbf83bfde,
- 0xa7cc5edc, 0x96fee356, 0xb3b69753, 0xce63ee4b, 0x32fbdc42, 0xf51fabab,
- 0x9e6f2d86, 0xb2c27a90, 0xd442d70c, 0x79bcb61b, 0x5c73a75a, 0xe51b8afd,
- 0xabab13b2, 0x66f8827f, 0x109f3eeb, 0x09a1fd67, 0xc0fb7449, 0x09f3eee4,
- 0x3f05ae71, 0x3f4e9df8, 0xafb84c53, 0x5c944356, 0xf21dbbd5, 0x4bfeebf9,
- 0xa8d3cf7f, 0xaaa7c9c4, 0x749c5c74, 0xe7b0c282, 0xf90ec5d1, 0x713397fe,
- 0xdbd43cfd, 0x10b5d8a8, 0xfdaf38f3, 0xe2f8ec35, 0xc1a79ead, 0x7738cf27,
- 0x3579f10e, 0x0d90c758, 0xbbe319ed, 0xdbd529e4, 0x3d36b688, 0x357e9260,
- 0x6df68a58, 0xfa20f435, 0x81762fd9, 0xf393ed4f, 0x3a622c6e, 0xb79a1acf,
- 0xe9788ede, 0x73fe8dd9, 0xec5e9e65, 0xdfeeb637, 0xe58f9c69, 0xc37987d9,
- 0xf9e4aa85, 0x6dea37c3, 0x55c22ecc, 0x371d0e3a, 0x93aca8fc, 0x58e7fbe4,
- 0xa55e39fb, 0xfdf9781a, 0x47bcb372, 0x7e4c4f20, 0x0a5d5eea, 0xa3de5879,
- 0x61afbc86, 0x5299ec9c, 0x7b6ef98f, 0xc77ec80d, 0x7c653b0d, 0xe3af396c,
- 0xa685b4a3, 0x0de404e0, 0x4e0d1e53, 0x7653bc80, 0xdc5cda8c, 0xb51810be,
- 0xe1787f21, 0xe86d476f, 0x7543c17f, 0x56bfe1e3, 0xc2df09ad, 0x3f5951b2,
- 0x921af79d, 0x04e8c277, 0x4d856fe4, 0x6c02596f, 0xe69e73b7, 0xb7f2937d,
- 0xd3638922, 0xfe9a5b0d, 0x87b04aa8, 0xe490cfe9, 0x259d54ab, 0xdd14bee3,
- 0x3e8f7dff, 0x6e8ec2a8, 0x09dcb208, 0x69e737f6, 0x1248e5d3, 0x6bacb0df,
- 0xf3837031, 0x3f71a4b5, 0x3cbe4733, 0xe423c0c5, 0x378c8d8f, 0xbeb7a6fe,
- 0x79c8be42, 0x8c7e18dc, 0x261c314d, 0xebef5dc4, 0x20fc1711, 0xbbdade79,
- 0xf78ad91e, 0x76e3536d, 0xd78fbc8b, 0xdb456df4, 0x259efada, 0x4cbf2487,
- 0x65f9cf9a, 0x9c9d7d12, 0x7b68e463, 0x39adf3f0, 0x76cbece3, 0x0ed12d70,
- 0x37439a4e, 0xd27abde0, 0x480eea9f, 0x0fdd091c, 0x6ad9d97c, 0xecae2377,
- 0xd8a555fa, 0xa9f5b7d7, 0xfaa98f32, 0xa751d947, 0x52540fcc, 0x87e6fc11,
- 0xe1e011da, 0x0c3c24ec, 0x8972dd48, 0xddae7043, 0xadb60778, 0x123e4a71,
- 0x5336ebf3, 0x98adc3e8, 0xef90e597, 0x45b70c11, 0x6f7c2ca6, 0x4aeee29a,
- 0x2ece2bc8, 0x9d041599, 0x830a19dd, 0x15cfe8ef, 0xd5c8ea37, 0xd6ae3a69,
- 0x7bad0da8, 0x352dfc79, 0x5bf1b82c, 0x6ff307e0, 0x7697acb7, 0xb14cd945,
- 0x290a5cdb, 0x7067fffa, 0x3d7bc42d, 0x67ad3df6, 0x20efb05b, 0xf04afbde,
- 0x8fa8b599, 0xe45d95fe, 0x80d50689, 0x33d3cf99, 0x7bb70481, 0xb8942cee,
- 0xc686a513, 0x2cff91fb, 0x6a3a954f, 0x13d704cf, 0xd3da6ef8, 0xf5e4a37c,
- 0xc7a4fe87, 0x29a5d1fb, 0x3d71e46e, 0x711b5cf3, 0x5d479eae, 0xa29afe32,
- 0xa13c0bf3, 0xa967a7eb, 0xe69ece7e, 0xc59f794c, 0x8767a1ee, 0xbfbe3267,
- 0xe5bc3259, 0x1803a8d5, 0x667b1fdf, 0x4fb73f70, 0xde770d29, 0x75733e07,
- 0xb9945779, 0xde4edee4, 0x7b13e379, 0xf1867d74, 0x897dac1d, 0xfefde923,
- 0xcb80febf, 0x002220b3, 0x00000000
-};
-
-#endif /*__BNX2X_INIT_VALUES_H__*/
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index ad5ef25add3e..e01539c33b8a 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -53,12 +53,19 @@
#include "bnx2x.h"
#include "bnx2x_init.h"
+#include "bnx2x_init_ops.h"
#include "bnx2x_dump.h"
-#define DRV_MODULE_VERSION "1.48.105"
-#define DRV_MODULE_RELDATE "2009/03/02"
+#define DRV_MODULE_VERSION "1.48.105-1"
+#define DRV_MODULE_RELDATE "2009/04/22"
#define BNX2X_BC_VER 0x040200
+#include <linux/firmware.h>
+#include "bnx2x_fw_file_hdr.h"
+/* FW files */
+#define FW_FILE_PREFIX_E1 "bnx2x-e1-"
+#define FW_FILE_PREFIX_E1H "bnx2x-e1h-"
+
/* Time in jiffies before concluding the transmitter is hung */
#define TX_TIMEOUT (5*HZ)
@@ -1539,7 +1546,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
len, cqe, comp_ring_cons);
#ifdef BNX2X_STOP_ON_ERROR
if (bp->panic)
- return -EINVAL;
+ return 0;
#endif
bnx2x_update_sge_prod(fp,
@@ -5232,13 +5239,15 @@ static void bnx2x_gunzip_end(struct bnx2x *bp)
}
}
-static int bnx2x_gunzip(struct bnx2x *bp, u8 *zbuf, int len)
+static int bnx2x_gunzip(struct bnx2x *bp, const u8 *zbuf, int len)
{
int n, rc;
/* check gzip header */
- if ((zbuf[0] != 0x1f) || (zbuf[1] != 0x8b) || (zbuf[2] != Z_DEFLATED))
+ if ((zbuf[0] != 0x1f) || (zbuf[1] != 0x8b) || (zbuf[2] != Z_DEFLATED)) {
+ BNX2X_ERR("Bad gzip header\n");
return -EINVAL;
+ }
n = 10;
@@ -5247,7 +5256,7 @@ static int bnx2x_gunzip(struct bnx2x *bp, u8 *zbuf, int len)
if (zbuf[3] & FNAME)
while ((zbuf[n++] != 0) && (n < len));
- bp->strm->next_in = zbuf + n;
+ bp->strm->next_in = (typeof(bp->strm->next_in))zbuf + n;
bp->strm->avail_in = len - n;
bp->strm->next_out = bp->gunzip_buf;
bp->strm->avail_out = FW_BUF_SIZE;
@@ -5369,8 +5378,8 @@ static int bnx2x_int_mem_test(struct bnx2x *bp)
msleep(50);
REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0x03);
msleep(50);
- bnx2x_init_block(bp, BRB1_COMMON_START, BRB1_COMMON_END);
- bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END);
+ bnx2x_init_block(bp, BRB1_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, PRS_BLOCK, COMMON_STAGE);
DP(NETIF_MSG_HW, "part2\n");
@@ -5434,8 +5443,8 @@ static int bnx2x_int_mem_test(struct bnx2x *bp)
msleep(50);
REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0x03);
msleep(50);
- bnx2x_init_block(bp, BRB1_COMMON_START, BRB1_COMMON_END);
- bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END);
+ bnx2x_init_block(bp, BRB1_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, PRS_BLOCK, COMMON_STAGE);
#ifndef BCM_ISCSI
/* set NIC mode */
REG_WR(bp, PRS_REG_NIC_MODE, 1);
@@ -5510,7 +5519,7 @@ static int bnx2x_init_common(struct bnx2x *bp)
REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0xffffffff);
REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, 0xfffc);
- bnx2x_init_block(bp, MISC_COMMON_START, MISC_COMMON_END);
+ bnx2x_init_block(bp, MISC_BLOCK, COMMON_STAGE);
if (CHIP_IS_E1H(bp))
REG_WR(bp, MISC_REG_E1HMF_MODE, IS_E1HMF(bp));
@@ -5518,14 +5527,14 @@ static int bnx2x_init_common(struct bnx2x *bp)
msleep(30);
REG_WR(bp, MISC_REG_LCPLL_CTRL_REG_2, 0x0);
- bnx2x_init_block(bp, PXP_COMMON_START, PXP_COMMON_END);
+ bnx2x_init_block(bp, PXP_BLOCK, COMMON_STAGE);
if (CHIP_IS_E1(bp)) {
/* enable HW interrupt from PXP on USDM overflow
bit 16 on INT_MASK_0 */
REG_WR(bp, PXP_REG_PXP_INT_MASK_0, 0);
}
- bnx2x_init_block(bp, PXP2_COMMON_START, PXP2_COMMON_END);
+ bnx2x_init_block(bp, PXP2_BLOCK, COMMON_STAGE);
bnx2x_init_pxp(bp);
#ifdef __BIG_ENDIAN
@@ -5571,60 +5580,60 @@ static int bnx2x_init_common(struct bnx2x *bp)
REG_WR(bp, PXP2_REG_RQ_DISABLE_INPUTS, 0);
REG_WR(bp, PXP2_REG_RD_DISABLE_INPUTS, 0);
- bnx2x_init_block(bp, DMAE_COMMON_START, DMAE_COMMON_END);
+ bnx2x_init_block(bp, DMAE_BLOCK, COMMON_STAGE);
/* clean the DMAE memory */
bp->dmae_ready = 1;
bnx2x_init_fill(bp, TSEM_REG_PRAM, 0, 8);
- bnx2x_init_block(bp, TCM_COMMON_START, TCM_COMMON_END);
- bnx2x_init_block(bp, UCM_COMMON_START, UCM_COMMON_END);
- bnx2x_init_block(bp, CCM_COMMON_START, CCM_COMMON_END);
- bnx2x_init_block(bp, XCM_COMMON_START, XCM_COMMON_END);
+ bnx2x_init_block(bp, TCM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, UCM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, CCM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, XCM_BLOCK, COMMON_STAGE);
bnx2x_read_dmae(bp, XSEM_REG_PASSIVE_BUFFER, 3);
bnx2x_read_dmae(bp, CSEM_REG_PASSIVE_BUFFER, 3);
bnx2x_read_dmae(bp, TSEM_REG_PASSIVE_BUFFER, 3);
bnx2x_read_dmae(bp, USEM_REG_PASSIVE_BUFFER, 3);
- bnx2x_init_block(bp, QM_COMMON_START, QM_COMMON_END);
+ bnx2x_init_block(bp, QM_BLOCK, COMMON_STAGE);
/* soft reset pulse */
REG_WR(bp, QM_REG_SOFT_RESET, 1);
REG_WR(bp, QM_REG_SOFT_RESET, 0);
#ifdef BCM_ISCSI
- bnx2x_init_block(bp, TIMERS_COMMON_START, TIMERS_COMMON_END);
+ bnx2x_init_block(bp, TIMERS_BLOCK, COMMON_STAGE);
#endif
- bnx2x_init_block(bp, DQ_COMMON_START, DQ_COMMON_END);
+ bnx2x_init_block(bp, DQ_BLOCK, COMMON_STAGE);
REG_WR(bp, DORQ_REG_DPM_CID_OFST, BCM_PAGE_SHIFT);
if (!CHIP_REV_IS_SLOW(bp)) {
/* enable hw interrupt from doorbell Q */
REG_WR(bp, DORQ_REG_DORQ_INT_MASK, 0);
}
- bnx2x_init_block(bp, BRB1_COMMON_START, BRB1_COMMON_END);
- bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END);
+ bnx2x_init_block(bp, BRB1_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, PRS_BLOCK, COMMON_STAGE);
REG_WR(bp, PRS_REG_A_PRSU_20, 0xf);
/* set NIC mode */
REG_WR(bp, PRS_REG_NIC_MODE, 1);
if (CHIP_IS_E1H(bp))
REG_WR(bp, PRS_REG_E1HOV_MODE, IS_E1HMF(bp));
- bnx2x_init_block(bp, TSDM_COMMON_START, TSDM_COMMON_END);
- bnx2x_init_block(bp, CSDM_COMMON_START, CSDM_COMMON_END);
- bnx2x_init_block(bp, USDM_COMMON_START, USDM_COMMON_END);
- bnx2x_init_block(bp, XSDM_COMMON_START, XSDM_COMMON_END);
+ bnx2x_init_block(bp, TSDM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, CSDM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, USDM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, XSDM_BLOCK, COMMON_STAGE);
bnx2x_init_fill(bp, TSTORM_INTMEM_ADDR, 0, STORM_INTMEM_SIZE(bp));
bnx2x_init_fill(bp, USTORM_INTMEM_ADDR, 0, STORM_INTMEM_SIZE(bp));
bnx2x_init_fill(bp, CSTORM_INTMEM_ADDR, 0, STORM_INTMEM_SIZE(bp));
bnx2x_init_fill(bp, XSTORM_INTMEM_ADDR, 0, STORM_INTMEM_SIZE(bp));
- bnx2x_init_block(bp, TSEM_COMMON_START, TSEM_COMMON_END);
- bnx2x_init_block(bp, USEM_COMMON_START, USEM_COMMON_END);
- bnx2x_init_block(bp, CSEM_COMMON_START, CSEM_COMMON_END);
- bnx2x_init_block(bp, XSEM_COMMON_START, XSEM_COMMON_END);
+ bnx2x_init_block(bp, TSEM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, USEM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, CSEM_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, XSEM_BLOCK, COMMON_STAGE);
/* sync semi rtc */
REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR,
@@ -5632,16 +5641,16 @@ static int bnx2x_init_common(struct bnx2x *bp)
REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET,
0x80000000);
- bnx2x_init_block(bp, UPB_COMMON_START, UPB_COMMON_END);
- bnx2x_init_block(bp, XPB_COMMON_START, XPB_COMMON_END);
- bnx2x_init_block(bp, PBF_COMMON_START, PBF_COMMON_END);
+ bnx2x_init_block(bp, UPB_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, XPB_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, PBF_BLOCK, COMMON_STAGE);
REG_WR(bp, SRC_REG_SOFT_RST, 1);
for (i = SRC_REG_KEYRSS0_0; i <= SRC_REG_KEYRSS1_9; i += 4) {
REG_WR(bp, i, 0xc0cac01a);
/* TODO: replace with something meaningful */
}
- bnx2x_init_block(bp, SRCH_COMMON_START, SRCH_COMMON_END);
+ bnx2x_init_block(bp, SRCH_BLOCK, COMMON_STAGE);
REG_WR(bp, SRC_REG_SOFT_RST, 0);
if (sizeof(union cdu_context) != 1024)
@@ -5649,7 +5658,7 @@ static int bnx2x_init_common(struct bnx2x *bp)
printk(KERN_ALERT PFX "please adjust the size of"
" cdu_context(%ld)\n", (long)sizeof(union cdu_context));
- bnx2x_init_block(bp, CDU_COMMON_START, CDU_COMMON_END);
+ bnx2x_init_block(bp, CDU_BLOCK, COMMON_STAGE);
val = (4 << 24) + (0 << 12) + 1024;
REG_WR(bp, CDU_REG_CDU_GLOBAL_PARAMS, val);
if (CHIP_IS_E1(bp)) {
@@ -5658,7 +5667,7 @@ static int bnx2x_init_common(struct bnx2x *bp)
REG_WR(bp, CDU_REG_CDU_DEBUG, 0);
}
- bnx2x_init_block(bp, CFC_COMMON_START, CFC_COMMON_END);
+ bnx2x_init_block(bp, CFC_BLOCK, COMMON_STAGE);
REG_WR(bp, CFC_REG_INIT_REG, 0x7FF);
/* enable context validation interrupt from CFC */
REG_WR(bp, CFC_REG_CFC_INT_MASK, 0);
@@ -5666,20 +5675,25 @@ static int bnx2x_init_common(struct bnx2x *bp)
/* set the thresholds to prevent CFC/CDU race */
REG_WR(bp, CFC_REG_DEBUG0, 0x20020000);
- bnx2x_init_block(bp, HC_COMMON_START, HC_COMMON_END);
- bnx2x_init_block(bp, MISC_AEU_COMMON_START, MISC_AEU_COMMON_END);
+ bnx2x_init_block(bp, HC_BLOCK, COMMON_STAGE);
+ bnx2x_init_block(bp, MISC_AEU_BLOCK, COMMON_STAGE);
/* PXPCS COMMON comes here */
+ bnx2x_init_block(bp, PXPCS_BLOCK, COMMON_STAGE);
/* Reset PCIE errors for debug */
REG_WR(bp, 0x2814, 0xffffffff);
REG_WR(bp, 0x3820, 0xffffffff);
/* EMAC0 COMMON comes here */
+ bnx2x_init_block(bp, EMAC0_BLOCK, COMMON_STAGE);
/* EMAC1 COMMON comes here */
+ bnx2x_init_block(bp, EMAC1_BLOCK, COMMON_STAGE);
/* DBU COMMON comes here */
+ bnx2x_init_block(bp, DBU_BLOCK, COMMON_STAGE);
/* DBG COMMON comes here */
+ bnx2x_init_block(bp, DBG_BLOCK, COMMON_STAGE);
- bnx2x_init_block(bp, NIG_COMMON_START, NIG_COMMON_END);
+ bnx2x_init_block(bp, NIG_BLOCK, COMMON_STAGE);
if (CHIP_IS_E1H(bp)) {
REG_WR(bp, NIG_REG_LLH_MF_MODE, IS_E1HMF(bp));
REG_WR(bp, NIG_REG_LLH_E1HOV_MODE, IS_E1HMF(bp));
@@ -5763,6 +5777,7 @@ static int bnx2x_init_common(struct bnx2x *bp)
static int bnx2x_init_port(struct bnx2x *bp)
{
int port = BP_PORT(bp);
+ int init_stage = port ? PORT1_STAGE : PORT0_STAGE;
u32 low, high;
u32 val;
@@ -5771,7 +5786,9 @@ static int bnx2x_init_port(struct bnx2x *bp)
REG_WR(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 0);
/* Port PXP comes here */
+ bnx2x_init_block(bp, PXP_BLOCK, init_stage);
/* Port PXP2 comes here */
+ bnx2x_init_block(bp, PXP2_BLOCK, init_stage);
#ifdef BCM_ISCSI
/* Port0 1
* Port1 385 */
@@ -5798,21 +5815,19 @@ static int bnx2x_init_port(struct bnx2x *bp)
REG_WR(bp, PXP2_REG_PSWRQ_SRC0_L2P + func*4, PXP_ONE_ILT(i));
#endif
/* Port CMs come here */
- bnx2x_init_block(bp, (port ? XCM_PORT1_START : XCM_PORT0_START),
- (port ? XCM_PORT1_END : XCM_PORT0_END));
+ bnx2x_init_block(bp, XCM_BLOCK, init_stage);
/* Port QM comes here */
#ifdef BCM_ISCSI
REG_WR(bp, TM_REG_LIN0_SCAN_TIME + func*4, 1024/64*20);
REG_WR(bp, TM_REG_LIN0_MAX_ACTIVE_CID + func*4, 31);
- bnx2x_init_block(bp, func ? TIMERS_PORT1_START : TIMERS_PORT0_START,
- func ? TIMERS_PORT1_END : TIMERS_PORT0_END);
+ bnx2x_init_block(bp, TIMERS_BLOCK, init_stage);
#endif
/* Port DQ comes here */
+ bnx2x_init_block(bp, DQ_BLOCK, init_stage);
- bnx2x_init_block(bp, (port ? BRB1_PORT1_START : BRB1_PORT0_START),
- (port ? BRB1_PORT1_END : BRB1_PORT0_END));
+ bnx2x_init_block(bp, BRB1_BLOCK, init_stage);
if (CHIP_REV_IS_SLOW(bp) && !CHIP_IS_E1H(bp)) {
/* no pause for emulation and FPGA */
low = 0;
@@ -5837,25 +5852,27 @@ static int bnx2x_init_port(struct bnx2x *bp)
/* Port PRS comes here */
+ bnx2x_init_block(bp, PRS_BLOCK, init_stage);
/* Port TSDM comes here */
+ bnx2x_init_block(bp, TSDM_BLOCK, init_stage);
/* Port CSDM comes here */
+ bnx2x_init_block(bp, CSDM_BLOCK, init_stage);
/* Port USDM comes here */
+ bnx2x_init_block(bp, USDM_BLOCK, init_stage);
/* Port XSDM comes here */
+ bnx2x_init_block(bp, XSDM_BLOCK, init_stage);
- bnx2x_init_block(bp, port ? TSEM_PORT1_START : TSEM_PORT0_START,
- port ? TSEM_PORT1_END : TSEM_PORT0_END);
- bnx2x_init_block(bp, port ? USEM_PORT1_START : USEM_PORT0_START,
- port ? USEM_PORT1_END : USEM_PORT0_END);
- bnx2x_init_block(bp, port ? CSEM_PORT1_START : CSEM_PORT0_START,
- port ? CSEM_PORT1_END : CSEM_PORT0_END);
- bnx2x_init_block(bp, port ? XSEM_PORT1_START : XSEM_PORT0_START,
- port ? XSEM_PORT1_END : XSEM_PORT0_END);
+ bnx2x_init_block(bp, TSEM_BLOCK, init_stage);
+ bnx2x_init_block(bp, USEM_BLOCK, init_stage);
+ bnx2x_init_block(bp, CSEM_BLOCK, init_stage);
+ bnx2x_init_block(bp, XSEM_BLOCK, init_stage);
/* Port UPB comes here */
+ bnx2x_init_block(bp, UPB_BLOCK, init_stage);
/* Port XPB comes here */
+ bnx2x_init_block(bp, XPB_BLOCK, init_stage);
- bnx2x_init_block(bp, port ? PBF_PORT1_START : PBF_PORT0_START,
- port ? PBF_PORT1_END : PBF_PORT0_END);
+ bnx2x_init_block(bp, PBF_BLOCK, init_stage);
/* configure PBF to work without PAUSE mtu 9000 */
REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0);
@@ -5885,18 +5902,17 @@ static int bnx2x_init_port(struct bnx2x *bp)
/* Port SRCH comes here */
#endif
/* Port CDU comes here */
+ bnx2x_init_block(bp, CDU_BLOCK, init_stage);
/* Port CFC comes here */
+ bnx2x_init_block(bp, CFC_BLOCK, init_stage);
if (CHIP_IS_E1(bp)) {
REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, 0);
REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, 0);
}
- bnx2x_init_block(bp, port ? HC_PORT1_START : HC_PORT0_START,
- port ? HC_PORT1_END : HC_PORT0_END);
+ bnx2x_init_block(bp, HC_BLOCK, init_stage);
- bnx2x_init_block(bp, port ? MISC_AEU_PORT1_START :
- MISC_AEU_PORT0_START,
- port ? MISC_AEU_PORT1_END : MISC_AEU_PORT0_END);
+ bnx2x_init_block(bp, MISC_AEU_BLOCK, init_stage);
/* init aeu_mask_attn_func_0/1:
* - SF mode: bits 3-7 are masked. only bits 0-2 are in use
* - MF mode: bit 3 is masked. bits 0-2 are in use as in SF
@@ -5905,13 +5921,17 @@ static int bnx2x_init_port(struct bnx2x *bp)
(IS_E1HMF(bp) ? 0xF7 : 0x7));
/* Port PXPCS comes here */
+ bnx2x_init_block(bp, PXPCS_BLOCK, init_stage);
/* Port EMAC0 comes here */
+ bnx2x_init_block(bp, EMAC0_BLOCK, init_stage);
/* Port EMAC1 comes here */
+ bnx2x_init_block(bp, EMAC1_BLOCK, init_stage);
/* Port DBU comes here */
+ bnx2x_init_block(bp, DBU_BLOCK, init_stage);
/* Port DBG comes here */
+ bnx2x_init_block(bp, DBG_BLOCK, init_stage);
- bnx2x_init_block(bp, port ? NIG_PORT1_START : NIG_PORT0_START,
- port ? NIG_PORT1_END : NIG_PORT0_END);
+ bnx2x_init_block(bp, NIG_BLOCK, init_stage);
REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1);
@@ -5931,7 +5951,9 @@ static int bnx2x_init_port(struct bnx2x *bp)
}
/* Port MCP comes here */
+ bnx2x_init_block(bp, MCP_BLOCK, init_stage);
/* Port DMAE comes here */
+ bnx2x_init_block(bp, DMAE_BLOCK, init_stage);
switch (XGXS_EXT_PHY_TYPE(bp->link_params.ext_phy_config)) {
case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726:
@@ -6036,7 +6058,7 @@ static int bnx2x_init_func(struct bnx2x *bp)
if (CHIP_IS_E1H(bp)) {
for (i = 0; i < 9; i++)
bnx2x_init_block(bp,
- cm_start[func][i], cm_end[func][i]);
+ cm_blocks[i], FUNC0_STAGE + func);
REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 1);
REG_WR(bp, NIG_REG_LLH0_FUNC_VLAN_ID + port*8, bp->e1hov);
@@ -6049,7 +6071,7 @@ static int bnx2x_init_func(struct bnx2x *bp)
REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, 0);
REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, 0);
}
- bnx2x_init_block(bp, hc_limits[func][0], hc_limits[func][1]);
+ bnx2x_init_block(bp, HC_BLOCK, FUNC0_STAGE + func);
/* Reset PCIE errors for debug */
REG_WR(bp, 0x2114, 0xffffffff);
@@ -11082,6 +11104,190 @@ static int __devinit bnx2x_get_pcie_speed(struct bnx2x *bp)
val = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
return val;
}
+static int __devinit bnx2x_check_firmware(struct bnx2x *bp)
+{
+ struct bnx2x_fw_file_hdr *fw_hdr;
+ struct bnx2x_fw_file_section *sections;
+ u16 *ops_offsets;
+ u32 offset, len, num_ops;
+ int i;
+ const struct firmware *firmware = bp->firmware;
+ const u8 * fw_ver;
+
+ if (firmware->size < sizeof(struct bnx2x_fw_file_hdr))
+ return -EINVAL;
+
+ fw_hdr = (struct bnx2x_fw_file_hdr *)firmware->data;
+ sections = (struct bnx2x_fw_file_section *)fw_hdr;
+
+ /* Make sure none of the offsets and sizes make us read beyond
+ * the end of the firmware data */
+ for (i = 0; i < sizeof(*fw_hdr) / sizeof(*sections); i++) {
+ offset = be32_to_cpu(sections[i].offset);
+ len = be32_to_cpu(sections[i].len);
+ if (offset + len > firmware->size) {
+ printk(KERN_ERR PFX "Section %d length is out of bounds\n", i);
+ return -EINVAL;
+ }
+ }
+
+ /* Likewise for the init_ops offsets */
+ offset = be32_to_cpu(fw_hdr->init_ops_offsets.offset);
+ ops_offsets = (u16 *)(firmware->data + offset);
+ num_ops = be32_to_cpu(fw_hdr->init_ops.len) / sizeof(struct raw_op);
+
+ for (i = 0; i < be32_to_cpu(fw_hdr->init_ops_offsets.len) / 2; i++) {
+ if (be16_to_cpu(ops_offsets[i]) > num_ops) {
+ printk(KERN_ERR PFX "Section offset %d is out of bounds\n", i);
+ return -EINVAL;
+ }
+ }
+
+ /* Check FW version */
+ offset = be32_to_cpu(fw_hdr->fw_version.offset);
+ fw_ver = firmware->data + offset;
+ if ((fw_ver[0] != BCM_5710_FW_MAJOR_VERSION) ||
+ (fw_ver[1] != BCM_5710_FW_MINOR_VERSION) ||
+ (fw_ver[2] != BCM_5710_FW_REVISION_VERSION) ||
+ (fw_ver[3] != BCM_5710_FW_ENGINEERING_VERSION)) {
+ printk(KERN_ERR PFX "Bad FW version:%d.%d.%d.%d."
+ " Should be %d.%d.%d.%d\n",
+ fw_ver[0], fw_ver[1], fw_ver[2],
+ fw_ver[3], BCM_5710_FW_MAJOR_VERSION,
+ BCM_5710_FW_MINOR_VERSION,
+ BCM_5710_FW_REVISION_VERSION,
+ BCM_5710_FW_ENGINEERING_VERSION);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static void inline be32_to_cpu_n(const u8 *_source, u8 *_target, u32 n)
+{
+ u32 i;
+ const __be32 *source = (const __be32*)_source;
+ u32 *target = (u32*)_target;
+
+ for (i = 0; i < n/4; i++)
+ target[i] = be32_to_cpu(source[i]);
+}
+
+/*
+ Ops array is stored in the following format:
+ {op(8bit), offset(24bit, big endian), data(32bit, big endian)}
+ */
+static void inline bnx2x_prep_ops(const u8 *_source, u8 *_target, u32 n)
+{
+ u32 i, j, tmp;
+ const __be32 *source = (const __be32*)_source;
+ struct raw_op *target = (struct raw_op*)_target;
+
+ for (i = 0, j = 0; i < n/8; i++, j+=2) {
+ tmp = be32_to_cpu(source[j]);
+ target[i].op = (tmp >> 24) & 0xff;
+ target[i].offset = tmp & 0xffffff;
+ target[i].raw_data = be32_to_cpu(source[j+1]);
+ }
+}
+static void inline be16_to_cpu_n(const u8 *_source, u8 *_target, u32 n)
+{
+ u32 i;
+ u16 *target = (u16*)_target;
+ const __be16 *source = (const __be16*)_source;
+
+ for (i = 0; i < n/2; i++)
+ target[i] = be16_to_cpu(source[i]);
+}
+
+#define BNX2X_ALLOC_AND_SET(arr, lbl, func) \
+ do { \
+ u32 len = be32_to_cpu(fw_hdr->arr.len); \
+ bp->arr = kmalloc(len, GFP_KERNEL); \
+ if (!bp->arr) { \
+ printk(KERN_ERR PFX "Failed to allocate %d bytes for "#arr"\n", len); \
+ goto lbl; \
+ } \
+ func(bp->firmware->data + \
+ be32_to_cpu(fw_hdr->arr.offset), \
+ (u8*)bp->arr, len); \
+ } while (0)
+
+
+static int __devinit bnx2x_init_firmware(struct bnx2x *bp, struct device *dev)
+{
+ char fw_file_name[40] = {0};
+ int rc, offset;
+ struct bnx2x_fw_file_hdr *fw_hdr;
+
+ /* Create a FW file name */
+ if (CHIP_IS_E1(bp))
+ offset = sprintf(fw_file_name, FW_FILE_PREFIX_E1);
+ else
+ offset = sprintf(fw_file_name, FW_FILE_PREFIX_E1H);
+
+ sprintf(fw_file_name + offset, "%d.%d.%d.%d.fw",
+ BCM_5710_FW_MAJOR_VERSION,
+ BCM_5710_FW_MINOR_VERSION,
+ BCM_5710_FW_REVISION_VERSION,
+ BCM_5710_FW_ENGINEERING_VERSION);
+
+ printk(KERN_INFO PFX "Loading %s\n", fw_file_name);
+
+ rc = request_firmware(&bp->firmware, fw_file_name, dev);
+ if (rc) {
+ printk(KERN_ERR PFX "Can't load firmware file %s\n", fw_file_name);
+ goto request_firmware_exit;
+ }
+
+ rc = bnx2x_check_firmware(bp);
+ if (rc) {
+ printk(KERN_ERR PFX "Corrupt firmware file %s\n", fw_file_name);
+ goto request_firmware_exit;
+ }
+
+ fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data;
+
+ /* Initialize the pointers to the init arrays */
+ /* Blob */
+ BNX2X_ALLOC_AND_SET(init_data, request_firmware_exit, be32_to_cpu_n);
+
+ /* Opcodes */
+ BNX2X_ALLOC_AND_SET(init_ops, init_ops_alloc_err, bnx2x_prep_ops);
+
+ /* Offsets */
+ BNX2X_ALLOC_AND_SET(init_ops_offsets, init_offsets_alloc_err, be16_to_cpu_n);
+
+ /* STORMs firmware */
+ bp->tsem_int_table_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->tsem_int_table_data.offset);
+ bp->tsem_pram_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->tsem_pram_data.offset);
+ bp->usem_int_table_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->usem_int_table_data.offset);
+ bp->usem_pram_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->usem_pram_data.offset);
+ bp->xsem_int_table_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->xsem_int_table_data.offset);
+ bp->xsem_pram_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->xsem_pram_data.offset);
+ bp->csem_int_table_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->csem_int_table_data.offset);
+ bp->csem_pram_data = bp->firmware->data +
+ be32_to_cpu(fw_hdr->csem_pram_data.offset);
+
+ return 0;
+init_offsets_alloc_err:
+ kfree(bp->init_ops);
+init_ops_alloc_err:
+ kfree(bp->init_data);
+request_firmware_exit:
+ release_firmware(bp->firmware);
+
+ return rc;
+}
+
+
static int __devinit bnx2x_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
@@ -11116,6 +11322,13 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
if (rc)
goto init_one_exit;
+ /* Set init arrays */
+ rc = bnx2x_init_firmware(bp, &pdev->dev);
+ if (rc) {
+ printk(KERN_ERR PFX "Error loading firmware\n");
+ goto init_one_exit;
+ }
+
rc = register_netdev(dev);
if (rc) {
dev_err(&pdev->dev, "Cannot register net device\n");
@@ -11163,6 +11376,11 @@ static void __devexit bnx2x_remove_one(struct pci_dev *pdev)
unregister_netdev(dev);
+ kfree(bp->init_ops_offsets);
+ kfree(bp->init_ops);
+ kfree(bp->init_data);
+ release_firmware(bp->firmware);
+
if (bp->regview)
iounmap(bp->regview);
@@ -11412,13 +11630,20 @@ static struct pci_driver bnx2x_pci_driver = {
static int __init bnx2x_init(void)
{
+ int ret;
+
bnx2x_wq = create_singlethread_workqueue("bnx2x");
if (bnx2x_wq == NULL) {
printk(KERN_ERR PFX "Cannot create workqueue\n");
return -ENOMEM;
}
- return pci_register_driver(&bnx2x_pci_driver);
+ ret = pci_register_driver(&bnx2x_pci_driver);
+ if (ret) {
+ printk(KERN_ERR PFX "Cannot register driver\n");
+ destroy_workqueue(bnx2x_wq);
+ }
+ return ret;
}
static void __exit bnx2x_cleanup(void)
@@ -11431,3 +11656,4 @@ static void __exit bnx2x_cleanup(void)
module_init(bnx2x_init);
module_exit(bnx2x_cleanup);
+
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index faf094abef7f..d4b570886c6e 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1850,9 +1850,10 @@ static u16 aggregator_identifier;
* Can be called only after the mac address of the bond is set.
*/
void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast)
-{
+{
// check that the bond is not initialized yet
- if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr), &(bond->dev->dev_addr))) {
+ if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr),
+ bond->dev->dev_addr)) {
aggregator_identifier = 0;
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index a306230381c8..2c46a154f2c6 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -26,10 +26,10 @@
#include <asm/byteorder.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
+#include <linux/if_ether.h>
// General definitions
-#define BOND_ETH_P_LACPDU 0x8809
-#define PKT_TYPE_LACPDU cpu_to_be16(BOND_ETH_P_LACPDU)
+#define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
#define AD_TIMER_INTERVAL 100 /*msec*/
#define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 74824028f85c..92a9d69c5650 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -695,6 +695,18 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
if (bond->params.use_carrier)
return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0;
+ /* Try to get link status using Ethtool first. */
+ if (slave_dev->ethtool_ops) {
+ if (slave_dev->ethtool_ops->get_link) {
+ u32 link;
+
+ link = slave_dev->ethtool_ops->get_link(slave_dev);
+
+ return link ? BMSR_LSTATUS : 0;
+ }
+ }
+
+ /* Ethtool can't be used, fallback to MII ioclts. */
ioctl = slave_ops->ndo_do_ioctl;
if (ioctl) {
/* TODO: set pointer to correct ioctl on a per team member */
@@ -721,20 +733,6 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
}
/*
- * Some drivers cache ETHTOOL_GLINK for a period of time so we only
- * attempt to get link status from it if the above MII ioctls fail.
- */
- if (slave_dev->ethtool_ops) {
- if (slave_dev->ethtool_ops->get_link) {
- u32 link;
-
- link = slave_dev->ethtool_ops->get_link(slave_dev);
-
- return link ? BMSR_LSTATUS : 0;
- }
- }
-
- /*
* If reporting, report that either there's no dev->do_ioctl,
* or both SIOCGMIIREG and get_link failed (meaning that we
* cannot report link status). If not reporting, pretend
@@ -2240,6 +2238,9 @@ static int bond_miimon_inspect(struct bonding *bond)
{
struct slave *slave;
int i, link_state, commit = 0;
+ bool ignore_updelay;
+
+ ignore_updelay = !bond->curr_active_slave ? true : false;
bond_for_each_slave(bond, slave, i) {
slave->new_link = BOND_LINK_NOCHANGE;
@@ -2304,6 +2305,7 @@ static int bond_miimon_inspect(struct bonding *bond)
": %s: link status up for "
"interface %s, enabling it in %d ms.\n",
bond->dev->name, slave->dev->name,
+ ignore_updelay ? 0 :
bond->params.updelay *
bond->params.miimon);
}
@@ -2322,9 +2324,13 @@ static int bond_miimon_inspect(struct bonding *bond)
continue;
}
+ if (ignore_updelay)
+ slave->delay = 0;
+
if (slave->delay <= 0) {
slave->new_link = BOND_LINK_UP;
commit++;
+ ignore_updelay = false;
continue;
}
@@ -2789,7 +2795,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
*/
bond_for_each_slave(bond, slave, i) {
if (slave->link != BOND_LINK_UP) {
- if (time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks) &&
+ if (time_before_eq(jiffies, dev_trans_start(slave->dev) + delta_in_ticks) &&
time_before_eq(jiffies, slave->dev->last_rx + delta_in_ticks)) {
slave->link = BOND_LINK_UP;
@@ -2821,7 +2827,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
* when the source ip is 0, so don't take the link down
* if we don't know our ip yet
*/
- if (time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) ||
+ if (time_after_eq(jiffies, dev_trans_start(slave->dev) + 2*delta_in_ticks) ||
(time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks))) {
slave->link = BOND_LINK_DOWN;
@@ -2932,7 +2938,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
* the bond has an IP address)
*/
if ((slave->state == BOND_STATE_ACTIVE) &&
- (time_after_eq(jiffies, slave->dev->trans_start +
+ (time_after_eq(jiffies, dev_trans_start(slave->dev) +
2 * delta_in_ticks) ||
(time_after_eq(jiffies, slave_last_rx(bond, slave)
+ 2 * delta_in_ticks)))) {
@@ -2976,7 +2982,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
write_lock_bh(&bond->curr_slave_lock);
if (!bond->curr_active_slave &&
- time_before_eq(jiffies, slave->dev->trans_start +
+ time_before_eq(jiffies, dev_trans_start(slave->dev) +
delta_in_ticks)) {
slave->link = BOND_LINK_UP;
bond_change_active_slave(bond, slave);
@@ -3453,8 +3459,28 @@ static void bond_destroy_proc_dir(void)
bond_proc_dir = NULL;
}
}
+
+#else /* !CONFIG_PROC_FS */
+
+static int bond_create_proc_entry(struct bonding *bond)
+{
+}
+
+static void bond_remove_proc_entry(struct bonding *bond)
+{
+}
+
+static void bond_create_proc_dir(void)
+{
+}
+
+static void bond_destroy_proc_dir(void)
+{
+}
+
#endif /* CONFIG_PROC_FS */
+
/*-------------------------- netdev event handling --------------------------*/
/*
@@ -3462,10 +3488,8 @@ static void bond_destroy_proc_dir(void)
*/
static int bond_event_changename(struct bonding *bond)
{
-#ifdef CONFIG_PROC_FS
bond_remove_proc_entry(bond);
bond_create_proc_entry(bond);
-#endif
down_write(&(bonding_rwsem));
bond_destroy_sysfs_entry(bond);
bond_create_sysfs_entry(bond);
@@ -4631,9 +4655,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
NETIF_F_HW_VLAN_RX |
NETIF_F_HW_VLAN_FILTER);
-#ifdef CONFIG_PROC_FS
bond_create_proc_entry(bond);
-#endif
list_add_tail(&bond->bond_list, &bond_dev_list);
return 0;
@@ -4671,9 +4693,7 @@ static void bond_deinit(struct net_device *bond_dev)
bond_work_cancel_all(bond);
-#ifdef CONFIG_PROC_FS
bond_remove_proc_entry(bond);
-#endif
}
/* Unregister and free all bond devices.
@@ -4692,9 +4712,7 @@ static void bond_free_all(void)
bond_destroy(bond);
}
-#ifdef CONFIG_PROC_FS
bond_destroy_proc_dir();
-#endif
}
/*------------------------- Module initialization ---------------------------*/
@@ -5130,6 +5148,7 @@ int bond_create(char *name, struct bond_params *params)
goto out_rtnl;
}
+ bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
if (!name) {
res = dev_alloc_name(bond_dev, "bond%d");
if (res < 0)
@@ -5189,9 +5208,7 @@ static int __init bonding_init(void)
goto out;
}
-#ifdef CONFIG_PROC_FS
bond_create_proc_dir();
-#endif
init_rwsem(&bonding_rwsem);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index d28731535226..3a1b7b04eb79 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -251,7 +251,8 @@ static ssize_t bonding_store_slaves(struct device *d,
/* Note: We can't hold bond->lock here, as bond_create grabs it. */
- rtnl_lock();
+ if (!rtnl_trylock())
+ return restart_syscall();
down_write(&(bonding_rwsem));
sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
@@ -1171,7 +1172,8 @@ static ssize_t bonding_store_primary(struct device *d,
struct slave *slave;
struct bonding *bond = to_bond(d);
- rtnl_lock();
+ if (!rtnl_trylock())
+ return restart_syscall();
read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock);
@@ -1288,7 +1290,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
struct slave *new_active = NULL;
struct bonding *bond = to_bond(d);
- rtnl_lock();
+ if (!rtnl_trylock())
+ return restart_syscall();
read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock);
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index 57def0d57371..cfd6c5a285fa 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -12,6 +12,59 @@ config CAN_VCAN
This driver can also be built as a module. If so, the module
will be called vcan.
+config CAN_DEV
+ tristate "Platform CAN drivers with Netlink support"
+ depends on CAN
+ default Y
+ ---help---
+ Enables the common framework for platform CAN drivers with Netlink
+ support. This is the standard library for CAN drivers.
+ If unsure, say Y.
+
+config CAN_CALC_BITTIMING
+ bool "CAN bit-timing calculation"
+ depends on CAN_DEV
+ default Y
+ ---help---
+ If enabled, CAN bit-timing parameters will be calculated for the
+ bit-rate specified via Netlink argument "bitrate" when the device
+ get started. This works fine for the most common CAN controllers
+ with standard bit-rates but may fail for exotic bit-rates or CAN
+ source clock frequencies. Disabling saves some space, but then the
+ bit-timing parameters must be specified directly using the Netlink
+ arguments "tq", "prop_seg", "phase_seg1", "phase_seg2" and "sjw".
+ If unsure, say Y.
+
+config CAN_SJA1000
+ depends on CAN_DEV
+ tristate "Philips SJA1000"
+ ---help---
+ Driver for the SJA1000 CAN controllers from Philips or NXP
+
+config CAN_SJA1000_PLATFORM
+ depends on CAN_SJA1000
+ tristate "Generic Platform Bus based SJA1000 driver"
+ ---help---
+ This driver adds support for the SJA1000 chips connected to
+ the "platform bus" (Linux abstraction for directly to the
+ processor attached devices). Which can be found on various
+ boards from Phytec (http://www.phytec.de) like the PCM027,
+ PCM038.
+
+config CAN_EMS_PCI
+ tristate "EMS CPC-PCI and CPC-PCIe Card"
+ depends on PCI && CAN_SJA1000
+ ---help---
+ This driver is for the one or two channel CPC-PCI and CPC-PCIe
+ cards from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de).
+
+config CAN_KVASER_PCI
+ tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards"
+ depends on PCI && CAN_SJA1000
+ ---help---
+ This driver is for the the PCIcanx and PCIcan cards (1, 2 or
+ 4 channel) from Kvaser (http://www.kvaser.com).
+
config CAN_DEBUG_DEVICES
bool "CAN devices debugging messages"
depends on CAN
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile
index c4bead705cd9..523a941b358b 100644
--- a/drivers/net/can/Makefile
+++ b/drivers/net/can/Makefile
@@ -3,3 +3,10 @@
#
obj-$(CONFIG_CAN_VCAN) += vcan.o
+
+obj-$(CONFIG_CAN_DEV) += can-dev.o
+can-dev-y := dev.o
+
+obj-$(CONFIG_CAN_SJA1000) += sja1000/
+
+ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
new file mode 100644
index 000000000000..52b0e7d8901d
--- /dev/null
+++ b/drivers/net/can/dev.c
@@ -0,0 +1,657 @@
+/*
+ * Copyright (C) 2005 Marc Kleine-Budde, Pengutronix
+ * Copyright (C) 2006 Andrey Volkov, Varma Electronics
+ * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/can/netlink.h>
+#include <net/rtnetlink.h>
+
+#define MOD_DESC "CAN device driver interface"
+
+MODULE_DESCRIPTION(MOD_DESC);
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");
+
+#ifdef CONFIG_CAN_CALC_BITTIMING
+#define CAN_CALC_MAX_ERROR 50 /* in one-tenth of a percent */
+
+/*
+ * Bit-timing calculation derived from:
+ *
+ * Code based on LinCAN sources and H8S2638 project
+ * Copyright 2004-2006 Pavel Pisa - DCE FELK CVUT cz
+ * Copyright 2005 Stanislav Marek
+ * email: pisa@cmp.felk.cvut.cz
+ *
+ * Calculates proper bit-timing parameters for a specified bit-rate
+ * and sample-point, which can then be used to set the bit-timing
+ * registers of the CAN controller. You can find more information
+ * in the header file linux/can/netlink.h.
+ */
+static int can_update_spt(const struct can_bittiming_const *btc,
+ int sampl_pt, int tseg, int *tseg1, int *tseg2)
+{
+ *tseg2 = tseg + 1 - (sampl_pt * (tseg + 1)) / 1000;
+ if (*tseg2 < btc->tseg2_min)
+ *tseg2 = btc->tseg2_min;
+ if (*tseg2 > btc->tseg2_max)
+ *tseg2 = btc->tseg2_max;
+ *tseg1 = tseg - *tseg2;
+ if (*tseg1 > btc->tseg1_max) {
+ *tseg1 = btc->tseg1_max;
+ *tseg2 = tseg - *tseg1;
+ }
+ return 1000 * (tseg + 1 - *tseg2) / (tseg + 1);
+}
+
+static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
+{
+ struct can_priv *priv = netdev_priv(dev);
+ const struct can_bittiming_const *btc = priv->bittiming_const;
+ long rate, best_rate = 0;
+ long best_error = 1000000000, error = 0;
+ int best_tseg = 0, best_brp = 0, brp = 0;
+ int tsegall, tseg = 0, tseg1 = 0, tseg2 = 0;
+ int spt_error = 1000, spt = 0, sampl_pt;
+ u64 v64;
+
+ if (!priv->bittiming_const)
+ return -ENOTSUPP;
+
+ /* Use CIA recommended sample points */
+ if (bt->sample_point) {
+ sampl_pt = bt->sample_point;
+ } else {
+ if (bt->bitrate > 800000)
+ sampl_pt = 750;
+ else if (bt->bitrate > 500000)
+ sampl_pt = 800;
+ else
+ sampl_pt = 875;
+ }
+
+ /* tseg even = round down, odd = round up */
+ for (tseg = (btc->tseg1_max + btc->tseg2_max) * 2 + 1;
+ tseg >= (btc->tseg1_min + btc->tseg2_min) * 2; tseg--) {
+ tsegall = 1 + tseg / 2;
+ /* Compute all possible tseg choices (tseg=tseg1+tseg2) */
+ brp = priv->clock.freq / (tsegall * bt->bitrate) + tseg % 2;
+ /* chose brp step which is possible in system */
+ brp = (brp / btc->brp_inc) * btc->brp_inc;
+ if ((brp < btc->brp_min) || (brp > btc->brp_max))
+ continue;
+ rate = priv->clock.freq / (brp * tsegall);
+ error = bt->bitrate - rate;
+ /* tseg brp biterror */
+ if (error < 0)
+ error = -error;
+ if (error > best_error)
+ continue;
+ best_error = error;
+ if (error == 0) {
+ spt = can_update_spt(btc, sampl_pt, tseg / 2,
+ &tseg1, &tseg2);
+ error = sampl_pt - spt;
+ if (error < 0)
+ error = -error;
+ if (error > spt_error)
+ continue;
+ spt_error = error;
+ }
+ best_tseg = tseg / 2;
+ best_brp = brp;
+ best_rate = rate;
+ if (error == 0)
+ break;
+ }
+
+ if (best_error) {
+ /* Error in one-tenth of a percent */
+ error = (best_error * 1000) / bt->bitrate;
+ if (error > CAN_CALC_MAX_ERROR) {
+ dev_err(dev->dev.parent,
+ "bitrate error %ld.%ld%% too high\n",
+ error / 10, error % 10);
+ return -EDOM;
+ } else {
+ dev_warn(dev->dev.parent, "bitrate error %ld.%ld%%\n",
+ error / 10, error % 10);
+ }
+ }
+
+ /* real sample point */
+ bt->sample_point = can_update_spt(btc, sampl_pt, best_tseg,
+ &tseg1, &tseg2);
+
+ v64 = (u64)best_brp * 1000000000UL;
+ do_div(v64, priv->clock.freq);
+ bt->tq = (u32)v64;
+ bt->prop_seg = tseg1 / 2;
+ bt->phase_seg1 = tseg1 - bt->prop_seg;
+ bt->phase_seg2 = tseg2;
+ bt->sjw = 1;
+ bt->brp = best_brp;
+ /* real bit-rate */
+ bt->bitrate = priv->clock.freq / (bt->brp * (tseg1 + tseg2 + 1));
+
+ return 0;
+}
+#else /* !CONFIG_CAN_CALC_BITTIMING */
+static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
+{
+ dev_err(dev->dev.parent, "bit-timing calculation not available\n");
+ return -EINVAL;
+}
+#endif /* CONFIG_CAN_CALC_BITTIMING */
+
+/*
+ * Checks the validity of the specified bit-timing parameters prop_seg,
+ * phase_seg1, phase_seg2 and sjw and tries to determine the bitrate
+ * prescaler value brp. You can find more information in the header
+ * file linux/can/netlink.h.
+ */
+static int can_fixup_bittiming(struct net_device *dev, struct can_bittiming *bt)
+{
+ struct can_priv *priv = netdev_priv(dev);
+ const struct can_bittiming_const *btc = priv->bittiming_const;
+ int tseg1, alltseg;
+ u64 brp64;
+
+ if (!priv->bittiming_const)
+ return -ENOTSUPP;
+
+ tseg1 = bt->prop_seg + bt->phase_seg1;
+ if (!bt->sjw)
+ bt->sjw = 1;
+ if (bt->sjw > btc->sjw_max ||
+ tseg1 < btc->tseg1_min || tseg1 > btc->tseg1_max ||
+ bt->phase_seg2 < btc->tseg2_min || bt->phase_seg2 > btc->tseg2_max)
+ return -ERANGE;
+
+ brp64 = (u64)priv->clock.freq * (u64)bt->tq;
+ if (btc->brp_inc > 1)
+ do_div(brp64, btc->brp_inc);
+ brp64 += 500000000UL - 1;
+ do_div(brp64, 1000000000UL); /* the practicable BRP */
+ if (btc->brp_inc > 1)
+ brp64 *= btc->brp_inc;
+ bt->brp = (u32)brp64;
+
+ if (bt->brp < btc->brp_min || bt->brp > btc->brp_max)
+ return -EINVAL;
+
+ alltseg = bt->prop_seg + bt->phase_seg1 + bt->phase_seg2 + 1;
+ bt->bitrate = priv->clock.freq / (bt->brp * alltseg);
+ bt->sample_point = ((tseg1 + 1) * 1000) / alltseg;
+
+ return 0;
+}
+
+int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt)
+{
+ struct can_priv *priv = netdev_priv(dev);
+ int err;
+
+ /* Check if the CAN device has bit-timing parameters */
+ if (priv->bittiming_const) {
+
+ /* Non-expert mode? Check if the bitrate has been pre-defined */
+ if (!bt->tq)
+ /* Determine bit-timing parameters */
+ err = can_calc_bittiming(dev, bt);
+ else
+ /* Check bit-timing params and calculate proper brp */
+ err = can_fixup_bittiming(dev, bt);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
+/*
+ * Local echo of CAN messages
+ *
+ * CAN network devices *should* support a local echo functionality
+ * (see Documentation/networking/can.txt). To test the handling of CAN
+ * interfaces that do not support the local echo both driver types are
+ * implemented. In the case that the driver does not support the echo
+ * the IFF_ECHO remains clear in dev->flags. This causes the PF_CAN core
+ * to perform the echo as a fallback solution.
+ */
+static void can_flush_echo_skb(struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ int i;
+
+ for (i = 0; i < CAN_ECHO_SKB_MAX; i++) {
+ if (priv->echo_skb[i]) {
+ kfree_skb(priv->echo_skb[i]);
+ priv->echo_skb[i] = NULL;
+ stats->tx_dropped++;
+ stats->tx_aborted_errors++;
+ }
+ }
+}
+
+/*
+ * Put the skb on the stack to be looped backed locally lateron
+ *
+ * The function is typically called in the start_xmit function
+ * of the device driver. The driver must protect access to
+ * priv->echo_skb, if necessary.
+ */
+void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ /* check flag whether this packet has to be looped back */
+ if (!(dev->flags & IFF_ECHO) || skb->pkt_type != PACKET_LOOPBACK) {
+ kfree_skb(skb);
+ return;
+ }
+
+ if (!priv->echo_skb[idx]) {
+ struct sock *srcsk = skb->sk;
+
+ if (atomic_read(&skb->users) != 1) {
+ struct sk_buff *old_skb = skb;
+
+ skb = skb_clone(old_skb, GFP_ATOMIC);
+ kfree_skb(old_skb);
+ if (!skb)
+ return;
+ } else
+ skb_orphan(skb);
+
+ skb->sk = srcsk;
+
+ /* make settings for echo to reduce code in irq context */
+ skb->protocol = htons(ETH_P_CAN);
+ skb->pkt_type = PACKET_BROADCAST;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb->dev = dev;
+
+ /* save this skb for tx interrupt echo handling */
+ priv->echo_skb[idx] = skb;
+ } else {
+ /* locking problem with netif_stop_queue() ?? */
+ dev_err(dev->dev.parent, "%s: BUG! echo_skb is occupied!\n",
+ __func__);
+ kfree_skb(skb);
+ }
+}
+EXPORT_SYMBOL_GPL(can_put_echo_skb);
+
+/*
+ * Get the skb from the stack and loop it back locally
+ *
+ * The function is typically called when the TX done interrupt
+ * is handled in the device driver. The driver must protect
+ * access to priv->echo_skb, if necessary.
+ */
+void can_get_echo_skb(struct net_device *dev, int idx)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ if ((dev->flags & IFF_ECHO) && priv->echo_skb[idx]) {
+ netif_rx(priv->echo_skb[idx]);
+ priv->echo_skb[idx] = NULL;
+ }
+}
+EXPORT_SYMBOL_GPL(can_get_echo_skb);
+
+/*
+ * CAN device restart for bus-off recovery
+ */
+void can_restart(unsigned long data)
+{
+ struct net_device *dev = (struct net_device *)data;
+ struct can_priv *priv = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ struct sk_buff *skb;
+ struct can_frame *cf;
+ int err;
+
+ BUG_ON(netif_carrier_ok(dev));
+
+ /*
+ * No synchronization needed because the device is bus-off and
+ * no messages can come in or go out.
+ */
+ can_flush_echo_skb(dev);
+
+ /* send restart message upstream */
+ skb = dev_alloc_skb(sizeof(struct can_frame));
+ if (skb == NULL) {
+ err = -ENOMEM;
+ goto out;
+ }
+ skb->dev = dev;
+ skb->protocol = htons(ETH_P_CAN);
+ cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
+ memset(cf, 0, sizeof(struct can_frame));
+ cf->can_id = CAN_ERR_FLAG | CAN_ERR_RESTARTED;
+ cf->can_dlc = CAN_ERR_DLC;
+
+ netif_rx(skb);
+
+ dev->last_rx = jiffies;
+ stats->rx_packets++;
+ stats->rx_bytes += cf->can_dlc;
+
+ dev_dbg(dev->dev.parent, "restarted\n");
+ priv->can_stats.restarts++;
+
+ /* Now restart the device */
+ err = priv->do_set_mode(dev, CAN_MODE_START);
+
+out:
+ netif_carrier_on(dev);
+ if (err)
+ dev_err(dev->dev.parent, "Error %d during restart", err);
+}
+
+int can_restart_now(struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ /*
+ * A manual restart is only permitted if automatic restart is
+ * disabled and the device is in the bus-off state
+ */
+ if (priv->restart_ms)
+ return -EINVAL;
+ if (priv->state != CAN_STATE_BUS_OFF)
+ return -EBUSY;
+
+ /* Runs as soon as possible in the timer context */
+ mod_timer(&priv->restart_timer, jiffies);
+
+ return 0;
+}
+
+/*
+ * CAN bus-off
+ *
+ * This functions should be called when the device goes bus-off to
+ * tell the netif layer that no more packets can be sent or received.
+ * If enabled, a timer is started to trigger bus-off recovery.
+ */
+void can_bus_off(struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ dev_dbg(dev->dev.parent, "bus-off\n");
+
+ netif_carrier_off(dev);
+ priv->can_stats.bus_off++;
+
+ if (priv->restart_ms)
+ mod_timer(&priv->restart_timer,
+ jiffies + (priv->restart_ms * HZ) / 1000);
+}
+EXPORT_SYMBOL_GPL(can_bus_off);
+
+static void can_setup(struct net_device *dev)
+{
+ dev->type = ARPHRD_CAN;
+ dev->mtu = sizeof(struct can_frame);
+ dev->hard_header_len = 0;
+ dev->addr_len = 0;
+ dev->tx_queue_len = 10;
+
+ /* New-style flags. */
+ dev->flags = IFF_NOARP;
+ dev->features = NETIF_F_NO_CSUM;
+}
+
+/*
+ * Allocate and setup space for the CAN network device
+ */
+struct net_device *alloc_candev(int sizeof_priv)
+{
+ struct net_device *dev;
+ struct can_priv *priv;
+
+ dev = alloc_netdev(sizeof_priv, "can%d", can_setup);
+ if (!dev)
+ return NULL;
+
+ priv = netdev_priv(dev);
+
+ priv->state = CAN_STATE_STOPPED;
+
+ init_timer(&priv->restart_timer);
+
+ return dev;
+}
+EXPORT_SYMBOL_GPL(alloc_candev);
+
+/*
+ * Free space of the CAN network device
+ */
+void free_candev(struct net_device *dev)
+{
+ free_netdev(dev);
+}
+EXPORT_SYMBOL_GPL(free_candev);
+
+/*
+ * Common open function when the device gets opened.
+ *
+ * This function should be called in the open function of the device
+ * driver.
+ */
+int open_candev(struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ if (!priv->bittiming.tq && !priv->bittiming.bitrate) {
+ dev_err(dev->dev.parent, "bit-timing not yet defined\n");
+ return -EINVAL;
+ }
+
+ setup_timer(&priv->restart_timer, can_restart, (unsigned long)dev);
+
+ return 0;
+}
+EXPORT_SYMBOL(open_candev);
+
+/*
+ * Common close function for cleanup before the device gets closed.
+ *
+ * This function should be called in the close function of the device
+ * driver.
+ */
+void close_candev(struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ if (del_timer_sync(&priv->restart_timer))
+ dev_put(dev);
+ can_flush_echo_skb(dev);
+}
+EXPORT_SYMBOL_GPL(close_candev);
+
+/*
+ * CAN netlink interface
+ */
+static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
+ [IFLA_CAN_STATE] = { .type = NLA_U32 },
+ [IFLA_CAN_CTRLMODE] = { .len = sizeof(struct can_ctrlmode) },
+ [IFLA_CAN_RESTART_MS] = { .type = NLA_U32 },
+ [IFLA_CAN_RESTART] = { .type = NLA_U32 },
+ [IFLA_CAN_BITTIMING] = { .len = sizeof(struct can_bittiming) },
+ [IFLA_CAN_BITTIMING_CONST]
+ = { .len = sizeof(struct can_bittiming_const) },
+ [IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) },
+};
+
+static int can_changelink(struct net_device *dev,
+ struct nlattr *tb[], struct nlattr *data[])
+{
+ struct can_priv *priv = netdev_priv(dev);
+ int err;
+
+ /* We need synchronization with dev->stop() */
+ ASSERT_RTNL();
+
+ if (data[IFLA_CAN_CTRLMODE]) {
+ struct can_ctrlmode *cm;
+
+ /* Do not allow changing controller mode while running */
+ if (dev->flags & IFF_UP)
+ return -EBUSY;
+ cm = nla_data(data[IFLA_CAN_CTRLMODE]);
+ priv->ctrlmode &= ~cm->mask;
+ priv->ctrlmode |= cm->flags;
+ }
+
+ if (data[IFLA_CAN_BITTIMING]) {
+ struct can_bittiming bt;
+
+ /* Do not allow changing bittiming while running */
+ if (dev->flags & IFF_UP)
+ return -EBUSY;
+ memcpy(&bt, nla_data(data[IFLA_CAN_BITTIMING]), sizeof(bt));
+ if ((!bt.bitrate && !bt.tq) || (bt.bitrate && bt.tq))
+ return -EINVAL;
+ err = can_get_bittiming(dev, &bt);
+ if (err)
+ return err;
+ memcpy(&priv->bittiming, &bt, sizeof(bt));
+
+ if (priv->do_set_bittiming) {
+ /* Finally, set the bit-timing registers */
+ err = priv->do_set_bittiming(dev);
+ if (err)
+ return err;
+ }
+ }
+
+ if (data[IFLA_CAN_RESTART_MS]) {
+ /* Do not allow changing restart delay while running */
+ if (dev->flags & IFF_UP)
+ return -EBUSY;
+ priv->restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
+ }
+
+ if (data[IFLA_CAN_RESTART]) {
+ /* Do not allow a restart while not running */
+ if (!(dev->flags & IFF_UP))
+ return -EINVAL;
+ err = can_restart_now(dev);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
+static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+ struct can_ctrlmode cm = {.flags = priv->ctrlmode};
+ enum can_state state = priv->state;
+
+ if (priv->do_get_state)
+ priv->do_get_state(dev, &state);
+ NLA_PUT_U32(skb, IFLA_CAN_STATE, state);
+ NLA_PUT(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm);
+ NLA_PUT_U32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms);
+ NLA_PUT(skb, IFLA_CAN_BITTIMING,
+ sizeof(priv->bittiming), &priv->bittiming);
+ NLA_PUT(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock);
+ if (priv->bittiming_const)
+ NLA_PUT(skb, IFLA_CAN_BITTIMING_CONST,
+ sizeof(*priv->bittiming_const), priv->bittiming_const);
+
+ return 0;
+
+nla_put_failure:
+ return -EMSGSIZE;
+}
+
+static int can_fill_xstats(struct sk_buff *skb, const struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ NLA_PUT(skb, IFLA_INFO_XSTATS,
+ sizeof(priv->can_stats), &priv->can_stats);
+
+ return 0;
+
+nla_put_failure:
+ return -EMSGSIZE;
+}
+
+static struct rtnl_link_ops can_link_ops __read_mostly = {
+ .kind = "can",
+ .maxtype = IFLA_CAN_MAX,
+ .policy = can_policy,
+ .setup = can_setup,
+ .changelink = can_changelink,
+ .fill_info = can_fill_info,
+ .fill_xstats = can_fill_xstats,
+};
+
+/*
+ * Register the CAN network device
+ */
+int register_candev(struct net_device *dev)
+{
+ dev->rtnl_link_ops = &can_link_ops;
+ return register_netdev(dev);
+}
+EXPORT_SYMBOL_GPL(register_candev);
+
+/*
+ * Unregister the CAN network device
+ */
+void unregister_candev(struct net_device *dev)
+{
+ unregister_netdev(dev);
+}
+EXPORT_SYMBOL_GPL(unregister_candev);
+
+static __init int can_dev_init(void)
+{
+ int err;
+
+ err = rtnl_link_register(&can_link_ops);
+ if (!err)
+ printk(KERN_INFO MOD_DESC "\n");
+
+ return err;
+}
+module_init(can_dev_init);
+
+static __exit void can_dev_exit(void)
+{
+ rtnl_link_unregister(&can_link_ops);
+}
+module_exit(can_dev_exit);
+
+MODULE_ALIAS_RTNL_LINK("can");
diff --git a/drivers/net/can/sja1000/Makefile b/drivers/net/can/sja1000/Makefile
new file mode 100644
index 000000000000..d6c631f9e665
--- /dev/null
+++ b/drivers/net/can/sja1000/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the SJA1000 CAN controller drivers.
+#
+
+obj-$(CONFIG_CAN_SJA1000) += sja1000.o
+obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
+obj-$(CONFIG_CAN_EMS_PCI) += ems_pci.o
+obj-$(CONFIG_CAN_KVASER_PCI) += kvaser_pci.o
+
+ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
new file mode 100644
index 000000000000..3cd2ff9165e3
--- /dev/null
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2007 Wolfgang Grandegger <wg@grandegger.com>
+ * Copyright (C) 2008 Markus Plessing <plessing@ems-wuensche.com>
+ * Copyright (C) 2008 Sebastian Haas <haas@ems-wuensche.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/io.h>
+
+#include "sja1000.h"
+
+#define DRV_NAME "ems_pci"
+
+MODULE_AUTHOR("Sebastian Haas <haas@ems-wuenche.com>");
+MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_MAX_CHAN 2
+
+struct ems_pci_card {
+ int channels;
+
+ struct pci_dev *pci_dev;
+ struct net_device *net_dev[EMS_PCI_MAX_CHAN];
+
+ void __iomem *conf_addr;
+ void __iomem *base_addr;
+};
+
+#define EMS_PCI_CAN_CLOCK (16000000 / 2)
+
+/*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
+ * PSB4610 PITA-2 bridge control registers
+ */
+#define PITA2_ICR 0x00 /* Interrupt Control Register */
+#define PITA2_ICR_INT0 0x00000002 /* [RC] INT0 Active/Clear */
+#define PITA2_ICR_INT0_EN 0x00020000 /* [RW] Enable INT0 */
+
+#define PITA2_MISC 0x1c /* Miscellaneous Register */
+#define PITA2_MISC_CONFIG 0x04000000 /* Multiplexed parallel interface */
+
+/*
+ * The board configuration is probably following:
+ * RX1 is connected to ground.
+ * TX1 is not connected.
+ * CLKO is not connected.
+ * Setting the OCR register to 0xDA is a good idea.
+ * This means normal output mode , push-pull and the correct polarity.
+ */
+#define EMS_PCI_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
+
+/*
+ * In the CDR register, you should set CBP to 1.
+ * You will probably also want to set the clock divider value to 7
+ * (meaning direct oscillator output) because the second SJA1000 chip
+ * is driven by the first one CLKOUT output.
+ */
+#define EMS_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
+#define EMS_PCI_MEM_SIZE 4096 /* Size of the remapped io-memory */
+#define EMS_PCI_CAN_BASE_OFFSET 0x400 /* offset where the controllers starts */
+#define EMS_PCI_CAN_CTRL_SIZE 0x200 /* memory size for each controller */
+
+#define EMS_PCI_PORT_BYTES 0x4 /* Each register occupies 4 bytes */
+
+#define EMS_PCI_VENDOR_ID 0x110a /* PCI device and vendor ID */
+#define EMS_PCI_DEVICE_ID 0x2104
+
+static struct pci_device_id ems_pci_tbl[] = {
+ {EMS_PCI_VENDOR_ID, EMS_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
+ {0,}
+};
+MODULE_DEVICE_TABLE(pci, ems_pci_tbl);
+
+/*
+ * Helper to read internal registers from card logic (not CAN)
+ */
+static u8 ems_pci_readb(struct ems_pci_card *card, unsigned int port)
+{
+ return readb((void __iomem *)card->base_addr
+ + (port * EMS_PCI_PORT_BYTES));
+}
+
+static u8 ems_pci_read_reg(const struct net_device *dev, int port)
+{
+ return readb((void __iomem *)dev->base_addr
+ + (port * EMS_PCI_PORT_BYTES));
+}
+
+static void ems_pci_write_reg(const struct net_device *dev, int port, u8 val)
+{
+ writeb(val, (void __iomem *)dev->base_addr
+ + (port * EMS_PCI_PORT_BYTES));
+}
+
+static void ems_pci_post_irq(const struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct ems_pci_card *card = (struct ems_pci_card *)priv->priv;
+
+ /* reset int flag of pita */
+ writel(PITA2_ICR_INT0_EN | PITA2_ICR_INT0, card->conf_addr
+ + PITA2_ICR);
+}
+
+/*
+ * Check if a CAN controller is present at the specified location
+ * by trying to set 'em into the PeliCAN mode
+ */
+static inline int ems_pci_check_chan(struct net_device *dev)
+{
+ unsigned char res;
+
+ /* Make sure SJA1000 is in reset mode */
+ ems_pci_write_reg(dev, REG_MOD, 1);
+
+ ems_pci_write_reg(dev, REG_CDR, CDR_PELICAN);
+
+ /* read reset-values */
+ res = ems_pci_read_reg(dev, REG_CDR);
+
+ if (res == CDR_PELICAN)
+ return 1;
+
+ return 0;
+}
+
+static void ems_pci_del_card(struct pci_dev *pdev)
+{
+ struct ems_pci_card *card = pci_get_drvdata(pdev);
+ struct net_device *dev;
+ int i = 0;
+
+ for (i = 0; i < card->channels; i++) {
+ dev = card->net_dev[i];
+
+ if (!dev)
+ continue;
+
+ dev_info(&pdev->dev, "Removing %s.\n", dev->name);
+ unregister_sja1000dev(dev);
+ free_sja1000dev(dev);
+ }
+
+ if (card->base_addr != NULL)
+ pci_iounmap(card->pci_dev, card->base_addr);
+
+ if (card->conf_addr != NULL)
+ pci_iounmap(card->pci_dev, card->conf_addr);
+
+ kfree(card);
+
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+}
+
+static void ems_pci_card_reset(struct ems_pci_card *card)
+{
+ /* Request board reset */
+ writeb(0, card->base_addr);
+}
+
+/*
+ * Probe PCI device for EMS CAN signature and register each available
+ * CAN channel to SJA1000 Socket-CAN subsystem.
+ */
+static int __devinit ems_pci_add_card(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ struct sja1000_priv *priv;
+ struct net_device *dev;
+ struct ems_pci_card *card;
+ int err, i;
+
+ /* Enabling PCI device */
+ if (pci_enable_device(pdev) < 0) {
+ dev_err(&pdev->dev, "Enabling PCI device failed\n");
+ return -ENODEV;
+ }
+
+ /* Allocating card structures to hold addresses, ... */
+ card = kzalloc(sizeof(struct ems_pci_card), GFP_KERNEL);
+ if (card == NULL) {
+ dev_err(&pdev->dev, "Unable to allocate memory\n");
+ pci_disable_device(pdev);
+ return -ENOMEM;
+ }
+
+ pci_set_drvdata(pdev, card);
+
+ card->pci_dev = pdev;
+
+ card->channels = 0;
+
+ /* Remap PITA configuration space, and controller memory area */
+ card->conf_addr = pci_iomap(pdev, 0, EMS_PCI_MEM_SIZE);
+ if (card->conf_addr == NULL) {
+ err = -ENOMEM;
+
+ goto failure_cleanup;
+ }
+
+ card->base_addr = pci_iomap(pdev, 1, EMS_PCI_MEM_SIZE);
+ if (card->base_addr == NULL) {
+ err = -ENOMEM;
+
+ goto failure_cleanup;
+ }
+
+ /* Configure PITA-2 parallel interface (enable MUX) */
+ writel(PITA2_MISC_CONFIG, card->conf_addr + PITA2_MISC);
+
+ /* Check for unique EMS CAN signature */
+ if (ems_pci_readb(card, 0) != 0x55 ||
+ ems_pci_readb(card, 1) != 0xAA ||
+ ems_pci_readb(card, 2) != 0x01 ||
+ ems_pci_readb(card, 3) != 0xCB ||
+ ems_pci_readb(card, 4) != 0x11) {
+ dev_err(&pdev->dev, "Not EMS Dr. Thomas Wuensche interface\n");
+
+ err = -ENODEV;
+ goto failure_cleanup;
+ }
+
+ ems_pci_card_reset(card);
+
+ /* Detect available channels */
+ for (i = 0; i < EMS_PCI_MAX_CHAN; i++) {
+ dev = alloc_sja1000dev(0);
+ if (dev == NULL) {
+ err = -ENOMEM;
+ goto failure_cleanup;
+ }
+
+ card->net_dev[i] = dev;
+ priv = netdev_priv(dev);
+ priv->priv = card;
+ priv->irq_flags = IRQF_SHARED;
+
+ dev->irq = pdev->irq;
+ dev->base_addr = (unsigned long)(card->base_addr
+ + EMS_PCI_CAN_BASE_OFFSET
+ + (i * EMS_PCI_CAN_CTRL_SIZE));
+
+ /* Check if channel is present */
+ if (ems_pci_check_chan(dev)) {
+ priv->read_reg = ems_pci_read_reg;
+ priv->write_reg = ems_pci_write_reg;
+ priv->post_irq = ems_pci_post_irq;
+ priv->can.clock.freq = EMS_PCI_CAN_CLOCK;
+ priv->ocr = EMS_PCI_OCR;
+ priv->cdr = EMS_PCI_CDR;
+
+ SET_NETDEV_DEV(dev, &pdev->dev);
+
+ /* Enable interrupts from card */
+ writel(PITA2_ICR_INT0_EN, card->conf_addr + PITA2_ICR);
+
+ /* Register SJA1000 device */
+ err = register_sja1000dev(dev);
+ if (err) {
+ dev_err(&pdev->dev, "Registering device failed "
+ "(err=%d)\n", err);
+ free_sja1000dev(dev);
+ goto failure_cleanup;
+ }
+
+ card->channels++;
+
+ dev_info(&pdev->dev, "Channel #%d at %#lX, irq %d\n",
+ i + 1, dev->base_addr,
+ dev->irq);
+ } else {
+ free_sja1000dev(dev);
+ }
+ }
+
+ return 0;
+
+failure_cleanup:
+ dev_err(&pdev->dev, "Error: %d. Cleaning Up.\n", err);
+
+ ems_pci_del_card(pdev);
+
+ return err;
+}
+
+static struct pci_driver ems_pci_driver = {
+ .name = DRV_NAME,
+ .id_table = ems_pci_tbl,
+ .probe = ems_pci_add_card,
+ .remove = ems_pci_del_card,
+};
+
+static int __init ems_pci_init(void)
+{
+ return pci_register_driver(&ems_pci_driver);
+}
+
+static void __exit ems_pci_exit(void)
+{
+ pci_unregister_driver(&ems_pci_driver);
+}
+
+module_init(ems_pci_init);
+module_exit(ems_pci_exit);
+
diff --git a/drivers/net/can/sja1000/kvaser_pci.c b/drivers/net/can/sja1000/kvaser_pci.c
new file mode 100644
index 000000000000..00830b358c4f
--- /dev/null
+++ b/drivers/net/can/sja1000/kvaser_pci.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2008 Per Dalen <per.dalen@cnw.se>
+ *
+ * Parts of this software are based on (derived) the following:
+ *
+ * - Kvaser linux driver, version 4.72 BETA
+ * Copyright (C) 2002-2007 KVASER AB
+ *
+ * - Lincan driver, version 0.3.3, OCERA project
+ * Copyright (C) 2004 Pavel Pisa
+ * Copyright (C) 2001 Arnaud Westenberg
+ *
+ * - Socketcan SJA1000 drivers
+ * Copyright (C) 2007 Wolfgang Grandegger <wg@grandegger.com>
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
+ * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
+ * 38106 Braunschweig, GERMANY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/io.h>
+
+#include "sja1000.h"
+
+#define DRV_NAME "kvaser_pci"
+
+MODULE_AUTHOR("Per Dalen <per.dalen@cnw.se>");
+MODULE_DESCRIPTION("Socket-CAN driver for KVASER PCAN PCI cards");
+MODULE_SUPPORTED_DEVICE("KVASER PCAN PCI CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define MAX_NO_OF_CHANNELS 4 /* max no of channels on a single card */
+
+struct kvaser_pci {
+ int channel;
+ struct pci_dev *pci_dev;
+ struct net_device *slave_dev[MAX_NO_OF_CHANNELS-1];
+ void __iomem *conf_addr;
+ void __iomem *res_addr;
+ int no_channels;
+ u8 xilinx_ver;
+};
+
+#define KVASER_PCI_CAN_CLOCK (16000000 / 2)
+
+/*
+ * The board configuration is probably following:
+ * RX1 is connected to ground.
+ * TX1 is not connected.
+ * CLKO is not connected.
+ * Setting the OCR register to 0xDA is a good idea.
+ * This means normal output mode , push-pull and the correct polarity.
+ */
+#define KVASER_PCI_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
+
+/*
+ * In the CDR register, you should set CBP to 1.
+ * You will probably also want to set the clock divider value to 0
+ * (meaning divide-by-2), the Pelican bit, and the clock-off bit
+ * (you will have no need for CLKOUT anyway).
+ */
+#define KVASER_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
+
+/*
+ * These register values are valid for revision 14 of the Xilinx logic.
+ */
+#define XILINX_VERINT 7 /* Lower nibble simulate interrupts,
+ high nibble version number. */
+
+#define XILINX_PRESUMED_VERSION 14
+
+/*
+ * Important S5920 registers
+ */
+#define S5920_INTCSR 0x38
+#define S5920_PTCR 0x60
+#define INTCSR_ADDON_INTENABLE_M 0x2000
+
+
+#define KVASER_PCI_PORT_BYTES 0x20
+
+#define PCI_CONFIG_PORT_SIZE 0x80 /* size of the config io-memory */
+#define PCI_PORT_SIZE 0x80 /* size of a channel io-memory */
+#define PCI_PORT_XILINX_SIZE 0x08 /* size of a xilinx io-memory */
+
+#define KVASER_PCI_VENDOR_ID1 0x10e8 /* the PCI device and vendor IDs */
+#define KVASER_PCI_DEVICE_ID1 0x8406
+
+#define KVASER_PCI_VENDOR_ID2 0x1a07 /* the PCI device and vendor IDs */
+#define KVASER_PCI_DEVICE_ID2 0x0008
+
+static struct pci_device_id kvaser_pci_tbl[] = {
+ {KVASER_PCI_VENDOR_ID1, KVASER_PCI_DEVICE_ID1, PCI_ANY_ID, PCI_ANY_ID,},
+ {KVASER_PCI_VENDOR_ID2, KVASER_PCI_DEVICE_ID2, PCI_ANY_ID, PCI_ANY_ID,},
+ { 0,}
+};
+
+MODULE_DEVICE_TABLE(pci, kvaser_pci_tbl);
+
+static u8 kvaser_pci_read_reg(const struct net_device *dev, int port)
+{
+ return ioread8((void __iomem *)(dev->base_addr + port));
+}
+
+static void kvaser_pci_write_reg(const struct net_device *dev, int port, u8 val)
+{
+ iowrite8(val, (void __iomem *)(dev->base_addr + port));
+}
+
+static void kvaser_pci_disable_irq(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct kvaser_pci *board = priv->priv;
+ u32 intcsr;
+
+ /* Disable interrupts from card */
+ intcsr = ioread32(board->conf_addr + S5920_INTCSR);
+ intcsr &= ~INTCSR_ADDON_INTENABLE_M;
+ iowrite32(intcsr, board->conf_addr + S5920_INTCSR);
+}
+
+static void kvaser_pci_enable_irq(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct kvaser_pci *board = priv->priv;
+ u32 tmp_en_io;
+
+ /* Enable interrupts from card */
+ tmp_en_io = ioread32(board->conf_addr + S5920_INTCSR);
+ tmp_en_io |= INTCSR_ADDON_INTENABLE_M;
+ iowrite32(tmp_en_io, board->conf_addr + S5920_INTCSR);
+}
+
+static int number_of_sja1000_chip(void __iomem *base_addr)
+{
+ u8 status;
+ int i;
+
+ for (i = 0; i < MAX_NO_OF_CHANNELS; i++) {
+ /* reset chip */
+ iowrite8(MOD_RM, base_addr +
+ (i * KVASER_PCI_PORT_BYTES) + REG_MOD);
+ status = ioread8(base_addr +
+ (i * KVASER_PCI_PORT_BYTES) + REG_MOD);
+ /* check reset bit */
+ if (!(status & MOD_RM))
+ break;
+ }
+
+ return i;
+}
+
+static void kvaser_pci_del_chan(struct net_device *dev)
+{
+ struct sja1000_priv *priv;
+ struct kvaser_pci *board;
+ int i;
+
+ if (!dev)
+ return;
+ priv = netdev_priv(dev);
+ board = priv->priv;
+ if (!board)
+ return;
+
+ dev_info(&board->pci_dev->dev, "Removing device %s\n",
+ dev->name);
+
+ /* Disable PCI interrupts */
+ kvaser_pci_disable_irq(dev);
+
+ for (i = 0; i < board->no_channels - 1; i++) {
+ if (board->slave_dev[i]) {
+ dev_info(&board->pci_dev->dev, "Removing device %s\n",
+ board->slave_dev[i]->name);
+ unregister_sja1000dev(board->slave_dev[i]);
+ free_sja1000dev(board->slave_dev[i]);
+ }
+ }
+ unregister_sja1000dev(dev);
+
+ pci_iounmap(board->pci_dev, (void __iomem *)dev->base_addr);
+ pci_iounmap(board->pci_dev, board->conf_addr);
+ pci_iounmap(board->pci_dev, board->res_addr);
+
+ free_sja1000dev(dev);
+}
+
+static int kvaser_pci_add_chan(struct pci_dev *pdev, int channel,
+ struct net_device **master_dev,
+ void __iomem *conf_addr,
+ void __iomem *res_addr,
+ unsigned long base_addr)
+{
+ struct net_device *dev;
+ struct sja1000_priv *priv;
+ struct kvaser_pci *board;
+ int err, init_step;
+
+ dev = alloc_sja1000dev(sizeof(struct kvaser_pci));
+ if (dev == NULL)
+ return -ENOMEM;
+
+ priv = netdev_priv(dev);
+ board = priv->priv;
+
+ board->pci_dev = pdev;
+ board->channel = channel;
+
+ /* S5920 */
+ board->conf_addr = conf_addr;
+
+ /* XILINX board wide address */
+ board->res_addr = res_addr;
+
+ if (channel == 0) {
+ board->xilinx_ver =
+ ioread8(board->res_addr + XILINX_VERINT) >> 4;
+ init_step = 2;
+
+ /* Assert PTADR# - we're in passive mode so the other bits are
+ not important */
+ iowrite32(0x80808080UL, board->conf_addr + S5920_PTCR);
+
+ /* Enable interrupts from card */
+ kvaser_pci_enable_irq(dev);
+ } else {
+ struct sja1000_priv *master_priv = netdev_priv(*master_dev);
+ struct kvaser_pci *master_board = master_priv->priv;
+ master_board->slave_dev[channel - 1] = dev;
+ master_board->no_channels = channel + 1;
+ board->xilinx_ver = master_board->xilinx_ver;
+ }
+
+ dev->base_addr = base_addr + channel * KVASER_PCI_PORT_BYTES;
+
+ priv->read_reg = kvaser_pci_read_reg;
+ priv->write_reg = kvaser_pci_write_reg;
+
+ priv->can.clock.freq = KVASER_PCI_CAN_CLOCK;
+
+ priv->ocr = KVASER_PCI_OCR;
+ priv->cdr = KVASER_PCI_CDR;
+
+ priv->irq_flags = IRQF_SHARED;
+ dev->irq = pdev->irq;
+
+ init_step = 4;
+
+ dev_info(&pdev->dev, "base_addr=%#lx conf_addr=%p irq=%d\n",
+ dev->base_addr, board->conf_addr, dev->irq);
+
+ SET_NETDEV_DEV(dev, &pdev->dev);
+
+ /* Register SJA1000 device */
+ err = register_sja1000dev(dev);
+ if (err) {
+ dev_err(&pdev->dev, "Registering device failed (err=%d)\n",
+ err);
+ goto failure;
+ }
+
+ if (channel == 0)
+ *master_dev = dev;
+
+ return 0;
+
+failure:
+ kvaser_pci_del_chan(dev);
+ return err;
+}
+
+static int __devinit kvaser_pci_init_one(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int err;
+ struct net_device *master_dev = NULL;
+ struct sja1000_priv *priv;
+ struct kvaser_pci *board;
+ int no_channels;
+ void __iomem *base_addr = NULL;
+ void __iomem *conf_addr = NULL;
+ void __iomem *res_addr = NULL;
+ int i;
+
+ dev_info(&pdev->dev, "initializing device %04x:%04x\n",
+ pdev->vendor, pdev->device);
+
+ err = pci_enable_device(pdev);
+ if (err)
+ goto failure;
+
+ err = pci_request_regions(pdev, DRV_NAME);
+ if (err)
+ goto failure_release_pci;
+
+ /* S5920 */
+ conf_addr = pci_iomap(pdev, 0, PCI_CONFIG_PORT_SIZE);
+ if (conf_addr == NULL) {
+ err = -ENODEV;
+ goto failure_release_regions;
+ }
+
+ /* XILINX board wide address */
+ res_addr = pci_iomap(pdev, 2, PCI_PORT_XILINX_SIZE);
+ if (res_addr == NULL) {
+ err = -ENOMEM;
+ goto failure_iounmap;
+ }
+
+ base_addr = pci_iomap(pdev, 1, PCI_PORT_SIZE);
+ if (base_addr == NULL) {
+ err = -ENOMEM;
+ goto failure_iounmap;
+ }
+
+ no_channels = number_of_sja1000_chip(base_addr);
+ if (no_channels == 0) {
+ err = -ENOMEM;
+ goto failure_iounmap;
+ }
+
+ for (i = 0; i < no_channels; i++) {
+ err = kvaser_pci_add_chan(pdev, i, &master_dev,
+ conf_addr, res_addr,
+ (unsigned long)base_addr);
+ if (err)
+ goto failure_cleanup;
+ }
+
+ priv = netdev_priv(master_dev);
+ board = priv->priv;
+
+ dev_info(&pdev->dev, "xilinx version=%d number of channels=%d\n",
+ board->xilinx_ver, board->no_channels);
+
+ pci_set_drvdata(pdev, master_dev);
+ return 0;
+
+failure_cleanup:
+ kvaser_pci_del_chan(master_dev);
+
+failure_iounmap:
+ if (conf_addr != NULL)
+ pci_iounmap(pdev, conf_addr);
+ if (res_addr != NULL)
+ pci_iounmap(pdev, res_addr);
+ if (base_addr != NULL)
+ pci_iounmap(pdev, base_addr);
+
+failure_release_regions:
+ pci_release_regions(pdev);
+
+failure_release_pci:
+ pci_disable_device(pdev);
+
+failure:
+ return err;
+
+}
+
+static void __devexit kvaser_pci_remove_one(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+
+ kvaser_pci_del_chan(dev);
+
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+}
+
+static struct pci_driver kvaser_pci_driver = {
+ .name = DRV_NAME,
+ .id_table = kvaser_pci_tbl,
+ .probe = kvaser_pci_init_one,
+ .remove = __devexit_p(kvaser_pci_remove_one),
+};
+
+static int __init kvaser_pci_init(void)
+{
+ return pci_register_driver(&kvaser_pci_driver);
+}
+
+static void __exit kvaser_pci_exit(void)
+{
+ pci_unregister_driver(&kvaser_pci_driver);
+}
+
+module_init(kvaser_pci_init);
+module_exit(kvaser_pci_exit);
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
new file mode 100644
index 000000000000..05b38dde648e
--- /dev/null
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -0,0 +1,637 @@
+/*
+ * sja1000.c - Philips SJA1000 network device driver
+ *
+ * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
+ * 38106 Braunschweig, GERMANY
+ *
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-users@lists.berlios.de>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/interrupt.h>
+#include <linux/ptrace.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/skbuff.h>
+#include <linux/delay.h>
+
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/can/error.h>
+#include <linux/can/dev.h>
+
+#include "sja1000.h"
+
+#define DRV_NAME "sja1000"
+
+MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION(DRV_NAME "CAN netdevice driver");
+
+static struct can_bittiming_const sja1000_bittiming_const = {
+ .name = DRV_NAME,
+ .tseg1_min = 1,
+ .tseg1_max = 16,
+ .tseg2_min = 1,
+ .tseg2_max = 8,
+ .sjw_max = 4,
+ .brp_min = 1,
+ .brp_max = 64,
+ .brp_inc = 1,
+};
+
+static int sja1000_probe_chip(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+
+ if (dev->base_addr && (priv->read_reg(dev, 0) == 0xFF)) {
+ printk(KERN_INFO "%s: probing @0x%lX failed\n",
+ DRV_NAME, dev->base_addr);
+ return 0;
+ }
+ return -1;
+}
+
+static void set_reset_mode(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ unsigned char status = priv->read_reg(dev, REG_MOD);
+ int i;
+
+ /* disable interrupts */
+ priv->write_reg(dev, REG_IER, IRQ_OFF);
+
+ for (i = 0; i < 100; i++) {
+ /* check reset bit */
+ if (status & MOD_RM) {
+ priv->can.state = CAN_STATE_STOPPED;
+ return;
+ }
+
+ priv->write_reg(dev, REG_MOD, MOD_RM); /* reset chip */
+ udelay(10);
+ status = priv->read_reg(dev, REG_MOD);
+ }
+
+ dev_err(dev->dev.parent, "setting SJA1000 into reset mode failed!\n");
+}
+
+static void set_normal_mode(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ unsigned char status = priv->read_reg(dev, REG_MOD);
+ int i;
+
+ for (i = 0; i < 100; i++) {
+ /* check reset bit */
+ if ((status & MOD_RM) == 0) {
+ priv->can.state = CAN_STATE_ERROR_ACTIVE;
+ /* enable all interrupts */
+ priv->write_reg(dev, REG_IER, IRQ_ALL);
+ return;
+ }
+
+ /* set chip to normal mode */
+ priv->write_reg(dev, REG_MOD, 0x00);
+ udelay(10);
+ status = priv->read_reg(dev, REG_MOD);
+ }
+
+ dev_err(dev->dev.parent, "setting SJA1000 into normal mode failed!\n");
+}
+
+static void sja1000_start(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+
+ /* leave reset mode */
+ if (priv->can.state != CAN_STATE_STOPPED)
+ set_reset_mode(dev);
+
+ /* Clear error counters and error code capture */
+ priv->write_reg(dev, REG_TXERR, 0x0);
+ priv->write_reg(dev, REG_RXERR, 0x0);
+ priv->read_reg(dev, REG_ECC);
+
+ /* leave reset mode */
+ set_normal_mode(dev);
+}
+
+static int sja1000_set_mode(struct net_device *dev, enum can_mode mode)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+
+ if (!priv->open_time)
+ return -EINVAL;
+
+ switch (mode) {
+ case CAN_MODE_START:
+ sja1000_start(dev);
+ if (netif_queue_stopped(dev))
+ netif_wake_queue(dev);
+ break;
+
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static int sja1000_set_bittiming(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct can_bittiming *bt = &priv->can.bittiming;
+ u8 btr0, btr1;
+
+ btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
+ btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
+ (((bt->phase_seg2 - 1) & 0x7) << 4);
+ if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
+ btr1 |= 0x80;
+
+ dev_info(dev->dev.parent,
+ "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
+
+ priv->write_reg(dev, REG_BTR0, btr0);
+ priv->write_reg(dev, REG_BTR1, btr1);
+
+ return 0;
+}
+
+/*
+ * initialize SJA1000 chip:
+ * - reset chip
+ * - set output mode
+ * - set baudrate
+ * - enable interrupts
+ * - start operating mode
+ */
+static void chipset_init(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+
+ /* set clock divider and output control register */
+ priv->write_reg(dev, REG_CDR, priv->cdr | CDR_PELICAN);
+
+ /* set acceptance filter (accept all) */
+ priv->write_reg(dev, REG_ACCC0, 0x00);
+ priv->write_reg(dev, REG_ACCC1, 0x00);
+ priv->write_reg(dev, REG_ACCC2, 0x00);
+ priv->write_reg(dev, REG_ACCC3, 0x00);
+
+ priv->write_reg(dev, REG_ACCM0, 0xFF);
+ priv->write_reg(dev, REG_ACCM1, 0xFF);
+ priv->write_reg(dev, REG_ACCM2, 0xFF);
+ priv->write_reg(dev, REG_ACCM3, 0xFF);
+
+ priv->write_reg(dev, REG_OCR, priv->ocr | OCR_MODE_NORMAL);
+}
+
+/*
+ * transmit a CAN message
+ * message layout in the sk_buff should be like this:
+ * xx xx xx xx ff ll 00 11 22 33 44 55 66 77
+ * [ can-id ] [flags] [len] [can data (up to 8 bytes]
+ */
+static int sja1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ struct can_frame *cf = (struct can_frame *)skb->data;
+ uint8_t fi;
+ uint8_t dlc;
+ canid_t id;
+ uint8_t dreg;
+ int i;
+
+ netif_stop_queue(dev);
+
+ fi = dlc = cf->can_dlc;
+ id = cf->can_id;
+
+ if (id & CAN_RTR_FLAG)
+ fi |= FI_RTR;
+
+ if (id & CAN_EFF_FLAG) {
+ fi |= FI_FF;
+ dreg = EFF_BUF;
+ priv->write_reg(dev, REG_FI, fi);
+ priv->write_reg(dev, REG_ID1, (id & 0x1fe00000) >> (5 + 16));
+ priv->write_reg(dev, REG_ID2, (id & 0x001fe000) >> (5 + 8));
+ priv->write_reg(dev, REG_ID3, (id & 0x00001fe0) >> 5);
+ priv->write_reg(dev, REG_ID4, (id & 0x0000001f) << 3);
+ } else {
+ dreg = SFF_BUF;
+ priv->write_reg(dev, REG_FI, fi);
+ priv->write_reg(dev, REG_ID1, (id & 0x000007f8) >> 3);
+ priv->write_reg(dev, REG_ID2, (id & 0x00000007) << 5);
+ }
+
+ for (i = 0; i < dlc; i++)
+ priv->write_reg(dev, dreg++, cf->data[i]);
+
+ stats->tx_bytes += dlc;
+ dev->trans_start = jiffies;
+
+ can_put_echo_skb(skb, dev, 0);
+
+ priv->write_reg(dev, REG_CMR, CMD_TR);
+
+ return 0;
+}
+
+static void sja1000_rx(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ struct can_frame *cf;
+ struct sk_buff *skb;
+ uint8_t fi;
+ uint8_t dreg;
+ canid_t id;
+ uint8_t dlc;
+ int i;
+
+ skb = dev_alloc_skb(sizeof(struct can_frame));
+ if (skb == NULL)
+ return;
+ skb->dev = dev;
+ skb->protocol = htons(ETH_P_CAN);
+
+ fi = priv->read_reg(dev, REG_FI);
+ dlc = fi & 0x0F;
+
+ if (fi & FI_FF) {
+ /* extended frame format (EFF) */
+ dreg = EFF_BUF;
+ id = (priv->read_reg(dev, REG_ID1) << (5 + 16))
+ | (priv->read_reg(dev, REG_ID2) << (5 + 8))
+ | (priv->read_reg(dev, REG_ID3) << 5)
+ | (priv->read_reg(dev, REG_ID4) >> 3);
+ id |= CAN_EFF_FLAG;
+ } else {
+ /* standard frame format (SFF) */
+ dreg = SFF_BUF;
+ id = (priv->read_reg(dev, REG_ID1) << 3)
+ | (priv->read_reg(dev, REG_ID2) >> 5);
+ }
+
+ if (fi & FI_RTR)
+ id |= CAN_RTR_FLAG;
+
+ cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
+ memset(cf, 0, sizeof(struct can_frame));
+ cf->can_id = id;
+ cf->can_dlc = dlc;
+ for (i = 0; i < dlc; i++)
+ cf->data[i] = priv->read_reg(dev, dreg++);
+
+ while (i < 8)
+ cf->data[i++] = 0;
+
+ /* release receive buffer */
+ priv->write_reg(dev, REG_CMR, CMD_RRB);
+
+ netif_rx(skb);
+
+ dev->last_rx = jiffies;
+ stats->rx_packets++;
+ stats->rx_bytes += dlc;
+}
+
+static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ struct can_frame *cf;
+ struct sk_buff *skb;
+ enum can_state state = priv->can.state;
+ uint8_t ecc, alc;
+
+ skb = dev_alloc_skb(sizeof(struct can_frame));
+ if (skb == NULL)
+ return -ENOMEM;
+ skb->dev = dev;
+ skb->protocol = htons(ETH_P_CAN);
+ cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
+ memset(cf, 0, sizeof(struct can_frame));
+ cf->can_id = CAN_ERR_FLAG;
+ cf->can_dlc = CAN_ERR_DLC;
+
+ if (isrc & IRQ_DOI) {
+ /* data overrun interrupt */
+ dev_dbg(dev->dev.parent, "data overrun interrupt\n");
+ cf->can_id |= CAN_ERR_CRTL;
+ cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
+ stats->rx_over_errors++;
+ stats->rx_errors++;
+ priv->write_reg(dev, REG_CMR, CMD_CDO); /* clear bit */
+ }
+
+ if (isrc & IRQ_EI) {
+ /* error warning interrupt */
+ dev_dbg(dev->dev.parent, "error warning interrupt\n");
+
+ if (status & SR_BS) {
+ state = CAN_STATE_BUS_OFF;
+ cf->can_id |= CAN_ERR_BUSOFF;
+ can_bus_off(dev);
+ } else if (status & SR_ES) {
+ state = CAN_STATE_ERROR_WARNING;
+ } else
+ state = CAN_STATE_ERROR_ACTIVE;
+ }
+ if (isrc & IRQ_BEI) {
+ /* bus error interrupt */
+ priv->can.can_stats.bus_error++;
+ stats->rx_errors++;
+
+ ecc = priv->read_reg(dev, REG_ECC);
+
+ cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
+
+ switch (ecc & ECC_MASK) {
+ case ECC_BIT:
+ cf->data[2] |= CAN_ERR_PROT_BIT;
+ break;
+ case ECC_FORM:
+ cf->data[2] |= CAN_ERR_PROT_FORM;
+ break;
+ case ECC_STUFF:
+ cf->data[2] |= CAN_ERR_PROT_STUFF;
+ break;
+ default:
+ cf->data[2] |= CAN_ERR_PROT_UNSPEC;
+ cf->data[3] = ecc & ECC_SEG;
+ break;
+ }
+ /* Error occured during transmission? */
+ if ((ecc & ECC_DIR) == 0)
+ cf->data[2] |= CAN_ERR_PROT_TX;
+ }
+ if (isrc & IRQ_EPI) {
+ /* error passive interrupt */
+ dev_dbg(dev->dev.parent, "error passive interrupt\n");
+ if (status & SR_ES)
+ state = CAN_STATE_ERROR_PASSIVE;
+ else
+ state = CAN_STATE_ERROR_ACTIVE;
+ }
+ if (isrc & IRQ_ALI) {
+ /* arbitration lost interrupt */
+ dev_dbg(dev->dev.parent, "arbitration lost interrupt\n");
+ alc = priv->read_reg(dev, REG_ALC);
+ priv->can.can_stats.arbitration_lost++;
+ stats->rx_errors++;
+ cf->can_id |= CAN_ERR_LOSTARB;
+ cf->data[0] = alc & 0x1f;
+ }
+
+ if (state != priv->can.state && (state == CAN_STATE_ERROR_WARNING ||
+ state == CAN_STATE_ERROR_PASSIVE)) {
+ uint8_t rxerr = priv->read_reg(dev, REG_RXERR);
+ uint8_t txerr = priv->read_reg(dev, REG_TXERR);
+ cf->can_id |= CAN_ERR_CRTL;
+ if (state == CAN_STATE_ERROR_WARNING) {
+ priv->can.can_stats.error_warning++;
+ cf->data[1] = (txerr > rxerr) ?
+ CAN_ERR_CRTL_TX_WARNING :
+ CAN_ERR_CRTL_RX_WARNING;
+ } else {
+ priv->can.can_stats.error_passive++;
+ cf->data[1] = (txerr > rxerr) ?
+ CAN_ERR_CRTL_TX_PASSIVE :
+ CAN_ERR_CRTL_RX_PASSIVE;
+ }
+ }
+
+ priv->can.state = state;
+
+ netif_rx(skb);
+
+ dev->last_rx = jiffies;
+ stats->rx_packets++;
+ stats->rx_bytes += cf->can_dlc;
+
+ return 0;
+}
+
+irqreturn_t sja1000_interrupt(int irq, void *dev_id)
+{
+ struct net_device *dev = (struct net_device *)dev_id;
+ struct sja1000_priv *priv = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ uint8_t isrc, status;
+ int n = 0;
+
+ /* Shared interrupts and IRQ off? */
+ if (priv->read_reg(dev, REG_IER) == IRQ_OFF)
+ return IRQ_NONE;
+
+ if (priv->pre_irq)
+ priv->pre_irq(dev);
+
+ while ((isrc = priv->read_reg(dev, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
+ n++;
+ status = priv->read_reg(dev, REG_SR);
+
+ if (isrc & IRQ_WUI)
+ dev_warn(dev->dev.parent, "wakeup interrupt\n");
+
+ if (isrc & IRQ_TI) {
+ /* transmission complete interrupt */
+ stats->tx_packets++;
+ can_get_echo_skb(dev, 0);
+ netif_wake_queue(dev);
+ }
+ if (isrc & IRQ_RI) {
+ /* receive interrupt */
+ while (status & SR_RBS) {
+ sja1000_rx(dev);
+ status = priv->read_reg(dev, REG_SR);
+ }
+ }
+ if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
+ /* error interrupt */
+ if (sja1000_err(dev, isrc, status))
+ break;
+ }
+ }
+
+ if (priv->post_irq)
+ priv->post_irq(dev);
+
+ if (n >= SJA1000_MAX_IRQ)
+ dev_dbg(dev->dev.parent, "%d messages handled in ISR", n);
+
+ return (n) ? IRQ_HANDLED : IRQ_NONE;
+}
+EXPORT_SYMBOL_GPL(sja1000_interrupt);
+
+static int sja1000_open(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+ int err;
+
+ /* set chip into reset mode */
+ set_reset_mode(dev);
+
+ /* common open */
+ err = open_candev(dev);
+ if (err)
+ return err;
+
+ /* register interrupt handler, if not done by the device driver */
+ if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER)) {
+ err = request_irq(dev->irq, &sja1000_interrupt, priv->irq_flags,
+ dev->name, (void *)dev);
+ if (err) {
+ return -EAGAIN;
+ close_candev(dev);
+ }
+ }
+
+ /* init and start chi */
+ sja1000_start(dev);
+ priv->open_time = jiffies;
+
+ netif_start_queue(dev);
+
+ return 0;
+}
+
+static int sja1000_close(struct net_device *dev)
+{
+ struct sja1000_priv *priv = netdev_priv(dev);
+
+ netif_stop_queue(dev);
+ set_reset_mode(dev);
+
+ if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER))
+ free_irq(dev->irq, (void *)dev);
+
+ close_candev(dev);
+
+ priv->open_time = 0;
+
+ return 0;
+}
+
+struct net_device *alloc_sja1000dev(int sizeof_priv)
+{
+ struct net_device *dev;
+ struct sja1000_priv *priv;
+
+ dev = alloc_candev(sizeof(struct sja1000_priv) + sizeof_priv);
+ if (!dev)
+ return NULL;
+
+ priv = netdev_priv(dev);
+
+ priv->dev = dev;
+ priv->can.bittiming_const = &sja1000_bittiming_const;
+ priv->can.do_set_bittiming = sja1000_set_bittiming;
+ priv->can.do_set_mode = sja1000_set_mode;
+
+ if (sizeof_priv)
+ priv->priv = (void *)priv + sizeof(struct sja1000_priv);
+
+ return dev;
+}
+EXPORT_SYMBOL_GPL(alloc_sja1000dev);
+
+void free_sja1000dev(struct net_device *dev)
+{
+ free_candev(dev);
+}
+EXPORT_SYMBOL_GPL(free_sja1000dev);
+
+static const struct net_device_ops sja1000_netdev_ops = {
+ .ndo_open = sja1000_open,
+ .ndo_stop = sja1000_close,
+ .ndo_start_xmit = sja1000_start_xmit,
+};
+
+int register_sja1000dev(struct net_device *dev)
+{
+ if (!sja1000_probe_chip(dev))
+ return -ENODEV;
+
+ dev->flags |= IFF_ECHO; /* we support local echo */
+ dev->netdev_ops = &sja1000_netdev_ops;
+
+ set_reset_mode(dev);
+ chipset_init(dev);
+
+ return register_candev(dev);
+}
+EXPORT_SYMBOL_GPL(register_sja1000dev);
+
+void unregister_sja1000dev(struct net_device *dev)
+{
+ set_reset_mode(dev);
+ unregister_candev(dev);
+}
+EXPORT_SYMBOL_GPL(unregister_sja1000dev);
+
+static __init int sja1000_init(void)
+{
+ printk(KERN_INFO "%s CAN netdevice driver\n", DRV_NAME);
+
+ return 0;
+}
+
+module_init(sja1000_init);
+
+static __exit void sja1000_exit(void)
+{
+ printk(KERN_INFO "%s: driver removed\n", DRV_NAME);
+}
+
+module_exit(sja1000_exit);
diff --git a/drivers/net/can/sja1000/sja1000.h b/drivers/net/can/sja1000/sja1000.h
new file mode 100644
index 000000000000..ccd302887964
--- /dev/null
+++ b/drivers/net/can/sja1000/sja1000.h
@@ -0,0 +1,180 @@
+/*
+ * sja1000.h - Philips SJA1000 network device driver
+ *
+ * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
+ * 38106 Braunschweig, GERMANY
+ *
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-users@lists.berlios.de>
+ *
+ */
+
+#ifndef SJA1000_DEV_H
+#define SJA1000_DEV_H
+
+#include <linux/can/dev.h>
+#include <linux/can/platform/sja1000.h>
+
+#define SJA1000_MAX_IRQ 20 /* max. number of interrupts handled in ISR */
+
+/* SJA1000 registers - manual section 6.4 (Pelican Mode) */
+#define REG_MOD 0x00
+#define REG_CMR 0x01
+#define REG_SR 0x02
+#define REG_IR 0x03
+#define REG_IER 0x04
+#define REG_ALC 0x0B
+#define REG_ECC 0x0C
+#define REG_EWL 0x0D
+#define REG_RXERR 0x0E
+#define REG_TXERR 0x0F
+#define REG_ACCC0 0x10
+#define REG_ACCC1 0x11
+#define REG_ACCC2 0x12
+#define REG_ACCC3 0x13
+#define REG_ACCM0 0x14
+#define REG_ACCM1 0x15
+#define REG_ACCM2 0x16
+#define REG_ACCM3 0x17
+#define REG_RMC 0x1D
+#define REG_RBSA 0x1E
+
+/* Common registers - manual section 6.5 */
+#define REG_BTR0 0x06
+#define REG_BTR1 0x07
+#define REG_OCR 0x08
+#define REG_CDR 0x1F
+
+#define REG_FI 0x10
+#define SFF_BUF 0x13
+#define EFF_BUF 0x15
+
+#define FI_FF 0x80
+#define FI_RTR 0x40
+
+#define REG_ID1 0x11
+#define REG_ID2 0x12
+#define REG_ID3 0x13
+#define REG_ID4 0x14
+
+#define CAN_RAM 0x20
+
+/* mode register */
+#define MOD_RM 0x01
+#define MOD_LOM 0x02
+#define MOD_STM 0x04
+#define MOD_AFM 0x08
+#define MOD_SM 0x10
+
+/* commands */
+#define CMD_SRR 0x10
+#define CMD_CDO 0x08
+#define CMD_RRB 0x04
+#define CMD_AT 0x02
+#define CMD_TR 0x01
+
+/* interrupt sources */
+#define IRQ_BEI 0x80
+#define IRQ_ALI 0x40
+#define IRQ_EPI 0x20
+#define IRQ_WUI 0x10
+#define IRQ_DOI 0x08
+#define IRQ_EI 0x04
+#define IRQ_TI 0x02
+#define IRQ_RI 0x01
+#define IRQ_ALL 0xFF
+#define IRQ_OFF 0x00
+
+/* status register content */
+#define SR_BS 0x80
+#define SR_ES 0x40
+#define SR_TS 0x20
+#define SR_RS 0x10
+#define SR_TCS 0x08
+#define SR_TBS 0x04
+#define SR_DOS 0x02
+#define SR_RBS 0x01
+
+#define SR_CRIT (SR_BS|SR_ES)
+
+/* ECC register */
+#define ECC_SEG 0x1F
+#define ECC_DIR 0x20
+#define ECC_ERR 6
+#define ECC_BIT 0x00
+#define ECC_FORM 0x40
+#define ECC_STUFF 0x80
+#define ECC_MASK 0xc0
+
+/*
+ * Flags for sja1000priv.flags
+ */
+#define SJA1000_CUSTOM_IRQ_HANDLER 0x1
+
+/*
+ * SJA1000 private data structure
+ */
+struct sja1000_priv {
+ struct can_priv can; /* must be the first member */
+ int open_time;
+ struct sk_buff *echo_skb;
+
+ /* the lower-layer is responsible for appropriate locking */
+ u8 (*read_reg) (const struct net_device *dev, int reg);
+ void (*write_reg) (const struct net_device *dev, int reg, u8 val);
+ void (*pre_irq) (const struct net_device *dev);
+ void (*post_irq) (const struct net_device *dev);
+
+ void *priv; /* for board-specific data */
+ struct net_device *dev;
+
+ unsigned long irq_flags; /* for request_irq() */
+
+ u16 flags; /* custom mode flags */
+ u8 ocr; /* output control register */
+ u8 cdr; /* clock divider register */
+};
+
+struct net_device *alloc_sja1000dev(int sizeof_priv);
+void free_sja1000dev(struct net_device *dev);
+int register_sja1000dev(struct net_device *dev);
+void unregister_sja1000dev(struct net_device *dev);
+
+irqreturn_t sja1000_interrupt(int irq, void *dev_id);
+
+#endif /* SJA1000_DEV_H */
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
new file mode 100644
index 000000000000..8017229d6fd6
--- /dev/null
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2005 Sascha Hauer, Pengutronix
+ * Copyright (C) 2007 Wolfgang Grandegger <wg@grandegger.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/irq.h>
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/can/platform/sja1000.h>
+#include <linux/io.h>
+
+#include "sja1000.h"
+
+#define DRV_NAME "sja1000_platform"
+
+MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
+MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
+MODULE_LICENSE("GPL v2");
+
+static u8 sp_read_reg(const struct net_device *dev, int reg)
+{
+ return ioread8((void __iomem *)(dev->base_addr + reg));
+}
+
+static void sp_write_reg(const struct net_device *dev, int reg, u8 val)
+{
+ iowrite8(val, (void __iomem *)(dev->base_addr + reg));
+}
+
+static int sp_probe(struct platform_device *pdev)
+{
+ int err;
+ void __iomem *addr;
+ struct net_device *dev;
+ struct sja1000_priv *priv;
+ struct resource *res_mem, *res_irq;
+ struct sja1000_platform_data *pdata;
+
+ pdata = pdev->dev.platform_data;
+ if (!pdata) {
+ dev_err(&pdev->dev, "No platform data provided!\n");
+ err = -ENODEV;
+ goto exit;
+ }
+
+ res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (!res_mem || !res_irq) {
+ err = -ENODEV;
+ goto exit;
+ }
+
+ if (!request_mem_region(res_mem->start, resource_size(res_mem),
+ DRV_NAME)) {
+ err = -EBUSY;
+ goto exit;
+ }
+
+ addr = ioremap_nocache(res_mem->start, resource_size(res_mem));
+ if (!addr) {
+ err = -ENOMEM;
+ goto exit_release;
+ }
+
+ dev = alloc_sja1000dev(0);
+ if (!dev) {
+ err = -ENOMEM;
+ goto exit_iounmap;
+ }
+ priv = netdev_priv(dev);
+
+ dev->base_addr = (unsigned long)addr;
+ dev->irq = res_irq->start;
+ priv->irq_flags = res_irq->flags & IRQF_TRIGGER_MASK;
+ priv->read_reg = sp_read_reg;
+ priv->write_reg = sp_write_reg;
+ priv->can.clock.freq = pdata->clock;
+ priv->ocr = pdata->ocr;
+ priv->cdr = pdata->cdr;
+
+ dev_set_drvdata(&pdev->dev, dev);
+ SET_NETDEV_DEV(dev, &pdev->dev);
+
+ err = register_sja1000dev(dev);
+ if (err) {
+ dev_err(&pdev->dev, "registering %s failed (err=%d)\n",
+ DRV_NAME, err);
+ goto exit_free;
+ }
+
+ dev_info(&pdev->dev, "%s device registered (base_addr=%#lx, irq=%d)\n",
+ DRV_NAME, dev->base_addr, dev->irq);
+ return 0;
+
+ exit_free:
+ free_sja1000dev(dev);
+ exit_iounmap:
+ iounmap(addr);
+ exit_release:
+ release_mem_region(res_mem->start, resource_size(res_mem));
+ exit:
+ return err;
+}
+
+static int sp_remove(struct platform_device *pdev)
+{
+ struct net_device *dev = dev_get_drvdata(&pdev->dev);
+ struct resource *res;
+
+ unregister_sja1000dev(dev);
+ dev_set_drvdata(&pdev->dev, NULL);
+
+ if (dev->base_addr)
+ iounmap((void __iomem *)dev->base_addr);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ release_mem_region(res->start, resource_size(res));
+
+ free_sja1000dev(dev);
+
+ return 0;
+}
+
+static struct platform_driver sp_driver = {
+ .probe = sp_probe,
+ .remove = sp_remove,
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init sp_init(void)
+{
+ return platform_driver_register(&sp_driver);
+}
+
+static void __exit sp_exit(void)
+{
+ platform_driver_unregister(&sp_driver);
+}
+
+module_init(sp_init);
+module_exit(sp_exit);
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index 4bd2455b0fe3..699d22c5fe09 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -46,7 +46,7 @@
#include <linux/pci.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
-#include <linux/mii.h>
+#include <linux/mdio.h>
#include <linux/crc32.h>
#include <linux/init.h>
#include <asm/io.h>
diff --git a/drivers/net/chelsio/cphy.h b/drivers/net/chelsio/cphy.h
index 79d855e267e0..1f095a9fc739 100644
--- a/drivers/net/chelsio/cphy.h
+++ b/drivers/net/chelsio/cphy.h
@@ -43,10 +43,11 @@
struct mdio_ops {
void (*init)(adapter_t *adapter, const struct board_info *bi);
- int (*read)(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *val);
- int (*write)(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val);
+ int (*read)(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr);
+ int (*write)(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr, u16 val);
+ unsigned mode_support;
};
/* PHY interrupt types */
@@ -83,11 +84,12 @@ struct cphy_ops {
int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex);
int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
int *duplex, int *fc);
+
+ u32 mmds;
};
/* A PHY instance */
struct cphy {
- int addr; /* PHY address */
int state; /* Link status state machine */
adapter_t *adapter; /* associated adapter */
@@ -101,56 +103,61 @@ struct cphy {
u32 elmer_gpo;
const struct cphy_ops *ops; /* PHY operations */
- int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *val);
- int (*mdio_write)(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val);
+ struct mdio_if_info mdio;
struct cphy_instance *instance;
};
/* Convenience MDIO read/write wrappers */
-static inline int mdio_read(struct cphy *cphy, int mmd, int reg,
- unsigned int *valp)
+static inline int cphy_mdio_read(struct cphy *cphy, int mmd, int reg,
+ unsigned int *valp)
{
- return cphy->mdio_read(cphy->adapter, cphy->addr, mmd, reg, valp);
+ int rc = cphy->mdio.mdio_read(cphy->mdio.dev, cphy->mdio.prtad, mmd,
+ reg);
+ *valp = (rc >= 0) ? rc : -1;
+ return (rc >= 0) ? 0 : rc;
}
-static inline int mdio_write(struct cphy *cphy, int mmd, int reg,
- unsigned int val)
+static inline int cphy_mdio_write(struct cphy *cphy, int mmd, int reg,
+ unsigned int val)
{
- return cphy->mdio_write(cphy->adapter, cphy->addr, mmd, reg, val);
+ return cphy->mdio.mdio_write(cphy->mdio.dev, cphy->mdio.prtad, mmd,
+ reg, val);
}
static inline int simple_mdio_read(struct cphy *cphy, int reg,
unsigned int *valp)
{
- return mdio_read(cphy, 0, reg, valp);
+ return cphy_mdio_read(cphy, MDIO_DEVAD_NONE, reg, valp);
}
static inline int simple_mdio_write(struct cphy *cphy, int reg,
unsigned int val)
{
- return mdio_write(cphy, 0, reg, val);
+ return cphy_mdio_write(cphy, MDIO_DEVAD_NONE, reg, val);
}
/* Convenience initializer */
-static inline void cphy_init(struct cphy *phy, adapter_t *adapter,
+static inline void cphy_init(struct cphy *phy, struct net_device *dev,
int phy_addr, struct cphy_ops *phy_ops,
const struct mdio_ops *mdio_ops)
{
+ struct adapter *adapter = netdev_priv(dev);
phy->adapter = adapter;
- phy->addr = phy_addr;
phy->ops = phy_ops;
if (mdio_ops) {
- phy->mdio_read = mdio_ops->read;
- phy->mdio_write = mdio_ops->write;
+ phy->mdio.prtad = phy_addr;
+ phy->mdio.mmds = phy_ops->mmds;
+ phy->mdio.mode_support = mdio_ops->mode_support;
+ phy->mdio.mdio_read = mdio_ops->read;
+ phy->mdio.mdio_write = mdio_ops->write;
}
+ phy->mdio.dev = dev;
}
/* Operations of the PHY-instance factory */
struct gphy {
/* Construct a PHY instance with the given PHY address */
- struct cphy *(*create)(adapter_t *adapter, int phy_addr,
+ struct cphy *(*create)(struct net_device *dev, int phy_addr,
const struct mdio_ops *mdio_ops);
/*
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index fa06994f9737..082cdb28b510 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -589,7 +589,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
}
cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
- cmd->phy_address = p->phy->addr;
+ cmd->phy_address = p->phy->mdio.prtad;
cmd->transceiver = XCVR_EXTERNAL;
cmd->autoneg = p->link_config.autoneg;
cmd->maxtxpkt = 0;
@@ -849,39 +849,9 @@ static const struct ethtool_ops t1_ethtool_ops = {
static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
{
struct adapter *adapter = dev->ml_priv;
- struct mii_ioctl_data *data = if_mii(req);
-
- switch (cmd) {
- case SIOCGMIIPHY:
- data->phy_id = adapter->port[dev->if_port].phy->addr;
- /* FALLTHRU */
- case SIOCGMIIREG: {
- struct cphy *phy = adapter->port[dev->if_port].phy;
- u32 val;
-
- if (!phy->mdio_read)
- return -EOPNOTSUPP;
- phy->mdio_read(adapter, data->phy_id, 0, data->reg_num & 0x1f,
- &val);
- data->val_out = val;
- break;
- }
- case SIOCSMIIREG: {
- struct cphy *phy = adapter->port[dev->if_port].phy;
-
- if (!capable(CAP_NET_ADMIN))
- return -EPERM;
- if (!phy->mdio_write)
- return -EOPNOTSUPP;
- phy->mdio_write(adapter, data->phy_id, 0, data->reg_num & 0x1f,
- data->val_in);
- break;
- }
+ struct mdio_if_info *mdio = &adapter->port[dev->if_port].phy->mdio;
- default:
- return -EOPNOTSUPP;
- }
- return 0;
+ return mdio_mii_ioctl(mdio, if_mii(req), cmd);
}
static int t1_change_mtu(struct net_device *dev, int new_mtu)
diff --git a/drivers/net/chelsio/mv88e1xxx.c b/drivers/net/chelsio/mv88e1xxx.c
index 0632be0d6494..809047a99e96 100644
--- a/drivers/net/chelsio/mv88e1xxx.c
+++ b/drivers/net/chelsio/mv88e1xxx.c
@@ -353,15 +353,16 @@ static struct cphy_ops mv88e1xxx_ops = {
.get_link_status = mv88e1xxx_get_link_status,
};
-static struct cphy *mv88e1xxx_phy_create(adapter_t *adapter, int phy_addr,
+static struct cphy *mv88e1xxx_phy_create(struct net_device *dev, int phy_addr,
const struct mdio_ops *mdio_ops)
{
+ struct adapter *adapter = netdev_priv(dev);
struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
if (!cphy)
return NULL;
- cphy_init(cphy, adapter, phy_addr, &mv88e1xxx_ops, mdio_ops);
+ cphy_init(cphy, dev, phy_addr, &mv88e1xxx_ops, mdio_ops);
/* Configure particular PHY's to run in a different mode. */
if ((board_info(adapter)->caps & SUPPORTED_TP) &&
diff --git a/drivers/net/chelsio/mv88x201x.c b/drivers/net/chelsio/mv88x201x.c
index cd856041af34..f7136b2fd1e5 100644
--- a/drivers/net/chelsio/mv88x201x.c
+++ b/drivers/net/chelsio/mv88x201x.c
@@ -53,7 +53,7 @@ static int led_init(struct cphy *cphy)
* Writing these bits maps control to another
* register. mmd(0x1) addr(0x7)
*/
- mdio_write(cphy, 0x3, 0x8304, 0xdddd);
+ cphy_mdio_write(cphy, MDIO_MMD_PCS, 0x8304, 0xdddd);
return 0;
}
@@ -62,14 +62,14 @@ static int led_link(struct cphy *cphy, u32 do_enable)
u32 led = 0;
#define LINK_ENABLE_BIT 0x1
- mdio_read(cphy, 0x1, 0x7, &led);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, &led);
if (do_enable & LINK_ENABLE_BIT) {
led |= LINK_ENABLE_BIT;
- mdio_write(cphy, 0x1, 0x7, led);
+ cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, led);
} else {
led &= ~LINK_ENABLE_BIT;
- mdio_write(cphy, 0x1, 0x7, led);
+ cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, led);
}
return 0;
}
@@ -86,7 +86,8 @@ static int mv88x201x_reset(struct cphy *cphy, int wait)
static int mv88x201x_interrupt_enable(struct cphy *cphy)
{
/* Enable PHY LASI interrupts. */
- mdio_write(cphy, 0x1, 0x9002, 0x1);
+ cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL,
+ MDIO_PMA_LASI_LSALARM);
/* Enable Marvell interrupts through Elmer0. */
if (t1_is_asic(cphy->adapter)) {
@@ -102,7 +103,7 @@ static int mv88x201x_interrupt_enable(struct cphy *cphy)
static int mv88x201x_interrupt_disable(struct cphy *cphy)
{
/* Disable PHY LASI interrupts. */
- mdio_write(cphy, 0x1, 0x9002, 0x0);
+ cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL, 0x0);
/* Disable Marvell interrupts through Elmer0. */
if (t1_is_asic(cphy->adapter)) {
@@ -122,25 +123,25 @@ static int mv88x201x_interrupt_clear(struct cphy *cphy)
#ifdef MV88x2010_LINK_STATUS_BUGS
/* Required to read twice before clear takes affect. */
- mdio_read(cphy, 0x1, 0x9003, &val);
- mdio_read(cphy, 0x1, 0x9004, &val);
- mdio_read(cphy, 0x1, 0x9005, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_RXSTAT, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_TXSTAT, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
/* Read this register after the others above it else
* the register doesn't clear correctly.
*/
- mdio_read(cphy, 0x1, 0x1, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
#endif
/* Clear link status. */
- mdio_read(cphy, 0x1, 0x1, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
/* Clear PHY LASI interrupts. */
- mdio_read(cphy, 0x1, 0x9005, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
#ifdef MV88x2010_LINK_STATUS_BUGS
/* Do it again. */
- mdio_read(cphy, 0x1, 0x9003, &val);
- mdio_read(cphy, 0x1, 0x9004, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_RXSTAT, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_TXSTAT, &val);
#endif
/* Clear Marvell interrupts through Elmer0. */
@@ -172,13 +173,12 @@ static int mv88x201x_get_link_status(struct cphy *cphy, int *link_ok,
int *speed, int *duplex, int *fc)
{
u32 val = 0;
-#define LINK_STATUS_BIT 0x4
if (link_ok) {
/* Read link status. */
- mdio_read(cphy, 0x1, 0x1, &val);
- val &= LINK_STATUS_BIT;
- *link_ok = (val == LINK_STATUS_BIT);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
+ val &= MDIO_STAT1_LSTATUS;
+ *link_ok = (val == MDIO_STAT1_LSTATUS);
/* Turn on/off Link LED */
led_link(cphy, *link_ok);
}
@@ -205,9 +205,11 @@ static struct cphy_ops mv88x201x_ops = {
.interrupt_handler = mv88x201x_interrupt_handler,
.get_link_status = mv88x201x_get_link_status,
.set_loopback = mv88x201x_set_loopback,
+ .mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
+ MDIO_DEVS_PHYXS | MDIO_DEVS_WIS),
};
-static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr,
+static struct cphy *mv88x201x_phy_create(struct net_device *dev, int phy_addr,
const struct mdio_ops *mdio_ops)
{
u32 val;
@@ -216,15 +218,15 @@ static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr,
if (!cphy)
return NULL;
- cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);
+ cphy_init(cphy, dev, phy_addr, &mv88x201x_ops, mdio_ops);
/* Commands the PHY to enable XFP's clock. */
- mdio_read(cphy, 0x3, 0x8300, &val);
- mdio_write(cphy, 0x3, 0x8300, val | 1);
+ cphy_mdio_read(cphy, MDIO_MMD_PCS, 0x8300, &val);
+ cphy_mdio_write(cphy, MDIO_MMD_PCS, 0x8300, val | 1);
/* Clear link status. Required because of a bug in the PHY. */
- mdio_read(cphy, 0x1, 0x8, &val);
- mdio_read(cphy, 0x3, 0x8, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT2, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PCS, MDIO_STAT2, &val);
/* Allows for Link,Ack LED turn on/off */
led_init(cphy);
diff --git a/drivers/net/chelsio/my3126.c b/drivers/net/chelsio/my3126.c
index 040acd29995a..4c6028512d10 100644
--- a/drivers/net/chelsio/my3126.c
+++ b/drivers/net/chelsio/my3126.c
@@ -43,11 +43,11 @@ static int my3126_interrupt_handler(struct cphy *cphy)
adapter = cphy->adapter;
if (cphy->count == 50) {
- mdio_read(cphy, 0x1, 0x1, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
val16 = (u16) val;
status = cphy->bmsr ^ val16;
- if (status & BMSR_LSTATUS)
+ if (status & MDIO_STAT1_LSTATUS)
t1_link_changed(adapter, 0);
cphy->bmsr = val16;
@@ -114,14 +114,14 @@ static int my3126_get_link_status(struct cphy *cphy,
adapter_t *adapter;
adapter = cphy->adapter;
- mdio_read(cphy, 0x1, 0x1, &val);
+ cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
val16 = (u16) val;
/* Populate elmer_gpo with the register value */
t1_tpi_read(adapter, A_ELMER0_GPO, &val);
cphy->elmer_gpo = val;
- *link_ok = (val16 & BMSR_LSTATUS);
+ *link_ok = (val16 & MDIO_STAT1_LSTATUS);
if (*link_ok) {
/* Turn on the LED. */
@@ -163,9 +163,11 @@ static struct cphy_ops my3126_ops = {
.interrupt_handler = my3126_interrupt_handler,
.get_link_status = my3126_get_link_status,
.set_loopback = my3126_set_loopback,
+ .mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
+ MDIO_DEVS_PHYXS),
};
-static struct cphy *my3126_phy_create(adapter_t *adapter,
+static struct cphy *my3126_phy_create(struct net_device *dev,
int phy_addr, const struct mdio_ops *mdio_ops)
{
struct cphy *cphy = kzalloc(sizeof (*cphy), GFP_KERNEL);
@@ -173,7 +175,7 @@ static struct cphy *my3126_phy_create(adapter_t *adapter,
if (!cphy)
return NULL;
- cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
+ cphy_init(cphy, dev, phy_addr, &my3126_ops, mdio_ops);
INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll);
cphy->bmsr = 0;
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 58f6fc055f6a..5e97a1a71d88 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -1149,8 +1149,8 @@ static inline void write_tx_desc(struct cmdQ_e *e, dma_addr_t mapping,
unsigned int len, unsigned int gen,
unsigned int eop)
{
- if (unlikely(len > SGE_TX_DESC_MAX_PLEN))
- BUG();
+ BUG_ON(len > SGE_TX_DESC_MAX_PLEN);
+
e->addr_lo = (u32)mapping;
e->addr_hi = (u64)mapping >> 32;
e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);
diff --git a/drivers/net/chelsio/subr.c b/drivers/net/chelsio/subr.c
index 7adf30230c4f..17720c6e5bfe 100644
--- a/drivers/net/chelsio/subr.c
+++ b/drivers/net/chelsio/subr.c
@@ -284,32 +284,29 @@ static void mi1_mdio_init(adapter_t *adapter, const struct board_info *bi)
/*
* Elmer MI1 MDIO read/write operations.
*/
-static int mi1_mdio_read(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *valp)
+static int mi1_mdio_read(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr)
{
+ struct adapter *adapter = dev->ml_priv;
u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
-
- if (mmd_addr)
- return -EINVAL;
+ unsigned int val;
spin_lock(&adapter->tpi_lock);
__t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
__t1_tpi_write(adapter,
A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_READ);
mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
- __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
+ __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, &val);
spin_unlock(&adapter->tpi_lock);
- return 0;
+ return val;
}
-static int mi1_mdio_write(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val)
+static int mi1_mdio_write(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr, u16 val)
{
+ struct adapter *adapter = dev->ml_priv;
u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
- if (mmd_addr)
- return -EINVAL;
-
spin_lock(&adapter->tpi_lock);
__t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
__t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
@@ -324,16 +321,19 @@ static int mi1_mdio_write(adapter_t *adapter, int phy_addr, int mmd_addr,
static const struct mdio_ops mi1_mdio_ops = {
.init = mi1_mdio_init,
.read = mi1_mdio_read,
- .write = mi1_mdio_write
+ .write = mi1_mdio_write,
+ .mode_support = MDIO_SUPPORTS_C22
};
#endif
#endif
-static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *valp)
+static int mi1_mdio_ext_read(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr)
{
+ struct adapter *adapter = dev->ml_priv;
u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
+ unsigned int val;
spin_lock(&adapter->tpi_lock);
@@ -350,14 +350,15 @@ static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
/* Read the data. */
- __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
+ __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, &val);
spin_unlock(&adapter->tpi_lock);
- return 0;
+ return val;
}
-static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val)
+static int mi1_mdio_ext_write(struct net_device *dev, int phy_addr,
+ int mmd_addr, u16 reg_addr, u16 val)
{
+ struct adapter *adapter = dev->ml_priv;
u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
spin_lock(&adapter->tpi_lock);
@@ -380,7 +381,8 @@ static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
static const struct mdio_ops mi1_mdio_ext_ops = {
.init = mi1_mdio_init,
.read = mi1_mdio_ext_read,
- .write = mi1_mdio_ext_write
+ .write = mi1_mdio_ext_write,
+ .mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22
};
enum {
@@ -1133,8 +1135,8 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
struct cmac *mac;
int phy_addr = bi->mdio_phybaseaddr + i;
- adapter->port[i].phy = bi->gphy->create(adapter, phy_addr,
- bi->mdio_ops);
+ adapter->port[i].phy = bi->gphy->create(adapter->port[i].dev,
+ phy_addr, bi->mdio_ops);
if (!adapter->port[i].phy) {
CH_ERR("%s: PHY %d initialization failed\n",
adapter->name, i);
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 3f476c7c0736..af305c0b34d1 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1093,6 +1093,19 @@ static int cpmac_stop(struct net_device *dev)
return 0;
}
+static const struct net_device_ops cpmac_netdev_ops = {
+ .ndo_open = cpmac_open,
+ .ndo_stop = cpmac_stop,
+ .ndo_start_xmit = cpmac_start_xmit,
+ .ndo_tx_timeout = cpmac_tx_timeout,
+ .ndo_set_multicast_list = cpmac_set_multicast_list,
+ .ndo_so_ioctl = cpmac_ioctl,
+ .ndo_set_config = cpmac_config,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int external_switch;
static int __devinit cpmac_probe(struct platform_device *pdev)
@@ -1143,14 +1156,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
dev->irq = platform_get_irq_byname(pdev, "irq");
- dev->open = cpmac_open;
- dev->stop = cpmac_stop;
- dev->set_config = cpmac_config;
- dev->hard_start_xmit = cpmac_start_xmit;
- dev->do_ioctl = cpmac_ioctl;
- dev->set_multicast_list = cpmac_set_multicast_list;
- dev->tx_timeout = cpmac_tx_timeout;
- dev->ethtool_ops = &cpmac_ethtool_ops;
+ dev->netdev_ops = &cpmac_netdev_ops;
+ dev->ethtool_ops = &cpmac_ethtool_ops;
netif_napi_add(dev, &priv->napi, cpmac_poll, 64);
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 714df2b675e6..322434ac42fc 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -195,7 +195,7 @@ struct sge_qset { /* an SGE queue set */
struct sge_rspq rspq;
struct sge_fl fl[SGE_RXQ_PER_SET];
struct sge_txq txq[SGE_TXQ_PER_SET];
- struct napi_gro_fraginfo lro_frag_tbl;
+ int nomem;
int lro_enabled;
void *lro_va;
struct net_device *netdev;
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c
index e1b22490ff59..df1f58576689 100644
--- a/drivers/net/cxgb3/ael1002.c
+++ b/drivers/net/cxgb3/ael1002.c
@@ -33,14 +33,6 @@
#include "regs.h"
enum {
- PMD_RSD = 10, /* PMA/PMD receive signal detect register */
- PCS_STAT1_X = 24, /* 10GBASE-X PCS status 1 register */
- PCS_STAT1_R = 32, /* 10GBASE-R PCS status 1 register */
- XS_LN_STAT = 24 /* XS lane status register */
-};
-
-enum {
- AEL100X_TX_DISABLE = 9,
AEL100X_TX_CONFIG1 = 0xc002,
AEL1002_PWR_DOWN_HI = 0xc011,
AEL1002_PWR_DOWN_LO = 0xc012,
@@ -74,8 +66,8 @@ static int set_phy_regs(struct cphy *phy, const struct reg_val *rv)
for (err = 0; rv->mmd_addr && !err; rv++) {
if (rv->clear_bits == 0xffff)
- err = mdio_write(phy, rv->mmd_addr, rv->reg_addr,
- rv->set_bits);
+ err = t3_mdio_write(phy, rv->mmd_addr, rv->reg_addr,
+ rv->set_bits);
else
err = t3_mdio_change_bits(phy, rv->mmd_addr,
rv->reg_addr, rv->clear_bits,
@@ -86,7 +78,8 @@ static int set_phy_regs(struct cphy *phy, const struct reg_val *rv)
static void ael100x_txon(struct cphy *phy)
{
- int tx_on_gpio = phy->addr == 0 ? F_GPIO7_OUT_VAL : F_GPIO2_OUT_VAL;
+ int tx_on_gpio =
+ phy->mdio.prtad == 0 ? F_GPIO7_OUT_VAL : F_GPIO2_OUT_VAL;
msleep(100);
t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN, 0, tx_on_gpio);
@@ -97,10 +90,11 @@ static int ael1002_power_down(struct cphy *phy, int enable)
{
int err;
- err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_DISABLE, !!enable);
+ err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, MDIO_PMA_TXDIS, !!enable);
if (!err)
- err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR,
- BMCR_PDOWN, enable ? BMCR_PDOWN : 0);
+ err = mdio_set_flag(&phy->mdio, phy->mdio.prtad,
+ MDIO_MMD_PMAPMD, MDIO_CTRL1,
+ MDIO_CTRL1_LPOWER, enable);
return err;
}
@@ -109,11 +103,11 @@ static int ael1002_reset(struct cphy *phy, int wait)
int err;
if ((err = ael1002_power_down(phy, 0)) ||
- (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_CONFIG1, 1)) ||
- (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_HI, 0)) ||
- (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_LO, 0)) ||
- (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_XFI_EQL, 0x18)) ||
- (err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL1002_LB_EN,
+ (err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL100X_TX_CONFIG1, 1)) ||
+ (err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL1002_PWR_DOWN_HI, 0)) ||
+ (err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL1002_PWR_DOWN_LO, 0)) ||
+ (err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL1002_XFI_EQL, 0x18)) ||
+ (err = t3_mdio_change_bits(phy, MDIO_MMD_PMAPMD, AEL1002_LB_EN,
0, 1 << 5)))
return err;
return 0;
@@ -132,12 +126,15 @@ static int get_link_status_r(struct cphy *phy, int *link_ok, int *speed,
{
if (link_ok) {
unsigned int stat0, stat1, stat2;
- int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0);
+ int err = t3_mdio_read(phy, MDIO_MMD_PMAPMD,
+ MDIO_PMA_RXDET, &stat0);
if (!err)
- err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_R, &stat1);
+ err = t3_mdio_read(phy, MDIO_MMD_PCS,
+ MDIO_PCS_10GBRT_STAT1, &stat1);
if (!err)
- err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2);
+ err = t3_mdio_read(phy, MDIO_MMD_PHYXS,
+ MDIO_PHYXS_LNSTAT, &stat2);
if (err)
return err;
*link_ok = (stat0 & stat1 & (stat2 >> 12)) & 1;
@@ -157,6 +154,7 @@ static struct cphy_ops ael1002_ops = {
.intr_handler = ael1002_intr_noop,
.get_link_status = get_link_status_r,
.power_down = ael1002_power_down,
+ .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS,
};
int t3_ael1002_phy_prep(struct cphy *phy, struct adapter *adapter,
@@ -171,13 +169,13 @@ int t3_ael1002_phy_prep(struct cphy *phy, struct adapter *adapter,
static int ael1006_reset(struct cphy *phy, int wait)
{
- return t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait);
+ return t3_phy_reset(phy, MDIO_MMD_PMAPMD, wait);
}
static int ael1006_power_down(struct cphy *phy, int enable)
{
- return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR,
- BMCR_PDOWN, enable ? BMCR_PDOWN : 0);
+ return mdio_set_flag(&phy->mdio, phy->mdio.prtad, MDIO_MMD_PMAPMD,
+ MDIO_CTRL1, MDIO_CTRL1_LPOWER, enable);
}
static struct cphy_ops ael1006_ops = {
@@ -188,6 +186,7 @@ static struct cphy_ops ael1006_ops = {
.intr_handler = t3_phy_lasi_intr_handler,
.get_link_status = get_link_status_r,
.power_down = ael1006_power_down,
+ .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS,
};
int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter,
@@ -203,9 +202,9 @@ int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter,
static int ael2005_setup_sr_edc(struct cphy *phy)
{
static struct reg_val regs[] = {
- { MDIO_DEV_PMA_PMD, 0xc003, 0xffff, 0x181 },
- { MDIO_DEV_PMA_PMD, 0xc010, 0xffff, 0x448a },
- { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5200 },
+ { MDIO_MMD_PMAPMD, 0xc003, 0xffff, 0x181 },
+ { MDIO_MMD_PMAPMD, 0xc010, 0xffff, 0x448a },
+ { MDIO_MMD_PMAPMD, 0xc04a, 0xffff, 0x5200 },
{ 0, 0, 0, 0 }
};
static u16 sr_edc[] = {
@@ -490,8 +489,8 @@ static int ael2005_setup_sr_edc(struct cphy *phy)
msleep(50);
for (i = 0; i < ARRAY_SIZE(sr_edc) && !err; i += 2)
- err = mdio_write(phy, MDIO_DEV_PMA_PMD, sr_edc[i],
- sr_edc[i + 1]);
+ err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, sr_edc[i],
+ sr_edc[i + 1]);
if (!err)
phy->priv = edc_sr;
return err;
@@ -500,12 +499,12 @@ static int ael2005_setup_sr_edc(struct cphy *phy)
static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype)
{
static struct reg_val regs[] = {
- { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5a00 },
+ { MDIO_MMD_PMAPMD, 0xc04a, 0xffff, 0x5a00 },
{ 0, 0, 0, 0 }
};
static struct reg_val preemphasis[] = {
- { MDIO_DEV_PMA_PMD, 0xc014, 0xffff, 0xfe16 },
- { MDIO_DEV_PMA_PMD, 0xc015, 0xffff, 0xa000 },
+ { MDIO_MMD_PMAPMD, 0xc014, 0xffff, 0xfe16 },
+ { MDIO_MMD_PMAPMD, 0xc015, 0xffff, 0xa000 },
{ 0, 0, 0, 0 }
};
static u16 twinax_edc[] = {
@@ -887,8 +886,8 @@ static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype)
msleep(50);
for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2)
- err = mdio_write(phy, MDIO_DEV_PMA_PMD, twinax_edc[i],
- twinax_edc[i + 1]);
+ err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, twinax_edc[i],
+ twinax_edc[i + 1]);
if (!err)
phy->priv = edc_twinax;
return err;
@@ -899,26 +898,26 @@ static int ael2005_i2c_rd(struct cphy *phy, int dev_addr, int word_addr)
int i, err;
unsigned int stat, data;
- err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL,
- (dev_addr << 8) | (1 << 8) | word_addr);
+ err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL_I2C_CTRL,
+ (dev_addr << 8) | (1 << 8) | word_addr);
if (err)
return err;
for (i = 0; i < 5; i++) {
msleep(1);
- err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat);
+ err = t3_mdio_read(phy, MDIO_MMD_PMAPMD, AEL_I2C_STAT, &stat);
if (err)
return err;
if ((stat & 3) == 1) {
- err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA,
- &data);
+ err = t3_mdio_read(phy, MDIO_MMD_PMAPMD, AEL_I2C_DATA,
+ &data);
if (err)
return err;
return data >> 8;
}
}
CH_WARN(phy->adapter, "PHY %u I2C read of addr %u timed out\n",
- phy->addr, word_addr);
+ phy->mdio.prtad, word_addr);
return -ETIMEDOUT;
}
@@ -927,7 +926,7 @@ static int get_module_type(struct cphy *phy, int delay_ms)
int v;
unsigned int stat;
- v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat);
+ v = t3_mdio_read(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_CTRL, &stat);
if (v)
return v;
@@ -971,48 +970,49 @@ unknown:
static int ael2005_intr_enable(struct cphy *phy)
{
- int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x200);
+ int err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_CTRL, 0x200);
return err ? err : t3_phy_lasi_intr_enable(phy);
}
static int ael2005_intr_disable(struct cphy *phy)
{
- int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x100);
+ int err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_CTRL, 0x100);
return err ? err : t3_phy_lasi_intr_disable(phy);
}
static int ael2005_intr_clear(struct cphy *phy)
{
- int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0xd00);
+ int err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_CTRL, 0xd00);
return err ? err : t3_phy_lasi_intr_clear(phy);
}
static int ael2005_reset(struct cphy *phy, int wait)
{
static struct reg_val regs0[] = {
- { MDIO_DEV_PMA_PMD, 0xc001, 0, 1 << 5 },
- { MDIO_DEV_PMA_PMD, 0xc017, 0, 1 << 5 },
- { MDIO_DEV_PMA_PMD, 0xc013, 0xffff, 0xf341 },
- { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 },
- { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8100 },
- { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 },
- { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0 },
+ { MDIO_MMD_PMAPMD, 0xc001, 0, 1 << 5 },
+ { MDIO_MMD_PMAPMD, 0xc017, 0, 1 << 5 },
+ { MDIO_MMD_PMAPMD, 0xc013, 0xffff, 0xf341 },
+ { MDIO_MMD_PMAPMD, 0xc210, 0xffff, 0x8000 },
+ { MDIO_MMD_PMAPMD, 0xc210, 0xffff, 0x8100 },
+ { MDIO_MMD_PMAPMD, 0xc210, 0xffff, 0x8000 },
+ { MDIO_MMD_PMAPMD, 0xc210, 0xffff, 0 },
{ 0, 0, 0, 0 }
};
static struct reg_val regs1[] = {
- { MDIO_DEV_PMA_PMD, 0xca00, 0xffff, 0x0080 },
- { MDIO_DEV_PMA_PMD, 0xca12, 0xffff, 0 },
+ { MDIO_MMD_PMAPMD, 0xca00, 0xffff, 0x0080 },
+ { MDIO_MMD_PMAPMD, 0xca12, 0xffff, 0 },
{ 0, 0, 0, 0 }
};
int err;
unsigned int lasi_ctrl;
- err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, &lasi_ctrl);
+ err = t3_mdio_read(phy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL,
+ &lasi_ctrl);
if (err)
return err;
- err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, 0);
+ err = t3_phy_reset(phy, MDIO_MMD_PMAPMD, 0);
if (err)
return err;
@@ -1051,13 +1051,13 @@ static int ael2005_intr_handler(struct cphy *phy)
unsigned int stat;
int ret, edc_needed, cause = 0;
- ret = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_STAT, &stat);
+ ret = t3_mdio_read(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_STAT, &stat);
if (ret)
return ret;
if (stat & AEL2005_MODDET_IRQ) {
- ret = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL,
- 0xd00);
+ ret = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_CTRL,
+ 0xd00);
if (ret)
return ret;
@@ -1098,6 +1098,7 @@ static struct cphy_ops ael2005_ops = {
.intr_handler = ael2005_intr_handler,
.get_link_status = get_link_status_r,
.power_down = ael1002_power_down,
+ .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS,
};
int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter,
@@ -1107,7 +1108,7 @@ int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter,
SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE |
SUPPORTED_IRQ, "10GBASE-R");
msleep(125);
- return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL_OPT_SETTINGS, 0,
+ return t3_mdio_change_bits(phy, MDIO_MMD_PMAPMD, AEL_OPT_SETTINGS, 0,
1 << 5);
}
@@ -1119,12 +1120,15 @@ static int get_link_status_x(struct cphy *phy, int *link_ok, int *speed,
{
if (link_ok) {
unsigned int stat0, stat1, stat2;
- int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0);
+ int err = t3_mdio_read(phy, MDIO_MMD_PMAPMD,
+ MDIO_PMA_RXDET, &stat0);
if (!err)
- err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_X, &stat1);
+ err = t3_mdio_read(phy, MDIO_MMD_PCS,
+ MDIO_PCS_10GBX_STAT1, &stat1);
if (!err)
- err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2);
+ err = t3_mdio_read(phy, MDIO_MMD_PHYXS,
+ MDIO_PHYXS_LNSTAT, &stat2);
if (err)
return err;
*link_ok = (stat0 & (stat1 >> 12) & (stat2 >> 12)) & 1;
@@ -1144,6 +1148,7 @@ static struct cphy_ops qt2045_ops = {
.intr_handler = t3_phy_lasi_intr_handler,
.get_link_status = get_link_status_x,
.power_down = ael1006_power_down,
+ .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS,
};
int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter,
@@ -1159,9 +1164,10 @@ int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter,
* Some cards where the PHY is supposed to be at address 0 actually
* have it at 1.
*/
- if (!phy_addr && !mdio_read(phy, MDIO_DEV_PMA_PMD, MII_BMSR, &stat) &&
+ if (!phy_addr &&
+ !t3_mdio_read(phy, MDIO_MMD_PMAPMD, MDIO_STAT1, &stat) &&
stat == 0xffff)
- phy->addr = 1;
+ phy->mdio.prtad = 1;
return 0;
}
@@ -1175,15 +1181,16 @@ static int xaui_direct_get_link_status(struct cphy *phy, int *link_ok,
{
if (link_ok) {
unsigned int status;
+ int prtad = phy->mdio.prtad;
status = t3_read_reg(phy->adapter,
- XGM_REG(A_XGM_SERDES_STAT0, phy->addr)) |
+ XGM_REG(A_XGM_SERDES_STAT0, prtad)) |
t3_read_reg(phy->adapter,
- XGM_REG(A_XGM_SERDES_STAT1, phy->addr)) |
+ XGM_REG(A_XGM_SERDES_STAT1, prtad)) |
t3_read_reg(phy->adapter,
- XGM_REG(A_XGM_SERDES_STAT2, phy->addr)) |
+ XGM_REG(A_XGM_SERDES_STAT2, prtad)) |
t3_read_reg(phy->adapter,
- XGM_REG(A_XGM_SERDES_STAT3, phy->addr));
+ XGM_REG(A_XGM_SERDES_STAT3, prtad));
*link_ok = !(status & F_LOWSIG0);
}
if (speed)
@@ -1211,7 +1218,7 @@ static struct cphy_ops xaui_direct_ops = {
int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter,
int phy_addr, const struct mdio_ops *mdio_ops)
{
- cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops,
+ cphy_init(phy, adapter, MDIO_PRTAD_NONE, &xaui_direct_ops, mdio_ops,
SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP,
"10GBASE-CX4");
return 0;
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index e508dc32f3ec..79a113b99e2f 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -39,7 +39,7 @@
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
-#include <linux/mii.h>
+#include <linux/mdio.h>
#include "version.h"
#define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ## __VA_ARGS__)
@@ -184,10 +184,11 @@ struct cphy;
struct adapter;
struct mdio_ops {
- int (*read)(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *val);
- int (*write)(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val);
+ int (*read)(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr);
+ int (*write)(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr, u16 val);
+ unsigned mode_support;
};
struct adapter_info {
@@ -520,27 +521,6 @@ enum {
MAC_RXFIFO_SIZE = 32768
};
-/* IEEE 802.3 specified MDIO devices */
-enum {
- MDIO_DEV_PMA_PMD = 1,
- MDIO_DEV_WIS = 2,
- MDIO_DEV_PCS = 3,
- MDIO_DEV_XGXS = 4,
- MDIO_DEV_ANEG = 7,
- MDIO_DEV_VEND1 = 30,
- MDIO_DEV_VEND2 = 31
-};
-
-/* LASI control and status registers */
-enum {
- RX_ALARM_CTRL = 0x9000,
- TX_ALARM_CTRL = 0x9001,
- LASI_CTRL = 0x9002,
- RX_ALARM_STAT = 0x9003,
- TX_ALARM_STAT = 0x9004,
- LASI_STAT = 0x9005
-};
-
/* PHY loopback direction */
enum {
PHY_LOOPBACK_TX = 1,
@@ -583,11 +563,12 @@ struct cphy_ops {
int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
int *duplex, int *fc);
int (*power_down)(struct cphy *phy, int enable);
+
+ u32 mmds;
};
/* A PHY instance */
struct cphy {
- u8 addr; /* PHY address */
u8 modtype; /* PHY module type */
short priv; /* scratch pad */
unsigned int caps; /* PHY capabilities */
@@ -595,23 +576,23 @@ struct cphy {
const char *desc; /* PHY description */
unsigned long fifo_errors; /* FIFO over/under-flows */
const struct cphy_ops *ops; /* PHY operations */
- int (*mdio_read)(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *val);
- int (*mdio_write)(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val);
+ struct mdio_if_info mdio;
};
/* Convenience MDIO read/write wrappers */
-static inline int mdio_read(struct cphy *phy, int mmd, int reg,
- unsigned int *valp)
+static inline int t3_mdio_read(struct cphy *phy, int mmd, int reg,
+ unsigned int *valp)
{
- return phy->mdio_read(phy->adapter, phy->addr, mmd, reg, valp);
+ int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg);
+ *valp = (rc >= 0) ? rc : -1;
+ return (rc >= 0) ? 0 : rc;
}
-static inline int mdio_write(struct cphy *phy, int mmd, int reg,
- unsigned int val)
+static inline int t3_mdio_write(struct cphy *phy, int mmd, int reg,
+ unsigned int val)
{
- return phy->mdio_write(phy->adapter, phy->addr, mmd, reg, val);
+ return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd,
+ reg, val);
}
/* Convenience initializer */
@@ -620,14 +601,16 @@ static inline void cphy_init(struct cphy *phy, struct adapter *adapter,
const struct mdio_ops *mdio_ops,
unsigned int caps, const char *desc)
{
- phy->addr = phy_addr;
phy->caps = caps;
phy->adapter = adapter;
phy->desc = desc;
phy->ops = phy_ops;
if (mdio_ops) {
- phy->mdio_read = mdio_ops->read;
- phy->mdio_write = mdio_ops->write;
+ phy->mdio.prtad = phy_addr;
+ phy->mdio.mmds = phy_ops->mmds;
+ phy->mdio.mode_support = mdio_ops->mode_support;
+ phy->mdio.mdio_read = mdio_ops->read;
+ phy->mdio.mdio_write = mdio_ops->write;
}
}
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 7ea48414c6cb..0b87fee023f5 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -37,7 +37,7 @@
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
-#include <linux/mii.h>
+#include <linux/mdio.h>
#include <linux/sockios.h>
#include <linux/workqueue.h>
#include <linux/proc_fs.h>
@@ -1593,7 +1593,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
}
cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
- cmd->phy_address = p->phy.addr;
+ cmd->phy_address = p->phy.mdio.prtad;
cmd->transceiver = XCVR_EXTERNAL;
cmd->autoneg = p->link_config.autoneg;
cmd->maxtxpkt = 0;
@@ -2308,70 +2308,25 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
struct mii_ioctl_data *data = if_mii(req);
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
- int ret, mmd;
switch (cmd) {
- case SIOCGMIIPHY:
- data->phy_id = pi->phy.addr;
+ case SIOCGMIIREG:
+ case SIOCSMIIREG:
+ /* Convert phy_id from older PRTAD/DEVAD format */
+ if (is_10G(adapter) &&
+ !mdio_phy_id_is_c45(data->phy_id) &&
+ (data->phy_id & 0x1f00) &&
+ !(data->phy_id & 0xe0e0))
+ data->phy_id = mdio_phy_id_c45(data->phy_id >> 8,
+ data->phy_id & 0x1f);
/* FALLTHRU */
- case SIOCGMIIREG:{
- u32 val;
- struct cphy *phy = &pi->phy;
-
- if (!phy->mdio_read)
- return -EOPNOTSUPP;
- if (is_10G(adapter)) {
- mmd = data->phy_id >> 8;
- if (!mmd)
- mmd = MDIO_DEV_PCS;
- else if (mmd > MDIO_DEV_VEND2)
- return -EINVAL;
-
- ret =
- phy->mdio_read(adapter, data->phy_id & 0x1f,
- mmd, data->reg_num, &val);
- } else
- ret =
- phy->mdio_read(adapter, data->phy_id & 0x1f,
- 0, data->reg_num & 0x1f,
- &val);
- if (!ret)
- data->val_out = val;
- break;
- }
- case SIOCSMIIREG:{
- struct cphy *phy = &pi->phy;
-
- if (!capable(CAP_NET_ADMIN))
- return -EPERM;
- if (!phy->mdio_write)
- return -EOPNOTSUPP;
- if (is_10G(adapter)) {
- mmd = data->phy_id >> 8;
- if (!mmd)
- mmd = MDIO_DEV_PCS;
- else if (mmd > MDIO_DEV_VEND2)
- return -EINVAL;
-
- ret =
- phy->mdio_write(adapter,
- data->phy_id & 0x1f, mmd,
- data->reg_num,
- data->val_in);
- } else
- ret =
- phy->mdio_write(adapter,
- data->phy_id & 0x1f, 0,
- data->reg_num & 0x1f,
- data->val_in);
- break;
- }
+ case SIOCGMIIPHY:
+ return mdio_mii_ioctl(&pi->phy.mdio, data, cmd);
case SIOCCHIOCTL:
return cxgb_extension_ioctl(dev, req->ifr_data);
default:
return -EOPNOTSUPP;
}
- return ret;
}
static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 26d3587f3399..73d569e758ec 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -654,7 +654,8 @@ static void t3_reset_qset(struct sge_qset *q)
q->txq_stopped = 0;
q->tx_reclaim_timer.function = NULL; /* for t3_stop_sge_timers() */
q->rx_reclaim_timer.function = NULL;
- q->lro_frag_tbl.nr_frags = q->lro_frag_tbl.len = 0;
+ q->nomem = 0;
+ napi_free_frags(&q->napi);
}
@@ -2074,20 +2075,19 @@ static void lro_add_page(struct adapter *adap, struct sge_qset *qs,
struct sge_fl *fl, int len, int complete)
{
struct rx_sw_desc *sd = &fl->sdesc[fl->cidx];
+ struct sk_buff *skb = NULL;
struct cpl_rx_pkt *cpl;
- struct skb_frag_struct *rx_frag = qs->lro_frag_tbl.frags;
- int nr_frags = qs->lro_frag_tbl.nr_frags;
- int frag_len = qs->lro_frag_tbl.len;
+ struct skb_frag_struct *rx_frag;
+ int nr_frags;
int offset = 0;
- if (!nr_frags) {
- offset = 2 + sizeof(struct cpl_rx_pkt);
- qs->lro_va = cpl = sd->pg_chunk.va + 2;
+ if (!qs->nomem) {
+ skb = napi_get_frags(&qs->napi);
+ qs->nomem = !skb;
}
fl->credits--;
- len -= offset;
pci_dma_sync_single_for_cpu(adap->pdev,
pci_unmap_addr(sd, dma_addr),
fl->buf_size - SGE_PG_RSVD,
@@ -2100,21 +2100,38 @@ static void lro_add_page(struct adapter *adap, struct sge_qset *qs,
fl->alloc_size,
PCI_DMA_FROMDEVICE);
+ if (!skb) {
+ put_page(sd->pg_chunk.page);
+ if (complete)
+ qs->nomem = 0;
+ return;
+ }
+
+ rx_frag = skb_shinfo(skb)->frags;
+ nr_frags = skb_shinfo(skb)->nr_frags;
+
+ if (!nr_frags) {
+ offset = 2 + sizeof(struct cpl_rx_pkt);
+ qs->lro_va = sd->pg_chunk.va + 2;
+ }
+ len -= offset;
+
prefetch(qs->lro_va);
rx_frag += nr_frags;
rx_frag->page = sd->pg_chunk.page;
rx_frag->page_offset = sd->pg_chunk.offset + offset;
rx_frag->size = len;
- frag_len += len;
- qs->lro_frag_tbl.nr_frags++;
- qs->lro_frag_tbl.len = frag_len;
+ skb->len += len;
+ skb->data_len += len;
+ skb->truesize += len;
+ skb_shinfo(skb)->nr_frags++;
if (!complete)
return;
- qs->lro_frag_tbl.ip_summed = CHECKSUM_UNNECESSARY;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
cpl = qs->lro_va;
if (unlikely(cpl->vlan_valid)) {
@@ -2123,15 +2140,11 @@ static void lro_add_page(struct adapter *adap, struct sge_qset *qs,
struct vlan_group *grp = pi->vlan_grp;
if (likely(grp != NULL)) {
- vlan_gro_frags(&qs->napi, grp, ntohs(cpl->vlan),
- &qs->lro_frag_tbl);
- goto out;
+ vlan_gro_frags(&qs->napi, grp, ntohs(cpl->vlan));
+ return;
}
}
- napi_gro_frags(&qs->napi, &qs->lro_frag_tbl);
-
-out:
- qs->lro_frag_tbl.nr_frags = qs->lro_frag_tbl.len = 0;
+ napi_gro_frags(&qs->napi);
}
/**
@@ -2300,8 +2313,6 @@ no_mem:
if (fl->use_pages) {
void *addr = fl->sdesc[fl->cidx].pg_chunk.va;
- prefetch(&qs->lro_frag_tbl);
-
prefetch(addr);
#if L1_CACHE_BYTES < 128
prefetch(addr + L1_CACHE_BYTES);
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index 4f68aeb2679a..fc7db8a9ba89 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -204,35 +204,33 @@ static void mi1_init(struct adapter *adap, const struct adapter_info *ai)
/*
* MI1 read/write operations for clause 22 PHYs.
*/
-static int t3_mi1_read(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *valp)
+static int t3_mi1_read(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr)
{
+ struct port_info *pi = netdev_priv(dev);
+ struct adapter *adapter = pi->adapter;
int ret;
u32 addr = V_REGADDR(reg_addr) | V_PHYADDR(phy_addr);
- if (mmd_addr)
- return -EINVAL;
-
mutex_lock(&adapter->mdio_lock);
t3_set_reg_field(adapter, A_MI1_CFG, V_ST(M_ST), V_ST(1));
t3_write_reg(adapter, A_MI1_ADDR, addr);
t3_write_reg(adapter, A_MI1_OP, V_MDI_OP(2));
ret = t3_wait_op_done(adapter, A_MI1_OP, F_BUSY, 0, MDIO_ATTEMPTS, 10);
if (!ret)
- *valp = t3_read_reg(adapter, A_MI1_DATA);
+ ret = t3_read_reg(adapter, A_MI1_DATA);
mutex_unlock(&adapter->mdio_lock);
return ret;
}
-static int t3_mi1_write(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val)
+static int t3_mi1_write(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr, u16 val)
{
+ struct port_info *pi = netdev_priv(dev);
+ struct adapter *adapter = pi->adapter;
int ret;
u32 addr = V_REGADDR(reg_addr) | V_PHYADDR(phy_addr);
- if (mmd_addr)
- return -EINVAL;
-
mutex_lock(&adapter->mdio_lock);
t3_set_reg_field(adapter, A_MI1_CFG, V_ST(M_ST), V_ST(1));
t3_write_reg(adapter, A_MI1_ADDR, addr);
@@ -244,8 +242,9 @@ static int t3_mi1_write(struct adapter *adapter, int phy_addr, int mmd_addr,
}
static const struct mdio_ops mi1_mdio_ops = {
- t3_mi1_read,
- t3_mi1_write
+ .read = t3_mi1_read,
+ .write = t3_mi1_write,
+ .mode_support = MDIO_SUPPORTS_C22
};
/*
@@ -268,9 +267,11 @@ static int mi1_wr_addr(struct adapter *adapter, int phy_addr, int mmd_addr,
/*
* MI1 read/write operations for indirect-addressed PHYs.
*/
-static int mi1_ext_read(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int *valp)
+static int mi1_ext_read(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr)
{
+ struct port_info *pi = netdev_priv(dev);
+ struct adapter *adapter = pi->adapter;
int ret;
mutex_lock(&adapter->mdio_lock);
@@ -280,15 +281,17 @@ static int mi1_ext_read(struct adapter *adapter, int phy_addr, int mmd_addr,
ret = t3_wait_op_done(adapter, A_MI1_OP, F_BUSY, 0,
MDIO_ATTEMPTS, 10);
if (!ret)
- *valp = t3_read_reg(adapter, A_MI1_DATA);
+ ret = t3_read_reg(adapter, A_MI1_DATA);
}
mutex_unlock(&adapter->mdio_lock);
return ret;
}
-static int mi1_ext_write(struct adapter *adapter, int phy_addr, int mmd_addr,
- int reg_addr, unsigned int val)
+static int mi1_ext_write(struct net_device *dev, int phy_addr, int mmd_addr,
+ u16 reg_addr, u16 val)
{
+ struct port_info *pi = netdev_priv(dev);
+ struct adapter *adapter = pi->adapter;
int ret;
mutex_lock(&adapter->mdio_lock);
@@ -304,8 +307,9 @@ static int mi1_ext_write(struct adapter *adapter, int phy_addr, int mmd_addr,
}
static const struct mdio_ops mi1_mdio_ext_ops = {
- mi1_ext_read,
- mi1_ext_write
+ .read = mi1_ext_read,
+ .write = mi1_ext_write,
+ .mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22
};
/**
@@ -325,10 +329,10 @@ int t3_mdio_change_bits(struct cphy *phy, int mmd, int reg, unsigned int clear,
int ret;
unsigned int val;
- ret = mdio_read(phy, mmd, reg, &val);
+ ret = t3_mdio_read(phy, mmd, reg, &val);
if (!ret) {
val &= ~clear;
- ret = mdio_write(phy, mmd, reg, val | set);
+ ret = t3_mdio_write(phy, mmd, reg, val | set);
}
return ret;
}
@@ -348,15 +352,16 @@ int t3_phy_reset(struct cphy *phy, int mmd, int wait)
int err;
unsigned int ctl;
- err = t3_mdio_change_bits(phy, mmd, MII_BMCR, BMCR_PDOWN, BMCR_RESET);
+ err = t3_mdio_change_bits(phy, mmd, MDIO_CTRL1, MDIO_CTRL1_LPOWER,
+ MDIO_CTRL1_RESET);
if (err || !wait)
return err;
do {
- err = mdio_read(phy, mmd, MII_BMCR, &ctl);
+ err = t3_mdio_read(phy, mmd, MDIO_CTRL1, &ctl);
if (err)
return err;
- ctl &= BMCR_RESET;
+ ctl &= MDIO_CTRL1_RESET;
if (ctl)
msleep(1);
} while (ctl && --wait);
@@ -377,7 +382,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert)
int err;
unsigned int val = 0;
- err = mdio_read(phy, 0, MII_CTRL1000, &val);
+ err = t3_mdio_read(phy, MDIO_DEVAD_NONE, MII_CTRL1000, &val);
if (err)
return err;
@@ -387,7 +392,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert)
if (advert & ADVERTISED_1000baseT_Full)
val |= ADVERTISE_1000FULL;
- err = mdio_write(phy, 0, MII_CTRL1000, val);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_CTRL1000, val);
if (err)
return err;
@@ -404,7 +409,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert)
val |= ADVERTISE_PAUSE_CAP;
if (advert & ADVERTISED_Asym_Pause)
val |= ADVERTISE_PAUSE_ASYM;
- return mdio_write(phy, 0, MII_ADVERTISE, val);
+ return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_ADVERTISE, val);
}
/**
@@ -427,7 +432,7 @@ int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert)
val |= ADVERTISE_1000XPAUSE;
if (advert & ADVERTISED_Asym_Pause)
val |= ADVERTISE_1000XPSE_ASYM;
- return mdio_write(phy, 0, MII_ADVERTISE, val);
+ return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_ADVERTISE, val);
}
/**
@@ -444,7 +449,7 @@ int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex)
int err;
unsigned int ctl;
- err = mdio_read(phy, 0, MII_BMCR, &ctl);
+ err = t3_mdio_read(phy, MDIO_DEVAD_NONE, MII_BMCR, &ctl);
if (err)
return err;
@@ -462,34 +467,36 @@ int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex)
}
if (ctl & BMCR_SPEED1000) /* auto-negotiation required for GigE */
ctl |= BMCR_ANENABLE;
- return mdio_write(phy, 0, MII_BMCR, ctl);
+ return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_BMCR, ctl);
}
int t3_phy_lasi_intr_enable(struct cphy *phy)
{
- return mdio_write(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, 1);
+ return t3_mdio_write(phy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL,
+ MDIO_PMA_LASI_LSALARM);
}
int t3_phy_lasi_intr_disable(struct cphy *phy)
{
- return mdio_write(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, 0);
+ return t3_mdio_write(phy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL, 0);
}
int t3_phy_lasi_intr_clear(struct cphy *phy)
{
u32 val;
- return mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_STAT, &val);
+ return t3_mdio_read(phy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
}
int t3_phy_lasi_intr_handler(struct cphy *phy)
{
unsigned int status;
- int err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_STAT, &status);
+ int err = t3_mdio_read(phy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT,
+ &status);
if (err)
return err;
- return (status & 1) ? cphy_cause_link_change : 0;
+ return (status & MDIO_PMA_LASI_LSALARM) ? cphy_cause_link_change : 0;
}
static const struct adapter_info t3_adap_info[] = {
@@ -3859,6 +3866,7 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
return -EINVAL;
}
+ p->phy.mdio.dev = adapter->port[i];
ret = pti->phy_prep(&p->phy, adapter, ai->phy_base_addr + j,
ai->mdio_ops);
if (ret)
@@ -3918,7 +3926,7 @@ int t3_replay_prep_adapter(struct adapter *adapter)
;
pti = &port_types[adapter->params.vpd.port_type[j]];
- ret = pti->phy_prep(&p->phy, adapter, p->phy.addr, NULL);
+ ret = pti->phy_prep(&p->phy, adapter, p->phy.mdio.prtad, NULL);
if (ret)
return ret;
p->phy.ops->power_down(&p->phy, 1);
diff --git a/drivers/net/cxgb3/vsc8211.c b/drivers/net/cxgb3/vsc8211.c
index d07130971b8f..4f9a1c2724f4 100644
--- a/drivers/net/cxgb3/vsc8211.c
+++ b/drivers/net/cxgb3/vsc8211.c
@@ -91,17 +91,18 @@ enum {
*/
static int vsc8211_reset(struct cphy *cphy, int wait)
{
- return t3_phy_reset(cphy, 0, 0);
+ return t3_phy_reset(cphy, MDIO_DEVAD_NONE, 0);
}
static int vsc8211_intr_enable(struct cphy *cphy)
{
- return mdio_write(cphy, 0, VSC8211_INTR_ENABLE, INTR_MASK);
+ return t3_mdio_write(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_ENABLE,
+ INTR_MASK);
}
static int vsc8211_intr_disable(struct cphy *cphy)
{
- return mdio_write(cphy, 0, VSC8211_INTR_ENABLE, 0);
+ return t3_mdio_write(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_ENABLE, 0);
}
static int vsc8211_intr_clear(struct cphy *cphy)
@@ -109,18 +110,20 @@ static int vsc8211_intr_clear(struct cphy *cphy)
u32 val;
/* Clear PHY interrupts by reading the register. */
- return mdio_read(cphy, 0, VSC8211_INTR_STATUS, &val);
+ return t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_STATUS, &val);
}
static int vsc8211_autoneg_enable(struct cphy *cphy)
{
- return t3_mdio_change_bits(cphy, 0, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE,
+ return t3_mdio_change_bits(cphy, MDIO_DEVAD_NONE, MII_BMCR,
+ BMCR_PDOWN | BMCR_ISOLATE,
BMCR_ANENABLE | BMCR_ANRESTART);
}
static int vsc8211_autoneg_restart(struct cphy *cphy)
{
- return t3_mdio_change_bits(cphy, 0, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE,
+ return t3_mdio_change_bits(cphy, MDIO_DEVAD_NONE, MII_BMCR,
+ BMCR_PDOWN | BMCR_ISOLATE,
BMCR_ANRESTART);
}
@@ -130,9 +133,9 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
unsigned int bmcr, status, lpa, adv;
int err, sp = -1, dplx = -1, pause = 0;
- err = mdio_read(cphy, 0, MII_BMCR, &bmcr);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMCR, &bmcr);
if (!err)
- err = mdio_read(cphy, 0, MII_BMSR, &status);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR, &status);
if (err)
return err;
@@ -142,7 +145,8 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
* once more to get the current link state.
*/
if (!(status & BMSR_LSTATUS))
- err = mdio_read(cphy, 0, MII_BMSR, &status);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR,
+ &status);
if (err)
return err;
*link_ok = (status & BMSR_LSTATUS) != 0;
@@ -156,7 +160,8 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
else
sp = SPEED_10;
} else if (status & BMSR_ANEGCOMPLETE) {
- err = mdio_read(cphy, 0, VSC8211_AUX_CTRL_STAT, &status);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_AUX_CTRL_STAT,
+ &status);
if (err)
return err;
@@ -170,9 +175,11 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
sp = SPEED_1000;
if (fc && dplx == DUPLEX_FULL) {
- err = mdio_read(cphy, 0, MII_LPA, &lpa);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_LPA,
+ &lpa);
if (!err)
- err = mdio_read(cphy, 0, MII_ADVERTISE, &adv);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE,
+ MII_ADVERTISE, &adv);
if (err)
return err;
@@ -202,9 +209,9 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
unsigned int bmcr, status, lpa, adv;
int err, sp = -1, dplx = -1, pause = 0;
- err = mdio_read(cphy, 0, MII_BMCR, &bmcr);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMCR, &bmcr);
if (!err)
- err = mdio_read(cphy, 0, MII_BMSR, &status);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR, &status);
if (err)
return err;
@@ -214,7 +221,8 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
* once more to get the current link state.
*/
if (!(status & BMSR_LSTATUS))
- err = mdio_read(cphy, 0, MII_BMSR, &status);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR,
+ &status);
if (err)
return err;
*link_ok = (status & BMSR_LSTATUS) != 0;
@@ -228,9 +236,10 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
else
sp = SPEED_10;
} else if (status & BMSR_ANEGCOMPLETE) {
- err = mdio_read(cphy, 0, MII_LPA, &lpa);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_LPA, &lpa);
if (!err)
- err = mdio_read(cphy, 0, MII_ADVERTISE, &adv);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_ADVERTISE,
+ &adv);
if (err)
return err;
@@ -270,23 +279,23 @@ static int vsc8211_set_automdi(struct cphy *phy, int enable)
{
int err;
- err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0x52b5);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 0x52b5);
if (err)
return err;
- err = mdio_write(phy, 0, 18, 0x12);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, 18, 0x12);
if (err)
return err;
- err = mdio_write(phy, 0, 17, enable ? 0x2803 : 0x3003);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, 17, enable ? 0x2803 : 0x3003);
if (err)
return err;
- err = mdio_write(phy, 0, 16, 0x87fa);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, 16, 0x87fa);
if (err)
return err;
- err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 0);
if (err)
return err;
@@ -315,7 +324,7 @@ static int vsc8211_intr_handler(struct cphy *cphy)
unsigned int cause;
int err, cphy_cause = 0;
- err = mdio_read(cphy, 0, VSC8211_INTR_STATUS, &cause);
+ err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_STATUS, &cause);
if (err)
return err;
@@ -367,12 +376,13 @@ int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter,
SUPPORTED_TP | SUPPORTED_IRQ, "10/100/1000BASE-T");
msleep(20); /* PHY needs ~10ms to start responding to MDIO */
- err = mdio_read(phy, 0, VSC8211_EXT_CTRL, &val);
+ err = t3_mdio_read(phy, MDIO_DEVAD_NONE, VSC8211_EXT_CTRL, &val);
if (err)
return err;
if (val & VSC_CTRL_MEDIA_MODE_HI) {
/* copper interface, just need to configure the LEDs */
- return mdio_write(phy, 0, VSC8211_LED_CTRL, 0x100);
+ return t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_LED_CTRL,
+ 0x100);
}
phy->caps = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
@@ -380,20 +390,20 @@ int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter,
phy->desc = "1000BASE-X";
phy->ops = &vsc8211_fiber_ops;
- err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 1);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 1);
if (err)
return err;
- err = mdio_write(phy, 0, VSC8211_SIGDET_CTRL, 1);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_SIGDET_CTRL, 1);
if (err)
return err;
- err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 0);
if (err)
return err;
- err = mdio_write(phy, 0, VSC8211_EXT_CTRL,
- val | VSC_CTRL_CLAUSE37_VIEW);
+ err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_CTRL,
+ val | VSC_CTRL_CLAUSE37_VIEW);
if (err)
return err;
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
new file mode 100644
index 000000000000..cf689a056b38
--- /dev/null
+++ b/drivers/net/davinci_emac.c
@@ -0,0 +1,2832 @@
+/*
+ * DaVinci Ethernet Medium Access Controller
+ *
+ * DaVinci EMAC is based upon CPPI 3.0 TI DMA engine
+ *
+ * Copyright (C) 2009 Texas Instruments.
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * ---------------------------------------------------------------------------
+ * History:
+ * 0-5 A number of folks worked on this driver in bits and pieces but the major
+ * contribution came from Suraj Iyer and Anant Gole
+ * 6.0 Anant Gole - rewrote the driver as per Linux conventions
+ * 6.1 Chaithrika U S - added support for Gigabit and RMII features,
+ * PHY layer usage
+ */
+
+/** Pending Items in this driver:
+ * 1. Use Linux cache infrastcture for DMA'ed memory (dma_xxx functions)
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/in.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/ethtool.h>
+#include <linux/highmem.h>
+#include <linux/proc_fs.h>
+#include <linux/ctype.h>
+#include <linux/version.h>
+#include <linux/spinlock.h>
+#include <linux/dma-mapping.h>
+#include <linux/clk.h>
+#include <linux/platform_device.h>
+#include <linux/semaphore.h>
+#include <linux/phy.h>
+#include <linux/bitops.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
+
+#include <asm/irq.h>
+#include <asm/page.h>
+
+#include <mach/emac.h>
+
+static int debug_level;
+module_param(debug_level, int, 0);
+MODULE_PARM_DESC(debug_level, "DaVinci EMAC debug level (NETIF_MSG bits)");
+
+/* Netif debug messages possible */
+#define DAVINCI_EMAC_DEBUG (NETIF_MSG_DRV | \
+ NETIF_MSG_PROBE | \
+ NETIF_MSG_LINK | \
+ NETIF_MSG_TIMER | \
+ NETIF_MSG_IFDOWN | \
+ NETIF_MSG_IFUP | \
+ NETIF_MSG_RX_ERR | \
+ NETIF_MSG_TX_ERR | \
+ NETIF_MSG_TX_QUEUED | \
+ NETIF_MSG_INTR | \
+ NETIF_MSG_TX_DONE | \
+ NETIF_MSG_RX_STATUS | \
+ NETIF_MSG_PKTDATA | \
+ NETIF_MSG_HW | \
+ NETIF_MSG_WOL)
+
+/* version info */
+#define EMAC_MAJOR_VERSION 6
+#define EMAC_MINOR_VERSION 1
+#define EMAC_MODULE_VERSION "6.1"
+MODULE_VERSION(EMAC_MODULE_VERSION);
+static const char emac_version_string[] = "TI DaVinci EMAC Linux v6.1";
+
+/* Configuration items */
+#define EMAC_DEF_PASS_CRC (0) /* Do not pass CRC upto frames */
+#define EMAC_DEF_QOS_EN (0) /* EMAC proprietary QoS disabled */
+#define EMAC_DEF_NO_BUFF_CHAIN (0) /* No buffer chain */
+#define EMAC_DEF_MACCTRL_FRAME_EN (0) /* Discard Maccontrol frames */
+#define EMAC_DEF_SHORT_FRAME_EN (0) /* Discard short frames */
+#define EMAC_DEF_ERROR_FRAME_EN (0) /* Discard error frames */
+#define EMAC_DEF_PROM_EN (0) /* Promiscous disabled */
+#define EMAC_DEF_PROM_CH (0) /* Promiscous channel is 0 */
+#define EMAC_DEF_BCAST_EN (1) /* Broadcast enabled */
+#define EMAC_DEF_BCAST_CH (0) /* Broadcast channel is 0 */
+#define EMAC_DEF_MCAST_EN (1) /* Multicast enabled */
+#define EMAC_DEF_MCAST_CH (0) /* Multicast channel is 0 */
+
+#define EMAC_DEF_TXPRIO_FIXED (1) /* TX Priority is fixed */
+#define EMAC_DEF_TXPACING_EN (0) /* TX pacing NOT supported*/
+
+#define EMAC_DEF_BUFFER_OFFSET (0) /* Buffer offset to DMA (future) */
+#define EMAC_DEF_MIN_ETHPKTSIZE (60) /* Minimum ethernet pkt size */
+#define EMAC_DEF_MAX_FRAME_SIZE (1500 + 14 + 4 + 4)
+#define EMAC_DEF_TX_CH (0) /* Default 0th channel */
+#define EMAC_DEF_RX_CH (0) /* Default 0th channel */
+#define EMAC_DEF_MDIO_TICK_MS (10) /* typically 1 tick=1 ms) */
+#define EMAC_DEF_MAX_TX_CH (1) /* Max TX channels configured */
+#define EMAC_DEF_MAX_RX_CH (1) /* Max RX channels configured */
+#define EMAC_POLL_WEIGHT (64) /* Default NAPI poll weight */
+
+/* Buffer descriptor parameters */
+#define EMAC_DEF_TX_MAX_SERVICE (32) /* TX max service BD's */
+#define EMAC_DEF_RX_MAX_SERVICE (64) /* should = netdev->weight */
+
+/* EMAC register related defines */
+#define EMAC_ALL_MULTI_REG_VALUE (0xFFFFFFFF)
+#define EMAC_NUM_MULTICAST_BITS (64)
+#define EMAC_TEARDOWN_VALUE (0xFFFFFFFC)
+#define EMAC_TX_CONTROL_TX_ENABLE_VAL (0x1)
+#define EMAC_RX_CONTROL_RX_ENABLE_VAL (0x1)
+#define EMAC_MAC_HOST_ERR_INTMASK_VAL (0x2)
+#define EMAC_RX_UNICAST_CLEAR_ALL (0xFF)
+#define EMAC_INT_MASK_CLEAR (0xFF)
+
+/* RX MBP register bit positions */
+#define EMAC_RXMBP_PASSCRC_MASK BIT(30)
+#define EMAC_RXMBP_QOSEN_MASK BIT(29)
+#define EMAC_RXMBP_NOCHAIN_MASK BIT(28)
+#define EMAC_RXMBP_CMFEN_MASK BIT(24)
+#define EMAC_RXMBP_CSFEN_MASK BIT(23)
+#define EMAC_RXMBP_CEFEN_MASK BIT(22)
+#define EMAC_RXMBP_CAFEN_MASK BIT(21)
+#define EMAC_RXMBP_PROMCH_SHIFT (16)
+#define EMAC_RXMBP_PROMCH_MASK (0x7 << 16)
+#define EMAC_RXMBP_BROADEN_MASK BIT(13)
+#define EMAC_RXMBP_BROADCH_SHIFT (8)
+#define EMAC_RXMBP_BROADCH_MASK (0x7 << 8)
+#define EMAC_RXMBP_MULTIEN_MASK BIT(5)
+#define EMAC_RXMBP_MULTICH_SHIFT (0)
+#define EMAC_RXMBP_MULTICH_MASK (0x7)
+#define EMAC_RXMBP_CHMASK (0x7)
+
+/* EMAC register definitions/bit maps used */
+# define EMAC_MBP_RXPROMISC (0x00200000)
+# define EMAC_MBP_PROMISCCH(ch) (((ch) & 0x7) << 16)
+# define EMAC_MBP_RXBCAST (0x00002000)
+# define EMAC_MBP_BCASTCHAN(ch) (((ch) & 0x7) << 8)
+# define EMAC_MBP_RXMCAST (0x00000020)
+# define EMAC_MBP_MCASTCHAN(ch) ((ch) & 0x7)
+
+/* EMAC mac_control register */
+#define EMAC_MACCONTROL_TXPTYPE (0x200)
+#define EMAC_MACCONTROL_TXPACEEN (0x40)
+#define EMAC_MACCONTROL_MIIEN (0x20)
+#define EMAC_MACCONTROL_GIGABITEN (0x80)
+#define EMAC_MACCONTROL_GIGABITEN_SHIFT (7)
+#define EMAC_MACCONTROL_FULLDUPLEXEN (0x1)
+#define EMAC_MACCONTROL_RMIISPEED_MASK BIT(15)
+
+/* GIGABIT MODE related bits */
+#define EMAC_DM646X_MACCONTORL_GMIIEN BIT(5)
+#define EMAC_DM646X_MACCONTORL_GIG BIT(7)
+#define EMAC_DM646X_MACCONTORL_GIGFORCE BIT(17)
+
+/* EMAC mac_status register */
+#define EMAC_MACSTATUS_TXERRCODE_MASK (0xF00000)
+#define EMAC_MACSTATUS_TXERRCODE_SHIFT (20)
+#define EMAC_MACSTATUS_TXERRCH_MASK (0x7)
+#define EMAC_MACSTATUS_TXERRCH_SHIFT (16)
+#define EMAC_MACSTATUS_RXERRCODE_MASK (0xF000)
+#define EMAC_MACSTATUS_RXERRCODE_SHIFT (12)
+#define EMAC_MACSTATUS_RXERRCH_MASK (0x7)
+#define EMAC_MACSTATUS_RXERRCH_SHIFT (8)
+
+/* EMAC RX register masks */
+#define EMAC_RX_MAX_LEN_MASK (0xFFFF)
+#define EMAC_RX_BUFFER_OFFSET_MASK (0xFFFF)
+
+/* MAC_IN_VECTOR (0x180) register bit fields */
+#define EMAC_DM644X_MAC_IN_VECTOR_HOST_INT (0x20000)
+#define EMAC_DM644X_MAC_IN_VECTOR_STATPEND_INT (0x10000)
+#define EMAC_DM644X_MAC_IN_VECTOR_RX_INT_VEC (0x0100)
+#define EMAC_DM644X_MAC_IN_VECTOR_TX_INT_VEC (0x01)
+
+/** NOTE:: For DM646x the IN_VECTOR has changed */
+#define EMAC_DM646X_MAC_IN_VECTOR_RX_INT_VEC BIT(EMAC_DEF_RX_CH)
+#define EMAC_DM646X_MAC_IN_VECTOR_TX_INT_VEC BIT(16 + EMAC_DEF_TX_CH)
+
+/* CPPI bit positions */
+#define EMAC_CPPI_SOP_BIT BIT(31)
+#define EMAC_CPPI_EOP_BIT BIT(30)
+#define EMAC_CPPI_OWNERSHIP_BIT BIT(29)
+#define EMAC_CPPI_EOQ_BIT BIT(28)
+#define EMAC_CPPI_TEARDOWN_COMPLETE_BIT BIT(27)
+#define EMAC_CPPI_PASS_CRC_BIT BIT(26)
+#define EMAC_RX_BD_BUF_SIZE (0xFFFF)
+#define EMAC_BD_LENGTH_FOR_CACHE (16) /* only CPPI bytes */
+#define EMAC_RX_BD_PKT_LENGTH_MASK (0xFFFF)
+
+/* Max hardware defines */
+#define EMAC_MAX_TXRX_CHANNELS (8) /* Max hardware channels */
+#define EMAC_DEF_MAX_MULTICAST_ADDRESSES (64) /* Max mcast addr's */
+
+/* EMAC Peripheral Device Register Memory Layout structure */
+#define EMAC_TXIDVER 0x0
+#define EMAC_TXCONTROL 0x4
+#define EMAC_TXTEARDOWN 0x8
+#define EMAC_RXIDVER 0x10
+#define EMAC_RXCONTROL 0x14
+#define EMAC_RXTEARDOWN 0x18
+#define EMAC_TXINTSTATRAW 0x80
+#define EMAC_TXINTSTATMASKED 0x84
+#define EMAC_TXINTMASKSET 0x88
+#define EMAC_TXINTMASKCLEAR 0x8C
+#define EMAC_MACINVECTOR 0x90
+
+#define EMAC_DM646X_MACEOIVECTOR 0x94
+
+#define EMAC_RXINTSTATRAW 0xA0
+#define EMAC_RXINTSTATMASKED 0xA4
+#define EMAC_RXINTMASKSET 0xA8
+#define EMAC_RXINTMASKCLEAR 0xAC
+#define EMAC_MACINTSTATRAW 0xB0
+#define EMAC_MACINTSTATMASKED 0xB4
+#define EMAC_MACINTMASKSET 0xB8
+#define EMAC_MACINTMASKCLEAR 0xBC
+
+#define EMAC_RXMBPENABLE 0x100
+#define EMAC_RXUNICASTSET 0x104
+#define EMAC_RXUNICASTCLEAR 0x108
+#define EMAC_RXMAXLEN 0x10C
+#define EMAC_RXBUFFEROFFSET 0x110
+#define EMAC_RXFILTERLOWTHRESH 0x114
+
+#define EMAC_MACCONTROL 0x160
+#define EMAC_MACSTATUS 0x164
+#define EMAC_EMCONTROL 0x168
+#define EMAC_FIFOCONTROL 0x16C
+#define EMAC_MACCONFIG 0x170
+#define EMAC_SOFTRESET 0x174
+#define EMAC_MACSRCADDRLO 0x1D0
+#define EMAC_MACSRCADDRHI 0x1D4
+#define EMAC_MACHASH1 0x1D8
+#define EMAC_MACHASH2 0x1DC
+#define EMAC_MACADDRLO 0x500
+#define EMAC_MACADDRHI 0x504
+#define EMAC_MACINDEX 0x508
+
+/* EMAC HDP and Completion registors */
+#define EMAC_TXHDP(ch) (0x600 + (ch * 4))
+#define EMAC_RXHDP(ch) (0x620 + (ch * 4))
+#define EMAC_TXCP(ch) (0x640 + (ch * 4))
+#define EMAC_RXCP(ch) (0x660 + (ch * 4))
+
+/* EMAC statistics registers */
+#define EMAC_RXGOODFRAMES 0x200
+#define EMAC_RXBCASTFRAMES 0x204
+#define EMAC_RXMCASTFRAMES 0x208
+#define EMAC_RXPAUSEFRAMES 0x20C
+#define EMAC_RXCRCERRORS 0x210
+#define EMAC_RXALIGNCODEERRORS 0x214
+#define EMAC_RXOVERSIZED 0x218
+#define EMAC_RXJABBER 0x21C
+#define EMAC_RXUNDERSIZED 0x220
+#define EMAC_RXFRAGMENTS 0x224
+#define EMAC_RXFILTERED 0x228
+#define EMAC_RXQOSFILTERED 0x22C
+#define EMAC_RXOCTETS 0x230
+#define EMAC_TXGOODFRAMES 0x234
+#define EMAC_TXBCASTFRAMES 0x238
+#define EMAC_TXMCASTFRAMES 0x23C
+#define EMAC_TXPAUSEFRAMES 0x240
+#define EMAC_TXDEFERRED 0x244
+#define EMAC_TXCOLLISION 0x248
+#define EMAC_TXSINGLECOLL 0x24C
+#define EMAC_TXMULTICOLL 0x250
+#define EMAC_TXEXCESSIVECOLL 0x254
+#define EMAC_TXLATECOLL 0x258
+#define EMAC_TXUNDERRUN 0x25C
+#define EMAC_TXCARRIERSENSE 0x260
+#define EMAC_TXOCTETS 0x264
+#define EMAC_NETOCTETS 0x280
+#define EMAC_RXSOFOVERRUNS 0x284
+#define EMAC_RXMOFOVERRUNS 0x288
+#define EMAC_RXDMAOVERRUNS 0x28C
+
+/* EMAC DM644x control registers */
+#define EMAC_CTRL_EWCTL (0x4)
+#define EMAC_CTRL_EWINTTCNT (0x8)
+
+/* EMAC MDIO related */
+/* Mask & Control defines */
+#define MDIO_CONTROL_CLKDIV (0xFF)
+#define MDIO_CONTROL_ENABLE BIT(30)
+#define MDIO_USERACCESS_GO BIT(31)
+#define MDIO_USERACCESS_WRITE BIT(30)
+#define MDIO_USERACCESS_READ (0)
+#define MDIO_USERACCESS_REGADR (0x1F << 21)
+#define MDIO_USERACCESS_PHYADR (0x1F << 16)
+#define MDIO_USERACCESS_DATA (0xFFFF)
+#define MDIO_USERPHYSEL_LINKSEL BIT(7)
+#define MDIO_VER_MODID (0xFFFF << 16)
+#define MDIO_VER_REVMAJ (0xFF << 8)
+#define MDIO_VER_REVMIN (0xFF)
+
+#define MDIO_USERACCESS(inst) (0x80 + (inst * 8))
+#define MDIO_USERPHYSEL(inst) (0x84 + (inst * 8))
+#define MDIO_CONTROL (0x04)
+
+/* EMAC DM646X control module registers */
+#define EMAC_DM646X_CMRXINTEN (0x14)
+#define EMAC_DM646X_CMTXINTEN (0x18)
+
+/* EMAC EOI codes for C0 */
+#define EMAC_DM646X_MAC_EOI_C0_RXEN (0x01)
+#define EMAC_DM646X_MAC_EOI_C0_TXEN (0x02)
+
+/** net_buf_obj: EMAC network bufferdata structure
+ *
+ * EMAC network buffer data structure
+ */
+struct emac_netbufobj {
+ void *buf_token;
+ char *data_ptr;
+ int length;
+};
+
+/** net_pkt_obj: EMAC network packet data structure
+ *
+ * EMAC network packet data structure - supports buffer list (for future)
+ */
+struct emac_netpktobj {
+ void *pkt_token; /* data token may hold tx/rx chan id */
+ struct emac_netbufobj *buf_list; /* array of network buffer objects */
+ int num_bufs;
+ int pkt_length;
+};
+
+/** emac_tx_bd: EMAC TX Buffer descriptor data structure
+ *
+ * EMAC TX Buffer descriptor data structure
+ */
+struct emac_tx_bd {
+ int h_next;
+ int buff_ptr;
+ int off_b_len;
+ int mode; /* SOP, EOP, ownership, EOQ, teardown,Qstarv, length */
+ struct emac_tx_bd __iomem *next;
+ void *buf_token;
+};
+
+/** emac_txch: EMAC TX Channel data structure
+ *
+ * EMAC TX Channel data structure
+ */
+struct emac_txch {
+ /* Config related */
+ u32 num_bd;
+ u32 service_max;
+
+ /* CPPI specific */
+ u32 alloc_size;
+ void __iomem *bd_mem;
+ struct emac_tx_bd __iomem *bd_pool_head;
+ struct emac_tx_bd __iomem *active_queue_head;
+ struct emac_tx_bd __iomem *active_queue_tail;
+ struct emac_tx_bd __iomem *last_hw_bdprocessed;
+ u32 queue_active;
+ u32 teardown_pending;
+ u32 *tx_complete;
+
+ /** statistics */
+ u32 proc_count; /* TX: # of times emac_tx_bdproc is called */
+ u32 mis_queued_packets;
+ u32 queue_reinit;
+ u32 end_of_queue_add;
+ u32 out_of_tx_bd;
+ u32 no_active_pkts; /* IRQ when there were no packets to process */
+ u32 active_queue_count;
+};
+
+/** emac_rx_bd: EMAC RX Buffer descriptor data structure
+ *
+ * EMAC RX Buffer descriptor data structure
+ */
+struct emac_rx_bd {
+ int h_next;
+ int buff_ptr;
+ int off_b_len;
+ int mode;
+ struct emac_rx_bd __iomem *next;
+ void *data_ptr;
+ void *buf_token;
+};
+
+/** emac_rxch: EMAC RX Channel data structure
+ *
+ * EMAC RX Channel data structure
+ */
+struct emac_rxch {
+ /* configuration info */
+ u32 num_bd;
+ u32 service_max;
+ u32 buf_size;
+ char mac_addr[6];
+
+ /** CPPI specific */
+ u32 alloc_size;
+ void __iomem *bd_mem;
+ struct emac_rx_bd __iomem *bd_pool_head;
+ struct emac_rx_bd __iomem *active_queue_head;
+ struct emac_rx_bd __iomem *active_queue_tail;
+ u32 queue_active;
+ u32 teardown_pending;
+
+ /* packet and buffer objects */
+ struct emac_netpktobj pkt_queue;
+ struct emac_netbufobj buf_queue;
+
+ /** statistics */
+ u32 proc_count; /* number of times emac_rx_bdproc is called */
+ u32 processed_bd;
+ u32 recycled_bd;
+ u32 out_of_rx_bd;
+ u32 out_of_rx_buffers;
+ u32 queue_reinit;
+ u32 end_of_queue_add;
+ u32 end_of_queue;
+ u32 mis_queued_packets;
+};
+
+/* emac_priv: EMAC private data structure
+ *
+ * EMAC adapter private data structure
+ */
+struct emac_priv {
+ u32 msg_enable;
+ struct net_device *ndev;
+ struct platform_device *pdev;
+ struct napi_struct napi;
+ char mac_addr[6];
+ spinlock_t tx_lock;
+ spinlock_t rx_lock;
+ void __iomem *remap_addr;
+ u32 emac_base_phys;
+ void __iomem *emac_base;
+ void __iomem *ctrl_base;
+ void __iomem *emac_ctrl_ram;
+ u32 ctrl_ram_size;
+ struct emac_txch *txch[EMAC_DEF_MAX_TX_CH];
+ struct emac_rxch *rxch[EMAC_DEF_MAX_RX_CH];
+ u32 link; /* 1=link on, 0=link off */
+ u32 speed; /* 0=Auto Neg, 1=No PHY, 10,100, 1000 - mbps */
+ u32 duplex; /* Link duplex: 0=Half, 1=Full */
+ u32 rx_buf_size;
+ u32 isr_count;
+ u8 rmii_en;
+ u8 version;
+ struct net_device_stats net_dev_stats;
+ u32 mac_hash1;
+ u32 mac_hash2;
+ u32 multicast_hash_cnt[EMAC_NUM_MULTICAST_BITS];
+ u32 rx_addr_type;
+ /* periodic timer required for MDIO polling */
+ struct timer_list periodic_timer;
+ u32 periodic_ticks;
+ u32 timer_active;
+ u32 phy_mask;
+ /* mii_bus,phy members */
+ struct mii_bus *mii_bus;
+ struct phy_device *phydev;
+ spinlock_t lock;
+};
+
+/* clock frequency for EMAC */
+static struct clk *emac_clk;
+static unsigned long emac_bus_frequency;
+static unsigned long mdio_max_freq;
+
+/* EMAC internal utility function */
+static inline u32 emac_virt_to_phys(void __iomem *addr)
+{
+ return (u32 __force) io_v2p(addr);
+}
+
+/* Cache macros - Packet buffers would be from skb pool which is cached */
+#define EMAC_VIRT_NOCACHE(addr) (addr)
+#define EMAC_CACHE_INVALIDATE(addr, size) \
+ dma_cache_maint((void *)addr, size, DMA_FROM_DEVICE)
+#define EMAC_CACHE_WRITEBACK(addr, size) \
+ dma_cache_maint((void *)addr, size, DMA_TO_DEVICE)
+#define EMAC_CACHE_WRITEBACK_INVALIDATE(addr, size) \
+ dma_cache_maint((void *)addr, size, DMA_BIDIRECTIONAL)
+
+/* DM644x does not have BD's in cached memory - so no cache functions */
+#define BD_CACHE_INVALIDATE(addr, size)
+#define BD_CACHE_WRITEBACK(addr, size)
+#define BD_CACHE_WRITEBACK_INVALIDATE(addr, size)
+
+/* EMAC TX Host Error description strings */
+static char *emac_txhost_errcodes[16] = {
+ "No error", "SOP error", "Ownership bit not set in SOP buffer",
+ "Zero Next Buffer Descriptor Pointer Without EOP",
+ "Zero Buffer Pointer", "Zero Buffer Length", "Packet Length Error",
+ "Reserved", "Reserved", "Reserved", "Reserved", "Reserved",
+ "Reserved", "Reserved", "Reserved", "Reserved"
+};
+
+/* EMAC RX Host Error description strings */
+static char *emac_rxhost_errcodes[16] = {
+ "No error", "Reserved", "Ownership bit not set in input buffer",
+ "Reserved", "Zero Buffer Pointer", "Reserved", "Reserved",
+ "Reserved", "Reserved", "Reserved", "Reserved", "Reserved",
+ "Reserved", "Reserved", "Reserved", "Reserved"
+};
+
+/* Helper macros */
+#define emac_read(reg) ioread32(priv->emac_base + (reg))
+#define emac_write(reg, val) iowrite32(val, priv->emac_base + (reg))
+
+#define emac_ctrl_read(reg) ioread32((priv->ctrl_base + (reg)))
+#define emac_ctrl_write(reg, val) iowrite32(val, (priv->ctrl_base + (reg)))
+
+#define emac_mdio_read(reg) ioread32(bus->priv + (reg))
+#define emac_mdio_write(reg, val) iowrite32(val, (bus->priv + (reg)))
+
+/**
+ * emac_dump_regs: Dump important EMAC registers to debug terminal
+ * @priv: The DaVinci EMAC private adapter structure
+ *
+ * Executes ethtool set cmd & sets phy mode
+ *
+ */
+static void emac_dump_regs(struct emac_priv *priv)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+
+ /* Print important registers in EMAC */
+ dev_info(emac_dev, "EMAC Basic registers\n");
+ dev_info(emac_dev, "EMAC: EWCTL: %08X, EWINTTCNT: %08X\n",
+ emac_ctrl_read(EMAC_CTRL_EWCTL),
+ emac_ctrl_read(EMAC_CTRL_EWINTTCNT));
+ dev_info(emac_dev, "EMAC: TXID: %08X %s, RXID: %08X %s\n",
+ emac_read(EMAC_TXIDVER),
+ ((emac_read(EMAC_TXCONTROL)) ? "enabled" : "disabled"),
+ emac_read(EMAC_RXIDVER),
+ ((emac_read(EMAC_RXCONTROL)) ? "enabled" : "disabled"));
+ dev_info(emac_dev, "EMAC: TXIntRaw:%08X, TxIntMasked: %08X, "\
+ "TxIntMasSet: %08X\n", emac_read(EMAC_TXINTSTATRAW),
+ emac_read(EMAC_TXINTSTATMASKED), emac_read(EMAC_TXINTMASKSET));
+ dev_info(emac_dev, "EMAC: RXIntRaw:%08X, RxIntMasked: %08X, "\
+ "RxIntMasSet: %08X\n", emac_read(EMAC_RXINTSTATRAW),
+ emac_read(EMAC_RXINTSTATMASKED), emac_read(EMAC_RXINTMASKSET));
+ dev_info(emac_dev, "EMAC: MacIntRaw:%08X, MacIntMasked: %08X, "\
+ "MacInVector=%08X\n", emac_read(EMAC_MACINTSTATRAW),
+ emac_read(EMAC_MACINTSTATMASKED), emac_read(EMAC_MACINVECTOR));
+ dev_info(emac_dev, "EMAC: EmuControl:%08X, FifoControl: %08X\n",
+ emac_read(EMAC_EMCONTROL), emac_read(EMAC_FIFOCONTROL));
+ dev_info(emac_dev, "EMAC: MBPEnable:%08X, RXUnicastSet: %08X, "\
+ "RXMaxLen=%08X\n", emac_read(EMAC_RXMBPENABLE),
+ emac_read(EMAC_RXUNICASTSET), emac_read(EMAC_RXMAXLEN));
+ dev_info(emac_dev, "EMAC: MacControl:%08X, MacStatus: %08X, "\
+ "MacConfig=%08X\n", emac_read(EMAC_MACCONTROL),
+ emac_read(EMAC_MACSTATUS), emac_read(EMAC_MACCONFIG));
+ dev_info(emac_dev, "EMAC: TXHDP[0]:%08X, RXHDP[0]: %08X\n",
+ emac_read(EMAC_TXHDP(0)), emac_read(EMAC_RXHDP(0)));
+ dev_info(emac_dev, "EMAC Statistics\n");
+ dev_info(emac_dev, "EMAC: rx_good_frames:%d\n",
+ emac_read(EMAC_RXGOODFRAMES));
+ dev_info(emac_dev, "EMAC: rx_broadcast_frames:%d\n",
+ emac_read(EMAC_RXBCASTFRAMES));
+ dev_info(emac_dev, "EMAC: rx_multicast_frames:%d\n",
+ emac_read(EMAC_RXMCASTFRAMES));
+ dev_info(emac_dev, "EMAC: rx_pause_frames:%d\n",
+ emac_read(EMAC_RXPAUSEFRAMES));
+ dev_info(emac_dev, "EMAC: rx_crcerrors:%d\n",
+ emac_read(EMAC_RXCRCERRORS));
+ dev_info(emac_dev, "EMAC: rx_align_code_errors:%d\n",
+ emac_read(EMAC_RXALIGNCODEERRORS));
+ dev_info(emac_dev, "EMAC: rx_oversized_frames:%d\n",
+ emac_read(EMAC_RXOVERSIZED));
+ dev_info(emac_dev, "EMAC: rx_jabber_frames:%d\n",
+ emac_read(EMAC_RXJABBER));
+ dev_info(emac_dev, "EMAC: rx_undersized_frames:%d\n",
+ emac_read(EMAC_RXUNDERSIZED));
+ dev_info(emac_dev, "EMAC: rx_fragments:%d\n",
+ emac_read(EMAC_RXFRAGMENTS));
+ dev_info(emac_dev, "EMAC: rx_filtered_frames:%d\n",
+ emac_read(EMAC_RXFILTERED));
+ dev_info(emac_dev, "EMAC: rx_qos_filtered_frames:%d\n",
+ emac_read(EMAC_RXQOSFILTERED));
+ dev_info(emac_dev, "EMAC: rx_octets:%d\n",
+ emac_read(EMAC_RXOCTETS));
+ dev_info(emac_dev, "EMAC: tx_goodframes:%d\n",
+ emac_read(EMAC_TXGOODFRAMES));
+ dev_info(emac_dev, "EMAC: tx_bcastframes:%d\n",
+ emac_read(EMAC_TXBCASTFRAMES));
+ dev_info(emac_dev, "EMAC: tx_mcastframes:%d\n",
+ emac_read(EMAC_TXMCASTFRAMES));
+ dev_info(emac_dev, "EMAC: tx_pause_frames:%d\n",
+ emac_read(EMAC_TXPAUSEFRAMES));
+ dev_info(emac_dev, "EMAC: tx_deferred_frames:%d\n",
+ emac_read(EMAC_TXDEFERRED));
+ dev_info(emac_dev, "EMAC: tx_collision_frames:%d\n",
+ emac_read(EMAC_TXCOLLISION));
+ dev_info(emac_dev, "EMAC: tx_single_coll_frames:%d\n",
+ emac_read(EMAC_TXSINGLECOLL));
+ dev_info(emac_dev, "EMAC: tx_mult_coll_frames:%d\n",
+ emac_read(EMAC_TXMULTICOLL));
+ dev_info(emac_dev, "EMAC: tx_excessive_collisions:%d\n",
+ emac_read(EMAC_TXEXCESSIVECOLL));
+ dev_info(emac_dev, "EMAC: tx_late_collisions:%d\n",
+ emac_read(EMAC_TXLATECOLL));
+ dev_info(emac_dev, "EMAC: tx_underrun:%d\n",
+ emac_read(EMAC_TXUNDERRUN));
+ dev_info(emac_dev, "EMAC: tx_carrier_sense_errors:%d\n",
+ emac_read(EMAC_TXCARRIERSENSE));
+ dev_info(emac_dev, "EMAC: tx_octets:%d\n",
+ emac_read(EMAC_TXOCTETS));
+ dev_info(emac_dev, "EMAC: net_octets:%d\n",
+ emac_read(EMAC_NETOCTETS));
+ dev_info(emac_dev, "EMAC: rx_sof_overruns:%d\n",
+ emac_read(EMAC_RXSOFOVERRUNS));
+ dev_info(emac_dev, "EMAC: rx_mof_overruns:%d\n",
+ emac_read(EMAC_RXMOFOVERRUNS));
+ dev_info(emac_dev, "EMAC: rx_dma_overruns:%d\n",
+ emac_read(EMAC_RXDMAOVERRUNS));
+}
+
+/*************************************************************************
+ * EMAC MDIO/Phy Functionality
+ *************************************************************************/
+/**
+ * emac_get_drvinfo: Get EMAC driver information
+ * @ndev: The DaVinci EMAC network adapter
+ * @info: ethtool info structure containing name and version
+ *
+ * Returns EMAC driver information (name and version)
+ *
+ */
+static void emac_get_drvinfo(struct net_device *ndev,
+ struct ethtool_drvinfo *info)
+{
+ strcpy(info->driver, emac_version_string);
+ strcpy(info->version, EMAC_MODULE_VERSION);
+}
+
+/**
+ * emac_get_settings: Get EMAC settings
+ * @ndev: The DaVinci EMAC network adapter
+ * @ecmd: ethtool command
+ *
+ * Executes ethool get command
+ *
+ */
+static int emac_get_settings(struct net_device *ndev,
+ struct ethtool_cmd *ecmd)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+ if (priv->phy_mask)
+ return phy_ethtool_gset(priv->phydev, ecmd);
+ else
+ return -EOPNOTSUPP;
+
+}
+
+/**
+ * emac_set_settings: Set EMAC settings
+ * @ndev: The DaVinci EMAC network adapter
+ * @ecmd: ethtool command
+ *
+ * Executes ethool set command
+ *
+ */
+static int emac_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+ if (priv->phy_mask)
+ return phy_ethtool_sset(priv->phydev, ecmd);
+ else
+ return -EOPNOTSUPP;
+
+}
+
+/**
+ * ethtool_ops: DaVinci EMAC Ethtool structure
+ *
+ * Ethtool support for EMAC adapter
+ *
+ */
+static const struct ethtool_ops ethtool_ops = {
+ .get_drvinfo = emac_get_drvinfo,
+ .get_settings = emac_get_settings,
+ .set_settings = emac_set_settings,
+ .get_link = ethtool_op_get_link,
+};
+
+/**
+ * emac_update_phystatus: Update Phy status
+ * @priv: The DaVinci EMAC private adapter structure
+ *
+ * Updates phy status and takes action for network queue if required
+ * based upon link status
+ *
+ */
+static void emac_update_phystatus(struct emac_priv *priv)
+{
+ u32 mac_control;
+ u32 new_duplex;
+ u32 cur_duplex;
+ struct net_device *ndev = priv->ndev;
+
+ mac_control = emac_read(EMAC_MACCONTROL);
+ cur_duplex = (mac_control & EMAC_MACCONTROL_FULLDUPLEXEN) ?
+ DUPLEX_FULL : DUPLEX_HALF;
+ if (priv->phy_mask)
+ new_duplex = priv->phydev->duplex;
+ else
+ new_duplex = DUPLEX_FULL;
+
+ /* We get called only if link has changed (speed/duplex/status) */
+ if ((priv->link) && (new_duplex != cur_duplex)) {
+ priv->duplex = new_duplex;
+ if (DUPLEX_FULL == priv->duplex)
+ mac_control |= (EMAC_MACCONTROL_FULLDUPLEXEN);
+ else
+ mac_control &= ~(EMAC_MACCONTROL_FULLDUPLEXEN);
+ }
+
+ if (priv->speed == SPEED_1000 && (priv->version == EMAC_VERSION_2)) {
+ mac_control = emac_read(EMAC_MACCONTROL);
+ mac_control |= (EMAC_DM646X_MACCONTORL_GMIIEN |
+ EMAC_DM646X_MACCONTORL_GIG |
+ EMAC_DM646X_MACCONTORL_GIGFORCE);
+ } else {
+ /* Clear the GIG bit and GIGFORCE bit */
+ mac_control &= ~(EMAC_DM646X_MACCONTORL_GIGFORCE |
+ EMAC_DM646X_MACCONTORL_GIG);
+
+ if (priv->rmii_en && (priv->speed == SPEED_100))
+ mac_control |= EMAC_MACCONTROL_RMIISPEED_MASK;
+ else
+ mac_control &= ~EMAC_MACCONTROL_RMIISPEED_MASK;
+ }
+
+ /* Update mac_control if changed */
+ emac_write(EMAC_MACCONTROL, mac_control);
+
+ if (priv->link) {
+ /* link ON */
+ if (!netif_carrier_ok(ndev))
+ netif_carrier_on(ndev);
+ /* reactivate the transmit queue if it is stopped */
+ if (netif_running(ndev) && netif_queue_stopped(ndev))
+ netif_wake_queue(ndev);
+ } else {
+ /* link OFF */
+ if (netif_carrier_ok(ndev))
+ netif_carrier_off(ndev);
+ if (!netif_queue_stopped(ndev))
+ netif_stop_queue(ndev);
+ }
+}
+
+/**
+ * hash_get: Calculate hash value from mac address
+ * @addr: mac address to delete from hash table
+ *
+ * Calculates hash value from mac address
+ *
+ */
+static u32 hash_get(u8 *addr)
+{
+ u32 hash;
+ u8 tmpval;
+ int cnt;
+ hash = 0;
+
+ for (cnt = 0; cnt < 2; cnt++) {
+ tmpval = *addr++;
+ hash ^= (tmpval >> 2) ^ (tmpval << 4);
+ tmpval = *addr++;
+ hash ^= (tmpval >> 4) ^ (tmpval << 2);
+ tmpval = *addr++;
+ hash ^= (tmpval >> 6) ^ (tmpval);
+ }
+
+ return hash & 0x3F;
+}
+
+/**
+ * hash_add: Hash function to add mac addr from hash table
+ * @priv: The DaVinci EMAC private adapter structure
+ * mac_addr: mac address to delete from hash table
+ *
+ * Adds mac address to the internal hash table
+ *
+ */
+static int hash_add(struct emac_priv *priv, u8 *mac_addr)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ u32 rc = 0;
+ u32 hash_bit;
+ u32 hash_value = hash_get(mac_addr);
+
+ if (hash_value >= EMAC_NUM_MULTICAST_BITS) {
+ if (netif_msg_drv(priv)) {
+ dev_err(emac_dev, "DaVinci EMAC: hash_add(): Invalid "\
+ "Hash %08x, should not be greater than %08x",
+ hash_value, (EMAC_NUM_MULTICAST_BITS - 1));
+ }
+ return -1;
+ }
+
+ /* set the hash bit only if not previously set */
+ if (priv->multicast_hash_cnt[hash_value] == 0) {
+ rc = 1; /* hash value changed */
+ if (hash_value < 32) {
+ hash_bit = BIT(hash_value);
+ priv->mac_hash1 |= hash_bit;
+ } else {
+ hash_bit = BIT((hash_value - 32));
+ priv->mac_hash2 |= hash_bit;
+ }
+ }
+
+ /* incr counter for num of mcast addr's mapped to "this" hash bit */
+ ++priv->multicast_hash_cnt[hash_value];
+
+ return rc;
+}
+
+/**
+ * hash_del: Hash function to delete mac addr from hash table
+ * @priv: The DaVinci EMAC private adapter structure
+ * mac_addr: mac address to delete from hash table
+ *
+ * Removes mac address from the internal hash table
+ *
+ */
+static int hash_del(struct emac_priv *priv, u8 *mac_addr)
+{
+ u32 hash_value;
+ u32 hash_bit;
+
+ hash_value = hash_get(mac_addr);
+ if (priv->multicast_hash_cnt[hash_value] > 0) {
+ /* dec cntr for num of mcast addr's mapped to this hash bit */
+ --priv->multicast_hash_cnt[hash_value];
+ }
+
+ /* if counter still > 0, at least one multicast address refers
+ * to this hash bit. so return 0 */
+ if (priv->multicast_hash_cnt[hash_value] > 0)
+ return 0;
+
+ if (hash_value < 32) {
+ hash_bit = BIT(hash_value);
+ priv->mac_hash1 &= ~hash_bit;
+ } else {
+ hash_bit = BIT((hash_value - 32));
+ priv->mac_hash2 &= ~hash_bit;
+ }
+
+ /* return 1 to indicate change in mac_hash registers reqd */
+ return 1;
+}
+
+/* EMAC multicast operation */
+#define EMAC_MULTICAST_ADD 0
+#define EMAC_MULTICAST_DEL 1
+#define EMAC_ALL_MULTI_SET 2
+#define EMAC_ALL_MULTI_CLR 3
+
+/**
+ * emac_add_mcast: Set multicast address in the EMAC adapter (Internal)
+ * @priv: The DaVinci EMAC private adapter structure
+ * @action: multicast operation to perform
+ * mac_addr: mac address to set
+ *
+ * Set multicast addresses in EMAC adapter - internal function
+ *
+ */
+static void emac_add_mcast(struct emac_priv *priv, u32 action, u8 *mac_addr)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ int update = -1;
+
+ switch (action) {
+ case EMAC_MULTICAST_ADD:
+ update = hash_add(priv, mac_addr);
+ break;
+ case EMAC_MULTICAST_DEL:
+ update = hash_del(priv, mac_addr);
+ break;
+ case EMAC_ALL_MULTI_SET:
+ update = 1;
+ priv->mac_hash1 = EMAC_ALL_MULTI_REG_VALUE;
+ priv->mac_hash2 = EMAC_ALL_MULTI_REG_VALUE;
+ break;
+ case EMAC_ALL_MULTI_CLR:
+ update = 1;
+ priv->mac_hash1 = 0;
+ priv->mac_hash2 = 0;
+ memset(&(priv->multicast_hash_cnt[0]), 0,
+ sizeof(priv->multicast_hash_cnt[0]) *
+ EMAC_NUM_MULTICAST_BITS);
+ break;
+ default:
+ if (netif_msg_drv(priv))
+ dev_err(emac_dev, "DaVinci EMAC: add_mcast"\
+ ": bad operation %d", action);
+ break;
+ }
+
+ /* write to the hardware only if the register status chances */
+ if (update > 0) {
+ emac_write(EMAC_MACHASH1, priv->mac_hash1);
+ emac_write(EMAC_MACHASH2, priv->mac_hash2);
+ }
+}
+
+/**
+ * emac_dev_mcast_set: Set multicast address in the EMAC adapter
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Set multicast addresses in EMAC adapter
+ *
+ */
+static void emac_dev_mcast_set(struct net_device *ndev)
+{
+ u32 mbp_enable;
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ mbp_enable = emac_read(EMAC_RXMBPENABLE);
+ if (ndev->flags & IFF_PROMISC) {
+ mbp_enable &= (~EMAC_MBP_PROMISCCH(EMAC_DEF_PROM_CH));
+ mbp_enable |= (EMAC_MBP_RXPROMISC);
+ } else {
+ mbp_enable = (mbp_enable & ~EMAC_MBP_RXPROMISC);
+ if ((ndev->flags & IFF_ALLMULTI) ||
+ (ndev->mc_count > EMAC_DEF_MAX_MULTICAST_ADDRESSES)) {
+ mbp_enable = (mbp_enable | EMAC_MBP_RXMCAST);
+ emac_add_mcast(priv, EMAC_ALL_MULTI_SET, NULL);
+ }
+ if (ndev->mc_count > 0) {
+ struct dev_mc_list *mc_ptr;
+ mbp_enable = (mbp_enable | EMAC_MBP_RXMCAST);
+ emac_add_mcast(priv, EMAC_ALL_MULTI_CLR, NULL);
+ /* program multicast address list into EMAC hardware */
+ for (mc_ptr = ndev->mc_list; mc_ptr;
+ mc_ptr = mc_ptr->next) {
+ emac_add_mcast(priv, EMAC_MULTICAST_ADD,
+ (u8 *)mc_ptr->dmi_addr);
+ }
+ } else {
+ mbp_enable = (mbp_enable & ~EMAC_MBP_RXMCAST);
+ emac_add_mcast(priv, EMAC_ALL_MULTI_CLR, NULL);
+ }
+ }
+ /* Set mbp config register */
+ emac_write(EMAC_RXMBPENABLE, mbp_enable);
+}
+
+/*************************************************************************
+ * EMAC Hardware manipulation
+ *************************************************************************/
+
+/**
+ * emac_int_disable: Disable EMAC module interrupt (from adapter)
+ * @priv: The DaVinci EMAC private adapter structure
+ *
+ * Disable EMAC interrupt on the adapter
+ *
+ */
+static void emac_int_disable(struct emac_priv *priv)
+{
+ if (priv->version == EMAC_VERSION_2) {
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ /* Program C0_Int_En to zero to turn off
+ * interrupts to the CPU */
+ emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0x0);
+ emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0x0);
+ /* NOTE: Rx Threshold and Misc interrupts are not disabled */
+
+ local_irq_restore(flags);
+
+ } else {
+ /* Set DM644x control registers for interrupt control */
+ emac_ctrl_write(EMAC_CTRL_EWCTL, 0x0);
+ }
+}
+
+/**
+ * emac_int_enable: Enable EMAC module interrupt (from adapter)
+ * @priv: The DaVinci EMAC private adapter structure
+ *
+ * Enable EMAC interrupt on the adapter
+ *
+ */
+static void emac_int_enable(struct emac_priv *priv)
+{
+ if (priv->version == EMAC_VERSION_2) {
+ emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0xff);
+ emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0xff);
+
+ /* In addition to turning on interrupt Enable, we need
+ * ack by writing appropriate values to the EOI
+ * register */
+
+ /* NOTE: Rx Threshold and Misc interrupts are not enabled */
+
+ /* ack rxen only then a new pulse will be generated */
+ emac_write(EMAC_DM646X_MACEOIVECTOR,
+ EMAC_DM646X_MAC_EOI_C0_RXEN);
+
+ /* ack txen- only then a new pulse will be generated */
+ emac_write(EMAC_DM646X_MACEOIVECTOR,
+ EMAC_DM646X_MAC_EOI_C0_TXEN);
+
+ } else {
+ /* Set DM644x control registers for interrupt control */
+ emac_ctrl_write(EMAC_CTRL_EWCTL, 0x1);
+ }
+}
+
+/**
+ * emac_irq: EMAC interrupt handler
+ * @irq: interrupt number
+ * @dev_id: EMAC network adapter data structure ptr
+ *
+ * EMAC Interrupt handler - we only schedule NAPI and not process any packets
+ * here. EVen the interrupt status is checked (TX/RX/Err) in NAPI poll function
+ *
+ * Returns interrupt handled condition
+ */
+static irqreturn_t emac_irq(int irq, void *dev_id)
+{
+ struct net_device *ndev = (struct net_device *)dev_id;
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ ++priv->isr_count;
+ if (likely(netif_running(priv->ndev))) {
+ emac_int_disable(priv);
+ napi_schedule(&priv->napi);
+ } else {
+ /* we are closing down, so dont process anything */
+ }
+ return IRQ_HANDLED;
+}
+
+/** EMAC on-chip buffer descriptor memory
+ *
+ * WARNING: Please note that the on chip memory is used for both TX and RX
+ * buffer descriptor queues and is equally divided between TX and RX desc's
+ * If the number of TX or RX descriptors change this memory pointers need
+ * to be adjusted. If external memory is allocated then these pointers can
+ * pointer to the memory
+ *
+ */
+#define EMAC_TX_BD_MEM(priv) ((priv)->emac_ctrl_ram)
+#define EMAC_RX_BD_MEM(priv) ((priv)->emac_ctrl_ram + \
+ (((priv)->ctrl_ram_size) >> 1))
+
+/**
+ * emac_init_txch: TX channel initialization
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ *
+ * Called during device init to setup a TX channel (allocate buffer desc
+ * create free pool and keep ready for transmission
+ *
+ * Returns success(0) or mem alloc failures error code
+ */
+static int emac_init_txch(struct emac_priv *priv, u32 ch)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ u32 cnt, bd_size;
+ void __iomem *mem;
+ struct emac_tx_bd __iomem *curr_bd;
+ struct emac_txch *txch = NULL;
+
+ txch = kzalloc(sizeof(struct emac_txch), GFP_KERNEL);
+ if (NULL == txch) {
+ dev_err(emac_dev, "DaVinci EMAC: TX Ch mem alloc failed");
+ return -ENOMEM;
+ }
+ priv->txch[ch] = txch;
+ txch->service_max = EMAC_DEF_TX_MAX_SERVICE;
+ txch->active_queue_head = NULL;
+ txch->active_queue_tail = NULL;
+ txch->queue_active = 0;
+ txch->teardown_pending = 0;
+
+ /* allocate memory for TX CPPI channel on a 4 byte boundry */
+ txch->tx_complete = kzalloc(txch->service_max * sizeof(u32),
+ GFP_KERNEL);
+ if (NULL == txch->tx_complete) {
+ dev_err(emac_dev, "DaVinci EMAC: Tx service mem alloc failed");
+ kfree(txch);
+ return -ENOMEM;
+ }
+
+ /* allocate buffer descriptor pool align every BD on four word
+ * boundry for future requirements */
+ bd_size = (sizeof(struct emac_tx_bd) + 0xF) & ~0xF;
+ txch->num_bd = (priv->ctrl_ram_size >> 1) / bd_size;
+ txch->alloc_size = (((bd_size * txch->num_bd) + 0xF) & ~0xF);
+
+ /* alloc TX BD memory */
+ txch->bd_mem = EMAC_TX_BD_MEM(priv);
+ __memzero((void __force *)txch->bd_mem, txch->alloc_size);
+
+ /* initialize the BD linked list */
+ mem = (void __force __iomem *)
+ (((u32 __force) txch->bd_mem + 0xF) & ~0xF);
+ txch->bd_pool_head = NULL;
+ for (cnt = 0; cnt < txch->num_bd; cnt++) {
+ curr_bd = mem + (cnt * bd_size);
+ curr_bd->next = txch->bd_pool_head;
+ txch->bd_pool_head = curr_bd;
+ }
+
+ /* reset statistics counters */
+ txch->out_of_tx_bd = 0;
+ txch->no_active_pkts = 0;
+ txch->active_queue_count = 0;
+
+ return 0;
+}
+
+/**
+ * emac_cleanup_txch: Book-keep function to clean TX channel resources
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: TX channel number
+ *
+ * Called to clean up TX channel resources
+ *
+ */
+static void emac_cleanup_txch(struct emac_priv *priv, u32 ch)
+{
+ struct emac_txch *txch = priv->txch[ch];
+
+ if (txch) {
+ if (txch->bd_mem)
+ txch->bd_mem = NULL;
+ kfree(txch->tx_complete);
+ kfree(txch);
+ priv->txch[ch] = NULL;
+ }
+}
+
+/**
+ * emac_net_tx_complete: TX packet completion function
+ * @priv: The DaVinci EMAC private adapter structure
+ * @net_data_tokens: packet token - skb pointer
+ * @num_tokens: number of skb's to free
+ * @ch: TX channel number
+ *
+ * Frees the skb once packet is transmitted
+ *
+ */
+static int emac_net_tx_complete(struct emac_priv *priv,
+ void **net_data_tokens,
+ int num_tokens, u32 ch)
+{
+ u32 cnt;
+
+ if (unlikely(num_tokens && netif_queue_stopped(priv->ndev)))
+ netif_start_queue(priv->ndev);
+ for (cnt = 0; cnt < num_tokens; cnt++) {
+ struct sk_buff *skb = (struct sk_buff *)net_data_tokens[cnt];
+ if (skb == NULL)
+ continue;
+ priv->net_dev_stats.tx_packets++;
+ priv->net_dev_stats.tx_bytes += skb->len;
+ dev_kfree_skb_any(skb);
+ }
+ return 0;
+}
+
+/**
+ * emac_txch_teardown: TX channel teardown
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: TX channel number
+ *
+ * Called to teardown TX channel
+ *
+ */
+static void emac_txch_teardown(struct emac_priv *priv, u32 ch)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ u32 teardown_cnt = 0xFFFFFFF0; /* Some high value */
+ struct emac_txch *txch = priv->txch[ch];
+ struct emac_tx_bd __iomem *curr_bd;
+
+ while ((emac_read(EMAC_TXCP(ch)) & EMAC_TEARDOWN_VALUE) !=
+ EMAC_TEARDOWN_VALUE) {
+ /* wait till tx teardown complete */
+ cpu_relax(); /* TODO: check if this helps ... */
+ --teardown_cnt;
+ if (0 == teardown_cnt) {
+ dev_err(emac_dev, "EMAC: TX teardown aborted\n");
+ break;
+ }
+ }
+ emac_write(EMAC_TXCP(ch), EMAC_TEARDOWN_VALUE);
+
+ /* process sent packets and return skb's to upper layer */
+ if (1 == txch->queue_active) {
+ curr_bd = txch->active_queue_head;
+ while (curr_bd != NULL) {
+ emac_net_tx_complete(priv, (void __force *)
+ &curr_bd->buf_token, 1, ch);
+ if (curr_bd != txch->active_queue_tail)
+ curr_bd = curr_bd->next;
+ else
+ break;
+ }
+ txch->bd_pool_head = txch->active_queue_head;
+ txch->active_queue_head =
+ txch->active_queue_tail = NULL;
+ }
+}
+
+/**
+ * emac_stop_txch: Stop TX channel operation
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: TX channel number
+ *
+ * Called to stop TX channel operation
+ *
+ */
+static void emac_stop_txch(struct emac_priv *priv, u32 ch)
+{
+ struct emac_txch *txch = priv->txch[ch];
+
+ if (txch) {
+ txch->teardown_pending = 1;
+ emac_write(EMAC_TXTEARDOWN, 0);
+ emac_txch_teardown(priv, ch);
+ txch->teardown_pending = 0;
+ emac_write(EMAC_TXINTMASKCLEAR, BIT(ch));
+ }
+}
+
+/**
+ * emac_tx_bdproc: TX buffer descriptor (packet) processing
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: TX channel number to process buffer descriptors for
+ * @budget: number of packets allowed to process
+ * @pending: indication to caller that packets are pending to process
+ *
+ * Processes TX buffer descriptors after packets are transmitted - checks
+ * ownership bit on the TX * descriptor and requeues it to free pool & frees
+ * the SKB buffer. Only "budget" number of packets are processed and
+ * indication of pending packets provided to the caller
+ *
+ * Returns number of packets processed
+ */
+static int emac_tx_bdproc(struct emac_priv *priv, u32 ch, u32 budget)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ unsigned long flags;
+ u32 frame_status;
+ u32 pkts_processed = 0;
+ u32 tx_complete_cnt = 0;
+ struct emac_tx_bd __iomem *curr_bd;
+ struct emac_txch *txch = priv->txch[ch];
+ u32 *tx_complete_ptr = txch->tx_complete;
+
+ if (unlikely(1 == txch->teardown_pending)) {
+ if (netif_msg_tx_err(priv) && net_ratelimit()) {
+ dev_err(emac_dev, "DaVinci EMAC:emac_tx_bdproc: "\
+ "teardown pending\n");
+ }
+ return 0; /* dont handle any pkt completions */
+ }
+
+ ++txch->proc_count;
+ spin_lock_irqsave(&priv->tx_lock, flags);
+ curr_bd = txch->active_queue_head;
+ if (NULL == curr_bd) {
+ emac_write(EMAC_TXCP(ch),
+ emac_virt_to_phys(txch->last_hw_bdprocessed));
+ txch->no_active_pkts++;
+ spin_unlock_irqrestore(&priv->tx_lock, flags);
+ return 0;
+ }
+ BD_CACHE_INVALIDATE(curr_bd, EMAC_BD_LENGTH_FOR_CACHE);
+ frame_status = curr_bd->mode;
+ while ((curr_bd) &&
+ ((frame_status & EMAC_CPPI_OWNERSHIP_BIT) == 0) &&
+ (pkts_processed < budget)) {
+ emac_write(EMAC_TXCP(ch), emac_virt_to_phys(curr_bd));
+ txch->active_queue_head = curr_bd->next;
+ if (frame_status & EMAC_CPPI_EOQ_BIT) {
+ if (curr_bd->next) { /* misqueued packet */
+ emac_write(EMAC_TXHDP(ch), curr_bd->h_next);
+ ++txch->mis_queued_packets;
+ } else {
+ txch->queue_active = 0; /* end of queue */
+ }
+ }
+ *tx_complete_ptr = (u32) curr_bd->buf_token;
+ ++tx_complete_ptr;
+ ++tx_complete_cnt;
+ curr_bd->next = txch->bd_pool_head;
+ txch->bd_pool_head = curr_bd;
+ --txch->active_queue_count;
+ pkts_processed++;
+ txch->last_hw_bdprocessed = curr_bd;
+ curr_bd = txch->active_queue_head;
+ if (curr_bd) {
+ BD_CACHE_INVALIDATE(curr_bd, EMAC_BD_LENGTH_FOR_CACHE);
+ frame_status = curr_bd->mode;
+ }
+ } /* end of pkt processing loop */
+
+ emac_net_tx_complete(priv,
+ (void *)&txch->tx_complete[0],
+ tx_complete_cnt, ch);
+ spin_unlock_irqrestore(&priv->tx_lock, flags);
+ return pkts_processed;
+}
+
+#define EMAC_ERR_TX_OUT_OF_BD -1
+
+/**
+ * emac_send: EMAC Transmit function (internal)
+ * @priv: The DaVinci EMAC private adapter structure
+ * @pkt: packet pointer (contains skb ptr)
+ * @ch: TX channel number
+ *
+ * Called by the transmit function to queue the packet in EMAC hardware queue
+ *
+ * Returns success(0) or error code (typically out of desc's)
+ */
+static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, u32 ch)
+{
+ unsigned long flags;
+ struct emac_tx_bd __iomem *curr_bd;
+ struct emac_txch *txch;
+ struct emac_netbufobj *buf_list;
+
+ txch = priv->txch[ch];
+ buf_list = pkt->buf_list; /* get handle to the buffer array */
+
+ /* check packet size and pad if short */
+ if (pkt->pkt_length < EMAC_DEF_MIN_ETHPKTSIZE) {
+ buf_list->length += (EMAC_DEF_MIN_ETHPKTSIZE - pkt->pkt_length);
+ pkt->pkt_length = EMAC_DEF_MIN_ETHPKTSIZE;
+ }
+
+ spin_lock_irqsave(&priv->tx_lock, flags);
+ curr_bd = txch->bd_pool_head;
+ if (curr_bd == NULL) {
+ txch->out_of_tx_bd++;
+ spin_unlock_irqrestore(&priv->tx_lock, flags);
+ return EMAC_ERR_TX_OUT_OF_BD;
+ }
+
+ txch->bd_pool_head = curr_bd->next;
+ curr_bd->buf_token = buf_list->buf_token;
+ /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */
+ curr_bd->buff_ptr = virt_to_phys(buf_list->data_ptr);
+ curr_bd->off_b_len = buf_list->length;
+ curr_bd->h_next = 0;
+ curr_bd->next = NULL;
+ curr_bd->mode = (EMAC_CPPI_SOP_BIT | EMAC_CPPI_OWNERSHIP_BIT |
+ EMAC_CPPI_EOP_BIT | pkt->pkt_length);
+
+ /* flush the packet from cache if write back cache is present */
+ BD_CACHE_WRITEBACK_INVALIDATE(curr_bd, EMAC_BD_LENGTH_FOR_CACHE);
+
+ /* send the packet */
+ if (txch->active_queue_head == NULL) {
+ txch->active_queue_head = curr_bd;
+ txch->active_queue_tail = curr_bd;
+ if (1 != txch->queue_active) {
+ emac_write(EMAC_TXHDP(ch),
+ emac_virt_to_phys(curr_bd));
+ txch->queue_active = 1;
+ }
+ ++txch->queue_reinit;
+ } else {
+ register struct emac_tx_bd __iomem *tail_bd;
+ register u32 frame_status;
+
+ tail_bd = txch->active_queue_tail;
+ tail_bd->next = curr_bd;
+ txch->active_queue_tail = curr_bd;
+ tail_bd = EMAC_VIRT_NOCACHE(tail_bd);
+ tail_bd->h_next = (int)emac_virt_to_phys(curr_bd);
+ frame_status = tail_bd->mode;
+ if (frame_status & EMAC_CPPI_EOQ_BIT) {
+ emac_write(EMAC_TXHDP(ch), emac_virt_to_phys(curr_bd));
+ frame_status &= ~(EMAC_CPPI_EOQ_BIT);
+ tail_bd->mode = frame_status;
+ ++txch->end_of_queue_add;
+ }
+ }
+ txch->active_queue_count++;
+ spin_unlock_irqrestore(&priv->tx_lock, flags);
+ return 0;
+}
+
+/**
+ * emac_dev_xmit: EMAC Transmit function
+ * @skb: SKB pointer
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Called by the system to transmit a packet - we queue the packet in
+ * EMAC hardware transmit queue
+ *
+ * Returns success(NETDEV_TX_OK) or error code (typically out of desc's)
+ */
+static int emac_dev_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+ struct device *emac_dev = &ndev->dev;
+ int ret_code;
+ struct emac_netbufobj tx_buf; /* buffer obj-only single frame support */
+ struct emac_netpktobj tx_packet; /* packet object */
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ /* If no link, return */
+ if (unlikely(!priv->link)) {
+ if (netif_msg_tx_err(priv) && net_ratelimit())
+ dev_err(emac_dev, "DaVinci EMAC: No link to transmit");
+ return NETDEV_TX_BUSY;
+ }
+
+ /* Build the buffer and packet objects - Since only single fragment is
+ * supported, need not set length and token in both packet & object.
+ * Doing so for completeness sake & to show that this needs to be done
+ * in multifragment case
+ */
+ tx_packet.buf_list = &tx_buf;
+ tx_packet.num_bufs = 1; /* only single fragment supported */
+ tx_packet.pkt_length = skb->len;
+ tx_packet.pkt_token = (void *)skb;
+ tx_buf.length = skb->len;
+ tx_buf.buf_token = (void *)skb;
+ tx_buf.data_ptr = skb->data;
+ EMAC_CACHE_WRITEBACK((unsigned long)skb->data, skb->len);
+ ndev->trans_start = jiffies;
+ ret_code = emac_send(priv, &tx_packet, EMAC_DEF_TX_CH);
+ if (unlikely(ret_code != 0)) {
+ if (ret_code == EMAC_ERR_TX_OUT_OF_BD) {
+ if (netif_msg_tx_err(priv) && net_ratelimit())
+ dev_err(emac_dev, "DaVinci EMAC: xmit() fatal"\
+ " err. Out of TX BD's");
+ netif_stop_queue(priv->ndev);
+ }
+ priv->net_dev_stats.tx_dropped++;
+ return NETDEV_TX_BUSY;
+ }
+
+ return NETDEV_TX_OK;
+}
+
+/**
+ * emac_dev_tx_timeout: EMAC Transmit timeout function
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Called when system detects that a skb timeout period has expired
+ * potentially due to a fault in the adapter in not being able to send
+ * it out on the wire. We teardown the TX channel assuming a hardware
+ * error and re-initialize the TX channel for hardware operation
+ *
+ */
+static void emac_dev_tx_timeout(struct net_device *ndev)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+ struct device *emac_dev = &ndev->dev;
+
+ if (netif_msg_tx_err(priv))
+ dev_err(emac_dev, "DaVinci EMAC: xmit timeout, restarting TX");
+
+ priv->net_dev_stats.tx_errors++;
+ emac_int_disable(priv);
+ emac_stop_txch(priv, EMAC_DEF_TX_CH);
+ emac_cleanup_txch(priv, EMAC_DEF_TX_CH);
+ emac_init_txch(priv, EMAC_DEF_TX_CH);
+ emac_write(EMAC_TXHDP(0), 0);
+ emac_write(EMAC_TXINTMASKSET, BIT(EMAC_DEF_TX_CH));
+ emac_int_enable(priv);
+}
+
+/**
+ * emac_net_alloc_rx_buf: Allocate a skb for RX
+ * @priv: The DaVinci EMAC private adapter structure
+ * @buf_size: size of SKB data buffer to allocate
+ * @data_token: data token returned (skb handle for storing in buffer desc)
+ * @ch: RX channel number
+ *
+ * Called during RX channel setup - allocates skb buffer of required size
+ * and provides the skb handle and allocated buffer data pointer to caller
+ *
+ * Returns skb data pointer or 0 on failure to alloc skb
+ */
+static void *emac_net_alloc_rx_buf(struct emac_priv *priv, int buf_size,
+ void **data_token, u32 ch)
+{
+ struct net_device *ndev = priv->ndev;
+ struct device *emac_dev = &ndev->dev;
+ struct sk_buff *p_skb;
+
+ p_skb = dev_alloc_skb(buf_size);
+ if (unlikely(NULL == p_skb)) {
+ if (netif_msg_rx_err(priv) && net_ratelimit())
+ dev_err(emac_dev, "DaVinci EMAC: failed to alloc skb");
+ return NULL;
+ }
+
+ /* set device pointer in skb and reserve space for extra bytes */
+ p_skb->dev = ndev;
+ skb_reserve(p_skb, NET_IP_ALIGN);
+ *data_token = (void *) p_skb;
+ EMAC_CACHE_WRITEBACK_INVALIDATE((unsigned long)p_skb->data, buf_size);
+ return p_skb->data;
+}
+
+/**
+ * emac_init_rxch: RX channel initialization
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ * @param: mac address for RX channel
+ *
+ * Called during device init to setup a RX channel (allocate buffers and
+ * buffer descriptors, create queue and keep ready for reception
+ *
+ * Returns success(0) or mem alloc failures error code
+ */
+static int emac_init_rxch(struct emac_priv *priv, u32 ch, char *param)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ u32 cnt, bd_size;
+ void __iomem *mem;
+ struct emac_rx_bd __iomem *curr_bd;
+ struct emac_rxch *rxch = NULL;
+
+ rxch = kzalloc(sizeof(struct emac_rxch), GFP_KERNEL);
+ if (NULL == rxch) {
+ dev_err(emac_dev, "DaVinci EMAC: RX Ch mem alloc failed");
+ return -ENOMEM;
+ }
+ priv->rxch[ch] = rxch;
+ rxch->buf_size = priv->rx_buf_size;
+ rxch->service_max = EMAC_DEF_RX_MAX_SERVICE;
+ rxch->queue_active = 0;
+ rxch->teardown_pending = 0;
+
+ /* save mac address */
+ for (cnt = 0; cnt < 6; cnt++)
+ rxch->mac_addr[cnt] = param[cnt];
+
+ /* allocate buffer descriptor pool align every BD on four word
+ * boundry for future requirements */
+ bd_size = (sizeof(struct emac_rx_bd) + 0xF) & ~0xF;
+ rxch->num_bd = (priv->ctrl_ram_size >> 1) / bd_size;
+ rxch->alloc_size = (((bd_size * rxch->num_bd) + 0xF) & ~0xF);
+ rxch->bd_mem = EMAC_RX_BD_MEM(priv);
+ __memzero((void __force *)rxch->bd_mem, rxch->alloc_size);
+ rxch->pkt_queue.buf_list = &rxch->buf_queue;
+
+ /* allocate RX buffer and initialize the BD linked list */
+ mem = (void __force __iomem *)
+ (((u32 __force) rxch->bd_mem + 0xF) & ~0xF);
+ rxch->active_queue_head = NULL;
+ rxch->active_queue_tail = mem;
+ for (cnt = 0; cnt < rxch->num_bd; cnt++) {
+ curr_bd = mem + (cnt * bd_size);
+ /* for future use the last parameter contains the BD ptr */
+ curr_bd->data_ptr = emac_net_alloc_rx_buf(priv,
+ rxch->buf_size,
+ (void __force **)&curr_bd->buf_token,
+ EMAC_DEF_RX_CH);
+ if (curr_bd->data_ptr == NULL) {
+ dev_err(emac_dev, "DaVinci EMAC: RX buf mem alloc " \
+ "failed for ch %d\n", ch);
+ kfree(rxch);
+ return -ENOMEM;
+ }
+
+ /* populate the hardware descriptor */
+ curr_bd->h_next = emac_virt_to_phys(rxch->active_queue_head);
+ /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */
+ curr_bd->buff_ptr = virt_to_phys(curr_bd->data_ptr);
+ curr_bd->off_b_len = rxch->buf_size;
+ curr_bd->mode = EMAC_CPPI_OWNERSHIP_BIT;
+
+ /* write back to hardware memory */
+ BD_CACHE_WRITEBACK_INVALIDATE((u32) curr_bd,
+ EMAC_BD_LENGTH_FOR_CACHE);
+ curr_bd->next = rxch->active_queue_head;
+ rxch->active_queue_head = curr_bd;
+ }
+
+ /* At this point rxCppi->activeQueueHead points to the first
+ RX BD ready to be given to RX HDP and rxch->active_queue_tail
+ points to the last RX BD
+ */
+ return 0;
+}
+
+/**
+ * emac_rxch_teardown: RX channel teardown
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ *
+ * Called during device stop to teardown RX channel
+ *
+ */
+static void emac_rxch_teardown(struct emac_priv *priv, u32 ch)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+ u32 teardown_cnt = 0xFFFFFFF0; /* Some high value */
+
+ while ((emac_read(EMAC_RXCP(ch)) & EMAC_TEARDOWN_VALUE) !=
+ EMAC_TEARDOWN_VALUE) {
+ /* wait till tx teardown complete */
+ cpu_relax(); /* TODO: check if this helps ... */
+ --teardown_cnt;
+ if (0 == teardown_cnt) {
+ dev_err(emac_dev, "EMAC: RX teardown aborted\n");
+ break;
+ }
+ }
+ emac_write(EMAC_RXCP(ch), EMAC_TEARDOWN_VALUE);
+}
+
+/**
+ * emac_stop_rxch: Stop RX channel operation
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ *
+ * Called during device stop to stop RX channel operation
+ *
+ */
+static void emac_stop_rxch(struct emac_priv *priv, u32 ch)
+{
+ struct emac_rxch *rxch = priv->rxch[ch];
+
+ if (rxch) {
+ rxch->teardown_pending = 1;
+ emac_write(EMAC_RXTEARDOWN, ch);
+ /* wait for teardown complete */
+ emac_rxch_teardown(priv, ch);
+ rxch->teardown_pending = 0;
+ emac_write(EMAC_RXINTMASKCLEAR, BIT(ch));
+ }
+}
+
+/**
+ * emac_cleanup_rxch: Book-keep function to clean RX channel resources
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ *
+ * Called during device stop to clean up RX channel resources
+ *
+ */
+static void emac_cleanup_rxch(struct emac_priv *priv, u32 ch)
+{
+ struct emac_rxch *rxch = priv->rxch[ch];
+ struct emac_rx_bd __iomem *curr_bd;
+
+ if (rxch) {
+ /* free the receive buffers previously allocated */
+ curr_bd = rxch->active_queue_head;
+ while (curr_bd) {
+ if (curr_bd->buf_token) {
+ dev_kfree_skb_any((struct sk_buff *)\
+ curr_bd->buf_token);
+ }
+ curr_bd = curr_bd->next;
+ }
+ if (rxch->bd_mem)
+ rxch->bd_mem = NULL;
+ kfree(rxch);
+ priv->rxch[ch] = NULL;
+ }
+}
+
+/**
+ * emac_set_type0addr: Set EMAC Type0 mac address
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ * @mac_addr: MAC address to set in device
+ *
+ * Called internally to set Type0 mac address of the adapter (Device)
+ *
+ * Returns success (0) or appropriate error code (none as of now)
+ */
+static void emac_set_type0addr(struct emac_priv *priv, u32 ch, char *mac_addr)
+{
+ u32 val;
+ val = ((mac_addr[5] << 8) | (mac_addr[4]));
+ emac_write(EMAC_MACSRCADDRLO, val);
+
+ val = ((mac_addr[3] << 24) | (mac_addr[2] << 16) | \
+ (mac_addr[1] << 8) | (mac_addr[0]));
+ emac_write(EMAC_MACSRCADDRHI, val);
+ val = emac_read(EMAC_RXUNICASTSET);
+ val |= BIT(ch);
+ emac_write(EMAC_RXUNICASTSET, val);
+ val = emac_read(EMAC_RXUNICASTCLEAR);
+ val &= ~BIT(ch);
+ emac_write(EMAC_RXUNICASTCLEAR, val);
+}
+
+/**
+ * emac_set_type1addr: Set EMAC Type1 mac address
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ * @mac_addr: MAC address to set in device
+ *
+ * Called internally to set Type1 mac address of the adapter (Device)
+ *
+ * Returns success (0) or appropriate error code (none as of now)
+ */
+static void emac_set_type1addr(struct emac_priv *priv, u32 ch, char *mac_addr)
+{
+ u32 val;
+ emac_write(EMAC_MACINDEX, ch);
+ val = ((mac_addr[5] << 8) | mac_addr[4]);
+ emac_write(EMAC_MACADDRLO, val);
+ val = ((mac_addr[3] << 24) | (mac_addr[2] << 16) | \
+ (mac_addr[1] << 8) | (mac_addr[0]));
+ emac_write(EMAC_MACADDRHI, val);
+ emac_set_type0addr(priv, ch, mac_addr);
+}
+
+/**
+ * emac_set_type2addr: Set EMAC Type2 mac address
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ * @mac_addr: MAC address to set in device
+ * @index: index into RX address entries
+ * @match: match parameter for RX address matching logic
+ *
+ * Called internally to set Type2 mac address of the adapter (Device)
+ *
+ * Returns success (0) or appropriate error code (none as of now)
+ */
+static void emac_set_type2addr(struct emac_priv *priv, u32 ch,
+ char *mac_addr, int index, int match)
+{
+ u32 val;
+ emac_write(EMAC_MACINDEX, index);
+ val = ((mac_addr[3] << 24) | (mac_addr[2] << 16) | \
+ (mac_addr[1] << 8) | (mac_addr[0]));
+ emac_write(EMAC_MACADDRHI, val);
+ val = ((mac_addr[5] << 8) | mac_addr[4] | ((ch & 0x7) << 16) | \
+ (match << 19) | BIT(20));
+ emac_write(EMAC_MACADDRLO, val);
+ emac_set_type0addr(priv, ch, mac_addr);
+}
+
+/**
+ * emac_setmac: Set mac address in the adapter (internal function)
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number
+ * @mac_addr: MAC address to set in device
+ *
+ * Called internally to set the mac address of the adapter (Device)
+ *
+ * Returns success (0) or appropriate error code (none as of now)
+ */
+static void emac_setmac(struct emac_priv *priv, u32 ch, char *mac_addr)
+{
+ struct device *emac_dev = &priv->ndev->dev;
+
+ if (priv->rx_addr_type == 0) {
+ emac_set_type0addr(priv, ch, mac_addr);
+ } else if (priv->rx_addr_type == 1) {
+ u32 cnt;
+ for (cnt = 0; cnt < EMAC_MAX_TXRX_CHANNELS; cnt++)
+ emac_set_type1addr(priv, ch, mac_addr);
+ } else if (priv->rx_addr_type == 2) {
+ emac_set_type2addr(priv, ch, mac_addr, ch, 1);
+ emac_set_type0addr(priv, ch, mac_addr);
+ } else {
+ if (netif_msg_drv(priv))
+ dev_err(emac_dev, "DaVinci EMAC: Wrong addressing\n");
+ }
+}
+
+/**
+ * emac_dev_setmac_addr: Set mac address in the adapter
+ * @ndev: The DaVinci EMAC network adapter
+ * @addr: MAC address to set in device
+ *
+ * Called by the system to set the mac address of the adapter (Device)
+ *
+ * Returns success (0) or appropriate error code (none as of now)
+ */
+static int emac_dev_setmac_addr(struct net_device *ndev, void *addr)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+ struct emac_rxch *rxch = priv->rxch[EMAC_DEF_RX_CH];
+ struct device *emac_dev = &priv->ndev->dev;
+ struct sockaddr *sa = addr;
+ DECLARE_MAC_BUF(mac);
+
+ /* Store mac addr in priv and rx channel and set it in EMAC hw */
+ memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
+ memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len);
+ memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len);
+ emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr);
+
+ if (netif_msg_drv(priv))
+ dev_notice(emac_dev, "DaVinci EMAC: emac_dev_setmac_addr %s\n",
+ print_mac(mac, priv->mac_addr));
+
+ return 0;
+}
+
+/**
+ * emac_addbd_to_rx_queue: Recycle RX buffer descriptor
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number to process buffer descriptors for
+ * @curr_bd: current buffer descriptor
+ * @buffer: buffer pointer for descriptor
+ * @buf_token: buffer token (stores skb information)
+ *
+ * Prepares the recycled buffer descriptor and addes it to hardware
+ * receive queue - if queue empty this descriptor becomes the head
+ * else addes the descriptor to end of queue
+ *
+ */
+static void emac_addbd_to_rx_queue(struct emac_priv *priv, u32 ch,
+ struct emac_rx_bd __iomem *curr_bd,
+ char *buffer, void *buf_token)
+{
+ struct emac_rxch *rxch = priv->rxch[ch];
+
+ /* populate the hardware descriptor */
+ curr_bd->h_next = 0;
+ /* FIXME buff_ptr = dma_map_single(... buffer ...) */
+ curr_bd->buff_ptr = virt_to_phys(buffer);
+ curr_bd->off_b_len = rxch->buf_size;
+ curr_bd->mode = EMAC_CPPI_OWNERSHIP_BIT;
+ curr_bd->next = NULL;
+ curr_bd->data_ptr = buffer;
+ curr_bd->buf_token = buf_token;
+
+ /* write back */
+ BD_CACHE_WRITEBACK_INVALIDATE(curr_bd, EMAC_BD_LENGTH_FOR_CACHE);
+ if (rxch->active_queue_head == NULL) {
+ rxch->active_queue_head = curr_bd;
+ rxch->active_queue_tail = curr_bd;
+ if (0 != rxch->queue_active) {
+ emac_write(EMAC_RXHDP(ch),
+ emac_virt_to_phys(rxch->active_queue_head));
+ rxch->queue_active = 1;
+ }
+ } else {
+ struct emac_rx_bd __iomem *tail_bd;
+ u32 frame_status;
+
+ tail_bd = rxch->active_queue_tail;
+ rxch->active_queue_tail = curr_bd;
+ tail_bd->next = curr_bd;
+ tail_bd = EMAC_VIRT_NOCACHE(tail_bd);
+ tail_bd->h_next = emac_virt_to_phys(curr_bd);
+ frame_status = tail_bd->mode;
+ if (frame_status & EMAC_CPPI_EOQ_BIT) {
+ emac_write(EMAC_RXHDP(ch),
+ emac_virt_to_phys(curr_bd));
+ frame_status &= ~(EMAC_CPPI_EOQ_BIT);
+ tail_bd->mode = frame_status;
+ ++rxch->end_of_queue_add;
+ }
+ }
+ ++rxch->recycled_bd;
+}
+
+/**
+ * emac_net_rx_cb: Prepares packet and sends to upper layer
+ * @priv: The DaVinci EMAC private adapter structure
+ * @net_pkt_list: Network packet list (received packets)
+ *
+ * Invalidates packet buffer memory and sends the received packet to upper
+ * layer
+ *
+ * Returns success or appropriate error code (none as of now)
+ */
+static int emac_net_rx_cb(struct emac_priv *priv,
+ struct emac_netpktobj *net_pkt_list)
+{
+ struct sk_buff *p_skb;
+ p_skb = (struct sk_buff *)net_pkt_list->pkt_token;
+ /* set length of packet */
+ skb_put(p_skb, net_pkt_list->pkt_length);
+ EMAC_CACHE_INVALIDATE((unsigned long)p_skb->data, p_skb->len);
+ p_skb->protocol = eth_type_trans(p_skb, priv->ndev);
+ p_skb->dev->last_rx = jiffies;
+ netif_receive_skb(p_skb);
+ priv->net_dev_stats.rx_bytes += net_pkt_list->pkt_length;
+ priv->net_dev_stats.rx_packets++;
+ return 0;
+}
+
+/**
+ * emac_rx_bdproc: RX buffer descriptor (packet) processing
+ * @priv: The DaVinci EMAC private adapter structure
+ * @ch: RX channel number to process buffer descriptors for
+ * @budget: number of packets allowed to process
+ * @pending: indication to caller that packets are pending to process
+ *
+ * Processes RX buffer descriptors - checks ownership bit on the RX buffer
+ * descriptor, sends the receive packet to upper layer, allocates a new SKB
+ * and recycles the buffer descriptor (requeues it in hardware RX queue).
+ * Only "budget" number of packets are processed and indication of pending
+ * packets provided to the caller.
+ *
+ * Returns number of packets processed (and indication of pending packets)
+ */
+static int emac_rx_bdproc(struct emac_priv *priv, u32 ch, u32 budget)
+{
+ unsigned long flags;
+ u32 frame_status;
+ u32 pkts_processed = 0;
+ char *new_buffer;
+ struct emac_rx_bd __iomem *curr_bd;
+ struct emac_rx_bd __iomem *last_bd;
+ struct emac_netpktobj *curr_pkt, pkt_obj;
+ struct emac_netbufobj buf_obj;
+ struct emac_netbufobj *rx_buf_obj;
+ void *new_buf_token;
+ struct emac_rxch *rxch = priv->rxch[ch];
+
+ if (unlikely(1 == rxch->teardown_pending))
+ return 0;
+ ++rxch->proc_count;
+ spin_lock_irqsave(&priv->rx_lock, flags);
+ pkt_obj.buf_list = &buf_obj;
+ curr_pkt = &pkt_obj;
+ curr_bd = rxch->active_queue_head;
+ BD_CACHE_INVALIDATE(curr_bd, EMAC_BD_LENGTH_FOR_CACHE);
+ frame_status = curr_bd->mode;
+
+ while ((curr_bd) &&
+ ((frame_status & EMAC_CPPI_OWNERSHIP_BIT) == 0) &&
+ (pkts_processed < budget)) {
+
+ new_buffer = emac_net_alloc_rx_buf(priv, rxch->buf_size,
+ &new_buf_token, EMAC_DEF_RX_CH);
+ if (unlikely(NULL == new_buffer)) {
+ ++rxch->out_of_rx_buffers;
+ goto end_emac_rx_bdproc;
+ }
+
+ /* populate received packet data structure */
+ rx_buf_obj = &curr_pkt->buf_list[0];
+ rx_buf_obj->data_ptr = (char *)curr_bd->data_ptr;
+ rx_buf_obj->length = curr_bd->off_b_len & EMAC_RX_BD_BUF_SIZE;
+ rx_buf_obj->buf_token = curr_bd->buf_token;
+ curr_pkt->pkt_token = curr_pkt->buf_list->buf_token;
+ curr_pkt->num_bufs = 1;
+ curr_pkt->pkt_length =
+ (frame_status & EMAC_RX_BD_PKT_LENGTH_MASK);
+ emac_write(EMAC_RXCP(ch), emac_virt_to_phys(curr_bd));
+ ++rxch->processed_bd;
+ last_bd = curr_bd;
+ curr_bd = last_bd->next;
+ rxch->active_queue_head = curr_bd;
+
+ /* check if end of RX queue ? */
+ if (frame_status & EMAC_CPPI_EOQ_BIT) {
+ if (curr_bd) {
+ ++rxch->mis_queued_packets;
+ emac_write(EMAC_RXHDP(ch),
+ emac_virt_to_phys(curr_bd));
+ } else {
+ ++rxch->end_of_queue;
+ rxch->queue_active = 0;
+ }
+ }
+
+ /* recycle BD */
+ emac_addbd_to_rx_queue(priv, ch, last_bd, new_buffer,
+ new_buf_token);
+
+ /* return the packet to the user - BD ptr passed in
+ * last parameter for potential *future* use */
+ spin_unlock_irqrestore(&priv->rx_lock, flags);
+ emac_net_rx_cb(priv, curr_pkt);
+ spin_lock_irqsave(&priv->rx_lock, flags);
+ curr_bd = rxch->active_queue_head;
+ if (curr_bd) {
+ BD_CACHE_INVALIDATE(curr_bd, EMAC_BD_LENGTH_FOR_CACHE);
+ frame_status = curr_bd->mode;
+ }
+ ++pkts_processed;
+ }
+
+end_emac_rx_bdproc:
+ spin_unlock_irqrestore(&priv->rx_lock, flags);
+ return pkts_processed;
+}
+
+/**
+ * emac_hw_enable: Enable EMAC hardware for packet transmission/reception
+ * @priv: The DaVinci EMAC private adapter structure
+ *
+ * Enables EMAC hardware for packet processing - enables PHY, enables RX
+ * for packet reception and enables device interrupts and then NAPI
+ *
+ * Returns success (0) or appropriate error code (none right now)
+ */
+static int emac_hw_enable(struct emac_priv *priv)
+{
+ u32 ch, val, mbp_enable, mac_control;
+
+ /* Soft reset */
+ emac_write(EMAC_SOFTRESET, 1);
+ while (emac_read(EMAC_SOFTRESET))
+ cpu_relax();
+
+ /* Disable interrupt & Set pacing for more interrupts initially */
+ emac_int_disable(priv);
+
+ /* Full duplex enable bit set when auto negotiation happens */
+ mac_control =
+ (((EMAC_DEF_TXPRIO_FIXED) ? (EMAC_MACCONTROL_TXPTYPE) : 0x0) |
+ ((priv->speed == 1000) ? EMAC_MACCONTROL_GIGABITEN : 0x0) |
+ ((EMAC_DEF_TXPACING_EN) ? (EMAC_MACCONTROL_TXPACEEN) : 0x0) |
+ ((priv->duplex == DUPLEX_FULL) ? 0x1 : 0));
+ emac_write(EMAC_MACCONTROL, mac_control);
+
+ mbp_enable =
+ (((EMAC_DEF_PASS_CRC) ? (EMAC_RXMBP_PASSCRC_MASK) : 0x0) |
+ ((EMAC_DEF_QOS_EN) ? (EMAC_RXMBP_QOSEN_MASK) : 0x0) |
+ ((EMAC_DEF_NO_BUFF_CHAIN) ? (EMAC_RXMBP_NOCHAIN_MASK) : 0x0) |
+ ((EMAC_DEF_MACCTRL_FRAME_EN) ? (EMAC_RXMBP_CMFEN_MASK) : 0x0) |
+ ((EMAC_DEF_SHORT_FRAME_EN) ? (EMAC_RXMBP_CSFEN_MASK) : 0x0) |
+ ((EMAC_DEF_ERROR_FRAME_EN) ? (EMAC_RXMBP_CEFEN_MASK) : 0x0) |
+ ((EMAC_DEF_PROM_EN) ? (EMAC_RXMBP_CAFEN_MASK) : 0x0) |
+ ((EMAC_DEF_PROM_CH & EMAC_RXMBP_CHMASK) << \
+ EMAC_RXMBP_PROMCH_SHIFT) |
+ ((EMAC_DEF_BCAST_EN) ? (EMAC_RXMBP_BROADEN_MASK) : 0x0) |
+ ((EMAC_DEF_BCAST_CH & EMAC_RXMBP_CHMASK) << \
+ EMAC_RXMBP_BROADCH_SHIFT) |
+ ((EMAC_DEF_MCAST_EN) ? (EMAC_RXMBP_MULTIEN_MASK) : 0x0) |
+ ((EMAC_DEF_MCAST_CH & EMAC_RXMBP_CHMASK) << \
+ EMAC_RXMBP_MULTICH_SHIFT));
+ emac_write(EMAC_RXMBPENABLE, mbp_enable);
+ emac_write(EMAC_RXMAXLEN, (EMAC_DEF_MAX_FRAME_SIZE &
+ EMAC_RX_MAX_LEN_MASK));
+ emac_write(EMAC_RXBUFFEROFFSET, (EMAC_DEF_BUFFER_OFFSET &
+ EMAC_RX_BUFFER_OFFSET_MASK));
+ emac_write(EMAC_RXFILTERLOWTHRESH, 0);
+ emac_write(EMAC_RXUNICASTCLEAR, EMAC_RX_UNICAST_CLEAR_ALL);
+ priv->rx_addr_type = (emac_read(EMAC_MACCONFIG) >> 8) & 0xFF;
+
+ val = emac_read(EMAC_TXCONTROL);
+ val |= EMAC_TX_CONTROL_TX_ENABLE_VAL;
+ emac_write(EMAC_TXCONTROL, val);
+ val = emac_read(EMAC_RXCONTROL);
+ val |= EMAC_RX_CONTROL_RX_ENABLE_VAL;
+ emac_write(EMAC_RXCONTROL, val);
+ emac_write(EMAC_MACINTMASKSET, EMAC_MAC_HOST_ERR_INTMASK_VAL);
+
+ for (ch = 0; ch < EMAC_DEF_MAX_TX_CH; ch++) {
+ emac_write(EMAC_TXHDP(ch), 0);
+ emac_write(EMAC_TXINTMASKSET, BIT(ch));
+ }
+ for (ch = 0; ch < EMAC_DEF_MAX_RX_CH; ch++) {
+ struct emac_rxch *rxch = priv->rxch[ch];
+ emac_setmac(priv, ch, rxch->mac_addr);
+ emac_write(EMAC_RXINTMASKSET, BIT(ch));
+ rxch->queue_active = 1;
+ emac_write(EMAC_RXHDP(ch),
+ emac_virt_to_phys(rxch->active_queue_head));
+ }
+
+ /* Enable MII */
+ val = emac_read(EMAC_MACCONTROL);
+ val |= (EMAC_MACCONTROL_MIIEN);
+ emac_write(EMAC_MACCONTROL, val);
+
+ /* Enable NAPI and interrupts */
+ napi_enable(&priv->napi);
+ emac_int_enable(priv);
+ return 0;
+
+}
+
+/**
+ * emac_poll: EMAC NAPI Poll function
+ * @ndev: The DaVinci EMAC network adapter
+ * @budget: Number of receive packets to process (as told by NAPI layer)
+ *
+ * NAPI Poll function implemented to process packets as per budget. We check
+ * the type of interrupt on the device and accordingly call the TX or RX
+ * packet processing functions. We follow the budget for RX processing and
+ * also put a cap on number of TX pkts processed through config param. The
+ * NAPI schedule function is called if more packets pending.
+ *
+ * Returns number of packets received (in most cases; else TX pkts - rarely)
+ */
+static int emac_poll(struct napi_struct *napi, int budget)
+{
+ unsigned int mask;
+ struct emac_priv *priv = container_of(napi, struct emac_priv, napi);
+ struct net_device *ndev = priv->ndev;
+ struct device *emac_dev = &ndev->dev;
+ u32 status = 0;
+ u32 num_pkts = 0;
+
+ if (!netif_running(ndev))
+ return 0;
+
+ /* Check interrupt vectors and call packet processing */
+ status = emac_read(EMAC_MACINVECTOR);
+
+ mask = EMAC_DM644X_MAC_IN_VECTOR_TX_INT_VEC;
+
+ if (priv->version == EMAC_VERSION_2)
+ mask = EMAC_DM646X_MAC_IN_VECTOR_TX_INT_VEC;
+
+ if (status & mask) {
+ num_pkts = emac_tx_bdproc(priv, EMAC_DEF_TX_CH,
+ EMAC_DEF_TX_MAX_SERVICE);
+ } /* TX processing */
+
+ if (num_pkts)
+ return budget;
+
+ mask = EMAC_DM644X_MAC_IN_VECTOR_RX_INT_VEC;
+
+ if (priv->version == EMAC_VERSION_2)
+ mask = EMAC_DM646X_MAC_IN_VECTOR_RX_INT_VEC;
+
+ if (status & mask) {
+ num_pkts = emac_rx_bdproc(priv, EMAC_DEF_RX_CH, budget);
+ } /* RX processing */
+
+ if (num_pkts < budget) {
+ napi_complete(napi);
+ emac_int_enable(priv);
+ }
+
+ if (unlikely(status & EMAC_DM644X_MAC_IN_VECTOR_HOST_INT)) {
+ u32 ch, cause;
+ dev_err(emac_dev, "DaVinci EMAC: Fatal Hardware Error\n");
+ netif_stop_queue(ndev);
+ napi_disable(&priv->napi);
+
+ status = emac_read(EMAC_MACSTATUS);
+ cause = ((status & EMAC_MACSTATUS_TXERRCODE_MASK) >>
+ EMAC_MACSTATUS_TXERRCODE_SHIFT);
+ if (cause) {
+ ch = ((status & EMAC_MACSTATUS_TXERRCH_MASK) >>
+ EMAC_MACSTATUS_TXERRCH_SHIFT);
+ if (net_ratelimit()) {
+ dev_err(emac_dev, "TX Host error %s on ch=%d\n",
+ &emac_txhost_errcodes[cause][0], ch);
+ }
+ }
+ cause = ((status & EMAC_MACSTATUS_RXERRCODE_MASK) >>
+ EMAC_MACSTATUS_RXERRCODE_SHIFT);
+ if (cause) {
+ ch = ((status & EMAC_MACSTATUS_RXERRCH_MASK) >>
+ EMAC_MACSTATUS_RXERRCH_SHIFT);
+ if (netif_msg_hw(priv) && net_ratelimit())
+ dev_err(emac_dev, "RX Host error %s on ch=%d\n",
+ &emac_rxhost_errcodes[cause][0], ch);
+ }
+ } /* Host error processing */
+
+ return num_pkts;
+}
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/**
+ * emac_poll_controller: EMAC Poll controller function
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Polled functionality used by netconsole and others in non interrupt mode
+ *
+ */
+void emac_poll_controller(struct net_device *ndev)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ emac_int_disable(priv);
+ emac_irq(ndev->irq, priv);
+ emac_int_enable(priv);
+}
+#endif
+
+/* PHY/MII bus related */
+
+/* Wait until mdio is ready for next command */
+#define MDIO_WAIT_FOR_USER_ACCESS\
+ while ((emac_mdio_read((MDIO_USERACCESS(0))) &\
+ MDIO_USERACCESS_GO) != 0)
+
+static int emac_mii_read(struct mii_bus *bus, int phy_id, int phy_reg)
+{
+ unsigned int phy_data = 0;
+ unsigned int phy_control;
+
+ /* Wait until mdio is ready for next command */
+ MDIO_WAIT_FOR_USER_ACCESS;
+
+ phy_control = (MDIO_USERACCESS_GO |
+ MDIO_USERACCESS_READ |
+ ((phy_reg << 21) & MDIO_USERACCESS_REGADR) |
+ ((phy_id << 16) & MDIO_USERACCESS_PHYADR) |
+ (phy_data & MDIO_USERACCESS_DATA));
+ emac_mdio_write(MDIO_USERACCESS(0), phy_control);
+
+ /* Wait until mdio is ready for next command */
+ MDIO_WAIT_FOR_USER_ACCESS;
+
+ return emac_mdio_read(MDIO_USERACCESS(0)) & MDIO_USERACCESS_DATA;
+
+}
+
+static int emac_mii_write(struct mii_bus *bus, int phy_id,
+ int phy_reg, u16 phy_data)
+{
+
+ unsigned int control;
+
+ /* until mdio is ready for next command */
+ MDIO_WAIT_FOR_USER_ACCESS;
+
+ control = (MDIO_USERACCESS_GO |
+ MDIO_USERACCESS_WRITE |
+ ((phy_reg << 21) & MDIO_USERACCESS_REGADR) |
+ ((phy_id << 16) & MDIO_USERACCESS_PHYADR) |
+ (phy_data & MDIO_USERACCESS_DATA));
+ emac_mdio_write(MDIO_USERACCESS(0), control);
+
+ return 0;
+}
+
+static int emac_mii_reset(struct mii_bus *bus)
+{
+ unsigned int clk_div;
+ int mdio_bus_freq = emac_bus_frequency;
+
+ if (mdio_max_freq & mdio_bus_freq)
+ clk_div = ((mdio_bus_freq / mdio_max_freq) - 1);
+ else
+ clk_div = 0xFF;
+
+ clk_div &= MDIO_CONTROL_CLKDIV;
+
+ /* Set enable and clock divider in MDIOControl */
+ emac_mdio_write(MDIO_CONTROL, (clk_div | MDIO_CONTROL_ENABLE));
+
+ return 0;
+
+}
+
+static int mii_irqs[PHY_MAX_ADDR] = { PHY_POLL, PHY_POLL };
+
+/* emac_driver: EMAC MII bus structure */
+
+static struct mii_bus *emac_mii;
+
+static void emac_adjust_link(struct net_device *ndev)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+ struct phy_device *phydev = priv->phydev;
+ unsigned long flags;
+ int new_state = 0;
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+ if (phydev->link) {
+ /* check the mode of operation - full/half duplex */
+ if (phydev->duplex != priv->duplex) {
+ new_state = 1;
+ priv->duplex = phydev->duplex;
+ }
+ if (phydev->speed != priv->speed) {
+ new_state = 1;
+ priv->speed = phydev->speed;
+ }
+ if (!priv->link) {
+ new_state = 1;
+ priv->link = 1;
+ }
+
+ } else if (priv->link) {
+ new_state = 1;
+ priv->link = 0;
+ priv->speed = 0;
+ priv->duplex = ~0;
+ }
+ if (new_state) {
+ emac_update_phystatus(priv);
+ phy_print_status(priv->phydev);
+ }
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+}
+
+/*************************************************************************
+ * Linux Driver Model
+ *************************************************************************/
+
+/**
+ * emac_devioctl: EMAC adapter ioctl
+ * @ndev: The DaVinci EMAC network adapter
+ * @ifrq: request parameter
+ * @cmd: command parameter
+ *
+ * EMAC driver ioctl function
+ *
+ * Returns success(0) or appropriate error code
+ */
+static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
+{
+ dev_warn(&ndev->dev, "DaVinci EMAC: ioctl not supported\n");
+
+ if (!(netif_running(ndev)))
+ return -EINVAL;
+
+ /* TODO: Add phy read and write and private statistics get feature */
+
+ return -EOPNOTSUPP;
+}
+
+/**
+ * emac_dev_open: EMAC device open
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Called when system wants to start the interface. We init TX/RX channels
+ * and enable the hardware for packet reception/transmission and start the
+ * network queue.
+ *
+ * Returns 0 for a successful open, or appropriate error code
+ */
+static int emac_dev_open(struct net_device *ndev)
+{
+ struct device *emac_dev = &ndev->dev;
+ u32 rc, cnt, ch;
+ int phy_addr;
+ struct resource *res;
+ int q, m;
+ int i = 0;
+ int k = 0;
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ netif_carrier_off(ndev);
+ for (cnt = 0; cnt <= ETH_ALEN; cnt++)
+ ndev->dev_addr[cnt] = priv->mac_addr[cnt];
+
+ /* Configuration items */
+ priv->rx_buf_size = EMAC_DEF_MAX_FRAME_SIZE + NET_IP_ALIGN;
+
+ /* Clear basic hardware */
+ for (ch = 0; ch < EMAC_MAX_TXRX_CHANNELS; ch++) {
+ emac_write(EMAC_TXHDP(ch), 0);
+ emac_write(EMAC_RXHDP(ch), 0);
+ emac_write(EMAC_RXHDP(ch), 0);
+ emac_write(EMAC_RXINTMASKCLEAR, EMAC_INT_MASK_CLEAR);
+ emac_write(EMAC_TXINTMASKCLEAR, EMAC_INT_MASK_CLEAR);
+ }
+ priv->mac_hash1 = 0;
+ priv->mac_hash2 = 0;
+ emac_write(EMAC_MACHASH1, 0);
+ emac_write(EMAC_MACHASH2, 0);
+
+ /* multi ch not supported - open 1 TX, 1RX ch by default */
+ rc = emac_init_txch(priv, EMAC_DEF_TX_CH);
+ if (0 != rc) {
+ dev_err(emac_dev, "DaVinci EMAC: emac_init_txch() failed");
+ return rc;
+ }
+ rc = emac_init_rxch(priv, EMAC_DEF_RX_CH, priv->mac_addr);
+ if (0 != rc) {
+ dev_err(emac_dev, "DaVinci EMAC: emac_init_rxch() failed");
+ return rc;
+ }
+
+ /* Request IRQ */
+
+ while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
+ for (i = res->start; i <= res->end; i++) {
+ if (request_irq(i, emac_irq, IRQF_DISABLED,
+ ndev->name, ndev))
+ goto rollback;
+ }
+ k++;
+ }
+
+ /* Start/Enable EMAC hardware */
+ emac_hw_enable(priv);
+
+ /* find the first phy */
+ priv->phydev = NULL;
+ if (priv->phy_mask) {
+ emac_mii_reset(priv->mii_bus);
+ for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
+ if (priv->mii_bus->phy_map[phy_addr]) {
+ priv->phydev = priv->mii_bus->phy_map[phy_addr];
+ break;
+ }
+ }
+
+ if (!priv->phydev) {
+ printk(KERN_ERR "%s: no PHY found\n", ndev->name);
+ return -1;
+ }
+
+ priv->phydev = phy_connect(ndev, dev_name(&priv->phydev->dev),
+ &emac_adjust_link, 0, PHY_INTERFACE_MODE_MII);
+
+ if (IS_ERR(priv->phydev)) {
+ printk(KERN_ERR "%s: Could not attach to PHY\n",
+ ndev->name);
+ return PTR_ERR(priv->phydev);
+ }
+
+ priv->link = 0;
+ priv->speed = 0;
+ priv->duplex = ~0;
+
+ printk(KERN_INFO "%s: attached PHY driver [%s] "
+ "(mii_bus:phy_addr=%s, id=%x)\n", ndev->name,
+ priv->phydev->drv->name, dev_name(&priv->phydev->dev),
+ priv->phydev->phy_id);
+ } else{
+ /* No PHY , fix the link, speed and duplex settings */
+ priv->link = 1;
+ priv->speed = SPEED_100;
+ priv->duplex = DUPLEX_FULL;
+ emac_update_phystatus(priv);
+ }
+
+ if (!netif_running(ndev)) /* debug only - to avoid compiler warning */
+ emac_dump_regs(priv);
+
+ if (netif_msg_drv(priv))
+ dev_notice(emac_dev, "DaVinci EMAC: Opened %s\n", ndev->name);
+
+ if (priv->phy_mask)
+ phy_start(priv->phydev);
+
+ return 0;
+
+rollback:
+
+ dev_err(emac_dev, "DaVinci EMAC: request_irq() failed");
+
+ for (q = k; k >= 0; k--) {
+ for (m = i; m >= res->start; m--)
+ free_irq(m, ndev);
+ res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k-1);
+ m = res->end;
+ }
+ return -EBUSY;
+}
+
+/**
+ * emac_dev_stop: EMAC device stop
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Called when system wants to stop or down the interface. We stop the network
+ * queue, disable interrupts and cleanup TX/RX channels.
+ *
+ * We return the statistics in net_device_stats structure pulled from emac
+ */
+static int emac_dev_stop(struct net_device *ndev)
+{
+ struct resource *res;
+ int i = 0;
+ int irq_num;
+ struct emac_priv *priv = netdev_priv(ndev);
+ struct device *emac_dev = &ndev->dev;
+
+ /* inform the upper layers. */
+ netif_stop_queue(ndev);
+ napi_disable(&priv->napi);
+
+ netif_carrier_off(ndev);
+ emac_int_disable(priv);
+ emac_stop_txch(priv, EMAC_DEF_TX_CH);
+ emac_stop_rxch(priv, EMAC_DEF_RX_CH);
+ emac_cleanup_txch(priv, EMAC_DEF_TX_CH);
+ emac_cleanup_rxch(priv, EMAC_DEF_RX_CH);
+ emac_write(EMAC_SOFTRESET, 1);
+
+ if (priv->phydev)
+ phy_disconnect(priv->phydev);
+
+ /* Free IRQ */
+ while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) {
+ for (irq_num = res->start; irq_num <= res->end; irq_num++)
+ free_irq(irq_num, priv->ndev);
+ i++;
+ }
+
+ if (netif_msg_drv(priv))
+ dev_notice(emac_dev, "DaVinci EMAC: %s stopped\n", ndev->name);
+
+ return 0;
+}
+
+/**
+ * emac_dev_getnetstats: EMAC get statistics function
+ * @ndev: The DaVinci EMAC network adapter
+ *
+ * Called when system wants to get statistics from the device.
+ *
+ * We return the statistics in net_device_stats structure pulled from emac
+ */
+static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
+{
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ /* update emac hardware stats and reset the registers*/
+
+ priv->net_dev_stats.multicast += emac_read(EMAC_RXMCASTFRAMES);
+ emac_write(EMAC_RXMCASTFRAMES, EMAC_ALL_MULTI_REG_VALUE);
+
+ priv->net_dev_stats.collisions += (emac_read(EMAC_TXCOLLISION) +
+ emac_read(EMAC_TXSINGLECOLL) +
+ emac_read(EMAC_TXMULTICOLL));
+ emac_write(EMAC_TXCOLLISION, EMAC_ALL_MULTI_REG_VALUE);
+ emac_write(EMAC_TXSINGLECOLL, EMAC_ALL_MULTI_REG_VALUE);
+ emac_write(EMAC_TXMULTICOLL, EMAC_ALL_MULTI_REG_VALUE);
+
+ priv->net_dev_stats.rx_length_errors += (emac_read(EMAC_RXOVERSIZED) +
+ emac_read(EMAC_RXJABBER) +
+ emac_read(EMAC_RXUNDERSIZED));
+ emac_write(EMAC_RXOVERSIZED, EMAC_ALL_MULTI_REG_VALUE);
+ emac_write(EMAC_RXJABBER, EMAC_ALL_MULTI_REG_VALUE);
+ emac_write(EMAC_RXUNDERSIZED, EMAC_ALL_MULTI_REG_VALUE);
+
+ priv->net_dev_stats.rx_over_errors += (emac_read(EMAC_RXSOFOVERRUNS) +
+ emac_read(EMAC_RXMOFOVERRUNS));
+ emac_write(EMAC_RXSOFOVERRUNS, EMAC_ALL_MULTI_REG_VALUE);
+ emac_write(EMAC_RXMOFOVERRUNS, EMAC_ALL_MULTI_REG_VALUE);
+
+ priv->net_dev_stats.rx_fifo_errors += emac_read(EMAC_RXDMAOVERRUNS);
+ emac_write(EMAC_RXDMAOVERRUNS, EMAC_ALL_MULTI_REG_VALUE);
+
+ priv->net_dev_stats.tx_carrier_errors +=
+ emac_read(EMAC_TXCARRIERSENSE);
+ emac_write(EMAC_TXCARRIERSENSE, EMAC_ALL_MULTI_REG_VALUE);
+
+ priv->net_dev_stats.tx_fifo_errors = emac_read(EMAC_TXUNDERRUN);
+ emac_write(EMAC_TXUNDERRUN, EMAC_ALL_MULTI_REG_VALUE);
+
+ return &priv->net_dev_stats;
+}
+
+static const struct net_device_ops emac_netdev_ops = {
+ .ndo_open = emac_dev_open,
+ .ndo_stop = emac_dev_stop,
+ .ndo_start_xmit = emac_dev_xmit,
+ .ndo_set_multicast_list = emac_dev_mcast_set,
+ .ndo_set_mac_address = emac_dev_setmac_addr,
+ .ndo_do_ioctl = emac_devioctl,
+ .ndo_tx_timeout = emac_dev_tx_timeout,
+ .ndo_get_stats = emac_dev_getnetstats,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = emac_poll_controller,
+#endif
+};
+
+/**
+ * davinci_emac_probe: EMAC device probe
+ * @pdev: The DaVinci EMAC device that we are removing
+ *
+ * Called when probing for emac devicesr. We get details of instances and
+ * resource information from platform init and register a network device
+ * and allocate resources necessary for driver to perform
+ */
+static int __devinit davinci_emac_probe(struct platform_device *pdev)
+{
+ int rc = 0;
+ struct resource *res;
+ struct net_device *ndev;
+ struct emac_priv *priv;
+ unsigned long size;
+ struct emac_platform_data *pdata;
+ struct device *emac_dev;
+
+ /* obtain emac clock from kernel */
+ emac_clk = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(emac_clk)) {
+ printk(KERN_ERR "DaVinci EMAC: Failed to get EMAC clock\n");
+ return -EBUSY;
+ }
+ emac_bus_frequency = clk_get_rate(emac_clk);
+ /* TODO: Probe PHY here if possible */
+
+ ndev = alloc_etherdev(sizeof(struct emac_priv));
+ if (!ndev) {
+ printk(KERN_ERR "DaVinci EMAC: Error allocating net_device\n");
+ clk_put(emac_clk);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, ndev);
+ priv = netdev_priv(ndev);
+ priv->pdev = pdev;
+ priv->ndev = ndev;
+ priv->msg_enable = netif_msg_init(debug_level, DAVINCI_EMAC_DEBUG);
+
+ spin_lock_init(&priv->tx_lock);
+ spin_lock_init(&priv->rx_lock);
+ spin_lock_init(&priv->lock);
+
+ pdata = pdev->dev.platform_data;
+ if (!pdata) {
+ printk(KERN_ERR "DaVinci EMAC: No platfrom data\n");
+ return -ENODEV;
+ }
+
+ /* MAC addr and PHY mask , RMII enable info from platform_data */
+ memcpy(priv->mac_addr, pdata->mac_addr, 6);
+ priv->phy_mask = pdata->phy_mask;
+ priv->rmii_en = pdata->rmii_en;
+ priv->version = pdata->version;
+ emac_dev = &ndev->dev;
+ /* Get EMAC platform data */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(emac_dev, "DaVinci EMAC: Error getting res\n");
+ rc = -ENOENT;
+ goto probe_quit;
+ }
+
+ priv->emac_base_phys = res->start + pdata->ctrl_reg_offset;
+ size = res->end - res->start + 1;
+ if (!request_mem_region(res->start, size, ndev->name)) {
+ dev_err(emac_dev, "DaVinci EMAC: failed request_mem_region() \
+ for regs\n");
+ rc = -ENXIO;
+ goto probe_quit;
+ }
+
+ priv->remap_addr = ioremap(res->start, size);
+ if (!priv->remap_addr) {
+ dev_err(emac_dev, "Unable to map IO\n");
+ rc = -ENOMEM;
+ release_mem_region(res->start, size);
+ goto probe_quit;
+ }
+ priv->emac_base = priv->remap_addr + pdata->ctrl_reg_offset;
+ ndev->base_addr = (unsigned long)priv->remap_addr;
+
+ priv->ctrl_base = priv->remap_addr + pdata->ctrl_mod_reg_offset;
+ priv->ctrl_ram_size = pdata->ctrl_ram_size;
+ priv->emac_ctrl_ram = priv->remap_addr + pdata->ctrl_ram_offset;
+
+ res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (!res) {
+ dev_err(emac_dev, "DaVinci EMAC: Error getting irq res\n");
+ rc = -ENOENT;
+ goto no_irq_res;
+ }
+ ndev->irq = res->start;
+
+ if (!is_valid_ether_addr(priv->mac_addr)) {
+ DECLARE_MAC_BUF(buf);
+ /* Use random MAC if none passed */
+ random_ether_addr(priv->mac_addr);
+ printk(KERN_WARNING "%s: using random MAC addr: %s\n",
+ __func__, print_mac(buf, priv->mac_addr));
+ }
+
+ ndev->netdev_ops = &emac_netdev_ops;
+ SET_ETHTOOL_OPS(ndev, &ethtool_ops);
+ netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
+
+ /* register the network device */
+ SET_NETDEV_DEV(ndev, &pdev->dev);
+ rc = register_netdev(ndev);
+ if (rc) {
+ dev_err(emac_dev, "DaVinci EMAC: Error in register_netdev\n");
+ rc = -ENODEV;
+ goto netdev_reg_err;
+ }
+
+ clk_enable(emac_clk);
+
+ /* MII/Phy intialisation, mdio bus registration */
+ emac_mii = mdiobus_alloc();
+ if (emac_mii == NULL) {
+ dev_err(emac_dev, "DaVinci EMAC: Error allocating mii_bus\n");
+ rc = -ENOMEM;
+ goto mdio_alloc_err;
+ }
+
+ priv->mii_bus = emac_mii;
+ emac_mii->name = "emac-mii",
+ emac_mii->read = emac_mii_read,
+ emac_mii->write = emac_mii_write,
+ emac_mii->reset = emac_mii_reset,
+ emac_mii->irq = mii_irqs,
+ emac_mii->phy_mask = ~(priv->phy_mask);
+ emac_mii->parent = &pdev->dev;
+ emac_mii->priv = priv->remap_addr + pdata->mdio_reg_offset;
+ snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%x", priv->pdev->id);
+ mdio_max_freq = pdata->mdio_max_freq;
+ emac_mii->reset(emac_mii);
+
+ /* Register the MII bus */
+ rc = mdiobus_register(emac_mii);
+ if (rc)
+ goto mdiobus_quit;
+
+ if (netif_msg_probe(priv)) {
+ dev_notice(emac_dev, "DaVinci EMAC Probe found device "\
+ "(regs: %p, irq: %d)\n",
+ (void *)priv->emac_base_phys, ndev->irq);
+ }
+ return 0;
+
+mdiobus_quit:
+ mdiobus_free(emac_mii);
+
+netdev_reg_err:
+mdio_alloc_err:
+no_irq_res:
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ release_mem_region(res->start, res->end - res->start + 1);
+ iounmap(priv->remap_addr);
+
+probe_quit:
+ clk_put(emac_clk);
+ free_netdev(ndev);
+ return rc;
+}
+
+/**
+ * davinci_emac_remove: EMAC device remove
+ * @pdev: The DaVinci EMAC device that we are removing
+ *
+ * Called when removing the device driver. We disable clock usage and release
+ * the resources taken up by the driver and unregister network device
+ */
+static int __devexit davinci_emac_remove(struct platform_device *pdev)
+{
+ struct resource *res;
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ struct emac_priv *priv = netdev_priv(ndev);
+
+ dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n");
+
+ clk_disable(emac_clk);
+ platform_set_drvdata(pdev, NULL);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ mdiobus_unregister(priv->mii_bus);
+ mdiobus_free(priv->mii_bus);
+
+ release_mem_region(res->start, res->end - res->start + 1);
+
+ unregister_netdev(ndev);
+ free_netdev(ndev);
+ iounmap(priv->remap_addr);
+
+ clk_disable(emac_clk);
+ clk_put(emac_clk);
+
+ return 0;
+}
+
+/**
+ * davinci_emac_driver: EMAC platform driver structure
+ *
+ * We implement only probe and remove functions - suspend/resume and
+ * others not supported by this module
+ */
+static struct platform_driver davinci_emac_driver = {
+ .driver = {
+ .name = "davinci_emac",
+ .owner = THIS_MODULE,
+ },
+ .probe = davinci_emac_probe,
+ .remove = __devexit_p(davinci_emac_remove),
+};
+
+/**
+ * davinci_emac_init: EMAC driver module init
+ *
+ * Called when initializing the driver. We register the driver with
+ * the platform.
+ */
+static int __init davinci_emac_init(void)
+{
+ return platform_driver_register(&davinci_emac_driver);
+}
+module_init(davinci_emac_init);
+
+/**
+ * davinci_emac_exit: EMAC driver module exit
+ *
+ * Called when exiting the driver completely. We unregister the driver with
+ * the platform and exit
+ */
+static void __exit davinci_emac_exit(void)
+{
+ platform_driver_unregister(&davinci_emac_driver);
+}
+module_exit(davinci_emac_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("DaVinci EMAC Maintainer: Anant Gole <anantgole@ti.com>");
+MODULE_AUTHOR("DaVinci EMAC Maintainer: Chaithrika U S <chaithrika@ti.com>");
+MODULE_DESCRIPTION("DaVinci EMAC Ethernet driver");
diff --git a/drivers/net/de600.c b/drivers/net/de600.c
index de63f1d41d32..c866ca99a068 100644
--- a/drivers/net/de600.c
+++ b/drivers/net/de600.c
@@ -38,14 +38,6 @@ static const char version[] = "de600.c: $Revision: 1.41-2.5 $, Bjorn Ekwall (bj
/* Add more time here if your adapter won't work OK: */
#define DE600_SLOW_DOWN udelay(delay_time)
-/* use 0 for production, 1 for verification, >2 for debug */
-#ifdef DE600_DEBUG
-#define PRINTK(x) if (de600_debug >= 2) printk x
-#else
-#define DE600_DEBUG 0
-#define PRINTK(x) /**/
-#endif
-
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
@@ -67,10 +59,6 @@ static const char version[] = "de600.c: $Revision: 1.41-2.5 $, Bjorn Ekwall (bj
#include "de600.h"
-static unsigned int de600_debug = DE600_DEBUG;
-module_param(de600_debug, int, 0);
-MODULE_PARM_DESC(de600_debug, "DE-600 debug level (0-2)");
-
static unsigned int check_lost = 1;
module_param(check_lost, bool, 0);
MODULE_PARM_DESC(check_lost, "If set then check for unplugged de600");
@@ -193,7 +181,7 @@ static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev)
}
/* Start real output */
- PRINTK(("de600_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages));
+ pr_debug("de600_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages);
if ((len = skb->len) < RUNT)
len = RUNT;
@@ -259,7 +247,7 @@ static irqreturn_t de600_interrupt(int irq, void *dev_id)
irq_status = de600_read_status(dev);
do {
- PRINTK(("de600_interrupt (%02X)\n", irq_status));
+ pr_debug("de600_interrupt (%02X)\n", irq_status);
if (irq_status & RX_GOOD)
de600_rx_intr(dev);
@@ -407,8 +395,7 @@ static struct net_device * __init de600_probe(void)
printk(KERN_INFO "%s: D-Link DE-600 pocket adapter", dev->name);
/* Alpha testers must have the version number to report bugs. */
- if (de600_debug > 1)
- printk(version);
+ pr_debug("%s", version);
/* probe for adapter */
err = -ENODEV;
diff --git a/drivers/net/de620.c b/drivers/net/de620.c
index d52f34cc9526..039bc1acadd3 100644
--- a/drivers/net/de620.c
+++ b/drivers/net/de620.c
@@ -48,7 +48,6 @@ static const char version[] =
* Compile-time options: (see below for descriptions)
* -DDE620_IO=0x378 (lpt1)
* -DDE620_IRQ=7 (lpt1)
- * -DDE602_DEBUG=...
* -DSHUTDOWN_WHEN_LOST
* -DCOUNT_LOOPS
* -DLOWSPEED
@@ -98,15 +97,6 @@ static const char version[] =
#define SHUTDOWN_WHEN_LOST
*/
-/*
- * Enable debugging by "-DDE620_DEBUG=3" when compiling,
- * OR by enabling the following #define
- *
- * use 0 for production, 1 for verification, >2 for debug
- *
-#define DE620_DEBUG 3
- */
-
#ifdef LOWSPEED
/*
* Enable this #define if you want to see debugging output that show how long
@@ -160,14 +150,6 @@ typedef unsigned char byte;
#define RUNT 60 /* Too small Ethernet packet */
#define GIANT 1514 /* largest legal size packet, no fcs */
-#ifdef DE620_DEBUG /* Compile-time configurable */
-#define PRINTK(x) if (de620_debug >= 2) printk x
-#else
-#define DE620_DEBUG 0
-#define PRINTK(x) /**/
-#endif
-
-
/*
* Force media with insmod:
* insmod de620.o bnc=1
@@ -186,8 +168,6 @@ static int io = DE620_IO;
static int irq = DE620_IRQ;
static int clone = DE620_CLONE;
-static unsigned int de620_debug = DE620_DEBUG;
-
static spinlock_t de620_lock;
module_param(bnc, int, 0);
@@ -195,13 +175,11 @@ module_param(utp, int, 0);
module_param(io, int, 0);
module_param(irq, int, 0);
module_param(clone, int, 0);
-module_param(de620_debug, int, 0);
MODULE_PARM_DESC(bnc, "DE-620 set BNC medium (0-1)");
MODULE_PARM_DESC(utp, "DE-620 set UTP medium (0-1)");
MODULE_PARM_DESC(io, "DE-620 I/O base address,required");
MODULE_PARM_DESC(irq, "DE-620 IRQ number,required");
MODULE_PARM_DESC(clone, "Check also for non-D-Link DE-620 clones (0-1)");
-MODULE_PARM_DESC(de620_debug, "DE-620 debug level (0-2)");
/***********************************************
* *
@@ -533,9 +511,9 @@ static int de620_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Start real output */
- spin_lock_irqsave(&de620_lock, flags)
- PRINTK(("de620_start_xmit: len=%d, bufs 0x%02x\n",
- (int)skb->len, using_txbuf));
+ spin_lock_irqsave(&de620_lock, flags);
+ pr_debug("de620_start_xmit: len=%d, bufs 0x%02x\n",
+ (int)skb->len, using_txbuf);
/* select a free tx buffer. if there is one... */
switch (using_txbuf) {
@@ -585,12 +563,12 @@ de620_interrupt(int irq_in, void *dev_id)
/* Read the status register (_not_ the status port) */
irq_status = de620_get_register(dev, R_STS);
- PRINTK(("de620_interrupt (%2.2X)\n", irq_status));
+ pr_debug("de620_interrupt (%2.2X)\n", irq_status);
if (irq_status & RXGOOD) {
do {
again = de620_rx_intr(dev);
- PRINTK(("again=%d\n", again));
+ pr_debug("again=%d\n", again);
}
while (again && (++bogus_count < 100));
}
@@ -622,7 +600,7 @@ static int de620_rx_intr(struct net_device *dev)
byte pagelink;
byte curr_page;
- PRINTK(("de620_rx_intr: next_rx_page = %d\n", next_rx_page));
+ pr_debug("de620_rx_intr: next_rx_page = %d\n", next_rx_page);
/* Tell the adapter that we are going to read data, and from where */
de620_send_command(dev, W_CR | RRN);
@@ -631,8 +609,9 @@ static int de620_rx_intr(struct net_device *dev)
/* Deep breath, and away we goooooo */
de620_read_block(dev, (byte *)&header_buf, sizeof(struct header_buf));
- PRINTK(("page status=0x%02x, nextpage=%d, packetsize=%d\n",
- header_buf.status, header_buf.Rx_NextPage, header_buf.Rx_ByteCount));
+ pr_debug("page status=0x%02x, nextpage=%d, packetsize=%d\n",
+ header_buf.status, header_buf.Rx_NextPage,
+ header_buf.Rx_ByteCount);
/* Plausible page header? */
pagelink = header_buf.Rx_NextPage;
@@ -683,7 +662,7 @@ static int de620_rx_intr(struct net_device *dev)
buffer = skb_put(skb,size);
/* copy the packet into the buffer */
de620_read_block(dev, buffer, size);
- PRINTK(("Read %d bytes\n", size));
+ pr_debug("Read %d bytes\n", size);
skb->protocol=eth_type_trans(skb,dev);
netif_rx(skb); /* deliver it "upstairs" */
/* count all receives */
@@ -696,7 +675,7 @@ static int de620_rx_intr(struct net_device *dev)
/* NOTE! We're _not_ checking the 'EMPTY'-flag! This seems better... */
curr_page = de620_get_register(dev, R_CPR);
de620_set_register(dev, W_NPRF, next_rx_page);
- PRINTK(("next_rx_page=%d CPR=%d\n", next_rx_page, curr_page));
+ pr_debug("next_rx_page=%d CPR=%d\n", next_rx_page, curr_page);
return (next_rx_page != curr_page); /* That was slightly tricky... */
}
@@ -830,8 +809,7 @@ struct net_device * __init de620_probe(int unit)
netdev_boot_setup_check(dev);
}
- if (de620_debug)
- printk(version);
+ pr_debug("%s", version);
printk(KERN_INFO "D-Link DE-620 pocket adapter");
@@ -878,14 +856,13 @@ struct net_device * __init de620_probe(int unit)
/* base_addr and irq are already set, see above! */
/* dump eeprom */
- if (de620_debug) {
- printk("\nEEPROM contents:\n");
- printk("RAM_Size = 0x%02X\n", nic_data.RAM_Size);
- printk("NodeID = %pM\n", nic_data.NodeID);
- printk("Model = %d\n", nic_data.Model);
- printk("Media = %d\n", nic_data.Media);
- printk("SCR = 0x%02x\n", nic_data.SCR);
- }
+ pr_debug("\nEEPROM contents:\n"
+ "RAM_Size = 0x%02X\n"
+ "NodeID = %pM\n"
+ "Model = %d\n"
+ "Media = %d\n"
+ "SCR = 0x%02x\n", nic_data.RAM_Size, nic_data.NodeID,
+ nic_data.Model, nic_data.Media, nic_data.SCR);
err = register_netdev(dev);
if (err)
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 357f565851ed..9301eb28d9e2 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -810,7 +810,7 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
dev->mem_start = 0;
- device->driver_data = dev;
+ dev_set_drvdata(device, dev);
SET_NETDEV_DEV (dev, device);
status = register_netdev(dev);
@@ -1614,7 +1614,7 @@ static int __devexit depca_device_remove (struct device *device)
struct depca_private *lp;
int bus;
- dev = device->driver_data;
+ dev = dev_get_drvdata(device);
lp = netdev_priv(dev);
unregister_netdev (dev);
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index d8350860c0f8..e402e91bf188 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -1170,6 +1170,21 @@ dm9000_stop(struct net_device *ndev)
return 0;
}
+static const struct net_device_ops dm9000_netdev_ops = {
+ .ndo_open = dm9000_open,
+ .ndo_stop = dm9000_stop,
+ .ndo_start_xmit = dm9000_start_xmit,
+ .ndo_tx_timeout = dm9000_timeout,
+ .ndo_set_multicast_list = dm9000_hash_table,
+ .ndo_do_ioctl = dm9000_ioctl,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = dm9000_poll_controller,
+#endif
+};
+
#define res_size(_r) (((_r)->end - (_r)->start) + 1)
/*
@@ -1339,18 +1354,9 @@ dm9000_probe(struct platform_device *pdev)
/* driver system function */
ether_setup(ndev);
- ndev->open = &dm9000_open;
- ndev->hard_start_xmit = &dm9000_start_xmit;
- ndev->tx_timeout = &dm9000_timeout;
- ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
- ndev->stop = &dm9000_stop;
- ndev->set_multicast_list = &dm9000_hash_table;
- ndev->ethtool_ops = &dm9000_ethtool_ops;
- ndev->do_ioctl = &dm9000_ioctl;
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- ndev->poll_controller = &dm9000_poll_controller;
-#endif
+ ndev->netdev_ops = &dm9000_netdev_ops;
+ ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
+ ndev->ethtool_ops = &dm9000_ethtool_ops;
db->msg_enable = NETIF_MSG_LINK;
db->mii.phy_id_mask = 0x1f;
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 0f9ee1348552..af5364f49550 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2785,7 +2785,7 @@ static int e100_resume(struct pci_dev *pdev)
/* ack any pending wake events, disable PME */
pci_enable_wake(pdev, 0, 0);
- /* disbale reverse auto-negotiation */
+ /* disable reverse auto-negotiation */
if (nic->phy == phy_82552_v) {
u16 smartspeed = mdio_read(netdev, nic->mii.phy_id,
E100_82552_SMARTSPEED);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index b1419e21b46b..9a32d0c73cb3 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -498,6 +498,8 @@ int e1000_up(struct e1000_adapter *adapter)
e1000_irq_enable(adapter);
+ netif_wake_queue(adapter->netdev);
+
/* fire a link change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
return 0;
@@ -1234,15 +1236,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
!e1000_check_mng_mode(hw))
e1000_get_hw_control(adapter);
- /* tell the stack to leave us alone until e1000_open() is called */
- netif_carrier_off(netdev);
- netif_stop_queue(netdev);
-
strcpy(netdev->name, "eth%d");
err = register_netdev(netdev);
if (err)
goto err_register;
+ /* carrier off reporting is important to ethtool even BEFORE open */
+ netif_carrier_off(netdev);
+
DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
cards_found++;
@@ -1441,6 +1442,8 @@ static int e1000_open(struct net_device *netdev)
if (test_bit(__E1000_TESTING, &adapter->flags))
return -EBUSY;
+ netif_carrier_off(netdev);
+
/* allocate transmit descriptors */
err = e1000_setup_all_tx_resources(adapter);
if (err)
@@ -2590,7 +2593,6 @@ static void e1000_watchdog(unsigned long data)
ew32(TCTL, tctl);
netif_carrier_on(netdev);
- netif_wake_queue(netdev);
mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
adapter->smartspeed = 0;
} else {
@@ -2607,7 +2609,6 @@ static void e1000_watchdog(unsigned long data)
printk(KERN_INFO "e1000: %s NIC Link is Down\n",
netdev->name);
netif_carrier_off(netdev);
- netif_stop_queue(netdev);
mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
/* 80003ES2LAN workaround--
@@ -2645,6 +2646,8 @@ static void e1000_watchdog(unsigned long data)
* (Do the reset outside of interrupt context). */
adapter->tx_timeout_count++;
schedule_work(&adapter->reset_task);
+ /* return immediately since reset is imminent */
+ return;
}
}
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index f37360aa12a8..44f0bf23dafc 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -62,7 +62,7 @@ struct e1000_info;
e_printk(KERN_NOTICE, adapter, format, ## arg)
-/* Interrupt modes, as used by the IntMode paramter */
+/* Interrupt modes, as used by the IntMode parameter */
#define E1000E_INT_MODE_LEGACY 0
#define E1000E_INT_MODE_MSI 1
#define E1000E_INT_MODE_MSIX 2
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index ca82f19a7ed1..ccaaee0951cf 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2826,6 +2826,8 @@ int e1000e_up(struct e1000_adapter *adapter)
e1000_configure_msix(adapter);
e1000_irq_enable(adapter);
+ netif_wake_queue(adapter->netdev);
+
/* fire a link change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
return 0;
@@ -2848,7 +2850,7 @@ void e1000e_down(struct e1000_adapter *adapter)
ew32(RCTL, rctl & ~E1000_RCTL_EN);
/* flush and sleep below */
- netif_tx_stop_all_queues(netdev);
+ netif_stop_queue(netdev);
/* disable transmits in the hardware */
tctl = er32(TCTL);
@@ -3072,6 +3074,8 @@ static int e1000_open(struct net_device *netdev)
if (test_bit(__E1000_TESTING, &adapter->state))
return -EBUSY;
+ netif_carrier_off(netdev);
+
/* allocate transmit descriptors */
err = e1000e_setup_tx_resources(adapter);
if (err)
@@ -3128,7 +3132,7 @@ static int e1000_open(struct net_device *netdev)
e1000_irq_enable(adapter);
- netif_tx_start_all_queues(netdev);
+ netif_start_queue(netdev);
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
@@ -3598,7 +3602,6 @@ static void e1000_watchdog_task(struct work_struct *work)
phy->ops.cfg_on_link_up(hw);
netif_carrier_on(netdev);
- netif_tx_wake_all_queues(netdev);
if (!test_bit(__E1000_DOWN, &adapter->state))
mod_timer(&adapter->phy_info_timer,
@@ -3612,7 +3615,6 @@ static void e1000_watchdog_task(struct work_struct *work)
printk(KERN_INFO "e1000e: %s NIC Link is Down\n",
adapter->netdev->name);
netif_carrier_off(netdev);
- netif_tx_stop_all_queues(netdev);
if (!test_bit(__E1000_DOWN, &adapter->state))
mod_timer(&adapter->phy_info_timer,
round_jiffies(jiffies + 2 * HZ));
@@ -3649,6 +3651,8 @@ link_up:
*/
adapter->tx_timeout_count++;
schedule_work(&adapter->reset_task);
+ /* return immediately since reset is imminent */
+ return;
}
}
@@ -5037,15 +5041,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
if (!(adapter->flags & FLAG_HAS_AMT))
e1000_get_hw_control(adapter);
- /* tell the stack to leave us alone until e1000_open() is called */
- netif_carrier_off(netdev);
- netif_tx_stop_all_queues(netdev);
-
strcpy(netdev->name, "eth%d");
err = register_netdev(netdev);
if (err)
goto err_register;
+ /* carrier off reporting is important to ethtool even BEFORE open */
+ netif_carrier_off(netdev);
+
e1000_print_device_info(adapter);
return 0;
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 16a41389575a..78952f8324e2 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -268,7 +268,7 @@ struct ehea_qp_init_attr {
};
/*
- * Event Queue attributes, passed as paramter
+ * Event Queue attributes, passed as parameter
*/
struct ehea_eq_attr {
u32 type;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index b22dab9153f6..147c4b088fb3 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -3261,7 +3261,7 @@ static ssize_t ehea_probe_port(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ehea_adapter *adapter = dev->driver_data;
+ struct ehea_adapter *adapter = dev_get_drvdata(dev);
struct ehea_port *port;
struct device_node *eth_dn = NULL;
int i;
@@ -3316,7 +3316,7 @@ static ssize_t ehea_remove_port(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ehea_adapter *adapter = dev->driver_data;
+ struct ehea_adapter *adapter = dev_get_drvdata(dev);
struct ehea_port *port;
int i;
u32 logical_port_id;
@@ -3404,7 +3404,7 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
adapter->pd = EHEA_PD_ID;
- dev->dev.driver_data = adapter;
+ dev_set_drvdata(&dev->dev, adapter);
/* initialize adapter and ports */
@@ -3468,7 +3468,7 @@ out:
static int __devexit ehea_remove(struct of_device *dev)
{
- struct ehea_adapter *adapter = dev->dev.driver_data;
+ struct ehea_adapter *adapter = dev_get_drvdata(&dev->dev);
int i;
for (i = 0; i < EHEA_MAX_PORTS; i++)
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index 5210bb1027cc..19b7dd983944 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -194,6 +194,7 @@ static void __init eql_setup(struct net_device *dev)
dev->type = ARPHRD_SLIP;
dev->tx_queue_len = 5; /* Hands them off fast */
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
}
static int eql_open(struct net_device *dev)
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 682e7f0b5581..28db6919c526 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -86,8 +86,7 @@ static unsigned char fec_mac_default[] = {
#endif
#endif /* CONFIG_M5272 */
-/* Forward declarations of some structures to support different PHYs
-*/
+/* Forward declarations of some structures to support different PHYs */
typedef struct {
uint mii_data;
@@ -123,8 +122,7 @@ typedef struct {
#error "FEC: descriptor ring size constants too large"
#endif
-/* Interrupt events/masks.
-*/
+/* Interrupt events/masks. */
#define FEC_ENET_HBERR ((uint)0x80000000) /* Heartbeat error */
#define FEC_ENET_BABR ((uint)0x40000000) /* Babbling receiver */
#define FEC_ENET_BABT ((uint)0x20000000) /* Babbling transmitter */
@@ -165,7 +163,7 @@ typedef struct {
*/
struct fec_enet_private {
/* Hardware registers of the FEC device */
- volatile fec_t *hwp;
+ void __iomem *hwp;
struct net_device *netdev;
@@ -174,16 +172,20 @@ struct fec_enet_private {
/* The saved address of a sent-in-place packet/buffer, for skfree(). */
unsigned char *tx_bounce[TX_RING_SIZE];
struct sk_buff* tx_skbuff[TX_RING_SIZE];
+ struct sk_buff* rx_skbuff[RX_RING_SIZE];
ushort skb_cur;
ushort skb_dirty;
- /* CPM dual port RAM relative addresses.
- */
+ /* CPM dual port RAM relative addresses */
dma_addr_t bd_dma;
- cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */
- cbd_t *tx_bd_base;
- cbd_t *cur_rx, *cur_tx; /* The next free ring entry */
- cbd_t *dirty_tx; /* The ring entries to be free()ed. */
+ /* Address of Rx and Tx buffers */
+ struct bufdesc *rx_bd_base;
+ struct bufdesc *tx_bd_base;
+ /* The next free ring entry */
+ struct bufdesc *cur_rx, *cur_tx;
+ /* The ring entries to be free()ed */
+ struct bufdesc *dirty_tx;
+
uint tx_full;
/* hold while accessing the HW like ringbuffer for tx/rx but not MAC */
spinlock_t hw_lock;
@@ -209,17 +211,13 @@ struct fec_enet_private {
int full_duplex;
};
-static int fec_enet_open(struct net_device *dev);
-static int fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev);
static void fec_enet_mii(struct net_device *dev);
static irqreturn_t fec_enet_interrupt(int irq, void * dev_id);
static void fec_enet_tx(struct net_device *dev);
static void fec_enet_rx(struct net_device *dev);
static int fec_enet_close(struct net_device *dev);
-static void set_multicast_list(struct net_device *dev);
static void fec_restart(struct net_device *dev, int duplex);
static void fec_stop(struct net_device *dev);
-static void fec_set_mac_address(struct net_device *dev);
/* MII processing. We keep this as simple as possible. Requests are
@@ -241,19 +239,16 @@ static mii_list_t *mii_tail;
static int mii_queue(struct net_device *dev, int request,
void (*func)(uint, struct net_device *));
-/* Make MII read/write commands for the FEC.
-*/
+/* Make MII read/write commands for the FEC */
#define mk_mii_read(REG) (0x60020000 | ((REG & 0x1f) << 18))
#define mk_mii_write(REG, VAL) (0x50020000 | ((REG & 0x1f) << 18) | \
(VAL & 0xffff))
#define mk_mii_end 0
-/* Transmitter timeout.
-*/
-#define TX_TIMEOUT (2*HZ)
+/* Transmitter timeout */
+#define TX_TIMEOUT (2 * HZ)
-/* Register definitions for the PHY.
-*/
+/* Register definitions for the PHY */
#define MII_REG_CR 0 /* Control Register */
#define MII_REG_SR 1 /* Status Register */
@@ -288,15 +283,11 @@ static int mii_queue(struct net_device *dev, int request,
static int
fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct fec_enet_private *fep;
- volatile fec_t *fecp;
- volatile cbd_t *bdp;
+ struct fec_enet_private *fep = netdev_priv(dev);
+ struct bufdesc *bdp;
unsigned short status;
unsigned long flags;
- fep = netdev_priv(dev);
- fecp = (volatile fec_t*)dev->base_addr;
-
if (!fep->link) {
/* Link is down or autonegotiation is in progress. */
return 1;
@@ -307,7 +298,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
bdp = fep->cur_tx;
status = bdp->cbd_sc;
-#ifndef final_version
+
if (status & BD_ENET_TX_READY) {
/* Ooops. All transmit buffers are full. Bail out.
* This should not happen, since dev->tbusy should be set.
@@ -316,21 +307,18 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
spin_unlock_irqrestore(&fep->hw_lock, flags);
return 1;
}
-#endif
- /* Clear all of the status flags.
- */
+ /* Clear all of the status flags */
status &= ~BD_ENET_TX_STATS;
- /* Set buffer length and buffer pointer.
- */
+ /* Set buffer length and buffer pointer */
bdp->cbd_bufaddr = __pa(skb->data);
bdp->cbd_datlen = skb->len;
/*
- * On some FEC implementations data must be aligned on
- * 4-byte boundaries. Use bounce buffers to copy data
- * and get it aligned. Ugh.
+ * On some FEC implementations data must be aligned on
+ * 4-byte boundaries. Use bounce buffers to copy data
+ * and get it aligned. Ugh.
*/
if (bdp->cbd_bufaddr & FEC_ALIGNMENT) {
unsigned int index;
@@ -339,8 +327,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
bdp->cbd_bufaddr = __pa(fep->tx_bounce[index]);
}
- /* Save skb pointer.
- */
+ /* Save skb pointer */
fep->tx_skbuff[fep->skb_cur] = skb;
dev->stats.tx_bytes += skb->len;
@@ -349,13 +336,12 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Push the data cache so the CPM does not get stale memory
* data.
*/
- dma_sync_single(NULL, bdp->cbd_bufaddr,
- bdp->cbd_datlen, DMA_TO_DEVICE);
+ bdp->cbd_bufaddr = dma_map_single(&dev->dev, skb->data,
+ FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
/* Send it on its way. Tell FEC it's ready, interrupt when done,
* it's the last BD of the frame, and to put the CRC on the end.
*/
-
status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
| BD_ENET_TX_LAST | BD_ENET_TX_TC);
bdp->cbd_sc = status;
@@ -363,22 +349,20 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies;
/* Trigger transmission start */
- fecp->fec_x_des_active = 0;
+ writel(0, fep->hwp + FEC_X_DES_ACTIVE);
- /* If this was the last BD in the ring, start at the beginning again.
- */
- if (status & BD_ENET_TX_WRAP) {
+ /* If this was the last BD in the ring, start at the beginning again. */
+ if (status & BD_ENET_TX_WRAP)
bdp = fep->tx_bd_base;
- } else {
+ else
bdp++;
- }
if (bdp == fep->dirty_tx) {
fep->tx_full = 1;
netif_stop_queue(dev);
}
- fep->cur_tx = (cbd_t *)bdp;
+ fep->cur_tx = bdp;
spin_unlock_irqrestore(&fep->hw_lock, flags);
@@ -390,75 +374,33 @@ fec_timeout(struct net_device *dev)
{
struct fec_enet_private *fep = netdev_priv(dev);
- printk("%s: transmit timed out.\n", dev->name);
dev->stats.tx_errors++;
-#ifndef final_version
- {
- int i;
- cbd_t *bdp;
-
- printk("Ring data dump: cur_tx %lx%s, dirty_tx %lx cur_rx: %lx\n",
- (unsigned long)fep->cur_tx, fep->tx_full ? " (full)" : "",
- (unsigned long)fep->dirty_tx,
- (unsigned long)fep->cur_rx);
-
- bdp = fep->tx_bd_base;
- printk(" tx: %u buffers\n", TX_RING_SIZE);
- for (i = 0 ; i < TX_RING_SIZE; i++) {
- printk(" %08x: %04x %04x %08x\n",
- (uint) bdp,
- bdp->cbd_sc,
- bdp->cbd_datlen,
- (int) bdp->cbd_bufaddr);
- bdp++;
- }
- bdp = fep->rx_bd_base;
- printk(" rx: %lu buffers\n", (unsigned long) RX_RING_SIZE);
- for (i = 0 ; i < RX_RING_SIZE; i++) {
- printk(" %08x: %04x %04x %08x\n",
- (uint) bdp,
- bdp->cbd_sc,
- bdp->cbd_datlen,
- (int) bdp->cbd_bufaddr);
- bdp++;
- }
- }
-#endif
fec_restart(dev, fep->full_duplex);
netif_wake_queue(dev);
}
-/* The interrupt handler.
- * This is called from the MPC core interrupt.
- */
static irqreturn_t
fec_enet_interrupt(int irq, void * dev_id)
{
struct net_device *dev = dev_id;
- volatile fec_t *fecp;
+ struct fec_enet_private *fep = netdev_priv(dev);
uint int_events;
irqreturn_t ret = IRQ_NONE;
- fecp = (volatile fec_t*)dev->base_addr;
-
- /* Get the interrupt events that caused us to be here.
- */
do {
- int_events = fecp->fec_ievent;
- fecp->fec_ievent = int_events;
+ int_events = readl(fep->hwp + FEC_IEVENT);
+ writel(int_events, fep->hwp + FEC_IEVENT);
- /* Handle receive event in its own function.
- */
if (int_events & FEC_ENET_RXF) {
ret = IRQ_HANDLED;
fec_enet_rx(dev);
}
/* Transmit OK, or non-fatal error. Update the buffer
- descriptors. FEC handles all errors, we just discover
- them as part of the transmit process.
- */
+ * descriptors. FEC handles all errors, we just discover
+ * them as part of the transmit process.
+ */
if (int_events & FEC_ENET_TXF) {
ret = IRQ_HANDLED;
fec_enet_tx(dev);
@@ -479,7 +421,7 @@ static void
fec_enet_tx(struct net_device *dev)
{
struct fec_enet_private *fep;
- volatile cbd_t *bdp;
+ struct bufdesc *bdp;
unsigned short status;
struct sk_buff *skb;
@@ -488,7 +430,11 @@ fec_enet_tx(struct net_device *dev)
bdp = fep->dirty_tx;
while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
- if (bdp == fep->cur_tx && fep->tx_full == 0) break;
+ if (bdp == fep->cur_tx && fep->tx_full == 0)
+ break;
+
+ dma_unmap_single(&dev->dev, bdp->cbd_bufaddr, FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
+ bdp->cbd_bufaddr = 0;
skb = fep->tx_skbuff[fep->skb_dirty];
/* Check for errors. */
@@ -510,31 +456,27 @@ fec_enet_tx(struct net_device *dev)
dev->stats.tx_packets++;
}
-#ifndef final_version
if (status & BD_ENET_TX_READY)
printk("HEY! Enet xmit interrupt and TX_READY.\n");
-#endif
+
/* Deferred means some collisions occurred during transmit,
* but we eventually sent the packet OK.
*/
if (status & BD_ENET_TX_DEF)
dev->stats.collisions++;
- /* Free the sk buffer associated with this last transmit.
- */
+ /* Free the sk buffer associated with this last transmit */
dev_kfree_skb_any(skb);
fep->tx_skbuff[fep->skb_dirty] = NULL;
fep->skb_dirty = (fep->skb_dirty + 1) & TX_RING_MOD_MASK;
- /* Update pointer to next buffer descriptor to be transmitted.
- */
+ /* Update pointer to next buffer descriptor to be transmitted */
if (status & BD_ENET_TX_WRAP)
bdp = fep->tx_bd_base;
else
bdp++;
- /* Since we have freed up a buffer, the ring is no longer
- * full.
+ /* Since we have freed up a buffer, the ring is no longer full
*/
if (fep->tx_full) {
fep->tx_full = 0;
@@ -542,7 +484,7 @@ fec_enet_tx(struct net_device *dev)
netif_wake_queue(dev);
}
}
- fep->dirty_tx = (cbd_t *)bdp;
+ fep->dirty_tx = bdp;
spin_unlock_irq(&fep->hw_lock);
}
@@ -555,9 +497,8 @@ fec_enet_tx(struct net_device *dev)
static void
fec_enet_rx(struct net_device *dev)
{
- struct fec_enet_private *fep;
- volatile fec_t *fecp;
- volatile cbd_t *bdp;
+ struct fec_enet_private *fep = netdev_priv(dev);
+ struct bufdesc *bdp;
unsigned short status;
struct sk_buff *skb;
ushort pkt_len;
@@ -567,9 +508,6 @@ fec_enet_rx(struct net_device *dev)
flush_cache_all();
#endif
- fep = netdev_priv(dev);
- fecp = (volatile fec_t*)dev->base_addr;
-
spin_lock_irq(&fep->hw_lock);
/* First, grab all of the stats for the incoming packet.
@@ -577,143 +515,121 @@ fec_enet_rx(struct net_device *dev)
*/
bdp = fep->cur_rx;
-while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) {
+ while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) {
-#ifndef final_version
- /* Since we have allocated space to hold a complete frame,
- * the last indicator should be set.
- */
- if ((status & BD_ENET_RX_LAST) == 0)
- printk("FEC ENET: rcv is not +last\n");
-#endif
+ /* Since we have allocated space to hold a complete frame,
+ * the last indicator should be set.
+ */
+ if ((status & BD_ENET_RX_LAST) == 0)
+ printk("FEC ENET: rcv is not +last\n");
- if (!fep->opened)
- goto rx_processing_done;
+ if (!fep->opened)
+ goto rx_processing_done;
- /* Check for errors. */
- if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
+ /* Check for errors. */
+ if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
BD_ENET_RX_CR | BD_ENET_RX_OV)) {
- dev->stats.rx_errors++;
- if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
- /* Frame too long or too short. */
- dev->stats.rx_length_errors++;
+ dev->stats.rx_errors++;
+ if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
+ /* Frame too long or too short. */
+ dev->stats.rx_length_errors++;
+ }
+ if (status & BD_ENET_RX_NO) /* Frame alignment */
+ dev->stats.rx_frame_errors++;
+ if (status & BD_ENET_RX_CR) /* CRC Error */
+ dev->stats.rx_crc_errors++;
+ if (status & BD_ENET_RX_OV) /* FIFO overrun */
+ dev->stats.rx_fifo_errors++;
}
- if (status & BD_ENET_RX_NO) /* Frame alignment */
+
+ /* Report late collisions as a frame error.
+ * On this error, the BD is closed, but we don't know what we
+ * have in the buffer. So, just drop this frame on the floor.
+ */
+ if (status & BD_ENET_RX_CL) {
+ dev->stats.rx_errors++;
dev->stats.rx_frame_errors++;
- if (status & BD_ENET_RX_CR) /* CRC Error */
- dev->stats.rx_crc_errors++;
- if (status & BD_ENET_RX_OV) /* FIFO overrun */
- dev->stats.rx_fifo_errors++;
- }
+ goto rx_processing_done;
+ }
- /* Report late collisions as a frame error.
- * On this error, the BD is closed, but we don't know what we
- * have in the buffer. So, just drop this frame on the floor.
- */
- if (status & BD_ENET_RX_CL) {
- dev->stats.rx_errors++;
- dev->stats.rx_frame_errors++;
- goto rx_processing_done;
- }
+ /* Process the incoming frame. */
+ dev->stats.rx_packets++;
+ pkt_len = bdp->cbd_datlen;
+ dev->stats.rx_bytes += pkt_len;
+ data = (__u8*)__va(bdp->cbd_bufaddr);
- /* Process the incoming frame.
- */
- dev->stats.rx_packets++;
- pkt_len = bdp->cbd_datlen;
- dev->stats.rx_bytes += pkt_len;
- data = (__u8*)__va(bdp->cbd_bufaddr);
-
- dma_sync_single(NULL, (unsigned long)__pa(data),
- pkt_len - 4, DMA_FROM_DEVICE);
-
- /* This does 16 byte alignment, exactly what we need.
- * The packet length includes FCS, but we don't want to
- * include that when passing upstream as it messes up
- * bridging applications.
- */
- skb = dev_alloc_skb(pkt_len-4);
+ dma_unmap_single(NULL, bdp->cbd_bufaddr, bdp->cbd_datlen,
+ DMA_FROM_DEVICE);
- if (skb == NULL) {
- printk("%s: Memory squeeze, dropping packet.\n", dev->name);
- dev->stats.rx_dropped++;
- } else {
- skb_put(skb,pkt_len-4); /* Make room */
- skb_copy_to_linear_data(skb, data, pkt_len-4);
- skb->protocol=eth_type_trans(skb,dev);
- netif_rx(skb);
- }
- rx_processing_done:
+ /* This does 16 byte alignment, exactly what we need.
+ * The packet length includes FCS, but we don't want to
+ * include that when passing upstream as it messes up
+ * bridging applications.
+ */
+ skb = dev_alloc_skb(pkt_len - 4 + NET_IP_ALIGN);
- /* Clear the status flags for this buffer.
- */
- status &= ~BD_ENET_RX_STATS;
+ if (unlikely(!skb)) {
+ printk("%s: Memory squeeze, dropping packet.\n",
+ dev->name);
+ dev->stats.rx_dropped++;
+ } else {
+ skb_reserve(skb, NET_IP_ALIGN);
+ skb_put(skb, pkt_len - 4); /* Make room */
+ skb_copy_to_linear_data(skb, data, pkt_len - 4);
+ skb->protocol = eth_type_trans(skb, dev);
+ netif_rx(skb);
+ }
- /* Mark the buffer empty.
- */
- status |= BD_ENET_RX_EMPTY;
- bdp->cbd_sc = status;
+ bdp->cbd_bufaddr = dma_map_single(NULL, data, bdp->cbd_datlen,
+ DMA_FROM_DEVICE);
+rx_processing_done:
+ /* Clear the status flags for this buffer */
+ status &= ~BD_ENET_RX_STATS;
- /* Update BD pointer to next entry.
- */
- if (status & BD_ENET_RX_WRAP)
- bdp = fep->rx_bd_base;
- else
- bdp++;
+ /* Mark the buffer empty */
+ status |= BD_ENET_RX_EMPTY;
+ bdp->cbd_sc = status;
-#if 1
- /* Doing this here will keep the FEC running while we process
- * incoming frames. On a heavily loaded network, we should be
- * able to keep up at the expense of system resources.
- */
- fecp->fec_r_des_active = 0;
-#endif
- } /* while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) */
- fep->cur_rx = (cbd_t *)bdp;
-
-#if 0
- /* Doing this here will allow us to process all frames in the
- * ring before the FEC is allowed to put more there. On a heavily
- * loaded network, some frames may be lost. Unfortunately, this
- * increases the interrupt overhead since we can potentially work
- * our way back to the interrupt return only to come right back
- * here.
- */
- fecp->fec_r_des_active = 0;
-#endif
+ /* Update BD pointer to next entry */
+ if (status & BD_ENET_RX_WRAP)
+ bdp = fep->rx_bd_base;
+ else
+ bdp++;
+ /* Doing this here will keep the FEC running while we process
+ * incoming frames. On a heavily loaded network, we should be
+ * able to keep up at the expense of system resources.
+ */
+ writel(0, fep->hwp + FEC_R_DES_ACTIVE);
+ }
+ fep->cur_rx = bdp;
spin_unlock_irq(&fep->hw_lock);
}
-
/* called from interrupt context */
static void
fec_enet_mii(struct net_device *dev)
{
struct fec_enet_private *fep;
- volatile fec_t *ep;
mii_list_t *mip;
- uint mii_reg;
fep = netdev_priv(dev);
spin_lock_irq(&fep->mii_lock);
- ep = fep->hwp;
- mii_reg = ep->fec_mii_data;
-
if ((mip = mii_head) == NULL) {
printk("MII and no head!\n");
goto unlock;
}
if (mip->mii_func != NULL)
- (*(mip->mii_func))(mii_reg, dev);
+ (*(mip->mii_func))(readl(fep->hwp + FEC_MII_DATA), dev);
mii_head = mip->mii_next;
mip->mii_next = mii_free;
mii_free = mip;
if ((mip = mii_head) != NULL)
- ep->fec_mii_data = mip->mii_regval;
+ writel(mip->mii_regval, fep->hwp + FEC_MII_DATA);
unlock:
spin_unlock_irq(&fep->mii_lock);
@@ -727,8 +643,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
mii_list_t *mip;
int retval;
- /* Add PHY address to register command.
- */
+ /* Add PHY address to register command */
fep = netdev_priv(dev);
spin_lock_irqsave(&fep->mii_lock, flags);
@@ -745,7 +660,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
mii_tail = mip;
} else {
mii_head = mii_tail = mip;
- fep->hwp->fec_mii_data = regval;
+ writel(regval, fep->hwp + FEC_MII_DATA);
}
} else {
retval = 1;
@@ -1246,11 +1161,8 @@ static void __inline__ fec_phy_ack_intr(void)
static void __inline__ fec_get_mac(struct net_device *dev)
{
struct fec_enet_private *fep = netdev_priv(dev);
- volatile fec_t *fecp;
unsigned char *iap, tmpaddr[ETH_ALEN];
- fecp = fep->hwp;
-
if (FEC_FLASHMAC) {
/*
* Get MAC address from FLASH.
@@ -1264,8 +1176,8 @@ static void __inline__ fec_get_mac(struct net_device *dev)
(iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
iap = fec_mac_default;
} else {
- *((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low;
- *((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16);
+ *((unsigned long *) &tmpaddr[0]) = readl(fep->hwp + FEC_ADDR_LOW);
+ *((unsigned short *) &tmpaddr[4]) = (readl(fep->hwp + FEC_ADDR_HIGH) >> 16);
iap = &tmpaddr[0];
}
@@ -1375,11 +1287,6 @@ static void mii_relink(struct work_struct *work)
fec_restart(dev, duplex);
} else
fec_stop(dev);
-
-#if 0
- enable_irq(fep->mii_irq);
-#endif
-
}
/* mii_queue_relink is called in interrupt context from mii_link_interrupt */
@@ -1388,12 +1295,12 @@ static void mii_queue_relink(uint mii_reg, struct net_device *dev)
struct fec_enet_private *fep = netdev_priv(dev);
/*
- ** We cannot queue phy_task twice in the workqueue. It
- ** would cause an endless loop in the workqueue.
- ** Fortunately, if the last mii_relink entry has not yet been
- ** executed now, it will do the job for the current interrupt,
- ** which is just what we want.
- */
+ * We cannot queue phy_task twice in the workqueue. It
+ * would cause an endless loop in the workqueue.
+ * Fortunately, if the last mii_relink entry has not yet been
+ * executed now, it will do the job for the current interrupt,
+ * which is just what we want.
+ */
if (fep->mii_phy_task_queued)
return;
@@ -1424,8 +1331,7 @@ phy_cmd_t const phy_cmd_config[] = {
{ mk_mii_end, }
};
-/* Read remainder of PHY ID.
-*/
+/* Read remainder of PHY ID. */
static void
mii_discover_phy3(uint mii_reg, struct net_device *dev)
{
@@ -1457,17 +1363,14 @@ static void
mii_discover_phy(uint mii_reg, struct net_device *dev)
{
struct fec_enet_private *fep;
- volatile fec_t *fecp;
uint phytype;
fep = netdev_priv(dev);
- fecp = fep->hwp;
if (fep->phy_addr < 32) {
if ((phytype = (mii_reg & 0xffff)) != 0xffff && phytype != 0) {
- /* Got first part of ID, now get remainder.
- */
+ /* Got first part of ID, now get remainder */
fep->phy_id = phytype << 16;
mii_queue(dev, mk_mii_read(MII_REG_PHYIR2),
mii_discover_phy3);
@@ -1479,15 +1382,15 @@ mii_discover_phy(uint mii_reg, struct net_device *dev)
} else {
printk("FEC: No PHY device found.\n");
/* Disable external MII interface */
- fecp->fec_mii_speed = fep->phy_speed = 0;
+ writel(0, fep->hwp + FEC_MII_SPEED);
+ fep->phy_speed = 0;
#ifdef HAVE_mii_link_interrupt
fec_disable_phy_intr();
#endif
}
}
-/* This interrupt occurs when the PHY detects a link change.
-*/
+/* This interrupt occurs when the PHY detects a link change */
#ifdef HAVE_mii_link_interrupt
static irqreturn_t
mii_link_interrupt(int irq, void * dev_id)
@@ -1497,10 +1400,6 @@ mii_link_interrupt(int irq, void * dev_id)
fec_phy_ack_intr();
-#if 0
- disable_irq(fep->mii_irq); /* disable now, enable later */
-#endif
-
mii_do_cmd(dev, fep->phy->ack_int);
mii_do_cmd(dev, phy_cmd_relink); /* restart and display status */
@@ -1508,19 +1407,91 @@ mii_link_interrupt(int irq, void * dev_id)
}
#endif
+static void fec_enet_free_buffers(struct net_device *dev)
+{
+ struct fec_enet_private *fep = netdev_priv(dev);
+ int i;
+ struct sk_buff *skb;
+ struct bufdesc *bdp;
+
+ bdp = fep->rx_bd_base;
+ for (i = 0; i < RX_RING_SIZE; i++) {
+ skb = fep->rx_skbuff[i];
+
+ if (bdp->cbd_bufaddr)
+ dma_unmap_single(&dev->dev, bdp->cbd_bufaddr,
+ FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
+ if (skb)
+ dev_kfree_skb(skb);
+ bdp++;
+ }
+
+ bdp = fep->tx_bd_base;
+ for (i = 0; i < TX_RING_SIZE; i++)
+ kfree(fep->tx_bounce[i]);
+}
+
+static int fec_enet_alloc_buffers(struct net_device *dev)
+{
+ struct fec_enet_private *fep = netdev_priv(dev);
+ int i;
+ struct sk_buff *skb;
+ struct bufdesc *bdp;
+
+ bdp = fep->rx_bd_base;
+ for (i = 0; i < RX_RING_SIZE; i++) {
+ skb = dev_alloc_skb(FEC_ENET_RX_FRSIZE);
+ if (!skb) {
+ fec_enet_free_buffers(dev);
+ return -ENOMEM;
+ }
+ fep->rx_skbuff[i] = skb;
+
+ bdp->cbd_bufaddr = dma_map_single(&dev->dev, skb->data,
+ FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
+ bdp->cbd_sc = BD_ENET_RX_EMPTY;
+ bdp++;
+ }
+
+ /* Set the last buffer to wrap. */
+ bdp--;
+ bdp->cbd_sc |= BD_SC_WRAP;
+
+ bdp = fep->tx_bd_base;
+ for (i = 0; i < TX_RING_SIZE; i++) {
+ fep->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_KERNEL);
+
+ bdp->cbd_sc = 0;
+ bdp->cbd_bufaddr = 0;
+ bdp++;
+ }
+
+ /* Set the last buffer to wrap. */
+ bdp--;
+ bdp->cbd_sc |= BD_SC_WRAP;
+
+ return 0;
+}
+
static int
fec_enet_open(struct net_device *dev)
{
struct fec_enet_private *fep = netdev_priv(dev);
+ int ret;
/* I should reset the ring buffers here, but I don't yet know
* a simple way to do that.
*/
- fec_set_mac_address(dev);
+
+ ret = fec_enet_alloc_buffers(dev);
+ if (ret)
+ return ret;
fep->sequence_done = 0;
fep->link = 0;
+ fec_restart(dev, 1);
+
if (fep->phy) {
mii_do_cmd(dev, fep->phy->ack_int);
mii_do_cmd(dev, fep->phy->config);
@@ -1537,21 +1508,17 @@ fec_enet_open(struct net_device *dev)
schedule();
mii_do_cmd(dev, fep->phy->startup);
-
- /* Set the initial link state to true. A lot of hardware
- * based on this device does not implement a PHY interrupt,
- * so we are never notified of link change.
- */
- fep->link = 1;
- } else {
- fep->link = 1; /* lets just try it and see */
- /* no phy, go full duplex, it's most likely a hub chip */
- fec_restart(dev, 1);
}
+ /* Set the initial link state to true. A lot of hardware
+ * based on this device does not implement a PHY interrupt,
+ * so we are never notified of link change.
+ */
+ fep->link = 1;
+
netif_start_queue(dev);
fep->opened = 1;
- return 0; /* Success */
+ return 0;
}
static int
@@ -1559,12 +1526,13 @@ fec_enet_close(struct net_device *dev)
{
struct fec_enet_private *fep = netdev_priv(dev);
- /* Don't know what to do yet.
- */
+ /* Don't know what to do yet. */
fep->opened = 0;
netif_stop_queue(dev);
fec_stop(dev);
+ fec_enet_free_buffers(dev);
+
return 0;
}
@@ -1583,87 +1551,102 @@ fec_enet_close(struct net_device *dev)
static void set_multicast_list(struct net_device *dev)
{
- struct fec_enet_private *fep;
- volatile fec_t *ep;
+ struct fec_enet_private *fep = netdev_priv(dev);
struct dev_mc_list *dmi;
- unsigned int i, j, bit, data, crc;
+ unsigned int i, j, bit, data, crc, tmp;
unsigned char hash;
- fep = netdev_priv(dev);
- ep = fep->hwp;
+ if (dev->flags & IFF_PROMISC) {
+ tmp = readl(fep->hwp + FEC_R_CNTRL);
+ tmp |= 0x8;
+ writel(tmp, fep->hwp + FEC_R_CNTRL);
+ return;
+ }
- if (dev->flags&IFF_PROMISC) {
- ep->fec_r_cntrl |= 0x0008;
- } else {
+ tmp = readl(fep->hwp + FEC_R_CNTRL);
+ tmp &= ~0x8;
+ writel(tmp, fep->hwp + FEC_R_CNTRL);
+
+ if (dev->flags & IFF_ALLMULTI) {
+ /* Catch all multicast addresses, so set the
+ * filter to all 1's
+ */
+ writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+ writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
- ep->fec_r_cntrl &= ~0x0008;
+ return;
+ }
- if (dev->flags & IFF_ALLMULTI) {
- /* Catch all multicast addresses, so set the
- * filter to all 1's.
- */
- ep->fec_grp_hash_table_high = 0xffffffff;
- ep->fec_grp_hash_table_low = 0xffffffff;
- } else {
- /* Clear filter and add the addresses in hash register.
- */
- ep->fec_grp_hash_table_high = 0;
- ep->fec_grp_hash_table_low = 0;
-
- dmi = dev->mc_list;
-
- for (j = 0; j < dev->mc_count; j++, dmi = dmi->next)
- {
- /* Only support group multicast for now.
- */
- if (!(dmi->dmi_addr[0] & 1))
- continue;
-
- /* calculate crc32 value of mac address
- */
- crc = 0xffffffff;
-
- for (i = 0; i < dmi->dmi_addrlen; i++)
- {
- data = dmi->dmi_addr[i];
- for (bit = 0; bit < 8; bit++, data >>= 1)
- {
- crc = (crc >> 1) ^
- (((crc ^ data) & 1) ? CRC32_POLY : 0);
- }
- }
-
- /* only upper 6 bits (HASH_BITS) are used
- which point to specific bit in he hash registers
- */
- hash = (crc >> (32 - HASH_BITS)) & 0x3f;
-
- if (hash > 31)
- ep->fec_grp_hash_table_high |= 1 << (hash - 32);
- else
- ep->fec_grp_hash_table_low |= 1 << hash;
+ /* Clear filter and add the addresses in hash register
+ */
+ writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+ writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+
+ dmi = dev->mc_list;
+
+ for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) {
+ /* Only support group multicast for now */
+ if (!(dmi->dmi_addr[0] & 1))
+ continue;
+
+ /* calculate crc32 value of mac address */
+ crc = 0xffffffff;
+
+ for (i = 0; i < dmi->dmi_addrlen; i++) {
+ data = dmi->dmi_addr[i];
+ for (bit = 0; bit < 8; bit++, data >>= 1) {
+ crc = (crc >> 1) ^
+ (((crc ^ data) & 1) ? CRC32_POLY : 0);
}
}
+
+ /* only upper 6 bits (HASH_BITS) are used
+ * which point to specific bit in he hash registers
+ */
+ hash = (crc >> (32 - HASH_BITS)) & 0x3f;
+
+ if (hash > 31) {
+ tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+ tmp |= 1 << (hash - 32);
+ writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+ } else {
+ tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+ tmp |= 1 << hash;
+ writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+ }
}
}
-/* Set a MAC change in hardware.
- */
-static void
-fec_set_mac_address(struct net_device *dev)
+/* Set a MAC change in hardware. */
+static int
+fec_set_mac_address(struct net_device *dev, void *p)
{
- volatile fec_t *fecp;
+ struct fec_enet_private *fep = netdev_priv(dev);
+ struct sockaddr *addr = p;
- fecp = ((struct fec_enet_private *)netdev_priv(dev))->hwp;
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
- /* Set station address. */
- fecp->fec_addr_low = dev->dev_addr[3] | (dev->dev_addr[2] << 8) |
- (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24);
- fecp->fec_addr_high = (dev->dev_addr[5] << 16) |
- (dev->dev_addr[4] << 24);
+ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+ writel(dev->dev_addr[3] | (dev->dev_addr[2] << 8) |
+ (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24),
+ fep->hwp + FEC_ADDR_LOW);
+ writel((dev->dev_addr[5] << 16) | (dev->dev_addr[4] << 24),
+ fep + FEC_ADDR_HIGH);
+ return 0;
}
+static const struct net_device_ops fec_netdev_ops = {
+ .ndo_open = fec_enet_open,
+ .ndo_stop = fec_enet_close,
+ .ndo_start_xmit = fec_enet_start_xmit,
+ .ndo_set_multicast_list = set_multicast_list,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_tx_timeout = fec_timeout,
+ .ndo_set_mac_address = fec_set_mac_address,
+};
+
/*
* XXX: We need to clean up on failure exits here.
*
@@ -1672,17 +1655,13 @@ fec_set_mac_address(struct net_device *dev)
int __init fec_enet_init(struct net_device *dev, int index)
{
struct fec_enet_private *fep = netdev_priv(dev);
- unsigned long mem_addr;
- volatile cbd_t *bdp;
- cbd_t *cbd_base;
- volatile fec_t *fecp;
- int i, j;
+ struct bufdesc *cbd_base;
+ int i;
- /* Allocate memory for buffer descriptors.
- */
- mem_addr = (unsigned long)dma_alloc_coherent(NULL, PAGE_SIZE,
- &fep->bd_dma, GFP_KERNEL);
- if (mem_addr == 0) {
+ /* Allocate memory for buffer descriptors. */
+ cbd_base = dma_alloc_coherent(NULL, PAGE_SIZE, &fep->bd_dma,
+ GFP_KERNEL);
+ if (!cbd_base) {
printk("FEC: allocate descriptor memory failed?\n");
return -ENOMEM;
}
@@ -1690,146 +1669,47 @@ int __init fec_enet_init(struct net_device *dev, int index)
spin_lock_init(&fep->hw_lock);
spin_lock_init(&fep->mii_lock);
- /* Create an Ethernet device instance.
- */
- fecp = (volatile fec_t *)dev->base_addr;
-
fep->index = index;
- fep->hwp = fecp;
+ fep->hwp = (void __iomem *)dev->base_addr;
fep->netdev = dev;
- /* Whack a reset. We should wait for this.
- */
- fecp->fec_ecntrl = 1;
- udelay(10);
-
/* Set the Ethernet address */
#ifdef CONFIG_M5272
fec_get_mac(dev);
#else
{
unsigned long l;
- l = fecp->fec_addr_low;
+ l = readl(fep->hwp + FEC_ADDR_LOW);
dev->dev_addr[0] = (unsigned char)((l & 0xFF000000) >> 24);
dev->dev_addr[1] = (unsigned char)((l & 0x00FF0000) >> 16);
dev->dev_addr[2] = (unsigned char)((l & 0x0000FF00) >> 8);
dev->dev_addr[3] = (unsigned char)((l & 0x000000FF) >> 0);
- l = fecp->fec_addr_high;
+ l = readl(fep->hwp + FEC_ADDR_HIGH);
dev->dev_addr[4] = (unsigned char)((l & 0xFF000000) >> 24);
dev->dev_addr[5] = (unsigned char)((l & 0x00FF0000) >> 16);
}
#endif
- cbd_base = (cbd_t *)mem_addr;
-
- /* Set receive and transmit descriptor base.
- */
+ /* Set receive and transmit descriptor base. */
fep->rx_bd_base = cbd_base;
fep->tx_bd_base = cbd_base + RX_RING_SIZE;
- fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
- fep->cur_rx = fep->rx_bd_base;
-
- fep->skb_cur = fep->skb_dirty = 0;
-
- /* Initialize the receive buffer descriptors.
- */
- bdp = fep->rx_bd_base;
- for (i=0; i<FEC_ENET_RX_PAGES; i++) {
-
- /* Allocate a page.
- */
- mem_addr = __get_free_page(GFP_KERNEL);
- /* XXX: missing check for allocation failure */
-
- /* Initialize the BD for every fragment in the page.
- */
- for (j=0; j<FEC_ENET_RX_FRPPG; j++) {
- bdp->cbd_sc = BD_ENET_RX_EMPTY;
- bdp->cbd_bufaddr = __pa(mem_addr);
- mem_addr += FEC_ENET_RX_FRSIZE;
- bdp++;
- }
- }
-
- /* Set the last buffer to wrap.
- */
- bdp--;
- bdp->cbd_sc |= BD_SC_WRAP;
-
- /* ...and the same for transmmit.
- */
- bdp = fep->tx_bd_base;
- for (i=0, j=FEC_ENET_TX_FRPPG; i<TX_RING_SIZE; i++) {
- if (j >= FEC_ENET_TX_FRPPG) {
- mem_addr = __get_free_page(GFP_KERNEL);
- j = 1;
- } else {
- mem_addr += FEC_ENET_TX_FRSIZE;
- j++;
- }
- fep->tx_bounce[i] = (unsigned char *) mem_addr;
-
- /* Initialize the BD for every fragment in the page.
- */
- bdp->cbd_sc = 0;
- bdp->cbd_bufaddr = 0;
- bdp++;
- }
-
- /* Set the last buffer to wrap.
- */
- bdp--;
- bdp->cbd_sc |= BD_SC_WRAP;
-
- /* Set receive and transmit descriptor base.
- */
- fecp->fec_r_des_start = fep->bd_dma;
- fecp->fec_x_des_start = (unsigned long)fep->bd_dma + sizeof(cbd_t)
- * RX_RING_SIZE;
-
#ifdef HAVE_mii_link_interrupt
fec_request_mii_intr(dev);
#endif
-
- fecp->fec_grp_hash_table_high = 0;
- fecp->fec_grp_hash_table_low = 0;
- fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
- fecp->fec_ecntrl = 2;
- fecp->fec_r_des_active = 0;
-#ifndef CONFIG_M5272
- fecp->fec_hash_table_high = 0;
- fecp->fec_hash_table_low = 0;
-#endif
-
- /* The FEC Ethernet specific entries in the device structure. */
- dev->open = fec_enet_open;
- dev->hard_start_xmit = fec_enet_start_xmit;
- dev->tx_timeout = fec_timeout;
+ /* The FEC Ethernet specific entries in the device structure */
dev->watchdog_timeo = TX_TIMEOUT;
- dev->stop = fec_enet_close;
- dev->set_multicast_list = set_multicast_list;
+ dev->netdev_ops = &fec_netdev_ops;
for (i=0; i<NMII-1; i++)
mii_cmds[i].mii_next = &mii_cmds[i+1];
mii_free = mii_cmds;
- /* setup MII interface */
- fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;
- fecp->fec_x_cntrl = 0x00;
-
- /*
- * Set MII speed to 2.5 MHz
- */
+ /* Set MII speed to 2.5 MHz */
fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
/ 2500000) / 2) & 0x3F) << 1;
- fecp->fec_mii_speed = fep->phy_speed;
fec_restart(dev, 0);
- /* Clear and enable interrupts */
- fecp->fec_ievent = 0xffc00000;
- fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII);
-
/* Queue up command to detect the PHY and initialize the
* remainder of the interface.
*/
@@ -1847,145 +1727,118 @@ int __init fec_enet_init(struct net_device *dev, int index)
static void
fec_restart(struct net_device *dev, int duplex)
{
- struct fec_enet_private *fep;
- volatile cbd_t *bdp;
- volatile fec_t *fecp;
+ struct fec_enet_private *fep = netdev_priv(dev);
+ struct bufdesc *bdp;
int i;
- fep = netdev_priv(dev);
- fecp = fep->hwp;
-
- /* Whack a reset. We should wait for this.
- */
- fecp->fec_ecntrl = 1;
+ /* Whack a reset. We should wait for this. */
+ writel(1, fep->hwp + FEC_ECNTRL);
udelay(10);
- /* Clear any outstanding interrupt.
- */
- fecp->fec_ievent = 0xffc00000;
+ /* Clear any outstanding interrupt. */
+ writel(0xffc00000, fep->hwp + FEC_IEVENT);
- /* Set station address.
- */
- fec_set_mac_address(dev);
+ /* Reset all multicast. */
+ writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+ writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+#ifndef CONFIG_M5272
+ writel(0, fep->hwp + FEC_HASH_TABLE_HIGH);
+ writel(0, fep->hwp + FEC_HASH_TABLE_LOW);
+#endif
- /* Reset all multicast.
- */
- fecp->fec_grp_hash_table_high = 0;
- fecp->fec_grp_hash_table_low = 0;
+ /* Set maximum receive buffer size. */
+ writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE);
- /* Set maximum receive buffer size.
- */
- fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
-
- /* Set receive and transmit descriptor base.
- */
- fecp->fec_r_des_start = fep->bd_dma;
- fecp->fec_x_des_start = (unsigned long)fep->bd_dma + sizeof(cbd_t)
- * RX_RING_SIZE;
+ /* Set receive and transmit descriptor base. */
+ writel(fep->bd_dma, fep->hwp + FEC_R_DES_START);
+ writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc) * RX_RING_SIZE,
+ fep->hwp + FEC_X_DES_START);
fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
fep->cur_rx = fep->rx_bd_base;
- /* Reset SKB transmit buffers.
- */
+ /* Reset SKB transmit buffers. */
fep->skb_cur = fep->skb_dirty = 0;
- for (i=0; i<=TX_RING_MOD_MASK; i++) {
- if (fep->tx_skbuff[i] != NULL) {
+ for (i = 0; i <= TX_RING_MOD_MASK; i++) {
+ if (fep->tx_skbuff[i]) {
dev_kfree_skb_any(fep->tx_skbuff[i]);
fep->tx_skbuff[i] = NULL;
}
}
- /* Initialize the receive buffer descriptors.
- */
+ /* Initialize the receive buffer descriptors. */
bdp = fep->rx_bd_base;
- for (i=0; i<RX_RING_SIZE; i++) {
+ for (i = 0; i < RX_RING_SIZE; i++) {
- /* Initialize the BD for every fragment in the page.
- */
+ /* Initialize the BD for every fragment in the page. */
bdp->cbd_sc = BD_ENET_RX_EMPTY;
bdp++;
}
- /* Set the last buffer to wrap.
- */
+ /* Set the last buffer to wrap */
bdp--;
bdp->cbd_sc |= BD_SC_WRAP;
- /* ...and the same for transmmit.
- */
+ /* ...and the same for transmit */
bdp = fep->tx_bd_base;
- for (i=0; i<TX_RING_SIZE; i++) {
+ for (i = 0; i < TX_RING_SIZE; i++) {
- /* Initialize the BD for every fragment in the page.
- */
+ /* Initialize the BD for every fragment in the page. */
bdp->cbd_sc = 0;
bdp->cbd_bufaddr = 0;
bdp++;
}
- /* Set the last buffer to wrap.
- */
+ /* Set the last buffer to wrap */
bdp--;
bdp->cbd_sc |= BD_SC_WRAP;
- /* Enable MII mode.
- */
+ /* Enable MII mode */
if (duplex) {
- fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;/* MII enable */
- fecp->fec_x_cntrl = 0x04; /* FD enable */
+ /* MII enable / FD enable */
+ writel(OPT_FRAME_SIZE | 0x04, fep->hwp + FEC_R_CNTRL);
+ writel(0x04, fep->hwp + FEC_X_CNTRL);
} else {
- /* MII enable|No Rcv on Xmit */
- fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x06;
- fecp->fec_x_cntrl = 0x00;
+ /* MII enable / No Rcv on Xmit */
+ writel(OPT_FRAME_SIZE | 0x06, fep->hwp + FEC_R_CNTRL);
+ writel(0x0, fep->hwp + FEC_X_CNTRL);
}
fep->full_duplex = duplex;
- /* Set MII speed.
- */
- fecp->fec_mii_speed = fep->phy_speed;
+ /* Set MII speed */
+ writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
- /* And last, enable the transmit and receive processing.
- */
- fecp->fec_ecntrl = 2;
- fecp->fec_r_des_active = 0;
+ /* And last, enable the transmit and receive processing */
+ writel(2, fep->hwp + FEC_ECNTRL);
+ writel(0, fep->hwp + FEC_R_DES_ACTIVE);
- /* Enable interrupts we wish to service.
- */
- fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII);
+ /* Enable interrupts we wish to service */
+ writel(FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII,
+ fep->hwp + FEC_IMASK);
}
static void
fec_stop(struct net_device *dev)
{
- volatile fec_t *fecp;
- struct fec_enet_private *fep;
-
- fep = netdev_priv(dev);
- fecp = fep->hwp;
+ struct fec_enet_private *fep = netdev_priv(dev);
- /*
- ** We cannot expect a graceful transmit stop without link !!!
- */
- if (fep->link)
- {
- fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */
+ /* We cannot expect a graceful transmit stop without link !!! */
+ if (fep->link) {
+ writel(1, fep->hwp + FEC_X_CNTRL); /* Graceful transmit stop */
udelay(10);
- if (!(fecp->fec_ievent & FEC_ENET_GRA))
+ if (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_GRA))
printk("fec_stop : Graceful transmit stop did not complete !\n");
- }
+ }
- /* Whack a reset. We should wait for this.
- */
- fecp->fec_ecntrl = 1;
+ /* Whack a reset. We should wait for this. */
+ writel(1, fep->hwp + FEC_ECNTRL);
udelay(10);
- /* Clear outstanding MII command interrupts.
- */
- fecp->fec_ievent = FEC_ENET_MII;
+ /* Clear outstanding MII command interrupts. */
+ writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
- fecp->fec_imask = FEC_ENET_MII;
- fecp->fec_mii_speed = fep->phy_speed;
+ writel(FEC_ENET_MII, fep->hwp + FEC_IMASK);
+ writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
}
static int __devinit
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index 76c64c92e190..30b7dd671336 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -20,82 +20,55 @@
* registers in the same peripheral device on different models
* of the ColdFire!
*/
-typedef struct fec {
- unsigned long fec_reserved0;
- unsigned long fec_ievent; /* Interrupt event reg */
- unsigned long fec_imask; /* Interrupt mask reg */
- unsigned long fec_reserved1;
- unsigned long fec_r_des_active; /* Receive descriptor reg */
- unsigned long fec_x_des_active; /* Transmit descriptor reg */
- unsigned long fec_reserved2[3];
- unsigned long fec_ecntrl; /* Ethernet control reg */
- unsigned long fec_reserved3[6];
- unsigned long fec_mii_data; /* MII manage frame reg */
- unsigned long fec_mii_speed; /* MII speed control reg */
- unsigned long fec_reserved4[7];
- unsigned long fec_mib_ctrlstat; /* MIB control/status reg */
- unsigned long fec_reserved5[7];
- unsigned long fec_r_cntrl; /* Receive control reg */
- unsigned long fec_reserved6[15];
- unsigned long fec_x_cntrl; /* Transmit Control reg */
- unsigned long fec_reserved7[7];
- unsigned long fec_addr_low; /* Low 32bits MAC address */
- unsigned long fec_addr_high; /* High 16bits MAC address */
- unsigned long fec_opd; /* Opcode + Pause duration */
- unsigned long fec_reserved8[10];
- unsigned long fec_hash_table_high; /* High 32bits hash table */
- unsigned long fec_hash_table_low; /* Low 32bits hash table */
- unsigned long fec_grp_hash_table_high;/* High 32bits hash table */
- unsigned long fec_grp_hash_table_low; /* Low 32bits hash table */
- unsigned long fec_reserved9[7];
- unsigned long fec_x_wmrk; /* FIFO transmit water mark */
- unsigned long fec_reserved10;
- unsigned long fec_r_bound; /* FIFO receive bound reg */
- unsigned long fec_r_fstart; /* FIFO receive start reg */
- unsigned long fec_reserved11[11];
- unsigned long fec_r_des_start; /* Receive descriptor ring */
- unsigned long fec_x_des_start; /* Transmit descriptor ring */
- unsigned long fec_r_buff_size; /* Maximum receive buff size */
-} fec_t;
+#define FEC_IEVENT 0x004 /* Interrupt event reg */
+#define FEC_IMASK 0x008 /* Interrupt mask reg */
+#define FEC_R_DES_ACTIVE 0x010 /* Receive descriptor reg */
+#define FEC_X_DES_ACTIVE 0x014 /* Transmit descriptor reg */
+#define FEC_ECNTRL 0x024 /* Ethernet control reg */
+#define FEC_MII_DATA 0x040 /* MII manage frame reg */
+#define FEC_MII_SPEED 0x044 /* MII speed control reg */
+#define FEC_MIB_CTRLSTAT 0x064 /* MIB control/status reg */
+#define FEC_R_CNTRL 0x084 /* Receive control reg */
+#define FEC_X_CNTRL 0x0c4 /* Transmit Control reg */
+#define FEC_ADDR_LOW 0x0e4 /* Low 32bits MAC address */
+#define FEC_ADDR_HIGH 0x0e8 /* High 16bits MAC address */
+#define FEC_OPD 0x0ec /* Opcode + Pause duration */
+#define FEC_HASH_TABLE_HIGH 0x118 /* High 32bits hash table */
+#define FEC_HASH_TABLE_LOW 0x11c /* Low 32bits hash table */
+#define FEC_GRP_HASH_TABLE_HIGH 0x120 /* High 32bits hash table */
+#define FEC_GRP_HASH_TABLE_LOW 0x124 /* Low 32bits hash table */
+#define FEC_X_WMRK 0x144 /* FIFO transmit water mark */
+#define FEC_R_BOUND 0x14c /* FIFO receive bound reg */
+#define FEC_R_FSTART 0x150 /* FIFO receive start reg */
+#define FEC_R_DES_START 0x180 /* Receive descriptor ring */
+#define FEC_X_DES_START 0x184 /* Transmit descriptor ring */
+#define FEC_R_BUFF_SIZE 0x188 /* Maximum receive buff size */
#else
-/*
- * Define device register set address map.
- */
-typedef struct fec {
- unsigned long fec_ecntrl; /* Ethernet control reg */
- unsigned long fec_ievent; /* Interrupt even reg */
- unsigned long fec_imask; /* Interrupt mask reg */
- unsigned long fec_ivec; /* Interrupt vec status reg */
- unsigned long fec_r_des_active; /* Receive descriptor reg */
- unsigned long fec_x_des_active; /* Transmit descriptor reg */
- unsigned long fec_reserved1[10];
- unsigned long fec_mii_data; /* MII manage frame reg */
- unsigned long fec_mii_speed; /* MII speed control reg */
- unsigned long fec_reserved2[17];
- unsigned long fec_r_bound; /* FIFO receive bound reg */
- unsigned long fec_r_fstart; /* FIFO receive start reg */
- unsigned long fec_reserved3[4];
- unsigned long fec_x_wmrk; /* FIFO transmit water mark */
- unsigned long fec_reserved4;
- unsigned long fec_x_fstart; /* FIFO transmit start reg */
- unsigned long fec_reserved5[21];
- unsigned long fec_r_cntrl; /* Receive control reg */
- unsigned long fec_max_frm_len; /* Maximum frame length reg */
- unsigned long fec_reserved6[14];
- unsigned long fec_x_cntrl; /* Transmit Control reg */
- unsigned long fec_reserved7[158];
- unsigned long fec_addr_low; /* Low 32bits MAC address */
- unsigned long fec_addr_high; /* High 16bits MAC address */
- unsigned long fec_grp_hash_table_high;/* High 32bits hash table */
- unsigned long fec_grp_hash_table_low; /* Low 32bits hash table */
- unsigned long fec_r_des_start; /* Receive descriptor ring */
- unsigned long fec_x_des_start; /* Transmit descriptor ring */
- unsigned long fec_r_buff_size; /* Maximum receive buff size */
- unsigned long reserved8[9];
- unsigned long fec_fifo_ram[112]; /* FIFO RAM buffer */
-} fec_t;
+#define FEC_ECNTRL; 0x000 /* Ethernet control reg */
+#define FEC_IEVENT; 0x004 /* Interrupt even reg */
+#define FEC_IMASK; 0x008 /* Interrupt mask reg */
+#define FEC_IVEC; 0x00c /* Interrupt vec status reg */
+#define FEC_R_DES_ACTIVE; 0x010 /* Receive descriptor reg */
+#define FEC_X_DES_ACTIVE; 0x01c /* Transmit descriptor reg */
+#define FEC_MII_DATA 0x040 /* MII manage frame reg */
+#define FEC_MII_SPEED 0x044 /* MII speed control reg */
+#define FEC_R_BOUND 0x08c /* FIFO receive bound reg */
+#define FEC_R_FSTART 0x090 /* FIFO receive start reg */
+#define FEC_X_WMRK 0x0a4 /* FIFO transmit water mark */
+#define FEC_X_FSTART 0x0ac /* FIFO transmit start reg */
+#define FEC_R_CNTRL 0x104 /* Receive control reg */
+#define FEC_MAX_FRM_LEN 0x108 /* Maximum frame length reg */
+#define FEC_X_CNTRL 0x144 /* Transmit Control reg */
+#define FEC_ADDR_LOW 0x3c0 /* Low 32bits MAC address */
+#define FEC_ADDR_HIGH 0x3c4 /* High 16bits MAC address */
+#define FEC_GRP_HASH_TABLE_HIGH 0x3c8 /* High 32bits hash table */
+#define FEC_GRP_HASH_TABLE_LOW 0x3cc /* Low 32bits hash table */
+#define FEC_R_DES_START 0x3d0 /* Receive descriptor ring */
+#define FEC_X_DES_START 0x3d4 /* Transmit descriptor ring */
+#define FEC_R_BUFF_SIZE 0x3d8 /* Maximum receive buff size */
+#define FEC_FIFO_RAM 0x400 /* FIFO RAM buffer */
#endif /* CONFIG_M5272 */
@@ -104,17 +77,17 @@ typedef struct fec {
* Define the buffer descriptor structure.
*/
#ifdef CONFIG_ARCH_MXC
-typedef struct bufdesc {
+struct bufdesc {
unsigned short cbd_datlen; /* Data length */
unsigned short cbd_sc; /* Control and status info */
unsigned long cbd_bufaddr; /* Buffer address */
-} cbd_t;
+};
#else
-typedef struct bufdesc {
+struct bufdesc {
unsigned short cbd_sc; /* Control and status info */
unsigned short cbd_datlen; /* Data length */
unsigned long cbd_bufaddr; /* Buffer address */
-} cbd_t;
+};
#endif
/*
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 8bbe7f617994..7d443405bbe2 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -25,6 +25,7 @@
#include <linux/hardirq.h>
#include <linux/delay.h>
#include <linux/of_device.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <linux/netdevice.h>
@@ -43,11 +44,9 @@
#define DRIVER_NAME "mpc52xx-fec"
-#define FEC5200_PHYADDR_NONE (-1)
-#define FEC5200_PHYADDR_7WIRE (-2)
-
/* Private driver data structure */
struct mpc52xx_fec_priv {
+ struct net_device *ndev;
int duplex;
int speed;
int r_irq;
@@ -59,10 +58,11 @@ struct mpc52xx_fec_priv {
int msg_enable;
/* MDIO link details */
- int phy_addr;
- unsigned int phy_speed;
+ unsigned int mdio_speed;
+ struct device_node *phy_node;
struct phy_device *phydev;
enum phy_state link;
+ int seven_wire_mode;
};
@@ -211,85 +211,25 @@ static void mpc52xx_fec_adjust_link(struct net_device *dev)
phy_print_status(phydev);
}
-static int mpc52xx_fec_init_phy(struct net_device *dev)
-{
- struct mpc52xx_fec_priv *priv = netdev_priv(dev);
- struct phy_device *phydev;
- char phy_id[BUS_ID_SIZE];
-
- snprintf(phy_id, sizeof(phy_id), "%x:%02x",
- (unsigned int)dev->base_addr, priv->phy_addr);
-
- priv->link = PHY_DOWN;
- priv->speed = 0;
- priv->duplex = -1;
-
- phydev = phy_connect(dev, phy_id, &mpc52xx_fec_adjust_link, 0, PHY_INTERFACE_MODE_MII);
- if (IS_ERR(phydev)) {
- dev_err(&dev->dev, "phy_connect failed\n");
- return PTR_ERR(phydev);
- }
- dev_info(&dev->dev, "attached phy %i to driver %s\n",
- phydev->addr, phydev->drv->name);
-
- priv->phydev = phydev;
-
- return 0;
-}
-
-static int mpc52xx_fec_phy_start(struct net_device *dev)
-{
- struct mpc52xx_fec_priv *priv = netdev_priv(dev);
- int err;
-
- if (priv->phy_addr < 0)
- return 0;
-
- err = mpc52xx_fec_init_phy(dev);
- if (err) {
- dev_err(&dev->dev, "mpc52xx_fec_init_phy failed\n");
- return err;
- }
-
- /* reset phy - this also wakes it from PDOWN */
- phy_write(priv->phydev, MII_BMCR, BMCR_RESET);
- phy_start(priv->phydev);
-
- return 0;
-}
-
-static void mpc52xx_fec_phy_stop(struct net_device *dev)
-{
- struct mpc52xx_fec_priv *priv = netdev_priv(dev);
-
- if (!priv->phydev)
- return;
-
- phy_disconnect(priv->phydev);
- /* power down phy */
- phy_stop(priv->phydev);
- phy_write(priv->phydev, MII_BMCR, BMCR_PDOWN);
-}
-
-static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv)
-{
- struct mpc52xx_fec __iomem *fec = priv->fec;
-
- if (priv->phydev)
- return;
-
- out_be32(&fec->mii_speed, priv->phy_speed);
-}
-
static int mpc52xx_fec_open(struct net_device *dev)
{
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
int err = -EBUSY;
+ if (priv->phy_node) {
+ priv->phydev = of_phy_connect(priv->ndev, priv->phy_node,
+ mpc52xx_fec_adjust_link, 0, 0);
+ if (!priv->phydev) {
+ dev_err(&dev->dev, "of_phy_connect failed\n");
+ return -ENODEV;
+ }
+ phy_start(priv->phydev);
+ }
+
if (request_irq(dev->irq, &mpc52xx_fec_interrupt, IRQF_SHARED,
DRIVER_NAME "_ctrl", dev)) {
dev_err(&dev->dev, "ctrl interrupt request failed\n");
- goto out;
+ goto free_phy;
}
if (request_irq(priv->r_irq, &mpc52xx_fec_rx_interrupt, 0,
DRIVER_NAME "_rx", dev)) {
@@ -311,10 +251,6 @@ static int mpc52xx_fec_open(struct net_device *dev)
goto free_irqs;
}
- err = mpc52xx_fec_phy_start(dev);
- if (err)
- goto free_skbs;
-
bcom_enable(priv->rx_dmatsk);
bcom_enable(priv->tx_dmatsk);
@@ -324,16 +260,18 @@ static int mpc52xx_fec_open(struct net_device *dev)
return 0;
- free_skbs:
- mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk);
-
free_irqs:
free_irq(priv->t_irq, dev);
free_2irqs:
free_irq(priv->r_irq, dev);
free_ctrl_irq:
free_irq(dev->irq, dev);
- out:
+ free_phy:
+ if (priv->phydev) {
+ phy_stop(priv->phydev);
+ phy_disconnect(priv->phydev);
+ priv->phydev = NULL;
+ }
return err;
}
@@ -352,7 +290,12 @@ static int mpc52xx_fec_close(struct net_device *dev)
free_irq(priv->r_irq, dev);
free_irq(priv->t_irq, dev);
- mpc52xx_fec_phy_stop(dev);
+ if (priv->phydev) {
+ /* power down phy */
+ phy_stop(priv->phydev);
+ phy_disconnect(priv->phydev);
+ priv->phydev = NULL;
+ }
return 0;
}
@@ -696,7 +639,7 @@ static void mpc52xx_fec_hw_init(struct net_device *dev)
/* set phy speed.
* this can't be done in phy driver, since it needs to be called
* before fec stuff (even on resume) */
- mpc52xx_fec_phy_hw_init(priv);
+ out_be32(&fec->mii_speed, priv->mdio_speed);
}
/**
@@ -732,7 +675,7 @@ static void mpc52xx_fec_start(struct net_device *dev)
rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */
rcntrl |= FEC_RCNTRL_FCE;
- if (priv->phy_addr != FEC5200_PHYADDR_7WIRE)
+ if (!priv->seven_wire_mode)
rcntrl |= FEC_RCNTRL_MII_MODE;
if (priv->duplex == DUPLEX_FULL)
@@ -798,8 +741,6 @@ static void mpc52xx_fec_stop(struct net_device *dev)
/* Stop FEC */
out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) & ~FEC_ECNTRL_ETHER_EN);
-
- return;
}
/* reset fec and bestcomm tasks */
@@ -817,9 +758,11 @@ static void mpc52xx_fec_reset(struct net_device *dev)
mpc52xx_fec_hw_init(dev);
- phy_stop(priv->phydev);
- phy_write(priv->phydev, MII_BMCR, BMCR_RESET);
- phy_start(priv->phydev);
+ if (priv->phydev) {
+ phy_stop(priv->phydev);
+ phy_write(priv->phydev, MII_BMCR, BMCR_RESET);
+ phy_start(priv->phydev);
+ }
bcom_fec_rx_reset(priv->rx_dmatsk);
bcom_fec_tx_reset(priv->tx_dmatsk);
@@ -919,8 +862,6 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
struct net_device *ndev;
struct mpc52xx_fec_priv *priv = NULL;
struct resource mem;
- struct device_node *phy_node;
- const phandle *phy_handle;
const u32 *prop;
int prop_size;
@@ -933,6 +874,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
return -ENOMEM;
priv = netdev_priv(ndev);
+ priv->ndev = ndev;
/* Reserve FEC control zone */
rv = of_address_to_resource(op->node, 0, &mem);
@@ -956,6 +898,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops;
ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT;
ndev->base_addr = mem.start;
+ SET_NETDEV_DEV(ndev, &op->dev);
spin_lock_init(&priv->lock);
@@ -1003,14 +946,9 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
*/
/* Start with safe defaults for link connection */
- priv->phy_addr = FEC5200_PHYADDR_NONE;
priv->speed = 100;
priv->duplex = DUPLEX_HALF;
- priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1;
-
- /* the 7-wire property means don't use MII mode */
- if (of_find_property(op->node, "fsl,7-wire-mode", NULL))
- priv->phy_addr = FEC5200_PHYADDR_7WIRE;
+ priv->mdio_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1;
/* The current speed preconfigures the speed of the MII link */
prop = of_get_property(op->node, "current-speed", &prop_size);
@@ -1019,43 +957,23 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF;
}
- /* If there is a phy handle, setup link to that phy */
- phy_handle = of_get_property(op->node, "phy-handle", &prop_size);
- if (phy_handle && (prop_size >= sizeof(phandle))) {
- phy_node = of_find_node_by_phandle(*phy_handle);
- prop = of_get_property(phy_node, "reg", &prop_size);
- if (prop && (prop_size >= sizeof(u32)))
- if ((*prop >= 0) && (*prop < PHY_MAX_ADDR))
- priv->phy_addr = *prop;
- of_node_put(phy_node);
+ /* If there is a phy handle, then get the PHY node */
+ priv->phy_node = of_parse_phandle(op->node, "phy-handle", 0);
+
+ /* the 7-wire property means don't use MII mode */
+ if (of_find_property(op->node, "fsl,7-wire-mode", NULL)) {
+ priv->seven_wire_mode = 1;
+ dev_info(&ndev->dev, "using 7-wire PHY mode\n");
}
/* Hardware init */
mpc52xx_fec_hw_init(ndev);
-
mpc52xx_fec_reset_stats(ndev);
- SET_NETDEV_DEV(ndev, &op->dev);
-
- /* Register the new network device */
rv = register_netdev(ndev);
if (rv < 0)
goto probe_error;
- /* Now report the link setup */
- switch (priv->phy_addr) {
- case FEC5200_PHYADDR_NONE:
- dev_info(&ndev->dev, "Fixed speed MII link: %i%cD\n",
- priv->speed, priv->duplex ? 'F' : 'H');
- break;
- case FEC5200_PHYADDR_7WIRE:
- dev_info(&ndev->dev, "using 7-wire PHY mode\n");
- break;
- default:
- dev_info(&ndev->dev, "Using PHY at MDIO address %i\n",
- priv->phy_addr);
- }
-
/* We're done ! */
dev_set_drvdata(&op->dev, ndev);
@@ -1065,6 +983,10 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
/* Error handling - free everything that might be allocated */
probe_error:
+ if (priv->phy_node)
+ of_node_put(priv->phy_node);
+ priv->phy_node = NULL;
+
irq_dispose_mapping(ndev->irq);
if (priv->rx_dmatsk)
@@ -1093,6 +1015,10 @@ mpc52xx_fec_remove(struct of_device *op)
unregister_netdev(ndev);
+ if (priv->phy_node)
+ of_node_put(priv->phy_node);
+ priv->phy_node = NULL;
+
irq_dispose_mapping(ndev->irq);
bcom_fec_rx_release(priv->rx_dmatsk);
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c
index dd9bfa42ac34..fec9f245116b 100644
--- a/drivers/net/fec_mpc52xx_phy.c
+++ b/drivers/net/fec_mpc52xx_phy.c
@@ -14,12 +14,14 @@
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <linux/of_platform.h>
+#include <linux/of_mdio.h>
#include <asm/io.h>
#include <asm/mpc52xx.h>
#include "fec_mpc52xx.h"
struct mpc52xx_fec_mdio_priv {
struct mpc52xx_fec __iomem *regs;
+ int mdio_irqs[PHY_MAX_ADDR];
};
static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
@@ -27,7 +29,7 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
{
struct mpc52xx_fec_mdio_priv *priv = bus->priv;
struct mpc52xx_fec __iomem *fec;
- int tries = 100;
+ int tries = 3;
value |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK;
value |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK;
@@ -38,7 +40,7 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
/* wait for it to finish, this takes about 23 us on lite5200b */
while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries)
- udelay(5);
+ msleep(1);
if (!tries)
return -ETIMEDOUT;
@@ -64,7 +66,6 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
{
struct device *dev = &of->dev;
struct device_node *np = of->node;
- struct device_node *child = NULL;
struct mii_bus *bus;
struct mpc52xx_fec_mdio_priv *priv;
struct resource res = {};
@@ -85,22 +86,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
bus->write = mpc52xx_fec_mdio_write;
/* setup irqs */
- bus->irq = kmalloc(sizeof(bus->irq[0]) * PHY_MAX_ADDR, GFP_KERNEL);
- if (bus->irq == NULL) {
- err = -ENOMEM;
- goto out_free;
- }
- for (i=0; i<PHY_MAX_ADDR; i++)
- bus->irq[i] = PHY_POLL;
-
- while ((child = of_get_next_child(np, child)) != NULL) {
- int irq = irq_of_parse_and_map(child, 0);
- if (irq != NO_IRQ) {
- const u32 *id = of_get_property(child, "reg", NULL);
- if (id)
- bus->irq[*id] = irq;
- }
- }
+ bus->irq = priv->mdio_irqs;
/* setup registers */
err = of_address_to_resource(np, 0, &res);
@@ -122,7 +108,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
out_be32(&priv->regs->mii_speed,
((mpc52xx_find_ipb_freq(of->node) >> 20) / 5) << 1);
- err = mdiobus_register(bus);
+ err = of_mdiobus_register(bus, np);
if (err)
goto out_unmap;
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index f9a846b1b92f..d0b1d9f17a5d 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -343,6 +343,7 @@ enum {
#define NVREG_POWERSTATE2_POWERUP_MASK 0x0F15
#define NVREG_POWERSTATE2_POWERUP_REV_A3 0x0001
#define NVREG_POWERSTATE2_PHY_RESET 0x0004
+#define NVREG_POWERSTATE2_GATE_CLOCKS 0x0F00
};
/* Big endian: should work, but is untested */
@@ -1017,6 +1018,23 @@ static int using_multi_irqs(struct net_device *dev)
return 1;
}
+static void nv_txrx_gate(struct net_device *dev, bool gate)
+{
+ struct fe_priv *np = get_nvpriv(dev);
+ u8 __iomem *base = get_hwbase(dev);
+ u32 powerstate;
+
+ if (!np->mac_in_use &&
+ (np->driver_data & DEV_HAS_POWER_CNTRL)) {
+ powerstate = readl(base + NvRegPowerState2);
+ if (gate)
+ powerstate |= NVREG_POWERSTATE2_GATE_CLOCKS;
+ else
+ powerstate &= ~NVREG_POWERSTATE2_GATE_CLOCKS;
+ writel(powerstate, base + NvRegPowerState2);
+ }
+}
+
static void nv_enable_irq(struct net_device *dev)
{
struct fe_priv *np = get_nvpriv(dev);
@@ -3394,12 +3412,14 @@ static void nv_linkchange(struct net_device *dev)
if (!netif_carrier_ok(dev)) {
netif_carrier_on(dev);
printk(KERN_INFO "%s: link up.\n", dev->name);
+ nv_txrx_gate(dev, false);
nv_start_rx(dev);
}
} else {
if (netif_carrier_ok(dev)) {
netif_carrier_off(dev);
printk(KERN_INFO "%s: link down.\n", dev->name);
+ nv_txrx_gate(dev, true);
nv_stop_rx(dev);
}
}
@@ -5327,6 +5347,7 @@ static int nv_open(struct net_device *dev)
mii_rw(dev, np->phyaddr, MII_BMCR,
mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ) & ~BMCR_PDOWN);
+ nv_txrx_gate(dev, false);
/* erase previous misconfiguration */
if (np->driver_data & DEV_HAS_POWER_CNTRL)
nv_mac_reset(dev);
@@ -5514,12 +5535,14 @@ static int nv_close(struct net_device *dev)
nv_drain_rxtx(dev);
if (np->wolenabled) {
+ nv_txrx_gate(dev, false);
writel(NVREG_PFF_ALWAYS|NVREG_PFF_MYADDR, base + NvRegPacketFilterFlags);
nv_start_rx(dev);
} else {
/* power down phy */
mii_rw(dev, np->phyaddr, MII_BMCR,
mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ)|BMCR_PDOWN);
+ nv_txrx_gate(dev, true);
}
/* FIXME: power down nic */
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index a9cbc3191a2a..b892c3ad9a74 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -36,6 +36,8 @@
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <linux/phy.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
@@ -752,9 +754,10 @@ static int fs_init_phy(struct net_device *dev)
fep->oldlink = 0;
fep->oldspeed = 0;
fep->oldduplex = -1;
- if(fep->fpi->bus_id)
- phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0,
- PHY_INTERFACE_MODE_MII);
+ if(fep->fpi->phy_node)
+ phydev = of_phy_connect(dev, fep->fpi->phy_node,
+ &fs_adjust_link, 0,
+ PHY_INTERFACE_MODE_MII);
else {
printk("No phy bus ID specified in BSP code\n");
return -EINVAL;
@@ -938,81 +941,6 @@ extern void fs_mii_disconnect(struct net_device *dev);
/**************************************************************************************/
-/* handy pointer to the immap */
-void __iomem *fs_enet_immap = NULL;
-
-static int setup_immap(void)
-{
-#ifdef CONFIG_CPM1
- fs_enet_immap = ioremap(IMAP_ADDR, 0x4000);
- WARN_ON(!fs_enet_immap);
-#elif defined(CONFIG_CPM2)
- fs_enet_immap = cpm2_immr;
-#endif
-
- return 0;
-}
-
-static void cleanup_immap(void)
-{
-#if defined(CONFIG_CPM1)
- iounmap(fs_enet_immap);
-#endif
-}
-
-/**************************************************************************************/
-
-static int __devinit find_phy(struct device_node *np,
- struct fs_platform_info *fpi)
-{
- struct device_node *phynode, *mdionode;
- int ret = 0, len, bus_id;
- const u32 *data;
-
- data = of_get_property(np, "fixed-link", NULL);
- if (data) {
- snprintf(fpi->bus_id, 16, "%x:%02x", 0, *data);
- return 0;
- }
-
- data = of_get_property(np, "phy-handle", &len);
- if (!data || len != 4)
- return -EINVAL;
-
- phynode = of_find_node_by_phandle(*data);
- if (!phynode)
- return -EINVAL;
-
- data = of_get_property(phynode, "reg", &len);
- if (!data || len != 4) {
- ret = -EINVAL;
- goto out_put_phy;
- }
-
- mdionode = of_get_parent(phynode);
- if (!mdionode) {
- ret = -EINVAL;
- goto out_put_phy;
- }
-
- bus_id = of_get_gpio(mdionode, 0);
- if (bus_id < 0) {
- struct resource res;
- ret = of_address_to_resource(mdionode, 0, &res);
- if (ret)
- goto out_put_mdio;
- bus_id = res.start;
- }
-
- snprintf(fpi->bus_id, 16, "%x:%02x", bus_id, *data);
-
-out_put_mdio:
- of_node_put(mdionode);
-out_put_phy:
- of_node_put(phynode);
- return ret;
-}
-
#ifdef CONFIG_FS_ENET_HAS_FEC
#define IS_FEC(match) ((match)->data == &fs_fec_ops)
#else
@@ -1062,9 +990,9 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
fpi->rx_copybreak = 240;
fpi->use_napi = 1;
fpi->napi_weight = 17;
-
- ret = find_phy(ofdev->node, fpi);
- if (ret)
+ fpi->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0);
+ if ((!fpi->phy_node) && (!of_get_property(ofdev->node, "fixed-link",
+ NULL)))
goto out_free_fpi;
privsize = sizeof(*fep) +
@@ -1136,6 +1064,7 @@ out_cleanup_data:
out_free_dev:
free_netdev(ndev);
dev_set_drvdata(&ofdev->dev, NULL);
+ of_node_put(fpi->phy_node);
out_free_fpi:
kfree(fpi);
return ret;
@@ -1151,7 +1080,7 @@ static int fs_enet_remove(struct of_device *ofdev)
fep->ops->free_bd(ndev);
fep->ops->cleanup_data(ndev);
dev_set_drvdata(fep->dev, NULL);
-
+ of_node_put(fep->fpi->phy_node);
free_netdev(ndev);
return 0;
}
@@ -1191,25 +1120,12 @@ static struct of_platform_driver fs_enet_driver = {
static int __init fs_init(void)
{
- int r = setup_immap();
- if (r != 0)
- return r;
-
- r = of_register_platform_driver(&fs_enet_driver);
- if (r != 0)
- goto out;
-
- return 0;
-
-out:
- cleanup_immap();
- return r;
+ return of_register_platform_driver(&fs_enet_driver);
}
static void __exit fs_cleanup(void)
{
of_unregister_platform_driver(&fs_enet_driver);
- cleanup_immap();
}
#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h
index 85a4bab7f630..ef01e09781a5 100644
--- a/drivers/net/fs_enet/fs_enet.h
+++ b/drivers/net/fs_enet/fs_enet.h
@@ -194,9 +194,4 @@ extern const struct fs_ops fs_scc_ops;
/*******************************************************************/
-/* handy pointer to the immap */
-extern void __iomem *fs_enet_immap;
-
-/*******************************************************************/
-
#endif
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 14e575313c89..ca7bcb8ab3a1 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -245,10 +245,6 @@ static void set_multicast_list(struct net_device *dev)
static void restart(struct net_device *dev)
{
-#ifdef CONFIG_DUET
- immap_t *immap = fs_enet_immap;
- u32 cptr;
-#endif
struct fs_enet_private *fep = netdev_priv(dev);
fec_t __iomem *fecp = fep->fec.fecp;
const struct fs_platform_info *fpi = fep->fpi;
@@ -315,36 +311,6 @@ static void restart(struct net_device *dev)
FW(fecp, ievent, 0xffc0);
FW(fecp, ivec, (virq_to_hw(fep->interrupt) / 2) << 29);
- /*
- * adjust to speed (only for DUET & RMII)
- */
-#ifdef CONFIG_DUET
- if (fpi->use_rmii) {
- cptr = in_be32(&immap->im_cpm.cp_cptr);
- switch (fs_get_fec_index(fpi->fs_no)) {
- case 0:
- cptr |= 0x100;
- if (fep->speed == 10)
- cptr |= 0x0000010;
- else if (fep->speed == 100)
- cptr &= ~0x0000010;
- break;
- case 1:
- cptr |= 0x80;
- if (fep->speed == 10)
- cptr |= 0x0000008;
- else if (fep->speed == 100)
- cptr &= ~0x0000008;
- break;
- default:
- BUG(); /* should never happen */
- break;
- }
- out_be32(&immap->im_cpm.cp_cptr, cptr);
- }
-#endif
-
-
FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */
/*
* adjust to duplex mode
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c
index 49b6645d7e0c..93b481b0e3c7 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -22,6 +22,7 @@
#include <linux/mii.h>
#include <linux/platform_device.h>
#include <linux/mdio-bitbang.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include "fs_enet.h"
@@ -149,31 +150,12 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus *bus,
return 0;
}
-static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
-{
- const u32 *data;
- int len, id, irq;
-
- data = of_get_property(np, "reg", &len);
- if (!data || len != 4)
- return;
-
- id = *data;
- bus->phy_mask &= ~(1 << id);
-
- irq = of_irq_to_resource(np, 0, NULL);
- if (irq != NO_IRQ)
- bus->irq[id] = irq;
-}
-
static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
const struct of_device_id *match)
{
- struct device_node *np = NULL;
struct mii_bus *new_bus;
struct bb_info *bitbang;
int ret = -ENOMEM;
- int i;
bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL);
if (!bitbang)
@@ -196,17 +178,10 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
if (!new_bus->irq)
goto out_unmap_regs;
- for (i = 0; i < PHY_MAX_ADDR; i++)
- new_bus->irq[i] = -1;
-
- while ((np = of_get_next_child(ofdev->node, np)))
- if (!strcmp(np->type, "ethernet-phy"))
- add_phy(new_bus, np);
-
new_bus->parent = &ofdev->dev;
dev_set_drvdata(&ofdev->dev, new_bus);
- ret = mdiobus_register(new_bus);
+ ret = of_mdiobus_register(new_bus, ofdev->node);
if (ret)
goto out_free_irqs;
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 28077cc1b949..75a09994d665 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -54,8 +54,7 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
fec_t __iomem *fecp = fec->fecp;
int i, ret = -1;
- if ((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0)
- BUG();
+ BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
/* Add PHY address to register command. */
out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_read(location));
@@ -79,8 +78,7 @@ static int fs_enet_fec_mii_write(struct mii_bus *bus, int phy_id, int location,
int i;
/* this must never happen */
- if ((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0)
- BUG();
+ BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
/* Add PHY address to register command. */
out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_write(location, val));
@@ -102,23 +100,6 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus)
return 0;
}
-static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
-{
- const u32 *data;
- int len, id, irq;
-
- data = of_get_property(np, "reg", &len);
- if (!data || len != 4)
- return;
-
- id = *data;
- bus->phy_mask &= ~(1 << id);
-
- irq = of_irq_to_resource(np, 0, NULL);
- if (irq != NO_IRQ)
- bus->irq[id] = irq;
-}
-
static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
const struct of_device_id *match)
{
@@ -165,17 +146,10 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
if (!new_bus->irq)
goto out_unmap_regs;
- for (i = 0; i < PHY_MAX_ADDR; i++)
- new_bus->irq[i] = -1;
-
- while ((np = of_get_next_child(ofdev->node, np)))
- if (!strcmp(np->type, "ethernet-phy"))
- add_phy(new_bus, np);
-
new_bus->parent = &ofdev->dev;
dev_set_drvdata(&ofdev->dev, new_bus);
- ret = mdiobus_register(new_bus);
+ ret = of_mdiobus_register(new_bus, ofdev->node);
if (ret)
goto out_free_irqs;
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index aa1eb88c21fc..d12e0e0336f4 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -34,6 +34,7 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <asm/io.h>
@@ -154,44 +155,6 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
return 0;
}
-/* Allocate an array which provides irq #s for each PHY on the given bus */
-static int *create_irq_map(struct device_node *np)
-{
- int *irqs;
- int i;
- struct device_node *child = NULL;
-
- irqs = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
-
- if (!irqs)
- return NULL;
-
- for (i = 0; i < PHY_MAX_ADDR; i++)
- irqs[i] = PHY_POLL;
-
- while ((child = of_get_next_child(np, child)) != NULL) {
- int irq = irq_of_parse_and_map(child, 0);
- const u32 *id;
-
- if (irq == NO_IRQ)
- continue;
-
- id = of_get_property(child, "reg", NULL);
-
- if (!id)
- continue;
-
- if (*id < PHY_MAX_ADDR && *id >= 0)
- irqs[*id] = irq;
- else
- printk(KERN_WARNING "%s: "
- "%d is not a valid PHY address\n",
- np->full_name, *id);
- }
-
- return irqs;
-}
-
void fsl_pq_mdio_bus_name(char *name, struct device_node *np)
{
const u32 *addr;
@@ -315,7 +278,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
new_bus->priv = (void __force *)regs;
- new_bus->irq = create_irq_map(np);
+ new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
if (NULL == new_bus->irq) {
err = -ENOMEM;
@@ -384,15 +347,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
out_be32(tbipa, tbiaddr);
- /*
- * The TBIPHY-only buses will find PHYs at every address,
- * so we mask them all but the TBI
- */
- if (of_device_is_compatible(np, "fsl,gianfar-tbi"))
- new_bus->phy_mask = ~(1 << tbiaddr);
-
- err = mdiobus_register(new_bus);
-
+ err = of_mdiobus_register(new_bus, np);
if (err) {
printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
new_bus->name);
@@ -460,10 +415,10 @@ int __init fsl_pq_mdio_init(void)
{
return of_register_platform_driver(&fsl_pq_mdio_driver);
}
+module_init(fsl_pq_mdio_init);
void fsl_pq_mdio_exit(void)
{
of_unregister_platform_driver(&fsl_pq_mdio_driver);
}
-subsys_initcall_sync(fsl_pq_mdio_init);
module_exit(fsl_pq_mdio_exit);
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b2c49679bba7..4ae1d259fced 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -75,6 +75,7 @@
#include <linux/if_vlan.h>
#include <linux/spinlock.h>
#include <linux/mm.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <linux/ip.h>
#include <linux/tcp.h>
@@ -168,17 +169,13 @@ static inline int gfar_uses_fcb(struct gfar_private *priv)
static int gfar_of_init(struct net_device *dev)
{
- struct device_node *phy, *mdio;
- const unsigned int *id;
const char *model;
const char *ctype;
const void *mac_addr;
- const phandle *ph;
u64 addr, size;
int err = 0;
struct gfar_private *priv = netdev_priv(dev);
struct device_node *np = priv->node;
- char bus_name[MII_BUS_ID_SIZE];
const u32 *stash;
const u32 *stash_len;
const u32 *stash_idx;
@@ -264,8 +261,8 @@ static int gfar_of_init(struct net_device *dev)
if (of_get_property(np, "fsl,magic-packet", NULL))
priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
- ph = of_get_property(np, "phy-handle", NULL);
- if (ph == NULL) {
+ priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
+ if (!priv->phy_node) {
u32 *fixed_link;
fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL);
@@ -273,57 +270,10 @@ static int gfar_of_init(struct net_device *dev)
err = -ENODEV;
goto err_out;
}
-
- snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id),
- PHY_ID_FMT, "0", fixed_link[0]);
- } else {
- phy = of_find_node_by_phandle(*ph);
-
- if (phy == NULL) {
- err = -ENODEV;
- goto err_out;
- }
-
- mdio = of_get_parent(phy);
-
- id = of_get_property(phy, "reg", NULL);
-
- of_node_put(phy);
-
- fsl_pq_mdio_bus_name(bus_name, mdio);
- of_node_put(mdio);
- snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id), "%s:%02x",
- bus_name, *id);
}
/* Find the TBI PHY. If it's not there, we don't support SGMII */
- ph = of_get_property(np, "tbi-handle", NULL);
- if (ph) {
- struct device_node *tbi = of_find_node_by_phandle(*ph);
- struct of_device *ofdev;
- struct mii_bus *bus;
-
- if (!tbi)
- return 0;
-
- mdio = of_get_parent(tbi);
- if (!mdio)
- return 0;
-
- ofdev = of_find_device_by_node(mdio);
-
- of_node_put(mdio);
-
- id = of_get_property(tbi, "reg", NULL);
- if (!id)
- return 0;
-
- of_node_put(tbi);
-
- bus = dev_get_drvdata(&ofdev->dev);
-
- priv->tbiphy = bus->phy_map[*id];
- }
+ priv->tbi_node = of_parse_phandle(np, "tbi-handle", 0);
return 0;
@@ -529,6 +479,10 @@ static int gfar_probe(struct of_device *ofdev,
register_fail:
iounmap(priv->regs);
regs_fail:
+ if (priv->phy_node)
+ of_node_put(priv->phy_node);
+ if (priv->tbi_node)
+ of_node_put(priv->tbi_node);
free_netdev(dev);
return err;
}
@@ -537,6 +491,11 @@ static int gfar_remove(struct of_device *ofdev)
{
struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
+ if (priv->phy_node)
+ of_node_put(priv->phy_node);
+ if (priv->tbi_node)
+ of_node_put(priv->tbi_node);
+
dev_set_drvdata(&ofdev->dev, NULL);
iounmap(priv->regs);
@@ -690,7 +649,6 @@ static int init_phy(struct net_device *dev)
uint gigabit_support =
priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
SUPPORTED_1000baseT_Full : 0;
- struct phy_device *phydev;
phy_interface_t interface;
priv->oldlink = 0;
@@ -699,21 +657,21 @@ static int init_phy(struct net_device *dev)
interface = gfar_get_interface(dev);
- phydev = phy_connect(dev, priv->phy_bus_id, &adjust_link, 0, interface);
+ if (priv->phy_node) {
+ priv->phydev = of_phy_connect(dev, priv->phy_node, &adjust_link,
+ 0, interface);
+ if (!priv->phydev) {
+ dev_err(&dev->dev, "error: Could not attach to PHY\n");
+ return -ENODEV;
+ }
+ }
if (interface == PHY_INTERFACE_MODE_SGMII)
gfar_configure_serdes(dev);
- if (IS_ERR(phydev)) {
- printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
- return PTR_ERR(phydev);
- }
-
/* Remove any features not supported by the controller */
- phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
- phydev->advertising = phydev->supported;
-
- priv->phydev = phydev;
+ priv->phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
+ priv->phydev->advertising = priv->phydev->supported;
return 0;
}
@@ -730,10 +688,17 @@ static int init_phy(struct net_device *dev)
static void gfar_configure_serdes(struct net_device *dev)
{
struct gfar_private *priv = netdev_priv(dev);
+ struct phy_device *tbiphy;
- if (!priv->tbiphy) {
- printk(KERN_WARNING "SGMII mode requires that the device "
- "tree specify a tbi-handle\n");
+ if (!priv->tbi_node) {
+ dev_warn(&dev->dev, "error: SGMII mode requires that the "
+ "device tree specify a tbi-handle\n");
+ return;
+ }
+
+ tbiphy = of_phy_find_device(priv->tbi_node);
+ if (!tbiphy) {
+ dev_err(&dev->dev, "error: Could not get TBI device\n");
return;
}
@@ -743,17 +708,17 @@ static void gfar_configure_serdes(struct net_device *dev)
* everything for us? Resetting it takes the link down and requires
* several seconds for it to come back.
*/
- if (phy_read(priv->tbiphy, MII_BMSR) & BMSR_LSTATUS)
+ if (phy_read(tbiphy, MII_BMSR) & BMSR_LSTATUS)
return;
/* Single clk mode, mii mode off(for serdes communication) */
- phy_write(priv->tbiphy, MII_TBICON, TBICON_CLK_SELECT);
+ phy_write(tbiphy, MII_TBICON, TBICON_CLK_SELECT);
- phy_write(priv->tbiphy, MII_ADVERTISE,
+ phy_write(tbiphy, MII_ADVERTISE,
ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
ADVERTISE_1000XPSE_ASYM);
- phy_write(priv->tbiphy, MII_BMCR, BMCR_ANENABLE |
+ phy_write(tbiphy, MII_BMCR, BMCR_ANENABLE |
BMCR_ANRESTART | BMCR_FULLDPLX | BMCR_SPEED1000);
}
@@ -1242,7 +1207,8 @@ static int gfar_enet_open(struct net_device *dev)
static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
{
struct txfcb *fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
- cacheable_memzero(fcb, GMAC_FCB_LEN);
+
+ memset(fcb, 0, GMAC_FCB_LEN);
return fcb;
}
@@ -1885,8 +1851,17 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
if (unlikely(!newskb))
newskb = skb;
- else if (skb)
+ else if (skb) {
+ /*
+ * We need to reset ->data to what it
+ * was before gfar_new_skb() re-aligned
+ * it to an RXBUF_ALIGNMENT boundary
+ * before we put the skb back on the
+ * recycle list.
+ */
+ skb->data = skb->head + NET_SKB_PAD;
__skb_queue_head(&priv->rx_recycle, skb);
+ }
} else {
/* Increment the number of packets */
dev->stats.rx_packets++;
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 0642d52aef5c..91317bc11154 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -779,7 +779,8 @@ struct gfar_private {
spinlock_t bflock;
phy_interface_t interface;
- char phy_bus_id[BUS_ID_SIZE];
+ struct device_node *phy_node;
+ struct device_node *tbi_node;
u32 device_flags;
unsigned char rx_csum_enable:1,
extended_hash:1,
@@ -793,7 +794,6 @@ struct gfar_private {
/* PHY stuff */
struct phy_device *phydev;
- struct phy_device *tbiphy;
struct mii_bus *mii_bus;
int oldspeed;
int oldduplex;
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index de3f49f991a3..8feda9fe8297 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -2864,7 +2864,7 @@ static int __init hp100_eisa_probe (struct device *gendev)
printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name,
dev->base_addr);
#endif
- gendev->driver_data = dev;
+ dev_set_drvdata(gendev, dev);
return 0;
out1:
free_netdev(dev);
@@ -2873,7 +2873,7 @@ static int __init hp100_eisa_probe (struct device *gendev)
static int __devexit hp100_eisa_remove (struct device *gendev)
{
- struct net_device *dev = gendev->driver_data;
+ struct net_device *dev = dev_get_drvdata(gendev);
cleanup_dev(dev);
return 0;
}
diff --git a/drivers/net/hplance.c b/drivers/net/hplance.c
index 2e802634d366..3e3528ade259 100644
--- a/drivers/net/hplance.c
+++ b/drivers/net/hplance.c
@@ -71,6 +71,19 @@ static struct dio_driver hplance_driver = {
.remove = __devexit_p(hplance_remove_one),
};
+static const struct net_device_ops hplance_netdev_ops = {
+ .ndo_open = hplance_open,
+ .ndo_stop = hplance_close,
+ .ndo_start_xmit = lance_start_xmit,
+ .ndo_set_multicast_list = lance_set_multicast,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = lance_poll,
+#endif
+};
+
/* Find all the HP Lance boards and initialise them... */
static int __devinit hplance_init_one(struct dio_dev *d,
const struct dio_device_id *ent)
@@ -135,13 +148,7 @@ static void __init hplance_init(struct net_device *dev, struct dio_dev *d)
/* Fill the dev fields */
dev->base_addr = va;
- dev->open = &hplance_open;
- dev->stop = &hplance_close;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = lance_poll;
-#endif
- dev->hard_start_xmit = &lance_start_xmit;
- dev->set_multicast_list = &lance_set_multicast;
+ dev->netdev_ops = &hplance_netdev_ops;
dev->dma = 0;
for (i=0; i<6; i++) {
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 5c6315df86b9..0995c438f286 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1203,6 +1203,20 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev)
return ret;
}
+static const struct net_device_ops ibmveth_netdev_ops = {
+ .ndo_open = ibmveth_open,
+ .ndo_stop = ibmveth_close,
+ .ndo_start_xmit = ibmveth_start_xmit,
+ .ndo_set_multicast_list = ibmveth_set_multicast_list,
+ .ndo_do_ioctl = ibmveth_ioctl,
+ .ndo_change_mtu = ibmveth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = ibmveth_poll_controller,
+#endif
+};
+
static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
{
int rc, i;
@@ -1241,7 +1255,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
return -ENOMEM;
adapter = netdev_priv(netdev);
- dev->dev.driver_data = netdev;
+ dev_set_drvdata(&dev->dev, netdev);
adapter->vdev = dev;
adapter->netdev = netdev;
@@ -1265,21 +1279,13 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
memcpy(&adapter->mac_addr, mac_addr_p, 6);
netdev->irq = dev->irq;
- netdev->open = ibmveth_open;
- netdev->stop = ibmveth_close;
- netdev->hard_start_xmit = ibmveth_start_xmit;
- netdev->set_multicast_list = ibmveth_set_multicast_list;
- netdev->do_ioctl = ibmveth_ioctl;
- netdev->ethtool_ops = &netdev_ethtool_ops;
- netdev->change_mtu = ibmveth_change_mtu;
+ netdev->netdev_ops = &ibmveth_netdev_ops;
+ netdev->ethtool_ops = &netdev_ethtool_ops;
SET_NETDEV_DEV(netdev, &dev->dev);
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = ibmveth_poll_controller;
-#endif
netdev->features |= NETIF_F_LLTX;
spin_lock_init(&adapter->stats_lock);
- memcpy(&netdev->dev_addr, &adapter->mac_addr, netdev->addr_len);
+ memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len);
for(i = 0; i<IbmVethNumBufferPools; i++) {
struct kobject *kobj = &adapter->rx_buff_pool[i].kobj;
@@ -1335,7 +1341,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
static int __devexit ibmveth_remove(struct vio_dev *dev)
{
- struct net_device *netdev = dev->dev.driver_data;
+ struct net_device *netdev = dev_get_drvdata(&dev->dev);
struct ibmveth_adapter *adapter = netdev_priv(netdev);
int i;
@@ -1368,8 +1374,8 @@ static void ibmveth_proc_unregister_driver(void)
static int ibmveth_show(struct seq_file *seq, void *v)
{
struct ibmveth_adapter *adapter = seq->private;
- char *current_mac = ((char*) &adapter->netdev->dev_addr);
- char *firmware_mac = ((char*) &adapter->mac_addr) ;
+ char *current_mac = (char *) adapter->netdev->dev_addr;
+ char *firmware_mac = (char *) &adapter->mac_addr;
seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version);
@@ -1468,8 +1474,8 @@ const char * buf, size_t count)
struct ibmveth_buff_pool *pool = container_of(kobj,
struct ibmveth_buff_pool,
kobj);
- struct net_device *netdev =
- container_of(kobj->parent, struct device, kobj)->driver_data;
+ struct net_device *netdev = dev_get_drvdata(
+ container_of(kobj->parent, struct device, kobj));
struct ibmveth_adapter *adapter = netdev_priv(netdev);
long value = simple_strtol(buf, NULL, 10);
long rc;
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 60a263001933..96713ef06298 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -156,6 +156,7 @@ static void ifb_setup(struct net_device *dev)
dev->flags |= IFF_NOARP;
dev->flags &= ~IFF_MULTICAST;
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
random_ether_addr(dev->dev_addr);
}
diff --git a/drivers/net/igb/e1000_82575.h b/drivers/net/igb/e1000_82575.h
index eaf977050368..0f16abab2565 100644
--- a/drivers/net/igb/e1000_82575.h
+++ b/drivers/net/igb/e1000_82575.h
@@ -130,6 +130,7 @@ struct e1000_adv_tx_context_desc {
#define E1000_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */
#define E1000_ADVTXD_TUCMD_IPV4 0x00000400 /* IP Packet Type: 1=IPv4 */
#define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800 /* L4 Packet TYPE of TCP */
+#define E1000_ADVTXD_TUCMD_L4T_SCTP 0x00001000 /* L4 packet TYPE of SCTP */
/* IPSec Encrypt Enable for ESP */
#define E1000_ADVTXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */
#define E1000_ADVTXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */
diff --git a/drivers/net/igb/e1000_defines.h b/drivers/net/igb/e1000_defines.h
index ad2d319d0f8b..3bda3db73f1f 100644
--- a/drivers/net/igb/e1000_defines.h
+++ b/drivers/net/igb/e1000_defines.h
@@ -289,8 +289,9 @@
#define E1000_SCTL_DISABLE_SERDES_LOOPBACK 0x0400
/* Receive Checksum Control */
+#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */
#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */
-#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */
+#define E1000_RXCSUM_CRCOFL 0x00000800 /* CRC32 offload enable */
#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */
/* Header split receive */
diff --git a/drivers/net/igb/e1000_mbx.c b/drivers/net/igb/e1000_mbx.c
index 840782fb5736..ed9058eca45c 100644
--- a/drivers/net/igb/e1000_mbx.c
+++ b/drivers/net/igb/e1000_mbx.c
@@ -140,13 +140,13 @@ static s32 igb_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)
struct e1000_mbx_info *mbx = &hw->mbx;
int countdown = mbx->timeout;
- if (!mbx->ops.check_for_msg)
+ if (!countdown || !mbx->ops.check_for_msg)
goto out;
while (mbx->ops.check_for_msg(hw, mbx_id)) {
+ countdown--;
if (!countdown)
break;
- countdown--;
udelay(mbx->usec_delay);
}
out:
@@ -165,13 +165,13 @@ static s32 igb_poll_for_ack(struct e1000_hw *hw, u16 mbx_id)
struct e1000_mbx_info *mbx = &hw->mbx;
int countdown = mbx->timeout;
- if (!mbx->ops.check_for_ack)
+ if (!countdown || !mbx->ops.check_for_ack)
goto out;
while (mbx->ops.check_for_ack(hw, mbx_id)) {
+ countdown--;
if (!countdown)
break;
- countdown--;
udelay(mbx->usec_delay);
}
out:
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 4e8464b9df2e..154c5acc6fce 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -238,7 +238,6 @@ struct igb_adapter {
u64 hw_csum_err;
u64 hw_csum_good;
u32 alloc_rx_buff_failed;
- bool rx_csum;
u32 gorc;
u64 gorc_old;
u16 rx_ps_hdr_size;
@@ -286,6 +285,7 @@ struct igb_adapter {
#define IGB_FLAG_DCA_ENABLED (1 << 1)
#define IGB_FLAG_QUAD_PORT_A (1 << 2)
#define IGB_FLAG_NEED_CTX_IDX (1 << 3)
+#define IGB_FLAG_RX_CSUM_DISABLED (1 << 4)
enum e1000_state_t {
__IGB_TESTING,
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index 27eae49e79c2..b8551a57dd3f 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -275,13 +275,17 @@ static int igb_set_pauseparam(struct net_device *netdev,
static u32 igb_get_rx_csum(struct net_device *netdev)
{
struct igb_adapter *adapter = netdev_priv(netdev);
- return adapter->rx_csum;
+ return !(adapter->flags & IGB_FLAG_RX_CSUM_DISABLED);
}
static int igb_set_rx_csum(struct net_device *netdev, u32 data)
{
struct igb_adapter *adapter = netdev_priv(netdev);
- adapter->rx_csum = data;
+
+ if (data)
+ adapter->flags &= ~IGB_FLAG_RX_CSUM_DISABLED;
+ else
+ adapter->flags |= IGB_FLAG_RX_CSUM_DISABLED;
return 0;
}
@@ -293,10 +297,16 @@ static u32 igb_get_tx_csum(struct net_device *netdev)
static int igb_set_tx_csum(struct net_device *netdev, u32 data)
{
- if (data)
+ struct igb_adapter *adapter = netdev_priv(netdev);
+
+ if (data) {
netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
- else
- netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+ if (adapter->hw.mac.type == e1000_82576)
+ netdev->features |= NETIF_F_SCTP_CSUM;
+ } else {
+ netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+ NETIF_F_SCTP_CSUM);
+ }
return 0;
}
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index e25343588fc7..2ec98091948b 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -942,6 +942,8 @@ int igb_up(struct igb_adapter *adapter)
rd32(E1000_ICR);
igb_irq_enable(adapter);
+ netif_tx_start_all_queues(adapter->netdev);
+
/* Fire a link change interrupt to start the watchdog. */
wr32(E1000_ICS, E1000_ICS_LSC);
return 0;
@@ -994,6 +996,11 @@ void igb_down(struct igb_adapter *adapter)
igb_reset(adapter);
igb_clean_all_tx_rings(adapter);
igb_clean_all_rx_rings(adapter);
+#ifdef CONFIG_IGB_DCA
+
+ /* since we reset the hardware DCA settings were cleared */
+ igb_setup_dca(adapter);
+#endif
}
void igb_reinit_locked(struct igb_adapter *adapter)
@@ -1343,6 +1350,9 @@ static int __devinit igb_probe(struct pci_dev *pdev,
if (pci_using_dac)
netdev->features |= NETIF_F_HIGHDMA;
+ if (adapter->hw.mac.type == e1000_82576)
+ netdev->features |= NETIF_F_SCTP_CSUM;
+
adapter->en_mng_pt = igb_enable_mng_pass_thru(&adapter->hw);
/* before reading the NVM, reset the controller to put the device in a
@@ -1390,8 +1400,6 @@ static int __devinit igb_probe(struct pci_dev *pdev,
igb_validate_mdi_setting(hw);
- adapter->rx_csum = 1;
-
/* Initial Wake on LAN setting If APM wake is enabled in the EEPROM,
* enable the ACPI Magic Packet filter
*/
@@ -1442,22 +1450,18 @@ static int __devinit igb_probe(struct pci_dev *pdev,
* driver. */
igb_get_hw_control(adapter);
- /* tell the stack to leave us alone until igb_open() is called */
- netif_carrier_off(netdev);
- netif_tx_stop_all_queues(netdev);
-
strcpy(netdev->name, "eth%d");
err = register_netdev(netdev);
if (err)
goto err_register;
+ /* carrier off reporting is important to ethtool even BEFORE open */
+ netif_carrier_off(netdev);
+
#ifdef CONFIG_IGB_DCA
if (dca_add_requester(&pdev->dev) == 0) {
adapter->flags |= IGB_FLAG_DCA_ENABLED;
dev_info(&pdev->dev, "DCA enabled\n");
- /* Always use CB2 mode, difference is masked
- * in the CB driver. */
- wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_CB2);
igb_setup_dca(adapter);
}
#endif
@@ -1699,6 +1703,8 @@ static int igb_open(struct net_device *netdev)
if (test_bit(__IGB_TESTING, &adapter->state))
return -EBUSY;
+ netif_carrier_off(netdev);
+
/* allocate transmit descriptors */
err = igb_setup_all_tx_resources(adapter);
if (err)
@@ -2231,29 +2237,24 @@ static void igb_configure_rx(struct igb_adapter *adapter)
mrqc |= (E1000_MRQC_RSS_FIELD_IPV6_UDP_EX |
E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
-
wr32(E1000_MRQC, mrqc);
-
- /* Multiqueue and raw packet checksumming are mutually
- * exclusive. Note that this not the same as TCP/IP
- * checksumming, which works fine. */
- rxcsum = rd32(E1000_RXCSUM);
- rxcsum |= E1000_RXCSUM_PCSD;
- wr32(E1000_RXCSUM, rxcsum);
- } else {
+ } else if (adapter->vfs_allocated_count) {
/* Enable multi-queue for sr-iov */
- if (adapter->vfs_allocated_count)
- wr32(E1000_MRQC, E1000_MRQC_ENABLE_VMDQ);
- /* Enable Receive Checksum Offload for TCP and UDP */
- rxcsum = rd32(E1000_RXCSUM);
- if (adapter->rx_csum)
- rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPPCSE;
- else
- rxcsum &= ~(E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPPCSE);
-
- wr32(E1000_RXCSUM, rxcsum);
+ wr32(E1000_MRQC, E1000_MRQC_ENABLE_VMDQ);
}
+ /* Enable Receive Checksum Offload for TCP and UDP */
+ rxcsum = rd32(E1000_RXCSUM);
+ /* Disable raw packet checksumming */
+ rxcsum |= E1000_RXCSUM_PCSD;
+
+ if (adapter->hw.mac.type == e1000_82576)
+ /* Enable Receive Checksum Offload for SCTP */
+ rxcsum |= E1000_RXCSUM_CRCOFL;
+
+ /* Don't need to set TUOFL or IPOFL, they default to 1 */
+ wr32(E1000_RXCSUM, rxcsum);
+
/* Set the default pool for the PF's first queue */
igb_configure_vt_default_pool(adapter);
@@ -2661,7 +2662,6 @@ static void igb_watchdog_task(struct work_struct *work)
}
netif_carrier_on(netdev);
- netif_tx_wake_all_queues(netdev);
igb_ping_all_vfs(adapter);
@@ -2678,7 +2678,6 @@ static void igb_watchdog_task(struct work_struct *work)
printk(KERN_INFO "igb: %s NIC Link is Down\n",
netdev->name);
netif_carrier_off(netdev);
- netif_tx_stop_all_queues(netdev);
igb_ping_all_vfs(adapter);
@@ -2712,6 +2711,8 @@ link_up:
* (Do the reset outside of interrupt context). */
adapter->tx_timeout_count++;
schedule_work(&adapter->reset_task);
+ /* return immediately since reset is imminent */
+ return;
}
}
@@ -2895,13 +2896,13 @@ static void igb_set_itr(struct igb_adapter *adapter)
switch (current_itr) {
/* counts and packets in update_itr are dependent on these numbers */
case lowest_latency:
- new_itr = 70000;
+ new_itr = 56; /* aka 70,000 ints/sec */
break;
case low_latency:
- new_itr = 20000; /* aka hwitr = ~200 */
+ new_itr = 196; /* aka 20,000 ints/sec */
break;
case bulk_latency:
- new_itr = 4000;
+ new_itr = 980; /* aka 4,000 ints/sec */
break;
default:
break;
@@ -2920,7 +2921,8 @@ set_itr_now:
* by adding intermediate steps when interrupt rate is
* increasing */
new_itr = new_itr > adapter->itr ?
- min(adapter->itr + (new_itr >> 2), new_itr) :
+ max((new_itr * adapter->itr) /
+ (new_itr + (adapter->itr >> 2)), new_itr) :
new_itr;
/* Don't write the value here; it resets the adapter's
* internal timer, and causes us to delay far longer than
@@ -2929,7 +2931,7 @@ set_itr_now:
* ends up being correct.
*/
adapter->itr = new_itr;
- adapter->rx_ring->itr_val = 1000000000 / (new_itr * 256);
+ adapter->rx_ring->itr_val = new_itr;
adapter->rx_ring->set_itr = 1;
}
@@ -3068,11 +3070,15 @@ static inline bool igb_tx_csum_adv(struct igb_adapter *adapter,
tu_cmd |= E1000_ADVTXD_TUCMD_IPV4;
if (ip_hdr(skb)->protocol == IPPROTO_TCP)
tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
+ else if (ip_hdr(skb)->protocol == IPPROTO_SCTP)
+ tu_cmd |= E1000_ADVTXD_TUCMD_L4T_SCTP;
break;
case cpu_to_be16(ETH_P_IPV6):
/* XXX what about other V6 headers?? */
if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
+ else if (ipv6_hdr(skb)->nexthdr == IPPROTO_SCTP)
+ tu_cmd |= E1000_ADVTXD_TUCMD_L4T_SCTP;
break;
default:
if (unlikely(net_ratelimit()))
@@ -3767,11 +3773,15 @@ static void igb_update_tx_dca(struct igb_ring *tx_ring)
static void igb_setup_dca(struct igb_adapter *adapter)
{
+ struct e1000_hw *hw = &adapter->hw;
int i;
if (!(adapter->flags & IGB_FLAG_DCA_ENABLED))
return;
+ /* Always use CB2 mode, difference is masked in the CB driver. */
+ wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_CB2);
+
for (i = 0; i < adapter->num_tx_queues; i++) {
adapter->tx_ring[i].cpu = -1;
igb_update_tx_dca(&adapter->tx_ring[i]);
@@ -4434,20 +4444,12 @@ static void igb_receive_skb(struct igb_ring *ring, u8 status,
bool vlan_extracted = (adapter->vlgrp && (status & E1000_RXD_STAT_VP));
skb_record_rx_queue(skb, ring->queue_index);
- if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
- if (vlan_extracted)
- vlan_gro_receive(&ring->napi, adapter->vlgrp,
- le16_to_cpu(rx_desc->wb.upper.vlan),
- skb);
- else
- napi_gro_receive(&ring->napi, skb);
- } else {
- if (vlan_extracted)
- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
- le16_to_cpu(rx_desc->wb.upper.vlan));
- else
- netif_receive_skb(skb);
- }
+ if (vlan_extracted)
+ vlan_gro_receive(&ring->napi, adapter->vlgrp,
+ le16_to_cpu(rx_desc->wb.upper.vlan),
+ skb);
+ else
+ napi_gro_receive(&ring->napi, skb);
}
static inline void igb_rx_checksum_adv(struct igb_adapter *adapter,
@@ -4456,19 +4458,28 @@ static inline void igb_rx_checksum_adv(struct igb_adapter *adapter,
skb->ip_summed = CHECKSUM_NONE;
/* Ignore Checksum bit is set or checksum is disabled through ethtool */
- if ((status_err & E1000_RXD_STAT_IXSM) || !adapter->rx_csum)
+ if ((status_err & E1000_RXD_STAT_IXSM) ||
+ (adapter->flags & IGB_FLAG_RX_CSUM_DISABLED))
return;
/* TCP/UDP checksum error bit is set */
if (status_err &
(E1000_RXDEXT_STATERR_TCPE | E1000_RXDEXT_STATERR_IPE)) {
+ /*
+ * work around errata with sctp packets where the TCPE aka
+ * L4E bit is set incorrectly on 64 byte (60 byte w/o crc)
+ * packets, (aka let the stack check the crc32c)
+ */
+ if (!((adapter->hw.mac.type == e1000_82576) &&
+ (skb->len == 60)))
+ adapter->hw_csum_err++;
/* let the stack verify checksum errors */
- adapter->hw_csum_err++;
return;
}
/* It must be a TCP or UDP packet with a valid checksum */
if (status_err & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))
skb->ip_summed = CHECKSUM_UNNECESSARY;
+ dev_dbg(&adapter->pdev->dev, "cksum success: bits %08X\n", status_err);
adapter->hw_csum_good++;
}
diff --git a/drivers/net/igbvf/ethtool.c b/drivers/net/igbvf/ethtool.c
index 1dcaa6905312..ee17a097d1ca 100644
--- a/drivers/net/igbvf/ethtool.c
+++ b/drivers/net/igbvf/ethtool.c
@@ -133,6 +133,24 @@ static int igbvf_set_pauseparam(struct net_device *netdev,
return -EOPNOTSUPP;
}
+static u32 igbvf_get_rx_csum(struct net_device *netdev)
+{
+ struct igbvf_adapter *adapter = netdev_priv(netdev);
+ return !(adapter->flags & IGBVF_FLAG_RX_CSUM_DISABLED);
+}
+
+static int igbvf_set_rx_csum(struct net_device *netdev, u32 data)
+{
+ struct igbvf_adapter *adapter = netdev_priv(netdev);
+
+ if (data)
+ adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED;
+ else
+ adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED;
+
+ return 0;
+}
+
static u32 igbvf_get_tx_csum(struct net_device *netdev)
{
return ((netdev->features & NETIF_F_IP_CSUM) != 0);
@@ -150,8 +168,6 @@ static int igbvf_set_tx_csum(struct net_device *netdev, u32 data)
static int igbvf_set_tso(struct net_device *netdev, u32 data)
{
struct igbvf_adapter *adapter = netdev_priv(netdev);
- int i;
- struct net_device *v_netdev;
if (data) {
netdev->features |= NETIF_F_TSO;
@@ -159,24 +175,10 @@ static int igbvf_set_tso(struct net_device *netdev, u32 data)
} else {
netdev->features &= ~NETIF_F_TSO;
netdev->features &= ~NETIF_F_TSO6;
- /* disable TSO on all VLANs if they're present */
- if (!adapter->vlgrp)
- goto tso_out;
- for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
- v_netdev = vlan_group_get_device(adapter->vlgrp, i);
- if (!v_netdev)
- continue;
-
- v_netdev->features &= ~NETIF_F_TSO;
- v_netdev->features &= ~NETIF_F_TSO6;
- vlan_group_set_device(adapter->vlgrp, i, v_netdev);
- }
}
-tso_out:
dev_info(&adapter->pdev->dev, "TSO is %s\n",
data ? "Enabled" : "Disabled");
- adapter->flags |= FLAG_TSO_FORCE;
return 0;
}
@@ -517,6 +519,8 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
.set_ringparam = igbvf_set_ringparam,
.get_pauseparam = igbvf_get_pauseparam,
.set_pauseparam = igbvf_set_pauseparam,
+ .get_rx_csum = igbvf_get_rx_csum,
+ .set_rx_csum = igbvf_set_rx_csum,
.get_tx_csum = igbvf_get_tx_csum,
.set_tx_csum = igbvf_set_tx_csum,
.get_sg = ethtool_op_get_sg,
diff --git a/drivers/net/igbvf/igbvf.h b/drivers/net/igbvf/igbvf.h
index 4bff35e46871..8e9b67ebbf8b 100644
--- a/drivers/net/igbvf/igbvf.h
+++ b/drivers/net/igbvf/igbvf.h
@@ -45,7 +45,7 @@ struct igbvf_adapter;
/* Interrupt defines */
#define IGBVF_START_ITR 648 /* ~6000 ints/sec */
-/* Interrupt modes, as used by the IntMode paramter */
+/* Interrupt modes, as used by the IntMode parameter */
#define IGBVF_INT_MODE_LEGACY 0
#define IGBVF_INT_MODE_MSI 1
#define IGBVF_INT_MODE_MSIX 2
@@ -286,11 +286,7 @@ struct igbvf_info {
};
/* hardware capability, feature, and workaround flags */
-#define FLAG_HAS_HW_VLAN_FILTER (1 << 0)
-#define FLAG_HAS_JUMBO_FRAMES (1 << 1)
-#define FLAG_MSI_ENABLED (1 << 2)
-#define FLAG_RX_CSUM_ENABLED (1 << 3)
-#define FLAG_TSO_FORCE (1 << 4)
+#define IGBVF_FLAG_RX_CSUM_DISABLED (1 << 0)
#define IGBVF_RX_DESC_ADV(R, i) \
(&((((R).desc))[i].rx_desc))
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index b774666ad3cf..44a8eef03a74 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -58,8 +58,7 @@ static void igbvf_reset_interrupt_capability(struct igbvf_adapter *);
static struct igbvf_info igbvf_vf_info = {
.mac = e1000_vfadapt,
- .flags = FLAG_HAS_JUMBO_FRAMES
- | FLAG_RX_CSUM_ENABLED,
+ .flags = 0,
.pba = 10,
.init_ops = e1000_init_function_pointers_vf,
};
@@ -107,8 +106,10 @@ static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter,
skb->ip_summed = CHECKSUM_NONE;
/* Ignore Checksum bit is set or checksum is disabled through ethtool */
- if ((status_err & E1000_RXD_STAT_IXSM))
+ if ((status_err & E1000_RXD_STAT_IXSM) ||
+ (adapter->flags & IGBVF_FLAG_RX_CSUM_DISABLED))
return;
+
/* TCP/UDP checksum error bit is set */
if (status_err &
(E1000_RXDEXT_STATERR_TCPE | E1000_RXDEXT_STATERR_IPE)) {
@@ -116,6 +117,7 @@ static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter,
adapter->hw_csum_err++;
return;
}
+
/* It must be a TCP or UDP packet with a valid checksum */
if (status_err & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))
skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -2351,15 +2353,6 @@ static int igbvf_change_mtu(struct net_device *netdev, int new_mtu)
return -EINVAL;
}
- /* Jumbo frame size limits */
- if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) {
- if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
- dev_err(&adapter->pdev->dev,
- "Jumbo Frames not supported.\n");
- return -EINVAL;
- }
- }
-
#define MAX_STD_JUMBO_FRAME_SIZE 9234
if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
dev_err(&adapter->pdev->dev, "MTU > 9216 not supported.\n");
diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h
index dd9318f19497..dfc2541bb556 100644
--- a/drivers/net/ipg.h
+++ b/drivers/net/ipg.h
@@ -514,7 +514,7 @@ enum ipg_regs {
#define IPG_DMALIST_ALIGN_PAD 0x07
#define IPG_MULTICAST_HASHTABLE_SIZE 0x40
-/* Number of miliseconds to wait after issuing a software reset.
+/* Number of milliseconds to wait after issuing a software reset.
* 0x05 <= IPG_AC_RESETWAIT to account for proper 10Mbps operation.
*/
#define IPG_AC_RESETWAIT 0x05
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index 941164076a2b..269153eedd26 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -23,6 +23,7 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/slab.h>
#include <linux/rtnetlink.h>
#include <linux/interrupt.h>
@@ -198,6 +199,17 @@ static int au1k_irda_init_iobuf(iobuff_t *io, int size)
return io->head ? 0 : -ENOMEM;
}
+static const struct net_device_ops au1k_irda_netdev_ops = {
+ .ndo_open = au1k_irda_start,
+ .ndo_stop = au1k_irda_stop,
+ .ndo_start_xmit = au1k_irda_hard_xmit,
+ .ndo_tx_timeout = au1k_tx_timeout,
+ .ndo_do_ioctl = au1k_irda_ioctl,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int au1k_irda_net_init(struct net_device *dev)
{
struct au1k_private *aup = netdev_priv(dev);
@@ -209,11 +221,7 @@ static int au1k_irda_net_init(struct net_device *dev)
if (err)
goto out1;
- dev->open = au1k_irda_start;
- dev->hard_start_xmit = au1k_irda_hard_xmit;
- dev->stop = au1k_irda_stop;
- dev->do_ioctl = au1k_irda_ioctl;
- dev->tx_timeout = au1k_tx_timeout;
+ dev->netdev_ops = &au1k_irda_netdev_ops;
irda_init_max_qos_capabilies(&aup->qos);
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index e775338b525f..3376a4f39e0a 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -14,6 +14,7 @@
*/
#include <linux/module.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
@@ -797,6 +798,16 @@ static int pxa_irda_init_iobuf(iobuff_t *io, int size)
return io->head ? 0 : -ENOMEM;
}
+static const struct net_device_ops pxa_irda_netdev_ops = {
+ .ndo_open = pxa_irda_start,
+ .ndo_stop = pxa_irda_stop,
+ .ndo_start_xmit = pxa_irda_hard_xmit,
+ .ndo_do_ioctl = pxa_irda_ioctl,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int pxa_irda_probe(struct platform_device *pdev)
{
struct net_device *dev;
@@ -845,10 +856,7 @@ static int pxa_irda_probe(struct platform_device *pdev)
if (err)
goto err_startup;
- dev->hard_start_xmit = pxa_irda_hard_xmit;
- dev->open = pxa_irda_start;
- dev->stop = pxa_irda_stop;
- dev->do_ioctl = pxa_irda_ioctl;
+ dev->netdev_ops = &pxa_irda_netdev_ops;
irda_init_max_qos_capabilies(&si->qos);
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 7a2b003954ca..2aeb2e6aec1b 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -24,6 +24,7 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/slab.h>
#include <linux/rtnetlink.h>
#include <linux/interrupt.h>
@@ -875,6 +876,16 @@ static int sa1100_irda_init_iobuf(iobuff_t *io, int size)
return io->head ? 0 : -ENOMEM;
}
+static const struct net_device_ops sa1100_irda_netdev_ops = {
+ .ndo_open = sa1100_irda_start,
+ .ndo_stop = sa1100_irda_stop,
+ .ndo_start_xmit = sa1100_irda_hard_xmit,
+ .ndo_do_ioctl = sa1100_irda_ioctl,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int sa1100_irda_probe(struct platform_device *pdev)
{
struct net_device *dev;
@@ -913,11 +924,8 @@ static int sa1100_irda_probe(struct platform_device *pdev)
if (err)
goto err_mem_5;
- dev->hard_start_xmit = sa1100_irda_hard_xmit;
- dev->open = sa1100_irda_start;
- dev->stop = sa1100_irda_stop;
- dev->do_ioctl = sa1100_irda_ioctl;
- dev->irq = IRQ_Ser2ICP;
+ dev->netdev_ops = &sa1100_irda_netdev_ops;
+ dev->irq = IRQ_Ser2ICP;
irda_init_max_qos_capabilies(&si->qos);
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index cb793c2bade2..e44215cb1882 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -1021,6 +1021,16 @@ static const struct ethtool_ops ops = {
.get_link = veth_get_link,
};
+static const struct net_device_ops veth_netdev_ops = {
+ .ndo_open = veth_open,
+ .ndo_stop = veth_close,
+ .ndo_start_xmit = veth_start_xmit,
+ .ndo_change_mtu = veth_change_mtu,
+ .ndo_set_multicast_list = veth_set_multicast_list,
+ .ndo_set_mac_address = NULL,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
static struct net_device *veth_probe_one(int vlan,
struct vio_dev *vio_dev)
{
@@ -1067,12 +1077,7 @@ static struct net_device *veth_probe_one(int vlan,
memcpy(&port->mac_addr, mac_addr, ETH_ALEN);
- dev->open = veth_open;
- dev->hard_start_xmit = veth_start_xmit;
- dev->stop = veth_close;
- dev->change_mtu = veth_change_mtu;
- dev->set_mac_address = NULL;
- dev->set_multicast_list = veth_set_multicast_list;
+ dev->netdev_ops = &veth_netdev_ops;
SET_ETHTOOL_OPS(dev, &ops);
SET_NETDEV_DEV(dev, vdev);
diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
index 11dcda0f453e..ff67a84e6802 100644
--- a/drivers/net/ixgb/ixgb_hw.c
+++ b/drivers/net/ixgb/ixgb_hw.c
@@ -192,7 +192,7 @@ ixgb_identify_xpak_vendor(struct ixgb_hw *hw)
vendor_name[i] = ixgb_read_phy_reg(hw,
MDIO_PMA_PMD_XPAK_VENDOR_NAME
+ i, IXGB_PHY_ADDRESS,
- MDIO_PMA_PMD_DID);
+ MDIO_MMD_PMAPMD);
}
/* Determine the actual vendor */
@@ -1225,15 +1225,15 @@ ixgb_optics_reset(struct ixgb_hw *hw)
u16 mdio_reg;
ixgb_write_phy_reg(hw,
- MDIO_PMA_PMD_CR1,
- IXGB_PHY_ADDRESS,
- MDIO_PMA_PMD_DID,
- MDIO_PMA_PMD_CR1_RESET);
-
- mdio_reg = ixgb_read_phy_reg( hw,
- MDIO_PMA_PMD_CR1,
- IXGB_PHY_ADDRESS,
- MDIO_PMA_PMD_DID);
+ MDIO_CTRL1,
+ IXGB_PHY_ADDRESS,
+ MDIO_MMD_PMAPMD,
+ MDIO_CTRL1_RESET);
+
+ mdio_reg = ixgb_read_phy_reg(hw,
+ MDIO_CTRL1,
+ IXGB_PHY_ADDRESS,
+ MDIO_MMD_PMAPMD);
}
return;
diff --git a/drivers/net/ixgb/ixgb_hw.h b/drivers/net/ixgb/ixgb_hw.h
index 831fe0c58b2b..af6ca3aab5ad 100644
--- a/drivers/net/ixgb/ixgb_hw.h
+++ b/drivers/net/ixgb/ixgb_hw.h
@@ -29,6 +29,8 @@
#ifndef _IXGB_HW_H_
#define _IXGB_HW_H_
+#include <linux/mdio.h>
+
#include "ixgb_osdep.h"
/* Enums */
@@ -507,18 +509,6 @@ typedef enum {
/* Definitions for the optics devices on the MDIO bus. */
#define IXGB_PHY_ADDRESS 0x0 /* Single PHY, multiple "Devices" */
-/* Standard five-bit Device IDs. See IEEE 802.3ae, clause 45 */
-#define MDIO_PMA_PMD_DID 0x01
-#define MDIO_WIS_DID 0x02
-#define MDIO_PCS_DID 0x03
-#define MDIO_XGXS_DID 0x04
-
-/* Standard PMA/PMD registers and bit definitions. */
-/* Note: This is a very limited set of definitions, */
-/* only implemented features are defined. */
-#define MDIO_PMA_PMD_CR1 0x0000
-#define MDIO_PMA_PMD_CR1_RESET 0x8000
-
#define MDIO_PMA_PMD_XPAK_VENDOR_NAME 0x803A /* XPAK/XENPAK devices only */
/* Vendor-specific MDIO registers */
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 4a0826b8f6f2..04cb81a739c2 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -266,6 +266,8 @@ ixgb_up(struct ixgb_adapter *adapter)
napi_enable(&adapter->napi);
ixgb_irq_enable(adapter);
+ netif_wake_queue(netdev);
+
mod_timer(&adapter->watchdog_timer, jiffies);
return 0;
@@ -471,10 +473,8 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (err)
goto err_register;
- /* we're going to reset, so assume we have no link for now */
-
+ /* carrier off reporting is important to ethtool even BEFORE open */
netif_carrier_off(netdev);
- netif_stop_queue(netdev);
DPRINTK(PROBE, INFO, "Intel(R) PRO/10GbE Network Connection\n");
ixgb_check_options(adapter);
@@ -592,6 +592,8 @@ ixgb_open(struct net_device *netdev)
if (err)
goto err_setup_tx;
+ netif_carrier_off(netdev);
+
/* allocate receive descriptors */
err = ixgb_setup_rx_resources(adapter);
@@ -602,6 +604,8 @@ ixgb_open(struct net_device *netdev)
if (err)
goto err_up;
+ netif_start_queue(netdev);
+
return 0;
err_up:
@@ -1116,7 +1120,6 @@ ixgb_watchdog(unsigned long data)
adapter->link_speed = 10000;
adapter->link_duplex = FULL_DUPLEX;
netif_carrier_on(netdev);
- netif_wake_queue(netdev);
}
} else {
if (netif_carrier_ok(netdev)) {
@@ -1125,8 +1128,6 @@ ixgb_watchdog(unsigned long data)
printk(KERN_INFO "ixgb: %s NIC Link is Down\n",
netdev->name);
netif_carrier_off(netdev);
- netif_stop_queue(netdev);
-
}
}
@@ -1139,6 +1140,8 @@ ixgb_watchdog(unsigned long data)
* to get done, so reset controller to flush Tx.
* (Do the reset outside of interrupt context). */
schedule_work(&adapter->tx_timeout_task);
+ /* return immediately since reset is imminent */
+ return;
}
}
diff --git a/drivers/net/ixgb/ixgb_osdep.h b/drivers/net/ixgb/ixgb_osdep.h
index d92e72bd627a..371a6be4d965 100644
--- a/drivers/net/ixgb/ixgb_osdep.h
+++ b/drivers/net/ixgb/ixgb_osdep.h
@@ -40,7 +40,7 @@
#include <linux/sched.h>
#undef ASSERT
-#define ASSERT(x) if (!(x)) BUG()
+#define ASSERT(x) BUG_ON(!(x))
#define MSGOUT(S, A, B) printk(KERN_DEBUG S "\n", A, B)
#ifdef DBG
diff --git a/drivers/net/ixgbe/Makefile b/drivers/net/ixgbe/Makefile
index b3f8208ec7be..21b41f42b61c 100644
--- a/drivers/net/ixgbe/Makefile
+++ b/drivers/net/ixgbe/Makefile
@@ -37,3 +37,5 @@ ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \
ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \
ixgbe_dcb_82599.o ixgbe_dcb_nl.o
+
+ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index c26433d14605..05a24055ac2f 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -36,6 +36,10 @@
#include "ixgbe_type.h"
#include "ixgbe_common.h"
#include "ixgbe_dcb.h"
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+#define IXGBE_FCOE
+#include "ixgbe_fcoe.h"
+#endif /* CONFIG_FCOE or CONFIG_FCOE_MODULE */
#ifdef CONFIG_IXGBE_DCA
#include <linux/dca.h>
#endif
@@ -71,6 +75,8 @@
#define IXGBE_RXBUFFER_128 128 /* Used for packet split */
#define IXGBE_RXBUFFER_256 256 /* Used for packet split */
#define IXGBE_RXBUFFER_2048 2048
+#define IXGBE_RXBUFFER_4096 4096
+#define IXGBE_RXBUFFER_8192 8192
#define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */
#define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
@@ -84,6 +90,8 @@
#define IXGBE_TX_FLAGS_VLAN (u32)(1 << 1)
#define IXGBE_TX_FLAGS_TSO (u32)(1 << 2)
#define IXGBE_TX_FLAGS_IPV4 (u32)(1 << 3)
+#define IXGBE_TX_FLAGS_FCOE (u32)(1 << 4)
+#define IXGBE_TX_FLAGS_FSO (u32)(1 << 5)
#define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000
#define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0x0000e000
#define IXGBE_TX_FLAGS_VLAN_SHIFT 16
@@ -147,6 +155,7 @@ struct ixgbe_ring {
u16 work_limit; /* max work per interrupt */
u16 rx_buf_len;
+ u64 rsc_count; /* stat for coalesced packets */
};
enum ixgbe_ring_f_enum {
@@ -154,6 +163,9 @@ enum ixgbe_ring_f_enum {
RING_F_DCB,
RING_F_VMDQ,
RING_F_RSS,
+#ifdef IXGBE_FCOE
+ RING_F_FCOE,
+#endif /* IXGBE_FCOE */
RING_F_ARRAY_SIZE /* must be last in enum set */
};
@@ -161,6 +173,9 @@ enum ixgbe_ring_f_enum {
#define IXGBE_MAX_DCB_INDICES 8
#define IXGBE_MAX_RSS_INDICES 16
#define IXGBE_MAX_VMDQ_INDICES 16
+#ifdef IXGBE_FCOE
+#define IXGBE_MAX_FCOE_INDICES 8
+#endif /* IXGBE_FCOE */
struct ixgbe_ring_feature {
int indices;
int mask;
@@ -186,6 +201,7 @@ struct ixgbe_q_vector {
u8 tx_itr;
u8 rx_itr;
u32 eitr;
+ u32 v_idx; /* vector index in list */
};
/* Helper macros to switch between ints/sec and what the register uses.
@@ -208,6 +224,10 @@ struct ixgbe_q_vector {
(&(((struct ixgbe_adv_tx_context_desc *)((R).desc))[i]))
#define IXGBE_MAX_JUMBO_FRAME_SIZE 16128
+#ifdef IXGBE_FCOE
+/* Use 3K as the baby jumbo frame size for FCoE */
+#define IXGBE_FCOE_JUMBO_FRAME_SIZE 3072
+#endif /* IXGBE_FCOE */
#define OTHER_VECTOR 1
#define NON_Q_VECTORS (OTHER_VECTOR)
@@ -229,11 +249,12 @@ struct ixgbe_adapter {
struct vlan_group *vlgrp;
u16 bd_number;
struct work_struct reset_task;
- struct ixgbe_q_vector q_vector[MAX_MSIX_Q_VECTORS];
+ struct ixgbe_q_vector *q_vector[MAX_MSIX_Q_VECTORS];
char name[MAX_MSIX_COUNT][IFNAMSIZ + 9];
struct ixgbe_dcb_config dcb_cfg;
struct ixgbe_dcb_config temp_dcb_cfg;
u8 dcb_set_bitmap;
+ enum ixgbe_fc_mode last_lfc_mode;
/* Interrupt Throttle Rate */
u32 itr_setting;
@@ -294,6 +315,9 @@ struct ixgbe_adapter {
#define IXGBE_FLAG_IN_WATCHDOG_TASK (u32)(1 << 23)
#define IXGBE_FLAG_IN_SFP_LINK_TASK (u32)(1 << 24)
#define IXGBE_FLAG_IN_SFP_MOD_TASK (u32)(1 << 25)
+#define IXGBE_FLAG_RSC_CAPABLE (u32)(1 << 26)
+#define IXGBE_FLAG_RSC_ENABLED (u32)(1 << 27)
+#define IXGBE_FLAG_FCOE_ENABLED (u32)(1 << 29)
/* default to trying for four seconds */
#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
@@ -325,6 +349,10 @@ struct ixgbe_adapter {
struct timer_list sfp_timer;
struct work_struct multispeed_fiber_task;
struct work_struct sfp_config_module_task;
+#ifdef IXGBE_FCOE
+ struct ixgbe_fcoe fcoe;
+#endif /* IXGBE_FCOE */
+ u64 rsc_count;
u32 wol;
u16 eeprom_version;
};
@@ -363,10 +391,21 @@ extern int ixgbe_setup_tx_resources(struct ixgbe_adapter *, struct ixgbe_ring *)
extern void ixgbe_free_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);
extern void ixgbe_free_tx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);
extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);
-extern void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter);
extern int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
-void ixgbe_napi_add_all(struct ixgbe_adapter *adapter);
-void ixgbe_napi_del_all(struct ixgbe_adapter *adapter);
+extern void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
extern void ixgbe_write_eitr(struct ixgbe_adapter *, int, u32);
+#ifdef IXGBE_FCOE
+extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
+extern int ixgbe_fso(struct ixgbe_adapter *adapter,
+ struct ixgbe_ring *tx_ring, struct sk_buff *skb,
+ u32 tx_flags, u8 *hdr_len);
+extern void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter);
+extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
+ union ixgbe_adv_rx_desc *rx_desc,
+ struct sk_buff *skb);
+extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
+ struct scatterlist *sgl, unsigned int sgc);
+extern int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
+#endif /* IXGBE_FCOE */
#endif /* _IXGBE_H_ */
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 4791238c3f6e..afc9fe3f1eda 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -75,18 +75,49 @@ static u16 ixgbe_get_pcie_msix_count_82598(struct ixgbe_hw *hw)
static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
{
struct ixgbe_mac_info *mac = &hw->mac;
+
+ /* Call PHY identify routine to get the phy type */
+ ixgbe_identify_phy_generic(hw);
+
+ mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
+ mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
+ mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
+ mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
+ mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
+ mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82598(hw);
+
+ return 0;
+}
+
+/**
+ * ixgbe_init_phy_ops_82598 - PHY/SFP specific init
+ * @hw: pointer to hardware structure
+ *
+ * Initialize any function pointers that were not able to be
+ * set during get_invariants because the PHY/SFP type was
+ * not known. Perform the SFP init if necessary.
+ *
+ **/
+s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
+{
+ struct ixgbe_mac_info *mac = &hw->mac;
struct ixgbe_phy_info *phy = &hw->phy;
s32 ret_val = 0;
u16 list_offset, data_offset;
- /* Set the bus information prior to PHY identification */
- mac->ops.get_bus_info(hw);
+ /* Identify the PHY */
+ phy->ops.identify(hw);
- /* Call PHY identify routine to get the phy type */
- ixgbe_identify_phy_generic(hw);
+ /* Overwrite the link function pointers if copper PHY */
+ if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
+ mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
+ mac->ops.setup_link_speed =
+ &ixgbe_setup_copper_link_speed_82598;
+ mac->ops.get_link_capabilities =
+ &ixgbe_get_copper_link_capabilities_82598;
+ }
- /* PHY Init */
- switch (phy->type) {
+ switch (hw->phy.type) {
case ixgbe_phy_tn:
phy->ops.check_link = &ixgbe_check_phy_link_tnx;
phy->ops.get_firmware_version =
@@ -106,8 +137,8 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
/* Check to see if SFP+ module is supported */
ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
- &list_offset,
- &data_offset);
+ &list_offset,
+ &data_offset);
if (ret_val != 0) {
ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
goto out;
@@ -117,21 +148,6 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
break;
}
- if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
- mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
- mac->ops.setup_link_speed =
- &ixgbe_setup_copper_link_speed_82598;
- mac->ops.get_link_capabilities =
- &ixgbe_get_copper_link_capabilities_82598;
- }
-
- mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
- mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
- mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
- mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
- mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
- mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82598(hw);
-
out:
return ret_val;
}
@@ -149,12 +165,19 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
bool *autoneg)
{
s32 status = 0;
+ u32 autoc = 0;
/*
* Determine link capabilities based on the stored value of AUTOC,
- * which represents EEPROM defaults.
+ * which represents EEPROM defaults. If AUTOC value has not been
+ * stored, use the current register value.
*/
- switch (hw->mac.orig_autoc & IXGBE_AUTOC_LMS_MASK) {
+ if (hw->mac.orig_link_settings_stored)
+ autoc = hw->mac.orig_autoc;
+ else
+ autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
+
+ switch (autoc & IXGBE_AUTOC_LMS_MASK) {
case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
*speed = IXGBE_LINK_SPEED_1GB_FULL;
*autoneg = false;
@@ -173,9 +196,9 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
case IXGBE_AUTOC_LMS_KX4_AN:
case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
*speed = IXGBE_LINK_SPEED_UNKNOWN;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP)
+ if (autoc & IXGBE_AUTOC_KX4_SUPP)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP)
+ if (autoc & IXGBE_AUTOC_KX_SUPP)
*speed |= IXGBE_LINK_SPEED_1GB_FULL;
*autoneg = true;
break;
@@ -206,14 +229,13 @@ static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
*speed = 0;
*autoneg = true;
- status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
&speed_ability);
if (status == 0) {
- if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
+ if (speed_ability & MDIO_SPEED_10G)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
+ if (speed_ability & MDIO_PMA_SPEED_1000)
*speed |= IXGBE_LINK_SPEED_1GB_FULL;
}
@@ -322,6 +344,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
}
/* Enable 802.3x based flow control settings. */
+ fctrl_reg |= IXGBE_FCTRL_DPF;
IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
@@ -340,7 +363,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
}
/* Configure pause time (2 TCs per register) */
- reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num));
+ reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2));
if ((packetbuf_num & 1) == 0)
reg = (reg & 0xFFFF0000) | hw->fc.pause_time;
else
@@ -380,9 +403,11 @@ static s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
* because it causes the controller to just blast out fc packets.
*/
if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
- hw_dbg(hw, "Invalid water mark configuration\n");
- ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
- goto out;
+ if (hw->fc.requested_mode != ixgbe_fc_none) {
+ hw_dbg(hw, "Invalid water mark configuration\n");
+ ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
+ goto out;
+ }
}
/*
@@ -500,9 +525,9 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
* clear indicates active; set indicates inactive.
*/
if (hw->phy.type == ixgbe_phy_nl) {
- hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
- hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
- hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV,
+ hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg);
+ hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg);
+ hw->phy.ops.read_reg(hw, 0xC00C, MDIO_MMD_PMAPMD,
&adapt_comp_reg);
if (link_up_wait_to_complete) {
for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
@@ -515,10 +540,10 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
}
msleep(100);
hw->phy.ops.read_reg(hw, 0xC79F,
- IXGBE_TWINAX_DEV,
+ MDIO_MMD_PMAPMD,
&link_reg);
hw->phy.ops.read_reg(hw, 0xC00C,
- IXGBE_TWINAX_DEV,
+ MDIO_MMD_PMAPMD,
&adapt_comp_reg);
}
} else {
@@ -716,14 +741,23 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
}
/* Reset PHY */
- if (hw->phy.reset_disable == false)
+ if (hw->phy.reset_disable == false) {
+ /* PHY ops must be identified and initialized prior to reset */
+
+ /* Init PHY and function pointers, perform SFP setup */
+ status = hw->phy.ops.init(hw);
+ if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
+ goto reset_hw_out;
+
hw->phy.ops.reset(hw);
+ }
/*
* Prevent the PCI-E bus from from hanging by disabling PCI-E master
* access and verify no pending requests before reset
*/
- if (ixgbe_disable_pcie_master(hw) != 0) {
+ status = ixgbe_disable_pcie_master(hw);
+ if (status != 0) {
status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
}
@@ -767,9 +801,16 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
}
+ /*
+ * Store MAC address from RAR0, clear receive address registers, and
+ * clear the multicast table
+ */
+ hw->mac.ops.init_rx_addrs(hw);
+
/* Store the permanent mac address */
hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
+reset_hw_out:
return status;
}
@@ -954,14 +995,14 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
hw->phy.ops.write_reg(hw,
IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ MDIO_MMD_PMAPMD,
sfp_addr);
/* Poll status */
for (i = 0; i < 100; i++) {
hw->phy.ops.read_reg(hw,
IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ MDIO_MMD_PMAPMD,
&sfp_stat);
sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
@@ -977,7 +1018,7 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
/* Read data */
hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data);
+ MDIO_MMD_PMAPMD, &sfp_data);
*eeprom_data = (u8)(sfp_data >> 8);
} else {
@@ -998,35 +1039,56 @@ out:
static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
{
u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
+ u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
+ u32 pma_pmd_10g = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
+ u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
+ u16 ext_ability = 0;
+
+ hw->phy.ops.identify(hw);
+
+ /* Copper PHY must be checked before AUTOC LMS to determine correct
+ * physical layer because 10GBase-T PHYs use LMS = KX4/KX */
+ if (hw->phy.type == ixgbe_phy_tn ||
+ hw->phy.type == ixgbe_phy_cu_unknown) {
+ hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
+ &ext_ability);
+ if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
+ if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
+ if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
+ goto out;
+ }
- switch (hw->device_id) {
- case IXGBE_DEV_ID_82598:
- /* Default device ID is mezzanine card KX/KX4 */
- physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
- IXGBE_PHYSICAL_LAYER_1000BASE_KX);
- break;
- case IXGBE_DEV_ID_82598_BX:
- physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
- case IXGBE_DEV_ID_82598EB_CX4:
- case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
- physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
- break;
- case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
- physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
+ switch (autoc & IXGBE_AUTOC_LMS_MASK) {
+ case IXGBE_AUTOC_LMS_1G_AN:
+ case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
+ if (pma_pmd_1g == IXGBE_AUTOC_1G_KX)
+ physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+ else
+ physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
break;
- case IXGBE_DEV_ID_82598AF_DUAL_PORT:
- case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
- case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
- physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
+ case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
+ if (pma_pmd_10g == IXGBE_AUTOC_10G_CX4)
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
+ else if (pma_pmd_10g == IXGBE_AUTOC_10G_KX4)
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
+ else /* XAUI */
+ physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
break;
- case IXGBE_DEV_ID_82598EB_XF_LR:
- physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
+ case IXGBE_AUTOC_LMS_KX4_AN:
+ case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
+ if (autoc & IXGBE_AUTOC_KX_SUPP)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+ if (autoc & IXGBE_AUTOC_KX4_SUPP)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
break;
- case IXGBE_DEV_ID_82598AT:
- physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_T |
- IXGBE_PHYSICAL_LAYER_1000BASE_T);
+ default:
break;
- case IXGBE_DEV_ID_82598EB_SFP_LOM:
+ }
+
+ if (hw->phy.type == ixgbe_phy_nl) {
hw->phy.ops.identify_sfp(hw);
switch (hw->phy.sfp_type) {
@@ -1043,13 +1105,25 @@ static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
break;
}
- break;
+ }
+ switch (hw->device_id) {
+ case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
+ physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
+ break;
+ case IXGBE_DEV_ID_82598AF_DUAL_PORT:
+ case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
+ case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
+ break;
+ case IXGBE_DEV_ID_82598EB_XF_LR:
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
+ break;
default:
- physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
break;
}
+out:
return physical_layer;
}
@@ -1099,6 +1173,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
static struct ixgbe_phy_operations phy_ops_82598 = {
.identify = &ixgbe_identify_phy_generic,
.identify_sfp = &ixgbe_identify_sfp_module_generic,
+ .init = &ixgbe_init_phy_ops_82598,
.reset = &ixgbe_reset_phy_generic,
.read_reg = &ixgbe_read_phy_reg_generic,
.write_reg = &ixgbe_write_phy_reg_generic,
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 29771fbaa42d..fef7397accda 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -100,12 +100,22 @@ s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
ixgbe_init_mac_link_ops_82599(hw);
+
+ hw->phy.ops.reset = NULL;
+
ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
&data_offset);
if (ret_val != 0)
goto setup_sfp_out;
+ /* PHY config will finish before releasing the semaphore */
+ ret_val = ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
+ if (ret_val != 0) {
+ ret_val = IXGBE_ERR_SWFW_SYNC;
+ goto setup_sfp_out;
+ }
+
hw->eeprom.ops.read(hw, ++data_offset, &data_value);
while (data_value != 0xffff) {
IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
@@ -116,6 +126,11 @@ s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
IXGBE_WRITE_REG(hw, IXGBE_CORECTL, 0x00000102);
IXGBE_WRITE_REG(hw, IXGBE_CORECTL, 0x00000b1d);
IXGBE_WRITE_FLUSH(hw);
+
+ /* Release the semaphore */
+ ixgbe_release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
+ /* Delay obtaining semaphore again to allow FW access */
+ msleep(hw->eeprom.semaphore_delay);
}
setup_sfp_out:
@@ -146,51 +161,60 @@ u32 ixgbe_get_pcie_msix_count_82599(struct ixgbe_hw *hw)
static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
{
struct ixgbe_mac_info *mac = &hw->mac;
- struct ixgbe_phy_info *phy = &hw->phy;
- s32 ret_val;
- /* Set the bus information prior to PHY identification */
- mac->ops.get_bus_info(hw);
+ ixgbe_init_mac_link_ops_82599(hw);
- /* Call PHY identify routine to get the Cu or SFI phy type */
- ret_val = phy->ops.identify(hw);
+ mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
+ mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
+ mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
+ mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
+ mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
+ mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82599(hw);
+
+ return 0;
+}
- if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
- goto get_invariants_out;
+/**
+ * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
+ * @hw: pointer to hardware structure
+ *
+ * Initialize any function pointers that were not able to be
+ * set during get_invariants because the PHY/SFP type was
+ * not known. Perform the SFP init if necessary.
+ *
+ **/
+s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
+{
+ struct ixgbe_mac_info *mac = &hw->mac;
+ struct ixgbe_phy_info *phy = &hw->phy;
+ s32 ret_val = 0;
- ixgbe_init_mac_link_ops_82599(hw);
+ /* Identify the PHY or SFP module */
+ ret_val = phy->ops.identify(hw);
- /* Setup SFP module if there is one present. */
- ret_val = mac->ops.setup_sfp(hw);
+ /* Setup function pointers based on detected SFP module and speeds */
+ ixgbe_init_mac_link_ops_82599(hw);
/* If copper media, overwrite with copper function pointers */
if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
mac->ops.setup_link = &ixgbe_setup_copper_link_82599;
mac->ops.setup_link_speed =
- &ixgbe_setup_copper_link_speed_82599;
+ &ixgbe_setup_copper_link_speed_82599;
mac->ops.get_link_capabilities =
&ixgbe_get_copper_link_capabilities_82599;
}
- /* PHY Init */
+ /* Set necessary function pointers based on phy type */
switch (hw->phy.type) {
case ixgbe_phy_tn:
phy->ops.check_link = &ixgbe_check_phy_link_tnx;
phy->ops.get_firmware_version =
- &ixgbe_get_phy_firmware_version_tnx;
+ &ixgbe_get_phy_firmware_version_tnx;
break;
default:
break;
}
- mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
- mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
- mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
- mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
- mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
- mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82599(hw);
-
-get_invariants_out:
return ret_val;
}
@@ -207,8 +231,19 @@ s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
bool *negotiation)
{
s32 status = 0;
+ u32 autoc = 0;
- switch (hw->mac.orig_autoc & IXGBE_AUTOC_LMS_MASK) {
+ /*
+ * Determine link capabilities based on the stored value of AUTOC,
+ * which represents EEPROM defaults. If AUTOC value has not been
+ * stored, use the current register value.
+ */
+ if (hw->mac.orig_link_settings_stored)
+ autoc = hw->mac.orig_autoc;
+ else
+ autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
+
+ switch (autoc & IXGBE_AUTOC_LMS_MASK) {
case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
*speed = IXGBE_LINK_SPEED_1GB_FULL;
*negotiation = false;
@@ -232,22 +267,22 @@ s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
case IXGBE_AUTOC_LMS_KX4_KX_KR:
case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
*speed = IXGBE_LINK_SPEED_UNKNOWN;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KR_SUPP)
+ if (autoc & IXGBE_AUTOC_KR_SUPP)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP)
+ if (autoc & IXGBE_AUTOC_KX4_SUPP)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP)
+ if (autoc & IXGBE_AUTOC_KX_SUPP)
*speed |= IXGBE_LINK_SPEED_1GB_FULL;
*negotiation = true;
break;
case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
*speed = IXGBE_LINK_SPEED_100_FULL;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KR_SUPP)
+ if (autoc & IXGBE_AUTOC_KR_SUPP)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP)
+ if (autoc & IXGBE_AUTOC_KX4_SUPP)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP)
+ if (autoc & IXGBE_AUTOC_KX_SUPP)
*speed |= IXGBE_LINK_SPEED_1GB_FULL;
*negotiation = true;
break;
@@ -291,14 +326,13 @@ static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
*speed = 0;
*autoneg = true;
- status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
&speed_ability);
if (status == 0) {
- if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
+ if (speed_ability & MDIO_SPEED_10G)
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
- if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
+ if (speed_ability & MDIO_PMA_SPEED_1000)
*speed |= IXGBE_LINK_SPEED_1GB_FULL;
}
@@ -325,6 +359,7 @@ enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
switch (hw->device_id) {
case IXGBE_DEV_ID_82599:
case IXGBE_DEV_ID_82599_KX4:
+ case IXGBE_DEV_ID_82599_XAUI_LOM:
/* Default device ID is mezzanine card KX/KX4 */
media_type = ixgbe_media_type_backplane;
break;
@@ -558,6 +593,7 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
s32 status = 0;
u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
+ u32 orig_autoc = 0;
u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
@@ -569,6 +605,13 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
speed &= link_capabilities;
+ /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
+ if (hw->mac.orig_link_settings_stored)
+ orig_autoc = hw->mac.orig_autoc;
+ else
+ orig_autoc = autoc;
+
+
if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
status = IXGBE_ERR_LINK_SETUP;
} else if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
@@ -577,9 +620,9 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
/* Set KX4/KX/KR support according to speed requested */
autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
if (speed & IXGBE_LINK_SPEED_10GB_FULL)
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP)
+ if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
autoc |= IXGBE_AUTOC_KX4_SUPP;
- if (hw->mac.orig_autoc & IXGBE_AUTOC_KR_SUPP)
+ if (orig_autoc & IXGBE_AUTOC_KR_SUPP)
autoc |= IXGBE_AUTOC_KR_SUPP;
if (speed & IXGBE_LINK_SPEED_1GB_FULL)
autoc |= IXGBE_AUTOC_KX_SUPP;
@@ -705,14 +748,30 @@ s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
/* Call adapter stop to disable tx/rx and clear interrupts */
hw->mac.ops.stop_adapter(hw);
+ /* PHY ops must be identified and initialized prior to reset */
+
+ /* Init PHY and function pointers, perform SFP setup */
+ status = hw->phy.ops.init(hw);
+
+ if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
+ goto reset_hw_out;
+
+ /* Setup SFP module if there is one present. */
+ if (hw->phy.sfp_setup_needed) {
+ status = hw->mac.ops.setup_sfp(hw);
+ hw->phy.sfp_setup_needed = false;
+ }
+
/* Reset PHY */
- hw->phy.ops.reset(hw);
+ if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
+ hw->phy.ops.reset(hw);
/*
* Prevent the PCI-E bus from from hanging by disabling PCI-E master
* access and verify no pending requests before reset
*/
- if (ixgbe_disable_pcie_master(hw) != 0) {
+ status = ixgbe_disable_pcie_master(hw);
+ if (status != 0) {
status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
}
@@ -770,9 +829,30 @@ s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
}
}
+ /*
+ * Store MAC address from RAR0, clear receive address registers, and
+ * clear the multicast table. Also reset num_rar_entries to 128,
+ * since we modify this value when programming the SAN MAC address.
+ */
+ hw->mac.num_rar_entries = 128;
+ hw->mac.ops.init_rx_addrs(hw);
+
/* Store the permanent mac address */
hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
+ /* Store the permanent SAN mac address */
+ hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
+
+ /* Add the SAN MAC address to the RAR only if it's a valid address */
+ if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
+ hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
+ hw->mac.san_addr, 0, IXGBE_RAH_AV);
+
+ /* Reserve the last RAR for the SAN MAC address */
+ hw->mac.num_rar_entries--;
+ }
+
+reset_hw_out:
return status;
}
@@ -1093,53 +1173,100 @@ s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
{
u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
+ u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
+ u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
+ u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
+ u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
+ u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
+ u16 ext_ability = 0;
u8 comp_codes_10g = 0;
- switch (hw->device_id) {
- case IXGBE_DEV_ID_82599:
- case IXGBE_DEV_ID_82599_KX4:
- /* Default device ID is mezzanine card KX/KX4 */
- physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
- IXGBE_PHYSICAL_LAYER_1000BASE_KX);
+ hw->phy.ops.identify(hw);
+
+ if (hw->phy.type == ixgbe_phy_tn ||
+ hw->phy.type == ixgbe_phy_cu_unknown) {
+ hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
+ &ext_ability);
+ if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
+ if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
+ if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
+ goto out;
+ }
+
+ switch (autoc & IXGBE_AUTOC_LMS_MASK) {
+ case IXGBE_AUTOC_LMS_1G_AN:
+ case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
+ if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
+ physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
+ IXGBE_PHYSICAL_LAYER_1000BASE_BX;
+ goto out;
+ } else
+ /* SFI mode so read SFP module */
+ goto sfp_check;
break;
- case IXGBE_DEV_ID_82599_SFP:
- hw->phy.ops.identify_sfp(hw);
+ case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
+ if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
+ else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
+ else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
+ goto out;
+ break;
+ case IXGBE_AUTOC_LMS_10G_SERIAL:
+ if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
+ goto out;
+ } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
+ goto sfp_check;
+ break;
+ case IXGBE_AUTOC_LMS_KX4_KX_KR:
+ case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
+ if (autoc & IXGBE_AUTOC_KX_SUPP)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+ if (autoc & IXGBE_AUTOC_KX4_SUPP)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
+ if (autoc & IXGBE_AUTOC_KR_SUPP)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
+ goto out;
+ break;
+ default:
+ goto out;
+ break;
+ }
- switch (hw->phy.sfp_type) {
- case ixgbe_sfp_type_da_cu:
- case ixgbe_sfp_type_da_cu_core0:
- case ixgbe_sfp_type_da_cu_core1:
- physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
- break;
- case ixgbe_sfp_type_sr:
+sfp_check:
+ /* SFP check must be done last since DA modules are sometimes used to
+ * test KR mode - we need to id KR mode correctly before SFP module.
+ * Call identify_sfp because the pluggable module may have changed */
+ hw->phy.ops.identify_sfp(hw);
+ if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
+ goto out;
+
+ switch (hw->phy.type) {
+ case ixgbe_phy_tw_tyco:
+ case ixgbe_phy_tw_unknown:
+ physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
+ break;
+ case ixgbe_phy_sfp_avago:
+ case ixgbe_phy_sfp_ftl:
+ case ixgbe_phy_sfp_intel:
+ case ixgbe_phy_sfp_unknown:
+ hw->phy.ops.read_i2c_eeprom(hw,
+ IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
+ if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
- break;
- case ixgbe_sfp_type_lr:
+ else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
- break;
- case ixgbe_sfp_type_srlr_core0:
- case ixgbe_sfp_type_srlr_core1:
- hw->phy.ops.read_i2c_eeprom(hw,
- IXGBE_SFF_10GBE_COMP_CODES,
- &comp_codes_10g);
- if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
- physical_layer =
- IXGBE_PHYSICAL_LAYER_10GBASE_SR;
- else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
- physical_layer =
- IXGBE_PHYSICAL_LAYER_10GBASE_LR;
- else
- physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
- default:
- physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
- break;
- }
break;
default:
- physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
break;
}
+out:
return physical_layer;
}
@@ -1187,6 +1314,90 @@ s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
return 0;
}
+/**
+ * ixgbe_get_device_caps_82599 - Get additional device capabilities
+ * @hw: pointer to hardware structure
+ * @device_caps: the EEPROM word with the extra device capabilities
+ *
+ * This function will read the EEPROM location for the device capabilities,
+ * and return the word through device_caps.
+ **/
+s32 ixgbe_get_device_caps_82599(struct ixgbe_hw *hw, u16 *device_caps)
+{
+ hw->eeprom.ops.read(hw, IXGBE_DEVICE_CAPS, device_caps);
+
+ return 0;
+}
+
+/**
+ * ixgbe_get_san_mac_addr_offset_82599 - SAN MAC address offset for 82599
+ * @hw: pointer to hardware structure
+ * @san_mac_offset: SAN MAC address offset
+ *
+ * This function will read the EEPROM location for the SAN MAC address
+ * pointer, and returns the value at that location. This is used in both
+ * get and set mac_addr routines.
+ **/
+s32 ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw *hw,
+ u16 *san_mac_offset)
+{
+ /*
+ * First read the EEPROM pointer to see if the MAC addresses are
+ * available.
+ */
+ hw->eeprom.ops.read(hw, IXGBE_SAN_MAC_ADDR_PTR, san_mac_offset);
+
+ return 0;
+}
+
+/**
+ * ixgbe_get_san_mac_addr_82599 - SAN MAC address retrieval for 82599
+ * @hw: pointer to hardware structure
+ * @san_mac_addr: SAN MAC address
+ *
+ * Reads the SAN MAC address from the EEPROM, if it's available. This is
+ * per-port, so set_lan_id() must be called before reading the addresses.
+ * set_lan_id() is called by identify_sfp(), but this cannot be relied
+ * upon for non-SFP connections, so we must call it here.
+ **/
+s32 ixgbe_get_san_mac_addr_82599(struct ixgbe_hw *hw, u8 *san_mac_addr)
+{
+ u16 san_mac_data, san_mac_offset;
+ u8 i;
+
+ /*
+ * First read the EEPROM pointer to see if the MAC addresses are
+ * available. If they're not, no point in calling set_lan_id() here.
+ */
+ ixgbe_get_san_mac_addr_offset_82599(hw, &san_mac_offset);
+
+ if ((san_mac_offset == 0) || (san_mac_offset == 0xFFFF)) {
+ /*
+ * No addresses available in this EEPROM. It's not an
+ * error though, so just wipe the local address and return.
+ */
+ for (i = 0; i < 6; i++)
+ san_mac_addr[i] = 0xFF;
+
+ goto san_mac_addr_out;
+ }
+
+ /* make sure we know which port we need to program */
+ hw->mac.ops.set_lan_id(hw);
+ /* apply the port offset to the address offset */
+ (hw->bus.func) ? (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT1_OFFSET) :
+ (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT0_OFFSET);
+ for (i = 0; i < 3; i++) {
+ hw->eeprom.ops.read(hw, san_mac_offset, &san_mac_data);
+ san_mac_addr[i * 2] = (u8)(san_mac_data);
+ san_mac_addr[i * 2 + 1] = (u8)(san_mac_data >> 8);
+ san_mac_offset++;
+ }
+
+san_mac_addr_out:
+ return 0;
+}
+
static struct ixgbe_mac_operations mac_ops_82599 = {
.init_hw = &ixgbe_init_hw_generic,
.reset_hw = &ixgbe_reset_hw_82599,
@@ -1196,6 +1407,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = {
.get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599,
.enable_rx_dma = &ixgbe_enable_rx_dma_82599,
.get_mac_addr = &ixgbe_get_mac_addr_generic,
+ .get_san_mac_addr = &ixgbe_get_san_mac_addr_82599,
+ .get_device_caps = &ixgbe_get_device_caps_82599,
.stop_adapter = &ixgbe_stop_adapter_generic,
.get_bus_info = &ixgbe_get_bus_info_generic,
.set_lan_id = &ixgbe_set_lan_id_multi_port_pcie,
@@ -1236,6 +1449,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
static struct ixgbe_phy_operations phy_ops_82599 = {
.identify = &ixgbe_identify_phy_82599,
.identify_sfp = &ixgbe_identify_sfp_module_generic,
+ .init = &ixgbe_init_phy_ops_82599,
.reset = &ixgbe_reset_phy_generic,
.read_reg = &ixgbe_read_phy_reg_generic,
.write_reg = &ixgbe_write_phy_reg_generic,
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index 186a65069b33..0cc3c47cb453 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -71,12 +71,6 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
/* Identify the PHY */
hw->phy.ops.identify(hw);
- /*
- * Store MAC address from RAR0, clear receive address registers, and
- * clear the multicast table
- */
- hw->mac.ops.init_rx_addrs(hw);
-
/* Clear the VLAN filter table */
hw->mac.ops.clear_vfta(hw);
@@ -1595,6 +1589,13 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
u32 mflcn_reg;
u32 fccfg_reg;
u32 reg;
+ u32 rx_pba_size;
+
+#ifdef CONFIG_DCB
+ if (hw->fc.requested_mode == ixgbe_fc_pfc)
+ goto out;
+
+#endif /* CONFIG_DCB */
mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
mflcn_reg &= ~(IXGBE_MFLCN_RFCE | IXGBE_MFLCN_RPFCE);
@@ -1653,24 +1654,45 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
}
/* Enable 802.3x based flow control settings. */
+ mflcn_reg |= IXGBE_MFLCN_DPF;
IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
- /* Set up and enable Rx high/low water mark thresholds, enable XON. */
- if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
- if (hw->fc.send_xon)
- IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num),
- (hw->fc.low_water | IXGBE_FCRTL_XONE));
- else
- IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num),
- hw->fc.low_water);
+ reg = IXGBE_READ_REG(hw, IXGBE_MTQC);
+ /* Thresholds are different for link flow control when in DCB mode */
+ if (reg & IXGBE_MTQC_RT_ENA) {
+ /* Always disable XON for LFC when in DCB mode */
+ IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), 0);
+
+ rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(packetbuf_num));
+ reg = (rx_pba_size >> 2) & 0xFFE0;
+ if (hw->fc.current_mode & ixgbe_fc_tx_pause)
+ reg |= IXGBE_FCRTH_FCEN;
+ IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num), reg);
+ } else {
+ /*
+ * Set up and enable Rx high/low water mark thresholds,
+ * enable XON.
+ */
+ if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
+ if (hw->fc.send_xon) {
+ IXGBE_WRITE_REG(hw,
+ IXGBE_FCRTL_82599(packetbuf_num),
+ (hw->fc.low_water |
+ IXGBE_FCRTL_XONE));
+ } else {
+ IXGBE_WRITE_REG(hw,
+ IXGBE_FCRTL_82599(packetbuf_num),
+ hw->fc.low_water);
+ }
- IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num),
- (hw->fc.high_water | IXGBE_FCRTH_FCEN));
+ IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num),
+ (hw->fc.high_water | IXGBE_FCRTH_FCEN));
+ }
}
/* Configure pause time (2 TCs per register) */
- reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num));
+ reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2));
if ((packetbuf_num & 1) == 0)
reg = (reg & 0xFFFF0000) | hw->fc.pause_time;
else
@@ -1859,9 +1881,11 @@ s32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
* because it causes the controller to just blast out fc packets.
*/
if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
- hw_dbg(hw, "Invalid water mark configuration\n");
- ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
- goto out;
+ if (hw->fc.requested_mode != ixgbe_fc_none) {
+ hw_dbg(hw, "Invalid water mark configuration\n");
+ ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
+ goto out;
+ }
}
/*
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82598.c b/drivers/net/ixgbe/ixgbe_dcb_82598.c
index 62206273d888..f30263898ebc 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82598.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_82598.c
@@ -294,6 +294,9 @@ s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw,
u32 reg, rx_pba_size;
u8 i;
+ if (!dcb_config->pfc_mode_enable)
+ goto out;
+
/* Enable Transmit Priority Flow Control */
reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
reg &= ~IXGBE_RMCS_TFCE_802_3X;
@@ -341,6 +344,7 @@ s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw,
/* Configure flow control refresh threshold value */
IXGBE_WRITE_REG(hw, IXGBE_FCRTV, 0x3400);
+out:
return 0;
}
diff --git a/drivers/net/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ixgbe/ixgbe_dcb_nl.c
index bd0a0c276952..d56890f5c9d5 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_nl.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_nl.c
@@ -28,15 +28,22 @@
#include "ixgbe.h"
#include <linux/dcbnl.h>
+#include "ixgbe_dcb_82598.h"
+#include "ixgbe_dcb_82599.h"
/* Callbacks for DCB netlink in the kernel */
#define BIT_DCB_MODE 0x01
#define BIT_PFC 0x02
#define BIT_PG_RX 0x04
#define BIT_PG_TX 0x08
-#define BIT_BCN 0x10
+#define BIT_RESETLINK 0x40
#define BIT_LINKSPEED 0x80
+/* Responses for the DCB_C_SET_ALL command */
+#define DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */
+#define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
+#define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
+
int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *src_dcb_cfg,
struct ixgbe_dcb_config *dst_dcb_cfg, int tc_max)
{
@@ -124,15 +131,12 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
if (netif_running(netdev))
netdev->netdev_ops->ndo_stop(netdev);
- ixgbe_reset_interrupt_capability(adapter);
- ixgbe_napi_del_all(adapter);
- INIT_LIST_HEAD(&netdev->napi_list);
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
- adapter->tx_ring = NULL;
- adapter->rx_ring = NULL;
+ ixgbe_clear_interrupt_scheme(adapter);
- adapter->hw.fc.requested_mode = ixgbe_fc_pfc;
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
+ adapter->last_lfc_mode = adapter->hw.fc.current_mode;
+ adapter->hw.fc.requested_mode = ixgbe_fc_none;
+ }
adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
ixgbe_init_interrupt_scheme(adapter);
@@ -141,17 +145,13 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
} else {
/* Turn off DCB */
if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
- adapter->hw.fc.requested_mode = ixgbe_fc_default;
if (netif_running(netdev))
netdev->netdev_ops->ndo_stop(netdev);
- ixgbe_reset_interrupt_capability(adapter);
- ixgbe_napi_del_all(adapter);
- INIT_LIST_HEAD(&netdev->napi_list);
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
- adapter->tx_ring = NULL;
- adapter->rx_ring = NULL;
+ ixgbe_clear_interrupt_scheme(adapter);
+ adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
+ adapter->temp_dcb_cfg.pfc_mode_enable = false;
+ adapter->dcb_cfg.pfc_mode_enable = false;
adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
ixgbe_init_interrupt_scheme(adapter);
@@ -167,10 +167,15 @@ static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
u8 *perm_addr)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
- int i;
+ int i, j;
for (i = 0; i < netdev->addr_len; i++)
perm_addr[i] = adapter->hw.mac.perm_addr[i];
+
+ if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
+ for (j = 0; j < netdev->addr_len; j++, i++)
+ perm_addr[i] = adapter->hw.mac.san_addr[j];
+ }
}
static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
@@ -197,8 +202,10 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
(adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent !=
adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent) ||
(adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap !=
- adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap))
+ adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap)) {
adapter->dcb_set_bitmap |= BIT_PG_TX;
+ adapter->dcb_set_bitmap |= BIT_RESETLINK;
+ }
}
static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
@@ -209,8 +216,10 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
if (adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] !=
- adapter->dcb_cfg.bw_percentage[0][bwg_id])
+ adapter->dcb_cfg.bw_percentage[0][bwg_id]) {
adapter->dcb_set_bitmap |= BIT_PG_RX;
+ adapter->dcb_set_bitmap |= BIT_RESETLINK;
+ }
}
static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
@@ -237,8 +246,10 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
(adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent !=
adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent) ||
(adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap !=
- adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap))
+ adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap)) {
adapter->dcb_set_bitmap |= BIT_PG_RX;
+ adapter->dcb_set_bitmap |= BIT_RESETLINK;
+ }
}
static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
@@ -249,8 +260,10 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
if (adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] !=
- adapter->dcb_cfg.bw_percentage[1][bwg_id])
+ adapter->dcb_cfg.bw_percentage[1][bwg_id]) {
adapter->dcb_set_bitmap |= BIT_PG_RX;
+ adapter->dcb_set_bitmap |= BIT_RESETLINK;
+ }
}
static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
@@ -319,28 +332,60 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
struct ixgbe_adapter *adapter = netdev_priv(netdev);
int ret;
- adapter->dcb_set_bitmap &= ~BIT_BCN; /* no set for BCN */
if (!adapter->dcb_set_bitmap)
- return 1;
+ return DCB_NO_HW_CHG;
- while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
- msleep(1);
+ /*
+ * Only take down the adapter if the configuration change
+ * requires a reset.
+ */
+ if (adapter->dcb_set_bitmap & BIT_RESETLINK) {
+ while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
+ msleep(1);
- if (netif_running(netdev))
- ixgbe_down(adapter);
+ if (netif_running(netdev))
+ ixgbe_down(adapter);
+ }
ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg,
adapter->ring_feature[RING_F_DCB].indices);
if (ret) {
- clear_bit(__IXGBE_RESETTING, &adapter->state);
- return ret;
+ if (adapter->dcb_set_bitmap & BIT_RESETLINK)
+ clear_bit(__IXGBE_RESETTING, &adapter->state);
+ return DCB_NO_HW_CHG;
+ }
+
+ if (adapter->dcb_cfg.pfc_mode_enable) {
+ if ((adapter->hw.mac.type != ixgbe_mac_82598EB) &&
+ (adapter->hw.fc.current_mode != ixgbe_fc_pfc))
+ adapter->last_lfc_mode = adapter->hw.fc.current_mode;
+ adapter->hw.fc.requested_mode = ixgbe_fc_pfc;
+ } else {
+ if (adapter->hw.mac.type != ixgbe_mac_82598EB)
+ adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
+ else
+ adapter->hw.fc.requested_mode = ixgbe_fc_none;
}
- if (netif_running(netdev))
- ixgbe_up(adapter);
+ if (adapter->dcb_set_bitmap & BIT_RESETLINK) {
+ if (netif_running(netdev))
+ ixgbe_up(adapter);
+ ret = DCB_HW_CHG_RST;
+ } else if (adapter->dcb_set_bitmap & BIT_PFC) {
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+ ixgbe_dcb_config_pfc_82598(&adapter->hw,
+ &adapter->dcb_cfg);
+ else if (adapter->hw.mac.type == ixgbe_mac_82599EB)
+ ixgbe_dcb_config_pfc_82599(&adapter->hw,
+ &adapter->dcb_cfg);
+ ret = DCB_HW_CHG;
+ }
+ if (adapter->dcb_cfg.pfc_mode_enable)
+ adapter->hw.fc.current_mode = ixgbe_fc_pfc;
+ if (adapter->dcb_set_bitmap & BIT_RESETLINK)
+ clear_bit(__IXGBE_RESETTING, &adapter->state);
adapter->dcb_set_bitmap = 0x00;
- clear_bit(__IXGBE_RESETTING, &adapter->state);
return ret;
}
@@ -416,11 +461,17 @@ static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
- return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
+ return adapter->dcb_cfg.pfc_mode_enable;
}
static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+
+ adapter->temp_dcb_cfg.pfc_mode_enable = state;
+ if (adapter->temp_dcb_cfg.pfc_mode_enable !=
+ adapter->dcb_cfg.pfc_mode_enable)
+ adapter->dcb_set_bitmap |= BIT_PFC;
return;
}
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index f0a20facc650..35255b8e90b7 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -67,6 +67,7 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
{"rx_over_errors", IXGBE_STAT(net_stats.rx_over_errors)},
{"rx_crc_errors", IXGBE_STAT(net_stats.rx_crc_errors)},
{"rx_frame_errors", IXGBE_STAT(net_stats.rx_frame_errors)},
+ {"hw_rsc_count", IXGBE_STAT(rsc_count)},
{"rx_fifo_errors", IXGBE_STAT(net_stats.rx_fifo_errors)},
{"rx_missed_errors", IXGBE_STAT(net_stats.rx_missed_errors)},
{"tx_aborted_errors", IXGBE_STAT(net_stats.tx_aborted_errors)},
@@ -90,6 +91,14 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
{"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)},
{"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)},
{"rx_no_dma_resources", IXGBE_STAT(hw_rx_no_dma_resources)},
+#ifdef IXGBE_FCOE
+ {"fcoe_bad_fccrc", IXGBE_STAT(stats.fccrc)},
+ {"rx_fcoe_dropped", IXGBE_STAT(stats.fcoerpdc)},
+ {"rx_fcoe_packets", IXGBE_STAT(stats.fcoeprc)},
+ {"rx_fcoe_dwords", IXGBE_STAT(stats.fcoedwrc)},
+ {"tx_fcoe_packets", IXGBE_STAT(stats.fcoeptc)},
+ {"tx_fcoe_dwords", IXGBE_STAT(stats.fcoedwtc)},
+#endif /* IXGBE_FCOE */
};
#define IXGBE_QUEUE_STATS_LEN \
@@ -245,6 +254,13 @@ static void ixgbe_get_pauseparam(struct net_device *netdev,
else
pause->autoneg = 1;
+#ifdef CONFIG_DCB
+ if (hw->fc.current_mode == ixgbe_fc_pfc) {
+ pause->rx_pause = 0;
+ pause->tx_pause = 0;
+ }
+
+#endif
if (hw->fc.current_mode == ixgbe_fc_rx_pause) {
pause->rx_pause = 1;
} else if (hw->fc.current_mode == ixgbe_fc_tx_pause) {
@@ -261,6 +277,13 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw;
+#ifdef CONFIG_DCB
+ if (adapter->dcb_cfg.pfc_mode_enable ||
+ ((hw->mac.type == ixgbe_mac_82598EB) &&
+ (adapter->flags & IXGBE_FLAG_DCB_ENABLED)))
+ return -EINVAL;
+
+#endif
if (pause->autoneg != AUTONEG_ENABLE)
hw->fc.disable_fc_autoneg = true;
else
@@ -277,6 +300,9 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
else
return -EINVAL;
+#ifdef CONFIG_DCB
+ adapter->last_lfc_mode = hw->fc.requested_mode;
+#endif
hw->mac.ops.setup_fc(hw, 0);
return 0;
@@ -311,10 +337,17 @@ static u32 ixgbe_get_tx_csum(struct net_device *netdev)
static int ixgbe_set_tx_csum(struct net_device *netdev, u32 data)
{
- if (data)
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+
+ if (data) {
netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
- else
+ if (adapter->hw.mac.type == ixgbe_mac_82599EB)
+ netdev->features |= NETIF_F_SCTP_CSUM;
+ } else {
netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+ if (adapter->hw.mac.type == ixgbe_mac_82599EB)
+ netdev->features &= ~NETIF_F_SCTP_CSUM;
+ }
return 0;
}
@@ -1106,7 +1139,7 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
}
for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++) {
- struct ixgbe_q_vector *q_vector = &adapter->q_vector[i];
+ struct ixgbe_q_vector *q_vector = adapter->q_vector[i];
if (q_vector->txr_count && !q_vector->rxr_count)
/* tx vector gets half the rate */
q_vector->eitr = (adapter->eitr_param >> 1);
@@ -1120,6 +1153,27 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
return 0;
}
+static int ixgbe_set_flags(struct net_device *netdev, u32 data)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+
+ ethtool_op_set_flags(netdev, data);
+
+ if (!(adapter->flags & IXGBE_FLAG_RSC_CAPABLE))
+ return 0;
+
+ /* if state changes we need to update adapter->flags and reset */
+ if ((!!(data & ETH_FLAG_LRO)) !=
+ (!!(adapter->flags & IXGBE_FLAG_RSC_ENABLED))) {
+ adapter->flags ^= IXGBE_FLAG_RSC_ENABLED;
+ if (netif_running(netdev))
+ ixgbe_reinit_locked(adapter);
+ else
+ ixgbe_reset(adapter);
+ }
+ return 0;
+
+}
static const struct ethtool_ops ixgbe_ethtool_ops = {
.get_settings = ixgbe_get_settings,
@@ -1154,7 +1208,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {
.get_coalesce = ixgbe_get_coalesce,
.set_coalesce = ixgbe_set_coalesce,
.get_flags = ethtool_op_get_flags,
- .set_flags = ethtool_op_set_flags,
+ .set_flags = ixgbe_set_flags,
};
void ixgbe_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ixgbe/ixgbe_fcoe.c b/drivers/net/ixgbe/ixgbe_fcoe.c
new file mode 100644
index 000000000000..d5939de8ba28
--- /dev/null
+++ b/drivers/net/ixgbe/ixgbe_fcoe.c
@@ -0,0 +1,552 @@
+/*******************************************************************************
+
+ Intel 10 Gigabit PCI Express Linux driver
+ Copyright(c) 1999 - 2009 Intel Corporation.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms and conditions of the GNU General Public License,
+ version 2, as published by the Free Software Foundation.
+
+ This program is distributed in the hope it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+ The full GNU General Public License is included in this distribution in
+ the file called "COPYING".
+
+ Contact Information:
+ e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+
+#include "ixgbe.h"
+#include <linux/if_ether.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/fc/fc_fs.h>
+#include <scsi/fc/fc_fcoe.h>
+#include <scsi/libfc.h>
+#include <scsi/libfcoe.h>
+
+/**
+ * ixgbe_rx_is_fcoe - check the rx desc for incoming pkt type
+ * @rx_desc: advanced rx descriptor
+ *
+ * Returns : true if it is FCoE pkt
+ */
+static inline bool ixgbe_rx_is_fcoe(union ixgbe_adv_rx_desc *rx_desc)
+{
+ u16 p;
+
+ p = le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.pkt_info);
+ if (p & IXGBE_RXDADV_PKTTYPE_ETQF) {
+ p &= IXGBE_RXDADV_PKTTYPE_ETQF_MASK;
+ p >>= IXGBE_RXDADV_PKTTYPE_ETQF_SHIFT;
+ return p == IXGBE_ETQF_FILTER_FCOE;
+ }
+ return false;
+}
+
+/**
+ * ixgbe_fcoe_clear_ddp - clear the given ddp context
+ * @ddp - ptr to the ixgbe_fcoe_ddp
+ *
+ * Returns : none
+ *
+ */
+static inline void ixgbe_fcoe_clear_ddp(struct ixgbe_fcoe_ddp *ddp)
+{
+ ddp->len = 0;
+ ddp->err = 0;
+ ddp->udl = NULL;
+ ddp->udp = 0UL;
+ ddp->sgl = NULL;
+ ddp->sgc = 0;
+}
+
+/**
+ * ixgbe_fcoe_ddp_put - free the ddp context for a given xid
+ * @netdev: the corresponding net_device
+ * @xid: the xid that corresponding ddp will be freed
+ *
+ * This is the implementation of net_device_ops.ndo_fcoe_ddp_done
+ * and it is expected to be called by ULD, i.e., FCP layer of libfc
+ * to release the corresponding ddp context when the I/O is done.
+ *
+ * Returns : data length already ddp-ed in bytes
+ */
+int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid)
+{
+ int len = 0;
+ struct ixgbe_fcoe *fcoe;
+ struct ixgbe_adapter *adapter;
+ struct ixgbe_fcoe_ddp *ddp;
+
+ if (!netdev)
+ goto out_ddp_put;
+
+ if (xid >= IXGBE_FCOE_DDP_MAX)
+ goto out_ddp_put;
+
+ adapter = netdev_priv(netdev);
+ fcoe = &adapter->fcoe;
+ ddp = &fcoe->ddp[xid];
+ if (!ddp->udl)
+ goto out_ddp_put;
+
+ len = ddp->len;
+ /* if there an error, force to invalidate ddp context */
+ if (ddp->err) {
+ spin_lock_bh(&fcoe->lock);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCFLT, 0);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCFLTRW,
+ (xid | IXGBE_FCFLTRW_WE));
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCBUFF, 0);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCDMARW,
+ (xid | IXGBE_FCDMARW_WE));
+ spin_unlock_bh(&fcoe->lock);
+ }
+ if (ddp->sgl)
+ pci_unmap_sg(adapter->pdev, ddp->sgl, ddp->sgc,
+ DMA_FROM_DEVICE);
+ pci_pool_free(fcoe->pool, ddp->udl, ddp->udp);
+ ixgbe_fcoe_clear_ddp(ddp);
+
+out_ddp_put:
+ return len;
+}
+
+/**
+ * ixgbe_fcoe_ddp_get - called to set up ddp context
+ * @netdev: the corresponding net_device
+ * @xid: the exchange id requesting ddp
+ * @sgl: the scatter-gather list for this request
+ * @sgc: the number of scatter-gather items
+ *
+ * This is the implementation of net_device_ops.ndo_fcoe_ddp_setup
+ * and is expected to be called from ULD, e.g., FCP layer of libfc
+ * to set up ddp for the corresponding xid of the given sglist for
+ * the corresponding I/O.
+ *
+ * Returns : 1 for success and 0 for no ddp
+ */
+int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
+ struct scatterlist *sgl, unsigned int sgc)
+{
+ struct ixgbe_adapter *adapter;
+ struct ixgbe_hw *hw;
+ struct ixgbe_fcoe *fcoe;
+ struct ixgbe_fcoe_ddp *ddp;
+ struct scatterlist *sg;
+ unsigned int i, j, dmacount;
+ unsigned int len;
+ static const unsigned int bufflen = 4096;
+ unsigned int firstoff = 0;
+ unsigned int lastsize;
+ unsigned int thisoff = 0;
+ unsigned int thislen = 0;
+ u32 fcbuff, fcdmarw, fcfltrw;
+ dma_addr_t addr;
+
+ if (!netdev || !sgl)
+ return 0;
+
+ adapter = netdev_priv(netdev);
+ if (xid >= IXGBE_FCOE_DDP_MAX) {
+ DPRINTK(DRV, WARNING, "xid=0x%x out-of-range\n", xid);
+ return 0;
+ }
+
+ fcoe = &adapter->fcoe;
+ if (!fcoe->pool) {
+ DPRINTK(DRV, WARNING, "xid=0x%x no ddp pool for fcoe\n", xid);
+ return 0;
+ }
+
+ ddp = &fcoe->ddp[xid];
+ if (ddp->sgl) {
+ DPRINTK(DRV, ERR, "xid 0x%x w/ non-null sgl=%p nents=%d\n",
+ xid, ddp->sgl, ddp->sgc);
+ return 0;
+ }
+ ixgbe_fcoe_clear_ddp(ddp);
+
+ /* setup dma from scsi command sgl */
+ dmacount = pci_map_sg(adapter->pdev, sgl, sgc, DMA_FROM_DEVICE);
+ if (dmacount == 0) {
+ DPRINTK(DRV, ERR, "xid 0x%x DMA map error\n", xid);
+ return 0;
+ }
+
+ /* alloc the udl from our ddp pool */
+ ddp->udl = pci_pool_alloc(fcoe->pool, GFP_KERNEL, &ddp->udp);
+ if (!ddp->udl) {
+ DPRINTK(DRV, ERR, "failed allocated ddp context\n");
+ goto out_noddp_unmap;
+ }
+ ddp->sgl = sgl;
+ ddp->sgc = sgc;
+
+ j = 0;
+ for_each_sg(sgl, sg, dmacount, i) {
+ addr = sg_dma_address(sg);
+ len = sg_dma_len(sg);
+ while (len) {
+ /* get the offset of length of current buffer */
+ thisoff = addr & ((dma_addr_t)bufflen - 1);
+ thislen = min((bufflen - thisoff), len);
+ /*
+ * all but the 1st buffer (j == 0)
+ * must be aligned on bufflen
+ */
+ if ((j != 0) && (thisoff))
+ goto out_noddp_free;
+ /*
+ * all but the last buffer
+ * ((i == (dmacount - 1)) && (thislen == len))
+ * must end at bufflen
+ */
+ if (((i != (dmacount - 1)) || (thislen != len))
+ && ((thislen + thisoff) != bufflen))
+ goto out_noddp_free;
+
+ ddp->udl[j] = (u64)(addr - thisoff);
+ /* only the first buffer may have none-zero offset */
+ if (j == 0)
+ firstoff = thisoff;
+ len -= thislen;
+ addr += thislen;
+ j++;
+ /* max number of buffers allowed in one DDP context */
+ if (j > IXGBE_BUFFCNT_MAX) {
+ DPRINTK(DRV, ERR, "xid=%x:%d,%d,%d:addr=%llx "
+ "not enough descriptors\n",
+ xid, i, j, dmacount, (u64)addr);
+ goto out_noddp_free;
+ }
+ }
+ }
+ /* only the last buffer may have non-full bufflen */
+ lastsize = thisoff + thislen;
+
+ fcbuff = (IXGBE_FCBUFF_4KB << IXGBE_FCBUFF_BUFFSIZE_SHIFT);
+ fcbuff |= (j << IXGBE_FCBUFF_BUFFCNT_SHIFT);
+ fcbuff |= (firstoff << IXGBE_FCBUFF_OFFSET_SHIFT);
+ fcbuff |= (IXGBE_FCBUFF_VALID);
+
+ fcdmarw = xid;
+ fcdmarw |= IXGBE_FCDMARW_WE;
+ fcdmarw |= (lastsize << IXGBE_FCDMARW_LASTSIZE_SHIFT);
+
+ fcfltrw = xid;
+ fcfltrw |= IXGBE_FCFLTRW_WE;
+
+ /* program DMA context */
+ hw = &adapter->hw;
+ spin_lock_bh(&fcoe->lock);
+ IXGBE_WRITE_REG(hw, IXGBE_FCPTRL, ddp->udp & DMA_32BIT_MASK);
+ IXGBE_WRITE_REG(hw, IXGBE_FCPTRH, (u64)ddp->udp >> 32);
+ IXGBE_WRITE_REG(hw, IXGBE_FCBUFF, fcbuff);
+ IXGBE_WRITE_REG(hw, IXGBE_FCDMARW, fcdmarw);
+ /* program filter context */
+ IXGBE_WRITE_REG(hw, IXGBE_FCPARAM, 0);
+ IXGBE_WRITE_REG(hw, IXGBE_FCFLT, IXGBE_FCFLT_VALID);
+ IXGBE_WRITE_REG(hw, IXGBE_FCFLTRW, fcfltrw);
+ spin_unlock_bh(&fcoe->lock);
+
+ return 1;
+
+out_noddp_free:
+ pci_pool_free(fcoe->pool, ddp->udl, ddp->udp);
+ ixgbe_fcoe_clear_ddp(ddp);
+
+out_noddp_unmap:
+ pci_unmap_sg(adapter->pdev, sgl, sgc, DMA_FROM_DEVICE);
+ return 0;
+}
+
+/**
+ * ixgbe_fcoe_ddp - check ddp status and mark it done
+ * @adapter: ixgbe adapter
+ * @rx_desc: advanced rx descriptor
+ * @skb: the skb holding the received data
+ *
+ * This checks ddp status.
+ *
+ * Returns : 0 for success and skb will not be delivered to ULD
+ */
+int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
+ union ixgbe_adv_rx_desc *rx_desc,
+ struct sk_buff *skb)
+{
+ u16 xid;
+ u32 sterr, fceofe, fcerr, fcstat;
+ int rc = -EINVAL;
+ struct ixgbe_fcoe *fcoe;
+ struct ixgbe_fcoe_ddp *ddp;
+ struct fc_frame_header *fh;
+
+ if (!ixgbe_rx_is_fcoe(rx_desc))
+ goto ddp_out;
+
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ sterr = le32_to_cpu(rx_desc->wb.upper.status_error);
+ fcerr = (sterr & IXGBE_RXDADV_ERR_FCERR);
+ fceofe = (sterr & IXGBE_RXDADV_ERR_FCEOFE);
+ if (fcerr == IXGBE_FCERR_BADCRC)
+ skb->ip_summed = CHECKSUM_NONE;
+
+ skb_reset_network_header(skb);
+ skb_set_transport_header(skb, skb_network_offset(skb) +
+ sizeof(struct fcoe_hdr));
+ fh = (struct fc_frame_header *)skb_transport_header(skb);
+ xid = be16_to_cpu(fh->fh_ox_id);
+ if (xid >= IXGBE_FCOE_DDP_MAX)
+ goto ddp_out;
+
+ fcoe = &adapter->fcoe;
+ ddp = &fcoe->ddp[xid];
+ if (!ddp->udl)
+ goto ddp_out;
+
+ ddp->err = (fcerr | fceofe);
+ if (ddp->err)
+ goto ddp_out;
+
+ fcstat = (sterr & IXGBE_RXDADV_STAT_FCSTAT);
+ if (fcstat) {
+ /* update length of DDPed data */
+ ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);
+ /* unmap the sg list when FCP_RSP is received */
+ if (fcstat == IXGBE_RXDADV_STAT_FCSTAT_FCPRSP) {
+ pci_unmap_sg(adapter->pdev, ddp->sgl,
+ ddp->sgc, DMA_FROM_DEVICE);
+ ddp->sgl = NULL;
+ ddp->sgc = 0;
+ }
+ /* return 0 to bypass going to ULD for DDPed data */
+ if (fcstat == IXGBE_RXDADV_STAT_FCSTAT_DDP)
+ rc = 0;
+ }
+
+ddp_out:
+ return rc;
+}
+
+/**
+ * ixgbe_fso - ixgbe FCoE Sequence Offload (FSO)
+ * @adapter: ixgbe adapter
+ * @tx_ring: tx desc ring
+ * @skb: associated skb
+ * @tx_flags: tx flags
+ * @hdr_len: hdr_len to be returned
+ *
+ * This sets up large send offload for FCoE
+ *
+ * Returns : 0 indicates no FSO, > 0 for FSO, < 0 for error
+ */
+int ixgbe_fso(struct ixgbe_adapter *adapter,
+ struct ixgbe_ring *tx_ring, struct sk_buff *skb,
+ u32 tx_flags, u8 *hdr_len)
+{
+ u8 sof, eof;
+ u32 vlan_macip_lens;
+ u32 fcoe_sof_eof;
+ u32 type_tucmd;
+ u32 mss_l4len_idx;
+ int mss = 0;
+ unsigned int i;
+ struct ixgbe_tx_buffer *tx_buffer_info;
+ struct ixgbe_adv_tx_context_desc *context_desc;
+ struct fc_frame_header *fh;
+
+ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_type != SKB_GSO_FCOE)) {
+ DPRINTK(DRV, ERR, "Wrong gso type %d:expecting SKB_GSO_FCOE\n",
+ skb_shinfo(skb)->gso_type);
+ return -EINVAL;
+ }
+
+ /* resets the header to point fcoe/fc */
+ skb_set_network_header(skb, skb->mac_len);
+ skb_set_transport_header(skb, skb->mac_len +
+ sizeof(struct fcoe_hdr));
+
+ /* sets up SOF and ORIS */
+ fcoe_sof_eof = 0;
+ sof = ((struct fcoe_hdr *)skb_network_header(skb))->fcoe_sof;
+ switch (sof) {
+ case FC_SOF_I2:
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_ORIS;
+ break;
+ case FC_SOF_I3:
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_SOF;
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_ORIS;
+ break;
+ case FC_SOF_N2:
+ break;
+ case FC_SOF_N3:
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_SOF;
+ break;
+ default:
+ DPRINTK(DRV, WARNING, "unknown sof = 0x%x\n", sof);
+ return -EINVAL;
+ }
+
+ /* the first byte of the last dword is EOF */
+ skb_copy_bits(skb, skb->len - 4, &eof, 1);
+ /* sets up EOF and ORIE */
+ switch (eof) {
+ case FC_EOF_N:
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_N;
+ break;
+ case FC_EOF_T:
+ /* lso needs ORIE */
+ if (skb_is_gso(skb)) {
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_N;
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_ORIE;
+ } else {
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_T;
+ }
+ break;
+ case FC_EOF_NI:
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_NI;
+ break;
+ case FC_EOF_A:
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_A;
+ break;
+ default:
+ DPRINTK(DRV, WARNING, "unknown eof = 0x%x\n", eof);
+ return -EINVAL;
+ }
+
+ /* sets up PARINC indicating data offset */
+ fh = (struct fc_frame_header *)skb_transport_header(skb);
+ if (fh->fh_f_ctl[2] & FC_FC_REL_OFF)
+ fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_PARINC;
+
+ /* hdr_len includes fc_hdr if FCoE lso is enabled */
+ *hdr_len = sizeof(struct fcoe_crc_eof);
+ if (skb_is_gso(skb))
+ *hdr_len += (skb_transport_offset(skb) +
+ sizeof(struct fc_frame_header));
+ /* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */
+ vlan_macip_lens = (skb_transport_offset(skb) +
+ sizeof(struct fc_frame_header));
+ vlan_macip_lens |= ((skb_transport_offset(skb) - 4)
+ << IXGBE_ADVTXD_MACLEN_SHIFT);
+ vlan_macip_lens |= (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK);
+
+ /* type_tycmd and mss: set TUCMD.FCoE to enable offload */
+ type_tucmd = IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT |
+ IXGBE_ADVTXT_TUCMD_FCOE;
+ if (skb_is_gso(skb))
+ mss = skb_shinfo(skb)->gso_size;
+ /* mss_l4len_id: use 1 for FSO as TSO, no need for L4LEN */
+ mss_l4len_idx = (mss << IXGBE_ADVTXD_MSS_SHIFT) |
+ (1 << IXGBE_ADVTXD_IDX_SHIFT);
+
+ /* write context desc */
+ i = tx_ring->next_to_use;
+ context_desc = IXGBE_TX_CTXTDESC_ADV(*tx_ring, i);
+ context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens);
+ context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof);
+ context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd);
+ context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx);
+
+ tx_buffer_info = &tx_ring->tx_buffer_info[i];
+ tx_buffer_info->time_stamp = jiffies;
+ tx_buffer_info->next_to_watch = i;
+
+ i++;
+ if (i == tx_ring->count)
+ i = 0;
+ tx_ring->next_to_use = i;
+
+ return skb_is_gso(skb);
+}
+
+/**
+ * ixgbe_configure_fcoe - configures registers for fcoe at start
+ * @adapter: ptr to ixgbe adapter
+ *
+ * This sets up FCoE related registers
+ *
+ * Returns : none
+ */
+void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
+{
+ int i, fcoe_q, fcoe_i;
+ struct ixgbe_hw *hw = &adapter->hw;
+ struct ixgbe_fcoe *fcoe = &adapter->fcoe;
+ struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE];
+
+ /* create the pool for ddp if not created yet */
+ if (!fcoe->pool) {
+ /* allocate ddp pool */
+ fcoe->pool = pci_pool_create("ixgbe_fcoe_ddp",
+ adapter->pdev, IXGBE_FCPTR_MAX,
+ IXGBE_FCPTR_ALIGN, PAGE_SIZE);
+ if (!fcoe->pool)
+ DPRINTK(DRV, ERR,
+ "failed to allocated FCoE DDP pool\n");
+
+ spin_lock_init(&fcoe->lock);
+ }
+
+ /* Enable L2 eth type filter for FCoE */
+ IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FCOE),
+ (ETH_P_FCOE | IXGBE_ETQF_FCOE | IXGBE_ETQF_FILTER_EN));
+ if (adapter->ring_feature[RING_F_FCOE].indices) {
+ /* Use multiple rx queues for FCoE by redirection table */
+ for (i = 0; i < IXGBE_FCRETA_SIZE; i++) {
+ fcoe_i = f->mask + i % f->indices;
+ fcoe_i &= IXGBE_FCRETA_ENTRY_MASK;
+ fcoe_q = adapter->rx_ring[fcoe_i].reg_idx;
+ IXGBE_WRITE_REG(hw, IXGBE_FCRETA(i), fcoe_q);
+ }
+ IXGBE_WRITE_REG(hw, IXGBE_FCRECTL, IXGBE_FCRECTL_ENA);
+ IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FCOE), 0);
+ } else {
+ /* Use single rx queue for FCoE */
+ fcoe_i = f->mask;
+ fcoe_q = adapter->rx_ring[fcoe_i].reg_idx;
+ IXGBE_WRITE_REG(hw, IXGBE_FCRECTL, 0);
+ IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FCOE),
+ IXGBE_ETQS_QUEUE_EN |
+ (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
+ }
+
+ IXGBE_WRITE_REG(hw, IXGBE_FCRXCTRL,
+ IXGBE_FCRXCTRL_FCOELLI |
+ IXGBE_FCRXCTRL_FCCRCBO |
+ (FC_FCOE_VER << IXGBE_FCRXCTRL_FCOEVER_SHIFT));
+}
+
+/**
+ * ixgbe_cleanup_fcoe - release all fcoe ddp context resources
+ * @adapter : ixgbe adapter
+ *
+ * Cleans up outstanding ddp context resources
+ *
+ * Returns : none
+ */
+void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter)
+{
+ int i;
+ struct ixgbe_fcoe *fcoe = &adapter->fcoe;
+
+ /* release ddp resource */
+ if (fcoe->pool) {
+ for (i = 0; i < IXGBE_FCOE_DDP_MAX; i++)
+ ixgbe_fcoe_ddp_put(adapter->netdev, i);
+ pci_pool_destroy(fcoe->pool);
+ fcoe->pool = NULL;
+ }
+}
diff --git a/drivers/net/ixgbe/ixgbe_fcoe.h b/drivers/net/ixgbe/ixgbe_fcoe.h
new file mode 100644
index 000000000000..b7f9b63aa49f
--- /dev/null
+++ b/drivers/net/ixgbe/ixgbe_fcoe.h
@@ -0,0 +1,66 @@
+/*******************************************************************************
+
+ Intel 10 Gigabit PCI Express Linux driver
+ Copyright(c) 1999 - 2009 Intel Corporation.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms and conditions of the GNU General Public License,
+ version 2, as published by the Free Software Foundation.
+
+ This program is distributed in the hope it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+ The full GNU General Public License is included in this distribution in
+ the file called "COPYING".
+
+ Contact Information:
+ e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _IXGBE_FCOE_H
+#define _IXGBE_FCOE_H
+
+#include <scsi/fc/fc_fcoe.h>
+
+/* shift bits within STAT fo FCSTAT */
+#define IXGBE_RXDADV_FCSTAT_SHIFT 4
+
+/* ddp user buffer */
+#define IXGBE_BUFFCNT_MAX 256 /* 8 bits bufcnt */
+#define IXGBE_FCPTR_ALIGN 16
+#define IXGBE_FCPTR_MAX (IXGBE_BUFFCNT_MAX * sizeof(dma_addr_t))
+#define IXGBE_FCBUFF_4KB 0x0
+#define IXGBE_FCBUFF_8KB 0x1
+#define IXGBE_FCBUFF_16KB 0x2
+#define IXGBE_FCBUFF_64KB 0x3
+#define IXGBE_FCBUFF_MAX 65536 /* 64KB max */
+#define IXGBE_FCBUFF_MIN 4096 /* 4KB min */
+#define IXGBE_FCOE_DDP_MAX 512 /* 9 bits xid */
+
+/* fcerr */
+#define IXGBE_FCERR_BADCRC 0x00100000
+
+struct ixgbe_fcoe_ddp {
+ int len;
+ u32 err;
+ unsigned int sgc;
+ struct scatterlist *sgl;
+ dma_addr_t udp;
+ u64 *udl;
+};
+
+struct ixgbe_fcoe {
+ spinlock_t lock;
+ struct pci_pool *pool;
+ struct ixgbe_fcoe_ddp ddp[IXGBE_FCOE_DDP_MAX];
+};
+
+#endif /* _IXGBE_FCOE_H */
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 07e778d3e5d2..e52798c4816b 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -39,6 +39,7 @@
#include <net/ip6_checksum.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
+#include <scsi/fc/fc_fcoe.h>
#include "ixgbe.h"
#include "ixgbe_common.h"
@@ -47,7 +48,7 @@ char ixgbe_driver_name[] = "ixgbe";
static const char ixgbe_driver_string[] =
"Intel(R) 10 Gigabit PCI Express Network Driver";
-#define DRV_VERSION "2.0.8-k2"
+#define DRV_VERSION "2.0.24-k2"
const char ixgbe_driver_version[] = DRV_VERSION;
static char ixgbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation.";
@@ -89,6 +90,8 @@ static struct pci_device_id ixgbe_pci_tbl[] = {
board_82598 },
{PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_KX4),
board_82599 },
+ {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_XAUI_LOM),
+ board_82599 },
{PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP),
board_82599 },
@@ -326,8 +329,18 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter *adapter,
}
/* re-arm the interrupt */
- if (count >= tx_ring->work_limit)
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, tx_ring->v_idx);
+ if (count >= tx_ring->work_limit) {
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS,
+ tx_ring->v_idx);
+ else if (tx_ring->v_idx & 0xFFFFFFFF)
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0),
+ tx_ring->v_idx);
+ else
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1),
+ (tx_ring->v_idx >> 32));
+ }
+
tx_ring->total_bytes += total_bytes;
tx_ring->total_packets += total_packets;
@@ -398,6 +411,9 @@ static void ixgbe_setup_dca(struct ixgbe_adapter *adapter)
if (!(adapter->flags & IXGBE_FLAG_DCA_ENABLED))
return;
+ /* always use CB2 mode, difference is masked in the CB driver */
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, 2);
+
for (i = 0; i < adapter->num_tx_queues; i++) {
adapter->tx_ring[i].cpu = -1;
ixgbe_update_tx_dca(adapter, &adapter->tx_ring[i]);
@@ -419,9 +435,6 @@ static int __ixgbe_notify_dca(struct device *dev, void *data)
/* if we're already enabled, don't do it again */
if (adapter->flags & IXGBE_FLAG_DCA_ENABLED)
break;
- /* Always use CB2 mode, difference is masked
- * in the CB driver. */
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, 2);
if (dca_add_requester(dev) == 0) {
adapter->flags |= IXGBE_FLAG_DCA_ENABLED;
ixgbe_setup_dca(adapter);
@@ -451,6 +464,7 @@ static int __ixgbe_notify_dca(struct device *dev, void *data)
**/
static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector,
struct sk_buff *skb, u8 status,
+ struct ixgbe_ring *ring,
union ixgbe_adv_rx_desc *rx_desc)
{
struct ixgbe_adapter *adapter = q_vector->adapter;
@@ -458,24 +472,17 @@ static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector,
bool is_vlan = (status & IXGBE_RXD_STAT_VP);
u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan);
- skb_record_rx_queue(skb, q_vector - &adapter->q_vector[0]);
- if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
+ skb_record_rx_queue(skb, ring->queue_index);
+ if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
if (adapter->vlgrp && is_vlan && (tag != 0))
vlan_gro_receive(napi, adapter->vlgrp, tag, skb);
else
napi_gro_receive(napi, skb);
} else {
- if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
- if (adapter->vlgrp && is_vlan && (tag != 0))
- vlan_hwaccel_receive_skb(skb, adapter->vlgrp, tag);
- else
- netif_receive_skb(skb);
- } else {
- if (adapter->vlgrp && is_vlan && (tag != 0))
- vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
- else
- netif_rx(skb);
- }
+ if (adapter->vlgrp && is_vlan && (tag != 0))
+ vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
+ else
+ netif_rx(skb);
}
}
@@ -622,6 +629,40 @@ static inline u16 ixgbe_get_pkt_info(union ixgbe_adv_rx_desc *rx_desc)
return rx_desc->wb.lower.lo_dword.hs_rss.pkt_info;
}
+static inline u32 ixgbe_get_rsc_count(union ixgbe_adv_rx_desc *rx_desc)
+{
+ return (le32_to_cpu(rx_desc->wb.lower.lo_dword.data) &
+ IXGBE_RXDADV_RSCCNT_MASK) >>
+ IXGBE_RXDADV_RSCCNT_SHIFT;
+}
+
+/**
+ * ixgbe_transform_rsc_queue - change rsc queue into a full packet
+ * @skb: pointer to the last skb in the rsc queue
+ *
+ * This function changes a queue full of hw rsc buffers into a completed
+ * packet. It uses the ->prev pointers to find the first packet and then
+ * turns it into the frag list owner.
+ **/
+static inline struct sk_buff *ixgbe_transform_rsc_queue(struct sk_buff *skb)
+{
+ unsigned int frag_list_size = 0;
+
+ while (skb->prev) {
+ struct sk_buff *prev = skb->prev;
+ frag_list_size += skb->len;
+ skb->prev = NULL;
+ skb = prev;
+ }
+
+ skb_shinfo(skb)->frag_list = skb->next;
+ skb->next = NULL;
+ skb->len += frag_list_size;
+ skb->data_len += frag_list_size;
+ skb->truesize += frag_list_size;
+ return skb;
+}
+
static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
struct ixgbe_ring *rx_ring,
int *work_done, int work_to_do)
@@ -631,7 +672,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
union ixgbe_adv_rx_desc *rx_desc, *next_rxd;
struct ixgbe_rx_buffer *rx_buffer_info, *next_buffer;
struct sk_buff *skb;
- unsigned int i;
+ unsigned int i, rsc_count = 0;
u32 len, staterr;
u16 hdr_info;
bool cleaned = false;
@@ -697,20 +738,38 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
i++;
if (i == rx_ring->count)
i = 0;
- next_buffer = &rx_ring->rx_buffer_info[i];
next_rxd = IXGBE_RX_DESC_ADV(*rx_ring, i);
prefetch(next_rxd);
-
cleaned_count++;
+
+ if (adapter->flags & IXGBE_FLAG_RSC_CAPABLE)
+ rsc_count = ixgbe_get_rsc_count(rx_desc);
+
+ if (rsc_count) {
+ u32 nextp = (staterr & IXGBE_RXDADV_NEXTP_MASK) >>
+ IXGBE_RXDADV_NEXTP_SHIFT;
+ next_buffer = &rx_ring->rx_buffer_info[nextp];
+ rx_ring->rsc_count += (rsc_count - 1);
+ } else {
+ next_buffer = &rx_ring->rx_buffer_info[i];
+ }
+
if (staterr & IXGBE_RXD_STAT_EOP) {
+ if (skb->prev)
+ skb = ixgbe_transform_rsc_queue(skb);
rx_ring->stats.packets++;
rx_ring->stats.bytes += skb->len;
} else {
- rx_buffer_info->skb = next_buffer->skb;
- rx_buffer_info->dma = next_buffer->dma;
- next_buffer->skb = skb;
- next_buffer->dma = 0;
+ if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
+ rx_buffer_info->skb = next_buffer->skb;
+ rx_buffer_info->dma = next_buffer->dma;
+ next_buffer->skb = skb;
+ next_buffer->dma = 0;
+ } else {
+ skb->next = next_buffer->skb;
+ skb->next->prev = skb;
+ }
adapter->non_eop_descs++;
goto next_desc;
}
@@ -727,7 +786,13 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
total_rx_packets++;
skb->protocol = eth_type_trans(skb, adapter->netdev);
- ixgbe_receive_skb(q_vector, skb, staterr, rx_desc);
+#ifdef IXGBE_FCOE
+ /* if ddp, not passing to ULD unless for FCP_RSP or error */
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
+ if (!ixgbe_fcoe_ddp(adapter, rx_desc, skb))
+ goto next_desc;
+#endif /* IXGBE_FCOE */
+ ixgbe_receive_skb(q_vector, skb, staterr, rx_ring, rx_desc);
next_desc:
rx_desc->wb.upper.status_error = 0;
@@ -740,7 +805,7 @@ next_desc:
/* use prefetched values */
rx_desc = next_rxd;
- rx_buffer_info = next_buffer;
+ rx_buffer_info = &rx_ring->rx_buffer_info[i];
staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
}
@@ -780,7 +845,7 @@ static void ixgbe_configure_msix(struct ixgbe_adapter *adapter)
* corresponding register.
*/
for (v_idx = 0; v_idx < q_vectors; v_idx++) {
- q_vector = &adapter->q_vector[v_idx];
+ q_vector = adapter->q_vector[v_idx];
/* XXX for_each_bit(...) */
r_idx = find_first_bit(q_vector->rxr_idx,
adapter->num_rx_queues);
@@ -929,8 +994,7 @@ static void ixgbe_set_itr_msix(struct ixgbe_q_vector *q_vector)
struct ixgbe_adapter *adapter = q_vector->adapter;
u32 new_itr;
u8 current_itr, ret_itr;
- int i, r_idx, v_idx = ((void *)q_vector - (void *)(adapter->q_vector)) /
- sizeof(struct ixgbe_q_vector);
+ int i, r_idx, v_idx = q_vector->v_idx;
struct ixgbe_ring *rx_ring, *tx_ring;
r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues);
@@ -1121,7 +1185,13 @@ static irqreturn_t ixgbe_msix_clean_rx(int irq, void *data)
r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues);
rx_ring = &(adapter->rx_ring[r_idx]);
/* disable interrupts on this vector only */
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, rx_ring->v_idx);
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, rx_ring->v_idx);
+ else if (rx_ring->v_idx & 0xFFFFFFFF)
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), rx_ring->v_idx);
+ else
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1),
+ (rx_ring->v_idx >> 32));
napi_schedule(&q_vector->napi);
return IRQ_HANDLED;
@@ -1135,6 +1205,23 @@ static irqreturn_t ixgbe_msix_clean_many(int irq, void *data)
return IRQ_HANDLED;
}
+static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter,
+ u64 qmask)
+{
+ u32 mask;
+
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
+ mask = (IXGBE_EIMS_RTX_QUEUE & qmask);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
+ } else {
+ mask = (qmask & 0xFFFFFFFF);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(0), mask);
+ mask = (qmask >> 32);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(1), mask);
+ }
+ /* skip the flush */
+}
+
/**
* ixgbe_clean_rxonly - msix (aka one shot) rx clean routine
* @napi: napi struct with our devices info in it
@@ -1167,7 +1254,7 @@ static int ixgbe_clean_rxonly(struct napi_struct *napi, int budget)
if (adapter->itr_setting & 1)
ixgbe_set_itr_msix(q_vector);
if (!test_bit(__IXGBE_DOWN, &adapter->state))
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, rx_ring->v_idx);
+ ixgbe_irq_enable_queues(adapter, rx_ring->v_idx);
}
return work_done;
@@ -1189,7 +1276,7 @@ static int ixgbe_clean_rxonly_many(struct napi_struct *napi, int budget)
struct ixgbe_ring *rx_ring = NULL;
int work_done = 0, i;
long r_idx;
- u16 enable_mask = 0;
+ u64 enable_mask = 0;
/* attempt to distribute budget to each queue fairly, but don't allow
* the budget to go below 1 because we'll exit polling */
@@ -1216,7 +1303,7 @@ static int ixgbe_clean_rxonly_many(struct napi_struct *napi, int budget)
if (adapter->itr_setting & 1)
ixgbe_set_itr_msix(q_vector);
if (!test_bit(__IXGBE_DOWN, &adapter->state))
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, enable_mask);
+ ixgbe_irq_enable_queues(adapter, enable_mask);
return 0;
}
@@ -1225,19 +1312,21 @@ static int ixgbe_clean_rxonly_many(struct napi_struct *napi, int budget)
static inline void map_vector_to_rxq(struct ixgbe_adapter *a, int v_idx,
int r_idx)
{
- a->q_vector[v_idx].adapter = a;
- set_bit(r_idx, a->q_vector[v_idx].rxr_idx);
- a->q_vector[v_idx].rxr_count++;
- a->rx_ring[r_idx].v_idx = 1 << v_idx;
+ struct ixgbe_q_vector *q_vector = a->q_vector[v_idx];
+
+ set_bit(r_idx, q_vector->rxr_idx);
+ q_vector->rxr_count++;
+ a->rx_ring[r_idx].v_idx = (u64)1 << v_idx;
}
static inline void map_vector_to_txq(struct ixgbe_adapter *a, int v_idx,
- int r_idx)
+ int t_idx)
{
- a->q_vector[v_idx].adapter = a;
- set_bit(r_idx, a->q_vector[v_idx].txr_idx);
- a->q_vector[v_idx].txr_count++;
- a->tx_ring[r_idx].v_idx = 1 << v_idx;
+ struct ixgbe_q_vector *q_vector = a->q_vector[v_idx];
+
+ set_bit(t_idx, q_vector->txr_idx);
+ q_vector->txr_count++;
+ a->tx_ring[t_idx].v_idx = (u64)1 << v_idx;
}
/**
@@ -1333,7 +1422,7 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
(!(_v)->txr_count) ? &ixgbe_msix_clean_rx : \
&ixgbe_msix_clean_many)
for (vector = 0; vector < q_vectors; vector++) {
- handler = SET_HANDLER(&adapter->q_vector[vector]);
+ handler = SET_HANDLER(adapter->q_vector[vector]);
if(handler == &ixgbe_msix_clean_rx) {
sprintf(adapter->name[vector], "%s-%s-%d",
@@ -1349,7 +1438,7 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
err = request_irq(adapter->msix_entries[vector].vector,
handler, 0, adapter->name[vector],
- &(adapter->q_vector[vector]));
+ adapter->q_vector[vector]);
if (err) {
DPRINTK(PROBE, ERR,
"request_irq failed for MSIX interrupt "
@@ -1372,7 +1461,7 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
free_queue_irqs:
for (i = vector - 1; i >= 0; i--)
free_irq(adapter->msix_entries[--vector].vector,
- &(adapter->q_vector[i]));
+ adapter->q_vector[i]);
adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
pci_disable_msix(adapter->pdev);
kfree(adapter->msix_entries);
@@ -1383,7 +1472,7 @@ out:
static void ixgbe_set_itr(struct ixgbe_adapter *adapter)
{
- struct ixgbe_q_vector *q_vector = adapter->q_vector;
+ struct ixgbe_q_vector *q_vector = adapter->q_vector[0];
u8 current_itr;
u32 new_itr = q_vector->eitr;
struct ixgbe_ring *rx_ring = &adapter->rx_ring[0];
@@ -1436,7 +1525,8 @@ static void ixgbe_set_itr(struct ixgbe_adapter *adapter)
static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
{
u32 mask;
- mask = IXGBE_EIMS_ENABLE_MASK;
+
+ mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE);
if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE)
mask |= IXGBE_EIMS_GPI_SDP1;
if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
@@ -1446,14 +1536,7 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
}
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
- if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
- /* enable the rest of the queue vectors */
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(1),
- (IXGBE_EIMS_RTX_QUEUE << 16));
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(2),
- ((IXGBE_EIMS_RTX_QUEUE << 16) |
- IXGBE_EIMS_RTX_QUEUE));
- }
+ ixgbe_irq_enable_queues(adapter, ~0);
IXGBE_WRITE_FLUSH(&adapter->hw);
}
@@ -1467,6 +1550,7 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
struct net_device *netdev = data;
struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw;
+ struct ixgbe_q_vector *q_vector = adapter->q_vector[0];
u32 eicr;
/*
@@ -1494,13 +1578,13 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
ixgbe_check_fan_failure(adapter, eicr);
- if (napi_schedule_prep(&adapter->q_vector[0].napi)) {
+ if (napi_schedule_prep(&(q_vector->napi))) {
adapter->tx_ring[0].total_packets = 0;
adapter->tx_ring[0].total_bytes = 0;
adapter->rx_ring[0].total_packets = 0;
adapter->rx_ring[0].total_bytes = 0;
/* would disable interrupts here but EIAM disabled it */
- __napi_schedule(&adapter->q_vector[0].napi);
+ __napi_schedule(&(q_vector->napi));
}
return IRQ_HANDLED;
@@ -1511,7 +1595,7 @@ static inline void ixgbe_reset_q_vectors(struct ixgbe_adapter *adapter)
int i, q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
for (i = 0; i < q_vectors; i++) {
- struct ixgbe_q_vector *q_vector = &adapter->q_vector[i];
+ struct ixgbe_q_vector *q_vector = adapter->q_vector[i];
bitmap_zero(q_vector->rxr_idx, MAX_RX_QUEUES);
bitmap_zero(q_vector->txr_idx, MAX_TX_QUEUES);
q_vector->rxr_count = 0;
@@ -1562,7 +1646,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
i--;
for (; i >= 0; i--) {
free_irq(adapter->msix_entries[i].vector,
- &(adapter->q_vector[i]));
+ adapter->q_vector[i]);
}
ixgbe_reset_q_vectors(adapter);
@@ -1577,10 +1661,12 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
**/
static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
{
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
- if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
+ } else {
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, 0xFFFF0000);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), ~0);
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1), ~0);
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(2), ~0);
}
IXGBE_WRITE_FLUSH(&adapter->hw);
if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
@@ -1592,18 +1678,6 @@ static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
}
}
-static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter)
-{
- u32 mask = IXGBE_EIMS_RTX_QUEUE;
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
- if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(1), mask << 16);
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(2),
- (mask << 16 | mask));
- }
- /* skip the flush */
-}
-
/**
* ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts
*
@@ -1673,11 +1747,34 @@ static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter, int index)
u32 srrctl;
int queue0 = 0;
unsigned long mask;
+ struct ixgbe_ring_feature *feature = adapter->ring_feature;
if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
- queue0 = index;
+ if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+ int dcb_i = feature[RING_F_DCB].indices;
+ if (dcb_i == 8)
+ queue0 = index >> 4;
+ else if (dcb_i == 4)
+ queue0 = index >> 5;
+ else
+ dev_err(&adapter->pdev->dev, "Invalid DCB "
+ "configuration\n");
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
+ struct ixgbe_ring_feature *f;
+
+ rx_ring = &adapter->rx_ring[queue0];
+ f = &adapter->ring_feature[RING_F_FCOE];
+ if ((queue0 == 0) && (index > rx_ring->reg_idx))
+ queue0 = f->mask + index -
+ rx_ring->reg_idx - 1;
+ }
+#endif /* IXGBE_FCOE */
+ } else {
+ queue0 = index;
+ }
} else {
- mask = (unsigned long) adapter->ring_feature[RING_F_RSS].mask;
+ mask = (unsigned long) feature[RING_F_RSS].mask;
queue0 = index & mask;
index = index & mask;
}
@@ -1689,33 +1786,55 @@ static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter, int index)
srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK;
srrctl &= ~IXGBE_SRRCTL_BSIZEPKT_MASK;
+ srrctl |= (IXGBE_RX_HDR_SIZE << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
+ IXGBE_SRRCTL_BSIZEHDR_MASK;
+
if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
- u16 bufsz = IXGBE_RXBUFFER_2048;
- /* grow the amount we can receive on large page machines */
- if (bufsz < (PAGE_SIZE / 2))
- bufsz = (PAGE_SIZE / 2);
- /* cap the bufsz at our largest descriptor size */
- bufsz = min((u16)IXGBE_MAX_RXBUFFER, bufsz);
-
- srrctl |= bufsz >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
+#if (PAGE_SIZE / 2) > IXGBE_MAX_RXBUFFER
+ srrctl |= IXGBE_MAX_RXBUFFER >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
+#else
+ srrctl |= (PAGE_SIZE / 2) >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
+#endif
srrctl |= IXGBE_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS;
- srrctl |= ((IXGBE_RX_HDR_SIZE <<
- IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
- IXGBE_SRRCTL_BSIZEHDR_MASK);
} else {
+ srrctl |= ALIGN(rx_ring->rx_buf_len, 1024) >>
+ IXGBE_SRRCTL_BSIZEPKT_SHIFT;
srrctl |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
-
- if (rx_ring->rx_buf_len == MAXIMUM_ETHERNET_VLAN_SIZE)
- srrctl |= IXGBE_RXBUFFER_2048 >>
- IXGBE_SRRCTL_BSIZEPKT_SHIFT;
- else
- srrctl |= rx_ring->rx_buf_len >>
- IXGBE_SRRCTL_BSIZEPKT_SHIFT;
}
IXGBE_WRITE_REG(&adapter->hw, IXGBE_SRRCTL(index), srrctl);
}
+static u32 ixgbe_setup_mrqc(struct ixgbe_adapter *adapter)
+{
+ u32 mrqc = 0;
+ int mask;
+
+ if (!(adapter->hw.mac.type == ixgbe_mac_82599EB))
+ return mrqc;
+
+ mask = adapter->flags & (IXGBE_FLAG_RSS_ENABLED
+#ifdef CONFIG_IXGBE_DCB
+ | IXGBE_FLAG_DCB_ENABLED
+#endif
+ );
+
+ switch (mask) {
+ case (IXGBE_FLAG_RSS_ENABLED):
+ mrqc = IXGBE_MRQC_RSSEN;
+ break;
+#ifdef CONFIG_IXGBE_DCB
+ case (IXGBE_FLAG_DCB_ENABLED):
+ mrqc = IXGBE_MRQC_RT8TCEN;
+ break;
+#endif /* CONFIG_IXGBE_DCB */
+ default:
+ break;
+ }
+
+ return mrqc;
+}
+
/**
* ixgbe_configure_rx - Configure 8259x Receive Unit after Reset
* @adapter: board private structure
@@ -1736,11 +1855,17 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
u32 fctrl, hlreg0;
u32 reta = 0, mrqc = 0;
u32 rdrxctl;
+ u32 rscctrl;
int rx_buf_len;
/* Decide whether to use packet split mode or not */
adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED;
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
+ adapter->flags &= ~IXGBE_FLAG_RX_PS_ENABLED;
+#endif /* IXGBE_FCOE */
+
/* Set the RX buffer length according to the mode */
if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
rx_buf_len = IXGBE_RX_HDR_SIZE;
@@ -1749,11 +1874,13 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
u32 psrtype = IXGBE_PSRTYPE_TCPHDR |
IXGBE_PSRTYPE_UDPHDR |
IXGBE_PSRTYPE_IPV4HDR |
- IXGBE_PSRTYPE_IPV6HDR;
+ IXGBE_PSRTYPE_IPV6HDR |
+ IXGBE_PSRTYPE_L2HDR;
IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), psrtype);
}
} else {
- if (netdev->mtu <= ETH_DATA_LEN)
+ if (!(adapter->flags & IXGBE_FLAG_RSC_ENABLED) &&
+ (netdev->mtu <= ETH_DATA_LEN))
rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE;
else
rx_buf_len = ALIGN(max_frame, 1024);
@@ -1770,6 +1897,10 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
else
hlreg0 |= IXGBE_HLREG0_JUMBOEN;
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
+ hlreg0 |= IXGBE_HLREG0_JUMBOEN;
+#endif
IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
rdlen = adapter->rx_ring[0].count * sizeof(union ixgbe_adv_rx_desc);
@@ -1777,8 +1908,10 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN);
- /* Setup the HW Rx Head and Tail Descriptor Pointers and
- * the Base and Length of the Rx Descriptor Ring */
+ /*
+ * Setup the HW Rx Head and Tail Descriptor Pointers and
+ * the Base and Length of the Rx Descriptor Ring
+ */
for (i = 0; i < adapter->num_rx_queues; i++) {
rdba = adapter->rx_ring[i].dma;
j = adapter->rx_ring[i].reg_idx;
@@ -1791,6 +1924,17 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
adapter->rx_ring[i].tail = IXGBE_RDT(j);
adapter->rx_ring[i].rx_buf_len = rx_buf_len;
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
+ struct ixgbe_ring_feature *f;
+ f = &adapter->ring_feature[RING_F_FCOE];
+ if ((rx_buf_len < IXGBE_FCOE_JUMBO_FRAME_SIZE) &&
+ (i >= f->mask) && (i < f->mask + f->indices))
+ adapter->rx_ring[i].rx_buf_len =
+ IXGBE_FCOE_JUMBO_FRAME_SIZE;
+ }
+
+#endif /* IXGBE_FCOE */
ixgbe_configure_srrctl(adapter, j);
}
@@ -1811,23 +1955,8 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
}
/* Program MRQC for the distribution of queues */
- if (hw->mac.type == ixgbe_mac_82599EB) {
- int mask = adapter->flags & (
- IXGBE_FLAG_RSS_ENABLED
- | IXGBE_FLAG_DCB_ENABLED
- );
+ mrqc = ixgbe_setup_mrqc(adapter);
- switch (mask) {
- case (IXGBE_FLAG_RSS_ENABLED):
- mrqc = IXGBE_MRQC_RSSEN;
- break;
- case (IXGBE_FLAG_DCB_ENABLED):
- mrqc = IXGBE_MRQC_RT8TCEN;
- break;
- default:
- break;
- }
- }
if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
/* Fill out redirection table */
for (i = 0, j = 0; i < 128; i++, j++) {
@@ -1875,8 +2004,45 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
if (hw->mac.type == ixgbe_mac_82599EB) {
rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
rdrxctl |= IXGBE_RDRXCTL_CRCSTRIP;
+ rdrxctl &= ~IXGBE_RDRXCTL_RSCFRSTSIZE;
IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
}
+
+ if (adapter->flags & IXGBE_FLAG_RSC_ENABLED) {
+ /* Enable 82599 HW-RSC */
+ for (i = 0; i < adapter->num_rx_queues; i++) {
+ j = adapter->rx_ring[i].reg_idx;
+ rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j));
+ rscctrl |= IXGBE_RSCCTL_RSCEN;
+ /*
+ * we must limit the number of descriptors so that the
+ * total size of max desc * buf_len is not greater
+ * than 65535
+ */
+ if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
+#if (MAX_SKB_FRAGS > 16)
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
+#elif (MAX_SKB_FRAGS > 8)
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
+#elif (MAX_SKB_FRAGS > 4)
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
+#else
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_1;
+#endif
+ } else {
+ if (rx_buf_len < IXGBE_RXBUFFER_4096)
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
+ else if (rx_buf_len < IXGBE_RXBUFFER_8192)
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
+ else
+ rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
+ }
+ IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl);
+ }
+ /* Disable RSC for ACK packets */
+ IXGBE_WRITE_REG(hw, IXGBE_RSCDBU,
+ (IXGBE_RSCDBU_RSCACKDIS | IXGBE_READ_REG(hw, IXGBE_RSCDBU)));
+ }
}
static void ixgbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2041,7 +2207,7 @@ static void ixgbe_napi_enable_all(struct ixgbe_adapter *adapter)
for (q_idx = 0; q_idx < q_vectors; q_idx++) {
struct napi_struct *napi;
- q_vector = &adapter->q_vector[q_idx];
+ q_vector = adapter->q_vector[q_idx];
if (!q_vector->rxr_count)
continue;
napi = &q_vector->napi;
@@ -2064,7 +2230,7 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter)
q_vectors = 1;
for (q_idx = 0; q_idx < q_vectors; q_idx++) {
- q_vector = &adapter->q_vector[q_idx];
+ q_vector = adapter->q_vector[q_idx];
if (!q_vector->rxr_count)
continue;
napi_disable(&q_vector->napi);
@@ -2140,6 +2306,11 @@ static void ixgbe_configure(struct ixgbe_adapter *adapter)
netif_set_gso_max_size(netdev, 65536);
#endif
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
+ ixgbe_configure_fcoe(adapter);
+
+#endif /* IXGBE_FCOE */
ixgbe_configure_tx(adapter);
ixgbe_configure_rx(adapter);
for (i = 0; i < adapter->num_rx_queues; i++)
@@ -2294,6 +2465,13 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
}
+#ifdef IXGBE_FCOE
+ /* adjust max frame to be able to do baby jumbo for FCoE */
+ if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
+ (max_frame < IXGBE_FCOE_JUMBO_FRAME_SIZE))
+ max_frame = IXGBE_FCOE_JUMBO_FRAME_SIZE;
+
+#endif /* IXGBE_FCOE */
mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD);
if (max_frame != (mhadd >> IXGBE_MHADD_MFS_SHIFT)) {
mhadd &= ~IXGBE_MHADD_MFS_MASK;
@@ -2357,6 +2535,17 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
ixgbe_irq_enable(adapter);
/*
+ * If this adapter has a fan, check to see if we had a failure
+ * before we enabled the interrupt.
+ */
+ if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) {
+ u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+ if (esdp & IXGBE_ESDP_SDP1)
+ DPRINTK(DRV, CRIT,
+ "Fan has stopped, replace the adapter\n");
+ }
+
+ /*
* For hot-pluggable SFP+ devices, a new SFP+ module may have
* arrived before interrupts were enabled. We need to kick off
* the SFP+ module setup first, then try to bring up link.
@@ -2404,8 +2593,6 @@ int ixgbe_up(struct ixgbe_adapter *adapter)
/* hardware has been reset, we need to reload some things */
ixgbe_configure(adapter);
- ixgbe_napi_add_all(adapter);
-
return ixgbe_up_complete(adapter);
}
@@ -2445,8 +2632,13 @@ static void ixgbe_clean_rx_ring(struct ixgbe_adapter *adapter,
rx_buffer_info->dma = 0;
}
if (rx_buffer_info->skb) {
- dev_kfree_skb(rx_buffer_info->skb);
+ struct sk_buff *skb = rx_buffer_info->skb;
rx_buffer_info->skb = NULL;
+ do {
+ struct sk_buff *this = skb;
+ skb = skb->prev;
+ dev_kfree_skb(this);
+ } while (skb);
}
if (!rx_buffer_info->page)
continue;
@@ -2575,13 +2767,6 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
netif_carrier_off(netdev);
-#ifdef CONFIG_IXGBE_DCA
- if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) {
- adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED;
- dca_remove_requester(&adapter->pdev->dev);
- }
-
-#endif
if (!pci_channel_offline(adapter->pdev))
ixgbe_reset(adapter);
ixgbe_clean_all_tx_rings(adapter);
@@ -2589,13 +2774,7 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
#ifdef CONFIG_IXGBE_DCA
/* since we reset the hardware DCA settings were cleared */
- if (dca_add_requester(&adapter->pdev->dev) == 0) {
- adapter->flags |= IXGBE_FLAG_DCA_ENABLED;
- /* always use CB2 mode, difference is masked
- * in the CB driver */
- IXGBE_WRITE_REG(hw, IXGBE_DCA_CTRL, 2);
- ixgbe_setup_dca(adapter);
- }
+ ixgbe_setup_dca(adapter);
#endif
}
@@ -2632,7 +2811,7 @@ static int ixgbe_poll(struct napi_struct *napi, int budget)
if (adapter->itr_setting & 1)
ixgbe_set_itr(adapter);
if (!test_bit(__IXGBE_DOWN, &adapter->state))
- ixgbe_irq_enable_queues(adapter);
+ ixgbe_irq_enable_queues(adapter, IXGBE_EIMS_RTX_QUEUE);
}
return work_done;
}
@@ -2668,17 +2847,15 @@ static void ixgbe_reset_task(struct work_struct *work)
static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter)
{
bool ret = false;
+ struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_DCB];
- if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
- adapter->ring_feature[RING_F_DCB].mask = 0x7 << 3;
- adapter->num_rx_queues =
- adapter->ring_feature[RING_F_DCB].indices;
- adapter->num_tx_queues =
- adapter->ring_feature[RING_F_DCB].indices;
- ret = true;
- } else {
- ret = false;
- }
+ if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
+ return ret;
+
+ f->mask = 0x7 << 3;
+ adapter->num_rx_queues = f->indices;
+ adapter->num_tx_queues = f->indices;
+ ret = true;
return ret;
}
@@ -2695,13 +2872,12 @@ static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter)
static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
{
bool ret = false;
+ struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_RSS];
if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
- adapter->ring_feature[RING_F_RSS].mask = 0xF;
- adapter->num_rx_queues =
- adapter->ring_feature[RING_F_RSS].indices;
- adapter->num_tx_queues =
- adapter->ring_feature[RING_F_RSS].indices;
+ f->mask = 0xF;
+ adapter->num_rx_queues = f->indices;
+ adapter->num_tx_queues = f->indices;
ret = true;
} else {
ret = false;
@@ -2710,6 +2886,47 @@ static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
return ret;
}
+#ifdef IXGBE_FCOE
+/**
+ * ixgbe_set_fcoe_queues: Allocate queues for Fiber Channel over Ethernet (FCoE)
+ * @adapter: board private structure to initialize
+ *
+ * FCoE RX FCRETA can use up to 8 rx queues for up to 8 different exchanges.
+ * The ring feature mask is not used as a mask for FCoE, as it can take any 8
+ * rx queues out of the max number of rx queues, instead, it is used as the
+ * index of the first rx queue used by FCoE.
+ *
+ **/
+static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter)
+{
+ bool ret = false;
+ struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE];
+
+ f->indices = min((int)num_online_cpus(), f->indices);
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
+#ifdef CONFIG_IXGBE_DCB
+ if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+ DPRINTK(PROBE, INFO, "FCOE enabled with DCB \n");
+ ixgbe_set_dcb_queues(adapter);
+ }
+#endif
+ if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
+ DPRINTK(PROBE, INFO, "FCOE enabled with RSS \n");
+ ixgbe_set_rss_queues(adapter);
+ }
+ /* adding FCoE rx rings to the end */
+ f->mask = adapter->num_rx_queues;
+ adapter->num_rx_queues += f->indices;
+ if (adapter->num_tx_queues == 0)
+ adapter->num_tx_queues = f->indices;
+
+ ret = true;
+ }
+
+ return ret;
+}
+
+#endif /* IXGBE_FCOE */
/*
* ixgbe_set_num_queues: Allocate queues for device, feature dependant
* @adapter: board private structure to initialize
@@ -2723,6 +2940,11 @@ static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
**/
static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
{
+#ifdef IXGBE_FCOE
+ if (ixgbe_set_fcoe_queues(adapter))
+ goto done;
+
+#endif /* IXGBE_FCOE */
#ifdef CONFIG_IXGBE_DCB
if (ixgbe_set_dcb_queues(adapter))
goto done;
@@ -2778,9 +3000,6 @@ static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
kfree(adapter->msix_entries);
adapter->msix_entries = NULL;
- adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
- adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
- ixgbe_set_num_queues(adapter);
} else {
adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */
/*
@@ -2901,6 +3120,39 @@ static inline bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter)
}
#endif
+#ifdef IXGBE_FCOE
+/**
+ * ixgbe_cache_ring_fcoe - Descriptor ring to register mapping for the FCoE
+ * @adapter: board private structure to initialize
+ *
+ * Cache the descriptor ring offsets for FCoE mode to the assigned rings.
+ *
+ */
+static inline bool ixgbe_cache_ring_fcoe(struct ixgbe_adapter *adapter)
+{
+ int i, fcoe_i = 0;
+ bool ret = false;
+ struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE];
+
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
+#ifdef CONFIG_IXGBE_DCB
+ if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+ ixgbe_cache_ring_dcb(adapter);
+ fcoe_i = adapter->rx_ring[0].reg_idx + 1;
+ }
+#endif /* CONFIG_IXGBE_DCB */
+ if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
+ ixgbe_cache_ring_rss(adapter);
+ fcoe_i = f->mask;
+ }
+ for (i = 0; i < f->indices; i++, fcoe_i++)
+ adapter->rx_ring[f->mask + i].reg_idx = fcoe_i;
+ ret = true;
+ }
+ return ret;
+}
+
+#endif /* IXGBE_FCOE */
/**
* ixgbe_cache_ring_register - Descriptor ring to register mapping
* @adapter: board private structure to initialize
@@ -2918,6 +3170,11 @@ static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter)
adapter->rx_ring[0].reg_idx = 0;
adapter->tx_ring[0].reg_idx = 0;
+#ifdef IXGBE_FCOE
+ if (ixgbe_cache_ring_fcoe(adapter))
+ return;
+
+#endif /* IXGBE_FCOE */
#ifdef CONFIG_IXGBE_DCB
if (ixgbe_cache_ring_dcb(adapter))
return;
@@ -3004,31 +3261,20 @@ static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)
* mean we disable MSI-X capabilities of the adapter. */
adapter->msix_entries = kcalloc(v_budget,
sizeof(struct msix_entry), GFP_KERNEL);
- if (!adapter->msix_entries) {
- adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
- adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
- ixgbe_set_num_queues(adapter);
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
- err = ixgbe_alloc_queues(adapter);
- if (err) {
- DPRINTK(PROBE, ERR, "Unable to allocate memory "
- "for queues\n");
- goto out;
- }
-
- goto try_msi;
- }
+ if (adapter->msix_entries) {
+ for (vector = 0; vector < v_budget; vector++)
+ adapter->msix_entries[vector].entry = vector;
- for (vector = 0; vector < v_budget; vector++)
- adapter->msix_entries[vector].entry = vector;
+ ixgbe_acquire_msix_vectors(adapter, v_budget);
- ixgbe_acquire_msix_vectors(adapter, v_budget);
+ if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED)
+ goto out;
+ }
- if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED)
- goto out;
+ adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
+ adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
+ ixgbe_set_num_queues(adapter);
-try_msi:
err = pci_enable_msi(adapter->pdev);
if (!err) {
adapter->flags |= IXGBE_FLAG_MSI_ENABLED;
@@ -3043,6 +3289,87 @@ out:
return err;
}
+/**
+ * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors
+ * @adapter: board private structure to initialize
+ *
+ * We allocate one q_vector per queue interrupt. If allocation fails we
+ * return -ENOMEM.
+ **/
+static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter)
+{
+ int q_idx, num_q_vectors;
+ struct ixgbe_q_vector *q_vector;
+ int napi_vectors;
+ int (*poll)(struct napi_struct *, int);
+
+ if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
+ num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
+ napi_vectors = adapter->num_rx_queues;
+ poll = &ixgbe_clean_rxonly;
+ } else {
+ num_q_vectors = 1;
+ napi_vectors = 1;
+ poll = &ixgbe_poll;
+ }
+
+ for (q_idx = 0; q_idx < num_q_vectors; q_idx++) {
+ q_vector = kzalloc(sizeof(struct ixgbe_q_vector), GFP_KERNEL);
+ if (!q_vector)
+ goto err_out;
+ q_vector->adapter = adapter;
+ q_vector->v_idx = q_idx;
+ q_vector->eitr = adapter->eitr_param;
+ if (q_idx < napi_vectors)
+ netif_napi_add(adapter->netdev, &q_vector->napi,
+ (*poll), 64);
+ adapter->q_vector[q_idx] = q_vector;
+ }
+
+ return 0;
+
+err_out:
+ while (q_idx) {
+ q_idx--;
+ q_vector = adapter->q_vector[q_idx];
+ netif_napi_del(&q_vector->napi);
+ kfree(q_vector);
+ adapter->q_vector[q_idx] = NULL;
+ }
+ return -ENOMEM;
+}
+
+/**
+ * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors
+ * @adapter: board private structure to initialize
+ *
+ * This function frees the memory allocated to the q_vectors. In addition if
+ * NAPI is enabled it will delete any references to the NAPI struct prior
+ * to freeing the q_vector.
+ **/
+static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter)
+{
+ int q_idx, num_q_vectors;
+ int napi_vectors;
+
+ if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
+ num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
+ napi_vectors = adapter->num_rx_queues;
+ } else {
+ num_q_vectors = 1;
+ napi_vectors = 1;
+ }
+
+ for (q_idx = 0; q_idx < num_q_vectors; q_idx++) {
+ struct ixgbe_q_vector *q_vector = adapter->q_vector[q_idx];
+
+ adapter->q_vector[q_idx] = NULL;
+ if (q_idx < napi_vectors)
+ netif_napi_del(&q_vector->napi);
+ kfree(q_vector);
+ }
+}
+
void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter)
{
if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
@@ -3074,18 +3401,25 @@ int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
/* Number of supported queues */
ixgbe_set_num_queues(adapter);
- err = ixgbe_alloc_queues(adapter);
- if (err) {
- DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
- goto err_alloc_queues;
- }
-
err = ixgbe_set_interrupt_capability(adapter);
if (err) {
DPRINTK(PROBE, ERR, "Unable to setup interrupt capabilities\n");
goto err_set_interrupt;
}
+ err = ixgbe_alloc_q_vectors(adapter);
+ if (err) {
+ DPRINTK(PROBE, ERR, "Unable to allocate memory for queue "
+ "vectors\n");
+ goto err_alloc_q_vectors;
+ }
+
+ err = ixgbe_alloc_queues(adapter);
+ if (err) {
+ DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
+ goto err_alloc_queues;
+ }
+
DPRINTK(DRV, INFO, "Multiqueue %s: Rx Queue count = %u, "
"Tx Queue count = %u\n",
(adapter->num_rx_queues > 1) ? "Enabled" :
@@ -3095,11 +3429,30 @@ int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
return 0;
+err_alloc_queues:
+ ixgbe_free_q_vectors(adapter);
+err_alloc_q_vectors:
+ ixgbe_reset_interrupt_capability(adapter);
err_set_interrupt:
+ return err;
+}
+
+/**
+ * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings
+ * @adapter: board private structure to clear interrupt scheme on
+ *
+ * We go through and clear interrupt specific resources and reset the structure
+ * to pre-load conditions
+ **/
+void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
+{
kfree(adapter->tx_ring);
kfree(adapter->rx_ring);
-err_alloc_queues:
- return err;
+ adapter->tx_ring = NULL;
+ adapter->rx_ring = NULL;
+
+ ixgbe_free_q_vectors(adapter);
+ ixgbe_reset_interrupt_capability(adapter);
}
/**
@@ -3185,10 +3538,19 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
adapter->ring_feature[RING_F_RSS].indices = rss;
adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
adapter->ring_feature[RING_F_DCB].indices = IXGBE_MAX_DCB_INDICES;
- if (hw->mac.type == ixgbe_mac_82598EB)
+ if (hw->mac.type == ixgbe_mac_82598EB) {
+ if (hw->device_id == IXGBE_DEV_ID_82598AT)
+ adapter->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE;
adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82598;
- else if (hw->mac.type == ixgbe_mac_82599EB)
+ } else if (hw->mac.type == ixgbe_mac_82599EB) {
adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82599;
+ adapter->flags |= IXGBE_FLAG_RSC_CAPABLE;
+ adapter->flags |= IXGBE_FLAG_RSC_ENABLED;
+#ifdef IXGBE_FCOE
+ adapter->flags |= IXGBE_FLAG_FCOE_ENABLED;
+ adapter->ring_feature[RING_F_FCOE].indices = IXGBE_FCRETA_SIZE;
+#endif /* IXGBE_FCOE */
+ }
#ifdef CONFIG_IXGBE_DCB
/* Configure DCB traffic classes */
@@ -3203,6 +3565,7 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
adapter->dcb_cfg.bw_percentage[DCB_TX_CONFIG][0] = 100;
adapter->dcb_cfg.bw_percentage[DCB_RX_CONFIG][0] = 100;
adapter->dcb_cfg.rx_pba_cfg = pba_equal;
+ adapter->dcb_cfg.pfc_mode_enable = false;
adapter->dcb_cfg.round_robin_enable = false;
adapter->dcb_set_bitmap = 0x00;
ixgbe_copy_dcb_cfg(&adapter->dcb_cfg, &adapter->temp_dcb_cfg,
@@ -3213,6 +3576,9 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
/* default flow control settings */
hw->fc.requested_mode = ixgbe_fc_full;
hw->fc.current_mode = ixgbe_fc_full; /* init for ethtool output */
+#ifdef CONFIG_DCB
+ adapter->last_lfc_mode = hw->fc.current_mode;
+#endif
hw->fc.high_water = IXGBE_DEFAULT_FCRTH;
hw->fc.low_water = IXGBE_DEFAULT_FCRTL;
hw->fc.pause_time = IXGBE_DEFAULT_FCPAUSE;
@@ -3503,6 +3869,8 @@ static int ixgbe_open(struct net_device *netdev)
if (test_bit(__IXGBE_TESTING, &adapter->state))
return -EBUSY;
+ netif_carrier_off(netdev);
+
/* allocate transmit descriptors */
err = ixgbe_setup_all_tx_resources(adapter);
if (err)
@@ -3515,8 +3883,6 @@ static int ixgbe_open(struct net_device *netdev)
ixgbe_configure(adapter);
- ixgbe_napi_add_all(adapter);
-
err = ixgbe_request_irq(adapter);
if (err)
goto err_req_irq;
@@ -3568,55 +3934,6 @@ static int ixgbe_close(struct net_device *netdev)
return 0;
}
-/**
- * ixgbe_napi_add_all - prep napi structs for use
- * @adapter: private struct
- *
- * helper function to napi_add each possible q_vector->napi
- */
-void ixgbe_napi_add_all(struct ixgbe_adapter *adapter)
-{
- int q_idx, q_vectors;
- struct net_device *netdev = adapter->netdev;
- int (*poll)(struct napi_struct *, int);
-
- /* check if we already have our netdev->napi_list populated */
- if (&netdev->napi_list != netdev->napi_list.next)
- return;
-
- if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
- poll = &ixgbe_clean_rxonly;
- /* Only enable as many vectors as we have rx queues. */
- q_vectors = adapter->num_rx_queues;
- } else {
- poll = &ixgbe_poll;
- /* only one q_vector for legacy modes */
- q_vectors = 1;
- }
-
- for (q_idx = 0; q_idx < q_vectors; q_idx++) {
- struct ixgbe_q_vector *q_vector = &adapter->q_vector[q_idx];
- netif_napi_add(adapter->netdev, &q_vector->napi, (*poll), 64);
- }
-}
-
-void ixgbe_napi_del_all(struct ixgbe_adapter *adapter)
-{
- int q_idx;
- int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
-
- /* legacy and MSI only use one vector */
- if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
- q_vectors = 1;
-
- for (q_idx = 0; q_idx < q_vectors; q_idx++) {
- struct ixgbe_q_vector *q_vector = &adapter->q_vector[q_idx];
- if (!q_vector->rxr_count)
- continue;
- netif_napi_del(&q_vector->napi);
- }
-}
-
#ifdef CONFIG_PM
static int ixgbe_resume(struct pci_dev *pdev)
{
@@ -3626,7 +3943,8 @@ static int ixgbe_resume(struct pci_dev *pdev)
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
- err = pci_enable_device(pdev);
+
+ err = pci_enable_device_mem(pdev);
if (err) {
printk(KERN_ERR "ixgbe: Cannot enable PCI device from "
"suspend\n");
@@ -3634,8 +3952,7 @@ static int ixgbe_resume(struct pci_dev *pdev)
}
pci_set_master(pdev);
- pci_enable_wake(pdev, PCI_D3hot, 0);
- pci_enable_wake(pdev, PCI_D3cold, 0);
+ pci_wake_from_d3(pdev, false);
err = ixgbe_init_interrupt_scheme(adapter);
if (err) {
@@ -3679,11 +3996,7 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
ixgbe_free_all_tx_resources(adapter);
ixgbe_free_all_rx_resources(adapter);
}
- ixgbe_reset_interrupt_capability(adapter);
- ixgbe_napi_del_all(adapter);
- INIT_LIST_HEAD(&netdev->napi_list);
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
+ ixgbe_clear_interrupt_scheme(adapter);
#ifdef CONFIG_PM
retval = pci_save_state(pdev);
@@ -3711,13 +4024,10 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
IXGBE_WRITE_REG(hw, IXGBE_WUFC, 0);
}
- if (wufc && hw->mac.type == ixgbe_mac_82599EB) {
- pci_enable_wake(pdev, PCI_D3hot, 1);
- pci_enable_wake(pdev, PCI_D3cold, 1);
- } else {
- pci_enable_wake(pdev, PCI_D3hot, 0);
- pci_enable_wake(pdev, PCI_D3cold, 0);
- }
+ if (wufc && hw->mac.type == ixgbe_mac_82599EB)
+ pci_wake_from_d3(pdev, true);
+ else
+ pci_wake_from_d3(pdev, false);
*enable_wake = !!wufc;
@@ -3772,9 +4082,13 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
if (hw->mac.type == ixgbe_mac_82599EB) {
+ u64 rsc_count = 0;
for (i = 0; i < 16; i++)
adapter->hw_rx_no_dma_resources +=
IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
+ for (i = 0; i < adapter->num_rx_queues; i++)
+ rsc_count += adapter->rx_ring[i].rsc_count;
+ adapter->rsc_count = rsc_count;
}
adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
@@ -3821,6 +4135,14 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
IXGBE_READ_REG(hw, IXGBE_TORH); /* to clear */
adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
+#ifdef IXGBE_FCOE
+ adapter->stats.fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
+ adapter->stats.fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
+ adapter->stats.fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
+ adapter->stats.fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
+ adapter->stats.fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
+ adapter->stats.fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
+#endif /* IXGBE_FCOE */
} else {
adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
@@ -3896,7 +4218,7 @@ static void ixgbe_watchdog(unsigned long data)
int i;
for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++)
- eics |= (1 << i);
+ eics |= ((u64)1 << i);
/* Cause software interrupt to ensure rx rings are cleaned */
switch (hw->mac.type) {
@@ -3916,16 +4238,9 @@ static void ixgbe_watchdog(unsigned long data)
break;
case ixgbe_mac_82599EB:
if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
- /*
- * EICS(0..15) first 0-15 q vectors
- * EICS[1] (16..31) q vectors 16-31
- * EICS[2] (0..31) q vectors 32-63
- */
- IXGBE_WRITE_REG(hw, IXGBE_EICS,
- (u32)(eics & 0xFFFF));
+ IXGBE_WRITE_REG(hw, IXGBE_EICS_EX(0),
+ (u32)(eics & 0xFFFFFFFF));
IXGBE_WRITE_REG(hw, IXGBE_EICS_EX(1),
- (u32)(eics & 0xFFFF0000));
- IXGBE_WRITE_REG(hw, IXGBE_EICS_EX(2),
(u32)(eics >> 32));
} else {
/*
@@ -4011,16 +4326,32 @@ static void ixgbe_watchdog_task(struct work_struct *work)
struct ixgbe_hw *hw = &adapter->hw;
u32 link_speed = adapter->link_speed;
bool link_up = adapter->link_up;
+ int i;
+ struct ixgbe_ring *tx_ring;
+ int some_tx_pending = 0;
adapter->flags |= IXGBE_FLAG_IN_WATCHDOG_TASK;
if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
+ if (link_up) {
+#ifdef CONFIG_DCB
+ if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+ for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
+ hw->mac.ops.setup_fc(hw, i);
+ } else {
+ hw->mac.ops.setup_fc(hw, 0);
+ }
+#else
+ hw->mac.ops.setup_fc(hw, 0);
+#endif
+ }
+
if (link_up ||
time_after(jiffies, (adapter->link_check_timeout +
IXGBE_TRY_LINK_TIMEOUT))) {
- IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMC_LSC);
adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
+ IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMC_LSC);
}
adapter->link_up = link_up;
adapter->link_speed = link_speed;
@@ -4068,6 +4399,25 @@ static void ixgbe_watchdog_task(struct work_struct *work)
}
}
+ if (!netif_carrier_ok(netdev)) {
+ for (i = 0; i < adapter->num_tx_queues; i++) {
+ tx_ring = &adapter->tx_ring[i];
+ if (tx_ring->next_to_use != tx_ring->next_to_clean) {
+ some_tx_pending = 1;
+ break;
+ }
+ }
+
+ if (some_tx_pending) {
+ /* We've lost link, so the controller stops DMA,
+ * but we've got queued Tx work that's never going
+ * to get done, so reset controller to flush Tx.
+ * (Do the reset outside of interrupt context).
+ */
+ schedule_work(&adapter->reset_task);
+ }
+ }
+
ixgbe_update_stats(adapter);
adapter->flags &= ~IXGBE_FLAG_IN_WATCHDOG_TASK;
}
@@ -4196,12 +4546,18 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
if (ip_hdr(skb)->protocol == IPPROTO_TCP)
type_tucmd_mlhl |=
IXGBE_ADVTXD_TUCMD_L4T_TCP;
+ else if (ip_hdr(skb)->protocol == IPPROTO_SCTP)
+ type_tucmd_mlhl |=
+ IXGBE_ADVTXD_TUCMD_L4T_SCTP;
break;
case cpu_to_be16(ETH_P_IPV6):
/* XXX what about other V6 headers?? */
if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
type_tucmd_mlhl |=
IXGBE_ADVTXD_TUCMD_L4T_TCP;
+ else if (ipv6_hdr(skb)->nexthdr == IPPROTO_SCTP)
+ type_tucmd_mlhl |=
+ IXGBE_ADVTXD_TUCMD_L4T_SCTP;
break;
default:
if (unlikely(net_ratelimit())) {
@@ -4234,10 +4590,12 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
struct ixgbe_ring *tx_ring,
- struct sk_buff *skb, unsigned int first)
+ struct sk_buff *skb, u32 tx_flags,
+ unsigned int first)
{
struct ixgbe_tx_buffer *tx_buffer_info;
- unsigned int len = skb_headlen(skb);
+ unsigned int len;
+ unsigned int total = skb->len;
unsigned int offset = 0, size, count = 0, i;
unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
unsigned int f;
@@ -4252,6 +4610,11 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
map = skb_shinfo(skb)->dma_maps;
+ if (tx_flags & IXGBE_TX_FLAGS_FCOE)
+ /* excluding fcoe_crc_eof for FCoE */
+ total -= sizeof(struct fcoe_crc_eof);
+
+ len = min(skb_headlen(skb), total);
while (len) {
tx_buffer_info = &tx_ring->tx_buffer_info[i];
size = min(len, (uint)IXGBE_MAX_DATA_PER_TXD);
@@ -4262,6 +4625,7 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
tx_buffer_info->next_to_watch = i;
len -= size;
+ total -= size;
offset += size;
count++;
@@ -4276,7 +4640,7 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
struct skb_frag_struct *frag;
frag = &skb_shinfo(skb)->frags[f];
- len = frag->size;
+ len = min((unsigned int)frag->size, total);
offset = 0;
while (len) {
@@ -4293,9 +4657,12 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
tx_buffer_info->next_to_watch = i;
len -= size;
+ total -= size;
offset += size;
count++;
}
+ if (total == 0)
+ break;
}
tx_ring->tx_buffer_info[i].skb = skb;
@@ -4337,6 +4704,13 @@ static void ixgbe_tx_queue(struct ixgbe_adapter *adapter,
olinfo_status |= IXGBE_TXD_POPTS_TXSM <<
IXGBE_ADVTXD_POPTS_SHIFT;
+ if (tx_flags & IXGBE_TX_FLAGS_FCOE) {
+ olinfo_status |= IXGBE_ADVTXD_CC;
+ olinfo_status |= (1 << IXGBE_ADVTXD_IDX_SHIFT);
+ if (tx_flags & IXGBE_TX_FLAGS_FSO)
+ cmd_type_len |= IXGBE_ADVTXD_DCMD_TSE;
+ }
+
olinfo_status |= ((paylen - hdr_len) << IXGBE_ADVTXD_PAYLEN_SHIFT);
i = tx_ring->next_to_use;
@@ -4433,10 +4807,16 @@ static int ixgbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT;
tx_flags |= IXGBE_TX_FLAGS_VLAN;
}
- /* three things can cause us to need a context descriptor */
+
+ if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
+ (skb->protocol == htons(ETH_P_FCOE)))
+ tx_flags |= IXGBE_TX_FLAGS_FCOE;
+
+ /* four things can cause us to need a context descriptor */
if (skb_is_gso(skb) ||
(skb->ip_summed == CHECKSUM_PARTIAL) ||
- (tx_flags & IXGBE_TX_FLAGS_VLAN))
+ (tx_flags & IXGBE_TX_FLAGS_VLAN) ||
+ (tx_flags & IXGBE_TX_FLAGS_FCOE))
count++;
count += TXD_USE_COUNT(skb_headlen(skb));
@@ -4448,23 +4828,35 @@ static int ixgbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
return NETDEV_TX_BUSY;
}
- if (skb->protocol == htons(ETH_P_IP))
- tx_flags |= IXGBE_TX_FLAGS_IPV4;
first = tx_ring->next_to_use;
- tso = ixgbe_tso(adapter, tx_ring, skb, tx_flags, &hdr_len);
- if (tso < 0) {
- dev_kfree_skb_any(skb);
- return NETDEV_TX_OK;
- }
-
- if (tso)
- tx_flags |= IXGBE_TX_FLAGS_TSO;
- else if (ixgbe_tx_csum(adapter, tx_ring, skb, tx_flags) &&
- (skb->ip_summed == CHECKSUM_PARTIAL))
- tx_flags |= IXGBE_TX_FLAGS_CSUM;
+ if (tx_flags & IXGBE_TX_FLAGS_FCOE) {
+#ifdef IXGBE_FCOE
+ /* setup tx offload for FCoE */
+ tso = ixgbe_fso(adapter, tx_ring, skb, tx_flags, &hdr_len);
+ if (tso < 0) {
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+ if (tso)
+ tx_flags |= IXGBE_TX_FLAGS_FSO;
+#endif /* IXGBE_FCOE */
+ } else {
+ if (skb->protocol == htons(ETH_P_IP))
+ tx_flags |= IXGBE_TX_FLAGS_IPV4;
+ tso = ixgbe_tso(adapter, tx_ring, skb, tx_flags, &hdr_len);
+ if (tso < 0) {
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
- count = ixgbe_tx_map(adapter, tx_ring, skb, first);
+ if (tso)
+ tx_flags |= IXGBE_TX_FLAGS_TSO;
+ else if (ixgbe_tx_csum(adapter, tx_ring, skb, tx_flags) &&
+ (skb->ip_summed == CHECKSUM_PARTIAL))
+ tx_flags |= IXGBE_TX_FLAGS_CSUM;
+ }
+ count = ixgbe_tx_map(adapter, tx_ring, skb, tx_flags, first);
if (count) {
ixgbe_tx_queue(adapter, tx_ring, tx_flags, count, skb->len,
hdr_len);
@@ -4519,6 +4911,82 @@ static int ixgbe_set_mac(struct net_device *netdev, void *p)
return 0;
}
+static int
+ixgbe_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+ struct ixgbe_hw *hw = &adapter->hw;
+ u16 value;
+ int rc;
+
+ if (prtad != hw->phy.mdio.prtad)
+ return -EINVAL;
+ rc = hw->phy.ops.read_reg(hw, addr, devad, &value);
+ if (!rc)
+ rc = value;
+ return rc;
+}
+
+static int ixgbe_mdio_write(struct net_device *netdev, int prtad, int devad,
+ u16 addr, u16 value)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+ struct ixgbe_hw *hw = &adapter->hw;
+
+ if (prtad != hw->phy.mdio.prtad)
+ return -EINVAL;
+ return hw->phy.ops.write_reg(hw, addr, devad, value);
+}
+
+static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+
+ return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd);
+}
+
+/**
+ * ixgbe_add_sanmac_netdev - Add the SAN MAC address to the corresponding
+ * netdev->dev_addr_list
+ * @netdev: network interface device structure
+ *
+ * Returns non-zero on failure
+ **/
+static int ixgbe_add_sanmac_netdev(struct net_device *dev)
+{
+ int err = 0;
+ struct ixgbe_adapter *adapter = netdev_priv(dev);
+ struct ixgbe_mac_info *mac = &adapter->hw.mac;
+
+ if (is_valid_ether_addr(mac->san_addr)) {
+ rtnl_lock();
+ err = dev_addr_add(dev, mac->san_addr, NETDEV_HW_ADDR_T_SAN);
+ rtnl_unlock();
+ }
+ return err;
+}
+
+/**
+ * ixgbe_del_sanmac_netdev - Removes the SAN MAC address to the corresponding
+ * netdev->dev_addr_list
+ * @netdev: network interface device structure
+ *
+ * Returns non-zero on failure
+ **/
+static int ixgbe_del_sanmac_netdev(struct net_device *dev)
+{
+ int err = 0;
+ struct ixgbe_adapter *adapter = netdev_priv(dev);
+ struct ixgbe_mac_info *mac = &adapter->hw.mac;
+
+ if (is_valid_ether_addr(mac->san_addr)) {
+ rtnl_lock();
+ err = dev_addr_del(dev, mac->san_addr, NETDEV_HW_ADDR_T_SAN);
+ rtnl_unlock();
+ }
+ return err;
+}
+
#ifdef CONFIG_NET_POLL_CONTROLLER
/*
* Polling 'interrupt' - used by things like netconsole to send skbs
@@ -4552,9 +5020,14 @@ static const struct net_device_ops ixgbe_netdev_ops = {
.ndo_vlan_rx_register = ixgbe_vlan_rx_register,
.ndo_vlan_rx_add_vid = ixgbe_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid,
+ .ndo_do_ioctl = ixgbe_ioctl,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = ixgbe_netpoll,
#endif
+#ifdef IXGBE_FCOE
+ .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get,
+ .ndo_fcoe_ddp_done = ixgbe_fcoe_ddp_put,
+#endif /* IXGBE_FCOE */
};
/**
@@ -4577,9 +5050,12 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data];
static int cards_found;
int i, err, pci_using_dac;
+#ifdef IXGBE_FCOE
+ u16 device_caps;
+#endif
u32 part_num, eec;
- err = pci_enable_device(pdev);
+ err = pci_enable_device_mem(pdev);
if (err)
return err;
@@ -4599,9 +5075,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
pci_using_dac = 0;
}
- err = pci_request_regions(pdev, ixgbe_driver_name);
+ err = pci_request_selected_regions(pdev, pci_select_bars(pdev,
+ IORESOURCE_MEM), ixgbe_driver_name);
if (err) {
- dev_err(&pdev->dev, "pci_request_regions failed 0x%x\n", err);
+ dev_err(&pdev->dev,
+ "pci_request_selected_regions failed 0x%x\n", err);
goto err_pci_reg;
}
@@ -4665,6 +5143,13 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
/* PHY */
memcpy(&hw->phy.ops, ii->phy_ops, sizeof(hw->phy.ops));
hw->phy.sfp_type = ixgbe_sfp_type_unknown;
+ /* ixgbe_identify_phy_generic will set prtad and mmds properly */
+ hw->phy.mdio.prtad = MDIO_PRTAD_NONE;
+ hw->phy.mdio.mmds = 0;
+ hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
+ hw->phy.mdio.dev = netdev;
+ hw->phy.mdio.mdio_read = ixgbe_mdio_read;
+ hw->phy.mdio.mdio_write = ixgbe_mdio_write;
/* set up this timer and work struct before calling get_invariants
* which might start the timer
@@ -4702,9 +5187,24 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
if (err)
goto err_sw_init;
+ /*
+ * If there is a fan on this device and it has failed log the
+ * failure.
+ */
+ if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) {
+ u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+ if (esdp & IXGBE_ESDP_SDP1)
+ DPRINTK(PROBE, CRIT,
+ "Fan has stopped, replace the adapter\n");
+ }
+
/* reset_hw fills in the perm_addr as well */
err = hw->mac.ops.reset_hw(hw);
- if (err) {
+ if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
+ dev_err(&adapter->pdev->dev, "failed to load because an "
+ "unsupported SFP+ module type was detected.\n");
+ goto err_sw_init;
+ } else if (err) {
dev_err(&adapter->pdev->dev, "HW Init failed: %d\n", err);
goto err_sw_init;
}
@@ -4720,6 +5220,9 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
netdev->features |= NETIF_F_TSO6;
netdev->features |= NETIF_F_GRO;
+ if (adapter->hw.mac.type == ixgbe_mac_82599EB)
+ netdev->features |= NETIF_F_SCTP_CSUM;
+
netdev->vlan_features |= NETIF_F_TSO;
netdev->vlan_features |= NETIF_F_TSO6;
netdev->vlan_features |= NETIF_F_IP_CSUM;
@@ -4732,9 +5235,26 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
netdev->dcbnl_ops = &dcbnl_ops;
#endif
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
+ if (hw->mac.ops.get_device_caps) {
+ hw->mac.ops.get_device_caps(hw, &device_caps);
+ if (!(device_caps & IXGBE_DEVICE_CAPS_FCOE_OFFLOADS)) {
+ netdev->features |= NETIF_F_FCOE_CRC;
+ netdev->features |= NETIF_F_FSO;
+ netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1;
+ } else {
+ adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED;
+ }
+ }
+ }
+#endif /* IXGBE_FCOE */
if (pci_using_dac)
netdev->features |= NETIF_F_HIGHDMA;
+ if (adapter->flags & IXGBE_FLAG_RSC_ENABLED)
+ netdev->features |= NETIF_F_LRO;
+
/* make sure the EEPROM is good */
if (hw->eeprom.ops.validate_checksum(hw, NULL) < 0) {
dev_err(&pdev->dev, "The EEPROM Checksum Is Not Valid\n");
@@ -4774,6 +5294,9 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
device_init_wakeup(&adapter->pdev->dev, true);
device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
+ /* pick up the PCI bus settings for reporting later */
+ hw->mac.ops.get_bus_info(hw);
+
/* print bus type/speed/width info */
dev_info(&pdev->dev, "(PCI Express:%s:%s) %pM\n",
((hw->bus.speed == ixgbe_bus_speed_5000) ? "5.0Gb/s":
@@ -4807,22 +5330,22 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
/* reset the hardware with the new settings */
hw->mac.ops.start_hw(hw);
- netif_carrier_off(netdev);
-
strcpy(netdev->name, "eth%d");
err = register_netdev(netdev);
if (err)
goto err_register;
+ /* carrier off reporting is important to ethtool even BEFORE open */
+ netif_carrier_off(netdev);
+
#ifdef CONFIG_IXGBE_DCA
if (dca_add_requester(&pdev->dev) == 0) {
adapter->flags |= IXGBE_FLAG_DCA_ENABLED;
- /* always use CB2 mode, difference is masked
- * in the CB driver */
- IXGBE_WRITE_REG(hw, IXGBE_DCA_CTRL, 2);
ixgbe_setup_dca(adapter);
}
#endif
+ /* add san mac addr to netdev */
+ ixgbe_add_sanmac_netdev(netdev);
dev_info(&pdev->dev, "Intel(R) 10 Gigabit Network Connection\n");
cards_found++;
@@ -4831,8 +5354,8 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
err_register:
ixgbe_release_hw_control(adapter);
err_hw_init:
+ ixgbe_clear_interrupt_scheme(adapter);
err_sw_init:
- ixgbe_reset_interrupt_capability(adapter);
err_eeprom:
clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
del_timer_sync(&adapter->sfp_timer);
@@ -4843,7 +5366,8 @@ err_eeprom:
err_ioremap:
free_netdev(netdev);
err_alloc_etherdev:
- pci_release_regions(pdev);
+ pci_release_selected_regions(pdev, pci_select_bars(pdev,
+ IORESOURCE_MEM));
err_pci_reg:
err_dma:
pci_disable_device(pdev);
@@ -4887,19 +5411,27 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
}
#endif
+#ifdef IXGBE_FCOE
+ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
+ ixgbe_cleanup_fcoe(adapter);
+
+#endif /* IXGBE_FCOE */
+
+ /* remove the added san mac */
+ ixgbe_del_sanmac_netdev(netdev);
+
if (netdev->reg_state == NETREG_REGISTERED)
unregister_netdev(netdev);
- ixgbe_reset_interrupt_capability(adapter);
+ ixgbe_clear_interrupt_scheme(adapter);
ixgbe_release_hw_control(adapter);
iounmap(adapter->hw.hw_addr);
- pci_release_regions(pdev);
+ pci_release_selected_regions(pdev, pci_select_bars(pdev,
+ IORESOURCE_MEM));
DPRINTK(PROBE, INFO, "complete\n");
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
free_netdev(netdev);
@@ -4927,6 +5459,9 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
netif_device_detach(netdev);
+ if (state == pci_channel_io_perm_failure)
+ return PCI_ERS_RESULT_DISCONNECT;
+
if (netif_running(netdev))
ixgbe_down(adapter);
pci_disable_device(pdev);
@@ -4948,7 +5483,7 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)
pci_ers_result_t result;
int err;
- if (pci_enable_device(pdev)) {
+ if (pci_enable_device_mem(pdev)) {
DPRINTK(PROBE, ERR,
"Cannot re-enable PCI device after reset.\n");
result = PCI_ERS_RESULT_DISCONNECT;
@@ -4956,8 +5491,7 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)
pci_set_master(pdev);
pci_restore_state(pdev);
- pci_enable_wake(pdev, PCI_D3hot, 0);
- pci_enable_wake(pdev, PCI_D3cold, 0);
+ pci_wake_from_d3(pdev, false);
ixgbe_reset(adapter);
IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0);
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 14e9606aa3b3..8210b49aeff4 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -44,7 +44,6 @@ static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data);
static bool ixgbe_get_i2c_data(u32 *i2cctl);
static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw);
-static bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr);
static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id);
static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw);
@@ -61,8 +60,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
if (hw->phy.type == ixgbe_phy_unknown) {
for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
- if (ixgbe_validate_phy_addr(hw, phy_addr)) {
- hw->phy.addr = phy_addr;
+ if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) {
ixgbe_get_phy_id(hw);
hw->phy.type =
ixgbe_get_phy_type_from_id(hw->phy.id);
@@ -78,26 +76,6 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
}
/**
- * ixgbe_validate_phy_addr - Determines phy address is valid
- * @hw: pointer to hardware structure
- *
- **/
-static bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
-{
- u16 phy_id = 0;
- bool valid = false;
-
- hw->phy.addr = phy_addr;
- hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
-
- if (phy_id != 0xFFFF && phy_id != 0x0)
- valid = true;
-
- return valid;
-}
-
-/**
* ixgbe_get_phy_id - Get the phy type
* @hw: pointer to hardware structure
*
@@ -108,14 +86,12 @@ static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
u16 phy_id_high = 0;
u16 phy_id_low = 0;
- status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ status = hw->phy.ops.read_reg(hw, MDIO_DEVID1, MDIO_MMD_PMAPMD,
&phy_id_high);
if (status == 0) {
hw->phy.id = (u32)(phy_id_high << 16);
- status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ status = hw->phy.ops.read_reg(hw, MDIO_DEVID2, MDIO_MMD_PMAPMD,
&phy_id_low);
hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
@@ -160,9 +136,8 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
* Perform soft PHY reset to the PHY_XS.
* This will cause a soft reset to the PHY
*/
- return hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
- IXGBE_MDIO_PHY_XS_DEV_TYPE,
- IXGBE_MDIO_PHY_XS_RESET);
+ return hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS,
+ MDIO_CTRL1_RESET);
}
/**
@@ -192,7 +167,7 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
/* Setup and write the address cycle command */
command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
(device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
- (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+ (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
(IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
@@ -223,7 +198,8 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
*/
command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
(device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
- (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+ (hw->phy.mdio.prtad <<
+ IXGBE_MSCA_PHY_ADDR_SHIFT) |
(IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
@@ -292,7 +268,7 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
/* Setup and write the address cycle command */
command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
(device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
- (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+ (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
(IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
@@ -323,7 +299,8 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
*/
command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
(device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
- (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+ (hw->phy.mdio.prtad <<
+ IXGBE_MSCA_PHY_ADDR_SHIFT) |
(IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
@@ -365,7 +342,7 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
s32 status = IXGBE_NOT_IMPLEMENTED;
u32 time_out;
u32 max_time_out = 10;
- u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
+ u16 autoneg_reg;
/*
* Set advertisement settings in PHY based on autoneg_advertised
@@ -373,36 +350,31 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
* tnx devices cannot be "forced" to a autoneg 10G and fail. But can
* for a 1G.
*/
- hw->phy.ops.read_reg(hw, IXGBE_MII_SPEED_SELECTION_REG,
- IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
+ hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, MDIO_MMD_AN, &autoneg_reg);
if (hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_1GB_FULL)
- autoneg_reg &= 0xEFFF; /* 0 in bit 12 is 1G operation */
+ autoneg_reg &= ~MDIO_AN_10GBT_CTRL_ADV10G;
else
- autoneg_reg |= 0x1000; /* 1 in bit 12 is 10G/1G operation */
+ autoneg_reg |= MDIO_AN_10GBT_CTRL_ADV10G;
- hw->phy.ops.write_reg(hw, IXGBE_MII_SPEED_SELECTION_REG,
- IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
+ hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE, MDIO_MMD_AN, autoneg_reg);
/* Restart PHY autonegotiation and wait for completion */
- hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
- IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
+ hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, &autoneg_reg);
- autoneg_reg |= IXGBE_MII_RESTART;
+ autoneg_reg |= MDIO_AN_CTRL1_RESTART;
- hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
- IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
+ hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, autoneg_reg);
/* Wait for autonegotiation to finish */
for (time_out = 0; time_out < max_time_out; time_out++) {
udelay(10);
/* Restart PHY autonegotiation and wait for completion */
- status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
- IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ status = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
&autoneg_reg);
- autoneg_reg &= IXGBE_MII_AUTONEG_COMPLETE;
- if (autoneg_reg == IXGBE_MII_AUTONEG_COMPLETE) {
+ autoneg_reg &= MDIO_AN_STAT1_COMPLETE;
+ if (autoneg_reg == MDIO_AN_STAT1_COMPLETE) {
status = 0;
break;
}
@@ -457,23 +429,21 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
s32 ret_val = 0;
u32 i;
- hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
- IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
+ hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data);
/* reset the PHY and poll for completion */
- hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
- IXGBE_MDIO_PHY_XS_DEV_TYPE,
- (phy_data | IXGBE_MDIO_PHY_XS_RESET));
+ hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS,
+ (phy_data | MDIO_CTRL1_RESET));
for (i = 0; i < 100; i++) {
- hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
- IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
- if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
+ hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS,
+ &phy_data);
+ if ((phy_data & MDIO_CTRL1_RESET) == 0)
break;
msleep(10);
}
- if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
+ if ((phy_data & MDIO_CTRL1_RESET) != 0) {
hw_dbg(hw, "PHY reset did not complete.\n");
ret_val = IXGBE_ERR_PHY;
goto out;
@@ -509,7 +479,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
for (i = 0; i < edata; i++) {
hw->eeprom.ops.read(hw, data_offset, &eword);
hw->phy.ops.write_reg(hw, phy_offset,
- IXGBE_TWINAX_DEV, eword);
+ MDIO_MMD_PMAPMD, eword);
hw_dbg(hw, "Wrote %4.4x to %4.4x\n", eword,
phy_offset);
data_offset++;
@@ -552,11 +522,12 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
{
s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
u32 vendor_oui = 0;
+ enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
u8 identifier = 0;
u8 comp_codes_1g = 0;
u8 comp_codes_10g = 0;
u8 oui_bytes[3] = {0, 0, 0};
- u8 transmission_media = 0;
+ u8 cable_tech = 0;
u16 enforce_sfp = 0;
status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
@@ -572,8 +543,8 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
&comp_codes_1g);
hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_10GBE_COMP_CODES,
&comp_codes_10g);
- hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_TRANSMISSION_MEDIA,
- &transmission_media);
+ hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_CABLE_TECHNOLOGY,
+ &cable_tech);
/* ID Module
* =========
@@ -586,7 +557,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
* 6 SFP_SR/LR_CORE1 - 82599-specific
*/
if (hw->mac.type == ixgbe_mac_82598EB) {
- if (transmission_media & IXGBE_SFF_TWIN_AX_CAPABLE)
+ if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
hw->phy.sfp_type = ixgbe_sfp_type_sr;
@@ -595,7 +566,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
else
hw->phy.sfp_type = ixgbe_sfp_type_unknown;
} else if (hw->mac.type == ixgbe_mac_82599EB) {
- if (transmission_media & IXGBE_SFF_TWIN_AX_CAPABLE)
+ if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
if (hw->bus.lan_id == 0)
hw->phy.sfp_type =
ixgbe_sfp_type_da_cu_core0;
@@ -620,8 +591,18 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
hw->phy.sfp_type = ixgbe_sfp_type_unknown;
}
+ if (hw->phy.sfp_type != stored_sfp_type)
+ hw->phy.sfp_setup_needed = true;
+
+ /* Determine if the SFP+ PHY is dual speed or not. */
+ if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
+ (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
+ ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
+ (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
+ hw->phy.multispeed_fiber = true;
+
/* Determine PHY vendor */
- if (hw->phy.type == ixgbe_phy_unknown) {
+ if (hw->phy.type != ixgbe_phy_nl) {
hw->phy.id = identifier;
hw->phy.ops.read_i2c_eeprom(hw,
IXGBE_SFF_VENDOR_OUI_BYTE0,
@@ -640,8 +621,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
switch (vendor_oui) {
case IXGBE_SFF_VENDOR_OUI_TYCO:
- if (transmission_media &
- IXGBE_SFF_TWIN_AX_CAPABLE)
+ if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.type = ixgbe_phy_tw_tyco;
break;
case IXGBE_SFF_VENDOR_OUI_FTL:
@@ -654,31 +634,42 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
hw->phy.type = ixgbe_phy_sfp_intel;
break;
default:
- if (transmission_media &
- IXGBE_SFF_TWIN_AX_CAPABLE)
+ if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
hw->phy.type = ixgbe_phy_tw_unknown;
else
hw->phy.type = ixgbe_phy_sfp_unknown;
break;
}
}
- if (hw->mac.type == ixgbe_mac_82598EB ||
- (hw->phy.sfp_type != ixgbe_sfp_type_sr &&
- hw->phy.sfp_type != ixgbe_sfp_type_lr &&
- hw->phy.sfp_type != ixgbe_sfp_type_srlr_core0 &&
- hw->phy.sfp_type != ixgbe_sfp_type_srlr_core1)) {
+
+ /* All passive DA cables are supported */
+ if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
+ status = 0;
+ goto out;
+ }
+
+ /* 1G SFP modules are not supported */
+ if (comp_codes_10g == 0) {
+ hw->phy.type = ixgbe_phy_sfp_unsupported;
+ status = IXGBE_ERR_SFP_NOT_SUPPORTED;
+ goto out;
+ }
+
+ /* Anything else 82598-based is supported */
+ if (hw->mac.type == ixgbe_mac_82598EB) {
status = 0;
goto out;
}
- hw->eeprom.ops.read(hw, IXGBE_PHY_ENFORCE_INTEL_SFP_OFFSET,
- &enforce_sfp);
- if (!(enforce_sfp & IXGBE_PHY_ALLOW_ANY_SFP)) {
+ /* This is guaranteed to be 82599, no need to check for NULL */
+ hw->mac.ops.get_device_caps(hw, &enforce_sfp);
+ if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
/* Make sure we're a supported PHY type */
if (hw->phy.type == ixgbe_phy_sfp_intel) {
status = 0;
} else {
hw_dbg(hw, "SFP+ module not supported\n");
+ hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED;
}
} else {
@@ -1279,7 +1270,7 @@ s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
udelay(10);
status = hw->phy.ops.read_reg(hw,
IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
- IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ MDIO_MMD_VEND1,
&phy_data);
phy_link = phy_data &
IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
@@ -1307,8 +1298,7 @@ s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
{
s32 status = 0;
- status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
- IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ status = hw->phy.ops.read_reg(hw, TNX_FW_REV, MDIO_MMD_VEND1,
firmware_version);
return status;
diff --git a/drivers/net/ixgbe/ixgbe_phy.h b/drivers/net/ixgbe/ixgbe_phy.h
index cc5f1b3287e1..9b700f5bf1ed 100644
--- a/drivers/net/ixgbe/ixgbe_phy.h
+++ b/drivers/net/ixgbe/ixgbe_phy.h
@@ -39,11 +39,12 @@
#define IXGBE_SFF_VENDOR_OUI_BYTE2 0x27
#define IXGBE_SFF_1GBE_COMP_CODES 0x6
#define IXGBE_SFF_10GBE_COMP_CODES 0x3
-#define IXGBE_SFF_TRANSMISSION_MEDIA 0x9
+#define IXGBE_SFF_CABLE_TECHNOLOGY 0x8
/* Bitmasks */
-#define IXGBE_SFF_TWIN_AX_CAPABLE 0x80
+#define IXGBE_SFF_DA_PASSIVE_CABLE 0x4
#define IXGBE_SFF_1GBASESX_CAPABLE 0x1
+#define IXGBE_SFF_1GBASELX_CAPABLE 0x2
#define IXGBE_SFF_10GBASESR_CAPABLE 0x10
#define IXGBE_SFF_10GBASELR_CAPABLE 0x20
#define IXGBE_I2C_EEPROM_READ_MASK 0x100
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 030ff0a9ea67..ba3ed0f0bc9c 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -29,6 +29,7 @@
#define _IXGBE_TYPE_H_
#include <linux/types.h>
+#include <linux/mdio.h>
/* Vendor ID */
#define IXGBE_INTEL_VENDOR_ID 0x8086
@@ -48,6 +49,7 @@
#define IXGBE_DEV_ID_82599 0x10D8
#define IXGBE_DEV_ID_82599_KX4 0x10F7
#define IXGBE_DEV_ID_82599_SFP 0x10FB
+#define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC
/* General Registers */
#define IXGBE_CTRL 0x00000
@@ -443,6 +445,21 @@
#define IXGBE_SECTXCTRL_STORE_FORWARD_ENABLE 0x4
+/* HW RSC registers */
+#define IXGBE_RSCCTL(_i) (((_i) < 64) ? (0x0102C + ((_i) * 0x40)) : \
+ (0x0D02C + ((_i - 64) * 0x40)))
+#define IXGBE_RSCDBU 0x03028
+#define IXGBE_RSCCTL_RSCEN 0x01
+#define IXGBE_RSCCTL_MAXDESC_1 0x00
+#define IXGBE_RSCCTL_MAXDESC_4 0x04
+#define IXGBE_RSCCTL_MAXDESC_8 0x08
+#define IXGBE_RSCCTL_MAXDESC_16 0x0C
+#define IXGBE_RXDADV_RSCCNT_SHIFT 17
+#define IXGBE_GPIE_RSC_DELAY_SHIFT 11
+#define IXGBE_RXDADV_RSCCNT_MASK 0x001E0000
+#define IXGBE_RSCDBU_RSCACKDIS 0x00000080
+#define IXGBE_RDRXCTL_RSCFRSTSIZE 0x003E0000
+
/* DCB registers */
#define IXGBE_RTRPCS 0x02430
#define IXGBE_RTTDCS 0x04900
@@ -462,6 +479,63 @@
#define IXGBE_RTTDTECC_NO_BCN 0x00000100
#define IXGBE_RTTBCNRC 0x04984
+/* FCoE registers */
+#define IXGBE_FCPTRL 0x02410 /* FC User Desc. PTR Low */
+#define IXGBE_FCPTRH 0x02414 /* FC USer Desc. PTR High */
+#define IXGBE_FCBUFF 0x02418 /* FC Buffer Control */
+#define IXGBE_FCDMARW 0x02420 /* FC Receive DMA RW */
+#define IXGBE_FCINVST0 0x03FC0 /* FC Invalid DMA Context Status Reg 0 */
+#define IXGBE_FCINVST(_i) (IXGBE_FCINVST0 + ((_i) * 4))
+#define IXGBE_FCBUFF_VALID (1 << 0) /* DMA Context Valid */
+#define IXGBE_FCBUFF_BUFFSIZE (3 << 3) /* User Buffer Size */
+#define IXGBE_FCBUFF_WRCONTX (1 << 7) /* 0: Initiator, 1: Target */
+#define IXGBE_FCBUFF_BUFFCNT 0x0000ff00 /* Number of User Buffers */
+#define IXGBE_FCBUFF_OFFSET 0xffff0000 /* User Buffer Offset */
+#define IXGBE_FCBUFF_BUFFSIZE_SHIFT 3
+#define IXGBE_FCBUFF_BUFFCNT_SHIFT 8
+#define IXGBE_FCBUFF_OFFSET_SHIFT 16
+#define IXGBE_FCDMARW_WE (1 << 14) /* Write enable */
+#define IXGBE_FCDMARW_RE (1 << 15) /* Read enable */
+#define IXGBE_FCDMARW_FCOESEL 0x000001ff /* FC X_ID: 11 bits */
+#define IXGBE_FCDMARW_LASTSIZE 0xffff0000 /* Last User Buffer Size */
+#define IXGBE_FCDMARW_LASTSIZE_SHIFT 16
+
+/* FCoE SOF/EOF */
+#define IXGBE_TEOFF 0x04A94 /* Tx FC EOF */
+#define IXGBE_TSOFF 0x04A98 /* Tx FC SOF */
+#define IXGBE_REOFF 0x05158 /* Rx FC EOF */
+#define IXGBE_RSOFF 0x051F8 /* Rx FC SOF */
+/* FCoE Filter Context Registers */
+#define IXGBE_FCFLT 0x05108 /* FC FLT Context */
+#define IXGBE_FCFLTRW 0x05110 /* FC Filter RW Control */
+#define IXGBE_FCPARAM 0x051d8 /* FC Offset Parameter */
+#define IXGBE_FCFLT_VALID (1 << 0) /* Filter Context Valid */
+#define IXGBE_FCFLT_FIRST (1 << 1) /* Filter First */
+#define IXGBE_FCFLT_SEQID 0x00ff0000 /* Sequence ID */
+#define IXGBE_FCFLT_SEQCNT 0xff000000 /* Sequence Count */
+#define IXGBE_FCFLTRW_RVALDT (1 << 13) /* Fast Re-Validation */
+#define IXGBE_FCFLTRW_WE (1 << 14) /* Write Enable */
+#define IXGBE_FCFLTRW_RE (1 << 15) /* Read Enable */
+/* FCoE Receive Control */
+#define IXGBE_FCRXCTRL 0x05100 /* FC Receive Control */
+#define IXGBE_FCRXCTRL_FCOELLI (1 << 0) /* Low latency interrupt */
+#define IXGBE_FCRXCTRL_SAVBAD (1 << 1) /* Save Bad Frames */
+#define IXGBE_FCRXCTRL_FRSTRDH (1 << 2) /* EN 1st Read Header */
+#define IXGBE_FCRXCTRL_LASTSEQH (1 << 3) /* EN Last Header in Seq */
+#define IXGBE_FCRXCTRL_ALLH (1 << 4) /* EN All Headers */
+#define IXGBE_FCRXCTRL_FRSTSEQH (1 << 5) /* EN 1st Seq. Header */
+#define IXGBE_FCRXCTRL_ICRC (1 << 6) /* Ignore Bad FC CRC */
+#define IXGBE_FCRXCTRL_FCCRCBO (1 << 7) /* FC CRC Byte Ordering */
+#define IXGBE_FCRXCTRL_FCOEVER 0x00000f00 /* FCoE Version: 4 bits */
+#define IXGBE_FCRXCTRL_FCOEVER_SHIFT 8
+/* FCoE Redirection */
+#define IXGBE_FCRECTL 0x0ED00 /* FC Redirection Control */
+#define IXGBE_FCRETA0 0x0ED10 /* FC Redirection Table 0 */
+#define IXGBE_FCRETA(_i) (IXGBE_FCRETA0 + ((_i) * 4)) /* FCoE Redir */
+#define IXGBE_FCRECTL_ENA 0x1 /* FCoE Redir Table Enable */
+#define IXGBE_FCRETA_SIZE 8 /* Max entries in FCRETA */
+#define IXGBE_FCRETA_ENTRY_MASK 0x0000007f /* 7 bits for the queue index */
+
/* Stats registers */
#define IXGBE_CRCERRS 0x04000
#define IXGBE_ILLERRC 0x04004
@@ -533,6 +607,13 @@
#define IXGBE_QPRDC(_i) (0x01430 + ((_i) * 0x40)) /* 16 of these */
#define IXGBE_QBTC_L(_i) (0x08700 + ((_i) * 0x8)) /* 16 of these */
#define IXGBE_QBTC_H(_i) (0x08704 + ((_i) * 0x8)) /* 16 of these */
+#define IXGBE_FCCRC 0x05118 /* Count of Good Eth CRC w/ Bad FC CRC */
+#define IXGBE_FCOERPDC 0x0241C /* FCoE Rx Packets Dropped Count */
+#define IXGBE_FCLAST 0x02424 /* FCoE Last Error Count */
+#define IXGBE_FCOEPRC 0x02428 /* Number of FCoE Packets Received */
+#define IXGBE_FCOEDWRC 0x0242C /* Number of FCoE DWords Received */
+#define IXGBE_FCOEPTC 0x08784 /* Number of FCoE Packets Transmitted */
+#define IXGBE_FCOEDWTC 0x08788 /* Number of FCoE DWords Transmitted */
/* Management */
#define IXGBE_MAVTV(_i) (0x05010 + ((_i) * 4)) /* 8 of these (0-7) */
@@ -833,13 +914,7 @@
/* Omer bit masks */
#define IXGBE_CORECTL_WRITE_CMD 0x00010000
-/* Device Type definitions for new protocol MDIO commands */
-#define IXGBE_MDIO_PMA_PMD_DEV_TYPE 0x1
-#define IXGBE_MDIO_PCS_DEV_TYPE 0x3
-#define IXGBE_MDIO_PHY_XS_DEV_TYPE 0x4
-#define IXGBE_MDIO_AUTO_NEG_DEV_TYPE 0x7
-#define IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE 0x1E /* Device 30 */
-#define IXGBE_TWINAX_DEV 1
+/* MDIO definitions */
#define IXGBE_MDIO_COMMAND_TIMEOUT 100 /* PHY Timeout for 1 GB mode */
@@ -850,31 +925,10 @@
#define IXGBE_MDIO_VENDOR_SPECIFIC_1_10G_SPEED 0x0018
#define IXGBE_MDIO_VENDOR_SPECIFIC_1_1G_SPEED 0x0010
-#define IXGBE_MDIO_AUTO_NEG_CONTROL 0x0 /* AUTO_NEG Control Reg */
-#define IXGBE_MDIO_AUTO_NEG_STATUS 0x1 /* AUTO_NEG Status Reg */
-#define IXGBE_MDIO_PHY_XS_CONTROL 0x0 /* PHY_XS Control Reg */
-#define IXGBE_MDIO_PHY_XS_RESET 0x8000 /* PHY_XS Reset */
-#define IXGBE_MDIO_PHY_ID_HIGH 0x2 /* PHY ID High Reg*/
-#define IXGBE_MDIO_PHY_ID_LOW 0x3 /* PHY ID Low Reg*/
-#define IXGBE_MDIO_PHY_SPEED_ABILITY 0x4 /* Speed Ability Reg */
-#define IXGBE_MDIO_PHY_SPEED_10G 0x0001 /* 10G capable */
-#define IXGBE_MDIO_PHY_SPEED_1G 0x0010 /* 1G capable */
-#define IXGBE_MDIO_PHY_EXT_ABILITY 0xB /* Ext Ability Reg */
-#define IXGBE_MDIO_PHY_10GBASET_ABILITY 0x0004 /* 10GBaseT capable */
-#define IXGBE_MDIO_PHY_1000BASET_ABILITY 0x0020 /* 1000BaseT capable */
-
#define IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR 0xC30A /* PHY_XS SDA/SCL Addr Reg */
#define IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA 0xC30B /* PHY_XS SDA/SCL Data Reg */
#define IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT 0xC30C /* PHY_XS SDA/SCL Status Reg */
-/* MII clause 22/28 definitions */
-#define IXGBE_MDIO_PHY_LOW_POWER_MODE 0x0800
-
-#define IXGBE_MII_SPEED_SELECTION_REG 0x10
-#define IXGBE_MII_RESTART 0x200
-#define IXGBE_MII_AUTONEG_COMPLETE 0x20
-#define IXGBE_MII_AUTONEG_REG 0x0
-
#define IXGBE_PHY_REVISION_MASK 0xFFFFFFF0
#define IXGBE_MAX_PHY_ADDR 32
@@ -898,8 +952,6 @@
#define IXGBE_CONTROL_NL 0x000F
#define IXGBE_CONTROL_EOL_NL 0x0FFF
#define IXGBE_CONTROL_SOL_NL 0x0000
-#define IXGBE_PHY_ENFORCE_INTEL_SFP_OFFSET 0x002C
-#define IXGBE_PHY_ALLOW_ANY_SFP 0x1
/* General purpose Interrupt Enable */
#define IXGBE_SDP0_GPIEN 0x00000001 /* SDP0 */
@@ -958,6 +1010,8 @@
#define IXGBE_VT_CTL_DIS_DEFPL 0x20000000 /* disable default pool */
#define IXGBE_VT_CTL_REPLEN 0x40000000 /* replication enabled */
#define IXGBE_VT_CTL_VT_ENABLE 0x00000001 /* Enable VT Mode */
+#define IXGBE_VT_CTL_POOL_SHIFT 7
+#define IXGBE_VT_CTL_POOL_MASK (0x3F << IXGBE_VT_CTL_POOL_SHIFT)
/* VMOLR bitmasks */
#define IXGBE_VMOLR_AUPE 0x01000000 /* accept untagged packets */
@@ -1148,6 +1202,7 @@
/* Interrupt Vector Allocation Registers */
#define IXGBE_IVAR_REG_NUM 25
+#define IXGBE_IVAR_REG_NUM_82599 64
#define IXGBE_IVAR_TXRX_ENTRY 96
#define IXGBE_IVAR_RX_ENTRY 64
#define IXGBE_IVAR_RX_QUEUE(_i) (0 + (_i))
@@ -1163,6 +1218,7 @@
/* ETYPE Queue Filter/Select Bit Masks */
#define IXGBE_MAX_ETQF_FILTERS 8
+#define IXGBE_ETQF_FCOE 0x08000000 /* bit 27 */
#define IXGBE_ETQF_BCN 0x10000000 /* bit 28 */
#define IXGBE_ETQF_1588 0x40000000 /* bit 30 */
#define IXGBE_ETQF_FILTER_EN 0x80000000 /* bit 31 */
@@ -1185,6 +1241,7 @@
*/
#define IXGBE_ETQF_FILTER_EAPOL 0
#define IXGBE_ETQF_FILTER_BCN 1
+#define IXGBE_ETQF_FILTER_FCOE 2
#define IXGBE_ETQF_FILTER_1588 3
/* VLAN Control Bit Masks */
#define IXGBE_VLNCTRL_VET 0x0000FFFF /* bits 0-15 */
@@ -1382,6 +1439,8 @@
#define IXGBE_FW_PTR 0x0F
#define IXGBE_PBANUM0_PTR 0x15
#define IXGBE_PBANUM1_PTR 0x16
+#define IXGBE_DEVICE_CAPS 0x2C
+#define IXGBE_SAN_MAC_ADDR_PTR 0x28
#define IXGBE_PCIE_MSIX_82599_CAPS 0x72
#define IXGBE_PCIE_MSIX_82598_CAPS 0x62
@@ -1425,6 +1484,11 @@
#define IXGBE_EERD_ATTEMPTS 100000
#endif
+#define IXGBE_SAN_MAC_ADDR_PORT0_OFFSET 0x0
+#define IXGBE_SAN_MAC_ADDR_PORT1_OFFSET 0x3
+#define IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP 0x1
+#define IXGBE_DEVICE_CAPS_FCOE_OFFLOADS 0x2
+
/* PCI Bus Info */
#define IXGBE_PCI_LINK_STATUS 0xB2
#define IXGBE_PCI_LINK_WIDTH 0x3F0
@@ -1553,7 +1617,8 @@
#define IXGBE_MTQC_RT_ENA 0x1 /* DCB Enable */
#define IXGBE_MTQC_VT_ENA 0x2 /* VMDQ2 Enable */
#define IXGBE_MTQC_64Q_1PB 0x0 /* 64 queues 1 pack buffer */
-#define IXGBE_MTQC_64VF 0x8 /* 2 TX Queues per pool w/64VF's */
+#define IXGBE_MTQC_32VF 0x8 /* 4 TX Queues per pool w/32VF's */
+#define IXGBE_MTQC_64VF 0x4 /* 2 TX Queues per pool w/64VF's */
#define IXGBE_MTQC_8TC_8TQ 0xC /* 8 TC if RT_ENA or 8 TQ if VT_ENA */
/* Receive Descriptor bit definitions */
@@ -1585,6 +1650,8 @@
#define IXGBE_RXD_ERR_IPE 0x80 /* IP Checksum Error */
#define IXGBE_RXDADV_ERR_MASK 0xfff00000 /* RDESC.ERRORS mask */
#define IXGBE_RXDADV_ERR_SHIFT 20 /* RDESC.ERRORS shift */
+#define IXGBE_RXDADV_ERR_FCEOFE 0x80000000 /* FCoEFe/IPE */
+#define IXGBE_RXDADV_ERR_FCERR 0x00700000 /* FCERR/FDIRERR */
#define IXGBE_RXDADV_ERR_HBO 0x00800000 /*Header Buffer Overflow */
#define IXGBE_RXDADV_ERR_CE 0x01000000 /* CRC Error */
#define IXGBE_RXDADV_ERR_LE 0x02000000 /* Length Error */
@@ -1604,12 +1671,19 @@
#define IXGBE_RXDADV_STAT_FLM IXGBE_RXD_STAT_FLM /* FDir Match */
#define IXGBE_RXDADV_STAT_VP IXGBE_RXD_STAT_VP /* IEEE VLAN Pkt */
#define IXGBE_RXDADV_STAT_MASK 0x000fffff /* Stat/NEXTP: bit 0-19 */
+#define IXGBE_RXDADV_STAT_FCEOFS 0x00000040 /* FCoE EOF/SOF Stat */
+#define IXGBE_RXDADV_STAT_FCSTAT 0x00000030 /* FCoE Pkt Stat */
+#define IXGBE_RXDADV_STAT_FCSTAT_NOMTCH 0x00000000 /* 00: No Ctxt Match */
+#define IXGBE_RXDADV_STAT_FCSTAT_NODDP 0x00000010 /* 01: Ctxt w/o DDP */
+#define IXGBE_RXDADV_STAT_FCSTAT_FCPRSP 0x00000020 /* 10: Recv. FCP_RSP */
+#define IXGBE_RXDADV_STAT_FCSTAT_DDP 0x00000030 /* 11: Ctxt w/ DDP */
/* PSRTYPE bit definitions */
#define IXGBE_PSRTYPE_TCPHDR 0x00000010
#define IXGBE_PSRTYPE_UDPHDR 0x00000020
#define IXGBE_PSRTYPE_IPV4HDR 0x00000100
#define IXGBE_PSRTYPE_IPV6HDR 0x00000200
+#define IXGBE_PSRTYPE_L2HDR 0x00001000
/* SRRCTL bit definitions */
#define IXGBE_SRRCTL_BSIZEPKT_SHIFT 10 /* so many KBs */
@@ -1836,6 +1910,16 @@ struct ixgbe_adv_tx_context_desc {
#define IXGBE_ADVTXD_POPTS_IPSEC 0x00000400 /* IPSec offload request */
#define IXGBE_ADVTXD_TUCMD_IPSEC_TYPE_ESP 0x00002000 /* IPSec Type ESP */
#define IXGBE_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN 0x00004000/* ESP Encrypt Enable */
+#define IXGBE_ADVTXT_TUCMD_FCOE 0x00008000 /* FCoE Frame Type */
+#define IXGBE_ADVTXD_FCOEF_EOF_MASK (0x3 << 10) /* FC EOF index */
+#define IXGBE_ADVTXD_FCOEF_SOF ((1 << 2) << 10) /* FC SOF index */
+#define IXGBE_ADVTXD_FCOEF_PARINC ((1 << 3) << 10) /* Rel_Off in F_CTL */
+#define IXGBE_ADVTXD_FCOEF_ORIE ((1 << 4) << 10) /* Orientation: End */
+#define IXGBE_ADVTXD_FCOEF_ORIS ((1 << 5) << 10) /* Orientation: Start */
+#define IXGBE_ADVTXD_FCOEF_EOF_N (0x0 << 10) /* 00: EOFn */
+#define IXGBE_ADVTXD_FCOEF_EOF_T (0x1 << 10) /* 01: EOFt */
+#define IXGBE_ADVTXD_FCOEF_EOF_NI (0x2 << 10) /* 10: EOFni */
+#define IXGBE_ADVTXD_FCOEF_EOF_A (0x3 << 10) /* 11: EOFa */
#define IXGBE_ADVTXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */
#define IXGBE_ADVTXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */
@@ -1861,7 +1945,7 @@ typedef u32 ixgbe_physical_layer;
#define IXGBE_PHYSICAL_LAYER_UNKNOWN 0
#define IXGBE_PHYSICAL_LAYER_10GBASE_T 0x0001
#define IXGBE_PHYSICAL_LAYER_1000BASE_T 0x0002
-#define IXGBE_PHYSICAL_LAYER_100BASE_T 0x0004
+#define IXGBE_PHYSICAL_LAYER_100BASE_TX 0x0004
#define IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU 0x0008
#define IXGBE_PHYSICAL_LAYER_10GBASE_LR 0x0010
#define IXGBE_PHYSICAL_LAYER_10GBASE_LRM 0x0020
@@ -1870,6 +1954,8 @@ typedef u32 ixgbe_physical_layer;
#define IXGBE_PHYSICAL_LAYER_10GBASE_CX4 0x0100
#define IXGBE_PHYSICAL_LAYER_1000BASE_KX 0x0200
#define IXGBE_PHYSICAL_LAYER_1000BASE_BX 0x0400
+#define IXGBE_PHYSICAL_LAYER_10GBASE_KR 0x0800
+#define IXGBE_PHYSICAL_LAYER_10GBASE_XAUI 0x1000
enum ixgbe_eeprom_type {
ixgbe_eeprom_uninitialized = 0,
@@ -1897,6 +1983,7 @@ enum ixgbe_phy_type {
ixgbe_phy_sfp_ftl,
ixgbe_phy_sfp_unknown,
ixgbe_phy_sfp_intel,
+ ixgbe_phy_sfp_unsupported,
ixgbe_phy_generic
};
@@ -2075,6 +2162,12 @@ struct ixgbe_hw_stats {
u64 fdirfstat_fremove;
u64 fdirmatch;
u64 fdirmiss;
+ u64 fccrc;
+ u64 fcoerpdc;
+ u64 fcoeprc;
+ u64 fcoeptc;
+ u64 fcoedwrc;
+ u64 fcoedwtc;
};
/* forward declaration */
@@ -2101,6 +2194,8 @@ struct ixgbe_mac_operations {
enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
u32 (*get_supported_physical_layer)(struct ixgbe_hw *);
s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
+ s32 (*get_san_mac_addr)(struct ixgbe_hw *, u8 *);
+ s32 (*get_device_caps)(struct ixgbe_hw *, u16 *);
s32 (*stop_adapter)(struct ixgbe_hw *);
s32 (*get_bus_info)(struct ixgbe_hw *);
void (*set_lan_id)(struct ixgbe_hw *);
@@ -2146,6 +2241,7 @@ struct ixgbe_mac_operations {
struct ixgbe_phy_operations {
s32 (*identify)(struct ixgbe_hw *);
s32 (*identify_sfp)(struct ixgbe_hw *);
+ s32 (*init)(struct ixgbe_hw *);
s32 (*reset)(struct ixgbe_hw *);
s32 (*read_reg)(struct ixgbe_hw *, u32, u32, u16 *);
s32 (*write_reg)(struct ixgbe_hw *, u32, u32, u16);
@@ -2173,6 +2269,7 @@ struct ixgbe_mac_info {
enum ixgbe_mac_type type;
u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
u8 perm_addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
+ u8 san_addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
s32 mc_filter_type;
u32 mcft_size;
u32 vft_size;
@@ -2189,10 +2286,11 @@ struct ixgbe_mac_info {
struct ixgbe_phy_info {
struct ixgbe_phy_operations ops;
+ struct mdio_if_info mdio;
enum ixgbe_phy_type type;
- u32 addr;
u32 id;
enum ixgbe_sfp_type sfp_type;
+ bool sfp_setup_needed;
u32 revision;
enum ixgbe_media_type media_type;
bool reset_disable;
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index d3bf2f017cc2..2a0174b62e96 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -270,6 +270,18 @@ static int ixpdev_close(struct net_device *dev)
return 0;
}
+static const struct net_device_ops ixpdev_netdev_ops = {
+ .ndo_open = ixpdev_open,
+ .ndo_stop = ixpdev_close,
+ .ndo_start_xmit = ixpdev_xmit,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = ixpdev_poll_controller,
+#endif
+};
+
struct net_device *ixpdev_alloc(int channel, int sizeof_priv)
{
struct net_device *dev;
@@ -279,12 +291,7 @@ struct net_device *ixpdev_alloc(int channel, int sizeof_priv)
if (dev == NULL)
return NULL;
- dev->hard_start_xmit = ixpdev_xmit;
- dev->open = ixpdev_open;
- dev->stop = ixpdev_close;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = ixpdev_poll_controller;
-#endif
+ dev->netdev_ops = &ixpdev_netdev_ops;
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index 14248cfc3dfd..d12106b47bf2 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -96,6 +96,18 @@ static int jazzsonic_close(struct net_device* dev)
return err;
}
+static const struct net_device_ops sonic_netdev_ops = {
+ .ndo_open = jazzsonic_open,
+ .ndo_stop = jazzsonic_close,
+ .ndo_start_xmit = sonic_send_packet,
+ .ndo_get_stats = sonic_get_stats,
+ .ndo_set_multicast_list = sonic_multicast_list,
+ .ndo_tx_timeout = sonic_tx_timeout,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int __init sonic_probe1(struct net_device *dev)
{
static unsigned version_printed;
@@ -179,12 +191,7 @@ static int __init sonic_probe1(struct net_device *dev)
lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
* SONIC_BUS_SCALE(lp->dma_bitmode));
- dev->open = jazzsonic_open;
- dev->stop = jazzsonic_close;
- dev->hard_start_xmit = sonic_send_packet;
- dev->get_stats = sonic_get_stats;
- dev->set_multicast_list = &sonic_multicast_list;
- dev->tx_timeout = sonic_tx_timeout;
+ dev->netdev_ops = &sonic_netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
/*
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index 38d6649a29c4..dc238567cae1 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -1081,6 +1081,21 @@ static int korina_close(struct net_device *dev)
return 0;
}
+static const struct net_device_ops korina_netdev_ops = {
+ .ndo_open = korina_open,
+ .ndo_stop = korina_close,
+ .ndo_start_xmit = korina_send_packet,
+ .ndo_set_multicast_list = korina_multicast_list,
+ .ndo_tx_timeout = korina_tx_timeout,
+ .ndo_do_ioctl = korina_ioctl,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = korina_poll_controller,
+#endif
+};
+
static int korina_probe(struct platform_device *pdev)
{
struct korina_device *bif = platform_get_drvdata(pdev);
@@ -1149,17 +1164,9 @@ static int korina_probe(struct platform_device *pdev)
dev->irq = lp->rx_irq;
lp->dev = dev;
- dev->open = korina_open;
- dev->stop = korina_close;
- dev->hard_start_xmit = korina_send_packet;
- dev->set_multicast_list = &korina_multicast_list;
+ dev->netdev_ops = &korina_netdev_ops;
dev->ethtool_ops = &netdev_ethtool_ops;
- dev->tx_timeout = korina_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
- dev->do_ioctl = &korina_ioctl;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = korina_poll_controller;
-#endif
netif_napi_add(dev, &lp->napi, korina_poll, 64);
lp->phy_addr = (((lp->rx_irq == 0x2c? 1:0) << 8) | 0x05);
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index efbae4b8398e..a0c578585a50 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -161,12 +161,12 @@ lan_init_chip(struct parisc_device *dev)
if (!dev->irq) {
printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n",
- __FILE__, dev->hpa.start);
+ __FILE__, (unsigned long)dev->hpa.start);
return -ENODEV;
}
- printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n", dev->hpa.start,
- dev->irq);
+ printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n",
+ (unsigned long)dev->hpa.start, dev->irq);
netdevice = alloc_etherdev(sizeof(struct i596_private));
if (!netdevice)
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index 7415f517491d..070fa4500871 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -1036,6 +1036,19 @@ static void print_eth(unsigned char *add, char *str)
printk(KERN_DEBUG "i596 0x%p, %pM --> %pM %02X%02X, %s\n",
add, add + 6, add, add[12], add[13], str);
}
+static const struct net_device_ops i596_netdev_ops = {
+ .ndo_open = i596_open,
+ .ndo_stop = i596_close,
+ .ndo_start_xmit = i596_start_xmit,
+ .ndo_set_multicast_list = set_multicast_list,
+ .ndo_tx_timeout = i596_tx_timeout,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = i596_poll_controller,
+#endif
+};
static int __devinit i82596_probe(struct net_device *dev)
{
@@ -1062,16 +1075,8 @@ static int __devinit i82596_probe(struct net_device *dev)
return -ENOMEM;
}
- /* The 82596-specific entries in the device structure. */
- dev->open = i596_open;
- dev->stop = i596_close;
- dev->hard_start_xmit = i596_start_xmit;
- dev->set_multicast_list = set_multicast_list;
- dev->tx_timeout = i596_tx_timeout;
+ dev->netdev_ops = &i596_netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = i596_poll_controller;
-#endif
memset(dma, 0, sizeof(struct i596_dma));
lp->dma = dma;
diff --git a/drivers/net/ll_temac.h b/drivers/net/ll_temac.h
new file mode 100644
index 000000000000..1af66a1e6911
--- /dev/null
+++ b/drivers/net/ll_temac.h
@@ -0,0 +1,374 @@
+
+#ifndef XILINX_LL_TEMAC_H
+#define XILINX_LL_TEMAC_H
+
+#include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/spinlock.h>
+#include <asm/dcr.h>
+#include <asm/dcr-regs.h>
+
+/* packet size info */
+#define XTE_HDR_SIZE 14 /* size of Ethernet header */
+#define XTE_TRL_SIZE 4 /* size of Ethernet trailer (FCS) */
+#define XTE_JUMBO_MTU 9000
+#define XTE_MAX_JUMBO_FRAME_SIZE (XTE_JUMBO_MTU + XTE_HDR_SIZE + XTE_TRL_SIZE)
+
+/* Configuration options */
+
+/* Accept all incoming packets.
+ * This option defaults to disabled (cleared) */
+#define XTE_OPTION_PROMISC (1 << 0)
+/* Jumbo frame support for Tx & Rx.
+ * This option defaults to disabled (cleared) */
+#define XTE_OPTION_JUMBO (1 << 1)
+/* VLAN Rx & Tx frame support.
+ * This option defaults to disabled (cleared) */
+#define XTE_OPTION_VLAN (1 << 2)
+/* Enable recognition of flow control frames on Rx
+ * This option defaults to enabled (set) */
+#define XTE_OPTION_FLOW_CONTROL (1 << 4)
+/* Strip FCS and PAD from incoming frames.
+ * Note: PAD from VLAN frames is not stripped.
+ * This option defaults to disabled (set) */
+#define XTE_OPTION_FCS_STRIP (1 << 5)
+/* Generate FCS field and add PAD automatically for outgoing frames.
+ * This option defaults to enabled (set) */
+#define XTE_OPTION_FCS_INSERT (1 << 6)
+/* Enable Length/Type error checking for incoming frames. When this option is
+set, the MAC will filter frames that have a mismatched type/length field
+and if XTE_OPTION_REPORT_RXERR is set, the user is notified when these
+types of frames are encountered. When this option is cleared, the MAC will
+allow these types of frames to be received.
+This option defaults to enabled (set) */
+#define XTE_OPTION_LENTYPE_ERR (1 << 7)
+/* Enable the transmitter.
+ * This option defaults to enabled (set) */
+#define XTE_OPTION_TXEN (1 << 11)
+/* Enable the receiver
+* This option defaults to enabled (set) */
+#define XTE_OPTION_RXEN (1 << 12)
+
+/* Default options set when device is initialized or reset */
+#define XTE_OPTION_DEFAULTS \
+ (XTE_OPTION_TXEN | \
+ XTE_OPTION_FLOW_CONTROL | \
+ XTE_OPTION_RXEN)
+
+/* XPS_LL_TEMAC SDMA registers definition */
+
+#define TX_NXTDESC_PTR 0x00 /* r */
+#define TX_CURBUF_ADDR 0x01 /* r */
+#define TX_CURBUF_LENGTH 0x02 /* r */
+#define TX_CURDESC_PTR 0x03 /* rw */
+#define TX_TAILDESC_PTR 0x04 /* rw */
+#define TX_CHNL_CTRL 0x05 /* rw */
+/*
+ 0:7 24:31 IRQTimeout
+ 8:15 16:23 IRQCount
+ 16:20 11:15 Reserved
+ 21 10 0
+ 22 9 UseIntOnEnd
+ 23 8 LdIRQCnt
+ 24 7 IRQEn
+ 25:28 3:6 Reserved
+ 29 2 IrqErrEn
+ 30 1 IrqDlyEn
+ 31 0 IrqCoalEn
+*/
+#define CHNL_CTRL_IRQ_IOE (1 << 9)
+#define CHNL_CTRL_IRQ_EN (1 << 7)
+#define CHNL_CTRL_IRQ_ERR_EN (1 << 2)
+#define CHNL_CTRL_IRQ_DLY_EN (1 << 1)
+#define CHNL_CTRL_IRQ_COAL_EN (1 << 0)
+#define TX_IRQ_REG 0x06 /* rw */
+/*
+ 0:7 24:31 DltTmrValue
+ 8:15 16:23 ClscCntrValue
+ 16:17 14:15 Reserved
+ 18:21 10:13 ClscCnt
+ 22:23 8:9 DlyCnt
+ 24:28 3::7 Reserved
+ 29 2 ErrIrq
+ 30 1 DlyIrq
+ 31 0 CoalIrq
+ */
+#define TX_CHNL_STS 0x07 /* r */
+/*
+ 0:9 22:31 Reserved
+ 10 21 TailPErr
+ 11 20 CmpErr
+ 12 19 AddrErr
+ 13 18 NxtPErr
+ 14 17 CurPErr
+ 15 16 BsyWr
+ 16:23 8:15 Reserved
+ 24 7 Error
+ 25 6 IOE
+ 26 5 SOE
+ 27 4 Cmplt
+ 28 3 SOP
+ 29 2 EOP
+ 30 1 EngBusy
+ 31 0 Reserved
+*/
+
+#define RX_NXTDESC_PTR 0x08 /* r */
+#define RX_CURBUF_ADDR 0x09 /* r */
+#define RX_CURBUF_LENGTH 0x0a /* r */
+#define RX_CURDESC_PTR 0x0b /* rw */
+#define RX_TAILDESC_PTR 0x0c /* rw */
+#define RX_CHNL_CTRL 0x0d /* rw */
+/*
+ 0:7 24:31 IRQTimeout
+ 8:15 16:23 IRQCount
+ 16:20 11:15 Reserved
+ 21 10 0
+ 22 9 UseIntOnEnd
+ 23 8 LdIRQCnt
+ 24 7 IRQEn
+ 25:28 3:6 Reserved
+ 29 2 IrqErrEn
+ 30 1 IrqDlyEn
+ 31 0 IrqCoalEn
+ */
+#define RX_IRQ_REG 0x0e /* rw */
+#define IRQ_COAL (1 << 0)
+#define IRQ_DLY (1 << 1)
+#define IRQ_ERR (1 << 2)
+#define IRQ_DMAERR (1 << 7) /* this is not documented ??? */
+/*
+ 0:7 24:31 DltTmrValue
+ 8:15 16:23 ClscCntrValue
+ 16:17 14:15 Reserved
+ 18:21 10:13 ClscCnt
+ 22:23 8:9 DlyCnt
+ 24:28 3::7 Reserved
+*/
+#define RX_CHNL_STS 0x0f /* r */
+#define CHNL_STS_ENGBUSY (1 << 1)
+#define CHNL_STS_EOP (1 << 2)
+#define CHNL_STS_SOP (1 << 3)
+#define CHNL_STS_CMPLT (1 << 4)
+#define CHNL_STS_SOE (1 << 5)
+#define CHNL_STS_IOE (1 << 6)
+#define CHNL_STS_ERR (1 << 7)
+
+#define CHNL_STS_BSYWR (1 << 16)
+#define CHNL_STS_CURPERR (1 << 17)
+#define CHNL_STS_NXTPERR (1 << 18)
+#define CHNL_STS_ADDRERR (1 << 19)
+#define CHNL_STS_CMPERR (1 << 20)
+#define CHNL_STS_TAILERR (1 << 21)
+/*
+ 0:9 22:31 Reserved
+ 10 21 TailPErr
+ 11 20 CmpErr
+ 12 19 AddrErr
+ 13 18 NxtPErr
+ 14 17 CurPErr
+ 15 16 BsyWr
+ 16:23 8:15 Reserved
+ 24 7 Error
+ 25 6 IOE
+ 26 5 SOE
+ 27 4 Cmplt
+ 28 3 SOP
+ 29 2 EOP
+ 30 1 EngBusy
+ 31 0 Reserved
+*/
+
+#define DMA_CONTROL_REG 0x10 /* rw */
+#define DMA_CONTROL_RST (1 << 0)
+#define DMA_TAIL_ENABLE (1 << 2)
+
+/* XPS_LL_TEMAC direct registers definition */
+
+#define XTE_RAF0_OFFSET 0x00
+#define RAF0_RST (1 << 0)
+#define RAF0_MCSTREJ (1 << 1)
+#define RAF0_BCSTREJ (1 << 2)
+#define XTE_TPF0_OFFSET 0x04
+#define XTE_IFGP0_OFFSET 0x08
+#define XTE_ISR0_OFFSET 0x0c
+#define ISR0_HARDACSCMPLT (1 << 0)
+#define ISR0_AUTONEG (1 << 1)
+#define ISR0_RXCMPLT (1 << 2)
+#define ISR0_RXREJ (1 << 3)
+#define ISR0_RXFIFOOVR (1 << 4)
+#define ISR0_TXCMPLT (1 << 5)
+#define ISR0_RXDCMLCK (1 << 6)
+
+#define XTE_IPR0_OFFSET 0x10
+#define XTE_IER0_OFFSET 0x14
+
+#define XTE_MSW0_OFFSET 0x20
+#define XTE_LSW0_OFFSET 0x24
+#define XTE_CTL0_OFFSET 0x28
+#define XTE_RDY0_OFFSET 0x2c
+
+#define XTE_RSE_MIIM_RR_MASK 0x0002
+#define XTE_RSE_MIIM_WR_MASK 0x0004
+#define XTE_RSE_CFG_RR_MASK 0x0020
+#define XTE_RSE_CFG_WR_MASK 0x0040
+#define XTE_RDY0_HARD_ACS_RDY_MASK (0x10000)
+
+/* XPS_LL_TEMAC indirect registers offset definition */
+
+#define XTE_RXC0_OFFSET 0x00000200 /* Rx configuration word 0 */
+#define XTE_RXC1_OFFSET 0x00000240 /* Rx configuration word 1 */
+#define XTE_RXC1_RXRST_MASK (1 << 31) /* Receiver reset */
+#define XTE_RXC1_RXJMBO_MASK (1 << 30) /* Jumbo frame enable */
+#define XTE_RXC1_RXFCS_MASK (1 << 29) /* FCS not stripped */
+#define XTE_RXC1_RXEN_MASK (1 << 28) /* Receiver enable */
+#define XTE_RXC1_RXVLAN_MASK (1 << 27) /* VLAN enable */
+#define XTE_RXC1_RXHD_MASK (1 << 26) /* Half duplex */
+#define XTE_RXC1_RXLT_MASK (1 << 25) /* Length/type check disable */
+
+#define XTE_TXC_OFFSET 0x00000280 /* Tx configuration */
+#define XTE_TXC_TXRST_MASK (1 << 31) /* Transmitter reset */
+#define XTE_TXC_TXJMBO_MASK (1 << 30) /* Jumbo frame enable */
+#define XTE_TXC_TXFCS_MASK (1 << 29) /* Generate FCS */
+#define XTE_TXC_TXEN_MASK (1 << 28) /* Transmitter enable */
+#define XTE_TXC_TXVLAN_MASK (1 << 27) /* VLAN enable */
+#define XTE_TXC_TXHD_MASK (1 << 26) /* Half duplex */
+
+#define XTE_FCC_OFFSET 0x000002C0 /* Flow control config */
+#define XTE_FCC_RXFLO_MASK (1 << 29) /* Rx flow control enable */
+#define XTE_FCC_TXFLO_MASK (1 << 30) /* Tx flow control enable */
+
+#define XTE_EMCFG_OFFSET 0x00000300 /* EMAC configuration */
+#define XTE_EMCFG_LINKSPD_MASK 0xC0000000 /* Link speed */
+#define XTE_EMCFG_HOSTEN_MASK (1 << 26) /* Host interface enable */
+#define XTE_EMCFG_LINKSPD_10 0x00000000 /* 10 Mbit LINKSPD_MASK */
+#define XTE_EMCFG_LINKSPD_100 (1 << 30) /* 100 Mbit LINKSPD_MASK */
+#define XTE_EMCFG_LINKSPD_1000 (1 << 31) /* 1000 Mbit LINKSPD_MASK */
+
+#define XTE_GMIC_OFFSET 0x00000320 /* RGMII/SGMII config */
+#define XTE_MC_OFFSET 0x00000340 /* MDIO configuration */
+#define XTE_UAW0_OFFSET 0x00000380 /* Unicast address word 0 */
+#define XTE_UAW1_OFFSET 0x00000384 /* Unicast address word 1 */
+
+#define XTE_MAW0_OFFSET 0x00000388 /* Multicast addr word 0 */
+#define XTE_MAW1_OFFSET 0x0000038C /* Multicast addr word 1 */
+#define XTE_AFM_OFFSET 0x00000390 /* Promiscuous mode */
+#define XTE_AFM_EPPRM_MASK (1 << 31) /* Promiscuous mode enable */
+
+/* Interrupt Request status */
+#define XTE_TIS_OFFSET 0x000003A0
+#define TIS_FRIS (1 << 0)
+#define TIS_MRIS (1 << 1)
+#define TIS_MWIS (1 << 2)
+#define TIS_ARIS (1 << 3)
+#define TIS_AWIS (1 << 4)
+#define TIS_CRIS (1 << 5)
+#define TIS_CWIS (1 << 6)
+
+#define XTE_TIE_OFFSET 0x000003A4 /* Interrupt enable */
+
+/** MII Mamagement Control register (MGTCR) */
+#define XTE_MGTDR_OFFSET 0x000003B0 /* MII data */
+#define XTE_MIIMAI_OFFSET 0x000003B4 /* MII control */
+
+#define CNTLREG_WRITE_ENABLE_MASK 0x8000
+#define CNTLREG_EMAC1SEL_MASK 0x0400
+#define CNTLREG_ADDRESSCODE_MASK 0x03ff
+
+/* CDMAC descriptor status bit definitions */
+
+#define STS_CTRL_APP0_ERR (1 << 31)
+#define STS_CTRL_APP0_IRQONEND (1 << 30)
+/* undoccumented */
+#define STS_CTRL_APP0_STOPONEND (1 << 29)
+#define STS_CTRL_APP0_CMPLT (1 << 28)
+#define STS_CTRL_APP0_SOP (1 << 27)
+#define STS_CTRL_APP0_EOP (1 << 26)
+#define STS_CTRL_APP0_ENGBUSY (1 << 25)
+/* undocumented */
+#define STS_CTRL_APP0_ENGRST (1 << 24)
+
+#define TX_CONTROL_CALC_CSUM_MASK 1
+
+#define XTE_ALIGN 32
+#define BUFFER_ALIGN(adr) ((XTE_ALIGN - ((u32) adr)) % XTE_ALIGN)
+
+#define MULTICAST_CAM_TABLE_NUM 4
+
+/* TX/RX CURDESC_PTR points to first descriptor */
+/* TX/RX TAILDESC_PTR points to last descriptor in linked list */
+
+/**
+ * struct cdmac_bd - LocalLink buffer descriptor format
+ *
+ * app0 bits:
+ * 0 Error
+ * 1 IrqOnEnd generate an interrupt at completion of DMA op
+ * 2 reserved
+ * 3 completed Current descriptor completed
+ * 4 SOP TX - marks first desc/ RX marks first desct
+ * 5 EOP TX marks last desc/RX marks last desc
+ * 6 EngBusy DMA is processing
+ * 7 reserved
+ * 8:31 application specific
+ */
+struct cdmac_bd {
+ u32 next; /* Physical address of next buffer descriptor */
+ u32 phys;
+ u32 len;
+ u32 app0;
+ u32 app1; /* TX start << 16 | insert */
+ u32 app2; /* TX csum */
+ u32 app3;
+ u32 app4; /* skb for TX length for RX */
+};
+
+struct temac_local {
+ struct net_device *ndev;
+ struct device *dev;
+
+ /* Connection to PHY device */
+ struct phy_device *phy_dev; /* Pointer to PHY device */
+ struct device_node *phy_node;
+
+ /* MDIO bus data */
+ struct mii_bus *mii_bus; /* MII bus reference */
+ int mdio_irqs[PHY_MAX_ADDR]; /* IRQs table for MDIO bus */
+
+ /* IO registers and IRQs */
+ void __iomem *regs;
+ dcr_host_t sdma_dcrs;
+ int tx_irq;
+ int rx_irq;
+ int emac_num;
+
+ struct sk_buff **rx_skb;
+ spinlock_t rx_lock;
+ struct mutex indirect_mutex;
+ u32 options; /* Current options word */
+ int last_link;
+
+ /* Buffer descriptors */
+ struct cdmac_bd *tx_bd_v;
+ dma_addr_t tx_bd_p;
+ struct cdmac_bd *rx_bd_v;
+ dma_addr_t rx_bd_p;
+ int tx_bd_ci;
+ int tx_bd_next;
+ int tx_bd_tail;
+ int rx_bd_ci;
+};
+
+/* xilinx_temac.c */
+u32 temac_ior(struct temac_local *lp, int offset);
+void temac_iow(struct temac_local *lp, int offset, u32 value);
+int temac_indirect_busywait(struct temac_local *lp);
+u32 temac_indirect_in32(struct temac_local *lp, int reg);
+void temac_indirect_out32(struct temac_local *lp, int reg, u32 value);
+
+
+/* xilinx_temac_mdio.c */
+int temac_mdio_setup(struct temac_local *lp, struct device_node *np);
+void temac_mdio_teardown(struct temac_local *lp);
+
+#endif /* XILINX_LL_TEMAC_H */
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
new file mode 100644
index 000000000000..96e7248876c1
--- /dev/null
+++ b/drivers/net/ll_temac_main.c
@@ -0,0 +1,969 @@
+/*
+ * Driver for Xilinx TEMAC Ethernet device
+ *
+ * Copyright (c) 2008 Nissin Systems Co., Ltd., Yoshio Kashiwagi
+ * Copyright (c) 2005-2008 DLA Systems, David H. Lynch Jr. <dhlii@dlasys.net>
+ * Copyright (c) 2008-2009 Secret Lab Technologies Ltd.
+ *
+ * This is a driver for the Xilinx ll_temac ipcore which is often used
+ * in the Virtex and Spartan series of chips.
+ *
+ * Notes:
+ * - The ll_temac hardware uses indirect access for many of the TEMAC
+ * registers, include the MDIO bus. However, indirect access to MDIO
+ * registers take considerably more clock cycles than to TEMAC registers.
+ * MDIO accesses are long, so threads doing them should probably sleep
+ * rather than busywait. However, since only one indirect access can be
+ * in progress at any given time, that means that *all* indirect accesses
+ * could end up sleeping (to wait for an MDIO access to complete).
+ * Fortunately none of the indirect accesses are on the 'hot' path for tx
+ * or rx, so this should be okay.
+ *
+ * TODO:
+ * - Fix driver to work on more than just Virtex5. Right now the driver
+ * assumes that the locallink DMA registers are accessed via DCR
+ * instructions.
+ * - Factor out locallink DMA code into separate driver
+ * - Fix multicast assignment.
+ * - Fix support for hardware checksumming.
+ * - Testing. Lots and lots of testing.
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/etherdevice.h>
+#include <linux/init.h>
+#include <linux/mii.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_mdio.h>
+#include <linux/of_platform.h>
+#include <linux/skbuff.h>
+#include <linux/spinlock.h>
+#include <linux/tcp.h> /* needed for sizeof(tcphdr) */
+#include <linux/udp.h> /* needed for sizeof(udphdr) */
+#include <linux/phy.h>
+#include <linux/in.h>
+#include <linux/io.h>
+#include <linux/ip.h>
+
+#include "ll_temac.h"
+
+#define TX_BD_NUM 64
+#define RX_BD_NUM 128
+
+/* ---------------------------------------------------------------------
+ * Low level register access functions
+ */
+
+u32 temac_ior(struct temac_local *lp, int offset)
+{
+ return in_be32((u32 *)(lp->regs + offset));
+}
+
+void temac_iow(struct temac_local *lp, int offset, u32 value)
+{
+ out_be32((u32 *) (lp->regs + offset), value);
+}
+
+int temac_indirect_busywait(struct temac_local *lp)
+{
+ long end = jiffies + 2;
+
+ while (!(temac_ior(lp, XTE_RDY0_OFFSET) & XTE_RDY0_HARD_ACS_RDY_MASK)) {
+ if (end - jiffies <= 0) {
+ WARN_ON(1);
+ return -ETIMEDOUT;
+ }
+ msleep(1);
+ }
+ return 0;
+}
+
+/**
+ * temac_indirect_in32
+ *
+ * lp->indirect_mutex must be held when calling this function
+ */
+u32 temac_indirect_in32(struct temac_local *lp, int reg)
+{
+ u32 val;
+
+ if (temac_indirect_busywait(lp))
+ return -ETIMEDOUT;
+ temac_iow(lp, XTE_CTL0_OFFSET, reg);
+ if (temac_indirect_busywait(lp))
+ return -ETIMEDOUT;
+ val = temac_ior(lp, XTE_LSW0_OFFSET);
+
+ return val;
+}
+
+/**
+ * temac_indirect_out32
+ *
+ * lp->indirect_mutex must be held when calling this function
+ */
+void temac_indirect_out32(struct temac_local *lp, int reg, u32 value)
+{
+ if (temac_indirect_busywait(lp))
+ return;
+ temac_iow(lp, XTE_LSW0_OFFSET, value);
+ temac_iow(lp, XTE_CTL0_OFFSET, CNTLREG_WRITE_ENABLE_MASK | reg);
+}
+
+static u32 temac_dma_in32(struct temac_local *lp, int reg)
+{
+ return dcr_read(lp->sdma_dcrs, reg);
+}
+
+static void temac_dma_out32(struct temac_local *lp, int reg, u32 value)
+{
+ dcr_write(lp->sdma_dcrs, reg, value);
+}
+
+/**
+ * temac_dma_bd_init - Setup buffer descriptor rings
+ */
+static int temac_dma_bd_init(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ struct sk_buff *skb;
+ int i;
+
+ lp->rx_skb = kzalloc(sizeof(struct sk_buff)*RX_BD_NUM, GFP_KERNEL);
+ /* allocate the tx and rx ring buffer descriptors. */
+ /* returns a virtual addres and a physical address. */
+ lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent,
+ sizeof(*lp->tx_bd_v) * TX_BD_NUM,
+ &lp->tx_bd_p, GFP_KERNEL);
+ lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent,
+ sizeof(*lp->rx_bd_v) * RX_BD_NUM,
+ &lp->rx_bd_p, GFP_KERNEL);
+
+ memset(lp->tx_bd_v, 0, sizeof(*lp->tx_bd_v) * TX_BD_NUM);
+ for (i = 0; i < TX_BD_NUM; i++) {
+ lp->tx_bd_v[i].next = lp->tx_bd_p +
+ sizeof(*lp->tx_bd_v) * ((i + 1) % TX_BD_NUM);
+ }
+
+ memset(lp->rx_bd_v, 0, sizeof(*lp->rx_bd_v) * RX_BD_NUM);
+ for (i = 0; i < RX_BD_NUM; i++) {
+ lp->rx_bd_v[i].next = lp->rx_bd_p +
+ sizeof(*lp->rx_bd_v) * ((i + 1) % RX_BD_NUM);
+
+ skb = alloc_skb(XTE_MAX_JUMBO_FRAME_SIZE
+ + XTE_ALIGN, GFP_ATOMIC);
+ if (skb == 0) {
+ dev_err(&ndev->dev, "alloc_skb error %d\n", i);
+ return -1;
+ }
+ lp->rx_skb[i] = skb;
+ skb_reserve(skb, BUFFER_ALIGN(skb->data));
+ /* returns physical address of skb->data */
+ lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent,
+ skb->data,
+ XTE_MAX_JUMBO_FRAME_SIZE,
+ DMA_FROM_DEVICE);
+ lp->rx_bd_v[i].len = XTE_MAX_JUMBO_FRAME_SIZE;
+ lp->rx_bd_v[i].app0 = STS_CTRL_APP0_IRQONEND;
+ }
+
+ temac_dma_out32(lp, TX_CHNL_CTRL, 0x10220400 |
+ CHNL_CTRL_IRQ_EN |
+ CHNL_CTRL_IRQ_DLY_EN |
+ CHNL_CTRL_IRQ_COAL_EN);
+ /* 0x10220483 */
+ /* 0x00100483 */
+ temac_dma_out32(lp, RX_CHNL_CTRL, 0xff010000 |
+ CHNL_CTRL_IRQ_EN |
+ CHNL_CTRL_IRQ_DLY_EN |
+ CHNL_CTRL_IRQ_COAL_EN |
+ CHNL_CTRL_IRQ_IOE);
+ /* 0xff010283 */
+
+ temac_dma_out32(lp, RX_CURDESC_PTR, lp->rx_bd_p);
+ temac_dma_out32(lp, RX_TAILDESC_PTR,
+ lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
+ temac_dma_out32(lp, TX_CURDESC_PTR, lp->tx_bd_p);
+
+ return 0;
+}
+
+/* ---------------------------------------------------------------------
+ * net_device_ops
+ */
+
+static int temac_set_mac_address(struct net_device *ndev, void *address)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+
+ if (address)
+ memcpy(ndev->dev_addr, address, ETH_ALEN);
+
+ if (!is_valid_ether_addr(ndev->dev_addr))
+ random_ether_addr(ndev->dev_addr);
+
+ /* set up unicast MAC address filter set its mac address */
+ mutex_lock(&lp->indirect_mutex);
+ temac_indirect_out32(lp, XTE_UAW0_OFFSET,
+ (ndev->dev_addr[0]) |
+ (ndev->dev_addr[1] << 8) |
+ (ndev->dev_addr[2] << 16) |
+ (ndev->dev_addr[3] << 24));
+ /* There are reserved bits in EUAW1
+ * so don't affect them Set MAC bits [47:32] in EUAW1 */
+ temac_indirect_out32(lp, XTE_UAW1_OFFSET,
+ (ndev->dev_addr[4] & 0x000000ff) |
+ (ndev->dev_addr[5] << 8));
+ mutex_unlock(&lp->indirect_mutex);
+
+ return 0;
+}
+
+static void temac_set_multicast_list(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ u32 multi_addr_msw, multi_addr_lsw, val;
+ int i;
+
+ mutex_lock(&lp->indirect_mutex);
+ if (ndev->flags & (IFF_ALLMULTI | IFF_PROMISC)
+ || ndev->mc_count > MULTICAST_CAM_TABLE_NUM) {
+ /*
+ * We must make the kernel realise we had to move
+ * into promisc mode or we start all out war on
+ * the cable. If it was a promisc request the
+ * flag is already set. If not we assert it.
+ */
+ ndev->flags |= IFF_PROMISC;
+ temac_indirect_out32(lp, XTE_AFM_OFFSET, XTE_AFM_EPPRM_MASK);
+ dev_info(&ndev->dev, "Promiscuous mode enabled.\n");
+ } else if (ndev->mc_count) {
+ struct dev_mc_list *mclist = ndev->mc_list;
+ for (i = 0; mclist && i < ndev->mc_count; i++) {
+
+ if (i >= MULTICAST_CAM_TABLE_NUM)
+ break;
+ multi_addr_msw = ((mclist->dmi_addr[3] << 24) |
+ (mclist->dmi_addr[2] << 16) |
+ (mclist->dmi_addr[1] << 8) |
+ (mclist->dmi_addr[0]));
+ temac_indirect_out32(lp, XTE_MAW0_OFFSET,
+ multi_addr_msw);
+ multi_addr_lsw = ((mclist->dmi_addr[5] << 8) |
+ (mclist->dmi_addr[4]) | (i << 16));
+ temac_indirect_out32(lp, XTE_MAW1_OFFSET,
+ multi_addr_lsw);
+ mclist = mclist->next;
+ }
+ } else {
+ val = temac_indirect_in32(lp, XTE_AFM_OFFSET);
+ temac_indirect_out32(lp, XTE_AFM_OFFSET,
+ val & ~XTE_AFM_EPPRM_MASK);
+ temac_indirect_out32(lp, XTE_MAW0_OFFSET, 0);
+ temac_indirect_out32(lp, XTE_MAW1_OFFSET, 0);
+ dev_info(&ndev->dev, "Promiscuous mode disabled.\n");
+ }
+ mutex_unlock(&lp->indirect_mutex);
+}
+
+struct temac_option {
+ int flg;
+ u32 opt;
+ u32 reg;
+ u32 m_or;
+ u32 m_and;
+} temac_options[] = {
+ /* Turn on jumbo packet support for both Rx and Tx */
+ {
+ .opt = XTE_OPTION_JUMBO,
+ .reg = XTE_TXC_OFFSET,
+ .m_or = XTE_TXC_TXJMBO_MASK,
+ },
+ {
+ .opt = XTE_OPTION_JUMBO,
+ .reg = XTE_RXC1_OFFSET,
+ .m_or =XTE_RXC1_RXJMBO_MASK,
+ },
+ /* Turn on VLAN packet support for both Rx and Tx */
+ {
+ .opt = XTE_OPTION_VLAN,
+ .reg = XTE_TXC_OFFSET,
+ .m_or =XTE_TXC_TXVLAN_MASK,
+ },
+ {
+ .opt = XTE_OPTION_VLAN,
+ .reg = XTE_RXC1_OFFSET,
+ .m_or =XTE_RXC1_RXVLAN_MASK,
+ },
+ /* Turn on FCS stripping on receive packets */
+ {
+ .opt = XTE_OPTION_FCS_STRIP,
+ .reg = XTE_RXC1_OFFSET,
+ .m_or =XTE_RXC1_RXFCS_MASK,
+ },
+ /* Turn on FCS insertion on transmit packets */
+ {
+ .opt = XTE_OPTION_FCS_INSERT,
+ .reg = XTE_TXC_OFFSET,
+ .m_or =XTE_TXC_TXFCS_MASK,
+ },
+ /* Turn on length/type field checking on receive packets */
+ {
+ .opt = XTE_OPTION_LENTYPE_ERR,
+ .reg = XTE_RXC1_OFFSET,
+ .m_or =XTE_RXC1_RXLT_MASK,
+ },
+ /* Turn on flow control */
+ {
+ .opt = XTE_OPTION_FLOW_CONTROL,
+ .reg = XTE_FCC_OFFSET,
+ .m_or =XTE_FCC_RXFLO_MASK,
+ },
+ /* Turn on flow control */
+ {
+ .opt = XTE_OPTION_FLOW_CONTROL,
+ .reg = XTE_FCC_OFFSET,
+ .m_or =XTE_FCC_TXFLO_MASK,
+ },
+ /* Turn on promiscuous frame filtering (all frames are received ) */
+ {
+ .opt = XTE_OPTION_PROMISC,
+ .reg = XTE_AFM_OFFSET,
+ .m_or =XTE_AFM_EPPRM_MASK,
+ },
+ /* Enable transmitter if not already enabled */
+ {
+ .opt = XTE_OPTION_TXEN,
+ .reg = XTE_TXC_OFFSET,
+ .m_or =XTE_TXC_TXEN_MASK,
+ },
+ /* Enable receiver? */
+ {
+ .opt = XTE_OPTION_RXEN,
+ .reg = XTE_RXC1_OFFSET,
+ .m_or =XTE_RXC1_RXEN_MASK,
+ },
+ {}
+};
+
+/**
+ * temac_setoptions
+ */
+static u32 temac_setoptions(struct net_device *ndev, u32 options)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ struct temac_option *tp = &temac_options[0];
+ int reg;
+
+ mutex_lock(&lp->indirect_mutex);
+ while (tp->opt) {
+ reg = temac_indirect_in32(lp, tp->reg) & ~tp->m_or;
+ if (options & tp->opt)
+ reg |= tp->m_or;
+ temac_indirect_out32(lp, tp->reg, reg);
+ tp++;
+ }
+ lp->options |= options;
+ mutex_unlock(&lp->indirect_mutex);
+
+ return (0);
+}
+
+/* Initilize temac */
+static void temac_device_reset(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ u32 timeout;
+ u32 val;
+
+ /* Perform a software reset */
+
+ /* 0x300 host enable bit ? */
+ /* reset PHY through control register ?:1 */
+
+ dev_dbg(&ndev->dev, "%s()\n", __func__);
+
+ mutex_lock(&lp->indirect_mutex);
+ /* Reset the receiver and wait for it to finish reset */
+ temac_indirect_out32(lp, XTE_RXC1_OFFSET, XTE_RXC1_RXRST_MASK);
+ timeout = 1000;
+ while (temac_indirect_in32(lp, XTE_RXC1_OFFSET) & XTE_RXC1_RXRST_MASK) {
+ udelay(1);
+ if (--timeout == 0) {
+ dev_err(&ndev->dev,
+ "temac_device_reset RX reset timeout!!\n");
+ break;
+ }
+ }
+
+ /* Reset the transmitter and wait for it to finish reset */
+ temac_indirect_out32(lp, XTE_TXC_OFFSET, XTE_TXC_TXRST_MASK);
+ timeout = 1000;
+ while (temac_indirect_in32(lp, XTE_TXC_OFFSET) & XTE_TXC_TXRST_MASK) {
+ udelay(1);
+ if (--timeout == 0) {
+ dev_err(&ndev->dev,
+ "temac_device_reset TX reset timeout!!\n");
+ break;
+ }
+ }
+
+ /* Disable the receiver */
+ val = temac_indirect_in32(lp, XTE_RXC1_OFFSET);
+ temac_indirect_out32(lp, XTE_RXC1_OFFSET, val & ~XTE_RXC1_RXEN_MASK);
+
+ /* Reset Local Link (DMA) */
+ temac_dma_out32(lp, DMA_CONTROL_REG, DMA_CONTROL_RST);
+ timeout = 1000;
+ while (temac_dma_in32(lp, DMA_CONTROL_REG) & DMA_CONTROL_RST) {
+ udelay(1);
+ if (--timeout == 0) {
+ dev_err(&ndev->dev,
+ "temac_device_reset DMA reset timeout!!\n");
+ break;
+ }
+ }
+ temac_dma_out32(lp, DMA_CONTROL_REG, DMA_TAIL_ENABLE);
+
+ temac_dma_bd_init(ndev);
+
+ temac_indirect_out32(lp, XTE_RXC0_OFFSET, 0);
+ temac_indirect_out32(lp, XTE_RXC1_OFFSET, 0);
+ temac_indirect_out32(lp, XTE_TXC_OFFSET, 0);
+ temac_indirect_out32(lp, XTE_FCC_OFFSET, XTE_FCC_RXFLO_MASK);
+
+ mutex_unlock(&lp->indirect_mutex);
+
+ /* Sync default options with HW
+ * but leave receiver and transmitter disabled. */
+ temac_setoptions(ndev,
+ lp->options & ~(XTE_OPTION_TXEN | XTE_OPTION_RXEN));
+
+ temac_set_mac_address(ndev, NULL);
+
+ /* Set address filter table */
+ temac_set_multicast_list(ndev);
+ if (temac_setoptions(ndev, lp->options))
+ dev_err(&ndev->dev, "Error setting TEMAC options\n");
+
+ /* Init Driver variable */
+ ndev->trans_start = 0;
+}
+
+void temac_adjust_link(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ struct phy_device *phy = lp->phy_dev;
+ u32 mii_speed;
+ int link_state;
+
+ /* hash together the state values to decide if something has changed */
+ link_state = phy->speed | (phy->duplex << 1) | phy->link;
+
+ mutex_lock(&lp->indirect_mutex);
+ if (lp->last_link != link_state) {
+ mii_speed = temac_indirect_in32(lp, XTE_EMCFG_OFFSET);
+ mii_speed &= ~XTE_EMCFG_LINKSPD_MASK;
+
+ switch (phy->speed) {
+ case SPEED_1000: mii_speed |= XTE_EMCFG_LINKSPD_1000; break;
+ case SPEED_100: mii_speed |= XTE_EMCFG_LINKSPD_100; break;
+ case SPEED_10: mii_speed |= XTE_EMCFG_LINKSPD_10; break;
+ }
+
+ /* Write new speed setting out to TEMAC */
+ temac_indirect_out32(lp, XTE_EMCFG_OFFSET, mii_speed);
+ lp->last_link = link_state;
+ phy_print_status(phy);
+ }
+ mutex_unlock(&lp->indirect_mutex);
+}
+
+static void temac_start_xmit_done(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ struct cdmac_bd *cur_p;
+ unsigned int stat = 0;
+
+ cur_p = &lp->tx_bd_v[lp->tx_bd_ci];
+ stat = cur_p->app0;
+
+ while (stat & STS_CTRL_APP0_CMPLT) {
+ dma_unmap_single(ndev->dev.parent, cur_p->phys, cur_p->len,
+ DMA_TO_DEVICE);
+ if (cur_p->app4)
+ dev_kfree_skb_irq((struct sk_buff *)cur_p->app4);
+ cur_p->app0 = 0;
+
+ ndev->stats.tx_packets++;
+ ndev->stats.tx_bytes += cur_p->len;
+
+ lp->tx_bd_ci++;
+ if (lp->tx_bd_ci >= TX_BD_NUM)
+ lp->tx_bd_ci = 0;
+
+ cur_p = &lp->tx_bd_v[lp->tx_bd_ci];
+ stat = cur_p->app0;
+ }
+
+ netif_wake_queue(ndev);
+}
+
+static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ struct cdmac_bd *cur_p;
+ dma_addr_t start_p, tail_p;
+ int ii;
+ unsigned long num_frag;
+ skb_frag_t *frag;
+
+ num_frag = skb_shinfo(skb)->nr_frags;
+ frag = &skb_shinfo(skb)->frags[0];
+ start_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail;
+ cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
+
+ if (cur_p->app0 & STS_CTRL_APP0_CMPLT) {
+ if (!netif_queue_stopped(ndev)) {
+ netif_stop_queue(ndev);
+ return NETDEV_TX_BUSY;
+ }
+ return NETDEV_TX_BUSY;
+ }
+
+ cur_p->app0 = 0;
+ if (skb->ip_summed == CHECKSUM_PARTIAL) {
+ const struct iphdr *ip = ip_hdr(skb);
+ int length = 0, start = 0, insert = 0;
+
+ switch (ip->protocol) {
+ case IPPROTO_TCP:
+ start = sizeof(struct iphdr) + ETH_HLEN;
+ insert = sizeof(struct iphdr) + ETH_HLEN + 16;
+ length = ip->tot_len - sizeof(struct iphdr);
+ break;
+ case IPPROTO_UDP:
+ start = sizeof(struct iphdr) + ETH_HLEN;
+ insert = sizeof(struct iphdr) + ETH_HLEN + 6;
+ length = ip->tot_len - sizeof(struct iphdr);
+ break;
+ default:
+ break;
+ }
+ cur_p->app1 = ((start << 16) | insert);
+ cur_p->app2 = csum_tcpudp_magic(ip->saddr, ip->daddr,
+ length, ip->protocol, 0);
+ skb->data[insert] = 0;
+ skb->data[insert + 1] = 0;
+ }
+ cur_p->app0 |= STS_CTRL_APP0_SOP;
+ cur_p->len = skb_headlen(skb);
+ cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, skb->len,
+ DMA_TO_DEVICE);
+ cur_p->app4 = (unsigned long)skb;
+
+ for (ii = 0; ii < num_frag; ii++) {
+ lp->tx_bd_tail++;
+ if (lp->tx_bd_tail >= TX_BD_NUM)
+ lp->tx_bd_tail = 0;
+
+ cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
+ cur_p->phys = dma_map_single(ndev->dev.parent,
+ (void *)page_address(frag->page) +
+ frag->page_offset,
+ frag->size, DMA_TO_DEVICE);
+ cur_p->len = frag->size;
+ cur_p->app0 = 0;
+ frag++;
+ }
+ cur_p->app0 |= STS_CTRL_APP0_EOP;
+
+ tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail;
+ lp->tx_bd_tail++;
+ if (lp->tx_bd_tail >= TX_BD_NUM)
+ lp->tx_bd_tail = 0;
+
+ /* Kick off the transfer */
+ temac_dma_out32(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
+
+ return 0;
+}
+
+
+static void ll_temac_recv(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ struct sk_buff *skb, *new_skb;
+ unsigned int bdstat;
+ struct cdmac_bd *cur_p;
+ dma_addr_t tail_p;
+ int length;
+ unsigned long skb_vaddr;
+ unsigned long flags;
+
+ spin_lock_irqsave(&lp->rx_lock, flags);
+
+ tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci;
+ cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
+
+ bdstat = cur_p->app0;
+ while ((bdstat & STS_CTRL_APP0_CMPLT)) {
+
+ skb = lp->rx_skb[lp->rx_bd_ci];
+ length = cur_p->app4;
+
+ skb_vaddr = virt_to_bus(skb->data);
+ dma_unmap_single(ndev->dev.parent, skb_vaddr, length,
+ DMA_FROM_DEVICE);
+
+ skb_put(skb, length);
+ skb->dev = ndev;
+ skb->protocol = eth_type_trans(skb, ndev);
+ skb->ip_summed = CHECKSUM_NONE;
+
+ netif_rx(skb);
+
+ ndev->stats.rx_packets++;
+ ndev->stats.rx_bytes += length;
+
+ new_skb = alloc_skb(XTE_MAX_JUMBO_FRAME_SIZE + XTE_ALIGN,
+ GFP_ATOMIC);
+ if (new_skb == 0) {
+ dev_err(&ndev->dev, "no memory for new sk_buff\n");
+ spin_unlock_irqrestore(&lp->rx_lock, flags);
+ return;
+ }
+
+ skb_reserve(new_skb, BUFFER_ALIGN(new_skb->data));
+
+ cur_p->app0 = STS_CTRL_APP0_IRQONEND;
+ cur_p->phys = dma_map_single(ndev->dev.parent, new_skb->data,
+ XTE_MAX_JUMBO_FRAME_SIZE,
+ DMA_FROM_DEVICE);
+ cur_p->len = XTE_MAX_JUMBO_FRAME_SIZE;
+ lp->rx_skb[lp->rx_bd_ci] = new_skb;
+
+ lp->rx_bd_ci++;
+ if (lp->rx_bd_ci >= RX_BD_NUM)
+ lp->rx_bd_ci = 0;
+
+ cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
+ bdstat = cur_p->app0;
+ }
+ temac_dma_out32(lp, RX_TAILDESC_PTR, tail_p);
+
+ spin_unlock_irqrestore(&lp->rx_lock, flags);
+}
+
+static irqreturn_t ll_temac_tx_irq(int irq, void *_ndev)
+{
+ struct net_device *ndev = _ndev;
+ struct temac_local *lp = netdev_priv(ndev);
+ unsigned int status;
+
+ status = temac_dma_in32(lp, TX_IRQ_REG);
+ temac_dma_out32(lp, TX_IRQ_REG, status);
+
+ if (status & (IRQ_COAL | IRQ_DLY))
+ temac_start_xmit_done(lp->ndev);
+ if (status & 0x080)
+ dev_err(&ndev->dev, "DMA error 0x%x\n", status);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t ll_temac_rx_irq(int irq, void *_ndev)
+{
+ struct net_device *ndev = _ndev;
+ struct temac_local *lp = netdev_priv(ndev);
+ unsigned int status;
+
+ /* Read and clear the status registers */
+ status = temac_dma_in32(lp, RX_IRQ_REG);
+ temac_dma_out32(lp, RX_IRQ_REG, status);
+
+ if (status & (IRQ_COAL | IRQ_DLY))
+ ll_temac_recv(lp->ndev);
+
+ return IRQ_HANDLED;
+}
+
+static int temac_open(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ int rc;
+
+ dev_dbg(&ndev->dev, "temac_open()\n");
+
+ if (lp->phy_node) {
+ lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
+ temac_adjust_link, 0, 0);
+ if (!lp->phy_dev) {
+ dev_err(lp->dev, "of_phy_connect() failed\n");
+ return -ENODEV;
+ }
+
+ phy_start(lp->phy_dev);
+ }
+
+ rc = request_irq(lp->tx_irq, ll_temac_tx_irq, 0, ndev->name, ndev);
+ if (rc)
+ goto err_tx_irq;
+ rc = request_irq(lp->rx_irq, ll_temac_rx_irq, 0, ndev->name, ndev);
+ if (rc)
+ goto err_rx_irq;
+
+ temac_device_reset(ndev);
+ return 0;
+
+ err_rx_irq:
+ free_irq(lp->tx_irq, ndev);
+ err_tx_irq:
+ if (lp->phy_dev)
+ phy_disconnect(lp->phy_dev);
+ lp->phy_dev = NULL;
+ dev_err(lp->dev, "request_irq() failed\n");
+ return rc;
+}
+
+static int temac_stop(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+
+ dev_dbg(&ndev->dev, "temac_close()\n");
+
+ free_irq(lp->tx_irq, ndev);
+ free_irq(lp->rx_irq, ndev);
+
+ if (lp->phy_dev)
+ phy_disconnect(lp->phy_dev);
+ lp->phy_dev = NULL;
+
+ return 0;
+}
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void
+temac_poll_controller(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+
+ disable_irq(lp->tx_irq);
+ disable_irq(lp->rx_irq);
+
+ ll_temac_rx_irq(lp->tx_irq, lp);
+ ll_temac_tx_irq(lp->rx_irq, lp);
+
+ enable_irq(lp->tx_irq);
+ enable_irq(lp->rx_irq);
+}
+#endif
+
+static const struct net_device_ops temac_netdev_ops = {
+ .ndo_open = temac_open,
+ .ndo_stop = temac_stop,
+ .ndo_start_xmit = temac_start_xmit,
+ .ndo_set_mac_address = temac_set_mac_address,
+ //.ndo_set_multicast_list = temac_set_multicast_list,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = temac_poll_controller,
+#endif
+};
+
+/* ---------------------------------------------------------------------
+ * SYSFS device attributes
+ */
+static ssize_t temac_show_llink_regs(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct net_device *ndev = dev_get_drvdata(dev);
+ struct temac_local *lp = netdev_priv(ndev);
+ int i, len = 0;
+
+ for (i = 0; i < 0x11; i++)
+ len += sprintf(buf + len, "%.8x%s", temac_dma_in32(lp, i),
+ (i % 8) == 7 ? "\n" : " ");
+ len += sprintf(buf + len, "\n");
+
+ return len;
+}
+
+static DEVICE_ATTR(llink_regs, 0440, temac_show_llink_regs, NULL);
+
+static struct attribute *temac_device_attrs[] = {
+ &dev_attr_llink_regs.attr,
+ NULL,
+};
+
+static const struct attribute_group temac_attr_group = {
+ .attrs = temac_device_attrs,
+};
+
+static int __init
+temac_of_probe(struct of_device *op, const struct of_device_id *match)
+{
+ struct device_node *np;
+ struct temac_local *lp;
+ struct net_device *ndev;
+ const void *addr;
+ int size, rc = 0;
+ unsigned int dcrs;
+
+ /* Init network device structure */
+ ndev = alloc_etherdev(sizeof(*lp));
+ if (!ndev) {
+ dev_err(&op->dev, "could not allocate device.\n");
+ return -ENOMEM;
+ }
+ ether_setup(ndev);
+ dev_set_drvdata(&op->dev, ndev);
+ SET_NETDEV_DEV(ndev, &op->dev);
+ ndev->flags &= ~IFF_MULTICAST; /* clear multicast */
+ ndev->features = NETIF_F_SG | NETIF_F_FRAGLIST;
+ ndev->netdev_ops = &temac_netdev_ops;
+#if 0
+ ndev->features |= NETIF_F_IP_CSUM; /* Can checksum TCP/UDP over IPv4. */
+ ndev->features |= NETIF_F_HW_CSUM; /* Can checksum all the packets. */
+ ndev->features |= NETIF_F_IPV6_CSUM; /* Can checksum IPV6 TCP/UDP */
+ ndev->features |= NETIF_F_HIGHDMA; /* Can DMA to high memory. */
+ ndev->features |= NETIF_F_HW_VLAN_TX; /* Transmit VLAN hw accel */
+ ndev->features |= NETIF_F_HW_VLAN_RX; /* Receive VLAN hw acceleration */
+ ndev->features |= NETIF_F_HW_VLAN_FILTER; /* Receive VLAN filtering */
+ ndev->features |= NETIF_F_VLAN_CHALLENGED; /* cannot handle VLAN pkts */
+ ndev->features |= NETIF_F_GSO; /* Enable software GSO. */
+ ndev->features |= NETIF_F_MULTI_QUEUE; /* Has multiple TX/RX queues */
+ ndev->features |= NETIF_F_LRO; /* large receive offload */
+#endif
+
+ /* setup temac private info structure */
+ lp = netdev_priv(ndev);
+ lp->ndev = ndev;
+ lp->dev = &op->dev;
+ lp->options = XTE_OPTION_DEFAULTS;
+ spin_lock_init(&lp->rx_lock);
+ mutex_init(&lp->indirect_mutex);
+
+ /* map device registers */
+ lp->regs = of_iomap(op->node, 0);
+ if (!lp->regs) {
+ dev_err(&op->dev, "could not map temac regs.\n");
+ goto nodev;
+ }
+
+ /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
+ np = of_parse_phandle(op->node, "llink-connected", 0);
+ if (!np) {
+ dev_err(&op->dev, "could not find DMA node\n");
+ goto nodev;
+ }
+
+ dcrs = dcr_resource_start(np, 0);
+ if (dcrs == 0) {
+ dev_err(&op->dev, "could not get DMA register address\n");
+ goto nodev;;
+ }
+ lp->sdma_dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0));
+ dev_dbg(&op->dev, "DCR base: %x\n", dcrs);
+
+ lp->rx_irq = irq_of_parse_and_map(np, 0);
+ lp->tx_irq = irq_of_parse_and_map(np, 1);
+ if (!lp->rx_irq || !lp->tx_irq) {
+ dev_err(&op->dev, "could not determine irqs\n");
+ rc = -ENOMEM;
+ goto nodev;
+ }
+
+ of_node_put(np); /* Finished with the DMA node; drop the reference */
+
+ /* Retrieve the MAC address */
+ addr = of_get_property(op->node, "local-mac-address", &size);
+ if ((!addr) || (size != 6)) {
+ dev_err(&op->dev, "could not find MAC address\n");
+ rc = -ENODEV;
+ goto nodev;
+ }
+ temac_set_mac_address(ndev, (void *)addr);
+
+ rc = temac_mdio_setup(lp, op->node);
+ if (rc)
+ dev_warn(&op->dev, "error registering MDIO bus\n");
+
+ lp->phy_node = of_parse_phandle(op->node, "phy-handle", 0);
+ if (lp->phy_node)
+ dev_dbg(lp->dev, "using PHY node %s (%p)\n", np->full_name, np);
+
+ /* Add the device attributes */
+ rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group);
+ if (rc) {
+ dev_err(lp->dev, "Error creating sysfs files\n");
+ goto nodev;
+ }
+
+ rc = register_netdev(lp->ndev);
+ if (rc) {
+ dev_err(lp->dev, "register_netdev() error (%i)\n", rc);
+ goto err_register_ndev;
+ }
+
+ return 0;
+
+ err_register_ndev:
+ sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
+ nodev:
+ free_netdev(ndev);
+ ndev = NULL;
+ return rc;
+}
+
+static int __devexit temac_of_remove(struct of_device *op)
+{
+ struct net_device *ndev = dev_get_drvdata(&op->dev);
+ struct temac_local *lp = netdev_priv(ndev);
+
+ temac_mdio_teardown(lp);
+ unregister_netdev(ndev);
+ sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
+ if (lp->phy_node)
+ of_node_put(lp->phy_node);
+ lp->phy_node = NULL;
+ dev_set_drvdata(&op->dev, NULL);
+ free_netdev(ndev);
+ return 0;
+}
+
+static struct of_device_id temac_of_match[] __devinitdata = {
+ { .compatible = "xlnx,xps-ll-temac-1.01.b", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, temac_of_match);
+
+static struct of_platform_driver temac_of_driver = {
+ .match_table = temac_of_match,
+ .probe = temac_of_probe,
+ .remove = __devexit_p(temac_of_remove),
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "xilinx_temac",
+ },
+};
+
+static int __init temac_init(void)
+{
+ return of_register_platform_driver(&temac_of_driver);
+}
+module_init(temac_init);
+
+static void __exit temac_exit(void)
+{
+ of_unregister_platform_driver(&temac_of_driver);
+}
+module_exit(temac_exit);
+
+MODULE_DESCRIPTION("Xilinx LL_TEMAC Ethernet driver");
+MODULE_AUTHOR("Yoshio Kashiwagi");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/ll_temac_mdio.c b/drivers/net/ll_temac_mdio.c
new file mode 100644
index 000000000000..da0e462308d5
--- /dev/null
+++ b/drivers/net/ll_temac_mdio.c
@@ -0,0 +1,120 @@
+/*
+ * MDIO bus driver for the Xilinx TEMAC device
+ *
+ * Copyright (c) 2009 Secret Lab Technologies, Ltd.
+ */
+
+#include <linux/io.h>
+#include <linux/netdevice.h>
+#include <linux/mutex.h>
+#include <linux/phy.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_mdio.h>
+
+#include "ll_temac.h"
+
+/* ---------------------------------------------------------------------
+ * MDIO Bus functions
+ */
+static int temac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
+{
+ struct temac_local *lp = bus->priv;
+ u32 rc;
+
+ /* Write the PHY address to the MIIM Access Initiator register.
+ * When the transfer completes, the PHY register value will appear
+ * in the LSW0 register */
+ mutex_lock(&lp->indirect_mutex);
+ temac_iow(lp, XTE_LSW0_OFFSET, (phy_id << 5) | reg);
+ rc = temac_indirect_in32(lp, XTE_MIIMAI_OFFSET);
+ mutex_unlock(&lp->indirect_mutex);
+
+ dev_dbg(lp->dev, "temac_mdio_read(phy_id=%i, reg=%x) == %x\n",
+ phy_id, reg, rc);
+
+ return rc;
+}
+
+static int temac_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
+{
+ struct temac_local *lp = bus->priv;
+
+ dev_dbg(lp->dev, "temac_mdio_write(phy_id=%i, reg=%x, val=%x)\n",
+ phy_id, reg, val);
+
+ /* First write the desired value into the write data register
+ * and then write the address into the access initiator register
+ */
+ mutex_lock(&lp->indirect_mutex);
+ temac_indirect_out32(lp, XTE_MGTDR_OFFSET, val);
+ temac_indirect_out32(lp, XTE_MIIMAI_OFFSET, (phy_id << 5) | reg);
+ mutex_unlock(&lp->indirect_mutex);
+
+ return 0;
+}
+
+int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
+{
+ struct mii_bus *bus;
+ const u32 *bus_hz;
+ int clk_div;
+ int rc, size;
+ struct resource res;
+
+ /* Calculate a reasonable divisor for the clock rate */
+ clk_div = 0x3f; /* worst-case default setting */
+ bus_hz = of_get_property(np, "clock-frequency", &size);
+ if (bus_hz && size >= sizeof(*bus_hz)) {
+ clk_div = (*bus_hz) / (2500 * 1000 * 2) - 1;
+ if (clk_div < 1)
+ clk_div = 1;
+ if (clk_div > 0x3f)
+ clk_div = 0x3f;
+ }
+
+ /* Enable the MDIO bus by asserting the enable bit and writing
+ * in the clock config */
+ mutex_lock(&lp->indirect_mutex);
+ temac_indirect_out32(lp, XTE_MC_OFFSET, 1 << 6 | clk_div);
+ mutex_unlock(&lp->indirect_mutex);
+
+ bus = mdiobus_alloc();
+ if (!bus)
+ return -ENOMEM;
+
+ of_address_to_resource(np, 0, &res);
+ snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
+ (unsigned long long)res.start);
+ bus->priv = lp;
+ bus->name = "Xilinx TEMAC MDIO";
+ bus->read = temac_mdio_read;
+ bus->write = temac_mdio_write;
+ bus->parent = lp->dev;
+ bus->irq = lp->mdio_irqs; /* preallocated IRQ table */
+
+ lp->mii_bus = bus;
+
+ rc = of_mdiobus_register(bus, np);
+ if (rc)
+ goto err_register;
+
+ mutex_lock(&lp->indirect_mutex);
+ dev_dbg(lp->dev, "MDIO bus registered; MC:%x\n",
+ temac_indirect_in32(lp, XTE_MC_OFFSET));
+ mutex_unlock(&lp->indirect_mutex);
+ return 0;
+
+ err_register:
+ mdiobus_free(bus);
+ return rc;
+}
+
+void temac_mdio_teardown(struct temac_local *lp)
+{
+ mdiobus_unregister(lp->mii_bus);
+ kfree(lp->mii_bus->irq);
+ mdiobus_free(lp->mii_bus);
+ lp->mii_bus = NULL;
+}
+
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index b7d438a367f3..da472c687481 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -62,6 +62,7 @@
struct pcpu_lstats {
unsigned long packets;
unsigned long bytes;
+ unsigned long drops;
};
/*
@@ -71,18 +72,22 @@ struct pcpu_lstats {
static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct pcpu_lstats *pcpu_lstats, *lb_stats;
+ int len;
skb_orphan(skb);
- skb->protocol = eth_type_trans(skb,dev);
+ skb->protocol = eth_type_trans(skb, dev);
/* it's OK to use per_cpu_ptr() because BHs are off */
pcpu_lstats = dev->ml_priv;
lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
- lb_stats->bytes += skb->len;
- lb_stats->packets++;
- netif_rx(skb);
+ len = skb->len;
+ if (likely(netif_rx(skb) == NET_RX_SUCCESS)) {
+ lb_stats->bytes += len;
+ lb_stats->packets++;
+ } else
+ lb_stats->drops++;
return 0;
}
@@ -93,6 +98,7 @@ static struct net_device_stats *loopback_get_stats(struct net_device *dev)
struct net_device_stats *stats = &dev->stats;
unsigned long bytes = 0;
unsigned long packets = 0;
+ unsigned long drops = 0;
int i;
pcpu_lstats = dev->ml_priv;
@@ -102,11 +108,14 @@ static struct net_device_stats *loopback_get_stats(struct net_device *dev)
lb_stats = per_cpu_ptr(pcpu_lstats, i);
bytes += lb_stats->bytes;
packets += lb_stats->packets;
+ drops += lb_stats->drops;
}
stats->rx_packets = packets;
stats->tx_packets = packets;
- stats->rx_bytes = bytes;
- stats->tx_bytes = bytes;
+ stats->rx_dropped = drops;
+ stats->rx_errors = drops;
+ stats->rx_bytes = bytes;
+ stats->tx_bytes = bytes;
return stats;
}
@@ -161,6 +170,7 @@ static void loopback_setup(struct net_device *dev)
dev->tx_queue_len = 0;
dev->type = ARPHRD_LOOPBACK; /* 0x0001*/
dev->flags = IFF_LOOPBACK;
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
dev->features = NETIF_F_SG | NETIF_F_FRAGLIST
| NETIF_F_TSO
| NETIF_F_NO_CSUM
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index 8e884869a05b..f26667d5eaae 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -304,7 +304,7 @@ struct net_device * __init mac8390_probe(int unit)
if (!MACH_IS_MAC)
return ERR_PTR(-ENODEV);
- dev = alloc_ei_netdev();
+ dev = ____alloc_ei_netdev(0);
if (!dev)
return ERR_PTR(-ENOMEM);
@@ -481,10 +481,10 @@ void cleanup_module(void)
static const struct net_device_ops mac8390_netdev_ops = {
.ndo_open = mac8390_open,
.ndo_stop = mac8390_close,
- .ndo_start_xmit = ei_start_xmit,
- .ndo_tx_timeout = ei_tx_timeout,
- .ndo_get_stats = ei_get_stats,
- .ndo_set_multicast_list = ei_set_multicast_list,
+ .ndo_start_xmit = __ei_start_xmit,
+ .ndo_tx_timeout = __ei_tx_timeout,
+ .ndo_get_stats = __ei_get_stats,
+ .ndo_set_multicast_list = __ei_set_multicast_list,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = eth_change_mtu,
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index 384e072de2e7..e24175a39460 100644
--- a/drivers/net/mac89x0.c
+++ b/drivers/net/mac89x0.c
@@ -73,8 +73,6 @@ static char *version =
or override something. */
#include <linux/module.h>
-#define PRINTK(x) printk x
-
/*
Sources:
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index e82aee41d77e..722265920da8 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -599,6 +599,21 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/*
+ * Polling receive - used by netconsole and other diagnostic tools
+ * to allow network i/o with interrupts disabled.
+ */
+static void macb_poll_controller(struct net_device *dev)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ macb_interrupt(dev->irq, dev);
+ local_irq_restore(flags);
+}
+#endif
+
static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct macb *bp = netdev_priv(dev);
@@ -1094,6 +1109,9 @@ static const struct net_device_ops macb_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = eth_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = macb_poll_controller,
+#endif
};
static int __init macb_probe(struct platform_device *pdev)
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index feebbd92aff2..1ad740bc8878 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -94,6 +94,16 @@ static void __mace_set_address(struct net_device *dev, void *addr);
*/
static unsigned char *dummy_buf;
+static const struct net_device_ops mace_netdev_ops = {
+ .ndo_open = mace_open,
+ .ndo_stop = mace_close,
+ .ndo_start_xmit = mace_xmit_start,
+ .ndo_set_multicast_list = mace_set_multicast,
+ .ndo_set_mac_address = mace_set_address,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_id *match)
{
struct device_node *mace = macio_get_of_node(mdev);
@@ -207,11 +217,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
}
}
- dev->open = mace_open;
- dev->stop = mace_close;
- dev->hard_start_xmit = mace_xmit_start;
- dev->set_multicast_list = mace_set_multicast;
- dev->set_mac_address = mace_set_address;
+ dev->netdev_ops = &mace_netdev_ops;
/*
* Most of what is below could be moved to mace_open()
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 274e99bb63ac..44f3c2896f20 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -180,6 +180,17 @@ static void mace_dma_off(struct net_device *dev)
psc_write_word(PSC_ENETWR_CMD + PSC_SET1, 0x1100);
}
+static const struct net_device_ops mace_netdev_ops = {
+ .ndo_open = mace_open,
+ .ndo_stop = mace_close,
+ .ndo_start_xmit = mace_xmit_start,
+ .ndo_tx_timeout = mace_tx_timeout,
+ .ndo_set_multicast_list = mace_set_multicast,
+ .ndo_set_mac_address = mace_set_address,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
/*
* Not really much of a probe. The hardware table tells us if this
* model of Macintrash has a MACE (AV macintoshes)
@@ -240,13 +251,8 @@ static int __devinit mace_probe(struct platform_device *pdev)
return -ENODEV;
}
- dev->open = mace_open;
- dev->stop = mace_close;
- dev->hard_start_xmit = mace_xmit_start;
- dev->tx_timeout = mace_tx_timeout;
+ dev->netdev_ops = &mace_netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
- dev->set_multicast_list = mace_set_multicast;
- dev->set_mac_address = mace_set_address;
printk(KERN_INFO "%s: 68K MACE, hardware address %pM\n",
dev->name, dev->dev_addr);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 214a8cf2b708..d5334b41e4b4 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -374,36 +374,20 @@ static void macvlan_ethtool_get_drvinfo(struct net_device *dev,
static u32 macvlan_ethtool_get_rx_csum(struct net_device *dev)
{
const struct macvlan_dev *vlan = netdev_priv(dev);
- struct net_device *lowerdev = vlan->lowerdev;
-
- if (lowerdev->ethtool_ops == NULL ||
- lowerdev->ethtool_ops->get_rx_csum == NULL)
- return 0;
- return lowerdev->ethtool_ops->get_rx_csum(lowerdev);
+ return dev_ethtool_get_rx_csum(vlan->lowerdev);
}
static int macvlan_ethtool_get_settings(struct net_device *dev,
struct ethtool_cmd *cmd)
{
const struct macvlan_dev *vlan = netdev_priv(dev);
- struct net_device *lowerdev = vlan->lowerdev;
-
- if (!lowerdev->ethtool_ops ||
- !lowerdev->ethtool_ops->get_settings)
- return -EOPNOTSUPP;
-
- return lowerdev->ethtool_ops->get_settings(lowerdev, cmd);
+ return dev_ethtool_get_settings(vlan->lowerdev, cmd);
}
static u32 macvlan_ethtool_get_flags(struct net_device *dev)
{
const struct macvlan_dev *vlan = netdev_priv(dev);
- struct net_device *lowerdev = vlan->lowerdev;
-
- if (!lowerdev->ethtool_ops ||
- !lowerdev->ethtool_ops->get_flags)
- return 0;
- return lowerdev->ethtool_ops->get_flags(lowerdev);
+ return dev_ethtool_get_flags(vlan->lowerdev);
}
static const struct ethtool_ops macvlan_ethtool_ops = {
@@ -430,6 +414,7 @@ static void macvlan_setup(struct net_device *dev)
{
ether_setup(dev);
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
dev->netdev_ops = &macvlan_netdev_ops;
dev->destructor = free_netdev;
dev->header_ops = &macvlan_hard_header_ops,
diff --git a/drivers/net/mdio.c b/drivers/net/mdio.c
new file mode 100644
index 000000000000..66483035f683
--- /dev/null
+++ b/drivers/net/mdio.c
@@ -0,0 +1,414 @@
+/*
+ * mdio.c: Generic support for MDIO-compatible transceivers
+ * Copyright 2006-2009 Solarflare Communications Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation, incorporated herein by reference.
+ */
+
+#include <linux/kernel.h>
+#include <linux/capability.h>
+#include <linux/errno.h>
+#include <linux/ethtool.h>
+#include <linux/mdio.h>
+#include <linux/module.h>
+
+/**
+ * mdio45_probe - probe for an MDIO (clause 45) device
+ * @mdio: MDIO interface
+ * @prtad: Expected PHY address
+ *
+ * This sets @prtad and @mmds in the MDIO interface if successful.
+ * Returns 0 on success, negative on error.
+ */
+int mdio45_probe(struct mdio_if_info *mdio, int prtad)
+{
+ int mmd, stat2, devs1, devs2;
+
+ /* Assume PHY must have at least one of PMA/PMD, WIS, PCS, PHY
+ * XS or DTE XS; give up if none is present. */
+ for (mmd = 1; mmd <= 5; mmd++) {
+ /* Is this MMD present? */
+ stat2 = mdio->mdio_read(mdio->dev, prtad, mmd, MDIO_STAT2);
+ if (stat2 < 0 ||
+ (stat2 & MDIO_STAT2_DEVPRST) != MDIO_STAT2_DEVPRST_VAL)
+ continue;
+
+ /* It should tell us about all the other MMDs */
+ devs1 = mdio->mdio_read(mdio->dev, prtad, mmd, MDIO_DEVS1);
+ devs2 = mdio->mdio_read(mdio->dev, prtad, mmd, MDIO_DEVS2);
+ if (devs1 < 0 || devs2 < 0)
+ continue;
+
+ mdio->prtad = prtad;
+ mdio->mmds = devs1 | (devs2 << 16);
+ return 0;
+ }
+
+ return -ENODEV;
+}
+EXPORT_SYMBOL(mdio45_probe);
+
+/**
+ * mdio_set_flag - set or clear flag in an MDIO register
+ * @mdio: MDIO interface
+ * @prtad: PHY address
+ * @devad: MMD address
+ * @addr: Register address
+ * @mask: Mask for flag (single bit set)
+ * @sense: New value of flag
+ *
+ * This debounces changes: it does not write the register if the flag
+ * already has the proper value. Returns 0 on success, negative on error.
+ */
+int mdio_set_flag(const struct mdio_if_info *mdio,
+ int prtad, int devad, u16 addr, int mask,
+ bool sense)
+{
+ int old_val = mdio->mdio_read(mdio->dev, prtad, devad, addr);
+ int new_val;
+
+ if (old_val < 0)
+ return old_val;
+ if (sense)
+ new_val = old_val | mask;
+ else
+ new_val = old_val & ~mask;
+ if (old_val == new_val)
+ return 0;
+ return mdio->mdio_write(mdio->dev, prtad, devad, addr, new_val);
+}
+EXPORT_SYMBOL(mdio_set_flag);
+
+/**
+ * mdio_link_ok - is link status up/OK
+ * @mdio: MDIO interface
+ * @mmd_mask: Mask for MMDs to check
+ *
+ * Returns 1 if the PHY reports link status up/OK, 0 otherwise.
+ * @mmd_mask is normally @mdio->mmds, but if loopback is enabled
+ * the MMDs being bypassed should be excluded from the mask.
+ */
+int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmd_mask)
+{
+ int devad, reg;
+
+ if (!mmd_mask) {
+ /* Use absence of XGMII faults in lieu of link state */
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad,
+ MDIO_MMD_PHYXS, MDIO_STAT2);
+ return reg >= 0 && !(reg & MDIO_STAT2_RXFAULT);
+ }
+
+ for (devad = 0; mmd_mask; devad++) {
+ if (mmd_mask & (1 << devad)) {
+ mmd_mask &= ~(1 << devad);
+
+ /* Read twice because link state is latched and a
+ * read moves the current state into the register */
+ mdio->mdio_read(mdio->dev, mdio->prtad,
+ devad, MDIO_STAT1);
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad,
+ devad, MDIO_STAT1);
+ if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
+ return false;
+ }
+ }
+
+ return true;
+}
+EXPORT_SYMBOL(mdio45_links_ok);
+
+/**
+ * mdio45_nway_restart - restart auto-negotiation for this interface
+ * @mdio: MDIO interface
+ *
+ * Returns 0 on success, negative on error.
+ */
+int mdio45_nway_restart(const struct mdio_if_info *mdio)
+{
+ if (!(mdio->mmds & MDIO_DEVS_AN))
+ return -EOPNOTSUPP;
+
+ mdio_set_flag(mdio, mdio->prtad, MDIO_MMD_AN, MDIO_CTRL1,
+ MDIO_AN_CTRL1_RESTART, true);
+ return 0;
+}
+EXPORT_SYMBOL(mdio45_nway_restart);
+
+static u32 mdio45_get_an(const struct mdio_if_info *mdio, u16 addr)
+{
+ u32 result = 0;
+ int reg;
+
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN, addr);
+ if (reg & ADVERTISE_10HALF)
+ result |= ADVERTISED_10baseT_Half;
+ if (reg & ADVERTISE_10FULL)
+ result |= ADVERTISED_10baseT_Full;
+ if (reg & ADVERTISE_100HALF)
+ result |= ADVERTISED_100baseT_Half;
+ if (reg & ADVERTISE_100FULL)
+ result |= ADVERTISED_100baseT_Full;
+ return result;
+}
+
+/**
+ * mdio45_ethtool_gset_npage - get settings for ETHTOOL_GSET
+ * @mdio: MDIO interface
+ * @ecmd: Ethtool request structure
+ * @npage_adv: Modes currently advertised on next pages
+ * @npage_lpa: Modes advertised by link partner on next pages
+ *
+ * Since the CSRs for auto-negotiation using next pages are not fully
+ * standardised, this function does not attempt to decode them. The
+ * caller must pass them in.
+ */
+void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
+ struct ethtool_cmd *ecmd,
+ u32 npage_adv, u32 npage_lpa)
+{
+ int reg;
+
+ ecmd->transceiver = XCVR_INTERNAL;
+ ecmd->phy_address = mdio->prtad;
+ ecmd->mdio_support =
+ mdio->mode_support & (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22);
+
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
+ MDIO_CTRL2);
+ switch (reg & MDIO_PMA_CTRL2_TYPE) {
+ case MDIO_PMA_CTRL2_10GBT:
+ case MDIO_PMA_CTRL2_1000BT:
+ case MDIO_PMA_CTRL2_100BTX:
+ case MDIO_PMA_CTRL2_10BT:
+ ecmd->port = PORT_TP;
+ ecmd->supported = SUPPORTED_TP;
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
+ MDIO_SPEED);
+ if (reg & MDIO_SPEED_10G)
+ ecmd->supported |= SUPPORTED_10000baseT_Full;
+ if (reg & MDIO_PMA_SPEED_1000)
+ ecmd->supported |= (SUPPORTED_1000baseT_Full |
+ SUPPORTED_1000baseT_Half);
+ if (reg & MDIO_PMA_SPEED_100)
+ ecmd->supported |= (SUPPORTED_100baseT_Full |
+ SUPPORTED_100baseT_Half);
+ if (reg & MDIO_PMA_SPEED_10)
+ ecmd->supported |= (SUPPORTED_10baseT_Full |
+ SUPPORTED_10baseT_Half);
+ ecmd->advertising = ADVERTISED_TP;
+ break;
+
+ case MDIO_PMA_CTRL2_10GBCX4:
+ ecmd->port = PORT_OTHER;
+ ecmd->supported = 0;
+ ecmd->advertising = 0;
+ break;
+
+ case MDIO_PMA_CTRL2_10GBKX4:
+ case MDIO_PMA_CTRL2_10GBKR:
+ case MDIO_PMA_CTRL2_1000BKX:
+ ecmd->port = PORT_OTHER;
+ ecmd->supported = SUPPORTED_Backplane;
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
+ MDIO_PMA_EXTABLE);
+ if (reg & MDIO_PMA_EXTABLE_10GBKX4)
+ ecmd->supported |= SUPPORTED_10000baseKX4_Full;
+ if (reg & MDIO_PMA_EXTABLE_10GBKR)
+ ecmd->supported |= SUPPORTED_10000baseKR_Full;
+ if (reg & MDIO_PMA_EXTABLE_1000BKX)
+ ecmd->supported |= SUPPORTED_1000baseKX_Full;
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
+ MDIO_PMA_10GBR_FECABLE);
+ if (reg & MDIO_PMA_10GBR_FECABLE_ABLE)
+ ecmd->supported |= SUPPORTED_10000baseR_FEC;
+ ecmd->advertising = ADVERTISED_Backplane;
+ break;
+
+ /* All the other defined modes are flavours of optical */
+ default:
+ ecmd->port = PORT_FIBRE;
+ ecmd->supported = SUPPORTED_FIBRE;
+ ecmd->advertising = ADVERTISED_FIBRE;
+ break;
+ }
+
+ if (mdio->mmds & MDIO_DEVS_AN) {
+ ecmd->supported |= SUPPORTED_Autoneg;
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN,
+ MDIO_CTRL1);
+ if (reg & MDIO_AN_CTRL1_ENABLE) {
+ ecmd->autoneg = AUTONEG_ENABLE;
+ ecmd->advertising |=
+ ADVERTISED_Autoneg |
+ mdio45_get_an(mdio, MDIO_AN_ADVERTISE) |
+ npage_adv;
+ } else {
+ ecmd->autoneg = AUTONEG_DISABLE;
+ }
+ } else {
+ ecmd->autoneg = AUTONEG_DISABLE;
+ }
+
+ if (ecmd->autoneg) {
+ u32 modes = 0;
+ int an_stat = mdio->mdio_read(mdio->dev, mdio->prtad,
+ MDIO_MMD_AN, MDIO_STAT1);
+
+ /* If AN is complete and successful, report best common
+ * mode, otherwise report best advertised mode. */
+ if (an_stat & MDIO_AN_STAT1_COMPLETE) {
+ ecmd->lp_advertising =
+ mdio45_get_an(mdio, MDIO_AN_LPA) | npage_lpa;
+ if (an_stat & MDIO_AN_STAT1_LPABLE)
+ ecmd->lp_advertising |= ADVERTISED_Autoneg;
+ modes = ecmd->advertising & ecmd->lp_advertising;
+ }
+ if ((modes & ~ADVERTISED_Autoneg) == 0)
+ modes = ecmd->advertising;
+
+ if (modes & (ADVERTISED_10000baseT_Full |
+ ADVERTISED_10000baseKX4_Full |
+ ADVERTISED_10000baseKR_Full)) {
+ ecmd->speed = SPEED_10000;
+ ecmd->duplex = DUPLEX_FULL;
+ } else if (modes & (ADVERTISED_1000baseT_Full |
+ ADVERTISED_1000baseT_Half |
+ ADVERTISED_1000baseKX_Full)) {
+ ecmd->speed = SPEED_1000;
+ ecmd->duplex = !(modes & ADVERTISED_1000baseT_Half);
+ } else if (modes & (ADVERTISED_100baseT_Full |
+ ADVERTISED_100baseT_Half)) {
+ ecmd->speed = SPEED_100;
+ ecmd->duplex = !!(modes & ADVERTISED_100baseT_Full);
+ } else {
+ ecmd->speed = SPEED_10;
+ ecmd->duplex = !!(modes & ADVERTISED_10baseT_Full);
+ }
+ } else {
+ /* Report forced settings */
+ reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
+ MDIO_CTRL1);
+ ecmd->speed = (((reg & MDIO_PMA_CTRL1_SPEED1000) ? 100 : 1) *
+ ((reg & MDIO_PMA_CTRL1_SPEED100) ? 100 : 10));
+ ecmd->duplex = (reg & MDIO_CTRL1_FULLDPLX ||
+ ecmd->speed == SPEED_10000);
+ }
+}
+EXPORT_SYMBOL(mdio45_ethtool_gset_npage);
+
+/**
+ * mdio45_ethtool_spauseparam_an - set auto-negotiated pause parameters
+ * @mdio: MDIO interface
+ * @ecmd: Ethtool request structure
+ *
+ * This function assumes that the PHY has an auto-negotiation MMD. It
+ * will enable and disable advertising of flow control as appropriate.
+ */
+void mdio45_ethtool_spauseparam_an(const struct mdio_if_info *mdio,
+ const struct ethtool_pauseparam *ecmd)
+{
+ int adv, old_adv;
+
+ WARN_ON(!(mdio->mmds & MDIO_DEVS_AN));
+
+ old_adv = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN,
+ MDIO_AN_ADVERTISE);
+ adv = old_adv & ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
+ if (ecmd->autoneg)
+ adv |= mii_advertise_flowctrl(
+ (ecmd->rx_pause ? FLOW_CTRL_RX : 0) |
+ (ecmd->tx_pause ? FLOW_CTRL_TX : 0));
+ if (adv != old_adv) {
+ mdio->mdio_write(mdio->dev, mdio->prtad, MDIO_MMD_AN,
+ MDIO_AN_ADVERTISE, adv);
+ mdio45_nway_restart(mdio);
+ }
+}
+EXPORT_SYMBOL(mdio45_ethtool_spauseparam_an);
+
+/**
+ * mdio_mii_ioctl - MII ioctl interface for MDIO (clause 22 or 45) PHYs
+ * @mdio: MDIO interface
+ * @mii_data: MII ioctl data structure
+ * @cmd: MII ioctl command
+ *
+ * Returns 0 on success, negative on error.
+ */
+int mdio_mii_ioctl(const struct mdio_if_info *mdio,
+ struct mii_ioctl_data *mii_data, int cmd)
+{
+ int prtad, devad;
+ u16 addr = mii_data->reg_num;
+
+ /* Validate/convert cmd to one of SIOC{G,S}MIIREG */
+ switch (cmd) {
+ case SIOCGMIIPHY:
+ if (mdio->prtad == MDIO_PRTAD_NONE)
+ return -EOPNOTSUPP;
+ mii_data->phy_id = mdio->prtad;
+ cmd = SIOCGMIIREG;
+ break;
+ case SIOCGMIIREG:
+ break;
+ case SIOCSMIIREG:
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ /* Validate/convert phy_id */
+ if ((mdio->mode_support & MDIO_SUPPORTS_C45) &&
+ mdio_phy_id_is_c45(mii_data->phy_id)) {
+ prtad = mdio_phy_id_prtad(mii_data->phy_id);
+ devad = mdio_phy_id_devad(mii_data->phy_id);
+ } else if ((mdio->mode_support & MDIO_SUPPORTS_C22) &&
+ mii_data->phy_id < 0x20) {
+ prtad = mii_data->phy_id;
+ devad = MDIO_DEVAD_NONE;
+ addr &= 0x1f;
+ } else if ((mdio->mode_support & MDIO_EMULATE_C22) &&
+ mdio->prtad != MDIO_PRTAD_NONE &&
+ mii_data->phy_id == mdio->prtad) {
+ /* Remap commonly-used MII registers. */
+ prtad = mdio->prtad;
+ switch (addr) {
+ case MII_BMCR:
+ case MII_BMSR:
+ case MII_PHYSID1:
+ case MII_PHYSID2:
+ devad = __ffs(mdio->mmds);
+ break;
+ case MII_ADVERTISE:
+ case MII_LPA:
+ if (!(mdio->mmds & MDIO_DEVS_AN))
+ return -EINVAL;
+ devad = MDIO_MMD_AN;
+ if (addr == MII_ADVERTISE)
+ addr = MDIO_AN_ADVERTISE;
+ else
+ addr = MDIO_AN_LPA;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ return -EINVAL;
+ }
+
+ if (cmd == SIOCGMIIREG) {
+ int rc = mdio->mdio_read(mdio->dev, prtad, devad, addr);
+ if (rc < 0)
+ return rc;
+ mii_data->val_out = rc;
+ return 0;
+ } else {
+ return mdio->mdio_write(mdio->dev, prtad, devad, addr,
+ mii_data->val_in);
+ }
+}
+EXPORT_SYMBOL(mdio_mii_ioctl);
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index dbd3436912b8..5d04d94f2a21 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -770,9 +770,17 @@ static int meth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
}
}
-/*
- * Return statistics to the caller
- */
+static const struct net_device_ops meth_netdev_ops = {
+ .ndo_open = meth_open,
+ .ndo_stop = meth_release,
+ .ndo_start_xmit = meth_tx,
+ .ndo_do_ioctl = meth_ioctl,
+ .ndo_tx_timeout = meth_tx_timeout,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
/*
* The init function.
*/
@@ -786,16 +794,10 @@ static int __init meth_probe(struct platform_device *pdev)
if (!dev)
return -ENOMEM;
- dev->open = meth_open;
- dev->stop = meth_release;
- dev->hard_start_xmit = meth_tx;
- dev->do_ioctl = meth_ioctl;
-#ifdef HAVE_TX_TIMEOUT
- dev->tx_timeout = meth_tx_timeout;
- dev->watchdog_timeo = timeout;
-#endif
- dev->irq = MACE_ETHERNET_IRQ;
- dev->base_addr = (unsigned long)&mace->eth;
+ dev->netdev_ops = &meth_netdev_ops;
+ dev->watchdog_timeo = timeout;
+ dev->irq = MACE_ETHERNET_IRQ;
+ dev->base_addr = (unsigned long)&mace->eth;
memcpy(dev->dev_addr, o2meth_eaddr, 6);
priv = netdev_priv(dev);
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index 92056051f269..d81a5d22a3a9 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -31,7 +31,27 @@
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
-#include <linux/mii.h>
+#include <linux/mdio.h>
+
+static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
+{
+ u32 result = 0;
+ int advert;
+
+ advert = mii->mdio_read(mii->dev, mii->phy_id, addr);
+ if (advert & LPA_LPACK)
+ result |= ADVERTISED_Autoneg;
+ if (advert & ADVERTISE_10HALF)
+ result |= ADVERTISED_10baseT_Half;
+ if (advert & ADVERTISE_10FULL)
+ result |= ADVERTISED_10baseT_Full;
+ if (advert & ADVERTISE_100HALF)
+ result |= ADVERTISED_100baseT_Half;
+ if (advert & ADVERTISE_100FULL)
+ result |= ADVERTISED_100baseT_Full;
+
+ return result;
+}
/**
* mii_ethtool_gset - get settings that are specified in @ecmd
@@ -43,8 +63,8 @@
int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
{
struct net_device *dev = mii->dev;
- u32 advert, bmcr, lpa, nego;
- u32 advert2 = 0, bmcr2 = 0, lpa2 = 0;
+ u16 bmcr, bmsr, ctrl1000 = 0, stat1000 = 0;
+ u32 nego;
ecmd->supported =
(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
@@ -62,50 +82,51 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
/* this isn't fully supported at higher layers */
ecmd->phy_address = mii->phy_id;
+ ecmd->mdio_support = MDIO_SUPPORTS_C22;
ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII;
- advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
- if (mii->supports_gmii)
- advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
-
- if (advert & ADVERTISE_10HALF)
- ecmd->advertising |= ADVERTISED_10baseT_Half;
- if (advert & ADVERTISE_10FULL)
- ecmd->advertising |= ADVERTISED_10baseT_Full;
- if (advert & ADVERTISE_100HALF)
- ecmd->advertising |= ADVERTISED_100baseT_Half;
- if (advert & ADVERTISE_100FULL)
- ecmd->advertising |= ADVERTISED_100baseT_Full;
- if (advert2 & ADVERTISE_1000HALF)
- ecmd->advertising |= ADVERTISED_1000baseT_Half;
- if (advert2 & ADVERTISE_1000FULL)
- ecmd->advertising |= ADVERTISED_1000baseT_Full;
bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
- lpa = mii->mdio_read(dev, mii->phy_id, MII_LPA);
+ bmsr = mii->mdio_read(dev, mii->phy_id, MII_BMSR);
if (mii->supports_gmii) {
- bmcr2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
- lpa2 = mii->mdio_read(dev, mii->phy_id, MII_STAT1000);
+ ctrl1000 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
+ stat1000 = mii->mdio_read(dev, mii->phy_id, MII_STAT1000);
}
if (bmcr & BMCR_ANENABLE) {
ecmd->advertising |= ADVERTISED_Autoneg;
ecmd->autoneg = AUTONEG_ENABLE;
- nego = mii_nway_result(advert & lpa);
- if ((bmcr2 & (ADVERTISE_1000HALF | ADVERTISE_1000FULL)) &
- (lpa2 >> 2))
+ ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE);
+ if (ctrl1000 & ADVERTISE_1000HALF)
+ ecmd->advertising |= ADVERTISED_1000baseT_Half;
+ if (ctrl1000 & ADVERTISE_1000FULL)
+ ecmd->advertising |= ADVERTISED_1000baseT_Full;
+
+ if (bmsr & BMSR_ANEGCOMPLETE) {
+ ecmd->lp_advertising = mii_get_an(mii, MII_LPA);
+ if (stat1000 & LPA_1000HALF)
+ ecmd->lp_advertising |=
+ ADVERTISED_1000baseT_Half;
+ if (stat1000 & LPA_1000FULL)
+ ecmd->lp_advertising |=
+ ADVERTISED_1000baseT_Full;
+ } else {
+ ecmd->lp_advertising = 0;
+ }
+
+ nego = ecmd->advertising & ecmd->lp_advertising;
+
+ if (nego & (ADVERTISED_1000baseT_Full |
+ ADVERTISED_1000baseT_Half)) {
ecmd->speed = SPEED_1000;
- else if (nego == LPA_100FULL || nego == LPA_100HALF)
+ ecmd->duplex = !!(nego & ADVERTISED_1000baseT_Full);
+ } else if (nego & (ADVERTISED_100baseT_Full |
+ ADVERTISED_100baseT_Half)) {
ecmd->speed = SPEED_100;
- else
- ecmd->speed = SPEED_10;
- if ((lpa2 & LPA_1000FULL) || nego == LPA_100FULL ||
- nego == LPA_10FULL) {
- ecmd->duplex = DUPLEX_FULL;
- mii->full_duplex = 1;
+ ecmd->duplex = !!(nego & ADVERTISED_100baseT_Full);
} else {
- ecmd->duplex = DUPLEX_HALF;
- mii->full_duplex = 0;
+ ecmd->speed = SPEED_10;
+ ecmd->duplex = !!(nego & ADVERTISED_10baseT_Full);
}
} else {
ecmd->autoneg = AUTONEG_DISABLE;
@@ -116,6 +137,8 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
}
+ mii->full_duplex = ecmd->duplex;
+
/* ignore maxtxpkt, maxrxpkt for now */
return 0;
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
index 664835b822fb..b3b9a147d09a 100644
--- a/drivers/net/mipsnet.c
+++ b/drivers/net/mipsnet.c
@@ -237,6 +237,16 @@ static void mipsnet_set_mclist(struct net_device *dev)
{
}
+static const struct net_device_ops mipsnet_netdev_ops = {
+ .ndo_open = mipsnet_open,
+ .ndo_stop = mipsnet_close,
+ .ndo_start_xmit = mipsnet_xmit,
+ .ndo_set_multicast_list = mipsnet_set_mclist,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int __init mipsnet_probe(struct platform_device *dev)
{
struct net_device *netdev;
@@ -250,10 +260,7 @@ static int __init mipsnet_probe(struct platform_device *dev)
platform_set_drvdata(dev, netdev);
- netdev->open = mipsnet_open;
- netdev->stop = mipsnet_close;
- netdev->hard_start_xmit = mipsnet_xmit;
- netdev->set_multicast_list = mipsnet_set_mclist;
+ netdev->netdev_ops = &mipsnet_netdev_ops;
/*
* TODO: probe for these or load them from PARAM
diff --git a/drivers/net/mlx4/en_cq.c b/drivers/net/mlx4/en_cq.c
index a276125b709b..21786ad4455e 100644
--- a/drivers/net/mlx4/en_cq.c
+++ b/drivers/net/mlx4/en_cq.c
@@ -89,6 +89,9 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq)
*cq->mcq.arm_db = 0;
memset(cq->buf, 0, cq->buf_size);
+ if (!cq->is_tx)
+ cq->size = priv->rx_ring[cq->ring].actual_size;
+
err = mlx4_cq_alloc(mdev->dev, cq->size, &cq->wqres.mtt, &mdev->priv_uar,
cq->wqres.db.dma, &cq->mcq, cq->vector, cq->is_tx);
if (err)
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 7bcc49de1637..cf89bfb29d6e 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -371,7 +371,7 @@ static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
int i;
/* If we haven't received a specific coalescing setting
- * (module param), we set the moderation paramters as follows:
+ * (module param), we set the moderation parameters as follows:
* - moder_cnt is set to the number of mtu sized packets to
* satisfy our coelsing target.
* - moder_time is set to a fixed value.
@@ -556,10 +556,8 @@ int mlx4_en_start_port(struct net_device *dev)
struct mlx4_en_dev *mdev = priv->mdev;
struct mlx4_en_cq *cq;
struct mlx4_en_tx_ring *tx_ring;
- struct mlx4_en_rx_ring *rx_ring;
int rx_index = 0;
int tx_index = 0;
- u16 stride;
int err = 0;
int i;
int j;
@@ -573,12 +571,15 @@ int mlx4_en_start_port(struct net_device *dev)
dev->mtu = min(dev->mtu, priv->max_mtu);
mlx4_en_calc_rx_buf(dev);
mlx4_dbg(DRV, priv, "Rx buf size:%d\n", priv->rx_skb_size);
- stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) +
- DS_SIZE * priv->num_frags);
+
/* Configure rx cq's and rings */
+ err = mlx4_en_activate_rx_rings(priv);
+ if (err) {
+ mlx4_err(mdev, "Failed to activate RX rings\n");
+ return err;
+ }
for (i = 0; i < priv->rx_ring_num; i++) {
cq = &priv->rx_cq[i];
- rx_ring = &priv->rx_ring[i];
err = mlx4_en_activate_cq(priv, cq);
if (err) {
@@ -594,20 +595,14 @@ int mlx4_en_start_port(struct net_device *dev)
goto cq_err;
}
mlx4_en_arm_cq(priv, cq);
-
+ priv->rx_ring[i].cqn = cq->mcq.cqn;
++rx_index;
}
- err = mlx4_en_activate_rx_rings(priv);
- if (err) {
- mlx4_err(mdev, "Failed to activate RX rings\n");
- goto cq_err;
- }
-
err = mlx4_en_config_rss_steer(priv);
if (err) {
mlx4_err(mdev, "Failed configuring rss steering\n");
- goto rx_err;
+ goto cq_err;
}
/* Configure tx cq's and rings */
@@ -694,12 +689,11 @@ tx_err:
}
mlx4_en_release_rss_steer(priv);
-rx_err:
- for (i = 0; i < priv->rx_ring_num; i++)
- mlx4_en_deactivate_rx_ring(priv, &priv->rx_ring[i]);
cq_err:
while (rx_index--)
mlx4_en_deactivate_cq(priv, &priv->rx_cq[rx_index]);
+ for (i = 0; i < priv->rx_ring_num; i++)
+ mlx4_en_deactivate_rx_ring(priv, &priv->rx_ring[i]);
return err; /* need to close devices */
}
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 9ee873e872b3..6bfab6e5ba1d 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -202,12 +202,35 @@ static inline void mlx4_en_update_rx_prod_db(struct mlx4_en_rx_ring *ring)
*ring->wqres.db.db = cpu_to_be32(ring->prod & 0xffff);
}
+static void mlx4_en_free_rx_desc(struct mlx4_en_priv *priv,
+ struct mlx4_en_rx_ring *ring,
+ int index)
+{
+ struct mlx4_en_dev *mdev = priv->mdev;
+ struct skb_frag_struct *skb_frags;
+ struct mlx4_en_rx_desc *rx_desc = ring->buf + (index << ring->log_stride);
+ dma_addr_t dma;
+ int nr;
+
+ skb_frags = ring->rx_info + (index << priv->log_rx_info);
+ for (nr = 0; nr < priv->num_frags; nr++) {
+ mlx4_dbg(DRV, priv, "Freeing fragment:%d\n", nr);
+ dma = be64_to_cpu(rx_desc->data[nr].addr);
+
+ mlx4_dbg(DRV, priv, "Unmaping buffer at dma:0x%llx\n", (u64) dma);
+ pci_unmap_single(mdev->pdev, dma, skb_frags[nr].size,
+ PCI_DMA_FROMDEVICE);
+ put_page(skb_frags[nr].page);
+ }
+}
+
static int mlx4_en_fill_rx_buffers(struct mlx4_en_priv *priv)
{
struct mlx4_en_dev *mdev = priv->mdev;
struct mlx4_en_rx_ring *ring;
int ring_ind;
int buf_ind;
+ int new_size;
for (buf_ind = 0; buf_ind < priv->prof->rx_ring_size; buf_ind++) {
for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) {
@@ -220,18 +243,30 @@ static int mlx4_en_fill_rx_buffers(struct mlx4_en_priv *priv)
"enough rx buffers\n");
return -ENOMEM;
} else {
- if (netif_msg_rx_err(priv))
- mlx4_warn(mdev,
- "Only %d buffers allocated\n",
- ring->actual_size);
- goto out;
+ new_size = rounddown_pow_of_two(ring->actual_size);
+ mlx4_warn(mdev, "Only %d buffers allocated "
+ "reducing ring size to %d",
+ ring->actual_size, new_size);
+ goto reduce_rings;
}
}
ring->actual_size++;
ring->prod++;
}
}
-out:
+ return 0;
+
+reduce_rings:
+ for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) {
+ ring = &priv->rx_ring[ring_ind];
+ while (ring->actual_size > new_size) {
+ ring->actual_size--;
+ ring->prod--;
+ mlx4_en_free_rx_desc(priv, ring, ring->actual_size);
+ }
+ ring->size_mask = ring->actual_size - 1;
+ }
+
return 0;
}
@@ -255,7 +290,7 @@ static int mlx4_en_fill_rx_buf(struct net_device *dev,
++num;
++ring->prod;
}
- if ((u32) (ring->prod - ring->cons) == ring->size)
+ if ((u32) (ring->prod - ring->cons) == ring->actual_size)
ring->full = 1;
return num;
@@ -264,33 +299,17 @@ static int mlx4_en_fill_rx_buf(struct net_device *dev,
static void mlx4_en_free_rx_buf(struct mlx4_en_priv *priv,
struct mlx4_en_rx_ring *ring)
{
- struct mlx4_en_dev *mdev = priv->mdev;
- struct skb_frag_struct *skb_frags;
- struct mlx4_en_rx_desc *rx_desc;
- dma_addr_t dma;
int index;
- int nr;
mlx4_dbg(DRV, priv, "Freeing Rx buf - cons:%d prod:%d\n",
ring->cons, ring->prod);
/* Unmap and free Rx buffers */
- BUG_ON((u32) (ring->prod - ring->cons) > ring->size);
+ BUG_ON((u32) (ring->prod - ring->cons) > ring->actual_size);
while (ring->cons != ring->prod) {
index = ring->cons & ring->size_mask;
- rx_desc = ring->buf + (index << ring->log_stride);
- skb_frags = ring->rx_info + (index << priv->log_rx_info);
mlx4_dbg(DRV, priv, "Processing descriptor:%d\n", index);
-
- for (nr = 0; nr < priv->num_frags; nr++) {
- mlx4_dbg(DRV, priv, "Freeing fragment:%d\n", nr);
- dma = be64_to_cpu(rx_desc->data[nr].addr);
-
- mlx4_dbg(DRV, priv, "Unmaping buffer at dma:0x%llx\n", (u64) dma);
- pci_unmap_single(mdev->pdev, dma, skb_frags[nr].size,
- PCI_DMA_FROMDEVICE);
- put_page(skb_frags[nr].page);
- }
+ mlx4_en_free_rx_desc(priv, ring, index);
++ring->cons;
}
}
@@ -454,7 +473,7 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
mlx4_en_update_rx_prod_db(ring);
/* Configure SRQ representing the ring */
- ring->srq.max = ring->size;
+ ring->srq.max = ring->actual_size;
ring->srq.max_gs = max_gs;
ring->srq.wqe_shift = ilog2(ring->stride);
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 6bb5af35eda6..1361ddc8d31f 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -88,7 +88,24 @@ static char mv643xx_eth_driver_version[] = "1.4";
#define MAC_ADDR_LOW 0x0014
#define MAC_ADDR_HIGH 0x0018
#define SDMA_CONFIG 0x001c
+#define TX_BURST_SIZE_16_64BIT 0x01000000
+#define TX_BURST_SIZE_4_64BIT 0x00800000
+#define BLM_TX_NO_SWAP 0x00000020
+#define BLM_RX_NO_SWAP 0x00000010
+#define RX_BURST_SIZE_16_64BIT 0x00000008
+#define RX_BURST_SIZE_4_64BIT 0x00000004
#define PORT_SERIAL_CONTROL 0x003c
+#define SET_MII_SPEED_TO_100 0x01000000
+#define SET_GMII_SPEED_TO_1000 0x00800000
+#define SET_FULL_DUPLEX_MODE 0x00200000
+#define MAX_RX_PACKET_9700BYTE 0x000a0000
+#define DISABLE_AUTO_NEG_SPEED_GMII 0x00002000
+#define DO_NOT_FORCE_LINK_FAIL 0x00000400
+#define SERIAL_PORT_CONTROL_RESERVED 0x00000200
+#define DISABLE_AUTO_NEG_FOR_FLOW_CTRL 0x00000008
+#define DISABLE_AUTO_NEG_FOR_DUPLEX 0x00000004
+#define FORCE_LINK_PASS 0x00000002
+#define SERIAL_PORT_ENABLE 0x00000001
#define PORT_STATUS 0x0044
#define TX_FIFO_EMPTY 0x00000400
#define TX_IN_PROGRESS 0x00000080
@@ -106,7 +123,9 @@ static char mv643xx_eth_driver_version[] = "1.4";
#define TX_BW_BURST 0x005c
#define INT_CAUSE 0x0060
#define INT_TX_END 0x07f80000
+#define INT_TX_END_0 0x00080000
#define INT_RX 0x000003fc
+#define INT_RX_0 0x00000004
#define INT_EXT 0x00000002
#define INT_CAUSE_EXT 0x0064
#define INT_EXT_LINK_PHY 0x00110000
@@ -135,15 +154,8 @@ static char mv643xx_eth_driver_version[] = "1.4";
/*
- * SDMA configuration register.
+ * SDMA configuration register default value.
*/
-#define RX_BURST_SIZE_4_64BIT (2 << 1)
-#define RX_BURST_SIZE_16_64BIT (4 << 1)
-#define BLM_RX_NO_SWAP (1 << 4)
-#define BLM_TX_NO_SWAP (1 << 5)
-#define TX_BURST_SIZE_4_64BIT (2 << 22)
-#define TX_BURST_SIZE_16_64BIT (4 << 22)
-
#if defined(__BIG_ENDIAN)
#define PORT_SDMA_CONFIG_DEFAULT_VALUE \
(RX_BURST_SIZE_4_64BIT | \
@@ -160,22 +172,11 @@ static char mv643xx_eth_driver_version[] = "1.4";
/*
- * Port serial control register.
+ * Misc definitions.
*/
-#define SET_MII_SPEED_TO_100 (1 << 24)
-#define SET_GMII_SPEED_TO_1000 (1 << 23)
-#define SET_FULL_DUPLEX_MODE (1 << 21)
-#define MAX_RX_PACKET_9700BYTE (5 << 17)
-#define DISABLE_AUTO_NEG_SPEED_GMII (1 << 13)
-#define DO_NOT_FORCE_LINK_FAIL (1 << 10)
-#define SERIAL_PORT_CONTROL_RESERVED (1 << 9)
-#define DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1 << 3)
-#define DISABLE_AUTO_NEG_FOR_DUPLEX (1 << 2)
-#define FORCE_LINK_PASS (1 << 1)
-#define SERIAL_PORT_ENABLE (1 << 0)
-
-#define DEFAULT_RX_QUEUE_SIZE 128
-#define DEFAULT_TX_QUEUE_SIZE 256
+#define DEFAULT_RX_QUEUE_SIZE 128
+#define DEFAULT_TX_QUEUE_SIZE 256
+#define SKB_DMA_REALIGN ((PAGE_SIZE - NET_SKB_PAD) % SMP_CACHE_BYTES)
/*
@@ -393,6 +394,7 @@ struct mv643xx_eth_private {
struct work_struct tx_timeout_task;
struct napi_struct napi;
+ u32 int_mask;
u8 oom;
u8 work_link;
u8 work_tx;
@@ -651,23 +653,20 @@ static int rxq_refill(struct rx_queue *rxq, int budget)
refilled = 0;
while (refilled < budget && rxq->rx_desc_count < rxq->rx_ring_size) {
struct sk_buff *skb;
- int unaligned;
int rx;
struct rx_desc *rx_desc;
skb = __skb_dequeue(&mp->rx_recycle);
if (skb == NULL)
- skb = dev_alloc_skb(mp->skb_size +
- dma_get_cache_alignment() - 1);
+ skb = dev_alloc_skb(mp->skb_size);
if (skb == NULL) {
mp->oom = 1;
goto oom;
}
- unaligned = (u32)skb->data & (dma_get_cache_alignment() - 1);
- if (unaligned)
- skb_reserve(skb, dma_get_cache_alignment() - unaligned);
+ if (SKB_DMA_REALIGN)
+ skb_reserve(skb, SKB_DMA_REALIGN);
refilled++;
rxq->rx_desc_count++;
@@ -969,8 +968,7 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
if (skb != NULL) {
if (skb_queue_len(&mp->rx_recycle) <
mp->rx_ring_size &&
- skb_recycle_check(skb, mp->skb_size +
- dma_get_cache_alignment() - 1))
+ skb_recycle_check(skb, mp->skb_size))
__skb_queue_head(&mp->rx_recycle, skb);
else
dev_kfree_skb(skb);
@@ -1810,7 +1808,6 @@ static void mv643xx_eth_program_multicast_filter(struct net_device *dev)
if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
int port_num;
u32 accept;
- int i;
oom:
port_num = mp->port_num;
@@ -2067,15 +2064,16 @@ static int mv643xx_eth_collect_events(struct mv643xx_eth_private *mp)
u32 int_cause;
u32 int_cause_ext;
- int_cause = rdlp(mp, INT_CAUSE) & (INT_TX_END | INT_RX | INT_EXT);
+ int_cause = rdlp(mp, INT_CAUSE) & mp->int_mask;
if (int_cause == 0)
return 0;
int_cause_ext = 0;
- if (int_cause & INT_EXT)
+ if (int_cause & INT_EXT) {
+ int_cause &= ~INT_EXT;
int_cause_ext = rdlp(mp, INT_CAUSE_EXT);
+ }
- int_cause &= INT_TX_END | INT_RX;
if (int_cause) {
wrlp(mp, INT_CAUSE, ~int_cause);
mp->work_tx_end |= ((int_cause & INT_TX_END) >> 19) &
@@ -2182,6 +2180,7 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
if (mp->work_link) {
mp->work_link = 0;
handle_link_event(mp);
+ work_done++;
continue;
}
@@ -2220,7 +2219,7 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
if (mp->oom)
mod_timer(&mp->rx_oom, jiffies + (HZ / 10));
napi_complete(napi);
- wrlp(mp, INT_MASK, INT_TX_END | INT_RX | INT_EXT);
+ wrlp(mp, INT_MASK, mp->int_mask);
}
return work_done;
@@ -2341,6 +2340,14 @@ static void mv643xx_eth_recalc_skb_size(struct mv643xx_eth_private *mp)
* size field are ignored by the hardware.
*/
mp->skb_size = (skb_size + 7) & ~7;
+
+ /*
+ * If NET_SKB_PAD is smaller than a cache line,
+ * netdev_alloc_skb() will cause skb->data to be misaligned
+ * to a cache line boundary. If this is the case, include
+ * some extra space to allow re-aligning the data area.
+ */
+ mp->skb_size += SKB_DMA_REALIGN;
}
static int mv643xx_eth_open(struct net_device *dev)
@@ -2366,6 +2373,8 @@ static int mv643xx_eth_open(struct net_device *dev)
skb_queue_head_init(&mp->rx_recycle);
+ mp->int_mask = INT_EXT;
+
for (i = 0; i < mp->rxq_count; i++) {
err = rxq_init(mp, i);
if (err) {
@@ -2375,6 +2384,7 @@ static int mv643xx_eth_open(struct net_device *dev)
}
rxq_refill(mp->rxq + i, INT_MAX);
+ mp->int_mask |= INT_RX_0 << i;
}
if (mp->oom) {
@@ -2389,12 +2399,13 @@ static int mv643xx_eth_open(struct net_device *dev)
txq_deinit(mp->txq + i);
goto out_free;
}
+ mp->int_mask |= INT_TX_END_0 << i;
}
port_start(mp);
wrlp(mp, INT_MASK_EXT, INT_EXT_LINK_PHY | INT_EXT_TX);
- wrlp(mp, INT_MASK, INT_TX_END | INT_RX | INT_EXT);
+ wrlp(mp, INT_MASK, mp->int_mask);
return 0;
@@ -2538,7 +2549,7 @@ static void mv643xx_eth_netpoll(struct net_device *dev)
mv643xx_eth_irq(dev->irq, dev);
- wrlp(mp, INT_MASK, INT_TX_END | INT_RX | INT_EXT);
+ wrlp(mp, INT_MASK, mp->int_mask);
}
#endif
diff --git a/drivers/net/mvme147.c b/drivers/net/mvme147.c
index 435e5a847c43..93c709d63e2f 100644
--- a/drivers/net/mvme147.c
+++ b/drivers/net/mvme147.c
@@ -57,6 +57,17 @@ typedef void (*writerap_t)(void *, unsigned short);
typedef void (*writerdp_t)(void *, unsigned short);
typedef unsigned short (*readrdp_t)(void *);
+static const struct net_device_ops lance_netdev_ops = {
+ .ndo_open = m147lance_open,
+ .ndo_stop = m147lance_close,
+ .ndo_start_xmit = lance_start_xmit,
+ .ndo_set_multicast_list = lance_set_multicast,
+ .ndo_tx_timeout = lance_tx_timeout,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
/* Initialise the one and only on-board 7990 */
struct net_device * __init mvme147lance_probe(int unit)
{
@@ -81,11 +92,7 @@ struct net_device * __init mvme147lance_probe(int unit)
/* Fill the dev fields */
dev->base_addr = (unsigned long)MVME147_LANCE_BASE;
- dev->open = &m147lance_open;
- dev->stop = &m147lance_close;
- dev->hard_start_xmit = &lance_start_xmit;
- dev->set_multicast_list = &lance_set_multicast;
- dev->tx_timeout = &lance_tx_timeout;
+ dev->netdev_ops = &lance_netdev_ops;
dev->dma = 0;
addr=(u_long *)ETHERNET_ADDRESS;
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index f2c4a665e93f..7e28b4610122 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -75,7 +75,7 @@
#include "myri10ge_mcp.h"
#include "myri10ge_mcp_gen_header.h"
-#define MYRI10GE_VERSION_STR "1.4.4-1.401"
+#define MYRI10GE_VERSION_STR "1.5.0-1.418"
MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -255,6 +255,7 @@ struct myri10ge_priv {
u32 read_write_dma;
u32 link_changes;
u32 msg_enable;
+ unsigned int board_number;
};
static char *myri10ge_fw_unaligned = "myri10ge_ethp_z8e.dat";
@@ -266,6 +267,13 @@ static char *myri10ge_fw_name = NULL;
module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name");
+#define MYRI10GE_MAX_BOARDS 8
+static char *myri10ge_fw_names[MYRI10GE_MAX_BOARDS] =
+ {[0 ... (MYRI10GE_MAX_BOARDS - 1)] = NULL };
+module_param_array_named(myri10ge_fw_names, myri10ge_fw_names, charp, NULL,
+ 0444);
+MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image names per board");
+
static int myri10ge_ecrc_enable = 1;
module_param(myri10ge_ecrc_enable, int, S_IRUGO);
MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E");
@@ -319,10 +327,6 @@ static int myri10ge_debug = -1; /* defaults above */
module_param(myri10ge_debug, int, 0);
MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
-static int myri10ge_lro = 1;
-module_param(myri10ge_lro, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload");
-
static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS;
module_param(myri10ge_lro_max_pkts, int, S_IRUGO);
MODULE_PARM_DESC(myri10ge_lro_max_pkts,
@@ -361,6 +365,8 @@ static inline void put_be32(__be32 val, __be32 __iomem * p)
__raw_writel((__force __u32) val, (__force void __iomem *)p);
}
+static struct net_device_stats *myri10ge_get_stats(struct net_device *dev);
+
static int
myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
struct myri10ge_cmd *data, int atomic)
@@ -1290,7 +1296,7 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, struct myri10ge_rx_buf *rx,
remainder -= MYRI10GE_ALLOC_SIZE;
}
- if (mgp->csum_flag && myri10ge_lro) {
+ if (dev->features & NETIF_F_LRO) {
rx_frags[0].page_offset += MXGEFW_PAD;
rx_frags[0].size -= MXGEFW_PAD;
len -= MXGEFW_PAD;
@@ -1412,6 +1418,7 @@ myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget)
{
struct myri10ge_rx_done *rx_done = &ss->rx_done;
struct myri10ge_priv *mgp = ss->mgp;
+ struct net_device *netdev = mgp->dev;
unsigned long rx_bytes = 0;
unsigned long rx_packets = 0;
unsigned long rx_ok;
@@ -1445,7 +1452,7 @@ myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget)
ss->stats.rx_packets += rx_packets;
ss->stats.rx_bytes += rx_bytes;
- if (myri10ge_lro)
+ if (netdev->features & NETIF_F_LRO)
lro_flush_all(&rx_done->lro_mgr);
/* restock receive rings if needed */
@@ -1686,7 +1693,7 @@ myri10ge_get_ringparam(struct net_device *netdev,
ring->rx_mini_max_pending = mgp->ss[0].rx_small.mask + 1;
ring->rx_max_pending = mgp->ss[0].rx_big.mask + 1;
ring->rx_jumbo_max_pending = 0;
- ring->tx_max_pending = mgp->ss[0].rx_small.mask + 1;
+ ring->tx_max_pending = mgp->ss[0].tx.mask + 1;
ring->rx_mini_pending = ring->rx_mini_max_pending;
ring->rx_pending = ring->rx_max_pending;
ring->rx_jumbo_pending = ring->rx_jumbo_max_pending;
@@ -1706,12 +1713,17 @@ static u32 myri10ge_get_rx_csum(struct net_device *netdev)
static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
{
struct myri10ge_priv *mgp = netdev_priv(netdev);
+ int err = 0;
if (csum_enabled)
mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
- else
+ else {
+ u32 flags = ethtool_op_get_flags(netdev);
+ err = ethtool_op_set_flags(netdev, (flags & ~ETH_FLAG_LRO));
mgp->csum_flag = 0;
- return 0;
+
+ }
+ return err;
}
static int myri10ge_set_tso(struct net_device *netdev, u32 tso_enabled)
@@ -1803,6 +1815,8 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
int slice;
int i;
+ /* force stats update */
+ (void)myri10ge_get_stats(netdev);
for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
data[i] = ((unsigned long *)&mgp->stats)[i];
@@ -1892,7 +1906,9 @@ static const struct ethtool_ops myri10ge_ethtool_ops = {
.get_sset_count = myri10ge_get_sset_count,
.get_ethtool_stats = myri10ge_get_ethtool_stats,
.set_msglevel = myri10ge_set_msglevel,
- .get_msglevel = myri10ge_get_msglevel
+ .get_msglevel = myri10ge_get_msglevel,
+ .get_flags = ethtool_op_get_flags,
+ .set_flags = ethtool_op_set_flags
};
static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss)
@@ -2969,6 +2985,7 @@ static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
struct net_device_stats *stats = &mgp->stats;
int i;
+ spin_lock(&mgp->stats_lock);
memset(stats, 0, sizeof(*stats));
for (i = 0; i < mgp->num_slices; i++) {
slice_stats = &mgp->ss[i].stats;
@@ -2979,6 +2996,7 @@ static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
stats->rx_dropped += slice_stats->rx_dropped;
stats->tx_dropped += slice_stats->tx_dropped;
}
+ spin_unlock(&mgp->stats_lock);
return stats;
}
@@ -3253,6 +3271,8 @@ abort:
static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
{
+ int overridden = 0;
+
if (myri10ge_force_firmware == 0) {
int link_width, exp_cap;
u16 lnk;
@@ -3286,10 +3306,18 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
}
}
if (myri10ge_fw_name != NULL) {
- dev_info(&mgp->pdev->dev, "overriding firmware to %s\n",
- myri10ge_fw_name);
+ overridden = 1;
mgp->fw_name = myri10ge_fw_name;
}
+ if (mgp->board_number < MYRI10GE_MAX_BOARDS &&
+ myri10ge_fw_names[mgp->board_number] != NULL &&
+ strlen(myri10ge_fw_names[mgp->board_number])) {
+ mgp->fw_name = myri10ge_fw_names[mgp->board_number];
+ overridden = 1;
+ }
+ if (overridden)
+ dev_info(&mgp->pdev->dev, "overriding firmware to %s\n",
+ mgp->fw_name);
}
#ifdef CONFIG_PM
@@ -3754,6 +3782,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
int status = -ENXIO;
int dac_enabled;
unsigned hdr_offset, ss_offset;
+ static int board_number;
netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES);
if (netdev == NULL) {
@@ -3770,6 +3799,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
mgp->pause = myri10ge_flow_control;
mgp->intr_coal_delay = myri10ge_intr_coal_delay;
mgp->msg_enable = netif_msg_init(myri10ge_debug, MYRI10GE_MSG_DEFAULT);
+ mgp->board_number = board_number;
init_waitqueue_head(&mgp->down_wq);
if (pci_enable_device(pdev)) {
@@ -3884,6 +3914,13 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (dac_enabled)
netdev->features |= NETIF_F_HIGHDMA;
+ netdev->features |= NETIF_F_LRO;
+
+ netdev->vlan_features |= mgp->features;
+ if (mgp->fw_ver_tiny < 37)
+ netdev->vlan_features &= ~NETIF_F_TSO6;
+ if (mgp->fw_ver_tiny < 32)
+ netdev->vlan_features &= ~NETIF_F_TSO;
/* make sure we can get an irq, and that MSI can be
* setup (if available). Also ensure netdev->irq
@@ -3902,6 +3939,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
(unsigned long)mgp);
+ spin_lock_init(&mgp->stats_lock);
SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
status = register_netdev(netdev);
@@ -3919,6 +3957,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->irq, mgp->tx_boundary, mgp->fw_name,
(mgp->wc_enabled ? "Enabled" : "Disabled"));
+ board_number++;
return 0;
abort_with_state:
@@ -4008,6 +4047,8 @@ static struct pci_device_id myri10ge_pci_tbl[] = {
{0},
};
+MODULE_DEVICE_TABLE(pci, myri10ge_pci_tbl);
+
static struct pci_driver myri10ge_driver = {
.name = "myri10ge",
.probe = myri10ge_probe,
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index 7d83896b8c26..3fcebb70151c 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -374,7 +374,7 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
dev->ethtool_ops = &ne2k_pci_ethtool_ops;
NS8390_init(dev, 0);
- memcpy(dev->dev_addr, SA_prom, 6);
+ memcpy(dev->dev_addr, SA_prom, dev->addr_len);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
i = register_netdev(dev);
diff --git a/drivers/net/ne3210.c b/drivers/net/ne3210.c
index 6a843f7350ab..a00bbfb9aed0 100644
--- a/drivers/net/ne3210.c
+++ b/drivers/net/ne3210.c
@@ -104,7 +104,7 @@ static int __init ne3210_eisa_probe (struct device *device)
}
SET_NETDEV_DEV(dev, device);
- device->driver_data = dev;
+ dev_set_drvdata(device, dev);
ioaddr = edev->base_addr;
if (!request_region(ioaddr, NE3210_IO_EXTENT, DRV_NAME)) {
@@ -225,7 +225,7 @@ static int __init ne3210_eisa_probe (struct device *device)
static int __devexit ne3210_eisa_remove (struct device *device)
{
- struct net_device *dev = device->driver_data;
+ struct net_device *dev = dev_get_drvdata(device);
unsigned long ioaddr = to_eisa_device (device)->base_addr;
unregister_netdev (dev);
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c
index 1861d5bbd96b..946366dcc992 100644
--- a/drivers/net/netx-eth.c
+++ b/drivers/net/netx-eth.c
@@ -301,6 +301,17 @@ netx_eth_phy_write(struct net_device *ndev, int phy_id, int reg, int value)
while (readl(NETX_MIIMU) & MIIMU_SNRDY);
}
+static const struct net_device_ops netx_eth_netdev_ops = {
+ .ndo_open = netx_eth_open,
+ .ndo_stop = netx_eth_close,
+ .ndo_start_xmit = netx_eth_hard_start_xmit,
+ .ndo_tx_timeout = netx_eth_timeout,
+ .ndo_set_multicast_list = netx_eth_set_multicast_list,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int netx_eth_enable(struct net_device *ndev)
{
struct netx_eth_priv *priv = netdev_priv(ndev);
@@ -309,12 +320,8 @@ static int netx_eth_enable(struct net_device *ndev)
ether_setup(ndev);
- ndev->open = netx_eth_open;
- ndev->stop = netx_eth_close;
- ndev->hard_start_xmit = netx_eth_hard_start_xmit;
- ndev->tx_timeout = netx_eth_timeout;
+ ndev->netdev_ops = &netx_eth_netdev_ops;
ndev->watchdog_timeo = msecs_to_jiffies(5000);
- ndev->set_multicast_list = netx_eth_set_multicast_list;
priv->msg_enable = NETIF_MSG_LINK;
priv->mii.phy_id_mask = 0x1f;
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index c40815169f35..ab11c2b3f0fe 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -34,10 +34,6 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
-#include <linux/compiler.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
@@ -46,21 +42,16 @@
#include <linux/in.h>
#include <linux/tcp.h>
#include <linux/skbuff.h>
+#include <linux/firmware.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
-#include <linux/interrupt.h>
#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
#include <linux/vmalloc.h>
-#include <asm/system.h>
#include <asm/io.h>
#include <asm/byteorder.h>
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
#include "netxen_nic_hw.h"
@@ -84,10 +75,10 @@
(sizeof(struct netxen_rx_buffer) * rds_ring->num_desc)
#define STATUS_DESC_RINGSIZE(sds_ring) \
(sizeof(struct status_desc) * (sds_ring)->num_desc)
-#define TX_BUFF_RINGSIZE(adapter) \
- (sizeof(struct netxen_cmd_buffer) * adapter->num_txd)
-#define TX_DESC_RINGSIZE(adapter) \
- (sizeof(struct cmd_desc_type0) * adapter->num_txd)
+#define TX_BUFF_RINGSIZE(tx_ring) \
+ (sizeof(struct netxen_cmd_buffer) * tx_ring->num_desc)
+#define TX_DESC_RINGSIZE(tx_ring) \
+ (sizeof(struct cmd_desc_type0) * tx_ring->num_desc)
#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
@@ -118,6 +109,7 @@
#define NX_P3_A2 0x30
#define NX_P3_B0 0x40
#define NX_P3_B1 0x41
+#define NX_P3_B2 0x42
#define NX_IS_REVISION_P2(REVISION) (REVISION <= NX_P2_C1)
#define NX_IS_REVISION_P3(REVISION) (REVISION >= NX_P3_A0)
@@ -203,18 +195,10 @@
#define MAX_RCV_DESCRIPTORS_10G 4096
#define MAX_JUMBO_RCV_DESCRIPTORS 1024
#define MAX_LRO_RCV_DESCRIPTORS 8
-#define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS
-#define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
-#define MAX_RCV_DESC MAX_RCV_DESCRIPTORS
-#define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS
-#define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8)
-#define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \
- MAX_LRO_RCV_DESCRIPTORS)
-#define MIN_TX_COUNT 4096
-#define MIN_RX_COUNT 4096
#define NETXEN_CTX_SIGNATURE 0xdee0
+#define NETXEN_CTX_SIGNATURE_V2 0x0002dee0
+#define NETXEN_CTX_RESET 0xbad0
#define NETXEN_RCV_PRODUCER(ringid) (ringid)
-#define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */
#define PHAN_PEG_RCV_INITIALIZED 0xff01
#define PHAN_PEG_RCV_START_INITIALIZE 0xff00
@@ -253,12 +237,19 @@ typedef u32 netxen_ctx_msg;
#define netxen_set_msg_opcode(config_word, val) \
((config_word) &= ~(0xf<<28), (config_word) |= (val & 0xf) << 28)
-struct netxen_rcv_context {
- __le64 rcv_ring_addr;
- __le32 rcv_ring_size;
+struct netxen_rcv_ring {
+ __le64 addr;
+ __le32 size;
__le32 rsrvd;
};
+struct netxen_sts_ring {
+ __le64 addr;
+ __le32 size;
+ __le16 msi_index;
+ __le16 rsvd;
+} ;
+
struct netxen_ring_ctx {
/* one command ring */
@@ -268,13 +259,18 @@ struct netxen_ring_ctx {
__le32 rsrvd;
/* three receive rings */
- struct netxen_rcv_context rcv_ctx[3];
+ struct netxen_rcv_ring rcv_rings[NUM_RCV_DESC_RINGS];
- /* one status ring */
__le64 sts_ring_addr;
__le32 sts_ring_size;
__le32 ctx_id;
+
+ __le64 rsrvd_2[3];
+ __le32 sts_ring_count;
+ __le32 rsrvd_3;
+ struct netxen_sts_ring sts_rings[NUM_STS_DESC_RINGS];
+
} __attribute__ ((aligned(64)));
/*
@@ -373,6 +369,7 @@ struct rcv_desc {
/* opcode field in status_desc */
#define NETXEN_NIC_RXPKT_DESC 0x04
#define NETXEN_OLD_RXPKT_DESC 0x3f
+#define NETXEN_NIC_RESPONSE_DESC 0x05
/* for status field in status_desc */
#define STATUS_NEED_CKSUM (1)
@@ -382,13 +379,11 @@ struct rcv_desc {
#define STATUS_OWNER_HOST (0x1ULL << 56)
#define STATUS_OWNER_PHANTOM (0x2ULL << 56)
-/* Note: sizeof(status_desc) should always be a mutliple of 2 */
-
-#define netxen_get_sts_desc_lro_cnt(status_desc) \
- ((status_desc)->lro & 0x7F)
-#define netxen_get_sts_desc_lro_last_frag(status_desc) \
- (((status_desc)->lro & 0x80) >> 7)
-
+/* Status descriptor:
+ 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
+ 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
+ 53-55 desc_cnt, 56-57 owner, 58-63 opcode
+ */
#define netxen_get_sts_port(sts_data) \
((sts_data) & 0x0F)
#define netxen_get_sts_status(sts_data) \
@@ -403,41 +398,15 @@ struct rcv_desc {
(((sts_data) >> 44) & 0x0F)
#define netxen_get_sts_pkt_offset(sts_data) \
(((sts_data) >> 48) & 0x1F)
+#define netxen_get_sts_desc_cnt(sts_data) \
+ (((sts_data) >> 53) & 0x7)
#define netxen_get_sts_opcode(sts_data) \
(((sts_data) >> 58) & 0x03F)
struct status_desc {
- /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
- 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
- 53-55 desc_cnt, 56-57 owner, 58-63 opcode
- */
- __le64 status_desc_data;
- union {
- struct {
- __le32 hash_value;
- u8 hash_type;
- u8 msg_type;
- u8 unused;
- union {
- /* Bit pattern: 0-6 lro_count indicates frag
- * sequence, 7 last_frag indicates last frag
- */
- u8 lro;
-
- /* chained buffers */
- u8 nr_frags;
- };
- };
- struct {
- __le16 frag_handles[4];
- };
- };
+ __le64 status_desc_data[2];
} __attribute__ ((aligned(16)));
-enum {
- NETXEN_RCV_PEG_0 = 0,
- NETXEN_RCV_PEG_1
-};
/* The version of the main data structure */
#define NETXEN_BDINFO_VERSION 1
@@ -447,85 +416,35 @@ enum {
/* Max number of Gig ports on a Phantom board */
#define NETXEN_MAX_PORTS 4
-typedef enum {
- NETXEN_BRDTYPE_P1_BD = 0x0000,
- NETXEN_BRDTYPE_P1_SB = 0x0001,
- NETXEN_BRDTYPE_P1_SMAX = 0x0002,
- NETXEN_BRDTYPE_P1_SOCK = 0x0003,
-
- NETXEN_BRDTYPE_P2_SOCK_31 = 0x0008,
- NETXEN_BRDTYPE_P2_SOCK_35 = 0x0009,
- NETXEN_BRDTYPE_P2_SB35_4G = 0x000a,
- NETXEN_BRDTYPE_P2_SB31_10G = 0x000b,
- NETXEN_BRDTYPE_P2_SB31_2G = 0x000c,
-
- NETXEN_BRDTYPE_P2_SB31_10G_IMEZ = 0x000d,
- NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
- NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f,
-
- NETXEN_BRDTYPE_P3_REF_QG = 0x0021,
- NETXEN_BRDTYPE_P3_HMEZ = 0x0022,
- NETXEN_BRDTYPE_P3_10G_CX4_LP = 0x0023,
- NETXEN_BRDTYPE_P3_4_GB = 0x0024,
- NETXEN_BRDTYPE_P3_IMEZ = 0x0025,
- NETXEN_BRDTYPE_P3_10G_SFP_PLUS = 0x0026,
- NETXEN_BRDTYPE_P3_10000_BASE_T = 0x0027,
- NETXEN_BRDTYPE_P3_XG_LOM = 0x0028,
- NETXEN_BRDTYPE_P3_4_GB_MM = 0x0029,
- NETXEN_BRDTYPE_P3_10G_SFP_CT = 0x002a,
- NETXEN_BRDTYPE_P3_10G_SFP_QT = 0x002b,
- NETXEN_BRDTYPE_P3_10G_CX4 = 0x0031,
- NETXEN_BRDTYPE_P3_10G_XFP = 0x0032,
- NETXEN_BRDTYPE_P3_10G_TP = 0x0080
-
-} netxen_brdtype_t;
-
-typedef enum {
- NETXEN_BRDMFG_INVENTEC = 1
-} netxen_brdmfg;
-
-typedef enum {
- MEM_ORG_128Mbx4 = 0x0, /* DDR1 only */
- MEM_ORG_128Mbx8 = 0x1, /* DDR1 only */
- MEM_ORG_128Mbx16 = 0x2, /* DDR1 only */
- MEM_ORG_256Mbx4 = 0x3,
- MEM_ORG_256Mbx8 = 0x4,
- MEM_ORG_256Mbx16 = 0x5,
- MEM_ORG_512Mbx4 = 0x6,
- MEM_ORG_512Mbx8 = 0x7,
- MEM_ORG_512Mbx16 = 0x8,
- MEM_ORG_1Gbx4 = 0x9,
- MEM_ORG_1Gbx8 = 0xa,
- MEM_ORG_1Gbx16 = 0xb,
- MEM_ORG_2Gbx4 = 0xc,
- MEM_ORG_2Gbx8 = 0xd,
- MEM_ORG_2Gbx16 = 0xe,
- MEM_ORG_128Mbx32 = 0x10002, /* GDDR only */
- MEM_ORG_256Mbx32 = 0x10005 /* GDDR only */
-} netxen_mn_mem_org_t;
-
-typedef enum {
- MEM_ORG_512Kx36 = 0x0,
- MEM_ORG_1Mx36 = 0x1,
- MEM_ORG_2Mx36 = 0x2
-} netxen_sn_mem_org_t;
-
-typedef enum {
- MEM_DEPTH_4MB = 0x1,
- MEM_DEPTH_8MB = 0x2,
- MEM_DEPTH_16MB = 0x3,
- MEM_DEPTH_32MB = 0x4,
- MEM_DEPTH_64MB = 0x5,
- MEM_DEPTH_128MB = 0x6,
- MEM_DEPTH_256MB = 0x7,
- MEM_DEPTH_512MB = 0x8,
- MEM_DEPTH_1GB = 0x9,
- MEM_DEPTH_2GB = 0xa,
- MEM_DEPTH_4GB = 0xb,
- MEM_DEPTH_8GB = 0xc,
- MEM_DEPTH_16GB = 0xd,
- MEM_DEPTH_32GB = 0xe
-} netxen_mem_depth_t;
+#define NETXEN_BRDTYPE_P1_BD 0x0000
+#define NETXEN_BRDTYPE_P1_SB 0x0001
+#define NETXEN_BRDTYPE_P1_SMAX 0x0002
+#define NETXEN_BRDTYPE_P1_SOCK 0x0003
+
+#define NETXEN_BRDTYPE_P2_SOCK_31 0x0008
+#define NETXEN_BRDTYPE_P2_SOCK_35 0x0009
+#define NETXEN_BRDTYPE_P2_SB35_4G 0x000a
+#define NETXEN_BRDTYPE_P2_SB31_10G 0x000b
+#define NETXEN_BRDTYPE_P2_SB31_2G 0x000c
+
+#define NETXEN_BRDTYPE_P2_SB31_10G_IMEZ 0x000d
+#define NETXEN_BRDTYPE_P2_SB31_10G_HMEZ 0x000e
+#define NETXEN_BRDTYPE_P2_SB31_10G_CX4 0x000f
+
+#define NETXEN_BRDTYPE_P3_REF_QG 0x0021
+#define NETXEN_BRDTYPE_P3_HMEZ 0x0022
+#define NETXEN_BRDTYPE_P3_10G_CX4_LP 0x0023
+#define NETXEN_BRDTYPE_P3_4_GB 0x0024
+#define NETXEN_BRDTYPE_P3_IMEZ 0x0025
+#define NETXEN_BRDTYPE_P3_10G_SFP_PLUS 0x0026
+#define NETXEN_BRDTYPE_P3_10000_BASE_T 0x0027
+#define NETXEN_BRDTYPE_P3_XG_LOM 0x0028
+#define NETXEN_BRDTYPE_P3_4_GB_MM 0x0029
+#define NETXEN_BRDTYPE_P3_10G_SFP_CT 0x002a
+#define NETXEN_BRDTYPE_P3_10G_SFP_QT 0x002b
+#define NETXEN_BRDTYPE_P3_10G_CX4 0x0031
+#define NETXEN_BRDTYPE_P3_10G_XFP 0x0032
+#define NETXEN_BRDTYPE_P3_10G_TP 0x0080
struct netxen_board_info {
u32 header_version;
@@ -676,17 +595,15 @@ struct netxen_new_user_info {
#define PRIMARY_IMAGE_BAD 0xffffffff
/* Flash memory map */
-typedef enum {
- NETXEN_CRBINIT_START = 0, /* Crbinit section */
- NETXEN_BRDCFG_START = 0x4000, /* board config */
- NETXEN_INITCODE_START = 0x6000, /* pegtune code */
- NETXEN_BOOTLD_START = 0x10000, /* bootld */
- NETXEN_IMAGE_START = 0x43000, /* compressed image */
- NETXEN_SECONDARY_START = 0x200000, /* backup images */
- NETXEN_PXE_START = 0x3E0000, /* user defined region */
- NETXEN_USER_START = 0x3E8000, /* User defined region for new boards */
- NETXEN_FIXED_START = 0x3F0000 /* backup of crbinit */
-} netxen_flash_map_t;
+#define NETXEN_CRBINIT_START 0 /* crbinit section */
+#define NETXEN_BRDCFG_START 0x4000 /* board config */
+#define NETXEN_INITCODE_START 0x6000 /* pegtune code */
+#define NETXEN_BOOTLD_START 0x10000 /* bootld */
+#define NETXEN_IMAGE_START 0x43000 /* compressed image */
+#define NETXEN_SECONDARY_START 0x200000 /* backup images */
+#define NETXEN_PXE_START 0x3E0000 /* PXE boot rom */
+#define NETXEN_USER_START 0x3E8000 /* Firmare info */
+#define NETXEN_FIXED_START 0x3F0000 /* backup of crbinit */
#define NX_FW_VERSION_OFFSET (NETXEN_USER_START+0x408)
#define NX_FW_SIZE_OFFSET (NETXEN_USER_START+0x40c)
@@ -708,21 +625,8 @@ typedef enum {
#define NETXEN_FLASH_SECONDARY_SIZE (NETXEN_USER_START-NETXEN_SECONDARY_START)
#define NETXEN_NUM_PRIMARY_SECTORS (0x20)
#define NETXEN_NUM_CONFIG_SECTORS (1)
-#define PFX "NetXen: "
extern char netxen_nic_driver_name[];
-/* Note: Make sure to not call this before adapter->port is valid */
-#if !defined(NETXEN_DEBUG)
-#define DPRINTK(klevel, fmt, args...) do { \
- } while (0)
-#else
-#define DPRINTK(klevel, fmt, args...) do { \
- printk(KERN_##klevel PFX "%s: %s: " fmt, __func__,\
- (adapter != NULL && adapter->netdev != NULL) ? \
- adapter->netdev->name : NULL, \
- ## args); } while(0)
-#endif
-
/* Number of status descriptors to handle per interrupt */
#define MAX_STATUS_HANDLE (64)
@@ -732,7 +636,7 @@ extern char netxen_nic_driver_name[];
*/
struct netxen_skb_frag {
u64 dma;
- ulong length;
+ u64 length;
};
#define _netxen_set_bits(config_word, start, bits, val) {\
@@ -793,34 +697,24 @@ struct netxen_hardware_context {
u8 cut_through;
u8 revision_id;
+ u8 pci_func;
+ u8 linkup;
u16 port_type;
- int board_type;
- u32 linkup;
- /* Address of cmd ring in Phantom */
- struct cmd_desc_type0 *cmd_desc_head;
- dma_addr_t cmd_desc_phys_addr;
- struct netxen_adapter *adapter;
- int pci_func;
+ u16 board_type;
};
#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
#define ETHERNET_FCS_SIZE 4
struct netxen_adapter_stats {
- u64 rcvdbadskb;
u64 xmitcalled;
- u64 xmitedframes;
u64 xmitfinished;
- u64 badskblen;
- u64 nocmddescriptor;
- u64 polled;
u64 rxdropped;
u64 txdropped;
u64 csummed;
u64 no_rcv;
u64 rxbytes;
u64 txbytes;
- u64 ints;
};
/*
@@ -852,14 +746,25 @@ struct nx_host_sds_ring {
struct napi_struct napi;
struct list_head free_list[NUM_RCV_DESC_RINGS];
- u16 clean_tx;
- u16 post_rxd;
int irq;
dma_addr_t phys_addr;
char name[IFNAMSIZ+4];
};
+struct nx_host_tx_ring {
+ u32 producer;
+ __le32 *hw_consumer;
+ u32 sw_consumer;
+ u32 crb_cmd_producer;
+ u32 crb_cmd_consumer;
+ u32 num_desc;
+
+ struct netxen_cmd_buffer *cmd_buf_arr;
+ struct cmd_desc_type0 *desc_head;
+ dma_addr_t phys_addr;
+};
+
/*
* Receive context. There is one such structure per instance of the
* receive processing. Any state information that is relevant to
@@ -871,8 +776,11 @@ struct netxen_recv_context {
u16 context_id;
u16 virt_port;
- struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS];
- struct nx_host_sds_ring sds_rings[NUM_STS_DESC_RINGS];
+ struct nx_host_rds_ring *rds_rings;
+ struct nx_host_sds_ring *sds_rings;
+
+ struct netxen_ring_ctx *hwctx;
+ dma_addr_t phys_addr;
};
/* New HW context creation */
@@ -1111,8 +1019,8 @@ typedef struct {
#define NETXEN_MAC_DEL 2
typedef struct nx_mac_list_s {
- struct nx_mac_list_s *next;
- uint8_t mac_addr[MAX_ADDR_LEN];
+ struct list_head list;
+ uint8_t mac_addr[ETH_ALEN+2];
} nx_mac_list_t;
/*
@@ -1154,31 +1062,118 @@ typedef struct {
#define NX_MAC_EVENT 0x1
-enum {
- NX_NIC_H2C_OPCODE_START = 0,
- NX_NIC_H2C_OPCODE_CONFIG_RSS,
- NX_NIC_H2C_OPCODE_CONFIG_RSS_TBL,
- NX_NIC_H2C_OPCODE_CONFIG_INTR_COALESCE,
- NX_NIC_H2C_OPCODE_CONFIG_LED,
- NX_NIC_H2C_OPCODE_CONFIG_PROMISCUOUS,
- NX_NIC_H2C_OPCODE_CONFIG_L2_MAC,
- NX_NIC_H2C_OPCODE_LRO_REQUEST,
- NX_NIC_H2C_OPCODE_GET_SNMP_STATS,
- NX_NIC_H2C_OPCODE_PROXY_START_REQUEST,
- NX_NIC_H2C_OPCODE_PROXY_STOP_REQUEST,
- NX_NIC_H2C_OPCODE_PROXY_SET_MTU,
- NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE,
- NX_H2P_OPCODE_GET_FINGER_PRINT_REQUEST,
- NX_H2P_OPCODE_INSTALL_LICENSE_REQUEST,
- NX_H2P_OPCODE_GET_LICENSE_CAPABILITY_REQUEST,
- NX_NIC_H2C_OPCODE_GET_NET_STATS,
- NX_NIC_H2C_OPCODE_LAST
-};
+/*
+ * Driver --> Firmware
+ */
+#define NX_NIC_H2C_OPCODE_START 0
+#define NX_NIC_H2C_OPCODE_CONFIG_RSS 1
+#define NX_NIC_H2C_OPCODE_CONFIG_RSS_TBL 2
+#define NX_NIC_H2C_OPCODE_CONFIG_INTR_COALESCE 3
+#define NX_NIC_H2C_OPCODE_CONFIG_LED 4
+#define NX_NIC_H2C_OPCODE_CONFIG_PROMISCUOUS 5
+#define NX_NIC_H2C_OPCODE_CONFIG_L2_MAC 6
+#define NX_NIC_H2C_OPCODE_LRO_REQUEST 7
+#define NX_NIC_H2C_OPCODE_GET_SNMP_STATS 8
+#define NX_NIC_H2C_OPCODE_PROXY_START_REQUEST 9
+#define NX_NIC_H2C_OPCODE_PROXY_STOP_REQUEST 10
+#define NX_NIC_H2C_OPCODE_PROXY_SET_MTU 11
+#define NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE 12
+#define NX_NIC_H2C_OPCODE_GET_FINGER_PRINT_REQUEST 13
+#define NX_NIC_H2C_OPCODE_INSTALL_LICENSE_REQUEST 14
+#define NX_NIC_H2C_OPCODE_GET_LICENSE_CAPABILITY_REQUEST 15
+#define NX_NIC_H2C_OPCODE_GET_NET_STATS 16
+#define NX_NIC_H2C_OPCODE_PROXY_UPDATE_P2V 17
+#define NX_NIC_H2C_OPCODE_CONFIG_IPADDR 18
+#define NX_NIC_H2C_OPCODE_CONFIG_LOOPBACK 19
+#define NX_NIC_H2C_OPCODE_PROXY_STOP_DONE 20
+#define NX_NIC_H2C_OPCODE_GET_LINKEVENT 21
+#define NX_NIC_C2C_OPCODE 22
+#define NX_NIC_H2C_OPCODE_LAST 23
+
+/*
+ * Firmware --> Driver
+ */
+
+#define NX_NIC_C2H_OPCODE_START 128
+#define NX_NIC_C2H_OPCODE_CONFIG_RSS_RESPONSE 129
+#define NX_NIC_C2H_OPCODE_CONFIG_RSS_TBL_RESPONSE 130
+#define NX_NIC_C2H_OPCODE_CONFIG_MAC_RESPONSE 131
+#define NX_NIC_C2H_OPCODE_CONFIG_PROMISCUOUS_RESPONSE 132
+#define NX_NIC_C2H_OPCODE_CONFIG_L2_MAC_RESPONSE 133
+#define NX_NIC_C2H_OPCODE_LRO_DELETE_RESPONSE 134
+#define NX_NIC_C2H_OPCODE_LRO_ADD_FAILURE_RESPONSE 135
+#define NX_NIC_C2H_OPCODE_GET_SNMP_STATS 136
+#define NX_NIC_C2H_OPCODE_GET_FINGER_PRINT_REPLY 137
+#define NX_NIC_C2H_OPCODE_INSTALL_LICENSE_REPLY 138
+#define NX_NIC_C2H_OPCODE_GET_LICENSE_CAPABILITIES_REPLY 139
+#define NX_NIC_C2H_OPCODE_GET_NET_STATS_RESPONSE 140
+#define NX_NIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE 141
+#define NX_NIC_C2H_OPCODE_LAST 142
#define VPORT_MISS_MODE_DROP 0 /* drop all unmatched */
#define VPORT_MISS_MODE_ACCEPT_ALL 1 /* accept all packets */
#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */
+#define NX_FW_CAPABILITY_LINK_NOTIFICATION (1 << 5)
+#define NX_FW_CAPABILITY_SWITCHING (1 << 6)
+
+/* module types */
+#define LINKEVENT_MODULE_NOT_PRESENT 1
+#define LINKEVENT_MODULE_OPTICAL_UNKNOWN 2
+#define LINKEVENT_MODULE_OPTICAL_SRLR 3
+#define LINKEVENT_MODULE_OPTICAL_LRM 4
+#define LINKEVENT_MODULE_OPTICAL_SFP_1G 5
+#define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE 6
+#define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN 7
+#define LINKEVENT_MODULE_TWINAX 8
+
+#define LINKSPEED_10GBPS 10000
+#define LINKSPEED_1GBPS 1000
+#define LINKSPEED_100MBPS 100
+#define LINKSPEED_10MBPS 10
+
+#define LINKSPEED_ENCODED_10MBPS 0
+#define LINKSPEED_ENCODED_100MBPS 1
+#define LINKSPEED_ENCODED_1GBPS 2
+
+#define LINKEVENT_AUTONEG_DISABLED 0
+#define LINKEVENT_AUTONEG_ENABLED 1
+
+#define LINKEVENT_HALF_DUPLEX 0
+#define LINKEVENT_FULL_DUPLEX 1
+
+#define LINKEVENT_LINKSPEED_MBPS 0
+#define LINKEVENT_LINKSPEED_ENCODED 1
+
+/* firmware response header:
+ * 63:58 - message type
+ * 57:56 - owner
+ * 55:53 - desc count
+ * 52:48 - reserved
+ * 47:40 - completion id
+ * 39:32 - opcode
+ * 31:16 - error code
+ * 15:00 - reserved
+ */
+#define netxen_get_nic_msgtype(msg_hdr) \
+ ((msg_hdr >> 58) & 0x3F)
+#define netxen_get_nic_msg_compid(msg_hdr) \
+ ((msg_hdr >> 40) & 0xFF)
+#define netxen_get_nic_msg_opcode(msg_hdr) \
+ ((msg_hdr >> 32) & 0xFF)
+#define netxen_get_nic_msg_errcode(msg_hdr) \
+ ((msg_hdr >> 16) & 0xFFFF)
+
+typedef struct {
+ union {
+ struct {
+ u64 hdr;
+ u64 body[7];
+ };
+ u64 words[8];
+ };
+} nx_fw_msg_t;
+
typedef struct {
__le64 qhdr;
__le64 req_hdr;
@@ -1218,99 +1213,96 @@ struct netxen_adapter {
struct net_device *netdev;
struct pci_dev *pdev;
- int pci_using_dac;
- struct net_device_stats net_stats;
- int mtu;
- int portnum;
- u8 physical_port;
- u16 tx_context_id;
-
- uint8_t mc_enabled;
- uint8_t max_mc_count;
- nx_mac_list_t *mac_list;
-
- struct netxen_legacy_intr_set legacy_intr;
-
- struct work_struct watchdog_task;
- struct timer_list watchdog_timer;
- struct work_struct tx_timeout_task;
+ struct list_head mac_list;
u32 curr_window;
u32 crb_win;
rwlock_t adapter_lock;
- u32 cmd_producer;
- __le32 *cmd_consumer;
- u32 last_cmd_consumer;
- u32 crb_addr_cmd_producer;
- u32 crb_addr_cmd_consumer;
spinlock_t tx_clean_lock;
- u32 num_txd;
- u32 num_rxd;
- u32 num_jumbo_rxd;
- u32 num_lro_rxd;
+ u16 num_txd;
+ u16 num_rxd;
+ u16 num_jumbo_rxd;
+ u16 num_lro_rxd;
+
+ u8 max_rds_rings;
+ u8 max_sds_rings;
+ u8 driver_mismatch;
+ u8 msix_supported;
+ u8 rx_csum;
+ u8 pci_using_dac;
+ u8 portnum;
+ u8 physical_port;
+
+ u8 mc_enabled;
+ u8 max_mc_count;
+ u8 rss_supported;
+ u8 resv2;
+ u32 resv3;
+
+ u8 has_link_events;
+ u8 resv1;
+ u16 tx_context_id;
+ u16 mtu;
+ u16 is_up;
- int max_rds_rings;
- int max_sds_rings;
+ u16 link_speed;
+ u16 link_duplex;
+ u16 link_autoneg;
+ u16 module_type;
+ u32 capabilities;
u32 flags;
u32 irq;
- int driver_mismatch;
u32 temp;
- u32 fw_major;
- u32 fw_version;
-
- int msix_supported;
- struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER];
+ u32 msi_tgt_status;
+ u32 resv4;
struct netxen_adapter_stats stats;
- u16 link_speed;
- u16 link_duplex;
- u16 state;
- u16 link_autoneg;
- int rx_csum;
-
- struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */
-
- /*
- * Receive instances. These can be either one per port,
- * or one per peg, etc.
- */
struct netxen_recv_context recv_ctx;
+ struct nx_host_tx_ring *tx_ring;
- int is_up;
- struct netxen_dummy_dma dummy_dma;
- nx_nic_intr_coalesce_t coal;
-
- /* Context interface shared between card and host */
- struct netxen_ring_ctx *ctx_desc;
- dma_addr_t ctx_desc_phys_addr;
- int intr_scheme;
- int msi_mode;
int (*enable_phy_interrupts) (struct netxen_adapter *);
int (*disable_phy_interrupts) (struct netxen_adapter *);
- int (*macaddr_set) (struct netxen_adapter *, netxen_ethernet_macaddr_t);
+ int (*macaddr_set) (struct netxen_adapter *, u8 *);
int (*set_mtu) (struct netxen_adapter *, int);
int (*set_promisc) (struct netxen_adapter *, u32);
+ void (*set_multi) (struct net_device *);
int (*phy_read) (struct netxen_adapter *, long reg, u32 *);
int (*phy_write) (struct netxen_adapter *, long reg, u32 val);
int (*init_port) (struct netxen_adapter *, int);
int (*stop_port) (struct netxen_adapter *);
- int (*hw_read_wx)(struct netxen_adapter *, ulong, void *, int);
- int (*hw_write_wx)(struct netxen_adapter *, ulong, void *, int);
+ u32 (*hw_read_wx)(struct netxen_adapter *, ulong);
+ int (*hw_write_wx)(struct netxen_adapter *, ulong, u32);
int (*pci_mem_read)(struct netxen_adapter *, u64, void *, int);
int (*pci_mem_write)(struct netxen_adapter *, u64, void *, int);
int (*pci_write_immediate)(struct netxen_adapter *, u64, u32);
u32 (*pci_read_immediate)(struct netxen_adapter *, u64);
- void (*pci_write_normalize)(struct netxen_adapter *, u64, u32);
- u32 (*pci_read_normalize)(struct netxen_adapter *, u64);
unsigned long (*pci_set_window)(struct netxen_adapter *,
unsigned long long);
-}; /* netxen_adapter structure */
+
+ struct netxen_legacy_intr_set legacy_intr;
+
+ struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER];
+
+ struct netxen_dummy_dma dummy_dma;
+
+ struct work_struct watchdog_task;
+ struct timer_list watchdog_timer;
+ struct work_struct tx_timeout_task;
+
+ struct net_device_stats net_stats;
+
+ nx_nic_intr_coalesce_t coal;
+
+ u32 fw_major;
+ u32 fw_version;
+ const struct firmware *fw;
+};
/*
* NetXen dma watchdog control structure
@@ -1330,46 +1322,6 @@ struct netxen_adapter {
#define netxen_get_dma_watchdog_disabled(config_word) \
(((config_word) >> 1) & 0x1)
-/* Max number of xmit producer threads that can run simultaneously */
-#define MAX_XMIT_PRODUCERS 16
-
-#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
- ((adapter)->ahw.pci_base0 + (off))
-#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
- ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
-#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
- ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
-
-static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
- unsigned long off)
-{
- if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
- return (adapter->ahw.pci_base0 + off);
- } else if ((off < SECOND_PAGE_GROUP_END) &&
- (off >= SECOND_PAGE_GROUP_START)) {
- return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
- } else if ((off < THIRD_PAGE_GROUP_END) &&
- (off >= THIRD_PAGE_GROUP_START)) {
- return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
- }
- return NULL;
-}
-
-static inline void __iomem *pci_base(struct netxen_adapter *adapter,
- unsigned long off)
-{
- if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
- return adapter->ahw.pci_base0;
- } else if ((off < SECOND_PAGE_GROUP_END) &&
- (off >= SECOND_PAGE_GROUP_START)) {
- return adapter->ahw.pci_base1;
- } else if ((off < THIRD_PAGE_GROUP_END) &&
- (off >= THIRD_PAGE_GROUP_START)) {
- return adapter->ahw.pci_base2;
- }
- return NULL;
-}
-
int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
@@ -1382,21 +1334,22 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
/* Functions available from netxen_nic_hw.c */
int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
-void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
-int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
-void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
-void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 *value);
-void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value);
-void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value);
+
+int netxen_p2_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr);
+int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr);
+
+#define NXRD32(adapter, off) \
+ (adapter->hw_read_wx(adapter, off))
+#define NXWR32(adapter, off, val) \
+ (adapter->hw_write_wx(adapter, off, val))
int netxen_nic_get_board_info(struct netxen_adapter *adapter);
void netxen_nic_get_firmware_info(struct netxen_adapter *adapter);
int netxen_nic_wol_supported(struct netxen_adapter *adapter);
-int netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter,
- ulong off, void *data, int len);
+u32 netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off);
int netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
- ulong off, void *data, int len);
+ ulong off, u32 data);
int netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
u64 off, void *data, int size);
int netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
@@ -1412,16 +1365,13 @@ unsigned long netxen_nic_pci_set_window_128M(struct netxen_adapter *adapter,
void netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter,
u32 wndw);
-int netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter,
- ulong off, void *data, int len);
+u32 netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off);
int netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
- ulong off, void *data, int len);
+ ulong off, u32 data);
int netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
u64 off, void *data, int size);
int netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
u64 off, void *data, int size);
-void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
- unsigned long off, int data);
int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter,
u64 off, u32 data);
u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off);
@@ -1435,8 +1385,9 @@ unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
void netxen_free_adapter_offload(struct netxen_adapter *adapter);
int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
-int netxen_receive_peg_ready(struct netxen_adapter *adapter);
int netxen_load_firmware(struct netxen_adapter *adapter);
+void netxen_request_firmware(struct netxen_adapter *adapter);
+void netxen_release_firmware(struct netxen_adapter *adapter);
int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
@@ -1475,6 +1426,8 @@ void netxen_p3_free_mac_list(struct netxen_adapter *adapter);
int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32);
int netxen_config_intr_coalesce(struct netxen_adapter *adapter);
int netxen_config_rss(struct netxen_adapter *adapter, int enable);
+int netxen_linkevent_request(struct netxen_adapter *adapter, int enable);
+void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup);
int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu);
int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
@@ -1483,7 +1436,7 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p);
struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
- uint32_t crb_producer);
+ struct nx_host_tx_ring *tx_ring, uint32_t crb_producer);
/*
* NetXen Board information
@@ -1491,7 +1444,7 @@ void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
#define NETXEN_MAX_SHORT_NAME 32
struct netxen_brdinfo {
- netxen_brdtype_t brdtype; /* type of board */
+ int brdtype; /* type of board */
long ports; /* max no of physical ports */
char short_name[NETXEN_MAX_SHORT_NAME];
};
@@ -1541,17 +1494,15 @@ dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
u32 ctrl;
/* check if already inactive */
- if (adapter->hw_read_wx(adapter,
- NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
- printk(KERN_ERR "failed to read dma watchdog status\n");
+ ctrl = adapter->hw_read_wx(adapter,
+ NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
return 1;
/* Send the disable request */
netxen_set_dma_watchdog_disable_req(ctrl);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+ NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
return 0;
}
@@ -1561,9 +1512,8 @@ dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
{
u32 ctrl;
- if (adapter->hw_read_wx(adapter,
- NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
- printk(KERN_ERR "failed to read dma watchdog status\n");
+ ctrl = adapter->hw_read_wx(adapter,
+ NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
}
@@ -1573,9 +1523,8 @@ dma_watchdog_wakeup(struct netxen_adapter *adapter)
{
u32 ctrl;
- if (adapter->hw_read_wx(adapter,
- NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
- printk(KERN_ERR "failed to read dma watchdog status\n");
+ ctrl = adapter->hw_read_wx(adapter,
+ NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
if (netxen_get_dma_watchdog_enabled(ctrl))
return 1;
@@ -1583,8 +1532,7 @@ dma_watchdog_wakeup(struct netxen_adapter *adapter)
/* send the wakeup request */
netxen_set_dma_watchdog_enable_req(ctrl);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+ NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
return 0;
}
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index 9234473bc08a..4754f5cffad0 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -41,8 +41,7 @@ netxen_api_lock(struct netxen_adapter *adapter)
for (;;) {
/* Acquire PCIE HW semaphore5 */
- netxen_nic_read_w0(adapter,
- NETXEN_PCIE_REG(PCIE_SEM5_LOCK), &done);
+ done = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM5_LOCK));
if (done == 1)
break;
@@ -56,7 +55,7 @@ netxen_api_lock(struct netxen_adapter *adapter)
}
#if 0
- netxen_nic_write_w1(adapter,
+ NXWR32(adapter,
NETXEN_API_LOCK_ID, NX_OS_API_LOCK_DRIVER);
#endif
return 0;
@@ -65,11 +64,8 @@ netxen_api_lock(struct netxen_adapter *adapter)
static int
netxen_api_unlock(struct netxen_adapter *adapter)
{
- u32 val;
-
/* Release PCIE HW semaphore5 */
- netxen_nic_read_w0(adapter,
- NETXEN_PCIE_REG(PCIE_SEM5_UNLOCK), &val);
+ NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM5_UNLOCK));
return 0;
}
@@ -86,7 +82,7 @@ netxen_poll_rsp(struct netxen_adapter *adapter)
if (++timeout > NX_OS_CRB_RETRY_COUNT)
return NX_CDRP_RSP_TIMEOUT;
- netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET, &rsp);
+ rsp = NXRD32(adapter, NX_CDRP_CRB_OFFSET);
} while (!NX_CDRP_IS_RSP(rsp));
return rsp;
@@ -106,16 +102,15 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
if (netxen_api_lock(adapter))
return NX_RCODE_TIMEOUT;
- netxen_nic_write_w1(adapter, NX_SIGN_CRB_OFFSET, signature);
+ NXWR32(adapter, NX_SIGN_CRB_OFFSET, signature);
- netxen_nic_write_w1(adapter, NX_ARG1_CRB_OFFSET, arg1);
+ NXWR32(adapter, NX_ARG1_CRB_OFFSET, arg1);
- netxen_nic_write_w1(adapter, NX_ARG2_CRB_OFFSET, arg2);
+ NXWR32(adapter, NX_ARG2_CRB_OFFSET, arg2);
- netxen_nic_write_w1(adapter, NX_ARG3_CRB_OFFSET, arg3);
+ NXWR32(adapter, NX_ARG3_CRB_OFFSET, arg3);
- netxen_nic_write_w1(adapter, NX_CDRP_CRB_OFFSET,
- NX_CDRP_FORM_CMD(cmd));
+ NXWR32(adapter, NX_CDRP_CRB_OFFSET, NX_CDRP_FORM_CMD(cmd));
rsp = netxen_poll_rsp(adapter);
@@ -125,7 +120,7 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
rcode = NX_RCODE_TIMEOUT;
} else if (rsp == NX_CDRP_RSP_FAIL) {
- netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET, &rcode);
+ rcode = NXRD32(adapter, NX_ARG1_CRB_OFFSET);
printk(KERN_ERR "%s: failed card response code:0x%x\n",
netxen_nic_driver_name, rcode);
@@ -328,6 +323,8 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
int err = 0;
u64 offset, phys_addr;
dma_addr_t rq_phys_addr, rsp_phys_addr;
+ struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
+ struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
rq_size = SIZEOF_HOSTRQ_TX(nx_hostrq_tx_ctx_t);
rq_addr = pci_alloc_consistent(adapter->pdev,
@@ -362,15 +359,13 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
prq->dummy_dma_addr = cpu_to_le64(adapter->dummy_dma.phys_addr);
- offset = adapter->ctx_desc_phys_addr+sizeof(struct netxen_ring_ctx);
+ offset = recv_ctx->phys_addr + sizeof(struct netxen_ring_ctx);
prq->cmd_cons_dma_addr = cpu_to_le64(offset);
prq_cds = &prq->cds_ring;
- prq_cds->host_phys_addr =
- cpu_to_le64(adapter->ahw.cmd_desc_phys_addr);
-
- prq_cds->ring_size = cpu_to_le32(adapter->num_txd);
+ prq_cds->host_phys_addr = cpu_to_le64(tx_ring->phys_addr);
+ prq_cds->ring_size = cpu_to_le32(tx_ring->num_desc);
phys_addr = rq_phys_addr;
err = netxen_issue_cmd(adapter,
@@ -383,8 +378,7 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
if (err == NX_RCODE_SUCCESS) {
temp = le32_to_cpu(prsp->cds_ring.host_producer_crb);
- adapter->crb_addr_cmd_producer =
- NETXEN_NIC_REG(temp - 0x200);
+ tx_ring->crb_cmd_producer = NETXEN_NIC_REG(temp - 0x200);
#if 0
adapter->tx_state =
le32_to_cpu(prsp->host_ctx_state);
@@ -448,7 +442,19 @@ static struct netxen_recv_crb recv_crb_registers[] = {
NETXEN_NIC_REG(0x120)
},
/* crb_sts_consumer: */
- NETXEN_NIC_REG(0x138),
+ {
+ NETXEN_NIC_REG(0x138),
+ NETXEN_NIC_REG_2(0x000),
+ NETXEN_NIC_REG_2(0x004),
+ NETXEN_NIC_REG_2(0x008),
+ },
+ /* sw_int_mask */
+ {
+ CRB_SW_INT_MASK_0,
+ NETXEN_NIC_REG_2(0x044),
+ NETXEN_NIC_REG_2(0x048),
+ NETXEN_NIC_REG_2(0x04c),
+ },
},
/* Instance 1 */
{
@@ -461,7 +467,19 @@ static struct netxen_recv_crb recv_crb_registers[] = {
NETXEN_NIC_REG(0x164)
},
/* crb_sts_consumer: */
- NETXEN_NIC_REG(0x17c),
+ {
+ NETXEN_NIC_REG(0x17c),
+ NETXEN_NIC_REG_2(0x020),
+ NETXEN_NIC_REG_2(0x024),
+ NETXEN_NIC_REG_2(0x028),
+ },
+ /* sw_int_mask */
+ {
+ CRB_SW_INT_MASK_1,
+ NETXEN_NIC_REG_2(0x064),
+ NETXEN_NIC_REG_2(0x068),
+ NETXEN_NIC_REG_2(0x06c),
+ },
},
/* Instance 2 */
{
@@ -474,7 +492,19 @@ static struct netxen_recv_crb recv_crb_registers[] = {
NETXEN_NIC_REG(0x208)
},
/* crb_sts_consumer: */
- NETXEN_NIC_REG(0x220),
+ {
+ NETXEN_NIC_REG(0x220),
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ },
+ /* sw_int_mask */
+ {
+ CRB_SW_INT_MASK_2,
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ },
},
/* Instance 3 */
{
@@ -487,7 +517,19 @@ static struct netxen_recv_crb recv_crb_registers[] = {
NETXEN_NIC_REG(0x24c)
},
/* crb_sts_consumer: */
- NETXEN_NIC_REG(0x264),
+ {
+ NETXEN_NIC_REG(0x264),
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ },
+ /* sw_int_mask */
+ {
+ CRB_SW_INT_MASK_3,
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ NETXEN_NIC_REG_2(0x03c),
+ },
},
};
@@ -497,84 +539,91 @@ netxen_init_old_ctx(struct netxen_adapter *adapter)
struct netxen_recv_context *recv_ctx;
struct nx_host_rds_ring *rds_ring;
struct nx_host_sds_ring *sds_ring;
+ struct nx_host_tx_ring *tx_ring;
int ring;
- int func_id = adapter->portnum;
-
- adapter->ctx_desc->cmd_ring_addr =
- cpu_to_le64(adapter->ahw.cmd_desc_phys_addr);
- adapter->ctx_desc->cmd_ring_size =
- cpu_to_le32(adapter->num_txd);
+ int port = adapter->portnum;
+ struct netxen_ring_ctx *hwctx;
+ u32 signature;
+ tx_ring = adapter->tx_ring;
recv_ctx = &adapter->recv_ctx;
+ hwctx = recv_ctx->hwctx;
+
+ hwctx->cmd_ring_addr = cpu_to_le64(tx_ring->phys_addr);
+ hwctx->cmd_ring_size = cpu_to_le32(tx_ring->num_desc);
+
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
rds_ring = &recv_ctx->rds_rings[ring];
- adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr =
+ hwctx->rcv_rings[ring].addr =
cpu_to_le64(rds_ring->phys_addr);
- adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size =
+ hwctx->rcv_rings[ring].size =
cpu_to_le32(rds_ring->num_desc);
}
- sds_ring = &recv_ctx->sds_rings[0];
- adapter->ctx_desc->sts_ring_addr = cpu_to_le64(sds_ring->phys_addr);
- adapter->ctx_desc->sts_ring_size = cpu_to_le32(sds_ring->num_desc);
-
- adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id),
- lower32(adapter->ctx_desc_phys_addr));
- adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_HI(func_id),
- upper32(adapter->ctx_desc_phys_addr));
- adapter->pci_write_normalize(adapter, CRB_CTX_SIGNATURE_REG(func_id),
- NETXEN_CTX_SIGNATURE | func_id);
+
+ for (ring = 0; ring < adapter->max_sds_rings; ring++) {
+ sds_ring = &recv_ctx->sds_rings[ring];
+
+ if (ring == 0) {
+ hwctx->sts_ring_addr = cpu_to_le64(sds_ring->phys_addr);
+ hwctx->sts_ring_size = cpu_to_le32(sds_ring->num_desc);
+ }
+ hwctx->sts_rings[ring].addr = cpu_to_le64(sds_ring->phys_addr);
+ hwctx->sts_rings[ring].size = cpu_to_le32(sds_ring->num_desc);
+ hwctx->sts_rings[ring].msi_index = cpu_to_le16(ring);
+ }
+ hwctx->sts_ring_count = cpu_to_le32(adapter->max_sds_rings);
+
+ signature = (adapter->max_sds_rings > 1) ?
+ NETXEN_CTX_SIGNATURE_V2 : NETXEN_CTX_SIGNATURE;
+
+ NXWR32(adapter, CRB_CTX_ADDR_REG_LO(port),
+ lower32(recv_ctx->phys_addr));
+ NXWR32(adapter, CRB_CTX_ADDR_REG_HI(port),
+ upper32(recv_ctx->phys_addr));
+ NXWR32(adapter, CRB_CTX_SIGNATURE_REG(port),
+ signature | port);
return 0;
}
-static uint32_t sw_int_mask[4] = {
- CRB_SW_INT_MASK_0, CRB_SW_INT_MASK_1,
- CRB_SW_INT_MASK_2, CRB_SW_INT_MASK_3
-};
-
int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
{
- struct netxen_hardware_context *hw = &adapter->ahw;
- u32 state = 0;
void *addr;
int err = 0;
int ring;
struct netxen_recv_context *recv_ctx;
struct nx_host_rds_ring *rds_ring;
struct nx_host_sds_ring *sds_ring;
+ struct nx_host_tx_ring *tx_ring;
struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev;
+ int port = adapter->portnum;
- err = netxen_receive_peg_ready(adapter);
- if (err) {
- printk(KERN_ERR "Rcv Peg initialization not complete:%x.\n",
- state);
- return err;
- }
+ recv_ctx = &adapter->recv_ctx;
+ tx_ring = adapter->tx_ring;
addr = pci_alloc_consistent(pdev,
sizeof(struct netxen_ring_ctx) + sizeof(uint32_t),
- &adapter->ctx_desc_phys_addr);
-
+ &recv_ctx->phys_addr);
if (addr == NULL) {
dev_err(&pdev->dev, "failed to allocate hw context\n");
return -ENOMEM;
}
+
memset(addr, 0, sizeof(struct netxen_ring_ctx));
- adapter->ctx_desc = (struct netxen_ring_ctx *)addr;
- adapter->ctx_desc->ctx_id = cpu_to_le32(adapter->portnum);
- adapter->ctx_desc->cmd_consumer_offset =
- cpu_to_le64(adapter->ctx_desc_phys_addr +
+ recv_ctx->hwctx = (struct netxen_ring_ctx *)addr;
+ recv_ctx->hwctx->ctx_id = cpu_to_le32(port);
+ recv_ctx->hwctx->cmd_consumer_offset =
+ cpu_to_le64(recv_ctx->phys_addr +
sizeof(struct netxen_ring_ctx));
- adapter->cmd_consumer =
+ tx_ring->hw_consumer =
(__le32 *)(((char *)addr) + sizeof(struct netxen_ring_ctx));
/* cmd desc ring */
- addr = pci_alloc_consistent(pdev,
- TX_DESC_RINGSIZE(adapter),
- &hw->cmd_desc_phys_addr);
+ addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring),
+ &tx_ring->phys_addr);
if (addr == NULL) {
dev_err(&pdev->dev, "%s: failed to allocate tx desc ring\n",
@@ -582,9 +631,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
return -ENOMEM;
}
- hw->cmd_desc_head = (struct cmd_desc_type0 *)addr;
-
- recv_ctx = &adapter->recv_ctx;
+ tx_ring->desc_head = (struct cmd_desc_type0 *)addr;
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
rds_ring = &recv_ctx->rds_rings[ring];
@@ -602,8 +649,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
if (adapter->fw_major < 4)
rds_ring->crb_rcv_producer =
- recv_crb_registers[adapter->portnum].
- crb_rcv_producer[ring];
+ recv_crb_registers[port].crb_rcv_producer[ring];
}
for (ring = 0; ring < adapter->max_sds_rings; ring++) {
@@ -620,13 +666,16 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
goto err_out_free;
}
sds_ring->desc_head = (struct status_desc *)addr;
+
+ sds_ring->crb_sts_consumer =
+ recv_crb_registers[port].crb_sts_consumer[ring];
+
+ sds_ring->crb_intr_mask =
+ recv_crb_registers[port].sw_int_mask[ring];
}
if (adapter->fw_major >= 4) {
- adapter->intr_scheme = INTR_SCHEME_PERPORT;
- adapter->msi_mode = MSI_MODE_MULTIFUNC;
-
err = nx_fw_cmd_create_rx_ctx(adapter);
if (err)
goto err_out_free;
@@ -634,23 +683,11 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
if (err)
goto err_out_free;
} else {
- sds_ring = &recv_ctx->sds_rings[0];
- sds_ring->crb_sts_consumer =
- recv_crb_registers[adapter->portnum].crb_sts_consumer;
-
- adapter->intr_scheme = adapter->pci_read_normalize(adapter,
- CRB_NIC_CAPABILITIES_FW);
- adapter->msi_mode = adapter->pci_read_normalize(adapter,
- CRB_NIC_MSI_MODE_FW);
- recv_ctx->sds_rings[0].crb_intr_mask =
- sw_int_mask[adapter->portnum];
-
err = netxen_init_old_ctx(adapter);
if (err) {
netxen_free_hw_resources(adapter);
return err;
}
-
}
return 0;
@@ -665,32 +702,40 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
struct netxen_recv_context *recv_ctx;
struct nx_host_rds_ring *rds_ring;
struct nx_host_sds_ring *sds_ring;
+ struct nx_host_tx_ring *tx_ring;
int ring;
+ int port = adapter->portnum;
+
if (adapter->fw_major >= 4) {
nx_fw_cmd_destroy_tx_ctx(adapter);
nx_fw_cmd_destroy_rx_ctx(adapter);
+ } else {
+ netxen_api_lock(adapter);
+ NXWR32(adapter, CRB_CTX_SIGNATURE_REG(port),
+ NETXEN_CTX_RESET | port);
+ netxen_api_unlock(adapter);
}
- if (adapter->ctx_desc != NULL) {
+ recv_ctx = &adapter->recv_ctx;
+
+ if (recv_ctx->hwctx != NULL) {
pci_free_consistent(adapter->pdev,
sizeof(struct netxen_ring_ctx) +
sizeof(uint32_t),
- adapter->ctx_desc,
- adapter->ctx_desc_phys_addr);
- adapter->ctx_desc = NULL;
+ recv_ctx->hwctx,
+ recv_ctx->phys_addr);
+ recv_ctx->hwctx = NULL;
}
- if (adapter->ahw.cmd_desc_head != NULL) {
+ tx_ring = adapter->tx_ring;
+ if (tx_ring->desc_head != NULL) {
pci_free_consistent(adapter->pdev,
- sizeof(struct cmd_desc_type0) *
- adapter->num_txd,
- adapter->ahw.cmd_desc_head,
- adapter->ahw.cmd_desc_phys_addr);
- adapter->ahw.cmd_desc_head = NULL;
+ TX_DESC_RINGSIZE(tx_ring),
+ tx_ring->desc_head, tx_ring->phys_addr);
+ tx_ring->desc_head = NULL;
}
- recv_ctx = &adapter->recv_ctx;
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
rds_ring = &recv_ctx->rds_rings[ring];
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index a677ff895184..e16ea46c24b8 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -30,7 +30,6 @@
#include <linux/types.h>
#include <linux/delay.h>
-#include <asm/uaccess.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <linux/netdevice.h>
@@ -53,13 +52,9 @@ struct netxen_nic_stats {
#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
- {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)},
{"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)},
- {"xmited_frames", NETXEN_NIC_STAT(stats.xmitedframes)},
{"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)},
- {"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)},
- {"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)},
- {"polled", NETXEN_NIC_STAT(stats.polled)},
+ {"rx_dropped", NETXEN_NIC_STAT(stats.rxdropped)},
{"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
{"csummed", NETXEN_NIC_STAT(stats.csummed)},
{"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
@@ -97,12 +92,9 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
write_lock_irqsave(&adapter->adapter_lock, flags);
- fw_major = adapter->pci_read_normalize(adapter,
- NETXEN_FW_VERSION_MAJOR);
- fw_minor = adapter->pci_read_normalize(adapter,
- NETXEN_FW_VERSION_MINOR);
- fw_build = adapter->pci_read_normalize(adapter,
- NETXEN_FW_VERSION_SUB);
+ fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
+ fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
+ fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
write_unlock_irqrestore(&adapter->adapter_lock, flags);
sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
@@ -115,6 +107,7 @@ static int
netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
{
struct netxen_adapter *adapter = netdev_priv(dev);
+ int check_sfp_module = 0;
/* read which mode */
if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
@@ -139,7 +132,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
} else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
u32 val;
- adapter->hw_read_wx(adapter, NETXEN_PORT_MODE_ADDR, &val, 4);
+ val = NXRD32(adapter, NETXEN_PORT_MODE_ADDR);
if (val == NETXEN_PORT_MODE_802_3_AP) {
ecmd->supported = SUPPORTED_1000baseT_Full;
ecmd->advertising = ADVERTISED_1000baseT_Full;
@@ -148,13 +141,19 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
ecmd->advertising = ADVERTISED_10000baseT_Full;
}
+ if (netif_running(dev) && adapter->has_link_events) {
+ ecmd->speed = adapter->link_speed;
+ ecmd->autoneg = adapter->link_autoneg;
+ ecmd->duplex = adapter->link_duplex;
+ goto skip;
+ }
+
ecmd->port = PORT_TP;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
u16 pcifn = adapter->ahw.pci_func;
- adapter->hw_read_wx(adapter,
- P3_LINK_SPEED_REG(pcifn), &val, 4);
+ val = NXRD32(adapter, P3_LINK_SPEED_REG(pcifn));
ecmd->speed = P3_LINK_SPEED_MHZ *
P3_LINK_SPEED_VAL(pcifn, val);
} else
@@ -165,10 +164,11 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
} else
return -EIO;
+skip:
ecmd->phy_address = adapter->physical_port;
ecmd->transceiver = XCVR_EXTERNAL;
- switch ((netxen_brdtype_t)adapter->ahw.board_type) {
+ switch (adapter->ahw.board_type) {
case NETXEN_BRDTYPE_P2_SB35_4G:
case NETXEN_BRDTYPE_P2_SB31_2G:
case NETXEN_BRDTYPE_P3_REF_QG:
@@ -195,7 +195,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
case NETXEN_BRDTYPE_P3_HMEZ:
ecmd->supported |= SUPPORTED_MII;
ecmd->advertising |= ADVERTISED_MII;
- ecmd->port = PORT_FIBRE;
+ ecmd->port = PORT_MII;
ecmd->autoneg = AUTONEG_DISABLE;
break;
case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
@@ -203,6 +203,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
case NETXEN_BRDTYPE_P3_10G_SFP_QT:
ecmd->advertising |= ADVERTISED_TP;
ecmd->supported |= SUPPORTED_TP;
+ check_sfp_module = netif_running(dev) &&
+ adapter->has_link_events;
case NETXEN_BRDTYPE_P2_SB31_10G:
case NETXEN_BRDTYPE_P3_10G_XFP:
ecmd->supported |= SUPPORTED_FIBRE;
@@ -217,6 +219,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
ecmd->advertising |=
(ADVERTISED_FIBRE | ADVERTISED_TP);
ecmd->port = PORT_FIBRE;
+ check_sfp_module = netif_running(dev) &&
+ adapter->has_link_events;
} else {
ecmd->autoneg = AUTONEG_ENABLE;
ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg);
@@ -227,10 +231,28 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
break;
default:
printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
- (netxen_brdtype_t)adapter->ahw.board_type);
+ adapter->ahw.board_type);
return -EIO;
}
+ if (check_sfp_module) {
+ switch (adapter->module_type) {
+ case LINKEVENT_MODULE_OPTICAL_UNKNOWN:
+ case LINKEVENT_MODULE_OPTICAL_SRLR:
+ case LINKEVENT_MODULE_OPTICAL_LRM:
+ case LINKEVENT_MODULE_OPTICAL_SFP_1G:
+ ecmd->port = PORT_FIBRE;
+ break;
+ case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE:
+ case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN:
+ case LINKEVENT_MODULE_TWINAX:
+ ecmd->port = PORT_TP;
+ break;
+ default:
+ ecmd->port = -1;
+ }
+ }
+
return 0;
}
@@ -398,12 +420,11 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
(adapter->pdev)->device;
/* which mode */
- adapter->hw_read_wx(adapter, NETXEN_NIU_MODE, &regs_buff[0], 4);
+ regs_buff[0] = NXRD32(adapter, NETXEN_NIU_MODE);
mode = regs_buff[0];
/* Common registers to all the modes */
- adapter->hw_read_wx(adapter,
- NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER, &regs_buff[2], 4);
+ regs_buff[2] = NXRD32(adapter, NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER);
/* GB/XGB Mode */
mode = (mode / 2) - 1;
window = 0;
@@ -414,9 +435,8 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
window = adapter->physical_port *
NETXEN_NIC_PORT_WINDOW;
- adapter->hw_read_wx(adapter,
- niu_registers[mode].reg[i - 3] + window,
- &regs_buff[i], 4);
+ regs_buff[i] = NXRD32(adapter,
+ niu_registers[mode].reg[i - 3] + window);
}
}
@@ -440,7 +460,7 @@ static u32 netxen_nic_test_link(struct net_device *dev)
return !val;
}
} else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
- val = adapter->pci_read_normalize(adapter, CRB_XG_STATE);
+ val = NXRD32(adapter, CRB_XG_STATE);
return (val == XG_LINK_UP) ? 0 : 1;
}
return -EIO;
@@ -504,10 +524,9 @@ netxen_nic_get_pauseparam(struct net_device *dev,
if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
return;
/* get flow control settings */
- netxen_nic_read_w0(adapter,NETXEN_NIU_GB_MAC_CONFIG_0(port),
- &val);
+ val = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port));
pause->rx_pause = netxen_gb_get_rx_flowctl(val);
- netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val);
+ val = NXRD32(adapter, NETXEN_NIU_GB_PAUSE_CTL);
switch (port) {
case 0:
pause->tx_pause = !(netxen_gb_get_gb0_mask(val));
@@ -527,7 +546,7 @@ netxen_nic_get_pauseparam(struct net_device *dev,
if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
return;
pause->rx_pause = 1;
- netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val);
+ val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL);
if (port == 0)
pause->tx_pause = !(netxen_xg_get_xg0_mask(val));
else
@@ -550,18 +569,17 @@ netxen_nic_set_pauseparam(struct net_device *dev,
if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
return -EIO;
/* set flow control */
- netxen_nic_read_w0(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(port), &val);
+ val = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port));
if (pause->rx_pause)
netxen_gb_rx_flowctl(val);
else
netxen_gb_unset_rx_flowctl(val);
- netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
val);
/* set autoneg */
- netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val);
+ val = NXRD32(adapter, NETXEN_NIU_GB_PAUSE_CTL);
switch (port) {
case 0:
if (pause->tx_pause)
@@ -589,11 +607,11 @@ netxen_nic_set_pauseparam(struct net_device *dev,
netxen_gb_set_gb3_mask(val);
break;
}
- netxen_nic_write_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, val);
+ NXWR32(adapter, NETXEN_NIU_GB_PAUSE_CTL, val);
} else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
return -EIO;
- netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val);
+ val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL);
if (port == 0) {
if (pause->tx_pause)
netxen_xg_unset_xg0_mask(val);
@@ -605,7 +623,7 @@ netxen_nic_set_pauseparam(struct net_device *dev,
else
netxen_xg_set_xg1_mask(val);
}
- netxen_nic_write_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, val);
+ NXWR32(adapter, NETXEN_NIU_XG_PAUSE_CTL, val);
} else {
printk(KERN_ERR "%s: Unknown board type: %x\n",
netxen_nic_driver_name,
@@ -619,14 +637,14 @@ static int netxen_nic_reg_test(struct net_device *dev)
struct netxen_adapter *adapter = netdev_priv(dev);
u32 data_read, data_written;
- netxen_nic_read_w0(adapter, NETXEN_PCIX_PH_REG(0), &data_read);
+ data_read = NXRD32(adapter, NETXEN_PCIX_PH_REG(0));
if ((data_read & 0xffff) != PHAN_VENDOR_ID)
return 1;
data_written = (u32)0xa5a5a5a5;
- netxen_nic_reg_write(adapter, CRB_SCRATCHPAD_TEST, data_written);
- data_read = adapter->pci_read_normalize(adapter, CRB_SCRATCHPAD_TEST);
+ NXWR32(adapter, CRB_SCRATCHPAD_TEST, data_written);
+ data_read = NXRD32(adapter, CRB_SCRATCHPAD_TEST);
if (data_written != data_read)
return 1;
@@ -743,11 +761,11 @@ netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
return;
- wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+ wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV);
if (wol_cfg & (1UL << adapter->portnum))
wol->supported |= WAKE_MAGIC;
- wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+ wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG);
if (wol_cfg & (1UL << adapter->portnum))
wol->wolopts |= WAKE_MAGIC;
}
@@ -764,16 +782,16 @@ netxen_nic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
if (wol->wolopts & ~WAKE_MAGIC)
return -EOPNOTSUPP;
- wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+ wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV);
if (!(wol_cfg & (1 << adapter->portnum)))
return -EOPNOTSUPP;
- wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+ wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG);
if (wol->wolopts & WAKE_MAGIC)
wol_cfg |= 1UL << adapter->portnum;
else
wol_cfg &= ~(1UL << adapter->portnum);
- netxen_nic_reg_write(adapter, NETXEN_WOL_CONFIG, wol_cfg);
+ NXWR32(adapter, NETXEN_WOL_CONFIG, wol_cfg);
return 0;
}
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 016c62129c76..7f0ddbfa7b28 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -31,16 +31,8 @@
#ifndef __NETXEN_NIC_HDR_H_
#define __NETXEN_NIC_HDR_H_
-#include <linux/module.h>
#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <asm/irq.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
#include <linux/types.h>
-#include <asm/uaccess.h>
-#include <asm/string.h> /* for memset */
/*
* The basic unit of access when reading/writing control registers.
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 5026811c04ce..42ffb825ebf1 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -32,7 +32,6 @@
#include "netxen_nic_hw.h"
#include "netxen_nic_phan_reg.h"
-#include <linux/firmware.h>
#include <net/ip.h>
#define MASK(n) ((1ULL<<(n))-1)
@@ -48,8 +47,49 @@
#define CRB_HI(off) ((crb_hub_agt[CRB_BLK(off)] << 20) | ((off) & 0xf0000))
#define CRB_INDIRECT_2M (0x1e0000UL)
+#ifndef readq
+static inline u64 readq(void __iomem *addr)
+{
+ return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
+}
+#endif
+
+#ifndef writeq
+static inline void writeq(u64 val, void __iomem *addr)
+{
+ writel(((u32) (val)), (addr));
+ writel(((u32) (val >> 32)), (addr + 4));
+}
+#endif
+
+#define ADDR_IN_RANGE(addr, low, high) \
+ (((addr) < (high)) && ((addr) >= (low)))
+
+#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
+ ((adapter)->ahw.pci_base0 + (off))
+#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
+ ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
+#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
+ ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
+
+static void __iomem *pci_base_offset(struct netxen_adapter *adapter,
+ unsigned long off)
+{
+ if (ADDR_IN_RANGE(off, FIRST_PAGE_GROUP_START, FIRST_PAGE_GROUP_END))
+ return PCI_OFFSET_FIRST_RANGE(adapter, off);
+
+ if (ADDR_IN_RANGE(off, SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_END))
+ return PCI_OFFSET_SECOND_RANGE(adapter, off);
+
+ if (ADDR_IN_RANGE(off, THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_END))
+ return PCI_OFFSET_THIRD_RANGE(adapter, off);
+
+ return NULL;
+}
+
#define CRB_WIN_LOCK_TIMEOUT 100000000
-static crb_128M_2M_block_map_t crb_128M_2M_map[64] = {
+static crb_128M_2M_block_map_t
+crb_128M_2M_map[64] __cacheline_aligned_in_smp = {
{{{0, 0, 0, 0} } }, /* 0: PCI */
{{{1, 0x0100000, 0x0102000, 0x120000}, /* 1: PCIE */
{1, 0x0110000, 0x0120000, 0x130000},
@@ -279,39 +319,8 @@ static unsigned crb_hub_agt[64] =
/* PCI Windowing for DDR regions. */
-#define ADDR_IN_RANGE(addr, low, high) \
- (((addr) <= (high)) && ((addr) >= (low)))
-
#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
-#define NETXEN_NIC_ZERO_PAUSE_ADDR 0ULL
-#define NETXEN_NIC_UNIT_PAUSE_ADDR 0x200ULL
-#define NETXEN_NIC_EPG_PAUSE_ADDR1 0x2200010000c28001ULL
-#define NETXEN_NIC_EPG_PAUSE_ADDR2 0x0100088866554433ULL
-
-#define NETXEN_NIC_WINDOW_MARGIN 0x100000
-
-int netxen_nic_set_mac(struct net_device *netdev, void *p)
-{
- struct netxen_adapter *adapter = netdev_priv(netdev);
- struct sockaddr *addr = p;
-
- if (netif_running(netdev))
- return -EBUSY;
-
- if (!is_valid_ether_addr(addr->sa_data))
- return -EADDRNOTAVAIL;
-
- memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
-
- /* For P3, MAC addr is not set in NIU */
- if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
- if (adapter->macaddr_set)
- adapter->macaddr_set(adapter, addr->sa_data);
-
- return 0;
-}
-
#define NETXEN_UNICAST_ADDR(port, index) \
(NETXEN_UNICAST_ADDR_BASE+(port*32)+(index*8))
#define NETXEN_MCAST_ADDR(port, index) \
@@ -331,22 +340,20 @@ netxen_nic_enable_mcast_filter(struct netxen_adapter *adapter)
if (adapter->mc_enabled)
return 0;
- adapter->hw_read_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4);
+ val = NXRD32(adapter, NETXEN_MAC_ADDR_CNTL_REG);
val |= (1UL << (28+port));
- adapter->hw_write_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4);
+ NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
/* add broadcast addr to filter */
val = 0xffffff;
- netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_UNICAST_ADDR(port, 0)+4, val);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0)+4, val);
/* add station addr to filter */
val = MAC_HI(addr);
- netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 1), val);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1), val);
val = MAC_LO(addr);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_UNICAST_ADDR(port, 1)+4, val);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, val);
adapter->mc_enabled = 1;
return 0;
@@ -362,18 +369,17 @@ netxen_nic_disable_mcast_filter(struct netxen_adapter *adapter)
if (!adapter->mc_enabled)
return 0;
- adapter->hw_read_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4);
+ val = NXRD32(adapter, NETXEN_MAC_ADDR_CNTL_REG);
val &= ~(1UL << (28+port));
- adapter->hw_write_wx(adapter, NETXEN_MAC_ADDR_CNTL_REG, &val, 4);
+ NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
val = MAC_HI(addr);
- netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0), val);
val = MAC_LO(addr);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_UNICAST_ADDR(port, 0)+4, val);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0)+4, val);
- netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 1), 0);
- netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, 0);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1), 0);
+ NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, 0);
adapter->mc_enabled = 0;
return 0;
@@ -389,10 +395,8 @@ netxen_nic_set_mcast_addr(struct netxen_adapter *adapter,
lo = MAC_LO(addr);
hi = MAC_HI(addr);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_MCAST_ADDR(port, index), hi);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_MCAST_ADDR(port, index)+4, lo);
+ NXWR32(adapter, NETXEN_MCAST_ADDR(port, index), hi);
+ NXWR32(adapter, NETXEN_MCAST_ADDR(port, index)+4, lo);
return 0;
}
@@ -445,100 +449,58 @@ void netxen_p2_nic_set_multi(struct net_device *netdev)
netxen_nic_set_mcast_addr(adapter, index, null_addr);
}
-static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
- u8 *addr, nx_mac_list_t **add_list, nx_mac_list_t **del_list)
-{
- nx_mac_list_t *cur, *prev;
-
- /* if in del_list, move it to adapter->mac_list */
- for (cur = *del_list, prev = NULL; cur;) {
- if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0) {
- if (prev == NULL)
- *del_list = cur->next;
- else
- prev->next = cur->next;
- cur->next = adapter->mac_list;
- adapter->mac_list = cur;
- return 0;
- }
- prev = cur;
- cur = cur->next;
- }
-
- /* make sure to add each mac address only once */
- for (cur = adapter->mac_list; cur; cur = cur->next) {
- if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0)
- return 0;
- }
- /* not in del_list, create new entry and add to add_list */
- cur = kmalloc(sizeof(*cur), in_atomic()? GFP_ATOMIC : GFP_KERNEL);
- if (cur == NULL) {
- printk(KERN_ERR "%s: cannot allocate memory. MAC filtering may"
- "not work properly from now.\n", __func__);
- return -1;
- }
-
- memcpy(cur->mac_addr, addr, ETH_ALEN);
- cur->next = *add_list;
- *add_list = cur;
- return 0;
-}
-
static int
netxen_send_cmd_descs(struct netxen_adapter *adapter,
- struct cmd_desc_type0 *cmd_desc_arr, int nr_elements)
+ struct cmd_desc_type0 *cmd_desc_arr, int nr_desc)
{
- uint32_t i, producer;
+ u32 i, producer, consumer;
struct netxen_cmd_buffer *pbuf;
struct cmd_desc_type0 *cmd_desc;
-
- if (nr_elements > MAX_PENDING_DESC_BLOCK_SIZE || nr_elements == 0) {
- printk(KERN_WARNING "%s: Too many command descriptors in a "
- "request\n", __func__);
- return -EINVAL;
- }
+ struct nx_host_tx_ring *tx_ring;
i = 0;
+ tx_ring = adapter->tx_ring;
netif_tx_lock_bh(adapter->netdev);
- producer = adapter->cmd_producer;
+ producer = tx_ring->producer;
+ consumer = tx_ring->sw_consumer;
+
+ if (nr_desc >= find_diff_among(producer, consumer, tx_ring->num_desc)) {
+ netif_tx_unlock_bh(adapter->netdev);
+ return -EBUSY;
+ }
+
do {
cmd_desc = &cmd_desc_arr[i];
- pbuf = &adapter->cmd_buf_arr[producer];
+ pbuf = &tx_ring->cmd_buf_arr[producer];
pbuf->skb = NULL;
pbuf->frag_count = 0;
- /* adapter->ahw.cmd_desc_head[producer] = *cmd_desc; */
- memcpy(&adapter->ahw.cmd_desc_head[producer],
+ memcpy(&tx_ring->desc_head[producer],
&cmd_desc_arr[i], sizeof(struct cmd_desc_type0));
- producer = get_next_index(producer,
- adapter->num_txd);
+ producer = get_next_index(producer, tx_ring->num_desc);
i++;
- } while (i != nr_elements);
-
- adapter->cmd_producer = producer;
+ } while (i != nr_desc);
- /* write producer index to start the xmit */
+ tx_ring->producer = producer;
- netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer);
+ netxen_nic_update_cmd_producer(adapter, tx_ring, producer);
netif_tx_unlock_bh(adapter->netdev);
return 0;
}
-static int nx_p3_sre_macaddr_change(struct net_device *dev,
- u8 *addr, unsigned op)
+static int
+nx_p3_sre_macaddr_change(struct netxen_adapter *adapter, u8 *addr, unsigned op)
{
- struct netxen_adapter *adapter = netdev_priv(dev);
nx_nic_req_t req;
nx_mac_req_t *mac_req;
u64 word;
- int rv;
memset(&req, 0, sizeof(nx_nic_req_t));
req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
@@ -550,28 +512,51 @@ static int nx_p3_sre_macaddr_change(struct net_device *dev,
mac_req->op = op;
memcpy(mac_req->mac_addr, addr, 6);
- rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
- if (rv != 0) {
- printk(KERN_ERR "ERROR. Could not send mac update\n");
- return rv;
+ return netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
+}
+
+static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
+ u8 *addr, struct list_head *del_list)
+{
+ struct list_head *head;
+ nx_mac_list_t *cur;
+
+ /* look up if already exists */
+ list_for_each(head, del_list) {
+ cur = list_entry(head, nx_mac_list_t, list);
+
+ if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0) {
+ list_move_tail(head, &adapter->mac_list);
+ return 0;
+ }
}
- return 0;
+ cur = kzalloc(sizeof(nx_mac_list_t), GFP_ATOMIC);
+ if (cur == NULL) {
+ printk(KERN_ERR "%s: failed to add mac address filter\n",
+ adapter->netdev->name);
+ return -ENOMEM;
+ }
+ memcpy(cur->mac_addr, addr, ETH_ALEN);
+ list_add_tail(&cur->list, &adapter->mac_list);
+ return nx_p3_sre_macaddr_change(adapter,
+ cur->mac_addr, NETXEN_MAC_ADD);
}
void netxen_p3_nic_set_multi(struct net_device *netdev)
{
struct netxen_adapter *adapter = netdev_priv(netdev);
- nx_mac_list_t *cur, *next, *del_list, *add_list = NULL;
struct dev_mc_list *mc_ptr;
u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
u32 mode = VPORT_MISS_MODE_DROP;
+ LIST_HEAD(del_list);
+ struct list_head *head;
+ nx_mac_list_t *cur;
- del_list = adapter->mac_list;
- adapter->mac_list = NULL;
+ list_splice_tail_init(&adapter->mac_list, &del_list);
- nx_p3_nic_add_mac(adapter, netdev->dev_addr, &add_list, &del_list);
- nx_p3_nic_add_mac(adapter, bcast_addr, &add_list, &del_list);
+ nx_p3_nic_add_mac(adapter, netdev->dev_addr, &del_list);
+ nx_p3_nic_add_mac(adapter, bcast_addr, &del_list);
if (netdev->flags & IFF_PROMISC) {
mode = VPORT_MISS_MODE_ACCEPT_ALL;
@@ -587,25 +572,20 @@ void netxen_p3_nic_set_multi(struct net_device *netdev)
if (netdev->mc_count > 0) {
for (mc_ptr = netdev->mc_list; mc_ptr;
mc_ptr = mc_ptr->next) {
- nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr,
- &add_list, &del_list);
+ nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr, &del_list);
}
}
send_fw_cmd:
adapter->set_promisc(adapter, mode);
- for (cur = del_list; cur;) {
- nx_p3_sre_macaddr_change(netdev, cur->mac_addr, NETXEN_MAC_DEL);
- next = cur->next;
+ head = &del_list;
+ while (!list_empty(head)) {
+ cur = list_entry(head->next, nx_mac_list_t, list);
+
+ nx_p3_sre_macaddr_change(adapter,
+ cur->mac_addr, NETXEN_MAC_DEL);
+ list_del(&cur->list);
kfree(cur);
- cur = next;
- }
- for (cur = add_list; cur;) {
- nx_p3_sre_macaddr_change(netdev, cur->mac_addr, NETXEN_MAC_ADD);
- next = cur->next;
- cur->next = adapter->mac_list;
- adapter->mac_list = cur;
- cur = next;
}
}
@@ -630,17 +610,25 @@ int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
void netxen_p3_free_mac_list(struct netxen_adapter *adapter)
{
- nx_mac_list_t *cur, *next;
-
- cur = adapter->mac_list;
-
- while (cur) {
- next = cur->next;
+ nx_mac_list_t *cur;
+ struct list_head *head = &adapter->mac_list;
+
+ while (!list_empty(head)) {
+ cur = list_entry(head->next, nx_mac_list_t, list);
+ nx_p3_sre_macaddr_change(adapter,
+ cur->mac_addr, NETXEN_MAC_DEL);
+ list_del(&cur->list);
kfree(cur);
- cur = next;
}
}
+int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr)
+{
+ /* assuming caller has already copied new addr to netdev */
+ netxen_p3_nic_set_multi(adapter->netdev);
+ return 0;
+}
+
#define NETXEN_CONFIG_INTR_COALESCE 3
/*
@@ -717,6 +705,28 @@ int netxen_config_rss(struct netxen_adapter *adapter, int enable)
return rv;
}
+int netxen_linkevent_request(struct netxen_adapter *adapter, int enable)
+{
+ nx_nic_req_t req;
+ u64 word;
+ int rv;
+
+ memset(&req, 0, sizeof(nx_nic_req_t));
+ req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
+
+ word = NX_NIC_H2C_OPCODE_GET_LINKEVENT | ((u64)adapter->portnum << 16);
+ req.req_hdr = cpu_to_le64(word);
+ req.words[0] = cpu_to_le64(enable | (enable << 8));
+
+ rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
+ if (rv != 0) {
+ printk(KERN_ERR "%s: could not configure link notification\n",
+ adapter->netdev->name);
+ }
+
+ return rv;
+}
+
/*
* netxen_nic_change_mtu - Change the Maximum Transfer Unit
* @returns 0 on success, negative on failure
@@ -812,8 +822,8 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac)
crbaddr = CRB_MAC_BLOCK_START +
(4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1));
- adapter->hw_read_wx(adapter, crbaddr, &mac_lo, 4);
- adapter->hw_read_wx(adapter, crbaddr+4, &mac_hi, 4);
+ mac_lo = NXRD32(adapter, crbaddr);
+ mac_hi = NXRD32(adapter, crbaddr+4);
if (pci_func & 1)
*mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
@@ -831,8 +841,7 @@ static int crb_win_lock(struct netxen_adapter *adapter)
while (!done) {
/* acquire semaphore3 from PCI HW block */
- adapter->hw_read_wx(adapter,
- NETXEN_PCIE_REG(PCIE_SEM7_LOCK), &done, 4);
+ done = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM7_LOCK));
if (done == 1)
break;
if (timeout >= CRB_WIN_LOCK_TIMEOUT)
@@ -840,8 +849,7 @@ static int crb_win_lock(struct netxen_adapter *adapter)
timeout++;
udelay(1);
}
- netxen_crb_writelit_adapter(adapter,
- NETXEN_CRB_WIN_LOCK_ID, adapter->portnum);
+ NXWR32(adapter, NETXEN_CRB_WIN_LOCK_ID, adapter->portnum);
return 0;
}
@@ -849,8 +857,7 @@ static void crb_win_unlock(struct netxen_adapter *adapter)
{
int val;
- adapter->hw_read_wx(adapter,
- NETXEN_PCIE_REG(PCIE_SEM7_UNLOCK), &val, 4);
+ val = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM7_UNLOCK));
}
/*
@@ -907,17 +914,15 @@ netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter, u32 wndw)
* In: 'off' is offset from base in 128M pci map
*/
static int
-netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter,
- ulong *off, int len)
+netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter, ulong *off)
{
- unsigned long end = *off + len;
crb_128M_2M_sub_block_map_t *m;
if (*off >= NETXEN_CRB_MAX)
return -1;
- if (*off >= NETXEN_PCI_CAMQM && (end <= NETXEN_PCI_CAMQM_2M_END)) {
+ if (*off >= NETXEN_PCI_CAMQM && (*off < NETXEN_PCI_CAMQM_2M_END)) {
*off = (*off - NETXEN_PCI_CAMQM) + NETXEN_PCI_CAMQM_2M_BASE +
(ulong)adapter->ahw.pci_base0;
return 0;
@@ -927,14 +932,13 @@ netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter,
return -1;
*off -= NETXEN_PCI_CRBSPACE;
- end = *off + len;
/*
* Try direct map
*/
m = &crb_128M_2M_map[CRB_BLK(*off)].sub_block[CRB_SUBBLK(*off)];
- if (m->valid && (m->start_128M <= *off) && (m->end_128M >= end)) {
+ if (m->valid && (m->start_128M <= *off) && (m->end_128M > *off)) {
*off = *off + m->start_2M - m->start_128M +
(ulong)adapter->ahw.pci_base0;
return 0;
@@ -972,214 +976,11 @@ netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong *off)
(ulong)adapter->ahw.pci_base0;
}
-static int
-netxen_do_load_firmware(struct netxen_adapter *adapter, const char *fwname,
- const struct firmware *fw)
-{
- u64 *ptr64;
- u32 i, flashaddr, size;
- struct pci_dev *pdev = adapter->pdev;
-
- if (fw)
- dev_info(&pdev->dev, "loading firmware from file %s\n", fwname);
- else
- dev_info(&pdev->dev, "loading firmware from flash\n");
-
- if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
- adapter->pci_write_normalize(adapter,
- NETXEN_ROMUSB_GLB_CAS_RST, 1);
-
- if (fw) {
- __le64 data;
-
- size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START) / 8;
-
- ptr64 = (u64 *)&fw->data[NETXEN_BOOTLD_START];
- flashaddr = NETXEN_BOOTLD_START;
-
- for (i = 0; i < size; i++) {
- data = cpu_to_le64(ptr64[i]);
- adapter->pci_mem_write(adapter, flashaddr, &data, 8);
- flashaddr += 8;
- }
-
- size = *(u32 *)&fw->data[NX_FW_SIZE_OFFSET];
- size = (__force u32)cpu_to_le32(size) / 8;
-
- ptr64 = (u64 *)&fw->data[NETXEN_IMAGE_START];
- flashaddr = NETXEN_IMAGE_START;
-
- for (i = 0; i < size; i++) {
- data = cpu_to_le64(ptr64[i]);
-
- if (adapter->pci_mem_write(adapter,
- flashaddr, &data, 8))
- return -EIO;
-
- flashaddr += 8;
- }
- } else {
- u32 data;
-
- size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START) / 4;
- flashaddr = NETXEN_BOOTLD_START;
-
- for (i = 0; i < size; i++) {
- if (netxen_rom_fast_read(adapter,
- flashaddr, (int *)&data) != 0)
- return -EIO;
-
- if (adapter->pci_mem_write(adapter,
- flashaddr, &data, 4))
- return -EIO;
-
- flashaddr += 4;
- }
- }
- msleep(1);
-
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
- adapter->pci_write_normalize(adapter,
- NETXEN_ROMUSB_GLB_SW_RESET, 0x80001d);
- else {
- adapter->pci_write_normalize(adapter,
- NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL, 0x3fff);
- adapter->pci_write_normalize(adapter,
- NETXEN_ROMUSB_GLB_CAS_RST, 0);
- }
-
- return 0;
-}
-
-static int
-netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname,
- const struct firmware *fw)
-{
- __le32 val;
- u32 major, minor, build, ver, min_ver, bios;
- struct pci_dev *pdev = adapter->pdev;
-
- if (fw->size < NX_FW_MIN_SIZE)
- return -EINVAL;
-
- val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_MAGIC_OFFSET]);
- if ((__force u32)val != NETXEN_BDINFO_MAGIC)
- return -EINVAL;
-
- val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
- major = (__force u32)val & 0xff;
- minor = ((__force u32)val >> 8) & 0xff;
- build = (__force u32)val >> 16;
-
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
- min_ver = NETXEN_VERSION_CODE(4, 0, 216);
- else
- min_ver = NETXEN_VERSION_CODE(3, 4, 216);
-
- ver = NETXEN_VERSION_CODE(major, minor, build);
-
- if ((major > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) {
- dev_err(&pdev->dev,
- "%s: firmware version %d.%d.%d unsupported\n",
- fwname, major, minor, build);
- return -EINVAL;
- }
-
- val = cpu_to_le32(*(u32 *)&fw->data[NX_BIOS_VERSION_OFFSET]);
- netxen_rom_fast_read(adapter, NX_BIOS_VERSION_OFFSET, (int *)&bios);
- if ((__force u32)val != bios) {
- dev_err(&pdev->dev, "%s: firmware bios is incompatible\n",
- fwname);
- return -EINVAL;
- }
-
- /* check if flashed firmware is newer */
- if (netxen_rom_fast_read(adapter,
- NX_FW_VERSION_OFFSET, (int *)&val))
- return -EIO;
- major = (__force u32)val & 0xff;
- minor = ((__force u32)val >> 8) & 0xff;
- build = (__force u32)val >> 16;
- if (NETXEN_VERSION_CODE(major, minor, build) > ver)
- return -EINVAL;
-
- netxen_nic_reg_write(adapter, NETXEN_CAM_RAM(0x1fc),
- NETXEN_BDINFO_MAGIC);
- return 0;
-}
-
-static char *fw_name[] = { "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin" };
-
-int netxen_load_firmware(struct netxen_adapter *adapter)
-{
- u32 capability, flashed_ver;
- const struct firmware *fw;
- int fw_type;
- struct pci_dev *pdev = adapter->pdev;
- int rc = 0;
-
- if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
- fw_type = NX_P2_MN_ROMIMAGE;
- goto request_fw;
- } else {
- fw_type = NX_P3_CT_ROMIMAGE;
- goto request_fw;
- }
-
-request_mn:
- capability = 0;
-
- netxen_rom_fast_read(adapter,
- NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
- if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
- adapter->hw_read_wx(adapter,
- NX_PEG_TUNE_CAPABILITY, &capability, 4);
- if (capability & NX_PEG_TUNE_MN_PRESENT) {
- fw_type = NX_P3_MN_ROMIMAGE;
- goto request_fw;
- }
- }
-
-request_fw:
- rc = request_firmware(&fw, fw_name[fw_type], &pdev->dev);
- if (rc != 0) {
- if (fw_type == NX_P3_CT_ROMIMAGE) {
- msleep(1);
- goto request_mn;
- }
-
- fw = NULL;
- goto load_fw;
- }
-
- rc = netxen_validate_firmware(adapter, fw_name[fw_type], fw);
- if (rc != 0) {
- release_firmware(fw);
-
- if (fw_type == NX_P3_CT_ROMIMAGE) {
- msleep(1);
- goto request_mn;
- }
-
- fw = NULL;
- }
-
-load_fw:
- rc = netxen_do_load_firmware(adapter, fw_name[fw_type], fw);
-
- if (fw)
- release_firmware(fw);
- return rc;
-}
-
int
-netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
- ulong off, void *data, int len)
+netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data)
{
void __iomem *addr;
- BUG_ON(len != 4);
-
if (ADDR_IN_WINDOW1(off)) {
addr = NETXEN_CRB_NORMALIZE(adapter, off);
} else { /* Window 0 */
@@ -1192,7 +993,7 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
return 1;
}
- writel(*(u32 *) data, addr);
+ writel(data, addr);
if (!ADDR_IN_WINDOW1(off))
netxen_nic_pci_change_crbwindow_128M(adapter, 1);
@@ -1200,13 +1001,11 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
return 0;
}
-int
-netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter,
- ulong off, void *data, int len)
+u32
+netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off)
{
void __iomem *addr;
-
- BUG_ON(len != 4);
+ u32 data;
if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
addr = NETXEN_CRB_NORMALIZE(adapter, off);
@@ -1220,24 +1019,21 @@ netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter,
return 1;
}
- *(u32 *)data = readl(addr);
+ data = readl(addr);
if (!ADDR_IN_WINDOW1(off))
netxen_nic_pci_change_crbwindow_128M(adapter, 1);
- return 0;
+ return data;
}
int
-netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
- ulong off, void *data, int len)
+netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, ulong off, u32 data)
{
unsigned long flags = 0;
int rv;
- BUG_ON(len != 4);
-
- rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off, len);
+ rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off);
if (rv == -1) {
printk(KERN_ERR "%s: invalid offset: 0x%016lx\n",
@@ -1250,26 +1046,24 @@ netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
write_lock_irqsave(&adapter->adapter_lock, flags);
crb_win_lock(adapter);
netxen_nic_pci_set_crbwindow_2M(adapter, &off);
- writel(*(uint32_t *)data, (void __iomem *)off);
+ writel(data, (void __iomem *)off);
crb_win_unlock(adapter);
write_unlock_irqrestore(&adapter->adapter_lock, flags);
} else
- writel(*(uint32_t *)data, (void __iomem *)off);
+ writel(data, (void __iomem *)off);
return 0;
}
-int
-netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter,
- ulong off, void *data, int len)
+u32
+netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off)
{
unsigned long flags = 0;
int rv;
+ u32 data;
- BUG_ON(len != 4);
-
- rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off, len);
+ rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off);
if (rv == -1) {
printk(KERN_ERR "%s: invalid offset: 0x%016lx\n",
@@ -1282,47 +1076,13 @@ netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter,
write_lock_irqsave(&adapter->adapter_lock, flags);
crb_win_lock(adapter);
netxen_nic_pci_set_crbwindow_2M(adapter, &off);
- *(uint32_t *)data = readl((void __iomem *)off);
+ data = readl((void __iomem *)off);
crb_win_unlock(adapter);
write_unlock_irqrestore(&adapter->adapter_lock, flags);
} else
- *(uint32_t *)data = readl((void __iomem *)off);
-
- return 0;
-}
+ data = readl((void __iomem *)off);
-void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
-{
- adapter->hw_write_wx(adapter, off, &val, 4);
-}
-
-int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off)
-{
- int val;
- adapter->hw_read_wx(adapter, off, &val, 4);
- return val;
-}
-
-/* Change the window to 0, write and change back to window 1. */
-void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value)
-{
- adapter->hw_write_wx(adapter, index, &value, 4);
-}
-
-/* Change the window to 0, read and change back to window 1. */
-void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 *value)
-{
- adapter->hw_read_wx(adapter, index, value, 4);
-}
-
-void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value)
-{
- adapter->hw_write_wx(adapter, index, &value, 4);
-}
-
-void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value)
-{
- adapter->hw_read_wx(adapter, index, value, 4);
+ return data;
}
/*
@@ -1425,17 +1185,6 @@ u32 netxen_nic_pci_read_immediate_128M(struct netxen_adapter *adapter, u64 off)
return readl((void __iomem *)(pci_base_offset(adapter, off)));
}
-void netxen_nic_pci_write_normalize_128M(struct netxen_adapter *adapter,
- u64 off, u32 data)
-{
- writel(data, NETXEN_CRB_NORMALIZE(adapter, off));
-}
-
-u32 netxen_nic_pci_read_normalize_128M(struct netxen_adapter *adapter, u64 off)
-{
- return readl(NETXEN_CRB_NORMALIZE(adapter, off));
-}
-
unsigned long
netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
unsigned long long addr)
@@ -1447,12 +1196,10 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
/* DDR network side */
window = MN_WIN(addr);
adapter->ahw.ddr_mn_window = window;
- adapter->hw_write_wx(adapter,
- adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
- &window, 4);
- adapter->hw_read_wx(adapter,
- adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
- &win_read, 4);
+ NXWR32(adapter, adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
+ window);
+ win_read = NXRD32(adapter,
+ adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE);
if ((win_read << 17) != window) {
printk(KERN_INFO "Written MNwin (0x%x) != "
"Read MNwin (0x%x)\n", window, win_read);
@@ -1467,12 +1214,10 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
window = OCM_WIN(addr);
adapter->ahw.ddr_mn_window = window;
- adapter->hw_write_wx(adapter,
- adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
- &window, 4);
- adapter->hw_read_wx(adapter,
- adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
- &win_read, 4);
+ NXWR32(adapter, adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE,
+ window);
+ win_read = NXRD32(adapter,
+ adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE);
if ((win_read >> 7) != window) {
printk(KERN_INFO "%s: Written OCMwin (0x%x) != "
"Read OCMwin (0x%x)\n",
@@ -1485,12 +1230,10 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
/* QDR network side */
window = MS_WIN(addr);
adapter->ahw.qdr_sn_window = window;
- adapter->hw_write_wx(adapter,
- adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE,
- &window, 4);
- adapter->hw_read_wx(adapter,
- adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE,
- &win_read, 4);
+ NXWR32(adapter, adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE,
+ window);
+ win_read = NXRD32(adapter,
+ adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE);
if (win_read != window) {
printk(KERN_INFO "%s: Written MSwin (0x%x) != "
"Read MSwin (0x%x)\n",
@@ -1936,27 +1679,20 @@ netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
for (i = 0; i < loop; i++) {
temp = off8 + (i << 3);
- adapter->hw_write_wx(adapter,
- mem_crb+MIU_TEST_AGT_ADDR_LO, &temp, 4);
+ NXWR32(adapter, mem_crb+MIU_TEST_AGT_ADDR_LO, temp);
temp = 0;
- adapter->hw_write_wx(adapter,
- mem_crb+MIU_TEST_AGT_ADDR_HI, &temp, 4);
+ NXWR32(adapter, mem_crb+MIU_TEST_AGT_ADDR_HI, temp);
temp = word[i] & 0xffffffff;
- adapter->hw_write_wx(adapter,
- mem_crb+MIU_TEST_AGT_WRDATA_LO, &temp, 4);
+ NXWR32(adapter, mem_crb+MIU_TEST_AGT_WRDATA_LO, temp);
temp = (word[i] >> 32) & 0xffffffff;
- adapter->hw_write_wx(adapter,
- mem_crb+MIU_TEST_AGT_WRDATA_HI, &temp, 4);
+ NXWR32(adapter, mem_crb+MIU_TEST_AGT_WRDATA_HI, temp);
temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
- adapter->hw_write_wx(adapter,
- mem_crb+MIU_TEST_AGT_CTRL, &temp, 4);
+ NXWR32(adapter, mem_crb+MIU_TEST_AGT_CTRL, temp);
temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
- adapter->hw_write_wx(adapter,
- mem_crb+MIU_TEST_AGT_CTRL, &temp, 4);
+ NXWR32(adapter, mem_crb+MIU_TEST_AGT_CTRL, temp);
for (j = 0; j < MAX_CTL_CHECK; j++) {
- adapter->hw_read_wx(adapter,
- mem_crb + MIU_TEST_AGT_CTRL, &temp, 4);
+ temp = NXRD32(adapter, mem_crb + MIU_TEST_AGT_CTRL);
if ((temp & MIU_TA_CTL_BUSY) == 0)
break;
}
@@ -2013,21 +1749,16 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
for (i = 0; i < loop; i++) {
temp = off8 + (i << 3);
- adapter->hw_write_wx(adapter,
- mem_crb + MIU_TEST_AGT_ADDR_LO, &temp, 4);
+ NXWR32(adapter, mem_crb + MIU_TEST_AGT_ADDR_LO, temp);
temp = 0;
- adapter->hw_write_wx(adapter,
- mem_crb + MIU_TEST_AGT_ADDR_HI, &temp, 4);
+ NXWR32(adapter, mem_crb + MIU_TEST_AGT_ADDR_HI, temp);
temp = MIU_TA_CTL_ENABLE;
- adapter->hw_write_wx(adapter,
- mem_crb + MIU_TEST_AGT_CTRL, &temp, 4);
+ NXWR32(adapter, mem_crb + MIU_TEST_AGT_CTRL, temp);
temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE;
- adapter->hw_write_wx(adapter,
- mem_crb + MIU_TEST_AGT_CTRL, &temp, 4);
+ NXWR32(adapter, mem_crb + MIU_TEST_AGT_CTRL, temp);
for (j = 0; j < MAX_CTL_CHECK; j++) {
- adapter->hw_read_wx(adapter,
- mem_crb + MIU_TEST_AGT_CTRL, &temp, 4);
+ temp = NXRD32(adapter, mem_crb + MIU_TEST_AGT_CTRL);
if ((temp & MIU_TA_CTL_BUSY) == 0)
break;
}
@@ -2042,8 +1773,8 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
start = off0[i] >> 2;
end = (off0[i] + sz[i] - 1) >> 2;
for (k = start; k <= end; k++) {
- adapter->hw_read_wx(adapter,
- mem_crb + MIU_TEST_AGT_RDDATA(k), &temp, 4);
+ temp = NXRD32(adapter,
+ mem_crb + MIU_TEST_AGT_RDDATA(k));
word[i] |= ((uint64_t)temp << (32 * k));
}
}
@@ -2086,29 +1817,14 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter,
u64 off, u32 data)
{
- adapter->hw_write_wx(adapter, off, &data, 4);
+ NXWR32(adapter, off, data);
return 0;
}
u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off)
{
- u32 temp;
- adapter->hw_read_wx(adapter, off, &temp, 4);
- return temp;
-}
-
-void netxen_nic_pci_write_normalize_2M(struct netxen_adapter *adapter,
- u64 off, u32 data)
-{
- adapter->hw_write_wx(adapter, off, &data, 4);
-}
-
-u32 netxen_nic_pci_read_normalize_2M(struct netxen_adapter *adapter, u64 off)
-{
- u32 temp;
- adapter->hw_read_wx(adapter, off, &temp, 4);
- return temp;
+ return NXRD32(adapter, off);
}
int netxen_nic_get_board_info(struct netxen_adapter *adapter)
@@ -2142,13 +1858,12 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
adapter->ahw.board_type = board_type;
if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) {
- u32 gpio = netxen_nic_reg_read(adapter,
- NETXEN_ROMUSB_GLB_PAD_GPIO_I);
+ u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I);
if ((gpio & 0x8000) == 0)
board_type = NETXEN_BRDTYPE_P3_10G_TP;
}
- switch ((netxen_brdtype_t)board_type) {
+ switch (board_type) {
case NETXEN_BRDTYPE_P2_SB35_4G:
adapter->ahw.port_type = NETXEN_NIC_GBE;
break;
@@ -2195,8 +1910,7 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu)
{
new_mtu += MTU_FUDGE_FACTOR;
- netxen_nic_write_w0(adapter,
- NETXEN_NIU_GB_MAX_FRAME_SIZE(adapter->physical_port),
+ NXWR32(adapter, NETXEN_NIU_GB_MAX_FRAME_SIZE(adapter->physical_port),
new_mtu);
return 0;
}
@@ -2205,21 +1919,12 @@ int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu)
{
new_mtu += MTU_FUDGE_FACTOR;
if (adapter->physical_port == 0)
- netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE,
- new_mtu);
+ NXWR32(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu);
else
- netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE,
- new_mtu);
+ NXWR32(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu);
return 0;
}
-void
-netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
- unsigned long off, int data)
-{
- adapter->hw_write_wx(adapter, off, &data, 4);
-}
-
void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
{
__u32 status;
@@ -2234,8 +1939,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
}
if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
- adapter->hw_read_wx(adapter,
- NETXEN_PORT_MODE_ADDR, &port_mode, 4);
+ port_mode = NXRD32(adapter, NETXEN_PORT_MODE_ADDR);
if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
adapter->link_speed = SPEED_1000;
adapter->link_duplex = DUPLEX_FULL;
@@ -2312,9 +2016,9 @@ void netxen_nic_get_firmware_info(struct netxen_adapter *adapter)
addr += sizeof(u32);
}
- adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MAJOR, &fw_major, 4);
- adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MINOR, &fw_minor, 4);
- adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4);
+ fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
+ fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
+ fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
adapter->fw_major = fw_major;
adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build);
@@ -2337,8 +2041,7 @@ void netxen_nic_get_firmware_info(struct netxen_adapter *adapter)
fw_major, fw_minor, fw_build);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
- adapter->hw_read_wx(adapter,
- NETXEN_MIU_MN_CONTROL, &i, 4);
+ i = NXRD32(adapter, NETXEN_MIU_MN_CONTROL);
adapter->ahw.cut_through = (i & 0x4) ? 1 : 0;
dev_info(&pdev->dev, "firmware running in %s mode\n",
adapter->ahw.cut_through ? "cut-through" : "legacy");
@@ -2353,9 +2056,9 @@ netxen_nic_wol_supported(struct netxen_adapter *adapter)
if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
return 0;
- wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+ wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV);
if (wol_cfg & (1UL << adapter->portnum)) {
- wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+ wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG);
if (wol_cfg & (1 << adapter->portnum))
return 1;
}
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h
index 04b47a7993cd..d4e833339781 100644
--- a/drivers/net/netxen/netxen_nic_hw.h
+++ b/drivers/net/netxen/netxen_nic_hw.h
@@ -36,35 +36,13 @@
/* Hardware memory size of 128 meg */
#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
-#ifndef readq
-static inline u64 readq(void __iomem * addr)
-{
- return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
-}
-#endif
-
-#ifndef writeq
-static inline void writeq(u64 val, void __iomem * addr)
-{
- writel(((u32) (val)), (addr));
- writel(((u32) (val >> 32)), (addr + 4));
-}
-#endif
-
struct netxen_adapter;
#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
-struct netxen_port;
void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
-typedef u8 netxen_ethernet_macaddr_t[6];
-
/* Nibble or Byte mode for phy interface (GbE mode only) */
-typedef enum {
- NETXEN_NIU_10_100_MB = 0,
- NETXEN_NIU_1000_MB
-} netxen_niu_gbe_ifmode_t;
#define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
@@ -222,30 +200,28 @@ typedef enum {
/*
* PHY-Specific MII control/status registers.
*/
-typedef enum {
- NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL = 0,
- NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS = 1,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 = 2,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 = 3,
- NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG = 4,
- NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART = 5,
- NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE = 6,
- NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT = 7,
- NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE = 8,
- NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL = 9,
- NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS = 10,
- NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS = 15,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL = 16,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS = 17,
- NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE = 18,
- NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS = 19,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE = 20,
- NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT = 21,
- NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL = 24,
- NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE = 25,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET = 26,
- NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE = 27
-} netxen_niu_phy_register_t;
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL 0
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS 1
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 2
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 3
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG 4
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART 5
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE 6
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT 7
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE 8
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL 9
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS 10
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS 15
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL 16
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS 17
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE 18
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS 19
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE 20
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT 21
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL 24
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE 25
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET 26
+#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE 27
/*
* PHY-Specific Status Register (reg 17).
@@ -417,14 +393,6 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
u32 mode);
-/* set the MAC address for a given MAC */
-int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
- netxen_ethernet_macaddr_t addr);
-
-/* XG version */
-int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
- netxen_ethernet_macaddr_t addr);
-
/* Generic enable for GbE ports. Will detect the speed of the link. */
int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 0759c35f16ac..4a51c31330da 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -108,42 +108,6 @@ static void crb_addr_transform_setup(void)
crb_addr_transform(I2C0);
}
-int netxen_init_firmware(struct netxen_adapter *adapter)
-{
- u32 state = 0, loops = 0, err = 0;
-
- /* Window 1 call */
- state = adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE);
-
- if (state == PHAN_INITIALIZE_ACK)
- return 0;
-
- while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
- msleep(1);
- /* Window 1 call */
- state = adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE);
-
- loops++;
- }
- if (loops >= 2000) {
- printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
- state);
- err = -EIO;
- return err;
- }
- /* Window 1 call */
- adapter->pci_write_normalize(adapter,
- CRB_NIC_CAPABILITIES_HOST, INTR_SCHEME_PERPORT);
- adapter->pci_write_normalize(adapter,
- CRB_NIC_MSI_MODE_HOST, MSI_MODE_MULTIFUNC);
- adapter->pci_write_normalize(adapter,
- CRB_MPORT_MODE, MPORT_MULTI_FUNCTION_MODE);
- adapter->pci_write_normalize(adapter,
- CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK);
-
- return err;
-}
-
void netxen_release_rx_buffers(struct netxen_adapter *adapter)
{
struct netxen_recv_context *recv_ctx;
@@ -173,9 +137,10 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter)
struct netxen_cmd_buffer *cmd_buf;
struct netxen_skb_frag *buffrag;
int i, j;
+ struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
- cmd_buf = adapter->cmd_buf_arr;
- for (i = 0; i < adapter->num_txd; i++) {
+ cmd_buf = tx_ring->cmd_buf_arr;
+ for (i = 0; i < tx_ring->num_desc; i++) {
buffrag = cmd_buf->frag_array;
if (buffrag->dma) {
pci_unmap_single(adapter->pdev, buffrag->dma,
@@ -203,9 +168,14 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter)
{
struct netxen_recv_context *recv_ctx;
struct nx_host_rds_ring *rds_ring;
+ struct nx_host_tx_ring *tx_ring;
int ring;
recv_ctx = &adapter->recv_ctx;
+
+ if (recv_ctx->rds_rings == NULL)
+ goto skip_rds;
+
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
rds_ring = &recv_ctx->rds_rings[ring];
if (rds_ring->rx_buf_arr) {
@@ -213,10 +183,15 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter)
rds_ring->rx_buf_arr = NULL;
}
}
+ kfree(recv_ctx->rds_rings);
- if (adapter->cmd_buf_arr)
- vfree(adapter->cmd_buf_arr);
- return;
+skip_rds:
+ if (adapter->tx_ring == NULL)
+ return;
+
+ tx_ring = adapter->tx_ring;
+ if (tx_ring->cmd_buf_arr)
+ vfree(tx_ring->cmd_buf_arr);
}
int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
@@ -224,23 +199,45 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
struct netxen_recv_context *recv_ctx;
struct nx_host_rds_ring *rds_ring;
struct nx_host_sds_ring *sds_ring;
+ struct nx_host_tx_ring *tx_ring;
struct netxen_rx_buffer *rx_buf;
- int ring, i, num_rx_bufs;
+ int ring, i, size;
struct netxen_cmd_buffer *cmd_buf_arr;
struct net_device *netdev = adapter->netdev;
+ struct pci_dev *pdev = adapter->pdev;
- cmd_buf_arr =
- (struct netxen_cmd_buffer *)vmalloc(TX_BUFF_RINGSIZE(adapter));
+ size = sizeof(struct nx_host_tx_ring);
+ tx_ring = kzalloc(size, GFP_KERNEL);
+ if (tx_ring == NULL) {
+ dev_err(&pdev->dev, "%s: failed to allocate tx ring struct\n",
+ netdev->name);
+ return -ENOMEM;
+ }
+ adapter->tx_ring = tx_ring;
+
+ tx_ring->num_desc = adapter->num_txd;
+
+ cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring));
if (cmd_buf_arr == NULL) {
- printk(KERN_ERR "%s: Failed to allocate cmd buffer ring\n",
+ dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n",
netdev->name);
return -ENOMEM;
}
- memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(adapter));
- adapter->cmd_buf_arr = cmd_buf_arr;
+ memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring));
+ tx_ring->cmd_buf_arr = cmd_buf_arr;
recv_ctx = &adapter->recv_ctx;
+
+ size = adapter->max_rds_rings * sizeof (struct nx_host_rds_ring);
+ rds_ring = kzalloc(size, GFP_KERNEL);
+ if (rds_ring == NULL) {
+ dev_err(&pdev->dev, "%s: failed to allocate rds ring struct\n",
+ netdev->name);
+ return -ENOMEM;
+ }
+ recv_ctx->rds_rings = rds_ring;
+
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
rds_ring = &recv_ctx->rds_rings[ring];
switch (ring) {
@@ -292,9 +289,8 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
* Now go through all of them, set reference handles
* and put them in the queues.
*/
- num_rx_bufs = rds_ring->num_desc;
rx_buf = rds_ring->rx_buf_arr;
- for (i = 0; i < num_rx_bufs; i++) {
+ for (i = 0; i < rds_ring->num_desc; i++) {
list_add_tail(&rx_buf->list,
&rds_ring->free_list);
rx_buf->ref_handle = i;
@@ -307,8 +303,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
for (ring = 0; ring < adapter->max_sds_rings; ring++) {
sds_ring = &recv_ctx->sds_rings[ring];
sds_ring->irq = adapter->msix_entries[ring].vector;
- sds_ring->clean_tx = (ring == 0);
- sds_ring->post_rxd = (ring == 0);
sds_ring->adapter = adapter;
sds_ring->num_desc = adapter->num_rxd;
@@ -325,13 +319,15 @@ err_out:
void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
{
+ adapter->macaddr_set = netxen_p2_nic_set_mac_addr;
+ adapter->set_multi = netxen_p2_nic_set_multi;
+
switch (adapter->ahw.port_type) {
case NETXEN_NIC_GBE:
adapter->enable_phy_interrupts =
netxen_niu_gbe_enable_phy_interrupts;
adapter->disable_phy_interrupts =
netxen_niu_gbe_disable_phy_interrupts;
- adapter->macaddr_set = netxen_niu_macaddr_set;
adapter->set_mtu = netxen_nic_set_mtu_gb;
adapter->set_promisc = netxen_niu_set_promiscuous_mode;
adapter->phy_read = netxen_niu_gbe_phy_read;
@@ -345,7 +341,6 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
netxen_niu_xgbe_enable_phy_interrupts;
adapter->disable_phy_interrupts =
netxen_niu_xgbe_disable_phy_interrupts;
- adapter->macaddr_set = netxen_niu_xg_macaddr_set;
adapter->set_mtu = netxen_nic_set_mtu_xgb;
adapter->init_port = netxen_niu_xg_init_port;
adapter->set_promisc = netxen_niu_xg_set_promiscuous_mode;
@@ -359,6 +354,8 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
adapter->set_mtu = nx_fw_cmd_set_mtu;
adapter->set_promisc = netxen_p3_nic_set_promisc;
+ adapter->macaddr_set = netxen_p3_nic_set_mac_addr;
+ adapter->set_multi = netxen_p3_nic_set_multi;
}
}
@@ -400,8 +397,7 @@ static int rom_lock(struct netxen_adapter *adapter)
while (!done) {
/* acquire semaphore2 from PCI HW block */
- netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_LOCK),
- &done);
+ done = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM2_LOCK));
if (done == 1)
break;
if (timeout >= rom_lock_timeout)
@@ -418,7 +414,7 @@ static int rom_lock(struct netxen_adapter *adapter)
cpu_relax(); /*This a nop instr on i386 */
}
}
- netxen_nic_reg_write(adapter, NETXEN_ROM_LOCK_ID, ROM_LOCK_DRIVER);
+ NXWR32(adapter, NETXEN_ROM_LOCK_ID, ROM_LOCK_DRIVER);
return 0;
}
@@ -430,7 +426,7 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
cond_resched();
while (done == 0) {
- done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS);
+ done = NXRD32(adapter, NETXEN_ROMUSB_GLB_STATUS);
done &= 2;
timeout++;
if (timeout >= rom_max_timeout) {
@@ -443,30 +439,28 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
static void netxen_rom_unlock(struct netxen_adapter *adapter)
{
- u32 val;
-
/* release semaphore2 */
- netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK), &val);
+ NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK));
}
static int do_rom_fast_read(struct netxen_adapter *adapter,
int addr, int *valp)
{
- netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
- netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
- netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
- netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
+ NXWR32(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
+ NXWR32(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
+ NXWR32(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
+ NXWR32(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
if (netxen_wait_rom_done(adapter)) {
printk("Error waiting for rom done\n");
return -EIO;
}
/* reset abyte_cnt and dummy_byte_cnt */
- netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
+ NXWR32(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
udelay(10);
- netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
+ NXWR32(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
- *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA);
+ *valp = NXRD32(adapter, NETXEN_ROMUSB_ROM_RDATA);
return 0;
}
@@ -530,8 +524,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
/* resetall */
rom_lock(adapter);
- netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
- 0xffffffff);
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 0xffffffff);
netxen_rom_unlock(adapter);
if (verbose) {
@@ -655,7 +648,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
}
}
- adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
+ NXWR32(adapter, off, buf[i].data);
msleep(init_delay);
}
@@ -665,36 +658,230 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
/* unreset_net_cache */
if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
- adapter->hw_read_wx(adapter,
- NETXEN_ROMUSB_GLB_SW_RESET, &val, 4);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_ROMUSB_GLB_SW_RESET, (val & 0xffffff0f));
+ val = NXRD32(adapter, NETXEN_ROMUSB_GLB_SW_RESET);
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, (val & 0xffffff0f));
}
/* p2dn replyCount */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
/* disable_peg_cache 0 */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_D + 0x4c, 8);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_D + 0x4c, 8);
/* disable_peg_cache 1 */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_I + 0x4c, 8);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_I + 0x4c, 8);
/* peg_clr_all */
/* peg_clr 0 */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8, 0);
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_0 + 0x8, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_0 + 0xc, 0);
/* peg_clr 1 */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8, 0);
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_1 + 0x8, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_1 + 0xc, 0);
/* peg_clr 2 */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8, 0);
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_2 + 0x8, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_2 + 0xc, 0);
/* peg_clr 3 */
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8, 0);
- netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_3 + 0x8, 0);
+ NXWR32(adapter, NETXEN_CRB_PEG_NET_3 + 0xc, 0);
+ return 0;
+}
+
+int
+netxen_load_firmware(struct netxen_adapter *adapter)
+{
+ u64 *ptr64;
+ u32 i, flashaddr, size;
+ const struct firmware *fw = adapter->fw;
+
+ if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1);
+
+ if (fw) {
+ __le64 data;
+
+ size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START) / 8;
+
+ ptr64 = (u64 *)&fw->data[NETXEN_BOOTLD_START];
+ flashaddr = NETXEN_BOOTLD_START;
+
+ for (i = 0; i < size; i++) {
+ data = cpu_to_le64(ptr64[i]);
+ adapter->pci_mem_write(adapter, flashaddr, &data, 8);
+ flashaddr += 8;
+ }
+
+ size = *(u32 *)&fw->data[NX_FW_SIZE_OFFSET];
+ size = (__force u32)cpu_to_le32(size) / 8;
+
+ ptr64 = (u64 *)&fw->data[NETXEN_IMAGE_START];
+ flashaddr = NETXEN_IMAGE_START;
+
+ for (i = 0; i < size; i++) {
+ data = cpu_to_le64(ptr64[i]);
+
+ if (adapter->pci_mem_write(adapter,
+ flashaddr, &data, 8))
+ return -EIO;
+
+ flashaddr += 8;
+ }
+ } else {
+ u32 data;
+
+ size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START) / 4;
+ flashaddr = NETXEN_BOOTLD_START;
+
+ for (i = 0; i < size; i++) {
+ if (netxen_rom_fast_read(adapter,
+ flashaddr, (int *)&data) != 0)
+ return -EIO;
+
+ if (adapter->pci_mem_write(adapter,
+ flashaddr, &data, 4))
+ return -EIO;
+
+ flashaddr += 4;
+ }
+ }
+ msleep(1);
+
+ if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 0x80001d);
+ else {
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL, 0x3fff);
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 0);
+ }
+
+ return 0;
+}
+
+static int
+netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
+{
+ __le32 val;
+ u32 major, minor, build, ver, min_ver, bios;
+ struct pci_dev *pdev = adapter->pdev;
+ const struct firmware *fw = adapter->fw;
+
+ if (fw->size < NX_FW_MIN_SIZE)
+ return -EINVAL;
+
+ val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_MAGIC_OFFSET]);
+ if ((__force u32)val != NETXEN_BDINFO_MAGIC)
+ return -EINVAL;
+
+ val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
+ major = (__force u32)val & 0xff;
+ minor = ((__force u32)val >> 8) & 0xff;
+ build = (__force u32)val >> 16;
+
+ if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
+ min_ver = NETXEN_VERSION_CODE(4, 0, 216);
+ else
+ min_ver = NETXEN_VERSION_CODE(3, 4, 216);
+
+ ver = NETXEN_VERSION_CODE(major, minor, build);
+
+ if ((major > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) {
+ dev_err(&pdev->dev,
+ "%s: firmware version %d.%d.%d unsupported\n",
+ fwname, major, minor, build);
+ return -EINVAL;
+ }
+
+ val = cpu_to_le32(*(u32 *)&fw->data[NX_BIOS_VERSION_OFFSET]);
+ netxen_rom_fast_read(adapter, NX_BIOS_VERSION_OFFSET, (int *)&bios);
+ if ((__force u32)val != bios) {
+ dev_err(&pdev->dev, "%s: firmware bios is incompatible\n",
+ fwname);
+ return -EINVAL;
+ }
+
+ /* check if flashed firmware is newer */
+ if (netxen_rom_fast_read(adapter,
+ NX_FW_VERSION_OFFSET, (int *)&val))
+ return -EIO;
+ major = (__force u32)val & 0xff;
+ minor = ((__force u32)val >> 8) & 0xff;
+ build = (__force u32)val >> 16;
+ if (NETXEN_VERSION_CODE(major, minor, build) > ver)
+ return -EINVAL;
+
+ NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
return 0;
}
+static char *fw_name[] = { "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin" };
+
+void netxen_request_firmware(struct netxen_adapter *adapter)
+{
+ u32 capability, flashed_ver;
+ int fw_type;
+ struct pci_dev *pdev = adapter->pdev;
+ int rc = 0;
+
+ if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
+ fw_type = NX_P2_MN_ROMIMAGE;
+ goto request_fw;
+ } else {
+ fw_type = NX_P3_CT_ROMIMAGE;
+ goto request_fw;
+ }
+
+request_mn:
+ capability = 0;
+
+ netxen_rom_fast_read(adapter,
+ NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
+ if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
+ capability = NXRD32(adapter, NX_PEG_TUNE_CAPABILITY);
+ if (capability & NX_PEG_TUNE_MN_PRESENT) {
+ fw_type = NX_P3_MN_ROMIMAGE;
+ goto request_fw;
+ }
+ }
+
+request_fw:
+ rc = request_firmware(&adapter->fw, fw_name[fw_type], &pdev->dev);
+ if (rc != 0) {
+ if (fw_type == NX_P3_CT_ROMIMAGE) {
+ msleep(1);
+ goto request_mn;
+ }
+
+ adapter->fw = NULL;
+ goto done;
+ }
+
+ rc = netxen_validate_firmware(adapter, fw_name[fw_type]);
+ if (rc != 0) {
+ release_firmware(adapter->fw);
+
+ if (fw_type == NX_P3_CT_ROMIMAGE) {
+ msleep(1);
+ goto request_mn;
+ }
+
+ adapter->fw = NULL;
+ goto done;
+ }
+
+done:
+ if (adapter->fw)
+ dev_info(&pdev->dev, "loading firmware from file %s\n",
+ fw_name[fw_type]);
+ else
+ dev_info(&pdev->dev, "loading firmware from flash\n");
+}
+
+
+void
+netxen_release_firmware(struct netxen_adapter *adapter)
+{
+ if (adapter->fw)
+ release_firmware(adapter->fw);
+}
+
int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
{
uint64_t addr;
@@ -715,12 +902,12 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
hi = (addr >> 32) & 0xffffffff;
lo = addr & 0xffffffff;
- adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
- adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
+ NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
+ NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
uint32_t temp = 0;
- adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF, &temp, 4);
+ NXWR32(adapter, CRB_HOST_DUMMY_BUF, temp);
}
return 0;
@@ -762,8 +949,7 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
if (!pegtune_val) {
do {
- val = adapter->pci_read_normalize(adapter,
- CRB_CMDPEG_STATE);
+ val = NXRD32(adapter, CRB_CMDPEG_STATE);
if (val == PHAN_INITIALIZE_COMPLETE ||
val == PHAN_INITIALIZE_ACK)
@@ -774,7 +960,7 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
} while (--retries);
if (!retries) {
- pegtune_val = adapter->pci_read_normalize(adapter,
+ pegtune_val = NXRD32(adapter,
NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
printk(KERN_WARNING "netxen_phantom_init: init failed, "
"pegtune_val=%x\n", pegtune_val);
@@ -785,13 +971,14 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
return 0;
}
-int netxen_receive_peg_ready(struct netxen_adapter *adapter)
+static int
+netxen_receive_peg_ready(struct netxen_adapter *adapter)
{
u32 val = 0;
int retries = 2000;
do {
- val = adapter->pci_read_normalize(adapter, CRB_RCVPEG_STATE);
+ val = NXRD32(adapter, CRB_RCVPEG_STATE);
if (val == PHAN_PEG_RCV_INITIALIZED)
return 0;
@@ -809,6 +996,93 @@ int netxen_receive_peg_ready(struct netxen_adapter *adapter)
return 0;
}
+int netxen_init_firmware(struct netxen_adapter *adapter)
+{
+ int err;
+
+ err = netxen_receive_peg_ready(adapter);
+ if (err)
+ return err;
+
+ NXWR32(adapter, CRB_NIC_CAPABILITIES_HOST, INTR_SCHEME_PERPORT);
+ NXWR32(adapter, CRB_NIC_MSI_MODE_HOST, MSI_MODE_MULTIFUNC);
+ NXWR32(adapter, CRB_MPORT_MODE, MPORT_MULTI_FUNCTION_MODE);
+ NXWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK);
+
+ if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) {
+ adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1);
+ }
+
+ return err;
+}
+
+static void
+netxen_handle_linkevent(struct netxen_adapter *adapter, nx_fw_msg_t *msg)
+{
+ u32 cable_OUI;
+ u16 cable_len;
+ u16 link_speed;
+ u8 link_status, module, duplex, autoneg;
+ struct net_device *netdev = adapter->netdev;
+
+ adapter->has_link_events = 1;
+
+ cable_OUI = msg->body[1] & 0xffffffff;
+ cable_len = (msg->body[1] >> 32) & 0xffff;
+ link_speed = (msg->body[1] >> 48) & 0xffff;
+
+ link_status = msg->body[2] & 0xff;
+ duplex = (msg->body[2] >> 16) & 0xff;
+ autoneg = (msg->body[2] >> 24) & 0xff;
+
+ module = (msg->body[2] >> 8) & 0xff;
+ if (module == LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE) {
+ printk(KERN_INFO "%s: unsupported cable: OUI 0x%x, length %d\n",
+ netdev->name, cable_OUI, cable_len);
+ } else if (module == LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN) {
+ printk(KERN_INFO "%s: unsupported cable length %d\n",
+ netdev->name, cable_len);
+ }
+
+ netxen_advert_link_change(adapter, link_status);
+
+ /* update link parameters */
+ if (duplex == LINKEVENT_FULL_DUPLEX)
+ adapter->link_duplex = DUPLEX_FULL;
+ else
+ adapter->link_duplex = DUPLEX_HALF;
+ adapter->module_type = module;
+ adapter->link_autoneg = autoneg;
+ adapter->link_speed = link_speed;
+}
+
+static void
+netxen_handle_fw_message(int desc_cnt, int index,
+ struct nx_host_sds_ring *sds_ring)
+{
+ nx_fw_msg_t msg;
+ struct status_desc *desc;
+ int i = 0, opcode;
+
+ while (desc_cnt > 0 && i < 8) {
+ desc = &sds_ring->desc_head[index];
+ msg.words[i++] = le64_to_cpu(desc->status_desc_data[0]);
+ msg.words[i++] = le64_to_cpu(desc->status_desc_data[1]);
+
+ index = get_next_index(index, sds_ring->num_desc);
+ desc_cnt--;
+ }
+
+ opcode = netxen_get_nic_msg_opcode(msg.body[0]);
+ switch (opcode) {
+ case NX_NIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE:
+ netxen_handle_linkevent(sds_ring->adapter, &msg);
+ break;
+ default:
+ break;
+ }
+}
+
static int
netxen_alloc_rx_skb(struct netxen_adapter *adapter,
struct nx_host_rds_ring *rds_ring,
@@ -874,7 +1148,8 @@ no_skb:
static struct netxen_rx_buffer *
netxen_process_rcv(struct netxen_adapter *adapter,
- int ring, int index, int length, int cksum, int pkt_offset)
+ int ring, int index, int length, int cksum, int pkt_offset,
+ struct nx_host_sds_ring *sds_ring)
{
struct net_device *netdev = adapter->netdev;
struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
@@ -902,7 +1177,7 @@ netxen_process_rcv(struct netxen_adapter *adapter,
skb->protocol = eth_type_trans(skb, netdev);
- netif_receive_skb(skb);
+ napi_gro_receive(&sds_ring->napi, skb);
adapter->stats.no_rcv++;
adapter->stats.rxbytes += length;
@@ -927,35 +1202,53 @@ netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max)
int count = 0;
u64 sts_data;
- int opcode, ring, index, length, cksum, pkt_offset;
+ int opcode, ring, index, length, cksum, pkt_offset, desc_cnt;
while (count < max) {
desc = &sds_ring->desc_head[consumer];
- sts_data = le64_to_cpu(desc->status_desc_data);
+ sts_data = le64_to_cpu(desc->status_desc_data[0]);
if (!(sts_data & STATUS_OWNER_HOST))
break;
+ desc_cnt = netxen_get_sts_desc_cnt(sts_data);
ring = netxen_get_sts_type(sts_data);
+
if (ring > RCV_RING_JUMBO)
- continue;
+ goto skip;
opcode = netxen_get_sts_opcode(sts_data);
+ switch (opcode) {
+ case NETXEN_NIC_RXPKT_DESC:
+ case NETXEN_OLD_RXPKT_DESC:
+ break;
+ case NETXEN_NIC_RESPONSE_DESC:
+ netxen_handle_fw_message(desc_cnt, consumer, sds_ring);
+ default:
+ goto skip;
+ }
+
+ WARN_ON(desc_cnt > 1);
+
index = netxen_get_sts_refhandle(sts_data);
length = netxen_get_sts_totallength(sts_data);
cksum = netxen_get_sts_status(sts_data);
pkt_offset = netxen_get_sts_pkt_offset(sts_data);
rxbuf = netxen_process_rcv(adapter, ring, index,
- length, cksum, pkt_offset);
+ length, cksum, pkt_offset, sds_ring);
if (rxbuf)
list_add_tail(&rxbuf->list, &sds_ring->free_list[ring]);
- desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM);
-
- consumer = get_next_index(consumer, sds_ring->num_desc);
+skip:
+ for (; desc_cnt > 0; desc_cnt--) {
+ desc = &sds_ring->desc_head[consumer];
+ desc->status_desc_data[0] =
+ cpu_to_le64(STATUS_OWNER_PHANTOM);
+ consumer = get_next_index(consumer, sds_ring->num_desc);
+ }
count++;
}
@@ -980,8 +1273,7 @@ netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max)
if (count) {
sds_ring->consumer = consumer;
- adapter->pci_write_normalize(adapter,
- sds_ring->crb_sts_consumer, consumer);
+ NXWR32(adapter, sds_ring->crb_sts_consumer, consumer);
}
return count;
@@ -990,23 +1282,24 @@ netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max)
/* Process Command status ring */
int netxen_process_cmd_ring(struct netxen_adapter *adapter)
{
- u32 last_consumer, consumer;
+ u32 sw_consumer, hw_consumer;
int count = 0, i;
struct netxen_cmd_buffer *buffer;
struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev;
struct netxen_skb_frag *frag;
int done = 0;
+ struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
if (!spin_trylock(&adapter->tx_clean_lock))
return 1;
- last_consumer = adapter->last_cmd_consumer;
- barrier(); /* cmd_consumer can change underneath */
- consumer = le32_to_cpu(*(adapter->cmd_consumer));
+ sw_consumer = tx_ring->sw_consumer;
+ barrier(); /* hw_consumer can change underneath */
+ hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
- while (last_consumer != consumer) {
- buffer = &adapter->cmd_buf_arr[last_consumer];
+ while (sw_consumer != hw_consumer) {
+ buffer = &tx_ring->cmd_buf_arr[sw_consumer];
if (buffer->skb) {
frag = &buffer->frag_array[0];
pci_unmap_single(pdev, frag->dma, frag->length,
@@ -1024,16 +1317,16 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
buffer->skb = NULL;
}
- last_consumer = get_next_index(last_consumer,
- adapter->num_txd);
+ sw_consumer = get_next_index(sw_consumer, tx_ring->num_desc);
if (++count >= MAX_STATUS_HANDLE)
break;
}
- if (count) {
- adapter->last_cmd_consumer = last_consumer;
+ tx_ring->sw_consumer = sw_consumer;
+
+ if (count && netif_running(netdev)) {
smp_mb();
- if (netif_queue_stopped(netdev) && netif_running(netdev)) {
+ if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) {
netif_tx_lock(netdev);
netif_wake_queue(netdev);
smp_mb();
@@ -1053,9 +1346,9 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
* There is still a possible race condition and the host could miss an
* interrupt. The card has to take care of this.
*/
- barrier(); /* cmd_consumer can change underneath */
- consumer = le32_to_cpu(*(adapter->cmd_consumer));
- done = (last_consumer == consumer);
+ barrier(); /* hw_consumer can change underneath */
+ hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
+ done = (sw_consumer == hw_consumer);
spin_unlock(&adapter->tx_clean_lock);
return (done);
@@ -1099,8 +1392,7 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
if (count) {
rds_ring->producer = producer;
- adapter->pci_write_normalize(adapter,
- rds_ring->crb_rcv_producer,
+ NXWR32(adapter, rds_ring->crb_rcv_producer,
(producer-1) & (rds_ring->num_desc-1));
if (adapter->fw_major < 4) {
@@ -1160,10 +1452,8 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
if (count) {
rds_ring->producer = producer;
- adapter->pci_write_normalize(adapter,
- rds_ring->crb_rcv_producer,
+ NXWR32(adapter, rds_ring->crb_rcv_producer,
(producer - 1) & (rds_ring->num_desc - 1));
- wmb();
}
spin_unlock(&rds_ring->lock);
}
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index aef77289bd34..50477f5c3ecb 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -29,7 +29,7 @@
*/
#include <linux/vmalloc.h>
-#include <linux/highmem.h>
+#include <linux/interrupt.h>
#include "netxen_nic_hw.h"
#include "netxen_nic.h"
@@ -107,10 +107,9 @@ static uint32_t crb_cmd_producer[4] = {
void
netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
- uint32_t crb_producer)
+ struct nx_host_tx_ring *tx_ring, u32 producer)
{
- adapter->pci_write_normalize(adapter,
- adapter->crb_addr_cmd_producer, crb_producer);
+ NXWR32(adapter, tx_ring->crb_cmd_producer, producer);
}
static uint32_t crb_cmd_consumer[4] = {
@@ -120,10 +119,9 @@ static uint32_t crb_cmd_consumer[4] = {
static inline void
netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
- u32 crb_consumer)
+ struct nx_host_tx_ring *tx_ring, u32 consumer)
{
- adapter->pci_write_normalize(adapter,
- adapter->crb_addr_cmd_consumer, crb_consumer);
+ NXWR32(adapter, tx_ring->crb_cmd_consumer, consumer);
}
static uint32_t msi_tgt_status[8] = {
@@ -139,37 +137,54 @@ static inline void netxen_nic_disable_int(struct nx_host_sds_ring *sds_ring)
{
struct netxen_adapter *adapter = sds_ring->adapter;
- adapter->pci_write_normalize(adapter, sds_ring->crb_intr_mask, 0);
+ NXWR32(adapter, sds_ring->crb_intr_mask, 0);
}
static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring)
{
struct netxen_adapter *adapter = sds_ring->adapter;
- adapter->pci_write_normalize(adapter, sds_ring->crb_intr_mask, 0x1);
+ NXWR32(adapter, sds_ring->crb_intr_mask, 0x1);
if (!NETXEN_IS_MSI_FAMILY(adapter))
adapter->pci_write_immediate(adapter,
adapter->legacy_intr.tgt_mask_reg, 0xfbff);
}
+static int
+netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count)
+{
+ int size = sizeof(struct nx_host_sds_ring) * count;
+
+ recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL);
+
+ return (recv_ctx->sds_rings == NULL);
+}
+
static void
+netxen_free_sds_rings(struct netxen_recv_context *recv_ctx)
+{
+ if (recv_ctx->sds_rings != NULL)
+ kfree(recv_ctx->sds_rings);
+}
+
+static int
netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev)
{
int ring;
struct nx_host_sds_ring *sds_ring;
struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
- if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
- adapter->max_sds_rings = (num_online_cpus() >= 4) ? 4 : 2;
- else
- adapter->max_sds_rings = 1;
+ if (netxen_alloc_sds_rings(recv_ctx, adapter->max_sds_rings))
+ return 1;
for (ring = 0; ring < adapter->max_sds_rings; ring++) {
sds_ring = &recv_ctx->sds_rings[ring];
netif_napi_add(netdev, &sds_ring->napi,
netxen_nic_poll, NETXEN_NETDEV_WEIGHT);
}
+
+ return 0;
}
static void
@@ -195,8 +210,9 @@ netxen_napi_disable(struct netxen_adapter *adapter)
for (ring = 0; ring < adapter->max_sds_rings; ring++) {
sds_ring = &recv_ctx->sds_rings[ring];
- netxen_nic_disable_int(sds_ring);
napi_disable(&sds_ring->napi);
+ netxen_nic_disable_int(sds_ring);
+ synchronize_irq(sds_ring->irq);
}
}
@@ -240,7 +256,7 @@ nx_update_dma_mask(struct netxen_adapter *adapter)
change = 0;
- shift = netxen_nic_reg_read(adapter, CRB_DMA_SHIFT);
+ shift = NXRD32(adapter, CRB_DMA_SHIFT);
if (shift >= 32)
return 0;
@@ -268,10 +284,21 @@ static void netxen_check_options(struct netxen_adapter *adapter)
else if (adapter->ahw.port_type == NETXEN_NIC_GBE)
adapter->num_rxd = MAX_RCV_DESCRIPTORS_1G;
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
+ adapter->msix_supported = 0;
+ if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
adapter->msix_supported = !!use_msi_x;
- else
- adapter->msix_supported = 0;
+ adapter->rss_supported = !!use_msi_x;
+ } else if (adapter->fw_version >= NETXEN_VERSION_CODE(3, 4, 336)) {
+ switch (adapter->ahw.board_type) {
+ case NETXEN_BRDTYPE_P2_SB31_10G:
+ case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
+ adapter->msix_supported = !!use_msi_x;
+ adapter->rss_supported = !!use_msi_x;
+ break;
+ default:
+ break;
+ }
+ }
adapter->num_txd = MAX_CMD_DESCRIPTORS_HOST;
adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS;
@@ -287,43 +314,34 @@ netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
if (first_boot == 0x55555555) {
/* This is the first boot after power up */
- adapter->pci_write_normalize(adapter,
- NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
+ NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
return 0;
/* PCI bus master workaround */
- adapter->hw_read_wx(adapter,
- NETXEN_PCIE_REG(0x4), &first_boot, 4);
+ first_boot = NXRD32(adapter, NETXEN_PCIE_REG(0x4));
if (!(first_boot & 0x4)) {
first_boot |= 0x4;
- adapter->hw_write_wx(adapter,
- NETXEN_PCIE_REG(0x4), &first_boot, 4);
- adapter->hw_read_wx(adapter,
- NETXEN_PCIE_REG(0x4), &first_boot, 4);
+ NXWR32(adapter, NETXEN_PCIE_REG(0x4), first_boot);
+ first_boot = NXRD32(adapter, NETXEN_PCIE_REG(0x4));
}
/* This is the first boot after power up */
- adapter->hw_read_wx(adapter,
- NETXEN_ROMUSB_GLB_SW_RESET, &first_boot, 4);
+ first_boot = NXRD32(adapter, NETXEN_ROMUSB_GLB_SW_RESET);
if (first_boot != 0x80000f) {
/* clear the register for future unloads/loads */
- adapter->pci_write_normalize(adapter,
- NETXEN_CAM_RAM(0x1fc), 0);
+ NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), 0);
return -EIO;
}
/* Start P2 boot loader */
- val = adapter->pci_read_normalize(adapter,
- NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
- adapter->pci_write_normalize(adapter,
- NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
+ val = NXRD32(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
+ NXWR32(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
timeout = 0;
do {
msleep(1);
- val = adapter->pci_read_normalize(adapter,
- NETXEN_CAM_RAM(0x1fc));
+ val = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc));
if (++timeout > 5000)
return -EIO;
@@ -342,24 +360,19 @@ static void netxen_set_port_mode(struct netxen_adapter *adapter)
(val == NETXEN_BRDTYPE_P3_XG_LOM)) {
if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
data = NETXEN_PORT_MODE_802_3_AP;
- adapter->hw_write_wx(adapter,
- NETXEN_PORT_MODE_ADDR, &data, 4);
+ NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
} else if (port_mode == NETXEN_PORT_MODE_XG) {
data = NETXEN_PORT_MODE_XG;
- adapter->hw_write_wx(adapter,
- NETXEN_PORT_MODE_ADDR, &data, 4);
+ NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
} else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_1G) {
data = NETXEN_PORT_MODE_AUTO_NEG_1G;
- adapter->hw_write_wx(adapter,
- NETXEN_PORT_MODE_ADDR, &data, 4);
+ NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
} else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_XG) {
data = NETXEN_PORT_MODE_AUTO_NEG_XG;
- adapter->hw_write_wx(adapter,
- NETXEN_PORT_MODE_ADDR, &data, 4);
+ NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
} else {
data = NETXEN_PORT_MODE_AUTO_NEG;
- adapter->hw_write_wx(adapter,
- NETXEN_PORT_MODE_ADDR, &data, 4);
+ NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data);
}
if ((wol_port_mode != NETXEN_PORT_MODE_802_3_AP) &&
@@ -368,8 +381,7 @@ static void netxen_set_port_mode(struct netxen_adapter *adapter)
(wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_XG)) {
wol_port_mode = NETXEN_PORT_MODE_AUTO_NEG;
}
- adapter->hw_write_wx(adapter, NETXEN_WOL_PORT_MODE,
- &wol_port_mode, 4);
+ NXWR32(adapter, NETXEN_WOL_PORT_MODE, wol_port_mode);
}
}
@@ -389,11 +401,11 @@ static void netxen_set_msix_bit(struct pci_dev *pdev, int enable)
}
}
-static void netxen_init_msix_entries(struct netxen_adapter *adapter)
+static void netxen_init_msix_entries(struct netxen_adapter *adapter, int count)
{
int i;
- for (i = 0; i < MSIX_ENTRIES_PER_ADAPTER; i++)
+ for (i = 0; i < count; i++)
adapter->msix_entries[i].entry = i;
}
@@ -424,20 +436,38 @@ netxen_read_mac_addr(struct netxen_adapter *adapter)
if (!is_valid_ether_addr(netdev->perm_addr))
dev_warn(&pdev->dev, "Bad MAC address %pM.\n", netdev->dev_addr);
- else
- adapter->macaddr_set(adapter, netdev->dev_addr);
return 0;
}
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+ struct netxen_adapter *adapter = netdev_priv(netdev);
+ struct sockaddr *addr = p;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EINVAL;
+
+ if (netif_running(netdev)) {
+ netif_device_detach(netdev);
+ netxen_napi_disable(adapter);
+ }
+
+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+ adapter->macaddr_set(adapter, addr->sa_data);
+
+ if (netif_running(netdev)) {
+ netif_device_attach(netdev);
+ netxen_napi_enable(adapter);
+ }
+ return 0;
+}
+
static void netxen_set_multicast_list(struct net_device *dev)
{
struct netxen_adapter *adapter = netdev_priv(dev);
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
- netxen_p3_nic_set_multi(dev);
- else
- netxen_p2_nic_set_multi(dev);
+ adapter->set_multi(dev);
}
static const struct net_device_ops netxen_netdev_ops = {
@@ -460,10 +490,17 @@ netxen_setup_intr(struct netxen_adapter *adapter)
{
struct netxen_legacy_intr_set *legacy_intrp;
struct pci_dev *pdev = adapter->pdev;
+ int err, num_msix;
+
+ if (adapter->rss_supported) {
+ num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ?
+ MSIX_ENTRIES_PER_ADAPTER : 2;
+ } else
+ num_msix = 1;
+
+ adapter->max_sds_rings = 1;
adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);
- adapter->intr_scheme = -1;
- adapter->msi_mode = -1;
if (adapter->ahw.revision_id >= NX_P3_B0)
legacy_intrp = &legacy_intr[adapter->ahw.pci_func];
@@ -478,24 +515,36 @@ netxen_setup_intr(struct netxen_adapter *adapter)
if (adapter->msix_supported) {
- netxen_init_msix_entries(adapter);
- if (pci_enable_msix(pdev, adapter->msix_entries,
- MSIX_ENTRIES_PER_ADAPTER))
- goto request_msi;
+ netxen_init_msix_entries(adapter, num_msix);
+ err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
+ if (err == 0) {
+ adapter->flags |= NETXEN_NIC_MSIX_ENABLED;
+ netxen_set_msix_bit(pdev, 1);
- adapter->flags |= NETXEN_NIC_MSIX_ENABLED;
- netxen_set_msix_bit(pdev, 1);
- dev_info(&pdev->dev, "using msi-x interrupts\n");
+ if (adapter->rss_supported)
+ adapter->max_sds_rings = num_msix;
- } else {
-request_msi:
- if (use_msi && !pci_enable_msi(pdev)) {
- adapter->flags |= NETXEN_NIC_MSI_ENABLED;
- dev_info(&pdev->dev, "using msi interrupts\n");
- } else
- dev_info(&pdev->dev, "using legacy interrupts\n");
+ dev_info(&pdev->dev, "using msi-x interrupts\n");
+ return;
+ }
+
+ if (err > 0)
+ pci_disable_msix(pdev);
+
+ /* fall through for msi */
+ }
+
+ if (use_msi && !pci_enable_msi(pdev)) {
+ adapter->flags |= NETXEN_NIC_MSI_ENABLED;
+ adapter->msi_tgt_status =
+ msi_tgt_status[adapter->ahw.pci_func];
+ dev_info(&pdev->dev, "using msi interrupts\n");
adapter->msix_entries[0].vector = pdev->irq;
+ return;
}
+
+ dev_info(&pdev->dev, "using legacy interrupts\n");
+ adapter->msix_entries[0].vector = pdev->irq;
}
static void
@@ -552,8 +601,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
adapter->hw_read_wx = netxen_nic_hw_read_wx_128M;
adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M;
adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M;
- adapter->pci_read_normalize = netxen_nic_pci_read_normalize_128M;
- adapter->pci_write_normalize = netxen_nic_pci_write_normalize_128M;
adapter->pci_set_window = netxen_nic_pci_set_window_128M;
adapter->pci_mem_read = netxen_nic_pci_mem_read_128M;
adapter->pci_mem_write = netxen_nic_pci_mem_write_128M;
@@ -575,9 +622,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M;
adapter->pci_write_immediate =
netxen_nic_pci_write_immediate_2M;
- adapter->pci_read_normalize = netxen_nic_pci_read_normalize_2M;
- adapter->pci_write_normalize =
- netxen_nic_pci_write_normalize_2M;
adapter->pci_set_window = netxen_nic_pci_set_window_2M;
adapter->pci_mem_read = netxen_nic_pci_mem_read_2M;
adapter->pci_mem_write = netxen_nic_pci_mem_write_2M;
@@ -643,25 +687,22 @@ err_out:
}
static int
-netxen_start_firmware(struct netxen_adapter *adapter)
+netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
{
int val, err, first_boot;
struct pci_dev *pdev = adapter->pdev;
int first_driver = 0;
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
- if (adapter->ahw.pci_func == 0)
- first_driver = 1;
- } else {
- if (adapter->portnum == 0)
- first_driver = 1;
- }
+
+ if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+ first_driver = (adapter->portnum == 0);
+ else
+ first_driver = (adapter->ahw.pci_func == 0);
if (!first_driver)
return 0;
- first_boot = adapter->pci_read_normalize(adapter,
- NETXEN_CAM_RAM(0x1fc));
+ first_boot = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc));
err = netxen_check_hw_init(adapter, first_boot);
if (err) {
@@ -669,14 +710,16 @@ netxen_start_firmware(struct netxen_adapter *adapter)
return err;
}
+ if (request_fw)
+ netxen_request_firmware(adapter);
+
if (first_boot != 0x55555555) {
- adapter->pci_write_normalize(adapter,
- CRB_CMDPEG_STATE, 0);
+ NXWR32(adapter, CRB_CMDPEG_STATE, 0);
netxen_pinit_from_rom(adapter, 0);
msleep(1);
}
- netxen_nic_reg_write(adapter, CRB_DMA_SHIFT, 0x55555555);
+ NXWR32(adapter, CRB_DMA_SHIFT, 0x55555555);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
netxen_set_port_mode(adapter);
@@ -688,8 +731,7 @@ netxen_start_firmware(struct netxen_adapter *adapter)
val = 0x7654;
if (adapter->ahw.port_type == NETXEN_NIC_XGBE)
val |= 0x0f000000;
- netxen_crb_writelit_adapter(adapter,
- NETXEN_MAC_ADDR_CNTL_REG, val);
+ NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
}
@@ -703,7 +745,7 @@ netxen_start_firmware(struct netxen_adapter *adapter)
val = (_NETXEN_NIC_LINUX_MAJOR << 16)
| ((_NETXEN_NIC_LINUX_MINOR << 8))
| (_NETXEN_NIC_LINUX_SUBVERSION);
- adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, val);
+ NXWR32(adapter, CRB_DRIVER_VERSION, val);
/* Handshake with the card before we register the devices. */
err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
@@ -726,15 +768,6 @@ netxen_nic_request_irq(struct netxen_adapter *adapter)
struct net_device *netdev = adapter->netdev;
struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
- if ((adapter->msi_mode != MSI_MODE_MULTIFUNC) ||
- (adapter->intr_scheme != INTR_SCHEME_PERPORT)) {
- printk(KERN_ERR "%s: Firmware interrupt scheme is "
- "incompatible with driver\n",
- netdev->name);
- adapter->driver_mismatch = 1;
- return -EINVAL;
- }
-
if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
handler = netxen_msix_intr;
else if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
@@ -747,7 +780,7 @@ netxen_nic_request_irq(struct netxen_adapter *adapter)
for (ring = 0; ring < adapter->max_sds_rings; ring++) {
sds_ring = &recv_ctx->sds_rings[ring];
- sprintf(sds_ring->name, "%16s[%d]", netdev->name, ring);
+ sprintf(sds_ring->name, "%s[%d]", netdev->name, ring);
err = request_irq(sds_ring->irq, handler,
flags, sds_ring->name, sds_ring);
if (err)
@@ -782,22 +815,26 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
netxen_nic_driver_name, adapter->portnum);
return err;
}
- adapter->macaddr_set(adapter, netdev->dev_addr);
-
- netxen_nic_set_link_parameters(adapter);
+ if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+ adapter->macaddr_set(adapter, netdev->dev_addr);
- netxen_set_multicast_list(netdev);
- if (adapter->set_mtu)
- adapter->set_mtu(adapter, netdev->mtu);
+ adapter->set_multi(netdev);
+ adapter->set_mtu(adapter, netdev->mtu);
adapter->ahw.linkup = 0;
- mod_timer(&adapter->watchdog_timer, jiffies);
netxen_napi_enable(adapter);
if (adapter->max_sds_rings > 1)
netxen_config_rss(adapter, 1);
+ if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)
+ netxen_linkevent_request(adapter, 1);
+ else
+ netxen_nic_set_link_parameters(adapter);
+
+ mod_timer(&adapter->watchdog_timer, jiffies);
+
return 0;
}
@@ -806,11 +843,15 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
{
netif_carrier_off(netdev);
netif_stop_queue(netdev);
- netxen_napi_disable(adapter);
if (adapter->stop_port)
adapter->stop_port(adapter);
+ if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
+ netxen_p3_free_mac_list(adapter);
+
+ netxen_napi_disable(adapter);
+
netxen_release_tx_buffers(adapter);
FLUSH_SCHEDULED_WORK();
@@ -825,6 +866,7 @@ netxen_nic_attach(struct netxen_adapter *adapter)
struct pci_dev *pdev = adapter->pdev;
int err, ring;
struct nx_host_rds_ring *rds_ring;
+ struct nx_host_tx_ring *tx_ring;
err = netxen_init_firmware(adapter);
if (err != 0) {
@@ -854,13 +896,12 @@ netxen_nic_attach(struct netxen_adapter *adapter)
}
if (adapter->fw_major < 4) {
- adapter->crb_addr_cmd_producer =
- crb_cmd_producer[adapter->portnum];
- adapter->crb_addr_cmd_consumer =
- crb_cmd_consumer[adapter->portnum];
+ tx_ring = adapter->tx_ring;
+ tx_ring->crb_cmd_producer = crb_cmd_producer[adapter->portnum];
+ tx_ring->crb_cmd_consumer = crb_cmd_consumer[adapter->portnum];
- netxen_nic_update_cmd_producer(adapter, 0);
- netxen_nic_update_cmd_consumer(adapter, 0);
+ netxen_nic_update_cmd_producer(adapter, tx_ring, 0);
+ netxen_nic_update_cmd_consumer(adapter, tx_ring, 0);
}
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
@@ -889,10 +930,9 @@ err_out_free_sw:
static void
netxen_nic_detach(struct netxen_adapter *adapter)
{
- netxen_nic_free_irq(adapter);
-
netxen_release_rx_buffers(adapter);
netxen_free_hw_resources(adapter);
+ netxen_nic_free_irq(adapter);
netxen_free_sw_resources(adapter);
adapter->is_up = 0;
@@ -957,6 +997,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
rwlock_init(&adapter->adapter_lock);
spin_lock_init(&adapter->tx_clean_lock);
+ INIT_LIST_HEAD(&adapter->mac_list);
err = netxen_setup_pci_map(adapter);
if (err)
@@ -979,6 +1020,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO);
+ netdev->features |= (NETIF_F_GRO);
netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO);
if (NX_IS_REVISION_P3(revision_id)) {
@@ -1011,7 +1053,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
break;
}
- err = netxen_start_firmware(adapter);
+ err = netxen_start_firmware(adapter, 1);
if (err)
goto err_out_iounmap;
@@ -1024,8 +1066,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
*/
adapter->physical_port = adapter->portnum;
if (adapter->fw_major < 4) {
- i = adapter->pci_read_normalize(adapter,
- CRB_V2P(adapter->portnum));
+ i = NXRD32(adapter, CRB_V2P(adapter->portnum));
if (i != 0x55555555)
adapter->physical_port = i;
}
@@ -1036,10 +1077,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->irq = adapter->msix_entries[0].vector;
- netxen_napi_add(adapter, netdev);
-
- err = netxen_receive_peg_ready(adapter);
- if (err)
+ if (netxen_napi_add(adapter, netdev))
goto err_out_disable_msi;
init_timer(&adapter->watchdog_timer);
@@ -1113,18 +1151,18 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) {
netxen_nic_detach(adapter);
-
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
- netxen_p3_free_mac_list(adapter);
}
if (adapter->portnum == 0)
netxen_free_adapter_offload(adapter);
netxen_teardown_intr(adapter);
+ netxen_free_sds_rings(&adapter->recv_ctx);
netxen_cleanup_pci_map(adapter);
+ netxen_release_firmware(adapter);
+
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
@@ -1176,7 +1214,7 @@ netxen_nic_resume(struct pci_dev *pdev)
adapter->curr_window = 255;
- err = netxen_start_firmware(adapter);
+ err = netxen_start_firmware(adapter, 0);
if (err) {
dev_err(&pdev->dev, "failed to start firmware\n");
return err;
@@ -1315,7 +1353,7 @@ static int
netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
{
struct netxen_adapter *adapter = netdev_priv(netdev);
- struct netxen_hardware_context *hw = &adapter->ahw;
+ struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
unsigned int first_seg_len = skb->len - skb->data_len;
struct netxen_cmd_buffer *pbuf;
struct netxen_skb_frag *buffrag;
@@ -1326,28 +1364,26 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
u32 producer, consumer;
int frag_count, no_of_desc;
- u32 num_txd = adapter->num_txd;
+ u32 num_txd = tx_ring->num_desc;
bool is_tso = false;
frag_count = skb_shinfo(skb)->nr_frags + 1;
- /* There 4 fragments per descriptor */
+ /* 4 fragments per cmd des */
no_of_desc = (frag_count + 3) >> 2;
- producer = adapter->cmd_producer;
+ producer = tx_ring->producer;
smp_mb();
- consumer = adapter->last_cmd_consumer;
- if ((no_of_desc+2) > find_diff_among(producer, consumer, num_txd)) {
+ consumer = tx_ring->sw_consumer;
+ if ((no_of_desc+2) >= find_diff_among(producer, consumer, num_txd)) {
netif_stop_queue(netdev);
smp_mb();
return NETDEV_TX_BUSY;
}
- /* Copy the descriptors into the hardware */
- hwdesc = &hw->cmd_desc_head[producer];
+ hwdesc = &tx_ring->desc_head[producer];
netxen_clear_cmddesc((u64 *)hwdesc);
- /* Take skb->data itself */
- pbuf = &adapter->cmd_buf_arr[producer];
+ pbuf = &tx_ring->cmd_buf_arr[producer];
is_tso = netxen_tso_check(netdev, hwdesc, skb);
@@ -1376,9 +1412,9 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
if ((i & 0x3) == 0) {
k = 0;
producer = get_next_index(producer, num_txd);
- hwdesc = &hw->cmd_desc_head[producer];
+ hwdesc = &tx_ring->desc_head[producer];
netxen_clear_cmddesc((u64 *)hwdesc);
- pbuf = &adapter->cmd_buf_arr[producer];
+ pbuf = &tx_ring->cmd_buf_arr[producer];
pbuf->skb = NULL;
}
frag = &skb_shinfo(skb)->frags[i - 1];
@@ -1430,8 +1466,8 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
more_hdr = 0;
}
/* copy the MAC/IP/TCP headers to the cmd descriptor list */
- hwdesc = &hw->cmd_desc_head[producer];
- pbuf = &adapter->cmd_buf_arr[producer];
+ hwdesc = &tx_ring->desc_head[producer];
+ pbuf = &tx_ring->cmd_buf_arr[producer];
pbuf->skb = NULL;
/* copy the first 64 bytes */
@@ -1440,8 +1476,8 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
producer = get_next_index(producer, num_txd);
if (more_hdr) {
- hwdesc = &hw->cmd_desc_head[producer];
- pbuf = &adapter->cmd_buf_arr[producer];
+ hwdesc = &tx_ring->desc_head[producer];
+ pbuf = &tx_ring->cmd_buf_arr[producer];
pbuf->skb = NULL;
/* copy the next 64 bytes - should be enough except
* for pathological case
@@ -1454,10 +1490,10 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
}
}
- adapter->cmd_producer = producer;
+ tx_ring->producer = producer;
adapter->stats.txbytes += skb->len;
- netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer);
+ netxen_nic_update_cmd_producer(adapter, tx_ring, producer);
adapter->stats.xmitcalled++;
netdev->trans_start = jiffies;
@@ -1476,7 +1512,7 @@ static int netxen_nic_check_temp(struct netxen_adapter *adapter)
uint32_t temp, temp_state, temp_val;
int rv = 0;
- temp = adapter->pci_read_normalize(adapter, CRB_TEMP_STATE);
+ temp = NXRD32(adapter, CRB_TEMP_STATE);
temp_state = nx_get_temp_state(temp);
temp_val = nx_get_temp_val(temp);
@@ -1510,26 +1546,9 @@ static int netxen_nic_check_temp(struct netxen_adapter *adapter)
return rv;
}
-static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
+void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup)
{
struct net_device *netdev = adapter->netdev;
- u32 val, port, linkup;
-
- port = adapter->physical_port;
-
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
- val = adapter->pci_read_normalize(adapter, CRB_XG_STATE_P3);
- val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
- linkup = (val == XG_LINK_UP_P3);
- } else {
- val = adapter->pci_read_normalize(adapter, CRB_XG_STATE);
- if (adapter->ahw.port_type == NETXEN_NIC_GBE)
- linkup = (val >> port) & 1;
- else {
- val = (val >> port*8) & 0xff;
- linkup = (val == XG_LINK_UP);
- }
- }
if (adapter->ahw.linkup && !linkup) {
printk(KERN_INFO "%s: %s NIC Link is down\n",
@@ -1540,7 +1559,9 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
netif_stop_queue(netdev);
}
- netxen_nic_set_link_parameters(adapter);
+ if (!adapter->has_link_events)
+ netxen_nic_set_link_parameters(adapter);
+
} else if (!adapter->ahw.linkup && linkup) {
printk(KERN_INFO "%s: %s NIC Link is up\n",
netxen_nic_driver_name, netdev->name);
@@ -1550,8 +1571,32 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
netif_wake_queue(netdev);
}
- netxen_nic_set_link_parameters(adapter);
+ if (!adapter->has_link_events)
+ netxen_nic_set_link_parameters(adapter);
+ }
+}
+
+static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
+{
+ u32 val, port, linkup;
+
+ port = adapter->physical_port;
+
+ if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
+ val = NXRD32(adapter, CRB_XG_STATE_P3);
+ val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
+ linkup = (val == XG_LINK_UP_P3);
+ } else {
+ val = NXRD32(adapter, CRB_XG_STATE);
+ if (adapter->ahw.port_type == NETXEN_NIC_GBE)
+ linkup = (val >> port) & 1;
+ else {
+ val = (val >> port*8) & 0xff;
+ linkup = (val == XG_LINK_UP);
+ }
}
+
+ netxen_advert_link_change(adapter, linkup);
}
static void netxen_watchdog(unsigned long v)
@@ -1569,7 +1614,8 @@ void netxen_watchdog_task(struct work_struct *work)
if ((adapter->portnum == 0) && netxen_nic_check_temp(adapter))
return;
- netxen_nic_handle_phy_intr(adapter);
+ if (!adapter->has_link_events)
+ netxen_nic_handle_phy_intr(adapter);
if (netif_running(adapter->netdev))
mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
@@ -1598,10 +1644,6 @@ static void netxen_tx_timeout_task(struct work_struct *work)
netif_wake_queue(adapter->netdev);
}
-/*
- * netxen_nic_get_stats - Get System Network Statistics
- * @netdev: network interface device structure
- */
struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
{
struct netxen_adapter *adapter = netdev_priv(netdev);
@@ -1609,22 +1651,11 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
memset(stats, 0, sizeof(*stats));
- /* total packets received */
stats->rx_packets = adapter->stats.no_rcv;
- /* total packets transmitted */
- stats->tx_packets = adapter->stats.xmitedframes +
- adapter->stats.xmitfinished;
- /* total bytes received */
+ stats->tx_packets = adapter->stats.xmitfinished;
stats->rx_bytes = adapter->stats.rxbytes;
- /* total bytes transmitted */
stats->tx_bytes = adapter->stats.txbytes;
- /* bad packets received */
- stats->rx_errors = adapter->stats.rcvdbadskb;
- /* packet transmit problems */
- stats->tx_errors = adapter->stats.nocmddescriptor;
- /* no space in linux buffers */
stats->rx_dropped = adapter->stats.rxdropped;
- /* no space available in linux */
stats->tx_dropped = adapter->stats.txdropped;
return stats;
@@ -1651,15 +1682,14 @@ static irqreturn_t netxen_intr(int irq, void *data)
} else {
unsigned long our_int = 0;
- our_int = adapter->pci_read_normalize(adapter, CRB_INT_VECTOR);
+ our_int = NXRD32(adapter, CRB_INT_VECTOR);
/* not our interrupt */
if (!test_and_clear_bit((7 + adapter->portnum), &our_int))
return IRQ_NONE;
/* claim interrupt */
- adapter->pci_write_normalize(adapter,
- CRB_INT_VECTOR, (our_int & 0xffffffff));
+ NXWR32(adapter, CRB_INT_VECTOR, (our_int & 0xffffffff));
}
/* clear interrupt */
@@ -1685,7 +1715,7 @@ static irqreturn_t netxen_msi_intr(int irq, void *data)
/* clear interrupt */
adapter->pci_write_immediate(adapter,
- msi_tgt_status[adapter->ahw.pci_func], 0xffffffff);
+ adapter->msi_tgt_status, 0xffffffff);
napi_schedule(&sds_ring->napi);
return IRQ_HANDLED;
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index d85203203d4d..5941c79be723 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -43,8 +43,7 @@ static int phy_lock(struct netxen_adapter *adapter)
int done = 0, timeout = 0;
while (!done) {
- done = netxen_nic_reg_read(adapter,
- NETXEN_PCIE_REG(PCIE_SEM3_LOCK));
+ done = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM3_LOCK));
if (done == 1)
break;
if (timeout >= phy_lock_timeout) {
@@ -59,8 +58,7 @@ static int phy_lock(struct netxen_adapter *adapter)
}
}
- netxen_crb_writelit_adapter(adapter,
- NETXEN_PHY_LOCK_ID, PHY_LOCK_DRIVER);
+ NXWR32(adapter, NETXEN_PHY_LOCK_ID, PHY_LOCK_DRIVER);
return 0;
}
@@ -105,9 +103,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
* so it cannot be in reset
*/
- if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
- &mac_cfg0, 4))
- return -EIO;
+ mac_cfg0 = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0));
if (netxen_gb_get_soft_reset(mac_cfg0)) {
__u32 temp;
temp = 0;
@@ -115,9 +111,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
netxen_gb_rx_reset_pb(temp);
netxen_gb_tx_reset_mac(temp);
netxen_gb_rx_reset_mac(temp);
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(0),
- &temp, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), temp))
return -EIO;
restore = 1;
}
@@ -125,43 +119,32 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
address = 0;
netxen_gb_mii_mgmt_reg_addr(address, reg);
netxen_gb_mii_mgmt_phy_addr(address, phy);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
- &address, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0), address))
return -EIO;
command = 0; /* turn off any prior activity */
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
- &command, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
return -EIO;
/* send read command */
netxen_gb_mii_mgmt_set_read_cycle(command);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
- &command, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
return -EIO;
status = 0;
do {
- if (adapter->hw_read_wx(adapter,
- NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
- &status, 4))
- return -EIO;
+ status = NXRD32(adapter, NETXEN_NIU_GB_MII_MGMT_INDICATE(0));
timeout++;
} while ((netxen_get_gb_mii_mgmt_busy(status)
|| netxen_get_gb_mii_mgmt_notvalid(status))
&& (timeout++ < NETXEN_NIU_PHY_WAITMAX));
if (timeout < NETXEN_NIU_PHY_WAITMAX) {
- if (adapter->hw_read_wx(adapter,
- NETXEN_NIU_GB_MII_MGMT_STATUS(0),
- readval, 4))
- return -EIO;
+ *readval = NXRD32(adapter, NETXEN_NIU_GB_MII_MGMT_STATUS(0));
result = 0;
} else
result = -1;
if (restore)
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(0),
- &mac_cfg0, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), mac_cfg0))
return -EIO;
phy_unlock(adapter);
return result;
@@ -197,9 +180,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
* cannot be in reset
*/
- if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
- &mac_cfg0, 4))
- return -EIO;
+ mac_cfg0 = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0));
if (netxen_gb_get_soft_reset(mac_cfg0)) {
__u32 temp;
temp = 0;
@@ -208,35 +189,27 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
netxen_gb_tx_reset_mac(temp);
netxen_gb_rx_reset_mac(temp);
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(0),
- &temp, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), temp))
return -EIO;
restore = 1;
}
command = 0; /* turn off any prior activity */
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
- &command, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
return -EIO;
address = 0;
netxen_gb_mii_mgmt_reg_addr(address, reg);
netxen_gb_mii_mgmt_phy_addr(address, phy);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
- &address, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0), address))
return -EIO;
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
- &val, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0), val))
return -EIO;
status = 0;
do {
- if (adapter->hw_read_wx(adapter,
- NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
- &status, 4))
- return -EIO;
+ status = NXRD32(adapter, NETXEN_NIU_GB_MII_MGMT_INDICATE(0));
timeout++;
} while ((netxen_get_gb_mii_mgmt_busy(status))
&& (timeout++ < NETXEN_NIU_PHY_WAITMAX));
@@ -248,9 +221,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
/* restore the state of port 0 MAC in case we tampered with it */
if (restore)
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(0),
- &mac_cfg0, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), mac_cfg0))
return -EIO;
return result;
@@ -258,7 +229,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter)
{
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
+ NXWR32(adapter, NETXEN_NIU_INT_MASK, 0x3f);
return 0;
}
@@ -281,7 +252,7 @@ int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter)
int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter)
{
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
+ NXWR32(adapter, NETXEN_NIU_INT_MASK, 0x7f);
return 0;
}
@@ -315,36 +286,27 @@ static int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter)
static void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
int port, long enable)
{
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
- 0x80000000);
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
- 0x0000f0025);
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
- 0xf1ff);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB0_GMII_MODE + (port << 3), 0);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB0_MII_MODE + (port << 3), 1);
- netxen_crb_writelit_adapter(adapter,
- (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
+ NXWR32(adapter, NETXEN_NIU_MODE, 0x2);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 0x80000000);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 0x0000f0025);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port), 0xf1ff);
+ NXWR32(adapter, NETXEN_NIU_GB0_GMII_MODE + (port << 3), 0);
+ NXWR32(adapter, NETXEN_NIU_GB0_MII_MODE + (port << 3), 1);
+ NXWR32(adapter, (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
+ NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
if (enable) {
/*
* Do NOT enable flow control until a suitable solution for
* shutting down pause frames is found.
*/
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(port),
- 0x5);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 0x5);
}
if (netxen_niu_gbe_enable_phy_interrupts(adapter))
- printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
+ printk(KERN_ERR "ERROR enabling PHY interrupts\n");
if (netxen_niu_gbe_clear_phy_interrupts(adapter))
- printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
+ printk(KERN_ERR "ERROR clearing PHY interrupts\n");
}
/*
@@ -353,36 +315,27 @@ static void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
static void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter,
int port, long enable)
{
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
- 0x80000000);
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
- 0x0000f0025);
- netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
- 0xf2ff);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB0_MII_MODE + (port << 3), 0);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB0_GMII_MODE + (port << 3), 1);
- netxen_crb_writelit_adapter(adapter,
- (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
+ NXWR32(adapter, NETXEN_NIU_MODE, 0x2);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 0x80000000);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 0x0000f0025);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port), 0xf2ff);
+ NXWR32(adapter, NETXEN_NIU_GB0_MII_MODE + (port << 3), 0);
+ NXWR32(adapter, NETXEN_NIU_GB0_GMII_MODE + (port << 3), 1);
+ NXWR32(adapter, (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
+ NXWR32(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
if (enable) {
/*
* Do NOT enable flow control until a suitable solution for
* shutting down pause frames is found.
*/
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0(port),
- 0x5);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 0x5);
}
if (netxen_niu_gbe_enable_phy_interrupts(adapter))
- printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
+ printk(KERN_ERR "ERROR enabling PHY interrupts\n");
if (netxen_niu_gbe_clear_phy_interrupts(adapter))
- printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
+ printk(KERN_ERR "ERROR clearing PHY interrupts\n");
}
int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
@@ -416,25 +369,20 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
* plugged in.
*/
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0
- (port),
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
NETXEN_GB_MAC_SOFT_RESET);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_GB_MAC_CONFIG_0
- (port),
- NETXEN_GB_MAC_RESET_PROT_BLK
- | NETXEN_GB_MAC_ENABLE_TX_RX
- |
- NETXEN_GB_MAC_PAUSED_FRMS);
+ NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
+ NETXEN_GB_MAC_RESET_PROT_BLK |
+ NETXEN_GB_MAC_ENABLE_TX_RX |
+ NETXEN_GB_MAC_PAUSED_FRMS);
if (netxen_niu_gbe_clear_phy_interrupts(adapter))
- printk(KERN_ERR PFX
+ printk(KERN_ERR
"ERROR clearing PHY interrupts\n");
if (netxen_niu_gbe_enable_phy_interrupts(adapter))
- printk(KERN_ERR PFX
+ printk(KERN_ERR
"ERROR enabling PHY interrupts\n");
if (netxen_niu_gbe_clear_phy_interrupts(adapter))
- printk(KERN_ERR PFX
+ printk(KERN_ERR
"ERROR clearing PHY interrupts\n");
result = -1;
}
@@ -447,88 +395,10 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
{
if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_XGE_CONFIG_1+(0x10000*port), 0x1447);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_XGE_CONFIG_0+(0x10000*port), 0x5);
- }
-
- return 0;
-}
-
-/*
- * Return the current station MAC address.
- * Note that the passed-in value must already be in network byte order.
- */
-static int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
- netxen_ethernet_macaddr_t * addr)
-{
- u32 stationhigh;
- u32 stationlow;
- int phy = adapter->physical_port;
- u8 val[8];
-
- if (addr == NULL)
- return -EINVAL;
- if ((phy < 0) || (phy > 3))
- return -EINVAL;
-
- if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy),
- &stationhigh, 4))
- return -EIO;
- if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
- &stationlow, 4))
- return -EIO;
- ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
- ((__le32 *)val)[0] = cpu_to_le32(stationlow);
-
- memcpy(addr, val + 2, 6);
-
- return 0;
-}
-
-/*
- * Set the station MAC address.
- * Note that the passed-in value must already be in network byte order.
- */
-int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
- netxen_ethernet_macaddr_t addr)
-{
- u8 temp[4];
- u32 val;
- int phy = adapter->physical_port;
- unsigned char mac_addr[6];
- int i;
-
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
- return 0;
-
- for (i = 0; i < 10; i++) {
- temp[0] = temp[1] = 0;
- memcpy(temp + 2, addr, 2);
- val = le32_to_cpu(*(__le32 *)temp);
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4))
- return -EIO;
-
- memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
- val = le32_to_cpu(*(__le32 *)temp);
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4))
- return -2;
-
- netxen_niu_macaddr_get(adapter,
- (netxen_ethernet_macaddr_t *) mac_addr);
- if (memcmp(mac_addr, addr, 6) == 0)
- break;
+ NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_1+(0x10000*port), 0x1447);
+ NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_0+(0x10000*port), 0x5);
}
- if (i == 10) {
- printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
- netxen_nic_driver_name, adapter->netdev->name);
- printk(KERN_ERR "MAC address set: %pM.\n", addr);
- printk(KERN_ERR "MAC address get: %pM.\n", mac_addr);
- }
return 0;
}
@@ -545,8 +415,7 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
return -EINVAL;
mac_cfg0 = 0;
netxen_gb_soft_reset(mac_cfg0);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
- &mac_cfg0, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), mac_cfg0))
return -EIO;
return 0;
}
@@ -564,8 +433,8 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
return -EINVAL;
mac_cfg = 0;
- if (adapter->hw_write_wx(adapter,
- NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), &mac_cfg, 4))
+ if (NXWR32(adapter,
+ NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), mac_cfg))
return -EIO;
return 0;
}
@@ -581,9 +450,7 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
return -EINVAL;
/* save previous contents */
- if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
- &reg, 4))
- return -EIO;
+ reg = NXRD32(adapter, NETXEN_NIU_GB_DROP_WRONGADDR);
if (mode == NETXEN_NIU_PROMISC_MODE) {
switch (port) {
case 0:
@@ -619,67 +486,11 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
return -EIO;
}
}
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
- &reg, 4))
+ if (NXWR32(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, reg))
return -EIO;
return 0;
}
-/*
- * Set the MAC address for an XG port
- * Note that the passed-in value must already be in network byte order.
- */
-int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
- netxen_ethernet_macaddr_t addr)
-{
- int phy = adapter->physical_port;
- u8 temp[4];
- u32 val;
-
- if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
- return 0;
-
- if ((phy < 0) || (phy > NETXEN_NIU_MAX_XG_PORTS))
- return -EIO;
-
- temp[0] = temp[1] = 0;
- switch (phy) {
- case 0:
- memcpy(temp + 2, addr, 2);
- val = le32_to_cpu(*(__le32 *)temp);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
- &val, 4))
- return -EIO;
-
- memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
- val = le32_to_cpu(*(__le32 *)temp);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
- &val, 4))
- return -EIO;
- break;
-
- case 1:
- memcpy(temp + 2, addr, 2);
- val = le32_to_cpu(*(__le32 *)temp);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_1,
- &val, 4))
- return -EIO;
-
- memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
- val = le32_to_cpu(*(__le32 *)temp);
- if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_HI,
- &val, 4))
- return -EIO;
- break;
-
- default:
- printk(KERN_ERR "Unknown port %d\n", phy);
- break;
- }
-
- return 0;
-}
-
int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
u32 mode)
{
@@ -689,9 +500,7 @@ int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
if (port > NETXEN_NIU_MAX_XG_PORTS)
return -EINVAL;
- if (adapter->hw_read_wx(adapter,
- NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), &reg, 4))
- return -EIO;
+ reg = NXRD32(adapter, NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port));
if (mode == NETXEN_NIU_PROMISC_MODE)
reg = (reg | 0x2000UL);
else
@@ -702,8 +511,40 @@ int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
else
reg = (reg & ~0x1000UL);
- netxen_crb_writelit_adapter(adapter,
- NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg);
+ NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg);
+
+ return 0;
+}
+
+int netxen_p2_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr)
+{
+ u32 mac_hi, mac_lo;
+ u32 reg_hi, reg_lo;
+
+ u8 phy = adapter->physical_port;
+ u8 phy_count = (adapter->ahw.port_type == NETXEN_NIC_XGBE) ?
+ NETXEN_NIU_MAX_XG_PORTS : NETXEN_NIU_MAX_GBE_PORTS;
+
+ if (phy >= phy_count)
+ return -EINVAL;
+
+ mac_lo = ((u32)addr[0] << 16) | ((u32)addr[1] << 24);
+ mac_hi = addr[2] | ((u32)addr[3] << 8) |
+ ((u32)addr[4] << 16) | ((u32)addr[5] << 24);
+
+ if (adapter->ahw.port_type == NETXEN_NIC_XGBE) {
+ reg_lo = NETXEN_NIU_XGE_STATION_ADDR_0_1 + (0x10000 * phy);
+ reg_hi = NETXEN_NIU_XGE_STATION_ADDR_0_HI + (0x10000 * phy);
+ } else {
+ reg_lo = NETXEN_NIU_GB_STATION_ADDR_1(phy);
+ reg_hi = NETXEN_NIU_GB_STATION_ADDR_0(phy);
+ }
+
+ /* write twice to flush */
+ if (NXWR32(adapter, reg_lo, mac_lo) || NXWR32(adapter, reg_hi, mac_hi))
+ return -EIO;
+ if (NXWR32(adapter, reg_lo, mac_lo) || NXWR32(adapter, reg_hi, mac_hi))
+ return -EIO;
return 0;
}
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index 50183335e43a..b73a62ca74f8 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -36,23 +36,25 @@
*/
#define NIC_CRB_BASE NETXEN_CAM_RAM(0x200)
#define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X))
+#define NIC_CRB_BASE_2 NETXEN_CAM_RAM(0x700)
+#define NETXEN_NIC_REG_2(X) (NIC_CRB_BASE_2+(X))
#define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00)
#define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04)
#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08)
#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c)
-#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10) /* C0 EPG BUG */
+#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10)
#define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14)
#define NX_CDRP_CRB_OFFSET NETXEN_NIC_REG(0x18)
#define NX_ARG1_CRB_OFFSET NETXEN_NIC_REG(0x1c)
#define NX_ARG2_CRB_OFFSET NETXEN_NIC_REG(0x20)
#define NX_ARG3_CRB_OFFSET NETXEN_NIC_REG(0x24)
#define NX_SIGN_CRB_OFFSET NETXEN_NIC_REG(0x28)
-#define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x20) /* 4 regs for perf */
+#define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x20)
#define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x24)
#define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x28)
#define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x2c)
-#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x30) /* phantom init status */
+#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x30)
#define CRB_MMAP_ADDR_3 NETXEN_NIC_REG(0x34)
#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x38)
#define CRB_HOST_DUMMY_BUF_ADDR_HI NETXEN_NIC_REG(0x3c)
@@ -65,7 +67,7 @@
#define CRB_MMAP_SIZE_1 NETXEN_NIC_REG(0x58)
#define CRB_MMAP_SIZE_2 NETXEN_NIC_REG(0x5c)
#define CRB_MMAP_SIZE_3 NETXEN_NIC_REG(0x60)
-#define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x64) /* interrupt coalescing */
+#define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x64)
#define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x68)
#define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x6c)
#define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x70)
@@ -83,13 +85,13 @@
#define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xa0)
#define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xa4)
#define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xa8)
-#define CRB_TX_STATE NETXEN_NIC_REG(0xac) /* Debug -performance */
+#define CRB_TX_STATE NETXEN_NIC_REG(0xac)
#define CRB_TX_COUNT NETXEN_NIC_REG(0xb0)
#define CRB_RX_STATE NETXEN_NIC_REG(0xb4)
#define CRB_RX_PERF_DEBUG_1 NETXEN_NIC_REG(0xb8)
-#define CRB_RX_LRO_CONTROL NETXEN_NIC_REG(0xbc) /* LRO On/OFF */
+#define CRB_RX_LRO_CONTROL NETXEN_NIC_REG(0xbc)
#define CRB_RX_LRO_START_NUM NETXEN_NIC_REG(0xc0)
-#define CRB_MPORT_MODE NETXEN_NIC_REG(0xc4) /* Multiport Mode */
+#define CRB_MPORT_MODE NETXEN_NIC_REG(0xc4)
#define CRB_CMD_RING_SIZE NETXEN_NIC_REG(0xc8)
#define CRB_DMA_SHIFT NETXEN_NIC_REG(0xcc)
#define CRB_INT_VECTOR NETXEN_NIC_REG(0xd4)
@@ -109,8 +111,6 @@
#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0)
#define CRB_CMD_PRODUCER_OFFSET_2 NETXEN_NIC_REG(0x1b8)
#define CRB_CMD_CONSUMER_OFFSET_2 NETXEN_NIC_REG(0x1bc)
-
-// 1c0 to 1cc used for signature reg
#define CRB_CMD_PRODUCER_OFFSET_3 NETXEN_NIC_REG(0x1d0)
#define CRB_CMD_CONSUMER_OFFSET_3 NETXEN_NIC_REG(0x1d4)
#define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4)
@@ -120,13 +120,13 @@
#define CRB_V2P_2 NETXEN_NIC_REG(0x298)
#define CRB_V2P_3 NETXEN_NIC_REG(0x29c)
#define CRB_V2P(port) (CRB_V2P_0+((port)*4))
-#define CRB_DRIVER_VERSION NETXEN_NIC_REG(0x2a0)
-/* sw int status/mask registers */
+#define CRB_DRIVER_VERSION NETXEN_NIC_REG(0x2a0)
#define CRB_SW_INT_MASK_0 NETXEN_NIC_REG(0x1d8)
#define CRB_SW_INT_MASK_1 NETXEN_NIC_REG(0x1e0)
#define CRB_SW_INT_MASK_2 NETXEN_NIC_REG(0x1e4)
#define CRB_SW_INT_MASK_3 NETXEN_NIC_REG(0x1e8)
+#define CRB_FW_CAPABILITIES_1 NETXEN_CAM_RAM(0x128)
#define CRB_MAC_BLOCK_START NETXEN_CAM_RAM(0x1c0)
/*
@@ -136,7 +136,7 @@
#define CRB_NIC_CAPABILITIES_HOST NETXEN_NIC_REG(0x1a8)
#define CRB_NIC_CAPABILITIES_FW NETXEN_NIC_REG(0x1dc)
#define CRB_NIC_MSI_MODE_HOST NETXEN_NIC_REG(0x270)
-#define CRB_NIC_MSI_MODE_FW NETXEN_NIC_REG(0x274)
+#define CRB_NIC_MSI_MODE_FW NETXEN_NIC_REG(0x274)
#define INTR_SCHEME_PERPORT 0x1
#define MSI_MODE_MULTIFUNC 0x1
@@ -162,7 +162,8 @@
struct netxen_recv_crb {
u32 crb_rcv_producer[NUM_RCV_DESC_RINGS];
- u32 crb_sts_consumer;
+ u32 crb_sts_consumer[NUM_STS_DESC_RINGS];
+ u32 sw_int_mask[NUM_STS_DESC_RINGS];
};
/*
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 8754e44cadae..3bd0b5933d59 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -3242,8 +3242,8 @@ struct niu {
struct niu_parent *parent;
u32 flags;
-#define NIU_FLAGS_HOTPLUG_PHY_PRESENT 0x02000000 /* Removebale PHY detected*/
-#define NIU_FLAGS_HOTPLUG_PHY 0x01000000 /* Removebale PHY */
+#define NIU_FLAGS_HOTPLUG_PHY_PRESENT 0x02000000 /* Removeable PHY detected*/
+#define NIU_FLAGS_HOTPLUG_PHY 0x01000000 /* Removeable PHY */
#define NIU_FLAGS_VPD_VALID 0x00800000 /* VPD has valid version */
#define NIU_FLAGS_MSIX 0x00400000 /* MSI-X in use */
#define NIU_FLAGS_MCAST 0x00200000 /* multicast filter enabled */
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 5eeb5a87b738..c254a7f5b9f5 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -24,6 +24,7 @@
#include <linux/dmaengine.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
+#include <linux/of_mdio.h>
#include <linux/etherdevice.h>
#include <asm/dma-mapping.h>
#include <linux/in.h>
@@ -1086,34 +1087,17 @@ static int pasemi_mac_phy_init(struct net_device *dev)
struct pasemi_mac *mac = netdev_priv(dev);
struct device_node *dn, *phy_dn;
struct phy_device *phydev;
- unsigned int phy_id;
- const phandle *ph;
- const unsigned int *prop;
- struct resource r;
- int ret;
dn = pci_device_to_OF_node(mac->pdev);
- ph = of_get_property(dn, "phy-handle", NULL);
- if (!ph)
- return -ENODEV;
- phy_dn = of_find_node_by_phandle(*ph);
-
- prop = of_get_property(phy_dn, "reg", NULL);
- ret = of_address_to_resource(phy_dn->parent, 0, &r);
- if (ret)
- goto err;
-
- phy_id = *prop;
- snprintf(mac->phy_id, sizeof(mac->phy_id), "%x:%02x",
- (int)r.start, phy_id);
-
+ phy_dn = of_parse_phandle(dn, "phy-handle", 0);
of_node_put(phy_dn);
mac->link = 0;
mac->speed = 0;
mac->duplex = -1;
- phydev = phy_connect(dev, mac->phy_id, &pasemi_adjust_link, 0, PHY_INTERFACE_MODE_SGMII);
+ phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0,
+ PHY_INTERFACE_MODE_SGMII);
if (IS_ERR(phydev)) {
printk(KERN_ERR "%s: Could not attach to phy\n", dev->name);
@@ -1123,10 +1107,6 @@ static int pasemi_mac_phy_init(struct net_device *dev)
mac->phydev = phydev;
return 0;
-
-err:
- of_node_put(phy_dn);
- return -ENODEV;
}
@@ -1735,12 +1715,25 @@ out:
return ret;
}
+static const struct net_device_ops pasemi_netdev_ops = {
+ .ndo_open = pasemi_mac_open,
+ .ndo_stop = pasemi_mac_close,
+ .ndo_start_xmit = pasemi_mac_start_tx,
+ .ndo_set_multicast_list = pasemi_mac_set_rx_mode,
+ .ndo_set_mac_address = pasemi_mac_set_mac_addr,
+ .ndo_change_mtu = pasemi_mac_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = pasemi_mac_netpoll,
+#endif
+};
+
static int __devinit
pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct pasemi_mac *mac;
- int err;
+ int err, ret;
err = pci_enable_device(pdev);
if (err)
@@ -1798,12 +1791,13 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
}
memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr));
- mac->dma_if = mac_to_intf(mac);
- if (mac->dma_if < 0) {
+ ret = mac_to_intf(mac);
+ if (ret < 0) {
dev_err(&mac->pdev->dev, "Can't map DMA interface\n");
err = -ENODEV;
goto out;
}
+ mac->dma_if = ret;
switch (pdev->device) {
case 0xa005:
@@ -1817,19 +1811,11 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto out;
}
- dev->open = pasemi_mac_open;
- dev->stop = pasemi_mac_close;
- dev->hard_start_xmit = pasemi_mac_start_tx;
- dev->set_multicast_list = pasemi_mac_set_rx_mode;
- dev->set_mac_address = pasemi_mac_set_mac_addr;
+ dev->netdev_ops = &pasemi_netdev_ops;
dev->mtu = PE_DEF_MTU;
/* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
mac->bufsz = dev->mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = pasemi_mac_netpoll;
-#endif
- dev->change_mtu = pasemi_mac_change_mtu;
dev->ethtool_ops = &pasemi_mac_ethtool_ops;
if (err)
diff --git a/drivers/net/pasemi_mac.h b/drivers/net/pasemi_mac.h
index 1a115ec60b53..e2f4efa8ad46 100644
--- a/drivers/net/pasemi_mac.h
+++ b/drivers/net/pasemi_mac.h
@@ -100,7 +100,6 @@ struct pasemi_mac {
int duplex;
unsigned int msg_enable;
- char phy_id[BUS_ID_SIZE];
};
/* Software status descriptor (ring_info) */
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index c95fd72c3bb9..8c1f6988f398 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -728,6 +728,17 @@ err_out:
return rc;
}
+static const struct net_device_ops netdrv_netdev_ops = {
+ .ndo_open = netdrv_open,
+ .ndo_stop = netdrv_close,
+ .ndo_start_xmit = netdrv_start_xmit,
+ .ndo_set_multicast_list = netdrv_set_rx_mode,
+ .ndo_do_ioctl = netdrv_ioctl,
+ .ndo_tx_timeout = netdrv_tx_timeout,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
static int __devinit netdrv_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent)
@@ -769,13 +780,7 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
((u16 *) (dev->dev_addr))[i] =
le16_to_cpu (read_eeprom (ioaddr, i + 7, addr_len));
- /* The Rtl8139-specific entries in the device structure. */
- dev->open = netdrv_open;
- dev->hard_start_xmit = netdrv_start_xmit;
- dev->stop = netdrv_close;
- dev->set_multicast_list = netdrv_set_rx_mode;
- dev->do_ioctl = netdrv_ioctl;
- dev->tx_timeout = netdrv_tx_timeout;
+ dev->netdev_ops = &netdrv_netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
dev->irq = pdev->irq;
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 8f3872b8985d..f35c609ba020 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -1195,7 +1195,7 @@ static int el3_close(struct net_device *dev)
static struct pcmcia_device_id tc574_ids[] = {
PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0574),
- PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0556, "3CCFEM556.cis"),
+ PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0556, "cis/3CCFEM556.cis"),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, tc574_ids);
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index cdf661a6092c..ec7cf5ac4f05 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -967,8 +967,8 @@ static struct pcmcia_device_id tc589_ids[] = {
PCMCIA_MFC_DEVICE_PROD_ID1(0, "Motorola MARQUIS", 0xf03e4e77),
PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0589),
PCMCIA_DEVICE_PROD_ID12("Farallon", "ENet", 0x58d93fc4, 0x992c2202),
- PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0035, "3CXEM556.cis"),
- PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x003d, "3CXEM556.cis"),
+ PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0035, "cis/3CXEM556.cis"),
+ PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x003d, "cis/3CXEM556.cis"),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, tc589_ids);
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 80124fac65fa..1c35e1d637a0 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1227,7 +1227,6 @@ static void pcnet32_rx_entry(struct net_device *dev,
dev->stats.rx_dropped++;
return;
}
- skb->dev = dev;
if (!rx_in_place) {
skb_reserve(skb, NET_IP_ALIGN);
skb_put(skb, pkt_len); /* Make room */
@@ -1406,7 +1405,7 @@ static int pcnet32_poll(struct napi_struct *napi, int budget)
/* Set interrupt enable. */
lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN);
- mmiowb();
+
spin_unlock_irqrestore(&lp->lock, flags);
}
return work_done;
@@ -2598,7 +2597,7 @@ pcnet32_interrupt(int irq, void *dev_id)
val = lp->a.read_csr(ioaddr, CSR3);
val |= 0x5f00;
lp->a.write_csr(ioaddr, CSR3, val);
- mmiowb();
+
__napi_schedule(&lp->napi);
break;
}
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b754020cbe75..bd4e8d72dc08 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -113,7 +113,6 @@ int mdiobus_register(struct mii_bus *bus)
bus->reset(bus);
for (i = 0; i < PHY_MAX_ADDR; i++) {
- bus->phy_map[i] = NULL;
if ((bus->phy_mask & (1 << i)) == 0) {
struct phy_device *phydev;
@@ -150,6 +149,7 @@ void mdiobus_unregister(struct mii_bus *bus)
for (i = 0; i < PHY_MAX_ADDR; i++) {
if (bus->phy_map[i])
device_unregister(&bus->phy_map[i]->dev);
+ bus->phy_map[i] = NULL;
}
}
EXPORT_SYMBOL(mdiobus_unregister);
@@ -188,35 +188,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
if (IS_ERR(phydev) || phydev == NULL)
return phydev;
- /* There's a PHY at this address
- * We need to set:
- * 1) IRQ
- * 2) bus_id
- * 3) parent
- * 4) bus
- * 5) mii_bus
- * And, we need to register it */
-
- phydev->irq = bus->irq != NULL ? bus->irq[addr] : PHY_POLL;
-
- phydev->dev.parent = bus->parent;
- phydev->dev.bus = &mdio_bus_type;
- dev_set_name(&phydev->dev, PHY_ID_FMT, bus->id, addr);
-
- phydev->bus = bus;
-
- /* Run all of the fixups for this PHY */
- phy_scan_fixups(phydev);
-
- err = device_register(&phydev->dev);
+ err = phy_device_register(phydev);
if (err) {
- printk(KERN_ERR "phy %d failed to register\n", addr);
phy_device_free(phydev);
- phydev = NULL;
+ return NULL;
}
- bus->phy_map[addr] = phydev;
-
return phydev;
}
EXPORT_SYMBOL(mdiobus_scan);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 0a06e4fd37d9..a2ece89622d6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -39,20 +39,21 @@ MODULE_DESCRIPTION("PHY library");
MODULE_AUTHOR("Andy Fleming");
MODULE_LICENSE("GPL");
-static struct phy_driver genphy_driver;
-extern int mdio_bus_init(void);
-extern void mdio_bus_exit(void);
-
void phy_device_free(struct phy_device *phydev)
{
kfree(phydev);
}
+EXPORT_SYMBOL(phy_device_free);
static void phy_device_release(struct device *dev)
{
phy_device_free(to_phy_device(dev));
}
+static struct phy_driver genphy_driver;
+extern int mdio_bus_init(void);
+extern void mdio_bus_exit(void);
+
static LIST_HEAD(phy_fixup_list);
static DEFINE_MUTEX(phy_fixup_lock);
@@ -166,6 +167,10 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
dev->addr = addr;
dev->phy_id = phy_id;
dev->bus = bus;
+ dev->dev.parent = bus->parent;
+ dev->dev.bus = &mdio_bus_type;
+ dev->irq = bus->irq != NULL ? bus->irq[addr] : PHY_POLL;
+ dev_set_name(&dev->dev, PHY_ID_FMT, bus->id, addr);
dev->state = PHY_DOWN;
@@ -235,6 +240,38 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
return dev;
}
+EXPORT_SYMBOL(get_phy_device);
+
+/**
+ * phy_device_register - Register the phy device on the MDIO bus
+ * @phy_device: phy_device structure to be added to the MDIO bus
+ */
+int phy_device_register(struct phy_device *phydev)
+{
+ int err;
+
+ /* Don't register a phy if one is already registered at this
+ * address */
+ if (phydev->bus->phy_map[phydev->addr])
+ return -EINVAL;
+ phydev->bus->phy_map[phydev->addr] = phydev;
+
+ /* Run all of the fixups for this PHY */
+ phy_scan_fixups(phydev);
+
+ err = device_register(&phydev->dev);
+ if (err) {
+ pr_err("phy %d failed to register\n", phydev->addr);
+ goto out;
+ }
+
+ return 0;
+
+ out:
+ phydev->bus->phy_map[phydev->addr] = NULL;
+ return err;
+}
+EXPORT_SYMBOL(phy_device_register);
/**
* phy_prepare_link - prepares the PHY layer to monitor link status
@@ -255,6 +292,33 @@ void phy_prepare_link(struct phy_device *phydev,
}
/**
+ * phy_connect_direct - connect an ethernet device to a specific phy_device
+ * @dev: the network device to connect
+ * @phydev: the pointer to the phy device
+ * @handler: callback function for state change notifications
+ * @flags: PHY device's dev_flags
+ * @interface: PHY device's interface
+ */
+int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
+ void (*handler)(struct net_device *), u32 flags,
+ phy_interface_t interface)
+{
+ int rc;
+
+ rc = phy_attach_direct(dev, phydev, flags, interface);
+ if (rc)
+ return rc;
+
+ phy_prepare_link(phydev, handler);
+ phy_start_machine(phydev, NULL);
+ if (phydev->irq > 0)
+ phy_start_interrupts(phydev);
+
+ return 0;
+}
+EXPORT_SYMBOL(phy_connect_direct);
+
+/**
* phy_connect - connect an ethernet device to a PHY device
* @dev: the network device to connect
* @bus_id: the id string of the PHY device to connect
@@ -275,18 +339,21 @@ struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,
phy_interface_t interface)
{
struct phy_device *phydev;
+ struct device *d;
+ int rc;
- phydev = phy_attach(dev, bus_id, flags, interface);
-
- if (IS_ERR(phydev))
- return phydev;
-
- phy_prepare_link(phydev, handler);
-
- phy_start_machine(phydev, NULL);
+ /* Search the list of PHY devices on the mdio bus for the
+ * PHY with the requested name */
+ d = bus_find_device_by_name(&mdio_bus_type, NULL, bus_id);
+ if (!d) {
+ pr_err("PHY %s not found\n", bus_id);
+ return ERR_PTR(-ENODEV);
+ }
+ phydev = to_phy_device(d);
- if (phydev->irq > 0)
- phy_start_interrupts(phydev);
+ rc = phy_connect_direct(dev, phydev, handler, flags, interface);
+ if (rc)
+ return ERR_PTR(rc);
return phydev;
}
@@ -310,9 +377,9 @@ void phy_disconnect(struct phy_device *phydev)
EXPORT_SYMBOL(phy_disconnect);
/**
- * phy_attach - attach a network device to a particular PHY device
+ * phy_attach_direct - attach a network device to a given PHY device pointer
* @dev: network device to attach
- * @bus_id: PHY device to attach
+ * @phydev: Pointer to phy_device to attach
* @flags: PHY device's dev_flags
* @interface: PHY device's interface
*
@@ -323,22 +390,10 @@ EXPORT_SYMBOL(phy_disconnect);
* the attaching device, and given a callback for link status
* change. The phy_device is returned to the attaching driver.
*/
-struct phy_device *phy_attach(struct net_device *dev,
- const char *bus_id, u32 flags, phy_interface_t interface)
+int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
+ u32 flags, phy_interface_t interface)
{
- struct bus_type *bus = &mdio_bus_type;
- struct phy_device *phydev;
- struct device *d;
-
- /* Search the list of PHY devices on the mdio bus for the
- * PHY with the requested name */
- d = bus_find_device_by_name(bus, NULL, bus_id);
- if (d) {
- phydev = to_phy_device(d);
- } else {
- printk(KERN_ERR "%s not found\n", bus_id);
- return ERR_PTR(-ENODEV);
- }
+ struct device *d = &phydev->dev;
/* Assume that if there is no driver, that it doesn't
* exist, and we should use the genphy driver. */
@@ -351,13 +406,12 @@ struct phy_device *phy_attach(struct net_device *dev,
err = device_bind_driver(d);
if (err)
- return ERR_PTR(err);
+ return err;
}
if (phydev->attached_dev) {
- printk(KERN_ERR "%s: %s already attached\n",
- dev->name, bus_id);
- return ERR_PTR(-EBUSY);
+ dev_err(&dev->dev, "PHY already attached\n");
+ return -EBUSY;
}
phydev->attached_dev = dev;
@@ -375,14 +429,49 @@ struct phy_device *phy_attach(struct net_device *dev,
err = phy_scan_fixups(phydev);
if (err < 0)
- return ERR_PTR(err);
+ return err;
err = phydev->drv->config_init(phydev);
if (err < 0)
- return ERR_PTR(err);
+ return err;
}
+ return 0;
+}
+EXPORT_SYMBOL(phy_attach_direct);
+
+/**
+ * phy_attach - attach a network device to a particular PHY device
+ * @dev: network device to attach
+ * @bus_id: Bus ID of PHY device to attach
+ * @flags: PHY device's dev_flags
+ * @interface: PHY device's interface
+ *
+ * Description: Same as phy_attach_direct() except that a PHY bus_id
+ * string is passed instead of a pointer to a struct phy_device.
+ */
+struct phy_device *phy_attach(struct net_device *dev,
+ const char *bus_id, u32 flags, phy_interface_t interface)
+{
+ struct bus_type *bus = &mdio_bus_type;
+ struct phy_device *phydev;
+ struct device *d;
+ int rc;
+
+ /* Search the list of PHY devices on the mdio bus for the
+ * PHY with the requested name */
+ d = bus_find_device_by_name(bus, NULL, bus_id);
+ if (!d) {
+ pr_err("PHY %s not found\n", bus_id);
+ return ERR_PTR(-ENODEV);
+ }
+ phydev = to_phy_device(d);
+
+ rc = phy_attach_direct(dev, phydev, flags, interface);
+ if (rc)
+ return ERR_PTR(rc);
+
return phydev;
}
EXPORT_SYMBOL(phy_attach);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 8ee91421db12..639d11bc444e 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1054,6 +1054,7 @@ static void ppp_setup(struct net_device *dev)
dev->type = ARPHRD_PPP;
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
dev->features |= NETIF_F_NETNS_LOCAL;
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
}
/*
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 5b07dd8e5c04..5981debcde5e 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -1238,8 +1238,7 @@ static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
struct pppol2tp_session *session;
struct sock *sk;
- if (tunnel == NULL)
- BUG();
+ BUG_ON(tunnel == NULL);
PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
"%s: closing all sessions...\n", tunnel->name);
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c
index 9f81b797f10b..ac9493f6c1a1 100644
--- a/drivers/net/qlge/qlge_mpi.c
+++ b/drivers/net/qlge/qlge_mpi.c
@@ -141,7 +141,7 @@ end:
/* We are being asked by firmware to accept
* a change to the port. This is only
* a change to max frame sizes (Tx/Rx), pause
- * paramters, or loopback mode. We wake up a worker
+ * parameters, or loopback mode. We wake up a worker
* to handler processing this since a mailbox command
* will need to be sent to ACK the request.
*/
@@ -371,7 +371,7 @@ static int ql_mpi_handler(struct ql_adapter *qdev, struct mbox_params *mbcp)
/* We are being asked by firmware to accept
* a change to the port. This is only
* a change to max frame sizes (Tx/Rx), pause
- * paramters, or loopback mode.
+ * parameters, or loopback mode.
*/
case AEN_IDC_REQ:
status = ql_idc_req_aen(qdev);
@@ -380,7 +380,7 @@ static int ql_mpi_handler(struct ql_adapter *qdev, struct mbox_params *mbcp)
/* Process and inbound IDC event.
* This will happen when we're trying to
* change tx/rx max frame size, change pause
- * paramters or loopback mode.
+ * parameters or loopback mode.
*/
case AEN_IDC_CMPLT:
case AEN_IDC_EXT:
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 6f97b47d74a6..1508b124e3d8 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -49,8 +49,8 @@
#include <asm/processor.h>
#define DRV_NAME "r6040"
-#define DRV_VERSION "0.22"
-#define DRV_RELDATE "25Mar2009"
+#define DRV_VERSION "0.23"
+#define DRV_RELDATE "05May2009"
/* PHY CHIP Address */
#define PHY1_ADDR 1 /* For MAC1 */
@@ -742,6 +742,14 @@ static int r6040_up(struct net_device *dev)
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
int ret;
+ u16 val;
+
+ /* Check presence of a second PHY */
+ val = r6040_phy_read(ioaddr, lp->phy_addr, 2);
+ if (val == 0xFFFF) {
+ printk(KERN_ERR DRV_NAME " no second PHY attached\n");
+ return -EIO;
+ }
/* Initialise and alloc RX/TX buffers */
r6040_init_txbufs(dev);
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 0b6e8c896835..023cba404ea5 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -479,7 +479,6 @@ struct rtl8169_private {
u16 intr_event;
u16 napi_event;
u16 intr_mask;
- int phy_auto_nego_reg;
int phy_1000_ctrl_reg;
#ifdef CONFIG_R8169_VLAN
struct vlan_group *vlgrp;
@@ -844,76 +843,81 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
{
struct rtl8169_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
- int auto_nego, giga_ctrl;
-
- auto_nego = mdio_read(ioaddr, MII_ADVERTISE);
- auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL |
- ADVERTISE_100HALF | ADVERTISE_100FULL);
- giga_ctrl = mdio_read(ioaddr, MII_CTRL1000);
- giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
+ int giga_ctrl, bmcr;
if (autoneg == AUTONEG_ENABLE) {
+ int auto_nego;
+
+ auto_nego = mdio_read(ioaddr, MII_ADVERTISE);
auto_nego |= (ADVERTISE_10HALF | ADVERTISE_10FULL |
ADVERTISE_100HALF | ADVERTISE_100FULL);
- giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF;
- } else {
- if (speed == SPEED_10)
- auto_nego |= ADVERTISE_10HALF | ADVERTISE_10FULL;
- else if (speed == SPEED_100)
- auto_nego |= ADVERTISE_100HALF | ADVERTISE_100FULL;
- else if (speed == SPEED_1000)
- giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF;
+ auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
- if (duplex == DUPLEX_HALF)
- auto_nego &= ~(ADVERTISE_10FULL | ADVERTISE_100FULL);
-
- if (duplex == DUPLEX_FULL)
- auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_100HALF);
-
- /* This tweak comes straight from Realtek's driver. */
- if ((speed == SPEED_100) && (duplex == DUPLEX_HALF) &&
- ((tp->mac_version == RTL_GIGA_MAC_VER_13) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_16))) {
- auto_nego = ADVERTISE_100HALF | ADVERTISE_CSMA;
- }
- }
+ giga_ctrl = mdio_read(ioaddr, MII_CTRL1000);
+ giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
- /* The 8100e/8101e/8102e do Fast Ethernet only. */
- if ((tp->mac_version == RTL_GIGA_MAC_VER_07) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_08) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_09) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_10) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_13) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_14) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_15) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_16)) {
- if ((giga_ctrl & (ADVERTISE_1000FULL | ADVERTISE_1000HALF)) &&
- netif_msg_link(tp)) {
+ /* The 8100e/8101e/8102e do Fast Ethernet only. */
+ if ((tp->mac_version != RTL_GIGA_MAC_VER_07) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_08) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_09) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_10) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_13) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_14) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_15) &&
+ (tp->mac_version != RTL_GIGA_MAC_VER_16)) {
+ giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF;
+ } else if (netif_msg_link(tp)) {
printk(KERN_INFO "%s: PHY does not support 1000Mbps.\n",
dev->name);
}
- giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
- }
- auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
+ bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
+
+ if ((tp->mac_version == RTL_GIGA_MAC_VER_11) ||
+ (tp->mac_version == RTL_GIGA_MAC_VER_12) ||
+ (tp->mac_version >= RTL_GIGA_MAC_VER_17)) {
+ /*
+ * Wake up the PHY.
+ * Vendor specific (0x1f) and reserved (0x0e) MII
+ * registers.
+ */
+ mdio_write(ioaddr, 0x1f, 0x0000);
+ mdio_write(ioaddr, 0x0e, 0x0000);
+ }
+
+ mdio_write(ioaddr, MII_ADVERTISE, auto_nego);
+ mdio_write(ioaddr, MII_CTRL1000, giga_ctrl);
+ } else {
+ giga_ctrl = 0;
+
+ if (speed == SPEED_10)
+ bmcr = 0;
+ else if (speed == SPEED_100)
+ bmcr = BMCR_SPEED100;
+ else
+ return -EINVAL;
+
+ if (duplex == DUPLEX_FULL)
+ bmcr |= BMCR_FULLDPLX;
- if ((tp->mac_version == RTL_GIGA_MAC_VER_11) ||
- (tp->mac_version == RTL_GIGA_MAC_VER_12) ||
- (tp->mac_version >= RTL_GIGA_MAC_VER_17)) {
- /*
- * Wake up the PHY.
- * Vendor specific (0x1f) and reserved (0x0e) MII registers.
- */
mdio_write(ioaddr, 0x1f, 0x0000);
- mdio_write(ioaddr, 0x0e, 0x0000);
}
- tp->phy_auto_nego_reg = auto_nego;
tp->phy_1000_ctrl_reg = giga_ctrl;
- mdio_write(ioaddr, MII_ADVERTISE, auto_nego);
- mdio_write(ioaddr, MII_CTRL1000, giga_ctrl);
- mdio_write(ioaddr, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
+ mdio_write(ioaddr, MII_BMCR, bmcr);
+
+ if ((tp->mac_version == RTL_GIGA_MAC_VER_02) ||
+ (tp->mac_version == RTL_GIGA_MAC_VER_03)) {
+ if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) {
+ mdio_write(ioaddr, 0x17, 0x2138);
+ mdio_write(ioaddr, 0x0e, 0x0260);
+ } else {
+ mdio_write(ioaddr, 0x17, 0x2108);
+ mdio_write(ioaddr, 0x0e, 0x0000);
+ }
+ }
+
return 0;
}
@@ -3554,54 +3558,64 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
int handled = 0;
int status;
+ /* loop handling interrupts until we have no new ones or
+ * we hit a invalid/hotplug case.
+ */
status = RTL_R16(IntrStatus);
+ while (status && status != 0xffff) {
+ handled = 1;
- /* hotplug/major error/no more work/shared irq */
- if ((status == 0xffff) || !status)
- goto out;
-
- handled = 1;
+ /* Handle all of the error cases first. These will reset
+ * the chip, so just exit the loop.
+ */
+ if (unlikely(!netif_running(dev))) {
+ rtl8169_asic_down(ioaddr);
+ break;
+ }
- if (unlikely(!netif_running(dev))) {
- rtl8169_asic_down(ioaddr);
- goto out;
- }
+ /* Work around for rx fifo overflow */
+ if (unlikely(status & RxFIFOOver) &&
+ (tp->mac_version == RTL_GIGA_MAC_VER_11)) {
+ netif_stop_queue(dev);
+ rtl8169_tx_timeout(dev);
+ break;
+ }
- status &= tp->intr_mask;
- RTL_W16(IntrStatus,
- (status & RxFIFOOver) ? (status | RxOverflow) : status);
+ if (unlikely(status & SYSErr)) {
+ rtl8169_pcierr_interrupt(dev);
+ break;
+ }
- if (!(status & tp->intr_event))
- goto out;
+ if (status & LinkChg)
+ rtl8169_check_link_status(dev, tp, ioaddr);
- /* Work around for rx fifo overflow */
- if (unlikely(status & RxFIFOOver) &&
- (tp->mac_version == RTL_GIGA_MAC_VER_11)) {
- netif_stop_queue(dev);
- rtl8169_tx_timeout(dev);
- goto out;
- }
+ /* We need to see the lastest version of tp->intr_mask to
+ * avoid ignoring an MSI interrupt and having to wait for
+ * another event which may never come.
+ */
+ smp_rmb();
+ if (status & tp->intr_mask & tp->napi_event) {
+ RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event);
+ tp->intr_mask = ~tp->napi_event;
+
+ if (likely(napi_schedule_prep(&tp->napi)))
+ __napi_schedule(&tp->napi);
+ else if (netif_msg_intr(tp)) {
+ printk(KERN_INFO "%s: interrupt %04x in poll\n",
+ dev->name, status);
+ }
+ }
- if (unlikely(status & SYSErr)) {
- rtl8169_pcierr_interrupt(dev);
- goto out;
+ /* We only get a new MSI interrupt when all active irq
+ * sources on the chip have been acknowledged. So, ack
+ * everything we've seen and check if new sources have become
+ * active to avoid blocking all interrupts from the chip.
+ */
+ RTL_W16(IntrStatus,
+ (status & RxFIFOOver) ? (status | RxOverflow) : status);
+ status = RTL_R16(IntrStatus);
}
- if (status & LinkChg)
- rtl8169_check_link_status(dev, tp, ioaddr);
-
- if (status & tp->napi_event) {
- RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event);
- tp->intr_mask = ~tp->napi_event;
-
- if (likely(napi_schedule_prep(&tp->napi)))
- __napi_schedule(&tp->napi);
- else if (netif_msg_intr(tp)) {
- printk(KERN_INFO "%s: interrupt %04x in poll\n",
- dev->name, status);
- }
- }
-out:
return IRQ_RETVAL(handled);
}
@@ -3617,13 +3631,15 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
if (work_done < budget) {
napi_complete(napi);
- tp->intr_mask = 0xffff;
- /*
- * 20040426: the barrier is not strictly required but the
- * behavior of the irq handler could be less predictable
- * without it. Btw, the lack of flush for the posted pci
- * write is safe - FR
+
+ /* We need for force the visibility of tp->intr_mask
+ * for other CPUs, as we can loose an MSI interrupt
+ * and potentially wait for a retransmit timeout if we don't.
+ * The posted write to IntrMask is safe, as it will
+ * eventually make it to the chip and we won't loose anything
+ * until it does.
*/
+ tp->intr_mask = 0xffff;
smp_wmb();
RTL_W16(IntrMask, tp->intr_event);
}
@@ -3791,16 +3807,13 @@ static struct net_device_stats *rtl8169_get_stats(struct net_device *dev)
return &dev->stats;
}
-#ifdef CONFIG_PM
-
-static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state)
+static void rtl8169_net_suspend(struct net_device *dev)
{
- struct net_device *dev = pci_get_drvdata(pdev);
struct rtl8169_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
if (!netif_running(dev))
- goto out_pci_suspend;
+ return;
netif_device_detach(dev);
netif_stop_queue(dev);
@@ -3812,24 +3825,25 @@ static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state)
rtl8169_rx_missed(dev, ioaddr);
spin_unlock_irq(&tp->lock);
+}
-out_pci_suspend:
- pci_save_state(pdev);
- pci_enable_wake(pdev, pci_choose_state(pdev, state),
- (tp->features & RTL_FEATURE_WOL) ? 1 : 0);
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
+#ifdef CONFIG_PM
+
+static int rtl8169_suspend(struct device *device)
+{
+ struct pci_dev *pdev = to_pci_dev(device);
+ struct net_device *dev = pci_get_drvdata(pdev);
+
+ rtl8169_net_suspend(dev);
return 0;
}
-static int rtl8169_resume(struct pci_dev *pdev)
+static int rtl8169_resume(struct device *device)
{
+ struct pci_dev *pdev = to_pci_dev(device);
struct net_device *dev = pci_get_drvdata(pdev);
- pci_set_power_state(pdev, PCI_D0);
- pci_restore_state(pdev);
- pci_enable_wake(pdev, PCI_D0, 0);
-
if (!netif_running(dev))
goto out;
@@ -3840,23 +3854,42 @@ out:
return 0;
}
+static struct dev_pm_ops rtl8169_pm_ops = {
+ .suspend = rtl8169_suspend,
+ .resume = rtl8169_resume,
+ .freeze = rtl8169_suspend,
+ .thaw = rtl8169_resume,
+ .poweroff = rtl8169_suspend,
+ .restore = rtl8169_resume,
+};
+
+#define RTL8169_PM_OPS (&rtl8169_pm_ops)
+
+#else /* !CONFIG_PM */
+
+#define RTL8169_PM_OPS NULL
+
+#endif /* !CONFIG_PM */
+
static void rtl_shutdown(struct pci_dev *pdev)
{
- rtl8169_suspend(pdev, PMSG_SUSPEND);
-}
+ struct net_device *dev = pci_get_drvdata(pdev);
-#endif /* CONFIG_PM */
+ rtl8169_net_suspend(dev);
+
+ if (system_state == SYSTEM_POWER_OFF) {
+ pci_wake_from_d3(pdev, true);
+ pci_set_power_state(pdev, PCI_D3hot);
+ }
+}
static struct pci_driver rtl8169_pci_driver = {
.name = MODULENAME,
.id_table = rtl8169_pci_tbl,
.probe = rtl8169_init_one,
.remove = __devexit_p(rtl8169_remove_one),
-#ifdef CONFIG_PM
- .suspend = rtl8169_suspend,
- .resume = rtl8169_resume,
.shutdown = rtl_shutdown,
-#endif
+ .driver.pm = RTL8169_PM_OPS,
};
static int __init rtl8169_init_module(void)
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index ec59e29807a6..8702e7acdee6 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -428,6 +428,15 @@ static const struct ethtool_ops rionet_ethtool_ops = {
.get_link = ethtool_op_get_link,
};
+static const struct net_device_ops rionet_netdev_ops = {
+ .ndo_open = rionet_open,
+ .ndo_stop = rionet_close,
+ .ndo_start_xmit = rionet_start_xmit,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+};
+
static int rionet_setup_netdev(struct rio_mport *mport)
{
int rc = 0;
@@ -466,10 +475,7 @@ static int rionet_setup_netdev(struct rio_mport *mport)
ndev->dev_addr[4] = device_id >> 8;
ndev->dev_addr[5] = device_id & 0xff;
- /* Fill in the driver function table */
- ndev->open = &rionet_open;
- ndev->hard_start_xmit = &rionet_start_xmit;
- ndev->stop = &rionet_close;
+ ndev->netdev_ops = &rionet_netdev_ops;
ndev->mtu = RIO_MAX_MSG_SIZE - 14;
ndev->features = NETIF_F_LLTX;
SET_ETHTOOL_OPS(ndev, &rionet_ethtool_ops);
diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h
index f8274f8941ea..416669fd68c6 100644
--- a/drivers/net/s2io-regs.h
+++ b/drivers/net/s2io-regs.h
@@ -271,11 +271,6 @@ struct XENA_dev_config {
u64 mdio_control;
#define MDIO_MMD_INDX_ADDR(val) vBIT(val, 0, 16)
#define MDIO_MMD_DEV_ADDR(val) vBIT(val, 19, 5)
-#define MDIO_MMD_PMA_DEV_ADDR 0x1
-#define MDIO_MMD_PMD_DEV_ADDR 0x1
-#define MDIO_MMD_WIS_DEV_ADDR 0x2
-#define MDIO_MMD_PCS_DEV_ADDR 0x3
-#define MDIO_MMD_PHYXS_DEV_ADDR 0x4
#define MDIO_MMS_PRT_ADDR(val) vBIT(val, 27, 5)
#define MDIO_CTRL_START_TRANS(val) vBIT(val, 56, 4)
#define MDIO_OP(val) vBIT(val, 60, 2)
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 1a4979f27fb5..80562ea77de3 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -63,6 +63,7 @@
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/mdio.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/delay.h>
@@ -3328,9 +3329,9 @@ static void s2io_updt_xpak_counter(struct net_device *dev)
struct stat_block *stat_info = sp->mac_control.stats_info;
/* Check the communication with the MDIO slave */
- addr = 0x0000;
+ addr = MDIO_CTRL1;
val64 = 0x0;
- val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
+ val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev);
if((val64 == 0xFFFF) || (val64 == 0x0000))
{
DBG_PRINT(ERR_DBG, "ERR: MDIO slave access failed - "
@@ -3338,24 +3339,24 @@ static void s2io_updt_xpak_counter(struct net_device *dev)
return;
}
- /* Check for the expecte value of 2040 at PMA address 0x0000 */
- if(val64 != 0x2040)
+ /* Check for the expected value of control reg 1 */
+ if(val64 != MDIO_CTRL1_SPEED10G)
{
DBG_PRINT(ERR_DBG, "Incorrect value at PMA address 0x0000 - ");
- DBG_PRINT(ERR_DBG, "Returned: %llx- Expected: 0x2040\n",
- (unsigned long long)val64);
+ DBG_PRINT(ERR_DBG, "Returned: %llx- Expected: 0x%x\n",
+ (unsigned long long)val64, MDIO_CTRL1_SPEED10G);
return;
}
/* Loading the DOM register to MDIO register */
addr = 0xA100;
- s2io_mdio_write(MDIO_MMD_PMA_DEV_ADDR, addr, val16, dev);
- val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
+ s2io_mdio_write(MDIO_MMD_PMAPMD, addr, val16, dev);
+ val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev);
/* Reading the Alarm flags */
addr = 0xA070;
val64 = 0x0;
- val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
+ val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev);
flag = CHECKBIT(val64, 0x7);
type = 1;
@@ -3387,7 +3388,7 @@ static void s2io_updt_xpak_counter(struct net_device *dev)
/* Reading the Warning flags */
addr = 0xA074;
val64 = 0x0;
- val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
+ val64 = s2io_mdio_read(MDIO_MMD_PMAPMD, addr, dev);
if(CHECKBIT(val64, 0x7))
stat_info->xpak_stat.warn_transceiver_temp_high++;
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index ce7551e17ba7..7a4b9fbddbaf 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2271,6 +2271,21 @@ static int sb1250_change_mtu(struct net_device *_dev, int new_mtu)
return 0;
}
+static const struct net_device_ops sbmac_netdev_ops = {
+ .ndo_open = sbmac_open,
+ .ndo_stop = sbmac_close,
+ .ndo_start_xmit = sbmac_start_tx,
+ .ndo_set_multicast_list = sbmac_set_rx_mode,
+ .ndo_tx_timeout = sbmac_tx_timeout,
+ .ndo_do_ioctl = sbmac_mii_ioctl,
+ .ndo_change_mtu = sb1250_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = sbmac_netpoll,
+#endif
+};
+
/**********************************************************************
* SBMAC_INIT(dev)
*
@@ -2285,7 +2300,7 @@ static int sb1250_change_mtu(struct net_device *_dev, int new_mtu)
static int sbmac_init(struct platform_device *pldev, long long base)
{
- struct net_device *dev = pldev->dev.driver_data;
+ struct net_device *dev = dev_get_drvdata(&pldev->dev);
int idx = pldev->id;
struct sbmac_softc *sc = netdev_priv(dev);
unsigned char *eaddr;
@@ -2327,21 +2342,11 @@ static int sbmac_init(struct platform_device *pldev, long long base)
spin_lock_init(&(sc->sbm_lock));
- dev->open = sbmac_open;
- dev->hard_start_xmit = sbmac_start_tx;
- dev->stop = sbmac_close;
- dev->set_multicast_list = sbmac_set_rx_mode;
- dev->do_ioctl = sbmac_mii_ioctl;
- dev->tx_timeout = sbmac_tx_timeout;
- dev->watchdog_timeo = TX_TIMEOUT;
+ dev->netdev_ops = &sbmac_netdev_ops;
+ dev->watchdog_timeo = TX_TIMEOUT;
netif_napi_add(dev, &sc->napi, sbmac_poll, 16);
- dev->change_mtu = sb1250_change_mtu;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = sbmac_netpoll;
-#endif
-
dev->irq = UNIT_INT(idx);
/* This is needed for PASS2 for Rx H/W checksum feature */
@@ -2726,7 +2731,7 @@ static int __init sbmac_probe(struct platform_device *pldev)
goto out_unmap;
}
- pldev->dev.driver_data = dev;
+ dev_set_drvdata(&pldev->dev, dev);
SET_NETDEV_DEV(dev, &pldev->dev);
sc = netdev_priv(dev);
@@ -2751,7 +2756,7 @@ out_out:
static int __exit sbmac_remove(struct platform_device *pldev)
{
- struct net_device *dev = pldev->dev.driver_data;
+ struct net_device *dev = dev_get_drvdata(&pldev->dev);
struct sbmac_softc *sc = netdev_priv(dev);
unregister_netdev(dev);
diff --git a/drivers/net/sfc/Kconfig b/drivers/net/sfc/Kconfig
index 12a82966b577..260aafaac235 100644
--- a/drivers/net/sfc/Kconfig
+++ b/drivers/net/sfc/Kconfig
@@ -1,7 +1,7 @@
config SFC
tristate "Solarflare Solarstorm SFC4000 support"
depends on PCI && INET
- select MII
+ select MDIO
select CRC32
select I2C
select I2C_ALGOBIT
diff --git a/drivers/net/sfc/boards.c b/drivers/net/sfc/boards.c
index 5182ac5a1034..4a4c74c891b7 100644
--- a/drivers/net/sfc/boards.c
+++ b/drivers/net/sfc/boards.c
@@ -172,7 +172,6 @@ static const u8 sfe4002_lm87_regs[] = {
static struct i2c_board_info sfe4002_hwmon_info = {
I2C_BOARD_INFO("lm87", 0x2e),
.platform_data = &sfe4002_lm87_channel,
- .irq = -1,
};
/****************************************************************************/
@@ -247,7 +246,6 @@ static const u8 sfn4112f_lm87_regs[] = {
static struct i2c_board_info sfn4112f_hwmon_info = {
I2C_BOARD_INFO("lm87", 0x2e),
.platform_data = &sfn4112f_lm87_channel,
- .irq = -1,
};
#define SFN4112F_ACT_LED 0
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 7269a426051c..343e8da1fa30 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -50,16 +50,6 @@ static struct workqueue_struct *reset_workqueue;
*************************************************************************/
/*
- * Enable large receive offload (LRO) aka soft segment reassembly (SSR)
- *
- * This sets the default for new devices. It can be controlled later
- * using ethtool.
- */
-static int lro = true;
-module_param(lro, int, 0644);
-MODULE_PARM_DESC(lro, "Large receive offload acceleration");
-
-/*
* Use separate channels for TX and RX events
*
* Set this to 1 to use separate channels for TX and RX. It allows us
@@ -894,9 +884,9 @@ static int efx_wanted_rx_queues(void)
int count;
int cpu;
- if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+ if (unlikely(!alloc_cpumask_var(&core_mask, GFP_KERNEL))) {
printk(KERN_WARNING
- "efx.c: allocation failure, irq balancing hobbled\n");
+ "sfc: RSS disabled due to allocation failure\n");
return 1;
}
@@ -1300,10 +1290,16 @@ out_requeue:
static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
{
struct efx_nic *efx = netdev_priv(net_dev);
+ struct mii_ioctl_data *data = if_mii(ifr);
EFX_ASSERT_RESET_SERIALISED(efx);
- return generic_mii_ioctl(&efx->mii, if_mii(ifr), cmd, NULL);
+ /* Convert phy_id from older PRTAD/DEVAD format */
+ if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
+ (data->phy_id & 0xfc00) == 0x0400)
+ data->phy_id ^= MDIO_PHY_ID_C45 | 0x0400;
+
+ return mdio_mii_ioctl(&efx->mdio, data, cmd);
}
/**************************************************************************
@@ -1945,7 +1941,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
mutex_init(&efx->mac_lock);
efx->mac_op = &efx_dummy_mac_operations;
efx->phy_op = &efx_dummy_phy_operations;
- efx->mii.dev = net_dev;
+ efx->mdio.dev = net_dev;
INIT_WORK(&efx->phy_work, efx_phy_work);
INIT_WORK(&efx->mac_work, efx_mac_work);
atomic_set(&efx->netif_stop_count, 1);
@@ -2161,9 +2157,8 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
if (!net_dev)
return -ENOMEM;
net_dev->features |= (NETIF_F_IP_CSUM | NETIF_F_SG |
- NETIF_F_HIGHDMA | NETIF_F_TSO);
- if (lro)
- net_dev->features |= NETIF_F_GRO;
+ NETIF_F_HIGHDMA | NETIF_F_TSO |
+ NETIF_F_GRO);
/* Mask for features that also apply to VLAN devices */
net_dev->vlan_features |= (NETIF_F_ALL_CSUM | NETIF_F_SG |
NETIF_F_HIGHDMA | NETIF_F_TSO);
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 64309f4e8b19..997ea2a3d53f 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -10,6 +10,7 @@
#include <linux/netdevice.h>
#include <linux/ethtool.h>
+#include <linux/mdio.h>
#include <linux/rtnetlink.h>
#include "net_driver.h"
#include "workarounds.h"
@@ -345,8 +346,8 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
unsigned int n = 0, i;
enum efx_loopback_mode mode;
- efx_fill_test(n++, strings, data, &tests->mii,
- "core", 0, "mii", NULL);
+ efx_fill_test(n++, strings, data, &tests->mdio,
+ "core", 0, "mdio", NULL);
efx_fill_test(n++, strings, data, &tests->nvram,
"core", 0, "nvram", NULL);
efx_fill_test(n++, strings, data, &tests->interrupt,
@@ -529,14 +530,7 @@ static int efx_ethtool_nway_reset(struct net_device *net_dev)
{
struct efx_nic *efx = netdev_priv(net_dev);
- if (efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_AN)) {
- mdio_clause45_set_flag(efx, efx->mii.phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1,
- __ffs(BMCR_ANRESTART), true);
- return 0;
- }
-
- return -EOPNOTSUPP;
+ return mdio45_nway_restart(&efx->mdio);
}
static u32 efx_ethtool_get_link(struct net_device *net_dev)
@@ -689,7 +683,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
return -EINVAL;
}
- if (!(efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_AN)) &&
+ if (!(efx->phy_op->mmds & MDIO_DEVS_AN) &&
(wanted_fc & EFX_FC_AUTO)) {
EFX_LOG(efx, "PHY does not support flow control "
"autonegotiation\n");
@@ -717,7 +711,8 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
mutex_lock(&efx->mac_lock);
efx->wanted_fc = wanted_fc;
- mdio_clause45_set_pause(efx);
+ if (efx->phy_op->mmds & MDIO_DEVS_AN)
+ mdio45_ethtool_spauseparam_an(&efx->mdio, pause);
__efx_reconfigure_port(efx);
mutex_unlock(&efx->mac_lock);
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 466a8abb0053..c049364aec46 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -2063,26 +2063,6 @@ int falcon_dma_stats(struct efx_nic *efx, unsigned int done_offset)
**************************************************************************
*/
-/* Use the top bit of the MII PHY id to indicate the PHY type
- * (1G/10G), with the remaining bits as the actual PHY id.
- *
- * This allows us to avoid leaking information from the mii_if_info
- * structure into other data structures.
- */
-#define FALCON_PHY_ID_ID_WIDTH EFX_WIDTH(MD_PRT_DEV_ADR)
-#define FALCON_PHY_ID_ID_MASK ((1 << FALCON_PHY_ID_ID_WIDTH) - 1)
-#define FALCON_PHY_ID_WIDTH (FALCON_PHY_ID_ID_WIDTH + 1)
-#define FALCON_PHY_ID_MASK ((1 << FALCON_PHY_ID_WIDTH) - 1)
-#define FALCON_PHY_ID_10G (1 << (FALCON_PHY_ID_WIDTH - 1))
-
-
-/* Packing the clause 45 port and device fields into a single value */
-#define MD_PRT_ADR_COMP_LBN (MD_PRT_ADR_LBN - MD_DEV_ADR_LBN)
-#define MD_PRT_ADR_COMP_WIDTH MD_PRT_ADR_WIDTH
-#define MD_DEV_ADR_COMP_LBN 0
-#define MD_DEV_ADR_COMP_WIDTH MD_DEV_ADR_WIDTH
-
-
/* Wait for GMII access to complete */
static int falcon_gmii_wait(struct efx_nic *efx)
{
@@ -2108,49 +2088,29 @@ static int falcon_gmii_wait(struct efx_nic *efx)
return -ETIMEDOUT;
}
-/* Writes a GMII register of a PHY connected to Falcon using MDIO. */
-static void falcon_mdio_write(struct net_device *net_dev, int phy_id,
- int addr, int value)
+/* Write an MDIO register of a PHY connected to Falcon. */
+static int falcon_mdio_write(struct net_device *net_dev,
+ int prtad, int devad, u16 addr, u16 value)
{
struct efx_nic *efx = netdev_priv(net_dev);
- unsigned int phy_id2 = phy_id & FALCON_PHY_ID_ID_MASK;
efx_oword_t reg;
+ int rc;
- /* The 'generic' prt/dev packing in mdio_10g.h is conveniently
- * chosen so that the only current user, Falcon, can take the
- * packed value and use them directly.
- * Fail to build if this assumption is broken.
- */
- BUILD_BUG_ON(FALCON_PHY_ID_10G != MDIO45_XPRT_ID_IS10G);
- BUILD_BUG_ON(FALCON_PHY_ID_ID_WIDTH != MDIO45_PRT_DEV_WIDTH);
- BUILD_BUG_ON(MD_PRT_ADR_COMP_LBN != MDIO45_PRT_ID_COMP_LBN);
- BUILD_BUG_ON(MD_DEV_ADR_COMP_LBN != MDIO45_DEV_ID_COMP_LBN);
-
- if (phy_id2 == PHY_ADDR_INVALID)
- return;
-
- /* See falcon_mdio_read for an explanation. */
- if (!(phy_id & FALCON_PHY_ID_10G)) {
- int mmd = ffs(efx->phy_op->mmds) - 1;
- EFX_TRACE(efx, "Fixing erroneous clause22 write\n");
- phy_id2 = mdio_clause45_pack(phy_id2, mmd)
- & FALCON_PHY_ID_ID_MASK;
- }
-
- EFX_REGDUMP(efx, "writing GMII %d register %02x with %04x\n", phy_id,
- addr, value);
+ EFX_REGDUMP(efx, "writing MDIO %d register %d.%d with 0x%04x\n",
+ prtad, devad, addr, value);
spin_lock_bh(&efx->phy_lock);
- /* Check MII not currently being accessed */
- if (falcon_gmii_wait(efx) != 0)
+ /* Check MDIO not currently being accessed */
+ rc = falcon_gmii_wait(efx);
+ if (rc)
goto out;
/* Write the address/ID register */
EFX_POPULATE_OWORD_1(reg, MD_PHY_ADR, addr);
falcon_write(efx, &reg, MD_PHY_ADR_REG_KER);
- EFX_POPULATE_OWORD_1(reg, MD_PRT_DEV_ADR, phy_id2);
+ EFX_POPULATE_OWORD_2(reg, MD_PRT_ADR, prtad, MD_DEV_ADR, devad);
falcon_write(efx, &reg, MD_ID_REG_KER);
/* Write data */
@@ -2163,7 +2123,8 @@ static void falcon_mdio_write(struct net_device *net_dev, int phy_id,
falcon_write(efx, &reg, MD_CS_REG_KER);
/* Wait for data to be written */
- if (falcon_gmii_wait(efx) != 0) {
+ rc = falcon_gmii_wait(efx);
+ if (rc) {
/* Abort the write operation */
EFX_POPULATE_OWORD_2(reg,
MD_WRC, 0,
@@ -2174,45 +2135,28 @@ static void falcon_mdio_write(struct net_device *net_dev, int phy_id,
out:
spin_unlock_bh(&efx->phy_lock);
+ return rc;
}
-/* Reads a GMII register from a PHY connected to Falcon. If no value
- * could be read, -1 will be returned. */
-static int falcon_mdio_read(struct net_device *net_dev, int phy_id, int addr)
+/* Read an MDIO register of a PHY connected to Falcon. */
+static int falcon_mdio_read(struct net_device *net_dev,
+ int prtad, int devad, u16 addr)
{
struct efx_nic *efx = netdev_priv(net_dev);
- unsigned int phy_addr = phy_id & FALCON_PHY_ID_ID_MASK;
efx_oword_t reg;
- int value = -1;
-
- if (phy_addr == PHY_ADDR_INVALID)
- return -1;
-
- /* Our PHY code knows whether it needs to talk clause 22(1G) or 45(10G)
- * but the generic Linux code does not make any distinction or have
- * any state for this.
- * We spot the case where someone tried to talk 22 to a 45 PHY and
- * redirect the request to the lowest numbered MMD as a clause45
- * request. This is enough to allow simple queries like id and link
- * state to succeed. TODO: We may need to do more in future.
- */
- if (!(phy_id & FALCON_PHY_ID_10G)) {
- int mmd = ffs(efx->phy_op->mmds) - 1;
- EFX_TRACE(efx, "Fixing erroneous clause22 read\n");
- phy_addr = mdio_clause45_pack(phy_addr, mmd)
- & FALCON_PHY_ID_ID_MASK;
- }
+ int rc;
spin_lock_bh(&efx->phy_lock);
- /* Check MII not currently being accessed */
- if (falcon_gmii_wait(efx) != 0)
+ /* Check MDIO not currently being accessed */
+ rc = falcon_gmii_wait(efx);
+ if (rc)
goto out;
EFX_POPULATE_OWORD_1(reg, MD_PHY_ADR, addr);
falcon_write(efx, &reg, MD_PHY_ADR_REG_KER);
- EFX_POPULATE_OWORD_1(reg, MD_PRT_DEV_ADR, phy_addr);
+ EFX_POPULATE_OWORD_2(reg, MD_PRT_ADR, prtad, MD_DEV_ADR, devad);
falcon_write(efx, &reg, MD_ID_REG_KER);
/* Request data to be read */
@@ -2220,12 +2164,12 @@ static int falcon_mdio_read(struct net_device *net_dev, int phy_id, int addr)
falcon_write(efx, &reg, MD_CS_REG_KER);
/* Wait for data to become available */
- value = falcon_gmii_wait(efx);
- if (value == 0) {
+ rc = falcon_gmii_wait(efx);
+ if (rc == 0) {
falcon_read(efx, &reg, MD_RXD_REG_KER);
- value = EFX_OWORD_FIELD(reg, MD_RXD);
- EFX_REGDUMP(efx, "read from GMII %d register %02x, got %04x\n",
- phy_id, addr, value);
+ rc = EFX_OWORD_FIELD(reg, MD_RXD);
+ EFX_REGDUMP(efx, "read from MDIO %d register %d.%d, got %04x\n",
+ prtad, devad, addr, rc);
} else {
/* Abort the read operation */
EFX_POPULATE_OWORD_2(reg,
@@ -2233,22 +2177,13 @@ static int falcon_mdio_read(struct net_device *net_dev, int phy_id, int addr)
MD_GC, 1);
falcon_write(efx, &reg, MD_CS_REG_KER);
- EFX_LOG(efx, "read from GMII 0x%x register %02x, got "
- "error %d\n", phy_id, addr, value);
+ EFX_LOG(efx, "read from MDIO %d register %d.%d, got error %d\n",
+ prtad, devad, addr, rc);
}
out:
spin_unlock_bh(&efx->phy_lock);
-
- return value;
-}
-
-static void falcon_init_mdio(struct mii_if_info *gmii)
-{
- gmii->mdio_read = falcon_mdio_read;
- gmii->mdio_write = falcon_mdio_write;
- gmii->phy_id_mask = FALCON_PHY_ID_MASK;
- gmii->reg_num_mask = ((1 << EFX_WIDTH(MD_PHY_ADR)) - 1);
+ return rc;
}
static int falcon_probe_phy(struct efx_nic *efx)
@@ -2342,9 +2277,11 @@ int falcon_probe_port(struct efx_nic *efx)
if (rc)
return rc;
- /* Set up GMII structure for PHY */
- efx->mii.supports_gmii = true;
- falcon_init_mdio(&efx->mii);
+ /* Set up MDIO structure for PHY */
+ efx->mdio.mmds = efx->phy_op->mmds;
+ efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
+ efx->mdio.mdio_read = falcon_mdio_read;
+ efx->mdio.mdio_write = falcon_mdio_write;
/* Hardware flow ctrl. FalconA RX FIFO too small for pause generation */
if (falcon_rev(efx) >= FALCON_REV_B0)
@@ -2761,7 +2698,7 @@ static int falcon_probe_nvconfig(struct efx_nic *efx)
if (rc == -EINVAL) {
EFX_ERR(efx, "NVRAM is invalid therefore using defaults\n");
efx->phy_type = PHY_TYPE_NONE;
- efx->mii.phy_id = PHY_ADDR_INVALID;
+ efx->mdio.prtad = MDIO_PRTAD_NONE;
board_rev = 0;
rc = 0;
} else if (rc) {
@@ -2771,7 +2708,7 @@ static int falcon_probe_nvconfig(struct efx_nic *efx)
struct falcon_nvconfig_board_v3 *v3 = &nvconfig->board_v3;
efx->phy_type = v2->port0_phy_type;
- efx->mii.phy_id = v2->port0_phy_addr;
+ efx->mdio.prtad = v2->port0_phy_addr;
board_rev = le16_to_cpu(v2->board_revision);
if (le16_to_cpu(nvconfig->board_struct_ver) >= 3) {
@@ -2793,7 +2730,7 @@ static int falcon_probe_nvconfig(struct efx_nic *efx)
/* Read the MAC addresses */
memcpy(efx->mac_address, nvconfig->mac_address[0], ETH_ALEN);
- EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mii.phy_id);
+ EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad);
efx_set_board_info(efx, board_rev);
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
index bda8d5bb72e4..375e2a5961ec 100644
--- a/drivers/net/sfc/falcon_hwdefs.h
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -456,9 +456,6 @@
#define MD_PRT_ADR_WIDTH 5
#define MD_DEV_ADR_LBN 6
#define MD_DEV_ADR_WIDTH 5
-/* Used for writing both at once */
-#define MD_PRT_DEV_ADR_LBN 6
-#define MD_PRT_DEV_ADR_WIDTH 10
/* PHY management status & mask register (DWORD read only) */
#define MD_STAT_REG_KER 0xc50
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c
index 5a03713685ac..2b3269c03263 100644
--- a/drivers/net/sfc/falcon_xmac.c
+++ b/drivers/net/sfc/falcon_xmac.c
@@ -133,7 +133,7 @@ bool falcon_xaui_link_ok(struct efx_nic *efx)
/* If the link is up, then check the phy side of the xaui link */
if (efx->link_up && link_ok)
if (efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS))
- link_ok = mdio_clause45_phyxgxs_lane_sync(efx);
+ link_ok = efx_mdio_phyxgxs_lane_sync(efx);
return link_ok;
}
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
index 9f5ec3eb3418..6c33459f9ea9 100644
--- a/drivers/net/sfc/mdio_10g.c
+++ b/drivers/net/sfc/mdio_10g.c
@@ -17,7 +17,7 @@
#include "boards.h"
#include "workarounds.h"
-unsigned mdio_id_oui(u32 id)
+unsigned efx_mdio_id_oui(u32 id)
{
unsigned oui = 0;
int i;
@@ -32,52 +32,45 @@ unsigned mdio_id_oui(u32 id)
return oui;
}
-int mdio_clause45_reset_mmd(struct efx_nic *port, int mmd,
+int efx_mdio_reset_mmd(struct efx_nic *port, int mmd,
int spins, int spintime)
{
u32 ctrl;
- int phy_id = port->mii.phy_id;
/* Catch callers passing values in the wrong units (or just silly) */
EFX_BUG_ON_PARANOID(spins * spintime >= 5000);
- mdio_clause45_write(port, phy_id, mmd, MDIO_MMDREG_CTRL1,
- (1 << MDIO_MMDREG_CTRL1_RESET_LBN));
+ efx_mdio_write(port, mmd, MDIO_CTRL1, MDIO_CTRL1_RESET);
/* Wait for the reset bit to clear. */
do {
msleep(spintime);
- ctrl = mdio_clause45_read(port, phy_id, mmd, MDIO_MMDREG_CTRL1);
+ ctrl = efx_mdio_read(port, mmd, MDIO_CTRL1);
spins--;
- } while (spins && (ctrl & (1 << MDIO_MMDREG_CTRL1_RESET_LBN)));
+ } while (spins && (ctrl & MDIO_CTRL1_RESET));
return spins ? spins : -ETIMEDOUT;
}
-static int mdio_clause45_check_mmd(struct efx_nic *efx, int mmd,
- int fault_fatal)
+static int efx_mdio_check_mmd(struct efx_nic *efx, int mmd, int fault_fatal)
{
int status;
- int phy_id = efx->mii.phy_id;
if (LOOPBACK_INTERNAL(efx))
return 0;
if (mmd != MDIO_MMD_AN) {
/* Read MMD STATUS2 to check it is responding. */
- status = mdio_clause45_read(efx, phy_id, mmd,
- MDIO_MMDREG_STAT2);
- if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) &
- ((1 << MDIO_MMDREG_STAT2_PRESENT_WIDTH) - 1)) !=
- MDIO_MMDREG_STAT2_PRESENT_VAL) {
+ status = efx_mdio_read(efx, mmd, MDIO_STAT2);
+ if ((status & MDIO_STAT2_DEVPRST) != MDIO_STAT2_DEVPRST_VAL) {
EFX_ERR(efx, "PHY MMD %d not responding.\n", mmd);
return -EIO;
}
}
/* Read MMD STATUS 1 to check for fault. */
- status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT1);
- if ((status & (1 << MDIO_MMDREG_STAT1_FAULT_LBN)) != 0) {
+ status = efx_mdio_read(efx, mmd, MDIO_STAT1);
+ if (status & MDIO_STAT1_FAULT) {
if (fault_fatal) {
EFX_ERR(efx, "PHY MMD %d reporting fatal"
" fault: status %x\n", mmd, status);
@@ -94,8 +87,7 @@ static int mdio_clause45_check_mmd(struct efx_nic *efx, int mmd,
#define MDIO45_RESET_TIME 1000 /* ms */
#define MDIO45_RESET_ITERS 100
-int mdio_clause45_wait_reset_mmds(struct efx_nic *efx,
- unsigned int mmd_mask)
+int efx_mdio_wait_reset_mmds(struct efx_nic *efx, unsigned int mmd_mask)
{
const int spintime = MDIO45_RESET_TIME / MDIO45_RESET_ITERS;
int tries = MDIO45_RESET_ITERS;
@@ -109,16 +101,13 @@ int mdio_clause45_wait_reset_mmds(struct efx_nic *efx,
in_reset = 0;
while (mask) {
if (mask & 1) {
- stat = mdio_clause45_read(efx,
- efx->mii.phy_id,
- mmd,
- MDIO_MMDREG_CTRL1);
+ stat = efx_mdio_read(efx, mmd, MDIO_CTRL1);
if (stat < 0) {
EFX_ERR(efx, "failed to read status of"
" MMD %d\n", mmd);
return -EIO;
}
- if (stat & (1 << MDIO_MMDREG_CTRL1_RESET_LBN))
+ if (stat & MDIO_CTRL1_RESET)
in_reset |= (1 << mmd);
}
mask = mask >> 1;
@@ -137,28 +126,26 @@ int mdio_clause45_wait_reset_mmds(struct efx_nic *efx,
return rc;
}
-int mdio_clause45_check_mmds(struct efx_nic *efx,
- unsigned int mmd_mask, unsigned int fatal_mask)
+int efx_mdio_check_mmds(struct efx_nic *efx,
+ unsigned int mmd_mask, unsigned int fatal_mask)
{
- int mmd = 0, probe_mmd, devs0, devs1;
+ int mmd = 0, probe_mmd, devs1, devs2;
u32 devices;
/* Historically we have probed the PHYXS to find out what devices are
* present,but that doesn't work so well if the PHYXS isn't expected
* to exist, if so just find the first item in the list supplied. */
- probe_mmd = (mmd_mask & MDIO_MMDREG_DEVS_PHYXS) ? MDIO_MMD_PHYXS :
+ probe_mmd = (mmd_mask & MDIO_DEVS_PHYXS) ? MDIO_MMD_PHYXS :
__ffs(mmd_mask);
/* Check all the expected MMDs are present */
- devs0 = mdio_clause45_read(efx, efx->mii.phy_id,
- probe_mmd, MDIO_MMDREG_DEVS0);
- devs1 = mdio_clause45_read(efx, efx->mii.phy_id,
- probe_mmd, MDIO_MMDREG_DEVS1);
- if (devs0 < 0 || devs1 < 0) {
+ devs1 = efx_mdio_read(efx, probe_mmd, MDIO_DEVS1);
+ devs2 = efx_mdio_read(efx, probe_mmd, MDIO_DEVS2);
+ if (devs1 < 0 || devs2 < 0) {
EFX_ERR(efx, "failed to read devices present\n");
return -EIO;
}
- devices = devs0 | (devs1 << 16);
+ devices = devs1 | (devs2 << 16);
if ((devices & mmd_mask) != mmd_mask) {
EFX_ERR(efx, "required MMDs not present: got %x, "
"wanted %x\n", devices, mmd_mask);
@@ -170,7 +157,7 @@ int mdio_clause45_check_mmds(struct efx_nic *efx,
while (mmd_mask) {
if (mmd_mask & 1) {
int fault_fatal = fatal_mask & 1;
- if (mdio_clause45_check_mmd(efx, mmd, fault_fatal))
+ if (efx_mdio_check_mmd(efx, mmd, fault_fatal))
return -EIO;
}
mmd_mask = mmd_mask >> 1;
@@ -181,13 +168,8 @@ int mdio_clause45_check_mmds(struct efx_nic *efx,
return 0;
}
-bool mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
+bool efx_mdio_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
{
- int phy_id = efx->mii.phy_id;
- u32 reg;
- bool ok = true;
- int mmd = 0;
-
/* If the port is in loopback, then we should only consider a subset
* of mmd's */
if (LOOPBACK_INTERNAL(efx))
@@ -197,241 +179,75 @@ bool mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
else if (efx_phy_mode_disabled(efx->phy_mode))
return false;
else if (efx->loopback_mode == LOOPBACK_PHYXS)
- mmd_mask &= ~(MDIO_MMDREG_DEVS_PHYXS |
- MDIO_MMDREG_DEVS_PCS |
- MDIO_MMDREG_DEVS_PMAPMD |
- MDIO_MMDREG_DEVS_AN);
+ mmd_mask &= ~(MDIO_DEVS_PHYXS |
+ MDIO_DEVS_PCS |
+ MDIO_DEVS_PMAPMD |
+ MDIO_DEVS_AN);
else if (efx->loopback_mode == LOOPBACK_PCS)
- mmd_mask &= ~(MDIO_MMDREG_DEVS_PCS |
- MDIO_MMDREG_DEVS_PMAPMD |
- MDIO_MMDREG_DEVS_AN);
+ mmd_mask &= ~(MDIO_DEVS_PCS |
+ MDIO_DEVS_PMAPMD |
+ MDIO_DEVS_AN);
else if (efx->loopback_mode == LOOPBACK_PMAPMD)
- mmd_mask &= ~(MDIO_MMDREG_DEVS_PMAPMD |
- MDIO_MMDREG_DEVS_AN);
-
- if (!mmd_mask) {
- /* Use presence of XGMII faults in leui of link state */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS,
- MDIO_PHYXS_STATUS2);
- return !(reg & (1 << MDIO_PHYXS_STATUS2_RX_FAULT_LBN));
- }
+ mmd_mask &= ~(MDIO_DEVS_PMAPMD |
+ MDIO_DEVS_AN);
- while (mmd_mask) {
- if (mmd_mask & 1) {
- /* Double reads because link state is latched, and a
- * read moves the current state into the register */
- reg = mdio_clause45_read(efx, phy_id,
- mmd, MDIO_MMDREG_STAT1);
- reg = mdio_clause45_read(efx, phy_id,
- mmd, MDIO_MMDREG_STAT1);
- ok = ok && (reg & (1 << MDIO_MMDREG_STAT1_LINK_LBN));
- }
- mmd_mask = (mmd_mask >> 1);
- mmd++;
- }
- return ok;
+ return mdio45_links_ok(&efx->mdio, mmd_mask);
}
-void mdio_clause45_transmit_disable(struct efx_nic *efx)
+void efx_mdio_transmit_disable(struct efx_nic *efx)
{
- mdio_clause45_set_flag(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_TXDIS, MDIO_MMDREG_TXDIS_GLOBAL_LBN,
- efx->phy_mode & PHY_MODE_TX_DISABLED);
+ efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD,
+ MDIO_PMA_TXDIS, MDIO_PMD_TXDIS_GLOBAL,
+ efx->phy_mode & PHY_MODE_TX_DISABLED);
}
-void mdio_clause45_phy_reconfigure(struct efx_nic *efx)
+void efx_mdio_phy_reconfigure(struct efx_nic *efx)
{
- int phy_id = efx->mii.phy_id;
-
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_CTRL1, MDIO_PMAPMD_CTRL1_LBACK_LBN,
- efx->loopback_mode == LOOPBACK_PMAPMD);
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PCS,
- MDIO_MMDREG_CTRL1, MDIO_MMDREG_CTRL1_LBACK_LBN,
- efx->loopback_mode == LOOPBACK_PCS);
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PHYXS,
- MDIO_MMDREG_CTRL1, MDIO_MMDREG_CTRL1_LBACK_LBN,
- efx->loopback_mode == LOOPBACK_NETWORK);
+ efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD,
+ MDIO_CTRL1, MDIO_PMA_CTRL1_LOOPBACK,
+ efx->loopback_mode == LOOPBACK_PMAPMD);
+ efx_mdio_set_flag(efx, MDIO_MMD_PCS,
+ MDIO_CTRL1, MDIO_PCS_CTRL1_LOOPBACK,
+ efx->loopback_mode == LOOPBACK_PCS);
+ efx_mdio_set_flag(efx, MDIO_MMD_PHYXS,
+ MDIO_CTRL1, MDIO_PHYXS_CTRL1_LOOPBACK,
+ efx->loopback_mode == LOOPBACK_NETWORK);
}
-static void mdio_clause45_set_mmd_lpower(struct efx_nic *efx,
- int lpower, int mmd)
+static void efx_mdio_set_mmd_lpower(struct efx_nic *efx,
+ int lpower, int mmd)
{
- int phy = efx->mii.phy_id;
- int stat = mdio_clause45_read(efx, phy, mmd, MDIO_MMDREG_STAT1);
+ int stat = efx_mdio_read(efx, mmd, MDIO_STAT1);
EFX_TRACE(efx, "Setting low power mode for MMD %d to %d\n",
mmd, lpower);
- if (stat & (1 << MDIO_MMDREG_STAT1_LPABLE_LBN)) {
- mdio_clause45_set_flag(efx, phy, mmd, MDIO_MMDREG_CTRL1,
- MDIO_MMDREG_CTRL1_LPOWER_LBN, lpower);
+ if (stat & MDIO_STAT1_LPOWERABLE) {
+ efx_mdio_set_flag(efx, mmd, MDIO_CTRL1,
+ MDIO_CTRL1_LPOWER, lpower);
}
}
-void mdio_clause45_set_mmds_lpower(struct efx_nic *efx,
- int low_power, unsigned int mmd_mask)
+void efx_mdio_set_mmds_lpower(struct efx_nic *efx,
+ int low_power, unsigned int mmd_mask)
{
int mmd = 0;
- mmd_mask &= ~MDIO_MMDREG_DEVS_AN;
+ mmd_mask &= ~MDIO_DEVS_AN;
while (mmd_mask) {
if (mmd_mask & 1)
- mdio_clause45_set_mmd_lpower(efx, low_power, mmd);
+ efx_mdio_set_mmd_lpower(efx, low_power, mmd);
mmd_mask = (mmd_mask >> 1);
mmd++;
}
}
-static u32 mdio_clause45_get_an(struct efx_nic *efx, u16 addr)
-{
- int phy_id = efx->mii.phy_id;
- u32 result = 0;
- int reg;
-
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, addr);
- if (reg & ADVERTISE_10HALF)
- result |= ADVERTISED_10baseT_Half;
- if (reg & ADVERTISE_10FULL)
- result |= ADVERTISED_10baseT_Full;
- if (reg & ADVERTISE_100HALF)
- result |= ADVERTISED_100baseT_Half;
- if (reg & ADVERTISE_100FULL)
- result |= ADVERTISED_100baseT_Full;
- return result;
-}
-
-/**
- * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO.
- * @efx: Efx NIC
- * @ecmd: Buffer for settings
- *
- * On return the 'port', 'speed', 'supported' and 'advertising' fields of
- * ecmd have been filled out.
- */
-void mdio_clause45_get_settings(struct efx_nic *efx,
- struct ethtool_cmd *ecmd)
-{
- mdio_clause45_get_settings_ext(efx, ecmd, 0, 0);
-}
-
-/**
- * mdio_clause45_get_settings_ext - Read (some of) the PHY settings over MDIO.
- * @efx: Efx NIC
- * @ecmd: Buffer for settings
- * @xnp: Advertised Extended Next Page state
- * @xnp_lpa: Link Partner's advertised XNP state
- *
- * On return the 'port', 'speed', 'supported' and 'advertising' fields of
- * ecmd have been filled out.
- */
-void mdio_clause45_get_settings_ext(struct efx_nic *efx,
- struct ethtool_cmd *ecmd,
- u32 npage_adv, u32 npage_lpa)
-{
- int phy_id = efx->mii.phy_id;
- int reg;
-
- ecmd->transceiver = XCVR_INTERNAL;
- ecmd->phy_address = phy_id;
-
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_CTRL2);
- switch (reg & MDIO_PMAPMD_CTRL2_TYPE_MASK) {
- case MDIO_PMAPMD_CTRL2_10G_BT:
- case MDIO_PMAPMD_CTRL2_1G_BT:
- case MDIO_PMAPMD_CTRL2_100_BT:
- case MDIO_PMAPMD_CTRL2_10_BT:
- ecmd->port = PORT_TP;
- ecmd->supported = SUPPORTED_TP;
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_SPEED);
- if (reg & (1 << MDIO_MMDREG_SPEED_10G_LBN))
- ecmd->supported |= SUPPORTED_10000baseT_Full;
- if (reg & (1 << MDIO_MMDREG_SPEED_1000M_LBN))
- ecmd->supported |= (SUPPORTED_1000baseT_Full |
- SUPPORTED_1000baseT_Half);
- if (reg & (1 << MDIO_MMDREG_SPEED_100M_LBN))
- ecmd->supported |= (SUPPORTED_100baseT_Full |
- SUPPORTED_100baseT_Half);
- if (reg & (1 << MDIO_MMDREG_SPEED_10M_LBN))
- ecmd->supported |= (SUPPORTED_10baseT_Full |
- SUPPORTED_10baseT_Half);
- ecmd->advertising = ADVERTISED_TP;
- break;
-
- /* We represent CX4 as fibre in the absence of anything better */
- case MDIO_PMAPMD_CTRL2_10G_CX4:
- /* All the other defined modes are flavours of optical */
- default:
- ecmd->port = PORT_FIBRE;
- ecmd->supported = SUPPORTED_FIBRE;
- ecmd->advertising = ADVERTISED_FIBRE;
- break;
- }
-
- if (efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_AN)) {
- ecmd->supported |= SUPPORTED_Autoneg;
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1);
- if (reg & BMCR_ANENABLE) {
- ecmd->autoneg = AUTONEG_ENABLE;
- ecmd->advertising |=
- ADVERTISED_Autoneg |
- mdio_clause45_get_an(efx, MDIO_AN_ADVERTISE) |
- npage_adv;
- } else
- ecmd->autoneg = AUTONEG_DISABLE;
- } else
- ecmd->autoneg = AUTONEG_DISABLE;
-
- if (ecmd->autoneg) {
- /* If AN is complete, report best common mode,
- * otherwise report best advertised mode. */
- u32 modes = 0;
- if (mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_STAT1) &
- (1 << MDIO_AN_STATUS_AN_DONE_LBN))
- modes = (ecmd->advertising &
- (mdio_clause45_get_an(efx, MDIO_AN_LPA) |
- npage_lpa));
- if (modes == 0)
- modes = ecmd->advertising;
-
- if (modes & ADVERTISED_10000baseT_Full) {
- ecmd->speed = SPEED_10000;
- ecmd->duplex = DUPLEX_FULL;
- } else if (modes & (ADVERTISED_1000baseT_Full |
- ADVERTISED_1000baseT_Half)) {
- ecmd->speed = SPEED_1000;
- ecmd->duplex = !!(modes & ADVERTISED_1000baseT_Full);
- } else if (modes & (ADVERTISED_100baseT_Full |
- ADVERTISED_100baseT_Half)) {
- ecmd->speed = SPEED_100;
- ecmd->duplex = !!(modes & ADVERTISED_100baseT_Full);
- } else {
- ecmd->speed = SPEED_10;
- ecmd->duplex = !!(modes & ADVERTISED_10baseT_Full);
- }
- } else {
- /* Report forced settings */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_CTRL1);
- ecmd->speed = (((reg & BMCR_SPEED1000) ? 100 : 1) *
- ((reg & BMCR_SPEED100) ? 100 : 10));
- ecmd->duplex = (reg & BMCR_FULLDPLX ||
- ecmd->speed == SPEED_10000);
- }
-}
-
/**
- * mdio_clause45_set_settings - Set (some of) the PHY settings over MDIO.
+ * efx_mdio_set_settings - Set (some of) the PHY settings over MDIO.
* @efx: Efx NIC
* @ecmd: New settings
*/
-int mdio_clause45_set_settings(struct efx_nic *efx,
- struct ethtool_cmd *ecmd)
+int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
{
- int phy_id = efx->mii.phy_id;
struct ethtool_cmd prev;
u32 required;
int reg;
@@ -488,95 +304,48 @@ int mdio_clause45_set_settings(struct efx_nic *efx,
else if (ecmd->advertising & (ADVERTISED_1000baseT_Half |
ADVERTISED_1000baseT_Full))
reg |= ADVERTISE_NPAGE;
- reg |= efx_fc_advertise(efx->wanted_fc);
- mdio_clause45_write(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_ADVERTISE, reg);
+ reg |= mii_advertise_flowctrl(efx->wanted_fc);
+ efx_mdio_write(efx, MDIO_MMD_AN, MDIO_AN_ADVERTISE, reg);
/* Set up the (extended) next page if necessary */
if (efx->phy_op->set_npage_adv)
efx->phy_op->set_npage_adv(efx, ecmd->advertising);
/* Enable and restart AN */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1);
- reg |= BMCR_ANENABLE;
+ reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_CTRL1);
+ reg |= MDIO_AN_CTRL1_ENABLE;
if (!(EFX_WORKAROUND_15195(efx) &&
LOOPBACK_MASK(efx) & efx->phy_op->loopbacks))
- reg |= BMCR_ANRESTART;
+ reg |= MDIO_AN_CTRL1_RESTART;
if (xnp)
- reg |= 1 << MDIO_AN_CTRL_XNP_LBN;
+ reg |= MDIO_AN_CTRL1_XNP;
else
- reg &= ~(1 << MDIO_AN_CTRL_XNP_LBN);
- mdio_clause45_write(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1, reg);
+ reg &= ~MDIO_AN_CTRL1_XNP;
+ efx_mdio_write(efx, MDIO_MMD_AN, MDIO_CTRL1, reg);
} else {
/* Disable AN */
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1,
- __ffs(BMCR_ANENABLE), false);
+ efx_mdio_set_flag(efx, MDIO_MMD_AN, MDIO_CTRL1,
+ MDIO_AN_CTRL1_ENABLE, false);
/* Set the basic control bits */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_CTRL1);
- reg &= ~(BMCR_SPEED1000 | BMCR_SPEED100 | BMCR_FULLDPLX |
- 0x003c);
+ reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, MDIO_CTRL1);
+ reg &= ~(MDIO_CTRL1_SPEEDSEL | MDIO_CTRL1_FULLDPLX);
if (ecmd->speed == SPEED_100)
- reg |= BMCR_SPEED100;
+ reg |= MDIO_PMA_CTRL1_SPEED100;
if (ecmd->duplex)
- reg |= BMCR_FULLDPLX;
- mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_MMDREG_CTRL1, reg);
+ reg |= MDIO_CTRL1_FULLDPLX;
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, MDIO_CTRL1, reg);
}
return 0;
}
-void mdio_clause45_set_pause(struct efx_nic *efx)
-{
- int phy_id = efx->mii.phy_id;
- int reg;
-
- if (efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_AN)) {
- /* Set pause capability advertising */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_ADVERTISE);
- reg &= ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
- reg |= efx_fc_advertise(efx->wanted_fc);
- mdio_clause45_write(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_ADVERTISE, reg);
-
- /* Restart auto-negotiation */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1);
- if (reg & BMCR_ANENABLE) {
- reg |= BMCR_ANRESTART;
- mdio_clause45_write(efx, phy_id, MDIO_MMD_AN,
- MDIO_MMDREG_CTRL1, reg);
- }
- }
-}
-
-enum efx_fc_type mdio_clause45_get_pause(struct efx_nic *efx)
+enum efx_fc_type efx_mdio_get_pause(struct efx_nic *efx)
{
- int phy_id = efx->mii.phy_id;
int lpa;
- if (!(efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_AN)))
+ if (!(efx->phy_op->mmds & MDIO_DEVS_AN))
return efx->wanted_fc;
- lpa = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, MDIO_AN_LPA);
+ lpa = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_LPA);
return efx_fc_resolve(efx->wanted_fc, lpa);
}
-
-void mdio_clause45_set_flag(struct efx_nic *efx, u8 prt, u8 dev,
- u16 addr, int bit, bool sense)
-{
- int old_val = mdio_clause45_read(efx, prt, dev, addr);
- int new_val;
-
- if (sense)
- new_val = old_val | (1 << bit);
- else
- new_val = old_val & ~(1 << bit);
- if (old_val != new_val)
- mdio_clause45_write(efx, prt, dev, addr, new_val);
-}
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h
index 7014d2279c20..6b14421a7444 100644
--- a/drivers/net/sfc/mdio_10g.h
+++ b/drivers/net/sfc/mdio_10g.h
@@ -10,247 +10,53 @@
#ifndef EFX_MDIO_10G_H
#define EFX_MDIO_10G_H
+#include <linux/mdio.h>
+
/*
- * Definitions needed for doing 10G MDIO as specified in clause 45
- * MDIO, which do not appear in Linux yet. Also some helper functions.
+ * Helper functions for doing 10G MDIO as specified in IEEE 802.3 clause 45.
*/
#include "efx.h"
#include "boards.h"
-/* Numbering of the MDIO Manageable Devices (MMDs) */
-/* Physical Medium Attachment/ Physical Medium Dependent sublayer */
-#define MDIO_MMD_PMAPMD (1)
-/* WAN Interface Sublayer */
-#define MDIO_MMD_WIS (2)
-/* Physical Coding Sublayer */
-#define MDIO_MMD_PCS (3)
-/* PHY Extender Sublayer */
-#define MDIO_MMD_PHYXS (4)
-/* Extender Sublayer */
-#define MDIO_MMD_DTEXS (5)
-/* Transmission convergence */
-#define MDIO_MMD_TC (6)
-/* Auto negotiation */
-#define MDIO_MMD_AN (7)
-/* Clause 22 extension */
-#define MDIO_MMD_C22EXT 29
-
-/* Generic register locations */
-#define MDIO_MMDREG_CTRL1 (0)
-#define MDIO_MMDREG_STAT1 (1)
-#define MDIO_MMDREG_IDHI (2)
-#define MDIO_MMDREG_IDLOW (3)
-#define MDIO_MMDREG_SPEED (4)
-#define MDIO_MMDREG_DEVS0 (5)
-#define MDIO_MMDREG_DEVS1 (6)
-#define MDIO_MMDREG_CTRL2 (7)
-#define MDIO_MMDREG_STAT2 (8)
-#define MDIO_MMDREG_TXDIS (9)
-
-/* Bits in MMDREG_CTRL1 */
-/* Reset */
-#define MDIO_MMDREG_CTRL1_RESET_LBN (15)
-#define MDIO_MMDREG_CTRL1_RESET_WIDTH (1)
-/* Loopback */
-/* Loopback bit for WIS, PCS, PHYSX and DTEXS */
-#define MDIO_MMDREG_CTRL1_LBACK_LBN (14)
-#define MDIO_MMDREG_CTRL1_LBACK_WIDTH (1)
-/* Low power */
-#define MDIO_MMDREG_CTRL1_LPOWER_LBN (11)
-#define MDIO_MMDREG_CTRL1_LPOWER_WIDTH (1)
-
-/* Bits in MMDREG_STAT1 */
-#define MDIO_MMDREG_STAT1_FAULT_LBN (7)
-#define MDIO_MMDREG_STAT1_FAULT_WIDTH (1)
-/* Link state */
-#define MDIO_MMDREG_STAT1_LINK_LBN (2)
-#define MDIO_MMDREG_STAT1_LINK_WIDTH (1)
-/* Low power ability */
-#define MDIO_MMDREG_STAT1_LPABLE_LBN (1)
-#define MDIO_MMDREG_STAT1_LPABLE_WIDTH (1)
-
-/* Bits in combined ID regs */
-static inline unsigned mdio_id_rev(u32 id) { return id & 0xf; }
-static inline unsigned mdio_id_model(u32 id) { return (id >> 4) & 0x3f; }
-extern unsigned mdio_id_oui(u32 id);
-
-/* Bits in MMDREG_DEVS0/1. Someone thoughtfully layed things out
- * so the 'bit present' bit number of an MMD is the number of
- * that MMD */
-#define DEV_PRESENT_BIT(_b) (1 << _b)
-
-#define MDIO_MMDREG_DEVS_PHYXS DEV_PRESENT_BIT(MDIO_MMD_PHYXS)
-#define MDIO_MMDREG_DEVS_PCS DEV_PRESENT_BIT(MDIO_MMD_PCS)
-#define MDIO_MMDREG_DEVS_PMAPMD DEV_PRESENT_BIT(MDIO_MMD_PMAPMD)
-#define MDIO_MMDREG_DEVS_AN DEV_PRESENT_BIT(MDIO_MMD_AN)
-#define MDIO_MMDREG_DEVS_C22EXT DEV_PRESENT_BIT(MDIO_MMD_C22EXT)
-
-/* Bits in MMDREG_SPEED */
-#define MDIO_MMDREG_SPEED_10G_LBN 0
-#define MDIO_MMDREG_SPEED_10G_WIDTH 1
-#define MDIO_MMDREG_SPEED_1000M_LBN 4
-#define MDIO_MMDREG_SPEED_1000M_WIDTH 1
-#define MDIO_MMDREG_SPEED_100M_LBN 5
-#define MDIO_MMDREG_SPEED_100M_WIDTH 1
-#define MDIO_MMDREG_SPEED_10M_LBN 6
-#define MDIO_MMDREG_SPEED_10M_WIDTH 1
-
-/* Bits in MMDREG_STAT2 */
-#define MDIO_MMDREG_STAT2_PRESENT_VAL (2)
-#define MDIO_MMDREG_STAT2_PRESENT_LBN (14)
-#define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2)
-
-/* Bits in MMDREG_TXDIS */
-#define MDIO_MMDREG_TXDIS_GLOBAL_LBN (0)
-#define MDIO_MMDREG_TXDIS_GLOBAL_WIDTH (1)
-
-/* MMD-specific bits, ordered by MMD, then register */
-#define MDIO_PMAPMD_CTRL1_LBACK_LBN (0)
-#define MDIO_PMAPMD_CTRL1_LBACK_WIDTH (1)
-
-/* PMA type (4 bits) */
-#define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0)
-#define MDIO_PMAPMD_CTRL2_10G_EW (0x1)
-#define MDIO_PMAPMD_CTRL2_10G_LW (0x2)
-#define MDIO_PMAPMD_CTRL2_10G_SW (0x3)
-#define MDIO_PMAPMD_CTRL2_10G_LX4 (0x4)
-#define MDIO_PMAPMD_CTRL2_10G_ER (0x5)
-#define MDIO_PMAPMD_CTRL2_10G_LR (0x6)
-#define MDIO_PMAPMD_CTRL2_10G_SR (0x7)
-/* Reserved */
-#define MDIO_PMAPMD_CTRL2_10G_BT (0x9)
-/* Reserved */
-/* Reserved */
-#define MDIO_PMAPMD_CTRL2_1G_BT (0xc)
-/* Reserved */
-#define MDIO_PMAPMD_CTRL2_100_BT (0xe)
-#define MDIO_PMAPMD_CTRL2_10_BT (0xf)
-#define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf)
-
-/* PMA 10GBT registers */
-#define MDIO_PMAPMD_10GBT_TXPWR (131)
-#define MDIO_PMAPMD_10GBT_TXPWR_SHORT_LBN (0)
-#define MDIO_PMAPMD_10GBT_TXPWR_SHORT_WIDTH (1)
-
-/* PHY XGXS Status 2 */
-#define MDIO_PHYXS_STATUS2 (8)
-#define MDIO_PHYXS_STATUS2_RX_FAULT_LBN 10
-
-/* PHY XGXS lane state */
-#define MDIO_PHYXS_LANE_STATE (0x18)
-#define MDIO_PHYXS_LANE_ALIGNED_LBN (12)
-
-/* AN registers */
-#define MDIO_AN_CTRL_XNP_LBN 13
-#define MDIO_AN_STATUS (1)
-#define MDIO_AN_STATUS_XNP_LBN (7)
-#define MDIO_AN_STATUS_PAGE_LBN (6)
-#define MDIO_AN_STATUS_AN_DONE_LBN (5)
-#define MDIO_AN_STATUS_LP_AN_CAP_LBN (0)
-
-#define MDIO_AN_ADVERTISE 16
-#define MDIO_AN_ADVERTISE_XNP_LBN 12
-#define MDIO_AN_LPA 19
-#define MDIO_AN_XNP 22
-#define MDIO_AN_LPA_XNP 25
-
-#define MDIO_AN_10GBT_CTRL 32
-#define MDIO_AN_10GBT_CTRL_ADV_10G_LBN 12
-#define MDIO_AN_10GBT_STATUS (33)
-#define MDIO_AN_10GBT_STATUS_MS_FLT_LBN (15) /* MASTER/SLAVE config fault */
-#define MDIO_AN_10GBT_STATUS_MS_LBN (14) /* MASTER/SLAVE config */
-#define MDIO_AN_10GBT_STATUS_LOC_OK_LBN (13) /* Local OK */
-#define MDIO_AN_10GBT_STATUS_REM_OK_LBN (12) /* Remote OK */
-#define MDIO_AN_10GBT_STATUS_LP_10G_LBN (11) /* Link partner is 10GBT capable */
-#define MDIO_AN_10GBT_STATUS_LP_LTA_LBN (10) /* LP loop timing ability */
-#define MDIO_AN_10GBT_STATUS_LP_TRR_LBN (9) /* LP Training Reset Request */
-
+static inline unsigned efx_mdio_id_rev(u32 id) { return id & 0xf; }
+static inline unsigned efx_mdio_id_model(u32 id) { return (id >> 4) & 0x3f; }
+extern unsigned efx_mdio_id_oui(u32 id);
-/* Packing of the prt and dev arguments of clause 45 style MDIO into a
- * single int so they can be passed into the mdio_read/write functions
- * that currently exist. Note that as Falcon is the only current user,
- * the packed form is chosen to match what Falcon needs to write into
- * a register. This is checked at compile-time so do not change it. If
- * your target chip needs things layed out differently you will need
- * to unpack the arguments in your chip-specific mdio functions.
- */
- /* These are defined by the standard. */
-#define MDIO45_PRT_ID_WIDTH (5)
-#define MDIO45_DEV_ID_WIDTH (5)
-
-/* The prt ID is just packed in immediately to the left of the dev ID */
-#define MDIO45_PRT_DEV_WIDTH (MDIO45_PRT_ID_WIDTH + MDIO45_DEV_ID_WIDTH)
-
-#define MDIO45_PRT_ID_MASK ((1 << MDIO45_PRT_DEV_WIDTH) - 1)
-/* This is the prt + dev extended by 1 bit to hold the 'is clause 45' flag. */
-#define MDIO45_XPRT_ID_WIDTH (MDIO45_PRT_DEV_WIDTH + 1)
-#define MDIO45_XPRT_ID_MASK ((1 << MDIO45_XPRT_ID_WIDTH) - 1)
-#define MDIO45_XPRT_ID_IS10G (1 << (MDIO45_XPRT_ID_WIDTH - 1))
-
-
-#define MDIO45_PRT_ID_COMP_LBN MDIO45_DEV_ID_WIDTH
-#define MDIO45_PRT_ID_COMP_WIDTH MDIO45_PRT_ID_WIDTH
-#define MDIO45_DEV_ID_COMP_LBN 0
-#define MDIO45_DEV_ID_COMP_WIDTH MDIO45_DEV_ID_WIDTH
-
-/* Compose port and device into a phy_id */
-static inline int mdio_clause45_pack(u8 prt, u8 dev)
-{
- efx_dword_t phy_id;
- EFX_POPULATE_DWORD_2(phy_id, MDIO45_PRT_ID_COMP, prt,
- MDIO45_DEV_ID_COMP, dev);
- return MDIO45_XPRT_ID_IS10G | EFX_DWORD_VAL(phy_id);
-}
-
-static inline void mdio_clause45_unpack(u32 val, u8 *prt, u8 *dev)
+static inline int efx_mdio_read(struct efx_nic *efx, int devad, int addr)
{
- efx_dword_t phy_id;
- EFX_POPULATE_DWORD_1(phy_id, EFX_DWORD_0, val);
- *prt = EFX_DWORD_FIELD(phy_id, MDIO45_PRT_ID_COMP);
- *dev = EFX_DWORD_FIELD(phy_id, MDIO45_DEV_ID_COMP);
+ return efx->mdio.mdio_read(efx->net_dev, efx->mdio.prtad, devad, addr);
}
-static inline int mdio_clause45_read(struct efx_nic *efx,
- u8 prt, u8 dev, u16 addr)
+static inline void
+efx_mdio_write(struct efx_nic *efx, int devad, int addr, int value)
{
- return efx->mii.mdio_read(efx->net_dev,
- mdio_clause45_pack(prt, dev), addr);
+ efx->mdio.mdio_write(efx->net_dev, efx->mdio.prtad, devad, addr, value);
}
-static inline void mdio_clause45_write(struct efx_nic *efx,
- u8 prt, u8 dev, u16 addr, int value)
+static inline u32 efx_mdio_read_id(struct efx_nic *efx, int mmd)
{
- efx->mii.mdio_write(efx->net_dev,
- mdio_clause45_pack(prt, dev), addr, value);
-}
-
-
-static inline u32 mdio_clause45_read_id(struct efx_nic *efx, int mmd)
-{
- int phy_id = efx->mii.phy_id;
- u16 id_low = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_IDLOW);
- u16 id_hi = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_IDHI);
+ u16 id_low = efx_mdio_read(efx, mmd, MDIO_DEVID2);
+ u16 id_hi = efx_mdio_read(efx, mmd, MDIO_DEVID1);
return (id_hi << 16) | (id_low);
}
-static inline bool mdio_clause45_phyxgxs_lane_sync(struct efx_nic *efx)
+static inline bool efx_mdio_phyxgxs_lane_sync(struct efx_nic *efx)
{
int i, lane_status;
bool sync;
for (i = 0; i < 2; ++i)
- lane_status = mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PHYXS,
- MDIO_PHYXS_LANE_STATE);
+ lane_status = efx_mdio_read(efx, MDIO_MMD_PHYXS,
+ MDIO_PHYXS_LNSTAT);
- sync = !!(lane_status & (1 << MDIO_PHYXS_LANE_ALIGNED_LBN));
+ sync = !!(lane_status & MDIO_PHYXS_LNSTAT_ALIGN);
if (!sync)
EFX_LOG(efx, "XGXS lane status: %x\n", lane_status);
return sync;
}
-extern const char *mdio_clause45_mmd_name(int mmd);
+extern const char *efx_mdio_mmd_name(int mmd);
/*
* Reset a specific MMD and wait for reset to clear.
@@ -258,54 +64,44 @@ extern const char *mdio_clause45_mmd_name(int mmd);
*
* This function will sleep
*/
-extern int mdio_clause45_reset_mmd(struct efx_nic *efx, int mmd,
- int spins, int spintime);
+extern int efx_mdio_reset_mmd(struct efx_nic *efx, int mmd,
+ int spins, int spintime);
-/* As mdio_clause45_check_mmd but for multiple MMDs */
-int mdio_clause45_check_mmds(struct efx_nic *efx,
- unsigned int mmd_mask, unsigned int fatal_mask);
+/* As efx_mdio_check_mmd but for multiple MMDs */
+int efx_mdio_check_mmds(struct efx_nic *efx,
+ unsigned int mmd_mask, unsigned int fatal_mask);
/* Check the link status of specified mmds in bit mask */
-extern bool mdio_clause45_links_ok(struct efx_nic *efx,
- unsigned int mmd_mask);
+extern bool efx_mdio_links_ok(struct efx_nic *efx, unsigned int mmd_mask);
/* Generic transmit disable support though PMAPMD */
-extern void mdio_clause45_transmit_disable(struct efx_nic *efx);
+extern void efx_mdio_transmit_disable(struct efx_nic *efx);
/* Generic part of reconfigure: set/clear loopback bits */
-extern void mdio_clause45_phy_reconfigure(struct efx_nic *efx);
+extern void efx_mdio_phy_reconfigure(struct efx_nic *efx);
/* Set the power state of the specified MMDs */
-extern void mdio_clause45_set_mmds_lpower(struct efx_nic *efx,
- int low_power, unsigned int mmd_mask);
-
-/* Read (some of) the PHY settings over MDIO */
-extern void mdio_clause45_get_settings(struct efx_nic *efx,
- struct ethtool_cmd *ecmd);
-
-/* Read (some of) the PHY settings over MDIO */
-extern void
-mdio_clause45_get_settings_ext(struct efx_nic *efx, struct ethtool_cmd *ecmd,
- u32 xnp, u32 xnp_lpa);
+extern void efx_mdio_set_mmds_lpower(struct efx_nic *efx,
+ int low_power, unsigned int mmd_mask);
/* Set (some of) the PHY settings over MDIO */
-extern int mdio_clause45_set_settings(struct efx_nic *efx,
- struct ethtool_cmd *ecmd);
-
-/* Set pause parameters to be advertised through AN (if available) */
-extern void mdio_clause45_set_pause(struct efx_nic *efx);
+extern int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd);
/* Get pause parameters from AN if available (otherwise return
* requested pause parameters)
*/
-enum efx_fc_type mdio_clause45_get_pause(struct efx_nic *efx);
+enum efx_fc_type efx_mdio_get_pause(struct efx_nic *efx);
/* Wait for specified MMDs to exit reset within a timeout */
-extern int mdio_clause45_wait_reset_mmds(struct efx_nic *efx,
- unsigned int mmd_mask);
+extern int efx_mdio_wait_reset_mmds(struct efx_nic *efx,
+ unsigned int mmd_mask);
/* Set or clear flag, debouncing */
-extern void mdio_clause45_set_flag(struct efx_nic *efx, u8 prt, u8 dev,
- u16 addr, int bit, bool sense);
+static inline void
+efx_mdio_set_flag(struct efx_nic *efx, int devad, int addr,
+ int mask, bool state)
+{
+ mdio_set_flag(&efx->mdio, efx->mdio.prtad, devad, addr, mask, state);
+}
#endif /* EFX_MDIO_10G_H */
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index e169e5dcd1e6..5eabede9ac18 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -19,7 +19,7 @@
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/timer.h>
-#include <linux/mii.h>
+#include <linux/mdio.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <linux/device.h>
@@ -458,8 +458,6 @@ enum phy_type {
PHY_TYPE_MAX /* Insert any new items before this */
};
-#define PHY_ADDR_INVALID 0xff
-
#define EFX_IS10G(efx) ((efx)->link_speed == 10000)
enum nic_state {
@@ -497,8 +495,8 @@ struct efx_nic;
/* Pseudo bit-mask flow control field */
enum efx_fc_type {
- EFX_FC_RX = 1,
- EFX_FC_TX = 2,
+ EFX_FC_RX = FLOW_CTRL_RX,
+ EFX_FC_TX = FLOW_CTRL_TX,
EFX_FC_AUTO = 4,
};
@@ -508,33 +506,15 @@ enum efx_mac_type {
EFX_XMAC = 2,
};
-static inline unsigned int efx_fc_advertise(enum efx_fc_type wanted_fc)
-{
- unsigned int adv = 0;
- if (wanted_fc & EFX_FC_RX)
- adv = ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
- if (wanted_fc & EFX_FC_TX)
- adv ^= ADVERTISE_PAUSE_ASYM;
- return adv;
-}
-
static inline enum efx_fc_type efx_fc_resolve(enum efx_fc_type wanted_fc,
unsigned int lpa)
{
- unsigned int adv = efx_fc_advertise(wanted_fc);
+ BUILD_BUG_ON(EFX_FC_AUTO & (EFX_FC_RX | EFX_FC_TX));
if (!(wanted_fc & EFX_FC_AUTO))
return wanted_fc;
- if (adv & lpa & ADVERTISE_PAUSE_CAP)
- return EFX_FC_RX | EFX_FC_TX;
- if (adv & lpa & ADVERTISE_PAUSE_ASYM) {
- if (adv & ADVERTISE_PAUSE_CAP)
- return EFX_FC_RX;
- if (lpa & ADVERTISE_PAUSE_CAP)
- return EFX_FC_TX;
- }
- return 0;
+ return mii_resolve_flowctrl_fdx(mii_advertise_flowctrl(wanted_fc), lpa);
}
/**
@@ -758,7 +738,7 @@ union efx_multicast_hash {
* @phy_lock: PHY access lock
* @phy_op: PHY interface
* @phy_data: PHY private data (including PHY-specific stats)
- * @mii: PHY interface
+ * @mdio: PHY MDIO interface
* @phy_mode: PHY operating mode. Serialised by @mac_lock.
* @mac_up: MAC link state
* @link_up: Link status
@@ -845,7 +825,7 @@ struct efx_nic {
struct work_struct phy_work;
struct efx_phy_operations *phy_op;
void *phy_data;
- struct mii_if_info mii;
+ struct mdio_if_info mdio;
enum efx_phy_mode phy_mode;
bool mac_up;
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 66d7fe3db3e6..01f9432c31ef 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -450,17 +450,27 @@ static void efx_rx_packet_lro(struct efx_channel *channel,
/* Pass the skb/page into the LRO engine */
if (rx_buf->page) {
- struct napi_gro_fraginfo info;
+ struct sk_buff *skb = napi_get_frags(napi);
- info.frags[0].page = rx_buf->page;
- info.frags[0].page_offset = efx_rx_buf_offset(rx_buf);
- info.frags[0].size = rx_buf->len;
- info.nr_frags = 1;
- info.ip_summed = CHECKSUM_UNNECESSARY;
- info.len = rx_buf->len;
+ if (!skb) {
+ put_page(rx_buf->page);
+ goto out;
+ }
+
+ skb_shinfo(skb)->frags[0].page = rx_buf->page;
+ skb_shinfo(skb)->frags[0].page_offset =
+ efx_rx_buf_offset(rx_buf);
+ skb_shinfo(skb)->frags[0].size = rx_buf->len;
+ skb_shinfo(skb)->nr_frags = 1;
+
+ skb->len = rx_buf->len;
+ skb->data_len = rx_buf->len;
+ skb->truesize += rx_buf->len;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
- napi_gro_frags(napi, &info);
+ napi_gro_frags(napi);
+out:
EFX_BUG_ON_PARANOID(rx_buf->skb);
rx_buf->page = NULL;
} else {
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 0a598084c513..043795715955 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -80,39 +80,38 @@ struct efx_loopback_state {
*
**************************************************************************/
-static int efx_test_mii(struct efx_nic *efx, struct efx_self_tests *tests)
+static int efx_test_mdio(struct efx_nic *efx, struct efx_self_tests *tests)
{
int rc = 0;
+ int devad = __ffs(efx->mdio.mmds);
u16 physid1, physid2;
- struct mii_if_info *mii = &efx->mii;
- struct net_device *net_dev = efx->net_dev;
if (efx->phy_type == PHY_TYPE_NONE)
return 0;
mutex_lock(&efx->mac_lock);
- tests->mii = -1;
+ tests->mdio = -1;
- physid1 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID1);
- physid2 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID2);
+ physid1 = efx_mdio_read(efx, devad, MDIO_DEVID1);
+ physid2 = efx_mdio_read(efx, devad, MDIO_DEVID2);
if ((physid1 == 0x0000) || (physid1 == 0xffff) ||
(physid2 == 0x0000) || (physid2 == 0xffff)) {
- EFX_ERR(efx, "no MII PHY present with ID %d\n",
- mii->phy_id);
+ EFX_ERR(efx, "no MDIO PHY present with ID %d\n",
+ efx->mdio.prtad);
rc = -EINVAL;
goto out;
}
if (EFX_IS10G(efx)) {
- rc = mdio_clause45_check_mmds(efx, efx->phy_op->mmds, 0);
+ rc = efx_mdio_check_mmds(efx, efx->phy_op->mmds, 0);
if (rc)
goto out;
}
out:
mutex_unlock(&efx->mac_lock);
- tests->mii = rc ? -1 : 1;
+ tests->mdio = rc ? -1 : 1;
return rc;
}
@@ -673,7 +672,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
/* Online (i.e. non-disruptive) testing
* This checks interrupt generation, event delivery and PHY presence. */
- rc = efx_test_mii(efx, tests);
+ rc = efx_test_mdio(efx, tests);
if (rc && !rc_test)
rc_test = rc;
diff --git a/drivers/net/sfc/selftest.h b/drivers/net/sfc/selftest.h
index 39451cf938cf..f6feee04c96b 100644
--- a/drivers/net/sfc/selftest.h
+++ b/drivers/net/sfc/selftest.h
@@ -32,7 +32,7 @@ struct efx_loopback_self_tests {
*/
struct efx_self_tests {
/* online tests */
- int mii;
+ int mdio;
int nvram;
int interrupt;
int eventq_dma[EFX_MAX_CHANNELS];
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index 4eac5da81e5a..cee00ad49b57 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -296,7 +296,6 @@ static int sfe4001_check_hw(struct efx_nic *efx)
static struct i2c_board_info sfe4001_hwmon_info = {
I2C_BOARD_INFO("max6647", 0x4e),
- .irq = -1,
};
/* This board uses an I2C expander to provider power to the PHY, which needs to
@@ -389,12 +388,10 @@ static void sfn4111t_fini(struct efx_nic *efx)
static struct i2c_board_info sfn4111t_a0_hwmon_info = {
I2C_BOARD_INFO("max6647", 0x4e),
- .irq = -1,
};
static struct i2c_board_info sfn4111t_r5_hwmon_info = {
I2C_BOARD_INFO("max6646", 0x4d),
- .irq = -1,
};
int sfn4111t_init(struct efx_nic *efx)
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index e61dc4d4741c..db723c58f6f1 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -23,10 +23,10 @@
* clause 22 extension MMD, but since it doesn't have all the generic
* MMD registers it is pointless to include it here.
*/
-#define TENXPRESS_REQUIRED_DEVS (MDIO_MMDREG_DEVS_PMAPMD | \
- MDIO_MMDREG_DEVS_PCS | \
- MDIO_MMDREG_DEVS_PHYXS | \
- MDIO_MMDREG_DEVS_AN)
+#define TENXPRESS_REQUIRED_DEVS (MDIO_DEVS_PMAPMD | \
+ MDIO_DEVS_PCS | \
+ MDIO_DEVS_PHYXS | \
+ MDIO_DEVS_AN)
#define SFX7101_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \
(1 << LOOPBACK_PCS) | \
@@ -44,18 +44,6 @@
*/
#define MAX_BAD_LP_TRIES (5)
-/* LASI Control */
-#define PMA_PMD_LASI_CTRL 36866
-#define PMA_PMD_LASI_STATUS 36869
-#define PMA_PMD_LS_ALARM_LBN 0
-#define PMA_PMD_LS_ALARM_WIDTH 1
-#define PMA_PMD_TX_ALARM_LBN 1
-#define PMA_PMD_TX_ALARM_WIDTH 1
-#define PMA_PMD_RX_ALARM_LBN 2
-#define PMA_PMD_RX_ALARM_WIDTH 1
-#define PMA_PMD_AN_ALARM_LBN 3
-#define PMA_PMD_AN_ALARM_WIDTH 1
-
/* Extended control register */
#define PMA_PMD_XCONTROL_REG 49152
#define PMA_PMD_EXT_GMII_EN_LBN 1
@@ -153,10 +141,6 @@
#define LOOPBACK_NEAR_LBN (8)
#define LOOPBACK_NEAR_WIDTH (1)
-#define PCS_10GBASET_STAT1 32
-#define PCS_10GBASET_BLKLK_LBN 0
-#define PCS_10GBASET_BLKLK_WIDTH 1
-
/* Boot status register */
#define PCS_BOOT_STATUS_REG 53248
#define PCS_BOOT_FATAL_ERROR_LBN 0
@@ -206,10 +190,8 @@ static ssize_t show_phy_short_reach(struct device *dev,
struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev));
int reg;
- reg = mdio_clause45_read(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- MDIO_PMAPMD_10GBT_TXPWR);
- return sprintf(buf, "%d\n",
- !!(reg & (1 << MDIO_PMAPMD_10GBT_TXPWR_SHORT_LBN)));
+ reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TXPWR);
+ return sprintf(buf, "%d\n", !!(reg & MDIO_PMA_10GBT_TXPWR_SHORT));
}
static ssize_t set_phy_short_reach(struct device *dev,
@@ -219,10 +201,9 @@ static ssize_t set_phy_short_reach(struct device *dev,
struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev));
rtnl_lock();
- mdio_clause45_set_flag(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- MDIO_PMAPMD_10GBT_TXPWR,
- MDIO_PMAPMD_10GBT_TXPWR_SHORT_LBN,
- count != 0 && *buf != '0');
+ efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TXPWR,
+ MDIO_PMA_10GBT_TXPWR_SHORT,
+ count != 0 && *buf != '0');
efx_reconfigure_port(efx);
rtnl_unlock();
@@ -238,9 +219,8 @@ int sft9001_wait_boot(struct efx_nic *efx)
int boot_stat;
for (;;) {
- boot_stat = mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PCS,
- PCS_BOOT_STATUS_REG);
+ boot_stat = efx_mdio_read(efx, MDIO_MMD_PCS,
+ PCS_BOOT_STATUS_REG);
if (boot_stat >= 0) {
EFX_LOG(efx, "PHY boot status = %#x\n", boot_stat);
switch (boot_stat &
@@ -286,38 +266,32 @@ int sft9001_wait_boot(struct efx_nic *efx)
static int tenxpress_init(struct efx_nic *efx)
{
- int phy_id = efx->mii.phy_id;
int reg;
if (efx->phy_type == PHY_TYPE_SFX7101) {
/* Enable 312.5 MHz clock */
- mdio_clause45_write(efx, phy_id,
- MDIO_MMD_PCS, PCS_TEST_SELECT_REG,
- 1 << CLK312_EN_LBN);
+ efx_mdio_write(efx, MDIO_MMD_PCS, PCS_TEST_SELECT_REG,
+ 1 << CLK312_EN_LBN);
} else {
/* Enable 312.5 MHz clock and GMII */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG);
reg |= ((1 << PMA_PMD_EXT_GMII_EN_LBN) |
(1 << PMA_PMD_EXT_CLK_OUT_LBN) |
(1 << PMA_PMD_EXT_CLK312_LBN) |
(1 << PMA_PMD_EXT_ROBUST_LBN));
- mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG, reg);
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT,
- GPHY_XCONTROL_REG, GPHY_ISOLATE_LBN,
- false);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg);
+ efx_mdio_set_flag(efx, MDIO_MMD_C22EXT,
+ GPHY_XCONTROL_REG, 1 << GPHY_ISOLATE_LBN,
+ false);
}
/* Set the LEDs up as: Green = Link, Amber = Link/Act, Red = Off */
if (efx->phy_type == PHY_TYPE_SFX7101) {
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_LED_CTRL_REG,
- PMA_PMA_LED_ACTIVITY_LBN,
- true);
- mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_LED_OVERR_REG, PMA_PMD_LED_DEFAULT);
+ efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, PMA_PMD_LED_CTRL_REG,
+ 1 << PMA_PMA_LED_ACTIVITY_LBN, true);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_LED_OVERR_REG,
+ PMA_PMD_LED_DEFAULT);
}
return 0;
@@ -337,22 +311,19 @@ static int tenxpress_phy_init(struct efx_nic *efx)
if (!(efx->phy_mode & PHY_MODE_SPECIAL)) {
if (efx->phy_type == PHY_TYPE_SFT9001A) {
int reg;
- reg = mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD,
+ PMA_PMD_XCONTROL_REG);
reg |= (1 << PMA_PMD_EXT_SSR_LBN);
- mdio_clause45_write(efx, efx->mii.phy_id,
- MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG, reg);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD,
+ PMA_PMD_XCONTROL_REG, reg);
mdelay(200);
}
- rc = mdio_clause45_wait_reset_mmds(efx,
- TENXPRESS_REQUIRED_DEVS);
+ rc = efx_mdio_wait_reset_mmds(efx, TENXPRESS_REQUIRED_DEVS);
if (rc < 0)
goto fail;
- rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
+ rc = efx_mdio_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
if (rc < 0)
goto fail;
}
@@ -360,7 +331,6 @@ static int tenxpress_phy_init(struct efx_nic *efx)
rc = tenxpress_init(efx);
if (rc < 0)
goto fail;
- mdio_clause45_set_pause(efx);
if (efx->phy_type == PHY_TYPE_SFT9001B) {
rc = device_create_file(&efx->pci_dev->dev,
@@ -395,17 +365,14 @@ static int tenxpress_special_reset(struct efx_nic *efx)
efx_stats_disable(efx);
/* Initiate reset */
- reg = mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG);
reg |= (1 << PMA_PMD_EXT_SSR_LBN);
- mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG, reg);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg);
mdelay(200);
/* Wait for the blocks to come out of reset */
- rc = mdio_clause45_wait_reset_mmds(efx,
- TENXPRESS_REQUIRED_DEVS);
+ rc = efx_mdio_wait_reset_mmds(efx, TENXPRESS_REQUIRED_DEVS);
if (rc < 0)
goto out;
@@ -424,7 +391,6 @@ out:
static void sfx7101_check_bad_lp(struct efx_nic *efx, bool link_ok)
{
struct tenxpress_phy_data *pd = efx->phy_data;
- int phy_id = efx->mii.phy_id;
bool bad_lp;
int reg;
@@ -432,11 +398,10 @@ static void sfx7101_check_bad_lp(struct efx_nic *efx, bool link_ok)
bad_lp = false;
} else {
/* Check that AN has started but not completed. */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_STATUS);
- if (!(reg & (1 << MDIO_AN_STATUS_LP_AN_CAP_LBN)))
+ reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_STAT1);
+ if (!(reg & MDIO_AN_STAT1_LPABLE))
return; /* LP status is unknown */
- bad_lp = !(reg & (1 << MDIO_AN_STATUS_AN_DONE_LBN));
+ bad_lp = !(reg & MDIO_AN_STAT1_COMPLETE);
if (bad_lp)
pd->bad_lp_tries++;
}
@@ -448,8 +413,8 @@ static void sfx7101_check_bad_lp(struct efx_nic *efx, bool link_ok)
/* Use the RX (red) LED as an error indicator once we've seen AN
* failure several times in a row, and also log a message. */
if (!bad_lp || pd->bad_lp_tries == MAX_BAD_LP_TRIES) {
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_LED_OVERR_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD,
+ PMA_PMD_LED_OVERR_REG);
reg &= ~(PMA_PMD_LED_MASK << PMA_PMD_LED_RX_LBN);
if (!bad_lp) {
reg |= PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN;
@@ -460,23 +425,22 @@ static void sfx7101_check_bad_lp(struct efx_nic *efx, bool link_ok)
" supports 10GBASE-T ONLY, so no link can"
" be established\n");
}
- mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_LED_OVERR_REG, reg);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD,
+ PMA_PMD_LED_OVERR_REG, reg);
pd->bad_lp_tries = bad_lp;
}
}
static bool sfx7101_link_ok(struct efx_nic *efx)
{
- return mdio_clause45_links_ok(efx,
- MDIO_MMDREG_DEVS_PMAPMD |
- MDIO_MMDREG_DEVS_PCS |
- MDIO_MMDREG_DEVS_PHYXS);
+ return efx_mdio_links_ok(efx,
+ MDIO_DEVS_PMAPMD |
+ MDIO_DEVS_PCS |
+ MDIO_DEVS_PHYXS);
}
static bool sft9001_link_ok(struct efx_nic *efx, struct ethtool_cmd *ecmd)
{
- int phy_id = efx->mii.phy_id;
u32 reg;
if (efx_phy_mode_disabled(efx->phy_mode))
@@ -484,50 +448,43 @@ static bool sft9001_link_ok(struct efx_nic *efx, struct ethtool_cmd *ecmd)
else if (efx->loopback_mode == LOOPBACK_GPHY)
return true;
else if (efx->loopback_mode)
- return mdio_clause45_links_ok(efx,
- MDIO_MMDREG_DEVS_PMAPMD |
- MDIO_MMDREG_DEVS_PHYXS);
+ return efx_mdio_links_ok(efx,
+ MDIO_DEVS_PMAPMD |
+ MDIO_DEVS_PHYXS);
/* We must use the same definition of link state as LASI,
* otherwise we can miss a link state transition
*/
if (ecmd->speed == 10000) {
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS,
- PCS_10GBASET_STAT1);
- return reg & (1 << PCS_10GBASET_BLKLK_LBN);
+ reg = efx_mdio_read(efx, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT1);
+ return reg & MDIO_PCS_10GBRT_STAT1_BLKLK;
} else {
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_C22EXT,
- C22EXT_STATUS_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_C22EXT, C22EXT_STATUS_REG);
return reg & (1 << C22EXT_STATUS_LINK_LBN);
}
}
static void tenxpress_ext_loopback(struct efx_nic *efx)
{
- int phy_id = efx->mii.phy_id;
-
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PHYXS,
- PHYXS_TEST1, LOOPBACK_NEAR_LBN,
- efx->loopback_mode == LOOPBACK_PHYXS);
+ efx_mdio_set_flag(efx, MDIO_MMD_PHYXS, PHYXS_TEST1,
+ 1 << LOOPBACK_NEAR_LBN,
+ efx->loopback_mode == LOOPBACK_PHYXS);
if (efx->phy_type != PHY_TYPE_SFX7101)
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT,
- GPHY_XCONTROL_REG,
- GPHY_LOOPBACK_NEAR_LBN,
- efx->loopback_mode == LOOPBACK_GPHY);
+ efx_mdio_set_flag(efx, MDIO_MMD_C22EXT, GPHY_XCONTROL_REG,
+ 1 << GPHY_LOOPBACK_NEAR_LBN,
+ efx->loopback_mode == LOOPBACK_GPHY);
}
static void tenxpress_low_power(struct efx_nic *efx)
{
- int phy_id = efx->mii.phy_id;
-
if (efx->phy_type == PHY_TYPE_SFX7101)
- mdio_clause45_set_mmds_lpower(
+ efx_mdio_set_mmds_lpower(
efx, !!(efx->phy_mode & PHY_MODE_LOW_POWER),
TENXPRESS_REQUIRED_DEVS);
else
- mdio_clause45_set_flag(
- efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG, PMA_PMD_EXT_LPOWER_LBN,
+ efx_mdio_set_flag(
+ efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG,
+ 1 << PMA_PMD_EXT_LPOWER_LBN,
!!(efx->phy_mode & PHY_MODE_LOW_POWER));
}
@@ -568,8 +525,8 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx)
WARN_ON(rc);
}
- mdio_clause45_transmit_disable(efx);
- mdio_clause45_phy_reconfigure(efx);
+ efx_mdio_transmit_disable(efx);
+ efx_mdio_phy_reconfigure(efx);
tenxpress_ext_loopback(efx);
phy_data->loopback_mode = efx->loopback_mode;
@@ -585,7 +542,7 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx)
efx->link_fd = ecmd.duplex == DUPLEX_FULL;
efx->link_up = sft9001_link_ok(efx, &ecmd);
}
- efx->link_fc = mdio_clause45_get_pause(efx);
+ efx->link_fc = efx_mdio_get_pause(efx);
}
/* Poll PHY for interrupt */
@@ -599,7 +556,7 @@ static void tenxpress_phy_poll(struct efx_nic *efx)
if (link_ok != efx->link_up) {
change = true;
} else {
- unsigned int link_fc = mdio_clause45_get_pause(efx);
+ unsigned int link_fc = efx_mdio_get_pause(efx);
if (link_fc != efx->link_fc)
change = true;
}
@@ -609,10 +566,9 @@ static void tenxpress_phy_poll(struct efx_nic *efx)
if (link_ok != efx->link_up)
change = true;
} else {
- u32 status = mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PMAPMD,
- PMA_PMD_LASI_STATUS);
- if (status & (1 << PMA_PMD_LS_ALARM_LBN))
+ int status = efx_mdio_read(efx, MDIO_MMD_PMAPMD,
+ MDIO_PMA_LASI_STAT);
+ if (status & MDIO_PMA_LASI_LSALARM)
change = true;
}
@@ -634,8 +590,7 @@ static void tenxpress_phy_fini(struct efx_nic *efx)
if (efx->phy_type == PHY_TYPE_SFX7101) {
/* Power down the LNPGA */
reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
- mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_XCONTROL_REG, reg);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg);
/* Waiting here ensures that the board fini, which can turn
* off the power to the PHY, won't get run until the LNPGA
@@ -661,8 +616,7 @@ void tenxpress_phy_blink(struct efx_nic *efx, bool blink)
else
reg = PMA_PMD_LED_DEFAULT;
- mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_LED_OVERR_REG, reg);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_LED_OVERR_REG, reg);
}
static const char *const sfx7101_test_names[] = {
@@ -698,7 +652,6 @@ static const char *const sft9001_test_names[] = {
static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags)
{
struct ethtool_cmd ecmd;
- int phy_id = efx->mii.phy_id;
int rc = 0, rc2, i, ctrl_reg, res_reg;
if (flags & ETH_TEST_FL_OFFLINE)
@@ -717,11 +670,10 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags)
* must reset the PHY to resume normal service. */
ctrl_reg |= (1 << CDIAG_CTRL_BRK_LINK_LBN);
}
- mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_CDIAG_CTRL_REG, ctrl_reg);
+ efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_CDIAG_CTRL_REG,
+ ctrl_reg);
i = 0;
- while (mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_CDIAG_CTRL_REG) &
+ while (efx_mdio_read(efx, MDIO_MMD_PMAPMD, PMA_PMD_CDIAG_CTRL_REG) &
(1 << CDIAG_CTRL_IN_PROG_LBN)) {
if (++i == 50) {
rc = -ETIMEDOUT;
@@ -729,15 +681,13 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags)
}
msleep(100);
}
- res_reg = mdio_clause45_read(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_CDIAG_RES_REG);
+ res_reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, PMA_PMD_CDIAG_RES_REG);
for (i = 0; i < 4; i++) {
int pair_res =
(res_reg >> (CDIAG_RES_A_LBN - i * CDIAG_RES_WIDTH))
& ((1 << CDIAG_RES_WIDTH) - 1);
- int len_reg = mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PMAPMD,
- PMA_PMD_CDIAG_LEN_REG + i);
+ int len_reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD,
+ PMA_PMD_CDIAG_LEN_REG + i);
if (pair_res == CDIAG_RES_OK)
results[1 + i] = 1;
else if (pair_res == CDIAG_RES_INVALID)
@@ -769,32 +719,27 @@ out:
static void
tenxpress_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
{
- int phy_id = efx->mii.phy_id;
u32 adv = 0, lpa = 0;
int reg;
if (efx->phy_type != PHY_TYPE_SFX7101) {
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_C22EXT,
- C22EXT_MSTSLV_CTRL);
+ reg = efx_mdio_read(efx, MDIO_MMD_C22EXT, C22EXT_MSTSLV_CTRL);
if (reg & (1 << C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN))
adv |= ADVERTISED_1000baseT_Full;
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_C22EXT,
- C22EXT_MSTSLV_STATUS);
+ reg = efx_mdio_read(efx, MDIO_MMD_C22EXT, C22EXT_MSTSLV_STATUS);
if (reg & (1 << C22EXT_MSTSLV_STATUS_LP_1000_HD_LBN))
lpa |= ADVERTISED_1000baseT_Half;
if (reg & (1 << C22EXT_MSTSLV_STATUS_LP_1000_FD_LBN))
lpa |= ADVERTISED_1000baseT_Full;
}
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_10GBT_CTRL);
- if (reg & (1 << MDIO_AN_10GBT_CTRL_ADV_10G_LBN))
+ reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL);
+ if (reg & MDIO_AN_10GBT_CTRL_ADV10G)
adv |= ADVERTISED_10000baseT_Full;
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_10GBT_STATUS);
- if (reg & (1 << MDIO_AN_10GBT_STATUS_LP_10G_LBN))
+ reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_10GBT_STAT);
+ if (reg & MDIO_AN_10GBT_STAT_LP10G)
lpa |= ADVERTISED_10000baseT_Full;
- mdio_clause45_get_settings_ext(efx, ecmd, adv, lpa);
+ mdio45_ethtool_gset_npage(&efx->mdio, ecmd, adv, lpa);
if (efx->phy_type != PHY_TYPE_SFX7101)
ecmd->supported |= (SUPPORTED_100baseT_Full |
@@ -813,29 +758,24 @@ static int tenxpress_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
if (!ecmd->autoneg)
return -EINVAL;
- return mdio_clause45_set_settings(efx, ecmd);
+ return efx_mdio_set_settings(efx, ecmd);
}
static void sfx7101_set_npage_adv(struct efx_nic *efx, u32 advertising)
{
- mdio_clause45_set_flag(efx, efx->mii.phy_id, MDIO_MMD_AN,
- MDIO_AN_10GBT_CTRL,
- MDIO_AN_10GBT_CTRL_ADV_10G_LBN,
- advertising & ADVERTISED_10000baseT_Full);
+ efx_mdio_set_flag(efx, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
+ MDIO_AN_10GBT_CTRL_ADV10G,
+ advertising & ADVERTISED_10000baseT_Full);
}
static void sft9001_set_npage_adv(struct efx_nic *efx, u32 advertising)
{
- int phy_id = efx->mii.phy_id;
-
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT,
- C22EXT_MSTSLV_CTRL,
- C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN,
- advertising & ADVERTISED_1000baseT_Full);
- mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_AN,
- MDIO_AN_10GBT_CTRL,
- MDIO_AN_10GBT_CTRL_ADV_10G_LBN,
- advertising & ADVERTISED_10000baseT_Full);
+ efx_mdio_set_flag(efx, MDIO_MMD_C22EXT, C22EXT_MSTSLV_CTRL,
+ 1 << C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN,
+ advertising & ADVERTISED_1000baseT_Full);
+ efx_mdio_set_flag(efx, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
+ MDIO_AN_10GBT_CTRL_ADV10G,
+ advertising & ADVERTISED_10000baseT_Full);
}
struct efx_phy_operations falcon_sfx7101_phy_ops = {
diff --git a/drivers/net/sfc/xenpack.h b/drivers/net/sfc/xenpack.h
deleted file mode 100644
index b0d1f225b70a..000000000000
--- a/drivers/net/sfc/xenpack.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2006 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-#ifndef EFX_XENPACK_H
-#define EFX_XENPACK_H
-
-/* Exported functions from Xenpack standard PHY control */
-
-#include "mdio_10g.h"
-
-/****************************************************************************/
-/* XENPACK MDIO register extensions */
-#define MDIO_XP_LASI_RX_CTRL (0x9000)
-#define MDIO_XP_LASI_TX_CTRL (0x9001)
-#define MDIO_XP_LASI_CTRL (0x9002)
-#define MDIO_XP_LASI_RX_STAT (0x9003)
-#define MDIO_XP_LASI_TX_STAT (0x9004)
-#define MDIO_XP_LASI_STAT (0x9005)
-
-/* Control/Status bits */
-#define XP_LASI_LS_ALARM (1 << 0)
-#define XP_LASI_TX_ALARM (1 << 1)
-#define XP_LASI_RX_ALARM (1 << 2)
-/* These two are Quake vendor extensions to the standard XENPACK defines */
-#define XP_LASI_LS_INTB (1 << 3)
-#define XP_LASI_TEST (1 << 7)
-
-/* Enable LASI interrupts for PHY */
-static inline void xenpack_enable_lasi_irqs(struct efx_nic *efx)
-{
- int reg;
- int phy_id = efx->mii.phy_id;
- /* Read to clear LASI status register */
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_XP_LASI_STAT);
-
- mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
- MDIO_XP_LASI_CTRL, XP_LASI_LS_ALARM);
-}
-
-/* Read the LASI interrupt status to clear the interrupt. */
-static inline int xenpack_clear_lasi_irqs(struct efx_nic *efx)
-{
- /* Read to clear link status alarm */
- return mdio_clause45_read(efx, efx->mii.phy_id,
- MDIO_MMD_PMAPMD, MDIO_XP_LASI_STAT);
-}
-
-/* Turn off LASI interrupts */
-static inline void xenpack_disable_lasi_irqs(struct efx_nic *efx)
-{
- mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- MDIO_XP_LASI_CTRL, 0);
-}
-
-#endif /* EFX_XENPACK_H */
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c
index bb1ef77d5f56..bb2e6afd0829 100644
--- a/drivers/net/sfc/xfp_phy.c
+++ b/drivers/net/sfc/xfp_phy.c
@@ -15,13 +15,12 @@
#include <linux/delay.h>
#include "efx.h"
#include "mdio_10g.h"
-#include "xenpack.h"
#include "phy.h"
#include "falcon.h"
-#define XFP_REQUIRED_DEVS (MDIO_MMDREG_DEVS_PCS | \
- MDIO_MMDREG_DEVS_PMAPMD | \
- MDIO_MMDREG_DEVS_PHYXS)
+#define XFP_REQUIRED_DEVS (MDIO_DEVS_PCS | \
+ MDIO_DEVS_PMAPMD | \
+ MDIO_DEVS_PHYXS)
#define XFP_LOOPBACKS ((1 << LOOPBACK_PCS) | \
(1 << LOOPBACK_PMAPMD) | \
@@ -49,8 +48,7 @@
void xfp_set_led(struct efx_nic *p, int led, int mode)
{
int addr = MDIO_QUAKE_LED0_REG + led;
- mdio_clause45_write(p, p->mii.phy_id, MDIO_MMD_PMAPMD, addr,
- mode);
+ efx_mdio_write(p, MDIO_MMD_PMAPMD, addr, mode);
}
struct xfp_phy_data {
@@ -63,14 +61,12 @@ struct xfp_phy_data {
static int qt2025c_wait_reset(struct efx_nic *efx)
{
unsigned long timeout = jiffies + 10 * HZ;
- int phy_id = efx->mii.phy_id;
int reg, old_counter = 0;
/* Wait for firmware heartbeat to start */
for (;;) {
int counter;
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS,
- PCS_FW_HEARTBEAT_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_PCS, PCS_FW_HEARTBEAT_REG);
if (reg < 0)
return reg;
counter = ((reg >> PCS_FW_HEARTB_LBN) &
@@ -86,8 +82,7 @@ static int qt2025c_wait_reset(struct efx_nic *efx)
/* Wait for firmware status to look good */
for (;;) {
- reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS,
- PCS_UC8051_STATUS_REG);
+ reg = efx_mdio_read(efx, MDIO_MMD_PCS, PCS_UC8051_STATUS_REG);
if (reg < 0)
return reg;
if ((reg &
@@ -109,9 +104,9 @@ static int xfp_reset_phy(struct efx_nic *efx)
{
int rc;
- rc = mdio_clause45_reset_mmd(efx, MDIO_MMD_PHYXS,
- XFP_MAX_RESET_TIME / XFP_RESET_WAIT,
- XFP_RESET_WAIT);
+ rc = efx_mdio_reset_mmd(efx, MDIO_MMD_PHYXS,
+ XFP_MAX_RESET_TIME / XFP_RESET_WAIT,
+ XFP_RESET_WAIT);
if (rc < 0)
goto fail;
@@ -126,8 +121,7 @@ static int xfp_reset_phy(struct efx_nic *efx)
/* Check that all the MMDs we expect are present and responding. We
* expect faults on some if the link is down, but not on the PHY XS */
- rc = mdio_clause45_check_mmds(efx, XFP_REQUIRED_DEVS,
- MDIO_MMDREG_DEVS_PHYXS);
+ rc = efx_mdio_check_mmds(efx, XFP_REQUIRED_DEVS, MDIO_DEVS_PHYXS);
if (rc < 0)
goto fail;
@@ -143,7 +137,7 @@ static int xfp_reset_phy(struct efx_nic *efx)
static int xfp_phy_init(struct efx_nic *efx)
{
struct xfp_phy_data *phy_data;
- u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS);
+ u32 devid = efx_mdio_read_id(efx, MDIO_MMD_PHYXS);
int rc;
phy_data = kzalloc(sizeof(struct xfp_phy_data), GFP_KERNEL);
@@ -152,8 +146,8 @@ static int xfp_phy_init(struct efx_nic *efx)
efx->phy_data = phy_data;
EFX_INFO(efx, "PHY ID reg %x (OUI %06x model %02x revision %x)\n",
- devid, mdio_id_oui(devid), mdio_id_model(devid),
- mdio_id_rev(devid));
+ devid, efx_mdio_id_oui(devid), efx_mdio_id_model(devid),
+ efx_mdio_id_rev(devid));
phy_data->phy_mode = efx->phy_mode;
@@ -174,12 +168,13 @@ static int xfp_phy_init(struct efx_nic *efx)
static void xfp_phy_clear_interrupt(struct efx_nic *efx)
{
- xenpack_clear_lasi_irqs(efx);
+ /* Read to clear link status alarm */
+ efx_mdio_read(efx, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT);
}
static int xfp_link_ok(struct efx_nic *efx)
{
- return mdio_clause45_links_ok(efx, XFP_REQUIRED_DEVS);
+ return efx_mdio_links_ok(efx, XFP_REQUIRED_DEVS);
}
static void xfp_phy_poll(struct efx_nic *efx)
@@ -200,9 +195,9 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
* or optical transceivers, varying somewhat between
* firmware versions. Only 'static mode' appears to
* cover everything. */
- mdio_clause45_set_flag(
- efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
- PMA_PMD_FTX_CTRL2_REG, PMA_PMD_FTX_STATIC_LBN,
+ mdio_set_flag(
+ &efx->mdio, efx->mdio.prtad, MDIO_MMD_PMAPMD,
+ PMA_PMD_FTX_CTRL2_REG, 1 << PMA_PMD_FTX_STATIC_LBN,
efx->phy_mode & PHY_MODE_TX_DISABLED ||
efx->phy_mode & PHY_MODE_LOW_POWER ||
efx->loopback_mode == LOOPBACK_PCS ||
@@ -213,10 +208,10 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
(phy_data->phy_mode & PHY_MODE_TX_DISABLED))
xfp_reset_phy(efx);
- mdio_clause45_transmit_disable(efx);
+ efx_mdio_transmit_disable(efx);
}
- mdio_clause45_phy_reconfigure(efx);
+ efx_mdio_phy_reconfigure(efx);
phy_data->phy_mode = efx->phy_mode;
efx->link_up = xfp_link_ok(efx);
@@ -225,6 +220,10 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
efx->link_fc = efx->wanted_fc;
}
+static void xfp_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
+{
+ mdio45_ethtool_gset(&efx->mdio, ecmd);
+}
static void xfp_phy_fini(struct efx_nic *efx)
{
@@ -243,8 +242,8 @@ struct efx_phy_operations falcon_xfp_phy_ops = {
.poll = xfp_phy_poll,
.fini = xfp_phy_fini,
.clear_interrupt = xfp_phy_clear_interrupt,
- .get_settings = mdio_clause45_get_settings,
- .set_settings = mdio_clause45_set_settings,
+ .get_settings = xfp_phy_get_settings,
+ .set_settings = efx_mdio_set_settings,
.mmds = XFP_REQUIRED_DEVS,
.loopbacks = XFP_LOOPBACKS,
};
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 97d68560067d..5fb88ca6dd7f 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -709,6 +709,17 @@ static inline void setup_rx_ring(struct net_device *dev,
dma_sync_desc_dev(dev, &buf[i]);
}
+static const struct net_device_ops sgiseeq_netdev_ops = {
+ .ndo_open = sgiseeq_open,
+ .ndo_stop = sgiseeq_close,
+ .ndo_start_xmit = sgiseeq_start_xmit,
+ .ndo_tx_timeout = timeout,
+ .ndo_set_multicast_list = sgiseeq_set_multicast,
+ .ndo_set_mac_address = sgiseeq_set_mac_address,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
static int __init sgiseeq_probe(struct platform_device *pdev)
{
struct sgiseeq_platform_data *pd = pdev->dev.platform_data;
@@ -775,13 +786,8 @@ static int __init sgiseeq_probe(struct platform_device *pdev)
SEEQ_CTRL_SFLAG | SEEQ_CTRL_ESHORT |
SEEQ_CTRL_ENCARR;
- dev->open = sgiseeq_open;
- dev->stop = sgiseeq_close;
- dev->hard_start_xmit = sgiseeq_start_xmit;
- dev->tx_timeout = timeout;
+ dev->netdev_ops = &sgiseeq_netdev_ops;
dev->watchdog_timeo = (200 * HZ) / 1000;
- dev->set_multicast_list = sgiseeq_set_multicast;
- dev->set_mac_address = sgiseeq_set_mac_address;
dev->irq = irq;
if (register_netdev(dev)) {
diff --git a/drivers/net/skfp/h/smt.h b/drivers/net/skfp/h/smt.h
index 1ff589988d10..2976757a36fb 100644
--- a/drivers/net/skfp/h/smt.h
+++ b/drivers/net/skfp/h/smt.h
@@ -413,7 +413,7 @@ struct smt_p_reason {
#define SMT_RDF_SUCCESS 0x00000003 /* success (PMF) */
#define SMT_RDF_BADSET 0x00000004 /* bad set count (PMF) */
#define SMT_RDF_ILLEGAL 0x00000005 /* read only (PMF) */
-#define SMT_RDF_NOPARAM 0x6 /* paramter not supported (PMF) */
+#define SMT_RDF_NOPARAM 0x6 /* parameter not supported (PMF) */
#define SMT_RDF_RANGE 0x8 /* out of range */
#define SMT_RDF_AUTHOR 0x9 /* not autohorized */
#define SMT_RDF_LENGTH 0x0a /* length error */
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index e14aec0a7333..19d343c42a21 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -159,12 +159,6 @@ MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
static int num_boards; /* total number of adapters configured */
-#ifdef DRIVERDEBUG
-#define PRINTK(s, args...) printk(s, ## args)
-#else
-#define PRINTK(s, args...)
-#endif // DRIVERDEBUG
-
static const struct net_device_ops skfp_netdev_ops = {
.ndo_open = skfp_open,
.ndo_stop = skfp_close,
@@ -213,7 +207,7 @@ static int skfp_init_one(struct pci_dev *pdev,
void __iomem *mem;
int err;
- PRINTK(KERN_INFO "entering skfp_init_one\n");
+ pr_debug(KERN_INFO "entering skfp_init_one\n");
if (num_boards == 0)
printk("%s\n", boot_msg);
@@ -389,7 +383,7 @@ static int skfp_driver_init(struct net_device *dev)
skfddi_priv *bp = &smc->os;
int err = -EIO;
- PRINTK(KERN_INFO "entering skfp_driver_init\n");
+ pr_debug(KERN_INFO "entering skfp_driver_init\n");
// set the io address in private structures
bp->base_addr = dev->base_addr;
@@ -409,7 +403,7 @@ static int skfp_driver_init(struct net_device *dev)
// Determine the required size of the 'shared' memory area.
bp->SharedMemSize = mac_drv_check_space();
- PRINTK(KERN_INFO "Memory for HWM: %ld\n", bp->SharedMemSize);
+ pr_debug(KERN_INFO "Memory for HWM: %ld\n", bp->SharedMemSize);
if (bp->SharedMemSize > 0) {
bp->SharedMemSize += 16; // for descriptor alignment
@@ -433,13 +427,13 @@ static int skfp_driver_init(struct net_device *dev)
card_stop(smc); // Reset adapter.
- PRINTK(KERN_INFO "mac_drv_init()..\n");
+ pr_debug(KERN_INFO "mac_drv_init()..\n");
if (mac_drv_init(smc) != 0) {
- PRINTK(KERN_INFO "mac_drv_init() failed.\n");
+ pr_debug(KERN_INFO "mac_drv_init() failed.\n");
goto fail;
}
read_address(smc, NULL);
- PRINTK(KERN_INFO "HW-Addr: %02x %02x %02x %02x %02x %02x\n",
+ pr_debug(KERN_INFO "HW-Addr: %02x %02x %02x %02x %02x %02x\n",
smc->hw.fddi_canon_addr.a[0],
smc->hw.fddi_canon_addr.a[1],
smc->hw.fddi_canon_addr.a[2],
@@ -495,7 +489,7 @@ static int skfp_open(struct net_device *dev)
struct s_smc *smc = netdev_priv(dev);
int err;
- PRINTK(KERN_INFO "entering skfp_open\n");
+ pr_debug(KERN_INFO "entering skfp_open\n");
/* Register IRQ - support shared interrupts by passing device ptr */
err = request_irq(dev->irq, skfp_interrupt, IRQF_SHARED,
dev->name, dev);
@@ -868,12 +862,12 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
/* Enable promiscuous mode, if necessary */
if (dev->flags & IFF_PROMISC) {
mac_drv_rx_mode(smc, RX_ENABLE_PROMISC);
- PRINTK(KERN_INFO "PROMISCUOUS MODE ENABLED\n");
+ pr_debug(KERN_INFO "PROMISCUOUS MODE ENABLED\n");
}
/* Else, update multicast address table */
else {
mac_drv_rx_mode(smc, RX_DISABLE_PROMISC);
- PRINTK(KERN_INFO "PROMISCUOUS MODE DISABLED\n");
+ pr_debug(KERN_INFO "PROMISCUOUS MODE DISABLED\n");
// Reset all MC addresses
mac_clear_multicast(smc);
@@ -881,7 +875,7 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
if (dev->flags & IFF_ALLMULTI) {
mac_drv_rx_mode(smc, RX_ENABLE_ALLMULTI);
- PRINTK(KERN_INFO "ENABLE ALL MC ADDRESSES\n");
+ pr_debug(KERN_INFO "ENABLE ALL MC ADDRESSES\n");
} else if (dev->mc_count > 0) {
if (dev->mc_count <= FPMAX_MULTICAST) {
/* use exact filtering */
@@ -894,12 +888,12 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
(struct fddi_addr *)dmi->dmi_addr,
1);
- PRINTK(KERN_INFO "ENABLE MC ADDRESS:");
- PRINTK(" %02x %02x %02x ",
+ pr_debug(KERN_INFO "ENABLE MC ADDRESS:");
+ pr_debug(" %02x %02x %02x ",
dmi->dmi_addr[0],
dmi->dmi_addr[1],
dmi->dmi_addr[2]);
- PRINTK("%02x %02x %02x\n",
+ pr_debug("%02x %02x %02x\n",
dmi->dmi_addr[3],
dmi->dmi_addr[4],
dmi->dmi_addr[5]);
@@ -909,11 +903,11 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
} else { // more MC addresses than HW supports
mac_drv_rx_mode(smc, RX_ENABLE_ALLMULTI);
- PRINTK(KERN_INFO "ENABLE ALL MC ADDRESSES\n");
+ pr_debug(KERN_INFO "ENABLE ALL MC ADDRESSES\n");
}
} else { // no MC addresses
- PRINTK(KERN_INFO "DISABLE ALL MC ADDRESSES\n");
+ pr_debug(KERN_INFO "DISABLE ALL MC ADDRESSES\n");
}
/* Update adapter filters */
@@ -1067,7 +1061,7 @@ static int skfp_send_pkt(struct sk_buff *skb, struct net_device *dev)
struct s_smc *smc = netdev_priv(dev);
skfddi_priv *bp = &smc->os;
- PRINTK(KERN_INFO "skfp_send_pkt\n");
+ pr_debug(KERN_INFO "skfp_send_pkt\n");
/*
* Verify that incoming transmit request is OK
@@ -1137,13 +1131,13 @@ static void send_queued_packets(struct s_smc *smc)
int frame_status; // HWM tx frame status.
- PRINTK(KERN_INFO "send queued packets\n");
+ pr_debug(KERN_INFO "send queued packets\n");
for (;;) {
// send first buffer from queue
skb = skb_dequeue(&bp->SendSkbQueue);
if (!skb) {
- PRINTK(KERN_INFO "queue empty\n");
+ pr_debug(KERN_INFO "queue empty\n");
return;
} // queue empty !
@@ -1174,11 +1168,11 @@ static void send_queued_packets(struct s_smc *smc)
if ((frame_status & RING_DOWN) != 0) {
// Ring is down.
- PRINTK("Tx attempt while ring down.\n");
+ pr_debug("Tx attempt while ring down.\n");
} else if ((frame_status & OUT_OF_TXD) != 0) {
- PRINTK("%s: out of TXDs.\n", bp->dev->name);
+ pr_debug("%s: out of TXDs.\n", bp->dev->name);
} else {
- PRINTK("%s: out of transmit resources",
+ pr_debug("%s: out of transmit resources",
bp->dev->name);
}
@@ -1255,7 +1249,7 @@ static void CheckSourceAddress(unsigned char *frame, unsigned char *hw_addr)
static void ResetAdapter(struct s_smc *smc)
{
- PRINTK(KERN_INFO "[fddi: ResetAdapter]\n");
+ pr_debug(KERN_INFO "[fddi: ResetAdapter]\n");
// Stop the adapter.
@@ -1301,7 +1295,7 @@ void llc_restart_tx(struct s_smc *smc)
{
skfddi_priv *bp = &smc->os;
- PRINTK(KERN_INFO "[llc_restart_tx]\n");
+ pr_debug(KERN_INFO "[llc_restart_tx]\n");
// Try to send queued packets
spin_unlock(&bp->DriverLock);
@@ -1331,7 +1325,7 @@ void *mac_drv_get_space(struct s_smc *smc, unsigned int size)
{
void *virt;
- PRINTK(KERN_INFO "mac_drv_get_space (%d bytes), ", size);
+ pr_debug(KERN_INFO "mac_drv_get_space (%d bytes), ", size);
virt = (void *) (smc->os.SharedMemAddr + smc->os.SharedMemHeap);
if ((smc->os.SharedMemHeap + size) > smc->os.SharedMemSize) {
@@ -1340,9 +1334,9 @@ void *mac_drv_get_space(struct s_smc *smc, unsigned int size)
}
smc->os.SharedMemHeap += size; // Move heap pointer.
- PRINTK(KERN_INFO "mac_drv_get_space end\n");
- PRINTK(KERN_INFO "virt addr: %lx\n", (ulong) virt);
- PRINTK(KERN_INFO "bus addr: %lx\n", (ulong)
+ pr_debug(KERN_INFO "mac_drv_get_space end\n");
+ pr_debug(KERN_INFO "virt addr: %lx\n", (ulong) virt);
+ pr_debug(KERN_INFO "bus addr: %lx\n", (ulong)
(smc->os.SharedMemDMA +
((char *) virt - (char *)smc->os.SharedMemAddr)));
return (virt);
@@ -1372,7 +1366,7 @@ void *mac_drv_get_desc_mem(struct s_smc *smc, unsigned int size)
char *virt;
- PRINTK(KERN_INFO "mac_drv_get_desc_mem\n");
+ pr_debug(KERN_INFO "mac_drv_get_desc_mem\n");
// Descriptor memory must be aligned on 16-byte boundary.
@@ -1381,8 +1375,8 @@ void *mac_drv_get_desc_mem(struct s_smc *smc, unsigned int size)
size = (u_int) (16 - (((unsigned long) virt) & 15UL));
size = size % 16;
- PRINTK("Allocate %u bytes alignment gap ", size);
- PRINTK("for descriptor memory.\n");
+ pr_debug("Allocate %u bytes alignment gap ", size);
+ pr_debug("for descriptor memory.\n");
if (!mac_drv_get_space(smc, size)) {
printk("fddi: Unable to align descriptor memory.\n");
@@ -1516,11 +1510,11 @@ void mac_drv_tx_complete(struct s_smc *smc, volatile struct s_smt_fp_txd *txd)
{
struct sk_buff *skb;
- PRINTK(KERN_INFO "entering mac_drv_tx_complete\n");
+ pr_debug(KERN_INFO "entering mac_drv_tx_complete\n");
// Check if this TxD points to a skb
if (!(skb = txd->txd_os.skb)) {
- PRINTK("TXD with no skb assigned.\n");
+ pr_debug("TXD with no skb assigned.\n");
return;
}
txd->txd_os.skb = NULL;
@@ -1536,7 +1530,7 @@ void mac_drv_tx_complete(struct s_smc *smc, volatile struct s_smt_fp_txd *txd)
// free the skb
dev_kfree_skb_irq(skb);
- PRINTK(KERN_INFO "leaving mac_drv_tx_complete\n");
+ pr_debug(KERN_INFO "leaving mac_drv_tx_complete\n");
} // mac_drv_tx_complete
@@ -1603,7 +1597,7 @@ void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
unsigned short ri;
u_int RifLength;
- PRINTK(KERN_INFO "entering mac_drv_rx_complete (len=%d)\n", len);
+ pr_debug(KERN_INFO "entering mac_drv_rx_complete (len=%d)\n", len);
if (frag_count != 1) { // This is not allowed to happen.
printk("fddi: Multi-fragment receive!\n");
@@ -1612,7 +1606,7 @@ void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
}
skb = rxd->rxd_os.skb;
if (!skb) {
- PRINTK(KERN_INFO "No skb in rxd\n");
+ pr_debug(KERN_INFO "No skb in rxd\n");
smc->os.MacStat.gen.rx_errors++;
goto RequeueRxd;
}
@@ -1642,7 +1636,7 @@ void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
else {
int n;
// goos: RIF removal has still to be tested
- PRINTK(KERN_INFO "RIF found\n");
+ pr_debug(KERN_INFO "RIF found\n");
// Get RIF length from Routing Control (RC) field.
cp = virt + FDDI_MAC_HDR_LEN; // Point behind MAC header.
@@ -1687,7 +1681,7 @@ void mac_drv_rx_complete(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
return;
RequeueRxd:
- PRINTK(KERN_INFO "Rx: re-queue RXD.\n");
+ pr_debug(KERN_INFO "Rx: re-queue RXD.\n");
mac_drv_requeue_rxd(smc, rxd, frag_count);
smc->os.MacStat.gen.rx_errors++; // Count receive packets
// not indicated.
@@ -1736,7 +1730,7 @@ void mac_drv_requeue_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
skb = src_rxd->rxd_os.skb;
if (skb == NULL) { // this should not happen
- PRINTK("Requeue with no skb in rxd!\n");
+ pr_debug("Requeue with no skb in rxd!\n");
skb = alloc_skb(MaxFrameSize + 3, GFP_ATOMIC);
if (skb) {
// we got a skb
@@ -1751,7 +1745,7 @@ void mac_drv_requeue_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
rxd->rxd_os.dma_addr = b_addr;
} else {
// no skb available, use local buffer
- PRINTK("Queueing invalid buffer!\n");
+ pr_debug("Queueing invalid buffer!\n");
rxd->rxd_os.skb = NULL;
v_addr = smc->os.LocalRxBuffer;
b_addr = smc->os.LocalRxBufferDMA;
@@ -1798,7 +1792,7 @@ void mac_drv_fill_rxd(struct s_smc *smc)
struct sk_buff *skb;
volatile struct s_smt_fp_rxd *rxd;
- PRINTK(KERN_INFO "entering mac_drv_fill_rxd\n");
+ pr_debug(KERN_INFO "entering mac_drv_fill_rxd\n");
// Walk through the list of free receive buffers, passing receive
// buffers to the HWM as long as RXDs are available.
@@ -1806,7 +1800,7 @@ void mac_drv_fill_rxd(struct s_smc *smc)
MaxFrameSize = smc->os.MaxFrameSize;
// Check if there is any RXD left.
while (HWM_GET_RX_FREE(smc) > 0) {
- PRINTK(KERN_INFO ".\n");
+ pr_debug(KERN_INFO ".\n");
rxd = HWM_GET_CURR_RXD(smc);
skb = alloc_skb(MaxFrameSize + 3, GFP_ATOMIC);
@@ -1826,7 +1820,7 @@ void mac_drv_fill_rxd(struct s_smc *smc)
// keep the receiver running in hope of better times.
// Multiple descriptors may point to this local buffer,
// so data in it must be considered invalid.
- PRINTK("Queueing invalid buffer!\n");
+ pr_debug("Queueing invalid buffer!\n");
v_addr = smc->os.LocalRxBuffer;
b_addr = smc->os.LocalRxBufferDMA;
}
@@ -1837,7 +1831,7 @@ void mac_drv_fill_rxd(struct s_smc *smc)
hwm_rx_frag(smc, v_addr, b_addr, MaxFrameSize,
FIRST_FRAG | LAST_FRAG);
}
- PRINTK(KERN_INFO "leaving mac_drv_fill_rxd\n");
+ pr_debug(KERN_INFO "leaving mac_drv_fill_rxd\n");
} // mac_drv_fill_rxd
@@ -1863,7 +1857,7 @@ void mac_drv_clear_rxd(struct s_smc *smc, volatile struct s_smt_fp_rxd *rxd,
struct sk_buff *skb;
- PRINTK("entering mac_drv_clear_rxd\n");
+ pr_debug("entering mac_drv_clear_rxd\n");
if (frag_count != 1) // This is not allowed to happen.
@@ -1919,19 +1913,19 @@ int mac_drv_rx_init(struct s_smc *smc, int len, int fc,
{
struct sk_buff *skb;
- PRINTK("entering mac_drv_rx_init(len=%d)\n", len);
+ pr_debug("entering mac_drv_rx_init(len=%d)\n", len);
// "Received" a SMT or NSA frame of the local SMT.
if (len != la_len || len < FDDI_MAC_HDR_LEN || !look_ahead) {
- PRINTK("fddi: Discard invalid local SMT frame\n");
- PRINTK(" len=%d, la_len=%d, (ULONG) look_ahead=%08lXh.\n",
+ pr_debug("fddi: Discard invalid local SMT frame\n");
+ pr_debug(" len=%d, la_len=%d, (ULONG) look_ahead=%08lXh.\n",
len, la_len, (unsigned long) look_ahead);
return (0);
}
skb = alloc_skb(len + 3, GFP_ATOMIC);
if (!skb) {
- PRINTK("fddi: Local SMT: skb memory exhausted.\n");
+ pr_debug("fddi: Local SMT: skb memory exhausted.\n");
return (0);
}
skb_reserve(skb, 3);
@@ -1981,40 +1975,40 @@ void smt_timer_poll(struct s_smc *smc)
************************/
void ring_status_indication(struct s_smc *smc, u_long status)
{
- PRINTK("ring_status_indication( ");
+ pr_debug("ring_status_indication( ");
if (status & RS_RES15)
- PRINTK("RS_RES15 ");
+ pr_debug("RS_RES15 ");
if (status & RS_HARDERROR)
- PRINTK("RS_HARDERROR ");
+ pr_debug("RS_HARDERROR ");
if (status & RS_SOFTERROR)
- PRINTK("RS_SOFTERROR ");
+ pr_debug("RS_SOFTERROR ");
if (status & RS_BEACON)
- PRINTK("RS_BEACON ");
+ pr_debug("RS_BEACON ");
if (status & RS_PATHTEST)
- PRINTK("RS_PATHTEST ");
+ pr_debug("RS_PATHTEST ");
if (status & RS_SELFTEST)
- PRINTK("RS_SELFTEST ");
+ pr_debug("RS_SELFTEST ");
if (status & RS_RES9)
- PRINTK("RS_RES9 ");
+ pr_debug("RS_RES9 ");
if (status & RS_DISCONNECT)
- PRINTK("RS_DISCONNECT ");
+ pr_debug("RS_DISCONNECT ");
if (status & RS_RES7)
- PRINTK("RS_RES7 ");
+ pr_debug("RS_RES7 ");
if (status & RS_DUPADDR)
- PRINTK("RS_DUPADDR ");
+ pr_debug("RS_DUPADDR ");
if (status & RS_NORINGOP)
- PRINTK("RS_NORINGOP ");
+ pr_debug("RS_NORINGOP ");
if (status & RS_VERSION)
- PRINTK("RS_VERSION ");
+ pr_debug("RS_VERSION ");
if (status & RS_STUCKBYPASSS)
- PRINTK("RS_STUCKBYPASSS ");
+ pr_debug("RS_STUCKBYPASSS ");
if (status & RS_EVENT)
- PRINTK("RS_EVENT ");
+ pr_debug("RS_EVENT ");
if (status & RS_RINGOPCHANGE)
- PRINTK("RS_RINGOPCHANGE ");
+ pr_debug("RS_RINGOPCHANGE ");
if (status & RS_RES0)
- PRINTK("RS_RES0 ");
- PRINTK("]\n");
+ pr_debug("RS_RES0 ");
+ pr_debug("]\n");
} // ring_status_indication
@@ -2057,17 +2051,17 @@ void smt_stat_counter(struct s_smc *smc, int stat)
{
// BOOLEAN RingIsUp ;
- PRINTK(KERN_INFO "smt_stat_counter\n");
+ pr_debug(KERN_INFO "smt_stat_counter\n");
switch (stat) {
case 0:
- PRINTK(KERN_INFO "Ring operational change.\n");
+ pr_debug(KERN_INFO "Ring operational change.\n");
break;
case 1:
- PRINTK(KERN_INFO "Receive fifo overflow.\n");
+ pr_debug(KERN_INFO "Receive fifo overflow.\n");
smc->os.MacStat.gen.rx_errors++;
break;
default:
- PRINTK(KERN_INFO "Unknown status (%d).\n", stat);
+ pr_debug(KERN_INFO "Unknown status (%d).\n", stat);
break;
}
} // smt_stat_counter
@@ -2123,10 +2117,10 @@ void cfm_state_change(struct s_smc *smc, int c_state)
s = "SC11_C_WRAP_S";
break;
default:
- PRINTK(KERN_INFO "cfm_state_change: unknown %d\n", c_state);
+ pr_debug(KERN_INFO "cfm_state_change: unknown %d\n", c_state);
return;
}
- PRINTK(KERN_INFO "cfm_state_change: %s\n", s);
+ pr_debug(KERN_INFO "cfm_state_change: %s\n", s);
#endif // DRIVERDEBUG
} // cfm_state_change
@@ -2181,7 +2175,7 @@ void ecm_state_change(struct s_smc *smc, int e_state)
s = "unknown";
break;
}
- PRINTK(KERN_INFO "ecm_state_change: %s\n", s);
+ pr_debug(KERN_INFO "ecm_state_change: %s\n", s);
#endif //DRIVERDEBUG
} // ecm_state_change
@@ -2236,7 +2230,7 @@ void rmt_state_change(struct s_smc *smc, int r_state)
s = "unknown";
break;
}
- PRINTK(KERN_INFO "[rmt_state_change: %s]\n", s);
+ pr_debug(KERN_INFO "[rmt_state_change: %s]\n", s);
#endif // DRIVERDEBUG
} // rmt_state_change
@@ -2256,7 +2250,7 @@ void rmt_state_change(struct s_smc *smc, int r_state)
************************/
void drv_reset_indication(struct s_smc *smc)
{
- PRINTK(KERN_INFO "entering drv_reset_indication\n");
+ pr_debug(KERN_INFO "entering drv_reset_indication\n");
smc->os.ResetRequested = TRUE; // Set flag.
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 5c61d5fad908..527c2ce59150 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -616,6 +616,14 @@ static void sl_uninit(struct net_device *dev)
sl_free_bufs(sl);
}
+/* Hook the destructor so we can free slip devices at the right point in time */
+static void sl_free_netdev(struct net_device *dev)
+{
+ int i = dev->base_addr;
+ free_netdev(dev);
+ slip_devs[i] = NULL;
+}
+
static const struct net_device_ops sl_netdev_ops = {
.ndo_init = sl_init,
.ndo_uninit = sl_uninit,
@@ -634,7 +642,7 @@ static const struct net_device_ops sl_netdev_ops = {
static void sl_setup(struct net_device *dev)
{
dev->netdev_ops = &sl_netdev_ops;
- dev->destructor = free_netdev;
+ dev->destructor = sl_free_netdev;
dev->hard_header_len = 0;
dev->addr_len = 0;
@@ -712,8 +720,6 @@ static void sl_sync(void)
static struct slip *sl_alloc(dev_t line)
{
int i;
- int sel = -1;
- int score = -1;
struct net_device *dev = NULL;
struct slip *sl;
@@ -724,55 +730,7 @@ static struct slip *sl_alloc(dev_t line)
dev = slip_devs[i];
if (dev == NULL)
break;
-
- sl = netdev_priv(dev);
- if (sl->leased) {
- if (sl->line != line)
- continue;
- if (sl->tty)
- return NULL;
-
- /* Clear ESCAPE & ERROR flags */
- sl->flags &= (1 << SLF_INUSE);
- return sl;
- }
-
- if (sl->tty)
- continue;
-
- if (current->pid == sl->pid) {
- if (sl->line == line && score < 3) {
- sel = i;
- score = 3;
- continue;
- }
- if (score < 2) {
- sel = i;
- score = 2;
- }
- continue;
- }
- if (sl->line == line && score < 1) {
- sel = i;
- score = 1;
- continue;
- }
- if (score < 0) {
- sel = i;
- score = 0;
- }
- }
-
- if (sel >= 0) {
- i = sel;
- dev = slip_devs[i];
- if (score > 1) {
- sl = netdev_priv(dev);
- sl->flags &= (1 << SLF_INUSE);
- return sl;
- }
}
-
/* Sorry, too many, all slots in use */
if (i >= slip_maxdev)
return NULL;
@@ -909,30 +867,13 @@ err_exit:
}
/*
-
- FIXME: 1,2 are fixed 3 was never true anyway.
-
- Let me to blame a bit.
- 1. TTY module calls this funstion on soft interrupt.
- 2. TTY module calls this function WITH MASKED INTERRUPTS!
- 3. TTY module does not notify us about line discipline
- shutdown,
-
- Seems, now it is clean. The solution is to consider netdevice and
- line discipline sides as two independent threads.
-
- By-product (not desired): sl? does not feel hangups and remains open.
- It is supposed, that user level program (dip, diald, slattach...)
- will catch SIGHUP and make the rest of work.
-
- I see no way to make more with current tty code. --ANK
- */
-
-/*
* Close down a SLIP channel.
* This means flushing out any pending queues, and then returning. This
* call is serialized against other ldisc functions.
+ *
+ * We also use this method fo a hangup event
*/
+
static void slip_close(struct tty_struct *tty)
{
struct slip *sl = tty->disc_data;
@@ -951,10 +892,16 @@ static void slip_close(struct tty_struct *tty)
del_timer_sync(&sl->keepalive_timer);
del_timer_sync(&sl->outfill_timer);
#endif
-
- /* Count references from TTY module */
+ /* Flush network side */
+ unregister_netdev(sl->dev);
+ /* This will complete via sl_free_netdev */
}
+static int slip_hangup(struct tty_struct *tty)
+{
+ slip_close(tty);
+ return 0;
+}
/************************************************************************
* STANDARD SLIP ENCAPSULATION *
************************************************************************/
@@ -1311,6 +1258,7 @@ static struct tty_ldisc_ops sl_ldisc = {
.name = "slip",
.open = slip_open,
.close = slip_close,
+ .hangup = slip_hangup,
.ioctl = slip_ioctl,
.receive_buf = slip_receive_buf,
.write_wakeup = slip_write_wakeup,
@@ -1384,6 +1332,8 @@ static void __exit slip_exit(void)
}
} while (busy && time_before(jiffies, timeout));
+ /* FIXME: hangup is async so we should wait when doing this second
+ phase */
for (i = 0; i < slip_maxdev; i++) {
dev = slip_devs[i];
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index 8d36d40649ef..c791ef76c1d6 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -370,7 +370,7 @@ static int __init ultramca_probe(struct device *gen_dev)
outb(reg4, ioaddr + 4);
- gen_dev->driver_data = dev;
+ dev_set_drvdata(gen_dev, dev);
/* The 8390 isn't at the base address, so fake the offset
*/
@@ -531,7 +531,7 @@ static int ultramca_close_card(struct net_device *dev)
static int ultramca_remove(struct device *gen_dev)
{
struct mca_device *mca_dev = to_mca_device(gen_dev);
- struct net_device *dev = (struct net_device *)gen_dev->driver_data;
+ struct net_device *dev = dev_get_drvdata(gen_dev);
if (dev) {
/* NB: ultra_close_card() does free_irq */
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 293610334a77..bc4976ac8712 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -1774,6 +1774,20 @@ static int __devinit smc911x_findirq(struct net_device *dev)
return probe_irq_off(cookie);
}
+static const struct net_device_ops smc911x_netdev_ops = {
+ .ndo_open = smc911x_open,
+ .ndo_stop = smc911x_close,
+ .ndo_start_xmit = smc911x_hard_start_xmit,
+ .ndo_tx_timeout = smc911x_timeout,
+ .ndo_set_multicast_list = smc911x_set_multicast_list,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = smc911x_poll_controller,
+#endif
+};
+
/*
* Function: smc911x_probe(unsigned long ioaddr)
*
@@ -1940,16 +1954,9 @@ static int __devinit smc911x_probe(struct net_device *dev)
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
- dev->open = smc911x_open;
- dev->stop = smc911x_close;
- dev->hard_start_xmit = smc911x_hard_start_xmit;
- dev->tx_timeout = smc911x_timeout;
+ dev->netdev_ops = &smc911x_netdev_ops;
dev->watchdog_timeo = msecs_to_jiffies(watchdog);
- dev->set_multicast_list = smc911x_set_multicast_list;
dev->ethtool_ops = &smc911x_ethtool_ops;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = smc911x_poll_controller;
-#endif
INIT_WORK(&lp->phy_configure, smc911x_phy_configure);
lp->mii.phy_id_mask = 0x1f;
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 329f890e2903..f1f773b17fe1 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -45,7 +45,8 @@
defined(CONFIG_MACH_ZYLONITE) ||\
defined(CONFIG_MACH_LITTLETON) ||\
defined(CONFIG_MACH_ZYLONITE2) ||\
- defined(CONFIG_ARCH_VIPER)
+ defined(CONFIG_ARCH_VIPER) ||\
+ defined(CONFIG_MACH_STARGATE2)
#include <asm/mach-types.h>
@@ -73,7 +74,7 @@
/* We actually can't write halfwords properly if not word aligned */
static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
{
- if (machine_is_mainstone() && reg & 2) {
+ if ((machine_is_mainstone() || machine_is_stargate2()) && reg & 2) {
unsigned int v = val << 16;
v |= readl(ioaddr + (reg & ~2)) & 0xffff;
writel(v, ioaddr + (reg & ~2));
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index eb7db032a780..3cff84078a9e 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -47,6 +47,7 @@
#include <linux/bitops.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/swab.h>
#include <linux/phy.h>
#include <linux/smsc911x.h>
#include "smsc911x.h"
@@ -175,6 +176,12 @@ static inline void
smsc911x_tx_writefifo(struct smsc911x_data *pdata, unsigned int *buf,
unsigned int wordcount)
{
+ if (pdata->config.flags & SMSC911X_SWAP_FIFO) {
+ while (wordcount--)
+ smsc911x_reg_write(pdata, TX_DATA_FIFO, swab32(*buf++));
+ return;
+ }
+
if (pdata->config.flags & SMSC911X_USE_32BIT) {
writesl(pdata->ioaddr + TX_DATA_FIFO, buf, wordcount);
return;
@@ -194,6 +201,12 @@ static inline void
smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsigned int *buf,
unsigned int wordcount)
{
+ if (pdata->config.flags & SMSC911X_SWAP_FIFO) {
+ while (wordcount--)
+ *buf++ = swab32(smsc911x_reg_read(pdata, RX_DATA_FIFO));
+ return;
+ }
+
if (pdata->config.flags & SMSC911X_USE_32BIT) {
readsl(pdata->ioaddr + RX_DATA_FIFO, buf, wordcount);
return;
@@ -1963,7 +1976,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
retval = -ENODEV;
goto out_0;
}
- res_size = res->end - res->start;
+ res_size = res->end - res->start + 1;
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!irq_res) {
@@ -2096,12 +2109,58 @@ out_0:
return retval;
}
+#ifdef CONFIG_PM
+/* This implementation assumes the devices remains powered on its VDDVARIO
+ * pins during suspend. */
+
+static int smsc911x_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct net_device *dev = platform_get_drvdata(pdev);
+ struct smsc911x_data *pdata = netdev_priv(dev);
+
+ /* enable wake on LAN, energy detection and the external PME
+ * signal. */
+ smsc911x_reg_write(pdata, PMT_CTRL,
+ PMT_CTRL_PM_MODE_D1_ | PMT_CTRL_WOL_EN_ |
+ PMT_CTRL_ED_EN_ | PMT_CTRL_PME_EN_);
+
+ return 0;
+}
+
+static int smsc911x_resume(struct platform_device *pdev)
+{
+ struct net_device *dev = platform_get_drvdata(pdev);
+ struct smsc911x_data *pdata = netdev_priv(dev);
+ unsigned int to = 100;
+
+ /* Note 3.11 from the datasheet:
+ * "When the LAN9220 is in a power saving state, a write of any
+ * data to the BYTE_TEST register will wake-up the device."
+ */
+ smsc911x_reg_write(pdata, BYTE_TEST, 0);
+
+ /* poll the READY bit in PMT_CTRL. Any other access to the device is
+ * forbidden while this bit isn't set. Try for 100ms and return -EIO
+ * if it failed. */
+ while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to)
+ udelay(1000);
+
+ return (to == 0) ? -EIO : 0;
+}
+
+#else
+#define smsc911x_suspend NULL
+#define smsc911x_resume NULL
+#endif
+
static struct platform_driver smsc911x_driver = {
.probe = smsc911x_drv_probe,
.remove = smsc911x_drv_remove,
.driver = {
.name = SMSC_CHIPNAME,
},
+ .suspend = smsc911x_suspend,
+ .resume = smsc911x_resume,
};
/* Entry point for loading the module */
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index e5beb299cbd0..9bd9dadb8534 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -294,6 +294,16 @@ out:
return ERR_PTR(err);
}
+static const struct net_device_ops lance_netdev_ops = {
+ .ndo_open = lance_open,
+ .ndo_stop = lance_close,
+ .ndo_start_xmit = lance_start_xmit,
+ .ndo_set_multicast_list = set_multicast_list,
+ .ndo_set_mac_address = NULL,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
static int __init lance_probe( struct net_device *dev)
{
unsigned long ioaddr;
@@ -397,12 +407,7 @@ static int __init lance_probe( struct net_device *dev)
if (did_version++ == 0)
printk( version );
- /* The LANCE-specific entries in the device structure. */
- dev->open = &lance_open;
- dev->hard_start_xmit = &lance_start_xmit;
- dev->stop = &lance_close;
- dev->set_multicast_list = &set_multicast_list;
- dev->set_mac_address = NULL;
+ dev->netdev_ops = &lance_netdev_ops;
// KLUDGE -- REMOVE ME
set_bit(__LINK_STATE_PRESENT, &dev->state);
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index 0ce2db6ce2bf..d737f6b8f876 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -688,14 +688,11 @@ static void tc_handle_link_change(struct net_device *dev)
if (status_change && netif_msg_link(lp)) {
phy_print_status(phydev);
-#ifdef DEBUG
- printk(KERN_DEBUG
- "%s: MII BMCR %04x BMSR %04x LPA %04x\n",
- dev->name,
- phy_read(phydev, MII_BMCR),
- phy_read(phydev, MII_BMSR),
- phy_read(phydev, MII_LPA));
-#endif
+ pr_debug("%s: MII BMCR %04x BMSR %04x LPA %04x\n",
+ dev->name,
+ phy_read(phydev, MII_BMCR),
+ phy_read(phydev, MII_BMSR),
+ phy_read(phydev, MII_LPA));
}
}
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 201be425643a..eb65e25989f3 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
#define DRV_MODULE_NAME "tg3"
#define PFX DRV_MODULE_NAME ": "
-#define DRV_MODULE_VERSION "3.98"
-#define DRV_MODULE_RELDATE "February 25, 2009"
+#define DRV_MODULE_VERSION "3.99"
+#define DRV_MODULE_RELDATE "April 20, 2009"
#define TG3_DEF_MAC_MODE 0
#define TG3_DEF_RX_MODE 0
@@ -1950,7 +1950,8 @@ static void tg3_frob_aux_power(struct tg3 *tp)
GRC_LCLCTRL_GPIO_OUTPUT0 |
GRC_LCLCTRL_GPIO_OUTPUT1),
100);
- } else if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761) {
+ } else if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761 ||
+ tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761S) {
/* The 5761 non-e device swaps GPIO 0 and GPIO 2. */
u32 grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 |
GRC_LCLCTRL_GPIO_OE1 |
@@ -2455,8 +2456,6 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
}
}
- __tg3_set_mac_addr(tp, 0);
-
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
u32 val;
@@ -4656,6 +4655,7 @@ static int tg3_poll(struct napi_struct *napi, int budget)
* so we must read it before checking for more work.
*/
tp->last_tag = sblk->status_tag;
+ tp->last_irq_tag = tp->last_tag;
rmb();
} else
sblk->status &= ~SD_STATUS_UPDATED;
@@ -4811,7 +4811,7 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id)
* Reading the PCI State register will confirm whether the
* interrupt is ours and will flush the status block.
*/
- if (unlikely(sblk->status_tag == tp->last_tag)) {
+ if (unlikely(sblk->status_tag == tp->last_irq_tag)) {
if ((tp->tg3_flags & TG3_FLAG_CHIP_RESETTING) ||
(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
handled = 0;
@@ -4831,18 +4831,22 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id)
* excessive spurious interrupts can be worse in some cases.
*/
tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
+
+ /*
+ * In a shared interrupt configuration, sometimes other devices'
+ * interrupts will scream. We record the current status tag here
+ * so that the above check can report that the screaming interrupts
+ * are unhandled. Eventually they will be silenced.
+ */
+ tp->last_irq_tag = sblk->status_tag;
+
if (tg3_irq_sync(tp))
goto out;
- if (napi_schedule_prep(&tp->napi)) {
- prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
- /* Update last_tag to mark that this status has been
- * seen. Because interrupt may be shared, we may be
- * racing with tg3_poll(), so only update last_tag
- * if tg3_poll() is not scheduled.
- */
- tp->last_tag = sblk->status_tag;
- __napi_schedule(&tp->napi);
- }
+
+ prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
+
+ napi_schedule(&tp->napi);
+
out:
return IRQ_RETVAL(handled);
}
@@ -6156,6 +6160,7 @@ static int tg3_chip_reset(struct tg3 *tp)
tp->hw_status->status_tag = 0;
}
tp->last_tag = 0;
+ tp->last_irq_tag = 0;
smp_mb();
synchronize_irq(tp->pdev->irq);
@@ -6350,6 +6355,8 @@ static int tg3_halt(struct tg3 *tp, int kind, int silent)
tg3_abort_hw(tp, silent);
err = tg3_chip_reset(tp);
+ __tg3_set_mac_addr(tp, 0);
+
tg3_write_sig_legacy(tp, kind);
tg3_write_sig_post_reset(tp, kind);
@@ -6711,6 +6718,13 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
tw32(TG3_CPMU_HST_ACC, val);
}
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780) {
+ val = tr32(PCIE_PWR_MGMT_THRESH) & ~PCIE_PWR_MGMT_L1_THRESH_MSK;
+ val |= PCIE_PWR_MGMT_EXT_ASPM_TMR_EN |
+ PCIE_PWR_MGMT_L1_THRESH_4MS;
+ tw32(PCIE_PWR_MGMT_THRESH, val);
+ }
+
/* This works around an issue with Athlon chipsets on
* B3 tigon3 silicon. This bit has no effect on any
* other revision. But do not set this on PCI Express
@@ -7138,7 +7152,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
udelay(100);
tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
- tp->last_tag = 0;
if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
tw32_f(DMAC_MODE, DMAC_MODE_ENABLE);
@@ -8539,6 +8552,9 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
u32 i, offset, len, b_offset, b_count;
__be32 val;
+ if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM)
+ return -EINVAL;
+
if (tp->link_config.phy_is_low_power)
return -EAGAIN;
@@ -8604,7 +8620,8 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
if (tp->link_config.phy_is_low_power)
return -EAGAIN;
- if (eeprom->magic != TG3_EEPROM_MAGIC)
+ if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) ||
+ eeprom->magic != TG3_EEPROM_MAGIC)
return -EINVAL;
offset = eeprom->offset;
@@ -9201,6 +9218,9 @@ static int tg3_test_nvram(struct tg3 *tp)
__be32 *buf;
int i, j, k, err = 0, size;
+ if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM)
+ return 0;
+
if (tg3_nvram_read(tp, 0, &magic) != 0)
return -EIO;
@@ -10183,7 +10203,8 @@ static void __devinit tg3_get_nvram_size(struct tg3 *tp)
{
u32 val;
- if (tg3_nvram_read(tp, 0, &val) != 0)
+ if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) ||
+ tg3_nvram_read(tp, 0, &val) != 0)
return;
/* Selfboot format */
@@ -10565,6 +10586,7 @@ static void __devinit tg3_get_57780_nvram_info(struct tg3 *tp)
}
break;
default:
+ tp->tg3_flags3 |= TG3_FLG3_NO_NVRAM;
return;
}
@@ -11365,7 +11387,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
unsigned int i;
u32 magic;
- if (tg3_nvram_read(tp, 0x0, &magic))
+ if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) ||
+ tg3_nvram_read(tp, 0x0, &magic))
goto out_not_found;
if (magic == TG3_EEPROM_MAGIC) {
@@ -11457,6 +11480,15 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
out_not_found:
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
strcpy(tp->board_part_number, "BCM95906");
+ else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 &&
+ tp->pdev->device == TG3PCI_DEVICE_TIGON3_57780)
+ strcpy(tp->board_part_number, "BCM57780");
+ else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 &&
+ tp->pdev->device == TG3PCI_DEVICE_TIGON3_57760)
+ strcpy(tp->board_part_number, "BCM57760");
+ else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 &&
+ tp->pdev->device == TG3PCI_DEVICE_TIGON3_57790)
+ strcpy(tp->board_part_number, "BCM57790");
else
strcpy(tp->board_part_number, "none");
}
@@ -11667,6 +11699,14 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
{
u32 val;
+ if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) {
+ tp->fw_ver[0] = 's';
+ tp->fw_ver[1] = 'b';
+ tp->fw_ver[2] = '\0';
+
+ return;
+ }
+
if (tg3_nvram_read(tp, 0, &val))
return;
@@ -11952,7 +11992,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2;
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 ||
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780)
+ tp->pci_chip_rev_id == CHIPREV_ID_57780_A0 ||
+ tp->pci_chip_rev_id == CHIPREV_ID_57780_A1)
tp->tg3_flags3 |= TG3_FLG3_CLKREQ_BUG;
}
} else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) {
@@ -12144,7 +12185,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780)
tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL;
- if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761) {
+ if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761 ||
+ tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761S) {
/* Turn off the debug UART. */
tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL;
if (tp->tg3_flags2 & TG3_FLG2_IS_NIC)
@@ -12454,7 +12496,8 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
}
if (!addr_ok) {
/* Next, try NVRAM. */
- if (!tg3_nvram_read_be32(tp, mac_offset + 0, &hi) &&
+ if (!(tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) &&
+ !tg3_nvram_read_be32(tp, mac_offset + 0, &hi) &&
!tg3_nvram_read_be32(tp, mac_offset + 4, &lo)) {
memcpy(&dev->dev_addr[0], ((char *)&hi) + 2, 2);
memcpy(&dev->dev_addr[2], (char *)&lo, sizeof(lo));
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index cb4c62abdd21..b3347c41a1a3 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -95,6 +95,8 @@
#define CHIPREV_ID_5752_A1 0x6001
#define CHIPREV_ID_5714_A2 0x9002
#define CHIPREV_ID_5906_A1 0xc001
+#define CHIPREV_ID_57780_A0 0x57780000
+#define CHIPREV_ID_57780_A1 0x57780001
#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
#define ASIC_REV_5700 0x07
#define ASIC_REV_5701 0x00
@@ -1697,6 +1699,8 @@
#define PCIE_PWR_MGMT_THRESH 0x00007d28
#define PCIE_PWR_MGMT_L1_THRESH_MSK 0x0000ff00
+#define PCIE_PWR_MGMT_L1_THRESH_4MS 0x0000ff00
+#define PCIE_PWR_MGMT_EXT_ASPM_TMR_EN 0x01000000
/* OTP bit definitions */
@@ -2501,6 +2505,7 @@ struct tg3 {
struct tg3_hw_status *hw_status;
dma_addr_t status_mapping;
u32 last_tag;
+ u32 last_irq_tag;
u32 msg_enable;
@@ -2635,6 +2640,7 @@ struct tg3 {
#define TG3_FLG3_CLKREQ_BUG 0x00000800
#define TG3_FLG3_PHY_ENABLE_APD 0x00001000
#define TG3_FLG3_5755_PLUS 0x00002000
+#define TG3_FLG3_NO_NVRAM 0x00004000
struct timer_list timer;
u16 timer_counter;
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 534c0f38483c..0337b9d673f4 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -79,7 +79,7 @@ MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ;
MODULE_DESCRIPTION("3Com 3C359 Velocity XL Token Ring Adapter Driver \n") ;
MODULE_FIRMWARE(FW_NAME);
-/* Module paramters */
+/* Module parameters */
/* Ring Speed 0,4,16
* 0 = Autosense
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 2e70ee8f1459..46a2cc92d979 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -169,7 +169,7 @@ static char *open_min_error[] = {
"Monitor Contention failer for RPL", "FDX Protocol Error"
};
-/* Module paramters */
+/* Module parameters */
/* Ring Speed 0,4,16
* 0 = Autosense
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index d068a9d36883..2d819fc85589 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -132,7 +132,7 @@ static char *open_min_error[] = {"No error", "Function Failure", "Signal Lost",
"Reserved", "Reserved", "No Monitor Detected for RPL",
"Monitor Contention failer for RPL", "FDX Protocol Error"};
-/* Module paramters */
+/* Module parameters */
MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ;
MODULE_DESCRIPTION("Olympic PCI/Cardbus Chipset Driver") ;
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index f9491bd787d1..32256179a205 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -1099,7 +1099,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
struct pci_dev *pdev = NULL;
int i, status=0;
- gendev->driver_data = dev;
+ dev_set_drvdata(gendev, dev);
/* Ensure we're not sleeping */
if (lp->bus == EISA) {
@@ -2094,7 +2094,7 @@ static int __devexit de4x5_eisa_remove (struct device *device)
struct net_device *dev;
u_long iobase;
- dev = device->driver_data;
+ dev = dev_get_drvdata(device);
iobase = dev->base_addr;
unregister_netdev (dev);
@@ -2338,7 +2338,7 @@ static void __devexit de4x5_pci_remove (struct pci_dev *pdev)
struct net_device *dev;
u_long iobase;
- dev = pdev->dev.driver_data;
+ dev = dev_get_drvdata(&pdev->dev);
iobase = dev->base_addr;
unregister_netdev (dev);
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 264e61404f34..842b1a2c40d4 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -1601,8 +1601,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
/* no more hardware accesses behind this line. */
- BUG_ON(np->csr6);
- if (ioread32(ioaddr + IntrEnable)) BUG();
+ BUG_ON(np->csr6 || ioread32(ioaddr + IntrEnable));
/* pci_power_off(pdev, -1); */
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 735bf41c654a..d80b8c60b67c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -540,31 +540,34 @@ static inline struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
/* Get packet from user space buffer */
static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
- struct iovec *iv, size_t count,
+ const struct iovec *iv, size_t count,
int noblock)
{
struct tun_pi pi = { 0, cpu_to_be16(ETH_P_IP) };
struct sk_buff *skb;
size_t len = count, align = 0;
struct virtio_net_hdr gso = { 0 };
+ int offset = 0;
if (!(tun->flags & TUN_NO_PI)) {
if ((len -= sizeof(pi)) > count)
return -EINVAL;
- if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi)))
+ if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
return -EFAULT;
+ offset += sizeof(pi);
}
if (tun->flags & TUN_VNET_HDR) {
if ((len -= sizeof(gso)) > count)
return -EINVAL;
- if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
+ if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
return -EFAULT;
if (gso.hdr_len > len)
return -EINVAL;
+ offset += sizeof(pi);
}
if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
@@ -581,7 +584,7 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
return PTR_ERR(skb);
}
- if (skb_copy_datagram_from_iovec(skb, 0, iv, len)) {
+ if (skb_copy_datagram_from_iovec(skb, 0, iv, offset, len)) {
tun->dev->stats.rx_dropped++;
kfree_skb(skb);
return -EFAULT;
@@ -673,7 +676,7 @@ static ssize_t tun_chr_aio_write(struct kiocb *iocb, const struct iovec *iv,
DBG(KERN_INFO "%s: tun_chr_write %ld\n", tun->dev->name, count);
- result = tun_get_user(tun, (struct iovec *)iv, iov_length(iv, count),
+ result = tun_get_user(tun, iv, iov_length(iv, count),
file->f_flags & O_NONBLOCK);
tun_put(tun);
@@ -683,7 +686,7 @@ static ssize_t tun_chr_aio_write(struct kiocb *iocb, const struct iovec *iv,
/* Put packet to the user space buffer */
static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
struct sk_buff *skb,
- struct iovec *iv, int len)
+ const struct iovec *iv, int len)
{
struct tun_pi pi = { 0, skb->protocol };
ssize_t total = 0;
@@ -697,7 +700,7 @@ static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
pi.flags |= TUN_PKT_STRIP;
}
- if (memcpy_toiovec(iv, (void *) &pi, sizeof(pi)))
+ if (memcpy_toiovecend(iv, (void *) &pi, 0, sizeof(pi)))
return -EFAULT;
total += sizeof(pi);
}
@@ -730,14 +733,15 @@ static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
gso.csum_offset = skb->csum_offset;
} /* else everything is zero */
- if (unlikely(memcpy_toiovec(iv, (void *)&gso, sizeof(gso))))
+ if (unlikely(memcpy_toiovecend(iv, (void *)&gso, total,
+ sizeof(gso))))
return -EFAULT;
total += sizeof(gso);
}
len = min_t(int, skb->len, len);
- skb_copy_datagram_iovec(skb, 0, iv, len);
+ skb_copy_datagram_const_iovec(skb, 0, iv, total, len);
total += len;
tun->dev->stats.tx_packets++;
@@ -792,7 +796,7 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
}
netif_wake_queue(tun->dev);
- ret = tun_put_user(tun, skb, (struct iovec *) iv, len);
+ ret = tun_put_user(tun, skb, iv, len);
kfree_skb(skb);
break;
}
@@ -861,6 +865,52 @@ static struct proto tun_proto = {
.obj_size = sizeof(struct tun_sock),
};
+static int tun_flags(struct tun_struct *tun)
+{
+ int flags = 0;
+
+ if (tun->flags & TUN_TUN_DEV)
+ flags |= IFF_TUN;
+ else
+ flags |= IFF_TAP;
+
+ if (tun->flags & TUN_NO_PI)
+ flags |= IFF_NO_PI;
+
+ if (tun->flags & TUN_ONE_QUEUE)
+ flags |= IFF_ONE_QUEUE;
+
+ if (tun->flags & TUN_VNET_HDR)
+ flags |= IFF_VNET_HDR;
+
+ return flags;
+}
+
+static ssize_t tun_show_flags(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct tun_struct *tun = netdev_priv(to_net_dev(dev));
+ return sprintf(buf, "0x%x\n", tun_flags(tun));
+}
+
+static ssize_t tun_show_owner(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct tun_struct *tun = netdev_priv(to_net_dev(dev));
+ return sprintf(buf, "%d\n", tun->owner);
+}
+
+static ssize_t tun_show_group(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct tun_struct *tun = netdev_priv(to_net_dev(dev));
+ return sprintf(buf, "%d\n", tun->group);
+}
+
+static DEVICE_ATTR(tun_flags, 0444, tun_show_flags, NULL);
+static DEVICE_ATTR(owner, 0444, tun_show_owner, NULL);
+static DEVICE_ATTR(group, 0444, tun_show_group, NULL);
+
static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
{
struct sock *sk;
@@ -870,6 +920,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
dev = __dev_get_by_name(net, ifr->ifr_name);
if (dev) {
+ if (ifr->ifr_flags & IFF_TUN_EXCL)
+ return -EBUSY;
if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops)
tun = netdev_priv(dev);
else if ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops)
@@ -944,6 +996,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
if (err < 0)
goto err_free_sk;
+ if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
+ device_create_file(&tun->dev->dev, &dev_attr_owner) ||
+ device_create_file(&tun->dev->dev, &dev_attr_group))
+ printk(KERN_ERR "Failed to create tun sysfs files\n");
+
sk->sk_destruct = tun_sock_destruct;
err = tun_attach(tun, file);
@@ -996,21 +1053,7 @@ static int tun_get_iff(struct net *net, struct file *file, struct ifreq *ifr)
strcpy(ifr->ifr_name, tun->dev->name);
- ifr->ifr_flags = 0;
-
- if (ifr->ifr_flags & TUN_TUN_DEV)
- ifr->ifr_flags |= IFF_TUN;
- else
- ifr->ifr_flags |= IFF_TAP;
-
- if (tun->flags & TUN_NO_PI)
- ifr->ifr_flags |= IFF_NO_PI;
-
- if (tun->flags & TUN_ONE_QUEUE)
- ifr->ifr_flags |= IFF_ONE_QUEUE;
-
- if (tun->flags & TUN_VNET_HDR)
- ifr->ifr_flags |= IFF_VNET_HDR;
+ ifr->ifr_flags = tun_flags(tun);
tun_put(tun);
return 0;
@@ -1318,6 +1361,7 @@ static const struct file_operations tun_fops = {
static struct miscdevice tun_miscdev = {
.minor = TUN_MINOR,
.name = "tun",
+ .devnode = "net/tun",
.fops = &tun_fops,
};
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 44f8392da117..33d4e4c0e8f2 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -27,6 +27,7 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/workqueue.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <asm/uaccess.h>
@@ -270,7 +271,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
u8 num_entries,
u32 thread_size,
u32 thread_alignment,
- enum qe_risc_allocation risc,
+ unsigned int risc,
int skip_page_for_first_entry)
{
u32 init_enet_offset;
@@ -307,7 +308,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
static int return_init_enet_entries(struct ucc_geth_private *ugeth,
u32 *p_start,
u8 num_entries,
- enum qe_risc_allocation risc,
+ unsigned int risc,
int skip_page_for_first_entry)
{
u32 init_enet_offset;
@@ -342,7 +343,7 @@ static int dump_init_enet_entries(struct ucc_geth_private *ugeth,
u32 __iomem *p_start,
u8 num_entries,
u32 thread_size,
- enum qe_risc_allocation risc,
+ unsigned int risc,
int skip_page_for_first_entry)
{
u32 init_enet_offset;
@@ -1543,12 +1544,14 @@ static int init_phy(struct net_device *dev)
priv->oldspeed = 0;
priv->oldduplex = -1;
- phydev = phy_connect(dev, ug_info->phy_bus_id, &adjust_link, 0,
- priv->phy_interface);
+ if (!ug_info->phy_node)
+ return 0;
- if (IS_ERR(phydev)) {
+ phydev = of_phy_connect(dev, ug_info->phy_node, &adjust_link, 0,
+ priv->phy_interface);
+ if (!phydev) {
printk("%s: Could not attach to PHY\n", dev->name);
- return PTR_ERR(phydev);
+ return -ENODEV;
}
phydev->supported &= (ADVERTISED_10baseT_Half |
@@ -2135,6 +2138,14 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
return -ENOMEM;
}
+ /* read the number of risc engines, update the riscTx and riscRx
+ * if there are 4 riscs in QE
+ */
+ if (qe_get_num_of_risc() == 4) {
+ ug_info->riscTx = QE_RISC_ALLOCATION_FOUR_RISCS;
+ ug_info->riscRx = QE_RISC_ALLOCATION_FOUR_RISCS;
+ }
+
ugeth->ug_regs = ioremap(uf_info->regs, sizeof(*ugeth->ug_regs));
if (!ugeth->ug_regs) {
if (netif_msg_probe(ugeth))
@@ -3217,7 +3228,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
dev->stats.tx_packets++;
/* Free the sk buffer associated with this TxBD */
- dev_kfree_skb_irq(ugeth->
+ dev_kfree_skb(ugeth->
tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]]);
ugeth->tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]] = NULL;
ugeth->skb_dirtytx[txQ] =
@@ -3251,9 +3262,15 @@ static int ucc_geth_poll(struct napi_struct *napi, int budget)
for (i = 0; i < ug_info->numQueuesRx; i++)
howmany += ucc_geth_rx(ugeth, i, budget - howmany);
+ /* Tx event processing */
+ spin_lock(&ugeth->lock);
+ for (i = 0; i < ug_info->numQueuesTx; i++)
+ ucc_geth_tx(ugeth->ndev, i);
+ spin_unlock(&ugeth->lock);
+
if (howmany < budget) {
napi_complete(napi);
- setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS);
+ setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS | UCCE_TX_EVENTS);
}
return howmany;
@@ -3267,8 +3284,6 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
struct ucc_geth_info *ug_info;
register u32 ucce;
register u32 uccm;
- register u32 tx_mask;
- u8 i;
ugeth_vdbg("%s: IN", __func__);
@@ -3282,27 +3297,14 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
out_be32(uccf->p_ucce, ucce);
/* check for receive events that require processing */
- if (ucce & UCCE_RX_EVENTS) {
+ if (ucce & (UCCE_RX_EVENTS | UCCE_TX_EVENTS)) {
if (napi_schedule_prep(&ugeth->napi)) {
- uccm &= ~UCCE_RX_EVENTS;
+ uccm &= ~(UCCE_RX_EVENTS | UCCE_TX_EVENTS);
out_be32(uccf->p_uccm, uccm);
__napi_schedule(&ugeth->napi);
}
}
- /* Tx event processing */
- if (ucce & UCCE_TX_EVENTS) {
- spin_lock(&ugeth->lock);
- tx_mask = UCC_GETH_UCCE_TXB0;
- for (i = 0; i < ug_info->numQueuesTx; i++) {
- if (ucce & tx_mask)
- ucc_geth_tx(dev, i);
- ucce &= ~tx_mask;
- tx_mask <<= 1;
- }
- spin_unlock(&ugeth->lock);
- }
-
/* Errors and other events */
if (ucce & UCCE_OTHER) {
if (ucce & UCC_GETH_UCCE_BSY)
@@ -3520,14 +3522,12 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
{
struct device *device = &ofdev->dev;
struct device_node *np = ofdev->node;
- struct device_node *mdio;
struct net_device *dev = NULL;
struct ucc_geth_private *ugeth = NULL;
struct ucc_geth_info *ug_info;
struct resource res;
struct device_node *phy;
int err, ucc_num, max_speed = 0;
- const phandle *ph;
const u32 *fixed_link;
const unsigned int *prop;
const char *sprop;
@@ -3627,40 +3627,13 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
fixed_link = of_get_property(np, "fixed-link", NULL);
if (fixed_link) {
- snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
- PHY_ID_FMT, "0", fixed_link[0]);
phy = NULL;
} else {
- char bus_name[MII_BUS_ID_SIZE];
-
- ph = of_get_property(np, "phy-handle", NULL);
- phy = of_find_node_by_phandle(*ph);
-
+ phy = of_parse_phandle(np, "phy-handle", 0);
if (phy == NULL)
return -ENODEV;
-
- /* set the PHY address */
- prop = of_get_property(phy, "reg", NULL);
- if (prop == NULL)
- return -1;
-
- /* Set the bus id */
- mdio = of_get_parent(phy);
-
- if (mdio == NULL)
- return -ENODEV;
-
- err = of_address_to_resource(mdio, 0, &res);
-
- if (err) {
- of_node_put(mdio);
- return err;
- }
- fsl_pq_mdio_bus_name(bus_name, mdio);
- of_node_put(mdio);
- snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
- "%s:%02x", bus_name, *prop);
}
+ ug_info->phy_node = phy;
/* get the phy interface type, or default to MII */
prop = of_get_property(np, "phy-connection-type", NULL);
@@ -3702,7 +3675,15 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
ug_info->uf_info.utfet = UCC_GETH_UTFET_GIGA_INIT;
ug_info->uf_info.utftt = UCC_GETH_UTFTT_GIGA_INIT;
ug_info->numThreadsTx = UCC_GETH_NUM_OF_THREADS_4;
- ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_4;
+
+ /* If QE's snum number is 46 which means we need to support
+ * 4 UECs at 1000Base-T simultaneously, we need to allocate
+ * more Threads to Rx.
+ */
+ if (qe_get_num_of_snums() == 46)
+ ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_6;
+ else
+ ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_4;
}
if (netif_msg_probe(&debug))
@@ -3735,7 +3716,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
dev->netdev_ops = &ucc_geth_netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
INIT_WORK(&ugeth->timeout_work, ucc_geth_timeout_work);
- netif_napi_add(dev, &ugeth->napi, ucc_geth_poll, UCC_GETH_DEV_WEIGHT);
+ netif_napi_add(dev, &ugeth->napi, ucc_geth_poll, 64);
dev->mtu = 1500;
ugeth->msg_enable = netif_msg_init(debug.msg_enable, UGETH_MSG_DEFAULT);
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index 2f8ee7c87efe..816027656c06 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -852,7 +852,6 @@ struct ucc_geth_hardware_statistics {
/* Driver definitions */
#define TX_BD_RING_LEN 0x10
#define RX_BD_RING_LEN 0x10
-#define UCC_GETH_DEV_WEIGHT TX_BD_RING_LEN
#define TX_RING_MOD_MASK(size) (size-1)
#define RX_RING_MOD_MASK(size) (size-1)
@@ -1100,7 +1099,7 @@ struct ucc_geth_info {
u32 eventRegMask;
u16 pausePeriod;
u16 extensionField;
- char phy_bus_id[BUS_ID_SIZE];
+ struct device_node *phy_node;
u8 weightfactor[NUM_TX_QUEUES];
u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES];
u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX];
@@ -1120,8 +1119,8 @@ struct ucc_geth_info {
enum ucc_geth_maccfg2_pad_and_crc_mode padAndCrc;
enum ucc_geth_num_of_threads numThreadsTx;
enum ucc_geth_num_of_threads numThreadsRx;
- enum qe_risc_allocation riscTx;
- enum qe_risc_allocation riscRx;
+ unsigned int riscTx;
+ unsigned int riscRx;
};
/* structure representing UCC GETH */
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
index 6fcb500257bc..61fe80dda3e3 100644
--- a/drivers/net/ucc_geth_ethtool.c
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -7,7 +7,7 @@
*
* Limitation:
* Can only get/set setttings of the first queue.
- * Need to re-open the interface manually after changing some paramters.
+ * Need to re-open the interface manually after changing some parameters.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index dfc6cf765fbd..3717569828bf 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -359,4 +359,12 @@ config USB_HSO
To compile this driver as a module, choose M here: the
module will be called hso.
+config USB_NET_INT51X1
+ tristate "Intellon PLC based usb adapter"
+ depends on USB_USBNET
+ help
+ Choose this option if you're using a 14Mb USB-based PLC
+ (Powerline Communications) solution with an Intellon
+ INT51x1/INT5200 chip, like the "devolo dLan duo".
+
endmenu
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index c8aef62cf2b7..b870b0b1cbe0 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -20,4 +20,5 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
obj-$(CONFIG_USB_USBNET) += usbnet.o
+obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 55e8ecc3a9e5..01fd528306ec 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -25,7 +25,6 @@
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ctype.h>
#include <linux/ethtool.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
@@ -389,36 +388,6 @@ static void cdc_status(struct usbnet *dev, struct urb *urb)
}
}
-static u8 nibble(unsigned char c)
-{
- if (likely(isdigit(c)))
- return c - '0';
- c = toupper(c);
- if (likely(isxdigit(c)))
- return 10 + c - 'A';
- return 0;
-}
-
-static inline int
-get_ethernet_addr(struct usbnet *dev, struct usb_cdc_ether_desc *e)
-{
- int tmp, i;
- unsigned char buf [13];
-
- tmp = usb_string(dev->udev, e->iMACAddress, buf, sizeof buf);
- if (tmp != 12) {
- dev_dbg(&dev->udev->dev,
- "bad MAC string %d fetch, %d\n", e->iMACAddress, tmp);
- if (tmp >= 0)
- tmp = -EINVAL;
- return tmp;
- }
- for (i = tmp = 0; i < 6; i++, tmp += 2)
- dev->net->dev_addr [i] =
- (nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
- return 0;
-}
-
static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
{
int status;
@@ -428,7 +397,7 @@ static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
if (status < 0)
return status;
- status = get_ethernet_addr(dev, info->ether);
+ status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
if (status < 0) {
usb_set_intfdata(info->data, NULL);
usb_driver_release_interface(driver_of(intf), info->data);
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 6fc4f82b0beb..7ae82446b93a 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -497,10 +497,10 @@ static int dm9601_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
int len;
/* format:
- b0: rx status
- b1: packet length (incl crc) low
- b2: packet length (incl crc) high
- b3..n-4: packet data
+ b1: rx status
+ b2: packet length (incl crc) low
+ b3: packet length (incl crc) high
+ b4..n-4: packet data
bn-3..bn: ethernet crc
*/
@@ -533,8 +533,8 @@ static struct sk_buff *dm9601_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
int len;
/* format:
- b0: packet length low
- b1: packet length high
+ b1: packet length low
+ b2: packet length high
b3..n: packet data
*/
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index f84b78d94c40..837135f0390a 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -482,7 +482,7 @@ static ssize_t hso_sysfs_show_porttype(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct hso_device *hso_dev = dev->driver_data;
+ struct hso_device *hso_dev = dev_get_drvdata(dev);
char *port_name;
if (!hso_dev)
@@ -2313,7 +2313,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
serial->parent->dev = tty_register_device(tty_drv, minor,
&serial->parent->interface->dev);
dev = serial->parent->dev;
- dev->driver_data = serial->parent;
+ dev_set_drvdata(dev, serial->parent);
i = device_create_file(dev, &dev_attr_hsotype);
/* fill in specific data for later use */
@@ -2484,7 +2484,7 @@ static int add_net_device(struct hso_device *hso_dev)
static int hso_radio_toggle(void *data, enum rfkill_state state)
{
struct hso_device *hso_dev = data;
- int enabled = (state == RFKILL_STATE_ON);
+ int enabled = (state == RFKILL_STATE_UNBLOCKED);
int rv;
mutex_lock(&hso_dev->mutex);
@@ -2522,7 +2522,7 @@ static void hso_create_rfkill(struct hso_device *hso_dev,
snprintf(rfkn, 20, "hso-%d",
interface->altsetting->desc.bInterfaceNumber);
hso_net->rfkill->name = rfkn;
- hso_net->rfkill->state = RFKILL_STATE_ON;
+ hso_net->rfkill->state = RFKILL_STATE_UNBLOCKED;
hso_net->rfkill->data = hso_dev;
hso_net->rfkill->toggle_radio = hso_radio_toggle;
if (rfkill_register(hso_net->rfkill) < 0) {
diff --git a/drivers/net/usb/int51x1.c b/drivers/net/usb/int51x1.c
new file mode 100644
index 000000000000..55cf7081de10
--- /dev/null
+++ b/drivers/net/usb/int51x1.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2009 Peter Holik
+ *
+ * Intellon usb PLC (Powerline Communications) usb net driver
+ *
+ * http://www.tandel.be/downloads/INT51X1_Datasheet.pdf
+ *
+ * Based on the work of Jan 'RedBully' Seiffert
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or.
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#include <linux/usb.h>
+#include <linux/usb/usbnet.h>
+
+#define INT51X1_VENDOR_ID 0x09e1
+#define INT51X1_PRODUCT_ID 0x5121
+
+#define INT51X1_HEADER_SIZE 2 /* 2 byte header */
+
+#define PACKET_TYPE_PROMISCUOUS (1 << 0)
+#define PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
+#define PACKET_TYPE_DIRECTED (1 << 2)
+#define PACKET_TYPE_BROADCAST (1 << 3)
+#define PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
+
+#define SET_ETHERNET_PACKET_FILTER 0x43
+
+static int int51x1_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
+{
+ int len;
+
+ if (!(pskb_may_pull(skb, INT51X1_HEADER_SIZE))) {
+ deverr(dev, "unexpected tiny rx frame");
+ return 0;
+ }
+
+ len = le16_to_cpu(*(__le16 *)&skb->data[skb->len - 2]);
+
+ skb_trim(skb, len);
+
+ return 1;
+}
+
+static struct sk_buff *int51x1_tx_fixup(struct usbnet *dev,
+ struct sk_buff *skb, gfp_t flags)
+{
+ int pack_len = skb->len;
+ int pack_with_header_len = pack_len + INT51X1_HEADER_SIZE;
+ int headroom = skb_headroom(skb);
+ int tailroom = skb_tailroom(skb);
+ int need_tail = 0;
+ __le16 *len;
+
+ /* if packet and our header is smaler than 64 pad to 64 (+ ZLP) */
+ if ((pack_with_header_len) < dev->maxpacket)
+ need_tail = dev->maxpacket - pack_with_header_len + 1;
+ /*
+ * usbnet would send a ZLP if packetlength mod urbsize == 0 for us,
+ * but we need to know ourself, because this would add to the length
+ * we send down to the device...
+ */
+ else if (!(pack_with_header_len % dev->maxpacket))
+ need_tail = 1;
+
+ if (!skb_cloned(skb) &&
+ (headroom + tailroom >= need_tail + INT51X1_HEADER_SIZE)) {
+ if (headroom < INT51X1_HEADER_SIZE || tailroom < need_tail) {
+ skb->data = memmove(skb->head + INT51X1_HEADER_SIZE,
+ skb->data, skb->len);
+ skb_set_tail_pointer(skb, skb->len);
+ }
+ } else {
+ struct sk_buff *skb2;
+
+ skb2 = skb_copy_expand(skb,
+ INT51X1_HEADER_SIZE,
+ need_tail,
+ flags);
+ dev_kfree_skb_any(skb);
+ if (!skb2)
+ return NULL;
+ skb = skb2;
+ }
+
+ pack_len += need_tail;
+ pack_len &= 0x07ff;
+
+ len = (__le16 *) __skb_push(skb, INT51X1_HEADER_SIZE);
+ *len = cpu_to_le16(pack_len);
+
+ if(need_tail)
+ memset(__skb_put(skb, need_tail), 0, need_tail);
+
+ return skb;
+}
+
+static void int51x1_async_cmd_callback(struct urb *urb)
+{
+ struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
+ int status = urb->status;
+
+ if (status < 0)
+ dev_warn(&urb->dev->dev, "async callback failed with %d\n", status);
+
+ kfree(req);
+ usb_free_urb(urb);
+}
+
+static void int51x1_set_multicast(struct net_device *netdev)
+{
+ struct usb_ctrlrequest *req;
+ int status;
+ struct urb *urb;
+ struct usbnet *dev = netdev_priv(netdev);
+ u16 filter = PACKET_TYPE_DIRECTED | PACKET_TYPE_BROADCAST;
+
+ if (netdev->flags & IFF_PROMISC) {
+ /* do not expect to see traffic of other PLCs */
+ filter |= PACKET_TYPE_PROMISCUOUS;
+ devinfo(dev, "promiscuous mode enabled");
+ } else if (netdev->mc_count ||
+ (netdev->flags & IFF_ALLMULTI)) {
+ filter |= PACKET_TYPE_ALL_MULTICAST;
+ devdbg(dev, "receive all multicast enabled");
+ } else {
+ /* ~PROMISCUOUS, ~MULTICAST */
+ devdbg(dev, "receive own packets only");
+ }
+
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
+ if (!urb) {
+ devwarn(dev, "Error allocating URB");
+ return;
+ }
+
+ req = kmalloc(sizeof(*req), GFP_ATOMIC);
+ if (!req) {
+ devwarn(dev, "Error allocating control msg");
+ goto out;
+ }
+
+ req->bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
+ req->bRequest = SET_ETHERNET_PACKET_FILTER;
+ req->wValue = cpu_to_le16(filter);
+ req->wIndex = 0;
+ req->wLength = 0;
+
+ usb_fill_control_urb(urb, dev->udev, usb_sndctrlpipe(dev->udev, 0),
+ (void *)req, NULL, 0,
+ int51x1_async_cmd_callback,
+ (void *)req);
+
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status < 0) {
+ devwarn(dev, "Error submitting control msg, sts=%d", status);
+ goto out1;
+ }
+ return;
+out1:
+ kfree(req);
+out:
+ usb_free_urb(urb);
+}
+
+static const struct net_device_ops int51x1_netdev_ops = {
+ .ndo_open = usbnet_open,
+ .ndo_stop = usbnet_stop,
+ .ndo_start_xmit = usbnet_start_xmit,
+ .ndo_tx_timeout = usbnet_tx_timeout,
+ .ndo_change_mtu = usbnet_change_mtu,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_multicast_list = int51x1_set_multicast,
+};
+
+static int int51x1_bind(struct usbnet *dev, struct usb_interface *intf)
+{
+ int status = usbnet_get_ethernet_addr(dev, 3);
+
+ if (status)
+ return status;
+
+ dev->net->hard_header_len += INT51X1_HEADER_SIZE;
+ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
+ dev->net->netdev_ops = &int51x1_netdev_ops;
+
+ return usbnet_get_endpoints(dev, intf);
+}
+
+static const struct driver_info int51x1_info = {
+ .description = "Intellon usb powerline adapter",
+ .bind = int51x1_bind,
+ .rx_fixup = int51x1_rx_fixup,
+ .tx_fixup = int51x1_tx_fixup,
+ .in = 1,
+ .out = 2,
+ .flags = FLAG_ETHER,
+};
+
+static const struct usb_device_id products[] = {
+ {
+ USB_DEVICE(INT51X1_VENDOR_ID, INT51X1_PRODUCT_ID),
+ .driver_info = (unsigned long) &int51x1_info,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(usb, products);
+
+static struct usb_driver int51x1_driver = {
+ .name = "int51x1",
+ .id_table = products,
+ .probe = usbnet_probe,
+ .disconnect = usbnet_disconnect,
+ .suspend = usbnet_suspend,
+ .resume = usbnet_resume,
+};
+
+static int __init int51x1_init(void)
+{
+ return usb_register(&int51x1_driver);
+}
+module_init(int51x1_init);
+
+static void __exit int51x1_exit(void)
+{
+ usb_deregister(&int51x1_driver);
+}
+module_exit(int51x1_exit);
+
+MODULE_AUTHOR("Peter Holik");
+MODULE_DESCRIPTION("Intellon usb powerline adapter");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 3d0d0b0b37c5..e01314789718 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -31,7 +31,6 @@
****************************************************************/
/* TODO:
- * Fix in_interrupt() problem
* Develop test procedures for USB net interfaces
* Run test procedures
* Fix bugs from previous two steps
@@ -606,14 +605,30 @@ static void kaweth_usb_receive(struct urb *urb)
struct sk_buff *skb;
- if(unlikely(status == -ECONNRESET || status == -ESHUTDOWN))
- /* we are killed - set a flag and wake the disconnect handler */
- {
+ if (unlikely(status == -EPIPE)) {
+ kaweth->stats.rx_errors++;
kaweth->end = 1;
wake_up(&kaweth->term_wait);
+ dbg("Status was -EPIPE.");
return;
}
-
+ if (unlikely(status == -ECONNRESET || status == -ESHUTDOWN)) {
+ /* we are killed - set a flag and wake the disconnect handler */
+ kaweth->end = 1;
+ wake_up(&kaweth->term_wait);
+ dbg("Status was -ECONNRESET or -ESHUTDOWN.");
+ return;
+ }
+ if (unlikely(status == -EPROTO || status == -ETIME ||
+ status == -EILSEQ)) {
+ kaweth->stats.rx_errors++;
+ dbg("Status was -EPROTO, -ETIME, or -EILSEQ.");
+ return;
+ }
+ if (unlikely(status == -EOVERFLOW)) {
+ kaweth->stats.rx_errors++;
+ dbg("Status was -EOVERFLOW.");
+ }
spin_lock(&kaweth->device_lock);
if (IS_BLOCKED(kaweth->status)) {
spin_unlock(&kaweth->device_lock);
@@ -883,13 +898,16 @@ static void kaweth_set_rx_mode(struct net_device *net)
****************************************************************/
static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
{
+ int result;
__u16 packet_filter_bitmap = kaweth->packet_filter_bitmap;
+
kaweth->packet_filter_bitmap = 0;
if (packet_filter_bitmap == 0)
return;
- {
- int result;
+ if (in_interrupt())
+ return;
+
result = kaweth_control(kaweth,
usb_sndctrlpipe(kaweth->dev, 0),
KAWETH_COMMAND_SET_PACKET_FILTER,
@@ -906,7 +924,6 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
else {
dbg("Set Rx mode to %d", packet_filter_bitmap);
}
- }
}
/****************************************************************
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 5a7283372b53..89a91f8c22de 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1134,7 +1134,7 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
if (skb->len == size) {
if (pdata->use_rx_csum)
smsc95xx_rx_csum_offload(skb);
-
+ skb_trim(skb, skb->len - 4); /* remove fcs */
skb->truesize = size + sizeof(struct sk_buff);
return 1;
@@ -1152,7 +1152,7 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
if (pdata->use_rx_csum)
smsc95xx_rx_csum_offload(ax_skb);
-
+ skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */
ax_skb->truesize = size + sizeof(struct sk_buff);
usbnet_skb_return(dev, ax_skb);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index f3a2fce6166c..c94de6243140 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -37,6 +37,7 @@
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/ctype.h>
#include <linux/ethtool.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
@@ -156,6 +157,36 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
}
EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
+static u8 nibble(unsigned char c)
+{
+ if (likely(isdigit(c)))
+ return c - '0';
+ c = toupper(c);
+ if (likely(isxdigit(c)))
+ return 10 + c - 'A';
+ return 0;
+}
+
+int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
+{
+ int tmp, i;
+ unsigned char buf [13];
+
+ tmp = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
+ if (tmp != 12) {
+ dev_dbg(&dev->udev->dev,
+ "bad MAC string %d fetch, %d\n", iMACAddress, tmp);
+ if (tmp >= 0)
+ tmp = -EINVAL;
+ return tmp;
+ }
+ for (i = tmp = 0; i < 6; i++, tmp += 2)
+ dev->net->dev_addr [i] =
+ (nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
+
static void intr_complete (struct urb *urb);
static int init_status (struct usbnet *dev, struct usb_interface *intf)
@@ -1185,12 +1216,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
#endif
net->netdev_ops = &usbnet_netdev_ops;
-#ifdef CONFIG_COMPAT_NET_DEV_OPS
- net->hard_start_xmit = usbnet_start_xmit;
- net->open = usbnet_open;
- net->stop = usbnet_stop;
- net->tx_timeout = usbnet_tx_timeout;
-#endif
net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
net->ethtool_ops = &usbnet_ethtool_ops;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4d1d47953fc6..a4a4b91e0465 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -622,12 +622,9 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
unsigned int tmp;
int i;
- if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
- BUG(); /* Caller should know better */
- return false;
- }
-
- BUG_ON(out + in > VIRTNET_SEND_COMMAND_SG_MAX);
+ /* Caller should know better */
+ BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) ||
+ (out + in > VIRTNET_SEND_COMMAND_SG_MAX));
out++; /* Add header */
in++; /* Add return status */
@@ -642,8 +639,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
sg_set_buf(&sg[i + 1], sg_virt(s), s->length);
sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
- if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0)
- BUG();
+ BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi));
vi->cvq->vq_ops->kick(vi->cvq);
@@ -845,6 +841,10 @@ static int virtnet_probe(struct virtio_device *vdev)
int err;
struct net_device *dev;
struct virtnet_info *vi;
+ struct virtqueue *vqs[3];
+ vq_callback_t *callbacks[] = { skb_recv_done, skb_xmit_done, NULL};
+ const char *names[] = { "input", "output", "control" };
+ int nvqs;
/* Allocate ourselves a network device with room for our info */
dev = alloc_etherdev(sizeof(struct virtnet_info));
@@ -905,25 +905,19 @@ static int virtnet_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
vi->mergeable_rx_bufs = true;
- /* We expect two virtqueues, receive then send. */
- vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
- if (IS_ERR(vi->rvq)) {
- err = PTR_ERR(vi->rvq);
+ /* We expect two virtqueues, receive then send,
+ * and optionally control. */
+ nvqs = virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) ? 3 : 2;
+
+ err = vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names);
+ if (err)
goto free;
- }
- vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done);
- if (IS_ERR(vi->svq)) {
- err = PTR_ERR(vi->svq);
- goto free_recv;
- }
+ vi->rvq = vqs[0];
+ vi->svq = vqs[1];
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
- vi->cvq = vdev->config->find_vq(vdev, 2, NULL);
- if (IS_ERR(vi->cvq)) {
- err = PTR_ERR(vi->svq);
- goto free_send;
- }
+ vi->cvq = vqs[2];
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VLAN))
dev->features |= NETIF_F_HW_VLAN_FILTER;
@@ -941,7 +935,7 @@ static int virtnet_probe(struct virtio_device *vdev)
err = register_netdev(dev);
if (err) {
pr_debug("virtio_net: registering device failed\n");
- goto free_ctrl;
+ goto free_vqs;
}
/* Last of all, set up some receive buffers. */
@@ -962,13 +956,8 @@ static int virtnet_probe(struct virtio_device *vdev)
unregister:
unregister_netdev(dev);
-free_ctrl:
- if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
- vdev->config->del_vq(vi->cvq);
-free_send:
- vdev->config->del_vq(vi->svq);
-free_recv:
- vdev->config->del_vq(vi->rvq);
+free_vqs:
+ vdev->config->del_vqs(vdev);
free:
free_netdev(dev);
return err;
@@ -994,12 +983,10 @@ static void virtnet_remove(struct virtio_device *vdev)
BUG_ON(vi->num != 0);
- vdev->config->del_vq(vi->svq);
- vdev->config->del_vq(vi->rvq);
- if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
- vdev->config->del_vq(vi->cvq);
unregister_netdev(vi->dev);
+ vdev->config->del_vqs(vi->vdev);
+
while (vi->pages)
__free_pages(get_a_page(vi, GFP_KERNEL), 0);
diff --git a/drivers/net/vxge/vxge-traffic.c b/drivers/net/vxge/vxge-traffic.c
index c2eeac4125f3..370f55cbbad7 100644
--- a/drivers/net/vxge/vxge-traffic.c
+++ b/drivers/net/vxge/vxge-traffic.c
@@ -1923,7 +1923,7 @@ enum vxge_hw_status __vxge_hw_vpath_alarm_process(
if (vpath == NULL) {
alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
alarm_event);
- goto out;
+ goto out2;
}
hldev = vpath->hldev;
@@ -2161,7 +2161,7 @@ enum vxge_hw_status __vxge_hw_vpath_alarm_process(
}
out:
hldev->stats.sw_dev_err_stats.vpath_alarms++;
-
+out2:
if ((alarm_event == VXGE_HW_EVENT_ALARM_CLEARED) ||
(alarm_event == VXGE_HW_EVENT_UNKNOWN))
return VXGE_HW_OK;
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 800530101093..bfa0161a02d3 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -1054,6 +1054,7 @@ static void pvc_setup(struct net_device *dev)
dev->flags = IFF_POINTOPOINT;
dev->hard_header_len = 10;
dev->addr_len = 2;
+ dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
}
static const struct net_device_ops pvc_ops = {
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 765a7f5d6aa4..a6dc317083d3 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -579,7 +579,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
debug_desc(phys, desc);
BUG_ON(phys & 0x1F);
qmgr_put_entry(queue, phys);
- BUG_ON(qmgr_stat_overflow(queue));
+ /* Don't check for queue overflow here, we've allocated sufficient
+ length and queues >= 32 don't support this check anyway. */
}
@@ -789,10 +790,10 @@ static void hss_hdlc_txdone_irq(void *pdev)
free_buffer_irq(port->tx_buff_tab[n_desc]);
port->tx_buff_tab[n_desc] = NULL;
- start = qmgr_stat_empty(port->plat->txreadyq);
+ start = qmgr_stat_below_low_watermark(port->plat->txreadyq);
queue_put_desc(port->plat->txreadyq,
tx_desc_phys(port, n_desc), desc);
- if (start) {
+ if (start) { /* TX-ready queue was empty */
#if DEBUG_TX
printk(KERN_DEBUG "%s: hss_hdlc_txdone_irq xmit"
" ready\n", dev->name);
@@ -867,13 +868,13 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
queue_put_desc(queue_ids[port->id].tx, tx_desc_phys(port, n), desc);
dev->trans_start = jiffies;
- if (qmgr_stat_empty(txreadyq)) {
+ if (qmgr_stat_below_low_watermark(txreadyq)) { /* empty */
#if DEBUG_TX
printk(KERN_DEBUG "%s: hss_hdlc_xmit queue full\n", dev->name);
#endif
netif_stop_queue(dev);
/* we could miss TX ready interrupt */
- if (!qmgr_stat_empty(txreadyq)) {
+ if (!qmgr_stat_below_low_watermark(txreadyq)) {
#if DEBUG_TX
printk(KERN_DEBUG "%s: hss_hdlc_xmit ready again\n",
dev->name);
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index c23fde0c0344..79dabc557bd3 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -225,6 +225,7 @@ static char rcsid[] =
#include <linux/skbuff.h>
#include <linux/if_arp.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/spinlock.h>
#include <linux/if.h>
#include <net/arp.h>
@@ -3246,6 +3247,16 @@ static inline void show_version(void)
rcsvers, rcsdate, __DATE__, __TIME__);
} /* show_version */
+static const struct net_device_ops cpc_netdev_ops = {
+ .ndo_open = cpc_open,
+ .ndo_stop = cpc_close,
+ .ndo_tx_timeout = cpc_tx_timeout,
+ .ndo_set_mac_address = NULL,
+ .ndo_change_mtu = cpc_change_mtu,
+ .ndo_do_ioctl = cpc_ioctl,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
static void cpc_init_card(pc300_t * card)
{
int i, devcount = 0;
@@ -3357,18 +3368,11 @@ static void cpc_init_card(pc300_t * card)
dev->mem_start = card->hw.ramphys;
dev->mem_end = card->hw.ramphys + card->hw.ramsize - 1;
dev->irq = card->hw.irq;
- dev->init = NULL;
dev->tx_queue_len = PC300_TX_QUEUE_LEN;
dev->mtu = PC300_DEF_MTU;
- dev->open = cpc_open;
- dev->stop = cpc_close;
- dev->tx_timeout = cpc_tx_timeout;
+ dev->netdev_ops = &cpc_netdev_ops;
dev->watchdog_timeo = PC300_TX_TIMEOUT;
- dev->set_multicast_list = NULL;
- dev->set_mac_address = NULL;
- dev->change_mtu = cpc_change_mtu;
- dev->do_ioctl = cpc_ioctl;
if (register_hdlc_device(dev) == 0) {
printk("%s: Cyclades-PC300/", dev->name);
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index ca4151a9e222..17851321b7fd 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -505,27 +505,52 @@ int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
#ifdef CONFIG_PM
struct usb_device *usb_dev = i2400mu->usb_dev;
#endif
+ unsigned is_autosuspend = 0;
struct i2400m *i2400m = &i2400mu->i2400m;
+#ifdef CONFIG_PM
+ if (usb_dev->auto_pm > 0)
+ is_autosuspend = 1;
+#endif
+
d_fnstart(3, dev, "(iface %p pm_msg %u)\n", iface, pm_msg.event);
if (i2400m->updown == 0)
goto no_firmware;
- d_printf(1, dev, "fw up, requesting standby\n");
+ if (i2400m->state == I2400M_SS_DATA_PATH_CONNECTED && is_autosuspend) {
+ /* ugh -- the device is connected and this suspend
+ * request is an autosuspend one (not a system standby
+ * / hibernate).
+ *
+ * The only way the device can go to standby is if the
+ * link with the base station is in IDLE mode; that
+ * were the case, we'd be in status
+ * I2400M_SS_CONNECTED_IDLE. But we are not.
+ *
+ * If we *tell* him to go power save now, it'll reset
+ * as a precautionary measure, so if this is an
+ * autosuspend thing, say no and it'll come back
+ * later, when the link is IDLE
+ */
+ result = -EBADF;
+ d_printf(1, dev, "fw up, link up, not-idle, autosuspend: "
+ "not entering powersave\n");
+ goto error_not_now;
+ }
+ d_printf(1, dev, "fw up: entering powersave\n");
atomic_dec(&i2400mu->do_autopm);
result = i2400m_cmd_enter_powersave(i2400m);
atomic_inc(&i2400mu->do_autopm);
-#ifdef CONFIG_PM
- if (result < 0 && usb_dev->auto_pm == 0) {
+ if (result < 0 && !is_autosuspend) {
/* System suspend, can't fail */
dev_err(dev, "failed to suspend, will reset on resume\n");
result = 0;
}
-#endif
if (result < 0)
goto error_enter_powersave;
i2400mu_notification_release(i2400mu);
- d_printf(1, dev, "fw up, got standby\n");
+ d_printf(1, dev, "powersave requested\n");
error_enter_powersave:
+error_not_now:
no_firmware:
d_fnend(3, dev, "(iface %p pm_msg %u) = %d\n",
iface, pm_msg.event, result);
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 8a0823588c51..a67d29290ba0 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -146,10 +146,10 @@ config LIBERTAS_CS
A driver for Marvell Libertas 8385 CompactFlash devices.
config LIBERTAS_SDIO
- tristate "Marvell Libertas 8385 and 8686 SDIO 802.11b/g cards"
+ tristate "Marvell Libertas 8385/8686/8688 SDIO 802.11b/g cards"
depends on LIBERTAS && MMC
---help---
- A driver for Marvell Libertas 8385 and 8686 SDIO devices.
+ A driver for Marvell Libertas 8385/8686/8688 SDIO devices.
config LIBERTAS_SPI
tristate "Marvell Libertas 8686 SPI 802.11b/g cards"
@@ -337,6 +337,7 @@ config USB_NET_RNDIS_WLAN
select USB_NET_CDCETHER
select USB_NET_RNDIS_HOST
select WIRELESS_EXT
+ select CFG80211
---help---
This is a driver for wireless RNDIS devices.
These are USB based adapters found in devices such as:
@@ -433,6 +434,13 @@ config RTL8187
Thanks to Realtek for their support!
+# If possible, automatically enable LEDs for RTL8187.
+
+config RTL8187_LEDS
+ bool
+ depends on RTL8187 && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = RTL8187)
+ default y
+
config ADM8211
tristate "ADMtek ADM8211 support"
depends on MAC80211 && PCI && WLAN_80211 && EXPERIMENTAL
@@ -483,9 +491,7 @@ config MWL8K
will be called mwl8k. If unsure, say N.
source "drivers/net/wireless/p54/Kconfig"
-source "drivers/net/wireless/ath5k/Kconfig"
-source "drivers/net/wireless/ath9k/Kconfig"
-source "drivers/net/wireless/ar9170/Kconfig"
+source "drivers/net/wireless/ath/Kconfig"
source "drivers/net/wireless/ipw2x00/Kconfig"
source "drivers/net/wireless/iwlwifi/Kconfig"
source "drivers/net/wireless/hostap/Kconfig"
@@ -494,5 +500,7 @@ source "drivers/net/wireless/b43legacy/Kconfig"
source "drivers/net/wireless/zd1211rw/Kconfig"
source "drivers/net/wireless/rt2x00/Kconfig"
source "drivers/net/wireless/orinoco/Kconfig"
+source "drivers/net/wireless/wl12xx/Kconfig"
+source "drivers/net/wireless/iwmc3200wifi/Kconfig"
endmenu
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 50e7fba7f0ea..7a4647e78fd3 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -55,8 +55,10 @@ obj-$(CONFIG_RT2X00) += rt2x00/
obj-$(CONFIG_P54_COMMON) += p54/
-obj-$(CONFIG_ATH5K) += ath5k/
-obj-$(CONFIG_ATH9K) += ath9k/
-obj-$(CONFIG_AR9170_USB) += ar9170/
+obj-$(CONFIG_ATH_COMMON) += ath/
obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
+
+obj-$(CONFIG_WL12XX) += wl12xx/
+
+obj-$(CONFIG_IWM) += iwmc3200wifi/
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index f71821795018..2b9e379994a1 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1311,18 +1311,20 @@ static int adm8211_config(struct ieee80211_hw *dev, u32 changed)
return 0;
}
-static int adm8211_config_interface(struct ieee80211_hw *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
+static void adm8211_bss_info_changed(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *conf,
+ u32 changes)
{
struct adm8211_priv *priv = dev->priv;
+ if (!(changes & BSS_CHANGED_BSSID))
+ return;
+
if (memcmp(conf->bssid, priv->bssid, ETH_ALEN)) {
adm8211_set_bssid(dev, conf->bssid);
memcpy(priv->bssid, conf->bssid, ETH_ALEN);
}
-
- return 0;
}
static void adm8211_configure_filter(struct ieee80211_hw *dev,
@@ -1753,7 +1755,7 @@ static const struct ieee80211_ops adm8211_ops = {
.add_interface = adm8211_add_interface,
.remove_interface = adm8211_remove_interface,
.config = adm8211_config,
- .config_interface = adm8211_config_interface,
+ .bss_info_changed = adm8211_bss_info_changed,
.configure_filter = adm8211_configure_filter,
.get_stats = adm8211_get_stats,
.get_tx_stats = adm8211_get_tx_stats,
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index d73475739127..9eabf4d1f2e7 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -6467,6 +6467,7 @@ static int airo_get_encode(struct net_device *dev,
{
struct airo_info *local = dev->ml_priv;
int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
+ int wep_key_len;
u8 buf[16];
if (!local->wep_capable)
@@ -6500,11 +6501,13 @@ static int airo_get_encode(struct net_device *dev,
dwrq->flags |= index + 1;
/* Copy the key to the user buffer */
- dwrq->length = get_wep_key(local, index, &buf[0], sizeof(buf));
- if (dwrq->length != -1)
- memcpy(extra, buf, dwrq->length);
- else
+ wep_key_len = get_wep_key(local, index, &buf[0], sizeof(buf));
+ if (wep_key_len < 0) {
dwrq->length = 0;
+ } else {
+ dwrq->length = wep_key_len;
+ memcpy(extra, buf, dwrq->length);
+ }
return 0;
}
@@ -6617,7 +6620,7 @@ static int airo_get_encodeext(struct net_device *dev,
struct airo_info *local = dev->ml_priv;
struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int idx, max_key_len;
+ int idx, max_key_len, wep_key_len;
u8 buf[16];
if (!local->wep_capable)
@@ -6661,11 +6664,13 @@ static int airo_get_encodeext(struct net_device *dev,
memset(extra, 0, 16);
/* Copy the key to the user buffer */
- ext->key_len = get_wep_key(local, idx, &buf[0], sizeof(buf));
- if (ext->key_len != -1)
- memcpy(extra, buf, ext->key_len);
- else
+ wep_key_len = get_wep_key(local, idx, &buf[0], sizeof(buf));
+ if (wep_key_len < 0) {
ext->key_len = 0;
+ } else {
+ ext->key_len = wep_key_len;
+ memcpy(extra, buf, ext->key_len);
+ }
return 0;
}
diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index 744f4f4dd3d1..cea7f1466c54 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -1965,13 +1965,18 @@ static int at76_config(struct ieee80211_hw *hw, u32 changed)
return 0;
}
-static int at76_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
+static void at76_bss_info_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *conf,
+ u32 changed)
{
struct at76_priv *priv = hw->priv;
at76_dbg(DBG_MAC80211, "%s():", __func__);
+
+ if (!(changed & BSS_CHANGED_BSSID))
+ return;
+
at76_dbg_dump(DBG_MAC80211, conf->bssid, ETH_ALEN, "bssid:");
mutex_lock(&priv->mtx);
@@ -1983,8 +1988,6 @@ static int at76_config_interface(struct ieee80211_hw *hw,
at76_join(priv);
mutex_unlock(&priv->mtx);
-
- return 0;
}
/* must be atomic */
@@ -2076,7 +2079,7 @@ static const struct ieee80211_ops at76_ops = {
.add_interface = at76_add_interface,
.remove_interface = at76_remove_interface,
.config = at76_config,
- .config_interface = at76_config_interface,
+ .bss_info_changed = at76_bss_info_changed,
.configure_filter = at76_configure_filter,
.start = at76_mac80211_start,
.stop = at76_mac80211_stop,
@@ -2250,6 +2253,7 @@ static int at76_init_new_device(struct at76_priv *priv,
/* mac80211 initialisation */
priv->hw->wiphy->max_scan_ssids = 1;
+ priv->hw->wiphy->max_scan_ie_len = 0;
priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &at76_supported_band;
priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
@@ -2311,8 +2315,7 @@ static void at76_delete_device(struct at76_priv *priv)
del_timer_sync(&ledtrig_tx_timer);
- if (priv->rx_skb)
- kfree_skb(priv->rx_skb);
+ kfree_skb(priv->rx_skb);
usb_put_dev(priv->udev);
diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig
new file mode 100644
index 000000000000..d26e7b485315
--- /dev/null
+++ b/drivers/net/wireless/ath/Kconfig
@@ -0,0 +1,8 @@
+config ATH_COMMON
+ tristate "Atheros Wireless Cards"
+ depends on ATH5K || ATH9K || AR9170_USB
+
+source "drivers/net/wireless/ath/ath5k/Kconfig"
+source "drivers/net/wireless/ath/ath9k/Kconfig"
+source "drivers/net/wireless/ath/ar9170/Kconfig"
+
diff --git a/drivers/net/wireless/ath/Makefile b/drivers/net/wireless/ath/Makefile
new file mode 100644
index 000000000000..4bb0132ada37
--- /dev/null
+++ b/drivers/net/wireless/ath/Makefile
@@ -0,0 +1,6 @@
+obj-$(CONFIG_ATH5K) += ath5k/
+obj-$(CONFIG_ATH9K) += ath9k/
+obj-$(CONFIG_AR9170_USB) += ar9170/
+
+obj-$(CONFIG_ATH_COMMON) += ath.o
+ath-objs := main.o regd.o
diff --git a/drivers/net/wireless/ar9170/Kconfig b/drivers/net/wireless/ath/ar9170/Kconfig
index de4281fda129..b99e3263ee6d 100644
--- a/drivers/net/wireless/ar9170/Kconfig
+++ b/drivers/net/wireless/ath/ar9170/Kconfig
@@ -2,6 +2,7 @@ config AR9170_USB
tristate "Atheros AR9170 802.11n USB support"
depends on USB && MAC80211 && WLAN_80211 && EXPERIMENTAL
select FW_LOADER
+ select ATH_COMMON
help
This is a driver for the Atheros "otus" 802.11n USB devices.
diff --git a/drivers/net/wireless/ar9170/Makefile b/drivers/net/wireless/ath/ar9170/Makefile
index 8d91c7ee3215..8d91c7ee3215 100644
--- a/drivers/net/wireless/ar9170/Makefile
+++ b/drivers/net/wireless/ath/ar9170/Makefile
diff --git a/drivers/net/wireless/ar9170/ar9170.h b/drivers/net/wireless/ath/ar9170/ar9170.h
index f4fb2e94aea0..17bd3eaf3e03 100644
--- a/drivers/net/wireless/ar9170/ar9170.h
+++ b/drivers/net/wireless/ath/ar9170/ar9170.h
@@ -40,7 +40,7 @@
#include <linux/completion.h>
#include <linux/spinlock.h>
-#include <net/wireless.h>
+#include <net/cfg80211.h>
#include <net/mac80211.h>
#ifdef CONFIG_AR9170_LEDS
#include <linux/leds.h>
@@ -48,6 +48,8 @@
#include "eeprom.h"
#include "hw.h"
+#include "../regd.h"
+
#define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
enum ar9170_bw {
@@ -58,6 +60,21 @@ enum ar9170_bw {
__AR9170_NUM_BW,
};
+static inline enum ar9170_bw nl80211_to_ar9170(enum nl80211_channel_type type)
+{
+ switch (type) {
+ case NL80211_CHAN_NO_HT:
+ case NL80211_CHAN_HT20:
+ return AR9170_BW_20;
+ case NL80211_CHAN_HT40MINUS:
+ return AR9170_BW_40_BELOW;
+ case NL80211_CHAN_HT40PLUS:
+ return AR9170_BW_40_ABOVE;
+ default:
+ BUG();
+ }
+}
+
enum ar9170_rf_init_mode {
AR9170_RFI_NONE,
AR9170_RFI_WARM,
@@ -87,10 +104,16 @@ enum ar9170_device_state {
AR9170_ASSOCIATED,
};
+struct ar9170_rxstream_mpdu_merge {
+ struct ar9170_rx_head plcp;
+ bool has_plcp;
+};
+
struct ar9170 {
struct ieee80211_hw *hw;
struct mutex mutex;
enum ar9170_device_state state;
+ unsigned long bad_hw_nagger;
int (*open)(struct ar9170 *);
void (*stop)(struct ar9170 *);
@@ -118,6 +141,7 @@ struct ar9170 {
u64 cur_mc_hash, want_mc_hash;
u32 cur_filter, want_filter;
unsigned int filter_changed;
+ unsigned int filter_state;
bool sniffer_enabled;
/* PHY */
@@ -151,11 +175,17 @@ struct ar9170 {
/* EEPROM */
struct ar9170_eeprom eeprom;
+ struct ath_regulatory regulatory;
/* global tx status for unregistered Stations. */
struct sk_buff_head global_tx_status;
struct sk_buff_head global_tx_status_waste;
struct delayed_work tx_status_janitor;
+
+ /* rxstream mpdu merge */
+ struct ar9170_rxstream_mpdu_merge rx_mpdu;
+ struct sk_buff *rx_failover;
+ int rx_failover_missing;
};
struct ar9170_sta_info {
diff --git a/drivers/net/wireless/ar9170/cmd.c b/drivers/net/wireless/ath/ar9170/cmd.c
index f57a6200167b..f57a6200167b 100644
--- a/drivers/net/wireless/ar9170/cmd.c
+++ b/drivers/net/wireless/ath/ar9170/cmd.c
diff --git a/drivers/net/wireless/ar9170/cmd.h b/drivers/net/wireless/ath/ar9170/cmd.h
index a4f0e50e52b4..a4f0e50e52b4 100644
--- a/drivers/net/wireless/ar9170/cmd.h
+++ b/drivers/net/wireless/ath/ar9170/cmd.h
diff --git a/drivers/net/wireless/ar9170/eeprom.h b/drivers/net/wireless/ath/ar9170/eeprom.h
index d2c8cc83f1dd..d2c8cc83f1dd 100644
--- a/drivers/net/wireless/ar9170/eeprom.h
+++ b/drivers/net/wireless/ath/ar9170/eeprom.h
diff --git a/drivers/net/wireless/ar9170/hw.h b/drivers/net/wireless/ath/ar9170/hw.h
index 53e250a4278f..3293e0fb24fb 100644
--- a/drivers/net/wireless/ar9170/hw.h
+++ b/drivers/net/wireless/ath/ar9170/hw.h
@@ -207,6 +207,8 @@ enum ar9170_cmd {
#define AR9170_MAC_REG_AC1_AC0_TXOP (AR9170_MAC_REG_BASE + 0xB44)
#define AR9170_MAC_REG_AC3_AC2_TXOP (AR9170_MAC_REG_BASE + 0xB48)
+#define AR9170_MAC_REG_AMPDU_SET (AR9170_MAC_REG_BASE + 0xba0)
+
#define AR9170_MAC_REG_ACK_TABLE (AR9170_MAC_REG_BASE + 0xC00)
#define AR9170_MAC_REG_AMPDU_RX_THRESH (AR9170_MAC_REG_BASE + 0xC50)
@@ -312,7 +314,7 @@ struct ar9170_rx_head {
u8 plcp[12];
} __packed;
-struct ar9170_rx_tail {
+struct ar9170_rx_phystatus {
union {
struct {
u8 rssi_ant0, rssi_ant1, rssi_ant2,
@@ -324,6 +326,9 @@ struct ar9170_rx_tail {
u8 evm_stream0[6], evm_stream1[6];
u8 phy_err;
+} __packed;
+
+struct ar9170_rx_macstatus {
u8 SAidx, DAidx;
u8 error;
u8 status;
@@ -339,7 +344,7 @@ struct ar9170_rx_tail {
#define AR9170_RX_ENC_SOFTWARE 0x8
-static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_tail *t)
+static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t)
{
return (t->SAidx & 0xc0) >> 4 |
(t->DAidx & 0xc0) >> 6;
@@ -357,10 +362,9 @@ static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_tail *t)
#define AR9170_RX_STATUS_MPDU_MASK 0x30
#define AR9170_RX_STATUS_MPDU_SINGLE 0x00
-#define AR9170_RX_STATUS_MPDU_FIRST 0x10
-#define AR9170_RX_STATUS_MPDU_MIDDLE 0x20
-#define AR9170_RX_STATUS_MPDU_LAST 0x30
-
+#define AR9170_RX_STATUS_MPDU_FIRST 0x20
+#define AR9170_RX_STATUS_MPDU_MIDDLE 0x30
+#define AR9170_RX_STATUS_MPDU_LAST 0x10
#define AR9170_RX_ERROR_RXTO 0x01
#define AR9170_RX_ERROR_OVERRUN 0x02
@@ -369,6 +373,7 @@ static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_tail *t)
#define AR9170_RX_ERROR_WRONG_RA 0x10
#define AR9170_RX_ERROR_PLCP 0x20
#define AR9170_RX_ERROR_MMIC 0x40
+#define AR9170_RX_ERROR_FATAL 0x80
struct ar9170_cmd_tx_status {
__le16 unkn;
diff --git a/drivers/net/wireless/ar9170/led.c b/drivers/net/wireless/ath/ar9170/led.c
index 341cead7f606..341cead7f606 100644
--- a/drivers/net/wireless/ar9170/led.c
+++ b/drivers/net/wireless/ath/ar9170/led.c
diff --git a/drivers/net/wireless/ar9170/mac.c b/drivers/net/wireless/ath/ar9170/mac.c
index c8fa3073169f..43aeb69685d3 100644
--- a/drivers/net/wireless/ar9170/mac.c
+++ b/drivers/net/wireless/ath/ar9170/mac.c
@@ -72,6 +72,24 @@ int ar9170_set_qos(struct ar9170 *ar)
return ar9170_regwrite_result();
}
+static int ar9170_set_ampdu_density(struct ar9170 *ar, u8 mpdudensity)
+{
+ u32 val;
+
+ /* don't allow AMPDU density > 8us */
+ if (mpdudensity > 6)
+ return -EINVAL;
+
+ /* Watch out! Otus uses slightly different density values. */
+ val = 0x140a00 | (mpdudensity ? (mpdudensity + 1) : 0);
+
+ ar9170_regwrite_begin(ar);
+ ar9170_regwrite(AR9170_MAC_REG_AMPDU_SET, val);
+ ar9170_regwrite_finish();
+
+ return ar9170_regwrite_result();
+}
+
int ar9170_init_mac(struct ar9170 *ar)
{
ar9170_regwrite_begin(ar);
@@ -265,9 +283,9 @@ int ar9170_set_operating_mode(struct ar9170 *ar)
case NL80211_IFTYPE_ADHOC:
pm_mode |= AR9170_MAC_REG_POWERMGT_IBSS;
break;
-/* case NL80211_IFTYPE_AP:
+ case NL80211_IFTYPE_AP:
pm_mode |= AR9170_MAC_REG_POWERMGT_AP;
- break;*/
+ break;
case NL80211_IFTYPE_WDS:
pm_mode |= AR9170_MAC_REG_POWERMGT_AP_WDS;
break;
@@ -296,6 +314,11 @@ int ar9170_set_operating_mode(struct ar9170 *ar)
if (err)
return err;
+ /* set AMPDU density to 8us. */
+ err = ar9170_set_ampdu_density(ar, 6);
+ if (err)
+ return err;
+
ar9170_regwrite_begin(ar);
ar9170_regwrite(AR9170_MAC_REG_POWERMANAGEMENT, pm_mode);
@@ -316,9 +339,9 @@ int ar9170_set_beacon_timers(struct ar9170 *ar)
u32 v = 0;
u32 pretbtt = 0;
- v |= ar->hw->conf.beacon_int;
-
if (ar->vif) {
+ v |= ar->vif->bss_conf.beacon_int;
+
switch (ar->vif->type) {
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_ADHOC:
@@ -326,7 +349,7 @@ int ar9170_set_beacon_timers(struct ar9170 *ar)
break;
case NL80211_IFTYPE_AP:
v |= BIT(24);
- pretbtt = (ar->hw->conf.beacon_int - 6) << 16;
+ pretbtt = (ar->vif->bss_conf.beacon_int - 6) << 16;
break;
default:
break;
diff --git a/drivers/net/wireless/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 5996ff9f7f47..99df9ddae9cb 100644
--- a/drivers/net/wireless/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -142,11 +142,36 @@ static struct ieee80211_channel ar9170_5ghz_chantable[] = {
};
#undef CHAN
+#define AR9170_HT_CAP \
+{ \
+ .ht_supported = true, \
+ .cap = IEEE80211_HT_CAP_MAX_AMSDU | \
+ IEEE80211_HT_CAP_SM_PS | \
+ IEEE80211_HT_CAP_SUP_WIDTH_20_40 | \
+ IEEE80211_HT_CAP_SGI_40 | \
+ IEEE80211_HT_CAP_DSSSCCK40 | \
+ IEEE80211_HT_CAP_SM_PS, \
+ .ampdu_factor = 3, \
+ .ampdu_density = 6, \
+ .mcs = { \
+ .rx_mask = { 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, }, \
+ }, \
+}
+
static struct ieee80211_supported_band ar9170_band_2GHz = {
.channels = ar9170_2ghz_chantable,
.n_channels = ARRAY_SIZE(ar9170_2ghz_chantable),
.bitrates = ar9170_g_ratetable,
.n_bitrates = ar9170_g_ratetable_size,
+ .ht_cap = AR9170_HT_CAP,
+};
+
+static struct ieee80211_supported_band ar9170_band_5GHz = {
+ .channels = ar9170_5ghz_chantable,
+ .n_channels = ARRAY_SIZE(ar9170_5ghz_chantable),
+ .bitrates = ar9170_a_ratetable,
+ .n_bitrates = ar9170_a_ratetable_size,
+ .ht_cap = AR9170_HT_CAP,
};
#ifdef AR9170_QUEUE_DEBUG
@@ -190,13 +215,6 @@ static void ar9170_dump_station_tx_status_queue(struct ar9170 *ar,
}
#endif /* AR9170_QUEUE_DEBUG */
-static struct ieee80211_supported_band ar9170_band_5GHz = {
- .channels = ar9170_5ghz_chantable,
- .n_channels = ARRAY_SIZE(ar9170_5ghz_chantable),
- .bitrates = ar9170_a_ratetable,
- .n_bitrates = ar9170_a_ratetable_size,
-};
-
void ar9170_handle_tx_status(struct ar9170 *ar, struct sk_buff *skb,
bool valid_status, u16 tx_status)
{
@@ -436,214 +454,430 @@ static void ar9170_handle_command_response(struct ar9170 *ar,
}
}
-/*
- * If the frame alignment is right (or the kernel has
- * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS), and there
- * is only a single MPDU in the USB frame, then we can
- * submit to mac80211 the SKB directly. However, since
- * there may be multiple packets in one SKB in stream
- * mode, and we need to observe the proper ordering,
- * this is non-trivial.
- */
-static void ar9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
+static void ar9170_rx_reset_rx_mpdu(struct ar9170 *ar)
{
- struct sk_buff *skb;
- struct ar9170_rx_head *head = (void *)buf;
- struct ar9170_rx_tail *tail;
- struct ieee80211_rx_status status;
- int mpdu_len, i;
- u8 error, antennas = 0, decrypt;
- __le16 fc;
- int reserved;
+ memset(&ar->rx_mpdu.plcp, 0, sizeof(struct ar9170_rx_head));
+ ar->rx_mpdu.has_plcp = false;
+}
- if (unlikely(!IS_STARTED(ar)))
- return ;
+static int ar9170_nag_limiter(struct ar9170 *ar)
+{
+ bool print_message;
+
+ /*
+ * we expect all sorts of errors in promiscuous mode.
+ * don't bother with it, it's OK!
+ */
+ if (ar->sniffer_enabled)
+ return false;
+
+ /*
+ * only go for frequent errors! The hardware tends to
+ * do some stupid thing once in a while under load, in
+ * noisy environments or just for fun!
+ */
+ if (time_before(jiffies, ar->bad_hw_nagger) && net_ratelimit())
+ print_message = true;
+ else
+ print_message = false;
+
+ /* reset threshold for "once in a while" */
+ ar->bad_hw_nagger = jiffies + HZ / 4;
+ return print_message;
+}
+
+static int ar9170_rx_mac_status(struct ar9170 *ar,
+ struct ar9170_rx_head *head,
+ struct ar9170_rx_macstatus *mac,
+ struct ieee80211_rx_status *status)
+{
+ u8 error, decrypt;
- /* Received MPDU */
- mpdu_len = len;
- mpdu_len -= sizeof(struct ar9170_rx_head);
- mpdu_len -= sizeof(struct ar9170_rx_tail);
BUILD_BUG_ON(sizeof(struct ar9170_rx_head) != 12);
- BUILD_BUG_ON(sizeof(struct ar9170_rx_tail) != 24);
+ BUILD_BUG_ON(sizeof(struct ar9170_rx_macstatus) != 4);
- if (mpdu_len <= FCS_LEN)
- return;
+ error = mac->error;
+ if (error & AR9170_RX_ERROR_MMIC) {
+ status->flag |= RX_FLAG_MMIC_ERROR;
+ error &= ~AR9170_RX_ERROR_MMIC;
+ }
- tail = (void *)(buf + sizeof(struct ar9170_rx_head) + mpdu_len);
+ if (error & AR9170_RX_ERROR_PLCP) {
+ status->flag |= RX_FLAG_FAILED_PLCP_CRC;
+ error &= ~AR9170_RX_ERROR_PLCP;
- for (i = 0; i < 3; i++)
- if (tail->rssi[i] != 0x80)
- antennas |= BIT(i);
+ if (!(ar->filter_state & FIF_PLCPFAIL))
+ return -EINVAL;
+ }
- /* post-process RSSI */
- for (i = 0; i < 7; i++)
- if (tail->rssi[i] & 0x80)
- tail->rssi[i] = ((tail->rssi[i] & 0x7f) + 1) & 0x7f;
+ if (error & AR9170_RX_ERROR_FCS) {
+ status->flag |= RX_FLAG_FAILED_FCS_CRC;
+ error &= ~AR9170_RX_ERROR_FCS;
- memset(&status, 0, sizeof(status));
+ if (!(ar->filter_state & FIF_FCSFAIL))
+ return -EINVAL;
+ }
+
+ decrypt = ar9170_get_decrypt_type(mac);
+ if (!(decrypt & AR9170_RX_ENC_SOFTWARE) &&
+ decrypt != AR9170_ENC_ALG_NONE)
+ status->flag |= RX_FLAG_DECRYPTED;
+
+ /* ignore wrong RA errors */
+ error &= ~AR9170_RX_ERROR_WRONG_RA;
+
+ if (error & AR9170_RX_ERROR_DECRYPT) {
+ error &= ~AR9170_RX_ERROR_DECRYPT;
+ /*
+ * Rx decryption is done in place,
+ * the original data is lost anyway.
+ */
+
+ return -EINVAL;
+ }
- status.band = ar->channel->band;
- status.freq = ar->channel->center_freq;
- status.signal = ar->noise[0] + tail->rssi_combined;
- status.noise = ar->noise[0];
- status.antenna = antennas;
+ /* drop any other error frames */
+ if (unlikely(error)) {
+ /* TODO: update netdevice's RX dropped/errors statistics */
+
+ if (ar9170_nag_limiter(ar))
+ printk(KERN_DEBUG "%s: received frame with "
+ "suspicious error code (%#x).\n",
+ wiphy_name(ar->hw->wiphy), error);
+
+ return -EINVAL;
+ }
- switch (tail->status & AR9170_RX_STATUS_MODULATION_MASK) {
+ status->band = ar->channel->band;
+ status->freq = ar->channel->center_freq;
+
+ switch (mac->status & AR9170_RX_STATUS_MODULATION_MASK) {
case AR9170_RX_STATUS_MODULATION_CCK:
- if (tail->status & AR9170_RX_STATUS_SHORT_PREAMBLE)
- status.flag |= RX_FLAG_SHORTPRE;
+ if (mac->status & AR9170_RX_STATUS_SHORT_PREAMBLE)
+ status->flag |= RX_FLAG_SHORTPRE;
switch (head->plcp[0]) {
case 0x0a:
- status.rate_idx = 0;
+ status->rate_idx = 0;
break;
case 0x14:
- status.rate_idx = 1;
+ status->rate_idx = 1;
break;
case 0x37:
- status.rate_idx = 2;
+ status->rate_idx = 2;
break;
case 0x6e:
- status.rate_idx = 3;
+ status->rate_idx = 3;
break;
default:
- if ((!ar->sniffer_enabled) && (net_ratelimit()))
+ if (ar9170_nag_limiter(ar))
printk(KERN_ERR "%s: invalid plcp cck rate "
"(%x).\n", wiphy_name(ar->hw->wiphy),
head->plcp[0]);
- return;
+ return -EINVAL;
}
break;
+
case AR9170_RX_STATUS_MODULATION_OFDM:
- switch (head->plcp[0] & 0xF) {
- case 0xB:
- status.rate_idx = 0;
+ switch (head->plcp[0] & 0xf) {
+ case 0xb:
+ status->rate_idx = 0;
break;
- case 0xF:
- status.rate_idx = 1;
+ case 0xf:
+ status->rate_idx = 1;
break;
- case 0xA:
- status.rate_idx = 2;
+ case 0xa:
+ status->rate_idx = 2;
break;
- case 0xE:
- status.rate_idx = 3;
+ case 0xe:
+ status->rate_idx = 3;
break;
case 0x9:
- status.rate_idx = 4;
+ status->rate_idx = 4;
break;
- case 0xD:
- status.rate_idx = 5;
+ case 0xd:
+ status->rate_idx = 5;
break;
case 0x8:
- status.rate_idx = 6;
+ status->rate_idx = 6;
break;
- case 0xC:
- status.rate_idx = 7;
+ case 0xc:
+ status->rate_idx = 7;
break;
default:
- if ((!ar->sniffer_enabled) && (net_ratelimit()))
+ if (ar9170_nag_limiter(ar))
printk(KERN_ERR "%s: invalid plcp ofdm rate "
"(%x).\n", wiphy_name(ar->hw->wiphy),
head->plcp[0]);
- return;
+ return -EINVAL;
}
- if (status.band == IEEE80211_BAND_2GHZ)
- status.rate_idx += 4;
+ if (status->band == IEEE80211_BAND_2GHZ)
+ status->rate_idx += 4;
break;
+
case AR9170_RX_STATUS_MODULATION_HT:
+ if (head->plcp[3] & 0x80)
+ status->flag |= RX_FLAG_40MHZ;
+ if (head->plcp[6] & 0x80)
+ status->flag |= RX_FLAG_SHORT_GI;
+
+ status->rate_idx = clamp(0, 75, head->plcp[6] & 0x7f);
+ status->flag |= RX_FLAG_HT;
+ break;
+
case AR9170_RX_STATUS_MODULATION_DUPOFDM:
/* XXX */
-
- if (net_ratelimit())
+ if (ar9170_nag_limiter(ar))
printk(KERN_ERR "%s: invalid modulation\n",
wiphy_name(ar->hw->wiphy));
- return;
+ return -EINVAL;
}
- error = tail->error;
+ return 0;
+}
- if (error & AR9170_RX_ERROR_MMIC) {
- status.flag |= RX_FLAG_MMIC_ERROR;
- error &= ~AR9170_RX_ERROR_MMIC;
- }
+static void ar9170_rx_phy_status(struct ar9170 *ar,
+ struct ar9170_rx_phystatus *phy,
+ struct ieee80211_rx_status *status)
+{
+ int i;
- if (error & AR9170_RX_ERROR_PLCP) {
- status.flag |= RX_FLAG_FAILED_PLCP_CRC;
- error &= ~AR9170_RX_ERROR_PLCP;
+ BUILD_BUG_ON(sizeof(struct ar9170_rx_phystatus) != 20);
+
+ for (i = 0; i < 3; i++)
+ if (phy->rssi[i] != 0x80)
+ status->antenna |= BIT(i);
+
+ /* post-process RSSI */
+ for (i = 0; i < 7; i++)
+ if (phy->rssi[i] & 0x80)
+ phy->rssi[i] = ((phy->rssi[i] & 0x7f) + 1) & 0x7f;
+
+ /* TODO: we could do something with phy_errors */
+ status->signal = ar->noise[0] + phy->rssi_combined;
+ status->noise = ar->noise[0];
+}
+
+static struct sk_buff *ar9170_rx_copy_data(u8 *buf, int len)
+{
+ struct sk_buff *skb;
+ int reserved = 0;
+ struct ieee80211_hdr *hdr = (void *) buf;
+
+ if (ieee80211_is_data_qos(hdr->frame_control)) {
+ u8 *qc = ieee80211_get_qos_ctl(hdr);
+ reserved += NET_IP_ALIGN;
+
+ if (*qc & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
+ reserved += NET_IP_ALIGN;
}
- if (error & AR9170_RX_ERROR_FCS) {
- status.flag |= RX_FLAG_FAILED_FCS_CRC;
- error &= ~AR9170_RX_ERROR_FCS;
+ if (ieee80211_has_a4(hdr->frame_control))
+ reserved += NET_IP_ALIGN;
+
+ reserved = 32 + (reserved & NET_IP_ALIGN);
+
+ skb = dev_alloc_skb(len + reserved);
+ if (likely(skb)) {
+ skb_reserve(skb, reserved);
+ memcpy(skb_put(skb, len), buf, len);
}
- decrypt = ar9170_get_decrypt_type(tail);
- if (!(decrypt & AR9170_RX_ENC_SOFTWARE) &&
- decrypt != AR9170_ENC_ALG_NONE)
- status.flag |= RX_FLAG_DECRYPTED;
+ return skb;
+}
- /* ignore wrong RA errors */
- error &= ~AR9170_RX_ERROR_WRONG_RA;
+/*
+ * If the frame alignment is right (or the kernel has
+ * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS), and there
+ * is only a single MPDU in the USB frame, then we could
+ * submit to mac80211 the SKB directly. However, since
+ * there may be multiple packets in one SKB in stream
+ * mode, and we need to observe the proper ordering,
+ * this is non-trivial.
+ */
- if (error & AR9170_RX_ERROR_DECRYPT) {
- error &= ~AR9170_RX_ERROR_DECRYPT;
+static void ar9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len)
+{
+ struct ar9170_rx_head *head;
+ struct ar9170_rx_macstatus *mac;
+ struct ar9170_rx_phystatus *phy = NULL;
+ struct ieee80211_rx_status status;
+ struct sk_buff *skb;
+ int mpdu_len;
+
+ if (unlikely(!IS_STARTED(ar) || len < (sizeof(*mac))))
+ return ;
+
+ /* Received MPDU */
+ mpdu_len = len - sizeof(*mac);
+
+ mac = (void *)(buf + mpdu_len);
+ if (unlikely(mac->error & AR9170_RX_ERROR_FATAL)) {
+ /* this frame is too damaged and can't be used - drop it */
- /*
- * Rx decryption is done in place,
- * the original data is lost anyway.
- */
return ;
}
- /* drop any other error frames */
- if ((error) && (net_ratelimit())) {
- printk(KERN_DEBUG "%s: errors: %#x\n",
- wiphy_name(ar->hw->wiphy), error);
- return;
+ switch (mac->status & AR9170_RX_STATUS_MPDU_MASK) {
+ case AR9170_RX_STATUS_MPDU_FIRST:
+ /* first mpdu packet has the plcp header */
+ if (likely(mpdu_len >= sizeof(struct ar9170_rx_head))) {
+ head = (void *) buf;
+ memcpy(&ar->rx_mpdu.plcp, (void *) buf,
+ sizeof(struct ar9170_rx_head));
+
+ mpdu_len -= sizeof(struct ar9170_rx_head);
+ buf += sizeof(struct ar9170_rx_head);
+ ar->rx_mpdu.has_plcp = true;
+ } else {
+ if (ar9170_nag_limiter(ar))
+ printk(KERN_ERR "%s: plcp info is clipped.\n",
+ wiphy_name(ar->hw->wiphy));
+ return ;
+ }
+ break;
+
+ case AR9170_RX_STATUS_MPDU_LAST:
+ /* last mpdu has a extra tail with phy status information */
+
+ if (likely(mpdu_len >= sizeof(struct ar9170_rx_phystatus))) {
+ mpdu_len -= sizeof(struct ar9170_rx_phystatus);
+ phy = (void *)(buf + mpdu_len);
+ } else {
+ if (ar9170_nag_limiter(ar))
+ printk(KERN_ERR "%s: frame tail is clipped.\n",
+ wiphy_name(ar->hw->wiphy));
+ return ;
+ }
+
+ case AR9170_RX_STATUS_MPDU_MIDDLE:
+ /* middle mpdus are just data */
+ if (unlikely(!ar->rx_mpdu.has_plcp)) {
+ if (!ar9170_nag_limiter(ar))
+ return ;
+
+ printk(KERN_ERR "%s: rx stream did not start "
+ "with a first_mpdu frame tag.\n",
+ wiphy_name(ar->hw->wiphy));
+
+ return ;
+ }
+
+ head = &ar->rx_mpdu.plcp;
+ break;
+
+ case AR9170_RX_STATUS_MPDU_SINGLE:
+ /* single mpdu - has plcp (head) and phy status (tail) */
+ head = (void *) buf;
+
+ mpdu_len -= sizeof(struct ar9170_rx_head);
+ mpdu_len -= sizeof(struct ar9170_rx_phystatus);
+
+ buf += sizeof(struct ar9170_rx_head);
+ phy = (void *)(buf + mpdu_len);
+ break;
+
+ default:
+ BUG_ON(1);
+ break;
}
- buf += sizeof(struct ar9170_rx_head);
- fc = *(__le16 *)buf;
+ if (unlikely(mpdu_len < FCS_LEN))
+ return ;
- if (ieee80211_is_data_qos(fc) ^ ieee80211_has_a4(fc))
- reserved = 32 + 2;
- else
- reserved = 32;
+ memset(&status, 0, sizeof(status));
+ if (unlikely(ar9170_rx_mac_status(ar, head, mac, &status)))
+ return ;
- skb = dev_alloc_skb(mpdu_len + reserved);
- if (!skb)
- return;
+ if (phy)
+ ar9170_rx_phy_status(ar, phy, &status);
- skb_reserve(skb, reserved);
- memcpy(skb_put(skb, mpdu_len), buf, mpdu_len);
- ieee80211_rx_irqsafe(ar->hw, skb, &status);
+ skb = ar9170_rx_copy_data(buf, mpdu_len);
+ if (likely(skb))
+ ieee80211_rx_irqsafe(ar->hw, skb, &status);
}
void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb)
{
- unsigned int i, tlen, resplen;
+ unsigned int i, tlen, resplen, wlen = 0, clen = 0;
u8 *tbuf, *respbuf;
tbuf = skb->data;
tlen = skb->len;
while (tlen >= 4) {
- int clen = tbuf[1] << 8 | tbuf[0];
- int wlen = (clen + 3) & ~3;
+ clen = tbuf[1] << 8 | tbuf[0];
+ wlen = ALIGN(clen, 4);
- /*
- * parse stream (if any)
- */
+ /* check if this is stream has a valid tag.*/
if (tbuf[2] != 0 || tbuf[3] != 0x4e) {
- printk(KERN_ERR "%s: missing tag!\n",
- wiphy_name(ar->hw->wiphy));
+ /*
+ * TODO: handle the highly unlikely event that the
+ * corrupted stream has the TAG at the right position.
+ */
+
+ /* check if the frame can be repaired. */
+ if (!ar->rx_failover_missing) {
+ /* this is no "short read". */
+ if (ar9170_nag_limiter(ar)) {
+ printk(KERN_ERR "%s: missing tag!\n",
+ wiphy_name(ar->hw->wiphy));
+ goto err_telluser;
+ } else
+ goto err_silent;
+ }
+
+ if (ar->rx_failover_missing > tlen) {
+ if (ar9170_nag_limiter(ar)) {
+ printk(KERN_ERR "%s: possible multi "
+ "stream corruption!\n",
+ wiphy_name(ar->hw->wiphy));
+ goto err_telluser;
+ } else
+ goto err_silent;
+ }
+
+ memcpy(skb_put(ar->rx_failover, tlen), tbuf, tlen);
+ ar->rx_failover_missing -= tlen;
+
+ if (ar->rx_failover_missing <= 0) {
+ /*
+ * nested ar9170_rx call!
+ * termination is guranteed, even when the
+ * combined frame also have a element with
+ * a bad tag.
+ */
+
+ ar->rx_failover_missing = 0;
+ ar9170_rx(ar, ar->rx_failover);
+
+ skb_reset_tail_pointer(ar->rx_failover);
+ skb_trim(ar->rx_failover, 0);
+ }
+
return ;
}
+
+ /* check if stream is clipped */
if (wlen > tlen - 4) {
- printk(KERN_ERR "%s: invalid RX (%d, %d, %d)\n",
- wiphy_name(ar->hw->wiphy), clen, wlen, tlen);
- print_hex_dump(KERN_DEBUG, "data: ",
- DUMP_PREFIX_OFFSET,
- 16, 1, tbuf, tlen, true);
+ if (ar->rx_failover_missing) {
+ /* TODO: handle double stream corruption. */
+ if (ar9170_nag_limiter(ar)) {
+ printk(KERN_ERR "%s: double rx stream "
+ "corruption!\n",
+ wiphy_name(ar->hw->wiphy));
+ goto err_telluser;
+ } else
+ goto err_silent;
+ }
+
+ /*
+ * save incomplete data set.
+ * the firmware will resend the missing bits when
+ * the rx - descriptor comes round again.
+ */
+
+ memcpy(skb_put(ar->rx_failover, tlen), tbuf, tlen);
+ ar->rx_failover_missing = clen - tlen;
return ;
}
resplen = clen;
@@ -668,12 +902,44 @@ void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb)
if (i == 12)
ar9170_handle_command_response(ar, respbuf, resplen);
else
- ar9170_handle_mpdu(ar, respbuf, resplen);
+ ar9170_handle_mpdu(ar, respbuf, clen);
}
- if (tlen)
- printk(KERN_ERR "%s: buffer remains!\n",
- wiphy_name(ar->hw->wiphy));
+ if (tlen) {
+ if (net_ratelimit())
+ printk(KERN_ERR "%s: %d bytes of unprocessed "
+ "data left in rx stream!\n",
+ wiphy_name(ar->hw->wiphy), tlen);
+
+ goto err_telluser;
+ }
+
+ return ;
+
+err_telluser:
+ printk(KERN_ERR "%s: damaged RX stream data [want:%d, "
+ "data:%d, rx:%d, pending:%d ]\n",
+ wiphy_name(ar->hw->wiphy), clen, wlen, tlen,
+ ar->rx_failover_missing);
+
+ if (ar->rx_failover_missing)
+ print_hex_dump_bytes("rxbuf:", DUMP_PREFIX_OFFSET,
+ ar->rx_failover->data,
+ ar->rx_failover->len);
+
+ print_hex_dump_bytes("stream:", DUMP_PREFIX_OFFSET,
+ skb->data, skb->len);
+
+ printk(KERN_ERR "%s: please check your hardware and cables, if "
+ "you see this message frequently.\n",
+ wiphy_name(ar->hw->wiphy));
+
+err_silent:
+ if (ar->rx_failover_missing) {
+ skb_reset_tail_pointer(ar->rx_failover);
+ skb_trim(ar->rx_failover, 0);
+ ar->rx_failover_missing = 0;
+ }
}
#define AR9170_FILL_QUEUE(queue, ai_fs, cwmin, cwmax, _txop) \
@@ -703,6 +969,8 @@ static int ar9170_op_start(struct ieee80211_hw *hw)
AR9170_FILL_QUEUE(ar->edcf[3], 2, 3, 7, 47); /* VOICE */
AR9170_FILL_QUEUE(ar->edcf[4], 2, 3, 7, 0); /* SPECIAL */
+ ar->bad_hw_nagger = jiffies;
+
err = ar->open(ar);
if (err)
goto out;
@@ -742,8 +1010,9 @@ static void ar9170_op_stop(struct ieee80211_hw *hw)
if (IS_STARTED(ar))
ar->state = AR9170_IDLE;
- mutex_lock(&ar->mutex);
+ flush_workqueue(ar->hw->workqueue);
+ mutex_lock(&ar->mutex);
cancel_delayed_work_sync(&ar->tx_status_janitor);
cancel_work_sync(&ar->filter_config_work);
cancel_work_sync(&ar->beacon_work);
@@ -1068,7 +1337,7 @@ static int ar9170_op_config(struct ieee80211_hw *hw, u32 changed)
goto out;
}
- if (changed & IEEE80211_CONF_CHANGE_BEACON_INTERVAL) {
+ if (changed & BSS_CHANGED_BEACON_INT) {
err = ar9170_set_beacon_timers(ar);
if (err)
goto out;
@@ -1076,7 +1345,8 @@ static int ar9170_op_config(struct ieee80211_hw *hw, u32 changed)
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
err = ar9170_set_channel(ar, hw->conf.channel,
- AR9170_RFI_NONE, AR9170_BW_20);
+ AR9170_RFI_NONE,
+ nl80211_to_ar9170(hw->conf.channel_type));
if (err)
goto out;
/* adjust slot time for 5 GHz */
@@ -1090,43 +1360,16 @@ out:
return err;
}
-static int ar9170_op_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct ar9170 *ar = hw->priv;
- int err = 0;
-
- mutex_lock(&ar->mutex);
-
- if (conf->changed & IEEE80211_IFCC_BSSID) {
- memcpy(ar->bssid, conf->bssid, ETH_ALEN);
- err = ar9170_set_operating_mode(ar);
- }
-
- if (conf->changed & IEEE80211_IFCC_BEACON) {
- err = ar9170_update_beacon(ar);
-
- if (err)
- goto out;
- err = ar9170_set_beacon_timers(ar);
- }
-
-out:
- mutex_unlock(&ar->mutex);
- return err;
-}
-
static void ar9170_set_filters(struct work_struct *work)
{
struct ar9170 *ar = container_of(work, struct ar9170,
filter_config_work);
int err;
- mutex_lock(&ar->mutex);
if (unlikely(!IS_STARTED(ar)))
- goto unlock;
+ return ;
+ mutex_lock(&ar->mutex);
if (ar->filter_changed & AR9170_FILTER_CHANGED_PROMISC) {
err = ar9170_set_operating_mode(ar);
if (err)
@@ -1155,8 +1398,8 @@ static void ar9170_op_configure_filter(struct ieee80211_hw *hw,
/* mask supported flags */
*new_flags &= FIF_ALLMULTI | FIF_CONTROL | FIF_BCN_PRBRESP_PROMISC |
- FIF_PROMISC_IN_BSS;
-
+ FIF_PROMISC_IN_BSS | FIF_FCSFAIL | FIF_PLCPFAIL;
+ ar->filter_state = *new_flags;
/*
* We can support more by setting the sniffer bit and
* then checking the error flags, later.
@@ -1218,6 +1461,17 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
mutex_lock(&ar->mutex);
+ if (changed & BSS_CHANGED_BSSID) {
+ memcpy(ar->bssid, bss_conf->bssid, ETH_ALEN);
+ err = ar9170_set_operating_mode(ar);
+ }
+
+ if (changed & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED)) {
+ err = ar9170_update_beacon(ar);
+ if (!err)
+ ar9170_set_beacon_timers(ar);
+ }
+
ar9170_regwrite_begin(ar);
if (changed & BSS_CHANGED_ASSOC) {
@@ -1229,6 +1483,9 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
#endif /* CONFIG_AR9170_LEDS */
}
+ if (changed & BSS_CHANGED_BEACON_INT)
+ err = ar9170_set_beacon_timers(ar);
+
if (changed & BSS_CHANGED_HT) {
/* TODO */
err = 0;
@@ -1298,7 +1555,7 @@ static int ar9170_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
switch (key->alg) {
case ALG_WEP:
- if (key->keylen == LEN_WEP40)
+ if (key->keylen == WLAN_KEY_LEN_WEP40)
ktype = AR9170_ENC_ALG_WEP64;
else
ktype = AR9170_ENC_ALG_WEP128;
@@ -1498,6 +1755,24 @@ static int ar9170_conf_tx(struct ieee80211_hw *hw, u16 queue,
return ret;
}
+static int ar9170_ampdu_action(struct ieee80211_hw *hw,
+ enum ieee80211_ampdu_mlme_action action,
+ struct ieee80211_sta *sta, u16 tid, u16 *ssn)
+{
+ switch (action) {
+ case IEEE80211_AMPDU_RX_START:
+ case IEEE80211_AMPDU_RX_STOP:
+ /*
+ * Something goes wrong -- RX locks up
+ * after a while of receiving aggregated
+ * frames -- not enabling for now.
+ */
+ return -EOPNOTSUPP;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
static const struct ieee80211_ops ar9170_ops = {
.start = ar9170_op_start,
.stop = ar9170_op_stop,
@@ -1505,7 +1780,6 @@ static const struct ieee80211_ops ar9170_ops = {
.add_interface = ar9170_op_add_interface,
.remove_interface = ar9170_op_remove_interface,
.config = ar9170_op_config,
- .config_interface = ar9170_op_config_interface,
.configure_filter = ar9170_op_configure_filter,
.conf_tx = ar9170_conf_tx,
.bss_info_changed = ar9170_op_bss_info_changed,
@@ -1514,26 +1788,40 @@ static const struct ieee80211_ops ar9170_ops = {
.sta_notify = ar9170_sta_notify,
.get_stats = ar9170_get_stats,
.get_tx_stats = ar9170_get_tx_stats,
+ .ampdu_action = ar9170_ampdu_action,
};
void *ar9170_alloc(size_t priv_size)
{
struct ieee80211_hw *hw;
struct ar9170 *ar;
+ struct sk_buff *skb;
int i;
+ /*
+ * this buffer is used for rx stream reconstruction.
+ * Under heavy load this device (or the transport layer?)
+ * tends to split the streams into seperate rx descriptors.
+ */
+
+ skb = __dev_alloc_skb(AR9170_MAX_RX_BUFFER_SIZE, GFP_KERNEL);
+ if (!skb)
+ goto err_nomem;
+
hw = ieee80211_alloc_hw(priv_size, &ar9170_ops);
if (!hw)
- return ERR_PTR(-ENOMEM);
+ goto err_nomem;
ar = hw->priv;
ar->hw = hw;
+ ar->rx_failover = skb;
mutex_init(&ar->mutex);
spin_lock_init(&ar->cmdlock);
spin_lock_init(&ar->tx_stats_lock);
skb_queue_head_init(&ar->global_tx_status);
skb_queue_head_init(&ar->global_tx_status_waste);
+ ar9170_rx_reset_rx_mpdu(ar);
INIT_WORK(&ar->filter_config_work, ar9170_set_filters);
INIT_WORK(&ar->beacon_work, ar9170_new_beacon);
INIT_DELAYED_WORK(&ar->tx_status_janitor, ar9170_tx_status_janitor);
@@ -1561,6 +1849,10 @@ void *ar9170_alloc(size_t priv_size)
ar->noise[i] = -95; /* ATH_DEFAULT_NOISE_FLOOR */
return ar;
+
+err_nomem:
+ kfree_skb(skb);
+ return ERR_PTR(-ENOMEM);
}
static int ar9170_read_eeprom(struct ar9170 *ar)
@@ -1619,12 +1911,24 @@ static int ar9170_read_eeprom(struct ar9170 *ar)
else
ar->hw->channel_change_time = 80 * 1000;
+ ar->regulatory.current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]);
+ ar->regulatory.current_rd_ext = le16_to_cpu(ar->eeprom.reg_domain[1]);
+
/* second part of wiphy init */
SET_IEEE80211_PERM_ADDR(ar->hw, addr);
return bands ? 0 : -EINVAL;
}
+static int ar9170_reg_notifier(struct wiphy *wiphy,
+ struct regulatory_request *request)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct ar9170 *ar = hw->priv;
+
+ return ath_reg_notifier_apply(wiphy, request, &ar->regulatory);
+}
+
int ar9170_register(struct ar9170 *ar, struct device *pdev)
{
int err;
@@ -1634,10 +1938,18 @@ int ar9170_register(struct ar9170 *ar, struct device *pdev)
if (err)
goto err_out;
+ err = ath_regd_init(&ar->regulatory, ar->hw->wiphy,
+ ar9170_reg_notifier);
+ if (err)
+ goto err_out;
+
err = ieee80211_register_hw(ar->hw);
if (err)
goto err_out;
+ if (!ath_is_world_regd(&ar->regulatory))
+ regulatory_hint(ar->hw->wiphy, ar->regulatory.alpha2);
+
err = ar9170_init_leds(ar);
if (err)
goto err_unreg;
@@ -1666,6 +1978,7 @@ void ar9170_unregister(struct ar9170 *ar)
ar9170_unregister_leds(ar);
#endif /* CONFIG_AR9170_LEDS */
+ kfree_skb(ar->rx_failover);
ieee80211_unregister_hw(ar->hw);
mutex_destroy(&ar->mutex);
}
diff --git a/drivers/net/wireless/ar9170/phy.c b/drivers/net/wireless/ath/ar9170/phy.c
index 6ce20754b8e7..6ce20754b8e7 100644
--- a/drivers/net/wireless/ar9170/phy.c
+++ b/drivers/net/wireless/ath/ar9170/phy.c
diff --git a/drivers/net/wireless/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index fddda477095c..d7c13c0177ca 100644
--- a/drivers/net/wireless/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -350,7 +350,7 @@ static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
goto err_unbuf;
}
- if (outlen >= 0 && aru->readlen != outlen) {
+ if (aru->readlen != outlen) {
err = -EMSGSIZE;
goto err_unbuf;
}
@@ -689,6 +689,9 @@ static int ar9170_usb_probe(struct usb_interface *intf,
aru->common.exec_cmd = ar9170_usb_exec_cmd;
aru->common.callback_cmd = ar9170_usb_callback_cmd;
+#ifdef CONFIG_PM
+ udev->reset_resume = 1;
+#endif
err = ar9170_usb_reset(aru);
if (err)
goto err_freehw;
@@ -805,6 +808,7 @@ static struct usb_driver ar9170_driver = {
#ifdef CONFIG_PM
.suspend = ar9170_suspend,
.resume = ar9170_resume,
+ .reset_resume = ar9170_resume,
#endif /* CONFIG_PM */
};
diff --git a/drivers/net/wireless/ar9170/usb.h b/drivers/net/wireless/ath/ar9170/usb.h
index f5852924cd64..ac42586495d8 100644
--- a/drivers/net/wireless/ar9170/usb.h
+++ b/drivers/net/wireless/ath/ar9170/usb.h
@@ -43,7 +43,7 @@
#include <linux/completion.h>
#include <linux/spinlock.h>
#include <linux/leds.h>
-#include <net/wireless.h>
+#include <net/cfg80211.h>
#include <net/mac80211.h>
#include <linux/firmware.h>
#include "eeprom.h"
diff --git a/drivers/net/wireless/ath5k/Kconfig b/drivers/net/wireless/ath/ath5k/Kconfig
index 75383a5df992..509b6f94f73b 100644
--- a/drivers/net/wireless/ath5k/Kconfig
+++ b/drivers/net/wireless/ath/ath5k/Kconfig
@@ -1,6 +1,7 @@
config ATH5K
tristate "Atheros 5xxx wireless cards support"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
+ select ATH_COMMON
select MAC80211_LEDS
select LEDS_CLASS
select NEW_LEDS
diff --git a/drivers/net/wireless/ath5k/Makefile b/drivers/net/wireless/ath/ath5k/Makefile
index 84a74c5248e5..84a74c5248e5 100644
--- a/drivers/net/wireless/ath5k/Makefile
+++ b/drivers/net/wireless/ath/ath5k/Makefile
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 0b616e72fe05..813718210338 100644
--- a/drivers/net/wireless/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -27,6 +27,8 @@
#include <linux/types.h>
#include <net/mac80211.h>
+#include "../regd.h"
+
/* RX/TX descriptor hw structs
* TODO: Driver part should only see sw structs */
#include "desc.h"
@@ -207,7 +209,6 @@
#define AR5K_TUNE_MAX_TXPOWER 63
#define AR5K_TUNE_DEFAULT_TXPOWER 25
#define AR5K_TUNE_TPC_TXPOWER false
-#define AR5K_TUNE_ANT_DIVERSITY true
#define AR5K_TUNE_HWTXTRIES 4
#define AR5K_INIT_CARR_SENSE_EN 1
@@ -418,6 +419,17 @@ enum ath5k_driver_mode {
AR5K_MODE_MAX = 5
};
+enum ath5k_ant_mode {
+ AR5K_ANTMODE_DEFAULT = 0, /* default antenna setup */
+ AR5K_ANTMODE_FIXED_A = 1, /* only antenna A is present */
+ AR5K_ANTMODE_FIXED_B = 2, /* only antenna B is present */
+ AR5K_ANTMODE_SINGLE_AP = 3, /* sta locked on a single ap */
+ AR5K_ANTMODE_SECTOR_AP = 4, /* AP with tx antenna set on tx desc */
+ AR5K_ANTMODE_SECTOR_STA = 5, /* STA with tx antenna set on tx desc */
+ AR5K_ANTMODE_DEBUG = 6, /* Debug mode -A -> Rx, B-> Tx- */
+ AR5K_ANTMODE_MAX,
+};
+
/****************\
TX DEFINITIONS
@@ -1039,8 +1051,6 @@ struct ath5k_hw {
bool ah_5ghz;
bool ah_2ghz;
-#define ah_regdomain ah_capabilities.cap_regdomain.reg_current
-#define ah_regdomain_hw ah_capabilities.cap_regdomain.reg_hw
#define ah_modes ah_capabilities.cap_mode
#define ah_ee_version ah_capabilities.cap_eeprom.ee_version
@@ -1051,8 +1061,11 @@ struct ath5k_hw {
bool ah_software_retry;
u32 ah_limit_tx_retries;
- u32 ah_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
- bool ah_ant_diversity;
+ /* Antenna Control */
+ u32 ah_ant_ctl[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
+ u8 ah_ant_mode;
+ u8 ah_tx_ant;
+ u8 ah_def_ant;
u8 ah_sta_id[ETH_ALEN];
@@ -1065,6 +1078,7 @@ struct ath5k_hw {
u32 ah_gpio[AR5K_MAX_GPIO];
int ah_gpio_npins;
+ struct ath_regulatory ah_regulatory;
struct ath5k_capabilities ah_capabilities;
struct ath5k_txq_info ah_txq[AR5K_NUM_TX_QUEUES];
@@ -1099,11 +1113,12 @@ struct ath5k_hw {
/* Values in 0.25dB units */
s16 txp_min_pwr;
s16 txp_max_pwr;
+ /* Values in 0.5dB units */
s16 txp_offset;
s16 txp_ofdm;
- /* Values in dB units */
- s16 txp_cck_ofdm_pwr_delta;
s16 txp_cck_ofdm_gainf_delta;
+ /* Value in dB units */
+ s16 txp_cck_ofdm_pwr_delta;
} ah_txpower;
struct {
@@ -1263,14 +1278,21 @@ extern int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *chann
/* PHY calibration */
extern int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel);
extern int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq);
+/* Spur mitigation */
+bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
+ struct ieee80211_channel *channel);
+void ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah,
+ struct ieee80211_channel *channel);
/* Misc PHY functions */
extern u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan);
-extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant);
-extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah);
extern int ath5k_hw_phy_disable(struct ath5k_hw *ah);
+/* Antenna control */
+extern void ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode);
+extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant);
+extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah);
/* TX power setup */
extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 ee_mode, u8 txpower);
-extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 ee_mode, u8 txpower);
+extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
/*
* Functions used internaly
diff --git a/drivers/net/wireless/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 70d376c63aac..c41ef58393e7 100644
--- a/drivers/net/wireless/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -133,7 +133,6 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
ah->ah_cw_min = AR5K_TUNE_CWMIN;
ah->ah_limit_tx_retries = AR5K_INIT_TX_RETRY;
ah->ah_software_retry = false;
- ah->ah_ant_diversity = AR5K_TUNE_ANT_DIVERSITY;
/*
* Set the mac version based on the pci id
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 32df27a9c7a2..fb5193764afa 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -61,9 +61,13 @@
static int ath5k_calinterval = 10; /* Calibrate PHY every 10 secs (TODO: Fixme) */
static int modparam_nohwcrypt;
-module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
+module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
+static int modparam_all_channels;
+module_param_named(all_channels, modparam_all_channels, bool, S_IRUGO);
+MODULE_PARM_DESC(all_channels, "Expose all channels the device can use.");
+
/******************\
* Internal defines *
@@ -223,9 +227,6 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
static void ath5k_remove_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
static int ath5k_config(struct ieee80211_hw *hw, u32 changed);
-static int ath5k_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf);
static void ath5k_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *new_flags,
@@ -241,8 +242,8 @@ static int ath5k_get_tx_stats(struct ieee80211_hw *hw,
static u64 ath5k_get_tsf(struct ieee80211_hw *hw);
static void ath5k_set_tsf(struct ieee80211_hw *hw, u64 tsf);
static void ath5k_reset_tsf(struct ieee80211_hw *hw);
-static int ath5k_beacon_update(struct ath5k_softc *sc,
- struct sk_buff *skb);
+static int ath5k_beacon_update(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif);
static void ath5k_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *bss_conf,
@@ -255,7 +256,6 @@ static const struct ieee80211_ops ath5k_hw_ops = {
.add_interface = ath5k_add_interface,
.remove_interface = ath5k_remove_interface,
.config = ath5k_config,
- .config_interface = ath5k_config_interface,
.configure_filter = ath5k_configure_filter,
.set_key = ath5k_set_key,
.get_stats = ath5k_get_stats,
@@ -516,6 +516,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
IEEE80211_HW_NOISE_DBM;
hw->wiphy->interface_modes =
+ BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_MESH_POINT);
@@ -705,6 +706,15 @@ err_no_irq:
* Driver Initialization *
\***********************/
+static int ath5k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct ath5k_softc *sc = hw->priv;
+ struct ath_regulatory *reg = &sc->ah->ah_regulatory;
+
+ return ath_reg_notifier_apply(wiphy, request, reg);
+}
+
static int
ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
{
@@ -793,12 +803,23 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
memset(sc->bssidmask, 0xff, ETH_ALEN);
ath5k_hw_set_bssid_mask(sc->ah, sc->bssidmask);
+ ah->ah_regulatory.current_rd =
+ ah->ah_capabilities.cap_eeprom.ee_regdomain;
+ ret = ath_regd_init(&ah->ah_regulatory, hw->wiphy, ath5k_reg_notifier);
+ if (ret) {
+ ATH5K_ERR(sc, "can't initialize regulatory system\n");
+ goto err_queues;
+ }
+
ret = ieee80211_register_hw(hw);
if (ret) {
ATH5K_ERR(sc, "can't register ieee80211 hw\n");
goto err_queues;
}
+ if (!ath_is_world_regd(&sc->ah->ah_regulatory))
+ regulatory_hint(hw->wiphy, sc->ah->ah_regulatory.alpha2);
+
ath5k_init_leds(sc);
return 0;
@@ -862,6 +883,20 @@ ath5k_ieee2mhz(short chan)
return 2212 + chan * 20;
}
+/*
+ * Returns true for the channel numbers used without all_channels modparam.
+ */
+static bool ath5k_is_standard_channel(short chan)
+{
+ return ((chan <= 14) ||
+ /* UNII 1,2 */
+ ((chan & 3) == 0 && chan >= 36 && chan <= 64) ||
+ /* midband */
+ ((chan & 3) == 0 && chan >= 100 && chan <= 140) ||
+ /* UNII-3 */
+ ((chan & 3) == 1 && chan >= 149 && chan <= 165));
+}
+
static unsigned int
ath5k_copy_channels(struct ath5k_hw *ah,
struct ieee80211_channel *channels,
@@ -899,6 +934,9 @@ ath5k_copy_channels(struct ath5k_hw *ah,
if (!ath5k_channel_ok(ah, freq, chfreq))
continue;
+ if (!modparam_all_channels && !ath5k_is_standard_channel(ch))
+ continue;
+
/* Write channel info and increment counter */
channels[count].center_freq = freq;
channels[count].band = (chfreq == CHANNEL_2GHZ) ?
@@ -1238,7 +1276,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,
(sc->power_level * 2),
hw_rate,
- info->control.rates[0].count, keyidx, 0, flags,
+ info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
cts_rate, duration);
if (ret)
goto err_unmap;
@@ -1574,9 +1612,8 @@ ath5k_rx_start(struct ath5k_softc *sc)
ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "cachelsz %u rxbufsize %u\n",
sc->cachelsz, sc->rxbufsize);
- sc->rxlink = NULL;
-
spin_lock_bh(&sc->rxbuflock);
+ sc->rxlink = NULL;
list_for_each_entry(bf, &sc->rxbuf, list) {
ret = ath5k_rxbuf_setup(sc, bf);
if (ret != 0) {
@@ -1585,9 +1622,9 @@ ath5k_rx_start(struct ath5k_softc *sc)
}
}
bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list);
+ ath5k_hw_set_rxdp(ah, bf->daddr);
spin_unlock_bh(&sc->rxbuflock);
- ath5k_hw_set_rxdp(ah, bf->daddr);
ath5k_hw_start_rx_dma(ah); /* enable recv descriptors */
ath5k_mode_setup(sc); /* set filters, etc. */
ath5k_hw_start_rx_pcu(ah); /* re-enable PCU/DMA engine */
@@ -1699,35 +1736,6 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,
}
}
-static void ath5k_tasklet_beacon(unsigned long data)
-{
- struct ath5k_softc *sc = (struct ath5k_softc *) data;
-
- /*
- * Software beacon alert--time to send a beacon.
- *
- * In IBSS mode we use this interrupt just to
- * keep track of the next TBTT (target beacon
- * transmission time) in order to detect wether
- * automatic TSF updates happened.
- */
- if (sc->opmode == NL80211_IFTYPE_ADHOC) {
- /* XXX: only if VEOL suppported */
- u64 tsf = ath5k_hw_get_tsf64(sc->ah);
- sc->nexttbtt += sc->bintval;
- ATH5K_DBG(sc, ATH5K_DEBUG_BEACON,
- "SWBA nexttbtt: %x hw_tu: %x "
- "TSF: %llx\n",
- sc->nexttbtt,
- TSF_TO_TU(tsf),
- (unsigned long long) tsf);
- } else {
- spin_lock(&sc->block);
- ath5k_beacon_send(sc);
- spin_unlock(&sc->block);
- }
-}
-
static void
ath5k_tasklet_rx(unsigned long data)
{
@@ -1736,7 +1744,7 @@ ath5k_tasklet_rx(unsigned long data)
struct sk_buff *skb, *next_skb;
dma_addr_t next_skb_addr;
struct ath5k_softc *sc = (void *)data;
- struct ath5k_buf *bf, *bf_last;
+ struct ath5k_buf *bf;
struct ath5k_desc *ds;
int ret;
int hdrlen;
@@ -1747,7 +1755,6 @@ ath5k_tasklet_rx(unsigned long data)
ATH5K_WARN(sc, "empty rx buf pool\n");
goto unlock;
}
- bf_last = list_entry(sc->rxbuf.prev, struct ath5k_buf, list);
do {
rxs.flag = 0;
@@ -1756,24 +1763,9 @@ ath5k_tasklet_rx(unsigned long data)
skb = bf->skb;
ds = bf->desc;
- /*
- * last buffer must not be freed to ensure proper hardware
- * function. When the hardware finishes also a packet next to
- * it, we are sure, it doesn't use it anymore and we can go on.
- */
- if (bf_last == bf)
- bf->flags |= 1;
- if (bf->flags) {
- struct ath5k_buf *bf_next = list_entry(bf->list.next,
- struct ath5k_buf, list);
- ret = sc->ah->ah_proc_rx_desc(sc->ah, bf_next->desc,
- &rs);
- if (ret)
- break;
- bf->flags &= ~1;
- /* skip the overwritten one (even status is martian) */
- goto next;
- }
+ /* bail if HW is still using self-linked descriptor */
+ if (ath5k_hw_get_rxdp(sc->ah) == bf->daddr)
+ break;
ret = sc->ah->ah_proc_rx_desc(sc->ah, ds, &rs);
if (unlikely(ret == -EINPROGRESS))
@@ -2014,7 +2006,8 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ath5k_hw *ah = sc->ah;
struct ath5k_desc *ds;
- int ret, antenna = 0;
+ int ret = 0;
+ u8 antenna;
u32 flags;
bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len,
@@ -2028,23 +2021,35 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
}
ds = bf->desc;
+ antenna = ah->ah_tx_ant;
flags = AR5K_TXDESC_NOACK;
if (sc->opmode == NL80211_IFTYPE_ADHOC && ath5k_hw_hasveol(ah)) {
ds->ds_link = bf->daddr; /* self-linked */
flags |= AR5K_TXDESC_VEOL;
- /*
- * Let hardware handle antenna switching if txantenna is not set
- */
- } else {
+ } else
ds->ds_link = 0;
- /*
- * Switch antenna every 4 beacons if txantenna is not set
- * XXX assumes two antennas
- */
- if (antenna == 0)
- antenna = sc->bsent & 4 ? 2 : 1;
- }
+
+ /*
+ * If we use multiple antennas on AP and use
+ * the Sectored AP scenario, switch antenna every
+ * 4 beacons to make sure everybody hears our AP.
+ * When a client tries to associate, hw will keep
+ * track of the tx antenna to be used for this client
+ * automaticaly, based on ACKed packets.
+ *
+ * Note: AP still listens and transmits RTS on the
+ * default antenna which is supposed to be an omni.
+ *
+ * Note2: On sectored scenarios it's possible to have
+ * multiple antennas (1omni -the default- and 14 sectors)
+ * so if we choose to actually support this mode we need
+ * to allow user to set how many antennas we have and tweak
+ * the code below to send beacons on all of them.
+ */
+ if (ah->ah_ant_mode == AR5K_ANTMODE_SECTOR_AP)
+ antenna = sc->bsent & 4 ? 2 : 1;
+
/* FIXME: If we are in g mode and rate is a CCK rate
* subtract ah->ah_txpower.txp_cck_ofdm_pwr_delta
@@ -2097,7 +2102,7 @@ ath5k_beacon_send(struct ath5k_softc *sc)
sc->bmisscount++;
ATH5K_DBG(sc, ATH5K_DEBUG_BEACON,
"missed %u consecutive beacons\n", sc->bmisscount);
- if (sc->bmisscount > 3) { /* NB: 3 is a guess */
+ if (sc->bmisscount > 10) { /* NB: 10 is a guess */
ATH5K_DBG(sc, ATH5K_DEBUG_BEACON,
"stuck beacon time (%u missed)\n",
sc->bmisscount);
@@ -2118,10 +2123,14 @@ ath5k_beacon_send(struct ath5k_softc *sc)
* are still pending on the queue.
*/
if (unlikely(ath5k_hw_stop_tx_dma(ah, sc->bhalq))) {
- ATH5K_WARN(sc, "beacon queue %u didn't stop?\n", sc->bhalq);
+ ATH5K_WARN(sc, "beacon queue %u didn't start/stop ?\n", sc->bhalq);
/* NB: hw still stops DMA, so proceed */
}
+ /* refresh the beacon for AP mode */
+ if (sc->opmode == NL80211_IFTYPE_AP)
+ ath5k_beacon_update(sc->hw, sc->vif);
+
ath5k_hw_set_txdp(ah, sc->bhalq, bf->daddr);
ath5k_hw_start_tx_dma(ah, sc->bhalq);
ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "TXDP[%u] = %llx (%p)\n",
@@ -2278,6 +2287,35 @@ ath5k_beacon_config(struct ath5k_softc *sc)
ath5k_hw_set_imr(ah, sc->imask);
}
+static void ath5k_tasklet_beacon(unsigned long data)
+{
+ struct ath5k_softc *sc = (struct ath5k_softc *) data;
+
+ /*
+ * Software beacon alert--time to send a beacon.
+ *
+ * In IBSS mode we use this interrupt just to
+ * keep track of the next TBTT (target beacon
+ * transmission time) in order to detect wether
+ * automatic TSF updates happened.
+ */
+ if (sc->opmode == NL80211_IFTYPE_ADHOC) {
+ /* XXX: only if VEOL suppported */
+ u64 tsf = ath5k_hw_get_tsf64(sc->ah);
+ sc->nexttbtt += sc->bintval;
+ ATH5K_DBG(sc, ATH5K_DEBUG_BEACON,
+ "SWBA nexttbtt: %x hw_tu: %x "
+ "TSF: %llx\n",
+ sc->nexttbtt,
+ TSF_TO_TU(tsf),
+ (unsigned long long) tsf);
+ } else {
+ spin_lock(&sc->block);
+ ath5k_beacon_send(sc);
+ spin_unlock(&sc->block);
+ }
+}
+
/********************\
* Interrupt handling *
@@ -2452,7 +2490,7 @@ ath5k_intr(int irq, void *dev_id)
tasklet_schedule(&sc->restq);
} else {
if (status & AR5K_INT_SWBA) {
- tasklet_schedule(&sc->beacontq);
+ tasklet_hi_schedule(&sc->beacontq);
}
if (status & AR5K_INT_RXEOL) {
/*
@@ -2482,7 +2520,7 @@ ath5k_intr(int irq, void *dev_id)
ath5k_hw_update_mib_counters(ah, &sc->ll_stats);
}
}
- } while (ath5k_hw_is_intr_pending(ah) && counter-- > 0);
+ } while (ath5k_hw_is_intr_pending(ah) && --counter > 0);
if (unlikely(!counter))
ATH5K_WARN(sc, "too many interrupts, giving up for now\n");
@@ -2731,56 +2769,47 @@ static int
ath5k_config(struct ieee80211_hw *hw, u32 changed)
{
struct ath5k_softc *sc = hw->priv;
+ struct ath5k_hw *ah = sc->ah;
struct ieee80211_conf *conf = &hw->conf;
- int ret;
+ int ret = 0;
mutex_lock(&sc->lock);
sc->bintval = conf->beacon_int;
- sc->power_level = conf->power_level;
ret = ath5k_chan_set(sc, conf->channel);
+ if (ret < 0)
+ return ret;
- mutex_unlock(&sc->lock);
- return ret;
-}
+ if ((changed & IEEE80211_CONF_CHANGE_POWER) &&
+ (sc->power_level != conf->power_level)) {
+ sc->power_level = conf->power_level;
-static int
-ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct ath5k_softc *sc = hw->priv;
- struct ath5k_hw *ah = sc->ah;
- int ret = 0;
-
- mutex_lock(&sc->lock);
- if (sc->vif != vif) {
- ret = -EIO;
- goto unlock;
- }
- if (conf->changed & IEEE80211_IFCC_BSSID && conf->bssid) {
- /* Cache for later use during resets */
- memcpy(ah->ah_bssid, conf->bssid, ETH_ALEN);
- /* XXX: assoc id is set to 0 for now, mac80211 doesn't have
- * a clean way of letting us retrieve this yet. */
- ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
- mmiowb();
- }
- if (conf->changed & IEEE80211_IFCC_BEACON &&
- (vif->type == NL80211_IFTYPE_ADHOC ||
- vif->type == NL80211_IFTYPE_MESH_POINT ||
- vif->type == NL80211_IFTYPE_AP)) {
- struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
- if (!beacon) {
- ret = -ENOMEM;
- goto unlock;
- }
- ath5k_beacon_update(sc, beacon);
+ /* Half dB steps */
+ ath5k_hw_set_txpower_limit(ah, (conf->power_level * 2));
}
-unlock:
+ /* TODO:
+ * 1) Move this on config_interface and handle each case
+ * separately eg. when we have only one STA vif, use
+ * AR5K_ANTMODE_SINGLE_AP
+ *
+ * 2) Allow the user to change antenna mode eg. when only
+ * one antenna is present
+ *
+ * 3) Allow the user to set default/tx antenna when possible
+ *
+ * 4) Default mode should handle 90% of the cases, together
+ * with fixed a/b and single AP modes we should be able to
+ * handle 99%. Sectored modes are extreme cases and i still
+ * haven't found a usage for them. If we decide to support them,
+ * then we must allow the user to set how many tx antennas we
+ * have available
+ */
+ ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
+
mutex_unlock(&sc->lock);
- return ret;
+ return 0;
}
#define SUPPORTED_FIF_FLAGS \
@@ -3020,28 +3049,55 @@ ath5k_reset_tsf(struct ieee80211_hw *hw)
ath5k_hw_reset_tsf(sc->ah);
}
+/*
+ * Updates the beacon that is sent by ath5k_beacon_send. For adhoc,
+ * this is called only once at config_bss time, for AP we do it every
+ * SWBA interrupt so that the TIM will reflect buffered frames.
+ *
+ * Called with the beacon lock.
+ */
static int
-ath5k_beacon_update(struct ath5k_softc *sc, struct sk_buff *skb)
+ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
{
- unsigned long flags;
int ret;
+ struct ath5k_softc *sc = hw->priv;
+ struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
+
+ if (!skb) {
+ ret = -ENOMEM;
+ goto out;
+ }
ath5k_debug_dump_skb(sc, skb, "BC ", 1);
- spin_lock_irqsave(&sc->block, flags);
ath5k_txbuf_free(sc, sc->bbuf);
sc->bbuf->skb = skb;
ret = ath5k_beacon_setup(sc, sc->bbuf);
if (ret)
sc->bbuf->skb = NULL;
+out:
+ return ret;
+}
+
+/*
+ * Update the beacon and reconfigure the beacon queues.
+ */
+static void
+ath5k_beacon_reconfig(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+{
+ int ret;
+ unsigned long flags;
+ struct ath5k_softc *sc = hw->priv;
+
+ spin_lock_irqsave(&sc->block, flags);
+ ret = ath5k_beacon_update(hw, vif);
spin_unlock_irqrestore(&sc->block, flags);
- if (!ret) {
+ if (ret == 0) {
ath5k_beacon_config(sc);
mmiowb();
}
-
- return ret;
}
+
static void
set_beacon_filter(struct ieee80211_hw *hw, bool enable)
{
@@ -3063,11 +3119,37 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw,
u32 changes)
{
struct ath5k_softc *sc = hw->priv;
+ struct ath5k_hw *ah = sc->ah;
+
+ mutex_lock(&sc->lock);
+ if (WARN_ON(sc->vif != vif))
+ goto unlock;
+
+ if (changes & BSS_CHANGED_BSSID) {
+ /* Cache for later use during resets */
+ memcpy(ah->ah_bssid, bss_conf->bssid, ETH_ALEN);
+ /* XXX: assoc id is set to 0 for now, mac80211 doesn't have
+ * a clean way of letting us retrieve this yet. */
+ ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
+ mmiowb();
+ }
+
+ if (changes & BSS_CHANGED_BEACON_INT)
+ sc->bintval = bss_conf->beacon_int;
+
if (changes & BSS_CHANGED_ASSOC) {
- mutex_lock(&sc->lock);
sc->assoc = bss_conf->assoc;
if (sc->opmode == NL80211_IFTYPE_STATION)
set_beacon_filter(hw, sc->assoc);
- mutex_unlock(&sc->lock);
}
+
+ if (changes & BSS_CHANGED_BEACON &&
+ (vif->type == NL80211_IFTYPE_ADHOC ||
+ vif->type == NL80211_IFTYPE_MESH_POINT ||
+ vif->type == NL80211_IFTYPE_AP)) {
+ ath5k_beacon_reconfig(hw, vif);
+ }
+
+ unlock:
+ mutex_unlock(&sc->lock);
}
diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 822956114cd7..852b2c189fd8 100644
--- a/drivers/net/wireless/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -56,7 +56,6 @@
struct ath5k_buf {
struct list_head list;
- unsigned int flags; /* rx descriptor flags */
struct ath5k_desc *desc; /* virtual addr of desc */
dma_addr_t daddr; /* physical addr of desc */
struct sk_buff *skb; /* skbuff for buf */
diff --git a/drivers/net/wireless/ath5k/caps.c b/drivers/net/wireless/ath/ath5k/caps.c
index 367a6c7d3cc7..367a6c7d3cc7 100644
--- a/drivers/net/wireless/ath5k/caps.c
+++ b/drivers/net/wireless/ath/ath5k/caps.c
diff --git a/drivers/net/wireless/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 4904a07e4b59..4904a07e4b59 100644
--- a/drivers/net/wireless/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
diff --git a/drivers/net/wireless/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h
index 66f69f04e55e..66f69f04e55e 100644
--- a/drivers/net/wireless/ath5k/debug.h
+++ b/drivers/net/wireless/ath/ath5k/debug.h
diff --git a/drivers/net/wireless/ath5k/desc.c b/drivers/net/wireless/ath/ath5k/desc.c
index dc30a2b70a6b..dc30a2b70a6b 100644
--- a/drivers/net/wireless/ath5k/desc.c
+++ b/drivers/net/wireless/ath/ath5k/desc.c
diff --git a/drivers/net/wireless/ath5k/desc.h b/drivers/net/wireless/ath/ath5k/desc.h
index 56158c804e3e..56158c804e3e 100644
--- a/drivers/net/wireless/ath5k/desc.h
+++ b/drivers/net/wireless/ath/ath5k/desc.h
diff --git a/drivers/net/wireless/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c
index b65b4feb2d28..941b51130a6f 100644
--- a/drivers/net/wireless/ath5k/dma.c
+++ b/drivers/net/wireless/ath/ath5k/dma.c
@@ -80,8 +80,6 @@ int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah)
* ath5k_hw_get_rxdp - Get RX Descriptor's address
*
* @ah: The &struct ath5k_hw
- *
- * XXX: Is RXDP read and clear ?
*/
u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah)
{
diff --git a/drivers/net/wireless/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index c0fb3b09ba45..c56b494d417a 100644
--- a/drivers/net/wireless/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -156,6 +156,17 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
ee->ee_db[AR5K_EEPROM_MODE_11G][0] = (val >> 3) & 0x7;
}
+ AR5K_EEPROM_READ(AR5K_EEPROM_IS_HB63, val);
+
+ if ((ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4)) && val)
+ ee->ee_is_hb63 = true;
+ else
+ ee->ee_is_hb63 = false;
+
+ AR5K_EEPROM_READ(AR5K_EEPROM_RFKILL, val);
+ ee->ee_rfkill_pin = (u8) AR5K_REG_MS(val, AR5K_EEPROM_RFKILL_GPIO_SEL);
+ ee->ee_rfkill_pol = val & AR5K_EEPROM_RFKILL_POLARITY ? true : false;
+
return 0;
}
@@ -197,16 +208,16 @@ static int ath5k_eeprom_read_ants(struct ath5k_hw *ah, u32 *offset,
ee->ee_ant_control[mode][i++] = (val >> 6) & 0x3f;
ee->ee_ant_control[mode][i++] = val & 0x3f;
- /* Get antenna modes */
- ah->ah_antenna[mode][0] =
+ /* Get antenna switch tables */
+ ah->ah_ant_ctl[mode][AR5K_ANT_CTL] =
(ee->ee_ant_control[mode][0] << 4);
- ah->ah_antenna[mode][AR5K_ANT_FIXED_A] =
+ ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_A] =
ee->ee_ant_control[mode][1] |
(ee->ee_ant_control[mode][2] << 6) |
(ee->ee_ant_control[mode][3] << 12) |
(ee->ee_ant_control[mode][4] << 18) |
(ee->ee_ant_control[mode][5] << 24);
- ah->ah_antenna[mode][AR5K_ANT_FIXED_B] =
+ ah->ah_ant_ctl[mode][AR5K_ANT_SWTABLE_B] =
ee->ee_ant_control[mode][6] |
(ee->ee_ant_control[mode][7] << 6) |
(ee->ee_ant_control[mode][8] << 12) |
@@ -640,9 +651,9 @@ ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
static inline void
ath5k_get_pcdac_intercepts(struct ath5k_hw *ah, u8 min, u8 max, u8 *vp)
{
- const static u16 intercepts3[] =
+ static const u16 intercepts3[] =
{ 0, 5, 10, 20, 30, 50, 70, 85, 90, 95, 100 };
- const static u16 intercepts3_2[] =
+ static const u16 intercepts3_2[] =
{ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
const u16 *ip;
int i;
@@ -1694,9 +1705,40 @@ ath5k_eeprom_read_ctl_info(struct ath5k_hw *ah)
return 0;
}
+static int
+ath5k_eeprom_read_spur_chans(struct ath5k_hw *ah)
+{
+ struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
+ u32 offset;
+ u16 val;
+ int ret = 0, i;
+
+ offset = AR5K_EEPROM_CTL(ee->ee_version) +
+ AR5K_EEPROM_N_CTLS(ee->ee_version);
+
+ if (ee->ee_version < AR5K_EEPROM_VERSION_5_3) {
+ /* No spur info for 5GHz */
+ ee->ee_spur_chans[0][0] = AR5K_EEPROM_NO_SPUR;
+ /* 2 channels for 2GHz (2464/2420) */
+ ee->ee_spur_chans[0][1] = AR5K_EEPROM_5413_SPUR_CHAN_1;
+ ee->ee_spur_chans[1][1] = AR5K_EEPROM_5413_SPUR_CHAN_2;
+ ee->ee_spur_chans[2][1] = AR5K_EEPROM_NO_SPUR;
+ } else if (ee->ee_version >= AR5K_EEPROM_VERSION_5_3) {
+ for (i = 0; i < AR5K_EEPROM_N_SPUR_CHANS; i++) {
+ AR5K_EEPROM_READ(offset, val);
+ ee->ee_spur_chans[i][0] = val;
+ AR5K_EEPROM_READ(offset + AR5K_EEPROM_N_SPUR_CHANS,
+ val);
+ ee->ee_spur_chans[i][1] = val;
+ offset++;
+ }
+ }
+
+ return ret;
+}
/*
- * Initialize eeprom power tables
+ * Initialize eeprom data structure
*/
int
ath5k_eeprom_init(struct ath5k_hw *ah)
@@ -1719,6 +1761,10 @@ ath5k_eeprom_init(struct ath5k_hw *ah)
if (err < 0)
return err;
+ err = ath5k_eeprom_read_spur_chans(ah);
+ if (err < 0)
+ return err;
+
return 0;
}
@@ -1754,16 +1800,3 @@ int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
return 0;
}
-
-bool ath5k_eeprom_is_hb63(struct ath5k_hw *ah)
-{
- u16 data;
-
- ath5k_hw_eeprom_read(ah, AR5K_EEPROM_IS_HB63, &data);
-
- if ((ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4)) && data)
- return true;
- else
- return false;
-}
-
diff --git a/drivers/net/wireless/ath5k/eeprom.h b/drivers/net/wireless/ath/ath5k/eeprom.h
index b0c0606dea0b..64be73a5edae 100644
--- a/drivers/net/wireless/ath5k/eeprom.h
+++ b/drivers/net/wireless/ath/ath5k/eeprom.h
@@ -26,6 +26,13 @@
#define AR5K_EEPROM_MAGIC_5210 0x0000145a /* 5210 */
#define AR5K_EEPROM_IS_HB63 0x000b /* Talon detect */
+
+#define AR5K_EEPROM_RFKILL 0x0f
+#define AR5K_EEPROM_RFKILL_GPIO_SEL 0x0000001c
+#define AR5K_EEPROM_RFKILL_GPIO_SEL_S 2
+#define AR5K_EEPROM_RFKILL_POLARITY 0x00000002
+#define AR5K_EEPROM_RFKILL_POLARITY_S 1
+
#define AR5K_EEPROM_REG_DOMAIN 0x00bf /* EEPROM regdom */
#define AR5K_EEPROM_CHECKSUM 0x00c0 /* EEPROM checksum */
#define AR5K_EEPROM_INFO_BASE 0x00c0 /* EEPROM header */
@@ -66,11 +73,6 @@
#define AR5K_EEPROM_HDR_RFKILL(_v) (((_v) >> 14) & 0x1) /* Device has RFKill support */
#define AR5K_EEPROM_HDR_T_5GHZ_DIS(_v) (((_v) >> 15) & 0x1) /* Disable turbo for 5Ghz */
-#define AR5K_EEPROM_RFKILL_GPIO_SEL 0x0000001c
-#define AR5K_EEPROM_RFKILL_GPIO_SEL_S 2
-#define AR5K_EEPROM_RFKILL_POLARITY 0x00000002
-#define AR5K_EEPROM_RFKILL_POLARITY_S 1
-
/* Newer EEPROMs are using a different offset */
#define AR5K_EEPROM_OFF(_v, _v3_0, _v3_3) \
(((_v) >= AR5K_EEPROM_VERSION_3_3) ? _v3_3 : _v3_0)
@@ -211,6 +213,23 @@
#define AR5K_EEPROM_I_GAIN 10
#define AR5K_EEPROM_CCK_OFDM_DELTA 15
#define AR5K_EEPROM_N_IQ_CAL 2
+/* 5GHz/2GHz */
+enum ath5k_eeprom_freq_bands{
+ AR5K_EEPROM_BAND_5GHZ = 0,
+ AR5K_EEPROM_BAND_2GHZ = 1,
+ AR5K_EEPROM_N_FREQ_BANDS,
+};
+/* Spur chans per freq band */
+#define AR5K_EEPROM_N_SPUR_CHANS 5
+/* fbin value for chan 2464 x2 */
+#define AR5K_EEPROM_5413_SPUR_CHAN_1 1640
+/* fbin value for chan 2420 x2 */
+#define AR5K_EEPROM_5413_SPUR_CHAN_2 1200
+#define AR5K_EEPROM_SPUR_CHAN_MASK 0x3FFF
+#define AR5K_EEPROM_NO_SPUR 0x8000
+#define AR5K_SPUR_CHAN_WIDTH 87
+#define AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz 3125
+#define AR5K_SPUR_SYMBOL_WIDTH_TURBO_100Hz 6250
#define AR5K_EEPROM_READ(_o, _v) do { \
ret = ath5k_hw_eeprom_read(ah, (_o), &(_v)); \
@@ -221,11 +240,11 @@
#define AR5K_EEPROM_READ_HDR(_o, _v) \
AR5K_EEPROM_READ(_o, ah->ah_capabilities.cap_eeprom._v); \
-enum ath5k_ant_setting {
- AR5K_ANT_VARIABLE = 0, /* variable by programming */
- AR5K_ANT_FIXED_A = 1, /* fixed to 11a frequencies */
- AR5K_ANT_FIXED_B = 2, /* fixed to 11b frequencies */
- AR5K_ANT_MAX = 3,
+enum ath5k_ant_table {
+ AR5K_ANT_CTL = 0, /* Idle switch table settings */
+ AR5K_ANT_SWTABLE_A = 1, /* Switch table for antenna A */
+ AR5K_ANT_SWTABLE_B = 2, /* Switch table for antenna B */
+ AR5K_ANT_MAX,
};
enum ath5k_ctl_mode {
@@ -369,6 +388,9 @@ struct ath5k_eeprom_info {
u16 ee_version;
u16 ee_header;
u16 ee_ant_gain;
+ u8 ee_rfkill_pin;
+ bool ee_rfkill_pol;
+ bool ee_is_hb63;
u16 ee_misc0;
u16 ee_misc1;
u16 ee_misc2;
@@ -436,6 +458,10 @@ struct ath5k_eeprom_info {
s8 ee_pga_desired_size_turbo[AR5K_EEPROM_N_MODES];
s8 ee_pd_gain_overlap;
+ /* Spur mitigation data (fbin values for spur channels) */
+ u16 ee_spur_chans[AR5K_EEPROM_N_SPUR_CHANS][AR5K_EEPROM_N_FREQ_BANDS];
+
+ /* Antenna raw switch tables */
u32 ee_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
};
diff --git a/drivers/net/wireless/ath5k/gpio.c b/drivers/net/wireless/ath/ath5k/gpio.c
index 64a27e73d02e..64a27e73d02e 100644
--- a/drivers/net/wireless/ath5k/gpio.c
+++ b/drivers/net/wireless/ath/ath5k/gpio.c
diff --git a/drivers/net/wireless/ath5k/initvals.c b/drivers/net/wireless/ath/ath5k/initvals.c
index 61fb621ed20d..18eb5190ce4b 100644
--- a/drivers/net/wireless/ath5k/initvals.c
+++ b/drivers/net/wireless/ath/ath5k/initvals.c
@@ -537,8 +537,6 @@ static const struct ath5k_ini ar5212_ini_common_start[] = {
{ AR5K_DCU_TX_FILTER_1(15), 0x00000000 },
{ AR5K_DCU_TX_FILTER_CLR, 0x00000000 },
{ AR5K_DCU_TX_FILTER_SET, 0x00000000 },
- { AR5K_DCU_TX_FILTER_CLR, 0x00000000 },
- { AR5K_DCU_TX_FILTER_SET, 0x00000000 },
{ AR5K_STA_ID1, 0x00000000 },
{ AR5K_BSS_ID0, 0x00000000 },
{ AR5K_BSS_ID1, 0x00000000 },
@@ -669,7 +667,7 @@ static const struct ath5k_ini ar5212_ini_common_start[] = {
/*{ AR5K_PHY(650), 0x000001b5 },*/
{ AR5K_PHY(651), 0x00000000 },
{ AR5K_PHY_TXPOWER_RATE3, 0x20202020 },
- { AR5K_PHY_TXPOWER_RATE2, 0x20202020 },
+ { AR5K_PHY_TXPOWER_RATE4, 0x20202020 },
/*{ AR5K_PHY(655), 0x13c889af },*/
{ AR5K_PHY(656), 0x38490a20 },
{ AR5K_PHY(657), 0x00007bb6 },
@@ -718,7 +716,7 @@ static const struct ath5k_ini_mode ar5212_ini_mode_start[] = {
{ AR5K_PHY_SETTLING,
{ 0x1372161c, 0x13721c25, 0x13721722, 0x137216a2, 0x13721c25 } },
{ AR5K_PHY_AGCCTL,
- { 0x00009d10, 0x00009d10, 0x00009d18, 0x00009d18, 0x00009d18 } },
+ { 0x00009d10, 0x00009d10, 0x00009d18, 0x00009d18, 0x00009d10 } },
{ AR5K_PHY_NF,
{ 0x0001ce00, 0x0001ce00, 0x0001ce00, 0x0001ce00, 0x0001ce00 } },
{ AR5K_PHY_WEAK_OFDM_HIGH_THR,
@@ -799,7 +797,7 @@ static const struct ath5k_ini_mode rf5112_ini_mode_end[] = {
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0de8b4e0, 0x0de8b4e0, 0x0de8b4e0, 0x0de8b4e0, 0x0de8b4e0 } },
{ AR5K_PHY_SIG,
- { 0x7e800d2e, 0x7e800d2e, 0x7ee80d2e, 0x7ee80d2e, 0x7ee80d2e } },
+ { 0x7e800d2e, 0x7e800d2e, 0x7ee80d2e, 0x7ee80d2e, 0x7e800d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x3137665e, 0x3137665e, 0x3137665e, 0x3137665e, 0x3137665e } },
{ AR5K_PHY_WEAK_OFDM_LOW_THR,
diff --git a/drivers/net/wireless/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index 19555fb79c9b..876725f08b6c 100644
--- a/drivers/net/wireless/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -53,8 +53,6 @@
/* Devices we match on for LED config info (typically laptops) */
static const struct pci_device_id ath5k_led_devices[] = {
- /* IBM-specific AR5212 */
- { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) },
/* AR5211 */
{ PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5211), ATH_LED(0, 0) },
/* HP Compaq nc6xx, nc4000, nx6000 */
@@ -67,6 +65,12 @@ static const struct pci_device_id ath5k_led_devices[] = {
{ ATH_SDEVICE(PCI_VENDOR_ID_AMBIT, 0x0428), ATH_LED(3, 0) },
/* Acer Extensa 5620z (nekoreeve@gmail.com) */
{ ATH_SDEVICE(PCI_VENDOR_ID_QMI, 0x0105), ATH_LED(3, 0) },
+ /* Fukato Datacask Jupiter 1014a (mrb74@gmx.at) */
+ { ATH_SDEVICE(PCI_VENDOR_ID_AZWAVE, 0x1026), ATH_LED(3, 0) },
+ /* IBM ThinkPad AR5BXB6 (legovini@spiro.fisica.unipd.it) */
+ { ATH_SDEVICE(PCI_VENDOR_ID_IBM, 0x058a), ATH_LED(1, 0) },
+ /* IBM-specific AR5212 (all others) */
+ { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) },
{ }
};
@@ -78,7 +82,7 @@ void ath5k_led_enable(struct ath5k_softc *sc)
}
}
-void ath5k_led_on(struct ath5k_softc *sc)
+static void ath5k_led_on(struct ath5k_softc *sc)
{
if (!test_bit(ATH_STAT_LEDSOFT, sc->status))
return;
diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c
index 55122f1e1986..ec35503f6a40 100644
--- a/drivers/net/wireless/ath5k/pcu.c
+++ b/drivers/net/wireless/ath/ath5k/pcu.c
@@ -736,8 +736,8 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
/* When in AP mode zero timer0 to start TSF */
if (ah->ah_op_mode == NL80211_IFTYPE_AP)
ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
- else
- ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
+
+ ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
ath5k_hw_reg_write(ah, timer1, AR5K_TIMER1);
ath5k_hw_reg_write(ah, timer2, AR5K_TIMER2);
ath5k_hw_reg_write(ah, timer3, AR5K_TIMER3);
@@ -1003,7 +1003,7 @@ int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry)
* Note2: Windows driver (ndiswrapper) sets this to
* 0x00000714 instead of 0x00000007
*/
- if (ah->ah_version > AR5K_AR5211) {
+ if (ah->ah_version >= AR5K_AR5211) {
ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
AR5K_KEYTABLE_TYPE(entry));
@@ -1038,9 +1038,9 @@ int ath5k_keycache_type(const struct ieee80211_key_conf *key)
case ALG_CCMP:
return AR5K_KEYTABLE_TYPE_CCM;
case ALG_WEP:
- if (key->keylen == LEN_WEP40)
+ if (key->keylen == WLAN_KEY_LEN_WEP40)
return AR5K_KEYTABLE_TYPE_40;
- else if (key->keylen == LEN_WEP104)
+ else if (key->keylen == WLAN_KEY_LEN_WEP104)
return AR5K_KEYTABLE_TYPE_104;
return -EINVAL;
default:
diff --git a/drivers/net/wireless/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 9e2faae5ae94..a876ca8d69ef 100644
--- a/drivers/net/wireless/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -168,9 +168,6 @@ int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah)
* tx power and a Peak to Average Power Detector (PAPD) will try
* to measure the gain.
*
- * TODO: Use propper tx power setting for the probe packet so
- * that we don't observe a serious power drop on the receiver
- *
* XXX: How about forcing a tx packet (bypassing PCU arbitrator etc)
* just after we enable the probe so that we don't mess with
* standard traffic ? Maybe it's time to use sw interrupts and
@@ -186,7 +183,7 @@ static void ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah)
/* Send the packet with 2dB below max power as
* patent doc suggest */
- ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txpower.txp_max_pwr - 4,
+ ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txpower.txp_ofdm - 4,
AR5K_PHY_PAPD_PROBE_TXPOWER) |
AR5K_PHY_PAPD_PROBE_TX_NEXT, AR5K_PHY_PAPD_PROBE);
@@ -1356,6 +1353,257 @@ int ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
return ret;
}
+/***************************\
+* Spur mitigation functions *
+\***************************/
+
+bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
+ struct ieee80211_channel *channel)
+{
+ u8 refclk_freq;
+
+ if ((ah->ah_radio == AR5K_RF5112) ||
+ (ah->ah_radio == AR5K_RF5413) ||
+ (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4)))
+ refclk_freq = 40;
+ else
+ refclk_freq = 32;
+
+ if ((channel->center_freq % refclk_freq != 0) &&
+ ((channel->center_freq % refclk_freq < 10) ||
+ (channel->center_freq % refclk_freq > 22)))
+ return true;
+ else
+ return false;
+}
+
+void
+ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah,
+ struct ieee80211_channel *channel)
+{
+ struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
+ u32 mag_mask[4] = {0, 0, 0, 0};
+ u32 pilot_mask[2] = {0, 0};
+ /* Note: fbin values are scaled up by 2 */
+ u16 spur_chan_fbin, chan_fbin, symbol_width, spur_detection_window;
+ s32 spur_delta_phase, spur_freq_sigma_delta;
+ s32 spur_offset, num_symbols_x16;
+ u8 num_symbol_offsets, i, freq_band;
+
+ /* Convert current frequency to fbin value (the same way channels
+ * are stored on EEPROM, check out ath5k_eeprom_bin2freq) and scale
+ * up by 2 so we can compare it later */
+ if (channel->hw_value & CHANNEL_2GHZ) {
+ chan_fbin = (channel->center_freq - 2300) * 10;
+ freq_band = AR5K_EEPROM_BAND_2GHZ;
+ } else {
+ chan_fbin = (channel->center_freq - 4900) * 10;
+ freq_band = AR5K_EEPROM_BAND_5GHZ;
+ }
+
+ /* Check if any spur_chan_fbin from EEPROM is
+ * within our current channel's spur detection range */
+ spur_chan_fbin = AR5K_EEPROM_NO_SPUR;
+ spur_detection_window = AR5K_SPUR_CHAN_WIDTH;
+ /* XXX: Half/Quarter channels ?*/
+ if (channel->hw_value & CHANNEL_TURBO)
+ spur_detection_window *= 2;
+
+ for (i = 0; i < AR5K_EEPROM_N_SPUR_CHANS; i++) {
+ spur_chan_fbin = ee->ee_spur_chans[i][freq_band];
+
+ /* Note: mask cleans AR5K_EEPROM_NO_SPUR flag
+ * so it's zero if we got nothing from EEPROM */
+ if (spur_chan_fbin == AR5K_EEPROM_NO_SPUR) {
+ spur_chan_fbin &= AR5K_EEPROM_SPUR_CHAN_MASK;
+ break;
+ }
+
+ if ((chan_fbin - spur_detection_window <=
+ (spur_chan_fbin & AR5K_EEPROM_SPUR_CHAN_MASK)) &&
+ (chan_fbin + spur_detection_window >=
+ (spur_chan_fbin & AR5K_EEPROM_SPUR_CHAN_MASK))) {
+ spur_chan_fbin &= AR5K_EEPROM_SPUR_CHAN_MASK;
+ break;
+ }
+ }
+
+ /* We need to enable spur filter for this channel */
+ if (spur_chan_fbin) {
+ spur_offset = spur_chan_fbin - chan_fbin;
+ /*
+ * Calculate deltas:
+ * spur_freq_sigma_delta -> spur_offset / sample_freq << 21
+ * spur_delta_phase -> spur_offset / chip_freq << 11
+ * Note: Both values have 100KHz resolution
+ */
+ /* XXX: Half/Quarter rate channels ? */
+ switch (channel->hw_value) {
+ case CHANNEL_A:
+ /* Both sample_freq and chip_freq are 40MHz */
+ spur_delta_phase = (spur_offset << 17) / 25;
+ spur_freq_sigma_delta = (spur_delta_phase >> 10);
+ symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz;
+ break;
+ case CHANNEL_G:
+ /* sample_freq -> 40MHz chip_freq -> 44MHz
+ * (for b compatibility) */
+ spur_freq_sigma_delta = (spur_offset << 8) / 55;
+ spur_delta_phase = (spur_offset << 17) / 25;
+ symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz;
+ break;
+ case CHANNEL_T:
+ case CHANNEL_TG:
+ /* Both sample_freq and chip_freq are 80MHz */
+ spur_delta_phase = (spur_offset << 16) / 25;
+ spur_freq_sigma_delta = (spur_delta_phase >> 10);
+ symbol_width = AR5K_SPUR_SYMBOL_WIDTH_TURBO_100Hz;
+ break;
+ default:
+ return;
+ }
+
+ /* Calculate pilot and magnitude masks */
+
+ /* Scale up spur_offset by 1000 to switch to 100HZ resolution
+ * and divide by symbol_width to find how many symbols we have
+ * Note: number of symbols is scaled up by 16 */
+ num_symbols_x16 = ((spur_offset * 1000) << 4) / symbol_width;
+
+ /* Spur is on a symbol if num_symbols_x16 % 16 is zero */
+ if (!(num_symbols_x16 & 0xF))
+ /* _X_ */
+ num_symbol_offsets = 3;
+ else
+ /* _xx_ */
+ num_symbol_offsets = 4;
+
+ for (i = 0; i < num_symbol_offsets; i++) {
+
+ /* Calculate pilot mask */
+ s32 curr_sym_off =
+ (num_symbols_x16 / 16) + i + 25;
+
+ /* Pilot magnitude mask seems to be a way to
+ * declare the boundaries for our detection
+ * window or something, it's 2 for the middle
+ * value(s) where the symbol is expected to be
+ * and 1 on the boundary values */
+ u8 plt_mag_map =
+ (i == 0 || i == (num_symbol_offsets - 1))
+ ? 1 : 2;
+
+ if (curr_sym_off >= 0 && curr_sym_off <= 32) {
+ if (curr_sym_off <= 25)
+ pilot_mask[0] |= 1 << curr_sym_off;
+ else if (curr_sym_off >= 27)
+ pilot_mask[0] |= 1 << (curr_sym_off - 1);
+ } else if (curr_sym_off >= 33 && curr_sym_off <= 52)
+ pilot_mask[1] |= 1 << (curr_sym_off - 33);
+
+ /* Calculate magnitude mask (for viterbi decoder) */
+ if (curr_sym_off >= -1 && curr_sym_off <= 14)
+ mag_mask[0] |=
+ plt_mag_map << (curr_sym_off + 1) * 2;
+ else if (curr_sym_off >= 15 && curr_sym_off <= 30)
+ mag_mask[1] |=
+ plt_mag_map << (curr_sym_off - 15) * 2;
+ else if (curr_sym_off >= 31 && curr_sym_off <= 46)
+ mag_mask[2] |=
+ plt_mag_map << (curr_sym_off - 31) * 2;
+ else if (curr_sym_off >= 46 && curr_sym_off <= 53)
+ mag_mask[3] |=
+ plt_mag_map << (curr_sym_off - 47) * 2;
+
+ }
+
+ /* Write settings on hw to enable spur filter */
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK_CTL,
+ AR5K_PHY_BIN_MASK_CTL_RATE, 0xff);
+ /* XXX: Self correlator also ? */
+ AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ,
+ AR5K_PHY_IQ_PILOT_MASK_EN |
+ AR5K_PHY_IQ_CHAN_MASK_EN |
+ AR5K_PHY_IQ_SPUR_FILT_EN);
+
+ /* Set delta phase and freq sigma delta */
+ ath5k_hw_reg_write(ah,
+ AR5K_REG_SM(spur_delta_phase,
+ AR5K_PHY_TIMING_11_SPUR_DELTA_PHASE) |
+ AR5K_REG_SM(spur_freq_sigma_delta,
+ AR5K_PHY_TIMING_11_SPUR_FREQ_SD) |
+ AR5K_PHY_TIMING_11_USE_SPUR_IN_AGC,
+ AR5K_PHY_TIMING_11);
+
+ /* Write pilot masks */
+ ath5k_hw_reg_write(ah, pilot_mask[0], AR5K_PHY_TIMING_7);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_TIMING_8,
+ AR5K_PHY_TIMING_8_PILOT_MASK_2,
+ pilot_mask[1]);
+
+ ath5k_hw_reg_write(ah, pilot_mask[0], AR5K_PHY_TIMING_9);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_TIMING_10,
+ AR5K_PHY_TIMING_10_PILOT_MASK_2,
+ pilot_mask[1]);
+
+ /* Write magnitude masks */
+ ath5k_hw_reg_write(ah, mag_mask[0], AR5K_PHY_BIN_MASK_1);
+ ath5k_hw_reg_write(ah, mag_mask[1], AR5K_PHY_BIN_MASK_2);
+ ath5k_hw_reg_write(ah, mag_mask[2], AR5K_PHY_BIN_MASK_3);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK_CTL,
+ AR5K_PHY_BIN_MASK_CTL_MASK_4,
+ mag_mask[3]);
+
+ ath5k_hw_reg_write(ah, mag_mask[0], AR5K_PHY_BIN_MASK2_1);
+ ath5k_hw_reg_write(ah, mag_mask[1], AR5K_PHY_BIN_MASK2_2);
+ ath5k_hw_reg_write(ah, mag_mask[2], AR5K_PHY_BIN_MASK2_3);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK2_4,
+ AR5K_PHY_BIN_MASK2_4_MASK_4,
+ mag_mask[3]);
+
+ } else if (ath5k_hw_reg_read(ah, AR5K_PHY_IQ) &
+ AR5K_PHY_IQ_SPUR_FILT_EN) {
+ /* Clean up spur mitigation settings and disable fliter */
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK_CTL,
+ AR5K_PHY_BIN_MASK_CTL_RATE, 0);
+ AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_IQ,
+ AR5K_PHY_IQ_PILOT_MASK_EN |
+ AR5K_PHY_IQ_CHAN_MASK_EN |
+ AR5K_PHY_IQ_SPUR_FILT_EN);
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_TIMING_11);
+
+ /* Clear pilot masks */
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_TIMING_7);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_TIMING_8,
+ AR5K_PHY_TIMING_8_PILOT_MASK_2,
+ 0);
+
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_TIMING_9);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_TIMING_10,
+ AR5K_PHY_TIMING_10_PILOT_MASK_2,
+ 0);
+
+ /* Clear magnitude masks */
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_BIN_MASK_1);
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_BIN_MASK_2);
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_BIN_MASK_3);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK_CTL,
+ AR5K_PHY_BIN_MASK_CTL_MASK_4,
+ 0);
+
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_BIN_MASK2_1);
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_BIN_MASK2_2);
+ ath5k_hw_reg_write(ah, 0, AR5K_PHY_BIN_MASK2_3);
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_BIN_MASK2_4,
+ AR5K_PHY_BIN_MASK2_4_MASK_4,
+ 0);
+ }
+}
+
+/********************\
+ Misc PHY functions
+\********************/
+
int ath5k_hw_phy_disable(struct ath5k_hw *ah)
{
ATH5K_TRACE(ah->ah_sc);
@@ -1365,10 +1613,6 @@ int ath5k_hw_phy_disable(struct ath5k_hw *ah)
return 0;
}
-/********************\
- Misc PHY functions
-\********************/
-
/*
* Get the PHY Chip revision
*/
@@ -1417,25 +1661,189 @@ u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan)
return ret;
}
+/*****************\
+* Antenna control *
+\*****************/
+
void /*TODO:Boundary check*/
-ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant)
+ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant)
{
ATH5K_TRACE(ah->ah_sc);
- /*Just a try M.F.*/
+
if (ah->ah_version != AR5K_AR5210)
- ath5k_hw_reg_write(ah, ant, AR5K_DEFAULT_ANTENNA);
+ ath5k_hw_reg_write(ah, ant & 0x7, AR5K_DEFAULT_ANTENNA);
}
unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah)
{
ATH5K_TRACE(ah->ah_sc);
- /*Just a try M.F.*/
+
if (ah->ah_version != AR5K_AR5210)
- return ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA);
+ return ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA) & 0x7;
return false; /*XXX: What do we return for 5210 ?*/
}
+/*
+ * Enable/disable fast rx antenna diversity
+ */
+static void
+ath5k_hw_set_fast_div(struct ath5k_hw *ah, u8 ee_mode, bool enable)
+{
+ switch (ee_mode) {
+ case AR5K_EEPROM_MODE_11G:
+ /* XXX: This is set to
+ * disabled on initvals !!! */
+ case AR5K_EEPROM_MODE_11A:
+ if (enable)
+ AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_AGCCTL,
+ AR5K_PHY_AGCCTL_OFDM_DIV_DIS);
+ else
+ AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_AGCCTL,
+ AR5K_PHY_AGCCTL_OFDM_DIV_DIS);
+ break;
+ case AR5K_EEPROM_MODE_11B:
+ AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_AGCCTL,
+ AR5K_PHY_AGCCTL_OFDM_DIV_DIS);
+ break;
+ default:
+ return;
+ }
+
+ if (enable) {
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_RESTART,
+ AR5K_PHY_RESTART_DIV_GC, 0xc);
+
+ AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_FAST_ANT_DIV,
+ AR5K_PHY_FAST_ANT_DIV_EN);
+ } else {
+ AR5K_REG_WRITE_BITS(ah, AR5K_PHY_RESTART,
+ AR5K_PHY_RESTART_DIV_GC, 0x8);
+
+ AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_FAST_ANT_DIV,
+ AR5K_PHY_FAST_ANT_DIV_EN);
+ }
+}
+
+/*
+ * Set antenna operating mode
+ */
+void
+ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
+{
+ struct ieee80211_channel *channel = &ah->ah_current_channel;
+ bool use_def_for_tx, update_def_on_tx, use_def_for_rts, fast_div;
+ bool use_def_for_sg;
+ u8 def_ant, tx_ant, ee_mode;
+ u32 sta_id1 = 0;
+
+ def_ant = ah->ah_def_ant;
+
+ ATH5K_TRACE(ah->ah_sc);
+
+ switch (channel->hw_value & CHANNEL_MODES) {
+ case CHANNEL_A:
+ case CHANNEL_T:
+ case CHANNEL_XR:
+ ee_mode = AR5K_EEPROM_MODE_11A;
+ break;
+ case CHANNEL_G:
+ case CHANNEL_TG:
+ ee_mode = AR5K_EEPROM_MODE_11G;
+ break;
+ case CHANNEL_B:
+ ee_mode = AR5K_EEPROM_MODE_11B;
+ break;
+ default:
+ ATH5K_ERR(ah->ah_sc,
+ "invalid channel: %d\n", channel->center_freq);
+ return;
+ }
+
+ switch (ant_mode) {
+ case AR5K_ANTMODE_DEFAULT:
+ tx_ant = 0;
+ use_def_for_tx = false;
+ update_def_on_tx = false;
+ use_def_for_rts = false;
+ use_def_for_sg = false;
+ fast_div = true;
+ break;
+ case AR5K_ANTMODE_FIXED_A:
+ def_ant = 1;
+ tx_ant = 0;
+ use_def_for_tx = true;
+ update_def_on_tx = false;
+ use_def_for_rts = true;
+ use_def_for_sg = true;
+ fast_div = false;
+ break;
+ case AR5K_ANTMODE_FIXED_B:
+ def_ant = 2;
+ tx_ant = 0;
+ use_def_for_tx = true;
+ update_def_on_tx = false;
+ use_def_for_rts = true;
+ use_def_for_sg = true;
+ fast_div = false;
+ break;
+ case AR5K_ANTMODE_SINGLE_AP:
+ def_ant = 1; /* updated on tx */
+ tx_ant = 0;
+ use_def_for_tx = true;
+ update_def_on_tx = true;
+ use_def_for_rts = true;
+ use_def_for_sg = true;
+ fast_div = true;
+ break;
+ case AR5K_ANTMODE_SECTOR_AP:
+ tx_ant = 1; /* variable */
+ use_def_for_tx = false;
+ update_def_on_tx = false;
+ use_def_for_rts = true;
+ use_def_for_sg = false;
+ fast_div = false;
+ break;
+ case AR5K_ANTMODE_SECTOR_STA:
+ tx_ant = 1; /* variable */
+ use_def_for_tx = true;
+ update_def_on_tx = false;
+ use_def_for_rts = true;
+ use_def_for_sg = false;
+ fast_div = true;
+ break;
+ case AR5K_ANTMODE_DEBUG:
+ def_ant = 1;
+ tx_ant = 2;
+ use_def_for_tx = false;
+ update_def_on_tx = false;
+ use_def_for_rts = false;
+ use_def_for_sg = false;
+ fast_div = false;
+ break;
+ default:
+ return;
+ }
+
+ ah->ah_tx_ant = tx_ant;
+ ah->ah_ant_mode = ant_mode;
+
+ sta_id1 |= use_def_for_tx ? AR5K_STA_ID1_DEFAULT_ANTENNA : 0;
+ sta_id1 |= update_def_on_tx ? AR5K_STA_ID1_DESC_ANTENNA : 0;
+ sta_id1 |= use_def_for_rts ? AR5K_STA_ID1_RTS_DEF_ANTENNA : 0;
+ sta_id1 |= use_def_for_sg ? AR5K_STA_ID1_SELFGEN_DEF_ANT : 0;
+
+ AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_ANTENNA_SETTINGS);
+
+ if (sta_id1)
+ AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1, sta_id1);
+
+ /* Note: set diversity before default antenna
+ * because it won't work correctly */
+ ath5k_hw_set_fast_div(ah, ee_mode, fast_div);
+ ath5k_hw_set_def_antenna(ah, def_ant);
+}
+
/****************\
* TX power setup *
@@ -1487,28 +1895,38 @@ ath5k_get_linear_pcdac_min(const u8 *stepL, const u8 *stepR,
{
s8 tmp;
s16 min_pwrL, min_pwrR;
- s16 pwr_i = pwrL[0];
-
- do {
- pwr_i--;
- tmp = (s8) ath5k_get_interpolated_value(pwr_i,
- pwrL[0], pwrL[1],
- stepL[0], stepL[1]);
-
- } while (tmp > 1);
+ s16 pwr_i;
- min_pwrL = pwr_i;
-
- pwr_i = pwrR[0];
- do {
- pwr_i--;
- tmp = (s8) ath5k_get_interpolated_value(pwr_i,
- pwrR[0], pwrR[1],
- stepR[0], stepR[1]);
+ if (WARN_ON(stepL[0] == stepL[1] || stepR[0] == stepR[1]))
+ return 0;
- } while (tmp > 1);
+ if (pwrL[0] == pwrL[1])
+ min_pwrL = pwrL[0];
+ else {
+ pwr_i = pwrL[0];
+ do {
+ pwr_i--;
+ tmp = (s8) ath5k_get_interpolated_value(pwr_i,
+ pwrL[0], pwrL[1],
+ stepL[0], stepL[1]);
+ } while (tmp > 1);
+
+ min_pwrL = pwr_i;
+ }
- min_pwrR = pwr_i;
+ if (pwrR[0] == pwrR[1])
+ min_pwrR = pwrR[0];
+ else {
+ pwr_i = pwrR[0];
+ do {
+ pwr_i--;
+ tmp = (s8) ath5k_get_interpolated_value(pwr_i,
+ pwrR[0], pwrR[1],
+ stepR[0], stepR[1]);
+ } while (tmp > 1);
+
+ min_pwrR = pwr_i;
+ }
/* Keep the right boundary so that it works for both curves */
return max(min_pwrL, min_pwrR);
@@ -1743,8 +2161,6 @@ done:
* Get the max edge power for this channel if
* we have such data from EEPROM's Conformance Test
* Limits (CTL), and limit max power if needed.
- *
- * FIXME: Only works for world regulatory domains
*/
static void
ath5k_get_max_ctl_power(struct ath5k_hw *ah,
@@ -1760,26 +2176,23 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah,
u8 ctl_idx = 0xFF;
u32 target = channel->center_freq;
- /* Find out a CTL for our mode that's not mapped
- * on a specific reg domain.
- *
- * TODO: Map our current reg domain to one of the 3 available
- * reg domain ids so that we can support more CTLs. */
+ ctl_mode = ath_regd_get_band_ctl(&ah->ah_regulatory, channel->band);
+
switch (channel->hw_value & CHANNEL_MODES) {
case CHANNEL_A:
- ctl_mode = AR5K_CTL_11A | AR5K_CTL_NO_REGDOMAIN;
+ ctl_mode |= AR5K_CTL_11A;
break;
case CHANNEL_G:
- ctl_mode = AR5K_CTL_11G | AR5K_CTL_NO_REGDOMAIN;
+ ctl_mode |= AR5K_CTL_11G;
break;
case CHANNEL_B:
- ctl_mode = AR5K_CTL_11B | AR5K_CTL_NO_REGDOMAIN;
+ ctl_mode |= AR5K_CTL_11B;
break;
case CHANNEL_T:
- ctl_mode = AR5K_CTL_TURBO | AR5K_CTL_NO_REGDOMAIN;
+ ctl_mode |= AR5K_CTL_TURBO;
break;
case CHANNEL_TG:
- ctl_mode = AR5K_CTL_TURBOG | AR5K_CTL_NO_REGDOMAIN;
+ ctl_mode |= AR5K_CTL_TURBOG;
break;
case CHANNEL_XR:
/* Fall through */
@@ -2475,8 +2888,19 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
for (i = 8; i <= 15; i++)
rates[i] -= ah->ah_txpower.txp_cck_ofdm_gainf_delta;
- ah->ah_txpower.txp_min_pwr = rates[7];
- ah->ah_txpower.txp_max_pwr = rates[0];
+ /* Now that we have all rates setup use table offset to
+ * match the power range set by user with the power indices
+ * on PCDAC/PDADC table */
+ for (i = 0; i < 16; i++) {
+ rates[i] += ah->ah_txpower.txp_offset;
+ /* Don't get out of bounds */
+ if (rates[i] > 63)
+ rates[i] = 63;
+ }
+
+ /* Min/max in 0.25dB units */
+ ah->ah_txpower.txp_min_pwr = 2 * rates[7];
+ ah->ah_txpower.txp_max_pwr = 2 * rates[0];
ah->ah_txpower.txp_ofdm = rates[7];
}
@@ -2584,16 +3008,37 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
return 0;
}
-int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 mode, u8 txpower)
+int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
{
/*Just a try M.F.*/
struct ieee80211_channel *channel = &ah->ah_current_channel;
+ u8 ee_mode;
ATH5K_TRACE(ah->ah_sc);
+
+ switch (channel->hw_value & CHANNEL_MODES) {
+ case CHANNEL_A:
+ case CHANNEL_T:
+ case CHANNEL_XR:
+ ee_mode = AR5K_EEPROM_MODE_11A;
+ break;
+ case CHANNEL_G:
+ case CHANNEL_TG:
+ ee_mode = AR5K_EEPROM_MODE_11G;
+ break;
+ case CHANNEL_B:
+ ee_mode = AR5K_EEPROM_MODE_11B;
+ break;
+ default:
+ ATH5K_ERR(ah->ah_sc,
+ "invalid channel: %d\n", channel->center_freq);
+ return -EINVAL;
+ }
+
ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER,
"changing txpower to %d\n", txpower);
- return ath5k_hw_txpower(ah, channel, mode, txpower);
+ return ath5k_hw_txpower(ah, channel, ee_mode, txpower);
}
#undef _ATH5K_PHY
diff --git a/drivers/net/wireless/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c
index 5094c394a4b2..73407b3f53ef 100644
--- a/drivers/net/wireless/ath5k/qcu.c
+++ b/drivers/net/wireless/ath/ath5k/qcu.c
@@ -160,7 +160,8 @@ u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue)
if (ah->ah_version == AR5K_AR5210)
return false;
- pending = (AR5K_QUEUE_STATUS(queue) & AR5K_QCU_STS_FRMPENDCNT);
+ pending = ath5k_hw_reg_read(ah, AR5K_QUEUE_STATUS(queue));
+ pending &= AR5K_QCU_STS_FRMPENDCNT;
/* It's possible to have no frames pending even if TXE
* is set. To indicate that q has not stopped return
@@ -401,14 +402,16 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue)
AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_DFS_MISC(queue),
(AR5K_DCU_MISC_ARBLOCK_CTL_GLOBAL <<
AR5K_DCU_MISC_ARBLOCK_CTL_S) |
+ AR5K_DCU_MISC_ARBLOCK_IGNORE |
AR5K_DCU_MISC_POST_FR_BKOFF_DIS |
AR5K_DCU_MISC_BCN_ENABLE);
break;
case AR5K_TX_QUEUE_CAB:
AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue),
- AR5K_QCU_MISC_FRSHED_DBA_GT |
+ AR5K_QCU_MISC_FRSHED_BCN_SENT_GT |
AR5K_QCU_MISC_CBREXP_DIS |
+ AR5K_QCU_MISC_RDY_VEOL_POLICY |
AR5K_QCU_MISC_CBREXP_BCN_DIS);
ath5k_hw_reg_write(ah, ((AR5K_TUNE_BEACON_INTERVAL -
diff --git a/drivers/net/wireless/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h
index 7070d1543cdc..6809b54a2ad7 100644
--- a/drivers/net/wireless/ath5k/reg.h
+++ b/drivers/net/wireless/ath/ath5k/reg.h
@@ -1148,6 +1148,11 @@
#define AR5K_STA_ID1_CBCIV_ENDIAN 0x40000000 /* ??? */
#define AR5K_STA_ID1_KEYSRCH_MCAST 0x80000000 /* Do key cache search for mcast frames */
+#define AR5K_STA_ID1_ANTENNA_SETTINGS (AR5K_STA_ID1_DEFAULT_ANTENNA | \
+ AR5K_STA_ID1_DESC_ANTENNA | \
+ AR5K_STA_ID1_RTS_DEF_ANTENNA | \
+ AR5K_STA_ID1_SELFGEN_DEF_ANT)
+
/*
* First BSSID register (MAC address, lower 32bits)
*/
@@ -2028,7 +2033,9 @@
#define AR5K_PHY_AGCCTL 0x9860 /* Register address */
#define AR5K_PHY_AGCCTL_CAL 0x00000001 /* Enable PHY calibration */
#define AR5K_PHY_AGCCTL_NF 0x00000002 /* Enable Noise Floor calibration */
+#define AR5K_PHY_AGCCTL_OFDM_DIV_DIS 0x00000008 /* Disable antenna diversity on OFDM modes */
#define AR5K_PHY_AGCCTL_NF_EN 0x00008000 /* Enable nf calibration to happen (?) */
+#define AR5K_PHY_AGCTL_FLTR_CAL 0x00010000 /* Allow filter calibration (?) */
#define AR5K_PHY_AGCCTL_NF_NOUPDATE 0x00020000 /* Don't update nf automaticaly */
/*
@@ -2528,7 +2535,7 @@
* PHY CCK Cross-correlator Barker RSSI threshold register [5212+]
*/
#define AR5K_PHY_CCK_CROSSCORR 0xa208
-#define AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR 0x0000000f
+#define AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR 0x0000003f
#define AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR_S 0
/* Same address is used for antenna diversity activation */
diff --git a/drivers/net/wireless/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index 7a17d31b2fd9..66067733ddd3 100644
--- a/drivers/net/wireless/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -26,7 +26,7 @@
\*****************************/
#include <linux/pci.h> /* To determine if a card is pci-e */
-#include <linux/bitops.h> /* For get_bitmask_order */
+#include <linux/log2.h>
#include "ath5k.h"
#include "reg.h"
#include "base.h"
@@ -54,9 +54,8 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,
u32 coef_scaled, coef_exp, coef_man,
ds_coef_exp, ds_coef_man, clock;
- if (!(ah->ah_version == AR5K_AR5212) ||
- !(channel->hw_value & CHANNEL_OFDM))
- BUG();
+ BUG_ON(!(ah->ah_version == AR5K_AR5212) ||
+ !(channel->hw_value & CHANNEL_OFDM));
/* Get coefficient
* ALGO: coef = (5 * clock * carrier_freq) / 2)
@@ -69,10 +68,10 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,
/* Get exponent
* ALGO: coef_exp = 14 - highest set bit position */
- coef_exp = get_bitmask_order(coef_scaled);
+ coef_exp = ilog2(coef_scaled);
/* Doesn't make sense if it's zero*/
- if (!coef_exp)
+ if (!coef_scaled || !coef_exp)
return -EINVAL;
/* Note: we've shifted coef_scaled by 24 */
@@ -359,7 +358,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
mode |= AR5K_PHY_MODE_FREQ_5GHZ;
if (ah->ah_radio == AR5K_RF5413)
- clock |= AR5K_PHY_PLL_40MHZ_5413;
+ clock = AR5K_PHY_PLL_40MHZ_5413;
else
clock |= AR5K_PHY_PLL_40MHZ;
@@ -508,7 +507,7 @@ static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable)
if (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4))
scal = AR5K_PHY_SCAL_32MHZ_2417;
- else if (ath5k_eeprom_is_hb63(ah))
+ else if (ee->ee_is_hb63)
scal = AR5K_PHY_SCAL_32MHZ_HB63;
else
scal = AR5K_PHY_SCAL_32MHZ;
@@ -537,26 +536,6 @@ static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable)
return;
}
-static bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
- struct ieee80211_channel *channel)
-{
- u8 refclk_freq;
-
- if ((ah->ah_radio == AR5K_RF5112) ||
- (ah->ah_radio == AR5K_RF5413) ||
- (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4)))
- refclk_freq = 40;
- else
- refclk_freq = 32;
-
- if ((channel->center_freq % refclk_freq != 0) &&
- ((channel->center_freq % refclk_freq < 10) ||
- (channel->center_freq % refclk_freq > 22)))
- return true;
- else
- return false;
-}
-
/* TODO: Half/Quarter rate */
static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah,
struct ieee80211_channel *channel)
@@ -599,9 +578,10 @@ static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah,
/* Set DAC/ADC delays */
if (ah->ah_version == AR5K_AR5212) {
u32 scal;
+ struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
if (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4))
scal = AR5K_PHY_SCAL_32MHZ_2417;
- else if (ath5k_eeprom_is_hb63(ah))
+ else if (ee->ee_is_hb63)
scal = AR5K_PHY_SCAL_32MHZ_HB63;
else
scal = AR5K_PHY_SCAL_32MHZ;
@@ -698,13 +678,13 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
/* Set antenna idle switch table */
AR5K_REG_WRITE_BITS(ah, AR5K_PHY_ANT_CTL,
AR5K_PHY_ANT_CTL_SWTABLE_IDLE,
- (ah->ah_antenna[ee_mode][0] |
+ (ah->ah_ant_ctl[ee_mode][0] |
AR5K_PHY_ANT_CTL_TXRX_EN));
- /* Set antenna switch table */
- ath5k_hw_reg_write(ah, ah->ah_antenna[ee_mode][ant[0]],
+ /* Set antenna switch tables */
+ ath5k_hw_reg_write(ah, ah->ah_ant_ctl[ee_mode][ant[0]],
AR5K_PHY_ANT_SWITCH_TABLE_0);
- ath5k_hw_reg_write(ah, ah->ah_antenna[ee_mode][ant[1]],
+ ath5k_hw_reg_write(ah, ah->ah_ant_ctl[ee_mode][ant[1]],
AR5K_PHY_ANT_SWITCH_TABLE_1);
/* Noise floor threshold */
@@ -998,10 +978,10 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
ath5k_hw_tweak_initval_settings(ah, channel);
/*
- * Set TX power (FIXME)
+ * Set TX power
*/
ret = ath5k_hw_txpower(ah, channel, ee_mode,
- AR5K_TUNE_DEFAULT_TXPOWER);
+ ah->ah_txpower.txp_max_pwr / 2);
if (ret)
return ret;
@@ -1024,9 +1004,22 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
/* Write OFDM timings on 5212*/
if (ah->ah_version == AR5K_AR5212 &&
channel->hw_value & CHANNEL_OFDM) {
+ struct ath5k_eeprom_info *ee =
+ &ah->ah_capabilities.cap_eeprom;
+
ret = ath5k_hw_write_ofdm_timings(ah, channel);
if (ret)
return ret;
+
+ /* Note: According to docs we can have a newer
+ * EEPROM on old hardware, so we need to verify
+ * that our hardware is new enough to have spur
+ * mitigation registers (delta phase etc) */
+ if (ah->ah_mac_srev >= AR5K_SREV_AR5424 ||
+ (ah->ah_mac_srev >= AR5K_SREV_AR5424 &&
+ ee->ee_version >= AR5K_EEPROM_VERSION_5_3))
+ ath5k_hw_set_spur_mitigation_filter(ah,
+ channel);
}
/*Enable/disable 802.11b mode on 5111
@@ -1042,17 +1035,15 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
/*
* In case a fixed antenna was set as default
- * write the same settings on both AR5K_PHY_ANT_SWITCH_TABLE
- * registers.
+ * use the same switch table twice.
*/
- if (s_ant != 0) {
- if (s_ant == AR5K_ANT_FIXED_A) /* 1 - Main */
- ant[0] = ant[1] = AR5K_ANT_FIXED_A;
- else /* 2 - Aux */
- ant[0] = ant[1] = AR5K_ANT_FIXED_B;
- } else {
- ant[0] = AR5K_ANT_FIXED_A;
- ant[1] = AR5K_ANT_FIXED_B;
+ if (ah->ah_ant_mode == AR5K_ANTMODE_FIXED_A)
+ ant[0] = ant[1] = AR5K_ANT_SWTABLE_A;
+ else if (ah->ah_ant_mode == AR5K_ANTMODE_FIXED_B)
+ ant[0] = ant[1] = AR5K_ANT_SWTABLE_B;
+ else {
+ ant[0] = AR5K_ANT_SWTABLE_A;
+ ant[1] = AR5K_ANT_SWTABLE_B;
}
/* Commit values from EEPROM */
@@ -1260,6 +1251,8 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
*/
ath5k_hw_noise_floor_calibration(ah, channel->center_freq);
+ /* Restore antenna mode */
+ ath5k_hw_set_antenna_mode(ah, ah->ah_ant_mode);
/*
* Configure QCUs/DCUs
diff --git a/drivers/net/wireless/ath5k/rfbuffer.h b/drivers/net/wireless/ath/ath5k/rfbuffer.h
index e50baff66175..e50baff66175 100644
--- a/drivers/net/wireless/ath5k/rfbuffer.h
+++ b/drivers/net/wireless/ath/ath5k/rfbuffer.h
diff --git a/drivers/net/wireless/ath5k/rfgain.h b/drivers/net/wireless/ath/ath5k/rfgain.h
index 1354d8c392c8..1354d8c392c8 100644
--- a/drivers/net/wireless/ath5k/rfgain.h
+++ b/drivers/net/wireless/ath/ath5k/rfgain.h
diff --git a/drivers/net/wireless/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 90a8dd873786..0ed1ac312aa6 100644
--- a/drivers/net/wireless/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -2,6 +2,7 @@ config ATH9K
tristate "Atheros 802.11n wireless cards support"
depends on PCI && MAC80211 && WLAN_80211
depends on RFKILL || RFKILL=n
+ select ATH_COMMON
select MAC80211_LEDS
select LEDS_CLASS
select NEW_LEDS
diff --git a/drivers/net/wireless/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index 1a4d4eab6fe8..783bc39eb2ff 100644
--- a/drivers/net/wireless/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -4,7 +4,6 @@ ath9k-y += hw.o \
calib.o \
ani.o \
phy.o \
- regd.o \
beacon.o \
main.o \
recv.o \
diff --git a/drivers/net/wireless/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index 0e65c51ba176..0e65c51ba176 100644
--- a/drivers/net/wireless/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
diff --git a/drivers/net/wireless/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index 6c5e887d50d7..1aeafb511ddd 100644
--- a/drivers/net/wireless/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -569,8 +569,7 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
DPRINTF(ah->ah_sc, ATH_DBG_ANI,
"phyCnt1 0x%x, resetting "
"counter value to 0x%x\n",
- phyCnt1,
- aniState->ofdmPhyErrBase);
+ phyCnt1, aniState->ofdmPhyErrBase);
REG_WRITE(ah, AR_PHY_ERR_1,
aniState->ofdmPhyErrBase);
REG_WRITE(ah, AR_PHY_ERR_MASK_1,
@@ -580,8 +579,7 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
DPRINTF(ah->ah_sc, ATH_DBG_ANI,
"phyCnt2 0x%x, resetting "
"counter value to 0x%x\n",
- phyCnt2,
- aniState->cckPhyErrBase);
+ phyCnt2, aniState->cckPhyErrBase);
REG_WRITE(ah, AR_PHY_ERR_2,
aniState->cckPhyErrBase);
REG_WRITE(ah, AR_PHY_ERR_MASK_2,
@@ -667,7 +665,7 @@ u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hw *ah,
u32 cc = REG_READ(ah, AR_CCCNT);
if (cycles == 0 || cycles > cc) {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
+ DPRINTF(ah->ah_sc, ATH_DBG_ANI,
"cycle counter wrap. ExtBusy = 0\n");
good = 0;
} else {
diff --git a/drivers/net/wireless/ath9k/ani.h b/drivers/net/wireless/ath/ath9k/ani.h
index 08b4e7ed5ff0..08b4e7ed5ff0 100644
--- a/drivers/net/wireless/ath9k/ani.h
+++ b/drivers/net/wireless/ath/ath9k/ani.h
diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 2689a08a2844..796a3adffea0 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -53,11 +53,7 @@ struct ath_node;
#define A_MAX(a, b) ((a) > (b) ? (a) : (b))
-#define ASSERT(exp) do { \
- if (unlikely(!(exp))) { \
- BUG(); \
- } \
- } while (0)
+#define ASSERT(exp) BUG_ON(!(exp))
#define TSF_TO_TU(_h,_l) \
((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
@@ -70,7 +66,6 @@ struct ath_config {
u32 ath_aggr_prot;
u16 txpowlimit;
u8 cabqReadytime;
- u8 swBeaconProcess;
};
/*************************/
@@ -78,13 +73,17 @@ struct ath_config {
/*************************/
#define ATH_TXBUF_RESET(_bf) do { \
- (_bf)->bf_status = 0; \
+ (_bf)->bf_stale = false; \
(_bf)->bf_lastbf = NULL; \
(_bf)->bf_next = NULL; \
memset(&((_bf)->bf_state), 0, \
sizeof(struct ath_buf_state)); \
} while (0)
+#define ATH_RXBUF_RESET(_bf) do { \
+ (_bf)->bf_stale = false; \
+ } while (0)
+
/**
* enum buffer_type - Buffer type flags
*
@@ -110,7 +109,7 @@ struct ath_buf_state {
int bfs_seqno;
int bfs_tidno;
int bfs_retries;
- u32 bf_type;
+ u8 bf_type;
u32 bfs_keyix;
enum ath9k_key_type bfs_keytype;
};
@@ -134,26 +133,21 @@ struct ath_buf {
struct ath_buf *bf_lastbf; /* last buf of this unit (a frame or
an aggregate) */
struct ath_buf *bf_next; /* next subframe in the aggregate */
- void *bf_mpdu; /* enclosing frame structure */
+ struct sk_buff *bf_mpdu; /* enclosing frame structure */
struct ath_desc *bf_desc; /* virtual addr of desc */
dma_addr_t bf_daddr; /* physical addr of desc */
dma_addr_t bf_buf_addr; /* physical addr of data buffer */
- u32 bf_status;
+ bool bf_stale;
u16 bf_flags;
struct ath_buf_state bf_state;
dma_addr_t bf_dmacontext;
};
-#define ATH_RXBUF_RESET(_bf) ((_bf)->bf_status = 0)
-#define ATH_BUFSTATUS_STALE 0x00000002
-
struct ath_descdma {
- const char *dd_name;
struct ath_desc *dd_desc;
dma_addr_t dd_desc_paddr;
u32 dd_desc_len;
struct ath_buf *dd_bufptr;
- dma_addr_t dd_dmacontext;
};
int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
@@ -299,26 +293,6 @@ struct ath_tx_control {
#define ATH_TX_XRETRY 0x02
#define ATH_TX_BAR 0x04
-/* All RSSI values are noise floor adjusted */
-struct ath_tx_stat {
- int rssi;
- int rssictl[ATH_MAX_ANTENNA];
- int rssiextn[ATH_MAX_ANTENNA];
- int rateieee;
- int rateKbps;
- int ratecode;
- int flags;
- u32 airtime; /* time on air per final tx rate */
-};
-
-struct aggr_rifs_param {
- int param_max_frames;
- int param_max_len;
- int param_rl;
- int param_al;
- struct ath_rc_series *param_rcs;
-};
-
struct ath_node {
struct ath_softc *an_sc;
struct ath_atx_tid tid[WME_NUM_TID];
@@ -366,7 +340,7 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
int ath_tx_init(struct ath_softc *sc, int nbufs);
-int ath_tx_cleanup(struct ath_softc *sc);
+void ath_tx_cleanup(struct ath_softc *sc);
struct ath_txq *ath_test_get_txq(struct ath_softc *sc, struct sk_buff *skb);
int ath_txq_update(struct ath_softc *sc, int qnum,
struct ath9k_tx_queue_info *q);
@@ -529,19 +503,22 @@ struct ath_rfkill {
#define SC_OP_BEACONS BIT(1)
#define SC_OP_RXAGGR BIT(2)
#define SC_OP_TXAGGR BIT(3)
-#define SC_OP_CHAINMASK_UPDATE BIT(4)
-#define SC_OP_FULL_RESET BIT(5)
-#define SC_OP_PREAMBLE_SHORT BIT(6)
-#define SC_OP_PROTECT_ENABLE BIT(7)
-#define SC_OP_RXFLUSH BIT(8)
-#define SC_OP_LED_ASSOCIATED BIT(9)
-#define SC_OP_RFKILL_REGISTERED BIT(10)
-#define SC_OP_RFKILL_SW_BLOCKED BIT(11)
-#define SC_OP_RFKILL_HW_BLOCKED BIT(12)
-#define SC_OP_WAIT_FOR_BEACON BIT(13)
-#define SC_OP_LED_ON BIT(14)
-#define SC_OP_SCANNING BIT(15)
-#define SC_OP_TSF_RESET BIT(16)
+#define SC_OP_FULL_RESET BIT(4)
+#define SC_OP_PREAMBLE_SHORT BIT(5)
+#define SC_OP_PROTECT_ENABLE BIT(6)
+#define SC_OP_RXFLUSH BIT(7)
+#define SC_OP_LED_ASSOCIATED BIT(8)
+#define SC_OP_RFKILL_REGISTERED BIT(9)
+#define SC_OP_RFKILL_SW_BLOCKED BIT(10)
+#define SC_OP_RFKILL_HW_BLOCKED BIT(11)
+#define SC_OP_WAIT_FOR_BEACON BIT(12)
+#define SC_OP_LED_ON BIT(13)
+#define SC_OP_SCANNING BIT(14)
+#define SC_OP_TSF_RESET BIT(15)
+#define SC_OP_WAIT_FOR_CAB BIT(16)
+#define SC_OP_WAIT_FOR_PSPOLL_DATA BIT(17)
+#define SC_OP_WAIT_FOR_TX_ACK BIT(18)
+#define SC_OP_BEACON_SYNC BIT(19)
struct ath_bus_ops {
void (*read_cachesize)(struct ath_softc *sc, int *csz);
@@ -603,8 +580,8 @@ struct ath_softc {
struct ath_tx tx;
struct ath_beacon beacon;
struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
- struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
- struct ath_rate_table *cur_rate_table;
+ const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
+ const struct ath_rate_table *cur_rate_table;
struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
struct ath_led radio_led;
@@ -617,6 +594,8 @@ struct ath_softc {
int led_on_cnt;
int led_off_cnt;
+ int beacon_interval;
+
struct ath_rfkill rf_kill;
struct ath_ani ani;
struct ath9k_node_stats nodestats;
@@ -624,6 +603,7 @@ struct ath_softc {
struct ath9k_debug debug;
#endif
struct ath_bus_ops *bus_ops;
+ struct ath_beacon_config cur_beacon_conf;
};
struct ath_wiphy {
@@ -701,7 +681,9 @@ static inline void ath9k_ps_restore(struct ath_softc *sc)
{
if (atomic_dec_and_test(&sc->ps_usecount))
if ((sc->hw->conf.flags & IEEE80211_CONF_PS) &&
- !(sc->sc_flags & SC_OP_WAIT_FOR_BEACON))
+ !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
+ SC_OP_WAIT_FOR_PSPOLL_DATA |
+ SC_OP_WAIT_FOR_TX_ACK)))
ath9k_hw_setpower(sc->sc_ah,
sc->sc_ah->restore_mode);
}
@@ -722,36 +704,7 @@ void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
bool ath9k_wiphy_scanning(struct ath_softc *sc);
void ath9k_wiphy_work(struct work_struct *work);
-/*
- * Read and write, they both share the same lock. We do this to serialize
- * reads and writes on Atheros 802.11n PCI devices only. This is required
- * as the FIFO on these devices can only accept sanely 2 requests. After
- * that the device goes bananas. Serializing the reads/writes prevents this
- * from happening.
- */
-
-static inline void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val)
-{
- if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
- unsigned long flags;
- spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags);
- iowrite32(val, ah->ah_sc->mem + reg_offset);
- spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags);
- } else
- iowrite32(val, ah->ah_sc->mem + reg_offset);
-}
-
-static inline unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset)
-{
- u32 val;
- if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
- unsigned long flags;
- spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags);
- val = ioread32(ah->ah_sc->mem + reg_offset);
- spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags);
- } else
- val = ioread32(ah->ah_sc->mem + reg_offset);
- return val;
-}
+void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val);
+unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset);
#endif /* ATH9K_H */
diff --git a/drivers/net/wireless/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index ec995730632d..a21b21339fbc 100644
--- a/drivers/net/wireless/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -43,7 +43,7 @@ static int ath_beaconq_config(struct ath_softc *sc)
if (!ath9k_hw_set_txq_props(ah, sc->beacon.beaconq, &qi)) {
DPRINTF(sc, ATH_DBG_FATAL,
- "unable to update h/w beacon queue parameters\n");
+ "Unable to update h/w beacon queue parameters\n");
return 0;
} else {
ath9k_hw_resettxqueue(ah, sc->beacon.beaconq);
@@ -59,11 +59,11 @@ static int ath_beaconq_config(struct ath_softc *sc)
static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
struct ath_buf *bf)
{
- struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
+ struct sk_buff *skb = bf->bf_mpdu;
struct ath_hw *ah = sc->sc_ah;
struct ath_desc *ds;
struct ath9k_11n_rate_series series[4];
- struct ath_rate_table *rt;
+ const struct ath_rate_table *rt;
int flags, antenna, ctsrate = 0, ctsduration = 0;
u8 rate;
@@ -132,16 +132,13 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
avp = (void *)vif->drv_priv;
cabq = sc->beacon.cabq;
- if (avp->av_bcbuf == NULL) {
- DPRINTF(sc, ATH_DBG_BEACON, "avp=%p av_bcbuf=%p\n",
- avp, avp->av_bcbuf);
+ if (avp->av_bcbuf == NULL)
return NULL;
- }
/* Release the old beacon first */
bf = avp->av_bcbuf;
- skb = (struct sk_buff *)bf->bf_mpdu;
+ skb = bf->bf_mpdu;
if (skb) {
dma_unmap_single(sc->dev, bf->bf_dmacontext,
skb->len, DMA_TO_DEVICE);
@@ -229,7 +226,7 @@ static void ath_beacon_start_adhoc(struct ath_softc *sc,
return;
bf = avp->av_bcbuf;
- skb = (struct sk_buff *) bf->bf_mpdu;
+ skb = bf->bf_mpdu;
ath_beacon_setup(sc, avp, bf);
@@ -302,7 +299,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
/* release the previous beacon frame, if it already exists. */
bf = avp->av_bcbuf;
if (bf->bf_mpdu != NULL) {
- skb = (struct sk_buff *)bf->bf_mpdu;
+ skb = bf->bf_mpdu;
dma_unmap_single(sc->dev, bf->bf_dmacontext,
skb->len, DMA_TO_DEVICE);
dev_kfree_skb_any(skb);
@@ -323,8 +320,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
u64 tsfadjust;
int intval;
- intval = sc->hw->conf.beacon_int ?
- sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL;
+ intval = sc->beacon_interval ? : ATH_DEFAULT_BINTVAL;
/*
* Calculate the TSF offset for this beacon slot, i.e., the
@@ -374,7 +370,7 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp)
bf = avp->av_bcbuf;
if (bf->bf_mpdu != NULL) {
- struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
+ struct sk_buff *skb = bf->bf_mpdu;
dma_unmap_single(sc->dev, bf->bf_dmacontext,
skb->len, DMA_TO_DEVICE);
dev_kfree_skb_any(skb);
@@ -434,8 +430,7 @@ void ath_beacon_tasklet(unsigned long data)
* on the tsf to safeguard against missing an swba.
*/
- intval = sc->hw->conf.beacon_int ?
- sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL;
+ intval = sc->beacon_interval ? : ATH_DEFAULT_BINTVAL;
tsf = ath9k_hw_gettsf64(ah);
tsftu = TSF_TO_TU(tsf>>32, tsf);
@@ -512,8 +507,7 @@ void ath_beacon_tasklet(unsigned long data)
* slot. Slots that are not occupied will generate nothing.
*/
static void ath_beacon_config_ap(struct ath_softc *sc,
- struct ath_beacon_config *conf,
- struct ath_vif *avp)
+ struct ath_beacon_config *conf)
{
u32 nexttbtt, intval;
@@ -558,14 +552,14 @@ static void ath_beacon_config_ap(struct ath_softc *sc,
* we've associated with.
*/
static void ath_beacon_config_sta(struct ath_softc *sc,
- struct ath_beacon_config *conf,
- struct ath_vif *avp)
+ struct ath_beacon_config *conf)
{
struct ath9k_beacon_state bs;
int dtimperiod, dtimcount, sleepduration;
int cfpperiod, cfpcount;
u32 nexttbtt = 0, intval, tsftu;
u64 tsf;
+ int num_beacons, offset, dtim_dec_count, cfp_dec_count;
memset(&bs, 0, sizeof(bs));
intval = conf->beacon_interval & ATH9K_BEACON_PERIOD;
@@ -593,14 +587,27 @@ static void ath_beacon_config_sta(struct ath_softc *sc,
*/
tsf = ath9k_hw_gettsf64(sc->sc_ah);
tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE;
- do {
+
+ num_beacons = tsftu / intval + 1;
+ offset = tsftu % intval;
+ nexttbtt = tsftu - offset;
+ if (offset)
nexttbtt += intval;
- if (--dtimcount < 0) {
- dtimcount = dtimperiod - 1;
- if (--cfpcount < 0)
- cfpcount = cfpperiod - 1;
- }
- } while (nexttbtt < tsftu);
+
+ /* DTIM Beacon every dtimperiod Beacon */
+ dtim_dec_count = num_beacons % dtimperiod;
+ /* CFP every cfpperiod DTIM Beacon */
+ cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod;
+ if (dtim_dec_count)
+ cfp_dec_count++;
+
+ dtimcount -= dtim_dec_count;
+ if (dtimcount < 0)
+ dtimcount += dtimperiod;
+
+ cfpcount -= cfp_dec_count;
+ if (cfpcount < 0)
+ cfpcount += cfpperiod;
bs.bs_intval = intval;
bs.bs_nexttbtt = nexttbtt;
@@ -659,7 +666,6 @@ static void ath_beacon_config_sta(struct ath_softc *sc,
static void ath_beacon_config_adhoc(struct ath_softc *sc,
struct ath_beacon_config *conf,
- struct ath_vif *avp,
struct ieee80211_vif *vif)
{
u64 tsf;
@@ -703,44 +709,50 @@ static void ath_beacon_config_adhoc(struct ath_softc *sc,
sc->beacon.bmisscnt = 0;
ath9k_hw_set_interrupts(sc->sc_ah, sc->imask);
- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)
+ /* FIXME: Handle properly when vif is NULL */
+ if (vif && sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)
ath_beacon_start_adhoc(sc, vif);
}
void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
{
- struct ath_beacon_config conf;
+ struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
+ enum nl80211_iftype iftype;
/* Setup the beacon configuration parameters */
- memset(&conf, 0, sizeof(struct ath_beacon_config));
- conf.beacon_interval = sc->hw->conf.beacon_int ?
- sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL;
- conf.listen_interval = 1;
- conf.dtim_period = conf.beacon_interval;
- conf.dtim_count = 1;
- conf.bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf.beacon_interval;
-
if (vif) {
- struct ath_vif *avp = (struct ath_vif *)vif->drv_priv;
-
- switch(avp->av_opmode) {
- case NL80211_IFTYPE_AP:
- ath_beacon_config_ap(sc, &conf, avp);
- break;
- case NL80211_IFTYPE_ADHOC:
- case NL80211_IFTYPE_MESH_POINT:
- ath_beacon_config_adhoc(sc, &conf, avp, vif);
- break;
- case NL80211_IFTYPE_STATION:
- ath_beacon_config_sta(sc, &conf, avp);
- break;
- default:
- DPRINTF(sc, ATH_DBG_CONFIG,
- "Unsupported beaconing mode\n");
- return;
- }
+ struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
+
+ iftype = vif->type;
- sc->sc_flags |= SC_OP_BEACONS;
+ cur_conf->beacon_interval = bss_conf->beacon_int;
+ cur_conf->dtim_period = bss_conf->dtim_period;
+ cur_conf->listen_interval = 1;
+ cur_conf->dtim_count = 1;
+ cur_conf->bmiss_timeout =
+ ATH_DEFAULT_BMISS_LIMIT * cur_conf->beacon_interval;
+ } else {
+ iftype = sc->sc_ah->opmode;
}
+
+
+ switch (iftype) {
+ case NL80211_IFTYPE_AP:
+ ath_beacon_config_ap(sc, cur_conf);
+ break;
+ case NL80211_IFTYPE_ADHOC:
+ case NL80211_IFTYPE_MESH_POINT:
+ ath_beacon_config_adhoc(sc, cur_conf, vif);
+ break;
+ case NL80211_IFTYPE_STATION:
+ ath_beacon_config_sta(sc, cur_conf);
+ break;
+ default:
+ DPRINTF(sc, ATH_DBG_CONFIG,
+ "Unsupported beaconing mode\n");
+ return;
+ }
+
+ sc->sc_flags |= SC_OP_BEACONS;
}
diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index e2d62e97131c..a32d7e7fecbe 100644
--- a/drivers/net/wireless/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -186,7 +186,7 @@ static bool getNoiseFloorThresh(struct ath_hw *ah,
}
static void ath9k_hw_setup_calibration(struct ath_hw *ah,
- struct hal_cal_list *currCal)
+ struct ath9k_cal_list *currCal)
{
REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(0),
AR_PHY_TIMING_CTRL4_IQCAL_LOG_COUNT_MAX,
@@ -220,7 +220,7 @@ static void ath9k_hw_setup_calibration(struct ath_hw *ah,
}
static void ath9k_hw_reset_calibration(struct ath_hw *ah,
- struct hal_cal_list *currCal)
+ struct ath9k_cal_list *currCal)
{
int i;
@@ -238,13 +238,12 @@ static void ath9k_hw_reset_calibration(struct ath_hw *ah,
ah->cal_samples = 0;
}
-static void ath9k_hw_per_calibration(struct ath_hw *ah,
+static bool ath9k_hw_per_calibration(struct ath_hw *ah,
struct ath9k_channel *ichan,
u8 rxchainmask,
- struct hal_cal_list *currCal,
- bool *isCalDone)
+ struct ath9k_cal_list *currCal)
{
- *isCalDone = false;
+ bool iscaldone = false;
if (currCal->calState == CAL_RUNNING) {
if (!(REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
@@ -263,7 +262,7 @@ static void ath9k_hw_per_calibration(struct ath_hw *ah,
currCal->calData->calPostProc(ah, numChains);
ichan->CalValid |= currCal->calData->calType;
currCal->calState = CAL_DONE;
- *isCalDone = true;
+ iscaldone = true;
} else {
ath9k_hw_setup_calibration(ah, currCal);
}
@@ -271,11 +270,13 @@ static void ath9k_hw_per_calibration(struct ath_hw *ah,
} else if (!(ichan->CalValid & currCal->calData->calType)) {
ath9k_hw_reset_calibration(ah, currCal);
}
+
+ return iscaldone;
}
/* Assumes you are talking about the currently configured channel */
static bool ath9k_hw_iscal_supported(struct ath_hw *ah,
- enum hal_cal_types calType)
+ enum ath9k_cal_types calType)
{
struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
@@ -284,8 +285,8 @@ static bool ath9k_hw_iscal_supported(struct ath_hw *ah,
return true;
case ADC_GAIN_CAL:
case ADC_DC_CAL:
- if (conf->channel->band == IEEE80211_BAND_5GHZ &&
- conf_is_ht20(conf))
+ if (!(conf->channel->band == IEEE80211_BAND_2GHZ &&
+ conf_is_ht20(conf)))
return true;
break;
}
@@ -498,7 +499,7 @@ static void ath9k_hw_adc_dccal_calibrate(struct ath_hw *ah, u8 numChains)
{
u32 iOddMeasOffset, iEvenMeasOffset, val, i;
int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch;
- const struct hal_percal_data *calData =
+ const struct ath9k_percal_data *calData =
ah->cal_list_curr->calData;
u32 numSamples =
(1 << (calData->calCountMax + 5)) * calData->calNumSamples;
@@ -555,7 +556,7 @@ static void ath9k_hw_adc_dccal_calibrate(struct ath_hw *ah, u8 numChains)
bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
{
struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
- struct hal_cal_list *currCal = ah->cal_list_curr;
+ struct ath9k_cal_list *currCal = ah->cal_list_curr;
if (!ah->curchan)
return true;
@@ -841,30 +842,28 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
}
bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
- u8 rxchainmask, bool longcal,
- bool *isCalDone)
+ u8 rxchainmask, bool longcal)
{
- struct hal_cal_list *currCal = ah->cal_list_curr;
-
- *isCalDone = true;
+ bool iscaldone = true;
+ struct ath9k_cal_list *currCal = ah->cal_list_curr;
if (currCal &&
(currCal->calState == CAL_RUNNING ||
currCal->calState == CAL_WAITING)) {
- ath9k_hw_per_calibration(ah, chan, rxchainmask, currCal,
- isCalDone);
- if (*isCalDone) {
+ iscaldone = ath9k_hw_per_calibration(ah, chan,
+ rxchainmask, currCal);
+ if (iscaldone) {
ah->cal_list_curr = currCal = currCal->calNext;
if (currCal->calState == CAL_WAITING) {
- *isCalDone = false;
+ iscaldone = false;
ath9k_hw_reset_calibration(ah, currCal);
}
}
}
if (longcal) {
- if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah))
+ if (AR_SREV_9285_11_OR_LATER(ah))
ath9k_hw_9285_pa_cal(ah);
if (OLC_FOR_AR9280_20_LATER)
@@ -872,18 +871,15 @@ bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
ath9k_hw_getnf(ah, chan);
ath9k_hw_loadnf(ah, ah->curchan);
ath9k_hw_start_nfcal(ah);
-
- if (chan->channelFlags & CHANNEL_CW_INT)
- chan->channelFlags &= ~CHANNEL_CW_INT;
}
- return true;
+ return iscaldone;
}
static bool ar9285_clc(struct ath_hw *ah, struct ath9k_channel *chan)
{
REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
- if (chan->channelFlags & CHANNEL_HT20) {
+ if (IS_CHAN_HT20(chan)) {
REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_PARALLEL_CAL_ENABLE);
REG_SET_BIT(ah, AR_PHY_TURBO, AR_PHY_FC_DYN2040_EN);
REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
@@ -919,83 +915,66 @@ static bool ar9285_clc(struct ath_hw *ah, struct ath9k_channel *chan)
return true;
}
-bool ath9k_hw_init_cal(struct ath_hw *ah,
- struct ath9k_channel *chan)
+bool ath9k_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
{
- if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) {
+ if (AR_SREV_9285_12_OR_LATER(ah)) {
if (!ar9285_clc(ah, chan))
return false;
- } else if (AR_SREV_9280_10_OR_LATER(ah)) {
- REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
- REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
- REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
+ } else {
+ if (AR_SREV_9280_10_OR_LATER(ah)) {
+ REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
+ REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
+ }
- /* Kick off the cal */
+ /* Calibrate the AGC */
REG_WRITE(ah, AR_PHY_AGC_CONTROL,
- REG_READ(ah, AR_PHY_AGC_CONTROL) |
- AR_PHY_AGC_CONTROL_CAL);
+ REG_READ(ah, AR_PHY_AGC_CONTROL) |
+ AR_PHY_AGC_CONTROL_CAL);
- if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
- AR_PHY_AGC_CONTROL_CAL, 0,
- AH_WAIT_TIMEOUT)) {
+ /* Poll for offset calibration complete */
+ if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL,
+ 0, AH_WAIT_TIMEOUT)) {
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
"offset calibration failed to complete in 1ms; "
"noisy environment?\n");
return false;
}
- REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
- REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
- REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
- }
-
- /* Calibrate the AGC */
- REG_WRITE(ah, AR_PHY_AGC_CONTROL,
- REG_READ(ah, AR_PHY_AGC_CONTROL) |
- AR_PHY_AGC_CONTROL_CAL);
-
- if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL,
- 0, AH_WAIT_TIMEOUT)) {
- DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
- "offset calibration failed to complete in 1ms; "
- "noisy environment?\n");
- return false;
- }
-
- if (AR_SREV_9280_10_OR_LATER(ah)) {
- REG_SET_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
- REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
+ if (AR_SREV_9280_10_OR_LATER(ah)) {
+ REG_SET_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
+ REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
+ }
}
/* Do PA Calibration */
- if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah))
+ if (AR_SREV_9285_11_OR_LATER(ah))
ath9k_hw_9285_pa_cal(ah);
- /* Do NF Calibration */
+ /* Do NF Calibration after DC offset and other calibrations */
REG_WRITE(ah, AR_PHY_AGC_CONTROL,
- REG_READ(ah, AR_PHY_AGC_CONTROL) |
- AR_PHY_AGC_CONTROL_NF);
+ REG_READ(ah, AR_PHY_AGC_CONTROL) | AR_PHY_AGC_CONTROL_NF);
ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
+ /* Enable IQ, ADC Gain and ADC DC offset CALs */
if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
if (ath9k_hw_iscal_supported(ah, ADC_GAIN_CAL)) {
INIT_CAL(&ah->adcgain_caldata);
INSERT_CAL(ah, &ah->adcgain_caldata);
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
- "enabling ADC Gain Calibration.\n");
+ "enabling ADC Gain Calibration.\n");
}
if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) {
INIT_CAL(&ah->adcdc_caldata);
INSERT_CAL(ah, &ah->adcdc_caldata);
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
- "enabling ADC DC Calibration.\n");
+ "enabling ADC DC Calibration.\n");
}
if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) {
INIT_CAL(&ah->iq_caldata);
INSERT_CAL(ah, &ah->iq_caldata);
DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
- "enabling IQ Calibration.\n");
+ "enabling IQ Calibration.\n");
}
ah->cal_list_curr = ah->cal_list;
@@ -1009,49 +988,49 @@ bool ath9k_hw_init_cal(struct ath_hw *ah,
return true;
}
-const struct hal_percal_data iq_cal_multi_sample = {
+const struct ath9k_percal_data iq_cal_multi_sample = {
IQ_MISMATCH_CAL,
MAX_CAL_SAMPLES,
PER_MIN_LOG_COUNT,
ath9k_hw_iqcal_collect,
ath9k_hw_iqcalibrate
};
-const struct hal_percal_data iq_cal_single_sample = {
+const struct ath9k_percal_data iq_cal_single_sample = {
IQ_MISMATCH_CAL,
MIN_CAL_SAMPLES,
PER_MAX_LOG_COUNT,
ath9k_hw_iqcal_collect,
ath9k_hw_iqcalibrate
};
-const struct hal_percal_data adc_gain_cal_multi_sample = {
+const struct ath9k_percal_data adc_gain_cal_multi_sample = {
ADC_GAIN_CAL,
MAX_CAL_SAMPLES,
PER_MIN_LOG_COUNT,
ath9k_hw_adc_gaincal_collect,
ath9k_hw_adc_gaincal_calibrate
};
-const struct hal_percal_data adc_gain_cal_single_sample = {
+const struct ath9k_percal_data adc_gain_cal_single_sample = {
ADC_GAIN_CAL,
MIN_CAL_SAMPLES,
PER_MAX_LOG_COUNT,
ath9k_hw_adc_gaincal_collect,
ath9k_hw_adc_gaincal_calibrate
};
-const struct hal_percal_data adc_dc_cal_multi_sample = {
+const struct ath9k_percal_data adc_dc_cal_multi_sample = {
ADC_DC_CAL,
MAX_CAL_SAMPLES,
PER_MIN_LOG_COUNT,
ath9k_hw_adc_dccal_collect,
ath9k_hw_adc_dccal_calibrate
};
-const struct hal_percal_data adc_dc_cal_single_sample = {
+const struct ath9k_percal_data adc_dc_cal_single_sample = {
ADC_DC_CAL,
MIN_CAL_SAMPLES,
PER_MAX_LOG_COUNT,
ath9k_hw_adc_dccal_collect,
ath9k_hw_adc_dccal_calibrate
};
-const struct hal_percal_data adc_init_dc_cal = {
+const struct ath9k_percal_data adc_init_dc_cal = {
ADC_DC_INIT_CAL,
MIN_CAL_SAMPLES,
INIT_LOG_COUNT,
diff --git a/drivers/net/wireless/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index 1c74bd50700d..fe5367f14148 100644
--- a/drivers/net/wireless/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -17,13 +17,13 @@
#ifndef CALIB_H
#define CALIB_H
-extern const struct hal_percal_data iq_cal_multi_sample;
-extern const struct hal_percal_data iq_cal_single_sample;
-extern const struct hal_percal_data adc_gain_cal_multi_sample;
-extern const struct hal_percal_data adc_gain_cal_single_sample;
-extern const struct hal_percal_data adc_dc_cal_multi_sample;
-extern const struct hal_percal_data adc_dc_cal_single_sample;
-extern const struct hal_percal_data adc_init_dc_cal;
+extern const struct ath9k_percal_data iq_cal_multi_sample;
+extern const struct ath9k_percal_data iq_cal_single_sample;
+extern const struct ath9k_percal_data adc_gain_cal_multi_sample;
+extern const struct ath9k_percal_data adc_gain_cal_single_sample;
+extern const struct ath9k_percal_data adc_dc_cal_multi_sample;
+extern const struct ath9k_percal_data adc_dc_cal_single_sample;
+extern const struct ath9k_percal_data adc_init_dc_cal;
#define AR_PHY_CCA_MAX_GOOD_VALUE -85
#define AR_PHY_CCA_MAX_HIGH_VALUE -62
@@ -67,14 +67,14 @@ struct ar5416IniArray {
} \
} while (0)
-enum hal_cal_types {
+enum ath9k_cal_types {
ADC_DC_INIT_CAL = 0x1,
ADC_GAIN_CAL = 0x2,
ADC_DC_CAL = 0x4,
IQ_MISMATCH_CAL = 0x8
};
-enum hal_cal_state {
+enum ath9k_cal_state {
CAL_INACTIVE,
CAL_WAITING,
CAL_RUNNING,
@@ -87,18 +87,18 @@ enum hal_cal_state {
#define PER_MIN_LOG_COUNT 2
#define PER_MAX_LOG_COUNT 10
-struct hal_percal_data {
- enum hal_cal_types calType;
+struct ath9k_percal_data {
+ enum ath9k_cal_types calType;
u32 calNumSamples;
u32 calCountMax;
void (*calCollect) (struct ath_hw *);
void (*calPostProc) (struct ath_hw *, u8);
};
-struct hal_cal_list {
- const struct hal_percal_data *calData;
- enum hal_cal_state calState;
- struct hal_cal_list *calNext;
+struct ath9k_cal_list {
+ const struct ath9k_percal_data *calData;
+ enum ath9k_cal_state calState;
+ struct ath9k_cal_list *calNext;
};
struct ath9k_nfcal_hist {
@@ -116,8 +116,7 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah,
void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah);
s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan);
bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
- u8 rxchainmask, bool longcal,
- bool *isCalDone);
+ u8 rxchainmask, bool longcal);
bool ath9k_hw_init_cal(struct ath_hw *ah,
struct ath9k_channel *chan);
diff --git a/drivers/net/wireless/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index fdf9528fa49b..97df20cbf528 100644
--- a/drivers/net/wireless/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -498,6 +498,9 @@ int ath9k_init_debug(struct ath_softc *sc)
{
sc->debug.debug_mask = ath9k_debug;
+ if (!ath9k_debugfs_root)
+ return -ENOENT;
+
sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
ath9k_debugfs_root);
if (!sc->debug.debugfs_phy)
diff --git a/drivers/net/wireless/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 7b0e5419d2bc..db845cf960c9 100644
--- a/drivers/net/wireless/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -19,20 +19,17 @@
enum ATH_DEBUG {
ATH_DBG_RESET = 0x00000001,
- ATH_DBG_REG_IO = 0x00000002,
- ATH_DBG_QUEUE = 0x00000004,
- ATH_DBG_EEPROM = 0x00000008,
- ATH_DBG_CALIBRATE = 0x00000010,
- ATH_DBG_CHANNEL = 0x00000020,
- ATH_DBG_INTERRUPT = 0x00000040,
- ATH_DBG_REGULATORY = 0x00000080,
- ATH_DBG_ANI = 0x00000100,
- ATH_DBG_POWER_MGMT = 0x00000200,
- ATH_DBG_XMIT = 0x00000400,
- ATH_DBG_BEACON = 0x00001000,
- ATH_DBG_CONFIG = 0x00002000,
- ATH_DBG_KEYCACHE = 0x00004000,
- ATH_DBG_FATAL = 0x00008000,
+ ATH_DBG_QUEUE = 0x00000002,
+ ATH_DBG_EEPROM = 0x00000004,
+ ATH_DBG_CALIBRATE = 0x00000008,
+ ATH_DBG_INTERRUPT = 0x00000010,
+ ATH_DBG_REGULATORY = 0x00000020,
+ ATH_DBG_ANI = 0x00000040,
+ ATH_DBG_XMIT = 0x00000080,
+ ATH_DBG_BEACON = 0x00000100,
+ ATH_DBG_CONFIG = 0x00000200,
+ ATH_DBG_FATAL = 0x00000400,
+ ATH_DBG_PS = 0x00000800,
ATH_DBG_ANY = 0xffffffff
};
diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index ffc36b0361c7..a2fda702b620 100644
--- a/drivers/net/wireless/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -694,7 +694,7 @@ static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
#undef TMP_VAL_VPD_TABLE
}
-static bool ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
+static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
struct ath9k_channel *chan,
int16_t *pTxPowerIndexOffset)
{
@@ -783,11 +783,11 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
((pdadcValues[4 * j + 3] & 0xFF) << 24);
REG_WRITE(ah, regOffset, reg32);
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"PDADC (%d,%4x): %4.4x %8.8x\n",
i, regChainOffset, regOffset,
reg32);
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"PDADC: Chain %d | "
"PDADC %3d Value %3d | "
"PDADC %3d Value %3d | "
@@ -805,11 +805,9 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
}
*pTxPowerIndexOffset = 0;
-
- return true;
}
-static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
+static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
struct ath9k_channel *chan,
int16_t *ratesArray,
u16 cfgCtl,
@@ -910,7 +908,7 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
ah->eep_ops->get_eeprom_rev(ah) <= 2)
twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, "
"EXT_ADDITIVE %d\n",
ctlMode, numCtlModes, isHt40CtlMode,
@@ -918,7 +916,7 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
for (i = 0; (i < AR5416_NUM_CTLS) &&
pEepData->ctlIndex[i]; i++) {
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
" LOOP-Ctlidx %d: cfgCtl 0x%2.2x "
"pCtlMode 0x%2.2x ctlIndex 0x%2.2x "
"chan %d\n",
@@ -941,7 +939,7 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
IS_CHAN_2GHZ(chan),
AR5416_EEP4K_NUM_BAND_EDGES);
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
" MATCH-EE_IDX %d: ch %d is2 %d "
"2xMinEdge %d chainmask %d chains %d\n",
i, freq, IS_CHAN_2GHZ(chan),
@@ -961,7 +959,7 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower);
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
" SEL-Min ctlMode %d pCtlMode %d "
"2xMaxEdge %d sP %d minCtlPwr %d\n",
ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
@@ -1041,10 +1039,9 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0];
ratesArray[rateExtCck] = targetPowerCckExt.tPow2x[0];
}
- return true;
}
-static int ath9k_hw_4k_set_txpower(struct ath_hw *ah,
+static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
struct ath9k_channel *chan,
u16 cfgCtl,
u8 twiceAntennaReduction,
@@ -1065,22 +1062,13 @@ static int ath9k_hw_4k_set_txpower(struct ath_hw *ah,
ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
}
- if (!ath9k_hw_set_4k_power_per_rate_table(ah, chan,
+ ath9k_hw_set_4k_power_per_rate_table(ah, chan,
&ratesArray[0], cfgCtl,
twiceAntennaReduction,
twiceMaxRegulatoryPower,
- powerLimit)) {
- DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
- "ath9k_hw_set_txpower: unable to set "
- "tx power per rate table\n");
- return -EIO;
- }
+ powerLimit);
- if (!ath9k_hw_set_4k_power_cal_table(ah, chan, &txPowerIndexOffset)) {
- DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
- "ath9k_hw_set_txpower: unable to set power table\n");
- return -EIO;
- }
+ ath9k_hw_set_4k_power_cal_table(ah, chan, &txPowerIndexOffset);
for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
@@ -1168,7 +1156,6 @@ static int ath9k_hw_4k_set_txpower(struct ath_hw *ah,
else
ah->regulatory.max_power_level = ratesArray[i];
- return 0;
}
static void ath9k_hw_4k_set_addac(struct ath_hw *ah,
@@ -2103,7 +2090,7 @@ static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
return;
}
-static bool ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
+static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
struct ath9k_channel *chan,
int16_t *pTxPowerIndexOffset)
{
@@ -2234,11 +2221,11 @@ static bool ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
((pdadcValues[4 * j + 3] & 0xFF) << 24);
REG_WRITE(ah, regOffset, reg32);
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"PDADC (%d,%4x): %4.4x %8.8x\n",
i, regChainOffset, regOffset,
reg32);
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"PDADC: Chain %d | PDADC %3d "
"Value %3d | PDADC %3d Value %3d | "
"PDADC %3d Value %3d | PDADC %3d "
@@ -2255,13 +2242,11 @@ static bool ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
}
*pTxPowerIndexOffset = 0;
-
- return true;
#undef SM_PD_GAIN
#undef SM_PDGAIN_B
}
-static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
+static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
struct ath9k_channel *chan,
int16_t *ratesArray,
u16 cfgCtl,
@@ -2415,14 +2400,14 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
ah->eep_ops->get_eeprom_rev(ah) <= 2)
twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, "
"EXT_ADDITIVE %d\n",
ctlMode, numCtlModes, isHt40CtlMode,
(pCtlMode[ctlMode] & EXT_ADDITIVE));
for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; i++) {
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
" LOOP-Ctlidx %d: cfgCtl 0x%2.2x "
"pCtlMode 0x%2.2x ctlIndex 0x%2.2x "
"chan %d\n",
@@ -2441,7 +2426,7 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
rep->ctlEdges[ar5416_get_ntxchains(tx_chainmask) - 1],
IS_CHAN_2GHZ(chan), AR5416_NUM_BAND_EDGES);
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
" MATCH-EE_IDX %d: ch %d is2 %d "
"2xMinEdge %d chainmask %d chains %d\n",
i, freq, IS_CHAN_2GHZ(chan),
@@ -2460,7 +2445,7 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
minCtlPower = min(twiceMaxEdgePower, scaledPower);
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
" SEL-Min ctlMode %d pCtlMode %d "
"2xMaxEdge %d sP %d minCtlPwr %d\n",
ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
@@ -2549,10 +2534,9 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
targetPowerCckExt.tPow2x[0];
}
}
- return true;
}
-static int ath9k_hw_def_set_txpower(struct ath_hw *ah,
+static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
struct ath9k_channel *chan,
u16 cfgCtl,
u8 twiceAntennaReduction,
@@ -2575,22 +2559,13 @@ static int ath9k_hw_def_set_txpower(struct ath_hw *ah,
ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
}
- if (!ath9k_hw_set_def_power_per_rate_table(ah, chan,
+ ath9k_hw_set_def_power_per_rate_table(ah, chan,
&ratesArray[0], cfgCtl,
twiceAntennaReduction,
twiceMaxRegulatoryPower,
- powerLimit)) {
- DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
- "ath9k_hw_set_txpower: unable to set "
- "tx power per rate table\n");
- return -EIO;
- }
+ powerLimit);
- if (!ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset)) {
- DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
- "ath9k_hw_set_txpower: unable to set power table\n");
- return -EIO;
- }
+ ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset);
for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
@@ -2717,8 +2692,6 @@ static int ath9k_hw_def_set_txpower(struct ath_hw *ah,
"Invalid chainmask configuration\n");
break;
}
-
- return 0;
}
static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah,
diff --git a/drivers/net/wireless/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
index 25b68c881ff1..67b8bd12941a 100644
--- a/drivers/net/wireless/ath9k/eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
@@ -17,6 +17,8 @@
#ifndef EEPROM_H
#define EEPROM_H
+#include <net/cfg80211.h>
+
#define AH_USE_EEPROM 0x1
#ifdef __BIG_ENDIAN
@@ -492,7 +494,7 @@ struct eeprom_ops {
struct ath9k_channel *chan);
void (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan);
void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
- int (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
+ void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
u16 cfgCtl, u8 twiceAntennaReduction,
u8 twiceMaxRegulatoryPower, u8 powerLimit);
u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index b15eaf8417ff..1579c9407ed5 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -84,6 +84,38 @@ static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs)
return ath9k_hw_mac_clks(ah, usecs);
}
+/*
+ * Read and write, they both share the same lock. We do this to serialize
+ * reads and writes on Atheros 802.11n PCI devices only. This is required
+ * as the FIFO on these devices can only accept sanely 2 requests. After
+ * that the device goes bananas. Serializing the reads/writes prevents this
+ * from happening.
+ */
+
+void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val)
+{
+ if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
+ unsigned long flags;
+ spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags);
+ iowrite32(val, ah->ah_sc->mem + reg_offset);
+ spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags);
+ } else
+ iowrite32(val, ah->ah_sc->mem + reg_offset);
+}
+
+unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset)
+{
+ u32 val;
+ if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
+ unsigned long flags;
+ spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags);
+ val = ioread32(ah->ah_sc->mem + reg_offset);
+ spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags);
+ } else
+ val = ioread32(ah->ah_sc->mem + reg_offset);
+ return val;
+}
+
bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
{
int i;
@@ -97,7 +129,7 @@ bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
udelay(AH_TIME_QUANTUM);
}
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_ANY,
"timeout (%d us) on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n",
timeout, reg, REG_READ(ah, reg), mask, val);
@@ -136,7 +168,7 @@ bool ath9k_get_channel_edges(struct ath_hw *ah,
}
u16 ath9k_hw_computetxtime(struct ath_hw *ah,
- struct ath_rate_table *rates,
+ const struct ath_rate_table *rates,
u32 frameLen, u16 rateix,
bool shortPreamble)
{
@@ -181,7 +213,7 @@ u16 ath9k_hw_computetxtime(struct ath_hw *ah,
}
break;
default:
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"Unknown phy %u (rate ix %u)\n",
rates->info[rateix].phy, rateix);
txTime = 0;
@@ -306,7 +338,7 @@ static bool ath9k_hw_chip_test(struct ath_hw *ah)
REG_WRITE(ah, addr, wrData);
rdData = REG_READ(ah, addr);
if (rdData != wrData) {
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"address test failed "
"addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
addr, wrData, rdData);
@@ -318,7 +350,7 @@ static bool ath9k_hw_chip_test(struct ath_hw *ah)
REG_WRITE(ah, addr, wrData);
rdData = REG_READ(ah, addr);
if (wrData != rdData) {
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"address test failed "
"addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
addr, wrData, rdData);
@@ -363,10 +395,7 @@ static void ath9k_hw_set_defaults(struct ath_hw *ah)
ah->config.ack_6mb = 0x0;
ah->config.cwm_ignore_extcca = 0;
ah->config.pcie_powersave_enable = 0;
- ah->config.pcie_l1skp_enable = 0;
ah->config.pcie_clock_req = 0;
- ah->config.pcie_power_reset = 0x100;
- ah->config.pcie_restore = 0;
ah->config.pcie_waen = 0;
ah->config.analog_shiftreg = 1;
ah->config.ht_enable = 1;
@@ -375,13 +404,6 @@ static void ath9k_hw_set_defaults(struct ath_hw *ah)
ah->config.cck_trig_high = 200;
ah->config.cck_trig_low = 100;
ah->config.enable_ani = 1;
- ah->config.noise_immunity_level = 4;
- ah->config.ofdm_weaksignal_det = 1;
- ah->config.cck_weaksignal_thr = 0;
- ah->config.spur_immunity_level = 2;
- ah->config.firstep_level = 0;
- ah->config.rssi_thr_high = 40;
- ah->config.rssi_thr_low = 7;
ah->config.diversity_control = 0;
ah->config.antenna_switch_swap = 0;
@@ -390,7 +412,7 @@ static void ath9k_hw_set_defaults(struct ath_hw *ah)
ah->config.spurchans[i][1] = AR_NO_SPUR;
}
- ah->config.intr_mitigation = 1;
+ ah->config.intr_mitigation = true;
/*
* We need this for PCI devices only (Cardbus, PCI, miniPCI)
@@ -463,8 +485,8 @@ static int ath9k_hw_rfattach(struct ath_hw *ah)
rfStatus = ath9k_hw_init_rf(ah, &ecode);
if (!rfStatus) {
- DPRINTF(ah->ah_sc, ATH_DBG_RESET,
- "RF setup failed, status %u\n", ecode);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "RF setup failed, status: %u\n", ecode);
return ecode;
}
@@ -488,10 +510,9 @@ static int ath9k_hw_rf_claim(struct ath_hw *ah)
case AR_RAD2122_SREV_MAJOR:
break;
default:
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
- "5G Radio Chip Rev 0x%02X is not "
- "supported by this driver\n",
- ah->hw_version.analog5GhzRev);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "Radio Chip Rev 0x%02X not supported\n",
+ val & AR_RADIO_SREV_MAJOR);
return -EOPNOTSUPP;
}
@@ -513,12 +534,8 @@ static int ath9k_hw_init_macaddr(struct ath_hw *ah)
ah->macaddr[2 * i] = eeval >> 8;
ah->macaddr[2 * i + 1] = eeval & 0xff;
}
- if (sum == 0 || sum == 0xffff * 3) {
- DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
- "mac address read failed: %pM\n",
- ah->macaddr);
+ if (sum == 0 || sum == 0xffff * 3)
return -EADDRNOTAVAIL;
- }
return 0;
}
@@ -575,11 +592,8 @@ static int ath9k_hw_post_attach(struct ath_hw *ah)
{
int ecode;
- if (!ath9k_hw_chip_test(ah)) {
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
- "hardware self-test failed\n");
+ if (!ath9k_hw_chip_test(ah))
return -ENODEV;
- }
ecode = ath9k_hw_rf_claim(ah);
if (ecode != 0)
@@ -617,17 +631,14 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
ath9k_hw_set_defaults(ah);
- if (ah->config.intr_mitigation != 0)
- ah->intr_mitigation = true;
-
if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) {
- DPRINTF(sc, ATH_DBG_RESET, "Couldn't reset chip\n");
+ DPRINTF(sc, ATH_DBG_FATAL, "Couldn't reset chip\n");
ecode = -EIO;
goto bad;
}
if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) {
- DPRINTF(sc, ATH_DBG_RESET, "Couldn't wakeup chip\n");
+ DPRINTF(sc, ATH_DBG_FATAL, "Couldn't wakeup chip\n");
ecode = -EIO;
goto bad;
}
@@ -650,7 +661,7 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
(ah->hw_version.macVersion != AR_SREV_VERSION_5416_PCIE) &&
(ah->hw_version.macVersion != AR_SREV_VERSION_9160) &&
(!AR_SREV_9100(ah)) && (!AR_SREV_9280(ah)) && (!AR_SREV_9285(ah))) {
- DPRINTF(sc, ATH_DBG_RESET,
+ DPRINTF(sc, ATH_DBG_FATAL,
"Mac Chip Rev 0x%02x.%x is not supported by "
"this driver\n", ah->hw_version.macVersion,
ah->hw_version.macRev);
@@ -690,10 +701,6 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
if (AR_SREV_9280_10_OR_LATER(ah))
ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
- DPRINTF(sc, ATH_DBG_RESET,
- "This Mac Chip Rev 0x%02x.%x is \n",
- ah->hw_version.macVersion, ah->hw_version.macRev);
-
if (AR_SREV_9285_12_OR_LATER(ah)) {
INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2,
@@ -859,11 +866,7 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
if (AR_SREV_9280_20(ah))
ath9k_hw_init_txgain_ini(ah);
- if (!ath9k_hw_fill_cap_info(ah)) {
- DPRINTF(sc, ATH_DBG_RESET, "failed ath9k_hw_fill_cap_info\n");
- ecode = -EINVAL;
- goto bad;
- }
+ ath9k_hw_fill_cap_info(ah);
if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) {
@@ -885,8 +888,8 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
ecode = ath9k_hw_init_macaddr(ah);
if (ecode != 0) {
- DPRINTF(sc, ATH_DBG_RESET,
- "failed initializing mac address\n");
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "Failed to initialize MAC address\n");
goto bad;
}
@@ -1054,7 +1057,7 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
AR_IMR_RXORN |
AR_IMR_BCNMISC;
- if (ah->intr_mitigation)
+ if (ah->config.intr_mitigation)
ah->mask_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR;
else
ah->mask_reg |= AR_IMR_RXOK;
@@ -1203,23 +1206,23 @@ static u32 ath9k_hw_def_ini_fixup(struct ath_hw *ah,
switch (ah->hw_version.devid) {
case AR9280_DEVID_PCI:
if (reg == 0x7894) {
- DPRINTF(ah->ah_sc, ATH_DBG_ANY,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"ini VAL: %x EEPROM: %x\n", value,
(pBase->version & 0xff));
if ((pBase->version & 0xff) > 0x0a) {
- DPRINTF(ah->ah_sc, ATH_DBG_ANY,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"PWDCLKIND: %d\n",
pBase->pwdclkind);
value &= ~AR_AN_TOP2_PWDCLKIND;
value |= AR_AN_TOP2_PWDCLKIND &
(pBase->pwdclkind << AR_AN_TOP2_PWDCLKIND_S);
} else {
- DPRINTF(ah->ah_sc, ATH_DBG_ANY,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"PWDCLKIND Earlier Rev\n");
}
- DPRINTF(ah->ah_sc, ATH_DBG_ANY,
+ DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"final ini VAL: %x\n", value);
}
break;
@@ -1249,6 +1252,21 @@ static void ath9k_olc_init(struct ath_hw *ah)
ah->PDADCdelta = 0;
}
+static u32 ath9k_regd_get_ctl(struct ath_regulatory *reg,
+ struct ath9k_channel *chan)
+{
+ u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band);
+
+ if (IS_CHAN_B(chan))
+ ctl |= CTL_11B;
+ else if (IS_CHAN_G(chan))
+ ctl |= CTL_11G;
+ else
+ ctl |= CTL_11A;
+
+ return ctl;
+}
+
static int ath9k_hw_process_ini(struct ath_hw *ah,
struct ath9k_channel *chan,
enum ath9k_ht_macmode macmode)
@@ -1256,7 +1274,6 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
int i, regWrites = 0;
struct ieee80211_channel *channel = chan->chan;
u32 modesIndex, freqIndex;
- int status;
switch (chan->chanmode) {
case CHANNEL_A:
@@ -1327,8 +1344,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
if (AR_SREV_9280(ah))
REG_WRITE_ARRAY(&ah->iniModesRxGain, modesIndex, regWrites);
- if (AR_SREV_9280(ah) || (AR_SREV_9285(ah) &&
- AR_SREV_9285_12_OR_LATER(ah)))
+ if (AR_SREV_9280(ah) || AR_SREV_9285_12_OR_LATER(ah))
REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
for (i = 0; i < ah->iniCommon.ia_rows; i++) {
@@ -1359,20 +1375,15 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
if (OLC_FOR_AR9280_20_LATER)
ath9k_olc_init(ah);
- status = ah->eep_ops->set_txpower(ah, chan,
- ath9k_regd_get_ctl(ah, chan),
- channel->max_antenna_gain * 2,
- channel->max_power * 2,
- min((u32) MAX_RATE_POWER,
- (u32) ah->regulatory.power_limit));
- if (status != 0) {
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
- "error init'ing transmit power\n");
- return -EIO;
- }
+ ah->eep_ops->set_txpower(ah, chan,
+ ath9k_regd_get_ctl(&ah->regulatory, chan),
+ channel->max_antenna_gain * 2,
+ channel->max_power * 2,
+ min((u32) MAX_RATE_POWER,
+ (u32) ah->regulatory.power_limit));
if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"ar5416SetRfRegs failed\n");
return -EIO;
}
@@ -1600,11 +1611,9 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
switch (type) {
case ATH9K_RESET_POWER_ON:
return ath9k_hw_set_reset_power_on(ah);
- break;
case ATH9K_RESET_WARM:
case ATH9K_RESET_COLD:
return ath9k_hw_set_reset(ah, type);
- break;
default:
return false;
}
@@ -1678,7 +1687,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
REG_WRITE(ah, AR_PHY_RFBUS_REQ, AR_PHY_RFBUS_REQ_EN);
if (!ath9k_hw_wait(ah, AR_PHY_RFBUS_GRANT, AR_PHY_RFBUS_GRANT_EN,
AR_PHY_RFBUS_GRANT_EN, AH_WAIT_TIMEOUT)) {
- DPRINTF(ah->ah_sc, ATH_DBG_REG_IO,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"Could not kill baseband RX\n");
return false;
}
@@ -1686,29 +1695,21 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
ath9k_hw_set_regs(ah, chan, macmode);
if (AR_SREV_9280_10_OR_LATER(ah)) {
- if (!(ath9k_hw_ar9280_set_channel(ah, chan))) {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
- "failed to set channel\n");
- return false;
- }
+ ath9k_hw_ar9280_set_channel(ah, chan);
} else {
if (!(ath9k_hw_set_channel(ah, chan))) {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
- "failed to set channel\n");
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "Failed to set channel\n");
return false;
}
}
- if (ah->eep_ops->set_txpower(ah, chan,
- ath9k_regd_get_ctl(ah, chan),
+ ah->eep_ops->set_txpower(ah, chan,
+ ath9k_regd_get_ctl(&ah->regulatory, chan),
channel->max_antenna_gain * 2,
channel->max_power * 2,
min((u32) MAX_RATE_POWER,
- (u32) ah->regulatory.power_limit)) != 0) {
- DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
- "error init'ing transmit power\n");
- return false;
- }
+ (u32) ah->regulatory.power_limit));
synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
if (IS_CHAN_B(chan))
@@ -2199,14 +2200,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
ah->txchainmask = sc->tx_chainmask;
ah->rxchainmask = sc->rx_chainmask;
- if (AR_SREV_9285(ah)) {
- ah->txchainmask &= 0x1;
- ah->rxchainmask &= 0x1;
- } else if (AR_SREV_9280(ah)) {
- ah->txchainmask &= 0x3;
- ah->rxchainmask &= 0x3;
- }
-
if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
return -EIO;
@@ -2242,7 +2235,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
ath9k_hw_mark_phy_inactive(ah);
if (!ath9k_hw_chip_reset(ah, chan)) {
- DPRINTF(ah->ah_sc, ATH_DBG_RESET, "chip reset failed\n");
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Chip reset failed\n");
return -EINVAL;
}
@@ -2304,13 +2297,11 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
- if (AR_SREV_9280_10_OR_LATER(ah)) {
- if (!(ath9k_hw_ar9280_set_channel(ah, chan)))
- return -EIO;
- } else {
+ if (AR_SREV_9280_10_OR_LATER(ah))
+ ath9k_hw_ar9280_set_channel(ah, chan);
+ else
if (!(ath9k_hw_set_channel(ah, chan)))
return -EIO;
- }
for (i = 0; i < AR_NUM_DCU; i++)
REG_WRITE(ah, AR_DQCUMASK(i), 1 << i);
@@ -2335,8 +2326,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
REG_WRITE(ah, AR_OBS, 8);
- if (ah->intr_mitigation) {
-
+ if (ah->config.intr_mitigation) {
REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
}
@@ -2385,8 +2375,8 @@ bool ath9k_hw_keyreset(struct ath_hw *ah, u16 entry)
u32 keyType;
if (entry >= ah->caps.keycache_size) {
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
- "entry %u out of range\n", entry);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "keychache entry %u out of range\n", entry);
return false;
}
@@ -2422,8 +2412,8 @@ bool ath9k_hw_keysetmac(struct ath_hw *ah, u16 entry, const u8 *mac)
u32 macHi, macLo;
if (entry >= ah->caps.keycache_size) {
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
- "entry %u out of range\n", entry);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "keychache entry %u out of range\n", entry);
return false;
}
@@ -2454,8 +2444,8 @@ bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
u32 keyType;
if (entry >= pCap->keycache_size) {
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
- "entry %u out of range\n", entry);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "keycache entry %u out of range\n", entry);
return false;
}
@@ -2465,7 +2455,7 @@ bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
break;
case ATH9K_CIPHER_AES_CCM:
if (!(pCap->hw_caps & ATH9K_HW_CAP_CIPHER_AESCCM)) {
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
+ DPRINTF(ah->ah_sc, ATH_DBG_ANY,
"AES-CCM not supported by mac rev 0x%x\n",
ah->hw_version.macRev);
return false;
@@ -2476,20 +2466,20 @@ bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
keyType = AR_KEYTABLE_TYPE_TKIP;
if (ATH9K_IS_MIC_ENABLED(ah)
&& entry + 64 >= pCap->keycache_size) {
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
+ DPRINTF(ah->ah_sc, ATH_DBG_ANY,
"entry %u inappropriate for TKIP\n", entry);
return false;
}
break;
case ATH9K_CIPHER_WEP:
- if (k->kv_len < LEN_WEP40) {
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
+ if (k->kv_len < WLAN_KEY_LEN_WEP40) {
+ DPRINTF(ah->ah_sc, ATH_DBG_ANY,
"WEP key length %u too small\n", k->kv_len);
return false;
}
- if (k->kv_len <= LEN_WEP40)
+ if (k->kv_len <= WLAN_KEY_LEN_WEP40)
keyType = AR_KEYTABLE_TYPE_40;
- else if (k->kv_len <= LEN_WEP104)
+ else if (k->kv_len <= WLAN_KEY_LEN_WEP104)
keyType = AR_KEYTABLE_TYPE_104;
else
keyType = AR_KEYTABLE_TYPE_128;
@@ -2498,7 +2488,7 @@ bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
keyType = AR_KEYTABLE_TYPE_CLR;
break;
default:
- DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"cipher %u not supported\n", k->kv_type);
return false;
}
@@ -2508,7 +2498,7 @@ bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
key2 = get_unaligned_le32(k->kv_val + 6);
key3 = get_unaligned_le16(k->kv_val + 10);
key4 = get_unaligned_le32(k->kv_val + 12);
- if (k->kv_len <= LEN_WEP104)
+ if (k->kv_len <= WLAN_KEY_LEN_WEP104)
key4 &= 0xff;
/*
@@ -2716,7 +2706,7 @@ static bool ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip)
AR_RTC_FORCE_WAKE_EN);
}
if (i == 0) {
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"Failed to wakeup in %uus\n", POWER_UP_TIME / 20);
return false;
}
@@ -2737,9 +2727,8 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
"UNDEFINED"
};
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, "%s -> %s (%s)\n",
- modes[ah->power_mode], modes[mode],
- setChip ? "set chip " : "");
+ DPRINTF(ah->ah_sc, ATH_DBG_RESET, "%s -> %s\n",
+ modes[ah->power_mode], modes[mode]);
switch (mode) {
case ATH9K_PM_AWAKE:
@@ -2753,7 +2742,7 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
ath9k_set_power_network_sleep(ah, setChip);
break;
default:
- DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"Unknown power mode %u\n", mode);
return false;
}
@@ -2943,7 +2932,7 @@ bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked)
*masked = isr & ATH9K_INT_COMMON;
- if (ah->intr_mitigation) {
+ if (ah->config.intr_mitigation) {
if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM))
*masked |= ATH9K_INT_RX;
}
@@ -3000,6 +2989,7 @@ bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked)
DPRINTF(ah->ah_sc, ATH_DBG_ANY,
"received PCI PERR interrupt\n");
}
+ *masked |= ATH9K_INT_FATAL;
}
if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) {
DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT,
@@ -3061,7 +3051,7 @@ enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
}
if (ints & ATH9K_INT_RX) {
mask |= AR_IMR_RXERR;
- if (ah->intr_mitigation)
+ if (ah->config.intr_mitigation)
mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
else
mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
@@ -3259,7 +3249,7 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
/* HW Capabilities */
/*******************/
-bool ath9k_hw_fill_cap_info(struct ath_hw *ah)
+void ath9k_hw_fill_cap_info(struct ath_hw *ah)
{
struct ath9k_hw_capabilities *pCap = &ah->caps;
u16 capField = 0, eeval;
@@ -3343,8 +3333,6 @@ bool ath9k_hw_fill_cap_info(struct ath_hw *ah)
pCap->hw_caps |= ATH9K_HW_CAP_MIC_TKIP;
pCap->hw_caps |= ATH9K_HW_CAP_MIC_AESCCM;
- pCap->hw_caps |= ATH9K_HW_CAP_CHAN_SPREAD;
-
if (ah->config.ht_enable)
pCap->hw_caps |= ATH9K_HW_CAP_HT;
else
@@ -3368,7 +3356,6 @@ bool ath9k_hw_fill_cap_info(struct ath_hw *ah)
pCap->keycache_size = AR_KEYTABLE_SIZE;
pCap->hw_caps |= ATH9K_HW_CAP_FASTCC;
- pCap->num_mr_retries = 4;
pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD;
if (AR_SREV_9285_10_OR_LATER(ah))
@@ -3378,14 +3365,6 @@ bool ath9k_hw_fill_cap_info(struct ath_hw *ah)
else
pCap->num_gpio_pins = AR_NUM_GPIO;
- if (AR_SREV_9280_10_OR_LATER(ah)) {
- pCap->hw_caps |= ATH9K_HW_CAP_WOW;
- pCap->hw_caps |= ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT;
- } else {
- pCap->hw_caps &= ~ATH9K_HW_CAP_WOW;
- pCap->hw_caps &= ~ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT;
- }
-
if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) {
pCap->hw_caps |= ATH9K_HW_CAP_CST;
pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX;
@@ -3411,7 +3390,8 @@ bool ath9k_hw_fill_cap_info(struct ath_hw *ah)
(ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) ||
(ah->hw_version.macVersion == AR_SREV_VERSION_9160) ||
(ah->hw_version.macVersion == AR_SREV_VERSION_9100) ||
- (ah->hw_version.macVersion == AR_SREV_VERSION_9280))
+ (ah->hw_version.macVersion == AR_SREV_VERSION_9280) ||
+ (ah->hw_version.macVersion == AR_SREV_VERSION_9285))
pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
else
pCap->hw_caps |= ATH9K_HW_CAP_AUTOSLEEP;
@@ -3445,8 +3425,6 @@ bool ath9k_hw_fill_cap_info(struct ath_hw *ah)
ah->btactive_gpio = 6;
ah->wlanactive_gpio = 5;
}
-
- return true;
}
bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
@@ -3754,22 +3732,19 @@ bool ath9k_hw_disable(struct ath_hw *ah)
return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD);
}
-bool ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
{
struct ath9k_channel *chan = ah->curchan;
struct ieee80211_channel *channel = chan->chan;
ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER);
- if (ah->eep_ops->set_txpower(ah, chan,
- ath9k_regd_get_ctl(ah, chan),
- channel->max_antenna_gain * 2,
- channel->max_power * 2,
- min((u32) MAX_RATE_POWER,
- (u32) ah->regulatory.power_limit)) != 0)
- return false;
-
- return true;
+ ah->eep_ops->set_txpower(ah, chan,
+ ath9k_regd_get_ctl(&ah->regulatory, chan),
+ channel->max_antenna_gain * 2,
+ channel->max_power * 2,
+ min((u32) MAX_RATE_POWER,
+ (u32) ah->regulatory.power_limit));
}
void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac)
diff --git a/drivers/net/wireless/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 0b594e0ee260..dd8508ef6e05 100644
--- a/drivers/net/wireless/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -25,10 +25,11 @@
#include "ani.h"
#include "eeprom.h"
#include "calib.h"
-#include "regd.h"
#include "reg.h"
#include "phy.h"
+#include "../regd.h"
+
#define ATHEROS_VENDOR_ID 0x168c
#define AR5416_DEVID_PCI 0x0023
#define AR5416_DEVID_PCIE 0x0024
@@ -124,29 +125,24 @@ enum wireless_mode {
};
enum ath9k_hw_caps {
- ATH9K_HW_CAP_CHAN_SPREAD = BIT(0),
- ATH9K_HW_CAP_MIC_AESCCM = BIT(1),
- ATH9K_HW_CAP_MIC_CKIP = BIT(2),
- ATH9K_HW_CAP_MIC_TKIP = BIT(3),
- ATH9K_HW_CAP_CIPHER_AESCCM = BIT(4),
- ATH9K_HW_CAP_CIPHER_CKIP = BIT(5),
- ATH9K_HW_CAP_CIPHER_TKIP = BIT(6),
- ATH9K_HW_CAP_VEOL = BIT(7),
- ATH9K_HW_CAP_BSSIDMASK = BIT(8),
- ATH9K_HW_CAP_MCAST_KEYSEARCH = BIT(9),
- ATH9K_HW_CAP_CHAN_HALFRATE = BIT(10),
- ATH9K_HW_CAP_CHAN_QUARTERRATE = BIT(11),
- ATH9K_HW_CAP_HT = BIT(12),
- ATH9K_HW_CAP_GTT = BIT(13),
- ATH9K_HW_CAP_FASTCC = BIT(14),
- ATH9K_HW_CAP_RFSILENT = BIT(15),
- ATH9K_HW_CAP_WOW = BIT(16),
- ATH9K_HW_CAP_CST = BIT(17),
- ATH9K_HW_CAP_ENHANCEDPM = BIT(18),
- ATH9K_HW_CAP_AUTOSLEEP = BIT(19),
- ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(20),
- ATH9K_HW_CAP_WOW_MATCHPATTERN_EXACT = BIT(21),
- ATH9K_HW_CAP_BT_COEX = BIT(22)
+ ATH9K_HW_CAP_MIC_AESCCM = BIT(0),
+ ATH9K_HW_CAP_MIC_CKIP = BIT(1),
+ ATH9K_HW_CAP_MIC_TKIP = BIT(2),
+ ATH9K_HW_CAP_CIPHER_AESCCM = BIT(3),
+ ATH9K_HW_CAP_CIPHER_CKIP = BIT(4),
+ ATH9K_HW_CAP_CIPHER_TKIP = BIT(5),
+ ATH9K_HW_CAP_VEOL = BIT(6),
+ ATH9K_HW_CAP_BSSIDMASK = BIT(7),
+ ATH9K_HW_CAP_MCAST_KEYSEARCH = BIT(8),
+ ATH9K_HW_CAP_HT = BIT(9),
+ ATH9K_HW_CAP_GTT = BIT(10),
+ ATH9K_HW_CAP_FASTCC = BIT(11),
+ ATH9K_HW_CAP_RFSILENT = BIT(12),
+ ATH9K_HW_CAP_CST = BIT(13),
+ ATH9K_HW_CAP_ENHANCEDPM = BIT(14),
+ ATH9K_HW_CAP_AUTOSLEEP = BIT(15),
+ ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(16),
+ ATH9K_HW_CAP_BT_COEX = BIT(17)
};
enum ath9k_capability_type {
@@ -166,7 +162,6 @@ struct ath9k_hw_capabilities {
u16 keycache_size;
u16 low_5ghz_chan, high_5ghz_chan;
u16 low_2ghz_chan, high_2ghz_chan;
- u16 num_mr_retries;
u16 rts_aggr_limit;
u8 tx_chainmask;
u8 rx_chainmask;
@@ -184,11 +179,8 @@ struct ath9k_ops_config {
int ack_6mb;
int cwm_ignore_extcca;
u8 pcie_powersave_enable;
- u8 pcie_l1skp_enable;
u8 pcie_clock_req;
u32 pcie_waen;
- int pcie_power_reset;
- u8 pcie_restore;
u8 analog_shiftreg;
u8 ht_enable;
u32 ofdm_trig_low;
@@ -196,17 +188,10 @@ struct ath9k_ops_config {
u32 cck_trig_high;
u32 cck_trig_low;
u32 enable_ani;
- u8 noise_immunity_level;
- u32 ofdm_weaksignal_det;
- u32 cck_weaksignal_thr;
- u8 spur_immunity_level;
- u8 firstep_level;
- int8_t rssi_thr_high;
- int8_t rssi_thr_low;
u16 diversity_control;
u16 antenna_switch_swap;
int serialize_regmode;
- int intr_mitigation;
+ bool intr_mitigation;
#define SPUR_DISABLE 0
#define SPUR_ENABLE_IOCTL 1
#define SPUR_ENABLE_EEPROM 2
@@ -281,13 +266,6 @@ enum ath9k_int {
#define CHANNEL_HT40PLUS 0x20000
#define CHANNEL_HT40MINUS 0x40000
-#define CHANNEL_INTERFERENCE 0x01
-#define CHANNEL_DFS 0x02
-#define CHANNEL_4MS_LIMIT 0x04
-#define CHANNEL_DFS_CLEAR 0x08
-#define CHANNEL_DISALLOW_ADHOC 0x10
-#define CHANNEL_PER_11D_ADHOC 0x20
-
#define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM)
#define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK)
#define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM)
@@ -318,10 +296,6 @@ struct ath9k_channel {
int16_t rawNoiseFloor;
};
-#define IS_CHAN_A(_c) ((((_c)->channelFlags & CHANNEL_A) == CHANNEL_A) || \
- (((_c)->channelFlags & CHANNEL_A_HT20) == CHANNEL_A_HT20) || \
- (((_c)->channelFlags & CHANNEL_A_HT40PLUS) == CHANNEL_A_HT40PLUS) || \
- (((_c)->channelFlags & CHANNEL_A_HT40MINUS) == CHANNEL_A_HT40MINUS))
#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \
(((_c)->channelFlags & CHANNEL_G_HT20) == CHANNEL_G_HT20) || \
(((_c)->channelFlags & CHANNEL_G_HT40PLUS) == CHANNEL_G_HT40PLUS) || \
@@ -329,7 +303,6 @@ struct ath9k_channel {
#define IS_CHAN_OFDM(_c) (((_c)->channelFlags & CHANNEL_OFDM) != 0)
#define IS_CHAN_5GHZ(_c) (((_c)->channelFlags & CHANNEL_5GHZ) != 0)
#define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0)
-#define IS_CHAN_PASSIVE(_c) (((_c)->channelFlags & CHANNEL_PASSIVE) != 0)
#define IS_CHAN_HALF_RATE(_c) (((_c)->channelFlags & CHANNEL_HALF) != 0)
#define IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0)
#define IS_CHAN_A_5MHZ_SPACED(_c) \
@@ -420,7 +393,7 @@ struct ath_hw {
struct ath9k_hw_version hw_version;
struct ath9k_ops_config config;
struct ath9k_hw_capabilities caps;
- struct ath9k_regulatory regulatory;
+ struct ath_regulatory regulatory;
struct ath9k_channel channels[38];
struct ath9k_channel *curchan;
@@ -463,14 +436,14 @@ struct ath_hw {
enum ath9k_ant_setting diversity_control;
/* Calibration */
- enum hal_cal_types supp_cals;
- struct hal_cal_list iq_caldata;
- struct hal_cal_list adcgain_caldata;
- struct hal_cal_list adcdc_calinitdata;
- struct hal_cal_list adcdc_caldata;
- struct hal_cal_list *cal_list;
- struct hal_cal_list *cal_list_last;
- struct hal_cal_list *cal_list_curr;
+ enum ath9k_cal_types supp_cals;
+ struct ath9k_cal_list iq_caldata;
+ struct ath9k_cal_list adcgain_caldata;
+ struct ath9k_cal_list adcdc_calinitdata;
+ struct ath9k_cal_list adcdc_caldata;
+ struct ath9k_cal_list *cal_list;
+ struct ath9k_cal_list *cal_list_last;
+ struct ath9k_cal_list *cal_list_curr;
#define totalPowerMeasI meas0.unsign
#define totalPowerMeasQ meas1.unsign
#define totalIqCorrMeas meas2.sign
@@ -540,7 +513,6 @@ struct ath_hw {
enum ath9k_ani_cmd ani_function;
u32 intr_txqs;
- bool intr_mitigation;
enum ath9k_ht_extprotspacing extprotspacing;
u8 txchainmask;
u8 rxchainmask;
@@ -573,7 +545,7 @@ struct ath_hw *ath9k_hw_attach(u16 devid, struct ath_softc *sc, int *error);
void ath9k_hw_rfdetach(struct ath_hw *ah);
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
bool bChannelChange);
-bool ath9k_hw_fill_cap_info(struct ath_hw *ah);
+void ath9k_hw_fill_cap_info(struct ath_hw *ah);
bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
u32 capability, u32 *result);
bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type,
@@ -608,7 +580,8 @@ bool ath9k_hw_setantennaswitch(struct ath_hw *ah,
bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
u32 ath9k_hw_reverse_bits(u32 val, u32 n);
bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high);
-u16 ath9k_hw_computetxtime(struct ath_hw *ah, struct ath_rate_table *rates,
+u16 ath9k_hw_computetxtime(struct ath_hw *ah,
+ const struct ath_rate_table *rates,
u32 frameLen, u16 rateix, bool shortPreamble);
void ath9k_hw_get_channel_centers(struct ath_hw *ah,
struct ath9k_channel *chan,
@@ -617,7 +590,7 @@ u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
bool ath9k_hw_phy_disable(struct ath_hw *ah);
bool ath9k_hw_disable(struct ath_hw *ah);
-bool ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit);
+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit);
void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac);
void ath9k_hw_setopmode(struct ath_hw *ah);
void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
diff --git a/drivers/net/wireless/ath9k/initvals.h b/drivers/net/wireless/ath/ath9k/initvals.h
index e2f0a34b79a1..e2f0a34b79a1 100644
--- a/drivers/net/wireless/ath9k/initvals.h
+++ b/drivers/net/wireless/ath/ath9k/initvals.h
diff --git a/drivers/net/wireless/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index e0a6dee45839..8ae4ec21667b 100644
--- a/drivers/net/wireless/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -49,7 +49,7 @@ bool ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp)
bool ath9k_hw_txstart(struct ath_hw *ah, u32 q)
{
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "queue %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Enable TXE on queue: %u\n", q);
REG_WRITE(ah, AR_Q_TXE, 1 << q);
@@ -110,13 +110,15 @@ bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
u32 wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
if (q >= pCap->total_queues) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Stopping TX DMA, "
+ "invalid queue: %u\n", q);
return false;
}
qi = &ah->txq[q];
if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue\n");
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Stopping TX DMA, "
+ "inactive queue: %u\n", q);
return false;
}
@@ -146,7 +148,7 @@ bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
break;
DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
- "TSF have moved while trying to set "
+ "TSF has moved while trying to set "
"quiet time TSF: 0x%08x\n", tsfLow);
}
@@ -158,8 +160,8 @@ bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
wait = wait_time;
while (ath9k_hw_numtxpending(ah, q)) {
if ((--wait) == 0) {
- DPRINTF(ah->ah_sc, ATH_DBG_XMIT,
- "Failed to stop Tx DMA in 100 "
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
+ "Failed to stop TX DMA in 100 "
"msec after killing last frame\n");
break;
}
@@ -454,17 +456,19 @@ bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
struct ath9k_tx_queue_info *qi;
if (q >= pCap->total_queues) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Set TXQ properties, "
+ "invalid queue: %u\n", q);
return false;
}
qi = &ah->txq[q];
if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue\n");
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Set TXQ properties, "
+ "inactive queue: %u\n", q);
return false;
}
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "queue %p\n", qi);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Set queue properties for: %u\n", q);
qi->tqi_ver = qinfo->tqi_ver;
qi->tqi_subtype = qinfo->tqi_subtype;
@@ -521,13 +525,15 @@ bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q,
struct ath9k_tx_queue_info *qi;
if (q >= pCap->total_queues) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Get TXQ properties, "
+ "invalid queue: %u\n", q);
return false;
}
qi = &ah->txq[q];
if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue\n");
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Get TXQ properties, "
+ "inactive queue: %u\n", q);
return false;
}
@@ -575,22 +581,23 @@ int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type,
ATH9K_TX_QUEUE_INACTIVE)
break;
if (q == pCap->total_queues) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
- "no available tx queue\n");
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "No available TX queue\n");
return -1;
}
break;
default:
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "bad tx queue type %u\n", type);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Invalid TX queue type: %u\n",
+ type);
return -1;
}
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "queue %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Setup TX queue: %u\n", q);
qi = &ah->txq[q];
if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
- "tx queue %u already active\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "TX queue: %u already active\n", q);
return -1;
}
memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
@@ -620,16 +627,18 @@ bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q)
struct ath9k_tx_queue_info *qi;
if (q >= pCap->total_queues) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Release TXQ, "
+ "invalid queue: %u\n", q);
return false;
}
qi = &ah->txq[q];
if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Release TXQ, "
+ "inactive queue: %u\n", q);
return false;
}
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "release queue %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Release TX queue: %u\n", q);
qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
ah->txok_interrupt_mask &= ~(1 << q);
@@ -650,17 +659,19 @@ bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q)
u32 cwMin, chanCwMin, value;
if (q >= pCap->total_queues) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Reset TXQ, "
+ "invalid queue: %u\n", q);
return false;
}
qi = &ah->txq[q];
if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Reset TXQ, "
+ "inactive queue: %u\n", q);
return true;
}
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "reset queue %u\n", q);
+ DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "Reset TX queue: %u\n", q);
if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
if (chan && IS_CHAN_B(chan))
@@ -894,7 +905,7 @@ bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
reg = REG_READ(ah, AR_OBS_BUS_1);
DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
- "rx failed to go idle in 10 ms RXSM=0x%x\n", reg);
+ "RX failed to go idle in 10 ms RXSM=0x%x\n", reg);
return false;
}
@@ -949,8 +960,8 @@ bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
}
if (i == 0) {
- DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
- "dma failed to stop in %d ms "
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ "DMA failed to stop in %d ms "
"AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
AH_RX_STOP_DMA_TIMEOUT / 1000,
REG_READ(ah, AR_CR),
diff --git a/drivers/net/wireless/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index 1176bce8b76c..1176bce8b76c 100644
--- a/drivers/net/wireless/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 13d4e6756c99..430a6ca864f6 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -35,14 +35,14 @@ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
#define CHAN2G(_freq, _idx) { \
.center_freq = (_freq), \
.hw_value = (_idx), \
- .max_power = 30, \
+ .max_power = 20, \
}
#define CHAN5G(_freq, _idx) { \
.band = IEEE80211_BAND_5GHZ, \
.center_freq = (_freq), \
.hw_value = (_idx), \
- .max_power = 30, \
+ .max_power = 20, \
}
/* Some 2 GHz radios are actually tunable on 2312-2732
@@ -189,7 +189,7 @@ static u8 parse_mpdudensity(u8 mpdudensity)
static void ath_setup_rates(struct ath_softc *sc, enum ieee80211_band band)
{
- struct ath_rate_table *rate_table = NULL;
+ const struct ath_rate_table *rate_table = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_rate *rate;
int i, maxrates;
@@ -280,14 +280,13 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
"Unable to reset channel (%u Mhz) "
- "reset status %u\n",
+ "reset status %d\n",
channel->center_freq, r);
spin_unlock_bh(&sc->sc_resetlock);
return r;
}
spin_unlock_bh(&sc->sc_resetlock);
- sc->sc_flags &= ~SC_OP_CHAINMASK_UPDATE;
sc->sc_flags &= ~SC_OP_FULL_RESET;
if (ath_startrecv(sc) != 0) {
@@ -330,6 +329,12 @@ static void ath_ani_calibrate(unsigned long data)
if (sc->sc_flags & SC_OP_SCANNING)
goto set_timer;
+ /* Only calibrate if awake */
+ if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE)
+ goto set_timer;
+
+ ath9k_ps_wakeup(sc);
+
/* Long calibration runs independently of short calibration. */
if ((timestamp - sc->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) {
longcal = true;
@@ -368,31 +373,21 @@ static void ath_ani_calibrate(unsigned long data)
/* Perform calibration if necessary */
if (longcal || shortcal) {
- bool iscaldone = false;
-
- if (ath9k_hw_calibrate(ah, ah->curchan,
- sc->rx_chainmask, longcal,
- &iscaldone)) {
- if (longcal)
- sc->ani.noise_floor =
- ath9k_hw_getchan_noise(ah,
- ah->curchan);
-
- DPRINTF(sc, ATH_DBG_ANI,
- "calibrate chan %u/%x nf: %d\n",
- ah->curchan->channel,
- ah->curchan->channelFlags,
- sc->ani.noise_floor);
- } else {
- DPRINTF(sc, ATH_DBG_ANY,
- "calibrate chan %u/%x failed\n",
- ah->curchan->channel,
- ah->curchan->channelFlags);
- }
- sc->ani.caldone = iscaldone;
+ sc->ani.caldone = ath9k_hw_calibrate(ah, ah->curchan,
+ sc->rx_chainmask, longcal);
+
+ if (longcal)
+ sc->ani.noise_floor = ath9k_hw_getchan_noise(ah,
+ ah->curchan);
+
+ DPRINTF(sc, ATH_DBG_ANI," calibrate chan %u/%x nf: %d\n",
+ ah->curchan->channel, ah->curchan->channelFlags,
+ sc->ani.noise_floor);
}
}
+ ath9k_ps_restore(sc);
+
set_timer:
/*
* Set timer interval based on previous results.
@@ -408,6 +403,18 @@ set_timer:
mod_timer(&sc->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
}
+static void ath_start_ani(struct ath_softc *sc)
+{
+ unsigned long timestamp = jiffies_to_msecs(jiffies);
+
+ sc->ani.longcal_timer = timestamp;
+ sc->ani.shortcal_timer = timestamp;
+ sc->ani.checkani_timer = timestamp;
+
+ mod_timer(&sc->ani.timer,
+ jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
+}
+
/*
* Update tx/rx chainmask. For legacy association,
* hard code chainmask to 1x1, for 11n association, use
@@ -416,7 +423,6 @@ set_timer:
*/
void ath_update_chainmask(struct ath_softc *sc, int is_ht)
{
- sc->sc_flags |= SC_OP_CHAINMASK_UPDATE;
if (is_ht ||
(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BT_COEX)) {
sc->tx_chainmask = sc->sc_ah->caps.tx_chainmask;
@@ -436,12 +442,12 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta)
an = (struct ath_node *)sta->drv_priv;
- if (sc->sc_flags & SC_OP_TXAGGR)
+ if (sc->sc_flags & SC_OP_TXAGGR) {
ath_tx_node_init(sc, an);
-
- an->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
- sta->ht_cap.ampdu_factor);
- an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);
+ an->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
+ sta->ht_cap.ampdu_factor);
+ an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);
+ }
}
static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
@@ -457,133 +463,130 @@ static void ath9k_tasklet(unsigned long data)
struct ath_softc *sc = (struct ath_softc *)data;
u32 status = sc->intrstatus;
+ ath9k_ps_wakeup(sc);
+
if (status & ATH9K_INT_FATAL) {
- /* need a chip reset */
ath_reset(sc, false);
+ ath9k_ps_restore(sc);
return;
- } else {
+ }
- if (status &
- (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN)) {
- spin_lock_bh(&sc->rx.rxflushlock);
- ath_rx_tasklet(sc, 0);
- spin_unlock_bh(&sc->rx.rxflushlock);
- }
- /* XXX: optimize this */
- if (status & ATH9K_INT_TX)
- ath_tx_tasklet(sc);
+ if (status & (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN)) {
+ spin_lock_bh(&sc->rx.rxflushlock);
+ ath_rx_tasklet(sc, 0);
+ spin_unlock_bh(&sc->rx.rxflushlock);
+ }
+
+ if (status & ATH9K_INT_TX)
+ ath_tx_tasklet(sc);
+
+ if ((status & ATH9K_INT_TSFOOR) &&
+ (sc->hw->conf.flags & IEEE80211_CONF_PS)) {
+ /*
+ * TSF sync does not look correct; remain awake to sync with
+ * the next Beacon.
+ */
+ DPRINTF(sc, ATH_DBG_PS, "TSFOOR - Sync with next Beacon\n");
+ sc->sc_flags |= SC_OP_WAIT_FOR_BEACON | SC_OP_BEACON_SYNC;
}
/* re-enable hardware interrupt */
ath9k_hw_set_interrupts(sc->sc_ah, sc->imask);
+ ath9k_ps_restore(sc);
}
irqreturn_t ath_isr(int irq, void *dev)
{
+#define SCHED_INTR ( \
+ ATH9K_INT_FATAL | \
+ ATH9K_INT_RXORN | \
+ ATH9K_INT_RXEOL | \
+ ATH9K_INT_RX | \
+ ATH9K_INT_TX | \
+ ATH9K_INT_BMISS | \
+ ATH9K_INT_CST | \
+ ATH9K_INT_TSFOOR)
+
struct ath_softc *sc = dev;
struct ath_hw *ah = sc->sc_ah;
enum ath9k_int status;
bool sched = false;
- do {
- if (sc->sc_flags & SC_OP_INVALID) {
- /*
- * The hardware is not ready/present, don't
- * touch anything. Note this can happen early
- * on if the IRQ is shared.
- */
- return IRQ_NONE;
- }
- if (!ath9k_hw_intrpend(ah)) { /* shared irq, not for us */
- return IRQ_NONE;
- }
+ /*
+ * The hardware is not ready/present, don't
+ * touch anything. Note this can happen early
+ * on if the IRQ is shared.
+ */
+ if (sc->sc_flags & SC_OP_INVALID)
+ return IRQ_NONE;
- /*
- * Figure out the reason(s) for the interrupt. Note
- * that the hal returns a pseudo-ISR that may include
- * bits we haven't explicitly enabled so we mask the
- * value to insure we only process bits we requested.
- */
- ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
- status &= sc->imask; /* discard unasked-for bits */
+ /* shared irq, not for us */
- /*
- * If there are no status bits set, then this interrupt was not
- * for me (should have been caught above).
- */
- if (!status)
- return IRQ_NONE;
+ if (!ath9k_hw_intrpend(ah))
+ return IRQ_NONE;
- sc->intrstatus = status;
- ath9k_ps_wakeup(sc);
+ /*
+ * Figure out the reason(s) for the interrupt. Note
+ * that the hal returns a pseudo-ISR that may include
+ * bits we haven't explicitly enabled so we mask the
+ * value to insure we only process bits we requested.
+ */
+ ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
+ status &= sc->imask; /* discard unasked-for bits */
- if (status & ATH9K_INT_FATAL) {
- /* need a chip reset */
- sched = true;
- } else if (status & ATH9K_INT_RXORN) {
- /* need a chip reset */
- sched = true;
- } else {
- if (status & ATH9K_INT_SWBA) {
- /* schedule a tasklet for beacon handling */
- tasklet_schedule(&sc->bcon_tasklet);
- }
- if (status & ATH9K_INT_RXEOL) {
- /*
- * NB: the hardware should re-read the link when
- * RXE bit is written, but it doesn't work
- * at least on older hardware revs.
- */
- sched = true;
- }
+ /*
+ * If there are no status bits set, then this interrupt was not
+ * for me (should have been caught above).
+ */
+ if (!status)
+ return IRQ_NONE;
- if (status & ATH9K_INT_TXURN)
- /* bump tx trigger level */
- ath9k_hw_updatetxtriglevel(ah, true);
- /* XXX: optimize this */
- if (status & ATH9K_INT_RX)
- sched = true;
- if (status & ATH9K_INT_TX)
- sched = true;
- if (status & ATH9K_INT_BMISS)
- sched = true;
- /* carrier sense timeout */
- if (status & ATH9K_INT_CST)
- sched = true;
- if (status & ATH9K_INT_MIB) {
- /*
- * Disable interrupts until we service the MIB
- * interrupt; otherwise it will continue to
- * fire.
- */
- ath9k_hw_set_interrupts(ah, 0);
- /*
- * Let the hal handle the event. We assume
- * it will clear whatever condition caused
- * the interrupt.
- */
- ath9k_hw_procmibevent(ah, &sc->nodestats);
- ath9k_hw_set_interrupts(ah, sc->imask);
- }
- if (status & ATH9K_INT_TIM_TIMER) {
- if (!(ah->caps.hw_caps &
- ATH9K_HW_CAP_AUTOSLEEP)) {
- /* Clear RxAbort bit so that we can
- * receive frames */
- ath9k_hw_setpower(ah, ATH9K_PM_AWAKE);
- ath9k_hw_setrxabort(ah, 0);
- sched = true;
- sc->sc_flags |= SC_OP_WAIT_FOR_BEACON;
- }
- }
- if (status & ATH9K_INT_TSFOOR) {
- /* FIXME: Handle this interrupt for power save */
- sched = true;
- }
+ /* Cache the status */
+ sc->intrstatus = status;
+
+ if (status & SCHED_INTR)
+ sched = true;
+
+ /*
+ * If a FATAL or RXORN interrupt is received, we have to reset the
+ * chip immediately.
+ */
+ if (status & (ATH9K_INT_FATAL | ATH9K_INT_RXORN))
+ goto chip_reset;
+
+ if (status & ATH9K_INT_SWBA)
+ tasklet_schedule(&sc->bcon_tasklet);
+
+ if (status & ATH9K_INT_TXURN)
+ ath9k_hw_updatetxtriglevel(ah, true);
+
+ if (status & ATH9K_INT_MIB) {
+ /*
+ * Disable interrupts until we service the MIB
+ * interrupt; otherwise it will continue to
+ * fire.
+ */
+ ath9k_hw_set_interrupts(ah, 0);
+ /*
+ * Let the hal handle the event. We assume
+ * it will clear whatever condition caused
+ * the interrupt.
+ */
+ ath9k_hw_procmibevent(ah, &sc->nodestats);
+ ath9k_hw_set_interrupts(ah, sc->imask);
+ }
+
+ if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
+ if (status & ATH9K_INT_TIM_TIMER) {
+ /* Clear RxAbort bit so that we can
+ * receive frames */
+ ath9k_hw_setpower(ah, ATH9K_PM_AWAKE);
+ ath9k_hw_setrxabort(sc->sc_ah, 0);
+ sc->sc_flags |= SC_OP_WAIT_FOR_BEACON;
}
- ath9k_ps_restore(sc);
- } while (0);
+
+chip_reset:
ath_debug_stat_interrupt(sc, status);
@@ -594,6 +597,8 @@ irqreturn_t ath_isr(int irq, void *dev)
}
return IRQ_HANDLED;
+
+#undef SCHED_INTR
}
static u32 ath_get_extchanmode(struct ath_softc *sc,
@@ -676,7 +681,7 @@ static int ath_setkey_tkip(struct ath_softc *sc, u16 keyix, const u8 *key,
memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic));
if (!ath9k_hw_set_keycache_entry(sc->sc_ah, keyix, hk, NULL)) {
/* TX MIC entry failed. No need to proceed further */
- DPRINTF(sc, ATH_DBG_KEYCACHE,
+ DPRINTF(sc, ATH_DBG_FATAL,
"Setting TX MIC Key Failed\n");
return 0;
}
@@ -909,6 +914,13 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
if (avp->av_opmode == NL80211_IFTYPE_STATION) {
sc->curaid = bss_conf->aid;
ath9k_hw_write_associd(sc);
+
+ /*
+ * Request a re-configuration of Beacon related timers
+ * on the receipt of the first Beacon frame (i.e.,
+ * after time sync with the AP).
+ */
+ sc->sc_flags |= SC_OP_BEACON_SYNC;
}
/* Configure the beacon */
@@ -920,11 +932,9 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
sc->nodestats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
sc->nodestats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER;
- /* Start ANI */
- mod_timer(&sc->ani.timer,
- jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
+ ath_start_ani(sc);
} else {
- DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info DISSOC\n");
+ DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
sc->curaid = 0;
}
}
@@ -1098,14 +1108,14 @@ void ath_radio_enable(struct ath_softc *sc)
int r;
ath9k_ps_wakeup(sc);
- spin_lock_bh(&sc->sc_resetlock);
+ ath9k_hw_configpcipowersave(ah, 0);
+ spin_lock_bh(&sc->sc_resetlock);
r = ath9k_hw_reset(ah, ah->curchan, false);
-
if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
"Unable to reset channel %u (%uMhz) ",
- "reset status %u\n",
+ "reset status %d\n",
channel->center_freq, r);
}
spin_unlock_bh(&sc->sc_resetlock);
@@ -1157,12 +1167,13 @@ void ath_radio_disable(struct ath_softc *sc)
if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
"Unable to reset channel %u (%uMhz) "
- "reset status %u\n",
+ "reset status %d\n",
channel->center_freq, r);
}
spin_unlock_bh(&sc->sc_resetlock);
ath9k_hw_phy_disable(ah);
+ ath9k_hw_configpcipowersave(ah, 1);
ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
ath9k_ps_restore(sc);
}
@@ -1362,6 +1373,17 @@ void ath_detach(struct ath_softc *sc)
ath9k_ps_restore(sc);
}
+static int ath9k_reg_notifier(struct wiphy *wiphy,
+ struct regulatory_request *request)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct ath_wiphy *aphy = hw->priv;
+ struct ath_softc *sc = aphy->sc;
+ struct ath_regulatory *reg = &sc->sc_ah->regulatory;
+
+ return ath_reg_notifier_apply(wiphy, request, reg);
+}
+
static int ath_init(u16 devid, struct ath_softc *sc)
{
struct ath_hw *ah = NULL;
@@ -1403,7 +1425,7 @@ static int ath_init(u16 devid, struct ath_softc *sc)
/* Get the hardware key cache size. */
sc->keymax = ah->caps.keycache_size;
if (sc->keymax > ATH_KEYMAX) {
- DPRINTF(sc, ATH_DBG_KEYCACHE,
+ DPRINTF(sc, ATH_DBG_ANY,
"Warning, using only %u entries in %u key cache\n",
ATH_KEYMAX, sc->keymax);
sc->keymax = ATH_KEYMAX;
@@ -1416,7 +1438,7 @@ static int ath_init(u16 devid, struct ath_softc *sc)
for (i = 0; i < sc->keymax; i++)
ath9k_hw_keyreset(ah, (u16) i);
- if (ath9k_regd_init(sc->sc_ah))
+ if (error)
goto bad;
/* default to MONITOR mode */
@@ -1545,9 +1567,6 @@ static int ath_init(u16 devid, struct ath_softc *sc)
sc->beacon.bslot_aphy[i] = NULL;
}
- /* save MISC configurations */
- sc->config.swBeaconProcess = 1;
-
/* setup channels and rates */
sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
@@ -1602,9 +1621,6 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_MESH_POINT);
- hw->wiphy->reg_notifier = ath9k_reg_notifier;
- hw->wiphy->strict_regulatory = true;
-
hw->queues = 4;
hw->max_rates = 4;
hw->channel_change_time = 5000;
@@ -1625,8 +1641,8 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
int ath_attach(u16 devid, struct ath_softc *sc)
{
struct ieee80211_hw *hw = sc->hw;
- const struct ieee80211_regdomain *regd;
int error = 0, i;
+ struct ath_regulatory *reg;
DPRINTF(sc, ATH_DBG_CONFIG, "Attach ATH hw\n");
@@ -1640,6 +1656,13 @@ int ath_attach(u16 devid, struct ath_softc *sc)
ath_set_hw_capab(sc, hw);
+ error = ath_regd_init(&sc->sc_ah->regulatory, sc->hw->wiphy,
+ ath9k_reg_notifier);
+ if (error)
+ return error;
+
+ reg = &sc->sc_ah->regulatory;
+
if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes))
@@ -1666,31 +1689,14 @@ int ath_attach(u16 devid, struct ath_softc *sc)
goto error_attach;
#endif
- if (ath9k_is_world_regd(sc->sc_ah)) {
- /* Anything applied here (prior to wiphy registration) gets
- * saved on the wiphy orig_* parameters */
- regd = ath9k_world_regdomain(sc->sc_ah);
- hw->wiphy->custom_regulatory = true;
- hw->wiphy->strict_regulatory = false;
- } else {
- /* This gets applied in the case of the absense of CRDA,
- * it's our own custom world regulatory domain, similar to
- * cfg80211's but we enable passive scanning */
- regd = ath9k_default_world_regdomain();
- }
- wiphy_apply_custom_regulatory(hw->wiphy, regd);
- ath9k_reg_apply_radar_flags(hw->wiphy);
- ath9k_reg_apply_world_flags(hw->wiphy, NL80211_REGDOM_SET_BY_DRIVER);
-
INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
sc->wiphy_scheduler_int = msecs_to_jiffies(500);
error = ieee80211_register_hw(hw);
- if (!ath9k_is_world_regd(sc->sc_ah)) {
- error = regulatory_hint(hw->wiphy,
- sc->sc_ah->regulatory.alpha2);
+ if (!ath_is_world_regd(reg)) {
+ error = regulatory_hint(hw->wiphy, reg->alpha2);
if (error)
goto error_attach;
}
@@ -1728,7 +1734,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false);
if (r)
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset hardware; reset status %u\n", r);
+ "Unable to reset hardware; reset status %d\n", r);
spin_unlock_bh(&sc->sc_resetlock);
if (ath_startrecv(sc) != 0)
@@ -1792,7 +1798,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
goto fail;
}
- dd->dd_name = name;
dd->dd_desc_len = sizeof(struct ath_desc) * nbuf * ndesc;
/*
@@ -1822,7 +1827,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
}
ds = dd->dd_desc;
DPRINTF(sc, ATH_DBG_CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n",
- dd->dd_name, ds, (u32) dd->dd_desc_len,
+ name, ds, (u32) dd->dd_desc_len,
ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
/* allocate buffers */
@@ -2021,7 +2026,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
r = ath9k_hw_reset(sc->sc_ah, init_channel, false);
if (r) {
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset hardware; reset status %u "
+ "Unable to reset hardware; reset status %d "
"(freq %u MHz)\n", r,
curchan->center_freq);
spin_unlock_bh(&sc->sc_resetlock);
@@ -2043,8 +2048,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
* here except setup the interrupt mask.
*/
if (ath_startrecv(sc) != 0) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to start recv logic\n");
+ DPRINTF(sc, ATH_DBG_FATAL, "Unable to start recv logic\n");
r = -EIO;
goto mutex_unlock;
}
@@ -2095,6 +2099,46 @@ static int ath9k_tx(struct ieee80211_hw *hw,
goto exit;
}
+ if (sc->hw->conf.flags & IEEE80211_CONF_PS) {
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+ /*
+ * mac80211 does not set PM field for normal data frames, so we
+ * need to update that based on the current PS mode.
+ */
+ if (ieee80211_is_data(hdr->frame_control) &&
+ !ieee80211_is_nullfunc(hdr->frame_control) &&
+ !ieee80211_has_pm(hdr->frame_control)) {
+ DPRINTF(sc, ATH_DBG_PS, "Add PM=1 for a TX frame "
+ "while in PS mode\n");
+ hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
+ }
+ }
+
+ if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
+ /*
+ * We are using PS-Poll and mac80211 can request TX while in
+ * power save mode. Need to wake up hardware for the TX to be
+ * completed and if needed, also for RX of buffered frames.
+ */
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+ ath9k_ps_wakeup(sc);
+ ath9k_hw_setrxabort(sc->sc_ah, 0);
+ if (ieee80211_is_pspoll(hdr->frame_control)) {
+ DPRINTF(sc, ATH_DBG_PS, "Sending PS-Poll to pick a "
+ "buffered frame\n");
+ sc->sc_flags |= SC_OP_WAIT_FOR_PSPOLL_DATA;
+ } else {
+ DPRINTF(sc, ATH_DBG_PS, "Wake up to complete TX\n");
+ sc->sc_flags |= SC_OP_WAIT_FOR_TX_ACK;
+ }
+ /*
+ * The actual restore operation will happen only after
+ * the sc_flags bit is cleared. We are just dropping
+ * the ps_usecount here.
+ */
+ ath9k_ps_restore(sc);
+ }
+
memset(&txctl, 0, sizeof(struct ath_tx_control));
/*
@@ -2257,25 +2301,10 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
sc->imask |= ATH9K_INT_TSFOOR;
}
- /*
- * Some hardware processes the TIM IE and fires an
- * interrupt when the TIM bit is set. For hardware
- * that does, if not overridden by configuration,
- * enable the TIM interrupt when operating as station.
- */
- if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ENHANCEDPM) &&
- (conf->type == NL80211_IFTYPE_STATION) &&
- !sc->config.swBeaconProcess)
- sc->imask |= ATH9K_INT_TIM;
-
ath9k_hw_set_interrupts(sc->sc_ah, sc->imask);
- if (conf->type == NL80211_IFTYPE_AP) {
- /* TODO: is this a suitable place to start ANI for AP mode? */
- /* Start ANI */
- mod_timer(&sc->ani.timer,
- jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
- }
+ if (conf->type == NL80211_IFTYPE_AP)
+ ath_start_ani(sc);
out:
mutex_unlock(&sc->mutex);
@@ -2326,26 +2355,36 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ieee80211_conf *conf = &hw->conf;
+ struct ath_hw *ah = sc->sc_ah;
mutex_lock(&sc->mutex);
if (changed & IEEE80211_CONF_CHANGE_PS) {
if (conf->flags & IEEE80211_CONF_PS) {
- if ((sc->imask & ATH9K_INT_TIM_TIMER) == 0) {
- sc->imask |= ATH9K_INT_TIM_TIMER;
- ath9k_hw_set_interrupts(sc->sc_ah,
- sc->imask);
+ if (!(ah->caps.hw_caps &
+ ATH9K_HW_CAP_AUTOSLEEP)) {
+ if ((sc->imask & ATH9K_INT_TIM_TIMER) == 0) {
+ sc->imask |= ATH9K_INT_TIM_TIMER;
+ ath9k_hw_set_interrupts(sc->sc_ah,
+ sc->imask);
+ }
+ ath9k_hw_setrxabort(sc->sc_ah, 1);
}
- ath9k_hw_setrxabort(sc->sc_ah, 1);
ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
} else {
ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
- ath9k_hw_setrxabort(sc->sc_ah, 0);
- sc->sc_flags &= ~SC_OP_WAIT_FOR_BEACON;
- if (sc->imask & ATH9K_INT_TIM_TIMER) {
- sc->imask &= ~ATH9K_INT_TIM_TIMER;
- ath9k_hw_set_interrupts(sc->sc_ah,
- sc->imask);
+ if (!(ah->caps.hw_caps &
+ ATH9K_HW_CAP_AUTOSLEEP)) {
+ ath9k_hw_setrxabort(sc->sc_ah, 0);
+ sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON |
+ SC_OP_WAIT_FOR_CAB |
+ SC_OP_WAIT_FOR_PSPOLL_DATA |
+ SC_OP_WAIT_FOR_TX_ACK);
+ if (sc->imask & ATH9K_INT_TIM_TIMER) {
+ sc->imask &= ~ATH9K_INT_TIM_TIMER;
+ ath9k_hw_set_interrupts(sc->sc_ah,
+ sc->imask);
+ }
}
}
}
@@ -2387,114 +2426,6 @@ skip_chan_change:
if (changed & IEEE80211_CONF_CHANGE_POWER)
sc->config.txpowlimit = 2 * conf->power_level;
- /*
- * The HW TSF has to be reset when the beacon interval changes.
- * We set the flag here, and ath_beacon_config_ap() would take this
- * into account when it gets called through the subsequent
- * config_interface() call - with IFCC_BEACON in the changed field.
- */
-
- if (changed & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
- sc->sc_flags |= SC_OP_TSF_RESET;
-
- mutex_unlock(&sc->mutex);
-
- return 0;
-}
-
-static int ath9k_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct ath_wiphy *aphy = hw->priv;
- struct ath_softc *sc = aphy->sc;
- struct ath_hw *ah = sc->sc_ah;
- struct ath_vif *avp = (void *)vif->drv_priv;
- u32 rfilt = 0;
- int error, i;
-
- mutex_lock(&sc->mutex);
-
- /* TODO: Need to decide which hw opmode to use for multi-interface
- * cases */
- if (vif->type == NL80211_IFTYPE_AP &&
- ah->opmode != NL80211_IFTYPE_AP) {
- ah->opmode = NL80211_IFTYPE_STATION;
- ath9k_hw_setopmode(ah);
- memcpy(sc->curbssid, sc->sc_ah->macaddr, ETH_ALEN);
- sc->curaid = 0;
- ath9k_hw_write_associd(sc);
- /* Request full reset to get hw opmode changed properly */
- sc->sc_flags |= SC_OP_FULL_RESET;
- }
-
- if ((conf->changed & IEEE80211_IFCC_BSSID) &&
- !is_zero_ether_addr(conf->bssid)) {
- switch (vif->type) {
- case NL80211_IFTYPE_STATION:
- case NL80211_IFTYPE_ADHOC:
- case NL80211_IFTYPE_MESH_POINT:
- /* Set BSSID */
- memcpy(sc->curbssid, conf->bssid, ETH_ALEN);
- memcpy(avp->bssid, conf->bssid, ETH_ALEN);
- sc->curaid = 0;
- ath9k_hw_write_associd(sc);
-
- /* Set aggregation protection mode parameters */
- sc->config.ath_aggr_prot = 0;
-
- DPRINTF(sc, ATH_DBG_CONFIG,
- "RX filter 0x%x bssid %pM aid 0x%x\n",
- rfilt, sc->curbssid, sc->curaid);
-
- /* need to reconfigure the beacon */
- sc->sc_flags &= ~SC_OP_BEACONS ;
-
- break;
- default:
- break;
- }
- }
-
- if ((vif->type == NL80211_IFTYPE_ADHOC) ||
- (vif->type == NL80211_IFTYPE_AP) ||
- (vif->type == NL80211_IFTYPE_MESH_POINT)) {
- if ((conf->changed & IEEE80211_IFCC_BEACON) ||
- (conf->changed & IEEE80211_IFCC_BEACON_ENABLED &&
- conf->enable_beacon)) {
- /*
- * Allocate and setup the beacon frame.
- *
- * Stop any previous beacon DMA. This may be
- * necessary, for example, when an ibss merge
- * causes reconfiguration; we may be called
- * with beacon transmission active.
- */
- ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
-
- error = ath_beacon_alloc(aphy, vif);
- if (error != 0) {
- mutex_unlock(&sc->mutex);
- return error;
- }
-
- ath_beacon_config(sc, vif);
- }
- }
-
- /* Check for WLAN_CAPABILITY_PRIVACY ? */
- if ((avp->av_opmode != NL80211_IFTYPE_STATION)) {
- for (i = 0; i < IEEE80211_WEP_NKID; i++)
- if (ath9k_hw_keyisvalid(sc->sc_ah, (u16)i))
- ath9k_hw_keysetmac(sc->sc_ah,
- (u16)i,
- sc->curbssid);
- }
-
- /* Only legacy IBSS for now */
- if (vif->type == NL80211_IFTYPE_ADHOC)
- ath_update_chainmask(sc, 0);
-
mutex_unlock(&sc->mutex);
return 0;
@@ -2523,8 +2454,10 @@ static void ath9k_configure_filter(struct ieee80211_hw *hw,
*total_flags &= SUPPORTED_FILTERS;
sc->rx.rxfilter = *total_flags;
+ ath9k_ps_wakeup(sc);
rfilt = ath_calcrxfilter(sc);
ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
+ ath9k_ps_restore(sc);
DPRINTF(sc, ATH_DBG_CONFIG, "Set HW RX filter: 0x%x\n", sc->rx.rxfilter);
}
@@ -2562,6 +2495,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
mutex_lock(&sc->mutex);
+ memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
+
qi.tqi_aifs = params->aifs;
qi.tqi_cwmin = params->cw_min;
qi.tqi_cwmax = params->cw_max;
@@ -2598,7 +2533,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
mutex_lock(&sc->mutex);
ath9k_ps_wakeup(sc);
- DPRINTF(sc, ATH_DBG_KEYCACHE, "Set HW Key\n");
+ DPRINTF(sc, ATH_DBG_CONFIG, "Set HW Key\n");
switch (cmd) {
case SET_KEY:
@@ -2634,9 +2569,92 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
{
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
+ struct ath_hw *ah = sc->sc_ah;
+ struct ath_vif *avp = (void *)vif->drv_priv;
+ u32 rfilt = 0;
+ int error, i;
mutex_lock(&sc->mutex);
+ /*
+ * TODO: Need to decide which hw opmode to use for
+ * multi-interface cases
+ * XXX: This belongs into add_interface!
+ */
+ if (vif->type == NL80211_IFTYPE_AP &&
+ ah->opmode != NL80211_IFTYPE_AP) {
+ ah->opmode = NL80211_IFTYPE_STATION;
+ ath9k_hw_setopmode(ah);
+ memcpy(sc->curbssid, sc->sc_ah->macaddr, ETH_ALEN);
+ sc->curaid = 0;
+ ath9k_hw_write_associd(sc);
+ /* Request full reset to get hw opmode changed properly */
+ sc->sc_flags |= SC_OP_FULL_RESET;
+ }
+
+ if ((changed & BSS_CHANGED_BSSID) &&
+ !is_zero_ether_addr(bss_conf->bssid)) {
+ switch (vif->type) {
+ case NL80211_IFTYPE_STATION:
+ case NL80211_IFTYPE_ADHOC:
+ case NL80211_IFTYPE_MESH_POINT:
+ /* Set BSSID */
+ memcpy(sc->curbssid, bss_conf->bssid, ETH_ALEN);
+ memcpy(avp->bssid, bss_conf->bssid, ETH_ALEN);
+ sc->curaid = 0;
+ ath9k_hw_write_associd(sc);
+
+ /* Set aggregation protection mode parameters */
+ sc->config.ath_aggr_prot = 0;
+
+ DPRINTF(sc, ATH_DBG_CONFIG,
+ "RX filter 0x%x bssid %pM aid 0x%x\n",
+ rfilt, sc->curbssid, sc->curaid);
+
+ /* need to reconfigure the beacon */
+ sc->sc_flags &= ~SC_OP_BEACONS ;
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ((vif->type == NL80211_IFTYPE_ADHOC) ||
+ (vif->type == NL80211_IFTYPE_AP) ||
+ (vif->type == NL80211_IFTYPE_MESH_POINT)) {
+ if ((changed & BSS_CHANGED_BEACON) ||
+ (changed & BSS_CHANGED_BEACON_ENABLED &&
+ bss_conf->enable_beacon)) {
+ /*
+ * Allocate and setup the beacon frame.
+ *
+ * Stop any previous beacon DMA. This may be
+ * necessary, for example, when an ibss merge
+ * causes reconfiguration; we may be called
+ * with beacon transmission active.
+ */
+ ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
+
+ error = ath_beacon_alloc(aphy, vif);
+ if (!error)
+ ath_beacon_config(sc, vif);
+ }
+ }
+
+ /* Check for WLAN_CAPABILITY_PRIVACY ? */
+ if ((avp->av_opmode != NL80211_IFTYPE_STATION)) {
+ for (i = 0; i < IEEE80211_WEP_NKID; i++)
+ if (ath9k_hw_keyisvalid(sc->sc_ah, (u16)i))
+ ath9k_hw_keysetmac(sc->sc_ah,
+ (u16)i,
+ sc->curbssid);
+ }
+
+ /* Only legacy IBSS for now */
+ if (vif->type == NL80211_IFTYPE_ADHOC)
+ ath_update_chainmask(sc, 0);
+
if (changed & BSS_CHANGED_ERP_PREAMBLE) {
DPRINTF(sc, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n",
bss_conf->use_short_preamble);
@@ -2662,6 +2680,18 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
ath9k_bss_assoc_info(sc, vif, bss_conf);
}
+ /*
+ * The HW TSF has to be reset when the beacon interval changes.
+ * We set the flag here, and ath_beacon_config_ap() would take this
+ * into account when it gets called through the subsequent
+ * config_interface() call - with IFCC_BEACON in the changed field.
+ */
+
+ if (changed & BSS_CHANGED_BEACON_INT) {
+ sc->sc_flags |= SC_OP_TSF_RESET;
+ sc->beacon_interval = bss_conf->beacon_int;
+ }
+
mutex_unlock(&sc->mutex);
}
@@ -2771,6 +2801,7 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
mutex_lock(&sc->mutex);
aphy->state = ATH_WIPHY_ACTIVE;
sc->sc_flags &= ~SC_OP_SCANNING;
+ sc->sc_flags |= SC_OP_FULL_RESET;
mutex_unlock(&sc->mutex);
}
@@ -2781,7 +2812,6 @@ struct ieee80211_ops ath9k_ops = {
.add_interface = ath9k_add_interface,
.remove_interface = ath9k_remove_interface,
.config = ath9k_config,
- .config_interface = ath9k_config_interface,
.configure_filter = ath9k_configure_filter,
.sta_notify = ath9k_sta_notify,
.conf_tx = ath9k_conf_tx,
diff --git a/drivers/net/wireless/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 168411d322a2..168411d322a2 100644
--- a/drivers/net/wireless/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
diff --git a/drivers/net/wireless/ath9k/phy.c b/drivers/net/wireless/ath/ath9k/phy.c
index 8bcba906929a..aaa941561c36 100644
--- a/drivers/net/wireless/ath9k/phy.c
+++ b/drivers/net/wireless/ath/ath9k/phy.c
@@ -46,7 +46,7 @@ ath9k_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
channelSel = ((freq - 704) * 2 - 3040) / 10;
bModeSynth = 1;
} else {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"Invalid channel %u MHz\n", freq);
return false;
}
@@ -79,7 +79,7 @@ ath9k_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
channelSel = ath9k_hw_reverse_bits((freq - 4800) / 5, 8);
aModeRefSel = ath9k_hw_reverse_bits(1, 2);
} else {
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
+ DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
"Invalid channel %u MHz\n", freq);
return false;
}
@@ -96,9 +96,8 @@ ath9k_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
return true;
}
-bool
-ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
- struct ath9k_channel *chan)
+void ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
+ struct ath9k_channel *chan)
{
u16 bMode, fracMode, aModeRefSel = 0;
u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0;
@@ -169,8 +168,6 @@ ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
ah->curchan = chan;
ah->curchan_rad_index = -1;
-
- return true;
}
static void
diff --git a/drivers/net/wireless/ath9k/phy.h b/drivers/net/wireless/ath/ath9k/phy.h
index 0f7f8e0c9c95..c70f530642f6 100644
--- a/drivers/net/wireless/ath9k/phy.h
+++ b/drivers/net/wireless/ath/ath9k/phy.h
@@ -17,7 +17,7 @@
#ifndef PHY_H
#define PHY_H
-bool ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
+void ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
struct ath9k_channel
*chan);
bool ath9k_hw_set_channel(struct ath_hw *ah,
@@ -556,9 +556,6 @@ bool ath9k_hw_init_rf(struct ath_hw *ah,
int r; \
for (r = 0; r < ((iniarray)->ia_rows); r++) { \
REG_WRITE(ah, INI_RA((iniarray), r, 0), (regData)[r]); \
- DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL, \
- "RF 0x%x V 0x%x\n", \
- INI_RA((iniarray), r, 0), (regData)[r]); \
DO_DELAY(regWr); \
} \
} while (0)
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 824ccbb8b7b8..ba06e78b2f50 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -17,7 +17,7 @@
#include "ath9k.h"
-static struct ath_rate_table ar5416_11na_ratetable = {
+static const struct ath_rate_table ar5416_11na_ratetable = {
42,
{
{ VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
@@ -155,7 +155,7 @@ static struct ath_rate_table ar5416_11na_ratetable = {
/* 4ms frame limit not used for NG mode. The values filled
* for HT are the 64K max aggregate limit */
-static struct ath_rate_table ar5416_11ng_ratetable = {
+static const struct ath_rate_table ar5416_11ng_ratetable = {
46,
{
{ VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
@@ -302,7 +302,7 @@ static struct ath_rate_table ar5416_11ng_ratetable = {
WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
};
-static struct ath_rate_table ar5416_11a_ratetable = {
+static const struct ath_rate_table ar5416_11a_ratetable = {
8,
{
{ VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
@@ -335,7 +335,7 @@ static struct ath_rate_table ar5416_11a_ratetable = {
0, /* Phy rates allowed initially */
};
-static struct ath_rate_table ar5416_11g_ratetable = {
+static const struct ath_rate_table ar5416_11g_ratetable = {
12,
{
{ VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
@@ -380,7 +380,7 @@ static struct ath_rate_table ar5416_11g_ratetable = {
0, /* Phy rates allowed initially */
};
-static struct ath_rate_table ar5416_11b_ratetable = {
+static const struct ath_rate_table ar5416_11b_ratetable = {
4,
{
{ VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
@@ -420,7 +420,7 @@ static inline int8_t median(int8_t a, int8_t b, int8_t c)
}
}
-static void ath_rc_sort_validrates(struct ath_rate_table *rate_table,
+static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table,
struct ath_rate_priv *ath_rc_priv)
{
u8 i, j, idx, idx_next;
@@ -461,10 +461,11 @@ static inline int ath_rc_isvalid_txmask(struct ath_rate_priv *ath_rc_priv,
return ath_rc_priv->valid_rate_index[index];
}
-static inline int ath_rc_get_nextvalid_txrate(struct ath_rate_table *rate_table,
- struct ath_rate_priv *ath_rc_priv,
- u8 cur_valid_txrate,
- u8 *next_idx)
+static inline
+int ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table,
+ struct ath_rate_priv *ath_rc_priv,
+ u8 cur_valid_txrate,
+ u8 *next_idx)
{
u8 i;
@@ -500,7 +501,7 @@ static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw)
}
static inline int
-ath_rc_get_nextlowervalid_txrate(struct ath_rate_table *rate_table,
+ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table,
struct ath_rate_priv *ath_rc_priv,
u8 cur_valid_txrate, u8 *next_idx)
{
@@ -517,14 +518,14 @@ ath_rc_get_nextlowervalid_txrate(struct ath_rate_table *rate_table,
}
static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
u32 capflag)
{
u8 i, hi = 0;
u32 valid;
for (i = 0; i < rate_table->rate_cnt; i++) {
- valid = (ath_rc_priv->single_stream ?
+ valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ?
rate_table->info[i].valid_single_stream :
rate_table->info[i].valid);
if (valid == 1) {
@@ -547,7 +548,7 @@ static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv,
}
static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
struct ath_rateset *rateset,
u32 capflag)
{
@@ -557,9 +558,9 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
for (i = 0; i < rateset->rs_nrates; i++) {
for (j = 0; j < rate_table->rate_cnt; j++) {
u32 phy = rate_table->info[j].phy;
- u32 valid = (ath_rc_priv->single_stream ?
- rate_table->info[j].valid_single_stream :
- rate_table->info[j].valid);
+ u32 valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ?
+ rate_table->info[j].valid_single_stream :
+ rate_table->info[j].valid);
u8 rate = rateset->rs_rates[i];
u8 dot11rate = rate_table->info[j].dot11rate;
@@ -592,7 +593,7 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
}
static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
u8 *mcs_set, u32 capflag)
{
struct ath_rateset *rateset = (struct ath_rateset *)mcs_set;
@@ -603,7 +604,7 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
for (i = 0; i < rateset->rs_nrates; i++) {
for (j = 0; j < rate_table->rate_cnt; j++) {
u32 phy = rate_table->info[j].phy;
- u32 valid = (ath_rc_priv->single_stream ?
+ u32 valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ?
rate_table->info[j].valid_single_stream :
rate_table->info[j].valid);
u8 rate = rateset->rs_rates[i];
@@ -630,7 +631,7 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
struct ath_rate_priv *ath_rc_priv,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
int *is_probing)
{
u32 dt, best_thruput, this_thruput, now_msec;
@@ -740,14 +741,15 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
if (rate > (ath_rc_priv->rate_table_size - 1))
rate = ath_rc_priv->rate_table_size - 1;
- ASSERT((rate_table->info[rate].valid && !ath_rc_priv->single_stream) ||
+ ASSERT((rate_table->info[rate].valid &&
+ (ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG)) ||
(rate_table->info[rate].valid_single_stream &&
- ath_rc_priv->single_stream));
+ !(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG)));
return rate;
}
-static void ath_rc_rate_set_series(struct ath_rate_table *rate_table,
+static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table,
struct ieee80211_tx_rate *rate,
struct ieee80211_tx_rate_control *txrc,
u8 tries, u8 rix, int rtsctsenable)
@@ -768,7 +770,7 @@ static void ath_rc_rate_set_series(struct ath_rate_table *rate_table,
}
static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
struct ieee80211_tx_info *tx_info)
{
struct ieee80211_tx_rate *rates = tx_info->control.rates;
@@ -806,12 +808,12 @@ static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
static u8 ath_rc_rate_getidx(struct ath_softc *sc,
struct ath_rate_priv *ath_rc_priv,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
u8 rix, u16 stepdown,
u16 min_rate)
{
u32 j;
- u8 nextindex;
+ u8 nextindex = 0;
if (min_rate) {
for (j = RATE_TABLE_SIZE; j > 0; j--) {
@@ -837,7 +839,7 @@ static void ath_rc_ratefind(struct ath_softc *sc,
struct ath_rate_priv *ath_rc_priv,
struct ieee80211_tx_rate_control *txrc)
{
- struct ath_rate_table *rate_table;
+ const struct ath_rate_table *rate_table;
struct sk_buff *skb = txrc->skb;
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
struct ieee80211_tx_rate *rates = tx_info->control.rates;
@@ -936,7 +938,7 @@ static void ath_rc_ratefind(struct ath_softc *sc,
}
static bool ath_rc_update_per(struct ath_softc *sc,
- struct ath_rate_table *rate_table,
+ const struct ath_rate_table *rate_table,
struct ath_rate_priv *ath_rc_priv,
struct ath_tx_info_priv *tx_info_priv,
int tx_rate, int xretries, int retries,
@@ -1141,7 +1143,7 @@ static void ath_rc_update_ht(struct ath_softc *sc,
int rate;
u8 last_per;
bool state_change = false;
- struct ath_rate_table *rate_table = sc->cur_rate_table;
+ const struct ath_rate_table *rate_table = sc->cur_rate_table;
int size = ath_rc_priv->rate_table_size;
if ((tx_rate < 0) || (tx_rate > rate_table->rate_cnt))
@@ -1275,7 +1277,7 @@ static void ath_rc_update_ht(struct ath_softc *sc,
#undef CHK_RSSI
}
-static int ath_rc_get_rateindex(struct ath_rate_table *rate_table,
+static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
struct ieee80211_tx_rate *rate)
{
int rix;
@@ -1299,7 +1301,7 @@ static void ath_rc_tx_status(struct ath_softc *sc,
int final_ts_idx, int xretries, int long_retry)
{
struct ath_tx_info_priv *tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
- struct ath_rate_table *rate_table;
+ const struct ath_rate_table *rate_table;
struct ieee80211_tx_rate *rates = tx_info->status.rates;
u8 flags;
u32 i = 0, rix;
@@ -1320,7 +1322,7 @@ static void ath_rc_tx_status(struct ath_softc *sc,
* 40 to 20 => don't update */
if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
- (ath_rc_priv->rc_phy_mode != WLAN_RC_40_FLAG))
+ !(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG))
return;
rix = ath_rc_get_rateindex(rate_table, &rates[i]);
@@ -1345,18 +1347,19 @@ static void ath_rc_tx_status(struct ath_softc *sc,
/* If HT40 and we have switched mode from 40 to 20 => don't update */
if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
- (ath_rc_priv->rc_phy_mode != WLAN_RC_40_FLAG)) {
+ !(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG))
return;
- }
rix = ath_rc_get_rateindex(rate_table, &rates[i]);
ath_rc_update_ht(sc, ath_rc_priv, tx_info_priv, rix,
xretries, long_retry);
}
-static struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
- enum ieee80211_band band,
- bool is_ht, bool is_cw_40)
+static const
+struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
+ enum ieee80211_band band,
+ bool is_ht,
+ bool is_cw_40)
{
int mode = 0;
@@ -1390,7 +1393,7 @@ static void ath_rc_init(struct ath_softc *sc,
struct ath_rate_priv *ath_rc_priv,
struct ieee80211_supported_band *sband,
struct ieee80211_sta *sta,
- struct ath_rate_table *rate_table)
+ const struct ath_rate_table *rate_table)
{
struct ath_rateset *rateset = &ath_rc_priv->neg_rates;
u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
@@ -1420,10 +1423,6 @@ static void ath_rc_init(struct ath_softc *sc,
ath_rc_priv->valid_phy_rateidx[i][j] = 0;
ath_rc_priv->valid_phy_ratecnt[i] = 0;
}
- ath_rc_priv->rc_phy_mode = ath_rc_priv->ht_cap & WLAN_RC_40_FLAG;
-
- /* Set stream capability */
- ath_rc_priv->single_stream = (ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ? 0 : 1;
if (!rateset->rs_nrates) {
/* No working rate, just initialize valid rates */
@@ -1572,12 +1571,13 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
struct ath_rate_priv *ath_rc_priv = priv_sta;
__le16 fc = hdr->frame_control;
- /* lowest rate for management and multicast/broadcast frames */
- if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) ||
- !sta) {
+ /* lowest rate for management and NO_ACK frames */
+ if (!ieee80211_is_data(fc) ||
+ tx_info->flags & IEEE80211_TX_CTL_NO_ACK || !sta) {
tx_info->control.rates[0].idx = rate_lowest_index(sband, sta);
tx_info->control.rates[0].count =
- is_multicast_ether_addr(hdr->addr1) ? 1 : ATH_MGT_TXMAXTRY;
+ (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) ?
+ 1 : ATH_MGT_TXMAXTRY;
return;
}
@@ -1590,7 +1590,7 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
{
struct ath_softc *sc = priv;
struct ath_rate_priv *ath_rc_priv = priv_sta;
- struct ath_rate_table *rate_table = NULL;
+ const struct ath_rate_table *rate_table = NULL;
bool is_cw40, is_sgi40;
int i, j = 0;
@@ -1639,7 +1639,7 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
{
struct ath_softc *sc = priv;
struct ath_rate_priv *ath_rc_priv = priv_sta;
- struct ath_rate_table *rate_table = NULL;
+ const struct ath_rate_table *rate_table = NULL;
bool oper_cw40 = false, oper_sgi40;
bool local_cw40 = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG) ?
true : false;
diff --git a/drivers/net/wireless/ath9k/rc.h b/drivers/net/wireless/ath/ath9k/rc.h
index 199a3ce57d64..e3abd76103fd 100644
--- a/drivers/net/wireless/ath9k/rc.h
+++ b/drivers/net/wireless/ath/ath9k/rc.h
@@ -24,7 +24,6 @@ struct ath_softc;
#define ATH_RATE_MAX 30
#define RATE_TABLE_SIZE 64
#define MAX_TX_RATE_PHY 48
-#define WLAN_CTRL_FRAME_SIZE (2+2+6+4)
/* VALID_ALL - valid for 20/40/Legacy,
* VALID - Legacy only,
@@ -158,7 +157,6 @@ struct ath_rateset {
* @probe_interval: interval for ratectrl to probe for other rates
* @prev_data_rix: rate idx of last data frame
* @ht_cap: HT capabilities
- * @single_stream: When TRUE, only single TX stream possible
* @neg_rates: Negotatied rates
* @neg_ht_rates: Negotiated HT rates
*/
@@ -176,10 +174,8 @@ struct ath_rate_priv {
u8 max_valid_rate;
u8 valid_rate_index[RATE_TABLE_SIZE];
u8 ht_cap;
- u8 single_stream;
u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
- u8 rc_phy_mode;
u8 rate_max_phy;
u32 rssi_time;
u32 rssi_down_time;
diff --git a/drivers/net/wireless/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index dd1f30156740..5014a19b0f75 100644
--- a/drivers/net/wireless/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -283,54 +283,51 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
struct ath_buf *bf;
int error = 0;
- do {
- spin_lock_init(&sc->rx.rxflushlock);
- sc->sc_flags &= ~SC_OP_RXFLUSH;
- spin_lock_init(&sc->rx.rxbuflock);
-
- sc->rx.bufsize = roundup(IEEE80211_MAX_MPDU_LEN,
- min(sc->cachelsz,
- (u16)64));
+ spin_lock_init(&sc->rx.rxflushlock);
+ sc->sc_flags &= ~SC_OP_RXFLUSH;
+ spin_lock_init(&sc->rx.rxbuflock);
- DPRINTF(sc, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n",
- sc->cachelsz, sc->rx.bufsize);
+ sc->rx.bufsize = roundup(IEEE80211_MAX_MPDU_LEN,
+ min(sc->cachelsz, (u16)64));
- /* Initialize rx descriptors */
+ DPRINTF(sc, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n",
+ sc->cachelsz, sc->rx.bufsize);
- error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf,
- "rx", nbufs, 1);
- if (error != 0) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "failed to allocate rx descriptors: %d\n", error);
- break;
- }
+ /* Initialize rx descriptors */
- list_for_each_entry(bf, &sc->rx.rxbuf, list) {
- skb = ath_rxbuf_alloc(sc, sc->rx.bufsize, GFP_KERNEL);
- if (skb == NULL) {
- error = -ENOMEM;
- break;
- }
+ error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf,
+ "rx", nbufs, 1);
+ if (error != 0) {
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "failed to allocate rx descriptors: %d\n", error);
+ goto err;
+ }
- bf->bf_mpdu = skb;
- bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
- sc->rx.bufsize,
- DMA_FROM_DEVICE);
- if (unlikely(dma_mapping_error(sc->dev,
- bf->bf_buf_addr))) {
- dev_kfree_skb_any(skb);
- bf->bf_mpdu = NULL;
- DPRINTF(sc, ATH_DBG_CONFIG,
- "dma_mapping_error() on RX init\n");
- error = -ENOMEM;
- break;
- }
- bf->bf_dmacontext = bf->bf_buf_addr;
+ list_for_each_entry(bf, &sc->rx.rxbuf, list) {
+ skb = ath_rxbuf_alloc(sc, sc->rx.bufsize, GFP_KERNEL);
+ if (skb == NULL) {
+ error = -ENOMEM;
+ goto err;
}
- sc->rx.rxlink = NULL;
- } while (0);
+ bf->bf_mpdu = skb;
+ bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
+ sc->rx.bufsize,
+ DMA_FROM_DEVICE);
+ if (unlikely(dma_mapping_error(sc->dev,
+ bf->bf_buf_addr))) {
+ dev_kfree_skb_any(skb);
+ bf->bf_mpdu = NULL;
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "dma_mapping_error() on RX init\n");
+ error = -ENOMEM;
+ goto err;
+ }
+ bf->bf_dmacontext = bf->bf_buf_addr;
+ }
+ sc->rx.rxlink = NULL;
+err:
if (error)
ath_rx_cleanup(sc);
@@ -345,10 +342,8 @@ void ath_rx_cleanup(struct ath_softc *sc)
list_for_each_entry(bf, &sc->rx.rxbuf, list) {
skb = bf->bf_mpdu;
if (skb) {
- dma_unmap_single(sc->dev,
- bf->bf_buf_addr,
- sc->rx.bufsize,
- DMA_FROM_DEVICE);
+ dma_unmap_single(sc->dev, bf->bf_buf_addr,
+ sc->rx.bufsize, DMA_FROM_DEVICE);
dev_kfree_skb(skb);
}
}
@@ -478,6 +473,159 @@ void ath_flushrecv(struct ath_softc *sc)
spin_unlock_bh(&sc->rx.rxflushlock);
}
+static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
+{
+ /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
+ struct ieee80211_mgmt *mgmt;
+ u8 *pos, *end, id, elen;
+ struct ieee80211_tim_ie *tim;
+
+ mgmt = (struct ieee80211_mgmt *)skb->data;
+ pos = mgmt->u.beacon.variable;
+ end = skb->data + skb->len;
+
+ while (pos + 2 < end) {
+ id = *pos++;
+ elen = *pos++;
+ if (pos + elen > end)
+ break;
+
+ if (id == WLAN_EID_TIM) {
+ if (elen < sizeof(*tim))
+ break;
+ tim = (struct ieee80211_tim_ie *) pos;
+ if (tim->dtim_count != 0)
+ break;
+ return tim->bitmap_ctrl & 0x01;
+ }
+
+ pos += elen;
+ }
+
+ return false;
+}
+
+static void ath_rx_ps_back_to_sleep(struct ath_softc *sc)
+{
+ sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON | SC_OP_WAIT_FOR_CAB);
+}
+
+static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb)
+{
+ struct ieee80211_mgmt *mgmt;
+
+ if (skb->len < 24 + 8 + 2 + 2)
+ return;
+
+ mgmt = (struct ieee80211_mgmt *)skb->data;
+ if (memcmp(sc->curbssid, mgmt->bssid, ETH_ALEN) != 0)
+ return; /* not from our current AP */
+
+ if (sc->sc_flags & SC_OP_BEACON_SYNC) {
+ sc->sc_flags &= ~SC_OP_BEACON_SYNC;
+ DPRINTF(sc, ATH_DBG_PS, "Reconfigure Beacon timers based on "
+ "timestamp from the AP\n");
+ ath_beacon_config(sc, NULL);
+ }
+
+ if (!(sc->hw->conf.flags & IEEE80211_CONF_PS)) {
+ /* We are not in PS mode anymore; remain awake */
+ DPRINTF(sc, ATH_DBG_PS, "Not in PS mode anymore, remain "
+ "awake\n");
+ sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON | SC_OP_WAIT_FOR_CAB);
+ return;
+ }
+
+ if (ath_beacon_dtim_pending_cab(skb)) {
+ /*
+ * Remain awake waiting for buffered broadcast/multicast
+ * frames.
+ */
+ DPRINTF(sc, ATH_DBG_PS, "Received DTIM beacon indicating "
+ "buffered broadcast/multicast frame(s)\n");
+ sc->sc_flags |= SC_OP_WAIT_FOR_CAB;
+ return;
+ }
+
+ if (sc->sc_flags & SC_OP_WAIT_FOR_CAB) {
+ /*
+ * This can happen if a broadcast frame is dropped or the AP
+ * fails to send a frame indicating that all CAB frames have
+ * been delivered.
+ */
+ DPRINTF(sc, ATH_DBG_PS, "PS wait for CAB frames timed out\n");
+ }
+
+ /* No more broadcast/multicast frames to be received at this point. */
+ ath_rx_ps_back_to_sleep(sc);
+}
+
+static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb)
+{
+ struct ieee80211_hdr *hdr;
+
+ hdr = (struct ieee80211_hdr *)skb->data;
+
+ /* Process Beacon and CAB receive in PS state */
+ if ((sc->sc_flags & SC_OP_WAIT_FOR_BEACON) &&
+ ieee80211_is_beacon(hdr->frame_control))
+ ath_rx_ps_beacon(sc, skb);
+ else if ((sc->sc_flags & SC_OP_WAIT_FOR_CAB) &&
+ (ieee80211_is_data(hdr->frame_control) ||
+ ieee80211_is_action(hdr->frame_control)) &&
+ is_multicast_ether_addr(hdr->addr1) &&
+ !ieee80211_has_moredata(hdr->frame_control)) {
+ DPRINTF(sc, ATH_DBG_PS, "All PS CAB frames received, back to "
+ "sleep\n");
+ /*
+ * No more broadcast/multicast frames to be received at this
+ * point.
+ */
+ ath_rx_ps_back_to_sleep(sc);
+ } else if ((sc->sc_flags & SC_OP_WAIT_FOR_PSPOLL_DATA) &&
+ !is_multicast_ether_addr(hdr->addr1) &&
+ !ieee80211_has_morefrags(hdr->frame_control)) {
+ sc->sc_flags &= ~SC_OP_WAIT_FOR_PSPOLL_DATA;
+ DPRINTF(sc, ATH_DBG_PS, "Going back to sleep after having "
+ "received PS-Poll data (0x%x)\n",
+ sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
+ SC_OP_WAIT_FOR_CAB |
+ SC_OP_WAIT_FOR_PSPOLL_DATA |
+ SC_OP_WAIT_FOR_TX_ACK));
+ }
+}
+
+static void ath_rx_send_to_mac80211(struct ath_softc *sc, struct sk_buff *skb,
+ struct ieee80211_rx_status *rx_status)
+{
+ struct ieee80211_hdr *hdr;
+
+ hdr = (struct ieee80211_hdr *)skb->data;
+
+ /* Send the frame to mac80211 */
+ if (is_multicast_ether_addr(hdr->addr1)) {
+ int i;
+ /*
+ * Deliver broadcast/multicast frames to all suitable
+ * virtual wiphys.
+ */
+ /* TODO: filter based on channel configuration */
+ for (i = 0; i < sc->num_sec_wiphy; i++) {
+ struct ath_wiphy *aphy = sc->sec_wiphy[i];
+ struct sk_buff *nskb;
+ if (aphy == NULL)
+ continue;
+ nskb = skb_copy(skb, GFP_ATOMIC);
+ if (nskb)
+ __ieee80211_rx(aphy->hw, nskb, rx_status);
+ }
+ __ieee80211_rx(sc->hw, skb, rx_status);
+ } else {
+ /* Deliver unicast frames based on receiver address */
+ __ieee80211_rx(ath_get_virt_hw(sc, hdr), skb, rx_status);
+ }
+}
+
int ath_rx_tasklet(struct ath_softc *sc, int flush)
{
#define PA2DESC(_sc, _pa) \
@@ -627,7 +775,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error) {
rx_status.flag |= RX_FLAG_DECRYPTED;
- } else if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_PROTECTED)
+ } else if (ieee80211_has_protected(fc)
&& !decrypt_error && skb->len >= hdrlen + 4) {
keyix = skb->data[hdrlen + 3] >> 6;
@@ -636,36 +784,11 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
}
if (ah->sw_mgmt_crypto &&
(rx_status.flag & RX_FLAG_DECRYPTED) &&
- ieee80211_is_mgmt(hdr->frame_control)) {
+ ieee80211_is_mgmt(fc)) {
/* Use software decrypt for management frames. */
rx_status.flag &= ~RX_FLAG_DECRYPTED;
}
- /* Send the frame to mac80211 */
- if (hdr->addr1[5] & 0x01) {
- int i;
- /*
- * Deliver broadcast/multicast frames to all suitable
- * virtual wiphys.
- */
- /* TODO: filter based on channel configuration */
- for (i = 0; i < sc->num_sec_wiphy; i++) {
- struct ath_wiphy *aphy = sc->sec_wiphy[i];
- struct sk_buff *nskb;
- if (aphy == NULL)
- continue;
- nskb = skb_copy(skb, GFP_ATOMIC);
- if (nskb)
- __ieee80211_rx(aphy->hw, nskb,
- &rx_status);
- }
- __ieee80211_rx(sc->hw, skb, &rx_status);
- } else {
- /* Deliver unicast frames based on receiver address */
- __ieee80211_rx(ath_get_virt_hw(sc, hdr), skb,
- &rx_status);
- }
-
/* We will now give hardware our shiny new allocated skb */
bf->bf_mpdu = requeue_skb;
bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
@@ -675,8 +798,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
bf->bf_buf_addr))) {
dev_kfree_skb_any(requeue_skb);
bf->bf_mpdu = NULL;
- DPRINTF(sc, ATH_DBG_CONFIG,
+ DPRINTF(sc, ATH_DBG_FATAL,
"dma_mapping_error() on RX\n");
+ ath_rx_send_to_mac80211(sc, skb, &rx_status);
break;
}
bf->bf_dmacontext = bf->bf_buf_addr;
@@ -692,11 +816,12 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
sc->rx.rxotherant = 0;
}
- if (ieee80211_is_beacon(fc) &&
- (sc->sc_flags & SC_OP_WAIT_FOR_BEACON)) {
- sc->sc_flags &= ~SC_OP_WAIT_FOR_BEACON;
- ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
- }
+ if (unlikely(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
+ SC_OP_WAIT_FOR_PSPOLL_DATA)))
+ ath_rx_ps(sc, skb);
+
+ ath_rx_send_to_mac80211(sc, skb, &rx_status);
+
requeue:
list_move_tail(&bf->list, &sc->rx.rxbuf);
ath_rx_buf_link(sc, bf);
diff --git a/drivers/net/wireless/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 52605246679f..52605246679f 100644
--- a/drivers/net/wireless/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
diff --git a/drivers/net/wireless/ath9k/virtual.c b/drivers/net/wireless/ath/ath9k/virtual.c
index 1ff429b027d7..1ff429b027d7 100644
--- a/drivers/net/wireless/ath9k/virtual.c
+++ b/drivers/net/wireless/ath/ath9k/virtual.c
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 689bdbf78808..a8def4fa449c 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -283,7 +283,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0;
bool rc_update = true;
- skb = (struct sk_buff *)bf->bf_mpdu;
+ skb = bf->bf_mpdu;
hdr = (struct ieee80211_hdr *)skb->data;
rcu_read_lock();
@@ -380,8 +380,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
ath_tx_complete_buf(sc, bf, &bf_head, !txfail, sendbar);
} else {
/* retry the un-acked ones */
- if (bf->bf_next == NULL &&
- bf_last->bf_status & ATH_BUFSTATUS_STALE) {
+ if (bf->bf_next == NULL && bf_last->bf_stale) {
struct ath_buf *tbf;
tbf = ath_clone_txbuf(sc, bf_last);
@@ -435,7 +434,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
struct ath_atx_tid *tid)
{
- struct ath_rate_table *rate_table = sc->cur_rate_table;
+ const struct ath_rate_table *rate_table = sc->cur_rate_table;
struct sk_buff *skb;
struct ieee80211_tx_info *tx_info;
struct ieee80211_tx_rate *rates;
@@ -444,7 +443,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
u16 aggr_limit, legacy = 0, maxampdu;
int i;
- skb = (struct sk_buff *)bf->bf_mpdu;
+ skb = bf->bf_mpdu;
tx_info = IEEE80211_SKB_CB(skb);
rates = tx_info->control.rates;
tx_info_priv = (struct ath_tx_info_priv *)tx_info->rate_driver_data[0];
@@ -498,7 +497,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
struct ath_buf *bf, u16 frmlen)
{
- struct ath_rate_table *rt = sc->cur_rate_table;
+ const struct ath_rate_table *rt = sc->cur_rate_table;
struct sk_buff *skb = bf->bf_mpdu;
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
u32 nsymbits, nsymbols, mpdudensity;
@@ -972,7 +971,7 @@ int ath_cabq_update(struct ath_softc *sc)
else if (sc->config.cabqReadytime > ATH9K_READY_TIME_HI_BOUND)
sc->config.cabqReadytime = ATH9K_READY_TIME_HI_BOUND;
- qi.tqi_readyTime = (sc->hw->conf.beacon_int *
+ qi.tqi_readyTime = (sc->beacon_interval *
sc->config.cabqReadytime) / 100;
ath_txq_update(sc, qnum, &qi);
@@ -1004,7 +1003,7 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
- if (bf->bf_status & ATH_BUFSTATUS_STALE) {
+ if (bf->bf_stale) {
list_del(&bf->list);
spin_unlock_bh(&txq->axq_lock);
@@ -1071,7 +1070,7 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
r = ath9k_hw_reset(ah, sc->sc_ah->curchan, true);
if (r)
DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to reset hardware; reset status %u\n",
+ "Unable to reset hardware; reset status %d\n",
r);
spin_unlock_bh(&sc->sc_resetlock);
}
@@ -1408,7 +1407,7 @@ static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb,
static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
int width, int half_gi, bool shortPreamble)
{
- struct ath_rate_table *rate_table = sc->cur_rate_table;
+ const struct ath_rate_table *rate_table = sc->cur_rate_table;
u32 nbits, nsymbits, duration, nsymbols;
u8 rc;
int streams, pktlen;
@@ -1440,7 +1439,7 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
{
- struct ath_rate_table *rt = sc->cur_rate_table;
+ const struct ath_rate_table *rt = sc->cur_rate_table;
struct ath9k_11n_rate_series series[4];
struct sk_buff *skb;
struct ieee80211_tx_info *tx_info;
@@ -1452,7 +1451,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4);
- skb = (struct sk_buff *)bf->bf_mpdu;
+ skb = bf->bf_mpdu;
tx_info = IEEE80211_SKB_CB(skb);
rates = tx_info->control.rates;
hdr = (struct ieee80211_hdr *)skb->data;
@@ -1573,8 +1572,9 @@ static int ath_tx_setup_buffer(struct ieee80211_hw *hw, struct ath_buf *bf,
skb->len, DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(sc->dev, bf->bf_dmacontext))) {
bf->bf_mpdu = NULL;
- DPRINTF(sc, ATH_DBG_CONFIG,
- "dma_mapping_error() on TX\n");
+ kfree(tx_info_priv);
+ tx_info->rate_driver_data[0] = NULL;
+ DPRINTF(sc, ATH_DBG_FATAL, "dma_mapping_error() on TX\n");
return -ENOMEM;
}
@@ -1586,7 +1586,7 @@ static int ath_tx_setup_buffer(struct ieee80211_hw *hw, struct ath_buf *bf,
static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
struct ath_tx_control *txctl)
{
- struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
+ struct sk_buff *skb = bf->bf_mpdu;
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
struct ath_node *an = NULL;
@@ -1790,6 +1790,16 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
skb_pull(skb, padsize);
}
+ if (sc->sc_flags & SC_OP_WAIT_FOR_TX_ACK) {
+ sc->sc_flags &= ~SC_OP_WAIT_FOR_TX_ACK;
+ DPRINTF(sc, ATH_DBG_PS, "Going back to sleep after having "
+ "received TX status (0x%x)\n",
+ sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
+ SC_OP_WAIT_FOR_CAB |
+ SC_OP_WAIT_FOR_PSPOLL_DATA |
+ SC_OP_WAIT_FOR_TX_ACK));
+ }
+
if (frame_type == ATH9K_NOT_INTERNAL)
ieee80211_tx_status(hw, skb);
else
@@ -1860,7 +1870,7 @@ static int ath_tx_num_badfrms(struct ath_softc *sc, struct ath_buf *bf,
static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds,
int nbad, int txok, bool update_rc)
{
- struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
+ struct sk_buff *skb = bf->bf_mpdu;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
struct ath_tx_info_priv *tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
@@ -1941,7 +1951,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
* it with the STALE flag.
*/
bf_held = NULL;
- if (bf->bf_status & ATH_BUFSTATUS_STALE) {
+ if (bf->bf_stale) {
bf_held = bf;
if (list_is_last(&bf_held->list, &txq->axq_q)) {
txq->axq_link = NULL;
@@ -1982,7 +1992,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
* however leave the last descriptor back as the holding
* descriptor for hw.
*/
- lastbf->bf_status |= ATH_BUFSTATUS_STALE;
+ lastbf->bf_stale = true;
INIT_LIST_HEAD(&bf_head);
if (!list_is_singular(&lastbf->list))
list_cut_position(&bf_head,
@@ -2048,44 +2058,38 @@ int ath_tx_init(struct ath_softc *sc, int nbufs)
{
int error = 0;
- do {
- spin_lock_init(&sc->tx.txbuflock);
+ spin_lock_init(&sc->tx.txbuflock);
- error = ath_descdma_setup(sc, &sc->tx.txdma, &sc->tx.txbuf,
- "tx", nbufs, 1);
- if (error != 0) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "Failed to allocate tx descriptors: %d\n",
- error);
- break;
- }
-
- error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf,
- "beacon", ATH_BCBUF, 1);
- if (error != 0) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "Failed to allocate beacon descriptors: %d\n",
- error);
- break;
- }
+ error = ath_descdma_setup(sc, &sc->tx.txdma, &sc->tx.txbuf,
+ "tx", nbufs, 1);
+ if (error != 0) {
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "Failed to allocate tx descriptors: %d\n", error);
+ goto err;
+ }
- } while (0);
+ error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf,
+ "beacon", ATH_BCBUF, 1);
+ if (error != 0) {
+ DPRINTF(sc, ATH_DBG_FATAL,
+ "Failed to allocate beacon descriptors: %d\n", error);
+ goto err;
+ }
+err:
if (error != 0)
ath_tx_cleanup(sc);
return error;
}
-int ath_tx_cleanup(struct ath_softc *sc)
+void ath_tx_cleanup(struct ath_softc *sc)
{
if (sc->beacon.bdma.dd_desc_len != 0)
ath_descdma_cleanup(sc, &sc->beacon.bdma, &sc->beacon.bbuf);
if (sc->tx.txdma.dd_desc_len != 0)
ath_descdma_cleanup(sc, &sc->tx.txdma, &sc->tx.txbuf);
-
- return 0;
}
void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c
new file mode 100644
index 000000000000..9949b11cb151
--- /dev/null
+++ b/drivers/net/wireless/ath/main.c
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2009 Atheros Communications Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+MODULE_AUTHOR("Atheros Communications");
+MODULE_DESCRIPTION("Shared library for Atheros wireless LAN cards.");
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/net/wireless/ath9k/regd.c b/drivers/net/wireless/ath/regd.c
index 4ca625102291..7a89f9fac7d4 100644
--- a/drivers/net/wireless/ath9k/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -16,7 +16,9 @@
#include <linux/kernel.h>
#include <linux/slab.h>
-#include "ath9k.h"
+#include <net/cfg80211.h>
+#include <net/mac80211.h>
+#include "regd.h"
#include "regd_common.h"
/*
@@ -55,7 +57,7 @@
/* Can be used for:
* 0x60, 0x61, 0x62 */
-static const struct ieee80211_regdomain ath9k_world_regdom_60_61_62 = {
+static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
.n_reg_rules = 5,
.alpha2 = "99",
.reg_rules = {
@@ -65,7 +67,7 @@ static const struct ieee80211_regdomain ath9k_world_regdom_60_61_62 = {
};
/* Can be used by 0x63 and 0x65 */
-static const struct ieee80211_regdomain ath9k_world_regdom_63_65 = {
+static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
.n_reg_rules = 4,
.alpha2 = "99",
.reg_rules = {
@@ -76,7 +78,7 @@ static const struct ieee80211_regdomain ath9k_world_regdom_63_65 = {
};
/* Can be used by 0x64 only */
-static const struct ieee80211_regdomain ath9k_world_regdom_64 = {
+static const struct ieee80211_regdomain ath_world_regdom_64 = {
.n_reg_rules = 3,
.alpha2 = "99",
.reg_rules = {
@@ -86,7 +88,7 @@ static const struct ieee80211_regdomain ath9k_world_regdom_64 = {
};
/* Can be used by 0x66 and 0x69 */
-static const struct ieee80211_regdomain ath9k_world_regdom_66_69 = {
+static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
.n_reg_rules = 3,
.alpha2 = "99",
.reg_rules = {
@@ -96,7 +98,7 @@ static const struct ieee80211_regdomain ath9k_world_regdom_66_69 = {
};
/* Can be used by 0x67, 0x6A and 0x68 */
-static const struct ieee80211_regdomain ath9k_world_regdom_67_68_6A = {
+static const struct ieee80211_regdomain ath_world_regdom_67_68_6A = {
.n_reg_rules = 4,
.alpha2 = "99",
.reg_rules = {
@@ -112,49 +114,51 @@ static inline bool is_wwr_sku(u16 regd)
(regd == WORLD);
}
-static u16 ath9k_regd_get_eepromRD(struct ath_hw *ah)
+static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg)
{
- return ah->regulatory.current_rd & ~WORLDWIDE_ROAMING_FLAG;
+ return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG;
}
-bool ath9k_is_world_regd(struct ath_hw *ah)
+bool ath_is_world_regd(struct ath_regulatory *reg)
{
- return is_wwr_sku(ath9k_regd_get_eepromRD(ah));
+ return is_wwr_sku(ath_regd_get_eepromRD(reg));
}
+EXPORT_SYMBOL(ath_is_world_regd);
-const struct ieee80211_regdomain *ath9k_default_world_regdomain(void)
+static const struct ieee80211_regdomain *ath_default_world_regdomain(void)
{
/* this is the most restrictive */
- return &ath9k_world_regdom_64;
+ return &ath_world_regdom_64;
}
-const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hw *ah)
+static const struct
+ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
{
- switch (ah->regulatory.regpair->regDmnEnum) {
+ switch (reg->regpair->regDmnEnum) {
case 0x60:
case 0x61:
case 0x62:
- return &ath9k_world_regdom_60_61_62;
+ return &ath_world_regdom_60_61_62;
case 0x63:
case 0x65:
- return &ath9k_world_regdom_63_65;
+ return &ath_world_regdom_63_65;
case 0x64:
- return &ath9k_world_regdom_64;
+ return &ath_world_regdom_64;
case 0x66:
case 0x69:
- return &ath9k_world_regdom_66_69;
+ return &ath_world_regdom_66_69;
case 0x67:
case 0x68:
case 0x6A:
- return &ath9k_world_regdom_67_68_6A;
+ return &ath_world_regdom_67_68_6A;
default:
WARN_ON(1);
- return ath9k_default_world_regdomain();
+ return ath_default_world_regdomain();
}
}
/* Frequency is one where radar detection is required */
-static bool ath9k_is_radar_freq(u16 center_freq)
+static bool ath_is_radar_freq(u16 center_freq)
{
return (center_freq >= 5260 && center_freq <= 5700);
}
@@ -168,9 +172,9 @@ static bool ath9k_is_radar_freq(u16 center_freq)
* received a beacon on a channel we can enable active scan and
* adhoc (or beaconing).
*/
-static void ath9k_reg_apply_beaconing_flags(
- struct wiphy *wiphy,
- enum nl80211_reg_initiator initiator)
+static void
+ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
enum ieee80211_band band;
struct ieee80211_supported_band *sband;
@@ -191,13 +195,15 @@ static void ath9k_reg_apply_beaconing_flags(
ch = &sband->channels[i];
- if (ath9k_is_radar_freq(ch->center_freq) ||
+ if (ath_is_radar_freq(ch->center_freq) ||
(ch->flags & IEEE80211_CHAN_RADAR))
continue;
if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
- r = freq_reg_info(wiphy, ch->center_freq,
- &bandwidth, &reg_rule);
+ r = freq_reg_info(wiphy,
+ ch->center_freq,
+ bandwidth,
+ &reg_rule);
if (r)
continue;
/*
@@ -227,9 +233,9 @@ static void ath9k_reg_apply_beaconing_flags(
}
/* Allows active scan scan on Ch 12 and 13 */
-static void ath9k_reg_apply_active_scan_flags(
- struct wiphy *wiphy,
- enum nl80211_reg_initiator initiator)
+static void
+ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch;
@@ -261,7 +267,7 @@ static void ath9k_reg_apply_active_scan_flags(
*/
ch = &sband->channels[11]; /* CH 12 */
- r = freq_reg_info(wiphy, ch->center_freq, &bandwidth, &reg_rule);
+ r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule);
if (!r) {
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
@@ -269,7 +275,7 @@ static void ath9k_reg_apply_active_scan_flags(
}
ch = &sband->channels[12]; /* CH 13 */
- r = freq_reg_info(wiphy, ch->center_freq, &bandwidth, &reg_rule);
+ r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule);
if (!r) {
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
@@ -278,7 +284,7 @@ static void ath9k_reg_apply_active_scan_flags(
}
/* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */
-void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
+static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
{
struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch;
@@ -291,7 +297,7 @@ void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
for (i = 0; i < sband->n_channels; i++) {
ch = &sband->channels[i];
- if (!ath9k_is_radar_freq(ch->center_freq))
+ if (!ath_is_radar_freq(ch->center_freq))
continue;
/* We always enable radar detection/DFS on this
* frequency range. Additionally we also apply on
@@ -310,37 +316,31 @@ void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
}
}
-void ath9k_reg_apply_world_flags(struct wiphy *wiphy,
- enum nl80211_reg_initiator initiator)
+static void ath_reg_apply_world_flags(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator,
+ struct ath_regulatory *reg)
{
- struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
- struct ath_wiphy *aphy = hw->priv;
- struct ath_softc *sc = aphy->sc;
- struct ath_hw *ah = sc->sc_ah;
-
- switch (ah->regulatory.regpair->regDmnEnum) {
+ switch (reg->regpair->regDmnEnum) {
case 0x60:
case 0x63:
case 0x66:
case 0x67:
- ath9k_reg_apply_beaconing_flags(wiphy, initiator);
+ ath_reg_apply_beaconing_flags(wiphy, initiator);
break;
case 0x68:
- ath9k_reg_apply_beaconing_flags(wiphy, initiator);
- ath9k_reg_apply_active_scan_flags(wiphy, initiator);
+ ath_reg_apply_beaconing_flags(wiphy, initiator);
+ ath_reg_apply_active_scan_flags(wiphy, initiator);
break;
}
return;
}
-int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
+int ath_reg_notifier_apply(struct wiphy *wiphy,
+ struct regulatory_request *request,
+ struct ath_regulatory *reg)
{
- struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
- struct ath_wiphy *aphy = hw->priv;
- struct ath_softc *sc = aphy->sc;
-
/* We always apply this */
- ath9k_reg_apply_radar_flags(wiphy);
+ ath_reg_apply_radar_flags(wiphy);
switch (request->initiator) {
case NL80211_REGDOM_SET_BY_DRIVER:
@@ -348,17 +348,19 @@ int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
case NL80211_REGDOM_SET_BY_USER:
break;
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
- if (ath9k_is_world_regd(sc->sc_ah))
- ath9k_reg_apply_world_flags(wiphy, request->initiator);
+ if (ath_is_world_regd(reg))
+ ath_reg_apply_world_flags(wiphy, request->initiator,
+ reg);
break;
}
return 0;
}
+EXPORT_SYMBOL(ath_reg_notifier_apply);
-bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah)
+static bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
{
- u16 rd = ath9k_regd_get_eepromRD(ah);
+ u16 rd = ath_regd_get_eepromRD(reg);
int i;
if (rd & COUNTRY_ERD_FLAG) {
@@ -373,14 +375,14 @@ bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah)
if (regDomainPairs[i].regDmnEnum == rd)
return true;
}
- DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
- "invalid regulatory domain/country code 0x%x\n", rd);
+ printk(KERN_DEBUG
+ "ath: invalid regulatory domain/country code 0x%x\n", rd);
return false;
}
/* EEPROM country code to regpair mapping */
static struct country_code_to_enum_rd*
-ath9k_regd_find_country(u16 countryCode)
+ath_regd_find_country(u16 countryCode)
{
int i;
@@ -393,7 +395,7 @@ ath9k_regd_find_country(u16 countryCode)
/* EEPROM rd code to regpair mapping */
static struct country_code_to_enum_rd*
-ath9k_regd_find_country_by_rd(int regdmn)
+ath_regd_find_country_by_rd(int regdmn)
{
int i;
@@ -405,13 +407,13 @@ ath9k_regd_find_country_by_rd(int regdmn)
}
/* Returns the map of the EEPROM set RD to a country code */
-static u16 ath9k_regd_get_default_country(u16 rd)
+static u16 ath_regd_get_default_country(u16 rd)
{
if (rd & COUNTRY_ERD_FLAG) {
struct country_code_to_enum_rd *country = NULL;
u16 cc = rd & ~COUNTRY_ERD_FLAG;
- country = ath9k_regd_find_country(cc);
+ country = ath_regd_find_country(cc);
if (country != NULL)
return cc;
}
@@ -420,7 +422,7 @@ static u16 ath9k_regd_get_default_country(u16 rd)
}
static struct reg_dmn_pair_mapping*
-ath9k_get_regpair(int regdmn)
+ath_get_regpair(int regdmn)
{
int i;
@@ -433,87 +435,120 @@ ath9k_get_regpair(int regdmn)
return NULL;
}
-int ath9k_regd_init(struct ath_hw *ah)
+static int
+ath_regd_init_wiphy(struct ath_regulatory *reg,
+ struct wiphy *wiphy,
+ int (*reg_notifier)(struct wiphy *wiphy,
+ struct regulatory_request *request))
+{
+ const struct ieee80211_regdomain *regd;
+
+ wiphy->reg_notifier = reg_notifier;
+ wiphy->strict_regulatory = true;
+
+ if (ath_is_world_regd(reg)) {
+ /*
+ * Anything applied here (prior to wiphy registration) gets
+ * saved on the wiphy orig_* parameters
+ */
+ regd = ath_world_regdomain(reg);
+ wiphy->custom_regulatory = true;
+ wiphy->strict_regulatory = false;
+ } else {
+ /*
+ * This gets applied in the case of the absense of CRDA,
+ * it's our own custom world regulatory domain, similar to
+ * cfg80211's but we enable passive scanning.
+ */
+ regd = ath_default_world_regdomain();
+ }
+ wiphy_apply_custom_regulatory(wiphy, regd);
+ ath_reg_apply_radar_flags(wiphy);
+ ath_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
+ return 0;
+}
+
+int
+ath_regd_init(struct ath_regulatory *reg,
+ struct wiphy *wiphy,
+ int (*reg_notifier)(struct wiphy *wiphy,
+ struct regulatory_request *request))
{
struct country_code_to_enum_rd *country = NULL;
u16 regdmn;
- if (!ath9k_regd_is_eeprom_valid(ah)) {
- DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
- "Invalid EEPROM contents\n");
+ if (!ath_regd_is_eeprom_valid(reg)) {
+ printk(KERN_ERR "ath: Invalid EEPROM contents\n");
return -EINVAL;
}
- regdmn = ath9k_regd_get_eepromRD(ah);
- ah->regulatory.country_code = ath9k_regd_get_default_country(regdmn);
+ regdmn = ath_regd_get_eepromRD(reg);
+ reg->country_code = ath_regd_get_default_country(regdmn);
- if (ah->regulatory.country_code == CTRY_DEFAULT &&
+ if (reg->country_code == CTRY_DEFAULT &&
regdmn == CTRY_DEFAULT)
- ah->regulatory.country_code = CTRY_UNITED_STATES;
+ reg->country_code = CTRY_UNITED_STATES;
- if (ah->regulatory.country_code == CTRY_DEFAULT) {
+ if (reg->country_code == CTRY_DEFAULT) {
country = NULL;
} else {
- country = ath9k_regd_find_country(ah->regulatory.country_code);
+ country = ath_regd_find_country(reg->country_code);
if (country == NULL) {
- DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
- "Country is NULL!!!!, cc= %d\n",
- ah->regulatory.country_code);
+ printk(KERN_DEBUG
+ "ath: Country is NULL!!!!, cc= %d\n",
+ reg->country_code);
return -EINVAL;
} else
regdmn = country->regDmnEnum;
}
- ah->regulatory.regpair = ath9k_get_regpair(regdmn);
+ reg->regpair = ath_get_regpair(regdmn);
- if (!ah->regulatory.regpair) {
- DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+ if (!reg->regpair) {
+ printk(KERN_DEBUG "ath: "
"No regulatory domain pair found, cannot continue\n");
return -EINVAL;
}
if (!country)
- country = ath9k_regd_find_country_by_rd(regdmn);
+ country = ath_regd_find_country_by_rd(regdmn);
if (country) {
- ah->regulatory.alpha2[0] = country->isoName[0];
- ah->regulatory.alpha2[1] = country->isoName[1];
+ reg->alpha2[0] = country->isoName[0];
+ reg->alpha2[1] = country->isoName[1];
} else {
- ah->regulatory.alpha2[0] = '0';
- ah->regulatory.alpha2[1] = '0';
+ reg->alpha2[0] = '0';
+ reg->alpha2[1] = '0';
}
- DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
- "Country alpha2 being used: %c%c\n"
- "Regulatory.Regpair detected: 0x%0x\n",
- ah->regulatory.alpha2[0], ah->regulatory.alpha2[1],
- ah->regulatory.regpair->regDmnEnum);
+ printk(KERN_DEBUG "ath: Country alpha2 being used: %c%c\n",
+ reg->alpha2[0], reg->alpha2[1]);
+ printk(KERN_DEBUG "ath: Regpair detected: 0x%0x\n",
+ reg->regpair->regDmnEnum);
+ ath_regd_init_wiphy(reg, wiphy, reg_notifier);
return 0;
}
+EXPORT_SYMBOL(ath_regd_init);
-u32 ath9k_regd_get_ctl(struct ath_hw *ah, struct ath9k_channel *chan)
+u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
+ enum ieee80211_band band)
{
- u32 ctl = NO_CTL;
-
- if (!ah->regulatory.regpair ||
- (ah->regulatory.country_code == CTRY_DEFAULT &&
- is_wwr_sku(ath9k_regd_get_eepromRD(ah)))) {
- if (IS_CHAN_B(chan))
- ctl = SD_NO_CTL | CTL_11B;
- else if (IS_CHAN_G(chan))
- ctl = SD_NO_CTL | CTL_11G;
- else
- ctl = SD_NO_CTL | CTL_11A;
- return ctl;
+ if (!reg->regpair ||
+ (reg->country_code == CTRY_DEFAULT &&
+ is_wwr_sku(ath_regd_get_eepromRD(reg)))) {
+ return SD_NO_CTL;
}
- if (IS_CHAN_B(chan))
- ctl = ah->regulatory.regpair->reg_2ghz_ctl | CTL_11B;
- else if (IS_CHAN_G(chan))
- ctl = ah->regulatory.regpair->reg_2ghz_ctl | CTL_11G;
- else
- ctl = ah->regulatory.regpair->reg_5ghz_ctl | CTL_11A;
+ switch (band) {
+ case IEEE80211_BAND_2GHZ:
+ return reg->regpair->reg_2ghz_ctl;
+ case IEEE80211_BAND_5GHZ:
+ return reg->regpair->reg_5ghz_ctl;
+ default:
+ return NO_CTL;
+ }
- return ctl;
+ return NO_CTL;
}
+EXPORT_SYMBOL(ath_regd_get_band_ctl);
diff --git a/drivers/net/wireless/ath9k/regd.h b/drivers/net/wireless/ath/regd.h
index 9f5fbd4eea7a..07291ccb23f2 100644
--- a/drivers/net/wireless/ath9k/regd.h
+++ b/drivers/net/wireless/ath/regd.h
@@ -17,6 +17,25 @@
#ifndef REGD_H
#define REGD_H
+#include <linux/nl80211.h>
+
+#include <net/cfg80211.h>
+
+#define NO_CTL 0xff
+#define SD_NO_CTL 0xE0
+#define NO_CTL 0xff
+#define CTL_MODE_M 7
+#define CTL_11A 0
+#define CTL_11B 1
+#define CTL_11G 2
+#define CTL_2GHT20 5
+#define CTL_5GHT20 6
+#define CTL_2GHT40 7
+#define CTL_5GHT40 8
+
+#define CTRY_DEBUG 0x1ff
+#define CTRY_DEFAULT 0
+
#define COUNTRY_ERD_FLAG 0x8000
#define WORLDWIDE_ROAMING_FLAG 0x4000
@@ -40,7 +59,7 @@ struct country_code_to_enum_rd {
const char *isoName;
};
-struct ath9k_regulatory {
+struct ath_regulatory {
char alpha2[2];
u16 country_code;
u16 max_power_level;
@@ -233,15 +252,14 @@ enum CountryCode {
CTRY_BELGIUM2 = 5002
};
-bool ath9k_is_world_regd(struct ath_hw *ah);
-const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hw *ah);
-const struct ieee80211_regdomain *ath9k_default_world_regdomain(void);
-void ath9k_reg_apply_world_flags(struct wiphy *wiphy,
- enum nl80211_reg_initiator initiator);
-void ath9k_reg_apply_radar_flags(struct wiphy *wiphy);
-int ath9k_regd_init(struct ath_hw *ah);
-bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah);
-u32 ath9k_regd_get_ctl(struct ath_hw *ah, struct ath9k_channel *chan);
-int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request);
+bool ath_is_world_regd(struct ath_regulatory *reg);
+int ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
+ int (*reg_notifier)(struct wiphy *wiphy,
+ struct regulatory_request *request));
+u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
+ enum ieee80211_band band);
+int ath_reg_notifier_apply(struct wiphy *wiphy,
+ struct regulatory_request *request,
+ struct ath_regulatory *reg);
#endif
diff --git a/drivers/net/wireless/ath9k/regd_common.h b/drivers/net/wireless/ath/regd_common.h
index 4d0e298cd1c7..4d0e298cd1c7 100644
--- a/drivers/net/wireless/ath9k/regd_common.h
+++ b/drivers/net/wireless/ath/regd_common.h
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 77406245dc7b..ddaa859c3491 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -279,7 +279,7 @@ static int atmel_config(struct pcmcia_device *link)
struct pcmcia_device_id *did;
dev = link->priv;
- did = handle_to_dev(link).driver_data;
+ did = dev_get_drvdata(&handle_to_dev(link));
DEBUG(0, "atmel_config(0x%p)\n", link);
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index aab71a70ba78..21572e40b79d 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -3,7 +3,6 @@ config B43
depends on SSB_POSSIBLE && MAC80211 && WLAN_80211 && HAS_DMA
select SSB
select FW_LOADER
- select HW_RANDOM
---help---
b43 is a driver for the Broadcom 43xx series wireless devices.
@@ -106,6 +105,13 @@ config B43_RFKILL
depends on B43 && (RFKILL = y || RFKILL = B43) && RFKILL_INPUT && (INPUT_POLLDEV = y || INPUT_POLLDEV = B43)
default y
+# This config option automatically enables b43 HW-RNG support,
+# if the HW-RNG core is enabled.
+config B43_HWRNG
+ bool
+ depends on B43 && (HW_RANDOM = y || HW_RANDOM = B43)
+ default y
+
config B43_DEBUG
bool "Broadcom 43xx debugging"
depends on B43
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index beaf18d6e8a7..4e8ad841c3c5 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -625,9 +625,11 @@ struct b43_wl {
/* Stats about the wireless interface */
struct ieee80211_low_level_stats ieee_stats;
+#ifdef CONFIG_B43_HWRNG
struct hwrng rng;
- u8 rng_initialized;
+ bool rng_initialized;
char rng_name[30 + 1];
+#endif /* CONFIG_B43_HWRNG */
/* The RF-kill button */
struct b43_rfkill rfkill;
@@ -776,8 +778,8 @@ struct b43_wldev {
/* Reason code of the last interrupt. */
u32 irq_reason;
u32 dma_reason[6];
- /* saved irq enable/disable state bitfield. */
- u32 irq_savedstate;
+ /* The currently active generic-interrupt mask. */
+ u32 irq_mask;
/* Link Quality calculation context. */
struct b43_noise_calculation noisecalc;
/* if > 0 MAC is suspended. if == 0 MAC is enabled. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 79b685e300c7..cb4a8712946a 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -673,32 +673,6 @@ static void b43_short_slot_timing_disable(struct b43_wldev *dev)
b43_set_slot_time(dev, 20);
}
-/* Enable a Generic IRQ. "mask" is the mask of which IRQs to enable.
- * Returns the _previously_ enabled IRQ mask.
- */
-static inline u32 b43_interrupt_enable(struct b43_wldev *dev, u32 mask)
-{
- u32 old_mask;
-
- old_mask = b43_read32(dev, B43_MMIO_GEN_IRQ_MASK);
- b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, old_mask | mask);
-
- return old_mask;
-}
-
-/* Disable a Generic IRQ. "mask" is the mask of which IRQs to disable.
- * Returns the _previously_ enabled IRQ mask.
- */
-static inline u32 b43_interrupt_disable(struct b43_wldev *dev, u32 mask)
-{
- u32 old_mask;
-
- old_mask = b43_read32(dev, B43_MMIO_GEN_IRQ_MASK);
- b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, old_mask & ~mask);
-
- return old_mask;
-}
-
/* Synchronize IRQ top- and bottom-half.
* IRQs must be masked before calling this.
* This must not be called with the irq_lock held.
@@ -1593,7 +1567,7 @@ static void handle_irq_beacon(struct b43_wldev *dev)
/* This is the bottom half of the asynchronous beacon update. */
/* Ignore interrupt in the future. */
- dev->irq_savedstate &= ~B43_IRQ_BEACON;
+ dev->irq_mask &= ~B43_IRQ_BEACON;
cmd = b43_read32(dev, B43_MMIO_MACCMD);
beacon0_valid = (cmd & B43_MACCMD_BEACON0_VALID);
@@ -1602,7 +1576,7 @@ static void handle_irq_beacon(struct b43_wldev *dev)
/* Schedule interrupt manually, if busy. */
if (beacon0_valid && beacon1_valid) {
b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_BEACON);
- dev->irq_savedstate |= B43_IRQ_BEACON;
+ dev->irq_mask |= B43_IRQ_BEACON;
return;
}
@@ -1641,11 +1615,9 @@ static void b43_beacon_update_trigger_work(struct work_struct *work)
if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) {
spin_lock_irq(&wl->irq_lock);
/* update beacon right away or defer to irq */
- dev->irq_savedstate = b43_read32(dev, B43_MMIO_GEN_IRQ_MASK);
handle_irq_beacon(dev);
/* The handler might have updated the IRQ mask. */
- b43_write32(dev, B43_MMIO_GEN_IRQ_MASK,
- dev->irq_savedstate);
+ b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask);
mmiowb();
spin_unlock_irq(&wl->irq_lock);
}
@@ -1879,7 +1851,7 @@ static void b43_interrupt_tasklet(struct b43_wldev *dev)
if (reason & B43_IRQ_TX_OK)
handle_irq_transmit_status(dev);
- b43_interrupt_enable(dev, dev->irq_savedstate);
+ b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask);
mmiowb();
spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
}
@@ -1893,7 +1865,9 @@ static void b43_interrupt_ack(struct b43_wldev *dev, u32 reason)
b43_write32(dev, B43_MMIO_DMA2_REASON, dev->dma_reason[2]);
b43_write32(dev, B43_MMIO_DMA3_REASON, dev->dma_reason[3]);
b43_write32(dev, B43_MMIO_DMA4_REASON, dev->dma_reason[4]);
+/* Unused ring
b43_write32(dev, B43_MMIO_DMA5_REASON, dev->dma_reason[5]);
+*/
}
/* Interrupt handler top-half */
@@ -1903,18 +1877,19 @@ static irqreturn_t b43_interrupt_handler(int irq, void *dev_id)
struct b43_wldev *dev = dev_id;
u32 reason;
- if (!dev)
- return IRQ_NONE;
+ B43_WARN_ON(!dev);
spin_lock(&dev->wl->irq_lock);
- if (b43_status(dev) < B43_STAT_STARTED)
+ if (unlikely(b43_status(dev) < B43_STAT_STARTED)) {
+ /* This can only happen on shared IRQ lines. */
goto out;
+ }
reason = b43_read32(dev, B43_MMIO_GEN_IRQ_REASON);
if (reason == 0xffffffff) /* shared IRQ */
goto out;
ret = IRQ_HANDLED;
- reason &= b43_read32(dev, B43_MMIO_GEN_IRQ_MASK);
+ reason &= dev->irq_mask;
if (!reason)
goto out;
@@ -1928,16 +1903,18 @@ static irqreturn_t b43_interrupt_handler(int irq, void *dev_id)
& 0x0001DC00;
dev->dma_reason[4] = b43_read32(dev, B43_MMIO_DMA4_REASON)
& 0x0000DC00;
+/* Unused ring
dev->dma_reason[5] = b43_read32(dev, B43_MMIO_DMA5_REASON)
& 0x0000DC00;
+*/
b43_interrupt_ack(dev, reason);
/* disable all IRQs. They are enabled again in the bottom half. */
- dev->irq_savedstate = b43_interrupt_disable(dev, B43_IRQ_ALL);
+ b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0);
/* save the reason code and call our bottom half. */
dev->irq_reason = reason;
tasklet_schedule(&dev->isr_tasklet);
- out:
+out:
mmiowb();
spin_unlock(&dev->wl->irq_lock);
@@ -2980,6 +2957,7 @@ static void b43_security_init(struct b43_wldev *dev)
b43_clear_keys(dev);
}
+#ifdef CONFIG_B43_HWRNG
static int b43_rng_read(struct hwrng *rng, u32 *data)
{
struct b43_wl *wl = (struct b43_wl *)rng->priv;
@@ -2995,17 +2973,21 @@ static int b43_rng_read(struct hwrng *rng, u32 *data)
return (sizeof(u16));
}
+#endif /* CONFIG_B43_HWRNG */
static void b43_rng_exit(struct b43_wl *wl)
{
+#ifdef CONFIG_B43_HWRNG
if (wl->rng_initialized)
hwrng_unregister(&wl->rng);
+#endif /* CONFIG_B43_HWRNG */
}
static int b43_rng_init(struct b43_wl *wl)
{
- int err;
+ int err = 0;
+#ifdef CONFIG_B43_HWRNG
snprintf(wl->rng_name, ARRAY_SIZE(wl->rng_name),
"%s_%s", KBUILD_MODNAME, wiphy_name(wl->hw->wiphy));
wl->rng.name = wl->rng_name;
@@ -3018,6 +3000,7 @@ static int b43_rng_init(struct b43_wl *wl)
b43err(wl, "Failed to register the random "
"number generator (%d)\n", err);
}
+#endif /* CONFIG_B43_HWRNG */
return err;
}
@@ -3485,11 +3468,6 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
if (phy->ops->set_rx_antenna)
phy->ops->set_rx_antenna(dev, antenna);
- /* Update templates for AP/mesh mode. */
- if (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
- b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT))
- b43_set_beacon_int(dev, conf->beacon_int);
-
if (!!conf->radio_enabled != phy->radio_on) {
if (conf->radio_enabled) {
b43_software_rfkill(dev, RFKILL_STATE_UNBLOCKED);
@@ -3565,14 +3543,45 @@ static void b43_op_bss_info_changed(struct ieee80211_hw *hw,
{
struct b43_wl *wl = hw_to_b43_wl(hw);
struct b43_wldev *dev;
+ unsigned long flags;
mutex_lock(&wl->mutex);
dev = wl->current_dev;
if (!dev || b43_status(dev) < B43_STAT_STARTED)
goto out_unlock_mutex;
+
+ B43_WARN_ON(wl->vif != vif);
+
+ spin_lock_irqsave(&wl->irq_lock, flags);
+ if (changed & BSS_CHANGED_BSSID) {
+ if (conf->bssid)
+ memcpy(wl->bssid, conf->bssid, ETH_ALEN);
+ else
+ memset(wl->bssid, 0, ETH_ALEN);
+ }
+
+ if (b43_status(dev) >= B43_STAT_INITIALIZED) {
+ if (changed & BSS_CHANGED_BEACON &&
+ (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
+ b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT) ||
+ b43_is_mode(wl, NL80211_IFTYPE_ADHOC)))
+ b43_update_templates(wl);
+
+ if (changed & BSS_CHANGED_BSSID)
+ b43_write_mac_bssid_templates(dev);
+ }
+ spin_unlock_irqrestore(&wl->irq_lock, flags);
+
b43_mac_suspend(dev);
+ /* Update templates for AP/mesh mode. */
+ if (changed & BSS_CHANGED_BEACON_INT &&
+ (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
+ b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT) ||
+ b43_is_mode(wl, NL80211_IFTYPE_ADHOC)))
+ b43_set_beacon_int(dev, conf->beacon_int);
+
if (changed & BSS_CHANGED_BASIC_RATES)
b43_update_basic_rates(dev, conf->basic_rates);
@@ -3586,8 +3595,6 @@ static void b43_op_bss_info_changed(struct ieee80211_hw *hw,
b43_mac_enable(dev);
out_unlock_mutex:
mutex_unlock(&wl->mutex);
-
- return;
}
static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -3630,7 +3637,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
err = -EINVAL;
switch (key->alg) {
case ALG_WEP:
- if (key->keylen == LEN_WEP40)
+ if (key->keylen == WLAN_KEY_LEN_WEP40)
algorithm = B43_SEC_ALGO_WEP40;
else
algorithm = B43_SEC_ALGO_WEP104;
@@ -3745,41 +3752,6 @@ static void b43_op_configure_filter(struct ieee80211_hw *hw,
spin_unlock_irqrestore(&wl->irq_lock, flags);
}
-static int b43_op_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct b43_wl *wl = hw_to_b43_wl(hw);
- struct b43_wldev *dev = wl->current_dev;
- unsigned long flags;
-
- if (!dev)
- return -ENODEV;
- mutex_lock(&wl->mutex);
- spin_lock_irqsave(&wl->irq_lock, flags);
- B43_WARN_ON(wl->vif != vif);
- if (conf->bssid)
- memcpy(wl->bssid, conf->bssid, ETH_ALEN);
- else
- memset(wl->bssid, 0, ETH_ALEN);
- if (b43_status(dev) >= B43_STAT_INITIALIZED) {
- if (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
- b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT)) {
- B43_WARN_ON(vif->type != wl->if_type);
- if (conf->changed & IEEE80211_IFCC_BEACON)
- b43_update_templates(wl);
- } else if (b43_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
- if (conf->changed & IEEE80211_IFCC_BEACON)
- b43_update_templates(wl);
- }
- b43_write_mac_bssid_templates(dev);
- }
- spin_unlock_irqrestore(&wl->irq_lock, flags);
- mutex_unlock(&wl->mutex);
-
- return 0;
-}
-
/* Locking: wl->mutex */
static void b43_wireless_core_stop(struct b43_wldev *dev)
{
@@ -3793,7 +3765,7 @@ static void b43_wireless_core_stop(struct b43_wldev *dev)
* setting the status to INITIALIZED, as the interrupt handler
* won't care about IRQs then. */
spin_lock_irqsave(&wl->irq_lock, flags);
- dev->irq_savedstate = b43_interrupt_disable(dev, B43_IRQ_ALL);
+ b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0);
b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* flush */
spin_unlock_irqrestore(&wl->irq_lock, flags);
b43_synchronize_irq(dev);
@@ -3834,7 +3806,7 @@ static int b43_wireless_core_start(struct b43_wldev *dev)
/* Start data flow (TX/RX). */
b43_mac_enable(dev);
- b43_interrupt_enable(dev, dev->irq_savedstate);
+ b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask);
/* Start maintainance work */
b43_periodic_tasks_setup(dev);
@@ -3997,9 +3969,9 @@ static void setup_struct_wldev_for_init(struct b43_wldev *dev)
/* IRQ related flags */
dev->irq_reason = 0;
memset(dev->dma_reason, 0, sizeof(dev->dma_reason));
- dev->irq_savedstate = B43_IRQ_MASKTEMPLATE;
+ dev->irq_mask = B43_IRQ_MASKTEMPLATE;
if (b43_modparam_verbose < B43_VERBOSITY_DEBUG)
- dev->irq_savedstate &= ~B43_IRQ_PHY_TXERR;
+ dev->irq_mask &= ~B43_IRQ_PHY_TXERR;
dev->mac_suspended = 1;
@@ -4449,7 +4421,6 @@ static const struct ieee80211_ops b43_hw_ops = {
.remove_interface = b43_op_remove_interface,
.config = b43_op_config,
.bss_info_changed = b43_op_bss_info_changed,
- .config_interface = b43_op_config_interface,
.configure_filter = b43_op_configure_filter,
.set_key = b43_op_set_key,
.get_stats = b43_op_get_stats,
diff --git a/drivers/net/wireless/b43legacy/Kconfig b/drivers/net/wireless/b43legacy/Kconfig
index aef2298d37ac..d4f628a74bbd 100644
--- a/drivers/net/wireless/b43legacy/Kconfig
+++ b/drivers/net/wireless/b43legacy/Kconfig
@@ -3,7 +3,6 @@ config B43LEGACY
depends on SSB_POSSIBLE && MAC80211 && WLAN_80211 && HAS_DMA
select SSB
select FW_LOADER
- select HW_RANDOM
---help---
b43legacy is a driver for 802.11b devices from Broadcom (BCM4301 and
BCM4303) and early model 802.11g chips (BCM4306 Ver. 2) used in the
@@ -51,6 +50,13 @@ config B43LEGACY_RFKILL
depends on B43LEGACY && (RFKILL = y || RFKILL = B43LEGACY) && RFKILL_INPUT && (INPUT_POLLDEV = y || INPUT_POLLDEV = B43LEGACY)
default y
+# This config option automatically enables b43 HW-RNG support,
+# if the HW-RNG core is enabled.
+config B43LEGACY_HWRNG
+ bool
+ depends on B43LEGACY && (HW_RANDOM = y || HW_RANDOM = B43LEGACY)
+ default y
+
config B43LEGACY_DEBUG
bool "Broadcom 43xx-legacy debugging"
depends on B43LEGACY
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h
index 97b0e06dfe21..19a4b0bc0d87 100644
--- a/drivers/net/wireless/b43legacy/b43legacy.h
+++ b/drivers/net/wireless/b43legacy/b43legacy.h
@@ -59,7 +59,8 @@
#define B43legacy_MMIO_XMITSTAT_1 0x174
#define B43legacy_MMIO_REV3PLUS_TSF_LOW 0x180 /* core rev >= 3 only */
#define B43legacy_MMIO_REV3PLUS_TSF_HIGH 0x184 /* core rev >= 3 only */
-
+#define B43legacy_MMIO_TSF_CFP_REP 0x188
+#define B43legacy_MMIO_TSF_CFP_START 0x18C
/* 32-bit DMA */
#define B43legacy_MMIO_DMA32_BASE0 0x200
#define B43legacy_MMIO_DMA32_BASE1 0x220
@@ -258,7 +259,6 @@
#define B43legacy_IRQ_ALL 0xFFFFFFFF
#define B43legacy_IRQ_MASKTEMPLATE (B43legacy_IRQ_MAC_SUSPENDED | \
- B43legacy_IRQ_BEACON | \
B43legacy_IRQ_TBTT_INDI | \
B43legacy_IRQ_ATIM_END | \
B43legacy_IRQ_PMQ | \
@@ -596,9 +596,11 @@ struct b43legacy_wl {
/* Stats about the wireless interface */
struct ieee80211_low_level_stats ieee_stats;
+#ifdef CONFIG_B43LEGACY_HWRNG
struct hwrng rng;
u8 rng_initialized;
char rng_name[30 + 1];
+#endif
/* The RF-kill button */
struct b43legacy_rfkill rfkill;
@@ -614,6 +616,8 @@ struct b43legacy_wl {
struct sk_buff *current_beacon;
bool beacon0_uploaded;
bool beacon1_uploaded;
+ bool beacon_templates_virgin; /* Never wrote the templates? */
+ struct work_struct beacon_update_trigger;
};
/* Pointers to the firmware data and meta information about it. */
@@ -690,8 +694,8 @@ struct b43legacy_wldev {
/* Reason code of the last interrupt. */
u32 irq_reason;
u32 dma_reason[6];
- /* saved irq enable/disable state bitfield. */
- u32 irq_savedstate;
+ /* The currently active generic-interrupt mask. */
+ u32 irq_mask;
/* Link Quality calculation context. */
struct b43legacy_noise_calculation noisecalc;
/* if > 0 MAC is suspended. if == 0 MAC is enabled. */
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 879edc786713..f6f3fbf0a2f4 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -583,35 +583,6 @@ static void b43legacy_short_slot_timing_disable(struct b43legacy_wldev *dev)
b43legacy_set_slot_time(dev, 20);
}
-/* Enable a Generic IRQ. "mask" is the mask of which IRQs to enable.
- * Returns the _previously_ enabled IRQ mask.
- */
-static inline u32 b43legacy_interrupt_enable(struct b43legacy_wldev *dev,
- u32 mask)
-{
- u32 old_mask;
-
- old_mask = b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_MASK);
- b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, old_mask |
- mask);
-
- return old_mask;
-}
-
-/* Disable a Generic IRQ. "mask" is the mask of which IRQs to disable.
- * Returns the _previously_ enabled IRQ mask.
- */
-static inline u32 b43legacy_interrupt_disable(struct b43legacy_wldev *dev,
- u32 mask)
-{
- u32 old_mask;
-
- old_mask = b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_MASK);
- b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, old_mask & ~mask);
-
- return old_mask;
-}
-
/* Synchronize IRQ top- and bottom-half.
* IRQs must be masked before calling this.
* This must not be called with the irq_lock held.
@@ -955,23 +926,54 @@ static void b43legacy_write_template_common(struct b43legacy_wldev *dev,
size + sizeof(struct b43legacy_plcp_hdr6));
}
+/* Convert a b43legacy antenna number value to the PHY TX control value. */
+static u16 b43legacy_antenna_to_phyctl(int antenna)
+{
+ switch (antenna) {
+ case B43legacy_ANTENNA0:
+ return B43legacy_TX4_PHY_ANT0;
+ case B43legacy_ANTENNA1:
+ return B43legacy_TX4_PHY_ANT1;
+ }
+ return B43legacy_TX4_PHY_ANTLAST;
+}
+
static void b43legacy_write_beacon_template(struct b43legacy_wldev *dev,
u16 ram_offset,
- u16 shm_size_offset, u8 rate)
+ u16 shm_size_offset)
{
unsigned int i, len, variable_len;
const struct ieee80211_mgmt *bcn;
const u8 *ie;
bool tim_found = 0;
+ unsigned int rate;
+ u16 ctl;
+ int antenna;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(dev->wl->current_beacon);
bcn = (const struct ieee80211_mgmt *)(dev->wl->current_beacon->data);
len = min((size_t)dev->wl->current_beacon->len,
0x200 - sizeof(struct b43legacy_plcp_hdr6));
+ rate = ieee80211_get_tx_rate(dev->wl->hw, info)->hw_value;
b43legacy_write_template_common(dev, (const u8 *)bcn, len, ram_offset,
shm_size_offset, rate);
+ /* Write the PHY TX control parameters. */
+ antenna = B43legacy_ANTENNA_DEFAULT;
+ antenna = b43legacy_antenna_to_phyctl(antenna);
+ ctl = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED,
+ B43legacy_SHM_SH_BEACPHYCTL);
+ /* We can't send beacons with short preamble. Would get PHY errors. */
+ ctl &= ~B43legacy_TX4_PHY_SHORTPRMBL;
+ ctl &= ~B43legacy_TX4_PHY_ANT;
+ ctl &= ~B43legacy_TX4_PHY_ENC;
+ ctl |= antenna;
+ ctl |= B43legacy_TX4_PHY_ENC_CCK;
+ b43legacy_shm_write16(dev, B43legacy_SHM_SHARED,
+ B43legacy_SHM_SH_BEACPHYCTL, ctl);
+
/* Find the position of the TIM and the DTIM_period value
* and write them to SHM. */
ie = bcn->u.beacon.variable;
@@ -1013,7 +1015,8 @@ static void b43legacy_write_beacon_template(struct b43legacy_wldev *dev,
b43legacywarn(dev->wl, "Did not find a valid TIM IE in the "
"beacon template packet. AP or IBSS operation "
"may be broken.\n");
- }
+ } else
+ b43legacydbg(dev->wl, "Updated beacon template\n");
}
static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev,
@@ -1025,7 +1028,7 @@ static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev,
__le16 dur;
plcp.data = 0;
- b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->bitrate);
+ b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->hw_value);
dur = ieee80211_generic_frame_duration(dev->wl->hw,
dev->wl->vif,
size,
@@ -1129,10 +1132,103 @@ static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev,
0x200 - sizeof(struct b43legacy_plcp_hdr6));
b43legacy_write_template_common(dev, probe_resp_data,
size, ram_offset,
- shm_size_offset, rate->bitrate);
+ shm_size_offset, rate->hw_value);
kfree(probe_resp_data);
}
+static void b43legacy_upload_beacon0(struct b43legacy_wldev *dev)
+{
+ struct b43legacy_wl *wl = dev->wl;
+
+ if (wl->beacon0_uploaded)
+ return;
+ b43legacy_write_beacon_template(dev, 0x68, 0x18);
+ /* FIXME: Probe resp upload doesn't really belong here,
+ * but we don't use that feature anyway. */
+ b43legacy_write_probe_resp_template(dev, 0x268, 0x4A,
+ &__b43legacy_ratetable[3]);
+ wl->beacon0_uploaded = 1;
+}
+
+static void b43legacy_upload_beacon1(struct b43legacy_wldev *dev)
+{
+ struct b43legacy_wl *wl = dev->wl;
+
+ if (wl->beacon1_uploaded)
+ return;
+ b43legacy_write_beacon_template(dev, 0x468, 0x1A);
+ wl->beacon1_uploaded = 1;
+}
+
+static void handle_irq_beacon(struct b43legacy_wldev *dev)
+{
+ struct b43legacy_wl *wl = dev->wl;
+ u32 cmd, beacon0_valid, beacon1_valid;
+
+ if (!b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
+ return;
+
+ /* This is the bottom half of the asynchronous beacon update. */
+
+ /* Ignore interrupt in the future. */
+ dev->irq_mask &= ~B43legacy_IRQ_BEACON;
+
+ cmd = b43legacy_read32(dev, B43legacy_MMIO_MACCMD);
+ beacon0_valid = (cmd & B43legacy_MACCMD_BEACON0_VALID);
+ beacon1_valid = (cmd & B43legacy_MACCMD_BEACON1_VALID);
+
+ /* Schedule interrupt manually, if busy. */
+ if (beacon0_valid && beacon1_valid) {
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_REASON, B43legacy_IRQ_BEACON);
+ dev->irq_mask |= B43legacy_IRQ_BEACON;
+ return;
+ }
+
+ if (unlikely(wl->beacon_templates_virgin)) {
+ /* We never uploaded a beacon before.
+ * Upload both templates now, but only mark one valid. */
+ wl->beacon_templates_virgin = 0;
+ b43legacy_upload_beacon0(dev);
+ b43legacy_upload_beacon1(dev);
+ cmd = b43legacy_read32(dev, B43legacy_MMIO_MACCMD);
+ cmd |= B43legacy_MACCMD_BEACON0_VALID;
+ b43legacy_write32(dev, B43legacy_MMIO_MACCMD, cmd);
+ } else {
+ if (!beacon0_valid) {
+ b43legacy_upload_beacon0(dev);
+ cmd = b43legacy_read32(dev, B43legacy_MMIO_MACCMD);
+ cmd |= B43legacy_MACCMD_BEACON0_VALID;
+ b43legacy_write32(dev, B43legacy_MMIO_MACCMD, cmd);
+ } else if (!beacon1_valid) {
+ b43legacy_upload_beacon1(dev);
+ cmd = b43legacy_read32(dev, B43legacy_MMIO_MACCMD);
+ cmd |= B43legacy_MACCMD_BEACON1_VALID;
+ b43legacy_write32(dev, B43legacy_MMIO_MACCMD, cmd);
+ }
+ }
+}
+
+static void b43legacy_beacon_update_trigger_work(struct work_struct *work)
+{
+ struct b43legacy_wl *wl = container_of(work, struct b43legacy_wl,
+ beacon_update_trigger);
+ struct b43legacy_wldev *dev;
+
+ mutex_lock(&wl->mutex);
+ dev = wl->current_dev;
+ if (likely(dev && (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED))) {
+ spin_lock_irq(&wl->irq_lock);
+ /* Update beacon right away or defer to IRQ. */
+ handle_irq_beacon(dev);
+ /* The handler might have updated the IRQ mask. */
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK,
+ dev->irq_mask);
+ mmiowb();
+ spin_unlock_irq(&wl->irq_lock);
+ }
+ mutex_unlock(&wl->mutex);
+}
+
/* Asynchronously update the packet templates in template RAM.
* Locking: Requires wl->irq_lock to be locked. */
static void b43legacy_update_templates(struct b43legacy_wl *wl)
@@ -1156,54 +1252,24 @@ static void b43legacy_update_templates(struct b43legacy_wl *wl)
wl->current_beacon = beacon;
wl->beacon0_uploaded = 0;
wl->beacon1_uploaded = 0;
+ queue_work(wl->hw->workqueue, &wl->beacon_update_trigger);
}
static void b43legacy_set_beacon_int(struct b43legacy_wldev *dev,
u16 beacon_int)
{
b43legacy_time_lock(dev);
- if (dev->dev->id.revision >= 3)
- b43legacy_write32(dev, 0x188, (beacon_int << 16));
- else {
+ if (dev->dev->id.revision >= 3) {
+ b43legacy_write32(dev, B43legacy_MMIO_TSF_CFP_REP,
+ (beacon_int << 16));
+ b43legacy_write32(dev, B43legacy_MMIO_TSF_CFP_START,
+ (beacon_int << 10));
+ } else {
b43legacy_write16(dev, 0x606, (beacon_int >> 6));
b43legacy_write16(dev, 0x610, beacon_int);
}
b43legacy_time_unlock(dev);
-}
-
-static void handle_irq_beacon(struct b43legacy_wldev *dev)
-{
- struct b43legacy_wl *wl = dev->wl;
- u32 cmd;
-
- if (!b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
- return;
-
- /* This is the bottom half of the asynchronous beacon update. */
-
- cmd = b43legacy_read32(dev, B43legacy_MMIO_MACCMD);
- if (!(cmd & B43legacy_MACCMD_BEACON0_VALID)) {
- if (!wl->beacon0_uploaded) {
- b43legacy_write_beacon_template(dev, 0x68,
- B43legacy_SHM_SH_BTL0,
- B43legacy_CCK_RATE_1MB);
- b43legacy_write_probe_resp_template(dev, 0x268,
- B43legacy_SHM_SH_PRTLEN,
- &__b43legacy_ratetable[3]);
- wl->beacon0_uploaded = 1;
- }
- cmd |= B43legacy_MACCMD_BEACON0_VALID;
- }
- if (!(cmd & B43legacy_MACCMD_BEACON1_VALID)) {
- if (!wl->beacon1_uploaded) {
- b43legacy_write_beacon_template(dev, 0x468,
- B43legacy_SHM_SH_BTL1,
- B43legacy_CCK_RATE_1MB);
- wl->beacon1_uploaded = 1;
- }
- cmd |= B43legacy_MACCMD_BEACON1_VALID;
- }
- b43legacy_write32(dev, B43legacy_MMIO_MACCMD, cmd);
+ b43legacydbg(dev->wl, "Set beacon interval to %u\n", beacon_int);
}
static void handle_irq_ucode_debug(struct b43legacy_wldev *dev)
@@ -1302,7 +1368,7 @@ static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
if (reason & B43legacy_IRQ_TX_OK)
handle_irq_transmit_status(dev);
- b43legacy_interrupt_enable(dev, dev->irq_savedstate);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask);
mmiowb();
spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
}
@@ -1354,18 +1420,18 @@ static irqreturn_t b43legacy_interrupt_handler(int irq, void *dev_id)
struct b43legacy_wldev *dev = dev_id;
u32 reason;
- if (!dev)
- return IRQ_NONE;
+ B43legacy_WARN_ON(!dev);
spin_lock(&dev->wl->irq_lock);
- if (b43legacy_status(dev) < B43legacy_STAT_STARTED)
+ if (unlikely(b43legacy_status(dev) < B43legacy_STAT_STARTED))
+ /* This can only happen on shared IRQ lines. */
goto out;
reason = b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_REASON);
if (reason == 0xffffffff) /* shared IRQ */
goto out;
ret = IRQ_HANDLED;
- reason &= b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_MASK);
+ reason &= dev->irq_mask;
if (!reason)
goto out;
@@ -1389,10 +1455,9 @@ static irqreturn_t b43legacy_interrupt_handler(int irq, void *dev_id)
& 0x0000DC00;
b43legacy_interrupt_ack(dev, reason);
- /* disable all IRQs. They are enabled again in the bottom half. */
- dev->irq_savedstate = b43legacy_interrupt_disable(dev,
- B43legacy_IRQ_ALL);
- /* save the reason code and call our bottom half. */
+ /* Disable all IRQs. They are enabled again in the bottom half. */
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, 0);
+ /* Save the reason code and call our bottom half. */
dev->irq_reason = reason;
tasklet_schedule(&dev->isr_tasklet);
out:
@@ -1852,7 +1917,8 @@ void b43legacy_mac_enable(struct b43legacy_wldev *dev)
/* Re-enable IRQs. */
spin_lock_irq(&dev->wl->irq_lock);
- b43legacy_interrupt_enable(dev, dev->irq_savedstate);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK,
+ dev->irq_mask);
spin_unlock_irq(&dev->wl->irq_lock);
}
}
@@ -1871,10 +1937,9 @@ void b43legacy_mac_suspend(struct b43legacy_wldev *dev)
/* Mask IRQs before suspending MAC. Otherwise
* the MAC stays busy and won't suspend. */
spin_lock_irq(&dev->wl->irq_lock);
- tmp = b43legacy_interrupt_disable(dev, B43legacy_IRQ_ALL);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, 0);
spin_unlock_irq(&dev->wl->irq_lock);
b43legacy_synchronize_irq(dev);
- dev->irq_savedstate = tmp;
b43legacy_power_saving_ctl_bits(dev, -1, 1);
b43legacy_write32(dev, B43legacy_MMIO_MACCTL,
@@ -2297,6 +2362,7 @@ static void b43legacy_security_init(struct b43legacy_wldev *dev)
dev->max_nr_keys - 8);
}
+#ifdef CONFIG_B43LEGACY_HWRNG
static int b43legacy_rng_read(struct hwrng *rng, u32 *data)
{
struct b43legacy_wl *wl = (struct b43legacy_wl *)rng->priv;
@@ -2312,17 +2378,21 @@ static int b43legacy_rng_read(struct hwrng *rng, u32 *data)
return (sizeof(u16));
}
+#endif
static void b43legacy_rng_exit(struct b43legacy_wl *wl)
{
+#ifdef CONFIG_B43LEGACY_HWRNG
if (wl->rng_initialized)
hwrng_unregister(&wl->rng);
+#endif
}
static int b43legacy_rng_init(struct b43legacy_wl *wl)
{
- int err;
+ int err = 0;
+#ifdef CONFIG_B43LEGACY_HWRNG
snprintf(wl->rng_name, ARRAY_SIZE(wl->rng_name),
"%s_%s", KBUILD_MODNAME, wiphy_name(wl->hw->wiphy));
wl->rng.name = wl->rng_name;
@@ -2336,6 +2406,7 @@ static int b43legacy_rng_init(struct b43legacy_wl *wl)
"number generator (%d)\n", err);
}
+#endif
return err;
}
@@ -2557,7 +2628,6 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
int antenna_tx;
int antenna_rx;
int err = 0;
- u32 savedirqs;
antenna_tx = B43legacy_ANTENNA_DEFAULT;
antenna_rx = B43legacy_ANTENNA_DEFAULT;
@@ -2597,7 +2667,7 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
spin_unlock_irqrestore(&wl->irq_lock, flags);
goto out_unlock_mutex;
}
- savedirqs = b43legacy_interrupt_disable(dev, B43legacy_IRQ_ALL);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, 0);
spin_unlock_irqrestore(&wl->irq_lock, flags);
b43legacy_synchronize_irq(dev);
@@ -2619,11 +2689,6 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
/* Antennas for RX and management frame TX. */
b43legacy_mgmtframe_txantenna(dev, antenna_tx);
- /* Update templates for AP mode. */
- if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
- b43legacy_set_beacon_int(dev, conf->beacon_int);
-
-
if (!!conf->radio_enabled != phy->radio_on) {
if (conf->radio_enabled) {
b43legacy_radio_turn_on(dev);
@@ -2641,7 +2706,7 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
}
spin_lock_irqsave(&wl->irq_lock, flags);
- b43legacy_interrupt_enable(dev, savedirqs);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask);
mmiowb();
spin_unlock_irqrestore(&wl->irq_lock, flags);
out_unlock_mutex:
@@ -2704,9 +2769,9 @@ static void b43legacy_op_bss_info_changed(struct ieee80211_hw *hw,
struct b43legacy_wldev *dev;
struct b43legacy_phy *phy;
unsigned long flags;
- u32 savedirqs;
mutex_lock(&wl->mutex);
+ B43legacy_WARN_ON(wl->vif != vif);
dev = wl->current_dev;
phy = &dev->phy;
@@ -2719,12 +2784,35 @@ static void b43legacy_op_bss_info_changed(struct ieee80211_hw *hw,
spin_unlock_irqrestore(&wl->irq_lock, flags);
goto out_unlock_mutex;
}
- savedirqs = b43legacy_interrupt_disable(dev, B43legacy_IRQ_ALL);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, 0);
+
+ if (changed & BSS_CHANGED_BSSID) {
+ b43legacy_synchronize_irq(dev);
+
+ if (conf->bssid)
+ memcpy(wl->bssid, conf->bssid, ETH_ALEN);
+ else
+ memset(wl->bssid, 0, ETH_ALEN);
+ }
+
+ if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) {
+ if (changed & BSS_CHANGED_BEACON &&
+ (b43legacy_is_mode(wl, NL80211_IFTYPE_AP) ||
+ b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)))
+ b43legacy_update_templates(wl);
+
+ if (changed & BSS_CHANGED_BSSID)
+ b43legacy_write_mac_bssid_templates(dev);
+ }
spin_unlock_irqrestore(&wl->irq_lock, flags);
- b43legacy_synchronize_irq(dev);
b43legacy_mac_suspend(dev);
+ if (changed & BSS_CHANGED_BEACON_INT &&
+ (b43legacy_is_mode(wl, NL80211_IFTYPE_AP) ||
+ b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)))
+ b43legacy_set_beacon_int(dev, conf->beacon_int);
+
if (changed & BSS_CHANGED_BASIC_RATES)
b43legacy_update_basic_rates(dev, conf->basic_rates);
@@ -2738,14 +2826,12 @@ static void b43legacy_op_bss_info_changed(struct ieee80211_hw *hw,
b43legacy_mac_enable(dev);
spin_lock_irqsave(&wl->irq_lock, flags);
- b43legacy_interrupt_enable(dev, savedirqs);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask);
/* XXX: why? */
mmiowb();
spin_unlock_irqrestore(&wl->irq_lock, flags);
out_unlock_mutex:
mutex_unlock(&wl->mutex);
-
- return;
}
static void b43legacy_op_configure_filter(struct ieee80211_hw *hw,
@@ -2787,40 +2873,6 @@ static void b43legacy_op_configure_filter(struct ieee80211_hw *hw,
spin_unlock_irqrestore(&wl->irq_lock, flags);
}
-static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
- struct b43legacy_wldev *dev = wl->current_dev;
- unsigned long flags;
-
- if (!dev)
- return -ENODEV;
- mutex_lock(&wl->mutex);
- spin_lock_irqsave(&wl->irq_lock, flags);
- B43legacy_WARN_ON(wl->vif != vif);
- if (conf->bssid)
- memcpy(wl->bssid, conf->bssid, ETH_ALEN);
- else
- memset(wl->bssid, 0, ETH_ALEN);
- if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) {
- if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP)) {
- B43legacy_WARN_ON(vif->type != NL80211_IFTYPE_AP);
- if (conf->changed & IEEE80211_IFCC_BEACON)
- b43legacy_update_templates(wl);
- } else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
- if (conf->changed & IEEE80211_IFCC_BEACON)
- b43legacy_update_templates(wl);
- }
- b43legacy_write_mac_bssid_templates(dev);
- }
- spin_unlock_irqrestore(&wl->irq_lock, flags);
- mutex_unlock(&wl->mutex);
-
- return 0;
-}
-
/* Locking: wl->mutex */
static void b43legacy_wireless_core_stop(struct b43legacy_wldev *dev)
{
@@ -2834,8 +2886,7 @@ static void b43legacy_wireless_core_stop(struct b43legacy_wldev *dev)
* setting the status to INITIALIZED, as the interrupt handler
* won't care about IRQs then. */
spin_lock_irqsave(&wl->irq_lock, flags);
- dev->irq_savedstate = b43legacy_interrupt_disable(dev,
- B43legacy_IRQ_ALL);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, 0);
b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_MASK); /* flush */
spin_unlock_irqrestore(&wl->irq_lock, flags);
b43legacy_synchronize_irq(dev);
@@ -2875,7 +2926,7 @@ static int b43legacy_wireless_core_start(struct b43legacy_wldev *dev)
/* Start data flow (TX/RX) */
b43legacy_mac_enable(dev);
- b43legacy_interrupt_enable(dev, dev->irq_savedstate);
+ b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask);
/* Start maintenance work */
b43legacy_periodic_tasks_setup(dev);
@@ -3038,7 +3089,7 @@ static void setup_struct_wldev_for_init(struct b43legacy_wldev *dev)
/* IRQ related flags */
dev->irq_reason = 0;
memset(dev->dma_reason, 0, sizeof(dev->dma_reason));
- dev->irq_savedstate = B43legacy_IRQ_MASKTEMPLATE;
+ dev->irq_mask = B43legacy_IRQ_MASKTEMPLATE;
dev->mac_suspended = 1;
@@ -3392,6 +3443,9 @@ static int b43legacy_op_start(struct ieee80211_hw *hw)
memset(wl->bssid, 0, ETH_ALEN);
memset(wl->mac_addr, 0, ETH_ALEN);
wl->filter_flags = 0;
+ wl->beacon0_uploaded = 0;
+ wl->beacon1_uploaded = 0;
+ wl->beacon_templates_virgin = 1;
mutex_lock(&wl->mutex);
@@ -3429,6 +3483,7 @@ static void b43legacy_op_stop(struct ieee80211_hw *hw)
struct b43legacy_wldev *dev = wl->current_dev;
b43legacy_rfkill_exit(dev);
+ cancel_work_sync(&(wl->beacon_update_trigger));
mutex_lock(&wl->mutex);
if (b43legacy_status(dev) >= B43legacy_STAT_STARTED)
@@ -3457,7 +3512,6 @@ static const struct ieee80211_ops b43legacy_hw_ops = {
.remove_interface = b43legacy_op_remove_interface,
.config = b43legacy_op_dev_config,
.bss_info_changed = b43legacy_op_bss_info_changed,
- .config_interface = b43legacy_op_config_interface,
.configure_filter = b43legacy_op_configure_filter,
.get_stats = b43legacy_op_get_stats,
.get_tx_stats = b43legacy_op_get_tx_stats,
@@ -3760,6 +3814,7 @@ static int b43legacy_wireless_init(struct ssb_device *dev)
spin_lock_init(&wl->leds_lock);
mutex_init(&wl->mutex);
INIT_LIST_HEAD(&wl->devlist);
+ INIT_WORK(&wl->beacon_update_trigger, b43legacy_beacon_update_trigger_work);
ssb_set_devtypedata(dev, wl);
b43legacyinfo(wl, "Broadcom %04X WLAN found\n", dev->bus->chip_id);
diff --git a/drivers/net/wireless/b43legacy/pio.c b/drivers/net/wireless/b43legacy/pio.c
index 746d5361bba0..51866c9a2769 100644
--- a/drivers/net/wireless/b43legacy/pio.c
+++ b/drivers/net/wireless/b43legacy/pio.c
@@ -443,7 +443,7 @@ int b43legacy_pio_init(struct b43legacy_wldev *dev)
pio->queue3 = queue;
if (dev->dev->id.revision < 3)
- dev->irq_savedstate |= B43legacy_IRQ_PIO_WORKAROUND;
+ dev->irq_mask |= B43legacy_IRQ_PIO_WORKAROUND;
b43legacydbg(dev->wl, "PIO initialized\n");
err = 0;
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c
index 12fca99f7578..b8e39dd06e99 100644
--- a/drivers/net/wireless/b43legacy/xmit.c
+++ b/drivers/net/wireless/b43legacy/xmit.c
@@ -274,7 +274,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
/* PHY TX Control word */
if (rate_ofdm)
- phy_ctl |= B43legacy_TX4_PHY_OFDM;
+ phy_ctl |= B43legacy_TX4_PHY_ENC_OFDM;
if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
phy_ctl |= B43legacy_TX4_PHY_SHORTPRMBL;
switch (info->antenna_sel_tx) {
diff --git a/drivers/net/wireless/b43legacy/xmit.h b/drivers/net/wireless/b43legacy/xmit.h
index 62e09d02788f..91633087a20b 100644
--- a/drivers/net/wireless/b43legacy/xmit.h
+++ b/drivers/net/wireless/b43legacy/xmit.h
@@ -67,7 +67,9 @@ struct b43legacy_txhdr_fw3 {
#define B43legacy_TX4_EFT_RTSFBOFDM 0x0010 /* RTS/CTS fallback rate type */
/* PHY TX control word */
-#define B43legacy_TX4_PHY_OFDM 0x0001 /* Data frame rate type */
+#define B43legacy_TX4_PHY_ENC 0x0003 /* Data frame encoding */
+#define B43legacy_TX4_PHY_ENC_CCK 0x0000 /* CCK */
+#define B43legacy_TX4_PHY_ENC_OFDM 0x0001 /* Data frame rate type */
#define B43legacy_TX4_PHY_SHORTPRMBL 0x0010 /* Use short preamble */
#define B43legacy_TX4_PHY_ANT 0x03C0 /* Antenna selection */
#define B43legacy_TX4_PHY_ANT0 0x0000 /* Use antenna 0 */
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 3dad1cf8f241..ff9b5c882184 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -1423,7 +1423,7 @@ static int prism2_hw_init2(struct net_device *dev, int initial)
prism2_check_sta_fw_version(local);
if (hfa384x_get_rid(dev, HFA384X_RID_CNFOWNMACADDR,
- &dev->dev_addr, 6, 1) < 0) {
+ dev->dev_addr, 6, 1) < 0) {
printk("%s: could not get own MAC address\n",
dev->name);
}
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index cbf15d703201..0e5d51086a44 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -435,7 +435,7 @@ static int prism2_plx_probe(struct pci_dev *pdev,
unsigned long pccard_attr_mem;
unsigned int pccard_attr_len;
void __iomem *attr_mem = NULL;
- unsigned int cor_offset, cor_index;
+ unsigned int cor_offset = 0, cor_index = 0;
u32 reg;
local_info_t *local = NULL;
struct net_device *dev = NULL;
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index 97e5647ff050..742432388ca3 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -3488,7 +3488,7 @@ static DEVICE_ATTR(pci, S_IRUGO, show_pci, NULL);
static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
char *buf)
{
- struct ipw2100_priv *p = d->driver_data;
+ struct ipw2100_priv *p = dev_get_drvdata(d);
return sprintf(buf, "0x%08x\n", (int)p->config);
}
@@ -3497,7 +3497,7 @@ static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);
static ssize_t show_status(struct device *d, struct device_attribute *attr,
char *buf)
{
- struct ipw2100_priv *p = d->driver_data;
+ struct ipw2100_priv *p = dev_get_drvdata(d);
return sprintf(buf, "0x%08x\n", (int)p->status);
}
@@ -3506,7 +3506,7 @@ static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
static ssize_t show_capability(struct device *d, struct device_attribute *attr,
char *buf)
{
- struct ipw2100_priv *p = d->driver_data;
+ struct ipw2100_priv *p = dev_get_drvdata(d);
return sprintf(buf, "0x%08x\n", (int)p->capability);
}
@@ -4224,7 +4224,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
1 - SW based RF kill active (sysfs)
2 - HW based RF kill active
3 - Both HW and SW baed RF kill active */
- struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data;
+ struct ipw2100_priv *priv = dev_get_drvdata(d);
int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
(rf_kill_active(priv) ? 0x2 : 0x0);
return sprintf(buf, "%i\n", val);
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index bd4dbcfe1bbe..c3b3dfe43d1a 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -1527,7 +1527,7 @@ static DEVICE_ATTR(led, S_IWUSR | S_IRUGO, show_led, store_led);
static ssize_t show_status(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
return sprintf(buf, "0x%08x\n", (int)p->status);
}
@@ -1536,7 +1536,7 @@ static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
char *buf)
{
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
return sprintf(buf, "0x%08x\n", (int)p->config);
}
@@ -1545,7 +1545,7 @@ static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);
static ssize_t show_nic_type(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "TYPE: %d\n", priv->nic_type);
}
@@ -1555,7 +1555,7 @@ static ssize_t show_ucode_version(struct device *d,
struct device_attribute *attr, char *buf)
{
u32 len = sizeof(u32), tmp = 0;
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
if (ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len))
return 0;
@@ -1569,7 +1569,7 @@ static ssize_t show_rtc(struct device *d, struct device_attribute *attr,
char *buf)
{
u32 len = sizeof(u32), tmp = 0;
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
if (ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len))
return 0;
@@ -1586,14 +1586,15 @@ static DEVICE_ATTR(rtc, S_IWUSR | S_IRUGO, show_rtc, NULL);
static ssize_t show_eeprom_delay(struct device *d,
struct device_attribute *attr, char *buf)
{
- int n = ((struct ipw_priv *)d->driver_data)->eeprom_delay;
+ struct ipw_priv *p = dev_get_drvdata(d);
+ int n = p->eeprom_delay;
return sprintf(buf, "%i\n", n);
}
static ssize_t store_eeprom_delay(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
sscanf(buf, "%i", &p->eeprom_delay);
return strnlen(buf, count);
}
@@ -1605,7 +1606,7 @@ static ssize_t show_command_event_reg(struct device *d,
struct device_attribute *attr, char *buf)
{
u32 reg = 0;
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
reg = ipw_read_reg32(p, IPW_INTERNAL_CMD_EVENT);
return sprintf(buf, "0x%08x\n", reg);
@@ -1615,7 +1616,7 @@ static ssize_t store_command_event_reg(struct device *d,
const char *buf, size_t count)
{
u32 reg;
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
sscanf(buf, "%x", &reg);
ipw_write_reg32(p, IPW_INTERNAL_CMD_EVENT, reg);
@@ -1629,7 +1630,7 @@ static ssize_t show_mem_gpio_reg(struct device *d,
struct device_attribute *attr, char *buf)
{
u32 reg = 0;
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
reg = ipw_read_reg32(p, 0x301100);
return sprintf(buf, "0x%08x\n", reg);
@@ -1639,7 +1640,7 @@ static ssize_t store_mem_gpio_reg(struct device *d,
const char *buf, size_t count)
{
u32 reg;
- struct ipw_priv *p = d->driver_data;
+ struct ipw_priv *p = dev_get_drvdata(d);
sscanf(buf, "%x", &reg);
ipw_write_reg32(p, 0x301100, reg);
@@ -1653,7 +1654,7 @@ static ssize_t show_indirect_dword(struct device *d,
struct device_attribute *attr, char *buf)
{
u32 reg = 0;
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
if (priv->status & STATUS_INDIRECT_DWORD)
reg = ipw_read_reg32(priv, priv->indirect_dword);
@@ -1666,7 +1667,7 @@ static ssize_t store_indirect_dword(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
sscanf(buf, "%x", &priv->indirect_dword);
priv->status |= STATUS_INDIRECT_DWORD;
@@ -1680,7 +1681,7 @@ static ssize_t show_indirect_byte(struct device *d,
struct device_attribute *attr, char *buf)
{
u8 reg = 0;
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
if (priv->status & STATUS_INDIRECT_BYTE)
reg = ipw_read_reg8(priv, priv->indirect_byte);
@@ -1693,7 +1694,7 @@ static ssize_t store_indirect_byte(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
sscanf(buf, "%x", &priv->indirect_byte);
priv->status |= STATUS_INDIRECT_BYTE;
@@ -1707,7 +1708,7 @@ static ssize_t show_direct_dword(struct device *d,
struct device_attribute *attr, char *buf)
{
u32 reg = 0;
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
if (priv->status & STATUS_DIRECT_DWORD)
reg = ipw_read32(priv, priv->direct_dword);
@@ -1720,7 +1721,7 @@ static ssize_t store_direct_dword(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
sscanf(buf, "%x", &priv->direct_dword);
priv->status |= STATUS_DIRECT_DWORD;
@@ -1747,7 +1748,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
1 - SW based RF kill active (sysfs)
2 - HW based RF kill active
3 - Both HW and SW baed RF kill active */
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
(rf_kill_active(priv) ? 0x2 : 0x0);
return sprintf(buf, "%i\n", val);
@@ -1791,7 +1792,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio)
static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *priv = d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
ipw_radio_kill_sw(priv, buf[0] == '1');
@@ -1803,7 +1804,7 @@ static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill);
static ssize_t show_speed_scan(struct device *d, struct device_attribute *attr,
char *buf)
{
- struct ipw_priv *priv = (struct ipw_priv *)d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
int pos = 0, len = 0;
if (priv->config & CFG_SPEED_SCAN) {
while (priv->speed_scan[pos] != 0)
@@ -1818,7 +1819,7 @@ static ssize_t show_speed_scan(struct device *d, struct device_attribute *attr,
static ssize_t store_speed_scan(struct device *d, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *priv = (struct ipw_priv *)d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
int channel, pos = 0;
const char *p = buf;
@@ -1857,14 +1858,14 @@ static DEVICE_ATTR(speed_scan, S_IWUSR | S_IRUGO, show_speed_scan,
static ssize_t show_net_stats(struct device *d, struct device_attribute *attr,
char *buf)
{
- struct ipw_priv *priv = (struct ipw_priv *)d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "%c\n", (priv->config & CFG_NET_STATS) ? '1' : '0');
}
static ssize_t store_net_stats(struct device *d, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct ipw_priv *priv = (struct ipw_priv *)d->driver_data;
+ struct ipw_priv *priv = dev_get_drvdata(d);
if (buf[0] == '1')
priv->config |= CFG_NET_STATS;
else
@@ -3176,11 +3177,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
/* Start the Dma */
rc = ipw_fw_dma_enable(priv);
- if (priv->sram_desc.last_cb_index > 0) {
- /* the DMA is already ready this would be a bug. */
- BUG();
- goto out;
- }
+ /* the DMA is already ready this would be a bug. */
+ BUG_ON(priv->sram_desc.last_cb_index > 0);
do {
chunk = (struct fw_chunk *)(data + offset);
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index 92a26922e792..8ce6e961c5da 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -154,10 +154,6 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
goto failed;
}
ieee = netdev_priv(dev);
-#ifdef CONFIG_COMPAT_NET_DEV_OPS
- dev->hard_start_xmit = ieee80211_xmit;
- dev->change_mtu = ieee80211_change_mtu;
-#endif
ieee->dev = dev;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
index ac22f59be9ef..bd7e520d98c2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
@@ -44,6 +44,15 @@
#include "iwl-core.h"
#include "iwl-dev.h"
+#ifdef CONFIG_IWLWIFI_DEBUG
+static const char *led_type_str[] = {
+ __stringify(IWL_LED_TRG_TX),
+ __stringify(IWL_LED_TRG_RX),
+ __stringify(IWL_LED_TRG_ASSOC),
+ __stringify(IWL_LED_TRG_RADIO),
+ NULL
+};
+#endif /* CONFIG_IWLWIFI_DEBUG */
static const struct {
u16 brightness;
@@ -61,7 +70,7 @@ static const struct {
{10, 110, 110},
{5, 130, 130},
{0, 167, 167},
- /*SOLID_ON*/
+ /* SOLID_ON */
{-1, IWL_LED_SOLID, 0}
};
@@ -143,6 +152,30 @@ static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
}
/*
+ * Set led on in case of association
+ * */
+static int iwl3945_led_associate(struct iwl_priv *priv, int led_id)
+{
+ IWL_DEBUG_LED(priv, "Associated\n");
+
+ priv->allow_blinking = 1;
+ return iwl3945_led_on(priv, led_id);
+}
+/* Set Led off in case of disassociation */
+static int iwl3945_led_disassociate(struct iwl_priv *priv, int led_id)
+{
+ IWL_DEBUG_LED(priv, "Disassociated\n");
+
+ priv->allow_blinking = 0;
+ if (iwl_is_rfkill(priv))
+ iwl3945_led_off(priv, led_id);
+ else
+ iwl3945_led_on(priv, led_id);
+
+ return 0;
+}
+
+/*
* brightness call back function for Tx/Rx LED
*/
static int iwl3945_led_associated(struct iwl_priv *priv, int led_id)
@@ -165,26 +198,21 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct iwl_led *led = container_of(led_cdev,
- struct iwl_led, led_dev);
+ struct iwl_led, led_dev);
struct iwl_priv *priv = led->priv;
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return;
+ IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
+ led_type_str[led->type], brightness);
+
switch (brightness) {
case LED_FULL:
- if (led->type == IWL_LED_TRG_ASSOC) {
- priv->allow_blinking = 1;
- IWL_DEBUG_LED(priv, "MAC is associated\n");
- }
if (led->led_on)
led->led_on(priv, IWL_LED_LINK);
break;
case LED_OFF:
- if (led->type == IWL_LED_TRG_ASSOC) {
- priv->allow_blinking = 0;
- IWL_DEBUG_LED(priv, "MAC is disassociated\n");
- }
if (led->led_off)
led->led_off(priv, IWL_LED_LINK);
break;
@@ -197,8 +225,6 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
}
}
-
-
/*
* Register led class with the system
*/
@@ -237,12 +263,12 @@ static int iwl3945_led_register_led(struct iwl_priv *priv,
static inline u8 get_blink_rate(struct iwl_priv *priv)
{
int index;
- u64 current_tpt = priv->rxtxpackets;
- s64 tpt = current_tpt - priv->led_tpt;
+ s64 tpt = priv->rxtxpackets;
if (tpt < 0)
tpt = -tpt;
- priv->led_tpt = current_tpt;
+
+ IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt);
if (!priv->allow_blinking)
index = IWL_MAX_BLINK_TBL;
@@ -250,13 +276,9 @@ static inline u8 get_blink_rate(struct iwl_priv *priv)
for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
break;
- return index;
-}
-static inline int is_rf_kill(struct iwl_priv *priv)
-{
- return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
- test_bit(STATUS_RF_KILL_SW, &priv->status);
+ IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index);
+ return index;
}
/*
@@ -272,7 +294,7 @@ void iwl3945_led_background(struct iwl_priv *priv)
priv->last_blink_time = 0;
return;
}
- if (is_rf_kill(priv)) {
+ if (iwl_is_rfkill(priv)) {
priv->last_blink_time = 0;
return;
}
@@ -341,8 +363,8 @@ int iwl3945_led_register(struct iwl_priv *priv)
IWL_LED_TRG_ASSOC, 0, trigger);
/* for assoc always turn led on */
- priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on;
- priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on;
+ priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate;
+ priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate;
priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
if (ret)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index af6b9d444778..814afaf6d10b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -683,11 +683,10 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
if (sta)
rate_mask = sta->supp_rates[sband->band];
- /* Send management frames and broadcast/multicast data using lowest
- * rate. */
+ /* Send management frames and NO_ACK data using lowest rate. */
fc = le16_to_cpu(hdr->frame_control);
if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
- is_multicast_ether_addr(hdr->addr1) ||
+ info->flags & IEEE80211_TX_CTL_NO_ACK ||
!sta || !priv_sta) {
IWL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n");
if (!rate_mask)
@@ -696,6 +695,8 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
else
info->control.rates[0].idx =
rate_lowest_index(sband, sta);
+ if (info->flags & IEEE80211_TX_CTL_NO_ACK)
+ info->control.rates[0].count = 1;
return;
}
@@ -719,7 +720,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
IWL_DEBUG_RATE(priv, "LQ: ADD station %pm\n",
hdr->addr1);
sta_id = iwl3945_add_station(priv,
- hdr->addr1, 0, CMD_ASYNC);
+ hdr->addr1, 0, CMD_ASYNC, NULL);
}
if (sta_id != IWL_INVALID_STATION)
rs_sta->ibss_sta_added = 1;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 527525cc0919..fd65e1c3e055 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -98,7 +98,6 @@ const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945] = {
* ... and set IWL_EVT_DISABLE to 1. */
void iwl3945_disable_events(struct iwl_priv *priv)
{
- int ret;
int i;
u32 base; /* SRAM address of event log header */
u32 disable_ptr; /* SRAM address of event-disable bitmap array */
@@ -159,26 +158,17 @@ void iwl3945_disable_events(struct iwl_priv *priv)
return;
}
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- IWL_WARN(priv, "Can not read from adapter at this time.\n");
- return;
- }
-
disable_ptr = iwl_read_targ_mem(priv, base + (4 * sizeof(u32)));
array_size = iwl_read_targ_mem(priv, base + (5 * sizeof(u32)));
- iwl_release_nic_access(priv);
if (IWL_EVT_DISABLE && (array_size == IWL_EVT_DISABLE_SIZE)) {
IWL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n",
disable_ptr);
- ret = iwl_grab_nic_access(priv);
for (i = 0; i < IWL_EVT_DISABLE_SIZE; i++)
iwl_write_targ_mem(priv,
disable_ptr + (i * sizeof(u32)),
evt_disable[i]);
- iwl_release_nic_access(priv);
} else {
IWL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n");
IWL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n");
@@ -908,55 +898,30 @@ u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate, u8 flags)
static int iwl3945_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src)
{
- int ret;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
-
if (src == IWL_PWR_SRC_VAUX) {
if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) {
iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
APMG_PS_CTRL_VAL_PWR_SRC_VAUX,
~APMG_PS_CTRL_MSK_PWR_SRC);
- iwl_release_nic_access(priv);
iwl_poll_bit(priv, CSR_GPIO_IN,
CSR_GPIO_IN_VAL_VAUX_PWR_SRC,
CSR_GPIO_IN_BIT_AUX_POWER, 5000);
- } else {
- iwl_release_nic_access(priv);
}
} else {
iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
APMG_PS_CTRL_VAL_PWR_SRC_VMAIN,
~APMG_PS_CTRL_MSK_PWR_SRC);
- iwl_release_nic_access(priv);
iwl_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC,
CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */
}
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
+ return 0;
}
static int iwl3945_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
{
- int rc;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
- }
-
iwl_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->dma_addr);
iwl_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma);
iwl_write_direct32(priv, FH39_RCSR_WPTR(0), 0);
@@ -973,23 +938,11 @@ static int iwl3945_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
/* fake read to flush all prev I/O */
iwl_read_direct32(priv, FH39_RSSR_CTRL);
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
-
return 0;
}
static int iwl3945_tx_reset(struct iwl_priv *priv)
{
- int rc;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
- }
/* bypass mode */
iwl_write_prph(priv, ALM_SCD_MODE_REG, 0x2);
@@ -1017,8 +970,6 @@ static int iwl3945_tx_reset(struct iwl_priv *priv)
FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH |
FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH);
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
@@ -1061,7 +1012,7 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv)
static int iwl3945_apm_init(struct iwl_priv *priv)
{
- int ret = 0;
+ int ret;
iwl_power_initialize(priv);
@@ -1083,10 +1034,6 @@ static int iwl3945_apm_init(struct iwl_priv *priv)
goto out;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- goto out;
-
/* enable DMA */
iwl_write_prph(priv, APMG_CLK_CTRL_REG, APMG_CLK_VAL_DMA_CLK_RQT |
APMG_CLK_VAL_BSM_CLK_RQT);
@@ -1097,7 +1044,6 @@ static int iwl3945_apm_init(struct iwl_priv *priv)
iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
- iwl_release_nic_access(priv);
out:
return ret;
}
@@ -1110,6 +1056,11 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
spin_lock_irqsave(&priv->lock, flags);
+ /* Determine HW type */
+ pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id);
+
+ IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id);
+
if (rev_id & PCI_CFG_REV_ID_BIT_RTP)
IWL_DEBUG_INFO(priv, "RTP type \n");
else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) {
@@ -1163,7 +1114,6 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
int iwl3945_hw_nic_init(struct iwl_priv *priv)
{
- u8 rev_id;
int rc;
unsigned long flags;
struct iwl_rx_queue *rxq = &priv->rxq;
@@ -1172,12 +1122,6 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv)
priv->cfg->ops->lib->apm_ops.init(priv);
spin_unlock_irqrestore(&priv->lock, flags);
- /* Determine HW type */
- rc = pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id);
- if (rc)
- return rc;
- IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id);
-
rc = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN);
if (rc)
return rc;
@@ -1198,22 +1142,13 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv)
iwl3945_rx_init(priv, rxq);
- spin_lock_irqsave(&priv->lock, flags);
/* Look at using this instead:
rxq->need_update = 1;
iwl_rx_queue_update_write_ptr(priv, rxq);
*/
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
- }
iwl_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7);
- iwl_release_nic_access(priv);
-
- spin_unlock_irqrestore(&priv->lock, flags);
rc = iwl3945_txq_ctx_reset(priv);
if (rc)
@@ -1245,14 +1180,6 @@ void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv)
void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv)
{
int txq_id;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- if (iwl_grab_nic_access(priv)) {
- spin_unlock_irqrestore(&priv->lock, flags);
- iwl3945_hw_txq_ctx_free(priv);
- return;
- }
/* stop SCD */
iwl_write_prph(priv, ALM_SCD_MODE_REG, 0);
@@ -1265,9 +1192,6 @@ void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv)
1000);
}
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
-
iwl3945_hw_txq_ctx_free(priv);
}
@@ -1312,12 +1236,8 @@ static void iwl3945_apm_stop(struct iwl_priv *priv)
static int iwl3945_apm_reset(struct iwl_priv *priv)
{
- int rc;
- unsigned long flags;
-
iwl3945_apm_stop_master(priv);
- spin_lock_irqsave(&priv->lock, flags);
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
udelay(10);
@@ -1327,36 +1247,31 @@ static int iwl3945_apm_reset(struct iwl_priv *priv)
iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
- rc = iwl_grab_nic_access(priv);
- if (!rc) {
- iwl_write_prph(priv, APMG_CLK_CTRL_REG,
- APMG_CLK_VAL_BSM_CLK_RQT);
+ iwl_write_prph(priv, APMG_CLK_CTRL_REG,
+ APMG_CLK_VAL_BSM_CLK_RQT);
- iwl_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0);
- iwl_write_prph(priv, APMG_RTC_INT_STT_REG,
+ iwl_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0);
+ iwl_write_prph(priv, APMG_RTC_INT_STT_REG,
0xFFFFFFFF);
- /* enable DMA */
- iwl_write_prph(priv, APMG_CLK_EN_REG,
- APMG_CLK_VAL_DMA_CLK_RQT |
- APMG_CLK_VAL_BSM_CLK_RQT);
- udelay(10);
+ /* enable DMA */
+ iwl_write_prph(priv, APMG_CLK_EN_REG,
+ APMG_CLK_VAL_DMA_CLK_RQT |
+ APMG_CLK_VAL_BSM_CLK_RQT);
+ udelay(10);
- iwl_set_bits_prph(priv, APMG_PS_CTRL_REG,
+ iwl_set_bits_prph(priv, APMG_PS_CTRL_REG,
APMG_PS_CTRL_VAL_RESET_REQ);
- udelay(5);
- iwl_clear_bits_prph(priv, APMG_PS_CTRL_REG,
+ udelay(5);
+ iwl_clear_bits_prph(priv, APMG_PS_CTRL_REG,
APMG_PS_CTRL_VAL_RESET_REQ);
- iwl_release_nic_access(priv);
- }
/* Clear the 'host command active' bit... */
clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
wake_up_interruptible(&priv->wait_command_queue);
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
+ return 0;
}
/**
@@ -1964,6 +1879,194 @@ int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power)
return 0;
}
+static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
+{
+ int rc = 0;
+ struct iwl_rx_packet *res = NULL;
+ struct iwl3945_rxon_assoc_cmd rxon_assoc;
+ struct iwl_host_cmd cmd = {
+ .id = REPLY_RXON_ASSOC,
+ .len = sizeof(rxon_assoc),
+ .meta.flags = CMD_WANT_SKB,
+ .data = &rxon_assoc,
+ };
+ const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
+ const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
+
+ if ((rxon1->flags == rxon2->flags) &&
+ (rxon1->filter_flags == rxon2->filter_flags) &&
+ (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
+ (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
+ IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
+ return 0;
+ }
+
+ rxon_assoc.flags = priv->staging_rxon.flags;
+ rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
+ rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
+ rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
+ rxon_assoc.reserved = 0;
+
+ rc = iwl_send_cmd_sync(priv, &cmd);
+ if (rc)
+ return rc;
+
+ res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
+ if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
+ IWL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n");
+ rc = -EIO;
+ }
+
+ priv->alloc_rxb_skb--;
+ dev_kfree_skb_any(cmd.meta.u.skb);
+
+ return rc;
+}
+
+/**
+ * iwl3945_commit_rxon - commit staging_rxon to hardware
+ *
+ * The RXON command in staging_rxon is committed to the hardware and
+ * the active_rxon structure is updated with the new data. This
+ * function correctly transitions out of the RXON_ASSOC_MSK state if
+ * a HW tune is required based on the RXON structure changes.
+ */
+static int iwl3945_commit_rxon(struct iwl_priv *priv)
+{
+ /* cast away the const for active_rxon in this function */
+ struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
+ struct iwl3945_rxon_cmd *staging_rxon = (void *)&priv->staging_rxon;
+ int rc = 0;
+ bool new_assoc =
+ !!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK);
+
+ if (!iwl_is_alive(priv))
+ return -1;
+
+ /* always get timestamp with Rx frame */
+ staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK;
+
+ /* select antenna */
+ staging_rxon->flags &=
+ ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
+ staging_rxon->flags |= iwl3945_get_antenna_flags(priv);
+
+ rc = iwl_check_rxon_cmd(priv);
+ if (rc) {
+ IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
+ return -EINVAL;
+ }
+
+ /* If we don't need to send a full RXON, we can use
+ * iwl3945_rxon_assoc_cmd which is used to reconfigure filter
+ * and other flags for the current radio configuration. */
+ if (!iwl_full_rxon_required(priv)) {
+ rc = iwl_send_rxon_assoc(priv);
+ if (rc) {
+ IWL_ERR(priv, "Error setting RXON_ASSOC "
+ "configuration (%d).\n", rc);
+ return rc;
+ }
+
+ memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
+
+ return 0;
+ }
+
+ /* If we are currently associated and the new config requires
+ * an RXON_ASSOC and the new config wants the associated mask enabled,
+ * we must clear the associated from the active configuration
+ * before we apply the new config */
+ if (iwl_is_associated(priv) && new_assoc) {
+ IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n");
+ active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
+
+ /*
+ * reserved4 and 5 could have been filled by the iwlcore code.
+ * Let's clear them before pushing to the 3945.
+ */
+ active_rxon->reserved4 = 0;
+ active_rxon->reserved5 = 0;
+ rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
+ sizeof(struct iwl3945_rxon_cmd),
+ &priv->active_rxon);
+
+ /* If the mask clearing failed then we set
+ * active_rxon back to what it was previously */
+ if (rc) {
+ active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK;
+ IWL_ERR(priv, "Error clearing ASSOC_MSK on current "
+ "configuration (%d).\n", rc);
+ return rc;
+ }
+ }
+
+ IWL_DEBUG_INFO(priv, "Sending RXON\n"
+ "* with%s RXON_FILTER_ASSOC_MSK\n"
+ "* channel = %d\n"
+ "* bssid = %pM\n",
+ (new_assoc ? "" : "out"),
+ le16_to_cpu(staging_rxon->channel),
+ staging_rxon->bssid_addr);
+
+ /*
+ * reserved4 and 5 could have been filled by the iwlcore code.
+ * Let's clear them before pushing to the 3945.
+ */
+ staging_rxon->reserved4 = 0;
+ staging_rxon->reserved5 = 0;
+
+ iwl_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto);
+
+ /* Apply the new configuration */
+ rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
+ sizeof(struct iwl3945_rxon_cmd),
+ staging_rxon);
+ if (rc) {
+ IWL_ERR(priv, "Error setting new configuration (%d).\n", rc);
+ return rc;
+ }
+
+ memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
+
+ priv->cfg->ops->smgmt->clear_station_table(priv);
+
+ /* If we issue a new RXON command which required a tune then we must
+ * send a new TXPOWER command or we won't be able to Tx any frames */
+ rc = priv->cfg->ops->lib->send_tx_power(priv);
+ if (rc) {
+ IWL_ERR(priv, "Error setting Tx power (%d).\n", rc);
+ return rc;
+ }
+
+ /* Add the broadcast address so we can send broadcast frames */
+ if (priv->cfg->ops->smgmt->add_station(priv, iwl_bcast_addr, 0, 0, NULL) ==
+ IWL_INVALID_STATION) {
+ IWL_ERR(priv, "Error adding BROADCAST address for transmit.\n");
+ return -EIO;
+ }
+
+ /* If we have set the ASSOC_MSK and we are in BSS mode then
+ * add the IWL_AP_ID to the station rate table */
+ if (iwl_is_associated(priv) &&
+ (priv->iw_mode == NL80211_IFTYPE_STATION))
+ if (priv->cfg->ops->smgmt->add_station(priv,
+ priv->active_rxon.bssid_addr, 1, 0, NULL)
+ == IWL_INVALID_STATION) {
+ IWL_ERR(priv, "Error adding AP address for transmit\n");
+ return -EIO;
+ }
+
+ /* Init the hardware's rate fallback order based on the band */
+ rc = iwl3945_init_hw_rate_table(priv);
+ if (rc) {
+ IWL_ERR(priv, "Error setting HW rate table: %02X\n", rc);
+ return -EIO;
+ }
+
+ return 0;
+}
+
/* will add 3945 channel switch cmd handling later */
int iwl3945_hw_channel_switch(struct iwl_priv *priv, u16 channel)
{
@@ -2314,14 +2417,6 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv)
int iwl3945_hw_rxq_stop(struct iwl_priv *priv)
{
int rc;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
- }
iwl_write_direct32(priv, FH39_RCSR_CONFIG(0), 0);
rc = iwl_poll_direct_bit(priv, FH39_RSSR_STATUS,
@@ -2329,28 +2424,17 @@ int iwl3945_hw_rxq_stop(struct iwl_priv *priv)
if (rc < 0)
IWL_ERR(priv, "Can't stop Rx DMA.\n");
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
-
return 0;
}
int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq)
{
- int rc;
- unsigned long flags;
int txq_id = txq->q.id;
struct iwl3945_shared *shared_data = priv->shared_virt;
shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr);
- spin_lock_irqsave(&priv->lock, flags);
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
- }
iwl_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0);
iwl_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0);
@@ -2360,11 +2444,9 @@ int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq)
FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD |
FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL |
FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE);
- iwl_release_nic_access(priv);
/* fake read to flush all prev. writes */
iwl_read32(priv, FH39_TSSR_CBB_BASE);
- spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
@@ -2672,10 +2754,6 @@ static int iwl3945_load_bsm(struct iwl_priv *priv)
inst_len = priv->ucode_init.len;
data_len = priv->ucode_init_data.len;
- rc = iwl_grab_nic_access(priv);
- if (rc)
- return rc;
-
iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst);
iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata);
iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len);
@@ -2689,10 +2767,8 @@ static int iwl3945_load_bsm(struct iwl_priv *priv)
le32_to_cpu(*image));
rc = iwl3945_verify_bsm(priv);
- if (rc) {
- iwl_release_nic_access(priv);
+ if (rc)
return rc;
- }
/* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */
iwl_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0);
@@ -2724,11 +2800,14 @@ static int iwl3945_load_bsm(struct iwl_priv *priv)
iwl_write_prph(priv, BSM_WR_CTRL_REG,
BSM_WR_CTRL_REG_BIT_START_EN);
- iwl_release_nic_access(priv);
-
return 0;
}
+static struct iwl_hcmd_ops iwl3945_hcmd = {
+ .rxon_assoc = iwl3945_send_rxon_assoc,
+ .commit_rxon = iwl3945_commit_rxon,
+};
+
static struct iwl_lib_ops iwl3945_lib = {
.txq_attach_buf_to_tfd = iwl3945_hw_txq_attach_buf_to_tfd,
.txq_free_tfd = iwl3945_hw_txq_free_tfd,
@@ -2758,6 +2837,18 @@ static struct iwl_lib_ops iwl3945_lib = {
},
.send_tx_power = iwl3945_send_tx_power,
.is_valid_rtc_data_addr = iwl3945_hw_valid_rtc_data_addr,
+ .post_associate = iwl3945_post_associate,
+ .isr = iwl_isr_legacy,
+ .config_ap = iwl3945_config_ap,
+};
+
+static struct iwl_station_mgmt_ops iwl3945_station_mgmt = {
+ .add_station = iwl3945_add_station,
+#if 0
+ .remove_station = iwl3945_remove_station,
+#endif
+ .find_station = iwl3945_hw_find_station,
+ .clear_station_table = iwl3945_clear_stations_table,
};
static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
@@ -2767,7 +2858,9 @@ static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
static struct iwl_ops iwl3945_ops = {
.lib = &iwl3945_lib,
+ .hcmd = &iwl3945_hcmd,
.utils = &iwl3945_hcmd_utils,
+ .smgmt = &iwl3945_station_mgmt,
};
static struct iwl_cfg iwl3945_bg_cfg = {
@@ -2779,7 +2872,8 @@ static struct iwl_cfg iwl3945_bg_cfg = {
.eeprom_size = IWL3945_EEPROM_IMG_SIZE,
.eeprom_ver = EEPROM_3945_EEPROM_VERSION,
.ops = &iwl3945_ops,
- .mod_params = &iwl3945_mod_params
+ .mod_params = &iwl3945_mod_params,
+ .use_isr_legacy = true
};
static struct iwl_cfg iwl3945_abg_cfg = {
@@ -2791,7 +2885,8 @@ static struct iwl_cfg iwl3945_abg_cfg = {
.eeprom_size = IWL3945_EEPROM_IMG_SIZE,
.eeprom_ver = EEPROM_3945_EEPROM_VERSION,
.ops = &iwl3945_ops,
- .mod_params = &iwl3945_mod_params
+ .mod_params = &iwl3945_mod_params,
+ .use_isr_legacy = true
};
struct pci_device_id iwl3945_hw_card_ids[] = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 55188844657b..da87528f355f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -162,7 +162,6 @@ struct iwl3945_frame {
#define STATUS_TEMPERATURE 8
#define STATUS_GEO_CONFIGURED 9
#define STATUS_EXIT_PENDING 10
-#define STATUS_IN_SUSPEND 11
#define STATUS_STATISTICS 12
#define STATUS_SCANNING 13
#define STATUS_SCAN_ABORTING 14
@@ -207,7 +206,8 @@ struct iwl3945_addsta_cmd;
extern int iwl3945_send_add_station(struct iwl_priv *priv,
struct iwl3945_addsta_cmd *sta, u8 flags);
extern u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *bssid,
- int is_ap, u8 flags);
+ int is_ap, u8 flags, struct ieee80211_sta_ht_cap *ht_info);
+extern void iwl3945_clear_stations_table(struct iwl_priv *priv);
extern int iwl3945_power_init_handle(struct iwl_priv *priv);
extern int iwl3945_eeprom_init(struct iwl_priv *priv);
extern int iwl3945_calc_db_from_ratio(int sig_ratio);
@@ -278,6 +278,8 @@ extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
struct iwl_rx_mem_buffer *rxb);
extern void iwl3945_disable_events(struct iwl_priv *priv);
extern int iwl4965_get_temperature(const struct iwl_priv *priv);
+extern void iwl3945_post_associate(struct iwl_priv *priv);
+extern void iwl3945_config_ap(struct iwl_priv *priv);
/**
* iwl3945_hw_find_station - Find station id for a given BSSID
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 847a6220c5e6..a0b29411a4b3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -163,10 +163,6 @@ static int iwl4965_load_bsm(struct iwl_priv *priv)
inst_len = priv->ucode_init.len;
data_len = priv->ucode_init_data.len;
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
-
iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst);
iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata);
iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len);
@@ -179,10 +175,8 @@ static int iwl4965_load_bsm(struct iwl_priv *priv)
_iwl_write_prph(priv, reg_offset, le32_to_cpu(*image));
ret = iwl4965_verify_bsm(priv);
- if (ret) {
- iwl_release_nic_access(priv);
+ if (ret)
return ret;
- }
/* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */
iwl_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0);
@@ -211,7 +205,6 @@ static int iwl4965_load_bsm(struct iwl_priv *priv)
* (e.g. when powering back up after power-save shutdown) */
iwl_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN);
- iwl_release_nic_access(priv);
return 0;
}
@@ -229,20 +222,12 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv)
{
dma_addr_t pinst;
dma_addr_t pdata;
- unsigned long flags;
int ret = 0;
/* bits 35:4 for 4965 */
pinst = priv->ucode_code.p_addr >> 4;
pdata = priv->ucode_data_backup.p_addr >> 4;
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
-
/* Tell bootstrap uCode where to find image to load */
iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst);
iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata);
@@ -253,10 +238,6 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv)
* that all new ptr/size info is in place */
iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG,
priv->ucode_code.len | BSM_DRAM_INST_LOAD);
- iwl_release_nic_access(priv);
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n");
return ret;
@@ -312,10 +293,12 @@ restart:
queue_work(priv->workqueue, &priv->restart);
}
-static int is_fat_channel(__le32 rxon_flags)
+static bool is_fat_channel(__le32 rxon_flags)
{
- return (rxon_flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) ||
- (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK);
+ int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK)
+ >> RXON_FLG_CHANNEL_MODE_POS;
+ return ((chan_mod == CHANNEL_MODE_PURE_40) ||
+ (chan_mod == CHANNEL_MODE_MIXED));
}
/*
@@ -358,10 +341,6 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
goto out;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- goto out;
-
/* enable DMA */
iwl_write_prph(priv, APMG_CLK_CTRL_REG, APMG_CLK_VAL_DMA_CLK_RQT |
APMG_CLK_VAL_BSM_CLK_RQT);
@@ -372,7 +351,6 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
- iwl_release_nic_access(priv);
out:
return ret;
}
@@ -454,11 +432,9 @@ static void iwl4965_apm_stop(struct iwl_priv *priv)
static int iwl4965_apm_reset(struct iwl_priv *priv)
{
int ret = 0;
- unsigned long flags;
iwl4965_apm_stop_master(priv);
- spin_lock_irqsave(&priv->lock, flags);
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
@@ -475,9 +451,6 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
udelay(10);
- ret = iwl_grab_nic_access(priv);
- if (ret)
- goto out;
/* Enable DMA and BSM Clock */
iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT |
APMG_CLK_VAL_BSM_CLK_RQT);
@@ -488,14 +461,10 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
- iwl_release_nic_access(priv);
-
clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
wake_up_interruptible(&priv->wait_command_queue);
out:
- spin_unlock_irqrestore(&priv->lock, flags);
-
return ret;
}
@@ -681,18 +650,11 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
{
u32 a;
unsigned long flags;
- int ret;
int i, chan;
u32 reg_val;
spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
-
/* Clear 4965's internal Tx Scheduler data base */
priv->scd_base_addr = iwl_read_prph(priv, IWL49_SCD_SRAM_BASE_ADDR);
a = priv->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET;
@@ -759,10 +721,9 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
}
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
+ return 0;
}
static struct iwl_sensitivity_ranges iwl4965_sensitivity = {
@@ -788,6 +749,12 @@ static struct iwl_sensitivity_ranges iwl4965_sensitivity = {
.nrg_th_ofdm = 100,
};
+static void iwl4965_set_ct_threshold(struct iwl_priv *priv)
+{
+ /* want Kelvin */
+ priv->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
+}
+
/**
* iwl4965_hw_set_hw_params
*
@@ -822,7 +789,8 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
priv->hw_params.rx_chains_num = 2;
priv->hw_params.valid_tx_ant = ANT_A | ANT_B;
priv->hw_params.valid_rx_ant = ANT_A | ANT_B;
- priv->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
+ if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
+ priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
priv->hw_params.sens = &iwl4965_sensitivity;
@@ -1524,7 +1492,7 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv)
struct iwl4965_txpowertable_cmd cmd = { 0 };
int ret;
u8 band = 0;
- u8 is_fat = 0;
+ bool is_fat = false;
u8 ctrl_chan_high = 0;
if (test_bit(STATUS_SCANNING, &priv->status)) {
@@ -1602,7 +1570,7 @@ static int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
{
int rc;
u8 band = 0;
- u8 is_fat = 0;
+ bool is_fat = false;
u8 ctrl_chan_high = 0;
struct iwl4965_channel_switch_cmd cmd = { 0 };
const struct iwl_channel_info *ch_info;
@@ -1833,8 +1801,6 @@ static void iwl4965_tx_queue_stop_scheduler(struct iwl_priv *priv,
static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
u16 ssn_idx, u8 tx_fifo)
{
- int ret = 0;
-
if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) ||
(IWL49_FIRST_AMPDU_QUEUE + IWL49_NUM_AMPDU_QUEUES <= txq_id)) {
IWL_WARN(priv,
@@ -1844,10 +1810,6 @@ static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
return -EINVAL;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
-
iwl4965_tx_queue_stop_scheduler(priv, txq_id);
iwl_clear_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id));
@@ -1861,8 +1823,6 @@ static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
iwl_txq_ctx_deactivate(priv, txq_id);
iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
- iwl_release_nic_access(priv);
-
return 0;
}
@@ -1904,7 +1864,6 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
int tx_fifo, int sta_id, int tid, u16 ssn_idx)
{
unsigned long flags;
- int ret;
u16 ra_tid;
if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) ||
@@ -1922,11 +1881,6 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
/* Stop this Tx queue before configuring it */
iwl4965_tx_queue_stop_scheduler(priv, txq_id);
@@ -1959,7 +1913,6 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
/* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
return 0;
@@ -2268,9 +2221,17 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
cancel_work_sync(&priv->txpower_work);
}
+static struct iwl_station_mgmt_ops iwl4965_station_mgmt = {
+ .add_station = iwl_add_station_flags,
+ .remove_station = iwl_remove_station,
+ .find_station = iwl_find_station,
+ .clear_station_table = iwl_clear_stations_table,
+};
static struct iwl_hcmd_ops iwl4965_hcmd = {
.rxon_assoc = iwl4965_send_rxon_assoc,
+ .commit_rxon = iwl_commit_rxon,
+ .set_rxon_chain = iwl_set_rxon_chain,
};
static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
@@ -2323,13 +2284,20 @@ static struct iwl_lib_ops iwl4965_lib = {
},
.send_tx_power = iwl4965_send_tx_power,
.update_chain_flags = iwl_update_chain_flags,
- .temperature = iwl4965_temperature_calib,
+ .post_associate = iwl_post_associate,
+ .config_ap = iwl_config_ap,
+ .isr = iwl_isr_legacy,
+ .temp_ops = {
+ .temperature = iwl4965_temperature_calib,
+ .set_ct_kill = iwl4965_set_ct_threshold,
+ },
};
static struct iwl_ops iwl4965_ops = {
.lib = &iwl4965_lib,
.hcmd = &iwl4965_hcmd,
.utils = &iwl4965_hcmd_utils,
+ .smgmt = &iwl4965_station_mgmt,
};
struct iwl_cfg iwl4965_agn_cfg = {
@@ -2343,6 +2311,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
.eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION,
.ops = &iwl4965_ops,
.mod_params = &iwl4965_mod_params,
+ .use_isr_legacy = true
};
/* Module firmware */
@@ -2350,8 +2319,6 @@ MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE(IWL4965_UCODE_API_MAX));
module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
-module_param_named(disable, iwl4965_mod_params.disable, int, 0444);
-MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
module_param_named(swcrypto, iwl4965_mod_params.sw_crypto, int, 0444);
MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
module_param_named(debug, iwl4965_mod_params.debug, uint, 0444);
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
index 15cac70e36e2..4ef6804a455a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
@@ -87,6 +87,18 @@
#define IWL50_NUM_AMPDU_QUEUES 10
#define IWL50_FIRST_AMPDU_QUEUE 10
+/* 5150 only */
+#define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF (-5)
+
+static inline s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
+{
+ u16 *temp_calib = (u16 *)iwl_eeprom_query_addr(priv,
+ EEPROM_5000_TEMPERATURE);
+ /* offset = temperature - voltage / coef */
+ s32 offset = (s32)(temp_calib[0] - temp_calib[1] / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
+ return offset;
+}
+
/* Fixed (non-configurable) rx data from phy */
/**
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index e5ca2511a81a..ab29aab6b2d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -46,7 +46,7 @@
#include "iwl-6000-hw.h"
/* Highest firmware API version supported */
-#define IWL5000_UCODE_API_MAX 1
+#define IWL5000_UCODE_API_MAX 2
#define IWL5150_UCODE_API_MAX 2
/* Lowest firmware API version supported */
@@ -124,10 +124,6 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
return ret;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
-
/* enable DMA */
iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
@@ -137,8 +133,6 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
- iwl_release_nic_access(priv);
-
return ret;
}
@@ -165,12 +159,9 @@ static void iwl5000_apm_stop(struct iwl_priv *priv)
static int iwl5000_apm_reset(struct iwl_priv *priv)
{
int ret = 0;
- unsigned long flags;
iwl5000_apm_stop_master(priv);
- spin_lock_irqsave(&priv->lock, flags);
-
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
udelay(10);
@@ -193,10 +184,6 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
goto out;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- goto out;
-
/* enable DMA */
iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
@@ -205,11 +192,7 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
/* disable L1-Active */
iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
-
- iwl_release_nic_access(priv);
-
out:
- spin_unlock_irqrestore(&priv->lock, flags);
return ret;
}
@@ -252,11 +235,9 @@ static void iwl5000_nic_config(struct iwl_priv *priv)
* (PCIe power is lost before PERST# is asserted),
* causing ME FW to lose ownership and not being able to obtain it back.
*/
- iwl_grab_nic_access(priv);
iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
}
@@ -434,15 +415,19 @@ static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
return &priv->eeprom[address];
}
-static s32 iwl5150_get_ct_threshold(struct iwl_priv *priv)
+static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
{
- const s32 volt2temp_coef = -5;
- u16 *temp_calib = (u16 *)iwl_eeprom_query_addr(priv,
- EEPROM_5000_TEMPERATURE);
- /* offset = temperate - voltage / coef */
- s32 offset = temp_calib[0] - temp_calib[1] / volt2temp_coef;
- s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD) - offset;
- return threshold * volt2temp_coef;
+ const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
+ s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD) -
+ iwl_temp_calib_to_offset(priv);
+
+ priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
+}
+
+static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
+{
+ /* want Celsius */
+ priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
}
/*
@@ -533,19 +518,9 @@ static int iwl5000_load_section(struct iwl_priv *priv,
struct fw_desc *image,
u32 dst_addr)
{
- int ret = 0;
- unsigned long flags;
-
dma_addr_t phy_addr = image->p_addr;
u32 byte_cnt = image->len;
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
-
iwl_write_direct32(priv,
FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
@@ -574,8 +549,6 @@ static int iwl5000_load_section(struct iwl_priv *priv,
FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
@@ -678,7 +651,7 @@ static void iwl5000_init_alive_start(struct iwl_priv *priv)
goto restart;
}
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
ret = priv->cfg->ops->lib->alive_notify(priv);
if (ret) {
IWL_WARN(priv,
@@ -736,18 +709,11 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
{
u32 a;
unsigned long flags;
- int ret;
int i, chan;
u32 reg_val;
spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
-
priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR);
a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET;
for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET;
@@ -815,7 +781,6 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
iwl_txq_ctx_activate(priv, 8);
iwl_txq_ctx_activate(priv, 9);
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
@@ -868,17 +833,8 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
- switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
- case CSR_HW_REV_TYPE_5150:
- /* 5150 wants in Kelvin */
- priv->hw_params.ct_kill_threshold =
- iwl5150_get_ct_threshold(priv);
- break;
- default:
- /* all others want Celsius */
- priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
- break;
- }
+ if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
+ priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
/* Set initial calibration set */
switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
@@ -900,7 +856,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
break;
}
-
return 0;
}
@@ -1006,7 +961,6 @@ static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
int tx_fifo, int sta_id, int tid, u16 ssn_idx)
{
unsigned long flags;
- int ret;
u16 ra_tid;
if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
@@ -1024,11 +978,6 @@ static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
/* Stop this Tx queue before configuring it */
iwl5000_tx_queue_stop_scheduler(priv, txq_id);
@@ -1064,7 +1013,6 @@ static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
/* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
return 0;
@@ -1073,8 +1021,6 @@ static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
u16 ssn_idx, u8 tx_fifo)
{
- int ret;
-
if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
(IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
IWL_ERR(priv,
@@ -1084,10 +1030,6 @@ static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
return -EINVAL;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
-
iwl5000_tx_queue_stop_scheduler(priv, txq_id);
iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id));
@@ -1101,8 +1043,6 @@ static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
iwl_txq_ctx_deactivate(priv, txq_id);
iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
- iwl_release_nic_access(priv);
-
return 0;
}
@@ -1434,6 +1374,17 @@ static void iwl5000_temperature(struct iwl_priv *priv)
priv->temperature = le32_to_cpu(priv->statistics.general.temperature);
}
+static void iwl5150_temperature(struct iwl_priv *priv)
+{
+ u32 vt = 0;
+ s32 offset = iwl_temp_calib_to_offset(priv);
+
+ vt = le32_to_cpu(priv->statistics.general.temperature);
+ vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
+ /* now vt hold the temperature in Kelvin */
+ priv->temperature = KELVIN_TO_CELSIUS(vt);
+}
+
/* Calc max signal level (dBm) among 3 possible receivers */
int iwl5000_calc_rssi(struct iwl_priv *priv,
struct iwl_rx_phy_res *rx_resp)
@@ -1472,8 +1423,17 @@ int iwl5000_calc_rssi(struct iwl_priv *priv,
return max_rssi - agc - IWL49_RSSI_OFFSET;
}
+struct iwl_station_mgmt_ops iwl5000_station_mgmt = {
+ .add_station = iwl_add_station_flags,
+ .remove_station = iwl_remove_station,
+ .find_station = iwl_find_station,
+ .clear_station_table = iwl_clear_stations_table,
+};
+
struct iwl_hcmd_ops iwl5000_hcmd = {
.rxon_assoc = iwl5000_send_rxon_assoc,
+ .commit_rxon = iwl_commit_rxon,
+ .set_rxon_chain = iwl_set_rxon_chain,
};
struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
@@ -1502,7 +1462,6 @@ struct iwl_lib_ops iwl5000_lib = {
.init_alive_start = iwl5000_init_alive_start,
.alive_notify = iwl5000_alive_notify,
.send_tx_power = iwl5000_send_tx_power,
- .temperature = iwl5000_temperature,
.update_chain_flags = iwl_update_chain_flags,
.apm_ops = {
.init = iwl5000_apm_init,
@@ -1527,12 +1486,77 @@ struct iwl_lib_ops iwl5000_lib = {
.calib_version = iwl5000_eeprom_calib_version,
.query_addr = iwl5000_eeprom_query_addr,
},
+ .post_associate = iwl_post_associate,
+ .isr = iwl_isr_ict,
+ .config_ap = iwl_config_ap,
+ .temp_ops = {
+ .temperature = iwl5000_temperature,
+ .set_ct_kill = iwl5000_set_ct_threshold,
+ },
+};
+
+static struct iwl_lib_ops iwl5150_lib = {
+ .set_hw_params = iwl5000_hw_set_hw_params,
+ .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
+ .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
+ .txq_set_sched = iwl5000_txq_set_sched,
+ .txq_agg_enable = iwl5000_txq_agg_enable,
+ .txq_agg_disable = iwl5000_txq_agg_disable,
+ .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
+ .txq_free_tfd = iwl_hw_txq_free_tfd,
+ .txq_init = iwl_hw_tx_queue_init,
+ .rx_handler_setup = iwl5000_rx_handler_setup,
+ .setup_deferred_work = iwl5000_setup_deferred_work,
+ .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
+ .load_ucode = iwl5000_load_ucode,
+ .init_alive_start = iwl5000_init_alive_start,
+ .alive_notify = iwl5000_alive_notify,
+ .send_tx_power = iwl5000_send_tx_power,
+ .update_chain_flags = iwl_update_chain_flags,
+ .apm_ops = {
+ .init = iwl5000_apm_init,
+ .reset = iwl5000_apm_reset,
+ .stop = iwl5000_apm_stop,
+ .config = iwl5000_nic_config,
+ .set_pwr_src = iwl_set_pwr_src,
+ },
+ .eeprom_ops = {
+ .regulatory_bands = {
+ EEPROM_5000_REG_BAND_1_CHANNELS,
+ EEPROM_5000_REG_BAND_2_CHANNELS,
+ EEPROM_5000_REG_BAND_3_CHANNELS,
+ EEPROM_5000_REG_BAND_4_CHANNELS,
+ EEPROM_5000_REG_BAND_5_CHANNELS,
+ EEPROM_5000_REG_BAND_24_FAT_CHANNELS,
+ EEPROM_5000_REG_BAND_52_FAT_CHANNELS
+ },
+ .verify_signature = iwlcore_eeprom_verify_signature,
+ .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
+ .release_semaphore = iwlcore_eeprom_release_semaphore,
+ .calib_version = iwl5000_eeprom_calib_version,
+ .query_addr = iwl5000_eeprom_query_addr,
+ },
+ .post_associate = iwl_post_associate,
+ .isr = iwl_isr_ict,
+ .config_ap = iwl_config_ap,
+ .temp_ops = {
+ .temperature = iwl5150_temperature,
+ .set_ct_kill = iwl5150_set_ct_threshold,
+ },
};
struct iwl_ops iwl5000_ops = {
.lib = &iwl5000_lib,
.hcmd = &iwl5000_hcmd,
.utils = &iwl5000_hcmd_utils,
+ .smgmt = &iwl5000_station_mgmt,
+};
+
+static struct iwl_ops iwl5150_ops = {
+ .lib = &iwl5150_lib,
+ .hcmd = &iwl5000_hcmd,
+ .utils = &iwl5000_hcmd_utils,
+ .smgmt = &iwl5000_station_mgmt,
};
struct iwl_mod_params iwl50_mod_params = {
@@ -1630,7 +1654,7 @@ struct iwl_cfg iwl5150_agn_cfg = {
.ucode_api_max = IWL5150_UCODE_API_MAX,
.ucode_api_min = IWL5150_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
- .ops = &iwl5000_ops,
+ .ops = &iwl5150_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
.eeprom_ver = EEPROM_5050_EEPROM_VERSION,
.eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
@@ -1643,9 +1667,6 @@ struct iwl_cfg iwl5150_agn_cfg = {
MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
-module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
-MODULE_PARM_DESC(disable50,
- "manually disable the 50XX radio (default 0 [radio on])");
module_param_named(swcrypto50, iwl50_mod_params.sw_crypto, bool, 0444);
MODULE_PARM_DESC(swcrypto50,
"using software crypto engine (default 0 [hardware])\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index bd438d8acf55..7236382aeaa6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -72,6 +72,7 @@ static struct iwl_ops iwl6000_ops = {
.lib = &iwl5000_lib,
.hcmd = &iwl5000_hcmd,
.utils = &iwl6000_hcmd_utils,
+ .smgmt = &iwl5000_station_mgmt,
};
struct iwl_cfg iwl6000_2ag_cfg = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index cab7842a73aa..23a58b00f180 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -52,7 +52,7 @@
/* max allowed rate miss before sync LQ cmd */
#define IWL_MISSED_RATE_MAX 15
/* max time to accum history 2 seconds */
-#define IWL_RATE_SCALE_FLUSH_INTVL (2*HZ)
+#define IWL_RATE_SCALE_FLUSH_INTVL (3*HZ)
static u8 rs_ht_to_legacy[] = {
IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX,
@@ -100,6 +100,7 @@ struct iwl_scale_tbl_info {
u8 is_fat; /* 1 = 40 MHz channel width */
u8 is_dup; /* 1 = duplicated data streams */
u8 action; /* change modulation; IWL_[LEGACY/SISO/MIMO]_SWITCH_* */
+ u8 max_search; /* maximun number of tables we can search */
s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */
u32 current_rate; /* rate_n_flags, uCode API format */
struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */
@@ -135,7 +136,7 @@ struct iwl_lq_sta {
u32 table_count;
u32 total_failed; /* total failed frames, any/all rates */
u32 total_success; /* total successful frames, any/all rates */
- u32 flush_timer; /* time staying in mode before new search */
+ u64 flush_timer; /* time staying in mode before new search */
u8 action_counter; /* # mode-switch actions tried */
u8 is_green;
@@ -160,6 +161,7 @@ struct iwl_lq_sta {
#ifdef CONFIG_MAC80211_DEBUGFS
struct dentry *rs_sta_dbgfs_scale_table_file;
struct dentry *rs_sta_dbgfs_stats_table_file;
+ struct dentry *rs_sta_dbgfs_rate_scale_data_file;
struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
u32 dbg_fixed_rate;
#endif
@@ -167,10 +169,12 @@ struct iwl_lq_sta {
/* used to be in sta_info */
int last_txrate_idx;
+ /* last tx rate_n_flags */
+ u32 last_rate_n_flags;
};
static void rs_rate_scale_perform(struct iwl_priv *priv,
- struct ieee80211_hdr *hdr,
+ struct sk_buff *skb,
struct ieee80211_sta *sta,
struct iwl_lq_sta *lq_sta);
static void rs_fill_link_cmd(const struct iwl_priv *priv,
@@ -191,7 +195,7 @@ static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta,
* 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits
* "G" is the only table that supports CCK (the first 4 rates).
*/
-/*FIXME:RS:need to separate tables for MIMO2/MIMO3*/
+
static s32 expected_tpt_A[IWL_RATE_COUNT] = {
0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186, 186
};
@@ -208,11 +212,11 @@ static s32 expected_tpt_siso20MHzSGI[IWL_RATE_COUNT] = {
0, 0, 0, 0, 46, 46, 82, 110, 132, 168, 192, 202, 211
};
-static s32 expected_tpt_mimo20MHz[IWL_RATE_COUNT] = {
+static s32 expected_tpt_mimo2_20MHz[IWL_RATE_COUNT] = {
0, 0, 0, 0, 74, 74, 123, 155, 179, 214, 236, 244, 251
};
-static s32 expected_tpt_mimo20MHzSGI[IWL_RATE_COUNT] = {
+static s32 expected_tpt_mimo2_20MHzSGI[IWL_RATE_COUNT] = {
0, 0, 0, 0, 81, 81, 131, 164, 188, 222, 243, 251, 257
};
@@ -224,14 +228,50 @@ static s32 expected_tpt_siso40MHzSGI[IWL_RATE_COUNT] = {
0, 0, 0, 0, 83, 83, 135, 169, 193, 229, 250, 257, 264
};
-static s32 expected_tpt_mimo40MHz[IWL_RATE_COUNT] = {
+static s32 expected_tpt_mimo2_40MHz[IWL_RATE_COUNT] = {
0, 0, 0, 0, 123, 123, 182, 214, 235, 264, 279, 285, 289
};
-static s32 expected_tpt_mimo40MHzSGI[IWL_RATE_COUNT] = {
+static s32 expected_tpt_mimo2_40MHzSGI[IWL_RATE_COUNT] = {
0, 0, 0, 0, 131, 131, 191, 222, 242, 270, 284, 289, 293
};
+/* Expected throughput metric MIMO3 */
+static s32 expected_tpt_mimo3_20MHz[IWL_RATE_COUNT] = {
+ 0, 0, 0, 0, 99, 99, 153, 186, 208, 239, 256, 263, 268
+};
+
+static s32 expected_tpt_mimo3_20MHzSGI[IWL_RATE_COUNT] = {
+ 0, 0, 0, 0, 106, 106, 162, 194, 215, 246, 262, 268, 273
+};
+
+static s32 expected_tpt_mimo3_40MHz[IWL_RATE_COUNT] = {
+ 0, 0, 0, 0, 152, 152, 211, 239, 255, 279, 290, 294, 297
+};
+
+static s32 expected_tpt_mimo3_40MHzSGI[IWL_RATE_COUNT] = {
+ 0, 0, 0, 0, 160, 160, 219, 245, 261, 284, 294, 297, 300
+};
+
+/* mbps, mcs */
+const static struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = {
+ {"1", ""},
+ {"2", ""},
+ {"5.5", ""},
+ {"11", ""},
+ {"6", "BPSK 1/2"},
+ {"9", "BPSK 1/2"},
+ {"12", "QPSK 1/2"},
+ {"18", "QPSK 3/4"},
+ {"24", "16QAM 1/2"},
+ {"36", "16QAM 3/4"},
+ {"48", "64QAM 2/3"},
+ {"54", "64QAM 3/4"},
+ {"60", "64QAM 5/6"}
+};
+
+#define MCS_INDEX_PER_STREAM (8)
+
static inline u8 rs_extract_rate(u32 rate_n_flags)
{
return (u8)(rate_n_flags & 0xFF);
@@ -543,6 +583,7 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags,
tbl->is_dup = 0;
tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS);
tbl->lq_type = LQ_NONE;
+ tbl->max_search = IWL_MAX_SEARCH;
/* legacy rate format */
if (!(rate_n_flags & RATE_MCS_HT_MSK)) {
@@ -576,8 +617,10 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags,
tbl->lq_type = LQ_MIMO2;
/* MIMO3 */
} else {
- if (num_of_ant == 3)
+ if (num_of_ant == 3) {
+ tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH;
tbl->lq_type = LQ_MIMO3;
+ }
}
}
return 0;
@@ -611,19 +654,19 @@ static int rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags,
return 1;
}
-/* FIXME:RS: in 4965 we don't use greenfield at all */
-/* FIXME:RS: don't use greenfield for now in TX */
-#if 0
-static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf)
+/* in 4965 we don't use greenfield at all */
+static inline u8 rs_use_green(struct iwl_priv *priv,
+ struct ieee80211_conf *conf)
{
- return (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) &&
- priv->current_ht_config.is_green_field &&
- !priv->current_ht_config.non_GF_STA_present;
-}
-#endif
-static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf)
-{
- return 0;
+ u8 is_green;
+
+ if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
+ is_green = 0;
+ else
+ is_green = (conf_is_ht(conf) &&
+ priv->current_ht_config.is_green_field &&
+ !priv->current_ht_config.non_GF_STA_present);
+ return is_green;
}
/**
@@ -735,6 +778,7 @@ static u32 rs_get_lower_rate(struct iwl_lq_sta *lq_sta,
tbl->is_fat = 0;
tbl->is_SGI = 0;
+ tbl->max_search = IWL_MAX_SEARCH;
}
rate_mask = rs_get_supported_rates(lq_sta, NULL, tbl->lq_type);
@@ -793,7 +837,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n");
if (!ieee80211_is_data(hdr->frame_control) ||
- is_multicast_ether_addr(hdr->addr1))
+ info->flags & IEEE80211_TX_CTL_NO_ACK)
return;
/* This packet was aggregated but doesn't carry rate scale info */
@@ -902,6 +946,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
* else look up the rate that was, finally, successful.
*/
tx_rate = le32_to_cpu(table->rs_table[index].rate_n_flags);
+ lq_sta->last_rate_n_flags = tx_rate;
rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index);
/* Update frame history window with "success" if Tx got ACKed ... */
@@ -958,7 +1003,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
/* See if there's a better rate or modulation mode to try. */
if (sta && sta->supp_rates[sband->band])
- rs_rate_scale_perform(priv, hdr, sta, lq_sta);
+ rs_rate_scale_perform(priv, skb, sta, lq_sta);
out:
return;
}
@@ -988,6 +1033,8 @@ static void rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy,
lq_sta->table_count = 0;
lq_sta->total_failed = 0;
lq_sta->total_success = 0;
+ lq_sta->flush_timer = jiffies;
+ lq_sta->action_counter = 0;
}
/*
@@ -1011,17 +1058,26 @@ static void rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta,
tbl->expected_tpt = expected_tpt_siso20MHzSGI;
else
tbl->expected_tpt = expected_tpt_siso20MHz;
-
- } else if (is_mimo(tbl->lq_type)) { /* FIXME:need to separate mimo2/3 */
+ } else if (is_mimo2(tbl->lq_type)) {
if (tbl->is_fat && !lq_sta->is_dup)
if (tbl->is_SGI)
- tbl->expected_tpt = expected_tpt_mimo40MHzSGI;
+ tbl->expected_tpt = expected_tpt_mimo2_40MHzSGI;
else
- tbl->expected_tpt = expected_tpt_mimo40MHz;
+ tbl->expected_tpt = expected_tpt_mimo2_40MHz;
else if (tbl->is_SGI)
- tbl->expected_tpt = expected_tpt_mimo20MHzSGI;
+ tbl->expected_tpt = expected_tpt_mimo2_20MHzSGI;
else
- tbl->expected_tpt = expected_tpt_mimo20MHz;
+ tbl->expected_tpt = expected_tpt_mimo2_20MHz;
+ } else if (is_mimo3(tbl->lq_type)) {
+ if (tbl->is_fat && !lq_sta->is_dup)
+ if (tbl->is_SGI)
+ tbl->expected_tpt = expected_tpt_mimo3_40MHzSGI;
+ else
+ tbl->expected_tpt = expected_tpt_mimo3_40MHz;
+ else if (tbl->is_SGI)
+ tbl->expected_tpt = expected_tpt_mimo3_20MHzSGI;
+ else
+ tbl->expected_tpt = expected_tpt_mimo3_20MHz;
} else
tbl->expected_tpt = expected_tpt_G;
}
@@ -1130,7 +1186,7 @@ static s32 rs_get_best_rate(struct iwl_priv *priv,
}
/*
- * Set up search table for MIMO
+ * Set up search table for MIMO2
*/
static int rs_switch_to_mimo2(struct iwl_priv *priv,
struct iwl_lq_sta *lq_sta,
@@ -1158,10 +1214,10 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
tbl->lq_type = LQ_MIMO2;
tbl->is_dup = lq_sta->is_dup;
tbl->action = 0;
+ tbl->max_search = IWL_MAX_SEARCH;
rate_mask = lq_sta->active_mimo2_rate;
- if (priv->current_ht_config.supported_chan_width
- == IWL_CHANNEL_WIDTH_40MHZ)
+ if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap))
tbl->is_fat = 1;
else
tbl->is_fat = 0;
@@ -1183,7 +1239,73 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index);
IWL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask);
+ if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) {
+ IWL_DEBUG_RATE(priv, "Can't switch with index %d rate mask %x\n",
+ rate, rate_mask);
+ return -1;
+ }
+ tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green);
+
+ IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n",
+ tbl->current_rate, is_green);
+ return 0;
+}
+
+/*
+ * Set up search table for MIMO3
+ */
+static int rs_switch_to_mimo3(struct iwl_priv *priv,
+ struct iwl_lq_sta *lq_sta,
+ struct ieee80211_conf *conf,
+ struct ieee80211_sta *sta,
+ struct iwl_scale_tbl_info *tbl, int index)
+{
+ u16 rate_mask;
+ s32 rate;
+ s8 is_green = lq_sta->is_green;
+
+ if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
+ return -1;
+
+ if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
+ == WLAN_HT_CAP_SM_PS_STATIC)
+ return -1;
+
+ /* Need both Tx chains/antennas to support MIMO */
+ if (priv->hw_params.tx_chains_num < 3)
+ return -1;
+
+ IWL_DEBUG_RATE(priv, "LQ: try to switch to MIMO3\n");
+
+ tbl->lq_type = LQ_MIMO3;
+ tbl->is_dup = lq_sta->is_dup;
+ tbl->action = 0;
+ tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH;
+ rate_mask = lq_sta->active_mimo3_rate;
+
+ if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap))
+ tbl->is_fat = 1;
+ else
+ tbl->is_fat = 0;
+ /* FIXME: - don't toggle SGI here
+ if (tbl->is_fat) {
+ if (priv->current_ht_config.sgf & HT_SHORT_GI_40MHZ_ONLY)
+ tbl->is_SGI = 1;
+ else
+ tbl->is_SGI = 0;
+ } else if (priv->current_ht_config.sgf & HT_SHORT_GI_20MHZ_ONLY)
+ tbl->is_SGI = 1;
+ else
+ tbl->is_SGI = 0;
+ */
+
+ rs_set_expected_tpt_table(lq_sta, tbl);
+
+ rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index);
+
+ IWL_DEBUG_RATE(priv, "LQ: MIMO3 best rate %d mask %X\n",
+ rate, rate_mask);
if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) {
IWL_DEBUG_RATE(priv, "Can't switch with index %d rate mask %x\n",
rate, rate_mask);
@@ -1217,10 +1339,10 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
tbl->is_dup = lq_sta->is_dup;
tbl->lq_type = LQ_SISO;
tbl->action = 0;
+ tbl->max_search = IWL_MAX_SEARCH;
rate_mask = lq_sta->active_siso_rate;
- if (priv->current_ht_config.supported_chan_width
- == IWL_CHANNEL_WIDTH_40MHZ)
+ if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap))
tbl->is_fat = 1;
else
tbl->is_fat = 0;
@@ -1274,15 +1396,15 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
u8 tx_chains_num = priv->hw_params.tx_chains_num;
int ret = 0;
+ u8 update_search_tbl_counter = 0;
for (; ;) {
+ lq_sta->action_counter++;
switch (tbl->action) {
case IWL_LEGACY_SWITCH_ANTENNA1:
case IWL_LEGACY_SWITCH_ANTENNA2:
IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n");
- lq_sta->action_counter++;
-
if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 &&
tx_chains_num <= 1) ||
(tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 &&
@@ -1298,6 +1420,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
if (rs_toggle_antenna(valid_tx_ant,
&search_tbl->current_rate, search_tbl)) {
+ update_search_tbl_counter = 1;
rs_set_expected_tpt_table(lq_sta, search_tbl);
goto out;
}
@@ -1342,9 +1465,29 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
goto out;
}
break;
+
+ case IWL_LEGACY_SWITCH_MIMO3_ABC:
+ IWL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO3\n");
+
+ /* Set up search table to try MIMO3 */
+ memcpy(search_tbl, tbl, sz);
+ search_tbl->is_SGI = 0;
+
+ search_tbl->ant_type = ANT_ABC;
+
+ if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
+ break;
+
+ ret = rs_switch_to_mimo3(priv, lq_sta, conf, sta,
+ search_tbl, index);
+ if (!ret) {
+ lq_sta->action_counter = 0;
+ goto out;
+ }
+ break;
}
tbl->action++;
- if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC)
+ if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC)
tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
if (tbl->action == start_action)
@@ -1357,8 +1500,10 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
out:
lq_sta->search_better_tbl = 1;
tbl->action++;
- if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC)
+ if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC)
tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
+ if (update_search_tbl_counter)
+ search_tbl->action = tbl->action;
return 0;
}
@@ -1381,6 +1526,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
u8 start_action = tbl->action;
u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
u8 tx_chains_num = priv->hw_params.tx_chains_num;
+ u8 update_search_tbl_counter = 0;
int ret;
for (;;) {
@@ -1401,8 +1547,10 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
memcpy(search_tbl, tbl, sz);
if (rs_toggle_antenna(valid_tx_ant,
- &search_tbl->current_rate, search_tbl))
+ &search_tbl->current_rate, search_tbl)) {
+ update_search_tbl_counter = 1;
goto out;
+ }
break;
case IWL_SISO_SWITCH_MIMO2_AB:
case IWL_SISO_SWITCH_MIMO2_AC:
@@ -1456,10 +1604,25 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
search_tbl->current_rate =
rate_n_flags_from_tbl(priv, search_tbl,
index, is_green);
+ update_search_tbl_counter = 1;
goto out;
+ case IWL_SISO_SWITCH_MIMO3_ABC:
+ IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO3\n");
+ memcpy(search_tbl, tbl, sz);
+ search_tbl->is_SGI = 0;
+ search_tbl->ant_type = ANT_ABC;
+
+ if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
+ break;
+
+ ret = rs_switch_to_mimo3(priv, lq_sta, conf, sta,
+ search_tbl, index);
+ if (!ret)
+ goto out;
+ break;
}
tbl->action++;
- if (tbl->action > IWL_SISO_SWITCH_GI)
+ if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC)
tbl->action = IWL_SISO_SWITCH_ANTENNA1;
if (tbl->action == start_action)
@@ -1471,15 +1634,18 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
out:
lq_sta->search_better_tbl = 1;
tbl->action++;
- if (tbl->action > IWL_SISO_SWITCH_GI)
+ if (tbl->action > IWL_SISO_SWITCH_MIMO3_ABC)
tbl->action = IWL_SISO_SWITCH_ANTENNA1;
+ if (update_search_tbl_counter)
+ search_tbl->action = tbl->action;
+
return 0;
}
/*
- * Try to switch to new modulation mode from MIMO
+ * Try to switch to new modulation mode from MIMO2
*/
-static int rs_move_mimo_to_other(struct iwl_priv *priv,
+static int rs_move_mimo2_to_other(struct iwl_priv *priv,
struct iwl_lq_sta *lq_sta,
struct ieee80211_conf *conf,
struct ieee80211_sta *sta, int index)
@@ -1494,6 +1660,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
u8 start_action = tbl->action;
u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
u8 tx_chains_num = priv->hw_params.tx_chains_num;
+ u8 update_search_tbl_counter = 0;
int ret;
for (;;) {
@@ -1501,7 +1668,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
switch (tbl->action) {
case IWL_MIMO2_SWITCH_ANTENNA1:
case IWL_MIMO2_SWITCH_ANTENNA2:
- IWL_DEBUG_RATE(priv, "LQ: MIMO toggle Antennas\n");
+ IWL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n");
if (tx_chains_num <= 2)
break;
@@ -1511,8 +1678,10 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
memcpy(search_tbl, tbl, sz);
if (rs_toggle_antenna(valid_tx_ant,
- &search_tbl->current_rate, search_tbl))
+ &search_tbl->current_rate, search_tbl)) {
+ update_search_tbl_counter = 1;
goto out;
+ }
break;
case IWL_MIMO2_SWITCH_SISO_A:
case IWL_MIMO2_SWITCH_SISO_B:
@@ -1549,9 +1718,9 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
HT_SHORT_GI_40MHZ))
break;
- IWL_DEBUG_RATE(priv, "LQ: MIMO toggle SGI/NGI\n");
+ IWL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n");
- /* Set up new search table for MIMO */
+ /* Set up new search table for MIMO2 */
memcpy(search_tbl, tbl, sz);
search_tbl->is_SGI = !tbl->is_SGI;
rs_set_expected_tpt_table(lq_sta, search_tbl);
@@ -1569,11 +1738,27 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
search_tbl->current_rate =
rate_n_flags_from_tbl(priv, search_tbl,
index, is_green);
+ update_search_tbl_counter = 1;
goto out;
+ case IWL_MIMO2_SWITCH_MIMO3_ABC:
+ IWL_DEBUG_RATE(priv, "LQ: MIMO2 switch to MIMO3\n");
+ memcpy(search_tbl, tbl, sz);
+ search_tbl->is_SGI = 0;
+ search_tbl->ant_type = ANT_ABC;
+
+ if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
+ break;
+
+ ret = rs_switch_to_mimo3(priv, lq_sta, conf, sta,
+ search_tbl, index);
+ if (!ret)
+ goto out;
+
+ break;
}
tbl->action++;
- if (tbl->action > IWL_MIMO2_SWITCH_GI)
+ if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC)
tbl->action = IWL_MIMO2_SWITCH_ANTENNA1;
if (tbl->action == start_action)
@@ -1584,8 +1769,153 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
out:
lq_sta->search_better_tbl = 1;
tbl->action++;
- if (tbl->action > IWL_MIMO2_SWITCH_GI)
+ if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC)
tbl->action = IWL_MIMO2_SWITCH_ANTENNA1;
+ if (update_search_tbl_counter)
+ search_tbl->action = tbl->action;
+
+ return 0;
+
+}
+
+/*
+ * Try to switch to new modulation mode from MIMO3
+ */
+static int rs_move_mimo3_to_other(struct iwl_priv *priv,
+ struct iwl_lq_sta *lq_sta,
+ struct ieee80211_conf *conf,
+ struct ieee80211_sta *sta, int index)
+{
+ s8 is_green = lq_sta->is_green;
+ struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
+ struct iwl_scale_tbl_info *search_tbl =
+ &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]);
+ struct iwl_rate_scale_data *window = &(tbl->win[index]);
+ u32 sz = (sizeof(struct iwl_scale_tbl_info) -
+ (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT));
+ u8 start_action = tbl->action;
+ u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
+ u8 tx_chains_num = priv->hw_params.tx_chains_num;
+ int ret;
+ u8 update_search_tbl_counter = 0;
+
+ for (;;) {
+ lq_sta->action_counter++;
+ switch (tbl->action) {
+ case IWL_MIMO3_SWITCH_ANTENNA1:
+ case IWL_MIMO3_SWITCH_ANTENNA2:
+ IWL_DEBUG_RATE(priv, "LQ: MIMO3 toggle Antennas\n");
+
+ if (tx_chains_num <= 3)
+ break;
+
+ if (window->success_ratio >= IWL_RS_GOOD_RATIO)
+ break;
+
+ memcpy(search_tbl, tbl, sz);
+ if (rs_toggle_antenna(valid_tx_ant,
+ &search_tbl->current_rate, search_tbl))
+ goto out;
+ break;
+ case IWL_MIMO3_SWITCH_SISO_A:
+ case IWL_MIMO3_SWITCH_SISO_B:
+ case IWL_MIMO3_SWITCH_SISO_C:
+ IWL_DEBUG_RATE(priv, "LQ: MIMO3 switch to SISO\n");
+
+ /* Set up new search table for SISO */
+ memcpy(search_tbl, tbl, sz);
+
+ if (tbl->action == IWL_MIMO3_SWITCH_SISO_A)
+ search_tbl->ant_type = ANT_A;
+ else if (tbl->action == IWL_MIMO3_SWITCH_SISO_B)
+ search_tbl->ant_type = ANT_B;
+ else
+ search_tbl->ant_type = ANT_C;
+
+ if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
+ break;
+
+ ret = rs_switch_to_siso(priv, lq_sta, conf, sta,
+ search_tbl, index);
+ if (!ret)
+ goto out;
+
+ break;
+
+ case IWL_MIMO3_SWITCH_MIMO2_AB:
+ case IWL_MIMO3_SWITCH_MIMO2_AC:
+ case IWL_MIMO3_SWITCH_MIMO2_BC:
+ IWL_DEBUG_RATE(priv, "LQ: MIMO3 switch to MIMO2\n");
+
+ memcpy(search_tbl, tbl, sz);
+ search_tbl->is_SGI = 0;
+ if (tbl->action == IWL_MIMO3_SWITCH_MIMO2_AB)
+ search_tbl->ant_type = ANT_AB;
+ else if (tbl->action == IWL_MIMO3_SWITCH_MIMO2_AC)
+ search_tbl->ant_type = ANT_AC;
+ else
+ search_tbl->ant_type = ANT_BC;
+
+ if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
+ break;
+
+ ret = rs_switch_to_mimo2(priv, lq_sta, conf, sta,
+ search_tbl, index);
+ if (!ret)
+ goto out;
+
+ break;
+
+ case IWL_MIMO3_SWITCH_GI:
+ if (!tbl->is_fat &&
+ !(priv->current_ht_config.sgf &
+ HT_SHORT_GI_20MHZ))
+ break;
+ if (tbl->is_fat &&
+ !(priv->current_ht_config.sgf &
+ HT_SHORT_GI_40MHZ))
+ break;
+
+ IWL_DEBUG_RATE(priv, "LQ: MIMO3 toggle SGI/NGI\n");
+
+ /* Set up new search table for MIMO */
+ memcpy(search_tbl, tbl, sz);
+ search_tbl->is_SGI = !tbl->is_SGI;
+ rs_set_expected_tpt_table(lq_sta, search_tbl);
+ /*
+ * If active table already uses the fastest possible
+ * modulation (dual stream with short guard interval),
+ * and it's working well, there's no need to look
+ * for a better type of modulation!
+ */
+ if (tbl->is_SGI) {
+ s32 tpt = lq_sta->last_tpt / 100;
+ if (tpt >= search_tbl->expected_tpt[index])
+ break;
+ }
+ search_tbl->current_rate =
+ rate_n_flags_from_tbl(priv, search_tbl,
+ index, is_green);
+ update_search_tbl_counter = 1;
+ goto out;
+ }
+ tbl->action++;
+ if (tbl->action > IWL_MIMO3_SWITCH_GI)
+ tbl->action = IWL_MIMO3_SWITCH_ANTENNA1;
+
+ if (tbl->action == start_action)
+ break;
+ }
+ search_tbl->lq_type = LQ_NONE;
+ return 0;
+ out:
+ lq_sta->search_better_tbl = 1;
+ tbl->action++;
+ if (tbl->action > IWL_MIMO3_SWITCH_GI)
+ tbl->action = IWL_MIMO3_SWITCH_ANTENNA1;
+ if (update_search_tbl_counter)
+ search_tbl->action = tbl->action;
+
return 0;
}
@@ -1616,8 +1946,8 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
/* Elapsed time using current modulation mode */
if (lq_sta->flush_timer)
flush_interval_passed =
- time_after(jiffies,
- (unsigned long)(lq_sta->flush_timer +
+ time_after(jiffies,
+ (unsigned long)(lq_sta->flush_timer +
IWL_RATE_SCALE_FLUSH_INTVL));
/*
@@ -1676,12 +2006,14 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
* Do rate scaling and search for new modulation mode.
*/
static void rs_rate_scale_perform(struct iwl_priv *priv,
- struct ieee80211_hdr *hdr,
+ struct sk_buff *skb,
struct ieee80211_sta *sta,
struct iwl_lq_sta *lq_sta)
{
struct ieee80211_hw *hw = priv->hw;
struct ieee80211_conf *conf = &hw->conf;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
int low = IWL_RATE_INVALID;
int high = IWL_RATE_INVALID;
int index;
@@ -1707,11 +2039,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n");
- /* Send management frames and broadcast/multicast data using
- * lowest rate. */
+ /* Send management frames and NO_ACK data using lowest rate. */
/* TODO: this could probably be improved.. */
if (!ieee80211_is_data(hdr->frame_control) ||
- is_multicast_ether_addr(hdr->addr1))
+ info->flags & IEEE80211_TX_CTL_NO_ACK)
return;
if (!sta || !lq_sta)
@@ -1732,6 +2063,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
active_tbl = 1 - lq_sta->active_tbl;
tbl = &(lq_sta->lq_info[active_tbl]);
+ if (is_legacy(tbl->lq_type))
+ lq_sta->is_green = 0;
+ else
+ lq_sta->is_green = rs_use_green(priv, conf);
is_green = lq_sta->is_green;
/* current tx rate */
@@ -1951,6 +2286,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
update_lq = 1;
index = low;
}
+
break;
case 1:
/* Increase starting rate, update uCode's rate table */
@@ -1997,8 +2333,10 @@ lq_update:
rs_move_legacy_other(priv, lq_sta, conf, sta, index);
else if (is_siso(tbl->lq_type))
rs_move_siso_to_other(priv, lq_sta, conf, sta, index);
+ else if (is_mimo2(tbl->lq_type))
+ rs_move_mimo2_to_other(priv, lq_sta, conf, sta, index);
else
- rs_move_mimo_to_other(priv, lq_sta, conf, sta, index);
+ rs_move_mimo3_to_other(priv, lq_sta, conf, sta, index);
/* If new "search" mode was selected, set up in uCode table */
if (lq_sta->search_better_tbl) {
@@ -2014,8 +2352,11 @@ lq_update:
tbl->current_rate, index);
rs_fill_link_cmd(priv, lq_sta, tbl->current_rate);
iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC);
- }
+ } else
+ done_search = 1;
+ }
+ if (done_search && !lq_sta->stay_in_tbl) {
/* If the "active" (non-search) mode was legacy,
* and we've tried switching antennas,
* but we haven't been able to try HT modes (not available),
@@ -2023,8 +2364,7 @@ lq_update:
* before next round of mode comparisons. */
tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]);
if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) &&
- lq_sta->action_counter >= 1) {
- lq_sta->action_counter = 0;
+ lq_sta->action_counter > tbl1->max_search) {
IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n");
rs_set_stay_in_table(priv, 1, lq_sta);
}
@@ -2033,7 +2373,7 @@ lq_update:
* have been tried and compared, stay in this best modulation
* mode for a while before next round of mode comparisons. */
if (lq_sta->enable_counter &&
- (lq_sta->action_counter >= IWL_ACTION_LIMIT)) {
+ (lq_sta->action_counter >= tbl1->max_search)) {
if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) &&
(lq_sta->tx_agg_tid_en & (1 << tid)) &&
(tid != MAX_TID_COUNT)) {
@@ -2047,20 +2387,8 @@ lq_update:
lq_sta, sta);
}
}
- lq_sta->action_counter = 0;
rs_set_stay_in_table(priv, 0, lq_sta);
}
-
- /*
- * Else, don't search for a new modulation mode.
- * Put new timestamp in stay-in-modulation-mode flush timer if:
- * 1) Not changing rates right now
- * 2) Not just finishing up a search
- * 3) flush timer is empty
- */
- } else {
- if ((!update_lq) && (!done_search) && (!lq_sta->flush_timer))
- lq_sta->flush_timer = jiffies;
}
out:
@@ -2156,16 +2484,17 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
if (sta)
mask_bit = sta->supp_rates[sband->band];
- /* Send management frames and broadcast/multicast data using lowest
- * rate. */
+ /* Send management frames and NO_ACK data using lowest rate. */
if (!ieee80211_is_data(hdr->frame_control) ||
- is_multicast_ether_addr(hdr->addr1) || !sta || !lq_sta) {
+ info->flags & IEEE80211_TX_CTL_NO_ACK || !sta || !lq_sta) {
if (!mask_bit)
info->control.rates[0].idx =
rate_lowest_index(sband, NULL);
else
info->control.rates[0].idx =
rate_lowest_index(sband, sta);
+ if (info->flags & IEEE80211_TX_CTL_NO_ACK)
+ info->control.rates[0].count = 1;
return;
}
@@ -2173,13 +2502,15 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
!lq_sta->ibss_sta_added) {
- u8 sta_id = iwl_find_station(priv, hdr->addr1);
+ u8 sta_id = priv->cfg->ops->smgmt->find_station(priv,
+ hdr->addr1);
if (sta_id == IWL_INVALID_STATION) {
IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n",
hdr->addr1);
- sta_id = iwl_add_station_flags(priv, hdr->addr1,
- 0, CMD_ASYNC, NULL);
+ sta_id = priv->cfg->ops->smgmt->add_station(priv,
+ hdr->addr1, 0,
+ CMD_ASYNC, NULL);
}
if ((sta_id != IWL_INVALID_STATION)) {
lq_sta->lq.sta_id = sta_id;
@@ -2189,12 +2520,33 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
}
}
- if (rate_idx < 0 || rate_idx > IWL_RATE_COUNT)
- rate_idx = rate_lowest_index(sband, sta);
- else if (sband->band == IEEE80211_BAND_5GHZ)
+ if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) {
rate_idx -= IWL_FIRST_OFDM_RATE;
-
+ /* 6M and 9M shared same MCS index */
+ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0;
+ if (rs_extract_rate(lq_sta->last_rate_n_flags) >=
+ IWL_RATE_MIMO3_6M_PLCP)
+ rate_idx = rate_idx + (2 * MCS_INDEX_PER_STREAM);
+ else if (rs_extract_rate(lq_sta->last_rate_n_flags) >=
+ IWL_RATE_MIMO2_6M_PLCP)
+ rate_idx = rate_idx + MCS_INDEX_PER_STREAM;
+ info->control.rates[0].flags = IEEE80211_TX_RC_MCS;
+ if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK)
+ info->control.rates[0].flags |= IEEE80211_TX_RC_SHORT_GI;
+ if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK)
+ info->control.rates[0].flags |= IEEE80211_TX_RC_DUP_DATA;
+ if (lq_sta->last_rate_n_flags & RATE_MCS_FAT_MSK)
+ info->control.rates[0].flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
+ if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK)
+ info->control.rates[0].flags |= IEEE80211_TX_RC_GREEN_FIELD;
+ } else {
+ if (rate_idx < 0 || rate_idx > IWL_RATE_COUNT)
+ rate_idx = rate_lowest_index(sband, sta);
+ else if (sband->band == IEEE80211_BAND_5GHZ)
+ rate_idx -= IWL_FIRST_OFDM_RATE;
+ }
info->control.rates[0].idx = rate_idx;
+
}
static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
@@ -2246,15 +2598,17 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
lq_sta->ibss_sta_added = 0;
if (priv->iw_mode == NL80211_IFTYPE_AP) {
- u8 sta_id = iwl_find_station(priv, sta->addr);
+ u8 sta_id = priv->cfg->ops->smgmt->find_station(priv,
+ sta->addr);
/* for IBSS the call are from tasklet */
IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr);
if (sta_id == IWL_INVALID_STATION) {
IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr);
- sta_id = iwl_add_station_flags(priv, sta->addr,
- 0, CMD_ASYNC, NULL);
+ sta_id = priv->cfg->ops->smgmt->add_station(priv,
+ sta->addr, 0,
+ CMD_ASYNC, NULL);
}
if ((sta_id != IWL_INVALID_STATION)) {
lq_sta->lq.sta_id = sta_id;
@@ -2539,6 +2893,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
char *buff;
int desc = 0;
int i = 0;
+ int index = 0;
ssize_t ret;
struct iwl_lq_sta *lq_sta = file->private_data;
@@ -2568,8 +2923,11 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
((is_mimo2(tbl->lq_type)) ? "MIMO2" : "MIMO3"));
desc += sprintf(buff+desc, " %s",
(tbl->is_fat) ? "40MHz" : "20MHz");
- desc += sprintf(buff+desc, " %s\n", (tbl->is_SGI) ? "SGI" : "");
+ desc += sprintf(buff+desc, " %s %s\n", (tbl->is_SGI) ? "SGI" : "",
+ (lq_sta->is_green) ? "GF enabled" : "");
}
+ desc += sprintf(buff+desc, "last tx rate=0x%X\n",
+ lq_sta->last_rate_n_flags);
desc += sprintf(buff+desc, "general:"
"flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n",
lq_sta->lq.general_params.flags,
@@ -2590,10 +2948,19 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
lq_sta->lq.general_params.start_rate_index[2],
lq_sta->lq.general_params.start_rate_index[3]);
-
- for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
- desc += sprintf(buff+desc, " rate[%d] 0x%X\n",
- i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags));
+ for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
+ index = iwl_hwrate_to_plcp_idx(
+ le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags));
+ if (is_legacy(tbl->lq_type)) {
+ desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n",
+ i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags),
+ iwl_rate_mcs[index].mbps);
+ } else {
+ desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps (%s)\n",
+ i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags),
+ iwl_rate_mcs[index].mbps, iwl_rate_mcs[index].mcs);
+ }
+ }
ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
kfree(buff);
@@ -2620,13 +2987,14 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
return -ENOMEM;
for (i = 0; i < LQ_SIZE; i++) {
- desc += sprintf(buff+desc, "%s type=%d SGI=%d FAT=%d DUP=%d\n"
+ desc += sprintf(buff+desc, "%s type=%d SGI=%d FAT=%d DUP=%d GF=%d\n"
"rate=0x%X\n",
lq_sta->active_tbl == i ? "*" : "x",
lq_sta->lq_info[i].lq_type,
lq_sta->lq_info[i].is_SGI,
lq_sta->lq_info[i].is_fat,
lq_sta->lq_info[i].is_dup,
+ lq_sta->is_green,
lq_sta->lq_info[i].current_rate);
for (j = 0; j < IWL_RATE_COUNT; j++) {
desc += sprintf(buff+desc,
@@ -2646,6 +3014,43 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
.open = open_file_generic,
};
+static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
+ char __user *user_buf, size_t count, loff_t *ppos)
+{
+ char buff[120];
+ int desc = 0;
+ ssize_t ret;
+
+ struct iwl_lq_sta *lq_sta = file->private_data;
+ struct iwl_priv *priv;
+ struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl];
+
+ priv = lq_sta->drv;
+
+ if (is_Ht(tbl->lq_type))
+ desc += sprintf(buff+desc,
+ "Bit Rate= %d Mb/s\n",
+ tbl->expected_tpt[lq_sta->last_txrate_idx]);
+ else
+ desc += sprintf(buff+desc,
+ "Bit Rate= %d Mb/s\n",
+ iwl_rates[lq_sta->last_txrate_idx].ieee >> 1);
+ desc += sprintf(buff+desc,
+ "Signal Level= %d dBm\tNoise Level= %d dBm\n",
+ priv->last_rx_rssi, priv->last_rx_noise);
+ desc += sprintf(buff+desc,
+ "Tsf= 0x%llx\tBeacon time= 0x%08X\n",
+ priv->last_tsf, priv->last_beacon_time);
+
+ ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+ return ret;
+}
+
+static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
+ .read = rs_sta_dbgfs_rate_scale_data_read,
+ .open = open_file_generic,
+};
+
static void rs_add_debugfs(void *priv, void *priv_sta,
struct dentry *dir)
{
@@ -2656,6 +3061,9 @@ static void rs_add_debugfs(void *priv, void *priv_sta,
lq_sta->rs_sta_dbgfs_stats_table_file =
debugfs_create_file("rate_stats_table", 0600, dir,
lq_sta, &rs_sta_dbgfs_stats_table_ops);
+ lq_sta->rs_sta_dbgfs_rate_scale_data_file =
+ debugfs_create_file("rate_scale_data", 0600, dir,
+ lq_sta, &rs_sta_dbgfs_rate_scale_data_ops);
lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file =
debugfs_create_u8("tx_agg_tid_enable", 0600, dir,
&lq_sta->tx_agg_tid_en);
@@ -2667,6 +3075,7 @@ static void rs_remove_debugfs(void *priv, void *priv_sta)
struct iwl_lq_sta *lq_sta = priv_sta;
debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file);
debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file);
+ debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file);
debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file);
}
#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index ab59acc405d9..25050bf315a2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -241,6 +241,7 @@ enum {
#define IWL_LEGACY_SWITCH_MIMO2_AB 3
#define IWL_LEGACY_SWITCH_MIMO2_AC 4
#define IWL_LEGACY_SWITCH_MIMO2_BC 5
+#define IWL_LEGACY_SWITCH_MIMO3_ABC 6
/* possible actions when in siso mode */
#define IWL_SISO_SWITCH_ANTENNA1 0
@@ -249,6 +250,8 @@ enum {
#define IWL_SISO_SWITCH_MIMO2_AC 3
#define IWL_SISO_SWITCH_MIMO2_BC 4
#define IWL_SISO_SWITCH_GI 5
+#define IWL_SISO_SWITCH_MIMO3_ABC 6
+
/* possible actions when in mimo mode */
#define IWL_MIMO2_SWITCH_ANTENNA1 0
@@ -257,6 +260,23 @@ enum {
#define IWL_MIMO2_SWITCH_SISO_B 3
#define IWL_MIMO2_SWITCH_SISO_C 4
#define IWL_MIMO2_SWITCH_GI 5
+#define IWL_MIMO2_SWITCH_MIMO3_ABC 6
+
+
+/* possible actions when in mimo3 mode */
+#define IWL_MIMO3_SWITCH_ANTENNA1 0
+#define IWL_MIMO3_SWITCH_ANTENNA2 1
+#define IWL_MIMO3_SWITCH_SISO_A 2
+#define IWL_MIMO3_SWITCH_SISO_B 3
+#define IWL_MIMO3_SWITCH_SISO_C 4
+#define IWL_MIMO3_SWITCH_MIMO2_AB 5
+#define IWL_MIMO3_SWITCH_MIMO2_AC 6
+#define IWL_MIMO3_SWITCH_MIMO2_BC 7
+#define IWL_MIMO3_SWITCH_GI 8
+
+
+#define IWL_MAX_11N_MIMO3_SEARCH IWL_MIMO3_SWITCH_GI
+#define IWL_MAX_SEARCH IWL_MIMO2_SWITCH_MIMO3_ABC
/*FIXME:RS:add possible actions for MIMO3*/
@@ -307,6 +327,13 @@ enum iwl_table_type {
#define ANT_BC (ANT_B | ANT_C)
#define ANT_ABC (ANT_AB | ANT_C)
+#define IWL_MAX_MCS_DISPLAY_SIZE 12
+
+struct iwl_rate_mcs_info {
+ char mbps[IWL_MAX_MCS_DISPLAY_SIZE];
+ char mcs[IWL_MAX_MCS_DISPLAY_SIZE];
+};
+
static inline u8 num_of_ant(u8 mask)
{
return !!((mask) & ANT_A) +
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 3bb28db4a40f..0a5507cbeb3f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -102,7 +102,7 @@ MODULE_ALIAS("iwl4965");
* function correctly transitions out of the RXON_ASSOC_MSK state if
* a HW tune is required based on the RXON structure changes.
*/
-static int iwl_commit_rxon(struct iwl_priv *priv)
+int iwl_commit_rxon(struct iwl_priv *priv)
{
/* cast away the const for active_rxon in this function */
struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
@@ -188,10 +188,9 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
}
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
- if (!priv->error_recovering)
- priv->start_calib = 0;
+ priv->start_calib = 0;
/* Add the broadcast address so we can send broadcast frames */
if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) ==
@@ -246,8 +245,9 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
void iwl_update_chain_flags(struct iwl_priv *priv)
{
- iwl_set_rxon_chain(priv);
- iwl_commit_rxon(priv);
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+ iwlcore_commit_rxon(priv);
}
static void iwl_clear_free_frames(struct iwl_priv *priv)
@@ -503,24 +503,12 @@ int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
int iwl_hw_tx_queue_init(struct iwl_priv *priv,
struct iwl_tx_queue *txq)
{
- int ret;
- unsigned long flags;
int txq_id = txq->q.id;
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
-
/* Circular buffer (TFD queue in DRAM) physical base address */
iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id),
txq->q.dma_addr >> 8);
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
-
return 0;
}
@@ -531,76 +519,6 @@ int iwl_hw_tx_queue_init(struct iwl_priv *priv,
*
******************************************************************************/
-static void iwl_ht_conf(struct iwl_priv *priv,
- struct ieee80211_bss_conf *bss_conf)
-{
- struct ieee80211_sta_ht_cap *ht_conf;
- struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
- struct ieee80211_sta *sta;
-
- IWL_DEBUG_MAC80211(priv, "enter: \n");
-
- if (!iwl_conf->is_ht)
- return;
-
-
- /*
- * It is totally wrong to base global information on something
- * that is valid only when associated, alas, this driver works
- * that way and I don't know how to fix it.
- */
-
- rcu_read_lock();
- sta = ieee80211_find_sta(priv->hw, priv->bssid);
- if (!sta) {
- rcu_read_unlock();
- return;
- }
- ht_conf = &sta->ht_cap;
-
- if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20)
- iwl_conf->sgf |= HT_SHORT_GI_20MHZ;
- if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40)
- iwl_conf->sgf |= HT_SHORT_GI_40MHZ;
-
- iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD);
- iwl_conf->max_amsdu_size =
- !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU);
-
- iwl_conf->supported_chan_width =
- !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
-
- /*
- * XXX: The HT configuration needs to be moved into iwl_mac_config()
- * to be done there correctly.
- */
-
- iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
- if (conf_is_ht40_minus(&priv->hw->conf))
- iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
- else if (conf_is_ht40_plus(&priv->hw->conf))
- iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
-
- /* If no above or below channel supplied disable FAT channel */
- if (iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_ABOVE &&
- iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_BELOW)
- iwl_conf->supported_chan_width = 0;
-
- iwl_conf->sm_ps = (u8)((ht_conf->cap & IEEE80211_HT_CAP_SM_PS) >> 2);
-
- memcpy(&iwl_conf->mcs, &ht_conf->mcs, 16);
-
- iwl_conf->tx_chan_width = iwl_conf->supported_chan_width != 0;
- iwl_conf->ht_protection =
- bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
- iwl_conf->non_GF_STA_present =
- !!(bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
-
- rcu_read_unlock();
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-}
-
#define MAX_UCODE_BEACON_INTERVAL 4096
static u16 iwl_adjust_beacon_interval(u16 beacon_val)
@@ -636,7 +554,8 @@ static void iwl_setup_rxon_timing(struct iwl_priv *priv)
beacon_int = iwl_adjust_beacon_interval(priv->beacon_int);
priv->rxon_timing.atim_window = 0;
} else {
- beacon_int = iwl_adjust_beacon_interval(conf->beacon_int);
+ beacon_int = iwl_adjust_beacon_interval(
+ priv->vif->bss_conf.beacon_int);
/* TODO: we need to get atim_window from upper stack
* for now we set to 0 */
@@ -657,30 +576,6 @@ static void iwl_setup_rxon_timing(struct iwl_priv *priv)
le16_to_cpu(priv->rxon_timing.atim_window));
}
-static int iwl_set_mode(struct iwl_priv *priv, int mode)
-{
- iwl_connection_init_rx_config(priv, mode);
- iwl_set_rxon_chain(priv);
- memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
-
- iwl_clear_stations_table(priv);
-
- /* dont commit rxon if rf-kill is on*/
- if (!iwl_is_ready_rf(priv))
- return -EAGAIN;
-
- cancel_delayed_work(&priv->scan_check);
- if (iwl_scan_cancel_timeout(priv, 100)) {
- IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
- IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
- return -EAGAIN;
- }
-
- iwl_commit_rxon(priv);
-
- return 0;
-}
-
/******************************************************************************
*
* Generic RX handler implementations
@@ -802,6 +697,7 @@ static void iwl_rx_card_state_notif(struct iwl_priv *priv,
struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
unsigned long status = priv->status;
+ unsigned long reg_flags;
IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s\n",
(flags & HW_CARD_DISABLED) ? "Kill" : "On",
@@ -813,32 +709,25 @@ static void iwl_rx_card_state_notif(struct iwl_priv *priv,
iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
- if (!iwl_grab_nic_access(priv)) {
- iwl_write_direct32(
- priv, HBUS_TARG_MBX_C,
- HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
-
- iwl_release_nic_access(priv);
- }
+ iwl_write_direct32(priv, HBUS_TARG_MBX_C,
+ HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
if (!(flags & RXON_CARD_DISABLED)) {
iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
- if (!iwl_grab_nic_access(priv)) {
- iwl_write_direct32(
- priv, HBUS_TARG_MBX_C,
+ iwl_write_direct32(priv, HBUS_TARG_MBX_C,
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
- iwl_release_nic_access(priv);
- }
}
if (flags & RF_CARD_DISABLED) {
iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
iwl_read32(priv, CSR_UCODE_DRV_GP1);
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
if (!iwl_grab_nic_access(priv))
iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
}
@@ -867,14 +756,6 @@ static void iwl_rx_card_state_notif(struct iwl_priv *priv,
int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src)
{
- int ret;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret)
- goto err;
-
if (src == IWL_PWR_SRC_VAUX) {
if (pci_pme_capable(priv->pci_dev, PCI_D3cold))
iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
@@ -886,10 +767,7 @@ int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src)
~APMG_PS_CTRL_MSK_PWR_SRC);
}
- iwl_release_nic_access(priv);
-err:
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
+ return 0;
}
/**
@@ -953,6 +831,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
unsigned long flags;
u8 fill_rx = 0;
u32 count = 8;
+ int total_empty;
/* uCode's read index (stored in shared DRAM) indicates the last Rx
* buffer that the driver may process (last buffer filled by ucode). */
@@ -963,7 +842,12 @@ void iwl_rx_handle(struct iwl_priv *priv)
if (i == r)
IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i);
- if (iwl_rx_queue_space(rxq) > (RX_QUEUE_SIZE / 2))
+ /* calculate total frames need to be restock after handling RX */
+ total_empty = r - priv->rxq.write_actual;
+ if (total_empty < 0)
+ total_empty += RX_QUEUE_SIZE;
+
+ if (total_empty > (RX_QUEUE_SIZE / 2))
fill_rx = 1;
while (i != r) {
@@ -1002,6 +886,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r,
i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
+ priv->isr_stats.rx_handlers[pkt->hdr.cmd]++;
} else {
/* No handling needed */
IWL_DEBUG_RX(priv,
@@ -1039,7 +924,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
count++;
if (count >= 8) {
priv->rxq.read = i;
- iwl_rx_queue_restock(priv);
+ iwl_rx_replenish_now(priv);
count = 0;
}
}
@@ -1047,7 +932,10 @@ void iwl_rx_handle(struct iwl_priv *priv)
/* Backtrack one entry */
priv->rxq.read = i;
- iwl_rx_queue_restock(priv);
+ if (fill_rx)
+ iwl_rx_replenish_now(priv);
+ else
+ iwl_rx_queue_restock(priv);
}
/* call this function to flush any scheduled tasklet */
@@ -1058,24 +946,7 @@ static inline void iwl_synchronize_irq(struct iwl_priv *priv)
tasklet_kill(&priv->irq_tasklet);
}
-static void iwl_error_recovery(struct iwl_priv *priv)
-{
- unsigned long flags;
-
- memcpy(&priv->staging_rxon, &priv->recovery_rxon,
- sizeof(priv->staging_rxon));
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
-
- iwl_rxon_add_station(priv, priv->bssid, 1);
-
- spin_lock_irqsave(&priv->lock, flags);
- priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id);
- priv->error_recovering = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
-}
-
-static void iwl_irq_tasklet(struct iwl_priv *priv)
+static void iwl_irq_tasklet_legacy(struct iwl_priv *priv)
{
u32 inta, handled = 0;
u32 inta_fh;
@@ -1123,6 +994,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
/* Tell the device to stop sending interrupts */
iwl_disable_interrupts(priv);
+ priv->isr_stats.hw++;
iwl_irq_handle_error(priv);
handled |= CSR_INT_BIT_HW_ERR;
@@ -1135,13 +1007,17 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
#ifdef CONFIG_IWLWIFI_DEBUG
if (priv->debug_level & (IWL_DL_ISR)) {
/* NIC fires this, but we don't use it, redundant with WAKEUP */
- if (inta & CSR_INT_BIT_SCD)
+ if (inta & CSR_INT_BIT_SCD) {
IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
"the frame/frames.\n");
+ priv->isr_stats.sch++;
+ }
/* Alive notification via Rx interrupt will do the real work */
- if (inta & CSR_INT_BIT_ALIVE)
+ if (inta & CSR_INT_BIT_ALIVE) {
IWL_DEBUG_ISR(priv, "Alive interrupt\n");
+ priv->isr_stats.alive++;
+ }
}
#endif
/* Safely ignore these bits for debug checks below */
@@ -1157,6 +1033,8 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
IWL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n",
hw_rf_kill ? "disable radio" : "enable radio");
+ priv->isr_stats.rfkill++;
+
/* driver only loads ucode once setting the interface up.
* the driver allows loading the ucode even if the radio
* is killed. Hence update the killswitch state here. The
@@ -1176,6 +1054,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
/* Chip got too hot and stopped itself */
if (inta & CSR_INT_BIT_CT_KILL) {
IWL_ERR(priv, "Microcode CT kill error detected.\n");
+ priv->isr_stats.ctkill++;
handled |= CSR_INT_BIT_CT_KILL;
}
@@ -1183,6 +1062,8 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
if (inta & CSR_INT_BIT_SW_ERR) {
IWL_ERR(priv, "Microcode SW error detected. "
" Restarting 0x%X.\n", inta);
+ priv->isr_stats.sw++;
+ priv->isr_stats.sw_err = inta;
iwl_irq_handle_error(priv);
handled |= CSR_INT_BIT_SW_ERR;
}
@@ -1198,6 +1079,8 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
iwl_txq_update_write_ptr(priv, &priv->txq[4]);
iwl_txq_update_write_ptr(priv, &priv->txq[5]);
+ priv->isr_stats.wakeup++;
+
handled |= CSR_INT_BIT_WAKEUP;
}
@@ -1206,23 +1089,27 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
* notifications from uCode come through here*/
if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
iwl_rx_handle(priv);
+ priv->isr_stats.rx++;
handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
}
if (inta & CSR_INT_BIT_FH_TX) {
IWL_DEBUG_ISR(priv, "Tx interrupt\n");
+ priv->isr_stats.tx++;
handled |= CSR_INT_BIT_FH_TX;
/* FH finished to write, send event */
priv->ucode_write_complete = 1;
wake_up_interruptible(&priv->wait_command_queue);
}
- if (inta & ~handled)
+ if (inta & ~handled) {
IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
+ priv->isr_stats.unhandled++;
+ }
- if (inta & ~CSR_INI_SET_MASK) {
+ if (inta & ~(priv->inta_mask)) {
IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n",
- inta & ~CSR_INI_SET_MASK);
+ inta & ~priv->inta_mask);
IWL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh);
}
@@ -1243,6 +1130,200 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
spin_unlock_irqrestore(&priv->lock, flags);
}
+/* tasklet for iwlagn interrupt */
+static void iwl_irq_tasklet(struct iwl_priv *priv)
+{
+ u32 inta = 0;
+ u32 handled = 0;
+ unsigned long flags;
+#ifdef CONFIG_IWLWIFI_DEBUG
+ u32 inta_mask;
+#endif
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+ /* Ack/clear/reset pending uCode interrupts.
+ * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
+ */
+ iwl_write32(priv, CSR_INT, priv->inta);
+
+ inta = priv->inta;
+
+#ifdef CONFIG_IWLWIFI_DEBUG
+ if (priv->debug_level & IWL_DL_ISR) {
+ /* just for debug */
+ inta_mask = iwl_read32(priv, CSR_INT_MASK);
+ IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x\n ",
+ inta, inta_mask);
+ }
+#endif
+ /* saved interrupt in inta variable now we can reset priv->inta */
+ priv->inta = 0;
+
+ /* Now service all interrupt bits discovered above. */
+ if (inta & CSR_INT_BIT_HW_ERR) {
+ IWL_ERR(priv, "Microcode HW error detected. Restarting.\n");
+
+ /* Tell the device to stop sending interrupts */
+ iwl_disable_interrupts(priv);
+
+ priv->isr_stats.hw++;
+ iwl_irq_handle_error(priv);
+
+ handled |= CSR_INT_BIT_HW_ERR;
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ return;
+ }
+
+#ifdef CONFIG_IWLWIFI_DEBUG
+ if (priv->debug_level & (IWL_DL_ISR)) {
+ /* NIC fires this, but we don't use it, redundant with WAKEUP */
+ if (inta & CSR_INT_BIT_SCD) {
+ IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
+ "the frame/frames.\n");
+ priv->isr_stats.sch++;
+ }
+
+ /* Alive notification via Rx interrupt will do the real work */
+ if (inta & CSR_INT_BIT_ALIVE) {
+ IWL_DEBUG_ISR(priv, "Alive interrupt\n");
+ priv->isr_stats.alive++;
+ }
+ }
+#endif
+ /* Safely ignore these bits for debug checks below */
+ inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
+
+ /* HW RF KILL switch toggled */
+ if (inta & CSR_INT_BIT_RF_KILL) {
+ int hw_rf_kill = 0;
+ if (!(iwl_read32(priv, CSR_GP_CNTRL) &
+ CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
+ hw_rf_kill = 1;
+
+ IWL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n",
+ hw_rf_kill ? "disable radio" : "enable radio");
+
+ priv->isr_stats.rfkill++;
+
+ /* driver only loads ucode once setting the interface up.
+ * the driver allows loading the ucode even if the radio
+ * is killed. Hence update the killswitch state here. The
+ * rfkill handler will care about restarting if needed.
+ */
+ if (!test_bit(STATUS_ALIVE, &priv->status)) {
+ if (hw_rf_kill)
+ set_bit(STATUS_RF_KILL_HW, &priv->status);
+ else
+ clear_bit(STATUS_RF_KILL_HW, &priv->status);
+ queue_work(priv->workqueue, &priv->rf_kill);
+ }
+
+ handled |= CSR_INT_BIT_RF_KILL;
+ }
+
+ /* Chip got too hot and stopped itself */
+ if (inta & CSR_INT_BIT_CT_KILL) {
+ IWL_ERR(priv, "Microcode CT kill error detected.\n");
+ priv->isr_stats.ctkill++;
+ handled |= CSR_INT_BIT_CT_KILL;
+ }
+
+ /* Error detected by uCode */
+ if (inta & CSR_INT_BIT_SW_ERR) {
+ IWL_ERR(priv, "Microcode SW error detected. "
+ " Restarting 0x%X.\n", inta);
+ priv->isr_stats.sw++;
+ priv->isr_stats.sw_err = inta;
+ iwl_irq_handle_error(priv);
+ handled |= CSR_INT_BIT_SW_ERR;
+ }
+
+ /* uCode wakes up after power-down sleep */
+ if (inta & CSR_INT_BIT_WAKEUP) {
+ IWL_DEBUG_ISR(priv, "Wakeup interrupt\n");
+ iwl_rx_queue_update_write_ptr(priv, &priv->rxq);
+ iwl_txq_update_write_ptr(priv, &priv->txq[0]);
+ iwl_txq_update_write_ptr(priv, &priv->txq[1]);
+ iwl_txq_update_write_ptr(priv, &priv->txq[2]);
+ iwl_txq_update_write_ptr(priv, &priv->txq[3]);
+ iwl_txq_update_write_ptr(priv, &priv->txq[4]);
+ iwl_txq_update_write_ptr(priv, &priv->txq[5]);
+
+ priv->isr_stats.wakeup++;
+
+ handled |= CSR_INT_BIT_WAKEUP;
+ }
+
+ /* All uCode command responses, including Tx command responses,
+ * Rx "responses" (frame-received notification), and other
+ * notifications from uCode come through here*/
+ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX |
+ CSR_INT_BIT_RX_PERIODIC)) {
+ IWL_DEBUG_ISR(priv, "Rx interrupt\n");
+ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
+ handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
+ iwl_write32(priv, CSR_FH_INT_STATUS,
+ CSR49_FH_INT_RX_MASK);
+ }
+ if (inta & CSR_INT_BIT_RX_PERIODIC) {
+ handled |= CSR_INT_BIT_RX_PERIODIC;
+ iwl_write32(priv, CSR_INT, CSR_INT_BIT_RX_PERIODIC);
+ }
+ /* Sending RX interrupt require many steps to be done in the
+ * the device:
+ * 1- write interrupt to current index in ICT table.
+ * 2- dma RX frame.
+ * 3- update RX shared data to indicate last write index.
+ * 4- send interrupt.
+ * This could lead to RX race, driver could receive RX interrupt
+ * but the shared data changes does not reflect this.
+ * this could lead to RX race, RX periodic will solve this race
+ */
+ iwl_write32(priv, CSR_INT_PERIODIC_REG,
+ CSR_INT_PERIODIC_DIS);
+ iwl_rx_handle(priv);
+ /* Only set RX periodic if real RX is received. */
+ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX))
+ iwl_write32(priv, CSR_INT_PERIODIC_REG,
+ CSR_INT_PERIODIC_ENA);
+
+ priv->isr_stats.rx++;
+ }
+
+ if (inta & CSR_INT_BIT_FH_TX) {
+ iwl_write32(priv, CSR_FH_INT_STATUS, CSR49_FH_INT_TX_MASK);
+ IWL_DEBUG_ISR(priv, "Tx interrupt\n");
+ priv->isr_stats.tx++;
+ handled |= CSR_INT_BIT_FH_TX;
+ /* FH finished to write, send event */
+ priv->ucode_write_complete = 1;
+ wake_up_interruptible(&priv->wait_command_queue);
+ }
+
+ if (inta & ~handled) {
+ IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
+ priv->isr_stats.unhandled++;
+ }
+
+ if (inta & ~(priv->inta_mask)) {
+ IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n",
+ inta & ~priv->inta_mask);
+ }
+
+
+ /* Re-enable all interrupts */
+ /* only Re-enable if diabled by irq */
+ if (test_bit(STATUS_INT_ENABLED, &priv->status))
+ iwl_enable_interrupts(priv);
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+}
+
+
/******************************************************************************
*
* uCode download functions
@@ -1508,10 +1589,6 @@ static int iwl_read_ucode(struct iwl_priv *priv)
return ret;
}
-/* temporary */
-static int iwl_mac_beacon_update(struct ieee80211_hw *hw,
- struct sk_buff *skb);
-
/**
* iwl_alive_start - called after REPLY_ALIVE notification received
* from protocol/runtime uCode (initialization uCode's
@@ -1540,7 +1617,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
goto restart;
}
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
ret = priv->cfg->ops->lib->alive_notify(priv);
if (ret) {
IWL_WARN(priv,
@@ -1568,7 +1645,10 @@ static void iwl_alive_start(struct iwl_priv *priv)
} else {
/* Initialize our rx_config data */
iwl_connection_init_rx_config(priv, priv->iw_mode);
- iwl_set_rxon_chain(priv);
+
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
}
@@ -1578,7 +1658,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
iwl_reset_run_time_calib(priv);
/* Configure the adapter for unassociated operation */
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
/* At this point, the NIC is initialized and operational */
iwl_rf_kill_ct_config(priv);
@@ -1589,9 +1669,6 @@ static void iwl_alive_start(struct iwl_priv *priv)
set_bit(STATUS_READY, &priv->status);
wake_up_interruptible(&priv->wait_command_queue);
- if (priv->error_recovering)
- iwl_error_recovery(priv);
-
iwl_power_update_mode(priv, 1);
/* reassociate for ADHOC mode */
@@ -1626,7 +1703,7 @@ static void __iwl_down(struct iwl_priv *priv)
iwl_leds_unregister(priv);
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
/* Unblock any waiting calls */
wake_up_interruptible_all(&priv->wait_command_queue);
@@ -1649,7 +1726,7 @@ static void __iwl_down(struct iwl_priv *priv)
ieee80211_stop_queues(priv->hw);
/* If we have not previously called iwl_init() then
- * clear all bits but the RF Kill and SUSPEND bits and return */
+ * clear all bits but the RF Kill bits and return */
if (!iwl_is_init(priv)) {
priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) <<
STATUS_RF_KILL_HW |
@@ -1657,28 +1734,26 @@ static void __iwl_down(struct iwl_priv *priv)
STATUS_RF_KILL_SW |
test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
STATUS_GEO_CONFIGURED |
- test_bit(STATUS_IN_SUSPEND, &priv->status) <<
- STATUS_IN_SUSPEND |
test_bit(STATUS_EXIT_PENDING, &priv->status) <<
STATUS_EXIT_PENDING;
goto exit;
}
- /* ...otherwise clear out all the status bits but the RF Kill and
- * SUSPEND bits and continue taking the NIC down. */
+ /* ...otherwise clear out all the status bits but the RF Kill
+ * bits and continue taking the NIC down. */
priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) <<
STATUS_RF_KILL_HW |
test_bit(STATUS_RF_KILL_SW, &priv->status) <<
STATUS_RF_KILL_SW |
test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
STATUS_GEO_CONFIGURED |
- test_bit(STATUS_IN_SUSPEND, &priv->status) <<
- STATUS_IN_SUSPEND |
test_bit(STATUS_FW_ERROR, &priv->status) <<
STATUS_FW_ERROR |
test_bit(STATUS_EXIT_PENDING, &priv->status) <<
STATUS_EXIT_PENDING;
+ /* device going down, Stop using ICT table */
+ iwl_disable_ict(priv);
spin_lock_irqsave(&priv->lock, flags);
iwl_clear_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
@@ -1687,18 +1762,13 @@ static void __iwl_down(struct iwl_priv *priv)
iwl_txq_ctx_stop(priv);
iwl_rxq_stop(priv);
- spin_lock_irqsave(&priv->lock, flags);
- if (!iwl_grab_nic_access(priv)) {
- iwl_write_prph(priv, APMG_CLK_DIS_REG,
- APMG_CLK_VAL_DMA_CLK_RQT);
- iwl_release_nic_access(priv);
- }
- spin_unlock_irqrestore(&priv->lock, flags);
+ iwl_write_prph(priv, APMG_CLK_DIS_REG,
+ APMG_CLK_VAL_DMA_CLK_RQT);
udelay(5);
/* FIXME: apm_ops.suspend(priv) */
- if (exit_pending || test_bit(STATUS_IN_SUSPEND, &priv->status))
+ if (exit_pending)
priv->cfg->ops->lib->apm_ops.stop(priv);
else
priv->cfg->ops->lib->apm_ops.reset(priv);
@@ -1722,6 +1792,49 @@ static void iwl_down(struct iwl_priv *priv)
iwl_cancel_deferred_work(priv);
}
+#define HW_READY_TIMEOUT (50)
+
+static int iwl_set_hw_ready(struct iwl_priv *priv)
+{
+ int ret = 0;
+
+ iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
+ CSR_HW_IF_CONFIG_REG_BIT_NIC_READY);
+
+ /* See if we got it */
+ ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
+ CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
+ CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
+ HW_READY_TIMEOUT);
+ if (ret != -ETIMEDOUT)
+ priv->hw_ready = true;
+ else
+ priv->hw_ready = false;
+
+ IWL_DEBUG_INFO(priv, "hardware %s\n",
+ (priv->hw_ready == 1) ? "ready" : "not ready");
+ return ret;
+}
+
+static int iwl_prepare_card_hw(struct iwl_priv *priv)
+{
+ int ret = 0;
+
+ IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter \n");
+
+ iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
+ CSR_HW_IF_CONFIG_REG_PREPARE);
+
+ ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
+ ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE,
+ CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000);
+
+ if (ret != -ETIMEDOUT)
+ iwl_set_hw_ready(priv);
+
+ return ret;
+}
+
#define MAX_HW_RESTARTS 5
static int __iwl_up(struct iwl_priv *priv)
@@ -1739,6 +1852,13 @@ static int __iwl_up(struct iwl_priv *priv)
return -EIO;
}
+ iwl_prepare_card_hw(priv);
+
+ if (!priv->hw_ready) {
+ IWL_WARN(priv, "Exit HW not ready\n");
+ return -EIO;
+ }
+
/* If platform's RF_KILL switch is NOT set to KILL */
if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
clear_bit(STATUS_RF_KILL_HW, &priv->status);
@@ -1767,6 +1887,8 @@ static int __iwl_up(struct iwl_priv *priv)
/* clear (again), then enable host interrupts */
iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
+ /* enable dram interrupt */
+ iwl_reset_ict(priv);
iwl_enable_interrupts(priv);
/* really make sure rfkill handshake bits are cleared */
@@ -1781,7 +1903,7 @@ static int __iwl_up(struct iwl_priv *priv)
for (i = 0; i < MAX_HW_RESTARTS; i++) {
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
/* load bootstrap state machine,
* load bootstrap program into processor's memory,
@@ -1794,9 +1916,6 @@ static int __iwl_up(struct iwl_priv *priv)
continue;
}
- /* Clear out the uCode error bit if it is set */
- clear_bit(STATUS_FW_ERROR, &priv->status);
-
/* start card; "initialize" will load runtime ucode */
iwl_nic_start(priv);
@@ -1891,8 +2010,17 @@ static void iwl_bg_restart(struct work_struct *data)
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return;
- iwl_down(priv);
- queue_work(priv->workqueue, &priv->up);
+ if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
+ mutex_lock(&priv->mutex);
+ priv->vif = NULL;
+ priv->is_open = 0;
+ mutex_unlock(&priv->mutex);
+ iwl_down(priv);
+ ieee80211_restart_hw(priv->hw);
+ } else {
+ iwl_down(priv);
+ queue_work(priv->workqueue, &priv->up);
+ }
}
static void iwl_bg_rx_replenish(struct work_struct *data)
@@ -1910,7 +2038,7 @@ static void iwl_bg_rx_replenish(struct work_struct *data)
#define IWL_DELAY_NEXT_SCAN (HZ*2)
-static void iwl_post_associate(struct iwl_priv *priv)
+void iwl_post_associate(struct iwl_priv *priv)
{
struct ieee80211_conf *conf = NULL;
int ret = 0;
@@ -1932,13 +2060,12 @@ static void iwl_post_associate(struct iwl_priv *priv)
if (!priv->vif || !priv->is_open)
return;
- iwl_power_cancel_timeout(priv);
iwl_scan_cancel_timeout(priv, 200);
conf = ieee80211_get_hw_conf(priv->hw);
priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
iwl_setup_rxon_timing(priv);
ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
@@ -1951,7 +2078,9 @@ static void iwl_post_associate(struct iwl_priv *priv)
iwl_set_rxon_ht(priv, &priv->current_ht_config);
- iwl_set_rxon_chain(priv);
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
@@ -1973,7 +2102,7 @@ static void iwl_post_associate(struct iwl_priv *priv)
}
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
switch (priv->iw_mode) {
case NL80211_IFTYPE_STATION:
@@ -2006,7 +2135,7 @@ static void iwl_post_associate(struct iwl_priv *priv)
* If chain noise has already been run, then we need to enable
* power management here */
if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE)
- iwl_power_enable_management(priv);
+ iwl_power_update_mode(priv, 0);
/* Enable Rx differential gain and sensitivity calibrations */
iwl_chain_noise_reset(priv);
@@ -2059,9 +2188,6 @@ static int iwl_mac_start(struct ieee80211_hw *hw)
IWL_DEBUG_INFO(priv, "Start UP work done.\n");
- if (test_bit(STATUS_IN_SUSPEND, &priv->status))
- return 0;
-
/* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
* mac80211 will not be run successfully. */
ret = wait_event_interruptible_timeout(priv->wait_command_queue,
@@ -2087,10 +2213,8 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
IWL_DEBUG_MAC80211(priv, "enter\n");
- if (!priv->is_open) {
- IWL_DEBUG_MAC80211(priv, "leave - skip\n");
+ if (!priv->is_open)
return;
- }
priv->is_open = 0;
@@ -2130,175 +2254,7 @@ static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
return NETDEV_TX_OK;
}
-static int iwl_mac_add_interface(struct ieee80211_hw *hw,
- struct ieee80211_if_init_conf *conf)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
-
- IWL_DEBUG_MAC80211(priv, "enter: type %d\n", conf->type);
-
- if (priv->vif) {
- IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
- return -EOPNOTSUPP;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
- priv->vif = conf->vif;
- priv->iw_mode = conf->type;
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- mutex_lock(&priv->mutex);
-
- if (conf->mac_addr) {
- IWL_DEBUG_MAC80211(priv, "Set %pM\n", conf->mac_addr);
- memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
- }
-
- if (iwl_set_mode(priv, conf->type) == -EAGAIN)
- /* we are not ready, will run again when ready */
- set_bit(STATUS_MODE_PENDING, &priv->status);
-
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
- return 0;
-}
-
-/**
- * iwl_mac_config - mac80211 config callback
- *
- * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to
- * be set inappropriately and the driver currently sets the hardware up to
- * use it whenever needed.
- */
-static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
-{
- struct iwl_priv *priv = hw->priv;
- const struct iwl_channel_info *ch_info;
- struct ieee80211_conf *conf = &hw->conf;
- unsigned long flags = 0;
- int ret = 0;
- u16 ch;
- int scan_active = 0;
-
- mutex_lock(&priv->mutex);
- IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n",
- conf->channel->hw_value, changed);
-
- if (unlikely(!priv->cfg->mod_params->disable_hw_scan &&
- test_bit(STATUS_SCANNING, &priv->status))) {
- scan_active = 1;
- IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
- }
-
-
- /* during scanning mac80211 will delay channel setting until
- * scan finish with changed = 0
- */
- if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) {
- if (scan_active)
- goto set_ch_out;
-
- ch = ieee80211_frequency_to_channel(conf->channel->center_freq);
- ch_info = iwl_get_channel_info(priv, conf->channel->band, ch);
- if (!is_channel_valid(ch_info)) {
- IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
- ret = -EINVAL;
- goto set_ch_out;
- }
-
- if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
- !is_channel_ibss(ch_info)) {
- IWL_ERR(priv, "channel %d in band %d not "
- "IBSS channel\n",
- conf->channel->hw_value, conf->channel->band);
- ret = -EINVAL;
- goto set_ch_out;
- }
-
- priv->current_ht_config.is_ht = conf_is_ht(conf);
-
- spin_lock_irqsave(&priv->lock, flags);
-
-
- /* if we are switching from ht to 2.4 clear flags
- * from any ht related info since 2.4 does not
- * support ht */
- if ((le16_to_cpu(priv->staging_rxon.channel) != ch))
- priv->staging_rxon.flags = 0;
-
- iwl_set_rxon_channel(priv, conf->channel);
-
- iwl_set_flags_for_band(priv, conf->channel->band);
- spin_unlock_irqrestore(&priv->lock, flags);
- set_ch_out:
- /* The list of supported rates and rate mask can be different
- * for each band; since the band may have changed, reset
- * the rate mask to what mac80211 lists */
- iwl_set_rate(priv);
- }
-
- if (changed & IEEE80211_CONF_CHANGE_PS) {
- if (conf->flags & IEEE80211_CONF_PS)
- ret = iwl_power_set_user_mode(priv, IWL_POWER_INDEX_3);
- else
- ret = iwl_power_set_user_mode(priv, IWL_POWER_MODE_CAM);
- if (ret)
- IWL_DEBUG_MAC80211(priv, "Error setting power level\n");
-
- }
-
- if (changed & IEEE80211_CONF_CHANGE_POWER) {
- IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
- priv->tx_power_user_lmt, conf->power_level);
-
- iwl_set_tx_power(priv, conf->power_level, false);
- }
-
- /* call to ensure that 4965 rx_chain is set properly in monitor mode */
- iwl_set_rxon_chain(priv);
-
- if (changed & IEEE80211_CONF_CHANGE_RADIO_ENABLED) {
- if (conf->radio_enabled &&
- iwl_radio_kill_sw_enable_radio(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF-KILL - "
- "waiting for uCode\n");
- goto out;
- }
-
- if (!conf->radio_enabled)
- iwl_radio_kill_sw_disable_radio(priv);
- }
-
- if (!conf->radio_enabled) {
- IWL_DEBUG_MAC80211(priv, "leave - radio disabled\n");
- goto out;
- }
-
- if (!iwl_is_ready(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
- goto out;
- }
-
- if (scan_active)
- goto out;
-
- if (memcmp(&priv->active_rxon,
- &priv->staging_rxon, sizeof(priv->staging_rxon)))
- iwl_commit_rxon(priv);
- else
- IWL_DEBUG_INFO(priv, "No re-sending same RXON configuration.\n");
-
-
-out:
- IWL_DEBUG_MAC80211(priv, "leave\n");
- mutex_unlock(&priv->mutex);
- return ret;
-}
-
-static void iwl_config_ap(struct iwl_priv *priv)
+void iwl_config_ap(struct iwl_priv *priv)
{
int ret = 0;
unsigned long flags;
@@ -2311,7 +2267,7 @@ static void iwl_config_ap(struct iwl_priv *priv)
/* RXON - unassoc (to set timing command) */
priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
/* RXON Timing */
iwl_setup_rxon_timing(priv);
@@ -2321,7 +2277,8 @@ static void iwl_config_ap(struct iwl_priv *priv)
IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
"Attempting to continue.\n");
- iwl_set_rxon_chain(priv);
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
/* FIXME: what should be the assoc_id for AP? */
priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
@@ -2347,7 +2304,7 @@ static void iwl_config_ap(struct iwl_priv *priv)
}
/* restore RXON assoc */
priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
spin_lock_irqsave(&priv->lock, flags);
iwl_activate_qos(priv, 1);
spin_unlock_irqrestore(&priv->lock, flags);
@@ -2360,194 +2317,6 @@ static void iwl_config_ap(struct iwl_priv *priv)
* clear sta table, add BCAST sta... */
}
-
-static int iwl_mac_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct iwl_priv *priv = hw->priv;
- int rc;
-
- if (conf == NULL)
- return -EIO;
-
- if (priv->vif != vif) {
- IWL_DEBUG_MAC80211(priv, "leave - priv->vif != vif\n");
- return 0;
- }
-
- if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
- conf->changed & IEEE80211_IFCC_BEACON) {
- struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
- if (!beacon)
- return -ENOMEM;
- mutex_lock(&priv->mutex);
- rc = iwl_mac_beacon_update(hw, beacon);
- mutex_unlock(&priv->mutex);
- if (rc)
- return rc;
- }
-
- if (!iwl_is_alive(priv))
- return -EAGAIN;
-
- mutex_lock(&priv->mutex);
-
- if (conf->bssid)
- IWL_DEBUG_MAC80211(priv, "bssid: %pM\n", conf->bssid);
-
-/*
- * very dubious code was here; the probe filtering flag is never set:
- *
- if (unlikely(test_bit(STATUS_SCANNING, &priv->status)) &&
- !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
- */
-
- if (priv->iw_mode == NL80211_IFTYPE_AP) {
- if (!conf->bssid) {
- conf->bssid = priv->mac_addr;
- memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
- IWL_DEBUG_MAC80211(priv, "bssid was set to: %pM\n",
- conf->bssid);
- }
- if (priv->ibss_beacon)
- dev_kfree_skb(priv->ibss_beacon);
-
- priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
- }
-
- if (iwl_is_rfkill(priv))
- goto done;
-
- if (conf->bssid && !is_zero_ether_addr(conf->bssid) &&
- !is_multicast_ether_addr(conf->bssid)) {
- /* If there is currently a HW scan going on in the background
- * then we need to cancel it else the RXON below will fail. */
- if (iwl_scan_cancel_timeout(priv, 100)) {
- IWL_WARN(priv, "Aborted scan still in progress "
- "after 100ms\n");
- IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
- mutex_unlock(&priv->mutex);
- return -EAGAIN;
- }
- memcpy(priv->staging_rxon.bssid_addr, conf->bssid, ETH_ALEN);
-
- /* TODO: Audit driver for usage of these members and see
- * if mac80211 deprecates them (priv->bssid looks like it
- * shouldn't be there, but I haven't scanned the IBSS code
- * to verify) - jpk */
- memcpy(priv->bssid, conf->bssid, ETH_ALEN);
-
- if (priv->iw_mode == NL80211_IFTYPE_AP)
- iwl_config_ap(priv);
- else {
- rc = iwl_commit_rxon(priv);
- if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
- iwl_rxon_add_station(
- priv, priv->active_rxon.bssid_addr, 1);
- }
-
- } else {
- iwl_scan_cancel_timeout(priv, 100);
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
- }
-
- done:
- IWL_DEBUG_MAC80211(priv, "leave\n");
- mutex_unlock(&priv->mutex);
-
- return 0;
-}
-
-static void iwl_mac_remove_interface(struct ieee80211_hw *hw,
- struct ieee80211_if_init_conf *conf)
-{
- struct iwl_priv *priv = hw->priv;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- mutex_lock(&priv->mutex);
-
- if (iwl_is_ready_rf(priv)) {
- iwl_scan_cancel_timeout(priv, 100);
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
- }
- if (priv->vif == conf->vif) {
- priv->vif = NULL;
- memset(priv->bssid, 0, ETH_ALEN);
- }
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-
-}
-
-#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
-static void iwl_bss_info_changed(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_bss_conf *bss_conf,
- u32 changes)
-{
- struct iwl_priv *priv = hw->priv;
-
- IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
-
- if (changes & BSS_CHANGED_ERP_PREAMBLE) {
- IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
- bss_conf->use_short_preamble);
- if (bss_conf->use_short_preamble)
- priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
- else
- priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
- }
-
- if (changes & BSS_CHANGED_ERP_CTS_PROT) {
- IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
- if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
- priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
- else
- priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
- }
-
- if (changes & BSS_CHANGED_HT) {
- iwl_ht_conf(priv, bss_conf);
- iwl_set_rxon_chain(priv);
- }
-
- if (changes & BSS_CHANGED_ASSOC) {
- IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
- /* This should never happen as this function should
- * never be called from interrupt context. */
- if (WARN_ON_ONCE(in_interrupt()))
- return;
- if (bss_conf->assoc) {
- priv->assoc_id = bss_conf->aid;
- priv->beacon_int = bss_conf->beacon_int;
- priv->power_data.dtim_period = bss_conf->dtim_period;
- priv->timestamp = bss_conf->timestamp;
- priv->assoc_capability = bss_conf->assoc_capability;
-
- /* we have just associated, don't start scan too early
- * leave time for EAPOL exchange to complete
- */
- priv->next_scan_jiffies = jiffies +
- IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
- mutex_lock(&priv->mutex);
- iwl_post_associate(priv);
- mutex_unlock(&priv->mutex);
- } else {
- priv->assoc_id = 0;
- IWL_DEBUG_MAC80211(priv, "DISASSOC %d\n", bss_conf->assoc);
- }
- } else if (changes && iwl_is_associated(priv) && priv->assoc_id) {
- IWL_DEBUG_MAC80211(priv, "Associated Changes %d\n", changes);
- iwl_send_rxon_assoc(priv);
- }
-
-}
-
static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
struct ieee80211_key_conf *keyconf, const u8 *addr,
u32 iv32, u16 *phase1key)
@@ -2579,7 +2348,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return -EOPNOTSUPP;
}
addr = sta ? sta->addr : iwl_bcast_addr;
- sta_id = iwl_find_station(priv, addr);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION) {
IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
addr);
@@ -2630,49 +2399,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return ret;
}
-static int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
- const struct ieee80211_tx_queue_params *params)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
- int q;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
- return -EIO;
- }
-
- if (queue >= AC_NUM) {
- IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
- return 0;
- }
-
- q = AC_NUM - 1 - queue;
-
- spin_lock_irqsave(&priv->lock, flags);
-
- priv->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min);
- priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max);
- priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
- priv->qos_data.def_qos_parm.ac[q].edca_txop =
- cpu_to_le16((params->txop * 32));
-
- priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
- priv->qos_data.qos_active = 1;
-
- if (priv->iw_mode == NL80211_IFTYPE_AP)
- iwl_activate_qos(priv, 1);
- else if (priv->assoc_id && iwl_is_associated(priv))
- iwl_activate_qos(priv, 0);
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
- return 0;
-}
-
static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
enum ieee80211_ampdu_mlme_action action,
struct ieee80211_sta *sta, u16 tid, u16 *ssn)
@@ -2715,41 +2441,6 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
return 0;
}
-static int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
- struct ieee80211_tx_queue_stats *stats)
-{
- struct iwl_priv *priv = hw->priv;
- int i, avail;
- struct iwl_tx_queue *txq;
- struct iwl_queue *q;
- unsigned long flags;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
- return -EIO;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
-
- for (i = 0; i < AC_NUM; i++) {
- txq = &priv->txq[i];
- q = &txq->q;
- avail = iwl_queue_space(q);
-
- stats[i].len = q->n_window - avail;
- stats[i].limit = q->n_window - q->high_mark;
- stats[i].count = q->n_window;
-
- }
- spin_unlock_irqrestore(&priv->lock, flags);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-
- return 0;
-}
-
static int iwl_mac_get_stats(struct ieee80211_hw *hw,
struct ieee80211_low_level_stats *stats)
{
@@ -2762,120 +2453,6 @@ static int iwl_mac_get_stats(struct ieee80211_hw *hw,
return 0;
}
-static void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
-
- mutex_lock(&priv->mutex);
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- spin_lock_irqsave(&priv->lock, flags);
- memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info));
- spin_unlock_irqrestore(&priv->lock, flags);
-
- iwl_reset_qos(priv);
-
- spin_lock_irqsave(&priv->lock, flags);
- priv->assoc_id = 0;
- priv->assoc_capability = 0;
- priv->assoc_station_added = 0;
-
- /* new association get rid of ibss beacon skb */
- if (priv->ibss_beacon)
- dev_kfree_skb(priv->ibss_beacon);
-
- priv->ibss_beacon = NULL;
-
- priv->beacon_int = priv->hw->conf.beacon_int;
- priv->timestamp = 0;
- if ((priv->iw_mode == NL80211_IFTYPE_STATION))
- priv->beacon_int = 0;
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
- mutex_unlock(&priv->mutex);
- return;
- }
-
- /* we are restarting association process
- * clear RXON_FILTER_ASSOC_MSK bit
- */
- if (priv->iw_mode != NL80211_IFTYPE_AP) {
- iwl_scan_cancel_timeout(priv, 100);
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl_commit_rxon(priv);
- }
-
- iwl_power_update_mode(priv, 0);
-
- /* Per mac80211.h: This is only used in IBSS mode... */
- if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
-
- /* switch to CAM during association period.
- * the ucode will block any association/authentication
- * frome during assiciation period if it can not hear
- * the AP because of PM. the timer enable PM back is
- * association do not complete
- */
- if (priv->hw->conf.channel->flags & (IEEE80211_CHAN_PASSIVE_SCAN |
- IEEE80211_CHAN_RADAR))
- iwl_power_disable_management(priv, 3000);
-
- IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
- mutex_unlock(&priv->mutex);
- return;
- }
-
- iwl_set_rate(priv);
-
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-}
-
-static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
- __le64 timestamp;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
- return -EIO;
- }
-
- if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
- IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
- return -EIO;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
-
- if (priv->ibss_beacon)
- dev_kfree_skb(priv->ibss_beacon);
-
- priv->ibss_beacon = skb;
-
- priv->assoc_id = 0;
- timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
- priv->timestamp = le64_to_cpu(timestamp);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
- spin_unlock_irqrestore(&priv->lock, flags);
-
- iwl_reset_qos(priv);
-
- iwl_post_associate(priv);
-
-
- return 0;
-}
-
/*****************************************************************************
*
* sysfs attributes
@@ -2895,7 +2472,7 @@ static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
static ssize_t show_debug_level(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "0x%08X\n", priv->debug_level);
}
@@ -2903,7 +2480,7 @@ static ssize_t store_debug_level(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
unsigned long val;
int ret;
@@ -2926,7 +2503,7 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
static ssize_t show_version(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
struct iwl_alive_resp *palive = &priv->card_alive;
ssize_t pos = 0;
u16 eeprom_ver;
@@ -2943,8 +2520,10 @@ static ssize_t show_version(struct device *d,
if (priv->eeprom) {
eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
- pos += sprintf(buf + pos, "EEPROM version: 0x%x\n",
- eeprom_ver);
+ pos += sprintf(buf + pos, "NVM Type: %s, version: 0x%x\n",
+ (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
+ ? "OTP" : "EEPROM", eeprom_ver);
+
} else {
pos += sprintf(buf + pos, "EEPROM not initialzed\n");
}
@@ -2957,7 +2536,7 @@ static DEVICE_ATTR(version, S_IWUSR | S_IRUGO, show_version, NULL);
static ssize_t show_temperature(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
if (!iwl_is_alive(priv))
return -EAGAIN;
@@ -2970,7 +2549,7 @@ static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL);
static ssize_t show_tx_power(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
if (!iwl_is_ready_rf(priv))
return sprintf(buf, "off\n");
@@ -2982,7 +2561,7 @@ static ssize_t store_tx_power(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
unsigned long val;
int ret;
@@ -3000,7 +2579,7 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
static ssize_t show_flags(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "0x%04X\n", priv->active_rxon.flags);
}
@@ -3009,7 +2588,7 @@ static ssize_t store_flags(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
unsigned long val;
u32 flags;
int ret = strict_strtoul(buf, 0, &val);
@@ -3025,7 +2604,7 @@ static ssize_t store_flags(struct device *d,
else {
IWL_DEBUG_INFO(priv, "Commit rxon.flags = 0x%04X\n", flags);
priv->staging_rxon.flags = cpu_to_le32(flags);
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
}
}
mutex_unlock(&priv->mutex);
@@ -3038,7 +2617,7 @@ static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, show_flags, store_flags);
static ssize_t show_filter_flags(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "0x%04X\n",
le32_to_cpu(priv->active_rxon.filter_flags));
@@ -3048,7 +2627,7 @@ static ssize_t store_filter_flags(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
unsigned long val;
u32 filter_flags;
int ret = strict_strtoul(buf, 0, &val);
@@ -3066,7 +2645,7 @@ static ssize_t store_filter_flags(struct device *d,
"0x%04X\n", filter_flags);
priv->staging_rxon.filter_flags =
cpu_to_le32(filter_flags);
- iwl_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
}
}
mutex_unlock(&priv->mutex);
@@ -3109,32 +2688,37 @@ static ssize_t show_power_level(struct device *d,
{
struct iwl_priv *priv = dev_get_drvdata(d);
int mode = priv->power_data.user_power_setting;
- int system = priv->power_data.system_power_setting;
int level = priv->power_data.power_mode;
char *p = buf;
- switch (system) {
- case IWL_POWER_SYS_AUTO:
- p += sprintf(p, "SYSTEM:auto");
- break;
- case IWL_POWER_SYS_AC:
- p += sprintf(p, "SYSTEM:ac");
- break;
- case IWL_POWER_SYS_BATTERY:
- p += sprintf(p, "SYSTEM:battery");
- break;
- }
-
- p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO) ?
- "fixed" : "auto");
- p += sprintf(p, "\tINDEX:%d", level);
- p += sprintf(p, "\n");
+ p += sprintf(p, "INDEX:%d\t", level);
+ p += sprintf(p, "USER:%d\n", mode);
return p - buf + 1;
}
static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level,
store_power_level);
+static ssize_t show_qos(struct device *d,
+ struct device_attribute *attr, char *buf)
+{
+ struct iwl_priv *priv = dev_get_drvdata(d);
+ char *p = buf;
+ int q;
+
+ for (q = 0; q < AC_NUM; q++) {
+ p += sprintf(p, "\tcw_min\tcw_max\taifsn\ttxop\n");
+ p += sprintf(p, "AC[%d]\t%u\t%u\t%u\t%u\n", q,
+ priv->qos_data.def_qos_parm.ac[q].cw_min,
+ priv->qos_data.def_qos_parm.ac[q].cw_max,
+ priv->qos_data.def_qos_parm.ac[q].aifsn,
+ priv->qos_data.def_qos_parm.ac[q].edca_txop);
+ }
+
+ return p - buf + 1;
+}
+
+static DEVICE_ATTR(qos, S_IRUGO, show_qos, NULL);
static ssize_t show_statistics(struct device *d,
struct device_attribute *attr, char *buf)
@@ -3197,7 +2781,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start);
iwl_setup_scan_deferred_work(priv);
- iwl_setup_power_deferred_work(priv);
if (priv->cfg->ops->lib->setup_deferred_work)
priv->cfg->ops->lib->setup_deferred_work(priv);
@@ -3206,8 +2789,12 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
priv->statistics_periodic.data = (unsigned long)priv;
priv->statistics_periodic.function = iwl_bg_statistics_periodic;
- tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
- iwl_irq_tasklet, (unsigned long)priv);
+ if (!priv->cfg->use_isr_legacy)
+ tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
+ iwl_irq_tasklet, (unsigned long)priv);
+ else
+ tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
+ iwl_irq_tasklet_legacy, (unsigned long)priv);
}
static void iwl_cancel_deferred_work(struct iwl_priv *priv)
@@ -3217,7 +2804,6 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
cancel_delayed_work_sync(&priv->init_alive_start);
cancel_delayed_work(&priv->scan_check);
- cancel_delayed_work_sync(&priv->set_power_save);
cancel_delayed_work(&priv->alive_start);
cancel_work_sync(&priv->beacon_update);
del_timer_sync(&priv->statistics_periodic);
@@ -3234,7 +2820,7 @@ static struct attribute *iwl_sysfs_entries[] = {
&dev_attr_debug_level.attr,
#endif
&dev_attr_version.attr,
-
+ &dev_attr_qos.attr,
NULL
};
@@ -3250,7 +2836,6 @@ static struct ieee80211_ops iwl_hw_ops = {
.add_interface = iwl_mac_add_interface,
.remove_interface = iwl_mac_remove_interface,
.config = iwl_mac_config,
- .config_interface = iwl_mac_config_interface,
.configure_filter = iwl_configure_filter,
.set_key = iwl_mac_set_key,
.update_tkip_key = iwl_mac_update_tkip_key,
@@ -3298,6 +2883,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
priv->cfg = cfg;
priv->pci_dev = pdev;
+ priv->inta_mask = CSR_INI_SET_MASK;
#ifdef CONFIG_IWLWIFI_DEBUG
priv->debug_level = priv->cfg->mod_params->debug;
@@ -3348,6 +2934,10 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
(unsigned long long) pci_resource_len(pdev, 0));
IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
+ /* this spin lock will be used in apm_ops.init and EEPROM access
+ * we should init now
+ */
+ spin_lock_init(&priv->reg_lock);
iwl_hw_detect(priv);
IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n",
priv->cfg->name, priv->hw_rev);
@@ -3356,6 +2946,12 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
* PCI Tx retries from interfering with C3 CPU state */
pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
+ iwl_prepare_card_hw(priv);
+ if (!priv->hw_ready) {
+ IWL_WARN(priv, "Failed, HW not ready\n");
+ goto out_iounmap;
+ }
+
/* amp init */
err = priv->cfg->ops->lib->apm_ops.init(priv);
if (err < 0) {
@@ -3397,18 +2993,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto out_free_eeprom;
/* At this point both hw and priv are initialized. */
- /**********************************
- * 7. Initialize module parameters
- **********************************/
-
- /* Disable radio (SW RF KILL) via parameter when loading driver */
- if (priv->cfg->mod_params->disable) {
- set_bit(STATUS_RF_KILL_SW, &priv->status);
- IWL_DEBUG_INFO(priv, "Radio disabled.\n");
- }
-
/********************
- * 8. Setup services
+ * 7. Setup services
********************/
spin_lock_irqsave(&priv->lock, flags);
iwl_disable_interrupts(priv);
@@ -3416,8 +3002,9 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_enable_msi(priv->pci_dev);
- err = request_irq(priv->pci_dev->irq, iwl_isr, IRQF_SHARED,
- DRV_NAME, priv);
+ iwl_alloc_isr_ict(priv);
+ err = request_irq(priv->pci_dev->irq, priv->cfg->ops->lib->isr,
+ IRQF_SHARED, DRV_NAME, priv);
if (err) {
IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq);
goto out_disable_msi;
@@ -3432,7 +3019,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
iwl_setup_rx_handlers(priv);
/**********************************
- * 9. Setup and register mac80211
+ * 8. Setup and register mac80211
**********************************/
/* enable interrupts if needed: hw bug w/a */
@@ -3450,7 +3037,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err = iwl_dbgfs_register(priv, DRV_NAME);
if (err)
- IWL_ERR(priv, "failed to create debugfs files\n");
+ IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
/* If platform's RF_KILL switch is NOT set to KILL */
if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
@@ -3474,6 +3061,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group);
out_free_irq:
free_irq(priv->pci_dev->irq, priv);
+ iwl_free_isr_ict(priv);
out_disable_msi:
pci_disable_msi(priv->pci_dev);
iwl_uninit_drv(priv);
@@ -3533,7 +3121,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
iwl_rx_queue_free(priv, &priv->rxq);
iwl_hw_txq_ctx_free(priv);
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
iwl_eeprom_free(priv);
@@ -3555,51 +3143,14 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
iwl_uninit_drv(priv);
+ iwl_free_isr_ict(priv);
+
if (priv->ibss_beacon)
dev_kfree_skb(priv->ibss_beacon);
ieee80211_free_hw(priv->hw);
}
-#ifdef CONFIG_PM
-
-static int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
-{
- struct iwl_priv *priv = pci_get_drvdata(pdev);
-
- if (priv->is_open) {
- set_bit(STATUS_IN_SUSPEND, &priv->status);
- iwl_mac_stop(priv->hw);
- priv->is_open = 1;
- }
-
- pci_save_state(pdev);
- pci_disable_device(pdev);
- pci_set_power_state(pdev, PCI_D3hot);
-
- return 0;
-}
-
-static int iwl_pci_resume(struct pci_dev *pdev)
-{
- struct iwl_priv *priv = pci_get_drvdata(pdev);
- int ret;
-
- pci_set_power_state(pdev, PCI_D0);
- ret = pci_enable_device(pdev);
- if (ret)
- return ret;
- pci_restore_state(pdev);
- iwl_enable_interrupts(priv);
-
- if (priv->is_open)
- iwl_mac_start(priv->hw);
-
- clear_bit(STATUS_IN_SUSPEND, &priv->status);
- return 0;
-}
-
-#endif /* CONFIG_PM */
/*****************************************************************************
*
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 735f3f19928c..a5d63672ad39 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -857,7 +857,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
priv->cfg->ops->lib->update_chain_flags(priv);
data->state = IWL_CHAIN_NOISE_DONE;
- iwl_power_enable_management(priv);
+ iwl_power_update_mode(priv, 0);
}
EXPORT_SYMBOL(iwl_chain_noise_calibration);
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 29d40746da6a..e581dc323f0a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -614,8 +614,18 @@ enum {
#define RXON_FLG_CHANNEL_MODE_POS (25)
#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
-#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK cpu_to_le32(0x1 << 25)
-#define RXON_FLG_CHANNEL_MODE_MIXED_MSK cpu_to_le32(0x2 << 25)
+
+/* channel mode */
+enum {
+ CHANNEL_MODE_LEGACY = 0,
+ CHANNEL_MODE_PURE_40 = 1,
+ CHANNEL_MODE_MIXED = 2,
+ CHANNEL_MODE_RESERVED = 3,
+};
+#define RXON_FLG_CHANNEL_MODE_LEGACY cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
+#define RXON_FLG_CHANNEL_MODE_PURE_40 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
+#define RXON_FLG_CHANNEL_MODE_MIXED cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
+
/* CTS to self (if spec allows) flag */
#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
@@ -2469,11 +2479,12 @@ struct iwl_ssid_ie {
u8 ssid[32];
} __attribute__ ((packed));
-#define PROBE_OPTION_MAX_API1 0x4
-#define PROBE_OPTION_MAX 0x14
+#define PROBE_OPTION_MAX_3945 4
+#define PROBE_OPTION_MAX 20
#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
#define IWL_GOOD_CRC_TH cpu_to_le16(1)
#define IWL_MAX_SCAN_SIZE 1024
+#define IWL_MAX_PROBE_REQUEST 200
/*
* REPLY_SCAN_CMD = 0x80 (command)
@@ -2552,7 +2563,7 @@ struct iwl3945_scan_cmd {
struct iwl3945_tx_cmd tx_cmd;
/* For directed active scans (set to all-0s otherwise) */
- struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_API1];
+ struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
/*
* Probe request frame, followed by channel list.
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index c54fb93e9d72..e93ddb74457e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -39,6 +39,7 @@
#include "iwl-rfkill.h"
#include "iwl-power.h"
#include "iwl-sta.h"
+#include "iwl-helpers.h"
MODULE_DESCRIPTION("iwl core");
@@ -59,6 +60,8 @@ MODULE_LICENSE("GPL");
IWL_RATE_##pp##M_INDEX, \
IWL_RATE_##np##M_INDEX }
+static irqreturn_t iwl_isr(int irq, void *data);
+
/*
* Parameter order:
* rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate
@@ -273,6 +276,14 @@ void iwl_activate_qos(struct iwl_priv *priv, u8 force)
}
EXPORT_SYMBOL(iwl_activate_qos);
+/*
+ * AC CWmin CW max AIFSN TXOP Limit TXOP Limit
+ * (802.11b) (802.11a/g)
+ * AC_BK 15 1023 7 0 0
+ * AC_BE 15 1023 3 0 0
+ * AC_VI 7 15 2 6.016ms 3.008ms
+ * AC_VO 3 7 2 3.264ms 1.504ms
+ */
void iwl_reset_qos(struct iwl_priv *priv)
{
u16 cw_min = 15;
@@ -304,6 +315,7 @@ void iwl_reset_qos(struct iwl_priv *priv)
if (priv->qos_data.qos_active)
aifs = 3;
+ /* AC_BE */
priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
@@ -311,6 +323,7 @@ void iwl_reset_qos(struct iwl_priv *priv)
priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
if (priv->qos_data.qos_active) {
+ /* AC_BK */
i = 1;
priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
@@ -318,11 +331,12 @@ void iwl_reset_qos(struct iwl_priv *priv)
priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
+ /* AC_VI */
i = 2;
priv->qos_data.def_qos_parm.ac[i].cw_min =
cpu_to_le16((cw_min + 1) / 2 - 1);
priv->qos_data.def_qos_parm.ac[i].cw_max =
- cpu_to_le16(cw_max);
+ cpu_to_le16(cw_min);
priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
if (is_legacy)
priv->qos_data.def_qos_parm.ac[i].edca_txop =
@@ -332,11 +346,12 @@ void iwl_reset_qos(struct iwl_priv *priv)
cpu_to_le16(3008);
priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
+ /* AC_VO */
i = 3;
priv->qos_data.def_qos_parm.ac[i].cw_min =
cpu_to_le16((cw_min + 1) / 4 - 1);
priv->qos_data.def_qos_parm.ac[i].cw_max =
- cpu_to_le16((cw_max + 1) / 2 - 1);
+ cpu_to_le16((cw_min + 1) / 2 - 1);
priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
if (is_legacy)
@@ -591,10 +606,10 @@ static u8 iwl_is_channel_extension(struct iwl_priv *priv,
if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE)
return !(ch_info->fat_extension_channel &
- IEEE80211_CHAN_NO_FAT_ABOVE);
+ IEEE80211_CHAN_NO_HT40PLUS);
else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW)
return !(ch_info->fat_extension_channel &
- IEEE80211_CHAN_NO_FAT_BELOW);
+ IEEE80211_CHAN_NO_HT40MINUS);
return 0;
}
@@ -605,19 +620,23 @@ u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv,
struct iwl_ht_info *iwl_ht_conf = &priv->current_ht_config;
if ((!iwl_ht_conf->is_ht) ||
- (iwl_ht_conf->supported_chan_width != IWL_CHANNEL_WIDTH_40MHZ) ||
- (iwl_ht_conf->extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE))
+ (iwl_ht_conf->supported_chan_width != IWL_CHANNEL_WIDTH_40MHZ))
return 0;
+ /* We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40
+ * the bit will not set if it is pure 40MHz case
+ */
if (sta_ht_inf) {
- if ((!sta_ht_inf->ht_supported) ||
- (!(sta_ht_inf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)))
+ if (!sta_ht_inf->ht_supported)
return 0;
}
- return iwl_is_channel_extension(priv, priv->band,
- le16_to_cpu(priv->staging_rxon.channel),
- iwl_ht_conf->extension_chan_offset);
+ if (iwl_ht_conf->ht_protection & IEEE80211_HT_OP_MODE_PROTECTION_20MHZ)
+ return 1;
+ else
+ return iwl_is_channel_extension(priv, priv->band,
+ le16_to_cpu(priv->staging_rxon.channel),
+ iwl_ht_conf->extension_chan_offset);
}
EXPORT_SYMBOL(iwl_is_fat_tx_allowed);
@@ -735,6 +754,8 @@ int iwl_full_rxon_required(struct iwl_priv *priv)
priv->active_rxon.ofdm_ht_single_stream_basic_rates) ||
(priv->staging_rxon.ofdm_ht_dual_stream_basic_rates !=
priv->active_rxon.ofdm_ht_dual_stream_basic_rates) ||
+ (priv->staging_rxon.ofdm_ht_triple_stream_basic_rates !=
+ priv->active_rxon.ofdm_ht_triple_stream_basic_rates) ||
(priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id))
return 1;
@@ -785,43 +806,53 @@ EXPORT_SYMBOL(iwl_rate_get_lowest_plcp);
void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
{
struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
- u32 val;
if (!ht_info->is_ht) {
- rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
- RXON_FLG_CHANNEL_MODE_PURE_40_MSK |
+ rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
RXON_FLG_FAT_PROT_MSK |
RXON_FLG_HT_PROT_MSK);
return;
}
- /* Set up channel bandwidth: 20 MHz only, or 20/40 mixed if fat ok */
- if (iwl_is_fat_tx_allowed(priv, NULL))
- rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED_MSK;
- else
- rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
- RXON_FLG_CHANNEL_MODE_PURE_40_MSK);
-
- /* Note: control channel is opposite of extension channel */
- switch (ht_info->extension_chan_offset) {
- case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
- rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
- break;
- case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
- rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
- break;
- case IEEE80211_HT_PARAM_CHA_SEC_NONE:
- default:
- rxon->flags &= ~RXON_FLG_CHANNEL_MODE_MIXED_MSK;
- break;
+ /* FIXME: if the definition of ht_protection changed, the "translation"
+ * will be needed for rxon->flags
+ */
+ rxon->flags |= cpu_to_le32(ht_info->ht_protection << RXON_FLG_HT_OPERATING_MODE_POS);
+
+ /* Set up channel bandwidth:
+ * 20 MHz only, 20/40 mixed or pure 40 if fat ok */
+ /* clear the HT channel mode before set the mode */
+ rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
+ RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
+ if (iwl_is_fat_tx_allowed(priv, NULL)) {
+ /* pure 40 fat */
+ if (rxon->flags & RXON_FLG_FAT_PROT_MSK)
+ rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40;
+ else {
+ /* Note: control channel is opposite of extension channel */
+ switch (ht_info->extension_chan_offset) {
+ case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
+ rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
+ rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
+ break;
+ case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
+ rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
+ rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
+ break;
+ case IEEE80211_HT_PARAM_CHA_SEC_NONE:
+ default:
+ /* channel location only valid if in Mixed mode */
+ IWL_ERR(priv, "invalid extension channel offset\n");
+ break;
+ }
+ }
+ } else {
+ rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY;
}
- val = ht_info->ht_protection;
-
- rxon->flags |= cpu_to_le32(val << RXON_FLG_HT_OPERATING_MODE_POS);
-
- iwl_set_rxon_chain(priv);
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
IWL_DEBUG_ASSOC(priv, "supported HT rate 0x%X 0x%X 0x%X "
"rxon flags 0x%X operation mode :0x%X "
@@ -901,10 +932,11 @@ static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
* never called for monitor mode. The only way mac80211 informs us about
* monitor mode is through configuring filters (call to configure_filter).
*/
-static bool iwl_is_monitor_mode(struct iwl_priv *priv)
+bool iwl_is_monitor_mode(struct iwl_priv *priv)
{
return !!(priv->staging_rxon.filter_flags & RXON_FILTER_PROMISC_MSK);
}
+EXPORT_SYMBOL(iwl_is_monitor_mode);
/**
* iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image
@@ -956,10 +988,10 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
if (iwl_is_monitor_mode(priv) &&
!(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) &&
((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)) {
- rx_chain = 0x07 << RXON_RX_CHAIN_VALID_POS;
- rx_chain |= 0x06 << RXON_RX_CHAIN_FORCE_SEL_POS;
- rx_chain |= 0x07 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
- rx_chain |= 0x01 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
+ rx_chain = ANT_ABC << RXON_RX_CHAIN_VALID_POS;
+ rx_chain |= ANT_BC << RXON_RX_CHAIN_FORCE_SEL_POS;
+ rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
+ rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
}
priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain);
@@ -1068,11 +1100,6 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
RXON_FILTER_ACCEPT_GRP_MSK;
break;
- case NL80211_IFTYPE_MONITOR:
- priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER;
- priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK |
- RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
- break;
default:
IWL_ERR(priv, "Unsupported interface type %d\n", mode);
break;
@@ -1111,16 +1138,18 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
priv->staging_rxon.cck_basic_rates =
(IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
- priv->staging_rxon.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
- RXON_FLG_CHANNEL_MODE_PURE_40_MSK);
+ /* clear both MIX and PURE40 mode flag */
+ priv->staging_rxon.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED |
+ RXON_FLG_CHANNEL_MODE_PURE_40);
memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN);
priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
+ priv->staging_rxon.ofdm_ht_triple_stream_basic_rates = 0xff;
}
EXPORT_SYMBOL(iwl_connection_init_rx_config);
-void iwl_set_rate(struct iwl_priv *priv)
+static void iwl_set_rate(struct iwl_priv *priv)
{
const struct ieee80211_supported_band *hw = NULL;
struct ieee80211_rate *rate;
@@ -1166,7 +1195,6 @@ void iwl_set_rate(struct iwl_priv *priv)
priv->staging_rxon.ofdm_basic_rates =
(IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
}
-EXPORT_SYMBOL(iwl_set_rate);
void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
{
@@ -1230,11 +1258,6 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
"Restarting adapter due to uCode error.\n");
- if (iwl_is_associated(priv)) {
- memcpy(&priv->recovery_rxon, &priv->active_rxon,
- sizeof(priv->recovery_rxon));
- priv->error_recovering = 1;
- }
if (priv->cfg->mod_params->restart_fw)
queue_work(priv->workqueue, &priv->restart);
}
@@ -1298,19 +1321,20 @@ int iwl_setup_mac(struct iwl_priv *priv)
hw->flags = IEEE80211_HW_SIGNAL_DBM |
IEEE80211_HW_NOISE_DBM |
IEEE80211_HW_AMPDU_AGGREGATION |
- IEEE80211_HW_SPECTRUM_MGMT |
- IEEE80211_HW_SUPPORTS_PS;
+ IEEE80211_HW_SPECTRUM_MGMT;
hw->wiphy->interface_modes =
BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC);
hw->wiphy->custom_regulatory = true;
- hw->wiphy->max_scan_ssids = 1;
+
+ hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
+ /* we create the 802.11 header and a zero-length SSID element */
+ hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2;
/* Default value; 4 EDCA QOS priorities */
hw->queues = 4;
- hw->conf.beacon_int = 100;
hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;
if (priv->bands[IEEE80211_BAND_2GHZ].n_channels)
@@ -1357,7 +1381,6 @@ int iwl_init_drv(struct iwl_priv *priv)
priv->ibss_beacon = NULL;
spin_lock_init(&priv->lock);
- spin_lock_init(&priv->power_data.lock);
spin_lock_init(&priv->sta_lock);
spin_lock_init(&priv->hcmd_lock);
@@ -1366,7 +1389,7 @@ int iwl_init_drv(struct iwl_priv *priv)
mutex_init(&priv->mutex);
/* Clear the driver's (not device's) station table */
- iwl_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
priv->data_retry_limit = -1;
priv->ieee_channels = NULL;
@@ -1378,7 +1401,9 @@ int iwl_init_drv(struct iwl_priv *priv)
priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED;
/* Choose which receivers/antennas to use */
- iwl_set_rxon_chain(priv);
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
iwl_init_scan_params(priv);
iwl_reset_qos(priv);
@@ -1475,11 +1500,272 @@ void iwl_enable_interrupts(struct iwl_priv *priv)
{
IWL_DEBUG_ISR(priv, "Enabling interrupts\n");
set_bit(STATUS_INT_ENABLED, &priv->status);
- iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
+ iwl_write32(priv, CSR_INT_MASK, priv->inta_mask);
}
EXPORT_SYMBOL(iwl_enable_interrupts);
-irqreturn_t iwl_isr(int irq, void *data)
+
+#define ICT_COUNT (PAGE_SIZE/sizeof(u32))
+
+/* Free dram table */
+void iwl_free_isr_ict(struct iwl_priv *priv)
+{
+ if (priv->ict_tbl_vir) {
+ pci_free_consistent(priv->pci_dev, (sizeof(u32) * ICT_COUNT) +
+ PAGE_SIZE, priv->ict_tbl_vir,
+ priv->ict_tbl_dma);
+ priv->ict_tbl_vir = NULL;
+ }
+}
+EXPORT_SYMBOL(iwl_free_isr_ict);
+
+
+/* allocate dram shared table it is a PAGE_SIZE aligned
+ * also reset all data related to ICT table interrupt.
+ */
+int iwl_alloc_isr_ict(struct iwl_priv *priv)
+{
+
+ if (priv->cfg->use_isr_legacy)
+ return 0;
+ /* allocate shrared data table */
+ priv->ict_tbl_vir = pci_alloc_consistent(priv->pci_dev, (sizeof(u32) *
+ ICT_COUNT) + PAGE_SIZE,
+ &priv->ict_tbl_dma);
+ if (!priv->ict_tbl_vir)
+ return -ENOMEM;
+
+ /* align table to PAGE_SIZE boundry */
+ priv->aligned_ict_tbl_dma = ALIGN(priv->ict_tbl_dma, PAGE_SIZE);
+
+ IWL_DEBUG_ISR(priv, "ict dma addr %Lx dma aligned %Lx diff %d\n",
+ (unsigned long long)priv->ict_tbl_dma,
+ (unsigned long long)priv->aligned_ict_tbl_dma,
+ (int)(priv->aligned_ict_tbl_dma - priv->ict_tbl_dma));
+
+ priv->ict_tbl = priv->ict_tbl_vir +
+ (priv->aligned_ict_tbl_dma - priv->ict_tbl_dma);
+
+ IWL_DEBUG_ISR(priv, "ict vir addr %p vir aligned %p diff %d\n",
+ priv->ict_tbl, priv->ict_tbl_vir,
+ (int)(priv->aligned_ict_tbl_dma - priv->ict_tbl_dma));
+
+ /* reset table and index to all 0 */
+ memset(priv->ict_tbl_vir,0, (sizeof(u32) * ICT_COUNT) + PAGE_SIZE);
+ priv->ict_index = 0;
+
+ /* add periodic RX interrupt */
+ priv->inta_mask |= CSR_INT_BIT_RX_PERIODIC;
+ return 0;
+}
+EXPORT_SYMBOL(iwl_alloc_isr_ict);
+
+/* Device is going up inform it about using ICT interrupt table,
+ * also we need to tell the driver to start using ICT interrupt.
+ */
+int iwl_reset_ict(struct iwl_priv *priv)
+{
+ u32 val;
+ unsigned long flags;
+
+ if (!priv->ict_tbl_vir)
+ return 0;
+
+ spin_lock_irqsave(&priv->lock, flags);
+ iwl_disable_interrupts(priv);
+
+ memset(&priv->ict_tbl[0],0, sizeof(u32) * ICT_COUNT);
+
+ val = priv->aligned_ict_tbl_dma >> PAGE_SHIFT;
+
+ val |= CSR_DRAM_INT_TBL_ENABLE;
+ val |= CSR_DRAM_INIT_TBL_WRAP_CHECK;
+
+ IWL_DEBUG_ISR(priv, "CSR_DRAM_INT_TBL_REG =0x%X "
+ "aligned dma address %Lx\n",
+ val, (unsigned long long)priv->aligned_ict_tbl_dma);
+
+ iwl_write32(priv, CSR_DRAM_INT_TBL_REG, val);
+ priv->use_ict = true;
+ priv->ict_index = 0;
+ iwl_write32(priv, CSR_INT, priv->inta_mask);
+ iwl_enable_interrupts(priv);
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ return 0;
+}
+EXPORT_SYMBOL(iwl_reset_ict);
+
+/* Device is going down disable ict interrupt usage */
+void iwl_disable_ict(struct iwl_priv *priv)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&priv->lock, flags);
+ priv->use_ict = false;
+ spin_unlock_irqrestore(&priv->lock, flags);
+}
+EXPORT_SYMBOL(iwl_disable_ict);
+
+/* interrupt handler using ict table, with this interrupt driver will
+ * stop using INTA register to get device's interrupt, reading this register
+ * is expensive, device will write interrupts in ICT dram table, increment
+ * index then will fire interrupt to driver, driver will OR all ICT table
+ * entries from current index up to table entry with 0 value. the result is
+ * the interrupt we need to service, driver will set the entries back to 0 and
+ * set index.
+ */
+irqreturn_t iwl_isr_ict(int irq, void *data)
+{
+ struct iwl_priv *priv = data;
+ u32 inta, inta_mask;
+ u32 val = 0;
+
+ if (!priv)
+ return IRQ_NONE;
+
+ /* dram interrupt table not set yet,
+ * use legacy interrupt.
+ */
+ if (!priv->use_ict)
+ return iwl_isr(irq, data);
+
+ spin_lock(&priv->lock);
+
+ /* Disable (but don't clear!) interrupts here to avoid
+ * back-to-back ISRs and sporadic interrupts from our NIC.
+ * If we have something to service, the tasklet will re-enable ints.
+ * If we *don't* have something, we'll re-enable before leaving here.
+ */
+ inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
+ iwl_write32(priv, CSR_INT_MASK, 0x00000000);
+
+
+ /* Ignore interrupt if there's nothing in NIC to service.
+ * This may be due to IRQ shared with another device,
+ * or due to sporadic interrupts thrown from our NIC. */
+ if (!priv->ict_tbl[priv->ict_index]) {
+ IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
+ goto none;
+ }
+
+ /* read all entries that not 0 start with ict_index */
+ while (priv->ict_tbl[priv->ict_index]) {
+
+ val |= priv->ict_tbl[priv->ict_index];
+ IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n",
+ priv->ict_index,
+ priv->ict_tbl[priv->ict_index]);
+ priv->ict_tbl[priv->ict_index] = 0;
+ priv->ict_index = iwl_queue_inc_wrap(priv->ict_index,
+ ICT_COUNT);
+
+ }
+
+ /* We should not get this value, just ignore it. */
+ if (val == 0xffffffff)
+ val = 0;
+
+ inta = (0xff & val) | ((0xff00 & val) << 16);
+ IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x ict 0x%08x\n",
+ inta, inta_mask, val);
+
+ inta &= priv->inta_mask;
+ priv->inta |= inta;
+
+ /* iwl_irq_tasklet() will service interrupts and re-enable them */
+ if (likely(inta))
+ tasklet_schedule(&priv->irq_tasklet);
+ else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta) {
+ /* Allow interrupt if was disabled by this handler and
+ * no tasklet was schedules, We should not enable interrupt,
+ * tasklet will enable it.
+ */
+ iwl_enable_interrupts(priv);
+ }
+
+ spin_unlock(&priv->lock);
+ return IRQ_HANDLED;
+
+ none:
+ /* re-enable interrupts here since we don't have anything to service.
+ * only Re-enable if disabled by irq.
+ */
+ if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
+ iwl_enable_interrupts(priv);
+
+ spin_unlock(&priv->lock);
+ return IRQ_NONE;
+}
+EXPORT_SYMBOL(iwl_isr_ict);
+
+
+static irqreturn_t iwl_isr(int irq, void *data)
+{
+ struct iwl_priv *priv = data;
+ u32 inta, inta_mask;
+ u32 inta_fh;
+
+ if (!priv)
+ return IRQ_NONE;
+
+ spin_lock(&priv->lock);
+
+ /* Disable (but don't clear!) interrupts here to avoid
+ * back-to-back ISRs and sporadic interrupts from our NIC.
+ * If we have something to service, the tasklet will re-enable ints.
+ * If we *don't* have something, we'll re-enable before leaving here. */
+ inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
+ iwl_write32(priv, CSR_INT_MASK, 0x00000000);
+
+ /* Discover which interrupts are active/pending */
+ inta = iwl_read32(priv, CSR_INT);
+
+ /* Ignore interrupt if there's nothing in NIC to service.
+ * This may be due to IRQ shared with another device,
+ * or due to sporadic interrupts thrown from our NIC. */
+ if (!inta) {
+ IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
+ goto none;
+ }
+
+ if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
+ /* Hardware disappeared. It might have already raised
+ * an interrupt */
+ IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
+ goto unplugged;
+ }
+
+#ifdef CONFIG_IWLWIFI_DEBUG
+ if (priv->debug_level & (IWL_DL_ISR)) {
+ inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
+ IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, "
+ "fh 0x%08x\n", inta, inta_mask, inta_fh);
+ }
+#endif
+
+ priv->inta |= inta;
+ /* iwl_irq_tasklet() will service interrupts and re-enable them */
+ if (likely(inta))
+ tasklet_schedule(&priv->irq_tasklet);
+ else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
+ iwl_enable_interrupts(priv);
+
+ unplugged:
+ spin_unlock(&priv->lock);
+ return IRQ_HANDLED;
+
+ none:
+ /* re-enable interrupts here since we don't have anything to service. */
+ /* only Re-enable if diabled by irq and no schedules tasklet. */
+ if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
+ iwl_enable_interrupts(priv);
+
+ spin_unlock(&priv->lock);
+ return IRQ_NONE;
+}
+
+irqreturn_t iwl_isr_legacy(int irq, void *data)
{
struct iwl_priv *priv = data;
u32 inta, inta_mask;
@@ -1536,7 +1822,7 @@ irqreturn_t iwl_isr(int irq, void *data)
spin_unlock(&priv->lock);
return IRQ_NONE;
}
-EXPORT_SYMBOL(iwl_isr);
+EXPORT_SYMBOL(iwl_isr_legacy);
int iwl_send_bt_config(struct iwl_priv *priv)
{
@@ -1580,10 +1866,6 @@ static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
-
for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
/* read data comes through single port, auto-incr addr */
/* NOTE: Use the debugless read so we don't flood kernel log
@@ -1599,8 +1881,6 @@ static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
}
}
- iwl_release_nic_access(priv);
-
return ret;
}
@@ -1618,10 +1898,6 @@ static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
-
iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
IWL49_RTC_INST_LOWER_BOUND);
@@ -1642,8 +1918,6 @@ static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
}
}
- iwl_release_nic_access(priv);
-
if (!errcnt)
IWL_DEBUG_INFO(priv,
"ucode image in INSTRUCTION memory is good\n");
@@ -1752,7 +2026,6 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
u32 data2, line;
u32 desc, time, count, base, data1;
u32 blink1, blink2, ilink1, ilink2;
- int ret;
if (priv->ucode_type == UCODE_INIT)
base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr);
@@ -1764,12 +2037,6 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
return;
}
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- IWL_WARN(priv, "Can not read from adapter at this time.\n");
- return;
- }
-
count = iwl_read_targ_mem(priv, base);
if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) {
@@ -1796,7 +2063,6 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
IWL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2,
ilink1, ilink2);
- iwl_release_nic_access(priv);
}
EXPORT_SYMBOL(iwl_dump_nic_error_log);
@@ -1805,7 +2071,6 @@ EXPORT_SYMBOL(iwl_dump_nic_error_log);
/**
* iwl_print_event_log - Dump error event log to syslog
*
- * NOTE: Must be called with iwl_grab_nic_access() already obtained!
*/
static void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
u32 num_events, u32 mode)
@@ -1851,7 +2116,6 @@ static void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
void iwl_dump_nic_event_log(struct iwl_priv *priv)
{
- int ret;
u32 base; /* SRAM byte address of event log header */
u32 capacity; /* event log capacity in # entries */
u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
@@ -1869,12 +2133,6 @@ void iwl_dump_nic_event_log(struct iwl_priv *priv)
return;
}
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- IWL_WARN(priv, "Can not read from adapter at this time.\n");
- return;
- }
-
/* event log header */
capacity = iwl_read_targ_mem(priv, base);
mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32)));
@@ -1886,7 +2144,6 @@ void iwl_dump_nic_event_log(struct iwl_priv *priv)
/* bail out if nothing in log */
if (size == 0) {
IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n");
- iwl_release_nic_access(priv);
return;
}
@@ -1901,7 +2158,6 @@ void iwl_dump_nic_event_log(struct iwl_priv *priv)
/* (then/else) start at top of log */
iwl_print_event_log(priv, 0, next_entry, mode);
- iwl_release_nic_access(priv);
}
EXPORT_SYMBOL(iwl_dump_nic_event_log);
@@ -2008,11 +2264,11 @@ int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv)
/* wake up ucode */
msleep(10);
- spin_lock_irqsave(&priv->lock, flags);
iwl_read32(priv, CSR_UCODE_DRV_GP1);
+ spin_lock_irqsave(&priv->reg_lock, flags);
if (!iwl_grab_nic_access(priv))
iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
+ spin_unlock_irqrestore(&priv->reg_lock, flags);
if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
IWL_DEBUG_RF_KILL(priv, "Can not turn radio back on - "
@@ -2054,7 +2310,7 @@ void iwl_bg_rf_kill(struct work_struct *work)
"HW and/or SW RF Kill no longer active, restarting "
"device\n");
if (!test_bit(STATUS_EXIT_PENDING, &priv->status) &&
- test_bit(STATUS_ALIVE, &priv->status))
+ priv->is_open)
queue_work(priv->workqueue, &priv->restart);
} else {
/* make sure mac80211 stop sending Tx frame */
@@ -2112,3 +2368,666 @@ void iwl_rx_reply_error(struct iwl_priv *priv,
}
EXPORT_SYMBOL(iwl_rx_reply_error);
+void iwl_clear_isr_stats(struct iwl_priv *priv)
+{
+ memset(&priv->isr_stats, 0, sizeof(priv->isr_stats));
+}
+EXPORT_SYMBOL(iwl_clear_isr_stats);
+
+int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
+ const struct ieee80211_tx_queue_params *params)
+{
+ struct iwl_priv *priv = hw->priv;
+ unsigned long flags;
+ int q;
+
+ IWL_DEBUG_MAC80211(priv, "enter\n");
+
+ if (!iwl_is_ready_rf(priv)) {
+ IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
+ return -EIO;
+ }
+
+ if (queue >= AC_NUM) {
+ IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
+ return 0;
+ }
+
+ q = AC_NUM - 1 - queue;
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+ priv->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min);
+ priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max);
+ priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
+ priv->qos_data.def_qos_parm.ac[q].edca_txop =
+ cpu_to_le16((params->txop * 32));
+
+ priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
+ priv->qos_data.qos_active = 1;
+
+ if (priv->iw_mode == NL80211_IFTYPE_AP)
+ iwl_activate_qos(priv, 1);
+ else if (priv->assoc_id && iwl_is_associated(priv))
+ iwl_activate_qos(priv, 0);
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+ return 0;
+}
+EXPORT_SYMBOL(iwl_mac_conf_tx);
+
+static void iwl_ht_conf(struct iwl_priv *priv,
+ struct ieee80211_bss_conf *bss_conf)
+{
+ struct ieee80211_sta_ht_cap *ht_conf;
+ struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
+ struct ieee80211_sta *sta;
+
+ IWL_DEBUG_MAC80211(priv, "enter: \n");
+
+ if (!iwl_conf->is_ht)
+ return;
+
+
+ /*
+ * It is totally wrong to base global information on something
+ * that is valid only when associated, alas, this driver works
+ * that way and I don't know how to fix it.
+ */
+
+ rcu_read_lock();
+ sta = ieee80211_find_sta(priv->hw, priv->bssid);
+ if (!sta) {
+ rcu_read_unlock();
+ return;
+ }
+ ht_conf = &sta->ht_cap;
+
+ if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20)
+ iwl_conf->sgf |= HT_SHORT_GI_20MHZ;
+ if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40)
+ iwl_conf->sgf |= HT_SHORT_GI_40MHZ;
+
+ iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD);
+ iwl_conf->max_amsdu_size =
+ !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU);
+
+ iwl_conf->supported_chan_width =
+ !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
+
+ /*
+ * XXX: The HT configuration needs to be moved into iwl_mac_config()
+ * to be done there correctly.
+ */
+
+ iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
+ if (conf_is_ht40_minus(&priv->hw->conf))
+ iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
+ else if (conf_is_ht40_plus(&priv->hw->conf))
+ iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
+
+ /* If no above or below channel supplied disable FAT channel */
+ if (iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_ABOVE &&
+ iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_BELOW)
+ iwl_conf->supported_chan_width = 0;
+
+ iwl_conf->sm_ps = (u8)((ht_conf->cap & IEEE80211_HT_CAP_SM_PS) >> 2);
+
+ memcpy(&iwl_conf->mcs, &ht_conf->mcs, 16);
+
+ iwl_conf->tx_chan_width = iwl_conf->supported_chan_width != 0;
+ iwl_conf->ht_protection =
+ bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
+ iwl_conf->non_GF_STA_present =
+ !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
+
+ rcu_read_unlock();
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+}
+
+#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
+void iwl_bss_info_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *bss_conf,
+ u32 changes)
+{
+ struct iwl_priv *priv = hw->priv;
+ int ret;
+
+ IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
+
+ if (!iwl_is_alive(priv))
+ return;
+
+ mutex_lock(&priv->mutex);
+
+ if (changes & BSS_CHANGED_BEACON &&
+ priv->iw_mode == NL80211_IFTYPE_AP) {
+ dev_kfree_skb(priv->ibss_beacon);
+ priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
+ }
+
+ if ((changes & BSS_CHANGED_BSSID) && !iwl_is_rfkill(priv)) {
+ /* If there is currently a HW scan going on in the background
+ * then we need to cancel it else the RXON below will fail. */
+ if (iwl_scan_cancel_timeout(priv, 100)) {
+ IWL_WARN(priv, "Aborted scan still in progress "
+ "after 100ms\n");
+ IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
+ mutex_unlock(&priv->mutex);
+ return;
+ }
+ memcpy(priv->staging_rxon.bssid_addr,
+ bss_conf->bssid, ETH_ALEN);
+
+ /* TODO: Audit driver for usage of these members and see
+ * if mac80211 deprecates them (priv->bssid looks like it
+ * shouldn't be there, but I haven't scanned the IBSS code
+ * to verify) - jpk */
+ memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
+
+ if (priv->iw_mode == NL80211_IFTYPE_AP)
+ iwlcore_config_ap(priv);
+ else {
+ int rc = iwlcore_commit_rxon(priv);
+ if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
+ iwl_rxon_add_station(
+ priv, priv->active_rxon.bssid_addr, 1);
+ }
+ } else if (!iwl_is_rfkill(priv)) {
+ iwl_scan_cancel_timeout(priv, 100);
+ priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
+ iwlcore_commit_rxon(priv);
+ }
+
+ if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
+ changes & BSS_CHANGED_BEACON) {
+ struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
+
+ if (beacon)
+ iwl_mac_beacon_update(hw, beacon);
+ }
+
+ mutex_unlock(&priv->mutex);
+
+ if (changes & BSS_CHANGED_ERP_PREAMBLE) {
+ IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
+ bss_conf->use_short_preamble);
+ if (bss_conf->use_short_preamble)
+ priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
+ else
+ priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
+ }
+
+ if (changes & BSS_CHANGED_ERP_CTS_PROT) {
+ IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
+ if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
+ priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
+ else
+ priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
+ }
+
+ if (changes & BSS_CHANGED_HT) {
+ iwl_ht_conf(priv, bss_conf);
+
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+ }
+
+ if (changes & BSS_CHANGED_ASSOC) {
+ IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
+ /* This should never happen as this function should
+ * never be called from interrupt context. */
+ if (WARN_ON_ONCE(in_interrupt()))
+ return;
+ if (bss_conf->assoc) {
+ priv->assoc_id = bss_conf->aid;
+ priv->beacon_int = bss_conf->beacon_int;
+ priv->power_data.dtim_period = bss_conf->dtim_period;
+ priv->timestamp = bss_conf->timestamp;
+ priv->assoc_capability = bss_conf->assoc_capability;
+
+ /* we have just associated, don't start scan too early
+ * leave time for EAPOL exchange to complete
+ */
+ priv->next_scan_jiffies = jiffies +
+ IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
+ mutex_lock(&priv->mutex);
+ priv->cfg->ops->lib->post_associate(priv);
+ mutex_unlock(&priv->mutex);
+ } else {
+ priv->assoc_id = 0;
+ IWL_DEBUG_MAC80211(priv, "DISASSOC %d\n", bss_conf->assoc);
+ }
+ } else if (changes && iwl_is_associated(priv) && priv->assoc_id) {
+ IWL_DEBUG_MAC80211(priv, "Associated Changes %d\n", changes);
+ ret = iwl_send_rxon_assoc(priv);
+ if (!ret)
+ /* Sync active_rxon with latest change. */
+ memcpy((void *)&priv->active_rxon,
+ &priv->staging_rxon,
+ sizeof(struct iwl_rxon_cmd));
+ }
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+}
+EXPORT_SYMBOL(iwl_bss_info_changed);
+
+int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+ struct iwl_priv *priv = hw->priv;
+ unsigned long flags;
+ __le64 timestamp;
+
+ IWL_DEBUG_MAC80211(priv, "enter\n");
+
+ if (!iwl_is_ready_rf(priv)) {
+ IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
+ return -EIO;
+ }
+
+ if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
+ IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
+ return -EIO;
+ }
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+ if (priv->ibss_beacon)
+ dev_kfree_skb(priv->ibss_beacon);
+
+ priv->ibss_beacon = skb;
+
+ priv->assoc_id = 0;
+ timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
+ priv->timestamp = le64_to_cpu(timestamp);
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ iwl_reset_qos(priv);
+
+ priv->cfg->ops->lib->post_associate(priv);
+
+
+ return 0;
+}
+EXPORT_SYMBOL(iwl_mac_beacon_update);
+
+int iwl_set_mode(struct iwl_priv *priv, int mode)
+{
+ if (mode == NL80211_IFTYPE_ADHOC) {
+ const struct iwl_channel_info *ch_info;
+
+ ch_info = iwl_get_channel_info(priv,
+ priv->band,
+ le16_to_cpu(priv->staging_rxon.channel));
+
+ if (!ch_info || !is_channel_ibss(ch_info)) {
+ IWL_ERR(priv, "channel %d not IBSS channel\n",
+ le16_to_cpu(priv->staging_rxon.channel));
+ return -EINVAL;
+ }
+ }
+
+ iwl_connection_init_rx_config(priv, mode);
+
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
+ memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
+
+ priv->cfg->ops->smgmt->clear_station_table(priv);
+
+ /* dont commit rxon if rf-kill is on*/
+ if (!iwl_is_ready_rf(priv))
+ return -EAGAIN;
+
+ cancel_delayed_work(&priv->scan_check);
+ if (iwl_scan_cancel_timeout(priv, 100)) {
+ IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
+ IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
+ return -EAGAIN;
+ }
+
+ iwlcore_commit_rxon(priv);
+
+ return 0;
+}
+EXPORT_SYMBOL(iwl_set_mode);
+
+int iwl_mac_add_interface(struct ieee80211_hw *hw,
+ struct ieee80211_if_init_conf *conf)
+{
+ struct iwl_priv *priv = hw->priv;
+ unsigned long flags;
+
+ IWL_DEBUG_MAC80211(priv, "enter: type %d\n", conf->type);
+
+ if (priv->vif) {
+ IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
+ return -EOPNOTSUPP;
+ }
+
+ spin_lock_irqsave(&priv->lock, flags);
+ priv->vif = conf->vif;
+ priv->iw_mode = conf->type;
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ mutex_lock(&priv->mutex);
+
+ if (conf->mac_addr) {
+ IWL_DEBUG_MAC80211(priv, "Set %pM\n", conf->mac_addr);
+ memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
+ }
+
+ if (iwl_set_mode(priv, conf->type) == -EAGAIN)
+ /* we are not ready, will run again when ready */
+ set_bit(STATUS_MODE_PENDING, &priv->status);
+
+ mutex_unlock(&priv->mutex);
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+ return 0;
+}
+EXPORT_SYMBOL(iwl_mac_add_interface);
+
+void iwl_mac_remove_interface(struct ieee80211_hw *hw,
+ struct ieee80211_if_init_conf *conf)
+{
+ struct iwl_priv *priv = hw->priv;
+
+ IWL_DEBUG_MAC80211(priv, "enter\n");
+
+ mutex_lock(&priv->mutex);
+
+ if (iwl_is_ready_rf(priv)) {
+ iwl_scan_cancel_timeout(priv, 100);
+ priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
+ iwlcore_commit_rxon(priv);
+ }
+ if (priv->vif == conf->vif) {
+ priv->vif = NULL;
+ memset(priv->bssid, 0, ETH_ALEN);
+ }
+ mutex_unlock(&priv->mutex);
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+
+}
+EXPORT_SYMBOL(iwl_mac_remove_interface);
+
+/**
+ * iwl_mac_config - mac80211 config callback
+ *
+ * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to
+ * be set inappropriately and the driver currently sets the hardware up to
+ * use it whenever needed.
+ */
+int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
+{
+ struct iwl_priv *priv = hw->priv;
+ const struct iwl_channel_info *ch_info;
+ struct ieee80211_conf *conf = &hw->conf;
+ unsigned long flags = 0;
+ int ret = 0;
+ u16 ch;
+ int scan_active = 0;
+
+ mutex_lock(&priv->mutex);
+
+ IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n",
+ conf->channel->hw_value, changed);
+
+ if (unlikely(!priv->cfg->mod_params->disable_hw_scan &&
+ test_bit(STATUS_SCANNING, &priv->status))) {
+ scan_active = 1;
+ IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
+ }
+
+
+ /* during scanning mac80211 will delay channel setting until
+ * scan finish with changed = 0
+ */
+ if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) {
+ if (scan_active)
+ goto set_ch_out;
+
+ ch = ieee80211_frequency_to_channel(conf->channel->center_freq);
+ ch_info = iwl_get_channel_info(priv, conf->channel->band, ch);
+ if (!is_channel_valid(ch_info)) {
+ IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
+ ret = -EINVAL;
+ goto set_ch_out;
+ }
+
+ if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
+ !is_channel_ibss(ch_info)) {
+ IWL_ERR(priv, "channel %d in band %d not "
+ "IBSS channel\n",
+ conf->channel->hw_value, conf->channel->band);
+ ret = -EINVAL;
+ goto set_ch_out;
+ }
+
+ priv->current_ht_config.is_ht = conf_is_ht(conf);
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+
+ /* if we are switching from ht to 2.4 clear flags
+ * from any ht related info since 2.4 does not
+ * support ht */
+ if ((le16_to_cpu(priv->staging_rxon.channel) != ch))
+ priv->staging_rxon.flags = 0;
+
+ iwl_set_rxon_channel(priv, conf->channel);
+
+ iwl_set_flags_for_band(priv, conf->channel->band);
+ spin_unlock_irqrestore(&priv->lock, flags);
+ set_ch_out:
+ /* The list of supported rates and rate mask can be different
+ * for each band; since the band may have changed, reset
+ * the rate mask to what mac80211 lists */
+ iwl_set_rate(priv);
+ }
+
+ if (changed & IEEE80211_CONF_CHANGE_PS &&
+ priv->iw_mode == NL80211_IFTYPE_STATION) {
+ priv->power_data.power_disabled =
+ !(conf->flags & IEEE80211_CONF_PS);
+ ret = iwl_power_update_mode(priv, 0);
+ if (ret)
+ IWL_DEBUG_MAC80211(priv, "Error setting power level\n");
+ }
+
+ if (changed & IEEE80211_CONF_CHANGE_POWER) {
+ IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
+ priv->tx_power_user_lmt, conf->power_level);
+
+ iwl_set_tx_power(priv, conf->power_level, false);
+ }
+
+ /* call to ensure that 4965 rx_chain is set properly in monitor mode */
+ if (priv->cfg->ops->hcmd->set_rxon_chain)
+ priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
+ if (changed & IEEE80211_CONF_CHANGE_RADIO_ENABLED) {
+ if (conf->radio_enabled &&
+ iwl_radio_kill_sw_enable_radio(priv)) {
+ IWL_DEBUG_MAC80211(priv, "leave - RF-KILL - "
+ "waiting for uCode\n");
+ goto out;
+ }
+
+ if (!conf->radio_enabled)
+ iwl_radio_kill_sw_disable_radio(priv);
+ }
+
+ if (!conf->radio_enabled) {
+ IWL_DEBUG_MAC80211(priv, "leave - radio disabled\n");
+ goto out;
+ }
+
+ if (!iwl_is_ready(priv)) {
+ IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
+ goto out;
+ }
+
+ if (scan_active)
+ goto out;
+
+ if (memcmp(&priv->active_rxon,
+ &priv->staging_rxon, sizeof(priv->staging_rxon)))
+ iwlcore_commit_rxon(priv);
+ else
+ IWL_DEBUG_INFO(priv, "Not re-sending same RXON configuration.\n");
+
+
+out:
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+ mutex_unlock(&priv->mutex);
+ return ret;
+}
+EXPORT_SYMBOL(iwl_mac_config);
+
+int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
+ struct ieee80211_tx_queue_stats *stats)
+{
+ struct iwl_priv *priv = hw->priv;
+ int i, avail;
+ struct iwl_tx_queue *txq;
+ struct iwl_queue *q;
+ unsigned long flags;
+
+ IWL_DEBUG_MAC80211(priv, "enter\n");
+
+ if (!iwl_is_ready_rf(priv)) {
+ IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
+ return -EIO;
+ }
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+ for (i = 0; i < AC_NUM; i++) {
+ txq = &priv->txq[i];
+ q = &txq->q;
+ avail = iwl_queue_space(q);
+
+ stats[i].len = q->n_window - avail;
+ stats[i].limit = q->n_window - q->high_mark;
+ stats[i].count = q->n_window;
+
+ }
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+
+ return 0;
+}
+EXPORT_SYMBOL(iwl_mac_get_tx_stats);
+
+void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
+{
+ struct iwl_priv *priv = hw->priv;
+ unsigned long flags;
+
+ mutex_lock(&priv->mutex);
+ IWL_DEBUG_MAC80211(priv, "enter\n");
+
+ spin_lock_irqsave(&priv->lock, flags);
+ memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info));
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ iwl_reset_qos(priv);
+
+ spin_lock_irqsave(&priv->lock, flags);
+ priv->assoc_id = 0;
+ priv->assoc_capability = 0;
+ priv->assoc_station_added = 0;
+
+ /* new association get rid of ibss beacon skb */
+ if (priv->ibss_beacon)
+ dev_kfree_skb(priv->ibss_beacon);
+
+ priv->ibss_beacon = NULL;
+
+ priv->beacon_int = priv->vif->bss_conf.beacon_int;
+ priv->timestamp = 0;
+ if ((priv->iw_mode == NL80211_IFTYPE_STATION))
+ priv->beacon_int = 0;
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ if (!iwl_is_ready_rf(priv)) {
+ IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
+ mutex_unlock(&priv->mutex);
+ return;
+ }
+
+ /* we are restarting association process
+ * clear RXON_FILTER_ASSOC_MSK bit
+ */
+ if (priv->iw_mode != NL80211_IFTYPE_AP) {
+ iwl_scan_cancel_timeout(priv, 100);
+ priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
+ iwlcore_commit_rxon(priv);
+ }
+
+ if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
+ IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
+ mutex_unlock(&priv->mutex);
+ return;
+ }
+
+ iwl_set_rate(priv);
+
+ mutex_unlock(&priv->mutex);
+
+ IWL_DEBUG_MAC80211(priv, "leave\n");
+}
+EXPORT_SYMBOL(iwl_mac_reset_tsf);
+
+#ifdef CONFIG_PM
+
+int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+ struct iwl_priv *priv = pci_get_drvdata(pdev);
+
+ /*
+ * This function is called when system goes into suspend state
+ * mac80211 will call iwl_mac_stop() from the mac80211 suspend function
+ * first but since iwl_mac_stop() has no knowledge of who the caller is,
+ * it will not call apm_ops.stop() to stop the DMA operation.
+ * Calling apm_ops.stop here to make sure we stop the DMA.
+ */
+ priv->cfg->ops->lib->apm_ops.stop(priv);
+
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, PCI_D3hot);
+
+ return 0;
+}
+EXPORT_SYMBOL(iwl_pci_suspend);
+
+int iwl_pci_resume(struct pci_dev *pdev)
+{
+ struct iwl_priv *priv = pci_get_drvdata(pdev);
+ int ret;
+
+ pci_set_power_state(pdev, PCI_D0);
+ ret = pci_enable_device(pdev);
+ if (ret)
+ return ret;
+ pci_restore_state(pdev);
+ iwl_enable_interrupts(priv);
+
+ return 0;
+}
+EXPORT_SYMBOL(iwl_pci_resume);
+
+#endif /* CONFIG_PM */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index a8eac8c3c1fa..87df1b767941 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -83,9 +83,21 @@ struct iwl_cmd;
#define IWL_SKU_A 0x2
#define IWL_SKU_N 0x8
+struct iwl_station_mgmt_ops {
+ u8 (*add_station)(struct iwl_priv *priv, const u8 *addr,
+ int is_ap, u8 flags, struct ieee80211_sta_ht_cap *ht_info);
+ int (*remove_station)(struct iwl_priv *priv, const u8 *addr,
+ int is_ap);
+ u8 (*find_station)(struct iwl_priv *priv, const u8 *addr);
+ void (*clear_station_table)(struct iwl_priv *priv);
+};
+
struct iwl_hcmd_ops {
int (*rxon_assoc)(struct iwl_priv *priv);
+ int (*commit_rxon)(struct iwl_priv *priv);
+ void (*set_rxon_chain)(struct iwl_priv *priv);
};
+
struct iwl_hcmd_utils_ops {
u16 (*get_hcmd_size)(u8 cmd_id, u16 len);
u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data);
@@ -100,6 +112,19 @@ struct iwl_hcmd_utils_ops {
struct iwl_rx_phy_res *rx_resp);
};
+struct iwl_apm_ops {
+ int (*init)(struct iwl_priv *priv);
+ int (*reset)(struct iwl_priv *priv);
+ void (*stop)(struct iwl_priv *priv);
+ void (*config)(struct iwl_priv *priv);
+ int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src);
+};
+
+struct iwl_temp_ops {
+ void (*temperature)(struct iwl_priv *priv);
+ void (*set_ct_kill)(struct iwl_priv *priv);
+};
+
struct iwl_lib_ops {
/* set hw dependent parameters */
int (*set_hw_params)(struct iwl_priv *priv);
@@ -137,30 +162,31 @@ struct iwl_lib_ops {
int (*is_valid_rtc_data_addr)(u32 addr);
/* 1st ucode load */
int (*load_ucode)(struct iwl_priv *priv);
- /* power management */
- struct {
- int (*init)(struct iwl_priv *priv);
- int (*reset)(struct iwl_priv *priv);
- void (*stop)(struct iwl_priv *priv);
- void (*config)(struct iwl_priv *priv);
- int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src);
- } apm_ops;
+ /* power management */
+ struct iwl_apm_ops apm_ops;
+
/* power */
int (*send_tx_power) (struct iwl_priv *priv);
void (*update_chain_flags)(struct iwl_priv *priv);
- void (*temperature) (struct iwl_priv *priv);
+ void (*post_associate) (struct iwl_priv *priv);
+ void (*config_ap) (struct iwl_priv *priv);
+ irqreturn_t (*isr) (int irq, void *data);
+
/* eeprom operations (as defined in iwl-eeprom.h) */
struct iwl_eeprom_ops eeprom_ops;
+
+ /* temperature */
+ struct iwl_temp_ops temp_ops;
};
struct iwl_ops {
const struct iwl_lib_ops *lib;
const struct iwl_hcmd_ops *hcmd;
const struct iwl_hcmd_utils_ops *utils;
+ const struct iwl_station_mgmt_ops *smgmt;
};
struct iwl_mod_params {
- int disable; /* def: 0 = enable radio */
int sw_crypto; /* def: 0 = using hardware encryption */
u32 debug; /* def: 0 = minimal debug log messages */
int disable_hw_scan; /* def: 0 = use h/w scan */
@@ -214,6 +240,7 @@ struct iwl_cfg {
u8 valid_tx_ant;
u8 valid_rx_ant;
bool need_pll_cfg;
+ bool use_isr_legacy;
};
/***************************
@@ -225,6 +252,8 @@ struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
void iwl_hw_detect(struct iwl_priv *priv);
void iwl_reset_qos(struct iwl_priv *priv);
void iwl_activate_qos(struct iwl_priv *priv, u8 force);
+int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
+ const struct ieee80211_tx_queue_params *params);
void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt);
int iwl_check_rxon_cmd(struct iwl_priv *priv);
int iwl_full_rxon_required(struct iwl_priv *priv);
@@ -249,6 +278,24 @@ int iwl_setup_mac(struct iwl_priv *priv);
int iwl_set_hw_params(struct iwl_priv *priv);
int iwl_init_drv(struct iwl_priv *priv);
void iwl_uninit_drv(struct iwl_priv *priv);
+bool iwl_is_monitor_mode(struct iwl_priv *priv);
+void iwl_post_associate(struct iwl_priv *priv);
+void iwl_bss_info_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *bss_conf,
+ u32 changes);
+int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb);
+int iwl_commit_rxon(struct iwl_priv *priv);
+int iwl_set_mode(struct iwl_priv *priv, int mode);
+int iwl_mac_add_interface(struct ieee80211_hw *hw,
+ struct ieee80211_if_init_conf *conf);
+void iwl_mac_remove_interface(struct ieee80211_hw *hw,
+ struct ieee80211_if_init_conf *conf);
+int iwl_mac_config(struct ieee80211_hw *hw, u32 changed);
+void iwl_config_ap(struct iwl_priv *priv);
+int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
+ struct ieee80211_tx_queue_stats *stats);
+void iwl_mac_reset_tsf(struct ieee80211_hw *hw);
/*****************************************************
* RX handlers.
@@ -271,10 +318,11 @@ int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
struct iwl_rx_queue *q);
void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
void iwl_rx_replenish(struct iwl_priv *priv);
+void iwl_rx_replenish_now(struct iwl_priv *priv);
int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
int iwl_rx_queue_restock(struct iwl_priv *priv);
int iwl_rx_queue_space(const struct iwl_rx_queue *q);
-void iwl_rx_allocate(struct iwl_priv *priv);
+void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority);
void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
/* Handlers */
@@ -328,8 +376,6 @@ int iwl_hwrate_to_plcp_idx(u32 rate_n_flags);
u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv);
-void iwl_set_rate(struct iwl_priv *priv);
-
u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx);
static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
@@ -358,8 +404,8 @@ int iwl_scan_cancel(struct iwl_priv *priv);
int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
int iwl_scan_initiate(struct iwl_priv *priv);
int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req);
-u16 iwl_fill_probe_req(struct iwl_priv *priv, enum ieee80211_band band,
- struct ieee80211_mgmt *frame, int left);
+u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
+ const u8 *ie, int ie_len, int left);
void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
enum ieee80211_band band,
@@ -423,7 +469,13 @@ int iwl_send_card_state(struct iwl_priv *priv, u32 flags,
*****************************************************/
void iwl_disable_interrupts(struct iwl_priv *priv);
void iwl_enable_interrupts(struct iwl_priv *priv);
-irqreturn_t iwl_isr(int irq, void *data);
+irqreturn_t iwl_isr_legacy(int irq, void *data);
+int iwl_reset_ict(struct iwl_priv *priv);
+void iwl_disable_ict(struct iwl_priv *priv);
+int iwl_alloc_isr_ict(struct iwl_priv *priv);
+void iwl_free_isr_ict(struct iwl_priv *priv);
+irqreturn_t iwl_isr_ict(int irq, void *data);
+
static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv)
{
int pos;
@@ -432,12 +484,17 @@ static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv)
pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
return pci_lnk_ctl;
}
+#ifdef CONFIG_PM
+int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state);
+int iwl_pci_resume(struct pci_dev *pdev);
+#endif /* CONFIG_PM */
/*****************************************************
* Error Handling Debugging
******************************************************/
void iwl_dump_nic_error_log(struct iwl_priv *priv);
void iwl_dump_nic_event_log(struct iwl_priv *priv);
+void iwl_clear_isr_stats(struct iwl_priv *priv);
/*****************************************************
* GEOS
@@ -458,7 +515,6 @@ void iwlcore_free_geos(struct iwl_priv *priv);
#define STATUS_TEMPERATURE 8
#define STATUS_GEO_CONFIGURED 9
#define STATUS_EXIT_PENDING 10
-#define STATUS_IN_SUSPEND 11
#define STATUS_STATISTICS 12
#define STATUS_SCANNING 13
#define STATUS_SCAN_ABORTING 14
@@ -528,7 +584,14 @@ static inline int iwl_send_rxon_assoc(struct iwl_priv *priv)
{
return priv->cfg->ops->hcmd->rxon_assoc(priv);
}
-
+static inline int iwlcore_commit_rxon(struct iwl_priv *priv)
+{
+ return priv->cfg->ops->hcmd->commit_rxon(priv);
+}
+static inline void iwlcore_config_ap(struct iwl_priv *priv)
+{
+ priv->cfg->ops->lib->config_ap(priv);
+}
static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
struct iwl_priv *priv, enum ieee80211_band band)
{
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 6e983149b83b..f03dae1b2f36 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -89,6 +89,7 @@
/* EEPROM reads */
#define CSR_EEPROM_REG (CSR_BASE+0x02c)
#define CSR_EEPROM_GP (CSR_BASE+0x030)
+#define CSR_OTP_GP_REG (CSR_BASE+0x034)
#define CSR_GIO_REG (CSR_BASE+0x03C)
#define CSR_GP_UCODE (CSR_BASE+0x044)
#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
@@ -96,8 +97,10 @@
#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
#define CSR_LED_REG (CSR_BASE+0x094)
+#define CSR_DRAM_INT_TBL_REG (CSR_BASE+0x0A0)
#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
+#define CSR_INT_PERIODIC_REG (CSR_BASE+0x005)
/* Analog phase-lock-loop configuration */
#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
/*
@@ -123,16 +126,18 @@
#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000)
#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
-#define CSR_HW_IF_CONFIG_REG_BIT_PCI_OWN_SEM (0x00400000)
-#define CSR_HW_IF_CONFIG_REG_BIT_ME_OWN (0x02000000)
-#define CSR_HW_IF_CONFIG_REG_BIT_WAKE_ME (0x08000000)
+#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000)
+#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000)
+#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000)
+#define CSR_INT_PERIODIC_DIS (0x00)
+#define CSR_INT_PERIODIC_ENA (0xFF)
/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
* acknowledged (reset) by host writing "1" to flagged bits. */
#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */
-#define CSR_INT_BIT_DNLD (1 << 28) /* uCode Download */
+#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */
#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */
#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */
#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */
@@ -226,6 +231,10 @@
#define CSR_EEPROM_GP_VALID_MSK (0x00000007)
#define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
+#define CSR_OTP_GP_REG_DEVICE_SELECT (0x00010000) /* 0 - EEPROM, 1 - OTP */
+#define CSR_OTP_GP_REG_OTP_ACCESS_MODE (0x00020000) /* 0 - absolute, 1 - relative */
+#define CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK (0x00100000) /* bit 20 */
+#define CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK (0x00200000) /* bit 21 */
/* CSR GIO */
#define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002)
@@ -251,6 +260,11 @@
/* HPET MEM debug */
#define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000)
+
+/* DRAM INT TABLE */
+#define CSR_DRAM_INT_TBL_ENABLE (1 << 31)
+#define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27)
+
/*=== HBUS (Host-side Bus) ===*/
#define HBUS_BASE (0x400)
/*
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 65d1a7f2db9e..2cf014f523be 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -68,13 +68,14 @@ struct iwl_debugfs {
struct dentry *dir_rf;
struct dir_data_files {
struct dentry *file_sram;
- struct dentry *file_eeprom;
+ struct dentry *file_nvm;
struct dentry *file_stations;
struct dentry *file_rx_statistics;
struct dentry *file_tx_statistics;
struct dentry *file_log_event;
struct dentry *file_channels;
struct dentry *file_status;
+ struct dentry *file_interrupt;
} dbgfs_data_files;
struct dir_rf_files {
struct dentry *file_disable_sensitivity;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 64eb585f1578..af70229144b3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -172,7 +172,6 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
const size_t bufsz = sizeof(buf);
- iwl_grab_nic_access(priv);
for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
priv->dbgfs->sram_len - i);
@@ -192,7 +191,6 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
}
pos += scnprintf(buf + pos, bufsz - pos, "\n");
- iwl_release_nic_access(priv);
ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
return ret;
@@ -292,7 +290,7 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
return ret;
}
-static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
+static ssize_t iwl_dbgfs_nvm_read(struct file *file,
char __user *user_buf,
size_t count,
loff_t *ppos)
@@ -306,7 +304,7 @@ static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
buf_size = 4 * eeprom_len + 256;
if (eeprom_len % 16) {
- IWL_ERR(priv, "EEPROM size is not multiple of 16.\n");
+ IWL_ERR(priv, "NVM size is not multiple of 16.\n");
return -ENODATA;
}
@@ -318,6 +316,13 @@ static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
}
ptr = priv->eeprom;
+ if (!ptr) {
+ IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
+ return -ENOMEM;
+ }
+ pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s\n",
+ (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
+ ? "OTP" : "EEPROM");
for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
@@ -375,51 +380,53 @@ static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
}
supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
- channels = supp_band->channels;
-
- pos += scnprintf(buf + pos, bufsz - pos,
- "Displaying %d channels in 2.4GHz band 802.11bg):\n",
- supp_band->n_channels);
+ if (supp_band) {
+ channels = supp_band->channels;
- for (i = 0; i < supp_band->n_channels; i++)
pos += scnprintf(buf + pos, bufsz - pos,
- "%d: %ddBm: BSS%s%s, %s.\n",
- ieee80211_frequency_to_channel(
- channels[i].center_freq),
- channels[i].max_power,
- channels[i].flags & IEEE80211_CHAN_RADAR ?
- " (IEEE 802.11h required)" : "",
- (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
- || (channels[i].flags &
- IEEE80211_CHAN_RADAR)) ? "" :
- ", IBSS",
- channels[i].flags &
- IEEE80211_CHAN_PASSIVE_SCAN ?
- "passive only" : "active/passive");
+ "Displaying %d channels in 2.4GHz band 802.11bg):\n",
+ supp_band->n_channels);
+ for (i = 0; i < supp_band->n_channels; i++)
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "%d: %ddBm: BSS%s%s, %s.\n",
+ ieee80211_frequency_to_channel(
+ channels[i].center_freq),
+ channels[i].max_power,
+ channels[i].flags & IEEE80211_CHAN_RADAR ?
+ " (IEEE 802.11h required)" : "",
+ ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
+ || (channels[i].flags &
+ IEEE80211_CHAN_RADAR)) ? "" :
+ ", IBSS",
+ channels[i].flags &
+ IEEE80211_CHAN_PASSIVE_SCAN ?
+ "passive only" : "active/passive");
+ }
supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
- channels = supp_band->channels;
-
- pos += scnprintf(buf + pos, bufsz - pos,
- "Displaying %d channels in 5.2GHz band (802.11a)\n",
- supp_band->n_channels);
+ if (supp_band) {
+ channels = supp_band->channels;
- for (i = 0; i < supp_band->n_channels; i++)
pos += scnprintf(buf + pos, bufsz - pos,
- "%d: %ddBm: BSS%s%s, %s.\n",
- ieee80211_frequency_to_channel(
- channels[i].center_freq),
- channels[i].max_power,
- channels[i].flags & IEEE80211_CHAN_RADAR ?
- " (IEEE 802.11h required)" : "",
- ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
- || (channels[i].flags &
- IEEE80211_CHAN_RADAR)) ? "" :
- ", IBSS",
- channels[i].flags &
- IEEE80211_CHAN_PASSIVE_SCAN ?
- "passive only" : "active/passive");
+ "Displaying %d channels in 5.2GHz band (802.11a)\n",
+ supp_band->n_channels);
+ for (i = 0; i < supp_band->n_channels; i++)
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "%d: %ddBm: BSS%s%s, %s.\n",
+ ieee80211_frequency_to_channel(
+ channels[i].center_freq),
+ channels[i].max_power,
+ channels[i].flags & IEEE80211_CHAN_RADAR ?
+ " (IEEE 802.11h required)" : "",
+ ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
+ || (channels[i].flags &
+ IEEE80211_CHAN_RADAR)) ? "" :
+ ", IBSS",
+ channels[i].flags &
+ IEEE80211_CHAN_PASSIVE_SCAN ?
+ "passive only" : "active/passive");
+ }
ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
kfree(buf);
return ret;
@@ -456,8 +463,6 @@ static ssize_t iwl_dbgfs_status_read(struct file *file,
test_bit(STATUS_GEO_CONFIGURED, &priv->status));
pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
test_bit(STATUS_EXIT_PENDING, &priv->status));
- pos += scnprintf(buf + pos, bufsz - pos, "STATUS_IN_SUSPEND:\t %d\n",
- test_bit(STATUS_IN_SUSPEND, &priv->status));
pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
test_bit(STATUS_STATISTICS, &priv->status));
pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
@@ -475,14 +480,104 @@ static ssize_t iwl_dbgfs_status_read(struct file *file,
return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
}
+static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos) {
+
+ struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+ int pos = 0;
+ int cnt = 0;
+ char *buf;
+ int bufsz = 24 * 64; /* 24 items * 64 char per item */
+ ssize_t ret;
+
+ buf = kzalloc(bufsz, GFP_KERNEL);
+ if (!buf) {
+ IWL_ERR(priv, "Can not allocate Buffer\n");
+ return -ENOMEM;
+ }
+
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "Interrupt Statistics Report:\n");
+
+ pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
+ priv->isr_stats.hw);
+ pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
+ priv->isr_stats.sw);
+ if (priv->isr_stats.sw > 0) {
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "\tLast Restarting Code: 0x%X\n",
+ priv->isr_stats.sw_err);
+ }
+#ifdef CONFIG_IWLWIFI_DEBUG
+ pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
+ priv->isr_stats.sch);
+ pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
+ priv->isr_stats.alive);
+#endif
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "HW RF KILL switch toggled:\t %u\n",
+ priv->isr_stats.rfkill);
+
+ pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
+ priv->isr_stats.ctkill);
+
+ pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
+ priv->isr_stats.wakeup);
+
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "Rx command responses:\t\t %u\n",
+ priv->isr_stats.rx);
+ for (cnt = 0; cnt < REPLY_MAX; cnt++) {
+ if (priv->isr_stats.rx_handlers[cnt] > 0)
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "\tRx handler[%36s]:\t\t %u\n",
+ get_cmd_string(cnt),
+ priv->isr_stats.rx_handlers[cnt]);
+ }
+
+ pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
+ priv->isr_stats.tx);
+
+ pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
+ priv->isr_stats.unhandled);
+
+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+ kfree(buf);
+ return ret;
+}
+
+static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct iwl_priv *priv = file->private_data;
+ char buf[8];
+ int buf_size;
+ u32 reset_flag;
+
+ memset(buf, 0, sizeof(buf));
+ buf_size = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, buf_size))
+ return -EFAULT;
+ if (sscanf(buf, "%x", &reset_flag) != 1)
+ return -EFAULT;
+ if (reset_flag == 0)
+ iwl_clear_isr_stats(priv);
+
+ return count;
+}
+
+
DEBUGFS_READ_WRITE_FILE_OPS(sram);
DEBUGFS_WRITE_FILE_OPS(log_event);
-DEBUGFS_READ_FILE_OPS(eeprom);
+DEBUGFS_READ_FILE_OPS(nvm);
DEBUGFS_READ_FILE_OPS(stations);
DEBUGFS_READ_FILE_OPS(rx_statistics);
DEBUGFS_READ_FILE_OPS(tx_statistics);
DEBUGFS_READ_FILE_OPS(channels);
DEBUGFS_READ_FILE_OPS(status);
+DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
/*
* Create the debugfs files and directories
@@ -510,7 +605,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv);
- DEBUGFS_ADD_FILE(eeprom, data);
+ DEBUGFS_ADD_FILE(nvm, data);
DEBUGFS_ADD_FILE(sram, data);
DEBUGFS_ADD_FILE(log_event, data);
DEBUGFS_ADD_FILE(stations, data);
@@ -518,6 +613,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
DEBUGFS_ADD_FILE(tx_statistics, data);
DEBUGFS_ADD_FILE(channels, data);
DEBUGFS_ADD_FILE(status, data);
+ DEBUGFS_ADD_FILE(interrupt, data);
DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
&priv->disable_chain_noise_cal);
@@ -540,7 +636,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
if (!priv->dbgfs)
return;
- DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_eeprom);
+ DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_nvm);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
@@ -548,6 +644,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status);
+ DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt);
DEBUGFS_REMOVE(priv->dbgfs->dir_data);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index cf7f0db58fcf..2dafc26fb6a8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -70,6 +70,7 @@ extern struct iwl_ops iwl5000_ops;
extern struct iwl_lib_ops iwl5000_lib;
extern struct iwl_hcmd_ops iwl5000_hcmd;
extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils;
+extern struct iwl_station_mgmt_ops iwl5000_station_mgmt;
/* shared functions from iwl-5000.c */
extern u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len);
@@ -381,6 +382,7 @@ struct iwl_rx_queue {
u32 read;
u32 write;
u32 free_count;
+ u32 write_actual;
struct list_head rx_free;
struct list_head rx_used;
int need_update;
@@ -498,22 +500,13 @@ struct iwl_qos_info {
#define STA_PS_STATUS_WAKE 0
#define STA_PS_STATUS_SLEEP 1
-struct iwl3945_tid_data {
- u16 seq_number;
-};
-
-struct iwl3945_hw_key {
- enum ieee80211_key_alg alg;
- int keylen;
- u8 key[32];
-};
struct iwl3945_station_entry {
struct iwl3945_addsta_cmd sta;
- struct iwl3945_tid_data tid[MAX_TID_COUNT];
+ struct iwl_tid_data tid[MAX_TID_COUNT];
u8 used;
u8 ps_status;
- struct iwl3945_hw_key keyinfo;
+ struct iwl_hw_key keyinfo;
};
struct iwl_station_entry {
@@ -822,6 +815,26 @@ enum {
MEASUREMENT_ACTIVE = (1 << 1),
};
+enum iwl_nvm_type {
+ NVM_DEVICE_TYPE_EEPROM = 0,
+ NVM_DEVICE_TYPE_OTP,
+};
+
+/* interrupt statistics */
+struct isr_statistics {
+ u32 hw;
+ u32 sw;
+ u32 sw_err;
+ u32 sch;
+ u32 alive;
+ u32 rfkill;
+ u32 ctkill;
+ u32 wakeup;
+ u32 rx;
+ u32 rx_handlers[REPLY_MAX];
+ u32 tx;
+ u32 unhandled;
+};
#define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
@@ -877,15 +890,14 @@ struct iwl_priv {
unsigned long scan_start_tsf;
void *scan;
int scan_bands;
- int one_direct_scan;
- u8 direct_ssid_len;
- u8 direct_ssid[IW_ESSID_MAX_SIZE];
+ struct cfg80211_scan_request *scan_request;
u8 scan_tx_ant[IEEE80211_NUM_BANDS];
u8 mgmt_tx_ant;
/* spinlock */
spinlock_t lock; /* protect general shared data */
spinlock_t hcmd_lock; /* protect hcmd */
+ spinlock_t reg_lock; /* protect hw register access */
struct mutex mutex;
/* basic pci-network driver stuff */
@@ -919,7 +931,6 @@ struct iwl_priv {
const struct iwl_rxon_cmd active_rxon;
struct iwl_rxon_cmd staging_rxon;
- int error_recovering;
struct iwl_rxon_cmd recovery_rxon;
/* 1st responses from initialize and runtime uCode images.
@@ -978,6 +989,9 @@ struct iwl_priv {
u64 bytes;
} tx_stats[3], rx_stats[3];
+ /* counts interrupts */
+ struct isr_statistics isr_stats;
+
struct iwl_power_mgr power_data;
struct iwl_notif_statistics statistics;
@@ -1017,6 +1031,7 @@ struct iwl_priv {
/* eeprom */
u8 *eeprom;
+ int nvm_device_type;
struct iwl_eeprom_calib_info *calib_info;
enum nl80211_iftype iw_mode;
@@ -1034,7 +1049,16 @@ struct iwl_priv {
/*End*/
struct iwl_hw_params hw_params;
+ /* INT ICT Table */
+ u32 *ict_tbl;
+ dma_addr_t ict_tbl_dma;
+ dma_addr_t aligned_ict_tbl_dma;
+ int ict_index;
+ void *ict_tbl_vir;
+ u32 inta;
+ bool use_ict;
+ u32 inta_mask;
/* Current association information needed to configure the
* hardware */
u16 assoc_id;
@@ -1059,7 +1083,6 @@ struct iwl_priv {
struct tasklet_struct irq_tasklet;
- struct delayed_work set_power_save;
struct delayed_work init_alive_start;
struct delayed_work alive_start;
struct delayed_work scan_check;
@@ -1090,7 +1113,7 @@ struct iwl_priv {
u32 disable_tx_power_cal;
struct work_struct run_time_calib_work;
struct timer_list statistics_periodic;
-
+ bool hw_ready;
/*For 3945*/
#define IWL_DEFAULT_TX_POWER 0x0F
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 75517d05df08..cefa501e5971 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -152,6 +152,32 @@ int iwlcore_eeprom_verify_signature(struct iwl_priv *priv)
}
EXPORT_SYMBOL(iwlcore_eeprom_verify_signature);
+static int iwlcore_get_nvm_type(struct iwl_priv *priv)
+{
+ u32 otpgp;
+ int nvm_type;
+
+ /* OTP only valid for CP/PP and after */
+ switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
+ case CSR_HW_REV_TYPE_3945:
+ case CSR_HW_REV_TYPE_4965:
+ case CSR_HW_REV_TYPE_5300:
+ case CSR_HW_REV_TYPE_5350:
+ case CSR_HW_REV_TYPE_5100:
+ case CSR_HW_REV_TYPE_5150:
+ nvm_type = NVM_DEVICE_TYPE_EEPROM;
+ break;
+ default:
+ otpgp = iwl_read32(priv, CSR_OTP_GP_REG);
+ if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT)
+ nvm_type = NVM_DEVICE_TYPE_OTP;
+ else
+ nvm_type = NVM_DEVICE_TYPE_EEPROM;
+ break;
+ }
+ return nvm_type;
+}
+
/*
* The device's EEPROM semaphore prevents conflicts between driver and uCode
* when accessing the EEPROM; each access is a series of pulses to/from the
@@ -198,6 +224,33 @@ const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset)
}
EXPORT_SYMBOL(iwlcore_eeprom_query_addr);
+static int iwl_init_otp_access(struct iwl_priv *priv)
+{
+ int ret;
+
+ /* Enable 40MHz radio clock */
+ _iwl_write32(priv, CSR_GP_CNTRL,
+ _iwl_read32(priv, CSR_GP_CNTRL) |
+ CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
+
+ /* wait for clock to be ready */
+ ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+ CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
+ 25000);
+ if (ret < 0)
+ IWL_ERR(priv, "Time out access OTP\n");
+ else {
+ if (!ret) {
+ iwl_set_bits_prph(priv, APMG_PS_CTRL_REG,
+ APMG_PS_CTRL_VAL_RESET_REQ);
+ udelay(5);
+ iwl_clear_bits_prph(priv, APMG_PS_CTRL_REG,
+ APMG_PS_CTRL_VAL_RESET_REQ);
+ }
+ }
+ return ret;
+}
+
/**
* iwl_eeprom_init - read EEPROM contents
*
@@ -209,11 +262,18 @@ int iwl_eeprom_init(struct iwl_priv *priv)
{
u16 *e;
u32 gp = iwl_read32(priv, CSR_EEPROM_GP);
- int sz = priv->cfg->eeprom_size;
+ int sz;
int ret;
u16 addr;
+ u32 otpgp;
+
+ priv->nvm_device_type = iwlcore_get_nvm_type(priv);
/* allocate eeprom */
+ if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
+ priv->cfg->eeprom_size =
+ OTP_BLOCK_SIZE * OTP_LOWER_BLOCKS_TOTAL;
+ sz = priv->cfg->eeprom_size;
priv->eeprom = kzalloc(sz, GFP_KERNEL);
if (!priv->eeprom) {
ret = -ENOMEM;
@@ -235,30 +295,77 @@ int iwl_eeprom_init(struct iwl_priv *priv)
ret = -ENOENT;
goto err;
}
-
- /* eeprom is an array of 16bit values */
- for (addr = 0; addr < sz; addr += sizeof(u16)) {
- u32 r;
-
- _iwl_write32(priv, CSR_EEPROM_REG,
- CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
-
- ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG,
- CSR_EEPROM_REG_READ_VALID_MSK,
- IWL_EEPROM_ACCESS_TIMEOUT);
- if (ret < 0) {
- IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr);
- goto done;
+ if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
+ ret = iwl_init_otp_access(priv);
+ if (ret) {
+ IWL_ERR(priv, "Failed to initialize OTP access.\n");
+ ret = -ENOENT;
+ goto err;
+ }
+ _iwl_write32(priv, CSR_EEPROM_GP,
+ iwl_read32(priv, CSR_EEPROM_GP) &
+ ~CSR_EEPROM_GP_IF_OWNER_MSK);
+ /* clear */
+ _iwl_write32(priv, CSR_OTP_GP_REG,
+ iwl_read32(priv, CSR_OTP_GP_REG) |
+ CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK |
+ CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
+
+ for (addr = 0; addr < sz; addr += sizeof(u16)) {
+ u32 r;
+
+ _iwl_write32(priv, CSR_EEPROM_REG,
+ CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
+
+ ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG,
+ CSR_EEPROM_REG_READ_VALID_MSK,
+ IWL_EEPROM_ACCESS_TIMEOUT);
+ if (ret < 0) {
+ IWL_ERR(priv, "Time out reading OTP[%d]\n", addr);
+ goto done;
+ }
+ r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
+ /* check for ECC errors: */
+ otpgp = iwl_read32(priv, CSR_OTP_GP_REG);
+ if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) {
+ /* stop in this case */
+ IWL_ERR(priv, "Uncorrectable OTP ECC error, Abort OTP read\n");
+ goto done;
+ }
+ if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) {
+ /* continue in this case */
+ _iwl_write32(priv, CSR_OTP_GP_REG,
+ iwl_read32(priv, CSR_OTP_GP_REG) |
+ CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
+ IWL_ERR(priv, "Correctable OTP ECC error, continue read\n");
+ }
+ e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
+ }
+ } else {
+ /* eeprom is an array of 16bit values */
+ for (addr = 0; addr < sz; addr += sizeof(u16)) {
+ u32 r;
+
+ _iwl_write32(priv, CSR_EEPROM_REG,
+ CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
+
+ ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG,
+ CSR_EEPROM_REG_READ_VALID_MSK,
+ IWL_EEPROM_ACCESS_TIMEOUT);
+ if (ret < 0) {
+ IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr);
+ goto done;
+ }
+ r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
+ e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
}
- r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
- e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
}
ret = 0;
done:
priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv);
err:
if (ret)
- kfree(priv->eeprom);
+ iwl_eeprom_free(priv);
alloc_err:
return ret;
}
@@ -285,7 +392,7 @@ int iwl_eeprom_check_version(struct iwl_priv *priv)
return 0;
err:
- IWL_ERR(priv, "Unsupported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
+ IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
eeprom_ver, priv->cfg->eeprom_ver,
calib_ver, priv->cfg->eeprom_calib_ver);
return -EINVAL;
@@ -301,6 +408,8 @@ EXPORT_SYMBOL(iwl_eeprom_query_addr);
u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset)
{
+ if (!priv->eeprom)
+ return 0;
return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8);
}
EXPORT_SYMBOL(iwl_eeprom_query16);
@@ -481,8 +590,8 @@ int iwl_init_channel_map(struct iwl_priv *priv)
/* First write that fat is not enabled, and then enable
* one by one */
ch_info->fat_extension_channel =
- (IEEE80211_CHAN_NO_FAT_ABOVE |
- IEEE80211_CHAN_NO_FAT_BELOW);
+ (IEEE80211_CHAN_NO_HT40PLUS |
+ IEEE80211_CHAN_NO_HT40MINUS);
if (!(is_channel_valid(ch_info))) {
IWL_DEBUG_INFO(priv, "Ch. %d Flags %x [%sGHz] - "
@@ -561,7 +670,7 @@ int iwl_init_channel_map(struct iwl_priv *priv)
fat_extension_chan = 0;
else
fat_extension_chan =
- IEEE80211_CHAN_NO_FAT_BELOW;
+ IEEE80211_CHAN_NO_HT40MINUS;
/* Set up driver's info for lower half */
iwl_set_fat_chan_info(priv, ieeeband,
@@ -573,7 +682,7 @@ int iwl_init_channel_map(struct iwl_priv *priv)
iwl_set_fat_chan_info(priv, ieeeband,
(eeprom_ch_index[ch] + 4),
&(eeprom_ch_info[ch]),
- IEEE80211_CHAN_NO_FAT_ABOVE);
+ IEEE80211_CHAN_NO_HT40PLUS);
}
}
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 3479153d96ca..195b4ef12c27 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -179,6 +179,10 @@ struct iwl_eeprom_channel {
#define EEPROM_5050_TX_POWER_VERSION (4)
#define EEPROM_5050_EEPROM_VERSION (0x21E)
+/* OTP */
+#define OTP_LOWER_BLOCKS_TOTAL (3)
+#define OTP_BLOCK_SIZE (0x400)
+
/* 2.4 GHz */
extern const u8 iwl_eeprom_band_1[14];
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index 083ea1ffbe87..d30cb0275d19 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -131,9 +131,23 @@ static inline void __iwl_set_bit(const char *f, u32 l,
IWL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
_iwl_write32(priv, reg, val);
}
-#define iwl_set_bit(p, r, m) __iwl_set_bit(__FILE__, __LINE__, p, r, m)
+static inline void iwl_set_bit(struct iwl_priv *p, u32 r, u32 m)
+{
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&p->reg_lock, reg_flags);
+ __iwl_set_bit(__FILE__, __LINE__, p, r, m);
+ spin_unlock_irqrestore(&p->reg_lock, reg_flags);
+}
#else
-#define iwl_set_bit(p, r, m) _iwl_set_bit(p, r, m)
+static inline void iwl_set_bit(struct iwl_priv *p, u32 r, u32 m)
+{
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&p->reg_lock, reg_flags);
+ _iwl_set_bit(p, r, m);
+ spin_unlock_irqrestore(&p->reg_lock, reg_flags);
+}
#endif
static inline void _iwl_clear_bit(struct iwl_priv *priv, u32 reg, u32 mask)
@@ -148,19 +162,30 @@ static inline void __iwl_clear_bit(const char *f, u32 l,
IWL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
_iwl_write32(priv, reg, val);
}
-#define iwl_clear_bit(p, r, m) __iwl_clear_bit(__FILE__, __LINE__, p, r, m)
+static inline void iwl_clear_bit(struct iwl_priv *p, u32 r, u32 m)
+{
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&p->reg_lock, reg_flags);
+ __iwl_clear_bit(__FILE__, __LINE__, p, r, m);
+ spin_unlock_irqrestore(&p->reg_lock, reg_flags);
+}
#else
-#define iwl_clear_bit(p, r, m) _iwl_clear_bit(p, r, m)
+static inline void iwl_clear_bit(struct iwl_priv *p, u32 r, u32 m)
+{
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&p->reg_lock, reg_flags);
+ _iwl_clear_bit(p, r, m);
+ spin_unlock_irqrestore(&p->reg_lock, reg_flags);
+}
#endif
static inline int _iwl_grab_nic_access(struct iwl_priv *priv)
{
int ret;
u32 val;
-#ifdef CONFIG_IWLWIFI_DEBUG
- if (atomic_read(&priv->restrict_refcnt))
- return 0;
-#endif
+
/* this bit wakes up the NIC */
_iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
ret = _iwl_poll_bit(priv, CSR_GP_CNTRL,
@@ -170,12 +195,10 @@ static inline int _iwl_grab_nic_access(struct iwl_priv *priv)
if (ret < 0) {
val = _iwl_read32(priv, CSR_GP_CNTRL);
IWL_ERR(priv, "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val);
+ _iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI);
return -EIO;
}
-#ifdef CONFIG_IWLWIFI_DEBUG
- atomic_inc(&priv->restrict_refcnt);
-#endif
return 0;
}
@@ -183,9 +206,6 @@ static inline int _iwl_grab_nic_access(struct iwl_priv *priv)
static inline int __iwl_grab_nic_access(const char *f, u32 l,
struct iwl_priv *priv)
{
- if (atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Grabbing access while already held %s %d.\n", f, l);
-
IWL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l);
return _iwl_grab_nic_access(priv);
}
@@ -198,18 +218,13 @@ static inline int __iwl_grab_nic_access(const char *f, u32 l,
static inline void _iwl_release_nic_access(struct iwl_priv *priv)
{
-#ifdef CONFIG_IWLWIFI_DEBUG
- if (atomic_dec_and_test(&priv->restrict_refcnt))
-#endif
- _iwl_clear_bit(priv, CSR_GP_CNTRL,
- CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
+ _iwl_clear_bit(priv, CSR_GP_CNTRL,
+ CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
}
#ifdef CONFIG_IWLWIFI_DEBUG
static inline void __iwl_release_nic_access(const char *f, u32 l,
struct iwl_priv *priv)
{
- if (atomic_read(&priv->restrict_refcnt) <= 0)
- IWL_ERR(priv, "Release unheld nic access at line %s %d.\n", f, l);
IWL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l);
_iwl_release_nic_access(priv);
@@ -230,16 +245,37 @@ static inline u32 __iwl_read_direct32(const char *f, u32 l,
struct iwl_priv *priv, u32 reg)
{
u32 value = _iwl_read_direct32(priv, reg);
- if (!atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Nic access not held from %s %d\n", f, l);
IWL_DEBUG_IO(priv, "read_direct32(0x%4X) = 0x%08x - %s %d \n", reg, value,
f, l);
return value;
}
-#define iwl_read_direct32(priv, reg) \
- __iwl_read_direct32(__FILE__, __LINE__, priv, reg)
+static inline u32 iwl_read_direct32(struct iwl_priv *priv, u32 reg)
+{
+ u32 value;
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
+ value = __iwl_read_direct32(__FILE__, __LINE__, priv, reg);
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+ return value;
+}
+
#else
-#define iwl_read_direct32 _iwl_read_direct32
+static inline u32 iwl_read_direct32(struct iwl_priv *priv, u32 reg)
+{
+ u32 value;
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
+ value = _iwl_read_direct32(priv, reg);
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+ return value;
+
+}
#endif
static inline void _iwl_write_direct32(struct iwl_priv *priv,
@@ -247,19 +283,17 @@ static inline void _iwl_write_direct32(struct iwl_priv *priv,
{
_iwl_write32(priv, reg, value);
}
-#ifdef CONFIG_IWLWIFI_DEBUG
-static void __iwl_write_direct32(const char *f , u32 line,
- struct iwl_priv *priv, u32 reg, u32 value)
+static inline void iwl_write_direct32(struct iwl_priv *priv, u32 reg, u32 value)
{
- if (!atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Nic access not held from %s line %d\n", f, line);
- _iwl_write_direct32(priv, reg, value);
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ if (!iwl_grab_nic_access(priv)) {
+ _iwl_write_direct32(priv, reg, value);
+ iwl_release_nic_access(priv);
+ }
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
-#define iwl_write_direct32(priv, reg, value) \
- __iwl_write_direct32(__func__, __LINE__, priv, reg, value)
-#else
-#define iwl_write_direct32 _iwl_write_direct32
-#endif
static inline void iwl_write_reg_buf(struct iwl_priv *priv,
u32 reg, u32 len, u32 *values)
@@ -268,14 +302,23 @@ static inline void iwl_write_reg_buf(struct iwl_priv *priv,
if ((priv != NULL) && (values != NULL)) {
for (; 0 < len; len -= count, reg += count, values++)
- _iwl_write_direct32(priv, reg, *values);
+ iwl_write_direct32(priv, reg, *values);
}
}
static inline int _iwl_poll_direct_bit(struct iwl_priv *priv, u32 addr,
u32 mask, int timeout)
{
- return _iwl_poll_bit(priv, addr, mask, mask, timeout);
+ int t = 0;
+
+ do {
+ if ((iwl_read_direct32(priv, addr) & mask) == mask)
+ return t;
+ udelay(IWL_POLL_INTERVAL);
+ t += IWL_POLL_INTERVAL;
+ } while (t < timeout);
+
+ return -ETIMEDOUT;
}
#ifdef CONFIG_IWLWIFI_DEBUG
@@ -305,20 +348,18 @@ static inline u32 _iwl_read_prph(struct iwl_priv *priv, u32 reg)
rmb();
return _iwl_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
}
-#ifdef CONFIG_IWLWIFI_DEBUG
-static inline u32 __iwl_read_prph(const char *f, u32 line,
- struct iwl_priv *priv, u32 reg)
+static inline u32 iwl_read_prph(struct iwl_priv *priv, u32 reg)
{
- if (!atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Nic access not held from %s line %d\n", f, line);
- return _iwl_read_prph(priv, reg);
-}
+ unsigned long reg_flags;
+ u32 val;
-#define iwl_read_prph(priv, reg) \
- __iwl_read_prph(__func__, __LINE__, priv, reg)
-#else
-#define iwl_read_prph _iwl_read_prph
-#endif
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
+ val = _iwl_read_prph(priv, reg);
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+ return val;
+}
static inline void _iwl_write_prph(struct iwl_priv *priv,
u32 addr, u32 val)
@@ -328,83 +369,107 @@ static inline void _iwl_write_prph(struct iwl_priv *priv,
wmb();
_iwl_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
}
-#ifdef CONFIG_IWLWIFI_DEBUG
-static inline void __iwl_write_prph(const char *f, u32 line,
- struct iwl_priv *priv, u32 addr, u32 val)
+
+static inline void iwl_write_prph(struct iwl_priv *priv, u32 addr, u32 val)
{
- if (!atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Nic access not held from %s line %d\n", f, line);
- _iwl_write_prph(priv, addr, val);
-}
+ unsigned long reg_flags;
-#define iwl_write_prph(priv, addr, val) \
- __iwl_write_prph(__func__, __LINE__, priv, addr, val);
-#else
-#define iwl_write_prph _iwl_write_prph
-#endif
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ if (!iwl_grab_nic_access(priv)) {
+ _iwl_write_prph(priv, addr, val);
+ iwl_release_nic_access(priv);
+ }
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+}
#define _iwl_set_bits_prph(priv, reg, mask) \
_iwl_write_prph(priv, reg, (_iwl_read_prph(priv, reg) | mask))
-#ifdef CONFIG_IWLWIFI_DEBUG
-static inline void __iwl_set_bits_prph(const char *f, u32 line,
- struct iwl_priv *priv,
- u32 reg, u32 mask)
+
+static inline void iwl_set_bits_prph(struct iwl_priv *priv, u32 reg, u32 mask)
{
- if (!atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Nic access not held from %s line %d\n", f, line);
+ unsigned long reg_flags;
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
_iwl_set_bits_prph(priv, reg, mask);
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
-#define iwl_set_bits_prph(priv, reg, mask) \
- __iwl_set_bits_prph(__func__, __LINE__, priv, reg, mask)
-#else
-#define iwl_set_bits_prph _iwl_set_bits_prph
-#endif
#define _iwl_set_bits_mask_prph(priv, reg, bits, mask) \
_iwl_write_prph(priv, reg, ((_iwl_read_prph(priv, reg) & mask) | bits))
-#ifdef CONFIG_IWLWIFI_DEBUG
-static inline void __iwl_set_bits_mask_prph(const char *f, u32 line,
- struct iwl_priv *priv, u32 reg, u32 bits, u32 mask)
+static inline void iwl_set_bits_mask_prph(struct iwl_priv *priv, u32 reg,
+ u32 bits, u32 mask)
{
- if (!atomic_read(&priv->restrict_refcnt))
- IWL_ERR(priv, "Nic access not held from %s line %d\n", f, line);
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
_iwl_set_bits_mask_prph(priv, reg, bits, mask);
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
-#define iwl_set_bits_mask_prph(priv, reg, bits, mask) \
- __iwl_set_bits_mask_prph(__func__, __LINE__, priv, reg, bits, mask)
-#else
-#define iwl_set_bits_mask_prph _iwl_set_bits_mask_prph
-#endif
static inline void iwl_clear_bits_prph(struct iwl_priv
*priv, u32 reg, u32 mask)
{
- u32 val = _iwl_read_prph(priv, reg);
+ unsigned long reg_flags;
+ u32 val;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
+ val = _iwl_read_prph(priv, reg);
_iwl_write_prph(priv, reg, (val & ~mask));
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
static inline u32 iwl_read_targ_mem(struct iwl_priv *priv, u32 addr)
{
- iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
+ unsigned long reg_flags;
+ u32 value;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ iwl_grab_nic_access(priv);
+
+ _iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
rmb();
- return iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
+ value = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
+
+ iwl_release_nic_access(priv);
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+ return value;
}
static inline void iwl_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val)
{
- iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
- wmb();
- iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ if (!iwl_grab_nic_access(priv)) {
+ _iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
+ wmb();
+ _iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
+ iwl_release_nic_access(priv);
+ }
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
static inline void iwl_write_targ_mem_buf(struct iwl_priv *priv, u32 addr,
u32 len, u32 *values)
{
- iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
- wmb();
- for (; 0 < len; len -= sizeof(u32), values++)
- iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values);
+ unsigned long reg_flags;
+
+ spin_lock_irqsave(&priv->reg_lock, reg_flags);
+ if (!iwl_grab_nic_access(priv)) {
+ _iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
+ wmb();
+ for (; 0 < len; len -= sizeof(u32), values++)
+ _iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values);
+
+ iwl_release_nic_access(priv);
+ }
+ spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
}
#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 47c894530eb5..f2ea3f05f6e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -41,38 +41,33 @@
#include "iwl-power.h"
/*
- * Setting power level allow the card to go to sleep when not busy
- * there are three factor that decide the power level to go to, they
- * are list here with its priority
- * 1- critical_power_setting this will be set according to card temperature.
- * 2- system_power_setting this will be set by system PM manager.
- * 3- user_power_setting this will be set by user either by writing to sys or
- * mac80211
+ * Setting power level allow the card to go to sleep when not busy.
*
- * if system_power_setting and user_power_setting is set to auto
- * the power level will be decided according to association status and battery
- * status.
+ * The power level is set to INDEX_1 (the least deep state) by
+ * default, and will, in the future, be the deepest state unless
+ * otherwise required by pm_qos network latency requirements.
*
+ * Using INDEX_1 without pm_qos is ok because mac80211 will disable
+ * PS when even checking every beacon for the TIM bit would exceed
+ * the required latency.
*/
-#define MSEC_TO_USEC 1024
#define IWL_POWER_RANGE_0_MAX (2)
#define IWL_POWER_RANGE_1_MAX (10)
-
-#define IWL_POWER_ON_BATTERY IWL_POWER_INDEX_5
-#define IWL_POWER_ON_AC_DISASSOC IWL_POWER_MODE_CAM
-#define IWL_POWER_ON_AC_ASSOC IWL_POWER_MODE_CAM
-
-
-#define IWL_CT_KILL_TEMPERATURE 110
-#define IWL_MIN_POWER_TEMPERATURE 100
-#define IWL_REDUCED_POWER_TEMPERATURE 95
-
+#define NOSLP cpu_to_le16(0), 0, 0
+#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
+#define TU_TO_USEC 1024
+#define SLP_TOUT(T) cpu_to_le32((T) * TU_TO_USEC)
+#define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
+ cpu_to_le32(X1), \
+ cpu_to_le32(X2), \
+ cpu_to_le32(X3), \
+ cpu_to_le32(X4)}
/* default power management (not Tx power) table values */
-/* for TIM 0-10 */
-static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
+/* for DTIM period 0 through IWL_POWER_RANGE_0_MAX */
+static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = {
{{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
{{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
@@ -82,8 +77,8 @@ static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
};
-/* for TIM = 3-10 */
-static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
+/* for DTIM period IWL_POWER_RANGE_0_MAX + 1 through IWL_POWER_RANGE_1_MAX */
+static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = {
{{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
{{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0},
@@ -92,8 +87,8 @@ static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2}
};
-/* for TIM > 11 */
-static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = {
+/* for DTIM period > IWL_POWER_RANGE_1_MAX */
+static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = {
{{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
{{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0},
@@ -106,39 +101,15 @@ static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = {
/* set card power command */
static int iwl_set_power(struct iwl_priv *priv, void *cmd)
{
- return iwl_send_cmd_pdu_async(priv, POWER_TABLE_CMD,
- sizeof(struct iwl_powertable_cmd),
- cmd, NULL);
-}
-/* decide the right power level according to association status
- * and battery status
- */
-static u16 iwl_get_auto_power_mode(struct iwl_priv *priv)
-{
- u16 mode;
-
- switch (priv->power_data.user_power_setting) {
- case IWL_POWER_AUTO:
- /* if running on battery */
- if (priv->power_data.is_battery_active)
- mode = IWL_POWER_ON_BATTERY;
- else if (iwl_is_associated(priv))
- mode = IWL_POWER_ON_AC_ASSOC;
- else
- mode = IWL_POWER_ON_AC_DISASSOC;
- break;
- default:
- mode = priv->power_data.user_power_setting;
- break;
- }
- return mode;
+ return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD,
+ sizeof(struct iwl_powertable_cmd), cmd);
}
/* initialize to default */
static void iwl_power_init_handle(struct iwl_priv *priv)
{
struct iwl_power_mgr *pow_data;
- int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX;
+ int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_NUM;
struct iwl_powertable_cmd *cmd;
int i;
u16 lctl;
@@ -157,7 +128,7 @@ static void iwl_power_init_handle(struct iwl_priv *priv)
IWL_DEBUG_POWER(priv, "adjust power command flags\n");
- for (i = 0; i < IWL_POWER_MAX; i++) {
+ for (i = 0; i < IWL_POWER_NUM; i++) {
cmd = &pow_data->pwr_range_0[i].cmd;
if (lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN)
@@ -247,33 +218,12 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
- /* If on battery, set to 3,
- * if plugged into AC power, set to CAM ("continuously aware mode"),
- * else user level */
-
- switch (setting->system_power_setting) {
- case IWL_POWER_SYS_AUTO:
- final_mode = iwl_get_auto_power_mode(priv);
- break;
- case IWL_POWER_SYS_BATTERY:
- final_mode = IWL_POWER_INDEX_3;
- break;
- case IWL_POWER_SYS_AC:
- final_mode = IWL_POWER_MODE_CAM;
- break;
- default:
- final_mode = IWL_POWER_INDEX_3;
- WARN_ON(1);
- }
-
- if (setting->critical_power_setting > final_mode)
- final_mode = setting->critical_power_setting;
+ final_mode = priv->power_data.user_power_setting;
- /* driver only support CAM for non STA network */
- if (priv->iw_mode != NL80211_IFTYPE_STATION)
+ if (setting->power_disabled)
final_mode = IWL_POWER_MODE_CAM;
- if (iwl_is_ready_rf(priv) && !setting->power_disabled &&
+ if (iwl_is_ready_rf(priv) &&
((setting->power_mode != final_mode) || force)) {
struct iwl_powertable_cmd cmd;
@@ -290,8 +240,6 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
if (final_mode == IWL_POWER_MODE_CAM)
clear_bit(STATUS_POWER_PMI, &priv->status);
- else
- set_bit(STATUS_POWER_PMI, &priv->status);
if (priv->cfg->ops->lib->update_chain_flags && update_chains)
priv->cfg->ops->lib->update_chain_flags(priv);
@@ -307,51 +255,10 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
}
EXPORT_SYMBOL(iwl_power_update_mode);
-/* Allow other iwl code to disable/enable power management active
- * this will be useful for rate scale to disable PM during heavy
- * Tx/Rx activities
- */
-int iwl_power_disable_management(struct iwl_priv *priv, u32 ms)
-{
- u16 prev_mode;
- int ret = 0;
-
- if (priv->power_data.power_disabled)
- return -EBUSY;
-
- prev_mode = priv->power_data.user_power_setting;
- priv->power_data.user_power_setting = IWL_POWER_MODE_CAM;
- ret = iwl_power_update_mode(priv, 0);
- priv->power_data.power_disabled = 1;
- priv->power_data.user_power_setting = prev_mode;
- cancel_delayed_work(&priv->set_power_save);
- if (ms)
- queue_delayed_work(priv->workqueue, &priv->set_power_save,
- msecs_to_jiffies(ms));
-
-
- return ret;
-}
-EXPORT_SYMBOL(iwl_power_disable_management);
-
-/* Allow other iwl code to disable/enable power management active
- * this will be useful for rate scale to disable PM during high
- * volume activities
- */
-int iwl_power_enable_management(struct iwl_priv *priv)
-{
- int ret = 0;
-
- priv->power_data.power_disabled = 0;
- ret = iwl_power_update_mode(priv, 0);
- return ret;
-}
-EXPORT_SYMBOL(iwl_power_enable_management);
-
/* set user_power_setting */
int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode)
{
- if (mode > IWL_POWER_MAX)
+ if (mode >= IWL_POWER_NUM)
return -EINVAL;
priv->power_data.user_power_setting = mode;
@@ -360,86 +267,12 @@ int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode)
}
EXPORT_SYMBOL(iwl_power_set_user_mode);
-/* set system_power_setting. This should be set by over all
- * PM application.
- */
-int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode)
-{
- if (mode < IWL_POWER_SYS_MAX)
- priv->power_data.system_power_setting = mode;
- else
- return -EINVAL;
- return iwl_power_update_mode(priv, 0);
-}
-EXPORT_SYMBOL(iwl_power_set_system_mode);
-
/* initialize to default */
void iwl_power_initialize(struct iwl_priv *priv)
{
iwl_power_init_handle(priv);
- priv->power_data.user_power_setting = IWL_POWER_AUTO;
- priv->power_data.system_power_setting = IWL_POWER_SYS_AUTO;
- priv->power_data.power_disabled = 0;
- priv->power_data.is_battery_active = 0;
- priv->power_data.critical_power_setting = 0;
+ priv->power_data.user_power_setting = IWL_POWER_INDEX_1;
+ /* default to disabled until mac80211 says otherwise */
+ priv->power_data.power_disabled = 1;
}
EXPORT_SYMBOL(iwl_power_initialize);
-
-/* set critical_power_setting according to temperature value */
-int iwl_power_temperature_change(struct iwl_priv *priv)
-{
- int ret = 0;
- s32 temperature = KELVIN_TO_CELSIUS(priv->last_temperature);
- u16 new_critical = priv->power_data.critical_power_setting;
-
- if (temperature > IWL_CT_KILL_TEMPERATURE)
- return 0;
- else if (temperature > IWL_MIN_POWER_TEMPERATURE)
- new_critical = IWL_POWER_INDEX_5;
- else if (temperature > IWL_REDUCED_POWER_TEMPERATURE)
- new_critical = IWL_POWER_INDEX_3;
- else
- new_critical = IWL_POWER_MODE_CAM;
-
- if (new_critical != priv->power_data.critical_power_setting)
- priv->power_data.critical_power_setting = new_critical;
-
- if (priv->power_data.critical_power_setting >
- priv->power_data.power_mode)
- ret = iwl_power_update_mode(priv, 0);
-
- return ret;
-}
-EXPORT_SYMBOL(iwl_power_temperature_change);
-
-static void iwl_bg_set_power_save(struct work_struct *work)
-{
- struct iwl_priv *priv = container_of(work,
- struct iwl_priv, set_power_save.work);
- IWL_DEBUG_POWER(priv, "update power\n");
-
- if (test_bit(STATUS_EXIT_PENDING, &priv->status))
- return;
-
- mutex_lock(&priv->mutex);
-
- /* on starting association we disable power management
- * until association, if association failed then this
- * timer will expire and enable PM again.
- */
- if (!iwl_is_associated(priv))
- iwl_power_enable_management(priv);
-
- mutex_unlock(&priv->mutex);
-}
-void iwl_setup_power_deferred_work(struct iwl_priv *priv)
-{
- INIT_DELAYED_WORK(&priv->set_power_save, iwl_bg_set_power_save);
-}
-EXPORT_SYMBOL(iwl_setup_power_deferred_work);
-
-void iwl_power_cancel_timeout(struct iwl_priv *priv)
-{
- cancel_delayed_work(&priv->set_power_save);
-}
-EXPORT_SYMBOL(iwl_power_cancel_timeout);
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 18963392121e..37ba3bb7a25a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -40,56 +40,29 @@ enum {
IWL_POWER_INDEX_3,
IWL_POWER_INDEX_4,
IWL_POWER_INDEX_5,
- IWL_POWER_AUTO,
- IWL_POWER_MAX = IWL_POWER_AUTO,
+ IWL_POWER_NUM
};
-enum {
- IWL_POWER_SYS_AUTO,
- IWL_POWER_SYS_AC,
- IWL_POWER_SYS_BATTERY,
- IWL_POWER_SYS_MAX,
-};
-
-
/* Power management (not Tx power) structures */
-#define NOSLP cpu_to_le16(0), 0, 0
-#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
-#define SLP_TOUT(T) cpu_to_le32((T) * MSEC_TO_USEC)
-#define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
- cpu_to_le32(X1), \
- cpu_to_le32(X2), \
- cpu_to_le32(X3), \
- cpu_to_le32(X4)}
struct iwl_power_vec_entry {
struct iwl_powertable_cmd cmd;
u8 no_dtim;
};
struct iwl_power_mgr {
- spinlock_t lock;
- struct iwl_power_vec_entry pwr_range_0[IWL_POWER_MAX];
- struct iwl_power_vec_entry pwr_range_1[IWL_POWER_MAX];
- struct iwl_power_vec_entry pwr_range_2[IWL_POWER_MAX];
+ struct iwl_power_vec_entry pwr_range_0[IWL_POWER_NUM];
+ struct iwl_power_vec_entry pwr_range_1[IWL_POWER_NUM];
+ struct iwl_power_vec_entry pwr_range_2[IWL_POWER_NUM];
u32 dtim_period;
/* final power level that used to calculate final power command */
u8 power_mode;
- u8 user_power_setting; /* set by user through mac80211 or sysfs */
- u8 system_power_setting; /* set by kernel system tools */
- u8 critical_power_setting; /* set if driver over heated */
- u8 is_battery_active; /* DC/AC power */
- u8 power_disabled; /* flag to disable using power saving level */
+ u8 user_power_setting; /* set by user through sysfs */
+ u8 power_disabled; /* set by mac80211's CONF_PS */
};
-void iwl_setup_power_deferred_work(struct iwl_priv *priv);
-void iwl_power_cancel_timeout(struct iwl_priv *priv);
int iwl_power_update_mode(struct iwl_priv *priv, bool force);
-int iwl_power_disable_management(struct iwl_priv *priv, u32 ms);
-int iwl_power_enable_management(struct iwl_priv *priv);
int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode);
-int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode);
void iwl_power_initialize(struct iwl_priv *priv);
-int iwl_power_temperature_change(struct iwl_priv *priv);
#endif /* __iwl_power_setting_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 8f65908f66f1..2b8d40b37a1c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -145,18 +145,14 @@ int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q)
goto exit_unlock;
}
- ret = iwl_grab_nic_access(priv);
- if (ret)
- goto exit_unlock;
-
- /* Device expects a multiple of 8 */
- iwl_write_direct32(priv, rx_wrt_ptr_reg, q->write & ~0x7);
- iwl_release_nic_access(priv);
+ q->write_actual = (q->write & ~0x7);
+ iwl_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual);
/* Else device is assumed to be awake */
} else {
/* Device expects a multiple of 8 */
- iwl_write32(priv, rx_wrt_ptr_reg, q->write & ~0x7);
+ q->write_actual = (q->write & ~0x7);
+ iwl_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual);
}
q->need_update = 0;
@@ -218,7 +214,7 @@ int iwl_rx_queue_restock(struct iwl_priv *priv)
/* If we've added more space for the firmware to place data, tell it.
* Increment device's write pointer in multiples of 8. */
- if (write != (rxq->write & ~0x7)) {
+ if (rxq->write_actual != (rxq->write & ~0x7)) {
spin_lock_irqsave(&rxq->lock, flags);
rxq->need_update = 1;
spin_unlock_irqrestore(&rxq->lock, flags);
@@ -238,7 +234,7 @@ EXPORT_SYMBOL(iwl_rx_queue_restock);
* Also restock the Rx queue via iwl_rx_queue_restock.
* This is called as a scheduled work item (except for during initialization)
*/
-void iwl_rx_allocate(struct iwl_priv *priv)
+void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority)
{
struct iwl_rx_queue *rxq = &priv->rxq;
struct list_head *element;
@@ -260,7 +256,8 @@ void iwl_rx_allocate(struct iwl_priv *priv)
/* Alloc a new receive buffer */
rxb->skb = alloc_skb(priv->hw_params.rx_buf_size + 256,
- GFP_KERNEL);
+ priority);
+
if (!rxb->skb) {
IWL_CRIT(priv, "Can not allocate SKB buffers\n");
/* We don't reschedule replenish work here -- we will
@@ -295,7 +292,7 @@ void iwl_rx_replenish(struct iwl_priv *priv)
{
unsigned long flags;
- iwl_rx_allocate(priv);
+ iwl_rx_allocate(priv, GFP_KERNEL);
spin_lock_irqsave(&priv->lock, flags);
iwl_rx_queue_restock(priv);
@@ -303,6 +300,14 @@ void iwl_rx_replenish(struct iwl_priv *priv)
}
EXPORT_SYMBOL(iwl_rx_replenish);
+void iwl_rx_replenish_now(struct iwl_priv *priv)
+{
+ iwl_rx_allocate(priv, GFP_ATOMIC);
+
+ iwl_rx_queue_restock(priv);
+}
+EXPORT_SYMBOL(iwl_rx_replenish_now);
+
/* Assumes that the skb field of the buffers in 'pool' is kept accurate.
* If an SKB has been detached, the POOL needs to have its SKB set to NULL
@@ -358,6 +363,7 @@ int iwl_rx_queue_alloc(struct iwl_priv *priv)
/* Set us so that we have processed and used all buffers, but have
* not restocked the Rx queue with fresh buffers */
rxq->read = rxq->write = 0;
+ rxq->write_actual = 0;
rxq->free_count = 0;
rxq->need_update = 0;
return 0;
@@ -396,6 +402,7 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
/* Set us so that we have processed and used all buffers, but have
* not restocked the Rx queue with fresh buffers */
rxq->read = rxq->write = 0;
+ rxq->write_actual = 0;
rxq->free_count = 0;
spin_unlock_irqrestore(&rxq->lock, flags);
}
@@ -403,18 +410,12 @@ EXPORT_SYMBOL(iwl_rx_queue_reset);
int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
{
- int ret;
- unsigned long flags;
u32 rb_size;
const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */
- const u32 rb_timeout = 0; /* FIXME: RX_RB_TIMEOUT why this stalls RX */
+ u32 rb_timeout = 0; /* FIXME: RX_RB_TIMEOUT for all devices? */
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (ret) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
+ if (!priv->cfg->use_isr_legacy)
+ rb_timeout = RX_RB_TIMEOUT;
if (priv->cfg->mod_params->amsdu_size_8K)
rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K;
@@ -452,35 +453,19 @@ int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
(rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)|
(rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS));
- iwl_release_nic_access(priv);
-
iwl_write32(priv, CSR_INT_COALESCING, 0x40);
- spin_unlock_irqrestore(&priv->lock, flags);
-
return 0;
}
int iwl_rxq_stop(struct iwl_priv *priv)
{
- int ret;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (unlikely(ret)) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return ret;
- }
/* stop Rx DMA */
iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG,
FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
- iwl_release_nic_access(priv);
- spin_unlock_irqrestore(&priv->lock, flags);
-
return 0;
}
EXPORT_SYMBOL(iwl_rxq_stop);
@@ -582,8 +567,8 @@ void iwl_rx_statistics(struct iwl_priv *priv,
iwl_leds_background(priv);
- if (priv->cfg->ops->lib->temperature && change)
- priv->cfg->ops->lib->temperature(priv);
+ if (priv->cfg->ops->lib->temp_ops.temperature && change)
+ priv->cfg->ops->lib->temp_ops.temperature(priv);
}
EXPORT_SYMBOL(iwl_rx_statistics);
@@ -1102,13 +1087,6 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
if (rx_start->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
rx_status.flag |= RX_FLAG_SHORTPRE;
- /* Take shortcut when only in monitor mode */
- if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
- iwl_pass_packet_to_mac80211(priv, include_phy,
- rxb, &rx_status);
- return;
- }
-
network_packet = iwl_is_network_packet(priv, header);
if (network_packet) {
priv->last_rx_rssi = rx_status.signal;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index e7c65c4f741b..e26875dbe859 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -227,9 +227,6 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
/* The HW is no longer scanning */
clear_bit(STATUS_SCAN_HW, &priv->status);
- /* The scan completion notification came in, so kill that timer... */
- cancel_delayed_work(&priv->scan_check);
-
IWL_DEBUG_INFO(priv, "Scan pass on %sGHz took %dms\n",
(priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
"2.4" : "5.2",
@@ -448,13 +445,6 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
unsigned long flags;
struct iwl_priv *priv = hw->priv;
int ret;
- u8 *ssid = NULL;
- size_t ssid_len = 0;
-
- if (req->n_ssids) {
- ssid = req->ssids[0].ssid;
- ssid_len = req->ssids[0].ssid_len;
- }
IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -488,13 +478,7 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
goto out_unlock;
}
- if (ssid_len) {
- priv->one_direct_scan = 1;
- priv->direct_ssid_len = ssid_len;
- memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len);
- } else {
- priv->one_direct_scan = 0;
- }
+ priv->scan_request = req;
ret = iwl_scan_initiate(priv);
@@ -533,73 +517,14 @@ void iwl_bg_scan_check(struct work_struct *data)
EXPORT_SYMBOL(iwl_bg_scan_check);
/**
- * iwl_supported_rate_to_ie - fill in the supported rate in IE field
- *
- * return : set the bit for each supported rate insert in ie
- */
-static u16 iwl_supported_rate_to_ie(u8 *ie, u16 supported_rate,
- u16 basic_rate, int *left)
-{
- u16 ret_rates = 0, bit;
- int i;
- u8 *cnt = ie;
- u8 *rates = ie + 1;
-
- for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) {
- if (bit & supported_rate) {
- ret_rates |= bit;
- rates[*cnt] = iwl_rates[i].ieee |
- ((bit & basic_rate) ? 0x80 : 0x00);
- (*cnt)++;
- (*left)--;
- if ((*left <= 0) ||
- (*cnt >= IWL_SUPPORTED_RATES_IE_LEN))
- break;
- }
- }
-
- return ret_rates;
-}
-
-
-static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
- u8 *pos, int *left)
-{
- struct ieee80211_ht_cap *ht_cap;
-
- if (!sband || !sband->ht_cap.ht_supported)
- return;
-
- if (*left < sizeof(struct ieee80211_ht_cap))
- return;
-
- *pos++ = sizeof(struct ieee80211_ht_cap);
- ht_cap = (struct ieee80211_ht_cap *) pos;
-
- ht_cap->cap_info = cpu_to_le16(sband->ht_cap.cap);
- memcpy(&ht_cap->mcs, &sband->ht_cap.mcs, 16);
- ht_cap->ampdu_params_info =
- (sband->ht_cap.ampdu_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) |
- ((sband->ht_cap.ampdu_density << 2) &
- IEEE80211_HT_AMPDU_PARM_DENSITY);
- *left -= sizeof(struct ieee80211_ht_cap);
-}
-
-/**
* iwl_fill_probe_req - fill in all required fields and IE for probe request
*/
-u16 iwl_fill_probe_req(struct iwl_priv *priv,
- enum ieee80211_band band,
- struct ieee80211_mgmt *frame,
- int left)
+u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
+ const u8 *ies, int ie_len, int left)
{
int len = 0;
u8 *pos = NULL;
- u16 active_rates, ret_rates, cck_rates, active_rate_basic;
- const struct ieee80211_supported_band *sband =
- iwl_get_hw_mode(priv, band);
-
/* Make sure there is enough space for the probe request,
* two mandatory IEs and the data */
@@ -627,62 +552,12 @@ u16 iwl_fill_probe_req(struct iwl_priv *priv,
len += 2;
- /* fill in supported rate */
- left -= 2;
- if (left < 0)
- return 0;
+ if (WARN_ON(left < ie_len))
+ return len;
- *pos++ = WLAN_EID_SUPP_RATES;
- *pos = 0;
-
- /* exclude 60M rate */
- active_rates = priv->rates_mask;
- active_rates &= ~IWL_RATE_60M_MASK;
-
- active_rate_basic = active_rates & IWL_BASIC_RATES_MASK;
-
- cck_rates = IWL_CCK_RATES_MASK & active_rates;
- ret_rates = iwl_supported_rate_to_ie(pos, cck_rates,
- active_rate_basic, &left);
- active_rates &= ~ret_rates;
-
- ret_rates = iwl_supported_rate_to_ie(pos, active_rates,
- active_rate_basic, &left);
- active_rates &= ~ret_rates;
-
- len += 2 + *pos;
- pos += (*pos) + 1;
-
- if (active_rates == 0)
- goto fill_end;
-
- /* fill in supported extended rate */
- /* ...next IE... */
- left -= 2;
- if (left < 0)
- return 0;
- /* ... fill it in... */
- *pos++ = WLAN_EID_EXT_SUPP_RATES;
- *pos = 0;
- iwl_supported_rate_to_ie(pos, active_rates, active_rate_basic, &left);
- if (*pos > 0) {
- len += 2 + *pos;
- pos += (*pos) + 1;
- } else {
- pos--;
- }
-
- fill_end:
-
- left -= 2;
- if (left < 0)
- return 0;
-
- *pos++ = WLAN_EID_HT_CAPABILITY;
- *pos = 0;
- iwl_ht_cap_to_ie(sband, pos, &left);
- if (*pos > 0)
- len += 2 + *pos;
+ memcpy(pos, ies, ie_len);
+ len += ie_len;
+ left -= ie_len;
return (u16)len;
}
@@ -702,16 +577,20 @@ static void iwl_bg_request_scan(struct work_struct *data)
int ret = 0;
u32 rate_flags = 0;
u16 cmd_len;
+ u16 rx_chain = 0;
enum ieee80211_band band;
- u8 n_probes = 2;
- u8 rx_chain = priv->hw_params.valid_rx_ant;
+ u8 n_probes = 0;
+ u8 rx_ant = priv->hw_params.valid_rx_ant;
u8 rate;
- DECLARE_SSID_BUF(ssid);
+ bool is_active = false;
+ int chan_mod;
conf = ieee80211_get_hw_conf(priv->hw);
mutex_lock(&priv->mutex);
+ cancel_delayed_work(&priv->scan_check);
+
if (!iwl_is_ready(priv)) {
IWL_WARN(priv, "request scan called when driver not ready.\n");
goto done;
@@ -796,19 +675,25 @@ static void iwl_bg_request_scan(struct work_struct *data)
scan_suspend_time, interval);
}
- /* We should add the ability for user to lock to PASSIVE ONLY */
- if (priv->one_direct_scan) {
- IWL_DEBUG_SCAN(priv, "Start direct scan for '%s'\n",
- print_ssid(ssid, priv->direct_ssid,
- priv->direct_ssid_len));
- scan->direct_scan[0].id = WLAN_EID_SSID;
- scan->direct_scan[0].len = priv->direct_ssid_len;
- memcpy(scan->direct_scan[0].ssid,
- priv->direct_ssid, priv->direct_ssid_len);
- n_probes++;
- } else {
- IWL_DEBUG_SCAN(priv, "Start indirect scan.\n");
- }
+ if (priv->scan_request->n_ssids) {
+ int i, p = 0;
+ IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
+ for (i = 0; i < priv->scan_request->n_ssids; i++) {
+ /* always does wildcard anyway */
+ if (!priv->scan_request->ssids[i].ssid_len)
+ continue;
+ scan->direct_scan[p].id = WLAN_EID_SSID;
+ scan->direct_scan[p].len =
+ priv->scan_request->ssids[i].ssid_len;
+ memcpy(scan->direct_scan[p].ssid,
+ priv->scan_request->ssids[i].ssid,
+ priv->scan_request->ssids[i].ssid_len);
+ n_probes++;
+ p++;
+ }
+ is_active = true;
+ } else
+ IWL_DEBUG_SCAN(priv, "Start passive scan.\n");
scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id;
@@ -818,7 +703,9 @@ static void iwl_bg_request_scan(struct work_struct *data)
if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
band = IEEE80211_BAND_2GHZ;
scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
- if (priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) {
+ chan_mod = le32_to_cpu(priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_MSK)
+ >> RXON_FLG_CHANNEL_MODE_POS;
+ if (chan_mod == CHANNEL_MODE_PURE_40) {
rate = IWL_RATE_6M_PLCP;
} else {
rate = IWL_RATE_1M_PLCP;
@@ -828,13 +715,18 @@ static void iwl_bg_request_scan(struct work_struct *data)
} else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
band = IEEE80211_BAND_5GHZ;
rate = IWL_RATE_6M_PLCP;
- scan->good_CRC_th = IWL_GOOD_CRC_TH;
+ /*
+ * If active scaning is requested but a certain channel
+ * is marked passive, we can do active scanning if we
+ * detect transmissions.
+ */
+ scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH : 0;
/* Force use of chains B and C (0x6) for scan Rx for 4965
* Avoid A (0x1) because of its off-channel reception on A-band.
*/
if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
- rx_chain = 0x6;
+ rx_ant = ANT_BC;
} else {
IWL_WARN(priv, "Invalid scan band count\n");
goto done;
@@ -846,26 +738,27 @@ static void iwl_bg_request_scan(struct work_struct *data)
scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
/* MIMO is not used here, but value is required */
- scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK |
- cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) |
- (rx_chain << RXON_RX_CHAIN_FORCE_SEL_POS) |
- (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS));
-
- cmd_len = iwl_fill_probe_req(priv, band,
- (struct ieee80211_mgmt *)scan->data,
- IWL_MAX_SCAN_SIZE - sizeof(*scan));
+ rx_chain |= ANT_ABC << RXON_RX_CHAIN_VALID_POS;
+ rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
+ rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
+ rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
+ scan->rx_chain = cpu_to_le16(rx_chain);
+ cmd_len = iwl_fill_probe_req(priv,
+ (struct ieee80211_mgmt *)scan->data,
+ priv->scan_request->ie,
+ priv->scan_request->ie_len,
+ IWL_MAX_SCAN_SIZE - sizeof(*scan));
scan->tx_cmd.len = cpu_to_le16(cmd_len);
- if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
+ if (iwl_is_monitor_mode(priv))
scan->filter_flags = RXON_FILTER_PROMISC_MSK;
scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
RXON_FILTER_BCON_AWARE_MSK);
scan->channel_count =
- iwl_get_channels_for_scan(priv, band, 1, /* active */
- n_probes,
+ iwl_get_channels_for_scan(priv, band, is_active, n_probes,
(void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
if (scan->channel_count == 0) {
@@ -925,6 +818,8 @@ void iwl_bg_scan_completed(struct work_struct *work)
IWL_DEBUG_SCAN(priv, "SCAN complete scan\n");
+ cancel_delayed_work(&priv->scan_check);
+
ieee80211_scan_completed(priv->hw, false);
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 44ab03a12e40..0eb939c40ac1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -75,7 +75,7 @@ int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
return IWL_AP_ID;
} else {
u8 *da = ieee80211_get_DA(hdr);
- return iwl_find_station(priv, da);
+ return priv->cfg->ops->smgmt->find_station(priv, da);
}
}
EXPORT_SYMBOL(iwl_get_ra_sta_id);
@@ -300,7 +300,7 @@ EXPORT_SYMBOL(iwl_add_station_flags);
static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr)
{
unsigned long flags;
- u8 sta_id = iwl_find_station(priv, addr);
+ u8 sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
BUG_ON(sta_id == IWL_INVALID_STATION);
@@ -490,7 +490,7 @@ void iwl_clear_stations_table(struct iwl_priv *priv)
/* keep track of static keys */
for (i = 0; i < WEP_KEYS_MAX ; i++) {
if (priv->wep_keys[i].key_size)
- test_and_set_bit(i, &priv->ucode_key_table);
+ set_bit(i, &priv->ucode_key_table);
}
spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -767,7 +767,7 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
unsigned long flags;
int i;
- sta_id = iwl_find_station(priv, addr);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION) {
IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
addr);
@@ -1020,7 +1020,7 @@ int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
rcu_read_unlock();
}
- sta_id = iwl_add_station_flags(priv, addr, is_ap,
+ sta_id = priv->cfg->ops->smgmt->add_station(priv, addr, is_ap,
0, cur_ht_config);
/* Set up default rate scaling table in device's station table */
@@ -1054,7 +1054,7 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
/* If we are an AP, then find the station, or use BCAST */
case NL80211_IFTYPE_AP:
- sta_id = iwl_find_station(priv, hdr->addr1);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, hdr->addr1);
if (sta_id != IWL_INVALID_STATION)
return sta_id;
return priv->hw_params.bcast_sta_id;
@@ -1062,12 +1062,12 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
/* If this frame is going out to an IBSS network, find the station,
* or create a new station table entry */
case NL80211_IFTYPE_ADHOC:
- sta_id = iwl_find_station(priv, hdr->addr1);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, hdr->addr1);
if (sta_id != IWL_INVALID_STATION)
return sta_id;
/* Create new station table entry */
- sta_id = iwl_add_station_flags(priv, hdr->addr1,
+ sta_id = priv->cfg->ops->smgmt->add_station(priv, hdr->addr1,
0, CMD_ASYNC, NULL);
if (sta_id != IWL_INVALID_STATION)
@@ -1079,11 +1079,6 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
return priv->hw_params.bcast_sta_id;
- /* If we are in monitor mode, use BCAST. This is required for
- * packet injection. */
- case NL80211_IFTYPE_MONITOR:
- return priv->hw_params.bcast_sta_id;
-
default:
IWL_WARN(priv, "Unknown mode of operation: %d\n",
priv->iw_mode);
@@ -1116,7 +1111,7 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv,
unsigned long flags;
int sta_id;
- sta_id = iwl_find_station(priv, addr);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION)
return -ENXIO;
@@ -1138,7 +1133,7 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid)
unsigned long flags;
int sta_id;
- sta_id = iwl_find_station(priv, addr);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION) {
IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid);
return -ENXIO;
@@ -1173,7 +1168,7 @@ static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
void iwl_update_ps_mode(struct iwl_priv *priv, u16 ps_bit, u8 *addr)
{
/* FIXME: need locking over ps_status ??? */
- u8 sta_id = iwl_find_station(priv, addr);
+ u8 sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
if (sta_id != IWL_INVALID_STATION) {
u8 sta_awake = priv->stations[sta_id].
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 71d5b8a1a73e..85ae7a62109c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -102,13 +102,8 @@ int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq)
return ret;
}
- /* restore this queue's parameters in nic hardware. */
- ret = iwl_grab_nic_access(priv);
- if (ret)
- return ret;
iwl_write_direct32(priv, HBUS_TARG_WRPTR,
txq->q.write_ptr | (txq_id << 8));
- iwl_release_nic_access(priv);
/* else not in power-save mode, uCode will never sleep when we're
* trying to tx (during RFKILL, we're not trying to tx). */
@@ -429,11 +424,6 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
goto error_kw;
}
spin_lock_irqsave(&priv->lock, flags);
- ret = iwl_grab_nic_access(priv);
- if (unlikely(ret)) {
- spin_unlock_irqrestore(&priv->lock, flags);
- goto error_reset;
- }
/* Turn off all Tx DMA fifos */
priv->cfg->ops->lib->txq_set_sched(priv, 0);
@@ -441,7 +431,6 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
/* Tell NIC where to find the "keep warm" buffer */
iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4);
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
/* Alloc and init all Tx queues, including the command queue (#4) */
@@ -460,7 +449,6 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
error:
iwl_hw_txq_ctx_free(priv);
- error_reset:
iwl_free_dma_ptr(priv, &priv->kw);
error_kw:
iwl_free_dma_ptr(priv, &priv->scd_bc_tbls);
@@ -478,10 +466,6 @@ void iwl_txq_ctx_stop(struct iwl_priv *priv)
/* Turn off all Tx DMA fifos */
spin_lock_irqsave(&priv->lock, flags);
- if (iwl_grab_nic_access(priv)) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return;
- }
priv->cfg->ops->lib->txq_set_sched(priv, 0);
@@ -492,7 +476,6 @@ void iwl_txq_ctx_stop(struct iwl_priv *priv)
FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch),
1000);
}
- iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
/* Deallocate memory for all Tx queues */
@@ -728,7 +711,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
/* drop all data frame if we are not associated */
if (ieee80211_is_data(fc) &&
- (priv->iw_mode != NL80211_IFTYPE_MONITOR ||
+ (!iwl_is_monitor_mode(priv) ||
!(info->flags & IEEE80211_TX_CTL_INJECTED)) && /* packet injection */
(!iwl_is_associated(priv) ||
((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) ||
@@ -1183,8 +1166,10 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
__func__, ra, tid);
sta_id = iwl_find_station(priv, ra);
- if (sta_id == IWL_INVALID_STATION)
+ if (sta_id == IWL_INVALID_STATION) {
+ IWL_ERR(priv, "Start AGG on invalid station\n");
return -ENXIO;
+ }
if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) {
IWL_ERR(priv, "Start AGG when state is not IWL_AGG_OFF !\n");
@@ -1192,8 +1177,10 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
}
txq_id = iwl_txq_ctx_activate_free(priv);
- if (txq_id == -1)
+ if (txq_id == -1) {
+ IWL_ERR(priv, "No free aggregation queue available\n");
return -ENXIO;
+ }
spin_lock_irqsave(&priv->sta_lock, flags);
tid_data = &priv->stations[sta_id].tid[tid];
@@ -1207,7 +1194,7 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
return ret;
if (tid_data->tfds_in_queue == 0) {
- IWL_ERR(priv, "HW queue is empty\n");
+ IWL_DEBUG_HT(priv, "HW queue is empty\n");
tid_data->agg.state = IWL_AGG_ON;
ieee80211_start_tx_ba_cb_irqsafe(priv->hw, ra, tid);
} else {
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 4cce66133500..5c10b87d0336 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -149,7 +149,7 @@ out:
*
* NOTE: This does not clear or otherwise alter the device's station table.
*/
-static void iwl3945_clear_stations_table(struct iwl_priv *priv)
+void iwl3945_clear_stations_table(struct iwl_priv *priv)
{
unsigned long flags;
@@ -164,7 +164,7 @@ static void iwl3945_clear_stations_table(struct iwl_priv *priv)
/**
* iwl3945_add_station - Add station to station tables in driver and device
*/
-u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap, u8 flags)
+u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap, u8 flags, struct ieee80211_sta_ht_cap *ht_info)
{
int i;
int index = IWL_INVALID_STATION;
@@ -233,50 +233,6 @@ u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap, u8 flag
}
-static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
-{
- int rc = 0;
- struct iwl_rx_packet *res = NULL;
- struct iwl3945_rxon_assoc_cmd rxon_assoc;
- struct iwl_host_cmd cmd = {
- .id = REPLY_RXON_ASSOC,
- .len = sizeof(rxon_assoc),
- .meta.flags = CMD_WANT_SKB,
- .data = &rxon_assoc,
- };
- const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
- const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
-
- if ((rxon1->flags == rxon2->flags) &&
- (rxon1->filter_flags == rxon2->filter_flags) &&
- (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
- (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
- IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
- return 0;
- }
-
- rxon_assoc.flags = priv->staging_rxon.flags;
- rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
- rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
- rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
- rxon_assoc.reserved = 0;
-
- rc = iwl_send_cmd_sync(priv, &cmd);
- if (rc)
- return rc;
-
- res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
- if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
- IWL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n");
- rc = -EIO;
- }
-
- priv->alloc_rxb_skb--;
- dev_kfree_skb_any(cmd.meta.u.skb);
-
- return rc;
-}
-
/**
* iwl3945_get_antenna_flags - Get antenna flags for RXON command
* @priv: eeprom and antenna fields are used to determine antenna flags
@@ -314,150 +270,6 @@ __le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv)
return 0; /* "diversity" is default if error */
}
-/**
- * iwl3945_commit_rxon - commit staging_rxon to hardware
- *
- * The RXON command in staging_rxon is committed to the hardware and
- * the active_rxon structure is updated with the new data. This
- * function correctly transitions out of the RXON_ASSOC_MSK state if
- * a HW tune is required based on the RXON structure changes.
- */
-static int iwl3945_commit_rxon(struct iwl_priv *priv)
-{
- /* cast away the const for active_rxon in this function */
- struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
- struct iwl3945_rxon_cmd *staging_rxon = (void *)&priv->staging_rxon;
- int rc = 0;
- bool new_assoc =
- !!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK);
-
- if (!iwl_is_alive(priv))
- return -1;
-
- /* always get timestamp with Rx frame */
- staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK;
-
- /* select antenna */
- staging_rxon->flags &=
- ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
- staging_rxon->flags |= iwl3945_get_antenna_flags(priv);
-
- rc = iwl_check_rxon_cmd(priv);
- if (rc) {
- IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
- return -EINVAL;
- }
-
- /* If we don't need to send a full RXON, we can use
- * iwl3945_rxon_assoc_cmd which is used to reconfigure filter
- * and other flags for the current radio configuration. */
- if (!iwl_full_rxon_required(priv)) {
- rc = iwl3945_send_rxon_assoc(priv);
- if (rc) {
- IWL_ERR(priv, "Error setting RXON_ASSOC "
- "configuration (%d).\n", rc);
- return rc;
- }
-
- memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
-
- return 0;
- }
-
- /* If we are currently associated and the new config requires
- * an RXON_ASSOC and the new config wants the associated mask enabled,
- * we must clear the associated from the active configuration
- * before we apply the new config */
- if (iwl_is_associated(priv) && new_assoc) {
- IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n");
- active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
-
- /*
- * reserved4 and 5 could have been filled by the iwlcore code.
- * Let's clear them before pushing to the 3945.
- */
- active_rxon->reserved4 = 0;
- active_rxon->reserved5 = 0;
- rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
- sizeof(struct iwl3945_rxon_cmd),
- &priv->active_rxon);
-
- /* If the mask clearing failed then we set
- * active_rxon back to what it was previously */
- if (rc) {
- active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK;
- IWL_ERR(priv, "Error clearing ASSOC_MSK on current "
- "configuration (%d).\n", rc);
- return rc;
- }
- }
-
- IWL_DEBUG_INFO(priv, "Sending RXON\n"
- "* with%s RXON_FILTER_ASSOC_MSK\n"
- "* channel = %d\n"
- "* bssid = %pM\n",
- (new_assoc ? "" : "out"),
- le16_to_cpu(staging_rxon->channel),
- staging_rxon->bssid_addr);
-
- /*
- * reserved4 and 5 could have been filled by the iwlcore code.
- * Let's clear them before pushing to the 3945.
- */
- staging_rxon->reserved4 = 0;
- staging_rxon->reserved5 = 0;
-
- iwl_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto);
-
- /* Apply the new configuration */
- rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
- sizeof(struct iwl3945_rxon_cmd),
- staging_rxon);
- if (rc) {
- IWL_ERR(priv, "Error setting new configuration (%d).\n", rc);
- return rc;
- }
-
- memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
-
- iwl3945_clear_stations_table(priv);
-
- /* If we issue a new RXON command which required a tune then we must
- * send a new TXPOWER command or we won't be able to Tx any frames */
- rc = priv->cfg->ops->lib->send_tx_power(priv);
- if (rc) {
- IWL_ERR(priv, "Error setting Tx power (%d).\n", rc);
- return rc;
- }
-
- /* Add the broadcast address so we can send broadcast frames */
- if (iwl3945_add_station(priv, iwl_bcast_addr, 0, 0) ==
- IWL_INVALID_STATION) {
- IWL_ERR(priv, "Error adding BROADCAST address for transmit.\n");
- return -EIO;
- }
-
- /* If we have set the ASSOC_MSK and we are in BSS mode then
- * add the IWL_AP_ID to the station rate table */
- if (iwl_is_associated(priv) &&
- (priv->iw_mode == NL80211_IFTYPE_STATION))
- if (iwl3945_add_station(priv, priv->active_rxon.bssid_addr,
- 1, 0)
- == IWL_INVALID_STATION) {
- IWL_ERR(priv, "Error adding AP address for transmit\n");
- return -EIO;
- }
-
- /* Init the hardware's rate fallback order based on the band */
- rc = iwl3945_init_hw_rate_table(priv);
- if (rc) {
- IWL_ERR(priv, "Error setting HW rate table: %02X\n", rc);
- return -EIO;
- }
-
- return 0;
-}
-
static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
struct ieee80211_key_conf *keyconf,
u8 sta_id)
@@ -528,7 +340,7 @@ static int iwl3945_clear_sta_key_info(struct iwl_priv *priv, u8 sta_id)
unsigned long flags;
spin_lock_irqsave(&priv->sta_lock, flags);
- memset(&priv->stations_39[sta_id].keyinfo, 0, sizeof(struct iwl3945_hw_key));
+ memset(&priv->stations_39[sta_id].keyinfo, 0, sizeof(struct iwl_hw_key));
memset(&priv->stations_39[sta_id].sta.key, 0,
sizeof(struct iwl4965_keyinfo));
priv->stations_39[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC;
@@ -739,7 +551,8 @@ static void iwl3945_setup_rxon_timing(struct iwl_priv *priv)
priv->rxon_timing.atim_window = 0;
} else {
priv->rxon_timing.beacon_interval =
- iwl3945_adjust_beacon_interval(conf->beacon_int);
+ iwl3945_adjust_beacon_interval(
+ priv->vif->bss_conf.beacon_int);
/* TODO: we need to get atim_window from upper stack
* for now we set to 0 */
priv->rxon_timing.atim_window = 0;
@@ -758,42 +571,6 @@ static void iwl3945_setup_rxon_timing(struct iwl_priv *priv)
le16_to_cpu(priv->rxon_timing.atim_window));
}
-static int iwl3945_set_mode(struct iwl_priv *priv, int mode)
-{
- if (mode == NL80211_IFTYPE_ADHOC) {
- const struct iwl_channel_info *ch_info;
-
- ch_info = iwl_get_channel_info(priv,
- priv->band,
- le16_to_cpu(priv->staging_rxon.channel));
-
- if (!ch_info || !is_channel_ibss(ch_info)) {
- IWL_ERR(priv, "channel %d not IBSS channel\n",
- le16_to_cpu(priv->staging_rxon.channel));
- return -EINVAL;
- }
- }
-
- iwl_connection_init_rx_config(priv, mode);
-
- iwl3945_clear_stations_table(priv);
-
- /* don't commit rxon if rf-kill is on*/
- if (!iwl_is_ready_rf(priv))
- return -EAGAIN;
-
- cancel_delayed_work(&priv->scan_check);
- if (iwl_scan_cancel_timeout(priv, 100)) {
- IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
- IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
- return -EAGAIN;
- }
-
- iwl3945_commit_rxon(priv);
-
- return 0;
-}
-
static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
struct ieee80211_tx_info *info,
struct iwl_cmd *cmd,
@@ -801,8 +578,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
int sta_id)
{
struct iwl3945_tx_cmd *tx = (struct iwl3945_tx_cmd *)cmd->cmd.payload;
- struct iwl3945_hw_key *keyinfo =
- &priv->stations_39[sta_id].keyinfo;
+ struct iwl_hw_key *keyinfo = &priv->stations_39[sta_id].keyinfo;
switch (keyinfo->alg) {
case ALG_CCMP:
@@ -900,64 +676,6 @@ static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv,
tx->next_frame_len = 0;
}
-/**
- * iwl3945_get_sta_id - Find station's index within station table
- */
-static int iwl3945_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
-{
- int sta_id;
- u16 fc = le16_to_cpu(hdr->frame_control);
-
- /* If this frame is broadcast or management, use broadcast station id */
- if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) ||
- is_multicast_ether_addr(hdr->addr1))
- return priv->hw_params.bcast_sta_id;
-
- switch (priv->iw_mode) {
-
- /* If we are a client station in a BSS network, use the special
- * AP station entry (that's the only station we communicate with) */
- case NL80211_IFTYPE_STATION:
- return IWL_AP_ID;
-
- /* If we are an AP, then find the station, or use BCAST */
- case NL80211_IFTYPE_AP:
- sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
- if (sta_id != IWL_INVALID_STATION)
- return sta_id;
- return priv->hw_params.bcast_sta_id;
-
- /* If this frame is going out to an IBSS network, find the station,
- * or create a new station table entry */
- case NL80211_IFTYPE_ADHOC: {
- /* Create new station table entry */
- sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
- if (sta_id != IWL_INVALID_STATION)
- return sta_id;
-
- sta_id = iwl3945_add_station(priv, hdr->addr1, 0, CMD_ASYNC);
-
- if (sta_id != IWL_INVALID_STATION)
- return sta_id;
-
- IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
- "Defaulting to broadcast...\n",
- hdr->addr1);
- iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
- return priv->hw_params.bcast_sta_id;
- }
- /* If we are in monitor mode, use BCAST. This is required for
- * packet injection. */
- case NL80211_IFTYPE_MONITOR:
- return priv->hw_params.bcast_sta_id;
-
- default:
- IWL_WARN(priv, "Unknown mode of operation: %d\n",
- priv->iw_mode);
- return priv->hw_params.bcast_sta_id;
- }
-}
-
/*
* start REPLY_TX command process
*/
@@ -1011,7 +729,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
/* drop all data frame if we are not associated */
if (ieee80211_is_data(fc) &&
- (priv->iw_mode != NL80211_IFTYPE_MONITOR) && /* packet injection */
+ (!iwl_is_monitor_mode(priv)) && /* packet injection */
(!iwl_is_associated(priv) ||
((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) {
IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
@@ -1023,7 +741,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
hdr_len = ieee80211_hdrlen(fc);
/* Find (or create) index into station table for destination station */
- sta_id = iwl3945_get_sta_id(priv, hdr);
+ sta_id = iwl_get_sta_id(priv, hdr);
if (sta_id == IWL_INVALID_STATION) {
IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
hdr->addr1);
@@ -1625,15 +1343,24 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv)
struct list_head *element;
struct iwl_rx_mem_buffer *rxb;
unsigned long flags;
- spin_lock_irqsave(&rxq->lock, flags);
- while (!list_empty(&rxq->rx_used)) {
+
+ while (1) {
+ spin_lock_irqsave(&rxq->lock, flags);
+
+ if (list_empty(&rxq->rx_used)) {
+ spin_unlock_irqrestore(&rxq->lock, flags);
+ return;
+ }
+
element = rxq->rx_used.next;
rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
+ list_del(element);
+ spin_unlock_irqrestore(&rxq->lock, flags);
/* Alloc a new receive buffer */
rxb->skb =
alloc_skb(priv->hw_params.rx_buf_size,
- __GFP_NOWARN | GFP_ATOMIC);
+ GFP_KERNEL);
if (!rxb->skb) {
if (net_ratelimit())
IWL_CRIT(priv, ": Can not allocate SKB buffers\n");
@@ -1651,18 +1378,18 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv)
*/
skb_reserve(rxb->skb, 4);
- priv->alloc_rxb_skb++;
- list_del(element);
-
/* Get physical address of RB/SKB */
rxb->real_dma_addr = pci_map_single(priv->pci_dev,
rxb->skb->data,
priv->hw_params.rx_buf_size,
PCI_DMA_FROMDEVICE);
+
+ spin_lock_irqsave(&rxq->lock, flags);
list_add_tail(&rxb->list, &rxq->rx_free);
+ priv->alloc_rxb_skb++;
rxq->free_count++;
+ spin_unlock_irqrestore(&rxq->lock, flags);
}
- spin_unlock_irqrestore(&rxq->lock, flags);
}
void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
@@ -1695,18 +1422,6 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
spin_unlock_irqrestore(&rxq->lock, flags);
}
-/*
- * this should be called while priv->lock is locked
- */
-static void __iwl3945_rx_replenish(void *data)
-{
- struct iwl_priv *priv = data;
-
- iwl3945_rx_allocate(priv);
- iwl3945_rx_queue_restock(priv);
-}
-
-
void iwl3945_rx_replenish(void *data)
{
struct iwl_priv *priv = data;
@@ -1886,6 +1601,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv)
"r = %d, i = %d, %s, 0x%02x\n", r, i,
get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
+ priv->isr_stats.rx_handlers[pkt->hdr.cmd]++;
} else {
/* No handling needed */
IWL_DEBUG(priv, IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR,
@@ -1923,7 +1639,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv)
count++;
if (count >= 8) {
priv->rxq.read = i;
- __iwl3945_rx_replenish(priv);
+ iwl3945_rx_queue_restock(priv);
count = 0;
}
}
@@ -1970,7 +1686,6 @@ static void iwl3945_dump_nic_error_log(struct iwl_priv *priv)
u32 i;
u32 desc, time, count, base, data1;
u32 blink1, blink2, ilink1, ilink2;
- int rc;
base = le32_to_cpu(priv->card_alive.error_event_table_ptr);
@@ -1979,11 +1694,6 @@ static void iwl3945_dump_nic_error_log(struct iwl_priv *priv)
return;
}
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- IWL_WARN(priv, "Can not read from adapter at this time.\n");
- return;
- }
count = iwl_read_targ_mem(priv, base);
@@ -2018,8 +1728,6 @@ static void iwl3945_dump_nic_error_log(struct iwl_priv *priv)
ilink1, ilink2, data1);
}
- iwl_release_nic_access(priv);
-
}
#define EVENT_START_OFFSET (6 * sizeof(u32))
@@ -2027,7 +1735,6 @@ static void iwl3945_dump_nic_error_log(struct iwl_priv *priv)
/**
* iwl3945_print_event_log - Dump error event log to syslog
*
- * NOTE: Must be called with iwl_grab_nic_access() already obtained!
*/
static void iwl3945_print_event_log(struct iwl_priv *priv, u32 start_idx,
u32 num_events, u32 mode)
@@ -2070,7 +1777,6 @@ static void iwl3945_print_event_log(struct iwl_priv *priv, u32 start_idx,
static void iwl3945_dump_nic_event_log(struct iwl_priv *priv)
{
- int rc;
u32 base; /* SRAM byte address of event log header */
u32 capacity; /* event log capacity in # entries */
u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
@@ -2084,12 +1790,6 @@ static void iwl3945_dump_nic_event_log(struct iwl_priv *priv)
return;
}
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- IWL_WARN(priv, "Can not read from adapter at this time.\n");
- return;
- }
-
/* event log header */
capacity = iwl_read_targ_mem(priv, base);
mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32)));
@@ -2101,7 +1801,6 @@ static void iwl3945_dump_nic_event_log(struct iwl_priv *priv)
/* bail out if nothing in log */
if (size == 0) {
IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n");
- iwl_release_nic_access(priv);
return;
}
@@ -2117,24 +1816,6 @@ static void iwl3945_dump_nic_event_log(struct iwl_priv *priv)
/* (then/else) start at top of log */
iwl3945_print_event_log(priv, 0, next_entry, mode);
- iwl_release_nic_access(priv);
-}
-
-static void iwl3945_error_recovery(struct iwl_priv *priv)
-{
- unsigned long flags;
-
- memcpy(&priv->staging_rxon, &priv->recovery_rxon,
- sizeof(priv->staging_rxon));
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
-
- iwl3945_add_station(priv, priv->bssid, 1, 0);
-
- spin_lock_irqsave(&priv->lock, flags);
- priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id);
- priv->error_recovering = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
}
static void iwl3945_irq_tasklet(struct iwl_priv *priv)
@@ -2185,6 +1866,7 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
/* Tell the device to stop sending interrupts */
iwl_disable_interrupts(priv);
+ priv->isr_stats.hw++;
iwl_irq_handle_error(priv);
handled |= CSR_INT_BIT_HW_ERR;
@@ -2197,13 +1879,17 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
#ifdef CONFIG_IWLWIFI_DEBUG
if (priv->debug_level & (IWL_DL_ISR)) {
/* NIC fires this, but we don't use it, redundant with WAKEUP */
- if (inta & CSR_INT_BIT_SCD)
+ if (inta & CSR_INT_BIT_SCD) {
IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
"the frame/frames.\n");
+ priv->isr_stats.sch++;
+ }
/* Alive notification via Rx interrupt will do the real work */
- if (inta & CSR_INT_BIT_ALIVE)
+ if (inta & CSR_INT_BIT_ALIVE) {
IWL_DEBUG_ISR(priv, "Alive interrupt\n");
+ priv->isr_stats.alive++;
+ }
}
#endif
/* Safely ignore these bits for debug checks below */
@@ -2213,6 +1899,8 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
if (inta & CSR_INT_BIT_SW_ERR) {
IWL_ERR(priv, "Microcode SW error detected. "
"Restarting 0x%X.\n", inta);
+ priv->isr_stats.sw++;
+ priv->isr_stats.sw_err = inta;
iwl_irq_handle_error(priv);
handled |= CSR_INT_BIT_SW_ERR;
}
@@ -2228,6 +1916,7 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
iwl_txq_update_write_ptr(priv, &priv->txq[4]);
iwl_txq_update_write_ptr(priv, &priv->txq[5]);
+ priv->isr_stats.wakeup++;
handled |= CSR_INT_BIT_WAKEUP;
}
@@ -2236,27 +1925,28 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
* notifications from uCode come through here*/
if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
iwl3945_rx_handle(priv);
+ priv->isr_stats.rx++;
handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
}
if (inta & CSR_INT_BIT_FH_TX) {
IWL_DEBUG_ISR(priv, "Tx interrupt\n");
+ priv->isr_stats.tx++;
iwl_write32(priv, CSR_FH_INT_STATUS, (1 << 6));
- if (!iwl_grab_nic_access(priv)) {
- iwl_write_direct32(priv, FH39_TCSR_CREDIT
- (FH39_SRVC_CHNL), 0x0);
- iwl_release_nic_access(priv);
- }
+ iwl_write_direct32(priv, FH39_TCSR_CREDIT
+ (FH39_SRVC_CHNL), 0x0);
handled |= CSR_INT_BIT_FH_TX;
}
- if (inta & ~handled)
+ if (inta & ~handled) {
IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
+ priv->isr_stats.unhandled++;
+ }
- if (inta & ~CSR_INI_SET_MASK) {
+ if (inta & ~priv->inta_mask) {
IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n",
- inta & ~CSR_INI_SET_MASK);
+ inta & ~priv->inta_mask);
IWL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh);
}
@@ -2420,10 +2110,6 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le
IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
- rc = iwl_grab_nic_access(priv);
- if (rc)
- return rc;
-
iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
IWL39_RTC_INST_LOWER_BOUND);
@@ -2444,7 +2130,6 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le
}
}
- iwl_release_nic_access(priv);
if (!errcnt)
IWL_DEBUG_INFO(priv,
@@ -2468,10 +2153,6 @@ static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
- rc = iwl_grab_nic_access(priv);
- if (rc)
- return rc;
-
for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
/* read data comes through single port, auto-incr addr */
/* NOTE: Use the debugless read so we don't flood kernel log
@@ -2492,8 +2173,6 @@ static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
}
}
- iwl_release_nic_access(priv);
-
return rc;
}
@@ -2817,20 +2496,11 @@ static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv)
{
dma_addr_t pinst;
dma_addr_t pdata;
- int rc = 0;
- unsigned long flags;
/* bits 31:0 for 3945 */
pinst = priv->ucode_code.p_addr;
pdata = priv->ucode_data_backup.p_addr;
- spin_lock_irqsave(&priv->lock, flags);
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- spin_unlock_irqrestore(&priv->lock, flags);
- return rc;
- }
-
/* Tell bootstrap uCode where to find image to load */
iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst);
iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata);
@@ -2842,13 +2512,9 @@ static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv)
iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG,
priv->ucode_code.len | BSM_DRAM_INST_LOAD);
- iwl_release_nic_access(priv);
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n");
- return rc;
+ return 0;
}
/**
@@ -2894,11 +2560,6 @@ static void iwl3945_init_alive_start(struct iwl_priv *priv)
queue_work(priv->workqueue, &priv->restart);
}
-
-/* temporary */
-static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw,
- struct sk_buff *skb);
-
/**
* iwl3945_alive_start - called after REPLY_ALIVE notification received
* from protocol/runtime uCode (initialization uCode's
@@ -2906,7 +2567,6 @@ static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw,
*/
static void iwl3945_alive_start(struct iwl_priv *priv)
{
- int rc = 0;
int thermal_spin = 0;
u32 rfkill;
@@ -2929,17 +2589,10 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
goto restart;
}
- iwl3945_clear_stations_table(priv);
-
- rc = iwl_grab_nic_access(priv);
- if (rc) {
- IWL_WARN(priv, "Can not read RFKILL status from adapter\n");
- return;
- }
+ priv->cfg->ops->smgmt->clear_station_table(priv);
rfkill = iwl_read_prph(priv, APMG_RFKILL_REG);
IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill);
- iwl_release_nic_access(priv);
if (rfkill & 0x1) {
clear_bit(STATUS_RF_KILL_HW, &priv->status);
@@ -2959,9 +2612,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
/* After the ALIVE response, we can send commands to 3945 uCode */
set_bit(STATUS_ALIVE, &priv->status);
- /* Clear out the uCode error bit if it is set */
- clear_bit(STATUS_FW_ERROR, &priv->status);
-
if (iwl_is_rfkill(priv))
return;
@@ -2988,7 +2638,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
iwl_send_bt_config(priv);
/* Configure the adapter for unassociated operation */
- iwl3945_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
iwl3945_reg_txpower_periodic(priv);
@@ -2998,17 +2648,17 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
set_bit(STATUS_READY, &priv->status);
wake_up_interruptible(&priv->wait_command_queue);
- if (priv->error_recovering)
- iwl3945_error_recovery(priv);
-
/* reassociate for ADHOC mode */
if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) {
struct sk_buff *beacon = ieee80211_beacon_get(priv->hw,
priv->vif);
if (beacon)
- iwl3945_mac_beacon_update(priv->hw, beacon);
+ iwl_mac_beacon_update(priv->hw, beacon);
}
+ if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status))
+ iwl_set_mode(priv, priv->iw_mode);
+
return;
restart:
@@ -3031,7 +2681,7 @@ static void __iwl3945_down(struct iwl_priv *priv)
set_bit(STATUS_EXIT_PENDING, &priv->status);
iwl3945_led_unregister(priv);
- iwl3945_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
/* Unblock any waiting calls */
wake_up_interruptible_all(&priv->wait_command_queue);
@@ -3054,7 +2704,7 @@ static void __iwl3945_down(struct iwl_priv *priv)
ieee80211_stop_queues(priv->hw);
/* If we have not previously called iwl3945_init() then
- * clear all bits but the RF Kill and SUSPEND bits and return */
+ * clear all bits but the RF Kill bits and return */
if (!iwl_is_init(priv)) {
priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) <<
STATUS_RF_KILL_HW |
@@ -3062,23 +2712,19 @@ static void __iwl3945_down(struct iwl_priv *priv)
STATUS_RF_KILL_SW |
test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
STATUS_GEO_CONFIGURED |
- test_bit(STATUS_IN_SUSPEND, &priv->status) <<
- STATUS_IN_SUSPEND |
test_bit(STATUS_EXIT_PENDING, &priv->status) <<
STATUS_EXIT_PENDING;
goto exit;
}
- /* ...otherwise clear out all the status bits but the RF Kill and
- * SUSPEND bits and continue taking the NIC down. */
+ /* ...otherwise clear out all the status bits but the RF Kill
+ * bits and continue taking the NIC down. */
priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) <<
STATUS_RF_KILL_HW |
test_bit(STATUS_RF_KILL_SW, &priv->status) <<
STATUS_RF_KILL_SW |
test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
STATUS_GEO_CONFIGURED |
- test_bit(STATUS_IN_SUSPEND, &priv->status) <<
- STATUS_IN_SUSPEND |
test_bit(STATUS_FW_ERROR, &priv->status) <<
STATUS_FW_ERROR |
test_bit(STATUS_EXIT_PENDING, &priv->status) <<
@@ -3092,17 +2738,12 @@ static void __iwl3945_down(struct iwl_priv *priv)
iwl3945_hw_txq_ctx_stop(priv);
iwl3945_hw_rxq_stop(priv);
- spin_lock_irqsave(&priv->lock, flags);
- if (!iwl_grab_nic_access(priv)) {
- iwl_write_prph(priv, APMG_CLK_DIS_REG,
- APMG_CLK_VAL_DMA_CLK_RQT);
- iwl_release_nic_access(priv);
- }
- spin_unlock_irqrestore(&priv->lock, flags);
+ iwl_write_prph(priv, APMG_CLK_DIS_REG,
+ APMG_CLK_VAL_DMA_CLK_RQT);
udelay(5);
- if (exit_pending || test_bit(STATUS_IN_SUSPEND, &priv->status))
+ if (exit_pending)
priv->cfg->ops->lib->apm_ops.stop(priv);
else
priv->cfg->ops->lib->apm_ops.reset(priv);
@@ -3155,10 +2796,8 @@ static int __iwl3945_up(struct iwl_priv *priv)
clear_bit(STATUS_RF_KILL_HW, &priv->status);
else {
set_bit(STATUS_RF_KILL_HW, &priv->status);
- if (!test_bit(STATUS_IN_SUSPEND, &priv->status)) {
- IWL_WARN(priv, "Radio disabled by HW RF Kill switch\n");
- return -ENODEV;
- }
+ IWL_WARN(priv, "Radio disabled by HW RF Kill switch\n");
+ return -ENODEV;
}
iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
@@ -3194,7 +2833,7 @@ static int __iwl3945_up(struct iwl_priv *priv)
for (i = 0; i < MAX_HW_RESTARTS; i++) {
- iwl3945_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
/* load bootstrap state machine,
* load bootstrap program into processor's memory,
@@ -3290,14 +2929,16 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
int rc = 0;
struct iwl3945_scan_cmd *scan;
struct ieee80211_conf *conf = NULL;
- u8 n_probes = 2;
+ u8 n_probes = 0;
enum ieee80211_band band;
- DECLARE_SSID_BUF(ssid);
+ bool is_active = false;
conf = ieee80211_get_hw_conf(priv->hw);
mutex_lock(&priv->mutex);
+ cancel_delayed_work(&priv->scan_check);
+
if (!iwl_is_ready(priv)) {
IWL_WARN(priv, "request scan called when driver not ready.\n");
goto done;
@@ -3391,18 +3032,25 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
scan_suspend_time, interval);
}
- /* We should add the ability for user to lock to PASSIVE ONLY */
- if (priv->one_direct_scan) {
- IWL_DEBUG_SCAN(priv, "Kicking off one direct scan for '%s'\n",
- print_ssid(ssid, priv->direct_ssid,
- priv->direct_ssid_len));
- scan->direct_scan[0].id = WLAN_EID_SSID;
- scan->direct_scan[0].len = priv->direct_ssid_len;
- memcpy(scan->direct_scan[0].ssid,
- priv->direct_ssid, priv->direct_ssid_len);
- n_probes++;
+ if (priv->scan_request->n_ssids) {
+ int i, p = 0;
+ IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
+ for (i = 0; i < priv->scan_request->n_ssids; i++) {
+ /* always does wildcard anyway */
+ if (!priv->scan_request->ssids[i].ssid_len)
+ continue;
+ scan->direct_scan[p].id = WLAN_EID_SSID;
+ scan->direct_scan[p].len =
+ priv->scan_request->ssids[i].ssid_len;
+ memcpy(scan->direct_scan[p].ssid,
+ priv->scan_request->ssids[i].ssid,
+ priv->scan_request->ssids[i].ssid_len);
+ n_probes++;
+ p++;
+ }
+ is_active = true;
} else
- IWL_DEBUG_SCAN(priv, "Kicking off one indirect scan.\n");
+ IWL_DEBUG_SCAN(priv, "Kicking off passive scan.\n");
/* We don't build a direct scan probe request; the uCode will do
* that based on the direct_mask added to each channel entry */
@@ -3419,7 +3067,12 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
band = IEEE80211_BAND_2GHZ;
} else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
scan->tx_cmd.rate = IWL_RATE_6M_PLCP;
- scan->good_CRC_th = IWL_GOOD_CRC_TH;
+ /*
+ * If active scaning is requested but a certain channel
+ * is marked passive, we can do active scanning if we
+ * detect transmissions.
+ */
+ scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH : 0;
band = IEEE80211_BAND_5GHZ;
} else {
IWL_WARN(priv, "Invalid scan band count\n");
@@ -3427,19 +3080,20 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
}
scan->tx_cmd.len = cpu_to_le16(
- iwl_fill_probe_req(priv, band,
- (struct ieee80211_mgmt *)scan->data,
- IWL_MAX_SCAN_SIZE - sizeof(*scan)));
+ iwl_fill_probe_req(priv,
+ (struct ieee80211_mgmt *)scan->data,
+ priv->scan_request->ie,
+ priv->scan_request->ie_len,
+ IWL_MAX_SCAN_SIZE - sizeof(*scan)));
/* select Rx antennas */
scan->flags |= iwl3945_get_antenna_flags(priv);
- if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
+ if (iwl_is_monitor_mode(priv))
scan->filter_flags = RXON_FILTER_PROMISC_MSK;
scan->channel_count =
- iwl3945_get_channels_for_scan(priv, band, 1, /* active */
- n_probes,
+ iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
(void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
if (scan->channel_count == 0) {
@@ -3497,8 +3151,17 @@ static void iwl3945_bg_restart(struct work_struct *data)
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return;
- iwl3945_down(priv);
- queue_work(priv->workqueue, &priv->up);
+ if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
+ mutex_lock(&priv->mutex);
+ priv->vif = NULL;
+ priv->is_open = 0;
+ mutex_unlock(&priv->mutex);
+ iwl3945_down(priv);
+ ieee80211_restart_hw(priv->hw);
+ } else {
+ iwl3945_down(priv);
+ queue_work(priv->workqueue, &priv->up);
+ }
}
static void iwl3945_bg_rx_replenish(struct work_struct *data)
@@ -3516,7 +3179,7 @@ static void iwl3945_bg_rx_replenish(struct work_struct *data)
#define IWL_DELAY_NEXT_SCAN (HZ*2)
-static void iwl3945_post_associate(struct iwl_priv *priv)
+void iwl3945_post_associate(struct iwl_priv *priv)
{
int rc = 0;
struct ieee80211_conf *conf = NULL;
@@ -3541,7 +3204,7 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
conf = ieee80211_get_hw_conf(priv->hw);
priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
iwl3945_setup_rxon_timing(priv);
@@ -3574,7 +3237,7 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
}
- iwl3945_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
switch (priv->iw_mode) {
case NL80211_IFTYPE_STATION:
@@ -3584,7 +3247,7 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
case NL80211_IFTYPE_ADHOC:
priv->assoc_id = 1;
- iwl3945_add_station(priv, priv->bssid, 0, 0);
+ priv->cfg->ops->smgmt->add_station(priv, priv->bssid, 0, 0, NULL);
iwl3945_sync_sta(priv, IWL_STA_ID,
(priv->band == IEEE80211_BAND_5GHZ) ?
IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP,
@@ -3606,8 +3269,6 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN;
}
-static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed);
-
/*****************************************************************************
*
* mac80211 entry point functions
@@ -3650,9 +3311,6 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
IWL_DEBUG_INFO(priv, "Start UP work.\n");
- if (test_bit(STATUS_IN_SUSPEND, &priv->status))
- return 0;
-
/* Wait for START_ALIVE from ucode. Otherwise callbacks from
* mac80211 will not be run successfully. */
ret = wait_event_interruptible_timeout(priv->wait_command_queue,
@@ -3731,144 +3389,7 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
return NETDEV_TX_OK;
}
-static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
- struct ieee80211_if_init_conf *conf)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
-
- IWL_DEBUG_MAC80211(priv, "enter: type %d\n", conf->type);
-
- if (priv->vif) {
- IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
- return -EOPNOTSUPP;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
- priv->vif = conf->vif;
- priv->iw_mode = conf->type;
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- mutex_lock(&priv->mutex);
-
- if (conf->mac_addr) {
- IWL_DEBUG_MAC80211(priv, "Set: %pM\n", conf->mac_addr);
- memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
- }
-
- if (iwl_is_ready(priv))
- iwl3945_set_mode(priv, conf->type);
-
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
- return 0;
-}
-
-/**
- * iwl3945_mac_config - mac80211 config callback
- *
- * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to
- * be set inappropriately and the driver currently sets the hardware up to
- * use it whenever needed.
- */
-static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
-{
- struct iwl_priv *priv = hw->priv;
- const struct iwl_channel_info *ch_info;
- struct ieee80211_conf *conf = &hw->conf;
- unsigned long flags;
- int ret = 0;
-
- mutex_lock(&priv->mutex);
- IWL_DEBUG_MAC80211(priv, "enter to channel %d\n",
- conf->channel->hw_value);
-
- if (!iwl_is_ready(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
- ret = -EIO;
- goto out;
- }
-
- if (unlikely(!iwl3945_mod_params.disable_hw_scan &&
- test_bit(STATUS_SCANNING, &priv->status))) {
- IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
- set_bit(STATUS_CONF_PENDING, &priv->status);
- mutex_unlock(&priv->mutex);
- return 0;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
-
- ch_info = iwl_get_channel_info(priv, conf->channel->band,
- conf->channel->hw_value);
- if (!is_channel_valid(ch_info)) {
- IWL_DEBUG_SCAN(priv,
- "Channel %d [%d] is INVALID for this band.\n",
- conf->channel->hw_value, conf->channel->band);
- IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
- spin_unlock_irqrestore(&priv->lock, flags);
- ret = -EINVAL;
- goto out;
- }
-
- iwl_set_rxon_channel(priv, conf->channel);
-
- iwl_set_flags_for_band(priv, conf->channel->band);
-
- /* The list of supported rates and rate mask can be different
- * for each phymode; since the phymode may have changed, reset
- * the rate mask to what mac80211 lists */
- iwl_set_rate(priv);
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
-#ifdef IEEE80211_CONF_CHANNEL_SWITCH
- if (conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) {
- iwl3945_hw_channel_switch(priv, conf->channel);
- goto out;
- }
-#endif
-
- if (changed & IEEE80211_CONF_CHANGE_RADIO_ENABLED) {
- if (conf->radio_enabled &&
- iwl_radio_kill_sw_enable_radio(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF-KILL - "
- "waiting for uCode\n");
- goto out;
- }
-
- if (!conf->radio_enabled) {
- iwl_radio_kill_sw_disable_radio(priv);
- IWL_DEBUG_MAC80211(priv, "leave - radio disabled\n");
- goto out;
- }
- }
-
- if (iwl_is_rfkill(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF kill\n");
- ret = -EIO;
- goto out;
- }
-
- iwl_set_rate(priv);
-
- if (memcmp(&priv->active_rxon,
- &priv->staging_rxon, sizeof(priv->staging_rxon)))
- iwl3945_commit_rxon(priv);
- else
- IWL_DEBUG_INFO(priv, "Not re-sending same RXON configuration\n");
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-
-out:
- clear_bit(STATUS_CONF_PENDING, &priv->status);
- mutex_unlock(&priv->mutex);
- return ret;
-}
-
-static void iwl3945_config_ap(struct iwl_priv *priv)
+void iwl3945_config_ap(struct iwl_priv *priv)
{
int rc = 0;
@@ -3880,7 +3401,7 @@ static void iwl3945_config_ap(struct iwl_priv *priv)
/* RXON - unassoc (to set timing command) */
priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
/* RXON Timing */
memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
@@ -3916,8 +3437,8 @@ static void iwl3945_config_ap(struct iwl_priv *priv)
}
/* restore RXON assoc */
priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
- iwl3945_add_station(priv, iwl_bcast_addr, 0, 0);
+ iwlcore_commit_rxon(priv);
+ priv->cfg->ops->smgmt->add_station(priv, iwl_bcast_addr, 0, 0, NULL);
}
iwl3945_send_beacon_cmd(priv);
@@ -3926,189 +3447,6 @@ static void iwl3945_config_ap(struct iwl_priv *priv)
* clear sta table, add BCAST sta... */
}
-static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct iwl_priv *priv = hw->priv;
- int rc;
-
- if (conf == NULL)
- return -EIO;
-
- if (priv->vif != vif) {
- IWL_DEBUG_MAC80211(priv, "leave - priv->vif != vif\n");
- return 0;
- }
-
- /* handle this temporarily here */
- if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
- conf->changed & IEEE80211_IFCC_BEACON) {
- struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
- if (!beacon)
- return -ENOMEM;
- mutex_lock(&priv->mutex);
- rc = iwl3945_mac_beacon_update(hw, beacon);
- mutex_unlock(&priv->mutex);
- if (rc)
- return rc;
- }
-
- if (!iwl_is_alive(priv))
- return -EAGAIN;
-
- mutex_lock(&priv->mutex);
-
- if (conf->bssid)
- IWL_DEBUG_MAC80211(priv, "bssid: %pM\n", conf->bssid);
-
-/*
- * very dubious code was here; the probe filtering flag is never set:
- *
- if (unlikely(test_bit(STATUS_SCANNING, &priv->status)) &&
- !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
- */
-
- if (priv->iw_mode == NL80211_IFTYPE_AP) {
- if (!conf->bssid) {
- conf->bssid = priv->mac_addr;
- memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
- IWL_DEBUG_MAC80211(priv, "bssid was set to: %pM\n",
- conf->bssid);
- }
- if (priv->ibss_beacon)
- dev_kfree_skb(priv->ibss_beacon);
-
- priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
- }
-
- if (iwl_is_rfkill(priv))
- goto done;
-
- if (conf->bssid && !is_zero_ether_addr(conf->bssid) &&
- !is_multicast_ether_addr(conf->bssid)) {
- /* If there is currently a HW scan going on in the background
- * then we need to cancel it else the RXON below will fail. */
- if (iwl_scan_cancel_timeout(priv, 100)) {
- IWL_WARN(priv, "Aborted scan still in progress "
- "after 100ms\n");
- IWL_DEBUG_MAC80211(priv, "leaving:scan abort failed\n");
- mutex_unlock(&priv->mutex);
- return -EAGAIN;
- }
- memcpy(priv->staging_rxon.bssid_addr, conf->bssid, ETH_ALEN);
-
- /* TODO: Audit driver for usage of these members and see
- * if mac80211 deprecates them (priv->bssid looks like it
- * shouldn't be there, but I haven't scanned the IBSS code
- * to verify) - jpk */
- memcpy(priv->bssid, conf->bssid, ETH_ALEN);
-
- if (priv->iw_mode == NL80211_IFTYPE_AP)
- iwl3945_config_ap(priv);
- else {
- rc = iwl3945_commit_rxon(priv);
- if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
- iwl3945_add_station(priv,
- priv->active_rxon.bssid_addr, 1, 0);
- }
-
- } else {
- iwl_scan_cancel_timeout(priv, 100);
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
- }
-
- done:
- IWL_DEBUG_MAC80211(priv, "leave\n");
- mutex_unlock(&priv->mutex);
-
- return 0;
-}
-
-static void iwl3945_mac_remove_interface(struct ieee80211_hw *hw,
- struct ieee80211_if_init_conf *conf)
-{
- struct iwl_priv *priv = hw->priv;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- mutex_lock(&priv->mutex);
-
- if (iwl_is_ready_rf(priv)) {
- iwl_scan_cancel_timeout(priv, 100);
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
- }
- if (priv->vif == conf->vif) {
- priv->vif = NULL;
- memset(priv->bssid, 0, ETH_ALEN);
- }
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-}
-
-#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
-
-static void iwl3945_bss_info_changed(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_bss_conf *bss_conf,
- u32 changes)
-{
- struct iwl_priv *priv = hw->priv;
-
- IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
-
- if (changes & BSS_CHANGED_ERP_PREAMBLE) {
- IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
- bss_conf->use_short_preamble);
- if (bss_conf->use_short_preamble)
- priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
- else
- priv->staging_rxon.flags &=
- ~RXON_FLG_SHORT_PREAMBLE_MSK;
- }
-
- if (changes & BSS_CHANGED_ERP_CTS_PROT) {
- IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n",
- bss_conf->use_cts_prot);
- if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
- priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
- else
- priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
- }
-
- if (changes & BSS_CHANGED_ASSOC) {
- IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
- /* This should never happen as this function should
- * never be called from interrupt context. */
- if (WARN_ON_ONCE(in_interrupt()))
- return;
- if (bss_conf->assoc) {
- priv->assoc_id = bss_conf->aid;
- priv->beacon_int = bss_conf->beacon_int;
- priv->timestamp = bss_conf->timestamp;
- priv->assoc_capability = bss_conf->assoc_capability;
- priv->power_data.dtim_period = bss_conf->dtim_period;
- priv->next_scan_jiffies = jiffies +
- IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
- mutex_lock(&priv->mutex);
- iwl3945_post_associate(priv);
- mutex_unlock(&priv->mutex);
- } else {
- priv->assoc_id = 0;
- IWL_DEBUG_MAC80211(priv,
- "DISASSOC %d\n", bss_conf->assoc);
- }
- } else if (changes && iwl_is_associated(priv) && priv->assoc_id) {
- IWL_DEBUG_MAC80211(priv,
- "Associated Changes %d\n", changes);
- iwl3945_send_rxon_assoc(priv);
- }
-
-}
-
static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
@@ -4131,7 +3469,7 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
static_key = !iwl_is_associated(priv);
if (!static_key) {
- sta_id = iwl3945_hw_find_station(priv, addr);
+ sta_id = priv->cfg->ops->smgmt->find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION) {
IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
addr);
@@ -4167,185 +3505,6 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return ret;
}
-static int iwl3945_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
- const struct ieee80211_tx_queue_params *params)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
- int q;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
- return -EIO;
- }
-
- if (queue >= AC_NUM) {
- IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
- return 0;
- }
-
- q = AC_NUM - 1 - queue;
-
- spin_lock_irqsave(&priv->lock, flags);
-
- priv->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min);
- priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max);
- priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
- priv->qos_data.def_qos_parm.ac[q].edca_txop =
- cpu_to_le16((params->txop * 32));
-
- priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
- priv->qos_data.qos_active = 1;
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- mutex_lock(&priv->mutex);
- if (priv->iw_mode == NL80211_IFTYPE_AP)
- iwl_activate_qos(priv, 1);
- else if (priv->assoc_id && iwl_is_associated(priv))
- iwl_activate_qos(priv, 0);
-
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
- return 0;
-}
-
-static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
- struct ieee80211_tx_queue_stats *stats)
-{
- struct iwl_priv *priv = hw->priv;
- int i, avail;
- struct iwl_tx_queue *txq;
- struct iwl_queue *q;
- unsigned long flags;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
- return -EIO;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
-
- for (i = 0; i < AC_NUM; i++) {
- txq = &priv->txq[i];
- q = &txq->q;
- avail = iwl_queue_space(q);
-
- stats[i].len = q->n_window - avail;
- stats[i].limit = q->n_window - q->high_mark;
- stats[i].count = q->n_window;
-
- }
- spin_unlock_irqrestore(&priv->lock, flags);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-
- return 0;
-}
-
-static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
-
- mutex_lock(&priv->mutex);
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- iwl_reset_qos(priv);
-
- spin_lock_irqsave(&priv->lock, flags);
- priv->assoc_id = 0;
- priv->assoc_capability = 0;
-
- /* new association get rid of ibss beacon skb */
- if (priv->ibss_beacon)
- dev_kfree_skb(priv->ibss_beacon);
-
- priv->ibss_beacon = NULL;
-
- priv->beacon_int = priv->hw->conf.beacon_int;
- priv->timestamp = 0;
- if ((priv->iw_mode == NL80211_IFTYPE_STATION))
- priv->beacon_int = 0;
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
- mutex_unlock(&priv->mutex);
- return;
- }
-
- /* we are restarting association process
- * clear RXON_FILTER_ASSOC_MSK bit
- */
- if (priv->iw_mode != NL80211_IFTYPE_AP) {
- iwl_scan_cancel_timeout(priv, 100);
- priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
- iwl3945_commit_rxon(priv);
- }
-
- /* Per mac80211.h: This is only used in IBSS mode... */
- if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
-
- IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
- mutex_unlock(&priv->mutex);
- return;
- }
-
- iwl_set_rate(priv);
-
- mutex_unlock(&priv->mutex);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
-
-}
-
-static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
- struct iwl_priv *priv = hw->priv;
- unsigned long flags;
- __le64 timestamp;
-
- IWL_DEBUG_MAC80211(priv, "enter\n");
-
- if (!iwl_is_ready_rf(priv)) {
- IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
- return -EIO;
- }
-
- if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
- IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
- return -EIO;
- }
-
- spin_lock_irqsave(&priv->lock, flags);
-
- if (priv->ibss_beacon)
- dev_kfree_skb(priv->ibss_beacon);
-
- priv->ibss_beacon = skb;
-
- priv->assoc_id = 0;
- timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
- priv->timestamp = le64_to_cpu(timestamp);
-
- IWL_DEBUG_MAC80211(priv, "leave\n");
- spin_unlock_irqrestore(&priv->lock, flags);
-
- iwl_reset_qos(priv);
-
- iwl3945_post_associate(priv);
-
-
- return 0;
-}
-
/*****************************************************************************
*
* sysfs attributes
@@ -4364,7 +3523,7 @@ static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
static ssize_t show_debug_level(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "0x%08X\n", priv->debug_level);
}
@@ -4372,7 +3531,7 @@ static ssize_t store_debug_level(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
unsigned long val;
int ret;
@@ -4393,7 +3552,7 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
static ssize_t show_temperature(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
if (!iwl_is_alive(priv))
return -EAGAIN;
@@ -4406,7 +3565,7 @@ static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL);
static ssize_t show_tx_power(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "%d\n", priv->tx_power_user_lmt);
}
@@ -4414,7 +3573,7 @@ static ssize_t store_tx_power(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
char *p = (char *)buf;
u32 val;
@@ -4432,7 +3591,7 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
static ssize_t show_flags(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "0x%04X\n", priv->active_rxon.flags);
}
@@ -4441,7 +3600,7 @@ static ssize_t store_flags(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
u32 flags = simple_strtoul(buf, NULL, 0);
mutex_lock(&priv->mutex);
@@ -4453,7 +3612,7 @@ static ssize_t store_flags(struct device *d,
IWL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n",
flags);
priv->staging_rxon.flags = cpu_to_le32(flags);
- iwl3945_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
}
}
mutex_unlock(&priv->mutex);
@@ -4466,7 +3625,7 @@ static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, show_flags, store_flags);
static ssize_t show_filter_flags(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
return sprintf(buf, "0x%04X\n",
le32_to_cpu(priv->active_rxon.filter_flags));
@@ -4476,7 +3635,7 @@ static ssize_t store_filter_flags(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
u32 filter_flags = simple_strtoul(buf, NULL, 0);
mutex_lock(&priv->mutex);
@@ -4489,7 +3648,7 @@ static ssize_t store_filter_flags(struct device *d,
"0x%04X\n", filter_flags);
priv->staging_rxon.filter_flags =
cpu_to_le32(filter_flags);
- iwl3945_commit_rxon(priv);
+ iwlcore_commit_rxon(priv);
}
}
mutex_unlock(&priv->mutex);
@@ -4629,26 +3788,11 @@ static ssize_t show_power_level(struct device *d,
{
struct iwl_priv *priv = dev_get_drvdata(d);
int mode = priv->power_data.user_power_setting;
- int system = priv->power_data.system_power_setting;
int level = priv->power_data.power_mode;
char *p = buf;
- switch (system) {
- case IWL_POWER_SYS_AUTO:
- p += sprintf(p, "SYSTEM:auto");
- break;
- case IWL_POWER_SYS_AC:
- p += sprintf(p, "SYSTEM:ac");
- break;
- case IWL_POWER_SYS_BATTERY:
- p += sprintf(p, "SYSTEM:battery");
- break;
- }
-
- p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO) ?
- "fixed" : "auto");
- p += sprintf(p, "\tINDEX:%d", level);
- p += sprintf(p, "\n");
+ p += sprintf(p, "INDEX:%d\t", level);
+ p += sprintf(p, "USER:%d\n", mode);
return p - buf + 1;
}
@@ -4761,7 +3905,7 @@ static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, show_antenna, store_antenna);
static ssize_t show_status(struct device *d,
struct device_attribute *attr, char *buf)
{
- struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
+ struct iwl_priv *priv = dev_get_drvdata(d);
if (!iwl_is_alive(priv))
return -EAGAIN;
return sprintf(buf, "0x%08x\n", (int)priv->status);
@@ -4773,10 +3917,11 @@ static ssize_t dump_error_log(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct iwl_priv *priv = dev_get_drvdata(d);
char *p = (char *)buf;
if (p[0] == '1')
- iwl3945_dump_nic_error_log((struct iwl_priv *)d->driver_data);
+ iwl3945_dump_nic_error_log(priv);
return strnlen(buf, count);
}
@@ -4787,10 +3932,11 @@ static ssize_t dump_event_log(struct device *d,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct iwl_priv *priv = dev_get_drvdata(d);
char *p = (char *)buf;
if (p[0] == '1')
- iwl3945_dump_nic_event_log((struct iwl_priv *)d->driver_data);
+ iwl3945_dump_nic_event_log(priv);
return strnlen(buf, count);
}
@@ -4869,16 +4015,15 @@ static struct ieee80211_ops iwl3945_hw_ops = {
.tx = iwl3945_mac_tx,
.start = iwl3945_mac_start,
.stop = iwl3945_mac_stop,
- .add_interface = iwl3945_mac_add_interface,
- .remove_interface = iwl3945_mac_remove_interface,
- .config = iwl3945_mac_config,
- .config_interface = iwl3945_mac_config_interface,
+ .add_interface = iwl_mac_add_interface,
+ .remove_interface = iwl_mac_remove_interface,
+ .config = iwl_mac_config,
.configure_filter = iwl_configure_filter,
.set_key = iwl3945_mac_set_key,
- .get_tx_stats = iwl3945_mac_get_tx_stats,
- .conf_tx = iwl3945_mac_conf_tx,
- .reset_tsf = iwl3945_mac_reset_tsf,
- .bss_info_changed = iwl3945_bss_info_changed,
+ .get_tx_stats = iwl_mac_get_tx_stats,
+ .conf_tx = iwl_mac_conf_tx,
+ .reset_tsf = iwl_mac_reset_tsf,
+ .bss_info_changed = iwl_bss_info_changed,
.hw_scan = iwl_mac_hw_scan
};
@@ -4891,7 +4036,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
priv->ibss_beacon = NULL;
spin_lock_init(&priv->lock);
- spin_lock_init(&priv->power_data.lock);
spin_lock_init(&priv->sta_lock);
spin_lock_init(&priv->hcmd_lock);
@@ -4900,7 +4044,7 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
mutex_init(&priv->mutex);
/* Clear the driver's (not device's) station table */
- iwl3945_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
priv->data_retry_limit = -1;
priv->ieee_channels = NULL;
@@ -4971,13 +4115,13 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
hw->wiphy->custom_regulatory = true;
- hw->wiphy->max_scan_ssids = 1; /* WILL FIX */
+ hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
+ /* we create the 802.11 header and a zero-length SSID element */
+ hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2;
/* Default value; 4 EDCA QOS priorities */
hw->queues = 4;
- hw->conf.beacon_int = 100;
-
if (priv->bands[IEEE80211_BAND_2GHZ].n_channels)
priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
&priv->bands[IEEE80211_BAND_2GHZ];
@@ -5042,6 +4186,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
priv->cfg = cfg;
priv->pci_dev = pdev;
+ priv->inta_mask = CSR_INI_SET_MASK;
#ifdef CONFIG_IWLWIFI_DEBUG
priv->debug_level = iwl3945_mod_params.debug;
@@ -5088,6 +4233,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
* PCI Tx retries from interfering with C3 CPU state */
pci_write_config_byte(pdev, 0x41, 0x00);
+ /* this spin lock will be used in apm_ops.init and EEPROM access
+ * we should init now
+ */
+ spin_lock_init(&priv->reg_lock);
+
/* amp init */
err = priv->cfg->ops->lib->apm_ops.init(priv);
if (err < 0) {
@@ -5133,20 +4283,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n",
priv->cfg->name);
- /***********************************
- * 7. Initialize Module Parameters
- * **********************************/
-
- /* Initialize module parameter values here */
- /* Disable radio (SW RF KILL) via parameter when loading driver */
- if (iwl3945_mod_params.disable) {
- set_bit(STATUS_RF_KILL_SW, &priv->status);
- IWL_DEBUG_INFO(priv, "Radio disabled.\n");
- }
-
-
/***********************
- * 8. Setup Services
+ * 7. Setup Services
* ********************/
spin_lock_irqsave(&priv->lock, flags);
@@ -5155,8 +4293,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
pci_enable_msi(priv->pci_dev);
- err = request_irq(priv->pci_dev->irq, iwl_isr, IRQF_SHARED,
- DRV_NAME, priv);
+ err = request_irq(priv->pci_dev->irq, priv->cfg->ops->lib->isr,
+ IRQF_SHARED, DRV_NAME, priv);
if (err) {
IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq);
goto out_disable_msi;
@@ -5174,7 +4312,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
iwl3945_setup_rx_handlers(priv);
/*********************************
- * 9. Setup and Register mac80211
+ * 8. Setup and Register mac80211
* *******************************/
iwl_enable_interrupts(priv);
@@ -5183,6 +4321,10 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
if (err)
goto out_remove_sysfs;
+ err = iwl_dbgfs_register(priv, DRV_NAME);
+ if (err)
+ IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
+
err = iwl_rfkill_init(priv);
if (err)
IWL_ERR(priv, "Unable to initialize RFKILL system. "
@@ -5233,6 +4375,8 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
+ iwl_dbgfs_unregister(priv);
+
set_bit(STATUS_EXIT_PENDING, &priv->status);
if (priv->mac80211_registered) {
@@ -5263,7 +4407,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
iwl3945_hw_txq_ctx_free(priv);
iwl3945_unset_hw_params(priv);
- iwl3945_clear_stations_table(priv);
+ priv->cfg->ops->smgmt->clear_station_table(priv);
/*netif_stop_queue(dev); */
flush_workqueue(priv->workqueue);
@@ -5291,43 +4435,6 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
ieee80211_free_hw(priv->hw);
}
-#ifdef CONFIG_PM
-
-static int iwl3945_pci_suspend(struct pci_dev *pdev, pm_message_t state)
-{
- struct iwl_priv *priv = pci_get_drvdata(pdev);
-
- if (priv->is_open) {
- set_bit(STATUS_IN_SUSPEND, &priv->status);
- iwl3945_mac_stop(priv->hw);
- priv->is_open = 1;
- }
- pci_save_state(pdev);
- pci_disable_device(pdev);
- pci_set_power_state(pdev, PCI_D3hot);
-
- return 0;
-}
-
-static int iwl3945_pci_resume(struct pci_dev *pdev)
-{
- struct iwl_priv *priv = pci_get_drvdata(pdev);
- int ret;
-
- pci_set_power_state(pdev, PCI_D0);
- ret = pci_enable_device(pdev);
- if (ret)
- return ret;
- pci_restore_state(pdev);
-
- if (priv->is_open)
- iwl3945_mac_start(priv->hw);
-
- clear_bit(STATUS_IN_SUSPEND, &priv->status);
- return 0;
-}
-
-#endif /* CONFIG_PM */
/*****************************************************************************
*
@@ -5341,8 +4448,8 @@ static struct pci_driver iwl3945_driver = {
.probe = iwl3945_pci_probe,
.remove = __devexit_p(iwl3945_pci_remove),
#ifdef CONFIG_PM
- .suspend = iwl3945_pci_suspend,
- .resume = iwl3945_pci_resume,
+ .suspend = iwl_pci_suspend,
+ .resume = iwl_pci_resume,
#endif
};
@@ -5383,8 +4490,6 @@ MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX));
module_param_named(antenna, iwl3945_mod_params.antenna, int, 0444);
MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
-module_param_named(disable, iwl3945_mod_params.disable, int, 0444);
-MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
module_param_named(swcrypto, iwl3945_mod_params.sw_crypto, int, 0444);
MODULE_PARM_DESC(swcrypto,
"using software crypto (default 1 [software])\n");
diff --git a/drivers/net/wireless/iwmc3200wifi/Kconfig b/drivers/net/wireless/iwmc3200wifi/Kconfig
new file mode 100644
index 000000000000..41bd4b2b5411
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/Kconfig
@@ -0,0 +1,24 @@
+config IWM
+ tristate "Intel Wireless Multicomm 3200 WiFi driver"
+ depends on MMC && WLAN_80211 && EXPERIMENTAL
+ select WIRELESS_EXT
+ select CFG80211
+ select FW_LOADER
+ select RFKILL
+
+config IWM_DEBUG
+ bool "Enable full debugging output in iwmc3200wifi"
+ depends on IWM && DEBUG_FS
+ ---help---
+ This option will enable debug tracing and setting for iwm
+
+ You can set the debug level and module through debugfs. By
+ default all modules are set to the IWL_DL_ERR level.
+ To see the list of debug modules and levels, see iwm/debug.h
+
+ For example, if you want the full MLME debug output:
+ echo 0xff > /debug/iwm/phyN/debug/mlme
+
+ Or, if you want the full debug, for all modules:
+ echo 0xff > /debug/iwm/phyN/debug/level
+ echo 0xff > /debug/iwm/phyN/debug/modules
diff --git a/drivers/net/wireless/iwmc3200wifi/Makefile b/drivers/net/wireless/iwmc3200wifi/Makefile
new file mode 100644
index 000000000000..7cb415e5c11b
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/Makefile
@@ -0,0 +1,5 @@
+obj-$(CONFIG_IWM) := iwmc3200wifi.o
+iwmc3200wifi-objs += main.o netdev.o rx.o tx.o sdio.o hal.o fw.o
+iwmc3200wifi-objs += commands.o wext.o cfg80211.o eeprom.o rfkill.o
+
+iwmc3200wifi-$(CONFIG_IWM_DEBUG) += debugfs.o
diff --git a/drivers/net/wireless/iwmc3200wifi/bus.h b/drivers/net/wireless/iwmc3200wifi/bus.h
new file mode 100644
index 000000000000..836663eec257
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/bus.h
@@ -0,0 +1,57 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#ifndef __IWM_BUS_H__
+#define __IWM_BUS_H__
+
+#include "iwm.h"
+
+struct iwm_if_ops {
+ int (*enable)(struct iwm_priv *iwm);
+ int (*disable)(struct iwm_priv *iwm);
+ int (*send_chunk)(struct iwm_priv *iwm, u8* buf, int count);
+
+ int (*debugfs_init)(struct iwm_priv *iwm, struct dentry *parent_dir);
+ void (*debugfs_exit)(struct iwm_priv *iwm);
+
+ const char *umac_name;
+ const char *calib_lmac_name;
+ const char *lmac_name;
+};
+
+static inline int iwm_bus_send_chunk(struct iwm_priv *iwm, u8 *buf, int count)
+{
+ return iwm->bus_ops->send_chunk(iwm, buf, count);
+}
+
+static inline int iwm_bus_enable(struct iwm_priv *iwm)
+{
+ return iwm->bus_ops->enable(iwm);
+}
+
+static inline int iwm_bus_disable(struct iwm_priv *iwm)
+{
+ return iwm->bus_ops->disable(iwm);
+}
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
new file mode 100644
index 000000000000..3256ad2c96ce
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
@@ -0,0 +1,409 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <linux/ieee80211.h>
+#include <net/cfg80211.h>
+
+#include "iwm.h"
+#include "commands.h"
+#include "cfg80211.h"
+#include "debug.h"
+
+#define RATETAB_ENT(_rate, _rateid, _flags) \
+ { \
+ .bitrate = (_rate), \
+ .hw_value = (_rateid), \
+ .flags = (_flags), \
+ }
+
+#define CHAN2G(_channel, _freq, _flags) { \
+ .band = IEEE80211_BAND_2GHZ, \
+ .center_freq = (_freq), \
+ .hw_value = (_channel), \
+ .flags = (_flags), \
+ .max_antenna_gain = 0, \
+ .max_power = 30, \
+}
+
+#define CHAN5G(_channel, _flags) { \
+ .band = IEEE80211_BAND_5GHZ, \
+ .center_freq = 5000 + (5 * (_channel)), \
+ .hw_value = (_channel), \
+ .flags = (_flags), \
+ .max_antenna_gain = 0, \
+ .max_power = 30, \
+}
+
+static struct ieee80211_rate iwm_rates[] = {
+ RATETAB_ENT(10, 0x1, 0),
+ RATETAB_ENT(20, 0x2, 0),
+ RATETAB_ENT(55, 0x4, 0),
+ RATETAB_ENT(110, 0x8, 0),
+ RATETAB_ENT(60, 0x10, 0),
+ RATETAB_ENT(90, 0x20, 0),
+ RATETAB_ENT(120, 0x40, 0),
+ RATETAB_ENT(180, 0x80, 0),
+ RATETAB_ENT(240, 0x100, 0),
+ RATETAB_ENT(360, 0x200, 0),
+ RATETAB_ENT(480, 0x400, 0),
+ RATETAB_ENT(540, 0x800, 0),
+};
+
+#define iwm_a_rates (iwm_rates + 4)
+#define iwm_a_rates_size 8
+#define iwm_g_rates (iwm_rates + 0)
+#define iwm_g_rates_size 12
+
+static struct ieee80211_channel iwm_2ghz_channels[] = {
+ CHAN2G(1, 2412, 0),
+ CHAN2G(2, 2417, 0),
+ CHAN2G(3, 2422, 0),
+ CHAN2G(4, 2427, 0),
+ CHAN2G(5, 2432, 0),
+ CHAN2G(6, 2437, 0),
+ CHAN2G(7, 2442, 0),
+ CHAN2G(8, 2447, 0),
+ CHAN2G(9, 2452, 0),
+ CHAN2G(10, 2457, 0),
+ CHAN2G(11, 2462, 0),
+ CHAN2G(12, 2467, 0),
+ CHAN2G(13, 2472, 0),
+ CHAN2G(14, 2484, 0),
+};
+
+static struct ieee80211_channel iwm_5ghz_a_channels[] = {
+ CHAN5G(34, 0), CHAN5G(36, 0),
+ CHAN5G(38, 0), CHAN5G(40, 0),
+ CHAN5G(42, 0), CHAN5G(44, 0),
+ CHAN5G(46, 0), CHAN5G(48, 0),
+ CHAN5G(52, 0), CHAN5G(56, 0),
+ CHAN5G(60, 0), CHAN5G(64, 0),
+ CHAN5G(100, 0), CHAN5G(104, 0),
+ CHAN5G(108, 0), CHAN5G(112, 0),
+ CHAN5G(116, 0), CHAN5G(120, 0),
+ CHAN5G(124, 0), CHAN5G(128, 0),
+ CHAN5G(132, 0), CHAN5G(136, 0),
+ CHAN5G(140, 0), CHAN5G(149, 0),
+ CHAN5G(153, 0), CHAN5G(157, 0),
+ CHAN5G(161, 0), CHAN5G(165, 0),
+ CHAN5G(184, 0), CHAN5G(188, 0),
+ CHAN5G(192, 0), CHAN5G(196, 0),
+ CHAN5G(200, 0), CHAN5G(204, 0),
+ CHAN5G(208, 0), CHAN5G(212, 0),
+ CHAN5G(216, 0),
+};
+
+static struct ieee80211_supported_band iwm_band_2ghz = {
+ .channels = iwm_2ghz_channels,
+ .n_channels = ARRAY_SIZE(iwm_2ghz_channels),
+ .bitrates = iwm_g_rates,
+ .n_bitrates = iwm_g_rates_size,
+};
+
+static struct ieee80211_supported_band iwm_band_5ghz = {
+ .channels = iwm_5ghz_a_channels,
+ .n_channels = ARRAY_SIZE(iwm_5ghz_a_channels),
+ .bitrates = iwm_a_rates,
+ .n_bitrates = iwm_a_rates_size,
+};
+
+int iwm_cfg80211_inform_bss(struct iwm_priv *iwm)
+{
+ struct wiphy *wiphy = iwm_to_wiphy(iwm);
+ struct iwm_bss_info *bss, *next;
+ struct iwm_umac_notif_bss_info *umac_bss;
+ struct ieee80211_mgmt *mgmt;
+ struct ieee80211_channel *channel;
+ struct ieee80211_supported_band *band;
+ s32 signal;
+ int freq;
+
+ list_for_each_entry_safe(bss, next, &iwm->bss_list, node) {
+ umac_bss = bss->bss;
+ mgmt = (struct ieee80211_mgmt *)(umac_bss->frame_buf);
+
+ if (umac_bss->band == UMAC_BAND_2GHZ)
+ band = wiphy->bands[IEEE80211_BAND_2GHZ];
+ else if (umac_bss->band == UMAC_BAND_5GHZ)
+ band = wiphy->bands[IEEE80211_BAND_5GHZ];
+ else {
+ IWM_ERR(iwm, "Invalid band: %d\n", umac_bss->band);
+ return -EINVAL;
+ }
+
+ freq = ieee80211_channel_to_frequency(umac_bss->channel);
+ channel = ieee80211_get_channel(wiphy, freq);
+ signal = umac_bss->rssi * 100;
+
+ if (!cfg80211_inform_bss_frame(wiphy, channel, mgmt,
+ le16_to_cpu(umac_bss->frame_len),
+ signal, GFP_KERNEL))
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int iwm_cfg80211_change_iface(struct wiphy *wiphy, int ifindex,
+ enum nl80211_iftype type, u32 *flags,
+ struct vif_params *params)
+{
+ struct net_device *ndev;
+ struct wireless_dev *wdev;
+ struct iwm_priv *iwm;
+ u32 old_mode;
+
+ /* we're under RTNL */
+ ndev = __dev_get_by_index(&init_net, ifindex);
+ if (!ndev)
+ return -ENODEV;
+
+ wdev = ndev->ieee80211_ptr;
+ iwm = ndev_to_iwm(ndev);
+ old_mode = iwm->conf.mode;
+
+ switch (type) {
+ case NL80211_IFTYPE_STATION:
+ iwm->conf.mode = UMAC_MODE_BSS;
+ break;
+ case NL80211_IFTYPE_ADHOC:
+ iwm->conf.mode = UMAC_MODE_IBSS;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ wdev->iftype = type;
+
+ if ((old_mode == iwm->conf.mode) || !iwm->umac_profile)
+ return 0;
+
+ iwm->umac_profile->mode = cpu_to_le32(iwm->conf.mode);
+
+ if (iwm->umac_profile_active) {
+ int ret = iwm_invalidate_mlme_profile(iwm);
+ if (ret < 0)
+ IWM_ERR(iwm, "Couldn't invalidate profile\n");
+ }
+
+ return 0;
+}
+
+static int iwm_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
+ struct cfg80211_scan_request *request)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(ndev);
+ int ret;
+
+ if (!test_bit(IWM_STATUS_READY, &iwm->status)) {
+ IWM_ERR(iwm, "Scan while device is not ready\n");
+ return -EIO;
+ }
+
+ if (test_bit(IWM_STATUS_SCANNING, &iwm->status)) {
+ IWM_ERR(iwm, "Scanning already\n");
+ return -EAGAIN;
+ }
+
+ if (test_bit(IWM_STATUS_SCAN_ABORTING, &iwm->status)) {
+ IWM_ERR(iwm, "Scanning being aborted\n");
+ return -EAGAIN;
+ }
+
+ set_bit(IWM_STATUS_SCANNING, &iwm->status);
+
+ ret = iwm_scan_ssids(iwm, request->ssids, request->n_ssids);
+ if (ret) {
+ clear_bit(IWM_STATUS_SCANNING, &iwm->status);
+ return ret;
+ }
+
+ iwm->scan_request = request;
+ return 0;
+}
+
+static int iwm_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
+{
+ struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
+
+ if (changed & WIPHY_PARAM_RTS_THRESHOLD &&
+ (iwm->conf.rts_threshold != wiphy->rts_threshold)) {
+ int ret;
+
+ iwm->conf.rts_threshold = wiphy->rts_threshold;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_RTS_THRESHOLD,
+ iwm->conf.rts_threshold);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (changed & WIPHY_PARAM_FRAG_THRESHOLD &&
+ (iwm->conf.frag_threshold != wiphy->frag_threshold)) {
+ int ret;
+
+ iwm->conf.frag_threshold = wiphy->frag_threshold;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_FRAG_THRESHOLD,
+ iwm->conf.frag_threshold);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int iwm_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_ibss_params *params)
+{
+ struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
+ struct ieee80211_channel *chan = params->channel;
+ struct cfg80211_bss *bss;
+
+ if (!test_bit(IWM_STATUS_READY, &iwm->status))
+ return -EIO;
+
+ /* UMAC doesn't support creating IBSS network with specified bssid.
+ * This should be removed after we have join only mode supported. */
+ if (params->bssid)
+ return -EOPNOTSUPP;
+
+ bss = cfg80211_get_ibss(iwm_to_wiphy(iwm), NULL,
+ params->ssid, params->ssid_len);
+ if (!bss) {
+ iwm_scan_one_ssid(iwm, params->ssid, params->ssid_len);
+ schedule_timeout_interruptible(2 * HZ);
+ bss = cfg80211_get_ibss(iwm_to_wiphy(iwm), NULL,
+ params->ssid, params->ssid_len);
+ }
+ /* IBSS join only mode is not supported by UMAC ATM */
+ if (bss) {
+ cfg80211_put_bss(bss);
+ return -EOPNOTSUPP;
+ }
+
+ iwm->channel = ieee80211_frequency_to_channel(chan->center_freq);
+ iwm->umac_profile->ibss.band = chan->band;
+ iwm->umac_profile->ibss.channel = iwm->channel;
+ iwm->umac_profile->ssid.ssid_len = params->ssid_len;
+ memcpy(iwm->umac_profile->ssid.ssid, params->ssid, params->ssid_len);
+
+ if (params->bssid)
+ memcpy(&iwm->umac_profile->bssid[0], params->bssid, ETH_ALEN);
+
+ return iwm_send_mlme_profile(iwm);
+}
+
+static int iwm_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
+{
+ struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
+
+ if (iwm->umac_profile_active)
+ return iwm_invalidate_mlme_profile(iwm);
+
+ return 0;
+}
+
+static struct cfg80211_ops iwm_cfg80211_ops = {
+ .change_virtual_intf = iwm_cfg80211_change_iface,
+ .scan = iwm_cfg80211_scan,
+ .set_wiphy_params = iwm_cfg80211_set_wiphy_params,
+ .join_ibss = iwm_cfg80211_join_ibss,
+ .leave_ibss = iwm_cfg80211_leave_ibss,
+};
+
+struct wireless_dev *iwm_wdev_alloc(int sizeof_bus, struct device *dev)
+{
+ int ret = 0;
+ struct wireless_dev *wdev;
+
+ /*
+ * We're trying to have the following memory
+ * layout:
+ *
+ * +-------------------------+
+ * | struct wiphy |
+ * +-------------------------+
+ * | struct iwm_priv |
+ * +-------------------------+
+ * | bus private data |
+ * | (e.g. iwm_priv_sdio) |
+ * +-------------------------+
+ *
+ */
+
+ wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
+ if (!wdev) {
+ dev_err(dev, "Couldn't allocate wireless device\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ wdev->wiphy = wiphy_new(&iwm_cfg80211_ops,
+ sizeof(struct iwm_priv) + sizeof_bus);
+ if (!wdev->wiphy) {
+ dev_err(dev, "Couldn't allocate wiphy device\n");
+ ret = -ENOMEM;
+ goto out_err_new;
+ }
+
+ set_wiphy_dev(wdev->wiphy, dev);
+ wdev->wiphy->max_scan_ssids = UMAC_WIFI_IF_PROBE_OPTION_MAX;
+ wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_ADHOC);
+ wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &iwm_band_2ghz;
+ wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &iwm_band_5ghz;
+ wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
+
+ ret = wiphy_register(wdev->wiphy);
+ if (ret < 0) {
+ dev_err(dev, "Couldn't register wiphy device\n");
+ goto out_err_register;
+ }
+
+ return wdev;
+
+ out_err_register:
+ wiphy_free(wdev->wiphy);
+
+ out_err_new:
+ kfree(wdev);
+
+ return ERR_PTR(ret);
+}
+
+void iwm_wdev_free(struct iwm_priv *iwm)
+{
+ struct wireless_dev *wdev = iwm_to_wdev(iwm);
+
+ if (!wdev)
+ return;
+
+ wiphy_unregister(wdev->wiphy);
+ wiphy_free(wdev->wiphy);
+ kfree(wdev);
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.h b/drivers/net/wireless/iwmc3200wifi/cfg80211.h
new file mode 100644
index 000000000000..56a34145acbf
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.h
@@ -0,0 +1,31 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#ifndef __IWM_CFG80211_H__
+#define __IWM_CFG80211_H__
+
+int iwm_cfg80211_inform_bss(struct iwm_priv *iwm);
+struct wireless_dev *iwm_wdev_alloc(int sizeof_bus, struct device *dev);
+void iwm_wdev_free(struct iwm_priv *iwm);
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c
new file mode 100644
index 000000000000..834a7f544e5d
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/commands.c
@@ -0,0 +1,920 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <linux/ieee80211.h>
+
+#include "iwm.h"
+#include "bus.h"
+#include "hal.h"
+#include "umac.h"
+#include "commands.h"
+#include "debug.h"
+
+static int iwm_send_lmac_ptrough_cmd(struct iwm_priv *iwm,
+ u8 lmac_cmd_id,
+ const void *lmac_payload,
+ u16 lmac_payload_size,
+ u8 resp)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_LMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_lmac_cmd lmac_cmd;
+
+ lmac_cmd.id = lmac_cmd_id;
+
+ umac_cmd.id = UMAC_CMD_OPCODE_WIFI_PASS_THROUGH;
+ umac_cmd.resp = resp;
+
+ return iwm_hal_send_host_cmd(iwm, &udma_cmd, &umac_cmd, &lmac_cmd,
+ lmac_payload, lmac_payload_size);
+}
+
+int iwm_send_wifi_if_cmd(struct iwm_priv *iwm, void *payload, u16 payload_size,
+ bool resp)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+
+ umac_cmd.id = UMAC_CMD_OPCODE_WIFI_IF_WRAPPER;
+ umac_cmd.resp = resp;
+
+ return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd,
+ payload, payload_size);
+}
+
+static struct coex_event iwm_sta_xor_prio_tbl[COEX_EVENTS_NUM] =
+{
+ {4, 3, 0, COEX_UNASSOC_IDLE_FLAGS},
+ {4, 3, 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
+ {4, 3, 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
+ {4, 3, 0, COEX_CALIBRATION_FLAGS},
+ {4, 3, 0, COEX_PERIODIC_CALIBRATION_FLAGS},
+ {4, 3, 0, COEX_CONNECTION_ESTAB_FLAGS},
+ {4, 3, 0, COEX_ASSOCIATED_IDLE_FLAGS},
+ {4, 3, 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
+ {4, 3, 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
+ {4, 3, 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
+ {6, 3, 0, COEX_XOR_RF_ON_FLAGS},
+ {4, 3, 0, COEX_RF_OFF_FLAGS},
+ {6, 6, 0, COEX_STAND_ALONE_DEBUG_FLAGS},
+ {4, 3, 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
+ {4, 3, 0, COEX_RSRVD1_FLAGS},
+ {4, 3, 0, COEX_RSRVD2_FLAGS}
+};
+
+static struct coex_event iwm_sta_cm_prio_tbl[COEX_EVENTS_NUM] =
+{
+ {1, 1, 0, COEX_UNASSOC_IDLE_FLAGS},
+ {4, 3, 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
+ {3, 3, 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
+ {5, 5, 0, COEX_CALIBRATION_FLAGS},
+ {4, 4, 0, COEX_PERIODIC_CALIBRATION_FLAGS},
+ {5, 4, 0, COEX_CONNECTION_ESTAB_FLAGS},
+ {4, 4, 0, COEX_ASSOCIATED_IDLE_FLAGS},
+ {4, 4, 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
+ {4, 4, 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
+ {4, 4, 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
+ {1, 1, 0, COEX_RF_ON_FLAGS},
+ {1, 1, 0, COEX_RF_OFF_FLAGS},
+ {6, 6, 0, COEX_STAND_ALONE_DEBUG_FLAGS},
+ {5, 4, 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
+ {1, 1, 0, COEX_RSRVD1_FLAGS},
+ {1, 1, 0, COEX_RSRVD2_FLAGS}
+};
+
+int iwm_send_prio_table(struct iwm_priv *iwm)
+{
+ struct iwm_coex_prio_table_cmd coex_table_cmd;
+ u32 coex_enabled, mode_enabled;
+
+ memset(&coex_table_cmd, 0, sizeof(struct iwm_coex_prio_table_cmd));
+
+ coex_table_cmd.flags = COEX_FLAGS_STA_TABLE_VALID_MSK;
+
+ switch (iwm->conf.coexist_mode) {
+ case COEX_MODE_XOR:
+ case COEX_MODE_CM:
+ coex_enabled = 1;
+ break;
+ default:
+ coex_enabled = 0;
+ break;
+ }
+
+ switch (iwm->conf.mode) {
+ case UMAC_MODE_BSS:
+ case UMAC_MODE_IBSS:
+ mode_enabled = 1;
+ break;
+ default:
+ mode_enabled = 0;
+ break;
+ }
+
+ if (coex_enabled && mode_enabled) {
+ coex_table_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK |
+ COEX_FLAGS_ASSOC_WAKEUP_UMASK_MSK |
+ COEX_FLAGS_UNASSOC_WAKEUP_UMASK_MSK;
+
+ switch (iwm->conf.coexist_mode) {
+ case COEX_MODE_XOR:
+ memcpy(coex_table_cmd.sta_prio, iwm_sta_xor_prio_tbl,
+ sizeof(iwm_sta_xor_prio_tbl));
+ break;
+ case COEX_MODE_CM:
+ memcpy(coex_table_cmd.sta_prio, iwm_sta_cm_prio_tbl,
+ sizeof(iwm_sta_cm_prio_tbl));
+ break;
+ default:
+ IWM_ERR(iwm, "Invalid coex_mode 0x%x\n",
+ iwm->conf.coexist_mode);
+ break;
+ }
+ } else
+ IWM_WARN(iwm, "coexistense disabled\n");
+
+ return iwm_send_lmac_ptrough_cmd(iwm, COEX_PRIORITY_TABLE_CMD,
+ &coex_table_cmd,
+ sizeof(struct iwm_coex_prio_table_cmd), 1);
+}
+
+int iwm_send_init_calib_cfg(struct iwm_priv *iwm, u8 calib_requested)
+{
+ struct iwm_lmac_cal_cfg_cmd cal_cfg_cmd;
+
+ memset(&cal_cfg_cmd, 0, sizeof(struct iwm_lmac_cal_cfg_cmd));
+
+ cal_cfg_cmd.ucode_cfg.init.enable = cpu_to_le32(calib_requested);
+ cal_cfg_cmd.ucode_cfg.init.start = cpu_to_le32(calib_requested);
+ cal_cfg_cmd.ucode_cfg.init.send_res = cpu_to_le32(calib_requested);
+ cal_cfg_cmd.ucode_cfg.flags =
+ cpu_to_le32(CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_AFTER_MSK);
+
+ return iwm_send_lmac_ptrough_cmd(iwm, CALIBRATION_CFG_CMD, &cal_cfg_cmd,
+ sizeof(struct iwm_lmac_cal_cfg_cmd), 1);
+}
+
+int iwm_send_periodic_calib_cfg(struct iwm_priv *iwm, u8 calib_requested)
+{
+ struct iwm_lmac_cal_cfg_cmd cal_cfg_cmd;
+
+ memset(&cal_cfg_cmd, 0, sizeof(struct iwm_lmac_cal_cfg_cmd));
+
+ cal_cfg_cmd.ucode_cfg.periodic.enable = cpu_to_le32(calib_requested);
+ cal_cfg_cmd.ucode_cfg.periodic.start = cpu_to_le32(calib_requested);
+
+ return iwm_send_lmac_ptrough_cmd(iwm, CALIBRATION_CFG_CMD, &cal_cfg_cmd,
+ sizeof(struct iwm_lmac_cal_cfg_cmd), 0);
+}
+
+int iwm_store_rxiq_calib_result(struct iwm_priv *iwm)
+{
+ struct iwm_calib_rxiq *rxiq;
+ u8 *eeprom_rxiq = iwm_eeprom_access(iwm, IWM_EEPROM_CALIB_RXIQ);
+ int grplen = sizeof(struct iwm_calib_rxiq_group);
+
+ rxiq = kzalloc(sizeof(struct iwm_calib_rxiq), GFP_KERNEL);
+ if (!rxiq) {
+ IWM_ERR(iwm, "Couldn't alloc memory for RX IQ\n");
+ return -ENOMEM;
+ }
+
+ eeprom_rxiq = iwm_eeprom_access(iwm, IWM_EEPROM_CALIB_RXIQ);
+ if (IS_ERR(eeprom_rxiq)) {
+ IWM_ERR(iwm, "Couldn't access EEPROM RX IQ entry\n");
+ return PTR_ERR(eeprom_rxiq);
+ }
+
+ iwm->calib_res[SHILOH_PHY_CALIBRATE_RX_IQ_CMD].buf = (u8 *)rxiq;
+ iwm->calib_res[SHILOH_PHY_CALIBRATE_RX_IQ_CMD].size = sizeof(*rxiq);
+
+ rxiq->hdr.opcode = SHILOH_PHY_CALIBRATE_RX_IQ_CMD;
+ rxiq->hdr.first_grp = 0;
+ rxiq->hdr.grp_num = 1;
+ rxiq->hdr.all_data_valid = 1;
+
+ memcpy(&rxiq->group[0], eeprom_rxiq, 4 * grplen);
+ memcpy(&rxiq->group[4], eeprom_rxiq + 6 * grplen, grplen);
+
+ return 0;
+}
+
+int iwm_send_calib_results(struct iwm_priv *iwm)
+{
+ int i, ret = 0;
+
+ for (i = PHY_CALIBRATE_OPCODES_NUM; i < CALIBRATION_CMD_NUM; i++) {
+ if (test_bit(i - PHY_CALIBRATE_OPCODES_NUM,
+ &iwm->calib_done_map)) {
+ IWM_DBG_CMD(iwm, DBG,
+ "Send calibration %d result\n", i);
+ ret |= iwm_send_lmac_ptrough_cmd(iwm,
+ REPLY_PHY_CALIBRATION_CMD,
+ iwm->calib_res[i].buf,
+ iwm->calib_res[i].size, 0);
+
+ kfree(iwm->calib_res[i].buf);
+ iwm->calib_res[i].buf = NULL;
+ iwm->calib_res[i].size = 0;
+ }
+ }
+
+ return ret;
+}
+
+int iwm_send_umac_reset(struct iwm_priv *iwm, __le32 reset_flags, bool resp)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_umac_cmd_reset reset;
+
+ reset.flags = reset_flags;
+
+ umac_cmd.id = UMAC_CMD_OPCODE_RESET;
+ umac_cmd.resp = resp;
+
+ return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &reset,
+ sizeof(struct iwm_umac_cmd_reset));
+}
+
+int iwm_umac_set_config_fix(struct iwm_priv *iwm, u16 tbl, u16 key, u32 value)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_umac_cmd_set_param_fix param;
+
+ if ((tbl != UMAC_PARAM_TBL_CFG_FIX) &&
+ (tbl != UMAC_PARAM_TBL_FA_CFG_FIX))
+ return -EINVAL;
+
+ umac_cmd.id = UMAC_CMD_OPCODE_SET_PARAM_FIX;
+ umac_cmd.resp = 0;
+
+ param.tbl = cpu_to_le16(tbl);
+ param.key = cpu_to_le16(key);
+ param.value = cpu_to_le32(value);
+
+ return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &param,
+ sizeof(struct iwm_umac_cmd_set_param_fix));
+}
+
+int iwm_umac_set_config_var(struct iwm_priv *iwm, u16 key,
+ void *payload, u16 payload_size)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_umac_cmd_set_param_var *param_hdr;
+ u8 *param;
+ int ret;
+
+ param = kzalloc(payload_size +
+ sizeof(struct iwm_umac_cmd_set_param_var), GFP_KERNEL);
+ if (!param) {
+ IWM_ERR(iwm, "Couldn't allocate param\n");
+ return -ENOMEM;
+ }
+
+ param_hdr = (struct iwm_umac_cmd_set_param_var *)param;
+
+ umac_cmd.id = UMAC_CMD_OPCODE_SET_PARAM_VAR;
+ umac_cmd.resp = 0;
+
+ param_hdr->tbl = cpu_to_le16(UMAC_PARAM_TBL_CFG_VAR);
+ param_hdr->key = cpu_to_le16(key);
+ param_hdr->len = cpu_to_le16(payload_size);
+ memcpy(param + sizeof(struct iwm_umac_cmd_set_param_var),
+ payload, payload_size);
+
+ ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, param,
+ sizeof(struct iwm_umac_cmd_set_param_var) +
+ payload_size);
+ kfree(param);
+
+ return ret;
+}
+
+int iwm_send_umac_config(struct iwm_priv *iwm,
+ __le32 reset_flags)
+{
+ int ret;
+
+ /* Use UMAC default values */
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_POWER_INDEX, iwm->conf.power_index);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_FA_CFG_FIX,
+ CFG_FRAG_THRESHOLD,
+ iwm->conf.frag_threshold);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_RTS_THRESHOLD,
+ iwm->conf.rts_threshold);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_CTS_TO_SELF, iwm->conf.cts_to_self);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_COEX_MODE, iwm->conf.coexist_mode);
+ if (ret < 0)
+ return ret;
+
+ /*
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_ASSOCIATION_TIMEOUT,
+ iwm->conf.assoc_timeout);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_ROAM_TIMEOUT,
+ iwm->conf.roam_timeout);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_WIRELESS_MODE,
+ WIRELESS_MODE_11A | WIRELESS_MODE_11G);
+ if (ret < 0)
+ return ret;
+ */
+
+ ret = iwm_umac_set_config_var(iwm, CFG_NET_ADDR,
+ iwm_to_ndev(iwm)->dev_addr, ETH_ALEN);
+ if (ret < 0)
+ return ret;
+
+ /* UMAC PM static configurations */
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_PM_LEGACY_RX_TIMEOUT, 0x12C);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_PM_LEGACY_TX_TIMEOUT, 0x15E);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_PM_CTRL_FLAGS, 0x30001);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_PM_KEEP_ALIVE_IN_BEACONS, 0x80);
+ if (ret < 0)
+ return ret;
+
+ /* reset UMAC */
+ ret = iwm_send_umac_reset(iwm, reset_flags, 1);
+ if (ret < 0)
+ return ret;
+
+ ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_RESET, IWM_SRC_UMAC,
+ WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Wait for UMAC RESET timeout\n");
+ return ret;
+ }
+
+ return ret;
+}
+
+int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id)
+{
+ struct iwm_udma_wifi_cmd udma_cmd;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_tx_info *tx_info = skb_to_tx_info(skb);
+
+ udma_cmd.eop = 1; /* always set eop for non-concatenated Tx */
+ udma_cmd.credit_group = pool_id;
+ udma_cmd.ra_tid = tx_info->sta << 4 | tx_info->tid;
+ udma_cmd.lmac_offset = 0;
+
+ umac_cmd.id = REPLY_TX;
+ umac_cmd.color = tx_info->color;
+ umac_cmd.resp = 0;
+
+ return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd,
+ skb->data, skb->len);
+}
+
+static int iwm_target_read(struct iwm_priv *iwm, __le32 address,
+ u8 *response, u32 resp_size)
+{
+ struct iwm_udma_nonwifi_cmd target_cmd;
+ struct iwm_nonwifi_cmd *cmd;
+ u16 seq_num;
+ int ret = 0;
+
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_READ;
+ target_cmd.addr = address;
+ target_cmd.op1_sz = cpu_to_le32(resp_size);
+ target_cmd.op2 = 0;
+ target_cmd.handle_by_hw = 0;
+ target_cmd.resp = 1;
+ target_cmd.eop = 1;
+
+ ret = iwm_hal_send_target_cmd(iwm, &target_cmd, NULL);
+ if (ret < 0)
+ IWM_ERR(iwm, "Couldn't send READ command\n");
+
+ /* When succeding, the send_target routine returns the seq number */
+ seq_num = ret;
+
+ ret = wait_event_interruptible_timeout(iwm->nonwifi_queue,
+ (cmd = iwm_get_pending_nonwifi_cmd(iwm, seq_num,
+ UMAC_HDI_OUT_OPCODE_READ)) != NULL,
+ 2 * HZ);
+
+ if (!ret) {
+ IWM_ERR(iwm, "Didn't receive a target READ answer\n");
+ return ret;
+ }
+
+ memcpy(response, cmd->buf.hdr + sizeof(struct iwm_udma_in_hdr),
+ resp_size);
+
+ kfree(cmd);
+
+ return ret;
+}
+
+int iwm_read_mac(struct iwm_priv *iwm, u8 *mac)
+{
+ int ret;
+ u8 mac_align[ALIGN(ETH_ALEN, 8)];
+
+ ret = iwm_target_read(iwm, cpu_to_le32(WICO_MAC_ADDRESS_ADDR),
+ mac_align, sizeof(mac_align));
+ if (ret < 0)
+ return ret;
+
+ if (is_valid_ether_addr(mac_align))
+ memcpy(mac, mac_align, ETH_ALEN);
+ else {
+ IWM_ERR(iwm, "Invalid EEPROM MAC\n");
+ memcpy(mac, iwm->conf.mac_addr, ETH_ALEN);
+ get_random_bytes(&mac[3], 3);
+ }
+
+ return 0;
+}
+
+int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx)
+{
+ struct iwm_umac_tx_key_id tx_key_id;
+
+ if (!iwm->default_key || !iwm->default_key->in_use)
+ return -EINVAL;
+
+ tx_key_id.hdr.oid = UMAC_WIFI_IF_CMD_GLOBAL_TX_KEY_ID;
+ tx_key_id.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_tx_key_id) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ tx_key_id.key_idx = key_idx;
+
+ return iwm_send_wifi_if_cmd(iwm, &tx_key_id, sizeof(tx_key_id), 1);
+}
+
+static int iwm_check_profile(struct iwm_priv *iwm)
+{
+ if (!iwm->umac_profile_active)
+ return -EAGAIN;
+
+ if (iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_WEP_40 &&
+ iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_WEP_104 &&
+ iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_TKIP &&
+ iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_CCMP) {
+ IWM_ERR(iwm, "Wrong unicast cipher: 0x%x\n",
+ iwm->umac_profile->sec.ucast_cipher);
+ return -EAGAIN;
+ }
+
+ if (iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_WEP_40 &&
+ iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_WEP_104 &&
+ iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_TKIP &&
+ iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_CCMP) {
+ IWM_ERR(iwm, "Wrong multicast cipher: 0x%x\n",
+ iwm->umac_profile->sec.mcast_cipher);
+ return -EAGAIN;
+ }
+
+ if ((iwm->umac_profile->sec.ucast_cipher == UMAC_CIPHER_TYPE_WEP_40 ||
+ iwm->umac_profile->sec.ucast_cipher == UMAC_CIPHER_TYPE_WEP_104) &&
+ (iwm->umac_profile->sec.ucast_cipher !=
+ iwm->umac_profile->sec.mcast_cipher)) {
+ IWM_ERR(iwm, "Unicast and multicast ciphers differ for WEP\n");
+ }
+
+ return 0;
+}
+
+int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key,
+ struct iwm_key *key)
+{
+ int ret;
+ u8 cmd[64], *sta_addr, *key_data, key_len;
+ s8 key_idx;
+ u16 cmd_size = 0;
+ struct iwm_umac_key_hdr *key_hdr = &key->hdr;
+ struct iwm_umac_key_wep40 *wep40 = (struct iwm_umac_key_wep40 *)cmd;
+ struct iwm_umac_key_wep104 *wep104 = (struct iwm_umac_key_wep104 *)cmd;
+ struct iwm_umac_key_tkip *tkip = (struct iwm_umac_key_tkip *)cmd;
+ struct iwm_umac_key_ccmp *ccmp = (struct iwm_umac_key_ccmp *)cmd;
+
+ if (set_tx_key)
+ iwm->default_key = key;
+
+ /*
+ * We check if our current profile is valid.
+ * If not, we dont push the key, we just cache them,
+ * so that with the next siwsessid call, the keys
+ * will be actually pushed.
+ */
+ if (!remove) {
+ ret = iwm_check_profile(iwm);
+ if (ret < 0)
+ return ret;
+ }
+
+ sta_addr = key->hdr.mac;
+ key_data = key->key;
+ key_len = key->key_len;
+ key_idx = key->hdr.key_idx;
+
+ if (!remove) {
+ IWM_DBG_WEXT(iwm, DBG, "key_idx:%d set tx key:%d\n",
+ key_idx, set_tx_key);
+ IWM_DBG_WEXT(iwm, DBG, "key_len:%d\n", key_len);
+ IWM_DBG_WEXT(iwm, DBG, "MAC:%pM, idx:%d, multicast:%d\n",
+ key_hdr->mac, key_hdr->key_idx, key_hdr->multicast);
+
+ IWM_DBG_WEXT(iwm, DBG, "profile: mcast:0x%x, ucast:0x%x\n",
+ iwm->umac_profile->sec.mcast_cipher,
+ iwm->umac_profile->sec.ucast_cipher);
+ IWM_DBG_WEXT(iwm, DBG, "profile: auth_type:0x%x, flags:0x%x\n",
+ iwm->umac_profile->sec.auth_type,
+ iwm->umac_profile->sec.flags);
+
+ switch (key->alg) {
+ case UMAC_CIPHER_TYPE_WEP_40:
+ wep40->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP40_KEY;
+ wep40->hdr.buf_size =
+ cpu_to_le16(sizeof(struct iwm_umac_key_wep40) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ memcpy(&wep40->key_hdr, key_hdr,
+ sizeof(struct iwm_umac_key_hdr));
+ memcpy(wep40->key, key_data, key_len);
+ wep40->static_key = 1;
+
+ cmd_size = sizeof(struct iwm_umac_key_wep40);
+ break;
+
+ case UMAC_CIPHER_TYPE_WEP_104:
+ wep104->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP104_KEY;
+ wep104->hdr.buf_size =
+ cpu_to_le16(sizeof(struct iwm_umac_key_wep104) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ memcpy(&wep104->key_hdr, key_hdr,
+ sizeof(struct iwm_umac_key_hdr));
+ memcpy(wep104->key, key_data, key_len);
+ wep104->static_key = 1;
+
+ cmd_size = sizeof(struct iwm_umac_key_wep104);
+ break;
+
+ case UMAC_CIPHER_TYPE_CCMP:
+ key_hdr->key_idx++;
+ ccmp->hdr.oid = UMAC_WIFI_IF_CMD_ADD_CCMP_KEY;
+ ccmp->hdr.buf_size =
+ cpu_to_le16(sizeof(struct iwm_umac_key_ccmp) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ memcpy(&ccmp->key_hdr, key_hdr,
+ sizeof(struct iwm_umac_key_hdr));
+
+ memcpy(ccmp->key, key_data, key_len);
+
+ if (key->flags & IW_ENCODE_EXT_RX_SEQ_VALID)
+ memcpy(ccmp->iv_count, key->rx_seq, 6);
+
+ cmd_size = sizeof(struct iwm_umac_key_ccmp);
+ break;
+
+ case UMAC_CIPHER_TYPE_TKIP:
+ key_hdr->key_idx++;
+ tkip->hdr.oid = UMAC_WIFI_IF_CMD_ADD_TKIP_KEY;
+ tkip->hdr.buf_size =
+ cpu_to_le16(sizeof(struct iwm_umac_key_tkip) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ memcpy(&tkip->key_hdr, key_hdr,
+ sizeof(struct iwm_umac_key_hdr));
+
+ memcpy(tkip->tkip_key, key_data, IWM_TKIP_KEY_SIZE);
+ memcpy(tkip->mic_tx_key, key_data + IWM_TKIP_KEY_SIZE,
+ IWM_TKIP_MIC_SIZE);
+ memcpy(tkip->mic_rx_key,
+ key_data + IWM_TKIP_KEY_SIZE + IWM_TKIP_MIC_SIZE,
+ IWM_TKIP_MIC_SIZE);
+
+ if (key->flags & IW_ENCODE_EXT_RX_SEQ_VALID)
+ memcpy(ccmp->iv_count, key->rx_seq, 6);
+
+ cmd_size = sizeof(struct iwm_umac_key_tkip);
+ break;
+
+ default:
+ return -ENOTSUPP;
+ }
+
+ if ((key->alg == UMAC_CIPHER_TYPE_CCMP) ||
+ (key->alg == UMAC_CIPHER_TYPE_TKIP))
+ /*
+ * UGLY_UGLY_UGLY
+ * Copied HACK from the MWG driver.
+ * Without it, the key is set before the second
+ * EAPOL frame is sent, and the latter is thus
+ * encrypted.
+ */
+ schedule_timeout_interruptible(usecs_to_jiffies(300));
+
+ ret = iwm_send_wifi_if_cmd(iwm, cmd, cmd_size, 1);
+ if (ret < 0)
+ goto err;
+
+ /*
+ * We need a default key only if it is set and
+ * if we're doing WEP.
+ */
+ if (iwm->default_key == key &&
+ ((key->alg == UMAC_CIPHER_TYPE_WEP_40) ||
+ (key->alg == UMAC_CIPHER_TYPE_WEP_104))) {
+ ret = iwm_set_tx_key(iwm, key_idx);
+ if (ret < 0)
+ goto err;
+ }
+ } else {
+ struct iwm_umac_key_remove key_remove;
+
+ key_remove.hdr.oid = UMAC_WIFI_IF_CMD_REMOVE_KEY;
+ key_remove.hdr.buf_size =
+ cpu_to_le16(sizeof(struct iwm_umac_key_remove) -
+ sizeof(struct iwm_umac_wifi_if));
+ memcpy(&key_remove.key_hdr, key_hdr,
+ sizeof(struct iwm_umac_key_hdr));
+
+ ret = iwm_send_wifi_if_cmd(iwm, &key_remove,
+ sizeof(struct iwm_umac_key_remove),
+ 1);
+ if (ret < 0)
+ return ret;
+
+ iwm->keys[key_idx].in_use = 0;
+ }
+
+ return 0;
+
+ err:
+ kfree(key);
+ return ret;
+}
+
+
+int iwm_send_mlme_profile(struct iwm_priv *iwm)
+{
+ int ret, i;
+ struct iwm_umac_profile profile;
+
+ memcpy(&profile, iwm->umac_profile, sizeof(profile));
+
+ profile.hdr.oid = UMAC_WIFI_IF_CMD_SET_PROFILE;
+ profile.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_profile) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ ret = iwm_send_wifi_if_cmd(iwm, &profile, sizeof(profile), 1);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Send profile command failed\n");
+ return ret;
+ }
+
+ /* Wait for the profile to be active */
+ ret = wait_event_interruptible_timeout(iwm->mlme_queue,
+ iwm->umac_profile_active == 1,
+ 3 * HZ);
+ if (!ret)
+ return -EBUSY;
+
+
+ for (i = 0; i < IWM_NUM_KEYS; i++)
+ if (iwm->keys[i].in_use) {
+ int default_key = 0;
+ struct iwm_key *key = &iwm->keys[i];
+
+ if (key == iwm->default_key)
+ default_key = 1;
+
+ /* Wait for the profile before sending the keys */
+ wait_event_interruptible_timeout(iwm->mlme_queue,
+ (test_bit(IWM_STATUS_ASSOCIATING, &iwm->status) ||
+ test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)),
+ 3 * HZ);
+
+ ret = iwm_set_key(iwm, 0, default_key, key);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+int iwm_invalidate_mlme_profile(struct iwm_priv *iwm)
+{
+ int ret;
+ struct iwm_umac_invalidate_profile invalid;
+
+ invalid.hdr.oid = UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE;
+ invalid.hdr.buf_size =
+ cpu_to_le16(sizeof(struct iwm_umac_invalidate_profile) -
+ sizeof(struct iwm_umac_wifi_if));
+
+ invalid.reason = WLAN_REASON_UNSPECIFIED;
+
+ ret = iwm_send_wifi_if_cmd(iwm, &invalid, sizeof(invalid), 1);
+ if (ret < 0)
+ return ret;
+
+ ret = wait_event_interruptible_timeout(iwm->mlme_queue,
+ (iwm->umac_profile_active == 0),
+ 2 * HZ);
+ if (!ret)
+ return -EBUSY;
+
+ return 0;
+}
+
+int iwm_send_umac_stats_req(struct iwm_priv *iwm, u32 flags)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_umac_cmd_stats_req stats_req;
+
+ stats_req.flags = cpu_to_le32(flags);
+
+ umac_cmd.id = UMAC_CMD_OPCODE_STATISTIC_REQUEST;
+ umac_cmd.resp = 0;
+
+ return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &stats_req,
+ sizeof(struct iwm_umac_cmd_stats_req));
+}
+
+int iwm_send_umac_channel_list(struct iwm_priv *iwm)
+{
+ struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_umac_cmd_get_channel_list *ch_list;
+ int size = sizeof(struct iwm_umac_cmd_get_channel_list) +
+ sizeof(struct iwm_umac_channel_info) * 4;
+ int ret;
+
+ ch_list = kzalloc(size, GFP_KERNEL);
+ if (!ch_list) {
+ IWM_ERR(iwm, "Couldn't allocate channel list cmd\n");
+ return -ENOMEM;
+ }
+
+ ch_list->ch[0].band = UMAC_BAND_2GHZ;
+ ch_list->ch[0].type = UMAC_CHANNEL_WIDTH_20MHZ;
+ ch_list->ch[0].flags = UMAC_CHANNEL_FLAG_VALID;
+
+ ch_list->ch[1].band = UMAC_BAND_5GHZ;
+ ch_list->ch[1].type = UMAC_CHANNEL_WIDTH_20MHZ;
+ ch_list->ch[1].flags = UMAC_CHANNEL_FLAG_VALID;
+
+ ch_list->ch[2].band = UMAC_BAND_2GHZ;
+ ch_list->ch[2].type = UMAC_CHANNEL_WIDTH_20MHZ;
+ ch_list->ch[2].flags = UMAC_CHANNEL_FLAG_VALID | UMAC_CHANNEL_FLAG_IBSS;
+
+ ch_list->ch[3].band = UMAC_BAND_5GHZ;
+ ch_list->ch[3].type = UMAC_CHANNEL_WIDTH_20MHZ;
+ ch_list->ch[3].flags = UMAC_CHANNEL_FLAG_VALID | UMAC_CHANNEL_FLAG_IBSS;
+
+ ch_list->count = cpu_to_le16(4);
+
+ umac_cmd.id = UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST;
+ umac_cmd.resp = 1;
+
+ ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, ch_list, size);
+
+ kfree(ch_list);
+
+ return ret;
+}
+
+int iwm_scan_ssids(struct iwm_priv *iwm, struct cfg80211_ssid *ssids,
+ int ssid_num)
+{
+ struct iwm_umac_cmd_scan_request req;
+ int i, ret;
+
+ memset(&req, 0, sizeof(struct iwm_umac_cmd_scan_request));
+
+ req.hdr.oid = UMAC_WIFI_IF_CMD_SCAN_REQUEST;
+ req.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_cmd_scan_request)
+ - sizeof(struct iwm_umac_wifi_if));
+ req.type = UMAC_WIFI_IF_SCAN_TYPE_USER;
+ req.timeout = 2;
+ req.seq_num = iwm->scan_id;
+ req.ssid_num = min(ssid_num, UMAC_WIFI_IF_PROBE_OPTION_MAX);
+
+ for (i = 0; i < req.ssid_num; i++) {
+ memcpy(req.ssids[i].ssid, ssids[i].ssid, ssids[i].ssid_len);
+ req.ssids[i].ssid_len = ssids[i].ssid_len;
+ }
+
+ ret = iwm_send_wifi_if_cmd(iwm, &req, sizeof(req), 0);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't send scan request\n");
+ return ret;
+ }
+
+ iwm->scan_id = iwm->scan_id++ % IWM_SCAN_ID_MAX;
+
+ return 0;
+}
+
+int iwm_scan_one_ssid(struct iwm_priv *iwm, u8 *ssid, int ssid_len)
+{
+ struct cfg80211_ssid one_ssid;
+
+ if (test_and_set_bit(IWM_STATUS_SCANNING, &iwm->status))
+ return 0;
+
+ one_ssid.ssid_len = min(ssid_len, IEEE80211_MAX_SSID_LEN);
+ memcpy(&one_ssid.ssid, ssid, one_ssid.ssid_len);
+
+ return iwm_scan_ssids(iwm, &one_ssid, 1);
+}
+
+int iwm_target_reset(struct iwm_priv *iwm)
+{
+ struct iwm_udma_nonwifi_cmd target_cmd;
+
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_REBOOT;
+ target_cmd.addr = 0;
+ target_cmd.op1_sz = 0;
+ target_cmd.op2 = 0;
+ target_cmd.handle_by_hw = 0;
+ target_cmd.resp = 0;
+ target_cmd.eop = 1;
+
+ return iwm_hal_send_target_cmd(iwm, &target_cmd, NULL);
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.h b/drivers/net/wireless/iwmc3200wifi/commands.h
new file mode 100644
index 000000000000..36b13a130595
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/commands.h
@@ -0,0 +1,419 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_COMMANDS_H__
+#define __IWM_COMMANDS_H__
+
+#include <linux/ieee80211.h>
+
+#define IWM_BARKER_REBOOT_NOTIFICATION 0xF
+#define IWM_ACK_BARKER_NOTIFICATION 0x10
+
+/* UMAC commands */
+#define UMAC_RST_CTRL_FLG_LARC_CLK_EN 0x0001
+#define UMAC_RST_CTRL_FLG_LARC_RESET 0x0002
+#define UMAC_RST_CTRL_FLG_FUNC_RESET 0x0004
+#define UMAC_RST_CTRL_FLG_DEV_RESET 0x0008
+#define UMAC_RST_CTRL_FLG_WIFI_CORE_EN 0x0010
+#define UMAC_RST_CTRL_FLG_WIFI_LINK_EN 0x0040
+#define UMAC_RST_CTRL_FLG_WIFI_MLME_EN 0x0080
+#define UMAC_RST_CTRL_FLG_NVM_RELOAD 0x0100
+
+struct iwm_umac_cmd_reset {
+ __le32 flags;
+} __attribute__ ((packed));
+
+#define UMAC_PARAM_TBL_ORD_FIX 0x0
+#define UMAC_PARAM_TBL_ORD_VAR 0x1
+#define UMAC_PARAM_TBL_CFG_FIX 0x2
+#define UMAC_PARAM_TBL_CFG_VAR 0x3
+#define UMAC_PARAM_TBL_BSS_TRK 0x4
+#define UMAC_PARAM_TBL_FA_CFG_FIX 0x5
+#define UMAC_PARAM_TBL_STA 0x6
+#define UMAC_PARAM_TBL_CHN 0x7
+#define UMAC_PARAM_TBL_STATISTICS 0x8
+
+/* fast access table */
+enum {
+ CFG_FRAG_THRESHOLD = 0,
+ CFG_FRAME_RETRY_LIMIT,
+ CFG_OS_QUEUE_UTIL_TH,
+ CFG_RX_FILTER,
+ /* <-- LAST --> */
+ FAST_ACCESS_CFG_TBL_FIX_LAST
+};
+
+/* fixed size table */
+enum {
+ CFG_POWER_INDEX = 0,
+ CFG_PM_LEGACY_RX_TIMEOUT,
+ CFG_PM_LEGACY_TX_TIMEOUT,
+ CFG_PM_CTRL_FLAGS,
+ CFG_PM_KEEP_ALIVE_IN_BEACONS,
+ CFG_BT_ON_THRESHOLD,
+ CFG_RTS_THRESHOLD,
+ CFG_CTS_TO_SELF,
+ CFG_COEX_MODE,
+ CFG_WIRELESS_MODE,
+ CFG_ASSOCIATION_TIMEOUT,
+ CFG_ROAM_TIMEOUT,
+ CFG_CAPABILITY_SUPPORTED_RATES,
+ CFG_SCAN_ALLOWED_UNASSOC_FLAGS,
+ CFG_SCAN_ALLOWED_MAIN_ASSOC_FLAGS,
+ CFG_SCAN_ALLOWED_PAN_ASSOC_FLAGS,
+ CFG_SCAN_INTERNAL_PERIODIC_ENABLED,
+ CFG_SCAN_IMM_INTERNAL_PERIODIC_SCAN_ON_INIT,
+ CFG_SCAN_DEFAULT_PERIODIC_FREQ_SEC,
+ CFG_SCAN_NUM_PASSIVE_CHAN_PER_PARTIAL_SCAN,
+ CFG_TLC_SUPPORTED_TX_HT_RATES,
+ CFG_TLC_SUPPORTED_TX_RATES,
+ CFG_TLC_VALID_ANTENNA,
+ CFG_TLC_SPATIAL_STREAM_SUPPORTED,
+ CFG_TLC_RETRY_PER_RATE,
+ CFG_TLC_RETRY_PER_HT_RATE,
+ CFG_TLC_FIXED_RATE,
+ CFG_TLC_FIXED_RATE_FLAGS,
+ CFG_TLC_CONTROL_FLAGS,
+ CFG_TLC_SR_MIN_FAIL,
+ CFG_TLC_SR_MIN_PASS,
+ CFG_TLC_HT_STAY_IN_COL_PASS_THRESH,
+ CFG_TLC_HT_STAY_IN_COL_FAIL_THRESH,
+ CFG_TLC_LEGACY_STAY_IN_COL_PASS_THRESH,
+ CFG_TLC_LEGACY_STAY_IN_COL_FAIL_THRESH,
+ CFG_TLC_HT_FLUSH_STATS_PACKETS,
+ CFG_TLC_LEGACY_FLUSH_STATS_PACKETS,
+ CFG_TLC_LEGACY_FLUSH_STATS_MS,
+ CFG_TLC_HT_FLUSH_STATS_MS,
+ CFG_TLC_STAY_IN_COL_TIME_OUT,
+ CFG_TLC_AGG_SHORT_LIM,
+ CFG_TLC_AGG_LONG_LIM,
+ CFG_TLC_HT_SR_NO_DECREASE,
+ CFG_TLC_LEGACY_SR_NO_DECREASE,
+ CFG_TLC_SR_FORCE_DECREASE,
+ CFG_TLC_SR_ALLOW_INCREASE,
+ CFG_TLC_AGG_SET_LONG,
+ CFG_TLC_AUTO_AGGREGATION,
+ CFG_TLC_AGG_THRESHOLD,
+ CFG_TLC_TID_LOAD_THRESHOLD,
+ CFG_TLC_BLOCK_ACK_TIMEOUT,
+ CFG_TLC_NO_BA_COUNTED_AS_ONE,
+ CFG_TLC_NUM_BA_STREAMS_ALLOWED,
+ CFG_TLC_NUM_BA_STREAMS_PRESENT,
+ CFG_TLC_RENEW_ADDBA_DELAY,
+ CFG_TLC_NUM_OF_MULTISEC_TO_COUN_LOAD,
+ CFG_TLC_IS_STABLE_IN_HT,
+ CFG_RLC_CHAIN_CTRL,
+ CFG_TRK_TABLE_OP_MODE,
+ CFG_TRK_TABLE_RSSI_THRESHOLD,
+ CFG_TX_PWR_TARGET, /* Used By xVT */
+ CFG_TX_PWR_LIMIT_USR,
+ CFG_TX_PWR_LIMIT_BSS, /* 11d limit */
+ CFG_TX_PWR_LIMIT_BSS_CONSTRAINT, /* 11h constraint */
+ CFG_TX_PWR_MODE,
+ CFG_MLME_DBG_NOTIF_BLOCK,
+ CFG_BT_OFF_BECONS_INTERVALS,
+ CFG_BT_FRAG_DURATION,
+
+ /* <-- LAST --> */
+ CFG_TBL_FIX_LAST
+};
+
+/* variable size table */
+enum {
+ CFG_NET_ADDR = 0,
+ CFG_PROFILE,
+ /* <-- LAST --> */
+ CFG_TBL_VAR_LAST
+};
+
+struct iwm_umac_cmd_set_param_fix {
+ __le16 tbl;
+ __le16 key;
+ __le32 value;
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_set_param_var {
+ __le16 tbl;
+ __le16 key;
+ __le16 len;
+ __le16 reserved;
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_get_param {
+ __le16 tbl;
+ __le16 key;
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_get_param_resp {
+ __le16 tbl;
+ __le16 key;
+ __le16 len;
+ __le16 reserved;
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_eeprom_proxy_hdr {
+ __le32 type;
+ __le32 offset;
+ __le32 len;
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_eeprom_proxy {
+ struct iwm_umac_cmd_eeprom_proxy_hdr hdr;
+ u8 buf[0];
+} __attribute__ ((packed));
+
+#define IWM_UMAC_CMD_EEPROM_TYPE_READ 0x1
+#define IWM_UMAC_CMD_EEPROM_TYPE_WRITE 0x2
+
+#define UMAC_CHANNEL_FLAG_VALID BIT(0)
+#define UMAC_CHANNEL_FLAG_IBSS BIT(1)
+#define UMAC_CHANNEL_FLAG_ACTIVE BIT(3)
+#define UMAC_CHANNEL_FLAG_RADAR BIT(4)
+#define UMAC_CHANNEL_FLAG_DFS BIT(7)
+
+struct iwm_umac_channel_info {
+ u8 band;
+ u8 type;
+ u8 reserved;
+ u8 flags;
+ __le32 channels_mask;
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_get_channel_list {
+ __le16 count;
+ __le16 reserved;
+ struct iwm_umac_channel_info ch[0];
+} __attribute__ ((packed));
+
+
+/* UMAC WiFi interface commands */
+
+/* Coexistence mode */
+#define COEX_MODE_SA 0x1
+#define COEX_MODE_XOR 0x2
+#define COEX_MODE_CM 0x3
+#define COEX_MODE_MAX 0x4
+
+/* Wireless mode */
+#define WIRELESS_MODE_11A 0x1
+#define WIRELESS_MODE_11G 0x2
+
+#define UMAC_PROFILE_EX_IE_REQUIRED 0x1
+#define UMAC_PROFILE_QOS_ALLOWED 0x2
+
+/* Scanning */
+#define UMAC_WIFI_IF_PROBE_OPTION_MAX 10
+
+#define UMAC_WIFI_IF_SCAN_TYPE_USER 0x0
+#define UMAC_WIFI_IF_SCAN_TYPE_UMAC_RESERVED 0x1
+#define UMAC_WIFI_IF_SCAN_TYPE_HOST_PERIODIC 0x2
+#define UMAC_WIFI_IF_SCAN_TYPE_MAX 0x3
+
+struct iwm_umac_ssid {
+ u8 ssid_len;
+ u8 ssid[IEEE80211_MAX_SSID_LEN];
+ u8 reserved[3];
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_scan_request {
+ struct iwm_umac_wifi_if hdr;
+ __le32 type; /* UMAC_WIFI_IF_SCAN_TYPE_* */
+ u8 ssid_num;
+ u8 seq_num;
+ u8 timeout; /* In seconds */
+ u8 reserved;
+ struct iwm_umac_ssid ssids[UMAC_WIFI_IF_PROBE_OPTION_MAX];
+} __attribute__ ((packed));
+
+#define UMAC_CIPHER_TYPE_NONE 0xFF
+#define UMAC_CIPHER_TYPE_USE_GROUPCAST 0x00
+#define UMAC_CIPHER_TYPE_WEP_40 0x01
+#define UMAC_CIPHER_TYPE_WEP_104 0x02
+#define UMAC_CIPHER_TYPE_TKIP 0x04
+#define UMAC_CIPHER_TYPE_CCMP 0x08
+
+/* Supported authentication types - bitmap */
+#define UMAC_AUTH_TYPE_OPEN 0x00
+#define UMAC_AUTH_TYPE_LEGACY_PSK 0x01
+#define UMAC_AUTH_TYPE_8021X 0x02
+#define UMAC_AUTH_TYPE_RSNA_PSK 0x04
+
+/* iwm_umac_security.flag is WPA supported -- bits[0:0] */
+#define UMAC_SEC_FLG_WPA_ON_POS 0
+#define UMAC_SEC_FLG_WPA_ON_SEED 1
+#define UMAC_SEC_FLG_WPA_ON_MSK (UMAC_SEC_FLG_WPA_ON_SEED << \
+ UMAC_SEC_FLG_WPA_ON_POS)
+
+/* iwm_umac_security.flag is WPA2 supported -- bits [1:1] */
+#define UMAC_SEC_FLG_RSNA_ON_POS 1
+#define UMAC_SEC_FLG_RSNA_ON_SEED 1
+#define UMAC_SEC_FLG_RSNA_ON_MSK (UMAC_SEC_FLG_RSNA_ON_SEED << \
+ UMAC_SEC_FLG_RSNA_ON_POS)
+
+/* iwm_umac_security.flag is WSC mode on -- bits [2:2] */
+#define UMAC_SEC_FLG_WSC_ON_POS 2
+#define UMAC_SEC_FLG_WSC_ON_SEED 1
+
+/* Legacy profile can use only WEP40 and WEP104 for encryption and
+ * OPEN or PSK for authentication */
+#define UMAC_SEC_FLG_LEGACY_PROFILE 0
+
+struct iwm_umac_security {
+ u8 auth_type;
+ u8 ucast_cipher;
+ u8 mcast_cipher;
+ u8 flags;
+} __attribute__ ((packed));
+
+struct iwm_umac_ibss {
+ u8 beacon_interval; /* in millisecond */
+ u8 atim; /* in millisecond */
+ s8 join_only;
+ u8 band;
+ u8 channel;
+ u8 reserved[3];
+} __attribute__ ((packed));
+
+#define UMAC_MODE_BSS 0
+#define UMAC_MODE_IBSS 1
+
+#define UMAC_BSSID_MAX 4
+
+struct iwm_umac_profile {
+ struct iwm_umac_wifi_if hdr;
+ __le32 mode;
+ struct iwm_umac_ssid ssid;
+ u8 bssid[UMAC_BSSID_MAX][ETH_ALEN];
+ struct iwm_umac_security sec;
+ struct iwm_umac_ibss ibss;
+ __le32 channel_2ghz;
+ __le32 channel_5ghz;
+ __le16 flags;
+ u8 wireless_mode;
+ u8 bss_num;
+} __attribute__ ((packed));
+
+struct iwm_umac_invalidate_profile {
+ struct iwm_umac_wifi_if hdr;
+ u8 reason;
+ u8 reserved[3];
+} __attribute__ ((packed));
+
+/* Encryption key commands */
+struct iwm_umac_key_wep40 {
+ struct iwm_umac_wifi_if hdr;
+ struct iwm_umac_key_hdr key_hdr;
+ u8 key[WLAN_KEY_LEN_WEP40];
+ u8 static_key;
+ u8 reserved[2];
+} __attribute__ ((packed));
+
+struct iwm_umac_key_wep104 {
+ struct iwm_umac_wifi_if hdr;
+ struct iwm_umac_key_hdr key_hdr;
+ u8 key[WLAN_KEY_LEN_WEP104];
+ u8 static_key;
+ u8 reserved[2];
+} __attribute__ ((packed));
+
+#define IWM_TKIP_KEY_SIZE 16
+#define IWM_TKIP_MIC_SIZE 8
+struct iwm_umac_key_tkip {
+ struct iwm_umac_wifi_if hdr;
+ struct iwm_umac_key_hdr key_hdr;
+ u8 iv_count[6];
+ u8 reserved[2];
+ u8 tkip_key[IWM_TKIP_KEY_SIZE];
+ u8 mic_rx_key[IWM_TKIP_MIC_SIZE];
+ u8 mic_tx_key[IWM_TKIP_MIC_SIZE];
+} __attribute__ ((packed));
+
+struct iwm_umac_key_ccmp {
+ struct iwm_umac_wifi_if hdr;
+ struct iwm_umac_key_hdr key_hdr;
+ u8 iv_count[6];
+ u8 reserved[2];
+ u8 key[WLAN_KEY_LEN_CCMP];
+} __attribute__ ((packed));
+
+struct iwm_umac_key_remove {
+ struct iwm_umac_wifi_if hdr;
+ struct iwm_umac_key_hdr key_hdr;
+} __attribute__ ((packed));
+
+struct iwm_umac_tx_key_id {
+ struct iwm_umac_wifi_if hdr;
+ u8 key_idx;
+ u8 reserved[3];
+} __attribute__ ((packed));
+
+struct iwm_umac_cmd_stats_req {
+ __le32 flags;
+} __attribute__ ((packed));
+
+/* LMAC commands */
+int iwm_read_mac(struct iwm_priv *iwm, u8 *mac);
+int iwm_send_prio_table(struct iwm_priv *iwm);
+int iwm_send_init_calib_cfg(struct iwm_priv *iwm, u8 calib_requested);
+int iwm_send_periodic_calib_cfg(struct iwm_priv *iwm, u8 calib_requested);
+int iwm_send_calib_results(struct iwm_priv *iwm);
+int iwm_store_rxiq_calib_result(struct iwm_priv *iwm);
+
+/* UMAC commands */
+int iwm_send_wifi_if_cmd(struct iwm_priv *iwm, void *payload, u16 payload_size,
+ bool resp);
+int iwm_send_umac_reset(struct iwm_priv *iwm, __le32 reset_flags, bool resp);
+int iwm_umac_set_config_fix(struct iwm_priv *iwm, u16 tbl, u16 key, u32 value);
+int iwm_umac_set_config_var(struct iwm_priv *iwm, u16 key,
+ void *payload, u16 payload_size);
+int iwm_send_umac_config(struct iwm_priv *iwm, __le32 reset_flags);
+int iwm_send_mlme_profile(struct iwm_priv *iwm);
+int iwm_invalidate_mlme_profile(struct iwm_priv *iwm);
+int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id);
+int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx);
+int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key,
+ struct iwm_key *key);
+int iwm_send_umac_stats_req(struct iwm_priv *iwm, u32 flags);
+int iwm_send_umac_channel_list(struct iwm_priv *iwm);
+int iwm_scan_ssids(struct iwm_priv *iwm, struct cfg80211_ssid *ssids,
+ int ssid_num);
+int iwm_scan_one_ssid(struct iwm_priv *iwm, u8 *ssid, int ssid_len);
+
+/* UDMA commands */
+int iwm_target_reset(struct iwm_priv *iwm);
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/debug.h b/drivers/net/wireless/iwmc3200wifi/debug.h
new file mode 100644
index 000000000000..8fbb42d9c21f
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/debug.h
@@ -0,0 +1,124 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#ifndef __IWM_DEBUG_H__
+#define __IWM_DEBUG_H__
+
+#define IWM_ERR(p, f, a...) dev_err(iwm_to_dev(p), f, ## a)
+#define IWM_WARN(p, f, a...) dev_warn(iwm_to_dev(p), f, ## a)
+#define IWM_INFO(p, f, a...) dev_info(iwm_to_dev(p), f, ## a)
+#define IWM_CRIT(p, f, a...) dev_crit(iwm_to_dev(p), f, ## a)
+
+#ifdef CONFIG_IWM_DEBUG
+
+#define IWM_DEBUG_MODULE(i, level, module, f, a...) \
+do { \
+ if (unlikely(i->dbg.dbg_module[IWM_DM_##module] >= (IWM_DL_##level)))\
+ dev_printk(KERN_INFO, (iwm_to_dev(i)), \
+ "%s " f, __func__ , ## a); \
+} while (0)
+
+#define IWM_HEXDUMP(i, level, module, pref, buf, len) \
+do { \
+ if (unlikely(i->dbg.dbg_module[IWM_DM_##module] >= (IWM_DL_##level)))\
+ print_hex_dump(KERN_INFO, pref, DUMP_PREFIX_OFFSET, \
+ 16, 1, buf, len, 1); \
+} while (0)
+
+#else
+
+#define IWM_DEBUG_MODULE(i, level, module, f, a...)
+#define IWM_HEXDUMP(i, level, module, pref, buf, len)
+
+#endif /* CONFIG_IWM_DEBUG */
+
+/* Debug modules */
+enum iwm_debug_module_id {
+ IWM_DM_BOOT = 0,
+ IWM_DM_FW,
+ IWM_DM_SDIO,
+ IWM_DM_NTF,
+ IWM_DM_RX,
+ IWM_DM_TX,
+ IWM_DM_MLME,
+ IWM_DM_CMD,
+ IWM_DM_WEXT,
+ __IWM_DM_NR,
+};
+#define IWM_DM_DEFAULT 0
+
+#define IWM_DBG_BOOT(i, l, f, a...) IWM_DEBUG_MODULE(i, l, BOOT, f, ## a)
+#define IWM_DBG_FW(i, l, f, a...) IWM_DEBUG_MODULE(i, l, FW, f, ## a)
+#define IWM_DBG_SDIO(i, l, f, a...) IWM_DEBUG_MODULE(i, l, SDIO, f, ## a)
+#define IWM_DBG_NTF(i, l, f, a...) IWM_DEBUG_MODULE(i, l, NTF, f, ## a)
+#define IWM_DBG_RX(i, l, f, a...) IWM_DEBUG_MODULE(i, l, RX, f, ## a)
+#define IWM_DBG_TX(i, l, f, a...) IWM_DEBUG_MODULE(i, l, TX, f, ## a)
+#define IWM_DBG_MLME(i, l, f, a...) IWM_DEBUG_MODULE(i, l, MLME, f, ## a)
+#define IWM_DBG_CMD(i, l, f, a...) IWM_DEBUG_MODULE(i, l, CMD, f, ## a)
+#define IWM_DBG_WEXT(i, l, f, a...) IWM_DEBUG_MODULE(i, l, WEXT, f, ## a)
+
+/* Debug levels */
+enum iwm_debug_level {
+ IWM_DL_NONE = 0,
+ IWM_DL_ERR,
+ IWM_DL_WARN,
+ IWM_DL_INFO,
+ IWM_DL_DBG,
+};
+#define IWM_DL_DEFAULT IWM_DL_ERR
+
+struct iwm_debugfs {
+ struct iwm_priv *iwm;
+ struct dentry *rootdir;
+ struct dentry *devdir;
+ struct dentry *dbgdir;
+ struct dentry *txdir;
+ struct dentry *rxdir;
+ struct dentry *busdir;
+
+ u32 dbg_level;
+ struct dentry *dbg_level_dentry;
+
+ unsigned long dbg_modules;
+ struct dentry *dbg_modules_dentry;
+
+ u8 dbg_module[__IWM_DM_NR];
+ struct dentry *dbg_module_dentries[__IWM_DM_NR];
+
+ struct dentry *txq_dentry;
+ struct dentry *tx_credit_dentry;
+ struct dentry *rx_ticket_dentry;
+};
+
+#ifdef CONFIG_IWM_DEBUG
+int iwm_debugfs_init(struct iwm_priv *iwm);
+void iwm_debugfs_exit(struct iwm_priv *iwm);
+#else
+static inline int iwm_debugfs_init(struct iwm_priv *iwm)
+{
+ return 0;
+}
+static inline void iwm_debugfs_exit(struct iwm_priv *iwm) {}
+#endif
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c
new file mode 100644
index 000000000000..0fa7b9150d58
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c
@@ -0,0 +1,453 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/debugfs.h>
+
+#include "iwm.h"
+#include "bus.h"
+#include "rx.h"
+#include "debug.h"
+
+static struct {
+ u8 id;
+ char *name;
+} iwm_debug_module[__IWM_DM_NR] = {
+ {IWM_DM_BOOT, "boot"},
+ {IWM_DM_FW, "fw"},
+ {IWM_DM_SDIO, "sdio"},
+ {IWM_DM_NTF, "ntf"},
+ {IWM_DM_RX, "rx"},
+ {IWM_DM_TX, "tx"},
+ {IWM_DM_MLME, "mlme"},
+ {IWM_DM_CMD, "cmd"},
+ {IWM_DM_WEXT, "wext"},
+};
+
+#define add_dbg_module(dbg, name, id, initlevel) \
+do { \
+ struct dentry *d; \
+ dbg.dbg_module[id] = (initlevel); \
+ d = debugfs_create_x8(name, 0600, dbg.dbgdir, \
+ &(dbg.dbg_module[id])); \
+ if (!IS_ERR(d)) \
+ dbg.dbg_module_dentries[id] = d; \
+} while (0)
+
+static int iwm_debugfs_u32_read(void *data, u64 *val)
+{
+ struct iwm_priv *iwm = data;
+
+ *val = iwm->dbg.dbg_level;
+ return 0;
+}
+
+static int iwm_debugfs_dbg_level_write(void *data, u64 val)
+{
+ struct iwm_priv *iwm = data;
+ int i;
+
+ iwm->dbg.dbg_level = val;
+
+ for (i = 0; i < __IWM_DM_NR; i++)
+ iwm->dbg.dbg_module[i] = val;
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_iwm_dbg_level,
+ iwm_debugfs_u32_read, iwm_debugfs_dbg_level_write,
+ "%llu\n");
+
+static int iwm_debugfs_dbg_modules_write(void *data, u64 val)
+{
+ struct iwm_priv *iwm = data;
+ int i, bit;
+
+ iwm->dbg.dbg_modules = val;
+
+ for (i = 0; i < __IWM_DM_NR; i++)
+ iwm->dbg.dbg_module[i] = 0;
+
+ for_each_bit(bit, &iwm->dbg.dbg_modules, __IWM_DM_NR)
+ iwm->dbg.dbg_module[bit] = iwm->dbg.dbg_level;
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_iwm_dbg_modules,
+ iwm_debugfs_u32_read, iwm_debugfs_dbg_modules_write,
+ "%llu\n");
+
+static int iwm_txrx_open(struct inode *inode, struct file *filp)
+{
+ filp->private_data = inode->i_private;
+ return 0;
+}
+
+
+static ssize_t iwm_debugfs_txq_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct iwm_priv *iwm = filp->private_data;
+ char *buf;
+ int i, buf_len = 4096;
+ size_t len = 0;
+ ssize_t ret;
+
+ if (*ppos != 0)
+ return 0;
+ if (count < sizeof(buf))
+ return -ENOSPC;
+
+ buf = kzalloc(buf_len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ for (i = 0; i < IWM_TX_QUEUES; i++) {
+ struct iwm_tx_queue *txq = &iwm->txq[i];
+ struct sk_buff *skb;
+ int j;
+ unsigned long flags;
+
+ spin_lock_irqsave(&txq->queue.lock, flags);
+
+ skb = (struct sk_buff *)&txq->queue;
+
+ len += snprintf(buf + len, buf_len - len, "TXQ #%d\n", i);
+ len += snprintf(buf + len, buf_len - len, "\tStopped: %d\n",
+ __netif_subqueue_stopped(iwm_to_ndev(iwm),
+ txq->id));
+ len += snprintf(buf + len, buf_len - len, "\tConcat count:%d\n",
+ txq->concat_count);
+ len += snprintf(buf + len, buf_len - len, "\tQueue len: %d\n",
+ skb_queue_len(&txq->queue));
+ for (j = 0; j < skb_queue_len(&txq->queue); j++) {
+ struct iwm_tx_info *tx_info;
+
+ skb = skb->next;
+ tx_info = skb_to_tx_info(skb);
+
+ len += snprintf(buf + len, buf_len - len,
+ "\tSKB #%d\n", j);
+ len += snprintf(buf + len, buf_len - len,
+ "\t\tsta: %d\n", tx_info->sta);
+ len += snprintf(buf + len, buf_len - len,
+ "\t\tcolor: %d\n", tx_info->color);
+ len += snprintf(buf + len, buf_len - len,
+ "\t\ttid: %d\n", tx_info->tid);
+ }
+
+ spin_unlock_irqrestore(&txq->queue.lock, flags);
+ }
+
+ ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len);
+ kfree(buf);
+
+ return ret;
+}
+
+static ssize_t iwm_debugfs_tx_credit_read(struct file *filp,
+ char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct iwm_priv *iwm = filp->private_data;
+ struct iwm_tx_credit *credit = &iwm->tx_credit;
+ char *buf;
+ int i, buf_len = 4096;
+ size_t len = 0;
+ ssize_t ret;
+
+ if (*ppos != 0)
+ return 0;
+ if (count < sizeof(buf))
+ return -ENOSPC;
+
+ buf = kzalloc(buf_len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ len += snprintf(buf + len, buf_len - len,
+ "NR pools: %d\n", credit->pool_nr);
+ len += snprintf(buf + len, buf_len - len,
+ "pools map: 0x%lx\n", credit->full_pools_map);
+
+ len += snprintf(buf + len, buf_len - len, "\n### POOLS ###\n");
+ for (i = 0; i < IWM_MACS_OUT_GROUPS; i++) {
+ len += snprintf(buf + len, buf_len - len,
+ "pools entry #%d\n", i);
+ len += snprintf(buf + len, buf_len - len,
+ "\tid: %d\n",
+ credit->pools[i].id);
+ len += snprintf(buf + len, buf_len - len,
+ "\tsid: %d\n",
+ credit->pools[i].sid);
+ len += snprintf(buf + len, buf_len - len,
+ "\tmin_pages: %d\n",
+ credit->pools[i].min_pages);
+ len += snprintf(buf + len, buf_len - len,
+ "\tmax_pages: %d\n",
+ credit->pools[i].max_pages);
+ len += snprintf(buf + len, buf_len - len,
+ "\talloc_pages: %d\n",
+ credit->pools[i].alloc_pages);
+ len += snprintf(buf + len, buf_len - len,
+ "\tfreed_pages: %d\n",
+ credit->pools[i].total_freed_pages);
+ }
+
+ len += snprintf(buf + len, buf_len - len, "\n### SPOOLS ###\n");
+ for (i = 0; i < IWM_MACS_OUT_SGROUPS; i++) {
+ len += snprintf(buf + len, buf_len - len,
+ "spools entry #%d\n", i);
+ len += snprintf(buf + len, buf_len - len,
+ "\tid: %d\n",
+ credit->spools[i].id);
+ len += snprintf(buf + len, buf_len - len,
+ "\tmax_pages: %d\n",
+ credit->spools[i].max_pages);
+ len += snprintf(buf + len, buf_len - len,
+ "\talloc_pages: %d\n",
+ credit->spools[i].alloc_pages);
+
+ }
+
+ ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len);
+ kfree(buf);
+
+ return ret;
+}
+
+static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp,
+ char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct iwm_priv *iwm = filp->private_data;
+ struct iwm_rx_ticket_node *ticket, *next;
+ char *buf;
+ int buf_len = 4096, i;
+ size_t len = 0;
+ ssize_t ret;
+
+ if (*ppos != 0)
+ return 0;
+ if (count < sizeof(buf))
+ return -ENOSPC;
+
+ buf = kzalloc(buf_len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) {
+ len += snprintf(buf + len, buf_len - len, "Ticket #%d\n",
+ ticket->ticket->id);
+ len += snprintf(buf + len, buf_len - len, "\taction: 0x%x\n",
+ ticket->ticket->action);
+ len += snprintf(buf + len, buf_len - len, "\tflags: 0x%x\n",
+ ticket->ticket->flags);
+ }
+
+ for (i = 0; i < IWM_RX_ID_HASH; i++) {
+ struct iwm_rx_packet *packet, *nxt;
+ struct list_head *pkt_list = &iwm->rx_packets[i];
+ if (!list_empty(pkt_list)) {
+ len += snprintf(buf + len, buf_len - len,
+ "Packet hash #%d\n", i);
+ list_for_each_entry_safe(packet, nxt, pkt_list, node) {
+ len += snprintf(buf + len, buf_len - len,
+ "\tPacket id: %d\n",
+ packet->id);
+ len += snprintf(buf + len, buf_len - len,
+ "\tPacket length: %lu\n",
+ packet->pkt_size);
+ }
+ }
+ }
+
+ ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len);
+ kfree(buf);
+
+ return ret;
+}
+
+
+static const struct file_operations iwm_debugfs_txq_fops = {
+ .owner = THIS_MODULE,
+ .open = iwm_txrx_open,
+ .read = iwm_debugfs_txq_read,
+};
+
+static const struct file_operations iwm_debugfs_tx_credit_fops = {
+ .owner = THIS_MODULE,
+ .open = iwm_txrx_open,
+ .read = iwm_debugfs_tx_credit_read,
+};
+
+static const struct file_operations iwm_debugfs_rx_ticket_fops = {
+ .owner = THIS_MODULE,
+ .open = iwm_txrx_open,
+ .read = iwm_debugfs_rx_ticket_read,
+};
+
+int iwm_debugfs_init(struct iwm_priv *iwm)
+{
+ int i, result;
+ char devdir[16];
+
+ iwm->dbg.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
+ result = PTR_ERR(iwm->dbg.rootdir);
+ if (!result || IS_ERR(iwm->dbg.rootdir)) {
+ if (result == -ENODEV) {
+ IWM_ERR(iwm, "DebugFS (CONFIG_DEBUG_FS) not "
+ "enabled in kernel config\n");
+ result = 0; /* No debugfs support */
+ }
+ IWM_ERR(iwm, "Couldn't create rootdir: %d\n", result);
+ goto error;
+ }
+
+ snprintf(devdir, sizeof(devdir), "%s", wiphy_name(iwm_to_wiphy(iwm)));
+
+ iwm->dbg.devdir = debugfs_create_dir(devdir, iwm->dbg.rootdir);
+ result = PTR_ERR(iwm->dbg.devdir);
+ if (IS_ERR(iwm->dbg.devdir) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create devdir: %d\n", result);
+ goto error;
+ }
+
+ iwm->dbg.dbgdir = debugfs_create_dir("debug", iwm->dbg.devdir);
+ result = PTR_ERR(iwm->dbg.dbgdir);
+ if (IS_ERR(iwm->dbg.dbgdir) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create dbgdir: %d\n", result);
+ goto error;
+ }
+
+ iwm->dbg.rxdir = debugfs_create_dir("rx", iwm->dbg.devdir);
+ result = PTR_ERR(iwm->dbg.rxdir);
+ if (IS_ERR(iwm->dbg.rxdir) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create rx dir: %d\n", result);
+ goto error;
+ }
+
+ iwm->dbg.txdir = debugfs_create_dir("tx", iwm->dbg.devdir);
+ result = PTR_ERR(iwm->dbg.txdir);
+ if (IS_ERR(iwm->dbg.txdir) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create tx dir: %d\n", result);
+ goto error;
+ }
+
+ iwm->dbg.busdir = debugfs_create_dir("bus", iwm->dbg.devdir);
+ result = PTR_ERR(iwm->dbg.busdir);
+ if (IS_ERR(iwm->dbg.busdir) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create bus dir: %d\n", result);
+ goto error;
+ }
+
+ if (iwm->bus_ops->debugfs_init) {
+ result = iwm->bus_ops->debugfs_init(iwm, iwm->dbg.busdir);
+ if (result < 0) {
+ IWM_ERR(iwm, "Couldn't create bus entry: %d\n", result);
+ goto error;
+ }
+ }
+
+
+ iwm->dbg.dbg_level = IWM_DL_NONE;
+ iwm->dbg.dbg_level_dentry =
+ debugfs_create_file("level", 0200, iwm->dbg.dbgdir, iwm,
+ &fops_iwm_dbg_level);
+ result = PTR_ERR(iwm->dbg.dbg_level_dentry);
+ if (IS_ERR(iwm->dbg.dbg_level_dentry) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create dbg_level: %d\n", result);
+ goto error;
+ }
+
+
+ iwm->dbg.dbg_modules = IWM_DM_DEFAULT;
+ iwm->dbg.dbg_modules_dentry =
+ debugfs_create_file("modules", 0200, iwm->dbg.dbgdir, iwm,
+ &fops_iwm_dbg_modules);
+ result = PTR_ERR(iwm->dbg.dbg_modules_dentry);
+ if (IS_ERR(iwm->dbg.dbg_modules_dentry) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create dbg_modules: %d\n", result);
+ goto error;
+ }
+
+ for (i = 0; i < __IWM_DM_NR; i++)
+ add_dbg_module(iwm->dbg, iwm_debug_module[i].name,
+ iwm_debug_module[i].id, IWM_DL_DEFAULT);
+
+ iwm->dbg.txq_dentry = debugfs_create_file("queues", 0200,
+ iwm->dbg.txdir, iwm,
+ &iwm_debugfs_txq_fops);
+ result = PTR_ERR(iwm->dbg.txq_dentry);
+ if (IS_ERR(iwm->dbg.txq_dentry) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create tx queue: %d\n", result);
+ goto error;
+ }
+
+ iwm->dbg.tx_credit_dentry = debugfs_create_file("credits", 0200,
+ iwm->dbg.txdir, iwm,
+ &iwm_debugfs_tx_credit_fops);
+ result = PTR_ERR(iwm->dbg.tx_credit_dentry);
+ if (IS_ERR(iwm->dbg.tx_credit_dentry) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create tx credit: %d\n", result);
+ goto error;
+ }
+
+ iwm->dbg.rx_ticket_dentry = debugfs_create_file("tickets", 0200,
+ iwm->dbg.rxdir, iwm,
+ &iwm_debugfs_rx_ticket_fops);
+ result = PTR_ERR(iwm->dbg.rx_ticket_dentry);
+ if (IS_ERR(iwm->dbg.rx_ticket_dentry) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create rx ticket: %d\n", result);
+ goto error;
+ }
+
+ return 0;
+
+ error:
+ return result;
+}
+
+void iwm_debugfs_exit(struct iwm_priv *iwm)
+{
+ int i;
+
+ for (i = 0; i < __IWM_DM_NR; i++)
+ debugfs_remove(iwm->dbg.dbg_module_dentries[i]);
+
+ debugfs_remove(iwm->dbg.dbg_modules_dentry);
+ debugfs_remove(iwm->dbg.dbg_level_dentry);
+ debugfs_remove(iwm->dbg.txq_dentry);
+ debugfs_remove(iwm->dbg.tx_credit_dentry);
+ debugfs_remove(iwm->dbg.rx_ticket_dentry);
+ if (iwm->bus_ops->debugfs_exit)
+ iwm->bus_ops->debugfs_exit(iwm);
+
+ debugfs_remove(iwm->dbg.busdir);
+ debugfs_remove(iwm->dbg.dbgdir);
+ debugfs_remove(iwm->dbg.txdir);
+ debugfs_remove(iwm->dbg.rxdir);
+ debugfs_remove(iwm->dbg.devdir);
+ debugfs_remove(iwm->dbg.rootdir);
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/eeprom.c b/drivers/net/wireless/iwmc3200wifi/eeprom.c
new file mode 100644
index 000000000000..0f34b84fd2eb
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/eeprom.c
@@ -0,0 +1,187 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#include <linux/kernel.h>
+
+#include "iwm.h"
+#include "umac.h"
+#include "commands.h"
+#include "eeprom.h"
+
+static struct iwm_eeprom_entry eeprom_map[] = {
+ [IWM_EEPROM_SIG] =
+ {"Signature", IWM_EEPROM_SIG_OFF, IWM_EEPROM_SIG_LEN},
+
+ [IWM_EEPROM_VERSION] =
+ {"Version", IWM_EEPROM_VERSION_OFF, IWM_EEPROM_VERSION_LEN},
+
+ [IWM_EEPROM_OEM_HW_VERSION] =
+ {"OEM HW version", IWM_EEPROM_OEM_HW_VERSION_OFF,
+ IWM_EEPROM_OEM_HW_VERSION_LEN},
+
+ [IWM_EEPROM_MAC_VERSION] =
+ {"MAC version", IWM_EEPROM_MAC_VERSION_OFF, IWM_EEPROM_MAC_VERSION_LEN},
+
+ [IWM_EEPROM_CARD_ID] =
+ {"Card ID", IWM_EEPROM_CARD_ID_OFF, IWM_EEPROM_CARD_ID_LEN},
+
+ [IWM_EEPROM_RADIO_CONF] =
+ {"Radio config", IWM_EEPROM_RADIO_CONF_OFF, IWM_EEPROM_RADIO_CONF_LEN},
+
+ [IWM_EEPROM_SKU_CAP] =
+ {"SKU capabilities", IWM_EEPROM_SKU_CAP_OFF, IWM_EEPROM_SKU_CAP_LEN},
+
+ [IWM_EEPROM_CALIB_RXIQ_OFFSET] =
+ {"RX IQ offset", IWM_EEPROM_CALIB_RXIQ_OFF, IWM_EEPROM_INDIRECT_LEN},
+
+ [IWM_EEPROM_CALIB_RXIQ] =
+ {"Calib RX IQ", 0, IWM_EEPROM_CALIB_RXIQ_LEN},
+};
+
+
+static int iwm_eeprom_read(struct iwm_priv *iwm, u8 eeprom_id)
+{
+ int ret;
+ u32 entry_size, chunk_size, data_offset = 0, addr_offset = 0;
+ u32 addr;
+ struct iwm_udma_wifi_cmd udma_cmd;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_umac_cmd_eeprom_proxy eeprom_cmd;
+
+ if (eeprom_id > (IWM_EEPROM_LAST - 1))
+ return -EINVAL;
+
+ entry_size = eeprom_map[eeprom_id].length;
+
+ if (eeprom_id >= IWM_EEPROM_INDIRECT_DATA) {
+ /* indirect data */
+ u32 off_id = eeprom_id - IWM_EEPROM_INDIRECT_DATA +
+ IWM_EEPROM_INDIRECT_OFFSET;
+
+ eeprom_map[eeprom_id].offset =
+ *(u16 *)(iwm->eeprom + eeprom_map[off_id].offset) << 1;
+ }
+
+ addr = eeprom_map[eeprom_id].offset;
+
+ udma_cmd.eop = 1;
+ udma_cmd.credit_group = 0x4;
+ udma_cmd.ra_tid = UMAC_HDI_ACT_TBL_IDX_HOST_CMD;
+ udma_cmd.lmac_offset = 0;
+
+ umac_cmd.id = UMAC_CMD_OPCODE_EEPROM_PROXY;
+ umac_cmd.resp = 1;
+
+ while (entry_size > 0) {
+ chunk_size = min_t(u32, entry_size, IWM_MAX_EEPROM_DATA_LEN);
+
+ eeprom_cmd.hdr.type =
+ cpu_to_le32(IWM_UMAC_CMD_EEPROM_TYPE_READ);
+ eeprom_cmd.hdr.offset = cpu_to_le32(addr + addr_offset);
+ eeprom_cmd.hdr.len = cpu_to_le32(chunk_size);
+
+ ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd,
+ &umac_cmd, &eeprom_cmd,
+ sizeof(struct iwm_umac_cmd_eeprom_proxy));
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't read eeprom\n");
+ return ret;
+ }
+
+ ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_EEPROM_PROXY,
+ IWM_SRC_UMAC, 2*HZ);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Did not get any eeprom answer\n");
+ return ret;
+ }
+
+ data_offset += chunk_size;
+ addr_offset += chunk_size;
+ entry_size -= chunk_size;
+ }
+
+ return 0;
+}
+
+u8 *iwm_eeprom_access(struct iwm_priv *iwm, u8 eeprom_id)
+{
+ if (!iwm->eeprom)
+ return ERR_PTR(-ENODEV);
+
+ return iwm->eeprom + eeprom_map[eeprom_id].offset;
+}
+
+int iwm_eeprom_init(struct iwm_priv *iwm)
+{
+ int i, ret = 0;
+ char name[32];
+
+ iwm->eeprom = kzalloc(IWM_EEPROM_LEN, GFP_KERNEL);
+ if (!iwm->eeprom)
+ return -ENOMEM;
+
+ for (i = IWM_EEPROM_FIRST; i < IWM_EEPROM_LAST; i++) {
+#ifdef CONFIG_IWM_B0_HW_SUPPORT
+ if (iwm->conf.hw_b0 && (i >= IWM_EEPROM_INDIRECT_OFFSET))
+ break;
+#endif
+ ret = iwm_eeprom_read(iwm, i);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't read eeprom entry #%d: %s\n",
+ i, eeprom_map[i].name);
+ break;
+ }
+ }
+
+ IWM_DBG_BOOT(iwm, DBG, "EEPROM dump:\n");
+ for (i = IWM_EEPROM_FIRST; i < IWM_EEPROM_LAST; i++) {
+ memset(name, 0, 32);
+ sprintf(name, "%s: ", eeprom_map[i].name);
+
+ IWM_HEXDUMP(iwm, DBG, BOOT, name,
+ iwm->eeprom + eeprom_map[i].offset,
+ eeprom_map[i].length);
+ }
+
+ return ret;
+}
+
+void iwm_eeprom_exit(struct iwm_priv *iwm)
+{
+ kfree(iwm->eeprom);
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/eeprom.h b/drivers/net/wireless/iwmc3200wifi/eeprom.h
new file mode 100644
index 000000000000..cdb31a6a1f5f
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/eeprom.h
@@ -0,0 +1,114 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_EEPROM_H__
+#define __IWM_EEPROM_H__
+
+enum {
+ IWM_EEPROM_SIG = 0,
+ IWM_EEPROM_FIRST = IWM_EEPROM_SIG,
+ IWM_EEPROM_VERSION,
+ IWM_EEPROM_OEM_HW_VERSION,
+ IWM_EEPROM_MAC_VERSION,
+ IWM_EEPROM_CARD_ID,
+ IWM_EEPROM_RADIO_CONF,
+ IWM_EEPROM_SKU_CAP,
+
+ IWM_EEPROM_INDIRECT_OFFSET,
+ IWM_EEPROM_CALIB_RXIQ_OFFSET = IWM_EEPROM_INDIRECT_OFFSET,
+
+ IWM_EEPROM_INDIRECT_DATA,
+ IWM_EEPROM_CALIB_RXIQ = IWM_EEPROM_INDIRECT_DATA,
+
+ IWM_EEPROM_LAST,
+};
+
+#define IWM_EEPROM_SIG_OFF 0x00
+#define IWM_EEPROM_VERSION_OFF (0x54 << 1)
+#define IWM_EEPROM_OEM_HW_VERSION_OFF (0x56 << 1)
+#define IWM_EEPROM_MAC_VERSION_OFF (0x30 << 1)
+#define IWM_EEPROM_CARD_ID_OFF (0x5d << 1)
+#define IWM_EEPROM_RADIO_CONF_OFF (0x58 << 1)
+#define IWM_EEPROM_SKU_CAP_OFF (0x55 << 1)
+#define IWM_EEPROM_CALIB_CONFIG_OFF (0x7c << 1)
+
+#define IWM_EEPROM_SIG_LEN 4
+#define IWM_EEPROM_VERSION_LEN 2
+#define IWM_EEPROM_OEM_HW_VERSION_LEN 2
+#define IWM_EEPROM_MAC_VERSION_LEN 1
+#define IWM_EEPROM_CARD_ID_LEN 2
+#define IWM_EEPROM_RADIO_CONF_LEN 2
+#define IWM_EEPROM_SKU_CAP_LEN 2
+#define IWM_EEPROM_INDIRECT_LEN 2
+
+#define IWM_MAX_EEPROM_DATA_LEN 240
+#define IWM_EEPROM_LEN 0x800
+
+#define IWM_EEPROM_MIN_ALLOWED_VERSION 0x0610
+#define IWM_EEPROM_MAX_ALLOWED_VERSION 0x0700
+#define IWM_EEPROM_CURRENT_VERSION 0x0612
+
+#define IWM_EEPROM_SKU_CAP_BAND_24GHZ (1 << 4)
+#define IWM_EEPROM_SKU_CAP_BAND_52GHZ (1 << 5)
+#define IWM_EEPROM_SKU_CAP_11N_ENABLE (1 << 6)
+
+enum {
+ IWM_EEPROM_CALIB_CAL_HDR,
+ IWM_EEPROM_CALIB_TX_POWER,
+ IWM_EEPROM_CALIB_XTAL,
+ IWM_EEPROM_CALIB_TEMPERATURE,
+ IWM_EEPROM_CALIB_RX_BB_FILTER,
+ IWM_EEPROM_CALIB_RX_IQ,
+ IWM_EEPROM_CALIB_MAX,
+};
+
+#define IWM_EEPROM_CALIB_RXIQ_OFF (IWM_EEPROM_CALIB_CONFIG_OFF + \
+ (IWM_EEPROM_CALIB_RX_IQ << 1))
+#define IWM_EEPROM_CALIB_RXIQ_LEN sizeof(struct iwm_lmac_calib_rxiq)
+
+struct iwm_eeprom_entry {
+ char *name;
+ u32 offset;
+ u32 length;
+};
+
+int iwm_eeprom_init(struct iwm_priv *iwm);
+void iwm_eeprom_exit(struct iwm_priv *iwm);
+u8 *iwm_eeprom_access(struct iwm_priv *iwm, u8 eeprom_id);
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/fw.c b/drivers/net/wireless/iwmc3200wifi/fw.c
new file mode 100644
index 000000000000..db4ba0864730
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/fw.c
@@ -0,0 +1,388 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/firmware.h>
+
+#include "iwm.h"
+#include "bus.h"
+#include "hal.h"
+#include "umac.h"
+#include "debug.h"
+#include "fw.h"
+#include "commands.h"
+
+static const char fw_barker[] = "*WESTOPFORNOONE*";
+
+/*
+ * @op_code: Op code we're looking for.
+ * @index: There can be several instances of the same opcode within
+ * the firmware. Index specifies which one we're looking for.
+ */
+static int iwm_fw_op_offset(struct iwm_priv *iwm, const struct firmware *fw,
+ u16 op_code, u32 index)
+{
+ int offset = -EINVAL, fw_offset;
+ u32 op_index = 0;
+ const u8 *fw_ptr;
+ struct iwm_fw_hdr_rec *rec;
+
+ fw_offset = 0;
+ fw_ptr = fw->data;
+
+ /* We first need to look for the firmware barker */
+ if (memcmp(fw_ptr, fw_barker, IWM_HDR_BARKER_LEN)) {
+ IWM_ERR(iwm, "No barker string in this FW\n");
+ return -EINVAL;
+ }
+
+ if (fw->size < IWM_HDR_LEN) {
+ IWM_ERR(iwm, "FW is too small (%d)\n", fw->size);
+ return -EINVAL;
+ }
+
+ fw_offset += IWM_HDR_BARKER_LEN;
+
+ while (fw_offset < fw->size) {
+ rec = (struct iwm_fw_hdr_rec *)(fw_ptr + fw_offset);
+
+ IWM_DBG_FW(iwm, DBG, "FW: op_code: 0x%x, len: %d @ 0x%x\n",
+ rec->op_code, rec->len, fw_offset);
+
+ if (rec->op_code == IWM_HDR_REC_OP_INVALID) {
+ IWM_DBG_FW(iwm, DBG, "Reached INVALID op code\n");
+ break;
+ }
+
+ if (rec->op_code == op_code) {
+ if (op_index == index) {
+ fw_offset += sizeof(struct iwm_fw_hdr_rec);
+ offset = fw_offset;
+ goto out;
+ }
+ op_index++;
+ }
+
+ fw_offset += sizeof(struct iwm_fw_hdr_rec) + rec->len;
+ }
+
+ out:
+ return offset;
+}
+
+static int iwm_load_firmware_chunk(struct iwm_priv *iwm,
+ const struct firmware *fw,
+ struct iwm_fw_img_desc *img_desc)
+{
+ struct iwm_udma_nonwifi_cmd target_cmd;
+ u32 chunk_size;
+ const u8 *chunk_ptr;
+ int ret = 0;
+
+ IWM_DBG_FW(iwm, INFO, "Loading FW chunk: %d bytes @ 0x%x\n",
+ img_desc->length, img_desc->address);
+
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
+ target_cmd.handle_by_hw = 1;
+ target_cmd.op2 = 0;
+ target_cmd.resp = 0;
+ target_cmd.eop = 1;
+
+ chunk_size = img_desc->length;
+ chunk_ptr = fw->data + img_desc->offset;
+
+ while (chunk_size > 0) {
+ u32 tmp_chunk_size;
+
+ tmp_chunk_size = min_t(u32, chunk_size,
+ IWM_MAX_NONWIFI_CMD_BUFF_SIZE);
+
+ target_cmd.addr = cpu_to_le32(img_desc->address +
+ (chunk_ptr - fw->data - img_desc->offset));
+ target_cmd.op1_sz = cpu_to_le32(tmp_chunk_size);
+
+ IWM_DBG_FW(iwm, DBG, "\t%d bytes @ 0x%x\n",
+ tmp_chunk_size, target_cmd.addr);
+
+ ret = iwm_hal_send_target_cmd(iwm, &target_cmd, chunk_ptr);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't load FW chunk\n");
+ break;
+ }
+
+ chunk_size -= tmp_chunk_size;
+ chunk_ptr += tmp_chunk_size;
+ }
+
+ return ret;
+}
+/*
+ * To load a fw image to the target, we basically go through the
+ * fw, looking for OP_MEM_DESC records. Once we found one, we
+ * pass it to iwm_load_firmware_chunk().
+ * The OP_MEM_DESC records contain the actuall memory chunk to be
+ * sent, but also the destination address.
+ */
+static int iwm_load_img(struct iwm_priv *iwm, const char *img_name)
+{
+ const struct firmware *fw;
+ struct iwm_fw_img_desc *img_desc;
+ struct iwm_fw_img_ver *ver;
+ int ret = 0, fw_offset;
+ u32 opcode_idx = 0, build_date;
+ char *build_tag;
+
+ ret = request_firmware(&fw, img_name, iwm_to_dev(iwm));
+ if (ret) {
+ IWM_ERR(iwm, "Request firmware failed");
+ return ret;
+ }
+
+ IWM_DBG_FW(iwm, INFO, "Start to load FW %s\n", img_name);
+
+ while (1) {
+ fw_offset = iwm_fw_op_offset(iwm, fw,
+ IWM_HDR_REC_OP_MEM_DESC,
+ opcode_idx);
+ if (fw_offset < 0)
+ break;
+
+ img_desc = (struct iwm_fw_img_desc *)(fw->data + fw_offset);
+ ret = iwm_load_firmware_chunk(iwm, fw, img_desc);
+ if (ret < 0)
+ goto err_release_fw;
+ opcode_idx++;
+ };
+
+ /* Read firmware version */
+ fw_offset = iwm_fw_op_offset(iwm, fw, IWM_HDR_REC_OP_SW_VER, 0);
+ if (fw_offset < 0)
+ goto err_release_fw;
+
+ ver = (struct iwm_fw_img_ver *)(fw->data + fw_offset);
+
+ /* Read build tag */
+ fw_offset = iwm_fw_op_offset(iwm, fw, IWM_HDR_REC_OP_BUILD_TAG, 0);
+ if (fw_offset < 0)
+ goto err_release_fw;
+
+ build_tag = (char *)(fw->data + fw_offset);
+
+ /* Read build date */
+ fw_offset = iwm_fw_op_offset(iwm, fw, IWM_HDR_REC_OP_BUILD_DATE, 0);
+ if (fw_offset < 0)
+ goto err_release_fw;
+
+ build_date = *(u32 *)(fw->data + fw_offset);
+
+ IWM_INFO(iwm, "%s:\n", img_name);
+ IWM_INFO(iwm, "\tVersion: %02X.%02X\n", ver->major, ver->minor);
+ IWM_INFO(iwm, "\tBuild tag: %s\n", build_tag);
+ IWM_INFO(iwm, "\tBuild date: %x-%x-%x\n",
+ IWM_BUILD_YEAR(build_date), IWM_BUILD_MONTH(build_date),
+ IWM_BUILD_DAY(build_date));
+
+
+ err_release_fw:
+ release_firmware(fw);
+
+ return ret;
+}
+
+static int iwm_load_umac(struct iwm_priv *iwm)
+{
+ struct iwm_udma_nonwifi_cmd target_cmd;
+ int ret;
+
+ ret = iwm_load_img(iwm, iwm->bus_ops->umac_name);
+ if (ret < 0)
+ return ret;
+
+ /* We've loaded the UMAC, we can tell the target to jump there */
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_JUMP;
+ target_cmd.addr = cpu_to_le32(UMAC_MU_FW_INST_DATA_12_ADDR);
+ target_cmd.op1_sz = 0;
+ target_cmd.op2 = 0;
+ target_cmd.handle_by_hw = 0;
+ target_cmd.resp = 1 ;
+ target_cmd.eop = 1;
+
+ ret = iwm_hal_send_target_cmd(iwm, &target_cmd, NULL);
+ if (ret < 0)
+ IWM_ERR(iwm, "Couldn't send JMP command\n");
+
+ return ret;
+}
+
+static int iwm_load_lmac(struct iwm_priv *iwm, const char *img_name)
+{
+ int ret;
+
+ ret = iwm_load_img(iwm, img_name);
+ if (ret < 0)
+ return ret;
+
+ return iwm_send_umac_reset(iwm,
+ cpu_to_le32(UMAC_RST_CTRL_FLG_LARC_CLK_EN), 0);
+}
+
+/*
+ * We currently have to load 3 FWs:
+ * 1) The UMAC (Upper MAC).
+ * 2) The calibration LMAC (Lower MAC).
+ * We then send the calibration init command, so that the device can
+ * run a first calibration round.
+ * 3) The operational LMAC, which replaces the calibration one when it's
+ * done with the first calibration round.
+ *
+ * Once those 3 FWs have been loaded, we send the periodic calibration
+ * command, and then the device is available for regular 802.11 operations.
+ */
+int iwm_load_fw(struct iwm_priv *iwm)
+{
+ int ret;
+
+ /* We first start downloading the UMAC */
+ ret = iwm_load_umac(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "UMAC loading failed\n");
+ return ret;
+ }
+
+ /* Handle UMAC_ALIVE notification */
+ ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_ALIVE, IWM_SRC_UMAC,
+ WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Handle UMAC_ALIVE failed: %d\n", ret);
+ return ret;
+ }
+
+ /* UMAC is alive, we can download the calibration LMAC */
+ ret = iwm_load_lmac(iwm, iwm->bus_ops->calib_lmac_name);
+ if (ret) {
+ IWM_ERR(iwm, "Calibration LMAC loading failed\n");
+ return ret;
+ }
+
+ /* Handle UMAC_INIT_COMPLETE notification */
+ ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_INIT_COMPLETE,
+ IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Handle INIT_COMPLETE failed for calibration "
+ "LMAC: %d\n", ret);
+ return ret;
+ }
+
+ /* Read EEPROM data */
+ ret = iwm_eeprom_init(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't init eeprom array\n");
+ return ret;
+ }
+
+#ifdef CONFIG_IWM_B0_HW_SUPPORT
+ if (iwm->conf.hw_b0) {
+ clear_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->conf.init_calib_map);
+ clear_bit(PHY_CALIBRATE_RX_IQ_CMD,
+ &iwm->conf.periodic_calib_map);
+ }
+#endif
+ /* Read RX IQ calibration result from EEPROM */
+ if (test_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->conf.init_calib_map)) {
+ iwm_store_rxiq_calib_result(iwm);
+ set_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->calib_done_map);
+ }
+
+ iwm_send_prio_table(iwm);
+ iwm_send_init_calib_cfg(iwm, iwm->conf.init_calib_map);
+
+ while (iwm->calib_done_map != iwm->conf.init_calib_map) {
+ ret = iwm_notif_handle(iwm, CALIBRATION_RES_NOTIFICATION,
+ IWM_SRC_LMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Wait for calibration result timeout\n");
+ goto out;
+ }
+ IWM_DBG_FW(iwm, DBG, "Got calibration result. calib_done_map: "
+ "0x%lx, requested calibrations: 0x%lx\n",
+ iwm->calib_done_map, iwm->conf.init_calib_map);
+ }
+
+ /* Handle LMAC CALIBRATION_COMPLETE notification */
+ ret = iwm_notif_handle(iwm, CALIBRATION_COMPLETE_NOTIFICATION,
+ IWM_SRC_LMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Wait for CALIBRATION_COMPLETE timeout\n");
+ goto out;
+ }
+
+ IWM_INFO(iwm, "LMAC calibration done: 0x%lx\n", iwm->calib_done_map);
+
+ iwm_send_umac_reset(iwm, cpu_to_le32(UMAC_RST_CTRL_FLG_LARC_RESET), 1);
+
+ ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_RESET, IWM_SRC_UMAC,
+ WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Wait for UMAC RESET timeout\n");
+ goto out;
+ }
+
+ /* Download the operational LMAC */
+ ret = iwm_load_lmac(iwm, iwm->bus_ops->lmac_name);
+ if (ret) {
+ IWM_ERR(iwm, "LMAC loading failed\n");
+ goto out;
+ }
+
+ ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_INIT_COMPLETE,
+ IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Handle INIT_COMPLETE failed for LMAC: %d\n", ret);
+ goto out;
+ }
+
+ iwm_send_prio_table(iwm);
+ iwm_send_calib_results(iwm);
+ iwm_send_periodic_calib_cfg(iwm, iwm->conf.periodic_calib_map);
+
+ return 0;
+
+ out:
+ iwm_eeprom_exit(iwm);
+ return ret;
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/fw.h b/drivers/net/wireless/iwmc3200wifi/fw.h
new file mode 100644
index 000000000000..c70a3b40dad3
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/fw.h
@@ -0,0 +1,100 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_FW_H__
+#define __IWM_FW_H__
+
+/**
+ * struct iwm_fw_hdr_rec - An iwm firmware image is a
+ * concatenation of various records. Each of them is
+ * defined by an ID (aka op code), a length, and the
+ * actual data.
+ * @op_code: The record ID, see IWM_HDR_REC_OP_*
+ *
+ * @len: The record payload length
+ *
+ * @buf: The record payload
+ */
+struct iwm_fw_hdr_rec {
+ u16 op_code;
+ u16 len;
+ u8 buf[0];
+};
+
+/* Header's definitions */
+#define IWM_HDR_LEN (512)
+#define IWM_HDR_BARKER_LEN (16)
+
+/* Header's opcodes */
+#define IWM_HDR_REC_OP_INVALID (0x00)
+#define IWM_HDR_REC_OP_BUILD_DATE (0x01)
+#define IWM_HDR_REC_OP_BUILD_TAG (0x02)
+#define IWM_HDR_REC_OP_SW_VER (0x03)
+#define IWM_HDR_REC_OP_HW_SKU (0x04)
+#define IWM_HDR_REC_OP_BUILD_OPT (0x05)
+#define IWM_HDR_REC_OP_MEM_DESC (0x06)
+#define IWM_HDR_REC_USERDEFS (0x07)
+
+/* Header's records length (in bytes) */
+#define IWM_HDR_REC_LEN_BUILD_DATE (4)
+#define IWM_HDR_REC_LEN_BUILD_TAG (64)
+#define IWM_HDR_REC_LEN_SW_VER (4)
+#define IWM_HDR_REC_LEN_HW_SKU (4)
+#define IWM_HDR_REC_LEN_BUILD_OPT (4)
+#define IWM_HDR_REC_LEN_MEM_DESC (12)
+#define IWM_HDR_REC_LEN_USERDEF (64)
+
+#define IWM_BUILD_YEAR(date) ((date >> 16) & 0xffff)
+#define IWM_BUILD_MONTH(date) ((date >> 8) & 0xff)
+#define IWM_BUILD_DAY(date) (date & 0xff)
+
+struct iwm_fw_img_desc {
+ u32 offset;
+ u32 address;
+ u32 length;
+};
+
+struct iwm_fw_img_ver {
+ u8 minor;
+ u8 major;
+ u16 reserved;
+};
+
+int iwm_load_fw(struct iwm_priv *iwm);
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/hal.c b/drivers/net/wireless/iwmc3200wifi/hal.c
new file mode 100644
index 000000000000..ee127fe4f43f
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/hal.c
@@ -0,0 +1,464 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+/*
+ * Hardware Abstraction Layer for iwm.
+ *
+ * This file mostly defines an abstraction API for
+ * sending various commands to the target.
+ *
+ * We have 2 types of commands: wifi and non-wifi ones.
+ *
+ * - wifi commands:
+ * They are used for sending LMAC and UMAC commands,
+ * and thus are the most commonly used ones.
+ * There are 2 different wifi command types, the regular
+ * one and the LMAC one. The former is used to send
+ * UMAC commands (see UMAC_CMD_OPCODE_* from umac.h)
+ * while the latter is used for sending commands to the
+ * LMAC. If you look at LMAC commands you'll se that they
+ * are actually regular iwlwifi target commands encapsulated
+ * into a special UMAC command called UMAC passthrough.
+ * This is due to the fact the the host talks exclusively
+ * to the UMAC and so there needs to be a special UMAC
+ * command for talking to the LMAC.
+ * This is how a wifi command is layed out:
+ * ------------------------
+ * | iwm_udma_out_wifi_hdr |
+ * ------------------------
+ * | SW meta_data (32 bits) |
+ * ------------------------
+ * | iwm_dev_cmd_hdr |
+ * ------------------------
+ * | payload |
+ * | .... |
+ *
+ * - non-wifi, or general commands:
+ * Those commands are handled by the device's bootrom,
+ * and are typically sent when the UMAC and the LMAC
+ * are not yet available.
+ * * This is how a non-wifi command is layed out:
+ * ---------------------------
+ * | iwm_udma_out_nonwifi_hdr |
+ * ---------------------------
+ * | payload |
+ * | .... |
+
+ *
+ * All the commands start with a UDMA header, which is
+ * basically a 32 bits field. The 4 LSB there define
+ * an opcode that allows the target to differentiate
+ * between wifi (opcode is 0xf) and non-wifi commands
+ * (opcode is [0..0xe]).
+ *
+ * When a command (wifi or non-wifi) is supposed to receive
+ * an answer, we queue the command buffer. When we do receive
+ * a command response from the UMAC, we go through the list
+ * of pending command, and pass both the command and the answer
+ * to the rx handler. Each command is sent with a unique
+ * sequence id, and the answer is sent with the same one. This
+ * is how we're supposed to match an answer with its command.
+ * See rx.c:iwm_rx_handle_[non]wifi() and iwm_get_pending_[non]wifi()
+ * for the implementation details.
+ */
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+
+#include "iwm.h"
+#include "bus.h"
+#include "hal.h"
+#include "umac.h"
+#include "debug.h"
+
+static void iwm_nonwifi_cmd_init(struct iwm_priv *iwm,
+ struct iwm_nonwifi_cmd *cmd,
+ struct iwm_udma_nonwifi_cmd *udma_cmd)
+{
+ INIT_LIST_HEAD(&cmd->pending);
+
+ spin_lock(&iwm->cmd_lock);
+
+ cmd->resp_received = 0;
+
+ cmd->seq_num = iwm->nonwifi_seq_num;
+ udma_cmd->seq_num = cpu_to_le16(cmd->seq_num);
+
+ cmd->seq_num = iwm->nonwifi_seq_num++;
+ iwm->nonwifi_seq_num %= UMAC_NONWIFI_SEQ_NUM_MAX;
+
+ if (udma_cmd->resp)
+ list_add_tail(&cmd->pending, &iwm->nonwifi_pending_cmd);
+
+ spin_unlock(&iwm->cmd_lock);
+
+ cmd->buf.start = cmd->buf.payload;
+ cmd->buf.len = 0;
+
+ memcpy(&cmd->udma_cmd, udma_cmd, sizeof(*udma_cmd));
+}
+
+u16 iwm_alloc_wifi_cmd_seq(struct iwm_priv *iwm)
+{
+ u16 seq_num = iwm->wifi_seq_num;
+
+ iwm->wifi_seq_num++;
+ iwm->wifi_seq_num %= UMAC_WIFI_SEQ_NUM_MAX;
+
+ return seq_num;
+}
+
+static void iwm_wifi_cmd_init(struct iwm_priv *iwm,
+ struct iwm_wifi_cmd *cmd,
+ struct iwm_udma_wifi_cmd *udma_cmd,
+ struct iwm_umac_cmd *umac_cmd,
+ struct iwm_lmac_cmd *lmac_cmd,
+ u16 payload_size)
+{
+ INIT_LIST_HEAD(&cmd->pending);
+
+ spin_lock(&iwm->cmd_lock);
+
+ cmd->seq_num = iwm_alloc_wifi_cmd_seq(iwm);
+ umac_cmd->seq_num = cpu_to_le16(cmd->seq_num);
+
+ if (umac_cmd->resp)
+ list_add_tail(&cmd->pending, &iwm->wifi_pending_cmd);
+
+ spin_unlock(&iwm->cmd_lock);
+
+ cmd->buf.start = cmd->buf.payload;
+ cmd->buf.len = 0;
+
+ if (lmac_cmd) {
+ cmd->buf.start -= sizeof(struct iwm_lmac_hdr);
+
+ lmac_cmd->seq_num = cpu_to_le16(cmd->seq_num);
+ lmac_cmd->count = cpu_to_le16(payload_size);
+
+ memcpy(&cmd->lmac_cmd, lmac_cmd, sizeof(*lmac_cmd));
+
+ umac_cmd->count = cpu_to_le16(sizeof(struct iwm_lmac_hdr));
+ } else
+ umac_cmd->count = 0;
+
+ umac_cmd->count = cpu_to_le16(payload_size +
+ le16_to_cpu(umac_cmd->count));
+ udma_cmd->count = cpu_to_le16(sizeof(struct iwm_umac_fw_cmd_hdr) +
+ le16_to_cpu(umac_cmd->count));
+
+ memcpy(&cmd->udma_cmd, udma_cmd, sizeof(*udma_cmd));
+ memcpy(&cmd->umac_cmd, umac_cmd, sizeof(*umac_cmd));
+}
+
+void iwm_cmd_flush(struct iwm_priv *iwm)
+{
+ struct iwm_wifi_cmd *wcmd, *wnext;
+ struct iwm_nonwifi_cmd *nwcmd, *nwnext;
+
+ list_for_each_entry_safe(wcmd, wnext, &iwm->wifi_pending_cmd, pending) {
+ list_del(&wcmd->pending);
+ kfree(wcmd);
+ }
+
+ list_for_each_entry_safe(nwcmd, nwnext, &iwm->nonwifi_pending_cmd,
+ pending) {
+ list_del(&nwcmd->pending);
+ kfree(nwcmd);
+ }
+}
+
+struct iwm_wifi_cmd *iwm_get_pending_wifi_cmd(struct iwm_priv *iwm, u16 seq_num)
+{
+ struct iwm_wifi_cmd *cmd, *next;
+
+ list_for_each_entry_safe(cmd, next, &iwm->wifi_pending_cmd, pending)
+ if (cmd->seq_num == seq_num) {
+ list_del(&cmd->pending);
+ return cmd;
+ }
+
+ return NULL;
+}
+
+struct iwm_nonwifi_cmd *
+iwm_get_pending_nonwifi_cmd(struct iwm_priv *iwm, u8 seq_num, u8 cmd_opcode)
+{
+ struct iwm_nonwifi_cmd *cmd, *next;
+
+ list_for_each_entry_safe(cmd, next, &iwm->nonwifi_pending_cmd, pending)
+ if ((cmd->seq_num == seq_num) &&
+ (cmd->udma_cmd.opcode == cmd_opcode) &&
+ (cmd->resp_received)) {
+ list_del(&cmd->pending);
+ return cmd;
+ }
+
+ return NULL;
+}
+
+static void iwm_build_udma_nonwifi_hdr(struct iwm_priv *iwm,
+ struct iwm_udma_out_nonwifi_hdr *hdr,
+ struct iwm_udma_nonwifi_cmd *cmd)
+{
+ memset(hdr, 0, sizeof(*hdr));
+
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_OPCODE, cmd->opcode);
+ SET_VAL32(hdr->cmd, UDMA_HDI_OUT_NW_CMD_RESP, cmd->resp);
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_EOT, 1);
+ SET_VAL32(hdr->cmd, UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW,
+ cmd->handle_by_hw);
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_SIGNATURE, UMAC_HDI_OUT_SIGNATURE);
+ SET_VAL32(hdr->cmd, UDMA_HDI_OUT_CMD_NON_WIFI_HW_SEQ_NUM,
+ le16_to_cpu(cmd->seq_num));
+
+ hdr->addr = cmd->addr;
+ hdr->op1_sz = cmd->op1_sz;
+ hdr->op2 = cmd->op2;
+}
+
+static int iwm_send_udma_nonwifi_cmd(struct iwm_priv *iwm,
+ struct iwm_nonwifi_cmd *cmd)
+{
+ struct iwm_udma_out_nonwifi_hdr *udma_hdr;
+ struct iwm_nonwifi_cmd_buff *buf;
+ struct iwm_udma_nonwifi_cmd *udma_cmd = &cmd->udma_cmd;
+
+ buf = &cmd->buf;
+
+ buf->start -= sizeof(struct iwm_umac_nonwifi_out_hdr);
+ buf->len += sizeof(struct iwm_umac_nonwifi_out_hdr);
+
+ udma_hdr = (struct iwm_udma_out_nonwifi_hdr *)(buf->start);
+
+ iwm_build_udma_nonwifi_hdr(iwm, udma_hdr, udma_cmd);
+
+ IWM_DBG_CMD(iwm, DBG,
+ "Send UDMA nonwifi cmd: opcode = 0x%x, resp = 0x%x, "
+ "hw = 0x%x, seqnum = %d, addr = 0x%x, op1_sz = 0x%x, "
+ "op2 = 0x%x\n", udma_cmd->opcode, udma_cmd->resp,
+ udma_cmd->handle_by_hw, cmd->seq_num, udma_cmd->addr,
+ udma_cmd->op1_sz, udma_cmd->op2);
+
+ return iwm_bus_send_chunk(iwm, buf->start, buf->len);
+}
+
+void iwm_udma_wifi_hdr_set_eop(struct iwm_priv *iwm, u8 *buf, u8 eop)
+{
+ struct iwm_udma_out_wifi_hdr *hdr = (struct iwm_udma_out_wifi_hdr *)buf;
+
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_EOT, eop);
+}
+
+void iwm_build_udma_wifi_hdr(struct iwm_priv *iwm,
+ struct iwm_udma_out_wifi_hdr *hdr,
+ struct iwm_udma_wifi_cmd *cmd)
+{
+ memset(hdr, 0, sizeof(*hdr));
+
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_OPCODE, UMAC_HDI_OUT_OPCODE_WIFI);
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_EOT, cmd->eop);
+ SET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_SIGNATURE, UMAC_HDI_OUT_SIGNATURE);
+
+ SET_VAL32(hdr->meta_data, UMAC_HDI_OUT_BYTE_COUNT,
+ le16_to_cpu(cmd->count));
+ SET_VAL32(hdr->meta_data, UMAC_HDI_OUT_CREDIT_GRP, cmd->credit_group);
+ SET_VAL32(hdr->meta_data, UMAC_HDI_OUT_RATID, cmd->ra_tid);
+ SET_VAL32(hdr->meta_data, UMAC_HDI_OUT_LMAC_OFFSET, cmd->lmac_offset);
+}
+
+void iwm_build_umac_hdr(struct iwm_priv *iwm,
+ struct iwm_umac_fw_cmd_hdr *hdr,
+ struct iwm_umac_cmd *cmd)
+{
+ memset(hdr, 0, sizeof(*hdr));
+
+ SET_VAL32(hdr->meta_data, UMAC_FW_CMD_BYTE_COUNT,
+ le16_to_cpu(cmd->count));
+ SET_VAL32(hdr->meta_data, UMAC_FW_CMD_TX_STA_COLOR, cmd->color);
+ SET_VAL8(hdr->cmd.flags, UMAC_DEV_CMD_FLAGS_RESP_REQ, cmd->resp);
+
+ hdr->cmd.cmd = cmd->id;
+ hdr->cmd.seq_num = cmd->seq_num;
+}
+
+static int iwm_send_udma_wifi_cmd(struct iwm_priv *iwm,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_wifi_out_hdr *umac_hdr;
+ struct iwm_wifi_cmd_buff *buf;
+ struct iwm_udma_wifi_cmd *udma_cmd = &cmd->udma_cmd;
+ struct iwm_umac_cmd *umac_cmd = &cmd->umac_cmd;
+ int ret;
+
+ buf = &cmd->buf;
+
+ buf->start -= sizeof(struct iwm_umac_wifi_out_hdr);
+ buf->len += sizeof(struct iwm_umac_wifi_out_hdr);
+
+ umac_hdr = (struct iwm_umac_wifi_out_hdr *)(buf->start);
+
+ iwm_build_udma_wifi_hdr(iwm, &umac_hdr->hw_hdr, udma_cmd);
+ iwm_build_umac_hdr(iwm, &umac_hdr->sw_hdr, umac_cmd);
+
+ IWM_DBG_CMD(iwm, DBG,
+ "Send UDMA wifi cmd: opcode = 0x%x, UMAC opcode = 0x%x, "
+ "eop = 0x%x, count = 0x%x, credit_group = 0x%x, "
+ "ra_tid = 0x%x, lmac_offset = 0x%x, seqnum = %d\n",
+ UMAC_HDI_OUT_OPCODE_WIFI, umac_cmd->id,
+ udma_cmd->eop, udma_cmd->count, udma_cmd->credit_group,
+ udma_cmd->ra_tid, udma_cmd->lmac_offset, cmd->seq_num);
+
+ if (umac_cmd->id == UMAC_CMD_OPCODE_WIFI_PASS_THROUGH)
+ IWM_DBG_CMD(iwm, DBG, "\tLMAC opcode: 0x%x\n",
+ cmd->lmac_cmd.id);
+
+ ret = iwm_tx_credit_alloc(iwm, udma_cmd->credit_group, buf->len);
+
+ /* We keep sending UMAC reset regardless of the command credits.
+ * The UMAC is supposed to be reset anyway and the Tx credits are
+ * reinitialized afterwards. If we are lucky, the reset could
+ * still be done even though we have run out of credits for the
+ * command pool at this moment.*/
+ if (ret && (umac_cmd->id != UMAC_CMD_OPCODE_RESET)) {
+ IWM_DBG_TX(iwm, DBG, "Failed to alloc tx credit for cmd %d\n",
+ umac_cmd->id);
+ return ret;
+ }
+
+ return iwm_bus_send_chunk(iwm, buf->start, buf->len);
+}
+
+/* target_cmd a.k.a udma_nonwifi_cmd can be sent when UMAC is not available */
+int iwm_hal_send_target_cmd(struct iwm_priv *iwm,
+ struct iwm_udma_nonwifi_cmd *udma_cmd,
+ const void *payload)
+{
+ struct iwm_nonwifi_cmd *cmd;
+ int ret;
+
+ cmd = kzalloc(sizeof(struct iwm_nonwifi_cmd), GFP_KERNEL);
+ if (!cmd) {
+ IWM_ERR(iwm, "Couldn't alloc memory for hal cmd\n");
+ return -ENOMEM;
+ }
+
+ iwm_nonwifi_cmd_init(iwm, cmd, udma_cmd);
+
+ if (cmd->udma_cmd.opcode == UMAC_HDI_OUT_OPCODE_WRITE ||
+ cmd->udma_cmd.opcode == UMAC_HDI_OUT_OPCODE_WRITE_PERSISTENT) {
+ cmd->buf.len = le32_to_cpu(cmd->udma_cmd.op1_sz);
+ memcpy(&cmd->buf.payload, payload, cmd->buf.len);
+ }
+
+ ret = iwm_send_udma_nonwifi_cmd(iwm, cmd);
+
+ if (!udma_cmd->resp)
+ kfree(cmd);
+
+ if (ret < 0)
+ return ret;
+
+ return cmd->seq_num;
+}
+
+static void iwm_build_lmac_hdr(struct iwm_priv *iwm, struct iwm_lmac_hdr *hdr,
+ struct iwm_lmac_cmd *cmd)
+{
+ memset(hdr, 0, sizeof(*hdr));
+
+ hdr->id = cmd->id;
+ hdr->flags = 0; /* Is this ever used? */
+ hdr->seq_num = cmd->seq_num;
+}
+
+/*
+ * iwm_hal_send_host_cmd(): sends commands to the UMAC or the LMAC.
+ * Sending command to the LMAC is equivalent to sending a
+ * regular UMAC command with the LMAC passtrough or the LMAC
+ * wrapper UMAC command IDs.
+ */
+int iwm_hal_send_host_cmd(struct iwm_priv *iwm,
+ struct iwm_udma_wifi_cmd *udma_cmd,
+ struct iwm_umac_cmd *umac_cmd,
+ struct iwm_lmac_cmd *lmac_cmd,
+ const void *payload, u16 payload_size)
+{
+ struct iwm_wifi_cmd *cmd;
+ struct iwm_lmac_hdr *hdr;
+ int lmac_hdr_len = 0;
+ int ret;
+
+ cmd = kzalloc(sizeof(struct iwm_wifi_cmd), GFP_KERNEL);
+ if (!cmd) {
+ IWM_ERR(iwm, "Couldn't alloc memory for wifi hal cmd\n");
+ return -ENOMEM;
+ }
+
+ iwm_wifi_cmd_init(iwm, cmd, udma_cmd, umac_cmd, lmac_cmd, payload_size);
+
+ if (lmac_cmd) {
+ hdr = (struct iwm_lmac_hdr *)(cmd->buf.start);
+
+ iwm_build_lmac_hdr(iwm, hdr, &cmd->lmac_cmd);
+ lmac_hdr_len = sizeof(struct iwm_lmac_hdr);
+ }
+
+ memcpy(cmd->buf.payload, payload, payload_size);
+ cmd->buf.len = le16_to_cpu(umac_cmd->count);
+
+ ret = iwm_send_udma_wifi_cmd(iwm, cmd);
+
+ /* We free the cmd if we're not expecting any response */
+ if (!umac_cmd->resp)
+ kfree(cmd);
+ return ret;
+}
+
+/*
+ * iwm_hal_send_umac_cmd(): This is a special case for
+ * iwm_hal_send_host_cmd() to send direct UMAC cmd (without
+ * LMAC involved).
+ */
+int iwm_hal_send_umac_cmd(struct iwm_priv *iwm,
+ struct iwm_udma_wifi_cmd *udma_cmd,
+ struct iwm_umac_cmd *umac_cmd,
+ const void *payload, u16 payload_size)
+{
+ return iwm_hal_send_host_cmd(iwm, udma_cmd, umac_cmd, NULL,
+ payload, payload_size);
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/hal.h b/drivers/net/wireless/iwmc3200wifi/hal.h
new file mode 100644
index 000000000000..0adfdc85765d
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/hal.h
@@ -0,0 +1,236 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef _IWM_HAL_H_
+#define _IWM_HAL_H_
+
+#include "umac.h"
+
+#define GET_VAL8(s, name) ((s >> name##_POS) & name##_SEED)
+#define GET_VAL16(s, name) ((le16_to_cpu(s) >> name##_POS) & name##_SEED)
+#define GET_VAL32(s, name) ((le32_to_cpu(s) >> name##_POS) & name##_SEED)
+
+#define SET_VAL8(s, name, val) \
+do { \
+ s = (s & ~(name##_SEED << name##_POS)) | \
+ ((val & name##_SEED) << name##_POS); \
+} while (0)
+
+#define SET_VAL16(s, name, val) \
+do { \
+ s = cpu_to_le16((le16_to_cpu(s) & ~(name##_SEED << name##_POS)) | \
+ ((val & name##_SEED) << name##_POS)); \
+} while (0)
+
+#define SET_VAL32(s, name, val) \
+do { \
+ s = cpu_to_le32((le32_to_cpu(s) & ~(name##_SEED << name##_POS)) | \
+ ((val & name##_SEED) << name##_POS)); \
+} while (0)
+
+
+#define UDMA_UMAC_INIT { .eop = 1, \
+ .credit_group = 0x4, \
+ .ra_tid = UMAC_HDI_ACT_TBL_IDX_HOST_CMD, \
+ .lmac_offset = 0 }
+#define UDMA_LMAC_INIT { .eop = 1, \
+ .credit_group = 0x4, \
+ .ra_tid = UMAC_HDI_ACT_TBL_IDX_HOST_CMD, \
+ .lmac_offset = 4 }
+
+
+/* UDMA IN OP CODE -- cmd bits [3:0] */
+#define UDMA_IN_OPCODE_MASK 0xF
+
+#define UDMA_IN_OPCODE_GENERAL_RESP 0x0
+#define UDMA_IN_OPCODE_READ_RESP 0x1
+#define UDMA_IN_OPCODE_WRITE_RESP 0x2
+#define UDMA_IN_OPCODE_PERS_WRITE_RESP 0x5
+#define UDMA_IN_OPCODE_PERS_READ_RESP 0x6
+#define UDMA_IN_OPCODE_RD_MDFY_WR_RESP 0x7
+#define UDMA_IN_OPCODE_EP_MNGMT_MSG 0x8
+#define UDMA_IN_OPCODE_CRDT_CHNG_MSG 0x9
+#define UDMA_IN_OPCODE_CNTRL_DATABASE_MSG 0xA
+#define UDMA_IN_OPCODE_SW_MSG 0xB
+#define UDMA_IN_OPCODE_WIFI 0xF
+#define UDMA_IN_OPCODE_WIFI_LMAC 0x1F
+#define UDMA_IN_OPCODE_WIFI_UMAC 0x2F
+
+/* HW API: udma_hdi_nonwifi API (OUT and IN) */
+
+/* iwm_udma_nonwifi_cmd request response -- bits [9:9] */
+#define UDMA_HDI_OUT_NW_CMD_RESP_POS 9
+#define UDMA_HDI_OUT_NW_CMD_RESP_SEED 0x1
+
+/* iwm_udma_nonwifi_cmd handle by HW -- bits [11:11] */
+#define UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW_POS 11
+#define UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW_SEED 0x1
+
+/* iwm_udma_nonwifi_cmd sequence-number -- bits [12:15] */
+#define UDMA_HDI_OUT_NW_CMD_SEQ_NUM_POS 12
+#define UDMA_HDI_OUT_NW_CMD_SEQ_NUM_SEED 0xF
+
+/* UDMA IN Non-WIFI HW sequence number -- bits [12:15] */
+#define UDMA_IN_NW_HW_SEQ_NUM_POS 12
+#define UDMA_IN_NW_HW_SEQ_NUM_SEED 0xF
+
+/* UDMA IN Non-WIFI HW signature -- bits [16:31] */
+#define UDMA_IN_NW_HW_SIG_POS 16
+#define UDMA_IN_NW_HW_SIG_SEED 0xFFFF
+
+/* fixed signature */
+#define UDMA_IN_NW_HW_SIG 0xCBBC
+
+/* UDMA IN Non-WIFI HW block length -- bits [32:35] */
+#define UDMA_IN_NW_HW_LENGTH_SEED 0xF
+#define UDMA_IN_NW_HW_LENGTH_POS 32
+
+/* End of HW API: udma_hdi_nonwifi API (OUT and IN) */
+
+#define IWM_SDIO_FW_MAX_CHUNK_SIZE 2032
+#define IWM_MAX_WIFI_HEADERS_SIZE 32
+#define IWM_MAX_NONWIFI_HEADERS_SIZE 16
+#define IWM_MAX_NONWIFI_CMD_BUFF_SIZE (IWM_SDIO_FW_MAX_CHUNK_SIZE - \
+ IWM_MAX_NONWIFI_HEADERS_SIZE)
+#define IWM_MAX_WIFI_CMD_BUFF_SIZE (IWM_SDIO_FW_MAX_CHUNK_SIZE - \
+ IWM_MAX_WIFI_HEADERS_SIZE)
+
+#define IWM_HAL_CONCATENATE_BUF_SIZE 8192
+
+struct iwm_wifi_cmd_buff {
+ u16 len;
+ u8 *start;
+ u8 hdr[IWM_MAX_WIFI_HEADERS_SIZE];
+ u8 payload[IWM_MAX_WIFI_CMD_BUFF_SIZE];
+};
+
+struct iwm_nonwifi_cmd_buff {
+ u16 len;
+ u8 *start;
+ u8 hdr[IWM_MAX_NONWIFI_HEADERS_SIZE];
+ u8 payload[IWM_MAX_NONWIFI_CMD_BUFF_SIZE];
+};
+
+struct iwm_udma_nonwifi_cmd {
+ u8 opcode;
+ u8 eop;
+ u8 resp;
+ u8 handle_by_hw;
+ __le32 addr;
+ __le32 op1_sz;
+ __le32 op2;
+ __le16 seq_num;
+};
+
+struct iwm_udma_wifi_cmd {
+ __le16 count;
+ u8 eop;
+ u8 credit_group;
+ u8 ra_tid;
+ u8 lmac_offset;
+};
+
+struct iwm_umac_cmd {
+ u8 id;
+ __le16 count;
+ u8 resp;
+ __le16 seq_num;
+ u8 color;
+};
+
+struct iwm_lmac_cmd {
+ u8 id;
+ __le16 count;
+ u8 resp;
+ __le16 seq_num;
+};
+
+struct iwm_nonwifi_cmd {
+ u16 seq_num;
+ bool resp_received;
+ struct list_head pending;
+ struct iwm_udma_nonwifi_cmd udma_cmd;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_lmac_cmd lmac_cmd;
+ struct iwm_nonwifi_cmd_buff buf;
+ u32 flags;
+};
+
+struct iwm_wifi_cmd {
+ u16 seq_num;
+ struct list_head pending;
+ struct iwm_udma_wifi_cmd udma_cmd;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_lmac_cmd lmac_cmd;
+ struct iwm_wifi_cmd_buff buf;
+ u32 flags;
+};
+
+void iwm_cmd_flush(struct iwm_priv *iwm);
+
+struct iwm_wifi_cmd *iwm_get_pending_wifi_cmd(struct iwm_priv *iwm,
+ u16 seq_num);
+struct iwm_nonwifi_cmd *iwm_get_pending_nonwifi_cmd(struct iwm_priv *iwm,
+ u8 seq_num, u8 cmd_opcode);
+
+
+int iwm_hal_send_target_cmd(struct iwm_priv *iwm,
+ struct iwm_udma_nonwifi_cmd *ucmd,
+ const void *payload);
+
+int iwm_hal_send_host_cmd(struct iwm_priv *iwm,
+ struct iwm_udma_wifi_cmd *udma_cmd,
+ struct iwm_umac_cmd *umac_cmd,
+ struct iwm_lmac_cmd *lmac_cmd,
+ const void *payload, u16 payload_size);
+
+int iwm_hal_send_umac_cmd(struct iwm_priv *iwm,
+ struct iwm_udma_wifi_cmd *udma_cmd,
+ struct iwm_umac_cmd *umac_cmd,
+ const void *payload, u16 payload_size);
+
+u16 iwm_alloc_wifi_cmd_seq(struct iwm_priv *iwm);
+
+void iwm_udma_wifi_hdr_set_eop(struct iwm_priv *iwm, u8 *buf, u8 eop);
+void iwm_build_udma_wifi_hdr(struct iwm_priv *iwm,
+ struct iwm_udma_out_wifi_hdr *hdr,
+ struct iwm_udma_wifi_cmd *cmd);
+void iwm_build_umac_hdr(struct iwm_priv *iwm,
+ struct iwm_umac_fw_cmd_hdr *hdr,
+ struct iwm_umac_cmd *cmd);
+#endif /* _IWM_HAL_H_ */
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
new file mode 100644
index 000000000000..3b29681792bb
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
@@ -0,0 +1,350 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_H__
+#define __IWM_H__
+
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <net/cfg80211.h>
+
+#include "debug.h"
+#include "hal.h"
+#include "umac.h"
+#include "lmac.h"
+#include "eeprom.h"
+
+#define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation"
+#define IWM_AUTHOR "<ilw@linux.intel.com>"
+
+#define CONFIG_IWM_B0_HW_SUPPORT 1
+
+#define IWM_SRC_LMAC UMAC_HDI_IN_SOURCE_FHRX
+#define IWM_SRC_UDMA UMAC_HDI_IN_SOURCE_UDMA
+#define IWM_SRC_UMAC UMAC_HDI_IN_SOURCE_FW
+#define IWM_SRC_NUM 3
+
+#define IWM_POWER_INDEX_MIN 0
+#define IWM_POWER_INDEX_MAX 5
+#define IWM_POWER_INDEX_DEFAULT 3
+
+struct iwm_conf {
+ u32 sdio_ior_timeout;
+ unsigned long init_calib_map;
+ unsigned long periodic_calib_map;
+ bool reset_on_fatal_err;
+ bool auto_connect;
+ bool wimax_not_present;
+ bool enable_qos;
+ u32 mode;
+
+ u32 power_index;
+ u32 frag_threshold;
+ u32 rts_threshold;
+ bool cts_to_self;
+
+ u32 assoc_timeout;
+ u32 roam_timeout;
+ u32 wireless_mode;
+ u32 coexist_mode;
+
+ u8 ibss_band;
+ u8 ibss_channel;
+
+ u8 mac_addr[ETH_ALEN];
+#ifdef CONFIG_IWM_B0_HW_SUPPORT
+ bool hw_b0;
+#endif
+};
+
+enum {
+ COEX_MODE_SA = 1,
+ COEX_MODE_XOR,
+ COEX_MODE_CM,
+ COEX_MODE_MAX,
+};
+
+struct iwm_if_ops;
+struct iwm_wifi_cmd;
+
+struct pool_entry {
+ int id; /* group id */
+ int sid; /* super group id */
+ int min_pages; /* min capacity in pages */
+ int max_pages; /* max capacity in pages */
+ int alloc_pages; /* allocated # of pages. incresed by driver */
+ int total_freed_pages; /* total freed # of pages. incresed by UMAC */
+};
+
+struct spool_entry {
+ int id;
+ int max_pages;
+ int alloc_pages;
+};
+
+struct iwm_tx_credit {
+ spinlock_t lock;
+ int pool_nr;
+ unsigned long full_pools_map; /* bitmap for # of filled tx pools */
+ struct pool_entry pools[IWM_MACS_OUT_GROUPS];
+ struct spool_entry spools[IWM_MACS_OUT_SGROUPS];
+};
+
+struct iwm_notif {
+ struct list_head pending;
+ u32 cmd_id;
+ void *cmd;
+ u8 src;
+ void *buf;
+ unsigned long buf_size;
+};
+
+struct iwm_sta_info {
+ u8 addr[ETH_ALEN];
+ bool valid;
+ bool qos;
+ u8 color;
+};
+
+struct iwm_tx_info {
+ u8 sta;
+ u8 color;
+ u8 tid;
+};
+
+struct iwm_rx_info {
+ unsigned long rx_size;
+ unsigned long rx_buf_size;
+};
+
+#define IWM_NUM_KEYS 4
+
+struct iwm_umac_key_hdr {
+ u8 mac[ETH_ALEN];
+ u8 key_idx;
+ u8 multicast; /* BCast encrypt & BCast decrypt of frames FROM mac */
+} __attribute__ ((packed));
+
+struct iwm_key {
+ struct iwm_umac_key_hdr hdr;
+ u8 in_use;
+ u8 alg;
+ u32 flags;
+ u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE];
+ u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE];
+ u8 key_len;
+ u8 key[32];
+};
+
+#define IWM_RX_ID_HASH 0xff
+#define IWM_RX_ID_GET_HASH(id) ((id) % IWM_RX_ID_HASH)
+
+#define IWM_STA_TABLE_NUM 16
+#define IWM_TX_LIST_SIZE 64
+#define IWM_RX_LIST_SIZE 256
+
+#define IWM_SCAN_ID_MAX 0xff
+
+#define IWM_STATUS_READY 0
+#define IWM_STATUS_SCANNING 1
+#define IWM_STATUS_SCAN_ABORTING 2
+#define IWM_STATUS_ASSOCIATING 3
+#define IWM_STATUS_ASSOCIATED 4
+
+#define IWM_RADIO_RFKILL_OFF 0
+#define IWM_RADIO_RFKILL_HW 1
+#define IWM_RADIO_RFKILL_SW 2
+
+struct iwm_tx_queue {
+ int id;
+ struct sk_buff_head queue;
+ struct workqueue_struct *wq;
+ struct work_struct worker;
+ u8 concat_buf[IWM_HAL_CONCATENATE_BUF_SIZE];
+ int concat_count;
+ u8 *concat_ptr;
+};
+
+/* Queues 0 ~ 3 for AC data, 5 for iPAN */
+#define IWM_TX_QUEUES 5
+#define IWM_TX_DATA_QUEUES 4
+#define IWM_TX_CMD_QUEUE 4
+
+struct iwm_bss_info {
+ struct list_head node;
+ struct cfg80211_bss *cfg_bss;
+ struct iwm_umac_notif_bss_info *bss;
+};
+
+typedef int (*iwm_handler)(struct iwm_priv *priv, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd);
+
+#define IWM_WATCHDOG_PERIOD (6 * HZ)
+
+struct iwm_priv {
+ struct wireless_dev *wdev;
+ struct iwm_if_ops *bus_ops;
+
+ struct iwm_conf conf;
+
+ unsigned long status;
+ unsigned long radio;
+
+ struct list_head pending_notif;
+ wait_queue_head_t notif_queue;
+
+ wait_queue_head_t nonwifi_queue;
+
+ unsigned long calib_done_map;
+ struct {
+ u8 *buf;
+ u32 size;
+ } calib_res[CALIBRATION_CMD_NUM];
+
+ struct iwm_umac_profile *umac_profile;
+ bool umac_profile_active;
+
+ u8 bssid[ETH_ALEN];
+ u8 channel;
+ u16 rate;
+
+ struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM];
+ struct list_head bss_list;
+
+ void (*nonwifi_rx_handlers[UMAC_HDI_IN_OPCODE_NONWIFI_MAX])
+ (struct iwm_priv *priv, u8 *buf, unsigned long buf_size);
+
+ const iwm_handler *umac_handlers;
+ const iwm_handler *lmac_handlers;
+ DECLARE_BITMAP(lmac_handler_map, LMAC_COMMAND_ID_NUM);
+ DECLARE_BITMAP(umac_handler_map, LMAC_COMMAND_ID_NUM);
+ DECLARE_BITMAP(udma_handler_map, LMAC_COMMAND_ID_NUM);
+
+ struct list_head wifi_pending_cmd;
+ struct list_head nonwifi_pending_cmd;
+ u16 wifi_seq_num;
+ u8 nonwifi_seq_num;
+ spinlock_t cmd_lock;
+
+ u32 core_enabled;
+
+ u8 scan_id;
+ struct cfg80211_scan_request *scan_request;
+
+ struct sk_buff_head rx_list;
+ struct list_head rx_tickets;
+ struct list_head rx_packets[IWM_RX_ID_HASH];
+ struct workqueue_struct *rx_wq;
+ struct work_struct rx_worker;
+
+ struct iwm_tx_credit tx_credit;
+ struct iwm_tx_queue txq[IWM_TX_QUEUES];
+
+ struct iwm_key keys[IWM_NUM_KEYS];
+ struct iwm_key *default_key;
+
+ wait_queue_head_t mlme_queue;
+
+ struct iw_statistics wstats;
+ struct delayed_work stats_request;
+
+ struct iwm_debugfs dbg;
+
+ u8 *eeprom;
+ struct timer_list watchdog;
+ struct work_struct reset_worker;
+ struct rfkill *rfkill;
+
+ char private[0] __attribute__((__aligned__(NETDEV_ALIGN)));
+};
+
+static inline void *iwm_private(struct iwm_priv *iwm)
+{
+ BUG_ON(!iwm);
+ return &iwm->private;
+}
+
+#define hw_to_iwm(h) (h->iwm)
+#define iwm_to_dev(i) (wiphy_dev(i->wdev->wiphy))
+#define iwm_to_wiphy(i) (i->wdev->wiphy)
+#define wiphy_to_iwm(w) (struct iwm_priv *)(wiphy_priv(w))
+#define iwm_to_wdev(i) (i->wdev)
+#define wdev_to_iwm(w) (struct iwm_priv *)(wdev_priv(w))
+#define iwm_to_ndev(i) (i->wdev->netdev)
+#define ndev_to_iwm(n) (wdev_to_iwm(n->ieee80211_ptr))
+#define skb_to_rx_info(s) ((struct iwm_rx_info *)(s->cb))
+#define skb_to_tx_info(s) ((struct iwm_tx_info *)s->cb)
+
+extern const struct iw_handler_def iwm_iw_handler_def;
+
+void *iwm_if_alloc(int sizeof_bus, struct device *dev,
+ struct iwm_if_ops *if_ops);
+void iwm_if_free(struct iwm_priv *iwm);
+int iwm_mode_to_nl80211_iftype(int mode);
+int iwm_priv_init(struct iwm_priv *iwm);
+void iwm_reset(struct iwm_priv *iwm);
+void iwm_tx_credit_init_pools(struct iwm_priv *iwm,
+ struct iwm_umac_notif_alive *alive);
+int iwm_tx_credit_alloc(struct iwm_priv *iwm, int id, int nb);
+int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd,
+ u8 cmd_id, u8 source, u8 *buf, unsigned long buf_size);
+int iwm_notif_handle(struct iwm_priv *iwm, u32 cmd, u8 source, long timeout);
+void iwm_init_default_profile(struct iwm_priv *iwm,
+ struct iwm_umac_profile *profile);
+void iwm_link_on(struct iwm_priv *iwm);
+void iwm_link_off(struct iwm_priv *iwm);
+int iwm_up(struct iwm_priv *iwm);
+int iwm_down(struct iwm_priv *iwm);
+
+/* TX API */
+void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages);
+void iwm_tx_worker(struct work_struct *work);
+int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
+
+/* RX API */
+void iwm_rx_setup_handlers(struct iwm_priv *iwm);
+int iwm_rx_handle(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size);
+int iwm_rx_handle_resp(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd);
+void iwm_rx_free(struct iwm_priv *iwm);
+
+/* RF Kill API */
+int iwm_rfkill_init(struct iwm_priv *iwm);
+void iwm_rfkill_exit(struct iwm_priv *iwm);
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/lmac.h b/drivers/net/wireless/iwmc3200wifi/lmac.h
new file mode 100644
index 000000000000..db2e5eea1895
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/lmac.h
@@ -0,0 +1,457 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_LMAC_H__
+#define __IWM_LMAC_H__
+
+struct iwm_lmac_hdr {
+ u8 id;
+ u8 flags;
+ __le16 seq_num;
+} __attribute__ ((packed));
+
+/* LMAC commands */
+#define CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_AFTER_MSK 0x1
+
+struct iwm_lmac_cal_cfg_elt {
+ __le32 enable; /* 1 means LMAC needs to do something */
+ __le32 start; /* 1 to start calibration, 0 to stop */
+ __le32 send_res; /* 1 for sending back results */
+ __le32 apply_res; /* 1 for applying calibration results to HW */
+ __le32 reserved;
+} __attribute__ ((packed));
+
+struct iwm_lmac_cal_cfg_status {
+ struct iwm_lmac_cal_cfg_elt init;
+ struct iwm_lmac_cal_cfg_elt periodic;
+ __le32 flags; /* CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_AFTER_MSK */
+} __attribute__ ((packed));
+
+struct iwm_lmac_cal_cfg_cmd {
+ struct iwm_lmac_cal_cfg_status ucode_cfg;
+ struct iwm_lmac_cal_cfg_status driver_cfg;
+ __le32 reserved;
+} __attribute__ ((packed));
+
+struct iwm_lmac_cal_cfg_resp {
+ __le32 status;
+} __attribute__ ((packed));
+
+#define IWM_CARD_STATE_SW_HW_ENABLED 0x00
+#define IWM_CARD_STATE_HW_DISABLED 0x01
+#define IWM_CARD_STATE_SW_DISABLED 0x02
+#define IWM_CARD_STATE_CTKILL_DISABLED 0x04
+#define IWM_CARD_STATE_IS_RXON 0x10
+
+struct iwm_lmac_card_state {
+ __le32 flags;
+} __attribute__ ((packed));
+
+/**
+ * COEX_PRIORITY_TABLE_CMD
+ *
+ * Priority entry for each state
+ * Will keep two tables, for STA and WIPAN
+ */
+enum {
+ /* UN-ASSOCIATION PART */
+ COEX_UNASSOC_IDLE = 0,
+ COEX_UNASSOC_MANUAL_SCAN,
+ COEX_UNASSOC_AUTO_SCAN,
+
+ /* CALIBRATION */
+ COEX_CALIBRATION,
+ COEX_PERIODIC_CALIBRATION,
+
+ /* CONNECTION */
+ COEX_CONNECTION_ESTAB,
+
+ /* ASSOCIATION PART */
+ COEX_ASSOCIATED_IDLE,
+ COEX_ASSOC_MANUAL_SCAN,
+ COEX_ASSOC_AUTO_SCAN,
+ COEX_ASSOC_ACTIVE_LEVEL,
+
+ /* RF ON/OFF */
+ COEX_RF_ON,
+ COEX_RF_OFF,
+ COEX_STAND_ALONE_DEBUG,
+
+ /* IPNN */
+ COEX_IPAN_ASSOC_LEVEL,
+
+ /* RESERVED */
+ COEX_RSRVD1,
+ COEX_RSRVD2,
+
+ COEX_EVENTS_NUM
+};
+
+#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK 0x1
+#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK 0x2
+#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK 0x4
+
+struct coex_event {
+ u8 req_prio;
+ u8 win_med_prio;
+ u8 reserved;
+ u8 flags;
+} __attribute__ ((packed));
+
+#define COEX_FLAGS_STA_TABLE_VALID_MSK 0x1
+#define COEX_FLAGS_UNASSOC_WAKEUP_UMASK_MSK 0x4
+#define COEX_FLAGS_ASSOC_WAKEUP_UMASK_MSK 0x8
+#define COEX_FLAGS_COEX_ENABLE_MSK 0x80
+
+struct iwm_coex_prio_table_cmd {
+ u8 flags;
+ u8 reserved[3];
+ struct coex_event sta_prio[COEX_EVENTS_NUM];
+} __attribute__ ((packed));
+
+/* Coexistence definitions
+ *
+ * Constants to fill in the Priorities' Tables
+ * RP - Requested Priority
+ * WP - Win Medium Priority: priority assigned when the contention has been won
+ * FLAGS - Combination of COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK and
+ * COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK
+ */
+
+#define COEX_UNASSOC_IDLE_FLAGS 0
+#define COEX_UNASSOC_MANUAL_SCAN_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
+#define COEX_UNASSOC_AUTO_SCAN_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
+#define COEX_CALIBRATION_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
+#define COEX_PERIODIC_CALIBRATION_FLAGS 0
+/* COEX_CONNECTION_ESTAB: we need DELAY_MEDIUM_FREE_NTFY to let WiMAX
+ * disconnect from network. */
+#define COEX_CONNECTION_ESTAB_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK | \
+ COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK)
+#define COEX_ASSOCIATED_IDLE_FLAGS 0
+#define COEX_ASSOC_MANUAL_SCAN_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
+#define COEX_ASSOC_AUTO_SCAN_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
+#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
+#define COEX_RF_ON_FLAGS 0
+#define COEX_RF_OFF_FLAGS 0
+#define COEX_STAND_ALONE_DEBUG_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
+#define COEX_IPAN_ASSOC_LEVEL_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK | \
+ COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK)
+#define COEX_RSRVD1_FLAGS 0
+#define COEX_RSRVD2_FLAGS 0
+/* XOR_RF_ON is the event wrapping all radio ownership. We need
+ * DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network. */
+#define COEX_XOR_RF_ON_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
+ COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK | \
+ COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK)
+
+/* LMAC OP CODES */
+#define REPLY_PAD 0x0
+#define REPLY_ALIVE 0x1
+#define REPLY_ERROR 0x2
+#define REPLY_ECHO 0x3
+#define REPLY_HALT 0x6
+
+/* RXON state commands */
+#define REPLY_RX_ON 0x10
+#define REPLY_RX_ON_ASSOC 0x11
+#define REPLY_RX_OFF 0x12
+#define REPLY_QOS_PARAM 0x13
+#define REPLY_RX_ON_TIMING 0x14
+#define REPLY_INTERNAL_QOS_PARAM 0x15
+#define REPLY_RX_INT_TIMEOUT_CNFG 0x16
+#define REPLY_NULL 0x17
+
+/* Multi-Station support */
+#define REPLY_ADD_STA 0x18
+#define REPLY_REMOVE_STA 0x19
+#define REPLY_RESET_ALL_STA 0x1a
+
+/* RX, TX */
+#define REPLY_ALM_RX 0x1b
+#define REPLY_TX 0x1c
+#define REPLY_TXFIFO_FLUSH 0x1e
+
+/* MISC commands */
+#define REPLY_MGMT_MCAST_KEY 0x1f
+#define REPLY_WEPKEY 0x20
+#define REPLY_INIT_IV 0x21
+#define REPLY_WRITE_MIB 0x22
+#define REPLY_READ_MIB 0x23
+#define REPLY_RADIO_FE 0x24
+#define REPLY_TXFIFO_CFG 0x25
+#define REPLY_WRITE_READ 0x26
+#define REPLY_INSTALL_SEC_KEY 0x27
+
+
+#define REPLY_RATE_SCALE 0x47
+#define REPLY_LEDS_CMD 0x48
+#define REPLY_TX_LINK_QUALITY_CMD 0x4e
+#define REPLY_ANA_MIB_OVERRIDE_CMD 0x4f
+#define REPLY_WRITE2REG_CMD 0x50
+
+/* winfi-wifi coexistence */
+#define COEX_PRIORITY_TABLE_CMD 0x5a
+#define COEX_MEDIUM_NOTIFICATION 0x5b
+#define COEX_EVENT_CMD 0x5c
+
+/* more Protocol and Protocol-test commands */
+#define REPLY_MAX_SLEEP_TIME_CMD 0x61
+#define CALIBRATION_CFG_CMD 0x65
+#define CALIBRATION_RES_NOTIFICATION 0x66
+#define CALIBRATION_COMPLETE_NOTIFICATION 0x67
+
+/* Measurements */
+#define REPLY_QUIET_CMD 0x71
+#define REPLY_CHANNEL_SWITCH 0x72
+#define CHANNEL_SWITCH_NOTIFICATION 0x73
+
+#define REPLY_SPECTRUM_MEASUREMENT_CMD 0x74
+#define SPECTRUM_MEASURE_NOTIFICATION 0x75
+#define REPLY_MEASUREMENT_ABORT_CMD 0x76
+
+/* Power Management */
+#define POWER_TABLE_CMD 0x77
+#define SAVE_RESTORE_ADRESS_CMD 0x78
+#define REPLY_WATERMARK_CMD 0x79
+#define PM_DEBUG_STATISTIC_NOTIFIC 0x7B
+#define PD_FLUSH_N_NOTIFICATION 0x7C
+
+/* Scan commands and notifications */
+#define REPLY_SCAN_REQUEST_CMD 0x80
+#define REPLY_SCAN_ABORT_CMD 0x81
+#define SCAN_START_NOTIFICATION 0x82
+#define SCAN_RESULTS_NOTIFICATION 0x83
+#define SCAN_COMPLETE_NOTIFICATION 0x84
+
+/* Continuous TX commands */
+#define REPLY_CONT_TX_CMD 0x85
+#define END_OF_CONT_TX_NOTIFICATION 0x86
+
+/* Timer/Eeprom commands */
+#define TIMER_CMD 0x87
+#define EEPROM_WRITE_CMD 0x88
+
+/* PAPD commands */
+#define FEEDBACK_REQUEST_NOTIFICATION 0x8b
+#define REPLY_CW_CMD 0x8c
+
+/* IBSS/AP commands Continue */
+#define BEACON_NOTIFICATION 0x90
+#define REPLY_TX_BEACON 0x91
+#define REPLY_REQUEST_ATIM 0x93
+#define WHO_IS_AWAKE_NOTIFICATION 0x94
+#define TX_PWR_DBM_LIMIT_CMD 0x95
+#define QUIET_NOTIFICATION 0x96
+#define TX_PWR_TABLE_CMD 0x97
+#define TX_ANT_CONFIGURATION_CMD 0x98
+#define MEASURE_ABORT_NOTIFICATION 0x99
+#define REPLY_CALIBRATION_TUNE 0x9a
+
+/* bt config command */
+#define REPLY_BT_CONFIG 0x9b
+#define REPLY_STATISTICS_CMD 0x9c
+#define STATISTICS_NOTIFICATION 0x9d
+
+/* RF-KILL commands and notifications */
+#define REPLY_CARD_STATE_CMD 0xa0
+#define CARD_STATE_NOTIFICATION 0xa1
+
+/* Missed beacons notification */
+#define MISSED_BEACONS_NOTIFICATION 0xa2
+#define MISSED_BEACONS_NOTIFICATION_TH_CMD 0xa3
+
+#define REPLY_CT_KILL_CONFIG_CMD 0xa4
+
+/* HD commands and notifications */
+#define REPLY_HD_PARAMS_CMD 0xa6
+#define HD_PARAMS_NOTIFICATION 0xa7
+#define SENSITIVITY_CMD 0xa8
+#define U_APSD_PARAMS_CMD 0xa9
+#define NOISY_PLATFORM_CMD 0xaa
+#define ILLEGAL_CMD 0xac
+#define REPLY_PHY_CALIBRATION_CMD 0xb0
+#define REPLAY_RX_GAIN_CALIB_CMD 0xb1
+
+/* WiPAN commands */
+#define REPLY_WIPAN_PARAMS_CMD 0xb2
+#define REPLY_WIPAN_RX_ON_CMD 0xb3
+#define REPLY_WIPAN_RX_ON_TIMING 0xb4
+#define REPLY_WIPAN_TX_PWR_TABLE_CMD 0xb5
+#define REPLY_WIPAN_RXON_ASSOC_CMD 0xb6
+#define REPLY_WIPAN_QOS_PARAM 0xb7
+#define WIPAN_REPLY_WEPKEY 0xb8
+
+/* BeamForming commands */
+#define BEAMFORMER_CFG_CMD 0xba
+#define BEAMFORMEE_NOTIFICATION 0xbb
+
+/* TGn new Commands */
+#define REPLY_RX_PHY_CMD 0xc0
+#define REPLY_RX_MPDU_CMD 0xc1
+#define REPLY_MULTICAST_HASH 0xc2
+#define REPLY_KDR_RX 0xc3
+#define REPLY_RX_DSP_EXT_INFO 0xc4
+#define REPLY_COMPRESSED_BA 0xc5
+
+/* PNC commands */
+#define PNC_CONFIG_CMD 0xc8
+#define PNC_UPDATE_TABLE_CMD 0xc9
+#define XVT_GENERAL_CTRL_CMD 0xca
+#define REPLY_LEGACY_RADIO_FE 0xdd
+
+/* WoWLAN commands */
+#define WOWLAN_PATTERNS 0xe0
+#define WOWLAN_WAKEUP_FILTER 0xe1
+#define WOWLAN_TSC_RSC_PARAM 0xe2
+#define WOWLAN_TKIP_PARAM 0xe3
+#define WOWLAN_KEK_KCK_MATERIAL 0xe4
+#define WOWLAN_GET_STATUSES 0xe5
+#define WOWLAN_TX_POWER_PER_DB 0xe6
+#define REPLY_WOWLAN_GET_STATUSES WOWLAN_GET_STATUSES
+
+#define REPLY_DEBUG_CMD 0xf0
+#define REPLY_DSP_DEBUG_CMD 0xf1
+#define REPLY_DEBUG_MONITOR_CMD 0xf2
+#define REPLY_DEBUG_XVT_CMD 0xf3
+#define REPLY_DEBUG_DC_CALIB 0xf4
+#define REPLY_DYNAMIC_BP 0xf5
+
+/* General purpose Commands */
+#define REPLY_GP1_CMD 0xfa
+#define REPLY_GP2_CMD 0xfb
+#define REPLY_GP3_CMD 0xfc
+#define REPLY_GP4_CMD 0xfd
+#define REPLY_REPLAY_WRAPPER 0xfe
+#define REPLY_FRAME_DURATION_CALC_CMD 0xff
+
+#define LMAC_COMMAND_ID_MAX 0xff
+#define LMAC_COMMAND_ID_NUM (LMAC_COMMAND_ID_MAX + 1)
+
+
+/* Calibration */
+
+enum {
+ PHY_CALIBRATE_DC_CMD = 0,
+ PHY_CALIBRATE_LO_CMD = 1,
+ PHY_CALIBRATE_RX_BB_CMD = 2,
+ PHY_CALIBRATE_TX_IQ_CMD = 3,
+ PHY_CALIBRATE_RX_IQ_CMD = 4,
+ PHY_CALIBRATION_NOISE_CMD = 5,
+ PHY_CALIBRATE_AGC_TABLE_CMD = 6,
+ PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 7,
+ PHY_CALIBRATE_OPCODES_NUM,
+ SHILOH_PHY_CALIBRATE_DC_CMD = 8,
+ SHILOH_PHY_CALIBRATE_LO_CMD = 9,
+ SHILOH_PHY_CALIBRATE_RX_BB_CMD = 10,
+ SHILOH_PHY_CALIBRATE_TX_IQ_CMD = 11,
+ SHILOH_PHY_CALIBRATE_RX_IQ_CMD = 12,
+ SHILOH_PHY_CALIBRATION_NOISE_CMD = 13,
+ SHILOH_PHY_CALIBRATE_AGC_TABLE_CMD = 14,
+ SHILOH_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
+ SHILOH_PHY_CALIBRATE_BASE_BAND_CMD = 16,
+ SHILOH_PHY_CALIBRATE_TXIQ_PERIODIC_CMD = 17,
+ CALIBRATION_CMD_NUM,
+};
+
+struct iwm_lmac_calib_hdr {
+ u8 opcode;
+ u8 first_grp;
+ u8 grp_num;
+ u8 all_data_valid;
+} __attribute__ ((packed));
+
+#define IWM_LMAC_CALIB_FREQ_GROUPS_NR 7
+#define IWM_CALIB_FREQ_GROUPS_NR 5
+#define IWM_CALIB_DC_MODES_NR 12
+
+struct iwm_calib_rxiq_entry {
+ u16 ptam_postdist_ars;
+ u16 ptam_postdist_arc;
+} __attribute__ ((packed));
+
+struct iwm_calib_rxiq_group {
+ struct iwm_calib_rxiq_entry mode[IWM_CALIB_DC_MODES_NR];
+} __attribute__ ((packed));
+
+struct iwm_lmac_calib_rxiq {
+ struct iwm_calib_rxiq_group group[IWM_LMAC_CALIB_FREQ_GROUPS_NR];
+} __attribute__ ((packed));
+
+struct iwm_calib_rxiq {
+ struct iwm_lmac_calib_hdr hdr;
+ struct iwm_calib_rxiq_group group[IWM_CALIB_FREQ_GROUPS_NR];
+} __attribute__ ((packed));
+
+#define LMAC_STA_ID_SEED 0x0f
+#define LMAC_STA_ID_POS 0
+
+#define LMAC_STA_COLOR_SEED 0x7
+#define LMAC_STA_COLOR_POS 4
+
+struct iwm_lmac_power_report {
+ u8 pa_status;
+ u8 pa_integ_res_A[3];
+ u8 pa_integ_res_B[3];
+ u8 pa_integ_res_C[3];
+} __attribute__ ((packed));
+
+struct iwm_lmac_tx_resp {
+ u8 frame_cnt; /* 1-no aggregation, greater then 1 - aggregation */
+ u8 bt_kill_cnt;
+ __le16 retry_cnt;
+ __le32 initial_tx_rate;
+ __le16 wireless_media_time;
+ struct iwm_lmac_power_report power_report;
+ __le32 tfd_info;
+ __le16 seq_ctl;
+ __le16 byte_cnt;
+ u8 tlc_rate_info;
+ u8 ra_tid;
+ __le16 frame_ctl;
+ __le32 status;
+} __attribute__ ((packed));
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c
new file mode 100644
index 000000000000..6a2640f16b6d
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/main.c
@@ -0,0 +1,680 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/ieee80211.h>
+#include <linux/wireless.h>
+
+#include "iwm.h"
+#include "debug.h"
+#include "bus.h"
+#include "umac.h"
+#include "commands.h"
+#include "hal.h"
+#include "fw.h"
+#include "rx.h"
+
+static struct iwm_conf def_iwm_conf = {
+
+ .sdio_ior_timeout = 5000,
+ .init_calib_map = BIT(PHY_CALIBRATE_DC_CMD) |
+ BIT(PHY_CALIBRATE_LO_CMD) |
+ BIT(PHY_CALIBRATE_TX_IQ_CMD) |
+ BIT(PHY_CALIBRATE_RX_IQ_CMD),
+ .periodic_calib_map = BIT(PHY_CALIBRATE_DC_CMD) |
+ BIT(PHY_CALIBRATE_LO_CMD) |
+ BIT(PHY_CALIBRATE_TX_IQ_CMD) |
+ BIT(PHY_CALIBRATE_RX_IQ_CMD) |
+ BIT(SHILOH_PHY_CALIBRATE_BASE_BAND_CMD),
+ .reset_on_fatal_err = 1,
+ .auto_connect = 1,
+ .wimax_not_present = 0,
+ .enable_qos = 1,
+ .mode = UMAC_MODE_BSS,
+
+ /* UMAC configuration */
+ .power_index = 0,
+ .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
+ .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
+ .cts_to_self = 0,
+
+ .assoc_timeout = 2,
+ .roam_timeout = 10,
+ .wireless_mode = WIRELESS_MODE_11A | WIRELESS_MODE_11G,
+ .coexist_mode = COEX_MODE_CM,
+
+ /* IBSS */
+ .ibss_band = UMAC_BAND_2GHZ,
+ .ibss_channel = 1,
+
+ .mac_addr = {0x00, 0x02, 0xb3, 0x01, 0x02, 0x03},
+};
+
+static int modparam_reset;
+module_param_named(reset, modparam_reset, bool, 0644);
+MODULE_PARM_DESC(reset, "reset on firmware errors (default 0 [not reset])");
+
+int iwm_mode_to_nl80211_iftype(int mode)
+{
+ switch (mode) {
+ case UMAC_MODE_BSS:
+ return NL80211_IFTYPE_STATION;
+ case UMAC_MODE_IBSS:
+ return NL80211_IFTYPE_ADHOC;
+ default:
+ return NL80211_IFTYPE_UNSPECIFIED;
+ }
+
+ return 0;
+}
+
+static void iwm_statistics_request(struct work_struct *work)
+{
+ struct iwm_priv *iwm =
+ container_of(work, struct iwm_priv, stats_request.work);
+
+ iwm_send_umac_stats_req(iwm, 0);
+}
+
+static void iwm_reset_worker(struct work_struct *work)
+{
+ struct iwm_priv *iwm;
+ struct iwm_umac_profile *profile = NULL;
+ int uninitialized_var(ret), retry = 0;
+
+ iwm = container_of(work, struct iwm_priv, reset_worker);
+
+ if (iwm->umac_profile_active) {
+ profile = kmalloc(sizeof(struct iwm_umac_profile), GFP_KERNEL);
+ if (profile)
+ memcpy(profile, iwm->umac_profile, sizeof(*profile));
+ else
+ IWM_ERR(iwm, "Couldn't alloc memory for profile\n");
+ }
+
+ iwm_down(iwm);
+
+ while (retry++ < 3) {
+ ret = iwm_up(iwm);
+ if (!ret)
+ break;
+
+ schedule_timeout_uninterruptible(10 * HZ);
+ }
+
+ if (ret) {
+ IWM_WARN(iwm, "iwm_up() failed: %d\n", ret);
+
+ kfree(profile);
+ return;
+ }
+
+ if (profile) {
+ IWM_DBG_MLME(iwm, DBG, "Resend UMAC profile\n");
+ memcpy(iwm->umac_profile, profile, sizeof(*profile));
+ iwm_send_mlme_profile(iwm);
+ kfree(profile);
+ }
+}
+
+static void iwm_watchdog(unsigned long data)
+{
+ struct iwm_priv *iwm = (struct iwm_priv *)data;
+
+ IWM_WARN(iwm, "Watchdog expired: UMAC stalls!\n");
+
+ if (modparam_reset)
+ schedule_work(&iwm->reset_worker);
+}
+
+int iwm_priv_init(struct iwm_priv *iwm)
+{
+ int i;
+ char name[32];
+
+ iwm->status = 0;
+ INIT_LIST_HEAD(&iwm->pending_notif);
+ init_waitqueue_head(&iwm->notif_queue);
+ init_waitqueue_head(&iwm->nonwifi_queue);
+ init_waitqueue_head(&iwm->mlme_queue);
+ memcpy(&iwm->conf, &def_iwm_conf, sizeof(struct iwm_conf));
+ spin_lock_init(&iwm->tx_credit.lock);
+ INIT_LIST_HEAD(&iwm->wifi_pending_cmd);
+ INIT_LIST_HEAD(&iwm->nonwifi_pending_cmd);
+ iwm->wifi_seq_num = UMAC_WIFI_SEQ_NUM_BASE;
+ iwm->nonwifi_seq_num = UMAC_NONWIFI_SEQ_NUM_BASE;
+ spin_lock_init(&iwm->cmd_lock);
+ iwm->scan_id = 1;
+ INIT_DELAYED_WORK(&iwm->stats_request, iwm_statistics_request);
+ INIT_WORK(&iwm->reset_worker, iwm_reset_worker);
+ INIT_LIST_HEAD(&iwm->bss_list);
+
+ skb_queue_head_init(&iwm->rx_list);
+ INIT_LIST_HEAD(&iwm->rx_tickets);
+ for (i = 0; i < IWM_RX_ID_HASH; i++)
+ INIT_LIST_HEAD(&iwm->rx_packets[i]);
+
+ INIT_WORK(&iwm->rx_worker, iwm_rx_worker);
+
+ iwm->rx_wq = create_singlethread_workqueue(KBUILD_MODNAME "_rx");
+ if (!iwm->rx_wq)
+ return -EAGAIN;
+
+ for (i = 0; i < IWM_TX_QUEUES; i++) {
+ INIT_WORK(&iwm->txq[i].worker, iwm_tx_worker);
+ snprintf(name, 32, KBUILD_MODNAME "_tx_%d", i);
+ iwm->txq[i].id = i;
+ iwm->txq[i].wq = create_singlethread_workqueue(name);
+ if (!iwm->txq[i].wq)
+ return -EAGAIN;
+
+ skb_queue_head_init(&iwm->txq[i].queue);
+ }
+
+ for (i = 0; i < IWM_NUM_KEYS; i++)
+ memset(&iwm->keys[i], 0, sizeof(struct iwm_key));
+
+ iwm->default_key = NULL;
+
+ init_timer(&iwm->watchdog);
+ iwm->watchdog.function = iwm_watchdog;
+ iwm->watchdog.data = (unsigned long)iwm;
+
+ return 0;
+}
+
+/*
+ * We reset all the structures, and we reset the UMAC.
+ * After calling this routine, you're expected to reload
+ * the firmware.
+ */
+void iwm_reset(struct iwm_priv *iwm)
+{
+ struct iwm_notif *notif, *next;
+
+ if (test_bit(IWM_STATUS_READY, &iwm->status))
+ iwm_target_reset(iwm);
+
+ iwm->status = 0;
+ iwm->scan_id = 1;
+
+ list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) {
+ list_del(&notif->pending);
+ kfree(notif->buf);
+ kfree(notif);
+ }
+
+ iwm_cmd_flush(iwm);
+
+ flush_workqueue(iwm->rx_wq);
+
+ iwm_link_off(iwm);
+}
+
+/*
+ * Notification code:
+ *
+ * We're faced with the following issue: Any host command can
+ * have an answer or not, and if there's an answer to expect,
+ * it can be treated synchronously or asynchronously.
+ * To work around the synchronous answer case, we implemented
+ * our notification mechanism.
+ * When a code path needs to wait for a command response
+ * synchronously, it calls notif_handle(), which waits for the
+ * right notification to show up, and then process it. Before
+ * starting to wait, it registered as a waiter for this specific
+ * answer (by toggling a bit in on of the handler_map), so that
+ * the rx code knows that it needs to send a notification to the
+ * waiting processes. It does so by calling iwm_notif_send(),
+ * which adds the notification to the pending notifications list,
+ * and then wakes the waiting processes up.
+ */
+int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd,
+ u8 cmd_id, u8 source, u8 *buf, unsigned long buf_size)
+{
+ struct iwm_notif *notif;
+
+ notif = kzalloc(sizeof(struct iwm_notif), GFP_KERNEL);
+ if (!notif) {
+ IWM_ERR(iwm, "Couldn't alloc memory for notification\n");
+ return -ENOMEM;
+ }
+
+ INIT_LIST_HEAD(&notif->pending);
+ notif->cmd = cmd;
+ notif->cmd_id = cmd_id;
+ notif->src = source;
+ notif->buf = kzalloc(buf_size, GFP_KERNEL);
+ if (!notif->buf) {
+ IWM_ERR(iwm, "Couldn't alloc notification buffer\n");
+ kfree(notif);
+ return -ENOMEM;
+ }
+ notif->buf_size = buf_size;
+ memcpy(notif->buf, buf, buf_size);
+ list_add_tail(&notif->pending, &iwm->pending_notif);
+
+ wake_up_interruptible(&iwm->notif_queue);
+
+ return 0;
+}
+
+static struct iwm_notif *iwm_notif_find(struct iwm_priv *iwm, u32 cmd,
+ u8 source)
+{
+ struct iwm_notif *notif, *next;
+
+ list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) {
+ if ((notif->cmd_id == cmd) && (notif->src == source)) {
+ list_del(&notif->pending);
+ return notif;
+ }
+ }
+
+ return NULL;
+}
+
+static struct iwm_notif *iwm_notif_wait(struct iwm_priv *iwm, u32 cmd,
+ u8 source, long timeout)
+{
+ int ret;
+ struct iwm_notif *notif;
+ unsigned long *map = NULL;
+
+ switch (source) {
+ case IWM_SRC_LMAC:
+ map = &iwm->lmac_handler_map[0];
+ break;
+ case IWM_SRC_UMAC:
+ map = &iwm->umac_handler_map[0];
+ break;
+ case IWM_SRC_UDMA:
+ map = &iwm->udma_handler_map[0];
+ break;
+ }
+
+ set_bit(cmd, map);
+
+ ret = wait_event_interruptible_timeout(iwm->notif_queue,
+ ((notif = iwm_notif_find(iwm, cmd, source)) != NULL),
+ timeout);
+ clear_bit(cmd, map);
+
+ if (!ret)
+ return NULL;
+
+ return notif;
+}
+
+int iwm_notif_handle(struct iwm_priv *iwm, u32 cmd, u8 source, long timeout)
+{
+ int ret;
+ struct iwm_notif *notif;
+
+ notif = iwm_notif_wait(iwm, cmd, source, timeout);
+ if (!notif)
+ return -ETIME;
+
+ ret = iwm_rx_handle_resp(iwm, notif->buf, notif->buf_size, notif->cmd);
+ kfree(notif->buf);
+ kfree(notif);
+
+ return ret;
+}
+
+static int iwm_config_boot_params(struct iwm_priv *iwm)
+{
+ struct iwm_udma_nonwifi_cmd target_cmd;
+ int ret;
+
+ /* check Wimax is off and config debug monitor */
+ if (iwm->conf.wimax_not_present) {
+ u32 data1 = 0x1f;
+ u32 addr1 = 0x606BE258;
+
+ u32 data2_set = 0x0;
+ u32 data2_clr = 0x1;
+ u32 addr2 = 0x606BE100;
+
+ u32 data3 = 0x1;
+ u32 addr3 = 0x606BEC00;
+
+ target_cmd.resp = 0;
+ target_cmd.handle_by_hw = 0;
+ target_cmd.eop = 1;
+
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
+ target_cmd.addr = cpu_to_le32(addr1);
+ target_cmd.op1_sz = cpu_to_le32(sizeof(u32));
+ target_cmd.op2 = 0;
+
+ ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data1);
+ if (ret < 0) {
+ IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
+ return ret;
+ }
+
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_READ_MODIFY_WRITE;
+ target_cmd.addr = cpu_to_le32(addr2);
+ target_cmd.op1_sz = cpu_to_le32(data2_set);
+ target_cmd.op2 = cpu_to_le32(data2_clr);
+
+ ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data1);
+ if (ret < 0) {
+ IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
+ return ret;
+ }
+
+ target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
+ target_cmd.addr = cpu_to_le32(addr3);
+ target_cmd.op1_sz = cpu_to_le32(sizeof(u32));
+ target_cmd.op2 = 0;
+
+ ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data3);
+ if (ret < 0) {
+ IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+void iwm_init_default_profile(struct iwm_priv *iwm,
+ struct iwm_umac_profile *profile)
+{
+ memset(profile, 0, sizeof(struct iwm_umac_profile));
+
+ profile->sec.auth_type = UMAC_AUTH_TYPE_OPEN;
+ profile->sec.flags = UMAC_SEC_FLG_LEGACY_PROFILE;
+ profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_NONE;
+ profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_NONE;
+
+ if (iwm->conf.enable_qos)
+ profile->flags |= cpu_to_le16(UMAC_PROFILE_QOS_ALLOWED);
+
+ profile->wireless_mode = iwm->conf.wireless_mode;
+ profile->mode = cpu_to_le32(iwm->conf.mode);
+
+ profile->ibss.atim = 0;
+ profile->ibss.beacon_interval = 100;
+ profile->ibss.join_only = 0;
+ profile->ibss.band = iwm->conf.ibss_band;
+ profile->ibss.channel = iwm->conf.ibss_channel;
+}
+
+void iwm_link_on(struct iwm_priv *iwm)
+{
+ netif_carrier_on(iwm_to_ndev(iwm));
+ netif_tx_wake_all_queues(iwm_to_ndev(iwm));
+
+ iwm_send_umac_stats_req(iwm, 0);
+}
+
+void iwm_link_off(struct iwm_priv *iwm)
+{
+ struct iw_statistics *wstats = &iwm->wstats;
+ int i;
+
+ netif_tx_stop_all_queues(iwm_to_ndev(iwm));
+ netif_carrier_off(iwm_to_ndev(iwm));
+
+ for (i = 0; i < IWM_TX_QUEUES; i++) {
+ skb_queue_purge(&iwm->txq[i].queue);
+
+ iwm->txq[i].concat_count = 0;
+ iwm->txq[i].concat_ptr = iwm->txq[i].concat_buf;
+
+ flush_workqueue(iwm->txq[i].wq);
+ }
+
+ iwm_rx_free(iwm);
+
+ cancel_delayed_work(&iwm->stats_request);
+ memset(wstats, 0, sizeof(struct iw_statistics));
+ wstats->qual.updated = IW_QUAL_ALL_INVALID;
+
+ del_timer_sync(&iwm->watchdog);
+}
+
+static void iwm_bss_list_clean(struct iwm_priv *iwm)
+{
+ struct iwm_bss_info *bss, *next;
+
+ list_for_each_entry_safe(bss, next, &iwm->bss_list, node) {
+ list_del(&bss->node);
+ kfree(bss->bss);
+ kfree(bss);
+ }
+}
+
+static int iwm_channels_init(struct iwm_priv *iwm)
+{
+ int ret;
+
+#ifdef CONFIG_IWM_B0_HW_SUPPORT
+ if (iwm->conf.hw_b0) {
+ IWM_INFO(iwm, "Workaround EEPROM channels for B0 hardware\n");
+ return 0;
+ }
+#endif
+
+ ret = iwm_send_umac_channel_list(iwm);
+ if (ret) {
+ IWM_ERR(iwm, "Send channel list failed\n");
+ return ret;
+ }
+
+ ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST,
+ IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Didn't get a channel list notification\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+int iwm_up(struct iwm_priv *iwm)
+{
+ int ret;
+ struct iwm_notif *notif_reboot, *notif_ack = NULL;
+
+ ret = iwm_bus_enable(iwm);
+ if (ret) {
+ IWM_ERR(iwm, "Couldn't enable function\n");
+ return ret;
+ }
+
+ iwm_rx_setup_handlers(iwm);
+
+ /* Wait for initial BARKER_REBOOT from hardware */
+ notif_reboot = iwm_notif_wait(iwm, IWM_BARKER_REBOOT_NOTIFICATION,
+ IWM_SRC_UDMA, 2 * HZ);
+ if (!notif_reboot) {
+ IWM_ERR(iwm, "Wait for REBOOT_BARKER timeout\n");
+ goto err_disable;
+ }
+
+ /* We send the barker back */
+ ret = iwm_bus_send_chunk(iwm, notif_reboot->buf, 16);
+ if (ret) {
+ IWM_ERR(iwm, "REBOOT barker response failed\n");
+ kfree(notif_reboot);
+ goto err_disable;
+ }
+
+ kfree(notif_reboot->buf);
+ kfree(notif_reboot);
+
+ /* Wait for ACK_BARKER from hardware */
+ notif_ack = iwm_notif_wait(iwm, IWM_ACK_BARKER_NOTIFICATION,
+ IWM_SRC_UDMA, 2 * HZ);
+ if (!notif_ack) {
+ IWM_ERR(iwm, "Wait for ACK_BARKER timeout\n");
+ goto err_disable;
+ }
+
+ kfree(notif_ack->buf);
+ kfree(notif_ack);
+
+ /* We start to config static boot parameters */
+ ret = iwm_config_boot_params(iwm);
+ if (ret) {
+ IWM_ERR(iwm, "Config boot parameters failed\n");
+ goto err_disable;
+ }
+
+ ret = iwm_read_mac(iwm, iwm_to_ndev(iwm)->dev_addr);
+ if (ret) {
+ IWM_ERR(iwm, "MAC reading failed\n");
+ goto err_disable;
+ }
+
+ /* We can load the FWs */
+ ret = iwm_load_fw(iwm);
+ if (ret) {
+ IWM_ERR(iwm, "FW loading failed\n");
+ goto err_disable;
+ }
+
+ /* We configure the UMAC and enable the wifi module */
+ ret = iwm_send_umac_config(iwm,
+ cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_CORE_EN) |
+ cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_LINK_EN) |
+ cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_MLME_EN));
+ if (ret) {
+ IWM_ERR(iwm, "UMAC config failed\n");
+ goto err_fw;
+ }
+
+ ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS,
+ IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Didn't get a wifi core status notification\n");
+ goto err_fw;
+ }
+
+ if (iwm->core_enabled != (UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN |
+ UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN)) {
+ IWM_DBG_BOOT(iwm, DBG, "Not all cores enabled:0x%x\n",
+ iwm->core_enabled);
+ ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS,
+ IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
+ if (ret) {
+ IWM_ERR(iwm, "Didn't get a core status notification\n");
+ goto err_fw;
+ }
+
+ if (iwm->core_enabled != (UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN |
+ UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN)) {
+ IWM_ERR(iwm, "Not all cores enabled: 0x%x\n",
+ iwm->core_enabled);
+ goto err_fw;
+ } else {
+ IWM_INFO(iwm, "All cores enabled\n");
+ }
+ }
+
+ iwm->umac_profile = kmalloc(sizeof(struct iwm_umac_profile),
+ GFP_KERNEL);
+ if (!iwm->umac_profile) {
+ IWM_ERR(iwm, "Couldn't alloc memory for profile\n");
+ goto err_fw;
+ }
+
+ iwm_init_default_profile(iwm, iwm->umac_profile);
+
+ ret = iwm_channels_init(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't init channels\n");
+ goto err_profile;
+ }
+
+ /* Set the READY bit to indicate interface is brought up successfully */
+ set_bit(IWM_STATUS_READY, &iwm->status);
+
+ return 0;
+
+ err_profile:
+ kfree(iwm->umac_profile);
+ iwm->umac_profile = NULL;
+
+ err_fw:
+ iwm_eeprom_exit(iwm);
+
+ err_disable:
+ ret = iwm_bus_disable(iwm);
+ if (ret < 0)
+ IWM_ERR(iwm, "Couldn't disable function\n");
+
+ return -EIO;
+}
+
+int iwm_down(struct iwm_priv *iwm)
+{
+ int ret;
+
+ /* The interface is already down */
+ if (!test_bit(IWM_STATUS_READY, &iwm->status))
+ return 0;
+
+ if (iwm->scan_request) {
+ cfg80211_scan_done(iwm->scan_request, true);
+ iwm->scan_request = NULL;
+ }
+
+ clear_bit(IWM_STATUS_READY, &iwm->status);
+
+ iwm_eeprom_exit(iwm);
+ kfree(iwm->umac_profile);
+ iwm->umac_profile = NULL;
+ iwm_bss_list_clean(iwm);
+
+ iwm->default_key = NULL;
+ iwm->core_enabled = 0;
+
+ ret = iwm_bus_disable(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't disable function\n");
+ return ret;
+ }
+
+ return 0;
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
new file mode 100644
index 000000000000..eec7201e91a8
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -0,0 +1,172 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+/*
+ * This is the netdev related hooks for iwm.
+ *
+ * Some interesting code paths:
+ *
+ * iwm_open() (Called at netdev interface bringup time)
+ * -> iwm_up() (main.c)
+ * -> iwm_bus_enable()
+ * -> if_sdio_enable() (In case of an SDIO bus)
+ * -> sdio_enable_func()
+ * -> iwm_notif_wait(BARKER_REBOOT) (wait for reboot barker)
+ * -> iwm_notif_wait(ACK_BARKER) (wait for ACK barker)
+ * -> iwm_load_fw() (fw.c)
+ * -> iwm_load_umac()
+ * -> iwm_load_lmac() (Calibration LMAC)
+ * -> iwm_load_lmac() (Operational LMAC)
+ * -> iwm_send_umac_config()
+ *
+ * iwm_stop() (Called at netdev interface bringdown time)
+ * -> iwm_down()
+ * -> iwm_bus_disable()
+ * -> if_sdio_disable() (In case of an SDIO bus)
+ * -> sdio_disable_func()
+ */
+#include <linux/netdevice.h>
+
+#include "iwm.h"
+#include "cfg80211.h"
+#include "debug.h"
+
+static int iwm_open(struct net_device *ndev)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(ndev);
+ int ret = 0;
+
+ if (!test_bit(IWM_RADIO_RFKILL_SW, &iwm->radio))
+ ret = iwm_up(iwm);
+
+ return ret;
+}
+
+static int iwm_stop(struct net_device *ndev)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(ndev);
+ int ret = 0;
+
+ if (!test_bit(IWM_RADIO_RFKILL_SW, &iwm->radio))
+ ret = iwm_down(iwm);
+
+ return ret;
+}
+
+/*
+ * iwm AC to queue mapping
+ *
+ * AC_VO -> queue 3
+ * AC_VI -> queue 2
+ * AC_BE -> queue 1
+ * AC_BK -> queue 0
+ */
+static const u16 iwm_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
+
+static u16 iwm_select_queue(struct net_device *dev, struct sk_buff *skb)
+{
+ skb->priority = cfg80211_classify8021d(skb);
+
+ return iwm_1d_to_queue[skb->priority];
+}
+
+static const struct net_device_ops iwm_netdev_ops = {
+ .ndo_open = iwm_open,
+ .ndo_stop = iwm_stop,
+ .ndo_start_xmit = iwm_xmit_frame,
+ .ndo_select_queue = iwm_select_queue,
+};
+
+void *iwm_if_alloc(int sizeof_bus, struct device *dev,
+ struct iwm_if_ops *if_ops)
+{
+ struct net_device *ndev;
+ struct wireless_dev *wdev;
+ struct iwm_priv *iwm;
+ int ret = 0;
+
+ wdev = iwm_wdev_alloc(sizeof_bus, dev);
+ if (!wdev) {
+ dev_err(dev, "no memory for wireless device instance\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ iwm = wdev_to_iwm(wdev);
+ iwm->bus_ops = if_ops;
+ iwm->wdev = wdev;
+ iwm_priv_init(iwm);
+ wdev->iftype = iwm_mode_to_nl80211_iftype(iwm->conf.mode);
+
+ ndev = alloc_netdev_mq(0, "wlan%d", ether_setup,
+ IWM_TX_QUEUES);
+ if (!ndev) {
+ dev_err(dev, "no memory for network device instance\n");
+ goto out_wdev;
+ }
+
+ ndev->netdev_ops = &iwm_netdev_ops;
+ ndev->wireless_handlers = &iwm_iw_handler_def;
+ ndev->ieee80211_ptr = wdev;
+ SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
+ ret = register_netdev(ndev);
+ if (ret < 0) {
+ dev_err(dev, "Failed to register netdev: %d\n", ret);
+ goto out_ndev;
+ }
+
+ wdev->netdev = ndev;
+
+ ret = iwm_rfkill_init(iwm);
+ if (ret) {
+ dev_err(dev, "Failed to init rfkill\n");
+ goto out_rfkill;
+ }
+
+ return iwm;
+
+ out_rfkill:
+ unregister_netdev(ndev);
+
+ out_ndev:
+ free_netdev(ndev);
+
+ out_wdev:
+ iwm_wdev_free(iwm);
+ return ERR_PTR(ret);
+}
+
+void iwm_if_free(struct iwm_priv *iwm)
+{
+ int i;
+
+ if (!iwm_to_ndev(iwm))
+ return;
+
+ iwm_rfkill_exit(iwm);
+ unregister_netdev(iwm_to_ndev(iwm));
+ free_netdev(iwm_to_ndev(iwm));
+ iwm_wdev_free(iwm);
+ destroy_workqueue(iwm->rx_wq);
+ for (i = 0; i < IWM_TX_QUEUES; i++)
+ destroy_workqueue(iwm->txq[i].wq);
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/rfkill.c b/drivers/net/wireless/iwmc3200wifi/rfkill.c
new file mode 100644
index 000000000000..4ca8b495f82d
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/rfkill.c
@@ -0,0 +1,88 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#include <linux/rfkill.h>
+
+#include "iwm.h"
+
+static int iwm_rfkill_soft_toggle(void *data, enum rfkill_state state)
+{
+ struct iwm_priv *iwm = data;
+
+ switch (state) {
+ case RFKILL_STATE_UNBLOCKED:
+ if (test_bit(IWM_RADIO_RFKILL_HW, &iwm->radio))
+ return -EBUSY;
+
+ if (test_and_clear_bit(IWM_RADIO_RFKILL_SW, &iwm->radio) &&
+ (iwm_to_ndev(iwm)->flags & IFF_UP))
+ iwm_up(iwm);
+
+ break;
+ case RFKILL_STATE_SOFT_BLOCKED:
+ if (!test_and_set_bit(IWM_RADIO_RFKILL_SW, &iwm->radio))
+ iwm_down(iwm);
+
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+int iwm_rfkill_init(struct iwm_priv *iwm)
+{
+ int ret;
+
+ iwm->rfkill = rfkill_allocate(iwm_to_dev(iwm), RFKILL_TYPE_WLAN);
+ if (!iwm->rfkill) {
+ IWM_ERR(iwm, "Unable to allocate rfkill device\n");
+ return -ENOMEM;
+ }
+
+ iwm->rfkill->name = KBUILD_MODNAME;
+ iwm->rfkill->data = iwm;
+ iwm->rfkill->state = RFKILL_STATE_UNBLOCKED;
+ iwm->rfkill->toggle_radio = iwm_rfkill_soft_toggle;
+
+ ret = rfkill_register(iwm->rfkill);
+ if (ret) {
+ IWM_ERR(iwm, "Failed to register rfkill device\n");
+ goto fail;
+ }
+
+ return 0;
+ fail:
+ rfkill_free(iwm->rfkill);
+ return ret;
+}
+
+void iwm_rfkill_exit(struct iwm_priv *iwm)
+{
+ if (iwm->rfkill)
+ rfkill_unregister(iwm->rfkill);
+
+ rfkill_free(iwm->rfkill);
+ iwm->rfkill = NULL;
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
new file mode 100644
index 000000000000..d73cf96c6dc6
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -0,0 +1,1431 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/wireless.h>
+#include <linux/ieee80211.h>
+#include <linux/if_arp.h>
+#include <linux/list.h>
+#include <net/iw_handler.h>
+
+#include "iwm.h"
+#include "debug.h"
+#include "hal.h"
+#include "umac.h"
+#include "lmac.h"
+#include "commands.h"
+#include "rx.h"
+#include "cfg80211.h"
+#include "eeprom.h"
+
+static int iwm_rx_check_udma_hdr(struct iwm_udma_in_hdr *hdr)
+{
+ if ((le32_to_cpu(hdr->cmd) == UMAC_PAD_TERMINAL) ||
+ (le32_to_cpu(hdr->size) == UMAC_PAD_TERMINAL))
+ return -EINVAL;
+
+ return 0;
+}
+
+static inline int iwm_rx_resp_size(struct iwm_udma_in_hdr *hdr)
+{
+ return ALIGN(le32_to_cpu(hdr->size) + sizeof(struct iwm_udma_in_hdr),
+ 16);
+}
+
+/*
+ * Notification handlers:
+ *
+ * For every possible notification we can receive from the
+ * target, we have a handler.
+ * When we get a target notification, and there is no one
+ * waiting for it, it's just processed through the rx code
+ * path:
+ *
+ * iwm_rx_handle()
+ * -> iwm_rx_handle_umac()
+ * -> iwm_rx_handle_wifi()
+ * -> iwm_rx_handle_resp()
+ * -> iwm_ntf_*()
+ *
+ * OR
+ *
+ * -> iwm_rx_handle_non_wifi()
+ *
+ * If there are processes waiting for this notification, then
+ * iwm_rx_handle_wifi() just wakes those processes up and they
+ * grab the pending notification.
+ */
+static int iwm_ntf_error(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_error *error;
+ struct iwm_fw_error_hdr *fw_err;
+
+ error = (struct iwm_umac_notif_error *)buf;
+ fw_err = &error->err;
+
+
+ IWM_ERR(iwm, "%cMAC FW ERROR:\n",
+ (le32_to_cpu(fw_err->category) == UMAC_SYS_ERR_CAT_LMAC) ? 'L' : 'U');
+ IWM_ERR(iwm, "\tCategory: %d\n", le32_to_cpu(fw_err->category));
+ IWM_ERR(iwm, "\tStatus: 0x%x\n", le32_to_cpu(fw_err->status));
+ IWM_ERR(iwm, "\tPC: 0x%x\n", le32_to_cpu(fw_err->pc));
+ IWM_ERR(iwm, "\tblink1: %d\n", le32_to_cpu(fw_err->blink1));
+ IWM_ERR(iwm, "\tblink2: %d\n", le32_to_cpu(fw_err->blink2));
+ IWM_ERR(iwm, "\tilink1: %d\n", le32_to_cpu(fw_err->ilink1));
+ IWM_ERR(iwm, "\tilink2: %d\n", le32_to_cpu(fw_err->ilink2));
+ IWM_ERR(iwm, "\tData1: 0x%x\n", le32_to_cpu(fw_err->data1));
+ IWM_ERR(iwm, "\tData2: 0x%x\n", le32_to_cpu(fw_err->data2));
+ IWM_ERR(iwm, "\tLine number: %d\n", le32_to_cpu(fw_err->line_num));
+ IWM_ERR(iwm, "\tUMAC status: 0x%x\n", le32_to_cpu(fw_err->umac_status));
+ IWM_ERR(iwm, "\tLMAC status: 0x%x\n", le32_to_cpu(fw_err->lmac_status));
+ IWM_ERR(iwm, "\tSDIO status: 0x%x\n", le32_to_cpu(fw_err->sdio_status));
+
+ return 0;
+}
+
+static int iwm_ntf_umac_alive(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_alive *alive_resp =
+ (struct iwm_umac_notif_alive *)(buf);
+ u16 status = le16_to_cpu(alive_resp->status);
+
+ if (status == UMAC_NTFY_ALIVE_STATUS_ERR) {
+ IWM_ERR(iwm, "Receive error UMAC_ALIVE\n");
+ return -EIO;
+ }
+
+ iwm_tx_credit_init_pools(iwm, alive_resp);
+
+ return 0;
+}
+
+static int iwm_ntf_init_complete(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_init_complete *init_complete =
+ (struct iwm_umac_notif_init_complete *)(buf);
+ u16 status = le16_to_cpu(init_complete->status);
+
+ if (status == UMAC_NTFY_INIT_COMPLETE_STATUS_ERR) {
+ IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is on (radio off)\n");
+ set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
+ } else {
+ IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is off (radio on)\n");
+ clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
+ }
+
+ return 0;
+}
+
+static int iwm_ntf_tx_credit_update(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ int pool_nr, total_freed_pages;
+ unsigned long pool_map;
+ int i, id;
+ struct iwm_umac_notif_page_dealloc *dealloc =
+ (struct iwm_umac_notif_page_dealloc *)buf;
+
+ pool_nr = GET_VAL32(dealloc->changes, UMAC_DEALLOC_NTFY_CHANGES_CNT);
+ pool_map = GET_VAL32(dealloc->changes, UMAC_DEALLOC_NTFY_CHANGES_MSK);
+
+ IWM_DBG_TX(iwm, DBG, "UMAC dealloc notification: pool nr %d, "
+ "update map 0x%lx\n", pool_nr, pool_map);
+
+ spin_lock(&iwm->tx_credit.lock);
+
+ for (i = 0; i < pool_nr; i++) {
+ id = GET_VAL32(dealloc->grp_info[i],
+ UMAC_DEALLOC_NTFY_GROUP_NUM);
+ if (test_bit(id, &pool_map)) {
+ total_freed_pages = GET_VAL32(dealloc->grp_info[i],
+ UMAC_DEALLOC_NTFY_PAGE_CNT);
+ iwm_tx_credit_inc(iwm, id, total_freed_pages);
+ }
+ }
+
+ spin_unlock(&iwm->tx_credit.lock);
+
+ return 0;
+}
+
+static int iwm_ntf_umac_reset(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ IWM_DBG_NTF(iwm, DBG, "UMAC RESET done\n");
+
+ return 0;
+}
+
+static int iwm_ntf_lmac_version(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ IWM_DBG_NTF(iwm, INFO, "LMAC Version: %x.%x\n", buf[9], buf[8]);
+
+ return 0;
+}
+
+static int iwm_ntf_tx(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_lmac_tx_resp *tx_resp;
+ struct iwm_umac_wifi_in_hdr *hdr;
+
+ tx_resp = (struct iwm_lmac_tx_resp *)
+ (buf + sizeof(struct iwm_umac_wifi_in_hdr));
+ hdr = (struct iwm_umac_wifi_in_hdr *)buf;
+
+ IWM_DBG_NTF(iwm, DBG, "REPLY_TX, buf size: %lu\n", buf_size);
+
+ IWM_DBG_NTF(iwm, DBG, "Seqnum: %d\n",
+ le16_to_cpu(hdr->sw_hdr.cmd.seq_num));
+ IWM_DBG_NTF(iwm, DBG, "\tFrame cnt: %d\n", tx_resp->frame_cnt);
+ IWM_DBG_NTF(iwm, DBG, "\tRetry cnt: %d\n",
+ le16_to_cpu(tx_resp->retry_cnt));
+ IWM_DBG_NTF(iwm, DBG, "\tSeq ctl: %d\n", le16_to_cpu(tx_resp->seq_ctl));
+ IWM_DBG_NTF(iwm, DBG, "\tByte cnt: %d\n",
+ le16_to_cpu(tx_resp->byte_cnt));
+ IWM_DBG_NTF(iwm, DBG, "\tStatus: 0x%x\n", le32_to_cpu(tx_resp->status));
+
+ return 0;
+}
+
+
+static int iwm_ntf_calib_res(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ u8 opcode;
+ u8 *calib_buf;
+ struct iwm_lmac_calib_hdr *hdr = (struct iwm_lmac_calib_hdr *)
+ (buf + sizeof(struct iwm_umac_wifi_in_hdr));
+
+ opcode = hdr->opcode;
+
+ BUG_ON(opcode >= CALIBRATION_CMD_NUM ||
+ opcode < PHY_CALIBRATE_OPCODES_NUM);
+
+ IWM_DBG_NTF(iwm, DBG, "Store calibration result for opcode: %d\n",
+ opcode);
+
+ buf_size -= sizeof(struct iwm_umac_wifi_in_hdr);
+ calib_buf = iwm->calib_res[opcode].buf;
+
+ if (!calib_buf || (iwm->calib_res[opcode].size < buf_size)) {
+ kfree(calib_buf);
+ calib_buf = kzalloc(buf_size, GFP_KERNEL);
+ if (!calib_buf) {
+ IWM_ERR(iwm, "Memory allocation failed: calib_res\n");
+ return -ENOMEM;
+ }
+ iwm->calib_res[opcode].buf = calib_buf;
+ iwm->calib_res[opcode].size = buf_size;
+ }
+
+ memcpy(calib_buf, hdr, buf_size);
+ set_bit(opcode - PHY_CALIBRATE_OPCODES_NUM, &iwm->calib_done_map);
+
+ return 0;
+}
+
+static int iwm_ntf_calib_complete(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ IWM_DBG_NTF(iwm, DBG, "Calibration completed\n");
+
+ return 0;
+}
+
+static int iwm_ntf_calib_cfg(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_lmac_cal_cfg_resp *cal_resp;
+
+ cal_resp = (struct iwm_lmac_cal_cfg_resp *)
+ (buf + sizeof(struct iwm_umac_wifi_in_hdr));
+
+ IWM_DBG_NTF(iwm, DBG, "Calibration CFG command status: %d\n",
+ le32_to_cpu(cal_resp->status));
+
+ return 0;
+}
+
+static int iwm_ntf_wifi_status(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_wifi_status *status =
+ (struct iwm_umac_notif_wifi_status *)buf;
+
+ iwm->core_enabled |= le16_to_cpu(status->status);
+
+ return 0;
+}
+
+static struct iwm_rx_ticket_node *
+iwm_rx_ticket_node_alloc(struct iwm_priv *iwm, struct iwm_rx_ticket *ticket)
+{
+ struct iwm_rx_ticket_node *ticket_node;
+
+ ticket_node = kzalloc(sizeof(struct iwm_rx_ticket_node), GFP_KERNEL);
+ if (!ticket_node) {
+ IWM_ERR(iwm, "Couldn't allocate ticket node\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ ticket_node->ticket = kzalloc(sizeof(struct iwm_rx_ticket), GFP_KERNEL);
+ if (!ticket_node->ticket) {
+ IWM_ERR(iwm, "Couldn't allocate RX ticket\n");
+ kfree(ticket_node);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ memcpy(ticket_node->ticket, ticket, sizeof(struct iwm_rx_ticket));
+ INIT_LIST_HEAD(&ticket_node->node);
+
+ return ticket_node;
+}
+
+static void iwm_rx_ticket_node_free(struct iwm_rx_ticket_node *ticket_node)
+{
+ kfree(ticket_node->ticket);
+ kfree(ticket_node);
+}
+
+static struct iwm_rx_packet *iwm_rx_packet_get(struct iwm_priv *iwm, u16 id)
+{
+ u8 id_hash = IWM_RX_ID_GET_HASH(id);
+ struct list_head *packet_list;
+ struct iwm_rx_packet *packet, *next;
+
+ packet_list = &iwm->rx_packets[id_hash];
+
+ list_for_each_entry_safe(packet, next, packet_list, node)
+ if (packet->id == id)
+ return packet;
+
+ return NULL;
+}
+
+static struct iwm_rx_packet *iwm_rx_packet_alloc(struct iwm_priv *iwm, u8 *buf,
+ u32 size, u16 id)
+{
+ struct iwm_rx_packet *packet;
+
+ packet = kzalloc(sizeof(struct iwm_rx_packet), GFP_KERNEL);
+ if (!packet) {
+ IWM_ERR(iwm, "Couldn't allocate packet\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ packet->skb = dev_alloc_skb(size);
+ if (!packet->skb) {
+ IWM_ERR(iwm, "Couldn't allocate packet SKB\n");
+ kfree(packet);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ packet->pkt_size = size;
+
+ skb_put(packet->skb, size);
+ memcpy(packet->skb->data, buf, size);
+ INIT_LIST_HEAD(&packet->node);
+ packet->id = id;
+
+ return packet;
+}
+
+void iwm_rx_free(struct iwm_priv *iwm)
+{
+ struct iwm_rx_ticket_node *ticket, *nt;
+ struct iwm_rx_packet *packet, *np;
+ int i;
+
+ list_for_each_entry_safe(ticket, nt, &iwm->rx_tickets, node) {
+ list_del(&ticket->node);
+ iwm_rx_ticket_node_free(ticket);
+ }
+
+ for (i = 0; i < IWM_RX_ID_HASH; i++) {
+ list_for_each_entry_safe(packet, np, &iwm->rx_packets[i],
+ node) {
+ list_del(&packet->node);
+ kfree_skb(packet->skb);
+ kfree(packet);
+ }
+ }
+}
+
+static int iwm_ntf_rx_ticket(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_rx_ticket *ntf_rx_ticket =
+ (struct iwm_umac_notif_rx_ticket *)buf;
+ struct iwm_rx_ticket *ticket =
+ (struct iwm_rx_ticket *)ntf_rx_ticket->tickets;
+ int i, schedule_rx = 0;
+
+ for (i = 0; i < ntf_rx_ticket->num_tickets; i++) {
+ struct iwm_rx_ticket_node *ticket_node;
+
+ switch (le16_to_cpu(ticket->action)) {
+ case IWM_RX_TICKET_RELEASE:
+ case IWM_RX_TICKET_DROP:
+ /* We can push the packet to the stack */
+ ticket_node = iwm_rx_ticket_node_alloc(iwm, ticket);
+ if (IS_ERR(ticket_node))
+ return PTR_ERR(ticket_node);
+
+ IWM_DBG_NTF(iwm, DBG, "TICKET RELEASE(%d)\n",
+ ticket->id);
+ list_add_tail(&ticket_node->node, &iwm->rx_tickets);
+
+ /*
+ * We received an Rx ticket, most likely there's
+ * a packet pending for it, it's not worth going
+ * through the packet hash list to double check.
+ * Let's just fire the rx worker..
+ */
+ schedule_rx = 1;
+
+ break;
+
+ default:
+ IWM_ERR(iwm, "Invalid RX ticket action: 0x%x\n",
+ ticket->action);
+ }
+
+ ticket++;
+ }
+
+ if (schedule_rx)
+ queue_work(iwm->rx_wq, &iwm->rx_worker);
+
+ return 0;
+}
+
+static int iwm_ntf_rx_packet(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_wifi_in_hdr *wifi_hdr;
+ struct iwm_rx_packet *packet;
+ u16 id, buf_offset;
+ u32 packet_size;
+
+ IWM_DBG_NTF(iwm, DBG, "\n");
+
+ wifi_hdr = (struct iwm_umac_wifi_in_hdr *)buf;
+ id = le16_to_cpu(wifi_hdr->sw_hdr.cmd.seq_num);
+ buf_offset = sizeof(struct iwm_umac_wifi_in_hdr);
+ packet_size = buf_size - sizeof(struct iwm_umac_wifi_in_hdr);
+
+ IWM_DBG_NTF(iwm, DBG, "CMD:0x%x, seqnum: %d, packet size: %d\n",
+ wifi_hdr->sw_hdr.cmd.cmd, id, packet_size);
+ IWM_DBG_RX(iwm, DBG, "Packet id: %d\n", id);
+ IWM_HEXDUMP(iwm, DBG, RX, "PACKET: ", buf + buf_offset, packet_size);
+
+ packet = iwm_rx_packet_alloc(iwm, buf + buf_offset, packet_size, id);
+ if (IS_ERR(packet))
+ return PTR_ERR(packet);
+
+ list_add_tail(&packet->node, &iwm->rx_packets[IWM_RX_ID_GET_HASH(id)]);
+
+ /* We might (unlikely) have received the packet _after_ the ticket */
+ queue_work(iwm->rx_wq, &iwm->rx_worker);
+
+ return 0;
+}
+
+/* MLME handlers */
+static int iwm_mlme_assoc_start(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_assoc_start *start;
+
+ start = (struct iwm_umac_notif_assoc_start *)buf;
+
+ set_bit(IWM_STATUS_ASSOCIATING, &iwm->status);
+
+ IWM_DBG_MLME(iwm, INFO, "Association with %pM Started, reason: %d\n",
+ start->bssid, le32_to_cpu(start->roam_reason));
+
+ wake_up_interruptible(&iwm->mlme_queue);
+
+ return 0;
+}
+
+static int iwm_mlme_assoc_complete(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_assoc_complete *complete =
+ (struct iwm_umac_notif_assoc_complete *)buf;
+ union iwreq_data wrqu;
+
+ IWM_DBG_MLME(iwm, INFO, "Association with %pM completed, status: %d\n",
+ complete->bssid, complete->status);
+
+ memset(&wrqu, 0, sizeof(wrqu));
+
+ clear_bit(IWM_STATUS_ASSOCIATING, &iwm->status);
+
+ switch (le32_to_cpu(complete->status)) {
+ case UMAC_ASSOC_COMPLETE_SUCCESS:
+ set_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
+ memcpy(iwm->bssid, complete->bssid, ETH_ALEN);
+ iwm->channel = complete->channel;
+
+ iwm_link_on(iwm);
+
+ memcpy(wrqu.ap_addr.sa_data, complete->bssid, ETH_ALEN);
+ break;
+ case UMAC_ASSOC_COMPLETE_FAILURE:
+ clear_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
+ memset(iwm->bssid, 0, ETH_ALEN);
+ iwm->channel = 0;
+
+ iwm_link_off(iwm);
+ default:
+ break;
+ }
+
+ if (iwm->conf.mode == UMAC_MODE_IBSS) {
+ cfg80211_ibss_joined(iwm_to_ndev(iwm), iwm->bssid, GFP_KERNEL);
+ return 0;
+ }
+
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ wireless_send_event(iwm_to_ndev(iwm), SIOCGIWAP, &wrqu, NULL);
+
+ return 0;
+}
+
+static int iwm_mlme_profile_invalidate(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_profile_invalidate *invalid;
+
+ invalid = (struct iwm_umac_notif_profile_invalidate *)buf;
+
+ IWM_DBG_MLME(iwm, INFO, "Profile Invalidated. Reason: %d\n",
+ le32_to_cpu(invalid->reason));
+
+ clear_bit(IWM_STATUS_ASSOCIATING, &iwm->status);
+ clear_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
+
+ iwm->umac_profile_active = 0;
+ memset(iwm->bssid, 0, ETH_ALEN);
+ iwm->channel = 0;
+
+ iwm_link_off(iwm);
+
+ wake_up_interruptible(&iwm->mlme_queue);
+
+ return 0;
+}
+
+static int iwm_mlme_scan_complete(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ int ret;
+ struct iwm_umac_notif_scan_complete *scan_complete =
+ (struct iwm_umac_notif_scan_complete *)buf;
+ u32 result = le32_to_cpu(scan_complete->result);
+
+ IWM_DBG_MLME(iwm, INFO, "type:0x%x result:0x%x seq:%d\n",
+ le32_to_cpu(scan_complete->type),
+ le32_to_cpu(scan_complete->result),
+ scan_complete->seq_num);
+
+ if (!test_and_clear_bit(IWM_STATUS_SCANNING, &iwm->status)) {
+ IWM_ERR(iwm, "Scan complete while device not scanning\n");
+ return -EIO;
+ }
+ if (!iwm->scan_request)
+ return 0;
+
+ ret = iwm_cfg80211_inform_bss(iwm);
+
+ cfg80211_scan_done(iwm->scan_request,
+ (result & UMAC_SCAN_RESULT_ABORTED) ? 1 : !!ret);
+ iwm->scan_request = NULL;
+
+ return ret;
+}
+
+static int iwm_mlme_update_sta_table(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_sta_info *umac_sta =
+ (struct iwm_umac_notif_sta_info *)buf;
+ struct iwm_sta_info *sta;
+ int i;
+
+ switch (le32_to_cpu(umac_sta->opcode)) {
+ case UMAC_OPCODE_ADD_MODIFY:
+ sta = &iwm->sta_table[GET_VAL8(umac_sta->sta_id, LMAC_STA_ID)];
+
+ IWM_DBG_MLME(iwm, INFO, "%s STA: ID = %d, Color = %d, "
+ "addr = %pM, qos = %d\n",
+ sta->valid ? "Modify" : "Add",
+ GET_VAL8(umac_sta->sta_id, LMAC_STA_ID),
+ GET_VAL8(umac_sta->sta_id, LMAC_STA_COLOR),
+ umac_sta->mac_addr,
+ umac_sta->flags & UMAC_STA_FLAG_QOS);
+
+ sta->valid = 1;
+ sta->qos = umac_sta->flags & UMAC_STA_FLAG_QOS;
+ sta->color = GET_VAL8(umac_sta->sta_id, LMAC_STA_COLOR);
+ memcpy(sta->addr, umac_sta->mac_addr, ETH_ALEN);
+ break;
+ case UMAC_OPCODE_REMOVE:
+ IWM_DBG_MLME(iwm, INFO, "Remove STA: ID = %d, Color = %d, "
+ "addr = %pM\n",
+ GET_VAL8(umac_sta->sta_id, LMAC_STA_ID),
+ GET_VAL8(umac_sta->sta_id, LMAC_STA_COLOR),
+ umac_sta->mac_addr);
+
+ sta = &iwm->sta_table[GET_VAL8(umac_sta->sta_id, LMAC_STA_ID)];
+
+ if (!memcmp(sta->addr, umac_sta->mac_addr, ETH_ALEN))
+ sta->valid = 0;
+
+ break;
+ case UMAC_OPCODE_CLEAR_ALL:
+ for (i = 0; i < IWM_STA_TABLE_NUM; i++)
+ iwm->sta_table[i].valid = 0;
+
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int iwm_mlme_update_bss_table(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct wiphy *wiphy = iwm_to_wiphy(iwm);
+ struct ieee80211_mgmt *mgmt;
+ struct iwm_umac_notif_bss_info *umac_bss =
+ (struct iwm_umac_notif_bss_info *)buf;
+ struct ieee80211_channel *channel;
+ struct ieee80211_supported_band *band;
+ struct iwm_bss_info *bss, *next;
+ s32 signal;
+ int freq;
+ u16 frame_len = le16_to_cpu(umac_bss->frame_len);
+ size_t bss_len = sizeof(struct iwm_umac_notif_bss_info) + frame_len;
+
+ mgmt = (struct ieee80211_mgmt *)(umac_bss->frame_buf);
+
+ IWM_DBG_MLME(iwm, DBG, "New BSS info entry: %pM\n", mgmt->bssid);
+ IWM_DBG_MLME(iwm, DBG, "\tType: 0x%x\n", le32_to_cpu(umac_bss->type));
+ IWM_DBG_MLME(iwm, DBG, "\tTimestamp: %d\n",
+ le32_to_cpu(umac_bss->timestamp));
+ IWM_DBG_MLME(iwm, DBG, "\tTable Index: %d\n",
+ le16_to_cpu(umac_bss->table_idx));
+ IWM_DBG_MLME(iwm, DBG, "\tBand: %d\n", umac_bss->band);
+ IWM_DBG_MLME(iwm, DBG, "\tChannel: %d\n", umac_bss->channel);
+ IWM_DBG_MLME(iwm, DBG, "\tRSSI: %d\n", umac_bss->rssi);
+ IWM_DBG_MLME(iwm, DBG, "\tFrame Length: %d\n", frame_len);
+
+ list_for_each_entry_safe(bss, next, &iwm->bss_list, node)
+ if (bss->bss->table_idx == umac_bss->table_idx)
+ break;
+
+ if (&bss->node != &iwm->bss_list) {
+ /* Remove the old BSS entry, we will add it back later. */
+ list_del(&bss->node);
+ kfree(bss->bss);
+ } else {
+ /* New BSS entry */
+
+ bss = kzalloc(sizeof(struct iwm_bss_info), GFP_KERNEL);
+ if (!bss) {
+ IWM_ERR(iwm, "Couldn't allocate bss_info\n");
+ return -ENOMEM;
+ }
+ }
+
+ bss->bss = kzalloc(bss_len, GFP_KERNEL);
+ if (!bss) {
+ kfree(bss);
+ IWM_ERR(iwm, "Couldn't allocate bss\n");
+ return -ENOMEM;
+ }
+
+ INIT_LIST_HEAD(&bss->node);
+ memcpy(bss->bss, umac_bss, bss_len);
+
+ if (umac_bss->band == UMAC_BAND_2GHZ)
+ band = wiphy->bands[IEEE80211_BAND_2GHZ];
+ else if (umac_bss->band == UMAC_BAND_5GHZ)
+ band = wiphy->bands[IEEE80211_BAND_5GHZ];
+ else {
+ IWM_ERR(iwm, "Invalid band: %d\n", umac_bss->band);
+ goto err;
+ }
+
+ freq = ieee80211_channel_to_frequency(umac_bss->channel);
+ channel = ieee80211_get_channel(wiphy, freq);
+ signal = umac_bss->rssi * 100;
+
+ bss->cfg_bss = cfg80211_inform_bss_frame(wiphy, channel,
+ mgmt, frame_len,
+ signal, GFP_KERNEL);
+ if (!bss->cfg_bss)
+ goto err;
+
+ list_add_tail(&bss->node, &iwm->bss_list);
+
+ return 0;
+ err:
+ kfree(bss->bss);
+ kfree(bss);
+
+ return -EINVAL;
+}
+
+static int iwm_mlme_remove_bss(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_bss_removed *bss_rm =
+ (struct iwm_umac_notif_bss_removed *)buf;
+ struct iwm_bss_info *bss, *next;
+ u16 table_idx;
+ int i;
+
+ for (i = 0; i < le32_to_cpu(bss_rm->count); i++) {
+ table_idx = (le16_to_cpu(bss_rm->entries[i])
+ & IWM_BSS_REMOVE_INDEX_MSK);
+ list_for_each_entry_safe(bss, next, &iwm->bss_list, node)
+ if (bss->bss->table_idx == cpu_to_le16(table_idx)) {
+ struct ieee80211_mgmt *mgmt;
+
+ mgmt = (struct ieee80211_mgmt *)
+ (bss->bss->frame_buf);
+ IWM_DBG_MLME(iwm, ERR,
+ "BSS removed: %pM\n",
+ mgmt->bssid);
+ list_del(&bss->node);
+ kfree(bss->bss);
+ kfree(bss);
+ }
+ }
+
+ return 0;
+}
+
+static int iwm_mlme_mgt_frame(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_mgt_frame *mgt_frame =
+ (struct iwm_umac_notif_mgt_frame *)buf;
+ struct ieee80211_mgmt *mgt = (struct ieee80211_mgmt *)mgt_frame->frame;
+ u8 *ie;
+ unsigned int event;
+ union iwreq_data wrqu;
+
+ IWM_HEXDUMP(iwm, DBG, MLME, "MGT: ", mgt_frame->frame,
+ le16_to_cpu(mgt_frame->len));
+
+ if (ieee80211_is_assoc_req(mgt->frame_control)) {
+ ie = mgt->u.assoc_req.variable;;
+ event = IWEVASSOCREQIE;
+ } else if (ieee80211_is_reassoc_req(mgt->frame_control)) {
+ ie = mgt->u.reassoc_req.variable;;
+ event = IWEVASSOCREQIE;
+ } else if (ieee80211_is_assoc_resp(mgt->frame_control)) {
+ ie = mgt->u.assoc_resp.variable;;
+ event = IWEVASSOCRESPIE;
+ } else if (ieee80211_is_reassoc_resp(mgt->frame_control)) {
+ ie = mgt->u.reassoc_resp.variable;;
+ event = IWEVASSOCRESPIE;
+ } else {
+ IWM_ERR(iwm, "Unsupported management frame");
+ return 0;
+ }
+
+ wrqu.data.length = le16_to_cpu(mgt_frame->len) - (ie - (u8 *)mgt);
+
+ IWM_HEXDUMP(iwm, DBG, MLME, "EVT: ", ie, wrqu.data.length);
+ wireless_send_event(iwm_to_ndev(iwm), event, &wrqu, ie);
+
+ return 0;
+}
+
+static int iwm_ntf_mlme(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_wifi_if *notif =
+ (struct iwm_umac_notif_wifi_if *)buf;
+
+ switch (notif->status) {
+ case WIFI_IF_NTFY_ASSOC_START:
+ return iwm_mlme_assoc_start(iwm, buf, buf_size, cmd);
+ case WIFI_IF_NTFY_ASSOC_COMPLETE:
+ return iwm_mlme_assoc_complete(iwm, buf, buf_size, cmd);
+ case WIFI_IF_NTFY_PROFILE_INVALIDATE_COMPLETE:
+ return iwm_mlme_profile_invalidate(iwm, buf, buf_size, cmd);
+ case WIFI_IF_NTFY_CONNECTION_TERMINATED:
+ IWM_DBG_MLME(iwm, DBG, "Connection terminated\n");
+ break;
+ case WIFI_IF_NTFY_SCAN_COMPLETE:
+ return iwm_mlme_scan_complete(iwm, buf, buf_size, cmd);
+ case WIFI_IF_NTFY_STA_TABLE_CHANGE:
+ return iwm_mlme_update_sta_table(iwm, buf, buf_size, cmd);
+ case WIFI_IF_NTFY_EXTENDED_IE_REQUIRED:
+ IWM_DBG_MLME(iwm, DBG, "Extended IE required\n");
+ break;
+ case WIFI_IF_NTFY_BSS_TRK_TABLE_CHANGED:
+ return iwm_mlme_update_bss_table(iwm, buf, buf_size, cmd);
+ case WIFI_IF_NTFY_BSS_TRK_ENTRIES_REMOVED:
+ return iwm_mlme_remove_bss(iwm, buf, buf_size, cmd);
+ break;
+ case WIFI_IF_NTFY_MGMT_FRAME:
+ return iwm_mlme_mgt_frame(iwm, buf, buf_size, cmd);
+ case WIFI_DBG_IF_NTFY_SCAN_SUPER_JOB_START:
+ case WIFI_DBG_IF_NTFY_SCAN_SUPER_JOB_COMPLETE:
+ case WIFI_DBG_IF_NTFY_SCAN_CHANNEL_START:
+ case WIFI_DBG_IF_NTFY_SCAN_CHANNEL_RESULT:
+ case WIFI_DBG_IF_NTFY_SCAN_MINI_JOB_START:
+ case WIFI_DBG_IF_NTFY_SCAN_MINI_JOB_COMPLETE:
+ case WIFI_DBG_IF_NTFY_CNCT_ATC_START:
+ case WIFI_DBG_IF_NTFY_COEX_NOTIFICATION:
+ case WIFI_DBG_IF_NTFY_COEX_HANDLE_ENVELOP:
+ case WIFI_DBG_IF_NTFY_COEX_HANDLE_RELEASE_ENVELOP:
+ IWM_DBG_MLME(iwm, DBG, "MLME debug notification: 0x%x\n",
+ notif->status);
+ break;
+ default:
+ IWM_ERR(iwm, "Unhandled notification: 0x%x\n", notif->status);
+ break;
+ }
+
+ return 0;
+}
+
+#define IWM_STATS_UPDATE_INTERVAL (2 * HZ)
+
+static int iwm_ntf_statistics(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_notif_stats *stats = (struct iwm_umac_notif_stats *)buf;
+ struct iw_statistics *wstats = &iwm->wstats;
+ u16 max_rate = 0;
+ int i;
+
+ IWM_DBG_MLME(iwm, DBG, "Statistics notification received\n");
+
+ if (test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)) {
+ for (i = 0; i < UMAC_NTF_RATE_SAMPLE_NR; i++) {
+ max_rate = max_t(u16, max_rate,
+ max(le16_to_cpu(stats->tx_rate[i]),
+ le16_to_cpu(stats->rx_rate[i])));
+ }
+ /* UMAC passes rate info multiplies by 2 */
+ iwm->rate = max_rate >> 1;
+ }
+
+ wstats->status = 0;
+
+ wstats->discard.nwid = le32_to_cpu(stats->rx_drop_other_bssid);
+ wstats->discard.code = le32_to_cpu(stats->rx_drop_decode);
+ wstats->discard.fragment = le32_to_cpu(stats->rx_drop_reassembly);
+ wstats->discard.retries = le32_to_cpu(stats->tx_drop_max_retry);
+
+ wstats->miss.beacon = le32_to_cpu(stats->missed_beacons);
+
+ /* according to cfg80211 */
+ if (stats->rssi_dbm < -110)
+ wstats->qual.qual = 0;
+ else if (stats->rssi_dbm > -40)
+ wstats->qual.qual = 70;
+ else
+ wstats->qual.qual = stats->rssi_dbm + 110;
+
+ wstats->qual.level = stats->rssi_dbm;
+ wstats->qual.noise = stats->noise_dbm;
+ wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
+
+ schedule_delayed_work(&iwm->stats_request, IWM_STATS_UPDATE_INTERVAL);
+
+ mod_timer(&iwm->watchdog, round_jiffies(jiffies + IWM_WATCHDOG_PERIOD));
+
+ return 0;
+}
+
+static int iwm_ntf_eeprom_proxy(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_cmd_eeprom_proxy *eeprom_proxy =
+ (struct iwm_umac_cmd_eeprom_proxy *)
+ (buf + sizeof(struct iwm_umac_wifi_in_hdr));
+ struct iwm_umac_cmd_eeprom_proxy_hdr *hdr = &eeprom_proxy->hdr;
+ u32 hdr_offset = le32_to_cpu(hdr->offset);
+ u32 hdr_len = le32_to_cpu(hdr->len);
+ u32 hdr_type = le32_to_cpu(hdr->type);
+
+ IWM_DBG_NTF(iwm, DBG, "type: 0x%x, len: %d, offset: 0x%x\n",
+ hdr_type, hdr_len, hdr_offset);
+
+ if ((hdr_offset + hdr_len) > IWM_EEPROM_LEN)
+ return -EINVAL;
+
+#ifdef CONFIG_IWM_B0_HW_SUPPORT
+ if (hdr_offset == IWM_EEPROM_SKU_CAP_OFF) {
+ if (eeprom_proxy->buf[0] == 0xff)
+ iwm->conf.hw_b0 = 1;
+ }
+#endif
+
+ switch (hdr_type) {
+ case IWM_UMAC_CMD_EEPROM_TYPE_READ:
+ memcpy(iwm->eeprom + hdr_offset, eeprom_proxy->buf, hdr_len);
+ break;
+ case IWM_UMAC_CMD_EEPROM_TYPE_WRITE:
+ default:
+ return -ENOTSUPP;
+ }
+
+ return 0;
+}
+
+static int iwm_ntf_channel_info_list(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_cmd_get_channel_list *ch_list =
+ (struct iwm_umac_cmd_get_channel_list *)
+ (buf + sizeof(struct iwm_umac_wifi_in_hdr));
+ struct wiphy *wiphy = iwm_to_wiphy(iwm);
+ struct ieee80211_supported_band *band;
+ int i;
+
+ band = wiphy->bands[IEEE80211_BAND_2GHZ];
+
+ for (i = 0; i < band->n_channels; i++) {
+ unsigned long ch_mask_0 =
+ le32_to_cpu(ch_list->ch[0].channels_mask);
+ unsigned long ch_mask_2 =
+ le32_to_cpu(ch_list->ch[2].channels_mask);
+
+ if (!test_bit(i, &ch_mask_0))
+ band->channels[i].flags |= IEEE80211_CHAN_DISABLED;
+
+ if (!test_bit(i, &ch_mask_2))
+ band->channels[i].flags |= IEEE80211_CHAN_NO_IBSS;
+ }
+
+ band = wiphy->bands[IEEE80211_BAND_5GHZ];
+
+ for (i = 0; i < min(band->n_channels, 32); i++) {
+ unsigned long ch_mask_1 =
+ le32_to_cpu(ch_list->ch[1].channels_mask);
+ unsigned long ch_mask_3 =
+ le32_to_cpu(ch_list->ch[3].channels_mask);
+
+ if (!test_bit(i, &ch_mask_1))
+ band->channels[i].flags |= IEEE80211_CHAN_DISABLED;
+
+ if (!test_bit(i, &ch_mask_3))
+ band->channels[i].flags |= IEEE80211_CHAN_NO_IBSS;
+ }
+
+ return 0;
+}
+
+static int iwm_ntf_wifi_if_wrapper(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_umac_wifi_if *hdr =
+ (struct iwm_umac_wifi_if *)cmd->buf.payload;
+
+ IWM_DBG_NTF(iwm, DBG, "WIFI_IF_WRAPPER cmd is delivered to UMAC: "
+ "oid is %d\n", hdr->oid);
+
+ switch (hdr->oid) {
+ case UMAC_WIFI_IF_CMD_SET_PROFILE:
+ iwm->umac_profile_active = 1;
+ wake_up_interruptible(&iwm->mlme_queue);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size, struct iwm_wifi_cmd *cmd)
+{
+ struct iwm_lmac_card_state *state = (struct iwm_lmac_card_state *)
+ (buf + sizeof(struct iwm_umac_wifi_in_hdr));
+ u32 flags = le32_to_cpu(state->flags);
+
+ IWM_INFO(iwm, "HW RF Kill %s, CT Kill %s\n",
+ flags & IWM_CARD_STATE_HW_DISABLED ? "ON" : "OFF",
+ flags & IWM_CARD_STATE_CTKILL_DISABLED ? "ON" : "OFF");
+
+ if (flags & IWM_CARD_STATE_HW_DISABLED)
+ set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
+ else
+ clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
+
+ return 0;
+}
+
+static int iwm_rx_handle_wifi(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size)
+{
+ struct iwm_umac_wifi_in_hdr *wifi_hdr;
+ struct iwm_wifi_cmd *cmd;
+ u8 source, cmd_id;
+ u16 seq_num;
+ u32 count;
+ u8 resp;
+
+ wifi_hdr = (struct iwm_umac_wifi_in_hdr *)buf;
+ cmd_id = wifi_hdr->sw_hdr.cmd.cmd;
+
+ source = GET_VAL32(wifi_hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
+ if (source >= IWM_SRC_NUM) {
+ IWM_CRIT(iwm, "invalid source %d\n", source);
+ return -EINVAL;
+ }
+
+ count = (GET_VAL32(wifi_hdr->sw_hdr.meta_data, UMAC_FW_CMD_BYTE_COUNT));
+ count += sizeof(struct iwm_umac_wifi_in_hdr) -
+ sizeof(struct iwm_dev_cmd_hdr);
+ if (count > buf_size) {
+ IWM_CRIT(iwm, "count %d, buf size:%ld\n", count, buf_size);
+ return -EINVAL;
+ }
+
+ resp = GET_VAL32(wifi_hdr->sw_hdr.meta_data, UMAC_FW_CMD_STATUS);
+
+ seq_num = le16_to_cpu(wifi_hdr->sw_hdr.cmd.seq_num);
+
+ IWM_DBG_RX(iwm, DBG, "CMD:0x%x, source: 0x%x, seqnum: %d\n",
+ cmd_id, source, seq_num);
+
+ /*
+ * If this is a response to a previously sent command, there must
+ * be a pending command for this sequence number.
+ */
+ cmd = iwm_get_pending_wifi_cmd(iwm, seq_num);
+
+ /* Notify the caller only for sync commands. */
+ switch (source) {
+ case UMAC_HDI_IN_SOURCE_FHRX:
+ if (iwm->lmac_handlers[cmd_id] &&
+ test_bit(cmd_id, &iwm->lmac_handler_map[0]))
+ return iwm_notif_send(iwm, cmd, cmd_id, source,
+ buf, count);
+ break;
+ case UMAC_HDI_IN_SOURCE_FW:
+ if (iwm->umac_handlers[cmd_id] &&
+ test_bit(cmd_id, &iwm->umac_handler_map[0]))
+ return iwm_notif_send(iwm, cmd, cmd_id, source,
+ buf, count);
+ break;
+ case UMAC_HDI_IN_SOURCE_UDMA:
+ break;
+ }
+
+ return iwm_rx_handle_resp(iwm, buf, count, cmd);
+}
+
+int iwm_rx_handle_resp(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size,
+ struct iwm_wifi_cmd *cmd)
+{
+ u8 source, cmd_id;
+ struct iwm_umac_wifi_in_hdr *wifi_hdr;
+ int ret = 0;
+
+ wifi_hdr = (struct iwm_umac_wifi_in_hdr *)buf;
+ cmd_id = wifi_hdr->sw_hdr.cmd.cmd;
+
+ source = GET_VAL32(wifi_hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
+
+ IWM_DBG_RX(iwm, DBG, "CMD:0x%x, source: 0x%x\n", cmd_id, source);
+
+ switch (source) {
+ case UMAC_HDI_IN_SOURCE_FHRX:
+ if (iwm->lmac_handlers[cmd_id])
+ ret = iwm->lmac_handlers[cmd_id]
+ (iwm, buf, buf_size, cmd);
+ break;
+ case UMAC_HDI_IN_SOURCE_FW:
+ if (iwm->umac_handlers[cmd_id])
+ ret = iwm->umac_handlers[cmd_id]
+ (iwm, buf, buf_size, cmd);
+ break;
+ case UMAC_HDI_IN_SOURCE_UDMA:
+ ret = -EINVAL;
+ break;
+ }
+
+ kfree(cmd);
+
+ return ret;
+}
+
+static int iwm_rx_handle_nonwifi(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size)
+{
+ u8 seq_num;
+ struct iwm_udma_in_hdr *hdr = (struct iwm_udma_in_hdr *)buf;
+ struct iwm_nonwifi_cmd *cmd, *next;
+
+ seq_num = GET_VAL32(hdr->cmd, UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM);
+
+ /*
+ * We received a non wifi answer.
+ * Let's check if there's a pending command for it, and if so
+ * replace the command payload with the buffer, and then wake the
+ * callers up.
+ * That means we only support synchronised non wifi command response
+ * schemes.
+ */
+ list_for_each_entry_safe(cmd, next, &iwm->nonwifi_pending_cmd, pending)
+ if (cmd->seq_num == seq_num) {
+ cmd->resp_received = 1;
+ cmd->buf.len = buf_size;
+ memcpy(cmd->buf.hdr, buf, buf_size);
+ wake_up_interruptible(&iwm->nonwifi_queue);
+ }
+
+ return 0;
+}
+
+static int iwm_rx_handle_umac(struct iwm_priv *iwm, u8 *buf,
+ unsigned long buf_size)
+{
+ int ret = 0;
+ u8 op_code;
+ unsigned long buf_offset = 0;
+ struct iwm_udma_in_hdr *hdr;
+
+ /*
+ * To allow for a more efficient bus usage, UMAC
+ * messages are encapsulated into UDMA ones. This
+ * way we can have several UMAC messages in one bus
+ * transfer.
+ * A UDMA frame size is always aligned on 16 bytes,
+ * and a UDMA frame must not start with a UMAC_PAD_TERMINAL
+ * word. This is how we parse a bus frame into several
+ * UDMA ones.
+ */
+ while (buf_offset < buf_size) {
+
+ hdr = (struct iwm_udma_in_hdr *)(buf + buf_offset);
+
+ if (iwm_rx_check_udma_hdr(hdr) < 0) {
+ IWM_DBG_RX(iwm, DBG, "End of frame\n");
+ break;
+ }
+
+ op_code = GET_VAL32(hdr->cmd, UMAC_HDI_IN_CMD_OPCODE);
+
+ IWM_DBG_RX(iwm, DBG, "Op code: 0x%x\n", op_code);
+
+ if (op_code == UMAC_HDI_IN_OPCODE_WIFI) {
+ ret |= iwm_rx_handle_wifi(iwm, buf + buf_offset,
+ buf_size - buf_offset);
+ } else if (op_code < UMAC_HDI_IN_OPCODE_NONWIFI_MAX) {
+ if (GET_VAL32(hdr->cmd,
+ UDMA_HDI_IN_CMD_NON_WIFI_HW_SIG) !=
+ UDMA_HDI_IN_CMD_NON_WIFI_HW_SIG) {
+ IWM_ERR(iwm, "Incorrect hw signature\n");
+ return -EINVAL;
+ }
+ ret |= iwm_rx_handle_nonwifi(iwm, buf + buf_offset,
+ buf_size - buf_offset);
+ } else {
+ IWM_ERR(iwm, "Invalid RX opcode: 0x%x\n", op_code);
+ ret |= -EINVAL;
+ }
+
+ buf_offset += iwm_rx_resp_size(hdr);
+ }
+
+ return ret;
+}
+
+int iwm_rx_handle(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size)
+{
+ struct iwm_udma_in_hdr *hdr;
+
+ hdr = (struct iwm_udma_in_hdr *)buf;
+
+ switch (le32_to_cpu(hdr->cmd)) {
+ case UMAC_REBOOT_BARKER:
+ return iwm_notif_send(iwm, NULL, IWM_BARKER_REBOOT_NOTIFICATION,
+ IWM_SRC_UDMA, buf, buf_size);
+ case UMAC_ACK_BARKER:
+ return iwm_notif_send(iwm, NULL, IWM_ACK_BARKER_NOTIFICATION,
+ IWM_SRC_UDMA, NULL, 0);
+ default:
+ IWM_DBG_RX(iwm, DBG, "Received cmd: 0x%x\n", hdr->cmd);
+ return iwm_rx_handle_umac(iwm, buf, buf_size);
+ }
+
+ return 0;
+}
+
+static const iwm_handler iwm_umac_handlers[] =
+{
+ [UMAC_NOTIFY_OPCODE_ERROR] = iwm_ntf_error,
+ [UMAC_NOTIFY_OPCODE_ALIVE] = iwm_ntf_umac_alive,
+ [UMAC_NOTIFY_OPCODE_INIT_COMPLETE] = iwm_ntf_init_complete,
+ [UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS] = iwm_ntf_wifi_status,
+ [UMAC_NOTIFY_OPCODE_WIFI_IF_WRAPPER] = iwm_ntf_mlme,
+ [UMAC_NOTIFY_OPCODE_PAGE_DEALLOC] = iwm_ntf_tx_credit_update,
+ [UMAC_NOTIFY_OPCODE_RX_TICKET] = iwm_ntf_rx_ticket,
+ [UMAC_CMD_OPCODE_RESET] = iwm_ntf_umac_reset,
+ [UMAC_NOTIFY_OPCODE_STATS] = iwm_ntf_statistics,
+ [UMAC_CMD_OPCODE_EEPROM_PROXY] = iwm_ntf_eeprom_proxy,
+ [UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST] = iwm_ntf_channel_info_list,
+ [REPLY_RX_MPDU_CMD] = iwm_ntf_rx_packet,
+ [UMAC_CMD_OPCODE_WIFI_IF_WRAPPER] = iwm_ntf_wifi_if_wrapper,
+};
+
+static const iwm_handler iwm_lmac_handlers[] =
+{
+ [REPLY_TX] = iwm_ntf_tx,
+ [REPLY_ALIVE] = iwm_ntf_lmac_version,
+ [CALIBRATION_RES_NOTIFICATION] = iwm_ntf_calib_res,
+ [CALIBRATION_COMPLETE_NOTIFICATION] = iwm_ntf_calib_complete,
+ [CALIBRATION_CFG_CMD] = iwm_ntf_calib_cfg,
+ [REPLY_RX_MPDU_CMD] = iwm_ntf_rx_packet,
+ [CARD_STATE_NOTIFICATION] = iwm_ntf_card_state,
+};
+
+void iwm_rx_setup_handlers(struct iwm_priv *iwm)
+{
+ iwm->umac_handlers = (iwm_handler *) iwm_umac_handlers;
+ iwm->lmac_handlers = (iwm_handler *) iwm_lmac_handlers;
+}
+
+static void iwm_remove_iv(struct sk_buff *skb, u32 hdr_total_len)
+{
+ struct ieee80211_hdr *hdr;
+ unsigned int hdr_len;
+
+ hdr = (struct ieee80211_hdr *)skb->data;
+
+ if (!ieee80211_has_protected(hdr->frame_control))
+ return;
+
+ hdr_len = ieee80211_hdrlen(hdr->frame_control);
+ if (hdr_total_len <= hdr_len)
+ return;
+
+ memmove(skb->data + (hdr_total_len - hdr_len), skb->data, hdr_len);
+ skb_pull(skb, (hdr_total_len - hdr_len));
+}
+
+static void iwm_rx_adjust_packet(struct iwm_priv *iwm,
+ struct iwm_rx_packet *packet,
+ struct iwm_rx_ticket_node *ticket_node)
+{
+ u32 payload_offset = 0, payload_len;
+ struct iwm_rx_ticket *ticket = ticket_node->ticket;
+ struct iwm_rx_mpdu_hdr *mpdu_hdr;
+ struct ieee80211_hdr *hdr;
+
+ mpdu_hdr = (struct iwm_rx_mpdu_hdr *)packet->skb->data;
+ payload_offset += sizeof(struct iwm_rx_mpdu_hdr);
+ /* Padding is 0 or 2 bytes */
+ payload_len = le16_to_cpu(mpdu_hdr->len) +
+ (le16_to_cpu(ticket->flags) & IWM_RX_TICKET_PAD_SIZE_MSK);
+ payload_len -= ticket->tail_len;
+
+ IWM_DBG_RX(iwm, DBG, "Packet adjusted, len:%d, offset:%d, "
+ "ticket offset:%d ticket tail len:%d\n",
+ payload_len, payload_offset, ticket->payload_offset,
+ ticket->tail_len);
+
+ IWM_HEXDUMP(iwm, DBG, RX, "RAW: ", packet->skb->data, packet->skb->len);
+
+ skb_pull(packet->skb, payload_offset);
+ skb_trim(packet->skb, payload_len);
+
+ iwm_remove_iv(packet->skb, ticket->payload_offset);
+
+ hdr = (struct ieee80211_hdr *) packet->skb->data;
+ if (ieee80211_is_data_qos(hdr->frame_control)) {
+ /* UMAC handed QOS_DATA frame with 2 padding bytes appended
+ * to the qos_ctl field in IEEE 802.11 headers. */
+ memmove(packet->skb->data + IEEE80211_QOS_CTL_LEN + 2,
+ packet->skb->data,
+ ieee80211_hdrlen(hdr->frame_control) -
+ IEEE80211_QOS_CTL_LEN);
+ hdr = (struct ieee80211_hdr *) skb_pull(packet->skb,
+ IEEE80211_QOS_CTL_LEN + 2);
+ hdr->frame_control &= ~cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
+ }
+
+ IWM_HEXDUMP(iwm, DBG, RX, "ADJUSTED: ",
+ packet->skb->data, packet->skb->len);
+}
+
+static void classify8023(struct sk_buff *skb)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+
+ if (ieee80211_is_data_qos(hdr->frame_control)) {
+ u8 *qc = ieee80211_get_qos_ctl(hdr);
+ /* frame has qos control */
+ skb->priority = *qc & IEEE80211_QOS_CTL_TID_MASK;
+ } else {
+ skb->priority = 0;
+ }
+}
+
+static void iwm_rx_process_packet(struct iwm_priv *iwm,
+ struct iwm_rx_packet *packet,
+ struct iwm_rx_ticket_node *ticket_node)
+{
+ int ret;
+ struct sk_buff *skb = packet->skb;
+ struct wireless_dev *wdev = iwm_to_wdev(iwm);
+ struct net_device *ndev = iwm_to_ndev(iwm);
+
+ IWM_DBG_RX(iwm, DBG, "Processing packet ID %d\n", packet->id);
+
+ switch (le16_to_cpu(ticket_node->ticket->action)) {
+ case IWM_RX_TICKET_RELEASE:
+ IWM_DBG_RX(iwm, DBG, "RELEASE packet\n");
+ classify8023(skb);
+ iwm_rx_adjust_packet(iwm, packet, ticket_node);
+ ret = ieee80211_data_to_8023(skb, ndev->dev_addr, wdev->iftype);
+ if (ret < 0) {
+ IWM_DBG_RX(iwm, DBG, "Couldn't convert 802.11 header - "
+ "%d\n", ret);
+ break;
+ }
+
+ IWM_HEXDUMP(iwm, DBG, RX, "802.3: ", skb->data, skb->len);
+
+ skb->dev = iwm_to_ndev(iwm);
+ skb->protocol = eth_type_trans(skb, ndev);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ memset(skb->cb, 0, sizeof(skb->cb));
+
+ ndev->stats.rx_packets++;
+ ndev->stats.rx_bytes += skb->len;
+
+ if (netif_rx(skb) == NET_RX_DROP) {
+ IWM_ERR(iwm, "Packet dropped\n");
+ ndev->stats.rx_dropped++;
+ }
+ break;
+ case IWM_RX_TICKET_DROP:
+ IWM_DBG_RX(iwm, DBG, "DROP packet\n");
+ kfree_skb(packet->skb);
+ break;
+ default:
+ IWM_ERR(iwm, "Unknow ticket action: %d\n",
+ le16_to_cpu(ticket_node->ticket->action));
+ kfree_skb(packet->skb);
+ }
+
+ kfree(packet);
+ iwm_rx_ticket_node_free(ticket_node);
+}
+
+/*
+ * Rx data processing:
+ *
+ * We're receiving Rx packet from the LMAC, and Rx ticket from
+ * the UMAC.
+ * To forward a target data packet upstream (i.e. to the
+ * kernel network stack), we must have received an Rx ticket
+ * that tells us we're allowed to release this packet (ticket
+ * action is IWM_RX_TICKET_RELEASE). The Rx ticket also indicates,
+ * among other things, where valid data actually starts in the Rx
+ * packet.
+ */
+void iwm_rx_worker(struct work_struct *work)
+{
+ struct iwm_priv *iwm;
+ struct iwm_rx_ticket_node *ticket, *next;
+
+ iwm = container_of(work, struct iwm_priv, rx_worker);
+
+ /*
+ * We go through the tickets list and if there is a pending
+ * packet for it, we push it upstream.
+ * We stop whenever a ticket is missing its packet, as we're
+ * supposed to send the packets in order.
+ */
+ list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) {
+ struct iwm_rx_packet *packet =
+ iwm_rx_packet_get(iwm, le16_to_cpu(ticket->ticket->id));
+
+ if (!packet) {
+ IWM_DBG_RX(iwm, DBG, "Skip rx_work: Wait for ticket %d "
+ "to be handled first\n",
+ le16_to_cpu(ticket->ticket->id));
+ return;
+ }
+
+ list_del(&ticket->node);
+ list_del(&packet->node);
+ iwm_rx_process_packet(iwm, packet, ticket);
+ }
+}
+
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.h b/drivers/net/wireless/iwmc3200wifi/rx.h
new file mode 100644
index 000000000000..da0db91cee59
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/rx.h
@@ -0,0 +1,60 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_RX_H__
+#define __IWM_RX_H__
+
+#include <linux/skbuff.h>
+
+#include "umac.h"
+
+struct iwm_rx_ticket_node {
+ struct list_head node;
+ struct iwm_rx_ticket *ticket;
+};
+
+struct iwm_rx_packet {
+ struct list_head node;
+ u16 id;
+ struct sk_buff *skb;
+ unsigned long pkt_size;
+};
+
+void iwm_rx_worker(struct work_struct *work);
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c
new file mode 100644
index 000000000000..edc0a0091058
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/sdio.c
@@ -0,0 +1,516 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+/*
+ * This is the SDIO bus specific hooks for iwm.
+ * It also is the module's entry point.
+ *
+ * Interesting code paths:
+ * iwm_sdio_probe() (Called by an SDIO bus scan)
+ * -> iwm_if_alloc() (netdev.c)
+ * -> iwm_wdev_alloc() (cfg80211.c, allocates and register our wiphy)
+ * -> wiphy_new()
+ * -> wiphy_register()
+ * -> alloc_netdev_mq()
+ * -> register_netdev()
+ *
+ * iwm_sdio_remove()
+ * -> iwm_if_free() (netdev.c)
+ * -> unregister_netdev()
+ * -> iwm_wdev_free() (cfg80211.c)
+ * -> wiphy_unregister()
+ * -> wiphy_free()
+ *
+ * iwm_sdio_isr() (called in process context from the SDIO core code)
+ * -> queue_work(.., isr_worker)
+ * -- [async] --> iwm_sdio_isr_worker()
+ * -> iwm_rx_handle()
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/debugfs.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/sdio_func.h>
+
+#include "iwm.h"
+#include "debug.h"
+#include "bus.h"
+#include "sdio.h"
+
+static void iwm_sdio_isr_worker(struct work_struct *work)
+{
+ struct iwm_sdio_priv *hw;
+ struct iwm_priv *iwm;
+ struct iwm_rx_info *rx_info;
+ struct sk_buff *skb;
+ u8 *rx_buf;
+ unsigned long rx_size;
+
+ hw = container_of(work, struct iwm_sdio_priv, isr_worker);
+ iwm = hw_to_iwm(hw);
+
+ while (!skb_queue_empty(&iwm->rx_list)) {
+ skb = skb_dequeue(&iwm->rx_list);
+ rx_info = skb_to_rx_info(skb);
+ rx_size = rx_info->rx_size;
+ rx_buf = skb->data;
+
+ IWM_HEXDUMP(iwm, DBG, SDIO, "RX: ", rx_buf, rx_size);
+ if (iwm_rx_handle(iwm, rx_buf, rx_size) < 0)
+ IWM_WARN(iwm, "RX error\n");
+
+ kfree_skb(skb);
+ }
+}
+
+static void iwm_sdio_isr(struct sdio_func *func)
+{
+ struct iwm_priv *iwm;
+ struct iwm_sdio_priv *hw;
+ struct iwm_rx_info *rx_info;
+ struct sk_buff *skb;
+ unsigned long buf_size, read_size;
+ int ret;
+ u8 val;
+
+ hw = sdio_get_drvdata(func);
+ iwm = hw_to_iwm(hw);
+
+ buf_size = hw->blk_size;
+
+ /* We're checking the status */
+ val = sdio_readb(func, IWM_SDIO_INTR_STATUS_ADDR, &ret);
+ if (val == 0 || ret < 0) {
+ IWM_ERR(iwm, "Wrong INTR_STATUS\n");
+ return;
+ }
+
+ /* See if we have free buffers */
+ if (skb_queue_len(&iwm->rx_list) > IWM_RX_LIST_SIZE) {
+ IWM_ERR(iwm, "No buffer for more Rx frames\n");
+ return;
+ }
+
+ /* We first read the transaction size */
+ read_size = sdio_readb(func, IWM_SDIO_INTR_GET_SIZE_ADDR + 1, &ret);
+ read_size = read_size << 8;
+
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't read the xfer size\n");
+ return;
+ }
+
+ /* We need to clear the INT register */
+ sdio_writeb(func, 1, IWM_SDIO_INTR_CLEAR_ADDR, &ret);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't clear the INT register\n");
+ return;
+ }
+
+ while (buf_size < read_size)
+ buf_size <<= 1;
+
+ skb = dev_alloc_skb(buf_size);
+ if (!skb) {
+ IWM_ERR(iwm, "Couldn't alloc RX skb\n");
+ return;
+ }
+ rx_info = skb_to_rx_info(skb);
+ rx_info->rx_size = read_size;
+ rx_info->rx_buf_size = buf_size;
+
+ /* Now we can read the actual buffer */
+ ret = sdio_memcpy_fromio(func, skb_put(skb, read_size),
+ IWM_SDIO_DATA_ADDR, read_size);
+
+ /* The skb is put on a driver's specific Rx SKB list */
+ skb_queue_tail(&iwm->rx_list, skb);
+
+ /* We can now schedule the actual worker */
+ queue_work(hw->isr_wq, &hw->isr_worker);
+}
+
+static void iwm_sdio_rx_free(struct iwm_sdio_priv *hw)
+{
+ struct iwm_priv *iwm = hw_to_iwm(hw);
+
+ flush_workqueue(hw->isr_wq);
+
+ skb_queue_purge(&iwm->rx_list);
+}
+
+/* Bus ops */
+static int if_sdio_enable(struct iwm_priv *iwm)
+{
+ struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm);
+ int ret;
+
+ sdio_claim_host(hw->func);
+
+ ret = sdio_enable_func(hw->func);
+ if (ret) {
+ IWM_ERR(iwm, "Couldn't enable the device: is TOP driver "
+ "loaded and functional?\n");
+ goto release_host;
+ }
+
+ iwm_reset(iwm);
+
+ ret = sdio_claim_irq(hw->func, iwm_sdio_isr);
+ if (ret) {
+ IWM_ERR(iwm, "Failed to claim irq: %d\n", ret);
+ goto release_host;
+ }
+
+ sdio_writeb(hw->func, 1, IWM_SDIO_INTR_ENABLE_ADDR, &ret);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't enable INTR: %d\n", ret);
+ goto release_irq;
+ }
+
+ sdio_release_host(hw->func);
+
+ IWM_DBG_SDIO(iwm, INFO, "IWM SDIO enable\n");
+
+ return 0;
+
+ release_irq:
+ sdio_release_irq(hw->func);
+ release_host:
+ sdio_release_host(hw->func);
+
+ return ret;
+}
+
+static int if_sdio_disable(struct iwm_priv *iwm)
+{
+ struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm);
+ int ret;
+
+ iwm_reset(iwm);
+
+ sdio_claim_host(hw->func);
+ sdio_writeb(hw->func, 0, IWM_SDIO_INTR_ENABLE_ADDR, &ret);
+ if (ret < 0)
+ IWM_WARN(iwm, "Couldn't disable INTR: %d\n", ret);
+
+ sdio_release_irq(hw->func);
+ sdio_disable_func(hw->func);
+ sdio_release_host(hw->func);
+
+ iwm_sdio_rx_free(hw);
+
+ IWM_DBG_SDIO(iwm, INFO, "IWM SDIO disable\n");
+
+ return 0;
+}
+
+static int if_sdio_send_chunk(struct iwm_priv *iwm, u8 *buf, int count)
+{
+ struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm);
+ int aligned_count = ALIGN(count, hw->blk_size);
+ int ret;
+
+ if ((unsigned long)buf & 0x3) {
+ IWM_ERR(iwm, "buf <%p> is not dword aligned\n", buf);
+ /* TODO: Is this a hardware limitation? use get_unligned */
+ return -EINVAL;
+ }
+
+ sdio_claim_host(hw->func);
+ ret = sdio_memcpy_toio(hw->func, IWM_SDIO_DATA_ADDR, buf,
+ aligned_count);
+ sdio_release_host(hw->func);
+
+ return ret;
+}
+
+/* debugfs hooks */
+static int iwm_debugfs_sdio_open(struct inode *inode, struct file *filp)
+{
+ filp->private_data = inode->i_private;
+ return 0;
+}
+
+static ssize_t iwm_debugfs_sdio_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct iwm_priv *iwm = filp->private_data;
+ struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm);
+ char *buf;
+ u8 cccr;
+ int buf_len = 4096, ret;
+ size_t len = 0;
+
+ if (*ppos != 0)
+ return 0;
+ if (count < sizeof(buf))
+ return -ENOSPC;
+
+ buf = kzalloc(buf_len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ sdio_claim_host(hw->func);
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IOEx, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_IOEx\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_IOEx: 0x%x\n", cccr);
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IORx, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_IORx\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_IORx: 0x%x\n", cccr);
+
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IENx, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_IENx\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_IENx: 0x%x\n", cccr);
+
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_INTx, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_INTx\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_INTx: 0x%x\n", cccr);
+
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_ABORT, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_ABORTx\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_ABORT: 0x%x\n", cccr);
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_IF, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_IF\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_IF: 0x%x\n", cccr);
+
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_CAPS, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_CAPS\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_CAPS: 0x%x\n", cccr);
+
+ cccr = sdio_f0_readb(hw->func, SDIO_CCCR_CIS, &ret);
+ if (ret) {
+ IWM_ERR(iwm, "Could not read SDIO_CCCR_CIS\n");
+ goto err;
+ }
+ len += snprintf(buf + len, buf_len - len, "CCCR_CIS: 0x%x\n", cccr);
+
+ ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len);
+err:
+ sdio_release_host(hw->func);
+
+ kfree(buf);
+
+ return ret;
+}
+
+static const struct file_operations iwm_debugfs_sdio_fops = {
+ .owner = THIS_MODULE,
+ .open = iwm_debugfs_sdio_open,
+ .read = iwm_debugfs_sdio_read,
+};
+
+static int if_sdio_debugfs_init(struct iwm_priv *iwm, struct dentry *parent_dir)
+{
+ int result;
+ struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm);
+
+ hw->cccr_dentry = debugfs_create_file("cccr", 0200,
+ parent_dir, iwm,
+ &iwm_debugfs_sdio_fops);
+ result = PTR_ERR(hw->cccr_dentry);
+ if (IS_ERR(hw->cccr_dentry) && (result != -ENODEV)) {
+ IWM_ERR(iwm, "Couldn't create CCCR entry: %d\n", result);
+ return result;
+ }
+
+ return 0;
+}
+
+static void if_sdio_debugfs_exit(struct iwm_priv *iwm)
+{
+ struct iwm_sdio_priv *hw = iwm_to_if_sdio(iwm);
+
+ debugfs_remove(hw->cccr_dentry);
+}
+
+static struct iwm_if_ops if_sdio_ops = {
+ .enable = if_sdio_enable,
+ .disable = if_sdio_disable,
+ .send_chunk = if_sdio_send_chunk,
+ .debugfs_init = if_sdio_debugfs_init,
+ .debugfs_exit = if_sdio_debugfs_exit,
+ .umac_name = "iwmc3200wifi-umac-sdio.bin",
+ .calib_lmac_name = "iwmc3200wifi-lmac-calib-sdio.bin",
+ .lmac_name = "iwmc3200wifi-lmac-sdio.bin",
+};
+
+static int iwm_sdio_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ struct iwm_priv *iwm;
+ struct iwm_sdio_priv *hw;
+ struct device *dev = &func->dev;
+ int ret;
+
+ /* check if TOP has already initialized the card */
+ sdio_claim_host(func);
+ ret = sdio_enable_func(func);
+ if (ret) {
+ dev_err(dev, "wait for TOP to enable the device\n");
+ sdio_release_host(func);
+ return ret;
+ }
+
+ ret = sdio_set_block_size(func, IWM_SDIO_BLK_SIZE);
+
+ sdio_disable_func(func);
+ sdio_release_host(func);
+
+ if (ret < 0) {
+ dev_err(dev, "Failed to set block size: %d\n", ret);
+ return ret;
+ }
+
+ iwm = iwm_if_alloc(sizeof(struct iwm_sdio_priv), dev, &if_sdio_ops);
+ if (IS_ERR(iwm)) {
+ dev_err(dev, "allocate SDIO interface failed\n");
+ return PTR_ERR(iwm);
+ }
+
+ hw = iwm_private(iwm);
+ hw->iwm = iwm;
+
+ ret = iwm_debugfs_init(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Debugfs registration failed\n");
+ goto if_free;
+ }
+
+ sdio_set_drvdata(func, hw);
+
+ hw->func = func;
+ hw->blk_size = IWM_SDIO_BLK_SIZE;
+
+ hw->isr_wq = create_singlethread_workqueue(KBUILD_MODNAME "_sdio");
+ if (!hw->isr_wq) {
+ ret = -ENOMEM;
+ goto debugfs_exit;
+ }
+
+ INIT_WORK(&hw->isr_worker, iwm_sdio_isr_worker);
+
+ dev_info(dev, "IWM SDIO probe\n");
+
+ return 0;
+
+ debugfs_exit:
+ iwm_debugfs_exit(iwm);
+ if_free:
+ iwm_if_free(iwm);
+ return ret;
+}
+
+static void iwm_sdio_remove(struct sdio_func *func)
+{
+ struct iwm_sdio_priv *hw = sdio_get_drvdata(func);
+ struct iwm_priv *iwm = hw_to_iwm(hw);
+ struct device *dev = &func->dev;
+
+ iwm_debugfs_exit(iwm);
+ iwm_if_free(iwm);
+ destroy_workqueue(hw->isr_wq);
+
+ sdio_set_drvdata(func, NULL);
+
+ dev_info(dev, "IWM SDIO remove\n");
+
+ return;
+}
+
+static const struct sdio_device_id iwm_sdio_ids[] = {
+ { SDIO_DEVICE(SDIO_VENDOR_ID_INTEL, SDIO_DEVICE_ID_IWM) },
+ { /* end: all zeroes */ },
+};
+MODULE_DEVICE_TABLE(sdio, iwm_sdio_ids);
+
+static struct sdio_driver iwm_sdio_driver = {
+ .name = "iwm_sdio",
+ .id_table = iwm_sdio_ids,
+ .probe = iwm_sdio_probe,
+ .remove = iwm_sdio_remove,
+};
+
+static int __init iwm_sdio_init_module(void)
+{
+ int ret;
+
+ ret = sdio_register_driver(&iwm_sdio_driver);
+
+ return ret;
+}
+
+static void __exit iwm_sdio_exit_module(void)
+{
+ sdio_unregister_driver(&iwm_sdio_driver);
+}
+
+module_init(iwm_sdio_init_module);
+module_exit(iwm_sdio_exit_module);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR(IWM_COPYRIGHT " " IWM_AUTHOR);
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.h b/drivers/net/wireless/iwmc3200wifi/sdio.h
new file mode 100644
index 000000000000..b3c156b08dda
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/sdio.h
@@ -0,0 +1,67 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_SDIO_H__
+#define __IWM_SDIO_H__
+
+#define SDIO_VENDOR_ID_INTEL 0x89
+#define SDIO_DEVICE_ID_IWM 0x1403
+
+#define IWM_SDIO_DATA_ADDR 0x0
+#define IWM_SDIO_INTR_ENABLE_ADDR 0x14
+#define IWM_SDIO_INTR_STATUS_ADDR 0x13
+#define IWM_SDIO_INTR_CLEAR_ADDR 0x13
+#define IWM_SDIO_INTR_GET_SIZE_ADDR 0x2C
+
+#define IWM_SDIO_BLK_SIZE 256
+
+#define iwm_to_if_sdio(i) (struct iwm_sdio_priv *)(iwm->private)
+
+struct iwm_sdio_priv {
+ struct sdio_func *func;
+ struct iwm_priv *iwm;
+
+ struct workqueue_struct *isr_wq;
+ struct work_struct isr_worker;
+
+ struct dentry *cccr_dentry;
+
+ unsigned int blk_size;
+};
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/tx.c b/drivers/net/wireless/iwmc3200wifi/tx.c
new file mode 100644
index 000000000000..e3b4f7902daf
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/tx.c
@@ -0,0 +1,492 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+/*
+ * iwm Tx theory of operation:
+ *
+ * 1) We receive a 802.3 frame from the stack
+ * 2) We convert it to a 802.11 frame [iwm_xmit_frame]
+ * 3) We queue it to its corresponding tx queue [iwm_xmit_frame]
+ * 4) We schedule the tx worker. There is one worker per tx
+ * queue. [iwm_xmit_frame]
+ * 5) The tx worker is scheduled
+ * 6) We go through every queued skb on the tx queue, and for each
+ * and every one of them: [iwm_tx_worker]
+ * a) We check if we have enough Tx credits (see below for a Tx
+ * credits description) for the frame length. [iwm_tx_worker]
+ * b) If we do, we aggregate the Tx frame into a UDMA one, by
+ * concatenating one REPLY_TX command per Tx frame. [iwm_tx_worker]
+ * c) When we run out of credits, or when we reach the maximum
+ * concatenation size, we actually send the concatenated UDMA
+ * frame. [iwm_tx_worker]
+ *
+ * When we run out of Tx credits, the skbs are filling the tx queue,
+ * and eventually we will stop the netdev queue. [iwm_tx_worker]
+ * The tx queue is emptied as we're getting new tx credits, by
+ * scheduling the tx_worker. [iwm_tx_credit_inc]
+ * The netdev queue is started again when we have enough tx credits,
+ * and when our tx queue has some reasonable amout of space available
+ * (i.e. half of the max size). [iwm_tx_worker]
+ */
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/ieee80211.h>
+
+#include "iwm.h"
+#include "debug.h"
+#include "commands.h"
+#include "hal.h"
+#include "umac.h"
+#include "bus.h"
+
+#define IWM_UMAC_PAGE_ALLOC_WRAP 0xffff
+
+#define BYTES_TO_PAGES(n) (1 + ((n) >> ilog2(IWM_UMAC_PAGE_SIZE)) - \
+ (((n) & (IWM_UMAC_PAGE_SIZE - 1)) == 0))
+
+#define pool_id_to_queue(id) ((id < IWM_TX_CMD_QUEUE) ? id : id - 1)
+#define queue_to_pool_id(q) ((q < IWM_TX_CMD_QUEUE) ? q : q + 1)
+
+/* require to hold tx_credit lock */
+static int iwm_tx_credit_get(struct iwm_tx_credit *tx_credit, int id)
+{
+ struct pool_entry *pool = &tx_credit->pools[id];
+ struct spool_entry *spool = &tx_credit->spools[pool->sid];
+ int spool_pages;
+
+ /* number of pages can be taken from spool by this pool */
+ spool_pages = spool->max_pages - spool->alloc_pages +
+ max(pool->min_pages - pool->alloc_pages, 0);
+
+ return min(pool->max_pages - pool->alloc_pages, spool_pages);
+}
+
+static bool iwm_tx_credit_ok(struct iwm_priv *iwm, int id, int nb)
+{
+ u32 npages = BYTES_TO_PAGES(nb);
+
+ if (npages <= iwm_tx_credit_get(&iwm->tx_credit, id))
+ return 1;
+
+ set_bit(id, &iwm->tx_credit.full_pools_map);
+
+ IWM_DBG_TX(iwm, DBG, "LINK: stop txq[%d], available credit: %d\n",
+ pool_id_to_queue(id),
+ iwm_tx_credit_get(&iwm->tx_credit, id));
+
+ return 0;
+}
+
+void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages)
+{
+ struct pool_entry *pool;
+ struct spool_entry *spool;
+ int freed_pages;
+ int queue;
+
+ BUG_ON(id >= IWM_MACS_OUT_GROUPS);
+
+ pool = &iwm->tx_credit.pools[id];
+ spool = &iwm->tx_credit.spools[pool->sid];
+
+ freed_pages = total_freed_pages - pool->total_freed_pages;
+ IWM_DBG_TX(iwm, DBG, "Free %d pages for pool[%d]\n", freed_pages, id);
+
+ if (!freed_pages) {
+ IWM_DBG_TX(iwm, DBG, "No pages are freed by UMAC\n");
+ return;
+ } else if (freed_pages < 0)
+ freed_pages += IWM_UMAC_PAGE_ALLOC_WRAP + 1;
+
+ if (pool->alloc_pages > pool->min_pages) {
+ int spool_pages = pool->alloc_pages - pool->min_pages;
+ spool_pages = min(spool_pages, freed_pages);
+ spool->alloc_pages -= spool_pages;
+ }
+
+ pool->alloc_pages -= freed_pages;
+ pool->total_freed_pages = total_freed_pages;
+
+ IWM_DBG_TX(iwm, DBG, "Pool[%d] pages alloc: %d, total_freed: %d, "
+ "Spool[%d] pages alloc: %d\n", id, pool->alloc_pages,
+ pool->total_freed_pages, pool->sid, spool->alloc_pages);
+
+ if (test_bit(id, &iwm->tx_credit.full_pools_map) &&
+ (pool->alloc_pages < pool->max_pages / 2)) {
+ clear_bit(id, &iwm->tx_credit.full_pools_map);
+
+ queue = pool_id_to_queue(id);
+
+ IWM_DBG_TX(iwm, DBG, "LINK: start txq[%d], available "
+ "credit: %d\n", queue,
+ iwm_tx_credit_get(&iwm->tx_credit, id));
+ queue_work(iwm->txq[queue].wq, &iwm->txq[queue].worker);
+ }
+}
+
+static void iwm_tx_credit_dec(struct iwm_priv *iwm, int id, int alloc_pages)
+{
+ struct pool_entry *pool;
+ struct spool_entry *spool;
+ int spool_pages;
+
+ IWM_DBG_TX(iwm, DBG, "Allocate %d pages for pool[%d]\n",
+ alloc_pages, id);
+
+ BUG_ON(id >= IWM_MACS_OUT_GROUPS);
+
+ pool = &iwm->tx_credit.pools[id];
+ spool = &iwm->tx_credit.spools[pool->sid];
+
+ spool_pages = pool->alloc_pages + alloc_pages - pool->min_pages;
+
+ if (pool->alloc_pages >= pool->min_pages)
+ spool->alloc_pages += alloc_pages;
+ else if (spool_pages > 0)
+ spool->alloc_pages += spool_pages;
+
+ pool->alloc_pages += alloc_pages;
+
+ IWM_DBG_TX(iwm, DBG, "Pool[%d] pages alloc: %d, total_freed: %d, "
+ "Spool[%d] pages alloc: %d\n", id, pool->alloc_pages,
+ pool->total_freed_pages, pool->sid, spool->alloc_pages);
+}
+
+int iwm_tx_credit_alloc(struct iwm_priv *iwm, int id, int nb)
+{
+ u32 npages = BYTES_TO_PAGES(nb);
+ int ret = 0;
+
+ spin_lock(&iwm->tx_credit.lock);
+
+ if (!iwm_tx_credit_ok(iwm, id, nb)) {
+ IWM_DBG_TX(iwm, DBG, "No credit avaliable for pool[%d]\n", id);
+ ret = -ENOSPC;
+ goto out;
+ }
+
+ iwm_tx_credit_dec(iwm, id, npages);
+
+ out:
+ spin_unlock(&iwm->tx_credit.lock);
+ return ret;
+}
+
+/*
+ * Since we're on an SDIO or USB bus, we are not sharing memory
+ * for storing to be transmitted frames. The host needs to push
+ * them upstream. As a consequence there needs to be a way for
+ * the target to let us know if it can actually take more TX frames
+ * or not. This is what Tx credits are for.
+ *
+ * For each Tx HW queue, we have a Tx pool, and then we have one
+ * unique super pool (spool), which is actually a global pool of
+ * all the UMAC pages.
+ * For each Tx pool we have a min_pages, a max_pages fields, and a
+ * alloc_pages fields. The alloc_pages tracks the number of pages
+ * currently allocated from the tx pool.
+ * Here are the rules to check if given a tx frame we have enough
+ * tx credits for it:
+ * 1) We translate the frame length into a number of UMAC pages.
+ * Let's call them n_pages.
+ * 2) For the corresponding tx pool, we check if n_pages +
+ * pool->alloc_pages is higher than pool->min_pages. min_pages
+ * represent a set of pre-allocated pages on the tx pool. If
+ * that's the case, then we need to allocate those pages from
+ * the spool. We can do so until we reach spool->max_pages.
+ * 3) Each tx pool is not allowed to allocate more than pool->max_pages
+ * from the spool, so once we're over min_pages, we can allocate
+ * pages from the spool, but not more than max_pages.
+ *
+ * When the tx code path needs to send a tx frame, it checks first
+ * if it has enough tx credits, following those rules. [iwm_tx_credit_get]
+ * If it does, it then updates the pool and spool counters and
+ * then send the frame. [iwm_tx_credit_alloc and iwm_tx_credit_dec]
+ * On the other side, when the UMAC is done transmitting frames, it
+ * will send a credit update notification to the host. This is when
+ * the pool and spool counters gets to be decreased. [iwm_tx_credit_inc,
+ * called from rx.c:iwm_ntf_tx_credit_update]
+ *
+ */
+void iwm_tx_credit_init_pools(struct iwm_priv *iwm,
+ struct iwm_umac_notif_alive *alive)
+{
+ int i, sid, pool_pages;
+
+ spin_lock(&iwm->tx_credit.lock);
+
+ iwm->tx_credit.pool_nr = le16_to_cpu(alive->page_grp_count);
+ iwm->tx_credit.full_pools_map = 0;
+ memset(&iwm->tx_credit.spools[0], 0, sizeof(struct spool_entry));
+
+ IWM_DBG_TX(iwm, DBG, "Pools number is %d\n", iwm->tx_credit.pool_nr);
+
+ for (i = 0; i < iwm->tx_credit.pool_nr; i++) {
+ __le32 page_grp_state = alive->page_grp_state[i];
+
+ iwm->tx_credit.pools[i].id = GET_VAL32(page_grp_state,
+ UMAC_ALIVE_PAGE_STS_GRP_NUM);
+ iwm->tx_credit.pools[i].sid = GET_VAL32(page_grp_state,
+ UMAC_ALIVE_PAGE_STS_SGRP_NUM);
+ iwm->tx_credit.pools[i].min_pages = GET_VAL32(page_grp_state,
+ UMAC_ALIVE_PAGE_STS_GRP_MIN_SIZE);
+ iwm->tx_credit.pools[i].max_pages = GET_VAL32(page_grp_state,
+ UMAC_ALIVE_PAGE_STS_GRP_MAX_SIZE);
+ iwm->tx_credit.pools[i].alloc_pages = 0;
+ iwm->tx_credit.pools[i].total_freed_pages = 0;
+
+ sid = iwm->tx_credit.pools[i].sid;
+ pool_pages = iwm->tx_credit.pools[i].min_pages;
+
+ if (iwm->tx_credit.spools[sid].max_pages == 0) {
+ iwm->tx_credit.spools[sid].id = sid;
+ iwm->tx_credit.spools[sid].max_pages =
+ GET_VAL32(page_grp_state,
+ UMAC_ALIVE_PAGE_STS_SGRP_MAX_SIZE);
+ iwm->tx_credit.spools[sid].alloc_pages = 0;
+ }
+
+ iwm->tx_credit.spools[sid].alloc_pages += pool_pages;
+
+ IWM_DBG_TX(iwm, DBG, "Pool idx: %d, id: %d, sid: %d, capacity "
+ "min: %d, max: %d, pool alloc: %d, total_free: %d, "
+ "super poll alloc: %d\n",
+ i, iwm->tx_credit.pools[i].id,
+ iwm->tx_credit.pools[i].sid,
+ iwm->tx_credit.pools[i].min_pages,
+ iwm->tx_credit.pools[i].max_pages,
+ iwm->tx_credit.pools[i].alloc_pages,
+ iwm->tx_credit.pools[i].total_freed_pages,
+ iwm->tx_credit.spools[sid].alloc_pages);
+ }
+
+ spin_unlock(&iwm->tx_credit.lock);
+}
+
+#define IWM_UDMA_HDR_LEN sizeof(struct iwm_umac_wifi_out_hdr)
+
+static int iwm_tx_build_packet(struct iwm_priv *iwm, struct sk_buff *skb,
+ int pool_id, u8 *buf)
+{
+ struct iwm_umac_wifi_out_hdr *hdr = (struct iwm_umac_wifi_out_hdr *)buf;
+ struct iwm_udma_wifi_cmd udma_cmd;
+ struct iwm_umac_cmd umac_cmd;
+ struct iwm_tx_info *tx_info = skb_to_tx_info(skb);
+
+ udma_cmd.count = cpu_to_le16(skb->len +
+ sizeof(struct iwm_umac_fw_cmd_hdr));
+ /* set EOP to 0 here. iwm_udma_wifi_hdr_set_eop() will be
+ * called later to set EOP for the last packet. */
+ udma_cmd.eop = 0;
+ udma_cmd.credit_group = pool_id;
+ udma_cmd.ra_tid = tx_info->sta << 4 | tx_info->tid;
+ udma_cmd.lmac_offset = 0;
+
+ umac_cmd.id = REPLY_TX;
+ umac_cmd.count = cpu_to_le16(skb->len);
+ umac_cmd.color = tx_info->color;
+ umac_cmd.resp = 0;
+ umac_cmd.seq_num = cpu_to_le16(iwm_alloc_wifi_cmd_seq(iwm));
+
+ iwm_build_udma_wifi_hdr(iwm, &hdr->hw_hdr, &udma_cmd);
+ iwm_build_umac_hdr(iwm, &hdr->sw_hdr, &umac_cmd);
+
+ memcpy(buf + sizeof(*hdr), skb->data, skb->len);
+
+ return 0;
+}
+
+static int iwm_tx_send_concat_packets(struct iwm_priv *iwm,
+ struct iwm_tx_queue *txq)
+{
+ int ret;
+
+ if (!txq->concat_count)
+ return 0;
+
+ IWM_DBG_TX(iwm, DBG, "Send concatenated Tx: queue %d, %d bytes\n",
+ txq->id, txq->concat_count);
+
+ /* mark EOP for the last packet */
+ iwm_udma_wifi_hdr_set_eop(iwm, txq->concat_ptr, 1);
+
+ ret = iwm_bus_send_chunk(iwm, txq->concat_buf, txq->concat_count);
+
+ txq->concat_count = 0;
+ txq->concat_ptr = txq->concat_buf;
+
+ return ret;
+}
+
+#define CONFIG_IWM_TX_CONCATENATED 1
+
+void iwm_tx_worker(struct work_struct *work)
+{
+ struct iwm_priv *iwm;
+ struct iwm_tx_info *tx_info = NULL;
+ struct sk_buff *skb;
+ int cmdlen, ret;
+ struct iwm_tx_queue *txq;
+ int pool_id;
+
+ txq = container_of(work, struct iwm_tx_queue, worker);
+ iwm = container_of(txq, struct iwm_priv, txq[txq->id]);
+
+ pool_id = queue_to_pool_id(txq->id);
+
+ while (!test_bit(pool_id, &iwm->tx_credit.full_pools_map) &&
+ !skb_queue_empty(&txq->queue)) {
+
+ skb = skb_dequeue(&txq->queue);
+ tx_info = skb_to_tx_info(skb);
+ cmdlen = IWM_UDMA_HDR_LEN + skb->len;
+
+ IWM_DBG_TX(iwm, DBG, "Tx frame on queue %d: skb: 0x%p, sta: "
+ "%d, color: %d\n", txq->id, skb, tx_info->sta,
+ tx_info->color);
+
+#if !CONFIG_IWM_TX_CONCATENATED
+ /* temporarily keep this to comparing the performance */
+ ret = iwm_send_packet(iwm, skb, pool_id);
+#else
+
+ if (txq->concat_count + cmdlen > IWM_HAL_CONCATENATE_BUF_SIZE)
+ iwm_tx_send_concat_packets(iwm, txq);
+
+ ret = iwm_tx_credit_alloc(iwm, pool_id, cmdlen);
+ if (ret) {
+ IWM_DBG_TX(iwm, DBG, "not enough tx_credit for queue "
+ "%d, Tx worker stopped\n", txq->id);
+ skb_queue_head(&txq->queue, skb);
+ break;
+ }
+
+ txq->concat_ptr = txq->concat_buf + txq->concat_count;
+ iwm_tx_build_packet(iwm, skb, pool_id, txq->concat_ptr);
+ txq->concat_count += ALIGN(cmdlen, 16);
+#endif
+ kfree_skb(skb);
+ }
+
+ iwm_tx_send_concat_packets(iwm, txq);
+
+ if (__netif_subqueue_stopped(iwm_to_ndev(iwm), txq->id) &&
+ !test_bit(pool_id, &iwm->tx_credit.full_pools_map) &&
+ (skb_queue_len(&txq->queue) < IWM_TX_LIST_SIZE / 2)) {
+ IWM_DBG_TX(iwm, DBG, "LINK: start netif_subqueue[%d]", txq->id);
+ netif_wake_subqueue(iwm_to_ndev(iwm), txq->id);
+ }
+}
+
+int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(netdev);
+ struct net_device *ndev = iwm_to_ndev(iwm);
+ struct wireless_dev *wdev = iwm_to_wdev(iwm);
+ u8 *dst_addr;
+ struct iwm_tx_info *tx_info;
+ struct iwm_tx_queue *txq;
+ struct iwm_sta_info *sta_info;
+ u8 sta_id;
+ u16 queue;
+ int ret;
+
+ if (!test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)) {
+ IWM_DBG_TX(iwm, DBG, "LINK: stop netif_all_queues: "
+ "not associated\n");
+ netif_tx_stop_all_queues(netdev);
+ goto drop;
+ }
+
+ queue = skb_get_queue_mapping(skb);
+ BUG_ON(queue >= IWM_TX_DATA_QUEUES); /* no iPAN yet */
+
+ txq = &iwm->txq[queue];
+
+ /* No free space for Tx, tx_worker is too slow */
+ if (skb_queue_len(&txq->queue) > IWM_TX_LIST_SIZE) {
+ IWM_DBG_TX(iwm, DBG, "LINK: stop netif_subqueue[%d]\n", queue);
+ netif_stop_subqueue(netdev, queue);
+ return NETDEV_TX_BUSY;
+ }
+
+ ret = ieee80211_data_from_8023(skb, netdev->dev_addr, wdev->iftype,
+ iwm->bssid, 0);
+ if (ret) {
+ IWM_ERR(iwm, "build wifi header failed\n");
+ goto drop;
+ }
+
+ dst_addr = ((struct ieee80211_hdr *)(skb->data))->addr1;
+
+ for (sta_id = 0; sta_id < IWM_STA_TABLE_NUM; sta_id++) {
+ sta_info = &iwm->sta_table[sta_id];
+ if (sta_info->valid &&
+ !memcmp(dst_addr, sta_info->addr, ETH_ALEN))
+ break;
+ }
+
+ if (sta_id == IWM_STA_TABLE_NUM) {
+ IWM_ERR(iwm, "STA %pM not found in sta_table, Tx ignored\n",
+ dst_addr);
+ goto drop;
+ }
+
+ tx_info = skb_to_tx_info(skb);
+ tx_info->sta = sta_id;
+ tx_info->color = sta_info->color;
+ /* UMAC uses TID 8 (vs. 0) for non QoS packets */
+ if (sta_info->qos)
+ tx_info->tid = skb->priority;
+ else
+ tx_info->tid = IWM_UMAC_MGMT_TID;
+
+ skb_queue_tail(&iwm->txq[queue].queue, skb);
+
+ queue_work(iwm->txq[queue].wq, &iwm->txq[queue].worker);
+
+ ndev->stats.tx_packets++;
+ ndev->stats.tx_bytes += skb->len;
+ return NETDEV_TX_OK;
+
+ drop:
+ ndev->stats.tx_dropped++;
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+}
diff --git a/drivers/net/wireless/iwmc3200wifi/umac.h b/drivers/net/wireless/iwmc3200wifi/umac.h
new file mode 100644
index 000000000000..4a95cce1f0a6
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/umac.h
@@ -0,0 +1,744 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ */
+
+#ifndef __IWM_UMAC_H__
+#define __IWM_UMAC_H__
+
+struct iwm_udma_in_hdr {
+ __le32 cmd;
+ __le32 size;
+} __attribute__ ((packed));
+
+struct iwm_udma_out_nonwifi_hdr {
+ __le32 cmd;
+ __le32 addr;
+ __le32 op1_sz;
+ __le32 op2;
+} __attribute__ ((packed));
+
+struct iwm_udma_out_wifi_hdr {
+ __le32 cmd;
+ __le32 meta_data;
+} __attribute__ ((packed));
+
+/* Sequence numbering */
+#define UMAC_WIFI_SEQ_NUM_BASE 1
+#define UMAC_WIFI_SEQ_NUM_MAX 0x4000
+#define UMAC_NONWIFI_SEQ_NUM_BASE 1
+#define UMAC_NONWIFI_SEQ_NUM_MAX 0x10
+
+/* MAC address address */
+#define WICO_MAC_ADDRESS_ADDR 0x604008F8
+
+/* RA / TID */
+#define UMAC_HDI_ACT_TBL_IDX_TID_POS 0
+#define UMAC_HDI_ACT_TBL_IDX_TID_SEED 0xF
+
+#define UMAC_HDI_ACT_TBL_IDX_RA_POS 4
+#define UMAC_HDI_ACT_TBL_IDX_RA_SEED 0xF
+
+#define UMAC_HDI_ACT_TBL_IDX_RA_UMAC 0xF
+#define UMAC_HDI_ACT_TBL_IDX_TID_UMAC 0x9
+#define UMAC_HDI_ACT_TBL_IDX_TID_LMAC 0xA
+
+#define UMAC_HDI_ACT_TBL_IDX_HOST_CMD \
+ ((UMAC_HDI_ACT_TBL_IDX_RA_UMAC << UMAC_HDI_ACT_TBL_IDX_RA_POS) |\
+ (UMAC_HDI_ACT_TBL_IDX_TID_UMAC << UMAC_HDI_ACT_TBL_IDX_TID_POS))
+#define UMAC_HDI_ACT_TBL_IDX_UMAC_CMD \
+ ((UMAC_HDI_ACT_TBL_IDX_RA_UMAC << UMAC_HDI_ACT_TBL_IDX_RA_POS) |\
+ (UMAC_HDI_ACT_TBL_IDX_TID_LMAC << UMAC_HDI_ACT_TBL_IDX_TID_POS))
+
+/* iwm_umac_notif_alive.page_grp_state Group number -- bits [3:0] */
+#define UMAC_ALIVE_PAGE_STS_GRP_NUM_POS 0
+#define UMAC_ALIVE_PAGE_STS_GRP_NUM_SEED 0xF
+
+/* iwm_umac_notif_alive.page_grp_state Super group number -- bits [7:4] */
+#define UMAC_ALIVE_PAGE_STS_SGRP_NUM_POS 4
+#define UMAC_ALIVE_PAGE_STS_SGRP_NUM_SEED 0xF
+
+/* iwm_umac_notif_alive.page_grp_state Group min size -- bits [15:8] */
+#define UMAC_ALIVE_PAGE_STS_GRP_MIN_SIZE_POS 8
+#define UMAC_ALIVE_PAGE_STS_GRP_MIN_SIZE_SEED 0xFF
+
+/* iwm_umac_notif_alive.page_grp_state Group max size -- bits [23:16] */
+#define UMAC_ALIVE_PAGE_STS_GRP_MAX_SIZE_POS 16
+#define UMAC_ALIVE_PAGE_STS_GRP_MAX_SIZE_SEED 0xFF
+
+/* iwm_umac_notif_alive.page_grp_state Super group max size -- bits [31:24] */
+#define UMAC_ALIVE_PAGE_STS_SGRP_MAX_SIZE_POS 24
+#define UMAC_ALIVE_PAGE_STS_SGRP_MAX_SIZE_SEED 0xFF
+
+/* Barkers */
+#define UMAC_REBOOT_BARKER 0xdeadbeef
+#define UMAC_ACK_BARKER 0xfeedbabe
+#define UMAC_PAD_TERMINAL 0xadadadad
+
+/* UMAC JMP address */
+#define UMAC_MU_FW_INST_DATA_12_ADDR 0xBF0000
+
+/* iwm_umac_hdi_out_hdr.cmd OP code -- bits [3:0] */
+#define UMAC_HDI_OUT_CMD_OPCODE_POS 0
+#define UMAC_HDI_OUT_CMD_OPCODE_SEED 0xF
+
+/* iwm_umac_hdi_out_hdr.cmd End-Of-Transfer -- bits [10:10] */
+#define UMAC_HDI_OUT_CMD_EOT_POS 10
+#define UMAC_HDI_OUT_CMD_EOT_SEED 0x1
+
+/* iwm_umac_hdi_out_hdr.cmd UTFD only usage -- bits [11:11] */
+#define UMAC_HDI_OUT_CMD_UTFD_ONLY_POS 11
+#define UMAC_HDI_OUT_CMD_UTFD_ONLY_SEED 0x1
+
+/* iwm_umac_hdi_out_hdr.cmd Non-WiFi HW sequence number -- bits [12:15] */
+#define UDMA_HDI_OUT_CMD_NON_WIFI_HW_SEQ_NUM_POS 12
+#define UDMA_HDI_OUT_CMD_NON_WIFI_HW_SEQ_NUM_SEED 0xF
+
+/* iwm_umac_hdi_out_hdr.cmd Signature -- bits [31:16] */
+#define UMAC_HDI_OUT_CMD_SIGNATURE_POS 16
+#define UMAC_HDI_OUT_CMD_SIGNATURE_SEED 0xFFFF
+
+/* iwm_umac_hdi_out_hdr.meta_data Byte count -- bits [11:0] */
+#define UMAC_HDI_OUT_BYTE_COUNT_POS 0
+#define UMAC_HDI_OUT_BYTE_COUNT_SEED 0xFFF
+
+/* iwm_umac_hdi_out_hdr.meta_data Credit group -- bits [15:12] */
+#define UMAC_HDI_OUT_CREDIT_GRP_POS 12
+#define UMAC_HDI_OUT_CREDIT_GRP_SEED 0xF
+
+/* iwm_umac_hdi_out_hdr.meta_data RA/TID -- bits [23:16] */
+#define UMAC_HDI_OUT_RATID_POS 16
+#define UMAC_HDI_OUT_RATID_SEED 0xFF
+
+/* iwm_umac_hdi_out_hdr.meta_data LMAC offset -- bits [31:24] */
+#define UMAC_HDI_OUT_LMAC_OFFSET_POS 24
+#define UMAC_HDI_OUT_LMAC_OFFSET_SEED 0xFF
+
+/* Signature */
+#define UMAC_HDI_OUT_SIGNATURE 0xCBBC
+
+/* buffer alignment */
+#define UMAC_HDI_BUF_ALIGN_MSK 0xF
+
+/* iwm_umac_hdi_in_hdr.cmd OP code -- bits [3:0] */
+#define UMAC_HDI_IN_CMD_OPCODE_POS 0
+#define UMAC_HDI_IN_CMD_OPCODE_SEED 0xF
+
+/* iwm_umac_hdi_in_hdr.cmd Non-WiFi API response -- bits [6:4] */
+#define UMAC_HDI_IN_CMD_NON_WIFI_RESP_POS 4
+#define UMAC_HDI_IN_CMD_NON_WIFI_RESP_SEED 0x7
+
+/* iwm_umac_hdi_in_hdr.cmd WiFi API source -- bits [5:4] */
+#define UMAC_HDI_IN_CMD_SOURCE_POS 4
+#define UMAC_HDI_IN_CMD_SOURCE_SEED 0x3
+
+/* iwm_umac_hdi_in_hdr.cmd WiFi API EOT -- bits [6:6] */
+#define UMAC_HDI_IN_CMD_EOT_POS 6
+#define UMAC_HDI_IN_CMD_EOT_SEED 0x1
+
+/* iwm_umac_hdi_in_hdr.cmd timestamp present -- bits [7:7] */
+#define UMAC_HDI_IN_CMD_TIME_STAMP_PRESENT_POS 7
+#define UMAC_HDI_IN_CMD_TIME_STAMP_PRESENT_SEED 0x1
+
+/* iwm_umac_hdi_in_hdr.cmd WiFi Non-last AMSDU -- bits [8:8] */
+#define UMAC_HDI_IN_CMD_NON_LAST_AMSDU_POS 8
+#define UMAC_HDI_IN_CMD_NON_LAST_AMSDU_SEED 0x1
+
+/* iwm_umac_hdi_in_hdr.cmd WiFi HW sequence number -- bits [31:9] */
+#define UMAC_HDI_IN_CMD_HW_SEQ_NUM_POS 9
+#define UMAC_HDI_IN_CMD_HW_SEQ_NUM_SEED 0x7FFFFF
+
+/* iwm_umac_hdi_in_hdr.cmd Non-WiFi HW sequence number -- bits [12:15] */
+#define UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM_POS 12
+#define UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM_SEED 0xF
+
+/* iwm_umac_hdi_in_hdr.cmd Non-WiFi HW signature -- bits [16:31] */
+#define UDMA_HDI_IN_CMD_NON_WIFI_HW_SIG_POS 16
+#define UDMA_HDI_IN_CMD_NON_WIFI_HW_SIG_SEED 0xFFFF
+
+/* Fixed Non-WiFi signature */
+#define UDMA_HDI_IN_CMD_NON_WIFI_HW_SIG 0xCBBC
+
+/* IN NTFY op-codes */
+#define UMAC_NOTIFY_OPCODE_ALIVE 0xA1
+#define UMAC_NOTIFY_OPCODE_INIT_COMPLETE 0xA2
+#define UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS 0xA3
+#define UMAC_NOTIFY_OPCODE_ERROR 0xA4
+#define UMAC_NOTIFY_OPCODE_DEBUG 0xA5
+#define UMAC_NOTIFY_OPCODE_WIFI_IF_WRAPPER 0xB0
+#define UMAC_NOTIFY_OPCODE_STATS 0xB1
+#define UMAC_NOTIFY_OPCODE_PAGE_DEALLOC 0xB3
+#define UMAC_NOTIFY_OPCODE_RX_TICKET 0xB4
+#define UMAC_NOTIFY_OPCODE_MAX (UMAC_NOTIFY_OPCODE_RX_TICKET -\
+ UMAC_NOTIFY_OPCODE_ALIVE + 1)
+#define UMAC_NOTIFY_OPCODE_FIRST (UMAC_NOTIFY_OPCODE_ALIVE)
+
+/* HDI OUT OP CODE */
+#define UMAC_HDI_OUT_OPCODE_PING 0x0
+#define UMAC_HDI_OUT_OPCODE_READ 0x1
+#define UMAC_HDI_OUT_OPCODE_WRITE 0x2
+#define UMAC_HDI_OUT_OPCODE_JUMP 0x3
+#define UMAC_HDI_OUT_OPCODE_REBOOT 0x4
+#define UMAC_HDI_OUT_OPCODE_WRITE_PERSISTENT 0x5
+#define UMAC_HDI_OUT_OPCODE_READ_PERSISTENT 0x6
+#define UMAC_HDI_OUT_OPCODE_READ_MODIFY_WRITE 0x7
+/* #define UMAC_HDI_OUT_OPCODE_RESERVED 0x8..0xA */
+#define UMAC_HDI_OUT_OPCODE_WRITE_AUX_REG 0xB
+#define UMAC_HDI_OUT_OPCODE_WIFI 0xF
+
+/* HDI IN OP CODE -- Non WiFi*/
+#define UMAC_HDI_IN_OPCODE_PING 0x0
+#define UMAC_HDI_IN_OPCODE_READ 0x1
+#define UMAC_HDI_IN_OPCODE_WRITE 0x2
+#define UMAC_HDI_IN_OPCODE_WRITE_PERSISTENT 0x5
+#define UMAC_HDI_IN_OPCODE_READ_PERSISTENT 0x6
+#define UMAC_HDI_IN_OPCODE_READ_MODIFY_WRITE 0x7
+#define UMAC_HDI_IN_OPCODE_EP_MGMT 0x8
+#define UMAC_HDI_IN_OPCODE_CREDIT_CHANGE 0x9
+#define UMAC_HDI_IN_OPCODE_CTRL_DATABASE 0xA
+#define UMAC_HDI_IN_OPCODE_WRITE_AUX_REG 0xB
+#define UMAC_HDI_IN_OPCODE_NONWIFI_MAX \
+ (UMAC_HDI_IN_OPCODE_WRITE_AUX_REG + 1)
+#define UMAC_HDI_IN_OPCODE_WIFI 0xF
+
+/* HDI IN SOURCE */
+#define UMAC_HDI_IN_SOURCE_FHRX 0x0
+#define UMAC_HDI_IN_SOURCE_UDMA 0x1
+#define UMAC_HDI_IN_SOURCE_FW 0x2
+#define UMAC_HDI_IN_SOURCE_RESERVED 0x3
+
+/* OUT CMD op-codes */
+#define UMAC_CMD_OPCODE_ECHO 0x01
+#define UMAC_CMD_OPCODE_HALT 0x02
+#define UMAC_CMD_OPCODE_RESET 0x03
+#define UMAC_CMD_OPCODE_BULK_EP_INACT_TIMEOUT 0x09
+#define UMAC_CMD_OPCODE_URB_CANCEL_ACK 0x0A
+#define UMAC_CMD_OPCODE_DCACHE_FLUSH 0x0B
+#define UMAC_CMD_OPCODE_EEPROM_PROXY 0x0C
+#define UMAC_CMD_OPCODE_TX_ECHO 0x0D
+#define UMAC_CMD_OPCODE_DBG_MON 0x0E
+#define UMAC_CMD_OPCODE_INTERNAL_TX 0x0F
+#define UMAC_CMD_OPCODE_SET_PARAM_FIX 0x10
+#define UMAC_CMD_OPCODE_SET_PARAM_VAR 0x11
+#define UMAC_CMD_OPCODE_GET_PARAM 0x12
+#define UMAC_CMD_OPCODE_DBG_EVENT_WRAPPER 0x13
+#define UMAC_CMD_OPCODE_TARGET 0x14
+#define UMAC_CMD_OPCODE_STATISTIC_REQUEST 0x15
+#define UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST 0x16
+#define UMAC_CMD_OPCODE_SET_PARAM_LIST 0x17
+#define UMAC_CMD_OPCODE_GET_PARAM_LIST 0x18
+#define UMAC_CMD_OPCODE_BASE_WRAPPER 0xFA
+#define UMAC_CMD_OPCODE_LMAC_WRAPPER 0xFB
+#define UMAC_CMD_OPCODE_HW_TEST_WRAPPER 0xFC
+#define UMAC_CMD_OPCODE_WIFI_IF_WRAPPER 0xFD
+#define UMAC_CMD_OPCODE_WIFI_WRAPPER 0xFE
+#define UMAC_CMD_OPCODE_WIFI_PASS_THROUGH 0xFF
+
+/* UMAC WiFi interface op-codes */
+#define UMAC_WIFI_IF_CMD_SET_PROFILE 0x11
+#define UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE 0x12
+#define UMAC_WIFI_IF_CMD_SET_EXCLUDE_LIST 0x13
+#define UMAC_WIFI_IF_CMD_SCAN_REQUEST 0x14
+#define UMAC_WIFI_IF_CMD_SCAN_CONFIG 0x15
+#define UMAC_WIFI_IF_CMD_ADD_WEP40_KEY 0x16
+#define UMAC_WIFI_IF_CMD_ADD_WEP104_KEY 0x17
+#define UMAC_WIFI_IF_CMD_ADD_TKIP_KEY 0x18
+#define UMAC_WIFI_IF_CMD_ADD_CCMP_KEY 0x19
+#define UMAC_WIFI_IF_CMD_REMOVE_KEY 0x1A
+#define UMAC_WIFI_IF_CMD_GLOBAL_TX_KEY_ID 0x1B
+#define UMAC_WIFI_IF_CMD_SET_HOST_EXTENDED_IE 0x1C
+#define UMAC_WIFI_IF_CMD_GET_SUPPORTED_CHANNELS 0x1E
+#define UMAC_WIFI_IF_CMD_TX_PWR_TRIGGER 0x20
+
+/* UMAC WiFi interface ports */
+#define UMAC_WIFI_IF_FLG_PORT_DEF 0x00
+#define UMAC_WIFI_IF_FLG_PORT_PAN 0x01
+#define UMAC_WIFI_IF_FLG_PORT_PAN_INVALID WIFI_IF_FLG_PORT_DEF
+
+/* UMAC WiFi interface actions */
+#define UMAC_WIFI_IF_FLG_ACT_GET 0x10
+#define UMAC_WIFI_IF_FLG_ACT_SET 0x20
+
+/* iwm_umac_fw_cmd_hdr.meta_data byte count -- bits [11:0] */
+#define UMAC_FW_CMD_BYTE_COUNT_POS 0
+#define UMAC_FW_CMD_BYTE_COUNT_SEED 0xFFF
+
+/* iwm_umac_fw_cmd_hdr.meta_data status -- bits [15:12] */
+#define UMAC_FW_CMD_STATUS_POS 12
+#define UMAC_FW_CMD_STATUS_SEED 0xF
+
+/* iwm_umac_fw_cmd_hdr.meta_data full TX command by Driver -- bits [16:16] */
+#define UMAC_FW_CMD_TX_DRV_FULL_CMD_POS 16
+#define UMAC_FW_CMD_TX_DRV_FULL_CMD_SEED 0x1
+
+/* iwm_umac_fw_cmd_hdr.meta_data TX command by FW -- bits [17:17] */
+#define UMAC_FW_CMD_TX_FW_CMD_POS 17
+#define UMAC_FW_CMD_TX_FW_CMD_SEED 0x1
+
+/* iwm_umac_fw_cmd_hdr.meta_data TX plaintext mode -- bits [18:18] */
+#define UMAC_FW_CMD_TX_PLAINTEXT_POS 18
+#define UMAC_FW_CMD_TX_PLAINTEXT_SEED 0x1
+
+/* iwm_umac_fw_cmd_hdr.meta_data STA color -- bits [22:20] */
+#define UMAC_FW_CMD_TX_STA_COLOR_POS 20
+#define UMAC_FW_CMD_TX_STA_COLOR_SEED 0x7
+
+/* iwm_umac_fw_cmd_hdr.meta_data TX life time (TU) -- bits [31:24] */
+#define UMAC_FW_CMD_TX_LIFETIME_TU_POS 24
+#define UMAC_FW_CMD_TX_LIFETIME_TU_SEED 0xFF
+
+/* iwm_dev_cmd_hdr.flags Response required -- bits [5:5] */
+#define UMAC_DEV_CMD_FLAGS_RESP_REQ_POS 5
+#define UMAC_DEV_CMD_FLAGS_RESP_REQ_SEED 0x1
+
+/* iwm_dev_cmd_hdr.flags Aborted command -- bits [6:6] */
+#define UMAC_DEV_CMD_FLAGS_ABORT_POS 6
+#define UMAC_DEV_CMD_FLAGS_ABORT_SEED 0x1
+
+/* iwm_dev_cmd_hdr.flags Internal command -- bits [7:7] */
+#define DEV_CMD_FLAGS_FLD_INTERNAL_POS 7
+#define DEV_CMD_FLAGS_FLD_INTERNAL_SEED 0x1
+
+/* Rx */
+/* Rx actions */
+#define IWM_RX_TICKET_DROP 0x0
+#define IWM_RX_TICKET_RELEASE 0x1
+#define IWM_RX_TICKET_SNIFFER 0x2
+#define IWM_RX_TICKET_ENQUEUE 0x3
+
+/* Rx flags */
+#define IWM_RX_TICKET_PAD_SIZE_MSK 0x2
+#define IWM_RX_TICKET_SPECIAL_SNAP_MSK 0x4
+#define IWM_RX_TICKET_AMSDU_MSK 0x8
+#define IWM_RX_TICKET_DROP_REASON_POS 4
+#define IWM_RX_TICKET_DROP_REASON_MSK (0x1F << RX_TICKET_FLAGS_DROP_REASON_POS)
+
+#define IWM_RX_DROP_NO_DROP 0x0
+#define IWM_RX_DROP_BAD_CRC 0x1
+/* L2P no address match */
+#define IWM_RX_DROP_LMAC_ADDR_FILTER 0x2
+/* Multicast address not in list */
+#define IWM_RX_DROP_MCAST_ADDR_FILTER 0x3
+/* Control frames are not sent to the driver */
+#define IWM_RX_DROP_CTL_FRAME 0x4
+/* Our frame is back */
+#define IWM_RX_DROP_OUR_TX 0x5
+/* Association class filtering */
+#define IWM_RX_DROP_CLASS_FILTER 0x6
+/* Duplicated frame */
+#define IWM_RX_DROP_DUPLICATE_FILTER 0x7
+/* Decryption error */
+#define IWM_RX_DROP_SEC_ERR 0x8
+/* Unencrypted frame while encryption is on */
+#define IWM_RX_DROP_SEC_NO_ENCRYPTION 0x9
+/* Replay check failure */
+#define IWM_RX_DROP_SEC_REPLAY_ERR 0xa
+/* uCode and FW key color mismatch, check before replay */
+#define IWM_RX_DROP_SEC_KEY_COLOR_MISMATCH 0xb
+#define IWM_RX_DROP_SEC_TKIP_COUNTER_MEASURE 0xc
+/* No fragmentations Db is found */
+#define IWM_RX_DROP_FRAG_NO_RESOURCE 0xd
+/* Fragmention Db has seqCtl mismatch Vs. non-1st frag */
+#define IWM_RX_DROP_FRAG_ERR 0xe
+#define IWM_RX_DROP_FRAG_LOST 0xf
+#define IWM_RX_DROP_FRAG_COMPLETE 0x10
+/* Should be handled by UMAC */
+#define IWM_RX_DROP_MANAGEMENT 0x11
+/* STA not found by UMAC */
+#define IWM_RX_DROP_NO_STATION 0x12
+/* NULL or QoS NULL */
+#define IWM_RX_DROP_NULL_DATA 0x13
+#define IWM_RX_DROP_BA_REORDER_OLD_SEQCTL 0x14
+#define IWM_RX_DROP_BA_REORDER_DUPLICATE 0x15
+
+struct iwm_rx_ticket {
+ __le16 action;
+ __le16 id;
+ __le16 flags;
+ u8 payload_offset; /* includes: MAC header, pad, IV */
+ u8 tail_len; /* includes: MIC, ICV, CRC (w/o STATUS) */
+} __attribute__ ((packed));
+
+struct iwm_rx_mpdu_hdr {
+ __le16 len;
+ __le16 reserved;
+} __attribute__ ((packed));
+
+/* UMAC SW WIFI API */
+
+struct iwm_dev_cmd_hdr {
+ u8 cmd;
+ u8 flags;
+ __le16 seq_num;
+} __attribute__ ((packed));
+
+struct iwm_umac_fw_cmd_hdr {
+ __le32 meta_data;
+ struct iwm_dev_cmd_hdr cmd;
+} __attribute__ ((packed));
+
+struct iwm_umac_wifi_out_hdr {
+ struct iwm_udma_out_wifi_hdr hw_hdr;
+ struct iwm_umac_fw_cmd_hdr sw_hdr;
+} __attribute__ ((packed));
+
+struct iwm_umac_nonwifi_out_hdr {
+ struct iwm_udma_out_nonwifi_hdr hw_hdr;
+} __attribute__ ((packed));
+
+struct iwm_umac_wifi_in_hdr {
+ struct iwm_udma_in_hdr hw_hdr;
+ struct iwm_umac_fw_cmd_hdr sw_hdr;
+} __attribute__ ((packed));
+
+struct iwm_umac_nonwifi_in_hdr {
+ struct iwm_udma_in_hdr hw_hdr;
+ __le32 time_stamp;
+} __attribute__ ((packed));
+
+#define IWM_UMAC_PAGE_SIZE 0x200
+
+/* Notify structures */
+struct iwm_fw_version {
+ u8 minor;
+ u8 major;
+ __le16 id;
+};
+
+struct iwm_fw_build {
+ u8 type;
+ u8 subtype;
+ u8 platform;
+ u8 opt;
+};
+
+struct iwm_fw_alive_hdr {
+ struct iwm_fw_version ver;
+ struct iwm_fw_build build;
+ __le32 os_build;
+ __le32 log_hdr_addr;
+ __le32 log_buf_addr;
+ __le32 sys_timer_addr;
+};
+
+#define WAIT_NOTIF_TIMEOUT (2 * HZ)
+#define SCAN_COMPLETE_TIMEOUT (3 * HZ)
+
+#define UMAC_NTFY_ALIVE_STATUS_ERR 0xDEAD
+#define UMAC_NTFY_ALIVE_STATUS_OK 0xCAFE
+
+#define UMAC_NTFY_INIT_COMPLETE_STATUS_ERR 0xDEAD
+#define UMAC_NTFY_INIT_COMPLETE_STATUS_OK 0xCAFE
+
+#define UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN 0x40
+#define UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN 0x80
+
+#define IWM_MACS_OUT_GROUPS 6
+#define IWM_MACS_OUT_SGROUPS 1
+
+
+#define WIFI_IF_NTFY_ASSOC_START 0x80
+#define WIFI_IF_NTFY_ASSOC_COMPLETE 0x81
+#define WIFI_IF_NTFY_PROFILE_INVALIDATE_COMPLETE 0x82
+#define WIFI_IF_NTFY_CONNECTION_TERMINATED 0x83
+#define WIFI_IF_NTFY_SCAN_COMPLETE 0x84
+#define WIFI_IF_NTFY_STA_TABLE_CHANGE 0x85
+#define WIFI_IF_NTFY_EXTENDED_IE_REQUIRED 0x86
+#define WIFI_IF_NTFY_RADIO_PREEMPTION 0x87
+#define WIFI_IF_NTFY_BSS_TRK_TABLE_CHANGED 0x88
+#define WIFI_IF_NTFY_BSS_TRK_ENTRIES_REMOVED 0x89
+#define WIFI_IF_NTFY_LINK_QUALITY_STATISTICS 0x8A
+#define WIFI_IF_NTFY_MGMT_FRAME 0x8B
+
+/* DEBUG INDICATIONS */
+#define WIFI_DBG_IF_NTFY_SCAN_SUPER_JOB_START 0xE0
+#define WIFI_DBG_IF_NTFY_SCAN_SUPER_JOB_COMPLETE 0xE1
+#define WIFI_DBG_IF_NTFY_SCAN_CHANNEL_START 0xE2
+#define WIFI_DBG_IF_NTFY_SCAN_CHANNEL_RESULT 0xE3
+#define WIFI_DBG_IF_NTFY_SCAN_MINI_JOB_START 0xE4
+#define WIFI_DBG_IF_NTFY_SCAN_MINI_JOB_COMPLETE 0xE5
+#define WIFI_DBG_IF_NTFY_CNCT_ATC_START 0xE6
+#define WIFI_DBG_IF_NTFY_COEX_NOTIFICATION 0xE7
+#define WIFI_DBG_IF_NTFY_COEX_HANDLE_ENVELOP 0xE8
+#define WIFI_DBG_IF_NTFY_COEX_HANDLE_RELEASE_ENVELOP 0xE9
+
+/* Notification structures */
+struct iwm_umac_notif_wifi_if {
+ struct iwm_umac_wifi_in_hdr hdr;
+ u8 status;
+ u8 flags;
+ __le16 buf_size;
+} __attribute__ ((packed));
+
+#define UMAC_ROAM_REASON_FIRST_SELECTION 0x1
+#define UMAC_ROAM_REASON_AP_DEAUTH 0x2
+#define UMAC_ROAM_REASON_AP_CONNECT_LOST 0x3
+#define UMAC_ROAM_REASON_RSSI 0x4
+#define UMAC_ROAM_REASON_AP_ASSISTED_ROAM 0x5
+#define UMAC_ROAM_REASON_IBSS_COALESCING 0x6
+
+struct iwm_umac_notif_assoc_start {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 roam_reason;
+ u8 bssid[ETH_ALEN];
+ u8 reserved[2];
+} __attribute__ ((packed));
+
+#define UMAC_ASSOC_COMPLETE_SUCCESS 0x0
+#define UMAC_ASSOC_COMPLETE_FAILURE 0x1
+
+struct iwm_umac_notif_assoc_complete {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 status;
+ u8 bssid[ETH_ALEN];
+ u8 band;
+ u8 channel;
+} __attribute__ ((packed));
+
+#define UMAC_PROFILE_INVALID_ASSOC_TIMEOUT 0x0
+#define UMAC_PROFILE_INVALID_ROAM_TIMEOUT 0x1
+#define UMAC_PROFILE_INVALID_REQUEST 0x2
+#define UMAC_PROFILE_INVALID_RF_PREEMPTED 0x3
+
+struct iwm_umac_notif_profile_invalidate {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 reason;
+} __attribute__ ((packed));
+
+#define UMAC_SCAN_RESULT_SUCCESS 0x0
+#define UMAC_SCAN_RESULT_ABORTED 0x1
+#define UMAC_SCAN_RESULT_REJECTED 0x2
+#define UMAC_SCAN_RESULT_FAILED 0x3
+
+struct iwm_umac_notif_scan_complete {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 type;
+ __le32 result;
+ u8 seq_num;
+} __attribute__ ((packed));
+
+#define UMAC_OPCODE_ADD_MODIFY 0x0
+#define UMAC_OPCODE_REMOVE 0x1
+#define UMAC_OPCODE_CLEAR_ALL 0x2
+
+#define UMAC_STA_FLAG_QOS 0x1
+
+struct iwm_umac_notif_sta_info {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 opcode;
+ u8 mac_addr[ETH_ALEN];
+ u8 sta_id; /* bits 0-3: station ID, bits 4-7: station color */
+ u8 flags;
+} __attribute__ ((packed));
+
+#define UMAC_BAND_2GHZ 0
+#define UMAC_BAND_5GHZ 1
+
+#define UMAC_CHANNEL_WIDTH_20MHZ 0
+#define UMAC_CHANNEL_WIDTH_40MHZ 1
+
+struct iwm_umac_notif_bss_info {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 type;
+ __le32 timestamp;
+ __le16 table_idx;
+ __le16 frame_len;
+ u8 band;
+ u8 channel;
+ s8 rssi;
+ u8 reserved;
+ u8 frame_buf[1];
+} __attribute__ ((packed));
+
+#define IWM_BSS_REMOVE_INDEX_MSK 0x0fff
+#define IWM_BSS_REMOVE_FLAGS_MSK 0xfc00
+
+#define IWM_BSS_REMOVE_FLG_AGE 0x1000
+#define IWM_BSS_REMOVE_FLG_TIMEOUT 0x2000
+#define IWM_BSS_REMOVE_FLG_TABLE_FULL 0x4000
+
+struct iwm_umac_notif_bss_removed {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le32 count;
+ __le16 entries[0];
+} __attribute__ ((packed));
+
+struct iwm_umac_notif_mgt_frame {
+ struct iwm_umac_notif_wifi_if mlme_hdr;
+ __le16 len;
+ u8 frame[1];
+} __attribute__ ((packed));
+
+struct iwm_umac_notif_alive {
+ struct iwm_umac_wifi_in_hdr hdr;
+ __le16 status;
+ __le16 reserved1;
+ struct iwm_fw_alive_hdr alive_data;
+ __le16 reserved2;
+ __le16 page_grp_count;
+ __le32 page_grp_state[IWM_MACS_OUT_GROUPS];
+} __attribute__ ((packed));
+
+struct iwm_umac_notif_init_complete {
+ __le16 status;
+ __le16 reserved;
+} __attribute__ ((packed));
+
+/* error categories */
+enum {
+ UMAC_SYS_ERR_CAT_NONE = 0,
+ UMAC_SYS_ERR_CAT_BOOT,
+ UMAC_SYS_ERR_CAT_UMAC,
+ UMAC_SYS_ERR_CAT_UAXM,
+ UMAC_SYS_ERR_CAT_LMAC,
+ UMAC_SYS_ERR_CAT_MAX
+};
+
+struct iwm_fw_error_hdr {
+ __le32 category;
+ __le32 status;
+ __le32 pc;
+ __le32 blink1;
+ __le32 blink2;
+ __le32 ilink1;
+ __le32 ilink2;
+ __le32 data1;
+ __le32 data2;
+ __le32 line_num;
+ __le32 umac_status;
+ __le32 lmac_status;
+ __le32 sdio_status;
+} __attribute__ ((packed));
+
+struct iwm_umac_notif_error {
+ struct iwm_umac_wifi_in_hdr hdr;
+ struct iwm_fw_error_hdr err;
+} __attribute__ ((packed));
+
+#define UMAC_DEALLOC_NTFY_CHANGES_CNT_POS 0
+#define UMAC_DEALLOC_NTFY_CHANGES_CNT_SEED 0xff
+#define UMAC_DEALLOC_NTFY_CHANGES_MSK_POS 8
+#define UMAC_DEALLOC_NTFY_CHANGES_MSK_SEED 0xffffff
+#define UMAC_DEALLOC_NTFY_PAGE_CNT_POS 0
+#define UMAC_DEALLOC_NTFY_PAGE_CNT_SEED 0xffffff
+#define UMAC_DEALLOC_NTFY_GROUP_NUM_POS 24
+#define UMAC_DEALLOC_NTFY_GROUP_NUM_SEED 0xf
+
+struct iwm_umac_notif_page_dealloc {
+ struct iwm_umac_wifi_in_hdr hdr;
+ __le32 changes;
+ __le32 grp_info[IWM_MACS_OUT_GROUPS];
+} __attribute__ ((packed));
+
+struct iwm_umac_notif_wifi_status {
+ struct iwm_umac_wifi_in_hdr hdr;
+ __le16 status;
+ __le16 reserved;
+} __attribute__ ((packed));
+
+struct iwm_umac_notif_rx_ticket {
+ struct iwm_umac_wifi_in_hdr hdr;
+ u8 num_tickets;
+ u8 reserved[3];
+ struct iwm_rx_ticket tickets[1];
+} __attribute__ ((packed));
+
+/* Tx/Rx rates window (number of max of last update window per second) */
+#define UMAC_NTF_RATE_SAMPLE_NR 4
+
+#define IWM_UMAC_MGMT_TID 8
+#define IWM_UMAC_TID_NR 8
+
+struct iwm_umac_notif_stats {
+ struct iwm_umac_wifi_in_hdr hdr;
+ __le32 flags;
+ __le32 timestamp;
+ __le16 tid_load[IWM_UMAC_TID_NR + 2]; /* 1 non-QoS + 1 dword align */
+ __le16 tx_rate[UMAC_NTF_RATE_SAMPLE_NR];
+ __le16 rx_rate[UMAC_NTF_RATE_SAMPLE_NR];
+ s32 rssi_dbm;
+ s32 noise_dbm;
+ __le32 supp_rates;
+ __le32 missed_beacons;
+ __le32 rx_beacons;
+ __le32 rx_dir_pkts;
+ __le32 rx_nondir_pkts;
+ __le32 rx_multicast;
+ __le32 rx_errors;
+ __le32 rx_drop_other_bssid;
+ __le32 rx_drop_decode;
+ __le32 rx_drop_reassembly;
+ __le32 rx_drop_bad_len;
+ __le32 rx_drop_overflow;
+ __le32 rx_drop_crc;
+ __le32 rx_drop_missed;
+ __le32 tx_dir_pkts;
+ __le32 tx_nondir_pkts;
+ __le32 tx_failure;
+ __le32 tx_errors;
+ __le32 tx_drop_max_retry;
+ __le32 tx_err_abort;
+ __le32 tx_err_carrier;
+ __le32 rx_bytes;
+ __le32 tx_bytes;
+ __le32 tx_power;
+ __le32 tx_max_power;
+ __le32 roam_threshold;
+ __le32 ap_assoc_nr;
+ __le32 scan_full;
+ __le32 scan_abort;
+ __le32 ap_nr;
+ __le32 roam_nr;
+ __le32 roam_missed_beacons;
+ __le32 roam_rssi;
+ __le32 roam_unassoc;
+ __le32 roam_deauth;
+ __le32 roam_ap_loadblance;
+} __attribute__ ((packed));
+
+/* WiFi interface wrapper header */
+struct iwm_umac_wifi_if {
+ u8 oid;
+ u8 flags;
+ __le16 buf_size;
+} __attribute__ ((packed));
+
+#define IWM_SEQ_NUM_HOST_MSK 0x0000
+#define IWM_SEQ_NUM_UMAC_MSK 0x4000
+#define IWM_SEQ_NUM_LMAC_MSK 0x8000
+#define IWM_SEQ_NUM_MSK 0xC000
+
+#endif
diff --git a/drivers/net/wireless/iwmc3200wifi/wext.c b/drivers/net/wireless/iwmc3200wifi/wext.c
new file mode 100644
index 000000000000..584c94d0f399
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/wext.c
@@ -0,0 +1,723 @@
+/*
+ * Intel Wireless Multicomm 3200 WiFi driver
+ *
+ * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
+ * Samuel Ortiz <samuel.ortiz@intel.com>
+ * Zhu Yi <yi.zhu@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <linux/if_arp.h>
+#include <linux/etherdevice.h>
+#include <net/cfg80211.h>
+#include <net/iw_handler.h>
+
+#include "iwm.h"
+#include "umac.h"
+#include "commands.h"
+#include "debug.h"
+
+static struct iw_statistics *iwm_get_wireless_stats(struct net_device *dev)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ struct iw_statistics *wstats = &iwm->wstats;
+
+ if (!test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)) {
+ memset(wstats, 0, sizeof(struct iw_statistics));
+ wstats->qual.updated = IW_QUAL_ALL_INVALID;
+ }
+
+ return wstats;
+}
+
+static int iwm_wext_siwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *freq, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ if (freq->flags == IW_FREQ_AUTO)
+ return 0;
+
+ /* frequency/channel can only be set in IBSS mode */
+ if (iwm->conf.mode != UMAC_MODE_IBSS)
+ return -EOPNOTSUPP;
+
+ return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra);
+}
+
+static int iwm_wext_giwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *freq, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ if (iwm->conf.mode == UMAC_MODE_IBSS)
+ return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
+
+ freq->e = 0;
+ freq->m = iwm->channel;
+
+ return 0;
+}
+
+static int iwm_wext_siwap(struct net_device *dev, struct iw_request_info *info,
+ struct sockaddr *ap_addr, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ if (iwm->conf.mode == UMAC_MODE_IBSS)
+ return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
+
+ if (!test_bit(IWM_STATUS_READY, &iwm->status))
+ return -EIO;
+
+ if (is_zero_ether_addr(ap_addr->sa_data) ||
+ is_broadcast_ether_addr(ap_addr->sa_data)) {
+ IWM_DBG_WEXT(iwm, DBG, "clear mandatory bssid %pM\n",
+ iwm->umac_profile->bssid[0]);
+ memset(&iwm->umac_profile->bssid[0], 0, ETH_ALEN);
+ iwm->umac_profile->bss_num = 0;
+ } else {
+ IWM_DBG_WEXT(iwm, DBG, "add mandatory bssid %pM\n",
+ ap_addr->sa_data);
+ memcpy(&iwm->umac_profile->bssid[0], ap_addr->sa_data,
+ ETH_ALEN);
+ iwm->umac_profile->bss_num = 1;
+ }
+
+ if (iwm->umac_profile_active) {
+ if (!memcmp(&iwm->umac_profile->bssid[0], iwm->bssid, ETH_ALEN))
+ return 0;
+
+ iwm_invalidate_mlme_profile(iwm);
+ }
+
+ if (iwm->umac_profile->ssid.ssid_len)
+ return iwm_send_mlme_profile(iwm);
+
+ return 0;
+}
+
+static int iwm_wext_giwap(struct net_device *dev, struct iw_request_info *info,
+ struct sockaddr *ap_addr, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ switch (iwm->conf.mode) {
+ case UMAC_MODE_IBSS:
+ return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
+ case UMAC_MODE_BSS:
+ if (test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)) {
+ ap_addr->sa_family = ARPHRD_ETHER;
+ memcpy(&ap_addr->sa_data, iwm->bssid, ETH_ALEN);
+ } else
+ memset(&ap_addr->sa_data, 0, ETH_ALEN);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static int iwm_wext_siwessid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *data, char *ssid)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ size_t len = data->length;
+ int ret;
+
+ if (iwm->conf.mode == UMAC_MODE_IBSS)
+ return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
+
+ if (!test_bit(IWM_STATUS_READY, &iwm->status))
+ return -EIO;
+
+ if (len > 0 && ssid[len - 1] == '\0')
+ len--;
+
+ if (iwm->umac_profile_active) {
+ if (iwm->umac_profile->ssid.ssid_len == len &&
+ !memcmp(iwm->umac_profile->ssid.ssid, ssid, len))
+ return 0;
+
+ ret = iwm_invalidate_mlme_profile(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't invalidate profile\n");
+ return ret;
+ }
+ }
+
+ iwm->umac_profile->ssid.ssid_len = len;
+ memcpy(iwm->umac_profile->ssid.ssid, ssid, len);
+
+ return iwm_send_mlme_profile(iwm);
+}
+
+static int iwm_wext_giwessid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *data, char *ssid)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ if (iwm->conf.mode == UMAC_MODE_IBSS)
+ return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
+
+ if (!test_bit(IWM_STATUS_READY, &iwm->status))
+ return -EIO;
+
+ data->length = iwm->umac_profile->ssid.ssid_len;
+ if (data->length) {
+ memcpy(ssid, iwm->umac_profile->ssid.ssid, data->length);
+ data->flags = 1;
+ } else
+ data->flags = 0;
+
+ return 0;
+}
+
+static struct iwm_key *
+iwm_key_init(struct iwm_priv *iwm, u8 key_idx, bool in_use,
+ struct iw_encode_ext *ext, u8 alg)
+{
+ struct iwm_key *key = &iwm->keys[key_idx];
+
+ memset(key, 0, sizeof(struct iwm_key));
+ memcpy(key->hdr.mac, ext->addr.sa_data, ETH_ALEN);
+ key->hdr.key_idx = key_idx;
+ if (is_broadcast_ether_addr(ext->addr.sa_data))
+ key->hdr.multicast = 1;
+
+ key->in_use = in_use;
+ key->flags = ext->ext_flags;
+ key->alg = alg;
+ key->key_len = ext->key_len;
+ memcpy(key->key, ext->key, ext->key_len);
+
+ return key;
+}
+
+static int iwm_wext_giwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *rate, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ rate->value = iwm->rate * 1000000;
+
+ return 0;
+}
+
+static int iwm_wext_siwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *erq, char *key_buf)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ struct iwm_key *uninitialized_var(key);
+ int idx, i, uninitialized_var(alg), remove = 0, ret;
+
+ IWM_DBG_WEXT(iwm, DBG, "key len: %d\n", erq->length);
+ IWM_DBG_WEXT(iwm, DBG, "flags: 0x%x\n", erq->flags);
+
+ if (!iwm->umac_profile) {
+ IWM_ERR(iwm, "UMAC profile not allocated yet\n");
+ return -ENODEV;
+ }
+
+ if (erq->length == WLAN_KEY_LEN_WEP40) {
+ alg = UMAC_CIPHER_TYPE_WEP_40;
+ iwm->umac_profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_WEP_40;
+ iwm->umac_profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_WEP_40;
+ } else if (erq->length == WLAN_KEY_LEN_WEP104) {
+ alg = UMAC_CIPHER_TYPE_WEP_104;
+ iwm->umac_profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_WEP_104;
+ iwm->umac_profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_WEP_104;
+ }
+
+ if (erq->flags & IW_ENCODE_RESTRICTED)
+ iwm->umac_profile->sec.auth_type = UMAC_AUTH_TYPE_LEGACY_PSK;
+ else
+ iwm->umac_profile->sec.auth_type = UMAC_AUTH_TYPE_OPEN;
+
+ idx = erq->flags & IW_ENCODE_INDEX;
+ if (idx == 0) {
+ if (iwm->default_key)
+ for (i = 0; i < IWM_NUM_KEYS; i++) {
+ if (iwm->default_key == &iwm->keys[i]) {
+ idx = i;
+ break;
+ }
+ }
+ else
+ iwm->default_key = &iwm->keys[idx];
+ } else if (idx < 1 || idx > 4) {
+ return -EINVAL;
+ } else
+ idx--;
+
+ if (erq->flags & IW_ENCODE_DISABLED)
+ remove = 1;
+ else if (erq->length == 0) {
+ if (!iwm->keys[idx].in_use)
+ return -EINVAL;
+ iwm->default_key = &iwm->keys[idx];
+ }
+
+ if (erq->length) {
+ key = &iwm->keys[idx];
+ memset(key, 0, sizeof(struct iwm_key));
+ memset(key->hdr.mac, 0xff, ETH_ALEN);
+ key->hdr.key_idx = idx;
+ key->hdr.multicast = 1;
+ key->in_use = !remove;
+ key->alg = alg;
+ key->key_len = erq->length;
+ memcpy(key->key, key_buf, erq->length);
+
+ IWM_DBG_WEXT(iwm, DBG, "Setting key %d, default: %d\n",
+ idx, !!iwm->default_key);
+ }
+
+ if (remove) {
+ if ((erq->flags & IW_ENCODE_NOKEY) || (erq->length == 0)) {
+ int j;
+ for (j = 0; j < IWM_NUM_KEYS; j++)
+ if (iwm->keys[j].in_use) {
+ struct iwm_key *k = &iwm->keys[j];
+
+ k->in_use = 0;
+ ret = iwm_set_key(iwm, remove, 0, k);
+ if (ret < 0)
+ return ret;
+ }
+
+ iwm->umac_profile->sec.ucast_cipher =
+ UMAC_CIPHER_TYPE_NONE;
+ iwm->umac_profile->sec.mcast_cipher =
+ UMAC_CIPHER_TYPE_NONE;
+ iwm->umac_profile->sec.auth_type =
+ UMAC_AUTH_TYPE_OPEN;
+
+ return 0;
+ } else {
+ key->in_use = 0;
+ return iwm_set_key(iwm, remove, 0, key);
+ }
+ }
+
+ /*
+ * If we havent set a profile yet, we cant set keys.
+ * Keys will be pushed after we're associated.
+ */
+ if (!iwm->umac_profile_active)
+ return 0;
+
+ /*
+ * If there is a current active profile, but no
+ * default key, it's not worth trying to associate again.
+ */
+ if (!iwm->default_key)
+ return 0;
+
+ /*
+ * Here we have an active profile, but a key setting changed.
+ * We thus have to invalidate the current profile, and push the
+ * new one. Keys will be pushed when association takes place.
+ */
+ ret = iwm_invalidate_mlme_profile(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't invalidate profile\n");
+ return ret;
+ }
+
+ return iwm_send_mlme_profile(iwm);
+}
+
+static int iwm_wext_giwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *erq, char *key)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ int idx, i;
+
+ idx = erq->flags & IW_ENCODE_INDEX;
+ if (idx < 1 || idx > 4) {
+ idx = -1;
+ if (!iwm->default_key) {
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_NOKEY;
+ return 0;
+ } else
+ for (i = 0; i < IWM_NUM_KEYS; i++) {
+ if (iwm->default_key == &iwm->keys[i]) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx < 0)
+ return -EINVAL;
+ } else
+ idx--;
+
+ erq->flags = idx + 1;
+
+ if (!iwm->keys[idx].in_use) {
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_DISABLED;
+ return 0;
+ }
+
+ memcpy(key, iwm->keys[idx].key,
+ min_t(int, erq->length, iwm->keys[idx].key_len));
+ erq->length = iwm->keys[idx].key_len;
+ erq->flags |= IW_ENCODE_ENABLED;
+
+ if (iwm->umac_profile->mode == UMAC_MODE_BSS) {
+ switch (iwm->umac_profile->sec.auth_type) {
+ case UMAC_AUTH_TYPE_OPEN:
+ erq->flags |= IW_ENCODE_OPEN;
+ break;
+ default:
+ erq->flags |= IW_ENCODE_RESTRICTED;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static int iwm_set_wpa_version(struct iwm_priv *iwm, u8 wpa_version)
+{
+ if (wpa_version & IW_AUTH_WPA_VERSION_WPA2)
+ iwm->umac_profile->sec.flags = UMAC_SEC_FLG_RSNA_ON_MSK;
+ else if (wpa_version & IW_AUTH_WPA_VERSION_WPA)
+ iwm->umac_profile->sec.flags = UMAC_SEC_FLG_WPA_ON_MSK;
+ else
+ iwm->umac_profile->sec.flags = UMAC_SEC_FLG_LEGACY_PROFILE;
+
+ return 0;
+}
+
+static int iwm_wext_siwpower(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ u32 power_index;
+
+ if (wrq->disabled) {
+ power_index = IWM_POWER_INDEX_MIN;
+ goto set;
+ } else
+ power_index = IWM_POWER_INDEX_DEFAULT;
+
+ switch (wrq->flags & IW_POWER_MODE) {
+ case IW_POWER_ON:
+ case IW_POWER_MODE:
+ case IW_POWER_ALL_R:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ set:
+ if (power_index == iwm->conf.power_index)
+ return 0;
+
+ iwm->conf.power_index = power_index;
+
+ return iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
+ CFG_POWER_INDEX, iwm->conf.power_index);
+}
+
+static int iwm_wext_giwpower(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+
+ wrqu->power.disabled = (iwm->conf.power_index == IWM_POWER_INDEX_MIN);
+
+ return 0;
+}
+
+static int iwm_set_key_mgt(struct iwm_priv *iwm, u8 key_mgt)
+{
+ u8 *auth_type = &iwm->umac_profile->sec.auth_type;
+
+ if (key_mgt == IW_AUTH_KEY_MGMT_802_1X)
+ *auth_type = UMAC_AUTH_TYPE_8021X;
+ else if (key_mgt == IW_AUTH_KEY_MGMT_PSK) {
+ if (iwm->umac_profile->sec.flags &
+ (UMAC_SEC_FLG_WPA_ON_MSK | UMAC_SEC_FLG_RSNA_ON_MSK))
+ *auth_type = UMAC_AUTH_TYPE_RSNA_PSK;
+ else
+ *auth_type = UMAC_AUTH_TYPE_LEGACY_PSK;
+ } else {
+ IWM_ERR(iwm, "Invalid key mgt: 0x%x\n", key_mgt);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int iwm_set_cipher(struct iwm_priv *iwm, u8 cipher, u8 ucast)
+{
+ u8 *profile_cipher = ucast ? &iwm->umac_profile->sec.ucast_cipher :
+ &iwm->umac_profile->sec.mcast_cipher;
+
+ switch (cipher) {
+ case IW_AUTH_CIPHER_NONE:
+ *profile_cipher = UMAC_CIPHER_TYPE_NONE;
+ break;
+ case IW_AUTH_CIPHER_WEP40:
+ *profile_cipher = UMAC_CIPHER_TYPE_WEP_40;
+ break;
+ case IW_AUTH_CIPHER_TKIP:
+ *profile_cipher = UMAC_CIPHER_TYPE_TKIP;
+ break;
+ case IW_AUTH_CIPHER_CCMP:
+ *profile_cipher = UMAC_CIPHER_TYPE_CCMP;
+ break;
+ case IW_AUTH_CIPHER_WEP104:
+ *profile_cipher = UMAC_CIPHER_TYPE_WEP_104;
+ break;
+ default:
+ IWM_ERR(iwm, "Unsupported cipher: 0x%x\n", cipher);
+ return -ENOTSUPP;
+ }
+
+ return 0;
+}
+
+static int iwm_set_auth_alg(struct iwm_priv *iwm, u8 auth_alg)
+{
+ u8 *auth_type = &iwm->umac_profile->sec.auth_type;
+
+ switch (auth_alg) {
+ case IW_AUTH_ALG_OPEN_SYSTEM:
+ *auth_type = UMAC_AUTH_TYPE_OPEN;
+ break;
+ case IW_AUTH_ALG_SHARED_KEY:
+ if (iwm->umac_profile->sec.flags &
+ (UMAC_SEC_FLG_WPA_ON_MSK | UMAC_SEC_FLG_RSNA_ON_MSK)) {
+ if (*auth_type == UMAC_AUTH_TYPE_8021X)
+ return -EINVAL;
+ *auth_type = UMAC_AUTH_TYPE_RSNA_PSK;
+ } else {
+ *auth_type = UMAC_AUTH_TYPE_LEGACY_PSK;
+ }
+ break;
+ case IW_AUTH_ALG_LEAP:
+ default:
+ IWM_ERR(iwm, "Unsupported auth alg: 0x%x\n", auth_alg);
+ return -ENOTSUPP;
+ }
+
+ return 0;
+}
+
+static int iwm_wext_siwauth(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *data, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ int ret;
+
+ if ((data->flags) &
+ (IW_AUTH_WPA_VERSION | IW_AUTH_KEY_MGMT |
+ IW_AUTH_WPA_ENABLED | IW_AUTH_80211_AUTH_ALG)) {
+ /* We need to invalidate the current profile */
+ if (iwm->umac_profile_active) {
+ ret = iwm_invalidate_mlme_profile(iwm);
+ if (ret < 0) {
+ IWM_ERR(iwm, "Couldn't invalidate profile\n");
+ return ret;
+ }
+ }
+ }
+
+ switch (data->flags & IW_AUTH_INDEX) {
+ case IW_AUTH_WPA_VERSION:
+ return iwm_set_wpa_version(iwm, data->value);
+ break;
+ case IW_AUTH_CIPHER_PAIRWISE:
+ return iwm_set_cipher(iwm, data->value, 1);
+ break;
+ case IW_AUTH_CIPHER_GROUP:
+ return iwm_set_cipher(iwm, data->value, 0);
+ break;
+ case IW_AUTH_KEY_MGMT:
+ return iwm_set_key_mgt(iwm, data->value);
+ break;
+ case IW_AUTH_80211_AUTH_ALG:
+ return iwm_set_auth_alg(iwm, data->value);
+ break;
+ default:
+ return -ENOTSUPP;
+ }
+
+ return 0;
+}
+
+static int iwm_wext_giwauth(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *data, char *extra)
+{
+ return 0;
+}
+
+static int iwm_wext_siwencodeext(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *erq, char *extra)
+{
+ struct iwm_priv *iwm = ndev_to_iwm(dev);
+ struct iwm_key *key;
+ struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
+ int uninitialized_var(alg), idx, i, remove = 0;
+
+ IWM_DBG_WEXT(iwm, DBG, "alg: 0x%x\n", ext->alg);
+ IWM_DBG_WEXT(iwm, DBG, "key len: %d\n", ext->key_len);
+ IWM_DBG_WEXT(iwm, DBG, "ext_flags: 0x%x\n", ext->ext_flags);
+ IWM_DBG_WEXT(iwm, DBG, "flags: 0x%x\n", erq->flags);
+ IWM_DBG_WEXT(iwm, DBG, "length: 0x%x\n", erq->length);
+
+ switch (ext->alg) {
+ case IW_ENCODE_ALG_NONE:
+ remove = 1;
+ break;
+ case IW_ENCODE_ALG_WEP:
+ if (ext->key_len == WLAN_KEY_LEN_WEP40)
+ alg = UMAC_CIPHER_TYPE_WEP_40;
+ else if (ext->key_len == WLAN_KEY_LEN_WEP104)
+ alg = UMAC_CIPHER_TYPE_WEP_104;
+ else {
+ IWM_ERR(iwm, "Invalid key length: %d\n", ext->key_len);
+ return -EINVAL;
+ }
+
+ break;
+ case IW_ENCODE_ALG_TKIP:
+ alg = UMAC_CIPHER_TYPE_TKIP;
+ break;
+ case IW_ENCODE_ALG_CCMP:
+ alg = UMAC_CIPHER_TYPE_CCMP;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ idx = erq->flags & IW_ENCODE_INDEX;
+
+ if (idx == 0) {
+ if (iwm->default_key)
+ for (i = 0; i < IWM_NUM_KEYS; i++) {
+ if (iwm->default_key == &iwm->keys[i]) {
+ idx = i;
+ break;
+ }
+ }
+ } else if (idx < 1 || idx > 4) {
+ return -EINVAL;
+ } else
+ idx--;
+
+ if (erq->flags & IW_ENCODE_DISABLED)
+ remove = 1;
+ else if ((erq->length == 0) ||
+ (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) {
+ iwm->default_key = &iwm->keys[idx];
+ if (iwm->umac_profile_active && ext->alg == IW_ENCODE_ALG_WEP)
+ return iwm_set_tx_key(iwm, idx);
+ }
+
+ key = iwm_key_init(iwm, idx, !remove, ext, alg);
+
+ return iwm_set_key(iwm, remove, !iwm->default_key, key);
+}
+
+static const iw_handler iwm_handlers[] =
+{
+ (iw_handler) NULL, /* SIOCSIWCOMMIT */
+ (iw_handler) cfg80211_wext_giwname, /* SIOCGIWNAME */
+ (iw_handler) NULL, /* SIOCSIWNWID */
+ (iw_handler) NULL, /* SIOCGIWNWID */
+ (iw_handler) iwm_wext_siwfreq, /* SIOCSIWFREQ */
+ (iw_handler) iwm_wext_giwfreq, /* SIOCGIWFREQ */
+ (iw_handler) cfg80211_wext_siwmode, /* SIOCSIWMODE */
+ (iw_handler) cfg80211_wext_giwmode, /* SIOCGIWMODE */
+ (iw_handler) NULL, /* SIOCSIWSENS */
+ (iw_handler) NULL, /* SIOCGIWSENS */
+ (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
+ (iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */
+ (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
+ (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
+ (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
+ (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
+ (iw_handler) NULL, /* SIOCSIWSPY */
+ (iw_handler) NULL, /* SIOCGIWSPY */
+ (iw_handler) NULL, /* SIOCSIWTHRSPY */
+ (iw_handler) NULL, /* SIOCGIWTHRSPY */
+ (iw_handler) iwm_wext_siwap, /* SIOCSIWAP */
+ (iw_handler) iwm_wext_giwap, /* SIOCGIWAP */
+ (iw_handler) NULL, /* SIOCSIWMLME */
+ (iw_handler) NULL, /* SIOCGIWAPLIST */
+ (iw_handler) cfg80211_wext_siwscan, /* SIOCSIWSCAN */
+ (iw_handler) cfg80211_wext_giwscan, /* SIOCGIWSCAN */
+ (iw_handler) iwm_wext_siwessid, /* SIOCSIWESSID */
+ (iw_handler) iwm_wext_giwessid, /* SIOCGIWESSID */
+ (iw_handler) NULL, /* SIOCSIWNICKN */
+ (iw_handler) NULL, /* SIOCGIWNICKN */
+ (iw_handler) NULL, /* -- hole -- */
+ (iw_handler) NULL, /* -- hole -- */
+ (iw_handler) NULL, /* SIOCSIWRATE */
+ (iw_handler) iwm_wext_giwrate, /* SIOCGIWRATE */
+ (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
+ (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
+ (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
+ (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */
+ (iw_handler) NULL, /* SIOCSIWTXPOW */
+ (iw_handler) NULL, /* SIOCGIWTXPOW */
+ (iw_handler) NULL, /* SIOCSIWRETRY */
+ (iw_handler) NULL, /* SIOCGIWRETRY */
+ (iw_handler) iwm_wext_siwencode, /* SIOCSIWENCODE */
+ (iw_handler) iwm_wext_giwencode, /* SIOCGIWENCODE */
+ (iw_handler) iwm_wext_siwpower, /* SIOCSIWPOWER */
+ (iw_handler) iwm_wext_giwpower, /* SIOCGIWPOWER */
+ (iw_handler) NULL, /* -- hole -- */
+ (iw_handler) NULL, /* -- hole -- */
+ (iw_handler) NULL, /* SIOCSIWGENIE */
+ (iw_handler) NULL, /* SIOCGIWGENIE */
+ (iw_handler) iwm_wext_siwauth, /* SIOCSIWAUTH */
+ (iw_handler) iwm_wext_giwauth, /* SIOCGIWAUTH */
+ (iw_handler) iwm_wext_siwencodeext, /* SIOCSIWENCODEEXT */
+ (iw_handler) NULL, /* SIOCGIWENCODEEXT */
+ (iw_handler) NULL, /* SIOCSIWPMKSA */
+ (iw_handler) NULL, /* -- hole -- */
+};
+
+const struct iw_handler_def iwm_iw_handler_def = {
+ .num_standard = ARRAY_SIZE(iwm_handlers),
+ .standard = (iw_handler *) iwm_handlers,
+ .get_wireless_stats = iwm_get_wireless_stats,
+};
+
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 8c3605cdc64c..c455b9abbfc0 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -119,6 +119,19 @@ int lbs_update_hw_spec(struct lbs_private *priv)
lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
cmd.hwifversion, cmd.version);
+ /* Determine mesh_fw_ver from fwrelease and fwcapinfo */
+ /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
+ /* 5.110.22 have mesh command with 0xa3 command id */
+ /* 10.0.0.p0 FW brings in mesh config command with different id */
+ /* Check FW version MSB and initialize mesh_fw_ver */
+ if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5)
+ priv->mesh_fw_ver = MESH_FW_OLD;
+ else if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
+ (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK))
+ priv->mesh_fw_ver = MESH_FW_NEW;
+ else
+ priv->mesh_fw_ver = MESH_NONE;
+
/* Clamp region code to 8-bit since FW spec indicates that it should
* only ever be 8-bit, even though the field size is 16-bit. Some firmware
* returns non-zero high 8 bits here.
@@ -1036,17 +1049,26 @@ static int __lbs_mesh_config_send(struct lbs_private *priv,
uint16_t action, uint16_t type)
{
int ret;
+ u16 command = CMD_MESH_CONFIG_OLD;
lbs_deb_enter(LBS_DEB_CMD);
- cmd->hdr.command = cpu_to_le16(CMD_MESH_CONFIG);
+ /*
+ * Command id is 0xac for v10 FW along with mesh interface
+ * id in bits 14-13-12.
+ */
+ if (priv->mesh_fw_ver == MESH_FW_NEW)
+ command = CMD_MESH_CONFIG |
+ (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET);
+
+ cmd->hdr.command = cpu_to_le16(command);
cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config));
cmd->hdr.result = 0;
cmd->type = cpu_to_le16(type);
cmd->action = cpu_to_le16(action);
- ret = lbs_cmd_with_response(priv, CMD_MESH_CONFIG, cmd);
+ ret = lbs_cmd_with_response(priv, command, cmd);
lbs_deb_leave(LBS_DEB_CMD);
return ret;
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index e8dfde39abfc..48da157d6cda 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -227,6 +227,20 @@ static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, in
#define TxPD_CONTROL_WDS_FRAME (1<<17)
#define TxPD_MESH_FRAME TxPD_CONTROL_WDS_FRAME
+/** Mesh interface ID */
+#define MESH_IFACE_ID 0x0001
+/** Mesh id should be in bits 14-13-12 */
+#define MESH_IFACE_BIT_OFFSET 0x000c
+/** Mesh enable bit in FW capability */
+#define MESH_CAPINFO_ENABLE_MASK (1<<16)
+
+/** FW definition from Marvell v5 */
+#define MRVL_FW_V5 (0x05)
+/** FW definition from Marvell v10 */
+#define MRVL_FW_V10 (0x0a)
+/** FW major revision definition */
+#define MRVL_FW_MAJOR_REV(x) ((x)>>24)
+
/** RxPD status */
#define MRVDRV_RXPD_STATUS_OK 0x0001
@@ -380,6 +394,13 @@ enum KEY_INFO_WPA {
KEY_INFO_WPA_ENABLED = 0x04
};
+/** mesh_fw_ver */
+enum _mesh_fw_ver {
+ MESH_NONE = 0, /* MESH is not supported */
+ MESH_FW_OLD, /* MESH is supported in FW V5 */
+ MESH_FW_NEW, /* MESH is supported in FW V10 and newer */
+};
+
/* Default values for fwt commands. */
#define FWT_DEFAULT_METRIC 0
#define FWT_DEFAULT_DIR 1
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 27e81fd97c94..a4455ec7c354 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -101,6 +101,7 @@ struct lbs_mesh_stats {
/** Private structure for the MV device */
struct lbs_private {
int mesh_open;
+ int mesh_fw_ver;
int infra_open;
int mesh_autostart_enabled;
@@ -320,6 +321,8 @@ struct lbs_private {
u32 monitormode;
u8 fw_ready;
+ u8 fn_init_required;
+ u8 fn_shutdown_required;
};
extern struct cmd_confirm_sleep confirm_sleep;
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index d4457ef808a6..fe8f0cb737bc 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -83,8 +83,11 @@
#define CMD_FWT_ACCESS 0x0095
#define CMD_802_11_MONITOR_MODE 0x0098
#define CMD_MESH_ACCESS 0x009b
-#define CMD_MESH_CONFIG 0x00a3
+#define CMD_MESH_CONFIG_OLD 0x00a3
+#define CMD_MESH_CONFIG 0x00ac
#define CMD_SET_BOOT2_VER 0x00a5
+#define CMD_FUNC_INIT 0x00a9
+#define CMD_FUNC_SHUTDOWN 0x00aa
#define CMD_802_11_BEACON_CTRL 0x00b0
/* For the IEEE Power Save */
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index a899aeb676bb..391c54ab2b09 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -13,8 +13,19 @@
/* TxPD descriptor */
struct txpd {
- /* Current Tx packet status */
- __le32 tx_status;
+ /* union to cope up with later FW revisions */
+ union {
+ /* Current Tx packet status */
+ __le32 tx_status;
+ struct {
+ /* BSS type: client, AP, etc. */
+ u8 bss_type;
+ /* BSS number */
+ u8 bss_num;
+ /* Reserved */
+ __le16 reserved;
+ } bss;
+ } u;
/* Tx control */
__le32 tx_control;
__le32 tx_packet_location;
@@ -36,8 +47,17 @@ struct txpd {
/* RxPD Descriptor */
struct rxpd {
- /* Current Rx packet status */
- __le16 status;
+ /* union to cope up with later FW revisions */
+ union {
+ /* Current Rx packet status */
+ __le16 status;
+ struct {
+ /* BSS type: client, AP, etc. */
+ u8 bss_type;
+ /* BSS number */
+ u8 bss_num;
+ } bss;
+ } u;
/* SNR */
u8 snr;
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index cedeac6322fe..2a5b083bf9bd 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -273,7 +273,28 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
*/
#define IF_CS_PRODUCT_ID 0x0000001C
#define IF_CS_CF8385_B1_REV 0x12
+#define IF_CS_CF8381_B3_REV 0x04
+/*
+ * Used to detect other cards than CF8385 since their revisions of silicon
+ * doesn't match those from CF8385, eg. CF8381 B3 works with this driver.
+ */
+#define CF8381_MANFID 0x02db
+#define CF8381_CARDID 0x6064
+#define CF8385_MANFID 0x02df
+#define CF8385_CARDID 0x8103
+
+static inline int if_cs_hw_is_cf8381(struct pcmcia_device *p_dev)
+{
+ return (p_dev->manf_id == CF8381_MANFID &&
+ p_dev->card_id == CF8381_CARDID);
+}
+
+static inline int if_cs_hw_is_cf8385(struct pcmcia_device *p_dev)
+{
+ return (p_dev->manf_id == CF8385_MANFID &&
+ p_dev->card_id == CF8385_CARDID);
+}
/********************************************************************/
/* I/O and interrupt handling */
@@ -757,6 +778,7 @@ static void if_cs_release(struct pcmcia_device *p_dev)
static int if_cs_probe(struct pcmcia_device *p_dev)
{
int ret = -ENOMEM;
+ unsigned int prod_id;
struct lbs_private *priv;
struct if_cs_card *card;
/* CIS parsing */
@@ -859,7 +881,14 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1);
/* Check if we have a current silicon */
- if (if_cs_read8(card, IF_CS_PRODUCT_ID) < IF_CS_CF8385_B1_REV) {
+ prod_id = if_cs_read8(card, IF_CS_PRODUCT_ID);
+ if (if_cs_hw_is_cf8381(p_dev) && prod_id < IF_CS_CF8381_B3_REV) {
+ lbs_pr_err("old chips like 8381 rev B3 aren't supported\n");
+ ret = -ENODEV;
+ goto out2;
+ }
+
+ if (if_cs_hw_is_cf8385(p_dev) && prod_id < IF_CS_CF8385_B1_REV) {
lbs_pr_err("old chips like 8385 rev B1 aren't supported\n");
ret = -ENODEV;
goto out2;
@@ -950,7 +979,8 @@ static void if_cs_detach(struct pcmcia_device *p_dev)
/********************************************************************/
static struct pcmcia_device_id if_cs_ids[] = {
- PCMCIA_DEVICE_MANF_CARD(0x02df, 0x8103),
+ PCMCIA_DEVICE_MANF_CARD(CF8381_MANFID, CF8381_CARDID),
+ PCMCIA_DEVICE_MANF_CARD(CF8385_MANFID, CF8385_CARDID),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, if_cs_ids);
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index 76f4c653d641..a7e3fc119b70 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -48,8 +48,11 @@ static char *lbs_fw_name = NULL;
module_param_named(fw_name, lbs_fw_name, charp, 0644);
static const struct sdio_device_id if_sdio_ids[] = {
- { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_LIBERTAS) },
- { /* end: all zeroes */ },
+ { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL,
+ SDIO_DEVICE_ID_MARVELL_LIBERTAS) },
+ { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL,
+ SDIO_DEVICE_ID_MARVELL_8688WLAN) },
+ { /* end: all zeroes */ },
};
MODULE_DEVICE_TABLE(sdio, if_sdio_ids);
@@ -58,20 +61,30 @@ struct if_sdio_model {
int model;
const char *helper;
const char *firmware;
+ struct if_sdio_card *card;
};
static struct if_sdio_model if_sdio_models[] = {
{
/* 8385 */
- .model = 0x04,
+ .model = IF_SDIO_MODEL_8385,
.helper = "sd8385_helper.bin",
.firmware = "sd8385.bin",
+ .card = NULL,
},
{
/* 8686 */
- .model = 0x0B,
+ .model = IF_SDIO_MODEL_8686,
.helper = "sd8686_helper.bin",
.firmware = "sd8686.bin",
+ .card = NULL,
+ },
+ {
+ /* 8688 */
+ .model = IF_SDIO_MODEL_8688,
+ .helper = "sd8688_helper.bin",
+ .firmware = "sd8688.bin",
+ .card = NULL,
},
};
@@ -87,6 +100,7 @@ struct if_sdio_card {
int model;
unsigned long ioport;
+ unsigned int scratch_reg;
const char *helper;
const char *firmware;
@@ -98,25 +112,29 @@ struct if_sdio_card {
struct workqueue_struct *workqueue;
struct work_struct packet_worker;
+
+ u8 rx_unit;
};
/********************************************************************/
/* I/O */
/********************************************************************/
+/*
+ * For SD8385/SD8686, this function reads firmware status after
+ * the image is downloaded, or reads RX packet length when
+ * interrupt (with IF_SDIO_H_INT_UPLD bit set) is received.
+ * For SD8688, this function reads firmware status only.
+ */
static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err)
{
- int ret, reg;
+ int ret;
u16 scratch;
- if (card->model == 0x04)
- reg = IF_SDIO_SCRATCH_OLD;
- else
- reg = IF_SDIO_SCRATCH;
-
- scratch = sdio_readb(card->func, reg, &ret);
+ scratch = sdio_readb(card->func, card->scratch_reg, &ret);
if (!ret)
- scratch |= sdio_readb(card->func, reg + 1, &ret) << 8;
+ scratch |= sdio_readb(card->func, card->scratch_reg + 1,
+ &ret) << 8;
if (err)
*err = ret;
@@ -127,6 +145,46 @@ static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err)
return scratch;
}
+static u8 if_sdio_read_rx_unit(struct if_sdio_card *card)
+{
+ int ret;
+ u8 rx_unit;
+
+ rx_unit = sdio_readb(card->func, IF_SDIO_RX_UNIT, &ret);
+
+ if (ret)
+ rx_unit = 0;
+
+ return rx_unit;
+}
+
+static u16 if_sdio_read_rx_len(struct if_sdio_card *card, int *err)
+{
+ int ret;
+ u16 rx_len;
+
+ switch (card->model) {
+ case IF_SDIO_MODEL_8385:
+ case IF_SDIO_MODEL_8686:
+ rx_len = if_sdio_read_scratch(card, &ret);
+ break;
+ case IF_SDIO_MODEL_8688:
+ default: /* for newer chipsets */
+ rx_len = sdio_readb(card->func, IF_SDIO_RX_LEN, &ret);
+ if (!ret)
+ rx_len <<= card->rx_unit;
+ else
+ rx_len = 0xffff; /* invalid length */
+
+ break;
+ }
+
+ if (err)
+ *err = ret;
+
+ return rx_len;
+}
+
static int if_sdio_handle_cmd(struct if_sdio_card *card,
u8 *buffer, unsigned size)
{
@@ -207,7 +265,7 @@ static int if_sdio_handle_event(struct if_sdio_card *card,
lbs_deb_enter(LBS_DEB_SDIO);
- if (card->model == 0x04) {
+ if (card->model == IF_SDIO_MODEL_8385) {
event = sdio_readb(card->func, IF_SDIO_EVENT, &ret);
if (ret)
goto out;
@@ -245,7 +303,7 @@ static int if_sdio_card_to_host(struct if_sdio_card *card)
lbs_deb_enter(LBS_DEB_SDIO);
- size = if_sdio_read_scratch(card, &ret);
+ size = if_sdio_read_rx_len(card, &ret);
if (ret)
goto out;
@@ -488,7 +546,6 @@ static int if_sdio_prog_helper(struct if_sdio_card *card)
ret = 0;
release:
- sdio_set_block_size(card->func, 0);
sdio_release_host(card->func);
kfree(chunk_buffer);
release_fw:
@@ -624,7 +681,6 @@ static int if_sdio_prog_real(struct if_sdio_card *card)
ret = 0;
release:
- sdio_set_block_size(card->func, 0);
sdio_release_host(card->func);
kfree(chunk_buffer);
release_fw:
@@ -653,6 +709,8 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
if (ret)
goto out;
+ lbs_deb_sdio("firmware status = %#x\n", scratch);
+
if (scratch == IF_SDIO_FIRMWARE_OK) {
lbs_deb_sdio("firmware already loaded\n");
goto success;
@@ -667,6 +725,9 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
goto out;
success:
+ sdio_claim_host(card->func);
+ sdio_set_block_size(card->func, IF_SDIO_BLOCK_SIZE);
+ sdio_release_host(card->func);
ret = 0;
out:
@@ -820,10 +881,10 @@ static int if_sdio_probe(struct sdio_func *func,
if (sscanf(func->card->info[i],
"ID: %x", &model) == 1)
break;
- if (!strcmp(func->card->info[i], "IBIS Wireless SDIO Card")) {
- model = 4;
- break;
- }
+ if (!strcmp(func->card->info[i], "IBIS Wireless SDIO Card")) {
+ model = IF_SDIO_MODEL_8385;
+ break;
+ }
}
if (i == func->card->num_info) {
@@ -837,6 +898,20 @@ static int if_sdio_probe(struct sdio_func *func,
card->func = func;
card->model = model;
+
+ switch (card->model) {
+ case IF_SDIO_MODEL_8385:
+ card->scratch_reg = IF_SDIO_SCRATCH_OLD;
+ break;
+ case IF_SDIO_MODEL_8686:
+ card->scratch_reg = IF_SDIO_SCRATCH;
+ break;
+ case IF_SDIO_MODEL_8688:
+ default: /* for newer chipsets */
+ card->scratch_reg = IF_SDIO_FW_STATUS;
+ break;
+ }
+
spin_lock_init(&card->lock);
card->workqueue = create_workqueue("libertas_sdio");
INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker);
@@ -852,6 +927,8 @@ static int if_sdio_probe(struct sdio_func *func,
goto free;
}
+ if_sdio_models[i].card = card;
+
card->helper = if_sdio_models[i].helper;
card->firmware = if_sdio_models[i].firmware;
@@ -914,15 +991,32 @@ static int if_sdio_probe(struct sdio_func *func,
priv->fw_ready = 1;
+ sdio_claim_host(func);
+
+ /*
+ * Get rx_unit if the chip is SD8688 or newer.
+ * SD8385 & SD8686 do not have rx_unit.
+ */
+ if ((card->model != IF_SDIO_MODEL_8385)
+ && (card->model != IF_SDIO_MODEL_8686))
+ card->rx_unit = if_sdio_read_rx_unit(card);
+ else
+ card->rx_unit = 0;
+
/*
* Enable interrupts now that everything is set up
*/
- sdio_claim_host(func);
sdio_writeb(func, 0x0f, IF_SDIO_H_INT_MASK, &ret);
sdio_release_host(func);
if (ret)
goto reclaim;
+ /*
+ * FUNC_INIT is required for SD8688 WLAN/BT multiple functions
+ */
+ priv->fn_init_required =
+ (card->model == IF_SDIO_MODEL_8688) ? 1 : 0;
+
ret = lbs_start_card(priv);
if (ret)
goto err_activate_card;
@@ -963,23 +1057,30 @@ static void if_sdio_remove(struct sdio_func *func)
{
struct if_sdio_card *card;
struct if_sdio_packet *packet;
+ int ret;
lbs_deb_enter(LBS_DEB_SDIO);
card = sdio_get_drvdata(func);
+ lbs_stop_card(card->priv);
+
card->priv->surpriseremoved = 1;
lbs_deb_sdio("call remove card\n");
- lbs_stop_card(card->priv);
lbs_remove_card(card->priv);
flush_workqueue(card->workqueue);
destroy_workqueue(card->workqueue);
sdio_claim_host(func);
+
+ /* Disable interrupts */
+ sdio_writeb(func, 0x00, IF_SDIO_H_INT_MASK, &ret);
+
sdio_release_irq(func);
sdio_disable_func(func);
+
sdio_release_host(func);
while (card->packets) {
@@ -1022,8 +1123,23 @@ static int __init if_sdio_init_module(void)
static void __exit if_sdio_exit_module(void)
{
+ int i;
+ struct if_sdio_card *card;
+
lbs_deb_enter(LBS_DEB_SDIO);
+ for (i = 0; i < ARRAY_SIZE(if_sdio_models); i++) {
+ card = if_sdio_models[i].card;
+
+ /*
+ * FUNC_SHUTDOWN is required for SD8688 WLAN/BT
+ * multiple functions
+ */
+ if (card && card->priv)
+ card->priv->fn_shutdown_required =
+ (card->model == IF_SDIO_MODEL_8688) ? 1 : 0;
+ }
+
sdio_unregister_driver(&if_sdio_driver);
lbs_deb_leave(LBS_DEB_SDIO);
diff --git a/drivers/net/wireless/libertas/if_sdio.h b/drivers/net/wireless/libertas/if_sdio.h
index 533bdfbf5d2a..60c9b2fcef03 100644
--- a/drivers/net/wireless/libertas/if_sdio.h
+++ b/drivers/net/wireless/libertas/if_sdio.h
@@ -12,6 +12,10 @@
#ifndef _LBS_IF_SDIO_H
#define _LBS_IF_SDIO_H
+#define IF_SDIO_MODEL_8385 0x04
+#define IF_SDIO_MODEL_8686 0x0b
+#define IF_SDIO_MODEL_8688 0x10
+
#define IF_SDIO_IOPORT 0x00
#define IF_SDIO_H_INT_MASK 0x04
@@ -38,8 +42,14 @@
#define IF_SDIO_SCRATCH 0x34
#define IF_SDIO_SCRATCH_OLD 0x80fe
+#define IF_SDIO_FW_STATUS 0x40
#define IF_SDIO_FIRMWARE_OK 0xfedc
+#define IF_SDIO_RX_LEN 0x42
+#define IF_SDIO_RX_UNIT 0x43
+
#define IF_SDIO_EVENT 0x80fc
+#define IF_SDIO_BLOCK_SIZE 256
+
#endif
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index 07311e71af92..5fa55fe1f860 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -731,7 +731,7 @@ static int if_spi_c2h_data(struct if_spi_card *card)
goto out;
} else if (len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
lbs_pr_err("%s: error: card has %d bytes of data, but "
- "our maximum skb size is %u\n",
+ "our maximum skb size is %lu\n",
__func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
err = -EINVAL;
goto out;
@@ -814,6 +814,13 @@ static void if_spi_e2h(struct if_spi_card *card)
if (err)
goto out;
+ /* re-enable the card event interrupt */
+ spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
+ ~IF_SPI_HICU_CARD_EVENT);
+
+ /* generate a card interrupt */
+ spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG, IF_SPI_CIC_HOST_EVENT);
+
spin_lock_irqsave(&priv->driver_lock, flags);
lbs_queue_event(priv, cause & 0xff);
spin_unlock_irqrestore(&priv->driver_lock, flags);
@@ -1020,6 +1027,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
struct libertas_spi_platform_data *pdata = spi->dev.platform_data;
int err = 0;
u32 scratch;
+ struct sched_param param = { .sched_priority = 1 };
lbs_deb_enter(LBS_DEB_SPI);
@@ -1123,6 +1131,9 @@ static int __devinit if_spi_probe(struct spi_device *spi)
lbs_pr_err("error creating SPI thread: err=%d\n", err);
goto remove_card;
}
+ if (sched_setscheduler(card->spi_thread, SCHED_FIFO, &param))
+ lbs_pr_err("Error setting scheduler, using default.\n");
+
err = request_irq(spi->irq, if_spi_host_interrupt,
IRQF_TRIGGER_FALLING, "libertas_spi", card);
if (err) {
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index ea3dc038be76..d649caebf08a 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -686,8 +686,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
return;
}
- if (!in_interrupt())
- BUG();
+ BUG_ON(!in_interrupt());
spin_lock(&priv->driver_lock);
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 8ae935ac32f1..a58a12352672 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1002,9 +1002,17 @@ static int lbs_setup_firmware(struct lbs_private *priv)
{
int ret = -1;
s16 curlevel = 0, minlevel = 0, maxlevel = 0;
+ struct cmd_header cmd;
lbs_deb_enter(LBS_DEB_FW);
+ if (priv->fn_init_required) {
+ memset(&cmd, 0, sizeof(cmd));
+ if (__lbs_cmd(priv, CMD_FUNC_INIT, &cmd, sizeof(cmd),
+ lbs_cmd_copyback, (unsigned long) &cmd))
+ lbs_pr_alert("CMD_FUNC_INIT command failed\n");
+ }
+
/* Read MAC address from firmware */
memset(priv->current_addr, 0xff, ETH_ALEN);
ret = lbs_update_hw_spec(priv);
@@ -1192,6 +1200,9 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
priv->mesh_open = 0;
priv->infra_open = 0;
+ priv->fn_init_required = 0;
+ priv->fn_shutdown_required = 0;
+
/* Setup the OS Interface to our functions */
dev->netdev_ops = &lbs_netdev_ops;
dev->watchdog_timeo = 5 * HZ;
@@ -1307,8 +1318,10 @@ int lbs_start_card(struct lbs_private *priv)
lbs_update_channel(priv);
- /* 5.0.16p0 is known to NOT support any mesh */
- if (priv->fwrelease > 0x05001000) {
+ /* Check mesh FW version and appropriately send the mesh start
+ * command
+ */
+ if (priv->mesh_fw_ver == MESH_FW_OLD) {
/* Enable mesh, if supported, and work out which TLV it uses.
0x100 + 291 is an unofficial value used in 5.110.20.pXX
0x100 + 37 is the official value used in 5.110.21.pXX
@@ -1322,27 +1335,35 @@ int lbs_start_card(struct lbs_private *priv)
It's just that 5.110.20.pXX will not have done anything
useful */
- priv->mesh_tlv = 0x100 + 291;
+ priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID;
if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
priv->curbssparams.channel)) {
- priv->mesh_tlv = 0x100 + 37;
+ priv->mesh_tlv = TLV_TYPE_MESH_ID;
if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
priv->curbssparams.channel))
priv->mesh_tlv = 0;
}
- if (priv->mesh_tlv) {
- lbs_add_mesh(priv);
-
- if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
- lbs_pr_err("cannot register lbs_mesh attribute\n");
-
- /* While rtap isn't related to mesh, only mesh-enabled
- * firmware implements the rtap functionality via
- * CMD_802_11_MONITOR_MODE.
- */
- if (device_create_file(&dev->dev, &dev_attr_lbs_rtap))
- lbs_pr_err("cannot register lbs_rtap attribute\n");
- }
+ } else if (priv->mesh_fw_ver == MESH_FW_NEW) {
+ /* 10.0.0.pXX new firmwares should succeed with TLV
+ * 0x100+37; Do not invoke command with old TLV.
+ */
+ priv->mesh_tlv = TLV_TYPE_MESH_ID;
+ if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
+ priv->curbssparams.channel))
+ priv->mesh_tlv = 0;
+ }
+ if (priv->mesh_tlv) {
+ lbs_add_mesh(priv);
+
+ if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
+ lbs_pr_err("cannot register lbs_mesh attribute\n");
+
+ /* While rtap isn't related to mesh, only mesh-enabled
+ * firmware implements the rtap functionality via
+ * CMD_802_11_MONITOR_MODE.
+ */
+ if (device_create_file(&dev->dev, &dev_attr_lbs_rtap))
+ lbs_pr_err("cannot register lbs_rtap attribute\n");
}
lbs_debugfs_init_one(priv, dev);
@@ -1363,11 +1384,20 @@ void lbs_stop_card(struct lbs_private *priv)
struct net_device *dev;
struct cmd_ctrl_node *cmdnode;
unsigned long flags;
+ struct cmd_header cmd;
lbs_deb_enter(LBS_DEB_MAIN);
if (!priv)
goto out;
+
+ if (priv->fn_shutdown_required) {
+ memset(&cmd, 0, sizeof(cmd));
+ if (__lbs_cmd(priv, CMD_FUNC_SHUTDOWN, &cmd, sizeof(cmd),
+ lbs_cmd_copyback, (unsigned long) &cmd))
+ lbs_pr_alert("CMD_FUNC_SHUTDOWN command failed\n");
+ }
+
dev = priv->dev;
netif_stop_queue(dev);
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 8e669775cb5d..65f02cc6752f 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -25,7 +25,6 @@ struct rfc1042hdr {
} __attribute__ ((packed));
struct rxpackethdr {
- struct rxpd rx_pd;
struct eth803hdr eth803_hdr;
struct rfc1042hdr rfc1042_hdr;
} __attribute__ ((packed));
@@ -158,10 +157,18 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
if (priv->monitormode)
return process_rxed_802_11_packet(priv, skb);
- p_rx_pkt = (struct rxpackethdr *) skb->data;
- p_rx_pd = &p_rx_pkt->rx_pd;
- if (priv->mesh_dev && (p_rx_pd->rx_control & RxPD_MESH_FRAME))
- dev = priv->mesh_dev;
+ p_rx_pd = (struct rxpd *) skb->data;
+ p_rx_pkt = (struct rxpackethdr *) ((u8 *)p_rx_pd +
+ le32_to_cpu(p_rx_pd->pkt_ptr));
+ if (priv->mesh_dev) {
+ if (priv->mesh_fw_ver == MESH_FW_OLD) {
+ if (p_rx_pd->rx_control & RxPD_MESH_FRAME)
+ dev = priv->mesh_dev;
+ } else if (priv->mesh_fw_ver == MESH_FW_NEW) {
+ if (p_rx_pd->u.bss.bss_num == MESH_IFACE_ID)
+ dev = priv->mesh_dev;
+ }
+ }
lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data,
min_t(unsigned int, skb->len, 100));
@@ -174,20 +181,9 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
goto done;
}
- /*
- * Check rxpd status and update 802.3 stat,
- */
- if (!(p_rx_pd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) {
- lbs_deb_rx("rx err: frame received with bad status\n");
- lbs_pr_alert("rxpd not ok\n");
- dev->stats.rx_errors++;
- ret = 0;
- dev_kfree_skb(skb);
- goto done;
- }
-
- lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n",
- skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
+ lbs_deb_rx("rx data: skb->len - pkt_ptr = %d-%zd = %zd\n",
+ skb->len, (size_t)le32_to_cpu(p_rx_pd->pkt_ptr),
+ skb->len - (size_t)le32_to_cpu(p_rx_pd->pkt_ptr));
lbs_deb_hex(LBS_DEB_RX, "RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr,
sizeof(p_rx_pkt->eth803_hdr.dest_addr));
@@ -221,14 +217,14 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
/* Chop off the rxpd + the excess memory from the 802.2/llc/snap header
* that was removed
*/
- hdrchop = (u8 *) p_ethhdr - (u8 *) p_rx_pkt;
+ hdrchop = (u8 *)p_ethhdr - (u8 *)p_rx_pd;
} else {
lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP",
(u8 *) & p_rx_pkt->rfc1042_hdr,
sizeof(p_rx_pkt->rfc1042_hdr));
/* Chop off the rxpd */
- hdrchop = (u8 *) & p_rx_pkt->eth803_hdr - (u8 *) p_rx_pkt;
+ hdrchop = (u8 *)&p_rx_pkt->eth803_hdr - (u8 *)p_rx_pd;
}
/* Chop off the leading header bytes so the skb points to the start of
@@ -334,14 +330,6 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
goto done;
}
- /*
- * Check rxpd status and update 802.3 stat,
- */
- if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) {
- //lbs_deb_rx("rx err: frame received with bad status\n");
- dev->stats.rx_errors++;
- }
-
lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n",
skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
@@ -353,8 +341,6 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
radiotap_hdr.hdr.it_pad = 0;
radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr));
radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT);
- if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK)))
- radiotap_hdr.flags |= IEEE80211_RADIOTAP_F_BADFCS;
radiotap_hdr.rate = convert_mv_rate_to_radiotap(prxpd->rx_rate);
/* XXX must check no carryout */
radiotap_hdr.antsignal = prxpd->snr + prxpd->nf;
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index f10aa39a6b68..160cfd8311c0 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -132,8 +132,12 @@ int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
txpd->tx_packet_length = cpu_to_le16(pkt_len);
txpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd));
- if (dev == priv->mesh_dev)
- txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
+ if (dev == priv->mesh_dev) {
+ if (priv->mesh_fw_ver == MESH_FW_OLD)
+ txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
+ else if (priv->mesh_fw_ver == MESH_FW_NEW)
+ txpd->u.bss.bss_num = MESH_IFACE_ID;
+ }
lbs_deb_hex(LBS_DEB_TX, "txpd", (u8 *) &txpd, sizeof(struct txpd));
diff --git a/drivers/net/wireless/libertas/types.h b/drivers/net/wireless/libertas/types.h
index fb7a2d1a2525..de03b9c9c204 100644
--- a/drivers/net/wireless/libertas/types.h
+++ b/drivers/net/wireless/libertas/types.h
@@ -94,6 +94,8 @@ struct ieeetypes_assocrsp {
#define TLV_TYPE_TSFTIMESTAMP (PROPRIETARY_TLV_BASE_ID + 19)
#define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 22)
#define TLV_TYPE_SNR_HIGH (PROPRIETARY_TLV_BASE_ID + 23)
+#define TLV_TYPE_MESH_ID (PROPRIETARY_TLV_BASE_ID + 37)
+#define TLV_TYPE_OLD_MESH_ID (PROPRIETARY_TLV_BASE_ID + 291)
/** TLV related data structures*/
struct mrvlietypesheader {
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
index 59634c33b1f9..392337b37b1d 100644
--- a/drivers/net/wireless/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/libertas_tf/if_usb.c
@@ -461,8 +461,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
return;
}
- if (!in_interrupt())
- BUG();
+ BUG_ON(!in_interrupt());
spin_lock(&priv->driver_lock);
memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN,
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index e7289e2e7f16..10a99e26d392 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -366,36 +366,6 @@ static int lbtf_op_config(struct ieee80211_hw *hw, u32 changed)
return 0;
}
-static int lbtf_op_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct lbtf_private *priv = hw->priv;
- struct sk_buff *beacon;
-
- switch (priv->vif->type) {
- case NL80211_IFTYPE_AP:
- case NL80211_IFTYPE_MESH_POINT:
- beacon = ieee80211_beacon_get(hw, vif);
- if (beacon) {
- lbtf_beacon_set(priv, beacon);
- kfree_skb(beacon);
- lbtf_beacon_ctrl(priv, 1, hw->conf.beacon_int);
- }
- break;
- default:
- break;
- }
-
- if (conf->bssid) {
- u8 null_bssid[ETH_ALEN] = {0};
- bool activate = compare_ether_addr(conf->bssid, null_bssid);
- lbtf_set_bssid(priv, activate, conf->bssid);
- }
-
- return 0;
-}
-
#define SUPPORTED_FIF_FLAGS (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)
static void lbtf_op_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
@@ -451,6 +421,29 @@ static void lbtf_op_bss_info_changed(struct ieee80211_hw *hw,
u32 changes)
{
struct lbtf_private *priv = hw->priv;
+ struct sk_buff *beacon;
+
+ if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_INT)) {
+ switch (priv->vif->type) {
+ case NL80211_IFTYPE_AP:
+ case NL80211_IFTYPE_MESH_POINT:
+ beacon = ieee80211_beacon_get(hw, vif);
+ if (beacon) {
+ lbtf_beacon_set(priv, beacon);
+ kfree_skb(beacon);
+ lbtf_beacon_ctrl(priv, 1,
+ bss_conf->beacon_int);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (changes & BSS_CHANGED_BSSID) {
+ bool activate = !is_zero_ether_addr(bss_conf->bssid);
+ lbtf_set_bssid(priv, activate, bss_conf->bssid);
+ }
if (changes & BSS_CHANGED_ERP_PREAMBLE) {
if (bss_conf->use_short_preamble)
@@ -459,8 +452,6 @@ static void lbtf_op_bss_info_changed(struct ieee80211_hw *hw,
priv->preamble = CMD_TYPE_LONG_PREAMBLE;
lbtf_set_radio_control(priv);
}
-
- return;
}
static const struct ieee80211_ops lbtf_ops = {
@@ -470,7 +461,6 @@ static const struct ieee80211_ops lbtf_ops = {
.add_interface = lbtf_op_add_interface,
.remove_interface = lbtf_op_remove_interface,
.config = lbtf_op_config,
- .config_interface = lbtf_op_config_interface,
.configure_filter = lbtf_op_configure_filter,
.bss_info_changed = lbtf_op_bss_info_changed,
};
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index d4fdc8b7d7d8..574b8bb121e1 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -291,6 +291,14 @@ struct mac80211_hwsim_data {
bool ps_poll_pending;
struct dentry *debugfs;
struct dentry *debugfs_ps;
+
+ /*
+ * Only radios in the same group can communicate together (the
+ * channel has to match too). Each bit represents a group. A
+ * radio can be in more then one group.
+ */
+ u64 group;
+ struct dentry *debugfs_group;
};
@@ -412,7 +420,8 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
if (!data2->started || !data2->radio_enabled ||
!hwsim_ps_rx_ok(data2, skb) ||
- data->channel->center_freq != data2->channel->center_freq)
+ data->channel->center_freq != data2->channel->center_freq ||
+ !(data->group & data2->group))
continue;
nskb = skb_copy(skb, GFP_ATOMIC);
@@ -553,18 +562,15 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
struct mac80211_hwsim_data *data = hw->priv;
struct ieee80211_conf *conf = &hw->conf;
- printk(KERN_DEBUG "%s:%s (freq=%d radio_enabled=%d beacon_int=%d)\n",
+ printk(KERN_DEBUG "%s:%s (freq=%d radio_enabled=%d idle=%d ps=%d)\n",
wiphy_name(hw->wiphy), __func__,
conf->channel->center_freq, conf->radio_enabled,
- conf->beacon_int);
+ !!(conf->flags & IEEE80211_CONF_IDLE),
+ !!(conf->flags & IEEE80211_CONF_PS));
data->channel = conf->channel;
data->radio_enabled = conf->radio_enabled;
- data->beacon_int = 1024 * conf->beacon_int / 1000 * HZ / 1000;
- if (data->beacon_int < 1)
- data->beacon_int = 1;
-
- if (!data->started || !data->radio_enabled)
+ if (!data->started || !data->radio_enabled || !data->beacon_int)
del_timer(&data->beacon_timer);
else
mod_timer(&data->beacon_timer, jiffies + data->beacon_int);
@@ -592,35 +598,26 @@ static void mac80211_hwsim_configure_filter(struct ieee80211_hw *hw,
*total_flags = data->rx_filter;
}
-static int mac80211_hwsim_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
-
- hwsim_check_magic(vif);
- if (conf->changed & IEEE80211_IFCC_BSSID) {
- DECLARE_MAC_BUF(mac);
- printk(KERN_DEBUG "%s:%s: BSSID changed: %pM\n",
- wiphy_name(hw->wiphy), __func__,
- conf->bssid);
- memcpy(vp->bssid, conf->bssid, ETH_ALEN);
- }
- return 0;
-}
-
static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *info,
u32 changed)
{
struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
+ struct mac80211_hwsim_data *data = hw->priv;
hwsim_check_magic(vif);
printk(KERN_DEBUG "%s:%s(changed=0x%x)\n",
wiphy_name(hw->wiphy), __func__, changed);
+ if (changed & BSS_CHANGED_BSSID) {
+ printk(KERN_DEBUG "%s:%s: BSSID changed: %pM\n",
+ wiphy_name(hw->wiphy), __func__,
+ info->bssid);
+ memcpy(vp->bssid, info->bssid, ETH_ALEN);
+ }
+
if (changed & BSS_CHANGED_ASSOC) {
printk(KERN_DEBUG " %s: ASSOC: assoc=%d aid=%d\n",
wiphy_name(hw->wiphy), info->assoc, info->aid);
@@ -628,6 +625,14 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
vp->aid = info->aid;
}
+ if (changed & BSS_CHANGED_BEACON_INT) {
+ printk(KERN_DEBUG " %s: BCNINT: %d\n",
+ wiphy_name(hw->wiphy), info->beacon_int);
+ data->beacon_int = 1024 * info->beacon_int / 1000 * HZ / 1000;
+ if (WARN_ON(!data->beacon_int))
+ data->beacon_int = 1;
+ }
+
if (changed & BSS_CHANGED_ERP_CTS_PROT) {
printk(KERN_DEBUG " %s: ERP_CTS_PROT: %d\n",
wiphy_name(hw->wiphy), info->use_cts_prot);
@@ -646,7 +651,7 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_HT) {
printk(KERN_DEBUG " %s: HT: op_mode=0x%x\n",
wiphy_name(hw->wiphy),
- info->ht.operation_mode);
+ info->ht_operation_mode);
}
if (changed & BSS_CHANGED_BASIC_RATES) {
@@ -704,7 +709,6 @@ static const struct ieee80211_ops mac80211_hwsim_ops =
.remove_interface = mac80211_hwsim_remove_interface,
.config = mac80211_hwsim_config,
.configure_filter = mac80211_hwsim_configure_filter,
- .config_interface = mac80211_hwsim_config_interface,
.bss_info_changed = mac80211_hwsim_bss_info_changed,
.sta_notify = mac80211_hwsim_sta_notify,
.set_tim = mac80211_hwsim_set_tim,
@@ -725,6 +729,7 @@ static void mac80211_hwsim_free(void)
spin_unlock_bh(&hwsim_radio_lock);
list_for_each_entry(data, &tmplist, list) {
+ debugfs_remove(data->debugfs_group);
debugfs_remove(data->debugfs_ps);
debugfs_remove(data->debugfs);
ieee80211_unregister_hw(data->hw);
@@ -877,6 +882,24 @@ DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write,
"%llu\n");
+static int hwsim_fops_group_read(void *dat, u64 *val)
+{
+ struct mac80211_hwsim_data *data = dat;
+ *val = data->group;
+ return 0;
+}
+
+static int hwsim_fops_group_write(void *dat, u64 val)
+{
+ struct mac80211_hwsim_data *data = dat;
+ data->group = val;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_group,
+ hwsim_fops_group_read, hwsim_fops_group_write,
+ "%llx\n");
+
static int __init init_mac80211_hwsim(void)
{
int i, err = 0;
@@ -981,6 +1004,8 @@ static int __init init_mac80211_hwsim(void)
hw->wiphy->bands[band] = sband;
}
+ /* By default all radios are belonging to the first group */
+ data->group = 1;
/* Work to be done prior to ieee80211_register_hw() */
switch (regtest) {
@@ -1105,6 +1130,9 @@ static int __init init_mac80211_hwsim(void)
data->debugfs_ps = debugfs_create_file("ps", 0666,
data->debugfs, data,
&hwsim_fops_ps);
+ data->debugfs_group = debugfs_create_file("group", 0666,
+ data->debugfs, data,
+ &hwsim_fops_group);
setup_timer(&data->beacon_timer, mac80211_hwsim_beacon,
(unsigned long) hw);
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index a9a970469c2a..a263d5c84c08 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -2369,7 +2369,7 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
if (info->use_cts_prot) {
prot_mode = MWL8K_FRAME_PROT_11G;
} else {
- switch (info->ht.operation_mode &
+ switch (info->ht_operation_mode &
IEEE80211_HT_OP_MODE_PROTECTION) {
case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
prot_mode = MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY;
@@ -3089,19 +3089,6 @@ static int mwl8k_config(struct ieee80211_hw *hw, u32 changed)
return rc ? -EINVAL : 0;
}
-static int mwl8k_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
- u32 changed = conf->changed;
-
- if (changed & IEEE80211_IFCC_BSSID)
- memcpy(mv_vif->bssid, conf->bssid, IEEE80211_ADDR_LEN);
-
- return 0;
-}
-
struct mwl8k_bss_info_changed_worker {
struct mwl8k_work_struct header;
struct ieee80211_vif *vif;
@@ -3183,8 +3170,12 @@ static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
{
struct mwl8k_bss_info_changed_worker *worker;
struct mwl8k_priv *priv = hw->priv;
+ struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
int rc;
+ if (changed & BSS_CHANGED_BSSID)
+ memcpy(mv_vif->bssid, info->bssid, IEEE80211_ADDR_LEN);
+
if ((changed & BSS_CHANGED_ASSOC) == 0)
return;
@@ -3442,7 +3433,6 @@ static const struct ieee80211_ops mwl8k_ops = {
.add_interface = mwl8k_add_interface,
.remove_interface = mwl8k_remove_interface,
.config = mwl8k_config,
- .config_interface = mwl8k_config_interface,
.bss_info_changed = mwl8k_bss_info_changed,
.configure_filter = mwl8k_configure_filter,
.set_rts_threshold = mwl8k_set_rts_threshold,
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
index ecf8b6ed5a47..db3df947d8ed 100644
--- a/drivers/net/wireless/p54/p54.h
+++ b/drivers/net/wireless/p54/p54.h
@@ -125,6 +125,7 @@ struct p54_led_dev {
struct led_classdev led_dev;
char name[P54_LED_MAX_NAME_LEN + 1];
+ unsigned int toggled;
unsigned int index;
unsigned int registered;
};
@@ -133,55 +134,74 @@ struct p54_led_dev {
struct p54_common {
struct ieee80211_hw *hw;
- u32 rx_start;
- u32 rx_end;
- struct sk_buff_head tx_queue;
+ struct ieee80211_vif *vif;
void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb);
int (*open)(struct ieee80211_hw *dev);
void (*stop)(struct ieee80211_hw *dev);
- int mode;
+ struct sk_buff_head tx_queue;
+ struct mutex conf_mutex;
+
+ /* memory management (as seen by the firmware) */
+ u32 rx_start;
+ u32 rx_end;
u16 rx_mtu;
u8 headroom;
u8 tailroom;
- struct mutex conf_mutex;
- u8 mac_addr[ETH_ALEN];
- u8 bssid[ETH_ALEN];
+
+ /* firmware/hardware info */
+ unsigned int tx_hdr_len;
+ unsigned int fw_var;
+ unsigned int fw_interface;
+ u8 version;
+
+ /* (e)DCF / QOS state */
+ bool use_short_slot;
+ struct ieee80211_tx_queue_stats tx_stats[8];
+ struct p54_edcf_queue_param qos_params[8];
+
+ /* Radio data */
+ u16 rxhw;
u8 rx_diversity_mask;
u8 tx_diversity_mask;
+ unsigned int output_power;
+ int noise;
+ /* calibration, output power limit and rssi<->dBm conversation data */
struct pda_iq_autocal_entry *iq_autocal;
unsigned int iq_autocal_len;
- struct p54_cal_database *output_limit;
struct p54_cal_database *curve_data;
+ struct p54_cal_database *output_limit;
struct p54_rssi_linear_approximation rssical_db[IEEE80211_NUM_BANDS];
+
+ /* BBP/MAC state */
+ u8 mac_addr[ETH_ALEN];
+ u8 bssid[ETH_ALEN];
+ u16 wakeup_timer;
unsigned int filter_flags;
- bool use_short_slot;
- u16 rxhw;
- u8 version;
- unsigned int tx_hdr_len;
- unsigned int fw_var;
- unsigned int fw_interface;
- unsigned int output_power;
- u32 tsf_low32;
- u32 tsf_high32;
+ int mode;
+ u32 tsf_low32, tsf_high32;
u32 basic_rate_mask;
- u16 wakeup_timer;
u16 aid;
- struct ieee80211_tx_queue_stats tx_stats[8];
- struct p54_edcf_queue_param qos_params[8];
- struct ieee80211_low_level_stats stats;
- struct delayed_work work;
struct sk_buff *cached_beacon;
- int noise;
- void *eeprom;
- struct completion eeprom_comp;
+
+ /* cryptographic engine information */
u8 privacy_caps;
u8 rx_keycache_size;
+ unsigned long *used_rxkeys;
+
/* LED management */
#ifdef CONFIG_P54_LEDS
- struct p54_led_dev assoc_led;
- struct p54_led_dev tx_led;
+ struct p54_led_dev leds[4];
+ struct delayed_work led_work;
#endif /* CONFIG_P54_LEDS */
u16 softled_state; /* bit field of glowing LEDs */
+
+ /* statistics */
+ struct ieee80211_low_level_stats stats;
+ struct delayed_work work;
+
+ /* eeprom handling */
+ void *eeprom;
+ struct completion eeprom_comp;
};
int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb);
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index c8f0232ee5e0..48d81d98e12d 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -249,7 +249,7 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
dev->queues = P54_QUEUE_AC_NUM;
}
- if (!modparam_nohwcrypt)
+ if (!modparam_nohwcrypt) {
printk(KERN_INFO "%s: cryptographic accelerator "
"WEP:%s, TKIP:%s, CCMP:%s\n",
wiphy_name(dev->wiphy),
@@ -259,6 +259,26 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP) ?
"YES" : "no");
+ if (priv->rx_keycache_size) {
+ /*
+ * NOTE:
+ *
+ * The firmware provides at most 255 (0 - 254) slots
+ * for keys which are then used to offload decryption.
+ * As a result the 255 entry (aka 0xff) can be used
+ * safely by the driver to mark keys that didn't fit
+ * into the full cache. This trick saves us from
+ * keeping a extra list for uploaded keys.
+ */
+
+ priv->used_rxkeys = kzalloc(BITS_TO_LONGS(
+ priv->rx_keycache_size), GFP_KERNEL);
+
+ if (!priv->used_rxkeys)
+ return -ENOMEM;
+ }
+ }
+
return 0;
}
EXPORT_SYMBOL_GPL(p54_parse_firmware);
@@ -749,8 +769,6 @@ static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
rx_status.signal = p54_rssi_to_dbm(dev, hdr->rssi);
rx_status.noise = priv->noise;
- /* XX correct? */
- rx_status.qual = (100 * hdr->rssi) / 127;
if (hdr->rate & 0x10)
rx_status.flag |= RX_FLAG_SHORTPRE;
if (dev->conf.channel->band == IEEE80211_BAND_5GHZ)
@@ -804,7 +822,6 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
struct ieee80211_tx_info *info;
struct p54_tx_info *range;
unsigned long flags;
- u32 freed = 0, last_addr = priv->rx_start;
if (unlikely(!skb || !dev || !skb_queue_len(&priv->tx_queue)))
return;
@@ -824,7 +841,6 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
ni = IEEE80211_SKB_CB(skb->prev);
mr = (struct p54_tx_info *)ni->rate_driver_data;
- last_addr = mr->end_addr;
}
if (skb->next != (struct sk_buff *)&priv->tx_queue) {
struct ieee80211_tx_info *ni;
@@ -832,16 +848,11 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
ni = IEEE80211_SKB_CB(skb->next);
mr = (struct p54_tx_info *)ni->rate_driver_data;
- freed = mr->start_addr - last_addr;
- } else
- freed = priv->rx_end - last_addr;
+ }
__skb_unlink(skb, &priv->tx_queue);
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
dev_kfree_skb_any(skb);
-
- if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
- IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
- p54_wake_free_queues(dev);
+ p54_wake_free_queues(dev);
}
EXPORT_SYMBOL_GPL(p54_free_skb);
@@ -875,8 +886,6 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
struct sk_buff *entry;
u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom;
struct p54_tx_info *range = NULL;
- u32 freed = 0;
- u32 last_addr = priv->rx_start;
unsigned long flags;
int count, idx;
@@ -890,7 +899,6 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
range = (void *)info->rate_driver_data;
if (range->start_addr != addr) {
- last_addr = range->end_addr;
entry = entry->next;
continue;
}
@@ -901,11 +909,8 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
ni = IEEE80211_SKB_CB(entry->next);
mr = (struct p54_tx_info *)ni->rate_driver_data;
- freed = mr->start_addr - last_addr;
- } else
- freed = priv->rx_end - last_addr;
+ }
- last_addr = range->end_addr;
__skb_unlink(entry, &priv->tx_queue);
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
@@ -992,9 +997,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
out:
- if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
- IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
- p54_wake_free_queues(dev);
+ p54_wake_free_queues(dev);
}
static void p54_rx_eeprom_readback(struct ieee80211_hw *dev,
@@ -1044,6 +1047,7 @@ static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb)
static void p54_rx_trap(struct ieee80211_hw *dev, struct sk_buff *skb)
{
+ struct p54_common *priv = dev->priv;
struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
struct p54_trap *trap = (struct p54_trap *) hdr->data;
u16 event = le16_to_cpu(trap->event);
@@ -1057,6 +1061,8 @@ static void p54_rx_trap(struct ieee80211_hw *dev, struct sk_buff *skb)
wiphy_name(dev->wiphy), freq);
break;
case P54_TRAP_NO_BEACON:
+ if (priv->vif)
+ ieee80211_beacon_loss(priv->vif);
break;
case P54_TRAP_SCAN:
break;
@@ -1452,7 +1458,8 @@ static int p54_tx_fill(struct ieee80211_hw *dev, struct sk_buff *skb,
if (info->control.sta)
*aid = info->control.sta->aid;
- else
+
+ if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
*flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
break;
}
@@ -1939,7 +1946,8 @@ static int p54_set_ps(struct ieee80211_hw *dev)
int i;
if (dev->conf.flags & IEEE80211_CONF_PS)
- mode = P54_PSM | P54_PSM_DTIM | P54_PSM_MCBC;
+ mode = P54_PSM | P54_PSM_BEACON_TIMEOUT | P54_PSM_DTIM |
+ P54_PSM_CHECKSUM | P54_PSM_MCBC;
else
mode = P54_PSM_CAM;
@@ -1957,9 +1965,10 @@ static int p54_set_ps(struct ieee80211_hw *dev)
psm->intervals[i].periods = cpu_to_le16(1);
}
- psm->beacon_rssi_skip_max = 60;
+ psm->beacon_rssi_skip_max = 200;
psm->rssi_delta_threshold = 0;
- psm->nr = 0;
+ psm->nr = 10;
+ psm->exclude[0] = 0;
priv->tx(dev, skb);
@@ -2088,6 +2097,9 @@ static void p54_stop(struct ieee80211_hw *dev)
priv->softled_state = 0;
p54_set_leds(dev);
+#ifdef CONFIG_P54_LEDS
+ cancel_delayed_work_sync(&priv->led_work);
+#endif /* CONFIG_P54_LEDS */
cancel_delayed_work_sync(&priv->work);
if (priv->cached_beacon)
p54_tx_cancel(dev, priv->cached_beacon);
@@ -2111,6 +2123,8 @@ static int p54_add_interface(struct ieee80211_hw *dev,
return -EOPNOTSUPP;
}
+ priv->vif = conf->vif;
+
switch (conf->type) {
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_ADHOC:
@@ -2135,6 +2149,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
struct p54_common *priv = dev->priv;
mutex_lock(&priv->conf_mutex);
+ priv->vif = NULL;
if (priv->cached_beacon)
p54_tx_cancel(dev, priv->cached_beacon);
priv->mode = NL80211_IFTYPE_MONITOR;
@@ -2174,41 +2189,6 @@ out:
return ret;
}
-static int p54_config_interface(struct ieee80211_hw *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct p54_common *priv = dev->priv;
- int ret = 0;
-
- mutex_lock(&priv->conf_mutex);
- if (conf->changed & IEEE80211_IFCC_BSSID) {
- memcpy(priv->bssid, conf->bssid, ETH_ALEN);
- ret = p54_setup_mac(dev);
- if (ret)
- goto out;
- }
-
- if (conf->changed & IEEE80211_IFCC_BEACON) {
- ret = p54_scan(dev, P54_SCAN_EXIT, 0);
- if (ret)
- goto out;
- ret = p54_setup_mac(dev);
- if (ret)
- goto out;
- ret = p54_beacon_update(dev, vif);
- if (ret)
- goto out;
- ret = p54_set_edcf(dev);
- if (ret)
- goto out;
- }
-
-out:
- mutex_unlock(&priv->conf_mutex);
- return ret;
-}
-
static void p54_configure_filter(struct ieee80211_hw *dev,
unsigned int changed_flags,
unsigned int *total_flags,
@@ -2312,8 +2292,32 @@ static void p54_bss_info_changed(struct ieee80211_hw *dev,
u32 changed)
{
struct p54_common *priv = dev->priv;
+ int ret;
- if (changed & BSS_CHANGED_ERP_SLOT) {
+ mutex_lock(&priv->conf_mutex);
+ if (changed & BSS_CHANGED_BSSID) {
+ memcpy(priv->bssid, info->bssid, ETH_ALEN);
+ ret = p54_setup_mac(dev);
+ if (ret)
+ goto out;
+ }
+
+ if (changed & BSS_CHANGED_BEACON) {
+ ret = p54_scan(dev, P54_SCAN_EXIT, 0);
+ if (ret)
+ goto out;
+ ret = p54_setup_mac(dev);
+ if (ret)
+ goto out;
+ ret = p54_beacon_update(dev, vif);
+ if (ret)
+ goto out;
+ }
+ /* XXX: this mimics having two callbacks... clean up */
+ out:
+ mutex_unlock(&priv->conf_mutex);
+
+ if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_BEACON)) {
priv->use_short_slot = info->use_short_slot;
p54_set_edcf(dev);
}
@@ -2334,7 +2338,6 @@ static void p54_bss_info_changed(struct ieee80211_hw *dev,
p54_setup_mac(dev);
}
}
-
}
static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
@@ -2344,61 +2347,84 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
struct p54_common *priv = dev->priv;
struct sk_buff *skb;
struct p54_keycache *rxkey;
+ int slot, ret = 0;
u8 algo = 0;
if (modparam_nohwcrypt)
return -EOPNOTSUPP;
- if (cmd == DISABLE_KEY)
- algo = 0;
- else {
+ mutex_lock(&priv->conf_mutex);
+ if (cmd == SET_KEY) {
switch (key->alg) {
case ALG_TKIP:
if (!(priv->privacy_caps & (BR_DESC_PRIV_CAP_MICHAEL |
- BR_DESC_PRIV_CAP_TKIP)))
- return -EOPNOTSUPP;
+ BR_DESC_PRIV_CAP_TKIP))) {
+ ret = -EOPNOTSUPP;
+ goto out_unlock;
+ }
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
algo = P54_CRYPTO_TKIPMICHAEL;
break;
case ALG_WEP:
- if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_WEP))
- return -EOPNOTSUPP;
+ if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_WEP)) {
+ ret = -EOPNOTSUPP;
+ goto out_unlock;
+ }
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
algo = P54_CRYPTO_WEP;
break;
case ALG_CCMP:
- if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP))
- return -EOPNOTSUPP;
+ if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP)) {
+ ret = -EOPNOTSUPP;
+ goto out_unlock;
+ }
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
algo = P54_CRYPTO_AESCCMP;
break;
default:
- return -EOPNOTSUPP;
+ ret = -EOPNOTSUPP;
+ goto out_unlock;
}
- }
+ slot = bitmap_find_free_region(priv->used_rxkeys,
+ priv->rx_keycache_size, 0);
- if (key->keyidx > priv->rx_keycache_size) {
- /*
- * The device supports the choosen algorithm, but the firmware
- * does not provide enough key slots to store all of them.
- * So, incoming frames have to be decoded by the mac80211 stack,
- * but we can still offload encryption for outgoing frames.
- */
+ if (slot < 0) {
+ /*
+ * The device supports the choosen algorithm, but the
+ * firmware does not provide enough key slots to store
+ * all of them.
+ * But encryption offload for outgoing frames is always
+ * possible, so we just pretend that the upload was
+ * successful and do the decryption in software.
+ */
- return 0;
+ /* mark the key as invalid. */
+ key->hw_key_idx = 0xff;
+ goto out_unlock;
+ }
+ } else {
+ slot = key->hw_key_idx;
+
+ if (slot == 0xff) {
+ /* This key was not uploaded into the rx key cache. */
+
+ goto out_unlock;
+ }
+
+ bitmap_release_region(priv->used_rxkeys, slot, 0);
+ algo = 0;
}
- mutex_lock(&priv->conf_mutex);
skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*rxkey),
- P54_CONTROL_TYPE_RX_KEYCACHE, GFP_ATOMIC);
+ P54_CONTROL_TYPE_RX_KEYCACHE, GFP_KERNEL);
if (!skb) {
- mutex_unlock(&priv->conf_mutex);
- return -ENOMEM;
+ bitmap_release_region(priv->used_rxkeys, slot, 0);
+ ret = -ENOSPC;
+ goto out_unlock;
}
- /* TODO: some devices have 4 more free slots for rx keys */
rxkey = (struct p54_keycache *)skb_put(skb, sizeof(*rxkey));
- rxkey->entry = key->keyidx;
+ rxkey->entry = slot;
rxkey->key_id = key->keyidx;
rxkey->key_type = algo;
if (sta)
@@ -2416,11 +2442,51 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
}
priv->tx(dev, skb);
+ key->hw_key_idx = slot;
+
+out_unlock:
mutex_unlock(&priv->conf_mutex);
- return 0;
+ return ret;
}
#ifdef CONFIG_P54_LEDS
+static void p54_update_leds(struct work_struct *work)
+{
+ struct p54_common *priv = container_of(work, struct p54_common,
+ led_work.work);
+ int err, i, tmp, blink_delay = 400;
+ bool rerun = false;
+
+ /* Don't toggle the LED, when the device is down. */
+ if (priv->mode == NL80211_IFTYPE_UNSPECIFIED)
+ return ;
+
+ for (i = 0; i < ARRAY_SIZE(priv->leds); i++)
+ if (priv->leds[i].toggled) {
+ priv->softled_state |= BIT(i);
+
+ tmp = 70 + 200 / (priv->leds[i].toggled);
+ if (tmp < blink_delay)
+ blink_delay = tmp;
+
+ if (priv->leds[i].led_dev.brightness == LED_OFF)
+ rerun = true;
+
+ priv->leds[i].toggled =
+ !!priv->leds[i].led_dev.brightness;
+ } else
+ priv->softled_state &= ~BIT(i);
+
+ err = p54_set_leds(priv->hw);
+ if (err && net_ratelimit())
+ printk(KERN_ERR "%s: failed to update LEDs.\n",
+ wiphy_name(priv->hw->wiphy));
+
+ if (rerun)
+ queue_delayed_work(priv->hw->workqueue, &priv->led_work,
+ msecs_to_jiffies(blink_delay));
+}
+
static void p54_led_brightness_set(struct led_classdev *led_dev,
enum led_brightness brightness)
{
@@ -2428,28 +2494,23 @@ static void p54_led_brightness_set(struct led_classdev *led_dev,
led_dev);
struct ieee80211_hw *dev = led->hw_dev;
struct p54_common *priv = dev->priv;
- int err;
- /* Don't toggle the LED, when the device is down. */
if (priv->mode == NL80211_IFTYPE_UNSPECIFIED)
return ;
- if (brightness != LED_OFF)
- priv->softled_state |= BIT(led->index);
- else
- priv->softled_state &= ~BIT(led->index);
-
- err = p54_set_leds(dev);
- if (err && net_ratelimit())
- printk(KERN_ERR "%s: failed to update %s LED.\n",
- wiphy_name(dev->wiphy), led_dev->name);
+ if (brightness) {
+ led->toggled++;
+ queue_delayed_work(priv->hw->workqueue, &priv->led_work,
+ HZ/10);
+ }
}
static int p54_register_led(struct ieee80211_hw *dev,
- struct p54_led_dev *led,
unsigned int led_index,
char *name, char *trigger)
{
+ struct p54_common *priv = dev->priv;
+ struct p54_led_dev *led = &priv->leds[led_index];
int err;
if (led->registered)
@@ -2482,19 +2543,30 @@ static int p54_init_leds(struct ieee80211_hw *dev)
* TODO:
* Figure out if the EEPROM contains some hints about the number
* of available/programmable LEDs of the device.
- * But for now, we can assume that we have two programmable LEDs.
*/
- err = p54_register_led(dev, &priv->assoc_led, 0, "assoc",
+ INIT_DELAYED_WORK(&priv->led_work, p54_update_leds);
+
+ err = p54_register_led(dev, 0, "assoc",
ieee80211_get_assoc_led_name(dev));
if (err)
return err;
- err = p54_register_led(dev, &priv->tx_led, 1, "tx",
+ err = p54_register_led(dev, 1, "tx",
ieee80211_get_tx_led_name(dev));
if (err)
return err;
+ err = p54_register_led(dev, 2, "rx",
+ ieee80211_get_rx_led_name(dev));
+ if (err)
+ return err;
+
+ err = p54_register_led(dev, 3, "radio",
+ ieee80211_get_radio_led_name(dev));
+ if (err)
+ return err;
+
err = p54_set_leds(dev);
return err;
}
@@ -2502,11 +2574,11 @@ static int p54_init_leds(struct ieee80211_hw *dev)
static void p54_unregister_leds(struct ieee80211_hw *dev)
{
struct p54_common *priv = dev->priv;
+ int i;
- if (priv->tx_led.registered)
- led_classdev_unregister(&priv->tx_led.led_dev);
- if (priv->assoc_led.registered)
- led_classdev_unregister(&priv->assoc_led.led_dev);
+ for (i = 0; i < ARRAY_SIZE(priv->leds); i++)
+ if (priv->leds[i].registered)
+ led_classdev_unregister(&priv->leds[i].led_dev);
}
#endif /* CONFIG_P54_LEDS */
@@ -2520,7 +2592,6 @@ static const struct ieee80211_ops p54_ops = {
.sta_notify = p54_sta_notify,
.set_key = p54_set_key,
.config = p54_config,
- .config_interface = p54_config_interface,
.bss_info_changed = p54_bss_info_changed,
.configure_filter = p54_configure_filter,
.conf_tx = p54_conf_tx,
@@ -2607,21 +2678,10 @@ void p54_free_common(struct ieee80211_hw *dev)
kfree(priv->iq_autocal);
kfree(priv->output_limit);
kfree(priv->curve_data);
+ kfree(priv->used_rxkeys);
#ifdef CONFIG_P54_LEDS
p54_unregister_leds(dev);
#endif /* CONFIG_P54_LEDS */
}
EXPORT_SYMBOL_GPL(p54_free_common);
-
-static int __init p54_init(void)
-{
- return 0;
-}
-
-static void __exit p54_exit(void)
-{
-}
-
-module_init(p54_init);
-module_exit(p54_exit);
diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c
index d1fe577de3d4..83116baeb110 100644
--- a/drivers/net/wireless/p54/p54spi.c
+++ b/drivers/net/wireless/p54/p54spi.c
@@ -96,7 +96,7 @@ static void p54spi_spi_write(struct p54s_priv *priv, u8 address,
spi_message_add_tail(&t[0], &m);
t[1].tx_buf = buf;
- t[1].len = len;
+ t[1].len = len & ~1;
spi_message_add_tail(&t[1], &m);
if (len % 2) {
@@ -167,15 +167,31 @@ static const struct p54spi_spi_reg p54spi_registers_array[] =
static int p54spi_wait_bit(struct p54s_priv *priv, u16 reg, __le32 bits)
{
int i;
- __le32 buffer;
for (i = 0; i < 2000; i++) {
- p54spi_spi_read(priv, reg, &buffer, sizeof(buffer));
- if (buffer == bits)
+ __le32 buffer = p54spi_read32(priv, reg);
+ if ((buffer & bits) == bits)
return 1;
+ }
+ return 0;
+}
- msleep(1);
+static int p54spi_spi_write_dma(struct p54s_priv *priv, __le32 base,
+ const void *buf, size_t len)
+{
+ if (!p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL,
+ cpu_to_le32(HOST_ALLOWED))) {
+ dev_err(&priv->spi->dev, "spi_write_dma not allowed "
+ "to DMA write.\n");
+ return -EAGAIN;
}
+
+ p54spi_write16(priv, SPI_ADRS_DMA_WRITE_CTRL,
+ cpu_to_le16(SPI_DMA_WRITE_CTRL_ENABLE));
+
+ p54spi_write16(priv, SPI_ADRS_DMA_WRITE_LEN, cpu_to_le16(len));
+ p54spi_write32(priv, SPI_ADRS_DMA_WRITE_BASE, base);
+ p54spi_spi_write(priv, SPI_ADRS_DMA_DATA, buf, len);
return 0;
}
@@ -228,8 +244,15 @@ static int p54spi_request_eeprom(struct ieee80211_hw *dev)
static int p54spi_upload_firmware(struct ieee80211_hw *dev)
{
struct p54s_priv *priv = dev->priv;
- unsigned long fw_len, fw_addr;
- long _fw_len;
+ unsigned long fw_len, _fw_len;
+ unsigned int offset = 0;
+ int err = 0;
+ u8 *fw;
+
+ fw_len = priv->firmware->size;
+ fw = kmemdup(priv->firmware->data, fw_len, GFP_KERNEL);
+ if (!fw)
+ return -ENOMEM;
/* stop the device */
p54spi_write16(priv, SPI_ADRS_DEV_CTRL_STAT, cpu_to_le16(
@@ -244,36 +267,17 @@ static int p54spi_upload_firmware(struct ieee80211_hw *dev)
msleep(TARGET_BOOT_SLEEP);
- fw_addr = ISL38XX_DEV_FIRMWARE_ADDR;
- fw_len = priv->firmware->size;
-
while (fw_len > 0) {
_fw_len = min_t(long, fw_len, SPI_MAX_PACKET_SIZE);
- p54spi_write16(priv, SPI_ADRS_DMA_WRITE_CTRL,
- cpu_to_le16(SPI_DMA_WRITE_CTRL_ENABLE));
-
- if (p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL,
- cpu_to_le32(HOST_ALLOWED)) == 0) {
- dev_err(&priv->spi->dev, "fw_upload not allowed "
- "to DMA write.");
- return -EAGAIN;
- }
-
- p54spi_write16(priv, SPI_ADRS_DMA_WRITE_LEN,
- cpu_to_le16(_fw_len));
- p54spi_write32(priv, SPI_ADRS_DMA_WRITE_BASE,
- cpu_to_le32(fw_addr));
-
- p54spi_spi_write(priv, SPI_ADRS_DMA_DATA,
- &priv->firmware->data, _fw_len);
+ err = p54spi_spi_write_dma(priv, cpu_to_le32(
+ ISL38XX_DEV_FIRMWARE_ADDR + offset),
+ (fw + offset), _fw_len);
+ if (err < 0)
+ goto out;
fw_len -= _fw_len;
- fw_addr += _fw_len;
-
- /* FIXME: I think this doesn't work if firmware is large,
- * this loop goes to second round. fw->data is not
- * increased at all! */
+ offset += _fw_len;
}
BUG_ON(fw_len != 0);
@@ -292,7 +296,10 @@ static int p54spi_upload_firmware(struct ieee80211_hw *dev)
p54spi_write16(priv, SPI_ADRS_DEV_CTRL_STAT, cpu_to_le16(
SPI_CTRL_STAT_HOST_OVERRIDE | SPI_CTRL_STAT_RAM_BOOT));
msleep(TARGET_BOOT_SLEEP);
- return 0;
+
+out:
+ kfree(fw);
+ return err;
}
static void p54spi_power_off(struct p54s_priv *priv)
@@ -318,29 +325,21 @@ static inline void p54spi_int_ack(struct p54s_priv *priv, u32 val)
p54spi_write32(priv, SPI_ADRS_HOST_INT_ACK, cpu_to_le32(val));
}
-static void p54spi_wakeup(struct p54s_priv *priv)
+static int p54spi_wakeup(struct p54s_priv *priv)
{
- unsigned long timeout;
- u32 ints;
-
/* wake the chip */
p54spi_write32(priv, SPI_ADRS_ARM_INTERRUPTS,
cpu_to_le32(SPI_TARGET_INT_WAKEUP));
/* And wait for the READY interrupt */
- timeout = jiffies + HZ;
-
- ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
- while (!(ints & SPI_HOST_INT_READY)) {
- if (time_after(jiffies, timeout))
- goto out;
- ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
+ if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS,
+ cpu_to_le32(SPI_HOST_INT_READY))) {
+ dev_err(&priv->spi->dev, "INT_READY timeout\n");
+ return -EBUSY;
}
p54spi_int_ack(priv, SPI_HOST_INT_READY);
-
-out:
- return;
+ return 0;
}
static inline void p54spi_sleep(struct p54s_priv *priv)
@@ -372,27 +371,48 @@ static int p54spi_rx(struct p54s_priv *priv)
{
struct sk_buff *skb;
u16 len;
+ u16 rx_head[2];
+#define READAHEAD_SZ (sizeof(rx_head)-sizeof(u16))
- p54spi_wakeup(priv);
-
- /* dummy read to flush SPI DMA controller bug */
- p54spi_read16(priv, SPI_ADRS_GEN_PURP_1);
+ if (p54spi_wakeup(priv) < 0)
+ return -EBUSY;
- len = p54spi_read16(priv, SPI_ADRS_DMA_DATA);
+ /* Read data size and first data word in one SPI transaction
+ * This is workaround for firmware/DMA bug,
+ * when first data word gets lost under high load.
+ */
+ p54spi_spi_read(priv, SPI_ADRS_DMA_DATA, rx_head, sizeof(rx_head));
+ len = rx_head[0];
if (len == 0) {
- dev_err(&priv->spi->dev, "rx request of zero bytes");
+ p54spi_sleep(priv);
+ dev_err(&priv->spi->dev, "rx request of zero bytes\n");
return 0;
}
- skb = dev_alloc_skb(len);
+ /* Firmware may insert up to 4 padding bytes after the lmac header,
+ * but it does not amend the size of SPI data transfer.
+ * Such packets has correct data size in header, thus referencing
+ * past the end of allocated skb. Reserve extra 4 bytes for this case */
+ skb = dev_alloc_skb(len + 4);
if (!skb) {
+ p54spi_sleep(priv);
dev_err(&priv->spi->dev, "could not alloc skb");
- return 0;
+ return -ENOMEM;
}
- p54spi_spi_read(priv, SPI_ADRS_DMA_DATA, skb_put(skb, len), len);
+ if (len <= READAHEAD_SZ) {
+ memcpy(skb_put(skb, len), rx_head + 1, len);
+ } else {
+ memcpy(skb_put(skb, READAHEAD_SZ), rx_head + 1, READAHEAD_SZ);
+ p54spi_spi_read(priv, SPI_ADRS_DMA_DATA,
+ skb_put(skb, len - READAHEAD_SZ),
+ len - READAHEAD_SZ);
+ }
p54spi_sleep(priv);
+ /* Put additional bytes to compensate for the possible
+ * alignment-caused truncation */
+ skb_put(skb, 4);
if (p54_rx(priv->hw, skb) == 0)
dev_kfree_skb(skb);
@@ -414,39 +434,28 @@ static irqreturn_t p54spi_interrupt(int irq, void *config)
static int p54spi_tx_frame(struct p54s_priv *priv, struct sk_buff *skb)
{
struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
- struct p54s_dma_regs dma_regs;
- unsigned long timeout;
int ret = 0;
- u32 ints;
-
- p54spi_wakeup(priv);
- dma_regs.cmd = cpu_to_le16(SPI_DMA_WRITE_CTRL_ENABLE);
- dma_regs.len = cpu_to_le16(skb->len);
- dma_regs.addr = hdr->req_id;
+ if (p54spi_wakeup(priv) < 0)
+ return -EBUSY;
- p54spi_spi_write(priv, SPI_ADRS_DMA_WRITE_CTRL, &dma_regs,
- sizeof(dma_regs));
-
- p54spi_spi_write(priv, SPI_ADRS_DMA_DATA, skb->data, skb->len);
+ ret = p54spi_spi_write_dma(priv, hdr->req_id, skb->data, skb->len);
+ if (ret < 0)
+ goto out;
- timeout = jiffies + 2 * HZ;
- ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
- while (!(ints & SPI_HOST_INT_WR_READY)) {
- if (time_after(jiffies, timeout)) {
- dev_err(&priv->spi->dev, "WR_READY timeout");
- ret = -1;
- goto out;
- }
- ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
+ if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS,
+ cpu_to_le32(SPI_HOST_INT_WR_READY))) {
+ dev_err(&priv->spi->dev, "WR_READY timeout\n");
+ ret = -EAGAIN;
+ goto out;
}
p54spi_int_ack(priv, SPI_HOST_INT_WR_READY);
- p54spi_sleep(priv);
-out:
if (FREE_AFTER_TX(skb))
p54_free_skb(priv->hw, skb);
+out:
+ p54spi_sleep(priv);
return ret;
}
@@ -516,8 +525,7 @@ static void p54spi_work(struct work_struct *work)
mutex_lock(&priv->mutex);
- if (priv->fw_state == FW_STATE_OFF &&
- priv->fw_state == FW_STATE_RESET)
+ if (priv->fw_state == FW_STATE_OFF)
goto out;
ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
@@ -544,11 +552,6 @@ static void p54spi_work(struct work_struct *work)
}
ret = p54spi_wq_tx(priv);
- if (ret < 0)
- goto out;
-
- ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
-
out:
mutex_unlock(&priv->mutex);
}
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index 6cc6cbc9234f..f40c0f468b27 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -81,6 +81,29 @@ static struct usb_device_id p54u_table[] __devinitdata = {
MODULE_DEVICE_TABLE(usb, p54u_table);
+static const struct {
+ u32 intf;
+ enum p54u_hw_type type;
+ char fw[FIRMWARE_NAME_MAX];
+ char fw_legacy[FIRMWARE_NAME_MAX];
+ char hw[20];
+} p54u_fwlist[__NUM_P54U_HWTYPES] = {
+ {
+ .type = P54U_NET2280,
+ .intf = FW_LM86,
+ .fw = "isl3886usb",
+ .fw_legacy = "isl3890usb",
+ .hw = "ISL3886 + net2280",
+ },
+ {
+ .type = P54U_3887,
+ .intf = FW_LM87,
+ .fw = "isl3887usb",
+ .fw_legacy = "isl3887usb_bare",
+ .hw = "ISL3887",
+ },
+};
+
static void p54u_rx_cb(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
@@ -125,11 +148,7 @@ static void p54u_rx_cb(struct urb *urb)
}
skb_reset_tail_pointer(skb);
skb_trim(skb, 0);
- if (urb->transfer_buffer != skb_tail_pointer(skb)) {
- /* this should not happen */
- WARN_ON(1);
- urb->transfer_buffer = skb_tail_pointer(skb);
- }
+ urb->transfer_buffer = skb_tail_pointer(skb);
}
skb_queue_tail(&priv->rx_queue, skb);
usb_anchor_urb(urb, &priv->submitted);
@@ -206,53 +225,6 @@ static int p54u_init_urbs(struct ieee80211_hw *dev)
return ret;
}
-static void p54u_tx_3887(struct ieee80211_hw *dev, struct sk_buff *skb)
-{
- struct p54u_priv *priv = dev->priv;
- struct urb *addr_urb, *data_urb;
- int err = 0;
-
- addr_urb = usb_alloc_urb(0, GFP_ATOMIC);
- if (!addr_urb)
- return;
-
- data_urb = usb_alloc_urb(0, GFP_ATOMIC);
- if (!data_urb) {
- usb_free_urb(addr_urb);
- return;
- }
-
- usb_fill_bulk_urb(addr_urb, priv->udev,
- usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
- &((struct p54_hdr *)skb->data)->req_id, 4,
- p54u_tx_dummy_cb, dev);
- usb_fill_bulk_urb(data_urb, priv->udev,
- usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
- skb->data, skb->len, FREE_AFTER_TX(skb) ?
- p54u_tx_cb : p54u_tx_dummy_cb, skb);
- addr_urb->transfer_flags |= URB_ZERO_PACKET;
- data_urb->transfer_flags |= URB_ZERO_PACKET;
-
- usb_anchor_urb(addr_urb, &priv->submitted);
- err = usb_submit_urb(addr_urb, GFP_ATOMIC);
- if (err) {
- usb_unanchor_urb(addr_urb);
- goto out;
- }
-
- usb_anchor_urb(data_urb, &priv->submitted);
- err = usb_submit_urb(data_urb, GFP_ATOMIC);
- if (err)
- usb_unanchor_urb(data_urb);
-
- out:
- usb_free_urb(addr_urb);
- usb_free_urb(data_urb);
-
- if (err)
- p54_free_skb(dev, skb);
-}
-
static __le32 p54u_lm87_chksum(const __le32 *data, size_t length)
{
u32 chk = 0;
@@ -425,20 +397,16 @@ static int p54u_bulk_msg(struct p54u_priv *priv, unsigned int ep,
data, len, &alen, 2000);
}
-static const char p54u_romboot_3887[] = "~~~~";
-static const char p54u_firmware_upload_3887[] = "<\r";
-
-static int p54u_device_reset_3887(struct ieee80211_hw *dev)
+static int p54u_device_reset(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
int ret, lock = (priv->intf->condition != USB_INTERFACE_BINDING);
- u8 buf[4];
if (lock) {
ret = usb_lock_device_for_reset(priv->udev, priv->intf);
if (ret < 0) {
dev_err(&priv->udev->dev, "(p54usb) unable to lock "
- " device for reset: %d\n", ret);
+ "device for reset (%d)!\n", ret);
return ret;
}
}
@@ -447,26 +415,34 @@ static int p54u_device_reset_3887(struct ieee80211_hw *dev)
if (lock)
usb_unlock_device(priv->udev);
- if (ret) {
+ if (ret)
dev_err(&priv->udev->dev, "(p54usb) unable to reset "
- "device: %d\n", ret);
- return ret;
- }
+ "device (%d)!\n", ret);
+
+ return ret;
+}
+
+static const char p54u_romboot_3887[] = "~~~~";
+static int p54u_firmware_reset_3887(struct ieee80211_hw *dev)
+{
+ struct p54u_priv *priv = dev->priv;
+ u8 buf[4];
+ int ret;
memcpy(&buf, p54u_romboot_3887, sizeof(buf));
ret = p54u_bulk_msg(priv, P54U_PIPE_DATA,
buf, sizeof(buf));
if (ret)
dev_err(&priv->udev->dev, "(p54usb) unable to jump to "
- "boot ROM: %d\n", ret);
+ "boot ROM (%d)!\n", ret);
return ret;
}
+static const char p54u_firmware_upload_3887[] = "<\r";
static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
- const struct firmware *fw_entry = NULL;
int err, alen;
u8 carry = 0;
u8 *buf, *tmp;
@@ -475,51 +451,29 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
struct x2_header *hdr;
unsigned long timeout;
+ err = p54u_firmware_reset_3887(dev);
+ if (err)
+ return err;
+
tmp = buf = kmalloc(P54U_FW_BLOCK, GFP_KERNEL);
if (!buf) {
dev_err(&priv->udev->dev, "(p54usb) cannot allocate firmware"
"upload buffer!\n");
- err = -ENOMEM;
- goto err_bufalloc;
- }
-
- err = p54u_device_reset_3887(dev);
- if (err)
- goto err_reset;
-
- err = request_firmware(&fw_entry, "isl3887usb", &priv->udev->dev);
- if (err) {
- dev_err(&priv->udev->dev, "p54usb: cannot find firmware "
- "(isl3887usb)\n");
- err = request_firmware(&fw_entry, "isl3887usb_bare",
- &priv->udev->dev);
- if (err)
- goto err_req_fw_failed;
- }
-
- err = p54_parse_firmware(dev, fw_entry);
- if (err)
- goto err_upload_failed;
-
- if (priv->common.fw_interface != FW_LM87) {
- dev_err(&priv->udev->dev, "wrong firmware, "
- "please get a LM87 firmware and try again.\n");
- err = -EINVAL;
- goto err_upload_failed;
+ return -ENOMEM;
}
- left = block_size = min((size_t)P54U_FW_BLOCK, fw_entry->size);
+ left = block_size = min((size_t)P54U_FW_BLOCK, priv->fw->size);
strcpy(buf, p54u_firmware_upload_3887);
left -= strlen(p54u_firmware_upload_3887);
tmp += strlen(p54u_firmware_upload_3887);
- data = fw_entry->data;
- remains = fw_entry->size;
+ data = priv->fw->data;
+ remains = priv->fw->size;
hdr = (struct x2_header *)(buf + strlen(p54u_firmware_upload_3887));
memcpy(hdr->signature, X2_SIGNATURE, X2_SIGNATURE_SIZE);
hdr->fw_load_addr = cpu_to_le32(ISL38XX_DEV_FIRMWARE_ADDR);
- hdr->fw_length = cpu_to_le32(fw_entry->size);
+ hdr->fw_length = cpu_to_le32(priv->fw->size);
hdr->crc = cpu_to_le32(~crc32_le(~0, (void *)&hdr->fw_load_addr,
sizeof(u32)*2));
left -= sizeof(*hdr);
@@ -561,7 +515,8 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
left = block_size = min((unsigned int)P54U_FW_BLOCK, remains);
}
- *((__le32 *)buf) = cpu_to_le32(~crc32_le(~0, fw_entry->data, fw_entry->size));
+ *((__le32 *)buf) = cpu_to_le32(~crc32_le(~0, priv->fw->data,
+ priv->fw->size));
err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, sizeof(u32));
if (err) {
dev_err(&priv->udev->dev, "(p54usb) firmware upload failed!\n");
@@ -612,19 +567,14 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
if (err)
goto err_upload_failed;
- err_upload_failed:
- release_firmware(fw_entry);
- err_req_fw_failed:
- err_reset:
+err_upload_failed:
kfree(buf);
- err_bufalloc:
return err;
}
static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
- const struct firmware *fw_entry = NULL;
const struct p54p_csr *devreg = (const struct p54p_csr *) P54U_DEV_BASE;
int err, alen;
void *buf;
@@ -639,33 +589,6 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
return -ENOMEM;
}
- err = request_firmware(&fw_entry, "isl3886usb", &priv->udev->dev);
- if (err) {
- dev_err(&priv->udev->dev, "(p54usb) cannot find firmware "
- "(isl3886usb)\n");
- err = request_firmware(&fw_entry, "isl3890usb",
- &priv->udev->dev);
- if (err) {
- kfree(buf);
- return err;
- }
- }
-
- err = p54_parse_firmware(dev, fw_entry);
- if (err) {
- kfree(buf);
- release_firmware(fw_entry);
- return err;
- }
-
- if (priv->common.fw_interface != FW_LM86) {
- dev_err(&priv->udev->dev, "wrong firmware, "
- "please get a LM86(USB) firmware and try again.\n");
- kfree(buf);
- release_firmware(fw_entry);
- return -EINVAL;
- }
-
#define P54U_WRITE(type, addr, data) \
do {\
err = p54u_write(priv, buf, type,\
@@ -765,8 +688,8 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);
/* finally, we can upload firmware now! */
- remains = fw_entry->size;
- data = fw_entry->data;
+ remains = priv->fw->size;
+ data = priv->fw->data;
offset = ISL38XX_DEV_FIRMWARE_ADDR;
while (remains) {
@@ -875,12 +798,54 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
#undef P54U_WRITE
#undef P54U_READ
- fail:
- release_firmware(fw_entry);
+fail:
kfree(buf);
return err;
}
+static int p54u_load_firmware(struct ieee80211_hw *dev)
+{
+ struct p54u_priv *priv = dev->priv;
+ int err, i;
+
+ BUILD_BUG_ON(ARRAY_SIZE(p54u_fwlist) != __NUM_P54U_HWTYPES);
+
+ for (i = 0; i < __NUM_P54U_HWTYPES; i++)
+ if (p54u_fwlist[i].type == priv->hw_type)
+ break;
+
+ if (i == __NUM_P54U_HWTYPES)
+ return -EOPNOTSUPP;
+
+ err = request_firmware(&priv->fw, p54u_fwlist[i].fw, &priv->udev->dev);
+ if (err) {
+ dev_err(&priv->udev->dev, "(p54usb) cannot load firmware %s "
+ "(%d)!\n", p54u_fwlist[i].fw, err);
+
+ err = request_firmware(&priv->fw, p54u_fwlist[i].fw_legacy,
+ &priv->udev->dev);
+ if (err)
+ return err;
+ }
+
+ err = p54_parse_firmware(dev, priv->fw);
+ if (err)
+ goto out;
+
+ if (priv->common.fw_interface != p54u_fwlist[i].intf) {
+ dev_err(&priv->udev->dev, "wrong firmware, please get "
+ "a firmware for \"%s\" and try again.\n",
+ p54u_fwlist[i].hw);
+ err = -EINVAL;
+ }
+
+out:
+ if (err)
+ release_firmware(priv->fw);
+
+ return err;
+}
+
static int p54u_open(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
@@ -922,6 +887,7 @@ static int __devinit p54u_probe(struct usb_interface *intf,
}
priv = dev->priv;
+ priv->hw_type = P54U_INVALID_HW;
SET_IEEE80211_DEV(dev, &intf->dev);
usb_set_intfdata(intf, dev);
@@ -953,37 +919,48 @@ static int __devinit p54u_probe(struct usb_interface *intf,
priv->common.open = p54u_open;
priv->common.stop = p54u_stop;
if (recognized_pipes < P54U_PIPE_NUMBER) {
+#ifdef CONFIG_PM
+ /* ISL3887 needs a full reset on resume */
+ udev->reset_resume = 1;
+ err = p54u_device_reset(dev);
+#endif
+
priv->hw_type = P54U_3887;
- err = p54u_upload_firmware_3887(dev);
- if (priv->common.fw_interface == FW_LM87) {
- dev->extra_tx_headroom += sizeof(struct lm87_tx_hdr);
- priv->common.tx_hdr_len = sizeof(struct lm87_tx_hdr);
- priv->common.tx = p54u_tx_lm87;
- } else
- priv->common.tx = p54u_tx_3887;
+ dev->extra_tx_headroom += sizeof(struct lm87_tx_hdr);
+ priv->common.tx_hdr_len = sizeof(struct lm87_tx_hdr);
+ priv->common.tx = p54u_tx_lm87;
+ priv->upload_fw = p54u_upload_firmware_3887;
} else {
priv->hw_type = P54U_NET2280;
dev->extra_tx_headroom += sizeof(struct net2280_tx_hdr);
priv->common.tx_hdr_len = sizeof(struct net2280_tx_hdr);
priv->common.tx = p54u_tx_net2280;
- err = p54u_upload_firmware_net2280(dev);
+ priv->upload_fw = p54u_upload_firmware_net2280;
}
+ err = p54u_load_firmware(dev);
if (err)
goto err_free_dev;
+ err = priv->upload_fw(dev);
+ if (err)
+ goto err_free_fw;
+
p54u_open(dev);
err = p54_read_eeprom(dev);
p54u_stop(dev);
if (err)
- goto err_free_dev;
+ goto err_free_fw;
err = p54_register_common(dev, &udev->dev);
if (err)
- goto err_free_dev;
+ goto err_free_fw;
return 0;
- err_free_dev:
+err_free_fw:
+ release_firmware(priv->fw);
+
+err_free_dev:
ieee80211_free_hw(dev);
usb_set_intfdata(intf, NULL);
usb_put_dev(udev);
@@ -1002,20 +979,64 @@ static void __devexit p54u_disconnect(struct usb_interface *intf)
priv = dev->priv;
usb_put_dev(interface_to_usbdev(intf));
+ release_firmware(priv->fw);
p54_free_common(dev);
ieee80211_free_hw(dev);
}
static int p54u_pre_reset(struct usb_interface *intf)
{
+ struct ieee80211_hw *dev = usb_get_intfdata(intf);
+
+ if (!dev)
+ return -ENODEV;
+
+ p54u_stop(dev);
return 0;
}
+static int p54u_resume(struct usb_interface *intf)
+{
+ struct ieee80211_hw *dev = usb_get_intfdata(intf);
+ struct p54u_priv *priv;
+
+ if (!dev)
+ return -ENODEV;
+
+ priv = dev->priv;
+ if (unlikely(!(priv->upload_fw && priv->fw)))
+ return 0;
+
+ return priv->upload_fw(dev);
+}
+
static int p54u_post_reset(struct usb_interface *intf)
{
+ struct ieee80211_hw *dev = usb_get_intfdata(intf);
+ struct p54u_priv *priv;
+ int err;
+
+ err = p54u_resume(intf);
+ if (err)
+ return err;
+
+ /* reinitialize old device state */
+ priv = dev->priv;
+ if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED)
+ ieee80211_restart_hw(dev);
+
return 0;
}
+#ifdef CONFIG_PM
+
+static int p54u_suspend(struct usb_interface *intf, pm_message_t message)
+{
+ return p54u_pre_reset(intf);
+}
+
+#endif /* CONFIG_PM */
+
static struct usb_driver p54u_driver = {
.name = "p54usb",
.id_table = p54u_table,
@@ -1023,6 +1044,11 @@ static struct usb_driver p54u_driver = {
.disconnect = p54u_disconnect,
.pre_reset = p54u_pre_reset,
.post_reset = p54u_post_reset,
+#ifdef CONFIG_PM
+ .suspend = p54u_suspend,
+ .resume = p54u_resume,
+ .reset_resume = p54u_resume,
+#endif /* CONFIG_PM */
.soft_unbind = 1,
};
diff --git a/drivers/net/wireless/p54/p54usb.h b/drivers/net/wireless/p54/p54usb.h
index 8bc58982d8dd..e935b79f7f75 100644
--- a/drivers/net/wireless/p54/p54usb.h
+++ b/drivers/net/wireless/p54/p54usb.h
@@ -123,18 +123,26 @@ struct p54u_rx_info {
struct ieee80211_hw *dev;
};
+enum p54u_hw_type {
+ P54U_INVALID_HW,
+ P54U_NET2280,
+ P54U_3887,
+
+ /* keep last */
+ __NUM_P54U_HWTYPES,
+};
+
struct p54u_priv {
struct p54_common common;
struct usb_device *udev;
struct usb_interface *intf;
- enum {
- P54U_NET2280 = 0,
- P54U_3887
- } hw_type;
+ int (*upload_fw)(struct ieee80211_hw *dev);
+ enum p54u_hw_type hw_type;
spinlock_t lock;
struct sk_buff_head rx_queue;
struct usb_anchor submitted;
+ const struct firmware *fw;
};
#endif /* P54USB_H */
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index fa90d1d8d82e..22e71856aa24 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -892,7 +892,7 @@ static int ray_dev_init(struct net_device *dev)
#endif /* RAY_IMMEDIATE_INIT */
/* copy mac and broadcast addresses to linux device */
- memcpy(&dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
+ memcpy(dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
memset(dev->broadcast, 0xff, ETH_ALEN);
DEBUG(2, "ray_dev_init ending\n");
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index bebf735cd4bd..7f98a6f0c7ed 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2,7 +2,7 @@
* Driver for RNDIS based wireless USB devices.
*
* Copyright (C) 2007 by Bjorge Dijkstra <bjd@jooz.net>
- * Copyright (C) 2008 by Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
+ * Copyright (C) 2008-2009 by Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
#include <linux/ctype.h>
#include <linux/spinlock.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>
#include <linux/usb/usbnet.h>
#include <linux/usb/rndis_host.h>
@@ -195,6 +196,18 @@ enum ndis_80211_priv_filter {
ndis_80211_priv_8021x_wep
};
+enum ndis_80211_addkey_bits {
+ ndis_80211_addkey_8021x_auth = cpu_to_le32(1 << 28),
+ ndis_80211_addkey_set_init_recv_seq = cpu_to_le32(1 << 29),
+ ndis_80211_addkey_pairwise_key = cpu_to_le32(1 << 30),
+ ndis_80211_addkey_transmit_key = cpu_to_le32(1 << 31),
+};
+
+enum ndis_80211_addwep_bits {
+ ndis_80211_addwep_perclient_key = cpu_to_le32(1 << 30),
+ ndis_80211_addwep_transmit_key = cpu_to_le32(1 << 31),
+};
+
struct ndis_80211_ssid {
__le32 length;
u8 essid[NDIS_802_11_LENGTH_SSID];
@@ -308,7 +321,6 @@ enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
#define CAP_MODE_80211B 2
#define CAP_MODE_80211G 4
#define CAP_MODE_MASK 7
-#define CAP_SUPPORT_TXPOWER 8
#define WORK_LINK_UP (1<<0)
#define WORK_LINK_DOWN (1<<1)
@@ -316,25 +328,61 @@ enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
#define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set))
+static const struct ieee80211_channel rndis_channels[] = {
+ { .center_freq = 2412 },
+ { .center_freq = 2417 },
+ { .center_freq = 2422 },
+ { .center_freq = 2427 },
+ { .center_freq = 2432 },
+ { .center_freq = 2437 },
+ { .center_freq = 2442 },
+ { .center_freq = 2447 },
+ { .center_freq = 2452 },
+ { .center_freq = 2457 },
+ { .center_freq = 2462 },
+ { .center_freq = 2467 },
+ { .center_freq = 2472 },
+ { .center_freq = 2484 },
+};
+
+static const struct ieee80211_rate rndis_rates[] = {
+ { .bitrate = 10 },
+ { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 60 },
+ { .bitrate = 90 },
+ { .bitrate = 120 },
+ { .bitrate = 180 },
+ { .bitrate = 240 },
+ { .bitrate = 360 },
+ { .bitrate = 480 },
+ { .bitrate = 540 }
+};
+
/* RNDIS device private data */
struct rndis_wext_private {
- char name[32];
-
struct usbnet *usbdev;
+ struct wireless_dev wdev;
+
+ struct cfg80211_scan_request *scan_request;
+
struct workqueue_struct *workqueue;
struct delayed_work stats_work;
+ struct delayed_work scan_work;
struct work_struct work;
struct mutex command_lock;
spinlock_t stats_lock;
unsigned long work_pending;
+ struct ieee80211_supported_band band;
+ struct ieee80211_channel channels[ARRAY_SIZE(rndis_channels)];
+ struct ieee80211_rate rates[ARRAY_SIZE(rndis_rates)];
+
struct iw_statistics iwstats;
struct iw_statistics privstats;
- int nick_len;
- char nick[32];
-
int caps;
int multicast_size;
@@ -357,6 +405,7 @@ struct rndis_wext_private {
int encr_tx_key_index;
char encr_keys[4][32];
int encr_key_len[4];
+ char encr_key_wpa[4];
int wpa_version;
int wpa_keymgmt;
int wpa_authalg;
@@ -368,8 +417,22 @@ struct rndis_wext_private {
u8 command_buffer[COMMAND_BUFFER_SIZE];
};
+/*
+ * cfg80211 ops
+ */
+static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex,
+ enum nl80211_iftype type, u32 *flags,
+ struct vif_params *params);
+
+static int rndis_scan(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_scan_request *request);
+
+static struct cfg80211_ops rndis_config_ops = {
+ .change_virtual_intf = rndis_change_virtual_intf,
+ .scan = rndis_scan,
+};
-static const int rates_80211g[8] = { 6, 9, 12, 18, 24, 36, 48, 54 };
+static void *rndis_wiphy_privid = &rndis_wiphy_privid;
static const int bcm4320_power_output[4] = { 25, 50, 75, 100 };
@@ -584,7 +647,7 @@ static int rndis_set_config_parameter(struct usbnet *dev, char *param,
ret = rndis_set_oid(dev, OID_GEN_RNDIS_CONFIG_PARAMETER,
infobuf, info_len);
if (ret != 0)
- devdbg(dev, "setting rndis config paramater failed, %d.", ret);
+ devdbg(dev, "setting rndis config parameter failed, %d.", ret);
kfree(infobuf);
return ret;
@@ -894,7 +957,7 @@ static int set_infra_mode(struct usbnet *usbdev, int mode)
if (priv->wpa_keymgmt == 0 ||
priv->wpa_keymgmt == IW_AUTH_KEY_MGMT_802_1X) {
for (i = 0; i < 4; i++) {
- if (priv->encr_key_len[i] > 0)
+ if (priv->encr_key_len[i] > 0 && !priv->encr_key_wpa[i])
add_wep_key(usbdev, priv->encr_keys[i],
priv->encr_key_len[i], i);
}
@@ -948,7 +1011,7 @@ static int add_wep_key(struct usbnet *usbdev, char *key, int key_len, int index)
memcpy(&ndis_key.material, key, key_len);
if (index == priv->encr_tx_key_index) {
- ndis_key.index |= cpu_to_le32(1 << 31);
+ ndis_key.index |= ndis_80211_addwep_transmit_key;
ret = set_encr_mode(usbdev, IW_AUTH_CIPHER_WEP104,
IW_AUTH_CIPHER_NONE);
if (ret)
@@ -965,12 +1028,81 @@ static int add_wep_key(struct usbnet *usbdev, char *key, int key_len, int index)
}
priv->encr_key_len[index] = key_len;
+ priv->encr_key_wpa[index] = 0;
memcpy(&priv->encr_keys[index], key, key_len);
return 0;
}
+static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
+ int index, const struct sockaddr *addr,
+ const u8 *rx_seq, int alg, int flags)
+{
+ struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
+ struct ndis_80211_key ndis_key;
+ int ret;
+
+ if (index < 0 || index >= 4)
+ return -EINVAL;
+ if (key_len > sizeof(ndis_key.material) || key_len < 0)
+ return -EINVAL;
+ if ((flags & ndis_80211_addkey_set_init_recv_seq) && !rx_seq)
+ return -EINVAL;
+ if ((flags & ndis_80211_addkey_pairwise_key) && !addr)
+ return -EINVAL;
+
+ devdbg(usbdev, "add_wpa_key(%i): flags:%i%i%i", index,
+ !!(flags & ndis_80211_addkey_transmit_key),
+ !!(flags & ndis_80211_addkey_pairwise_key),
+ !!(flags & ndis_80211_addkey_set_init_recv_seq));
+
+ memset(&ndis_key, 0, sizeof(ndis_key));
+
+ ndis_key.size = cpu_to_le32(sizeof(ndis_key) -
+ sizeof(ndis_key.material) + key_len);
+ ndis_key.length = cpu_to_le32(key_len);
+ ndis_key.index = cpu_to_le32(index) | flags;
+
+ if (alg == IW_ENCODE_ALG_TKIP && key_len == 32) {
+ /* wpa_supplicant gives us the Michael MIC RX/TX keys in
+ * different order than NDIS spec, so swap the order here. */
+ memcpy(ndis_key.material, key, 16);
+ memcpy(ndis_key.material + 16, key + 24, 8);
+ memcpy(ndis_key.material + 24, key + 16, 8);
+ } else
+ memcpy(ndis_key.material, key, key_len);
+
+ if (flags & ndis_80211_addkey_set_init_recv_seq)
+ memcpy(ndis_key.rsc, rx_seq, 6);
+
+ if (flags & ndis_80211_addkey_pairwise_key) {
+ /* pairwise key */
+ memcpy(ndis_key.bssid, addr->sa_data, ETH_ALEN);
+ } else {
+ /* group key */
+ if (priv->infra_mode == ndis_80211_infra_adhoc)
+ memset(ndis_key.bssid, 0xff, ETH_ALEN);
+ else
+ get_bssid(usbdev, ndis_key.bssid);
+ }
+
+ ret = rndis_set_oid(usbdev, OID_802_11_ADD_KEY, &ndis_key,
+ le32_to_cpu(ndis_key.size));
+ devdbg(usbdev, "add_wpa_key: OID_802_11_ADD_KEY -> %08X", ret);
+ if (ret != 0)
+ return ret;
+
+ priv->encr_key_len[index] = key_len;
+ priv->encr_key_wpa[index] = 1;
+
+ if (flags & ndis_80211_addkey_transmit_key)
+ priv->encr_tx_key_index = index;
+
+ return 0;
+}
+
+
/* remove_key is for both wep and wpa */
static int remove_key(struct usbnet *usbdev, int index, u8 bssid[ETH_ALEN])
{
@@ -983,6 +1115,7 @@ static int remove_key(struct usbnet *usbdev, int index, u8 bssid[ETH_ALEN])
return 0;
priv->encr_key_len[index] = 0;
+ priv->encr_key_wpa[index] = 0;
memset(&priv->encr_keys[index], 0, sizeof(priv->encr_keys[index]));
if (priv->wpa_cipher_pair == IW_AUTH_CIPHER_TKIP ||
@@ -994,7 +1127,8 @@ static int remove_key(struct usbnet *usbdev, int index, u8 bssid[ETH_ALEN])
if (bssid) {
/* pairwise key */
if (memcmp(bssid, ffff_bssid, ETH_ALEN) != 0)
- remove_key.index |= cpu_to_le32(1 << 30);
+ remove_key.index |=
+ ndis_80211_addkey_pairwise_key;
memcpy(remove_key.bssid, bssid,
sizeof(remove_key.bssid));
} else
@@ -1086,131 +1220,180 @@ static void set_multicast_list(struct usbnet *usbdev)
/*
- * wireless extension handlers
+ * cfg80211 ops
*/
-
-static int rndis_iw_commit(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
+static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex,
+ enum nl80211_iftype type, u32 *flags,
+ struct vif_params *params)
{
- /* dummy op */
- return 0;
+ struct net_device *dev;
+ struct usbnet *usbdev;
+ int mode;
+
+ /* we're under RTNL */
+ dev = __dev_get_by_index(&init_net, ifindex);
+ if (!dev)
+ return -ENODEV;
+ usbdev = netdev_priv(dev);
+
+ switch (type) {
+ case NL80211_IFTYPE_ADHOC:
+ mode = ndis_80211_infra_adhoc;
+ break;
+ case NL80211_IFTYPE_STATION:
+ mode = ndis_80211_infra_infra;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return set_infra_mode(usbdev, mode);
}
-static int rndis_iw_get_range(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
+#define SCAN_DELAY_JIFFIES (HZ)
+static int rndis_scan(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_scan_request *request)
{
- struct iw_range *range = (struct iw_range *)extra;
struct usbnet *usbdev = netdev_priv(dev);
struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
- int len, ret, i, j, num, has_80211g_rates;
- u8 rates[8];
- __le32 tx_power;
+ int ret;
+ __le32 tmp;
- devdbg(usbdev, "SIOCGIWRANGE");
+ devdbg(usbdev, "cfg80211.scan");
- /* clear iw_range struct */
- memset(range, 0, sizeof(*range));
- wrqu->data.length = sizeof(*range);
+ if (!request)
+ return -EINVAL;
- range->txpower_capa = IW_TXPOW_MWATT;
- range->num_txpower = 1;
- if (priv->caps & CAP_SUPPORT_TXPOWER) {
- len = sizeof(tx_power);
- ret = rndis_query_oid(usbdev, OID_802_11_TX_POWER_LEVEL,
- &tx_power, &len);
- if (ret == 0 && le32_to_cpu(tx_power) != 0xFF)
- range->txpower[0] = le32_to_cpu(tx_power);
- else
- range->txpower[0] = get_bcm4320_power(priv);
- } else
- range->txpower[0] = get_bcm4320_power(priv);
+ if (priv->scan_request && priv->scan_request != request)
+ return -EBUSY;
- len = sizeof(rates);
- ret = rndis_query_oid(usbdev, OID_802_11_SUPPORTED_RATES, &rates,
- &len);
- has_80211g_rates = 0;
+ priv->scan_request = request;
+
+ tmp = cpu_to_le32(1);
+ ret = rndis_set_oid(usbdev, OID_802_11_BSSID_LIST_SCAN, &tmp,
+ sizeof(tmp));
if (ret == 0) {
- j = 0;
- for (i = 0; i < len; i++) {
- if (rates[i] == 0)
- break;
- range->bitrate[j] = (rates[i] & 0x7f) * 500000;
- /* check for non 802.11b rates */
- if (range->bitrate[j] == 6000000 ||
- range->bitrate[j] == 9000000 ||
- (range->bitrate[j] >= 12000000 &&
- range->bitrate[j] != 22000000))
- has_80211g_rates = 1;
- j++;
- }
- range->num_bitrates = j;
- } else
- range->num_bitrates = 0;
-
- /* fill in 802.11g rates */
- if (has_80211g_rates) {
- num = range->num_bitrates;
- for (i = 0; i < ARRAY_SIZE(rates_80211g); i++) {
- for (j = 0; j < num; j++) {
- if (range->bitrate[j] ==
- rates_80211g[i] * 1000000)
- break;
- }
- if (j == num)
- range->bitrate[range->num_bitrates++] =
- rates_80211g[i] * 1000000;
- if (range->num_bitrates == IW_MAX_BITRATES)
- break;
- }
+ /* Wait before retrieving scan results from device */
+ queue_delayed_work(priv->workqueue, &priv->scan_work,
+ SCAN_DELAY_JIFFIES);
+ }
- /* estimated max real througput in bps */
- range->throughput = 54 * 1000 * 1000 / 2;
+ return ret;
+}
- /* ~35% more with afterburner */
- if (priv->param_afterburner)
- range->throughput = range->throughput / 100 * 135;
- } else {
- /* estimated max real througput in bps */
- range->throughput = 11 * 1000 * 1000 / 2;
+
+static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev,
+ struct ndis_80211_bssid_ex *bssid)
+{
+ struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
+ struct ieee80211_channel *channel;
+ s32 signal;
+ u64 timestamp;
+ u16 capability;
+ u16 beacon_interval;
+ struct ndis_80211_fixed_ies *fixed;
+ int ie_len, bssid_len;
+ u8 *ie;
+
+ /* parse bssid structure */
+ bssid_len = le32_to_cpu(bssid->length);
+
+ if (bssid_len < sizeof(struct ndis_80211_bssid_ex) +
+ sizeof(struct ndis_80211_fixed_ies))
+ return NULL;
+
+ fixed = (struct ndis_80211_fixed_ies *)bssid->ies;
+
+ ie = (void *)(bssid->ies + sizeof(struct ndis_80211_fixed_ies));
+ ie_len = min(bssid_len - (int)sizeof(*bssid),
+ (int)le32_to_cpu(bssid->ie_length));
+ ie_len -= sizeof(struct ndis_80211_fixed_ies);
+ if (ie_len < 0)
+ return NULL;
+
+ /* extract data for cfg80211_inform_bss */
+ channel = ieee80211_get_channel(priv->wdev.wiphy,
+ KHZ_TO_MHZ(le32_to_cpu(bssid->config.ds_config)));
+ if (!channel)
+ return NULL;
+
+ signal = level_to_qual(le32_to_cpu(bssid->rssi));
+ timestamp = le64_to_cpu(*(__le64 *)fixed->timestamp);
+ capability = le16_to_cpu(fixed->capabilities);
+ beacon_interval = le16_to_cpu(fixed->beacon_interval);
+
+ return cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac,
+ timestamp, capability, beacon_interval, ie, ie_len, signal,
+ GFP_KERNEL);
+}
+
+
+static int rndis_check_bssid_list(struct usbnet *usbdev)
+{
+ void *buf = NULL;
+ struct ndis_80211_bssid_list_ex *bssid_list;
+ struct ndis_80211_bssid_ex *bssid;
+ int ret = -EINVAL, len, count, bssid_len;
+
+ devdbg(usbdev, "check_bssid_list");
+
+ len = CONTROL_BUFFER_SIZE;
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ ret = -ENOMEM;
+ goto out;
}
- range->num_channels = 14;
+ ret = rndis_query_oid(usbdev, OID_802_11_BSSID_LIST, buf, &len);
+ if (ret != 0)
+ goto out;
- for (i = 0; (i < 14) && (i < IW_MAX_FREQUENCIES); i++) {
- range->freq[i].i = i + 1;
- range->freq[i].m = ieee80211_dsss_chan_to_freq(i + 1) * 100000;
- range->freq[i].e = 1;
+ bssid_list = buf;
+ bssid = bssid_list->bssid;
+ bssid_len = le32_to_cpu(bssid->length);
+ count = le32_to_cpu(bssid_list->num_items);
+ devdbg(usbdev, "check_bssid_list: %d BSSIDs found", count);
+
+ while (count && ((void *)bssid + bssid_len) <= (buf + len)) {
+ rndis_bss_info_update(usbdev, bssid);
+
+ bssid = (void *)bssid + bssid_len;
+ bssid_len = le32_to_cpu(bssid->length);
+ count--;
}
- range->num_frequency = i;
- range->min_rts = 0;
- range->max_rts = 2347;
- range->min_frag = 256;
- range->max_frag = 2346;
+out:
+ kfree(buf);
+ return ret;
+}
+
- range->max_qual.qual = 100;
- range->max_qual.level = 154;
- range->max_qual.updated = IW_QUAL_QUAL_UPDATED
- | IW_QUAL_LEVEL_UPDATED
- | IW_QUAL_NOISE_INVALID;
+static void rndis_get_scan_results(struct work_struct *work)
+{
+ struct rndis_wext_private *priv =
+ container_of(work, struct rndis_wext_private, scan_work.work);
+ struct usbnet *usbdev = priv->usbdev;
+ int ret;
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = WIRELESS_EXT;
+ devdbg(usbdev, "get_scan_results");
- range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
- IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
- return 0;
+ ret = rndis_check_bssid_list(usbdev);
+
+ cfg80211_scan_done(priv->scan_request, ret < 0);
+
+ priv->scan_request = NULL;
}
-static int rndis_iw_get_name(struct net_device *dev,
+/*
+ * wireless extension handlers
+ */
+
+static int rndis_iw_commit(struct net_device *dev,
struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{
- struct usbnet *usbdev = netdev_priv(dev);
- struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
-
- strcpy(wrqu->name, priv->name);
+ /* dummy op */
return 0;
}
@@ -1422,55 +1605,6 @@ static int rndis_iw_get_auth(struct net_device *dev,
}
-static int rndis_iw_get_mode(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
-
- switch (priv->infra_mode) {
- case ndis_80211_infra_adhoc:
- wrqu->mode = IW_MODE_ADHOC;
- break;
- case ndis_80211_infra_infra:
- wrqu->mode = IW_MODE_INFRA;
- break;
- /*case ndis_80211_infra_auto_unknown:*/
- default:
- wrqu->mode = IW_MODE_AUTO;
- break;
- }
- devdbg(usbdev, "SIOCGIWMODE: %08x", wrqu->mode);
- return 0;
-}
-
-
-static int rndis_iw_set_mode(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- int mode;
-
- devdbg(usbdev, "SIOCSIWMODE: %08x", wrqu->mode);
-
- switch (wrqu->mode) {
- case IW_MODE_ADHOC:
- mode = ndis_80211_infra_adhoc;
- break;
- case IW_MODE_INFRA:
- mode = ndis_80211_infra_infra;
- break;
- /*case IW_MODE_AUTO:*/
- default:
- mode = ndis_80211_infra_auto_unknown;
- break;
- }
-
- return set_infra_mode(usbdev, mode);
-}
-
-
static int rndis_iw_set_encode(struct net_device *dev,
struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{
@@ -1539,9 +1673,7 @@ static int rndis_iw_set_encode_ext(struct net_device *dev,
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
struct usbnet *usbdev = netdev_priv(dev);
struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
- struct ndis_80211_key ndis_key;
- int keyidx, ret;
- u8 *addr;
+ int keyidx, flags;
keyidx = wrqu->encoding.flags & IW_ENCODE_INDEX;
@@ -1564,250 +1696,16 @@ static int rndis_iw_set_encode_ext(struct net_device *dev,
ext->alg == IW_ENCODE_ALG_NONE || ext->key_len == 0)
return remove_key(usbdev, keyidx, NULL);
- if (ext->key_len > sizeof(ndis_key.material))
- return -1;
-
- memset(&ndis_key, 0, sizeof(ndis_key));
-
- ndis_key.size = cpu_to_le32(sizeof(ndis_key) -
- sizeof(ndis_key.material) + ext->key_len);
- ndis_key.length = cpu_to_le32(ext->key_len);
- ndis_key.index = cpu_to_le32(keyidx);
-
- if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
- memcpy(ndis_key.rsc, ext->rx_seq, 6);
- ndis_key.index |= cpu_to_le32(1 << 29);
- }
-
- addr = ext->addr.sa_data;
- if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
- /* group key */
- if (priv->infra_mode == ndis_80211_infra_adhoc)
- memset(ndis_key.bssid, 0xff, ETH_ALEN);
- else
- get_bssid(usbdev, ndis_key.bssid);
- } else {
- /* pairwise key */
- ndis_key.index |= cpu_to_le32(1 << 30);
- memcpy(ndis_key.bssid, addr, ETH_ALEN);
- }
-
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- ndis_key.index |= cpu_to_le32(1 << 31);
-
- if (ext->alg == IW_ENCODE_ALG_TKIP && ext->key_len == 32) {
- /* wpa_supplicant gives us the Michael MIC RX/TX keys in
- * different order than NDIS spec, so swap the order here. */
- memcpy(ndis_key.material, ext->key, 16);
- memcpy(ndis_key.material + 16, ext->key + 24, 8);
- memcpy(ndis_key.material + 24, ext->key + 16, 8);
- } else
- memcpy(ndis_key.material, ext->key, ext->key_len);
-
- ret = rndis_set_oid(usbdev, OID_802_11_ADD_KEY, &ndis_key,
- le32_to_cpu(ndis_key.size));
- devdbg(usbdev, "SIOCSIWENCODEEXT: OID_802_11_ADD_KEY -> %08X", ret);
- if (ret != 0)
- return ret;
-
- priv->encr_key_len[keyidx] = ext->key_len;
- memcpy(&priv->encr_keys[keyidx], ndis_key.material, ext->key_len);
+ flags = 0;
+ if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
+ flags |= ndis_80211_addkey_set_init_recv_seq;
+ if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY))
+ flags |= ndis_80211_addkey_pairwise_key;
if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- priv->encr_tx_key_index = keyidx;
+ flags |= ndis_80211_addkey_transmit_key;
- return 0;
-}
-
-
-static int rndis_iw_set_scan(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- union iwreq_data evt;
- int ret = -EINVAL;
- __le32 tmp;
-
- devdbg(usbdev, "SIOCSIWSCAN");
-
- if (wrqu->data.flags == 0) {
- tmp = cpu_to_le32(1);
- ret = rndis_set_oid(usbdev, OID_802_11_BSSID_LIST_SCAN, &tmp,
- sizeof(tmp));
- evt.data.flags = 0;
- evt.data.length = 0;
- wireless_send_event(dev, SIOCGIWSCAN, &evt, NULL);
- }
- return ret;
-}
-
-
-static char *rndis_translate_scan(struct net_device *dev,
- struct iw_request_info *info, char *cev,
- char *end_buf,
- struct ndis_80211_bssid_ex *bssid)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- u8 *ie;
- char *current_val;
- int bssid_len, ie_len, i;
- u32 beacon, atim;
- struct iw_event iwe;
- unsigned char sbuf[32];
-
- bssid_len = le32_to_cpu(bssid->length);
-
- devdbg(usbdev, "BSSID %pM", bssid->mac);
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, bssid->mac, ETH_ALEN);
- cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_ADDR_LEN);
-
- devdbg(usbdev, "SSID(%d) %s", le32_to_cpu(bssid->ssid.length),
- bssid->ssid.essid);
- iwe.cmd = SIOCGIWESSID;
- iwe.u.essid.length = le32_to_cpu(bssid->ssid.length);
- iwe.u.essid.flags = 1;
- cev = iwe_stream_add_point(info, cev, end_buf, &iwe, bssid->ssid.essid);
-
- devdbg(usbdev, "MODE %d", le32_to_cpu(bssid->net_infra));
- iwe.cmd = SIOCGIWMODE;
- switch (le32_to_cpu(bssid->net_infra)) {
- case ndis_80211_infra_adhoc:
- iwe.u.mode = IW_MODE_ADHOC;
- break;
- case ndis_80211_infra_infra:
- iwe.u.mode = IW_MODE_INFRA;
- break;
- /*case ndis_80211_infra_auto_unknown:*/
- default:
- iwe.u.mode = IW_MODE_AUTO;
- break;
- }
- cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_UINT_LEN);
-
- devdbg(usbdev, "FREQ %d kHz", le32_to_cpu(bssid->config.ds_config));
- iwe.cmd = SIOCGIWFREQ;
- dsconfig_to_freq(le32_to_cpu(bssid->config.ds_config), &iwe.u.freq);
- cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_FREQ_LEN);
-
- devdbg(usbdev, "QUAL %d", le32_to_cpu(bssid->rssi));
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.qual = level_to_qual(le32_to_cpu(bssid->rssi));
- iwe.u.qual.level = le32_to_cpu(bssid->rssi);
- iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED
- | IW_QUAL_LEVEL_UPDATED
- | IW_QUAL_NOISE_INVALID;
- cev = iwe_stream_add_event(info, cev, end_buf, &iwe, IW_EV_QUAL_LEN);
-
- devdbg(usbdev, "ENCODE %d", le32_to_cpu(bssid->privacy));
- iwe.cmd = SIOCGIWENCODE;
- iwe.u.data.length = 0;
- if (le32_to_cpu(bssid->privacy) == ndis_80211_priv_accept_all)
- iwe.u.data.flags = IW_ENCODE_DISABLED;
- else
- iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-
- cev = iwe_stream_add_point(info, cev, end_buf, &iwe, NULL);
-
- devdbg(usbdev, "RATES:");
- current_val = cev + iwe_stream_lcp_len(info);
- iwe.cmd = SIOCGIWRATE;
- for (i = 0; i < sizeof(bssid->rates); i++) {
- if (bssid->rates[i] & 0x7f) {
- iwe.u.bitrate.value =
- ((bssid->rates[i] & 0x7f) *
- 500000);
- devdbg(usbdev, " %d", iwe.u.bitrate.value);
- current_val = iwe_stream_add_value(info, cev,
- current_val, end_buf, &iwe,
- IW_EV_PARAM_LEN);
- }
- }
-
- if ((current_val - cev) > iwe_stream_lcp_len(info))
- cev = current_val;
-
- beacon = le32_to_cpu(bssid->config.beacon_period);
- devdbg(usbdev, "BCN_INT %d", beacon);
- iwe.cmd = IWEVCUSTOM;
- snprintf(sbuf, sizeof(sbuf), "bcn_int=%d", beacon);
- iwe.u.data.length = strlen(sbuf);
- cev = iwe_stream_add_point(info, cev, end_buf, &iwe, sbuf);
-
- atim = le32_to_cpu(bssid->config.atim_window);
- devdbg(usbdev, "ATIM %d", atim);
- iwe.cmd = IWEVCUSTOM;
- snprintf(sbuf, sizeof(sbuf), "atim=%u", atim);
- iwe.u.data.length = strlen(sbuf);
- cev = iwe_stream_add_point(info, cev, end_buf, &iwe, sbuf);
-
- ie = (void *)(bssid->ies + sizeof(struct ndis_80211_fixed_ies));
- ie_len = min(bssid_len - (int)sizeof(*bssid),
- (int)le32_to_cpu(bssid->ie_length));
- ie_len -= sizeof(struct ndis_80211_fixed_ies);
- while (ie_len >= 2 && 2 + ie[1] <= ie_len) {
- if ((ie[0] == WLAN_EID_GENERIC && ie[1] >= 4 &&
- memcmp(ie + 2, "\x00\x50\xf2\x01", 4) == 0) ||
- ie[0] == WLAN_EID_RSN) {
- devdbg(usbdev, "IE: WPA%d",
- (ie[0] == WLAN_EID_RSN) ? 2 : 1);
- iwe.cmd = IWEVGENIE;
- /* arbitrary cut-off at 64 */
- iwe.u.data.length = min(ie[1] + 2, 64);
- cev = iwe_stream_add_point(info, cev, end_buf, &iwe, ie);
- }
-
- ie_len -= 2 + ie[1];
- ie += 2 + ie[1];
- }
-
- return cev;
-}
-
-
-static int rndis_iw_get_scan(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- void *buf = NULL;
- char *cev = extra;
- struct ndis_80211_bssid_list_ex *bssid_list;
- struct ndis_80211_bssid_ex *bssid;
- int ret = -EINVAL, len, count, bssid_len;
-
- devdbg(usbdev, "SIOCGIWSCAN");
-
- len = CONTROL_BUFFER_SIZE;
- buf = kmalloc(len, GFP_KERNEL);
- if (!buf) {
- ret = -ENOMEM;
- goto out;
- }
-
- ret = rndis_query_oid(usbdev, OID_802_11_BSSID_LIST, buf, &len);
-
- if (ret != 0)
- goto out;
-
- bssid_list = buf;
- bssid = bssid_list->bssid;
- bssid_len = le32_to_cpu(bssid->length);
- count = le32_to_cpu(bssid_list->num_items);
- devdbg(usbdev, "SIOCGIWSCAN: %d BSSIDs found", count);
-
- while (count && ((void *)bssid + bssid_len) <= (buf + len)) {
- cev = rndis_translate_scan(dev, info, cev,
- extra + IW_SCAN_MAX_DATA, bssid);
- bssid = (void *)bssid + bssid_len;
- bssid_len = le32_to_cpu(bssid->length);
- count--;
- }
-
-out:
- wrqu->data.length = cev - extra;
- wrqu->data.flags = 0;
- kfree(buf);
- return ret;
+ return add_wpa_key(usbdev, ext->key, ext->key_len, keyidx, &ext->addr,
+ ext->rx_seq, ext->alg, flags);
}
@@ -1936,39 +1834,6 @@ static int rndis_iw_get_frag(struct net_device *dev,
}
-static int rndis_iw_set_nick(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
-
- devdbg(usbdev, "SIOCSIWNICK");
-
- priv->nick_len = wrqu->data.length;
- if (priv->nick_len > 32)
- priv->nick_len = 32;
-
- memcpy(priv->nick, extra, priv->nick_len);
- return 0;
-}
-
-
-static int rndis_iw_get_nick(struct net_device *dev,
- struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
-{
- struct usbnet *usbdev = netdev_priv(dev);
- struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
-
- wrqu->data.flags = 1;
- wrqu->data.length = priv->nick_len;
- memcpy(extra, priv->nick, priv->nick_len);
-
- devdbg(usbdev, "SIOCGIWNICK: '%s'", priv->nick);
-
- return 0;
-}
-
-
static int rndis_iw_set_freq(struct net_device *dev,
struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{
@@ -2023,18 +1888,10 @@ static int rndis_iw_get_txpower(struct net_device *dev,
struct usbnet *usbdev = netdev_priv(dev);
struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
__le32 tx_power;
- int ret = 0, len;
if (priv->radio_on) {
- if (priv->caps & CAP_SUPPORT_TXPOWER) {
- len = sizeof(tx_power);
- ret = rndis_query_oid(usbdev, OID_802_11_TX_POWER_LEVEL,
- &tx_power, &len);
- if (ret != 0)
- return ret;
- } else
- /* fake incase not supported */
- tx_power = cpu_to_le32(get_bcm4320_power(priv));
+ /* fake since changing tx_power (by userlevel) not supported */
+ tx_power = cpu_to_le32(get_bcm4320_power(priv));
wrqu->txpower.flags = IW_TXPOW_MWATT;
wrqu->txpower.value = le32_to_cpu(tx_power);
@@ -2047,7 +1904,7 @@ static int rndis_iw_get_txpower(struct net_device *dev,
devdbg(usbdev, "SIOCGIWTXPOW: %d", wrqu->txpower.value);
- return ret;
+ return 0;
}
@@ -2057,7 +1914,6 @@ static int rndis_iw_set_txpower(struct net_device *dev,
struct usbnet *usbdev = netdev_priv(dev);
struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
__le32 tx_power = 0;
- int ret = 0;
if (!wrqu->txpower.disabled) {
if (wrqu->txpower.flags == IW_TXPOW_MWATT)
@@ -2080,22 +1936,10 @@ static int rndis_iw_set_txpower(struct net_device *dev,
devdbg(usbdev, "SIOCSIWTXPOW: %d", le32_to_cpu(tx_power));
if (le32_to_cpu(tx_power) != 0) {
- if (priv->caps & CAP_SUPPORT_TXPOWER) {
- /* turn radio on first */
- if (!priv->radio_on)
- disassociate(usbdev, 1);
-
- ret = rndis_set_oid(usbdev, OID_802_11_TX_POWER_LEVEL,
- &tx_power, sizeof(tx_power));
- if (ret != 0)
- ret = -EOPNOTSUPP;
- return ret;
- } else {
- /* txpower unsupported, just turn radio on */
- if (!priv->radio_on)
- return disassociate(usbdev, 1);
- return 0; /* all ready on */
- }
+ /* txpower unsupported, just turn radio on */
+ if (!priv->radio_on)
+ return disassociate(usbdev, 1);
+ return 0; /* all ready on */
}
/* tx_power == 0, turn off radio */
@@ -2165,20 +2009,18 @@ static struct iw_statistics *rndis_get_wireless_stats(struct net_device *dev)
static const iw_handler rndis_iw_handler[] =
{
IW_IOCTL(SIOCSIWCOMMIT) = rndis_iw_commit,
- IW_IOCTL(SIOCGIWNAME) = rndis_iw_get_name,
+ IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname,
IW_IOCTL(SIOCSIWFREQ) = rndis_iw_set_freq,
IW_IOCTL(SIOCGIWFREQ) = rndis_iw_get_freq,
- IW_IOCTL(SIOCSIWMODE) = rndis_iw_set_mode,
- IW_IOCTL(SIOCGIWMODE) = rndis_iw_get_mode,
- IW_IOCTL(SIOCGIWRANGE) = rndis_iw_get_range,
+ IW_IOCTL(SIOCSIWMODE) = (iw_handler) cfg80211_wext_siwmode,
+ IW_IOCTL(SIOCGIWMODE) = (iw_handler) cfg80211_wext_giwmode,
+ IW_IOCTL(SIOCGIWRANGE) = (iw_handler) cfg80211_wext_giwrange,
IW_IOCTL(SIOCSIWAP) = rndis_iw_set_bssid,
IW_IOCTL(SIOCGIWAP) = rndis_iw_get_bssid,
- IW_IOCTL(SIOCSIWSCAN) = rndis_iw_set_scan,
- IW_IOCTL(SIOCGIWSCAN) = rndis_iw_get_scan,
+ IW_IOCTL(SIOCSIWSCAN) = (iw_handler) cfg80211_wext_siwscan,
+ IW_IOCTL(SIOCGIWSCAN) = (iw_handler) cfg80211_wext_giwscan,
IW_IOCTL(SIOCSIWESSID) = rndis_iw_set_essid,
IW_IOCTL(SIOCGIWESSID) = rndis_iw_get_essid,
- IW_IOCTL(SIOCSIWNICKN) = rndis_iw_set_nick,
- IW_IOCTL(SIOCGIWNICKN) = rndis_iw_get_nick,
IW_IOCTL(SIOCGIWRATE) = rndis_iw_get_rate,
IW_IOCTL(SIOCSIWRTS) = rndis_iw_set_rts,
IW_IOCTL(SIOCGIWRTS) = rndis_iw_get_rts,
@@ -2306,16 +2148,8 @@ static int rndis_wext_get_caps(struct usbnet *usbdev)
__le32 items[8];
} networks_supported;
int len, retval, i, n;
- __le32 tx_power;
struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
- /* determine if supports setting txpower */
- len = sizeof(tx_power);
- retval = rndis_query_oid(usbdev, OID_802_11_TX_POWER_LEVEL, &tx_power,
- &len);
- if (retval == 0 && le32_to_cpu(tx_power) != 0xFF)
- priv->caps |= CAP_SUPPORT_TXPOWER;
-
/* determine supported modes */
len = sizeof(networks_supported);
retval = rndis_query_oid(usbdev, OID_802_11_NETWORK_TYPES_SUPPORTED,
@@ -2338,12 +2172,6 @@ static int rndis_wext_get_caps(struct usbnet *usbdev)
break;
}
}
- if (priv->caps & CAP_MODE_80211A)
- strcat(priv->name, "a");
- if (priv->caps & CAP_MODE_80211B)
- strcat(priv->name, "b");
- if (priv->caps & CAP_MODE_80211G)
- strcat(priv->name, "g");
}
return retval;
@@ -2387,7 +2215,7 @@ static void rndis_update_wireless_stats(struct work_struct *work)
if (ret == 0) {
memset(&iwstats.qual, 0, sizeof(iwstats.qual));
iwstats.qual.qual = level_to_qual(le32_to_cpu(rssi));
- iwstats.qual.level = le32_to_cpu(rssi);
+ iwstats.qual.level = level_to_qual(le32_to_cpu(rssi));
iwstats.qual.updated = IW_QUAL_QUAL_UPDATED
| IW_QUAL_LEVEL_UPDATED
| IW_QUAL_NOISE_INVALID;
@@ -2457,7 +2285,17 @@ end:
}
-static int bcm4320_early_init(struct usbnet *usbdev)
+static int bcm4320a_early_init(struct usbnet *usbdev)
+{
+ /* bcm4320a doesn't handle configuration parameters well. Try
+ * set any and you get partially zeroed mac and broken device.
+ */
+
+ return 0;
+}
+
+
+static int bcm4320b_early_init(struct usbnet *usbdev)
{
struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev);
char buf[8];
@@ -2538,20 +2376,28 @@ static const struct net_device_ops rndis_wext_netdev_ops = {
static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf)
{
+ struct wiphy *wiphy;
struct rndis_wext_private *priv;
int retval, len;
__le32 tmp;
- /* allocate rndis private data */
- priv = kzalloc(sizeof(struct rndis_wext_private), GFP_KERNEL);
- if (!priv)
+ /* allocate wiphy and rndis private data
+ * NOTE: We only support a single virtual interface, so wiphy
+ * and wireless_dev are somewhat synonymous for this device.
+ */
+ wiphy = wiphy_new(&rndis_config_ops, sizeof(struct rndis_wext_private));
+ if (!wiphy)
return -ENOMEM;
+ priv = wiphy_priv(wiphy);
+ usbdev->net->ieee80211_ptr = &priv->wdev;
+ priv->wdev.wiphy = wiphy;
+ priv->wdev.iftype = NL80211_IFTYPE_STATION;
+
/* These have to be initialized before calling generic_rndis_bind().
* Otherwise we'll be in big trouble in rndis_wext_early_init().
*/
usbdev->driver_priv = priv;
- strcpy(priv->name, "IEEE802.11");
usbdev->net->wireless_handlers = &rndis_iw_handlers;
priv->usbdev = usbdev;
@@ -2562,6 +2408,7 @@ static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf)
priv->workqueue = create_singlethread_workqueue("rndis_wlan");
INIT_WORK(&priv->work, rndis_wext_worker);
INIT_DELAYED_WORK(&priv->stats_work, rndis_update_wireless_stats);
+ INIT_DELAYED_WORK(&priv->scan_work, rndis_get_scan_results);
/* try bind rndis_host */
retval = generic_rndis_bind(usbdev, intf, FLAG_RNDIS_PHYM_WIRELESS);
@@ -2600,7 +2447,32 @@ static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf)
| IW_QUAL_QUAL_INVALID
| IW_QUAL_LEVEL_INVALID;
+ /* fill-out wiphy structure and register w/ cfg80211 */
+ memcpy(wiphy->perm_addr, usbdev->net->dev_addr, ETH_ALEN);
+ wiphy->privid = rndis_wiphy_privid;
+ wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
+ | BIT(NL80211_IFTYPE_ADHOC);
+ wiphy->max_scan_ssids = 1;
+
+ /* TODO: fill-out band information based on priv->caps */
rndis_wext_get_caps(usbdev);
+
+ memcpy(priv->channels, rndis_channels, sizeof(rndis_channels));
+ memcpy(priv->rates, rndis_rates, sizeof(rndis_rates));
+ priv->band.channels = priv->channels;
+ priv->band.n_channels = ARRAY_SIZE(rndis_channels);
+ priv->band.bitrates = priv->rates;
+ priv->band.n_bitrates = ARRAY_SIZE(rndis_rates);
+ wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
+ wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
+
+ set_wiphy_dev(wiphy, &usbdev->udev->dev);
+
+ if (wiphy_register(wiphy)) {
+ retval = -ENODEV;
+ goto fail;
+ }
+
set_default_iw_params(usbdev);
/* turn radio on */
@@ -2615,11 +2487,12 @@ static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf)
fail:
cancel_delayed_work_sync(&priv->stats_work);
+ cancel_delayed_work_sync(&priv->scan_work);
cancel_work_sync(&priv->work);
flush_workqueue(priv->workqueue);
destroy_workqueue(priv->workqueue);
- kfree(priv);
+ wiphy_free(wiphy);
return retval;
}
@@ -2632,15 +2505,18 @@ static void rndis_wext_unbind(struct usbnet *usbdev, struct usb_interface *intf)
disassociate(usbdev, 0);
cancel_delayed_work_sync(&priv->stats_work);
+ cancel_delayed_work_sync(&priv->scan_work);
cancel_work_sync(&priv->work);
flush_workqueue(priv->workqueue);
destroy_workqueue(priv->workqueue);
if (priv && priv->wpa_ie_len)
kfree(priv->wpa_ie);
- kfree(priv);
rndis_unbind(usbdev, intf);
+
+ wiphy_unregister(priv->wdev.wiphy);
+ wiphy_free(priv->wdev.wiphy);
}
@@ -2659,7 +2535,7 @@ static const struct driver_info bcm4320b_info = {
.rx_fixup = rndis_rx_fixup,
.tx_fixup = rndis_tx_fixup,
.reset = rndis_wext_reset,
- .early_init = bcm4320_early_init,
+ .early_init = bcm4320b_early_init,
.link_change = rndis_wext_link_change,
};
@@ -2672,7 +2548,7 @@ static const struct driver_info bcm4320a_info = {
.rx_fixup = rndis_rx_fixup,
.tx_fixup = rndis_tx_fixup,
.reset = rndis_wext_reset,
- .early_init = bcm4320_early_init,
+ .early_init = bcm4320a_early_init,
.link_change = rndis_wext_link_change,
};
@@ -2685,7 +2561,7 @@ static const struct driver_info rndis_wext_info = {
.rx_fixup = rndis_rx_fixup,
.tx_fixup = rndis_tx_fixup,
.reset = rndis_wext_reset,
- .early_init = bcm4320_early_init,
+ .early_init = bcm4320a_early_init,
.link_change = rndis_wext_link_change,
};
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index bfc5d9cf716e..18ee7d6c4028 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -77,6 +77,20 @@ config RT73USB
When compiled as a module, this driver will be called "rt73usb.ko".
+config RT2800USB
+ tristate "Ralink rt2800 (USB) support"
+ depends on USB
+ select RT2X00_LIB_USB
+ select RT2X00_LIB_HT
+ select RT2X00_LIB_FIRMWARE
+ select RT2X00_LIB_CRYPTO
+ select CRC_CCITT
+ ---help---
+ This adds support for rt2800 wireless chipset family.
+ Supported chips: RT2770, RT2870 & RT3070.
+
+ When compiled as a module, this driver will be called "rt2800usb.ko".
+
config RT2X00_LIB_PCI
tristate
select RT2X00_LIB
@@ -88,6 +102,9 @@ config RT2X00_LIB_USB
config RT2X00_LIB
tristate
+config RT2X00_LIB_HT
+ boolean
+
config RT2X00_LIB_FIRMWARE
boolean
select FW_LOADER
diff --git a/drivers/net/wireless/rt2x00/Makefile b/drivers/net/wireless/rt2x00/Makefile
index f22d808d8c51..bfc7226f0afe 100644
--- a/drivers/net/wireless/rt2x00/Makefile
+++ b/drivers/net/wireless/rt2x00/Makefile
@@ -8,6 +8,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
rt2x00lib-$(CONFIG_RT2X00_LIB_RFKILL) += rt2x00rfkill.o
rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o
+rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2x00ht.o
obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
@@ -17,3 +18,4 @@ obj-$(CONFIG_RT2500PCI) += rt2500pci.o
obj-$(CONFIG_RT61PCI) += rt61pci.o
obj-$(CONFIG_RT2500USB) += rt2500usb.o
obj-$(CONFIG_RT73USB) += rt73usb.o
+obj-$(CONFIG_RT2800USB) += rt2800usb.o
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 0f08773328c6..0197531bd88c 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -335,10 +335,11 @@ static void rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
preamble_mask = erp->short_preamble << 3;
rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
- rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT,
- erp->ack_timeout);
+ rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, erp->ack_timeout);
rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME,
erp->ack_consume_time);
+ rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
+ rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
@@ -371,6 +372,11 @@ static void rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
rt2x00_set_field32(&reg, CSR11_SLOT_TIME, erp->slot_time);
rt2x00pci_register_write(rt2x00dev, CSR11, reg);
+ rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
+ rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL, erp->beacon_int * 16);
+ rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION, erp->beacon_int * 16);
+ rt2x00pci_register_write(rt2x00dev, CSR12, reg);
+
rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
rt2x00_set_field32(&reg, CSR18_SIFS, erp->sifs);
rt2x00_set_field32(&reg, CSR18_PIFS, erp->pifs);
@@ -503,24 +509,6 @@ static void rt2400pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
rt2x00pci_register_write(rt2x00dev, CSR11, reg);
}
-static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_conf *libconf)
-{
- u32 reg;
-
- rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
- rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
- rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
- rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
-
- rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
- rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL,
- libconf->conf->beacon_int * 16);
- rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION,
- libconf->conf->beacon_int * 16);
- rt2x00pci_register_write(rt2x00dev, CSR12, reg);
-}
-
static void rt2400pci_config_ps(struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf)
{
@@ -558,8 +546,6 @@ static void rt2400pci_config(struct rt2x00_dev *rt2x00dev,
libconf->conf->power_level);
if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
rt2400pci_config_retry_limit(rt2x00dev, libconf);
- if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
- rt2400pci_config_duration(rt2x00dev, libconf);
if (flags & IEEE80211_CONF_CHANGE_PS)
rt2400pci_config_ps(rt2x00dev, libconf);
}
@@ -1361,7 +1347,7 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
*/
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
- rt2x00_set_chip(rt2x00dev, RT2460, value, reg);
+ rt2x00_set_chip_rf(rt2x00dev, value, reg);
if (!rt2x00_rf(&rt2x00dev->chip, RF2420) &&
!rt2x00_rf(&rt2x00dev->chip, RF2421)) {
@@ -1580,7 +1566,6 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
.add_interface = rt2x00mac_add_interface,
.remove_interface = rt2x00mac_remove_interface,
.config = rt2x00mac_config,
- .config_interface = rt2x00mac_config_interface,
.configure_filter = rt2x00mac_configure_filter,
.get_stats = rt2x00mac_get_stats,
.bss_info_changed = rt2x00mac_bss_info_changed,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 276a8232aaa0..f95cb646f85a 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -341,10 +341,11 @@ static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
preamble_mask = erp->short_preamble << 3;
rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
- rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT,
- erp->ack_timeout);
+ rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, erp->ack_timeout);
rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME,
erp->ack_consume_time);
+ rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
+ rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
@@ -377,6 +378,11 @@ static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
rt2x00_set_field32(&reg, CSR11_SLOT_TIME, erp->slot_time);
rt2x00pci_register_write(rt2x00dev, CSR11, reg);
+ rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
+ rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL, erp->beacon_int * 16);
+ rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION, erp->beacon_int * 16);
+ rt2x00pci_register_write(rt2x00dev, CSR12, reg);
+
rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
rt2x00_set_field32(&reg, CSR18_SIFS, erp->sifs);
rt2x00_set_field32(&reg, CSR18_PIFS, erp->pifs);
@@ -552,24 +558,6 @@ static void rt2500pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
rt2x00pci_register_write(rt2x00dev, CSR11, reg);
}
-static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_conf *libconf)
-{
- u32 reg;
-
- rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
- rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
- rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
- rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
-
- rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
- rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL,
- libconf->conf->beacon_int * 16);
- rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION,
- libconf->conf->beacon_int * 16);
- rt2x00pci_register_write(rt2x00dev, CSR12, reg);
-}
-
static void rt2500pci_config_ps(struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf)
{
@@ -609,8 +597,6 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev,
libconf->conf->power_level);
if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
rt2500pci_config_retry_limit(rt2x00dev, libconf);
- if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
- rt2500pci_config_duration(rt2x00dev, libconf);
if (flags & IEEE80211_CONF_CHANGE_PS)
rt2500pci_config_ps(rt2x00dev, libconf);
}
@@ -1525,7 +1511,7 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
*/
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
- rt2x00_set_chip(rt2x00dev, RT2560, value, reg);
+ rt2x00_set_chip_rf(rt2x00dev, value, reg);
if (!rt2x00_rf(&rt2x00dev->chip, RF2522) &&
!rt2x00_rf(&rt2x00dev->chip, RF2523) &&
@@ -1879,7 +1865,6 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
.add_interface = rt2x00mac_add_interface,
.remove_interface = rt2x00mac_remove_interface,
.config = rt2x00mac_config,
- .config_interface = rt2x00mac_config_interface,
.configure_filter = rt2x00mac_configure_filter,
.get_stats = rt2x00mac_get_stats,
.bss_info_changed = rt2x00mac_bss_info_changed,
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 9e630e70fc97..69f966f1ce54 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -503,6 +503,10 @@ static void rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
rt2500usb_register_write(rt2x00dev, TXRX_CSR11, erp->basic_rates);
+ rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
+ rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL, erp->beacon_int * 4);
+ rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg);
+
rt2500usb_register_write(rt2x00dev, MAC_CSR10, erp->slot_time);
rt2500usb_register_write(rt2x00dev, MAC_CSR11, erp->sifs);
rt2500usb_register_write(rt2x00dev, MAC_CSR12, erp->eifs);
@@ -632,17 +636,6 @@ static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
rt2500usb_rf_write(rt2x00dev, 3, rf3);
}
-static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_conf *libconf)
-{
- u16 reg;
-
- rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
- rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL,
- libconf->conf->beacon_int * 4);
- rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg);
-}
-
static void rt2500usb_config_ps(struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf)
{
@@ -680,8 +673,6 @@ static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
!(flags & IEEE80211_CONF_CHANGE_CHANNEL))
rt2500usb_config_txpower(rt2x00dev,
libconf->conf->power_level);
- if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
- rt2500usb_config_duration(rt2x00dev, libconf);
if (flags & IEEE80211_CONF_CHANGE_PS)
rt2500usb_config_ps(rt2x00dev, libconf);
}
@@ -1559,7 +1550,7 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
- if (!rt2x00_check_rev(&rt2x00dev->chip, 0)) {
+ if (!rt2x00_check_rev(&rt2x00dev->chip, 0x000ffff0, 0)) {
ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
return -ENODEV;
}
@@ -1908,7 +1899,6 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
.add_interface = rt2x00mac_add_interface,
.remove_interface = rt2x00mac_remove_interface,
.config = rt2x00mac_config,
- .config_interface = rt2x00mac_config_interface,
.configure_filter = rt2x00mac_configure_filter,
.set_key = rt2x00mac_set_key,
.get_stats = rt2x00mac_get_stats,
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
new file mode 100644
index 000000000000..142ad34fdc49
--- /dev/null
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -0,0 +1,3066 @@
+/*
+ Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
+ <http://rt2x00.serialmonkey.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the
+ Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ Module: rt2800usb
+ Abstract: rt2800usb device specific routines.
+ Supported chipsets: RT2800U.
+ */
+
+#include <linux/crc-ccitt.h>
+#include <linux/delay.h>
+#include <linux/etherdevice.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+
+#include "rt2x00.h"
+#include "rt2x00usb.h"
+#include "rt2800usb.h"
+
+/*
+ * Allow hardware encryption to be disabled.
+ */
+static int modparam_nohwcrypt = 1;
+module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
+MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
+
+/*
+ * Register access.
+ * All access to the CSR registers will go through the methods
+ * rt2x00usb_register_read and rt2x00usb_register_write.
+ * BBP and RF register require indirect register access,
+ * and use the CSR registers BBPCSR and RFCSR to achieve this.
+ * These indirect registers work with busy bits,
+ * and we will try maximal REGISTER_BUSY_COUNT times to access
+ * the register while taking a REGISTER_BUSY_DELAY us delay
+ * between each attampt. When the busy bit is still set at that time,
+ * the access attempt is considered to have failed,
+ * and we will print an error.
+ * The _lock versions must be used if you already hold the csr_mutex
+ */
+#define WAIT_FOR_BBP(__dev, __reg) \
+ rt2x00usb_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg))
+#define WAIT_FOR_RFCSR(__dev, __reg) \
+ rt2x00usb_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY, (__reg))
+#define WAIT_FOR_RF(__dev, __reg) \
+ rt2x00usb_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg))
+#define WAIT_FOR_MCU(__dev, __reg) \
+ rt2x00usb_regbusy_read((__dev), H2M_MAILBOX_CSR, \
+ H2M_MAILBOX_CSR_OWNER, (__reg))
+
+static void rt2800usb_bbp_write(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, const u8 value)
+{
+ u32 reg;
+
+ mutex_lock(&rt2x00dev->csr_mutex);
+
+ /*
+ * Wait until the BBP becomes available, afterwards we
+ * can safely write the new data into the register.
+ */
+ if (WAIT_FOR_BBP(rt2x00dev, &reg)) {
+ reg = 0;
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_VALUE, value);
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_REGNUM, word);
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_BUSY, 1);
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_READ_CONTROL, 0);
+
+ rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
+ }
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+}
+
+static void rt2800usb_bbp_read(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, u8 *value)
+{
+ u32 reg;
+
+ mutex_lock(&rt2x00dev->csr_mutex);
+
+ /*
+ * Wait until the BBP becomes available, afterwards we
+ * can safely write the read request into the register.
+ * After the data has been written, we wait until hardware
+ * returns the correct value, if at any time the register
+ * doesn't become available in time, reg will be 0xffffffff
+ * which means we return 0xff to the caller.
+ */
+ if (WAIT_FOR_BBP(rt2x00dev, &reg)) {
+ reg = 0;
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_REGNUM, word);
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_BUSY, 1);
+ rt2x00_set_field32(&reg, BBP_CSR_CFG_READ_CONTROL, 1);
+
+ rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
+
+ WAIT_FOR_BBP(rt2x00dev, &reg);
+ }
+
+ *value = rt2x00_get_field32(reg, BBP_CSR_CFG_VALUE);
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+}
+
+static void rt2800usb_rfcsr_write(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, const u8 value)
+{
+ u32 reg;
+
+ mutex_lock(&rt2x00dev->csr_mutex);
+
+ /*
+ * Wait until the RFCSR becomes available, afterwards we
+ * can safely write the new data into the register.
+ */
+ if (WAIT_FOR_RFCSR(rt2x00dev, &reg)) {
+ reg = 0;
+ rt2x00_set_field32(&reg, RF_CSR_CFG_DATA, value);
+ rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM, word);
+ rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE, 1);
+ rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY, 1);
+
+ rt2x00usb_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
+ }
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+}
+
+static void rt2800usb_rfcsr_read(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, u8 *value)
+{
+ u32 reg;
+
+ mutex_lock(&rt2x00dev->csr_mutex);
+
+ /*
+ * Wait until the RFCSR becomes available, afterwards we
+ * can safely write the read request into the register.
+ * After the data has been written, we wait until hardware
+ * returns the correct value, if at any time the register
+ * doesn't become available in time, reg will be 0xffffffff
+ * which means we return 0xff to the caller.
+ */
+ if (WAIT_FOR_RFCSR(rt2x00dev, &reg)) {
+ reg = 0;
+ rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM, word);
+ rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE, 0);
+ rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY, 1);
+
+ rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
+
+ WAIT_FOR_RFCSR(rt2x00dev, &reg);
+ }
+
+ *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA);
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+}
+
+static void rt2800usb_rf_write(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, const u32 value)
+{
+ u32 reg;
+
+ mutex_lock(&rt2x00dev->csr_mutex);
+
+ /*
+ * Wait until the RF becomes available, afterwards we
+ * can safely write the new data into the register.
+ */
+ if (WAIT_FOR_RF(rt2x00dev, &reg)) {
+ reg = 0;
+ rt2x00_set_field32(&reg, RF_CSR_CFG0_REG_VALUE_BW, value);
+ rt2x00_set_field32(&reg, RF_CSR_CFG0_STANDBYMODE, 0);
+ rt2x00_set_field32(&reg, RF_CSR_CFG0_SEL, 0);
+ rt2x00_set_field32(&reg, RF_CSR_CFG0_BUSY, 1);
+
+ rt2x00usb_register_write_lock(rt2x00dev, RF_CSR_CFG0, reg);
+ rt2x00_rf_write(rt2x00dev, word, value);
+ }
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+}
+
+static void rt2800usb_mcu_request(struct rt2x00_dev *rt2x00dev,
+ const u8 command, const u8 token,
+ const u8 arg0, const u8 arg1)
+{
+ u32 reg;
+
+ mutex_lock(&rt2x00dev->csr_mutex);
+
+ /*
+ * Wait until the MCU becomes available, afterwards we
+ * can safely write the new data into the register.
+ */
+ if (WAIT_FOR_MCU(rt2x00dev, &reg)) {
+ rt2x00_set_field32(&reg, H2M_MAILBOX_CSR_OWNER, 1);
+ rt2x00_set_field32(&reg, H2M_MAILBOX_CSR_CMD_TOKEN, token);
+ rt2x00_set_field32(&reg, H2M_MAILBOX_CSR_ARG0, arg0);
+ rt2x00_set_field32(&reg, H2M_MAILBOX_CSR_ARG1, arg1);
+ rt2x00usb_register_write_lock(rt2x00dev, H2M_MAILBOX_CSR, reg);
+
+ reg = 0;
+ rt2x00_set_field32(&reg, HOST_CMD_CSR_HOST_COMMAND, command);
+ rt2x00usb_register_write_lock(rt2x00dev, HOST_CMD_CSR, reg);
+ }
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+}
+
+#ifdef CONFIG_RT2X00_LIB_DEBUGFS
+static const struct rt2x00debug rt2800usb_rt2x00debug = {
+ .owner = THIS_MODULE,
+ .csr = {
+ .read = rt2x00usb_register_read,
+ .write = rt2x00usb_register_write,
+ .flags = RT2X00DEBUGFS_OFFSET,
+ .word_base = CSR_REG_BASE,
+ .word_size = sizeof(u32),
+ .word_count = CSR_REG_SIZE / sizeof(u32),
+ },
+ .eeprom = {
+ .read = rt2x00_eeprom_read,
+ .write = rt2x00_eeprom_write,
+ .word_base = EEPROM_BASE,
+ .word_size = sizeof(u16),
+ .word_count = EEPROM_SIZE / sizeof(u16),
+ },
+ .bbp = {
+ .read = rt2800usb_bbp_read,
+ .write = rt2800usb_bbp_write,
+ .word_base = BBP_BASE,
+ .word_size = sizeof(u8),
+ .word_count = BBP_SIZE / sizeof(u8),
+ },
+ .rf = {
+ .read = rt2x00_rf_read,
+ .write = rt2800usb_rf_write,
+ .word_base = RF_BASE,
+ .word_size = sizeof(u32),
+ .word_count = RF_SIZE / sizeof(u32),
+ },
+};
+#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
+
+#ifdef CONFIG_RT2X00_LIB_RFKILL
+static int rt2800usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)
+{
+ u32 reg;
+
+ rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, &reg);
+ return rt2x00_get_field32(reg, GPIO_CTRL_CFG_BIT2);
+}
+#else
+#define rt2800usb_rfkill_poll NULL
+#endif /* CONFIG_RT2X00_LIB_RFKILL */
+
+#ifdef CONFIG_RT2X00_LIB_LEDS
+static void rt2800usb_brightness_set(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ struct rt2x00_led *led =
+ container_of(led_cdev, struct rt2x00_led, led_dev);
+ unsigned int enabled = brightness != LED_OFF;
+ unsigned int bg_mode =
+ (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
+ unsigned int polarity =
+ rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
+ EEPROM_FREQ_LED_POLARITY);
+ unsigned int ledmode =
+ rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
+ EEPROM_FREQ_LED_MODE);
+
+ if (led->type == LED_TYPE_RADIO) {
+ rt2800usb_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
+ enabled ? 0x20 : 0);
+ } else if (led->type == LED_TYPE_ASSOC) {
+ rt2800usb_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
+ enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
+ } else if (led->type == LED_TYPE_QUALITY) {
+ /*
+ * The brightness is divided into 6 levels (0 - 5),
+ * The specs tell us the following levels:
+ * 0, 1 ,3, 7, 15, 31
+ * to determine the level in a simple way we can simply
+ * work with bitshifting:
+ * (1 << level) - 1
+ */
+ rt2800usb_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
+ (1 << brightness / (LED_FULL / 6)) - 1,
+ polarity);
+ }
+}
+
+static int rt2800usb_blink_set(struct led_classdev *led_cdev,
+ unsigned long *delay_on,
+ unsigned long *delay_off)
+{
+ struct rt2x00_led *led =
+ container_of(led_cdev, struct rt2x00_led, led_dev);
+ u32 reg;
+
+ rt2x00usb_register_read(led->rt2x00dev, LED_CFG, &reg);
+ rt2x00_set_field32(&reg, LED_CFG_ON_PERIOD, *delay_on);
+ rt2x00_set_field32(&reg, LED_CFG_OFF_PERIOD, *delay_off);
+ rt2x00_set_field32(&reg, LED_CFG_SLOW_BLINK_PERIOD, 3);
+ rt2x00_set_field32(&reg, LED_CFG_R_LED_MODE, 3);
+ rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE, 12);
+ rt2x00_set_field32(&reg, LED_CFG_Y_LED_MODE, 3);
+ rt2x00_set_field32(&reg, LED_CFG_LED_POLAR, 1);
+ rt2x00usb_register_write(led->rt2x00dev, LED_CFG, reg);
+
+ return 0;
+}
+
+static void rt2800usb_init_led(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00_led *led,
+ enum led_type type)
+{
+ led->rt2x00dev = rt2x00dev;
+ led->type = type;
+ led->led_dev.brightness_set = rt2800usb_brightness_set;
+ led->led_dev.blink_set = rt2800usb_blink_set;
+ led->flags = LED_INITIALIZED;
+}
+#endif /* CONFIG_RT2X00_LIB_LEDS */
+
+/*
+ * Configuration handlers.
+ */
+static void rt2800usb_config_wcid_attr(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_crypto *crypto,
+ struct ieee80211_key_conf *key)
+{
+ struct mac_wcid_entry wcid_entry;
+ struct mac_iveiv_entry iveiv_entry;
+ u32 offset;
+ u32 reg;
+
+ offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx);
+
+ rt2x00usb_register_read(rt2x00dev, offset, &reg);
+ rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_KEYTAB,
+ !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE));
+ rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_CIPHER,
+ (crypto->cmd == SET_KEY) * crypto->cipher);
+ rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_BSS_IDX,
+ (crypto->cmd == SET_KEY) * crypto->bssidx);
+ rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher);
+ rt2x00usb_register_write(rt2x00dev, offset, reg);
+
+ offset = MAC_IVEIV_ENTRY(key->hw_key_idx);
+
+ memset(&iveiv_entry, 0, sizeof(iveiv_entry));
+ if ((crypto->cipher == CIPHER_TKIP) ||
+ (crypto->cipher == CIPHER_TKIP_NO_MIC) ||
+ (crypto->cipher == CIPHER_AES))
+ iveiv_entry.iv[3] |= 0x20;
+ iveiv_entry.iv[3] |= key->keyidx << 6;
+ rt2x00usb_register_multiwrite(rt2x00dev, offset,
+ &iveiv_entry, sizeof(iveiv_entry));
+
+ offset = MAC_WCID_ENTRY(key->hw_key_idx);
+
+ memset(&wcid_entry, 0, sizeof(wcid_entry));
+ if (crypto->cmd == SET_KEY)
+ memcpy(&wcid_entry, crypto->address, ETH_ALEN);
+ rt2x00usb_register_multiwrite(rt2x00dev, offset,
+ &wcid_entry, sizeof(wcid_entry));
+}
+
+static int rt2800usb_config_shared_key(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_crypto *crypto,
+ struct ieee80211_key_conf *key)
+{
+ struct hw_key_entry key_entry;
+ struct rt2x00_field32 field;
+ int timeout;
+ u32 offset;
+ u32 reg;
+
+ if (crypto->cmd == SET_KEY) {
+ key->hw_key_idx = (4 * crypto->bssidx) + key->keyidx;
+
+ memcpy(key_entry.key, crypto->key,
+ sizeof(key_entry.key));
+ memcpy(key_entry.tx_mic, crypto->tx_mic,
+ sizeof(key_entry.tx_mic));
+ memcpy(key_entry.rx_mic, crypto->rx_mic,
+ sizeof(key_entry.rx_mic));
+
+ offset = SHARED_KEY_ENTRY(key->hw_key_idx);
+ timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
+ rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
+ USB_VENDOR_REQUEST_OUT,
+ offset, &key_entry,
+ sizeof(key_entry),
+ timeout);
+ }
+
+ /*
+ * The cipher types are stored over multiple registers
+ * starting with SHARED_KEY_MODE_BASE each word will have
+ * 32 bits and contains the cipher types for 2 bssidx each.
+ * Using the correct defines correctly will cause overhead,
+ * so just calculate the correct offset.
+ */
+ field.bit_offset = 4 * (key->hw_key_idx % 8);
+ field.bit_mask = 0x7 << field.bit_offset;
+
+ offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8);
+
+ rt2x00usb_register_read(rt2x00dev, offset, &reg);
+ rt2x00_set_field32(&reg, field,
+ (crypto->cmd == SET_KEY) * crypto->cipher);
+ rt2x00usb_register_write(rt2x00dev, offset, reg);
+
+ /*
+ * Update WCID information
+ */
+ rt2800usb_config_wcid_attr(rt2x00dev, crypto, key);
+
+ return 0;
+}
+
+static int rt2800usb_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_crypto *crypto,
+ struct ieee80211_key_conf *key)
+{
+ struct hw_key_entry key_entry;
+ int timeout;
+ u32 offset;
+
+ if (crypto->cmd == SET_KEY) {
+ /*
+ * 1 pairwise key is possible per AID, this means that the AID
+ * equals our hw_key_idx. Make sure the WCID starts _after_ the
+ * last possible shared key entry.
+ */
+ if (crypto->aid > (256 - 32))
+ return -ENOSPC;
+
+ key->hw_key_idx = 32 + crypto->aid;
+
+ memcpy(key_entry.key, crypto->key,
+ sizeof(key_entry.key));
+ memcpy(key_entry.tx_mic, crypto->tx_mic,
+ sizeof(key_entry.tx_mic));
+ memcpy(key_entry.rx_mic, crypto->rx_mic,
+ sizeof(key_entry.rx_mic));
+
+ offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx);
+ timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
+ rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
+ USB_VENDOR_REQUEST_OUT,
+ offset, &key_entry,
+ sizeof(key_entry),
+ timeout);
+ }
+
+ /*
+ * Update WCID information
+ */
+ rt2800usb_config_wcid_attr(rt2x00dev, crypto, key);
+
+ return 0;
+}
+
+static void rt2800usb_config_filter(struct rt2x00_dev *rt2x00dev,
+ const unsigned int filter_flags)
+{
+ u32 reg;
+
+ /*
+ * Start configuration steps.
+ * Note that the version error will always be dropped
+ * and broadcast frames will always be accepted since
+ * there is no filter for it at this time.
+ */
+ rt2x00usb_register_read(rt2x00dev, RX_FILTER_CFG, &reg);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_CRC_ERROR,
+ !(filter_flags & FIF_FCSFAIL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_PHY_ERROR,
+ !(filter_flags & FIF_PLCPFAIL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_NOT_TO_ME,
+ !(filter_flags & FIF_PROMISC_IN_BSS));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_NOT_MY_BSSD, 0);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_VER_ERROR, 1);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_MULTICAST,
+ !(filter_flags & FIF_ALLMULTI));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_BROADCAST, 0);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_DUPLICATE, 1);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_CF_END_ACK,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_CF_END,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_ACK,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_CTS,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_RTS,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_PSPOLL,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_BA, 1);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_BAR, 0);
+ rt2x00_set_field32(&reg, RX_FILTER_CFG_DROP_CNTL,
+ !(filter_flags & FIF_CONTROL));
+ rt2x00usb_register_write(rt2x00dev, RX_FILTER_CFG, reg);
+}
+
+static void rt2800usb_config_intf(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00_intf *intf,
+ struct rt2x00intf_conf *conf,
+ const unsigned int flags)
+{
+ unsigned int beacon_base;
+ u32 reg;
+
+ if (flags & CONFIG_UPDATE_TYPE) {
+ /*
+ * Clear current synchronisation setup.
+ * For the Beacon base registers we only need to clear
+ * the first byte since that byte contains the VALID and OWNER
+ * bits which (when set to 0) will invalidate the entire beacon.
+ */
+ beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
+ rt2x00usb_register_write(rt2x00dev, beacon_base, 0);
+
+ /*
+ * Enable synchronisation.
+ */
+ rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_SYNC, conf->sync);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
+ rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
+ }
+
+ if (flags & CONFIG_UPDATE_MAC) {
+ reg = le32_to_cpu(conf->mac[1]);
+ rt2x00_set_field32(&reg, MAC_ADDR_DW1_UNICAST_TO_ME_MASK, 0xff);
+ conf->mac[1] = cpu_to_le32(reg);
+
+ rt2x00usb_register_multiwrite(rt2x00dev, MAC_ADDR_DW0,
+ conf->mac, sizeof(conf->mac));
+ }
+
+ if (flags & CONFIG_UPDATE_BSSID) {
+ reg = le32_to_cpu(conf->bssid[1]);
+ rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_ID_MASK, 0);
+ rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_BCN_NUM, 0);
+ conf->bssid[1] = cpu_to_le32(reg);
+
+ rt2x00usb_register_multiwrite(rt2x00dev, MAC_BSSID_DW0,
+ conf->bssid, sizeof(conf->bssid));
+ }
+}
+
+static void rt2800usb_config_erp(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_erp *erp)
+{
+ u32 reg;
+
+ rt2x00usb_register_read(rt2x00dev, TX_TIMEOUT_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_TIMEOUT_CFG_RX_ACK_TIMEOUT,
+ DIV_ROUND_UP(erp->ack_timeout, erp->slot_time));
+ rt2x00usb_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, AUTO_RSP_CFG, &reg);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_BAC_ACK_POLICY,
+ !!erp->short_preamble);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_AR_PREAMBLE,
+ !!erp->short_preamble);
+ rt2x00usb_register_write(rt2x00dev, AUTO_RSP_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_PROTECT_CTRL,
+ erp->cts_protection ? 2 : 0);
+ rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
+
+ rt2x00usb_register_write(rt2x00dev, LEGACY_BASIC_RATE,
+ erp->basic_rates);
+ rt2x00usb_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
+
+ rt2x00usb_register_read(rt2x00dev, BKOFF_SLOT_CFG, &reg);
+ rt2x00_set_field32(&reg, BKOFF_SLOT_CFG_SLOT_TIME, erp->slot_time);
+ rt2x00_set_field32(&reg, BKOFF_SLOT_CFG_CC_DELAY_TIME, 2);
+ rt2x00usb_register_write(rt2x00dev, BKOFF_SLOT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, XIFS_TIME_CFG, &reg);
+ rt2x00_set_field32(&reg, XIFS_TIME_CFG_CCKM_SIFS_TIME, erp->sifs);
+ rt2x00_set_field32(&reg, XIFS_TIME_CFG_OFDM_SIFS_TIME, erp->sifs);
+ rt2x00_set_field32(&reg, XIFS_TIME_CFG_OFDM_XIFS_TIME, 4);
+ rt2x00_set_field32(&reg, XIFS_TIME_CFG_EIFS, erp->eifs);
+ rt2x00_set_field32(&reg, XIFS_TIME_CFG_BB_RXEND_ENABLE, 1);
+ rt2x00usb_register_write(rt2x00dev, XIFS_TIME_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_INTERVAL,
+ erp->beacon_int * 16);
+ rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
+}
+
+static void rt2800usb_config_ant(struct rt2x00_dev *rt2x00dev,
+ struct antenna_setup *ant)
+{
+ u8 r1;
+ u8 r3;
+
+ rt2800usb_bbp_read(rt2x00dev, 1, &r1);
+ rt2800usb_bbp_read(rt2x00dev, 3, &r3);
+
+ /*
+ * Configure the TX antenna.
+ */
+ switch ((int)ant->tx) {
+ case 1:
+ rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 0);
+ break;
+ case 2:
+ rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2);
+ break;
+ case 3:
+ /* Do nothing */
+ break;
+ }
+
+ /*
+ * Configure the RX antenna.
+ */
+ switch ((int)ant->rx) {
+ case 1:
+ rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
+ break;
+ case 2:
+ rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 1);
+ break;
+ case 3:
+ rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 2);
+ break;
+ }
+
+ rt2800usb_bbp_write(rt2x00dev, 3, r3);
+ rt2800usb_bbp_write(rt2x00dev, 1, r1);
+}
+
+static void rt2800usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_conf *libconf)
+{
+ u16 eeprom;
+ short lna_gain;
+
+ if (libconf->rf.channel <= 14) {
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG);
+ } else if (libconf->rf.channel <= 64) {
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
+ } else if (libconf->rf.channel <= 128) {
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
+ } else {
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
+ }
+
+ rt2x00dev->lna_gain = lna_gain;
+}
+
+static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
+ struct ieee80211_conf *conf,
+ struct rf_channel *rf,
+ struct channel_info *info)
+{
+ rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
+
+ if (rt2x00dev->default_ant.tx == 1)
+ rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
+
+ if (rt2x00dev->default_ant.rx == 1) {
+ rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1);
+ rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
+ } else if (rt2x00dev->default_ant.rx == 2)
+ rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
+
+ if (rf->channel > 14) {
+ /*
+ * When TX power is below 0, we should increase it by 7 to
+ * make it a positive value (Minumum value is -7).
+ * However this means that values between 0 and 7 have
+ * double meaning, and we should set a 7DBm boost flag.
+ */
+ rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST,
+ (info->tx_power1 >= 0));
+
+ if (info->tx_power1 < 0)
+ info->tx_power1 += 7;
+
+ rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A,
+ TXPOWER_A_TO_DEV(info->tx_power1));
+
+ rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST,
+ (info->tx_power2 >= 0));
+
+ if (info->tx_power2 < 0)
+ info->tx_power2 += 7;
+
+ rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A,
+ TXPOWER_A_TO_DEV(info->tx_power2));
+ } else {
+ rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G,
+ TXPOWER_G_TO_DEV(info->tx_power1));
+ rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G,
+ TXPOWER_G_TO_DEV(info->tx_power2));
+ }
+
+ rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
+
+ rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
+ rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
+ rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
+ rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
+
+ udelay(200);
+
+ rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
+ rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
+ rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
+ rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
+
+ udelay(200);
+
+ rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
+ rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
+ rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
+ rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
+}
+
+static void rt2800usb_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
+ struct ieee80211_conf *conf,
+ struct rf_channel *rf,
+ struct channel_info *info)
+{
+ u8 rfcsr;
+
+ rt2800usb_rfcsr_write(rt2x00dev, 2, rf->rf1);
+ rt2800usb_rfcsr_write(rt2x00dev, 2, rf->rf3);
+
+ rt2800usb_rfcsr_read(rt2x00dev, 6, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR6_R, rf->rf2);
+ rt2800usb_rfcsr_write(rt2x00dev, 6, rfcsr);
+
+ rt2800usb_rfcsr_read(rt2x00dev, 12, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER,
+ TXPOWER_G_TO_DEV(info->tx_power1));
+ rt2800usb_rfcsr_write(rt2x00dev, 12, rfcsr);
+
+ rt2800usb_rfcsr_read(rt2x00dev, 23, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset);
+ rt2800usb_rfcsr_write(rt2x00dev, 23, rfcsr);
+
+ rt2800usb_rfcsr_write(rt2x00dev, 24,
+ rt2x00dev->calibration[conf_is_ht40(conf)]);
+
+ rt2800usb_rfcsr_read(rt2x00dev, 23, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
+ rt2800usb_rfcsr_write(rt2x00dev, 23, rfcsr);
+}
+
+static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
+ struct ieee80211_conf *conf,
+ struct rf_channel *rf,
+ struct channel_info *info)
+{
+ u32 reg;
+ unsigned int tx_pin;
+ u8 bbp;
+
+ if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
+ rt2800usb_config_channel_rt2x(rt2x00dev, conf, rf, info);
+ else
+ rt2800usb_config_channel_rt3x(rt2x00dev, conf, rf, info);
+
+ /*
+ * Change BBP settings
+ */
+ rt2800usb_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+ rt2800usb_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+ rt2800usb_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
+ rt2800usb_bbp_write(rt2x00dev, 86, 0);
+
+ if (rf->channel <= 14) {
+ if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags)) {
+ rt2800usb_bbp_write(rt2x00dev, 82, 0x62);
+ rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
+ } else {
+ rt2800usb_bbp_write(rt2x00dev, 82, 0x84);
+ rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
+ }
+ } else {
+ rt2800usb_bbp_write(rt2x00dev, 82, 0xf2);
+
+ if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
+ rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
+ else
+ rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
+ }
+
+ rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_BAND_CFG_HT40_PLUS, conf_is_ht40_plus(conf));
+ rt2x00_set_field32(&reg, TX_BAND_CFG_A, rf->channel > 14);
+ rt2x00_set_field32(&reg, TX_BAND_CFG_BG, rf->channel <= 14);
+ rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
+
+ tx_pin = 0;
+
+ /* Turn on unused PA or LNA when not using 1T or 1R */
+ if (rt2x00dev->default_ant.tx != 1) {
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
+ }
+
+ /* Turn on unused PA or LNA when not using 1T or 1R */
+ if (rt2x00dev->default_ant.rx != 1) {
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
+ }
+
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, rf->channel <= 14);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
+
+ rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
+
+ rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
+ rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf));
+ rt2800usb_bbp_write(rt2x00dev, 4, bbp);
+
+ rt2800usb_bbp_read(rt2x00dev, 3, &bbp);
+ rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf));
+ rt2800usb_bbp_write(rt2x00dev, 3, bbp);
+
+ if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) {
+ if (conf_is_ht40(conf)) {
+ rt2800usb_bbp_write(rt2x00dev, 69, 0x1a);
+ rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
+ rt2800usb_bbp_write(rt2x00dev, 73, 0x16);
+ } else {
+ rt2800usb_bbp_write(rt2x00dev, 69, 0x16);
+ rt2800usb_bbp_write(rt2x00dev, 70, 0x08);
+ rt2800usb_bbp_write(rt2x00dev, 73, 0x11);
+ }
+ }
+
+ msleep(1);
+}
+
+static void rt2800usb_config_txpower(struct rt2x00_dev *rt2x00dev,
+ const int txpower)
+{
+ u32 reg;
+ u32 value = TXPOWER_G_TO_DEV(txpower);
+ u8 r1;
+
+ rt2800usb_bbp_read(rt2x00dev, 1, &r1);
+ rt2x00_set_field8(&reg, BBP1_TX_POWER, 0);
+ rt2800usb_bbp_write(rt2x00dev, 1, r1);
+
+ rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_0, &reg);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_1MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_2MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_55MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_11MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_6MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_9MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_12MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_0_18MBS, value);
+ rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_0, reg);
+
+ rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_1, &reg);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_24MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_36MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_48MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_54MBS, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_MCS0, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_MCS1, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_MCS2, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_1_MCS3, value);
+ rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_1, reg);
+
+ rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_2, &reg);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS4, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS5, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS6, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS7, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS8, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS9, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS10, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_2_MCS11, value);
+ rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_2, reg);
+
+ rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_3, &reg);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_MCS12, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_MCS13, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_MCS14, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_MCS15, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_UKNOWN1, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_UKNOWN2, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_UKNOWN3, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_3_UKNOWN4, value);
+ rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_3, reg);
+
+ rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_4, &reg);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_4_UKNOWN5, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_4_UKNOWN6, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_4_UKNOWN7, value);
+ rt2x00_set_field32(&reg, TX_PWR_CFG_4_UKNOWN8, value);
+ rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_4, reg);
+}
+
+static void rt2800usb_config_retry_limit(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_conf *libconf)
+{
+ u32 reg;
+
+ rt2x00usb_register_read(rt2x00dev, TX_RTY_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_RTY_CFG_SHORT_RTY_LIMIT,
+ libconf->conf->short_frame_max_tx_count);
+ rt2x00_set_field32(&reg, TX_RTY_CFG_LONG_RTY_LIMIT,
+ libconf->conf->long_frame_max_tx_count);
+ rt2x00_set_field32(&reg, TX_RTY_CFG_LONG_RTY_THRE, 2000);
+ rt2x00_set_field32(&reg, TX_RTY_CFG_NON_AGG_RTY_MODE, 0);
+ rt2x00_set_field32(&reg, TX_RTY_CFG_AGG_RTY_MODE, 0);
+ rt2x00_set_field32(&reg, TX_RTY_CFG_TX_AUTO_FB_ENABLE, 1);
+ rt2x00usb_register_write(rt2x00dev, TX_RTY_CFG, reg);
+}
+
+static void rt2800usb_config_ps(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_conf *libconf)
+{
+ enum dev_state state =
+ (libconf->conf->flags & IEEE80211_CONF_PS) ?
+ STATE_SLEEP : STATE_AWAKE;
+ u32 reg;
+
+ if (state == STATE_SLEEP) {
+ rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, 0);
+
+ rt2x00usb_register_read(rt2x00dev, AUTOWAKEUP_CFG, &reg);
+ rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 5);
+ rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE,
+ libconf->conf->listen_interval - 1);
+ rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTOWAKE, 1);
+ rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
+
+ rt2x00dev->ops->lib->set_device_state(rt2x00dev, state);
+ } else {
+ rt2x00dev->ops->lib->set_device_state(rt2x00dev, state);
+
+ rt2x00usb_register_read(rt2x00dev, AUTOWAKEUP_CFG, &reg);
+ rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 0);
+ rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE, 0);
+ rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTOWAKE, 0);
+ rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
+ }
+}
+
+static void rt2800usb_config(struct rt2x00_dev *rt2x00dev,
+ struct rt2x00lib_conf *libconf,
+ const unsigned int flags)
+{
+ /* Always recalculate LNA gain before changing configuration */
+ rt2800usb_config_lna_gain(rt2x00dev, libconf);
+
+ if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
+ rt2800usb_config_channel(rt2x00dev, libconf->conf,
+ &libconf->rf, &libconf->channel);
+ if (flags & IEEE80211_CONF_CHANGE_POWER)
+ rt2800usb_config_txpower(rt2x00dev, libconf->conf->power_level);
+ if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
+ rt2800usb_config_retry_limit(rt2x00dev, libconf);
+ if (flags & IEEE80211_CONF_CHANGE_PS)
+ rt2800usb_config_ps(rt2x00dev, libconf);
+}
+
+/*
+ * Link tuning
+ */
+static void rt2800usb_link_stats(struct rt2x00_dev *rt2x00dev,
+ struct link_qual *qual)
+{
+ u32 reg;
+
+ /*
+ * Update FCS error count from register.
+ */
+ rt2x00usb_register_read(rt2x00dev, RX_STA_CNT0, &reg);
+ qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR);
+}
+
+static u8 rt2800usb_get_default_vgc(struct rt2x00_dev *rt2x00dev)
+{
+ if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
+ if (rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION)
+ return 0x1c + (2 * rt2x00dev->lna_gain);
+ else
+ return 0x2e + rt2x00dev->lna_gain;
+ }
+
+ if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags))
+ return 0x32 + (rt2x00dev->lna_gain * 5) / 3;
+ else
+ return 0x3a + (rt2x00dev->lna_gain * 5) / 3;
+}
+
+static inline void rt2800usb_set_vgc(struct rt2x00_dev *rt2x00dev,
+ struct link_qual *qual, u8 vgc_level)
+{
+ if (qual->vgc_level != vgc_level) {
+ rt2800usb_bbp_write(rt2x00dev, 66, vgc_level);
+ qual->vgc_level = vgc_level;
+ qual->vgc_level_reg = vgc_level;
+ }
+}
+
+static void rt2800usb_reset_tuner(struct rt2x00_dev *rt2x00dev,
+ struct link_qual *qual)
+{
+ rt2800usb_set_vgc(rt2x00dev, qual,
+ rt2800usb_get_default_vgc(rt2x00dev));
+}
+
+static void rt2800usb_link_tuner(struct rt2x00_dev *rt2x00dev,
+ struct link_qual *qual, const u32 count)
+{
+ if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION)
+ return;
+
+ /*
+ * When RSSI is better then -80 increase VGC level with 0x10
+ */
+ rt2800usb_set_vgc(rt2x00dev, qual,
+ rt2800usb_get_default_vgc(rt2x00dev) +
+ ((qual->rssi > -80) * 0x10));
+}
+
+/*
+ * Firmware functions
+ */
+static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
+{
+ return FIRMWARE_RT2870;
+}
+
+static bool rt2800usb_check_crc(const u8 *data, const size_t len)
+{
+ u16 fw_crc;
+ u16 crc;
+
+ /*
+ * The last 2 bytes in the firmware array are the crc checksum itself,
+ * this means that we should never pass those 2 bytes to the crc
+ * algorithm.
+ */
+ fw_crc = (data[len - 2] << 8 | data[len - 1]);
+
+ /*
+ * Use the crc ccitt algorithm.
+ * This will return the same value as the legacy driver which
+ * used bit ordering reversion on the both the firmware bytes
+ * before input input as well as on the final output.
+ * Obviously using crc ccitt directly is much more efficient.
+ */
+ crc = crc_ccitt(~0, data, len - 2);
+
+ /*
+ * There is a small difference between the crc-itu-t + bitrev and
+ * the crc-ccitt crc calculation. In the latter method the 2 bytes
+ * will be swapped, use swab16 to convert the crc to the correct
+ * value.
+ */
+ crc = swab16(crc);
+
+ return fw_crc == crc;
+}
+
+static int rt2800usb_check_firmware(struct rt2x00_dev *rt2x00dev,
+ const u8 *data, const size_t len)
+{
+ u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff;
+ size_t offset = 0;
+
+ /*
+ * Firmware files:
+ * There are 2 variations of the rt2870 firmware.
+ * a) size: 4kb
+ * b) size: 8kb
+ * Note that (b) contains 2 seperate firmware blobs of 4k
+ * within the file. The first blob is the same firmware as (a),
+ * but the second blob is for the additional chipsets.
+ */
+ if (len != 4096 && len != 8192)
+ return FW_BAD_LENGTH;
+
+ /*
+ * Check if we need the upper 4kb firmware data or not.
+ */
+ if ((len == 4096) &&
+ (chipset != 0x2860) &&
+ (chipset != 0x2872) &&
+ (chipset != 0x3070))
+ return FW_BAD_VERSION;
+
+ /*
+ * 8kb firmware files must be checked as if it were
+ * 2 seperate firmware files.
+ */
+ while (offset < len) {
+ if (!rt2800usb_check_crc(data + offset, 4096))
+ return FW_BAD_CRC;
+
+ offset += 4096;
+ }
+
+ return FW_OK;
+}
+
+static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev,
+ const u8 *data, const size_t len)
+{
+ unsigned int i;
+ int status;
+ u32 reg;
+ u32 offset;
+ u32 length;
+ u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff;
+
+ /*
+ * Check which section of the firmware we need.
+ */
+ if ((chipset == 0x2860) ||
+ (chipset == 0x2872) ||
+ (chipset == 0x3070)) {
+ offset = 0;
+ length = 4096;
+ } else {
+ offset = 4096;
+ length = 4096;
+ }
+
+ /*
+ * Wait for stable hardware.
+ */
+ for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+ rt2x00usb_register_read(rt2x00dev, MAC_CSR0, &reg);
+ if (reg && reg != ~0)
+ break;
+ msleep(1);
+ }
+
+ if (i == REGISTER_BUSY_COUNT) {
+ ERROR(rt2x00dev, "Unstable hardware.\n");
+ return -EBUSY;
+ }
+
+ /*
+ * Write firmware to device.
+ */
+ rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
+ USB_VENDOR_REQUEST_OUT,
+ FIRMWARE_IMAGE_BASE,
+ data + offset, length,
+ REGISTER_TIMEOUT32(length));
+
+ rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+ rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
+
+ /*
+ * Send firmware request to device to load firmware,
+ * we need to specify a long timeout time.
+ */
+ status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
+ 0, USB_MODE_FIRMWARE,
+ REGISTER_TIMEOUT_FIRMWARE);
+ if (status < 0) {
+ ERROR(rt2x00dev, "Failed to write Firmware to device.\n");
+ return status;
+ }
+
+ msleep(10);
+ rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
+
+ /*
+ * Send signal to firmware during boot time.
+ */
+ rt2800usb_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0xff, 0, 0);
+
+ if ((chipset == 0x3070) ||
+ (chipset == 0x3071) ||
+ (chipset == 0x3572)) {
+ udelay(200);
+ rt2800usb_mcu_request(rt2x00dev, MCU_CURRENT, 0, 0, 0);
+ udelay(10);
+ }
+
+ /*
+ * Wait for device to stabilize.
+ */
+ for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+ rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, &reg);
+ if (rt2x00_get_field32(reg, PBF_SYS_CTRL_READY))
+ break;
+ msleep(1);
+ }
+
+ if (i == REGISTER_BUSY_COUNT) {
+ ERROR(rt2x00dev, "PBF system register not ready.\n");
+ return -EBUSY;
+ }
+
+ /*
+ * Initialize firmware.
+ */
+ rt2x00usb_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
+ rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
+ msleep(1);
+
+ return 0;
+}
+
+/*
+ * Initialization functions.
+ */
+static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
+{
+ u32 reg;
+ unsigned int i;
+
+ /*
+ * Wait untill BBP and RF are ready.
+ */
+ for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+ rt2x00usb_register_read(rt2x00dev, MAC_CSR0, &reg);
+ if (reg && reg != ~0)
+ break;
+ msleep(1);
+ }
+
+ if (i == REGISTER_BUSY_COUNT) {
+ ERROR(rt2x00dev, "Unstable hardware.\n");
+ return -EBUSY;
+ }
+
+ rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, &reg);
+ rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
+
+ rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
+ rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
+ rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
+
+ rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
+
+ rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
+ USB_MODE_RESET, REGISTER_TIMEOUT);
+
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
+
+ rt2x00usb_register_read(rt2x00dev, BCN_OFFSET0, &reg);
+ rt2x00_set_field32(&reg, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */
+ rt2x00_set_field32(&reg, BCN_OFFSET0_BCN1, 0xe8); /* 0x3a00 */
+ rt2x00_set_field32(&reg, BCN_OFFSET0_BCN2, 0xf0); /* 0x3c00 */
+ rt2x00_set_field32(&reg, BCN_OFFSET0_BCN3, 0xf8); /* 0x3e00 */
+ rt2x00usb_register_write(rt2x00dev, BCN_OFFSET0, reg);
+
+ rt2x00usb_register_read(rt2x00dev, BCN_OFFSET1, &reg);
+ rt2x00_set_field32(&reg, BCN_OFFSET1_BCN4, 0xc8); /* 0x3200 */
+ rt2x00_set_field32(&reg, BCN_OFFSET1_BCN5, 0xd0); /* 0x3400 */
+ rt2x00_set_field32(&reg, BCN_OFFSET1_BCN6, 0x77); /* 0x1dc0 */
+ rt2x00_set_field32(&reg, BCN_OFFSET1_BCN7, 0x6f); /* 0x1bc0 */
+ rt2x00usb_register_write(rt2x00dev, BCN_OFFSET1, reg);
+
+ rt2x00usb_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f);
+ rt2x00usb_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
+
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
+
+ rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_INTERVAL, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_SYNC, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TX_TIME_COMPENSATE, 0);
+ rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
+
+ if (rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) {
+ rt2x00usb_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400);
+ rt2x00usb_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
+ rt2x00usb_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
+ } else {
+ rt2x00usb_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000);
+ rt2x00usb_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
+ }
+
+ rt2x00usb_register_read(rt2x00dev, TX_LINK_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_REMOTE_MFB_LIFETIME, 32);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_MFB_ENABLE, 0);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_REMOTE_UMFS_ENABLE, 0);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_TX_MRQ_EN, 0);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_TX_RDG_EN, 0);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_TX_CF_ACK_EN, 1);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_REMOTE_MFB, 0);
+ rt2x00_set_field32(&reg, TX_LINK_CFG_REMOTE_MFS, 0);
+ rt2x00usb_register_write(rt2x00dev, TX_LINK_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, TX_TIMEOUT_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_TIMEOUT_CFG_MPDU_LIFETIME, 9);
+ rt2x00_set_field32(&reg, TX_TIMEOUT_CFG_TX_OP_TIMEOUT, 10);
+ rt2x00usb_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, MAX_LEN_CFG, &reg);
+ rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE);
+ if (rt2x00_rev(&rt2x00dev->chip) >= RT2880E_VERSION &&
+ rt2x00_rev(&rt2x00dev->chip) < RT3070_VERSION)
+ rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 2);
+ else
+ rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 1);
+ rt2x00_set_field32(&reg, MAX_LEN_CFG_MIN_PSDU, 0);
+ rt2x00_set_field32(&reg, MAX_LEN_CFG_MIN_MPDU, 0);
+ rt2x00usb_register_write(rt2x00dev, MAX_LEN_CFG, reg);
+
+ rt2x00usb_register_write(rt2x00dev, PBF_MAX_PCNT, 0x1f3fbf9f);
+
+ rt2x00usb_register_read(rt2x00dev, AUTO_RSP_CFG, &reg);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_AUTORESPONDER, 1);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_CTS_40_MMODE, 0);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_CTS_40_MREF, 0);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_DUAL_CTS_EN, 0);
+ rt2x00_set_field32(&reg, AUTO_RSP_CFG_ACK_CTS_PSM_BIT, 0);
+ rt2x00usb_register_write(rt2x00dev, AUTO_RSP_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, CCK_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_PROTECT_RATE, 8);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_PROTECT_CTRL, 0);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_PROTECT_NAV, 1);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_TX_OP_ALLOW_CCK, 1);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_TX_OP_ALLOW_MM20, 1);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_TX_OP_ALLOW_MM40, 1);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_TX_OP_ALLOW_GF20, 1);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_TX_OP_ALLOW_GF40, 1);
+ rt2x00usb_register_write(rt2x00dev, CCK_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_PROTECT_RATE, 8);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_PROTECT_CTRL, 0);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_PROTECT_NAV, 1);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_TX_OP_ALLOW_CCK, 1);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_TX_OP_ALLOW_MM20, 1);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_TX_OP_ALLOW_MM40, 1);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_TX_OP_ALLOW_GF20, 1);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_TX_OP_ALLOW_GF40, 1);
+ rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, MM20_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_PROTECT_RATE, 0x4004);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_PROTECT_CTRL, 0);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_PROTECT_NAV, 1);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_TX_OP_ALLOW_CCK, 1);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_TX_OP_ALLOW_MM20, 1);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_TX_OP_ALLOW_MM40, 0);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_TX_OP_ALLOW_GF20, 1);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_TX_OP_ALLOW_GF40, 0);
+ rt2x00usb_register_write(rt2x00dev, MM20_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, MM40_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_PROTECT_RATE, 0x4084);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_PROTECT_CTRL, 0);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_PROTECT_NAV, 1);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_TX_OP_ALLOW_CCK, 1);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_TX_OP_ALLOW_MM20, 1);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_TX_OP_ALLOW_MM40, 1);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_TX_OP_ALLOW_GF20, 1);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_TX_OP_ALLOW_GF40, 1);
+ rt2x00usb_register_write(rt2x00dev, MM40_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, GF20_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_PROTECT_RATE, 0x4004);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_PROTECT_CTRL, 0);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_PROTECT_NAV, 1);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_TX_OP_ALLOW_CCK, 1);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_TX_OP_ALLOW_MM20, 1);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_TX_OP_ALLOW_MM40, 0);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_TX_OP_ALLOW_GF20, 1);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_TX_OP_ALLOW_GF40, 0);
+ rt2x00usb_register_write(rt2x00dev, GF20_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, GF40_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_PROTECT_RATE, 0x4084);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_PROTECT_CTRL, 0);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_PROTECT_NAV, 1);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_TX_OP_ALLOW_CCK, 1);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_TX_OP_ALLOW_MM20, 1);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_TX_OP_ALLOW_MM40, 1);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_TX_OP_ALLOW_GF20, 1);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_TX_OP_ALLOW_GF40, 1);
+ rt2x00usb_register_write(rt2x00dev, GF40_PROT_CFG, reg);
+
+ rt2x00usb_register_write(rt2x00dev, PBF_CFG, 0xf40006);
+
+ rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_DMA_BUSY, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_RX_DMA_BUSY, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_WP_DMA_BURST_SIZE, 3);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_BIG_ENDIAN, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_RX_HDR_SCATTER, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_HDR_SEG_LEN, 0);
+ rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
+
+ rt2x00usb_register_write(rt2x00dev, TXOP_CTRL_CFG, 0x0000583f);
+ rt2x00usb_register_write(rt2x00dev, TXOP_HLDR_ET, 0x00000002);
+
+ rt2x00usb_register_read(rt2x00dev, TX_RTS_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 32);
+ rt2x00_set_field32(&reg, TX_RTS_CFG_RTS_THRES,
+ IEEE80211_MAX_RTS_THRESHOLD);
+ rt2x00_set_field32(&reg, TX_RTS_CFG_RTS_FBK_EN, 0);
+ rt2x00usb_register_write(rt2x00dev, TX_RTS_CFG, reg);
+
+ rt2x00usb_register_write(rt2x00dev, EXP_ACK_TIME, 0x002400ca);
+ rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
+
+ /*
+ * ASIC will keep garbage value after boot, clear encryption keys.
+ */
+ for (i = 0; i < 256; i++) {
+ u32 wcid[2] = { 0xffffffff, 0x00ffffff };
+ rt2x00usb_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
+ wcid, sizeof(wcid));
+
+ rt2x00usb_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1);
+ rt2x00usb_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0);
+ }
+
+ for (i = 0; i < 16; i++)
+ rt2x00usb_register_write(rt2x00dev,
+ SHARED_KEY_MODE_ENTRY(i), 0);
+
+ /*
+ * Clear all beacons
+ * For the Beacon base registers we only need to clear
+ * the first byte since that byte contains the VALID and OWNER
+ * bits which (when set to 0) will invalidate the entire beacon.
+ */
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE0, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE1, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE2, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE3, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE4, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE5, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE6, 0);
+ rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE7, 0);
+
+ rt2x00usb_register_read(rt2x00dev, USB_CYC_CFG, &reg);
+ rt2x00_set_field32(&reg, USB_CYC_CFG_CLOCK_CYCLE, 30);
+ rt2x00usb_register_write(rt2x00dev, USB_CYC_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, HT_FBK_CFG0, &reg);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS0FBK, 0);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS1FBK, 0);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS2FBK, 1);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS3FBK, 2);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS4FBK, 3);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS5FBK, 4);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS6FBK, 5);
+ rt2x00_set_field32(&reg, HT_FBK_CFG0_HTMCS7FBK, 6);
+ rt2x00usb_register_write(rt2x00dev, HT_FBK_CFG0, reg);
+
+ rt2x00usb_register_read(rt2x00dev, HT_FBK_CFG1, &reg);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS8FBK, 8);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS9FBK, 8);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS10FBK, 9);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS11FBK, 10);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS12FBK, 11);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS13FBK, 12);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS14FBK, 13);
+ rt2x00_set_field32(&reg, HT_FBK_CFG1_HTMCS15FBK, 14);
+ rt2x00usb_register_write(rt2x00dev, HT_FBK_CFG1, reg);
+
+ rt2x00usb_register_read(rt2x00dev, LG_FBK_CFG0, &reg);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS0FBK, 8);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS1FBK, 8);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS2FBK, 3);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS3FBK, 10);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS4FBK, 11);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS5FBK, 12);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS6FBK, 13);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_OFDMMCS7FBK, 14);
+ rt2x00usb_register_write(rt2x00dev, LG_FBK_CFG0, reg);
+
+ rt2x00usb_register_read(rt2x00dev, LG_FBK_CFG1, &reg);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_CCKMCS0FBK, 0);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_CCKMCS1FBK, 0);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_CCKMCS2FBK, 1);
+ rt2x00_set_field32(&reg, LG_FBK_CFG0_CCKMCS3FBK, 2);
+ rt2x00usb_register_write(rt2x00dev, LG_FBK_CFG1, reg);
+
+ /*
+ * We must clear the error counters.
+ * These registers are cleared on read,
+ * so we may pass a useless variable to store the value.
+ */
+ rt2x00usb_register_read(rt2x00dev, RX_STA_CNT0, &reg);
+ rt2x00usb_register_read(rt2x00dev, RX_STA_CNT1, &reg);
+ rt2x00usb_register_read(rt2x00dev, RX_STA_CNT2, &reg);
+ rt2x00usb_register_read(rt2x00dev, TX_STA_CNT0, &reg);
+ rt2x00usb_register_read(rt2x00dev, TX_STA_CNT1, &reg);
+ rt2x00usb_register_read(rt2x00dev, TX_STA_CNT2, &reg);
+
+ return 0;
+}
+
+static int rt2800usb_wait_bbp_rf_ready(struct rt2x00_dev *rt2x00dev)
+{
+ unsigned int i;
+ u32 reg;
+
+ for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+ rt2x00usb_register_read(rt2x00dev, MAC_STATUS_CFG, &reg);
+ if (!rt2x00_get_field32(reg, MAC_STATUS_CFG_BBP_RF_BUSY))
+ return 0;
+
+ udelay(REGISTER_BUSY_DELAY);
+ }
+
+ ERROR(rt2x00dev, "BBP/RF register access failed, aborting.\n");
+ return -EACCES;
+}
+
+static int rt2800usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
+{
+ unsigned int i;
+ u8 value;
+
+ /*
+ * BBP was enabled after firmware was loaded,
+ * but we need to reactivate it now.
+ */
+ rt2x00usb_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
+ rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
+ msleep(1);
+
+ for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+ rt2800usb_bbp_read(rt2x00dev, 0, &value);
+ if ((value != 0xff) && (value != 0x00))
+ return 0;
+ udelay(REGISTER_BUSY_DELAY);
+ }
+
+ ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
+ return -EACCES;
+}
+
+static int rt2800usb_init_bbp(struct rt2x00_dev *rt2x00dev)
+{
+ unsigned int i;
+ u16 eeprom;
+ u8 reg_id;
+ u8 value;
+
+ if (unlikely(rt2800usb_wait_bbp_rf_ready(rt2x00dev) ||
+ rt2800usb_wait_bbp_ready(rt2x00dev)))
+ return -EACCES;
+
+ rt2800usb_bbp_write(rt2x00dev, 65, 0x2c);
+ rt2800usb_bbp_write(rt2x00dev, 66, 0x38);
+ rt2800usb_bbp_write(rt2x00dev, 69, 0x12);
+ rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
+ rt2800usb_bbp_write(rt2x00dev, 73, 0x10);
+ rt2800usb_bbp_write(rt2x00dev, 81, 0x37);
+ rt2800usb_bbp_write(rt2x00dev, 82, 0x62);
+ rt2800usb_bbp_write(rt2x00dev, 83, 0x6a);
+ rt2800usb_bbp_write(rt2x00dev, 84, 0x99);
+ rt2800usb_bbp_write(rt2x00dev, 86, 0x00);
+ rt2800usb_bbp_write(rt2x00dev, 91, 0x04);
+ rt2800usb_bbp_write(rt2x00dev, 92, 0x00);
+ rt2800usb_bbp_write(rt2x00dev, 103, 0x00);
+ rt2800usb_bbp_write(rt2x00dev, 105, 0x05);
+
+ if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) {
+ rt2800usb_bbp_write(rt2x00dev, 69, 0x16);
+ rt2800usb_bbp_write(rt2x00dev, 73, 0x12);
+ }
+
+ if (rt2x00_rev(&rt2x00dev->chip) > RT2860D_VERSION) {
+ rt2800usb_bbp_write(rt2x00dev, 84, 0x19);
+ }
+
+ if (rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) {
+ rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
+ rt2800usb_bbp_write(rt2x00dev, 84, 0x99);
+ rt2800usb_bbp_write(rt2x00dev, 105, 0x05);
+ }
+
+ for (i = 0; i < EEPROM_BBP_SIZE; i++) {
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
+
+ if (eeprom != 0xffff && eeprom != 0x0000) {
+ reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
+ value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
+ rt2800usb_bbp_write(rt2x00dev, reg_id, value);
+ }
+ }
+
+ return 0;
+}
+
+static u8 rt2800usb_init_rx_filter(struct rt2x00_dev *rt2x00dev,
+ bool bw40, u8 rfcsr24, u8 filter_target)
+{
+ unsigned int i;
+ u8 bbp;
+ u8 rfcsr;
+ u8 passband;
+ u8 stopband;
+ u8 overtuned = 0;
+
+ rt2800usb_rfcsr_write(rt2x00dev, 24, rfcsr24);
+
+ rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
+ rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * bw40);
+ rt2800usb_bbp_write(rt2x00dev, 4, bbp);
+
+ rt2800usb_rfcsr_read(rt2x00dev, 22, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 1);
+ rt2800usb_rfcsr_write(rt2x00dev, 22, rfcsr);
+
+ /*
+ * Set power & frequency of passband test tone
+ */
+ rt2800usb_bbp_write(rt2x00dev, 24, 0);
+
+ for (i = 0; i < 100; i++) {
+ rt2800usb_bbp_write(rt2x00dev, 25, 0x90);
+ msleep(1);
+
+ rt2800usb_bbp_read(rt2x00dev, 55, &passband);
+ if (passband)
+ break;
+ }
+
+ /*
+ * Set power & frequency of stopband test tone
+ */
+ rt2800usb_bbp_write(rt2x00dev, 24, 0x06);
+
+ for (i = 0; i < 100; i++) {
+ rt2800usb_bbp_write(rt2x00dev, 25, 0x90);
+ msleep(1);
+
+ rt2800usb_bbp_read(rt2x00dev, 55, &stopband);
+
+ if ((passband - stopband) <= filter_target) {
+ rfcsr24++;
+ overtuned += ((passband - stopband) == filter_target);
+ } else
+ break;
+
+ rt2800usb_rfcsr_write(rt2x00dev, 24, rfcsr24);
+ }
+
+ rfcsr24 -= !!overtuned;
+
+ rt2800usb_rfcsr_write(rt2x00dev, 24, rfcsr24);
+ return rfcsr24;
+}
+
+static int rt2800usb_init_rfcsr(struct rt2x00_dev *rt2x00dev)
+{
+ u8 rfcsr;
+ u8 bbp;
+
+ if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
+ return 0;
+
+ /*
+ * Init RF calibration.
+ */
+ rt2800usb_rfcsr_read(rt2x00dev, 30, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
+ rt2800usb_rfcsr_write(rt2x00dev, 30, rfcsr);
+ msleep(1);
+ rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0);
+ rt2800usb_rfcsr_write(rt2x00dev, 30, rfcsr);
+
+ rt2800usb_rfcsr_write(rt2x00dev, 4, 0x40);
+ rt2800usb_rfcsr_write(rt2x00dev, 5, 0x03);
+ rt2800usb_rfcsr_write(rt2x00dev, 6, 0x02);
+ rt2800usb_rfcsr_write(rt2x00dev, 7, 0x70);
+ rt2800usb_rfcsr_write(rt2x00dev, 9, 0x0f);
+ rt2800usb_rfcsr_write(rt2x00dev, 10, 0x71);
+ rt2800usb_rfcsr_write(rt2x00dev, 11, 0x21);
+ rt2800usb_rfcsr_write(rt2x00dev, 12, 0x7b);
+ rt2800usb_rfcsr_write(rt2x00dev, 14, 0x90);
+ rt2800usb_rfcsr_write(rt2x00dev, 15, 0x58);
+ rt2800usb_rfcsr_write(rt2x00dev, 16, 0xb3);
+ rt2800usb_rfcsr_write(rt2x00dev, 17, 0x92);
+ rt2800usb_rfcsr_write(rt2x00dev, 18, 0x2c);
+ rt2800usb_rfcsr_write(rt2x00dev, 19, 0x02);
+ rt2800usb_rfcsr_write(rt2x00dev, 20, 0xba);
+ rt2800usb_rfcsr_write(rt2x00dev, 21, 0xdb);
+ rt2800usb_rfcsr_write(rt2x00dev, 24, 0x16);
+ rt2800usb_rfcsr_write(rt2x00dev, 25, 0x01);
+ rt2800usb_rfcsr_write(rt2x00dev, 27, 0x03);
+ rt2800usb_rfcsr_write(rt2x00dev, 29, 0x1f);
+
+ /*
+ * Set RX Filter calibration for 20MHz and 40MHz
+ */
+ rt2x00dev->calibration[0] =
+ rt2800usb_init_rx_filter(rt2x00dev, false, 0x07, 0x16);
+ rt2x00dev->calibration[1] =
+ rt2800usb_init_rx_filter(rt2x00dev, true, 0x27, 0x19);
+
+ /*
+ * Set back to initial state
+ */
+ rt2800usb_bbp_write(rt2x00dev, 24, 0);
+
+ rt2800usb_rfcsr_read(rt2x00dev, 22, &rfcsr);
+ rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0);
+ rt2800usb_rfcsr_write(rt2x00dev, 22, rfcsr);
+
+ /*
+ * set BBP back to BW20
+ */
+ rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
+ rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0);
+ rt2800usb_bbp_write(rt2x00dev, 4, bbp);
+
+ return 0;
+}
+
+/*
+ * Device state switch handlers.
+ */
+static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
+ enum dev_state state)
+{
+ u32 reg;
+
+ rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
+ rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX,
+ (state == STATE_RADIO_RX_ON) ||
+ (state == STATE_RADIO_RX_ON_LINK));
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
+}
+
+static int rt2800usb_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev)
+{
+ unsigned int i;
+ u32 reg;
+
+ for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+ rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
+ if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) &&
+ !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY))
+ return 0;
+
+ msleep(1);
+ }
+
+ ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n");
+ return -EACCES;
+}
+
+static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
+{
+ u32 reg;
+ u16 word;
+
+ /*
+ * Initialize all registers.
+ */
+ if (unlikely(rt2800usb_wait_wpdma_ready(rt2x00dev) ||
+ rt2800usb_init_registers(rt2x00dev) ||
+ rt2800usb_init_bbp(rt2x00dev) ||
+ rt2800usb_init_rfcsr(rt2x00dev)))
+ return -EIO;
+
+ rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
+ rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_TX, 1);
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
+
+ udelay(50);
+
+ rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 1);
+ rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
+
+
+ rt2x00usb_register_read(rt2x00dev, USB_DMA_CFG, &reg);
+ rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0);
+ /* Don't use bulk in aggregation when working with USB 1.1 */
+ rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN,
+ (rt2x00dev->rx->usb_maxpacket == 512));
+ rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
+ /*
+ * Total room for RX frames in kilobytes, PBF might still exceed
+ * this limit so reduce the number to prevent errors.
+ */
+ rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_LIMIT,
+ ((RX_ENTRIES * DATA_FRAME_SIZE) / 1024) - 3);
+ rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_EN, 1);
+ rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1);
+ rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
+ rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_TX, 1);
+ rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
+
+ /*
+ * Initialize LED control
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word);
+ rt2800usb_mcu_request(rt2x00dev, MCU_LED_1, 0xff,
+ word & 0xff, (word >> 8) & 0xff);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word);
+ rt2800usb_mcu_request(rt2x00dev, MCU_LED_2, 0xff,
+ word & 0xff, (word >> 8) & 0xff);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word);
+ rt2800usb_mcu_request(rt2x00dev, MCU_LED_3, 0xff,
+ word & 0xff, (word >> 8) & 0xff);
+
+ return 0;
+}
+
+static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
+{
+ u32 reg;
+
+ rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
+ rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
+ rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
+
+ rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0);
+ rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0);
+ rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, 0);
+
+ /* Wait for DMA, ignore error */
+ rt2800usb_wait_wpdma_ready(rt2x00dev);
+
+ rt2x00usb_disable_radio(rt2x00dev);
+}
+
+static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev,
+ enum dev_state state)
+{
+ if (state == STATE_AWAKE)
+ rt2800usb_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
+ else
+ rt2800usb_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2);
+
+ return 0;
+}
+
+static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
+ enum dev_state state)
+{
+ int retval = 0;
+
+ switch (state) {
+ case STATE_RADIO_ON:
+ /*
+ * Before the radio can be enabled, the device first has
+ * to be woken up. After that it needs a bit of time
+ * to be fully awake and the radio can be enabled.
+ */
+ rt2800usb_set_state(rt2x00dev, STATE_AWAKE);
+ msleep(1);
+ retval = rt2800usb_enable_radio(rt2x00dev);
+ break;
+ case STATE_RADIO_OFF:
+ /*
+ * After the radio has been disablee, the device should
+ * be put to sleep for powersaving.
+ */
+ rt2800usb_disable_radio(rt2x00dev);
+ rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
+ break;
+ case STATE_RADIO_RX_ON:
+ case STATE_RADIO_RX_ON_LINK:
+ case STATE_RADIO_RX_OFF:
+ case STATE_RADIO_RX_OFF_LINK:
+ rt2800usb_toggle_rx(rt2x00dev, state);
+ break;
+ case STATE_RADIO_IRQ_ON:
+ case STATE_RADIO_IRQ_OFF:
+ /* No support, but no error either */
+ break;
+ case STATE_DEEP_SLEEP:
+ case STATE_SLEEP:
+ case STATE_STANDBY:
+ case STATE_AWAKE:
+ retval = rt2800usb_set_state(rt2x00dev, state);
+ break;
+ default:
+ retval = -ENOTSUPP;
+ break;
+ }
+
+ if (unlikely(retval))
+ ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
+ state, retval);
+
+ return retval;
+}
+
+/*
+ * TX descriptor initialization
+ */
+static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
+ struct sk_buff *skb,
+ struct txentry_desc *txdesc)
+{
+ struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
+ __le32 *txi = skbdesc->desc;
+ __le32 *txwi = &txi[TXINFO_DESC_SIZE / sizeof(__le32)];
+ u32 word;
+
+ /*
+ * Initialize TX Info descriptor
+ */
+ rt2x00_desc_read(txwi, 0, &word);
+ rt2x00_set_field32(&word, TXWI_W0_FRAG,
+ test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W0_MIMO_PS, 0);
+ rt2x00_set_field32(&word, TXWI_W0_CF_ACK, 0);
+ rt2x00_set_field32(&word, TXWI_W0_TS,
+ test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W0_AMPDU,
+ test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY, txdesc->mpdu_density);
+ rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->ifs);
+ rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->mcs);
+ rt2x00_set_field32(&word, TXWI_W0_BW,
+ test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W0_SHORT_GI,
+ test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->stbc);
+ rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode);
+ rt2x00_desc_write(txwi, 0, word);
+
+ rt2x00_desc_read(txwi, 1, &word);
+ rt2x00_set_field32(&word, TXWI_W1_ACK,
+ test_bit(ENTRY_TXD_ACK, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W1_NSEQ,
+ test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags));
+ rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size);
+ rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID,
+ test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ?
+ txdesc->key_idx : 0xff);
+ rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT,
+ skb->len - txdesc->l2pad);
+ rt2x00_set_field32(&word, TXWI_W1_PACKETID,
+ skbdesc->entry->entry_idx);
+ rt2x00_desc_write(txwi, 1, word);
+
+ /*
+ * Always write 0 to IV/EIV fields, hardware will insert the IV
+ * from the IVEIV register when TXINFO_W0_WIV is set to 0.
+ * When TXINFO_W0_WIV is set to 1 it will use the IV data
+ * from the descriptor. The TXWI_W1_WIRELESS_CLI_ID indicates which
+ * crypto entry in the registers should be used to encrypt the frame.
+ */
+ _rt2x00_desc_write(txwi, 2, 0 /* skbdesc->iv[0] */);
+ _rt2x00_desc_write(txwi, 3, 0 /* skbdesc->iv[1] */);
+
+ /*
+ * Initialize TX descriptor
+ */
+ rt2x00_desc_read(txi, 0, &word);
+ rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN,
+ skb->len + TXWI_DESC_SIZE);
+ rt2x00_set_field32(&word, TXINFO_W0_WIV,
+ !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
+ rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2);
+ rt2x00_set_field32(&word, TXINFO_W0_SW_USE_LAST_ROUND, 0);
+ rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_NEXT_VALID, 0);
+ rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST,
+ test_bit(ENTRY_TXD_BURST, &txdesc->flags));
+ rt2x00_desc_write(txi, 0, word);
+}
+
+/*
+ * TX data initialization
+ */
+static void rt2800usb_write_beacon(struct queue_entry *entry)
+{
+ struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
+ struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+ unsigned int beacon_base;
+ u32 reg;
+
+ /*
+ * Add the descriptor in front of the skb.
+ */
+ skb_push(entry->skb, entry->queue->desc_size);
+ memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
+ skbdesc->desc = entry->skb->data;
+
+ /*
+ * Disable beaconing while we are reloading the beacon data,
+ * otherwise we might be sending out invalid data.
+ */
+ rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
+ rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
+
+ /*
+ * Write entire beacon with descriptor to register.
+ */
+ beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
+ rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
+ USB_VENDOR_REQUEST_OUT, beacon_base,
+ entry->skb->data, entry->skb->len,
+ REGISTER_TIMEOUT32(entry->skb->len));
+
+ /*
+ * Clean up the beacon skb.
+ */
+ dev_kfree_skb(entry->skb);
+ entry->skb = NULL;
+}
+
+static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
+{
+ int length;
+
+ /*
+ * The length _must_ include 4 bytes padding,
+ * it should always be multiple of 4,
+ * but it must _not_ be a multiple of the USB packet size.
+ */
+ length = roundup(entry->skb->len + 4, 4);
+ length += (4 * !(length % entry->queue->usb_maxpacket));
+
+ return length;
+}
+
+static void rt2800usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
+ const enum data_queue_qid queue)
+{
+ u32 reg;
+
+ if (queue != QID_BEACON) {
+ rt2x00usb_kick_tx_queue(rt2x00dev, queue);
+ return;
+ }
+
+ rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
+ if (!rt2x00_get_field32(reg, BCN_TIME_CFG_BEACON_GEN)) {
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
+ rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
+ rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
+ }
+}
+
+/*
+ * RX control handlers
+ */
+static void rt2800usb_fill_rxdone(struct queue_entry *entry,
+ struct rxdone_entry_desc *rxdesc)
+{
+ struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
+ struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+ __le32 *rxd = (__le32 *)entry->skb->data;
+ __le32 *rxwi;
+ u32 rxd0;
+ u32 rxwi0;
+ u32 rxwi1;
+ u32 rxwi2;
+ u32 rxwi3;
+
+ /*
+ * Copy descriptor to the skbdesc->desc buffer, making it safe from
+ * moving of frame data in rt2x00usb.
+ */
+ memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
+ rxd = (__le32 *)skbdesc->desc;
+ rxwi = &rxd[RXD_DESC_SIZE / sizeof(__le32)];
+
+ /*
+ * It is now safe to read the descriptor on all architectures.
+ */
+ rt2x00_desc_read(rxd, 0, &rxd0);
+ rt2x00_desc_read(rxwi, 0, &rxwi0);
+ rt2x00_desc_read(rxwi, 1, &rxwi1);
+ rt2x00_desc_read(rxwi, 2, &rxwi2);
+ rt2x00_desc_read(rxwi, 3, &rxwi3);
+
+ if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR))
+ rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
+
+ if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
+ rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF);
+ rxdesc->cipher_status =
+ rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
+ }
+
+ if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) {
+ /*
+ * Hardware has stripped IV/EIV data from 802.11 frame during
+ * decryption. Unfortunately the descriptor doesn't contain
+ * any fields with the EIV/IV data either, so they can't
+ * be restored by rt2x00lib.
+ */
+ rxdesc->flags |= RX_FLAG_IV_STRIPPED;
+
+ if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
+ rxdesc->flags |= RX_FLAG_DECRYPTED;
+ else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
+ rxdesc->flags |= RX_FLAG_MMIC_ERROR;
+ }
+
+ if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
+ rxdesc->dev_flags |= RXDONE_MY_BSS;
+
+ if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD))
+ rxdesc->dev_flags |= RXDONE_L2PAD;
+
+ if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
+ rxdesc->flags |= RX_FLAG_SHORT_GI;
+
+ if (rt2x00_get_field32(rxwi1, RXWI_W1_BW))
+ rxdesc->flags |= RX_FLAG_40MHZ;
+
+ /*
+ * Detect RX rate, always use MCS as signal type.
+ */
+ rxdesc->dev_flags |= RXDONE_SIGNAL_MCS;
+ rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
+ rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
+
+ /*
+ * Mask of 0x8 bit to remove the short preamble flag.
+ */
+ if (rxdesc->rate_mode == RATE_MODE_CCK)
+ rxdesc->signal &= ~0x8;
+
+ rxdesc->rssi =
+ (rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
+ rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2;
+
+ rxdesc->noise =
+ (rt2x00_get_field32(rxwi3, RXWI_W3_SNR0) +
+ rt2x00_get_field32(rxwi3, RXWI_W3_SNR1)) / 2;
+
+ rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
+
+ /*
+ * Remove RXWI descriptor from start of buffer.
+ */
+ skb_pull(entry->skb, skbdesc->desc_len);
+ skb_trim(entry->skb, rxdesc->size);
+}
+
+/*
+ * Device probe functions.
+ */
+static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+ u16 word;
+ u8 *mac;
+ u8 default_lna_gain;
+
+ rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+
+ /*
+ * Start validation of the data that has been read.
+ */
+ mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+ if (!is_valid_ether_addr(mac)) {
+ DECLARE_MAC_BUF(macbuf);
+
+ random_ether_addr(mac);
+ EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac));
+ }
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
+ if (word == 0xffff) {
+ rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
+ rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
+ rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
+ EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
+ } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
+ /*
+ * There is a max of 2 RX streams for RT2870 series
+ */
+ if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
+ rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
+ }
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
+ if (word == 0xffff) {
+ rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0);
+ rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
+ EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
+ }
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
+ if ((word & 0x00ff) == 0x00ff) {
+ rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
+ rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE,
+ LED_MODE_TXRX_ACTIVITY);
+ rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_LED1, 0x5555);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
+ EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
+ }
+
+ /*
+ * During the LNA validation we are going to use
+ * lna0 as correct value. Note that EEPROM_LNA
+ * is never validated.
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
+ default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
+ if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
+ default_lna_gain);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
+ if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
+ default_lna_gain);
+ rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
+
+ return 0;
+}
+
+static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+ u32 reg;
+ u16 value;
+ u16 eeprom;
+
+ /*
+ * Read EEPROM word for configuration.
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+ /*
+ * Identify RF chipset.
+ */
+ value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
+ rt2x00usb_register_read(rt2x00dev, MAC_CSR0, &reg);
+ rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
+
+ /*
+ * The check for rt2860 is not a typo, some rt2870 hardware
+ * identifies itself as rt2860 in the CSR register.
+ */
+ if (!rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28600000) &&
+ !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28700000) &&
+ !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28800000) &&
+ !rt2x00_check_rev(&rt2x00dev->chip, 0xffff0000, 0x30700000)) {
+ ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
+ return -ENODEV;
+ }
+
+ if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+ ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
+ return -ENODEV;
+ }
+
+ /*
+ * Identify default antenna configuration.
+ */
+ rt2x00dev->default_ant.tx =
+ rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH);
+ rt2x00dev->default_ant.rx =
+ rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH);
+
+ /*
+ * Read frequency offset and RF programming sequence.
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+ rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
+
+ /*
+ * Read external LNA informations.
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
+
+ if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
+ __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
+ if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
+ __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
+
+ /*
+ * Detect if this device has an hardware controlled radio.
+ */
+#ifdef CONFIG_RT2X00_LIB_RFKILL
+ if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
+ __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+#endif /* CONFIG_RT2X00_LIB_RFKILL */
+
+ /*
+ * Store led settings, for correct led behaviour.
+ */
+#ifdef CONFIG_RT2X00_LIB_LEDS
+ rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
+ rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
+ rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ,
+ &rt2x00dev->led_mcu_reg);
+#endif /* CONFIG_RT2X00_LIB_LEDS */
+
+ return 0;
+}
+
+/*
+ * RF value list for rt2870
+ * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
+ */
+static const struct rf_channel rf_vals[] = {
+ { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
+ { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
+ { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
+ { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
+ { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
+ { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
+ { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
+ { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
+ { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
+ { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
+ { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
+ { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
+ { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
+ { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
+
+ /* 802.11 UNI / HyperLan 2 */
+ { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
+ { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
+ { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
+ { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
+ { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
+ { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
+ { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
+ { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
+ { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
+ { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
+ { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
+ { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
+
+ /* 802.11 HyperLan 2 */
+ { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
+ { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
+ { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
+ { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
+ { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
+ { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
+ { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
+ { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
+ { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
+ { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
+ { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
+ { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
+ { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
+ { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
+ { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
+ { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
+
+ /* 802.11 UNII */
+ { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
+ { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
+ { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
+ { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
+ { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
+ { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
+ { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
+ { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
+ { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
+ { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
+ { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
+
+ /* 802.11 Japan */
+ { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
+ { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
+ { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
+ { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
+ { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
+ { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
+ { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
+};
+
+/*
+ * RF value list for rt3070
+ * Supports: 2.4 GHz
+ */
+static const struct rf_channel rf_vals_3070[] = {
+ {1, 241, 2, 2 },
+ {2, 241, 2, 7 },
+ {3, 242, 2, 2 },
+ {4, 242, 2, 7 },
+ {5, 243, 2, 2 },
+ {6, 243, 2, 7 },
+ {7, 244, 2, 2 },
+ {8, 244, 2, 7 },
+ {9, 245, 2, 2 },
+ {10, 245, 2, 7 },
+ {11, 246, 2, 2 },
+ {12, 246, 2, 7 },
+ {13, 247, 2, 2 },
+ {14, 248, 2, 4 },
+};
+
+static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+{
+ struct hw_mode_spec *spec = &rt2x00dev->spec;
+ struct channel_info *info;
+ char *tx_power1;
+ char *tx_power2;
+ unsigned int i;
+ u16 eeprom;
+
+ /*
+ * Initialize all hw fields.
+ */
+ rt2x00dev->hw->flags =
+ IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
+ IEEE80211_HW_SIGNAL_DBM |
+ IEEE80211_HW_SUPPORTS_PS |
+ IEEE80211_HW_PS_NULLFUNC_STACK;
+ rt2x00dev->hw->extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+
+ SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
+ SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
+ rt2x00_eeprom_addr(rt2x00dev,
+ EEPROM_MAC_ADDR_0));
+
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+ /*
+ * Initialize HT information.
+ */
+ spec->ht.ht_supported = true;
+ spec->ht.cap =
+ IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+ IEEE80211_HT_CAP_GRN_FLD |
+ IEEE80211_HT_CAP_SGI_20 |
+ IEEE80211_HT_CAP_SGI_40 |
+ IEEE80211_HT_CAP_TX_STBC |
+ IEEE80211_HT_CAP_RX_STBC |
+ IEEE80211_HT_CAP_PSMP_SUPPORT;
+ spec->ht.ampdu_factor = 3;
+ spec->ht.ampdu_density = 4;
+ spec->ht.mcs.tx_params =
+ IEEE80211_HT_MCS_TX_DEFINED |
+ IEEE80211_HT_MCS_TX_RX_DIFF |
+ ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
+ IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
+
+ switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
+ case 3:
+ spec->ht.mcs.rx_mask[2] = 0xff;
+ case 2:
+ spec->ht.mcs.rx_mask[1] = 0xff;
+ case 1:
+ spec->ht.mcs.rx_mask[0] = 0xff;
+ spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
+ break;
+ }
+
+ /*
+ * Initialize hw_mode information.
+ */
+ spec->supported_bands = SUPPORT_BAND_2GHZ;
+ spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
+
+ if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
+ rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+ spec->num_channels = 14;
+ spec->channels = rf_vals;
+ } else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
+ rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+ spec->supported_bands |= SUPPORT_BAND_5GHZ;
+ spec->num_channels = ARRAY_SIZE(rf_vals);
+ spec->channels = rf_vals;
+ } else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
+ rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+ spec->num_channels = ARRAY_SIZE(rf_vals_3070);
+ spec->channels = rf_vals_3070;
+ }
+
+ /*
+ * Create channel information array
+ */
+ info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ spec->channels_info = info;
+
+ tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
+ tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
+
+ for (i = 0; i < 14; i++) {
+ info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
+ info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
+ }
+
+ if (spec->num_channels > 14) {
+ tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
+ tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
+
+ for (i = 14; i < spec->num_channels; i++) {
+ info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
+ info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
+ }
+ }
+
+ return 0;
+}
+
+static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
+{
+ int retval;
+
+ /*
+ * Allocate eeprom data.
+ */
+ retval = rt2800usb_validate_eeprom(rt2x00dev);
+ if (retval)
+ return retval;
+
+ retval = rt2800usb_init_eeprom(rt2x00dev);
+ if (retval)
+ return retval;
+
+ /*
+ * Initialize hw specifications.
+ */
+ retval = rt2800usb_probe_hw_mode(rt2x00dev);
+ if (retval)
+ return retval;
+
+ /*
+ * This device requires firmware.
+ */
+ __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
+ __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
+ __set_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags);
+ if (!modparam_nohwcrypt)
+ __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);
+
+ /*
+ * Set the rssi offset.
+ */
+ rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
+
+ return 0;
+}
+
+/*
+ * IEEE80211 stack callback functions.
+ */
+static void rt2800usb_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
+ u32 *iv32, u16 *iv16)
+{
+ struct rt2x00_dev *rt2x00dev = hw->priv;
+ struct mac_iveiv_entry iveiv_entry;
+ u32 offset;
+
+ offset = MAC_IVEIV_ENTRY(hw_key_idx);
+ rt2x00usb_register_multiread(rt2x00dev, offset,
+ &iveiv_entry, sizeof(iveiv_entry));
+
+ memcpy(&iveiv_entry.iv[0], iv16, sizeof(iv16));
+ memcpy(&iveiv_entry.iv[4], iv32, sizeof(iv32));
+}
+
+static int rt2800usb_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
+{
+ struct rt2x00_dev *rt2x00dev = hw->priv;
+ u32 reg;
+ bool enabled = (value < IEEE80211_MAX_RTS_THRESHOLD);
+
+ rt2x00usb_register_read(rt2x00dev, TX_RTS_CFG, &reg);
+ rt2x00_set_field32(&reg, TX_RTS_CFG_RTS_THRES, value);
+ rt2x00usb_register_write(rt2x00dev, TX_RTS_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, CCK_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, CCK_PROT_CFG_RTS_TH_EN, enabled);
+ rt2x00usb_register_write(rt2x00dev, CCK_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, OFDM_PROT_CFG_RTS_TH_EN, enabled);
+ rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, MM20_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, MM20_PROT_CFG_RTS_TH_EN, enabled);
+ rt2x00usb_register_write(rt2x00dev, MM20_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, MM40_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, MM40_PROT_CFG_RTS_TH_EN, enabled);
+ rt2x00usb_register_write(rt2x00dev, MM40_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, GF20_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, GF20_PROT_CFG_RTS_TH_EN, enabled);
+ rt2x00usb_register_write(rt2x00dev, GF20_PROT_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, GF40_PROT_CFG, &reg);
+ rt2x00_set_field32(&reg, GF40_PROT_CFG_RTS_TH_EN, enabled);
+ rt2x00usb_register_write(rt2x00dev, GF40_PROT_CFG, reg);
+
+ return 0;
+}
+
+static int rt2800usb_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
+ const struct ieee80211_tx_queue_params *params)
+{
+ struct rt2x00_dev *rt2x00dev = hw->priv;
+ struct data_queue *queue;
+ struct rt2x00_field32 field;
+ int retval;
+ u32 reg;
+ u32 offset;
+
+ /*
+ * First pass the configuration through rt2x00lib, that will
+ * update the queue settings and validate the input. After that
+ * we are free to update the registers based on the value
+ * in the queue parameter.
+ */
+ retval = rt2x00mac_conf_tx(hw, queue_idx, params);
+ if (retval)
+ return retval;
+
+ /*
+ * We only need to perform additional register initialization
+ * for WMM queues/
+ */
+ if (queue_idx >= 4)
+ return 0;
+
+ queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
+
+ /* Update WMM TXOP register */
+ offset = WMM_TXOP0_CFG + (sizeof(u32) * (!!(queue_idx & 2)));
+ field.bit_offset = (queue_idx & 1) * 16;
+ field.bit_mask = 0xffff << field.bit_offset;
+
+ rt2x00usb_register_read(rt2x00dev, offset, &reg);
+ rt2x00_set_field32(&reg, field, queue->txop);
+ rt2x00usb_register_write(rt2x00dev, offset, reg);
+
+ /* Update WMM registers */
+ field.bit_offset = queue_idx * 4;
+ field.bit_mask = 0xf << field.bit_offset;
+
+ rt2x00usb_register_read(rt2x00dev, WMM_AIFSN_CFG, &reg);
+ rt2x00_set_field32(&reg, field, queue->aifs);
+ rt2x00usb_register_write(rt2x00dev, WMM_AIFSN_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, WMM_CWMIN_CFG, &reg);
+ rt2x00_set_field32(&reg, field, queue->cw_min);
+ rt2x00usb_register_write(rt2x00dev, WMM_CWMIN_CFG, reg);
+
+ rt2x00usb_register_read(rt2x00dev, WMM_CWMAX_CFG, &reg);
+ rt2x00_set_field32(&reg, field, queue->cw_max);
+ rt2x00usb_register_write(rt2x00dev, WMM_CWMAX_CFG, reg);
+
+ /* Update EDCA registers */
+ offset = EDCA_AC0_CFG + (sizeof(u32) * queue_idx);
+
+ rt2x00usb_register_read(rt2x00dev, offset, &reg);
+ rt2x00_set_field32(&reg, EDCA_AC0_CFG_TX_OP, queue->txop);
+ rt2x00_set_field32(&reg, EDCA_AC0_CFG_AIFSN, queue->aifs);
+ rt2x00_set_field32(&reg, EDCA_AC0_CFG_CWMIN, queue->cw_min);
+ rt2x00_set_field32(&reg, EDCA_AC0_CFG_CWMAX, queue->cw_max);
+ rt2x00usb_register_write(rt2x00dev, offset, reg);
+
+ return 0;
+}
+
+static u64 rt2800usb_get_tsf(struct ieee80211_hw *hw)
+{
+ struct rt2x00_dev *rt2x00dev = hw->priv;
+ u64 tsf;
+ u32 reg;
+
+ rt2x00usb_register_read(rt2x00dev, TSF_TIMER_DW1, &reg);
+ tsf = (u64) rt2x00_get_field32(reg, TSF_TIMER_DW1_HIGH_WORD) << 32;
+ rt2x00usb_register_read(rt2x00dev, TSF_TIMER_DW0, &reg);
+ tsf |= rt2x00_get_field32(reg, TSF_TIMER_DW0_LOW_WORD);
+
+ return tsf;
+}
+
+static const struct ieee80211_ops rt2800usb_mac80211_ops = {
+ .tx = rt2x00mac_tx,
+ .start = rt2x00mac_start,
+ .stop = rt2x00mac_stop,
+ .add_interface = rt2x00mac_add_interface,
+ .remove_interface = rt2x00mac_remove_interface,
+ .config = rt2x00mac_config,
+ .configure_filter = rt2x00mac_configure_filter,
+ .set_key = rt2x00mac_set_key,
+ .get_stats = rt2x00mac_get_stats,
+ .get_tkip_seq = rt2800usb_get_tkip_seq,
+ .set_rts_threshold = rt2800usb_set_rts_threshold,
+ .bss_info_changed = rt2x00mac_bss_info_changed,
+ .conf_tx = rt2800usb_conf_tx,
+ .get_tx_stats = rt2x00mac_get_tx_stats,
+ .get_tsf = rt2800usb_get_tsf,
+};
+
+static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
+ .probe_hw = rt2800usb_probe_hw,
+ .get_firmware_name = rt2800usb_get_firmware_name,
+ .check_firmware = rt2800usb_check_firmware,
+ .load_firmware = rt2800usb_load_firmware,
+ .initialize = rt2x00usb_initialize,
+ .uninitialize = rt2x00usb_uninitialize,
+ .clear_entry = rt2x00usb_clear_entry,
+ .set_device_state = rt2800usb_set_device_state,
+ .rfkill_poll = rt2800usb_rfkill_poll,
+ .link_stats = rt2800usb_link_stats,
+ .reset_tuner = rt2800usb_reset_tuner,
+ .link_tuner = rt2800usb_link_tuner,
+ .write_tx_desc = rt2800usb_write_tx_desc,
+ .write_tx_data = rt2x00usb_write_tx_data,
+ .write_beacon = rt2800usb_write_beacon,
+ .get_tx_data_len = rt2800usb_get_tx_data_len,
+ .kick_tx_queue = rt2800usb_kick_tx_queue,
+ .kill_tx_queue = rt2x00usb_kill_tx_queue,
+ .fill_rxdone = rt2800usb_fill_rxdone,
+ .config_shared_key = rt2800usb_config_shared_key,
+ .config_pairwise_key = rt2800usb_config_pairwise_key,
+ .config_filter = rt2800usb_config_filter,
+ .config_intf = rt2800usb_config_intf,
+ .config_erp = rt2800usb_config_erp,
+ .config_ant = rt2800usb_config_ant,
+ .config = rt2800usb_config,
+};
+
+static const struct data_queue_desc rt2800usb_queue_rx = {
+ .entry_num = RX_ENTRIES,
+ .data_size = AGGREGATION_SIZE,
+ .desc_size = RXD_DESC_SIZE + RXWI_DESC_SIZE,
+ .priv_size = sizeof(struct queue_entry_priv_usb),
+};
+
+static const struct data_queue_desc rt2800usb_queue_tx = {
+ .entry_num = TX_ENTRIES,
+ .data_size = AGGREGATION_SIZE,
+ .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
+ .priv_size = sizeof(struct queue_entry_priv_usb),
+};
+
+static const struct data_queue_desc rt2800usb_queue_bcn = {
+ .entry_num = 8 * BEACON_ENTRIES,
+ .data_size = MGMT_FRAME_SIZE,
+ .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
+ .priv_size = sizeof(struct queue_entry_priv_usb),
+};
+
+static const struct rt2x00_ops rt2800usb_ops = {
+ .name = KBUILD_MODNAME,
+ .max_sta_intf = 1,
+ .max_ap_intf = 8,
+ .eeprom_size = EEPROM_SIZE,
+ .rf_size = RF_SIZE,
+ .tx_queues = NUM_TX_QUEUES,
+ .rx = &rt2800usb_queue_rx,
+ .tx = &rt2800usb_queue_tx,
+ .bcn = &rt2800usb_queue_bcn,
+ .lib = &rt2800usb_rt2x00_ops,
+ .hw = &rt2800usb_mac80211_ops,
+#ifdef CONFIG_RT2X00_LIB_DEBUGFS
+ .debugfs = &rt2800usb_rt2x00debug,
+#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
+};
+
+/*
+ * rt2800usb module information.
+ */
+static struct usb_device_id rt2800usb_device_table[] = {
+ /* Abocom */
+ { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* AirTies */
+ { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Amigo */
+ { USB_DEVICE(0x0e0b, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0e0b, 0x9041), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Amit */
+ { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* ASUS */
+ { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0b05, 0x1760), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0b05, 0x1761), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* AzureWave */
+ { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x13d3, 0x3262), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x13d3, 0x3284), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Belkin */
+ { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x050d, 0x815c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x050d, 0x825a), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Buffalo */
+ { USB_DEVICE(0x0411, 0x00e8), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0411, 0x012e), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Conceptronic */
+ { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c08), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x14b2, 0x3c28), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Corega */
+ { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x18c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* D-Link */
+ { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07d1, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07d1, 0x3c0b), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x07d1, 0x3c13), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Edimax */
+ { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* EnGenius */
+ { USB_DEVICE(0X1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1740, 0x9705), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1740, 0x9706), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1740, 0x9801), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Gemtek */
+ { USB_DEVICE(0x15a9, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Gigabyte */
+ { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1044, 0x800c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Hawking */
+ { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0e66, 0x0009), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0e66, 0x000b), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* LevelOne */
+ { USB_DEVICE(0x1740, 0x0605), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1740, 0x0615), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Linksys */
+ { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1737, 0x0077), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Logitec */
+ { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Motorola */
+ { USB_DEVICE(0x100d, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x100d, 0x9032), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Ovislink */
+ { USB_DEVICE(0x1b75, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Pegatron */
+ { USB_DEVICE(0x1d4d, 0x0002), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x1d4d, 0x000c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Philips */
+ { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Planex */
+ { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x2019, 0xab24), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Qcom */
+ { USB_DEVICE(0x18e8, 0x6259), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Quanta */
+ { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Ralink */
+ { USB_DEVICE(0x0db0, 0x6899), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x148f, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Samsung */
+ { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Siemens */
+ { USB_DEVICE(0x129b, 0x1828), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Sitecom */
+ { USB_DEVICE(0x0df6, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x002b), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x002c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x002d), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0df6, 0x0040), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* SMC */
+ { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0xa512), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x083a, 0xc522), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Sparklan */
+ { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Sweex */
+ { USB_DEVICE(0x177f, 0x0153), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x177f, 0x0302), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x177f, 0x0313), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* U-Media*/
+ { USB_DEVICE(0x157e, 0x300e), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* ZCOM */
+ { USB_DEVICE(0x0cde, 0x0022), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0cde, 0x0025), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Zinwell */
+ { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) },
+ /* Zyxel */
+ { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { USB_DEVICE(0x0586, 0x341a), USB_DEVICE_DATA(&rt2800usb_ops) },
+ { 0, }
+};
+
+MODULE_AUTHOR(DRV_PROJECT);
+MODULE_VERSION(DRV_VERSION);
+MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
+MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards");
+MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
+MODULE_FIRMWARE(FIRMWARE_RT2870);
+MODULE_LICENSE("GPL");
+
+static struct usb_driver rt2800usb_driver = {
+ .name = KBUILD_MODNAME,
+ .id_table = rt2800usb_device_table,
+ .probe = rt2x00usb_probe,
+ .disconnect = rt2x00usb_disconnect,
+ .suspend = rt2x00usb_suspend,
+ .resume = rt2x00usb_resume,
+};
+
+static int __init rt2800usb_init(void)
+{
+ return usb_register(&rt2800usb_driver);
+}
+
+static void __exit rt2800usb_exit(void)
+{
+ usb_deregister(&rt2800usb_driver);
+}
+
+module_init(rt2800usb_init);
+module_exit(rt2800usb_exit);
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.h b/drivers/net/wireless/rt2x00/rt2800usb.h
new file mode 100644
index 000000000000..61a8be61d3f5
--- /dev/null
+++ b/drivers/net/wireless/rt2x00/rt2800usb.h
@@ -0,0 +1,1945 @@
+/*
+ Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
+ <http://rt2x00.serialmonkey.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the
+ Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ Module: rt2800usb
+ Abstract: Data structures and registers for the rt2800usb module.
+ Supported chipsets: RT2800U.
+ */
+
+#ifndef RT2800USB_H
+#define RT2800USB_H
+
+/*
+ * RF chip defines.
+ *
+ * RF2820 2.4G 2T3R
+ * RF2850 2.4G/5G 2T3R
+ * RF2720 2.4G 1T2R
+ * RF2750 2.4G/5G 1T2R
+ * RF3020 2.4G 1T1R
+ * RF2020 2.4G B/G
+ */
+#define RF2820 0x0001
+#define RF2850 0x0002
+#define RF2720 0x0003
+#define RF2750 0x0004
+#define RF3020 0x0005
+#define RF2020 0x0006
+
+/*
+ * RT2870 version
+ */
+#define RT2860C_VERSION 0x28600100
+#define RT2860D_VERSION 0x28600101
+#define RT2880E_VERSION 0x28720200
+#define RT2883_VERSION 0x28830300
+#define RT3070_VERSION 0x30700200
+
+/*
+ * Signal information.
+ * Defaul offset is required for RSSI <-> dBm conversion.
+ */
+#define DEFAULT_RSSI_OFFSET 120 /* FIXME */
+
+/*
+ * Register layout information.
+ */
+#define CSR_REG_BASE 0x1000
+#define CSR_REG_SIZE 0x0800
+#define EEPROM_BASE 0x0000
+#define EEPROM_SIZE 0x0110
+#define BBP_BASE 0x0000
+#define BBP_SIZE 0x0080
+#define RF_BASE 0x0004
+#define RF_SIZE 0x0010
+
+/*
+ * Number of TX queues.
+ */
+#define NUM_TX_QUEUES 4
+
+/*
+ * USB registers.
+ */
+
+/*
+ * HOST-MCU shared memory
+ */
+#define HOST_CMD_CSR 0x0404
+#define HOST_CMD_CSR_HOST_COMMAND FIELD32(0x000000ff)
+
+/*
+ * INT_SOURCE_CSR: Interrupt source register.
+ * Write one to clear corresponding bit.
+ * TX_FIFO_STATUS: FIFO Statistics is full, sw should read 0x171c
+ */
+#define INT_SOURCE_CSR 0x0200
+#define INT_SOURCE_CSR_RXDELAYINT FIELD32(0x00000001)
+#define INT_SOURCE_CSR_TXDELAYINT FIELD32(0x00000002)
+#define INT_SOURCE_CSR_RX_DONE FIELD32(0x00000004)
+#define INT_SOURCE_CSR_AC0_DMA_DONE FIELD32(0x00000008)
+#define INT_SOURCE_CSR_AC1_DMA_DONE FIELD32(0x00000010)
+#define INT_SOURCE_CSR_AC2_DMA_DONE FIELD32(0x00000020)
+#define INT_SOURCE_CSR_AC3_DMA_DONE FIELD32(0x00000040)
+#define INT_SOURCE_CSR_HCCA_DMA_DONE FIELD32(0x00000080)
+#define INT_SOURCE_CSR_MGMT_DMA_DONE FIELD32(0x00000100)
+#define INT_SOURCE_CSR_MCU_COMMAND FIELD32(0x00000200)
+#define INT_SOURCE_CSR_RXTX_COHERENT FIELD32(0x00000400)
+#define INT_SOURCE_CSR_TBTT FIELD32(0x00000800)
+#define INT_SOURCE_CSR_PRE_TBTT FIELD32(0x00001000)
+#define INT_SOURCE_CSR_TX_FIFO_STATUS FIELD32(0x00002000)
+#define INT_SOURCE_CSR_AUTO_WAKEUP FIELD32(0x00004000)
+#define INT_SOURCE_CSR_GPTIMER FIELD32(0x00008000)
+#define INT_SOURCE_CSR_RX_COHERENT FIELD32(0x00010000)
+#define INT_SOURCE_CSR_TX_COHERENT FIELD32(0x00020000)
+
+/*
+ * INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF.
+ */
+#define INT_MASK_CSR 0x0204
+#define INT_MASK_CSR_RXDELAYINT FIELD32(0x00000001)
+#define INT_MASK_CSR_TXDELAYINT FIELD32(0x00000002)
+#define INT_MASK_CSR_RX_DONE FIELD32(0x00000004)
+#define INT_MASK_CSR_AC0_DMA_DONE FIELD32(0x00000008)
+#define INT_MASK_CSR_AC1_DMA_DONE FIELD32(0x00000010)
+#define INT_MASK_CSR_AC2_DMA_DONE FIELD32(0x00000020)
+#define INT_MASK_CSR_AC3_DMA_DONE FIELD32(0x00000040)
+#define INT_MASK_CSR_HCCA_DMA_DONE FIELD32(0x00000080)
+#define INT_MASK_CSR_MGMT_DMA_DONE FIELD32(0x00000100)
+#define INT_MASK_CSR_MCU_COMMAND FIELD32(0x00000200)
+#define INT_MASK_CSR_RXTX_COHERENT FIELD32(0x00000400)
+#define INT_MASK_CSR_TBTT FIELD32(0x00000800)
+#define INT_MASK_CSR_PRE_TBTT FIELD32(0x00001000)
+#define INT_MASK_CSR_TX_FIFO_STATUS FIELD32(0x00002000)
+#define INT_MASK_CSR_AUTO_WAKEUP FIELD32(0x00004000)
+#define INT_MASK_CSR_GPTIMER FIELD32(0x00008000)
+#define INT_MASK_CSR_RX_COHERENT FIELD32(0x00010000)
+#define INT_MASK_CSR_TX_COHERENT FIELD32(0x00020000)
+
+/*
+ * WPDMA_GLO_CFG
+ */
+#define WPDMA_GLO_CFG 0x0208
+#define WPDMA_GLO_CFG_ENABLE_TX_DMA FIELD32(0x00000001)
+#define WPDMA_GLO_CFG_TX_DMA_BUSY FIELD32(0x00000002)
+#define WPDMA_GLO_CFG_ENABLE_RX_DMA FIELD32(0x00000004)
+#define WPDMA_GLO_CFG_RX_DMA_BUSY FIELD32(0x00000008)
+#define WPDMA_GLO_CFG_WP_DMA_BURST_SIZE FIELD32(0x00000030)
+#define WPDMA_GLO_CFG_TX_WRITEBACK_DONE FIELD32(0x00000040)
+#define WPDMA_GLO_CFG_BIG_ENDIAN FIELD32(0x00000080)
+#define WPDMA_GLO_CFG_RX_HDR_SCATTER FIELD32(0x0000ff00)
+#define WPDMA_GLO_CFG_HDR_SEG_LEN FIELD32(0xffff0000)
+
+/*
+ * WPDMA_RST_IDX
+ */
+#define WPDMA_RST_IDX 0x020c
+#define WPDMA_RST_IDX_DTX_IDX0 FIELD32(0x00000001)
+#define WPDMA_RST_IDX_DTX_IDX1 FIELD32(0x00000002)
+#define WPDMA_RST_IDX_DTX_IDX2 FIELD32(0x00000004)
+#define WPDMA_RST_IDX_DTX_IDX3 FIELD32(0x00000008)
+#define WPDMA_RST_IDX_DTX_IDX4 FIELD32(0x00000010)
+#define WPDMA_RST_IDX_DTX_IDX5 FIELD32(0x00000020)
+#define WPDMA_RST_IDX_DRX_IDX0 FIELD32(0x00010000)
+
+/*
+ * DELAY_INT_CFG
+ */
+#define DELAY_INT_CFG 0x0210
+#define DELAY_INT_CFG_RXMAX_PTIME FIELD32(0x000000ff)
+#define DELAY_INT_CFG_RXMAX_PINT FIELD32(0x00007f00)
+#define DELAY_INT_CFG_RXDLY_INT_EN FIELD32(0x00008000)
+#define DELAY_INT_CFG_TXMAX_PTIME FIELD32(0x00ff0000)
+#define DELAY_INT_CFG_TXMAX_PINT FIELD32(0x7f000000)
+#define DELAY_INT_CFG_TXDLY_INT_EN FIELD32(0x80000000)
+
+/*
+ * WMM_AIFSN_CFG: Aifsn for each EDCA AC
+ * AIFSN0: AC_BE
+ * AIFSN1: AC_BK
+ * AIFSN1: AC_VI
+ * AIFSN1: AC_VO
+ */
+#define WMM_AIFSN_CFG 0x0214
+#define WMM_AIFSN_CFG_AIFSN0 FIELD32(0x0000000f)
+#define WMM_AIFSN_CFG_AIFSN1 FIELD32(0x000000f0)
+#define WMM_AIFSN_CFG_AIFSN2 FIELD32(0x00000f00)
+#define WMM_AIFSN_CFG_AIFSN3 FIELD32(0x0000f000)
+
+/*
+ * WMM_CWMIN_CSR: CWmin for each EDCA AC
+ * CWMIN0: AC_BE
+ * CWMIN1: AC_BK
+ * CWMIN1: AC_VI
+ * CWMIN1: AC_VO
+ */
+#define WMM_CWMIN_CFG 0x0218
+#define WMM_CWMIN_CFG_CWMIN0 FIELD32(0x0000000f)
+#define WMM_CWMIN_CFG_CWMIN1 FIELD32(0x000000f0)
+#define WMM_CWMIN_CFG_CWMIN2 FIELD32(0x00000f00)
+#define WMM_CWMIN_CFG_CWMIN3 FIELD32(0x0000f000)
+
+/*
+ * WMM_CWMAX_CSR: CWmax for each EDCA AC
+ * CWMAX0: AC_BE
+ * CWMAX1: AC_BK
+ * CWMAX1: AC_VI
+ * CWMAX1: AC_VO
+ */
+#define WMM_CWMAX_CFG 0x021c
+#define WMM_CWMAX_CFG_CWMAX0 FIELD32(0x0000000f)
+#define WMM_CWMAX_CFG_CWMAX1 FIELD32(0x000000f0)
+#define WMM_CWMAX_CFG_CWMAX2 FIELD32(0x00000f00)
+#define WMM_CWMAX_CFG_CWMAX3 FIELD32(0x0000f000)
+
+/*
+ * AC_TXOP0: AC_BK/AC_BE TXOP register
+ * AC0TXOP: AC_BK in unit of 32us
+ * AC1TXOP: AC_BE in unit of 32us
+ */
+#define WMM_TXOP0_CFG 0x0220
+#define WMM_TXOP0_CFG_AC0TXOP FIELD32(0x0000ffff)
+#define WMM_TXOP0_CFG_AC1TXOP FIELD32(0xffff0000)
+
+/*
+ * AC_TXOP1: AC_VO/AC_VI TXOP register
+ * AC2TXOP: AC_VI in unit of 32us
+ * AC3TXOP: AC_VO in unit of 32us
+ */
+#define WMM_TXOP1_CFG 0x0224
+#define WMM_TXOP1_CFG_AC2TXOP FIELD32(0x0000ffff)
+#define WMM_TXOP1_CFG_AC3TXOP FIELD32(0xffff0000)
+
+/*
+ * GPIO_CTRL_CFG:
+ */
+#define GPIO_CTRL_CFG 0x0228
+#define GPIO_CTRL_CFG_BIT0 FIELD32(0x00000001)
+#define GPIO_CTRL_CFG_BIT1 FIELD32(0x00000002)
+#define GPIO_CTRL_CFG_BIT2 FIELD32(0x00000004)
+#define GPIO_CTRL_CFG_BIT3 FIELD32(0x00000008)
+#define GPIO_CTRL_CFG_BIT4 FIELD32(0x00000010)
+#define GPIO_CTRL_CFG_BIT5 FIELD32(0x00000020)
+#define GPIO_CTRL_CFG_BIT6 FIELD32(0x00000040)
+#define GPIO_CTRL_CFG_BIT7 FIELD32(0x00000080)
+#define GPIO_CTRL_CFG_BIT8 FIELD32(0x00000100)
+
+/*
+ * MCU_CMD_CFG
+ */
+#define MCU_CMD_CFG 0x022c
+
+/*
+ * AC_BK register offsets
+ */
+#define TX_BASE_PTR0 0x0230
+#define TX_MAX_CNT0 0x0234
+#define TX_CTX_IDX0 0x0238
+#define TX_DTX_IDX0 0x023c
+
+/*
+ * AC_BE register offsets
+ */
+#define TX_BASE_PTR1 0x0240
+#define TX_MAX_CNT1 0x0244
+#define TX_CTX_IDX1 0x0248
+#define TX_DTX_IDX1 0x024c
+
+/*
+ * AC_VI register offsets
+ */
+#define TX_BASE_PTR2 0x0250
+#define TX_MAX_CNT2 0x0254
+#define TX_CTX_IDX2 0x0258
+#define TX_DTX_IDX2 0x025c
+
+/*
+ * AC_VO register offsets
+ */
+#define TX_BASE_PTR3 0x0260
+#define TX_MAX_CNT3 0x0264
+#define TX_CTX_IDX3 0x0268
+#define TX_DTX_IDX3 0x026c
+
+/*
+ * HCCA register offsets
+ */
+#define TX_BASE_PTR4 0x0270
+#define TX_MAX_CNT4 0x0274
+#define TX_CTX_IDX4 0x0278
+#define TX_DTX_IDX4 0x027c
+
+/*
+ * MGMT register offsets
+ */
+#define TX_BASE_PTR5 0x0280
+#define TX_MAX_CNT5 0x0284
+#define TX_CTX_IDX5 0x0288
+#define TX_DTX_IDX5 0x028c
+
+/*
+ * RX register offsets
+ */
+#define RX_BASE_PTR 0x0290
+#define RX_MAX_CNT 0x0294
+#define RX_CRX_IDX 0x0298
+#define RX_DRX_IDX 0x029c
+
+/*
+ * USB_DMA_CFG
+ * RX_BULK_AGG_TIMEOUT: Rx Bulk Aggregation TimeOut in unit of 33ns.
+ * RX_BULK_AGG_LIMIT: Rx Bulk Aggregation Limit in unit of 256 bytes.
+ * PHY_CLEAR: phy watch dog enable.
+ * TX_CLEAR: Clear USB DMA TX path.
+ * TXOP_HALT: Halt TXOP count down when TX buffer is full.
+ * RX_BULK_AGG_EN: Enable Rx Bulk Aggregation.
+ * RX_BULK_EN: Enable USB DMA Rx.
+ * TX_BULK_EN: Enable USB DMA Tx.
+ * EP_OUT_VALID: OUT endpoint data valid.
+ * RX_BUSY: USB DMA RX FSM busy.
+ * TX_BUSY: USB DMA TX FSM busy.
+ */
+#define USB_DMA_CFG 0x02a0
+#define USB_DMA_CFG_RX_BULK_AGG_TIMEOUT FIELD32(0x000000ff)
+#define USB_DMA_CFG_RX_BULK_AGG_LIMIT FIELD32(0x0000ff00)
+#define USB_DMA_CFG_PHY_CLEAR FIELD32(0x00010000)
+#define USB_DMA_CFG_TX_CLEAR FIELD32(0x00080000)
+#define USB_DMA_CFG_TXOP_HALT FIELD32(0x00100000)
+#define USB_DMA_CFG_RX_BULK_AGG_EN FIELD32(0x00200000)
+#define USB_DMA_CFG_RX_BULK_EN FIELD32(0x00400000)
+#define USB_DMA_CFG_TX_BULK_EN FIELD32(0x00800000)
+#define USB_DMA_CFG_EP_OUT_VALID FIELD32(0x3f000000)
+#define USB_DMA_CFG_RX_BUSY FIELD32(0x40000000)
+#define USB_DMA_CFG_TX_BUSY FIELD32(0x80000000)
+
+/*
+ * USB_CYC_CFG
+ */
+#define USB_CYC_CFG 0x02a4
+#define USB_CYC_CFG_CLOCK_CYCLE FIELD32(0x000000ff)
+
+/*
+ * PBF_SYS_CTRL
+ * HOST_RAM_WRITE: enable Host program ram write selection
+ */
+#define PBF_SYS_CTRL 0x0400
+#define PBF_SYS_CTRL_READY FIELD32(0x00000080)
+#define PBF_SYS_CTRL_HOST_RAM_WRITE FIELD32(0x00010000)
+
+/*
+ * PBF registers
+ * Most are for debug. Driver doesn't touch PBF register.
+ */
+#define PBF_CFG 0x0408
+#define PBF_MAX_PCNT 0x040c
+#define PBF_CTRL 0x0410
+#define PBF_INT_STA 0x0414
+#define PBF_INT_ENA 0x0418
+
+/*
+ * BCN_OFFSET0:
+ */
+#define BCN_OFFSET0 0x042c
+#define BCN_OFFSET0_BCN0 FIELD32(0x000000ff)
+#define BCN_OFFSET0_BCN1 FIELD32(0x0000ff00)
+#define BCN_OFFSET0_BCN2 FIELD32(0x00ff0000)
+#define BCN_OFFSET0_BCN3 FIELD32(0xff000000)
+
+/*
+ * BCN_OFFSET1:
+ */
+#define BCN_OFFSET1 0x0430
+#define BCN_OFFSET1_BCN4 FIELD32(0x000000ff)
+#define BCN_OFFSET1_BCN5 FIELD32(0x0000ff00)
+#define BCN_OFFSET1_BCN6 FIELD32(0x00ff0000)
+#define BCN_OFFSET1_BCN7 FIELD32(0xff000000)
+
+/*
+ * PBF registers
+ * Most are for debug. Driver doesn't touch PBF register.
+ */
+#define TXRXQ_PCNT 0x0438
+#define PBF_DBG 0x043c
+
+/*
+ * RF registers
+ */
+#define RF_CSR_CFG 0x0500
+#define RF_CSR_CFG_DATA FIELD32(0x000000ff)
+#define RF_CSR_CFG_REGNUM FIELD32(0x00001f00)
+#define RF_CSR_CFG_WRITE FIELD32(0x00010000)
+#define RF_CSR_CFG_BUSY FIELD32(0x00020000)
+
+/*
+ * MAC Control/Status Registers(CSR).
+ * Some values are set in TU, whereas 1 TU == 1024 us.
+ */
+
+/*
+ * MAC_CSR0: ASIC revision number.
+ * ASIC_REV: 0
+ * ASIC_VER: 2870
+ */
+#define MAC_CSR0 0x1000
+#define MAC_CSR0_ASIC_REV FIELD32(0x0000ffff)
+#define MAC_CSR0_ASIC_VER FIELD32(0xffff0000)
+
+/*
+ * MAC_SYS_CTRL:
+ */
+#define MAC_SYS_CTRL 0x1004
+#define MAC_SYS_CTRL_RESET_CSR FIELD32(0x00000001)
+#define MAC_SYS_CTRL_RESET_BBP FIELD32(0x00000002)
+#define MAC_SYS_CTRL_ENABLE_TX FIELD32(0x00000004)
+#define MAC_SYS_CTRL_ENABLE_RX FIELD32(0x00000008)
+#define MAC_SYS_CTRL_CONTINUOUS_TX FIELD32(0x00000010)
+#define MAC_SYS_CTRL_LOOPBACK FIELD32(0x00000020)
+#define MAC_SYS_CTRL_WLAN_HALT FIELD32(0x00000040)
+#define MAC_SYS_CTRL_RX_TIMESTAMP FIELD32(0x00000080)
+
+/*
+ * MAC_ADDR_DW0: STA MAC register 0
+ */
+#define MAC_ADDR_DW0 0x1008
+#define MAC_ADDR_DW0_BYTE0 FIELD32(0x000000ff)
+#define MAC_ADDR_DW0_BYTE1 FIELD32(0x0000ff00)
+#define MAC_ADDR_DW0_BYTE2 FIELD32(0x00ff0000)
+#define MAC_ADDR_DW0_BYTE3 FIELD32(0xff000000)
+
+/*
+ * MAC_ADDR_DW1: STA MAC register 1
+ * UNICAST_TO_ME_MASK:
+ * Used to mask off bits from byte 5 of the MAC address
+ * to determine the UNICAST_TO_ME bit for RX frames.
+ * The full mask is complemented by BSS_ID_MASK:
+ * MASK = BSS_ID_MASK & UNICAST_TO_ME_MASK
+ */
+#define MAC_ADDR_DW1 0x100c
+#define MAC_ADDR_DW1_BYTE4 FIELD32(0x000000ff)
+#define MAC_ADDR_DW1_BYTE5 FIELD32(0x0000ff00)
+#define MAC_ADDR_DW1_UNICAST_TO_ME_MASK FIELD32(0x00ff0000)
+
+/*
+ * MAC_BSSID_DW0: BSSID register 0
+ */
+#define MAC_BSSID_DW0 0x1010
+#define MAC_BSSID_DW0_BYTE0 FIELD32(0x000000ff)
+#define MAC_BSSID_DW0_BYTE1 FIELD32(0x0000ff00)
+#define MAC_BSSID_DW0_BYTE2 FIELD32(0x00ff0000)
+#define MAC_BSSID_DW0_BYTE3 FIELD32(0xff000000)
+
+/*
+ * MAC_BSSID_DW1: BSSID register 1
+ * BSS_ID_MASK:
+ * 0: 1-BSSID mode (BSS index = 0)
+ * 1: 2-BSSID mode (BSS index: Byte5, bit 0)
+ * 2: 4-BSSID mode (BSS index: byte5, bit 0 - 1)
+ * 3: 8-BSSID mode (BSS index: byte5, bit 0 - 2)
+ * This mask is used to mask off bits 0, 1 and 2 of byte 5 of the
+ * BSSID. This will make sure that those bits will be ignored
+ * when determining the MY_BSS of RX frames.
+ */
+#define MAC_BSSID_DW1 0x1014
+#define MAC_BSSID_DW1_BYTE4 FIELD32(0x000000ff)
+#define MAC_BSSID_DW1_BYTE5 FIELD32(0x0000ff00)
+#define MAC_BSSID_DW1_BSS_ID_MASK FIELD32(0x00030000)
+#define MAC_BSSID_DW1_BSS_BCN_NUM FIELD32(0x001c0000)
+
+/*
+ * MAX_LEN_CFG: Maximum frame length register.
+ * MAX_MPDU: rt2860b max 16k bytes
+ * MAX_PSDU: Maximum PSDU length
+ * (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
+ */
+#define MAX_LEN_CFG 0x1018
+#define MAX_LEN_CFG_MAX_MPDU FIELD32(0x00000fff)
+#define MAX_LEN_CFG_MAX_PSDU FIELD32(0x00003000)
+#define MAX_LEN_CFG_MIN_PSDU FIELD32(0x0000c000)
+#define MAX_LEN_CFG_MIN_MPDU FIELD32(0x000f0000)
+
+/*
+ * BBP_CSR_CFG: BBP serial control register
+ * VALUE: Register value to program into BBP
+ * REG_NUM: Selected BBP register
+ * READ_CONTROL: 0 write BBP, 1 read BBP
+ * BUSY: ASIC is busy executing BBP commands
+ * BBP_PAR_DUR: 0 4 MAC clocks, 1 8 MAC clocks
+ * BBP_RW_MODE: 0 serial, 1 paralell
+ */
+#define BBP_CSR_CFG 0x101c
+#define BBP_CSR_CFG_VALUE FIELD32(0x000000ff)
+#define BBP_CSR_CFG_REGNUM FIELD32(0x0000ff00)
+#define BBP_CSR_CFG_READ_CONTROL FIELD32(0x00010000)
+#define BBP_CSR_CFG_BUSY FIELD32(0x00020000)
+#define BBP_CSR_CFG_BBP_PAR_DUR FIELD32(0x00040000)
+#define BBP_CSR_CFG_BBP_RW_MODE FIELD32(0x00080000)
+
+/*
+ * RF_CSR_CFG0: RF control register
+ * REGID_AND_VALUE: Register value to program into RF
+ * BITWIDTH: Selected RF register
+ * STANDBYMODE: 0 high when standby, 1 low when standby
+ * SEL: 0 RF_LE0 activate, 1 RF_LE1 activate
+ * BUSY: ASIC is busy executing RF commands
+ */
+#define RF_CSR_CFG0 0x1020
+#define RF_CSR_CFG0_REGID_AND_VALUE FIELD32(0x00ffffff)
+#define RF_CSR_CFG0_BITWIDTH FIELD32(0x1f000000)
+#define RF_CSR_CFG0_REG_VALUE_BW FIELD32(0x1fffffff)
+#define RF_CSR_CFG0_STANDBYMODE FIELD32(0x20000000)
+#define RF_CSR_CFG0_SEL FIELD32(0x40000000)
+#define RF_CSR_CFG0_BUSY FIELD32(0x80000000)
+
+/*
+ * RF_CSR_CFG1: RF control register
+ * REGID_AND_VALUE: Register value to program into RF
+ * RFGAP: Gap between BB_CONTROL_RF and RF_LE
+ * 0: 3 system clock cycle (37.5usec)
+ * 1: 5 system clock cycle (62.5usec)
+ */
+#define RF_CSR_CFG1 0x1024
+#define RF_CSR_CFG1_REGID_AND_VALUE FIELD32(0x00ffffff)
+#define RF_CSR_CFG1_RFGAP FIELD32(0x1f000000)
+
+/*
+ * RF_CSR_CFG2: RF control register
+ * VALUE: Register value to program into RF
+ * RFGAP: Gap between BB_CONTROL_RF and RF_LE
+ * 0: 3 system clock cycle (37.5usec)
+ * 1: 5 system clock cycle (62.5usec)
+ */
+#define RF_CSR_CFG2 0x1028
+#define RF_CSR_CFG2_VALUE FIELD32(0x00ffffff)
+
+/*
+ * LED_CFG: LED control
+ * color LED's:
+ * 0: off
+ * 1: blinking upon TX2
+ * 2: periodic slow blinking
+ * 3: always on
+ * LED polarity:
+ * 0: active low
+ * 1: active high
+ */
+#define LED_CFG 0x102c
+#define LED_CFG_ON_PERIOD FIELD32(0x000000ff)
+#define LED_CFG_OFF_PERIOD FIELD32(0x0000ff00)
+#define LED_CFG_SLOW_BLINK_PERIOD FIELD32(0x003f0000)
+#define LED_CFG_R_LED_MODE FIELD32(0x03000000)
+#define LED_CFG_G_LED_MODE FIELD32(0x0c000000)
+#define LED_CFG_Y_LED_MODE FIELD32(0x30000000)
+#define LED_CFG_LED_POLAR FIELD32(0x40000000)
+
+/*
+ * XIFS_TIME_CFG: MAC timing
+ * CCKM_SIFS_TIME: unit 1us. Applied after CCK RX/TX
+ * OFDM_SIFS_TIME: unit 1us. Applied after OFDM RX/TX
+ * OFDM_XIFS_TIME: unit 1us. Applied after OFDM RX
+ * when MAC doesn't reference BBP signal BBRXEND
+ * EIFS: unit 1us
+ * BB_RXEND_ENABLE: reference RXEND signal to begin XIFS defer
+ *
+ */
+#define XIFS_TIME_CFG 0x1100
+#define XIFS_TIME_CFG_CCKM_SIFS_TIME FIELD32(0x000000ff)
+#define XIFS_TIME_CFG_OFDM_SIFS_TIME FIELD32(0x0000ff00)
+#define XIFS_TIME_CFG_OFDM_XIFS_TIME FIELD32(0x000f0000)
+#define XIFS_TIME_CFG_EIFS FIELD32(0x1ff00000)
+#define XIFS_TIME_CFG_BB_RXEND_ENABLE FIELD32(0x20000000)
+
+/*
+ * BKOFF_SLOT_CFG:
+ */
+#define BKOFF_SLOT_CFG 0x1104
+#define BKOFF_SLOT_CFG_SLOT_TIME FIELD32(0x000000ff)
+#define BKOFF_SLOT_CFG_CC_DELAY_TIME FIELD32(0x0000ff00)
+
+/*
+ * NAV_TIME_CFG:
+ */
+#define NAV_TIME_CFG 0x1108
+#define NAV_TIME_CFG_SIFS FIELD32(0x000000ff)
+#define NAV_TIME_CFG_SLOT_TIME FIELD32(0x0000ff00)
+#define NAV_TIME_CFG_EIFS FIELD32(0x01ff0000)
+#define NAV_TIME_ZERO_SIFS FIELD32(0x02000000)
+
+/*
+ * CH_TIME_CFG: count as channel busy
+ */
+#define CH_TIME_CFG 0x110c
+
+/*
+ * PBF_LIFE_TIMER: TX/RX MPDU timestamp timer (free run) Unit: 1us
+ */
+#define PBF_LIFE_TIMER 0x1110
+
+/*
+ * BCN_TIME_CFG:
+ * BEACON_INTERVAL: in unit of 1/16 TU
+ * TSF_TICKING: Enable TSF auto counting
+ * TSF_SYNC: Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
+ * BEACON_GEN: Enable beacon generator
+ */
+#define BCN_TIME_CFG 0x1114
+#define BCN_TIME_CFG_BEACON_INTERVAL FIELD32(0x0000ffff)
+#define BCN_TIME_CFG_TSF_TICKING FIELD32(0x00010000)
+#define BCN_TIME_CFG_TSF_SYNC FIELD32(0x00060000)
+#define BCN_TIME_CFG_TBTT_ENABLE FIELD32(0x00080000)
+#define BCN_TIME_CFG_BEACON_GEN FIELD32(0x00100000)
+#define BCN_TIME_CFG_TX_TIME_COMPENSATE FIELD32(0xf0000000)
+
+/*
+ * TBTT_SYNC_CFG:
+ */
+#define TBTT_SYNC_CFG 0x1118
+
+/*
+ * TSF_TIMER_DW0: Local lsb TSF timer, read-only
+ */
+#define TSF_TIMER_DW0 0x111c
+#define TSF_TIMER_DW0_LOW_WORD FIELD32(0xffffffff)
+
+/*
+ * TSF_TIMER_DW1: Local msb TSF timer, read-only
+ */
+#define TSF_TIMER_DW1 0x1120
+#define TSF_TIMER_DW1_HIGH_WORD FIELD32(0xffffffff)
+
+/*
+ * TBTT_TIMER: TImer remains till next TBTT, read-only
+ */
+#define TBTT_TIMER 0x1124
+
+/*
+ * INT_TIMER_CFG:
+ */
+#define INT_TIMER_CFG 0x1128
+
+/*
+ * INT_TIMER_EN: GP-timer and pre-tbtt Int enable
+ */
+#define INT_TIMER_EN 0x112c
+
+/*
+ * CH_IDLE_STA: channel idle time
+ */
+#define CH_IDLE_STA 0x1130
+
+/*
+ * CH_BUSY_STA: channel busy time
+ */
+#define CH_BUSY_STA 0x1134
+
+/*
+ * MAC_STATUS_CFG:
+ * BBP_RF_BUSY: When set to 0, BBP and RF are stable.
+ * if 1 or higher one of the 2 registers is busy.
+ */
+#define MAC_STATUS_CFG 0x1200
+#define MAC_STATUS_CFG_BBP_RF_BUSY FIELD32(0x00000003)
+
+/*
+ * PWR_PIN_CFG:
+ */
+#define PWR_PIN_CFG 0x1204
+
+/*
+ * AUTOWAKEUP_CFG: Manual power control / status register
+ * TBCN_BEFORE_WAKE: ForceWake has high privilege than PutToSleep when both set
+ * AUTOWAKE: 0:sleep, 1:awake
+ */
+#define AUTOWAKEUP_CFG 0x1208
+#define AUTOWAKEUP_CFG_AUTO_LEAD_TIME FIELD32(0x000000ff)
+#define AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE FIELD32(0x00007f00)
+#define AUTOWAKEUP_CFG_AUTOWAKE FIELD32(0x00008000)
+
+/*
+ * EDCA_AC0_CFG:
+ */
+#define EDCA_AC0_CFG 0x1300
+#define EDCA_AC0_CFG_TX_OP FIELD32(0x000000ff)
+#define EDCA_AC0_CFG_AIFSN FIELD32(0x00000f00)
+#define EDCA_AC0_CFG_CWMIN FIELD32(0x0000f000)
+#define EDCA_AC0_CFG_CWMAX FIELD32(0x000f0000)
+
+/*
+ * EDCA_AC1_CFG:
+ */
+#define EDCA_AC1_CFG 0x1304
+#define EDCA_AC1_CFG_TX_OP FIELD32(0x000000ff)
+#define EDCA_AC1_CFG_AIFSN FIELD32(0x00000f00)
+#define EDCA_AC1_CFG_CWMIN FIELD32(0x0000f000)
+#define EDCA_AC1_CFG_CWMAX FIELD32(0x000f0000)
+
+/*
+ * EDCA_AC2_CFG:
+ */
+#define EDCA_AC2_CFG 0x1308
+#define EDCA_AC2_CFG_TX_OP FIELD32(0x000000ff)
+#define EDCA_AC2_CFG_AIFSN FIELD32(0x00000f00)
+#define EDCA_AC2_CFG_CWMIN FIELD32(0x0000f000)
+#define EDCA_AC2_CFG_CWMAX FIELD32(0x000f0000)
+
+/*
+ * EDCA_AC3_CFG:
+ */
+#define EDCA_AC3_CFG 0x130c
+#define EDCA_AC3_CFG_TX_OP FIELD32(0x000000ff)
+#define EDCA_AC3_CFG_AIFSN FIELD32(0x00000f00)
+#define EDCA_AC3_CFG_CWMIN FIELD32(0x0000f000)
+#define EDCA_AC3_CFG_CWMAX FIELD32(0x000f0000)
+
+/*
+ * EDCA_TID_AC_MAP:
+ */
+#define EDCA_TID_AC_MAP 0x1310
+
+/*
+ * TX_PWR_CFG_0:
+ */
+#define TX_PWR_CFG_0 0x1314
+#define TX_PWR_CFG_0_1MBS FIELD32(0x0000000f)
+#define TX_PWR_CFG_0_2MBS FIELD32(0x000000f0)
+#define TX_PWR_CFG_0_55MBS FIELD32(0x00000f00)
+#define TX_PWR_CFG_0_11MBS FIELD32(0x0000f000)
+#define TX_PWR_CFG_0_6MBS FIELD32(0x000f0000)
+#define TX_PWR_CFG_0_9MBS FIELD32(0x00f00000)
+#define TX_PWR_CFG_0_12MBS FIELD32(0x0f000000)
+#define TX_PWR_CFG_0_18MBS FIELD32(0xf0000000)
+
+/*
+ * TX_PWR_CFG_1:
+ */
+#define TX_PWR_CFG_1 0x1318
+#define TX_PWR_CFG_1_24MBS FIELD32(0x0000000f)
+#define TX_PWR_CFG_1_36MBS FIELD32(0x000000f0)
+#define TX_PWR_CFG_1_48MBS FIELD32(0x00000f00)
+#define TX_PWR_CFG_1_54MBS FIELD32(0x0000f000)
+#define TX_PWR_CFG_1_MCS0 FIELD32(0x000f0000)
+#define TX_PWR_CFG_1_MCS1 FIELD32(0x00f00000)
+#define TX_PWR_CFG_1_MCS2 FIELD32(0x0f000000)
+#define TX_PWR_CFG_1_MCS3 FIELD32(0xf0000000)
+
+/*
+ * TX_PWR_CFG_2:
+ */
+#define TX_PWR_CFG_2 0x131c
+#define TX_PWR_CFG_2_MCS4 FIELD32(0x0000000f)
+#define TX_PWR_CFG_2_MCS5 FIELD32(0x000000f0)
+#define TX_PWR_CFG_2_MCS6 FIELD32(0x00000f00)
+#define TX_PWR_CFG_2_MCS7 FIELD32(0x0000f000)
+#define TX_PWR_CFG_2_MCS8 FIELD32(0x000f0000)
+#define TX_PWR_CFG_2_MCS9 FIELD32(0x00f00000)
+#define TX_PWR_CFG_2_MCS10 FIELD32(0x0f000000)
+#define TX_PWR_CFG_2_MCS11 FIELD32(0xf0000000)
+
+/*
+ * TX_PWR_CFG_3:
+ */
+#define TX_PWR_CFG_3 0x1320
+#define TX_PWR_CFG_3_MCS12 FIELD32(0x0000000f)
+#define TX_PWR_CFG_3_MCS13 FIELD32(0x000000f0)
+#define TX_PWR_CFG_3_MCS14 FIELD32(0x00000f00)
+#define TX_PWR_CFG_3_MCS15 FIELD32(0x0000f000)
+#define TX_PWR_CFG_3_UKNOWN1 FIELD32(0x000f0000)
+#define TX_PWR_CFG_3_UKNOWN2 FIELD32(0x00f00000)
+#define TX_PWR_CFG_3_UKNOWN3 FIELD32(0x0f000000)
+#define TX_PWR_CFG_3_UKNOWN4 FIELD32(0xf0000000)
+
+/*
+ * TX_PWR_CFG_4:
+ */
+#define TX_PWR_CFG_4 0x1324
+#define TX_PWR_CFG_4_UKNOWN5 FIELD32(0x0000000f)
+#define TX_PWR_CFG_4_UKNOWN6 FIELD32(0x000000f0)
+#define TX_PWR_CFG_4_UKNOWN7 FIELD32(0x00000f00)
+#define TX_PWR_CFG_4_UKNOWN8 FIELD32(0x0000f000)
+
+/*
+ * TX_PIN_CFG:
+ */
+#define TX_PIN_CFG 0x1328
+#define TX_PIN_CFG_PA_PE_A0_EN FIELD32(0x00000001)
+#define TX_PIN_CFG_PA_PE_G0_EN FIELD32(0x00000002)
+#define TX_PIN_CFG_PA_PE_A1_EN FIELD32(0x00000004)
+#define TX_PIN_CFG_PA_PE_G1_EN FIELD32(0x00000008)
+#define TX_PIN_CFG_PA_PE_A0_POL FIELD32(0x00000010)
+#define TX_PIN_CFG_PA_PE_G0_POL FIELD32(0x00000020)
+#define TX_PIN_CFG_PA_PE_A1_POL FIELD32(0x00000040)
+#define TX_PIN_CFG_PA_PE_G1_POL FIELD32(0x00000080)
+#define TX_PIN_CFG_LNA_PE_A0_EN FIELD32(0x00000100)
+#define TX_PIN_CFG_LNA_PE_G0_EN FIELD32(0x00000200)
+#define TX_PIN_CFG_LNA_PE_A1_EN FIELD32(0x00000400)
+#define TX_PIN_CFG_LNA_PE_G1_EN FIELD32(0x00000800)
+#define TX_PIN_CFG_LNA_PE_A0_POL FIELD32(0x00001000)
+#define TX_PIN_CFG_LNA_PE_G0_POL FIELD32(0x00002000)
+#define TX_PIN_CFG_LNA_PE_A1_POL FIELD32(0x00004000)
+#define TX_PIN_CFG_LNA_PE_G1_POL FIELD32(0x00008000)
+#define TX_PIN_CFG_RFTR_EN FIELD32(0x00010000)
+#define TX_PIN_CFG_RFTR_POL FIELD32(0x00020000)
+#define TX_PIN_CFG_TRSW_EN FIELD32(0x00040000)
+#define TX_PIN_CFG_TRSW_POL FIELD32(0x00080000)
+
+/*
+ * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
+ */
+#define TX_BAND_CFG 0x132c
+#define TX_BAND_CFG_HT40_PLUS FIELD32(0x00000001)
+#define TX_BAND_CFG_A FIELD32(0x00000002)
+#define TX_BAND_CFG_BG FIELD32(0x00000004)
+
+/*
+ * TX_SW_CFG0:
+ */
+#define TX_SW_CFG0 0x1330
+
+/*
+ * TX_SW_CFG1:
+ */
+#define TX_SW_CFG1 0x1334
+
+/*
+ * TX_SW_CFG2:
+ */
+#define TX_SW_CFG2 0x1338
+
+/*
+ * TXOP_THRES_CFG:
+ */
+#define TXOP_THRES_CFG 0x133c
+
+/*
+ * TXOP_CTRL_CFG:
+ */
+#define TXOP_CTRL_CFG 0x1340
+
+/*
+ * TX_RTS_CFG:
+ * RTS_THRES: unit:byte
+ * RTS_FBK_EN: enable rts rate fallback
+ */
+#define TX_RTS_CFG 0x1344
+#define TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT FIELD32(0x000000ff)
+#define TX_RTS_CFG_RTS_THRES FIELD32(0x00ffff00)
+#define TX_RTS_CFG_RTS_FBK_EN FIELD32(0x01000000)
+
+/*
+ * TX_TIMEOUT_CFG:
+ * MPDU_LIFETIME: expiration time = 2^(9+MPDU LIFE TIME) us
+ * RX_ACK_TIMEOUT: unit:slot. Used for TX procedure
+ * TX_OP_TIMEOUT: TXOP timeout value for TXOP truncation.
+ * it is recommended that:
+ * (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
+ */
+#define TX_TIMEOUT_CFG 0x1348
+#define TX_TIMEOUT_CFG_MPDU_LIFETIME FIELD32(0x000000f0)
+#define TX_TIMEOUT_CFG_RX_ACK_TIMEOUT FIELD32(0x0000ff00)
+#define TX_TIMEOUT_CFG_TX_OP_TIMEOUT FIELD32(0x00ff0000)
+
+/*
+ * TX_RTY_CFG:
+ * SHORT_RTY_LIMIT: short retry limit
+ * LONG_RTY_LIMIT: long retry limit
+ * LONG_RTY_THRE: Long retry threshoold
+ * NON_AGG_RTY_MODE: Non-Aggregate MPDU retry mode
+ * 0:expired by retry limit, 1: expired by mpdu life timer
+ * AGG_RTY_MODE: Aggregate MPDU retry mode
+ * 0:expired by retry limit, 1: expired by mpdu life timer
+ * TX_AUTO_FB_ENABLE: Tx retry PHY rate auto fallback enable
+ */
+#define TX_RTY_CFG 0x134c
+#define TX_RTY_CFG_SHORT_RTY_LIMIT FIELD32(0x000000ff)
+#define TX_RTY_CFG_LONG_RTY_LIMIT FIELD32(0x0000ff00)
+#define TX_RTY_CFG_LONG_RTY_THRE FIELD32(0x0fff0000)
+#define TX_RTY_CFG_NON_AGG_RTY_MODE FIELD32(0x10000000)
+#define TX_RTY_CFG_AGG_RTY_MODE FIELD32(0x20000000)
+#define TX_RTY_CFG_TX_AUTO_FB_ENABLE FIELD32(0x40000000)
+
+/*
+ * TX_LINK_CFG:
+ * REMOTE_MFB_LIFETIME: remote MFB life time. unit: 32us
+ * MFB_ENABLE: TX apply remote MFB 1:enable
+ * REMOTE_UMFS_ENABLE: remote unsolicit MFB enable
+ * 0: not apply remote remote unsolicit (MFS=7)
+ * TX_MRQ_EN: MCS request TX enable
+ * TX_RDG_EN: RDG TX enable
+ * TX_CF_ACK_EN: Piggyback CF-ACK enable
+ * REMOTE_MFB: remote MCS feedback
+ * REMOTE_MFS: remote MCS feedback sequence number
+ */
+#define TX_LINK_CFG 0x1350
+#define TX_LINK_CFG_REMOTE_MFB_LIFETIME FIELD32(0x000000ff)
+#define TX_LINK_CFG_MFB_ENABLE FIELD32(0x00000100)
+#define TX_LINK_CFG_REMOTE_UMFS_ENABLE FIELD32(0x00000200)
+#define TX_LINK_CFG_TX_MRQ_EN FIELD32(0x00000400)
+#define TX_LINK_CFG_TX_RDG_EN FIELD32(0x00000800)
+#define TX_LINK_CFG_TX_CF_ACK_EN FIELD32(0x00001000)
+#define TX_LINK_CFG_REMOTE_MFB FIELD32(0x00ff0000)
+#define TX_LINK_CFG_REMOTE_MFS FIELD32(0xff000000)
+
+/*
+ * HT_FBK_CFG0:
+ */
+#define HT_FBK_CFG0 0x1354
+#define HT_FBK_CFG0_HTMCS0FBK FIELD32(0x0000000f)
+#define HT_FBK_CFG0_HTMCS1FBK FIELD32(0x000000f0)
+#define HT_FBK_CFG0_HTMCS2FBK FIELD32(0x00000f00)
+#define HT_FBK_CFG0_HTMCS3FBK FIELD32(0x0000f000)
+#define HT_FBK_CFG0_HTMCS4FBK FIELD32(0x000f0000)
+#define HT_FBK_CFG0_HTMCS5FBK FIELD32(0x00f00000)
+#define HT_FBK_CFG0_HTMCS6FBK FIELD32(0x0f000000)
+#define HT_FBK_CFG0_HTMCS7FBK FIELD32(0xf0000000)
+
+/*
+ * HT_FBK_CFG1:
+ */
+#define HT_FBK_CFG1 0x1358
+#define HT_FBK_CFG1_HTMCS8FBK FIELD32(0x0000000f)
+#define HT_FBK_CFG1_HTMCS9FBK FIELD32(0x000000f0)
+#define HT_FBK_CFG1_HTMCS10FBK FIELD32(0x00000f00)
+#define HT_FBK_CFG1_HTMCS11FBK FIELD32(0x0000f000)
+#define HT_FBK_CFG1_HTMCS12FBK FIELD32(0x000f0000)
+#define HT_FBK_CFG1_HTMCS13FBK FIELD32(0x00f00000)
+#define HT_FBK_CFG1_HTMCS14FBK FIELD32(0x0f000000)
+#define HT_FBK_CFG1_HTMCS15FBK FIELD32(0xf0000000)
+
+/*
+ * LG_FBK_CFG0:
+ */
+#define LG_FBK_CFG0 0x135c
+#define LG_FBK_CFG0_OFDMMCS0FBK FIELD32(0x0000000f)
+#define LG_FBK_CFG0_OFDMMCS1FBK FIELD32(0x000000f0)
+#define LG_FBK_CFG0_OFDMMCS2FBK FIELD32(0x00000f00)
+#define LG_FBK_CFG0_OFDMMCS3FBK FIELD32(0x0000f000)
+#define LG_FBK_CFG0_OFDMMCS4FBK FIELD32(0x000f0000)
+#define LG_FBK_CFG0_OFDMMCS5FBK FIELD32(0x00f00000)
+#define LG_FBK_CFG0_OFDMMCS6FBK FIELD32(0x0f000000)
+#define LG_FBK_CFG0_OFDMMCS7FBK FIELD32(0xf0000000)
+
+/*
+ * LG_FBK_CFG1:
+ */
+#define LG_FBK_CFG1 0x1360
+#define LG_FBK_CFG0_CCKMCS0FBK FIELD32(0x0000000f)
+#define LG_FBK_CFG0_CCKMCS1FBK FIELD32(0x000000f0)
+#define LG_FBK_CFG0_CCKMCS2FBK FIELD32(0x00000f00)
+#define LG_FBK_CFG0_CCKMCS3FBK FIELD32(0x0000f000)
+
+/*
+ * CCK_PROT_CFG: CCK Protection
+ * PROTECT_RATE: Protection control frame rate for CCK TX(RTS/CTS/CFEnd)
+ * PROTECT_CTRL: Protection control frame type for CCK TX
+ * 0:none, 1:RTS/CTS, 2:CTS-to-self
+ * PROTECT_NAV: TXOP protection type for CCK TX
+ * 0:none, 1:ShortNAVprotect, 2:LongNAVProtect
+ * TX_OP_ALLOW_CCK: CCK TXOP allowance, 0:disallow
+ * TX_OP_ALLOW_OFDM: CCK TXOP allowance, 0:disallow
+ * TX_OP_ALLOW_MM20: CCK TXOP allowance, 0:disallow
+ * TX_OP_ALLOW_MM40: CCK TXOP allowance, 0:disallow
+ * TX_OP_ALLOW_GF20: CCK TXOP allowance, 0:disallow
+ * TX_OP_ALLOW_GF40: CCK TXOP allowance, 0:disallow
+ * RTS_TH_EN: RTS threshold enable on CCK TX
+ */
+#define CCK_PROT_CFG 0x1364
+#define CCK_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
+#define CCK_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
+#define CCK_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
+#define CCK_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
+#define CCK_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
+#define CCK_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
+#define CCK_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
+#define CCK_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
+#define CCK_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
+#define CCK_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
+
+/*
+ * OFDM_PROT_CFG: OFDM Protection
+ */
+#define OFDM_PROT_CFG 0x1368
+#define OFDM_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
+#define OFDM_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
+#define OFDM_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
+#define OFDM_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
+#define OFDM_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
+#define OFDM_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
+#define OFDM_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
+#define OFDM_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
+#define OFDM_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
+#define OFDM_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
+
+/*
+ * MM20_PROT_CFG: MM20 Protection
+ */
+#define MM20_PROT_CFG 0x136c
+#define MM20_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
+#define MM20_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
+#define MM20_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
+#define MM20_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
+#define MM20_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
+#define MM20_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
+#define MM20_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
+#define MM20_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
+#define MM20_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
+#define MM20_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
+
+/*
+ * MM40_PROT_CFG: MM40 Protection
+ */
+#define MM40_PROT_CFG 0x1370
+#define MM40_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
+#define MM40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
+#define MM40_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
+#define MM40_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
+#define MM40_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
+#define MM40_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
+#define MM40_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
+#define MM40_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
+#define MM40_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
+#define MM40_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
+
+/*
+ * GF20_PROT_CFG: GF20 Protection
+ */
+#define GF20_PROT_CFG 0x1374
+#define GF20_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
+#define GF20_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
+#define GF20_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
+#define GF20_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
+#define GF20_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
+#define GF20_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
+#define GF20_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
+#define GF20_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
+#define GF20_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
+#define GF20_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
+
+/*
+ * GF40_PROT_CFG: GF40 Protection
+ */
+#define GF40_PROT_CFG 0x1378
+#define GF40_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
+#define GF40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
+#define GF40_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
+#define GF40_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
+#define GF40_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
+#define GF40_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
+#define GF40_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
+#define GF40_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
+#define GF40_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
+#define GF40_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
+
+/*
+ * EXP_CTS_TIME:
+ */
+#define EXP_CTS_TIME 0x137c
+
+/*
+ * EXP_ACK_TIME:
+ */
+#define EXP_ACK_TIME 0x1380
+
+/*
+ * RX_FILTER_CFG: RX configuration register.
+ */
+#define RX_FILTER_CFG 0x1400
+#define RX_FILTER_CFG_DROP_CRC_ERROR FIELD32(0x00000001)
+#define RX_FILTER_CFG_DROP_PHY_ERROR FIELD32(0x00000002)
+#define RX_FILTER_CFG_DROP_NOT_TO_ME FIELD32(0x00000004)
+#define RX_FILTER_CFG_DROP_NOT_MY_BSSD FIELD32(0x00000008)
+#define RX_FILTER_CFG_DROP_VER_ERROR FIELD32(0x00000010)
+#define RX_FILTER_CFG_DROP_MULTICAST FIELD32(0x00000020)
+#define RX_FILTER_CFG_DROP_BROADCAST FIELD32(0x00000040)
+#define RX_FILTER_CFG_DROP_DUPLICATE FIELD32(0x00000080)
+#define RX_FILTER_CFG_DROP_CF_END_ACK FIELD32(0x00000100)
+#define RX_FILTER_CFG_DROP_CF_END FIELD32(0x00000200)
+#define RX_FILTER_CFG_DROP_ACK FIELD32(0x00000400)
+#define RX_FILTER_CFG_DROP_CTS FIELD32(0x00000800)
+#define RX_FILTER_CFG_DROP_RTS FIELD32(0x00001000)
+#define RX_FILTER_CFG_DROP_PSPOLL FIELD32(0x00002000)
+#define RX_FILTER_CFG_DROP_BA FIELD32(0x00004000)
+#define RX_FILTER_CFG_DROP_BAR FIELD32(0x00008000)
+#define RX_FILTER_CFG_DROP_CNTL FIELD32(0x00010000)
+
+/*
+ * AUTO_RSP_CFG:
+ * AUTORESPONDER: 0: disable, 1: enable
+ * BAC_ACK_POLICY: 0:long, 1:short preamble
+ * CTS_40_MMODE: Response CTS 40MHz duplicate mode
+ * CTS_40_MREF: Response CTS 40MHz duplicate mode
+ * AR_PREAMBLE: Auto responder preamble 0:long, 1:short preamble
+ * DUAL_CTS_EN: Power bit value in control frame
+ * ACK_CTS_PSM_BIT:Power bit value in control frame
+ */
+#define AUTO_RSP_CFG 0x1404
+#define AUTO_RSP_CFG_AUTORESPONDER FIELD32(0x00000001)
+#define AUTO_RSP_CFG_BAC_ACK_POLICY FIELD32(0x00000002)
+#define AUTO_RSP_CFG_CTS_40_MMODE FIELD32(0x00000004)
+#define AUTO_RSP_CFG_CTS_40_MREF FIELD32(0x00000008)
+#define AUTO_RSP_CFG_AR_PREAMBLE FIELD32(0x00000010)
+#define AUTO_RSP_CFG_DUAL_CTS_EN FIELD32(0x00000040)
+#define AUTO_RSP_CFG_ACK_CTS_PSM_BIT FIELD32(0x00000080)
+
+/*
+ * LEGACY_BASIC_RATE:
+ */
+#define LEGACY_BASIC_RATE 0x1408
+
+/*
+ * HT_BASIC_RATE:
+ */
+#define HT_BASIC_RATE 0x140c
+
+/*
+ * HT_CTRL_CFG:
+ */
+#define HT_CTRL_CFG 0x1410
+
+/*
+ * SIFS_COST_CFG:
+ */
+#define SIFS_COST_CFG 0x1414
+
+/*
+ * RX_PARSER_CFG:
+ * Set NAV for all received frames
+ */
+#define RX_PARSER_CFG 0x1418
+
+/*
+ * TX_SEC_CNT0:
+ */
+#define TX_SEC_CNT0 0x1500
+
+/*
+ * RX_SEC_CNT0:
+ */
+#define RX_SEC_CNT0 0x1504
+
+/*
+ * CCMP_FC_MUTE:
+ */
+#define CCMP_FC_MUTE 0x1508
+
+/*
+ * TXOP_HLDR_ADDR0:
+ */
+#define TXOP_HLDR_ADDR0 0x1600
+
+/*
+ * TXOP_HLDR_ADDR1:
+ */
+#define TXOP_HLDR_ADDR1 0x1604
+
+/*
+ * TXOP_HLDR_ET:
+ */
+#define TXOP_HLDR_ET 0x1608
+
+/*
+ * QOS_CFPOLL_RA_DW0:
+ */
+#define QOS_CFPOLL_RA_DW0 0x160c
+
+/*
+ * QOS_CFPOLL_RA_DW1:
+ */
+#define QOS_CFPOLL_RA_DW1 0x1610
+
+/*
+ * QOS_CFPOLL_QC:
+ */
+#define QOS_CFPOLL_QC 0x1614
+
+/*
+ * RX_STA_CNT0: RX PLCP error count & RX CRC error count
+ */
+#define RX_STA_CNT0 0x1700
+#define RX_STA_CNT0_CRC_ERR FIELD32(0x0000ffff)
+#define RX_STA_CNT0_PHY_ERR FIELD32(0xffff0000)
+
+/*
+ * RX_STA_CNT1: RX False CCA count & RX LONG frame count
+ */
+#define RX_STA_CNT1 0x1704
+#define RX_STA_CNT1_FALSE_CCA FIELD32(0x0000ffff)
+#define RX_STA_CNT1_PLCP_ERR FIELD32(0xffff0000)
+
+/*
+ * RX_STA_CNT2:
+ */
+#define RX_STA_CNT2 0x1708
+#define RX_STA_CNT2_RX_DUPLI_COUNT FIELD32(0x0000ffff)
+#define RX_STA_CNT2_RX_FIFO_OVERFLOW FIELD32(0xffff0000)
+
+/*
+ * TX_STA_CNT0: TX Beacon count
+ */
+#define TX_STA_CNT0 0x170c
+#define TX_STA_CNT0_TX_FAIL_COUNT FIELD32(0x0000ffff)
+#define TX_STA_CNT0_TX_BEACON_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_STA_CNT1: TX tx count
+ */
+#define TX_STA_CNT1 0x1710
+#define TX_STA_CNT1_TX_SUCCESS FIELD32(0x0000ffff)
+#define TX_STA_CNT1_TX_RETRANSMIT FIELD32(0xffff0000)
+
+/*
+ * TX_STA_CNT2: TX tx count
+ */
+#define TX_STA_CNT2 0x1714
+#define TX_STA_CNT2_TX_ZERO_LEN_COUNT FIELD32(0x0000ffff)
+#define TX_STA_CNT2_TX_UNDER_FLOW_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_STA_FIFO: TX Result for specific PID status fifo register
+ */
+#define TX_STA_FIFO 0x1718
+#define TX_STA_FIFO_VALID FIELD32(0x00000001)
+#define TX_STA_FIFO_PID_TYPE FIELD32(0x0000001e)
+#define TX_STA_FIFO_TX_SUCCESS FIELD32(0x00000020)
+#define TX_STA_FIFO_TX_AGGRE FIELD32(0x00000040)
+#define TX_STA_FIFO_TX_ACK_REQUIRED FIELD32(0x00000080)
+#define TX_STA_FIFO_WCID FIELD32(0x0000ff00)
+#define TX_STA_FIFO_SUCCESS_RATE FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT: Debug counter
+ */
+#define TX_AGG_CNT 0x171c
+#define TX_AGG_CNT_NON_AGG_TX_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT_AGG_TX_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT0:
+ */
+#define TX_AGG_CNT0 0x1720
+#define TX_AGG_CNT0_AGG_SIZE_1_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT0_AGG_SIZE_2_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT1:
+ */
+#define TX_AGG_CNT1 0x1724
+#define TX_AGG_CNT1_AGG_SIZE_3_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT1_AGG_SIZE_4_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT2:
+ */
+#define TX_AGG_CNT2 0x1728
+#define TX_AGG_CNT2_AGG_SIZE_5_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT2_AGG_SIZE_6_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT3:
+ */
+#define TX_AGG_CNT3 0x172c
+#define TX_AGG_CNT3_AGG_SIZE_7_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT3_AGG_SIZE_8_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT4:
+ */
+#define TX_AGG_CNT4 0x1730
+#define TX_AGG_CNT4_AGG_SIZE_9_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT4_AGG_SIZE_10_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT5:
+ */
+#define TX_AGG_CNT5 0x1734
+#define TX_AGG_CNT5_AGG_SIZE_11_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT5_AGG_SIZE_12_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT6:
+ */
+#define TX_AGG_CNT6 0x1738
+#define TX_AGG_CNT6_AGG_SIZE_13_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT6_AGG_SIZE_14_COUNT FIELD32(0xffff0000)
+
+/*
+ * TX_AGG_CNT7:
+ */
+#define TX_AGG_CNT7 0x173c
+#define TX_AGG_CNT7_AGG_SIZE_15_COUNT FIELD32(0x0000ffff)
+#define TX_AGG_CNT7_AGG_SIZE_16_COUNT FIELD32(0xffff0000)
+
+/*
+ * MPDU_DENSITY_CNT:
+ * TX_ZERO_DEL: TX zero length delimiter count
+ * RX_ZERO_DEL: RX zero length delimiter count
+ */
+#define MPDU_DENSITY_CNT 0x1740
+#define MPDU_DENSITY_CNT_TX_ZERO_DEL FIELD32(0x0000ffff)
+#define MPDU_DENSITY_CNT_RX_ZERO_DEL FIELD32(0xffff0000)
+
+/*
+ * Security key table memory.
+ * MAC_WCID_BASE: 8-bytes (use only 6 bytes) * 256 entry
+ * PAIRWISE_KEY_TABLE_BASE: 32-byte * 256 entry
+ * MAC_IVEIV_TABLE_BASE: 8-byte * 256-entry
+ * MAC_WCID_ATTRIBUTE_BASE: 4-byte * 256-entry
+ * SHARED_KEY_TABLE_BASE: 32-byte * 16-entry
+ * SHARED_KEY_MODE_BASE: 4-byte * 16-entry
+ */
+#define MAC_WCID_BASE 0x1800
+#define PAIRWISE_KEY_TABLE_BASE 0x4000
+#define MAC_IVEIV_TABLE_BASE 0x6000
+#define MAC_WCID_ATTRIBUTE_BASE 0x6800
+#define SHARED_KEY_TABLE_BASE 0x6c00
+#define SHARED_KEY_MODE_BASE 0x7000
+
+#define MAC_WCID_ENTRY(__idx) \
+ ( MAC_WCID_BASE + ((__idx) * sizeof(struct mac_wcid_entry)) )
+#define PAIRWISE_KEY_ENTRY(__idx) \
+ ( PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) )
+#define MAC_IVEIV_ENTRY(__idx) \
+ ( MAC_IVEIV_TABLE_BASE + ((__idx) & sizeof(struct mac_iveiv_entry)) )
+#define MAC_WCID_ATTR_ENTRY(__idx) \
+ ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) )
+#define SHARED_KEY_ENTRY(__idx) \
+ ( SHARED_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) )
+#define SHARED_KEY_MODE_ENTRY(__idx) \
+ ( SHARED_KEY_MODE_BASE + ((__idx) * sizeof(u32)) )
+
+struct mac_wcid_entry {
+ u8 mac[6];
+ u8 reserved[2];
+} __attribute__ ((packed));
+
+struct hw_key_entry {
+ u8 key[16];
+ u8 tx_mic[8];
+ u8 rx_mic[8];
+} __attribute__ ((packed));
+
+struct mac_iveiv_entry {
+ u8 iv[8];
+} __attribute__ ((packed));
+
+/*
+ * MAC_WCID_ATTRIBUTE:
+ */
+#define MAC_WCID_ATTRIBUTE_KEYTAB FIELD32(0x00000001)
+#define MAC_WCID_ATTRIBUTE_CIPHER FIELD32(0x0000000e)
+#define MAC_WCID_ATTRIBUTE_BSS_IDX FIELD32(0x00000070)
+#define MAC_WCID_ATTRIBUTE_RX_WIUDF FIELD32(0x00000380)
+
+/*
+ * SHARED_KEY_MODE:
+ */
+#define SHARED_KEY_MODE_BSS0_KEY0 FIELD32(0x00000007)
+#define SHARED_KEY_MODE_BSS0_KEY1 FIELD32(0x00000070)
+#define SHARED_KEY_MODE_BSS0_KEY2 FIELD32(0x00000700)
+#define SHARED_KEY_MODE_BSS0_KEY3 FIELD32(0x00007000)
+#define SHARED_KEY_MODE_BSS1_KEY0 FIELD32(0x00070000)
+#define SHARED_KEY_MODE_BSS1_KEY1 FIELD32(0x00700000)
+#define SHARED_KEY_MODE_BSS1_KEY2 FIELD32(0x07000000)
+#define SHARED_KEY_MODE_BSS1_KEY3 FIELD32(0x70000000)
+
+/*
+ * HOST-MCU communication
+ */
+
+/*
+ * H2M_MAILBOX_CSR: Host-to-MCU Mailbox.
+ */
+#define H2M_MAILBOX_CSR 0x7010
+#define H2M_MAILBOX_CSR_ARG0 FIELD32(0x000000ff)
+#define H2M_MAILBOX_CSR_ARG1 FIELD32(0x0000ff00)
+#define H2M_MAILBOX_CSR_CMD_TOKEN FIELD32(0x00ff0000)
+#define H2M_MAILBOX_CSR_OWNER FIELD32(0xff000000)
+
+/*
+ * H2M_MAILBOX_CID:
+ */
+#define H2M_MAILBOX_CID 0x7014
+#define H2M_MAILBOX_CID_CMD0 FIELD32(0x000000ff)
+#define H2M_MAILBOX_CID_CMD1 FIELD32(0x0000ff00)
+#define H2M_MAILBOX_CID_CMD2 FIELD32(0x00ff0000)
+#define H2M_MAILBOX_CID_CMD3 FIELD32(0xff000000)
+
+/*
+ * H2M_MAILBOX_STATUS:
+ */
+#define H2M_MAILBOX_STATUS 0x701c
+
+/*
+ * H2M_INT_SRC:
+ */
+#define H2M_INT_SRC 0x7024
+
+/*
+ * H2M_BBP_AGENT:
+ */
+#define H2M_BBP_AGENT 0x7028
+
+/*
+ * MCU_LEDCS: LED control for MCU Mailbox.
+ */
+#define MCU_LEDCS_LED_MODE FIELD8(0x1f)
+#define MCU_LEDCS_POLARITY FIELD8(0x01)
+
+/*
+ * HW_CS_CTS_BASE:
+ * Carrier-sense CTS frame base address.
+ * It's where mac stores carrier-sense frame for carrier-sense function.
+ */
+#define HW_CS_CTS_BASE 0x7700
+
+/*
+ * HW_DFS_CTS_BASE:
+ * FS CTS frame base address. It's where mac stores CTS frame for DFS.
+ */
+#define HW_DFS_CTS_BASE 0x7780
+
+/*
+ * TXRX control registers - base address 0x3000
+ */
+
+/*
+ * TXRX_CSR1:
+ * rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
+ */
+#define TXRX_CSR1 0x77d0
+
+/*
+ * HW_DEBUG_SETTING_BASE:
+ * since NULL frame won't be that long (256 byte)
+ * We steal 16 tail bytes to save debugging settings
+ */
+#define HW_DEBUG_SETTING_BASE 0x77f0
+#define HW_DEBUG_SETTING_BASE2 0x7770
+
+/*
+ * HW_BEACON_BASE
+ * In order to support maximum 8 MBSS and its maximum length
+ * is 512 bytes for each beacon
+ * Three section discontinue memory segments will be used.
+ * 1. The original region for BCN 0~3
+ * 2. Extract memory from FCE table for BCN 4~5
+ * 3. Extract memory from Pair-wise key table for BCN 6~7
+ * It occupied those memory of wcid 238~253 for BCN 6
+ * and wcid 222~237 for BCN 7
+ *
+ * IMPORTANT NOTE: Not sure why legacy driver does this,
+ * but HW_BEACON_BASE7 is 0x0200 bytes below HW_BEACON_BASE6.
+ */
+#define HW_BEACON_BASE0 0x7800
+#define HW_BEACON_BASE1 0x7a00
+#define HW_BEACON_BASE2 0x7c00
+#define HW_BEACON_BASE3 0x7e00
+#define HW_BEACON_BASE4 0x7200
+#define HW_BEACON_BASE5 0x7400
+#define HW_BEACON_BASE6 0x5dc0
+#define HW_BEACON_BASE7 0x5bc0
+
+#define HW_BEACON_OFFSET(__index) \
+ ( ((__index) < 4) ? ( HW_BEACON_BASE0 + (__index * 0x0200) ) : \
+ (((__index) < 6) ? ( HW_BEACON_BASE4 + ((__index - 4) * 0x0200) ) : \
+ (HW_BEACON_BASE6 - ((__index - 6) * 0x0200))) )
+
+/*
+ * 8051 firmware image.
+ */
+#define FIRMWARE_RT2870 "rt2870.bin"
+#define FIRMWARE_IMAGE_BASE 0x3000
+
+/*
+ * BBP registers.
+ * The wordsize of the BBP is 8 bits.
+ */
+
+/*
+ * BBP 1: TX Antenna
+ */
+#define BBP1_TX_POWER FIELD8(0x07)
+#define BBP1_TX_ANTENNA FIELD8(0x18)
+
+/*
+ * BBP 3: RX Antenna
+ */
+#define BBP3_RX_ANTENNA FIELD8(0x18)
+#define BBP3_HT40_PLUS FIELD8(0x20)
+
+/*
+ * BBP 4: Bandwidth
+ */
+#define BBP4_TX_BF FIELD8(0x01)
+#define BBP4_BANDWIDTH FIELD8(0x18)
+
+/*
+ * RFCSR registers
+ * The wordsize of the RFCSR is 8 bits.
+ */
+
+/*
+ * RFCSR 6:
+ */
+#define RFCSR6_R FIELD8(0x03)
+
+/*
+ * RFCSR 7:
+ */
+#define RFCSR7_RF_TUNING FIELD8(0x01)
+
+/*
+ * RFCSR 12:
+ */
+#define RFCSR12_TX_POWER FIELD8(0x1f)
+
+/*
+ * RFCSR 22:
+ */
+#define RFCSR22_BASEBAND_LOOPBACK FIELD8(0x01)
+
+/*
+ * RFCSR 23:
+ */
+#define RFCSR23_FREQ_OFFSET FIELD8(0x7f)
+
+/*
+ * RFCSR 30:
+ */
+#define RFCSR30_RF_CALIBRATION FIELD8(0x80)
+
+/*
+ * RF registers
+ */
+
+/*
+ * RF 2
+ */
+#define RF2_ANTENNA_RX2 FIELD32(0x00000040)
+#define RF2_ANTENNA_TX1 FIELD32(0x00004000)
+#define RF2_ANTENNA_RX1 FIELD32(0x00020000)
+
+/*
+ * RF 3
+ */
+#define RF3_TXPOWER_G FIELD32(0x00003e00)
+#define RF3_TXPOWER_A_7DBM_BOOST FIELD32(0x00000200)
+#define RF3_TXPOWER_A FIELD32(0x00003c00)
+
+/*
+ * RF 4
+ */
+#define RF4_TXPOWER_G FIELD32(0x000007c0)
+#define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
+#define RF4_TXPOWER_A FIELD32(0x00000780)
+#define RF4_FREQ_OFFSET FIELD32(0x001f8000)
+#define RF4_HT40 FIELD32(0x00200000)
+
+/*
+ * EEPROM content.
+ * The wordsize of the EEPROM is 16 bits.
+ */
+
+/*
+ * EEPROM Version
+ */
+#define EEPROM_VERSION 0x0001
+#define EEPROM_VERSION_FAE FIELD16(0x00ff)
+#define EEPROM_VERSION_VERSION FIELD16(0xff00)
+
+/*
+ * HW MAC address.
+ */
+#define EEPROM_MAC_ADDR_0 0x0002
+#define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff)
+#define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00)
+#define EEPROM_MAC_ADDR_1 0x0003
+#define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff)
+#define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00)
+#define EEPROM_MAC_ADDR_2 0x0004
+#define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff)
+#define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
+
+/*
+ * EEPROM ANTENNA config
+ * RXPATH: 1: 1R, 2: 2R, 3: 3R
+ * TXPATH: 1: 1T, 2: 2T
+ */
+#define EEPROM_ANTENNA 0x001a
+#define EEPROM_ANTENNA_RXPATH FIELD16(0x000f)
+#define EEPROM_ANTENNA_TXPATH FIELD16(0x00f0)
+#define EEPROM_ANTENNA_RF_TYPE FIELD16(0x0f00)
+
+/*
+ * EEPROM NIC config
+ * CARDBUS_ACCEL: 0 - enable, 1 - disable
+ */
+#define EEPROM_NIC 0x001b
+#define EEPROM_NIC_HW_RADIO FIELD16(0x0001)
+#define EEPROM_NIC_DYNAMIC_TX_AGC FIELD16(0x0002)
+#define EEPROM_NIC_EXTERNAL_LNA_BG FIELD16(0x0004)
+#define EEPROM_NIC_EXTERNAL_LNA_A FIELD16(0x0008)
+#define EEPROM_NIC_CARDBUS_ACCEL FIELD16(0x0010)
+#define EEPROM_NIC_BW40M_SB_BG FIELD16(0x0020)
+#define EEPROM_NIC_BW40M_SB_A FIELD16(0x0040)
+#define EEPROM_NIC_WPS_PBC FIELD16(0x0080)
+#define EEPROM_NIC_BW40M_BG FIELD16(0x0100)
+#define EEPROM_NIC_BW40M_A FIELD16(0x0200)
+
+/*
+ * EEPROM frequency
+ */
+#define EEPROM_FREQ 0x001d
+#define EEPROM_FREQ_OFFSET FIELD16(0x00ff)
+#define EEPROM_FREQ_LED_MODE FIELD16(0x7f00)
+#define EEPROM_FREQ_LED_POLARITY FIELD16(0x1000)
+
+/*
+ * EEPROM LED
+ * POLARITY_RDY_G: Polarity RDY_G setting.
+ * POLARITY_RDY_A: Polarity RDY_A setting.
+ * POLARITY_ACT: Polarity ACT setting.
+ * POLARITY_GPIO_0: Polarity GPIO0 setting.
+ * POLARITY_GPIO_1: Polarity GPIO1 setting.
+ * POLARITY_GPIO_2: Polarity GPIO2 setting.
+ * POLARITY_GPIO_3: Polarity GPIO3 setting.
+ * POLARITY_GPIO_4: Polarity GPIO4 setting.
+ * LED_MODE: Led mode.
+ */
+#define EEPROM_LED1 0x001e
+#define EEPROM_LED2 0x001f
+#define EEPROM_LED3 0x0020
+#define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001)
+#define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002)
+#define EEPROM_LED_POLARITY_ACT FIELD16(0x0004)
+#define EEPROM_LED_POLARITY_GPIO_0 FIELD16(0x0008)
+#define EEPROM_LED_POLARITY_GPIO_1 FIELD16(0x0010)
+#define EEPROM_LED_POLARITY_GPIO_2 FIELD16(0x0020)
+#define EEPROM_LED_POLARITY_GPIO_3 FIELD16(0x0040)
+#define EEPROM_LED_POLARITY_GPIO_4 FIELD16(0x0080)
+#define EEPROM_LED_LED_MODE FIELD16(0x1f00)
+
+/*
+ * EEPROM LNA
+ */
+#define EEPROM_LNA 0x0022
+#define EEPROM_LNA_BG FIELD16(0x00ff)
+#define EEPROM_LNA_A0 FIELD16(0xff00)
+
+/*
+ * EEPROM RSSI BG offset
+ */
+#define EEPROM_RSSI_BG 0x0023
+#define EEPROM_RSSI_BG_OFFSET0 FIELD16(0x00ff)
+#define EEPROM_RSSI_BG_OFFSET1 FIELD16(0xff00)
+
+/*
+ * EEPROM RSSI BG2 offset
+ */
+#define EEPROM_RSSI_BG2 0x0024
+#define EEPROM_RSSI_BG2_OFFSET2 FIELD16(0x00ff)
+#define EEPROM_RSSI_BG2_LNA_A1 FIELD16(0xff00)
+
+/*
+ * EEPROM RSSI A offset
+ */
+#define EEPROM_RSSI_A 0x0025
+#define EEPROM_RSSI_A_OFFSET0 FIELD16(0x00ff)
+#define EEPROM_RSSI_A_OFFSET1 FIELD16(0xff00)
+
+/*
+ * EEPROM RSSI A2 offset
+ */
+#define EEPROM_RSSI_A2 0x0026
+#define EEPROM_RSSI_A2_OFFSET2 FIELD16(0x00ff)
+#define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00)
+
+/*
+ * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power.
+ * This is delta in 40MHZ.
+ * VALUE: Tx Power dalta value (MAX=4)
+ * TYPE: 1: Plus the delta value, 0: minus the delta value
+ * TXPOWER: Enable:
+ */
+#define EEPROM_TXPOWER_DELTA 0x0028
+#define EEPROM_TXPOWER_DELTA_VALUE FIELD16(0x003f)
+#define EEPROM_TXPOWER_DELTA_TYPE FIELD16(0x0040)
+#define EEPROM_TXPOWER_DELTA_TXPOWER FIELD16(0x0080)
+
+/*
+ * EEPROM TXPOWER 802.11BG
+ */
+#define EEPROM_TXPOWER_BG1 0x0029
+#define EEPROM_TXPOWER_BG2 0x0030
+#define EEPROM_TXPOWER_BG_SIZE 7
+#define EEPROM_TXPOWER_BG_1 FIELD16(0x00ff)
+#define EEPROM_TXPOWER_BG_2 FIELD16(0xff00)
+
+/*
+ * EEPROM TXPOWER 802.11A
+ */
+#define EEPROM_TXPOWER_A1 0x003c
+#define EEPROM_TXPOWER_A2 0x0053
+#define EEPROM_TXPOWER_A_SIZE 6
+#define EEPROM_TXPOWER_A_1 FIELD16(0x00ff)
+#define EEPROM_TXPOWER_A_2 FIELD16(0xff00)
+
+/*
+ * EEPROM TXpower byrate: 20MHZ power
+ */
+#define EEPROM_TXPOWER_BYRATE 0x006f
+
+/*
+ * EEPROM BBP.
+ */
+#define EEPROM_BBP_START 0x0078
+#define EEPROM_BBP_SIZE 16
+#define EEPROM_BBP_VALUE FIELD16(0x00ff)
+#define EEPROM_BBP_REG_ID FIELD16(0xff00)
+
+/*
+ * MCU mailbox commands.
+ */
+#define MCU_SLEEP 0x30
+#define MCU_WAKEUP 0x31
+#define MCU_RADIO_OFF 0x35
+#define MCU_CURRENT 0x36
+#define MCU_LED 0x50
+#define MCU_LED_STRENGTH 0x51
+#define MCU_LED_1 0x52
+#define MCU_LED_2 0x53
+#define MCU_LED_3 0x54
+#define MCU_RADAR 0x60
+#define MCU_BOOT_SIGNAL 0x72
+#define MCU_BBP_SIGNAL 0x80
+#define MCU_POWER_SAVE 0x83
+
+/*
+ * MCU mailbox tokens
+ */
+#define TOKEN_WAKUP 3
+
+/*
+ * DMA descriptor defines.
+ */
+#define TXD_DESC_SIZE ( 4 * sizeof(__le32) )
+#define TXINFO_DESC_SIZE ( 1 * sizeof(__le32) )
+#define TXWI_DESC_SIZE ( 4 * sizeof(__le32) )
+#define RXD_DESC_SIZE ( 1 * sizeof(__le32) )
+#define RXWI_DESC_SIZE ( 4 * sizeof(__le32) )
+
+/*
+ * TX descriptor format for TX, PRIO and Beacon Ring.
+ */
+
+/*
+ * Word0
+ */
+#define TXD_W0_SD_PTR0 FIELD32(0xffffffff)
+
+/*
+ * Word1
+ */
+#define TXD_W1_SD_LEN1 FIELD32(0x00003fff)
+#define TXD_W1_LAST_SEC1 FIELD32(0x00004000)
+#define TXD_W1_BURST FIELD32(0x00008000)
+#define TXD_W1_SD_LEN0 FIELD32(0x3fff0000)
+#define TXD_W1_LAST_SEC0 FIELD32(0x40000000)
+#define TXD_W1_DMA_DONE FIELD32(0x80000000)
+
+/*
+ * Word2
+ */
+#define TXD_W2_SD_PTR1 FIELD32(0xffffffff)
+
+/*
+ * Word3
+ * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
+ * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
+ * 0:MGMT, 1:HCCA 2:EDCA
+ */
+#define TXD_W3_WIV FIELD32(0x01000000)
+#define TXD_W3_QSEL FIELD32(0x06000000)
+#define TXD_W3_TCO FIELD32(0x20000000)
+#define TXD_W3_UCO FIELD32(0x40000000)
+#define TXD_W3_ICO FIELD32(0x80000000)
+
+/*
+ * TX Info structure
+ */
+
+/*
+ * Word0
+ * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
+ * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
+ * 0:MGMT, 1:HCCA 2:EDCA
+ * USB_DMA_NEXT_VALID: Used ONLY in USB bulk Aggregation, NextValid
+ * DMA_TX_BURST: used ONLY in USB bulk Aggregation.
+ * Force USB DMA transmit frame from current selected endpoint
+ */
+#define TXINFO_W0_USB_DMA_TX_PKT_LEN FIELD32(0x0000ffff)
+#define TXINFO_W0_WIV FIELD32(0x01000000)
+#define TXINFO_W0_QSEL FIELD32(0x06000000)
+#define TXINFO_W0_SW_USE_LAST_ROUND FIELD32(0x08000000)
+#define TXINFO_W0_USB_DMA_NEXT_VALID FIELD32(0x40000000)
+#define TXINFO_W0_USB_DMA_TX_BURST FIELD32(0x80000000)
+
+/*
+ * TX WI structure
+ */
+
+/*
+ * Word0
+ * FRAG: 1 To inform TKIP engine this is a fragment.
+ * MIMO_PS: The remote peer is in dynamic MIMO-PS mode
+ * TX_OP: 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs
+ * BW: Channel bandwidth 20MHz or 40 MHz
+ * STBC: 1: STBC support MCS =0-7, 2,3 : RESERVED
+ */
+#define TXWI_W0_FRAG FIELD32(0x00000001)
+#define TXWI_W0_MIMO_PS FIELD32(0x00000002)
+#define TXWI_W0_CF_ACK FIELD32(0x00000004)
+#define TXWI_W0_TS FIELD32(0x00000008)
+#define TXWI_W0_AMPDU FIELD32(0x00000010)
+#define TXWI_W0_MPDU_DENSITY FIELD32(0x000000e0)
+#define TXWI_W0_TX_OP FIELD32(0x00000300)
+#define TXWI_W0_MCS FIELD32(0x007f0000)
+#define TXWI_W0_BW FIELD32(0x00800000)
+#define TXWI_W0_SHORT_GI FIELD32(0x01000000)
+#define TXWI_W0_STBC FIELD32(0x06000000)
+#define TXWI_W0_IFS FIELD32(0x08000000)
+#define TXWI_W0_PHYMODE FIELD32(0xc0000000)
+
+/*
+ * Word1
+ */
+#define TXWI_W1_ACK FIELD32(0x00000001)
+#define TXWI_W1_NSEQ FIELD32(0x00000002)
+#define TXWI_W1_BW_WIN_SIZE FIELD32(0x000000fc)
+#define TXWI_W1_WIRELESS_CLI_ID FIELD32(0x0000ff00)
+#define TXWI_W1_MPDU_TOTAL_BYTE_COUNT FIELD32(0x0fff0000)
+#define TXWI_W1_PACKETID FIELD32(0xf0000000)
+
+/*
+ * Word2
+ */
+#define TXWI_W2_IV FIELD32(0xffffffff)
+
+/*
+ * Word3
+ */
+#define TXWI_W3_EIV FIELD32(0xffffffff)
+
+/*
+ * RX descriptor format for RX Ring.
+ */
+
+/*
+ * Word0
+ * UNICAST_TO_ME: This RX frame is unicast to me.
+ * MULTICAST: This is a multicast frame.
+ * BROADCAST: This is a broadcast frame.
+ * MY_BSS: this frame belongs to the same BSSID.
+ * CRC_ERROR: CRC error.
+ * CIPHER_ERROR: 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid.
+ * AMSDU: rx with 802.3 header, not 802.11 header.
+ */
+
+#define RXD_W0_BA FIELD32(0x00000001)
+#define RXD_W0_DATA FIELD32(0x00000002)
+#define RXD_W0_NULLDATA FIELD32(0x00000004)
+#define RXD_W0_FRAG FIELD32(0x00000008)
+#define RXD_W0_UNICAST_TO_ME FIELD32(0x00000010)
+#define RXD_W0_MULTICAST FIELD32(0x00000020)
+#define RXD_W0_BROADCAST FIELD32(0x00000040)
+#define RXD_W0_MY_BSS FIELD32(0x00000080)
+#define RXD_W0_CRC_ERROR FIELD32(0x00000100)
+#define RXD_W0_CIPHER_ERROR FIELD32(0x00000600)
+#define RXD_W0_AMSDU FIELD32(0x00000800)
+#define RXD_W0_HTC FIELD32(0x00001000)
+#define RXD_W0_RSSI FIELD32(0x00002000)
+#define RXD_W0_L2PAD FIELD32(0x00004000)
+#define RXD_W0_AMPDU FIELD32(0x00008000)
+#define RXD_W0_DECRYPTED FIELD32(0x00010000)
+#define RXD_W0_PLCP_RSSI FIELD32(0x00020000)
+#define RXD_W0_CIPHER_ALG FIELD32(0x00040000)
+#define RXD_W0_LAST_AMSDU FIELD32(0x00080000)
+#define RXD_W0_PLCP_SIGNAL FIELD32(0xfff00000)
+
+/*
+ * RX WI structure
+ */
+
+/*
+ * Word0
+ */
+#define RXWI_W0_WIRELESS_CLI_ID FIELD32(0x000000ff)
+#define RXWI_W0_KEY_INDEX FIELD32(0x00000300)
+#define RXWI_W0_BSSID FIELD32(0x00001c00)
+#define RXWI_W0_UDF FIELD32(0x0000e000)
+#define RXWI_W0_MPDU_TOTAL_BYTE_COUNT FIELD32(0x0fff0000)
+#define RXWI_W0_TID FIELD32(0xf0000000)
+
+/*
+ * Word1
+ */
+#define RXWI_W1_FRAG FIELD32(0x0000000f)
+#define RXWI_W1_SEQUENCE FIELD32(0x0000fff0)
+#define RXWI_W1_MCS FIELD32(0x007f0000)
+#define RXWI_W1_BW FIELD32(0x00800000)
+#define RXWI_W1_SHORT_GI FIELD32(0x01000000)
+#define RXWI_W1_STBC FIELD32(0x06000000)
+#define RXWI_W1_PHYMODE FIELD32(0xc0000000)
+
+/*
+ * Word2
+ */
+#define RXWI_W2_RSSI0 FIELD32(0x000000ff)
+#define RXWI_W2_RSSI1 FIELD32(0x0000ff00)
+#define RXWI_W2_RSSI2 FIELD32(0x00ff0000)
+
+/*
+ * Word3
+ */
+#define RXWI_W3_SNR0 FIELD32(0x000000ff)
+#define RXWI_W3_SNR1 FIELD32(0x0000ff00)
+
+/*
+ * Macro's for converting txpower from EEPROM to mac80211 value
+ * and from mac80211 value to register value.
+ */
+#define MIN_G_TXPOWER 0
+#define MIN_A_TXPOWER -7
+#define MAX_G_TXPOWER 31
+#define MAX_A_TXPOWER 15
+#define DEFAULT_TXPOWER 5
+
+#define TXPOWER_G_FROM_DEV(__txpower) \
+ ((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
+
+#define TXPOWER_G_TO_DEV(__txpower) \
+ clamp_t(char, __txpower, MIN_G_TXPOWER, MAX_G_TXPOWER)
+
+#define TXPOWER_A_FROM_DEV(__txpower) \
+ ((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
+
+#define TXPOWER_A_TO_DEV(__txpower) \
+ clamp_t(char, __txpower, MIN_A_TXPOWER, MAX_A_TXPOWER)
+
+#endif /* RT2800USB_H */
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 84bd6f19acb0..2b64a6198698 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -103,6 +103,15 @@
#define GET_DURATION_RES(__size, __rate)(((__size) * 8 * 10) % (__rate))
/*
+ * Determine the alignment requirement,
+ * to make sure the 802.11 payload is padded to a 4-byte boundrary
+ * we must determine the address of the payload and calculate the
+ * amount of bytes needed to move the data.
+ */
+#define ALIGN_SIZE(__skb, __header) \
+ ( ((unsigned long)((__skb)->data + (__header))) & 3 )
+
+/*
* Standard timing and size defines.
* These values should follow the ieee80211 specifications.
*/
@@ -138,6 +147,7 @@ struct rt2x00_chip {
#define RT2561 0x0302
#define RT2661 0x0401
#define RT2571 0x1300
+#define RT2870 0x1600
u16 rf;
u32 rev;
@@ -357,6 +367,7 @@ static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
* for @tx_power_a, @tx_power_bg and @channels.
* @channels: Device/chipset specific channel values (See &struct rf_channel).
* @channels_info: Additional information for channels (See &struct channel_info).
+ * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap).
*/
struct hw_mode_spec {
unsigned int supported_bands;
@@ -370,6 +381,8 @@ struct hw_mode_spec {
unsigned int num_channels;
const struct rf_channel *channels;
const struct channel_info *channels_info;
+
+ struct ieee80211_sta_ht_cap ht;
};
/*
@@ -404,6 +417,8 @@ struct rt2x00lib_erp {
short pifs;
short difs;
short eifs;
+
+ u16 beacon_int;
};
/*
@@ -590,6 +605,7 @@ enum rt2x00_flags {
DRIVER_REQUIRE_SCHEDULED,
DRIVER_REQUIRE_DMA,
DRIVER_REQUIRE_COPY_IV,
+ DRIVER_REQUIRE_L2PAD,
/*
* Driver features
@@ -606,6 +622,7 @@ enum rt2x00_flags {
CONFIG_EXTERNAL_LNA_BG,
CONFIG_DOUBLE_ANTENNA,
CONFIG_DISABLE_LINK_TUNING,
+ CONFIG_CHANNEL_HT40,
};
/*
@@ -672,6 +689,12 @@ struct rt2x00_dev {
unsigned long flags;
/*
+ * Device information, Bus IRQ and name (PCI, SoC)
+ */
+ int irq;
+ const char *name;
+
+ /*
* Chipset identification.
*/
struct rt2x00_chip chip;
@@ -772,6 +795,13 @@ struct rt2x00_dev {
u8 freq_offset;
/*
+ * Calibration information (for rt2800usb & rt2800pci).
+ * [0] -> BW20
+ * [1] -> BW40
+ */
+ u8 calibration[2];
+
+ /*
* Low level statistics which will have
* to be kept up to date while device is running.
*/
@@ -860,6 +890,18 @@ static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
rt2x00dev->chip.rev = rev;
}
+static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
+ const u16 rt)
+{
+ rt2x00dev->chip.rt = rt;
+}
+
+static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
+ const u16 rf, const u32 rev)
+{
+ rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
+}
+
static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
{
return (chipset->rt == chip);
@@ -875,11 +917,10 @@ static inline u32 rt2x00_rev(const struct rt2x00_chip *chipset)
return chipset->rev;
}
-static inline u16 rt2x00_check_rev(const struct rt2x00_chip *chipset,
- const u32 rev)
+static inline bool rt2x00_check_rev(const struct rt2x00_chip *chipset,
+ const u32 mask, const u32 rev)
{
- return (((chipset->rev & 0xffff0) == rev) &&
- !!(chipset->rev & 0x0000f));
+ return ((chipset->rev & mask) == rev);
}
/**
@@ -925,9 +966,6 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
-int rt2x00mac_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf);
void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *total_flags,
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 9c2f5517af2a..c5bbf0b6e207 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -106,6 +106,7 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
}
erp.basic_rates = bss_conf->basic_rates;
+ erp.beacon_int = bss_conf->beacon_int;
rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp);
}
@@ -173,6 +174,11 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
libconf.conf = conf;
if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL) {
+ if (conf_is_ht40(conf))
+ __set_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags);
+ else
+ __clear_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags);
+
memcpy(&libconf.rf,
&rt2x00dev->spec.channels[conf->channel->hw_value],
sizeof(libconf.rf));
diff --git a/drivers/net/wireless/rt2x00/rt2x00crypto.c b/drivers/net/wireless/rt2x00/rt2x00crypto.c
index 0b41845d9543..bc4e81e21841 100644
--- a/drivers/net/wireless/rt2x00/rt2x00crypto.c
+++ b/drivers/net/wireless/rt2x00/rt2x00crypto.c
@@ -33,7 +33,7 @@ enum cipher rt2x00crypto_key_to_cipher(struct ieee80211_key_conf *key)
{
switch (key->alg) {
case ALG_WEP:
- if (key->keylen == LEN_WEP40)
+ if (key->keylen == WLAN_KEY_LEN_WEP40)
return CIPHER_WEP64;
else
return CIPHER_WEP128;
@@ -65,7 +65,8 @@ void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry,
__set_bit(ENTRY_TXD_ENCRYPT_PAIRWISE, &txdesc->flags);
txdesc->key_idx = hw_key->hw_key_idx;
- txdesc->iv_offset = ieee80211_get_hdrlen_from_skb(entry->skb);
+ txdesc->iv_offset = txdesc->header_length;
+ txdesc->iv_len = hw_key->iv_len;
if (!(hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV))
__set_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags);
@@ -103,47 +104,44 @@ unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev,
return overhead;
}
-void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, unsigned int iv_len)
+void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, struct txentry_desc *txdesc)
{
struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
- unsigned int header_length = ieee80211_get_hdrlen_from_skb(skb);
- if (unlikely(!iv_len))
+ if (unlikely(!txdesc->iv_len))
return;
/* Copy IV/EIV data */
- memcpy(skbdesc->iv, skb->data + header_length, iv_len);
+ memcpy(skbdesc->iv, skb->data + txdesc->iv_offset, txdesc->iv_len);
}
-void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, unsigned int iv_len)
+void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, struct txentry_desc *txdesc)
{
struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
- unsigned int header_length = ieee80211_get_hdrlen_from_skb(skb);
- if (unlikely(!iv_len))
+ if (unlikely(!txdesc->iv_len))
return;
/* Copy IV/EIV data */
- memcpy(skbdesc->iv, skb->data + header_length, iv_len);
+ memcpy(skbdesc->iv, skb->data + txdesc->iv_offset, txdesc->iv_len);
/* Move ieee80211 header */
- memmove(skb->data + iv_len, skb->data, header_length);
+ memmove(skb->data + txdesc->iv_len, skb->data, txdesc->iv_offset);
/* Pull buffer to correct size */
- skb_pull(skb, iv_len);
+ skb_pull(skb, txdesc->iv_len);
/* IV/EIV data has officially be stripped */
- skbdesc->flags |= FRAME_DESC_IV_STRIPPED;
+ skbdesc->flags |= SKBDESC_IV_STRIPPED;
}
-void rt2x00crypto_tx_insert_iv(struct sk_buff *skb)
+void rt2x00crypto_tx_insert_iv(struct sk_buff *skb, unsigned int header_length)
{
struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
- unsigned int header_length = ieee80211_get_hdrlen_from_skb(skb);
const unsigned int iv_len =
((!!(skbdesc->iv[0])) * 4) + ((!!(skbdesc->iv[1])) * 4);
- if (!(skbdesc->flags & FRAME_DESC_IV_STRIPPED))
+ if (!(skbdesc->flags & SKBDESC_IV_STRIPPED))
return;
skb_push(skb, iv_len);
@@ -155,14 +153,15 @@ void rt2x00crypto_tx_insert_iv(struct sk_buff *skb)
memcpy(skb->data + header_length, skbdesc->iv, iv_len);
/* IV/EIV data has returned into the frame */
- skbdesc->flags &= ~FRAME_DESC_IV_STRIPPED;
+ skbdesc->flags &= ~SKBDESC_IV_STRIPPED;
}
-void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, unsigned int align,
+void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, bool l2pad,
unsigned int header_length,
struct rxdone_entry_desc *rxdesc)
{
unsigned int payload_len = rxdesc->size - header_length;
+ unsigned int align = ALIGN_SIZE(skb, header_length);
unsigned int iv_len;
unsigned int icv_len;
unsigned int transfer = 0;
@@ -192,32 +191,48 @@ void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, unsigned int align,
}
/*
- * Make room for new data, note that we increase both
- * headsize and tailsize when required. The tailsize is
- * only needed when ICV data needs to be inserted and
- * the padding is smaller than the ICV data.
- * When alignment requirements is greater than the
- * ICV data we must trim the skb to the correct size
- * because we need to remove the extra bytes.
+ * Make room for new data. There are 2 possibilities
+ * either the alignment is already present between
+ * the 802.11 header and payload. In that case we
+ * we have to move the header less then the iv_len
+ * since we can use the already available l2pad bytes
+ * for the iv data.
+ * When the alignment must be added manually we must
+ * move the header more then iv_len since we must
+ * make room for the payload move as well.
*/
- skb_push(skb, iv_len + align);
- if (align < icv_len)
- skb_put(skb, icv_len - align);
- else if (align > icv_len)
- skb_trim(skb, rxdesc->size + iv_len + icv_len);
+ if (l2pad) {
+ skb_push(skb, iv_len - align);
+ skb_put(skb, icv_len);
- /* Move ieee80211 header */
- memmove(skb->data + transfer,
- skb->data + transfer + iv_len + align,
- header_length);
- transfer += header_length;
+ /* Move ieee80211 header */
+ memmove(skb->data + transfer,
+ skb->data + transfer + (iv_len - align),
+ header_length);
+ transfer += header_length;
+ } else {
+ skb_push(skb, iv_len + align);
+ if (align < icv_len)
+ skb_put(skb, icv_len - align);
+ else if (align > icv_len)
+ skb_trim(skb, rxdesc->size + iv_len + icv_len);
+
+ /* Move ieee80211 header */
+ memmove(skb->data + transfer,
+ skb->data + transfer + iv_len + align,
+ header_length);
+ transfer += header_length;
+ }
/* Copy IV/EIV data */
memcpy(skb->data + transfer, rxdesc->iv, iv_len);
transfer += iv_len;
- /* Move payload */
- if (align) {
+ /*
+ * Move payload for alignment purposes. Note that
+ * this is only needed when no l2 padding is present.
+ */
+ if (!l2pad) {
memmove(skb->data + transfer,
skb->data + transfer + align,
payload_len);
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index 07d378ef0b46..7b3ee8c2eaef 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -138,7 +138,7 @@ void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev,
if (cipher == CIPHER_TKIP_NO_MIC)
cipher = CIPHER_TKIP;
- if (cipher == CIPHER_NONE || cipher > CIPHER_MAX)
+ if (cipher == CIPHER_NONE || cipher >= CIPHER_MAX)
return;
/* Remove CIPHER_NONE index */
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 5752aaae906b..57813e72c808 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -227,6 +227,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
enum data_queue_qid qid = skb_get_queue_mapping(entry->skb);
+ unsigned int header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
u8 rate_idx, rate_flags;
/*
@@ -235,13 +236,19 @@ void rt2x00lib_txdone(struct queue_entry *entry,
rt2x00queue_unmap_skb(rt2x00dev, entry->skb);
/*
+ * Remove L2 padding which was added during
+ */
+ if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
+ rt2x00queue_payload_align(entry->skb, true, header_length);
+
+ /*
* If the IV/EIV data was stripped from the frame before it was
* passed to the hardware, we should now reinsert it again because
* mac80211 will expect the the same data to be present it the
* frame as it was passed to us.
*/
if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags))
- rt2x00crypto_tx_insert_iv(entry->skb);
+ rt2x00crypto_tx_insert_iv(entry->skb, header_length);
/*
* Send frame to debugfs immediately, after this call is completed
@@ -253,7 +260,8 @@ void rt2x00lib_txdone(struct queue_entry *entry,
* Update TX statistics.
*/
rt2x00dev->link.qual.tx_success +=
- test_bit(TXDONE_SUCCESS, &txdesc->flags);
+ test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
+ test_bit(TXDONE_UNKNOWN, &txdesc->flags);
rt2x00dev->link.qual.tx_failed +=
test_bit(TXDONE_FAILURE, &txdesc->flags);
@@ -271,14 +279,16 @@ void rt2x00lib_txdone(struct queue_entry *entry,
tx_info->status.rates[1].idx = -1; /* terminate */
if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
- if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
+ if (test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
+ test_bit(TXDONE_UNKNOWN, &txdesc->flags))
tx_info->flags |= IEEE80211_TX_STAT_ACK;
else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
rt2x00dev->low_level_stats.dot11ACKFailureCount++;
}
if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
- if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
+ if (test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
+ test_bit(TXDONE_UNKNOWN, &txdesc->flags))
rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
rt2x00dev->low_level_stats.dot11RTSFailureCount++;
@@ -316,19 +326,54 @@ void rt2x00lib_txdone(struct queue_entry *entry,
}
EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
+static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev,
+ struct rxdone_entry_desc *rxdesc)
+{
+ struct ieee80211_supported_band *sband;
+ const struct rt2x00_rate *rate;
+ unsigned int i;
+ int signal;
+ int type;
+
+ /*
+ * For non-HT rates the MCS value needs to contain the
+ * actually used rate modulation (CCK or OFDM).
+ */
+ if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS)
+ signal = RATE_MCS(rxdesc->rate_mode, rxdesc->signal);
+ else
+ signal = rxdesc->signal;
+
+ type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK);
+
+ sband = &rt2x00dev->bands[rt2x00dev->curr_band];
+ for (i = 0; i < sband->n_bitrates; i++) {
+ rate = rt2x00_get_rate(sband->bitrates[i].hw_value);
+
+ if (((type == RXDONE_SIGNAL_PLCP) &&
+ (rate->plcp == signal)) ||
+ ((type == RXDONE_SIGNAL_BITRATE) &&
+ (rate->bitrate == signal)) ||
+ ((type == RXDONE_SIGNAL_MCS) &&
+ (rate->mcs == signal))) {
+ return i;
+ }
+ }
+
+ WARNING(rt2x00dev, "Frame received with unrecognized signal, "
+ "signal=0x%.4x, type=%d.\n", signal, type);
+ return 0;
+}
+
void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
struct queue_entry *entry)
{
struct rxdone_entry_desc rxdesc;
struct sk_buff *skb;
struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
- struct ieee80211_supported_band *sband;
- const struct rt2x00_rate *rate;
unsigned int header_length;
- unsigned int align;
- unsigned int i;
- int idx = -1;
-
+ bool l2pad;
+ int rate_idx;
/*
* Allocate a new sk_buffer. If no new buffer available, drop the
* received frame and reuse the existing buffer.
@@ -348,12 +393,15 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
memset(&rxdesc, 0, sizeof(rxdesc));
rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc);
+ /* Trim buffer to correct size */
+ skb_trim(entry->skb, rxdesc.size);
+
/*
* The data behind the ieee80211 header must be
* aligned on a 4 byte boundary.
*/
header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
- align = ((unsigned long)(entry->skb->data + header_length)) & 3;
+ l2pad = !!(rxdesc.dev_flags & RXDONE_L2PAD);
/*
* Hardware might have stripped the IV/EIV/ICV data,
@@ -362,40 +410,24 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
* in which case we should reinsert the data into the frame.
*/
if ((rxdesc.dev_flags & RXDONE_CRYPTO_IV) &&
- (rxdesc.flags & RX_FLAG_IV_STRIPPED)) {
- rt2x00crypto_rx_insert_iv(entry->skb, align,
- header_length, &rxdesc);
- } else if (align) {
- skb_push(entry->skb, align);
- /* Move entire frame in 1 command */
- memmove(entry->skb->data, entry->skb->data + align,
- rxdesc.size);
- }
-
- /* Update data pointers, trim buffer to correct size */
- skb_trim(entry->skb, rxdesc.size);
+ (rxdesc.flags & RX_FLAG_IV_STRIPPED))
+ rt2x00crypto_rx_insert_iv(entry->skb, l2pad, header_length,
+ &rxdesc);
+ else
+ rt2x00queue_payload_align(entry->skb, l2pad, header_length);
/*
- * Update RX statistics.
+ * Check if the frame was received using HT. In that case,
+ * the rate is the MCS index and should be passed to mac80211
+ * directly. Otherwise we need to translate the signal to
+ * the correct bitrate index.
*/
- sband = &rt2x00dev->bands[rt2x00dev->curr_band];
- for (i = 0; i < sband->n_bitrates; i++) {
- rate = rt2x00_get_rate(sband->bitrates[i].hw_value);
-
- if (((rxdesc.dev_flags & RXDONE_SIGNAL_PLCP) &&
- (rate->plcp == rxdesc.signal)) ||
- ((rxdesc.dev_flags & RXDONE_SIGNAL_BITRATE) &&
- (rate->bitrate == rxdesc.signal))) {
- idx = i;
- break;
- }
- }
-
- if (idx < 0) {
- WARNING(rt2x00dev, "Frame received with unrecognized signal,"
- "signal=0x%.2x, type=%d.\n", rxdesc.signal,
- (rxdesc.dev_flags & RXDONE_SIGNAL_MASK));
- idx = 0;
+ if (rxdesc.rate_mode == RATE_MODE_CCK ||
+ rxdesc.rate_mode == RATE_MODE_OFDM) {
+ rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc);
+ } else {
+ rxdesc.flags |= RX_FLAG_HT;
+ rate_idx = rxdesc.signal;
}
/*
@@ -405,7 +437,7 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
rt2x00debug_update_crypto(rt2x00dev, &rxdesc);
rx_status->mactime = rxdesc.timestamp;
- rx_status->rate_idx = idx;
+ rx_status->rate_idx = rate_idx;
rx_status->qual = rt2x00link_calculate_signal(rt2x00dev, rxdesc.rssi);
rx_status->signal = rxdesc.rssi;
rx_status->noise = rxdesc.noise;
@@ -440,72 +472,84 @@ const struct rt2x00_rate rt2x00_supported_rates[12] = {
.bitrate = 10,
.ratemask = BIT(0),
.plcp = 0x00,
+ .mcs = RATE_MCS(RATE_MODE_CCK, 0),
},
{
.flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
.bitrate = 20,
.ratemask = BIT(1),
.plcp = 0x01,
+ .mcs = RATE_MCS(RATE_MODE_CCK, 1),
},
{
.flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
.bitrate = 55,
.ratemask = BIT(2),
.plcp = 0x02,
+ .mcs = RATE_MCS(RATE_MODE_CCK, 2),
},
{
.flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
.bitrate = 110,
.ratemask = BIT(3),
.plcp = 0x03,
+ .mcs = RATE_MCS(RATE_MODE_CCK, 3),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 60,
.ratemask = BIT(4),
.plcp = 0x0b,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 0),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 90,
.ratemask = BIT(5),
.plcp = 0x0f,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 1),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 120,
.ratemask = BIT(6),
.plcp = 0x0a,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 2),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 180,
.ratemask = BIT(7),
.plcp = 0x0e,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 3),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 240,
.ratemask = BIT(8),
.plcp = 0x09,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 4),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 360,
.ratemask = BIT(9),
.plcp = 0x0d,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 5),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 480,
.ratemask = BIT(10),
.plcp = 0x08,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 6),
},
{
.flags = DEV_RATE_OFDM,
.bitrate = 540,
.ratemask = BIT(11),
.plcp = 0x0c,
+ .mcs = RATE_MCS(RATE_MODE_OFDM, 7),
},
};
@@ -581,6 +625,8 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
rt2x00dev->bands[IEEE80211_BAND_2GHZ].bitrates = rates;
hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
&rt2x00dev->bands[IEEE80211_BAND_2GHZ];
+ memcpy(&rt2x00dev->bands[IEEE80211_BAND_2GHZ].ht_cap,
+ &spec->ht, sizeof(spec->ht));
}
/*
@@ -597,6 +643,8 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
rt2x00dev->bands[IEEE80211_BAND_5GHZ].bitrates = &rates[4];
hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&rt2x00dev->bands[IEEE80211_BAND_5GHZ];
+ memcpy(&rt2x00dev->bands[IEEE80211_BAND_5GHZ].ht_cap,
+ &spec->ht, sizeof(spec->ht));
}
return 0;
diff --git a/drivers/net/wireless/rt2x00/rt2x00ht.c b/drivers/net/wireless/rt2x00/rt2x00ht.c
new file mode 100644
index 000000000000..e3cec839e540
--- /dev/null
+++ b/drivers/net/wireless/rt2x00/rt2x00ht.c
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
+ <http://rt2x00.serialmonkey.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the
+ Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ Module: rt2x00lib
+ Abstract: rt2x00 HT specific routines.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "rt2x00.h"
+#include "rt2x00lib.h"
+
+void rt2x00ht_create_tx_descriptor(struct queue_entry *entry,
+ struct txentry_desc *txdesc,
+ const struct rt2x00_rate *hwrate)
+{
+ struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
+ struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0];
+
+ if (tx_info->control.sta)
+ txdesc->mpdu_density =
+ tx_info->control.sta->ht_cap.ampdu_density;
+ else
+ txdesc->mpdu_density = 0;
+
+ txdesc->ba_size = 7; /* FIXME: What value is needed? */
+ txdesc->stbc = 0; /* FIXME: What value is needed? */
+
+ txdesc->mcs = rt2x00_get_rate_mcs(hwrate->mcs);
+ if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
+ txdesc->mcs |= 0x08;
+
+ /*
+ * Convert flags
+ */
+ if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
+ __set_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags);
+
+ /*
+ * Determine HT Mix/Greenfield rate mode
+ */
+ if (txrate->flags & IEEE80211_TX_RC_MCS)
+ txdesc->rate_mode = RATE_MODE_HT_MIX;
+ if (txrate->flags & IEEE80211_TX_RC_GREEN_FIELD)
+ txdesc->rate_mode = RATE_MODE_HT_GREENFIELD;
+ if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+ __set_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags);
+ if (txrate->flags & IEEE80211_TX_RC_SHORT_GI)
+ __set_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags);
+}
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index a631613177d0..0bf2715fa93a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -32,8 +32,8 @@
* Interval defines
* Both the link tuner as the rfkill will be called once per second.
*/
-#define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) )
-#define RFKILL_POLL_INTERVAL ( 1000 )
+#define LINK_TUNE_INTERVAL round_jiffies_relative(HZ)
+#define RFKILL_POLL_INTERVAL 1000
/*
* rt2x00_rate: Per rate device information
@@ -48,6 +48,7 @@ struct rt2x00_rate {
unsigned short ratemask;
unsigned short plcp;
+ unsigned short mcs;
};
extern const struct rt2x00_rate rt2x00_supported_rates[12];
@@ -57,6 +58,14 @@ static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value)
return &rt2x00_supported_rates[hw_value & 0xff];
}
+#define RATE_MCS(__mode, __mcs) \
+ ( (((__mode) & 0x00ff) << 8) | ((__mcs) & 0x00ff) )
+
+static inline int rt2x00_get_rate_mcs(const u16 mcs_value)
+{
+ return (mcs_value & 0x00ff);
+}
+
/*
* Radio control handlers.
*/
@@ -113,6 +122,23 @@ void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
/**
+ * rt2x00queue_payload_align - Align 802.11 payload to 4-byte boundary
+ * @skb: The skb to align
+ * @l2pad: Should L2 padding be used
+ * @header_length: Length of 802.11 header
+ *
+ * This function prepares the @skb to be send to the device or mac80211.
+ * If @l2pad is set to true padding will occur between the 802.11 header
+ * and payload. Otherwise the padding will be done in front of the 802.11
+ * header.
+ * When @l2pad is set the function will check for the &SKBDESC_L2_PADDED
+ * flag in &skb_frame_desc. If that flag is set, the padding is removed
+ * and the flag cleared. Otherwise the padding is added and the flag is set.
+ */
+void rt2x00queue_payload_align(struct sk_buff *skb,
+ bool l2pad, unsigned int header_length);
+
+/**
* rt2x00queue_write_tx_frame - Write TX frame to hardware
* @queue: Queue over which the frame should be send
* @skb: The skb to send
@@ -235,7 +261,7 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna);
* @rt2x00dev: Pointer to &struct rt2x00_dev.
*
* Initialize work structure and all link tuning related
- * paramters. This will not start the link tuning process itself.
+ * parameters. This will not start the link tuning process itself.
*/
void rt2x00link_register(struct rt2x00_dev *rt2x00dev);
@@ -295,10 +321,12 @@ void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry,
struct txentry_desc *txdesc);
unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev,
struct sk_buff *skb);
-void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, unsigned int iv_len);
-void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, unsigned int iv_len);
-void rt2x00crypto_tx_insert_iv(struct sk_buff *skb);
-void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, unsigned int align,
+void rt2x00crypto_tx_copy_iv(struct sk_buff *skb,
+ struct txentry_desc *txdesc);
+void rt2x00crypto_tx_remove_iv(struct sk_buff *skb,
+ struct txentry_desc *txdesc);
+void rt2x00crypto_tx_insert_iv(struct sk_buff *skb, unsigned int header_length);
+void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, bool l2pad,
unsigned int header_length,
struct rxdone_entry_desc *rxdesc);
#else
@@ -319,21 +347,21 @@ static inline unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev
}
static inline void rt2x00crypto_tx_copy_iv(struct sk_buff *skb,
- unsigned int iv_len)
+ struct txentry_desc *txdesc)
{
}
static inline void rt2x00crypto_tx_remove_iv(struct sk_buff *skb,
- unsigned int iv_len)
+ struct txentry_desc *txdesc)
{
}
-static inline void rt2x00crypto_tx_insert_iv(struct sk_buff *skb)
+static inline void rt2x00crypto_tx_insert_iv(struct sk_buff *skb,
+ unsigned int header_length)
{
}
-static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb,
- unsigned int align,
+static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, bool l2pad,
unsigned int header_length,
struct rxdone_entry_desc *rxdesc)
{
@@ -341,6 +369,21 @@ static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb,
#endif /* CONFIG_RT2X00_LIB_CRYPTO */
/*
+ * HT handlers.
+ */
+#ifdef CONFIG_RT2X00_LIB_HT
+void rt2x00ht_create_tx_descriptor(struct queue_entry *entry,
+ struct txentry_desc *txdesc,
+ const struct rt2x00_rate *hwrate);
+#else
+static inline void rt2x00ht_create_tx_descriptor(struct queue_entry *entry,
+ struct txentry_desc *txdesc,
+ const struct rt2x00_rate *hwrate)
+{
+}
+#endif /* CONFIG_RT2X00_LIB_HT */
+
+/*
* RFkill handlers.
*/
#ifdef CONFIG_RT2X00_LIB_RFKILL
diff --git a/drivers/net/wireless/rt2x00/rt2x00link.c b/drivers/net/wireless/rt2x00/rt2x00link.c
index 7eb5cd7e5f32..eb9b981b9139 100644
--- a/drivers/net/wireless/rt2x00/rt2x00link.c
+++ b/drivers/net/wireless/rt2x00/rt2x00link.c
@@ -387,7 +387,7 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)
rt2x00link_antenna_reset(rt2x00dev);
}
-void rt2x00link_reset_qual(struct rt2x00_dev *rt2x00dev)
+static void rt2x00link_reset_qual(struct rt2x00_dev *rt2x00dev)
{
struct link_qual *qual = &rt2x00dev->link.qual;
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index c41a0b9e473d..c4c06b4e1f08 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -390,56 +390,6 @@ int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed)
}
EXPORT_SYMBOL_GPL(rt2x00mac_config);
-int rt2x00mac_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct rt2x00_dev *rt2x00dev = hw->priv;
- struct rt2x00_intf *intf = vif_to_intf(vif);
- int update_bssid = 0;
- int status = 0;
-
- /*
- * Mac80211 might be calling this function while we are trying
- * to remove the device or perhaps suspending it.
- */
- if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
- return 0;
-
- spin_lock(&intf->lock);
-
- /*
- * conf->bssid can be NULL if coming from the internal
- * beacon update routine.
- */
- if (conf->changed & IEEE80211_IFCC_BSSID && conf->bssid) {
- update_bssid = 1;
- memcpy(&intf->bssid, conf->bssid, ETH_ALEN);
- }
-
- spin_unlock(&intf->lock);
-
- /*
- * Call rt2x00_config_intf() outside of the spinlock context since
- * the call will sleep for USB drivers. By using the ieee80211_if_conf
- * values as arguments we make keep access to rt2x00_intf thread safe
- * even without the lock.
- */
- rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL,
- update_bssid ? conf->bssid : NULL);
-
- /*
- * Update the beacon.
- */
- if (conf->changed & (IEEE80211_IFCC_BEACON |
- IEEE80211_IFCC_BEACON_ENABLED))
- status = rt2x00queue_update_beacon(rt2x00dev, vif,
- conf->enable_beacon);
-
- return status;
-}
-EXPORT_SYMBOL_GPL(rt2x00mac_config_interface);
-
void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *total_flags,
@@ -623,6 +573,44 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
struct rt2x00_dev *rt2x00dev = hw->priv;
struct rt2x00_intf *intf = vif_to_intf(vif);
unsigned int delayed = 0;
+ int update_bssid = 0;
+
+ /*
+ * Mac80211 might be calling this function while we are trying
+ * to remove the device or perhaps suspending it.
+ */
+ if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
+ return;
+
+ spin_lock(&intf->lock);
+
+ /*
+ * conf->bssid can be NULL if coming from the internal
+ * beacon update routine.
+ */
+ if (changes & BSS_CHANGED_BSSID) {
+ update_bssid = 1;
+ memcpy(&intf->bssid, bss_conf->bssid, ETH_ALEN);
+ }
+
+ spin_unlock(&intf->lock);
+
+ /*
+ * Call rt2x00_config_intf() outside of the spinlock context since
+ * the call will sleep for USB drivers. By using the ieee80211_if_conf
+ * values as arguments we make keep access to rt2x00_intf thread safe
+ * even without the lock.
+ */
+ if (changes & BSS_CHANGED_BSSID)
+ rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL,
+ update_bssid ? bss_conf->bssid : NULL);
+
+ /*
+ * Update the beacon.
+ */
+ if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED))
+ rt2x00queue_update_beacon(rt2x00dev, vif,
+ bss_conf->enable_beacon);
/*
* When the association status has changed we must reset the link
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 9730b4f8fd26..cdd5154bd4c0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -170,7 +170,6 @@ static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev,
int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
{
- struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
struct data_queue *queue;
int status;
@@ -186,11 +185,11 @@ int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
/*
* Register interrupt handler.
*/
- status = request_irq(pci_dev->irq, rt2x00dev->ops->lib->irq_handler,
- IRQF_SHARED, pci_name(pci_dev), rt2x00dev);
+ status = request_irq(rt2x00dev->irq, rt2x00dev->ops->lib->irq_handler,
+ IRQF_SHARED, rt2x00dev->name, rt2x00dev);
if (status) {
ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
- pci_dev->irq, status);
+ rt2x00dev->irq, status);
goto exit;
}
@@ -270,6 +269,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
struct ieee80211_hw *hw;
struct rt2x00_dev *rt2x00dev;
int retval;
+ u16 chip;
retval = pci_request_regions(pci_dev, pci_name(pci_dev));
if (retval) {
@@ -307,6 +307,14 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
rt2x00dev->dev = &pci_dev->dev;
rt2x00dev->ops = ops;
rt2x00dev->hw = hw;
+ rt2x00dev->irq = pci_dev->irq;
+ rt2x00dev->name = pci_name(pci_dev);
+
+ /*
+ * Determine RT chipset by reading PCI header.
+ */
+ pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip);
+ rt2x00_set_chip_rt(rt2x00dev, chip);
retval = rt2x00pci_alloc_reg(rt2x00dev);
if (retval)
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index a5664bd8493e..44e5b3279ca7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -148,6 +148,35 @@ void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
dev_kfree_skb_any(skb);
}
+void rt2x00queue_payload_align(struct sk_buff *skb,
+ bool l2pad, unsigned int header_length)
+{
+ struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
+ unsigned int frame_length = skb->len;
+ unsigned int align = ALIGN_SIZE(skb, header_length);
+
+ if (!align)
+ return;
+
+ if (l2pad) {
+ if (skbdesc->flags & SKBDESC_L2_PADDED) {
+ /* Remove L2 padding */
+ memmove(skb->data + align, skb->data, header_length);
+ skb_pull(skb, align);
+ skbdesc->flags &= ~SKBDESC_L2_PADDED;
+ } else {
+ /* Add L2 padding */
+ skb_push(skb, align);
+ memmove(skb->data, skb->data + align, header_length);
+ skbdesc->flags |= SKBDESC_L2_PADDED;
+ }
+ } else {
+ /* Generic payload alignment to 4-byte boundary */
+ skb_push(skb, align);
+ memmove(skb->data, skb->data + align, frame_length);
+ }
+}
+
static void rt2x00queue_create_tx_descriptor_seq(struct queue_entry *entry,
struct txentry_desc *txdesc)
{
@@ -259,6 +288,12 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
txdesc->aifs = entry->queue->aifs;
/*
+ * Header and alignment information.
+ */
+ txdesc->header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
+ txdesc->l2pad = ALIGN_SIZE(entry->skb, txdesc->header_length);
+
+ /*
* Check whether this frame is to be acked.
*/
if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK))
@@ -326,6 +361,7 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
* Apply TX descriptor handling by components
*/
rt2x00crypto_create_tx_descriptor(entry, txdesc);
+ rt2x00ht_create_tx_descriptor(entry, txdesc, hwrate);
rt2x00queue_create_tx_descriptor_seq(entry, txdesc);
rt2x00queue_create_tx_descriptor_plcp(entry, txdesc, hwrate);
}
@@ -368,7 +404,6 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
struct txentry_desc txdesc;
struct skb_frame_desc *skbdesc;
- unsigned int iv_len = 0;
u8 rate_idx, rate_flags;
if (unlikely(rt2x00queue_full(queue)))
@@ -390,9 +425,6 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
entry->skb = skb;
rt2x00queue_create_tx_descriptor(entry, &txdesc);
- if (IEEE80211_SKB_CB(skb)->control.hw_key != NULL)
- iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len;
-
/*
* All information is retrieved from the skb->cb array,
* now we should claim ownership of the driver part of that
@@ -415,11 +447,15 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) &&
!test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags)) {
if (test_bit(DRIVER_REQUIRE_COPY_IV, &queue->rt2x00dev->flags))
- rt2x00crypto_tx_copy_iv(skb, iv_len);
+ rt2x00crypto_tx_copy_iv(skb, &txdesc);
else
- rt2x00crypto_tx_remove_iv(skb, iv_len);
+ rt2x00crypto_tx_remove_iv(skb, &txdesc);
}
+ if (test_bit(DRIVER_REQUIRE_L2PAD, &queue->rt2x00dev->flags))
+ rt2x00queue_payload_align(entry->skb, true,
+ txdesc.header_length);
+
/*
* It could be possible that the queue was corrupted and this
* call failed. Since we always return NETDEV_TX_OK to mac80211,
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index 97e2ab08f080..b5e06347c8a7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -35,9 +35,12 @@
* for USB devices this restriction does not apply, but the value of
* 2432 makes sense since it is big enough to contain the maximum fragment
* size according to the ieee802.11 specs.
+ * The aggregation size depends on support from the driver, but should
+ * be something around 3840 bytes.
*/
-#define DATA_FRAME_SIZE 2432
-#define MGMT_FRAME_SIZE 256
+#define DATA_FRAME_SIZE 2432
+#define MGMT_FRAME_SIZE 256
+#define AGGREGATION_SIZE 3840
/**
* DOC: Number of entries per queue
@@ -87,13 +90,16 @@ enum data_queue_qid {
*
* @SKBDESC_DMA_MAPPED_RX: &skb_dma field has been mapped for RX
* @SKBDESC_DMA_MAPPED_TX: &skb_dma field has been mapped for TX
- * @FRAME_DESC_IV_STRIPPED: Frame contained a IV/EIV provided by
+ * @SKBDESC_IV_STRIPPED: Frame contained a IV/EIV provided by
* mac80211 but was stripped for processing by the driver.
+ * @SKBDESC_L2_PADDED: Payload has been padded for 4-byte alignment,
+ * the padded bytes are located between header and payload.
*/
enum skb_frame_desc_flags {
SKBDESC_DMA_MAPPED_RX = 1 << 0,
SKBDESC_DMA_MAPPED_TX = 1 << 1,
- FRAME_DESC_IV_STRIPPED = 1 << 2,
+ SKBDESC_IV_STRIPPED = 1 << 2,
+ SKBDESC_L2_PADDED = 1 << 3
};
/**
@@ -145,16 +151,20 @@ static inline struct skb_frame_desc* get_skb_frame_desc(struct sk_buff *skb)
*
* @RXDONE_SIGNAL_PLCP: Signal field contains the plcp value.
* @RXDONE_SIGNAL_BITRATE: Signal field contains the bitrate value.
+ * @RXDONE_SIGNAL_MCS: Signal field contains the mcs value.
* @RXDONE_MY_BSS: Does this frame originate from device's BSS.
* @RXDONE_CRYPTO_IV: Driver provided IV/EIV data.
* @RXDONE_CRYPTO_ICV: Driver provided ICV data.
+ * @RXDONE_L2PAD: 802.11 payload has been padded to 4-byte boundary.
*/
enum rxdone_entry_desc_flags {
- RXDONE_SIGNAL_PLCP = 1 << 0,
- RXDONE_SIGNAL_BITRATE = 1 << 1,
- RXDONE_MY_BSS = 1 << 2,
- RXDONE_CRYPTO_IV = 1 << 3,
- RXDONE_CRYPTO_ICV = 1 << 4,
+ RXDONE_SIGNAL_PLCP = BIT(0),
+ RXDONE_SIGNAL_BITRATE = BIT(1),
+ RXDONE_SIGNAL_MCS = BIT(2),
+ RXDONE_MY_BSS = BIT(3),
+ RXDONE_CRYPTO_IV = BIT(4),
+ RXDONE_CRYPTO_ICV = BIT(5),
+ RXDONE_L2PAD = BIT(6),
};
/**
@@ -163,7 +173,7 @@ enum rxdone_entry_desc_flags {
* from &rxdone_entry_desc to a signal value type.
*/
#define RXDONE_SIGNAL_MASK \
- ( RXDONE_SIGNAL_PLCP | RXDONE_SIGNAL_BITRATE )
+ ( RXDONE_SIGNAL_PLCP | RXDONE_SIGNAL_BITRATE | RXDONE_SIGNAL_MCS )
/**
* struct rxdone_entry_desc: RX Entry descriptor
@@ -177,6 +187,7 @@ enum rxdone_entry_desc_flags {
* @size: Data size of the received frame.
* @flags: MAC80211 receive flags (See &enum mac80211_rx_flags).
* @dev_flags: Ralink receive flags (See &enum rxdone_entry_desc_flags).
+ * @rate_mode: Rate mode (See @enum rate_modulation).
* @cipher: Cipher type used during decryption.
* @cipher_status: Decryption status.
* @iv: IV/EIV data used during decryption.
@@ -190,6 +201,7 @@ struct rxdone_entry_desc {
int size;
int flags;
int dev_flags;
+ u16 rate_mode;
u8 cipher;
u8 cipher_status;
@@ -243,6 +255,9 @@ struct txdone_entry_desc {
* @ENTRY_TXD_ENCRYPT_PAIRWISE: Use pairwise key table (instead of shared).
* @ENTRY_TXD_ENCRYPT_IV: Generate IV/EIV in hardware.
* @ENTRY_TXD_ENCRYPT_MMIC: Generate MIC in hardware.
+ * @ENTRY_TXD_HT_AMPDU: This frame is part of an AMPDU.
+ * @ENTRY_TXD_HT_BW_40: Use 40MHz Bandwidth.
+ * @ENTRY_TXD_HT_SHORT_GI: Use short GI.
*/
enum txentry_desc_flags {
ENTRY_TXD_RTS_FRAME,
@@ -258,6 +273,9 @@ enum txentry_desc_flags {
ENTRY_TXD_ENCRYPT_PAIRWISE,
ENTRY_TXD_ENCRYPT_IV,
ENTRY_TXD_ENCRYPT_MMIC,
+ ENTRY_TXD_HT_AMPDU,
+ ENTRY_TXD_HT_BW_40,
+ ENTRY_TXD_HT_SHORT_GI,
};
/**
@@ -267,11 +285,17 @@ enum txentry_desc_flags {
*
* @flags: Descriptor flags (See &enum queue_entry_flags).
* @queue: Queue identification (See &enum data_queue_qid).
+ * @header_length: Length of 802.11 header.
+ * @l2pad: Amount of padding to align 802.11 payload to 4-byte boundrary.
* @length_high: PLCP length high word.
* @length_low: PLCP length low word.
* @signal: PLCP signal.
* @service: PLCP service.
+ * @msc: MCS.
+ * @stbc: STBC.
+ * @ba_size: BA size.
* @rate_mode: Rate mode (See @enum rate_modulation).
+ * @mpdu_density: MDPU density.
* @retry_limit: Max number of retries.
* @aifs: AIFS value.
* @ifs: IFS value.
@@ -280,18 +304,26 @@ enum txentry_desc_flags {
* @cipher: Cipher type used for encryption.
* @key_idx: Key index used for encryption.
* @iv_offset: Position where IV should be inserted by hardware.
+ * @iv_len: Length of IV data.
*/
struct txentry_desc {
unsigned long flags;
enum data_queue_qid queue;
+ u16 header_length;
+ u16 l2pad;
+
u16 length_high;
u16 length_low;
u16 signal;
u16 service;
+ u16 mcs;
+ u16 stbc;
+ u16 ba_size;
u16 rate_mode;
+ u16 mpdu_density;
short retry_limit;
short aifs;
@@ -302,6 +334,7 @@ struct txentry_desc {
enum cipher cipher;
u16 key_idx;
u16 iv_offset;
+ u16 iv_len;
};
/**
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 2ca8b7a9722c..a8bf5c432858 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -603,15 +603,22 @@ static void rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
+ rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg);
+ rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_ENABLE, 1);
rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
!!erp->short_preamble);
rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
rt2x00pci_register_write(rt2x00dev, TXRX_CSR5, erp->basic_rates);
+ rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
+ rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_INTERVAL,
+ erp->beacon_int * 16);
+ rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
+
rt2x00pci_register_read(rt2x00dev, MAC_CSR9, &reg);
rt2x00_set_field32(&reg, MAC_CSR9_SLOT_TIME, erp->slot_time);
rt2x00pci_register_write(rt2x00dev, MAC_CSR9, reg);
@@ -938,25 +945,6 @@ static void rt61pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
}
-static void rt61pci_config_duration(struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_conf *libconf)
-{
- u32 reg;
-
- rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
- rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
- rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
-
- rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg);
- rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_ENABLE, 1);
- rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
-
- rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
- rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_INTERVAL,
- libconf->conf->beacon_int * 16);
- rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
-}
-
static void rt61pci_config_ps(struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf)
{
@@ -1016,8 +1004,6 @@ static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
rt61pci_config_txpower(rt2x00dev, libconf->conf->power_level);
if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
rt61pci_config_retry_limit(rt2x00dev, libconf);
- if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
- rt61pci_config_duration(rt2x00dev, libconf);
if (flags & IEEE80211_CONF_CHANGE_PS)
rt61pci_config_ps(rt2x00dev, libconf);
}
@@ -2308,7 +2294,6 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
u32 reg;
u16 value;
u16 eeprom;
- u16 device;
/*
* Read EEPROM word for configuration.
@@ -2317,14 +2302,10 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
/*
* Identify RF chipset.
- * To determine the RT chip we have to read the
- * PCI header of the device.
*/
- pci_read_config_word(to_pci_dev(rt2x00dev->dev),
- PCI_CONFIG_HEADER_DEVICE, &device);
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
rt2x00pci_register_read(rt2x00dev, MAC_CSR0, &reg);
- rt2x00_set_chip(rt2x00dev, device, value, reg);
+ rt2x00_set_chip_rf(rt2x00dev, value, reg);
if (!rt2x00_rf(&rt2x00dev->chip, RF5225) &&
!rt2x00_rf(&rt2x00dev->chip, RF5325) &&
@@ -2740,7 +2721,6 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = {
.add_interface = rt2x00mac_add_interface,
.remove_interface = rt2x00mac_remove_interface,
.config = rt2x00mac_config,
- .config_interface = rt2x00mac_config_interface,
.configure_filter = rt2x00mac_configure_filter,
.set_key = rt2x00mac_set_key,
.get_stats = rt2x00mac_get_stats,
diff --git a/drivers/net/wireless/rt2x00/rt61pci.h b/drivers/net/wireless/rt2x00/rt61pci.h
index 41e8959919f6..6c71f77c8165 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.h
+++ b/drivers/net/wireless/rt2x00/rt61pci.h
@@ -63,12 +63,6 @@
*/
/*
- * PCI Configuration Header
- */
-#define PCI_CONFIG_HEADER_VENDOR 0x0000
-#define PCI_CONFIG_HEADER_DEVICE 0x0002
-
-/*
* HOST_CMD_CSR: For HOST to interrupt embedded processor
*/
#define HOST_CMD_CSR 0x0008
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 853b2b279b64..211a3d6bc054 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -566,15 +566,22 @@ static void rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
+ rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
rt2x00usb_register_read(rt2x00dev, TXRX_CSR4, &reg);
+ rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_ENABLE, 1);
rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
!!erp->short_preamble);
rt2x00usb_register_write(rt2x00dev, TXRX_CSR4, reg);
rt2x00usb_register_write(rt2x00dev, TXRX_CSR5, erp->basic_rates);
+ rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
+ rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_INTERVAL,
+ erp->beacon_int * 16);
+ rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
+
rt2x00usb_register_read(rt2x00dev, MAC_CSR9, &reg);
rt2x00_set_field32(&reg, MAC_CSR9_SLOT_TIME, erp->slot_time);
rt2x00usb_register_write(rt2x00dev, MAC_CSR9, reg);
@@ -834,25 +841,6 @@ static void rt73usb_config_retry_limit(struct rt2x00_dev *rt2x00dev,
rt2x00usb_register_write(rt2x00dev, TXRX_CSR4, reg);
}
-static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
- struct rt2x00lib_conf *libconf)
-{
- u32 reg;
-
- rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
- rt2x00_set_field32(&reg, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
- rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
-
- rt2x00usb_register_read(rt2x00dev, TXRX_CSR4, &reg);
- rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_ENABLE, 1);
- rt2x00usb_register_write(rt2x00dev, TXRX_CSR4, reg);
-
- rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
- rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_INTERVAL,
- libconf->conf->beacon_int * 16);
- rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
-}
-
static void rt73usb_config_ps(struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf)
{
@@ -906,8 +894,6 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level);
if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
rt73usb_config_retry_limit(rt2x00dev, libconf);
- if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
- rt73usb_config_duration(rt2x00dev, libconf);
if (flags & IEEE80211_CONF_CHANGE_PS)
rt73usb_config_ps(rt2x00dev, libconf);
}
@@ -1846,7 +1832,8 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
rt2x00usb_register_read(rt2x00dev, MAC_CSR0, &reg);
rt2x00_set_chip(rt2x00dev, RT2571, value, reg);
- if (!rt2x00_check_rev(&rt2x00dev->chip, 0x25730)) {
+ if (!rt2x00_check_rev(&rt2x00dev->chip, 0x000ffff0, 0x25730) ||
+ rt2x00_check_rev(&rt2x00dev->chip, 0x0000000f, 0)) {
ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
return -ENODEV;
}
@@ -2259,7 +2246,6 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
.add_interface = rt2x00mac_add_interface,
.remove_interface = rt2x00mac_remove_interface,
.config = rt2x00mac_config,
- .config_interface = rt2x00mac_config_interface,
.configure_filter = rt2x00mac_configure_filter,
.set_key = rt2x00mac_set_key,
.get_stats = rt2x00mac_get_stats,
diff --git a/drivers/net/wireless/rtl818x/Makefile b/drivers/net/wireless/rtl818x/Makefile
index c113b3e69046..37e3d4db0c40 100644
--- a/drivers/net/wireless/rtl818x/Makefile
+++ b/drivers/net/wireless/rtl818x/Makefile
@@ -1,5 +1,5 @@
rtl8180-objs := rtl8180_dev.o rtl8180_rtl8225.o rtl8180_sa2400.o rtl8180_max2820.o rtl8180_grf5101.o
-rtl8187-objs := rtl8187_dev.o rtl8187_rtl8225.o
+rtl8187-objs := rtl8187_dev.o rtl8187_rtl8225.o rtl8187_leds.o
obj-$(CONFIG_RTL8180) += rtl8180.o
obj-$(CONFIG_RTL8187) += rtl8187.o
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 387c133ec0f2..7e65d7c31802 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -702,30 +702,26 @@ static int rtl8180_config(struct ieee80211_hw *dev, u32 changed)
return 0;
}
-static int rtl8180_config_interface(struct ieee80211_hw *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct rtl8180_priv *priv = dev->priv;
- int i;
-
- for (i = 0; i < ETH_ALEN; i++)
- rtl818x_iowrite8(priv, &priv->map->BSSID[i], conf->bssid[i]);
-
- if (is_valid_ether_addr(conf->bssid))
- rtl818x_iowrite8(priv, &priv->map->MSR, RTL818X_MSR_INFRA);
- else
- rtl818x_iowrite8(priv, &priv->map->MSR, RTL818X_MSR_NO_LINK);
-
- return 0;
-}
-
static void rtl8180_bss_info_changed(struct ieee80211_hw *dev,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *info,
u32 changed)
{
struct rtl8180_priv *priv = dev->priv;
+ int i;
+
+ if (changed & BSS_CHANGED_BSSID) {
+ for (i = 0; i < ETH_ALEN; i++)
+ rtl818x_iowrite8(priv, &priv->map->BSSID[i],
+ info->bssid[i]);
+
+ if (is_valid_ether_addr(info->bssid))
+ rtl818x_iowrite8(priv, &priv->map->MSR,
+ RTL818X_MSR_INFRA);
+ else
+ rtl818x_iowrite8(priv, &priv->map->MSR,
+ RTL818X_MSR_NO_LINK);
+ }
if (changed & BSS_CHANGED_ERP_SLOT && priv->rf->conf_erp)
priv->rf->conf_erp(dev, info);
@@ -770,7 +766,6 @@ static const struct ieee80211_ops rtl8180_ops = {
.add_interface = rtl8180_add_interface,
.remove_interface = rtl8180_remove_interface,
.config = rtl8180_config,
- .config_interface = rtl8180_config_interface,
.bss_info_changed = rtl8180_bss_info_changed,
.configure_filter = rtl8180_configure_filter,
};
diff --git a/drivers/net/wireless/rtl818x/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187.h
index edeff82a4d06..c09bfefc70f3 100644
--- a/drivers/net/wireless/rtl818x/rtl8187.h
+++ b/drivers/net/wireless/rtl818x/rtl8187.h
@@ -16,6 +16,7 @@
#define RTL8187_H
#include "rtl818x.h"
+#include "rtl8187_leds.h"
#define RTL8187_EEPROM_TXPWR_BASE 0x05
#define RTL8187_EEPROM_MAC_ADDR 0x07
@@ -102,6 +103,12 @@ struct rtl8187_priv {
struct usb_anchor anchored;
struct delayed_work work;
struct ieee80211_hw *dev;
+#ifdef CONFIG_RTL8187_LEDS
+ struct rtl8187_led led_tx;
+ struct rtl8187_led led_rx;
+ struct delayed_work led_on;
+ struct delayed_work led_off;
+#endif
u16 txpwr_base;
u8 asic_rev;
u8 is_rtl8187b;
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index bac6cfba6abd..6499ccc34c94 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -29,6 +29,9 @@
#include "rtl8187.h"
#include "rtl8187_rtl8225.h"
+#ifdef CONFIG_RTL8187_LEDS
+#include "rtl8187_leds.h"
+#endif
MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>");
@@ -734,10 +737,10 @@ static const u8 rtl8187b_reg_table[][3] = {
{0x85, 0x24, 0}, {0x88, 0x54, 0}, {0x8B, 0xB8, 0}, {0x8C, 0x07, 0},
{0x8D, 0x00, 0}, {0x94, 0x1B, 0}, {0x95, 0x12, 0}, {0x96, 0x00, 0},
{0x97, 0x06, 0}, {0x9D, 0x1A, 0}, {0x9F, 0x10, 0}, {0xB4, 0x22, 0},
- {0xBE, 0x80, 0}, {0xDB, 0x00, 0}, {0xEE, 0x00, 0}, {0x91, 0x03, 0},
+ {0xBE, 0x80, 0}, {0xDB, 0x00, 0}, {0xEE, 0x00, 0}, {0x4C, 0x00, 2},
- {0x4C, 0x00, 2}, {0x9F, 0x00, 3}, {0x8C, 0x01, 0}, {0x8D, 0x10, 0},
- {0x8E, 0x08, 0}, {0x8F, 0x00, 0}
+ {0x9F, 0x00, 3}, {0x8C, 0x01, 0}, {0x8D, 0x10, 0}, {0x8E, 0x08, 0},
+ {0x8F, 0x00, 0}
};
static int rtl8187b_init_hw(struct ieee80211_hw *dev)
@@ -1087,32 +1090,6 @@ static int rtl8187_config(struct ieee80211_hw *dev, u32 changed)
return 0;
}
-static int rtl8187_config_interface(struct ieee80211_hw *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct rtl8187_priv *priv = dev->priv;
- int i;
- u8 reg;
-
- mutex_lock(&priv->conf_mutex);
- for (i = 0; i < ETH_ALEN; i++)
- rtl818x_iowrite8(priv, &priv->map->BSSID[i], conf->bssid[i]);
-
- if (is_valid_ether_addr(conf->bssid)) {
- reg = RTL818X_MSR_INFRA;
- if (priv->is_rtl8187b)
- reg |= RTL818X_MSR_ENEDCA;
- rtl818x_iowrite8(priv, &priv->map->MSR, reg);
- } else {
- reg = RTL818X_MSR_NO_LINK;
- rtl818x_iowrite8(priv, &priv->map->MSR, reg);
- }
-
- mutex_unlock(&priv->conf_mutex);
- return 0;
-}
-
/*
* With 8187B, AC_*_PARAM clashes with FEMR definition in struct rtl818x_csr for
* example. Thus we have to use raw values for AC_*_PARAM register addresses.
@@ -1190,6 +1167,27 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
u32 changed)
{
struct rtl8187_priv *priv = dev->priv;
+ int i;
+ u8 reg;
+
+ if (changed & BSS_CHANGED_BSSID) {
+ mutex_lock(&priv->conf_mutex);
+ for (i = 0; i < ETH_ALEN; i++)
+ rtl818x_iowrite8(priv, &priv->map->BSSID[i],
+ info->bssid[i]);
+
+ if (is_valid_ether_addr(info->bssid)) {
+ reg = RTL818X_MSR_INFRA;
+ if (priv->is_rtl8187b)
+ reg |= RTL818X_MSR_ENEDCA;
+ rtl818x_iowrite8(priv, &priv->map->MSR, reg);
+ } else {
+ reg = RTL818X_MSR_NO_LINK;
+ rtl818x_iowrite8(priv, &priv->map->MSR, reg);
+ }
+
+ mutex_unlock(&priv->conf_mutex);
+ }
if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_ERP_PREAMBLE))
rtl8187_conf_erp(priv, info->use_short_slot,
@@ -1271,7 +1269,6 @@ static const struct ieee80211_ops rtl8187_ops = {
.add_interface = rtl8187_add_interface,
.remove_interface = rtl8187_remove_interface,
.config = rtl8187_config,
- .config_interface = rtl8187_config_interface,
.bss_info_changed = rtl8187_bss_info_changed,
.configure_filter = rtl8187_configure_filter,
.conf_tx = rtl8187_conf_tx
@@ -1478,9 +1475,6 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
(*channel++).hw_value = txpwr >> 8;
}
- if (priv->is_rtl8187b)
- printk(KERN_WARNING "rtl8187: 8187B chip detected.\n");
-
/*
* XXX: Once this driver supports anything that requires
* beacons it must implement IEEE80211_TX_CTL_ASSIGN_SEQ.
@@ -1512,6 +1506,12 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
chip_name, priv->asic_rev, priv->rf->name);
+#ifdef CONFIG_RTL8187_LEDS
+ eeprom_93cx6_read(&eeprom, 0x3F, &reg);
+ reg &= 0xFF;
+ rtl8187_leds_init(dev, reg);
+#endif
+
return 0;
err_free_dmabuf:
@@ -1531,6 +1531,9 @@ static void __devexit rtl8187_disconnect(struct usb_interface *intf)
if (!dev)
return;
+#ifdef CONFIG_RTL8187_LEDS
+ rtl8187_leds_exit(dev);
+#endif
ieee80211_unregister_hw(dev);
priv = dev->priv;
diff --git a/drivers/net/wireless/rtl818x/rtl8187_leds.c b/drivers/net/wireless/rtl818x/rtl8187_leds.c
new file mode 100644
index 000000000000..b44253592243
--- /dev/null
+++ b/drivers/net/wireless/rtl818x/rtl8187_leds.c
@@ -0,0 +1,218 @@
+/*
+ * Linux LED driver for RTL8187
+ *
+ * Copyright 2009 Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ * Based on the LED handling in the r8187 driver, which is:
+ * Copyright (c) Realtek Semiconductor Corp. All rights reserved.
+ *
+ * Thanks to Realtek for their support!
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifdef CONFIG_RTL8187_LEDS
+
+#include <net/mac80211.h>
+#include <linux/usb.h>
+#include <linux/eeprom_93cx6.h>
+
+#include "rtl8187.h"
+#include "rtl8187_leds.h"
+
+static void led_turn_on(struct work_struct *work)
+{
+ /* As this routine does read/write operations on the hardware, it must
+ * be run from a work queue.
+ */
+ u8 reg;
+ struct rtl8187_priv *priv = container_of(work, struct rtl8187_priv,
+ led_on.work);
+ struct rtl8187_led *led = &priv->led_tx;
+
+ /* Don't change the LED, when the device is down. */
+ if (priv->mode == NL80211_IFTYPE_UNSPECIFIED)
+ return ;
+
+ /* Skip if the LED is not registered. */
+ if (!led->dev)
+ return;
+ mutex_lock(&priv->conf_mutex);
+ switch (led->ledpin) {
+ case LED_PIN_GPIO0:
+ rtl818x_iowrite8(priv, &priv->map->GPIO, 0x01);
+ rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x00);
+ break;
+ case LED_PIN_LED0:
+ reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~(1 << 4);
+ rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg);
+ break;
+ case LED_PIN_LED1:
+ reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~(1 << 5);
+ rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg);
+ break;
+ case LED_PIN_HW:
+ default:
+ break;
+ }
+ mutex_unlock(&priv->conf_mutex);
+}
+
+static void led_turn_off(struct work_struct *work)
+{
+ /* As this routine does read/write operations on the hardware, it must
+ * be run from a work queue.
+ */
+ u8 reg;
+ struct rtl8187_priv *priv = container_of(work, struct rtl8187_priv,
+ led_off.work);
+ struct rtl8187_led *led = &priv->led_tx;
+
+ /* Don't change the LED, when the device is down. */
+ if (priv->mode == NL80211_IFTYPE_UNSPECIFIED)
+ return ;
+
+ /* Skip if the LED is not registered. */
+ if (!led->dev)
+ return;
+ mutex_lock(&priv->conf_mutex);
+ switch (led->ledpin) {
+ case LED_PIN_GPIO0:
+ rtl818x_iowrite8(priv, &priv->map->GPIO, 0x01);
+ rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x01);
+ break;
+ case LED_PIN_LED0:
+ reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) | (1 << 4);
+ rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg);
+ break;
+ case LED_PIN_LED1:
+ reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) | (1 << 5);
+ rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg);
+ break;
+ case LED_PIN_HW:
+ default:
+ break;
+ }
+ mutex_unlock(&priv->conf_mutex);
+}
+
+/* Callback from the LED subsystem. */
+static void rtl8187_led_brightness_set(struct led_classdev *led_dev,
+ enum led_brightness brightness)
+{
+ struct rtl8187_led *led = container_of(led_dev, struct rtl8187_led,
+ led_dev);
+ struct ieee80211_hw *hw = led->dev;
+ struct rtl8187_priv *priv = hw->priv;
+
+ if (brightness == LED_OFF) {
+ queue_delayed_work(hw->workqueue, &priv->led_off, 0);
+ /* The LED is off for 1/20 sec so that it just blinks. */
+ queue_delayed_work(hw->workqueue, &priv->led_on, HZ / 20);
+ } else
+ queue_delayed_work(hw->workqueue, &priv->led_on, 0);
+}
+
+static int rtl8187_register_led(struct ieee80211_hw *dev,
+ struct rtl8187_led *led, const char *name,
+ const char *default_trigger, u8 ledpin)
+{
+ int err;
+ struct rtl8187_priv *priv = dev->priv;
+
+ if (led->dev)
+ return -EEXIST;
+ if (!default_trigger)
+ return -EINVAL;
+ led->dev = dev;
+ led->ledpin = ledpin;
+ strncpy(led->name, name, sizeof(led->name));
+
+ led->led_dev.name = led->name;
+ led->led_dev.default_trigger = default_trigger;
+ led->led_dev.brightness_set = rtl8187_led_brightness_set;
+
+ err = led_classdev_register(&priv->udev->dev, &led->led_dev);
+ if (err) {
+ printk(KERN_INFO "LEDs: Failed to register %s\n", name);
+ led->dev = NULL;
+ return err;
+ }
+ return 0;
+}
+
+static void rtl8187_unregister_led(struct rtl8187_led *led)
+{
+ led_classdev_unregister(&led->led_dev);
+ led->dev = NULL;
+}
+
+void rtl8187_leds_init(struct ieee80211_hw *dev, u16 custid)
+{
+ struct rtl8187_priv *priv = dev->priv;
+ char name[RTL8187_LED_MAX_NAME_LEN + 1];
+ u8 ledpin;
+ int err;
+
+ /* According to the vendor driver, the LED operation depends on the
+ * customer ID encoded in the EEPROM
+ */
+ printk(KERN_INFO "rtl8187: Customer ID is 0x%02X\n", custid);
+ switch (custid) {
+ case EEPROM_CID_RSVD0:
+ case EEPROM_CID_RSVD1:
+ case EEPROM_CID_SERCOMM_PS:
+ case EEPROM_CID_QMI:
+ case EEPROM_CID_DELL:
+ case EEPROM_CID_TOSHIBA:
+ ledpin = LED_PIN_GPIO0;
+ break;
+ case EEPROM_CID_ALPHA0:
+ ledpin = LED_PIN_LED0;
+ break;
+ case EEPROM_CID_HW:
+ ledpin = LED_PIN_HW;
+ break;
+ default:
+ ledpin = LED_PIN_GPIO0;
+ }
+
+ INIT_DELAYED_WORK(&priv->led_on, led_turn_on);
+ INIT_DELAYED_WORK(&priv->led_off, led_turn_off);
+
+ snprintf(name, sizeof(name),
+ "rtl8187-%s::tx", wiphy_name(dev->wiphy));
+ err = rtl8187_register_led(dev, &priv->led_tx, name,
+ ieee80211_get_tx_led_name(dev), ledpin);
+ if (err)
+ goto error;
+ snprintf(name, sizeof(name),
+ "rtl8187-%s::rx", wiphy_name(dev->wiphy));
+ err = rtl8187_register_led(dev, &priv->led_rx, name,
+ ieee80211_get_rx_led_name(dev), ledpin);
+ if (!err) {
+ queue_delayed_work(dev->workqueue, &priv->led_on, 0);
+ return;
+ }
+ /* registration of RX LED failed - unregister TX */
+ rtl8187_unregister_led(&priv->led_tx);
+error:
+ /* If registration of either failed, cancel delayed work */
+ cancel_delayed_work_sync(&priv->led_off);
+ cancel_delayed_work_sync(&priv->led_on);
+}
+
+void rtl8187_leds_exit(struct ieee80211_hw *dev)
+{
+ struct rtl8187_priv *priv = dev->priv;
+
+ rtl8187_unregister_led(&priv->led_tx);
+ /* turn the LED off before exiting */
+ queue_delayed_work(dev->workqueue, &priv->led_off, 0);
+ cancel_delayed_work_sync(&priv->led_off);
+ rtl8187_unregister_led(&priv->led_rx);
+}
+#endif /* def CONFIG_RTL8187_LED */
+
diff --git a/drivers/net/wireless/rtl818x/rtl8187_leds.h b/drivers/net/wireless/rtl818x/rtl8187_leds.h
new file mode 100644
index 000000000000..a0332027aead
--- /dev/null
+++ b/drivers/net/wireless/rtl818x/rtl8187_leds.h
@@ -0,0 +1,57 @@
+/*
+ * Definitions for RTL8187 leds
+ *
+ * Copyright 2009 Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ * Based on the LED handling in the r8187 driver, which is:
+ * Copyright (c) Realtek Semiconductor Corp. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef RTL8187_LED_H
+#define RTL8187_LED_H
+
+#ifdef CONFIG_RTL8187_LEDS
+
+#define RTL8187_LED_MAX_NAME_LEN 21
+
+#include <linux/leds.h>
+#include <linux/types.h>
+
+enum {
+ LED_PIN_LED0,
+ LED_PIN_LED1,
+ LED_PIN_GPIO0,
+ LED_PIN_HW
+};
+
+enum {
+ EEPROM_CID_RSVD0 = 0x00,
+ EEPROM_CID_RSVD1 = 0xFF,
+ EEPROM_CID_ALPHA0 = 0x01,
+ EEPROM_CID_SERCOMM_PS = 0x02,
+ EEPROM_CID_HW = 0x03,
+ EEPROM_CID_TOSHIBA = 0x04,
+ EEPROM_CID_QMI = 0x07,
+ EEPROM_CID_DELL = 0x08
+};
+
+struct rtl8187_led {
+ struct ieee80211_hw *dev;
+ /* The LED class device */
+ struct led_classdev led_dev;
+ /* The pin/method used to control the led */
+ u8 ledpin;
+ /* The unique name string for this LED device. */
+ char name[RTL8187_LED_MAX_NAME_LEN + 1];
+};
+
+void rtl8187_leds_init(struct ieee80211_hw *dev, u16 code);
+void rtl8187_leds_exit(struct ieee80211_hw *dev);
+
+#endif /* def CONFIG_RTL8187_LED */
+
+#endif /* RTL8187_LED_H */
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index f95204632690..b7b0c46adb46 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -2509,7 +2509,7 @@ static void strip_dev_setup(struct net_device *dev)
* netdev_priv(dev) Already holds a pointer to our struct strip
*/
- *(MetricomAddress *) & dev->broadcast = broadcast_address;
+ *(MetricomAddress *)dev->broadcast = broadcast_address;
dev->dev_addr[0] = 0;
dev->addr_len = sizeof(MetricomAddress);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index e55b33961aeb..fa2821be44c2 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -138,7 +138,7 @@ psa_read(struct net_device * dev,
/*------------------------------------------------------------------*/
/*
- * Write the Paramter Storage Area to the WaveLAN card's memory
+ * Write the Parameter Storage Area to the WaveLAN card's memory
*/
static void
psa_write(struct net_device * dev,
diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig
new file mode 100644
index 000000000000..a82c4cd436d8
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/Kconfig
@@ -0,0 +1,11 @@
+config WL12XX
+ tristate "TI wl1251/wl1271 support"
+ depends on MAC80211 && WLAN_80211 && SPI_MASTER && GENERIC_HARDIRQS && EXPERIMENTAL
+ select FW_LOADER
+ select CRC7
+ ---help---
+ This module adds support for wireless adapters based on
+ TI wl1251/wl1271 chipsets.
+
+ If you choose to build a module, it'll be called wl12xx. Say N if
+ unsure.
diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile
new file mode 100644
index 000000000000..d43de27dc54c
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/Makefile
@@ -0,0 +1,4 @@
+wl12xx-objs = main.o spi.o event.o tx.o rx.o \
+ ps.o cmd.o acx.o boot.o init.o wl1251.o \
+ debugfs.o
+obj-$(CONFIG_WL12XX) += wl12xx.o
diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c
new file mode 100644
index 000000000000..1cfd458ad5ab
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/acx.c
@@ -0,0 +1,689 @@
+#include "acx.h"
+
+#include <linux/module.h>
+#include <linux/crc7.h>
+#include <linux/spi/spi.h>
+
+#include "wl12xx.h"
+#include "wl12xx_80211.h"
+#include "reg.h"
+#include "spi.h"
+#include "ps.h"
+
+int wl12xx_acx_frame_rates(struct wl12xx *wl, u8 ctrl_rate, u8 ctrl_mod,
+ u8 mgt_rate, u8 mgt_mod)
+{
+ int ret;
+ struct acx_fw_gen_frame_rates rates;
+
+ wl12xx_debug(DEBUG_ACX, "acx frame rates");
+
+ rates.header.id = ACX_FW_GEN_FRAME_RATES;
+ rates.header.len = sizeof(struct acx_fw_gen_frame_rates) -
+ sizeof(struct acx_header);
+
+ rates.tx_ctrl_frame_rate = ctrl_rate;
+ rates.tx_ctrl_frame_mod = ctrl_mod;
+ rates.tx_mgt_frame_rate = mgt_rate;
+ rates.tx_mgt_frame_mod = mgt_mod;
+
+ ret = wl12xx_cmd_configure(wl, &rates, sizeof(rates));
+ if (ret < 0) {
+ wl12xx_error("Failed to set FW rates and modulation");
+ return ret;
+ }
+
+ return 0;
+}
+
+
+int wl12xx_acx_station_id(struct wl12xx *wl)
+{
+ int ret, i;
+ struct dot11_station_id mac;
+
+ wl12xx_debug(DEBUG_ACX, "acx dot11_station_id");
+
+ mac.header.id = DOT11_STATION_ID;
+ mac.header.len = sizeof(mac) - sizeof(struct acx_header);
+
+ for (i = 0; i < ETH_ALEN; i++)
+ mac.mac[i] = wl->mac_addr[ETH_ALEN - 1 - i];
+
+ ret = wl12xx_cmd_configure(wl, &mac, sizeof(mac));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_acx_default_key(struct wl12xx *wl, u8 key_id)
+{
+ struct acx_dot11_default_key default_key;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id);
+
+ default_key.header.id = DOT11_DEFAULT_KEY;
+ default_key.header.len = sizeof(default_key) -
+ sizeof(struct acx_header);
+
+ default_key.id = key_id;
+
+ ret = wl12xx_cmd_configure(wl, &default_key, sizeof(default_key));
+ if (ret < 0) {
+ wl12xx_error("Couldnt set default key");
+ return ret;
+ }
+
+ wl->default_key = key_id;
+
+ return 0;
+}
+
+int wl12xx_acx_wake_up_conditions(struct wl12xx *wl, u8 listen_interval)
+{
+ struct acx_wake_up_condition wake_up;
+
+ wl12xx_debug(DEBUG_ACX, "acx wake up conditions");
+
+ wake_up.header.id = ACX_WAKE_UP_CONDITIONS;
+ wake_up.header.len = sizeof(wake_up) - sizeof(struct acx_header);
+
+ wake_up.wake_up_event = WAKE_UP_EVENT_DTIM_BITMAP;
+ wake_up.listen_interval = listen_interval;
+
+ return wl12xx_cmd_configure(wl, &wake_up, sizeof(wake_up));
+}
+
+int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth)
+{
+ int ret;
+ struct acx_sleep_auth auth;
+
+ wl12xx_debug(DEBUG_ACX, "acx sleep auth");
+
+ auth.header.id = ACX_SLEEP_AUTH;
+ auth.header.len = sizeof(auth) - sizeof(struct acx_header);
+
+ auth.sleep_auth = sleep_auth;
+
+ ret = wl12xx_cmd_configure(wl, &auth, sizeof(auth));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len)
+{
+ struct wl12xx_command cmd;
+ struct acx_revision *rev;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx fw rev");
+
+ memset(&cmd, 0, sizeof(cmd));
+
+ ret = wl12xx_cmd_interrogate(wl, ACX_FW_REV, sizeof(*rev), &cmd);
+ if (ret < 0) {
+ wl12xx_warning("ACX_FW_REV interrogate failed");
+ return ret;
+ }
+
+ rev = (struct acx_revision *) &cmd.parameters;
+
+ /* be careful with the buffer sizes */
+ strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
+
+ /*
+ * if the firmware version string is exactly
+ * sizeof(rev->fw_version) long or fw_len is less than
+ * sizeof(rev->fw_version) it won't be null terminated
+ */
+ buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
+
+ return 0;
+}
+
+int wl12xx_acx_tx_power(struct wl12xx *wl, int power)
+{
+ struct acx_current_tx_power ie;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
+
+ if (power < 0 || power > 25)
+ return -EINVAL;
+
+ memset(&ie, 0, sizeof(ie));
+
+ ie.header.id = DOT11_CUR_TX_PWR;
+ ie.header.len = sizeof(ie) - sizeof(struct acx_header);
+ ie.current_tx_power = power * 10;
+
+ ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie));
+ if (ret < 0) {
+ wl12xx_warning("configure of tx power failed: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_feature_cfg(struct wl12xx *wl)
+{
+ struct acx_feature_config feature;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx feature cfg");
+
+ memset(&feature, 0, sizeof(feature));
+
+ feature.header.id = ACX_FEATURE_CFG;
+ feature.header.len = sizeof(feature) - sizeof(struct acx_header);
+
+ /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
+ feature.data_flow_options = 0;
+ feature.options = 0;
+
+ ret = wl12xx_cmd_configure(wl, &feature, sizeof(feature));
+ if (ret < 0)
+ wl12xx_error("Couldnt set HW encryption");
+
+ return ret;
+}
+
+int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len)
+{
+ struct wl12xx_command cmd;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx mem map");
+
+ ret = wl12xx_cmd_interrogate(wl, ACX_MEM_MAP, len, &cmd);
+ if (ret < 0)
+ return ret;
+ else if (cmd.status != CMD_STATUS_SUCCESS)
+ return -EIO;
+
+ memcpy(mem_map, &cmd.parameters, len);
+
+ return 0;
+}
+
+int wl12xx_acx_data_path_params(struct wl12xx *wl,
+ struct acx_data_path_params_resp *data_path)
+{
+ struct acx_data_path_params params;
+ struct wl12xx_command cmd;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx data path params");
+
+ params.rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE;
+ params.tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE;
+
+ params.rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM;
+ params.tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM;
+
+ params.tx_complete_threshold = 1;
+
+ params.tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE;
+
+ params.tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT;
+
+ params.header.id = ACX_DATA_PATH_PARAMS;
+ params.header.len = sizeof(params) - sizeof(struct acx_header);
+
+ ret = wl12xx_cmd_configure(wl, &params, sizeof(params));
+ if (ret < 0)
+ return ret;
+
+
+ ret = wl12xx_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS,
+ sizeof(struct acx_data_path_params_resp),
+ &cmd);
+
+ if (ret < 0) {
+ wl12xx_warning("failed to read data path parameters: %d", ret);
+ return ret;
+ } else if (cmd.status != CMD_STATUS_SUCCESS) {
+ wl12xx_warning("data path parameter acx status failed");
+ return -EIO;
+ }
+
+ memcpy(data_path, &cmd.parameters, sizeof(*data_path));
+
+ return 0;
+}
+
+int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time)
+{
+ struct rx_msdu_lifetime msdu_lifetime;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx rx msdu life time");
+
+ msdu_lifetime.header.id = DOT11_RX_MSDU_LIFE_TIME;
+ msdu_lifetime.header.len = sizeof(msdu_lifetime) -
+ sizeof(struct acx_header);
+ msdu_lifetime.lifetime = life_time;
+
+ ret = wl12xx_cmd_configure(wl, &msdu_lifetime, sizeof(msdu_lifetime));
+ if (ret < 0) {
+ wl12xx_warning("failed to set rx msdu life time: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_rx_config(struct wl12xx *wl, u32 config, u32 filter)
+{
+ struct acx_rx_config rx_config;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx rx config");
+
+ rx_config.header.id = ACX_RX_CFG;
+ rx_config.header.len = sizeof(rx_config) - sizeof(struct acx_header);
+ rx_config.config_options = config;
+ rx_config.filter_options = filter;
+
+ ret = wl12xx_cmd_configure(wl, &rx_config, sizeof(rx_config));
+ if (ret < 0) {
+ wl12xx_warning("failed to set rx config: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_pd_threshold(struct wl12xx *wl)
+{
+ struct acx_packet_detection packet_detection;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx data pd threshold");
+
+ /* FIXME: threshold value not set */
+ packet_detection.header.id = ACX_PD_THRESHOLD;
+ packet_detection.header.len = sizeof(packet_detection) -
+ sizeof(struct acx_header);
+
+ ret = wl12xx_cmd_configure(wl, &packet_detection,
+ sizeof(packet_detection));
+ if (ret < 0) {
+ wl12xx_warning("failed to set pd threshold: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_slot(struct wl12xx *wl, enum acx_slot_type slot_time)
+{
+ struct acx_slot slot;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx slot");
+
+ slot.header.id = ACX_SLOT;
+ slot.header.len = sizeof(slot) - sizeof(struct acx_header);
+
+ slot.wone_index = STATION_WONE_INDEX;
+ slot.slot_time = slot_time;
+
+ ret = wl12xx_cmd_configure(wl, &slot, sizeof(slot));
+ if (ret < 0) {
+ wl12xx_warning("failed to set slot time: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_group_address_tbl(struct wl12xx *wl)
+{
+ struct multicast_grp_addr_start multicast;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx group address tbl");
+
+ /* MAC filtering */
+ multicast.header.id = DOT11_GROUP_ADDRESS_TBL;
+ multicast.header.len = sizeof(multicast) - sizeof(struct acx_header);
+
+ multicast.enabled = 0;
+ multicast.num_groups = 0;
+ memset(multicast.mac_table, 0, ADDRESS_GROUP_MAX_LEN);
+
+ ret = wl12xx_cmd_configure(wl, &multicast, sizeof(multicast));
+ if (ret < 0) {
+ wl12xx_warning("failed to set group addr table: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_service_period_timeout(struct wl12xx *wl)
+{
+ struct acx_rx_timeout rx_timeout;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx service period timeout");
+
+ /* RX timeout */
+ rx_timeout.header.id = ACX_SERVICE_PERIOD_TIMEOUT;
+ rx_timeout.header.len = sizeof(rx_timeout) - sizeof(struct acx_header);
+
+ rx_timeout.ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF;
+ rx_timeout.upsd_timeout = RX_TIMEOUT_UPSD_DEF;
+
+ ret = wl12xx_cmd_configure(wl, &rx_timeout, sizeof(rx_timeout));
+ if (ret < 0) {
+ wl12xx_warning("failed to set service period timeout: %d",
+ ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_rts_threshold(struct wl12xx *wl, u16 rts_threshold)
+{
+ struct acx_rts_threshold rts;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx rts threshold");
+
+ rts.header.id = DOT11_RTS_THRESHOLD;
+ rts.header.len = sizeof(rts) - sizeof(struct acx_header);
+
+ rts.threshold = rts_threshold;
+
+ ret = wl12xx_cmd_configure(wl, &rts, sizeof(rts));
+ if (ret < 0) {
+ wl12xx_warning("failed to set rts threshold: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_beacon_filter_opt(struct wl12xx *wl)
+{
+ struct acx_beacon_filter_option beacon_filter;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx beacon filter opt");
+
+ beacon_filter.header.id = ACX_BEACON_FILTER_OPT;
+ beacon_filter.header.len = sizeof(beacon_filter) -
+ sizeof(struct acx_header);
+
+ beacon_filter.enable = 0;
+ beacon_filter.max_num_beacons = 0;
+
+ ret = wl12xx_cmd_configure(wl, &beacon_filter, sizeof(beacon_filter));
+ if (ret < 0) {
+ wl12xx_warning("failed to set beacon filter opt: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_beacon_filter_table(struct wl12xx *wl)
+{
+ struct acx_beacon_filter_ie_table ie_table;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx beacon filter table");
+
+ ie_table.header.id = ACX_BEACON_FILTER_TABLE;
+ ie_table.header.len = sizeof(ie_table) - sizeof(struct acx_header);
+
+ ie_table.num_ie = 0;
+ memset(ie_table.table, 0, BEACON_FILTER_TABLE_MAX_SIZE);
+
+ ret = wl12xx_cmd_configure(wl, &ie_table, sizeof(ie_table));
+ if (ret < 0) {
+ wl12xx_warning("failed to set beacon filter table: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_sg_enable(struct wl12xx *wl)
+{
+ struct acx_bt_wlan_coex pta;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx sg enable");
+
+ pta.header.id = ACX_SG_ENABLE;
+ pta.header.len = sizeof(pta) - sizeof(struct acx_header);
+
+ pta.enable = SG_ENABLE;
+
+ ret = wl12xx_cmd_configure(wl, &pta, sizeof(pta));
+ if (ret < 0) {
+ wl12xx_warning("failed to set softgemini enable: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_sg_cfg(struct wl12xx *wl)
+{
+ struct acx_bt_wlan_coex_param param;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx sg cfg");
+
+ /* BT-WLAN coext parameters */
+ param.header.id = ACX_SG_CFG;
+ param.header.len = sizeof(param) - sizeof(struct acx_header);
+
+ param.min_rate = RATE_INDEX_24MBPS;
+ param.bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
+ param.wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
+ param.sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
+ param.rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
+ param.tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
+ param.rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
+ param.tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
+ param.wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
+ param.bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
+ param.next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
+ param.wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
+ param.hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
+ param.next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
+ param.antenna_type = PTA_ANTENNA_TYPE_DEF;
+ param.signal_type = PTA_SIGNALING_TYPE_DEF;
+ param.afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
+ param.quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
+ param.max_cts = PTA_MAX_NUM_CTS_DEF;
+ param.wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
+ param.bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
+ param.missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
+ param.wlan_elp_hp = PTA_ELP_HP_DEF;
+ param.bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
+ param.ack_mode_dual_ant = PTA_ACK_MODE_DEF;
+ param.pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
+ param.pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
+ param.bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
+
+ ret = wl12xx_cmd_configure(wl, &param, sizeof(param));
+ if (ret < 0) {
+ wl12xx_warning("failed to set sg config: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_cca_threshold(struct wl12xx *wl)
+{
+ struct acx_energy_detection detection;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx cca threshold");
+
+ detection.header.id = ACX_CCA_THRESHOLD;
+ detection.header.len = sizeof(detection) - sizeof(struct acx_header);
+
+ detection.rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
+ detection.tx_energy_detection = 0;
+
+ ret = wl12xx_cmd_configure(wl, &detection, sizeof(detection));
+ if (ret < 0) {
+ wl12xx_warning("failed to set cca threshold: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_bcn_dtim_options(struct wl12xx *wl)
+{
+ struct acx_beacon_broadcast bb;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx bcn dtim options");
+
+ bb.header.id = ACX_BCN_DTIM_OPTIONS;
+ bb.header.len = sizeof(bb) - sizeof(struct acx_header);
+
+ bb.beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
+ bb.broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
+ bb.rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
+ bb.ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
+
+ ret = wl12xx_cmd_configure(wl, &bb, sizeof(bb));
+ if (ret < 0) {
+ wl12xx_warning("failed to set rx config: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_aid(struct wl12xx *wl, u16 aid)
+{
+ struct acx_aid acx_aid;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx aid");
+
+ acx_aid.header.id = ACX_AID;
+ acx_aid.header.len = sizeof(acx_aid) - sizeof(struct acx_header);
+
+ acx_aid.aid = aid;
+
+ ret = wl12xx_cmd_configure(wl, &acx_aid, sizeof(acx_aid));
+ if (ret < 0) {
+ wl12xx_warning("failed to set aid: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_event_mbox_mask(struct wl12xx *wl, u32 event_mask)
+{
+ struct acx_event_mask mask;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx event mbox mask");
+
+ mask.header.id = ACX_EVENT_MBOX_MASK;
+ mask.header.len = sizeof(mask) - sizeof(struct acx_header);
+
+ /* high event mask is unused */
+ mask.high_event_mask = 0xffffffff;
+
+ mask.event_mask = event_mask;
+
+ ret = wl12xx_cmd_configure(wl, &mask, sizeof(mask));
+ if (ret < 0) {
+ wl12xx_warning("failed to set aid: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble)
+{
+ struct acx_preamble ie;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx_set_preamble");
+
+ memset(&ie, 0, sizeof(ie));
+
+ ie.header.id = ACX_PREAMBLE_TYPE;
+ ie.header.len = sizeof(ie) - sizeof(struct acx_header);
+ ie.preamble = preamble;
+ ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie));
+ if (ret < 0) {
+ wl12xx_warning("Setting of preamble failed: %d", ret);
+ return ret;
+ }
+ return 0;
+}
+
+int wl12xx_acx_cts_protect(struct wl12xx *wl,
+ enum acx_ctsprotect_type ctsprotect)
+{
+ struct acx_ctsprotect ie;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx_set_ctsprotect");
+
+ memset(&ie, 0, sizeof(ie));
+
+ ie.header.id = ACX_CTS_PROTECTION;
+ ie.header.len = sizeof(ie) - sizeof(struct acx_header);
+ ie.ctsprotect = ctsprotect;
+ ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie));
+ if (ret < 0) {
+ wl12xx_warning("Setting of ctsprotect failed: %d", ret);
+ return ret;
+ }
+ return 0;
+}
+
+int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats)
+{
+ struct wl12xx_command *answer;
+ int ret;
+
+ wl12xx_debug(DEBUG_ACX, "acx statistics");
+
+ answer = kmalloc(sizeof(*answer), GFP_KERNEL);
+ if (!answer) {
+ wl12xx_warning("could not allocate memory for acx statistics");
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ret = wl12xx_cmd_interrogate(wl, ACX_STATISTICS, sizeof(*answer),
+ answer);
+ if (ret < 0) {
+ wl12xx_warning("acx statistics failed: %d", ret);
+ goto out;
+ }
+
+ memcpy(stats, answer->parameters, sizeof(*stats));
+
+out:
+ kfree(answer);
+ return ret;
+}
diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h
new file mode 100644
index 000000000000..fb2d2340993c
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/acx.h
@@ -0,0 +1,1245 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_ACX_H__
+#define __WL12XX_ACX_H__
+
+#include "wl12xx.h"
+
+/* Target's information element */
+struct acx_header {
+ u16 id;
+ u16 len;
+};
+
+struct acx_error_counter {
+ struct acx_header header;
+
+ /* The number of PLCP errors since the last time this */
+ /* information element was interrogated. This field is */
+ /* automatically cleared when it is interrogated.*/
+ u32 PLCP_error;
+
+ /* The number of FCS errors since the last time this */
+ /* information element was interrogated. This field is */
+ /* automatically cleared when it is interrogated.*/
+ u32 FCS_error;
+
+ /* The number of MPDUs without PLCP header errors received*/
+ /* since the last time this information element was interrogated. */
+ /* This field is automatically cleared when it is interrogated.*/
+ u32 valid_frame;
+
+ /* the number of missed sequence numbers in the squentially */
+ /* values of frames seq numbers */
+ u32 seq_num_miss;
+} __attribute__ ((packed));
+
+struct acx_revision {
+ struct acx_header header;
+
+ /*
+ * The WiLink firmware version, an ASCII string x.x.x.x,
+ * that uniquely identifies the current firmware.
+ * The left most digit is incremented each time a
+ * significant change is made to the firmware, such as
+ * code redesign or new platform support.
+ * The second digit is incremented when major enhancements
+ * are added or major fixes are made.
+ * The third digit is incremented for each GA release.
+ * The fourth digit is incremented for each build.
+ * The first two digits identify a firmware release version,
+ * in other words, a unique set of features.
+ * The first three digits identify a GA release.
+ */
+ char fw_version[20];
+
+ /*
+ * This 4 byte field specifies the WiLink hardware version.
+ * bits 0 - 15: Reserved.
+ * bits 16 - 23: Version ID - The WiLink version ID
+ * (1 = first spin, 2 = second spin, and so on).
+ * bits 24 - 31: Chip ID - The WiLink chip ID.
+ */
+ u32 hw_version;
+} __attribute__ ((packed));
+
+enum wl12xx_psm_mode {
+ /* Active mode */
+ WL12XX_PSM_CAM = 0,
+
+ /* Power save mode */
+ WL12XX_PSM_PS = 1,
+
+ /* Extreme low power */
+ WL12XX_PSM_ELP = 2,
+};
+
+struct acx_sleep_auth {
+ struct acx_header header;
+
+ /* The sleep level authorization of the device. */
+ /* 0 - Always active*/
+ /* 1 - Power down mode: light / fast sleep*/
+ /* 2 - ELP mode: Deep / Max sleep*/
+ u8 sleep_auth;
+ u8 padding[3];
+} __attribute__ ((packed));
+
+#define TIM_ELE_ID 5
+#define PARTIAL_VBM_MAX 251
+
+struct tim {
+ u8 identity;
+ u8 length;
+ u8 dtim_count;
+ u8 dtim_period;
+ u8 bitmap_ctrl;
+ u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
+} __attribute__ ((packed));
+
+/* Virtual Bit Map update */
+struct vbm_update_request {
+ __le16 len;
+ u8 padding[2];
+ struct tim tim;
+} __attribute__ ((packed));
+
+enum {
+ HOSTIF_PCI_MASTER_HOST_INDIRECT,
+ HOSTIF_PCI_MASTER_HOST_DIRECT,
+ HOSTIF_SLAVE,
+ HOSTIF_PKT_RING,
+ HOSTIF_DONTCARE = 0xFF
+};
+
+#define DEFAULT_UCAST_PRIORITY 0
+#define DEFAULT_RX_Q_PRIORITY 0
+#define DEFAULT_NUM_STATIONS 1
+#define DEFAULT_RXQ_PRIORITY 0 /* low 0 .. 15 high */
+#define DEFAULT_RXQ_TYPE 0x07 /* All frames, Data/Ctrl/Mgmt */
+#define TRACE_BUFFER_MAX_SIZE 256
+
+#define DP_RX_PACKET_RING_CHUNK_SIZE 1600
+#define DP_TX_PACKET_RING_CHUNK_SIZE 1600
+#define DP_RX_PACKET_RING_CHUNK_NUM 2
+#define DP_TX_PACKET_RING_CHUNK_NUM 2
+#define DP_TX_COMPLETE_TIME_OUT 20
+#define FW_TX_CMPLT_BLOCK_SIZE 16
+
+struct acx_data_path_params {
+ struct acx_header header;
+
+ u16 rx_packet_ring_chunk_size;
+ u16 tx_packet_ring_chunk_size;
+
+ u8 rx_packet_ring_chunk_num;
+ u8 tx_packet_ring_chunk_num;
+
+ /*
+ * Maximum number of packets that can be gathered
+ * in the TX complete ring before an interrupt
+ * is generated.
+ */
+ u8 tx_complete_threshold;
+
+ /* Number of pending TX complete entries in cyclic ring.*/
+ u8 tx_complete_ring_depth;
+
+ /*
+ * Max num microseconds since a packet enters the TX
+ * complete ring until an interrupt is generated.
+ */
+ u32 tx_complete_timeout;
+} __attribute__ ((packed));
+
+
+struct acx_data_path_params_resp {
+ struct acx_header header;
+
+ u16 rx_packet_ring_chunk_size;
+ u16 tx_packet_ring_chunk_size;
+
+ u8 rx_packet_ring_chunk_num;
+ u8 tx_packet_ring_chunk_num;
+
+ u8 pad[2];
+
+ u32 rx_packet_ring_addr;
+ u32 tx_packet_ring_addr;
+
+ u32 rx_control_addr;
+ u32 tx_control_addr;
+
+ u32 tx_complete_addr;
+} __attribute__ ((packed));
+
+#define TX_MSDU_LIFETIME_MIN 0
+#define TX_MSDU_LIFETIME_MAX 3000
+#define TX_MSDU_LIFETIME_DEF 512
+#define RX_MSDU_LIFETIME_MIN 0
+#define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF
+#define RX_MSDU_LIFETIME_DEF 512000
+
+struct rx_msdu_lifetime {
+ struct acx_header header;
+
+ /*
+ * The maximum amount of time, in TU, before the
+ * firmware discards the MSDU.
+ */
+ u32 lifetime;
+} __attribute__ ((packed));
+
+/*
+ * RX Config Options Table
+ * Bit Definition
+ * === ==========
+ * 31:14 Reserved
+ * 13 Copy RX Status - when set, write three receive status words
+ * to top of rx'd MPDUs.
+ * When cleared, do not write three status words (added rev 1.5)
+ * 12 Reserved
+ * 11 RX Complete upon FCS error - when set, give rx complete
+ * interrupt for FCS errors, after the rx filtering, e.g. unicast
+ * frames not to us with FCS error will not generate an interrupt.
+ * 10 SSID Filter Enable - When set, the WiLink discards all beacon,
+ * probe request, and probe response frames with an SSID that does
+ * not match the SSID specified by the host in the START/JOIN
+ * command.
+ * When clear, the WiLink receives frames with any SSID.
+ * 9 Broadcast Filter Enable - When set, the WiLink discards all
+ * broadcast frames. When clear, the WiLink receives all received
+ * broadcast frames.
+ * 8:6 Reserved
+ * 5 BSSID Filter Enable - When set, the WiLink discards any frames
+ * with a BSSID that does not match the BSSID specified by the
+ * host.
+ * When clear, the WiLink receives frames from any BSSID.
+ * 4 MAC Addr Filter - When set, the WiLink discards any frames
+ * with a destination address that does not match the MAC address
+ * of the adaptor.
+ * When clear, the WiLink receives frames destined to any MAC
+ * address.
+ * 3 Promiscuous - When set, the WiLink receives all valid frames
+ * (i.e., all frames that pass the FCS check).
+ * When clear, only frames that pass the other filters specified
+ * are received.
+ * 2 FCS - When set, the WiLink includes the FCS with the received
+ * frame.
+ * When cleared, the FCS is discarded.
+ * 1 PLCP header - When set, write all data from baseband to frame
+ * buffer including PHY header.
+ * 0 Reserved - Always equal to 0.
+ *
+ * RX Filter Options Table
+ * Bit Definition
+ * === ==========
+ * 31:12 Reserved - Always equal to 0.
+ * 11 Association - When set, the WiLink receives all association
+ * related frames (association request/response, reassocation
+ * request/response, and disassociation). When clear, these frames
+ * are discarded.
+ * 10 Auth/De auth - When set, the WiLink receives all authentication
+ * and de-authentication frames. When clear, these frames are
+ * discarded.
+ * 9 Beacon - When set, the WiLink receives all beacon frames.
+ * When clear, these frames are discarded.
+ * 8 Contention Free - When set, the WiLink receives all contention
+ * free frames.
+ * When clear, these frames are discarded.
+ * 7 Control - When set, the WiLink receives all control frames.
+ * When clear, these frames are discarded.
+ * 6 Data - When set, the WiLink receives all data frames.
+ * When clear, these frames are discarded.
+ * 5 FCS Error - When set, the WiLink receives frames that have FCS
+ * errors.
+ * When clear, these frames are discarded.
+ * 4 Management - When set, the WiLink receives all management
+ * frames.
+ * When clear, these frames are discarded.
+ * 3 Probe Request - When set, the WiLink receives all probe request
+ * frames.
+ * When clear, these frames are discarded.
+ * 2 Probe Response - When set, the WiLink receives all probe
+ * response frames.
+ * When clear, these frames are discarded.
+ * 1 RTS/CTS/ACK - When set, the WiLink receives all RTS, CTS and ACK
+ * frames.
+ * When clear, these frames are discarded.
+ * 0 Rsvd Type/Sub Type - When set, the WiLink receives all frames
+ * that have reserved frame types and sub types as defined by the
+ * 802.11 specification.
+ * When clear, these frames are discarded.
+ */
+struct acx_rx_config {
+ struct acx_header header;
+
+ u32 config_options;
+ u32 filter_options;
+} __attribute__ ((packed));
+
+enum {
+ QOS_AC_BE = 0,
+ QOS_AC_BK,
+ QOS_AC_VI,
+ QOS_AC_VO,
+ QOS_HIGHEST_AC_INDEX = QOS_AC_VO,
+};
+
+#define MAX_NUM_OF_AC (QOS_HIGHEST_AC_INDEX+1)
+#define FIRST_AC_INDEX QOS_AC_BE
+#define MAX_NUM_OF_802_1d_TAGS 8
+#define AC_PARAMS_MAX_TSID 15
+#define MAX_APSD_CONF 0xffff
+
+#define QOS_TX_HIGH_MIN (0)
+#define QOS_TX_HIGH_MAX (100)
+
+#define QOS_TX_HIGH_BK_DEF (25)
+#define QOS_TX_HIGH_BE_DEF (35)
+#define QOS_TX_HIGH_VI_DEF (35)
+#define QOS_TX_HIGH_VO_DEF (35)
+
+#define QOS_TX_LOW_BK_DEF (15)
+#define QOS_TX_LOW_BE_DEF (25)
+#define QOS_TX_LOW_VI_DEF (25)
+#define QOS_TX_LOW_VO_DEF (25)
+
+struct acx_tx_queue_qos_config {
+ struct acx_header header;
+
+ u8 qid;
+ u8 pad[3];
+
+ /* Max number of blocks allowd in the queue */
+ u16 high_threshold;
+
+ /* Lowest memory blocks guaranteed for this queue */
+ u16 low_threshold;
+} __attribute__ ((packed));
+
+struct acx_packet_detection {
+ struct acx_header header;
+
+ u32 threshold;
+} __attribute__ ((packed));
+
+
+enum acx_slot_type {
+ SLOT_TIME_LONG = 0,
+ SLOT_TIME_SHORT = 1,
+ DEFAULT_SLOT_TIME = SLOT_TIME_SHORT,
+ MAX_SLOT_TIMES = 0xFF
+};
+
+#define STATION_WONE_INDEX 0
+
+struct acx_slot {
+ struct acx_header header;
+
+ u8 wone_index; /* Reserved */
+ u8 slot_time;
+ u8 reserved[6];
+} __attribute__ ((packed));
+
+
+#define ADDRESS_GROUP_MAX (8)
+#define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX)
+
+struct multicast_grp_addr_start {
+ struct acx_header header;
+
+ u8 enabled;
+ u8 num_groups;
+ u8 pad[2];
+ u8 mac_table[ADDRESS_GROUP_MAX_LEN];
+} __attribute__ ((packed));
+
+
+#define RX_TIMEOUT_PS_POLL_MIN 0
+#define RX_TIMEOUT_PS_POLL_MAX (200000)
+#define RX_TIMEOUT_PS_POLL_DEF (15)
+#define RX_TIMEOUT_UPSD_MIN 0
+#define RX_TIMEOUT_UPSD_MAX (200000)
+#define RX_TIMEOUT_UPSD_DEF (15)
+
+struct acx_rx_timeout {
+ struct acx_header header;
+
+ /*
+ * The longest time the STA will wait to receive
+ * traffic from the AP after a PS-poll has been
+ * transmitted.
+ */
+ u16 ps_poll_timeout;
+
+ /*
+ * The longest time the STA will wait to receive
+ * traffic from the AP after a frame has been sent
+ * from an UPSD enabled queue.
+ */
+ u16 upsd_timeout;
+} __attribute__ ((packed));
+
+#define RTS_THRESHOLD_MIN 0
+#define RTS_THRESHOLD_MAX 4096
+#define RTS_THRESHOLD_DEF 2347
+
+struct acx_rts_threshold {
+ struct acx_header header;
+
+ u16 threshold;
+ u8 pad[2];
+} __attribute__ ((packed));
+
+struct acx_beacon_filter_option {
+ struct acx_header header;
+
+ u8 enable;
+
+ /*
+ * The number of beacons without the unicast TIM
+ * bit set that the firmware buffers before
+ * signaling the host about ready frames.
+ * When set to 0 and the filter is enabled, beacons
+ * without the unicast TIM bit set are dropped.
+ */
+ u8 max_num_beacons;
+ u8 pad[2];
+} __attribute__ ((packed));
+
+/*
+ * ACXBeaconFilterEntry (not 221)
+ * Byte Offset Size (Bytes) Definition
+ * =========== ============ ==========
+ * 0 1 IE identifier
+ * 1 1 Treatment bit mask
+ *
+ * ACXBeaconFilterEntry (221)
+ * Byte Offset Size (Bytes) Definition
+ * =========== ============ ==========
+ * 0 1 IE identifier
+ * 1 1 Treatment bit mask
+ * 2 3 OUI
+ * 5 1 Type
+ * 6 2 Version
+ *
+ *
+ * Treatment bit mask - The information element handling:
+ * bit 0 - The information element is compared and transferred
+ * in case of change.
+ * bit 1 - The information element is transferred to the host
+ * with each appearance or disappearance.
+ * Note that both bits can be set at the same time.
+ */
+#define BEACON_FILTER_TABLE_MAX_IE_NUM (32)
+#define BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM (6)
+#define BEACON_FILTER_TABLE_IE_ENTRY_SIZE (2)
+#define BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE (6)
+#define BEACON_FILTER_TABLE_MAX_SIZE ((BEACON_FILTER_TABLE_MAX_IE_NUM * \
+ BEACON_FILTER_TABLE_IE_ENTRY_SIZE) + \
+ (BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM * \
+ BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE))
+
+struct acx_beacon_filter_ie_table {
+ struct acx_header header;
+
+ u8 num_ie;
+ u8 table[BEACON_FILTER_TABLE_MAX_SIZE];
+ u8 pad[3];
+} __attribute__ ((packed));
+
+enum {
+ SG_ENABLE = 0,
+ SG_DISABLE,
+ SG_SENSE_NO_ACTIVITY,
+ SG_SENSE_ACTIVE
+};
+
+struct acx_bt_wlan_coex {
+ struct acx_header header;
+
+ /*
+ * 0 -> PTA enabled
+ * 1 -> PTA disabled
+ * 2 -> sense no active mode, i.e.
+ * an interrupt is sent upon
+ * BT activity.
+ * 3 -> PTA is switched on in response
+ * to the interrupt sending.
+ */
+ u8 enable;
+ u8 pad[3];
+} __attribute__ ((packed));
+
+#define PTA_ANTENNA_TYPE_DEF (0)
+#define PTA_BT_HP_MAXTIME_DEF (2000)
+#define PTA_WLAN_HP_MAX_TIME_DEF (5000)
+#define PTA_SENSE_DISABLE_TIMER_DEF (1350)
+#define PTA_PROTECTIVE_RX_TIME_DEF (1500)
+#define PTA_PROTECTIVE_TX_TIME_DEF (1500)
+#define PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF (3000)
+#define PTA_SIGNALING_TYPE_DEF (1)
+#define PTA_AFH_LEVERAGE_ON_DEF (0)
+#define PTA_NUMBER_QUIET_CYCLE_DEF (0)
+#define PTA_MAX_NUM_CTS_DEF (3)
+#define PTA_NUMBER_OF_WLAN_PACKETS_DEF (2)
+#define PTA_NUMBER_OF_BT_PACKETS_DEF (2)
+#define PTA_PROTECTIVE_RX_TIME_FAST_DEF (1500)
+#define PTA_PROTECTIVE_TX_TIME_FAST_DEF (3000)
+#define PTA_CYCLE_TIME_FAST_DEF (8700)
+#define PTA_RX_FOR_AVALANCHE_DEF (5)
+#define PTA_ELP_HP_DEF (0)
+#define PTA_ANTI_STARVE_PERIOD_DEF (500)
+#define PTA_ANTI_STARVE_NUM_CYCLE_DEF (4)
+#define PTA_ALLOW_PA_SD_DEF (1)
+#define PTA_TIME_BEFORE_BEACON_DEF (6300)
+#define PTA_HPDM_MAX_TIME_DEF (1600)
+#define PTA_TIME_OUT_NEXT_WLAN_DEF (2550)
+#define PTA_AUTO_MODE_NO_CTS_DEF (0)
+#define PTA_BT_HP_RESPECTED_DEF (3)
+#define PTA_WLAN_RX_MIN_RATE_DEF (24)
+#define PTA_ACK_MODE_DEF (1)
+
+struct acx_bt_wlan_coex_param {
+ struct acx_header header;
+
+ /*
+ * The minimum rate of a received WLAN packet in the STA,
+ * during protective mode, of which a new BT-HP request
+ * during this Rx will always be respected and gain the antenna.
+ */
+ u32 min_rate;
+
+ /* Max time the BT HP will be respected. */
+ u16 bt_hp_max_time;
+
+ /* Max time the WLAN HP will be respected. */
+ u16 wlan_hp_max_time;
+
+ /*
+ * The time between the last BT activity
+ * and the moment when the sense mode returns
+ * to SENSE_INACTIVE.
+ */
+ u16 sense_disable_timer;
+
+ /* Time before the next BT HP instance */
+ u16 rx_time_bt_hp;
+ u16 tx_time_bt_hp;
+
+ /* range: 10-20000 default: 1500 */
+ u16 rx_time_bt_hp_fast;
+ u16 tx_time_bt_hp_fast;
+
+ /* range: 2000-65535 default: 8700 */
+ u16 wlan_cycle_fast;
+
+ /* range: 0 - 15000 (Msec) default: 1000 */
+ u16 bt_anti_starvation_period;
+
+ /* range 400-10000(Usec) default: 3000 */
+ u16 next_bt_lp_packet;
+
+ /* Deafult: worst case for BT DH5 traffic */
+ u16 wake_up_beacon;
+
+ /* range: 0-50000(Usec) default: 1050 */
+ u16 hp_dm_max_guard_time;
+
+ /*
+ * This is to prevent both BT & WLAN antenna
+ * starvation.
+ * Range: 100-50000(Usec) default:2550
+ */
+ u16 next_wlan_packet;
+
+ /* 0 -> shared antenna */
+ u8 antenna_type;
+
+ /*
+ * 0 -> TI legacy
+ * 1 -> Palau
+ */
+ u8 signal_type;
+
+ /*
+ * BT AFH status
+ * 0 -> no AFH
+ * 1 -> from dedicated GPIO
+ * 2 -> AFH on (from host)
+ */
+ u8 afh_leverage_on;
+
+ /*
+ * The number of cycles during which no
+ * TX will be sent after 1 cycle of RX
+ * transaction in protective mode
+ */
+ u8 quiet_cycle_num;
+
+ /*
+ * The maximum number of CTSs that will
+ * be sent for receiving RX packet in
+ * protective mode
+ */
+ u8 max_cts;
+
+ /*
+ * The number of WLAN packets
+ * transferred in common mode before
+ * switching to BT.
+ */
+ u8 wlan_packets_num;
+
+ /*
+ * The number of BT packets
+ * transferred in common mode before
+ * switching to WLAN.
+ */
+ u8 bt_packets_num;
+
+ /* range: 1-255 default: 5 */
+ u8 missed_rx_avalanche;
+
+ /* range: 0-1 default: 1 */
+ u8 wlan_elp_hp;
+
+ /* range: 0 - 15 default: 4 */
+ u8 bt_anti_starvation_cycles;
+
+ u8 ack_mode_dual_ant;
+
+ /*
+ * Allow PA_SD assertion/de-assertion
+ * during enabled BT activity.
+ */
+ u8 pa_sd_enable;
+
+ /*
+ * Enable/Disable PTA in auto mode:
+ * Support Both Active & P.S modes
+ */
+ u8 pta_auto_mode_enable;
+
+ /* range: 0 - 20 default: 1 */
+ u8 bt_hp_respected_num;
+} __attribute__ ((packed));
+
+#define CCA_THRSH_ENABLE_ENERGY_D 0x140A
+#define CCA_THRSH_DISABLE_ENERGY_D 0xFFEF
+
+struct acx_energy_detection {
+ struct acx_header header;
+
+ /* The RX Clear Channel Assessment threshold in the PHY */
+ u16 rx_cca_threshold;
+ u8 tx_energy_detection;
+ u8 pad;
+} __attribute__ ((packed));
+
+#define BCN_RX_TIMEOUT_DEF_VALUE 10000
+#define BROADCAST_RX_TIMEOUT_DEF_VALUE 20000
+#define RX_BROADCAST_IN_PS_DEF_VALUE 1
+#define CONSECUTIVE_PS_POLL_FAILURE_DEF 4
+
+struct acx_beacon_broadcast {
+ struct acx_header header;
+
+ u16 beacon_rx_timeout;
+ u16 broadcast_timeout;
+
+ /* Enables receiving of broadcast packets in PS mode */
+ u8 rx_broadcast_in_ps;
+
+ /* Consecutive PS Poll failures before updating the host */
+ u8 ps_poll_threshold;
+ u8 pad[2];
+} __attribute__ ((packed));
+
+struct acx_event_mask {
+ struct acx_header header;
+
+ u32 event_mask;
+ u32 high_event_mask; /* Unused */
+} __attribute__ ((packed));
+
+#define CFG_RX_FCS BIT(2)
+#define CFG_RX_ALL_GOOD BIT(3)
+#define CFG_UNI_FILTER_EN BIT(4)
+#define CFG_BSSID_FILTER_EN BIT(5)
+#define CFG_MC_FILTER_EN BIT(6)
+#define CFG_MC_ADDR0_EN BIT(7)
+#define CFG_MC_ADDR1_EN BIT(8)
+#define CFG_BC_REJECT_EN BIT(9)
+#define CFG_SSID_FILTER_EN BIT(10)
+#define CFG_RX_INT_FCS_ERROR BIT(11)
+#define CFG_RX_INT_ENCRYPTED BIT(12)
+#define CFG_RX_WR_RX_STATUS BIT(13)
+#define CFG_RX_FILTER_NULTI BIT(14)
+#define CFG_RX_RESERVE BIT(15)
+#define CFG_RX_TIMESTAMP_TSF BIT(16)
+
+#define CFG_RX_RSV_EN BIT(0)
+#define CFG_RX_RCTS_ACK BIT(1)
+#define CFG_RX_PRSP_EN BIT(2)
+#define CFG_RX_PREQ_EN BIT(3)
+#define CFG_RX_MGMT_EN BIT(4)
+#define CFG_RX_FCS_ERROR BIT(5)
+#define CFG_RX_DATA_EN BIT(6)
+#define CFG_RX_CTL_EN BIT(7)
+#define CFG_RX_CF_EN BIT(8)
+#define CFG_RX_BCN_EN BIT(9)
+#define CFG_RX_AUTH_EN BIT(10)
+#define CFG_RX_ASSOC_EN BIT(11)
+
+#define SCAN_PASSIVE BIT(0)
+#define SCAN_5GHZ_BAND BIT(1)
+#define SCAN_TRIGGERED BIT(2)
+#define SCAN_PRIORITY_HIGH BIT(3)
+
+struct acx_fw_gen_frame_rates {
+ struct acx_header header;
+
+ u8 tx_ctrl_frame_rate; /* RATE_* */
+ u8 tx_ctrl_frame_mod; /* CCK_* or PBCC_* */
+ u8 tx_mgt_frame_rate;
+ u8 tx_mgt_frame_mod;
+} __attribute__ ((packed));
+
+/* STA MAC */
+struct dot11_station_id {
+ struct acx_header header;
+
+ u8 mac[ETH_ALEN];
+ u8 pad[2];
+} __attribute__ ((packed));
+
+/* HW encryption keys */
+#define NUM_ACCESS_CATEGORIES_COPY 4
+#define MAX_KEY_SIZE 32
+
+/* When set, disable HW encryption */
+#define DF_ENCRYPTION_DISABLE 0x01
+/* When set, disable HW decryption */
+#define DF_SNIFF_MODE_ENABLE 0x80
+
+struct acx_feature_config {
+ struct acx_header header;
+
+ u32 options;
+ u32 data_flow_options;
+} __attribute__ ((packed));
+
+enum acx_key_action {
+ KEY_ADD_OR_REPLACE = 1,
+ KEY_REMOVE = 2,
+ KEY_SET_ID = 3,
+ MAX_KEY_ACTION = 0xffff,
+};
+
+enum acx_key_type {
+ KEY_WEP_DEFAULT = 0,
+ KEY_WEP_ADDR = 1,
+ KEY_AES_GROUP = 4,
+ KEY_AES_PAIRWISE = 5,
+ KEY_WEP_GROUP = 6,
+ KEY_TKIP_MIC_GROUP = 10,
+ KEY_TKIP_MIC_PAIRWISE = 11,
+};
+
+/*
+ *
+ * key_type_e key size key format
+ * ---------- --------- ----------
+ * 0x00 5, 13, 29 Key data
+ * 0x01 5, 13, 29 Key data
+ * 0x04 16 16 bytes of key data
+ * 0x05 16 16 bytes of key data
+ * 0x0a 32 16 bytes of TKIP key data
+ * 8 bytes of RX MIC key data
+ * 8 bytes of TX MIC key data
+ * 0x0b 32 16 bytes of TKIP key data
+ * 8 bytes of RX MIC key data
+ * 8 bytes of TX MIC key data
+ *
+ */
+
+struct acx_set_key {
+ /* Ignored for default WEP key */
+ u8 addr[ETH_ALEN];
+
+ /* key_action_e */
+ u16 key_action;
+
+ u16 reserved_1;
+
+ /* key size in bytes */
+ u8 key_size;
+
+ /* key_type_e */
+ u8 key_type;
+ u8 ssid_profile;
+
+ /*
+ * TKIP, AES: frame's key id field.
+ * For WEP default key: key id;
+ */
+ u8 id;
+ u8 reserved_2[6];
+ u8 key[MAX_KEY_SIZE];
+ u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
+ u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
+} __attribute__ ((packed));
+
+struct acx_current_tx_power {
+ struct acx_header header;
+
+ u8 current_tx_power;
+ u8 padding[3];
+} __attribute__ ((packed));
+
+struct acx_dot11_default_key {
+ struct acx_header header;
+
+ u8 id;
+ u8 pad[3];
+} __attribute__ ((packed));
+
+struct acx_tsf_info {
+ struct acx_header header;
+
+ u32 current_tsf_msb;
+ u32 current_tsf_lsb;
+ u32 last_TBTT_msb;
+ u32 last_TBTT_lsb;
+ u8 last_dtim_count;
+ u8 pad[3];
+} __attribute__ ((packed));
+
+/* 802.11 PS */
+enum acx_ps_mode {
+ STATION_ACTIVE_MODE,
+ STATION_POWER_SAVE_MODE
+};
+
+struct acx_ps_params {
+ u8 ps_mode; /* STATION_* */
+ u8 send_null_data; /* Do we have to send NULL data packet ? */
+ u8 retries; /* Number of retires for the initial NULL data packet */
+
+ /*
+ * TUs during which the target stays awake after switching
+ * to power save mode.
+ */
+ u8 hang_over_period;
+ u16 null_data_rate;
+ u8 pad[2];
+} __attribute__ ((packed));
+
+enum acx_wake_up_event {
+ WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/
+ WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/
+ WAKE_UP_EVENT_N_DTIM_BITMAP = 0x04, /* Wake on every Nth DTIM */
+ WAKE_UP_EVENT_N_BEACONS_BITMAP = 0x08, /* Wake on every Nth Beacon */
+ WAKE_UP_EVENT_BITS_MASK = 0x0F
+};
+
+struct acx_wake_up_condition {
+ struct acx_header header;
+
+ u8 wake_up_event; /* Only one bit can be set */
+ u8 listen_interval;
+ u8 pad[2];
+} __attribute__ ((packed));
+
+struct acx_aid {
+ struct acx_header header;
+
+ /*
+ * To be set when associated with an AP.
+ */
+ u16 aid;
+ u8 pad[2];
+} __attribute__ ((packed));
+
+enum acx_preamble_type {
+ ACX_PREAMBLE_LONG = 0,
+ ACX_PREAMBLE_SHORT = 1
+};
+
+struct acx_preamble {
+ struct acx_header header;
+ /*
+ * When set, the WiLink transmits the frames with a short preamble and
+ * when cleared, the WiLink transmits the frames with a long preamble.
+ */
+ u8 preamble;
+ u8 padding[3];
+} __attribute__ ((packed));
+
+enum acx_ctsprotect_type {
+ CTSPROTECT_DISABLE = 0,
+ CTSPROTECT_ENABLE = 1
+};
+
+struct acx_ctsprotect {
+ struct acx_header header;
+ u8 ctsprotect;
+ u8 padding[3];
+} __attribute__ ((packed));
+
+struct acx_tx_statistics {
+ u32 internal_desc_overflow;
+} __attribute__ ((packed));
+
+struct acx_rx_statistics {
+ u32 out_of_mem;
+ u32 hdr_overflow;
+ u32 hw_stuck;
+ u32 dropped;
+ u32 fcs_err;
+ u32 xfr_hint_trig;
+ u32 path_reset;
+ u32 reset_counter;
+} __attribute__ ((packed));
+
+struct acx_dma_statistics {
+ u32 rx_requested;
+ u32 rx_errors;
+ u32 tx_requested;
+ u32 tx_errors;
+} __attribute__ ((packed));
+
+struct acx_isr_statistics {
+ /* host command complete */
+ u32 cmd_cmplt;
+
+ /* fiqisr() */
+ u32 fiqs;
+
+ /* (INT_STS_ND & INT_TRIG_RX_HEADER) */
+ u32 rx_headers;
+
+ /* (INT_STS_ND & INT_TRIG_RX_CMPLT) */
+ u32 rx_completes;
+
+ /* (INT_STS_ND & INT_TRIG_NO_RX_BUF) */
+ u32 rx_mem_overflow;
+
+ /* (INT_STS_ND & INT_TRIG_S_RX_RDY) */
+ u32 rx_rdys;
+
+ /* irqisr() */
+ u32 irqs;
+
+ /* (INT_STS_ND & INT_TRIG_TX_PROC) */
+ u32 tx_procs;
+
+ /* (INT_STS_ND & INT_TRIG_DECRYPT_DONE) */
+ u32 decrypt_done;
+
+ /* (INT_STS_ND & INT_TRIG_DMA0) */
+ u32 dma0_done;
+
+ /* (INT_STS_ND & INT_TRIG_DMA1) */
+ u32 dma1_done;
+
+ /* (INT_STS_ND & INT_TRIG_TX_EXC_CMPLT) */
+ u32 tx_exch_complete;
+
+ /* (INT_STS_ND & INT_TRIG_COMMAND) */
+ u32 commands;
+
+ /* (INT_STS_ND & INT_TRIG_RX_PROC) */
+ u32 rx_procs;
+
+ /* (INT_STS_ND & INT_TRIG_PM_802) */
+ u32 hw_pm_mode_changes;
+
+ /* (INT_STS_ND & INT_TRIG_ACKNOWLEDGE) */
+ u32 host_acknowledges;
+
+ /* (INT_STS_ND & INT_TRIG_PM_PCI) */
+ u32 pci_pm;
+
+ /* (INT_STS_ND & INT_TRIG_ACM_WAKEUP) */
+ u32 wakeups;
+
+ /* (INT_STS_ND & INT_TRIG_LOW_RSSI) */
+ u32 low_rssi;
+} __attribute__ ((packed));
+
+struct acx_wep_statistics {
+ /* WEP address keys configured */
+ u32 addr_key_count;
+
+ /* default keys configured */
+ u32 default_key_count;
+
+ u32 reserved;
+
+ /* number of times that WEP key not found on lookup */
+ u32 key_not_found;
+
+ /* number of times that WEP key decryption failed */
+ u32 decrypt_fail;
+
+ /* WEP packets decrypted */
+ u32 packets;
+
+ /* WEP decrypt interrupts */
+ u32 interrupt;
+} __attribute__ ((packed));
+
+#define ACX_MISSED_BEACONS_SPREAD 10
+
+struct acx_pwr_statistics {
+ /* the amount of enters into power save mode (both PD & ELP) */
+ u32 ps_enter;
+
+ /* the amount of enters into ELP mode */
+ u32 elp_enter;
+
+ /* the amount of missing beacon interrupts to the host */
+ u32 missing_bcns;
+
+ /* the amount of wake on host-access times */
+ u32 wake_on_host;
+
+ /* the amount of wake on timer-expire */
+ u32 wake_on_timer_exp;
+
+ /* the number of packets that were transmitted with PS bit set */
+ u32 tx_with_ps;
+
+ /* the number of packets that were transmitted with PS bit clear */
+ u32 tx_without_ps;
+
+ /* the number of received beacons */
+ u32 rcvd_beacons;
+
+ /* the number of entering into PowerOn (power save off) */
+ u32 power_save_off;
+
+ /* the number of entries into power save mode */
+ u16 enable_ps;
+
+ /*
+ * the number of exits from power save, not including failed PS
+ * transitions
+ */
+ u16 disable_ps;
+
+ /*
+ * the number of times the TSF counter was adjusted because
+ * of drift
+ */
+ u32 fix_tsf_ps;
+
+ /* Gives statistics about the spread continuous missed beacons.
+ * The 16 LSB are dedicated for the PS mode.
+ * The 16 MSB are dedicated for the PS mode.
+ * cont_miss_bcns_spread[0] - single missed beacon.
+ * cont_miss_bcns_spread[1] - two continuous missed beacons.
+ * cont_miss_bcns_spread[2] - three continuous missed beacons.
+ * ...
+ * cont_miss_bcns_spread[9] - ten and more continuous missed beacons.
+ */
+ u32 cont_miss_bcns_spread[ACX_MISSED_BEACONS_SPREAD];
+
+ /* the number of beacons in awake mode */
+ u32 rcvd_awake_beacons;
+} __attribute__ ((packed));
+
+struct acx_mic_statistics {
+ u32 rx_pkts;
+ u32 calc_failure;
+} __attribute__ ((packed));
+
+struct acx_aes_statistics {
+ u32 encrypt_fail;
+ u32 decrypt_fail;
+ u32 encrypt_packets;
+ u32 decrypt_packets;
+ u32 encrypt_interrupt;
+ u32 decrypt_interrupt;
+} __attribute__ ((packed));
+
+struct acx_event_statistics {
+ u32 heart_beat;
+ u32 calibration;
+ u32 rx_mismatch;
+ u32 rx_mem_empty;
+ u32 rx_pool;
+ u32 oom_late;
+ u32 phy_transmit_error;
+ u32 tx_stuck;
+} __attribute__ ((packed));
+
+struct acx_ps_statistics {
+ u32 pspoll_timeouts;
+ u32 upsd_timeouts;
+ u32 upsd_max_sptime;
+ u32 upsd_max_apturn;
+ u32 pspoll_max_apturn;
+ u32 pspoll_utilization;
+ u32 upsd_utilization;
+} __attribute__ ((packed));
+
+struct acx_rxpipe_statistics {
+ u32 rx_prep_beacon_drop;
+ u32 descr_host_int_trig_rx_data;
+ u32 beacon_buffer_thres_host_int_trig_rx_data;
+ u32 missed_beacon_host_int_trig_rx_data;
+ u32 tx_xfr_host_int_trig_rx_data;
+} __attribute__ ((packed));
+
+struct acx_statistics {
+ struct acx_header header;
+
+ struct acx_tx_statistics tx;
+ struct acx_rx_statistics rx;
+ struct acx_dma_statistics dma;
+ struct acx_isr_statistics isr;
+ struct acx_wep_statistics wep;
+ struct acx_pwr_statistics pwr;
+ struct acx_aes_statistics aes;
+ struct acx_mic_statistics mic;
+ struct acx_event_statistics event;
+ struct acx_ps_statistics ps;
+ struct acx_rxpipe_statistics rxpipe;
+} __attribute__ ((packed));
+
+enum {
+ ACX_WAKE_UP_CONDITIONS = 0x0002,
+ ACX_MEM_CFG = 0x0003,
+ ACX_SLOT = 0x0004,
+ ACX_QUEUE_HEAD = 0x0005, /* for MASTER mode only */
+ ACX_AC_CFG = 0x0007,
+ ACX_MEM_MAP = 0x0008,
+ ACX_AID = 0x000A,
+ ACX_RADIO_PARAM = 0x000B, /* Not used */
+ ACX_CFG = 0x000C, /* Not used */
+ ACX_FW_REV = 0x000D,
+ ACX_MEDIUM_USAGE = 0x000F,
+ ACX_RX_CFG = 0x0010,
+ ACX_TX_QUEUE_CFG = 0x0011, /* FIXME: only used by wl1251 */
+ ACX_BSS_IN_PS = 0x0012, /* for AP only */
+ ACX_STATISTICS = 0x0013, /* Debug API */
+ ACX_FEATURE_CFG = 0x0015,
+ ACX_MISC_CFG = 0x0017, /* Not used */
+ ACX_TID_CFG = 0x001A,
+ ACX_BEACON_FILTER_OPT = 0x001F,
+ ACX_LOW_RSSI = 0x0020,
+ ACX_NOISE_HIST = 0x0021,
+ ACX_HDK_VERSION = 0x0022, /* ??? */
+ ACX_PD_THRESHOLD = 0x0023,
+ ACX_DATA_PATH_PARAMS = 0x0024, /* WO */
+ ACX_DATA_PATH_RESP_PARAMS = 0x0024, /* RO */
+ ACX_CCA_THRESHOLD = 0x0025,
+ ACX_EVENT_MBOX_MASK = 0x0026,
+#ifdef FW_RUNNING_AS_AP
+ ACX_DTIM_PERIOD = 0x0027, /* for AP only */
+#else
+ ACX_WR_TBTT_AND_DTIM = 0x0027, /* STA only */
+#endif
+ ACX_ACI_OPTION_CFG = 0x0029, /* OBSOLETE (for 1251)*/
+ ACX_GPIO_CFG = 0x002A, /* Not used */
+ ACX_GPIO_SET = 0x002B, /* Not used */
+ ACX_PM_CFG = 0x002C, /* To Be Documented */
+ ACX_CONN_MONIT_PARAMS = 0x002D,
+ ACX_AVERAGE_RSSI = 0x002E, /* Not used */
+ ACX_CONS_TX_FAILURE = 0x002F,
+ ACX_BCN_DTIM_OPTIONS = 0x0031,
+ ACX_SG_ENABLE = 0x0032,
+ ACX_SG_CFG = 0x0033,
+ ACX_ANTENNA_DIVERSITY_CFG = 0x0035, /* To Be Documented */
+ ACX_LOW_SNR = 0x0037, /* To Be Documented */
+ ACX_BEACON_FILTER_TABLE = 0x0038,
+ ACX_ARP_IP_FILTER = 0x0039,
+ ACX_ROAMING_STATISTICS_TBL = 0x003B,
+ ACX_RATE_POLICY = 0x003D,
+ ACX_CTS_PROTECTION = 0x003E,
+ ACX_SLEEP_AUTH = 0x003F,
+ ACX_PREAMBLE_TYPE = 0x0040,
+ ACX_ERROR_CNT = 0x0041,
+ ACX_FW_GEN_FRAME_RATES = 0x0042,
+ ACX_IBSS_FILTER = 0x0044,
+ ACX_SERVICE_PERIOD_TIMEOUT = 0x0045,
+ ACX_TSF_INFO = 0x0046,
+ ACX_CONFIG_PS_WMM = 0x0049,
+ ACX_ENABLE_RX_DATA_FILTER = 0x004A,
+ ACX_SET_RX_DATA_FILTER = 0x004B,
+ ACX_GET_DATA_FILTER_STATISTICS = 0x004C,
+ ACX_POWER_LEVEL_TABLE = 0x004D,
+ ACX_BET_ENABLE = 0x0050,
+ DOT11_STATION_ID = 0x1001,
+ DOT11_RX_MSDU_LIFE_TIME = 0x1004,
+ DOT11_CUR_TX_PWR = 0x100D,
+ DOT11_DEFAULT_KEY = 0x1010,
+ DOT11_RX_DOT11_MODE = 0x1012,
+ DOT11_RTS_THRESHOLD = 0x1013,
+ DOT11_GROUP_ADDRESS_TBL = 0x1014,
+
+ MAX_DOT11_IE = DOT11_GROUP_ADDRESS_TBL,
+
+ MAX_IE = 0xFFFF
+};
+
+
+int wl12xx_acx_frame_rates(struct wl12xx *wl, u8 ctrl_rate, u8 ctrl_mod,
+ u8 mgt_rate, u8 mgt_mod);
+int wl12xx_acx_station_id(struct wl12xx *wl);
+int wl12xx_acx_default_key(struct wl12xx *wl, u8 key_id);
+int wl12xx_acx_wake_up_conditions(struct wl12xx *wl, u8 listen_interval);
+int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth);
+int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len);
+int wl12xx_acx_tx_power(struct wl12xx *wl, int power);
+int wl12xx_acx_feature_cfg(struct wl12xx *wl);
+int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len);
+int wl12xx_acx_data_path_params(struct wl12xx *wl,
+ struct acx_data_path_params_resp *data_path);
+int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time);
+int wl12xx_acx_rx_config(struct wl12xx *wl, u32 config, u32 filter);
+int wl12xx_acx_pd_threshold(struct wl12xx *wl);
+int wl12xx_acx_slot(struct wl12xx *wl, enum acx_slot_type slot_time);
+int wl12xx_acx_group_address_tbl(struct wl12xx *wl);
+int wl12xx_acx_service_period_timeout(struct wl12xx *wl);
+int wl12xx_acx_rts_threshold(struct wl12xx *wl, u16 rts_threshold);
+int wl12xx_acx_beacon_filter_opt(struct wl12xx *wl);
+int wl12xx_acx_beacon_filter_table(struct wl12xx *wl);
+int wl12xx_acx_sg_enable(struct wl12xx *wl);
+int wl12xx_acx_sg_cfg(struct wl12xx *wl);
+int wl12xx_acx_cca_threshold(struct wl12xx *wl);
+int wl12xx_acx_bcn_dtim_options(struct wl12xx *wl);
+int wl12xx_acx_aid(struct wl12xx *wl, u16 aid);
+int wl12xx_acx_event_mbox_mask(struct wl12xx *wl, u32 event_mask);
+int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble);
+int wl12xx_acx_cts_protect(struct wl12xx *wl,
+ enum acx_ctsprotect_type ctsprotect);
+int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats);
+
+#endif /* __WL12XX_ACX_H__ */
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c
new file mode 100644
index 000000000000..48ac08c429bd
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/boot.c
@@ -0,0 +1,295 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/gpio.h>
+
+#include "reg.h"
+#include "boot.h"
+#include "spi.h"
+#include "event.h"
+
+static void wl12xx_boot_enable_interrupts(struct wl12xx *wl)
+{
+ enable_irq(wl->irq);
+}
+
+void wl12xx_boot_target_enable_interrupts(struct wl12xx *wl)
+{
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
+ wl12xx_reg_write32(wl, HI_CFG, HI_CFG_DEF_VAL);
+}
+
+int wl12xx_boot_soft_reset(struct wl12xx *wl)
+{
+ unsigned long timeout;
+ u32 boot_data;
+
+ /* perform soft reset */
+ wl12xx_reg_write32(wl, ACX_REG_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT);
+
+ /* SOFT_RESET is self clearing */
+ timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME);
+ while (1) {
+ boot_data = wl12xx_reg_read32(wl, ACX_REG_SLV_SOFT_RESET);
+ wl12xx_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data);
+ if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0)
+ break;
+
+ if (time_after(jiffies, timeout)) {
+ /* 1.2 check pWhalBus->uSelfClearTime if the
+ * timeout was reached */
+ wl12xx_error("soft reset timeout");
+ return -1;
+ }
+
+ udelay(SOFT_RESET_STALL_TIME);
+ }
+
+ /* disable Rx/Tx */
+ wl12xx_reg_write32(wl, ENABLE, 0x0);
+
+ /* disable auto calibration on start*/
+ wl12xx_reg_write32(wl, SPARE_A2, 0xffff);
+
+ return 0;
+}
+
+int wl12xx_boot_init_seq(struct wl12xx *wl)
+{
+ u32 scr_pad6, init_data, tmp, elp_cmd, ref_freq;
+
+ /*
+ * col #1: INTEGER_DIVIDER
+ * col #2: FRACTIONAL_DIVIDER
+ * col #3: ATTN_BB
+ * col #4: ALPHA_BB
+ * col #5: STOP_TIME_BB
+ * col #6: BB_PLL_LOOP_FILTER
+ */
+ static const u32 LUT[REF_FREQ_NUM][LUT_PARAM_NUM] = {
+
+ { 83, 87381, 0xB, 5, 0xF00, 3}, /* REF_FREQ_19_2*/
+ { 61, 141154, 0xB, 5, 0x1450, 2}, /* REF_FREQ_26_0*/
+ { 41, 174763, 0xC, 6, 0x2D00, 1}, /* REF_FREQ_38_4*/
+ { 40, 0, 0xC, 6, 0x2EE0, 1}, /* REF_FREQ_40_0*/
+ { 47, 162280, 0xC, 6, 0x2760, 1} /* REF_FREQ_33_6 */
+ };
+
+ /* read NVS params */
+ scr_pad6 = wl12xx_reg_read32(wl, SCR_PAD6);
+ wl12xx_debug(DEBUG_BOOT, "scr_pad6 0x%x", scr_pad6);
+
+ /* read ELP_CMD */
+ elp_cmd = wl12xx_reg_read32(wl, ELP_CMD);
+ wl12xx_debug(DEBUG_BOOT, "elp_cmd 0x%x", elp_cmd);
+
+ /* set the BB calibration time to be 300 usec (PLL_CAL_TIME) */
+ ref_freq = scr_pad6 & 0x000000FF;
+ wl12xx_debug(DEBUG_BOOT, "ref_freq 0x%x", ref_freq);
+
+ wl12xx_reg_write32(wl, PLL_CAL_TIME, 0x9);
+
+ /*
+ * PG 1.2: set the clock buffer time to be 210 usec (CLK_BUF_TIME)
+ */
+ wl12xx_reg_write32(wl, CLK_BUF_TIME, 0x6);
+
+ /*
+ * set the clock detect feature to work in the restart wu procedure
+ * (ELP_CFG_MODE[14]) and Select the clock source type
+ * (ELP_CFG_MODE[13:12])
+ */
+ tmp = ((scr_pad6 & 0x0000FF00) << 4) | 0x00004000;
+ wl12xx_reg_write32(wl, ELP_CFG_MODE, tmp);
+
+ /* PG 1.2: enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */
+ elp_cmd |= 0x00000040;
+ wl12xx_reg_write32(wl, ELP_CMD, elp_cmd);
+
+ /* PG 1.2: Set the BB PLL stable time to be 1000usec
+ * (PLL_STABLE_TIME) */
+ wl12xx_reg_write32(wl, CFG_PLL_SYNC_CNT, 0x20);
+
+ /* PG 1.2: read clock request time */
+ init_data = wl12xx_reg_read32(wl, CLK_REQ_TIME);
+
+ /*
+ * PG 1.2: set the clock request time to be ref_clk_settling_time -
+ * 1ms = 4ms
+ */
+ if (init_data > 0x21)
+ tmp = init_data - 0x21;
+ else
+ tmp = 0;
+ wl12xx_reg_write32(wl, CLK_REQ_TIME, tmp);
+
+ /* set BB PLL configurations in RF AFE */
+ wl12xx_reg_write32(wl, 0x003058cc, 0x4B5);
+
+ /* set RF_AFE_REG_5 */
+ wl12xx_reg_write32(wl, 0x003058d4, 0x50);
+
+ /* set RF_AFE_CTRL_REG_2 */
+ wl12xx_reg_write32(wl, 0x00305948, 0x11c001);
+
+ /*
+ * change RF PLL and BB PLL divider for VCO clock and adjust VCO
+ * bais current(RF_AFE_REG_13)
+ */
+ wl12xx_reg_write32(wl, 0x003058f4, 0x1e);
+
+ /* set BB PLL configurations */
+ tmp = LUT[ref_freq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000;
+ wl12xx_reg_write32(wl, 0x00305840, tmp);
+
+ /* set fractional divider according to Appendix C-BB PLL
+ * Calculations
+ */
+ tmp = LUT[ref_freq][LUT_PARAM_FRACTIONAL_DIVIDER];
+ wl12xx_reg_write32(wl, 0x00305844, tmp);
+
+ /* set the initial data for the sigma delta */
+ wl12xx_reg_write32(wl, 0x00305848, 0x3039);
+
+ /*
+ * set the accumulator attenuation value, calibration loop1
+ * (alpha), calibration loop2 (beta), calibration loop3 (gamma) and
+ * the VCO gain
+ */
+ tmp = (LUT[ref_freq][LUT_PARAM_ATTN_BB] << 16) |
+ (LUT[ref_freq][LUT_PARAM_ALPHA_BB] << 12) | 0x1;
+ wl12xx_reg_write32(wl, 0x00305854, tmp);
+
+ /*
+ * set the calibration stop time after holdoff time expires and set
+ * settling time HOLD_OFF_TIME_BB
+ */
+ tmp = LUT[ref_freq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000;
+ wl12xx_reg_write32(wl, 0x00305858, tmp);
+
+ /*
+ * set BB PLL Loop filter capacitor3- BB_C3[2:0] and set BB PLL
+ * constant leakage current to linearize PFD to 0uA -
+ * BB_ILOOPF[7:3]
+ */
+ tmp = LUT[ref_freq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030;
+ wl12xx_reg_write32(wl, 0x003058f8, tmp);
+
+ /*
+ * set regulator output voltage for n divider to
+ * 1.35-BB_REFDIV[1:0], set charge pump current- BB_CPGAIN[4:2],
+ * set BB PLL Loop filter capacitor2- BB_C2[7:5], set gain of BB
+ * PLL auto-call to normal mode- BB_CALGAIN_3DB[8]
+ */
+ wl12xx_reg_write32(wl, 0x003058f0, 0x29);
+
+ /* enable restart wakeup sequence (ELP_CMD[0]) */
+ wl12xx_reg_write32(wl, ELP_CMD, elp_cmd | 0x1);
+
+ /* restart sequence completed */
+ udelay(2000);
+
+ return 0;
+}
+
+int wl12xx_boot_run_firmware(struct wl12xx *wl)
+{
+ int loop, ret;
+ u32 chip_id, interrupt;
+
+ wl->chip.op_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT);
+
+ chip_id = wl12xx_reg_read32(wl, CHIP_ID_B);
+
+ wl12xx_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id);
+
+ if (chip_id != wl->chip.id) {
+ wl12xx_error("chip id doesn't match after firmware boot");
+ return -EIO;
+ }
+
+ /* wait for init to complete */
+ loop = 0;
+ while (loop++ < INIT_LOOP) {
+ udelay(INIT_LOOP_DELAY);
+ interrupt = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
+
+ if (interrupt == 0xffffffff) {
+ wl12xx_error("error reading hardware complete "
+ "init indication");
+ return -EIO;
+ }
+ /* check that ACX_INTR_INIT_COMPLETE is enabled */
+ else if (interrupt & wl->chip.intr_init_complete) {
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK,
+ wl->chip.intr_init_complete);
+ break;
+ }
+ }
+
+ if (loop >= INIT_LOOP) {
+ wl12xx_error("timeout waiting for the hardware to "
+ "complete initialization");
+ return -EIO;
+ }
+
+ /* get hardware config command mail box */
+ wl->cmd_box_addr = wl12xx_reg_read32(wl, REG_COMMAND_MAILBOX_PTR);
+
+ /* get hardware config event mail box */
+ wl->event_box_addr = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR);
+
+ /* set the working partition to its "running" mode offset */
+ wl12xx_set_partition(wl,
+ wl->chip.p_table[PART_WORK].mem.start,
+ wl->chip.p_table[PART_WORK].mem.size,
+ wl->chip.p_table[PART_WORK].reg.start,
+ wl->chip.p_table[PART_WORK].reg.size);
+
+ wl12xx_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x",
+ wl->cmd_box_addr, wl->event_box_addr);
+
+ /*
+ * in case of full asynchronous mode the firmware event must be
+ * ready to receive event from the command mailbox
+ */
+
+ /* enable gpio interrupts */
+ wl12xx_boot_enable_interrupts(wl);
+
+ wl->chip.op_target_enable_interrupts(wl);
+
+ /* unmask all mbox events */
+ wl->event_mask = 0xffffffff;
+
+ ret = wl12xx_event_unmask(wl);
+ if (ret < 0) {
+ wl12xx_error("EVENT mask setting failed");
+ return ret;
+ }
+
+ wl12xx_event_mbox_config(wl);
+
+ /* firmware startup completed */
+ return 0;
+}
diff --git a/drivers/net/wireless/wl12xx/boot.h b/drivers/net/wireless/wl12xx/boot.h
new file mode 100644
index 000000000000..4fa73132baae
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/boot.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __BOOT_H__
+#define __BOOT_H__
+
+#include "wl12xx.h"
+
+int wl12xx_boot_soft_reset(struct wl12xx *wl);
+int wl12xx_boot_init_seq(struct wl12xx *wl);
+int wl12xx_boot_run_firmware(struct wl12xx *wl);
+void wl12xx_boot_target_enable_interrupts(struct wl12xx *wl);
+
+/* number of times we try to read the INIT interrupt */
+#define INIT_LOOP 20000
+
+/* delay between retries */
+#define INIT_LOOP_DELAY 50
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c
new file mode 100644
index 000000000000..f73ab602b7ae
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/cmd.c
@@ -0,0 +1,353 @@
+#include "cmd.h"
+
+#include <linux/module.h>
+#include <linux/crc7.h>
+#include <linux/spi/spi.h>
+
+#include "wl12xx.h"
+#include "wl12xx_80211.h"
+#include "reg.h"
+#include "spi.h"
+#include "ps.h"
+
+int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len)
+{
+ struct wl12xx_command cmd;
+ unsigned long timeout;
+ size_t cmd_len;
+ u32 intr;
+ int ret = 0;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.id = type;
+ cmd.status = 0;
+ memcpy(cmd.parameters, buf, buf_len);
+ cmd_len = ALIGN(buf_len, 4) + CMDMBOX_HEADER_LEN;
+
+ wl12xx_ps_elp_wakeup(wl);
+
+ wl12xx_spi_mem_write(wl, wl->cmd_box_addr, &cmd, cmd_len);
+
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD);
+
+ timeout = jiffies + msecs_to_jiffies(WL12XX_COMMAND_TIMEOUT);
+
+ intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
+ while (!(intr & wl->chip.intr_cmd_complete)) {
+ if (time_after(jiffies, timeout)) {
+ wl12xx_error("command complete timeout");
+ ret = -ETIMEDOUT;
+ goto out;
+ }
+
+ msleep(1);
+
+ intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
+ }
+
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK,
+ wl->chip.intr_cmd_complete);
+
+out:
+ wl12xx_ps_elp_sleep(wl);
+
+ return ret;
+}
+
+int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer)
+{
+ int ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd test");
+
+ ret = wl12xx_cmd_send(wl, CMD_TEST, buf, buf_len);
+ if (ret < 0) {
+ wl12xx_warning("TEST command failed");
+ return ret;
+ }
+
+ if (answer) {
+ struct wl12xx_command *cmd_answer;
+
+ /*
+ * The test command got in, we can read the answer.
+ * The answer would be a wl12xx_command, where the
+ * parameter array contains the actual answer.
+ */
+
+ wl12xx_ps_elp_wakeup(wl);
+
+ wl12xx_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len);
+
+ wl12xx_ps_elp_sleep(wl);
+
+ cmd_answer = buf;
+ if (cmd_answer->status != CMD_STATUS_SUCCESS)
+ wl12xx_error("TEST command answer error: %d",
+ cmd_answer->status);
+ }
+
+ return 0;
+}
+
+
+int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len,
+ void *answer)
+{
+ struct wl12xx_command *cmd;
+ struct acx_header header;
+ int ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd interrogate");
+
+ header.id = ie_id;
+ header.len = ie_len - sizeof(header);
+
+ ret = wl12xx_cmd_send(wl, CMD_INTERROGATE, &header, sizeof(header));
+ if (ret < 0) {
+ wl12xx_error("INTERROGATE command failed");
+ return ret;
+ }
+
+ wl12xx_ps_elp_wakeup(wl);
+
+ /* the interrogate command got in, we can read the answer */
+ wl12xx_spi_mem_read(wl, wl->cmd_box_addr, answer,
+ CMDMBOX_HEADER_LEN + ie_len);
+
+ wl12xx_ps_elp_sleep(wl);
+
+ cmd = answer;
+ if (cmd->status != CMD_STATUS_SUCCESS)
+ wl12xx_error("INTERROGATE command error: %d",
+ cmd->status);
+
+ return 0;
+
+}
+
+int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len)
+{
+ int ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd configure");
+
+ ret = wl12xx_cmd_send(wl, CMD_CONFIGURE, ie,
+ ie_len);
+ if (ret < 0) {
+ wl12xx_warning("CONFIGURE command NOK");
+ return ret;
+ }
+
+ return 0;
+
+}
+
+int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity,
+ void *bitmap, u16 bitmap_len, u8 bitmap_control)
+{
+ struct vbm_update_request vbm;
+ int ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd vbm");
+
+ /* Count and period will be filled by the target */
+ vbm.tim.bitmap_ctrl = bitmap_control;
+ if (bitmap_len > PARTIAL_VBM_MAX) {
+ wl12xx_warning("cmd vbm len is %d B, truncating to %d",
+ bitmap_len, PARTIAL_VBM_MAX);
+ bitmap_len = PARTIAL_VBM_MAX;
+ }
+ memcpy(vbm.tim.pvb_field, bitmap, bitmap_len);
+ vbm.tim.identity = identity;
+ vbm.tim.length = bitmap_len + 3;
+
+ vbm.len = cpu_to_le16(bitmap_len + 5);
+
+ ret = wl12xx_cmd_send(wl, CMD_VBM, &vbm, sizeof(vbm));
+ if (ret < 0) {
+ wl12xx_error("VBM command failed");
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable)
+{
+ int ret;
+ u16 cmd_rx, cmd_tx;
+
+ wl12xx_debug(DEBUG_CMD, "cmd data path");
+
+ if (enable) {
+ cmd_rx = CMD_ENABLE_RX;
+ cmd_tx = CMD_ENABLE_TX;
+ } else {
+ cmd_rx = CMD_DISABLE_RX;
+ cmd_tx = CMD_DISABLE_TX;
+ }
+
+ ret = wl12xx_cmd_send(wl, cmd_rx, &channel, sizeof(channel));
+ if (ret < 0) {
+ wl12xx_error("rx %s cmd for channel %d failed",
+ enable ? "start" : "stop", channel);
+ return ret;
+ }
+
+ wl12xx_debug(DEBUG_BOOT, "rx %s cmd channel %d",
+ enable ? "start" : "stop", channel);
+
+ ret = wl12xx_cmd_send(wl, cmd_tx, &channel, sizeof(channel));
+ if (ret < 0) {
+ wl12xx_error("tx %s cmd for channel %d failed",
+ enable ? "start" : "stop", channel);
+ return ret;
+ }
+
+ wl12xx_debug(DEBUG_BOOT, "tx %s cmd channel %d",
+ enable ? "start" : "stop", channel);
+
+ return 0;
+}
+
+int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval,
+ u16 beacon_interval, u8 wait)
+{
+ unsigned long timeout;
+ struct cmd_join join = {};
+ int ret, i;
+ u8 *bssid;
+
+ /* FIXME: this should be in main.c */
+ ret = wl12xx_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE,
+ DEFAULT_HW_GEN_MODULATION_TYPE,
+ wl->tx_mgmt_frm_rate,
+ wl->tx_mgmt_frm_mod);
+ if (ret < 0)
+ return ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd join");
+
+ /* Reverse order BSSID */
+ bssid = (u8 *)&join.bssid_lsb;
+ for (i = 0; i < ETH_ALEN; i++)
+ bssid[i] = wl->bssid[ETH_ALEN - i - 1];
+
+ join.rx_config_options = wl->rx_config;
+ join.rx_filter_options = wl->rx_filter;
+
+ join.basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS |
+ RATE_MASK_5_5MBPS | RATE_MASK_11MBPS;
+
+ join.beacon_interval = beacon_interval;
+ join.dtim_interval = dtim_interval;
+ join.bss_type = bss_type;
+ join.channel = wl->channel;
+ join.ctrl = JOIN_CMD_CTRL_TX_FLUSH;
+
+ ret = wl12xx_cmd_send(wl, CMD_START_JOIN, &join, sizeof(join));
+ if (ret < 0) {
+ wl12xx_error("failed to initiate cmd join");
+ return ret;
+ }
+
+ timeout = msecs_to_jiffies(JOIN_TIMEOUT);
+
+ /*
+ * ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to
+ * simplify locking we just sleep instead, for now
+ */
+ if (wait)
+ msleep(10);
+
+ return 0;
+}
+
+int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode)
+{
+ int ret;
+ struct acx_ps_params ps_params;
+
+ /* FIXME: this should be in ps.c */
+ ret = wl12xx_acx_wake_up_conditions(wl, wl->listen_int);
+ if (ret < 0) {
+ wl12xx_error("Couldnt set wake up conditions");
+ return ret;
+ }
+
+ wl12xx_debug(DEBUG_CMD, "cmd set ps mode");
+
+ ps_params.ps_mode = ps_mode;
+ ps_params.send_null_data = 1;
+ ps_params.retries = 5;
+ ps_params.hang_over_period = 128;
+ ps_params.null_data_rate = 1; /* 1 Mbps */
+
+ ret = wl12xx_cmd_send(wl, CMD_SET_PS_MODE, &ps_params,
+ sizeof(ps_params));
+ if (ret < 0) {
+ wl12xx_error("cmd set_ps_mode failed");
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer)
+{
+ struct cmd_read_write_memory mem_cmd, *mem_answer;
+ struct wl12xx_command cmd;
+ int ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd read memory");
+
+ memset(&mem_cmd, 0, sizeof(mem_cmd));
+ mem_cmd.addr = addr;
+ mem_cmd.size = len;
+
+ ret = wl12xx_cmd_send(wl, CMD_READ_MEMORY, &mem_cmd, sizeof(mem_cmd));
+ if (ret < 0) {
+ wl12xx_error("read memory command failed: %d", ret);
+ return ret;
+ }
+
+ /* the read command got in, we can now read the answer */
+ wl12xx_spi_mem_read(wl, wl->cmd_box_addr, &cmd,
+ CMDMBOX_HEADER_LEN + sizeof(mem_cmd));
+
+ if (cmd.status != CMD_STATUS_SUCCESS)
+ wl12xx_error("error in read command result: %d", cmd.status);
+
+ mem_answer = (struct cmd_read_write_memory *) cmd.parameters;
+ memcpy(answer, mem_answer->value, len);
+
+ return 0;
+}
+
+int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id,
+ void *buf, size_t buf_len)
+{
+ struct wl12xx_cmd_packet_template template;
+ int ret;
+
+ wl12xx_debug(DEBUG_CMD, "cmd template %d", cmd_id);
+
+ memset(&template, 0, sizeof(template));
+
+ WARN_ON(buf_len > WL12XX_MAX_TEMPLATE_SIZE);
+ buf_len = min_t(size_t, buf_len, WL12XX_MAX_TEMPLATE_SIZE);
+ template.size = cpu_to_le16(buf_len);
+
+ if (buf)
+ memcpy(template.template, buf, buf_len);
+
+ ret = wl12xx_cmd_send(wl, cmd_id, &template,
+ sizeof(template.size) + buf_len);
+ if (ret < 0) {
+ wl12xx_warning("cmd set_template failed: %d", ret);
+ return ret;
+ }
+
+ return 0;
+}
diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h
new file mode 100644
index 000000000000..aa307dcd081f
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/cmd.h
@@ -0,0 +1,265 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_CMD_H__
+#define __WL12XX_CMD_H__
+
+#include "wl12xx.h"
+
+int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len);
+int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer);
+int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len,
+ void *answer);
+int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len);
+int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity,
+ void *bitmap, u16 bitmap_len, u8 bitmap_control);
+int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable);
+int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval,
+ u16 beacon_interval, u8 wait);
+int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode);
+int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer);
+int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id,
+ void *buf, size_t buf_len);
+
+/* unit ms */
+#define WL12XX_COMMAND_TIMEOUT 2000
+
+#define WL12XX_MAX_TEMPLATE_SIZE 300
+
+struct wl12xx_cmd_packet_template {
+ __le16 size;
+ u8 template[WL12XX_MAX_TEMPLATE_SIZE];
+} __attribute__ ((packed));
+
+enum wl12xx_commands {
+ CMD_RESET = 0,
+ CMD_INTERROGATE = 1, /*use this to read information elements*/
+ CMD_CONFIGURE = 2, /*use this to write information elements*/
+ CMD_ENABLE_RX = 3,
+ CMD_ENABLE_TX = 4,
+ CMD_DISABLE_RX = 5,
+ CMD_DISABLE_TX = 6,
+ CMD_SCAN = 8,
+ CMD_STOP_SCAN = 9,
+ CMD_VBM = 10,
+ CMD_START_JOIN = 11,
+ CMD_SET_KEYS = 12,
+ CMD_READ_MEMORY = 13,
+ CMD_WRITE_MEMORY = 14,
+ CMD_BEACON = 19,
+ CMD_PROBE_RESP = 20,
+ CMD_NULL_DATA = 21,
+ CMD_PROBE_REQ = 22,
+ CMD_TEST = 23,
+ CMD_RADIO_CALIBRATE = 25, /* OBSOLETE */
+ CMD_ENABLE_RX_PATH = 27, /* OBSOLETE */
+ CMD_NOISE_HIST = 28,
+ CMD_RX_RESET = 29,
+ CMD_PS_POLL = 30,
+ CMD_QOS_NULL_DATA = 31,
+ CMD_LNA_CONTROL = 32,
+ CMD_SET_BCN_MODE = 33,
+ CMD_MEASUREMENT = 34,
+ CMD_STOP_MEASUREMENT = 35,
+ CMD_DISCONNECT = 36,
+ CMD_SET_PS_MODE = 37,
+ CMD_CHANNEL_SWITCH = 38,
+ CMD_STOP_CHANNEL_SWICTH = 39,
+ CMD_AP_DISCOVERY = 40,
+ CMD_STOP_AP_DISCOVERY = 41,
+ CMD_SPS_SCAN = 42,
+ CMD_STOP_SPS_SCAN = 43,
+ CMD_HEALTH_CHECK = 45,
+ CMD_DEBUG = 46,
+ CMD_TRIGGER_SCAN_TO = 47,
+
+ NUM_COMMANDS,
+ MAX_COMMAND_ID = 0xFFFF,
+};
+
+#define MAX_CMD_PARAMS 572
+
+struct wl12xx_command {
+ u16 id;
+ u16 status;
+ u8 parameters[MAX_CMD_PARAMS];
+};
+
+enum {
+ CMD_MAILBOX_IDLE = 0,
+ CMD_STATUS_SUCCESS = 1,
+ CMD_STATUS_UNKNOWN_CMD = 2,
+ CMD_STATUS_UNKNOWN_IE = 3,
+ CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
+ CMD_STATUS_RX_BUSY = 13,
+ CMD_STATUS_INVALID_PARAM = 14,
+ CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
+ CMD_STATUS_OUT_OF_MEMORY = 16,
+ CMD_STATUS_STA_TABLE_FULL = 17,
+ CMD_STATUS_RADIO_ERROR = 18,
+ CMD_STATUS_WRONG_NESTING = 19,
+ CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
+ CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
+ MAX_COMMAND_STATUS = 0xff
+};
+
+
+/*
+ * CMD_READ_MEMORY
+ *
+ * The host issues this command to read the WiLink device memory/registers.
+ *
+ * Note: The Base Band address has special handling (16 bits registers and
+ * addresses). For more information, see the hardware specification.
+ */
+/*
+ * CMD_WRITE_MEMORY
+ *
+ * The host issues this command to write the WiLink device memory/registers.
+ *
+ * The Base Band address has special handling (16 bits registers and
+ * addresses). For more information, see the hardware specification.
+ */
+#define MAX_READ_SIZE 256
+
+struct cmd_read_write_memory {
+ /* The address of the memory to read from or write to.*/
+ u32 addr;
+
+ /* The amount of data in bytes to read from or write to the WiLink
+ * device.*/
+ u32 size;
+
+ /* The actual value read from or written to the Wilink. The source
+ of this field is the Host in WRITE command or the Wilink in READ
+ command. */
+ u8 value[MAX_READ_SIZE];
+};
+
+#define CMDMBOX_HEADER_LEN 4
+#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
+
+
+struct basic_scan_parameters {
+ u32 rx_config_options;
+ u32 rx_filter_options;
+
+ /*
+ * Scan options:
+ * bit 0: When this bit is set, passive scan.
+ * bit 1: Band, when this bit is set we scan
+ * in the 5Ghz band.
+ * bit 2: voice mode, 0 for normal scan.
+ * bit 3: scan priority, 1 for high priority.
+ */
+ u16 scan_options;
+
+ /* Number of channels to scan */
+ u8 num_channels;
+
+ /* Number opf probe requests to send, per channel */
+ u8 num_probe_requests;
+
+ /* Rate and modulation for probe requests */
+ u16 tx_rate;
+
+ u8 tid_trigger;
+ u8 ssid_len;
+ u32 ssid[8];
+
+} __attribute__ ((packed));
+
+struct basic_scan_channel_parameters {
+ u32 min_duration; /* in TU */
+ u32 max_duration; /* in TU */
+ u32 bssid_lsb;
+ u16 bssid_msb;
+
+ /*
+ * bits 0-3: Early termination count.
+ * bits 4-5: Early termination condition.
+ */
+ u8 early_termination;
+
+ u8 tx_power_att;
+ u8 channel;
+ u8 pad[3];
+} __attribute__ ((packed));
+
+/* SCAN parameters */
+#define SCAN_MAX_NUM_OF_CHANNELS 16
+
+struct cmd_scan {
+ struct basic_scan_parameters params;
+ struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
+} __attribute__ ((packed));
+
+enum {
+ BSS_TYPE_IBSS = 0,
+ BSS_TYPE_STA_BSS = 2,
+ BSS_TYPE_AP_BSS = 3,
+ MAX_BSS_TYPE = 0xFF
+};
+
+#define JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
+#define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE 0x01 /* Early wakeup time */
+
+
+struct cmd_join {
+ u32 bssid_lsb;
+ u16 bssid_msb;
+ u16 beacon_interval; /* in TBTTs */
+ u32 rx_config_options;
+ u32 rx_filter_options;
+
+ /*
+ * The target uses this field to determine the rate at
+ * which to transmit control frame responses (such as
+ * ACK or CTS frames).
+ */
+ u16 basic_rate_set;
+ u8 dtim_interval;
+ u8 tx_ctrl_frame_rate; /* OBSOLETE */
+ u8 tx_ctrl_frame_mod; /* OBSOLETE */
+ /*
+ * bits 0-2: This bitwise field specifies the type
+ * of BSS to start or join (BSS_TYPE_*).
+ * bit 4: Band - The radio band in which to join
+ * or start.
+ * 0 - 2.4GHz band
+ * 1 - 5GHz band
+ * bits 3, 5-7: Reserved
+ */
+ u8 bss_type;
+ u8 channel;
+ u8 ssid_len;
+ u8 ssid[IW_ESSID_MAX_SIZE];
+ u8 ctrl; /* JOIN_CMD_CTRL_* */
+ u8 tx_mgt_frame_rate; /* OBSOLETE */
+ u8 tx_mgt_frame_mod; /* OBSOLETE */
+ u8 reserved;
+} __attribute__ ((packed));
+
+
+#endif /* __WL12XX_CMD_H__ */
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c
new file mode 100644
index 000000000000..cdb368ce4dae
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/debugfs.c
@@ -0,0 +1,508 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "debugfs.h"
+
+#include <linux/skbuff.h>
+
+#include "wl12xx.h"
+#include "acx.h"
+
+/* ms */
+#define WL12XX_DEBUGFS_STATS_LIFETIME 1000
+
+/* debugfs macros idea from mac80211 */
+
+#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
+static ssize_t name## _read(struct file *file, char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ struct wl12xx *wl = file->private_data; \
+ char buf[buflen]; \
+ int res; \
+ \
+ res = scnprintf(buf, buflen, fmt "\n", ##value); \
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+} \
+ \
+static const struct file_operations name## _ops = { \
+ .read = name## _read, \
+ .open = wl12xx_open_file_generic, \
+};
+
+#define DEBUGFS_ADD(name, parent) \
+ wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
+ wl, &name## _ops); \
+ if (IS_ERR(wl->debugfs.name)) { \
+ ret = PTR_ERR(wl->debugfs.name); \
+ wl->debugfs.name = NULL; \
+ goto out; \
+ }
+
+#define DEBUGFS_DEL(name) \
+ do { \
+ debugfs_remove(wl->debugfs.name); \
+ wl->debugfs.name = NULL; \
+ } while (0)
+
+#define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \
+static ssize_t sub## _ ##name## _read(struct file *file, \
+ char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ struct wl12xx *wl = file->private_data; \
+ char buf[buflen]; \
+ int res; \
+ \
+ wl12xx_debugfs_update_stats(wl); \
+ \
+ res = scnprintf(buf, buflen, fmt "\n", \
+ wl->stats.fw_stats->sub.name); \
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+} \
+ \
+static const struct file_operations sub## _ ##name## _ops = { \
+ .read = sub## _ ##name## _read, \
+ .open = wl12xx_open_file_generic, \
+};
+
+#define DEBUGFS_FWSTATS_ADD(sub, name) \
+ DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)
+
+#define DEBUGFS_FWSTATS_DEL(sub, name) \
+ DEBUGFS_DEL(sub## _ ##name)
+
+static void wl12xx_debugfs_update_stats(struct wl12xx *wl)
+{
+ mutex_lock(&wl->mutex);
+
+ if (wl->state == WL12XX_STATE_ON &&
+ time_after(jiffies, wl->stats.fw_stats_update +
+ msecs_to_jiffies(WL12XX_DEBUGFS_STATS_LIFETIME))) {
+ wl12xx_acx_statistics(wl, wl->stats.fw_stats);
+ wl->stats.fw_stats_update = jiffies;
+ }
+
+ mutex_unlock(&wl->mutex);
+}
+
+static int wl12xx_open_file_generic(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
+}
+
+DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u");
+DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u");
+DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u");
+DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u");
+DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u");
+DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u");
+/* skipping wep.reserved */
+DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u");
+DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u");
+DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u");
+DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u");
+DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u");
+/* skipping cont_miss_bcns_spread for now */
+DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u");
+DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u");
+DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u");
+DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u");
+DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u");
+DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u");
+DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u");
+DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u");
+DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u");
+DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u");
+DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u");
+DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u");
+DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u");
+DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u");
+
+DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
+ 20, "%u");
+DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u");
+DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u");
+
+DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
+DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
+ wl->stats.excessive_retries);
+
+static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct wl12xx *wl = file->private_data;
+ u32 queue_len;
+ char buf[20];
+ int res;
+
+ queue_len = skb_queue_len(&wl->tx_queue);
+
+ res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+
+static const struct file_operations tx_queue_len_ops = {
+ .read = tx_queue_len_read,
+ .open = wl12xx_open_file_generic,
+};
+
+static void wl12xx_debugfs_delete_files(struct wl12xx *wl)
+{
+ DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
+
+ DEBUGFS_FWSTATS_DEL(rx, out_of_mem);
+ DEBUGFS_FWSTATS_DEL(rx, hdr_overflow);
+ DEBUGFS_FWSTATS_DEL(rx, hw_stuck);
+ DEBUGFS_FWSTATS_DEL(rx, dropped);
+ DEBUGFS_FWSTATS_DEL(rx, fcs_err);
+ DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig);
+ DEBUGFS_FWSTATS_DEL(rx, path_reset);
+ DEBUGFS_FWSTATS_DEL(rx, reset_counter);
+
+ DEBUGFS_FWSTATS_DEL(dma, rx_requested);
+ DEBUGFS_FWSTATS_DEL(dma, rx_errors);
+ DEBUGFS_FWSTATS_DEL(dma, tx_requested);
+ DEBUGFS_FWSTATS_DEL(dma, tx_errors);
+
+ DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt);
+ DEBUGFS_FWSTATS_DEL(isr, fiqs);
+ DEBUGFS_FWSTATS_DEL(isr, rx_headers);
+ DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow);
+ DEBUGFS_FWSTATS_DEL(isr, rx_rdys);
+ DEBUGFS_FWSTATS_DEL(isr, irqs);
+ DEBUGFS_FWSTATS_DEL(isr, tx_procs);
+ DEBUGFS_FWSTATS_DEL(isr, decrypt_done);
+ DEBUGFS_FWSTATS_DEL(isr, dma0_done);
+ DEBUGFS_FWSTATS_DEL(isr, dma1_done);
+ DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete);
+ DEBUGFS_FWSTATS_DEL(isr, commands);
+ DEBUGFS_FWSTATS_DEL(isr, rx_procs);
+ DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes);
+ DEBUGFS_FWSTATS_DEL(isr, host_acknowledges);
+ DEBUGFS_FWSTATS_DEL(isr, pci_pm);
+ DEBUGFS_FWSTATS_DEL(isr, wakeups);
+ DEBUGFS_FWSTATS_DEL(isr, low_rssi);
+
+ DEBUGFS_FWSTATS_DEL(wep, addr_key_count);
+ DEBUGFS_FWSTATS_DEL(wep, default_key_count);
+ /* skipping wep.reserved */
+ DEBUGFS_FWSTATS_DEL(wep, key_not_found);
+ DEBUGFS_FWSTATS_DEL(wep, decrypt_fail);
+ DEBUGFS_FWSTATS_DEL(wep, packets);
+ DEBUGFS_FWSTATS_DEL(wep, interrupt);
+
+ DEBUGFS_FWSTATS_DEL(pwr, ps_enter);
+ DEBUGFS_FWSTATS_DEL(pwr, elp_enter);
+ DEBUGFS_FWSTATS_DEL(pwr, missing_bcns);
+ DEBUGFS_FWSTATS_DEL(pwr, wake_on_host);
+ DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp);
+ DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps);
+ DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps);
+ DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons);
+ DEBUGFS_FWSTATS_DEL(pwr, power_save_off);
+ DEBUGFS_FWSTATS_DEL(pwr, enable_ps);
+ DEBUGFS_FWSTATS_DEL(pwr, disable_ps);
+ DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps);
+ /* skipping cont_miss_bcns_spread for now */
+ DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons);
+
+ DEBUGFS_FWSTATS_DEL(mic, rx_pkts);
+ DEBUGFS_FWSTATS_DEL(mic, calc_failure);
+
+ DEBUGFS_FWSTATS_DEL(aes, encrypt_fail);
+ DEBUGFS_FWSTATS_DEL(aes, decrypt_fail);
+ DEBUGFS_FWSTATS_DEL(aes, encrypt_packets);
+ DEBUGFS_FWSTATS_DEL(aes, decrypt_packets);
+ DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt);
+ DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt);
+
+ DEBUGFS_FWSTATS_DEL(event, heart_beat);
+ DEBUGFS_FWSTATS_DEL(event, calibration);
+ DEBUGFS_FWSTATS_DEL(event, rx_mismatch);
+ DEBUGFS_FWSTATS_DEL(event, rx_mem_empty);
+ DEBUGFS_FWSTATS_DEL(event, rx_pool);
+ DEBUGFS_FWSTATS_DEL(event, oom_late);
+ DEBUGFS_FWSTATS_DEL(event, phy_transmit_error);
+ DEBUGFS_FWSTATS_DEL(event, tx_stuck);
+
+ DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts);
+ DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts);
+ DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime);
+ DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn);
+ DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn);
+ DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization);
+ DEBUGFS_FWSTATS_DEL(ps, upsd_utilization);
+
+ DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop);
+ DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data);
+ DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
+ DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data);
+ DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data);
+
+ DEBUGFS_DEL(tx_queue_len);
+ DEBUGFS_DEL(retry_count);
+ DEBUGFS_DEL(excessive_retries);
+}
+
+static int wl12xx_debugfs_add_files(struct wl12xx *wl)
+{
+ int ret = 0;
+
+ DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
+
+ DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
+ DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
+ DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
+ DEBUGFS_FWSTATS_ADD(rx, dropped);
+ DEBUGFS_FWSTATS_ADD(rx, fcs_err);
+ DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
+ DEBUGFS_FWSTATS_ADD(rx, path_reset);
+ DEBUGFS_FWSTATS_ADD(rx, reset_counter);
+
+ DEBUGFS_FWSTATS_ADD(dma, rx_requested);
+ DEBUGFS_FWSTATS_ADD(dma, rx_errors);
+ DEBUGFS_FWSTATS_ADD(dma, tx_requested);
+ DEBUGFS_FWSTATS_ADD(dma, tx_errors);
+
+ DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
+ DEBUGFS_FWSTATS_ADD(isr, fiqs);
+ DEBUGFS_FWSTATS_ADD(isr, rx_headers);
+ DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
+ DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
+ DEBUGFS_FWSTATS_ADD(isr, irqs);
+ DEBUGFS_FWSTATS_ADD(isr, tx_procs);
+ DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
+ DEBUGFS_FWSTATS_ADD(isr, dma0_done);
+ DEBUGFS_FWSTATS_ADD(isr, dma1_done);
+ DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
+ DEBUGFS_FWSTATS_ADD(isr, commands);
+ DEBUGFS_FWSTATS_ADD(isr, rx_procs);
+ DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
+ DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
+ DEBUGFS_FWSTATS_ADD(isr, pci_pm);
+ DEBUGFS_FWSTATS_ADD(isr, wakeups);
+ DEBUGFS_FWSTATS_ADD(isr, low_rssi);
+
+ DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
+ DEBUGFS_FWSTATS_ADD(wep, default_key_count);
+ /* skipping wep.reserved */
+ DEBUGFS_FWSTATS_ADD(wep, key_not_found);
+ DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
+ DEBUGFS_FWSTATS_ADD(wep, packets);
+ DEBUGFS_FWSTATS_ADD(wep, interrupt);
+
+ DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
+ DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
+ DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
+ DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
+ DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
+ DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
+ DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
+ DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
+ DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
+ DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
+ DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
+ DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
+ /* skipping cont_miss_bcns_spread for now */
+ DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
+
+ DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
+ DEBUGFS_FWSTATS_ADD(mic, calc_failure);
+
+ DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
+ DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
+ DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
+ DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
+ DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
+ DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
+
+ DEBUGFS_FWSTATS_ADD(event, heart_beat);
+ DEBUGFS_FWSTATS_ADD(event, calibration);
+ DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
+ DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
+ DEBUGFS_FWSTATS_ADD(event, rx_pool);
+ DEBUGFS_FWSTATS_ADD(event, oom_late);
+ DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
+ DEBUGFS_FWSTATS_ADD(event, tx_stuck);
+
+ DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
+ DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
+ DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
+ DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
+ DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
+ DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
+ DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
+
+ DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
+ DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
+ DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
+ DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
+ DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
+
+ DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir);
+ DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
+ DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
+
+out:
+ if (ret < 0)
+ wl12xx_debugfs_delete_files(wl);
+
+ return ret;
+}
+
+void wl12xx_debugfs_reset(struct wl12xx *wl)
+{
+ memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
+ wl->stats.retry_count = 0;
+ wl->stats.excessive_retries = 0;
+}
+
+int wl12xx_debugfs_init(struct wl12xx *wl)
+{
+ int ret;
+
+ wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
+
+ if (IS_ERR(wl->debugfs.rootdir)) {
+ ret = PTR_ERR(wl->debugfs.rootdir);
+ wl->debugfs.rootdir = NULL;
+ goto err;
+ }
+
+ wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics",
+ wl->debugfs.rootdir);
+
+ if (IS_ERR(wl->debugfs.fw_statistics)) {
+ ret = PTR_ERR(wl->debugfs.fw_statistics);
+ wl->debugfs.fw_statistics = NULL;
+ goto err_root;
+ }
+
+ wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
+ GFP_KERNEL);
+
+ if (!wl->stats.fw_stats) {
+ ret = -ENOMEM;
+ goto err_fw;
+ }
+
+ wl->stats.fw_stats_update = jiffies;
+
+ ret = wl12xx_debugfs_add_files(wl);
+
+ if (ret < 0)
+ goto err_file;
+
+ return 0;
+
+err_file:
+ kfree(wl->stats.fw_stats);
+ wl->stats.fw_stats = NULL;
+
+err_fw:
+ debugfs_remove(wl->debugfs.fw_statistics);
+ wl->debugfs.fw_statistics = NULL;
+
+err_root:
+ debugfs_remove(wl->debugfs.rootdir);
+ wl->debugfs.rootdir = NULL;
+
+err:
+ return ret;
+}
+
+void wl12xx_debugfs_exit(struct wl12xx *wl)
+{
+ wl12xx_debugfs_delete_files(wl);
+
+ kfree(wl->stats.fw_stats);
+ wl->stats.fw_stats = NULL;
+
+ debugfs_remove(wl->debugfs.fw_statistics);
+ wl->debugfs.fw_statistics = NULL;
+
+ debugfs_remove(wl->debugfs.rootdir);
+ wl->debugfs.rootdir = NULL;
+
+}
diff --git a/drivers/net/wireless/wl12xx/debugfs.h b/drivers/net/wireless/wl12xx/debugfs.h
new file mode 100644
index 000000000000..562cdcbcc874
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/debugfs.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef WL12XX_DEBUGFS_H
+#define WL12XX_DEBUGFS_H
+
+#include "wl12xx.h"
+
+int wl12xx_debugfs_init(struct wl12xx *wl);
+void wl12xx_debugfs_exit(struct wl12xx *wl);
+void wl12xx_debugfs_reset(struct wl12xx *wl);
+
+#endif /* WL12XX_DEBUGFS_H */
diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c
new file mode 100644
index 000000000000..99529ca89a7e
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/event.c
@@ -0,0 +1,127 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "wl12xx.h"
+#include "reg.h"
+#include "spi.h"
+#include "event.h"
+#include "ps.h"
+
+static int wl12xx_event_scan_complete(struct wl12xx *wl,
+ struct event_mailbox *mbox)
+{
+ wl12xx_debug(DEBUG_EVENT, "status: 0x%x, channels: %d",
+ mbox->scheduled_scan_status,
+ mbox->scheduled_scan_channels);
+
+ if (wl->scanning) {
+ mutex_unlock(&wl->mutex);
+ ieee80211_scan_completed(wl->hw, false);
+ mutex_lock(&wl->mutex);
+ wl->scanning = false;
+ }
+
+ return 0;
+}
+
+static void wl12xx_event_mbox_dump(struct event_mailbox *mbox)
+{
+ wl12xx_debug(DEBUG_EVENT, "MBOX DUMP:");
+ wl12xx_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector);
+ wl12xx_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask);
+}
+
+static int wl12xx_event_process(struct wl12xx *wl, struct event_mailbox *mbox)
+{
+ int ret;
+ u32 vector;
+
+ wl12xx_event_mbox_dump(mbox);
+
+ vector = mbox->events_vector & ~(mbox->events_mask);
+ wl12xx_debug(DEBUG_EVENT, "vector: 0x%x", vector);
+
+ if (vector & SCAN_COMPLETE_EVENT_ID) {
+ ret = wl12xx_event_scan_complete(wl, mbox);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (vector & BSS_LOSE_EVENT_ID) {
+ wl12xx_debug(DEBUG_EVENT, "BSS_LOSE_EVENT");
+
+ if (wl->psm_requested && wl->psm) {
+ ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+int wl12xx_event_unmask(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_event_mbox_mask(wl, ~(wl->event_mask));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+void wl12xx_event_mbox_config(struct wl12xx *wl)
+{
+ wl->mbox_ptr[0] = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR);
+ wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox);
+
+ wl12xx_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x",
+ wl->mbox_ptr[0], wl->mbox_ptr[1]);
+}
+
+int wl12xx_event_handle(struct wl12xx *wl, u8 mbox_num)
+{
+ struct event_mailbox mbox;
+ int ret;
+
+ wl12xx_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num);
+
+ if (mbox_num > 1)
+ return -EINVAL;
+
+ /* first we read the mbox descriptor */
+ wl12xx_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox,
+ sizeof(struct event_mailbox));
+
+ /* process the descriptor */
+ ret = wl12xx_event_process(wl, &mbox);
+ if (ret < 0)
+ return ret;
+
+ /* then we let the firmware know it can go on...*/
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK);
+
+ return 0;
+}
diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/event.h
new file mode 100644
index 000000000000..1f4c2f7438a7
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/event.h
@@ -0,0 +1,121 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_EVENT_H__
+#define __WL12XX_EVENT_H__
+
+/*
+ * Mbox events
+ *
+ * The event mechanism is based on a pair of event buffers (buffers A and
+ * B) at fixed locations in the target's memory. The host processes one
+ * buffer while the other buffer continues to collect events. If the host
+ * is not processing events, an interrupt is issued to signal that a buffer
+ * is ready. Once the host is done with processing events from one buffer,
+ * it signals the target (with an ACK interrupt) that the event buffer is
+ * free.
+ */
+
+enum {
+ RESERVED1_EVENT_ID = BIT(0),
+ RESERVED2_EVENT_ID = BIT(1),
+ MEASUREMENT_START_EVENT_ID = BIT(2),
+ SCAN_COMPLETE_EVENT_ID = BIT(3),
+ CALIBRATION_COMPLETE_EVENT_ID = BIT(4),
+ ROAMING_TRIGGER_LOW_RSSI_EVENT_ID = BIT(5),
+ PS_REPORT_EVENT_ID = BIT(6),
+ SYNCHRONIZATION_TIMEOUT_EVENT_ID = BIT(7),
+ HEALTH_REPORT_EVENT_ID = BIT(8),
+ ACI_DETECTION_EVENT_ID = BIT(9),
+ DEBUG_REPORT_EVENT_ID = BIT(10),
+ MAC_STATUS_EVENT_ID = BIT(11),
+ DISCONNECT_EVENT_COMPLETE_ID = BIT(12),
+ JOIN_EVENT_COMPLETE_ID = BIT(13),
+ CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(14),
+ BSS_LOSE_EVENT_ID = BIT(15),
+ ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID = BIT(16),
+ MEASUREMENT_COMPLETE_EVENT_ID = BIT(17),
+ AP_DISCOVERY_COMPLETE_EVENT_ID = BIT(18),
+ SCHEDULED_SCAN_COMPLETE_EVENT_ID = BIT(19),
+ PSPOLL_DELIVERY_FAILURE_EVENT_ID = BIT(20),
+ RESET_BSS_EVENT_ID = BIT(21),
+ REGAINED_BSS_EVENT_ID = BIT(22),
+ ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID = BIT(23),
+ ROAMING_TRIGGER_LOW_SNR_EVENT_ID = BIT(24),
+ ROAMING_TRIGGER_REGAINED_SNR_EVENT_ID = BIT(25),
+
+ DBG_EVENT_ID = BIT(26),
+ BT_PTA_SENSE_EVENT_ID = BIT(27),
+ BT_PTA_PREDICTION_EVENT_ID = BIT(28),
+ BT_PTA_AVALANCHE_EVENT_ID = BIT(29),
+
+ PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(30),
+
+ EVENT_MBOX_ALL_EVENT_ID = 0x7fffffff,
+};
+
+struct event_debug_report {
+ u8 debug_event_id;
+ u8 num_params;
+ u16 pad;
+ u32 report_1;
+ u32 report_2;
+ u32 report_3;
+} __attribute__ ((packed));
+
+struct event_mailbox {
+ u32 events_vector;
+ u32 events_mask;
+ u32 reserved_1;
+ u32 reserved_2;
+
+ char average_rssi_level;
+ u8 ps_status;
+ u8 channel_switch_status;
+ u8 scheduled_scan_status;
+
+ /* Channels scanned by the scheduled scan */
+ u16 scheduled_scan_channels;
+
+ /* If bit 0 is set -> target's fatal error */
+ u16 health_report;
+ u16 bad_fft_counter;
+ u8 bt_pta_sense_info;
+ u8 bt_pta_protective_info;
+ u32 reserved;
+ u32 debug_report[2];
+
+ /* Number of FCS errors since last event */
+ u32 fcs_err_counter;
+
+ struct event_debug_report report;
+ u8 average_snr_level;
+ u8 padding[19];
+} __attribute__ ((packed));
+
+int wl12xx_event_unmask(struct wl12xx *wl);
+void wl12xx_event_mbox_config(struct wl12xx *wl);
+int wl12xx_event_handle(struct wl12xx *wl, u8 mbox);
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c
new file mode 100644
index 000000000000..2a573a6010bd
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/init.c
@@ -0,0 +1,200 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "init.h"
+#include "wl12xx_80211.h"
+#include "acx.h"
+#include "cmd.h"
+
+int wl12xx_hw_init_hwenc_config(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_feature_cfg(wl);
+ if (ret < 0) {
+ wl12xx_warning("couldn't set feature config");
+ return ret;
+ }
+
+ ret = wl12xx_acx_default_key(wl, wl->default_key);
+ if (ret < 0) {
+ wl12xx_warning("couldn't set default key");
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_hw_init_templates_config(struct wl12xx *wl)
+{
+ int ret;
+ u8 partial_vbm[PARTIAL_VBM_MAX];
+
+ /* send empty templates for fw memory reservation */
+ ret = wl12xx_cmd_template_set(wl, CMD_PROBE_REQ, NULL,
+ sizeof(struct wl12xx_probe_req_template));
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_template_set(wl, CMD_NULL_DATA, NULL,
+ sizeof(struct wl12xx_null_data_template));
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_template_set(wl, CMD_PS_POLL, NULL,
+ sizeof(struct wl12xx_ps_poll_template));
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL,
+ sizeof
+ (struct wl12xx_qos_null_data_template));
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_template_set(wl, CMD_PROBE_RESP, NULL,
+ sizeof
+ (struct wl12xx_probe_resp_template));
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_template_set(wl, CMD_BEACON, NULL,
+ sizeof
+ (struct wl12xx_beacon_template));
+ if (ret < 0)
+ return ret;
+
+ /* tim templates, first reserve space then allocate an empty one */
+ memset(partial_vbm, 0, PARTIAL_VBM_MAX);
+ ret = wl12xx_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_rx_config(struct wl12xx *wl, u32 config, u32 filter)
+{
+ int ret;
+
+ ret = wl12xx_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_rx_config(wl, config, filter);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_phy_config(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_pd_threshold(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_slot(wl, DEFAULT_SLOT_TIME);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_group_address_tbl(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_service_period_timeout(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_rts_threshold(wl, RTS_THRESHOLD_DEF);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_beacon_filter(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_beacon_filter_opt(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_beacon_filter_table(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_pta(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_sg_enable(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_acx_sg_cfg(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_energy_detection(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_cca_threshold(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_beacon_broadcast(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl12xx_acx_bcn_dtim_options(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_hw_init_power_auth(struct wl12xx *wl)
+{
+ return wl12xx_acx_sleep_auth(wl, WL12XX_PSM_CAM);
+}
diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h
new file mode 100644
index 000000000000..c8b6cd0b7c3e
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/init.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_INIT_H__
+#define __WL12XX_INIT_H__
+
+#include "wl12xx.h"
+
+int wl12xx_hw_init_hwenc_config(struct wl12xx *wl);
+int wl12xx_hw_init_templates_config(struct wl12xx *wl);
+int wl12xx_hw_init_mem_config(struct wl12xx *wl);
+int wl12xx_hw_init_rx_config(struct wl12xx *wl, u32 config, u32 filter);
+int wl12xx_hw_init_phy_config(struct wl12xx *wl);
+int wl12xx_hw_init_beacon_filter(struct wl12xx *wl);
+int wl12xx_hw_init_pta(struct wl12xx *wl);
+int wl12xx_hw_init_energy_detection(struct wl12xx *wl);
+int wl12xx_hw_init_beacon_broadcast(struct wl12xx *wl);
+int wl12xx_hw_init_power_auth(struct wl12xx *wl);
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
new file mode 100644
index 000000000000..603d6114882e
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -0,0 +1,1358 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008-2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/firmware.h>
+#include <linux/delay.h>
+#include <linux/irq.h>
+#include <linux/spi/spi.h>
+#include <linux/crc32.h>
+#include <linux/etherdevice.h>
+#include <linux/spi/wl12xx.h>
+
+#include "wl12xx.h"
+#include "wl12xx_80211.h"
+#include "reg.h"
+#include "wl1251.h"
+#include "spi.h"
+#include "event.h"
+#include "tx.h"
+#include "rx.h"
+#include "ps.h"
+#include "init.h"
+#include "debugfs.h"
+
+static void wl12xx_disable_interrupts(struct wl12xx *wl)
+{
+ disable_irq(wl->irq);
+}
+
+static void wl12xx_power_off(struct wl12xx *wl)
+{
+ wl->set_power(false);
+}
+
+static void wl12xx_power_on(struct wl12xx *wl)
+{
+ wl->set_power(true);
+}
+
+static irqreturn_t wl12xx_irq(int irq, void *cookie)
+{
+ struct wl12xx *wl;
+
+ wl12xx_debug(DEBUG_IRQ, "IRQ");
+
+ wl = cookie;
+
+ schedule_work(&wl->irq_work);
+
+ return IRQ_HANDLED;
+}
+
+static int wl12xx_fetch_firmware(struct wl12xx *wl)
+{
+ const struct firmware *fw;
+ int ret;
+
+ ret = request_firmware(&fw, wl->chip.fw_filename, &wl->spi->dev);
+
+ if (ret < 0) {
+ wl12xx_error("could not get firmware: %d", ret);
+ return ret;
+ }
+
+ if (fw->size % 4) {
+ wl12xx_error("firmware size is not multiple of 32 bits: %zu",
+ fw->size);
+ ret = -EILSEQ;
+ goto out;
+ }
+
+ wl->fw_len = fw->size;
+ wl->fw = kmalloc(wl->fw_len, GFP_KERNEL);
+
+ if (!wl->fw) {
+ wl12xx_error("could not allocate memory for the firmware");
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ memcpy(wl->fw, fw->data, wl->fw_len);
+
+ ret = 0;
+
+out:
+ release_firmware(fw);
+
+ return ret;
+}
+
+static int wl12xx_fetch_nvs(struct wl12xx *wl)
+{
+ const struct firmware *fw;
+ int ret;
+
+ ret = request_firmware(&fw, wl->chip.nvs_filename, &wl->spi->dev);
+
+ if (ret < 0) {
+ wl12xx_error("could not get nvs file: %d", ret);
+ return ret;
+ }
+
+ if (fw->size % 4) {
+ wl12xx_error("nvs size is not multiple of 32 bits: %zu",
+ fw->size);
+ ret = -EILSEQ;
+ goto out;
+ }
+
+ wl->nvs_len = fw->size;
+ wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL);
+
+ if (!wl->nvs) {
+ wl12xx_error("could not allocate memory for the nvs file");
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ memcpy(wl->nvs, fw->data, wl->nvs_len);
+
+ ret = 0;
+
+out:
+ release_firmware(fw);
+
+ return ret;
+}
+
+static void wl12xx_fw_wakeup(struct wl12xx *wl)
+{
+ u32 elp_reg;
+
+ elp_reg = ELPCTRL_WAKE_UP;
+ wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
+ elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
+
+ if (!(elp_reg & ELPCTRL_WLAN_READY)) {
+ wl12xx_warning("WLAN not ready");
+ elp_reg = ELPCTRL_WAKE_UP_WLAN_READY;
+ wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
+ }
+}
+
+static int wl12xx_chip_wakeup(struct wl12xx *wl)
+{
+ int ret = 0;
+
+ wl12xx_power_on(wl);
+ msleep(wl->chip.power_on_sleep);
+ wl12xx_spi_reset(wl);
+ wl12xx_spi_init(wl);
+
+ /* We don't need a real memory partition here, because we only want
+ * to use the registers at this point. */
+ wl12xx_set_partition(wl,
+ 0x00000000,
+ 0x00000000,
+ REGISTERS_BASE,
+ REGISTERS_DOWN_SIZE);
+
+ /* ELP module wake up */
+ wl12xx_fw_wakeup(wl);
+
+ /* whal_FwCtrl_BootSm() */
+
+ /* 0. read chip id from CHIP_ID */
+ wl->chip.id = wl12xx_reg_read32(wl, CHIP_ID_B);
+
+ /* 1. check if chip id is valid */
+
+ switch (wl->chip.id) {
+ case CHIP_ID_1251_PG12:
+ wl12xx_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)",
+ wl->chip.id);
+
+ wl1251_setup(wl);
+
+ break;
+ case CHIP_ID_1271_PG10:
+ case CHIP_ID_1251_PG10:
+ case CHIP_ID_1251_PG11:
+ default:
+ wl12xx_error("unsupported chip id: 0x%x", wl->chip.id);
+ ret = -ENODEV;
+ goto out;
+ }
+
+ if (wl->fw == NULL) {
+ ret = wl12xx_fetch_firmware(wl);
+ if (ret < 0)
+ goto out;
+ }
+
+ /* No NVS from netlink, try to get it from the filesystem */
+ if (wl->nvs == NULL) {
+ ret = wl12xx_fetch_nvs(wl);
+ if (ret < 0)
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
+static void wl12xx_filter_work(struct work_struct *work)
+{
+ struct wl12xx *wl =
+ container_of(work, struct wl12xx, filter_work);
+ int ret;
+
+ mutex_lock(&wl->mutex);
+
+ if (wl->state == WL12XX_STATE_OFF)
+ goto out;
+
+ ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0);
+ if (ret < 0)
+ goto out;
+
+out:
+ mutex_unlock(&wl->mutex);
+}
+
+int wl12xx_plt_start(struct wl12xx *wl)
+{
+ int ret;
+
+ wl12xx_notice("power up");
+
+ if (wl->state != WL12XX_STATE_OFF) {
+ wl12xx_error("cannot go into PLT state because not "
+ "in off state: %d", wl->state);
+ return -EBUSY;
+ }
+
+ wl->state = WL12XX_STATE_PLT;
+
+ ret = wl12xx_chip_wakeup(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl->chip.op_boot(wl);
+ if (ret < 0)
+ return ret;
+
+ wl12xx_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver);
+
+ ret = wl->chip.op_plt_init(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl12xx_plt_stop(struct wl12xx *wl)
+{
+ wl12xx_notice("power down");
+
+ if (wl->state != WL12XX_STATE_PLT) {
+ wl12xx_error("cannot power down because not in PLT "
+ "state: %d", wl->state);
+ return -EBUSY;
+ }
+
+ wl12xx_disable_interrupts(wl);
+ wl12xx_power_off(wl);
+
+ wl->state = WL12XX_STATE_OFF;
+
+ return 0;
+}
+
+
+static int wl12xx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+ struct wl12xx *wl = hw->priv;
+
+ skb_queue_tail(&wl->tx_queue, skb);
+
+ schedule_work(&wl->tx_work);
+
+ /*
+ * The workqueue is slow to process the tx_queue and we need stop
+ * the queue here, otherwise the queue will get too long.
+ */
+ if (skb_queue_len(&wl->tx_queue) >= WL12XX_TX_QUEUE_MAX_LENGTH) {
+ ieee80211_stop_queues(wl->hw);
+
+ /*
+ * FIXME: this is racy, the variable is not properly
+ * protected. Maybe fix this by removing the stupid
+ * variable altogether and checking the real queue state?
+ */
+ wl->tx_queue_stopped = true;
+ }
+
+ return NETDEV_TX_OK;
+}
+
+static int wl12xx_op_start(struct ieee80211_hw *hw)
+{
+ struct wl12xx *wl = hw->priv;
+ int ret = 0;
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 start");
+
+ mutex_lock(&wl->mutex);
+
+ if (wl->state != WL12XX_STATE_OFF) {
+ wl12xx_error("cannot start because not in off state: %d",
+ wl->state);
+ ret = -EBUSY;
+ goto out;
+ }
+
+ ret = wl12xx_chip_wakeup(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl->chip.op_boot(wl);
+ if (ret < 0)
+ goto out;
+
+ ret = wl->chip.op_hw_init(wl);
+ if (ret < 0)
+ goto out;
+
+ ret = wl12xx_acx_station_id(wl);
+ if (ret < 0)
+ goto out;
+
+ wl->state = WL12XX_STATE_ON;
+
+ wl12xx_info("firmware booted (%s)", wl->chip.fw_ver);
+
+out:
+ if (ret < 0)
+ wl12xx_power_off(wl);
+
+ mutex_unlock(&wl->mutex);
+
+ return ret;
+}
+
+static void wl12xx_op_stop(struct ieee80211_hw *hw)
+{
+ struct wl12xx *wl = hw->priv;
+
+ wl12xx_info("down");
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 stop");
+
+ mutex_lock(&wl->mutex);
+
+ WARN_ON(wl->state != WL12XX_STATE_ON);
+
+ if (wl->scanning) {
+ mutex_unlock(&wl->mutex);
+ ieee80211_scan_completed(wl->hw, true);
+ mutex_lock(&wl->mutex);
+ wl->scanning = false;
+ }
+
+ wl->state = WL12XX_STATE_OFF;
+
+ wl12xx_disable_interrupts(wl);
+
+ mutex_unlock(&wl->mutex);
+
+ cancel_work_sync(&wl->irq_work);
+ cancel_work_sync(&wl->tx_work);
+ cancel_work_sync(&wl->filter_work);
+
+ mutex_lock(&wl->mutex);
+
+ /* let's notify MAC80211 about the remaining pending TX frames */
+ wl12xx_tx_flush(wl);
+
+ wl12xx_power_off(wl);
+
+ memset(wl->bssid, 0, ETH_ALEN);
+ wl->listen_int = 1;
+ wl->bss_type = MAX_BSS_TYPE;
+
+ wl->data_in_count = 0;
+ wl->rx_counter = 0;
+ wl->rx_handled = 0;
+ wl->rx_current_buffer = 0;
+ wl->rx_last_id = 0;
+ wl->next_tx_complete = 0;
+ wl->elp = false;
+ wl->psm = 0;
+ wl->tx_queue_stopped = false;
+ wl->power_level = WL12XX_DEFAULT_POWER_LEVEL;
+
+ wl12xx_debugfs_reset(wl);
+
+ mutex_unlock(&wl->mutex);
+}
+
+static int wl12xx_op_add_interface(struct ieee80211_hw *hw,
+ struct ieee80211_if_init_conf *conf)
+{
+ struct wl12xx *wl = hw->priv;
+ DECLARE_MAC_BUF(mac);
+ int ret = 0;
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %s",
+ conf->type, print_mac(mac, conf->mac_addr));
+
+ mutex_lock(&wl->mutex);
+
+ switch (conf->type) {
+ case NL80211_IFTYPE_STATION:
+ wl->bss_type = BSS_TYPE_STA_BSS;
+ break;
+ case NL80211_IFTYPE_ADHOC:
+ wl->bss_type = BSS_TYPE_IBSS;
+ break;
+ default:
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
+ if (memcmp(wl->mac_addr, conf->mac_addr, ETH_ALEN)) {
+ memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN);
+ SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
+ ret = wl12xx_acx_station_id(wl);
+ if (ret < 0)
+ goto out;
+ }
+
+out:
+ mutex_unlock(&wl->mutex);
+ return ret;
+}
+
+static void wl12xx_op_remove_interface(struct ieee80211_hw *hw,
+ struct ieee80211_if_init_conf *conf)
+{
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 remove interface");
+}
+
+static int wl12xx_build_null_data(struct wl12xx *wl)
+{
+ struct wl12xx_null_data_template template;
+
+ if (!is_zero_ether_addr(wl->bssid)) {
+ memcpy(template.header.da, wl->bssid, ETH_ALEN);
+ memcpy(template.header.bssid, wl->bssid, ETH_ALEN);
+ } else {
+ memset(template.header.da, 0xff, ETH_ALEN);
+ memset(template.header.bssid, 0xff, ETH_ALEN);
+ }
+
+ memcpy(template.header.sa, wl->mac_addr, ETH_ALEN);
+ template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
+ IEEE80211_STYPE_NULLFUNC);
+
+ return wl12xx_cmd_template_set(wl, CMD_NULL_DATA, &template,
+ sizeof(template));
+
+}
+
+static int wl12xx_build_ps_poll(struct wl12xx *wl, u16 aid)
+{
+ struct wl12xx_ps_poll_template template;
+
+ memcpy(template.bssid, wl->bssid, ETH_ALEN);
+ memcpy(template.ta, wl->mac_addr, ETH_ALEN);
+ template.aid = aid;
+ template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
+
+ return wl12xx_cmd_template_set(wl, CMD_PS_POLL, &template,
+ sizeof(template));
+
+}
+
+static int wl12xx_op_config(struct ieee80211_hw *hw, u32 changed)
+{
+ struct wl12xx *wl = hw->priv;
+ struct ieee80211_conf *conf = &hw->conf;
+ int channel, ret = 0;
+
+ channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d",
+ channel,
+ conf->flags & IEEE80211_CONF_PS ? "on" : "off",
+ conf->power_level);
+
+ mutex_lock(&wl->mutex);
+
+ if (channel != wl->channel) {
+ /* FIXME: use beacon interval provided by mac80211 */
+ ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0);
+ if (ret < 0)
+ goto out;
+
+ wl->channel = channel;
+ }
+
+ ret = wl12xx_build_null_data(wl);
+ if (ret < 0)
+ goto out;
+
+ if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
+ wl12xx_info("psm enabled");
+
+ wl->psm_requested = true;
+
+ /*
+ * We enter PSM only if we're already associated.
+ * If we're not, we'll enter it when joining an SSID,
+ * through the bss_info_changed() hook.
+ */
+ ret = wl12xx_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
+ } else if (!(conf->flags & IEEE80211_CONF_PS) &&
+ wl->psm_requested) {
+ wl12xx_info("psm disabled");
+
+ wl->psm_requested = false;
+
+ if (wl->psm)
+ ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE);
+ }
+
+ if (conf->power_level != wl->power_level) {
+ ret = wl12xx_acx_tx_power(wl, conf->power_level);
+ if (ret < 0)
+ goto out;
+
+ wl->power_level = conf->power_level;
+ }
+
+out:
+ mutex_unlock(&wl->mutex);
+ return ret;
+}
+
+#define WL12XX_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
+ FIF_ALLMULTI | \
+ FIF_FCSFAIL | \
+ FIF_BCN_PRBRESP_PROMISC | \
+ FIF_CONTROL | \
+ FIF_OTHER_BSS)
+
+static void wl12xx_op_configure_filter(struct ieee80211_hw *hw,
+ unsigned int changed,
+ unsigned int *total,
+ int mc_count,
+ struct dev_addr_list *mc_list)
+{
+ struct wl12xx *wl = hw->priv;
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 configure filter");
+
+ *total &= WL12XX_SUPPORTED_FILTERS;
+ changed &= WL12XX_SUPPORTED_FILTERS;
+
+ if (changed == 0)
+ /* no filters which we support changed */
+ return;
+
+ /* FIXME: wl->rx_config and wl->rx_filter are not protected */
+
+ wl->rx_config = WL12XX_DEFAULT_RX_CONFIG;
+ wl->rx_filter = WL12XX_DEFAULT_RX_FILTER;
+
+ if (*total & FIF_PROMISC_IN_BSS) {
+ wl->rx_config |= CFG_BSSID_FILTER_EN;
+ wl->rx_config |= CFG_RX_ALL_GOOD;
+ }
+ if (*total & FIF_ALLMULTI)
+ /*
+ * CFG_MC_FILTER_EN in rx_config needs to be 0 to receive
+ * all multicast frames
+ */
+ wl->rx_config &= ~CFG_MC_FILTER_EN;
+ if (*total & FIF_FCSFAIL)
+ wl->rx_filter |= CFG_RX_FCS_ERROR;
+ if (*total & FIF_BCN_PRBRESP_PROMISC) {
+ wl->rx_config &= ~CFG_BSSID_FILTER_EN;
+ wl->rx_config &= ~CFG_SSID_FILTER_EN;
+ }
+ if (*total & FIF_CONTROL)
+ wl->rx_filter |= CFG_RX_CTL_EN;
+ if (*total & FIF_OTHER_BSS)
+ wl->rx_filter &= ~CFG_BSSID_FILTER_EN;
+
+ /*
+ * FIXME: workqueues need to be properly cancelled on stop(), for
+ * now let's just disable changing the filter settings. They will
+ * be updated any on config().
+ */
+ /* schedule_work(&wl->filter_work); */
+}
+
+/* HW encryption */
+static int wl12xx_set_key_type(struct wl12xx *wl, struct acx_set_key *key,
+ enum set_key_cmd cmd,
+ struct ieee80211_key_conf *mac80211_key,
+ const u8 *addr)
+{
+ switch (mac80211_key->alg) {
+ case ALG_WEP:
+ if (is_broadcast_ether_addr(addr))
+ key->key_type = KEY_WEP_DEFAULT;
+ else
+ key->key_type = KEY_WEP_ADDR;
+
+ mac80211_key->hw_key_idx = mac80211_key->keyidx;
+ break;
+ case ALG_TKIP:
+ if (is_broadcast_ether_addr(addr))
+ key->key_type = KEY_TKIP_MIC_GROUP;
+ else
+ key->key_type = KEY_TKIP_MIC_PAIRWISE;
+
+ mac80211_key->hw_key_idx = mac80211_key->keyidx;
+ break;
+ case ALG_CCMP:
+ if (is_broadcast_ether_addr(addr))
+ key->key_type = KEY_AES_GROUP;
+ else
+ key->key_type = KEY_AES_PAIRWISE;
+ mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
+ break;
+ default:
+ wl12xx_error("Unknown key algo 0x%x", mac80211_key->alg);
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
+ struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta,
+ struct ieee80211_key_conf *key)
+{
+ struct wl12xx *wl = hw->priv;
+ struct acx_set_key wl_key;
+ const u8 *addr;
+ int ret;
+
+ static const u8 bcast_addr[ETH_ALEN] =
+ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 set key");
+
+ memset(&wl_key, 0, sizeof(wl_key));
+
+ addr = sta ? sta->addr : bcast_addr;
+
+ wl12xx_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
+ wl12xx_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
+ wl12xx_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
+ key->alg, key->keyidx, key->keylen, key->flags);
+ wl12xx_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen);
+
+ mutex_lock(&wl->mutex);
+
+ switch (cmd) {
+ case SET_KEY:
+ wl_key.key_action = KEY_ADD_OR_REPLACE;
+ break;
+ case DISABLE_KEY:
+ wl_key.key_action = KEY_REMOVE;
+ break;
+ default:
+ wl12xx_error("Unsupported key cmd 0x%x", cmd);
+ break;
+ }
+
+ ret = wl12xx_set_key_type(wl, &wl_key, cmd, key, addr);
+ if (ret < 0) {
+ wl12xx_error("Set KEY type failed");
+ goto out;
+ }
+
+ if (wl_key.key_type != KEY_WEP_DEFAULT)
+ memcpy(wl_key.addr, addr, ETH_ALEN);
+
+ if ((wl_key.key_type == KEY_TKIP_MIC_GROUP) ||
+ (wl_key.key_type == KEY_TKIP_MIC_PAIRWISE)) {
+ /*
+ * We get the key in the following form:
+ * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
+ * but the target is expecting:
+ * TKIP - RX MIC - TX MIC
+ */
+ memcpy(wl_key.key, key->key, 16);
+ memcpy(wl_key.key + 16, key->key + 24, 8);
+ memcpy(wl_key.key + 24, key->key + 16, 8);
+
+ } else {
+ memcpy(wl_key.key, key->key, key->keylen);
+ }
+ wl_key.key_size = key->keylen;
+
+ wl_key.id = key->keyidx;
+ wl_key.ssid_profile = 0;
+
+ wl12xx_dump(DEBUG_CRYPT, "TARGET KEY: ", &wl_key, sizeof(wl_key));
+
+ if (wl12xx_cmd_send(wl, CMD_SET_KEYS, &wl_key, sizeof(wl_key)) < 0) {
+ wl12xx_error("Set KEY failed");
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
+out:
+ mutex_unlock(&wl->mutex);
+ return ret;
+}
+
+static int wl12xx_build_basic_rates(char *rates)
+{
+ u8 index = 0;
+
+ rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
+ rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
+ rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
+ rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
+
+ return index;
+}
+
+static int wl12xx_build_extended_rates(char *rates)
+{
+ u8 index = 0;
+
+ rates[index++] = IEEE80211_OFDM_RATE_6MB;
+ rates[index++] = IEEE80211_OFDM_RATE_9MB;
+ rates[index++] = IEEE80211_OFDM_RATE_12MB;
+ rates[index++] = IEEE80211_OFDM_RATE_18MB;
+ rates[index++] = IEEE80211_OFDM_RATE_24MB;
+ rates[index++] = IEEE80211_OFDM_RATE_36MB;
+ rates[index++] = IEEE80211_OFDM_RATE_48MB;
+ rates[index++] = IEEE80211_OFDM_RATE_54MB;
+
+ return index;
+}
+
+
+static int wl12xx_build_probe_req(struct wl12xx *wl, u8 *ssid, size_t ssid_len)
+{
+ struct wl12xx_probe_req_template template;
+ struct wl12xx_ie_rates *rates;
+ char *ptr;
+ u16 size;
+
+ ptr = (char *)&template;
+ size = sizeof(struct ieee80211_header);
+
+ memset(template.header.da, 0xff, ETH_ALEN);
+ memset(template.header.bssid, 0xff, ETH_ALEN);
+ memcpy(template.header.sa, wl->mac_addr, ETH_ALEN);
+ template.header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
+
+ /* IEs */
+ /* SSID */
+ template.ssid.header.id = WLAN_EID_SSID;
+ template.ssid.header.len = ssid_len;
+ if (ssid_len && ssid)
+ memcpy(template.ssid.ssid, ssid, ssid_len);
+ size += sizeof(struct wl12xx_ie_header) + ssid_len;
+ ptr += size;
+
+ /* Basic Rates */
+ rates = (struct wl12xx_ie_rates *)ptr;
+ rates->header.id = WLAN_EID_SUPP_RATES;
+ rates->header.len = wl12xx_build_basic_rates(rates->rates);
+ size += sizeof(struct wl12xx_ie_header) + rates->header.len;
+ ptr += sizeof(struct wl12xx_ie_header) + rates->header.len;
+
+ /* Extended rates */
+ rates = (struct wl12xx_ie_rates *)ptr;
+ rates->header.id = WLAN_EID_EXT_SUPP_RATES;
+ rates->header.len = wl12xx_build_extended_rates(rates->rates);
+ size += sizeof(struct wl12xx_ie_header) + rates->header.len;
+
+ wl12xx_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size);
+
+ return wl12xx_cmd_template_set(wl, CMD_PROBE_REQ, &template,
+ size);
+}
+
+static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len,
+ u8 active_scan, u8 high_prio, u8 num_channels,
+ u8 probe_requests)
+{
+ int i, ret;
+ u32 split_scan = 0;
+ u16 scan_options = 0;
+ struct cmd_scan *params;
+ struct wl12xx_command *cmd_answer;
+
+ if (wl->scanning)
+ return -EINVAL;
+
+ params = kzalloc(sizeof(*params), GFP_KERNEL);
+ if (!params)
+ return -ENOMEM;
+
+ params->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
+ params->params.rx_filter_options =
+ cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN);
+
+ /* High priority scan */
+ if (!active_scan)
+ scan_options |= SCAN_PASSIVE;
+ if (high_prio)
+ scan_options |= SCAN_PRIORITY_HIGH;
+ params->params.scan_options = scan_options;
+
+ params->params.num_channels = num_channels;
+ params->params.num_probe_requests = probe_requests;
+ params->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */
+ params->params.tid_trigger = 0;
+
+ for (i = 0; i < num_channels; i++) {
+ params->channels[i].min_duration = cpu_to_le32(30000);
+ params->channels[i].max_duration = cpu_to_le32(60000);
+ memset(&params->channels[i].bssid_lsb, 0xff, 4);
+ memset(&params->channels[i].bssid_msb, 0xff, 2);
+ params->channels[i].early_termination = 0;
+ params->channels[i].tx_power_att = 0;
+ params->channels[i].channel = i + 1;
+ memset(params->channels[i].pad, 0, 3);
+ }
+
+ for (i = num_channels; i < SCAN_MAX_NUM_OF_CHANNELS; i++)
+ memset(&params->channels[i], 0,
+ sizeof(struct basic_scan_channel_parameters));
+
+ if (len && ssid) {
+ params->params.ssid_len = len;
+ memcpy(params->params.ssid, ssid, len);
+ } else {
+ params->params.ssid_len = 0;
+ memset(params->params.ssid, 0, 32);
+ }
+
+ ret = wl12xx_build_probe_req(wl, ssid, len);
+ if (ret < 0) {
+ wl12xx_error("PROBE request template failed");
+ goto out;
+ }
+
+ ret = wl12xx_cmd_send(wl, CMD_TRIGGER_SCAN_TO, &split_scan,
+ sizeof(u32));
+ if (ret < 0) {
+ wl12xx_error("Split SCAN failed");
+ goto out;
+ }
+
+ wl12xx_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
+
+ wl->scanning = true;
+
+ ret = wl12xx_cmd_send(wl, CMD_SCAN, params, sizeof(*params));
+ if (ret < 0)
+ wl12xx_error("SCAN failed");
+
+ wl12xx_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params));
+
+ cmd_answer = (struct wl12xx_command *) params;
+ if (cmd_answer->status != CMD_STATUS_SUCCESS) {
+ wl12xx_error("TEST command answer error: %d",
+ cmd_answer->status);
+ wl->scanning = false;
+ ret = -EIO;
+ goto out;
+ }
+
+out:
+ kfree(params);
+ return ret;
+
+}
+
+static int wl12xx_op_hw_scan(struct ieee80211_hw *hw,
+ struct cfg80211_scan_request *req)
+{
+ struct wl12xx *wl = hw->priv;
+ int ret;
+ u8 *ssid = NULL;
+ size_t ssid_len = 0;
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 hw scan");
+
+ if (req->n_ssids) {
+ ssid = req->ssids[0].ssid;
+ ssid_len = req->ssids[0].ssid_len;
+ }
+
+ mutex_lock(&wl->mutex);
+ ret = wl12xx_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3);
+ mutex_unlock(&wl->mutex);
+
+ return ret;
+}
+
+static int wl12xx_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
+{
+ struct wl12xx *wl = hw->priv;
+ int ret;
+
+ ret = wl12xx_acx_rts_threshold(wl, (u16) value);
+
+ if (ret < 0)
+ wl12xx_warning("wl12xx_op_set_rts_threshold failed: %d", ret);
+
+ return ret;
+}
+
+static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *bss_conf,
+ u32 changed)
+{
+ enum acx_ps_mode mode;
+ struct wl12xx *wl = hw->priv;
+ struct sk_buff *beacon;
+ int ret;
+
+ wl12xx_debug(DEBUG_MAC80211, "mac80211 bss info changed");
+
+ mutex_lock(&wl->mutex);
+
+ if (changed & BSS_CHANGED_ASSOC) {
+ if (bss_conf->assoc) {
+ wl->aid = bss_conf->aid;
+
+ ret = wl12xx_build_ps_poll(wl, wl->aid);
+ if (ret < 0)
+ goto out;
+
+ ret = wl12xx_acx_aid(wl, wl->aid);
+ if (ret < 0)
+ goto out;
+
+ /* If we want to go in PSM but we're not there yet */
+ if (wl->psm_requested && !wl->psm) {
+ mode = STATION_POWER_SAVE_MODE;
+ ret = wl12xx_ps_set_mode(wl, mode);
+ if (ret < 0)
+ goto out;
+ }
+ }
+ }
+ if (changed & BSS_CHANGED_ERP_SLOT) {
+ if (bss_conf->use_short_slot)
+ ret = wl12xx_acx_slot(wl, SLOT_TIME_SHORT);
+ else
+ ret = wl12xx_acx_slot(wl, SLOT_TIME_LONG);
+ if (ret < 0) {
+ wl12xx_warning("Set slot time failed %d", ret);
+ goto out;
+ }
+ }
+
+ if (changed & BSS_CHANGED_ERP_PREAMBLE) {
+ if (bss_conf->use_short_preamble)
+ wl12xx_acx_set_preamble(wl, ACX_PREAMBLE_SHORT);
+ else
+ wl12xx_acx_set_preamble(wl, ACX_PREAMBLE_LONG);
+ }
+
+ if (changed & BSS_CHANGED_ERP_CTS_PROT) {
+ if (bss_conf->use_cts_prot)
+ ret = wl12xx_acx_cts_protect(wl, CTSPROTECT_ENABLE);
+ else
+ ret = wl12xx_acx_cts_protect(wl, CTSPROTECT_DISABLE);
+ if (ret < 0) {
+ wl12xx_warning("Set ctsprotect failed %d", ret);
+ goto out;
+ }
+ }
+
+ if (changed & BSS_CHANGED_BSSID) {
+ memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
+
+ ret = wl12xx_build_null_data(wl);
+ if (ret < 0)
+ goto out;
+
+ if (wl->bss_type != BSS_TYPE_IBSS) {
+ ret = wl12xx_cmd_join(wl, wl->bss_type, 5, 100, 1);
+ if (ret < 0)
+ goto out;
+ }
+ }
+
+ if (changed & BSS_CHANGED_BEACON) {
+ beacon = ieee80211_beacon_get(hw, vif);
+ ret = wl12xx_cmd_template_set(wl, CMD_BEACON, beacon->data,
+ beacon->len);
+
+ if (ret < 0) {
+ dev_kfree_skb(beacon);
+ goto out;
+ }
+
+ ret = wl12xx_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data,
+ beacon->len);
+
+ dev_kfree_skb(beacon);
+
+ if (ret < 0)
+ goto out;
+
+ ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0);
+
+ if (ret < 0)
+ goto out;
+ }
+
+out:
+ mutex_unlock(&wl->mutex);
+}
+
+
+/* can't be const, mac80211 writes to this */
+static struct ieee80211_rate wl12xx_rates[] = {
+ { .bitrate = 10,
+ .hw_value = 0x1,
+ .hw_value_short = 0x1, },
+ { .bitrate = 20,
+ .hw_value = 0x2,
+ .hw_value_short = 0x2,
+ .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 55,
+ .hw_value = 0x4,
+ .hw_value_short = 0x4,
+ .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 110,
+ .hw_value = 0x20,
+ .hw_value_short = 0x20,
+ .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 60,
+ .hw_value = 0x8,
+ .hw_value_short = 0x8, },
+ { .bitrate = 90,
+ .hw_value = 0x10,
+ .hw_value_short = 0x10, },
+ { .bitrate = 120,
+ .hw_value = 0x40,
+ .hw_value_short = 0x40, },
+ { .bitrate = 180,
+ .hw_value = 0x80,
+ .hw_value_short = 0x80, },
+ { .bitrate = 240,
+ .hw_value = 0x200,
+ .hw_value_short = 0x200, },
+ { .bitrate = 360,
+ .hw_value = 0x400,
+ .hw_value_short = 0x400, },
+ { .bitrate = 480,
+ .hw_value = 0x800,
+ .hw_value_short = 0x800, },
+ { .bitrate = 540,
+ .hw_value = 0x1000,
+ .hw_value_short = 0x1000, },
+};
+
+/* can't be const, mac80211 writes to this */
+static struct ieee80211_channel wl12xx_channels[] = {
+ { .hw_value = 1, .center_freq = 2412},
+ { .hw_value = 2, .center_freq = 2417},
+ { .hw_value = 3, .center_freq = 2422},
+ { .hw_value = 4, .center_freq = 2427},
+ { .hw_value = 5, .center_freq = 2432},
+ { .hw_value = 6, .center_freq = 2437},
+ { .hw_value = 7, .center_freq = 2442},
+ { .hw_value = 8, .center_freq = 2447},
+ { .hw_value = 9, .center_freq = 2452},
+ { .hw_value = 10, .center_freq = 2457},
+ { .hw_value = 11, .center_freq = 2462},
+ { .hw_value = 12, .center_freq = 2467},
+ { .hw_value = 13, .center_freq = 2472},
+};
+
+/* can't be const, mac80211 writes to this */
+static struct ieee80211_supported_band wl12xx_band_2ghz = {
+ .channels = wl12xx_channels,
+ .n_channels = ARRAY_SIZE(wl12xx_channels),
+ .bitrates = wl12xx_rates,
+ .n_bitrates = ARRAY_SIZE(wl12xx_rates),
+};
+
+static const struct ieee80211_ops wl12xx_ops = {
+ .start = wl12xx_op_start,
+ .stop = wl12xx_op_stop,
+ .add_interface = wl12xx_op_add_interface,
+ .remove_interface = wl12xx_op_remove_interface,
+ .config = wl12xx_op_config,
+ .configure_filter = wl12xx_op_configure_filter,
+ .tx = wl12xx_op_tx,
+ .set_key = wl12xx_op_set_key,
+ .hw_scan = wl12xx_op_hw_scan,
+ .bss_info_changed = wl12xx_op_bss_info_changed,
+ .set_rts_threshold = wl12xx_op_set_rts_threshold,
+};
+
+static int wl12xx_register_hw(struct wl12xx *wl)
+{
+ int ret;
+
+ if (wl->mac80211_registered)
+ return 0;
+
+ SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
+
+ ret = ieee80211_register_hw(wl->hw);
+ if (ret < 0) {
+ wl12xx_error("unable to register mac80211 hw: %d", ret);
+ return ret;
+ }
+
+ wl->mac80211_registered = true;
+
+ wl12xx_notice("loaded");
+
+ return 0;
+}
+
+static int wl12xx_init_ieee80211(struct wl12xx *wl)
+{
+ /* The tx descriptor buffer and the TKIP space */
+ wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc)
+ + WL12XX_TKIP_IV_SPACE;
+
+ /* unit us */
+ /* FIXME: find a proper value */
+ wl->hw->channel_change_time = 10000;
+
+ wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
+ IEEE80211_HW_NOISE_DBM;
+
+ wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+ wl->hw->wiphy->max_scan_ssids = 1;
+ wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl12xx_band_2ghz;
+
+ SET_IEEE80211_DEV(wl->hw, &wl->spi->dev);
+
+ return 0;
+}
+
+#define WL12XX_DEFAULT_CHANNEL 1
+static int __devinit wl12xx_probe(struct spi_device *spi)
+{
+ struct wl12xx_platform_data *pdata;
+ struct ieee80211_hw *hw;
+ struct wl12xx *wl;
+ int ret, i;
+ static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
+
+ pdata = spi->dev.platform_data;
+ if (!pdata) {
+ wl12xx_error("no platform data");
+ return -ENODEV;
+ }
+
+ hw = ieee80211_alloc_hw(sizeof(*wl), &wl12xx_ops);
+ if (!hw) {
+ wl12xx_error("could not alloc ieee80211_hw");
+ return -ENOMEM;
+ }
+
+ wl = hw->priv;
+ memset(wl, 0, sizeof(*wl));
+
+ wl->hw = hw;
+ dev_set_drvdata(&spi->dev, wl);
+ wl->spi = spi;
+
+ wl->data_in_count = 0;
+
+ skb_queue_head_init(&wl->tx_queue);
+
+ INIT_WORK(&wl->tx_work, wl12xx_tx_work);
+ INIT_WORK(&wl->filter_work, wl12xx_filter_work);
+ wl->channel = WL12XX_DEFAULT_CHANNEL;
+ wl->scanning = false;
+ wl->default_key = 0;
+ wl->listen_int = 1;
+ wl->rx_counter = 0;
+ wl->rx_handled = 0;
+ wl->rx_current_buffer = 0;
+ wl->rx_last_id = 0;
+ wl->rx_config = WL12XX_DEFAULT_RX_CONFIG;
+ wl->rx_filter = WL12XX_DEFAULT_RX_FILTER;
+ wl->elp = false;
+ wl->psm = 0;
+ wl->psm_requested = false;
+ wl->tx_queue_stopped = false;
+ wl->power_level = WL12XX_DEFAULT_POWER_LEVEL;
+
+ /* We use the default power on sleep time until we know which chip
+ * we're using */
+ wl->chip.power_on_sleep = WL12XX_DEFAULT_POWER_ON_SLEEP;
+
+ for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
+ wl->tx_frames[i] = NULL;
+
+ wl->next_tx_complete = 0;
+
+ /*
+ * In case our MAC address is not correctly set,
+ * we use a random but Nokia MAC.
+ */
+ memcpy(wl->mac_addr, nokia_oui, 3);
+ get_random_bytes(wl->mac_addr + 3, 3);
+
+ wl->state = WL12XX_STATE_OFF;
+ mutex_init(&wl->mutex);
+
+ wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
+ wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
+
+ /* This is the only SPI value that we need to set here, the rest
+ * comes from the board-peripherals file */
+ spi->bits_per_word = 32;
+
+ ret = spi_setup(spi);
+ if (ret < 0) {
+ wl12xx_error("spi_setup failed");
+ goto out_free;
+ }
+
+ wl->set_power = pdata->set_power;
+ if (!wl->set_power) {
+ wl12xx_error("set power function missing in platform data");
+ return -ENODEV;
+ }
+
+ wl->irq = spi->irq;
+ if (wl->irq < 0) {
+ wl12xx_error("irq missing in platform data");
+ return -ENODEV;
+ }
+
+ ret = request_irq(wl->irq, wl12xx_irq, 0, DRIVER_NAME, wl);
+ if (ret < 0) {
+ wl12xx_error("request_irq() failed: %d", ret);
+ goto out_free;
+ }
+
+ set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
+
+ disable_irq(wl->irq);
+
+ ret = wl12xx_init_ieee80211(wl);
+ if (ret)
+ goto out_irq;
+
+ ret = wl12xx_register_hw(wl);
+ if (ret)
+ goto out_irq;
+
+ wl12xx_debugfs_init(wl);
+
+ wl12xx_notice("initialized");
+
+ return 0;
+
+ out_irq:
+ free_irq(wl->irq, wl);
+
+ out_free:
+ ieee80211_free_hw(hw);
+
+ return ret;
+}
+
+static int __devexit wl12xx_remove(struct spi_device *spi)
+{
+ struct wl12xx *wl = dev_get_drvdata(&spi->dev);
+
+ ieee80211_unregister_hw(wl->hw);
+
+ wl12xx_debugfs_exit(wl);
+
+ free_irq(wl->irq, wl);
+ kfree(wl->target_mem_map);
+ kfree(wl->data_path);
+ kfree(wl->fw);
+ wl->fw = NULL;
+ kfree(wl->nvs);
+ wl->nvs = NULL;
+ ieee80211_free_hw(wl->hw);
+
+ return 0;
+}
+
+
+static struct spi_driver wl12xx_spi_driver = {
+ .driver = {
+ .name = "wl12xx",
+ .bus = &spi_bus_type,
+ .owner = THIS_MODULE,
+ },
+
+ .probe = wl12xx_probe,
+ .remove = __devexit_p(wl12xx_remove),
+};
+
+static int __init wl12xx_init(void)
+{
+ int ret;
+
+ ret = spi_register_driver(&wl12xx_spi_driver);
+ if (ret < 0) {
+ wl12xx_error("failed to register spi driver: %d", ret);
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
+static void __exit wl12xx_exit(void)
+{
+ spi_unregister_driver(&wl12xx_spi_driver);
+
+ wl12xx_notice("unloaded");
+}
+
+module_init(wl12xx_init);
+module_exit(wl12xx_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Kalle Valo <Kalle.Valo@nokia.com>, "
+ "Luciano Coelho <luciano.coelho@nokia.com>");
diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c
new file mode 100644
index 000000000000..83a10117330b
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/ps.c
@@ -0,0 +1,151 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "reg.h"
+#include "ps.h"
+#include "spi.h"
+
+#define WL12XX_WAKEUP_TIMEOUT 2000
+
+/* Routines to toggle sleep mode while in ELP */
+void wl12xx_ps_elp_sleep(struct wl12xx *wl)
+{
+ if (wl->elp || !wl->psm)
+ return;
+
+ wl12xx_debug(DEBUG_PSM, "chip to elp");
+
+ wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
+
+ wl->elp = true;
+}
+
+int wl12xx_ps_elp_wakeup(struct wl12xx *wl)
+{
+ unsigned long timeout;
+ u32 elp_reg;
+
+ if (!wl->elp)
+ return 0;
+
+ wl12xx_debug(DEBUG_PSM, "waking up chip from elp");
+
+ timeout = jiffies + msecs_to_jiffies(WL12XX_WAKEUP_TIMEOUT);
+
+ wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP);
+
+ elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
+
+ /*
+ * FIXME: we should wait for irq from chip but, as a temporary
+ * solution to simplify locking, let's poll instead
+ */
+ while (!(elp_reg & ELPCTRL_WLAN_READY)) {
+ if (time_after(jiffies, timeout)) {
+ wl12xx_error("elp wakeup timeout");
+ return -ETIMEDOUT;
+ }
+ msleep(1);
+ elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
+ }
+
+ wl12xx_debug(DEBUG_PSM, "wakeup time: %u ms",
+ jiffies_to_msecs(jiffies) -
+ (jiffies_to_msecs(timeout) - WL12XX_WAKEUP_TIMEOUT));
+
+ wl->elp = false;
+
+ return 0;
+}
+
+static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable)
+{
+ int ret;
+
+ if (enable) {
+ wl12xx_debug(DEBUG_PSM, "sleep auth psm/elp");
+
+ /*
+ * FIXME: we should PSM_ELP, but because of firmware wakeup
+ * problems let's use only PSM_PS
+ */
+ ret = wl12xx_acx_sleep_auth(wl, WL12XX_PSM_PS);
+ if (ret < 0)
+ return ret;
+
+ wl12xx_ps_elp_sleep(wl);
+ } else {
+ wl12xx_debug(DEBUG_PSM, "sleep auth cam");
+
+ /*
+ * When the target is in ELP, we can only
+ * access the ELP control register. Thus,
+ * we have to wake the target up before
+ * changing the power authorization.
+ */
+
+ wl12xx_ps_elp_wakeup(wl);
+
+ ret = wl12xx_acx_sleep_auth(wl, WL12XX_PSM_CAM);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode)
+{
+ int ret;
+
+ switch (mode) {
+ case STATION_POWER_SAVE_MODE:
+ wl12xx_debug(DEBUG_PSM, "entering psm");
+ ret = wl12xx_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_ps_set_elp(wl, true);
+ if (ret < 0)
+ return ret;
+
+ wl->psm = 1;
+ break;
+ case STATION_ACTIVE_MODE:
+ default:
+ wl12xx_debug(DEBUG_PSM, "leaving psm");
+ ret = wl12xx_ps_set_elp(wl, false);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_ps_mode(wl, STATION_ACTIVE_MODE);
+ if (ret < 0)
+ return ret;
+
+ wl->psm = 0;
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/ps.h
new file mode 100644
index 000000000000..5d7c52553830
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/ps.h
@@ -0,0 +1,36 @@
+#ifndef __WL12XX_PS_H__
+#define __WL12XX_PS_H__
+
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "wl12xx.h"
+#include "acx.h"
+
+int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode);
+void wl12xx_ps_elp_sleep(struct wl12xx *wl);
+int wl12xx_ps_elp_wakeup(struct wl12xx *wl);
+
+
+#endif /* __WL12XX_PS_H__ */
diff --git a/drivers/net/wireless/wl12xx/reg.h b/drivers/net/wireless/wl12xx/reg.h
new file mode 100644
index 000000000000..e421643215cd
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/reg.h
@@ -0,0 +1,745 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __REG_H__
+#define __REG_H__
+
+#include <linux/bitops.h>
+#include "wl12xx.h"
+
+#define REGISTERS_BASE 0x00300000
+#define DRPW_BASE 0x00310000
+
+#define REGISTERS_DOWN_SIZE 0x00008800
+#define REGISTERS_WORK_SIZE 0x0000b000
+
+#define HW_ACCESS_ELP_CTRL_REG_ADDR 0x1FFFC
+
+/* ELP register commands */
+#define ELPCTRL_WAKE_UP 0x1
+#define ELPCTRL_WAKE_UP_WLAN_READY 0x5
+#define ELPCTRL_SLEEP 0x0
+/* ELP WLAN_READY bit */
+#define ELPCTRL_WLAN_READY 0x2
+
+/*
+ * Interrupt registers.
+ * 64 bit interrupt sources registers ws ced.
+ * sme interupts were removed and new ones were added.
+ * Order was changed.
+ */
+#define FIQ_MASK (REGISTERS_BASE + 0x0400)
+#define FIQ_MASK_L (REGISTERS_BASE + 0x0400)
+#define FIQ_MASK_H (REGISTERS_BASE + 0x0404)
+#define FIQ_MASK_SET (REGISTERS_BASE + 0x0408)
+#define FIQ_MASK_SET_L (REGISTERS_BASE + 0x0408)
+#define FIQ_MASK_SET_H (REGISTERS_BASE + 0x040C)
+#define FIQ_MASK_CLR (REGISTERS_BASE + 0x0410)
+#define FIQ_MASK_CLR_L (REGISTERS_BASE + 0x0410)
+#define FIQ_MASK_CLR_H (REGISTERS_BASE + 0x0414)
+#define IRQ_MASK (REGISTERS_BASE + 0x0418)
+#define IRQ_MASK_L (REGISTERS_BASE + 0x0418)
+#define IRQ_MASK_H (REGISTERS_BASE + 0x041C)
+#define IRQ_MASK_SET (REGISTERS_BASE + 0x0420)
+#define IRQ_MASK_SET_L (REGISTERS_BASE + 0x0420)
+#define IRQ_MASK_SET_H (REGISTERS_BASE + 0x0424)
+#define IRQ_MASK_CLR (REGISTERS_BASE + 0x0428)
+#define IRQ_MASK_CLR_L (REGISTERS_BASE + 0x0428)
+#define IRQ_MASK_CLR_H (REGISTERS_BASE + 0x042C)
+#define ECPU_MASK (REGISTERS_BASE + 0x0448)
+#define FIQ_STS_L (REGISTERS_BASE + 0x044C)
+#define FIQ_STS_H (REGISTERS_BASE + 0x0450)
+#define IRQ_STS_L (REGISTERS_BASE + 0x0454)
+#define IRQ_STS_H (REGISTERS_BASE + 0x0458)
+#define INT_STS_ND (REGISTERS_BASE + 0x0464)
+#define INT_STS_RAW_L (REGISTERS_BASE + 0x0464)
+#define INT_STS_RAW_H (REGISTERS_BASE + 0x0468)
+#define INT_STS_CLR (REGISTERS_BASE + 0x04B4)
+#define INT_STS_CLR_L (REGISTERS_BASE + 0x04B4)
+#define INT_STS_CLR_H (REGISTERS_BASE + 0x04B8)
+#define INT_ACK (REGISTERS_BASE + 0x046C)
+#define INT_ACK_L (REGISTERS_BASE + 0x046C)
+#define INT_ACK_H (REGISTERS_BASE + 0x0470)
+#define INT_TRIG (REGISTERS_BASE + 0x0474)
+#define INT_TRIG_L (REGISTERS_BASE + 0x0474)
+#define INT_TRIG_H (REGISTERS_BASE + 0x0478)
+#define HOST_STS_L (REGISTERS_BASE + 0x045C)
+#define HOST_STS_H (REGISTERS_BASE + 0x0460)
+#define HOST_MASK (REGISTERS_BASE + 0x0430)
+#define HOST_MASK_L (REGISTERS_BASE + 0x0430)
+#define HOST_MASK_H (REGISTERS_BASE + 0x0434)
+#define HOST_MASK_SET (REGISTERS_BASE + 0x0438)
+#define HOST_MASK_SET_L (REGISTERS_BASE + 0x0438)
+#define HOST_MASK_SET_H (REGISTERS_BASE + 0x043C)
+#define HOST_MASK_CLR (REGISTERS_BASE + 0x0440)
+#define HOST_MASK_CLR_L (REGISTERS_BASE + 0x0440)
+#define HOST_MASK_CLR_H (REGISTERS_BASE + 0x0444)
+
+/* Host Interrupts*/
+#define HINT_MASK (REGISTERS_BASE + 0x0494)
+#define HINT_MASK_SET (REGISTERS_BASE + 0x0498)
+#define HINT_MASK_CLR (REGISTERS_BASE + 0x049C)
+#define HINT_STS_ND_MASKED (REGISTERS_BASE + 0x04A0)
+/*1150 spec calls this HINT_STS_RAW*/
+#define HINT_STS_ND (REGISTERS_BASE + 0x04B0)
+#define HINT_STS_CLR (REGISTERS_BASE + 0x04A4)
+#define HINT_ACK (REGISTERS_BASE + 0x04A8)
+#define HINT_TRIG (REGISTERS_BASE + 0x04AC)
+
+/* Device Configuration registers*/
+#define SOR_CFG (REGISTERS_BASE + 0x0800)
+#define ECPU_CTRL (REGISTERS_BASE + 0x0804)
+#define HI_CFG (REGISTERS_BASE + 0x0808)
+#define EE_START (REGISTERS_BASE + 0x080C)
+
+#define CHIP_ID_B (REGISTERS_BASE + 0x5674)
+
+#define CHIP_ID_1251_PG10 (0x7010101)
+#define CHIP_ID_1251_PG11 (0x7020101)
+#define CHIP_ID_1251_PG12 (0x7030101)
+
+#define ENABLE (REGISTERS_BASE + 0x5450)
+
+/* Power Management registers */
+#define ELP_CFG_MODE (REGISTERS_BASE + 0x5804)
+#define ELP_CMD (REGISTERS_BASE + 0x5808)
+#define PLL_CAL_TIME (REGISTERS_BASE + 0x5810)
+#define CLK_REQ_TIME (REGISTERS_BASE + 0x5814)
+#define CLK_BUF_TIME (REGISTERS_BASE + 0x5818)
+
+#define CFG_PLL_SYNC_CNT (REGISTERS_BASE + 0x5820)
+
+/* Scratch Pad registers*/
+#define SCR_PAD0 (REGISTERS_BASE + 0x5608)
+#define SCR_PAD1 (REGISTERS_BASE + 0x560C)
+#define SCR_PAD2 (REGISTERS_BASE + 0x5610)
+#define SCR_PAD3 (REGISTERS_BASE + 0x5614)
+#define SCR_PAD4 (REGISTERS_BASE + 0x5618)
+#define SCR_PAD4_SET (REGISTERS_BASE + 0x561C)
+#define SCR_PAD4_CLR (REGISTERS_BASE + 0x5620)
+#define SCR_PAD5 (REGISTERS_BASE + 0x5624)
+#define SCR_PAD5_SET (REGISTERS_BASE + 0x5628)
+#define SCR_PAD5_CLR (REGISTERS_BASE + 0x562C)
+#define SCR_PAD6 (REGISTERS_BASE + 0x5630)
+#define SCR_PAD7 (REGISTERS_BASE + 0x5634)
+#define SCR_PAD8 (REGISTERS_BASE + 0x5638)
+#define SCR_PAD9 (REGISTERS_BASE + 0x563C)
+
+/* Spare registers*/
+#define SPARE_A1 (REGISTERS_BASE + 0x0994)
+#define SPARE_A2 (REGISTERS_BASE + 0x0998)
+#define SPARE_A3 (REGISTERS_BASE + 0x099C)
+#define SPARE_A4 (REGISTERS_BASE + 0x09A0)
+#define SPARE_A5 (REGISTERS_BASE + 0x09A4)
+#define SPARE_A6 (REGISTERS_BASE + 0x09A8)
+#define SPARE_A7 (REGISTERS_BASE + 0x09AC)
+#define SPARE_A8 (REGISTERS_BASE + 0x09B0)
+#define SPARE_B1 (REGISTERS_BASE + 0x5420)
+#define SPARE_B2 (REGISTERS_BASE + 0x5424)
+#define SPARE_B3 (REGISTERS_BASE + 0x5428)
+#define SPARE_B4 (REGISTERS_BASE + 0x542C)
+#define SPARE_B5 (REGISTERS_BASE + 0x5430)
+#define SPARE_B6 (REGISTERS_BASE + 0x5434)
+#define SPARE_B7 (REGISTERS_BASE + 0x5438)
+#define SPARE_B8 (REGISTERS_BASE + 0x543C)
+
+enum wl12xx_acx_int_reg {
+ ACX_REG_INTERRUPT_TRIG,
+ ACX_REG_INTERRUPT_TRIG_H,
+
+/*=============================================
+ Host Interrupt Mask Register - 32bit (RW)
+ ------------------------------------------
+ Setting a bit in this register masks the
+ corresponding interrupt to the host.
+ 0 - RX0 - Rx first dubble buffer Data Interrupt
+ 1 - TXD - Tx Data Interrupt
+ 2 - TXXFR - Tx Transfer Interrupt
+ 3 - RX1 - Rx second dubble buffer Data Interrupt
+ 4 - RXXFR - Rx Transfer Interrupt
+ 5 - EVENT_A - Event Mailbox interrupt
+ 6 - EVENT_B - Event Mailbox interrupt
+ 7 - WNONHST - Wake On Host Interrupt
+ 8 - TRACE_A - Debug Trace interrupt
+ 9 - TRACE_B - Debug Trace interrupt
+ 10 - CDCMP - Command Complete Interrupt
+ 11 -
+ 12 -
+ 13 -
+ 14 - ICOMP - Initialization Complete Interrupt
+ 16 - SG SE - Soft Gemini - Sense enable interrupt
+ 17 - SG SD - Soft Gemini - Sense disable interrupt
+ 18 - -
+ 19 - -
+ 20 - -
+ 21- -
+ Default: 0x0001
+*==============================================*/
+ ACX_REG_INTERRUPT_MASK,
+
+/*=============================================
+ Host Interrupt Mask Set 16bit, (Write only)
+ ------------------------------------------
+ Setting a bit in this register sets
+ the corresponding bin in ACX_HINT_MASK register
+ without effecting the mask
+ state of other bits (0 = no effect).
+==============================================*/
+ ACX_REG_HINT_MASK_SET,
+
+/*=============================================
+ Host Interrupt Mask Clear 16bit,(Write only)
+ ------------------------------------------
+ Setting a bit in this register clears
+ the corresponding bin in ACX_HINT_MASK register
+ without effecting the mask
+ state of other bits (0 = no effect).
+=============================================*/
+ ACX_REG_HINT_MASK_CLR,
+
+/*=============================================
+ Host Interrupt Status Nondestructive Read
+ 16bit,(Read only)
+ ------------------------------------------
+ The host can read this register to determine
+ which interrupts are active.
+ Reading this register doesn't
+ effect its content.
+=============================================*/
+ ACX_REG_INTERRUPT_NO_CLEAR,
+
+/*=============================================
+ Host Interrupt Status Clear on Read Register
+ 16bit,(Read only)
+ ------------------------------------------
+ The host can read this register to determine
+ which interrupts are active.
+ Reading this register clears it,
+ thus making all interrupts inactive.
+==============================================*/
+ ACX_REG_INTERRUPT_CLEAR,
+
+/*=============================================
+ Host Interrupt Acknowledge Register
+ 16bit,(Write only)
+ ------------------------------------------
+ The host can set individual bits in this
+ register to clear (acknowledge) the corresp.
+ interrupt status bits in the HINT_STS_CLR and
+ HINT_STS_ND registers, thus making the
+ assotiated interrupt inactive. (0-no effect)
+==============================================*/
+ ACX_REG_INTERRUPT_ACK,
+
+/*===============================================
+ Host Software Reset - 32bit RW
+ ------------------------------------------
+ [31:1] Reserved
+ 0 SOFT_RESET Soft Reset - When this bit is set,
+ it holds the Wlan hardware in a soft reset state.
+ This reset disables all MAC and baseband processor
+ clocks except the CardBus/PCI interface clock.
+ It also initializes all MAC state machines except
+ the host interface. It does not reload the
+ contents of the EEPROM. When this bit is cleared
+ (not self-clearing), the Wlan hardware
+ exits the software reset state.
+===============================================*/
+ ACX_REG_SLV_SOFT_RESET,
+
+/*===============================================
+ EEPROM Burst Read Start - 32bit RW
+ ------------------------------------------
+ [31:1] Reserved
+ 0 ACX_EE_START - EEPROM Burst Read Start 0
+ Setting this bit starts a burst read from
+ the external EEPROM.
+ If this bit is set (after reset) before an EEPROM read/write,
+ the burst read starts at EEPROM address 0.
+ Otherwise, it starts at the address
+ following the address of the previous access.
+ TheWlan hardware hardware clears this bit automatically.
+
+ Default: 0x00000000
+*================================================*/
+ ACX_REG_EE_START,
+
+/* Embedded ARM CPU Control */
+
+/*===============================================
+ Halt eCPU - 32bit RW
+ ------------------------------------------
+ 0 HALT_ECPU Halt Embedded CPU - This bit is the
+ compliment of bit 1 (MDATA2) in the SOR_CFG register.
+ During a hardware reset, this bit holds
+ the inverse of MDATA2.
+ When downloading firmware from the host,
+ set this bit (pull down MDATA2).
+ The host clears this bit after downloading the firmware into
+ zero-wait-state SSRAM.
+ When loading firmware from Flash, clear this bit (pull up MDATA2)
+ so that the eCPU can run the bootloader code in Flash
+ HALT_ECPU eCPU State
+ --------------------
+ 1 halt eCPU
+ 0 enable eCPU
+ ===============================================*/
+ ACX_REG_ECPU_CONTROL,
+
+ ACX_REG_TABLE_LEN
+};
+
+#define ACX_SLV_SOFT_RESET_BIT BIT(1)
+#define ACX_REG_EEPROM_START_BIT BIT(1)
+
+/* Command/Information Mailbox Pointers */
+
+/*===============================================
+ Command Mailbox Pointer - 32bit RW
+ ------------------------------------------
+ This register holds the start address of
+ the command mailbox located in the Wlan hardware memory.
+ The host must read this pointer after a reset to
+ find the location of the command mailbox.
+ The Wlan hardware initializes the command mailbox
+ pointer with the default address of the command mailbox.
+ The command mailbox pointer is not valid until after
+ the host receives the Init Complete interrupt from
+ the Wlan hardware.
+ ===============================================*/
+#define REG_COMMAND_MAILBOX_PTR (SCR_PAD0)
+
+/*===============================================
+ Information Mailbox Pointer - 32bit RW
+ ------------------------------------------
+ This register holds the start address of
+ the information mailbox located in the Wlan hardware memory.
+ The host must read this pointer after a reset to find
+ the location of the information mailbox.
+ The Wlan hardware initializes the information mailbox pointer
+ with the default address of the information mailbox.
+ The information mailbox pointer is not valid
+ until after the host receives the Init Complete interrupt from
+ the Wlan hardware.
+ ===============================================*/
+#define REG_EVENT_MAILBOX_PTR (SCR_PAD1)
+
+
+/* Misc */
+
+#define REG_ENABLE_TX_RX (ENABLE)
+/*
+ * Rx configuration (filter) information element
+ * ---------------------------------------------
+ */
+#define REG_RX_CONFIG (RX_CFG)
+#define REG_RX_FILTER (RX_FILTER_CFG)
+
+
+#define RX_CFG_ENABLE_PHY_HEADER_PLCP 0x0002
+
+/* promiscuous - receives all valid frames */
+#define RX_CFG_PROMISCUOUS 0x0008
+
+/* receives frames from any BSSID */
+#define RX_CFG_BSSID 0x0020
+
+/* receives frames destined to any MAC address */
+#define RX_CFG_MAC 0x0010
+
+#define RX_CFG_ENABLE_ONLY_MY_DEST_MAC 0x0010
+#define RX_CFG_ENABLE_ANY_DEST_MAC 0x0000
+#define RX_CFG_ENABLE_ONLY_MY_BSSID 0x0020
+#define RX_CFG_ENABLE_ANY_BSSID 0x0000
+
+/* discards all broadcast frames */
+#define RX_CFG_DISABLE_BCAST 0x0200
+
+#define RX_CFG_ENABLE_ONLY_MY_SSID 0x0400
+#define RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR 0x0800
+#define RX_CFG_COPY_RX_STATUS 0x2000
+#define RX_CFG_TSF 0x10000
+
+#define RX_CONFIG_OPTION_ANY_DST_MY_BSS (RX_CFG_ENABLE_ANY_DEST_MAC | \
+ RX_CFG_ENABLE_ONLY_MY_BSSID)
+
+#define RX_CONFIG_OPTION_MY_DST_ANY_BSS (RX_CFG_ENABLE_ONLY_MY_DEST_MAC\
+ | RX_CFG_ENABLE_ANY_BSSID)
+
+#define RX_CONFIG_OPTION_ANY_DST_ANY_BSS (RX_CFG_ENABLE_ANY_DEST_MAC | \
+ RX_CFG_ENABLE_ANY_BSSID)
+
+#define RX_CONFIG_OPTION_MY_DST_MY_BSS (RX_CFG_ENABLE_ONLY_MY_DEST_MAC\
+ | RX_CFG_ENABLE_ONLY_MY_BSSID)
+
+#define RX_CONFIG_OPTION_FOR_SCAN (RX_CFG_ENABLE_PHY_HEADER_PLCP \
+ | RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR \
+ | RX_CFG_COPY_RX_STATUS | RX_CFG_TSF)
+
+#define RX_CONFIG_OPTION_FOR_MEASUREMENT (RX_CFG_ENABLE_ANY_DEST_MAC)
+
+#define RX_CONFIG_OPTION_FOR_JOIN (RX_CFG_ENABLE_ONLY_MY_BSSID | \
+ RX_CFG_ENABLE_ONLY_MY_DEST_MAC)
+
+#define RX_CONFIG_OPTION_FOR_IBSS_JOIN (RX_CFG_ENABLE_ONLY_MY_SSID | \
+ RX_CFG_ENABLE_ONLY_MY_DEST_MAC)
+
+#define RX_FILTER_OPTION_DEF (CFG_RX_MGMT_EN | CFG_RX_DATA_EN\
+ | CFG_RX_CTL_EN | CFG_RX_BCN_EN\
+ | CFG_RX_AUTH_EN | CFG_RX_ASSOC_EN)
+
+#define RX_FILTER_OPTION_FILTER_ALL 0
+
+#define RX_FILTER_OPTION_DEF_PRSP_BCN (CFG_RX_PRSP_EN | CFG_RX_MGMT_EN\
+ | CFG_RX_RCTS_ACK | CFG_RX_BCN_EN)
+
+#define RX_FILTER_OPTION_JOIN (CFG_RX_MGMT_EN | CFG_RX_DATA_EN\
+ | CFG_RX_BCN_EN | CFG_RX_AUTH_EN\
+ | CFG_RX_ASSOC_EN | CFG_RX_RCTS_ACK\
+ | CFG_RX_PRSP_EN)
+
+
+/*===============================================
+ Phy regs
+ ===============================================*/
+#define ACX_PHY_ADDR_REG SBB_ADDR
+#define ACX_PHY_DATA_REG SBB_DATA
+#define ACX_PHY_CTRL_REG SBB_CTL
+#define ACX_PHY_REG_WR_MASK 0x00000001ul
+#define ACX_PHY_REG_RD_MASK 0x00000002ul
+
+
+/*===============================================
+ EEPROM Read/Write Request 32bit RW
+ ------------------------------------------
+ 1 EE_READ - EEPROM Read Request 1 - Setting this bit
+ loads a single byte of data into the EE_DATA
+ register from the EEPROM location specified in
+ the EE_ADDR register.
+ The Wlan hardware hardware clears this bit automatically.
+ EE_DATA is valid when this bit is cleared.
+
+ 0 EE_WRITE - EEPROM Write Request - Setting this bit
+ writes a single byte of data from the EE_DATA register into the
+ EEPROM location specified in the EE_ADDR register.
+ The Wlan hardware hardware clears this bit automatically.
+*===============================================*/
+#define ACX_EE_CTL_REG EE_CTL
+#define EE_WRITE 0x00000001ul
+#define EE_READ 0x00000002ul
+
+/*===============================================
+ EEPROM Address - 32bit RW
+ ------------------------------------------
+ This register specifies the address
+ within the EEPROM from/to which to read/write data.
+ ===============================================*/
+#define ACX_EE_ADDR_REG EE_ADDR
+
+/*===============================================
+ EEPROM Data - 32bit RW
+ ------------------------------------------
+ This register either holds the read 8 bits of
+ data from the EEPROM or the write data
+ to be written to the EEPROM.
+ ===============================================*/
+#define ACX_EE_DATA_REG EE_DATA
+
+/*===============================================
+ EEPROM Base Address - 32bit RW
+ ------------------------------------------
+ This register holds the upper nine bits
+ [23:15] of the 24-bit Wlan hardware memory
+ address for burst reads from EEPROM accesses.
+ The EEPROM provides the lower 15 bits of this address.
+ The MSB of the address from the EEPROM is ignored.
+ ===============================================*/
+#define ACX_EE_CFG EE_CFG
+
+/*===============================================
+ GPIO Output Values -32bit, RW
+ ------------------------------------------
+ [31:16] Reserved
+ [15: 0] Specify the output values (at the output driver inputs) for
+ GPIO[15:0], respectively.
+ ===============================================*/
+#define ACX_GPIO_OUT_REG GPIO_OUT
+#define ACX_MAX_GPIO_LINES 15
+
+/*===============================================
+ Contention window -32bit, RW
+ ------------------------------------------
+ [31:26] Reserved
+ [25:16] Max (0x3ff)
+ [15:07] Reserved
+ [06:00] Current contention window value - default is 0x1F
+ ===============================================*/
+#define ACX_CONT_WIND_CFG_REG CONT_WIND_CFG
+#define ACX_CONT_WIND_MIN_MASK 0x0000007f
+#define ACX_CONT_WIND_MAX 0x03ff0000
+
+/*
+ * Indirect slave register/memory registers
+ * ----------------------------------------
+ */
+#define HW_SLAVE_REG_ADDR_REG 0x00000004
+#define HW_SLAVE_REG_DATA_REG 0x00000008
+#define HW_SLAVE_REG_CTRL_REG 0x0000000c
+
+#define SLAVE_AUTO_INC 0x00010000
+#define SLAVE_NO_AUTO_INC 0x00000000
+#define SLAVE_HOST_LITTLE_ENDIAN 0x00000000
+
+#define HW_SLAVE_MEM_ADDR_REG SLV_MEM_ADDR
+#define HW_SLAVE_MEM_DATA_REG SLV_MEM_DATA
+#define HW_SLAVE_MEM_CTRL_REG SLV_MEM_CTL
+#define HW_SLAVE_MEM_ENDIAN_REG SLV_END_CTL
+
+#define HW_FUNC_EVENT_INT_EN 0x8000
+#define HW_FUNC_EVENT_MASK_REG 0x00000034
+
+#define ACX_MAC_TIMESTAMP_REG (MAC_TIMESTAMP)
+
+/*===============================================
+ HI_CFG Interface Configuration Register Values
+ ------------------------------------------
+ ===============================================*/
+#define HI_CFG_UART_ENABLE 0x00000004
+#define HI_CFG_RST232_ENABLE 0x00000008
+#define HI_CFG_CLOCK_REQ_SELECT 0x00000010
+#define HI_CFG_HOST_INT_ENABLE 0x00000020
+#define HI_CFG_VLYNQ_OUTPUT_ENABLE 0x00000040
+#define HI_CFG_HOST_INT_ACTIVE_LOW 0x00000080
+#define HI_CFG_UART_TX_OUT_GPIO_15 0x00000100
+#define HI_CFG_UART_TX_OUT_GPIO_14 0x00000200
+#define HI_CFG_UART_TX_OUT_GPIO_7 0x00000400
+
+/*
+ * NOTE: USE_ACTIVE_HIGH compilation flag should be defined in makefile
+ * for platforms using active high interrupt level
+ */
+#ifdef USE_ACTIVE_HIGH
+#define HI_CFG_DEF_VAL \
+ (HI_CFG_UART_ENABLE | \
+ HI_CFG_RST232_ENABLE | \
+ HI_CFG_CLOCK_REQ_SELECT | \
+ HI_CFG_HOST_INT_ENABLE)
+#else
+#define HI_CFG_DEF_VAL \
+ (HI_CFG_UART_ENABLE | \
+ HI_CFG_RST232_ENABLE | \
+ HI_CFG_CLOCK_REQ_SELECT | \
+ HI_CFG_HOST_INT_ENABLE)
+
+#endif
+
+#define REF_FREQ_19_2 0
+#define REF_FREQ_26_0 1
+#define REF_FREQ_38_4 2
+#define REF_FREQ_40_0 3
+#define REF_FREQ_33_6 4
+#define REF_FREQ_NUM 5
+
+#define LUT_PARAM_INTEGER_DIVIDER 0
+#define LUT_PARAM_FRACTIONAL_DIVIDER 1
+#define LUT_PARAM_ATTN_BB 2
+#define LUT_PARAM_ALPHA_BB 3
+#define LUT_PARAM_STOP_TIME_BB 4
+#define LUT_PARAM_BB_PLL_LOOP_FILTER 5
+#define LUT_PARAM_NUM 6
+
+#define ACX_EEPROMLESS_IND_REG (SCR_PAD4)
+#define USE_EEPROM 0
+#define SOFT_RESET_MAX_TIME 1000000
+#define SOFT_RESET_STALL_TIME 1000
+#define NVS_DATA_BUNDARY_ALIGNMENT 4
+
+
+/* Firmware image load chunk size */
+#define CHUNK_SIZE 512
+
+/* Firmware image header size */
+#define FW_HDR_SIZE 8
+
+#define ECPU_CONTROL_HALT 0x00000101
+
+
+/******************************************************************************
+
+ CHANNELS, BAND & REG DOMAINS definitions
+
+******************************************************************************/
+
+
+enum {
+ RADIO_BAND_2_4GHZ = 0, /* 2.4 Ghz band */
+ RADIO_BAND_5GHZ = 1, /* 5 Ghz band */
+ RADIO_BAND_JAPAN_4_9_GHZ = 2,
+ DEFAULT_BAND = RADIO_BAND_2_4GHZ,
+ INVALID_BAND = 0xFE,
+ MAX_RADIO_BANDS = 0xFF
+};
+
+enum {
+ NO_RATE = 0,
+ RATE_1MBPS = 0x0A,
+ RATE_2MBPS = 0x14,
+ RATE_5_5MBPS = 0x37,
+ RATE_6MBPS = 0x0B,
+ RATE_9MBPS = 0x0F,
+ RATE_11MBPS = 0x6E,
+ RATE_12MBPS = 0x0A,
+ RATE_18MBPS = 0x0E,
+ RATE_22MBPS = 0xDC,
+ RATE_24MBPS = 0x09,
+ RATE_36MBPS = 0x0D,
+ RATE_48MBPS = 0x08,
+ RATE_54MBPS = 0x0C
+};
+
+enum {
+ RATE_INDEX_1MBPS = 0,
+ RATE_INDEX_2MBPS = 1,
+ RATE_INDEX_5_5MBPS = 2,
+ RATE_INDEX_6MBPS = 3,
+ RATE_INDEX_9MBPS = 4,
+ RATE_INDEX_11MBPS = 5,
+ RATE_INDEX_12MBPS = 6,
+ RATE_INDEX_18MBPS = 7,
+ RATE_INDEX_22MBPS = 8,
+ RATE_INDEX_24MBPS = 9,
+ RATE_INDEX_36MBPS = 10,
+ RATE_INDEX_48MBPS = 11,
+ RATE_INDEX_54MBPS = 12,
+ RATE_INDEX_MAX = RATE_INDEX_54MBPS,
+ MAX_RATE_INDEX,
+ INVALID_RATE_INDEX = MAX_RATE_INDEX,
+ RATE_INDEX_ENUM_MAX_SIZE = 0x7FFFFFFF
+};
+
+enum {
+ RATE_MASK_1MBPS = 0x1,
+ RATE_MASK_2MBPS = 0x2,
+ RATE_MASK_5_5MBPS = 0x4,
+ RATE_MASK_11MBPS = 0x20,
+};
+
+#define SHORT_PREAMBLE_BIT BIT(0) /* CCK or Barker depending on the rate */
+#define OFDM_RATE_BIT BIT(6)
+#define PBCC_RATE_BIT BIT(7)
+
+enum {
+ CCK_LONG = 0,
+ CCK_SHORT = SHORT_PREAMBLE_BIT,
+ PBCC_LONG = PBCC_RATE_BIT,
+ PBCC_SHORT = PBCC_RATE_BIT | SHORT_PREAMBLE_BIT,
+ OFDM = OFDM_RATE_BIT
+};
+
+/******************************************************************************
+
+Transmit-Descriptor RATE-SET field definitions...
+
+Define a new "Rate-Set" for TX path that incorporates the
+Rate & Modulation info into a single 16-bit field.
+
+TxdRateSet_t:
+b15 - Indicates Preamble type (1=SHORT, 0=LONG).
+ Notes:
+ Must be LONG (0) for 1Mbps rate.
+ Does not apply (set to 0) for RevG-OFDM rates.
+b14 - Indicates PBCC encoding (1=PBCC, 0=not).
+ Notes:
+ Does not apply (set to 0) for rates 1 and 2 Mbps.
+ Does not apply (set to 0) for RevG-OFDM rates.
+b13 - Unused (set to 0).
+b12-b0 - Supported Rate indicator bits as defined below.
+
+******************************************************************************/
+
+
+#define TNETW1251_CHIP_ID_PG1_0 0x07010101
+#define TNETW1251_CHIP_ID_PG1_1 0x07020101
+#define TNETW1251_CHIP_ID_PG1_2 0x07030101
+
+/*************************************************************************
+
+ Interrupt Trigger Register (Host -> WiLink)
+
+**************************************************************************/
+
+/* Hardware to Embedded CPU Interrupts - first 32-bit register set */
+
+/*
+ * Host Command Interrupt. Setting this bit masks
+ * the interrupt that the host issues to inform
+ * the FW that it has sent a command
+ * to the Wlan hardware Command Mailbox.
+ */
+#define INTR_TRIG_CMD BIT(0)
+
+/*
+ * Host Event Acknowlegde Interrupt. The host
+ * sets this bit to acknowledge that it received
+ * the unsolicited information from the event
+ * mailbox.
+ */
+#define INTR_TRIG_EVENT_ACK BIT(1)
+
+/*
+ * The host sets this bit to inform the Wlan
+ * FW that a TX packet is in the XFER
+ * Buffer #0.
+ */
+#define INTR_TRIG_TX_PROC0 BIT(2)
+
+/*
+ * The host sets this bit to inform the FW
+ * that it read a packet from RX XFER
+ * Buffer #0.
+ */
+#define INTR_TRIG_RX_PROC0 BIT(3)
+
+#define INTR_TRIG_DEBUG_ACK BIT(4)
+
+#define INTR_TRIG_STATE_CHANGED BIT(5)
+
+
+/* Hardware to Embedded CPU Interrupts - second 32-bit register set */
+
+/*
+ * The host sets this bit to inform the FW
+ * that it read a packet from RX XFER
+ * Buffer #1.
+ */
+#define INTR_TRIG_RX_PROC1 BIT(17)
+
+/*
+ * The host sets this bit to inform the Wlan
+ * hardware that a TX packet is in the XFER
+ * Buffer #1.
+ */
+#define INTR_TRIG_TX_PROC1 BIT(18)
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c
new file mode 100644
index 000000000000..981ea259eb89
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/rx.c
@@ -0,0 +1,208 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/skbuff.h>
+#include <net/mac80211.h>
+
+#include "wl12xx.h"
+#include "reg.h"
+#include "spi.h"
+#include "rx.h"
+
+static void wl12xx_rx_header(struct wl12xx *wl,
+ struct wl12xx_rx_descriptor *desc)
+{
+ u32 rx_packet_ring_addr;
+
+ rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr;
+ if (wl->rx_current_buffer)
+ rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
+
+ wl12xx_spi_mem_read(wl, rx_packet_ring_addr, desc,
+ sizeof(struct wl12xx_rx_descriptor));
+}
+
+static void wl12xx_rx_status(struct wl12xx *wl,
+ struct wl12xx_rx_descriptor *desc,
+ struct ieee80211_rx_status *status,
+ u8 beacon)
+{
+ memset(status, 0, sizeof(struct ieee80211_rx_status));
+
+ status->band = IEEE80211_BAND_2GHZ;
+ status->mactime = desc->timestamp;
+
+ /*
+ * The rx status timestamp is a 32 bits value while the TSF is a
+ * 64 bits one.
+ * For IBSS merging, TSF is mandatory, so we have to get it
+ * somehow, so we ask for ACX_TSF_INFO.
+ * That could be moved to the get_tsf() hook, but unfortunately,
+ * this one must be atomic, while our SPI routines can sleep.
+ */
+ if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) {
+ u64 mactime;
+ int ret;
+ struct wl12xx_command cmd;
+ struct acx_tsf_info *tsf_info;
+
+ memset(&cmd, 0, sizeof(cmd));
+
+ ret = wl12xx_cmd_interrogate(wl, ACX_TSF_INFO,
+ sizeof(struct acx_tsf_info),
+ &cmd);
+ if (ret < 0) {
+ wl12xx_warning("ACX_FW_REV interrogate failed");
+ return;
+ }
+
+ tsf_info = (struct acx_tsf_info *)&(cmd.parameters);
+
+ mactime = tsf_info->current_tsf_lsb |
+ (tsf_info->current_tsf_msb << 31);
+
+ status->mactime = mactime;
+ }
+
+ status->signal = desc->rssi;
+ status->qual = (desc->rssi - WL12XX_RX_MIN_RSSI) * 100 /
+ (WL12XX_RX_MAX_RSSI - WL12XX_RX_MIN_RSSI);
+ status->qual = min(status->qual, 100);
+ status->qual = max(status->qual, 0);
+
+ /*
+ * FIXME: guessing that snr needs to be divided by two, otherwise
+ * the values don't make any sense
+ */
+ status->noise = desc->rssi - desc->snr / 2;
+
+ status->freq = ieee80211_channel_to_frequency(desc->channel);
+
+ status->flag |= RX_FLAG_TSFT;
+
+ if (desc->flags & RX_DESC_ENCRYPTION_MASK) {
+ status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED;
+
+ if (likely(!(desc->flags & RX_DESC_DECRYPT_FAIL)))
+ status->flag |= RX_FLAG_DECRYPTED;
+
+ if (unlikely(desc->flags & RX_DESC_MIC_FAIL))
+ status->flag |= RX_FLAG_MMIC_ERROR;
+ }
+
+ if (unlikely(!(desc->flags & RX_DESC_VALID_FCS)))
+ status->flag |= RX_FLAG_FAILED_FCS_CRC;
+
+
+ /* FIXME: set status->rate_idx */
+}
+
+static void wl12xx_rx_body(struct wl12xx *wl,
+ struct wl12xx_rx_descriptor *desc)
+{
+ struct sk_buff *skb;
+ struct ieee80211_rx_status status;
+ u8 *rx_buffer, beacon = 0;
+ u16 length, *fc;
+ u32 curr_id, last_id_inc, rx_packet_ring_addr;
+
+ length = WL12XX_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH);
+ curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT;
+ last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1);
+
+ if (last_id_inc != curr_id) {
+ wl12xx_warning("curr ID:%d, last ID inc:%d",
+ curr_id, last_id_inc);
+ wl->rx_last_id = curr_id;
+ } else {
+ wl->rx_last_id = last_id_inc;
+ }
+
+ rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr +
+ sizeof(struct wl12xx_rx_descriptor) + 20;
+ if (wl->rx_current_buffer)
+ rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
+
+ skb = dev_alloc_skb(length);
+ if (!skb) {
+ wl12xx_error("Couldn't allocate RX frame");
+ return;
+ }
+
+ rx_buffer = skb_put(skb, length);
+ wl12xx_spi_mem_read(wl, rx_packet_ring_addr, rx_buffer, length);
+
+ /* The actual lenght doesn't include the target's alignment */
+ skb->len = desc->length - PLCP_HEADER_LENGTH;
+
+ fc = (u16 *)skb->data;
+
+ if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
+ beacon = 1;
+
+ wl12xx_rx_status(wl, desc, &status, beacon);
+
+ wl12xx_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len,
+ beacon ? "beacon" : "");
+
+ ieee80211_rx(wl->hw, skb, &status);
+}
+
+static void wl12xx_rx_ack(struct wl12xx *wl)
+{
+ u32 data, addr;
+
+ if (wl->rx_current_buffer) {
+ addr = ACX_REG_INTERRUPT_TRIG_H;
+ data = INTR_TRIG_RX_PROC1;
+ } else {
+ addr = ACX_REG_INTERRUPT_TRIG;
+ data = INTR_TRIG_RX_PROC0;
+ }
+
+ wl12xx_reg_write32(wl, addr, data);
+
+ /* Toggle buffer ring */
+ wl->rx_current_buffer = !wl->rx_current_buffer;
+}
+
+
+void wl12xx_rx(struct wl12xx *wl)
+{
+ struct wl12xx_rx_descriptor rx_desc;
+
+ if (wl->state != WL12XX_STATE_ON)
+ return;
+
+ /* We first read the frame's header */
+ wl12xx_rx_header(wl, &rx_desc);
+
+ /* Now we can read the body */
+ wl12xx_rx_body(wl, &rx_desc);
+
+ /* Finally, we need to ACK the RX */
+ wl12xx_rx_ack(wl);
+
+ return;
+}
diff --git a/drivers/net/wireless/wl12xx/rx.h b/drivers/net/wireless/wl12xx/rx.h
new file mode 100644
index 000000000000..8a23fdea5016
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/rx.h
@@ -0,0 +1,122 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_RX_H__
+#define __WL12XX_RX_H__
+
+#include <linux/bitops.h>
+
+/*
+ * RX PATH
+ *
+ * The Rx path uses a double buffer and an rx_contro structure, each located
+ * at a fixed address in the device memory. The host keeps track of which
+ * buffer is available and alternates between them on a per packet basis.
+ * The size of each of the two buffers is large enough to hold the longest
+ * 802.3 packet.
+ * The RX path goes like that:
+ * 1) The target generates an interrupt each time a new packet is received.
+ * There are 2 RX interrupts, one for each buffer.
+ * 2) The host reads the received packet from one of the double buffers.
+ * 3) The host triggers a target interrupt.
+ * 4) The target prepares the next RX packet.
+ */
+
+#define WL12XX_RX_MAX_RSSI -30
+#define WL12XX_RX_MIN_RSSI -95
+
+#define WL12XX_RX_ALIGN_TO 4
+#define WL12XX_RX_ALIGN(len) (((len) + WL12XX_RX_ALIGN_TO - 1) & \
+ ~(WL12XX_RX_ALIGN_TO - 1))
+
+#define SHORT_PREAMBLE_BIT BIT(0)
+#define OFDM_RATE_BIT BIT(6)
+#define PBCC_RATE_BIT BIT(7)
+
+#define PLCP_HEADER_LENGTH 8
+#define RX_DESC_PACKETID_SHIFT 11
+#define RX_MAX_PACKET_ID 3
+
+#define RX_DESC_VALID_FCS 0x0001
+#define RX_DESC_MATCH_RXADDR1 0x0002
+#define RX_DESC_MCAST 0x0004
+#define RX_DESC_STAINTIM 0x0008
+#define RX_DESC_VIRTUAL_BM 0x0010
+#define RX_DESC_BCAST 0x0020
+#define RX_DESC_MATCH_SSID 0x0040
+#define RX_DESC_MATCH_BSSID 0x0080
+#define RX_DESC_ENCRYPTION_MASK 0x0300
+#define RX_DESC_MEASURMENT 0x0400
+#define RX_DESC_SEQNUM_MASK 0x1800
+#define RX_DESC_MIC_FAIL 0x2000
+#define RX_DESC_DECRYPT_FAIL 0x4000
+
+struct wl12xx_rx_descriptor {
+ u32 timestamp; /* In microseconds */
+ u16 length; /* Paylod length, including headers */
+ u16 flags;
+
+ /*
+ * 0 - 802.11
+ * 1 - 802.3
+ * 2 - IP
+ * 3 - Raw Codec
+ */
+ u8 type;
+
+ /*
+ * Recevied Rate:
+ * 0x0A - 1MBPS
+ * 0x14 - 2MBPS
+ * 0x37 - 5_5MBPS
+ * 0x0B - 6MBPS
+ * 0x0F - 9MBPS
+ * 0x6E - 11MBPS
+ * 0x0A - 12MBPS
+ * 0x0E - 18MBPS
+ * 0xDC - 22MBPS
+ * 0x09 - 24MBPS
+ * 0x0D - 36MBPS
+ * 0x08 - 48MBPS
+ * 0x0C - 54MBPS
+ */
+ u8 rate;
+
+ u8 mod_pre; /* Modulation and preamble */
+ u8 channel;
+
+ /*
+ * 0 - 2.4 Ghz
+ * 1 - 5 Ghz
+ */
+ u8 band;
+
+ s8 rssi; /* in dB */
+ u8 rcpi; /* in dB */
+ u8 snr; /* in dB */
+} __attribute__ ((packed));
+
+void wl12xx_rx(struct wl12xx *wl);
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c
new file mode 100644
index 000000000000..abdf171a47e7
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/spi.c
@@ -0,0 +1,358 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/crc7.h>
+#include <linux/spi/spi.h>
+
+#include "wl12xx.h"
+#include "wl12xx_80211.h"
+#include "reg.h"
+#include "spi.h"
+#include "ps.h"
+
+static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr)
+{
+ /* If the address is lower than REGISTERS_BASE, it means that this is
+ * a chip-specific register address, so look it up in the registers
+ * table */
+ if (addr < REGISTERS_BASE) {
+ /* Make sure we don't go over the table */
+ if (addr >= ACX_REG_TABLE_LEN) {
+ wl12xx_error("address out of range (%d)", addr);
+ return -EINVAL;
+ }
+ addr = wl->chip.acx_reg_table[addr];
+ }
+
+ return addr - wl->physical_reg_addr + wl->virtual_reg_addr;
+}
+
+static int wl12xx_translate_mem_addr(struct wl12xx *wl, int addr)
+{
+ return addr - wl->physical_mem_addr + wl->virtual_mem_addr;
+}
+
+
+void wl12xx_spi_reset(struct wl12xx *wl)
+{
+ u8 *cmd;
+ struct spi_transfer t;
+ struct spi_message m;
+
+ cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
+ if (!cmd) {
+ wl12xx_error("could not allocate cmd for spi reset");
+ return;
+ }
+
+ memset(&t, 0, sizeof(t));
+ spi_message_init(&m);
+
+ memset(cmd, 0xff, WSPI_INIT_CMD_LEN);
+
+ t.tx_buf = cmd;
+ t.len = WSPI_INIT_CMD_LEN;
+ spi_message_add_tail(&t, &m);
+
+ spi_sync(wl->spi, &m);
+
+ wl12xx_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
+}
+
+void wl12xx_spi_init(struct wl12xx *wl)
+{
+ u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
+ struct spi_transfer t;
+ struct spi_message m;
+
+ cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
+ if (!cmd) {
+ wl12xx_error("could not allocate cmd for spi init");
+ return;
+ }
+
+ memset(crc, 0, sizeof(crc));
+ memset(&t, 0, sizeof(t));
+ spi_message_init(&m);
+
+ /*
+ * Set WSPI_INIT_COMMAND
+ * the data is being send from the MSB to LSB
+ */
+ cmd[2] = 0xff;
+ cmd[3] = 0xff;
+ cmd[1] = WSPI_INIT_CMD_START | WSPI_INIT_CMD_TX;
+ cmd[0] = 0;
+ cmd[7] = 0;
+ cmd[6] |= HW_ACCESS_WSPI_INIT_CMD_MASK << 3;
+ cmd[6] |= HW_ACCESS_WSPI_FIXED_BUSY_LEN & WSPI_INIT_CMD_FIXEDBUSY_LEN;
+
+ if (HW_ACCESS_WSPI_FIXED_BUSY_LEN == 0)
+ cmd[5] |= WSPI_INIT_CMD_DIS_FIXEDBUSY;
+ else
+ cmd[5] |= WSPI_INIT_CMD_EN_FIXEDBUSY;
+
+ cmd[5] |= WSPI_INIT_CMD_IOD | WSPI_INIT_CMD_IP | WSPI_INIT_CMD_CS
+ | WSPI_INIT_CMD_WSPI | WSPI_INIT_CMD_WS;
+
+ crc[0] = cmd[1];
+ crc[1] = cmd[0];
+ crc[2] = cmd[7];
+ crc[3] = cmd[6];
+ crc[4] = cmd[5];
+
+ cmd[4] |= crc7(0, crc, WSPI_INIT_CMD_CRC_LEN) << 1;
+ cmd[4] |= WSPI_INIT_CMD_END;
+
+ t.tx_buf = cmd;
+ t.len = WSPI_INIT_CMD_LEN;
+ spi_message_add_tail(&t, &m);
+
+ spi_sync(wl->spi, &m);
+
+ wl12xx_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
+}
+
+/* Set the SPI partitions to access the chip addresses
+ *
+ * There are two VIRTUAL (SPI) partitions (the memory partition and the
+ * registers partition), which are mapped to two different areas of the
+ * PHYSICAL (hardware) memory. This function also makes other checks to
+ * ensure that the partitions are not overlapping. In the diagram below, the
+ * memory partition comes before the register partition, but the opposite is
+ * also supported.
+ *
+ * PHYSICAL address
+ * space
+ *
+ * | |
+ * ...+----+--> mem_start
+ * VIRTUAL address ... | |
+ * space ... | | [PART_0]
+ * ... | |
+ * 0x00000000 <--+----+... ...+----+--> mem_start + mem_size
+ * | | ... | |
+ * |MEM | ... | |
+ * | | ... | |
+ * part_size <--+----+... | | {unused area)
+ * | | ... | |
+ * |REG | ... | |
+ * part_size | | ... | |
+ * + <--+----+... ...+----+--> reg_start
+ * reg_size ... | |
+ * ... | | [PART_1]
+ * ... | |
+ * ...+----+--> reg_start + reg_size
+ * | |
+ *
+ */
+void wl12xx_set_partition(struct wl12xx *wl,
+ u32 mem_start, u32 mem_size,
+ u32 reg_start, u32 reg_size)
+{
+ u8 tx_buf[sizeof(u32) + 2 * sizeof(struct wl12xx_partition)];
+ struct wl12xx_partition *partition;
+ struct spi_transfer t;
+ struct spi_message m;
+ u32 *cmd;
+ size_t len;
+ int addr;
+
+ spi_message_init(&m);
+ memset(&t, 0, sizeof(t));
+ memset(tx_buf, 0, sizeof(tx_buf));
+
+ cmd = (u32 *) tx_buf;
+ partition = (struct wl12xx_partition *) (tx_buf + sizeof(u32));
+ addr = HW_ACCESS_PART0_SIZE_ADDR;
+ len = 2 * sizeof(struct wl12xx_partition);
+
+ *cmd |= WSPI_CMD_WRITE;
+ *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+ *cmd |= addr & WSPI_CMD_BYTE_ADDR;
+
+ wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
+ mem_start, mem_size);
+ wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
+ reg_start, reg_size);
+
+ /* Make sure that the two partitions together don't exceed the
+ * address range */
+ if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) {
+ wl12xx_debug(DEBUG_SPI, "Total size exceeds maximum virtual"
+ " address range. Truncating partition[0].");
+ mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size;
+ wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
+ mem_start, mem_size);
+ wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
+ reg_start, reg_size);
+ }
+
+ if ((mem_start < reg_start) &&
+ ((mem_start + mem_size) > reg_start)) {
+ /* Guarantee that the memory partition doesn't overlap the
+ * registers partition */
+ wl12xx_debug(DEBUG_SPI, "End of partition[0] is "
+ "overlapping partition[1]. Adjusted.");
+ mem_size = reg_start - mem_start;
+ wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
+ mem_start, mem_size);
+ wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
+ reg_start, reg_size);
+ } else if ((reg_start < mem_start) &&
+ ((reg_start + reg_size) > mem_start)) {
+ /* Guarantee that the register partition doesn't overlap the
+ * memory partition */
+ wl12xx_debug(DEBUG_SPI, "End of partition[1] is"
+ " overlapping partition[0]. Adjusted.");
+ reg_size = mem_start - reg_start;
+ wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
+ mem_start, mem_size);
+ wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
+ reg_start, reg_size);
+ }
+
+ partition[0].start = mem_start;
+ partition[0].size = mem_size;
+ partition[1].start = reg_start;
+ partition[1].size = reg_size;
+
+ wl->physical_mem_addr = mem_start;
+ wl->physical_reg_addr = reg_start;
+
+ wl->virtual_mem_addr = 0;
+ wl->virtual_reg_addr = mem_size;
+
+ t.tx_buf = tx_buf;
+ t.len = sizeof(tx_buf);
+ spi_message_add_tail(&t, &m);
+
+ spi_sync(wl->spi, &m);
+}
+
+void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf,
+ size_t len)
+{
+ struct spi_transfer t[3];
+ struct spi_message m;
+ char busy_buf[TNETWIF_READ_OFFSET_BYTES];
+ u32 cmd;
+
+ cmd = 0;
+ cmd |= WSPI_CMD_READ;
+ cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+ cmd |= addr & WSPI_CMD_BYTE_ADDR;
+
+ spi_message_init(&m);
+ memset(t, 0, sizeof(t));
+
+ t[0].tx_buf = &cmd;
+ t[0].len = 4;
+ spi_message_add_tail(&t[0], &m);
+
+ /* Busy and non busy words read */
+ t[1].rx_buf = busy_buf;
+ t[1].len = TNETWIF_READ_OFFSET_BYTES;
+ spi_message_add_tail(&t[1], &m);
+
+ t[2].rx_buf = buf;
+ t[2].len = len;
+ spi_message_add_tail(&t[2], &m);
+
+ spi_sync(wl->spi, &m);
+
+ /* FIXME: check busy words */
+
+ wl12xx_dump(DEBUG_SPI, "spi_read cmd -> ", &cmd, sizeof(cmd));
+ wl12xx_dump(DEBUG_SPI, "spi_read buf <- ", buf, len);
+}
+
+void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf,
+ size_t len)
+{
+ struct spi_transfer t[2];
+ struct spi_message m;
+ u32 cmd;
+
+ cmd = 0;
+ cmd |= WSPI_CMD_WRITE;
+ cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+ cmd |= addr & WSPI_CMD_BYTE_ADDR;
+
+ spi_message_init(&m);
+ memset(t, 0, sizeof(t));
+
+ t[0].tx_buf = &cmd;
+ t[0].len = sizeof(cmd);
+ spi_message_add_tail(&t[0], &m);
+
+ t[1].tx_buf = buf;
+ t[1].len = len;
+ spi_message_add_tail(&t[1], &m);
+
+ spi_sync(wl->spi, &m);
+
+ wl12xx_dump(DEBUG_SPI, "spi_write cmd -> ", &cmd, sizeof(cmd));
+ wl12xx_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
+}
+
+void wl12xx_spi_mem_read(struct wl12xx *wl, int addr, void *buf,
+ size_t len)
+{
+ int physical;
+
+ physical = wl12xx_translate_mem_addr(wl, addr);
+
+ wl12xx_spi_read(wl, physical, buf, len);
+}
+
+void wl12xx_spi_mem_write(struct wl12xx *wl, int addr, void *buf,
+ size_t len)
+{
+ int physical;
+
+ physical = wl12xx_translate_mem_addr(wl, addr);
+
+ wl12xx_spi_write(wl, physical, buf, len);
+}
+
+u32 wl12xx_mem_read32(struct wl12xx *wl, int addr)
+{
+ return wl12xx_read32(wl, wl12xx_translate_mem_addr(wl, addr));
+}
+
+void wl12xx_mem_write32(struct wl12xx *wl, int addr, u32 val)
+{
+ wl12xx_write32(wl, wl12xx_translate_mem_addr(wl, addr), val);
+}
+
+u32 wl12xx_reg_read32(struct wl12xx *wl, int addr)
+{
+ return wl12xx_read32(wl, wl12xx_translate_reg_addr(wl, addr));
+}
+
+void wl12xx_reg_write32(struct wl12xx *wl, int addr, u32 val)
+{
+ wl12xx_write32(wl, wl12xx_translate_reg_addr(wl, addr), val);
+}
diff --git a/drivers/net/wireless/wl12xx/spi.h b/drivers/net/wireless/wl12xx/spi.h
new file mode 100644
index 000000000000..fd3227e904a8
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/spi.h
@@ -0,0 +1,109 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_SPI_H__
+#define __WL12XX_SPI_H__
+
+#include "cmd.h"
+#include "acx.h"
+#include "reg.h"
+
+#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
+
+#define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0
+#define HW_ACCESS_PART0_START_ADDR 0x1FFC4
+#define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8
+#define HW_ACCESS_PART1_START_ADDR 0x1FFCC
+
+#define HW_ACCESS_REGISTER_SIZE 4
+
+#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
+
+#define WSPI_CMD_READ 0x40000000
+#define WSPI_CMD_WRITE 0x00000000
+#define WSPI_CMD_FIXED 0x20000000
+#define WSPI_CMD_BYTE_LENGTH 0x1FFE0000
+#define WSPI_CMD_BYTE_LENGTH_OFFSET 17
+#define WSPI_CMD_BYTE_ADDR 0x0001FFFF
+
+#define WSPI_INIT_CMD_CRC_LEN 5
+
+#define WSPI_INIT_CMD_START 0x00
+#define WSPI_INIT_CMD_TX 0x40
+/* the extra bypass bit is sampled by the TNET as '1' */
+#define WSPI_INIT_CMD_BYPASS_BIT 0x80
+#define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07
+#define WSPI_INIT_CMD_EN_FIXEDBUSY 0x80
+#define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00
+#define WSPI_INIT_CMD_IOD 0x40
+#define WSPI_INIT_CMD_IP 0x20
+#define WSPI_INIT_CMD_CS 0x10
+#define WSPI_INIT_CMD_WS 0x08
+#define WSPI_INIT_CMD_WSPI 0x01
+#define WSPI_INIT_CMD_END 0x01
+
+#define WSPI_INIT_CMD_LEN 8
+
+#define TNETWIF_READ_OFFSET_BYTES 8
+#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \
+ ((TNETWIF_READ_OFFSET_BYTES - 4) / sizeof(u32))
+#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
+
+
+/* Raw target IO, address is not translated */
+void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf, size_t len);
+void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf, size_t len);
+
+/* Memory target IO, address is tranlated to partition 0 */
+void wl12xx_spi_mem_read(struct wl12xx *wl, int addr, void *buf, size_t len);
+void wl12xx_spi_mem_write(struct wl12xx *wl, int addr, void *buf, size_t len);
+u32 wl12xx_mem_read32(struct wl12xx *wl, int addr);
+void wl12xx_mem_write32(struct wl12xx *wl, int addr, u32 val);
+
+/* Registers IO */
+u32 wl12xx_reg_read32(struct wl12xx *wl, int addr);
+void wl12xx_reg_write32(struct wl12xx *wl, int addr, u32 val);
+
+/* INIT and RESET words */
+void wl12xx_spi_reset(struct wl12xx *wl);
+void wl12xx_spi_init(struct wl12xx *wl);
+void wl12xx_set_partition(struct wl12xx *wl,
+ u32 part_start, u32 part_size,
+ u32 reg_start, u32 reg_size);
+
+static inline u32 wl12xx_read32(struct wl12xx *wl, int addr)
+{
+ u32 response;
+
+ wl12xx_spi_read(wl, addr, &response, sizeof(u32));
+
+ return response;
+}
+
+static inline void wl12xx_write32(struct wl12xx *wl, int addr, u32 val)
+{
+ wl12xx_spi_write(wl, addr, &val, sizeof(u32));
+}
+
+#endif /* __WL12XX_SPI_H__ */
diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c
new file mode 100644
index 000000000000..62145e205a8c
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/tx.c
@@ -0,0 +1,557 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "wl12xx.h"
+#include "reg.h"
+#include "spi.h"
+#include "tx.h"
+#include "ps.h"
+
+static bool wl12xx_tx_double_buffer_busy(struct wl12xx *wl, u32 data_out_count)
+{
+ int used, data_in_count;
+
+ data_in_count = wl->data_in_count;
+
+ if (data_in_count < data_out_count)
+ /* data_in_count has wrapped */
+ data_in_count += TX_STATUS_DATA_OUT_COUNT_MASK + 1;
+
+ used = data_in_count - data_out_count;
+
+ WARN_ON(used < 0);
+ WARN_ON(used > DP_TX_PACKET_RING_CHUNK_NUM);
+
+ if (used >= DP_TX_PACKET_RING_CHUNK_NUM)
+ return true;
+ else
+ return false;
+}
+
+static int wl12xx_tx_path_status(struct wl12xx *wl)
+{
+ u32 status, addr, data_out_count;
+ bool busy;
+
+ addr = wl->data_path->tx_control_addr;
+ status = wl12xx_mem_read32(wl, addr);
+ data_out_count = status & TX_STATUS_DATA_OUT_COUNT_MASK;
+ busy = wl12xx_tx_double_buffer_busy(wl, data_out_count);
+
+ if (busy)
+ return -EBUSY;
+
+ return 0;
+}
+
+static int wl12xx_tx_id(struct wl12xx *wl, struct sk_buff *skb)
+{
+ int i;
+
+ for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
+ if (wl->tx_frames[i] == NULL) {
+ wl->tx_frames[i] = skb;
+ return i;
+ }
+
+ return -EBUSY;
+}
+
+static void wl12xx_tx_control(struct tx_double_buffer_desc *tx_hdr,
+ struct ieee80211_tx_info *control, u16 fc)
+{
+ *(u16 *)&tx_hdr->control = 0;
+
+ tx_hdr->control.rate_policy = 0;
+
+ /* 802.11 packets */
+ tx_hdr->control.packet_type = 0;
+
+ if (control->flags & IEEE80211_TX_CTL_NO_ACK)
+ tx_hdr->control.ack_policy = 1;
+
+ tx_hdr->control.tx_complete = 1;
+
+ if ((fc & IEEE80211_FTYPE_DATA) &&
+ ((fc & IEEE80211_STYPE_QOS_DATA) ||
+ (fc & IEEE80211_STYPE_QOS_NULLFUNC)))
+ tx_hdr->control.qos = 1;
+}
+
+/* RSN + MIC = 8 + 8 = 16 bytes (worst case - AES). */
+#define MAX_MSDU_SECURITY_LENGTH 16
+#define MAX_MPDU_SECURITY_LENGTH 16
+#define WLAN_QOS_HDR_LEN 26
+#define MAX_MPDU_HEADER_AND_SECURITY (MAX_MPDU_SECURITY_LENGTH + \
+ WLAN_QOS_HDR_LEN)
+#define HW_BLOCK_SIZE 252
+static void wl12xx_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr)
+{
+ u16 payload_len, frag_threshold, mem_blocks;
+ u16 num_mpdus, mem_blocks_per_frag;
+
+ frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
+ tx_hdr->frag_threshold = cpu_to_le16(frag_threshold);
+
+ payload_len = tx_hdr->length + MAX_MSDU_SECURITY_LENGTH;
+
+ if (payload_len > frag_threshold) {
+ mem_blocks_per_frag =
+ ((frag_threshold + MAX_MPDU_HEADER_AND_SECURITY) /
+ HW_BLOCK_SIZE) + 1;
+ num_mpdus = payload_len / frag_threshold;
+ mem_blocks = num_mpdus * mem_blocks_per_frag;
+ payload_len -= num_mpdus * frag_threshold;
+ num_mpdus++;
+
+ } else {
+ mem_blocks_per_frag = 0;
+ mem_blocks = 0;
+ num_mpdus = 1;
+ }
+
+ mem_blocks += (payload_len / HW_BLOCK_SIZE) + 1;
+
+ if (num_mpdus > 1)
+ mem_blocks += min(num_mpdus, mem_blocks_per_frag);
+
+ tx_hdr->num_mem_blocks = mem_blocks;
+}
+
+static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb,
+ struct ieee80211_tx_info *control)
+{
+ struct tx_double_buffer_desc *tx_hdr;
+ struct ieee80211_rate *rate;
+ int id;
+ u16 fc;
+
+ if (!skb)
+ return -EINVAL;
+
+ id = wl12xx_tx_id(wl, skb);
+ if (id < 0)
+ return id;
+
+ fc = *(u16 *)skb->data;
+ tx_hdr = (struct tx_double_buffer_desc *) skb_push(skb,
+ sizeof(*tx_hdr));
+
+ tx_hdr->length = cpu_to_le16(skb->len - sizeof(*tx_hdr));
+ rate = ieee80211_get_tx_rate(wl->hw, control);
+ tx_hdr->rate = cpu_to_le16(rate->hw_value);
+ tx_hdr->expiry_time = cpu_to_le32(1 << 16);
+ tx_hdr->id = id;
+
+ /* FIXME: how to get the correct queue id? */
+ tx_hdr->xmit_queue = 0;
+
+ wl12xx_tx_control(tx_hdr, control, fc);
+ wl12xx_tx_frag_block_num(tx_hdr);
+
+ return 0;
+}
+
+/* We copy the packet to the target */
+static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb,
+ struct ieee80211_tx_info *control)
+{
+ struct tx_double_buffer_desc *tx_hdr;
+ int len;
+ u32 addr;
+
+ if (!skb)
+ return -EINVAL;
+
+ tx_hdr = (struct tx_double_buffer_desc *) skb->data;
+
+ if (control->control.hw_key &&
+ control->control.hw_key->alg == ALG_TKIP) {
+ int hdrlen;
+ u16 fc;
+ u8 *pos;
+
+ fc = *(u16 *)(skb->data + sizeof(*tx_hdr));
+ tx_hdr->length += WL12XX_TKIP_IV_SPACE;
+
+ hdrlen = ieee80211_hdrlen(fc);
+
+ pos = skb_push(skb, WL12XX_TKIP_IV_SPACE);
+ memmove(pos, pos + WL12XX_TKIP_IV_SPACE,
+ sizeof(*tx_hdr) + hdrlen);
+ }
+
+ /* Revisit. This is a workaround for getting non-aligned packets.
+ This happens at least with EAPOL packets from the user space.
+ Our DMA requires packets to be aligned on a 4-byte boundary.
+ */
+ if (unlikely((long)skb->data & 0x03)) {
+ int offset = (4 - (long)skb->data) & 0x03;
+ wl12xx_debug(DEBUG_TX, "skb offset %d", offset);
+
+ /* check whether the current skb can be used */
+ if (!skb_cloned(skb) && (skb_tailroom(skb) >= offset)) {
+ unsigned char *src = skb->data;
+
+ /* align the buffer on a 4-byte boundary */
+ skb_reserve(skb, offset);
+ memmove(skb->data, src, skb->len);
+ } else {
+ wl12xx_info("No handler, fixme!");
+ return -EINVAL;
+ }
+ }
+
+ /* Our skb->data at this point includes the HW header */
+ len = WL12XX_TX_ALIGN(skb->len);
+
+ if (wl->data_in_count & 0x1)
+ addr = wl->data_path->tx_packet_ring_addr +
+ wl->data_path->tx_packet_ring_chunk_size;
+ else
+ addr = wl->data_path->tx_packet_ring_addr;
+
+ wl12xx_spi_mem_write(wl, addr, skb->data, len);
+
+ wl12xx_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x",
+ tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate);
+
+ return 0;
+}
+
+static void wl12xx_tx_trigger(struct wl12xx *wl)
+{
+ u32 data, addr;
+
+ if (wl->data_in_count & 0x1) {
+ addr = ACX_REG_INTERRUPT_TRIG_H;
+ data = INTR_TRIG_TX_PROC1;
+ } else {
+ addr = ACX_REG_INTERRUPT_TRIG;
+ data = INTR_TRIG_TX_PROC0;
+ }
+
+ wl12xx_reg_write32(wl, addr, data);
+
+ /* Bumping data in */
+ wl->data_in_count = (wl->data_in_count + 1) &
+ TX_STATUS_DATA_OUT_COUNT_MASK;
+}
+
+/* caller must hold wl->mutex */
+static int wl12xx_tx_frame(struct wl12xx *wl, struct sk_buff *skb)
+{
+ struct ieee80211_tx_info *info;
+ int ret = 0;
+ u8 idx;
+
+ info = IEEE80211_SKB_CB(skb);
+
+ if (info->control.hw_key) {
+ idx = info->control.hw_key->hw_key_idx;
+ if (unlikely(wl->default_key != idx)) {
+ ret = wl12xx_acx_default_key(wl, idx);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ ret = wl12xx_tx_path_status(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_tx_fill_hdr(wl, skb, info);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_tx_send_packet(wl, skb, info);
+ if (ret < 0)
+ return ret;
+
+ wl12xx_tx_trigger(wl);
+
+ return ret;
+}
+
+void wl12xx_tx_work(struct work_struct *work)
+{
+ struct wl12xx *wl = container_of(work, struct wl12xx, tx_work);
+ struct sk_buff *skb;
+ bool woken_up = false;
+ int ret;
+
+ mutex_lock(&wl->mutex);
+
+ if (unlikely(wl->state == WL12XX_STATE_OFF))
+ goto out;
+
+ while ((skb = skb_dequeue(&wl->tx_queue))) {
+ if (!woken_up) {
+ wl12xx_ps_elp_wakeup(wl);
+ woken_up = true;
+ }
+
+ ret = wl12xx_tx_frame(wl, skb);
+ if (ret == -EBUSY) {
+ /* firmware buffer is full, stop queues */
+ wl12xx_debug(DEBUG_TX, "tx_work: fw buffer full, "
+ "stop queues");
+ ieee80211_stop_queues(wl->hw);
+ wl->tx_queue_stopped = true;
+ skb_queue_head(&wl->tx_queue, skb);
+ goto out;
+ } else if (ret < 0) {
+ dev_kfree_skb(skb);
+ goto out;
+ }
+ }
+
+out:
+ if (woken_up)
+ wl12xx_ps_elp_sleep(wl);
+
+ mutex_unlock(&wl->mutex);
+}
+
+static const char *wl12xx_tx_parse_status(u8 status)
+{
+ /* 8 bit status field, one character per bit plus null */
+ static char buf[9];
+ int i = 0;
+
+ memset(buf, 0, sizeof(buf));
+
+ if (status & TX_DMA_ERROR)
+ buf[i++] = 'm';
+ if (status & TX_DISABLED)
+ buf[i++] = 'd';
+ if (status & TX_RETRY_EXCEEDED)
+ buf[i++] = 'r';
+ if (status & TX_TIMEOUT)
+ buf[i++] = 't';
+ if (status & TX_KEY_NOT_FOUND)
+ buf[i++] = 'k';
+ if (status & TX_ENCRYPT_FAIL)
+ buf[i++] = 'e';
+ if (status & TX_UNAVAILABLE_PRIORITY)
+ buf[i++] = 'p';
+
+ /* bit 0 is unused apparently */
+
+ return buf;
+}
+
+static void wl12xx_tx_packet_cb(struct wl12xx *wl,
+ struct tx_result *result)
+{
+ struct ieee80211_tx_info *info;
+ struct sk_buff *skb;
+ int hdrlen, ret;
+ u8 *frame;
+
+ skb = wl->tx_frames[result->id];
+ if (skb == NULL) {
+ wl12xx_error("SKB for packet %d is NULL", result->id);
+ return;
+ }
+
+ info = IEEE80211_SKB_CB(skb);
+
+ if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) &&
+ (result->status == TX_SUCCESS))
+ info->flags |= IEEE80211_TX_STAT_ACK;
+
+ info->status.rates[0].count = result->ack_failures + 1;
+ wl->stats.retry_count += result->ack_failures;
+
+ /*
+ * We have to remove our private TX header before pushing
+ * the skb back to mac80211.
+ */
+ frame = skb_pull(skb, sizeof(struct tx_double_buffer_desc));
+ if (info->control.hw_key &&
+ info->control.hw_key->alg == ALG_TKIP) {
+ hdrlen = ieee80211_get_hdrlen_from_skb(skb);
+ memmove(frame + WL12XX_TKIP_IV_SPACE, frame, hdrlen);
+ skb_pull(skb, WL12XX_TKIP_IV_SPACE);
+ }
+
+ wl12xx_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x"
+ " status 0x%x (%s)",
+ result->id, skb, result->ack_failures, result->rate,
+ result->status, wl12xx_tx_parse_status(result->status));
+
+
+ ieee80211_tx_status(wl->hw, skb);
+
+ wl->tx_frames[result->id] = NULL;
+
+ if (wl->tx_queue_stopped) {
+ wl12xx_debug(DEBUG_TX, "cb: queue was stopped");
+
+ skb = skb_dequeue(&wl->tx_queue);
+
+ /* The skb can be NULL because tx_work might have been
+ scheduled before the queue was stopped making the
+ queue empty */
+
+ if (skb) {
+ ret = wl12xx_tx_frame(wl, skb);
+ if (ret == -EBUSY) {
+ /* firmware buffer is still full */
+ wl12xx_debug(DEBUG_TX, "cb: fw buffer "
+ "still full");
+ skb_queue_head(&wl->tx_queue, skb);
+ return;
+ } else if (ret < 0) {
+ dev_kfree_skb(skb);
+ return;
+ }
+ }
+
+ wl12xx_debug(DEBUG_TX, "cb: waking queues");
+ ieee80211_wake_queues(wl->hw);
+ wl->tx_queue_stopped = false;
+ }
+}
+
+/* Called upon reception of a TX complete interrupt */
+void wl12xx_tx_complete(struct wl12xx *wl)
+{
+ int i, result_index, num_complete = 0;
+ struct tx_result result[FW_TX_CMPLT_BLOCK_SIZE], *result_ptr;
+
+ if (unlikely(wl->state != WL12XX_STATE_ON))
+ return;
+
+ /* First we read the result */
+ wl12xx_spi_mem_read(wl, wl->data_path->tx_complete_addr,
+ result, sizeof(result));
+
+ result_index = wl->next_tx_complete;
+
+ for (i = 0; i < ARRAY_SIZE(result); i++) {
+ result_ptr = &result[result_index];
+
+ if (result_ptr->done_1 == 1 &&
+ result_ptr->done_2 == 1) {
+ wl12xx_tx_packet_cb(wl, result_ptr);
+
+ result_ptr->done_1 = 0;
+ result_ptr->done_2 = 0;
+
+ result_index = (result_index + 1) &
+ (FW_TX_CMPLT_BLOCK_SIZE - 1);
+ num_complete++;
+ } else {
+ break;
+ }
+ }
+
+ /* Every completed frame needs to be acknowledged */
+ if (num_complete) {
+ /*
+ * If we've wrapped, we have to clear
+ * the results in 2 steps.
+ */
+ if (result_index > wl->next_tx_complete) {
+ /* Only 1 write is needed */
+ wl12xx_spi_mem_write(wl,
+ wl->data_path->tx_complete_addr +
+ (wl->next_tx_complete *
+ sizeof(struct tx_result)),
+ &result[wl->next_tx_complete],
+ num_complete *
+ sizeof(struct tx_result));
+
+
+ } else if (result_index < wl->next_tx_complete) {
+ /* 2 writes are needed */
+ wl12xx_spi_mem_write(wl,
+ wl->data_path->tx_complete_addr +
+ (wl->next_tx_complete *
+ sizeof(struct tx_result)),
+ &result[wl->next_tx_complete],
+ (FW_TX_CMPLT_BLOCK_SIZE -
+ wl->next_tx_complete) *
+ sizeof(struct tx_result));
+
+ wl12xx_spi_mem_write(wl,
+ wl->data_path->tx_complete_addr,
+ result,
+ (num_complete -
+ FW_TX_CMPLT_BLOCK_SIZE +
+ wl->next_tx_complete) *
+ sizeof(struct tx_result));
+
+ } else {
+ /* We have to write the whole array */
+ wl12xx_spi_mem_write(wl,
+ wl->data_path->tx_complete_addr,
+ result,
+ FW_TX_CMPLT_BLOCK_SIZE *
+ sizeof(struct tx_result));
+ }
+
+ }
+
+ wl->next_tx_complete = result_index;
+}
+
+/* caller must hold wl->mutex */
+void wl12xx_tx_flush(struct wl12xx *wl)
+{
+ int i;
+ struct sk_buff *skb;
+ struct ieee80211_tx_info *info;
+
+ /* TX failure */
+/* control->flags = 0; FIXME */
+
+ while ((skb = skb_dequeue(&wl->tx_queue))) {
+ info = IEEE80211_SKB_CB(skb);
+
+ wl12xx_debug(DEBUG_TX, "flushing skb 0x%p", skb);
+
+ if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS))
+ continue;
+
+ ieee80211_tx_status(wl->hw, skb);
+ }
+
+ for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
+ if (wl->tx_frames[i] != NULL) {
+ skb = wl->tx_frames[i];
+ info = IEEE80211_SKB_CB(skb);
+
+ if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS))
+ continue;
+
+ ieee80211_tx_status(wl->hw, skb);
+ wl->tx_frames[i] = NULL;
+ }
+}
diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h
new file mode 100644
index 000000000000..dc82691f4c14
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/tx.h
@@ -0,0 +1,215 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_TX_H__
+#define __WL12XX_TX_H__
+
+#include <linux/bitops.h>
+
+/*
+ *
+ * TX PATH
+ *
+ * The Tx path uses a double buffer and a tx_control structure, each located
+ * at a fixed address in the device's memory. On startup, the host retrieves
+ * the pointers to these addresses. A double buffer allows for continuous data
+ * flow towards the device. The host keeps track of which buffer is available
+ * and alternates between these two buffers on a per packet basis.
+ *
+ * The size of each of the two buffers is large enough to hold the longest
+ * 802.3 packet - maximum size Ethernet packet + header + descriptor.
+ * TX complete indication will be received a-synchronously in a TX done cyclic
+ * buffer which is composed of 16 tx_result descriptors structures and is used
+ * in a cyclic manner.
+ *
+ * The TX (HOST) procedure is as follows:
+ * 1. Read the Tx path status, that will give the data_out_count.
+ * 2. goto 1, if not possible.
+ * i.e. if data_in_count - data_out_count >= HwBuffer size (2 for double
+ * buffer).
+ * 3. Copy the packet (preceded by double_buffer_desc), if possible.
+ * i.e. if data_in_count - data_out_count < HwBuffer size (2 for double
+ * buffer).
+ * 4. increment data_in_count.
+ * 5. Inform the firmware by generating a firmware internal interrupt.
+ * 6. FW will increment data_out_count after it reads the buffer.
+ *
+ * The TX Complete procedure:
+ * 1. To get a TX complete indication the host enables the tx_complete flag in
+ * the TX descriptor Structure.
+ * 2. For each packet with a Tx Complete field set, the firmware adds the
+ * transmit results to the cyclic buffer (txDoneRing) and sets both done_1
+ * and done_2 to 1 to indicate driver ownership.
+ * 3. The firmware sends a Tx Complete interrupt to the host to trigger the
+ * host to process the new data. Note: interrupt will be send per packet if
+ * TX complete indication was requested in tx_control or per crossing
+ * aggregation threshold.
+ * 4. After receiving the Tx Complete interrupt, the host reads the
+ * TxDescriptorDone information in a cyclic manner and clears both done_1
+ * and done_2 fields.
+ *
+ */
+
+#define TX_COMPLETE_REQUIRED_BIT 0x80
+#define TX_STATUS_DATA_OUT_COUNT_MASK 0xf
+#define WL12XX_TX_ALIGN_TO 4
+#define WL12XX_TX_ALIGN(len) (((len) + WL12XX_TX_ALIGN_TO - 1) & \
+ ~(WL12XX_TX_ALIGN_TO - 1))
+#define WL12XX_TKIP_IV_SPACE 4
+
+struct tx_control {
+ /* Rate Policy (class) index */
+ unsigned rate_policy:3;
+
+ /* When set, no ack policy is expected */
+ unsigned ack_policy:1;
+
+ /*
+ * Packet type:
+ * 0 -> 802.11
+ * 1 -> 802.3
+ * 2 -> IP
+ * 3 -> raw codec
+ */
+ unsigned packet_type:2;
+
+ /* If set, this is a QoS-Null or QoS-Data frame */
+ unsigned qos:1;
+
+ /*
+ * If set, the target triggers the tx complete INT
+ * upon frame sending completion.
+ */
+ unsigned tx_complete:1;
+
+ /* 2 bytes padding before packet header */
+ unsigned xfer_pad:1;
+
+ unsigned reserved:7;
+} __attribute__ ((packed));
+
+
+struct tx_double_buffer_desc {
+ /* Length of payload, including headers. */
+ u16 length;
+
+ /*
+ * A bit mask that specifies the initial rate to be used
+ * Possible values are:
+ * 0x0001 - 1Mbits
+ * 0x0002 - 2Mbits
+ * 0x0004 - 5.5Mbits
+ * 0x0008 - 6Mbits
+ * 0x0010 - 9Mbits
+ * 0x0020 - 11Mbits
+ * 0x0040 - 12Mbits
+ * 0x0080 - 18Mbits
+ * 0x0100 - 22Mbits
+ * 0x0200 - 24Mbits
+ * 0x0400 - 36Mbits
+ * 0x0800 - 48Mbits
+ * 0x1000 - 54Mbits
+ */
+ u16 rate;
+
+ /* Time in us that a packet can spend in the target */
+ u32 expiry_time;
+
+ /* index of the TX queue used for this packet */
+ u8 xmit_queue;
+
+ /* Used to identify a packet */
+ u8 id;
+
+ struct tx_control control;
+
+ /*
+ * The FW should cut the packet into fragments
+ * of this size.
+ */
+ u16 frag_threshold;
+
+ /* Numbers of HW queue blocks to be allocated */
+ u8 num_mem_blocks;
+
+ u8 reserved;
+} __attribute__ ((packed));
+
+enum {
+ TX_SUCCESS = 0,
+ TX_DMA_ERROR = BIT(7),
+ TX_DISABLED = BIT(6),
+ TX_RETRY_EXCEEDED = BIT(5),
+ TX_TIMEOUT = BIT(4),
+ TX_KEY_NOT_FOUND = BIT(3),
+ TX_ENCRYPT_FAIL = BIT(2),
+ TX_UNAVAILABLE_PRIORITY = BIT(1),
+};
+
+struct tx_result {
+ /*
+ * Ownership synchronization between the host and
+ * the firmware. If done_1 and done_2 are cleared,
+ * owned by the FW (no info ready).
+ */
+ u8 done_1;
+
+ /* same as double_buffer_desc->id */
+ u8 id;
+
+ /*
+ * Total air access duration consumed by this
+ * packet, including all retries and overheads.
+ */
+ u16 medium_usage;
+
+ /* Total media delay (from 1st EDCA AIFS counter until TX Complete). */
+ u32 medium_delay;
+
+ /* Time between host xfer and tx complete */
+ u32 fw_hnadling_time;
+
+ /* The LS-byte of the last TKIP sequence number. */
+ u8 lsb_seq_num;
+
+ /* Retry count */
+ u8 ack_failures;
+
+ /* At which rate we got a ACK */
+ u16 rate;
+
+ u16 reserved;
+
+ /* TX_* */
+ u8 status;
+
+ /* See done_1 */
+ u8 done_2;
+} __attribute__ ((packed));
+
+void wl12xx_tx_work(struct work_struct *work);
+void wl12xx_tx_complete(struct wl12xx *wl);
+void wl12xx_tx_flush(struct wl12xx *wl);
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/wl1251.c b/drivers/net/wireless/wl12xx/wl1251.c
new file mode 100644
index 000000000000..ce1561a41fa4
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1251.c
@@ -0,0 +1,709 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008-2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "wl1251.h"
+#include "reg.h"
+#include "spi.h"
+#include "boot.h"
+#include "event.h"
+#include "acx.h"
+#include "tx.h"
+#include "rx.h"
+#include "ps.h"
+#include "init.h"
+
+static struct wl12xx_partition_set wl1251_part_table[PART_TABLE_LEN] = {
+ [PART_DOWN] = {
+ .mem = {
+ .start = 0x00000000,
+ .size = 0x00016800
+ },
+ .reg = {
+ .start = REGISTERS_BASE,
+ .size = REGISTERS_DOWN_SIZE
+ },
+ },
+
+ [PART_WORK] = {
+ .mem = {
+ .start = 0x00028000,
+ .size = 0x00014000
+ },
+ .reg = {
+ .start = REGISTERS_BASE,
+ .size = REGISTERS_WORK_SIZE
+ },
+ },
+
+ /* WL1251 doesn't use the DRPW partition, so we don't set it here */
+};
+
+static enum wl12xx_acx_int_reg wl1251_acx_reg_table[ACX_REG_TABLE_LEN] = {
+ [ACX_REG_INTERRUPT_TRIG] = (REGISTERS_BASE + 0x0474),
+ [ACX_REG_INTERRUPT_TRIG_H] = (REGISTERS_BASE + 0x0478),
+ [ACX_REG_INTERRUPT_MASK] = (REGISTERS_BASE + 0x0494),
+ [ACX_REG_HINT_MASK_SET] = (REGISTERS_BASE + 0x0498),
+ [ACX_REG_HINT_MASK_CLR] = (REGISTERS_BASE + 0x049C),
+ [ACX_REG_INTERRUPT_NO_CLEAR] = (REGISTERS_BASE + 0x04B0),
+ [ACX_REG_INTERRUPT_CLEAR] = (REGISTERS_BASE + 0x04A4),
+ [ACX_REG_INTERRUPT_ACK] = (REGISTERS_BASE + 0x04A8),
+ [ACX_REG_SLV_SOFT_RESET] = (REGISTERS_BASE + 0x0000),
+ [ACX_REG_EE_START] = (REGISTERS_BASE + 0x080C),
+ [ACX_REG_ECPU_CONTROL] = (REGISTERS_BASE + 0x0804)
+};
+
+static int wl1251_upload_firmware(struct wl12xx *wl)
+{
+ struct wl12xx_partition_set *p_table = wl->chip.p_table;
+ int addr, chunk_num, partition_limit;
+ size_t fw_data_len;
+ u8 *p;
+
+ /* whal_FwCtrl_LoadFwImageSm() */
+
+ wl12xx_debug(DEBUG_BOOT, "chip id before fw upload: 0x%x",
+ wl12xx_reg_read32(wl, CHIP_ID_B));
+
+ /* 10.0 check firmware length and set partition */
+ fw_data_len = (wl->fw[4] << 24) | (wl->fw[5] << 16) |
+ (wl->fw[6] << 8) | (wl->fw[7]);
+
+ wl12xx_debug(DEBUG_BOOT, "fw_data_len %zu chunk_size %d", fw_data_len,
+ CHUNK_SIZE);
+
+ if ((fw_data_len % 4) != 0) {
+ wl12xx_error("firmware length not multiple of four");
+ return -EIO;
+ }
+
+ wl12xx_set_partition(wl,
+ p_table[PART_DOWN].mem.start,
+ p_table[PART_DOWN].mem.size,
+ p_table[PART_DOWN].reg.start,
+ p_table[PART_DOWN].reg.size);
+
+ /* 10.1 set partition limit and chunk num */
+ chunk_num = 0;
+ partition_limit = p_table[PART_DOWN].mem.size;
+
+ while (chunk_num < fw_data_len / CHUNK_SIZE) {
+ /* 10.2 update partition, if needed */
+ addr = p_table[PART_DOWN].mem.start +
+ (chunk_num + 2) * CHUNK_SIZE;
+ if (addr > partition_limit) {
+ addr = p_table[PART_DOWN].mem.start +
+ chunk_num * CHUNK_SIZE;
+ partition_limit = chunk_num * CHUNK_SIZE +
+ p_table[PART_DOWN].mem.size;
+ wl12xx_set_partition(wl,
+ addr,
+ p_table[PART_DOWN].mem.size,
+ p_table[PART_DOWN].reg.start,
+ p_table[PART_DOWN].reg.size);
+ }
+
+ /* 10.3 upload the chunk */
+ addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE;
+ p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE;
+ wl12xx_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x",
+ p, addr);
+ wl12xx_spi_mem_write(wl, addr, p, CHUNK_SIZE);
+
+ chunk_num++;
+ }
+
+ /* 10.4 upload the last chunk */
+ addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE;
+ p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE;
+ wl12xx_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x",
+ fw_data_len % CHUNK_SIZE, p, addr);
+ wl12xx_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE);
+
+ return 0;
+}
+
+static int wl1251_upload_nvs(struct wl12xx *wl)
+{
+ size_t nvs_len, nvs_bytes_written, burst_len;
+ int nvs_start, i;
+ u32 dest_addr, val;
+ u8 *nvs_ptr, *nvs;
+
+ nvs = wl->nvs;
+ if (nvs == NULL)
+ return -ENODEV;
+
+ nvs_ptr = nvs;
+
+ nvs_len = wl->nvs_len;
+ nvs_start = wl->fw_len;
+
+ /*
+ * Layout before the actual NVS tables:
+ * 1 byte : burst length.
+ * 2 bytes: destination address.
+ * n bytes: data to burst copy.
+ *
+ * This is ended by a 0 length, then the NVS tables.
+ */
+
+ while (nvs_ptr[0]) {
+ burst_len = nvs_ptr[0];
+ dest_addr = (nvs_ptr[1] & 0xfe) | ((u32)(nvs_ptr[2] << 8));
+
+ /* We move our pointer to the data */
+ nvs_ptr += 3;
+
+ for (i = 0; i < burst_len; i++) {
+ val = (nvs_ptr[0] | (nvs_ptr[1] << 8)
+ | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24));
+
+ wl12xx_debug(DEBUG_BOOT,
+ "nvs burst write 0x%x: 0x%x",
+ dest_addr, val);
+ wl12xx_mem_write32(wl, dest_addr, val);
+
+ nvs_ptr += 4;
+ dest_addr += 4;
+ }
+ }
+
+ /*
+ * We've reached the first zero length, the first NVS table
+ * is 7 bytes further.
+ */
+ nvs_ptr += 7;
+ nvs_len -= nvs_ptr - nvs;
+ nvs_len = ALIGN(nvs_len, 4);
+
+ /* Now we must set the partition correctly */
+ wl12xx_set_partition(wl, nvs_start,
+ wl->chip.p_table[PART_DOWN].mem.size,
+ wl->chip.p_table[PART_DOWN].reg.start,
+ wl->chip.p_table[PART_DOWN].reg.size);
+
+ /* And finally we upload the NVS tables */
+ nvs_bytes_written = 0;
+ while (nvs_bytes_written < nvs_len) {
+ val = (nvs_ptr[0] | (nvs_ptr[1] << 8)
+ | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24));
+
+ val = cpu_to_le32(val);
+
+ wl12xx_debug(DEBUG_BOOT,
+ "nvs write table 0x%x: 0x%x",
+ nvs_start, val);
+ wl12xx_mem_write32(wl, nvs_start, val);
+
+ nvs_ptr += 4;
+ nvs_bytes_written += 4;
+ nvs_start += 4;
+ }
+
+ return 0;
+}
+
+static int wl1251_boot(struct wl12xx *wl)
+{
+ int ret = 0, minor_minor_e2_ver;
+ u32 tmp, boot_data;
+
+ ret = wl12xx_boot_soft_reset(wl);
+ if (ret < 0)
+ goto out;
+
+ /* 2. start processing NVS file */
+ ret = wl->chip.op_upload_nvs(wl);
+ if (ret < 0)
+ goto out;
+
+ /* write firmware's last address (ie. it's length) to
+ * ACX_EEPROMLESS_IND_REG */
+ wl12xx_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len);
+
+ /* 6. read the EEPROM parameters */
+ tmp = wl12xx_reg_read32(wl, SCR_PAD2);
+
+ /* 7. read bootdata */
+ wl->boot_attr.radio_type = (tmp & 0x0000FF00) >> 8;
+ wl->boot_attr.major = (tmp & 0x00FF0000) >> 16;
+ tmp = wl12xx_reg_read32(wl, SCR_PAD3);
+
+ /* 8. check bootdata and call restart sequence */
+ wl->boot_attr.minor = (tmp & 0x00FF0000) >> 16;
+ minor_minor_e2_ver = (tmp & 0xFF000000) >> 24;
+
+ wl12xx_debug(DEBUG_BOOT, "radioType 0x%x majorE2Ver 0x%x "
+ "minorE2Ver 0x%x minor_minor_e2_ver 0x%x",
+ wl->boot_attr.radio_type, wl->boot_attr.major,
+ wl->boot_attr.minor, minor_minor_e2_ver);
+
+ ret = wl12xx_boot_init_seq(wl);
+ if (ret < 0)
+ goto out;
+
+ /* 9. NVS processing done */
+ boot_data = wl12xx_reg_read32(wl, ACX_REG_ECPU_CONTROL);
+
+ wl12xx_debug(DEBUG_BOOT, "halt boot_data 0x%x", boot_data);
+
+ /* 10. check that ECPU_CONTROL_HALT bits are set in
+ * pWhalBus->uBootData and start uploading firmware
+ */
+ if ((boot_data & ECPU_CONTROL_HALT) == 0) {
+ wl12xx_error("boot failed, ECPU_CONTROL_HALT not set");
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = wl->chip.op_upload_fw(wl);
+ if (ret < 0)
+ goto out;
+
+ /* 10.5 start firmware */
+ ret = wl12xx_boot_run_firmware(wl);
+ if (ret < 0)
+ goto out;
+
+ /* Get and save the firmware version */
+ wl12xx_acx_fw_version(wl, wl->chip.fw_ver, sizeof(wl->chip.fw_ver));
+
+out:
+ return ret;
+}
+
+static int wl1251_mem_cfg(struct wl12xx *wl)
+{
+ struct wl1251_acx_config_memory mem_conf;
+ int ret, i;
+
+ wl12xx_debug(DEBUG_ACX, "wl1251 mem cfg");
+
+ /* memory config */
+ mem_conf.mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
+ mem_conf.mem_config.rx_mem_block_num = 35;
+ mem_conf.mem_config.tx_min_mem_block_num = 64;
+ mem_conf.mem_config.num_tx_queues = MAX_TX_QUEUES;
+ mem_conf.mem_config.host_if_options = HOSTIF_PKT_RING;
+ mem_conf.mem_config.num_ssid_profiles = 1;
+ mem_conf.mem_config.debug_buffer_size =
+ cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
+
+ /* RX queue config */
+ mem_conf.rx_queue_config.dma_address = 0;
+ mem_conf.rx_queue_config.num_descs = ACX_RX_DESC_DEF;
+ mem_conf.rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
+ mem_conf.rx_queue_config.type = DEFAULT_RXQ_TYPE;
+
+ /* TX queue config */
+ for (i = 0; i < MAX_TX_QUEUES; i++) {
+ mem_conf.tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
+ mem_conf.tx_queue_config[i].attributes = i;
+ }
+
+ mem_conf.header.id = ACX_MEM_CFG;
+ mem_conf.header.len = sizeof(struct wl1251_acx_config_memory) -
+ sizeof(struct acx_header);
+ mem_conf.header.len -=
+ (MAX_TX_QUEUE_CONFIGS - mem_conf.mem_config.num_tx_queues) *
+ sizeof(struct wl1251_acx_tx_queue_config);
+
+ ret = wl12xx_cmd_configure(wl, &mem_conf,
+ sizeof(struct wl1251_acx_config_memory));
+ if (ret < 0)
+ wl12xx_warning("wl1251 mem config failed: %d", ret);
+
+ return ret;
+}
+
+static int wl1251_hw_init_mem_config(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl1251_mem_cfg(wl);
+ if (ret < 0)
+ return ret;
+
+ wl->target_mem_map = kzalloc(sizeof(struct wl1251_acx_mem_map),
+ GFP_KERNEL);
+ if (!wl->target_mem_map) {
+ wl12xx_error("couldn't allocate target memory map");
+ return -ENOMEM;
+ }
+
+ /* we now ask for the firmware built memory map */
+ ret = wl12xx_acx_mem_map(wl, wl->target_mem_map,
+ sizeof(struct wl1251_acx_mem_map));
+ if (ret < 0) {
+ wl12xx_error("couldn't retrieve firmware memory map");
+ kfree(wl->target_mem_map);
+ wl->target_mem_map = NULL;
+ return ret;
+ }
+
+ return 0;
+}
+
+static void wl1251_set_ecpu_ctrl(struct wl12xx *wl, u32 flag)
+{
+ u32 cpu_ctrl;
+
+ /* 10.5.0 run the firmware (I) */
+ cpu_ctrl = wl12xx_reg_read32(wl, ACX_REG_ECPU_CONTROL);
+
+ /* 10.5.1 run the firmware (II) */
+ cpu_ctrl &= ~flag;
+ wl12xx_reg_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl);
+}
+
+static void wl1251_target_enable_interrupts(struct wl12xx *wl)
+{
+ /* Enable target's interrupts */
+ wl->intr_mask = WL1251_ACX_INTR_RX0_DATA |
+ WL1251_ACX_INTR_RX1_DATA |
+ WL1251_ACX_INTR_TX_RESULT |
+ WL1251_ACX_INTR_EVENT_A |
+ WL1251_ACX_INTR_EVENT_B |
+ WL1251_ACX_INTR_INIT_COMPLETE;
+ wl12xx_boot_target_enable_interrupts(wl);
+}
+
+static void wl1251_irq_work(struct work_struct *work)
+{
+ u32 intr;
+ struct wl12xx *wl =
+ container_of(work, struct wl12xx, irq_work);
+
+ mutex_lock(&wl->mutex);
+
+ wl12xx_debug(DEBUG_IRQ, "IRQ work");
+
+ if (wl->state == WL12XX_STATE_OFF)
+ goto out;
+
+ wl12xx_ps_elp_wakeup(wl);
+
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL);
+
+ intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
+ wl12xx_debug(DEBUG_IRQ, "intr: 0x%x", intr);
+
+ if (wl->data_path) {
+ wl12xx_spi_mem_read(wl, wl->data_path->rx_control_addr,
+ &wl->rx_counter, sizeof(u32));
+
+ /* We handle a frmware bug here */
+ switch ((wl->rx_counter - wl->rx_handled) & 0xf) {
+ case 0:
+ wl12xx_debug(DEBUG_IRQ, "RX: FW and host in sync");
+ intr &= ~WL1251_ACX_INTR_RX0_DATA;
+ intr &= ~WL1251_ACX_INTR_RX1_DATA;
+ break;
+ case 1:
+ wl12xx_debug(DEBUG_IRQ, "RX: FW +1");
+ intr |= WL1251_ACX_INTR_RX0_DATA;
+ intr &= ~WL1251_ACX_INTR_RX1_DATA;
+ break;
+ case 2:
+ wl12xx_debug(DEBUG_IRQ, "RX: FW +2");
+ intr |= WL1251_ACX_INTR_RX0_DATA;
+ intr |= WL1251_ACX_INTR_RX1_DATA;
+ break;
+ default:
+ wl12xx_warning("RX: FW and host out of sync: %d",
+ wl->rx_counter - wl->rx_handled);
+ break;
+ }
+
+ wl->rx_handled = wl->rx_counter;
+
+
+ wl12xx_debug(DEBUG_IRQ, "RX counter: %d", wl->rx_counter);
+ }
+
+ intr &= wl->intr_mask;
+
+ if (intr == 0) {
+ wl12xx_debug(DEBUG_IRQ, "INTR is 0");
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK,
+ ~(wl->intr_mask));
+
+ goto out_sleep;
+ }
+
+ if (intr & WL1251_ACX_INTR_RX0_DATA) {
+ wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA");
+ wl12xx_rx(wl);
+ }
+
+ if (intr & WL1251_ACX_INTR_RX1_DATA) {
+ wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA");
+ wl12xx_rx(wl);
+ }
+
+ if (intr & WL1251_ACX_INTR_TX_RESULT) {
+ wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT");
+ wl12xx_tx_complete(wl);
+ }
+
+ if (intr & (WL1251_ACX_INTR_EVENT_A | WL1251_ACX_INTR_EVENT_B)) {
+ wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)", intr);
+ if (intr & WL1251_ACX_INTR_EVENT_A)
+ wl12xx_event_handle(wl, 0);
+ else
+ wl12xx_event_handle(wl, 1);
+ }
+
+ if (intr & WL1251_ACX_INTR_INIT_COMPLETE)
+ wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_INIT_COMPLETE");
+
+ wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
+
+out_sleep:
+ wl12xx_ps_elp_sleep(wl);
+out:
+ mutex_unlock(&wl->mutex);
+}
+
+static int wl1251_hw_init_txq_fill(u8 qid,
+ struct acx_tx_queue_qos_config *config,
+ u32 num_blocks)
+{
+ config->qid = qid;
+
+ switch (qid) {
+ case QOS_AC_BE:
+ config->high_threshold =
+ (QOS_TX_HIGH_BE_DEF * num_blocks) / 100;
+ config->low_threshold =
+ (QOS_TX_LOW_BE_DEF * num_blocks) / 100;
+ break;
+ case QOS_AC_BK:
+ config->high_threshold =
+ (QOS_TX_HIGH_BK_DEF * num_blocks) / 100;
+ config->low_threshold =
+ (QOS_TX_LOW_BK_DEF * num_blocks) / 100;
+ break;
+ case QOS_AC_VI:
+ config->high_threshold =
+ (QOS_TX_HIGH_VI_DEF * num_blocks) / 100;
+ config->low_threshold =
+ (QOS_TX_LOW_VI_DEF * num_blocks) / 100;
+ break;
+ case QOS_AC_VO:
+ config->high_threshold =
+ (QOS_TX_HIGH_VO_DEF * num_blocks) / 100;
+ config->low_threshold =
+ (QOS_TX_LOW_VO_DEF * num_blocks) / 100;
+ break;
+ default:
+ wl12xx_error("Invalid TX queue id: %d", qid);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int wl1251_hw_init_tx_queue_config(struct wl12xx *wl)
+{
+ struct acx_tx_queue_qos_config config;
+ struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map;
+ int ret, i;
+
+ wl12xx_debug(DEBUG_ACX, "acx tx queue config");
+
+ config.header.id = ACX_TX_QUEUE_CFG;
+ config.header.len = sizeof(struct acx_tx_queue_qos_config) -
+ sizeof(struct acx_header);
+
+ for (i = 0; i < MAX_NUM_OF_AC; i++) {
+ ret = wl1251_hw_init_txq_fill(i, &config,
+ wl_mem_map->num_tx_mem_blocks);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_configure(wl, &config, sizeof(config));
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int wl1251_hw_init_data_path_config(struct wl12xx *wl)
+{
+ int ret;
+
+ /* asking for the data path parameters */
+ wl->data_path = kzalloc(sizeof(struct acx_data_path_params_resp),
+ GFP_KERNEL);
+ if (!wl->data_path) {
+ wl12xx_error("Couldnt allocate data path parameters");
+ return -ENOMEM;
+ }
+
+ ret = wl12xx_acx_data_path_params(wl, wl->data_path);
+ if (ret < 0) {
+ kfree(wl->data_path);
+ wl->data_path = NULL;
+ return ret;
+ }
+
+ return 0;
+}
+
+static int wl1251_hw_init(struct wl12xx *wl)
+{
+ struct wl1251_acx_mem_map *wl_mem_map;
+ int ret;
+
+ ret = wl12xx_hw_init_hwenc_config(wl);
+ if (ret < 0)
+ return ret;
+
+ /* Template settings */
+ ret = wl12xx_hw_init_templates_config(wl);
+ if (ret < 0)
+ return ret;
+
+ /* Default memory configuration */
+ ret = wl1251_hw_init_mem_config(wl);
+ if (ret < 0)
+ return ret;
+
+ /* Default data path configuration */
+ ret = wl1251_hw_init_data_path_config(wl);
+ if (ret < 0)
+ goto out_free_memmap;
+
+ /* RX config */
+ ret = wl12xx_hw_init_rx_config(wl,
+ RX_CFG_PROMISCUOUS | RX_CFG_TSF,
+ RX_FILTER_OPTION_DEF);
+ /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
+ RX_FILTER_OPTION_FILTER_ALL); */
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* TX queues config */
+ ret = wl1251_hw_init_tx_queue_config(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* PHY layer config */
+ ret = wl12xx_hw_init_phy_config(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* Beacon filtering */
+ ret = wl12xx_hw_init_beacon_filter(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* Bluetooth WLAN coexistence */
+ ret = wl12xx_hw_init_pta(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* Energy detection */
+ ret = wl12xx_hw_init_energy_detection(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* Beacons and boradcast settings */
+ ret = wl12xx_hw_init_beacon_broadcast(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* Enable data path */
+ ret = wl12xx_cmd_data_path(wl, wl->channel, 1);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ /* Default power state */
+ ret = wl12xx_hw_init_power_auth(wl);
+ if (ret < 0)
+ goto out_free_data_path;
+
+ wl_mem_map = wl->target_mem_map;
+ wl12xx_info("%d tx blocks at 0x%x, %d rx blocks at 0x%x",
+ wl_mem_map->num_tx_mem_blocks,
+ wl->data_path->tx_control_addr,
+ wl_mem_map->num_rx_mem_blocks,
+ wl->data_path->rx_control_addr);
+
+ return 0;
+
+ out_free_data_path:
+ kfree(wl->data_path);
+
+ out_free_memmap:
+ kfree(wl->target_mem_map);
+
+ return ret;
+}
+
+static int wl1251_plt_init(struct wl12xx *wl)
+{
+ int ret;
+
+ ret = wl1251_hw_init_mem_config(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_cmd_data_path(wl, wl->channel, 1);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+void wl1251_setup(struct wl12xx *wl)
+{
+ /* FIXME: Is it better to use strncpy here or is this ok? */
+ wl->chip.fw_filename = WL1251_FW_NAME;
+ wl->chip.nvs_filename = WL1251_NVS_NAME;
+
+ /* Now we know what chip we're using, so adjust the power on sleep
+ * time accordingly */
+ wl->chip.power_on_sleep = WL1251_POWER_ON_SLEEP;
+
+ wl->chip.intr_cmd_complete = WL1251_ACX_INTR_CMD_COMPLETE;
+ wl->chip.intr_init_complete = WL1251_ACX_INTR_INIT_COMPLETE;
+
+ wl->chip.op_upload_nvs = wl1251_upload_nvs;
+ wl->chip.op_upload_fw = wl1251_upload_firmware;
+ wl->chip.op_boot = wl1251_boot;
+ wl->chip.op_set_ecpu_ctrl = wl1251_set_ecpu_ctrl;
+ wl->chip.op_target_enable_interrupts = wl1251_target_enable_interrupts;
+ wl->chip.op_hw_init = wl1251_hw_init;
+ wl->chip.op_plt_init = wl1251_plt_init;
+
+ wl->chip.p_table = wl1251_part_table;
+ wl->chip.acx_reg_table = wl1251_acx_reg_table;
+
+ INIT_WORK(&wl->irq_work, wl1251_irq_work);
+}
diff --git a/drivers/net/wireless/wl12xx/wl1251.h b/drivers/net/wireless/wl12xx/wl1251.h
new file mode 100644
index 000000000000..1f4a44330394
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1251.h
@@ -0,0 +1,165 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL1251_H__
+#define __WL1251_H__
+
+#include <linux/bitops.h>
+
+#include "wl12xx.h"
+#include "acx.h"
+
+#define WL1251_FW_NAME "wl1251-fw.bin"
+#define WL1251_NVS_NAME "wl1251-nvs.bin"
+
+#define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */
+
+void wl1251_setup(struct wl12xx *wl);
+
+
+struct wl1251_acx_memory {
+ __le16 num_stations; /* number of STAs to be supported. */
+ u16 reserved_1;
+
+ /*
+ * Nmber of memory buffers for the RX mem pool.
+ * The actual number may be less if there are
+ * not enough blocks left for the minimum num
+ * of TX ones.
+ */
+ u8 rx_mem_block_num;
+ u8 reserved_2;
+ u8 num_tx_queues; /* From 1 to 16 */
+ u8 host_if_options; /* HOST_IF* */
+ u8 tx_min_mem_block_num;
+ u8 num_ssid_profiles;
+ __le16 debug_buffer_size;
+} __attribute__ ((packed));
+
+
+#define ACX_RX_DESC_MIN 1
+#define ACX_RX_DESC_MAX 127
+#define ACX_RX_DESC_DEF 32
+struct wl1251_acx_rx_queue_config {
+ u8 num_descs;
+ u8 pad;
+ u8 type;
+ u8 priority;
+ __le32 dma_address;
+} __attribute__ ((packed));
+
+#define ACX_TX_DESC_MIN 1
+#define ACX_TX_DESC_MAX 127
+#define ACX_TX_DESC_DEF 16
+struct wl1251_acx_tx_queue_config {
+ u8 num_descs;
+ u8 pad[2];
+ u8 attributes;
+} __attribute__ ((packed));
+
+#define MAX_TX_QUEUE_CONFIGS 5
+#define MAX_TX_QUEUES 4
+struct wl1251_acx_config_memory {
+ struct acx_header header;
+
+ struct wl1251_acx_memory mem_config;
+ struct wl1251_acx_rx_queue_config rx_queue_config;
+ struct wl1251_acx_tx_queue_config tx_queue_config[MAX_TX_QUEUE_CONFIGS];
+} __attribute__ ((packed));
+
+struct wl1251_acx_mem_map {
+ struct acx_header header;
+
+ void *code_start;
+ void *code_end;
+
+ void *wep_defkey_start;
+ void *wep_defkey_end;
+
+ void *sta_table_start;
+ void *sta_table_end;
+
+ void *packet_template_start;
+ void *packet_template_end;
+
+ void *queue_memory_start;
+ void *queue_memory_end;
+
+ void *packet_memory_pool_start;
+ void *packet_memory_pool_end;
+
+ void *debug_buffer1_start;
+ void *debug_buffer1_end;
+
+ void *debug_buffer2_start;
+ void *debug_buffer2_end;
+
+ /* Number of blocks FW allocated for TX packets */
+ u32 num_tx_mem_blocks;
+
+ /* Number of blocks FW allocated for RX packets */
+ u32 num_rx_mem_blocks;
+} __attribute__ ((packed));
+
+/*************************************************************************
+
+ Host Interrupt Register (WiLink -> Host)
+
+**************************************************************************/
+
+/* RX packet is ready in Xfer buffer #0 */
+#define WL1251_ACX_INTR_RX0_DATA BIT(0)
+
+/* TX result(s) are in the TX complete buffer */
+#define WL1251_ACX_INTR_TX_RESULT BIT(1)
+
+/* OBSOLETE */
+#define WL1251_ACX_INTR_TX_XFR BIT(2)
+
+/* RX packet is ready in Xfer buffer #1 */
+#define WL1251_ACX_INTR_RX1_DATA BIT(3)
+
+/* Event was entered to Event MBOX #A */
+#define WL1251_ACX_INTR_EVENT_A BIT(4)
+
+/* Event was entered to Event MBOX #B */
+#define WL1251_ACX_INTR_EVENT_B BIT(5)
+
+/* OBSOLETE */
+#define WL1251_ACX_INTR_WAKE_ON_HOST BIT(6)
+
+/* Trace meassge on MBOX #A */
+#define WL1251_ACX_INTR_TRACE_A BIT(7)
+
+/* Trace meassge on MBOX #B */
+#define WL1251_ACX_INTR_TRACE_B BIT(8)
+
+/* Command processing completion */
+#define WL1251_ACX_INTR_CMD_COMPLETE BIT(9)
+
+/* Init sequence is done */
+#define WL1251_ACX_INTR_INIT_COMPLETE BIT(14)
+
+#define WL1251_ACX_INTR_ALL 0xFFFFFFFF
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
new file mode 100644
index 000000000000..48641437414b
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -0,0 +1,409 @@
+/*
+ * This file is part of wl12xx
+ *
+ * Copyright (c) 1998-2007 Texas Instruments Incorporated
+ * Copyright (C) 2008-2009 Nokia Corporation
+ *
+ * Contact: Kalle Valo <kalle.valo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __WL12XX_H__
+#define __WL12XX_H__
+
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/bitops.h>
+#include <net/mac80211.h>
+
+#define DRIVER_NAME "wl12xx"
+#define DRIVER_PREFIX DRIVER_NAME ": "
+
+enum {
+ DEBUG_NONE = 0,
+ DEBUG_IRQ = BIT(0),
+ DEBUG_SPI = BIT(1),
+ DEBUG_BOOT = BIT(2),
+ DEBUG_MAILBOX = BIT(3),
+ DEBUG_NETLINK = BIT(4),
+ DEBUG_EVENT = BIT(5),
+ DEBUG_TX = BIT(6),
+ DEBUG_RX = BIT(7),
+ DEBUG_SCAN = BIT(8),
+ DEBUG_CRYPT = BIT(9),
+ DEBUG_PSM = BIT(10),
+ DEBUG_MAC80211 = BIT(11),
+ DEBUG_CMD = BIT(12),
+ DEBUG_ACX = BIT(13),
+ DEBUG_ALL = ~0,
+};
+
+#define DEBUG_LEVEL (DEBUG_NONE)
+
+#define DEBUG_DUMP_LIMIT 1024
+
+#define wl12xx_error(fmt, arg...) \
+ printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
+
+#define wl12xx_warning(fmt, arg...) \
+ printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
+
+#define wl12xx_notice(fmt, arg...) \
+ printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg)
+
+#define wl12xx_info(fmt, arg...) \
+ printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg)
+
+#define wl12xx_debug(level, fmt, arg...) \
+ do { \
+ if (level & DEBUG_LEVEL) \
+ printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \
+ } while (0)
+
+#define wl12xx_dump(level, prefix, buf, len) \
+ do { \
+ if (level & DEBUG_LEVEL) \
+ print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
+ DUMP_PREFIX_OFFSET, 16, 1, \
+ buf, \
+ min_t(size_t, len, DEBUG_DUMP_LIMIT), \
+ 0); \
+ } while (0)
+
+#define wl12xx_dump_ascii(level, prefix, buf, len) \
+ do { \
+ if (level & DEBUG_LEVEL) \
+ print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
+ DUMP_PREFIX_OFFSET, 16, 1, \
+ buf, \
+ min_t(size_t, len, DEBUG_DUMP_LIMIT), \
+ true); \
+ } while (0)
+
+#define WL12XX_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \
+ CFG_BSSID_FILTER_EN)
+
+#define WL12XX_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \
+ CFG_RX_MGMT_EN | \
+ CFG_RX_DATA_EN | \
+ CFG_RX_CTL_EN | \
+ CFG_RX_BCN_EN | \
+ CFG_RX_AUTH_EN | \
+ CFG_RX_ASSOC_EN)
+
+
+struct boot_attr {
+ u32 radio_type;
+ u8 mac_clock;
+ u8 arm_clock;
+ int firmware_debug;
+ u32 minor;
+ u32 major;
+ u32 bugfix;
+};
+
+enum wl12xx_state {
+ WL12XX_STATE_OFF,
+ WL12XX_STATE_ON,
+ WL12XX_STATE_PLT,
+};
+
+enum wl12xx_partition_type {
+ PART_DOWN,
+ PART_WORK,
+ PART_DRPW,
+
+ PART_TABLE_LEN
+};
+
+struct wl12xx_partition {
+ u32 size;
+ u32 start;
+};
+
+struct wl12xx_partition_set {
+ struct wl12xx_partition mem;
+ struct wl12xx_partition reg;
+};
+
+struct wl12xx;
+
+/* FIXME: I'm not sure about this structure name */
+struct wl12xx_chip {
+ u32 id;
+
+ const char *fw_filename;
+ const char *nvs_filename;
+
+ char fw_ver[21];
+
+ unsigned int power_on_sleep;
+ int intr_cmd_complete;
+ int intr_init_complete;
+
+ int (*op_upload_fw)(struct wl12xx *wl);
+ int (*op_upload_nvs)(struct wl12xx *wl);
+ int (*op_boot)(struct wl12xx *wl);
+ void (*op_set_ecpu_ctrl)(struct wl12xx *wl, u32 flag);
+ void (*op_target_enable_interrupts)(struct wl12xx *wl);
+ int (*op_hw_init)(struct wl12xx *wl);
+ int (*op_plt_init)(struct wl12xx *wl);
+
+ struct wl12xx_partition_set *p_table;
+ enum wl12xx_acx_int_reg *acx_reg_table;
+};
+
+struct wl12xx_stats {
+ struct acx_statistics *fw_stats;
+ unsigned long fw_stats_update;
+
+ unsigned int retry_count;
+ unsigned int excessive_retries;
+};
+
+struct wl12xx_debugfs {
+ struct dentry *rootdir;
+ struct dentry *fw_statistics;
+
+ struct dentry *tx_internal_desc_overflow;
+
+ struct dentry *rx_out_of_mem;
+ struct dentry *rx_hdr_overflow;
+ struct dentry *rx_hw_stuck;
+ struct dentry *rx_dropped;
+ struct dentry *rx_fcs_err;
+ struct dentry *rx_xfr_hint_trig;
+ struct dentry *rx_path_reset;
+ struct dentry *rx_reset_counter;
+
+ struct dentry *dma_rx_requested;
+ struct dentry *dma_rx_errors;
+ struct dentry *dma_tx_requested;
+ struct dentry *dma_tx_errors;
+
+ struct dentry *isr_cmd_cmplt;
+ struct dentry *isr_fiqs;
+ struct dentry *isr_rx_headers;
+ struct dentry *isr_rx_mem_overflow;
+ struct dentry *isr_rx_rdys;
+ struct dentry *isr_irqs;
+ struct dentry *isr_tx_procs;
+ struct dentry *isr_decrypt_done;
+ struct dentry *isr_dma0_done;
+ struct dentry *isr_dma1_done;
+ struct dentry *isr_tx_exch_complete;
+ struct dentry *isr_commands;
+ struct dentry *isr_rx_procs;
+ struct dentry *isr_hw_pm_mode_changes;
+ struct dentry *isr_host_acknowledges;
+ struct dentry *isr_pci_pm;
+ struct dentry *isr_wakeups;
+ struct dentry *isr_low_rssi;
+
+ struct dentry *wep_addr_key_count;
+ struct dentry *wep_default_key_count;
+ /* skipping wep.reserved */
+ struct dentry *wep_key_not_found;
+ struct dentry *wep_decrypt_fail;
+ struct dentry *wep_packets;
+ struct dentry *wep_interrupt;
+
+ struct dentry *pwr_ps_enter;
+ struct dentry *pwr_elp_enter;
+ struct dentry *pwr_missing_bcns;
+ struct dentry *pwr_wake_on_host;
+ struct dentry *pwr_wake_on_timer_exp;
+ struct dentry *pwr_tx_with_ps;
+ struct dentry *pwr_tx_without_ps;
+ struct dentry *pwr_rcvd_beacons;
+ struct dentry *pwr_power_save_off;
+ struct dentry *pwr_enable_ps;
+ struct dentry *pwr_disable_ps;
+ struct dentry *pwr_fix_tsf_ps;
+ /* skipping cont_miss_bcns_spread for now */
+ struct dentry *pwr_rcvd_awake_beacons;
+
+ struct dentry *mic_rx_pkts;
+ struct dentry *mic_calc_failure;
+
+ struct dentry *aes_encrypt_fail;
+ struct dentry *aes_decrypt_fail;
+ struct dentry *aes_encrypt_packets;
+ struct dentry *aes_decrypt_packets;
+ struct dentry *aes_encrypt_interrupt;
+ struct dentry *aes_decrypt_interrupt;
+
+ struct dentry *event_heart_beat;
+ struct dentry *event_calibration;
+ struct dentry *event_rx_mismatch;
+ struct dentry *event_rx_mem_empty;
+ struct dentry *event_rx_pool;
+ struct dentry *event_oom_late;
+ struct dentry *event_phy_transmit_error;
+ struct dentry *event_tx_stuck;
+
+ struct dentry *ps_pspoll_timeouts;
+ struct dentry *ps_upsd_timeouts;
+ struct dentry *ps_upsd_max_sptime;
+ struct dentry *ps_upsd_max_apturn;
+ struct dentry *ps_pspoll_max_apturn;
+ struct dentry *ps_pspoll_utilization;
+ struct dentry *ps_upsd_utilization;
+
+ struct dentry *rxpipe_rx_prep_beacon_drop;
+ struct dentry *rxpipe_descr_host_int_trig_rx_data;
+ struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data;
+ struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data;
+ struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data;
+
+ struct dentry *tx_queue_len;
+
+ struct dentry *retry_count;
+ struct dentry *excessive_retries;
+};
+
+struct wl12xx {
+ struct ieee80211_hw *hw;
+ bool mac80211_registered;
+
+ struct spi_device *spi;
+
+ void (*set_power)(bool enable);
+ int irq;
+
+ enum wl12xx_state state;
+ struct mutex mutex;
+
+ int physical_mem_addr;
+ int physical_reg_addr;
+ int virtual_mem_addr;
+ int virtual_reg_addr;
+
+ struct wl12xx_chip chip;
+
+ int cmd_box_addr;
+ int event_box_addr;
+ struct boot_attr boot_attr;
+
+ u8 *fw;
+ size_t fw_len;
+ u8 *nvs;
+ size_t nvs_len;
+
+ u8 bssid[ETH_ALEN];
+ u8 mac_addr[ETH_ALEN];
+ u8 bss_type;
+ u8 listen_int;
+ int channel;
+
+ void *target_mem_map;
+ struct acx_data_path_params_resp *data_path;
+
+ /* Number of TX packets transferred to the FW, modulo 16 */
+ u32 data_in_count;
+
+ /* Frames scheduled for transmission, not handled yet */
+ struct sk_buff_head tx_queue;
+ bool tx_queue_stopped;
+
+ struct work_struct tx_work;
+ struct work_struct filter_work;
+
+ /* Pending TX frames */
+ struct sk_buff *tx_frames[16];
+
+ /*
+ * Index pointing to the next TX complete entry
+ * in the cyclic XT complete array we get from
+ * the FW.
+ */
+ u32 next_tx_complete;
+
+ /* FW Rx counter */
+ u32 rx_counter;
+
+ /* Rx frames handled */
+ u32 rx_handled;
+
+ /* Current double buffer */
+ u32 rx_current_buffer;
+ u32 rx_last_id;
+
+ /* The target interrupt mask */
+ u32 intr_mask;
+ struct work_struct irq_work;
+
+ /* The mbox event mask */
+ u32 event_mask;
+
+ /* Mailbox pointers */
+ u32 mbox_ptr[2];
+
+ /* Are we currently scanning */
+ bool scanning;
+
+ /* Our association ID */
+ u16 aid;
+
+ /* Default key (for WEP) */
+ u32 default_key;
+
+ unsigned int tx_mgmt_frm_rate;
+ unsigned int tx_mgmt_frm_mod;
+
+ unsigned int rx_config;
+ unsigned int rx_filter;
+
+ /* is firmware in elp mode */
+ bool elp;
+
+ /* we can be in psm, but not in elp, we have to differentiate */
+ bool psm;
+
+ /* PSM mode requested */
+ bool psm_requested;
+
+ /* in dBm */
+ int power_level;
+
+ struct wl12xx_stats stats;
+ struct wl12xx_debugfs debugfs;
+};
+
+int wl12xx_plt_start(struct wl12xx *wl);
+int wl12xx_plt_stop(struct wl12xx *wl);
+
+#define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */
+#define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS
+#define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
+
+#define WL12XX_DEFAULT_POWER_LEVEL 20
+
+#define WL12XX_TX_QUEUE_MAX_LENGTH 20
+
+/* Different chips need different sleep times after power on. WL1271 needs
+ * 200ms, WL1251 needs only 10ms. By default we use 200ms, but as soon as we
+ * know the chip ID, we change the sleep value in the wl12xx chip structure,
+ * so in subsequent power ons, we don't waste more time then needed. */
+#define WL12XX_DEFAULT_POWER_ON_SLEEP 200
+
+#define CHIP_ID_1251_PG10 (0x7010101)
+#define CHIP_ID_1251_PG11 (0x7020101)
+#define CHIP_ID_1251_PG12 (0x7030101)
+#define CHIP_ID_1271_PG10 (0x4030101)
+
+#endif
diff --git a/drivers/net/wireless/wl12xx/wl12xx_80211.h b/drivers/net/wireless/wl12xx/wl12xx_80211.h
new file mode 100644
index 000000000000..657c2dbcb7d3
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl12xx_80211.h
@@ -0,0 +1,156 @@
+#ifndef __WL12XX_80211_H__
+#define __WL12XX_80211_H__
+
+#include <linux/if_ether.h> /* ETH_ALEN */
+
+/* RATES */
+#define IEEE80211_CCK_RATE_1MB 0x02
+#define IEEE80211_CCK_RATE_2MB 0x04
+#define IEEE80211_CCK_RATE_5MB 0x0B
+#define IEEE80211_CCK_RATE_11MB 0x16
+#define IEEE80211_OFDM_RATE_6MB 0x0C
+#define IEEE80211_OFDM_RATE_9MB 0x12
+#define IEEE80211_OFDM_RATE_12MB 0x18
+#define IEEE80211_OFDM_RATE_18MB 0x24
+#define IEEE80211_OFDM_RATE_24MB 0x30
+#define IEEE80211_OFDM_RATE_36MB 0x48
+#define IEEE80211_OFDM_RATE_48MB 0x60
+#define IEEE80211_OFDM_RATE_54MB 0x6C
+#define IEEE80211_BASIC_RATE_MASK 0x80
+
+#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
+#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
+#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
+#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
+#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
+#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
+#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
+#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
+#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
+#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
+#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
+#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
+
+#define IEEE80211_CCK_RATES_MASK 0x0000000F
+#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
+ IEEE80211_CCK_RATE_2MB_MASK)
+#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
+ IEEE80211_CCK_RATE_5MB_MASK | \
+ IEEE80211_CCK_RATE_11MB_MASK)
+
+#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
+#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
+ IEEE80211_OFDM_RATE_12MB_MASK | \
+ IEEE80211_OFDM_RATE_24MB_MASK)
+#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
+ IEEE80211_OFDM_RATE_9MB_MASK | \
+ IEEE80211_OFDM_RATE_18MB_MASK | \
+ IEEE80211_OFDM_RATE_36MB_MASK | \
+ IEEE80211_OFDM_RATE_48MB_MASK | \
+ IEEE80211_OFDM_RATE_54MB_MASK)
+#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
+ IEEE80211_CCK_DEFAULT_RATES_MASK)
+
+
+/* This really should be 8, but not for our firmware */
+#define MAX_SUPPORTED_RATES 32
+#define COUNTRY_STRING_LEN 3
+#define MAX_COUNTRY_TRIPLETS 32
+
+/* Headers */
+struct ieee80211_header {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 da[ETH_ALEN];
+ u8 sa[ETH_ALEN];
+ u8 bssid[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct wl12xx_ie_header {
+ u8 id;
+ u8 len;
+} __attribute__ ((packed));
+
+/* IEs */
+
+struct wl12xx_ie_ssid {
+ struct wl12xx_ie_header header;
+ char ssid[IW_ESSID_MAX_SIZE];
+} __attribute__ ((packed));
+
+struct wl12xx_ie_rates {
+ struct wl12xx_ie_header header;
+ u8 rates[MAX_SUPPORTED_RATES];
+} __attribute__ ((packed));
+
+struct wl12xx_ie_ds_params {
+ struct wl12xx_ie_header header;
+ u8 channel;
+} __attribute__ ((packed));
+
+struct country_triplet {
+ u8 channel;
+ u8 num_channels;
+ u8 max_tx_power;
+} __attribute__ ((packed));
+
+struct wl12xx_ie_country {
+ struct wl12xx_ie_header header;
+ u8 country_string[COUNTRY_STRING_LEN];
+ struct country_triplet triplets[MAX_COUNTRY_TRIPLETS];
+} __attribute__ ((packed));
+
+
+/* Templates */
+
+struct wl12xx_beacon_template {
+ struct ieee80211_header header;
+ __le32 time_stamp[2];
+ __le16 beacon_interval;
+ __le16 capability;
+ struct wl12xx_ie_ssid ssid;
+ struct wl12xx_ie_rates rates;
+ struct wl12xx_ie_rates ext_rates;
+ struct wl12xx_ie_ds_params ds_params;
+ struct wl12xx_ie_country country;
+} __attribute__ ((packed));
+
+struct wl12xx_null_data_template {
+ struct ieee80211_header header;
+} __attribute__ ((packed));
+
+struct wl12xx_ps_poll_template {
+ u16 fc;
+ u16 aid;
+ u8 bssid[ETH_ALEN];
+ u8 ta[ETH_ALEN];
+} __attribute__ ((packed));
+
+struct wl12xx_qos_null_data_template {
+ struct ieee80211_header header;
+ __le16 qos_ctl;
+} __attribute__ ((packed));
+
+struct wl12xx_probe_req_template {
+ struct ieee80211_header header;
+ struct wl12xx_ie_ssid ssid;
+ struct wl12xx_ie_rates rates;
+ struct wl12xx_ie_rates ext_rates;
+} __attribute__ ((packed));
+
+
+struct wl12xx_probe_resp_template {
+ struct ieee80211_header header;
+ __le32 time_stamp[2];
+ __le16 beacon_interval;
+ __le16 capability;
+ struct wl12xx_ie_ssid ssid;
+ struct wl12xx_ie_rates rates;
+ struct wl12xx_ie_rates ext_rates;
+ struct wl12xx_ie_ds_params ds_params;
+ struct wl12xx_ie_country country;
+} __attribute__ ((packed));
+
+#endif
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index c3a51266de20..40b07b988224 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -420,9 +420,9 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
cs->control |= ZD_CS_NEED_RANDOM_BACKOFF;
- /* Multicast */
- if (is_multicast_ether_addr(header->addr1))
- cs->control |= ZD_CS_MULTICAST;
+ /* No ACK expected (multicast, etc.) */
+ if (info->flags & IEEE80211_TX_CTL_NO_ACK)
+ cs->control |= ZD_CS_NO_ACK;
/* PS-POLL */
if (ieee80211_is_pspoll(header->frame_control))
@@ -755,52 +755,6 @@ static int zd_op_config(struct ieee80211_hw *hw, u32 changed)
return zd_chip_set_channel(&mac->chip, conf->channel->hw_value);
}
-static int zd_op_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct zd_mac *mac = zd_hw_mac(hw);
- int associated;
- int r;
-
- if (mac->type == NL80211_IFTYPE_MESH_POINT ||
- mac->type == NL80211_IFTYPE_ADHOC) {
- associated = true;
- if (conf->changed & IEEE80211_IFCC_BEACON) {
- struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
-
- if (!beacon)
- return -ENOMEM;
- r = zd_mac_config_beacon(hw, beacon);
- kfree_skb(beacon);
-
- if (r < 0)
- return r;
- }
-
- if (conf->changed & IEEE80211_IFCC_BEACON_ENABLED) {
- u32 interval;
-
- if (conf->enable_beacon)
- interval = BCN_MODE_IBSS | hw->conf.beacon_int;
- else
- interval = 0;
-
- r = zd_set_beacon_interval(&mac->chip, interval);
- if (r < 0)
- return r;
- }
- } else
- associated = is_valid_ether_addr(conf->bssid);
-
- spin_lock_irq(&mac->lock);
- mac->associated = associated;
- spin_unlock_irq(&mac->lock);
-
- /* TODO: do hardware bssid filtering */
- return 0;
-}
-
static void zd_process_intr(struct work_struct *work)
{
u16 int_status;
@@ -923,9 +877,42 @@ static void zd_op_bss_info_changed(struct ieee80211_hw *hw,
{
struct zd_mac *mac = zd_hw_mac(hw);
unsigned long flags;
+ int associated;
dev_dbg_f(zd_mac_dev(mac), "changes: %x\n", changes);
+ if (mac->type == NL80211_IFTYPE_MESH_POINT ||
+ mac->type == NL80211_IFTYPE_ADHOC) {
+ associated = true;
+ if (changes & BSS_CHANGED_BEACON) {
+ struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
+
+ if (beacon) {
+ zd_mac_config_beacon(hw, beacon);
+ kfree_skb(beacon);
+ }
+ }
+
+ if (changes & BSS_CHANGED_BEACON_ENABLED) {
+ u32 interval;
+
+ if (bss_conf->enable_beacon)
+ interval = BCN_MODE_IBSS |
+ bss_conf->beacon_int;
+ else
+ interval = 0;
+
+ zd_set_beacon_interval(&mac->chip, interval);
+ }
+ } else
+ associated = is_valid_ether_addr(bss_conf->bssid);
+
+ spin_lock_irq(&mac->lock);
+ mac->associated = associated;
+ spin_unlock_irq(&mac->lock);
+
+ /* TODO: do hardware bssid filtering */
+
if (changes & BSS_CHANGED_ERP_PREAMBLE) {
spin_lock_irqsave(&mac->lock, flags);
mac->short_preamble = bss_conf->use_short_preamble;
@@ -952,7 +939,6 @@ static const struct ieee80211_ops zd_ops = {
.add_interface = zd_op_add_interface,
.remove_interface = zd_op_remove_interface,
.config = zd_op_config,
- .config_interface = zd_op_config_interface,
.configure_filter = zd_op_configure_filter,
.bss_info_changed = zd_op_bss_info_changed,
.get_tsf = zd_op_get_tsf,
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 4c05d3ee4c37..7c2759118d13 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -87,7 +87,7 @@ struct zd_ctrlset {
/* zd_ctrlset control field */
#define ZD_CS_NEED_RANDOM_BACKOFF 0x01
-#define ZD_CS_MULTICAST 0x02
+#define ZD_CS_NO_ACK 0x02
#define ZD_CS_FRAME_TYPE_MASK 0x0c
#define ZD_CS_DATA_FRAME 0x00
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f67325387902..8d88daeed0c6 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1212,7 +1212,7 @@ static int __devinit netfront_probe(struct xenbus_device *dev,
}
info = netdev_priv(netdev);
- dev->dev.driver_data = info;
+ dev_set_drvdata(&dev->dev, info);
err = register_netdev(info->netdev);
if (err) {
@@ -1233,7 +1233,7 @@ static int __devinit netfront_probe(struct xenbus_device *dev,
fail:
free_netdev(netdev);
- dev->dev.driver_data = NULL;
+ dev_set_drvdata(&dev->dev, NULL);
return err;
}
@@ -1275,7 +1275,7 @@ static void xennet_disconnect_backend(struct netfront_info *info)
*/
static int netfront_resume(struct xenbus_device *dev)
{
- struct netfront_info *info = dev->dev.driver_data;
+ struct netfront_info *info = dev_get_drvdata(&dev->dev);
dev_dbg(&dev->dev, "%s\n", dev->nodename);
@@ -1600,7 +1600,7 @@ static int xennet_connect(struct net_device *dev)
static void backend_changed(struct xenbus_device *dev,
enum xenbus_state backend_state)
{
- struct netfront_info *np = dev->dev.driver_data;
+ struct netfront_info *np = dev_get_drvdata(&dev->dev);
struct net_device *netdev = np->netdev;
dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state));
@@ -1774,7 +1774,7 @@ static struct xenbus_device_id netfront_ids[] = {
static int __devexit xennet_remove(struct xenbus_device *dev)
{
- struct netfront_info *info = dev->dev.driver_data;
+ struct netfront_info *info = dev_get_drvdata(&dev->dev);
dev_dbg(&dev->dev, "%s\n", dev->nodename);
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 27f3b81333de..d2fa27c5c1b2 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -19,3 +19,9 @@ config OF_SPI
depends on OF && (PPC_OF || MICROBLAZE) && SPI
help
OpenFirmware SPI accessors
+
+config OF_MDIO
+ def_tristate PHYLIB
+ depends on OF && PHYLIB
+ help
+ OpenFirmware MDIO bus (Ethernet PHY) accessors
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index 4c3c6f8e36f5..bdfb5f5d4b06 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_OF_DEVICE) += device.o platform.o
obj-$(CONFIG_OF_GPIO) += gpio.o
obj-$(CONFIG_OF_I2C) += of_i2c.o
obj-$(CONFIG_OF_SPI) += of_spi.o
+obj-$(CONFIG_OF_MDIO) += of_mdio.o
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 41c5dfd85358..69f85c07d17f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -447,6 +447,7 @@ struct of_modalias_table {
static struct of_modalias_table of_modalias_table[] = {
{ "fsl,mcu-mpc8349emitx", "mcu-mpc8349emitx" },
{ "mmc-spi-slot", "mmc_spi" },
+ { "stm,m25p40", "m25p80" },
};
/**
@@ -495,6 +496,30 @@ int of_modalias_node(struct device_node *node, char *modalias, int len)
EXPORT_SYMBOL_GPL(of_modalias_node);
/**
+ * of_parse_phandle - Resolve a phandle property to a device_node pointer
+ * @np: Pointer to device node holding phandle property
+ * @phandle_name: Name of property holding a phandle value
+ * @index: For properties holding a table of phandles, this is the index into
+ * the table
+ *
+ * Returns the device_node pointer with refcount incremented. Use
+ * of_node_put() on it when done.
+ */
+struct device_node *
+of_parse_phandle(struct device_node *np, const char *phandle_name, int index)
+{
+ const phandle *phandle;
+ int size;
+
+ phandle = of_get_property(np, phandle_name, &size);
+ if ((!phandle) || (size < sizeof(*phandle) * (index + 1)))
+ return NULL;
+
+ return of_find_node_by_phandle(phandle[index]);
+}
+EXPORT_SYMBOL(of_parse_phandle);
+
+/**
* of_parse_phandles_with_args - Find a node pointed by phandle in a list
* @np: pointer to a device tree node containing a list
* @list_name: property name that contains a list
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
new file mode 100644
index 000000000000..aee967d7f760
--- /dev/null
+++ b/drivers/of/of_mdio.c
@@ -0,0 +1,139 @@
+/*
+ * OF helpers for the MDIO (Ethernet PHY) API
+ *
+ * Copyright (c) 2009 Secret Lab Technologies, Ltd.
+ *
+ * This file is released under the GPLv2
+ *
+ * This file provides helper functions for extracting PHY device information
+ * out of the OpenFirmware device tree and using it to populate an mii_bus.
+ */
+
+#include <linux/phy.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/module.h>
+
+MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
+MODULE_LICENSE("GPL");
+
+/**
+ * of_mdiobus_register - Register mii_bus and create PHYs from the device tree
+ * @mdio: pointer to mii_bus structure
+ * @np: pointer to device_node of MDIO bus.
+ *
+ * This function registers the mii_bus structure and registers a phy_device
+ * for each child node of @np.
+ */
+int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
+{
+ struct phy_device *phy;
+ struct device_node *child;
+ int rc, i;
+
+ /* Mask out all PHYs from auto probing. Instead the PHYs listed in
+ * the device tree are populated after the bus has been registered */
+ mdio->phy_mask = ~0;
+
+ /* Clear all the IRQ properties */
+ if (mdio->irq)
+ for (i=0; i<PHY_MAX_ADDR; i++)
+ mdio->irq[i] = PHY_POLL;
+
+ /* Register the MDIO bus */
+ rc = mdiobus_register(mdio);
+ if (rc)
+ return rc;
+
+ /* Loop over the child nodes and register a phy_device for each one */
+ for_each_child_of_node(np, child) {
+ const u32 *addr;
+ int len;
+
+ /* A PHY must have a reg property in the range [0-31] */
+ addr = of_get_property(child, "reg", &len);
+ if (!addr || len < sizeof(*addr) || *addr >= 32 || *addr < 0) {
+ dev_err(&mdio->dev, "%s has invalid PHY address\n",
+ child->full_name);
+ continue;
+ }
+
+ if (mdio->irq) {
+ mdio->irq[*addr] = irq_of_parse_and_map(child, 0);
+ if (!mdio->irq[*addr])
+ mdio->irq[*addr] = PHY_POLL;
+ }
+
+ phy = get_phy_device(mdio, *addr);
+ if (!phy) {
+ dev_err(&mdio->dev, "error probing PHY at address %i\n",
+ *addr);
+ continue;
+ }
+ phy_scan_fixups(phy);
+
+ /* Associate the OF node with the device structure so it
+ * can be looked up later */
+ of_node_get(child);
+ dev_archdata_set_node(&phy->dev.archdata, child);
+
+ /* All data is now stored in the phy struct; register it */
+ rc = phy_device_register(phy);
+ if (rc) {
+ phy_device_free(phy);
+ of_node_put(child);
+ continue;
+ }
+
+ dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
+ child->name, *addr);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(of_mdiobus_register);
+
+/**
+ * of_phy_find_device - Give a PHY node, find the phy_device
+ * @phy_np: Pointer to the phy's device tree node
+ *
+ * Returns a pointer to the phy_device.
+ */
+struct phy_device *of_phy_find_device(struct device_node *phy_np)
+{
+ struct device *d;
+ int match(struct device *dev, void *phy_np)
+ {
+ return dev_archdata_get_node(&dev->archdata) == phy_np;
+ }
+
+ if (!phy_np)
+ return NULL;
+
+ d = bus_find_device(&mdio_bus_type, NULL, phy_np, match);
+ return d ? to_phy_device(d) : NULL;
+}
+EXPORT_SYMBOL(of_phy_find_device);
+
+/**
+ * of_phy_connect - Connect to the phy described in the device tree
+ * @dev: pointer to net_device claiming the phy
+ * @phy_np: Pointer to device tree node for the PHY
+ * @hndlr: Link state callback for the network device
+ * @iface: PHY data interface type
+ *
+ * Returns a pointer to the phy_device if successfull. NULL otherwise
+ */
+struct phy_device *of_phy_connect(struct net_device *dev,
+ struct device_node *phy_np,
+ void (*hndlr)(struct net_device *), u32 flags,
+ phy_interface_t iface)
+{
+ struct phy_device *phy = of_phy_find_device(phy_np);
+
+ if (!phy)
+ return NULL;
+
+ return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy;
+}
+EXPORT_SYMBOL(of_phy_connect);
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index f0e99d4c066b..242257b19441 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -78,16 +78,20 @@ void free_cpu_buffers(void)
op_ring_buffer_write = NULL;
}
+#define RB_EVENT_HDR_SIZE 4
+
int alloc_cpu_buffers(void)
{
int i;
unsigned long buffer_size = oprofile_cpu_buffer_size;
+ unsigned long byte_size = buffer_size * (sizeof(struct op_sample) +
+ RB_EVENT_HDR_SIZE);
- op_ring_buffer_read = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS);
+ op_ring_buffer_read = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
if (!op_ring_buffer_read)
goto fail;
- op_ring_buffer_write = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS);
+ op_ring_buffer_write = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
if (!op_ring_buffer_write)
goto fail;
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index f415fdd9a885..5b89f404e668 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -373,7 +373,7 @@ static int __init eisa_probe(struct parisc_device *dev)
if (result >= 0) {
/* FIXME : Don't enumerate the bus twice. */
eisa_dev.root.dev = &dev->dev;
- dev->dev.driver_data = &eisa_dev.root;
+ dev_set_drvdata(&dev->dev, &eisa_dev.root);
eisa_dev.root.bus_base_addr = 0;
eisa_dev.root.res = &eisa_dev.hba.io_space;
eisa_dev.root.slots = result;
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 73348c4047e9..4a9cc92d4d18 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -702,7 +702,7 @@ static unsigned int iosapic_startup_irq(unsigned int irq)
}
#ifdef CONFIG_SMP
-static void iosapic_set_affinity_irq(unsigned int irq,
+static int iosapic_set_affinity_irq(unsigned int irq,
const struct cpumask *dest)
{
struct vector_info *vi = iosapic_get_vector(irq);
@@ -712,7 +712,7 @@ static void iosapic_set_affinity_irq(unsigned int irq,
dest_cpu = cpu_check_affinity(irq, dest);
if (dest_cpu < 0)
- return;
+ return -1;
cpumask_copy(irq_desc[irq].affinity, cpumask_of(dest_cpu));
vi->txn_addr = txn_affinity_addr(irq, dest_cpu);
@@ -724,6 +724,8 @@ static void iosapic_set_affinity_irq(unsigned int irq,
iosapic_set_irt_data(vi, &dummy_d0, &d1);
iosapic_wr_irt_entry(vi, d0, d1);
spin_unlock_irqrestore(&iosapic_lock, flags);
+
+ return 0;
}
#endif
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index e5999c4cedc8..d46dd57450ac 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -2010,7 +2010,7 @@ void __init sba_init(void)
void * sba_get_iommu(struct parisc_device *pci_hba)
{
struct parisc_device *sba_dev = parisc_parent(pci_hba);
- struct sba_device *sba = sba_dev->dev.driver_data;
+ struct sba_device *sba = dev_get_drvdata(&sba_dev->dev);
char t = sba_dev->id.hw_type;
int iocnum = (pci_hba->hw_path >> 3); /* rope # */
@@ -2031,7 +2031,7 @@ void * sba_get_iommu(struct parisc_device *pci_hba)
void sba_directed_lmmio(struct parisc_device *pci_hba, struct resource *r)
{
struct parisc_device *sba_dev = parisc_parent(pci_hba);
- struct sba_device *sba = sba_dev->dev.driver_data;
+ struct sba_device *sba = dev_get_drvdata(&sba_dev->dev);
char t = sba_dev->id.hw_type;
int i;
int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */
@@ -2073,7 +2073,7 @@ void sba_directed_lmmio(struct parisc_device *pci_hba, struct resource *r)
void sba_distributed_lmmio(struct parisc_device *pci_hba, struct resource *r )
{
struct parisc_device *sba_dev = parisc_parent(pci_hba);
- struct sba_device *sba = sba_dev->dev.driver_data;
+ struct sba_device *sba = dev_get_drvdata(&sba_dev->dev);
char t = sba_dev->id.hw_type;
int base, size;
int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
index e6a7e847ee80..6531db228391 100644
--- a/drivers/parport/parport_gsc.c
+++ b/drivers/parport/parport_gsc.c
@@ -376,14 +376,14 @@ static int __devinit parport_init_chip(struct parisc_device *dev)
/* PARPORT_IRQ_NONE */ PARPORT_DMA_NONE, NULL);
if (p)
parport_count++;
- dev->dev.driver_data = p;
+ dev_set_drvdata(&dev->dev, p);
return 0;
}
static int __devexit parport_remove_chip(struct parisc_device *dev)
{
- struct parport *p = dev->dev.driver_data;
+ struct parport *p = dev_get_drvdata(&dev->dev);
if (p) {
struct parport_gsc_private *priv = p->private_data;
struct parport_operations *ops = p->ops;
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index ba6af162fd39..b77ae6794275 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -39,7 +39,6 @@ obj-$(CONFIG_ALPHA) += setup-bus.o setup-irq.o
obj-$(CONFIG_ARM) += setup-bus.o setup-irq.o
obj-$(CONFIG_PARISC) += setup-bus.o
obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o
-obj-$(CONFIG_PPC32) += setup-irq.o
obj-$(CONFIG_PPC) += setup-bus.o
obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o
obj-$(CONFIG_X86_VISWS) += setup-irq.o
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 97a8194063b5..40af27f31043 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -41,9 +41,14 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
void *alignf_data)
{
int i, ret = -ENOMEM;
+ resource_size_t max = -1;
type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
+ /* don't allocate too high if the pref mem doesn't support 64bit*/
+ if (!(res->flags & IORESOURCE_MEM_64))
+ max = PCIBIOS_MAX_MEM_32;
+
for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
struct resource *r = bus->resource[i];
if (!r)
@@ -62,7 +67,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
/* Ok, try it out.. */
ret = allocate_resource(r, res, size,
r->start ? : min,
- -1, align,
+ max, align,
alignf, alignf_data);
if (ret == 0)
break;
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index fa3a11365ec3..f23460a5d106 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -515,6 +515,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
u32 ver;
static int iommu_allocated = 0;
int agaw = 0;
+ int msagaw = 0;
iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
if (!iommu)
@@ -535,12 +536,20 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
agaw = iommu_calculate_agaw(iommu);
if (agaw < 0) {
printk(KERN_ERR
- "Cannot get a valid agaw for iommu (seq_id = %d)\n",
+ "Cannot get a valid agaw for iommu (seq_id = %d)\n",
+ iommu->seq_id);
+ goto error;
+ }
+ msagaw = iommu_calculate_max_sagaw(iommu);
+ if (msagaw < 0) {
+ printk(KERN_ERR
+ "Cannot get a valid max agaw for iommu (seq_id = %d)\n",
iommu->seq_id);
goto error;
}
#endif
iommu->agaw = agaw;
+ iommu->msagaw = msagaw;
/* the registers might be more than one page */
map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),
@@ -714,41 +723,26 @@ void qi_global_iec(struct intel_iommu *iommu)
qi_submit_sync(&desc, iommu);
}
-int qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm,
- u64 type, int non_present_entry_flush)
+void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm,
+ u64 type)
{
struct qi_desc desc;
- if (non_present_entry_flush) {
- if (!cap_caching_mode(iommu->cap))
- return 1;
- else
- did = 0;
- }
-
desc.low = QI_CC_FM(fm) | QI_CC_SID(sid) | QI_CC_DID(did)
| QI_CC_GRAN(type) | QI_CC_TYPE;
desc.high = 0;
- return qi_submit_sync(&desc, iommu);
+ qi_submit_sync(&desc, iommu);
}
-int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
- unsigned int size_order, u64 type,
- int non_present_entry_flush)
+void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
+ unsigned int size_order, u64 type)
{
u8 dw = 0, dr = 0;
struct qi_desc desc;
int ih = 0;
- if (non_present_entry_flush) {
- if (!cap_caching_mode(iommu->cap))
- return 1;
- else
- did = 0;
- }
-
if (cap_write_drain(iommu->cap))
dw = 1;
@@ -760,7 +754,7 @@ int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
desc.high = QI_IOTLB_ADDR(addr) | QI_IOTLB_IH(ih)
| QI_IOTLB_AM(size_order);
- return qi_submit_sync(&desc, iommu);
+ qi_submit_sync(&desc, iommu);
}
/*
@@ -790,7 +784,6 @@ void dmar_disable_qi(struct intel_iommu *iommu)
cpu_relax();
iommu->gcmd &= ~DMA_GCMD_QIE;
-
writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl,
@@ -804,7 +797,7 @@ end:
*/
static void __dmar_enable_qi(struct intel_iommu *iommu)
{
- u32 cmd, sts;
+ u32 sts;
unsigned long flags;
struct q_inval *qi = iommu->qi;
@@ -818,9 +811,8 @@ static void __dmar_enable_qi(struct intel_iommu *iommu)
dmar_writeq(iommu->reg + DMAR_IQA_REG, virt_to_phys(qi->desc));
- cmd = iommu->gcmd | DMA_GCMD_QIE;
iommu->gcmd |= DMA_GCMD_QIE;
- writel(cmd, iommu->reg + DMAR_GCMD_REG);
+ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
/* Make sure hardware complete it */
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_QIES), sts);
@@ -1096,7 +1088,7 @@ int dmar_set_interrupt(struct intel_iommu *iommu)
set_irq_data(irq, NULL);
iommu->irq = 0;
destroy_irq(irq);
- return 0;
+ return ret;
}
ret = request_irq(irq, dmar_fault, 0, iommu->name, iommu);
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index 9aa4fe100a0d..ac888ccfa161 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -41,7 +41,7 @@ config HOTPLUG_PCI_FAKE
config HOTPLUG_PCI_COMPAQ
tristate "Compaq PCI Hotplug driver"
- depends on X86 && PCI_BIOS && PCI_LEGACY
+ depends on X86 && PCI_BIOS
help
Say Y here if you have a motherboard with a Compaq PCI Hotplug
controller.
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index afaf8f69f73e..53836001d511 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -150,25 +150,25 @@ struct ctrl_reg { /* offset */
/* offsets to the controller registers based on the above structure layout */
enum ctrl_offsets {
- SLOT_RST = offsetof(struct ctrl_reg, slot_RST),
+ SLOT_RST = offsetof(struct ctrl_reg, slot_RST),
SLOT_ENABLE = offsetof(struct ctrl_reg, slot_enable),
MISC = offsetof(struct ctrl_reg, misc),
LED_CONTROL = offsetof(struct ctrl_reg, led_control),
INT_INPUT_CLEAR = offsetof(struct ctrl_reg, int_input_clear),
- INT_MASK = offsetof(struct ctrl_reg, int_mask),
- CTRL_RESERVED0 = offsetof(struct ctrl_reg, reserved0),
+ INT_MASK = offsetof(struct ctrl_reg, int_mask),
+ CTRL_RESERVED0 = offsetof(struct ctrl_reg, reserved0),
CTRL_RESERVED1 = offsetof(struct ctrl_reg, reserved1),
CTRL_RESERVED2 = offsetof(struct ctrl_reg, reserved1),
- GEN_OUTPUT_AB = offsetof(struct ctrl_reg, gen_output_AB),
- NON_INT_INPUT = offsetof(struct ctrl_reg, non_int_input),
+ GEN_OUTPUT_AB = offsetof(struct ctrl_reg, gen_output_AB),
+ NON_INT_INPUT = offsetof(struct ctrl_reg, non_int_input),
CTRL_RESERVED3 = offsetof(struct ctrl_reg, reserved3),
CTRL_RESERVED4 = offsetof(struct ctrl_reg, reserved4),
CTRL_RESERVED5 = offsetof(struct ctrl_reg, reserved5),
CTRL_RESERVED6 = offsetof(struct ctrl_reg, reserved6),
CTRL_RESERVED7 = offsetof(struct ctrl_reg, reserved7),
CTRL_RESERVED8 = offsetof(struct ctrl_reg, reserved8),
- SLOT_MASK = offsetof(struct ctrl_reg, slot_mask),
- CTRL_RESERVED9 = offsetof(struct ctrl_reg, reserved9),
+ SLOT_MASK = offsetof(struct ctrl_reg, slot_mask),
+ CTRL_RESERVED9 = offsetof(struct ctrl_reg, reserved9),
CTRL_RESERVED10 = offsetof(struct ctrl_reg, reserved10),
CTRL_RESERVED11 = offsetof(struct ctrl_reg, reserved11),
SLOT_SERR = offsetof(struct ctrl_reg, slot_SERR),
@@ -190,7 +190,9 @@ struct hrt {
u32 reserved2;
} __attribute__ ((packed));
-/* offsets to the hotplug resource table registers based on the above structure layout */
+/* offsets to the hotplug resource table registers based on the above
+ * structure layout
+ */
enum hrt_offsets {
SIG0 = offsetof(struct hrt, sig0),
SIG1 = offsetof(struct hrt, sig1),
@@ -217,18 +219,20 @@ struct slot_rt {
u16 pre_mem_length;
} __attribute__ ((packed));
-/* offsets to the hotplug slot resource table registers based on the above structure layout */
+/* offsets to the hotplug slot resource table registers based on the above
+ * structure layout
+ */
enum slot_rt_offsets {
DEV_FUNC = offsetof(struct slot_rt, dev_func),
- PRIMARY_BUS = offsetof(struct slot_rt, primary_bus),
- SECONDARY_BUS = offsetof(struct slot_rt, secondary_bus),
- MAX_BUS = offsetof(struct slot_rt, max_bus),
- IO_BASE = offsetof(struct slot_rt, io_base),
- IO_LENGTH = offsetof(struct slot_rt, io_length),
- MEM_BASE = offsetof(struct slot_rt, mem_base),
- MEM_LENGTH = offsetof(struct slot_rt, mem_length),
- PRE_MEM_BASE = offsetof(struct slot_rt, pre_mem_base),
- PRE_MEM_LENGTH = offsetof(struct slot_rt, pre_mem_length),
+ PRIMARY_BUS = offsetof(struct slot_rt, primary_bus),
+ SECONDARY_BUS = offsetof(struct slot_rt, secondary_bus),
+ MAX_BUS = offsetof(struct slot_rt, max_bus),
+ IO_BASE = offsetof(struct slot_rt, io_base),
+ IO_LENGTH = offsetof(struct slot_rt, io_length),
+ MEM_BASE = offsetof(struct slot_rt, mem_base),
+ MEM_LENGTH = offsetof(struct slot_rt, mem_length),
+ PRE_MEM_BASE = offsetof(struct slot_rt, pre_mem_base),
+ PRE_MEM_LENGTH = offsetof(struct slot_rt, pre_mem_length),
};
struct pci_func {
@@ -286,8 +290,8 @@ struct event_info {
struct controller {
struct controller *next;
u32 ctrl_int_comp;
- struct mutex crit_sect; /* critical section mutex */
- void __iomem *hpc_reg; /* cookie for our pci controller location */
+ struct mutex crit_sect; /* critical section mutex */
+ void __iomem *hpc_reg; /* cookie for our pci controller location */
struct pci_resource *mem_head;
struct pci_resource *p_mem_head;
struct pci_resource *io_head;
@@ -299,7 +303,7 @@ struct controller {
u8 next_event;
u8 interrupt;
u8 cfgspc_irq;
- u8 bus; /* bus number for the pci hotplug controller */
+ u8 bus; /* bus number for the pci hotplug controller */
u8 rev;
u8 slot_device_offset;
u8 first_slot;
@@ -401,46 +405,57 @@ struct resource_lists {
/* debugfs functions for the hotplug controller info */
-extern void cpqhp_initialize_debugfs (void);
-extern void cpqhp_shutdown_debugfs (void);
-extern void cpqhp_create_debugfs_files (struct controller *ctrl);
-extern void cpqhp_remove_debugfs_files (struct controller *ctrl);
+extern void cpqhp_initialize_debugfs(void);
+extern void cpqhp_shutdown_debugfs(void);
+extern void cpqhp_create_debugfs_files(struct controller *ctrl);
+extern void cpqhp_remove_debugfs_files(struct controller *ctrl);
/* controller functions */
-extern void cpqhp_pushbutton_thread (unsigned long event_pointer);
-extern irqreturn_t cpqhp_ctrl_intr (int IRQ, void *data);
-extern int cpqhp_find_available_resources (struct controller *ctrl, void __iomem *rom_start);
-extern int cpqhp_event_start_thread (void);
-extern void cpqhp_event_stop_thread (void);
-extern struct pci_func *cpqhp_slot_create (unsigned char busnumber);
-extern struct pci_func *cpqhp_slot_find (unsigned char bus, unsigned char device, unsigned char index);
-extern int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func);
-extern int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func);
-extern int cpqhp_hardware_test (struct controller *ctrl, int test_num);
+extern void cpqhp_pushbutton_thread(unsigned long event_pointer);
+extern irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data);
+extern int cpqhp_find_available_resources(struct controller *ctrl,
+ void __iomem *rom_start);
+extern int cpqhp_event_start_thread(void);
+extern void cpqhp_event_stop_thread(void);
+extern struct pci_func *cpqhp_slot_create(unsigned char busnumber);
+extern struct pci_func *cpqhp_slot_find(unsigned char bus, unsigned char device,
+ unsigned char index);
+extern int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func);
+extern int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func);
+extern int cpqhp_hardware_test(struct controller *ctrl, int test_num);
/* resource functions */
extern int cpqhp_resource_sort_and_combine (struct pci_resource **head);
/* pci functions */
-extern int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
-extern int cpqhp_get_bus_dev (struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot);
-extern int cpqhp_save_config (struct controller *ctrl, int busnumber, int is_hot_plug);
-extern int cpqhp_save_base_addr_length (struct controller *ctrl, struct pci_func * func);
-extern int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func);
-extern int cpqhp_configure_board (struct controller *ctrl, struct pci_func * func);
-extern int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot);
-extern int cpqhp_valid_replace (struct controller *ctrl, struct pci_func * func);
-extern void cpqhp_destroy_board_resources (struct pci_func * func);
-extern int cpqhp_return_board_resources (struct pci_func * func, struct resource_lists * resources);
-extern void cpqhp_destroy_resource_list (struct resource_lists * resources);
-extern int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func);
-extern int cpqhp_unconfigure_device (struct pci_func* func);
+extern int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
+extern int cpqhp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num,
+ u8 slot);
+extern int cpqhp_save_config(struct controller *ctrl, int busnumber,
+ int is_hot_plug);
+extern int cpqhp_save_base_addr_length(struct controller *ctrl,
+ struct pci_func *func);
+extern int cpqhp_save_used_resources(struct controller *ctrl,
+ struct pci_func *func);
+extern int cpqhp_configure_board(struct controller *ctrl,
+ struct pci_func *func);
+extern int cpqhp_save_slot_config(struct controller *ctrl,
+ struct pci_func *new_slot);
+extern int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func);
+extern void cpqhp_destroy_board_resources(struct pci_func *func);
+extern int cpqhp_return_board_resources (struct pci_func *func,
+ struct resource_lists *resources);
+extern void cpqhp_destroy_resource_list(struct resource_lists *resources);
+extern int cpqhp_configure_device(struct controller *ctrl,
+ struct pci_func *func);
+extern int cpqhp_unconfigure_device(struct pci_func *func);
/* Global variables */
extern int cpqhp_debug;
extern int cpqhp_legacy_mode;
extern struct controller *cpqhp_ctrl_list;
extern struct pci_func *cpqhp_slot_list[256];
+extern struct irq_routing_table *cpqhp_routing_table;
/* these can be gotten rid of, but for debugging they are purty */
extern u8 cpqhp_nic_irq;
@@ -449,7 +464,7 @@ extern u8 cpqhp_disk_irq;
/* inline functions */
-static inline char *slot_name(struct slot *slot)
+static inline const char *slot_name(struct slot *slot)
{
return hotplug_slot_name(slot->hotplug_slot);
}
@@ -458,9 +473,9 @@ static inline char *slot_name(struct slot *slot)
* return_resource
*
* Puts node back in the resource list pointed to by head
- *
*/
-static inline void return_resource(struct pci_resource **head, struct pci_resource *node)
+static inline void return_resource(struct pci_resource **head,
+ struct pci_resource *node)
{
if (!node || !head)
return;
@@ -471,7 +486,7 @@ static inline void return_resource(struct pci_resource **head, struct pci_resour
static inline void set_SOGO(struct controller *ctrl)
{
u16 misc;
-
+
misc = readw(ctrl->hpc_reg + MISC);
misc = (misc | 0x0001) & 0xFFFB;
writew(misc, ctrl->hpc_reg + MISC);
@@ -481,7 +496,7 @@ static inline void set_SOGO(struct controller *ctrl)
static inline void amber_LED_on(struct controller *ctrl, u8 slot)
{
u32 led_control;
-
+
led_control = readl(ctrl->hpc_reg + LED_CONTROL);
led_control |= (0x01010000L << slot);
writel(led_control, ctrl->hpc_reg + LED_CONTROL);
@@ -491,7 +506,7 @@ static inline void amber_LED_on(struct controller *ctrl, u8 slot)
static inline void amber_LED_off(struct controller *ctrl, u8 slot)
{
u32 led_control;
-
+
led_control = readl(ctrl->hpc_reg + LED_CONTROL);
led_control &= ~(0x01010000L << slot);
writel(led_control, ctrl->hpc_reg + LED_CONTROL);
@@ -504,7 +519,7 @@ static inline int read_amber_LED(struct controller *ctrl, u8 slot)
led_control = readl(ctrl->hpc_reg + LED_CONTROL);
led_control &= (0x01010000L << slot);
-
+
return led_control ? 1 : 0;
}
@@ -512,7 +527,7 @@ static inline int read_amber_LED(struct controller *ctrl, u8 slot)
static inline void green_LED_on(struct controller *ctrl, u8 slot)
{
u32 led_control;
-
+
led_control = readl(ctrl->hpc_reg + LED_CONTROL);
led_control |= 0x0101L << slot;
writel(led_control, ctrl->hpc_reg + LED_CONTROL);
@@ -521,7 +536,7 @@ static inline void green_LED_on(struct controller *ctrl, u8 slot)
static inline void green_LED_off(struct controller *ctrl, u8 slot)
{
u32 led_control;
-
+
led_control = readl(ctrl->hpc_reg + LED_CONTROL);
led_control &= ~(0x0101L << slot);
writel(led_control, ctrl->hpc_reg + LED_CONTROL);
@@ -531,7 +546,7 @@ static inline void green_LED_off(struct controller *ctrl, u8 slot)
static inline void green_LED_blink(struct controller *ctrl, u8 slot)
{
u32 led_control;
-
+
led_control = readl(ctrl->hpc_reg + LED_CONTROL);
led_control &= ~(0x0101L << slot);
led_control |= (0x0001L << slot);
@@ -575,22 +590,21 @@ static inline u8 read_slot_enable(struct controller *ctrl)
}
-/*
+/**
* get_controller_speed - find the current frequency/mode of controller.
*
* @ctrl: controller to get frequency/mode for.
*
* Returns controller speed.
- *
*/
static inline u8 get_controller_speed(struct controller *ctrl)
{
u8 curr_freq;
- u16 misc;
-
+ u16 misc;
+
if (ctrl->pcix_support) {
curr_freq = readb(ctrl->hpc_reg + NEXT_CURR_FREQ);
- if ((curr_freq & 0xB0) == 0xB0)
+ if ((curr_freq & 0xB0) == 0xB0)
return PCI_SPEED_133MHz_PCIX;
if ((curr_freq & 0xA0) == 0xA0)
return PCI_SPEED_100MHz_PCIX;
@@ -602,19 +616,18 @@ static inline u8 get_controller_speed(struct controller *ctrl)
return PCI_SPEED_33MHz;
}
- misc = readw(ctrl->hpc_reg + MISC);
- return (misc & 0x0800) ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
+ misc = readw(ctrl->hpc_reg + MISC);
+ return (misc & 0x0800) ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
}
-
-/*
+
+/**
* get_adapter_speed - find the max supported frequency/mode of adapter.
*
* @ctrl: hotplug controller.
* @hp_slot: hotplug slot where adapter is installed.
*
* Returns adapter speed.
- *
*/
static inline u8 get_adapter_speed(struct controller *ctrl, u8 hp_slot)
{
@@ -672,7 +685,8 @@ static inline int get_slot_enabled(struct controller *ctrl, struct slot *slot)
}
-static inline int cpq_get_latch_status(struct controller *ctrl, struct slot *slot)
+static inline int cpq_get_latch_status(struct controller *ctrl,
+ struct slot *slot)
{
u32 status;
u8 hp_slot;
@@ -687,7 +701,8 @@ static inline int cpq_get_latch_status(struct controller *ctrl, struct slot *slo
}
-static inline int get_presence_status(struct controller *ctrl, struct slot *slot)
+static inline int get_presence_status(struct controller *ctrl,
+ struct slot *slot)
{
int presence_save = 0;
u8 hp_slot;
@@ -696,7 +711,8 @@ static inline int get_presence_status(struct controller *ctrl, struct slot *slot
hp_slot = slot->device - ctrl->slot_device_offset;
tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
- presence_save = (int) ((((~tempdword) >> 23) | ((~tempdword) >> 15)) >> hp_slot) & 0x02;
+ presence_save = (int) ((((~tempdword) >> 23) | ((~tempdword) >> 15))
+ >> hp_slot) & 0x02;
return presence_save;
}
@@ -718,5 +734,12 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl)
return retval;
}
-#endif
+#include <asm/pci_x86.h>
+static inline int cpqhp_routing_table_length(void)
+{
+ BUG_ON(cpqhp_routing_table == NULL);
+ return ((cpqhp_routing_table->size - sizeof(struct irq_routing_table)) /
+ sizeof(struct irq_info));
+}
+#endif
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index c2e1bcbb28a7..7888b37c6c8e 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -25,8 +25,7 @@
* Send feedback to <greg@kroah.com>
*
* Jan 12, 2003 - Added 66/100/133MHz PCI-X support,
- * Torben Mathiasen <torben.mathiasen@hp.com>
- *
+ * Torben Mathiasen <torben.mathiasen@hp.com>
*/
#include <linux/module.h>
@@ -45,7 +44,6 @@
#include "cpqphp.h"
#include "cpqphp_nvram.h"
-#include <asm/pci_x86.h>
/* Global variables */
@@ -53,6 +51,7 @@ int cpqhp_debug;
int cpqhp_legacy_mode;
struct controller *cpqhp_ctrl_list; /* = NULL */
struct pci_func *cpqhp_slot_list[256];
+struct irq_routing_table *cpqhp_routing_table;
/* local variables */
static void __iomem *smbios_table;
@@ -78,33 +77,6 @@ MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
#define CPQHPC_MODULE_MINOR 208
-static int one_time_init (void);
-static int set_attention_status (struct hotplug_slot *slot, u8 value);
-static int process_SI (struct hotplug_slot *slot);
-static int process_SS (struct hotplug_slot *slot);
-static int hardware_test (struct hotplug_slot *slot, u32 value);
-static int get_power_status (struct hotplug_slot *slot, u8 *value);
-static int get_attention_status (struct hotplug_slot *slot, u8 *value);
-static int get_latch_status (struct hotplug_slot *slot, u8 *value);
-static int get_adapter_status (struct hotplug_slot *slot, u8 *value);
-static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value);
-static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value);
-
-static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = {
- .owner = THIS_MODULE,
- .set_attention_status = set_attention_status,
- .enable_slot = process_SI,
- .disable_slot = process_SS,
- .hardware_test = hardware_test,
- .get_power_status = get_power_status,
- .get_attention_status = get_attention_status,
- .get_latch_status = get_latch_status,
- .get_adapter_status = get_adapter_status,
- .get_max_bus_speed = get_max_bus_speed,
- .get_cur_bus_speed = get_cur_bus_speed,
-};
-
-
static inline int is_slot64bit(struct slot *slot)
{
return (readb(slot->p_sm_slot + SMBIOS_SLOT_WIDTH) == 0x06) ? 1 : 0;
@@ -144,7 +116,7 @@ static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *e
break;
}
}
-
+
if (!status)
fp = NULL;
@@ -171,7 +143,7 @@ static int init_SERR(struct controller * ctrl)
tempdword = ctrl->first_slot;
number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
- // Loop through slots
+ /* Loop through slots */
while (number_of_slots) {
physical_slot = tempdword;
writeb(0, ctrl->hpc_reg + SLOT_SERR);
@@ -182,41 +154,42 @@ static int init_SERR(struct controller * ctrl)
return 0;
}
-
-/* nice debugging output */
-static int pci_print_IRQ_route (void)
+static int init_cpqhp_routing_table(void)
{
- struct irq_routing_table *routing_table;
int len;
- int loop;
- u8 tbus, tdevice, tslot;
-
- routing_table = pcibios_get_irq_routing_table();
- if (routing_table == NULL) {
- err("No BIOS Routing Table??? Not good\n");
+ cpqhp_routing_table = pcibios_get_irq_routing_table();
+ if (cpqhp_routing_table == NULL)
return -ENOMEM;
- }
- len = (routing_table->size - sizeof(struct irq_routing_table)) /
- sizeof(struct irq_info);
- // Make sure I got at least one entry
+ len = cpqhp_routing_table_length();
if (len == 0) {
- kfree(routing_table);
+ kfree(cpqhp_routing_table);
+ cpqhp_routing_table = NULL;
return -1;
}
- dbg("bus dev func slot\n");
+ return 0;
+}
+/* nice debugging output */
+static void pci_print_IRQ_route(void)
+{
+ int len;
+ int loop;
+ u8 tbus, tdevice, tslot;
+
+ len = cpqhp_routing_table_length();
+
+ dbg("bus dev func slot\n");
for (loop = 0; loop < len; ++loop) {
- tbus = routing_table->slots[loop].bus;
- tdevice = routing_table->slots[loop].devfn;
- tslot = routing_table->slots[loop].slot;
+ tbus = cpqhp_routing_table->slots[loop].bus;
+ tdevice = cpqhp_routing_table->slots[loop].devfn;
+ tslot = cpqhp_routing_table->slots[loop].slot;
dbg("%d %d %d %d\n", tbus, tdevice >> 3, tdevice & 0x7, tslot);
}
- kfree(routing_table);
- return 0;
+ return;
}
@@ -242,9 +215,9 @@ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,
void __iomem *p_max;
if (!smbios_table || !curr)
- return(NULL);
+ return NULL;
- // set p_max to the end of the table
+ /* set p_max to the end of the table */
p_max = smbios_start + readw(smbios_table + ST_LENGTH);
p_temp = curr;
@@ -253,20 +226,19 @@ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,
while ((p_temp < p_max) && !bail) {
/* Look for the double NULL terminator
* The first condition is the previous byte
- * and the second is the curr */
- if (!previous_byte && !(readb(p_temp))) {
+ * and the second is the curr
+ */
+ if (!previous_byte && !(readb(p_temp)))
bail = 1;
- }
previous_byte = readb(p_temp);
p_temp++;
}
- if (p_temp < p_max) {
+ if (p_temp < p_max)
return p_temp;
- } else {
+ else
return NULL;
- }
}
@@ -292,21 +264,18 @@ static void __iomem *get_SMBIOS_entry(void __iomem *smbios_start,
if (!smbios_table)
return NULL;
- if (!previous) {
+ if (!previous)
previous = smbios_start;
- } else {
+ else
previous = get_subsequent_smbios_entry(smbios_start,
smbios_table, previous);
- }
- while (previous) {
- if (readb(previous + SMBIOS_GENERIC_TYPE) != type) {
+ while (previous)
+ if (readb(previous + SMBIOS_GENERIC_TYPE) != type)
previous = get_subsequent_smbios_entry(smbios_start,
smbios_table, previous);
- } else {
+ else
break;
- }
- }
return previous;
}
@@ -322,144 +291,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
kfree(slot);
}
-#define SLOT_NAME_SIZE 10
-
-static int ctrl_slot_setup(struct controller *ctrl,
- void __iomem *smbios_start,
- void __iomem *smbios_table)
-{
- struct slot *slot;
- struct hotplug_slot *hotplug_slot;
- struct hotplug_slot_info *hotplug_slot_info;
- u8 number_of_slots;
- u8 slot_device;
- u8 slot_number;
- u8 ctrl_slot;
- u32 tempdword;
- char name[SLOT_NAME_SIZE];
- void __iomem *slot_entry= NULL;
- int result = -ENOMEM;
-
- dbg("%s\n", __func__);
-
- tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
-
- number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
- slot_device = readb(ctrl->hpc_reg + SLOT_MASK) >> 4;
- slot_number = ctrl->first_slot;
-
- while (number_of_slots) {
- slot = kzalloc(sizeof(*slot), GFP_KERNEL);
- if (!slot)
- goto error;
-
- slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
- GFP_KERNEL);
- if (!slot->hotplug_slot)
- goto error_slot;
- hotplug_slot = slot->hotplug_slot;
-
- hotplug_slot->info =
- kzalloc(sizeof(*(hotplug_slot->info)),
- GFP_KERNEL);
- if (!hotplug_slot->info)
- goto error_hpslot;
- hotplug_slot_info = hotplug_slot->info;
-
- slot->ctrl = ctrl;
- slot->bus = ctrl->bus;
- slot->device = slot_device;
- slot->number = slot_number;
- dbg("slot->number = %u\n", slot->number);
-
- slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9,
- slot_entry);
-
- while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) !=
- slot->number)) {
- slot_entry = get_SMBIOS_entry(smbios_start,
- smbios_table, 9, slot_entry);
- }
-
- slot->p_sm_slot = slot_entry;
-
- init_timer(&slot->task_event);
- slot->task_event.expires = jiffies + 5 * HZ;
- slot->task_event.function = cpqhp_pushbutton_thread;
-
- //FIXME: these capabilities aren't used but if they are
- // they need to be correctly implemented
- slot->capabilities |= PCISLOT_REPLACE_SUPPORTED;
- slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED;
-
- if (is_slot64bit(slot))
- slot->capabilities |= PCISLOT_64_BIT_SUPPORTED;
- if (is_slot66mhz(slot))
- slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED;
- if (ctrl->speed == PCI_SPEED_66MHz)
- slot->capabilities |= PCISLOT_66_MHZ_OPERATION;
-
- ctrl_slot =
- slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4);
-
- // Check presence
- slot->capabilities |=
- ((((~tempdword) >> 23) |
- ((~tempdword) >> 15)) >> ctrl_slot) & 0x02;
- // Check the switch state
- slot->capabilities |=
- ((~tempdword & 0xFF) >> ctrl_slot) & 0x01;
- // Check the slot enable
- slot->capabilities |=
- ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
-
- /* register this slot with the hotplug pci core */
- hotplug_slot->release = &release_slot;
- hotplug_slot->private = slot;
- snprintf(name, SLOT_NAME_SIZE, "%u", slot->number);
- hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
-
- hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot);
- hotplug_slot_info->attention_status =
- cpq_get_attention_status(ctrl, slot);
- hotplug_slot_info->latch_status =
- cpq_get_latch_status(ctrl, slot);
- hotplug_slot_info->adapter_status =
- get_presence_status(ctrl, slot);
-
- dbg("registering bus %d, dev %d, number %d, "
- "ctrl->slot_device_offset %d, slot %d\n",
- slot->bus, slot->device,
- slot->number, ctrl->slot_device_offset,
- slot_number);
- result = pci_hp_register(hotplug_slot,
- ctrl->pci_dev->bus,
- slot->device,
- name);
- if (result) {
- err("pci_hp_register failed with error %d\n", result);
- goto error_info;
- }
-
- slot->next = ctrl->slot;
- ctrl->slot = slot;
-
- number_of_slots--;
- slot_device++;
- slot_number++;
- }
-
- return 0;
-error_info:
- kfree(hotplug_slot_info);
-error_hpslot:
- kfree(hotplug_slot);
-error_slot:
- kfree(slot);
-error:
- return result;
-}
-
static int ctrl_slot_cleanup (struct controller * ctrl)
{
struct slot *old_slot, *next_slot;
@@ -476,36 +307,32 @@ static int ctrl_slot_cleanup (struct controller * ctrl)
cpqhp_remove_debugfs_files(ctrl);
- //Free IRQ associated with hot plug device
+ /* Free IRQ associated with hot plug device */
free_irq(ctrl->interrupt, ctrl);
- //Unmap the memory
+ /* Unmap the memory */
iounmap(ctrl->hpc_reg);
- //Finally reclaim PCI mem
+ /* Finally reclaim PCI mem */
release_mem_region(pci_resource_start(ctrl->pci_dev, 0),
pci_resource_len(ctrl->pci_dev, 0));
- return(0);
+ return 0;
}
-//============================================================================
-// function: get_slot_mapping
-//
-// Description: Attempts to determine a logical slot mapping for a PCI
-// device. Won't work for more than one PCI-PCI bridge
-// in a slot.
-//
-// Input: u8 bus_num - bus number of PCI device
-// u8 dev_num - device number of PCI device
-// u8 *slot - Pointer to u8 where slot number will
-// be returned
-//
-// Output: SUCCESS or FAILURE
-//=============================================================================
+/**
+ * get_slot_mapping - determine logical slot mapping for PCI device
+ *
+ * Won't work for more than one PCI-PCI bridge in a slot.
+ *
+ * @bus_num - bus number of PCI device
+ * @dev_num - device number of PCI device
+ * @slot - Pointer to u8 where slot number will be returned
+ *
+ * Output: SUCCESS or FAILURE
+ */
static int
get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)
{
- struct irq_routing_table *PCIIRQRoutingInfoLength;
u32 work;
long len;
long loop;
@@ -516,36 +343,25 @@ get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)
bridgeSlot = 0xFF;
- PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table();
- if (!PCIIRQRoutingInfoLength)
- return -1;
-
- len = (PCIIRQRoutingInfoLength->size -
- sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
- // Make sure I got at least one entry
- if (len == 0) {
- kfree(PCIIRQRoutingInfoLength);
- return -1;
- }
-
+ len = cpqhp_routing_table_length();
for (loop = 0; loop < len; ++loop) {
- tbus = PCIIRQRoutingInfoLength->slots[loop].bus;
- tdevice = PCIIRQRoutingInfoLength->slots[loop].devfn >> 3;
- tslot = PCIIRQRoutingInfoLength->slots[loop].slot;
+ tbus = cpqhp_routing_table->slots[loop].bus;
+ tdevice = cpqhp_routing_table->slots[loop].devfn >> 3;
+ tslot = cpqhp_routing_table->slots[loop].slot;
if ((tbus == bus_num) && (tdevice == dev_num)) {
*slot = tslot;
- kfree(PCIIRQRoutingInfoLength);
return 0;
} else {
/* Did not get a match on the target PCI device. Check
- * if the current IRQ table entry is a PCI-to-PCI bridge
- * device. If so, and it's secondary bus matches the
- * bus number for the target device, I need to save the
- * bridge's slot number. If I can not find an entry for
- * the target device, I will have to assume it's on the
- * other side of the bridge, and assign it the bridge's
- * slot. */
+ * if the current IRQ table entry is a PCI-to-PCI
+ * bridge device. If so, and it's secondary bus
+ * matches the bus number for the target device, I need
+ * to save the bridge's slot number. If I can not find
+ * an entry for the target device, I will have to
+ * assume it's on the other side of the bridge, and
+ * assign it the bridge's slot.
+ */
bus->number = tbus;
pci_bus_read_config_dword(bus, PCI_DEVFN(tdevice, 0),
PCI_CLASS_REVISION, &work);
@@ -555,25 +371,23 @@ get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)
PCI_DEVFN(tdevice, 0),
PCI_PRIMARY_BUS, &work);
// See if bridge's secondary bus matches target bus.
- if (((work >> 8) & 0x000000FF) == (long) bus_num) {
+ if (((work >> 8) & 0x000000FF) == (long) bus_num)
bridgeSlot = tslot;
- }
}
}
}
- // If we got here, we didn't find an entry in the IRQ mapping table
- // for the target PCI device. If we did determine that the target
- // device is on the other side of a PCI-to-PCI bridge, return the
- // slot number for the bridge.
+ /* If we got here, we didn't find an entry in the IRQ mapping table for
+ * the target PCI device. If we did determine that the target device
+ * is on the other side of a PCI-to-PCI bridge, return the slot number
+ * for the bridge.
+ */
if (bridgeSlot != 0xFF) {
*slot = bridgeSlot;
- kfree(PCIIRQRoutingInfoLength);
return 0;
}
- kfree(PCIIRQRoutingInfoLength);
- // Couldn't find an entry in the routing table for this PCI device
+ /* Couldn't find an entry in the routing table for this PCI device */
return -1;
}
@@ -591,32 +405,32 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
u8 hp_slot;
if (func == NULL)
- return(1);
+ return 1;
hp_slot = func->device - ctrl->slot_device_offset;
- // Wait for exclusive access to hardware
+ /* Wait for exclusive access to hardware */
mutex_lock(&ctrl->crit_sect);
- if (status == 1) {
+ if (status == 1)
amber_LED_on (ctrl, hp_slot);
- } else if (status == 0) {
+ else if (status == 0)
amber_LED_off (ctrl, hp_slot);
- } else {
- // Done with exclusive hardware access
+ else {
+ /* Done with exclusive hardware access */
mutex_unlock(&ctrl->crit_sect);
- return(1);
+ return 1;
}
set_SOGO(ctrl);
- // Wait for SOBS to be unset
+ /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- // Done with exclusive hardware access
+ /* Done with exclusive hardware access */
mutex_unlock(&ctrl->crit_sect);
- return(0);
+ return 0;
}
@@ -719,7 +533,7 @@ static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
- return cpqhp_hardware_test(ctrl, value);
+ return cpqhp_hardware_test(ctrl, value);
}
@@ -738,7 +552,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
{
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
-
+
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
*value = cpq_get_attention_status(ctrl, slot);
@@ -793,6 +607,231 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
return 0;
}
+static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = {
+ .owner = THIS_MODULE,
+ .set_attention_status = set_attention_status,
+ .enable_slot = process_SI,
+ .disable_slot = process_SS,
+ .hardware_test = hardware_test,
+ .get_power_status = get_power_status,
+ .get_attention_status = get_attention_status,
+ .get_latch_status = get_latch_status,
+ .get_adapter_status = get_adapter_status,
+ .get_max_bus_speed = get_max_bus_speed,
+ .get_cur_bus_speed = get_cur_bus_speed,
+};
+
+#define SLOT_NAME_SIZE 10
+
+static int ctrl_slot_setup(struct controller *ctrl,
+ void __iomem *smbios_start,
+ void __iomem *smbios_table)
+{
+ struct slot *slot;
+ struct hotplug_slot *hotplug_slot;
+ struct hotplug_slot_info *hotplug_slot_info;
+ u8 number_of_slots;
+ u8 slot_device;
+ u8 slot_number;
+ u8 ctrl_slot;
+ u32 tempdword;
+ char name[SLOT_NAME_SIZE];
+ void __iomem *slot_entry= NULL;
+ int result = -ENOMEM;
+
+ dbg("%s\n", __func__);
+
+ tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
+
+ number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
+ slot_device = readb(ctrl->hpc_reg + SLOT_MASK) >> 4;
+ slot_number = ctrl->first_slot;
+
+ while (number_of_slots) {
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+ if (!slot)
+ goto error;
+
+ slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
+ GFP_KERNEL);
+ if (!slot->hotplug_slot)
+ goto error_slot;
+ hotplug_slot = slot->hotplug_slot;
+
+ hotplug_slot->info = kzalloc(sizeof(*(hotplug_slot->info)),
+ GFP_KERNEL);
+ if (!hotplug_slot->info)
+ goto error_hpslot;
+ hotplug_slot_info = hotplug_slot->info;
+
+ slot->ctrl = ctrl;
+ slot->bus = ctrl->bus;
+ slot->device = slot_device;
+ slot->number = slot_number;
+ dbg("slot->number = %u\n", slot->number);
+
+ slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9,
+ slot_entry);
+
+ while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) !=
+ slot->number)) {
+ slot_entry = get_SMBIOS_entry(smbios_start,
+ smbios_table, 9, slot_entry);
+ }
+
+ slot->p_sm_slot = slot_entry;
+
+ init_timer(&slot->task_event);
+ slot->task_event.expires = jiffies + 5 * HZ;
+ slot->task_event.function = cpqhp_pushbutton_thread;
+
+ /*FIXME: these capabilities aren't used but if they are
+ * they need to be correctly implemented
+ */
+ slot->capabilities |= PCISLOT_REPLACE_SUPPORTED;
+ slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED;
+
+ if (is_slot64bit(slot))
+ slot->capabilities |= PCISLOT_64_BIT_SUPPORTED;
+ if (is_slot66mhz(slot))
+ slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED;
+ if (ctrl->speed == PCI_SPEED_66MHz)
+ slot->capabilities |= PCISLOT_66_MHZ_OPERATION;
+
+ ctrl_slot =
+ slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4);
+
+ /* Check presence */
+ slot->capabilities |=
+ ((((~tempdword) >> 23) |
+ ((~tempdword) >> 15)) >> ctrl_slot) & 0x02;
+ /* Check the switch state */
+ slot->capabilities |=
+ ((~tempdword & 0xFF) >> ctrl_slot) & 0x01;
+ /* Check the slot enable */
+ slot->capabilities |=
+ ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
+
+ /* register this slot with the hotplug pci core */
+ hotplug_slot->release = &release_slot;
+ hotplug_slot->private = slot;
+ snprintf(name, SLOT_NAME_SIZE, "%u", slot->number);
+ hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
+
+ hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot);
+ hotplug_slot_info->attention_status =
+ cpq_get_attention_status(ctrl, slot);
+ hotplug_slot_info->latch_status =
+ cpq_get_latch_status(ctrl, slot);
+ hotplug_slot_info->adapter_status =
+ get_presence_status(ctrl, slot);
+
+ dbg("registering bus %d, dev %d, number %d, "
+ "ctrl->slot_device_offset %d, slot %d\n",
+ slot->bus, slot->device,
+ slot->number, ctrl->slot_device_offset,
+ slot_number);
+ result = pci_hp_register(hotplug_slot,
+ ctrl->pci_dev->bus,
+ slot->device,
+ name);
+ if (result) {
+ err("pci_hp_register failed with error %d\n", result);
+ goto error_info;
+ }
+
+ slot->next = ctrl->slot;
+ ctrl->slot = slot;
+
+ number_of_slots--;
+ slot_device++;
+ slot_number++;
+ }
+
+ return 0;
+error_info:
+ kfree(hotplug_slot_info);
+error_hpslot:
+ kfree(hotplug_slot);
+error_slot:
+ kfree(slot);
+error:
+ return result;
+}
+
+static int one_time_init(void)
+{
+ int loop;
+ int retval = 0;
+
+ if (initialized)
+ return 0;
+
+ power_mode = 0;
+
+ retval = init_cpqhp_routing_table();
+ if (retval)
+ goto error;
+
+ if (cpqhp_debug)
+ pci_print_IRQ_route();
+
+ dbg("Initialize + Start the notification mechanism \n");
+
+ retval = cpqhp_event_start_thread();
+ if (retval)
+ goto error;
+
+ dbg("Initialize slot lists\n");
+ for (loop = 0; loop < 256; loop++)
+ cpqhp_slot_list[loop] = NULL;
+
+ /* FIXME: We also need to hook the NMI handler eventually.
+ * this also needs to be worked with Christoph
+ * register_NMI_handler();
+ */
+ /* Map rom address */
+ cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN);
+ if (!cpqhp_rom_start) {
+ err ("Could not ioremap memory region for ROM\n");
+ retval = -EIO;
+ goto error;
+ }
+
+ /* Now, map the int15 entry point if we are on compaq specific
+ * hardware
+ */
+ compaq_nvram_init(cpqhp_rom_start);
+
+ /* Map smbios table entry point structure */
+ smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start,
+ cpqhp_rom_start + ROM_PHY_LEN);
+ if (!smbios_table) {
+ err ("Could not find the SMBIOS pointer in memory\n");
+ retval = -EIO;
+ goto error_rom_start;
+ }
+
+ smbios_start = ioremap(readl(smbios_table + ST_ADDRESS),
+ readw(smbios_table + ST_LENGTH));
+ if (!smbios_start) {
+ err ("Could not ioremap memory region taken from SMBIOS values\n");
+ retval = -EIO;
+ goto error_smbios_start;
+ }
+
+ initialized = 1;
+
+ return retval;
+
+error_smbios_start:
+ iounmap(smbios_start);
+error_rom_start:
+ iounmap(cpqhp_rom_start);
+error:
+ return retval;
+}
+
static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
u8 num_of_slots = 0;
@@ -815,7 +854,9 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return err;
}
- // Need to read VID early b/c it's used to differentiate CPQ and INTC discovery
+ /* Need to read VID early b/c it's used to differentiate CPQ and INTC
+ * discovery
+ */
rc = pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor_id);
if (rc || ((vendor_id != PCI_VENDOR_ID_COMPAQ) && (vendor_id != PCI_VENDOR_ID_INTEL))) {
err(msg_HPC_non_compaq_or_intel);
@@ -832,217 +873,209 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
}
/* Check for the proper subsytem ID's
- * Intel uses a different SSID programming model than Compaq.
+ * Intel uses a different SSID programming model than Compaq.
* For Intel, each SSID bit identifies a PHP capability.
* Also Intel HPC's may have RID=0.
*/
- if ((pdev->revision > 2) || (vendor_id == PCI_VENDOR_ID_INTEL)) {
- // TODO: This code can be made to support non-Compaq or Intel subsystem IDs
- rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vid);
- if (rc) {
- err("%s : pci_read_config_word failed\n", __func__);
- goto err_disable_device;
- }
- dbg("Subsystem Vendor ID: %x\n", subsystem_vid);
- if ((subsystem_vid != PCI_VENDOR_ID_COMPAQ) && (subsystem_vid != PCI_VENDOR_ID_INTEL)) {
- err(msg_HPC_non_compaq_or_intel);
- rc = -ENODEV;
- goto err_disable_device;
- }
+ if ((pdev->revision <= 2) && (vendor_id != PCI_VENDOR_ID_INTEL)) {
+ err(msg_HPC_not_supported);
+ return -ENODEV;
+ }
- ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
- if (!ctrl) {
- err("%s : out of memory\n", __func__);
- rc = -ENOMEM;
- goto err_disable_device;
- }
+ /* TODO: This code can be made to support non-Compaq or Intel
+ * subsystem IDs
+ */
+ rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vid);
+ if (rc) {
+ err("%s : pci_read_config_word failed\n", __func__);
+ goto err_disable_device;
+ }
+ dbg("Subsystem Vendor ID: %x\n", subsystem_vid);
+ if ((subsystem_vid != PCI_VENDOR_ID_COMPAQ) && (subsystem_vid != PCI_VENDOR_ID_INTEL)) {
+ err(msg_HPC_non_compaq_or_intel);
+ rc = -ENODEV;
+ goto err_disable_device;
+ }
- rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
- if (rc) {
- err("%s : pci_read_config_word failed\n", __func__);
- goto err_free_ctrl;
- }
+ ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
+ if (!ctrl) {
+ err("%s : out of memory\n", __func__);
+ rc = -ENOMEM;
+ goto err_disable_device;
+ }
- info("Hot Plug Subsystem Device ID: %x\n", subsystem_deviceid);
-
- /* Set Vendor ID, so it can be accessed later from other functions */
- ctrl->vendor_id = vendor_id;
-
- switch (subsystem_vid) {
- case PCI_VENDOR_ID_COMPAQ:
- if (pdev->revision >= 0x13) { /* CIOBX */
- ctrl->push_flag = 1;
- ctrl->slot_switch_type = 1;
- ctrl->push_button = 1;
- ctrl->pci_config_space = 1;
- ctrl->defeature_PHP = 1;
- ctrl->pcix_support = 1;
- ctrl->pcix_speed_capability = 1;
- pci_read_config_byte(pdev, 0x41, &bus_cap);
- if (bus_cap & 0x80) {
- dbg("bus max supports 133MHz PCI-X\n");
- ctrl->speed_capability = PCI_SPEED_133MHz_PCIX;
- break;
- }
- if (bus_cap & 0x40) {
- dbg("bus max supports 100MHz PCI-X\n");
- ctrl->speed_capability = PCI_SPEED_100MHz_PCIX;
- break;
- }
- if (bus_cap & 20) {
- dbg("bus max supports 66MHz PCI-X\n");
- ctrl->speed_capability = PCI_SPEED_66MHz_PCIX;
- break;
- }
- if (bus_cap & 10) {
- dbg("bus max supports 66MHz PCI\n");
- ctrl->speed_capability = PCI_SPEED_66MHz;
- break;
- }
-
- break;
- }
-
- switch (subsystem_deviceid) {
- case PCI_SUB_HPC_ID:
- /* Original 6500/7000 implementation */
- ctrl->slot_switch_type = 1;
- ctrl->speed_capability = PCI_SPEED_33MHz;
- ctrl->push_button = 0;
- ctrl->pci_config_space = 1;
- ctrl->defeature_PHP = 1;
- ctrl->pcix_support = 0;
- ctrl->pcix_speed_capability = 0;
- break;
- case PCI_SUB_HPC_ID2:
- /* First Pushbutton implementation */
- ctrl->push_flag = 1;
- ctrl->slot_switch_type = 1;
- ctrl->speed_capability = PCI_SPEED_33MHz;
- ctrl->push_button = 1;
- ctrl->pci_config_space = 1;
- ctrl->defeature_PHP = 1;
- ctrl->pcix_support = 0;
- ctrl->pcix_speed_capability = 0;
- break;
- case PCI_SUB_HPC_ID_INTC:
- /* Third party (6500/7000) */
- ctrl->slot_switch_type = 1;
- ctrl->speed_capability = PCI_SPEED_33MHz;
- ctrl->push_button = 0;
- ctrl->pci_config_space = 1;
- ctrl->defeature_PHP = 1;
- ctrl->pcix_support = 0;
- ctrl->pcix_speed_capability = 0;
- break;
- case PCI_SUB_HPC_ID3:
- /* First 66 Mhz implementation */
- ctrl->push_flag = 1;
- ctrl->slot_switch_type = 1;
- ctrl->speed_capability = PCI_SPEED_66MHz;
- ctrl->push_button = 1;
- ctrl->pci_config_space = 1;
- ctrl->defeature_PHP = 1;
- ctrl->pcix_support = 0;
- ctrl->pcix_speed_capability = 0;
- break;
- case PCI_SUB_HPC_ID4:
- /* First PCI-X implementation, 100MHz */
- ctrl->push_flag = 1;
- ctrl->slot_switch_type = 1;
- ctrl->speed_capability = PCI_SPEED_100MHz_PCIX;
- ctrl->push_button = 1;
- ctrl->pci_config_space = 1;
- ctrl->defeature_PHP = 1;
- ctrl->pcix_support = 1;
- ctrl->pcix_speed_capability = 0;
- break;
- default:
- err(msg_HPC_not_supported);
- rc = -ENODEV;
- goto err_free_ctrl;
- }
- break;
+ rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
+ if (rc) {
+ err("%s : pci_read_config_word failed\n", __func__);
+ goto err_free_ctrl;
+ }
- case PCI_VENDOR_ID_INTEL:
- /* Check for speed capability (0=33, 1=66) */
- if (subsystem_deviceid & 0x0001) {
- ctrl->speed_capability = PCI_SPEED_66MHz;
- } else {
- ctrl->speed_capability = PCI_SPEED_33MHz;
- }
-
- /* Check for push button */
- if (subsystem_deviceid & 0x0002) {
- /* no push button */
- ctrl->push_button = 0;
- } else {
- /* push button supported */
- ctrl->push_button = 1;
- }
-
- /* Check for slot switch type (0=mechanical, 1=not mechanical) */
- if (subsystem_deviceid & 0x0004) {
- /* no switch */
- ctrl->slot_switch_type = 0;
- } else {
- /* switch */
- ctrl->slot_switch_type = 1;
- }
-
- /* PHP Status (0=De-feature PHP, 1=Normal operation) */
- if (subsystem_deviceid & 0x0008) {
- ctrl->defeature_PHP = 1; // PHP supported
- } else {
- ctrl->defeature_PHP = 0; // PHP not supported
- }
-
- /* Alternate Base Address Register Interface (0=not supported, 1=supported) */
- if (subsystem_deviceid & 0x0010) {
- ctrl->alternate_base_address = 1; // supported
- } else {
- ctrl->alternate_base_address = 0; // not supported
- }
-
- /* PCI Config Space Index (0=not supported, 1=supported) */
- if (subsystem_deviceid & 0x0020) {
- ctrl->pci_config_space = 1; // supported
- } else {
- ctrl->pci_config_space = 0; // not supported
- }
-
- /* PCI-X support */
- if (subsystem_deviceid & 0x0080) {
- /* PCI-X capable */
- ctrl->pcix_support = 1;
- /* Frequency of operation in PCI-X mode */
- if (subsystem_deviceid & 0x0040) {
- /* 133MHz PCI-X if bit 7 is 1 */
- ctrl->pcix_speed_capability = 1;
- } else {
- /* 100MHz PCI-X if bit 7 is 1 and bit 0 is 0, */
- /* 66MHz PCI-X if bit 7 is 1 and bit 0 is 1 */
- ctrl->pcix_speed_capability = 0;
- }
- } else {
- /* Conventional PCI */
- ctrl->pcix_support = 0;
- ctrl->pcix_speed_capability = 0;
- }
+ info("Hot Plug Subsystem Device ID: %x\n", subsystem_deviceid);
+
+ /* Set Vendor ID, so it can be accessed later from other
+ * functions
+ */
+ ctrl->vendor_id = vendor_id;
+
+ switch (subsystem_vid) {
+ case PCI_VENDOR_ID_COMPAQ:
+ if (pdev->revision >= 0x13) { /* CIOBX */
+ ctrl->push_flag = 1;
+ ctrl->slot_switch_type = 1;
+ ctrl->push_button = 1;
+ ctrl->pci_config_space = 1;
+ ctrl->defeature_PHP = 1;
+ ctrl->pcix_support = 1;
+ ctrl->pcix_speed_capability = 1;
+ pci_read_config_byte(pdev, 0x41, &bus_cap);
+ if (bus_cap & 0x80) {
+ dbg("bus max supports 133MHz PCI-X\n");
+ ctrl->speed_capability = PCI_SPEED_133MHz_PCIX;
break;
+ }
+ if (bus_cap & 0x40) {
+ dbg("bus max supports 100MHz PCI-X\n");
+ ctrl->speed_capability = PCI_SPEED_100MHz_PCIX;
+ break;
+ }
+ if (bus_cap & 20) {
+ dbg("bus max supports 66MHz PCI-X\n");
+ ctrl->speed_capability = PCI_SPEED_66MHz_PCIX;
+ break;
+ }
+ if (bus_cap & 10) {
+ dbg("bus max supports 66MHz PCI\n");
+ ctrl->speed_capability = PCI_SPEED_66MHz;
+ break;
+ }
+
+ break;
+ }
- default:
- err(msg_HPC_not_supported);
- rc = -ENODEV;
- goto err_free_ctrl;
+ switch (subsystem_deviceid) {
+ case PCI_SUB_HPC_ID:
+ /* Original 6500/7000 implementation */
+ ctrl->slot_switch_type = 1;
+ ctrl->speed_capability = PCI_SPEED_33MHz;
+ ctrl->push_button = 0;
+ ctrl->pci_config_space = 1;
+ ctrl->defeature_PHP = 1;
+ ctrl->pcix_support = 0;
+ ctrl->pcix_speed_capability = 0;
+ break;
+ case PCI_SUB_HPC_ID2:
+ /* First Pushbutton implementation */
+ ctrl->push_flag = 1;
+ ctrl->slot_switch_type = 1;
+ ctrl->speed_capability = PCI_SPEED_33MHz;
+ ctrl->push_button = 1;
+ ctrl->pci_config_space = 1;
+ ctrl->defeature_PHP = 1;
+ ctrl->pcix_support = 0;
+ ctrl->pcix_speed_capability = 0;
+ break;
+ case PCI_SUB_HPC_ID_INTC:
+ /* Third party (6500/7000) */
+ ctrl->slot_switch_type = 1;
+ ctrl->speed_capability = PCI_SPEED_33MHz;
+ ctrl->push_button = 0;
+ ctrl->pci_config_space = 1;
+ ctrl->defeature_PHP = 1;
+ ctrl->pcix_support = 0;
+ ctrl->pcix_speed_capability = 0;
+ break;
+ case PCI_SUB_HPC_ID3:
+ /* First 66 Mhz implementation */
+ ctrl->push_flag = 1;
+ ctrl->slot_switch_type = 1;
+ ctrl->speed_capability = PCI_SPEED_66MHz;
+ ctrl->push_button = 1;
+ ctrl->pci_config_space = 1;
+ ctrl->defeature_PHP = 1;
+ ctrl->pcix_support = 0;
+ ctrl->pcix_speed_capability = 0;
+ break;
+ case PCI_SUB_HPC_ID4:
+ /* First PCI-X implementation, 100MHz */
+ ctrl->push_flag = 1;
+ ctrl->slot_switch_type = 1;
+ ctrl->speed_capability = PCI_SPEED_100MHz_PCIX;
+ ctrl->push_button = 1;
+ ctrl->pci_config_space = 1;
+ ctrl->defeature_PHP = 1;
+ ctrl->pcix_support = 1;
+ ctrl->pcix_speed_capability = 0;
+ break;
+ default:
+ err(msg_HPC_not_supported);
+ rc = -ENODEV;
+ goto err_free_ctrl;
}
+ break;
+
+ case PCI_VENDOR_ID_INTEL:
+ /* Check for speed capability (0=33, 1=66) */
+ if (subsystem_deviceid & 0x0001)
+ ctrl->speed_capability = PCI_SPEED_66MHz;
+ else
+ ctrl->speed_capability = PCI_SPEED_33MHz;
+
+ /* Check for push button */
+ if (subsystem_deviceid & 0x0002)
+ ctrl->push_button = 0;
+ else
+ ctrl->push_button = 1;
+
+ /* Check for slot switch type (0=mechanical, 1=not mechanical) */
+ if (subsystem_deviceid & 0x0004)
+ ctrl->slot_switch_type = 0;
+ else
+ ctrl->slot_switch_type = 1;
+
+ /* PHP Status (0=De-feature PHP, 1=Normal operation) */
+ if (subsystem_deviceid & 0x0008)
+ ctrl->defeature_PHP = 1; /* PHP supported */
+ else
+ ctrl->defeature_PHP = 0; /* PHP not supported */
+
+ /* Alternate Base Address Register Interface
+ * (0=not supported, 1=supported)
+ */
+ if (subsystem_deviceid & 0x0010)
+ ctrl->alternate_base_address = 1;
+ else
+ ctrl->alternate_base_address = 0;
+
+ /* PCI Config Space Index (0=not supported, 1=supported) */
+ if (subsystem_deviceid & 0x0020)
+ ctrl->pci_config_space = 1;
+ else
+ ctrl->pci_config_space = 0;
+
+ /* PCI-X support */
+ if (subsystem_deviceid & 0x0080) {
+ ctrl->pcix_support = 1;
+ if (subsystem_deviceid & 0x0040)
+ /* 133MHz PCI-X if bit 7 is 1 */
+ ctrl->pcix_speed_capability = 1;
+ else
+ /* 100MHz PCI-X if bit 7 is 1 and bit 0 is 0, */
+ /* 66MHz PCI-X if bit 7 is 1 and bit 0 is 1 */
+ ctrl->pcix_speed_capability = 0;
+ } else {
+ /* Conventional PCI */
+ ctrl->pcix_support = 0;
+ ctrl->pcix_speed_capability = 0;
+ }
+ break;
- } else {
+ default:
err(msg_HPC_not_supported);
- return -ENODEV;
+ rc = -ENODEV;
+ goto err_free_ctrl;
}
- // Tell the user that we found one.
+ /* Tell the user that we found one. */
info("Initializing the PCI hot plug controller residing on PCI bus %d\n",
pdev->bus->number);
@@ -1087,7 +1120,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) {
goto err_free_bus;
}
-
+
dbg("pdev = %p\n", pdev);
dbg("pci resource start %llx\n", (unsigned long long)pci_resource_start(pdev, 0));
dbg("pci resource len %llx\n", (unsigned long long)pci_resource_len(pdev, 0));
@@ -1109,7 +1142,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_free_mem_region;
}
- // Check for 66Mhz operation
+ /* Check for 66Mhz operation */
ctrl->speed = get_controller_speed(ctrl);
@@ -1120,7 +1153,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
*
********************************************************/
- // find the physical slot number of the first hot plug slot
+ /* find the physical slot number of the first hot plug slot */
/* Get slot won't work for devices behind bridges, but
* in this case it will always be called for the "base"
@@ -1137,7 +1170,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_iounmap;
}
- // Store PCI Config Space for all devices on this bus
+ /* Store PCI Config Space for all devices on this bus */
rc = cpqhp_save_config(ctrl, ctrl->bus, readb(ctrl->hpc_reg + SLOT_MASK));
if (rc) {
err("%s: unable to save PCI configuration data, error %d\n",
@@ -1148,7 +1181,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/*
* Get IO, memory, and IRQ resources for new devices
*/
- // The next line is required for cpqhp_find_available_resources
+ /* The next line is required for cpqhp_find_available_resources */
ctrl->interrupt = pdev->irq;
if (ctrl->interrupt < 0x10) {
cpqhp_legacy_mode = 1;
@@ -1182,7 +1215,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
__func__, rc);
goto err_iounmap;
}
-
+
/* Mask all general input interrupts */
writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_MASK);
@@ -1196,12 +1229,14 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_iounmap;
}
- /* Enable Shift Out interrupt and clear it, also enable SERR on power fault */
+ /* Enable Shift Out interrupt and clear it, also enable SERR on power
+ * fault
+ */
temp_word = readw(ctrl->hpc_reg + MISC);
temp_word |= 0x4006;
writew(temp_word, ctrl->hpc_reg + MISC);
- // Changed 05/05/97 to clear all interrupts at start
+ /* Changed 05/05/97 to clear all interrupts at start */
writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_INPUT_CLEAR);
ctrl->ctrl_int_comp = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
@@ -1216,13 +1251,14 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
cpqhp_ctrl_list = ctrl;
}
- // turn off empty slots here unless command line option "ON" set
- // Wait for exclusive access to hardware
+ /* turn off empty slots here unless command line option "ON" set
+ * Wait for exclusive access to hardware
+ */
mutex_lock(&ctrl->crit_sect);
num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
- // find first device number for the ctrl
+ /* find first device number for the ctrl */
device = readb(ctrl->hpc_reg + SLOT_MASK) >> 4;
while (num_of_slots) {
@@ -1234,23 +1270,21 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hp_slot = func->device - ctrl->slot_device_offset;
dbg("hp_slot: %d\n", hp_slot);
- // We have to save the presence info for these slots
+ /* We have to save the presence info for these slots */
temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
- if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
+ if (ctrl->ctrl_int_comp & (0x1L << hp_slot))
func->switch_save = 0;
- } else {
+ else
func->switch_save = 0x10;
- }
- if (!power_mode) {
+ if (!power_mode)
if (!func->is_a_board) {
green_LED_off(ctrl, hp_slot);
slot_disable(ctrl, hp_slot);
}
- }
device++;
num_of_slots--;
@@ -1258,7 +1292,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!power_mode) {
set_SOGO(ctrl);
- // Wait for SOBS to be unset
+ /* Wait for SOBS to be unset */
wait_for_ctrl_irq(ctrl);
}
@@ -1269,7 +1303,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_free_irq;
}
- // Done with exclusive hardware access
+ /* Done with exclusive hardware access */
mutex_unlock(&ctrl->crit_sect);
cpqhp_create_debugfs_files(ctrl);
@@ -1291,77 +1325,6 @@ err_disable_device:
return rc;
}
-
-static int one_time_init(void)
-{
- int loop;
- int retval = 0;
-
- if (initialized)
- return 0;
-
- power_mode = 0;
-
- retval = pci_print_IRQ_route();
- if (retval)
- goto error;
-
- dbg("Initialize + Start the notification mechanism \n");
-
- retval = cpqhp_event_start_thread();
- if (retval)
- goto error;
-
- dbg("Initialize slot lists\n");
- for (loop = 0; loop < 256; loop++) {
- cpqhp_slot_list[loop] = NULL;
- }
-
- // FIXME: We also need to hook the NMI handler eventually.
- // this also needs to be worked with Christoph
- // register_NMI_handler();
-
- // Map rom address
- cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN);
- if (!cpqhp_rom_start) {
- err ("Could not ioremap memory region for ROM\n");
- retval = -EIO;
- goto error;
- }
-
- /* Now, map the int15 entry point if we are on compaq specific hardware */
- compaq_nvram_init(cpqhp_rom_start);
-
- /* Map smbios table entry point structure */
- smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start,
- cpqhp_rom_start + ROM_PHY_LEN);
- if (!smbios_table) {
- err ("Could not find the SMBIOS pointer in memory\n");
- retval = -EIO;
- goto error_rom_start;
- }
-
- smbios_start = ioremap(readl(smbios_table + ST_ADDRESS),
- readw(smbios_table + ST_LENGTH));
- if (!smbios_start) {
- err ("Could not ioremap memory region taken from SMBIOS values\n");
- retval = -EIO;
- goto error_smbios_start;
- }
-
- initialized = 1;
-
- return retval;
-
-error_smbios_start:
- iounmap(smbios_start);
-error_rom_start:
- iounmap(cpqhp_rom_start);
-error:
- return retval;
-}
-
-
static void __exit unload_cpqphpd(void)
{
struct pci_func *next;
@@ -1381,10 +1344,10 @@ static void __exit unload_cpqphpd(void)
if (ctrl->hpc_reg) {
u16 misc;
rc = read_slot_enable (ctrl);
-
+
writeb(0, ctrl->hpc_reg + SLOT_SERR);
writel(0xFFFFFFC0L | ~rc, ctrl->hpc_reg + INT_MASK);
-
+
misc = readw(ctrl->hpc_reg + MISC);
misc &= 0xFFFD;
writew(misc, ctrl->hpc_reg + MISC);
@@ -1464,38 +1427,34 @@ static void __exit unload_cpqphpd(void)
}
}
- // Stop the notification mechanism
+ /* Stop the notification mechanism */
if (initialized)
cpqhp_event_stop_thread();
- //unmap the rom address
+ /* unmap the rom address */
if (cpqhp_rom_start)
iounmap(cpqhp_rom_start);
if (smbios_start)
iounmap(smbios_start);
}
-
-
static struct pci_device_id hpcd_pci_tbl[] = {
{
/* handle any PCI Hotplug controller */
.class = ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00),
.class_mask = ~0,
-
+
/* no matter who makes it */
.vendor = PCI_ANY_ID,
.device = PCI_ANY_ID,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
-
+
}, { /* end: all zeroes */ }
};
MODULE_DEVICE_TABLE(pci, hpcd_pci_tbl);
-
-
static struct pci_driver cpqhpc_driver = {
.name = "compaq_pci_hotplug",
.id_table = hpcd_pci_tbl,
@@ -1503,8 +1462,6 @@ static struct pci_driver cpqhpc_driver = {
/* remove: cpqhpc_remove_one, */
};
-
-
static int __init cpqhpc_init(void)
{
int result;
@@ -1518,7 +1475,6 @@ static int __init cpqhpc_init(void)
return result;
}
-
static void __exit cpqhpc_cleanup(void)
{
dbg("unload_cpqphpd()\n");
@@ -1529,8 +1485,5 @@ static void __exit cpqhpc_cleanup(void)
cpqhp_shutdown_debugfs();
}
-
module_init(cpqhpc_init);
module_exit(cpqhpc_cleanup);
-
-
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index cc227a8c4b11..2fa47af992a8 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -81,14 +81,15 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x1L << hp_slot)) {
- /**********************************
+ /*
* this one changed.
- **********************************/
+ */
func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0);
/* this is the structure that tells the worker thread
- *what to do */
+ * what to do
+ */
taskInfo = &(ctrl->event_queue[ctrl->next_event]);
ctrl->next_event = (ctrl->next_event + 1) % 10;
taskInfo->hp_slot = hp_slot;
@@ -100,17 +101,17 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
- /**********************************
+ /*
* Switch opened
- **********************************/
+ */
func->switch_save = 0;
taskInfo->event_type = INT_SWITCH_OPEN;
} else {
- /**********************************
+ /*
* Switch closed
- **********************************/
+ */
func->switch_save = 0x10;
@@ -131,9 +132,8 @@ static struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
{
struct slot *slot = ctrl->slot;
- while (slot && (slot->device != device)) {
+ while (slot && (slot->device != device))
slot = slot->next;
- }
return slot;
}
@@ -152,17 +152,17 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
if (!change)
return 0;
- /**********************************
+ /*
* Presence Change
- **********************************/
+ */
dbg("cpqsbd: Presence/Notify input change.\n");
dbg(" Changed bits are 0x%4.4x\n", change );
for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x0101 << hp_slot)) {
- /**********************************
+ /*
* this one changed.
- **********************************/
+ */
func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0);
@@ -177,22 +177,23 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
return 0;
/* If the switch closed, must be a button
- * If not in button mode, nevermind */
+ * If not in button mode, nevermind
+ */
if (func->switch_save && (ctrl->push_button == 1)) {
temp_word = ctrl->ctrl_int_comp >> 16;
temp_byte = (temp_word >> hp_slot) & 0x01;
temp_byte |= (temp_word >> (hp_slot + 7)) & 0x02;
if (temp_byte != func->presence_save) {
- /**************************************
+ /*
* button Pressed (doesn't do anything)
- **************************************/
+ */
dbg("hp_slot %d button pressed\n", hp_slot);
taskInfo->event_type = INT_BUTTON_PRESS;
} else {
- /**********************************
+ /*
* button Released - TAKE ACTION!!!!
- **********************************/
+ */
dbg("hp_slot %d button released\n", hp_slot);
taskInfo->event_type = INT_BUTTON_RELEASE;
@@ -210,7 +211,8 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
}
} else {
/* Switch is open, assume a presence change
- * Save the presence state */
+ * Save the presence state
+ */
temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
@@ -241,17 +243,17 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
if (!change)
return 0;
- /**********************************
+ /*
* power fault
- **********************************/
+ */
info("power fault interrupt\n");
for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x01 << hp_slot)) {
- /**********************************
+ /*
* this one changed.
- **********************************/
+ */
func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0);
@@ -262,16 +264,16 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
rc++;
if (ctrl->ctrl_int_comp & (0x00000100 << hp_slot)) {
- /**********************************
+ /*
* power fault Cleared
- **********************************/
+ */
func->status = 0x00;
taskInfo->event_type = INT_POWER_FAULT_CLEAR;
} else {
- /**********************************
+ /*
* power fault
- **********************************/
+ */
taskInfo->event_type = INT_POWER_FAULT;
if (ctrl->rev < 4) {
@@ -432,13 +434,15 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
/* If we got here, there the bridge requires some of the resource, but
- * we may be able to split some off of the front */
+ * we may be able to split some off of the front
+ */
node = *head;
if (node->length & (alignment -1)) {
/* this one isn't an aligned length, so we'll make a new entry
- * and split it up. */
+ * and split it up.
+ */
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
@@ -544,10 +548,10 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
if (!(*head))
return NULL;
- if ( cpqhp_resource_sort_and_combine(head) )
+ if (cpqhp_resource_sort_and_combine(head))
return NULL;
- if ( sort_by_size(head) )
+ if (sort_by_size(head))
return NULL;
for (node = *head; node; node = node->next) {
@@ -556,7 +560,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
if (node->base & (size - 1)) {
/* this one isn't base aligned properly
- * so we'll make a new entry and split it up */
+ * so we'll make a new entry and split it up
+ */
temp_dword = (node->base | (size-1)) + 1;
/* Short circuit if adjusted size is too small */
@@ -581,7 +586,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
/* Don't need to check if too small since we already did */
if (node->length > size) {
/* this one is longer than we need
- * so we'll make a new entry and split it up */
+ * so we'll make a new entry and split it up
+ */
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
@@ -601,7 +607,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
continue;
/* If we got here, then it is the right size
- * Now take it out of the list and break */
+ * Now take it out of the list and break
+ */
if (*head == node) {
*head = node->next;
} else {
@@ -642,14 +649,16 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
return NULL;
for (max = *head; max; max = max->next) {
- /* If not big enough we could probably just bail,
- * instead we'll continue to the next. */
+ /* If not big enough we could probably just bail,
+ * instead we'll continue to the next.
+ */
if (max->length < size)
continue;
if (max->base & (size - 1)) {
/* this one isn't base aligned properly
- * so we'll make a new entry and split it up */
+ * so we'll make a new entry and split it up
+ */
temp_dword = (max->base | (size-1)) + 1;
/* Short circuit if adjusted size is too small */
@@ -672,7 +681,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
if ((max->base + max->length) & (size - 1)) {
/* this one isn't end aligned properly at the top
- * so we'll make a new entry and split it up */
+ * so we'll make a new entry and split it up
+ */
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
@@ -744,7 +754,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
if (node->base & (size - 1)) {
dbg("%s: not aligned\n", __func__);
/* this one isn't base aligned properly
- * so we'll make a new entry and split it up */
+ * so we'll make a new entry and split it up
+ */
temp_dword = (node->base | (size-1)) + 1;
/* Short circuit if adjusted size is too small */
@@ -769,7 +780,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
if (node->length > size) {
dbg("%s: too big\n", __func__);
/* this one is longer than we need
- * so we'll make a new entry and split it up */
+ * so we'll make a new entry and split it up
+ */
split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
if (!split_node)
@@ -886,19 +898,19 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data)
u32 Diff;
u32 temp_dword;
-
+
misc = readw(ctrl->hpc_reg + MISC);
- /***************************************
+ /*
* Check to see if it was our interrupt
- ***************************************/
+ */
if (!(misc & 0x000C)) {
return IRQ_NONE;
}
if (misc & 0x0004) {
- /**********************************
+ /*
* Serial Output interrupt Pending
- **********************************/
+ */
/* Clear the interrupt */
misc |= 0x0004;
@@ -961,11 +973,8 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
struct pci_func *next;
new_slot = kzalloc(sizeof(*new_slot), GFP_KERNEL);
- if (new_slot == NULL) {
- /* I'm not dead yet!
- * You will be. */
+ if (new_slot == NULL)
return new_slot;
- }
new_slot->next = NULL;
new_slot->configured = 1;
@@ -996,10 +1005,8 @@ static int slot_remove(struct pci_func * old_slot)
return 1;
next = cpqhp_slot_list[old_slot->bus];
-
- if (next == NULL) {
+ if (next == NULL)
return 1;
- }
if (next == old_slot) {
cpqhp_slot_list[old_slot->bus] = old_slot->next;
@@ -1008,9 +1015,8 @@ static int slot_remove(struct pci_func * old_slot)
return 0;
}
- while ((next->next != old_slot) && (next->next != NULL)) {
+ while ((next->next != old_slot) && (next->next != NULL))
next = next->next;
- }
if (next->next == old_slot) {
next->next = old_slot->next;
@@ -1040,9 +1046,8 @@ static int bridge_slot_remove(struct pci_func *bridge)
for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) {
next = cpqhp_slot_list[tempBus];
- while (!slot_remove(next)) {
+ while (!slot_remove(next))
next = cpqhp_slot_list[tempBus];
- }
}
next = cpqhp_slot_list[bridge->bus];
@@ -1130,39 +1135,43 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
u8 slot_power = readb(ctrl->hpc_reg + SLOT_POWER);
u16 reg16;
u32 leds = readl(ctrl->hpc_reg + LED_CONTROL);
-
+
if (ctrl->speed == adapter_speed)
return 0;
-
+
/* We don't allow freq/mode changes if we find another adapter running
- * in another slot on this controller */
+ * in another slot on this controller
+ */
for(slot = ctrl->slot; slot; slot = slot->next) {
- if (slot->device == (hp_slot + ctrl->slot_device_offset))
+ if (slot->device == (hp_slot + ctrl->slot_device_offset))
continue;
if (!slot->hotplug_slot || !slot->hotplug_slot->info)
continue;
- if (slot->hotplug_slot->info->adapter_status == 0)
+ if (slot->hotplug_slot->info->adapter_status == 0)
continue;
/* If another adapter is running on the same segment but at a
* lower speed/mode, we allow the new adapter to function at
- * this rate if supported */
- if (ctrl->speed < adapter_speed)
+ * this rate if supported
+ */
+ if (ctrl->speed < adapter_speed)
return 0;
return 1;
}
-
+
/* If the controller doesn't support freq/mode changes and the
- * controller is running at a higher mode, we bail */
+ * controller is running at a higher mode, we bail
+ */
if ((ctrl->speed > adapter_speed) && (!ctrl->pcix_speed_capability))
return 1;
-
+
/* But we allow the adapter to run at a lower rate if possible */
if ((ctrl->speed < adapter_speed) && (!ctrl->pcix_speed_capability))
return 0;
/* We try to set the max speed supported by both the adapter and
- * controller */
+ * controller
+ */
if (ctrl->speed_capability < adapter_speed) {
if (ctrl->speed == ctrl->speed_capability)
return 0;
@@ -1171,22 +1180,22 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
writel(0x0L, ctrl->hpc_reg + LED_CONTROL);
writeb(0x00, ctrl->hpc_reg + SLOT_ENABLE);
-
- set_SOGO(ctrl);
+
+ set_SOGO(ctrl);
wait_for_ctrl_irq(ctrl);
-
+
if (adapter_speed != PCI_SPEED_133MHz_PCIX)
reg = 0xF5;
else
- reg = 0xF4;
+ reg = 0xF4;
pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
-
+
reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ);
reg16 &= ~0x000F;
switch(adapter_speed) {
- case(PCI_SPEED_133MHz_PCIX):
+ case(PCI_SPEED_133MHz_PCIX):
reg = 0x75;
- reg16 |= 0xB;
+ reg16 |= 0xB;
break;
case(PCI_SPEED_100MHz_PCIX):
reg = 0x74;
@@ -1203,48 +1212,48 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
default: /* 33MHz PCI 2.2 */
reg = 0x71;
break;
-
+
}
reg16 |= 0xB << 12;
writew(reg16, ctrl->hpc_reg + NEXT_CURR_FREQ);
-
- mdelay(5);
-
+
+ mdelay(5);
+
/* Reenable interrupts */
writel(0, ctrl->hpc_reg + INT_MASK);
- pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
-
+ pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
+
/* Restart state machine */
reg = ~0xF;
pci_read_config_byte(ctrl->pci_dev, 0x43, &reg);
pci_write_config_byte(ctrl->pci_dev, 0x43, reg);
-
+
/* Only if mode change...*/
if (((ctrl->speed == PCI_SPEED_66MHz) && (adapter_speed == PCI_SPEED_66MHz_PCIX)) ||
((ctrl->speed == PCI_SPEED_66MHz_PCIX) && (adapter_speed == PCI_SPEED_66MHz)))
set_SOGO(ctrl);
-
+
wait_for_ctrl_irq(ctrl);
mdelay(1100);
-
+
/* Restore LED/Slot state */
writel(leds, ctrl->hpc_reg + LED_CONTROL);
writeb(slot_power, ctrl->hpc_reg + SLOT_ENABLE);
-
+
set_SOGO(ctrl);
wait_for_ctrl_irq(ctrl);
ctrl->speed = adapter_speed;
slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
- info("Successfully changed frequency/mode for adapter in slot %d\n",
+ info("Successfully changed frequency/mode for adapter in slot %d\n",
slot->number);
return 0;
}
-/* the following routines constitute the bulk of the
- hotplug controller logic
+/* the following routines constitute the bulk of the
+ * hotplug controller logic
*/
@@ -1268,17 +1277,17 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
hp_slot = func->device - ctrl->slot_device_offset;
- if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)) {
- /**********************************
- * The switch is open.
- **********************************/
+ /*
+ * The switch is open.
+ */
+ if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot))
rc = INTERLOCK_OPEN;
- } else if (is_slot_enabled (ctrl, hp_slot)) {
- /**********************************
- * The board is already on
- **********************************/
+ /*
+ * The board is already on
+ */
+ else if (is_slot_enabled (ctrl, hp_slot))
rc = CARD_FUNCTIONING;
- } else {
+ else {
mutex_lock(&ctrl->crit_sect);
/* turn on board without attaching to the bus */
@@ -1299,7 +1308,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
-
+
adapter_speed = get_adapter_speed(ctrl, hp_slot);
if (ctrl->speed != adapter_speed)
if (set_controller_speed(ctrl, adapter_speed, hp_slot))
@@ -1352,7 +1361,8 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
* Get slot won't work for devices behind
* bridges, but in this case it will always be
* called for the "base" bus/dev/func of an
- * adapter. */
+ * adapter.
+ */
mutex_lock(&ctrl->crit_sect);
@@ -1377,7 +1387,8 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
* Get slot won't work for devices behind bridges, but
* in this case it will always be called for the "base"
- * bus/dev/func of an adapter. */
+ * bus/dev/func of an adapter.
+ */
mutex_lock(&ctrl->crit_sect);
@@ -1434,7 +1445,8 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
wait_for_ctrl_irq (ctrl);
/* Change bits in slot power register to force another shift out
- * NOTE: this is to work around the timer bug */
+ * NOTE: this is to work around the timer bug
+ */
temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
@@ -1443,12 +1455,12 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
-
+
adapter_speed = get_adapter_speed(ctrl, hp_slot);
if (ctrl->speed != adapter_speed)
if (set_controller_speed(ctrl, adapter_speed, hp_slot))
rc = WRONG_BUS_FREQUENCY;
-
+
/* turn off board without attaching to the bus */
disable_slot_power (ctrl, hp_slot);
@@ -1461,7 +1473,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
if (rc)
return rc;
-
+
p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
/* turn on board and blink green LED */
@@ -1521,7 +1533,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
}
/* All F's is an empty slot or an invalid board */
- if (temp_register != 0xFFFFFFFF) { /* Check for a board in the slot */
+ if (temp_register != 0xFFFFFFFF) {
res_lists.io_head = ctrl->io_head;
res_lists.mem_head = ctrl->mem_head;
res_lists.p_mem_head = ctrl->p_mem_head;
@@ -1570,9 +1582,8 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
index = 0;
do {
new_slot = cpqhp_slot_find(ctrl->bus, func->device, index++);
- if (new_slot && !new_slot->pci_dev) {
+ if (new_slot && !new_slot->pci_dev)
cpqhp_configure_device(ctrl, new_slot);
- }
} while (new_slot);
mutex_lock(&ctrl->crit_sect);
@@ -1859,12 +1870,12 @@ static void interrupt_event_handler(struct controller *ctrl)
info(msg_button_on, p_slot->number);
}
mutex_lock(&ctrl->crit_sect);
-
+
dbg("blink green LED and turn off amber\n");
-
+
amber_LED_off (ctrl, hp_slot);
green_LED_blink (ctrl, hp_slot);
-
+
set_SOGO(ctrl);
/* Wait for SOBS to be unset */
@@ -1958,7 +1969,7 @@ void cpqhp_pushbutton_thread(unsigned long slot)
if (cpqhp_process_SI(ctrl, func) != 0) {
amber_LED_on(ctrl, hp_slot);
green_LED_off(ctrl, hp_slot);
-
+
set_SOGO(ctrl);
/* Wait for SOBS to be unset */
@@ -2079,7 +2090,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
struct pci_bus *pci_bus = ctrl->pci_bus;
int physical_slot=0;
- device = func->device;
+ device = func->device;
func = cpqhp_slot_find(ctrl->bus, device, index++);
p_slot = cpqhp_find_slot(ctrl, device);
if (p_slot) {
@@ -2113,9 +2124,8 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
/* If the VGA Enable bit is set, remove isn't
* supported */
- if (BCR & PCI_BRIDGE_CTL_VGA) {
+ if (BCR & PCI_BRIDGE_CTL_VGA)
rc = REMOVE_NOT_SUPPORTED;
- }
}
}
@@ -2183,67 +2193,67 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0f;
switch (test_num) {
- case 1:
- /* Do stuff here! */
-
- /* Do that funky LED thing */
- /* so we can restore them later */
- save_LED = readl(ctrl->hpc_reg + LED_CONTROL);
- work_LED = 0x01010101;
- switch_leds(ctrl, num_of_slots, &work_LED, 0);
- switch_leds(ctrl, num_of_slots, &work_LED, 1);
- switch_leds(ctrl, num_of_slots, &work_LED, 0);
- switch_leds(ctrl, num_of_slots, &work_LED, 1);
-
- work_LED = 0x01010000;
- writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
- switch_leds(ctrl, num_of_slots, &work_LED, 0);
- switch_leds(ctrl, num_of_slots, &work_LED, 1);
- work_LED = 0x00000101;
- writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
- switch_leds(ctrl, num_of_slots, &work_LED, 0);
- switch_leds(ctrl, num_of_slots, &work_LED, 1);
+ case 1:
+ /* Do stuff here! */
+
+ /* Do that funky LED thing */
+ /* so we can restore them later */
+ save_LED = readl(ctrl->hpc_reg + LED_CONTROL);
+ work_LED = 0x01010101;
+ switch_leds(ctrl, num_of_slots, &work_LED, 0);
+ switch_leds(ctrl, num_of_slots, &work_LED, 1);
+ switch_leds(ctrl, num_of_slots, &work_LED, 0);
+ switch_leds(ctrl, num_of_slots, &work_LED, 1);
+
+ work_LED = 0x01010000;
+ writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
+ switch_leds(ctrl, num_of_slots, &work_LED, 0);
+ switch_leds(ctrl, num_of_slots, &work_LED, 1);
+ work_LED = 0x00000101;
+ writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
+ switch_leds(ctrl, num_of_slots, &work_LED, 0);
+ switch_leds(ctrl, num_of_slots, &work_LED, 1);
+
+ work_LED = 0x01010000;
+ writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
+ for (loop = 0; loop < num_of_slots; loop++) {
+ set_SOGO(ctrl);
- work_LED = 0x01010000;
- writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
- for (loop = 0; loop < num_of_slots; loop++) {
- set_SOGO(ctrl);
+ /* Wait for SOGO interrupt */
+ wait_for_ctrl_irq (ctrl);
- /* Wait for SOGO interrupt */
- wait_for_ctrl_irq (ctrl);
+ /* Get ready for next iteration */
+ long_delay((3*HZ)/10);
+ work_LED = work_LED >> 16;
+ writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
- /* Get ready for next iteration */
- long_delay((3*HZ)/10);
- work_LED = work_LED >> 16;
- writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
-
- set_SOGO(ctrl);
+ set_SOGO(ctrl);
- /* Wait for SOGO interrupt */
- wait_for_ctrl_irq (ctrl);
+ /* Wait for SOGO interrupt */
+ wait_for_ctrl_irq (ctrl);
- /* Get ready for next iteration */
- long_delay((3*HZ)/10);
- work_LED = work_LED << 16;
- writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
- work_LED = work_LED << 1;
- writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
- }
+ /* Get ready for next iteration */
+ long_delay((3*HZ)/10);
+ work_LED = work_LED << 16;
+ writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
+ work_LED = work_LED << 1;
+ writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
+ }
- /* put it back the way it was */
- writel(save_LED, ctrl->hpc_reg + LED_CONTROL);
+ /* put it back the way it was */
+ writel(save_LED, ctrl->hpc_reg + LED_CONTROL);
- set_SOGO(ctrl);
+ set_SOGO(ctrl);
- /* Wait for SOBS to be unset */
- wait_for_ctrl_irq (ctrl);
- break;
- case 2:
- /* Do other stuff here! */
- break;
- case 3:
- /* and more... */
- break;
+ /* Wait for SOBS to be unset */
+ wait_for_ctrl_irq (ctrl);
+ break;
+ case 2:
+ /* Do other stuff here! */
+ break;
+ case 3:
+ /* and more... */
+ break;
}
return 0;
}
@@ -2312,9 +2322,9 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func
while ((function < max_functions) && (!stop_it)) {
pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
- if (ID == 0xFFFFFFFF) { /* There's nothing there. */
+ if (ID == 0xFFFFFFFF) {
function++;
- } else { /* There's something there */
+ } else {
/* Setup slot structure. */
new_slot = cpqhp_slot_create(func->bus);
@@ -2339,8 +2349,8 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func
/*
- Configuration logic that involves the hotplug data structures and
- their bookkeeping
+ * Configuration logic that involves the hotplug data structures and
+ * their bookkeeping
*/
@@ -2393,7 +2403,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
if (rc)
return rc;
- if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
+ if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
/* set Primary bus */
dbg("set Primary bus = %d\n", func->bus);
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
@@ -2484,7 +2494,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
temp_resources.irqs = &irqs;
/* Make copies of the nodes we are going to pass down so that
- * if there is a problem,we can just use these to free resources */
+ * if there is a problem,we can just use these to free resources
+ */
hold_bus_node = kmalloc(sizeof(*hold_bus_node), GFP_KERNEL);
hold_IO_node = kmalloc(sizeof(*hold_IO_node), GFP_KERNEL);
hold_mem_node = kmalloc(sizeof(*hold_mem_node), GFP_KERNEL);
@@ -2556,7 +2567,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16;
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
- /* Adjust this to compensate for extra adjustment in first loop */
+ /* Adjust this to compensate for extra adjustment in first loop
+ */
irqs.barber_pole--;
rc = 0;
@@ -2917,27 +2929,26 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} /* End of base register loop */
if (cpqhp_legacy_mode) {
/* Figure out which interrupt pin this function uses */
- rc = pci_bus_read_config_byte (pci_bus, devfn,
+ rc = pci_bus_read_config_byte (pci_bus, devfn,
PCI_INTERRUPT_PIN, &temp_byte);
/* If this function needs an interrupt and we are behind
* a bridge and the pin is tied to something that's
* alread mapped, set this one the same */
- if (temp_byte && resources->irqs &&
- (resources->irqs->valid_INT &
+ if (temp_byte && resources->irqs &&
+ (resources->irqs->valid_INT &
(0x01 << ((temp_byte + resources->irqs->barber_pole - 1) & 0x03)))) {
/* We have to share with something already set up */
- IRQ = resources->irqs->interrupt[(temp_byte +
+ IRQ = resources->irqs->interrupt[(temp_byte +
resources->irqs->barber_pole - 1) & 0x03];
} else {
/* Program IRQ based on card type */
rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
- if (class_code == PCI_BASE_CLASS_STORAGE) {
+ if (class_code == PCI_BASE_CLASS_STORAGE)
IRQ = cpqhp_disk_irq;
- } else {
+ else
IRQ = cpqhp_nic_irq;
- }
}
/* IRQ Line */
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
index cb174888002b..76ba8a1c774d 100644
--- a/drivers/pci/hotplug/cpqphp_nvram.c
+++ b/drivers/pci/hotplug/cpqphp_nvram.c
@@ -94,12 +94,13 @@ static u8 evbuffer[1024];
static void __iomem *compaq_int15_entry_point;
-static spinlock_t int15_lock; /* lock for ordering int15_bios_call() */
+/* lock for ordering int15_bios_call() */
+static spinlock_t int15_lock;
/* This is a series of function that deals with
- setting & getting the hotplug resource table in some environment variable.
-*/
+ * setting & getting the hotplug resource table in some environment variable.
+ */
/*
* We really shouldn't be doing this unless there is a _very_ good reason to!!!
@@ -113,7 +114,7 @@ static u32 add_byte( u32 **p_buffer, u8 value, u32 *used, u32 *avail)
if ((*used + 1) > *avail)
return(1);
-
+
*((u8*)*p_buffer) = value;
tByte = (u8**)p_buffer;
(*tByte)++;
@@ -170,10 +171,10 @@ static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size)
unsigned long flags;
int op = operation;
int ret_val;
-
+
if (!compaq_int15_entry_point)
return -ENODEV;
-
+
spin_lock_irqsave(&int15_lock, flags);
__asm__ (
"xorl %%ebx,%%ebx\n" \
@@ -187,7 +188,7 @@ static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size)
"D" (buffer), "m" (compaq_int15_entry_point)
: "%ebx", "%edx");
spin_unlock_irqrestore(&int15_lock, flags);
-
+
return((ret_val & 0xFF00) >> 8);
}
@@ -210,14 +211,16 @@ static int load_HRT (void __iomem *rom_start)
available = 1024;
- // Now load the EV
+ /* Now load the EV */
temp_dword = available;
rc = access_EV(READ_EV, "CQTHPS", evbuffer, &temp_dword);
evbuffer_length = temp_dword;
- // We're maintaining the resource lists so write FF to invalidate old info
+ /* We're maintaining the resource lists so write FF to invalidate old
+ * info
+ */
temp_dword = 1;
rc = access_EV(WRITE_EV, "CQTHPS", &temp_byte, &temp_dword);
@@ -263,13 +266,13 @@ static u32 store_HRT (void __iomem *rom_start)
p_EV_header = (struct ev_hrt_header *) pFill;
ctrl = cpqhp_ctrl_list;
-
- // The revision of this structure
+
+ /* The revision of this structure */
rc = add_byte( &pFill, 1 + ctrl->push_flag, &usedbytes, &available);
if (rc)
return(rc);
- // The number of controllers
+ /* The number of controllers */
rc = add_byte( &pFill, 1, &usedbytes, &available);
if (rc)
return(rc);
@@ -279,27 +282,27 @@ static u32 store_HRT (void __iomem *rom_start)
numCtrl++;
- // The bus number
+ /* The bus number */
rc = add_byte( &pFill, ctrl->bus, &usedbytes, &available);
if (rc)
return(rc);
- // The device Number
+ /* The device Number */
rc = add_byte( &pFill, PCI_SLOT(ctrl->pci_dev->devfn), &usedbytes, &available);
if (rc)
return(rc);
- // The function Number
+ /* The function Number */
rc = add_byte( &pFill, PCI_FUNC(ctrl->pci_dev->devfn), &usedbytes, &available);
if (rc)
return(rc);
- // Skip the number of available entries
+ /* Skip the number of available entries */
rc = add_dword( &pFill, 0, &usedbytes, &available);
if (rc)
return(rc);
- // Figure out memory Available
+ /* Figure out memory Available */
resNode = ctrl->mem_head;
@@ -308,12 +311,12 @@ static u32 store_HRT (void __iomem *rom_start)
while (resNode) {
loop ++;
- // base
+ /* base */
rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
if (rc)
return(rc);
- // length
+ /* length */
rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
if (rc)
return(rc);
@@ -321,10 +324,10 @@ static u32 store_HRT (void __iomem *rom_start)
resNode = resNode->next;
}
- // Fill in the number of entries
+ /* Fill in the number of entries */
p_ev_ctrl->mem_avail = loop;
- // Figure out prefetchable memory Available
+ /* Figure out prefetchable memory Available */
resNode = ctrl->p_mem_head;
@@ -333,12 +336,12 @@ static u32 store_HRT (void __iomem *rom_start)
while (resNode) {
loop ++;
- // base
+ /* base */
rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
if (rc)
return(rc);
- // length
+ /* length */
rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
if (rc)
return(rc);
@@ -346,10 +349,10 @@ static u32 store_HRT (void __iomem *rom_start)
resNode = resNode->next;
}
- // Fill in the number of entries
+ /* Fill in the number of entries */
p_ev_ctrl->p_mem_avail = loop;
- // Figure out IO Available
+ /* Figure out IO Available */
resNode = ctrl->io_head;
@@ -358,12 +361,12 @@ static u32 store_HRT (void __iomem *rom_start)
while (resNode) {
loop ++;
- // base
+ /* base */
rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
if (rc)
return(rc);
- // length
+ /* length */
rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
if (rc)
return(rc);
@@ -371,10 +374,10 @@ static u32 store_HRT (void __iomem *rom_start)
resNode = resNode->next;
}
- // Fill in the number of entries
+ /* Fill in the number of entries */
p_ev_ctrl->io_avail = loop;
- // Figure out bus Available
+ /* Figure out bus Available */
resNode = ctrl->bus_head;
@@ -383,12 +386,12 @@ static u32 store_HRT (void __iomem *rom_start)
while (resNode) {
loop ++;
- // base
+ /* base */
rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
if (rc)
return(rc);
- // length
+ /* length */
rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
if (rc)
return(rc);
@@ -396,15 +399,15 @@ static u32 store_HRT (void __iomem *rom_start)
resNode = resNode->next;
}
- // Fill in the number of entries
+ /* Fill in the number of entries */
p_ev_ctrl->bus_avail = loop;
ctrl = ctrl->next;
}
-
+
p_EV_header->num_of_ctrl = numCtrl;
- // Now store the EV
+ /* Now store the EV */
temp_dword = usedbytes;
@@ -449,20 +452,21 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
struct ev_hrt_header *p_EV_header;
if (!evbuffer_init) {
- // Read the resource list information in from NVRAM
+ /* Read the resource list information in from NVRAM */
if (load_HRT(rom_start))
memset (evbuffer, 0, 1024);
evbuffer_init = 1;
}
- // If we saved information in NVRAM, use it now
+ /* If we saved information in NVRAM, use it now */
p_EV_header = (struct ev_hrt_header *) evbuffer;
- // The following code is for systems where version 1.0 of this
- // driver has been loaded, but doesn't support the hardware.
- // In that case, the driver would incorrectly store something
- // in NVRAM.
+ /* The following code is for systems where version 1.0 of this
+ * driver has been loaded, but doesn't support the hardware.
+ * In that case, the driver would incorrectly store something
+ * in NVRAM.
+ */
if ((p_EV_header->Version == 2) ||
((p_EV_header->Version == 1) && !ctrl->push_flag)) {
p_byte = &(p_EV_header->next);
@@ -479,7 +483,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
function = p_ev_ctrl->function;
while ((bus != ctrl->bus) ||
- (device != PCI_SLOT(ctrl->pci_dev->devfn)) ||
+ (device != PCI_SLOT(ctrl->pci_dev->devfn)) ||
(function != PCI_FUNC(ctrl->pci_dev->devfn))) {
nummem = p_ev_ctrl->mem_avail;
numpmem = p_ev_ctrl->p_mem_avail;
@@ -491,7 +495,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
if (p_byte > ((u8*)p_EV_header + evbuffer_length))
return 2;
- // Skip forward to the next entry
+ /* Skip forward to the next entry */
p_byte += (nummem + numpmem + numio + numbus) * 8;
if (p_byte > ((u8*)p_EV_header + evbuffer_length))
@@ -629,8 +633,9 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
ctrl->bus_head = bus_node;
}
- // If all of the following fail, we don't have any resources for
- // hot plug add
+ /* If all of the following fail, we don't have any resources for
+ * hot plug add
+ */
rc = 1;
rc &= cpqhp_resource_sort_and_combine(&(ctrl->mem_head));
rc &= cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head));
@@ -640,14 +645,14 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
if (rc)
return(rc);
} else {
- if ((evbuffer[0] != 0) && (!ctrl->push_flag))
+ if ((evbuffer[0] != 0) && (!ctrl->push_flag))
return 1;
}
return 0;
}
-
+
int compaq_nvram_store (void __iomem *rom_start)
{
int rc = 1;
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 6c0ed0fcb8ee..6173b9a4544e 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -37,7 +37,6 @@
#include "../pci.h"
#include "cpqphp.h"
#include "cpqphp_nvram.h"
-#include <asm/pci_x86.h>
u8 cpqhp_nic_irq;
@@ -82,14 +81,14 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom
}
-int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
+int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
{
unsigned char bus;
struct pci_bus *child;
int num;
if (func->pci_dev == NULL)
- func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
+ func->pci_dev = pci_get_bus_and_slot(func->bus,PCI_DEVFN(func->device, func->function));
/* No pci device, we need to create it then */
if (func->pci_dev == NULL) {
@@ -99,7 +98,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
if (num)
pci_bus_add_devices(ctrl->pci_dev->bus);
- func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
+ func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
if (func->pci_dev == NULL) {
dbg("ERROR: pci_dev still null\n");
return 0;
@@ -112,20 +111,24 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
pci_do_scan_bus(child);
}
+ pci_dev_put(func->pci_dev);
+
return 0;
}
-int cpqhp_unconfigure_device(struct pci_func* func)
+int cpqhp_unconfigure_device(struct pci_func* func)
{
int j;
-
+
dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function);
for (j=0; j<8 ; j++) {
- struct pci_dev* temp = pci_find_slot(func->bus, PCI_DEVFN(func->device, j));
- if (temp)
+ struct pci_dev* temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
+ if (temp) {
+ pci_dev_put(temp);
pci_remove_bus_device(temp);
+ }
}
return 0;
}
@@ -178,32 +181,22 @@ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
if (!rc)
return !rc;
- // set the Edge Level Control Register (ELCR)
+ /* set the Edge Level Control Register (ELCR) */
temp_word = inb(0x4d0);
temp_word |= inb(0x4d1) << 8;
temp_word |= 0x01 << irq_num;
- // This should only be for x86 as it sets the Edge Level Control Register
- outb((u8) (temp_word & 0xFF), 0x4d0);
- outb((u8) ((temp_word & 0xFF00) >> 8), 0x4d1);
- rc = 0;
- }
+ /* This should only be for x86 as it sets the Edge Level
+ * Control Register
+ */
+ outb((u8) (temp_word & 0xFF), 0x4d0); outb((u8) ((temp_word &
+ 0xFF00) >> 8), 0x4d1); rc = 0; }
return rc;
}
-/*
- * WTF??? This function isn't in the code, yet a function calls it, but the
- * compiler optimizes it away? strange. Here as a placeholder to keep the
- * compiler happy.
- */
-static int PCI_ScanBusNonBridge (u8 bus, u8 device)
-{
- return 0;
-}
-
static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev_num)
{
u16 tdevice;
@@ -213,11 +206,11 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev
ctrl->pci_bus->number = bus_num;
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
- //Scan for access first
+ /* Scan for access first */
if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1)
continue;
dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice);
- //Yep we got one. Not a bridge ?
+ /* Yep we got one. Not a bridge ? */
if ((work >> 8) != PCI_TO_PCI_BRIDGE_CLASS) {
*dev_num = tdevice;
dbg("found it !\n");
@@ -225,16 +218,16 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev
}
}
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
- //Scan for access first
+ /* Scan for access first */
if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1)
continue;
dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);
- //Yep we got one. bridge ?
+ /* Yep we got one. bridge ? */
if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus);
+ /* XXX: no recursion, wtf? */
dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice);
- if (PCI_ScanBusNonBridge(tbus, tdevice) == 0)
- return 0;
+ return 0;
}
}
@@ -244,39 +237,23 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev
static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot, u8 nobridge)
{
- struct irq_routing_table *PCIIRQRoutingInfoLength;
- long len;
- long loop;
+ int loop, len;
u32 work;
-
u8 tbus, tdevice, tslot;
- PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table();
- if (!PCIIRQRoutingInfoLength)
- return -1;
-
- len = (PCIIRQRoutingInfoLength->size -
- sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
- // Make sure I got at least one entry
- if (len == 0) {
- kfree(PCIIRQRoutingInfoLength );
- return -1;
- }
-
+ len = cpqhp_routing_table_length();
for (loop = 0; loop < len; ++loop) {
- tbus = PCIIRQRoutingInfoLength->slots[loop].bus;
- tdevice = PCIIRQRoutingInfoLength->slots[loop].devfn;
- tslot = PCIIRQRoutingInfoLength->slots[loop].slot;
+ tbus = cpqhp_routing_table->slots[loop].bus;
+ tdevice = cpqhp_routing_table->slots[loop].devfn;
+ tslot = cpqhp_routing_table->slots[loop].slot;
if (tslot == slot) {
*bus_num = tbus;
*dev_num = tdevice;
ctrl->pci_bus->number = tbus;
pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work);
- if (!nobridge || (work == 0xffffffff)) {
- kfree(PCIIRQRoutingInfoLength );
+ if (!nobridge || (work == 0xffffffff))
return 0;
- }
dbg("bus_num %d devfn %d\n", *bus_num, *dev_num);
pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work);
@@ -287,28 +264,26 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
dbg("Scan bus for Non Bridge: bus %d\n", tbus);
if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) {
*bus_num = tbus;
- kfree(PCIIRQRoutingInfoLength );
return 0;
}
- } else {
- kfree(PCIIRQRoutingInfoLength );
+ } else
return 0;
- }
-
}
}
- kfree(PCIIRQRoutingInfoLength );
return -1;
}
int cpqhp_get_bus_dev (struct controller *ctrl, u8 * bus_num, u8 * dev_num, u8 slot)
{
- return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0); //plain (bridges allowed)
+ /* plain (bridges allowed) */
+ return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0);
}
-/* More PCI configuration routines; this time centered around hotplug controller */
+/* More PCI configuration routines; this time centered around hotplug
+ * controller
+ */
/*
@@ -339,12 +314,12 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
int stop_it;
int index;
- // Decide which slots are supported
+ /* Decide which slots are supported */
if (is_hot_plug) {
- //*********************************
- // is_hot_plug is the slot mask
- //*********************************
+ /*
+ * is_hot_plug is the slot mask
+ */
FirstSupported = is_hot_plug >> 4;
LastSupported = FirstSupported + (is_hot_plug & 0x0F) - 1;
} else {
@@ -352,123 +327,127 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
LastSupported = 0x1F;
}
- // Save PCI configuration space for all devices in supported slots
+ /* Save PCI configuration space for all devices in supported slots */
ctrl->pci_bus->number = busnumber;
for (device = FirstSupported; device <= LastSupported; device++) {
ID = 0xFFFFFFFF;
- rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(device, 0), PCI_VENDOR_ID, &ID);
+ rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, 0), PCI_VENDOR_ID, &ID);
+
+ if (ID == 0xFFFFFFFF) {
+ if (is_hot_plug) {
+ /* Setup slot structure with entry for empty
+ * slot
+ */
+ new_slot = cpqhp_slot_create(busnumber);
+ if (new_slot == NULL)
+ return 1;
- if (ID != 0xFFFFFFFF) { // device in slot
- rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(device, 0), 0x0B, &class_code);
- if (rc)
- return rc;
+ new_slot->bus = (u8) busnumber;
+ new_slot->device = (u8) device;
+ new_slot->function = 0;
+ new_slot->is_a_board = 0;
+ new_slot->presence_save = 0;
+ new_slot->switch_save = 0;
+ }
+ continue;
+ }
- rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(device, 0), PCI_HEADER_TYPE, &header_type);
- if (rc)
- return rc;
+ rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(device, 0), 0x0B, &class_code);
+ if (rc)
+ return rc;
- // If multi-function device, set max_functions to 8
- if (header_type & 0x80)
- max_functions = 8;
- else
- max_functions = 1;
+ rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(device, 0), PCI_HEADER_TYPE, &header_type);
+ if (rc)
+ return rc;
- function = 0;
+ /* If multi-function device, set max_functions to 8 */
+ if (header_type & 0x80)
+ max_functions = 8;
+ else
+ max_functions = 1;
- do {
- DevError = 0;
+ function = 0;
- if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // P-P Bridge
- // Recurse the subordinate bus
- // get the subordinate bus number
- rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(device, function), PCI_SECONDARY_BUS, &secondary_bus);
- if (rc) {
+ do {
+ DevError = 0;
+ if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
+ /* Recurse the subordinate bus
+ * get the subordinate bus number
+ */
+ rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(device, function), PCI_SECONDARY_BUS, &secondary_bus);
+ if (rc) {
+ return rc;
+ } else {
+ sub_bus = (int) secondary_bus;
+
+ /* Save secondary bus cfg spc
+ * with this recursive call.
+ */
+ rc = cpqhp_save_config(ctrl, sub_bus, 0);
+ if (rc)
return rc;
- } else {
- sub_bus = (int) secondary_bus;
-
- // Save secondary bus cfg spc
- // with this recursive call.
- rc = cpqhp_save_config(ctrl, sub_bus, 0);
- if (rc)
- return rc;
- ctrl->pci_bus->number = busnumber;
- }
+ ctrl->pci_bus->number = busnumber;
}
+ }
- index = 0;
+ index = 0;
+ new_slot = cpqhp_slot_find(busnumber, device, index++);
+ while (new_slot &&
+ (new_slot->function != (u8) function))
new_slot = cpqhp_slot_find(busnumber, device, index++);
- while (new_slot &&
- (new_slot->function != (u8) function))
- new_slot = cpqhp_slot_find(busnumber, device, index++);
- if (!new_slot) {
- // Setup slot structure.
- new_slot = cpqhp_slot_create(busnumber);
-
- if (new_slot == NULL)
- return(1);
- }
-
- new_slot->bus = (u8) busnumber;
- new_slot->device = (u8) device;
- new_slot->function = (u8) function;
- new_slot->is_a_board = 1;
- new_slot->switch_save = 0x10;
- // In case of unsupported board
- new_slot->status = DevError;
- new_slot->pci_dev = pci_find_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
-
- for (cloop = 0; cloop < 0x20; cloop++) {
- rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop]));
- if (rc)
- return rc;
- }
+ if (!new_slot) {
+ /* Setup slot structure. */
+ new_slot = cpqhp_slot_create(busnumber);
+ if (new_slot == NULL)
+ return 1;
+ }
- function++;
+ new_slot->bus = (u8) busnumber;
+ new_slot->device = (u8) device;
+ new_slot->function = (u8) function;
+ new_slot->is_a_board = 1;
+ new_slot->switch_save = 0x10;
+ /* In case of unsupported board */
+ new_slot->status = DevError;
+ new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
- stop_it = 0;
+ for (cloop = 0; cloop < 0x20; cloop++) {
+ rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop]));
+ if (rc)
+ return rc;
+ }
- // this loop skips to the next present function
- // reading in Class Code and Header type.
+ pci_dev_put(new_slot->pci_dev);
- while ((function < max_functions)&&(!stop_it)) {
- rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(device, function), PCI_VENDOR_ID, &ID);
- if (ID == 0xFFFFFFFF) { // nothing there.
- function++;
- } else { // Something there
- rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(device, function), 0x0B, &class_code);
- if (rc)
- return rc;
+ function++;
- rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(device, function), PCI_HEADER_TYPE, &header_type);
- if (rc)
- return rc;
+ stop_it = 0;
- stop_it++;
- }
+ /* this loop skips to the next present function
+ * reading in Class Code and Header type.
+ */
+ while ((function < max_functions) && (!stop_it)) {
+ rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), PCI_VENDOR_ID, &ID);
+ if (ID == 0xFFFFFFFF) {
+ function++;
+ continue;
}
+ rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(device, function), 0x0B, &class_code);
+ if (rc)
+ return rc;
- } while (function < max_functions);
- } // End of IF (device in slot?)
- else if (is_hot_plug) {
- // Setup slot structure with entry for empty slot
- new_slot = cpqhp_slot_create(busnumber);
+ rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(device, function), PCI_HEADER_TYPE, &header_type);
+ if (rc)
+ return rc;
- if (new_slot == NULL) {
- return(1);
+ stop_it++;
}
- new_slot->bus = (u8) busnumber;
- new_slot->device = (u8) device;
- new_slot->function = 0;
- new_slot->is_a_board = 0;
- new_slot->presence_save = 0;
- new_slot->switch_save = 0;
- }
- } // End of FOR loop
+ } while (function < max_functions);
+ } /* End of FOR loop */
- return(0);
+ return 0;
}
@@ -489,7 +468,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot)
u8 secondary_bus;
int sub_bus;
int max_functions;
- int function;
+ int function = 0;
int cloop = 0;
int stop_it;
@@ -498,63 +477,58 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot)
ctrl->pci_bus->number = new_slot->bus;
pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_VENDOR_ID, &ID);
- if (ID != 0xFFFFFFFF) { // device in slot
- pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), 0x0B, &class_code);
- pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_HEADER_TYPE, &header_type);
-
- if (header_type & 0x80) // Multi-function device
- max_functions = 8;
- else
- max_functions = 1;
-
- function = 0;
-
- do {
- if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // PCI-PCI Bridge
- // Recurse the subordinate bus
- pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus);
+ if (ID == 0xFFFFFFFF)
+ return 2;
- sub_bus = (int) secondary_bus;
+ pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), 0x0B, &class_code);
+ pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_HEADER_TYPE, &header_type);
- // Save the config headers for the secondary bus.
- rc = cpqhp_save_config(ctrl, sub_bus, 0);
- if (rc)
- return(rc);
- ctrl->pci_bus->number = new_slot->bus;
+ if (header_type & 0x80) /* Multi-function device */
+ max_functions = 8;
+ else
+ max_functions = 1;
- } // End of IF
+ while (function < max_functions) {
+ if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
+ /* Recurse the subordinate bus */
+ pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus);
- new_slot->status = 0;
+ sub_bus = (int) secondary_bus;
- for (cloop = 0; cloop < 0x20; cloop++) {
- pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop]));
- }
+ /* Save the config headers for the secondary
+ * bus.
+ */
+ rc = cpqhp_save_config(ctrl, sub_bus, 0);
+ if (rc)
+ return(rc);
+ ctrl->pci_bus->number = new_slot->bus;
- function++;
+ }
- stop_it = 0;
+ new_slot->status = 0;
- // this loop skips to the next present function
- // reading in the Class Code and the Header type.
+ for (cloop = 0; cloop < 0x20; cloop++)
+ pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop]));
- while ((function < max_functions) && (!stop_it)) {
- pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_VENDOR_ID, &ID);
+ function++;
- if (ID == 0xFFFFFFFF) { // nothing there.
- function++;
- } else { // Something there
- pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), 0x0B, &class_code);
+ stop_it = 0;
- pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_HEADER_TYPE, &header_type);
+ /* this loop skips to the next present function
+ * reading in the Class Code and the Header type.
+ */
+ while ((function < max_functions) && (!stop_it)) {
+ pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_VENDOR_ID, &ID);
- stop_it++;
- }
+ if (ID == 0xFFFFFFFF)
+ function++;
+ else {
+ pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), 0x0B, &class_code);
+ pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_HEADER_TYPE, &header_type);
+ stop_it++;
}
+ }
- } while (function < max_functions);
- } // End of IF (device in slot?)
- else {
- return 2;
}
return 0;
@@ -590,11 +564,10 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func * func)
pci_bus->number = func->bus;
devfn = PCI_DEVFN(func->device, func->function);
- // Check for Bridge
+ /* Check for Bridge */
pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
- // PCI-PCI Bridge
pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
sub_bus = (int) secondary_bus;
@@ -610,23 +583,27 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func * func)
}
pci_bus->number = func->bus;
- //FIXME: this loop is duplicated in the non-bridge case. The two could be rolled together
- // Figure out IO and memory base lengths
+ /* FIXME: this loop is duplicated in the non-bridge
+ * case. The two could be rolled together Figure out
+ * IO and memory base lengths
+ */
for (cloop = 0x10; cloop <= 0x14; cloop += 4) {
temp_register = 0xFFFFFFFF;
pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register);
pci_bus_read_config_dword (pci_bus, devfn, cloop, &base);
-
- if (base) { // If this register is implemented
+ /* If this register is implemented */
+ if (base) {
if (base & 0x01L) {
- // IO base
- // set base = amount of IO space requested
+ /* IO base
+ * set base = amount of IO space
+ * requested
+ */
base = base & 0xFFFFFFFE;
base = (~base) + 1;
type = 1;
} else {
- // memory base
+ /* memory base */
base = base & 0xFFFFFFF0;
base = (~base) + 1;
@@ -637,32 +614,36 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func * func)
type = 0;
}
- // Save information in slot structure
+ /* Save information in slot structure */
func->base_length[(cloop - 0x10) >> 2] =
base;
func->base_type[(cloop - 0x10) >> 2] = type;
- } // End of base register loop
+ } /* End of base register loop */
-
- } else if ((header_type & 0x7F) == 0x00) { // PCI-PCI Bridge
- // Figure out IO and memory base lengths
+ } else if ((header_type & 0x7F) == 0x00) {
+ /* Figure out IO and memory base lengths */
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
temp_register = 0xFFFFFFFF;
pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register);
pci_bus_read_config_dword (pci_bus, devfn, cloop, &base);
- if (base) { // If this register is implemented
+ /* If this register is implemented */
+ if (base) {
if (base & 0x01L) {
- // IO base
- // base = amount of IO space requested
+ /* IO base
+ * base = amount of IO space
+ * requested
+ */
base = base & 0xFFFFFFFE;
base = (~base) + 1;
type = 1;
} else {
- // memory base
- // base = amount of memory space requested
+ /* memory base
+ * base = amount of memory
+ * space requested
+ */
base = base & 0xFFFFFFF0;
base = (~base) + 1;
@@ -673,16 +654,16 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func * func)
type = 0;
}
- // Save information in slot structure
+ /* Save information in slot structure */
func->base_length[(cloop - 0x10) >> 2] = base;
func->base_type[(cloop - 0x10) >> 2] = type;
- } // End of base register loop
+ } /* End of base register loop */
- } else { // Some other unknown header type
+ } else { /* Some other unknown header type */
}
- // find the next device in this slot
+ /* find the next device in this slot */
func = cpqhp_slot_find(func->bus, func->device, index++);
}
@@ -728,18 +709,18 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
pci_bus->number = func->bus;
devfn = PCI_DEVFN(func->device, func->function);
- // Save the command register
+ /* Save the command register */
pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &save_command);
- // disable card
+ /* disable card */
command = 0x00;
pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
- // Check for Bridge
+ /* Check for Bridge */
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
- if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // PCI-PCI Bridge
- // Clear Bridge Control Register
+ if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
+ /* Clear Bridge Control Register */
command = 0x00;
pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
@@ -755,7 +736,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
bus_node->next = func->bus_head;
func->bus_head = bus_node;
- // Save IO base and Limit registers
+ /* Save IO base and Limit registers */
pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_BASE, &b_base);
pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_LIMIT, &b_length);
@@ -771,7 +752,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
func->io_head = io_node;
}
- // Save memory base and Limit registers
+ /* Save memory base and Limit registers */
pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_BASE, &w_base);
pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, &w_length);
@@ -787,7 +768,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
func->mem_head = mem_node;
}
- // Save prefetchable memory base and Limit registers
+ /* Save prefetchable memory base and Limit registers */
pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, &w_base);
pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &w_length);
@@ -802,7 +783,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
p_mem_node->next = func->p_mem_head;
func->p_mem_head = p_mem_node;
}
- // Figure out IO and memory base lengths
+ /* Figure out IO and memory base lengths */
for (cloop = 0x10; cloop <= 0x14; cloop += 4) {
pci_bus_read_config_dword (pci_bus, devfn, cloop, &save_base);
@@ -812,11 +793,14 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
temp_register = base;
- if (base) { // If this register is implemented
+ /* If this register is implemented */
+ if (base) {
if (((base & 0x03L) == 0x01)
&& (save_command & 0x01)) {
- // IO base
- // set temp_register = amount of IO space requested
+ /* IO base
+ * set temp_register = amount
+ * of IO space requested
+ */
temp_register = base & 0xFFFFFFFE;
temp_register = (~temp_register) + 1;
@@ -834,7 +818,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
} else
if (((base & 0x0BL) == 0x08)
&& (save_command & 0x02)) {
- // prefetchable memory base
+ /* prefetchable memory base */
temp_register = base & 0xFFFFFFF0;
temp_register = (~temp_register) + 1;
@@ -851,7 +835,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
} else
if (((base & 0x0BL) == 0x00)
&& (save_command & 0x02)) {
- // prefetchable memory base
+ /* prefetchable memory base */
temp_register = base & 0xFFFFFFF0;
temp_register = (~temp_register) + 1;
@@ -868,9 +852,10 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
} else
return(1);
}
- } // End of base register loop
- } else if ((header_type & 0x7F) == 0x00) { // Standard header
- // Figure out IO and memory base lengths
+ } /* End of base register loop */
+ /* Standard header */
+ } else if ((header_type & 0x7F) == 0x00) {
+ /* Figure out IO and memory base lengths */
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
@@ -880,11 +865,14 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
temp_register = base;
- if (base) { // If this register is implemented
+ /* If this register is implemented */
+ if (base) {
if (((base & 0x03L) == 0x01)
&& (save_command & 0x01)) {
- // IO base
- // set temp_register = amount of IO space requested
+ /* IO base
+ * set temp_register = amount
+ * of IO space requested
+ */
temp_register = base & 0xFFFFFFFE;
temp_register = (~temp_register) + 1;
@@ -901,7 +889,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
} else
if (((base & 0x0BL) == 0x08)
&& (save_command & 0x02)) {
- // prefetchable memory base
+ /* prefetchable memory base */
temp_register = base & 0xFFFFFFF0;
temp_register = (~temp_register) + 1;
@@ -918,7 +906,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
} else
if (((base & 0x0BL) == 0x00)
&& (save_command & 0x02)) {
- // prefetchable memory base
+ /* prefetchable memory base */
temp_register = base & 0xFFFFFFF0;
temp_register = (~temp_register) + 1;
@@ -935,15 +923,14 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
} else
return(1);
}
- } // End of base register loop
- } else { // Some other unknown header type
+ } /* End of base register loop */
}
- // find the next device in this slot
+ /* find the next device in this slot */
func = cpqhp_slot_find(func->bus, func->device, index++);
}
- return(0);
+ return 0;
}
@@ -975,16 +962,16 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func * func)
pci_bus->number = func->bus;
devfn = PCI_DEVFN(func->device, func->function);
- // Start at the top of config space so that the control
- // registers are programmed last
- for (cloop = 0x3C; cloop > 0; cloop -= 4) {
+ /* Start at the top of config space so that the control
+ * registers are programmed last
+ */
+ for (cloop = 0x3C; cloop > 0; cloop -= 4)
pci_bus_write_config_dword (pci_bus, devfn, cloop, func->config_space[cloop >> 2]);
- }
pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
- // If this is a bridge device, restore subordinate devices
- if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // PCI-PCI Bridge
+ /* If this is a bridge device, restore subordinate devices */
+ if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
sub_bus = (int) secondary_bus;
@@ -1000,8 +987,9 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func * func)
}
} else {
- // Check all the base Address Registers to make sure
- // they are the same. If not, the board is different.
+ /* Check all the base Address Registers to make sure
+ * they are the same. If not, the board is different.
+ */
for (cloop = 16; cloop < 40; cloop += 4) {
pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp);
@@ -1058,27 +1046,28 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func)
pci_bus_read_config_dword (pci_bus, devfn, PCI_VENDOR_ID, &temp_register);
- // No adapter present
+ /* No adapter present */
if (temp_register == 0xFFFFFFFF)
return(NO_ADAPTER_PRESENT);
if (temp_register != func->config_space[0])
return(ADAPTER_NOT_SAME);
- // Check for same revision number and class code
+ /* Check for same revision number and class code */
pci_bus_read_config_dword (pci_bus, devfn, PCI_CLASS_REVISION, &temp_register);
- // Adapter not the same
+ /* Adapter not the same */
if (temp_register != func->config_space[0x08 >> 2])
return(ADAPTER_NOT_SAME);
- // Check for Bridge
+ /* Check for Bridge */
pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
- if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // PCI-PCI Bridge
- // In order to continue checking, we must program the
- // bus registers in the bridge to respond to accesses
- // for it's subordinate bus(es)
+ if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
+ /* In order to continue checking, we must program the
+ * bus registers in the bridge to respond to accesses
+ * for its subordinate bus(es)
+ */
temp_register = func->config_space[0x18 >> 2];
pci_bus_write_config_dword (pci_bus, devfn, PCI_PRIMARY_BUS, temp_register);
@@ -1096,35 +1085,39 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func)
}
}
- // Check to see if it is a standard config header
+ /* Check to see if it is a standard config header */
else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
- // Check subsystem vendor and ID
+ /* Check subsystem vendor and ID */
pci_bus_read_config_dword (pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register);
if (temp_register != func->config_space[0x2C >> 2]) {
- // If it's a SMART-2 and the register isn't filled
- // in, ignore the difference because
- // they just have an old rev of the firmware
-
+ /* If it's a SMART-2 and the register isn't
+ * filled in, ignore the difference because
+ * they just have an old rev of the firmware
+ */
if (!((func->config_space[0] == 0xAE100E11)
&& (temp_register == 0x00L)))
return(ADAPTER_NOT_SAME);
}
- // Figure out IO and memory base lengths
+ /* Figure out IO and memory base lengths */
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
temp_register = 0xFFFFFFFF;
pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register);
pci_bus_read_config_dword (pci_bus, devfn, cloop, &base);
- if (base) { // If this register is implemented
+
+ /* If this register is implemented */
+ if (base) {
if (base & 0x01L) {
- // IO base
- // set base = amount of IO space requested
+ /* IO base
+ * set base = amount of IO
+ * space requested
+ */
base = base & 0xFFFFFFFE;
base = (~base) + 1;
type = 1;
} else {
- // memory base
+ /* memory base */
base = base & 0xFFFFFFF0;
base = (~base) + 1;
@@ -1135,23 +1128,24 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func)
type = 0;
}
- // Check information in slot structure
+ /* Check information in slot structure */
if (func->base_length[(cloop - 0x10) >> 2] != base)
return(ADAPTER_NOT_SAME);
if (func->base_type[(cloop - 0x10) >> 2] != type)
return(ADAPTER_NOT_SAME);
- } // End of base register loop
+ } /* End of base register loop */
- } // End of (type 0 config space) else
+ } /* End of (type 0 config space) else */
else {
- // this is not a type 0 or 1 config space header so
- // we don't know how to do it
+ /* this is not a type 0 or 1 config space header so
+ * we don't know how to do it
+ */
return(DEVICE_TYPE_NOT_SUPPORTED);
}
- // Get the next function
+ /* Get the next function */
func = cpqhp_slot_find(func->bus, func->device, index++);
}
@@ -1168,7 +1162,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func)
* this function is for hot plug ADD!
*
* returns 0 if success
- */
+ */
int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_start)
{
u8 temp;
@@ -1187,10 +1181,10 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
rom_resource_table = detect_HRT_floating_pointer(rom_start, rom_start+0xffff);
dbg("rom_resource_table = %p\n", rom_resource_table);
- if (rom_resource_table == NULL) {
+ if (rom_resource_table == NULL)
return -ENODEV;
- }
- // Sum all resources and setup resource maps
+
+ /* Sum all resources and setup resource maps */
unused_IRQ = readl(rom_resource_table + UNUSED_IRQ);
dbg("unused_IRQ = %x\n", unused_IRQ);
@@ -1222,13 +1216,11 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
temp = 0;
- if (!cpqhp_nic_irq) {
+ if (!cpqhp_nic_irq)
cpqhp_nic_irq = ctrl->cfgspc_irq;
- }
- if (!cpqhp_disk_irq) {
+ if (!cpqhp_disk_irq)
cpqhp_disk_irq = ctrl->cfgspc_irq;
- }
dbg("cpqhp_disk_irq, cpqhp_nic_irq= %d, %d\n", cpqhp_disk_irq, cpqhp_nic_irq);
@@ -1262,13 +1254,13 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
dev_func, io_base, io_length, mem_base, mem_length, pre_mem_base, pre_mem_length,
primary_bus, secondary_bus, max_bus);
- // If this entry isn't for our controller's bus, ignore it
+ /* If this entry isn't for our controller's bus, ignore it */
if (primary_bus != ctrl->bus) {
i--;
one_slot += sizeof (struct slot_rt);
continue;
}
- // find out if this entry is for an occupied slot
+ /* find out if this entry is for an occupied slot */
ctrl->pci_bus->number = primary_bus;
pci_bus_read_config_dword (ctrl->pci_bus, dev_func, PCI_VENDOR_ID, &temp_dword);
dbg("temp_D_word = %x\n", temp_dword);
@@ -1282,13 +1274,13 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
func = cpqhp_slot_find(primary_bus, dev_func >> 3, index++);
}
- // If we can't find a match, skip this table entry
+ /* If we can't find a match, skip this table entry */
if (!func) {
i--;
one_slot += sizeof (struct slot_rt);
continue;
}
- // this may not work and shouldn't be used
+ /* this may not work and shouldn't be used */
if (secondary_bus != primary_bus)
bridged_slot = 1;
else
@@ -1301,7 +1293,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
}
- // If we've got a valid IO base, use it
+ /* If we've got a valid IO base, use it */
temp_dword = io_base + io_length;
@@ -1325,7 +1317,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
}
}
- // If we've got a valid memory base, use it
+ /* If we've got a valid memory base, use it */
temp_dword = mem_base + mem_length;
if ((mem_base) && (temp_dword < 0x10000)) {
mem_node = kmalloc(sizeof(*mem_node), GFP_KERNEL);
@@ -1348,8 +1340,9 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
}
}
- // If we've got a valid prefetchable memory base, and
- // the base + length isn't greater than 0xFFFF
+ /* If we've got a valid prefetchable memory base, and
+ * the base + length isn't greater than 0xFFFF
+ */
temp_dword = pre_mem_base + pre_mem_length;
if ((pre_mem_base) && (temp_dword < 0x10000)) {
p_mem_node = kmalloc(sizeof(*p_mem_node), GFP_KERNEL);
@@ -1372,9 +1365,10 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
}
}
- // If we've got a valid bus number, use it
- // The second condition is to ignore bus numbers on
- // populated slots that don't have PCI-PCI bridges
+ /* If we've got a valid bus number, use it
+ * The second condition is to ignore bus numbers on
+ * populated slots that don't have PCI-PCI bridges
+ */
if (secondary_bus && (secondary_bus != primary_bus)) {
bus_node = kmalloc(sizeof(*bus_node), GFP_KERNEL);
if (!bus_node)
@@ -1398,8 +1392,9 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
one_slot += sizeof (struct slot_rt);
}
- // If all of the following fail, we don't have any resources for
- // hot plug add
+ /* If all of the following fail, we don't have any resources for
+ * hot plug add
+ */
rc = 1;
rc &= cpqhp_resource_sort_and_combine(&(ctrl->mem_head));
rc &= cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head));
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index dd18f857dfb0..29ccb8a6da8a 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -1419,3 +1419,4 @@ static void __exit ibmphp_exit(void)
}
module_init(ibmphp_init);
+module_exit(ibmphp_exit);
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c
index 6808d8333ecc..737a1c44b07a 100644
--- a/drivers/pci/htirq.c
+++ b/drivers/pci/htirq.c
@@ -98,6 +98,7 @@ int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
int max_irq;
int pos;
int irq;
+ int node;
pos = pci_find_ht_capability(dev, HT_CAPTYPE_IRQ);
if (!pos)
@@ -125,7 +126,8 @@ int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
cfg->msg.address_lo = 0xffffffff;
cfg->msg.address_hi = 0xffffffff;
- irq = create_irq();
+ node = dev_to_node(&dev->dev);
+ irq = create_irq_nr(0, node);
if (irq <= 0) {
kfree(cfg);
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index a563fbe559d0..8cd4aacd0711 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -53,6 +53,8 @@
#define DEFAULT_DOMAIN_ADDRESS_WIDTH 48
+#define MAX_AGAW_WIDTH 64
+
#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1)
#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
@@ -131,8 +133,6 @@ static inline void context_set_fault_enable(struct context_entry *context)
context->lo &= (((u64)-1) << 2) | 1;
}
-#define CONTEXT_TT_MULTI_LEVEL 0
-
static inline void context_set_translation_type(struct context_entry *context,
unsigned long value)
{
@@ -401,17 +401,13 @@ void free_iova_mem(struct iova *iova)
static inline int width_to_agaw(int width);
-/* calculate agaw for each iommu.
- * "SAGAW" may be different across iommus, use a default agaw, and
- * get a supported less agaw for iommus that don't support the default agaw.
- */
-int iommu_calculate_agaw(struct intel_iommu *iommu)
+static int __iommu_calculate_agaw(struct intel_iommu *iommu, int max_gaw)
{
unsigned long sagaw;
int agaw = -1;
sagaw = cap_sagaw(iommu->cap);
- for (agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH);
+ for (agaw = width_to_agaw(max_gaw);
agaw >= 0; agaw--) {
if (test_bit(agaw, &sagaw))
break;
@@ -420,6 +416,24 @@ int iommu_calculate_agaw(struct intel_iommu *iommu)
return agaw;
}
+/*
+ * Calculate max SAGAW for each iommu.
+ */
+int iommu_calculate_max_sagaw(struct intel_iommu *iommu)
+{
+ return __iommu_calculate_agaw(iommu, MAX_AGAW_WIDTH);
+}
+
+/*
+ * calculate agaw for each iommu.
+ * "SAGAW" may be different across iommus, use a default agaw, and
+ * get a supported less agaw for iommus that don't support the default agaw.
+ */
+int iommu_calculate_agaw(struct intel_iommu *iommu)
+{
+ return __iommu_calculate_agaw(iommu, DEFAULT_DOMAIN_ADDRESS_WIDTH);
+}
+
/* in native case, each domain is related to only one iommu */
static struct intel_iommu *domain_get_iommu(struct dmar_domain *domain)
{
@@ -809,7 +823,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu)
static void iommu_set_root_entry(struct intel_iommu *iommu)
{
void *addr;
- u32 cmd, sts;
+ u32 sts;
unsigned long flag;
addr = iommu->root_entry;
@@ -817,12 +831,11 @@ static void iommu_set_root_entry(struct intel_iommu *iommu)
spin_lock_irqsave(&iommu->register_lock, flag);
dmar_writeq(iommu->reg + DMAR_RTADDR_REG, virt_to_phys(addr));
- cmd = iommu->gcmd | DMA_GCMD_SRTP;
- writel(cmd, iommu->reg + DMAR_GCMD_REG);
+ writel(iommu->gcmd | DMA_GCMD_SRTP, iommu->reg + DMAR_GCMD_REG);
/* Make sure hardware complete it */
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
- readl, (sts & DMA_GSTS_RTPS), sts);
+ readl, (sts & DMA_GSTS_RTPS), sts);
spin_unlock_irqrestore(&iommu->register_lock, flag);
}
@@ -834,39 +847,25 @@ static void iommu_flush_write_buffer(struct intel_iommu *iommu)
if (!rwbf_quirk && !cap_rwbf(iommu->cap))
return;
- val = iommu->gcmd | DMA_GCMD_WBF;
spin_lock_irqsave(&iommu->register_lock, flag);
- writel(val, iommu->reg + DMAR_GCMD_REG);
+ writel(iommu->gcmd | DMA_GCMD_WBF, iommu->reg + DMAR_GCMD_REG);
/* Make sure hardware complete it */
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
- readl, (!(val & DMA_GSTS_WBFS)), val);
+ readl, (!(val & DMA_GSTS_WBFS)), val);
spin_unlock_irqrestore(&iommu->register_lock, flag);
}
/* return value determine if we need a write buffer flush */
-static int __iommu_flush_context(struct intel_iommu *iommu,
- u16 did, u16 source_id, u8 function_mask, u64 type,
- int non_present_entry_flush)
+static void __iommu_flush_context(struct intel_iommu *iommu,
+ u16 did, u16 source_id, u8 function_mask,
+ u64 type)
{
u64 val = 0;
unsigned long flag;
- /*
- * In the non-present entry flush case, if hardware doesn't cache
- * non-present entry we do nothing and if hardware cache non-present
- * entry, we flush entries of domain 0 (the domain id is used to cache
- * any non-present entries)
- */
- if (non_present_entry_flush) {
- if (!cap_caching_mode(iommu->cap))
- return 1;
- else
- did = 0;
- }
-
switch (type) {
case DMA_CCMD_GLOBAL_INVL:
val = DMA_CCMD_GLOBAL_INVL;
@@ -891,33 +890,16 @@ static int __iommu_flush_context(struct intel_iommu *iommu,
dmar_readq, (!(val & DMA_CCMD_ICC)), val);
spin_unlock_irqrestore(&iommu->register_lock, flag);
-
- /* flush context entry will implicitly flush write buffer */
- return 0;
}
/* return value determine if we need a write buffer flush */
-static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did,
- u64 addr, unsigned int size_order, u64 type,
- int non_present_entry_flush)
+static void __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did,
+ u64 addr, unsigned int size_order, u64 type)
{
int tlb_offset = ecap_iotlb_offset(iommu->ecap);
u64 val = 0, val_iva = 0;
unsigned long flag;
- /*
- * In the non-present entry flush case, if hardware doesn't cache
- * non-present entry we do nothing and if hardware cache non-present
- * entry, we flush entries of domain 0 (the domain id is used to cache
- * any non-present entries)
- */
- if (non_present_entry_flush) {
- if (!cap_caching_mode(iommu->cap))
- return 1;
- else
- did = 0;
- }
-
switch (type) {
case DMA_TLB_GLOBAL_FLUSH:
/* global flush doesn't need set IVA_REG */
@@ -965,12 +947,10 @@ static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did,
pr_debug("IOMMU: tlb flush request %Lx, actual %Lx\n",
(unsigned long long)DMA_TLB_IIRG(type),
(unsigned long long)DMA_TLB_IAIG(val));
- /* flush iotlb entry will implicitly flush write buffer */
- return 0;
}
-static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
- u64 addr, unsigned int pages, int non_present_entry_flush)
+static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
+ u64 addr, unsigned int pages)
{
unsigned int mask;
@@ -980,8 +960,7 @@ static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
/* Fallback to domain selective flush if no PSI support */
if (!cap_pgsel_inv(iommu->cap))
return iommu->flush.flush_iotlb(iommu, did, 0, 0,
- DMA_TLB_DSI_FLUSH,
- non_present_entry_flush);
+ DMA_TLB_DSI_FLUSH);
/*
* PSI requires page size to be 2 ^ x, and the base address is naturally
@@ -991,11 +970,10 @@ static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
/* Fallback to domain selective flush if size is too big */
if (mask > cap_max_amask_val(iommu->cap))
return iommu->flush.flush_iotlb(iommu, did, 0, 0,
- DMA_TLB_DSI_FLUSH, non_present_entry_flush);
+ DMA_TLB_DSI_FLUSH);
return iommu->flush.flush_iotlb(iommu, did, addr, mask,
- DMA_TLB_PSI_FLUSH,
- non_present_entry_flush);
+ DMA_TLB_PSI_FLUSH);
}
static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)
@@ -1021,13 +999,13 @@ static int iommu_enable_translation(struct intel_iommu *iommu)
unsigned long flags;
spin_lock_irqsave(&iommu->register_lock, flags);
- writel(iommu->gcmd|DMA_GCMD_TE, iommu->reg + DMAR_GCMD_REG);
+ iommu->gcmd |= DMA_GCMD_TE;
+ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
/* Make sure hardware complete it */
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
- readl, (sts & DMA_GSTS_TES), sts);
+ readl, (sts & DMA_GSTS_TES), sts);
- iommu->gcmd |= DMA_GCMD_TE;
spin_unlock_irqrestore(&iommu->register_lock, flags);
return 0;
}
@@ -1043,7 +1021,7 @@ static int iommu_disable_translation(struct intel_iommu *iommu)
/* Make sure hardware complete it */
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
- readl, (!(sts & DMA_GSTS_TES)), sts);
+ readl, (!(sts & DMA_GSTS_TES)), sts);
spin_unlock_irqrestore(&iommu->register_lock, flag);
return 0;
@@ -1325,8 +1303,8 @@ static void domain_exit(struct dmar_domain *domain)
free_domain_mem(domain);
}
-static int domain_context_mapping_one(struct dmar_domain *domain,
- int segment, u8 bus, u8 devfn)
+static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
+ u8 bus, u8 devfn, int translation)
{
struct context_entry *context;
unsigned long flags;
@@ -1339,7 +1317,10 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
pr_debug("Set context mapping for %02x:%02x.%d\n",
bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+
BUG_ON(!domain->pgd);
+ BUG_ON(translation != CONTEXT_TT_PASS_THROUGH &&
+ translation != CONTEXT_TT_MULTI_LEVEL);
iommu = device_to_iommu(segment, bus, devfn);
if (!iommu)
@@ -1399,21 +1380,37 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
}
context_set_domain_id(context, id);
- context_set_address_width(context, iommu->agaw);
- context_set_address_root(context, virt_to_phys(pgd));
- context_set_translation_type(context, CONTEXT_TT_MULTI_LEVEL);
+
+ /*
+ * In pass through mode, AW must be programmed to indicate the largest
+ * AGAW value supported by hardware. And ASR is ignored by hardware.
+ */
+ if (likely(translation == CONTEXT_TT_MULTI_LEVEL)) {
+ context_set_address_width(context, iommu->agaw);
+ context_set_address_root(context, virt_to_phys(pgd));
+ } else
+ context_set_address_width(context, iommu->msagaw);
+
+ context_set_translation_type(context, translation);
context_set_fault_enable(context);
context_set_present(context);
domain_flush_cache(domain, context, sizeof(*context));
- /* it's a non-present to present mapping */
- if (iommu->flush.flush_context(iommu, domain->id,
- (((u16)bus) << 8) | devfn, DMA_CCMD_MASK_NOBIT,
- DMA_CCMD_DEVICE_INVL, 1))
+ /*
+ * It's a non-present to present mapping. If hardware doesn't cache
+ * non-present entry we only need to flush the write-buffer. If the
+ * _does_ cache non-present entries, then it does so in the special
+ * domain #0, which we have to flush:
+ */
+ if (cap_caching_mode(iommu->cap)) {
+ iommu->flush.flush_context(iommu, 0,
+ (((u16)bus) << 8) | devfn,
+ DMA_CCMD_MASK_NOBIT,
+ DMA_CCMD_DEVICE_INVL);
+ iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH);
+ } else {
iommu_flush_write_buffer(iommu);
- else
- iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0);
-
+ }
spin_unlock_irqrestore(&iommu->lock, flags);
spin_lock_irqsave(&domain->iommu_lock, flags);
@@ -1426,13 +1423,15 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
}
static int
-domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev)
+domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev,
+ int translation)
{
int ret;
struct pci_dev *tmp, *parent;
ret = domain_context_mapping_one(domain, pci_domain_nr(pdev->bus),
- pdev->bus->number, pdev->devfn);
+ pdev->bus->number, pdev->devfn,
+ translation);
if (ret)
return ret;
@@ -1446,7 +1445,7 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev)
ret = domain_context_mapping_one(domain,
pci_domain_nr(parent->bus),
parent->bus->number,
- parent->devfn);
+ parent->devfn, translation);
if (ret)
return ret;
parent = parent->bus->self;
@@ -1454,12 +1453,14 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev)
if (tmp->is_pcie) /* this is a PCIE-to-PCI bridge */
return domain_context_mapping_one(domain,
pci_domain_nr(tmp->subordinate),
- tmp->subordinate->number, 0);
+ tmp->subordinate->number, 0,
+ translation);
else /* this is a legacy PCI bridge */
return domain_context_mapping_one(domain,
pci_domain_nr(tmp->bus),
tmp->bus->number,
- tmp->devfn);
+ tmp->devfn,
+ translation);
}
static int domain_context_mapped(struct pci_dev *pdev)
@@ -1540,9 +1541,8 @@ static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn)
clear_context_table(iommu, bus, devfn);
iommu->flush.flush_context(iommu, 0, 0, 0,
- DMA_CCMD_GLOBAL_INVL, 0);
- iommu->flush.flush_iotlb(iommu, 0, 0, 0,
- DMA_TLB_GLOBAL_FLUSH, 0);
+ DMA_CCMD_GLOBAL_INVL);
+ iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH);
}
static void domain_remove_dev_info(struct dmar_domain *domain)
@@ -1756,7 +1756,7 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev,
goto error;
/* context entry init */
- ret = domain_context_mapping(domain, pdev);
+ ret = domain_context_mapping(domain, pdev, CONTEXT_TT_MULTI_LEVEL);
if (!ret)
return 0;
error:
@@ -1857,6 +1857,23 @@ static inline void iommu_prepare_isa(void)
}
#endif /* !CONFIG_DMAR_FLPY_WA */
+/* Initialize each context entry as pass through.*/
+static int __init init_context_pass_through(void)
+{
+ struct pci_dev *pdev = NULL;
+ struct dmar_domain *domain;
+ int ret;
+
+ for_each_pci_dev(pdev) {
+ domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH);
+ ret = domain_context_mapping(domain, pdev,
+ CONTEXT_TT_PASS_THROUGH);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
static int __init init_dmars(void)
{
struct dmar_drhd_unit *drhd;
@@ -1864,6 +1881,7 @@ static int __init init_dmars(void)
struct pci_dev *pdev;
struct intel_iommu *iommu;
int i, ret;
+ int pass_through = 1;
/*
* for each drhd
@@ -1917,7 +1935,15 @@ static int __init init_dmars(void)
printk(KERN_ERR "IOMMU: allocate root entry failed\n");
goto error;
}
+ if (!ecap_pass_through(iommu->ecap))
+ pass_through = 0;
}
+ if (iommu_pass_through)
+ if (!pass_through) {
+ printk(KERN_INFO
+ "Pass Through is not supported by hardware.\n");
+ iommu_pass_through = 0;
+ }
/*
* Start from the sane iommu hardware state.
@@ -1972,45 +1998,57 @@ static int __init init_dmars(void)
}
}
-#ifdef CONFIG_INTR_REMAP
- if (!intr_remapping_enabled) {
- ret = enable_intr_remapping(0);
- if (ret)
- printk(KERN_ERR
- "IOMMU: enable interrupt remapping failed\n");
+ /*
+ * If pass through is set and enabled, context entries of all pci
+ * devices are intialized by pass through translation type.
+ */
+ if (iommu_pass_through) {
+ ret = init_context_pass_through();
+ if (ret) {
+ printk(KERN_ERR "IOMMU: Pass through init failed.\n");
+ iommu_pass_through = 0;
+ }
}
-#endif
/*
- * For each rmrr
- * for each dev attached to rmrr
- * do
- * locate drhd for dev, alloc domain for dev
- * allocate free domain
- * allocate page table entries for rmrr
- * if context not allocated for bus
- * allocate and init context
- * set present in root table for this bus
- * init context with domain, translation etc
- * endfor
- * endfor
+ * If pass through is not set or not enabled, setup context entries for
+ * identity mappings for rmrr, gfx, and isa.
*/
- for_each_rmrr_units(rmrr) {
- for (i = 0; i < rmrr->devices_cnt; i++) {
- pdev = rmrr->devices[i];
- /* some BIOS lists non-exist devices in DMAR table */
- if (!pdev)
- continue;
- ret = iommu_prepare_rmrr_dev(rmrr, pdev);
- if (ret)
- printk(KERN_ERR
+ if (!iommu_pass_through) {
+ /*
+ * For each rmrr
+ * for each dev attached to rmrr
+ * do
+ * locate drhd for dev, alloc domain for dev
+ * allocate free domain
+ * allocate page table entries for rmrr
+ * if context not allocated for bus
+ * allocate and init context
+ * set present in root table for this bus
+ * init context with domain, translation etc
+ * endfor
+ * endfor
+ */
+ for_each_rmrr_units(rmrr) {
+ for (i = 0; i < rmrr->devices_cnt; i++) {
+ pdev = rmrr->devices[i];
+ /*
+ * some BIOS lists non-exist devices in DMAR
+ * table.
+ */
+ if (!pdev)
+ continue;
+ ret = iommu_prepare_rmrr_dev(rmrr, pdev);
+ if (ret)
+ printk(KERN_ERR
"IOMMU: mapping reserved region failed\n");
+ }
}
- }
- iommu_prepare_gfx_mapping();
+ iommu_prepare_gfx_mapping();
- iommu_prepare_isa();
+ iommu_prepare_isa();
+ }
/*
* for each drhd
@@ -2032,10 +2070,8 @@ static int __init init_dmars(void)
iommu_set_root_entry(iommu);
- iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL,
- 0);
- iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH,
- 0);
+ iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL);
+ iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH);
iommu_disable_protect_mem_regions(iommu);
ret = iommu_enable_translation(iommu);
@@ -2121,7 +2157,8 @@ get_valid_domain_for_dev(struct pci_dev *pdev)
/* make sure context mapping is ok */
if (unlikely(!domain_context_mapped(pdev))) {
- ret = domain_context_mapping(domain, pdev);
+ ret = domain_context_mapping(domain, pdev,
+ CONTEXT_TT_MULTI_LEVEL);
if (ret) {
printk(KERN_ERR
"Domain context map for %s failed",
@@ -2182,10 +2219,11 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
if (ret)
goto error;
- /* it's a non-present to present mapping */
- ret = iommu_flush_iotlb_psi(iommu, domain->id,
- start_paddr, size >> VTD_PAGE_SHIFT, 1);
- if (ret)
+ /* it's a non-present to present mapping. Only flush if caching mode */
+ if (cap_caching_mode(iommu->cap))
+ iommu_flush_iotlb_psi(iommu, 0, start_paddr,
+ size >> VTD_PAGE_SHIFT);
+ else
iommu_flush_write_buffer(iommu);
return start_paddr + ((u64)paddr & (~PAGE_MASK));
@@ -2221,7 +2259,7 @@ static void flush_unmaps(void)
if (deferred_flush[i].next) {
iommu->flush.flush_iotlb(iommu, 0, 0, 0,
- DMA_TLB_GLOBAL_FLUSH, 0);
+ DMA_TLB_GLOBAL_FLUSH);
for (j = 0; j < deferred_flush[i].next; j++) {
__free_iova(&deferred_flush[i].domain[j]->iovad,
deferred_flush[i].iova[j]);
@@ -2300,9 +2338,8 @@ static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
/* free page tables */
dma_pte_free_pagetable(domain, start_addr, start_addr + size);
if (intel_iommu_strict) {
- if (iommu_flush_iotlb_psi(iommu,
- domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0))
- iommu_flush_write_buffer(iommu);
+ iommu_flush_iotlb_psi(iommu, domain->id, start_addr,
+ size >> VTD_PAGE_SHIFT);
/* free iova */
__free_iova(&domain->iovad, iova);
} else {
@@ -2393,9 +2430,8 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
/* free page tables */
dma_pte_free_pagetable(domain, start_addr, start_addr + size);
- if (iommu_flush_iotlb_psi(iommu, domain->id, start_addr,
- size >> VTD_PAGE_SHIFT, 0))
- iommu_flush_write_buffer(iommu);
+ iommu_flush_iotlb_psi(iommu, domain->id, start_addr,
+ size >> VTD_PAGE_SHIFT);
/* free iova */
__free_iova(&domain->iovad, iova);
@@ -2487,10 +2523,13 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
offset += size;
}
- /* it's a non-present to present mapping */
- if (iommu_flush_iotlb_psi(iommu, domain->id,
- start_addr, offset >> VTD_PAGE_SHIFT, 1))
+ /* it's a non-present to present mapping. Only flush if caching mode */
+ if (cap_caching_mode(iommu->cap))
+ iommu_flush_iotlb_psi(iommu, 0, start_addr,
+ offset >> VTD_PAGE_SHIFT);
+ else
iommu_flush_write_buffer(iommu);
+
return nelems;
}
@@ -2649,9 +2688,9 @@ static int init_iommu_hw(void)
iommu_set_root_entry(iommu);
iommu->flush.flush_context(iommu, 0, 0, 0,
- DMA_CCMD_GLOBAL_INVL, 0);
+ DMA_CCMD_GLOBAL_INVL);
iommu->flush.flush_iotlb(iommu, 0, 0, 0,
- DMA_TLB_GLOBAL_FLUSH, 0);
+ DMA_TLB_GLOBAL_FLUSH);
iommu_disable_protect_mem_regions(iommu);
iommu_enable_translation(iommu);
}
@@ -2666,9 +2705,9 @@ static void iommu_flush_all(void)
for_each_active_iommu(iommu, drhd) {
iommu->flush.flush_context(iommu, 0, 0, 0,
- DMA_CCMD_GLOBAL_INVL, 0);
+ DMA_CCMD_GLOBAL_INVL);
iommu->flush.flush_iotlb(iommu, 0, 0, 0,
- DMA_TLB_GLOBAL_FLUSH, 0);
+ DMA_TLB_GLOBAL_FLUSH);
}
}
@@ -2791,7 +2830,7 @@ int __init intel_iommu_init(void)
* Check the need for DMA-remapping initialization now.
* Above initialization will also be used by Interrupt-remapping.
*/
- if (no_iommu || swiotlb || dmar_disabled)
+ if (no_iommu || (swiotlb && !iommu_pass_through) || dmar_disabled)
return -ENODEV;
iommu_init_mempool();
@@ -2811,7 +2850,15 @@ int __init intel_iommu_init(void)
init_timer(&unmap_timer);
force_iommu = 1;
- dma_ops = &intel_dma_ops;
+
+ if (!iommu_pass_through) {
+ printk(KERN_INFO
+ "Multi-level page-table translation for DMAR.\n");
+ dma_ops = &intel_dma_ops;
+ } else
+ printk(KERN_INFO
+ "DMAR: Pass through translation for DMAR.\n");
+
init_iommu_sysfs();
register_iommu(&intel_iommu_ops);
@@ -3151,7 +3198,7 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
return -EFAULT;
}
- ret = domain_context_mapping(dmar_domain, pdev);
+ ret = domain_context_mapping(dmar_domain, pdev, CONTEXT_TT_MULTI_LEVEL);
if (ret)
return ret;
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c
index f5e0ea724a6f..1e83c8c5f985 100644
--- a/drivers/pci/intr_remapping.c
+++ b/drivers/pci/intr_remapping.c
@@ -15,6 +15,14 @@ static struct ioapic_scope ir_ioapic[MAX_IO_APICS];
static int ir_ioapic_num;
int intr_remapping_enabled;
+static int disable_intremap;
+static __init int setup_nointremap(char *str)
+{
+ disable_intremap = 1;
+ return 0;
+}
+early_param("nointremap", setup_nointremap);
+
struct irq_2_iommu {
struct intel_iommu *iommu;
u16 irte_index;
@@ -23,15 +31,12 @@ struct irq_2_iommu {
};
#ifdef CONFIG_GENERIC_HARDIRQS
-static struct irq_2_iommu *get_one_free_irq_2_iommu(int cpu)
+static struct irq_2_iommu *get_one_free_irq_2_iommu(int node)
{
struct irq_2_iommu *iommu;
- int node;
-
- node = cpu_to_node(cpu);
iommu = kzalloc_node(sizeof(*iommu), GFP_ATOMIC, node);
- printk(KERN_DEBUG "alloc irq_2_iommu on cpu %d node %d\n", cpu, node);
+ printk(KERN_DEBUG "alloc irq_2_iommu on node %d\n", node);
return iommu;
}
@@ -48,7 +53,7 @@ static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
return desc->irq_2_iommu;
}
-static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu)
+static struct irq_2_iommu *irq_2_iommu_alloc_node(unsigned int irq, int node)
{
struct irq_desc *desc;
struct irq_2_iommu *irq_iommu;
@@ -56,7 +61,7 @@ static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu)
/*
* alloc irq desc if not allocated already.
*/
- desc = irq_to_desc_alloc_cpu(irq, cpu);
+ desc = irq_to_desc_alloc_node(irq, node);
if (!desc) {
printk(KERN_INFO "can not get irq_desc for %d\n", irq);
return NULL;
@@ -65,14 +70,14 @@ static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu)
irq_iommu = desc->irq_2_iommu;
if (!irq_iommu)
- desc->irq_2_iommu = get_one_free_irq_2_iommu(cpu);
+ desc->irq_2_iommu = get_one_free_irq_2_iommu(node);
return desc->irq_2_iommu;
}
static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq)
{
- return irq_2_iommu_alloc_cpu(irq, boot_cpu_id);
+ return irq_2_iommu_alloc_node(irq, cpu_to_node(boot_cpu_id));
}
#else /* !CONFIG_SPARSE_IRQ */
@@ -404,7 +409,7 @@ int free_irte(int irq)
static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode)
{
u64 addr;
- u32 cmd, sts;
+ u32 sts;
unsigned long flags;
addr = virt_to_phys((void *)iommu->ir_table->base);
@@ -415,28 +420,13 @@ static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode)
(addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE);
/* Set interrupt-remapping table pointer */
- cmd = iommu->gcmd | DMA_GCMD_SIRTP;
iommu->gcmd |= DMA_GCMD_SIRTP;
- writel(cmd, iommu->reg + DMAR_GCMD_REG);
+ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
readl, (sts & DMA_GSTS_IRTPS), sts);
spin_unlock_irqrestore(&iommu->register_lock, flags);
- if (mode == 0) {
- spin_lock_irqsave(&iommu->register_lock, flags);
-
- /* enable comaptiblity format interrupt pass through */
- cmd = iommu->gcmd | DMA_GCMD_CFI;
- iommu->gcmd |= DMA_GCMD_CFI;
- writel(cmd, iommu->reg + DMAR_GCMD_REG);
-
- IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
- readl, (sts & DMA_GSTS_CFIS), sts);
-
- spin_unlock_irqrestore(&iommu->register_lock, flags);
- }
-
/*
* global invalidation of interrupt entry cache before enabling
* interrupt-remapping.
@@ -446,9 +436,8 @@ static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode)
spin_lock_irqsave(&iommu->register_lock, flags);
/* Enable interrupt-remapping */
- cmd = iommu->gcmd | DMA_GCMD_IRE;
iommu->gcmd |= DMA_GCMD_IRE;
- writel(cmd, iommu->reg + DMAR_GCMD_REG);
+ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
readl, (sts & DMA_GSTS_IRES), sts);
@@ -516,6 +505,23 @@ end:
spin_unlock_irqrestore(&iommu->register_lock, flags);
}
+int __init intr_remapping_supported(void)
+{
+ struct dmar_drhd_unit *drhd;
+
+ if (disable_intremap)
+ return 0;
+
+ for_each_drhd_unit(drhd) {
+ struct intel_iommu *iommu = drhd->iommu;
+
+ if (!ecap_ir_support(iommu->ecap))
+ return 0;
+ }
+
+ return 1;
+}
+
int __init enable_intr_remapping(int eim)
{
struct dmar_drhd_unit *drhd;
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 362773247fbf..7ffac27d5d4a 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -381,7 +381,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */
entry->msi_attrib.pos = pos;
- entry->mask_pos = msi_mask_bits_reg(pos, entry->msi_attrib.is_64);
+ entry->mask_pos = msi_mask_reg(pos, entry->msi_attrib.is_64);
/* All MSIs are unmasked by default, Mask them all */
if (entry->msi_attrib.maskbit)
pci_read_config_dword(dev, entry->mask_pos, &entry->masked);
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h
index 71f4df2ef654..a0662842550b 100644
--- a/drivers/pci/msi.h
+++ b/drivers/pci/msi.h
@@ -16,21 +16,15 @@
#define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO)
#define msi_upper_address_reg(base) (base + PCI_MSI_ADDRESS_HI)
#define msi_data_reg(base, is64bit) \
- ( (is64bit == 1) ? base+PCI_MSI_DATA_64 : base+PCI_MSI_DATA_32 )
-#define msi_mask_bits_reg(base, is64bit) \
- ( (is64bit == 1) ? base+PCI_MSI_MASK_BIT : base+PCI_MSI_MASK_BIT-4)
-#define msi_disable(control) control &= ~PCI_MSI_FLAGS_ENABLE
+ (base + ((is64bit == 1) ? PCI_MSI_DATA_64 : PCI_MSI_DATA_32))
+#define msi_mask_reg(base, is64bit) \
+ (base + ((is64bit == 1) ? PCI_MSI_MASK_64 : PCI_MSI_MASK_32))
#define is_64bit_address(control) (!!(control & PCI_MSI_FLAGS_64BIT))
#define is_mask_bit_support(control) (!!(control & PCI_MSI_FLAGS_MASKBIT))
#define msix_table_offset_reg(base) (base + 0x04)
#define msix_pba_offset_reg(base) (base + 0x08)
-#define msix_enable(control) control |= PCI_MSIX_FLAGS_ENABLE
-#define msix_disable(control) control &= ~PCI_MSIX_FLAGS_ENABLE
#define msix_table_size(control) ((control & PCI_MSIX_FLAGS_QSIZE)+1)
-#define multi_msix_capable msix_table_size
-#define msix_unmask(address) (address & ~PCI_MSIX_FLAGS_BITMASK)
-#define msix_mask(address) (address | PCI_MSIX_FLAGS_BITMASK)
-#define msix_is_pending(address) (address & PCI_MSIX_FLAGS_PENDMASK)
+#define multi_msix_capable(control) msix_table_size((control))
#endif /* MSI_H */
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 34bf0fdf5047..07bbb9b3b93f 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -24,6 +24,11 @@
#include <asm/setup.h>
#include "pci.h"
+const char *pci_power_names[] = {
+ "error", "D0", "D1", "D2", "D3hot", "D3cold", "unknown",
+};
+EXPORT_SYMBOL_GPL(pci_power_names);
+
unsigned int pci_pm_d3_delay = PCI_PM_D3_WAIT;
#ifdef CONFIG_PCI_DOMAINS
@@ -557,7 +562,8 @@ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
} else {
error = -ENODEV;
/* Fall back to PCI_D0 if native PM is not supported */
- pci_update_current_state(dev, PCI_D0);
+ if (!dev->pm_cap)
+ dev->current_state = PCI_D0;
}
return error;
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index e39982503863..13ffdc35ea0e 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -275,7 +275,7 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
memset(device, 0, sizeof(struct device));
device->bus = &pcie_port_bus_type;
device->driver = NULL;
- device->driver_data = NULL;
+ dev_set_drvdata(device, NULL);
device->release = release_pcie_device; /* callback to free pcie dev */
dev_set_name(device, "%s:pcie%02x",
pci_name(parent), get_descriptor_id(port_type, service_type));
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e3c3e081b834..3daa7f824da1 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -193,7 +193,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN;
if (type == pci_bar_io) {
l &= PCI_BASE_ADDRESS_IO_MASK;
- mask = PCI_BASE_ADDRESS_IO_MASK & 0xffff;
+ mask = PCI_BASE_ADDRESS_IO_MASK & IO_SPACE_LIMIT;
} else {
l &= PCI_BASE_ADDRESS_MEM_MASK;
mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
@@ -237,6 +237,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
dev_printk(KERN_DEBUG, &dev->dev,
"reg %x 64bit mmio: %pR\n", pos, res);
}
+
+ res->flags |= IORESOURCE_MEM_64;
} else {
sz = pci_size(l, sz, mask);
@@ -362,7 +364,10 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
}
}
if (base <= limit) {
- res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH;
+ res->flags = (mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) |
+ IORESOURCE_MEM | IORESOURCE_PREFETCH;
+ if (res->flags & PCI_PREF_RANGE_TYPE_64)
+ res->flags |= IORESOURCE_MEM_64;
res->start = base;
res->end = limit + 0xfffff;
dev_printk(KERN_DEBUG, &dev->dev, "bridge %sbit mmio pref: %pR\n",
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3067673d54f6..17cdf2fc951b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2461,9 +2461,35 @@ static void __devinit quirk_i82576_sriov(struct pci_dev *dev)
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10c9, quirk_i82576_sriov);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e6, quirk_i82576_sriov);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e7, quirk_i82576_sriov);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e8, quirk_i82576_sriov);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150a, quirk_i82576_sriov);
#endif /* CONFIG_PCI_IOV */
+#if defined CONFIG_X86 && (defined CONFIG_HWMON || defined CONFIG_HWMON_MODULE)
+/* Open access to 0x295-0x296 (hardware monitoring chip) on MSI MS-7031 */
+static void __devinit ati_ixp300_open_ioport(struct pci_dev *dev)
+{
+ u16 base;
+ u8 enable;
+
+ if (!(dev->subsystem_vendor == 0x1462 && /* MSI */
+ dev->subsystem_device == 0x0031)) /* MS-7031 */
+ return;
+
+ pci_read_config_byte(dev, 0x48, &enable);
+ pci_read_config_word(dev, 0x64, &base);
+
+ if (base == 0 && !(enable & BIT(2))) {
+ dev_info(&dev->dev, "Opening wide generic port at 0x295\n");
+ pci_write_config_word(dev, 0x64, 0x295);
+ pci_write_config_byte(dev, 0x48, enable | BIT(2));
+ }
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, 0x436c, ati_ixp300_open_ioport);
+#endif /* CONFIG_X86 && CONFIG_HWMON */
+
static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
struct pci_fixup *end)
{
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 710d4ea69568..650bc0a538dc 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -115,36 +115,6 @@ pci_find_next_bus(const struct pci_bus *from)
#ifdef CONFIG_PCI_LEGACY
/**
- * pci_find_slot - locate PCI device from a given PCI slot
- * @bus: number of PCI bus on which desired PCI device resides
- * @devfn: encodes number of PCI slot in which the desired PCI
- * device resides and the logical device number within that slot
- * in case of multi-function devices.
- *
- * Given a PCI bus and slot/function number, the desired PCI device
- * is located in system global list of PCI devices. If the device
- * is found, a pointer to its data structure is returned. If no
- * device is found, %NULL is returned.
- *
- * NOTE: Do not use this function any more; use pci_get_slot() instead, as
- * the PCI device returned by this function can disappear at any moment in
- * time.
- */
-struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn)
-{
- struct pci_dev *dev = NULL;
-
- while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
- if (dev->bus->number == bus && dev->devfn == devfn) {
- pci_dev_put(dev);
- return dev;
- }
- }
- return NULL;
-}
-EXPORT_SYMBOL(pci_find_slot);
-
-/**
* pci_find_device - begin or continue searching for a PCI device by vendor/device id
* @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
* @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index a00f85471b6e..b636e245445d 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -58,7 +58,6 @@ static void pbus_assign_resources_sorted(const struct pci_bus *bus)
res = list->res;
idx = res - &list->dev->resource[0];
if (pci_assign_resource(list->dev, idx)) {
- /* FIXME: get rid of this */
res->start = 0;
res->end = 0;
res->flags = 0;
@@ -143,6 +142,7 @@ static void pci_setup_bridge(struct pci_bus *bus)
struct pci_dev *bridge = bus->self;
struct pci_bus_region region;
u32 l, bu, lu, io_upper16;
+ int pref_mem64;
if (pci_is_enabled(bridge))
return;
@@ -198,16 +198,22 @@ static void pci_setup_bridge(struct pci_bus *bus)
pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, 0);
/* Set up PREF base/limit. */
+ pref_mem64 = 0;
bu = lu = 0;
pcibios_resource_to_bus(bridge, &region, bus->resource[2]);
if (bus->resource[2]->flags & IORESOURCE_PREFETCH) {
+ int width = 8;
l = (region.start >> 16) & 0xfff0;
l |= region.end & 0xfff00000;
- bu = upper_32_bits(region.start);
- lu = upper_32_bits(region.end);
- dev_info(&bridge->dev, " PREFETCH window: %#016llx-%#016llx\n",
- (unsigned long long)region.start,
- (unsigned long long)region.end);
+ if (bus->resource[2]->flags & IORESOURCE_MEM_64) {
+ pref_mem64 = 1;
+ bu = upper_32_bits(region.start);
+ lu = upper_32_bits(region.end);
+ width = 16;
+ }
+ dev_info(&bridge->dev, " PREFETCH window: %#0*llx-%#0*llx\n",
+ width, (unsigned long long)region.start,
+ width, (unsigned long long)region.end);
}
else {
l = 0x0000fff0;
@@ -215,9 +221,11 @@ static void pci_setup_bridge(struct pci_bus *bus)
}
pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, l);
- /* Set the upper 32 bits of PREF base & limit. */
- pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, bu);
- pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, lu);
+ if (pref_mem64) {
+ /* Set the upper 32 bits of PREF base & limit. */
+ pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, bu);
+ pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, lu);
+ }
pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bus->bridge_ctl);
}
@@ -255,8 +263,25 @@ static void pci_bridge_check_ranges(struct pci_bus *bus)
pci_read_config_dword(bridge, PCI_PREF_MEMORY_BASE, &pmem);
pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, 0x0);
}
- if (pmem)
+ if (pmem) {
b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH;
+ if ((pmem & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64)
+ b_res[2].flags |= IORESOURCE_MEM_64;
+ }
+
+ /* double check if bridge does support 64 bit pref */
+ if (b_res[2].flags & IORESOURCE_MEM_64) {
+ u32 mem_base_hi, tmp;
+ pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32,
+ &mem_base_hi);
+ pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32,
+ 0xffffffff);
+ pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32, &tmp);
+ if (!tmp)
+ b_res[2].flags &= ~IORESOURCE_MEM_64;
+ pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32,
+ mem_base_hi);
+ }
}
/* Helper function for sizing routines: find first available
@@ -336,6 +361,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
resource_size_t aligns[12]; /* Alignments from 1Mb to 2Gb */
int order, max_order;
struct resource *b_res = find_free_bus_resource(bus, type);
+ unsigned int mem64_mask = 0;
if (!b_res)
return 0;
@@ -344,9 +370,12 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
max_order = 0;
size = 0;
+ mem64_mask = b_res->flags & IORESOURCE_MEM_64;
+ b_res->flags &= ~IORESOURCE_MEM_64;
+
list_for_each_entry(dev, &bus->devices, bus_list) {
int i;
-
+
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
resource_size_t r_size;
@@ -372,6 +401,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
aligns[order] += align;
if (order > max_order)
max_order = order;
+ mem64_mask &= r->flags & IORESOURCE_MEM_64;
}
}
@@ -396,6 +426,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
b_res->start = min_align;
b_res->end = size + min_align - 1;
b_res->flags |= IORESOURCE_STARTALIGN;
+ b_res->flags |= mem64_mask;
return 1;
}
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 3039fcb86afc..0b6908b48935 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -135,23 +135,16 @@ void pci_disable_bridge_window(struct pci_dev *dev)
}
#endif /* CONFIG_PCI_QUIRKS */
-int pci_assign_resource(struct pci_dev *dev, int resno)
+static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
+ int resno)
{
- struct pci_bus *bus = dev->bus;
struct resource *res = dev->resource + resno;
resource_size_t size, min, align;
int ret;
size = resource_size(res);
min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM;
-
align = resource_alignment(res);
- if (!align) {
- dev_info(&dev->dev, "BAR %d: can't allocate resource (bogus "
- "alignment) %pR flags %#lx\n",
- resno, res, res->flags);
- return -EINVAL;
- }
/* First, try exact prefetching match.. */
ret = pci_bus_alloc_resource(bus, res, size, align, min,
@@ -169,10 +162,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
pcibios_align_resource, dev);
}
- if (ret) {
- dev_info(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
- resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
- } else {
+ if (!ret) {
res->flags &= ~IORESOURCE_STARTALIGN;
if (resno < PCI_BRIDGE_RESOURCES)
pci_update_resource(dev, resno);
@@ -181,6 +171,39 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
return ret;
}
+int pci_assign_resource(struct pci_dev *dev, int resno)
+{
+ struct resource *res = dev->resource + resno;
+ resource_size_t align;
+ struct pci_bus *bus;
+ int ret;
+
+ align = resource_alignment(res);
+ if (!align) {
+ dev_info(&dev->dev, "BAR %d: can't allocate resource (bogus "
+ "alignment) %pR flags %#lx\n",
+ resno, res, res->flags);
+ return -EINVAL;
+ }
+
+ bus = dev->bus;
+ while ((ret = __pci_assign_resource(bus, dev, resno))) {
+ if (bus->parent && bus->self->transparent)
+ bus = bus->parent;
+ else
+ bus = NULL;
+ if (bus)
+ continue;
+ break;
+ }
+
+ if (ret)
+ dev_info(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
+ resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
+
+ return ret;
+}
+
#if 0
int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
{
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 276473543982..fbf965b31c14 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -217,7 +217,7 @@ config PCMCIA_PXA2XX
depends on ARM && ARCH_PXA && PCMCIA
depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
|| MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
- || ARCH_VIPER || ARCH_PXA_ESERIES)
+ || ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2)
help
Say Y here to include support for the PXA2xx PCMCIA controller
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index bbac46327227..047394d98ac2 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -73,5 +73,6 @@ pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps4.o
pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o
pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o
+pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o
obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o $(pxa2xx-obj-y)
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 47cab31ff6e4..3b9f6613ab52 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -394,7 +394,7 @@ static int pcmcia_device_probe(struct device * dev)
p_drv = to_pcmcia_drv(dev->driver);
s = p_dev->socket;
- /* The PCMCIA code passes the match data in via dev->driver_data
+ /* The PCMCIA code passes the match data in via dev_set_drvdata(dev)
* which is an ugly hack. Once the driver probe is called it may
* and often will overwrite the match data so we must save it first
*
@@ -404,7 +404,7 @@ static int pcmcia_device_probe(struct device * dev)
* call which will then check whether there are two
* pseudo devices, and if not, add the second one.
*/
- did = p_dev->dev.driver_data;
+ did = dev_get_drvdata(&p_dev->dev);
ds_dev_dbg(1, dev, "trying to bind to %s\n", p_drv->drv.name);
@@ -499,7 +499,7 @@ static int pcmcia_device_remove(struct device * dev)
* pseudo multi-function card, we need to unbind
* all devices
*/
- did = p_dev->dev.driver_data;
+ did = dev_get_drvdata(&p_dev->dev);
if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
(p_dev->socket->device_count != 0) &&
(p_dev->device_no == 0))
@@ -988,7 +988,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
return 0;
}
- dev->dev.driver_data = (void *) did;
+ dev_set_drvdata(&dev->dev, did);
return 1;
}
diff --git a/drivers/pcmcia/pxa2xx_stargate2.c b/drivers/pcmcia/pxa2xx_stargate2.c
new file mode 100644
index 000000000000..490749ea677f
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_stargate2.c
@@ -0,0 +1,174 @@
+/*
+ * linux/drivers/pcmcia/pxa2xx_stargate2.c
+ *
+ * Stargate 2 PCMCIA specific routines.
+ *
+ * Created: December 6, 2005
+ * Author: Ed C. Epp
+ * Copyright: Intel Corp 2005
+ * Jonathan Cameron <jic23@cam.ac.uk> 2009
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+
+#include <pcmcia/ss.h>
+
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+
+#include "soc_common.h"
+
+#define SG2_S0_BUFF_CTL 120
+#define SG2_S0_POWER_CTL 108
+#define SG2_S0_GPIO_RESET 82
+#define SG2_S0_GPIO_DETECT 53
+#define SG2_S0_GPIO_READY 81
+
+static struct pcmcia_irqs irqs[] = {
+ { 0, IRQ_GPIO(SG2_S0_GPIO_DETECT), "PCMCIA0 CD" },
+};
+
+static int sg2_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
+{
+ skt->irq = IRQ_GPIO(SG2_S0_GPIO_READY);
+ return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void sg2_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
+{
+ soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void sg2_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
+ struct pcmcia_state *state)
+{
+ state->detect = !gpio_get_value(SG2_S0_GPIO_DETECT);
+ state->ready = !!gpio_get_value(SG2_S0_GPIO_READY);
+ state->bvd1 = 0; /* not available - battery detect on card */
+ state->bvd2 = 0; /* not available */
+ state->vs_3v = 1; /* not available - voltage detect for card */
+ state->vs_Xv = 0; /* not available */
+ state->wrprot = 0; /* not available - write protect */
+}
+
+static int sg2_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
+ const socket_state_t *state)
+{
+ /* Enable card power */
+ switch (state->Vcc) {
+ case 0:
+ /* sets power ctl register high */
+ gpio_set_value(SG2_S0_POWER_CTL, 1);
+ break;
+ case 33:
+ case 50:
+ /* sets power control register low (clear) */
+ gpio_set_value(SG2_S0_POWER_CTL, 0);
+ msleep(100);
+ break;
+ default:
+ pr_err("%s(): bad Vcc %u\n",
+ __func__, state->Vcc);
+ return -1;
+ }
+
+ /* reset */
+ gpio_set_value(SG2_S0_GPIO_RESET, !!(state->flags & SS_RESET));
+
+ return 0;
+}
+
+static void sg2_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
+{
+ soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void sg2_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
+{
+ soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static struct pcmcia_low_level sg2_pcmcia_ops __initdata = {
+ .owner = THIS_MODULE,
+ .hw_init = sg2_pcmcia_hw_init,
+ .hw_shutdown = sg2_pcmcia_hw_shutdown,
+ .socket_state = sg2_pcmcia_socket_state,
+ .configure_socket = sg2_pcmcia_configure_socket,
+ .socket_init = sg2_pcmcia_socket_init,
+ .socket_suspend = sg2_pcmcia_socket_suspend,
+ .nr = 1,
+};
+
+static struct platform_device *sg2_pcmcia_device;
+
+static int __init sg2_pcmcia_init(void)
+{
+ int ret;
+
+ if (!machine_is_stargate2())
+ return -ENODEV;
+
+ sg2_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
+ if (!sg2_pcmcia_device)
+ return -ENOMEM;
+
+ ret = gpio_request(SG2_S0_BUFF_CTL, "SG2 CF buff ctl");
+ if (ret)
+ goto error_put_platform_device;
+ ret = gpio_request(SG2_S0_POWER_CTL, "SG2 CF power ctl");
+ if (ret)
+ goto error_free_gpio_buff_ctl;
+ ret = gpio_request(SG2_S0_GPIO_RESET, "SG2 CF reset");
+ if (ret)
+ goto error_free_gpio_power_ctl;
+ /* Set gpio directions */
+ gpio_direction_output(SG2_S0_BUFF_CTL, 0);
+ gpio_direction_output(SG2_S0_POWER_CTL, 1);
+ gpio_direction_output(SG2_S0_GPIO_RESET, 1);
+
+ ret = platform_device_add_data(sg2_pcmcia_device,
+ &sg2_pcmcia_ops,
+ sizeof(sg2_pcmcia_ops));
+ if (ret)
+ goto error_free_gpio_reset;
+
+ ret = platform_device_add(sg2_pcmcia_device);
+ if (ret)
+ goto error_free_gpio_reset;
+
+ return 0;
+error_free_gpio_reset:
+ gpio_free(SG2_S0_GPIO_RESET);
+error_free_gpio_power_ctl:
+ gpio_free(SG2_S0_POWER_CTL);
+error_free_gpio_buff_ctl:
+ gpio_free(SG2_S0_BUFF_CTL);
+error_put_platform_device:
+ platform_device_put(sg2_pcmcia_device);
+
+ return ret;
+}
+
+static void __exit sg2_pcmcia_exit(void)
+{
+ platform_device_unregister(sg2_pcmcia_device);
+ gpio_free(SG2_S0_BUFF_CTL);
+ gpio_free(SG2_S0_POWER_CTL);
+ gpio_free(SG2_S0_GPIO_RESET);
+}
+
+fs_initcall(sg2_pcmcia_init);
+module_exit(sg2_pcmcia_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pxa2xx-pcmcia");
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 284ebaca6e45..cc79ef364f38 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -143,6 +143,19 @@ config MSI_LAPTOP
If you have an MSI S270 laptop, say Y or M here.
+config OQO_WMI
+ tristate "OQO WMI extras"
+ depends on ACPI_WMI
+ depends on INPUT && INPUT_POLLDEV
+ depends on RFKILL
+ depends on BACKLIGHT_CLASS_DEVICE
+ help
+ Say Y here if you want to support rfkill and backlight control on
+ series 2 OQO handheld devices.
+
+ To compile this driver as a module, choose M here: the module will
+ be called oqo-wmi.
+
config PANASONIC_LAPTOP
tristate "Panasonic Laptop Extras"
depends on INPUT && ACPI
@@ -341,6 +354,7 @@ config EEEPC_LAPTOP
select BACKLIGHT_CLASS_DEVICE
select HWMON
select RFKILL
+ select HOTPLUG_PCI
---help---
This driver supports the Fn-Fx keys on Eee PC laptops.
It also adds the ability to switch camera/wlan on/off.
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index e40c7bd1b87e..1637378ad3f4 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
obj-$(CONFIG_FUJITSU_LAPTOP) += fujitsu-laptop.o
+obj-$(CONFIG_OQO_WMI) += oqo-wmi.o
obj-$(CONFIG_PANASONIC_LAPTOP) += panasonic-laptop.o
obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o
obj-$(CONFIG_ACPI_WMI) += wmi.o
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 353a898c3693..a0845b2853c0 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -31,6 +31,7 @@
#include <linux/input.h>
#include <linux/rfkill.h>
#include <linux/pci.h>
+#include <linux/pci_hotplug.h>
#define EEEPC_LAPTOP_VERSION "0.1"
@@ -132,6 +133,7 @@ struct eeepc_hotk {
u16 *keycode_map;
struct rfkill *eeepc_wlan_rfkill;
struct rfkill *eeepc_bluetooth_rfkill;
+ struct hotplug_slot *hotplug_slot;
};
/* The actual device the driver binds to */
@@ -197,6 +199,15 @@ static struct acpi_driver eeepc_hotk_driver = {
},
};
+/* PCI hotplug ops */
+static int eeepc_get_adapter_status(struct hotplug_slot *slot, u8 *value);
+
+static struct hotplug_slot_ops eeepc_hotplug_slot_ops = {
+ .owner = THIS_MODULE,
+ .get_adapter_status = eeepc_get_adapter_status,
+ .get_power_status = eeepc_get_adapter_status,
+};
+
/* The backlight device /sys/class/backlight */
static struct backlight_device *eeepc_backlight_device;
@@ -529,6 +540,19 @@ static int notify_brn(void)
return -1;
}
+static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
+ u8 *value)
+{
+ int val = get_acpi(CM_ASL_WLAN);
+
+ if (val == 1 || val == 0)
+ *value = val;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
{
enum rfkill_state state;
@@ -655,6 +679,54 @@ static void eeepc_unregister_rfkill_notifier(char *node)
}
}
+static void eeepc_cleanup_pci_hotplug(struct hotplug_slot *hotplug_slot)
+{
+ kfree(hotplug_slot->info);
+ kfree(hotplug_slot);
+}
+
+static int eeepc_setup_pci_hotplug(void)
+{
+ int ret = -ENOMEM;
+ struct pci_bus *bus = pci_find_bus(0, 1);
+
+ if (!bus) {
+ printk(EEEPC_ERR "Unable to find wifi PCI bus\n");
+ return -ENODEV;
+ }
+
+ ehotk->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
+ if (!ehotk->hotplug_slot)
+ goto error_slot;
+
+ ehotk->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
+ GFP_KERNEL);
+ if (!ehotk->hotplug_slot->info)
+ goto error_info;
+
+ ehotk->hotplug_slot->private = ehotk;
+ ehotk->hotplug_slot->release = &eeepc_cleanup_pci_hotplug;
+ ehotk->hotplug_slot->ops = &eeepc_hotplug_slot_ops;
+ eeepc_get_adapter_status(ehotk->hotplug_slot,
+ &ehotk->hotplug_slot->info->adapter_status);
+
+ ret = pci_hp_register(ehotk->hotplug_slot, bus, 0, "eeepc-wifi");
+ if (ret) {
+ printk(EEEPC_ERR "Unable to register hotplug slot - %d\n", ret);
+ goto error_register;
+ }
+
+ return 0;
+
+error_register:
+ kfree(ehotk->hotplug_slot->info);
+error_info:
+ kfree(ehotk->hotplug_slot);
+ ehotk->hotplug_slot = NULL;
+error_slot:
+ return ret;
+}
+
static int eeepc_hotk_add(struct acpi_device *device)
{
acpi_status status = AE_OK;
@@ -738,8 +810,21 @@ static int eeepc_hotk_add(struct acpi_device *device)
goto bluetooth_fail;
}
+ result = eeepc_setup_pci_hotplug();
+ /*
+ * If we get -EBUSY then something else is handling the PCI hotplug -
+ * don't fail in this case
+ */
+ if (result == -EBUSY)
+ return 0;
+ else if (result)
+ goto pci_fail;
+
return 0;
+ pci_fail:
+ if (ehotk->eeepc_bluetooth_rfkill)
+ rfkill_unregister(ehotk->eeepc_bluetooth_rfkill);
bluetooth_fail:
if (ehotk->eeepc_bluetooth_rfkill)
rfkill_free(ehotk->eeepc_bluetooth_rfkill);
@@ -770,6 +855,8 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
+ if (ehotk->hotplug_slot)
+ pci_hp_deregister(ehotk->hotplug_slot);
kfree(ehotk);
return 0;
diff --git a/drivers/platform/x86/oqo-wmi.c b/drivers/platform/x86/oqo-wmi.c
new file mode 100644
index 000000000000..0a88af82f127
--- /dev/null
+++ b/drivers/platform/x86/oqo-wmi.c
@@ -0,0 +1,941 @@
+/*
+ * OQO WMI UPMC Extras
+ *
+ * Copyright (C) 2008 Brian S. Julin <bri@abrij.org>
+ *
+ * Based on acer-wmi:
+ * Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * NOTE: You need to turn SMI on in BIOS (if dmidecode works, you already have)
+ * NOTE: acpi-wmi support mandatory
+ * NOTE: backlight and inputdev support a must, ifdefs will come later
+ */
+
+/*
+ *
+ * 0.3: added WLAN enable switch, restore settings on unload,
+ * resume/suspend handling
+ * 0.2: Still not production-ready, but added ambient light sensor,
+ * backlight, and it prints the unit serial number to dmesg (do
+ * not know where to make that available to userspace yet.)
+ * 0.1: This is a first cut. Plan to reboot after playing with this.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/dmi.h>
+#include <linux/backlight.h>
+#include <linux/leds.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <linux/i8042.h>
+#include <linux/input-polldev.h>
+#include <linux/rfkill.h>
+
+#include <acpi/acpi_drivers.h>
+
+MODULE_AUTHOR("Brian Julin");
+MODULE_DESCRIPTION("OQO UPMC WMI Extras Driver");
+MODULE_LICENSE("GPL");
+
+#define OQO_LOGPREFIX "oqo-wmi: "
+#define OQO_ERR KERN_ERR OQO_LOGPREFIX
+#define OQO_NOTICE KERN_NOTICE OQO_LOGPREFIX
+#define OQO_INFO KERN_INFO OQO_LOGPREFIX
+
+#define OQO_KINE_MAXTRY 3
+
+/* Store defined devices globally since we only have one instance. */
+static struct platform_device *oqo_platform_device;
+static struct backlight_device *oqo_backlight_device;
+static struct rfkill *oqo_rfkill;
+static struct input_dev *oqo_kine;
+static struct input_polled_dev *oqo_kine_polled;
+
+/* Likewise store current and original settings globally. */
+struct oqo_settings {
+ int lid_wakes; /* not sure if ACPI handles/needs help here */
+ int kine_itvl;
+ int bl_bright;
+};
+
+static struct oqo_settings orig, curr;
+
+/* Some of this code is left like in acer-wmi so we can add the older
+ Model 01 and any future models more easily, but we should not expect
+ it to be as complicated as Acer given each model is a leap rather than
+ a subtle variant on the last, so we aren't using "quirks" perse. Not
+ sure if there is any real difference for our purposes between the o2
+ and e2.
+*/
+struct oqo_model {
+ const char *model;
+ u16 model_subs;
+};
+#define MODEL_SUB_OQO_O2_SMB0 3
+
+static struct oqo_model oqo_models[] = {
+ {
+ .model = "Model 2",
+ .model_subs = MODEL_SUB_OQO_O2_SMB0,
+ },
+ {}
+};
+
+static struct oqo_model *model;
+
+static int force;
+module_param(force, bool, 0644);
+MODULE_PARM_DESC(force, "Force WMI detection even if DMI detection failed");
+
+/*
+ * OQO Model 2 SMBUS registers
+ * We are just using WMI to read the Cx700 smbus, to share the
+ * ACPI mutex (what may also eventually work in VMs/win32)
+ * Using i2c-viapro directly could interfere with PM.
+ */
+
+#define OQO_O2_SMB0_WWAN_DSBL_ADDR 0x19
+#define OQO_O2_SMB0_WWAN_DSBL_MASK 0x02
+#define OQO_O2_SMB0_LUMIN_LO 0x20
+#define OQO_O2_SMB0_LUMIN_HI 0x21
+#define OQO_O2_SMB0_BL_LO 0x26
+#define OQO_O2_SMB0_BL_HI 0x27
+#define OQO_O2_SMB0_ACCEL_POLL_ITVL 0x45
+#define OQO_O2_SMB0_ACCEL_XLO 0x50
+#define OQO_O2_SMB0_ACCEL_XHI 0x51
+#define OQO_O2_SMB0_ACCEL_YLO 0x52
+#define OQO_O2_SMB0_ACCEL_YHI 0x53
+#define OQO_O2_SMB0_ACCEL_ZLO 0x54
+#define OQO_O2_SMB0_ACCEL_ZHI 0x55
+/* These may be handled by ACPI not sure yet. */
+#define OQO_O2_SMB0_LID_WAKES_ADDR 0x58
+#define OQO_O2_SMB0_LID_WAKES_MASK 0x08
+
+#define OQO_O2_SMB0_SERIAL_START 0x70
+#define OQO_O2_SMB0_SERIAL_LEN 11
+
+static char oqo_sn[OQO_O2_SMB0_SERIAL_LEN + 1];
+
+/* Other addresses I have noticed used on the 02 SMBUS (from DSDT and whatnot)
+ *
+ * These are not used because the linux ACPI drivers work fine on them
+ *
+ * 0x0A -- processor sleep mode?
+ * 0x0C -- ACPI events, probably clears when read.
+ * 0x30 -- thermal zone
+ * There is something going on at 0x31 through 0x34 which is likely
+ * also thermal. The values change over time. Have not figured that
+ * out yet.
+ * 0x41 -- AC detect
+ * 0x42 -- LID button ACTUALLY THIS DOES NOT WORK AND NEEDS TO BE FIXED
+ * 0xa0 and 0xa1 -- battery something (presence? state?)
+ * 0xa4 to 0xcf -- battery info (0xc8-0xca contains "OQO")
+ * 0xd4 to 0xef -- other battery stats
+ */
+
+/*
+ * OQO method GUIDs
+ */
+#define OQO_O2_AMW0_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
+MODULE_ALIAS("wmi:ABBC0F6D-8EA1-11D1-00A0-C90629100000");
+
+/*
+ * Interface type flags
+ */
+enum interface_type {
+ OQO_O2_AMW0,
+};
+
+/* Each low-level interface must define at least some of the following */
+struct wmi_interface {
+ /* The WMI device type */
+ u32 type;
+};
+
+static struct wmi_interface AMW0_interface = {
+ .type = OQO_O2_AMW0,
+};
+
+/* The detected/chosen interface */
+static struct wmi_interface *interface;
+
+static int dmi_matched(const struct dmi_system_id *dmi)
+{
+ model = dmi->driver_data;
+ /*
+ * Detect which ACPI-WMI interface we're using.
+ */
+ if (wmi_has_guid(OQO_O2_AMW0_GUID))
+ interface = &AMW0_interface;
+
+ return 0;
+}
+
+static struct dmi_system_id oqo_dmis[] = {
+ {
+ .callback = dmi_matched,
+ .ident = "OQO 02",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "OQO Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "OQO Model 2"),
+ },
+ .driver_data = oqo_models + 0,
+ },
+ {}
+};
+
+/*
+ * AMW0 (V1) interface on OQO Model 2
+ *
+ * wmba: has four functions selected by int arg 1. arg2 is 3 byte buffer.
+ * 1: performs GETB method on the SMBUS using bytes 0, 1 of Arg2
+ * returns a buffer object containing a single byte
+ * 2: performs SETB on SMBUS using bytes 0, 1, 2 of Arg2
+ * returns 0 as int.
+ * 3: dumps 256 values into a given SMBUS register (not used here)
+ * returns 0 as int.
+ * 4: puts byte 0 of arg2 into some sort of busy flag. Some ACPI
+ * funcs check this (==0) to decide if SMBUS operations are safe.
+ * returns 0 as int.
+ * wmbb: simply returns the busy flag set by wmba #4
+ */
+static acpi_status oqo_smbus_getb(u8 addr, u8 *result)
+{
+ struct acpi_buffer input, res;
+ acpi_status status;
+ union acpi_object *obj;
+ u32 arg2;
+
+ input.length = 4;
+ input.pointer = &arg2;
+ res.length = ACPI_ALLOCATE_BUFFER;
+ res.pointer = NULL;
+
+ arg2 = addr;
+ arg2 <<= 8;
+ arg2 |= 0x12; /* HOSTCMD */
+
+ status = wmi_evaluate_method(OQO_O2_AMW0_GUID, 1, 1, &input, &res);
+
+ if (status != AE_OK)
+ return status;
+
+ obj = (union acpi_object *)res.pointer;
+ if (!obj)
+ return AE_NULL_OBJECT;
+
+ if (obj->type != ACPI_TYPE_BUFFER
+ || obj->buffer.length != 1 || obj->buffer.pointer == NULL) {
+ kfree(obj);
+ return AE_TYPE;
+ }
+ *result = ((u8 *) (obj->buffer.pointer))[0];
+ kfree(obj);
+ return status;
+}
+
+static acpi_status oqo_smbus_setb(u8 addr, u8 val)
+{
+ struct acpi_buffer input, res;
+ acpi_status status;
+ union acpi_object *obj;
+ u32 arg2;
+
+ input.length = 4;
+ input.pointer = &arg2;
+ res.length = ACPI_ALLOCATE_BUFFER;
+ res.pointer = NULL;
+
+ arg2 = val;
+ arg2 <<= 8;
+ arg2 |= addr;
+ arg2 <<= 8;
+ arg2 |= 0x12; /* HOSTCMD */
+
+ status = wmi_evaluate_method(OQO_O2_AMW0_GUID, 1, 2, &input, &res);
+
+ if (status != AE_OK)
+ return status;
+
+ obj = (union acpi_object *)res.pointer;
+ if (!obj)
+ return AE_NULL_OBJECT;
+
+ if (obj->type != ACPI_TYPE_INTEGER) {
+ kfree(obj);
+ return AE_TYPE;
+ }
+ kfree(obj);
+ return status;
+}
+
+/*
+ * We assume we are the only one using this ...ahem... "lock" on
+ * the SMBUS because it would be pathetically noneffective otherwise.
+ *
+ * Nonzero silly_lock will keep certain ACPI routines away from the
+ * SMBUS (if they aren't already on it when you call it.) Zero
+ * silly_lock will let them back on
+ *
+ * This is probably useful before sleeping the system, and one
+ * waits until any ACPI funcs would have long finished before
+ * proceeding. It seems harmless enough and will work to wrap
+ * more accesses with it.
+ */
+static acpi_status oqo_lock_smbus(int silly_lock)
+{
+ struct acpi_buffer input, res;
+ acpi_status status;
+ union acpi_object *obj;
+ u32 arg2;
+
+ input.length = 4;
+ input.pointer = &arg2;
+ res.length = ACPI_ALLOCATE_BUFFER;
+ res.pointer = NULL;
+
+ arg2 = !!silly_lock;
+
+ status = wmi_evaluate_method(OQO_O2_AMW0_GUID, 1, 4, &input, &res);
+
+ if (status != AE_OK)
+ return status;
+
+ obj = (union acpi_object *)res.pointer;
+ if (!obj)
+ return AE_NULL_OBJECT;
+
+ if (obj->type != ACPI_TYPE_INTEGER) {
+ kfree(obj);
+ return AE_TYPE;
+ }
+ kfree(obj);
+ return status;
+}
+
+static int smread_s16(u8 hi_addr, u8 lo_addr)
+{
+ s16 ret = -1;
+ acpi_status status;
+ u8 r;
+
+ /* Keep some ACPI routines off the SMBUS */
+ status = oqo_lock_smbus(1);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ status = oqo_smbus_getb(hi_addr, &r);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ ret = r;
+ ret <<= 8;
+
+ status = oqo_smbus_getb(lo_addr, &r);
+ if (ACPI_FAILURE(status)) {
+ ret = -1;
+ goto skip;
+ }
+
+ ret |= r;
+ ret &= 0x7fff;
+skip:
+ /* Let ACPI routines back on the SMBUS */
+ status = oqo_lock_smbus(0);
+ if (ACPI_FAILURE(status))
+ return -1;
+ return (int)ret;
+}
+
+static int smwrite_s16(u8 hi_addr, u8 lo_addr, s16 val)
+{
+ acpi_status status;
+ u8 r;
+ int ret = -1;
+
+ status = oqo_lock_smbus(1);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ r = (val >> 8) & 0x7f;
+ status = oqo_smbus_setb(hi_addr, r);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ r = val & 0xff;
+ status = oqo_smbus_setb(lo_addr, r);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ ret = 0;
+skip:
+ status = oqo_lock_smbus(0);
+ if (ACPI_FAILURE(status))
+ return -1;
+ return ret;
+}
+
+static int smread_u8(u8 addr)
+{
+ int ret = -1;
+ acpi_status status;
+ u8 r;
+
+ status = oqo_lock_smbus(1);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ status = oqo_smbus_getb(addr, &r);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ ret = r;
+skip:
+ status = oqo_lock_smbus(0);
+ if (ACPI_FAILURE(status))
+ return -1;
+ return (int)ret;
+}
+
+static int smwrite_u8(u8 addr, u8 val)
+{
+ acpi_status status;
+ int ret = -1;
+
+ status = oqo_lock_smbus(1);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ status = oqo_smbus_setb(addr, val);
+ if (ACPI_FAILURE(status))
+ goto skip;
+
+ ret = 0;
+skip:
+ status = oqo_lock_smbus(0);
+ if (ACPI_FAILURE(status))
+ return -1;
+ return ret;
+}
+
+/*
+ * Accelerometer inputdev
+ */
+
+/*
+ * Get a reading of the accelerometer from the firwmware and push
+ * it to an inputdev.
+ *
+ * Also the ambient light detector hitch-hikes on the inputdev, since
+ * it could be useful in some of the same applications for accelerometers.
+ *
+ * Available information and a bit of poking have not found a
+ * way to freeze a snapshot of the accelerometer data, so we have
+ * to do consistency checks to reduce the odds that we mix low
+ * and high bytes from different updates.
+ *
+ * Unfortunately SMBUS access is very slow (11ms) and the firmware API
+ * does not provide 2-byte transfers, so mixed readings happen and
+ * have to be corrected a lot. (Do not know why; it should be a
+ * multi-kHz.. bus and the reads take only a hundred-ish cycles/byte.
+ * It is not the ACPI function -- it is slow on i2c-viapro as well.)
+ *
+ * Since there is such a big time lag between readings, the axis
+ * are decoupled and reported separately on different timelines as
+ * different events rather than as a set.
+ */
+static acpi_status oqo_read_kine(int *good, s16 *x, s16 *y, s16 *z,
+ u16 *lumin)
+{
+ u8 hiregs[4] = { OQO_O2_SMB0_ACCEL_XHI,
+ OQO_O2_SMB0_ACCEL_YHI,
+ OQO_O2_SMB0_ACCEL_ZHI,
+ OQO_O2_SMB0_LUMIN_HI
+ };
+ u8 loregs[4] = { OQO_O2_SMB0_ACCEL_XLO,
+ OQO_O2_SMB0_ACCEL_YLO,
+ OQO_O2_SMB0_ACCEL_ZLO,
+ OQO_O2_SMB0_LUMIN_LO
+ };
+
+ short ax[4] = { ABS_X, ABS_Y, ABS_Z, ABS_MISC };
+ u8 realgood = 0;
+ u16 res[4];
+ acpi_status status;
+ int i;
+
+ *good = 0;
+
+ /* Routine: Starting with the lo byte, read lo/hi bytes
+ alternately until two lo byte readings, match. Then
+ take that reading and combine it with the hi reading
+ sandwiched between. Errors can still happen when
+ jittering at wrap boundaries, but should be rare.
+
+ Don't use this for missile guidance.
+
+ Userspace post-processing error detection encouraged.
+ */
+ for (i = 0; i < 4; i++) {
+ int maxtry;
+ u32 log;
+ u8 r, lo, hi;
+
+ lo = loregs[i];
+ hi = hiregs[i];
+ log = 0;
+
+#define LOGRES(reg) do { \
+ status = oqo_smbus_getb(reg, &r); \
+ log <<= 8; log |= r; log &= 0xffffff; \
+ if (ACPI_FAILURE(status)) \
+ goto leave; \
+ } while (0)
+
+ maxtry = OQO_KINE_MAXTRY + 1;
+ while (maxtry) {
+ LOGRES(lo);
+ if (maxtry <= OQO_KINE_MAXTRY &&
+ (log >> 16) == (log & 0xff)) {
+ *(res + i) = log & 0xffff;
+ break;
+ }
+ LOGRES(hi);
+ maxtry--;
+ }
+
+ if (maxtry == OQO_KINE_MAXTRY)
+ realgood |= 1 << i;
+
+ if (maxtry) {
+ *good |= 1 << i;
+ /* JIC CYA: this bit may be reserved */
+ res[3] &= 0x7fff;
+ input_report_abs(oqo_kine, ax[i], (s16) res[i]);
+ }
+ /* else we had trouble getting the reading to lock
+ and we skip reporting this axis.
+ */
+ }
+
+ *x = (u16) res[0];
+ *y = (u16) res[1];
+ *z = (u16) res[2];
+ *lumin = (u16) res[3];
+ return status;
+leave:
+ return status;
+}
+
+/*
+ * Generic Device (interface-independent)
+ */
+
+static void oqo_kine_poll(struct input_polled_dev *dev)
+{
+ s16 x, y, z;
+ u16 lumin;
+ int good;
+ /* struct timeval tv1, tv2; */
+
+ if (dev != oqo_kine_polled)
+ return;
+ if (orig.kine_itvl < 0)
+ return;
+
+ x = y = z = 0;
+ oqo_read_kine(&good, &x, &y, &z, &lumin);
+}
+
+static int __devinit oqo_kine_init(void)
+{
+ int err;
+
+ oqo_kine = input_allocate_device();
+ if (!oqo_kine)
+ return -ENOMEM;
+
+ oqo_kine->name = "OQO embedded accelerometer";
+ oqo_kine->phys = "platform:oqo-wmi:kine";
+ oqo_kine->id.bustype = 0;
+ oqo_kine->id.vendor = 0;
+ oqo_kine->id.product = 2;
+ oqo_kine->id.version = 0;
+ oqo_kine->evbit[0] = BIT_MASK(EV_ABS);
+ set_bit(ABS_X, oqo_kine->absbit);
+ set_bit(ABS_Y, oqo_kine->absbit);
+ set_bit(ABS_Z, oqo_kine->absbit);
+ set_bit(ABS_MISC, oqo_kine->absbit);
+ oqo_kine->absmin[ABS_X] =
+ oqo_kine->absmin[ABS_Y] =
+ oqo_kine->absmin[ABS_Z] = oqo_kine->absmin[ABS_MISC] = -32768;
+ oqo_kine->absmax[ABS_X] =
+ oqo_kine->absmax[ABS_Y] =
+ oqo_kine->absmax[ABS_Z] = oqo_kine->absmax[ABS_MISC] = 32767;
+
+ dev_set_name(&oqo_kine->dev, "kine");
+
+ oqo_kine_polled = input_allocate_polled_device();
+ if (!oqo_kine_polled) {
+ err = -ENOMEM;
+ goto bail0;
+ }
+
+ oqo_kine_polled->poll = oqo_kine_poll;
+ oqo_kine_polled->poll_interval = 250;
+ oqo_kine_polled->input = oqo_kine;
+
+ orig.kine_itvl = -1; /* prevent callback from running */
+ err = input_register_polled_device(oqo_kine_polled);
+ if (err) {
+ printk(OQO_ERR "Failed to register OQO kine input\n");
+ goto bail1;
+ }
+
+ /* This will allow the callback to run now if successful. */
+ orig.kine_itvl = smread_u8(OQO_O2_SMB0_ACCEL_POLL_ITVL);
+ smwrite_u8(OQO_O2_SMB0_ACCEL_POLL_ITVL, 250);
+ curr.kine_itvl = smread_u8(OQO_O2_SMB0_ACCEL_POLL_ITVL);
+ if (orig.kine_itvl < 0 || curr.kine_itvl != 250) {
+ printk(OQO_ERR "Test communication with kine sensor failed\n");
+ err = -ENODEV;
+ goto bail2;
+ }
+
+ printk(OQO_INFO "Created OQO kine input.\n");
+ printk(OQO_INFO "Firmware interval %ims, driver interval %ims\n",
+ curr.kine_itvl, oqo_kine_polled->poll_interval);
+ return 0;
+bail2:
+ input_unregister_polled_device(oqo_kine_polled);
+bail1:
+ input_free_polled_device(oqo_kine_polled); /* frees oqo_kine */
+ return err;
+bail0:
+ input_free_device(oqo_kine);
+ return err;
+}
+
+static void __devexit oqo_kine_fini(void)
+{
+ smwrite_u8(OQO_O2_SMB0_ACCEL_POLL_ITVL, orig.kine_itvl);
+ input_unregister_polled_device(oqo_kine_polled);
+ input_free_polled_device(oqo_kine_polled);
+}
+
+/*
+ * Backlight device
+ */
+static int read_brightness(struct backlight_device *bd)
+{
+ return (int)smread_s16(OQO_O2_SMB0_BL_HI, OQO_O2_SMB0_BL_LO);
+}
+
+static int update_bl_status(struct backlight_device *bd)
+{
+ return smwrite_s16(OQO_O2_SMB0_BL_HI,
+ OQO_O2_SMB0_BL_LO, (s16) bd->props.brightness);
+}
+
+static struct backlight_ops oqo_bl_ops = {
+ .get_brightness = read_brightness,
+ .update_status = update_bl_status,
+};
+
+static int __devinit oqo_backlight_init(struct device *dev)
+{
+ struct backlight_device *bd;
+
+ /*
+ * It would be nice if someone would figure out how backlights
+ * like these, which are not driven through the video hardware,
+ * are supposed to find their associated fb and bind to it (and
+ * rebind when fb drivers change.
+ *
+ * Most extras backlights just shove a junk name in like we do here,
+ * and don't end up integrated with fbcon sysfs as a result.
+ */
+ bd = backlight_device_register("oqo-bl", dev, NULL, &oqo_bl_ops);
+
+ if (IS_ERR(bd)) {
+ printk(OQO_ERR "Could not register OQO backlight device\n");
+ oqo_backlight_device = NULL;
+ return PTR_ERR(bd);
+ }
+
+ oqo_backlight_device = bd;
+ bd->props.max_brightness = 0x7fff;
+ curr.bl_bright = orig.bl_bright = bd->props.brightness =
+ read_brightness(NULL);
+
+ if (bd->props.brightness < 0)
+ goto fail;
+
+ backlight_update_status(bd);
+ printk(OQO_INFO "Found backlight set at %i\n", bd->props.brightness);
+ return 0;
+
+fail:
+ backlight_device_unregister(oqo_backlight_device);
+ oqo_backlight_device = NULL;
+ return -ENODEV;
+}
+
+static void __devexit oqo_backlight_fini(void)
+{
+ if (!oqo_backlight_device)
+ return;
+ oqo_backlight_device->props.brightness = orig.bl_bright;
+ backlight_update_status(oqo_backlight_device);
+ backlight_device_unregister(oqo_backlight_device);
+}
+
+/*
+ * RFKill device
+ */
+
+static int oqo_rfkill_get(void *data, enum rfkill_state *state)
+{
+ int res;
+
+ res = smread_u8(OQO_O2_SMB0_WWAN_DSBL_ADDR);
+ if (res < 0)
+ return res;
+
+ res &= OQO_O2_SMB0_WWAN_DSBL_MASK;
+
+ if (res)
+ *state = RFKILL_STATE_SOFT_BLOCKED;
+ else
+ *state = RFKILL_STATE_UNBLOCKED;
+
+ return 0;
+}
+
+static int oqo_rfkill_toggle(void *data, enum rfkill_state state)
+{
+ int res;
+
+ res = smread_u8(OQO_O2_SMB0_WWAN_DSBL_ADDR);
+
+ if (state == RFKILL_STATE_UNBLOCKED)
+ res &= ~OQO_O2_SMB0_WWAN_DSBL_MASK;
+ else
+ res |= OQO_O2_SMB0_WWAN_DSBL_MASK;
+
+ return smwrite_u8(OQO_O2_SMB0_WWAN_DSBL_ADDR, res);
+}
+
+static int __devinit oqo_rfkill_init(struct device *dev)
+{
+ int res;
+
+ oqo_rfkill = rfkill_allocate(dev, RFKILL_TYPE_WWAN);
+ if (!oqo_rfkill)
+ return -ENODEV;
+
+ res = smread_u8(OQO_O2_SMB0_WWAN_DSBL_ADDR);
+ res &= OQO_O2_SMB0_WWAN_DSBL_MASK;
+
+ oqo_rfkill->name = "oqo-wwan";
+ if (res)
+ oqo_rfkill->state = RFKILL_STATE_SOFT_BLOCKED;
+ else
+ oqo_rfkill->state = RFKILL_STATE_UNBLOCKED;
+
+ oqo_rfkill->get_state = oqo_rfkill_get;
+ oqo_rfkill->toggle_radio = oqo_rfkill_toggle;
+ oqo_rfkill->user_claim_unsupported = 1;
+
+ res = rfkill_register(oqo_rfkill);
+
+ if (res)
+ rfkill_free(oqo_rfkill);
+
+ return res;
+}
+
+static void __devexit oqo_rfkill_fini(void)
+{
+ if (!oqo_rfkill)
+ return;
+ rfkill_unregister(oqo_rfkill);
+}
+
+/*
+ * Platform device
+ */
+
+static int __devinit oqo_platform_probe(struct platform_device *device)
+{
+ int err;
+ int i;
+ char *troubleok = "trouble, but continuing.\n";
+
+ memset(oqo_sn, 0, OQO_O2_SMB0_SERIAL_LEN + 1);
+ for (i = 0; i < OQO_O2_SMB0_SERIAL_LEN; i++) {
+ err = oqo_smbus_getb(OQO_O2_SMB0_SERIAL_START + i, oqo_sn + i);
+ if (err) {
+ printk(OQO_ERR "Serial number check failed.\n");
+ return err;
+ }
+ }
+ printk(OQO_INFO "Found OQO with serial number %s.\n", oqo_sn);
+
+ err = oqo_backlight_init(&device->dev);
+ if (err)
+ printk(OQO_ERR "Backlight init %s", troubleok);
+
+ err = oqo_rfkill_init(&device->dev);
+ if (err)
+ printk(OQO_ERR "RFKill init %s", troubleok);
+
+ /* LID does not work at all yet, and this may be taken
+ care of by ACPI.
+ */
+ orig.lid_wakes = smread_u8(OQO_O2_SMB0_LID_WAKES_ADDR);
+ orig.lid_wakes &= OQO_O2_SMB0_LID_WAKES_MASK;
+ orig.lid_wakes = curr.lid_wakes = !!orig.lid_wakes;
+ if (orig.lid_wakes < 0) {
+ printk(OQO_ERR "Wake on LID event %s", troubleok);
+ } else {
+ printk(OQO_INFO "Wake on LID is %s.\n",
+ (orig.lid_wakes ? "on" : "off"));
+ }
+
+ err = oqo_kine_init();
+ return err;
+}
+
+static int oqo_platform_remove(struct platform_device *device)
+{
+ oqo_backlight_fini();
+ oqo_rfkill_fini();
+ oqo_kine_fini();
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+
+static int oqo_platform_suspend(struct platform_device *dev, pm_message_t state)
+{
+ if (!interface)
+ return -ENOMEM;
+
+ /* This sticks during boot so do not turn it entirely off */
+ if (oqo_backlight_device) {
+ curr.bl_bright = read_brightness(oqo_backlight_device);
+ smwrite_s16(OQO_O2_SMB0_BL_HI, OQO_O2_SMB0_BL_LO, 256);
+ }
+ return 0;
+}
+
+static int oqo_platform_resume(struct platform_device *device)
+{
+ if (!interface)
+ return -ENOMEM;
+
+ if (oqo_backlight_device) {
+ smwrite_s16(OQO_O2_SMB0_BL_HI,
+ OQO_O2_SMB0_BL_LO, curr.bl_bright);
+ }
+
+ return 0;
+}
+
+#else
+#define oqo_platform_suspend NULL
+#define oqo_platform_resume NULL
+#endif
+
+static struct platform_driver oqo_platform_driver = {
+ .driver = {
+ .name = "oqo-wmi",
+ .owner = THIS_MODULE,
+ },
+ .probe = oqo_platform_probe,
+ .remove = oqo_platform_remove,
+ .suspend = oqo_platform_suspend,
+ .resume = oqo_platform_resume,
+};
+
+static int __init oqo_wmi_init(void)
+{
+ int err;
+
+ dmi_check_system(oqo_dmis);
+
+ if (!interface && force) {
+ model = oqo_models;
+ if (wmi_has_guid(OQO_O2_AMW0_GUID))
+ interface = &AMW0_interface;
+ }
+
+ if (!interface) {
+ printk(OQO_ERR "No or unsupported WMI interface. Aborting.\n");
+ printk(OQO_ERR "Hint: Get dmidecode working and try again.\n");
+ printk(OQO_ERR "(Check \"System Management BIOS\" in BIOS)\n");
+ if (!force)
+ printk(OQO_ERR "Use the force option to skip DMI"
+ " checking\n");
+ return -ENODEV;
+ }
+
+ err = platform_driver_register(&oqo_platform_driver);
+ if (err) {
+ printk(OQO_ERR "platform_driver_register gave %d.\n", err);
+ goto bail0;
+ }
+
+ oqo_platform_device = platform_device_alloc("oqo-wmi", -1);
+ if (!oqo_platform_device) {
+ printk(OQO_ERR "Could not allocate platform device.\n");
+ err = -ENOMEM;
+ goto bail1;
+ }
+
+ err = platform_device_add(oqo_platform_device);
+ if (err) {
+ printk(OQO_ERR "platform_device_add gave %d.\n", err);
+ platform_device_put(oqo_platform_device);
+ goto bail1;
+ }
+
+ return 0;
+
+bail1:
+ platform_driver_unregister(&oqo_platform_driver);
+bail0:
+ return err;
+}
+
+static void __exit oqo_wmi_fini(void)
+{
+ platform_device_del(oqo_platform_device);
+ platform_driver_unregister(&oqo_platform_driver);
+
+ return;
+}
+
+module_init(oqo_wmi_init);
+module_exit(oqo_wmi_fini);
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 9f187265db8e..0c6cd7c654da 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -46,6 +46,7 @@
#include <linux/platform_device.h>
#include <linux/rfkill.h>
#include <linux/input-polldev.h>
+#include <linux/input.h>
#include <asm/uaccess.h>
@@ -62,9 +63,10 @@ MODULE_LICENSE("GPL");
/* Toshiba ACPI method paths */
#define METHOD_LCD_BRIGHTNESS "\\_SB_.PCI0.VGA_.LCD_._BCM"
-#define METHOD_HCI_1 "\\_SB_.VALD.GHCI"
-#define METHOD_HCI_2 "\\_SB_.VALZ.GHCI"
+#define TOSH_INTERFACE_1 "\\_SB_.VALD"
+#define TOSH_INTERFACE_2 "\\_SB_.VALZ"
#define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX"
+#define GHCI_METHOD ".GHCI"
/* Toshiba HCI interface definitions
*
@@ -116,6 +118,36 @@ static const struct acpi_device_id toshiba_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, toshiba_device_ids);
+struct key_entry {
+ char type;
+ u16 code;
+ u16 keycode;
+};
+
+enum {KE_KEY, KE_END};
+
+static struct key_entry toshiba_acpi_keymap[] = {
+ {KE_KEY, 0x101, KEY_MUTE},
+ {KE_KEY, 0x13b, KEY_COFFEE},
+ {KE_KEY, 0x13c, KEY_BATTERY},
+ {KE_KEY, 0x13d, KEY_SLEEP},
+ {KE_KEY, 0x13e, KEY_SUSPEND},
+ {KE_KEY, 0x13f, KEY_SWITCHVIDEOMODE},
+ {KE_KEY, 0x140, KEY_BRIGHTNESSDOWN},
+ {KE_KEY, 0x141, KEY_BRIGHTNESSUP},
+ {KE_KEY, 0x142, KEY_WLAN},
+ {KE_KEY, 0x143, KEY_PROG1},
+ {KE_KEY, 0xb05, KEY_PROG2},
+ {KE_KEY, 0xb06, KEY_WWW},
+ {KE_KEY, 0xb07, KEY_MAIL},
+ {KE_KEY, 0xb30, KEY_STOP},
+ {KE_KEY, 0xb31, KEY_PREVIOUSSONG},
+ {KE_KEY, 0xb32, KEY_NEXTSONG},
+ {KE_KEY, 0xb33, KEY_PLAYPAUSE},
+ {KE_KEY, 0xb5a, KEY_MEDIA},
+ {KE_END, 0, 0},
+};
+
/* utility
*/
@@ -252,6 +284,8 @@ struct toshiba_acpi_dev {
struct platform_device *p_dev;
struct rfkill *rfk_dev;
struct input_polled_dev *poll_dev;
+ struct input_dev *hotkey_dev;
+ acpi_handle handle;
const char *bt_name;
const char *rfk_name;
@@ -700,6 +734,154 @@ static struct backlight_ops toshiba_backlight_data = {
.update_status = set_lcd_status,
};
+static struct key_entry *toshiba_acpi_get_entry_by_scancode(int code)
+{
+ struct key_entry *key;
+
+ for (key = toshiba_acpi_keymap; key->type != KE_END; key++)
+ if (code == key->code)
+ return key;
+
+ return NULL;
+}
+
+static struct key_entry *toshiba_acpi_get_entry_by_keycode(int code)
+{
+ struct key_entry *key;
+
+ for (key = toshiba_acpi_keymap; key->type != KE_END; key++)
+ if (code == key->keycode && key->type == KE_KEY)
+ return key;
+
+ return NULL;
+}
+
+static int toshiba_acpi_getkeycode(struct input_dev *dev, int scancode,
+ int *keycode)
+{
+ struct key_entry *key = toshiba_acpi_get_entry_by_scancode(scancode);
+
+ if (key && key->type == KE_KEY) {
+ *keycode = key->keycode;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static int toshiba_acpi_setkeycode(struct input_dev *dev, int scancode,
+ int keycode)
+{
+ struct key_entry *key;
+ int old_keycode;
+
+ if (keycode < 0 || keycode > KEY_MAX)
+ return -EINVAL;
+
+ key = toshiba_acpi_get_entry_by_scancode(scancode);
+ if (key && key->type == KE_KEY) {
+ old_keycode = key->keycode;
+ key->keycode = keycode;
+ set_bit(keycode, dev->keybit);
+ if (!toshiba_acpi_get_entry_by_keycode(old_keycode))
+ clear_bit(old_keycode, dev->keybit);
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *context)
+{
+ u32 hci_result, value;
+ struct key_entry *key;
+
+ if (event != 0x80)
+ return;
+ do {
+ hci_read1(HCI_SYSTEM_EVENT, &value, &hci_result);
+ if (hci_result == HCI_SUCCESS) {
+ if (value == 0x100)
+ continue;
+ else if (value & 0x80) {
+ key = toshiba_acpi_get_entry_by_scancode
+ (value & ~0x80);
+ if (!key) {
+ printk(MY_INFO "Unknown key %x\n",
+ value & ~0x80);
+ continue;
+ }
+ input_report_key(toshiba_acpi.hotkey_dev,
+ key->keycode, 1);
+ input_sync(toshiba_acpi.hotkey_dev);
+ input_report_key(toshiba_acpi.hotkey_dev,
+ key->keycode, 0);
+ input_sync(toshiba_acpi.hotkey_dev);
+ }
+ } else if (hci_result == HCI_NOT_SUPPORTED) {
+ /* This is a workaround for an unresolved issue on
+ * some machines where system events sporadically
+ * become disabled. */
+ hci_write1(HCI_SYSTEM_EVENT, 1, &hci_result);
+ printk(MY_NOTICE "Re-enabled hotkeys\n");
+ }
+ } while (hci_result != HCI_EMPTY);
+}
+
+static int toshiba_acpi_setup_keyboard(char *device)
+{
+ acpi_status status;
+ acpi_handle handle;
+ int result;
+ const struct key_entry *key;
+
+ status = acpi_get_handle(NULL, device, &handle);
+ if (ACPI_FAILURE(status)) {
+ printk(MY_INFO "Unable to get notification device\n");
+ return -ENODEV;
+ }
+
+ toshiba_acpi.handle = handle;
+
+ status = acpi_evaluate_object(handle, "ENAB", NULL, NULL);
+ if (ACPI_FAILURE(status)) {
+ printk(MY_INFO "Unable to enable hotkeys\n");
+ return -ENODEV;
+ }
+
+ status = acpi_install_notify_handler(handle, ACPI_DEVICE_NOTIFY,
+ toshiba_acpi_notify, NULL);
+ if (ACPI_FAILURE(status)) {
+ printk(MY_INFO "Unable to install hotkey notification\n");
+ return -ENODEV;
+ }
+
+ toshiba_acpi.hotkey_dev = input_allocate_device();
+ if (!toshiba_acpi.hotkey_dev) {
+ printk(MY_INFO "Unable to register input device\n");
+ return -ENOMEM;
+ }
+
+ toshiba_acpi.hotkey_dev->name = "Toshiba input device";
+ toshiba_acpi.hotkey_dev->phys = device;
+ toshiba_acpi.hotkey_dev->id.bustype = BUS_HOST;
+ toshiba_acpi.hotkey_dev->getkeycode = toshiba_acpi_getkeycode;
+ toshiba_acpi.hotkey_dev->setkeycode = toshiba_acpi_setkeycode;
+
+ for (key = toshiba_acpi_keymap; key->type != KE_END; key++) {
+ set_bit(EV_KEY, toshiba_acpi.hotkey_dev->evbit);
+ set_bit(key->keycode, toshiba_acpi.hotkey_dev->keybit);
+ }
+
+ result = input_register_device(toshiba_acpi.hotkey_dev);
+ if (result) {
+ printk(MY_INFO "Unable to register input device\n");
+ return result;
+ }
+
+ return 0;
+}
+
static void toshiba_acpi_exit(void)
{
if (toshiba_acpi.poll_dev) {
@@ -707,12 +889,18 @@ static void toshiba_acpi_exit(void)
input_free_polled_device(toshiba_acpi.poll_dev);
}
+ if (toshiba_acpi.hotkey_dev)
+ input_unregister_device(toshiba_acpi.hotkey_dev);
+
if (toshiba_acpi.rfk_dev)
rfkill_unregister(toshiba_acpi.rfk_dev);
if (toshiba_backlight_device)
backlight_device_unregister(toshiba_backlight_device);
+ acpi_remove_notify_handler(toshiba_acpi.handle, ACPI_DEVICE_NOTIFY,
+ toshiba_acpi_notify);
+
remove_device();
if (toshiba_proc_dir)
@@ -736,11 +924,15 @@ static int __init toshiba_acpi_init(void)
return -ENODEV;
/* simple device detection: look for HCI method */
- if (is_valid_acpi_path(METHOD_HCI_1))
- method_hci = METHOD_HCI_1;
- else if (is_valid_acpi_path(METHOD_HCI_2))
- method_hci = METHOD_HCI_2;
- else
+ if (is_valid_acpi_path(TOSH_INTERFACE_1 GHCI_METHOD)) {
+ method_hci = TOSH_INTERFACE_1 GHCI_METHOD;
+ if (toshiba_acpi_setup_keyboard(TOSH_INTERFACE_1))
+ printk(MY_INFO "Unable to activate hotkeys\n");
+ } else if (is_valid_acpi_path(TOSH_INTERFACE_2 GHCI_METHOD)) {
+ method_hci = TOSH_INTERFACE_2 GHCI_METHOD;
+ if (toshiba_acpi_setup_keyboard(TOSH_INTERFACE_2))
+ printk(MY_INFO "Unable to activate hotkeys\n");
+ } else
return -ENODEV;
printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n",
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index adf17856bacc..7f207f335bec 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -123,7 +123,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
}
flags = irq_flags(triggering, polarity, shareable);
- irq = acpi_register_gsi(gsi, triggering, polarity);
+ irq = acpi_register_gsi(&dev->dev, gsi, triggering, polarity);
if (irq >= 0)
pcibios_penalize_isa_irq(irq, 1);
else
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 74d0bfa3f310..3b78540288c7 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -290,7 +290,7 @@ static void __devinit rio_add_device(struct rio_dev *rdev)
* to a RIO device on success or NULL on failure.
*
*/
-static struct rio_dev *rio_setup_device(struct rio_net *net,
+static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
struct rio_mport *port, u16 destid,
u8 hopcount, int do_enum)
{
@@ -559,7 +559,7 @@ static void rio_net_add_mport(struct rio_net *net, struct rio_mport *port)
* Recursively enumerates a RIO network. Transactions are sent via the
* master port passed in @port.
*/
-static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
+static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
u8 hopcount)
{
int port_num;
@@ -718,7 +718,7 @@ static int rio_enum_complete(struct rio_mport *port)
* Recursively discovers a RIO network. Transactions are sent via the
* master port passed in @port.
*/
-static int
+static int __devinit
rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
u8 hopcount)
{
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index e58c0ce65aa6..f4317798e47c 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -47,6 +47,16 @@ config REGULATOR_VIRTUAL_CONSUMER
If unsure, say no.
+config REGULATOR_USERSPACE_CONSUMER
+ tristate "Userspace regulator consumer support"
+ default n
+ help
+ There are some classes of devices that are controlled entirely
+ from user space. Usersapce consumer driver provides ability to
+ control power supplies for such devices.
+
+ If unsure, say no.
+
config REGULATOR_BQ24022
tristate "TI bq24022 Dual Input 1-Cell Li-Ion Charger IC"
default n
@@ -56,6 +66,15 @@ config REGULATOR_BQ24022
charging select between 100 mA and 500 mA charging current
limit.
+config REGULATOR_MAX1586
+ tristate "Maxim 1586/1587 voltage regulator"
+ depends on I2C
+ default n
+ help
+ This driver controls a Maxim 1586 or 1587 voltage output
+ regulator via I2C bus. The provided regulator is suitable
+ for PXA27x chips to control VCC_CORE and VCC_USIM voltages.
+
config REGULATOR_TWL4030
bool "TI TWL4030/TWL5030/TPS695x0 PMIC"
depends on TWL4030_CORE
@@ -91,4 +110,11 @@ config REGULATOR_PCF50633
Say Y here to support the voltage regulators and convertors
on PCF50633
+config REGULATOR_LP3971
+ tristate "National Semiconductors LP3971 PMIC regulator driver"
+ depends on I2C
+ help
+ Say Y here to support the voltage regulators and convertors
+ on National Semiconductors LP3971 PMIC
+
endif
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index bac133afc061..4d762c4cccfd 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -6,8 +6,11 @@
obj-$(CONFIG_REGULATOR) += core.o
obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
+obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
+obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
+obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl4030-regulator.o
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index c6628f5a0af7..b8b89ef10a84 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -504,7 +504,7 @@ static int __init da903x_regulator_init(void)
{
return platform_driver_register(&da903x_regulator_driver);
}
-module_init(da903x_regulator_init);
+subsys_initcall(da903x_regulator_init);
static void __exit da903x_regulator_exit(void)
{
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 23d554628a76..cdc674fb46c3 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -44,10 +44,22 @@ static int fixed_voltage_get_voltage(struct regulator_dev *dev)
return data->microvolts;
}
+static int fixed_voltage_list_voltage(struct regulator_dev *dev,
+ unsigned selector)
+{
+ struct fixed_voltage_data *data = rdev_get_drvdata(dev);
+
+ if (selector != 0)
+ return -EINVAL;
+
+ return data->microvolts;
+}
+
static struct regulator_ops fixed_voltage_ops = {
.is_enabled = fixed_voltage_is_enabled,
.enable = fixed_voltage_enable,
.get_voltage = fixed_voltage_get_voltage,
+ .list_voltage = fixed_voltage_list_voltage,
};
static int regulator_fixed_voltage_probe(struct platform_device *pdev)
@@ -69,7 +81,8 @@ static int regulator_fixed_voltage_probe(struct platform_device *pdev)
}
drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE;
- drvdata->desc.ops = &fixed_voltage_ops,
+ drvdata->desc.ops = &fixed_voltage_ops;
+ drvdata->desc.n_voltages = 1;
drvdata->microvolts = config->microvolts;
@@ -117,7 +130,7 @@ static int __init regulator_fixed_voltage_init(void)
{
return platform_driver_register(&regulator_fixed_voltage_driver);
}
-module_init(regulator_fixed_voltage_init);
+subsys_initcall(regulator_fixed_voltage_init);
static void __exit regulator_fixed_voltage_exit(void)
{
@@ -128,3 +141,4 @@ module_exit(regulator_fixed_voltage_exit);
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
MODULE_DESCRIPTION("Fixed voltage regulator");
MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:reg-fixed-voltage");
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
new file mode 100644
index 000000000000..a61018a27698
--- /dev/null
+++ b/drivers/regulator/lp3971.c
@@ -0,0 +1,562 @@
+/*
+ * Regulator driver for National Semiconductors LP3971 PMIC chip
+ *
+ * Copyright (C) 2009 Samsung Electronics
+ * Author: Marek Szyprowski <m.szyprowski@samsung.com>
+ *
+ * Based on wm8350.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/bug.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/lp3971.h>
+
+struct lp3971 {
+ struct device *dev;
+ struct mutex io_lock;
+ struct i2c_client *i2c;
+ int num_regulators;
+ struct regulator_dev **rdev;
+};
+
+static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg);
+static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val);
+
+#define LP3971_SYS_CONTROL1_REG 0x07
+
+/* System control register 1 initial value,
+ bits 4 and 5 are EPROM programmable */
+#define SYS_CONTROL1_INIT_VAL 0x40
+#define SYS_CONTROL1_INIT_MASK 0xCF
+
+#define LP3971_BUCK_VOL_ENABLE_REG 0x10
+#define LP3971_BUCK_VOL_CHANGE_REG 0x20
+
+/* Voltage control registers shift:
+ LP3971_BUCK1 -> 0
+ LP3971_BUCK2 -> 4
+ LP3971_BUCK3 -> 6
+*/
+#define BUCK_VOL_CHANGE_SHIFT(x) (((1 << x) & ~0x01) << 1)
+#define BUCK_VOL_CHANGE_FLAG_GO 0x01
+#define BUCK_VOL_CHANGE_FLAG_TARGET 0x02
+#define BUCK_VOL_CHANGE_FLAG_MASK 0x03
+
+#define LP3971_BUCK1_BASE 0x23
+#define LP3971_BUCK2_BASE 0x29
+#define LP3971_BUCK3_BASE 0x32
+
+const static int buck_base_addr[] = {
+ LP3971_BUCK1_BASE,
+ LP3971_BUCK2_BASE,
+ LP3971_BUCK3_BASE,
+};
+
+#define LP3971_BUCK_TARGET_VOL1_REG(x) (buck_base_addr[x])
+#define LP3971_BUCK_TARGET_VOL2_REG(x) (buck_base_addr[x]+1)
+
+const static int buck_voltage_map[] = {
+ 0, 800, 850, 900, 950, 1000, 1050, 1100,
+ 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500,
+ 1550, 1600, 1650, 1700, 1800, 1900, 2500, 2800,
+ 3000, 3300,
+};
+
+#define BUCK_TARGET_VOL_MASK 0x3f
+#define BUCK_TARGET_VOL_MIN_IDX 0x01
+#define BUCK_TARGET_VOL_MAX_IDX 0x19
+
+#define LP3971_BUCK_RAMP_REG(x) (buck_base_addr[x]+2)
+
+#define LP3971_LDO_ENABLE_REG 0x12
+#define LP3971_LDO_VOL_CONTR_BASE 0x39
+
+/* Voltage control registers:
+ LP3971_LDO1 -> LP3971_LDO_VOL_CONTR_BASE + 0
+ LP3971_LDO2 -> LP3971_LDO_VOL_CONTR_BASE + 0
+ LP3971_LDO3 -> LP3971_LDO_VOL_CONTR_BASE + 1
+ LP3971_LDO4 -> LP3971_LDO_VOL_CONTR_BASE + 1
+ LP3971_LDO5 -> LP3971_LDO_VOL_CONTR_BASE + 2
+*/
+#define LP3971_LDO_VOL_CONTR_REG(x) (LP3971_LDO_VOL_CONTR_BASE + (x >> 1))
+
+/* Voltage control registers shift:
+ LP3971_LDO1 -> 0, LP3971_LDO2 -> 4
+ LP3971_LDO3 -> 0, LP3971_LDO4 -> 4
+ LP3971_LDO5 -> 0
+*/
+#define LDO_VOL_CONTR_SHIFT(x) ((x & 1) << 2)
+#define LDO_VOL_CONTR_MASK 0x0f
+
+const static int ldo45_voltage_map[] = {
+ 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350,
+ 1400, 1500, 1800, 1900, 2500, 2800, 3000, 3300,
+};
+
+const static int ldo123_voltage_map[] = {
+ 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500,
+ 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300,
+};
+
+const static int *ldo_voltage_map[] = {
+ ldo123_voltage_map, /* LDO1 */
+ ldo123_voltage_map, /* LDO2 */
+ ldo123_voltage_map, /* LDO3 */
+ ldo45_voltage_map, /* LDO4 */
+ ldo45_voltage_map, /* LDO5 */
+};
+
+#define LDO_VOL_VALUE_MAP(x) (ldo_voltage_map[(x - LP3971_LDO1)])
+
+#define LDO_VOL_MIN_IDX 0x00
+#define LDO_VOL_MAX_IDX 0x0f
+
+static int lp3971_ldo_list_voltage(struct regulator_dev *dev, unsigned index)
+{
+ int ldo = rdev_get_id(dev) - LP3971_LDO1;
+ return 1000 * LDO_VOL_VALUE_MAP(ldo)[index];
+}
+
+static int lp3971_ldo_is_enabled(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int ldo = rdev_get_id(dev) - LP3971_LDO1;
+ u16 mask = 1 << (1 + ldo);
+ u16 val;
+
+ val = lp3971_reg_read(lp3971, LP3971_LDO_ENABLE_REG);
+ return (val & mask) != 0;
+}
+
+static int lp3971_ldo_enable(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int ldo = rdev_get_id(dev) - LP3971_LDO1;
+ u16 mask = 1 << (1 + ldo);
+
+ return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, mask);
+}
+
+static int lp3971_ldo_disable(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int ldo = rdev_get_id(dev) - LP3971_LDO1;
+ u16 mask = 1 << (1 + ldo);
+
+ return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, 0);
+}
+
+static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int ldo = rdev_get_id(dev) - LP3971_LDO1;
+ u16 val, reg;
+
+ reg = lp3971_reg_read(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo));
+ val = (reg >> LDO_VOL_CONTR_SHIFT(ldo)) & LDO_VOL_CONTR_MASK;
+
+ return 1000 * LDO_VOL_VALUE_MAP(ldo)[val];
+}
+
+static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
+ int min_uV, int max_uV)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int ldo = rdev_get_id(dev) - LP3971_LDO1;
+ int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
+ const int *vol_map = LDO_VOL_VALUE_MAP(ldo);
+ u16 val;
+
+ if (min_vol < vol_map[LDO_VOL_MIN_IDX] ||
+ min_vol > vol_map[LDO_VOL_MAX_IDX])
+ return -EINVAL;
+
+ for (val = LDO_VOL_MIN_IDX; val <= LDO_VOL_MAX_IDX; val++)
+ if (vol_map[val] >= min_vol)
+ break;
+
+ if (vol_map[val] > max_vol)
+ return -EINVAL;
+
+ return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
+ LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), val);
+}
+
+static struct regulator_ops lp3971_ldo_ops = {
+ .list_voltage = lp3971_ldo_list_voltage,
+ .is_enabled = lp3971_ldo_is_enabled,
+ .enable = lp3971_ldo_enable,
+ .disable = lp3971_ldo_disable,
+ .get_voltage = lp3971_ldo_get_voltage,
+ .set_voltage = lp3971_ldo_set_voltage,
+};
+
+static int lp3971_dcdc_list_voltage(struct regulator_dev *dev, unsigned index)
+{
+ return 1000 * buck_voltage_map[index];
+}
+
+static int lp3971_dcdc_is_enabled(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int buck = rdev_get_id(dev) - LP3971_DCDC1;
+ u16 mask = 1 << (buck * 2);
+ u16 val;
+
+ val = lp3971_reg_read(lp3971, LP3971_BUCK_VOL_ENABLE_REG);
+ return (val & mask) != 0;
+}
+
+static int lp3971_dcdc_enable(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int buck = rdev_get_id(dev) - LP3971_DCDC1;
+ u16 mask = 1 << (buck * 2);
+
+ return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, mask);
+}
+
+static int lp3971_dcdc_disable(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int buck = rdev_get_id(dev) - LP3971_DCDC1;
+ u16 mask = 1 << (buck * 2);
+
+ return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, 0);
+}
+
+static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int buck = rdev_get_id(dev) - LP3971_DCDC1;
+ u16 reg;
+ int val;
+
+ reg = lp3971_reg_read(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck));
+ reg &= BUCK_TARGET_VOL_MASK;
+
+ if (reg <= BUCK_TARGET_VOL_MAX_IDX)
+ val = 1000 * buck_voltage_map[reg];
+ else {
+ val = 0;
+ dev_warn(&dev->dev, "chip reported incorrect voltage value.\n");
+ }
+
+ return val;
+}
+
+static int lp3971_dcdc_set_voltage(struct regulator_dev *dev,
+ int min_uV, int max_uV)
+{
+ struct lp3971 *lp3971 = rdev_get_drvdata(dev);
+ int buck = rdev_get_id(dev) - LP3971_DCDC1;
+ int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
+ const int *vol_map = buck_voltage_map;
+ u16 val;
+ int ret;
+
+ if (min_vol < vol_map[BUCK_TARGET_VOL_MIN_IDX] ||
+ min_vol > vol_map[BUCK_TARGET_VOL_MAX_IDX])
+ return -EINVAL;
+
+ for (val = BUCK_TARGET_VOL_MIN_IDX; val <= BUCK_TARGET_VOL_MAX_IDX;
+ val++)
+ if (vol_map[val] >= min_vol)
+ break;
+
+ if (vol_map[val] > max_vol)
+ return -EINVAL;
+
+ ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck),
+ BUCK_TARGET_VOL_MASK, val);
+ if (ret)
+ return ret;
+
+ ret = lp3971_set_bits(lp3971, LP3971_BUCK_VOL_CHANGE_REG,
+ BUCK_VOL_CHANGE_FLAG_MASK << BUCK_VOL_CHANGE_SHIFT(buck),
+ BUCK_VOL_CHANGE_FLAG_GO << BUCK_VOL_CHANGE_SHIFT(buck));
+ if (ret)
+ return ret;
+
+ return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_CHANGE_REG,
+ BUCK_VOL_CHANGE_FLAG_MASK << BUCK_VOL_CHANGE_SHIFT(buck),
+ 0 << BUCK_VOL_CHANGE_SHIFT(buck));
+}
+
+static struct regulator_ops lp3971_dcdc_ops = {
+ .list_voltage = lp3971_dcdc_list_voltage,
+ .is_enabled = lp3971_dcdc_is_enabled,
+ .enable = lp3971_dcdc_enable,
+ .disable = lp3971_dcdc_disable,
+ .get_voltage = lp3971_dcdc_get_voltage,
+ .set_voltage = lp3971_dcdc_set_voltage,
+};
+
+static struct regulator_desc regulators[] = {
+ {
+ .name = "LDO1",
+ .id = LP3971_LDO1,
+ .ops = &lp3971_ldo_ops,
+ .n_voltages = ARRAY_SIZE(ldo123_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "LDO2",
+ .id = LP3971_LDO2,
+ .ops = &lp3971_ldo_ops,
+ .n_voltages = ARRAY_SIZE(ldo123_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "LDO3",
+ .id = LP3971_LDO3,
+ .ops = &lp3971_ldo_ops,
+ .n_voltages = ARRAY_SIZE(ldo123_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "LDO4",
+ .id = LP3971_LDO4,
+ .ops = &lp3971_ldo_ops,
+ .n_voltages = ARRAY_SIZE(ldo45_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "LDO5",
+ .id = LP3971_LDO5,
+ .ops = &lp3971_ldo_ops,
+ .n_voltages = ARRAY_SIZE(ldo45_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "DCDC1",
+ .id = LP3971_DCDC1,
+ .ops = &lp3971_dcdc_ops,
+ .n_voltages = ARRAY_SIZE(buck_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "DCDC2",
+ .id = LP3971_DCDC2,
+ .ops = &lp3971_dcdc_ops,
+ .n_voltages = ARRAY_SIZE(buck_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "DCDC3",
+ .id = LP3971_DCDC3,
+ .ops = &lp3971_dcdc_ops,
+ .n_voltages = ARRAY_SIZE(buck_voltage_map),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+};
+
+static int lp3971_i2c_read(struct i2c_client *i2c, char reg, int count,
+ u16 *dest)
+{
+ int ret;
+
+ if (count != 1)
+ return -EIO;
+ ret = i2c_smbus_read_byte_data(i2c, reg);
+ if (ret < 0 || count != 1)
+ return -EIO;
+
+ *dest = ret;
+ return 0;
+}
+
+static int lp3971_i2c_write(struct i2c_client *i2c, char reg, int count,
+ const u16 *src)
+{
+ int ret;
+
+ if (count != 1)
+ return -EIO;
+ ret = i2c_smbus_write_byte_data(i2c, reg, *src);
+ if (ret >= 0)
+ return 0;
+
+ return ret;
+}
+
+static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg)
+{
+ u16 val = 0;
+
+ mutex_lock(&lp3971->io_lock);
+
+ lp3971_i2c_read(lp3971->i2c, reg, 1, &val);
+
+ dev_dbg(lp3971->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg,
+ (unsigned)val&0xff);
+
+ mutex_unlock(&lp3971->io_lock);
+
+ return val & 0xff;
+}
+
+static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val)
+{
+ u16 tmp;
+ int ret;
+
+ mutex_lock(&lp3971->io_lock);
+
+ ret = lp3971_i2c_read(lp3971->i2c, reg, 1, &tmp);
+ tmp = (tmp & ~mask) | val;
+ if (ret == 0) {
+ ret = lp3971_i2c_write(lp3971->i2c, reg, 1, &tmp);
+ dev_dbg(lp3971->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg,
+ (unsigned)val&0xff);
+ }
+ mutex_unlock(&lp3971->io_lock);
+
+ return ret;
+}
+
+static int setup_regulators(struct lp3971 *lp3971,
+ struct lp3971_platform_data *pdata)
+{
+ int i, err;
+ int num_regulators = pdata->num_regulators;
+ lp3971->num_regulators = num_regulators;
+ lp3971->rdev = kzalloc(sizeof(struct regulator_dev *) * num_regulators,
+ GFP_KERNEL);
+
+ /* Instantiate the regulators */
+ for (i = 0; i < num_regulators; i++) {
+ int id = pdata->regulators[i].id;
+ lp3971->rdev[i] = regulator_register(&regulators[id],
+ lp3971->dev, pdata->regulators[i].initdata, lp3971);
+
+ err = IS_ERR(lp3971->rdev[i]);
+ if (err) {
+ dev_err(lp3971->dev, "regulator init failed: %d\n",
+ err);
+ goto error;
+ }
+ }
+
+ return 0;
+error:
+ for (i = 0; i < num_regulators; i++)
+ if (lp3971->rdev[i])
+ regulator_unregister(lp3971->rdev[i]);
+ kfree(lp3971->rdev);
+ lp3971->rdev = NULL;
+ return err;
+}
+
+static int __devinit lp3971_i2c_probe(struct i2c_client *i2c,
+ const struct i2c_device_id *id)
+{
+ struct lp3971 *lp3971;
+ struct lp3971_platform_data *pdata = i2c->dev.platform_data;
+ int ret;
+ u16 val;
+
+ lp3971 = kzalloc(sizeof(struct lp3971), GFP_KERNEL);
+ if (lp3971 == NULL) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ lp3971->i2c = i2c;
+ lp3971->dev = &i2c->dev;
+ i2c_set_clientdata(i2c, lp3971);
+
+ mutex_init(&lp3971->io_lock);
+
+ /* Detect LP3971 */
+ ret = lp3971_i2c_read(i2c, LP3971_SYS_CONTROL1_REG, 1, &val);
+ if (ret == 0 && (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL)
+ ret = -ENODEV;
+ if (ret < 0) {
+ dev_err(&i2c->dev, "failed to detect device\n");
+ goto err_detect;
+ }
+
+ if (pdata) {
+ ret = setup_regulators(lp3971, pdata);
+ if (ret < 0)
+ goto err_detect;
+ } else
+ dev_warn(lp3971->dev, "No platform init data supplied\n");
+
+ return 0;
+
+err_detect:
+ i2c_set_clientdata(i2c, NULL);
+ kfree(lp3971);
+err:
+ return ret;
+}
+
+static int __devexit lp3971_i2c_remove(struct i2c_client *i2c)
+{
+ struct lp3971 *lp3971 = i2c_get_clientdata(i2c);
+ int i;
+ for (i = 0; i < lp3971->num_regulators; i++)
+ if (lp3971->rdev[i])
+ regulator_unregister(lp3971->rdev[i]);
+ kfree(lp3971->rdev);
+ i2c_set_clientdata(i2c, NULL);
+ kfree(lp3971);
+
+ return 0;
+}
+
+static const struct i2c_device_id lp3971_i2c_id[] = {
+ { "lp3971", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id);
+
+static struct i2c_driver lp3971_i2c_driver = {
+ .driver = {
+ .name = "LP3971",
+ .owner = THIS_MODULE,
+ },
+ .probe = lp3971_i2c_probe,
+ .remove = __devexit_p(lp3971_i2c_remove),
+ .id_table = lp3971_i2c_id,
+};
+
+static int __init lp3971_module_init(void)
+{
+ int ret = -ENODEV;
+
+ ret = i2c_add_driver(&lp3971_i2c_driver);
+ if (ret != 0)
+ pr_err("Failed to register I2C driver: %d\n", ret);
+
+ return ret;
+}
+module_init(lp3971_module_init);
+
+static void __exit lp3971_module_exit(void)
+{
+ i2c_del_driver(&lp3971_i2c_driver);
+}
+module_exit(lp3971_module_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Marek Szyprowski <m.szyprowski@samsung.com>");
+MODULE_DESCRIPTION("LP3971 PMIC driver");
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
new file mode 100644
index 000000000000..bbbb55fcfe8c
--- /dev/null
+++ b/drivers/regulator/max1586.c
@@ -0,0 +1,249 @@
+/*
+ * max1586.c -- Voltage and current regulation for the Maxim 1586
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/max1586.h>
+
+#define MAX1586_V3_MAX_VSEL 31
+#define MAX1586_V6_MAX_VSEL 3
+
+#define MAX1586_V3_MIN_UV 700000
+#define MAX1586_V3_MAX_UV 1475000
+#define MAX1586_V3_STEP_UV 25000
+
+#define MAX1586_V6_MIN_UV 0
+#define MAX1586_V6_MAX_UV 3000000
+
+#define I2C_V3_SELECT (0 << 5)
+#define I2C_V6_SELECT (1 << 5)
+
+/*
+ * V3 voltage
+ * On I2C bus, sending a "x" byte to the max1586 means :
+ * set V3 to 0.700V + (x & 0x1f) * 0.025V
+ */
+static int max1586_v3_calc_voltage(unsigned selector)
+{
+ return MAX1586_V3_MIN_UV + (MAX1586_V3_STEP_UV * selector);
+}
+
+static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+ struct i2c_client *client = rdev_get_drvdata(rdev);
+ unsigned selector;
+ u8 v3_prog;
+
+ if (min_uV < MAX1586_V3_MIN_UV || min_uV > MAX1586_V3_MAX_UV)
+ return -EINVAL;
+ if (max_uV < MAX1586_V3_MIN_UV || max_uV > MAX1586_V3_MAX_UV)
+ return -EINVAL;
+
+ selector = (min_uV - MAX1586_V3_MIN_UV) / MAX1586_V3_STEP_UV;
+ if (max1586_v3_calc_voltage(selector) > max_uV)
+ return -EINVAL;
+
+ dev_dbg(&client->dev, "changing voltage v3 to %dmv\n",
+ max1586_v3_calc_voltage(selector) / 1000);
+
+ v3_prog = I2C_V3_SELECT | (u8) selector;
+ return i2c_smbus_write_byte(client, v3_prog);
+}
+
+static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector)
+{
+ if (selector > MAX1586_V3_MAX_VSEL)
+ return -EINVAL;
+ return max1586_v3_calc_voltage(selector);
+}
+
+/*
+ * V6 voltage
+ * On I2C bus, sending a "x" byte to the max1586 means :
+ * set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
+ * As regulator framework doesn't accept voltages to be 0V, we use 1uV.
+ */
+static int max1586_v6_calc_voltage(unsigned selector)
+{
+ static int voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
+
+ return voltages_uv[selector];
+}
+
+static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+ struct i2c_client *client = rdev_get_drvdata(rdev);
+ unsigned selector;
+ u8 v6_prog;
+
+ if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV)
+ return -EINVAL;
+ if (max_uV < MAX1586_V6_MIN_UV || max_uV > MAX1586_V6_MAX_UV)
+ return -EINVAL;
+
+ if (min_uV >= 3000000)
+ selector = 3;
+ if (min_uV < 3000000)
+ selector = 2;
+ if (min_uV < 2500000)
+ selector = 1;
+ if (min_uV < 1800000)
+ selector = 0;
+
+ if (max1586_v6_calc_voltage(selector) > max_uV)
+ return -EINVAL;
+
+ dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
+ max1586_v6_calc_voltage(selector) / 1000);
+
+ v6_prog = I2C_V6_SELECT | (u8) selector;
+ return i2c_smbus_write_byte(client, v6_prog);
+}
+
+static int max1586_v6_list(struct regulator_dev *rdev, unsigned selector)
+{
+ if (selector > MAX1586_V6_MAX_VSEL)
+ return -EINVAL;
+ return max1586_v6_calc_voltage(selector);
+}
+
+/*
+ * The Maxim 1586 controls V3 and V6 voltages, but offers no way of reading back
+ * the set up value.
+ */
+static struct regulator_ops max1586_v3_ops = {
+ .set_voltage = max1586_v3_set,
+ .list_voltage = max1586_v3_list,
+};
+
+static struct regulator_ops max1586_v6_ops = {
+ .set_voltage = max1586_v6_set,
+ .list_voltage = max1586_v6_list,
+};
+
+static struct regulator_desc max1586_reg[] = {
+ {
+ .name = "Output_V3",
+ .id = MAX1586_V3,
+ .ops = &max1586_v3_ops,
+ .type = REGULATOR_VOLTAGE,
+ .n_voltages = MAX1586_V3_MAX_VSEL + 1,
+ .owner = THIS_MODULE,
+ },
+ {
+ .name = "Output_V6",
+ .id = MAX1586_V6,
+ .ops = &max1586_v6_ops,
+ .type = REGULATOR_VOLTAGE,
+ .n_voltages = MAX1586_V6_MAX_VSEL + 1,
+ .owner = THIS_MODULE,
+ },
+};
+
+static int max1586_pmic_probe(struct i2c_client *client,
+ const struct i2c_device_id *i2c_id)
+{
+ struct regulator_dev **rdev;
+ struct max1586_platform_data *pdata = client->dev.platform_data;
+ int i, id, ret = 0;
+
+ rdev = kzalloc(sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
+ GFP_KERNEL);
+ if (!rdev)
+ return -ENOMEM;
+
+ ret = -EINVAL;
+ for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
+ id = pdata->subdevs[i].id;
+ if (!pdata->subdevs[i].platform_data)
+ continue;
+ if (id < MAX1586_V3 || id > MAX1586_V6) {
+ dev_err(&client->dev, "invalid regulator id %d\n", id);
+ goto err;
+ }
+ rdev[i] = regulator_register(&max1586_reg[id], &client->dev,
+ pdata->subdevs[i].platform_data,
+ client);
+ if (IS_ERR(rdev[i])) {
+ ret = PTR_ERR(rdev[i]);
+ dev_err(&client->dev, "failed to register %s\n",
+ max1586_reg[id].name);
+ goto err;
+ }
+ }
+
+ i2c_set_clientdata(client, rdev);
+ dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n");
+ return 0;
+
+err:
+ while (--i >= 0)
+ regulator_unregister(rdev[i]);
+ kfree(rdev);
+ return ret;
+}
+
+static int max1586_pmic_remove(struct i2c_client *client)
+{
+ struct regulator_dev **rdev = i2c_get_clientdata(client);
+ int i;
+
+ for (i = 0; i <= MAX1586_V6; i++)
+ if (rdev[i])
+ regulator_unregister(rdev[i]);
+ kfree(rdev);
+ i2c_set_clientdata(client, NULL);
+
+ return 0;
+}
+
+static const struct i2c_device_id max1586_id[] = {
+ { "max1586", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, max1586_id);
+
+static struct i2c_driver max1586_pmic_driver = {
+ .probe = max1586_pmic_probe,
+ .remove = max1586_pmic_remove,
+ .driver = {
+ .name = "max1586",
+ },
+ .id_table = max1586_id,
+};
+
+static int __init max1586_pmic_init(void)
+{
+ return i2c_add_driver(&max1586_pmic_driver);
+}
+subsys_initcall(max1586_pmic_init);
+
+static void __exit max1586_pmic_exit(void)
+{
+ i2c_del_driver(&max1586_pmic_driver);
+}
+module_exit(max1586_pmic_exit);
+
+/* Module information */
+MODULE_DESCRIPTION("MAXIM 1586 voltage regulator driver");
+MODULE_AUTHOR("Robert Jarzmik");
+MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
index cd761d85c8fd..8e14900eb686 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -316,7 +316,7 @@ static int __init pcf50633_regulator_init(void)
{
return platform_driver_register(&pcf50633_regulator_driver);
}
-module_init(pcf50633_regulator_init);
+subsys_initcall(pcf50633_regulator_init);
static void __exit pcf50633_regulator_exit(void)
{
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
new file mode 100644
index 000000000000..06d2fa96a8b4
--- /dev/null
+++ b/drivers/regulator/userspace-consumer.c
@@ -0,0 +1,200 @@
+/*
+ * userspace-consumer.c
+ *
+ * Copyright 2009 CompuLab, Ltd.
+ *
+ * Author: Mike Rapoport <mike@compulab.co.il>
+ *
+ * Based of virtual consumer driver:
+ * Copyright 2008 Wolfson Microelectronics PLC.
+ * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ */
+
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+#include <linux/regulator/userspace-consumer.h>
+
+struct userspace_consumer_data {
+ const char *name;
+
+ struct mutex lock;
+ bool enabled;
+
+ int num_supplies;
+ struct regulator_bulk_data *supplies;
+};
+
+static ssize_t reg_show_name(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct userspace_consumer_data *data = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%s\n", data->name);
+}
+
+static ssize_t reg_show_state(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct userspace_consumer_data *data = dev_get_drvdata(dev);
+
+ if (data->enabled)
+ return sprintf(buf, "enabled\n");
+
+ return sprintf(buf, "disabled\n");
+}
+
+static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct userspace_consumer_data *data = dev_get_drvdata(dev);
+ bool enabled;
+ int ret;
+
+ /*
+ * sysfs_streq() doesn't need the \n's, but we add them so the strings
+ * will be shared with show_state(), above.
+ */
+ if (sysfs_streq(buf, "enabled\n") || sysfs_streq(buf, "1"))
+ enabled = true;
+ else if (sysfs_streq(buf, "disabled\n") || sysfs_streq(buf, "0"))
+ enabled = false;
+ else {
+ dev_err(dev, "Configuring invalid mode\n");
+ return count;
+ }
+
+ mutex_lock(&data->lock);
+ if (enabled != data->enabled) {
+ if (enabled)
+ ret = regulator_bulk_enable(data->num_supplies,
+ data->supplies);
+ else
+ ret = regulator_bulk_disable(data->num_supplies,
+ data->supplies);
+
+ if (ret == 0)
+ data->enabled = enabled;
+ else
+ dev_err(dev, "Failed to configure state: %d\n", ret);
+ }
+ mutex_unlock(&data->lock);
+
+ return count;
+}
+
+static DEVICE_ATTR(name, 0444, reg_show_name, NULL);
+static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state);
+
+static struct device_attribute *attributes[] = {
+ &dev_attr_name,
+ &dev_attr_state,
+};
+
+static int regulator_userspace_consumer_probe(struct platform_device *pdev)
+{
+ struct regulator_userspace_consumer_data *pdata;
+ struct userspace_consumer_data *drvdata;
+ int ret, i;
+
+ pdata = pdev->dev.platform_data;
+ if (!pdata)
+ return -EINVAL;
+
+ drvdata = kzalloc(sizeof(struct userspace_consumer_data), GFP_KERNEL);
+ if (drvdata == NULL)
+ return -ENOMEM;
+
+ drvdata->name = pdata->name;
+ drvdata->num_supplies = pdata->num_supplies;
+ drvdata->supplies = pdata->supplies;
+
+ mutex_init(&drvdata->lock);
+
+ ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
+ drvdata->supplies);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret);
+ goto err_alloc_supplies;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(attributes); i++) {
+ ret = device_create_file(&pdev->dev, attributes[i]);
+ if (ret != 0)
+ goto err_create_attrs;
+ }
+
+ if (pdata->init_on)
+ ret = regulator_bulk_enable(drvdata->num_supplies,
+ drvdata->supplies);
+
+ drvdata->enabled = pdata->init_on;
+
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to set initial state: %d\n", ret);
+ goto err_create_attrs;
+ }
+
+ platform_set_drvdata(pdev, drvdata);
+
+ return 0;
+
+err_create_attrs:
+ for (i = 0; i < ARRAY_SIZE(attributes); i++)
+ device_remove_file(&pdev->dev, attributes[i]);
+
+ regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
+
+err_alloc_supplies:
+ kfree(drvdata);
+ return ret;
+}
+
+static int regulator_userspace_consumer_remove(struct platform_device *pdev)
+{
+ struct userspace_consumer_data *data = platform_get_drvdata(pdev);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(attributes); i++)
+ device_remove_file(&pdev->dev, attributes[i]);
+
+ if (data->enabled)
+ regulator_bulk_disable(data->num_supplies, data->supplies);
+
+ regulator_bulk_free(data->num_supplies, data->supplies);
+ kfree(data);
+
+ return 0;
+}
+
+static struct platform_driver regulator_userspace_consumer_driver = {
+ .probe = regulator_userspace_consumer_probe,
+ .remove = regulator_userspace_consumer_remove,
+ .driver = {
+ .name = "reg-userspace-consumer",
+ },
+};
+
+
+static int __init regulator_userspace_consumer_init(void)
+{
+ return platform_driver_register(&regulator_userspace_consumer_driver);
+}
+module_init(regulator_userspace_consumer_init);
+
+static void __exit regulator_userspace_consumer_exit(void)
+{
+ platform_driver_unregister(&regulator_userspace_consumer_driver);
+}
+module_exit(regulator_userspace_consumer_exit);
+
+MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
+MODULE_DESCRIPTION("Userspace consumer for voltage and current regulators");
+MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index 71403fa3ffa1..e7db5664722e 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -347,3 +347,4 @@ module_exit(regulator_virtual_consumer_exit);
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
MODULE_DESCRIPTION("Virtual regulator consumer");
MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:reg-virt-consumer");
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 771eca1066b5..17a00b0fafd1 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1570,3 +1570,4 @@ module_exit(wm8350_regulator_exit);
MODULE_AUTHOR("Liam Girdwood");
MODULE_DESCRIPTION("WM8350 voltage and current regulator driver");
MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:wm8350-regulator");
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 157426029071..d9a2c988c6e7 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -320,7 +320,7 @@ static int __devinit wm8400_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
- pdev->dev.platform_data, pdev->dev.driver_data);
+ pdev->dev.platform_data, dev_get_drvdata(&pdev->dev));
if (IS_ERR(rdev))
return PTR_ERR(rdev);
@@ -359,7 +359,7 @@ static struct platform_driver wm8400_regulator_driver = {
int wm8400_register_regulator(struct device *dev, int reg,
struct regulator_init_data *initdata)
{
- struct wm8400 *wm8400 = dev->driver_data;
+ struct wm8400 *wm8400 = dev_get_drvdata(dev);
if (wm8400->regulators[reg].name)
return -EBUSY;
@@ -369,8 +369,8 @@ int wm8400_register_regulator(struct device *dev, int reg,
wm8400->regulators[reg].name = "wm8400-regulator";
wm8400->regulators[reg].id = reg;
wm8400->regulators[reg].dev.parent = dev;
- wm8400->regulators[reg].dev.driver_data = wm8400;
wm8400->regulators[reg].dev.platform_data = initdata;
+ dev_set_drvdata(&wm8400->regulators[reg].dev, wm8400);
return platform_device_register(&wm8400->regulators[reg]);
}
@@ -380,7 +380,7 @@ static int __init wm8400_regulator_init(void)
{
return platform_driver_register(&wm8400_regulator_driver);
}
-module_init(wm8400_regulator_init);
+subsys_initcall(wm8400_regulator_init);
static void __exit wm8400_regulator_exit(void)
{
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4e9851fc1746..1f27cedc452c 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -491,6 +491,15 @@ config RTC_DRV_M48T59
This driver can also be built as a module, if so, the module
will be called "rtc-m48t59".
+config RTC_DRV_MSM6242
+ tristate "Oki MSM6242"
+ help
+ If you say yes here you get support for the Oki MSM6242
+ timekeeping chip. It is used in some Amiga models (e.g. A2000).
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-msm6242.
+
config RTC_DRV_BQ4802
tristate "TI BQ4802"
help
@@ -500,6 +509,16 @@ config RTC_DRV_BQ4802
This driver can also be built as a module. If so, the module
will be called rtc-bq4802.
+config RTC_DRV_RP5C01
+ tristate "Ricoh RP5C01"
+ help
+ If you say yes here you get support for the Ricoh RP5C01
+ timekeeping chip. It is used in some Amiga models (e.g. A3000
+ and A4000).
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-rp5c01.
+
config RTC_DRV_V3020
tristate "EM Microelectronic V3020"
help
@@ -692,7 +711,7 @@ config RTC_DRV_GENERIC
tristate "Generic RTC support"
# Please consider writing a new RTC driver instead of using the generic
# RTC abstraction
- depends on PARISC || M68K || PPC
+ depends on PARISC || M68K || PPC || SUPERH32
help
Say Y or M here to enable RTC support on systems using the generic
RTC abstraction. If you do not know what you are doing, you should
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 6c0639a14f09..ab0275cae87f 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o
obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o
obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o
obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o
obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o
obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
@@ -59,6 +60,7 @@ obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o
obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o
obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o
+obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o
obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index f7a3283dd029..551332e4ed02 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -12,32 +12,56 @@
#include <linux/module.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>
-#include <mach/hardware.h>
+#include <linux/io.h>
+
+#define EP93XX_RTC_DATA 0x000
+#define EP93XX_RTC_MATCH 0x004
+#define EP93XX_RTC_STATUS 0x008
+#define EP93XX_RTC_STATUS_INTR (1<<0)
+#define EP93XX_RTC_LOAD 0x00C
+#define EP93XX_RTC_CONTROL 0x010
+#define EP93XX_RTC_CONTROL_MIE (1<<0)
+#define EP93XX_RTC_SWCOMP 0x108
+#define EP93XX_RTC_SWCOMP_DEL_MASK 0x001f0000
+#define EP93XX_RTC_SWCOMP_DEL_SHIFT 16
+#define EP93XX_RTC_SWCOMP_INT_MASK 0x0000ffff
+#define EP93XX_RTC_SWCOMP_INT_SHIFT 0
+
+#define DRV_VERSION "0.3"
-#define EP93XX_RTC_REG(x) (EP93XX_RTC_BASE + (x))
-#define EP93XX_RTC_DATA EP93XX_RTC_REG(0x0000)
-#define EP93XX_RTC_LOAD EP93XX_RTC_REG(0x000C)
-#define EP93XX_RTC_SWCOMP EP93XX_RTC_REG(0x0108)
-
-#define DRV_VERSION "0.2"
+/*
+ * struct device dev.platform_data is used to store our private data
+ * because struct rtc_device does not have a variable to hold it.
+ */
+struct ep93xx_rtc {
+ void __iomem *mmio_base;
+};
-static int ep93xx_get_swcomp(struct device *dev, unsigned short *preload,
+static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
unsigned short *delete)
{
- unsigned short comp = __raw_readl(EP93XX_RTC_SWCOMP);
+ struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
+ unsigned long comp;
+
+ comp = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP);
if (preload)
- *preload = comp & 0xffff;
+ *preload = (comp & EP93XX_RTC_SWCOMP_INT_MASK)
+ >> EP93XX_RTC_SWCOMP_INT_SHIFT;
if (delete)
- *delete = (comp >> 16) & 0x1f;
+ *delete = (comp & EP93XX_RTC_SWCOMP_DEL_MASK)
+ >> EP93XX_RTC_SWCOMP_DEL_SHIFT;
return 0;
}
static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
- unsigned long time = __raw_readl(EP93XX_RTC_DATA);
+ struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
+ unsigned long time;
+
+ time = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
rtc_time_to_tm(time, tm);
return 0;
@@ -45,7 +69,9 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs)
{
- __raw_writel(secs + 1, EP93XX_RTC_LOAD);
+ struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
+
+ __raw_writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD);
return 0;
}
@@ -53,7 +79,7 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
{
unsigned short preload, delete;
- ep93xx_get_swcomp(dev, &preload, &delete);
+ ep93xx_rtc_get_swcomp(dev, &preload, &delete);
seq_printf(seq, "preload\t\t: %d\n", preload);
seq_printf(seq, "delete\t\t: %d\n", delete);
@@ -67,54 +93,104 @@ static const struct rtc_class_ops ep93xx_rtc_ops = {
.proc = ep93xx_rtc_proc,
};
-static ssize_t ep93xx_sysfs_show_comp_preload(struct device *dev,
+static ssize_t ep93xx_rtc_show_comp_preload(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned short preload;
- ep93xx_get_swcomp(dev, &preload, NULL);
+ ep93xx_rtc_get_swcomp(dev, &preload, NULL);
return sprintf(buf, "%d\n", preload);
}
-static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_sysfs_show_comp_preload, NULL);
+static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_rtc_show_comp_preload, NULL);
-static ssize_t ep93xx_sysfs_show_comp_delete(struct device *dev,
+static ssize_t ep93xx_rtc_show_comp_delete(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned short delete;
- ep93xx_get_swcomp(dev, NULL, &delete);
+ ep93xx_rtc_get_swcomp(dev, NULL, &delete);
return sprintf(buf, "%d\n", delete);
}
-static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_sysfs_show_comp_delete, NULL);
+static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_rtc_show_comp_delete, NULL);
-static int __devinit ep93xx_rtc_probe(struct platform_device *dev)
+static int __init ep93xx_rtc_probe(struct platform_device *pdev)
{
- struct rtc_device *rtc = rtc_device_register("ep93xx",
- &dev->dev, &ep93xx_rtc_ops, THIS_MODULE);
+ struct ep93xx_rtc *ep93xx_rtc;
+ struct resource *res;
+ struct rtc_device *rtc;
+ int err;
+
+ ep93xx_rtc = kzalloc(sizeof(struct ep93xx_rtc), GFP_KERNEL);
+ if (ep93xx_rtc == NULL)
+ return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res == NULL)
+ return -ENXIO;
+
+ res = request_mem_region(res->start, resource_size(res), pdev->name);
+ if (res == NULL)
+ return -EBUSY;
+
+ ep93xx_rtc->mmio_base = ioremap(res->start, resource_size(res));
+ if (ep93xx_rtc->mmio_base == NULL) {
+ err = -ENXIO;
+ goto fail;
+ }
+ pdev->dev.platform_data = ep93xx_rtc;
+
+ rtc = rtc_device_register(pdev->name,
+ &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
- return PTR_ERR(rtc);
+ err = PTR_ERR(rtc);
+ goto fail;
}
- platform_set_drvdata(dev, rtc);
+ platform_set_drvdata(pdev, rtc);
- device_create_file(&dev->dev, &dev_attr_comp_preload);
- device_create_file(&dev->dev, &dev_attr_comp_delete);
+ err = device_create_file(&pdev->dev, &dev_attr_comp_preload);
+ if (err)
+ goto fail;
+ err = device_create_file(&pdev->dev, &dev_attr_comp_delete);
+ if (err) {
+ device_remove_file(&pdev->dev, &dev_attr_comp_preload);
+ goto fail;
+ }
return 0;
+
+fail:
+ if (ep93xx_rtc->mmio_base) {
+ iounmap(ep93xx_rtc->mmio_base);
+ pdev->dev.platform_data = NULL;
+ }
+ release_mem_region(res->start, resource_size(res));
+ return err;
}
-static int __devexit ep93xx_rtc_remove(struct platform_device *dev)
+static int __exit ep93xx_rtc_remove(struct platform_device *pdev)
{
- struct rtc_device *rtc = platform_get_drvdata(dev);
+ struct rtc_device *rtc = platform_get_drvdata(pdev);
+ struct ep93xx_rtc *ep93xx_rtc = pdev->dev.platform_data;
+ struct resource *res;
+
+ /* cleanup sysfs */
+ device_remove_file(&pdev->dev, &dev_attr_comp_delete);
+ device_remove_file(&pdev->dev, &dev_attr_comp_preload);
+
+ rtc_device_unregister(rtc);
+
+ iounmap(ep93xx_rtc->mmio_base);
+ pdev->dev.platform_data = NULL;
- if (rtc)
- rtc_device_unregister(rtc);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ release_mem_region(res->start, resource_size(res));
- platform_set_drvdata(dev, NULL);
+ platform_set_drvdata(pdev, NULL);
return 0;
}
@@ -122,23 +198,22 @@ static int __devexit ep93xx_rtc_remove(struct platform_device *dev)
/* work with hotplug and coldplug */
MODULE_ALIAS("platform:ep93xx-rtc");
-static struct platform_driver ep93xx_rtc_platform_driver = {
+static struct platform_driver ep93xx_rtc_driver = {
.driver = {
.name = "ep93xx-rtc",
.owner = THIS_MODULE,
},
- .probe = ep93xx_rtc_probe,
- .remove = __devexit_p(ep93xx_rtc_remove),
+ .remove = __exit_p(ep93xx_rtc_remove),
};
static int __init ep93xx_rtc_init(void)
{
- return platform_driver_register(&ep93xx_rtc_platform_driver);
+ return platform_driver_probe(&ep93xx_rtc_driver, ep93xx_rtc_probe);
}
static void __exit ep93xx_rtc_exit(void)
{
- platform_driver_unregister(&ep93xx_rtc_platform_driver);
+ platform_driver_unregister(&ep93xx_rtc_driver);
}
MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c
new file mode 100644
index 000000000000..10b9b7fb4700
--- /dev/null
+++ b/drivers/rtc/rtc-msm6242.c
@@ -0,0 +1,268 @@
+/*
+ * Oki MSM6242 RTC Driver
+ *
+ * Copyright 2009 Geert Uytterhoeven
+ *
+ * Based on the A2000 TOD code in arch/m68k/amiga/config.c
+ * Copyright (C) 1993 Hamish Macdonald
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+
+enum {
+ MSM6242_SECOND1 = 0x0, /* 1-second digit register */
+ MSM6242_SECOND10 = 0x1, /* 10-second digit register */
+ MSM6242_MINUTE1 = 0x2, /* 1-minute digit register */
+ MSM6242_MINUTE10 = 0x3, /* 10-minute digit register */
+ MSM6242_HOUR1 = 0x4, /* 1-hour digit register */
+ MSM6242_HOUR10 = 0x5, /* PM/AM, 10-hour digit register */
+ MSM6242_DAY1 = 0x6, /* 1-day digit register */
+ MSM6242_DAY10 = 0x7, /* 10-day digit register */
+ MSM6242_MONTH1 = 0x8, /* 1-month digit register */
+ MSM6242_MONTH10 = 0x9, /* 10-month digit register */
+ MSM6242_YEAR1 = 0xa, /* 1-year digit register */
+ MSM6242_YEAR10 = 0xb, /* 10-year digit register */
+ MSM6242_WEEK = 0xc, /* Week register */
+ MSM6242_CD = 0xd, /* Control Register D */
+ MSM6242_CE = 0xe, /* Control Register E */
+ MSM6242_CF = 0xf, /* Control Register F */
+};
+
+#define MSM6242_HOUR10_AM (0 << 2)
+#define MSM6242_HOUR10_PM (1 << 2)
+#define MSM6242_HOUR10_HR_MASK (3 << 0)
+
+#define MSM6242_WEEK_SUNDAY 0
+#define MSM6242_WEEK_MONDAY 1
+#define MSM6242_WEEK_TUESDAY 2
+#define MSM6242_WEEK_WEDNESDAY 3
+#define MSM6242_WEEK_THURSDAY 4
+#define MSM6242_WEEK_FRIDAY 5
+#define MSM6242_WEEK_SATURDAY 6
+
+#define MSM6242_CD_30_S_ADJ (1 << 3) /* 30-second adjustment */
+#define MSM6242_CD_IRQ_FLAG (1 << 2)
+#define MSM6242_CD_BUSY (1 << 1)
+#define MSM6242_CD_HOLD (1 << 0)
+
+#define MSM6242_CE_T_MASK (3 << 2)
+#define MSM6242_CE_T_64HZ (0 << 2) /* period 1/64 second */
+#define MSM6242_CE_T_1HZ (1 << 2) /* period 1 second */
+#define MSM6242_CE_T_1MINUTE (2 << 2) /* period 1 minute */
+#define MSM6242_CE_T_1HOUR (3 << 2) /* period 1 hour */
+
+#define MSM6242_CE_ITRPT_STND (1 << 1)
+#define MSM6242_CE_MASK (1 << 0) /* STD.P output control */
+
+#define MSM6242_CF_TEST (1 << 3)
+#define MSM6242_CF_12H (0 << 2)
+#define MSM6242_CF_24H (1 << 2)
+#define MSM6242_CF_STOP (1 << 1)
+#define MSM6242_CF_REST (1 << 0) /* reset */
+
+
+struct msm6242_priv {
+ u32 __iomem *regs;
+ struct rtc_device *rtc;
+};
+
+static inline unsigned int msm6242_read(struct msm6242_priv *priv,
+ unsigned int reg)
+{
+ return __raw_readl(&priv->regs[reg]) & 0xf;
+}
+
+static inline void msm6242_write(struct msm6242_priv *priv, unsigned int val,
+ unsigned int reg)
+{
+ return __raw_writel(val, &priv->regs[reg]);
+}
+
+static inline void msm6242_set(struct msm6242_priv *priv, unsigned int val,
+ unsigned int reg)
+{
+ msm6242_write(priv, msm6242_read(priv, reg) | val, reg);
+}
+
+static inline void msm6242_clear(struct msm6242_priv *priv, unsigned int val,
+ unsigned int reg)
+{
+ msm6242_write(priv, msm6242_read(priv, reg) & ~val, reg);
+}
+
+static void msm6242_lock(struct msm6242_priv *priv)
+{
+ int cnt = 5;
+
+ msm6242_set(priv, MSM6242_CD_HOLD, MSM6242_CD);
+
+ while ((msm6242_read(priv, MSM6242_CD) & MSM6242_CD_BUSY) && cnt--) {
+ msm6242_clear(priv, MSM6242_CD_HOLD, MSM6242_CD);
+ udelay(70);
+ msm6242_set(priv, MSM6242_CD_HOLD, MSM6242_CD);
+ }
+
+ if (!cnt)
+ pr_warning("msm6242: timed out waiting for RTC (0x%x)\n",
+ msm6242_read(priv, MSM6242_CD));
+}
+
+static void msm6242_unlock(struct msm6242_priv *priv)
+{
+ msm6242_clear(priv, MSM6242_CD_HOLD, MSM6242_CD);
+}
+
+static int msm6242_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct msm6242_priv *priv = dev_get_drvdata(dev);
+
+ msm6242_lock(priv);
+
+ tm->tm_sec = msm6242_read(priv, MSM6242_SECOND10) * 10 +
+ msm6242_read(priv, MSM6242_SECOND1);
+ tm->tm_min = msm6242_read(priv, MSM6242_MINUTE10) * 10 +
+ msm6242_read(priv, MSM6242_MINUTE1);
+ tm->tm_hour = (msm6242_read(priv, MSM6242_HOUR10 & 3)) * 10 +
+ msm6242_read(priv, MSM6242_HOUR1);
+ tm->tm_mday = msm6242_read(priv, MSM6242_DAY10) * 10 +
+ msm6242_read(priv, MSM6242_DAY1);
+ tm->tm_wday = msm6242_read(priv, MSM6242_WEEK);
+ tm->tm_mon = msm6242_read(priv, MSM6242_MONTH10) * 10 +
+ msm6242_read(priv, MSM6242_MONTH1) - 1;
+ tm->tm_year = msm6242_read(priv, MSM6242_YEAR10) * 10 +
+ msm6242_read(priv, MSM6242_YEAR1);
+ if (tm->tm_year <= 69)
+ tm->tm_year += 100;
+
+ if (!(msm6242_read(priv, MSM6242_CF) & MSM6242_CF_24H)) {
+ unsigned int pm = msm6242_read(priv, MSM6242_HOUR10) &
+ MSM6242_HOUR10_PM;
+ if (!pm && tm->tm_hour == 12)
+ tm->tm_hour = 0;
+ else if (pm && tm->tm_hour != 12)
+ tm->tm_hour += 12;
+ }
+
+ msm6242_unlock(priv);
+
+ return rtc_valid_tm(tm);
+}
+
+static int msm6242_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct msm6242_priv *priv = dev_get_drvdata(dev);
+
+ msm6242_lock(priv);
+
+ msm6242_write(priv, tm->tm_sec / 10, MSM6242_SECOND10);
+ msm6242_write(priv, tm->tm_sec % 10, MSM6242_SECOND1);
+ msm6242_write(priv, tm->tm_min / 10, MSM6242_MINUTE10);
+ msm6242_write(priv, tm->tm_min % 10, MSM6242_MINUTE1);
+ if (msm6242_read(priv, MSM6242_CF) & MSM6242_CF_24H)
+ msm6242_write(priv, tm->tm_hour / 10, MSM6242_HOUR10);
+ else if (tm->tm_hour >= 12)
+ msm6242_write(priv, MSM6242_HOUR10_PM + (tm->tm_hour - 12) / 10,
+ MSM6242_HOUR10);
+ else
+ msm6242_write(priv, tm->tm_hour / 10, MSM6242_HOUR10);
+ msm6242_write(priv, tm->tm_hour % 10, MSM6242_HOUR1);
+ msm6242_write(priv, tm->tm_mday / 10, MSM6242_DAY10);
+ msm6242_write(priv, tm->tm_mday % 10, MSM6242_DAY1);
+ if (tm->tm_wday != -1)
+ msm6242_write(priv, tm->tm_wday, MSM6242_WEEK);
+ msm6242_write(priv, (tm->tm_mon + 1) / 10, MSM6242_MONTH10);
+ msm6242_write(priv, (tm->tm_mon + 1) % 10, MSM6242_MONTH1);
+ if (tm->tm_year >= 100)
+ tm->tm_year -= 100;
+ msm6242_write(priv, tm->tm_year / 10, MSM6242_YEAR10);
+ msm6242_write(priv, tm->tm_year % 10, MSM6242_YEAR1);
+
+ msm6242_unlock(priv);
+ return 0;
+}
+
+static const struct rtc_class_ops msm6242_rtc_ops = {
+ .read_time = msm6242_read_time,
+ .set_time = msm6242_set_time,
+};
+
+static int __init msm6242_rtc_probe(struct platform_device *dev)
+{
+ struct resource *res;
+ struct msm6242_priv *priv;
+ struct rtc_device *rtc;
+ int error;
+
+ res = platform_get_resource(dev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->regs = ioremap(res->start, resource_size(res));
+ if (!priv->regs) {
+ error = -ENOMEM;
+ goto out_free_priv;
+ }
+
+ rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops,
+ THIS_MODULE);
+ if (IS_ERR(rtc)) {
+ error = PTR_ERR(rtc);
+ goto out_unmap;
+ }
+
+ priv->rtc = rtc;
+ platform_set_drvdata(dev, priv);
+ return 0;
+
+out_unmap:
+ iounmap(priv->regs);
+out_free_priv:
+ kfree(priv);
+ return error;
+}
+
+static int __exit msm6242_rtc_remove(struct platform_device *dev)
+{
+ struct msm6242_priv *priv = platform_get_drvdata(dev);
+
+ rtc_device_unregister(priv->rtc);
+ iounmap(priv->regs);
+ kfree(priv);
+ return 0;
+}
+
+static struct platform_driver msm6242_rtc_driver = {
+ .driver = {
+ .name = "rtc-msm6242",
+ .owner = THIS_MODULE,
+ },
+ .remove = __exit_p(msm6242_rtc_remove),
+};
+
+static int __init msm6242_rtc_init(void)
+{
+ return platform_driver_probe(&msm6242_rtc_driver, msm6242_rtc_probe);
+}
+
+static void __exit msm6242_rtc_fini(void)
+{
+ platform_driver_unregister(&msm6242_rtc_driver);
+}
+
+module_init(msm6242_rtc_init);
+module_exit(msm6242_rtc_fini);
+
+MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Oki MSM6242 RTC driver");
+MODULE_ALIAS("platform:rtc-msm6242");
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c
new file mode 100644
index 000000000000..e1313feb060f
--- /dev/null
+++ b/drivers/rtc/rtc-rp5c01.c
@@ -0,0 +1,222 @@
+/*
+ * Ricoh RP5C01 RTC Driver
+ *
+ * Copyright 2009 Geert Uytterhoeven
+ *
+ * Based on the A3000 TOD code in arch/m68k/amiga/config.c
+ * Copyright (C) 1993 Hamish Macdonald
+ */
+
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+
+enum {
+ RP5C01_1_SECOND = 0x0, /* MODE 00 */
+ RP5C01_10_SECOND = 0x1, /* MODE 00 */
+ RP5C01_1_MINUTE = 0x2, /* MODE 00 and MODE 01 */
+ RP5C01_10_MINUTE = 0x3, /* MODE 00 and MODE 01 */
+ RP5C01_1_HOUR = 0x4, /* MODE 00 and MODE 01 */
+ RP5C01_10_HOUR = 0x5, /* MODE 00 and MODE 01 */
+ RP5C01_DAY_OF_WEEK = 0x6, /* MODE 00 and MODE 01 */
+ RP5C01_1_DAY = 0x7, /* MODE 00 and MODE 01 */
+ RP5C01_10_DAY = 0x8, /* MODE 00 and MODE 01 */
+ RP5C01_1_MONTH = 0x9, /* MODE 00 */
+ RP5C01_10_MONTH = 0xa, /* MODE 00 */
+ RP5C01_1_YEAR = 0xb, /* MODE 00 */
+ RP5C01_10_YEAR = 0xc, /* MODE 00 */
+
+ RP5C01_12_24_SELECT = 0xa, /* MODE 01 */
+ RP5C01_LEAP_YEAR = 0xb, /* MODE 01 */
+
+ RP5C01_MODE = 0xd, /* all modes */
+ RP5C01_TEST = 0xe, /* all modes */
+ RP5C01_RESET = 0xf, /* all modes */
+};
+
+#define RP5C01_12_24_SELECT_12 (0 << 0)
+#define RP5C01_12_24_SELECT_24 (1 << 0)
+
+#define RP5C01_10_HOUR_AM (0 << 1)
+#define RP5C01_10_HOUR_PM (1 << 1)
+
+#define RP5C01_MODE_TIMER_EN (1 << 3) /* timer enable */
+#define RP5C01_MODE_ALARM_EN (1 << 2) /* alarm enable */
+
+#define RP5C01_MODE_MODE_MASK (3 << 0)
+#define RP5C01_MODE_MODE00 (0 << 0) /* time */
+#define RP5C01_MODE_MODE01 (1 << 0) /* alarm, 12h/24h, leap year */
+#define RP5C01_MODE_RAM_BLOCK10 (2 << 0) /* RAM 4 bits x 13 */
+#define RP5C01_MODE_RAM_BLOCK11 (3 << 0) /* RAM 4 bits x 13 */
+
+#define RP5C01_RESET_1HZ_PULSE (1 << 3)
+#define RP5C01_RESET_16HZ_PULSE (1 << 2)
+#define RP5C01_RESET_SECOND (1 << 1) /* reset divider stages for */
+ /* seconds or smaller units */
+#define RP5C01_RESET_ALARM (1 << 0) /* reset all alarm registers */
+
+
+struct rp5c01_priv {
+ u32 __iomem *regs;
+ struct rtc_device *rtc;
+};
+
+static inline unsigned int rp5c01_read(struct rp5c01_priv *priv,
+ unsigned int reg)
+{
+ return __raw_readl(&priv->regs[reg]) & 0xf;
+}
+
+static inline void rp5c01_write(struct rp5c01_priv *priv, unsigned int val,
+ unsigned int reg)
+{
+ return __raw_writel(val, &priv->regs[reg]);
+}
+
+static void rp5c01_lock(struct rp5c01_priv *priv)
+{
+ rp5c01_write(priv, RP5C01_MODE_MODE00, RP5C01_MODE);
+}
+
+static void rp5c01_unlock(struct rp5c01_priv *priv)
+{
+ rp5c01_write(priv, RP5C01_MODE_TIMER_EN | RP5C01_MODE_MODE01,
+ RP5C01_MODE);
+}
+
+static int rp5c01_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct rp5c01_priv *priv = dev_get_drvdata(dev);
+
+ rp5c01_lock(priv);
+
+ tm->tm_sec = rp5c01_read(priv, RP5C01_10_SECOND) * 10 +
+ rp5c01_read(priv, RP5C01_1_SECOND);
+ tm->tm_min = rp5c01_read(priv, RP5C01_10_MINUTE) * 10 +
+ rp5c01_read(priv, RP5C01_1_MINUTE);
+ tm->tm_hour = rp5c01_read(priv, RP5C01_10_HOUR) * 10 +
+ rp5c01_read(priv, RP5C01_1_HOUR);
+ tm->tm_mday = rp5c01_read(priv, RP5C01_10_DAY) * 10 +
+ rp5c01_read(priv, RP5C01_1_DAY);
+ tm->tm_wday = rp5c01_read(priv, RP5C01_DAY_OF_WEEK);
+ tm->tm_mon = rp5c01_read(priv, RP5C01_10_MONTH) * 10 +
+ rp5c01_read(priv, RP5C01_1_MONTH) - 1;
+ tm->tm_year = rp5c01_read(priv, RP5C01_10_YEAR) * 10 +
+ rp5c01_read(priv, RP5C01_1_YEAR);
+ if (tm->tm_year <= 69)
+ tm->tm_year += 100;
+
+ rp5c01_unlock(priv);
+
+ return rtc_valid_tm(tm);
+}
+
+static int rp5c01_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct rp5c01_priv *priv = dev_get_drvdata(dev);
+
+ rp5c01_lock(priv);
+
+ rp5c01_write(priv, tm->tm_sec / 10, RP5C01_10_SECOND);
+ rp5c01_write(priv, tm->tm_sec % 10, RP5C01_1_SECOND);
+ rp5c01_write(priv, tm->tm_min / 10, RP5C01_10_MINUTE);
+ rp5c01_write(priv, tm->tm_min % 10, RP5C01_1_MINUTE);
+ rp5c01_write(priv, tm->tm_hour / 10, RP5C01_10_HOUR);
+ rp5c01_write(priv, tm->tm_hour % 10, RP5C01_1_HOUR);
+ rp5c01_write(priv, tm->tm_mday / 10, RP5C01_10_DAY);
+ rp5c01_write(priv, tm->tm_mday % 10, RP5C01_1_DAY);
+ if (tm->tm_wday != -1)
+ rp5c01_write(priv, tm->tm_wday, RP5C01_DAY_OF_WEEK);
+ rp5c01_write(priv, (tm->tm_mon + 1) / 10, RP5C01_10_MONTH);
+ rp5c01_write(priv, (tm->tm_mon + 1) % 10, RP5C01_1_MONTH);
+ if (tm->tm_year >= 100)
+ tm->tm_year -= 100;
+ rp5c01_write(priv, tm->tm_year / 10, RP5C01_10_YEAR);
+ rp5c01_write(priv, tm->tm_year % 10, RP5C01_1_YEAR);
+
+ rp5c01_unlock(priv);
+ return 0;
+}
+
+static const struct rtc_class_ops rp5c01_rtc_ops = {
+ .read_time = rp5c01_read_time,
+ .set_time = rp5c01_set_time,
+};
+
+static int __init rp5c01_rtc_probe(struct platform_device *dev)
+{
+ struct resource *res;
+ struct rp5c01_priv *priv;
+ struct rtc_device *rtc;
+ int error;
+
+ res = platform_get_resource(dev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->regs = ioremap(res->start, resource_size(res));
+ if (!priv->regs) {
+ error = -ENOMEM;
+ goto out_free_priv;
+ }
+
+ rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops,
+ THIS_MODULE);
+ if (IS_ERR(rtc)) {
+ error = PTR_ERR(rtc);
+ goto out_unmap;
+ }
+
+ priv->rtc = rtc;
+ platform_set_drvdata(dev, priv);
+ return 0;
+
+out_unmap:
+ iounmap(priv->regs);
+out_free_priv:
+ kfree(priv);
+ return error;
+}
+
+static int __exit rp5c01_rtc_remove(struct platform_device *dev)
+{
+ struct rp5c01_priv *priv = platform_get_drvdata(dev);
+
+ rtc_device_unregister(priv->rtc);
+ iounmap(priv->regs);
+ kfree(priv);
+ return 0;
+}
+
+static struct platform_driver rp5c01_rtc_driver = {
+ .driver = {
+ .name = "rtc-rp5c01",
+ .owner = THIS_MODULE,
+ },
+ .remove = __exit_p(rp5c01_rtc_remove),
+};
+
+static int __init rp5c01_rtc_init(void)
+{
+ return platform_driver_probe(&rp5c01_rtc_driver, rp5c01_rtc_probe);
+}
+
+static void __exit rp5c01_rtc_fini(void)
+{
+ platform_driver_unregister(&rp5c01_rtc_driver);
+}
+
+module_init(rp5c01_rtc_init);
+module_exit(rp5c01_rtc_fini);
+
+MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Ricoh RP5C01 RTC driver");
+MODULE_ALIAS("platform:rtc-rp5c01");
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index d1815272c435..27a1be0cd4d4 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -603,7 +603,7 @@ static void dasd_profile_end(struct dasd_block *block,
if (dasd_profile_level != DASD_PROFILE_ON)
return;
- sectors = req->nr_sectors;
+ sectors = blk_rq_sectors(req);
if (!cqr->buildclk || !cqr->startclk ||
!cqr->stopclk || !cqr->endclk ||
!sectors)
@@ -1614,15 +1614,6 @@ void dasd_block_clear_timer(struct dasd_block *block)
}
/*
- * posts the buffer_cache about a finalized request
- */
-static inline void dasd_end_request(struct request *req, int error)
-{
- if (__blk_end_request(req, error, blk_rq_bytes(req)))
- BUG();
-}
-
-/*
* Process finished error recovery ccw.
*/
static inline void __dasd_block_process_erp(struct dasd_block *block,
@@ -1665,18 +1656,14 @@ static void __dasd_process_request_queue(struct dasd_block *block)
if (basedev->state < DASD_STATE_READY)
return;
/* Now we try to fetch requests from the request queue */
- while (!blk_queue_plugged(queue) &&
- elv_next_request(queue)) {
-
- req = elv_next_request(queue);
-
+ while (!blk_queue_plugged(queue) && (req = blk_peek_request(queue))) {
if (basedev->features & DASD_FEATURE_READONLY &&
rq_data_dir(req) == WRITE) {
DBF_DEV_EVENT(DBF_ERR, basedev,
"Rejecting write request %p",
req);
- blkdev_dequeue_request(req);
- dasd_end_request(req, -EIO);
+ blk_start_request(req);
+ __blk_end_request_all(req, -EIO);
continue;
}
cqr = basedev->discipline->build_cp(basedev, block, req);
@@ -1704,8 +1691,8 @@ static void __dasd_process_request_queue(struct dasd_block *block)
"CCW creation failed (rc=%ld) "
"on request %p",
PTR_ERR(cqr), req);
- blkdev_dequeue_request(req);
- dasd_end_request(req, -EIO);
+ blk_start_request(req);
+ __blk_end_request_all(req, -EIO);
continue;
}
/*
@@ -1714,7 +1701,7 @@ static void __dasd_process_request_queue(struct dasd_block *block)
*/
cqr->callback_data = (void *) req;
cqr->status = DASD_CQR_FILLED;
- blkdev_dequeue_request(req);
+ blk_start_request(req);
list_add_tail(&cqr->blocklist, &block->ccw_queue);
dasd_profile_start(block, cqr, req);
}
@@ -1731,7 +1718,7 @@ static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr)
status = cqr->block->base->discipline->free_cp(cqr, req);
if (status <= 0)
error = status ? status : -EIO;
- dasd_end_request(req, error);
+ __blk_end_request_all(req, error);
}
/*
@@ -2003,7 +1990,7 @@ static void dasd_setup_queue(struct dasd_block *block)
{
int max;
- blk_queue_hardsect_size(block->request_queue, block->bp_block);
+ blk_queue_logical_block_size(block->request_queue, block->bp_block);
max = block->base->discipline->max_blocks << block->s2b_shift;
blk_queue_max_sectors(block->request_queue, max);
blk_queue_max_phys_segments(block->request_queue, -1L);
@@ -2038,10 +2025,8 @@ static void dasd_flush_request_queue(struct dasd_block *block)
return;
spin_lock_irq(&block->request_queue_lock);
- while ((req = elv_next_request(block->request_queue))) {
- blkdev_dequeue_request(req);
- dasd_end_request(req, -EIO);
- }
+ while ((req = blk_fetch_request(block->request_queue)))
+ __blk_end_request_all(req, -EIO);
spin_unlock_irq(&block->request_queue_lock);
}
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index b9a7f7733446..2efaddfae560 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -505,8 +505,9 @@ static struct dasd_ccw_req *dasd_diag_build_cp(struct dasd_device *memdev,
return ERR_PTR(-EINVAL);
blksize = block->bp_block;
/* Calculate record id of first and last block. */
- first_rec = req->sector >> block->s2b_shift;
- last_rec = (req->sector + req->nr_sectors - 1) >> block->s2b_shift;
+ first_rec = blk_rq_pos(req) >> block->s2b_shift;
+ last_rec =
+ (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
/* Check struct bio and count the number of blocks for the request. */
count = 0;
rq_for_each_segment(bv, req, iter) {
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index cb52da033f06..a41c94053e64 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -2354,10 +2354,10 @@ static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev,
blksize = block->bp_block;
blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
/* Calculate record id of first and last block. */
- first_rec = first_trk = req->sector >> block->s2b_shift;
+ first_rec = first_trk = blk_rq_pos(req) >> block->s2b_shift;
first_offs = sector_div(first_trk, blk_per_trk);
last_rec = last_trk =
- (req->sector + req->nr_sectors - 1) >> block->s2b_shift;
+ (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
last_offs = sector_div(last_trk, blk_per_trk);
cdlspecial = (private->uses_cdl && first_rec < 2*blk_per_trk);
@@ -2420,7 +2420,7 @@ dasd_eckd_free_cp(struct dasd_ccw_req *cqr, struct request *req)
private = (struct dasd_eckd_private *) cqr->block->base->private;
blksize = cqr->block->bp_block;
blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
- recid = req->sector >> cqr->block->s2b_shift;
+ recid = blk_rq_pos(req) >> cqr->block->s2b_shift;
ccw = cqr->cpaddr;
/* Skip over define extent & locate record. */
ccw++;
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index a3eb6fd14673..8912358daa2f 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -270,8 +270,9 @@ static struct dasd_ccw_req *dasd_fba_build_cp(struct dasd_device * memdev,
return ERR_PTR(-EINVAL);
blksize = block->bp_block;
/* Calculate record id of first and last block. */
- first_rec = req->sector >> block->s2b_shift;
- last_rec = (req->sector + req->nr_sectors - 1) >> block->s2b_shift;
+ first_rec = blk_rq_pos(req) >> block->s2b_shift;
+ last_rec =
+ (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
/* Check struct bio and count the number of blocks for the request. */
count = 0;
cidaw = 0;
@@ -309,7 +310,7 @@ static struct dasd_ccw_req *dasd_fba_build_cp(struct dasd_device * memdev,
ccw = cqr->cpaddr;
/* First ccw is define extent. */
define_extent(ccw++, cqr->data, rq_data_dir(req),
- block->bp_block, req->sector, req->nr_sectors);
+ block->bp_block, blk_rq_pos(req), blk_rq_sectors(req));
/* Build locate_record + read/write ccws. */
idaws = (unsigned long *) (cqr->data + sizeof(struct DE_fba_data));
LO_data = (struct LO_fba_data *) (idaws + cidaw);
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index cfdcf1aed33c..a4c7ffcd9987 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -602,7 +602,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
dev_info->gd->private_data = dev_info;
dev_info->gd->driverfs_dev = &dev_info->dev;
blk_queue_make_request(dev_info->dcssblk_queue, dcssblk_make_request);
- blk_queue_hardsect_size(dev_info->dcssblk_queue, 4096);
+ blk_queue_logical_block_size(dev_info->dcssblk_queue, 4096);
seg_byte_size = (dev_info->end - dev_info->start + 1);
set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index 76814f3e898a..0ae0c83ef879 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -343,7 +343,7 @@ static int __init xpram_setup_blkdev(void)
goto out;
}
blk_queue_make_request(xpram_queues[i], xpram_make_request);
- blk_queue_hardsect_size(xpram_queues[i], 4096);
+ blk_queue_logical_block_size(xpram_queues[i], 4096);
}
/*
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 9ab06e0dad40..c639361d8085 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -368,7 +368,7 @@ raw3215_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
int cstat, dstat;
int count;
- raw = cdev->dev.driver_data;
+ raw = dev_get_drvdata(&cdev->dev);
req = (struct raw3215_req *) intparm;
cstat = irb->scsw.cmd.cstat;
dstat = irb->scsw.cmd.dstat;
@@ -635,7 +635,7 @@ raw3215_probe (struct ccw_device *cdev)
int line;
/* Console is special. */
- if (raw3215[0] && (cdev->dev.driver_data == raw3215[0]))
+ if (raw3215[0] && (raw3215[0] == dev_get_drvdata(&cdev->dev)))
return 0;
raw = kmalloc(sizeof(struct raw3215_info) +
RAW3215_INBUF_SIZE, GFP_KERNEL|GFP_DMA);
@@ -669,7 +669,7 @@ raw3215_probe (struct ccw_device *cdev)
}
init_waitqueue_head(&raw->empty_wait);
- cdev->dev.driver_data = raw;
+ dev_set_drvdata(&cdev->dev, raw);
cdev->handler = raw3215_irq;
return 0;
@@ -681,9 +681,9 @@ raw3215_remove (struct ccw_device *cdev)
struct raw3215_info *raw;
ccw_device_set_offline(cdev);
- raw = cdev->dev.driver_data;
+ raw = dev_get_drvdata(&cdev->dev);
if (raw) {
- cdev->dev.driver_data = NULL;
+ dev_set_drvdata(&cdev->dev, NULL);
kfree(raw->buffer);
kfree(raw);
}
@@ -694,7 +694,7 @@ raw3215_set_online (struct ccw_device *cdev)
{
struct raw3215_info *raw;
- raw = cdev->dev.driver_data;
+ raw = dev_get_drvdata(&cdev->dev);
if (!raw)
return -ENODEV;
@@ -706,7 +706,7 @@ raw3215_set_offline (struct ccw_device *cdev)
{
struct raw3215_info *raw;
- raw = cdev->dev.driver_data;
+ raw = dev_get_drvdata(&cdev->dev);
if (!raw)
return -ENODEV;
@@ -848,7 +848,7 @@ con3215_init(void)
raw->buffer = (char *) alloc_bootmem_low(RAW3215_BUFFER_SIZE);
raw->inbuf = (char *) alloc_bootmem_low(RAW3215_INBUF_SIZE);
raw->cdev = cdev;
- cdev->dev.driver_data = raw;
+ dev_set_drvdata(&cdev->dev, raw);
cdev->handler = raw3215_irq;
raw->flags |= RAW3215_FIXED;
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index d028d2ee83dd..ed5396dae58e 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -64,7 +64,7 @@ static struct con3270 *condev;
#define CON_UPDATE_ERASE 1 /* Use EWRITEA instead of WRITE. */
#define CON_UPDATE_LIST 2 /* Update lines in tty3270->update. */
#define CON_UPDATE_STATUS 4 /* Update status line. */
-#define CON_UPDATE_ALL 7
+#define CON_UPDATE_ALL 8 /* Recreate screen. */
static void con3270_update(struct con3270 *);
@@ -73,18 +73,10 @@ static void con3270_update(struct con3270 *);
*/
static void con3270_set_timer(struct con3270 *cp, int expires)
{
- if (expires == 0) {
- if (timer_pending(&cp->timer))
- del_timer(&cp->timer);
- return;
- }
- if (timer_pending(&cp->timer) &&
- mod_timer(&cp->timer, jiffies + expires))
- return;
- cp->timer.function = (void (*)(unsigned long)) con3270_update;
- cp->timer.data = (unsigned long) cp;
- cp->timer.expires = jiffies + expires;
- add_timer(&cp->timer);
+ if (expires == 0)
+ del_timer(&cp->timer);
+ else
+ mod_timer(&cp->timer, jiffies + expires);
}
/*
@@ -225,6 +217,12 @@ con3270_update(struct con3270 *cp)
spin_lock_irqsave(&cp->view.lock, flags);
updated = 0;
+ if (cp->update_flags & CON_UPDATE_ALL) {
+ con3270_rebuild_update(cp);
+ con3270_update_status(cp);
+ cp->update_flags = CON_UPDATE_ERASE | CON_UPDATE_LIST |
+ CON_UPDATE_STATUS;
+ }
if (cp->update_flags & CON_UPDATE_ERASE) {
/* Use erase write alternate to initialize display. */
raw3270_request_set_cmd(wrq, TC_EWRITEA);
@@ -302,7 +300,6 @@ con3270_read_tasklet(struct raw3270_request *rrq)
deactivate = 1;
break;
case 0x6d: /* clear: start from scratch. */
- con3270_rebuild_update(cp);
cp->update_flags = CON_UPDATE_ALL;
con3270_set_timer(cp, 1);
break;
@@ -382,30 +379,21 @@ con3270_issue_read(struct con3270 *cp)
static int
con3270_activate(struct raw3270_view *view)
{
- unsigned long flags;
struct con3270 *cp;
cp = (struct con3270 *) view;
- spin_lock_irqsave(&cp->view.lock, flags);
- cp->nr_up = 0;
- con3270_rebuild_update(cp);
- con3270_update_status(cp);
cp->update_flags = CON_UPDATE_ALL;
con3270_set_timer(cp, 1);
- spin_unlock_irqrestore(&cp->view.lock, flags);
return 0;
}
static void
con3270_deactivate(struct raw3270_view *view)
{
- unsigned long flags;
struct con3270 *cp;
cp = (struct con3270 *) view;
- spin_lock_irqsave(&cp->view.lock, flags);
del_timer(&cp->timer);
- spin_unlock_irqrestore(&cp->view.lock, flags);
}
static int
@@ -504,6 +492,7 @@ con3270_write(struct console *co, const char *str, unsigned int count)
con3270_cline_end(cp);
}
/* Setup timer to output current console buffer after 1/10 second */
+ cp->nr_up = 0;
if (cp->view.dev && !timer_pending(&cp->timer))
con3270_set_timer(cp, HZ/10);
spin_unlock_irqrestore(&cp->view.lock,flags);
@@ -624,7 +613,8 @@ con3270_init(void)
INIT_LIST_HEAD(&condev->lines);
INIT_LIST_HEAD(&condev->update);
- init_timer(&condev->timer);
+ setup_timer(&condev->timer, (void (*)(unsigned long)) con3270_update,
+ (unsigned long) condev);
tasklet_init(&condev->readlet,
(void (*)(unsigned long)) con3270_read_tasklet,
(unsigned long) condev->read);
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 0b15cf107ec9..1ab69df2684c 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -355,7 +355,7 @@ raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
struct raw3270_request *rq;
int rc;
- rp = (struct raw3270 *) cdev->dev.driver_data;
+ rp = dev_get_drvdata(&cdev->dev);
if (!rp)
return;
rq = (struct raw3270_request *) intparm;
@@ -828,7 +828,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
if (rp->minor == -1)
return -EUSERS;
rp->cdev = cdev;
- cdev->dev.driver_data = rp;
+ dev_set_drvdata(&cdev->dev, rp);
cdev->handler = raw3270_irq;
return 0;
}
@@ -1105,7 +1105,7 @@ raw3270_delete_device(struct raw3270 *rp)
/* Disconnect from ccw_device. */
cdev = rp->cdev;
rp->cdev = NULL;
- cdev->dev.driver_data = NULL;
+ dev_set_drvdata(&cdev->dev, NULL);
cdev->handler = NULL;
/* Put ccw_device structure. */
@@ -1129,7 +1129,7 @@ static ssize_t
raw3270_model_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%i\n",
- ((struct raw3270 *) dev->driver_data)->model);
+ ((struct raw3270 *) dev_get_drvdata(dev))->model);
}
static DEVICE_ATTR(model, 0444, raw3270_model_show, NULL);
@@ -1137,7 +1137,7 @@ static ssize_t
raw3270_rows_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%i\n",
- ((struct raw3270 *) dev->driver_data)->rows);
+ ((struct raw3270 *) dev_get_drvdata(dev))->rows);
}
static DEVICE_ATTR(rows, 0444, raw3270_rows_show, NULL);
@@ -1145,7 +1145,7 @@ static ssize_t
raw3270_columns_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%i\n",
- ((struct raw3270 *) dev->driver_data)->cols);
+ ((struct raw3270 *) dev_get_drvdata(dev))->cols);
}
static DEVICE_ATTR(columns, 0444, raw3270_columns_show, NULL);
@@ -1282,7 +1282,7 @@ raw3270_remove (struct ccw_device *cdev)
struct raw3270_view *v;
struct raw3270_notifier *np;
- rp = cdev->dev.driver_data;
+ rp = dev_get_drvdata(&cdev->dev);
/*
* _remove is the opposite of _probe; it's probe that
* should set up rp. raw3270_remove gets entered for
@@ -1330,7 +1330,7 @@ raw3270_set_offline (struct ccw_device *cdev)
{
struct raw3270 *rp;
- rp = cdev->dev.driver_data;
+ rp = dev_get_drvdata(&cdev->dev);
if (test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags))
return -EBUSY;
raw3270_remove(cdev);
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index 5f8e8ef43dd3..997ed5807589 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -1134,7 +1134,7 @@ tape_34xx_bread(struct tape_device *device, struct request *req)
/* Setup ccws. */
request->op = TO_BLOCK;
start_block = (struct tape_34xx_block_id *) request->cpdata;
- start_block->block = req->sector >> TAPEBLOCK_HSEC_S2B;
+ start_block->block = blk_rq_pos(req) >> TAPEBLOCK_HSEC_S2B;
DBF_EVENT(6, "start_block = %i\n", start_block->block);
ccw = request->cpaddr;
@@ -1289,7 +1289,7 @@ static int
tape_34xx_online(struct ccw_device *cdev)
{
return tape_generic_online(
- cdev->dev.driver_data,
+ dev_get_drvdata(&cdev->dev),
&tape_discipline_34xx
);
}
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index 823b05bd0dd7..5de27c9e4af1 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -633,7 +633,7 @@ tape_3590_bread(struct tape_device *device, struct request *req)
struct req_iterator iter;
DBF_EVENT(6, "xBREDid:");
- start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
+ start_block = blk_rq_pos(req) >> TAPEBLOCK_HSEC_S2B;
DBF_EVENT(6, "start_block = %i\n", start_block);
rq_for_each_segment(bv, req, iter)
@@ -1703,7 +1703,7 @@ static struct ccw_device_id tape_3590_ids[] = {
static int
tape_3590_online(struct ccw_device *cdev)
{
- return tape_generic_online(cdev->dev.driver_data,
+ return tape_generic_online(dev_get_drvdata(&cdev->dev),
&tape_discipline_3590);
}
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index f32e89e7c4f2..47ff695255ea 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -74,13 +74,6 @@ tapeblock_trigger_requeue(struct tape_device *device)
* Post finished request.
*/
static void
-tapeblock_end_request(struct request *req, int error)
-{
- if (blk_end_request(req, error, blk_rq_bytes(req)))
- BUG();
-}
-
-static void
__tapeblock_end_request(struct tape_request *ccw_req, void *data)
{
struct tape_device *device;
@@ -90,17 +83,17 @@ __tapeblock_end_request(struct tape_request *ccw_req, void *data)
device = ccw_req->device;
req = (struct request *) data;
- tapeblock_end_request(req, (ccw_req->rc == 0) ? 0 : -EIO);
+ blk_end_request_all(req, (ccw_req->rc == 0) ? 0 : -EIO);
if (ccw_req->rc == 0)
/* Update position. */
device->blk_data.block_position =
- (req->sector + req->nr_sectors) >> TAPEBLOCK_HSEC_S2B;
+ (blk_rq_pos(req) + blk_rq_sectors(req)) >> TAPEBLOCK_HSEC_S2B;
else
/* We lost the position information due to an error. */
device->blk_data.block_position = -1;
device->discipline->free_bread(ccw_req);
if (!list_empty(&device->req_queue) ||
- elv_next_request(device->blk_data.request_queue))
+ blk_peek_request(device->blk_data.request_queue))
tapeblock_trigger_requeue(device);
}
@@ -118,7 +111,7 @@ tapeblock_start_request(struct tape_device *device, struct request *req)
ccw_req = device->discipline->bread(device, req);
if (IS_ERR(ccw_req)) {
DBF_EVENT(1, "TBLOCK: bread failed\n");
- tapeblock_end_request(req, -EIO);
+ blk_end_request_all(req, -EIO);
return PTR_ERR(ccw_req);
}
ccw_req->callback = __tapeblock_end_request;
@@ -131,7 +124,7 @@ tapeblock_start_request(struct tape_device *device, struct request *req)
* Start/enqueueing failed. No retries in
* this case.
*/
- tapeblock_end_request(req, -EIO);
+ blk_end_request_all(req, -EIO);
device->discipline->free_bread(ccw_req);
}
@@ -169,19 +162,16 @@ tapeblock_requeue(struct work_struct *work) {
spin_lock_irq(&device->blk_data.request_queue_lock);
while (
!blk_queue_plugged(queue) &&
- elv_next_request(queue) &&
+ (req = blk_fetch_request(queue)) &&
nr_queued < TAPEBLOCK_MIN_REQUEUE
) {
- req = elv_next_request(queue);
if (rq_data_dir(req) == WRITE) {
DBF_EVENT(1, "TBLOCK: Rejecting write request\n");
- blkdev_dequeue_request(req);
spin_unlock_irq(&device->blk_data.request_queue_lock);
- tapeblock_end_request(req, -EIO);
+ blk_end_request_all(req, -EIO);
spin_lock_irq(&device->blk_data.request_queue_lock);
continue;
}
- blkdev_dequeue_request(req);
nr_queued++;
spin_unlock_irq(&device->blk_data.request_queue_lock);
rc = tapeblock_start_request(device, req);
@@ -232,7 +222,7 @@ tapeblock_setup_device(struct tape_device * device)
if (rc)
goto cleanup_queue;
- blk_queue_hardsect_size(blkdat->request_queue, TAPEBLOCK_HSEC_SIZE);
+ blk_queue_logical_block_size(blkdat->request_queue, TAPEBLOCK_HSEC_SIZE);
blk_queue_max_sectors(blkdat->request_queue, TAPEBLOCK_MAX_SEC);
blk_queue_max_phys_segments(blkdat->request_queue, -1L);
blk_queue_max_hw_segments(blkdat->request_queue, -1L);
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 8a109f3b69c6..dfeb0d445fd7 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -92,7 +92,7 @@ tape_medium_state_show(struct device *dev, struct device_attribute *attr, char *
{
struct tape_device *tdev;
- tdev = (struct tape_device *) dev->driver_data;
+ tdev = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->medium_state);
}
@@ -104,7 +104,7 @@ tape_first_minor_show(struct device *dev, struct device_attribute *attr, char *b
{
struct tape_device *tdev;
- tdev = (struct tape_device *) dev->driver_data;
+ tdev = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->first_minor);
}
@@ -116,7 +116,7 @@ tape_state_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct tape_device *tdev;
- tdev = (struct tape_device *) dev->driver_data;
+ tdev = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE, "%s\n", (tdev->first_minor < 0) ?
"OFFLINE" : tape_state_verbose[tdev->tape_state]);
}
@@ -130,7 +130,7 @@ tape_operation_show(struct device *dev, struct device_attribute *attr, char *buf
struct tape_device *tdev;
ssize_t rc;
- tdev = (struct tape_device *) dev->driver_data;
+ tdev = dev_get_drvdata(dev);
if (tdev->first_minor < 0)
return scnprintf(buf, PAGE_SIZE, "N/A\n");
@@ -156,7 +156,7 @@ tape_blocksize_show(struct device *dev, struct device_attribute *attr, char *buf
{
struct tape_device *tdev;
- tdev = (struct tape_device *) dev->driver_data;
+ tdev = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->char_data.block_size);
}
@@ -391,7 +391,7 @@ tape_generic_offline(struct ccw_device *cdev)
{
struct tape_device *device;
- device = cdev->dev.driver_data;
+ device = dev_get_drvdata(&cdev->dev);
if (!device) {
return -ENODEV;
}
@@ -534,7 +534,7 @@ tape_generic_probe(struct ccw_device *cdev)
tape_put_device(device);
return ret;
}
- cdev->dev.driver_data = device;
+ dev_set_drvdata(&cdev->dev, device);
cdev->handler = __tape_do_irq;
device->cdev = cdev;
ccw_device_get_id(cdev, &dev_id);
@@ -573,7 +573,7 @@ tape_generic_remove(struct ccw_device *cdev)
{
struct tape_device * device;
- device = cdev->dev.driver_data;
+ device = dev_get_drvdata(&cdev->dev);
if (!device) {
return;
}
@@ -613,9 +613,9 @@ tape_generic_remove(struct ccw_device *cdev)
tape_cleanup_device(device);
}
- if (cdev->dev.driver_data != NULL) {
+ if (!dev_get_drvdata(&cdev->dev)) {
sysfs_remove_group(&cdev->dev.kobj, &tape_attr_group);
- cdev->dev.driver_data = tape_put_device(cdev->dev.driver_data);
+ dev_set_drvdata(&cdev->dev, tape_put_device(dev_get_drvdata(&cdev->dev)));
}
}
@@ -1011,7 +1011,7 @@ __tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
struct tape_request *request;
int rc;
- device = (struct tape_device *) cdev->dev.driver_data;
+ device = dev_get_drvdata(&cdev->dev);
if (device == NULL) {
return;
}
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index a7fe6302c982..38385677c653 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -112,7 +112,7 @@ struct tty3270 {
#define TTY_UPDATE_LIST 2 /* Update lines in tty3270->update. */
#define TTY_UPDATE_INPUT 4 /* Update input line. */
#define TTY_UPDATE_STATUS 8 /* Update status line. */
-#define TTY_UPDATE_ALL 15
+#define TTY_UPDATE_ALL 16 /* Recreate screen. */
static void tty3270_update(struct tty3270 *);
@@ -121,19 +121,10 @@ static void tty3270_update(struct tty3270 *);
*/
static void tty3270_set_timer(struct tty3270 *tp, int expires)
{
- if (expires == 0) {
- if (timer_pending(&tp->timer) && del_timer(&tp->timer))
- raw3270_put_view(&tp->view);
- return;
- }
- if (timer_pending(&tp->timer) &&
- mod_timer(&tp->timer, jiffies + expires))
- return;
- raw3270_get_view(&tp->view);
- tp->timer.function = (void (*)(unsigned long)) tty3270_update;
- tp->timer.data = (unsigned long) tp;
- tp->timer.expires = jiffies + expires;
- add_timer(&tp->timer);
+ if (expires == 0)
+ del_timer(&tp->timer);
+ else
+ mod_timer(&tp->timer, jiffies + expires);
}
/*
@@ -337,7 +328,6 @@ tty3270_write_callback(struct raw3270_request *rq, void *data)
tp = (struct tty3270 *) rq->view;
if (rq->rc != 0) {
/* Write wasn't successfull. Refresh all. */
- tty3270_rebuild_update(tp);
tp->update_flags = TTY_UPDATE_ALL;
tty3270_set_timer(tp, 1);
}
@@ -366,6 +356,12 @@ tty3270_update(struct tty3270 *tp)
spin_lock(&tp->view.lock);
updated = 0;
+ if (tp->update_flags & TTY_UPDATE_ALL) {
+ tty3270_rebuild_update(tp);
+ tty3270_update_status(tp);
+ tp->update_flags = TTY_UPDATE_ERASE | TTY_UPDATE_LIST |
+ TTY_UPDATE_INPUT | TTY_UPDATE_STATUS;
+ }
if (tp->update_flags & TTY_UPDATE_ERASE) {
/* Use erase write alternate to erase display. */
raw3270_request_set_cmd(wrq, TC_EWRITEA);
@@ -425,7 +421,6 @@ tty3270_update(struct tty3270 *tp)
xchg(&tp->write, wrq);
}
spin_unlock(&tp->view.lock);
- raw3270_put_view(&tp->view);
}
/*
@@ -570,7 +565,6 @@ tty3270_read_tasklet(struct raw3270_request *rrq)
tty3270_set_timer(tp, 1);
} else if (tp->input->string[0] == 0x6d) {
/* Display has been cleared. Redraw. */
- tty3270_rebuild_update(tp);
tp->update_flags = TTY_UPDATE_ALL;
tty3270_set_timer(tp, 1);
}
@@ -641,22 +635,20 @@ static int
tty3270_activate(struct raw3270_view *view)
{
struct tty3270 *tp;
- unsigned long flags;
tp = (struct tty3270 *) view;
- spin_lock_irqsave(&tp->view.lock, flags);
- tp->nr_up = 0;
- tty3270_rebuild_update(tp);
- tty3270_update_status(tp);
tp->update_flags = TTY_UPDATE_ALL;
tty3270_set_timer(tp, 1);
- spin_unlock_irqrestore(&tp->view.lock, flags);
return 0;
}
static void
tty3270_deactivate(struct raw3270_view *view)
{
+ struct tty3270 *tp;
+
+ tp = (struct tty3270 *) view;
+ del_timer(&tp->timer);
}
static int
@@ -743,6 +735,7 @@ tty3270_free_view(struct tty3270 *tp)
{
int pages;
+ del_timer_sync(&tp->timer);
kbd_free(tp->kbd);
raw3270_request_free(tp->kreset);
raw3270_request_free(tp->read);
@@ -889,7 +882,8 @@ tty3270_open(struct tty_struct *tty, struct file * filp)
INIT_LIST_HEAD(&tp->update);
INIT_LIST_HEAD(&tp->rcl_lines);
tp->rcl_max = 20;
- init_timer(&tp->timer);
+ setup_timer(&tp->timer, (void (*)(unsigned long)) tty3270_update,
+ (unsigned long) tp);
tasklet_init(&tp->readlet,
(void (*)(unsigned long)) tty3270_read_tasklet,
(unsigned long) tp->read);
@@ -1754,14 +1748,6 @@ static const struct tty_operations tty3270_ops = {
.set_termios = tty3270_set_termios
};
-static void tty3270_notifier(int index, int active)
-{
- if (active)
- tty_register_device(tty3270_driver, index, NULL);
- else
- tty_unregister_device(tty3270_driver, index);
-}
-
/*
* 3270 tty registration code called from tty_init().
* Most kernel services (incl. kmalloc) are available at this poimt.
@@ -1796,12 +1782,6 @@ static int __init tty3270_init(void)
return ret;
}
tty3270_driver = driver;
- ret = raw3270_register_notifier(tty3270_notifier);
- if (ret) {
- put_tty_driver(driver);
- return ret;
-
- }
return 0;
}
@@ -1810,7 +1790,6 @@ tty3270_exit(void)
{
struct tty_driver *driver;
- raw3270_unregister_notifier(tty3270_notifier);
driver = tty3270_driver;
tty3270_driver = NULL;
tty_unregister_driver(driver);
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index d8a2289fcb69..ee1b418b0d8a 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -504,7 +504,7 @@ static ssize_t vmlogrdr_autopurge_store(struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
- struct vmlogrdr_priv_t *priv = dev->driver_data;
+ struct vmlogrdr_priv_t *priv = dev_get_drvdata(dev);
ssize_t ret = count;
switch (buf[0]) {
@@ -525,7 +525,7 @@ static ssize_t vmlogrdr_autopurge_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct vmlogrdr_priv_t *priv = dev->driver_data;
+ struct vmlogrdr_priv_t *priv = dev_get_drvdata(dev);
return sprintf(buf, "%u\n", priv->autopurge);
}
@@ -541,7 +541,7 @@ static ssize_t vmlogrdr_purge_store(struct device * dev,
char cp_command[80];
char cp_response[80];
- struct vmlogrdr_priv_t *priv = dev->driver_data;
+ struct vmlogrdr_priv_t *priv = dev_get_drvdata(dev);
if (buf[0] != '1')
return -EINVAL;
@@ -578,7 +578,7 @@ static ssize_t vmlogrdr_autorecording_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct vmlogrdr_priv_t *priv = dev->driver_data;
+ struct vmlogrdr_priv_t *priv = dev_get_drvdata(dev);
ssize_t ret = count;
switch (buf[0]) {
@@ -599,7 +599,7 @@ static ssize_t vmlogrdr_autorecording_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct vmlogrdr_priv_t *priv = dev->driver_data;
+ struct vmlogrdr_priv_t *priv = dev_get_drvdata(dev);
return sprintf(buf, "%u\n", priv->autorecording);
}
@@ -612,7 +612,7 @@ static ssize_t vmlogrdr_recording_store(struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
- struct vmlogrdr_priv_t *priv = dev->driver_data;
+ struct vmlogrdr_priv_t *priv = dev_get_drvdata(dev);
ssize_t ret;
switch (buf[0]) {
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 5dcef81fc9d9..6492b2015dd4 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -78,11 +78,11 @@ static DEFINE_MUTEX(vmur_mutex);
*
* Each ur device (urd) contains a reference to its corresponding ccw device
* (cdev) using the urd->cdev pointer. Each ccw device has a reference to the
- * ur device using the cdev->dev.driver_data pointer.
+ * ur device using dev_get_drvdata(&cdev->dev) pointer.
*
* urd references:
* - ur_probe gets a urd reference, ur_remove drops the reference
- * (cdev->dev.driver_data)
+ * dev_get_drvdata(&cdev->dev)
* - ur_open gets a urd reference, ur_relase drops the reference
* (urf->urd)
*
@@ -90,7 +90,7 @@ static DEFINE_MUTEX(vmur_mutex);
* - urdev_alloc get a cdev reference (urd->cdev)
* - urdev_free drops the cdev reference (urd->cdev)
*
- * Setting and clearing of cdev->dev.driver_data is protected by the ccwdev lock
+ * Setting and clearing of dev_get_drvdata(&cdev->dev) is protected by the ccwdev lock
*/
static struct urdev *urdev_alloc(struct ccw_device *cdev)
{
@@ -129,7 +129,7 @@ static struct urdev *urdev_get_from_cdev(struct ccw_device *cdev)
unsigned long flags;
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
- urd = cdev->dev.driver_data;
+ urd = dev_get_drvdata(&cdev->dev);
if (urd)
urdev_get(urd);
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
@@ -286,7 +286,7 @@ static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
TRACE("ur_int_handler: unsolicited interrupt\n");
return;
}
- urd = cdev->dev.driver_data;
+ urd = dev_get_drvdata(&cdev->dev);
BUG_ON(!urd);
/* On special conditions irb is an error pointer */
if (IS_ERR(irb))
@@ -832,7 +832,7 @@ static int ur_probe(struct ccw_device *cdev)
goto fail_remove_attr;
}
spin_lock_irq(get_ccwdev_lock(cdev));
- cdev->dev.driver_data = urd;
+ dev_set_drvdata(&cdev->dev, urd);
spin_unlock_irq(get_ccwdev_lock(cdev));
mutex_unlock(&vmur_mutex);
@@ -972,8 +972,8 @@ static void ur_remove(struct ccw_device *cdev)
ur_remove_attributes(&cdev->dev);
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
- urdev_put(cdev->dev.driver_data);
- cdev->dev.driver_data = NULL;
+ urdev_put(dev_get_drvdata(&cdev->dev));
+ dev_set_drvdata(&cdev->dev, NULL);
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
mutex_unlock(&vmur_mutex);
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 2aebb9823044..9889f188c7c5 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -28,7 +28,7 @@
#include <asm/chpid.h>
#include <asm/airq.h>
#include <asm/isc.h>
-#include <asm/cpu.h>
+#include <asm/cputime.h>
#include <asm/fcx.h>
#include <asm/nmi.h>
#include <asm/crw.h>
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 151754d54745..bf0a24af39a0 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -114,7 +114,7 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
struct subchannel *sch;
int ret;
- if (!cdev)
+ if (!cdev || !cdev->dev.parent)
return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV;
@@ -122,8 +122,6 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
cdev->private->state != DEV_STATE_W4SENSE)
return -EINVAL;
sch = to_subchannel(cdev->dev.parent);
- if (!sch)
- return -ENODEV;
ret = cio_clear(sch);
if (ret == 0)
cdev->private->intparm = intparm;
@@ -161,11 +159,9 @@ int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa,
struct subchannel *sch;
int ret;
- if (!cdev)
+ if (!cdev || !cdev->dev.parent)
return -ENODEV;
sch = to_subchannel(cdev->dev.parent);
- if (!sch)
- return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV;
if (cdev->private->state == DEV_STATE_VERIFY ||
@@ -339,7 +335,7 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
struct subchannel *sch;
int ret;
- if (!cdev)
+ if (!cdev || !cdev->dev.parent)
return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV;
@@ -347,8 +343,6 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
cdev->private->state != DEV_STATE_W4SENSE)
return -EINVAL;
sch = to_subchannel(cdev->dev.parent);
- if (!sch)
- return -ENODEV;
ret = cio_halt(sch);
if (ret == 0)
cdev->private->intparm = intparm;
@@ -372,11 +366,9 @@ int ccw_device_resume(struct ccw_device *cdev)
{
struct subchannel *sch;
- if (!cdev)
+ if (!cdev || !cdev->dev.parent)
return -ENODEV;
sch = to_subchannel(cdev->dev.parent);
- if (!sch)
- return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV;
if (cdev->private->state != DEV_STATE_ONLINE ||
@@ -471,11 +463,11 @@ __u8 ccw_device_get_path_mask(struct ccw_device *cdev)
{
struct subchannel *sch;
- sch = to_subchannel(cdev->dev.parent);
- if (!sch)
+ if (!cdev->dev.parent)
return 0;
- else
- return sch->lpm;
+
+ sch = to_subchannel(cdev->dev.parent);
+ return sch->lpm;
}
/*
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index accd957454e7..d79cf5bf0e62 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -881,42 +881,26 @@ no_handler:
qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED);
}
-static int qdio_establish_check_errors(struct ccw_device *cdev, int cstat,
- int dstat)
+static void qdio_establish_handle_irq(struct ccw_device *cdev, int cstat,
+ int dstat)
{
struct qdio_irq *irq_ptr = cdev->private->qdio_data;
- if (cstat || (dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
- DBF_ERROR("EQ:ck con");
- goto error;
- }
+ DBF_DEV_EVENT(DBF_INFO, irq_ptr, "qest irq");
- if (!(dstat & DEV_STAT_DEV_END)) {
- DBF_ERROR("EQ:no dev");
+ if (cstat)
goto error;
- }
-
- if (dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) {
- DBF_ERROR("EQ: bad io");
+ if (dstat & ~(DEV_STAT_DEV_END | DEV_STAT_CHN_END))
goto error;
- }
- return 0;
+ if (!(dstat & DEV_STAT_DEV_END))
+ goto error;
+ qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ESTABLISHED);
+ return;
+
error:
DBF_ERROR("%4x EQ:error", irq_ptr->schid.sch_no);
DBF_ERROR("ds: %2x cs:%2x", dstat, cstat);
-
qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
- return 1;
-}
-
-static void qdio_establish_handle_irq(struct ccw_device *cdev, int cstat,
- int dstat)
-{
- struct qdio_irq *irq_ptr = cdev->private->qdio_data;
-
- DBF_DEV_EVENT(DBF_INFO, irq_ptr, "qest irq");
- if (!qdio_establish_check_errors(cdev, cstat, dstat))
- qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ESTABLISHED);
}
/* qdio interrupt handler */
@@ -946,7 +930,6 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm,
}
}
qdio_irq_check_sense(irq_ptr, irb);
-
cstat = irb->scsw.cmd.cstat;
dstat = irb->scsw.cmd.dstat;
@@ -954,22 +937,19 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm,
case QDIO_IRQ_STATE_INACTIVE:
qdio_establish_handle_irq(cdev, cstat, dstat);
break;
-
case QDIO_IRQ_STATE_CLEANUP:
qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
break;
-
case QDIO_IRQ_STATE_ESTABLISHED:
case QDIO_IRQ_STATE_ACTIVE:
if (cstat & SCHN_STAT_PCI) {
qdio_int_handler_pci(irq_ptr);
return;
}
- if ((cstat & ~SCHN_STAT_PCI) || dstat) {
+ if (cstat || dstat)
qdio_handle_activate_check(cdev, intparm, cstat,
dstat);
- break;
- }
+ break;
default:
WARN_ON(1);
}
@@ -1514,7 +1494,7 @@ int do_QDIO(struct ccw_device *cdev, unsigned int callflags,
if ((bufnr > QDIO_MAX_BUFFERS_PER_Q) ||
(count > QDIO_MAX_BUFFERS_PER_Q) ||
- (q_nr > QDIO_MAX_QUEUES_PER_IRQ))
+ (q_nr >= QDIO_MAX_QUEUES_PER_IRQ))
return -EINVAL;
if (!count)
diff --git a/drivers/s390/cio/qdio_perf.c b/drivers/s390/cio/qdio_perf.c
index 136d0f0b1e93..eff943923c6f 100644
--- a/drivers/s390/cio/qdio_perf.c
+++ b/drivers/s390/cio/qdio_perf.c
@@ -25,18 +25,6 @@ struct qdio_perf_stats perf_stats;
static struct proc_dir_entry *qdio_perf_pde;
#endif
-inline void qdio_perf_stat_inc(atomic_long_t *count)
-{
- if (qdio_performance_stats)
- atomic_long_inc(count);
-}
-
-inline void qdio_perf_stat_dec(atomic_long_t *count)
-{
- if (qdio_performance_stats)
- atomic_long_dec(count);
-}
-
/*
* procfs functions
*/
diff --git a/drivers/s390/cio/qdio_perf.h b/drivers/s390/cio/qdio_perf.h
index 7821ac4fa517..ff4504ce1e3c 100644
--- a/drivers/s390/cio/qdio_perf.h
+++ b/drivers/s390/cio/qdio_perf.h
@@ -9,7 +9,6 @@
#define QDIO_PERF_H
#include <linux/types.h>
-#include <linux/device.h>
#include <asm/atomic.h>
struct qdio_perf_stats {
@@ -50,10 +49,13 @@ struct qdio_perf_stats {
extern struct qdio_perf_stats perf_stats;
extern int qdio_performance_stats;
+static inline void qdio_perf_stat_inc(atomic_long_t *count)
+{
+ if (qdio_performance_stats)
+ atomic_long_inc(count);
+}
+
int qdio_setup_perf_stats(void);
void qdio_remove_perf_stats(void);
-extern void qdio_perf_stat_inc(atomic_long_t *count);
-extern void qdio_perf_stat_dec(atomic_long_t *count);
-
#endif
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index cbc8566fab70..e38e5d306faf 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -173,8 +173,9 @@ static void kvm_notify(struct virtqueue *vq)
* this device and sets it up.
*/
static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
- unsigned index,
- void (*callback)(struct virtqueue *vq))
+ unsigned index,
+ void (*callback)(struct virtqueue *vq),
+ const char *name)
{
struct kvm_device *kdev = to_kvmdev(vdev);
struct kvm_vqconfig *config;
@@ -194,7 +195,7 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
vq = vring_new_virtqueue(config->num, KVM_S390_VIRTIO_RING_ALIGN,
vdev, (void *) config->address,
- kvm_notify, callback);
+ kvm_notify, callback, name);
if (!vq) {
err = -ENOMEM;
goto unmap;
@@ -226,6 +227,38 @@ static void kvm_del_vq(struct virtqueue *vq)
KVM_S390_VIRTIO_RING_ALIGN));
}
+static void kvm_del_vqs(struct virtio_device *vdev)
+{
+ struct virtqueue *vq, *n;
+
+ list_for_each_entry_safe(vq, n, &vdev->vqs, list)
+ kvm_del_vq(vq);
+}
+
+static int kvm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
+ struct virtqueue *vqs[],
+ vq_callback_t *callbacks[],
+ const char *names[])
+{
+ struct kvm_device *kdev = to_kvmdev(vdev);
+ int i;
+
+ /* We must have this many virtqueues. */
+ if (nvqs > kdev->desc->num_vq)
+ return -ENOENT;
+
+ for (i = 0; i < nvqs; ++i) {
+ vqs[i] = kvm_find_vq(vdev, i, callbacks[i], names[i]);
+ if (IS_ERR(vqs[i]))
+ goto error;
+ }
+ return 0;
+
+error:
+ kvm_del_vqs(vdev);
+ return PTR_ERR(vqs[i]);
+}
+
/*
* The config ops structure as defined by virtio config
*/
@@ -237,8 +270,8 @@ static struct virtio_config_ops kvm_vq_configspace_ops = {
.get_status = kvm_get_status,
.set_status = kvm_set_status,
.reset = kvm_reset,
- .find_vq = kvm_find_vq,
- .del_vq = kvm_del_vq,
+ .find_vqs = kvm_find_vqs,
+ .del_vqs = kvm_del_vqs,
};
/*
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 30a43cc79e76..82ea11855de4 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -284,7 +284,7 @@ claw_probe(struct ccwgroup_device *cgdev)
if (!get_device(&cgdev->dev))
return -ENODEV;
privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
- cgdev->dev.driver_data = privptr;
+ dev_set_drvdata(&cgdev->dev, privptr);
if (privptr == NULL) {
probe_error(cgdev);
put_device(&cgdev->dev);
@@ -597,14 +597,14 @@ claw_irq_handler(struct ccw_device *cdev,
CLAW_DBF_TEXT(4, trace, "clawirq");
/* Bypass all 'unsolicited interrupts' */
- if (!cdev->dev.driver_data) {
+ privptr = dev_get_drvdata(&cdev->dev);
+ if (!privptr) {
dev_warn(&cdev->dev, "An uninitialized CLAW device received an"
" IRQ, c-%02x d-%02x\n",
irb->scsw.cmd.cstat, irb->scsw.cmd.dstat);
CLAW_DBF_TEXT(2, trace, "badirq");
return;
}
- privptr = (struct claw_privbk *)cdev->dev.driver_data;
/* Try to extract channel from driver data. */
if (privptr->channel[READ].cdev == cdev)
@@ -1986,9 +1986,9 @@ probe_error( struct ccwgroup_device *cgdev)
struct claw_privbk *privptr;
CLAW_DBF_TEXT(4, trace, "proberr");
- privptr = (struct claw_privbk *) cgdev->dev.driver_data;
+ privptr = dev_get_drvdata(&cgdev->dev);
if (privptr != NULL) {
- cgdev->dev.driver_data = NULL;
+ dev_set_drvdata(&cgdev->dev, NULL);
kfree(privptr->p_env);
kfree(privptr->p_mtc_envelope);
kfree(privptr);
@@ -2917,9 +2917,9 @@ claw_new_device(struct ccwgroup_device *cgdev)
dev_info(&cgdev->dev, "add for %s\n",
dev_name(&cgdev->cdev[READ]->dev));
CLAW_DBF_TEXT(2, setup, "new_dev");
- privptr = cgdev->dev.driver_data;
- cgdev->cdev[READ]->dev.driver_data = privptr;
- cgdev->cdev[WRITE]->dev.driver_data = privptr;
+ privptr = dev_get_drvdata(&cgdev->dev);
+ dev_set_drvdata(&cgdev->cdev[READ]->dev, privptr);
+ dev_set_drvdata(&cgdev->cdev[WRITE]->dev, privptr);
if (!privptr)
return -ENODEV;
p_env = privptr->p_env;
@@ -2956,9 +2956,9 @@ claw_new_device(struct ccwgroup_device *cgdev)
goto out;
}
dev->ml_priv = privptr;
- cgdev->dev.driver_data = privptr;
- cgdev->cdev[READ]->dev.driver_data = privptr;
- cgdev->cdev[WRITE]->dev.driver_data = privptr;
+ dev_set_drvdata(&cgdev->dev, privptr);
+ dev_set_drvdata(&cgdev->cdev[READ]->dev, privptr);
+ dev_set_drvdata(&cgdev->cdev[WRITE]->dev, privptr);
/* sysfs magic */
SET_NETDEV_DEV(dev, &cgdev->dev);
if (register_netdev(dev) != 0) {
@@ -3024,7 +3024,7 @@ claw_shutdown_device(struct ccwgroup_device *cgdev)
int ret;
CLAW_DBF_TEXT_(2, setup, "%s", dev_name(&cgdev->dev));
- priv = cgdev->dev.driver_data;
+ priv = dev_get_drvdata(&cgdev->dev);
if (!priv)
return -ENODEV;
ndev = priv->channel[READ].ndev;
@@ -3054,7 +3054,7 @@ claw_remove_device(struct ccwgroup_device *cgdev)
BUG_ON(!cgdev);
CLAW_DBF_TEXT_(2, setup, "%s", dev_name(&cgdev->dev));
- priv = cgdev->dev.driver_data;
+ priv = dev_get_drvdata(&cgdev->dev);
BUG_ON(!priv);
dev_info(&cgdev->dev, " will be removed.\n");
if (cgdev->state == CCWGROUP_ONLINE)
@@ -3069,9 +3069,9 @@ claw_remove_device(struct ccwgroup_device *cgdev)
kfree(priv->channel[1].irb);
priv->channel[1].irb=NULL;
kfree(priv);
- cgdev->dev.driver_data=NULL;
- cgdev->cdev[READ]->dev.driver_data = NULL;
- cgdev->cdev[WRITE]->dev.driver_data = NULL;
+ dev_set_drvdata(&cgdev->dev, NULL);
+ dev_set_drvdata(&cgdev->cdev[READ]->dev, NULL);
+ dev_set_drvdata(&cgdev->cdev[WRITE]->dev, NULL);
put_device(&cgdev->dev);
return;
@@ -3087,7 +3087,7 @@ claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf)
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3101,7 +3101,7 @@ claw_hname_write(struct device *dev, struct device_attribute *attr,
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3125,7 +3125,7 @@ claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf)
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3139,7 +3139,7 @@ claw_adname_write(struct device *dev, struct device_attribute *attr,
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3163,7 +3163,7 @@ claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf)
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3178,7 +3178,7 @@ claw_apname_write(struct device *dev, struct device_attribute *attr,
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3212,7 +3212,7 @@ claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3227,7 +3227,7 @@ claw_wbuff_write(struct device *dev, struct device_attribute *attr,
struct claw_env * p_env;
int nnn,max;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3254,7 +3254,7 @@ claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
struct claw_privbk *priv;
struct claw_env * p_env;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
@@ -3269,7 +3269,7 @@ claw_rbuff_write(struct device *dev, struct device_attribute *attr,
struct claw_env *p_env;
int nnn,max;
- priv = dev->driver_data;
+ priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
p_env = priv->p_env;
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index 77f4033a0f4f..54c4649a493b 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1677,10 +1677,8 @@ static void ctcm_remove_device(struct ccwgroup_device *cgdev)
BUG_ON(priv == NULL);
CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
- "removing device %s, r/w = %s/%s, proto : %d",
- priv->channel[READ]->netdev->name,
- priv->channel[READ]->id, priv->channel[WRITE]->id,
- priv->protocol);
+ "removing device %p, proto : %d",
+ cgdev, priv->protocol);
if (cgdev->state == CCWGROUP_ONLINE)
ctcm_shutdown_device(cgdev);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index a45bc24eb5f9..ba6d45d29ad4 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1939,7 +1939,7 @@ lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct lcs_card *card;
- card = (struct lcs_card *)dev->driver_data;
+ card = dev_get_drvdata(dev);
if (!card)
return 0;
@@ -1956,7 +1956,7 @@ lcs_portno_store (struct device *dev, struct device_attribute *attr, const char
struct lcs_card *card;
int value;
- card = (struct lcs_card *)dev->driver_data;
+ card = dev_get_drvdata(dev);
if (!card)
return 0;
@@ -1990,7 +1990,7 @@ lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct lcs_card *card;
- card = (struct lcs_card *)dev->driver_data;
+ card = dev_get_drvdata(dev);
return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
}
@@ -2001,7 +2001,7 @@ lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char
struct lcs_card *card;
int value;
- card = (struct lcs_card *)dev->driver_data;
+ card = dev_get_drvdata(dev);
if (!card)
return 0;
@@ -2020,7 +2020,7 @@ static ssize_t
lcs_dev_recover_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct lcs_card *card = dev->driver_data;
+ struct lcs_card *card = dev_get_drvdata(dev);
char *tmp;
int i;
@@ -2073,7 +2073,7 @@ lcs_probe_device(struct ccwgroup_device *ccwgdev)
put_device(&ccwgdev->dev);
return ret;
}
- ccwgdev->dev.driver_data = card;
+ dev_set_drvdata(&ccwgdev->dev, card);
ccwgdev->cdev[0]->handler = lcs_irq;
ccwgdev->cdev[1]->handler = lcs_irq;
card->gdev = ccwgdev;
@@ -2090,7 +2090,7 @@ lcs_register_netdev(struct ccwgroup_device *ccwgdev)
struct lcs_card *card;
LCS_DBF_TEXT(2, setup, "regnetdv");
- card = (struct lcs_card *)ccwgdev->dev.driver_data;
+ card = dev_get_drvdata(&ccwgdev->dev);
if (card->dev->reg_state != NETREG_UNINITIALIZED)
return 0;
SET_NETDEV_DEV(card->dev, &ccwgdev->dev);
@@ -2123,7 +2123,7 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
enum lcs_dev_states recover_state;
int rc;
- card = (struct lcs_card *)ccwgdev->dev.driver_data;
+ card = dev_get_drvdata(&ccwgdev->dev);
if (!card)
return -ENODEV;
@@ -2229,7 +2229,7 @@ __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode)
int ret;
LCS_DBF_TEXT(3, setup, "shtdndev");
- card = (struct lcs_card *)ccwgdev->dev.driver_data;
+ card = dev_get_drvdata(&ccwgdev->dev);
if (!card)
return -ENODEV;
if (recovery_mode == 0) {
@@ -2296,7 +2296,7 @@ lcs_remove_device(struct ccwgroup_device *ccwgdev)
{
struct lcs_card *card;
- card = (struct lcs_card *)ccwgdev->dev.driver_data;
+ card = dev_get_drvdata(&ccwgdev->dev);
if (!card)
return;
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index d58fea52557d..6d668642af27 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -34,8 +34,8 @@ static inline int lcs_dbf_passes(debug_info_t *dbf_grp, int level)
* sysfs related stuff
*/
#define CARD_FROM_DEV(cdev) \
- (struct lcs_card *) \
- ((struct ccwgroup_device *)cdev->dev.driver_data)->dev.driver_data;
+ (struct lcs_card *) dev_get_drvdata( \
+ &((struct ccwgroup_device *)dev_get_drvdata(&cdev->dev))->dev);
/**
* CCW commands used in this driver
*/
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index be716e45f7ac..d507f7c65c34 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1364,7 +1364,7 @@ static int netiucv_change_mtu(struct net_device * dev, int new_mtu)
static ssize_t user_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%s\n", netiucv_printname(priv->conn->userid));
@@ -1373,7 +1373,7 @@ static ssize_t user_show(struct device *dev, struct device_attribute *attr,
static ssize_t user_write(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
struct net_device *ndev = priv->conn->netdev;
char *p;
char *tmp;
@@ -1430,7 +1430,8 @@ static DEVICE_ATTR(user, 0644, user_show, user_write);
static ssize_t buffer_show (struct device *dev, struct device_attribute *attr,
char *buf)
-{ struct netiucv_priv *priv = dev->driver_data;
+{
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%d\n", priv->conn->max_buffsize);
@@ -1439,7 +1440,7 @@ static ssize_t buffer_show (struct device *dev, struct device_attribute *attr,
static ssize_t buffer_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
struct net_device *ndev = priv->conn->netdev;
char *e;
int bs1;
@@ -1487,7 +1488,7 @@ static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
static ssize_t dev_fsm_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%s\n", fsm_getstate_str(priv->fsm));
@@ -1498,7 +1499,7 @@ static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL);
static ssize_t conn_fsm_show (struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%s\n", fsm_getstate_str(priv->conn->fsm));
@@ -1509,7 +1510,7 @@ static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL);
static ssize_t maxmulti_show (struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.maxmulti);
@@ -1519,7 +1520,7 @@ static ssize_t maxmulti_write (struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.maxmulti = 0;
@@ -1531,7 +1532,7 @@ static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write);
static ssize_t maxcq_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.maxcqueue);
@@ -1540,7 +1541,7 @@ static ssize_t maxcq_show (struct device *dev, struct device_attribute *attr,
static ssize_t maxcq_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.maxcqueue = 0;
@@ -1552,7 +1553,7 @@ static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write);
static ssize_t sdoio_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.doios_single);
@@ -1561,7 +1562,7 @@ static ssize_t sdoio_show (struct device *dev, struct device_attribute *attr,
static ssize_t sdoio_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.doios_single = 0;
@@ -1573,7 +1574,7 @@ static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write);
static ssize_t mdoio_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.doios_multi);
@@ -1582,7 +1583,7 @@ static ssize_t mdoio_show (struct device *dev, struct device_attribute *attr,
static ssize_t mdoio_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
priv->conn->prof.doios_multi = 0;
@@ -1594,7 +1595,7 @@ static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write);
static ssize_t txlen_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.txlen);
@@ -1603,7 +1604,7 @@ static ssize_t txlen_show (struct device *dev, struct device_attribute *attr,
static ssize_t txlen_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.txlen = 0;
@@ -1615,7 +1616,7 @@ static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write);
static ssize_t txtime_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.tx_time);
@@ -1624,7 +1625,7 @@ static ssize_t txtime_show (struct device *dev, struct device_attribute *attr,
static ssize_t txtime_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.tx_time = 0;
@@ -1636,7 +1637,7 @@ static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write);
static ssize_t txpend_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.tx_pending);
@@ -1645,7 +1646,7 @@ static ssize_t txpend_show (struct device *dev, struct device_attribute *attr,
static ssize_t txpend_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.tx_pending = 0;
@@ -1657,7 +1658,7 @@ static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write);
static ssize_t txmpnd_show (struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 5, __func__);
return sprintf(buf, "%ld\n", priv->conn->prof.tx_max_pending);
@@ -1666,7 +1667,7 @@ static ssize_t txmpnd_show (struct device *dev, struct device_attribute *attr,
static ssize_t txmpnd_write (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct netiucv_priv *priv = dev->driver_data;
+ struct netiucv_priv *priv = dev_get_drvdata(dev);
IUCV_DBF_TEXT(trace, 4, __func__);
priv->conn->prof.tx_max_pending = 0;
@@ -1758,7 +1759,7 @@ static int netiucv_register_device(struct net_device *ndev)
if (ret)
goto out_unreg;
priv->dev = dev;
- dev->driver_data = priv;
+ dev_set_drvdata(dev, priv);
return 0;
out_unreg:
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index c827d69b5a91..2994aa1ed466 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -952,6 +952,7 @@ static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue,
buf->buffer->element[i].addr = NULL;
buf->buffer->element[i].flags = 0;
}
+ buf->buffer->element[15].flags = 0;
buf->next_element_to_fill = 0;
atomic_set(&buf->state, QETH_QDIO_BUF_EMPTY);
}
@@ -1140,6 +1141,8 @@ static int qeth_setup_card(struct qeth_card *card)
card->ipato.enabled = 0;
card->ipato.invert4 = 0;
card->ipato.invert6 = 0;
+ if (card->info.type == QETH_CARD_TYPE_IQD)
+ card->options.checksum_type = NO_CHECKSUMMING;
/* init QDIO stuff */
qeth_init_qdio_info(card);
return 0;
diff --git a/drivers/s390/net/qeth_core_mpc.c b/drivers/s390/net/qeth_core_mpc.c
index 06f4de1f0507..ec24901c802c 100644
--- a/drivers/s390/net/qeth_core_mpc.c
+++ b/drivers/s390/net/qeth_core_mpc.c
@@ -181,6 +181,8 @@ static struct ipa_rc_msg qeth_ipa_rc_msg[] = {
{IPA_RC_L2_ADDR_TABLE_FULL, "Layer2 address table full"},
{IPA_RC_L2_DUP_LAYER3_MAC, "Duplicate with layer 3 MAC"},
{IPA_RC_L2_GMAC_NOT_FOUND, "GMAC not found"},
+ {IPA_RC_L2_MAC_NOT_AUTH_BY_HYP, "L2 mac not authorized by hypervisor"},
+ {IPA_RC_L2_MAC_NOT_AUTH_BY_ADP, "L2 mac not authorized by adapter"},
{IPA_RC_L2_MAC_NOT_FOUND, "L2 mac address not found"},
{IPA_RC_L2_INVALID_VLAN_ID, "L2 invalid vlan id"},
{IPA_RC_L2_DUP_VLAN_ID, "L2 duplicate vlan id"},
diff --git a/drivers/s390/net/qeth_core_mpc.h b/drivers/s390/net/qeth_core_mpc.h
index 18548822e37c..eecb2ee62e85 100644
--- a/drivers/s390/net/qeth_core_mpc.h
+++ b/drivers/s390/net/qeth_core_mpc.h
@@ -168,6 +168,8 @@ enum qeth_ipa_return_codes {
IPA_RC_L2_ADDR_TABLE_FULL = 0x2006,
IPA_RC_L2_DUP_LAYER3_MAC = 0x200a,
IPA_RC_L2_GMAC_NOT_FOUND = 0x200b,
+ IPA_RC_L2_MAC_NOT_AUTH_BY_HYP = 0x200c,
+ IPA_RC_L2_MAC_NOT_AUTH_BY_ADP = 0x200d,
IPA_RC_L2_MAC_NOT_FOUND = 0x2010,
IPA_RC_L2_INVALID_VLAN_ID = 0x2015,
IPA_RC_L2_DUP_VLAN_ID = 0x2016,
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 172031baedc1..9ca6bab7c9ba 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -130,7 +130,7 @@ static int qeth_l2_send_setgroupmac_cb(struct qeth_card *card,
cmd = (struct qeth_ipa_cmd *) data;
mac = &cmd->data.setdelmac.mac[0];
/* MAC already registered, needed in couple/uncouple case */
- if (cmd->hdr.return_code == 0x2005) {
+ if (cmd->hdr.return_code == IPA_RC_L2_DUP_MAC) {
QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s \n",
mac, QETH_CARD_IFNAME(card));
cmd->hdr.return_code = 0;
@@ -502,6 +502,30 @@ static int qeth_l2_send_setmac_cb(struct qeth_card *card,
if (cmd->hdr.return_code) {
QETH_DBF_TEXT_(TRACE, 2, "L2er%x", cmd->hdr.return_code);
card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
+ switch (cmd->hdr.return_code) {
+ case IPA_RC_L2_DUP_MAC:
+ case IPA_RC_L2_DUP_LAYER3_MAC:
+ dev_warn(&card->gdev->dev,
+ "MAC address "
+ "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
+ "already exists\n",
+ card->dev->dev_addr[0], card->dev->dev_addr[1],
+ card->dev->dev_addr[2], card->dev->dev_addr[3],
+ card->dev->dev_addr[4], card->dev->dev_addr[5]);
+ break;
+ case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP:
+ case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP:
+ dev_warn(&card->gdev->dev,
+ "MAC address "
+ "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
+ "is not authorized\n",
+ card->dev->dev_addr[0], card->dev->dev_addr[1],
+ card->dev->dev_addr[2], card->dev->dev_addr[3],
+ card->dev->dev_addr[4], card->dev->dev_addr[5]);
+ break;
+ default:
+ break;
+ }
cmd->hdr.return_code = -EIO;
} else {
card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
@@ -839,6 +863,7 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
{
struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
+ qeth_set_allowed_threads(card, 0, 1);
wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
if (cgdev->state == CCWGROUP_ONLINE) {
@@ -974,8 +999,9 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
dev_warn(&card->gdev->dev,
"The LAN is offline\n");
card->lan_online = 0;
+ return 0;
}
- return rc;
+ goto out_remove;
} else
card->lan_online = 1;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 0ba3817cb6a7..b36b5cdf9000 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1920,16 +1920,22 @@ static inline __u16 qeth_l3_rebuild_skb(struct qeth_card *card,
hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]);
}
- skb->ip_summed = card->options.checksum_type;
- if (card->options.checksum_type == HW_CHECKSUMMING) {
+ switch (card->options.checksum_type) {
+ case SW_CHECKSUMMING:
+ skb->ip_summed = CHECKSUM_NONE;
+ break;
+ case NO_CHECKSUMMING:
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ break;
+ case HW_CHECKSUMMING:
if ((hdr->hdr.l3.ext_flags &
- (QETH_HDR_EXT_CSUM_HDR_REQ |
- QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
- (QETH_HDR_EXT_CSUM_HDR_REQ |
- QETH_HDR_EXT_CSUM_TRANSP_REQ))
+ (QETH_HDR_EXT_CSUM_HDR_REQ |
+ QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
+ (QETH_HDR_EXT_CSUM_HDR_REQ |
+ QETH_HDR_EXT_CSUM_TRANSP_REQ))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
- skb->ip_summed = SW_CHECKSUMMING;
+ skb->ip_summed = CHECKSUM_NONE;
}
return vlan_id;
@@ -3070,6 +3076,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)
{
struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
+ qeth_set_allowed_threads(card, 0, 1);
wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
if (cgdev->state == CCWGROUP_ONLINE) {
@@ -3141,8 +3148,9 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
dev_warn(&card->gdev->dev,
"The LAN is offline\n");
card->lan_online = 0;
+ return 0;
}
- return rc;
+ goto out_remove;
} else
card->lan_online = 1;
qeth_set_large_send(card, card->options.large_send);
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 3ac27ee47396..2ccbd185a5fb 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -470,6 +470,12 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
if (!adapter)
return -ENOMEM;
+ adapter->gs = kzalloc(sizeof(struct zfcp_wka_ports), GFP_KERNEL);
+ if (!adapter->gs) {
+ kfree(adapter);
+ return -ENOMEM;
+ }
+
ccw_device->handler = NULL;
adapter->ccw_device = ccw_device;
atomic_set(&adapter->refcount, 0);
@@ -523,8 +529,7 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
goto sysfs_failed;
atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
-
- zfcp_fc_nameserver_init(adapter);
+ zfcp_fc_wka_ports_init(adapter);
if (!zfcp_adapter_scsi_register(adapter))
return 0;
@@ -571,6 +576,7 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
kfree(adapter->req_list);
kfree(adapter->fc_stats);
kfree(adapter->stats_reset_data);
+ kfree(adapter->gs);
kfree(adapter);
}
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index 733fe3bf6285..b2fe5cdbcaee 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -11,6 +11,24 @@
#include "zfcp_ext.h"
+#define ZFCP_MODEL_PRIV 0x4
+
+static struct ccw_device_id zfcp_ccw_device_id[] = {
+ { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x3) },
+ { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, ZFCP_MODEL_PRIV) },
+ {},
+};
+MODULE_DEVICE_TABLE(ccw, zfcp_ccw_device_id);
+
+/**
+ * zfcp_ccw_priv_sch - check if subchannel is privileged
+ * @adapter: Adapter/Subchannel to check
+ */
+int zfcp_ccw_priv_sch(struct zfcp_adapter *adapter)
+{
+ return adapter->ccw_device->id.dev_model == ZFCP_MODEL_PRIV;
+}
+
/**
* zfcp_ccw_probe - probe function of zfcp driver
* @ccw_device: pointer to belonging ccw device
@@ -176,8 +194,8 @@ static int zfcp_ccw_notify(struct ccw_device *ccw_device, int event)
"ccnoti4", NULL);
break;
case CIO_BOXED:
- dev_warn(&adapter->ccw_device->dev,
- "The ccw device did not respond in time.\n");
+ dev_warn(&adapter->ccw_device->dev, "The FCP device "
+ "did not respond within the specified time\n");
zfcp_erp_adapter_shutdown(adapter, 0, "ccnoti5", NULL);
break;
}
@@ -199,14 +217,6 @@ static void zfcp_ccw_shutdown(struct ccw_device *cdev)
up(&zfcp_data.config_sema);
}
-static struct ccw_device_id zfcp_ccw_device_id[] = {
- { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x3) },
- { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x4) }, /* priv. */
- {},
-};
-
-MODULE_DEVICE_TABLE(ccw, zfcp_ccw_device_id);
-
static struct ccw_driver zfcp_ccw_driver = {
.owner = THIS_MODULE,
.name = "zfcp",
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 0a1a5dd8d018..b99b87ce5a39 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -163,7 +163,7 @@ void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req)
}
response->fsf_command = fsf_req->fsf_command;
- response->fsf_reqid = (unsigned long)fsf_req;
+ response->fsf_reqid = fsf_req->req_id;
response->fsf_seqno = fsf_req->seq_no;
response->fsf_issued = fsf_req->issued;
response->fsf_prot_status = qtcb->prefix.prot_status;
@@ -737,7 +737,7 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
spin_lock_irqsave(&adapter->san_dbf_lock, flags);
memset(r, 0, sizeof(*r));
strncpy(r->tag, "octc", ZFCP_DBF_TAG_SIZE);
- r->fsf_reqid = (unsigned long)fsf_req;
+ r->fsf_reqid = fsf_req->req_id;
r->fsf_seqno = fsf_req->seq_no;
r->s_id = fc_host_port_id(adapter->scsi_host);
r->d_id = wka_port->d_id;
@@ -773,7 +773,7 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
spin_lock_irqsave(&adapter->san_dbf_lock, flags);
memset(r, 0, sizeof(*r));
strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE);
- r->fsf_reqid = (unsigned long)fsf_req;
+ r->fsf_reqid = fsf_req->req_id;
r->fsf_seqno = fsf_req->seq_no;
r->s_id = wka_port->d_id;
r->d_id = fc_host_port_id(adapter->scsi_host);
@@ -803,7 +803,7 @@ static void zfcp_san_dbf_event_els(const char *tag, int level,
spin_lock_irqsave(&adapter->san_dbf_lock, flags);
memset(rec, 0, sizeof(*rec));
strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
- rec->fsf_reqid = (unsigned long)fsf_req;
+ rec->fsf_reqid = fsf_req->req_id;
rec->fsf_seqno = fsf_req->seq_no;
rec->s_id = s_id;
rec->d_id = d_id;
@@ -965,7 +965,7 @@ static void zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level,
ZFCP_DBF_SCSI_FCP_SNS_INFO);
}
- rec->fsf_reqid = (unsigned long)fsf_req;
+ rec->fsf_reqid = fsf_req->req_id;
rec->fsf_seqno = fsf_req->seq_no;
rec->fsf_issued = fsf_req->issued;
}
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 4c362a9069f0..49d0532bca1c 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -22,6 +22,8 @@
#include <linux/syscalls.h>
#include <linux/scatterlist.h>
#include <linux/ioctl.h>
+#include <scsi/fc/fc_fs.h>
+#include <scsi/fc/fc_gs.h>
#include <scsi/scsi.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_cmnd.h>
@@ -29,6 +31,7 @@
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_fc.h>
+#include <scsi/scsi_bsg_fc.h>
#include <asm/ccwdev.h>
#include <asm/qdio.h>
#include <asm/debug.h>
@@ -47,13 +50,6 @@
/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
-/* Adapter Identification Parameters */
-#define ZFCP_CONTROL_UNIT_TYPE 0x1731
-#define ZFCP_CONTROL_UNIT_MODEL 0x03
-#define ZFCP_DEVICE_TYPE 0x1732
-#define ZFCP_DEVICE_MODEL 0x03
-#define ZFCP_DEVICE_MODEL_PRIV 0x04
-
/* DMQ bug workaround: don't use last SBALE */
#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
@@ -235,11 +231,6 @@ struct zfcp_ls_adisc {
/* FC-PH/FC-GS well-known address identifiers for generic services */
#define ZFCP_DID_WKA 0xFFFFF0
-#define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA
-#define ZFCP_DID_TIME_SERVICE 0xFFFFFB
-#define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC
-#define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8
-#define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7
/* remote port status */
#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
@@ -383,6 +374,14 @@ struct zfcp_wka_port {
struct delayed_work work;
};
+struct zfcp_wka_ports {
+ struct zfcp_wka_port ms; /* management service */
+ struct zfcp_wka_port ts; /* time service */
+ struct zfcp_wka_port ds; /* directory service */
+ struct zfcp_wka_port as; /* alias service */
+ struct zfcp_wka_port ks; /* key distribution service */
+};
+
struct zfcp_qdio_queue {
struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
u8 first; /* index of next free bfr in queue */
@@ -468,7 +467,7 @@ struct zfcp_adapter {
actions */
u32 erp_low_mem_count; /* nr of erp actions waiting
for memory */
- struct zfcp_wka_port nsp; /* adapter's nameserver */
+ struct zfcp_wka_ports *gs; /* generic services */
debug_info_t *rec_dbf;
debug_info_t *hba_dbf;
debug_info_t *san_dbf; /* debug feature areas */
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index fdc9b4352a64..8030e25152fb 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -719,7 +719,7 @@ static void zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *act)
zfcp_qdio_close(adapter);
zfcp_fsf_req_dismiss_all(adapter);
adapter->fsf_req_seq_no = 0;
- zfcp_fc_wka_port_force_offline(&adapter->nsp);
+ zfcp_fc_wka_port_force_offline(&adapter->gs->ds);
/* all ports and units are closed */
zfcp_erp_modify_adapter_status(adapter, "erascl1", NULL,
ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
@@ -880,6 +880,7 @@ static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act)
zfcp_port_put(port);
return ZFCP_ERP_CONTINUES;
}
+ /* fall through */
case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
if (!port->d_id)
return ZFCP_ERP_FAILED;
@@ -894,8 +895,13 @@ static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act)
act->step = ZFCP_ERP_STEP_PORT_CLOSING;
return ZFCP_ERP_CONTINUES;
}
- /* fall through otherwise */
}
+ if (port->d_id && !(p_status & ZFCP_STATUS_COMMON_NOESC)) {
+ port->d_id = 0;
+ _zfcp_erp_port_reopen(port, 0, "erpsoc1", NULL);
+ return ZFCP_ERP_EXIT;
+ }
+ /* fall through otherwise */
}
return ZFCP_ERP_FAILED;
}
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index 2e31b536548c..3044c6010306 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -27,6 +27,7 @@ extern int zfcp_sg_setup_table(struct scatterlist *, int);
/* zfcp_ccw.c */
extern int zfcp_ccw_register(void);
+extern int zfcp_ccw_priv_sch(struct zfcp_adapter *);
extern struct zfcp_adapter *zfcp_get_adapter_by_busid(char *);
/* zfcp_cfdc.c */
@@ -105,8 +106,12 @@ extern int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *);
extern void zfcp_fc_plogi_evaluate(struct zfcp_port *, struct fsf_plogi *);
extern void zfcp_test_link(struct zfcp_port *);
extern void zfcp_fc_link_test_work(struct work_struct *);
-extern void zfcp_fc_nameserver_init(struct zfcp_adapter *);
extern void zfcp_fc_wka_port_force_offline(struct zfcp_wka_port *);
+extern void zfcp_fc_wka_ports_init(struct zfcp_adapter *);
+extern int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *);
+extern int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *);
+extern void zfcp_fc_wka_port_force_offline(struct zfcp_wka_port *);
+
/* zfcp_fsf.c */
extern int zfcp_fsf_open_port(struct zfcp_erp_action *);
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 19ae0842047c..2f0705d76b72 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -116,18 +116,17 @@ static void zfcp_wka_port_put(struct zfcp_wka_port *wka_port)
{
if (atomic_dec_return(&wka_port->refcount) != 0)
return;
- /* wait 10 miliseconds, other reqs might pop in */
+ /* wait 10 milliseconds, other reqs might pop in */
schedule_delayed_work(&wka_port->work, HZ / 100);
}
-void zfcp_fc_nameserver_init(struct zfcp_adapter *adapter)
+static void zfcp_fc_wka_port_init(struct zfcp_wka_port *wka_port, u32 d_id,
+ struct zfcp_adapter *adapter)
{
- struct zfcp_wka_port *wka_port = &adapter->nsp;
-
init_waitqueue_head(&wka_port->completion_wq);
wka_port->adapter = adapter;
- wka_port->d_id = ZFCP_DID_DIRECTORY_SERVICE;
+ wka_port->d_id = d_id;
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
atomic_set(&wka_port->refcount, 0);
@@ -143,6 +142,17 @@ void zfcp_fc_wka_port_force_offline(struct zfcp_wka_port *wka)
mutex_unlock(&wka->mutex);
}
+void zfcp_fc_wka_ports_init(struct zfcp_adapter *adapter)
+{
+ struct zfcp_wka_ports *gs = adapter->gs;
+
+ zfcp_fc_wka_port_init(&gs->ms, FC_FID_MGMT_SERV, adapter);
+ zfcp_fc_wka_port_init(&gs->ts, FC_FID_TIME_SERV, adapter);
+ zfcp_fc_wka_port_init(&gs->ds, FC_FID_DIR_SERV, adapter);
+ zfcp_fc_wka_port_init(&gs->as, FC_FID_ALIASES, adapter);
+ zfcp_fc_wka_port_init(&gs->ks, FC_FID_SEC_KEY, adapter);
+}
+
static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
struct fcp_rscn_element *elem)
{
@@ -150,9 +160,14 @@ static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
struct zfcp_port *port;
read_lock_irqsave(&zfcp_data.config_lock, flags);
- list_for_each_entry(port, &fsf_req->adapter->port_list_head, list)
+ list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) {
if ((port->d_id & range) == (elem->nport_did & range))
zfcp_test_link(port);
+ if (!port->d_id)
+ zfcp_erp_port_reopen(port,
+ ZFCP_STATUS_COMMON_ERP_FAILED,
+ "fcrscn1", NULL);
+ }
read_unlock_irqrestore(&zfcp_data.config_lock, flags);
}
@@ -277,7 +292,7 @@ int static zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *erp_action,
/* setup parameters for send generic command */
gid_pn->port = erp_action->port;
- gid_pn->ct.wka_port = &adapter->nsp;
+ gid_pn->ct.wka_port = &adapter->gs->ds;
gid_pn->ct.handler = zfcp_fc_ns_handler;
gid_pn->ct.handler_data = (unsigned long) &compl_rec;
gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT;
@@ -324,13 +339,13 @@ int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *erp_action)
memset(gid_pn, 0, sizeof(*gid_pn));
- ret = zfcp_wka_port_get(&adapter->nsp);
+ ret = zfcp_wka_port_get(&adapter->gs->ds);
if (ret)
goto out;
ret = zfcp_fc_ns_gid_pn_request(erp_action, gid_pn);
- zfcp_wka_port_put(&adapter->nsp);
+ zfcp_wka_port_put(&adapter->gs->ds);
out:
mempool_free(gid_pn, adapter->pool.data_gid_pn);
return ret;
@@ -520,7 +535,7 @@ static int zfcp_scan_issue_gpn_ft(struct zfcp_gpn_ft *gpn_ft,
req->fc4_type = ZFCP_CT_SCSI_FCP;
/* prepare zfcp_send_ct */
- ct->wka_port = &adapter->nsp;
+ ct->wka_port = &adapter->gs->ds;
ct->handler = zfcp_fc_ns_handler;
ct->handler_data = (unsigned long)&compl_rec;
ct->timeout = 10;
@@ -639,7 +654,7 @@ int zfcp_scan_ports(struct zfcp_adapter *adapter)
fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV)
return 0;
- ret = zfcp_wka_port_get(&adapter->nsp);
+ ret = zfcp_wka_port_get(&adapter->gs->ds);
if (ret)
return ret;
@@ -661,7 +676,7 @@ int zfcp_scan_ports(struct zfcp_adapter *adapter)
}
zfcp_free_sg_env(gpn_ft, buf_num);
out:
- zfcp_wka_port_put(&adapter->nsp);
+ zfcp_wka_port_put(&adapter->gs->ds);
return ret;
}
@@ -670,3 +685,158 @@ void _zfcp_scan_ports_later(struct work_struct *work)
{
zfcp_scan_ports(container_of(work, struct zfcp_adapter, scan_work));
}
+
+struct zfcp_els_fc_job {
+ struct zfcp_send_els els;
+ struct fc_bsg_job *job;
+};
+
+static void zfcp_fc_generic_els_handler(unsigned long data)
+{
+ struct zfcp_els_fc_job *els_fc_job = (struct zfcp_els_fc_job *) data;
+ struct fc_bsg_job *job = els_fc_job->job;
+ struct fc_bsg_reply *reply = job->reply;
+
+ if (els_fc_job->els.status) {
+ /* request rejected or timed out */
+ reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_REJECT;
+ goto out;
+ }
+
+ reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK;
+ reply->reply_payload_rcv_len = job->reply_payload.payload_len;
+
+out:
+ job->state_flags = FC_RQST_STATE_DONE;
+ job->job_done(job);
+ kfree(els_fc_job);
+}
+
+int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *job)
+{
+ struct zfcp_els_fc_job *els_fc_job;
+ struct fc_rport *rport = job->rport;
+ struct Scsi_Host *shost;
+ struct zfcp_adapter *adapter;
+ struct zfcp_port *port;
+ u8 *port_did;
+
+ shost = rport ? rport_to_shost(rport) : job->shost;
+ adapter = (struct zfcp_adapter *)shost->hostdata[0];
+
+ if (!(atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN))
+ return -EINVAL;
+
+ els_fc_job = kzalloc(sizeof(struct zfcp_els_fc_job), GFP_KERNEL);
+ if (!els_fc_job)
+ return -ENOMEM;
+
+ els_fc_job->els.adapter = adapter;
+ if (rport) {
+ read_lock_irq(&zfcp_data.config_lock);
+ port = rport->dd_data;
+ if (port)
+ els_fc_job->els.d_id = port->d_id;
+ read_unlock_irq(&zfcp_data.config_lock);
+ if (!port) {
+ kfree(els_fc_job);
+ return -EINVAL;
+ }
+ } else {
+ port_did = job->request->rqst_data.h_els.port_id;
+ els_fc_job->els.d_id = (port_did[0] << 16) +
+ (port_did[1] << 8) + port_did[2];
+ }
+
+ els_fc_job->els.req = job->request_payload.sg_list;
+ els_fc_job->els.resp = job->reply_payload.sg_list;
+ els_fc_job->els.handler = zfcp_fc_generic_els_handler;
+ els_fc_job->els.handler_data = (unsigned long) els_fc_job;
+ els_fc_job->job = job;
+
+ return zfcp_fsf_send_els(&els_fc_job->els);
+}
+
+struct zfcp_ct_fc_job {
+ struct zfcp_send_ct ct;
+ struct fc_bsg_job *job;
+};
+
+static void zfcp_fc_generic_ct_handler(unsigned long data)
+{
+ struct zfcp_ct_fc_job *ct_fc_job = (struct zfcp_ct_fc_job *) data;
+ struct fc_bsg_job *job = ct_fc_job->job;
+
+ job->reply->reply_data.ctels_reply.status = ct_fc_job->ct.status ?
+ FC_CTELS_STATUS_REJECT : FC_CTELS_STATUS_OK;
+ job->reply->reply_payload_rcv_len = job->reply_payload.payload_len;
+ job->state_flags = FC_RQST_STATE_DONE;
+ job->job_done(job);
+
+ zfcp_wka_port_put(ct_fc_job->ct.wka_port);
+
+ kfree(ct_fc_job);
+}
+
+int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *job)
+{
+ int ret;
+ u8 gs_type;
+ struct fc_rport *rport = job->rport;
+ struct Scsi_Host *shost;
+ struct zfcp_adapter *adapter;
+ struct zfcp_ct_fc_job *ct_fc_job;
+ u32 preamble_word1;
+
+ shost = rport ? rport_to_shost(rport) : job->shost;
+
+ adapter = (struct zfcp_adapter *)shost->hostdata[0];
+ if (!(atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN))
+ return -EINVAL;
+
+ ct_fc_job = kzalloc(sizeof(struct zfcp_ct_fc_job), GFP_KERNEL);
+ if (!ct_fc_job)
+ return -ENOMEM;
+
+ preamble_word1 = job->request->rqst_data.r_ct.preamble_word1;
+ gs_type = (preamble_word1 & 0xff000000) >> 24;
+
+ switch (gs_type) {
+ case FC_FST_ALIAS:
+ ct_fc_job->ct.wka_port = &adapter->gs->as;
+ break;
+ case FC_FST_MGMT:
+ ct_fc_job->ct.wka_port = &adapter->gs->ms;
+ break;
+ case FC_FST_TIME:
+ ct_fc_job->ct.wka_port = &adapter->gs->ts;
+ break;
+ case FC_FST_DIR:
+ ct_fc_job->ct.wka_port = &adapter->gs->ds;
+ break;
+ default:
+ kfree(ct_fc_job);
+ return -EINVAL; /* no such service */
+ }
+
+ ret = zfcp_wka_port_get(ct_fc_job->ct.wka_port);
+ if (ret) {
+ kfree(ct_fc_job);
+ return ret;
+ }
+
+ ct_fc_job->ct.req = job->request_payload.sg_list;
+ ct_fc_job->ct.resp = job->reply_payload.sg_list;
+ ct_fc_job->ct.timeout = ZFCP_FSF_REQUEST_TIMEOUT;
+ ct_fc_job->ct.handler = zfcp_fc_generic_ct_handler;
+ ct_fc_job->ct.handler_data = (unsigned long) ct_fc_job;
+ ct_fc_job->ct.completion = NULL;
+ ct_fc_job->job = job;
+
+ ret = zfcp_fsf_send_ct(&ct_fc_job->ct, NULL, NULL);
+ if (ret) {
+ kfree(ct_fc_job);
+ zfcp_wka_port_put(ct_fc_job->ct.wka_port);
+ }
+ return ret;
+}
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 74dee32afba8..c57658f3d34f 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -526,6 +526,7 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
break;
case FSF_TOPO_AL:
fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
+ /* fall through */
default:
dev_err(&adapter->ccw_device->dev,
"Unknown or unsupported arbitrated loop "
@@ -897,6 +898,7 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
switch (fsq->word[0]) {
case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
zfcp_test_link(unit->port);
+ /* fall through */
case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
break;
@@ -993,6 +995,7 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
break;
case FSF_PORT_HANDLE_NOT_VALID:
zfcp_erp_adapter_reopen(adapter, 0, "fsscth1", req);
+ /* fall through */
case FSF_GENERIC_COMMAND_REJECTED:
case FSF_PAYLOAD_SIZE_MISMATCH:
case FSF_REQUEST_SIZE_TOO_LARGE:
@@ -1143,7 +1146,8 @@ static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req)
case FSF_RESPONSE_SIZE_TOO_LARGE:
break;
case FSF_ACCESS_DENIED:
- zfcp_fsf_access_denied_port(req, port);
+ if (port)
+ zfcp_fsf_access_denied_port(req, port);
break;
case FSF_SBAL_MISMATCH:
/* should never occure, avoided in zfcp_fsf_send_els */
@@ -1399,7 +1403,7 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
struct fsf_plogi *plogi;
if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
- return;
+ goto out;
switch (header->fsf_status) {
case FSF_PORT_ALREADY_OPEN:
@@ -1461,6 +1465,9 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
break;
}
+
+out:
+ zfcp_port_put(port);
}
/**
@@ -1473,6 +1480,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
struct qdio_buffer_element *sbale;
struct zfcp_adapter *adapter = erp_action->adapter;
struct zfcp_fsf_req *req;
+ struct zfcp_port *port = erp_action->port;
int retval = -EIO;
spin_lock_bh(&adapter->req_q_lock);
@@ -1493,16 +1501,18 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
req->handler = zfcp_fsf_open_port_handler;
- req->qtcb->bottom.support.d_id = erp_action->port->d_id;
- req->data = erp_action->port;
+ req->qtcb->bottom.support.d_id = port->d_id;
+ req->data = port;
req->erp_action = erp_action;
erp_action->fsf_req = req;
+ zfcp_port_get(port);
zfcp_fsf_start_erp_timer(req);
retval = zfcp_fsf_req_send(req);
if (retval) {
zfcp_fsf_req_free(req);
erp_action->fsf_req = NULL;
+ zfcp_port_put(port);
}
out:
spin_unlock_bh(&adapter->req_q_lock);
@@ -1590,8 +1600,10 @@ static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
dev_warn(&req->adapter->ccw_device->dev,
"Opening WKA port 0x%x failed\n", wka_port->d_id);
+ /* fall through */
case FSF_ADAPTER_STATUS_AVAILABLE:
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+ /* fall through */
case FSF_ACCESS_DENIED:
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
break;
@@ -1876,7 +1888,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) &&
(adapter->adapter_features & FSF_FEATURE_LUN_SHARING) &&
- (adapter->ccw_device->id.dev_model != ZFCP_DEVICE_MODEL_PRIV)) {
+ !zfcp_ccw_priv_sch(adapter)) {
exclusive = (bottom->lun_access_info &
FSF_UNIT_ACCESS_EXCLUSIVE);
readwrite = (bottom->lun_access_info &
@@ -2314,7 +2326,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
{
struct zfcp_fsf_req *req;
struct fcp_cmnd_iu *fcp_cmnd_iu;
- unsigned int sbtype;
+ unsigned int sbtype = SBAL_FLAGS0_TYPE_READ;
int real_bytes, retval = -EIO;
struct zfcp_adapter *adapter = unit->port->adapter;
@@ -2356,11 +2368,9 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
switch (scsi_cmnd->sc_data_direction) {
case DMA_NONE:
req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
- sbtype = SBAL_FLAGS0_TYPE_READ;
break;
case DMA_FROM_DEVICE:
req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ;
- sbtype = SBAL_FLAGS0_TYPE_READ;
fcp_cmnd_iu->rddata = 1;
break;
case DMA_TO_DEVICE:
@@ -2369,8 +2379,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
fcp_cmnd_iu->wddata = 1;
break;
case DMA_BIDIRECTIONAL:
- default:
- retval = -EIO;
goto failed_scsi_cmnd;
}
@@ -2394,9 +2402,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
scsi_sglist(scsi_cmnd),
FSF_MAX_SBALS_PER_REQ);
if (unlikely(real_bytes < 0)) {
- if (req->sbal_number < FSF_MAX_SBALS_PER_REQ)
- retval = -EIO;
- else {
+ if (req->sbal_number >= FSF_MAX_SBALS_PER_REQ) {
dev_err(&adapter->ccw_device->dev,
"Oversize data package, unit 0x%016Lx "
"on port 0x%016Lx closed\n",
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index e8fbeaeb5fbf..967ede73f4c5 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -12,6 +12,10 @@
#include "zfcp_ext.h"
#include <asm/atomic.h>
+static unsigned int default_depth = 32;
+module_param_named(queue_depth, default_depth, uint, 0600);
+MODULE_PARM_DESC(queue_depth, "Default queue depth for new SCSI devices");
+
/* Find start of Sense Information in FCP response unit*/
char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu)
{
@@ -24,6 +28,12 @@ char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu)
return fcp_sns_info_ptr;
}
+static int zfcp_scsi_change_queue_depth(struct scsi_device *sdev, int depth)
+{
+ scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
+ return sdev->queue_depth;
+}
+
static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt)
{
struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata;
@@ -34,7 +44,7 @@ static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt)
static int zfcp_scsi_slave_configure(struct scsi_device *sdp)
{
if (sdp->tagged_supported)
- scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, 32);
+ scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, default_depth);
else
scsi_adjust_queue_depth(sdp, 0, 1);
return 0;
@@ -613,6 +623,20 @@ void zfcp_scsi_scan(struct work_struct *work)
zfcp_unit_put(unit);
}
+static int zfcp_execute_fc_job(struct fc_bsg_job *job)
+{
+ switch (job->request->msgcode) {
+ case FC_BSG_RPT_ELS:
+ case FC_BSG_HST_ELS_NOLOGIN:
+ return zfcp_fc_execute_els_fc_job(job);
+ case FC_BSG_RPT_CT:
+ case FC_BSG_HST_CT:
+ return zfcp_fc_execute_ct_fc_job(job);
+ default:
+ return -EINVAL;
+ }
+}
+
struct fc_function_template zfcp_transport_functions = {
.show_starget_port_id = 1,
.show_starget_port_name = 1,
@@ -634,6 +658,7 @@ struct fc_function_template zfcp_transport_functions = {
.dev_loss_tmo_callbk = zfcp_scsi_dev_loss_tmo_callbk,
.terminate_rport_io = zfcp_scsi_terminate_rport_io,
.show_host_port_state = 1,
+ .bsg_request = zfcp_execute_fc_job,
/* no functions registered for following dynamic attributes but
directly set by LLDD */
.show_host_port_type = 1,
@@ -647,6 +672,7 @@ struct zfcp_data zfcp_data = {
.name = "zfcp",
.module = THIS_MODULE,
.proc_name = "zfcp",
+ .change_queue_depth = zfcp_scsi_change_queue_depth,
.slave_alloc = zfcp_scsi_slave_alloc,
.slave_configure = zfcp_scsi_slave_configure,
.slave_destroy = zfcp_scsi_slave_destroy,
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index a85ad05e8548..6d4651684688 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -186,31 +186,31 @@ static void jsfd_do_request(struct request_queue *q)
{
struct request *req;
- while ((req = elv_next_request(q)) != NULL) {
+ req = blk_fetch_request(q);
+ while (req) {
struct jsfd_part *jdp = req->rq_disk->private_data;
- unsigned long offset = req->sector << 9;
- size_t len = req->current_nr_sectors << 9;
+ unsigned long offset = blk_rq_pos(req) << 9;
+ size_t len = blk_rq_cur_bytes(req);
+ int err = -EIO;
- if ((offset + len) > jdp->dsize) {
- end_request(req, 0);
- continue;
- }
+ if ((offset + len) > jdp->dsize)
+ goto end;
if (rq_data_dir(req) != READ) {
printk(KERN_ERR "jsfd: write\n");
- end_request(req, 0);
- continue;
+ goto end;
}
if ((jdp->dbase & 0xff000000) != 0x20000000) {
printk(KERN_ERR "jsfd: bad base %x\n", (int)jdp->dbase);
- end_request(req, 0);
- continue;
+ goto end;
}
jsfd_read(req->buffer, jdp->dbase + offset, len);
-
- end_request(req, 1);
+ err = 0;
+ end:
+ if (!__blk_end_request_cur(req, err))
+ req = blk_fetch_request(q);
}
}
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 8b7983aba8f7..36c21b19e5d7 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1978,7 +1978,8 @@ static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id)
{
struct scsi_cmnd *cmd = tw_dev->srb[request_id];
- scsi_dma_unmap(cmd);
+ if (cmd->SCp.phase == TW_PHASE_SGLIST)
+ scsi_dma_unmap(cmd);
} /* End twa_unmap_scsi_data() */
/* scsi_host_template initializer */
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index c03f1d2c9e2e..faa0fcfed71e 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -6,7 +6,7 @@
Arnaldo Carvalho de Melo <acme@conectiva.com.br>
Brad Strand <linux@3ware.com>
- Copyright (C) 1999-2007 3ware Inc.
+ Copyright (C) 1999-2009 3ware Inc.
Kernel compatiblity By: Andre Hedrick <andre@suse.com>
Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com>
@@ -1294,7 +1294,8 @@ static void tw_unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
{
dprintk(KERN_WARNING "3w-xxxx: tw_unmap_scsi_data()\n");
- scsi_dma_unmap(cmd);
+ if (cmd->SCp.phase == TW_PHASE_SGLIST)
+ scsi_dma_unmap(cmd);
} /* End tw_unmap_scsi_data() */
/* This function will reset a device extension */
diff --git a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h
index 8e71e5e122b3..a5a2ba2561d9 100644
--- a/drivers/scsi/3w-xxxx.h
+++ b/drivers/scsi/3w-xxxx.h
@@ -6,7 +6,7 @@
Arnaldo Carvalho de Melo <acme@conectiva.com.br>
Brad Strand <linux@3ware.com>
- Copyright (C) 1999-2007 3ware Inc.
+ Copyright (C) 1999-2009 3ware Inc.
Kernel compatiblity By: Andre Hedrick <andre@suse.com>
Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com>
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 8ed2990c826e..759e1507e63c 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -191,20 +191,19 @@ config SCSI_ENCLOSURE
it has an enclosure device. Selecting this option will just allow
certain enclosure conditions to be reported and is not required.
-comment "Some SCSI devices (e.g. CD jukebox) support multiple LUNs"
- depends on SCSI
-
config SCSI_MULTI_LUN
bool "Probe all LUNs on each SCSI device"
depends on SCSI
help
- If you have a SCSI device that supports more than one LUN (Logical
- Unit Number), e.g. a CD jukebox, and only one LUN is detected, you
- can say Y here to force the SCSI driver to probe for multiple LUNs.
- A SCSI device with multiple LUNs acts logically like multiple SCSI
- devices. The vast majority of SCSI devices have only one LUN, and
- so most people can say N here. The max_luns boot/module parameter
- allows to override this setting.
+ Some devices support more than one LUN (Logical Unit Number) in order
+ to allow access to several media, e.g. CD jukebox, USB card reader,
+ mobile phone in mass storage mode. This option forces the kernel to
+ probe for all LUNs by default. This setting can be overriden by
+ max_luns boot/module parameter. Note that this option does not affect
+ devices conforming to SCSI-3 or higher as they can explicitely report
+ their number of LUNs. It is safe to say Y here unless you have one of
+ those rare devices which reacts in an unexpected way when probed for
+ multiple LUNs.
config SCSI_CONSTANTS
bool "Verbose SCSI error reporting (kernel size +=12K)"
@@ -508,6 +507,7 @@ config SCSI_AIC7XXX_OLD
source "drivers/scsi/aic7xxx/Kconfig.aic79xx"
source "drivers/scsi/aic94xx/Kconfig"
+source "drivers/scsi/mvsas/Kconfig"
config SCSI_DPT_I2O
tristate "Adaptec I2O RAID support "
@@ -628,6 +628,17 @@ config FCOE
---help---
Fibre Channel over Ethernet module
+config FCOE_FNIC
+ tristate "Cisco FNIC Driver"
+ depends on PCI && X86
+ select LIBFC
+ help
+ This is support for the Cisco PCI-Express FCoE HBA.
+
+ To compile this driver as a module, choose M here and read
+ <file:Documentation/scsi/scsi.txt>.
+ The module will be called fnic.
+
config SCSI_DMX3191D
tristate "DMX3191D SCSI support"
depends on PCI && SCSI
@@ -1039,16 +1050,6 @@ config SCSI_IZIP_SLOW_CTR
Generally, saying N is fine.
-config SCSI_MVSAS
- tristate "Marvell 88SE6440 SAS/SATA support"
- depends on PCI && SCSI
- select SCSI_SAS_LIBSAS
- help
- This driver supports Marvell SAS/SATA PCI devices.
-
- To compiler this driver as a module, choose M here: the module
- will be called mvsas.
-
config SCSI_NCR53C406A
tristate "NCR53c406a SCSI support"
depends on ISA && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index e7c861ac417d..8795c309963e 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_SCSI_DH) += device_handler/
obj-$(CONFIG_LIBFC) += libfc/
obj-$(CONFIG_LIBFCOE) += fcoe/
obj-$(CONFIG_FCOE) += fcoe/
+obj-$(CONFIG_FCOE_FNIC) += fnic/
obj-$(CONFIG_ISCSI_TCP) += libiscsi.o libiscsi_tcp.o iscsi_tcp.o
obj-$(CONFIG_INFINIBAND_ISER) += libiscsi.o
obj-$(CONFIG_SCSI_A4000T) += 53c700.o a4000t.o
@@ -125,7 +126,7 @@ obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/
obj-$(CONFIG_SCSI_IBMVFC) += ibmvscsi/
obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
obj-$(CONFIG_SCSI_STEX) += stex.o
-obj-$(CONFIG_SCSI_MVSAS) += mvsas.o
+obj-$(CONFIG_SCSI_MVSAS) += mvsas/
obj-$(CONFIG_PS3_ROM) += ps3rom.o
obj-$(CONFIG_SCSI_CXGB3_ISCSI) += libiscsi.o libiscsi_tcp.o cxgb3i/
diff --git a/drivers/scsi/NCR_D700.c b/drivers/scsi/NCR_D700.c
index c889d8458684..1cdf09a4779a 100644
--- a/drivers/scsi/NCR_D700.c
+++ b/drivers/scsi/NCR_D700.c
@@ -224,7 +224,7 @@ NCR_D700_probe_one(struct NCR_D700_private *p, int siop, int irq,
return ret;
}
-static int
+static irqreturn_t
NCR_D700_intr(int irq, void *data)
{
struct NCR_D700_private *p = (struct NCR_D700_private *)data;
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index ed0e3e55652a..538135783aab 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -646,7 +646,7 @@ static int aha1740_probe (struct device *dev)
static __devexit int aha1740_remove (struct device *dev)
{
- struct Scsi_Host *shpnt = dev->driver_data;
+ struct Scsi_Host *shpnt = dev_get_drvdata(dev);
struct aha1740_hostdata *host = HOSTDATA (shpnt);
scsi_remove_host(shpnt);
diff --git a/drivers/scsi/cxgb3i/cxgb3i.h b/drivers/scsi/cxgb3i/cxgb3i.h
index 59b0958d2d11..e3133b58e594 100644
--- a/drivers/scsi/cxgb3i/cxgb3i.h
+++ b/drivers/scsi/cxgb3i/cxgb3i.h
@@ -144,7 +144,6 @@ struct cxgb3i_adapter *cxgb3i_adapter_find_by_tdev(struct t3cdev *);
void cxgb3i_adapter_open(struct t3cdev *);
void cxgb3i_adapter_close(struct t3cdev *);
-struct cxgb3i_hba *cxgb3i_hba_find_by_netdev(struct net_device *);
struct cxgb3i_hba *cxgb3i_hba_host_add(struct cxgb3i_adapter *,
struct net_device *);
void cxgb3i_hba_host_remove(struct cxgb3i_hba *);
diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
index 9212400b9b13..04a43744aedf 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
@@ -178,7 +178,7 @@ void cxgb3i_adapter_close(struct t3cdev *t3dev)
* cxgb3i_hba_find_by_netdev - find the cxgb3i_hba structure via net_device
* @t3dev: t3cdev adapter
*/
-struct cxgb3i_hba *cxgb3i_hba_find_by_netdev(struct net_device *ndev)
+static struct cxgb3i_hba *cxgb3i_hba_find_by_netdev(struct net_device *ndev)
{
struct cxgb3i_adapter *snic;
int i;
@@ -261,20 +261,27 @@ void cxgb3i_hba_host_remove(struct cxgb3i_hba *hba)
/**
* cxgb3i_ep_connect - establish TCP connection to target portal
+ * @shost: scsi host to use
* @dst_addr: target IP address
* @non_blocking: blocking or non-blocking call
*
* Initiates a TCP/IP connection to the dst_addr
*/
-static struct iscsi_endpoint *cxgb3i_ep_connect(struct sockaddr *dst_addr,
+static struct iscsi_endpoint *cxgb3i_ep_connect(struct Scsi_Host *shost,
+ struct sockaddr *dst_addr,
int non_blocking)
{
struct iscsi_endpoint *ep;
struct cxgb3i_endpoint *cep;
- struct cxgb3i_hba *hba;
+ struct cxgb3i_hba *hba = NULL;
struct s3_conn *c3cn = NULL;
int err = 0;
+ if (shost)
+ hba = iscsi_host_priv(shost);
+
+ cxgb3i_api_debug("shost 0x%p, hba 0x%p.\n", shost, hba);
+
c3cn = cxgb3i_c3cn_create();
if (!c3cn) {
cxgb3i_log_info("ep connect OOM.\n");
@@ -282,17 +289,27 @@ static struct iscsi_endpoint *cxgb3i_ep_connect(struct sockaddr *dst_addr,
goto release_conn;
}
- err = cxgb3i_c3cn_connect(c3cn, (struct sockaddr_in *)dst_addr);
+ err = cxgb3i_c3cn_connect(hba ? hba->ndev : NULL, c3cn,
+ (struct sockaddr_in *)dst_addr);
if (err < 0) {
cxgb3i_log_info("ep connect failed.\n");
goto release_conn;
}
+
hba = cxgb3i_hba_find_by_netdev(c3cn->dst_cache->dev);
if (!hba) {
err = -ENOSPC;
cxgb3i_log_info("NOT going through cxgbi device.\n");
goto release_conn;
}
+
+ if (shost && hba != iscsi_host_priv(shost)) {
+ err = -ENOSPC;
+ cxgb3i_log_info("Could not connect through request host%u\n",
+ shost->host_no);
+ goto release_conn;
+ }
+
if (c3cn_is_closing(c3cn)) {
err = -ENOSPC;
cxgb3i_log_info("ep connect unable to connect.\n");
diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index e11c9c180f39..c1d5be4adf9c 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -1479,12 +1479,13 @@ static struct net_device *cxgb3_egress_dev(struct net_device *root_dev,
return NULL;
}
-static struct rtable *find_route(__be32 saddr, __be32 daddr,
+static struct rtable *find_route(struct net_device *dev,
+ __be32 saddr, __be32 daddr,
__be16 sport, __be16 dport)
{
struct rtable *rt;
struct flowi fl = {
- .oif = 0,
+ .oif = dev ? dev->ifindex : 0,
.nl_u = {
.ip4_u = {
.daddr = daddr,
@@ -1573,36 +1574,40 @@ out_err:
*
* return 0 if active open request is sent, < 0 otherwise.
*/
-int cxgb3i_c3cn_connect(struct s3_conn *c3cn, struct sockaddr_in *usin)
+int cxgb3i_c3cn_connect(struct net_device *dev, struct s3_conn *c3cn,
+ struct sockaddr_in *usin)
{
struct rtable *rt;
- struct net_device *dev;
struct cxgb3i_sdev_data *cdata;
struct t3cdev *cdev;
__be32 sipv4;
int err;
+ c3cn_conn_debug("c3cn 0x%p, dev 0x%p.\n", c3cn, dev);
+
if (usin->sin_family != AF_INET)
return -EAFNOSUPPORT;
c3cn->daddr.sin_port = usin->sin_port;
c3cn->daddr.sin_addr.s_addr = usin->sin_addr.s_addr;
- rt = find_route(c3cn->saddr.sin_addr.s_addr,
+ rt = find_route(dev, c3cn->saddr.sin_addr.s_addr,
c3cn->daddr.sin_addr.s_addr,
c3cn->saddr.sin_port,
c3cn->daddr.sin_port);
if (rt == NULL) {
- c3cn_conn_debug("NO route to 0x%x, port %u.\n",
+ c3cn_conn_debug("NO route to 0x%x, port %u, dev %s.\n",
c3cn->daddr.sin_addr.s_addr,
- ntohs(c3cn->daddr.sin_port));
+ ntohs(c3cn->daddr.sin_port),
+ dev ? dev->name : "any");
return -ENETUNREACH;
}
if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
- c3cn_conn_debug("multi-cast route to 0x%x, port %u.\n",
+ c3cn_conn_debug("multi-cast route to 0x%x, port %u, dev %s.\n",
c3cn->daddr.sin_addr.s_addr,
- ntohs(c3cn->daddr.sin_port));
+ ntohs(c3cn->daddr.sin_port),
+ dev ? dev->name : "any");
ip_rt_put(rt);
return -ENETUNREACH;
}
diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.h b/drivers/scsi/cxgb3i/cxgb3i_offload.h
index ebfca960c0a9..6a1d86b1fafe 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.h
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.h
@@ -169,7 +169,8 @@ void cxgb3i_sdev_add(struct t3cdev *, struct cxgb3_client *);
void cxgb3i_sdev_remove(struct t3cdev *);
struct s3_conn *cxgb3i_c3cn_create(void);
-int cxgb3i_c3cn_connect(struct s3_conn *, struct sockaddr_in *);
+int cxgb3i_c3cn_connect(struct net_device *, struct s3_conn *,
+ struct sockaddr_in *);
void cxgb3i_c3cn_rx_credits(struct s3_conn *, int);
int cxgb3i_c3cn_send_pdus(struct s3_conn *, struct sk_buff *);
void cxgb3i_c3cn_release(struct s3_conn *);
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 43b8c51e98d0..fd0544f7da81 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -561,6 +561,12 @@ static int rdac_check_sense(struct scsi_device *sdev,
struct rdac_dh_data *h = get_rdac_data(sdev);
switch (sense_hdr->sense_key) {
case NOT_READY:
+ if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01)
+ /* LUN Not Ready - Logical Unit Not Ready and is in
+ * the process of becoming ready
+ * Just retry.
+ */
+ return ADD_TO_MLQUEUE;
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x81)
/* LUN Not Ready - Storage firmware incompatible
* Manual code synchonisation required.
diff --git a/drivers/scsi/dpt/osd_util.h b/drivers/scsi/dpt/osd_util.h
index 4b56c0436ba2..b2613c2eaac7 100644
--- a/drivers/scsi/dpt/osd_util.h
+++ b/drivers/scsi/dpt/osd_util.h
@@ -342,7 +342,7 @@ uLONG osdGetThreadID(void);
/* wakes up the specifed thread */
void osdWakeThread(uLONG);
-/* osd sleep for x miliseconds */
+/* osd sleep for x milliseconds */
void osdSleep(uLONG);
#define DPT_THREAD_PRIORITY_LOWEST 0x00
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index be5099dd94b5..c7076ce25e21 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -1825,7 +1825,7 @@ static int eata2x_queuecommand(struct scsi_cmnd *SCpnt,
if (linked_comm && SCpnt->device->queue_depth > 2
&& TLDEV(SCpnt->device->type)) {
ha->cp_stat[i] = READY;
- flush_dev(SCpnt->device, SCpnt->request->sector, ha, 0);
+ flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), ha, 0);
return 0;
}
@@ -2144,13 +2144,13 @@ static int reorder(struct hostdata *ha, unsigned long cursec,
if (!cpp->din)
input_only = 0;
- if (SCpnt->request->sector < minsec)
- minsec = SCpnt->request->sector;
- if (SCpnt->request->sector > maxsec)
- maxsec = SCpnt->request->sector;
+ if (blk_rq_pos(SCpnt->request) < minsec)
+ minsec = blk_rq_pos(SCpnt->request);
+ if (blk_rq_pos(SCpnt->request) > maxsec)
+ maxsec = blk_rq_pos(SCpnt->request);
- sl[n] = SCpnt->request->sector;
- ioseek += SCpnt->request->nr_sectors;
+ sl[n] = blk_rq_pos(SCpnt->request);
+ ioseek += blk_rq_sectors(SCpnt->request);
if (!n)
continue;
@@ -2190,7 +2190,7 @@ static int reorder(struct hostdata *ha, unsigned long cursec,
k = il[n];
cpp = &ha->cp[k];
SCpnt = cpp->SCpnt;
- ll[n] = SCpnt->request->nr_sectors;
+ ll[n] = blk_rq_sectors(SCpnt->request);
pl[n] = SCpnt->serial_number;
if (!n)
@@ -2236,12 +2236,12 @@ static int reorder(struct hostdata *ha, unsigned long cursec,
cpp = &ha->cp[k];
SCpnt = cpp->SCpnt;
scmd_printk(KERN_INFO, SCpnt,
- "%s pid %ld mb %d fc %d nr %d sec %ld ns %ld"
+ "%s pid %ld mb %d fc %d nr %d sec %ld ns %u"
" cur %ld s:%c r:%c rev:%c in:%c ov:%c xd %d.\n",
(ihdlr ? "ihdlr" : "qcomm"),
SCpnt->serial_number, k, flushcount,
- n_ready, SCpnt->request->sector,
- SCpnt->request->nr_sectors, cursec, YESNO(s),
+ n_ready, blk_rq_pos(SCpnt->request),
+ blk_rq_sectors(SCpnt->request), cursec, YESNO(s),
YESNO(r), YESNO(rev), YESNO(input_only),
YESNO(overlap), cpp->din);
}
@@ -2408,7 +2408,7 @@ static irqreturn_t ihdlr(struct Scsi_Host *shost)
if (linked_comm && SCpnt->device->queue_depth > 2
&& TLDEV(SCpnt->device->type))
- flush_dev(SCpnt->device, SCpnt->request->sector, ha, 1);
+ flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), ha, 1);
tstatus = status_byte(spp->target_status);
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 03e1926f40b5..612262562b07 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -136,6 +136,58 @@ static struct scsi_host_template fcoe_shost_template = {
};
/**
+ * fcoe_fip_recv - handle a received FIP frame.
+ * @skb: the receive skb
+ * @dev: associated &net_device
+ * @ptype: the &packet_type structure which was used to register this handler.
+ * @orig_dev: original receive &net_device, in case @dev is a bond.
+ *
+ * Returns: 0 for success
+ */
+static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
+ struct packet_type *ptype,
+ struct net_device *orig_dev)
+{
+ struct fcoe_softc *fc;
+
+ fc = container_of(ptype, struct fcoe_softc, fip_packet_type);
+ fcoe_ctlr_recv(&fc->ctlr, skb);
+ return 0;
+}
+
+/**
+ * fcoe_fip_send() - send an Ethernet-encapsulated FIP frame.
+ * @fip: FCoE controller.
+ * @skb: FIP Packet.
+ */
+static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
+{
+ skb->dev = fcoe_from_ctlr(fip)->real_dev;
+ dev_queue_xmit(skb);
+}
+
+/**
+ * fcoe_update_src_mac() - Update Ethernet MAC filters.
+ * @fip: FCoE controller.
+ * @old: Unicast MAC address to delete if the MAC is non-zero.
+ * @new: Unicast MAC address to add.
+ *
+ * Remove any previously-set unicast MAC filter.
+ * Add secondary FCoE MAC address filter for our OUI.
+ */
+static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
+{
+ struct fcoe_softc *fc;
+
+ fc = fcoe_from_ctlr(fip);
+ rtnl_lock();
+ if (!is_zero_ether_addr(old))
+ dev_unicast_delete(fc->real_dev, old, ETH_ALEN);
+ dev_unicast_add(fc->real_dev, new, ETH_ALEN);
+ rtnl_unlock();
+}
+
+/**
* fcoe_lport_config() - sets up the fc_lport
* @lp: ptr to the fc_lport
*
@@ -146,6 +198,7 @@ static int fcoe_lport_config(struct fc_lport *lp)
lp->link_up = 0;
lp->qfull = 0;
lp->max_retry_count = 3;
+ lp->max_rport_retry_count = 3;
lp->e_d_tov = 2 * 1000; /* FC-FS default */
lp->r_a_tov = 2 * 2 * 1000;
lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS |
@@ -167,6 +220,32 @@ static int fcoe_lport_config(struct fc_lport *lp)
}
/**
+ * fcoe_netdev_cleanup() - clean up netdev configurations
+ * @fc: ptr to the fcoe_softc
+ */
+void fcoe_netdev_cleanup(struct fcoe_softc *fc)
+{
+ u8 flogi_maddr[ETH_ALEN];
+
+ /* Don't listen for Ethernet packets anymore */
+ dev_remove_pack(&fc->fcoe_packet_type);
+ dev_remove_pack(&fc->fip_packet_type);
+
+ /* Delete secondary MAC addresses */
+ rtnl_lock();
+ memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
+ dev_unicast_delete(fc->real_dev, flogi_maddr, ETH_ALEN);
+ if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
+ dev_unicast_delete(fc->real_dev,
+ fc->ctlr.data_src_addr, ETH_ALEN);
+ if (fc->ctlr.spma)
+ dev_unicast_delete(fc->real_dev,
+ fc->ctlr.ctl_src_addr, ETH_ALEN);
+ dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
+ rtnl_unlock();
+}
+
+/**
* fcoe_netdev_config() - Set up netdev for SW FCoE
* @lp : ptr to the fc_lport
* @netdev : ptr to the associated netdevice struct
@@ -181,6 +260,7 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
u64 wwnn, wwpn;
struct fcoe_softc *fc;
u8 flogi_maddr[ETH_ALEN];
+ struct netdev_hw_addr *ha;
/* Setup lport private data to point to fcoe softc */
fc = lport_priv(lp);
@@ -237,9 +317,23 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
skb_queue_head_init(&fc->fcoe_pending_queue);
fc->fcoe_pending_queue_active = 0;
+ /* look for SAN MAC address, if multiple SAN MACs exist, only
+ * use the first one for SPMA */
+ rcu_read_lock();
+ for_each_dev_addr(netdev, ha) {
+ if ((ha->type == NETDEV_HW_ADDR_T_SAN) &&
+ (is_valid_ether_addr(fc->ctlr.ctl_src_addr))) {
+ memcpy(fc->ctlr.ctl_src_addr, ha->addr, ETH_ALEN);
+ fc->ctlr.spma = 1;
+ break;
+ }
+ }
+ rcu_read_unlock();
+
/* setup Source Mac Address */
- memcpy(fc->ctlr.ctl_src_addr, fc->real_dev->dev_addr,
- fc->real_dev->addr_len);
+ if (!fc->ctlr.spma)
+ memcpy(fc->ctlr.ctl_src_addr, fc->real_dev->dev_addr,
+ fc->real_dev->addr_len);
wwnn = fcoe_wwn_from_mac(fc->real_dev->dev_addr, 1, 0);
fc_set_wwnn(lp, wwnn);
@@ -255,6 +349,8 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_add(fc->real_dev, flogi_maddr, ETH_ALEN);
+ if (fc->ctlr.spma)
+ dev_unicast_add(fc->real_dev, fc->ctlr.ctl_src_addr, ETH_ALEN);
dev_mc_add(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock();
@@ -267,6 +363,11 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
fc->fcoe_packet_type.dev = fc->real_dev;
dev_add_pack(&fc->fcoe_packet_type);
+ fc->fip_packet_type.func = fcoe_fip_recv;
+ fc->fip_packet_type.type = htons(ETH_P_FIP);
+ fc->fip_packet_type.dev = fc->real_dev;
+ dev_add_pack(&fc->fip_packet_type);
+
return 0;
}
@@ -334,7 +435,6 @@ static int fcoe_if_destroy(struct net_device *netdev)
{
struct fc_lport *lp = NULL;
struct fcoe_softc *fc;
- u8 flogi_maddr[ETH_ALEN];
BUG_ON(!netdev);
@@ -353,9 +453,10 @@ static int fcoe_if_destroy(struct net_device *netdev)
/* Remove the instance from fcoe's list */
fcoe_hostlist_remove(lp);
- /* Don't listen for Ethernet packets anymore */
- dev_remove_pack(&fc->fcoe_packet_type);
- dev_remove_pack(&fc->fip_packet_type);
+ /* clean up netdev configurations */
+ fcoe_netdev_cleanup(fc);
+
+ /* tear-down the FCoE controller */
fcoe_ctlr_destroy(&fc->ctlr);
/* Cleanup the fc_lport */
@@ -370,16 +471,6 @@ static int fcoe_if_destroy(struct net_device *netdev)
if (lp->emp)
fc_exch_mgr_free(lp->emp);
- /* Delete secondary MAC addresses */
- rtnl_lock();
- memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
- dev_unicast_delete(fc->real_dev, flogi_maddr, ETH_ALEN);
- if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
- dev_unicast_delete(fc->real_dev,
- fc->ctlr.data_src_addr, ETH_ALEN);
- dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
- rtnl_unlock();
-
/* Free the per-CPU receive threads */
fcoe_percpu_clean(lp);
@@ -439,58 +530,6 @@ static struct libfc_function_template fcoe_libfc_fcn_templ = {
};
/**
- * fcoe_fip_recv - handle a received FIP frame.
- * @skb: the receive skb
- * @dev: associated &net_device
- * @ptype: the &packet_type structure which was used to register this handler.
- * @orig_dev: original receive &net_device, in case @dev is a bond.
- *
- * Returns: 0 for success
- */
-static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
- struct packet_type *ptype,
- struct net_device *orig_dev)
-{
- struct fcoe_softc *fc;
-
- fc = container_of(ptype, struct fcoe_softc, fip_packet_type);
- fcoe_ctlr_recv(&fc->ctlr, skb);
- return 0;
-}
-
-/**
- * fcoe_fip_send() - send an Ethernet-encapsulated FIP frame.
- * @fip: FCoE controller.
- * @skb: FIP Packet.
- */
-static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
-{
- skb->dev = fcoe_from_ctlr(fip)->real_dev;
- dev_queue_xmit(skb);
-}
-
-/**
- * fcoe_update_src_mac() - Update Ethernet MAC filters.
- * @fip: FCoE controller.
- * @old: Unicast MAC address to delete if the MAC is non-zero.
- * @new: Unicast MAC address to add.
- *
- * Remove any previously-set unicast MAC filter.
- * Add secondary FCoE MAC address filter for our OUI.
- */
-static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
-{
- struct fcoe_softc *fc;
-
- fc = fcoe_from_ctlr(fip);
- rtnl_lock();
- if (!is_zero_ether_addr(old))
- dev_unicast_delete(fc->real_dev, old, ETH_ALEN);
- dev_unicast_add(fc->real_dev, new, ETH_ALEN);
- rtnl_unlock();
-}
-
-/**
* fcoe_if_create() - this function creates the fcoe interface
* @netdev: pointer the associated netdevice
*
@@ -531,13 +570,6 @@ static int fcoe_if_create(struct net_device *netdev)
goto out_host_put;
}
- /* configure lport network properties */
- rc = fcoe_netdev_config(lp, netdev);
- if (rc) {
- FC_DBG("Could not configure netdev for lport\n");
- goto out_host_put;
- }
-
/*
* Initialize FIP.
*/
@@ -545,23 +577,25 @@ static int fcoe_if_create(struct net_device *netdev)
fc->ctlr.send = fcoe_fip_send;
fc->ctlr.update_mac = fcoe_update_src_mac;
- fc->fip_packet_type.func = fcoe_fip_recv;
- fc->fip_packet_type.type = htons(ETH_P_FIP);
- fc->fip_packet_type.dev = fc->real_dev;
- dev_add_pack(&fc->fip_packet_type);
+ /* configure lport network properties */
+ rc = fcoe_netdev_config(lp, netdev);
+ if (rc) {
+ FC_DBG("Could not configure netdev for the interface\n");
+ goto out_netdev_cleanup;
+ }
/* configure lport scsi host properties */
rc = fcoe_shost_config(lp, shost, &netdev->dev);
if (rc) {
FC_DBG("Could not configure shost for lport\n");
- goto out_host_put;
+ goto out_netdev_cleanup;
}
/* lport exch manager allocation */
rc = fcoe_em_config(lp);
if (rc) {
FC_DBG("Could not configure em for lport\n");
- goto out_host_put;
+ goto out_netdev_cleanup;
}
/* Initialize the library */
@@ -587,6 +621,8 @@ static int fcoe_if_create(struct net_device *netdev)
out_lp_destroy:
fc_exch_mgr_free(lp->emp); /* Free the EM */
+out_netdev_cleanup:
+ fcoe_netdev_cleanup(fc);
out_host_put:
scsi_host_put(lp->host);
return rc;
@@ -1350,13 +1386,13 @@ out:
/**
* fcoe_dev_setup() - setup link change notification interface
*/
-static void fcoe_dev_setup()
+static void fcoe_dev_setup(void)
{
register_netdevice_notifier(&fcoe_notifier);
}
/**
- * fcoe_dev_setup() - cleanup link change notification interface
+ * fcoe_dev_cleanup() - cleanup link change notification interface
*/
static void fcoe_dev_cleanup(void)
{
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 62ba0f39c6bd..b9aa280100b0 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -198,6 +198,8 @@ static void fcoe_ctlr_solicit(struct fcoe_ctlr *fip, struct fcoe_fcf *fcf)
sol->fip.fip_subcode = FIP_SC_SOL;
sol->fip.fip_dl_len = htons(sizeof(sol->desc) / FIP_BPW);
sol->fip.fip_flags = htons(FIP_FL_FPMA);
+ if (fip->spma)
+ sol->fip.fip_flags |= htons(FIP_FL_SPMA);
sol->desc.mac.fd_desc.fip_dtype = FIP_DT_MAC;
sol->desc.mac.fd_desc.fip_dlen = sizeof(sol->desc.mac) / FIP_BPW;
@@ -350,6 +352,8 @@ static void fcoe_ctlr_send_keep_alive(struct fcoe_ctlr *fip, int ports, u8 *sa)
kal->fip.fip_dl_len = htons((sizeof(kal->mac) +
ports * sizeof(*vn)) / FIP_BPW);
kal->fip.fip_flags = htons(FIP_FL_FPMA);
+ if (fip->spma)
+ kal->fip.fip_flags |= htons(FIP_FL_SPMA);
kal->mac.fd_desc.fip_dtype = FIP_DT_MAC;
kal->mac.fd_desc.fip_dlen = sizeof(kal->mac) / FIP_BPW;
@@ -413,6 +417,8 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip,
cap->fip.fip_subcode = FIP_SC_REQ;
cap->fip.fip_dl_len = htons((dlen + sizeof(*mac)) / FIP_BPW);
cap->fip.fip_flags = htons(FIP_FL_FPMA);
+ if (fip->spma)
+ cap->fip.fip_flags |= htons(FIP_FL_SPMA);
cap->encaps.fd_desc.fip_dtype = dtype;
cap->encaps.fd_desc.fip_dlen = dlen / FIP_BPW;
@@ -421,8 +427,10 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip,
memset(mac, 0, sizeof(mac));
mac->fd_desc.fip_dtype = FIP_DT_MAC;
mac->fd_desc.fip_dlen = sizeof(*mac) / FIP_BPW;
- if (dtype != ELS_FLOGI)
+ if (dtype != FIP_DT_FLOGI)
memcpy(mac->fd_mac, fip->data_src_addr, ETH_ALEN);
+ else if (fip->spma)
+ memcpy(mac->fd_mac, fip->ctl_src_addr, ETH_ALEN);
skb->protocol = htons(ETH_P_802_3);
skb_reset_mac_header(skb);
diff --git a/drivers/scsi/fnic/Makefile b/drivers/scsi/fnic/Makefile
new file mode 100644
index 000000000000..37c3440bc17c
--- /dev/null
+++ b/drivers/scsi/fnic/Makefile
@@ -0,0 +1,15 @@
+obj-$(CONFIG_FCOE_FNIC) += fnic.o
+
+fnic-y := \
+ fnic_attrs.o \
+ fnic_isr.o \
+ fnic_main.o \
+ fnic_res.o \
+ fnic_fcs.o \
+ fnic_scsi.o \
+ vnic_cq.o \
+ vnic_dev.o \
+ vnic_intr.o \
+ vnic_rq.o \
+ vnic_wq_copy.o \
+ vnic_wq.o
diff --git a/drivers/scsi/fnic/cq_desc.h b/drivers/scsi/fnic/cq_desc.h
new file mode 100644
index 000000000000..d1225cf6320e
--- /dev/null
+++ b/drivers/scsi/fnic/cq_desc.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _CQ_DESC_H_
+#define _CQ_DESC_H_
+
+/*
+ * Completion queue descriptor types
+ */
+enum cq_desc_types {
+ CQ_DESC_TYPE_WQ_ENET = 0,
+ CQ_DESC_TYPE_DESC_COPY = 1,
+ CQ_DESC_TYPE_WQ_EXCH = 2,
+ CQ_DESC_TYPE_RQ_ENET = 3,
+ CQ_DESC_TYPE_RQ_FCP = 4,
+};
+
+/* Completion queue descriptor: 16B
+ *
+ * All completion queues have this basic layout. The
+ * type_specfic area is unique for each completion
+ * queue type.
+ */
+struct cq_desc {
+ __le16 completed_index;
+ __le16 q_number;
+ u8 type_specfic[11];
+ u8 type_color;
+};
+
+#define CQ_DESC_TYPE_BITS 4
+#define CQ_DESC_TYPE_MASK ((1 << CQ_DESC_TYPE_BITS) - 1)
+#define CQ_DESC_COLOR_MASK 1
+#define CQ_DESC_COLOR_SHIFT 7
+#define CQ_DESC_Q_NUM_BITS 10
+#define CQ_DESC_Q_NUM_MASK ((1 << CQ_DESC_Q_NUM_BITS) - 1)
+#define CQ_DESC_COMP_NDX_BITS 12
+#define CQ_DESC_COMP_NDX_MASK ((1 << CQ_DESC_COMP_NDX_BITS) - 1)
+
+static inline void cq_desc_dec(const struct cq_desc *desc_arg,
+ u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
+{
+ const struct cq_desc *desc = desc_arg;
+ const u8 type_color = desc->type_color;
+
+ *color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
+
+ /*
+ * Make sure color bit is read from desc *before* other fields
+ * are read from desc. Hardware guarantees color bit is last
+ * bit (byte) written. Adding the rmb() prevents the compiler
+ * and/or CPU from reordering the reads which would potentially
+ * result in reading stale values.
+ */
+
+ rmb();
+
+ *type = type_color & CQ_DESC_TYPE_MASK;
+ *q_number = le16_to_cpu(desc->q_number) & CQ_DESC_Q_NUM_MASK;
+ *completed_index = le16_to_cpu(desc->completed_index) &
+ CQ_DESC_COMP_NDX_MASK;
+}
+
+#endif /* _CQ_DESC_H_ */
diff --git a/drivers/scsi/fnic/cq_enet_desc.h b/drivers/scsi/fnic/cq_enet_desc.h
new file mode 100644
index 000000000000..a9fa26f82ddd
--- /dev/null
+++ b/drivers/scsi/fnic/cq_enet_desc.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _CQ_ENET_DESC_H_
+#define _CQ_ENET_DESC_H_
+
+#include "cq_desc.h"
+
+/* Ethernet completion queue descriptor: 16B */
+struct cq_enet_wq_desc {
+ __le16 completed_index;
+ __le16 q_number;
+ u8 reserved[11];
+ u8 type_color;
+};
+
+static inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc,
+ u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
+{
+ cq_desc_dec((struct cq_desc *)desc, type,
+ color, q_number, completed_index);
+}
+
+/* Completion queue descriptor: Ethernet receive queue, 16B */
+struct cq_enet_rq_desc {
+ __le16 completed_index_flags;
+ __le16 q_number_rss_type_flags;
+ __le32 rss_hash;
+ __le16 bytes_written_flags;
+ __le16 vlan;
+ __le16 checksum_fcoe;
+ u8 flags;
+ u8 type_color;
+};
+
+#define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12)
+#define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13)
+#define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14)
+#define CQ_ENET_RQ_DESC_FLAGS_SOP (0x1 << 15)
+
+#define CQ_ENET_RQ_DESC_RSS_TYPE_BITS 4
+#define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \
+ ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1)
+#define CQ_ENET_RQ_DESC_RSS_TYPE_NONE 0
+#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4 1
+#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4 2
+#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6 3
+#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6 4
+#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX 5
+#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX 6
+
+#define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC (0x1 << 14)
+
+#define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS 14
+#define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \
+ ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1)
+#define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED (0x1 << 14)
+#define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED (0x1 << 15)
+
+#define CQ_ENET_RQ_DESC_FCOE_SOF_BITS 4
+#define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \
+ ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1)
+#define CQ_ENET_RQ_DESC_FCOE_EOF_BITS 8
+#define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \
+ ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1)
+#define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT 8
+
+#define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK (0x1 << 0)
+#define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK (0x1 << 0)
+#define CQ_ENET_RQ_DESC_FLAGS_UDP (0x1 << 1)
+#define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR (0x1 << 1)
+#define CQ_ENET_RQ_DESC_FLAGS_TCP (0x1 << 2)
+#define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK (0x1 << 3)
+#define CQ_ENET_RQ_DESC_FLAGS_IPV6 (0x1 << 4)
+#define CQ_ENET_RQ_DESC_FLAGS_IPV4 (0x1 << 5)
+#define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6)
+#define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7)
+
+static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
+ u8 *type, u8 *color, u16 *q_number, u16 *completed_index,
+ u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type,
+ u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error,
+ u8 *vlan_stripped, u16 *vlan, u16 *checksum, u8 *fcoe_sof,
+ u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof,
+ u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok,
+ u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok)
+{
+ u16 completed_index_flags = le16_to_cpu(desc->completed_index_flags);
+ u16 q_number_rss_type_flags =
+ le16_to_cpu(desc->q_number_rss_type_flags);
+ u16 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
+
+ cq_desc_dec((struct cq_desc *)desc, type,
+ color, q_number, completed_index);
+
+ *ingress_port = (completed_index_flags &
+ CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0;
+ *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ?
+ 1 : 0;
+ *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ?
+ 1 : 0;
+ *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ?
+ 1 : 0;
+
+ *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) &
+ CQ_ENET_RQ_DESC_RSS_TYPE_MASK);
+ *csum_not_calc = (q_number_rss_type_flags &
+ CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0;
+
+ *rss_hash = le32_to_cpu(desc->rss_hash);
+
+ *bytes_written = bytes_written_flags &
+ CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
+ *packet_error = (bytes_written_flags &
+ CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0;
+ *vlan_stripped = (bytes_written_flags &
+ CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0;
+
+ *vlan = le16_to_cpu(desc->vlan);
+
+ if (*fcoe) {
+ *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) &
+ CQ_ENET_RQ_DESC_FCOE_SOF_MASK);
+ *fcoe_fc_crc_ok = (desc->flags &
+ CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
+ *fcoe_enc_error = (desc->flags &
+ CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
+ *fcoe_eof = (u8)((desc->checksum_fcoe >>
+ CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
+ CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
+ *checksum = 0;
+ } else {
+ *fcoe_sof = 0;
+ *fcoe_fc_crc_ok = 0;
+ *fcoe_enc_error = 0;
+ *fcoe_eof = 0;
+ *checksum = le16_to_cpu(desc->checksum_fcoe);
+ }
+
+ *tcp_udp_csum_ok =
+ (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0;
+ *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0;
+ *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0;
+ *ipv4_csum_ok =
+ (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0;
+ *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0;
+ *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0;
+ *ipv4_fragment =
+ (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0;
+ *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0;
+}
+
+#endif /* _CQ_ENET_DESC_H_ */
diff --git a/drivers/scsi/fnic/cq_exch_desc.h b/drivers/scsi/fnic/cq_exch_desc.h
new file mode 100644
index 000000000000..501660cfe228
--- /dev/null
+++ b/drivers/scsi/fnic/cq_exch_desc.h
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _CQ_EXCH_DESC_H_
+#define _CQ_EXCH_DESC_H_
+
+#include "cq_desc.h"
+
+/* Exchange completion queue descriptor: 16B */
+struct cq_exch_wq_desc {
+ u16 completed_index;
+ u16 q_number;
+ u16 exchange_id;
+ u8 tmpl;
+ u8 reserved0;
+ u32 reserved1;
+ u8 exch_status;
+ u8 reserved2[2];
+ u8 type_color;
+};
+
+#define CQ_EXCH_WQ_STATUS_BITS 2
+#define CQ_EXCH_WQ_STATUS_MASK ((1 << CQ_EXCH_WQ_STATUS_BITS) - 1)
+
+enum cq_exch_status_types {
+ CQ_EXCH_WQ_STATUS_TYPE_COMPLETE = 0,
+ CQ_EXCH_WQ_STATUS_TYPE_ABORT = 1,
+ CQ_EXCH_WQ_STATUS_TYPE_SGL_EOF = 2,
+ CQ_EXCH_WQ_STATUS_TYPE_TMPL_ERR = 3,
+};
+
+static inline void cq_exch_wq_desc_dec(struct cq_exch_wq_desc *desc_ptr,
+ u8 *type,
+ u8 *color,
+ u16 *q_number,
+ u16 *completed_index,
+ u8 *exch_status)
+{
+ cq_desc_dec((struct cq_desc *)desc_ptr, type,
+ color, q_number, completed_index);
+ *exch_status = desc_ptr->exch_status & CQ_EXCH_WQ_STATUS_MASK;
+}
+
+struct cq_fcp_rq_desc {
+ u16 completed_index_eop_sop_prt;
+ u16 q_number;
+ u16 exchange_id;
+ u16 tmpl;
+ u16 bytes_written;
+ u16 vlan;
+ u8 sof;
+ u8 eof;
+ u8 fcs_fer_fck;
+ u8 type_color;
+};
+
+#define CQ_FCP_RQ_DESC_FLAGS_SOP (1 << 15)
+#define CQ_FCP_RQ_DESC_FLAGS_EOP (1 << 14)
+#define CQ_FCP_RQ_DESC_FLAGS_PRT (1 << 12)
+#define CQ_FCP_RQ_DESC_TMPL_MASK 0x1f
+#define CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK 0x3fff
+#define CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT 14
+#define CQ_FCP_RQ_DESC_PACKET_ERR_MASK (1 << CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT)
+#define CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT 15
+#define CQ_FCP_RQ_DESC_VS_STRIPPED_MASK (1 << CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT)
+#define CQ_FCP_RQ_DESC_FC_CRC_OK_MASK 0x1
+#define CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT 1
+#define CQ_FCP_RQ_DESC_FCOE_ERR_MASK (1 << CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT)
+#define CQ_FCP_RQ_DESC_FCS_OK_SHIFT 7
+#define CQ_FCP_RQ_DESC_FCS_OK_MASK (1 << CQ_FCP_RQ_DESC_FCS_OK_SHIFT)
+
+static inline void cq_fcp_rq_desc_dec(struct cq_fcp_rq_desc *desc_ptr,
+ u8 *type,
+ u8 *color,
+ u16 *q_number,
+ u16 *completed_index,
+ u8 *eop,
+ u8 *sop,
+ u8 *fck,
+ u16 *exchange_id,
+ u16 *tmpl,
+ u32 *bytes_written,
+ u8 *sof,
+ u8 *eof,
+ u8 *ingress_port,
+ u8 *packet_err,
+ u8 *fcoe_err,
+ u8 *fcs_ok,
+ u8 *vlan_stripped,
+ u16 *vlan)
+{
+ cq_desc_dec((struct cq_desc *)desc_ptr, type,
+ color, q_number, completed_index);
+ *eop = (desc_ptr->completed_index_eop_sop_prt &
+ CQ_FCP_RQ_DESC_FLAGS_EOP) ? 1 : 0;
+ *sop = (desc_ptr->completed_index_eop_sop_prt &
+ CQ_FCP_RQ_DESC_FLAGS_SOP) ? 1 : 0;
+ *ingress_port =
+ (desc_ptr->completed_index_eop_sop_prt &
+ CQ_FCP_RQ_DESC_FLAGS_PRT) ? 1 : 0;
+ *exchange_id = desc_ptr->exchange_id;
+ *tmpl = desc_ptr->tmpl & CQ_FCP_RQ_DESC_TMPL_MASK;
+ *bytes_written =
+ desc_ptr->bytes_written & CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK;
+ *packet_err =
+ (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_PACKET_ERR_MASK) >>
+ CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT;
+ *vlan_stripped =
+ (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_VS_STRIPPED_MASK) >>
+ CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT;
+ *vlan = desc_ptr->vlan;
+ *sof = desc_ptr->sof;
+ *fck = desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FC_CRC_OK_MASK;
+ *fcoe_err = (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCOE_ERR_MASK) >>
+ CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT;
+ *eof = desc_ptr->eof;
+ *fcs_ok =
+ (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCS_OK_MASK) >>
+ CQ_FCP_RQ_DESC_FCS_OK_SHIFT;
+}
+
+struct cq_sgl_desc {
+ u16 exchange_id;
+ u16 q_number;
+ u32 active_burst_offset;
+ u32 tot_data_bytes;
+ u16 tmpl;
+ u8 sgl_err;
+ u8 type_color;
+};
+
+enum cq_sgl_err_types {
+ CQ_SGL_ERR_NO_ERROR = 0,
+ CQ_SGL_ERR_OVERFLOW, /* data ran beyond end of SGL */
+ CQ_SGL_ERR_SGL_LCL_ADDR_ERR, /* sgl access to local vnic addr illegal*/
+ CQ_SGL_ERR_ADDR_RSP_ERR, /* sgl address error */
+ CQ_SGL_ERR_DATA_RSP_ERR, /* sgl data rsp error */
+ CQ_SGL_ERR_CNT_ZERO_ERR, /* SGL count is 0 */
+ CQ_SGL_ERR_CNT_MAX_ERR, /* SGL count is larger than supported */
+ CQ_SGL_ERR_ORDER_ERR, /* frames recv on both ports, order err */
+ CQ_SGL_ERR_DATA_LCL_ADDR_ERR,/* sgl data buf to local vnic addr ill */
+ CQ_SGL_ERR_HOST_CQ_ERR, /* host cq entry to local vnic addr ill */
+};
+
+#define CQ_SGL_SGL_ERR_MASK 0x1f
+#define CQ_SGL_TMPL_MASK 0x1f
+
+static inline void cq_sgl_desc_dec(struct cq_sgl_desc *desc_ptr,
+ u8 *type,
+ u8 *color,
+ u16 *q_number,
+ u16 *exchange_id,
+ u32 *active_burst_offset,
+ u32 *tot_data_bytes,
+ u16 *tmpl,
+ u8 *sgl_err)
+{
+ /* Cheat a little by assuming exchange_id is the same as completed
+ index */
+ cq_desc_dec((struct cq_desc *)desc_ptr, type, color, q_number,
+ exchange_id);
+ *active_burst_offset = desc_ptr->active_burst_offset;
+ *tot_data_bytes = desc_ptr->tot_data_bytes;
+ *tmpl = desc_ptr->tmpl & CQ_SGL_TMPL_MASK;
+ *sgl_err = desc_ptr->sgl_err & CQ_SGL_SGL_ERR_MASK;
+}
+
+#endif /* _CQ_EXCH_DESC_H_ */
diff --git a/drivers/scsi/fnic/fcpio.h b/drivers/scsi/fnic/fcpio.h
new file mode 100644
index 000000000000..12d770d885c5
--- /dev/null
+++ b/drivers/scsi/fnic/fcpio.h
@@ -0,0 +1,780 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _FCPIO_H_
+#define _FCPIO_H_
+
+#include <linux/if_ether.h>
+
+/*
+ * This header file includes all of the data structures used for
+ * communication by the host driver to the fcp firmware.
+ */
+
+/*
+ * Exchange and sequence id space allocated to the host driver
+ */
+#define FCPIO_HOST_EXCH_RANGE_START 0x1000
+#define FCPIO_HOST_EXCH_RANGE_END 0x1fff
+#define FCPIO_HOST_SEQ_ID_RANGE_START 0x80
+#define FCPIO_HOST_SEQ_ID_RANGE_END 0xff
+
+/*
+ * Command entry type
+ */
+enum fcpio_type {
+ /*
+ * Initiator request types
+ */
+ FCPIO_ICMND_16 = 0x1,
+ FCPIO_ICMND_32,
+ FCPIO_ICMND_CMPL,
+ FCPIO_ITMF,
+ FCPIO_ITMF_CMPL,
+
+ /*
+ * Target request types
+ */
+ FCPIO_TCMND_16 = 0x11,
+ FCPIO_TCMND_32,
+ FCPIO_TDATA,
+ FCPIO_TXRDY,
+ FCPIO_TRSP,
+ FCPIO_TDRSP_CMPL,
+ FCPIO_TTMF,
+ FCPIO_TTMF_ACK,
+ FCPIO_TABORT,
+ FCPIO_TABORT_CMPL,
+
+ /*
+ * Misc request types
+ */
+ FCPIO_ACK = 0x20,
+ FCPIO_RESET,
+ FCPIO_RESET_CMPL,
+ FCPIO_FLOGI_REG,
+ FCPIO_FLOGI_REG_CMPL,
+ FCPIO_ECHO,
+ FCPIO_ECHO_CMPL,
+ FCPIO_LUNMAP_CHNG,
+ FCPIO_LUNMAP_REQ,
+ FCPIO_LUNMAP_REQ_CMPL,
+ FCPIO_FLOGI_FIP_REG,
+ FCPIO_FLOGI_FIP_REG_CMPL,
+};
+
+/*
+ * Header status codes from the firmware
+ */
+enum fcpio_status {
+ FCPIO_SUCCESS = 0, /* request was successful */
+
+ /*
+ * If a request to the firmware is rejected, the original request
+ * header will be returned with the status set to one of the following:
+ */
+ FCPIO_INVALID_HEADER, /* header contains invalid data */
+ FCPIO_OUT_OF_RESOURCE, /* out of resources to complete request */
+ FCPIO_INVALID_PARAM, /* some parameter in request is invalid */
+ FCPIO_REQ_NOT_SUPPORTED, /* request type is not supported */
+ FCPIO_IO_NOT_FOUND, /* requested I/O was not found */
+
+ /*
+ * Once a request is processed, the firmware will usually return
+ * a cmpl message type. In cases where errors occurred,
+ * the header status field would be filled in with one of the following:
+ */
+ FCPIO_ABORTED = 0x41, /* request was aborted */
+ FCPIO_TIMEOUT, /* request was timed out */
+ FCPIO_SGL_INVALID, /* request was aborted due to sgl error */
+ FCPIO_MSS_INVALID, /* request was aborted due to mss error */
+ FCPIO_DATA_CNT_MISMATCH, /* recv/sent more/less data than exp. */
+ FCPIO_FW_ERR, /* request was terminated due to fw error */
+ FCPIO_ITMF_REJECTED, /* itmf req was rejected by remote node */
+ FCPIO_ITMF_FAILED, /* itmf req was failed by remote node */
+ FCPIO_ITMF_INCORRECT_LUN, /* itmf req targeted incorrect LUN */
+ FCPIO_CMND_REJECTED, /* request was invalid and rejected */
+ FCPIO_NO_PATH_AVAIL, /* no paths to the lun was available */
+ FCPIO_PATH_FAILED, /* i/o sent to current path failed */
+ FCPIO_LUNMAP_CHNG_PEND, /* i/o rejected due to lunmap change */
+};
+
+/*
+ * The header command tag. All host requests will use the "tag" field
+ * to mark commands with a unique tag. When the firmware responds to
+ * a host request, it will copy the tag field into the response.
+ *
+ * The only firmware requests that will use the rx_id/ox_id fields instead
+ * of the tag field will be the target command and target task management
+ * requests. These two requests do not have corresponding host requests
+ * since they come directly from the FC initiator on the network.
+ */
+struct fcpio_tag {
+ union {
+ u32 req_id;
+ struct {
+ u16 rx_id;
+ u16 ox_id;
+ } ex_id;
+ } u;
+};
+
+static inline void
+fcpio_tag_id_enc(struct fcpio_tag *tag, u32 id)
+{
+ tag->u.req_id = id;
+}
+
+static inline void
+fcpio_tag_id_dec(struct fcpio_tag *tag, u32 *id)
+{
+ *id = tag->u.req_id;
+}
+
+static inline void
+fcpio_tag_exid_enc(struct fcpio_tag *tag, u16 ox_id, u16 rx_id)
+{
+ tag->u.ex_id.rx_id = rx_id;
+ tag->u.ex_id.ox_id = ox_id;
+}
+
+static inline void
+fcpio_tag_exid_dec(struct fcpio_tag *tag, u16 *ox_id, u16 *rx_id)
+{
+ *rx_id = tag->u.ex_id.rx_id;
+ *ox_id = tag->u.ex_id.ox_id;
+}
+
+/*
+ * The header for an fcpio request, whether from the firmware or from the
+ * host driver
+ */
+struct fcpio_header {
+ u8 type; /* enum fcpio_type */
+ u8 status; /* header status entry */
+ u16 _resvd; /* reserved */
+ struct fcpio_tag tag; /* header tag */
+};
+
+static inline void
+fcpio_header_enc(struct fcpio_header *hdr,
+ u8 type, u8 status,
+ struct fcpio_tag tag)
+{
+ hdr->type = type;
+ hdr->status = status;
+ hdr->_resvd = 0;
+ hdr->tag = tag;
+}
+
+static inline void
+fcpio_header_dec(struct fcpio_header *hdr,
+ u8 *type, u8 *status,
+ struct fcpio_tag *tag)
+{
+ *type = hdr->type;
+ *status = hdr->status;
+ *tag = hdr->tag;
+}
+
+#define CDB_16 16
+#define CDB_32 32
+#define LUN_ADDRESS 8
+
+/*
+ * fcpio_icmnd_16: host -> firmware request
+ *
+ * used for sending out an initiator SCSI 16-byte command
+ */
+struct fcpio_icmnd_16 {
+ u32 lunmap_id; /* index into lunmap table */
+ u8 special_req_flags; /* special exchange request flags */
+ u8 _resvd0[3]; /* reserved */
+ u32 sgl_cnt; /* scatter-gather list count */
+ u32 sense_len; /* sense buffer length */
+ u64 sgl_addr; /* scatter-gather list addr */
+ u64 sense_addr; /* sense buffer address */
+ u8 crn; /* SCSI Command Reference No. */
+ u8 pri_ta; /* SCSI Priority and Task attribute */
+ u8 _resvd1; /* reserved: should be 0 */
+ u8 flags; /* command flags */
+ u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */
+ u32 data_len; /* length of data expected */
+ u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
+ u8 _resvd2; /* reserved */
+ u8 d_id[3]; /* FC vNIC only: Target D_ID */
+ u16 mss; /* FC vNIC only: max burst */
+ u16 _resvd3; /* reserved */
+ u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */
+ u32 e_d_tov; /* FC vNIC only: Err Detect Timeout */
+};
+
+/*
+ * Special request flags
+ */
+#define FCPIO_ICMND_SRFLAG_RETRY 0x01 /* Enable Retry handling on exchange */
+
+/*
+ * Priority/Task Attribute settings
+ */
+#define FCPIO_ICMND_PTA_SIMPLE 0 /* simple task attribute */
+#define FCPIO_ICMND_PTA_HEADQ 1 /* head of queue task attribute */
+#define FCPIO_ICMND_PTA_ORDERED 2 /* ordered task attribute */
+#define FCPIO_ICMND_PTA_ACA 4 /* auto contingent allegiance */
+#define FCPIO_ICMND_PRI_SHIFT 3 /* priority field starts in bit 3 */
+
+/*
+ * Command flags
+ */
+#define FCPIO_ICMND_RDDATA 0x02 /* read data */
+#define FCPIO_ICMND_WRDATA 0x01 /* write data */
+
+/*
+ * fcpio_icmnd_32: host -> firmware request
+ *
+ * used for sending out an initiator SCSI 32-byte command
+ */
+struct fcpio_icmnd_32 {
+ u32 lunmap_id; /* index into lunmap table */
+ u8 special_req_flags; /* special exchange request flags */
+ u8 _resvd0[3]; /* reserved */
+ u32 sgl_cnt; /* scatter-gather list count */
+ u32 sense_len; /* sense buffer length */
+ u64 sgl_addr; /* scatter-gather list addr */
+ u64 sense_addr; /* sense buffer address */
+ u8 crn; /* SCSI Command Reference No. */
+ u8 pri_ta; /* SCSI Priority and Task attribute */
+ u8 _resvd1; /* reserved: should be 0 */
+ u8 flags; /* command flags */
+ u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */
+ u32 data_len; /* length of data expected */
+ u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
+ u8 _resvd2; /* reserved */
+ u8 d_id[3]; /* FC vNIC only: Target D_ID */
+ u16 mss; /* FC vNIC only: max burst */
+ u16 _resvd3; /* reserved */
+ u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */
+ u32 e_d_tov; /* FC vNIC only: Error Detect Timeout */
+};
+
+/*
+ * fcpio_itmf: host -> firmware request
+ *
+ * used for requesting the firmware to abort a request and/or send out
+ * a task management function
+ *
+ * The t_tag field is only needed when the request type is ABT_TASK.
+ */
+struct fcpio_itmf {
+ u32 lunmap_id; /* index into lunmap table */
+ u32 tm_req; /* SCSI Task Management request */
+ u32 t_tag; /* header tag of fcpio to be aborted */
+ u32 _resvd; /* _reserved */
+ u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
+ u8 _resvd1; /* reserved */
+ u8 d_id[3]; /* FC vNIC only: Target D_ID */
+ u32 r_a_tov; /* FC vNIC only: R_A_TOV in msec */
+ u32 e_d_tov; /* FC vNIC only: E_D_TOV in msec */
+};
+
+/*
+ * Task Management request
+ */
+enum fcpio_itmf_tm_req_type {
+ FCPIO_ITMF_ABT_TASK_TERM = 0x01, /* abort task and terminate */
+ FCPIO_ITMF_ABT_TASK, /* abort task and issue abts */
+ FCPIO_ITMF_ABT_TASK_SET, /* abort task set */
+ FCPIO_ITMF_CLR_TASK_SET, /* clear task set */
+ FCPIO_ITMF_LUN_RESET, /* logical unit reset task mgmt */
+ FCPIO_ITMF_CLR_ACA, /* Clear ACA condition */
+};
+
+/*
+ * fcpio_tdata: host -> firmware request
+ *
+ * used for requesting the firmware to send out a read data transfer for a
+ * target command
+ */
+struct fcpio_tdata {
+ u16 rx_id; /* FC rx_id of target command */
+ u16 flags; /* command flags */
+ u32 rel_offset; /* data sequence relative offset */
+ u32 sgl_cnt; /* scatter-gather list count */
+ u32 data_len; /* length of data expected to send */
+ u64 sgl_addr; /* scatter-gather list address */
+};
+
+/*
+ * Command flags
+ */
+#define FCPIO_TDATA_SCSI_RSP 0x01 /* send a scsi resp. after last frame */
+
+/*
+ * fcpio_txrdy: host -> firmware request
+ *
+ * used for requesting the firmware to send out a write data transfer for a
+ * target command
+ */
+struct fcpio_txrdy {
+ u16 rx_id; /* FC rx_id of target command */
+ u16 _resvd0; /* reserved */
+ u32 rel_offset; /* data sequence relative offset */
+ u32 sgl_cnt; /* scatter-gather list count */
+ u32 data_len; /* length of data expected to send */
+ u64 sgl_addr; /* scatter-gather list address */
+};
+
+/*
+ * fcpio_trsp: host -> firmware request
+ *
+ * used for requesting the firmware to send out a response for a target
+ * command
+ */
+struct fcpio_trsp {
+ u16 rx_id; /* FC rx_id of target command */
+ u16 _resvd0; /* reserved */
+ u32 sense_len; /* sense data buffer length */
+ u64 sense_addr; /* sense data buffer address */
+ u16 _resvd1; /* reserved */
+ u8 flags; /* response request flags */
+ u8 scsi_status; /* SCSI status */
+ u32 residual; /* SCSI data residual value of I/O */
+};
+
+/*
+ * resposnse request flags
+ */
+#define FCPIO_TRSP_RESID_UNDER 0x08 /* residual is valid and is underflow */
+#define FCPIO_TRSP_RESID_OVER 0x04 /* residual is valid and is overflow */
+
+/*
+ * fcpio_ttmf_ack: host -> firmware response
+ *
+ * used by the host to indicate to the firmware it has received and processed
+ * the target tmf request
+ */
+struct fcpio_ttmf_ack {
+ u16 rx_id; /* FC rx_id of target command */
+ u16 _resvd0; /* reserved */
+ u32 tmf_status; /* SCSI task management status */
+};
+
+/*
+ * fcpio_tabort: host -> firmware request
+ *
+ * used by the host to request the firmware to abort a target request that was
+ * received by the firmware
+ */
+struct fcpio_tabort {
+ u16 rx_id; /* rx_id of the target request */
+};
+
+/*
+ * fcpio_reset: host -> firmware request
+ *
+ * used by the host to signal a reset of the driver to the firmware
+ * and to request firmware to clean up all outstanding I/O
+ */
+struct fcpio_reset {
+ u32 _resvd;
+};
+
+enum fcpio_flogi_reg_format_type {
+ FCPIO_FLOGI_REG_DEF_DEST = 0, /* Use the oui | s_id mac format */
+ FCPIO_FLOGI_REG_GW_DEST, /* Use the fixed gateway mac */
+};
+
+/*
+ * fcpio_flogi_reg: host -> firmware request
+ *
+ * fc vnic only
+ * used by the host to notify the firmware of the lif's s_id
+ * and destination mac address format
+ */
+struct fcpio_flogi_reg {
+ u8 format;
+ u8 s_id[3]; /* FC vNIC only: Source S_ID */
+ u8 gateway_mac[ETH_ALEN]; /* Destination gateway mac */
+ u16 _resvd;
+ u32 r_a_tov; /* R_A_TOV in msec */
+ u32 e_d_tov; /* E_D_TOV in msec */
+};
+
+/*
+ * fcpio_echo: host -> firmware request
+ *
+ * sends a heartbeat echo request to the firmware
+ */
+struct fcpio_echo {
+ u32 _resvd;
+};
+
+/*
+ * fcpio_lunmap_req: host -> firmware request
+ *
+ * scsi vnic only
+ * sends a request to retrieve the lunmap table for scsi vnics
+ */
+struct fcpio_lunmap_req {
+ u64 addr; /* address of the buffer */
+ u32 len; /* len of the buffer */
+};
+
+/*
+ * fcpio_flogi_fip_reg: host -> firmware request
+ *
+ * fc vnic only
+ * used by the host to notify the firmware of the lif's s_id
+ * and destination mac address format
+ */
+struct fcpio_flogi_fip_reg {
+ u8 _resvd0;
+ u8 s_id[3]; /* FC vNIC only: Source S_ID */
+ u8 fcf_mac[ETH_ALEN]; /* FCF Target destination mac */
+ u16 _resvd1;
+ u32 r_a_tov; /* R_A_TOV in msec */
+ u32 e_d_tov; /* E_D_TOV in msec */
+ u8 ha_mac[ETH_ALEN]; /* Host adapter source mac */
+ u16 _resvd2;
+};
+
+/*
+ * Basic structure for all fcpio structures that are sent from the host to the
+ * firmware. They are 128 bytes per structure.
+ */
+#define FCPIO_HOST_REQ_LEN 128 /* expected length of host requests */
+
+struct fcpio_host_req {
+ struct fcpio_header hdr;
+
+ union {
+ /*
+ * Defines space needed for request
+ */
+ u8 buf[FCPIO_HOST_REQ_LEN - sizeof(struct fcpio_header)];
+
+ /*
+ * Initiator host requests
+ */
+ struct fcpio_icmnd_16 icmnd_16;
+ struct fcpio_icmnd_32 icmnd_32;
+ struct fcpio_itmf itmf;
+
+ /*
+ * Target host requests
+ */
+ struct fcpio_tdata tdata;
+ struct fcpio_txrdy txrdy;
+ struct fcpio_trsp trsp;
+ struct fcpio_ttmf_ack ttmf_ack;
+ struct fcpio_tabort tabort;
+
+ /*
+ * Misc requests
+ */
+ struct fcpio_reset reset;
+ struct fcpio_flogi_reg flogi_reg;
+ struct fcpio_echo echo;
+ struct fcpio_lunmap_req lunmap_req;
+ struct fcpio_flogi_fip_reg flogi_fip_reg;
+ } u;
+};
+
+/*
+ * fcpio_icmnd_cmpl: firmware -> host response
+ *
+ * used for sending the host a response to an initiator command
+ */
+struct fcpio_icmnd_cmpl {
+ u8 _resvd0[6]; /* reserved */
+ u8 flags; /* response flags */
+ u8 scsi_status; /* SCSI status */
+ u32 residual; /* SCSI data residual length */
+ u32 sense_len; /* SCSI sense length */
+};
+
+/*
+ * response flags
+ */
+#define FCPIO_ICMND_CMPL_RESID_UNDER 0x08 /* resid under and valid */
+#define FCPIO_ICMND_CMPL_RESID_OVER 0x04 /* resid over and valid */
+
+/*
+ * fcpio_itmf_cmpl: firmware -> host response
+ *
+ * used for sending the host a response for a itmf request
+ */
+struct fcpio_itmf_cmpl {
+ u32 _resvd; /* reserved */
+};
+
+/*
+ * fcpio_tcmnd_16: firmware -> host request
+ *
+ * used by the firmware to notify the host of an incoming target SCSI 16-Byte
+ * request
+ */
+struct fcpio_tcmnd_16 {
+ u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
+ u8 crn; /* SCSI Command Reference No. */
+ u8 pri_ta; /* SCSI Priority and Task attribute */
+ u8 _resvd2; /* reserved: should be 0 */
+ u8 flags; /* command flags */
+ u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */
+ u32 data_len; /* length of data expected */
+ u8 _resvd1; /* reserved */
+ u8 s_id[3]; /* FC vNIC only: Source S_ID */
+};
+
+/*
+ * Priority/Task Attribute settings
+ */
+#define FCPIO_TCMND_PTA_SIMPLE 0 /* simple task attribute */
+#define FCPIO_TCMND_PTA_HEADQ 1 /* head of queue task attribute */
+#define FCPIO_TCMND_PTA_ORDERED 2 /* ordered task attribute */
+#define FCPIO_TCMND_PTA_ACA 4 /* auto contingent allegiance */
+#define FCPIO_TCMND_PRI_SHIFT 3 /* priority field starts in bit 3 */
+
+/*
+ * Command flags
+ */
+#define FCPIO_TCMND_RDDATA 0x02 /* read data */
+#define FCPIO_TCMND_WRDATA 0x01 /* write data */
+
+/*
+ * fcpio_tcmnd_32: firmware -> host request
+ *
+ * used by the firmware to notify the host of an incoming target SCSI 32-Byte
+ * request
+ */
+struct fcpio_tcmnd_32 {
+ u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
+ u8 crn; /* SCSI Command Reference No. */
+ u8 pri_ta; /* SCSI Priority and Task attribute */
+ u8 _resvd2; /* reserved: should be 0 */
+ u8 flags; /* command flags */
+ u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */
+ u32 data_len; /* length of data expected */
+ u8 _resvd0; /* reserved */
+ u8 s_id[3]; /* FC vNIC only: Source S_ID */
+};
+
+/*
+ * fcpio_tdrsp_cmpl: firmware -> host response
+ *
+ * used by the firmware to notify the host of a response to a host target
+ * command
+ */
+struct fcpio_tdrsp_cmpl {
+ u16 rx_id; /* rx_id of the target request */
+ u16 _resvd0; /* reserved */
+};
+
+/*
+ * fcpio_ttmf: firmware -> host request
+ *
+ * used by the firmware to notify the host of an incoming task management
+ * function request
+ */
+struct fcpio_ttmf {
+ u8 _resvd0; /* reserved */
+ u8 s_id[3]; /* FC vNIC only: Source S_ID */
+ u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
+ u8 crn; /* SCSI Command Reference No. */
+ u8 _resvd2[3]; /* reserved */
+ u32 tmf_type; /* task management request type */
+};
+
+/*
+ * Task Management request
+ */
+#define FCPIO_TTMF_CLR_ACA 0x40 /* Clear ACA condition */
+#define FCPIO_TTMF_LUN_RESET 0x10 /* logical unit reset task mgmt */
+#define FCPIO_TTMF_CLR_TASK_SET 0x04 /* clear task set */
+#define FCPIO_TTMF_ABT_TASK_SET 0x02 /* abort task set */
+#define FCPIO_TTMF_ABT_TASK 0x01 /* abort task */
+
+/*
+ * fcpio_tabort_cmpl: firmware -> host response
+ *
+ * used by the firmware to respond to a host's tabort request
+ */
+struct fcpio_tabort_cmpl {
+ u16 rx_id; /* rx_id of the target request */
+ u16 _resvd0; /* reserved */
+};
+
+/*
+ * fcpio_ack: firmware -> host response
+ *
+ * used by firmware to notify the host of the last work request received
+ */
+struct fcpio_ack {
+ u16 request_out; /* last host entry received */
+ u16 _resvd;
+};
+
+/*
+ * fcpio_reset_cmpl: firmware -> host response
+ *
+ * use by firmware to respond to the host's reset request
+ */
+struct fcpio_reset_cmpl {
+ u16 vnic_id;
+};
+
+/*
+ * fcpio_flogi_reg_cmpl: firmware -> host response
+ *
+ * fc vnic only
+ * response to the fcpio_flogi_reg request
+ */
+struct fcpio_flogi_reg_cmpl {
+ u32 _resvd;
+};
+
+/*
+ * fcpio_echo_cmpl: firmware -> host response
+ *
+ * response to the fcpio_echo request
+ */
+struct fcpio_echo_cmpl {
+ u32 _resvd;
+};
+
+/*
+ * fcpio_lunmap_chng: firmware -> host notification
+ *
+ * scsi vnic only
+ * notifies the host that the lunmap tables have changed
+ */
+struct fcpio_lunmap_chng {
+ u32 _resvd;
+};
+
+/*
+ * fcpio_lunmap_req_cmpl: firmware -> host response
+ *
+ * scsi vnic only
+ * response for lunmap table request from the host
+ */
+struct fcpio_lunmap_req_cmpl {
+ u32 _resvd;
+};
+
+/*
+ * Basic structure for all fcpio structures that are sent from the firmware to
+ * the host. They are 64 bytes per structure.
+ */
+#define FCPIO_FW_REQ_LEN 64 /* expected length of fw requests */
+struct fcpio_fw_req {
+ struct fcpio_header hdr;
+
+ union {
+ /*
+ * Defines space needed for request
+ */
+ u8 buf[FCPIO_FW_REQ_LEN - sizeof(struct fcpio_header)];
+
+ /*
+ * Initiator firmware responses
+ */
+ struct fcpio_icmnd_cmpl icmnd_cmpl;
+ struct fcpio_itmf_cmpl itmf_cmpl;
+
+ /*
+ * Target firmware new requests
+ */
+ struct fcpio_tcmnd_16 tcmnd_16;
+ struct fcpio_tcmnd_32 tcmnd_32;
+
+ /*
+ * Target firmware responses
+ */
+ struct fcpio_tdrsp_cmpl tdrsp_cmpl;
+ struct fcpio_ttmf ttmf;
+ struct fcpio_tabort_cmpl tabort_cmpl;
+
+ /*
+ * Firmware response to work received
+ */
+ struct fcpio_ack ack;
+
+ /*
+ * Misc requests
+ */
+ struct fcpio_reset_cmpl reset_cmpl;
+ struct fcpio_flogi_reg_cmpl flogi_reg_cmpl;
+ struct fcpio_echo_cmpl echo_cmpl;
+ struct fcpio_lunmap_chng lunmap_chng;
+ struct fcpio_lunmap_req_cmpl lunmap_req_cmpl;
+ } u;
+};
+
+/*
+ * Access routines to encode and decode the color bit, which is the most
+ * significant bit of the MSB of the structure
+ */
+static inline void fcpio_color_enc(struct fcpio_fw_req *fw_req, u8 color)
+{
+ u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1;
+
+ if (color)
+ *c |= 0x80;
+ else
+ *c &= ~0x80;
+}
+
+static inline void fcpio_color_dec(struct fcpio_fw_req *fw_req, u8 *color)
+{
+ u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1;
+
+ *color = *c >> 7;
+
+ /*
+ * Make sure color bit is read from desc *before* other fields
+ * are read from desc. Hardware guarantees color bit is last
+ * bit (byte) written. Adding the rmb() prevents the compiler
+ * and/or CPU from reordering the reads which would potentially
+ * result in reading stale values.
+ */
+
+ rmb();
+
+}
+
+/*
+ * Lunmap table entry for scsi vnics
+ */
+#define FCPIO_LUNMAP_TABLE_SIZE 256
+#define FCPIO_FLAGS_LUNMAP_VALID 0x80
+#define FCPIO_FLAGS_BOOT 0x01
+struct fcpio_lunmap_entry {
+ u8 bus;
+ u8 target;
+ u8 lun;
+ u8 path_cnt;
+ u16 flags;
+ u16 update_cnt;
+};
+
+struct fcpio_lunmap_tbl {
+ u32 update_cnt;
+ struct fcpio_lunmap_entry lunmaps[FCPIO_LUNMAP_TABLE_SIZE];
+};
+
+#endif /* _FCPIO_H_ */
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
new file mode 100644
index 000000000000..e4c0a3d7d87b
--- /dev/null
+++ b/drivers/scsi/fnic/fnic.h
@@ -0,0 +1,265 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _FNIC_H_
+#define _FNIC_H_
+
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/workqueue.h>
+#include <scsi/libfc.h>
+#include "fnic_io.h"
+#include "fnic_res.h"
+#include "vnic_dev.h"
+#include "vnic_wq.h"
+#include "vnic_rq.h"
+#include "vnic_cq.h"
+#include "vnic_wq_copy.h"
+#include "vnic_intr.h"
+#include "vnic_stats.h"
+#include "vnic_scsi.h"
+
+#define DRV_NAME "fnic"
+#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
+#define DRV_VERSION "1.0.0.1121"
+#define PFX DRV_NAME ": "
+#define DFX DRV_NAME "%d: "
+
+#define DESC_CLEAN_LOW_WATERMARK 8
+#define FNIC_MAX_IO_REQ 2048 /* scsi_cmnd tag map entries */
+#define FNIC_IO_LOCKS 64 /* IO locks: power of 2 */
+#define FNIC_DFLT_QUEUE_DEPTH 32
+#define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */
+
+/*
+ * Tag bits used for special requests.
+ */
+#define BIT(nr) (1UL << (nr))
+#define FNIC_TAG_ABORT BIT(30) /* tag bit indicating abort */
+#define FNIC_TAG_DEV_RST BIT(29) /* indicates device reset */
+#define FNIC_TAG_MASK (BIT(24) - 1) /* mask for lookup */
+#define FNIC_NO_TAG -1
+
+/*
+ * Usage of the scsi_cmnd scratchpad.
+ * These fields are locked by the hashed io_req_lock.
+ */
+#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
+#define CMD_STATE(Cmnd) ((Cmnd)->SCp.phase)
+#define CMD_ABTS_STATUS(Cmnd) ((Cmnd)->SCp.Message)
+#define CMD_LR_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
+#define CMD_TAG(Cmnd) ((Cmnd)->SCp.sent_command)
+
+#define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */
+
+#define FNIC_LUN_RESET_TIMEOUT 10000 /* mSec */
+#define FNIC_HOST_RESET_TIMEOUT 10000 /* mSec */
+#define FNIC_RMDEVICE_TIMEOUT 1000 /* mSec */
+#define FNIC_HOST_RESET_SETTLE_TIME 30 /* Sec */
+
+#define FNIC_MAX_FCP_TARGET 256
+
+extern unsigned int fnic_log_level;
+
+#define FNIC_MAIN_LOGGING 0x01
+#define FNIC_FCS_LOGGING 0x02
+#define FNIC_SCSI_LOGGING 0x04
+#define FNIC_ISR_LOGGING 0x08
+
+#define FNIC_CHECK_LOGGING(LEVEL, CMD) \
+do { \
+ if (unlikely(fnic_log_level & LEVEL)) \
+ do { \
+ CMD; \
+ } while (0); \
+} while (0)
+
+#define FNIC_MAIN_DBG(kern_level, host, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \
+ shost_printk(kern_level, host, fmt, ##args);)
+
+#define FNIC_FCS_DBG(kern_level, host, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
+ shost_printk(kern_level, host, fmt, ##args);)
+
+#define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \
+ shost_printk(kern_level, host, fmt, ##args);)
+
+#define FNIC_ISR_DBG(kern_level, host, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \
+ shost_printk(kern_level, host, fmt, ##args);)
+
+extern const char *fnic_state_str[];
+
+enum fnic_intx_intr_index {
+ FNIC_INTX_WQ_RQ_COPYWQ,
+ FNIC_INTX_ERR,
+ FNIC_INTX_NOTIFY,
+ FNIC_INTX_INTR_MAX,
+};
+
+enum fnic_msix_intr_index {
+ FNIC_MSIX_RQ,
+ FNIC_MSIX_WQ,
+ FNIC_MSIX_WQ_COPY,
+ FNIC_MSIX_ERR_NOTIFY,
+ FNIC_MSIX_INTR_MAX,
+};
+
+struct fnic_msix_entry {
+ int requested;
+ char devname[IFNAMSIZ];
+ irqreturn_t (*isr)(int, void *);
+ void *devid;
+};
+
+enum fnic_state {
+ FNIC_IN_FC_MODE = 0,
+ FNIC_IN_FC_TRANS_ETH_MODE,
+ FNIC_IN_ETH_MODE,
+ FNIC_IN_ETH_TRANS_FC_MODE,
+};
+
+#define FNIC_WQ_COPY_MAX 1
+#define FNIC_WQ_MAX 1
+#define FNIC_RQ_MAX 1
+#define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
+
+struct mempool;
+
+/* Per-instance private data structure */
+struct fnic {
+ struct fc_lport *lport;
+ struct vnic_dev_bar bar0;
+
+ struct msix_entry msix_entry[FNIC_MSIX_INTR_MAX];
+ struct fnic_msix_entry msix[FNIC_MSIX_INTR_MAX];
+
+ struct vnic_stats *stats;
+ unsigned long stats_time; /* time of stats update */
+ struct vnic_nic_cfg *nic_cfg;
+ char name[IFNAMSIZ];
+ struct timer_list notify_timer; /* used for MSI interrupts */
+
+ unsigned int err_intr_offset;
+ unsigned int link_intr_offset;
+
+ unsigned int wq_count;
+ unsigned int cq_count;
+
+ u32 fcoui_mode:1; /* use fcoui address*/
+ u32 vlan_hw_insert:1; /* let hw insert the tag */
+ u32 in_remove:1; /* fnic device in removal */
+ u32 stop_rx_link_events:1; /* stop proc. rx frames, link events */
+
+ struct completion *remove_wait; /* device remove thread blocks */
+
+ struct fc_frame *flogi;
+ struct fc_frame *flogi_resp;
+ u16 flogi_oxid;
+ unsigned long s_id;
+ enum fnic_state state;
+ spinlock_t fnic_lock;
+
+ u16 vlan_id; /* VLAN tag including priority */
+ u8 mac_addr[ETH_ALEN];
+ u8 dest_addr[ETH_ALEN];
+ u8 data_src_addr[ETH_ALEN];
+ u64 fcp_input_bytes; /* internal statistic */
+ u64 fcp_output_bytes; /* internal statistic */
+ u32 link_down_cnt;
+ int link_status;
+
+ struct list_head list;
+ struct pci_dev *pdev;
+ struct vnic_fc_config config;
+ struct vnic_dev *vdev;
+ unsigned int raw_wq_count;
+ unsigned int wq_copy_count;
+ unsigned int rq_count;
+ int fw_ack_index[FNIC_WQ_COPY_MAX];
+ unsigned short fw_ack_recd[FNIC_WQ_COPY_MAX];
+ unsigned short wq_copy_desc_low[FNIC_WQ_COPY_MAX];
+ unsigned int intr_count;
+ u32 __iomem *legacy_pba;
+ struct fnic_host_tag *tags;
+ mempool_t *io_req_pool;
+ mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
+ spinlock_t io_req_lock[FNIC_IO_LOCKS]; /* locks for scsi cmnds */
+
+ struct work_struct link_work;
+ struct work_struct frame_work;
+ struct sk_buff_head frame_queue;
+
+ /* copy work queue cache line section */
+ ____cacheline_aligned struct vnic_wq_copy wq_copy[FNIC_WQ_COPY_MAX];
+ /* completion queue cache line section */
+ ____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
+
+ spinlock_t wq_copy_lock[FNIC_WQ_COPY_MAX];
+
+ /* work queue cache line section */
+ ____cacheline_aligned struct vnic_wq wq[FNIC_WQ_MAX];
+ spinlock_t wq_lock[FNIC_WQ_MAX];
+
+ /* receive queue cache line section */
+ ____cacheline_aligned struct vnic_rq rq[FNIC_RQ_MAX];
+
+ /* interrupt resource cache line section */
+ ____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX];
+};
+
+extern struct workqueue_struct *fnic_event_queue;
+extern struct device_attribute *fnic_attrs[];
+
+void fnic_clear_intr_mode(struct fnic *fnic);
+int fnic_set_intr_mode(struct fnic *fnic);
+void fnic_free_intr(struct fnic *fnic);
+int fnic_request_intr(struct fnic *fnic);
+
+int fnic_send(struct fc_lport *, struct fc_frame *);
+void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf);
+void fnic_handle_frame(struct work_struct *work);
+void fnic_handle_link(struct work_struct *work);
+int fnic_rq_cmpl_handler(struct fnic *fnic, int);
+int fnic_alloc_rq_frame(struct vnic_rq *rq);
+void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf);
+int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp);
+
+int fnic_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *));
+int fnic_abort_cmd(struct scsi_cmnd *);
+int fnic_device_reset(struct scsi_cmnd *);
+int fnic_host_reset(struct scsi_cmnd *);
+int fnic_reset(struct Scsi_Host *);
+void fnic_scsi_cleanup(struct fc_lport *);
+void fnic_scsi_abort_io(struct fc_lport *);
+void fnic_empty_scsi_cleanup(struct fc_lport *);
+void fnic_exch_mgr_reset(struct fc_lport *, u32, u32);
+int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int);
+int fnic_wq_cmpl_handler(struct fnic *fnic, int);
+int fnic_flogi_reg_handler(struct fnic *fnic);
+void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
+ struct fcpio_host_req *desc);
+int fnic_fw_reset_handler(struct fnic *fnic);
+void fnic_terminate_rport_io(struct fc_rport *);
+const char *fnic_state_to_str(unsigned int state);
+
+void fnic_log_q_error(struct fnic *fnic);
+void fnic_handle_link_event(struct fnic *fnic);
+
+#endif /* _FNIC_H_ */
diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c
new file mode 100644
index 000000000000..aea0c3becfd4
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_attrs.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/string.h>
+#include <linux/device.h>
+#include <scsi/scsi_host.h>
+#include "fnic.h"
+
+static ssize_t fnic_show_state(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct fc_lport *lp = shost_priv(class_to_shost(dev));
+ struct fnic *fnic = lport_priv(lp);
+
+ return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
+}
+
+static ssize_t fnic_show_drv_version(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
+}
+
+static ssize_t fnic_show_link_state(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct fc_lport *lp = shost_priv(class_to_shost(dev));
+
+ return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
+ ? "Link Up" : "Link Down");
+}
+
+static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
+static DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL);
+static DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL);
+
+struct device_attribute *fnic_attrs[] = {
+ &dev_attr_fnic_state,
+ &dev_attr_drv_version,
+ &dev_attr_link_state,
+ NULL,
+};
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
new file mode 100644
index 000000000000..07e6eedb83ce
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -0,0 +1,742 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/skbuff.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/if_ether.h>
+#include <linux/if_vlan.h>
+#include <linux/workqueue.h>
+#include <scsi/fc/fc_els.h>
+#include <scsi/fc/fc_fcoe.h>
+#include <scsi/fc_frame.h>
+#include <scsi/libfc.h>
+#include "fnic_io.h"
+#include "fnic.h"
+#include "cq_enet_desc.h"
+#include "cq_exch_desc.h"
+
+struct workqueue_struct *fnic_event_queue;
+
+void fnic_handle_link(struct work_struct *work)
+{
+ struct fnic *fnic = container_of(work, struct fnic, link_work);
+ unsigned long flags;
+ int old_link_status;
+ u32 old_link_down_cnt;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ if (fnic->stop_rx_link_events) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ old_link_down_cnt = fnic->link_down_cnt;
+ old_link_status = fnic->link_status;
+ fnic->link_status = vnic_dev_link_status(fnic->vdev);
+ fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev);
+
+ if (old_link_status == fnic->link_status) {
+ if (!fnic->link_status)
+ /* DOWN -> DOWN */
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ else {
+ if (old_link_down_cnt != fnic->link_down_cnt) {
+ /* UP -> DOWN -> UP */
+ fnic->lport->host_stats.link_failure_count++;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "link down\n");
+ fc_linkdown(fnic->lport);
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "link up\n");
+ fc_linkup(fnic->lport);
+ } else
+ /* UP -> UP */
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ }
+ } else if (fnic->link_status) {
+ /* DOWN -> UP */
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n");
+ fc_linkup(fnic->lport);
+ } else {
+ /* UP -> DOWN */
+ fnic->lport->host_stats.link_failure_count++;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link down\n");
+ fc_linkdown(fnic->lport);
+ }
+
+}
+
+/*
+ * This function passes incoming fabric frames to libFC
+ */
+void fnic_handle_frame(struct work_struct *work)
+{
+ struct fnic *fnic = container_of(work, struct fnic, frame_work);
+ struct fc_lport *lp = fnic->lport;
+ unsigned long flags;
+ struct sk_buff *skb;
+ struct fc_frame *fp;
+
+ while ((skb = skb_dequeue(&fnic->frame_queue))) {
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (fnic->stop_rx_link_events) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ dev_kfree_skb(skb);
+ return;
+ }
+ fp = (struct fc_frame *)skb;
+ /* if Flogi resp frame, register the address */
+ if (fr_flags(fp)) {
+ vnic_dev_add_addr(fnic->vdev,
+ fnic->data_src_addr);
+ fr_flags(fp) = 0;
+ }
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ fc_exch_recv(lp, lp->emp, fp);
+ }
+
+}
+
+static inline void fnic_import_rq_fc_frame(struct sk_buff *skb,
+ u32 len, u8 sof, u8 eof)
+{
+ struct fc_frame *fp = (struct fc_frame *)skb;
+
+ skb_trim(skb, len);
+ fr_eof(fp) = eof;
+ fr_sof(fp) = sof;
+}
+
+
+static inline int fnic_import_rq_eth_pkt(struct sk_buff *skb, u32 len)
+{
+ struct fc_frame *fp;
+ struct ethhdr *eh;
+ struct vlan_ethhdr *vh;
+ struct fcoe_hdr *fcoe_hdr;
+ struct fcoe_crc_eof *ft;
+ u32 transport_len = 0;
+
+ eh = (struct ethhdr *)skb->data;
+ vh = (struct vlan_ethhdr *)skb->data;
+ if (vh->h_vlan_proto == htons(ETH_P_8021Q) &&
+ vh->h_vlan_encapsulated_proto == htons(ETH_P_FCOE)) {
+ skb_pull(skb, sizeof(struct vlan_ethhdr));
+ transport_len += sizeof(struct vlan_ethhdr);
+ } else if (eh->h_proto == htons(ETH_P_FCOE)) {
+ transport_len += sizeof(struct ethhdr);
+ skb_pull(skb, sizeof(struct ethhdr));
+ } else
+ return -1;
+
+ fcoe_hdr = (struct fcoe_hdr *)skb->data;
+ if (FC_FCOE_DECAPS_VER(fcoe_hdr) != FC_FCOE_VER)
+ return -1;
+
+ fp = (struct fc_frame *)skb;
+ fc_frame_init(fp);
+ fr_sof(fp) = fcoe_hdr->fcoe_sof;
+ skb_pull(skb, sizeof(struct fcoe_hdr));
+ transport_len += sizeof(struct fcoe_hdr);
+
+ ft = (struct fcoe_crc_eof *)(skb->data + len -
+ transport_len - sizeof(*ft));
+ fr_eof(fp) = ft->fcoe_eof;
+ skb_trim(skb, len - transport_len - sizeof(*ft));
+ return 0;
+}
+
+static inline int fnic_handle_flogi_resp(struct fnic *fnic,
+ struct fc_frame *fp)
+{
+ u8 mac[ETH_ALEN] = FC_FCOE_FLOGI_MAC;
+ struct ethhdr *eth_hdr;
+ struct fc_frame_header *fh;
+ int ret = 0;
+ unsigned long flags;
+ struct fc_frame *old_flogi_resp = NULL;
+
+ fh = (struct fc_frame_header *)fr_hdr(fp);
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ if (fnic->state == FNIC_IN_ETH_MODE) {
+
+ /*
+ * Check if oxid matches on taking the lock. A new Flogi
+ * issued by libFC might have changed the fnic cached oxid
+ */
+ if (fnic->flogi_oxid != ntohs(fh->fh_ox_id)) {
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "Flogi response oxid not"
+ " matching cached oxid, dropping frame"
+ "\n");
+ ret = -1;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ dev_kfree_skb_irq(fp_skb(fp));
+ goto handle_flogi_resp_end;
+ }
+
+ /* Drop older cached flogi response frame, cache this frame */
+ old_flogi_resp = fnic->flogi_resp;
+ fnic->flogi_resp = fp;
+ fnic->flogi_oxid = FC_XID_UNKNOWN;
+
+ /*
+ * this frame is part of flogi get the src mac addr from this
+ * frame if the src mac is fcoui based then we mark the
+ * address mode flag to use fcoui base for dst mac addr
+ * otherwise we have to store the fcoe gateway addr
+ */
+ eth_hdr = (struct ethhdr *)skb_mac_header(fp_skb(fp));
+ memcpy(mac, eth_hdr->h_source, ETH_ALEN);
+
+ if (ntoh24(mac) == FC_FCOE_OUI)
+ fnic->fcoui_mode = 1;
+ else {
+ fnic->fcoui_mode = 0;
+ memcpy(fnic->dest_addr, mac, ETH_ALEN);
+ }
+
+ /*
+ * Except for Flogi frame, all outbound frames from us have the
+ * Eth Src address as FC_FCOE_OUI"our_sid". Flogi frame uses
+ * the vnic MAC address as the Eth Src address
+ */
+ fc_fcoe_set_mac(fnic->data_src_addr, fh->fh_d_id);
+
+ /* We get our s_id from the d_id of the flogi resp frame */
+ fnic->s_id = ntoh24(fh->fh_d_id);
+
+ /* Change state to reflect transition from Eth to FC mode */
+ fnic->state = FNIC_IN_ETH_TRANS_FC_MODE;
+
+ } else {
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "Unexpected fnic state %s while"
+ " processing flogi resp\n",
+ fnic_state_to_str(fnic->state));
+ ret = -1;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ dev_kfree_skb_irq(fp_skb(fp));
+ goto handle_flogi_resp_end;
+ }
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ /* Drop older cached frame */
+ if (old_flogi_resp)
+ dev_kfree_skb_irq(fp_skb(old_flogi_resp));
+
+ /*
+ * send flogi reg request to firmware, this will put the fnic in
+ * in FC mode
+ */
+ ret = fnic_flogi_reg_handler(fnic);
+
+ if (ret < 0) {
+ int free_fp = 1;
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ /*
+ * free the frame is some other thread is not
+ * pointing to it
+ */
+ if (fnic->flogi_resp != fp)
+ free_fp = 0;
+ else
+ fnic->flogi_resp = NULL;
+
+ if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE)
+ fnic->state = FNIC_IN_ETH_MODE;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ if (free_fp)
+ dev_kfree_skb_irq(fp_skb(fp));
+ }
+
+ handle_flogi_resp_end:
+ return ret;
+}
+
+/* Returns 1 for a response that matches cached flogi oxid */
+static inline int is_matching_flogi_resp_frame(struct fnic *fnic,
+ struct fc_frame *fp)
+{
+ struct fc_frame_header *fh;
+ int ret = 0;
+ u32 f_ctl;
+
+ fh = fc_frame_header_get(fp);
+ f_ctl = ntoh24(fh->fh_f_ctl);
+
+ if (fnic->flogi_oxid == ntohs(fh->fh_ox_id) &&
+ fh->fh_r_ctl == FC_RCTL_ELS_REP &&
+ (f_ctl & (FC_FC_EX_CTX | FC_FC_SEQ_CTX)) == FC_FC_EX_CTX &&
+ fh->fh_type == FC_TYPE_ELS)
+ ret = 1;
+
+ return ret;
+}
+
+static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc
+ *cq_desc, struct vnic_rq_buf *buf,
+ int skipped __attribute__((unused)),
+ void *opaque)
+{
+ struct fnic *fnic = vnic_dev_priv(rq->vdev);
+ struct sk_buff *skb;
+ struct fc_frame *fp;
+ unsigned int eth_hdrs_stripped;
+ u8 type, color, eop, sop, ingress_port, vlan_stripped;
+ u8 fcoe = 0, fcoe_sof, fcoe_eof;
+ u8 fcoe_fc_crc_ok = 1, fcoe_enc_error = 0;
+ u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok;
+ u8 ipv6, ipv4, ipv4_fragment, rss_type, csum_not_calc;
+ u8 fcs_ok = 1, packet_error = 0;
+ u16 q_number, completed_index, bytes_written = 0, vlan, checksum;
+ u32 rss_hash;
+ u16 exchange_id, tmpl;
+ u8 sof = 0;
+ u8 eof = 0;
+ u32 fcp_bytes_written = 0;
+ unsigned long flags;
+
+ pci_unmap_single(fnic->pdev, buf->dma_addr, buf->len,
+ PCI_DMA_FROMDEVICE);
+ skb = buf->os_buf;
+ buf->os_buf = NULL;
+
+ cq_desc_dec(cq_desc, &type, &color, &q_number, &completed_index);
+ if (type == CQ_DESC_TYPE_RQ_FCP) {
+ cq_fcp_rq_desc_dec((struct cq_fcp_rq_desc *)cq_desc,
+ &type, &color, &q_number, &completed_index,
+ &eop, &sop, &fcoe_fc_crc_ok, &exchange_id,
+ &tmpl, &fcp_bytes_written, &sof, &eof,
+ &ingress_port, &packet_error,
+ &fcoe_enc_error, &fcs_ok, &vlan_stripped,
+ &vlan);
+ eth_hdrs_stripped = 1;
+
+ } else if (type == CQ_DESC_TYPE_RQ_ENET) {
+ cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc,
+ &type, &color, &q_number, &completed_index,
+ &ingress_port, &fcoe, &eop, &sop,
+ &rss_type, &csum_not_calc, &rss_hash,
+ &bytes_written, &packet_error,
+ &vlan_stripped, &vlan, &checksum,
+ &fcoe_sof, &fcoe_fc_crc_ok,
+ &fcoe_enc_error, &fcoe_eof,
+ &tcp_udp_csum_ok, &udp, &tcp,
+ &ipv4_csum_ok, &ipv6, &ipv4,
+ &ipv4_fragment, &fcs_ok);
+ eth_hdrs_stripped = 0;
+
+ } else {
+ /* wrong CQ type*/
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "fnic rq_cmpl wrong cq type x%x\n", type);
+ goto drop;
+ }
+
+ if (!fcs_ok || packet_error || !fcoe_fc_crc_ok || fcoe_enc_error) {
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "fnic rq_cmpl fcoe x%x fcsok x%x"
+ " pkterr x%x fcoe_fc_crc_ok x%x, fcoe_enc_err"
+ " x%x\n",
+ fcoe, fcs_ok, packet_error,
+ fcoe_fc_crc_ok, fcoe_enc_error);
+ goto drop;
+ }
+
+ if (eth_hdrs_stripped)
+ fnic_import_rq_fc_frame(skb, fcp_bytes_written, sof, eof);
+ else if (fnic_import_rq_eth_pkt(skb, bytes_written))
+ goto drop;
+
+ fp = (struct fc_frame *)skb;
+
+ /*
+ * If frame is an ELS response that matches the cached FLOGI OX_ID,
+ * and is accept, issue flogi_reg_request copy wq request to firmware
+ * to register the S_ID and determine whether FC_OUI mode or GW mode.
+ */
+ if (is_matching_flogi_resp_frame(fnic, fp)) {
+ if (!eth_hdrs_stripped) {
+ if (fc_frame_payload_op(fp) == ELS_LS_ACC) {
+ fnic_handle_flogi_resp(fnic, fp);
+ return;
+ }
+ /*
+ * Recd. Flogi reject. No point registering
+ * with fw, but forward to libFC
+ */
+ goto forward;
+ }
+ goto drop;
+ }
+ if (!eth_hdrs_stripped)
+ goto drop;
+
+forward:
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (fnic->stop_rx_link_events) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ goto drop;
+ }
+ /* Use fr_flags to indicate whether succ. flogi resp or not */
+ fr_flags(fp) = 0;
+ fr_dev(fp) = fnic->lport;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ skb_queue_tail(&fnic->frame_queue, skb);
+ queue_work(fnic_event_queue, &fnic->frame_work);
+
+ return;
+drop:
+ dev_kfree_skb_irq(skb);
+}
+
+static int fnic_rq_cmpl_handler_cont(struct vnic_dev *vdev,
+ struct cq_desc *cq_desc, u8 type,
+ u16 q_number, u16 completed_index,
+ void *opaque)
+{
+ struct fnic *fnic = vnic_dev_priv(vdev);
+
+ vnic_rq_service(&fnic->rq[q_number], cq_desc, completed_index,
+ VNIC_RQ_RETURN_DESC, fnic_rq_cmpl_frame_recv,
+ NULL);
+ return 0;
+}
+
+int fnic_rq_cmpl_handler(struct fnic *fnic, int rq_work_to_do)
+{
+ unsigned int tot_rq_work_done = 0, cur_work_done;
+ unsigned int i;
+ int err;
+
+ for (i = 0; i < fnic->rq_count; i++) {
+ cur_work_done = vnic_cq_service(&fnic->cq[i], rq_work_to_do,
+ fnic_rq_cmpl_handler_cont,
+ NULL);
+ if (cur_work_done) {
+ err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame);
+ if (err)
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "fnic_alloc_rq_frame cant alloc"
+ " frame\n");
+ }
+ tot_rq_work_done += cur_work_done;
+ }
+
+ return tot_rq_work_done;
+}
+
+/*
+ * This function is called once at init time to allocate and fill RQ
+ * buffers. Subsequently, it is called in the interrupt context after RQ
+ * buffer processing to replenish the buffers in the RQ
+ */
+int fnic_alloc_rq_frame(struct vnic_rq *rq)
+{
+ struct fnic *fnic = vnic_dev_priv(rq->vdev);
+ struct sk_buff *skb;
+ u16 len;
+ dma_addr_t pa;
+
+ len = FC_FRAME_HEADROOM + FC_MAX_FRAME + FC_FRAME_TAILROOM;
+ skb = dev_alloc_skb(len);
+ if (!skb) {
+ FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
+ "Unable to allocate RQ sk_buff\n");
+ return -ENOMEM;
+ }
+ skb_reset_mac_header(skb);
+ skb_reset_transport_header(skb);
+ skb_reset_network_header(skb);
+ skb_put(skb, len);
+ pa = pci_map_single(fnic->pdev, skb->data, len, PCI_DMA_FROMDEVICE);
+ fnic_queue_rq_desc(rq, skb, pa, len);
+ return 0;
+}
+
+void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
+{
+ struct fc_frame *fp = buf->os_buf;
+ struct fnic *fnic = vnic_dev_priv(rq->vdev);
+
+ pci_unmap_single(fnic->pdev, buf->dma_addr, buf->len,
+ PCI_DMA_FROMDEVICE);
+
+ dev_kfree_skb(fp_skb(fp));
+ buf->os_buf = NULL;
+}
+
+static inline int is_flogi_frame(struct fc_frame_header *fh)
+{
+ return fh->fh_r_ctl == FC_RCTL_ELS_REQ && *(u8 *)(fh + 1) == ELS_FLOGI;
+}
+
+int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp)
+{
+ struct vnic_wq *wq = &fnic->wq[0];
+ struct sk_buff *skb;
+ dma_addr_t pa;
+ struct ethhdr *eth_hdr;
+ struct vlan_ethhdr *vlan_hdr;
+ struct fcoe_hdr *fcoe_hdr;
+ struct fc_frame_header *fh;
+ u32 tot_len, eth_hdr_len;
+ int ret = 0;
+ unsigned long flags;
+
+ fh = fc_frame_header_get(fp);
+ skb = fp_skb(fp);
+
+ if (!fnic->vlan_hw_insert) {
+ eth_hdr_len = sizeof(*vlan_hdr) + sizeof(*fcoe_hdr);
+ vlan_hdr = (struct vlan_ethhdr *)skb_push(skb, eth_hdr_len);
+ eth_hdr = (struct ethhdr *)vlan_hdr;
+ vlan_hdr->h_vlan_proto = htons(ETH_P_8021Q);
+ vlan_hdr->h_vlan_encapsulated_proto = htons(ETH_P_FCOE);
+ vlan_hdr->h_vlan_TCI = htons(fnic->vlan_id);
+ fcoe_hdr = (struct fcoe_hdr *)(vlan_hdr + 1);
+ } else {
+ eth_hdr_len = sizeof(*eth_hdr) + sizeof(*fcoe_hdr);
+ eth_hdr = (struct ethhdr *)skb_push(skb, eth_hdr_len);
+ eth_hdr->h_proto = htons(ETH_P_FCOE);
+ fcoe_hdr = (struct fcoe_hdr *)(eth_hdr + 1);
+ }
+
+ if (is_flogi_frame(fh)) {
+ fc_fcoe_set_mac(eth_hdr->h_dest, fh->fh_d_id);
+ memcpy(eth_hdr->h_source, fnic->mac_addr, ETH_ALEN);
+ } else {
+ if (fnic->fcoui_mode)
+ fc_fcoe_set_mac(eth_hdr->h_dest, fh->fh_d_id);
+ else
+ memcpy(eth_hdr->h_dest, fnic->dest_addr, ETH_ALEN);
+ memcpy(eth_hdr->h_source, fnic->data_src_addr, ETH_ALEN);
+ }
+
+ tot_len = skb->len;
+ BUG_ON(tot_len % 4);
+
+ memset(fcoe_hdr, 0, sizeof(*fcoe_hdr));
+ fcoe_hdr->fcoe_sof = fr_sof(fp);
+ if (FC_FCOE_VER)
+ FC_FCOE_ENCAPS_VER(fcoe_hdr, FC_FCOE_VER);
+
+ pa = pci_map_single(fnic->pdev, eth_hdr, tot_len, PCI_DMA_TODEVICE);
+
+ spin_lock_irqsave(&fnic->wq_lock[0], flags);
+
+ if (!vnic_wq_desc_avail(wq)) {
+ pci_unmap_single(fnic->pdev, pa,
+ tot_len, PCI_DMA_TODEVICE);
+ ret = -1;
+ goto fnic_send_frame_end;
+ }
+
+ fnic_queue_wq_desc(wq, skb, pa, tot_len, fr_eof(fp),
+ fnic->vlan_hw_insert, fnic->vlan_id, 1, 1, 1);
+fnic_send_frame_end:
+ spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
+
+ if (ret)
+ dev_kfree_skb_any(fp_skb(fp));
+
+ return ret;
+}
+
+/*
+ * fnic_send
+ * Routine to send a raw frame
+ */
+int fnic_send(struct fc_lport *lp, struct fc_frame *fp)
+{
+ struct fnic *fnic = lport_priv(lp);
+ struct fc_frame_header *fh;
+ int ret = 0;
+ enum fnic_state old_state;
+ unsigned long flags;
+ struct fc_frame *old_flogi = NULL;
+ struct fc_frame *old_flogi_resp = NULL;
+
+ if (fnic->in_remove) {
+ dev_kfree_skb(fp_skb(fp));
+ ret = -1;
+ goto fnic_send_end;
+ }
+
+ fh = fc_frame_header_get(fp);
+ /* if not an Flogi frame, send it out, this is the common case */
+ if (!is_flogi_frame(fh))
+ return fnic_send_frame(fnic, fp);
+
+ /* Flogi frame, now enter the state machine */
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+again:
+ /* Get any old cached frames, free them after dropping lock */
+ old_flogi = fnic->flogi;
+ fnic->flogi = NULL;
+ old_flogi_resp = fnic->flogi_resp;
+ fnic->flogi_resp = NULL;
+
+ fnic->flogi_oxid = FC_XID_UNKNOWN;
+
+ old_state = fnic->state;
+ switch (old_state) {
+ case FNIC_IN_FC_MODE:
+ case FNIC_IN_ETH_TRANS_FC_MODE:
+ default:
+ fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
+ vnic_dev_del_addr(fnic->vdev, fnic->data_src_addr);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (old_flogi) {
+ dev_kfree_skb(fp_skb(old_flogi));
+ old_flogi = NULL;
+ }
+ if (old_flogi_resp) {
+ dev_kfree_skb(fp_skb(old_flogi_resp));
+ old_flogi_resp = NULL;
+ }
+
+ ret = fnic_fw_reset_handler(fnic);
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (fnic->state != FNIC_IN_FC_TRANS_ETH_MODE)
+ goto again;
+ if (ret) {
+ fnic->state = old_state;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ dev_kfree_skb(fp_skb(fp));
+ goto fnic_send_end;
+ }
+ old_flogi = fnic->flogi;
+ fnic->flogi = fp;
+ fnic->flogi_oxid = ntohs(fh->fh_ox_id);
+ old_flogi_resp = fnic->flogi_resp;
+ fnic->flogi_resp = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ break;
+
+ case FNIC_IN_FC_TRANS_ETH_MODE:
+ /*
+ * A reset is pending with the firmware. Store the flogi
+ * and its oxid. The transition out of this state happens
+ * only when Firmware completes the reset, either with
+ * success or failed. If success, transition to
+ * FNIC_IN_ETH_MODE, if fail, then transition to
+ * FNIC_IN_FC_MODE
+ */
+ fnic->flogi = fp;
+ fnic->flogi_oxid = ntohs(fh->fh_ox_id);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ break;
+
+ case FNIC_IN_ETH_MODE:
+ /*
+ * The fw/hw is already in eth mode. Store the oxid,
+ * and send the flogi frame out. The transition out of this
+ * state happens only we receive flogi response from the
+ * network, and the oxid matches the cached oxid when the
+ * flogi frame was sent out. If they match, then we issue
+ * a flogi_reg request and transition to state
+ * FNIC_IN_ETH_TRANS_FC_MODE
+ */
+ fnic->flogi_oxid = ntohs(fh->fh_ox_id);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ ret = fnic_send_frame(fnic, fp);
+ break;
+ }
+
+fnic_send_end:
+ if (old_flogi)
+ dev_kfree_skb(fp_skb(old_flogi));
+ if (old_flogi_resp)
+ dev_kfree_skb(fp_skb(old_flogi_resp));
+ return ret;
+}
+
+static void fnic_wq_complete_frame_send(struct vnic_wq *wq,
+ struct cq_desc *cq_desc,
+ struct vnic_wq_buf *buf, void *opaque)
+{
+ struct sk_buff *skb = buf->os_buf;
+ struct fc_frame *fp = (struct fc_frame *)skb;
+ struct fnic *fnic = vnic_dev_priv(wq->vdev);
+
+ pci_unmap_single(fnic->pdev, buf->dma_addr,
+ buf->len, PCI_DMA_TODEVICE);
+ dev_kfree_skb_irq(fp_skb(fp));
+ buf->os_buf = NULL;
+}
+
+static int fnic_wq_cmpl_handler_cont(struct vnic_dev *vdev,
+ struct cq_desc *cq_desc, u8 type,
+ u16 q_number, u16 completed_index,
+ void *opaque)
+{
+ struct fnic *fnic = vnic_dev_priv(vdev);
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->wq_lock[q_number], flags);
+ vnic_wq_service(&fnic->wq[q_number], cq_desc, completed_index,
+ fnic_wq_complete_frame_send, NULL);
+ spin_unlock_irqrestore(&fnic->wq_lock[q_number], flags);
+
+ return 0;
+}
+
+int fnic_wq_cmpl_handler(struct fnic *fnic, int work_to_do)
+{
+ unsigned int wq_work_done = 0;
+ unsigned int i;
+
+ for (i = 0; i < fnic->raw_wq_count; i++) {
+ wq_work_done += vnic_cq_service(&fnic->cq[fnic->rq_count+i],
+ work_to_do,
+ fnic_wq_cmpl_handler_cont,
+ NULL);
+ }
+
+ return wq_work_done;
+}
+
+
+void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
+{
+ struct fc_frame *fp = buf->os_buf;
+ struct fnic *fnic = vnic_dev_priv(wq->vdev);
+
+ pci_unmap_single(fnic->pdev, buf->dma_addr,
+ buf->len, PCI_DMA_TODEVICE);
+
+ dev_kfree_skb(fp_skb(fp));
+ buf->os_buf = NULL;
+}
diff --git a/drivers/scsi/fnic/fnic_io.h b/drivers/scsi/fnic/fnic_io.h
new file mode 100644
index 000000000000..f0b896988cd5
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_io.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _FNIC_IO_H_
+#define _FNIC_IO_H_
+
+#include <scsi/fc/fc_fcp.h>
+
+#define FNIC_DFLT_SG_DESC_CNT 32
+#define FNIC_MAX_SG_DESC_CNT 1024 /* Maximum descriptors per sgl */
+#define FNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */
+
+struct host_sg_desc {
+ __le64 addr;
+ __le32 len;
+ u32 _resvd;
+};
+
+struct fnic_dflt_sgl_list {
+ struct host_sg_desc sg_desc[FNIC_DFLT_SG_DESC_CNT];
+};
+
+struct fnic_sgl_list {
+ struct host_sg_desc sg_desc[FNIC_MAX_SG_DESC_CNT];
+};
+
+enum fnic_sgl_list_type {
+ FNIC_SGL_CACHE_DFLT = 0, /* cache with default size sgl */
+ FNIC_SGL_CACHE_MAX, /* cache with max size sgl */
+ FNIC_SGL_NUM_CACHES /* number of sgl caches */
+};
+
+enum fnic_ioreq_state {
+ FNIC_IOREQ_CMD_PENDING = 0,
+ FNIC_IOREQ_ABTS_PENDING,
+ FNIC_IOREQ_ABTS_COMPLETE,
+ FNIC_IOREQ_CMD_COMPLETE,
+};
+
+struct fnic_io_req {
+ struct host_sg_desc *sgl_list; /* sgl list */
+ void *sgl_list_alloc; /* sgl list address used for free */
+ dma_addr_t sense_buf_pa; /* dma address for sense buffer*/
+ dma_addr_t sgl_list_pa; /* dma address for sgl list */
+ u16 sgl_cnt;
+ u8 sgl_type; /* device DMA descriptor list type */
+ u8 io_completed:1; /* set to 1 when fw completes IO */
+ u32 port_id; /* remote port DID */
+ struct completion *abts_done; /* completion for abts */
+ struct completion *dr_done; /* completion for device reset */
+};
+
+#endif /* _FNIC_IO_H_ */
diff --git a/drivers/scsi/fnic/fnic_isr.c b/drivers/scsi/fnic/fnic_isr.c
new file mode 100644
index 000000000000..2b3064828aea
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_isr.c
@@ -0,0 +1,332 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <scsi/libfc.h>
+#include <scsi/fc_frame.h>
+#include "vnic_dev.h"
+#include "vnic_intr.h"
+#include "vnic_stats.h"
+#include "fnic_io.h"
+#include "fnic.h"
+
+static irqreturn_t fnic_isr_legacy(int irq, void *data)
+{
+ struct fnic *fnic = data;
+ u32 pba;
+ unsigned long work_done = 0;
+
+ pba = vnic_intr_legacy_pba(fnic->legacy_pba);
+ if (!pba)
+ return IRQ_NONE;
+
+ if (pba & (1 << FNIC_INTX_NOTIFY)) {
+ vnic_intr_return_all_credits(&fnic->intr[FNIC_INTX_NOTIFY]);
+ fnic_handle_link_event(fnic);
+ }
+
+ if (pba & (1 << FNIC_INTX_ERR)) {
+ vnic_intr_return_all_credits(&fnic->intr[FNIC_INTX_ERR]);
+ fnic_log_q_error(fnic);
+ }
+
+ if (pba & (1 << FNIC_INTX_WQ_RQ_COPYWQ)) {
+ work_done += fnic_wq_copy_cmpl_handler(fnic, 8);
+ work_done += fnic_wq_cmpl_handler(fnic, 4);
+ work_done += fnic_rq_cmpl_handler(fnic, 4);
+
+ vnic_intr_return_credits(&fnic->intr[FNIC_INTX_WQ_RQ_COPYWQ],
+ work_done,
+ 1 /* unmask intr */,
+ 1 /* reset intr timer */);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t fnic_isr_msi(int irq, void *data)
+{
+ struct fnic *fnic = data;
+ unsigned long work_done = 0;
+
+ work_done += fnic_wq_copy_cmpl_handler(fnic, 8);
+ work_done += fnic_wq_cmpl_handler(fnic, 4);
+ work_done += fnic_rq_cmpl_handler(fnic, 4);
+
+ vnic_intr_return_credits(&fnic->intr[0],
+ work_done,
+ 1 /* unmask intr */,
+ 1 /* reset intr timer */);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t fnic_isr_msix_rq(int irq, void *data)
+{
+ struct fnic *fnic = data;
+ unsigned long rq_work_done = 0;
+
+ rq_work_done = fnic_rq_cmpl_handler(fnic, 4);
+ vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_RQ],
+ rq_work_done,
+ 1 /* unmask intr */,
+ 1 /* reset intr timer */);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t fnic_isr_msix_wq(int irq, void *data)
+{
+ struct fnic *fnic = data;
+ unsigned long wq_work_done = 0;
+
+ wq_work_done = fnic_wq_cmpl_handler(fnic, 4);
+ vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_WQ],
+ wq_work_done,
+ 1 /* unmask intr */,
+ 1 /* reset intr timer */);
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t fnic_isr_msix_wq_copy(int irq, void *data)
+{
+ struct fnic *fnic = data;
+ unsigned long wq_copy_work_done = 0;
+
+ wq_copy_work_done = fnic_wq_copy_cmpl_handler(fnic, 8);
+ vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_WQ_COPY],
+ wq_copy_work_done,
+ 1 /* unmask intr */,
+ 1 /* reset intr timer */);
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t fnic_isr_msix_err_notify(int irq, void *data)
+{
+ struct fnic *fnic = data;
+
+ vnic_intr_return_all_credits(&fnic->intr[FNIC_MSIX_ERR_NOTIFY]);
+ fnic_log_q_error(fnic);
+ fnic_handle_link_event(fnic);
+
+ return IRQ_HANDLED;
+}
+
+void fnic_free_intr(struct fnic *fnic)
+{
+ int i;
+
+ switch (vnic_dev_get_intr_mode(fnic->vdev)) {
+ case VNIC_DEV_INTR_MODE_INTX:
+ case VNIC_DEV_INTR_MODE_MSI:
+ free_irq(fnic->pdev->irq, fnic);
+ break;
+
+ case VNIC_DEV_INTR_MODE_MSIX:
+ for (i = 0; i < ARRAY_SIZE(fnic->msix); i++)
+ if (fnic->msix[i].requested)
+ free_irq(fnic->msix_entry[i].vector,
+ fnic->msix[i].devid);
+ break;
+
+ default:
+ break;
+ }
+}
+
+int fnic_request_intr(struct fnic *fnic)
+{
+ int err = 0;
+ int i;
+
+ switch (vnic_dev_get_intr_mode(fnic->vdev)) {
+
+ case VNIC_DEV_INTR_MODE_INTX:
+ err = request_irq(fnic->pdev->irq, &fnic_isr_legacy,
+ IRQF_SHARED, DRV_NAME, fnic);
+ break;
+
+ case VNIC_DEV_INTR_MODE_MSI:
+ err = request_irq(fnic->pdev->irq, &fnic_isr_msi,
+ 0, fnic->name, fnic);
+ break;
+
+ case VNIC_DEV_INTR_MODE_MSIX:
+
+ sprintf(fnic->msix[FNIC_MSIX_RQ].devname,
+ "%.11s-fcs-rq", fnic->name);
+ fnic->msix[FNIC_MSIX_RQ].isr = fnic_isr_msix_rq;
+ fnic->msix[FNIC_MSIX_RQ].devid = fnic;
+
+ sprintf(fnic->msix[FNIC_MSIX_WQ].devname,
+ "%.11s-fcs-wq", fnic->name);
+ fnic->msix[FNIC_MSIX_WQ].isr = fnic_isr_msix_wq;
+ fnic->msix[FNIC_MSIX_WQ].devid = fnic;
+
+ sprintf(fnic->msix[FNIC_MSIX_WQ_COPY].devname,
+ "%.11s-scsi-wq", fnic->name);
+ fnic->msix[FNIC_MSIX_WQ_COPY].isr = fnic_isr_msix_wq_copy;
+ fnic->msix[FNIC_MSIX_WQ_COPY].devid = fnic;
+
+ sprintf(fnic->msix[FNIC_MSIX_ERR_NOTIFY].devname,
+ "%.11s-err-notify", fnic->name);
+ fnic->msix[FNIC_MSIX_ERR_NOTIFY].isr =
+ fnic_isr_msix_err_notify;
+ fnic->msix[FNIC_MSIX_ERR_NOTIFY].devid = fnic;
+
+ for (i = 0; i < ARRAY_SIZE(fnic->msix); i++) {
+ err = request_irq(fnic->msix_entry[i].vector,
+ fnic->msix[i].isr, 0,
+ fnic->msix[i].devname,
+ fnic->msix[i].devid);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "MSIX: request_irq"
+ " failed %d\n", err);
+ fnic_free_intr(fnic);
+ break;
+ }
+ fnic->msix[i].requested = 1;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return err;
+}
+
+int fnic_set_intr_mode(struct fnic *fnic)
+{
+ unsigned int n = ARRAY_SIZE(fnic->rq);
+ unsigned int m = ARRAY_SIZE(fnic->wq);
+ unsigned int o = ARRAY_SIZE(fnic->wq_copy);
+ unsigned int i;
+
+ /*
+ * Set interrupt mode (INTx, MSI, MSI-X) depending
+ * system capabilities.
+ *
+ * Try MSI-X first
+ *
+ * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs
+ * (last INTR is used for WQ/RQ errors and notification area)
+ */
+
+ BUG_ON(ARRAY_SIZE(fnic->msix_entry) < n + m + o + 1);
+ for (i = 0; i < n + m + o + 1; i++)
+ fnic->msix_entry[i].entry = i;
+
+ if (fnic->rq_count >= n &&
+ fnic->raw_wq_count >= m &&
+ fnic->wq_copy_count >= o &&
+ fnic->cq_count >= n + m + o) {
+ if (!pci_enable_msix(fnic->pdev, fnic->msix_entry,
+ n + m + o + 1)) {
+ fnic->rq_count = n;
+ fnic->raw_wq_count = m;
+ fnic->wq_copy_count = o;
+ fnic->wq_count = m + o;
+ fnic->cq_count = n + m + o;
+ fnic->intr_count = n + m + o + 1;
+ fnic->err_intr_offset = FNIC_MSIX_ERR_NOTIFY;
+
+ FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host,
+ "Using MSI-X Interrupts\n");
+ vnic_dev_set_intr_mode(fnic->vdev,
+ VNIC_DEV_INTR_MODE_MSIX);
+ return 0;
+ }
+ }
+
+ /*
+ * Next try MSI
+ * We need 1 RQ, 1 WQ, 1 WQ_COPY, 3 CQs, and 1 INTR
+ */
+ if (fnic->rq_count >= 1 &&
+ fnic->raw_wq_count >= 1 &&
+ fnic->wq_copy_count >= 1 &&
+ fnic->cq_count >= 3 &&
+ fnic->intr_count >= 1 &&
+ !pci_enable_msi(fnic->pdev)) {
+
+ fnic->rq_count = 1;
+ fnic->raw_wq_count = 1;
+ fnic->wq_copy_count = 1;
+ fnic->wq_count = 2;
+ fnic->cq_count = 3;
+ fnic->intr_count = 1;
+ fnic->err_intr_offset = 0;
+
+ FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host,
+ "Using MSI Interrupts\n");
+ vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSI);
+
+ return 0;
+ }
+
+ /*
+ * Next try INTx
+ * We need 1 RQ, 1 WQ, 1 WQ_COPY, 3 CQs, and 3 INTRs
+ * 1 INTR is used for all 3 queues, 1 INTR for queue errors
+ * 1 INTR for notification area
+ */
+
+ if (fnic->rq_count >= 1 &&
+ fnic->raw_wq_count >= 1 &&
+ fnic->wq_copy_count >= 1 &&
+ fnic->cq_count >= 3 &&
+ fnic->intr_count >= 3) {
+
+ fnic->rq_count = 1;
+ fnic->raw_wq_count = 1;
+ fnic->wq_copy_count = 1;
+ fnic->cq_count = 3;
+ fnic->intr_count = 3;
+
+ FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host,
+ "Using Legacy Interrupts\n");
+ vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX);
+
+ return 0;
+ }
+
+ vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN);
+
+ return -EINVAL;
+}
+
+void fnic_clear_intr_mode(struct fnic *fnic)
+{
+ switch (vnic_dev_get_intr_mode(fnic->vdev)) {
+ case VNIC_DEV_INTR_MODE_MSIX:
+ pci_disable_msix(fnic->pdev);
+ break;
+ case VNIC_DEV_INTR_MODE_MSI:
+ pci_disable_msi(fnic->pdev);
+ break;
+ default:
+ break;
+ }
+
+ vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX);
+}
+
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
new file mode 100644
index 000000000000..a84072865fc2
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -0,0 +1,943 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/module.h>
+#include <linux/mempool.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/skbuff.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_fc.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/libfc.h>
+#include <scsi/fc_frame.h>
+
+#include "vnic_dev.h"
+#include "vnic_intr.h"
+#include "vnic_stats.h"
+#include "fnic_io.h"
+#include "fnic.h"
+
+#define PCI_DEVICE_ID_CISCO_FNIC 0x0045
+
+/* Timer to poll notification area for events. Used for MSI interrupts */
+#define FNIC_NOTIFY_TIMER_PERIOD (2 * HZ)
+
+static struct kmem_cache *fnic_sgl_cache[FNIC_SGL_NUM_CACHES];
+static struct kmem_cache *fnic_io_req_cache;
+LIST_HEAD(fnic_list);
+DEFINE_SPINLOCK(fnic_list_lock);
+
+/* Supported devices by fnic module */
+static struct pci_device_id fnic_id_table[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_FNIC) },
+ { 0, }
+};
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_AUTHOR("Abhijeet Joglekar <abjoglek@cisco.com>, "
+ "Joseph R. Eykholt <jeykholt@cisco.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(DRV_VERSION);
+MODULE_DEVICE_TABLE(pci, fnic_id_table);
+
+unsigned int fnic_log_level;
+module_param(fnic_log_level, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(fnic_log_level, "bit mask of fnic logging levels");
+
+
+static struct libfc_function_template fnic_transport_template = {
+ .frame_send = fnic_send,
+ .fcp_abort_io = fnic_empty_scsi_cleanup,
+ .fcp_cleanup = fnic_empty_scsi_cleanup,
+ .exch_mgr_reset = fnic_exch_mgr_reset
+};
+
+static int fnic_slave_alloc(struct scsi_device *sdev)
+{
+ struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+ struct fc_lport *lp = shost_priv(sdev->host);
+ struct fnic *fnic = lport_priv(lp);
+
+ sdev->tagged_supported = 1;
+
+ if (!rport || fc_remote_port_chkready(rport))
+ return -ENXIO;
+
+ scsi_activate_tcq(sdev, FNIC_DFLT_QUEUE_DEPTH);
+ rport->dev_loss_tmo = fnic->config.port_down_timeout / 1000;
+
+ return 0;
+}
+
+static struct scsi_host_template fnic_host_template = {
+ .module = THIS_MODULE,
+ .name = DRV_NAME,
+ .queuecommand = fnic_queuecommand,
+ .eh_abort_handler = fnic_abort_cmd,
+ .eh_device_reset_handler = fnic_device_reset,
+ .eh_host_reset_handler = fnic_host_reset,
+ .slave_alloc = fnic_slave_alloc,
+ .change_queue_depth = fc_change_queue_depth,
+ .change_queue_type = fc_change_queue_type,
+ .this_id = -1,
+ .cmd_per_lun = 3,
+ .can_queue = FNIC_MAX_IO_REQ,
+ .use_clustering = ENABLE_CLUSTERING,
+ .sg_tablesize = FNIC_MAX_SG_DESC_CNT,
+ .max_sectors = 0xffff,
+ .shost_attrs = fnic_attrs,
+};
+
+static void fnic_get_host_speed(struct Scsi_Host *shost);
+static struct scsi_transport_template *fnic_fc_transport;
+static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *);
+
+static struct fc_function_template fnic_fc_functions = {
+
+ .show_host_node_name = 1,
+ .show_host_port_name = 1,
+ .show_host_supported_classes = 1,
+ .show_host_supported_fc4s = 1,
+ .show_host_active_fc4s = 1,
+ .show_host_maxframe_size = 1,
+ .show_host_port_id = 1,
+ .show_host_supported_speeds = 1,
+ .get_host_speed = fnic_get_host_speed,
+ .show_host_speed = 1,
+ .show_host_port_type = 1,
+ .get_host_port_state = fc_get_host_port_state,
+ .show_host_port_state = 1,
+ .show_host_symbolic_name = 1,
+ .show_rport_maxframe_size = 1,
+ .show_rport_supported_classes = 1,
+ .show_host_fabric_name = 1,
+ .show_starget_node_name = 1,
+ .show_starget_port_name = 1,
+ .show_starget_port_id = 1,
+ .show_rport_dev_loss_tmo = 1,
+ .issue_fc_host_lip = fnic_reset,
+ .get_fc_host_stats = fnic_get_stats,
+ .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
+ .terminate_rport_io = fnic_terminate_rport_io,
+};
+
+static void fnic_get_host_speed(struct Scsi_Host *shost)
+{
+ struct fc_lport *lp = shost_priv(shost);
+ struct fnic *fnic = lport_priv(lp);
+ u32 port_speed = vnic_dev_port_speed(fnic->vdev);
+
+ /* Add in other values as they get defined in fw */
+ switch (port_speed) {
+ case 10000:
+ fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
+ break;
+ default:
+ fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
+ break;
+ }
+}
+
+static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host)
+{
+ int ret;
+ struct fc_lport *lp = shost_priv(host);
+ struct fnic *fnic = lport_priv(lp);
+ struct fc_host_statistics *stats = &lp->host_stats;
+ struct vnic_stats *vs;
+ unsigned long flags;
+
+ if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT))
+ return stats;
+ fnic->stats_time = jiffies;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (ret) {
+ FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host,
+ "fnic: Get vnic stats failed"
+ " 0x%x", ret);
+ return stats;
+ }
+ vs = fnic->stats;
+ stats->tx_frames = vs->tx.tx_unicast_frames_ok;
+ stats->tx_words = vs->tx.tx_unicast_bytes_ok / 4;
+ stats->rx_frames = vs->rx.rx_unicast_frames_ok;
+ stats->rx_words = vs->rx.rx_unicast_bytes_ok / 4;
+ stats->error_frames = vs->tx.tx_errors + vs->rx.rx_errors;
+ stats->dumped_frames = vs->tx.tx_drops + vs->rx.rx_drop;
+ stats->invalid_crc_count = vs->rx.rx_crc_errors;
+ stats->seconds_since_last_reset = (jiffies - lp->boot_time) / HZ;
+ stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000);
+ stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000);
+
+ return stats;
+}
+
+void fnic_log_q_error(struct fnic *fnic)
+{
+ unsigned int i;
+ u32 error_status;
+
+ for (i = 0; i < fnic->raw_wq_count; i++) {
+ error_status = ioread32(&fnic->wq[i].ctrl->error_status);
+ if (error_status)
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "WQ[%d] error_status"
+ " %d\n", i, error_status);
+ }
+
+ for (i = 0; i < fnic->rq_count; i++) {
+ error_status = ioread32(&fnic->rq[i].ctrl->error_status);
+ if (error_status)
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "RQ[%d] error_status"
+ " %d\n", i, error_status);
+ }
+
+ for (i = 0; i < fnic->wq_copy_count; i++) {
+ error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status);
+ if (error_status)
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "CWQ[%d] error_status"
+ " %d\n", i, error_status);
+ }
+}
+
+void fnic_handle_link_event(struct fnic *fnic)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (fnic->stop_rx_link_events) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ queue_work(fnic_event_queue, &fnic->link_work);
+
+}
+
+static int fnic_notify_set(struct fnic *fnic)
+{
+ int err;
+
+ switch (vnic_dev_get_intr_mode(fnic->vdev)) {
+ case VNIC_DEV_INTR_MODE_INTX:
+ err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY);
+ break;
+ case VNIC_DEV_INTR_MODE_MSI:
+ err = vnic_dev_notify_set(fnic->vdev, -1);
+ break;
+ case VNIC_DEV_INTR_MODE_MSIX:
+ err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY);
+ break;
+ default:
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Interrupt mode should be set up"
+ " before devcmd notify set %d\n",
+ vnic_dev_get_intr_mode(fnic->vdev));
+ err = -1;
+ break;
+ }
+
+ return err;
+}
+
+static void fnic_notify_timer(unsigned long data)
+{
+ struct fnic *fnic = (struct fnic *)data;
+
+ fnic_handle_link_event(fnic);
+ mod_timer(&fnic->notify_timer,
+ round_jiffies(jiffies + FNIC_NOTIFY_TIMER_PERIOD));
+}
+
+static void fnic_notify_timer_start(struct fnic *fnic)
+{
+ switch (vnic_dev_get_intr_mode(fnic->vdev)) {
+ case VNIC_DEV_INTR_MODE_MSI:
+ /*
+ * Schedule first timeout immediately. The driver is
+ * initiatialized and ready to look for link up notification
+ */
+ mod_timer(&fnic->notify_timer, jiffies);
+ break;
+ default:
+ /* Using intr for notification for INTx/MSI-X */
+ break;
+ };
+}
+
+static int fnic_dev_wait(struct vnic_dev *vdev,
+ int (*start)(struct vnic_dev *, int),
+ int (*finished)(struct vnic_dev *, int *),
+ int arg)
+{
+ unsigned long time;
+ int done;
+ int err;
+
+ err = start(vdev, arg);
+ if (err)
+ return err;
+
+ /* Wait for func to complete...2 seconds max */
+ time = jiffies + (HZ * 2);
+ do {
+ err = finished(vdev, &done);
+ if (err)
+ return err;
+ if (done)
+ return 0;
+ schedule_timeout_uninterruptible(HZ / 10);
+ } while (time_after(time, jiffies));
+
+ return -ETIMEDOUT;
+}
+
+static int fnic_cleanup(struct fnic *fnic)
+{
+ unsigned int i;
+ int err;
+ unsigned long flags;
+ struct fc_frame *flogi = NULL;
+ struct fc_frame *flogi_resp = NULL;
+
+ vnic_dev_disable(fnic->vdev);
+ for (i = 0; i < fnic->intr_count; i++)
+ vnic_intr_mask(&fnic->intr[i]);
+
+ for (i = 0; i < fnic->rq_count; i++) {
+ err = vnic_rq_disable(&fnic->rq[i]);
+ if (err)
+ return err;
+ }
+ for (i = 0; i < fnic->raw_wq_count; i++) {
+ err = vnic_wq_disable(&fnic->wq[i]);
+ if (err)
+ return err;
+ }
+ for (i = 0; i < fnic->wq_copy_count; i++) {
+ err = vnic_wq_copy_disable(&fnic->wq_copy[i]);
+ if (err)
+ return err;
+ }
+
+ /* Clean up completed IOs and FCS frames */
+ fnic_wq_copy_cmpl_handler(fnic, -1);
+ fnic_wq_cmpl_handler(fnic, -1);
+ fnic_rq_cmpl_handler(fnic, -1);
+
+ /* Clean up the IOs and FCS frames that have not completed */
+ for (i = 0; i < fnic->raw_wq_count; i++)
+ vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf);
+ for (i = 0; i < fnic->rq_count; i++)
+ vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
+ for (i = 0; i < fnic->wq_copy_count; i++)
+ vnic_wq_copy_clean(&fnic->wq_copy[i],
+ fnic_wq_copy_cleanup_handler);
+
+ for (i = 0; i < fnic->cq_count; i++)
+ vnic_cq_clean(&fnic->cq[i]);
+ for (i = 0; i < fnic->intr_count; i++)
+ vnic_intr_clean(&fnic->intr[i]);
+
+ /*
+ * Remove cached flogi and flogi resp frames if any
+ * These frames are not in any queue, and therefore queue
+ * cleanup does not clean them. So clean them explicitly
+ */
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ flogi = fnic->flogi;
+ fnic->flogi = NULL;
+ flogi_resp = fnic->flogi_resp;
+ fnic->flogi_resp = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (flogi)
+ dev_kfree_skb(fp_skb(flogi));
+
+ if (flogi_resp)
+ dev_kfree_skb(fp_skb(flogi_resp));
+
+ mempool_destroy(fnic->io_req_pool);
+ for (i = 0; i < FNIC_SGL_NUM_CACHES; i++)
+ mempool_destroy(fnic->io_sgl_pool[i]);
+
+ return 0;
+}
+
+static void fnic_iounmap(struct fnic *fnic)
+{
+ if (fnic->bar0.vaddr)
+ iounmap(fnic->bar0.vaddr);
+}
+
+/*
+ * Allocate element for mempools requiring GFP_DMA flag.
+ * Otherwise, checks in kmem_flagcheck() hit BUG_ON().
+ */
+static void *fnic_alloc_slab_dma(gfp_t gfp_mask, void *pool_data)
+{
+ struct kmem_cache *mem = pool_data;
+
+ return kmem_cache_alloc(mem, gfp_mask | GFP_ATOMIC | GFP_DMA);
+}
+
+static int __devinit fnic_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ struct Scsi_Host *host;
+ struct fc_lport *lp;
+ struct fnic *fnic;
+ mempool_t *pool;
+ int err;
+ int i;
+ unsigned long flags;
+
+ /*
+ * Allocate SCSI Host and set up association between host,
+ * local port, and fnic
+ */
+ host = scsi_host_alloc(&fnic_host_template,
+ sizeof(struct fc_lport) + sizeof(struct fnic));
+ if (!host) {
+ printk(KERN_ERR PFX "Unable to alloc SCSI host\n");
+ err = -ENOMEM;
+ goto err_out;
+ }
+ lp = shost_priv(host);
+ lp->host = host;
+ fnic = lport_priv(lp);
+ fnic->lport = lp;
+
+ snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME,
+ host->host_no);
+
+ host->transportt = fnic_fc_transport;
+
+ err = scsi_init_shared_tag_map(host, FNIC_MAX_IO_REQ);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Unable to alloc shared tag map\n");
+ goto err_out_free_hba;
+ }
+
+ /* Setup PCI resources */
+ pci_set_drvdata(pdev, fnic);
+
+ fnic->pdev = pdev;
+
+ err = pci_enable_device(pdev);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Cannot enable PCI device, aborting.\n");
+ goto err_out_free_hba;
+ }
+
+ err = pci_request_regions(pdev, DRV_NAME);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Cannot enable PCI resources, aborting\n");
+ goto err_out_disable_device;
+ }
+
+ pci_set_master(pdev);
+
+ /* Query PCI controller on system for DMA addressing
+ * limitation for the device. Try 40-bit first, and
+ * fail to 32-bit.
+ */
+ err = pci_set_dma_mask(pdev, DMA_40BIT_MASK);
+ if (err) {
+ err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "No usable DMA configuration "
+ "aborting\n");
+ goto err_out_release_regions;
+ }
+ err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Unable to obtain 32-bit DMA "
+ "for consistent allocations, aborting.\n");
+ goto err_out_release_regions;
+ }
+ } else {
+ err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Unable to obtain 40-bit DMA "
+ "for consistent allocations, aborting.\n");
+ goto err_out_release_regions;
+ }
+ }
+
+ /* Map vNIC resources from BAR0 */
+ if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "BAR0 not memory-map'able, aborting.\n");
+ err = -ENODEV;
+ goto err_out_release_regions;
+ }
+
+ fnic->bar0.vaddr = pci_iomap(pdev, 0, 0);
+ fnic->bar0.bus_addr = pci_resource_start(pdev, 0);
+ fnic->bar0.len = pci_resource_len(pdev, 0);
+
+ if (!fnic->bar0.vaddr) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Cannot memory-map BAR0 res hdr, "
+ "aborting.\n");
+ err = -ENODEV;
+ goto err_out_release_regions;
+ }
+
+ fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0);
+ if (!fnic->vdev) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "vNIC registration failed, "
+ "aborting.\n");
+ err = -ENODEV;
+ goto err_out_iounmap;
+ }
+
+ err = fnic_dev_wait(fnic->vdev, vnic_dev_open,
+ vnic_dev_open_done, 0);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "vNIC dev open failed, aborting.\n");
+ goto err_out_vnic_unregister;
+ }
+
+ err = vnic_dev_init(fnic->vdev, 0);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "vNIC dev init failed, aborting.\n");
+ goto err_out_dev_close;
+ }
+
+ err = vnic_dev_mac_addr(fnic->vdev, fnic->mac_addr);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "vNIC get MAC addr failed \n");
+ goto err_out_dev_close;
+ }
+
+ /* Get vNIC configuration */
+ err = fnic_get_vnic_config(fnic);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Get vNIC configuration failed, "
+ "aborting.\n");
+ goto err_out_dev_close;
+ }
+ host->max_lun = fnic->config.luns_per_tgt;
+ host->max_id = FNIC_MAX_FCP_TARGET;
+
+ fnic_get_res_counts(fnic);
+
+ err = fnic_set_intr_mode(fnic);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Failed to set intr mode, "
+ "aborting.\n");
+ goto err_out_dev_close;
+ }
+
+ err = fnic_request_intr(fnic);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Unable to request irq.\n");
+ goto err_out_clear_intr;
+ }
+
+ err = fnic_alloc_vnic_resources(fnic);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Failed to alloc vNIC resources, "
+ "aborting.\n");
+ goto err_out_free_intr;
+ }
+
+
+ /* initialize all fnic locks */
+ spin_lock_init(&fnic->fnic_lock);
+
+ for (i = 0; i < FNIC_WQ_MAX; i++)
+ spin_lock_init(&fnic->wq_lock[i]);
+
+ for (i = 0; i < FNIC_WQ_COPY_MAX; i++) {
+ spin_lock_init(&fnic->wq_copy_lock[i]);
+ fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK;
+ fnic->fw_ack_recd[i] = 0;
+ fnic->fw_ack_index[i] = -1;
+ }
+
+ for (i = 0; i < FNIC_IO_LOCKS; i++)
+ spin_lock_init(&fnic->io_req_lock[i]);
+
+ fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
+ if (!fnic->io_req_pool)
+ goto err_out_free_resources;
+
+ pool = mempool_create(2, fnic_alloc_slab_dma, mempool_free_slab,
+ fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
+ if (!pool)
+ goto err_out_free_ioreq_pool;
+ fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool;
+
+ pool = mempool_create(2, fnic_alloc_slab_dma, mempool_free_slab,
+ fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
+ if (!pool)
+ goto err_out_free_dflt_pool;
+ fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool;
+
+ /* setup vlan config, hw inserts vlan header */
+ fnic->vlan_hw_insert = 1;
+ fnic->vlan_id = 0;
+
+ fnic->flogi_oxid = FC_XID_UNKNOWN;
+ fnic->flogi = NULL;
+ fnic->flogi_resp = NULL;
+ fnic->state = FNIC_IN_FC_MODE;
+
+ /* Enable hardware stripping of vlan header on ingress */
+ fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1);
+
+ /* Setup notification buffer area */
+ err = fnic_notify_set(fnic);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Failed to alloc notify buffer, aborting.\n");
+ goto err_out_free_max_pool;
+ }
+
+ /* Setup notify timer when using MSI interrupts */
+ if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
+ setup_timer(&fnic->notify_timer,
+ fnic_notify_timer, (unsigned long)fnic);
+
+ /* allocate RQ buffers and post them to RQ*/
+ for (i = 0; i < fnic->rq_count; i++) {
+ err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "fnic_alloc_rq_frame can't alloc "
+ "frame\n");
+ goto err_out_free_rq_buf;
+ }
+ }
+
+ /*
+ * Initialization done with PCI system, hardware, firmware.
+ * Add host to SCSI
+ */
+ err = scsi_add_host(lp->host, &pdev->dev);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "fnic: scsi_add_host failed...exiting\n");
+ goto err_out_free_rq_buf;
+ }
+
+ /* Start local port initiatialization */
+
+ lp->link_up = 0;
+ lp->tt = fnic_transport_template;
+
+ lp->emp = fc_exch_mgr_alloc(lp, FC_CLASS_3,
+ FCPIO_HOST_EXCH_RANGE_START,
+ FCPIO_HOST_EXCH_RANGE_END);
+ if (!lp->emp) {
+ err = -ENOMEM;
+ goto err_out_remove_scsi_host;
+ }
+
+ lp->max_retry_count = fnic->config.flogi_retries;
+ lp->max_rport_retry_count = fnic->config.plogi_retries;
+ lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS |
+ FCP_SPPF_CONF_COMPL);
+ if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR)
+ lp->service_params |= FCP_SPPF_RETRY;
+
+ lp->boot_time = jiffies;
+ lp->e_d_tov = fnic->config.ed_tov;
+ lp->r_a_tov = fnic->config.ra_tov;
+ lp->link_supported_speeds = FC_PORTSPEED_10GBIT;
+ fc_set_wwnn(lp, fnic->config.node_wwn);
+ fc_set_wwpn(lp, fnic->config.port_wwn);
+
+ fc_exch_init(lp);
+ fc_lport_init(lp);
+ fc_elsct_init(lp);
+ fc_rport_init(lp);
+ fc_disc_init(lp);
+
+ fc_lport_config(lp);
+
+ if (fc_set_mfs(lp, fnic->config.maxdatafieldsize +
+ sizeof(struct fc_frame_header))) {
+ err = -EINVAL;
+ goto err_out_free_exch_mgr;
+ }
+ fc_host_maxframe_size(lp->host) = lp->mfs;
+
+ sprintf(fc_host_symbolic_name(lp->host),
+ DRV_NAME " v" DRV_VERSION " over %s", fnic->name);
+
+ spin_lock_irqsave(&fnic_list_lock, flags);
+ list_add_tail(&fnic->list, &fnic_list);
+ spin_unlock_irqrestore(&fnic_list_lock, flags);
+
+ INIT_WORK(&fnic->link_work, fnic_handle_link);
+ INIT_WORK(&fnic->frame_work, fnic_handle_frame);
+ skb_queue_head_init(&fnic->frame_queue);
+
+ /* Enable all queues */
+ for (i = 0; i < fnic->raw_wq_count; i++)
+ vnic_wq_enable(&fnic->wq[i]);
+ for (i = 0; i < fnic->rq_count; i++)
+ vnic_rq_enable(&fnic->rq[i]);
+ for (i = 0; i < fnic->wq_copy_count; i++)
+ vnic_wq_copy_enable(&fnic->wq_copy[i]);
+
+ fc_fabric_login(lp);
+
+ vnic_dev_enable(fnic->vdev);
+ for (i = 0; i < fnic->intr_count; i++)
+ vnic_intr_unmask(&fnic->intr[i]);
+
+ fnic_notify_timer_start(fnic);
+
+ return 0;
+
+err_out_free_exch_mgr:
+ fc_exch_mgr_free(lp->emp);
+err_out_remove_scsi_host:
+ fc_remove_host(fnic->lport->host);
+ scsi_remove_host(fnic->lport->host);
+err_out_free_rq_buf:
+ for (i = 0; i < fnic->rq_count; i++)
+ vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
+ vnic_dev_notify_unset(fnic->vdev);
+err_out_free_max_pool:
+ mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]);
+err_out_free_dflt_pool:
+ mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]);
+err_out_free_ioreq_pool:
+ mempool_destroy(fnic->io_req_pool);
+err_out_free_resources:
+ fnic_free_vnic_resources(fnic);
+err_out_free_intr:
+ fnic_free_intr(fnic);
+err_out_clear_intr:
+ fnic_clear_intr_mode(fnic);
+err_out_dev_close:
+ vnic_dev_close(fnic->vdev);
+err_out_vnic_unregister:
+ vnic_dev_unregister(fnic->vdev);
+err_out_iounmap:
+ fnic_iounmap(fnic);
+err_out_release_regions:
+ pci_release_regions(pdev);
+err_out_disable_device:
+ pci_disable_device(pdev);
+err_out_free_hba:
+ scsi_host_put(lp->host);
+err_out:
+ return err;
+}
+
+static void __devexit fnic_remove(struct pci_dev *pdev)
+{
+ struct fnic *fnic = pci_get_drvdata(pdev);
+ unsigned long flags;
+
+ /*
+ * Mark state so that the workqueue thread stops forwarding
+ * received frames and link events to the local port. ISR and
+ * other threads that can queue work items will also stop
+ * creating work items on the fnic workqueue
+ */
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ fnic->stop_rx_link_events = 1;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
+ del_timer_sync(&fnic->notify_timer);
+
+ /*
+ * Flush the fnic event queue. After this call, there should
+ * be no event queued for this fnic device in the workqueue
+ */
+ flush_workqueue(fnic_event_queue);
+ skb_queue_purge(&fnic->frame_queue);
+
+ /*
+ * Log off the fabric. This stops all remote ports, dns port,
+ * logs off the fabric. This flushes all rport, disc, lport work
+ * before returning
+ */
+ fc_fabric_logoff(fnic->lport);
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ fnic->in_remove = 1;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ fc_lport_destroy(fnic->lport);
+
+ /*
+ * This stops the fnic device, masks all interrupts. Completed
+ * CQ entries are drained. Posted WQ/RQ/Copy-WQ entries are
+ * cleaned up
+ */
+ fnic_cleanup(fnic);
+
+ BUG_ON(!skb_queue_empty(&fnic->frame_queue));
+
+ spin_lock_irqsave(&fnic_list_lock, flags);
+ list_del(&fnic->list);
+ spin_unlock_irqrestore(&fnic_list_lock, flags);
+
+ fc_remove_host(fnic->lport->host);
+ scsi_remove_host(fnic->lport->host);
+ fc_exch_mgr_free(fnic->lport->emp);
+ vnic_dev_notify_unset(fnic->vdev);
+ fnic_free_vnic_resources(fnic);
+ fnic_free_intr(fnic);
+ fnic_clear_intr_mode(fnic);
+ vnic_dev_close(fnic->vdev);
+ vnic_dev_unregister(fnic->vdev);
+ fnic_iounmap(fnic);
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+ scsi_host_put(fnic->lport->host);
+}
+
+static struct pci_driver fnic_driver = {
+ .name = DRV_NAME,
+ .id_table = fnic_id_table,
+ .probe = fnic_probe,
+ .remove = __devexit_p(fnic_remove),
+};
+
+static int __init fnic_init_module(void)
+{
+ size_t len;
+ int err = 0;
+
+ printk(KERN_INFO PFX "%s, ver %s\n", DRV_DESCRIPTION, DRV_VERSION);
+
+ /* Create a cache for allocation of default size sgls */
+ len = sizeof(struct fnic_dflt_sgl_list);
+ fnic_sgl_cache[FNIC_SGL_CACHE_DFLT] = kmem_cache_create
+ ("fnic_sgl_dflt", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
+ SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA,
+ NULL);
+ if (!fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]) {
+ printk(KERN_ERR PFX "failed to create fnic dflt sgl slab\n");
+ err = -ENOMEM;
+ goto err_create_fnic_sgl_slab_dflt;
+ }
+
+ /* Create a cache for allocation of max size sgls*/
+ len = sizeof(struct fnic_sgl_list);
+ fnic_sgl_cache[FNIC_SGL_CACHE_MAX] = kmem_cache_create
+ ("fnic_sgl_max", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
+ SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA,
+ NULL);
+ if (!fnic_sgl_cache[FNIC_SGL_CACHE_MAX]) {
+ printk(KERN_ERR PFX "failed to create fnic max sgl slab\n");
+ err = -ENOMEM;
+ goto err_create_fnic_sgl_slab_max;
+ }
+
+ /* Create a cache of io_req structs for use via mempool */
+ fnic_io_req_cache = kmem_cache_create("fnic_io_req",
+ sizeof(struct fnic_io_req),
+ 0, SLAB_HWCACHE_ALIGN, NULL);
+ if (!fnic_io_req_cache) {
+ printk(KERN_ERR PFX "failed to create fnic io_req slab\n");
+ err = -ENOMEM;
+ goto err_create_fnic_ioreq_slab;
+ }
+
+ fnic_event_queue = create_singlethread_workqueue("fnic_event_wq");
+ if (!fnic_event_queue) {
+ printk(KERN_ERR PFX "fnic work queue create failed\n");
+ err = -ENOMEM;
+ goto err_create_fnic_workq;
+ }
+
+ spin_lock_init(&fnic_list_lock);
+ INIT_LIST_HEAD(&fnic_list);
+
+ fnic_fc_transport = fc_attach_transport(&fnic_fc_functions);
+ if (!fnic_fc_transport) {
+ printk(KERN_ERR PFX "fc_attach_transport error\n");
+ err = -ENOMEM;
+ goto err_fc_transport;
+ }
+
+ /* register the driver with PCI system */
+ err = pci_register_driver(&fnic_driver);
+ if (err < 0) {
+ printk(KERN_ERR PFX "pci register error\n");
+ goto err_pci_register;
+ }
+ return err;
+
+err_pci_register:
+ fc_release_transport(fnic_fc_transport);
+err_fc_transport:
+ destroy_workqueue(fnic_event_queue);
+err_create_fnic_workq:
+ kmem_cache_destroy(fnic_io_req_cache);
+err_create_fnic_ioreq_slab:
+ kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
+err_create_fnic_sgl_slab_max:
+ kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
+err_create_fnic_sgl_slab_dflt:
+ return err;
+}
+
+static void __exit fnic_cleanup_module(void)
+{
+ pci_unregister_driver(&fnic_driver);
+ destroy_workqueue(fnic_event_queue);
+ kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
+ kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
+ kmem_cache_destroy(fnic_io_req_cache);
+ fc_release_transport(fnic_fc_transport);
+}
+
+module_init(fnic_init_module);
+module_exit(fnic_cleanup_module);
+
diff --git a/drivers/scsi/fnic/fnic_res.c b/drivers/scsi/fnic/fnic_res.c
new file mode 100644
index 000000000000..7ba61ec715d2
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_res.c
@@ -0,0 +1,444 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include "wq_enet_desc.h"
+#include "rq_enet_desc.h"
+#include "cq_enet_desc.h"
+#include "vnic_resource.h"
+#include "vnic_dev.h"
+#include "vnic_wq.h"
+#include "vnic_rq.h"
+#include "vnic_cq.h"
+#include "vnic_intr.h"
+#include "vnic_stats.h"
+#include "vnic_nic.h"
+#include "fnic.h"
+
+int fnic_get_vnic_config(struct fnic *fnic)
+{
+ struct vnic_fc_config *c = &fnic->config;
+ int err;
+
+#define GET_CONFIG(m) \
+ do { \
+ err = vnic_dev_spec(fnic->vdev, \
+ offsetof(struct vnic_fc_config, m), \
+ sizeof(c->m), &c->m); \
+ if (err) { \
+ shost_printk(KERN_ERR, fnic->lport->host, \
+ "Error getting %s, %d\n", #m, \
+ err); \
+ return err; \
+ } \
+ } while (0);
+
+ GET_CONFIG(node_wwn);
+ GET_CONFIG(port_wwn);
+ GET_CONFIG(wq_enet_desc_count);
+ GET_CONFIG(wq_copy_desc_count);
+ GET_CONFIG(rq_desc_count);
+ GET_CONFIG(maxdatafieldsize);
+ GET_CONFIG(ed_tov);
+ GET_CONFIG(ra_tov);
+ GET_CONFIG(intr_timer);
+ GET_CONFIG(intr_timer_type);
+ GET_CONFIG(flags);
+ GET_CONFIG(flogi_retries);
+ GET_CONFIG(flogi_timeout);
+ GET_CONFIG(plogi_retries);
+ GET_CONFIG(plogi_timeout);
+ GET_CONFIG(io_throttle_count);
+ GET_CONFIG(link_down_timeout);
+ GET_CONFIG(port_down_timeout);
+ GET_CONFIG(port_down_io_retries);
+ GET_CONFIG(luns_per_tgt);
+
+ c->wq_enet_desc_count =
+ min_t(u32, VNIC_FNIC_WQ_DESCS_MAX,
+ max_t(u32, VNIC_FNIC_WQ_DESCS_MIN,
+ c->wq_enet_desc_count));
+ c->wq_enet_desc_count = ALIGN(c->wq_enet_desc_count, 16);
+
+ c->wq_copy_desc_count =
+ min_t(u32, VNIC_FNIC_WQ_COPY_DESCS_MAX,
+ max_t(u32, VNIC_FNIC_WQ_COPY_DESCS_MIN,
+ c->wq_copy_desc_count));
+ c->wq_copy_desc_count = ALIGN(c->wq_copy_desc_count, 16);
+
+ c->rq_desc_count =
+ min_t(u32, VNIC_FNIC_RQ_DESCS_MAX,
+ max_t(u32, VNIC_FNIC_RQ_DESCS_MIN,
+ c->rq_desc_count));
+ c->rq_desc_count = ALIGN(c->rq_desc_count, 16);
+
+ c->maxdatafieldsize =
+ min_t(u16, VNIC_FNIC_MAXDATAFIELDSIZE_MAX,
+ max_t(u16, VNIC_FNIC_MAXDATAFIELDSIZE_MIN,
+ c->maxdatafieldsize));
+ c->ed_tov =
+ min_t(u32, VNIC_FNIC_EDTOV_MAX,
+ max_t(u32, VNIC_FNIC_EDTOV_MIN,
+ c->ed_tov));
+
+ c->ra_tov =
+ min_t(u32, VNIC_FNIC_RATOV_MAX,
+ max_t(u32, VNIC_FNIC_RATOV_MIN,
+ c->ra_tov));
+
+ c->flogi_retries =
+ min_t(u32, VNIC_FNIC_FLOGI_RETRIES_MAX, c->flogi_retries);
+
+ c->flogi_timeout =
+ min_t(u32, VNIC_FNIC_FLOGI_TIMEOUT_MAX,
+ max_t(u32, VNIC_FNIC_FLOGI_TIMEOUT_MIN,
+ c->flogi_timeout));
+
+ c->plogi_retries =
+ min_t(u32, VNIC_FNIC_PLOGI_RETRIES_MAX, c->plogi_retries);
+
+ c->plogi_timeout =
+ min_t(u32, VNIC_FNIC_PLOGI_TIMEOUT_MAX,
+ max_t(u32, VNIC_FNIC_PLOGI_TIMEOUT_MIN,
+ c->plogi_timeout));
+
+ c->io_throttle_count =
+ min_t(u32, VNIC_FNIC_IO_THROTTLE_COUNT_MAX,
+ max_t(u32, VNIC_FNIC_IO_THROTTLE_COUNT_MIN,
+ c->io_throttle_count));
+
+ c->link_down_timeout =
+ min_t(u32, VNIC_FNIC_LINK_DOWN_TIMEOUT_MAX,
+ c->link_down_timeout);
+
+ c->port_down_timeout =
+ min_t(u32, VNIC_FNIC_PORT_DOWN_TIMEOUT_MAX,
+ c->port_down_timeout);
+
+ c->port_down_io_retries =
+ min_t(u32, VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX,
+ c->port_down_io_retries);
+
+ c->luns_per_tgt =
+ min_t(u32, VNIC_FNIC_LUNS_PER_TARGET_MAX,
+ max_t(u32, VNIC_FNIC_LUNS_PER_TARGET_MIN,
+ c->luns_per_tgt));
+
+ c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer);
+ c->intr_timer_type = c->intr_timer_type;
+
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC MAC addr %02x:%02x:%02x:%02x:%02x:%02x "
+ "wq/wq_copy/rq %d/%d/%d\n",
+ fnic->mac_addr[0], fnic->mac_addr[1], fnic->mac_addr[2],
+ fnic->mac_addr[3], fnic->mac_addr[4], fnic->mac_addr[5],
+ c->wq_enet_desc_count, c->wq_copy_desc_count,
+ c->rq_desc_count);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC node wwn %llx port wwn %llx\n",
+ c->node_wwn, c->port_wwn);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC ed_tov %d ra_tov %d\n",
+ c->ed_tov, c->ra_tov);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC mtu %d intr timer %d\n",
+ c->maxdatafieldsize, c->intr_timer);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC flags 0x%x luns per tgt %d\n",
+ c->flags, c->luns_per_tgt);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC flogi_retries %d flogi timeout %d\n",
+ c->flogi_retries, c->flogi_timeout);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC plogi retries %d plogi timeout %d\n",
+ c->plogi_retries, c->plogi_timeout);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC io throttle count %d link dn timeout %d\n",
+ c->io_throttle_count, c->link_down_timeout);
+ shost_printk(KERN_INFO, fnic->lport->host,
+ "vNIC port dn io retries %d port dn timeout %d\n",
+ c->port_down_io_retries, c->port_down_timeout);
+
+ return 0;
+}
+
+int fnic_set_nic_config(struct fnic *fnic, u8 rss_default_cpu,
+ u8 rss_hash_type,
+ u8 rss_hash_bits, u8 rss_base_cpu, u8 rss_enable,
+ u8 tso_ipid_split_en, u8 ig_vlan_strip_en)
+{
+ u64 a0, a1;
+ u32 nic_cfg;
+ int wait = 1000;
+
+ vnic_set_nic_cfg(&nic_cfg, rss_default_cpu,
+ rss_hash_type, rss_hash_bits, rss_base_cpu,
+ rss_enable, tso_ipid_split_en, ig_vlan_strip_en);
+
+ a0 = nic_cfg;
+ a1 = 0;
+
+ return vnic_dev_cmd(fnic->vdev, CMD_NIC_CFG, &a0, &a1, wait);
+}
+
+void fnic_get_res_counts(struct fnic *fnic)
+{
+ fnic->wq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_WQ);
+ fnic->raw_wq_count = fnic->wq_count - 1;
+ fnic->wq_copy_count = fnic->wq_count - fnic->raw_wq_count;
+ fnic->rq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_RQ);
+ fnic->cq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_CQ);
+ fnic->intr_count = vnic_dev_get_res_count(fnic->vdev,
+ RES_TYPE_INTR_CTRL);
+}
+
+void fnic_free_vnic_resources(struct fnic *fnic)
+{
+ unsigned int i;
+
+ for (i = 0; i < fnic->raw_wq_count; i++)
+ vnic_wq_free(&fnic->wq[i]);
+
+ for (i = 0; i < fnic->wq_copy_count; i++)
+ vnic_wq_copy_free(&fnic->wq_copy[i]);
+
+ for (i = 0; i < fnic->rq_count; i++)
+ vnic_rq_free(&fnic->rq[i]);
+
+ for (i = 0; i < fnic->cq_count; i++)
+ vnic_cq_free(&fnic->cq[i]);
+
+ for (i = 0; i < fnic->intr_count; i++)
+ vnic_intr_free(&fnic->intr[i]);
+}
+
+int fnic_alloc_vnic_resources(struct fnic *fnic)
+{
+ enum vnic_dev_intr_mode intr_mode;
+ unsigned int mask_on_assertion;
+ unsigned int interrupt_offset;
+ unsigned int error_interrupt_enable;
+ unsigned int error_interrupt_offset;
+ unsigned int i, cq_index;
+ unsigned int wq_copy_cq_desc_count;
+ int err;
+
+ intr_mode = vnic_dev_get_intr_mode(fnic->vdev);
+
+ shost_printk(KERN_INFO, fnic->lport->host, "vNIC interrupt mode: %s\n",
+ intr_mode == VNIC_DEV_INTR_MODE_INTX ? "legacy PCI INTx" :
+ intr_mode == VNIC_DEV_INTR_MODE_MSI ? "MSI" :
+ intr_mode == VNIC_DEV_INTR_MODE_MSIX ?
+ "MSI-X" : "unknown");
+
+ shost_printk(KERN_INFO, fnic->lport->host, "vNIC resources avail: "
+ "wq %d cp_wq %d raw_wq %d rq %d cq %d intr %d\n",
+ fnic->wq_count, fnic->wq_copy_count, fnic->raw_wq_count,
+ fnic->rq_count, fnic->cq_count, fnic->intr_count);
+
+ /* Allocate Raw WQ used for FCS frames */
+ for (i = 0; i < fnic->raw_wq_count; i++) {
+ err = vnic_wq_alloc(fnic->vdev, &fnic->wq[i], i,
+ fnic->config.wq_enet_desc_count,
+ sizeof(struct wq_enet_desc));
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ /* Allocate Copy WQs used for SCSI IOs */
+ for (i = 0; i < fnic->wq_copy_count; i++) {
+ err = vnic_wq_copy_alloc(fnic->vdev, &fnic->wq_copy[i],
+ (fnic->raw_wq_count + i),
+ fnic->config.wq_copy_desc_count,
+ sizeof(struct fcpio_host_req));
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ /* RQ for receiving FCS frames */
+ for (i = 0; i < fnic->rq_count; i++) {
+ err = vnic_rq_alloc(fnic->vdev, &fnic->rq[i], i,
+ fnic->config.rq_desc_count,
+ sizeof(struct rq_enet_desc));
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ /* CQ for each RQ */
+ for (i = 0; i < fnic->rq_count; i++) {
+ cq_index = i;
+ err = vnic_cq_alloc(fnic->vdev,
+ &fnic->cq[cq_index], cq_index,
+ fnic->config.rq_desc_count,
+ sizeof(struct cq_enet_rq_desc));
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ /* CQ for each WQ */
+ for (i = 0; i < fnic->raw_wq_count; i++) {
+ cq_index = fnic->rq_count + i;
+ err = vnic_cq_alloc(fnic->vdev, &fnic->cq[cq_index], cq_index,
+ fnic->config.wq_enet_desc_count,
+ sizeof(struct cq_enet_wq_desc));
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ /* CQ for each COPY WQ */
+ wq_copy_cq_desc_count = (fnic->config.wq_copy_desc_count * 3);
+ for (i = 0; i < fnic->wq_copy_count; i++) {
+ cq_index = fnic->raw_wq_count + fnic->rq_count + i;
+ err = vnic_cq_alloc(fnic->vdev, &fnic->cq[cq_index],
+ cq_index,
+ wq_copy_cq_desc_count,
+ sizeof(struct fcpio_fw_req));
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ for (i = 0; i < fnic->intr_count; i++) {
+ err = vnic_intr_alloc(fnic->vdev, &fnic->intr[i], i);
+ if (err)
+ goto err_out_cleanup;
+ }
+
+ fnic->legacy_pba = vnic_dev_get_res(fnic->vdev,
+ RES_TYPE_INTR_PBA_LEGACY, 0);
+
+ if (!fnic->legacy_pba && intr_mode == VNIC_DEV_INTR_MODE_INTX) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Failed to hook legacy pba resource\n");
+ err = -ENODEV;
+ goto err_out_cleanup;
+ }
+
+ /*
+ * Init RQ/WQ resources.
+ *
+ * RQ[0 to n-1] point to CQ[0 to n-1]
+ * WQ[0 to m-1] point to CQ[n to n+m-1]
+ * WQ_COPY[0 to k-1] points to CQ[n+m to n+m+k-1]
+ *
+ * Note for copy wq we always initialize with cq_index = 0
+ *
+ * Error interrupt is not enabled for MSI.
+ */
+
+ switch (intr_mode) {
+ case VNIC_DEV_INTR_MODE_INTX:
+ case VNIC_DEV_INTR_MODE_MSIX:
+ error_interrupt_enable = 1;
+ error_interrupt_offset = fnic->err_intr_offset;
+ break;
+ default:
+ error_interrupt_enable = 0;
+ error_interrupt_offset = 0;
+ break;
+ }
+
+ for (i = 0; i < fnic->rq_count; i++) {
+ cq_index = i;
+ vnic_rq_init(&fnic->rq[i],
+ cq_index,
+ error_interrupt_enable,
+ error_interrupt_offset);
+ }
+
+ for (i = 0; i < fnic->raw_wq_count; i++) {
+ cq_index = i + fnic->rq_count;
+ vnic_wq_init(&fnic->wq[i],
+ cq_index,
+ error_interrupt_enable,
+ error_interrupt_offset);
+ }
+
+ for (i = 0; i < fnic->wq_copy_count; i++) {
+ vnic_wq_copy_init(&fnic->wq_copy[i],
+ 0 /* cq_index 0 - always */,
+ error_interrupt_enable,
+ error_interrupt_offset);
+ }
+
+ for (i = 0; i < fnic->cq_count; i++) {
+
+ switch (intr_mode) {
+ case VNIC_DEV_INTR_MODE_MSIX:
+ interrupt_offset = i;
+ break;
+ default:
+ interrupt_offset = 0;
+ break;
+ }
+
+ vnic_cq_init(&fnic->cq[i],
+ 0 /* flow_control_enable */,
+ 1 /* color_enable */,
+ 0 /* cq_head */,
+ 0 /* cq_tail */,
+ 1 /* cq_tail_color */,
+ 1 /* interrupt_enable */,
+ 1 /* cq_entry_enable */,
+ 0 /* cq_message_enable */,
+ interrupt_offset,
+ 0 /* cq_message_addr */);
+ }
+
+ /*
+ * Init INTR resources
+ *
+ * mask_on_assertion is not used for INTx due to the level-
+ * triggered nature of INTx
+ */
+
+ switch (intr_mode) {
+ case VNIC_DEV_INTR_MODE_MSI:
+ case VNIC_DEV_INTR_MODE_MSIX:
+ mask_on_assertion = 1;
+ break;
+ default:
+ mask_on_assertion = 0;
+ break;
+ }
+
+ for (i = 0; i < fnic->intr_count; i++) {
+ vnic_intr_init(&fnic->intr[i],
+ fnic->config.intr_timer,
+ fnic->config.intr_timer_type,
+ mask_on_assertion);
+ }
+
+ /* init the stats memory by making the first call here */
+ err = vnic_dev_stats_dump(fnic->vdev, &fnic->stats);
+ if (err) {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "vnic_dev_stats_dump failed - x%x\n", err);
+ goto err_out_cleanup;
+ }
+
+ /* Clear LIF stats */
+ vnic_dev_stats_clear(fnic->vdev);
+
+ return 0;
+
+err_out_cleanup:
+ fnic_free_vnic_resources(fnic);
+
+ return err;
+}
diff --git a/drivers/scsi/fnic/fnic_res.h b/drivers/scsi/fnic/fnic_res.h
new file mode 100644
index 000000000000..b6f310262534
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_res.h
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _FNIC_RES_H_
+#define _FNIC_RES_H_
+
+#include "wq_enet_desc.h"
+#include "rq_enet_desc.h"
+#include "vnic_wq.h"
+#include "vnic_rq.h"
+#include "fnic_io.h"
+#include "fcpio.h"
+#include "vnic_wq_copy.h"
+#include "vnic_cq_copy.h"
+
+static inline void fnic_queue_wq_desc(struct vnic_wq *wq,
+ void *os_buf, dma_addr_t dma_addr,
+ unsigned int len, unsigned int fc_eof,
+ int vlan_tag_insert,
+ unsigned int vlan_tag,
+ int cq_entry, int sop, int eop)
+{
+ struct wq_enet_desc *desc = vnic_wq_next_desc(wq);
+
+ wq_enet_desc_enc(desc,
+ (u64)dma_addr | VNIC_PADDR_TARGET,
+ (u16)len,
+ 0, /* mss_or_csum_offset */
+ (u16)fc_eof,
+ 0, /* offload_mode */
+ (u8)eop, (u8)cq_entry,
+ 1, /* fcoe_encap */
+ (u8)vlan_tag_insert,
+ (u16)vlan_tag,
+ 0 /* loopback */);
+
+ vnic_wq_post(wq, os_buf, dma_addr, len, sop, eop);
+}
+
+static inline void fnic_queue_wq_copy_desc_icmnd_16(struct vnic_wq_copy *wq,
+ u32 req_id,
+ u32 lunmap_id, u8 spl_flags,
+ u32 sgl_cnt, u32 sense_len,
+ u64 sgl_addr, u64 sns_addr,
+ u8 crn, u8 pri_ta,
+ u8 flags, u8 *scsi_cdb,
+ u32 data_len, u8 *lun,
+ u32 d_id, u16 mss,
+ u32 ratov, u32 edtov)
+{
+ struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq);
+
+ desc->hdr.type = FCPIO_ICMND_16; /* enum fcpio_type */
+ desc->hdr.status = 0; /* header status entry */
+ desc->hdr._resvd = 0; /* reserved */
+ desc->hdr.tag.u.req_id = req_id; /* id for this request */
+
+ desc->u.icmnd_16.lunmap_id = lunmap_id; /* index into lunmap table */
+ desc->u.icmnd_16.special_req_flags = spl_flags; /* exch req flags */
+ desc->u.icmnd_16._resvd0[0] = 0; /* reserved */
+ desc->u.icmnd_16._resvd0[1] = 0; /* reserved */
+ desc->u.icmnd_16._resvd0[2] = 0; /* reserved */
+ desc->u.icmnd_16.sgl_cnt = sgl_cnt; /* scatter-gather list count */
+ desc->u.icmnd_16.sense_len = sense_len; /* sense buffer length */
+ desc->u.icmnd_16.sgl_addr = sgl_addr; /* scatter-gather list addr */
+ desc->u.icmnd_16.sense_addr = sns_addr; /* sense buffer address */
+ desc->u.icmnd_16.crn = crn; /* SCSI Command Reference No.*/
+ desc->u.icmnd_16.pri_ta = pri_ta; /* SCSI Pri & Task attribute */
+ desc->u.icmnd_16._resvd1 = 0; /* reserved: should be 0 */
+ desc->u.icmnd_16.flags = flags; /* command flags */
+ memcpy(desc->u.icmnd_16.scsi_cdb, scsi_cdb, CDB_16); /* SCSI CDB */
+ desc->u.icmnd_16.data_len = data_len; /* length of data expected */
+ memcpy(desc->u.icmnd_16.lun, lun, LUN_ADDRESS); /* LUN address */
+ desc->u.icmnd_16._resvd2 = 0; /* reserved */
+ hton24(desc->u.icmnd_16.d_id, d_id); /* FC vNIC only: Target D_ID */
+ desc->u.icmnd_16.mss = mss; /* FC vNIC only: max burst */
+ desc->u.icmnd_16.r_a_tov = ratov; /*FC vNIC only: Res. Alloc Timeout */
+ desc->u.icmnd_16.e_d_tov = edtov; /*FC vNIC only: Err Detect Timeout */
+
+ vnic_wq_copy_post(wq);
+}
+
+static inline void fnic_queue_wq_copy_desc_itmf(struct vnic_wq_copy *wq,
+ u32 req_id, u32 lunmap_id,
+ u32 tm_req, u32 tm_id, u8 *lun,
+ u32 d_id, u32 r_a_tov,
+ u32 e_d_tov)
+{
+ struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq);
+
+ desc->hdr.type = FCPIO_ITMF; /* enum fcpio_type */
+ desc->hdr.status = 0; /* header status entry */
+ desc->hdr._resvd = 0; /* reserved */
+ desc->hdr.tag.u.req_id = req_id; /* id for this request */
+
+ desc->u.itmf.lunmap_id = lunmap_id; /* index into lunmap table */
+ desc->u.itmf.tm_req = tm_req; /* SCSI Task Management request */
+ desc->u.itmf.t_tag = tm_id; /* tag of fcpio to be aborted */
+ desc->u.itmf._resvd = 0;
+ memcpy(desc->u.itmf.lun, lun, LUN_ADDRESS); /* LUN address */
+ desc->u.itmf._resvd1 = 0;
+ hton24(desc->u.itmf.d_id, d_id); /* FC vNIC only: Target D_ID */
+ desc->u.itmf.r_a_tov = r_a_tov; /* FC vNIC only: R_A_TOV in msec */
+ desc->u.itmf.e_d_tov = e_d_tov; /* FC vNIC only: E_D_TOV in msec */
+
+ vnic_wq_copy_post(wq);
+}
+
+static inline void fnic_queue_wq_copy_desc_flogi_reg(struct vnic_wq_copy *wq,
+ u32 req_id, u8 format,
+ u32 s_id, u8 *gw_mac)
+{
+ struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq);
+
+ desc->hdr.type = FCPIO_FLOGI_REG; /* enum fcpio_type */
+ desc->hdr.status = 0; /* header status entry */
+ desc->hdr._resvd = 0; /* reserved */
+ desc->hdr.tag.u.req_id = req_id; /* id for this request */
+
+ desc->u.flogi_reg.format = format;
+ hton24(desc->u.flogi_reg.s_id, s_id);
+ memcpy(desc->u.flogi_reg.gateway_mac, gw_mac, ETH_ALEN);
+
+ vnic_wq_copy_post(wq);
+}
+
+static inline void fnic_queue_wq_copy_desc_fw_reset(struct vnic_wq_copy *wq,
+ u32 req_id)
+{
+ struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq);
+
+ desc->hdr.type = FCPIO_RESET; /* enum fcpio_type */
+ desc->hdr.status = 0; /* header status entry */
+ desc->hdr._resvd = 0; /* reserved */
+ desc->hdr.tag.u.req_id = req_id; /* id for this request */
+
+ vnic_wq_copy_post(wq);
+}
+
+static inline void fnic_queue_wq_copy_desc_lunmap(struct vnic_wq_copy *wq,
+ u32 req_id, u64 lunmap_addr,
+ u32 lunmap_len)
+{
+ struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq);
+
+ desc->hdr.type = FCPIO_LUNMAP_REQ; /* enum fcpio_type */
+ desc->hdr.status = 0; /* header status entry */
+ desc->hdr._resvd = 0; /* reserved */
+ desc->hdr.tag.u.req_id = req_id; /* id for this request */
+
+ desc->u.lunmap_req.addr = lunmap_addr; /* address of the buffer */
+ desc->u.lunmap_req.len = lunmap_len; /* len of the buffer */
+
+ vnic_wq_copy_post(wq);
+}
+
+static inline void fnic_queue_rq_desc(struct vnic_rq *rq,
+ void *os_buf, dma_addr_t dma_addr,
+ u16 len)
+{
+ struct rq_enet_desc *desc = vnic_rq_next_desc(rq);
+
+ rq_enet_desc_enc(desc,
+ (u64)dma_addr | VNIC_PADDR_TARGET,
+ RQ_ENET_TYPE_ONLY_SOP,
+ (u16)len);
+
+ vnic_rq_post(rq, os_buf, 0, dma_addr, len);
+}
+
+
+struct fnic;
+
+int fnic_get_vnic_config(struct fnic *);
+int fnic_alloc_vnic_resources(struct fnic *);
+void fnic_free_vnic_resources(struct fnic *);
+void fnic_get_res_counts(struct fnic *);
+int fnic_set_nic_config(struct fnic *fnic, u8 rss_default_cpu,
+ u8 rss_hash_type, u8 rss_hash_bits, u8 rss_base_cpu,
+ u8 rss_enable, u8 tso_ipid_split_en,
+ u8 ig_vlan_strip_en);
+
+#endif /* _FNIC_RES_H_ */
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
new file mode 100644
index 000000000000..eabf36502856
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -0,0 +1,1850 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/mempool.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/workqueue.h>
+#include <linux/pci.h>
+#include <linux/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/spinlock.h>
+#include <linux/if_ether.h>
+#include <linux/if_vlan.h>
+#include <linux/delay.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/fc/fc_els.h>
+#include <scsi/fc/fc_fcoe.h>
+#include <scsi/libfc.h>
+#include <scsi/fc_frame.h>
+#include "fnic_io.h"
+#include "fnic.h"
+
+const char *fnic_state_str[] = {
+ [FNIC_IN_FC_MODE] = "FNIC_IN_FC_MODE",
+ [FNIC_IN_FC_TRANS_ETH_MODE] = "FNIC_IN_FC_TRANS_ETH_MODE",
+ [FNIC_IN_ETH_MODE] = "FNIC_IN_ETH_MODE",
+ [FNIC_IN_ETH_TRANS_FC_MODE] = "FNIC_IN_ETH_TRANS_FC_MODE",
+};
+
+static const char *fnic_ioreq_state_str[] = {
+ [FNIC_IOREQ_CMD_PENDING] = "FNIC_IOREQ_CMD_PENDING",
+ [FNIC_IOREQ_ABTS_PENDING] = "FNIC_IOREQ_ABTS_PENDING",
+ [FNIC_IOREQ_ABTS_COMPLETE] = "FNIC_IOREQ_ABTS_COMPLETE",
+ [FNIC_IOREQ_CMD_COMPLETE] = "FNIC_IOREQ_CMD_COMPLETE",
+};
+
+static const char *fcpio_status_str[] = {
+ [FCPIO_SUCCESS] = "FCPIO_SUCCESS", /*0x0*/
+ [FCPIO_INVALID_HEADER] = "FCPIO_INVALID_HEADER",
+ [FCPIO_OUT_OF_RESOURCE] = "FCPIO_OUT_OF_RESOURCE",
+ [FCPIO_INVALID_PARAM] = "FCPIO_INVALID_PARAM]",
+ [FCPIO_REQ_NOT_SUPPORTED] = "FCPIO_REQ_NOT_SUPPORTED",
+ [FCPIO_IO_NOT_FOUND] = "FCPIO_IO_NOT_FOUND",
+ [FCPIO_ABORTED] = "FCPIO_ABORTED", /*0x41*/
+ [FCPIO_TIMEOUT] = "FCPIO_TIMEOUT",
+ [FCPIO_SGL_INVALID] = "FCPIO_SGL_INVALID",
+ [FCPIO_MSS_INVALID] = "FCPIO_MSS_INVALID",
+ [FCPIO_DATA_CNT_MISMATCH] = "FCPIO_DATA_CNT_MISMATCH",
+ [FCPIO_FW_ERR] = "FCPIO_FW_ERR",
+ [FCPIO_ITMF_REJECTED] = "FCPIO_ITMF_REJECTED",
+ [FCPIO_ITMF_FAILED] = "FCPIO_ITMF_FAILED",
+ [FCPIO_ITMF_INCORRECT_LUN] = "FCPIO_ITMF_INCORRECT_LUN",
+ [FCPIO_CMND_REJECTED] = "FCPIO_CMND_REJECTED",
+ [FCPIO_NO_PATH_AVAIL] = "FCPIO_NO_PATH_AVAIL",
+ [FCPIO_PATH_FAILED] = "FCPIO_PATH_FAILED",
+ [FCPIO_LUNMAP_CHNG_PEND] = "FCPIO_LUNHMAP_CHNG_PEND",
+};
+
+const char *fnic_state_to_str(unsigned int state)
+{
+ if (state >= ARRAY_SIZE(fnic_state_str) || !fnic_state_str[state])
+ return "unknown";
+
+ return fnic_state_str[state];
+}
+
+static const char *fnic_ioreq_state_to_str(unsigned int state)
+{
+ if (state >= ARRAY_SIZE(fnic_ioreq_state_str) ||
+ !fnic_ioreq_state_str[state])
+ return "unknown";
+
+ return fnic_ioreq_state_str[state];
+}
+
+static const char *fnic_fcpio_status_to_str(unsigned int status)
+{
+ if (status >= ARRAY_SIZE(fcpio_status_str) || !fcpio_status_str[status])
+ return "unknown";
+
+ return fcpio_status_str[status];
+}
+
+static void fnic_cleanup_io(struct fnic *fnic, int exclude_id);
+
+static inline spinlock_t *fnic_io_lock_hash(struct fnic *fnic,
+ struct scsi_cmnd *sc)
+{
+ u32 hash = sc->request->tag & (FNIC_IO_LOCKS - 1);
+
+ return &fnic->io_req_lock[hash];
+}
+
+/*
+ * Unmap the data buffer and sense buffer for an io_req,
+ * also unmap and free the device-private scatter/gather list.
+ */
+static void fnic_release_ioreq_buf(struct fnic *fnic,
+ struct fnic_io_req *io_req,
+ struct scsi_cmnd *sc)
+{
+ if (io_req->sgl_list_pa)
+ pci_unmap_single(fnic->pdev, io_req->sgl_list_pa,
+ sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt,
+ PCI_DMA_TODEVICE);
+ scsi_dma_unmap(sc);
+
+ if (io_req->sgl_cnt)
+ mempool_free(io_req->sgl_list_alloc,
+ fnic->io_sgl_pool[io_req->sgl_type]);
+ if (io_req->sense_buf_pa)
+ pci_unmap_single(fnic->pdev, io_req->sense_buf_pa,
+ SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE);
+}
+
+/* Free up Copy Wq descriptors. Called with copy_wq lock held */
+static int free_wq_copy_descs(struct fnic *fnic, struct vnic_wq_copy *wq)
+{
+ /* if no Ack received from firmware, then nothing to clean */
+ if (!fnic->fw_ack_recd[0])
+ return 1;
+
+ /*
+ * Update desc_available count based on number of freed descriptors
+ * Account for wraparound
+ */
+ if (wq->to_clean_index <= fnic->fw_ack_index[0])
+ wq->ring.desc_avail += (fnic->fw_ack_index[0]
+ - wq->to_clean_index + 1);
+ else
+ wq->ring.desc_avail += (wq->ring.desc_count
+ - wq->to_clean_index
+ + fnic->fw_ack_index[0] + 1);
+
+ /*
+ * just bump clean index to ack_index+1 accounting for wraparound
+ * this will essentially free up all descriptors between
+ * to_clean_index and fw_ack_index, both inclusive
+ */
+ wq->to_clean_index =
+ (fnic->fw_ack_index[0] + 1) % wq->ring.desc_count;
+
+ /* we have processed the acks received so far */
+ fnic->fw_ack_recd[0] = 0;
+ return 0;
+}
+
+
+/*
+ * fnic_fw_reset_handler
+ * Routine to send reset msg to fw
+ */
+int fnic_fw_reset_handler(struct fnic *fnic)
+{
+ struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+ int ret = 0;
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
+
+ if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
+ free_wq_copy_descs(fnic, wq);
+
+ if (!vnic_wq_copy_desc_avail(wq))
+ ret = -EAGAIN;
+ else
+ fnic_queue_wq_copy_desc_fw_reset(wq, SCSI_NO_TAG);
+
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
+
+ if (!ret)
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Issued fw reset\n");
+ else
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Failed to issue fw reset\n");
+ return ret;
+}
+
+
+/*
+ * fnic_flogi_reg_handler
+ * Routine to send flogi register msg to fw
+ */
+int fnic_flogi_reg_handler(struct fnic *fnic)
+{
+ struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+ u8 gw_mac[ETH_ALEN];
+ int ret = 0;
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
+
+ if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
+ free_wq_copy_descs(fnic, wq);
+
+ if (!vnic_wq_copy_desc_avail(wq)) {
+ ret = -EAGAIN;
+ goto flogi_reg_ioreq_end;
+ }
+
+ if (fnic->fcoui_mode)
+ memset(gw_mac, 0xff, ETH_ALEN);
+ else
+ memcpy(gw_mac, fnic->dest_addr, ETH_ALEN);
+
+ fnic_queue_wq_copy_desc_flogi_reg(wq, SCSI_NO_TAG,
+ FCPIO_FLOGI_REG_GW_DEST,
+ fnic->s_id,
+ gw_mac);
+
+flogi_reg_ioreq_end:
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
+
+ if (!ret)
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "flog reg issued\n");
+
+ return ret;
+}
+
+/*
+ * fnic_queue_wq_copy_desc
+ * Routine to enqueue a wq copy desc
+ */
+static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
+ struct vnic_wq_copy *wq,
+ struct fnic_io_req *io_req,
+ struct scsi_cmnd *sc,
+ u32 sg_count)
+{
+ struct scatterlist *sg;
+ struct fc_rport *rport = starget_to_rport(scsi_target(sc->device));
+ struct fc_rport_libfc_priv *rp = rport->dd_data;
+ struct host_sg_desc *desc;
+ u8 pri_tag = 0;
+ unsigned int i;
+ unsigned long intr_flags;
+ int flags;
+ u8 exch_flags;
+ struct scsi_lun fc_lun;
+ char msg[2];
+
+ if (sg_count) {
+ BUG_ON(sg_count < 0);
+ BUG_ON(sg_count > FNIC_MAX_SG_DESC_CNT);
+
+ /* For each SGE, create a device desc entry */
+ desc = io_req->sgl_list;
+ for_each_sg(scsi_sglist(sc), sg, sg_count, i) {
+ desc->addr = cpu_to_le64(sg_dma_address(sg));
+ desc->len = cpu_to_le32(sg_dma_len(sg));
+ desc->_resvd = 0;
+ desc++;
+ }
+
+ io_req->sgl_list_pa = pci_map_single
+ (fnic->pdev,
+ io_req->sgl_list,
+ sizeof(io_req->sgl_list[0]) * sg_count,
+ PCI_DMA_TODEVICE);
+ }
+
+ io_req->sense_buf_pa = pci_map_single(fnic->pdev,
+ sc->sense_buffer,
+ SCSI_SENSE_BUFFERSIZE,
+ PCI_DMA_FROMDEVICE);
+
+ int_to_scsilun(sc->device->lun, &fc_lun);
+
+ pri_tag = FCPIO_ICMND_PTA_SIMPLE;
+ msg[0] = MSG_SIMPLE_TAG;
+ scsi_populate_tag_msg(sc, msg);
+ if (msg[0] == MSG_ORDERED_TAG)
+ pri_tag = FCPIO_ICMND_PTA_ORDERED;
+
+ /* Enqueue the descriptor in the Copy WQ */
+ spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags);
+
+ if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
+ free_wq_copy_descs(fnic, wq);
+
+ if (unlikely(!vnic_wq_copy_desc_avail(wq))) {
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
+ return SCSI_MLQUEUE_HOST_BUSY;
+ }
+
+ flags = 0;
+ if (sc->sc_data_direction == DMA_FROM_DEVICE)
+ flags = FCPIO_ICMND_RDDATA;
+ else if (sc->sc_data_direction == DMA_TO_DEVICE)
+ flags = FCPIO_ICMND_WRDATA;
+
+ exch_flags = 0;
+ if ((fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) &&
+ (rp->flags & FC_RP_FLAGS_RETRY))
+ exch_flags |= FCPIO_ICMND_SRFLAG_RETRY;
+
+ fnic_queue_wq_copy_desc_icmnd_16(wq, sc->request->tag,
+ 0, exch_flags, io_req->sgl_cnt,
+ SCSI_SENSE_BUFFERSIZE,
+ io_req->sgl_list_pa,
+ io_req->sense_buf_pa,
+ 0, /* scsi cmd ref, always 0 */
+ pri_tag, /* scsi pri and tag */
+ flags, /* command flags */
+ sc->cmnd, scsi_bufflen(sc),
+ fc_lun.scsi_lun, io_req->port_id,
+ rport->maxframe_size, rp->r_a_tov,
+ rp->e_d_tov);
+
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
+ return 0;
+}
+
+/*
+ * fnic_queuecommand
+ * Routine to send a scsi cdb
+ * Called with host_lock held and interrupts disabled.
+ */
+int fnic_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
+{
+ struct fc_lport *lp;
+ struct fc_rport *rport;
+ struct fnic_io_req *io_req;
+ struct fnic *fnic;
+ struct vnic_wq_copy *wq;
+ int ret;
+ u32 sg_count;
+ unsigned long flags;
+ unsigned long ptr;
+
+ rport = starget_to_rport(scsi_target(sc->device));
+ ret = fc_remote_port_chkready(rport);
+ if (ret) {
+ sc->result = ret;
+ done(sc);
+ return 0;
+ }
+
+ lp = shost_priv(sc->device->host);
+ if (lp->state != LPORT_ST_READY || !(lp->link_up))
+ return SCSI_MLQUEUE_HOST_BUSY;
+
+ /*
+ * Release host lock, use driver resource specific locks from here.
+ * Don't re-enable interrupts in case they were disabled prior to the
+ * caller disabling them.
+ */
+ spin_unlock(lp->host->host_lock);
+
+ /* Get a new io_req for this SCSI IO */
+ fnic = lport_priv(lp);
+
+ io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
+ if (!io_req) {
+ ret = SCSI_MLQUEUE_HOST_BUSY;
+ goto out;
+ }
+ memset(io_req, 0, sizeof(*io_req));
+
+ /* Map the data buffer */
+ sg_count = scsi_dma_map(sc);
+ if (sg_count < 0) {
+ mempool_free(io_req, fnic->io_req_pool);
+ goto out;
+ }
+
+ /* Determine the type of scatter/gather list we need */
+ io_req->sgl_cnt = sg_count;
+ io_req->sgl_type = FNIC_SGL_CACHE_DFLT;
+ if (sg_count > FNIC_DFLT_SG_DESC_CNT)
+ io_req->sgl_type = FNIC_SGL_CACHE_MAX;
+
+ if (sg_count) {
+ io_req->sgl_list =
+ mempool_alloc(fnic->io_sgl_pool[io_req->sgl_type],
+ GFP_ATOMIC | GFP_DMA);
+ if (!io_req->sgl_list) {
+ ret = SCSI_MLQUEUE_HOST_BUSY;
+ scsi_dma_unmap(sc);
+ mempool_free(io_req, fnic->io_req_pool);
+ goto out;
+ }
+
+ /* Cache sgl list allocated address before alignment */
+ io_req->sgl_list_alloc = io_req->sgl_list;
+ ptr = (unsigned long) io_req->sgl_list;
+ if (ptr % FNIC_SG_DESC_ALIGN) {
+ io_req->sgl_list = (struct host_sg_desc *)
+ (((unsigned long) ptr
+ + FNIC_SG_DESC_ALIGN - 1)
+ & ~(FNIC_SG_DESC_ALIGN - 1));
+ }
+ }
+
+ /* initialize rest of io_req */
+ io_req->port_id = rport->port_id;
+ CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
+ CMD_SP(sc) = (char *)io_req;
+ sc->scsi_done = done;
+
+ /* create copy wq desc and enqueue it */
+ wq = &fnic->wq_copy[0];
+ ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count);
+ if (ret) {
+ /*
+ * In case another thread cancelled the request,
+ * refetch the pointer under the lock.
+ */
+ spinlock_t *io_lock = fnic_io_lock_hash(fnic, sc);
+
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ CMD_SP(sc) = NULL;
+ CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
+ spin_unlock_irqrestore(io_lock, flags);
+ if (io_req) {
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+ }
+ }
+out:
+ /* acquire host lock before returning to SCSI */
+ spin_lock(lp->host->host_lock);
+ return ret;
+}
+
+/*
+ * fnic_fcpio_fw_reset_cmpl_handler
+ * Routine to handle fw reset completion
+ */
+static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag tag;
+ int ret = 0;
+ struct fc_frame *flogi;
+ unsigned long flags;
+
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
+
+ /* Clean up all outstanding io requests */
+ fnic_cleanup_io(fnic, SCSI_NO_TAG);
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ flogi = fnic->flogi;
+ fnic->flogi = NULL;
+
+ /* fnic should be in FC_TRANS_ETH_MODE */
+ if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) {
+ /* Check status of reset completion */
+ if (!hdr_status) {
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "reset cmpl success\n");
+ /* Ready to send flogi out */
+ fnic->state = FNIC_IN_ETH_MODE;
+ } else {
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "fnic fw_reset : failed %s\n",
+ fnic_fcpio_status_to_str(hdr_status));
+
+ /*
+ * Unable to change to eth mode, cannot send out flogi
+ * Change state to fc mode, so that subsequent Flogi
+ * requests from libFC will cause more attempts to
+ * reset the firmware. Free the cached flogi
+ */
+ fnic->state = FNIC_IN_FC_MODE;
+ ret = -1;
+ }
+ } else {
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "Unexpected state %s while processing"
+ " reset cmpl\n", fnic_state_to_str(fnic->state));
+ ret = -1;
+ }
+
+ /* Thread removing device blocks till firmware reset is complete */
+ if (fnic->remove_wait)
+ complete(fnic->remove_wait);
+
+ /*
+ * If fnic is being removed, or fw reset failed
+ * free the flogi frame. Else, send it out
+ */
+ if (fnic->remove_wait || ret) {
+ fnic->flogi_oxid = FC_XID_UNKNOWN;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ if (flogi)
+ dev_kfree_skb_irq(fp_skb(flogi));
+ goto reset_cmpl_handler_end;
+ }
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (flogi)
+ ret = fnic_send_frame(fnic, flogi);
+
+ reset_cmpl_handler_end:
+ return ret;
+}
+
+/*
+ * fnic_fcpio_flogi_reg_cmpl_handler
+ * Routine to handle flogi register completion
+ */
+static int fnic_fcpio_flogi_reg_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag tag;
+ int ret = 0;
+ struct fc_frame *flogi_resp = NULL;
+ unsigned long flags;
+ struct sk_buff *skb;
+
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
+
+ /* Update fnic state based on status of flogi reg completion */
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ flogi_resp = fnic->flogi_resp;
+ fnic->flogi_resp = NULL;
+
+ if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE) {
+
+ /* Check flogi registration completion status */
+ if (!hdr_status) {
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "flog reg succeeded\n");
+ fnic->state = FNIC_IN_FC_MODE;
+ } else {
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "fnic flogi reg :failed %s\n",
+ fnic_fcpio_status_to_str(hdr_status));
+ fnic->state = FNIC_IN_ETH_MODE;
+ ret = -1;
+ }
+ } else {
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Unexpected fnic state %s while"
+ " processing flogi reg completion\n",
+ fnic_state_to_str(fnic->state));
+ ret = -1;
+ }
+
+ /* Successful flogi reg cmpl, pass frame to LibFC */
+ if (!ret && flogi_resp) {
+ if (fnic->stop_rx_link_events) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ goto reg_cmpl_handler_end;
+ }
+ skb = (struct sk_buff *)flogi_resp;
+ /* Use fr_flags to indicate whether flogi resp or not */
+ fr_flags(flogi_resp) = 1;
+ fr_dev(flogi_resp) = fnic->lport;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ skb_queue_tail(&fnic->frame_queue, skb);
+ queue_work(fnic_event_queue, &fnic->frame_work);
+
+ } else {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ if (flogi_resp)
+ dev_kfree_skb_irq(fp_skb(flogi_resp));
+ }
+
+reg_cmpl_handler_end:
+ return ret;
+}
+
+static inline int is_ack_index_in_range(struct vnic_wq_copy *wq,
+ u16 request_out)
+{
+ if (wq->to_clean_index <= wq->to_use_index) {
+ /* out of range, stale request_out index */
+ if (request_out < wq->to_clean_index ||
+ request_out >= wq->to_use_index)
+ return 0;
+ } else {
+ /* out of range, stale request_out index */
+ if (request_out < wq->to_clean_index &&
+ request_out >= wq->to_use_index)
+ return 0;
+ }
+ /* request_out index is in range */
+ return 1;
+}
+
+
+/*
+ * Mark that ack received and store the Ack index. If there are multiple
+ * acks received before Tx thread cleans it up, the latest value will be
+ * used which is correct behavior. This state should be in the copy Wq
+ * instead of in the fnic
+ */
+static inline void fnic_fcpio_ack_handler(struct fnic *fnic,
+ unsigned int cq_index,
+ struct fcpio_fw_req *desc)
+{
+ struct vnic_wq_copy *wq;
+ u16 request_out = desc->u.ack.request_out;
+ unsigned long flags;
+
+ /* mark the ack state */
+ wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count];
+ spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
+
+ if (is_ack_index_in_range(wq, request_out)) {
+ fnic->fw_ack_index[0] = request_out;
+ fnic->fw_ack_recd[0] = 1;
+ }
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
+}
+
+/*
+ * fnic_fcpio_icmnd_cmpl_handler
+ * Routine to handle icmnd completions
+ */
+static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag tag;
+ u32 id;
+ u64 xfer_len = 0;
+ struct fcpio_icmnd_cmpl *icmnd_cmpl;
+ struct fnic_io_req *io_req;
+ struct scsi_cmnd *sc;
+ unsigned long flags;
+ spinlock_t *io_lock;
+
+ /* Decode the cmpl description to get the io_req id */
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
+ fcpio_tag_id_dec(&tag, &id);
+
+ if (id >= FNIC_MAX_IO_REQ)
+ return;
+
+ sc = scsi_host_find_tag(fnic->lport->host, id);
+ WARN_ON_ONCE(!sc);
+ if (!sc)
+ return;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ WARN_ON_ONCE(!io_req);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ return;
+ }
+
+ /* firmware completed the io */
+ io_req->io_completed = 1;
+
+ /*
+ * if SCSI-ML has already issued abort on this command,
+ * ignore completion of the IO. The abts path will clean it up
+ */
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+ spin_unlock_irqrestore(io_lock, flags);
+ return;
+ }
+
+ /* Mark the IO as complete */
+ CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
+
+ icmnd_cmpl = &desc->u.icmnd_cmpl;
+
+ switch (hdr_status) {
+ case FCPIO_SUCCESS:
+ sc->result = (DID_OK << 16) | icmnd_cmpl->scsi_status;
+ xfer_len = scsi_bufflen(sc);
+ scsi_set_resid(sc, icmnd_cmpl->residual);
+
+ if (icmnd_cmpl->flags & FCPIO_ICMND_CMPL_RESID_UNDER)
+ xfer_len -= icmnd_cmpl->residual;
+
+ /*
+ * If queue_full, then try to reduce queue depth for all
+ * LUNS on the target. Todo: this should be accompanied
+ * by a periodic queue_depth rampup based on successful
+ * IO completion.
+ */
+ if (icmnd_cmpl->scsi_status == QUEUE_FULL) {
+ struct scsi_device *t_sdev;
+ int qd = 0;
+
+ shost_for_each_device(t_sdev, sc->device->host) {
+ if (t_sdev->id != sc->device->id)
+ continue;
+
+ if (t_sdev->queue_depth > 1) {
+ qd = scsi_track_queue_full
+ (t_sdev,
+ t_sdev->queue_depth - 1);
+ if (qd == -1)
+ qd = t_sdev->host->cmd_per_lun;
+ shost_printk(KERN_INFO,
+ fnic->lport->host,
+ "scsi[%d:%d:%d:%d"
+ "] queue full detected,"
+ "new depth = %d\n",
+ t_sdev->host->host_no,
+ t_sdev->channel,
+ t_sdev->id, t_sdev->lun,
+ t_sdev->queue_depth);
+ }
+ }
+ }
+ break;
+
+ case FCPIO_TIMEOUT: /* request was timed out */
+ sc->result = (DID_TIME_OUT << 16) | icmnd_cmpl->scsi_status;
+ break;
+
+ case FCPIO_ABORTED: /* request was aborted */
+ sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+ break;
+
+ case FCPIO_DATA_CNT_MISMATCH: /* recv/sent more/less data than exp. */
+ scsi_set_resid(sc, icmnd_cmpl->residual);
+ sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+ break;
+
+ case FCPIO_OUT_OF_RESOURCE: /* out of resources to complete request */
+ sc->result = (DID_REQUEUE << 16) | icmnd_cmpl->scsi_status;
+ break;
+ case FCPIO_INVALID_HEADER: /* header contains invalid data */
+ case FCPIO_INVALID_PARAM: /* some parameter in request invalid */
+ case FCPIO_REQ_NOT_SUPPORTED:/* request type is not supported */
+ case FCPIO_IO_NOT_FOUND: /* requested I/O was not found */
+ case FCPIO_SGL_INVALID: /* request was aborted due to sgl error */
+ case FCPIO_MSS_INVALID: /* request was aborted due to mss error */
+ case FCPIO_FW_ERR: /* request was terminated due fw error */
+ default:
+ shost_printk(KERN_ERR, fnic->lport->host, "hdr status = %s\n",
+ fnic_fcpio_status_to_str(hdr_status));
+ sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status;
+ break;
+ }
+
+ /* Break link with the SCSI command */
+ CMD_SP(sc) = NULL;
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+
+ mempool_free(io_req, fnic->io_req_pool);
+
+ if (sc->sc_data_direction == DMA_FROM_DEVICE) {
+ fnic->lport->host_stats.fcp_input_requests++;
+ fnic->fcp_input_bytes += xfer_len;
+ } else if (sc->sc_data_direction == DMA_TO_DEVICE) {
+ fnic->lport->host_stats.fcp_output_requests++;
+ fnic->fcp_output_bytes += xfer_len;
+ } else
+ fnic->lport->host_stats.fcp_control_requests++;
+
+ /* Call SCSI completion function to complete the IO */
+ if (sc->scsi_done)
+ sc->scsi_done(sc);
+
+}
+
+/* fnic_fcpio_itmf_cmpl_handler
+ * Routine to handle itmf completions
+ */
+static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag tag;
+ u32 id;
+ struct scsi_cmnd *sc;
+ struct fnic_io_req *io_req;
+ unsigned long flags;
+ spinlock_t *io_lock;
+
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
+ fcpio_tag_id_dec(&tag, &id);
+
+ if ((id & FNIC_TAG_MASK) >= FNIC_MAX_IO_REQ)
+ return;
+
+ sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK);
+ WARN_ON_ONCE(!sc);
+ if (!sc)
+ return;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ WARN_ON_ONCE(!io_req);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ return;
+ }
+
+ if (id & FNIC_TAG_ABORT) {
+ /* Completion of abort cmd */
+ if (CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING) {
+ /* This is a late completion. Ignore it */
+ spin_unlock_irqrestore(io_lock, flags);
+ return;
+ }
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
+ CMD_ABTS_STATUS(sc) = hdr_status;
+
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "abts cmpl recd. id %d status %s\n",
+ (int)(id & FNIC_TAG_MASK),
+ fnic_fcpio_status_to_str(hdr_status));
+
+ /*
+ * If scsi_eh thread is blocked waiting for abts to complete,
+ * signal completion to it. IO will be cleaned in the thread
+ * else clean it in this context
+ */
+ if (io_req->abts_done) {
+ complete(io_req->abts_done);
+ spin_unlock_irqrestore(io_lock, flags);
+ } else {
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "abts cmpl, completing IO\n");
+ CMD_SP(sc) = NULL;
+ sc->result = (DID_ERROR << 16);
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+ if (sc->scsi_done)
+ sc->scsi_done(sc);
+ }
+
+ } else if (id & FNIC_TAG_DEV_RST) {
+ /* Completion of device reset */
+ CMD_LR_STATUS(sc) = hdr_status;
+ CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "dev reset cmpl recd. id %d status %s\n",
+ (int)(id & FNIC_TAG_MASK),
+ fnic_fcpio_status_to_str(hdr_status));
+ if (io_req->dr_done)
+ complete(io_req->dr_done);
+ spin_unlock_irqrestore(io_lock, flags);
+
+ } else {
+ shost_printk(KERN_ERR, fnic->lport->host,
+ "Unexpected itmf io state %s tag %x\n",
+ fnic_ioreq_state_to_str(CMD_STATE(sc)), id);
+ spin_unlock_irqrestore(io_lock, flags);
+ }
+
+}
+
+/*
+ * fnic_fcpio_cmpl_handler
+ * Routine to service the cq for wq_copy
+ */
+static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,
+ unsigned int cq_index,
+ struct fcpio_fw_req *desc)
+{
+ struct fnic *fnic = vnic_dev_priv(vdev);
+ int ret = 0;
+
+ switch (desc->hdr.type) {
+ case FCPIO_ACK: /* fw copied copy wq desc to its queue */
+ fnic_fcpio_ack_handler(fnic, cq_index, desc);
+ break;
+
+ case FCPIO_ICMND_CMPL: /* fw completed a command */
+ fnic_fcpio_icmnd_cmpl_handler(fnic, desc);
+ break;
+
+ case FCPIO_ITMF_CMPL: /* fw completed itmf (abort cmd, lun reset)*/
+ fnic_fcpio_itmf_cmpl_handler(fnic, desc);
+ break;
+
+ case FCPIO_FLOGI_REG_CMPL: /* fw completed flogi_reg */
+ ret = fnic_fcpio_flogi_reg_cmpl_handler(fnic, desc);
+ break;
+
+ case FCPIO_RESET_CMPL: /* fw completed reset */
+ ret = fnic_fcpio_fw_reset_cmpl_handler(fnic, desc);
+ break;
+
+ default:
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "firmware completion type %d\n",
+ desc->hdr.type);
+ break;
+ }
+
+ return ret;
+}
+
+/*
+ * fnic_wq_copy_cmpl_handler
+ * Routine to process wq copy
+ */
+int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do)
+{
+ unsigned int wq_work_done = 0;
+ unsigned int i, cq_index;
+ unsigned int cur_work_done;
+
+ for (i = 0; i < fnic->wq_copy_count; i++) {
+ cq_index = i + fnic->raw_wq_count + fnic->rq_count;
+ cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index],
+ fnic_fcpio_cmpl_handler,
+ copy_work_to_do);
+ wq_work_done += cur_work_done;
+ }
+ return wq_work_done;
+}
+
+static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
+{
+ unsigned int i;
+ struct fnic_io_req *io_req;
+ unsigned long flags = 0;
+ struct scsi_cmnd *sc;
+ spinlock_t *io_lock;
+
+ for (i = 0; i < FNIC_MAX_IO_REQ; i++) {
+ if (i == exclude_id)
+ continue;
+
+ sc = scsi_host_find_tag(fnic->lport->host, i);
+ if (!sc)
+ continue;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ goto cleanup_scsi_cmd;
+ }
+
+ CMD_SP(sc) = NULL;
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ /*
+ * If there is a scsi_cmnd associated with this io_req, then
+ * free the corresponding state
+ */
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+
+cleanup_scsi_cmd:
+ sc->result = DID_TRANSPORT_DISRUPTED << 16;
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "fnic_cleanup_io:"
+ " DID_TRANSPORT_DISRUPTED\n");
+
+ /* Complete the command to SCSI */
+ if (sc->scsi_done)
+ sc->scsi_done(sc);
+ }
+}
+
+void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
+ struct fcpio_host_req *desc)
+{
+ u32 id;
+ struct fnic *fnic = vnic_dev_priv(wq->vdev);
+ struct fnic_io_req *io_req;
+ struct scsi_cmnd *sc;
+ unsigned long flags;
+ spinlock_t *io_lock;
+
+ /* get the tag reference */
+ fcpio_tag_id_dec(&desc->hdr.tag, &id);
+ id &= FNIC_TAG_MASK;
+
+ if (id >= FNIC_MAX_IO_REQ)
+ return;
+
+ sc = scsi_host_find_tag(fnic->lport->host, id);
+ if (!sc)
+ return;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+
+ /* Get the IO context which this desc refers to */
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+
+ /* fnic interrupts are turned off by now */
+
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ goto wq_copy_cleanup_scsi_cmd;
+ }
+
+ CMD_SP(sc) = NULL;
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+
+wq_copy_cleanup_scsi_cmd:
+ sc->result = DID_NO_CONNECT << 16;
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:"
+ " DID_NO_CONNECT\n");
+
+ if (sc->scsi_done)
+ sc->scsi_done(sc);
+}
+
+static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
+ u32 task_req, u8 *fc_lun,
+ struct fnic_io_req *io_req)
+{
+ struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
+
+ if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
+ free_wq_copy_descs(fnic, wq);
+
+ if (!vnic_wq_copy_desc_avail(wq)) {
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
+ return 1;
+ }
+ fnic_queue_wq_copy_desc_itmf(wq, tag | FNIC_TAG_ABORT,
+ 0, task_req, tag, fc_lun, io_req->port_id,
+ fnic->config.ra_tov, fnic->config.ed_tov);
+
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
+ return 0;
+}
+
+void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
+{
+ int tag;
+ struct fnic_io_req *io_req;
+ spinlock_t *io_lock;
+ unsigned long flags;
+ struct scsi_cmnd *sc;
+ struct scsi_lun fc_lun;
+ enum fnic_ioreq_state old_ioreq_state;
+
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "fnic_rport_reset_exch called portid 0x%06x\n",
+ port_id);
+
+ if (fnic->in_remove)
+ return;
+
+ for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
+ sc = scsi_host_find_tag(fnic->lport->host, tag);
+ if (!sc)
+ continue;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+
+ if (!io_req || io_req->port_id != port_id) {
+ spin_unlock_irqrestore(io_lock, flags);
+ continue;
+ }
+
+ /*
+ * Found IO that is still pending with firmware and
+ * belongs to rport that went away
+ */
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+ spin_unlock_irqrestore(io_lock, flags);
+ continue;
+ }
+ old_ioreq_state = CMD_STATE(sc);
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
+ CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
+
+ BUG_ON(io_req->abts_done);
+
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "fnic_rport_reset_exch: Issuing abts\n");
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ /* Now queue the abort command to firmware */
+ int_to_scsilun(sc->device->lun, &fc_lun);
+
+ if (fnic_queue_abort_io_req(fnic, tag,
+ FCPIO_ITMF_ABT_TASK_TERM,
+ fc_lun.scsi_lun, io_req)) {
+ /*
+ * Revert the cmd state back to old state, if
+ * it hasnt changed in between. This cmd will get
+ * aborted later by scsi_eh, or cleaned up during
+ * lun reset
+ */
+ io_lock = fnic_io_lock_hash(fnic, sc);
+
+ spin_lock_irqsave(io_lock, flags);
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
+ CMD_STATE(sc) = old_ioreq_state;
+ spin_unlock_irqrestore(io_lock, flags);
+ }
+ }
+
+}
+
+void fnic_terminate_rport_io(struct fc_rport *rport)
+{
+ int tag;
+ struct fnic_io_req *io_req;
+ spinlock_t *io_lock;
+ unsigned long flags;
+ struct scsi_cmnd *sc;
+ struct scsi_lun fc_lun;
+ struct fc_rport_libfc_priv *rdata = rport->dd_data;
+ struct fc_lport *lport = rdata->local_port;
+ struct fnic *fnic = lport_priv(lport);
+ struct fc_rport *cmd_rport;
+ enum fnic_ioreq_state old_ioreq_state;
+
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host, "fnic_terminate_rport_io called"
+ " wwpn 0x%llx, wwnn0x%llx, portid 0x%06x\n",
+ rport->port_name, rport->node_name,
+ rport->port_id);
+
+ if (fnic->in_remove)
+ return;
+
+ for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
+ sc = scsi_host_find_tag(fnic->lport->host, tag);
+ if (!sc)
+ continue;
+
+ cmd_rport = starget_to_rport(scsi_target(sc->device));
+ if (rport != cmd_rport)
+ continue;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+
+ if (!io_req || rport != cmd_rport) {
+ spin_unlock_irqrestore(io_lock, flags);
+ continue;
+ }
+
+ /*
+ * Found IO that is still pending with firmware and
+ * belongs to rport that went away
+ */
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+ spin_unlock_irqrestore(io_lock, flags);
+ continue;
+ }
+ old_ioreq_state = CMD_STATE(sc);
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
+ CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
+
+ BUG_ON(io_req->abts_done);
+
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "fnic_terminate_rport_io: Issuing abts\n");
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ /* Now queue the abort command to firmware */
+ int_to_scsilun(sc->device->lun, &fc_lun);
+
+ if (fnic_queue_abort_io_req(fnic, tag,
+ FCPIO_ITMF_ABT_TASK_TERM,
+ fc_lun.scsi_lun, io_req)) {
+ /*
+ * Revert the cmd state back to old state, if
+ * it hasnt changed in between. This cmd will get
+ * aborted later by scsi_eh, or cleaned up during
+ * lun reset
+ */
+ io_lock = fnic_io_lock_hash(fnic, sc);
+
+ spin_lock_irqsave(io_lock, flags);
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
+ CMD_STATE(sc) = old_ioreq_state;
+ spin_unlock_irqrestore(io_lock, flags);
+ }
+ }
+
+}
+
+static void fnic_block_error_handler(struct scsi_cmnd *sc)
+{
+ struct Scsi_Host *shost = sc->device->host;
+ struct fc_rport *rport = starget_to_rport(scsi_target(sc->device));
+ unsigned long flags;
+
+ spin_lock_irqsave(shost->host_lock, flags);
+ while (rport->port_state == FC_PORTSTATE_BLOCKED) {
+ spin_unlock_irqrestore(shost->host_lock, flags);
+ msleep(1000);
+ spin_lock_irqsave(shost->host_lock, flags);
+ }
+ spin_unlock_irqrestore(shost->host_lock, flags);
+
+}
+
+/*
+ * This function is exported to SCSI for sending abort cmnds.
+ * A SCSI IO is represented by a io_req in the driver.
+ * The ioreq is linked to the SCSI Cmd, thus a link with the ULP's IO.
+ */
+int fnic_abort_cmd(struct scsi_cmnd *sc)
+{
+ struct fc_lport *lp;
+ struct fnic *fnic;
+ struct fnic_io_req *io_req;
+ struct fc_rport *rport;
+ spinlock_t *io_lock;
+ unsigned long flags;
+ int ret = SUCCESS;
+ u32 task_req;
+ struct scsi_lun fc_lun;
+ DECLARE_COMPLETION_ONSTACK(tm_done);
+
+ /* Wait for rport to unblock */
+ fnic_block_error_handler(sc);
+
+ /* Get local-port, check ready and link up */
+ lp = shost_priv(sc->device->host);
+
+ fnic = lport_priv(lp);
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %d\n",
+ (starget_to_rport(scsi_target(sc->device)))->port_id,
+ sc->device->lun, sc->request->tag);
+
+ if (lp->state != LPORT_ST_READY || !(lp->link_up)) {
+ ret = FAILED;
+ goto fnic_abort_cmd_end;
+ }
+
+ /*
+ * Avoid a race between SCSI issuing the abort and the device
+ * completing the command.
+ *
+ * If the command is already completed by the fw cmpl code,
+ * we just return SUCCESS from here. This means that the abort
+ * succeeded. In the SCSI ML, since the timeout for command has
+ * happened, the completion wont actually complete the command
+ * and it will be considered as an aborted command
+ *
+ * The CMD_SP will not be cleared except while holding io_req_lock.
+ */
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ goto fnic_abort_cmd_end;
+ }
+
+ io_req->abts_done = &tm_done;
+
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+ spin_unlock_irqrestore(io_lock, flags);
+ goto wait_pending;
+ }
+ /*
+ * Command is still pending, need to abort it
+ * If the firmware completes the command after this point,
+ * the completion wont be done till mid-layer, since abort
+ * has already started.
+ */
+ CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
+ CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ /*
+ * Check readiness of the remote port. If the path to remote
+ * port is up, then send abts to the remote port to terminate
+ * the IO. Else, just locally terminate the IO in the firmware
+ */
+ rport = starget_to_rport(scsi_target(sc->device));
+ if (fc_remote_port_chkready(rport) == 0)
+ task_req = FCPIO_ITMF_ABT_TASK;
+ else
+ task_req = FCPIO_ITMF_ABT_TASK_TERM;
+
+ /* Now queue the abort command to firmware */
+ int_to_scsilun(sc->device->lun, &fc_lun);
+
+ if (fnic_queue_abort_io_req(fnic, sc->request->tag, task_req,
+ fc_lun.scsi_lun, io_req)) {
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (io_req)
+ io_req->abts_done = NULL;
+ spin_unlock_irqrestore(io_lock, flags);
+ ret = FAILED;
+ goto fnic_abort_cmd_end;
+ }
+
+ /*
+ * We queued an abort IO, wait for its completion.
+ * Once the firmware completes the abort command, it will
+ * wake up this thread.
+ */
+ wait_pending:
+ wait_for_completion_timeout(&tm_done,
+ msecs_to_jiffies
+ (2 * fnic->config.ra_tov +
+ fnic->config.ed_tov));
+
+ /* Check the abort status */
+ spin_lock_irqsave(io_lock, flags);
+
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ ret = FAILED;
+ goto fnic_abort_cmd_end;
+ }
+ io_req->abts_done = NULL;
+
+ /* fw did not complete abort, timed out */
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+ spin_unlock_irqrestore(io_lock, flags);
+ ret = FAILED;
+ goto fnic_abort_cmd_end;
+ }
+
+ /*
+ * firmware completed the abort, check the status,
+ * free the io_req irrespective of failure or success
+ */
+ if (CMD_ABTS_STATUS(sc) != FCPIO_SUCCESS)
+ ret = FAILED;
+
+ CMD_SP(sc) = NULL;
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+
+fnic_abort_cmd_end:
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Returning from abort cmd %s\n",
+ (ret == SUCCESS) ?
+ "SUCCESS" : "FAILED");
+ return ret;
+}
+
+static inline int fnic_queue_dr_io_req(struct fnic *fnic,
+ struct scsi_cmnd *sc,
+ struct fnic_io_req *io_req)
+{
+ struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+ struct scsi_lun fc_lun;
+ int ret = 0;
+ unsigned long intr_flags;
+
+ spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags);
+
+ if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0])
+ free_wq_copy_descs(fnic, wq);
+
+ if (!vnic_wq_copy_desc_avail(wq)) {
+ ret = -EAGAIN;
+ goto lr_io_req_end;
+ }
+
+ /* fill in the lun info */
+ int_to_scsilun(sc->device->lun, &fc_lun);
+
+ fnic_queue_wq_copy_desc_itmf(wq, sc->request->tag | FNIC_TAG_DEV_RST,
+ 0, FCPIO_ITMF_LUN_RESET, SCSI_NO_TAG,
+ fc_lun.scsi_lun, io_req->port_id,
+ fnic->config.ra_tov, fnic->config.ed_tov);
+
+lr_io_req_end:
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags);
+
+ return ret;
+}
+
+/*
+ * Clean up any pending aborts on the lun
+ * For each outstanding IO on this lun, whose abort is not completed by fw,
+ * issue a local abort. Wait for abort to complete. Return 0 if all commands
+ * successfully aborted, 1 otherwise
+ */
+static int fnic_clean_pending_aborts(struct fnic *fnic,
+ struct scsi_cmnd *lr_sc)
+{
+ int tag;
+ struct fnic_io_req *io_req;
+ spinlock_t *io_lock;
+ unsigned long flags;
+ int ret = 0;
+ struct scsi_cmnd *sc;
+ struct fc_rport *rport;
+ struct scsi_lun fc_lun;
+ struct scsi_device *lun_dev = lr_sc->device;
+ DECLARE_COMPLETION_ONSTACK(tm_done);
+
+ for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) {
+ sc = scsi_host_find_tag(fnic->lport->host, tag);
+ /*
+ * ignore this lun reset cmd or cmds that do not belong to
+ * this lun
+ */
+ if (!sc || sc == lr_sc || sc->device != lun_dev)
+ continue;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+
+ if (!io_req || sc->device != lun_dev) {
+ spin_unlock_irqrestore(io_lock, flags);
+ continue;
+ }
+
+ /*
+ * Found IO that is still pending with firmware and
+ * belongs to the LUN that we are resetting
+ */
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Found IO in %s on lun\n",
+ fnic_ioreq_state_to_str(CMD_STATE(sc)));
+
+ BUG_ON(CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING);
+
+ CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
+ io_req->abts_done = &tm_done;
+ spin_unlock_irqrestore(io_lock, flags);
+
+ /* Now queue the abort command to firmware */
+ int_to_scsilun(sc->device->lun, &fc_lun);
+ rport = starget_to_rport(scsi_target(sc->device));
+
+ if (fnic_queue_abort_io_req(fnic, tag,
+ FCPIO_ITMF_ABT_TASK_TERM,
+ fc_lun.scsi_lun, io_req)) {
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (io_req)
+ io_req->abts_done = NULL;
+ spin_unlock_irqrestore(io_lock, flags);
+ ret = 1;
+ goto clean_pending_aborts_end;
+ }
+
+ wait_for_completion_timeout(&tm_done,
+ msecs_to_jiffies
+ (fnic->config.ed_tov));
+
+ /* Recheck cmd state to check if it is now aborted */
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ ret = 1;
+ goto clean_pending_aborts_end;
+ }
+
+ io_req->abts_done = NULL;
+
+ /* if abort is still pending with fw, fail */
+ if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+ spin_unlock_irqrestore(io_lock, flags);
+ ret = 1;
+ goto clean_pending_aborts_end;
+ }
+ CMD_SP(sc) = NULL;
+ spin_unlock_irqrestore(io_lock, flags);
+
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+ }
+
+clean_pending_aborts_end:
+ return ret;
+}
+
+/*
+ * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN
+ * fail to get aborted. It calls driver's eh_device_reset with a SCSI command
+ * on the LUN.
+ */
+int fnic_device_reset(struct scsi_cmnd *sc)
+{
+ struct fc_lport *lp;
+ struct fnic *fnic;
+ struct fnic_io_req *io_req;
+ struct fc_rport *rport;
+ int status;
+ int ret = FAILED;
+ spinlock_t *io_lock;
+ unsigned long flags;
+ DECLARE_COMPLETION_ONSTACK(tm_done);
+
+ /* Wait for rport to unblock */
+ fnic_block_error_handler(sc);
+
+ /* Get local-port, check ready and link up */
+ lp = shost_priv(sc->device->host);
+
+ fnic = lport_priv(lp);
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "Device reset called FCID 0x%x, LUN 0x%x\n",
+ (starget_to_rport(scsi_target(sc->device)))->port_id,
+ sc->device->lun);
+
+
+ if (lp->state != LPORT_ST_READY || !(lp->link_up))
+ goto fnic_device_reset_end;
+
+ /* Check if remote port up */
+ rport = starget_to_rport(scsi_target(sc->device));
+ if (fc_remote_port_chkready(rport))
+ goto fnic_device_reset_end;
+
+ io_lock = fnic_io_lock_hash(fnic, sc);
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+
+ /*
+ * If there is a io_req attached to this command, then use it,
+ * else allocate a new one.
+ */
+ if (!io_req) {
+ io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ goto fnic_device_reset_end;
+ }
+ memset(io_req, 0, sizeof(*io_req));
+ io_req->port_id = rport->port_id;
+ CMD_SP(sc) = (char *)io_req;
+ }
+ io_req->dr_done = &tm_done;
+ CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
+ CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE;
+ spin_unlock_irqrestore(io_lock, flags);
+
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %d\n",
+ sc->request->tag);
+
+ /*
+ * issue the device reset, if enqueue failed, clean up the ioreq
+ * and break assoc with scsi cmd
+ */
+ if (fnic_queue_dr_io_req(fnic, sc, io_req)) {
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (io_req)
+ io_req->dr_done = NULL;
+ goto fnic_device_reset_clean;
+ }
+
+ /*
+ * Wait on the local completion for LUN reset. The io_req may be
+ * freed while we wait since we hold no lock.
+ */
+ wait_for_completion_timeout(&tm_done,
+ msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT));
+
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (!io_req) {
+ spin_unlock_irqrestore(io_lock, flags);
+ goto fnic_device_reset_end;
+ }
+ io_req->dr_done = NULL;
+
+ status = CMD_LR_STATUS(sc);
+ spin_unlock_irqrestore(io_lock, flags);
+
+ /*
+ * If lun reset not completed, bail out with failed. io_req
+ * gets cleaned up during higher levels of EH
+ */
+ if (status == FCPIO_INVALID_CODE) {
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Device reset timed out\n");
+ goto fnic_device_reset_end;
+ }
+
+ /* Completed, but not successful, clean up the io_req, return fail */
+ if (status != FCPIO_SUCCESS) {
+ spin_lock_irqsave(io_lock, flags);
+ FNIC_SCSI_DBG(KERN_DEBUG,
+ fnic->lport->host,
+ "Device reset completed - failed\n");
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ goto fnic_device_reset_clean;
+ }
+
+ /*
+ * Clean up any aborts on this lun that have still not
+ * completed. If any of these fail, then LUN reset fails.
+ * clean_pending_aborts cleans all cmds on this lun except
+ * the lun reset cmd. If all cmds get cleaned, the lun reset
+ * succeeds
+ */
+ if (fnic_clean_pending_aborts(fnic, sc)) {
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Device reset failed"
+ " since could not abort all IOs\n");
+ goto fnic_device_reset_clean;
+ }
+
+ /* Clean lun reset command */
+ spin_lock_irqsave(io_lock, flags);
+ io_req = (struct fnic_io_req *)CMD_SP(sc);
+ if (io_req)
+ /* Completed, and successful */
+ ret = SUCCESS;
+
+fnic_device_reset_clean:
+ if (io_req)
+ CMD_SP(sc) = NULL;
+
+ spin_unlock_irqrestore(io_lock, flags);
+
+ if (io_req) {
+ fnic_release_ioreq_buf(fnic, io_req, sc);
+ mempool_free(io_req, fnic->io_req_pool);
+ }
+
+fnic_device_reset_end:
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Returning from device reset %s\n",
+ (ret == SUCCESS) ?
+ "SUCCESS" : "FAILED");
+ return ret;
+}
+
+/* Clean up all IOs, clean up libFC local port */
+int fnic_reset(struct Scsi_Host *shost)
+{
+ struct fc_lport *lp;
+ struct fnic *fnic;
+ int ret = SUCCESS;
+
+ lp = shost_priv(shost);
+ fnic = lport_priv(lp);
+
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "fnic_reset called\n");
+
+ /*
+ * Reset local port, this will clean up libFC exchanges,
+ * reset remote port sessions, and if link is up, begin flogi
+ */
+ if (lp->tt.lport_reset(lp))
+ ret = FAILED;
+
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "Returning from fnic reset %s\n",
+ (ret == SUCCESS) ?
+ "SUCCESS" : "FAILED");
+
+ return ret;
+}
+
+/*
+ * SCSI Error handling calls driver's eh_host_reset if all prior
+ * error handling levels return FAILED. If host reset completes
+ * successfully, and if link is up, then Fabric login begins.
+ *
+ * Host Reset is the highest level of error recovery. If this fails, then
+ * host is offlined by SCSI.
+ *
+ */
+int fnic_host_reset(struct scsi_cmnd *sc)
+{
+ int ret;
+ unsigned long wait_host_tmo;
+ struct Scsi_Host *shost = sc->device->host;
+ struct fc_lport *lp = shost_priv(shost);
+
+ /*
+ * If fnic_reset is successful, wait for fabric login to complete
+ * scsi-ml tries to send a TUR to every device if host reset is
+ * successful, so before returning to scsi, fabric should be up
+ */
+ ret = fnic_reset(shost);
+ if (ret == SUCCESS) {
+ wait_host_tmo = jiffies + FNIC_HOST_RESET_SETTLE_TIME * HZ;
+ ret = FAILED;
+ while (time_before(jiffies, wait_host_tmo)) {
+ if ((lp->state == LPORT_ST_READY) &&
+ (lp->link_up)) {
+ ret = SUCCESS;
+ break;
+ }
+ ssleep(1);
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * This fxn is called from libFC when host is removed
+ */
+void fnic_scsi_abort_io(struct fc_lport *lp)
+{
+ int err = 0;
+ unsigned long flags;
+ enum fnic_state old_state;
+ struct fnic *fnic = lport_priv(lp);
+ DECLARE_COMPLETION_ONSTACK(remove_wait);
+
+ /* Issue firmware reset for fnic, wait for reset to complete */
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ fnic->remove_wait = &remove_wait;
+ old_state = fnic->state;
+ fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
+ vnic_dev_del_addr(fnic->vdev, fnic->data_src_addr);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ err = fnic_fw_reset_handler(fnic);
+ if (err) {
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)
+ fnic->state = old_state;
+ fnic->remove_wait = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ /* Wait for firmware reset to complete */
+ wait_for_completion_timeout(&remove_wait,
+ msecs_to_jiffies(FNIC_RMDEVICE_TIMEOUT));
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ fnic->remove_wait = NULL;
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+ "fnic_scsi_abort_io %s\n",
+ (fnic->state == FNIC_IN_ETH_MODE) ?
+ "SUCCESS" : "FAILED");
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+}
+
+/*
+ * This fxn called from libFC to clean up driver IO state on link down
+ */
+void fnic_scsi_cleanup(struct fc_lport *lp)
+{
+ unsigned long flags;
+ enum fnic_state old_state;
+ struct fnic *fnic = lport_priv(lp);
+
+ /* issue fw reset */
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ old_state = fnic->state;
+ fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
+ vnic_dev_del_addr(fnic->vdev, fnic->data_src_addr);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (fnic_fw_reset_handler(fnic)) {
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)
+ fnic->state = old_state;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ }
+
+}
+
+void fnic_empty_scsi_cleanup(struct fc_lport *lp)
+{
+}
+
+void fnic_exch_mgr_reset(struct fc_lport *lp, u32 sid, u32 did)
+{
+ struct fnic *fnic = lport_priv(lp);
+
+ /* Non-zero sid, nothing to do */
+ if (sid)
+ goto call_fc_exch_mgr_reset;
+
+ if (did) {
+ fnic_rport_exch_reset(fnic, did);
+ goto call_fc_exch_mgr_reset;
+ }
+
+ /*
+ * sid = 0, did = 0
+ * link down or device being removed
+ */
+ if (!fnic->in_remove)
+ fnic_scsi_cleanup(lp);
+ else
+ fnic_scsi_abort_io(lp);
+
+ /* call libFC exch mgr reset to reset its exchanges */
+call_fc_exch_mgr_reset:
+ fc_exch_mgr_reset(lp, sid, did);
+
+}
diff --git a/drivers/scsi/fnic/rq_enet_desc.h b/drivers/scsi/fnic/rq_enet_desc.h
new file mode 100644
index 000000000000..92e80ae6b725
--- /dev/null
+++ b/drivers/scsi/fnic/rq_enet_desc.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _RQ_ENET_DESC_H_
+#define _RQ_ENET_DESC_H_
+
+/* Ethernet receive queue descriptor: 16B */
+struct rq_enet_desc {
+ __le64 address;
+ __le16 length_type;
+ u8 reserved[6];
+};
+
+enum rq_enet_type_types {
+ RQ_ENET_TYPE_ONLY_SOP = 0,
+ RQ_ENET_TYPE_NOT_SOP = 1,
+ RQ_ENET_TYPE_RESV2 = 2,
+ RQ_ENET_TYPE_RESV3 = 3,
+};
+
+#define RQ_ENET_ADDR_BITS 64
+#define RQ_ENET_LEN_BITS 14
+#define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1)
+#define RQ_ENET_TYPE_BITS 2
+#define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1)
+
+static inline void rq_enet_desc_enc(struct rq_enet_desc *desc,
+ u64 address, u8 type, u16 length)
+{
+ desc->address = cpu_to_le64(address);
+ desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) |
+ ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
+}
+
+static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
+ u64 *address, u8 *type, u16 *length)
+{
+ *address = le64_to_cpu(desc->address);
+ *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK;
+ *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) &
+ RQ_ENET_TYPE_MASK);
+}
+
+#endif /* _RQ_ENET_DESC_H_ */
diff --git a/drivers/scsi/fnic/vnic_cq.c b/drivers/scsi/fnic/vnic_cq.c
new file mode 100644
index 000000000000..c5db32eda5ef
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_cq.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include "vnic_dev.h"
+#include "vnic_cq.h"
+
+void vnic_cq_free(struct vnic_cq *cq)
+{
+ vnic_dev_free_desc_ring(cq->vdev, &cq->ring);
+
+ cq->ctrl = NULL;
+}
+
+int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index,
+ unsigned int desc_count, unsigned int desc_size)
+{
+ int err;
+
+ cq->index = index;
+ cq->vdev = vdev;
+
+ cq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_CQ, index);
+ if (!cq->ctrl) {
+ printk(KERN_ERR "Failed to hook CQ[%d] resource\n", index);
+ return -EINVAL;
+ }
+
+ err = vnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, desc_size);
+ if (err)
+ return err;
+
+ return 0;
+}
+
+void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable,
+ unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail,
+ unsigned int cq_tail_color, unsigned int interrupt_enable,
+ unsigned int cq_entry_enable, unsigned int cq_message_enable,
+ unsigned int interrupt_offset, u64 cq_message_addr)
+{
+ u64 paddr;
+
+ paddr = (u64)cq->ring.base_addr | VNIC_PADDR_TARGET;
+ writeq(paddr, &cq->ctrl->ring_base);
+ iowrite32(cq->ring.desc_count, &cq->ctrl->ring_size);
+ iowrite32(flow_control_enable, &cq->ctrl->flow_control_enable);
+ iowrite32(color_enable, &cq->ctrl->color_enable);
+ iowrite32(cq_head, &cq->ctrl->cq_head);
+ iowrite32(cq_tail, &cq->ctrl->cq_tail);
+ iowrite32(cq_tail_color, &cq->ctrl->cq_tail_color);
+ iowrite32(interrupt_enable, &cq->ctrl->interrupt_enable);
+ iowrite32(cq_entry_enable, &cq->ctrl->cq_entry_enable);
+ iowrite32(cq_message_enable, &cq->ctrl->cq_message_enable);
+ iowrite32(interrupt_offset, &cq->ctrl->interrupt_offset);
+ writeq(cq_message_addr, &cq->ctrl->cq_message_addr);
+}
+
+void vnic_cq_clean(struct vnic_cq *cq)
+{
+ cq->to_clean = 0;
+ cq->last_color = 0;
+
+ iowrite32(0, &cq->ctrl->cq_head);
+ iowrite32(0, &cq->ctrl->cq_tail);
+ iowrite32(1, &cq->ctrl->cq_tail_color);
+
+ vnic_dev_clear_desc_ring(&cq->ring);
+}
diff --git a/drivers/scsi/fnic/vnic_cq.h b/drivers/scsi/fnic/vnic_cq.h
new file mode 100644
index 000000000000..4ede6809fb1e
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_cq.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_CQ_H_
+#define _VNIC_CQ_H_
+
+#include "cq_desc.h"
+#include "vnic_dev.h"
+
+/*
+ * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
+ * Driver) when both are built with CONFIG options =y
+ */
+#define vnic_cq_service fnic_cq_service
+#define vnic_cq_free fnic_cq_free
+#define vnic_cq_alloc fnic_cq_alloc
+#define vnic_cq_init fnic_cq_init
+#define vnic_cq_clean fnic_cq_clean
+
+/* Completion queue control */
+struct vnic_cq_ctrl {
+ u64 ring_base; /* 0x00 */
+ u32 ring_size; /* 0x08 */
+ u32 pad0;
+ u32 flow_control_enable; /* 0x10 */
+ u32 pad1;
+ u32 color_enable; /* 0x18 */
+ u32 pad2;
+ u32 cq_head; /* 0x20 */
+ u32 pad3;
+ u32 cq_tail; /* 0x28 */
+ u32 pad4;
+ u32 cq_tail_color; /* 0x30 */
+ u32 pad5;
+ u32 interrupt_enable; /* 0x38 */
+ u32 pad6;
+ u32 cq_entry_enable; /* 0x40 */
+ u32 pad7;
+ u32 cq_message_enable; /* 0x48 */
+ u32 pad8;
+ u32 interrupt_offset; /* 0x50 */
+ u32 pad9;
+ u64 cq_message_addr; /* 0x58 */
+ u32 pad10;
+};
+
+struct vnic_cq {
+ unsigned int index;
+ struct vnic_dev *vdev;
+ struct vnic_cq_ctrl __iomem *ctrl; /* memory-mapped */
+ struct vnic_dev_ring ring;
+ unsigned int to_clean;
+ unsigned int last_color;
+};
+
+static inline unsigned int vnic_cq_service(struct vnic_cq *cq,
+ unsigned int work_to_do,
+ int (*q_service)(struct vnic_dev *vdev, struct cq_desc *cq_desc,
+ u8 type, u16 q_number, u16 completed_index, void *opaque),
+ void *opaque)
+{
+ struct cq_desc *cq_desc;
+ unsigned int work_done = 0;
+ u16 q_number, completed_index;
+ u8 type, color;
+
+ cq_desc = (struct cq_desc *)((u8 *)cq->ring.descs +
+ cq->ring.desc_size * cq->to_clean);
+ cq_desc_dec(cq_desc, &type, &color,
+ &q_number, &completed_index);
+
+ while (color != cq->last_color) {
+
+ if ((*q_service)(cq->vdev, cq_desc, type,
+ q_number, completed_index, opaque))
+ break;
+
+ cq->to_clean++;
+ if (cq->to_clean == cq->ring.desc_count) {
+ cq->to_clean = 0;
+ cq->last_color = cq->last_color ? 0 : 1;
+ }
+
+ cq_desc = (struct cq_desc *)((u8 *)cq->ring.descs +
+ cq->ring.desc_size * cq->to_clean);
+ cq_desc_dec(cq_desc, &type, &color,
+ &q_number, &completed_index);
+
+ work_done++;
+ if (work_done >= work_to_do)
+ break;
+ }
+
+ return work_done;
+}
+
+void vnic_cq_free(struct vnic_cq *cq);
+int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index,
+ unsigned int desc_count, unsigned int desc_size);
+void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable,
+ unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail,
+ unsigned int cq_tail_color, unsigned int interrupt_enable,
+ unsigned int cq_entry_enable, unsigned int message_enable,
+ unsigned int interrupt_offset, u64 message_addr);
+void vnic_cq_clean(struct vnic_cq *cq);
+
+#endif /* _VNIC_CQ_H_ */
diff --git a/drivers/scsi/fnic/vnic_cq_copy.h b/drivers/scsi/fnic/vnic_cq_copy.h
new file mode 100644
index 000000000000..7901ce255a81
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_cq_copy.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_CQ_COPY_H_
+#define _VNIC_CQ_COPY_H_
+
+#include "fcpio.h"
+
+static inline unsigned int vnic_cq_copy_service(
+ struct vnic_cq *cq,
+ int (*q_service)(struct vnic_dev *vdev,
+ unsigned int index,
+ struct fcpio_fw_req *desc),
+ unsigned int work_to_do)
+
+{
+ struct fcpio_fw_req *desc;
+ unsigned int work_done = 0;
+ u8 color;
+
+ desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
+ cq->ring.desc_size * cq->to_clean);
+ fcpio_color_dec(desc, &color);
+
+ while (color != cq->last_color) {
+
+ if ((*q_service)(cq->vdev, cq->index, desc))
+ break;
+
+ cq->to_clean++;
+ if (cq->to_clean == cq->ring.desc_count) {
+ cq->to_clean = 0;
+ cq->last_color = cq->last_color ? 0 : 1;
+ }
+
+ desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
+ cq->ring.desc_size * cq->to_clean);
+ fcpio_color_dec(desc, &color);
+
+ work_done++;
+ if (work_done >= work_to_do)
+ break;
+ }
+
+ return work_done;
+}
+
+#endif /* _VNIC_CQ_COPY_H_ */
diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
new file mode 100644
index 000000000000..566770645086
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -0,0 +1,690 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/if_ether.h>
+#include "vnic_resource.h"
+#include "vnic_devcmd.h"
+#include "vnic_dev.h"
+#include "vnic_stats.h"
+
+struct vnic_res {
+ void __iomem *vaddr;
+ unsigned int count;
+};
+
+struct vnic_dev {
+ void *priv;
+ struct pci_dev *pdev;
+ struct vnic_res res[RES_TYPE_MAX];
+ enum vnic_dev_intr_mode intr_mode;
+ struct vnic_devcmd __iomem *devcmd;
+ struct vnic_devcmd_notify *notify;
+ struct vnic_devcmd_notify notify_copy;
+ dma_addr_t notify_pa;
+ u32 *linkstatus;
+ dma_addr_t linkstatus_pa;
+ struct vnic_stats *stats;
+ dma_addr_t stats_pa;
+ struct vnic_devcmd_fw_info *fw_info;
+ dma_addr_t fw_info_pa;
+};
+
+#define VNIC_MAX_RES_HDR_SIZE \
+ (sizeof(struct vnic_resource_header) + \
+ sizeof(struct vnic_resource) * RES_TYPE_MAX)
+#define VNIC_RES_STRIDE 128
+
+void *vnic_dev_priv(struct vnic_dev *vdev)
+{
+ return vdev->priv;
+}
+
+static int vnic_dev_discover_res(struct vnic_dev *vdev,
+ struct vnic_dev_bar *bar)
+{
+ struct vnic_resource_header __iomem *rh;
+ struct vnic_resource __iomem *r;
+ u8 type;
+
+ if (bar->len < VNIC_MAX_RES_HDR_SIZE) {
+ printk(KERN_ERR "vNIC BAR0 res hdr length error\n");
+ return -EINVAL;
+ }
+
+ rh = bar->vaddr;
+ if (!rh) {
+ printk(KERN_ERR "vNIC BAR0 res hdr not mem-mapped\n");
+ return -EINVAL;
+ }
+
+ if (ioread32(&rh->magic) != VNIC_RES_MAGIC ||
+ ioread32(&rh->version) != VNIC_RES_VERSION) {
+ printk(KERN_ERR "vNIC BAR0 res magic/version error "
+ "exp (%lx/%lx) curr (%x/%x)\n",
+ VNIC_RES_MAGIC, VNIC_RES_VERSION,
+ ioread32(&rh->magic), ioread32(&rh->version));
+ return -EINVAL;
+ }
+
+ r = (struct vnic_resource __iomem *)(rh + 1);
+
+ while ((type = ioread8(&r->type)) != RES_TYPE_EOL) {
+
+ u8 bar_num = ioread8(&r->bar);
+ u32 bar_offset = ioread32(&r->bar_offset);
+ u32 count = ioread32(&r->count);
+ u32 len;
+
+ r++;
+
+ if (bar_num != 0) /* only mapping in BAR0 resources */
+ continue;
+
+ switch (type) {
+ case RES_TYPE_WQ:
+ case RES_TYPE_RQ:
+ case RES_TYPE_CQ:
+ case RES_TYPE_INTR_CTRL:
+ /* each count is stride bytes long */
+ len = count * VNIC_RES_STRIDE;
+ if (len + bar_offset > bar->len) {
+ printk(KERN_ERR "vNIC BAR0 resource %d "
+ "out-of-bounds, offset 0x%x + "
+ "size 0x%x > bar len 0x%lx\n",
+ type, bar_offset,
+ len,
+ bar->len);
+ return -EINVAL;
+ }
+ break;
+ case RES_TYPE_INTR_PBA_LEGACY:
+ case RES_TYPE_DEVCMD:
+ len = count;
+ break;
+ default:
+ continue;
+ }
+
+ vdev->res[type].count = count;
+ vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset;
+ }
+
+ return 0;
+}
+
+unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
+ enum vnic_res_type type)
+{
+ return vdev->res[type].count;
+}
+
+void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
+ unsigned int index)
+{
+ if (!vdev->res[type].vaddr)
+ return NULL;
+
+ switch (type) {
+ case RES_TYPE_WQ:
+ case RES_TYPE_RQ:
+ case RES_TYPE_CQ:
+ case RES_TYPE_INTR_CTRL:
+ return (char __iomem *)vdev->res[type].vaddr +
+ index * VNIC_RES_STRIDE;
+ default:
+ return (char __iomem *)vdev->res[type].vaddr;
+ }
+}
+
+unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
+ unsigned int desc_count,
+ unsigned int desc_size)
+{
+ /* The base address of the desc rings must be 512 byte aligned.
+ * Descriptor count is aligned to groups of 32 descriptors. A
+ * count of 0 means the maximum 4096 descriptors. Descriptor
+ * size is aligned to 16 bytes.
+ */
+
+ unsigned int count_align = 32;
+ unsigned int desc_align = 16;
+
+ ring->base_align = 512;
+
+ if (desc_count == 0)
+ desc_count = 4096;
+
+ ring->desc_count = ALIGN(desc_count, count_align);
+
+ ring->desc_size = ALIGN(desc_size, desc_align);
+
+ ring->size = ring->desc_count * ring->desc_size;
+ ring->size_unaligned = ring->size + ring->base_align;
+
+ return ring->size_unaligned;
+}
+
+void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring)
+{
+ memset(ring->descs, 0, ring->size);
+}
+
+int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
+ unsigned int desc_count, unsigned int desc_size)
+{
+ vnic_dev_desc_ring_size(ring, desc_count, desc_size);
+
+ ring->descs_unaligned = pci_alloc_consistent(vdev->pdev,
+ ring->size_unaligned,
+ &ring->base_addr_unaligned);
+
+ if (!ring->descs_unaligned) {
+ printk(KERN_ERR
+ "Failed to allocate ring (size=%d), aborting\n",
+ (int)ring->size);
+ return -ENOMEM;
+ }
+
+ ring->base_addr = ALIGN(ring->base_addr_unaligned,
+ ring->base_align);
+ ring->descs = (u8 *)ring->descs_unaligned +
+ (ring->base_addr - ring->base_addr_unaligned);
+
+ vnic_dev_clear_desc_ring(ring);
+
+ ring->desc_avail = ring->desc_count - 1;
+
+ return 0;
+}
+
+void vnic_dev_free_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring)
+{
+ if (ring->descs) {
+ pci_free_consistent(vdev->pdev,
+ ring->size_unaligned,
+ ring->descs_unaligned,
+ ring->base_addr_unaligned);
+ ring->descs = NULL;
+ }
+}
+
+int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
+ u64 *a0, u64 *a1, int wait)
+{
+ struct vnic_devcmd __iomem *devcmd = vdev->devcmd;
+ int delay;
+ u32 status;
+ int dev_cmd_err[] = {
+ /* convert from fw's version of error.h to host's version */
+ 0, /* ERR_SUCCESS */
+ EINVAL, /* ERR_EINVAL */
+ EFAULT, /* ERR_EFAULT */
+ EPERM, /* ERR_EPERM */
+ EBUSY, /* ERR_EBUSY */
+ };
+ int err;
+
+ status = ioread32(&devcmd->status);
+ if (status & STAT_BUSY) {
+ printk(KERN_ERR "Busy devcmd %d\n", _CMD_N(cmd));
+ return -EBUSY;
+ }
+
+ if (_CMD_DIR(cmd) & _CMD_DIR_WRITE) {
+ writeq(*a0, &devcmd->args[0]);
+ writeq(*a1, &devcmd->args[1]);
+ wmb();
+ }
+
+ iowrite32(cmd, &devcmd->cmd);
+
+ if ((_CMD_FLAGS(cmd) & _CMD_FLAGS_NOWAIT))
+ return 0;
+
+ for (delay = 0; delay < wait; delay++) {
+
+ udelay(100);
+
+ status = ioread32(&devcmd->status);
+ if (!(status & STAT_BUSY)) {
+
+ if (status & STAT_ERROR) {
+ err = dev_cmd_err[(int)readq(&devcmd->args[0])];
+ printk(KERN_ERR "Error %d devcmd %d\n",
+ err, _CMD_N(cmd));
+ return -err;
+ }
+
+ if (_CMD_DIR(cmd) & _CMD_DIR_READ) {
+ rmb();
+ *a0 = readq(&devcmd->args[0]);
+ *a1 = readq(&devcmd->args[1]);
+ }
+
+ return 0;
+ }
+ }
+
+ printk(KERN_ERR "Timedout devcmd %d\n", _CMD_N(cmd));
+ return -ETIMEDOUT;
+}
+
+int vnic_dev_fw_info(struct vnic_dev *vdev,
+ struct vnic_devcmd_fw_info **fw_info)
+{
+ u64 a0, a1 = 0;
+ int wait = 1000;
+ int err = 0;
+
+ if (!vdev->fw_info) {
+ vdev->fw_info = pci_alloc_consistent(vdev->pdev,
+ sizeof(struct vnic_devcmd_fw_info),
+ &vdev->fw_info_pa);
+ if (!vdev->fw_info)
+ return -ENOMEM;
+
+ a0 = vdev->fw_info_pa;
+
+ /* only get fw_info once and cache it */
+ err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait);
+ }
+
+ *fw_info = vdev->fw_info;
+
+ return err;
+}
+
+int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
+ void *value)
+{
+ u64 a0, a1;
+ int wait = 1000;
+ int err;
+
+ a0 = offset;
+ a1 = size;
+
+ err = vnic_dev_cmd(vdev, CMD_DEV_SPEC, &a0, &a1, wait);
+
+ switch (size) {
+ case 1:
+ *(u8 *)value = (u8)a0;
+ break;
+ case 2:
+ *(u16 *)value = (u16)a0;
+ break;
+ case 4:
+ *(u32 *)value = (u32)a0;
+ break;
+ case 8:
+ *(u64 *)value = a0;
+ break;
+ default:
+ BUG();
+ break;
+ }
+
+ return err;
+}
+
+int vnic_dev_stats_clear(struct vnic_dev *vdev)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_STATS_CLEAR, &a0, &a1, wait);
+}
+
+int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats)
+{
+ u64 a0, a1;
+ int wait = 1000;
+
+ if (!vdev->stats) {
+ vdev->stats = pci_alloc_consistent(vdev->pdev,
+ sizeof(struct vnic_stats), &vdev->stats_pa);
+ if (!vdev->stats)
+ return -ENOMEM;
+ }
+
+ *stats = vdev->stats;
+ a0 = vdev->stats_pa;
+ a1 = sizeof(struct vnic_stats);
+
+ return vnic_dev_cmd(vdev, CMD_STATS_DUMP, &a0, &a1, wait);
+}
+
+int vnic_dev_close(struct vnic_dev *vdev)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_CLOSE, &a0, &a1, wait);
+}
+
+int vnic_dev_enable(struct vnic_dev *vdev)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait);
+}
+
+int vnic_dev_disable(struct vnic_dev *vdev)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_DISABLE, &a0, &a1, wait);
+}
+
+int vnic_dev_open(struct vnic_dev *vdev, int arg)
+{
+ u64 a0 = (u32)arg, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_OPEN, &a0, &a1, wait);
+}
+
+int vnic_dev_open_done(struct vnic_dev *vdev, int *done)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ int err;
+
+ *done = 0;
+
+ err = vnic_dev_cmd(vdev, CMD_OPEN_STATUS, &a0, &a1, wait);
+ if (err)
+ return err;
+
+ *done = (a0 == 0);
+
+ return 0;
+}
+
+int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg)
+{
+ u64 a0 = (u32)arg, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_SOFT_RESET, &a0, &a1, wait);
+}
+
+int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ int err;
+
+ *done = 0;
+
+ err = vnic_dev_cmd(vdev, CMD_SOFT_RESET_STATUS, &a0, &a1, wait);
+ if (err)
+ return err;
+
+ *done = (a0 == 0);
+
+ return 0;
+}
+
+int vnic_dev_hang_notify(struct vnic_dev *vdev)
+{
+ u64 a0, a1;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait);
+}
+
+int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
+{
+ u64 a0, a1;
+ int wait = 1000;
+ int err, i;
+
+ for (i = 0; i < ETH_ALEN; i++)
+ mac_addr[i] = 0;
+
+ err = vnic_dev_cmd(vdev, CMD_MAC_ADDR, &a0, &a1, wait);
+ if (err)
+ return err;
+
+ for (i = 0; i < ETH_ALEN; i++)
+ mac_addr[i] = ((u8 *)&a0)[i];
+
+ return 0;
+}
+
+void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
+ int broadcast, int promisc, int allmulti)
+{
+ u64 a0, a1 = 0;
+ int wait = 1000;
+ int err;
+
+ a0 = (directed ? CMD_PFILTER_DIRECTED : 0) |
+ (multicast ? CMD_PFILTER_MULTICAST : 0) |
+ (broadcast ? CMD_PFILTER_BROADCAST : 0) |
+ (promisc ? CMD_PFILTER_PROMISCUOUS : 0) |
+ (allmulti ? CMD_PFILTER_ALL_MULTICAST : 0);
+
+ err = vnic_dev_cmd(vdev, CMD_PACKET_FILTER, &a0, &a1, wait);
+ if (err)
+ printk(KERN_ERR "Can't set packet filter\n");
+}
+
+void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ int err;
+ int i;
+
+ for (i = 0; i < ETH_ALEN; i++)
+ ((u8 *)&a0)[i] = addr[i];
+
+ err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait);
+ if (err)
+ printk(KERN_ERR
+ "Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
+ err);
+}
+
+void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
+{
+ u64 a0 = 0, a1 = 0;
+ int wait = 1000;
+ int err;
+ int i;
+
+ for (i = 0; i < ETH_ALEN; i++)
+ ((u8 *)&a0)[i] = addr[i];
+
+ err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a0, &a1, wait);
+ if (err)
+ printk(KERN_ERR
+ "Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
+ err);
+}
+
+int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
+{
+ u64 a0, a1;
+ int wait = 1000;
+
+ if (!vdev->notify) {
+ vdev->notify = pci_alloc_consistent(vdev->pdev,
+ sizeof(struct vnic_devcmd_notify),
+ &vdev->notify_pa);
+ if (!vdev->notify)
+ return -ENOMEM;
+ }
+
+ a0 = vdev->notify_pa;
+ a1 = ((u64)intr << 32) & 0x0000ffff00000000ULL;
+ a1 += sizeof(struct vnic_devcmd_notify);
+
+ return vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait);
+}
+
+void vnic_dev_notify_unset(struct vnic_dev *vdev)
+{
+ u64 a0, a1;
+ int wait = 1000;
+
+ a0 = 0; /* paddr = 0 to unset notify buffer */
+ a1 = 0x0000ffff00000000ULL; /* intr num = -1 to unreg for intr */
+ a1 += sizeof(struct vnic_devcmd_notify);
+
+ vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait);
+}
+
+static int vnic_dev_notify_ready(struct vnic_dev *vdev)
+{
+ u32 *words;
+ unsigned int nwords = sizeof(struct vnic_devcmd_notify) / 4;
+ unsigned int i;
+ u32 csum;
+
+ if (!vdev->notify)
+ return 0;
+
+ do {
+ csum = 0;
+ memcpy(&vdev->notify_copy, vdev->notify,
+ sizeof(struct vnic_devcmd_notify));
+ words = (u32 *)&vdev->notify_copy;
+ for (i = 1; i < nwords; i++)
+ csum += words[i];
+ } while (csum != words[0]);
+
+ return 1;
+}
+
+int vnic_dev_init(struct vnic_dev *vdev, int arg)
+{
+ u64 a0 = (u32)arg, a1 = 0;
+ int wait = 1000;
+ return vnic_dev_cmd(vdev, CMD_INIT, &a0, &a1, wait);
+}
+
+int vnic_dev_link_status(struct vnic_dev *vdev)
+{
+ if (vdev->linkstatus)
+ return *vdev->linkstatus;
+
+ if (!vnic_dev_notify_ready(vdev))
+ return 0;
+
+ return vdev->notify_copy.link_state;
+}
+
+u32 vnic_dev_port_speed(struct vnic_dev *vdev)
+{
+ if (!vnic_dev_notify_ready(vdev))
+ return 0;
+
+ return vdev->notify_copy.port_speed;
+}
+
+u32 vnic_dev_msg_lvl(struct vnic_dev *vdev)
+{
+ if (!vnic_dev_notify_ready(vdev))
+ return 0;
+
+ return vdev->notify_copy.msglvl;
+}
+
+u32 vnic_dev_mtu(struct vnic_dev *vdev)
+{
+ if (!vnic_dev_notify_ready(vdev))
+ return 0;
+
+ return vdev->notify_copy.mtu;
+}
+
+u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev)
+{
+ if (!vnic_dev_notify_ready(vdev))
+ return 0;
+
+ return vdev->notify_copy.link_down_cnt;
+}
+
+void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
+ enum vnic_dev_intr_mode intr_mode)
+{
+ vdev->intr_mode = intr_mode;
+}
+
+enum vnic_dev_intr_mode vnic_dev_get_intr_mode(
+ struct vnic_dev *vdev)
+{
+ return vdev->intr_mode;
+}
+
+void vnic_dev_unregister(struct vnic_dev *vdev)
+{
+ if (vdev) {
+ if (vdev->notify)
+ pci_free_consistent(vdev->pdev,
+ sizeof(struct vnic_devcmd_notify),
+ vdev->notify,
+ vdev->notify_pa);
+ if (vdev->linkstatus)
+ pci_free_consistent(vdev->pdev,
+ sizeof(u32),
+ vdev->linkstatus,
+ vdev->linkstatus_pa);
+ if (vdev->stats)
+ pci_free_consistent(vdev->pdev,
+ sizeof(struct vnic_dev),
+ vdev->stats, vdev->stats_pa);
+ if (vdev->fw_info)
+ pci_free_consistent(vdev->pdev,
+ sizeof(struct vnic_devcmd_fw_info),
+ vdev->fw_info, vdev->fw_info_pa);
+ kfree(vdev);
+ }
+}
+
+struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
+ void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar)
+{
+ if (!vdev) {
+ vdev = kzalloc(sizeof(struct vnic_dev), GFP_KERNEL);
+ if (!vdev)
+ return NULL;
+ }
+
+ vdev->priv = priv;
+ vdev->pdev = pdev;
+
+ if (vnic_dev_discover_res(vdev, bar))
+ goto err_out;
+
+ vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0);
+ if (!vdev->devcmd)
+ goto err_out;
+
+ return vdev;
+
+err_out:
+ vnic_dev_unregister(vdev);
+ return NULL;
+}
diff --git a/drivers/scsi/fnic/vnic_dev.h b/drivers/scsi/fnic/vnic_dev.h
new file mode 100644
index 000000000000..f9935a8a5a09
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_dev.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_DEV_H_
+#define _VNIC_DEV_H_
+
+#include "vnic_resource.h"
+#include "vnic_devcmd.h"
+
+/*
+ * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
+ * Driver) when both are built with CONFIG options =y
+ */
+#define vnic_dev_priv fnic_dev_priv
+#define vnic_dev_get_res_count fnic_dev_get_res_count
+#define vnic_dev_get_res fnic_dev_get_res
+#define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz
+#define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring
+#define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring
+#define vnic_dev_free_desc_ring fnic_dev_free_desc_ring
+#define vnic_dev_cmd fnic_dev_cmd
+#define vnic_dev_fw_info fnic_dev_fw_info
+#define vnic_dev_spec fnic_dev_spec
+#define vnic_dev_stats_clear fnic_dev_stats_clear
+#define vnic_dev_stats_dump fnic_dev_stats_dump
+#define vnic_dev_hang_notify fnic_dev_hang_notify
+#define vnic_dev_packet_filter fnic_dev_packet_filter
+#define vnic_dev_add_addr fnic_dev_add_addr
+#define vnic_dev_del_addr fnic_dev_del_addr
+#define vnic_dev_mac_addr fnic_dev_mac_addr
+#define vnic_dev_notify_set fnic_dev_notify_set
+#define vnic_dev_notify_unset fnic_dev_notify_unset
+#define vnic_dev_link_status fnic_dev_link_status
+#define vnic_dev_port_speed fnic_dev_port_speed
+#define vnic_dev_msg_lvl fnic_dev_msg_lvl
+#define vnic_dev_mtu fnic_dev_mtu
+#define vnic_dev_link_down_cnt fnic_dev_link_down_cnt
+#define vnic_dev_close fnic_dev_close
+#define vnic_dev_enable fnic_dev_enable
+#define vnic_dev_disable fnic_dev_disable
+#define vnic_dev_open fnic_dev_open
+#define vnic_dev_open_done fnic_dev_open_done
+#define vnic_dev_init fnic_dev_init
+#define vnic_dev_soft_reset fnic_dev_soft_reset
+#define vnic_dev_soft_reset_done fnic_dev_soft_reset_done
+#define vnic_dev_set_intr_mode fnic_dev_set_intr_mode
+#define vnic_dev_get_intr_mode fnic_dev_get_intr_mode
+#define vnic_dev_unregister fnic_dev_unregister
+#define vnic_dev_register fnic_dev_register
+
+#ifndef VNIC_PADDR_TARGET
+#define VNIC_PADDR_TARGET 0x0000000000000000ULL
+#endif
+
+#ifndef readq
+static inline u64 readq(void __iomem *reg)
+{
+ return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg);
+}
+
+static inline void writeq(u64 val, void __iomem *reg)
+{
+ writel(val & 0xffffffff, reg);
+ writel(val >> 32, reg + 0x4UL);
+}
+#endif
+
+enum vnic_dev_intr_mode {
+ VNIC_DEV_INTR_MODE_UNKNOWN,
+ VNIC_DEV_INTR_MODE_INTX,
+ VNIC_DEV_INTR_MODE_MSI,
+ VNIC_DEV_INTR_MODE_MSIX,
+};
+
+struct vnic_dev_bar {
+ void __iomem *vaddr;
+ dma_addr_t bus_addr;
+ unsigned long len;
+};
+
+struct vnic_dev_ring {
+ void *descs;
+ size_t size;
+ dma_addr_t base_addr;
+ size_t base_align;
+ void *descs_unaligned;
+ size_t size_unaligned;
+ dma_addr_t base_addr_unaligned;
+ unsigned int desc_size;
+ unsigned int desc_count;
+ unsigned int desc_avail;
+};
+
+struct vnic_dev;
+struct vnic_stats;
+
+void *vnic_dev_priv(struct vnic_dev *vdev);
+unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
+ enum vnic_res_type type);
+void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
+ unsigned int index);
+unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
+ unsigned int desc_count,
+ unsigned int desc_size);
+void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
+int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
+ unsigned int desc_count, unsigned int desc_size);
+void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
+ struct vnic_dev_ring *ring);
+int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
+ u64 *a0, u64 *a1, int wait);
+int vnic_dev_fw_info(struct vnic_dev *vdev,
+ struct vnic_devcmd_fw_info **fw_info);
+int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset,
+ unsigned int size, void *value);
+int vnic_dev_stats_clear(struct vnic_dev *vdev);
+int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
+int vnic_dev_hang_notify(struct vnic_dev *vdev);
+void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
+ int broadcast, int promisc, int allmulti);
+void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
+void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
+int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
+int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
+void vnic_dev_notify_unset(struct vnic_dev *vdev);
+int vnic_dev_link_status(struct vnic_dev *vdev);
+u32 vnic_dev_port_speed(struct vnic_dev *vdev);
+u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
+u32 vnic_dev_mtu(struct vnic_dev *vdev);
+u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
+int vnic_dev_close(struct vnic_dev *vdev);
+int vnic_dev_enable(struct vnic_dev *vdev);
+int vnic_dev_disable(struct vnic_dev *vdev);
+int vnic_dev_open(struct vnic_dev *vdev, int arg);
+int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
+int vnic_dev_init(struct vnic_dev *vdev, int arg);
+int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
+int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
+void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
+ enum vnic_dev_intr_mode intr_mode);
+enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
+void vnic_dev_unregister(struct vnic_dev *vdev);
+struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
+ void *priv, struct pci_dev *pdev,
+ struct vnic_dev_bar *bar);
+
+#endif /* _VNIC_DEV_H_ */
diff --git a/drivers/scsi/fnic/vnic_devcmd.h b/drivers/scsi/fnic/vnic_devcmd.h
new file mode 100644
index 000000000000..d62b9061bf12
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_devcmd.h
@@ -0,0 +1,281 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_DEVCMD_H_
+#define _VNIC_DEVCMD_H_
+
+#define _CMD_NBITS 14
+#define _CMD_VTYPEBITS 10
+#define _CMD_FLAGSBITS 6
+#define _CMD_DIRBITS 2
+
+#define _CMD_NMASK ((1 << _CMD_NBITS)-1)
+#define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
+#define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
+#define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
+
+#define _CMD_NSHIFT 0
+#define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
+#define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
+#define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
+
+/*
+ * Direction bits (from host perspective).
+ */
+#define _CMD_DIR_NONE 0U
+#define _CMD_DIR_WRITE 1U
+#define _CMD_DIR_READ 2U
+#define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
+
+/*
+ * Flag bits.
+ */
+#define _CMD_FLAGS_NONE 0U
+#define _CMD_FLAGS_NOWAIT 1U
+
+/*
+ * vNIC type bits.
+ */
+#define _CMD_VTYPE_NONE 0U
+#define _CMD_VTYPE_ENET 1U
+#define _CMD_VTYPE_FC 2U
+#define _CMD_VTYPE_SCSI 4U
+#define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
+
+/*
+ * Used to create cmds..
+*/
+#define _CMDCF(dir, flags, vtype, nr) \
+ (((dir) << _CMD_DIRSHIFT) | \
+ ((flags) << _CMD_FLAGSSHIFT) | \
+ ((vtype) << _CMD_VTYPESHIFT) | \
+ ((nr) << _CMD_NSHIFT))
+#define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
+#define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
+
+/*
+ * Used to decode cmds..
+*/
+#define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
+#define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
+#define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
+#define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
+
+enum vnic_devcmd_cmd {
+ CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
+
+ /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */
+ CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
+
+ /* dev-specific block member:
+ * in: (u16)a0=offset,(u8)a1=size
+ * out: a0=value */
+ CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
+
+ /* stats clear */
+ CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
+
+ /* stats dump in mem: (u64)a0=paddr to stats area,
+ * (u16)a1=sizeof stats area */
+ CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
+
+ /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
+ CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
+
+ /* hang detection notification */
+ CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
+
+ /* MAC address in (u48)a0 */
+ CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ,
+ _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9),
+
+ /* disable/enable promisc mode: (u8)a0=0/1 */
+/***** XXX DEPRECATED *****/
+ CMD_PROMISC_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 10),
+
+ /* disable/enable all-multi mode: (u8)a0=0/1 */
+/***** XXX DEPRECATED *****/
+ CMD_ALLMULTI_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 11),
+
+ /* add addr from (u48)a0 */
+ CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
+ _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
+
+ /* del addr from (u48)a0 */
+ CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
+ _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
+
+ /* add VLAN id in (u16)a0 */
+ CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
+
+ /* del VLAN id in (u16)a0 */
+ CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
+
+ /* nic_cfg in (u32)a0 */
+ CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
+
+ /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
+ CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17),
+
+ /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
+ CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18),
+
+ /* initiate softreset */
+ CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
+
+ /* softreset status:
+ * out: a0=0 reset complete, a0=1 reset in progress */
+ CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
+
+ /* set struct vnic_devcmd_notify buffer in mem:
+ * in:
+ * (u64)a0=paddr to notify (set paddr=0 to unset)
+ * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
+ * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
+ * out:
+ * (u32)a1 = effective size
+ */
+ CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
+
+ /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
+ * (u8)a1=PXENV_UNDI_xxx */
+ CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
+
+ /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
+ CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
+
+ /* open status:
+ * out: a0=0 open complete, a0=1 open in progress */
+ CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
+
+ /* close vnic */
+ CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
+
+ /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
+ CMD_INIT = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
+
+ /* variant of CMD_INIT, with provisioning info
+ * (u64)a0=paddr of vnic_devcmd_provinfo
+ * (u32)a1=sizeof provision info */
+ CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
+
+ /* enable virtual link */
+ CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
+
+ /* disable virtual link */
+ CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
+
+ /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */
+ CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
+
+ /* init status:
+ * out: a0=0 init complete, a0=1 init in progress
+ * if a0=0, a1=errno */
+ CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
+
+ /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
+ * (u8)a1=INT13_CMD_xxx */
+ CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
+
+ /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
+ CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
+
+ /* undo initialize of virtual link */
+ CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
+};
+
+/* flags for CMD_OPEN */
+#define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
+
+/* flags for CMD_INIT */
+#define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
+
+/* flags for CMD_PACKET_FILTER */
+#define CMD_PFILTER_DIRECTED 0x01
+#define CMD_PFILTER_MULTICAST 0x02
+#define CMD_PFILTER_BROADCAST 0x04
+#define CMD_PFILTER_PROMISCUOUS 0x08
+#define CMD_PFILTER_ALL_MULTICAST 0x10
+
+enum vnic_devcmd_status {
+ STAT_NONE = 0,
+ STAT_BUSY = 1 << 0, /* cmd in progress */
+ STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */
+};
+
+enum vnic_devcmd_error {
+ ERR_SUCCESS = 0,
+ ERR_EINVAL = 1,
+ ERR_EFAULT = 2,
+ ERR_EPERM = 3,
+ ERR_EBUSY = 4,
+ ERR_ECMDUNKNOWN = 5,
+ ERR_EBADSTATE = 6,
+ ERR_ENOMEM = 7,
+ ERR_ETIMEDOUT = 8,
+ ERR_ELINKDOWN = 9,
+};
+
+struct vnic_devcmd_fw_info {
+ char fw_version[32];
+ char fw_build[32];
+ char hw_version[32];
+ char hw_serial_number[32];
+};
+
+struct vnic_devcmd_notify {
+ u32 csum; /* checksum over following words */
+
+ u32 link_state; /* link up == 1 */
+ u32 port_speed; /* effective port speed (rate limit) */
+ u32 mtu; /* MTU */
+ u32 msglvl; /* requested driver msg lvl */
+ u32 uif; /* uplink interface */
+ u32 status; /* status bits (see VNIC_STF_*) */
+ u32 error; /* error code (see ERR_*) for first ERR */
+ u32 link_down_cnt; /* running count of link down transitions */
+};
+#define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
+
+struct vnic_devcmd_provinfo {
+ u8 oui[3];
+ u8 type;
+ u8 data[0];
+};
+
+/*
+ * Writing cmd register causes STAT_BUSY to get set in status register.
+ * When cmd completes, STAT_BUSY will be cleared.
+ *
+ * If cmd completed successfully STAT_ERROR will be clear
+ * and args registers contain cmd-specific results.
+ *
+ * If cmd error, STAT_ERROR will be set and args[0] contains error code.
+ *
+ * status register is read-only. While STAT_BUSY is set,
+ * all other register contents are read-only.
+ */
+
+/* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
+#define VNIC_DEVCMD_NARGS 15
+struct vnic_devcmd {
+ u32 status; /* RO */
+ u32 cmd; /* RW */
+ u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */
+};
+
+#endif /* _VNIC_DEVCMD_H_ */
diff --git a/drivers/scsi/fnic/vnic_intr.c b/drivers/scsi/fnic/vnic_intr.c
new file mode 100644
index 000000000000..4f4dc8793d23
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_intr.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include "vnic_dev.h"
+#include "vnic_intr.h"
+
+void vnic_intr_free(struct vnic_intr *intr)
+{
+ intr->ctrl = NULL;
+}
+
+int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
+ unsigned int index)
+{
+ intr->index = index;
+ intr->vdev = vdev;
+
+ intr->ctrl = vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index);
+ if (!intr->ctrl) {
+ printk(KERN_ERR "Failed to hook INTR[%d].ctrl resource\n",
+ index);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer,
+ unsigned int coalescing_type, unsigned int mask_on_assertion)
+{
+ iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer);
+ iowrite32(coalescing_type, &intr->ctrl->coalescing_type);
+ iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion);
+ iowrite32(0, &intr->ctrl->int_credits);
+}
+
+void vnic_intr_clean(struct vnic_intr *intr)
+{
+ iowrite32(0, &intr->ctrl->int_credits);
+}
diff --git a/drivers/scsi/fnic/vnic_intr.h b/drivers/scsi/fnic/vnic_intr.h
new file mode 100644
index 000000000000..d5fb40e7c98e
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_intr.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_INTR_H_
+#define _VNIC_INTR_H_
+
+#include <linux/pci.h>
+#include "vnic_dev.h"
+
+/*
+ * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
+ * Driver) when both are built with CONFIG options =y
+ */
+#define vnic_intr_unmask fnic_intr_unmask
+#define vnic_intr_mask fnic_intr_mask
+#define vnic_intr_return_credits fnic_intr_return_credits
+#define vnic_intr_credits fnic_intr_credits
+#define vnic_intr_return_all_credits fnic_intr_return_all_credits
+#define vnic_intr_legacy_pba fnic_intr_legacy_pba
+#define vnic_intr_free fnic_intr_free
+#define vnic_intr_alloc fnic_intr_alloc
+#define vnic_intr_init fnic_intr_init
+#define vnic_intr_clean fnic_intr_clean
+
+#define VNIC_INTR_TIMER_MAX 0xffff
+
+#define VNIC_INTR_TIMER_TYPE_ABS 0
+#define VNIC_INTR_TIMER_TYPE_QUIET 1
+
+/* Interrupt control */
+struct vnic_intr_ctrl {
+ u32 coalescing_timer; /* 0x00 */
+ u32 pad0;
+ u32 coalescing_value; /* 0x08 */
+ u32 pad1;
+ u32 coalescing_type; /* 0x10 */
+ u32 pad2;
+ u32 mask_on_assertion; /* 0x18 */
+ u32 pad3;
+ u32 mask; /* 0x20 */
+ u32 pad4;
+ u32 int_credits; /* 0x28 */
+ u32 pad5;
+ u32 int_credit_return; /* 0x30 */
+ u32 pad6;
+};
+
+struct vnic_intr {
+ unsigned int index;
+ struct vnic_dev *vdev;
+ struct vnic_intr_ctrl __iomem *ctrl; /* memory-mapped */
+};
+
+static inline void vnic_intr_unmask(struct vnic_intr *intr)
+{
+ iowrite32(0, &intr->ctrl->mask);
+}
+
+static inline void vnic_intr_mask(struct vnic_intr *intr)
+{
+ iowrite32(1, &intr->ctrl->mask);
+}
+
+static inline void vnic_intr_return_credits(struct vnic_intr *intr,
+ unsigned int credits, int unmask, int reset_timer)
+{
+#define VNIC_INTR_UNMASK_SHIFT 16
+#define VNIC_INTR_RESET_TIMER_SHIFT 17
+
+ u32 int_credit_return = (credits & 0xffff) |
+ (unmask ? (1 << VNIC_INTR_UNMASK_SHIFT) : 0) |
+ (reset_timer ? (1 << VNIC_INTR_RESET_TIMER_SHIFT) : 0);
+
+ iowrite32(int_credit_return, &intr->ctrl->int_credit_return);
+}
+
+static inline unsigned int vnic_intr_credits(struct vnic_intr *intr)
+{
+ return ioread32(&intr->ctrl->int_credits);
+}
+
+static inline void vnic_intr_return_all_credits(struct vnic_intr *intr)
+{
+ unsigned int credits = vnic_intr_credits(intr);
+ int unmask = 1;
+ int reset_timer = 1;
+
+ vnic_intr_return_credits(intr, credits, unmask, reset_timer);
+}
+
+static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba)
+{
+ /* read PBA without clearing */
+ return ioread32(legacy_pba);
+}
+
+void vnic_intr_free(struct vnic_intr *intr);
+int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
+ unsigned int index);
+void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer,
+ unsigned int coalescing_type, unsigned int mask_on_assertion);
+void vnic_intr_clean(struct vnic_intr *intr);
+
+#endif /* _VNIC_INTR_H_ */
diff --git a/drivers/scsi/fnic/vnic_nic.h b/drivers/scsi/fnic/vnic_nic.h
new file mode 100644
index 000000000000..f15b83eeaced
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_nic.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_NIC_H_
+#define _VNIC_NIC_H_
+
+/*
+ * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
+ * Driver) when both are built with CONFIG options =y
+ */
+#define vnic_set_nic_cfg fnic_set_nic_cfg
+
+#define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD 0xffUL
+#define NIC_CFG_RSS_DEFAULT_CPU_SHIFT 0
+#define NIC_CFG_RSS_HASH_TYPE (0xffUL << 8)
+#define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD 0xffUL
+#define NIC_CFG_RSS_HASH_TYPE_SHIFT 8
+#define NIC_CFG_RSS_HASH_BITS (7UL << 16)
+#define NIC_CFG_RSS_HASH_BITS_MASK_FIELD 7UL
+#define NIC_CFG_RSS_HASH_BITS_SHIFT 16
+#define NIC_CFG_RSS_BASE_CPU (7UL << 19)
+#define NIC_CFG_RSS_BASE_CPU_MASK_FIELD 7UL
+#define NIC_CFG_RSS_BASE_CPU_SHIFT 19
+#define NIC_CFG_RSS_ENABLE (1UL << 22)
+#define NIC_CFG_RSS_ENABLE_MASK_FIELD 1UL
+#define NIC_CFG_RSS_ENABLE_SHIFT 22
+#define NIC_CFG_TSO_IPID_SPLIT_EN (1UL << 23)
+#define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD 1UL
+#define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT 23
+#define NIC_CFG_IG_VLAN_STRIP_EN (1UL << 24)
+#define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD 1UL
+#define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT 24
+
+static inline void vnic_set_nic_cfg(u32 *nic_cfg,
+ u8 rss_default_cpu, u8 rss_hash_type,
+ u8 rss_hash_bits, u8 rss_base_cpu,
+ u8 rss_enable, u8 tso_ipid_split_en,
+ u8 ig_vlan_strip_en)
+{
+ *nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) |
+ ((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD)
+ << NIC_CFG_RSS_HASH_TYPE_SHIFT) |
+ ((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD)
+ << NIC_CFG_RSS_HASH_BITS_SHIFT) |
+ ((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD)
+ << NIC_CFG_RSS_BASE_CPU_SHIFT) |
+ ((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD)
+ << NIC_CFG_RSS_ENABLE_SHIFT) |
+ ((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD)
+ << NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) |
+ ((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD)
+ << NIC_CFG_IG_VLAN_STRIP_EN_SHIFT);
+}
+
+#endif /* _VNIC_NIC_H_ */
diff --git a/drivers/scsi/fnic/vnic_resource.h b/drivers/scsi/fnic/vnic_resource.h
new file mode 100644
index 000000000000..2d842f79d41a
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_resource.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_RESOURCE_H_
+#define _VNIC_RESOURCE_H_
+
+#define VNIC_RES_MAGIC 0x766E6963L /* 'vnic' */
+#define VNIC_RES_VERSION 0x00000000L
+
+/* vNIC resource types */
+enum vnic_res_type {
+ RES_TYPE_EOL, /* End-of-list */
+ RES_TYPE_WQ, /* Work queues */
+ RES_TYPE_RQ, /* Receive queues */
+ RES_TYPE_CQ, /* Completion queues */
+ RES_TYPE_RSVD1,
+ RES_TYPE_NIC_CFG, /* Enet NIC config registers */
+ RES_TYPE_RSVD2,
+ RES_TYPE_RSVD3,
+ RES_TYPE_RSVD4,
+ RES_TYPE_RSVD5,
+ RES_TYPE_INTR_CTRL, /* Interrupt ctrl table */
+ RES_TYPE_INTR_TABLE, /* MSI/MSI-X Interrupt table */
+ RES_TYPE_INTR_PBA, /* MSI/MSI-X PBA table */
+ RES_TYPE_INTR_PBA_LEGACY, /* Legacy intr status */
+ RES_TYPE_RSVD6,
+ RES_TYPE_RSVD7,
+ RES_TYPE_DEVCMD, /* Device command region */
+ RES_TYPE_PASS_THRU_PAGE, /* Pass-thru page */
+
+ RES_TYPE_MAX, /* Count of resource types */
+};
+
+struct vnic_resource_header {
+ u32 magic;
+ u32 version;
+};
+
+struct vnic_resource {
+ u8 type;
+ u8 bar;
+ u8 pad[2];
+ u32 bar_offset;
+ u32 count;
+};
+
+#endif /* _VNIC_RESOURCE_H_ */
diff --git a/drivers/scsi/fnic/vnic_rq.c b/drivers/scsi/fnic/vnic_rq.c
new file mode 100644
index 000000000000..bedd0d285630
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_rq.c
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include "vnic_dev.h"
+#include "vnic_rq.h"
+
+static int vnic_rq_alloc_bufs(struct vnic_rq *rq)
+{
+ struct vnic_rq_buf *buf;
+ struct vnic_dev *vdev;
+ unsigned int i, j, count = rq->ring.desc_count;
+ unsigned int blks = VNIC_RQ_BUF_BLKS_NEEDED(count);
+
+ vdev = rq->vdev;
+
+ for (i = 0; i < blks; i++) {
+ rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ, GFP_ATOMIC);
+ if (!rq->bufs[i]) {
+ printk(KERN_ERR "Failed to alloc rq_bufs\n");
+ return -ENOMEM;
+ }
+ }
+
+ for (i = 0; i < blks; i++) {
+ buf = rq->bufs[i];
+ for (j = 0; j < VNIC_RQ_BUF_BLK_ENTRIES; j++) {
+ buf->index = i * VNIC_RQ_BUF_BLK_ENTRIES + j;
+ buf->desc = (u8 *)rq->ring.descs +
+ rq->ring.desc_size * buf->index;
+ if (buf->index + 1 == count) {
+ buf->next = rq->bufs[0];
+ break;
+ } else if (j + 1 == VNIC_RQ_BUF_BLK_ENTRIES) {
+ buf->next = rq->bufs[i + 1];
+ } else {
+ buf->next = buf + 1;
+ buf++;
+ }
+ }
+ }
+
+ rq->to_use = rq->to_clean = rq->bufs[0];
+ rq->buf_index = 0;
+
+ return 0;
+}
+
+void vnic_rq_free(struct vnic_rq *rq)
+{
+ struct vnic_dev *vdev;
+ unsigned int i;
+
+ vdev = rq->vdev;
+
+ vnic_dev_free_desc_ring(vdev, &rq->ring);
+
+ for (i = 0; i < VNIC_RQ_BUF_BLKS_MAX; i++) {
+ kfree(rq->bufs[i]);
+ rq->bufs[i] = NULL;
+ }
+
+ rq->ctrl = NULL;
+}
+
+int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index,
+ unsigned int desc_count, unsigned int desc_size)
+{
+ int err;
+
+ rq->index = index;
+ rq->vdev = vdev;
+
+ rq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_RQ, index);
+ if (!rq->ctrl) {
+ printk(KERN_ERR "Failed to hook RQ[%d] resource\n", index);
+ return -EINVAL;
+ }
+
+ vnic_rq_disable(rq);
+
+ err = vnic_dev_alloc_desc_ring(vdev, &rq->ring, desc_count, desc_size);
+ if (err)
+ return err;
+
+ err = vnic_rq_alloc_bufs(rq);
+ if (err) {
+ vnic_rq_free(rq);
+ return err;
+ }
+
+ return 0;
+}
+
+void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index,
+ unsigned int error_interrupt_enable,
+ unsigned int error_interrupt_offset)
+{
+ u64 paddr;
+ u32 fetch_index;
+
+ paddr = (u64)rq->ring.base_addr | VNIC_PADDR_TARGET;
+ writeq(paddr, &rq->ctrl->ring_base);
+ iowrite32(rq->ring.desc_count, &rq->ctrl->ring_size);
+ iowrite32(cq_index, &rq->ctrl->cq_index);
+ iowrite32(error_interrupt_enable, &rq->ctrl->error_interrupt_enable);
+ iowrite32(error_interrupt_offset, &rq->ctrl->error_interrupt_offset);
+ iowrite32(0, &rq->ctrl->dropped_packet_count);
+ iowrite32(0, &rq->ctrl->error_status);
+
+ /* Use current fetch_index as the ring starting point */
+ fetch_index = ioread32(&rq->ctrl->fetch_index);
+ rq->to_use = rq->to_clean =
+ &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES]
+ [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES];
+ iowrite32(fetch_index, &rq->ctrl->posted_index);
+
+ rq->buf_index = 0;
+}
+
+unsigned int vnic_rq_error_status(struct vnic_rq *rq)
+{
+ return ioread32(&rq->ctrl->error_status);
+}
+
+void vnic_rq_enable(struct vnic_rq *rq)
+{
+ iowrite32(1, &rq->ctrl->enable);
+}
+
+int vnic_rq_disable(struct vnic_rq *rq)
+{
+ unsigned int wait;
+
+ iowrite32(0, &rq->ctrl->enable);
+
+ /* Wait for HW to ACK disable request */
+ for (wait = 0; wait < 100; wait++) {
+ if (!(ioread32(&rq->ctrl->running)))
+ return 0;
+ udelay(1);
+ }
+
+ printk(KERN_ERR "Failed to disable RQ[%d]\n", rq->index);
+
+ return -ETIMEDOUT;
+}
+
+void vnic_rq_clean(struct vnic_rq *rq,
+ void (*buf_clean)(struct vnic_rq *rq, struct vnic_rq_buf *buf))
+{
+ struct vnic_rq_buf *buf;
+ u32 fetch_index;
+
+ BUG_ON(ioread32(&rq->ctrl->enable));
+
+ buf = rq->to_clean;
+
+ while (vnic_rq_desc_used(rq) > 0) {
+
+ (*buf_clean)(rq, buf);
+
+ buf = rq->to_clean = buf->next;
+ rq->ring.desc_avail++;
+ }
+
+ /* Use current fetch_index as the ring starting point */
+ fetch_index = ioread32(&rq->ctrl->fetch_index);
+ rq->to_use = rq->to_clean =
+ &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES]
+ [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES];
+ iowrite32(fetch_index, &rq->ctrl->posted_index);
+
+ rq->buf_index = 0;
+
+ vnic_dev_clear_desc_ring(&rq->ring);
+}
+
diff --git a/drivers/scsi/fnic/vnic_rq.h b/drivers/scsi/fnic/vnic_rq.h
new file mode 100644
index 000000000000..aebdfbd6ad3c
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_rq.h
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_RQ_H_
+#define _VNIC_RQ_H_
+
+#include <linux/pci.h>
+#include "vnic_dev.h"
+#include "vnic_cq.h"
+
+/*
+ * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
+ * Driver) when both are built with CONFIG options =y
+ */
+#define vnic_rq_desc_avail fnic_rq_desc_avail
+#define vnic_rq_desc_used fnic_rq_desc_used
+#define vnic_rq_next_desc fnic_rq_next_desc
+#define vnic_rq_next_index fnic_rq_next_index
+#define vnic_rq_next_buf_index fnic_rq_next_buf_index
+#define vnic_rq_post fnic_rq_post
+#define vnic_rq_posting_soon fnic_rq_posting_soon
+#define vnic_rq_return_descs fnic_rq_return_descs
+#define vnic_rq_service fnic_rq_service
+#define vnic_rq_fill fnic_rq_fill
+#define vnic_rq_free fnic_rq_free
+#define vnic_rq_alloc fnic_rq_alloc
+#define vnic_rq_init fnic_rq_init
+#define vnic_rq_error_status fnic_rq_error_status
+#define vnic_rq_enable fnic_rq_enable
+#define vnic_rq_disable fnic_rq_disable
+#define vnic_rq_clean fnic_rq_clean
+
+/* Receive queue control */
+struct vnic_rq_ctrl {
+ u64 ring_base; /* 0x00 */
+ u32 ring_size; /* 0x08 */
+ u32 pad0;
+ u32 posted_index; /* 0x10 */
+ u32 pad1;
+ u32 cq_index; /* 0x18 */
+ u32 pad2;
+ u32 enable; /* 0x20 */
+ u32 pad3;
+ u32 running; /* 0x28 */
+ u32 pad4;
+ u32 fetch_index; /* 0x30 */
+ u32 pad5;
+ u32 error_interrupt_enable; /* 0x38 */
+ u32 pad6;
+ u32 error_interrupt_offset; /* 0x40 */
+ u32 pad7;
+ u32 error_status; /* 0x48 */
+ u32 pad8;
+ u32 dropped_packet_count; /* 0x50 */
+ u32 pad9;
+ u32 dropped_packet_count_rc; /* 0x58 */
+ u32 pad10;
+};
+
+/* Break the vnic_rq_buf allocations into blocks of 64 entries */
+#define VNIC_RQ_BUF_BLK_ENTRIES 64
+#define VNIC_RQ_BUF_BLK_SZ \
+ (VNIC_RQ_BUF_BLK_ENTRIES * sizeof(struct vnic_rq_buf))
+#define VNIC_RQ_BUF_BLKS_NEEDED(entries) \
+ DIV_ROUND_UP(entries, VNIC_RQ_BUF_BLK_ENTRIES)
+#define VNIC_RQ_BUF_BLKS_MAX VNIC_RQ_BUF_BLKS_NEEDED(4096)
+
+struct vnic_rq_buf {
+ struct vnic_rq_buf *next;
+ dma_addr_t dma_addr;
+ void *os_buf;
+ unsigned int os_buf_index;
+ unsigned int len;
+ unsigned int index;
+ void *desc;
+};
+
+struct vnic_rq {
+ unsigned int index;
+ struct vnic_dev *vdev;
+ struct vnic_rq_ctrl __iomem *ctrl; /* memory-mapped */
+ struct vnic_dev_ring ring;
+ struct vnic_rq_buf *bufs[VNIC_RQ_BUF_BLKS_MAX];
+ struct vnic_rq_buf *to_use;
+ struct vnic_rq_buf *to_clean;
+ void *os_buf_head;
+ unsigned int buf_index;
+ unsigned int pkts_outstanding;
+};
+
+static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
+{
+ /* how many does SW own? */
+ return rq->ring.desc_avail;
+}
+
+static inline unsigned int vnic_rq_desc_used(struct vnic_rq *rq)
+{
+ /* how many does HW own? */
+ return rq->ring.desc_count - rq->ring.desc_avail - 1;
+}
+
+static inline void *vnic_rq_next_desc(struct vnic_rq *rq)
+{
+ return rq->to_use->desc;
+}
+
+static inline unsigned int vnic_rq_next_index(struct vnic_rq *rq)
+{
+ return rq->to_use->index;
+}
+
+static inline unsigned int vnic_rq_next_buf_index(struct vnic_rq *rq)
+{
+ return rq->buf_index++;
+}
+
+static inline void vnic_rq_post(struct vnic_rq *rq,
+ void *os_buf, unsigned int os_buf_index,
+ dma_addr_t dma_addr, unsigned int len)
+{
+ struct vnic_rq_buf *buf = rq->to_use;
+
+ buf->os_buf = os_buf;
+ buf->os_buf_index = os_buf_index;
+ buf->dma_addr = dma_addr;
+ buf->len = len;
+
+ buf = buf->next;
+ rq->to_use = buf;
+ rq->ring.desc_avail--;
+
+ /* Move the posted_index every nth descriptor
+ */
+
+#ifndef VNIC_RQ_RETURN_RATE
+#define VNIC_RQ_RETURN_RATE 0xf /* keep 2^n - 1 */
+#endif
+
+ if ((buf->index & VNIC_RQ_RETURN_RATE) == 0) {
+ /* Adding write memory barrier prevents compiler and/or CPU
+ * reordering, thus avoiding descriptor posting before
+ * descriptor is initialized. Otherwise, hardware can read
+ * stale descriptor fields.
+ */
+ wmb();
+ iowrite32(buf->index, &rq->ctrl->posted_index);
+ }
+}
+
+static inline int vnic_rq_posting_soon(struct vnic_rq *rq)
+{
+ return (rq->to_use->index & VNIC_RQ_RETURN_RATE) == 0;
+}
+
+static inline void vnic_rq_return_descs(struct vnic_rq *rq, unsigned int count)
+{
+ rq->ring.desc_avail += count;
+}
+
+enum desc_return_options {
+ VNIC_RQ_RETURN_DESC,
+ VNIC_RQ_DEFER_RETURN_DESC,
+};
+
+static inline void vnic_rq_service(struct vnic_rq *rq,
+ struct cq_desc *cq_desc, u16 completed_index,
+ int desc_return, void (*buf_service)(struct vnic_rq *rq,
+ struct cq_desc *cq_desc, struct vnic_rq_buf *buf,
+ int skipped, void *opaque), void *opaque)
+{
+ struct vnic_rq_buf *buf;
+ int skipped;
+
+ buf = rq->to_clean;
+ while (1) {
+
+ skipped = (buf->index != completed_index);
+
+ (*buf_service)(rq, cq_desc, buf, skipped, opaque);
+
+ if (desc_return == VNIC_RQ_RETURN_DESC)
+ rq->ring.desc_avail++;
+
+ rq->to_clean = buf->next;
+
+ if (!skipped)
+ break;
+
+ buf = rq->to_clean;
+ }
+}
+
+static inline int vnic_rq_fill(struct vnic_rq *rq,
+ int (*buf_fill)(struct vnic_rq *rq))
+{
+ int err;
+
+ while (vnic_rq_desc_avail(rq) > 1) {
+
+ err = (*buf_fill)(rq);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
+void vnic_rq_free(struct vnic_rq *rq);
+int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index,
+ unsigned int desc_count, unsigned int desc_size);
+void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index,
+ unsigned int error_interrupt_enable,
+ unsigned int error_interrupt_offset);
+unsigned int vnic_rq_error_status(struct vnic_rq *rq);
+void vnic_rq_enable(struct vnic_rq *rq);
+int vnic_rq_disable(struct vnic_rq *rq);
+void vnic_rq_clean(struct vnic_rq *rq,
+ void (*buf_clean)(struct vnic_rq *rq, struct vnic_rq_buf *buf));
+
+#endif /* _VNIC_RQ_H_ */
diff --git a/drivers/scsi/fnic/vnic_scsi.h b/drivers/scsi/fnic/vnic_scsi.h
new file mode 100644
index 000000000000..46baa5254001
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_scsi.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_SCSI_H_
+#define _VNIC_SCSI_H_
+
+#define VNIC_FNIC_WQ_COPY_COUNT_MIN 1
+#define VNIC_FNIC_WQ_COPY_COUNT_MAX 1
+
+#define VNIC_FNIC_WQ_DESCS_MIN 64
+#define VNIC_FNIC_WQ_DESCS_MAX 128
+
+#define VNIC_FNIC_WQ_COPY_DESCS_MIN 64
+#define VNIC_FNIC_WQ_COPY_DESCS_MAX 512
+
+#define VNIC_FNIC_RQ_DESCS_MIN 64
+#define VNIC_FNIC_RQ_DESCS_MAX 128
+
+#define VNIC_FNIC_EDTOV_MIN 1000
+#define VNIC_FNIC_EDTOV_MAX 255000
+#define VNIC_FNIC_EDTOV_DEF 2000
+
+#define VNIC_FNIC_RATOV_MIN 1000
+#define VNIC_FNIC_RATOV_MAX 255000
+
+#define VNIC_FNIC_MAXDATAFIELDSIZE_MIN 256
+#define VNIC_FNIC_MAXDATAFIELDSIZE_MAX 2112
+
+#define VNIC_FNIC_FLOGI_RETRIES_MIN 0
+#define VNIC_FNIC_FLOGI_RETRIES_MAX 0xffffffff
+#define VNIC_FNIC_FLOGI_RETRIES_DEF 0xffffffff
+
+#define VNIC_FNIC_FLOGI_TIMEOUT_MIN 1000
+#define VNIC_FNIC_FLOGI_TIMEOUT_MAX 255000
+
+#define VNIC_FNIC_PLOGI_RETRIES_MIN 0
+#define VNIC_FNIC_PLOGI_RETRIES_MAX 255
+#define VNIC_FNIC_PLOGI_RETRIES_DEF 8
+
+#define VNIC_FNIC_PLOGI_TIMEOUT_MIN 1000
+#define VNIC_FNIC_PLOGI_TIMEOUT_MAX 255000
+
+#define VNIC_FNIC_IO_THROTTLE_COUNT_MIN 256
+#define VNIC_FNIC_IO_THROTTLE_COUNT_MAX 4096
+
+#define VNIC_FNIC_LINK_DOWN_TIMEOUT_MIN 0
+#define VNIC_FNIC_LINK_DOWN_TIMEOUT_MAX 240000
+
+#define VNIC_FNIC_PORT_DOWN_TIMEOUT_MIN 0
+#define VNIC_FNIC_PORT_DOWN_TIMEOUT_MAX 240000
+
+#define VNIC_FNIC_PORT_DOWN_IO_RETRIES_MIN 0
+#define VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX 255
+
+#define VNIC_FNIC_LUNS_PER_TARGET_MIN 1
+#define VNIC_FNIC_LUNS_PER_TARGET_MAX 1024
+
+/* Device-specific region: scsi configuration */
+struct vnic_fc_config {
+ u64 node_wwn;
+ u64 port_wwn;
+ u32 flags;
+ u32 wq_enet_desc_count;
+ u32 wq_copy_desc_count;
+ u32 rq_desc_count;
+ u32 flogi_retries;
+ u32 flogi_timeout;
+ u32 plogi_retries;
+ u32 plogi_timeout;
+ u32 io_throttle_count;
+ u32 link_down_timeout;
+ u32 port_down_timeout;
+ u32 port_down_io_retries;
+ u32 luns_per_tgt;
+ u16 maxdatafieldsize;
+ u16 ed_tov;
+ u16 ra_tov;
+ u16 intr_timer;
+ u8 intr_timer_type;
+};
+
+#define VFCF_FCP_SEQ_LVL_ERR 0x1 /* Enable FCP-2 Error Recovery */
+#define VFCF_PERBI 0x2 /* persistent binding info available */
+
+#endif /* _VNIC_SCSI_H_ */
diff --git a/drivers/scsi/fnic/vnic_stats.h b/drivers/scsi/fnic/vnic_stats.h
new file mode 100644
index 000000000000..5372e23c1cb3
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_stats.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_STATS_H_
+#define _VNIC_STATS_H_
+
+/* Tx statistics */
+struct vnic_tx_stats {
+ u64 tx_frames_ok;
+ u64 tx_unicast_frames_ok;
+ u64 tx_multicast_frames_ok;
+ u64 tx_broadcast_frames_ok;
+ u64 tx_bytes_ok;
+ u64 tx_unicast_bytes_ok;
+ u64 tx_multicast_bytes_ok;
+ u64 tx_broadcast_bytes_ok;
+ u64 tx_drops;
+ u64 tx_errors;
+ u64 tx_tso;
+ u64 rsvd[16];
+};
+
+/* Rx statistics */
+struct vnic_rx_stats {
+ u64 rx_frames_ok;
+ u64 rx_frames_total;
+ u64 rx_unicast_frames_ok;
+ u64 rx_multicast_frames_ok;
+ u64 rx_broadcast_frames_ok;
+ u64 rx_bytes_ok;
+ u64 rx_unicast_bytes_ok;
+ u64 rx_multicast_bytes_ok;
+ u64 rx_broadcast_bytes_ok;
+ u64 rx_drop;
+ u64 rx_no_bufs;
+ u64 rx_errors;
+ u64 rx_rss;
+ u64 rx_crc_errors;
+ u64 rx_frames_64;
+ u64 rx_frames_127;
+ u64 rx_frames_255;
+ u64 rx_frames_511;
+ u64 rx_frames_1023;
+ u64 rx_frames_1518;
+ u64 rx_frames_to_max;
+ u64 rsvd[16];
+};
+
+struct vnic_stats {
+ struct vnic_tx_stats tx;
+ struct vnic_rx_stats rx;
+};
+
+#endif /* _VNIC_STATS_H_ */
diff --git a/drivers/scsi/fnic/vnic_wq.c b/drivers/scsi/fnic/vnic_wq.c
new file mode 100644
index 000000000000..1f9ea790d130
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_wq.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include "vnic_dev.h"
+#include "vnic_wq.h"
+
+static int vnic_wq_alloc_bufs(struct vnic_wq *wq)
+{
+ struct vnic_wq_buf *buf;
+ struct vnic_dev *vdev;
+ unsigned int i, j, count = wq->ring.desc_count;
+ unsigned int blks = VNIC_WQ_BUF_BLKS_NEEDED(count);
+
+ vdev = wq->vdev;
+
+ for (i = 0; i < blks; i++) {
+ wq->bufs[i] = kzalloc(VNIC_WQ_BUF_BLK_SZ, GFP_ATOMIC);
+ if (!wq->bufs[i]) {
+ printk(KERN_ERR "Failed to alloc wq_bufs\n");
+ return -ENOMEM;
+ }
+ }
+
+ for (i = 0; i < blks; i++) {
+ buf = wq->bufs[i];
+ for (j = 0; j < VNIC_WQ_BUF_BLK_ENTRIES; j++) {
+ buf->index = i * VNIC_WQ_BUF_BLK_ENTRIES + j;
+ buf->desc = (u8 *)wq->ring.descs +
+ wq->ring.desc_size * buf->index;
+ if (buf->index + 1 == count) {
+ buf->next = wq->bufs[0];
+ break;
+ } else if (j + 1 == VNIC_WQ_BUF_BLK_ENTRIES) {
+ buf->next = wq->bufs[i + 1];
+ } else {
+ buf->next = buf + 1;
+ buf++;
+ }
+ }
+ }
+
+ wq->to_use = wq->to_clean = wq->bufs[0];
+
+ return 0;
+}
+
+void vnic_wq_free(struct vnic_wq *wq)
+{
+ struct vnic_dev *vdev;
+ unsigned int i;
+
+ vdev = wq->vdev;
+
+ vnic_dev_free_desc_ring(vdev, &wq->ring);
+
+ for (i = 0; i < VNIC_WQ_BUF_BLKS_MAX; i++) {
+ kfree(wq->bufs[i]);
+ wq->bufs[i] = NULL;
+ }
+
+ wq->ctrl = NULL;
+
+}
+
+int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int index,
+ unsigned int desc_count, unsigned int desc_size)
+{
+ int err;
+
+ wq->index = index;
+ wq->vdev = vdev;
+
+ wq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_WQ, index);
+ if (!wq->ctrl) {
+ printk(KERN_ERR "Failed to hook WQ[%d] resource\n", index);
+ return -EINVAL;
+ }
+
+ vnic_wq_disable(wq);
+
+ err = vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size);
+ if (err)
+ return err;
+
+ err = vnic_wq_alloc_bufs(wq);
+ if (err) {
+ vnic_wq_free(wq);
+ return err;
+ }
+
+ return 0;
+}
+
+void vnic_wq_init(struct vnic_wq *wq, unsigned int cq_index,
+ unsigned int error_interrupt_enable,
+ unsigned int error_interrupt_offset)
+{
+ u64 paddr;
+
+ paddr = (u64)wq->ring.base_addr | VNIC_PADDR_TARGET;
+ writeq(paddr, &wq->ctrl->ring_base);
+ iowrite32(wq->ring.desc_count, &wq->ctrl->ring_size);
+ iowrite32(0, &wq->ctrl->fetch_index);
+ iowrite32(0, &wq->ctrl->posted_index);
+ iowrite32(cq_index, &wq->ctrl->cq_index);
+ iowrite32(error_interrupt_enable, &wq->ctrl->error_interrupt_enable);
+ iowrite32(error_interrupt_offset, &wq->ctrl->error_interrupt_offset);
+ iowrite32(0, &wq->ctrl->error_status);
+}
+
+unsigned int vnic_wq_error_status(struct vnic_wq *wq)
+{
+ return ioread32(&wq->ctrl->error_status);
+}
+
+void vnic_wq_enable(struct vnic_wq *wq)
+{
+ iowrite32(1, &wq->ctrl->enable);
+}
+
+int vnic_wq_disable(struct vnic_wq *wq)
+{
+ unsigned int wait;
+
+ iowrite32(0, &wq->ctrl->enable);
+
+ /* Wait for HW to ACK disable request */
+ for (wait = 0; wait < 100; wait++) {
+ if (!(ioread32(&wq->ctrl->running)))
+ return 0;
+ udelay(1);
+ }
+
+ printk(KERN_ERR "Failed to disable WQ[%d]\n", wq->index);
+
+ return -ETIMEDOUT;
+}
+
+void vnic_wq_clean(struct vnic_wq *wq,
+ void (*buf_clean)(struct vnic_wq *wq, struct vnic_wq_buf *buf))
+{
+ struct vnic_wq_buf *buf;
+
+ BUG_ON(ioread32(&wq->ctrl->enable));
+
+ buf = wq->to_clean;
+
+ while (vnic_wq_desc_used(wq) > 0) {
+
+ (*buf_clean)(wq, buf);
+
+ buf = wq->to_clean = buf->next;
+ wq->ring.desc_avail++;
+ }
+
+ wq->to_use = wq->to_clean = wq->bufs[0];
+
+ iowrite32(0, &wq->ctrl->fetch_index);
+ iowrite32(0, &wq->ctrl->posted_index);
+ iowrite32(0, &wq->ctrl->error_status);
+
+ vnic_dev_clear_desc_ring(&wq->ring);
+}
diff --git a/drivers/scsi/fnic/vnic_wq.h b/drivers/scsi/fnic/vnic_wq.h
new file mode 100644
index 000000000000..5cd094f79281
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_wq.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_WQ_H_
+#define _VNIC_WQ_H_
+
+#include <linux/pci.h>
+#include "vnic_dev.h"
+#include "vnic_cq.h"
+
+/*
+ * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
+ * Driver) when both are built with CONFIG options =y
+ */
+#define vnic_wq_desc_avail fnic_wq_desc_avail
+#define vnic_wq_desc_used fnic_wq_desc_used
+#define vnic_wq_next_desc fni_cwq_next_desc
+#define vnic_wq_post fnic_wq_post
+#define vnic_wq_service fnic_wq_service
+#define vnic_wq_free fnic_wq_free
+#define vnic_wq_alloc fnic_wq_alloc
+#define vnic_wq_init fnic_wq_init
+#define vnic_wq_error_status fnic_wq_error_status
+#define vnic_wq_enable fnic_wq_enable
+#define vnic_wq_disable fnic_wq_disable
+#define vnic_wq_clean fnic_wq_clean
+
+/* Work queue control */
+struct vnic_wq_ctrl {
+ u64 ring_base; /* 0x00 */
+ u32 ring_size; /* 0x08 */
+ u32 pad0;
+ u32 posted_index; /* 0x10 */
+ u32 pad1;
+ u32 cq_index; /* 0x18 */
+ u32 pad2;
+ u32 enable; /* 0x20 */
+ u32 pad3;
+ u32 running; /* 0x28 */
+ u32 pad4;
+ u32 fetch_index; /* 0x30 */
+ u32 pad5;
+ u32 dca_value; /* 0x38 */
+ u32 pad6;
+ u32 error_interrupt_enable; /* 0x40 */
+ u32 pad7;
+ u32 error_interrupt_offset; /* 0x48 */
+ u32 pad8;
+ u32 error_status; /* 0x50 */
+ u32 pad9;
+};
+
+struct vnic_wq_buf {
+ struct vnic_wq_buf *next;
+ dma_addr_t dma_addr;
+ void *os_buf;
+ unsigned int len;
+ unsigned int index;
+ int sop;
+ void *desc;
+};
+
+/* Break the vnic_wq_buf allocations into blocks of 64 entries */
+#define VNIC_WQ_BUF_BLK_ENTRIES 64
+#define VNIC_WQ_BUF_BLK_SZ \
+ (VNIC_WQ_BUF_BLK_ENTRIES * sizeof(struct vnic_wq_buf))
+#define VNIC_WQ_BUF_BLKS_NEEDED(entries) \
+ DIV_ROUND_UP(entries, VNIC_WQ_BUF_BLK_ENTRIES)
+#define VNIC_WQ_BUF_BLKS_MAX VNIC_WQ_BUF_BLKS_NEEDED(4096)
+
+struct vnic_wq {
+ unsigned int index;
+ struct vnic_dev *vdev;
+ struct vnic_wq_ctrl __iomem *ctrl; /* memory-mapped */
+ struct vnic_dev_ring ring;
+ struct vnic_wq_buf *bufs[VNIC_WQ_BUF_BLKS_MAX];
+ struct vnic_wq_buf *to_use;
+ struct vnic_wq_buf *to_clean;
+ unsigned int pkts_outstanding;
+};
+
+static inline unsigned int vnic_wq_desc_avail(struct vnic_wq *wq)
+{
+ /* how many does SW own? */
+ return wq->ring.desc_avail;
+}
+
+static inline unsigned int vnic_wq_desc_used(struct vnic_wq *wq)
+{
+ /* how many does HW own? */
+ return wq->ring.desc_count - wq->ring.desc_avail - 1;
+}
+
+static inline void *vnic_wq_next_desc(struct vnic_wq *wq)
+{
+ return wq->to_use->desc;
+}
+
+static inline void vnic_wq_post(struct vnic_wq *wq,
+ void *os_buf, dma_addr_t dma_addr,
+ unsigned int len, int sop, int eop)
+{
+ struct vnic_wq_buf *buf = wq->to_use;
+
+ buf->sop = sop;
+ buf->os_buf = eop ? os_buf : NULL;
+ buf->dma_addr = dma_addr;
+ buf->len = len;
+
+ buf = buf->next;
+ if (eop) {
+ /* Adding write memory barrier prevents compiler and/or CPU
+ * reordering, thus avoiding descriptor posting before
+ * descriptor is initialized. Otherwise, hardware can read
+ * stale descriptor fields.
+ */
+ wmb();
+ iowrite32(buf->index, &wq->ctrl->posted_index);
+ }
+ wq->to_use = buf;
+
+ wq->ring.desc_avail--;
+}
+
+static inline void vnic_wq_service(struct vnic_wq *wq,
+ struct cq_desc *cq_desc, u16 completed_index,
+ void (*buf_service)(struct vnic_wq *wq,
+ struct cq_desc *cq_desc, struct vnic_wq_buf *buf, void *opaque),
+ void *opaque)
+{
+ struct vnic_wq_buf *buf;
+
+ buf = wq->to_clean;
+ while (1) {
+
+ (*buf_service)(wq, cq_desc, buf, opaque);
+
+ wq->ring.desc_avail++;
+
+ wq->to_clean = buf->next;
+
+ if (buf->index == completed_index)
+ break;
+
+ buf = wq->to_clean;
+ }
+}
+
+void vnic_wq_free(struct vnic_wq *wq);
+int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int index,
+ unsigned int desc_count, unsigned int desc_size);
+void vnic_wq_init(struct vnic_wq *wq, unsigned int cq_index,
+ unsigned int error_interrupt_enable,
+ unsigned int error_interrupt_offset);
+unsigned int vnic_wq_error_status(struct vnic_wq *wq);
+void vnic_wq_enable(struct vnic_wq *wq);
+int vnic_wq_disable(struct vnic_wq *wq);
+void vnic_wq_clean(struct vnic_wq *wq,
+ void (*buf_clean)(struct vnic_wq *wq, struct vnic_wq_buf *buf));
+
+#endif /* _VNIC_WQ_H_ */
diff --git a/drivers/scsi/fnic/vnic_wq_copy.c b/drivers/scsi/fnic/vnic_wq_copy.c
new file mode 100644
index 000000000000..9eab7e7caf38
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_wq_copy.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include "vnic_wq_copy.h"
+
+void vnic_wq_copy_enable(struct vnic_wq_copy *wq)
+{
+ iowrite32(1, &wq->ctrl->enable);
+}
+
+int vnic_wq_copy_disable(struct vnic_wq_copy *wq)
+{
+ unsigned int wait;
+
+ iowrite32(0, &wq->ctrl->enable);
+
+ /* Wait for HW to ACK disable request */
+ for (wait = 0; wait < 100; wait++) {
+ if (!(ioread32(&wq->ctrl->running)))
+ return 0;
+ udelay(1);
+ }
+
+ printk(KERN_ERR "Failed to disable Copy WQ[%d],"
+ " fetch index=%d, posted_index=%d\n",
+ wq->index, ioread32(&wq->ctrl->fetch_index),
+ ioread32(&wq->ctrl->posted_index));
+
+ return -ENODEV;
+}
+
+void vnic_wq_copy_clean(struct vnic_wq_copy *wq,
+ void (*q_clean)(struct vnic_wq_copy *wq,
+ struct fcpio_host_req *wq_desc))
+{
+ BUG_ON(ioread32(&wq->ctrl->enable));
+
+ if (vnic_wq_copy_desc_in_use(wq))
+ vnic_wq_copy_service(wq, -1, q_clean);
+
+ wq->to_use_index = wq->to_clean_index = 0;
+
+ iowrite32(0, &wq->ctrl->fetch_index);
+ iowrite32(0, &wq->ctrl->posted_index);
+ iowrite32(0, &wq->ctrl->error_status);
+
+ vnic_dev_clear_desc_ring(&wq->ring);
+}
+
+void vnic_wq_copy_free(struct vnic_wq_copy *wq)
+{
+ struct vnic_dev *vdev;
+
+ vdev = wq->vdev;
+ vnic_dev_free_desc_ring(vdev, &wq->ring);
+ wq->ctrl = NULL;
+}
+
+int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct vnic_wq_copy *wq,
+ unsigned int index, unsigned int desc_count,
+ unsigned int desc_size)
+{
+ int err;
+
+ wq->index = index;
+ wq->vdev = vdev;
+ wq->to_use_index = wq->to_clean_index = 0;
+ wq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_WQ, index);
+ if (!wq->ctrl) {
+ printk(KERN_ERR "Failed to hook COPY WQ[%d] resource\n", index);
+ return -EINVAL;
+ }
+
+ vnic_wq_copy_disable(wq);
+
+ err = vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size);
+ if (err)
+ return err;
+
+ return 0;
+}
+
+void vnic_wq_copy_init(struct vnic_wq_copy *wq, unsigned int cq_index,
+ unsigned int error_interrupt_enable,
+ unsigned int error_interrupt_offset)
+{
+ u64 paddr;
+
+ paddr = (u64)wq->ring.base_addr | VNIC_PADDR_TARGET;
+ writeq(paddr, &wq->ctrl->ring_base);
+ iowrite32(wq->ring.desc_count, &wq->ctrl->ring_size);
+ iowrite32(0, &wq->ctrl->fetch_index);
+ iowrite32(0, &wq->ctrl->posted_index);
+ iowrite32(cq_index, &wq->ctrl->cq_index);
+ iowrite32(error_interrupt_enable, &wq->ctrl->error_interrupt_enable);
+ iowrite32(error_interrupt_offset, &wq->ctrl->error_interrupt_offset);
+}
+
diff --git a/drivers/scsi/fnic/vnic_wq_copy.h b/drivers/scsi/fnic/vnic_wq_copy.h
new file mode 100644
index 000000000000..6aff9740c3df
--- /dev/null
+++ b/drivers/scsi/fnic/vnic_wq_copy.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _VNIC_WQ_COPY_H_
+#define _VNIC_WQ_COPY_H_
+
+#include <linux/pci.h>
+#include "vnic_wq.h"
+#include "fcpio.h"
+
+#define VNIC_WQ_COPY_MAX 1
+
+struct vnic_wq_copy {
+ unsigned int index;
+ struct vnic_dev *vdev;
+ struct vnic_wq_ctrl __iomem *ctrl; /* memory-mapped */
+ struct vnic_dev_ring ring;
+ unsigned to_use_index;
+ unsigned to_clean_index;
+};
+
+static inline unsigned int vnic_wq_copy_desc_avail(struct vnic_wq_copy *wq)
+{
+ return wq->ring.desc_avail;
+}
+
+static inline unsigned int vnic_wq_copy_desc_in_use(struct vnic_wq_copy *wq)
+{
+ return wq->ring.desc_count - 1 - wq->ring.desc_avail;
+}
+
+static inline void *vnic_wq_copy_next_desc(struct vnic_wq_copy *wq)
+{
+ struct fcpio_host_req *desc = wq->ring.descs;
+ return &desc[wq->to_use_index];
+}
+
+static inline void vnic_wq_copy_post(struct vnic_wq_copy *wq)
+{
+
+ ((wq->to_use_index + 1) == wq->ring.desc_count) ?
+ (wq->to_use_index = 0) : (wq->to_use_index++);
+ wq->ring.desc_avail--;
+
+ /* Adding write memory barrier prevents compiler and/or CPU
+ * reordering, thus avoiding descriptor posting before
+ * descriptor is initialized. Otherwise, hardware can read
+ * stale descriptor fields.
+ */
+ wmb();
+
+ iowrite32(wq->to_use_index, &wq->ctrl->posted_index);
+}
+
+static inline void vnic_wq_copy_desc_process(struct vnic_wq_copy *wq, u16 index)
+{
+ unsigned int cnt;
+
+ if (wq->to_clean_index <= index)
+ cnt = (index - wq->to_clean_index) + 1;
+ else
+ cnt = wq->ring.desc_count - wq->to_clean_index + index + 1;
+
+ wq->to_clean_index = ((index + 1) % wq->ring.desc_count);
+ wq->ring.desc_avail += cnt;
+
+}
+
+static inline void vnic_wq_copy_service(struct vnic_wq_copy *wq,
+ u16 completed_index,
+ void (*q_service)(struct vnic_wq_copy *wq,
+ struct fcpio_host_req *wq_desc))
+{
+ struct fcpio_host_req *wq_desc = wq->ring.descs;
+ unsigned int curr_index;
+
+ while (1) {
+
+ if (q_service)
+ (*q_service)(wq, &wq_desc[wq->to_clean_index]);
+
+ wq->ring.desc_avail++;
+
+ curr_index = wq->to_clean_index;
+
+ /* increment the to-clean index so that we start
+ * with an unprocessed index next time we enter the loop
+ */
+ ((wq->to_clean_index + 1) == wq->ring.desc_count) ?
+ (wq->to_clean_index = 0) : (wq->to_clean_index++);
+
+ if (curr_index == completed_index)
+ break;
+
+ /* we have cleaned all the entries */
+ if ((completed_index == (u16)-1) &&
+ (wq->to_clean_index == wq->to_use_index))
+ break;
+ }
+}
+
+void vnic_wq_copy_enable(struct vnic_wq_copy *wq);
+int vnic_wq_copy_disable(struct vnic_wq_copy *wq);
+void vnic_wq_copy_free(struct vnic_wq_copy *wq);
+int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct vnic_wq_copy *wq,
+ unsigned int index, unsigned int desc_count, unsigned int desc_size);
+void vnic_wq_copy_init(struct vnic_wq_copy *wq, unsigned int cq_index,
+ unsigned int error_interrupt_enable,
+ unsigned int error_interrupt_offset);
+void vnic_wq_copy_clean(struct vnic_wq_copy *wq,
+ void (*q_clean)(struct vnic_wq_copy *wq,
+ struct fcpio_host_req *wq_desc));
+
+#endif /* _VNIC_WQ_COPY_H_ */
diff --git a/drivers/scsi/fnic/wq_enet_desc.h b/drivers/scsi/fnic/wq_enet_desc.h
new file mode 100644
index 000000000000..b121cbad18b8
--- /dev/null
+++ b/drivers/scsi/fnic/wq_enet_desc.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _WQ_ENET_DESC_H_
+#define _WQ_ENET_DESC_H_
+
+/* Ethernet work queue descriptor: 16B */
+struct wq_enet_desc {
+ __le64 address;
+ __le16 length;
+ __le16 mss_loopback;
+ __le16 header_length_flags;
+ __le16 vlan_tag;
+};
+
+#define WQ_ENET_ADDR_BITS 64
+#define WQ_ENET_LEN_BITS 14
+#define WQ_ENET_LEN_MASK ((1 << WQ_ENET_LEN_BITS) - 1)
+#define WQ_ENET_MSS_BITS 14
+#define WQ_ENET_MSS_MASK ((1 << WQ_ENET_MSS_BITS) - 1)
+#define WQ_ENET_MSS_SHIFT 2
+#define WQ_ENET_LOOPBACK_SHIFT 1
+#define WQ_ENET_HDRLEN_BITS 10
+#define WQ_ENET_HDRLEN_MASK ((1 << WQ_ENET_HDRLEN_BITS) - 1)
+#define WQ_ENET_FLAGS_OM_BITS 2
+#define WQ_ENET_FLAGS_OM_MASK ((1 << WQ_ENET_FLAGS_OM_BITS) - 1)
+#define WQ_ENET_FLAGS_EOP_SHIFT 12
+#define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT 13
+#define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT 14
+#define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT 15
+
+#define WQ_ENET_OFFLOAD_MODE_CSUM 0
+#define WQ_ENET_OFFLOAD_MODE_RESERVED 1
+#define WQ_ENET_OFFLOAD_MODE_CSUM_L4 2
+#define WQ_ENET_OFFLOAD_MODE_TSO 3
+
+static inline void wq_enet_desc_enc(struct wq_enet_desc *desc,
+ u64 address, u16 length, u16 mss, u16 header_length,
+ u8 offload_mode, u8 eop, u8 cq_entry, u8 fcoe_encap,
+ u8 vlan_tag_insert, u16 vlan_tag, u8 loopback)
+{
+ desc->address = cpu_to_le64(address);
+ desc->length = cpu_to_le16(length & WQ_ENET_LEN_MASK);
+ desc->mss_loopback = cpu_to_le16((mss & WQ_ENET_MSS_MASK) <<
+ WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT);
+ desc->header_length_flags = cpu_to_le16(
+ (header_length & WQ_ENET_HDRLEN_MASK) |
+ (offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS |
+ (eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT |
+ (cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT |
+ (fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT |
+ (vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT);
+ desc->vlan_tag = cpu_to_le16(vlan_tag);
+}
+
+static inline void wq_enet_desc_dec(struct wq_enet_desc *desc,
+ u64 *address, u16 *length, u16 *mss, u16 *header_length,
+ u8 *offload_mode, u8 *eop, u8 *cq_entry, u8 *fcoe_encap,
+ u8 *vlan_tag_insert, u16 *vlan_tag, u8 *loopback)
+{
+ *address = le64_to_cpu(desc->address);
+ *length = le16_to_cpu(desc->length) & WQ_ENET_LEN_MASK;
+ *mss = (le16_to_cpu(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) &
+ WQ_ENET_MSS_MASK;
+ *loopback = (u8)((le16_to_cpu(desc->mss_loopback) >>
+ WQ_ENET_LOOPBACK_SHIFT) & 1);
+ *header_length = le16_to_cpu(desc->header_length_flags) &
+ WQ_ENET_HDRLEN_MASK;
+ *offload_mode = (u8)((le16_to_cpu(desc->header_length_flags) >>
+ WQ_ENET_HDRLEN_BITS) & WQ_ENET_FLAGS_OM_MASK);
+ *eop = (u8)((le16_to_cpu(desc->header_length_flags) >>
+ WQ_ENET_FLAGS_EOP_SHIFT) & 1);
+ *cq_entry = (u8)((le16_to_cpu(desc->header_length_flags) >>
+ WQ_ENET_FLAGS_CQ_ENTRY_SHIFT) & 1);
+ *fcoe_encap = (u8)((le16_to_cpu(desc->header_length_flags) >>
+ WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT) & 1);
+ *vlan_tag_insert = (u8)((le16_to_cpu(desc->header_length_flags) >>
+ WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT) & 1);
+ *vlan_tag = le16_to_cpu(desc->vlan_tag);
+}
+
+#endif /* _WQ_ENET_DESC_H_ */
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index c9aa7611e408..1f41e4b8db61 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -910,9 +910,6 @@ static void login_rsp(struct srp_event_struct *evt_struct)
dev_info(hostdata->dev, "SRP_LOGIN succeeded\n");
- if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta < 0)
- dev_err(hostdata->dev, "Invalid request_limit.\n");
-
/* Now we know what the real request-limit is.
* This value is set rather than added to request_limit because
* request_limit could have been set to -1 by this client.
@@ -1657,7 +1654,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
unsigned long wait_switch = 0;
int rc;
- vdev->dev.driver_data = NULL;
+ dev_set_drvdata(&vdev->dev, NULL);
host = scsi_host_alloc(&driver_template, sizeof(*hostdata));
if (!host) {
@@ -1723,7 +1720,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
scsi_scan_host(host);
}
- vdev->dev.driver_data = hostdata;
+ dev_set_drvdata(&vdev->dev, hostdata);
return 0;
add_srp_port_failed:
@@ -1740,7 +1737,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
static int ibmvscsi_remove(struct vio_dev *vdev)
{
- struct ibmvscsi_host_data *hostdata = vdev->dev.driver_data;
+ struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev);
release_event_pool(&hostdata->pool, hostdata);
ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata,
max_events);
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index e2dd6a45924a..d5eaf9727109 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -892,7 +892,7 @@ free_vport:
static int ibmvstgt_remove(struct vio_dev *dev)
{
- struct srp_target *target = (struct srp_target *) dev->dev.driver_data;
+ struct srp_target *target = dev_get_drvdata(&dev->dev);
struct Scsi_Host *shost = target->shost;
struct vio_port *vport = target->ldata;
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index dd689ded8609..0f8bc772b112 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -7003,6 +7003,7 @@ static void ipr_pci_perm_failure(struct pci_dev *pdev)
ioa_cfg->sdt_state = ABORT_DUMP;
ioa_cfg->reset_retries = IPR_NUM_RESET_RELOAD_RETRIES;
ioa_cfg->in_ioa_bringdown = 1;
+ ioa_cfg->allow_cmds = 0;
ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
}
@@ -7688,7 +7689,7 @@ static void __ipr_remove(struct pci_dev *pdev)
* Return value:
* none
**/
-static void ipr_remove(struct pci_dev *pdev)
+static void __devexit ipr_remove(struct pci_dev *pdev)
{
struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev);
@@ -7864,7 +7865,7 @@ static struct pci_driver ipr_driver = {
.name = IPR_NAME,
.id_table = ipr_pci_table,
.probe = ipr_probe,
- .remove = ipr_remove,
+ .remove = __devexit_p(ipr_remove),
.shutdown = ipr_shutdown,
.err_handler = &ipr_err_handler,
};
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 747d73c5c8af..7bfbff7e0efb 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -478,7 +478,7 @@ static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
if (PTR_ERR(fp) == -FC_EX_CLOSED)
return fc_rport_error(rport, fp);
- if (rdata->retries < rdata->local_port->max_retry_count) {
+ if (rdata->retries < rdata->local_port->max_rport_retry_count) {
FC_DEBUG_RPORT("Error %ld in state %s, retrying\n",
PTR_ERR(fp), fc_rport_state(rport));
rdata->retries++;
@@ -1330,7 +1330,7 @@ int fc_rport_init(struct fc_lport *lport)
}
EXPORT_SYMBOL(fc_rport_init);
-int fc_setup_rport()
+int fc_setup_rport(void)
{
rport_event_queue = create_singlethread_workqueue("fc_rport_eq");
if (!rport_event_queue)
@@ -1339,7 +1339,7 @@ int fc_setup_rport()
}
EXPORT_SYMBOL(fc_setup_rport);
-void fc_destroy_rport()
+void fc_destroy_rport(void)
{
destroy_workqueue(rport_event_queue);
}
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index e72b4ad47d35..59908aead531 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -81,7 +81,8 @@ inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
struct Scsi_Host *shost = conn->session->host;
struct iscsi_host *ihost = shost_priv(shost);
- queue_work(ihost->workq, &conn->xmitwork);
+ if (ihost->workq)
+ queue_work(ihost->workq, &conn->xmitwork);
}
EXPORT_SYMBOL_GPL(iscsi_conn_queue_work);
@@ -109,11 +110,9 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)
* if the window closed with IO queued, then kick the
* xmit thread
*/
- if (!list_empty(&session->leadconn->xmitqueue) ||
- !list_empty(&session->leadconn->mgmtqueue)) {
- if (!(session->tt->caps & CAP_DATA_PATH_OFFLOAD))
- iscsi_conn_queue_work(session->leadconn);
- }
+ if (!list_empty(&session->leadconn->cmdqueue) ||
+ !list_empty(&session->leadconn->mgmtqueue))
+ iscsi_conn_queue_work(session->leadconn);
}
}
EXPORT_SYMBOL_GPL(iscsi_update_cmdsn);
@@ -257,9 +256,11 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
itt_t itt;
int rc;
- rc = conn->session->tt->alloc_pdu(task, ISCSI_OP_SCSI_CMD);
- if (rc)
- return rc;
+ if (conn->session->tt->alloc_pdu) {
+ rc = conn->session->tt->alloc_pdu(task, ISCSI_OP_SCSI_CMD);
+ if (rc)
+ return rc;
+ }
hdr = (struct iscsi_cmd *) task->hdr;
itt = hdr->itt;
memset(hdr, 0, sizeof(*hdr));
@@ -364,7 +365,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
return -EIO;
task->state = ISCSI_TASK_RUNNING;
- list_move_tail(&task->running, &conn->run_list);
conn->scsicmd_pdus_cnt++;
ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x "
@@ -380,26 +380,25 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
}
/**
- * iscsi_complete_command - finish a task
+ * iscsi_free_task - free a task
* @task: iscsi cmd task
*
* Must be called with session lock.
* This function returns the scsi command to scsi-ml or cleans
* up mgmt tasks then returns the task to the pool.
*/
-static void iscsi_complete_command(struct iscsi_task *task)
+static void iscsi_free_task(struct iscsi_task *task)
{
struct iscsi_conn *conn = task->conn;
struct iscsi_session *session = conn->session;
struct scsi_cmnd *sc = task->sc;
+ ISCSI_DBG_SESSION(session, "freeing task itt 0x%x state %d sc %p\n",
+ task->itt, task->state, task->sc);
+
session->tt->cleanup_task(task);
- list_del_init(&task->running);
- task->state = ISCSI_TASK_COMPLETED;
+ task->state = ISCSI_TASK_FREE;
task->sc = NULL;
-
- if (conn->task == task)
- conn->task = NULL;
/*
* login task is preallocated so do not free
*/
@@ -408,9 +407,6 @@ static void iscsi_complete_command(struct iscsi_task *task)
__kfifo_put(session->cmdpool.queue, (void*)&task, sizeof(void*));
- if (conn->ping_task == task)
- conn->ping_task = NULL;
-
if (sc) {
task->sc = NULL;
/* SCSI eh reuses commands to verify us */
@@ -433,7 +429,7 @@ EXPORT_SYMBOL_GPL(__iscsi_get_task);
static void __iscsi_put_task(struct iscsi_task *task)
{
if (atomic_dec_and_test(&task->refcount))
- iscsi_complete_command(task);
+ iscsi_free_task(task);
}
void iscsi_put_task(struct iscsi_task *task)
@@ -446,26 +442,74 @@ void iscsi_put_task(struct iscsi_task *task)
}
EXPORT_SYMBOL_GPL(iscsi_put_task);
+/**
+ * iscsi_complete_task - finish a task
+ * @task: iscsi cmd task
+ * @state: state to complete task with
+ *
+ * Must be called with session lock.
+ */
+static void iscsi_complete_task(struct iscsi_task *task, int state)
+{
+ struct iscsi_conn *conn = task->conn;
+
+ ISCSI_DBG_SESSION(conn->session,
+ "complete task itt 0x%x state %d sc %p\n",
+ task->itt, task->state, task->sc);
+ if (task->state == ISCSI_TASK_COMPLETED ||
+ task->state == ISCSI_TASK_ABRT_TMF ||
+ task->state == ISCSI_TASK_ABRT_SESS_RECOV)
+ return;
+ WARN_ON_ONCE(task->state == ISCSI_TASK_FREE);
+ task->state = state;
+
+ if (!list_empty(&task->running))
+ list_del_init(&task->running);
+
+ if (conn->task == task)
+ conn->task = NULL;
+
+ if (conn->ping_task == task)
+ conn->ping_task = NULL;
+
+ /* release get from queueing */
+ __iscsi_put_task(task);
+}
+
/*
- * session lock must be held
+ * session lock must be held and if not called for a task that is
+ * still pending or from the xmit thread, then xmit thread must
+ * be suspended.
*/
-static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task,
- int err)
+static void fail_scsi_task(struct iscsi_task *task, int err)
{
+ struct iscsi_conn *conn = task->conn;
struct scsi_cmnd *sc;
+ int state;
+ /*
+ * if a command completes and we get a successful tmf response
+ * we will hit this because the scsi eh abort code does not take
+ * a ref to the task.
+ */
sc = task->sc;
if (!sc)
return;
- if (task->state == ISCSI_TASK_PENDING)
+ if (task->state == ISCSI_TASK_PENDING) {
/*
* cmd never made it to the xmit thread, so we should not count
* the cmd in the sequencing
*/
conn->session->queued_cmdsn--;
+ /* it was never sent so just complete like normal */
+ state = ISCSI_TASK_COMPLETED;
+ } else if (err == DID_TRANSPORT_DISRUPTED)
+ state = ISCSI_TASK_ABRT_SESS_RECOV;
+ else
+ state = ISCSI_TASK_ABRT_TMF;
- sc->result = err;
+ sc->result = err << 16;
if (!scsi_bidi_cmnd(sc))
scsi_set_resid(sc, scsi_bufflen(sc));
else {
@@ -473,10 +517,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task,
scsi_in(sc)->resid = scsi_in(sc)->length;
}
- if (conn->task == task)
- conn->task = NULL;
- /* release ref from queuecommand */
- __iscsi_put_task(task);
+ iscsi_complete_task(task, state);
}
static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
@@ -516,7 +557,6 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
session->state = ISCSI_STATE_LOGGING_OUT;
task->state = ISCSI_TASK_RUNNING;
- list_move_tail(&task->running, &conn->mgmt_run_list);
ISCSI_DBG_SESSION(session, "mgmtpdu [op 0x%x hdr->itt 0x%x "
"datalen %d]\n", hdr->opcode & ISCSI_OPCODE_MASK,
hdr->itt, task->data_count);
@@ -528,6 +568,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size)
{
struct iscsi_session *session = conn->session;
+ struct iscsi_host *ihost = shost_priv(session->host);
struct iscsi_task *task;
itt_t itt;
@@ -544,6 +585,9 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
*/
task = conn->login_task;
else {
+ if (session->state != ISCSI_STATE_LOGGED_IN)
+ return NULL;
+
BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
@@ -559,6 +603,8 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
atomic_set(&task->refcount, 1);
task->conn = conn;
task->sc = NULL;
+ INIT_LIST_HEAD(&task->running);
+ task->state = ISCSI_TASK_PENDING;
if (data_size) {
memcpy(task->data, data, data_size);
@@ -566,11 +612,14 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
} else
task->data_count = 0;
- if (conn->session->tt->alloc_pdu(task, hdr->opcode)) {
- iscsi_conn_printk(KERN_ERR, conn, "Could not allocate "
- "pdu for mgmt task.\n");
- goto requeue_task;
+ if (conn->session->tt->alloc_pdu) {
+ if (conn->session->tt->alloc_pdu(task, hdr->opcode)) {
+ iscsi_conn_printk(KERN_ERR, conn, "Could not allocate "
+ "pdu for mgmt task.\n");
+ goto free_task;
+ }
}
+
itt = task->hdr->itt;
task->hdr_len = sizeof(struct iscsi_hdr);
memcpy(task->hdr, hdr, sizeof(struct iscsi_hdr));
@@ -583,30 +632,22 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
task->conn->session->age);
}
- INIT_LIST_HEAD(&task->running);
- list_add_tail(&task->running, &conn->mgmtqueue);
-
- if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) {
+ if (!ihost->workq) {
if (iscsi_prep_mgmt_task(conn, task))
goto free_task;
if (session->tt->xmit_task(task))
goto free_task;
-
- } else
+ } else {
+ list_add_tail(&task->running, &conn->mgmtqueue);
iscsi_conn_queue_work(conn);
+ }
return task;
free_task:
__iscsi_put_task(task);
return NULL;
-
-requeue_task:
- if (task != conn->login_task)
- __kfifo_put(session->cmdpool.queue, (void*)&task,
- sizeof(void*));
- return NULL;
}
int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
@@ -701,11 +742,10 @@ invalid_datalen:
sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
}
out:
- ISCSI_DBG_SESSION(session, "done [sc %p res %d itt 0x%x]\n",
+ ISCSI_DBG_SESSION(session, "cmd rsp done [sc %p res %d itt 0x%x]\n",
sc, sc->result, task->itt);
conn->scsirsp_pdus_cnt++;
-
- __iscsi_put_task(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
}
/**
@@ -724,6 +764,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
if (!(rhdr->flags & ISCSI_FLAG_DATA_STATUS))
return;
+ iscsi_update_cmdsn(conn->session, (struct iscsi_nopin *)hdr);
sc->result = (DID_OK << 16) | rhdr->cmd_status;
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
@@ -738,8 +779,11 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
}
+ ISCSI_DBG_SESSION(conn->session, "data in with status done "
+ "[sc %p res %d itt 0x%x]\n",
+ sc, sc->result, task->itt);
conn->scsirsp_pdus_cnt++;
- __iscsi_put_task(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
}
static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
@@ -823,7 +867,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
*
* The session lock must be held.
*/
-static struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
+struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
{
struct iscsi_session *session = conn->session;
int i;
@@ -840,6 +884,7 @@ static struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
return session->cmds[i];
}
+EXPORT_SYMBOL_GPL(iscsi_itt_to_task);
/**
* __iscsi_complete_pdu - complete pdu
@@ -959,7 +1004,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
}
iscsi_tmf_rsp(conn, hdr);
- __iscsi_put_task(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
break;
case ISCSI_OP_NOOP_IN:
iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr);
@@ -977,7 +1022,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
goto recv_pdu;
mod_timer(&conn->transport_timer, jiffies + conn->recv_timeout);
- __iscsi_put_task(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
break;
default:
rc = ISCSI_ERR_BAD_OPCODE;
@@ -989,7 +1034,7 @@ out:
recv_pdu:
if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
rc = ISCSI_ERR_CONN_FAILED;
- __iscsi_put_task(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
return rc;
}
EXPORT_SYMBOL_GPL(__iscsi_complete_pdu);
@@ -1166,7 +1211,12 @@ void iscsi_requeue_task(struct iscsi_task *task)
{
struct iscsi_conn *conn = task->conn;
- list_move_tail(&task->running, &conn->requeue);
+ /*
+ * this may be on the requeue list already if the xmit_task callout
+ * is handling the r2ts while we are adding new ones
+ */
+ if (list_empty(&task->running))
+ list_add_tail(&task->running, &conn->requeue);
iscsi_conn_queue_work(conn);
}
EXPORT_SYMBOL_GPL(iscsi_requeue_task);
@@ -1206,6 +1256,7 @@ check_mgmt:
while (!list_empty(&conn->mgmtqueue)) {
conn->task = list_entry(conn->mgmtqueue.next,
struct iscsi_task, running);
+ list_del_init(&conn->task->running);
if (iscsi_prep_mgmt_task(conn, conn->task)) {
__iscsi_put_task(conn->task);
conn->task = NULL;
@@ -1217,23 +1268,26 @@ check_mgmt:
}
/* process pending command queue */
- while (!list_empty(&conn->xmitqueue)) {
+ while (!list_empty(&conn->cmdqueue)) {
if (conn->tmf_state == TMF_QUEUED)
break;
- conn->task = list_entry(conn->xmitqueue.next,
+ conn->task = list_entry(conn->cmdqueue.next,
struct iscsi_task, running);
+ list_del_init(&conn->task->running);
if (conn->session->state == ISCSI_STATE_LOGGING_OUT) {
- fail_command(conn, conn->task, DID_IMM_RETRY << 16);
+ fail_scsi_task(conn->task, DID_IMM_RETRY);
continue;
}
rc = iscsi_prep_scsi_cmd_pdu(conn->task);
if (rc) {
if (rc == -ENOMEM) {
+ list_add_tail(&conn->task->running,
+ &conn->cmdqueue);
conn->task = NULL;
goto again;
} else
- fail_command(conn, conn->task, DID_ABORT << 16);
+ fail_scsi_task(conn->task, DID_ABORT);
continue;
}
rc = iscsi_xmit_task(conn);
@@ -1260,8 +1314,8 @@ check_mgmt:
conn->task = list_entry(conn->requeue.next,
struct iscsi_task, running);
+ list_del_init(&conn->task->running);
conn->task->state = ISCSI_TASK_RUNNING;
- list_move_tail(conn->requeue.next, &conn->run_list);
rc = iscsi_xmit_task(conn);
if (rc)
goto again;
@@ -1328,6 +1382,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
{
struct iscsi_cls_session *cls_session;
struct Scsi_Host *host;
+ struct iscsi_host *ihost;
int reason = 0;
struct iscsi_session *session;
struct iscsi_conn *conn;
@@ -1338,6 +1393,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
sc->SCp.ptr = NULL;
host = sc->device->host;
+ ihost = shost_priv(host);
spin_unlock(host->host_lock);
cls_session = starget_to_session(scsi_target(sc->device));
@@ -1350,13 +1406,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
goto fault;
}
- /*
- * ISCSI_STATE_FAILED is a temp. state. The recovery
- * code will decide what is best to do with command queued
- * during this time
- */
- if (session->state != ISCSI_STATE_LOGGED_IN &&
- session->state != ISCSI_STATE_FAILED) {
+ if (session->state != ISCSI_STATE_LOGGED_IN) {
/*
* to handle the race between when we set the recovery state
* and block the session we requeue here (commands could
@@ -1364,12 +1414,15 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
* up because the block code is not locked)
*/
switch (session->state) {
+ case ISCSI_STATE_FAILED:
case ISCSI_STATE_IN_RECOVERY:
reason = FAILURE_SESSION_IN_RECOVERY;
- goto reject;
+ sc->result = DID_IMM_RETRY << 16;
+ break;
case ISCSI_STATE_LOGGING_OUT:
reason = FAILURE_SESSION_LOGGING_OUT;
- goto reject;
+ sc->result = DID_IMM_RETRY << 16;
+ break;
case ISCSI_STATE_RECOVERY_FAILED:
reason = FAILURE_SESSION_RECOVERY_TIMEOUT;
sc->result = DID_TRANSPORT_FAILFAST << 16;
@@ -1402,9 +1455,8 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
reason = FAILURE_OOM;
goto reject;
}
- list_add_tail(&task->running, &conn->xmitqueue);
- if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) {
+ if (!ihost->workq) {
reason = iscsi_prep_scsi_cmd_pdu(task);
if (reason) {
if (reason == -ENOMEM) {
@@ -1419,8 +1471,10 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
reason = FAILURE_SESSION_NOT_READY;
goto prepd_reject;
}
- } else
+ } else {
+ list_add_tail(&task->running, &conn->cmdqueue);
iscsi_conn_queue_work(conn);
+ }
session->queued_cmdsn++;
spin_unlock(&session->lock);
@@ -1429,7 +1483,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
prepd_reject:
sc->scsi_done = NULL;
- iscsi_complete_command(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
reject:
spin_unlock(&session->lock);
ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n",
@@ -1439,7 +1493,7 @@ reject:
prepd_fault:
sc->scsi_done = NULL;
- iscsi_complete_command(task);
+ iscsi_complete_task(task, ISCSI_TASK_COMPLETED);
fault:
spin_unlock(&session->lock);
ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n",
@@ -1608,44 +1662,24 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
* Fail commands. session lock held and recv side suspended and xmit
* thread flushed
*/
-static void fail_all_commands(struct iscsi_conn *conn, unsigned lun,
- int error)
+static void fail_scsi_tasks(struct iscsi_conn *conn, unsigned lun,
+ int error)
{
- struct iscsi_task *task, *tmp;
-
- if (conn->task) {
- if (lun == -1 ||
- (conn->task->sc && conn->task->sc->device->lun == lun))
- conn->task = NULL;
- }
+ struct iscsi_task *task;
+ int i;
- /* flush pending */
- list_for_each_entry_safe(task, tmp, &conn->xmitqueue, running) {
- if (lun == task->sc->device->lun || lun == -1) {
- ISCSI_DBG_SESSION(conn->session,
- "failing pending sc %p itt 0x%x\n",
- task->sc, task->itt);
- fail_command(conn, task, error << 16);
- }
- }
+ for (i = 0; i < conn->session->cmds_max; i++) {
+ task = conn->session->cmds[i];
+ if (!task->sc || task->state == ISCSI_TASK_FREE)
+ continue;
- list_for_each_entry_safe(task, tmp, &conn->requeue, running) {
- if (lun == task->sc->device->lun || lun == -1) {
- ISCSI_DBG_SESSION(conn->session,
- "failing requeued sc %p itt 0x%x\n",
- task->sc, task->itt);
- fail_command(conn, task, error << 16);
- }
- }
+ if (lun != -1 && lun != task->sc->device->lun)
+ continue;
- /* fail all other running */
- list_for_each_entry_safe(task, tmp, &conn->run_list, running) {
- if (lun == task->sc->device->lun || lun == -1) {
- ISCSI_DBG_SESSION(conn->session,
- "failing in progress sc %p itt 0x%x\n",
- task->sc, task->itt);
- fail_command(conn, task, error << 16);
- }
+ ISCSI_DBG_SESSION(conn->session,
+ "failing sc %p itt 0x%x state %d\n",
+ task->sc, task->itt, task->state);
+ fail_scsi_task(task, error);
}
}
@@ -1655,7 +1689,7 @@ void iscsi_suspend_tx(struct iscsi_conn *conn)
struct iscsi_host *ihost = shost_priv(shost);
set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
- if (!(conn->session->tt->caps & CAP_DATA_PATH_OFFLOAD))
+ if (ihost->workq)
flush_workqueue(ihost->workq);
}
EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
@@ -1663,8 +1697,23 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
static void iscsi_start_tx(struct iscsi_conn *conn)
{
clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
- if (!(conn->session->tt->caps & CAP_DATA_PATH_OFFLOAD))
- iscsi_conn_queue_work(conn);
+ iscsi_conn_queue_work(conn);
+}
+
+/*
+ * We want to make sure a ping is in flight. It has timed out.
+ * And we are not busy processing a pdu that is making
+ * progress but got started before the ping and is taking a while
+ * to complete so the ping is just stuck behind it in a queue.
+ */
+static int iscsi_has_ping_timed_out(struct iscsi_conn *conn)
+{
+ if (conn->ping_task &&
+ time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) +
+ (conn->ping_timeout * HZ), jiffies))
+ return 1;
+ else
+ return 0;
}
static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
@@ -1702,16 +1751,20 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
* if the ping timedout then we are in the middle of cleaning up
* and can let the iscsi eh handle it
*/
- if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) +
- (conn->ping_timeout * HZ), jiffies))
+ if (iscsi_has_ping_timed_out(conn)) {
rc = BLK_EH_RESET_TIMER;
+ goto done;
+ }
/*
* if we are about to check the transport then give the command
* more time
*/
if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ),
- jiffies))
+ jiffies)) {
rc = BLK_EH_RESET_TIMER;
+ goto done;
+ }
+
/* if in the middle of checking the transport then give us more time */
if (conn->ping_task)
rc = BLK_EH_RESET_TIMER;
@@ -1738,13 +1791,13 @@ static void iscsi_check_transport_timeouts(unsigned long data)
recv_timeout *= HZ;
last_recv = conn->last_recv;
- if (conn->ping_task &&
- time_before_eq(conn->last_ping + (conn->ping_timeout * HZ),
- jiffies)) {
+
+ if (iscsi_has_ping_timed_out(conn)) {
iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
- "expired, last rx %lu, last ping %lu, "
- "now %lu\n", conn->ping_timeout, last_recv,
- conn->last_ping, jiffies);
+ "expired, recv timeout %d, last rx %lu, "
+ "last ping %lu, now %lu\n",
+ conn->ping_timeout, conn->recv_timeout,
+ last_recv, conn->last_ping, jiffies);
spin_unlock(&session->lock);
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
return;
@@ -1788,6 +1841,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data;
+ ISCSI_DBG_SESSION(session, "aborting sc %p\n", sc);
+
mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock);
/*
@@ -1810,6 +1865,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
sc->SCp.phase != session->age) {
spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex);
+ ISCSI_DBG_SESSION(session, "failing abort due to dropped "
+ "session.\n");
return FAILED;
}
@@ -1829,7 +1886,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
}
if (task->state == ISCSI_TASK_PENDING) {
- fail_command(conn, task, DID_ABORT << 16);
+ fail_scsi_task(task, DID_ABORT);
goto success;
}
@@ -1860,7 +1917,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
* then sent more data for the cmd.
*/
spin_lock(&session->lock);
- fail_command(conn, task, DID_ABORT << 16);
+ fail_scsi_task(task, DID_ABORT);
conn->tmf_state = TMF_INITIAL;
spin_unlock(&session->lock);
iscsi_start_tx(conn);
@@ -1967,7 +2024,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
iscsi_suspend_tx(conn);
spin_lock_bh(&session->lock);
- fail_all_commands(conn, sc->device->lun, DID_ERROR);
+ fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
conn->tmf_state = TMF_INITIAL;
spin_unlock_bh(&session->lock);
@@ -2274,6 +2331,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
if (cmd_task_size)
task->dd_data = &task[1];
task->itt = cmd_i;
+ task->state = ISCSI_TASK_FREE;
INIT_LIST_HEAD(&task->running);
}
@@ -2360,10 +2418,8 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
conn->transport_timer.data = (unsigned long)conn;
conn->transport_timer.function = iscsi_check_transport_timeouts;
- INIT_LIST_HEAD(&conn->run_list);
- INIT_LIST_HEAD(&conn->mgmt_run_list);
INIT_LIST_HEAD(&conn->mgmtqueue);
- INIT_LIST_HEAD(&conn->xmitqueue);
+ INIT_LIST_HEAD(&conn->cmdqueue);
INIT_LIST_HEAD(&conn->requeue);
INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
@@ -2531,27 +2587,28 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
EXPORT_SYMBOL_GPL(iscsi_conn_start);
static void
-flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn)
+fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn)
{
- struct iscsi_task *task, *tmp;
+ struct iscsi_task *task;
+ int i, state;
- /* handle pending */
- list_for_each_entry_safe(task, tmp, &conn->mgmtqueue, running) {
- ISCSI_DBG_SESSION(session, "flushing pending mgmt task "
- "itt 0x%x\n", task->itt);
- /* release ref from prep task */
- __iscsi_put_task(task);
- }
+ for (i = 0; i < conn->session->cmds_max; i++) {
+ task = conn->session->cmds[i];
+ if (task->sc)
+ continue;
- /* handle running */
- list_for_each_entry_safe(task, tmp, &conn->mgmt_run_list, running) {
- ISCSI_DBG_SESSION(session, "flushing running mgmt task "
- "itt 0x%x\n", task->itt);
- /* release ref from prep task */
- __iscsi_put_task(task);
- }
+ if (task->state == ISCSI_TASK_FREE)
+ continue;
+
+ ISCSI_DBG_SESSION(conn->session,
+ "failing mgmt itt 0x%x state %d\n",
+ task->itt, task->state);
+ state = ISCSI_TASK_ABRT_SESS_RECOV;
+ if (task->state == ISCSI_TASK_PENDING)
+ state = ISCSI_TASK_COMPLETED;
+ iscsi_complete_task(task, state);
- conn->task = NULL;
+ }
}
static void iscsi_start_session_recovery(struct iscsi_session *session,
@@ -2559,8 +2616,6 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
{
int old_stop_stage;
- del_timer_sync(&conn->transport_timer);
-
mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock);
if (conn->stop_stage == STOP_CONN_TERM) {
@@ -2578,13 +2633,17 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
session->state = ISCSI_STATE_TERMINATE;
else if (conn->stop_stage != STOP_CONN_RECOVER)
session->state = ISCSI_STATE_IN_RECOVERY;
+ spin_unlock_bh(&session->lock);
+
+ del_timer_sync(&conn->transport_timer);
+ iscsi_suspend_tx(conn);
+ spin_lock_bh(&session->lock);
old_stop_stage = conn->stop_stage;
conn->stop_stage = flag;
conn->c_stage = ISCSI_CONN_STOPPED;
spin_unlock_bh(&session->lock);
- iscsi_suspend_tx(conn);
/*
* for connection level recovery we should not calculate
* header digest. conn->hdr_size used for optimization
@@ -2605,11 +2664,8 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
* flush queues.
*/
spin_lock_bh(&session->lock);
- if (flag == STOP_CONN_RECOVER)
- fail_all_commands(conn, -1, DID_TRANSPORT_DISRUPTED);
- else
- fail_all_commands(conn, -1, DID_ERROR);
- flush_control_queues(session, conn);
+ fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED);
+ fail_mgmt_tasks(session, conn);
spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex);
}
@@ -2651,6 +2707,23 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
}
EXPORT_SYMBOL_GPL(iscsi_conn_bind);
+static int iscsi_switch_str_param(char **param, char *new_val_buf)
+{
+ char *new_val;
+
+ if (*param) {
+ if (!strcmp(*param, new_val_buf))
+ return 0;
+ }
+
+ new_val = kstrdup(new_val_buf, GFP_NOIO);
+ if (!new_val)
+ return -ENOMEM;
+
+ kfree(*param);
+ *param = new_val;
+ return 0;
+}
int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
enum iscsi_param param, char *buf, int buflen)
@@ -2723,38 +2796,15 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
sscanf(buf, "%u", &conn->exp_statsn);
break;
case ISCSI_PARAM_USERNAME:
- kfree(session->username);
- session->username = kstrdup(buf, GFP_KERNEL);
- if (!session->username)
- return -ENOMEM;
- break;
+ return iscsi_switch_str_param(&session->username, buf);
case ISCSI_PARAM_USERNAME_IN:
- kfree(session->username_in);
- session->username_in = kstrdup(buf, GFP_KERNEL);
- if (!session->username_in)
- return -ENOMEM;
- break;
+ return iscsi_switch_str_param(&session->username_in, buf);
case ISCSI_PARAM_PASSWORD:
- kfree(session->password);
- session->password = kstrdup(buf, GFP_KERNEL);
- if (!session->password)
- return -ENOMEM;
- break;
+ return iscsi_switch_str_param(&session->password, buf);
case ISCSI_PARAM_PASSWORD_IN:
- kfree(session->password_in);
- session->password_in = kstrdup(buf, GFP_KERNEL);
- if (!session->password_in)
- return -ENOMEM;
- break;
+ return iscsi_switch_str_param(&session->password_in, buf);
case ISCSI_PARAM_TARGET_NAME:
- /* this should not change between logins */
- if (session->targetname)
- break;
-
- session->targetname = kstrdup(buf, GFP_KERNEL);
- if (!session->targetname)
- return -ENOMEM;
- break;
+ return iscsi_switch_str_param(&session->targetname, buf);
case ISCSI_PARAM_TPGT:
sscanf(buf, "%d", &session->tpgt);
break;
@@ -2762,25 +2812,11 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
sscanf(buf, "%d", &conn->persistent_port);
break;
case ISCSI_PARAM_PERSISTENT_ADDRESS:
- /*
- * this is the address returned in discovery so it should
- * not change between logins.
- */
- if (conn->persistent_address)
- break;
-
- conn->persistent_address = kstrdup(buf, GFP_KERNEL);
- if (!conn->persistent_address)
- return -ENOMEM;
- break;
+ return iscsi_switch_str_param(&conn->persistent_address, buf);
case ISCSI_PARAM_IFACE_NAME:
- if (!session->ifacename)
- session->ifacename = kstrdup(buf, GFP_KERNEL);
- break;
+ return iscsi_switch_str_param(&session->ifacename, buf);
case ISCSI_PARAM_INITIATOR_NAME:
- if (!session->initiatorname)
- session->initiatorname = kstrdup(buf, GFP_KERNEL);
- break;
+ return iscsi_switch_str_param(&session->initiatorname, buf);
default:
return -ENOSYS;
}
@@ -2851,10 +2887,7 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
len = sprintf(buf, "%s\n", session->ifacename);
break;
case ISCSI_PARAM_INITIATOR_NAME:
- if (!session->initiatorname)
- len = sprintf(buf, "%s\n", "unknown");
- else
- len = sprintf(buf, "%s\n", session->initiatorname);
+ len = sprintf(buf, "%s\n", session->initiatorname);
break;
default:
return -ENOSYS;
@@ -2920,29 +2953,16 @@ int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,
switch (param) {
case ISCSI_HOST_PARAM_NETDEV_NAME:
- if (!ihost->netdev)
- len = sprintf(buf, "%s\n", "default");
- else
- len = sprintf(buf, "%s\n", ihost->netdev);
+ len = sprintf(buf, "%s\n", ihost->netdev);
break;
case ISCSI_HOST_PARAM_HWADDRESS:
- if (!ihost->hwaddress)
- len = sprintf(buf, "%s\n", "default");
- else
- len = sprintf(buf, "%s\n", ihost->hwaddress);
+ len = sprintf(buf, "%s\n", ihost->hwaddress);
break;
case ISCSI_HOST_PARAM_INITIATOR_NAME:
- if (!ihost->initiatorname)
- len = sprintf(buf, "%s\n", "unknown");
- else
- len = sprintf(buf, "%s\n", ihost->initiatorname);
+ len = sprintf(buf, "%s\n", ihost->initiatorname);
break;
case ISCSI_HOST_PARAM_IPADDRESS:
- if (!strlen(ihost->local_address))
- len = sprintf(buf, "%s\n", "unknown");
- else
- len = sprintf(buf, "%s\n",
- ihost->local_address);
+ len = sprintf(buf, "%s\n", ihost->local_address);
break;
default:
return -ENOSYS;
@@ -2959,17 +2979,11 @@ int iscsi_host_set_param(struct Scsi_Host *shost, enum iscsi_host_param param,
switch (param) {
case ISCSI_HOST_PARAM_NETDEV_NAME:
- if (!ihost->netdev)
- ihost->netdev = kstrdup(buf, GFP_KERNEL);
- break;
+ return iscsi_switch_str_param(&ihost->netdev, buf);
case ISCSI_HOST_PARAM_HWADDRESS:
- if (!ihost->hwaddress)
- ihost->hwaddress = kstrdup(buf, GFP_KERNEL);
- break;
+ return iscsi_switch_str_param(&ihost->hwaddress, buf);
case ISCSI_HOST_PARAM_INITIATOR_NAME:
- if (!ihost->initiatorname)
- ihost->initiatorname = kstrdup(buf, GFP_KERNEL);
- break;
+ return iscsi_switch_str_param(&ihost->initiatorname, buf);
default:
return -ENOSYS;
}
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index b579ca9f4836..2bc07090321d 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -440,8 +440,8 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
struct iscsi_tcp_task *tcp_task = task->dd_data;
struct iscsi_r2t_info *r2t;
- /* nothing to do for mgmt or pending tasks */
- if (!task->sc || task->state == ISCSI_TASK_PENDING)
+ /* nothing to do for mgmt */
+ if (!task->sc)
return;
/* flush task's r2t queues */
@@ -473,7 +473,13 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
int datasn = be32_to_cpu(rhdr->datasn);
unsigned total_in_length = scsi_in(task->sc)->length;
- iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr);
+ /*
+ * lib iscsi will update this in the completion handling if there
+ * is status.
+ */
+ if (!(rhdr->flags & ISCSI_FLAG_DATA_STATUS))
+ iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr);
+
if (tcp_conn->in.datalen == 0)
return 0;
@@ -857,6 +863,12 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
int rc = 0;
ISCSI_DBG_TCP(conn, "in %d bytes\n", skb->len - offset);
+ /*
+ * Update for each skb instead of pdu, because over slow networks a
+ * data_in's data could take a while to read in. We also want to
+ * account for r2ts.
+ */
+ conn->last_recv = jiffies;
if (unlikely(conn->suspend_rx)) {
ISCSI_DBG_TCP(conn, "Rx suspended!\n");
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 3da02e436788..54fa1e42dc4d 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1927,21 +1927,21 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
/* do we need to support multiple segments? */
if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
printk("%s: multiple segments req %u %u, rsp %u %u\n",
- __func__, req->bio->bi_vcnt, req->data_len,
- rsp->bio->bi_vcnt, rsp->data_len);
+ __func__, req->bio->bi_vcnt, blk_rq_bytes(req),
+ rsp->bio->bi_vcnt, blk_rq_bytes(rsp));
return -EINVAL;
}
- ret = smp_execute_task(dev, bio_data(req->bio), req->data_len,
- bio_data(rsp->bio), rsp->data_len);
+ ret = smp_execute_task(dev, bio_data(req->bio), blk_rq_bytes(req),
+ bio_data(rsp->bio), blk_rq_bytes(rsp));
if (ret > 0) {
/* positive number is the untransferred residual */
- rsp->data_len = ret;
- req->data_len = 0;
+ rsp->resid_len = ret;
+ req->resid_len = 0;
ret = 0;
} else if (ret == 0) {
- rsp->data_len = 0;
- req->data_len = 0;
+ rsp->resid_len = 0;
+ req->resid_len = 0;
}
return ret;
diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c
index d110a366c48a..1bc3b7567994 100644
--- a/drivers/scsi/libsas/sas_host_smp.c
+++ b/drivers/scsi/libsas/sas_host_smp.c
@@ -134,24 +134,24 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
{
u8 *req_data = NULL, *resp_data = NULL, *buf;
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
- int error = -EINVAL, resp_data_len = rsp->data_len;
+ int error = -EINVAL;
/* eight is the minimum size for request and response frames */
- if (req->data_len < 8 || rsp->data_len < 8)
+ if (blk_rq_bytes(req) < 8 || blk_rq_bytes(rsp) < 8)
goto out;
- if (bio_offset(req->bio) + req->data_len > PAGE_SIZE ||
- bio_offset(rsp->bio) + rsp->data_len > PAGE_SIZE) {
+ if (bio_offset(req->bio) + blk_rq_bytes(req) > PAGE_SIZE ||
+ bio_offset(rsp->bio) + blk_rq_bytes(rsp) > PAGE_SIZE) {
shost_printk(KERN_ERR, shost,
"SMP request/response frame crosses page boundary");
goto out;
}
- req_data = kzalloc(req->data_len, GFP_KERNEL);
+ req_data = kzalloc(blk_rq_bytes(req), GFP_KERNEL);
/* make sure frame can always be built ... we copy
* back only the requested length */
- resp_data = kzalloc(max(rsp->data_len, 128U), GFP_KERNEL);
+ resp_data = kzalloc(max(blk_rq_bytes(rsp), 128U), GFP_KERNEL);
if (!req_data || !resp_data) {
error = -ENOMEM;
@@ -160,7 +160,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
local_irq_disable();
buf = kmap_atomic(bio_page(req->bio), KM_USER0) + bio_offset(req->bio);
- memcpy(req_data, buf, req->data_len);
+ memcpy(req_data, buf, blk_rq_bytes(req));
kunmap_atomic(buf - bio_offset(req->bio), KM_USER0);
local_irq_enable();
@@ -178,15 +178,15 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
switch (req_data[1]) {
case SMP_REPORT_GENERAL:
- req->data_len -= 8;
- resp_data_len -= 32;
+ req->resid_len -= 8;
+ rsp->resid_len -= 32;
resp_data[2] = SMP_RESP_FUNC_ACC;
resp_data[9] = sas_ha->num_phys;
break;
case SMP_REPORT_MANUF_INFO:
- req->data_len -= 8;
- resp_data_len -= 64;
+ req->resid_len -= 8;
+ rsp->resid_len -= 64;
resp_data[2] = SMP_RESP_FUNC_ACC;
memcpy(resp_data + 12, shost->hostt->name,
SAS_EXPANDER_VENDOR_ID_LEN);
@@ -199,13 +199,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
break;
case SMP_DISCOVER:
- req->data_len -= 16;
- if ((int)req->data_len < 0) {
- req->data_len = 0;
+ req->resid_len -= 16;
+ if ((int)req->resid_len < 0) {
+ req->resid_len = 0;
error = -EINVAL;
goto out;
}
- resp_data_len -= 56;
+ rsp->resid_len -= 56;
sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
break;
@@ -215,13 +215,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
break;
case SMP_REPORT_PHY_SATA:
- req->data_len -= 16;
- if ((int)req->data_len < 0) {
- req->data_len = 0;
+ req->resid_len -= 16;
+ if ((int)req->resid_len < 0) {
+ req->resid_len = 0;
error = -EINVAL;
goto out;
}
- resp_data_len -= 60;
+ rsp->resid_len -= 60;
sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
break;
@@ -238,13 +238,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
break;
case SMP_PHY_CONTROL:
- req->data_len -= 44;
- if ((int)req->data_len < 0) {
- req->data_len = 0;
+ req->resid_len -= 44;
+ if ((int)req->resid_len < 0) {
+ req->resid_len = 0;
error = -EINVAL;
goto out;
}
- resp_data_len -= 8;
+ rsp->resid_len -= 8;
sas_phy_control(sas_ha, req_data[9], req_data[10],
req_data[32] >> 4, req_data[33] >> 4,
resp_data);
@@ -261,11 +261,10 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
local_irq_disable();
buf = kmap_atomic(bio_page(rsp->bio), KM_USER0) + bio_offset(rsp->bio);
- memcpy(buf, resp_data, rsp->data_len);
+ memcpy(buf, resp_data, blk_rq_bytes(rsp));
flush_kernel_dcache_page(bio_page(rsp->bio));
kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
local_irq_enable();
- rsp->data_len = resp_data_len;
out:
kfree(req_data);
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 15e2d132e8b9..2742ae8a3d09 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -135,7 +135,7 @@ int srp_target_alloc(struct srp_target *target, struct device *dev,
INIT_LIST_HEAD(&target->cmd_queue);
target->dev = dev;
- target->dev->driver_data = target;
+ dev_set_drvdata(target->dev, target);
target->srp_iu_size = iu_size;
target->rx_ring_size = nr;
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 167b66dd34c7..679adfff0bf8 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -827,8 +827,8 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc)
* @reftag: out: ref tag (reference tag)
*
* Description:
- * Extract DIF paramters from the command if possible. Otherwise,
- * use default paratmers.
+ * Extract DIF parameters from the command if possible. Otherwise,
+ * use default parameters.
*
**/
static inline void
@@ -1312,10 +1312,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
uint32_t bgstat = bgf->bgstat;
uint64_t failing_sector = 0;
- printk(KERN_ERR "BG ERROR in cmd 0x%x lba 0x%llx blk cnt 0x%lx "
+ printk(KERN_ERR "BG ERROR in cmd 0x%x lba 0x%llx blk cnt 0x%x "
"bgstat=0x%x bghm=0x%x\n",
cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd),
- cmd->request->nr_sectors, bgstat, bghm);
+ blk_rq_sectors(cmd->request), bgstat, bghm);
spin_lock(&_dump_buf_lock);
if (!_dump_buf_done) {
@@ -2378,15 +2378,15 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
if (cmnd->cmnd[0] == READ_10)
lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
"9035 BLKGRD: READ @ sector %llu, "
- "count %lu\n",
- (unsigned long long)scsi_get_lba(cmnd),
- cmnd->request->nr_sectors);
+ "count %u\n",
+ (unsigned long long)scsi_get_lba(cmnd),
+ blk_rq_sectors(cmnd->request));
else if (cmnd->cmnd[0] == WRITE_10)
lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
"9036 BLKGRD: WRITE @ sector %llu, "
- "count %lu cmd=%p\n",
+ "count %u cmd=%p\n",
(unsigned long long)scsi_get_lba(cmnd),
- cmnd->request->nr_sectors,
+ blk_rq_sectors(cmnd->request),
cmnd);
err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
@@ -2406,15 +2406,15 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
if (cmnd->cmnd[0] == READ_10)
lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
"9040 dbg: READ @ sector %llu, "
- "count %lu\n",
+ "count %u\n",
(unsigned long long)scsi_get_lba(cmnd),
- cmnd->request->nr_sectors);
+ blk_rq_sectors(cmnd->request));
else if (cmnd->cmnd[0] == WRITE_10)
lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
"9041 dbg: WRITE @ sector %llu, "
- "count %lu cmd=%p\n",
+ "count %u cmd=%p\n",
(unsigned long long)scsi_get_lba(cmnd),
- cmnd->request->nr_sectors, cmnd);
+ blk_rq_sectors(cmnd->request), cmnd);
else
lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
"9042 dbg: parser not implemented\n");
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 795201fa0b48..512c2cc1a33f 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -469,7 +469,7 @@ typedef struct {
u8 type; /* Type of the device */
u8 cur_status; /* current status of the device */
u8 tag_depth; /* Level of tagging */
- u8 sync_neg; /* sync negotiation - ENABLE or DISBALE */
+ u8 sync_neg; /* sync negotiation - ENABLE or DISABLE */
u32 size; /* configurable size in terms of 512 byte
blocks */
}__attribute__ ((packed)) phys_drv;
diff --git a/drivers/scsi/megaraid/mbox_defs.h b/drivers/scsi/megaraid/mbox_defs.h
index 170399ef06f4..b25b74764ec3 100644
--- a/drivers/scsi/megaraid/mbox_defs.h
+++ b/drivers/scsi/megaraid/mbox_defs.h
@@ -686,7 +686,7 @@ typedef struct {
* @type : Type of the device
* @cur_status : current status of the device
* @tag_depth : Level of tagging
- * @sync_neg : sync negotiation - ENABLE or DISBALE
+ * @sync_neg : sync negotiation - ENABLE or DISABLE
* @size : configurable size in terms of 512 byte
*/
typedef struct {
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
index babd4cc0cb25..286c185fa9e4 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -61,6 +61,7 @@
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_transport_sas.h>
#include <scsi/scsi_dbg.h>
+#include <scsi/scsi_eh.h>
#include "mpt2sas_debug.h"
@@ -68,10 +69,10 @@
#define MPT2SAS_DRIVER_NAME "mpt2sas"
#define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
#define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
-#define MPT2SAS_DRIVER_VERSION "01.100.02.00"
-#define MPT2SAS_MAJOR_VERSION 00
+#define MPT2SAS_DRIVER_VERSION "01.100.03.00"
+#define MPT2SAS_MAJOR_VERSION 01
#define MPT2SAS_MINOR_VERSION 100
-#define MPT2SAS_BUILD_VERSION 02
+#define MPT2SAS_BUILD_VERSION 03
#define MPT2SAS_RELEASE_VERSION 00
/*
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index ba6ab170bdf0..14e473d1fa7b 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -473,7 +473,7 @@ _ctl_poll(struct file *filep, poll_table *wait)
}
/**
- * _ctl_do_task_abort - assign an active smid to the abort_task
+ * _ctl_set_task_mid - assign an active smid to tm request
* @ioc: per adapter object
* @karg - (struct mpt2_ioctl_command)
* @tm_request - pointer to mf from user space
@@ -482,7 +482,7 @@ _ctl_poll(struct file *filep, poll_table *wait)
* during failure, the reply frame is filled.
*/
static int
-_ctl_do_task_abort(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
+_ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
Mpi2SCSITaskManagementRequest_t *tm_request)
{
u8 found = 0;
@@ -494,6 +494,14 @@ _ctl_do_task_abort(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
Mpi2SCSITaskManagementReply_t *tm_reply;
u32 sz;
u32 lun;
+ char *desc = NULL;
+
+ if (tm_request->TaskType == MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK)
+ desc = "abort_task";
+ else if (tm_request->TaskType == MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK)
+ desc = "query_task";
+ else
+ return 0;
lun = scsilun_to_int((struct scsi_lun *)tm_request->LUN);
@@ -517,13 +525,13 @@ _ctl_do_task_abort(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
if (!found) {
- dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "ABORT_TASK: "
- "DevHandle(0x%04x), lun(%d), no active mid!!\n", ioc->name,
- tm_request->DevHandle, lun));
+ dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: "
+ "handle(0x%04x), lun(%d), no active mid!!\n", ioc->name,
+ desc, tm_request->DevHandle, lun));
tm_reply = ioc->ctl_cmds.reply;
tm_reply->DevHandle = tm_request->DevHandle;
tm_reply->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
- tm_reply->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK;
+ tm_reply->TaskType = tm_request->TaskType;
tm_reply->MsgLength = sizeof(Mpi2SCSITaskManagementReply_t)/4;
tm_reply->VP_ID = tm_request->VP_ID;
tm_reply->VF_ID = tm_request->VF_ID;
@@ -535,9 +543,9 @@ _ctl_do_task_abort(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
return 1;
}
- dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "ABORT_TASK: "
- "DevHandle(0x%04x), lun(%d), smid(%d)\n", ioc->name,
- tm_request->DevHandle, lun, tm_request->TaskMID));
+ dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: "
+ "handle(0x%04x), lun(%d), task_mid(%d)\n", ioc->name,
+ desc, tm_request->DevHandle, lun, tm_request->TaskMID));
return 0;
}
@@ -739,8 +747,10 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
(Mpi2SCSITaskManagementRequest_t *)mpi_request;
if (tm_request->TaskType ==
- MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK) {
- if (_ctl_do_task_abort(ioc, &karg, tm_request)) {
+ MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK ||
+ tm_request->TaskType ==
+ MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK) {
+ if (_ctl_set_task_mid(ioc, &karg, tm_request)) {
mpt2sas_base_free_smid(ioc, smid);
goto out;
}
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index e3a7967259e7..2a01a5f2a84d 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -197,12 +197,12 @@ static struct pci_device_id scsih_pci_table[] = {
MODULE_DEVICE_TABLE(pci, scsih_pci_table);
/**
- * scsih_set_debug_level - global setting of ioc->logging_level.
+ * _scsih_set_debug_level - global setting of ioc->logging_level.
*
* Note: The logging levels are defined in mpt2sas_debug.h.
*/
static int
-scsih_set_debug_level(const char *val, struct kernel_param *kp)
+_scsih_set_debug_level(const char *val, struct kernel_param *kp)
{
int ret = param_set_int(val, kp);
struct MPT2SAS_ADAPTER *ioc;
@@ -215,7 +215,7 @@ scsih_set_debug_level(const char *val, struct kernel_param *kp)
ioc->logging_level = logging_level;
return 0;
}
-module_param_call(logging_level, scsih_set_debug_level, param_get_int,
+module_param_call(logging_level, _scsih_set_debug_level, param_get_int,
&logging_level, 0644);
/**
@@ -884,6 +884,41 @@ _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id,
}
/**
+ * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
+ * @ioc: per adapter object
+ * @id: target id
+ * @lun: lun number
+ * @channel: channel
+ * Context: This function will acquire ioc->scsi_lookup_lock.
+ *
+ * This will search for a matching channel:id:lun in the scsi_lookup array,
+ * returning 1 if found.
+ */
+static u8
+_scsih_scsi_lookup_find_by_lun(struct MPT2SAS_ADAPTER *ioc, int id,
+ unsigned int lun, int channel)
+{
+ u8 found;
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
+ found = 0;
+ for (i = 0 ; i < ioc->request_depth; i++) {
+ if (ioc->scsi_lookup[i].scmd &&
+ (ioc->scsi_lookup[i].scmd->device->id == id &&
+ ioc->scsi_lookup[i].scmd->device->channel == channel &&
+ ioc->scsi_lookup[i].scmd->device->lun == lun)) {
+ found = 1;
+ goto out;
+ }
+ }
+ out:
+ spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
+ return found;
+}
+
+/**
* _scsih_get_chain_buffer_dma - obtain block of chains (dma address)
* @ioc: per adapter object
* @smid: system request message index
@@ -1047,14 +1082,14 @@ _scsih_build_scatter_gather(struct MPT2SAS_ADAPTER *ioc,
}
/**
- * scsih_change_queue_depth - setting device queue depth
+ * _scsih_change_queue_depth - setting device queue depth
* @sdev: scsi device struct
* @qdepth: requested queue depth
*
* Returns queue depth.
*/
static int
-scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
+_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
{
struct Scsi_Host *shost = sdev->host;
int max_depth;
@@ -1079,14 +1114,14 @@ scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
}
/**
- * scsih_change_queue_depth - changing device queue tag type
+ * _scsih_change_queue_depth - changing device queue tag type
* @sdev: scsi device struct
* @tag_type: requested tag type
*
* Returns queue tag type.
*/
static int
-scsih_change_queue_type(struct scsi_device *sdev, int tag_type)
+_scsih_change_queue_type(struct scsi_device *sdev, int tag_type)
{
if (sdev->tagged_supported) {
scsi_set_tag_type(sdev, tag_type);
@@ -1101,14 +1136,14 @@ scsih_change_queue_type(struct scsi_device *sdev, int tag_type)
}
/**
- * scsih_target_alloc - target add routine
+ * _scsih_target_alloc - target add routine
* @starget: scsi target struct
*
* Returns 0 if ok. Any other return is assumed to be an error and
* the device is ignored.
*/
static int
-scsih_target_alloc(struct scsi_target *starget)
+_scsih_target_alloc(struct scsi_target *starget)
{
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -1163,13 +1198,13 @@ scsih_target_alloc(struct scsi_target *starget)
}
/**
- * scsih_target_destroy - target destroy routine
+ * _scsih_target_destroy - target destroy routine
* @starget: scsi target struct
*
* Returns nothing.
*/
static void
-scsih_target_destroy(struct scsi_target *starget)
+_scsih_target_destroy(struct scsi_target *starget)
{
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -1212,14 +1247,14 @@ scsih_target_destroy(struct scsi_target *starget)
}
/**
- * scsih_slave_alloc - device add routine
+ * _scsih_slave_alloc - device add routine
* @sdev: scsi device struct
*
* Returns 0 if ok. Any other return is assumed to be an error and
* the device is ignored.
*/
static int
-scsih_slave_alloc(struct scsi_device *sdev)
+_scsih_slave_alloc(struct scsi_device *sdev)
{
struct Scsi_Host *shost;
struct MPT2SAS_ADAPTER *ioc;
@@ -1273,13 +1308,13 @@ scsih_slave_alloc(struct scsi_device *sdev)
}
/**
- * scsih_slave_destroy - device destroy routine
+ * _scsih_slave_destroy - device destroy routine
* @sdev: scsi device struct
*
* Returns nothing.
*/
static void
-scsih_slave_destroy(struct scsi_device *sdev)
+_scsih_slave_destroy(struct scsi_device *sdev)
{
struct MPT2SAS_TARGET *sas_target_priv_data;
struct scsi_target *starget;
@@ -1295,13 +1330,13 @@ scsih_slave_destroy(struct scsi_device *sdev)
}
/**
- * scsih_display_sata_capabilities - sata capabilities
+ * _scsih_display_sata_capabilities - sata capabilities
* @ioc: per adapter object
* @sas_device: the sas_device object
* @sdev: scsi device struct
*/
static void
-scsih_display_sata_capabilities(struct MPT2SAS_ADAPTER *ioc,
+_scsih_display_sata_capabilities(struct MPT2SAS_ADAPTER *ioc,
struct _sas_device *sas_device, struct scsi_device *sdev)
{
Mpi2ConfigReply_t mpi_reply;
@@ -1401,14 +1436,14 @@ _scsih_get_volume_capabilities(struct MPT2SAS_ADAPTER *ioc,
}
/**
- * scsih_slave_configure - device configure routine.
+ * _scsih_slave_configure - device configure routine.
* @sdev: scsi device struct
*
* Returns 0 if ok. Any other return is assumed to be an error and
* the device is ignored.
*/
static int
-scsih_slave_configure(struct scsi_device *sdev)
+_scsih_slave_configure(struct scsi_device *sdev)
{
struct Scsi_Host *shost = sdev->host;
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -1489,7 +1524,7 @@ scsih_slave_configure(struct scsi_device *sdev)
r_level, raid_device->handle,
(unsigned long long)raid_device->wwid,
raid_device->num_pds, ds);
- scsih_change_queue_depth(sdev, qdepth);
+ _scsih_change_queue_depth(sdev, qdepth);
return 0;
}
@@ -1532,10 +1567,10 @@ scsih_slave_configure(struct scsi_device *sdev)
sas_device->slot);
if (!ssp_target)
- scsih_display_sata_capabilities(ioc, sas_device, sdev);
+ _scsih_display_sata_capabilities(ioc, sas_device, sdev);
}
- scsih_change_queue_depth(sdev, qdepth);
+ _scsih_change_queue_depth(sdev, qdepth);
if (ssp_target)
sas_read_port_mode_page(sdev);
@@ -1543,7 +1578,7 @@ scsih_slave_configure(struct scsi_device *sdev)
}
/**
- * scsih_bios_param - fetch head, sector, cylinder info for a disk
+ * _scsih_bios_param - fetch head, sector, cylinder info for a disk
* @sdev: scsi device struct
* @bdev: pointer to block device context
* @capacity: device size (in 512 byte sectors)
@@ -1555,7 +1590,7 @@ scsih_slave_configure(struct scsi_device *sdev)
* Return nothing.
*/
static int
-scsih_bios_param(struct scsi_device *sdev, struct block_device *bdev,
+_scsih_bios_param(struct scsi_device *sdev, struct block_device *bdev,
sector_t capacity, int params[])
{
int heads;
@@ -1636,7 +1671,7 @@ _scsih_response_code(struct MPT2SAS_ADAPTER *ioc, u8 response_code)
}
/**
- * scsih_tm_done - tm completion routine
+ * _scsih_tm_done - tm completion routine
* @ioc: per adapter object
* @smid: system request message index
* @VF_ID: virtual function id
@@ -1648,7 +1683,7 @@ _scsih_response_code(struct MPT2SAS_ADAPTER *ioc, u8 response_code)
* Return nothing.
*/
static void
-scsih_tm_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
+_scsih_tm_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
{
MPI2DefaultReply_t *mpi_reply;
@@ -1823,13 +1858,13 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
}
/**
- * scsih_abort - eh threads main abort routine
+ * _scsih_abort - eh threads main abort routine
* @sdev: scsi device struct
*
* Returns SUCCESS if command aborted else FAILED
*/
static int
-scsih_abort(struct scsi_cmnd *scmd)
+_scsih_abort(struct scsi_cmnd *scmd)
{
struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
struct MPT2SAS_DEVICE *sas_device_priv_data;
@@ -1889,15 +1924,86 @@ scsih_abort(struct scsi_cmnd *scmd)
return r;
}
+/**
+ * _scsih_dev_reset - eh threads main device reset routine
+ * @sdev: scsi device struct
+ *
+ * Returns SUCCESS if command aborted else FAILED
+ */
+static int
+_scsih_dev_reset(struct scsi_cmnd *scmd)
+{
+ struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
+ struct MPT2SAS_DEVICE *sas_device_priv_data;
+ struct _sas_device *sas_device;
+ unsigned long flags;
+ u16 handle;
+ int r;
+
+ printk(MPT2SAS_INFO_FMT "attempting device reset! scmd(%p)\n",
+ ioc->name, scmd);
+ scsi_print_command(scmd);
+
+ sas_device_priv_data = scmd->device->hostdata;
+ if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
+ printk(MPT2SAS_INFO_FMT "device been deleted! scmd(%p)\n",
+ ioc->name, scmd);
+ scmd->result = DID_NO_CONNECT << 16;
+ scmd->scsi_done(scmd);
+ r = SUCCESS;
+ goto out;
+ }
+
+ /* for hidden raid components obtain the volume_handle */
+ handle = 0;
+ if (sas_device_priv_data->sas_target->flags &
+ MPT_TARGET_FLAGS_RAID_COMPONENT) {
+ spin_lock_irqsave(&ioc->sas_device_lock, flags);
+ sas_device = _scsih_sas_device_find_by_handle(ioc,
+ sas_device_priv_data->sas_target->handle);
+ if (sas_device)
+ handle = sas_device->volume_handle;
+ spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
+ } else
+ handle = sas_device_priv_data->sas_target->handle;
+
+ if (!handle) {
+ scmd->result = DID_RESET << 16;
+ r = FAILED;
+ goto out;
+ }
+
+ mutex_lock(&ioc->tm_cmds.mutex);
+ mpt2sas_scsih_issue_tm(ioc, handle, 0,
+ MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, scmd->device->lun,
+ 30);
+
+ /*
+ * sanity check see whether all commands to this device been
+ * completed
+ */
+ if (_scsih_scsi_lookup_find_by_lun(ioc, scmd->device->id,
+ scmd->device->lun, scmd->device->channel))
+ r = FAILED;
+ else
+ r = SUCCESS;
+ ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
+ mutex_unlock(&ioc->tm_cmds.mutex);
+
+ out:
+ printk(MPT2SAS_INFO_FMT "device reset: %s scmd(%p)\n",
+ ioc->name, ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+ return r;
+}
/**
- * scsih_dev_reset - eh threads main device reset routine
+ * _scsih_target_reset - eh threads main target reset routine
* @sdev: scsi device struct
*
* Returns SUCCESS if command aborted else FAILED
*/
static int
-scsih_dev_reset(struct scsi_cmnd *scmd)
+_scsih_target_reset(struct scsi_cmnd *scmd)
{
struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
struct MPT2SAS_DEVICE *sas_device_priv_data;
@@ -1912,7 +2018,7 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
sas_device_priv_data = scmd->device->hostdata;
if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
- printk(MPT2SAS_INFO_FMT "device been deleted! scmd(%p)\n",
+ printk(MPT2SAS_INFO_FMT "target been deleted! scmd(%p)\n",
ioc->name, scmd);
scmd->result = DID_NO_CONNECT << 16;
scmd->scsi_done(scmd);
@@ -1962,13 +2068,13 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
}
/**
- * scsih_abort - eh threads main host reset routine
+ * _scsih_abort - eh threads main host reset routine
* @sdev: scsi device struct
*
* Returns SUCCESS if command aborted else FAILED
*/
static int
-scsih_host_reset(struct scsi_cmnd *scmd)
+_scsih_host_reset(struct scsi_cmnd *scmd)
{
struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
int r, retval;
@@ -2390,7 +2496,107 @@ mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
}
/**
- * scsih_qcmd - main scsi request entry point
+ * _scsih_setup_eedp - setup MPI request for EEDP transfer
+ * @scmd: pointer to scsi command object
+ * @mpi_request: pointer to the SCSI_IO reqest message frame
+ *
+ * Supporting protection 1 and 3.
+ *
+ * Returns nothing
+ */
+static void
+_scsih_setup_eedp(struct scsi_cmnd *scmd, Mpi2SCSIIORequest_t *mpi_request)
+{
+ u16 eedp_flags;
+ unsigned char prot_op = scsi_get_prot_op(scmd);
+ unsigned char prot_type = scsi_get_prot_type(scmd);
+
+ if (prot_type == SCSI_PROT_DIF_TYPE0 ||
+ prot_type == SCSI_PROT_DIF_TYPE2 ||
+ prot_op == SCSI_PROT_NORMAL)
+ return;
+
+ if (prot_op == SCSI_PROT_READ_STRIP)
+ eedp_flags = MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP;
+ else if (prot_op == SCSI_PROT_WRITE_INSERT)
+ eedp_flags = MPI2_SCSIIO_EEDPFLAGS_INSERT_OP;
+ else
+ return;
+
+ mpi_request->EEDPBlockSize = scmd->device->sector_size;
+
+ switch (prot_type) {
+ case SCSI_PROT_DIF_TYPE1:
+
+ /*
+ * enable ref/guard checking
+ * auto increment ref tag
+ */
+ mpi_request->EEDPFlags = eedp_flags |
+ MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG |
+ MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG |
+ MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
+ mpi_request->CDB.EEDP32.PrimaryReferenceTag =
+ cpu_to_be32(scsi_get_lba(scmd));
+
+ break;
+
+ case SCSI_PROT_DIF_TYPE3:
+
+ /*
+ * enable guard checking
+ */
+ mpi_request->EEDPFlags = eedp_flags |
+ MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
+
+ break;
+ }
+}
+
+/**
+ * _scsih_eedp_error_handling - return sense code for EEDP errors
+ * @scmd: pointer to scsi command object
+ * @ioc_status: ioc status
+ *
+ * Returns nothing
+ */
+static void
+_scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status)
+{
+ u8 ascq;
+ u8 sk;
+ u8 host_byte;
+
+ switch (ioc_status) {
+ case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
+ ascq = 0x01;
+ break;
+ case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
+ ascq = 0x02;
+ break;
+ case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
+ ascq = 0x03;
+ break;
+ default:
+ ascq = 0x00;
+ break;
+ }
+
+ if (scmd->sc_data_direction == DMA_TO_DEVICE) {
+ sk = ILLEGAL_REQUEST;
+ host_byte = DID_ABORT;
+ } else {
+ sk = ABORTED_COMMAND;
+ host_byte = DID_OK;
+ }
+
+ scsi_build_sense_buffer(0, scmd->sense_buffer, sk, 0x10, ascq);
+ scmd->result = DRIVER_SENSE << 24 | (host_byte << 16) |
+ SAM_STAT_CHECK_CONDITION;
+}
+
+/**
+ * _scsih_qcmd - main scsi request entry point
* @scmd: pointer to scsi command object
* @done: function pointer to be invoked on completion
*
@@ -2401,7 +2607,7 @@ mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
* SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full
*/
static int
-scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
+_scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
{
struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
struct MPT2SAS_DEVICE *sas_device_priv_data;
@@ -2470,6 +2676,7 @@ scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
}
mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
memset(mpi_request, 0, sizeof(Mpi2SCSIIORequest_t));
+ _scsih_setup_eedp(scmd, mpi_request);
mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
if (sas_device_priv_data->sas_target->flags &
MPT_TARGET_FLAGS_RAID_COMPONENT)
@@ -2604,6 +2811,15 @@ _scsih_scsi_ioc_info(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED:
desc_ioc_state = "scsi ext terminated";
break;
+ case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
+ desc_ioc_state = "eedp guard error";
+ break;
+ case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
+ desc_ioc_state = "eedp ref tag error";
+ break;
+ case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
+ desc_ioc_state = "eedp app tag error";
+ break;
default:
desc_ioc_state = "unknown";
break;
@@ -2783,7 +2999,7 @@ _scsih_smart_predicted_fault(struct MPT2SAS_ADAPTER *ioc, u16 handle)
}
/**
- * scsih_io_done - scsi request callback
+ * _scsih_io_done - scsi request callback
* @ioc: per adapter object
* @smid: system request message index
* @VF_ID: virtual function id
@@ -2794,7 +3010,7 @@ _scsih_smart_predicted_fault(struct MPT2SAS_ADAPTER *ioc, u16 handle)
* Return nothing.
*/
static void
-scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
+_scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
{
Mpi2SCSIIORequest_t *mpi_request;
Mpi2SCSIIOReply_t *mpi_reply;
@@ -2939,6 +3155,11 @@ scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
scmd->result = DID_RESET << 16;
break;
+ case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
+ case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
+ case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
+ _scsih_eedp_error_handling(scmd, ioc_status);
+ break;
case MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR:
case MPI2_IOCSTATUS_INVALID_FUNCTION:
case MPI2_IOCSTATUS_INVALID_SGL:
@@ -5130,18 +5351,19 @@ static struct scsi_host_template scsih_driver_template = {
.module = THIS_MODULE,
.name = "Fusion MPT SAS Host",
.proc_name = MPT2SAS_DRIVER_NAME,
- .queuecommand = scsih_qcmd,
- .target_alloc = scsih_target_alloc,
- .slave_alloc = scsih_slave_alloc,
- .slave_configure = scsih_slave_configure,
- .target_destroy = scsih_target_destroy,
- .slave_destroy = scsih_slave_destroy,
- .change_queue_depth = scsih_change_queue_depth,
- .change_queue_type = scsih_change_queue_type,
- .eh_abort_handler = scsih_abort,
- .eh_device_reset_handler = scsih_dev_reset,
- .eh_host_reset_handler = scsih_host_reset,
- .bios_param = scsih_bios_param,
+ .queuecommand = _scsih_qcmd,
+ .target_alloc = _scsih_target_alloc,
+ .slave_alloc = _scsih_slave_alloc,
+ .slave_configure = _scsih_slave_configure,
+ .target_destroy = _scsih_target_destroy,
+ .slave_destroy = _scsih_slave_destroy,
+ .change_queue_depth = _scsih_change_queue_depth,
+ .change_queue_type = _scsih_change_queue_type,
+ .eh_abort_handler = _scsih_abort,
+ .eh_device_reset_handler = _scsih_dev_reset,
+ .eh_target_reset_handler = _scsih_target_reset,
+ .eh_host_reset_handler = _scsih_host_reset,
+ .bios_param = _scsih_bios_param,
.can_queue = 1,
.this_id = -1,
.sg_tablesize = MPT2SAS_SG_DEPTH,
@@ -5228,13 +5450,13 @@ _scsih_expander_node_remove(struct MPT2SAS_ADAPTER *ioc,
}
/**
- * scsih_remove - detach and remove add host
+ * _scsih_remove - detach and remove add host
* @pdev: PCI device struct
*
* Return nothing.
*/
static void __devexit
-scsih_remove(struct pci_dev *pdev)
+_scsih_remove(struct pci_dev *pdev)
{
struct Scsi_Host *shost = pci_get_drvdata(pdev);
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -5442,14 +5664,14 @@ _scsih_probe_devices(struct MPT2SAS_ADAPTER *ioc)
}
/**
- * scsih_probe - attach and add scsi host
+ * _scsih_probe - attach and add scsi host
* @pdev: PCI device struct
* @id: pci device id
*
* Returns 0 success, anything else error.
*/
static int
-scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+_scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct MPT2SAS_ADAPTER *ioc;
struct Scsi_Host *shost;
@@ -5503,6 +5725,9 @@ scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_add_shost_fail;
}
+ scsi_host_set_prot(shost, SHOST_DIF_TYPE1_PROTECTION
+ | SHOST_DIF_TYPE3_PROTECTION);
+
/* event thread */
snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name),
"fw_event%d", ioc->id);
@@ -5536,14 +5761,14 @@ scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
#ifdef CONFIG_PM
/**
- * scsih_suspend - power management suspend main entry point
+ * _scsih_suspend - power management suspend main entry point
* @pdev: PCI device struct
* @state: PM state change to (usually PCI_D3)
*
* Returns 0 success, anything else error.
*/
static int
-scsih_suspend(struct pci_dev *pdev, pm_message_t state)
+_scsih_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct Scsi_Host *shost = pci_get_drvdata(pdev);
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -5564,13 +5789,13 @@ scsih_suspend(struct pci_dev *pdev, pm_message_t state)
}
/**
- * scsih_resume - power management resume main entry point
+ * _scsih_resume - power management resume main entry point
* @pdev: PCI device struct
*
* Returns 0 success, anything else error.
*/
static int
-scsih_resume(struct pci_dev *pdev)
+_scsih_resume(struct pci_dev *pdev)
{
struct Scsi_Host *shost = pci_get_drvdata(pdev);
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -5599,22 +5824,22 @@ scsih_resume(struct pci_dev *pdev)
static struct pci_driver scsih_driver = {
.name = MPT2SAS_DRIVER_NAME,
.id_table = scsih_pci_table,
- .probe = scsih_probe,
- .remove = __devexit_p(scsih_remove),
+ .probe = _scsih_probe,
+ .remove = __devexit_p(_scsih_remove),
#ifdef CONFIG_PM
- .suspend = scsih_suspend,
- .resume = scsih_resume,
+ .suspend = _scsih_suspend,
+ .resume = _scsih_resume,
#endif
};
/**
- * scsih_init - main entry point for this driver.
+ * _scsih_init - main entry point for this driver.
*
* Returns 0 success, anything else error.
*/
static int __init
-scsih_init(void)
+_scsih_init(void)
{
int error;
@@ -5630,10 +5855,10 @@ scsih_init(void)
mpt2sas_base_initialize_callback_handler();
/* queuecommand callback hander */
- scsi_io_cb_idx = mpt2sas_base_register_callback_handler(scsih_io_done);
+ scsi_io_cb_idx = mpt2sas_base_register_callback_handler(_scsih_io_done);
/* task managment callback handler */
- tm_cb_idx = mpt2sas_base_register_callback_handler(scsih_tm_done);
+ tm_cb_idx = mpt2sas_base_register_callback_handler(_scsih_tm_done);
/* base internal commands callback handler */
base_cb_idx = mpt2sas_base_register_callback_handler(mpt2sas_base_done);
@@ -5659,12 +5884,12 @@ scsih_init(void)
}
/**
- * scsih_exit - exit point for this driver (when it is a module).
+ * _scsih_exit - exit point for this driver (when it is a module).
*
* Returns 0 success, anything else error.
*/
static void __exit
-scsih_exit(void)
+_scsih_exit(void)
{
printk(KERN_INFO "mpt2sas version %s unloading\n",
MPT2SAS_DRIVER_VERSION);
@@ -5682,5 +5907,5 @@ scsih_exit(void)
mpt2sas_ctl_exit();
}
-module_init(scsih_init);
-module_exit(scsih_exit);
+module_init(_scsih_init);
+module_exit(_scsih_exit);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index e03dc0b1e1a0..686695b155c7 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -264,7 +264,7 @@ struct rep_manu_reply{
};
/**
- * transport_expander_report_manufacture - obtain SMP report_manufacture
+ * _transport_expander_report_manufacture - obtain SMP report_manufacture
* @ioc: per adapter object
* @sas_address: expander sas address
* @edev: the sas_expander_device object
@@ -274,7 +274,7 @@ struct rep_manu_reply{
* Returns 0 for success, non-zero for failure.
*/
static int
-transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
+_transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
u64 sas_address, struct sas_expander_device *edev)
{
Mpi2SmpPassthroughRequest_t *mpi_request;
@@ -578,7 +578,7 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle,
MPI2_SAS_DEVICE_INFO_EDGE_EXPANDER ||
mpt2sas_port->remote_identify.device_type ==
MPI2_SAS_DEVICE_INFO_FANOUT_EXPANDER)
- transport_expander_report_manufacture(ioc,
+ _transport_expander_report_manufacture(ioc,
mpt2sas_port->remote_identify.sas_address,
rphy_to_expander_device(rphy));
@@ -852,7 +852,7 @@ rphy_to_ioc(struct sas_rphy *rphy)
}
/**
- * transport_get_linkerrors -
+ * _transport_get_linkerrors -
* @phy: The sas phy object
*
* Only support sas_host direct attached phys.
@@ -860,7 +860,7 @@ rphy_to_ioc(struct sas_rphy *rphy)
*
*/
static int
-transport_get_linkerrors(struct sas_phy *phy)
+_transport_get_linkerrors(struct sas_phy *phy)
{
struct MPT2SAS_ADAPTER *ioc = phy_to_ioc(phy);
struct _sas_phy *mpt2sas_phy;
@@ -903,14 +903,14 @@ transport_get_linkerrors(struct sas_phy *phy)
}
/**
- * transport_get_enclosure_identifier -
+ * _transport_get_enclosure_identifier -
* @phy: The sas phy object
*
* Obtain the enclosure logical id for an expander.
* Returns 0 for success, non-zero for failure.
*/
static int
-transport_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
+_transport_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
{
struct MPT2SAS_ADAPTER *ioc = rphy_to_ioc(rphy);
struct _sas_node *sas_expander;
@@ -929,13 +929,13 @@ transport_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
}
/**
- * transport_get_bay_identifier -
+ * _transport_get_bay_identifier -
* @phy: The sas phy object
*
* Returns the slot id for a device that resides inside an enclosure.
*/
static int
-transport_get_bay_identifier(struct sas_rphy *rphy)
+_transport_get_bay_identifier(struct sas_rphy *rphy)
{
struct MPT2SAS_ADAPTER *ioc = rphy_to_ioc(rphy);
struct _sas_device *sas_device;
@@ -953,7 +953,7 @@ transport_get_bay_identifier(struct sas_rphy *rphy)
}
/**
- * transport_phy_reset -
+ * _transport_phy_reset -
* @phy: The sas phy object
* @hard_reset:
*
@@ -961,7 +961,7 @@ transport_get_bay_identifier(struct sas_rphy *rphy)
* Returns 0 for success, non-zero for failure.
*/
static int
-transport_phy_reset(struct sas_phy *phy, int hard_reset)
+_transport_phy_reset(struct sas_phy *phy, int hard_reset)
{
struct MPT2SAS_ADAPTER *ioc = phy_to_ioc(phy);
struct _sas_phy *mpt2sas_phy;
@@ -1002,7 +1002,7 @@ transport_phy_reset(struct sas_phy *phy, int hard_reset)
}
/**
- * transport_smp_handler - transport portal for smp passthru
+ * _transport_smp_handler - transport portal for smp passthru
* @shost: shost object
* @rphy: sas transport rphy object
* @req:
@@ -1012,7 +1012,7 @@ transport_phy_reset(struct sas_phy *phy, int hard_reset)
* smp_rep_general /sys/class/bsg/expander-5:0
*/
static int
-transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
+_transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
struct request *req)
{
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
@@ -1041,7 +1041,7 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
printk(MPT2SAS_ERR_FMT "%s: multiple segments req %u %u, "
"rsp %u %u\n", ioc->name, __func__, req->bio->bi_vcnt,
- req->data_len, rsp->bio->bi_vcnt, rsp->data_len);
+ blk_rq_bytes(req), rsp->bio->bi_vcnt, blk_rq_bytes(rsp));
return -EINVAL;
}
@@ -1104,7 +1104,7 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
*((u64 *)&mpi_request->SASAddress) = (rphy) ?
cpu_to_le64(rphy->identify.sas_address) :
cpu_to_le64(ioc->sas_hba.sas_address);
- mpi_request->RequestDataLength = cpu_to_le16(req->data_len - 4);
+ mpi_request->RequestDataLength = cpu_to_le16(blk_rq_bytes(req) - 4);
psge = &mpi_request->SGL;
/* WRITE sgel first */
@@ -1112,13 +1112,13 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC);
sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT;
dma_addr_out = pci_map_single(ioc->pdev, bio_data(req->bio),
- req->data_len, PCI_DMA_BIDIRECTIONAL);
+ blk_rq_bytes(req), PCI_DMA_BIDIRECTIONAL);
if (!dma_addr_out) {
mpt2sas_base_free_smid(ioc, le16_to_cpu(smid));
goto unmap;
}
- ioc->base_add_sg_single(psge, sgl_flags | (req->data_len - 4),
+ ioc->base_add_sg_single(psge, sgl_flags | (blk_rq_bytes(req) - 4),
dma_addr_out);
/* incr sgel */
@@ -1129,14 +1129,14 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER |
MPI2_SGE_FLAGS_END_OF_LIST);
sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT;
- dma_addr_in = pci_map_single(ioc->pdev, bio_data(rsp->bio),
- rsp->data_len, PCI_DMA_BIDIRECTIONAL);
+ dma_addr_in = pci_map_single(ioc->pdev, bio_data(rsp->bio),
+ blk_rq_bytes(rsp), PCI_DMA_BIDIRECTIONAL);
if (!dma_addr_in) {
mpt2sas_base_free_smid(ioc, le16_to_cpu(smid));
goto unmap;
}
- ioc->base_add_sg_single(psge, sgl_flags | (rsp->data_len + 4),
+ ioc->base_add_sg_single(psge, sgl_flags | (blk_rq_bytes(rsp) + 4),
dma_addr_in);
dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s - "
@@ -1170,9 +1170,8 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
memcpy(req->sense, mpi_reply, sizeof(*mpi_reply));
req->sense_len = sizeof(*mpi_reply);
- req->data_len = 0;
- rsp->data_len -= mpi_reply->ResponseDataLength;
-
+ req->resid_len = 0;
+ rsp->resid_len -= mpi_reply->ResponseDataLength;
} else {
dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT
"%s - no reply\n", ioc->name, __func__));
@@ -1188,10 +1187,10 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
unmap:
if (dma_addr_out)
- pci_unmap_single(ioc->pdev, dma_addr_out, req->data_len,
+ pci_unmap_single(ioc->pdev, dma_addr_out, blk_rq_bytes(req),
PCI_DMA_BIDIRECTIONAL);
if (dma_addr_in)
- pci_unmap_single(ioc->pdev, dma_addr_in, rsp->data_len,
+ pci_unmap_single(ioc->pdev, dma_addr_in, blk_rq_bytes(rsp),
PCI_DMA_BIDIRECTIONAL);
out:
@@ -1201,11 +1200,11 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
}
struct sas_function_template mpt2sas_transport_functions = {
- .get_linkerrors = transport_get_linkerrors,
- .get_enclosure_identifier = transport_get_enclosure_identifier,
- .get_bay_identifier = transport_get_bay_identifier,
- .phy_reset = transport_phy_reset,
- .smp_handler = transport_smp_handler,
+ .get_linkerrors = _transport_get_linkerrors,
+ .get_enclosure_identifier = _transport_get_enclosure_identifier,
+ .get_bay_identifier = _transport_get_bay_identifier,
+ .phy_reset = _transport_phy_reset,
+ .smp_handler = _transport_smp_handler,
};
struct scsi_transport_template *mpt2sas_transport_template;
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c
deleted file mode 100644
index e4acebd10d1b..000000000000
--- a/drivers/scsi/mvsas.c
+++ /dev/null
@@ -1,3222 +0,0 @@
-/*
- mvsas.c - Marvell 88SE6440 SAS/SATA support
-
- Copyright 2007 Red Hat, Inc.
- Copyright 2008 Marvell. <kewei@marvell.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2,
- or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; see the file COPYING. If not,
- write to the Free Software Foundation, 675 Mass Ave, Cambridge,
- MA 02139, USA.
-
- ---------------------------------------------------------------
-
- Random notes:
- * hardware supports controlling the endian-ness of data
- structures. this permits elimination of all the le32_to_cpu()
- and cpu_to_le32() conversions.
-
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/delay.h>
-#include <linux/dma-mapping.h>
-#include <linux/ctype.h>
-#include <scsi/libsas.h>
-#include <scsi/scsi_tcq.h>
-#include <scsi/sas_ata.h>
-#include <asm/io.h>
-
-#define DRV_NAME "mvsas"
-#define DRV_VERSION "0.5.2"
-#define _MV_DUMP 0
-#define MVS_DISABLE_NVRAM
-#define MVS_DISABLE_MSI
-
-#define mr32(reg) readl(regs + MVS_##reg)
-#define mw32(reg,val) writel((val), regs + MVS_##reg)
-#define mw32_f(reg,val) do { \
- writel((val), regs + MVS_##reg); \
- readl(regs + MVS_##reg); \
- } while (0)
-
-#define MVS_ID_NOT_MAPPED 0x7f
-#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width)
-
-/* offset for D2H FIS in the Received FIS List Structure */
-#define SATA_RECEIVED_D2H_FIS(reg_set) \
- ((void *) mvi->rx_fis + 0x400 + 0x100 * reg_set + 0x40)
-#define SATA_RECEIVED_PIO_FIS(reg_set) \
- ((void *) mvi->rx_fis + 0x400 + 0x100 * reg_set + 0x20)
-#define UNASSOC_D2H_FIS(id) \
- ((void *) mvi->rx_fis + 0x100 * id)
-
-#define for_each_phy(__lseq_mask, __mc, __lseq, __rest) \
- for ((__mc) = (__lseq_mask), (__lseq) = 0; \
- (__mc) != 0 && __rest; \
- (++__lseq), (__mc) >>= 1)
-
-/* driver compile-time configuration */
-enum driver_configuration {
- MVS_TX_RING_SZ = 1024, /* TX ring size (12-bit) */
- MVS_RX_RING_SZ = 1024, /* RX ring size (12-bit) */
- /* software requires power-of-2
- ring size */
-
- MVS_SLOTS = 512, /* command slots */
- MVS_SLOT_BUF_SZ = 8192, /* cmd tbl + IU + status + PRD */
- MVS_SSP_CMD_SZ = 64, /* SSP command table buffer size */
- MVS_ATA_CMD_SZ = 96, /* SATA command table buffer size */
- MVS_OAF_SZ = 64, /* Open address frame buffer size */
-
- MVS_RX_FIS_COUNT = 17, /* Optional rx'd FISs (max 17) */
-
- MVS_QUEUE_SIZE = 30, /* Support Queue depth */
- MVS_CAN_QUEUE = MVS_SLOTS - 1, /* SCSI Queue depth */
-};
-
-/* unchangeable hardware details */
-enum hardware_details {
- MVS_MAX_PHYS = 8, /* max. possible phys */
- MVS_MAX_PORTS = 8, /* max. possible ports */
- MVS_RX_FISL_SZ = 0x400 + (MVS_RX_FIS_COUNT * 0x100),
-};
-
-/* peripheral registers (BAR2) */
-enum peripheral_registers {
- SPI_CTL = 0x10, /* EEPROM control */
- SPI_CMD = 0x14, /* EEPROM command */
- SPI_DATA = 0x18, /* EEPROM data */
-};
-
-enum peripheral_register_bits {
- TWSI_RDY = (1U << 7), /* EEPROM interface ready */
- TWSI_RD = (1U << 4), /* EEPROM read access */
-
- SPI_ADDR_MASK = 0x3ffff, /* bits 17:0 */
-};
-
-/* enhanced mode registers (BAR4) */
-enum hw_registers {
- MVS_GBL_CTL = 0x04, /* global control */
- MVS_GBL_INT_STAT = 0x08, /* global irq status */
- MVS_GBL_PI = 0x0C, /* ports implemented bitmask */
- MVS_GBL_PORT_TYPE = 0xa0, /* port type */
-
- MVS_CTL = 0x100, /* SAS/SATA port configuration */
- MVS_PCS = 0x104, /* SAS/SATA port control/status */
- MVS_CMD_LIST_LO = 0x108, /* cmd list addr */
- MVS_CMD_LIST_HI = 0x10C,
- MVS_RX_FIS_LO = 0x110, /* RX FIS list addr */
- MVS_RX_FIS_HI = 0x114,
-
- MVS_TX_CFG = 0x120, /* TX configuration */
- MVS_TX_LO = 0x124, /* TX (delivery) ring addr */
- MVS_TX_HI = 0x128,
-
- MVS_TX_PROD_IDX = 0x12C, /* TX producer pointer */
- MVS_TX_CONS_IDX = 0x130, /* TX consumer pointer (RO) */
- MVS_RX_CFG = 0x134, /* RX configuration */
- MVS_RX_LO = 0x138, /* RX (completion) ring addr */
- MVS_RX_HI = 0x13C,
- MVS_RX_CONS_IDX = 0x140, /* RX consumer pointer (RO) */
-
- MVS_INT_COAL = 0x148, /* Int coalescing config */
- MVS_INT_COAL_TMOUT = 0x14C, /* Int coalescing timeout */
- MVS_INT_STAT = 0x150, /* Central int status */
- MVS_INT_MASK = 0x154, /* Central int enable */
- MVS_INT_STAT_SRS = 0x158, /* SATA register set status */
- MVS_INT_MASK_SRS = 0x15C,
-
- /* ports 1-3 follow after this */
- MVS_P0_INT_STAT = 0x160, /* port0 interrupt status */
- MVS_P0_INT_MASK = 0x164, /* port0 interrupt mask */
- MVS_P4_INT_STAT = 0x200, /* Port 4 interrupt status */
- MVS_P4_INT_MASK = 0x204, /* Port 4 interrupt enable mask */
-
- /* ports 1-3 follow after this */
- MVS_P0_SER_CTLSTAT = 0x180, /* port0 serial control/status */
- MVS_P4_SER_CTLSTAT = 0x220, /* port4 serial control/status */
-
- MVS_CMD_ADDR = 0x1B8, /* Command register port (addr) */
- MVS_CMD_DATA = 0x1BC, /* Command register port (data) */
-
- /* ports 1-3 follow after this */
- MVS_P0_CFG_ADDR = 0x1C0, /* port0 phy register address */
- MVS_P0_CFG_DATA = 0x1C4, /* port0 phy register data */
- MVS_P4_CFG_ADDR = 0x230, /* Port 4 config address */
- MVS_P4_CFG_DATA = 0x234, /* Port 4 config data */
-
- /* ports 1-3 follow after this */
- MVS_P0_VSR_ADDR = 0x1E0, /* port0 VSR address */
- MVS_P0_VSR_DATA = 0x1E4, /* port0 VSR data */
- MVS_P4_VSR_ADDR = 0x250, /* port 4 VSR addr */
- MVS_P4_VSR_DATA = 0x254, /* port 4 VSR data */
-};
-
-enum hw_register_bits {
- /* MVS_GBL_CTL */
- INT_EN = (1U << 1), /* Global int enable */
- HBA_RST = (1U << 0), /* HBA reset */
-
- /* MVS_GBL_INT_STAT */
- INT_XOR = (1U << 4), /* XOR engine event */
- INT_SAS_SATA = (1U << 0), /* SAS/SATA event */
-
- /* MVS_GBL_PORT_TYPE */ /* shl for ports 1-3 */
- SATA_TARGET = (1U << 16), /* port0 SATA target enable */
- MODE_AUTO_DET_PORT7 = (1U << 15), /* port0 SAS/SATA autodetect */
- MODE_AUTO_DET_PORT6 = (1U << 14),
- MODE_AUTO_DET_PORT5 = (1U << 13),
- MODE_AUTO_DET_PORT4 = (1U << 12),
- MODE_AUTO_DET_PORT3 = (1U << 11),
- MODE_AUTO_DET_PORT2 = (1U << 10),
- MODE_AUTO_DET_PORT1 = (1U << 9),
- MODE_AUTO_DET_PORT0 = (1U << 8),
- MODE_AUTO_DET_EN = MODE_AUTO_DET_PORT0 | MODE_AUTO_DET_PORT1 |
- MODE_AUTO_DET_PORT2 | MODE_AUTO_DET_PORT3 |
- MODE_AUTO_DET_PORT4 | MODE_AUTO_DET_PORT5 |
- MODE_AUTO_DET_PORT6 | MODE_AUTO_DET_PORT7,
- MODE_SAS_PORT7_MASK = (1U << 7), /* port0 SAS(1), SATA(0) mode */
- MODE_SAS_PORT6_MASK = (1U << 6),
- MODE_SAS_PORT5_MASK = (1U << 5),
- MODE_SAS_PORT4_MASK = (1U << 4),
- MODE_SAS_PORT3_MASK = (1U << 3),
- MODE_SAS_PORT2_MASK = (1U << 2),
- MODE_SAS_PORT1_MASK = (1U << 1),
- MODE_SAS_PORT0_MASK = (1U << 0),
- MODE_SAS_SATA = MODE_SAS_PORT0_MASK | MODE_SAS_PORT1_MASK |
- MODE_SAS_PORT2_MASK | MODE_SAS_PORT3_MASK |
- MODE_SAS_PORT4_MASK | MODE_SAS_PORT5_MASK |
- MODE_SAS_PORT6_MASK | MODE_SAS_PORT7_MASK,
-
- /* SAS_MODE value may be
- * dictated (in hw) by values
- * of SATA_TARGET & AUTO_DET
- */
-
- /* MVS_TX_CFG */
- TX_EN = (1U << 16), /* Enable TX */
- TX_RING_SZ_MASK = 0xfff, /* TX ring size, bits 11:0 */
-
- /* MVS_RX_CFG */
- RX_EN = (1U << 16), /* Enable RX */
- RX_RING_SZ_MASK = 0xfff, /* RX ring size, bits 11:0 */
-
- /* MVS_INT_COAL */
- COAL_EN = (1U << 16), /* Enable int coalescing */
-
- /* MVS_INT_STAT, MVS_INT_MASK */
- CINT_I2C = (1U << 31), /* I2C event */
- CINT_SW0 = (1U << 30), /* software event 0 */
- CINT_SW1 = (1U << 29), /* software event 1 */
- CINT_PRD_BC = (1U << 28), /* PRD BC err for read cmd */
- CINT_DMA_PCIE = (1U << 27), /* DMA to PCIE timeout */
- CINT_MEM = (1U << 26), /* int mem parity err */
- CINT_I2C_SLAVE = (1U << 25), /* slave I2C event */
- CINT_SRS = (1U << 3), /* SRS event */
- CINT_CI_STOP = (1U << 1), /* cmd issue stopped */
- CINT_DONE = (1U << 0), /* cmd completion */
-
- /* shl for ports 1-3 */
- CINT_PORT_STOPPED = (1U << 16), /* port0 stopped */
- CINT_PORT = (1U << 8), /* port0 event */
- CINT_PORT_MASK_OFFSET = 8,
- CINT_PORT_MASK = (0xFF << CINT_PORT_MASK_OFFSET),
-
- /* TX (delivery) ring bits */
- TXQ_CMD_SHIFT = 29,
- TXQ_CMD_SSP = 1, /* SSP protocol */
- TXQ_CMD_SMP = 2, /* SMP protocol */
- TXQ_CMD_STP = 3, /* STP/SATA protocol */
- TXQ_CMD_SSP_FREE_LIST = 4, /* add to SSP targ free list */
- TXQ_CMD_SLOT_RESET = 7, /* reset command slot */
- TXQ_MODE_I = (1U << 28), /* mode: 0=target,1=initiator */
- TXQ_PRIO_HI = (1U << 27), /* priority: 0=normal, 1=high */
- TXQ_SRS_SHIFT = 20, /* SATA register set */
- TXQ_SRS_MASK = 0x7f,
- TXQ_PHY_SHIFT = 12, /* PHY bitmap */
- TXQ_PHY_MASK = 0xff,
- TXQ_SLOT_MASK = 0xfff, /* slot number */
-
- /* RX (completion) ring bits */
- RXQ_GOOD = (1U << 23), /* Response good */
- RXQ_SLOT_RESET = (1U << 21), /* Slot reset complete */
- RXQ_CMD_RX = (1U << 20), /* target cmd received */
- RXQ_ATTN = (1U << 19), /* attention */
- RXQ_RSP = (1U << 18), /* response frame xfer'd */
- RXQ_ERR = (1U << 17), /* err info rec xfer'd */
- RXQ_DONE = (1U << 16), /* cmd complete */
- RXQ_SLOT_MASK = 0xfff, /* slot number */
-
- /* mvs_cmd_hdr bits */
- MCH_PRD_LEN_SHIFT = 16, /* 16-bit PRD table len */
- MCH_SSP_FR_TYPE_SHIFT = 13, /* SSP frame type */
-
- /* SSP initiator only */
- MCH_SSP_FR_CMD = 0x0, /* COMMAND frame */
-
- /* SSP initiator or target */
- MCH_SSP_FR_TASK = 0x1, /* TASK frame */
-
- /* SSP target only */
- MCH_SSP_FR_XFER_RDY = 0x4, /* XFER_RDY frame */
- MCH_SSP_FR_RESP = 0x5, /* RESPONSE frame */
- MCH_SSP_FR_READ = 0x6, /* Read DATA frame(s) */
- MCH_SSP_FR_READ_RESP = 0x7, /* ditto, plus RESPONSE */
-
- MCH_PASSTHRU = (1U << 12), /* pass-through (SSP) */
- MCH_FBURST = (1U << 11), /* first burst (SSP) */
- MCH_CHK_LEN = (1U << 10), /* chk xfer len (SSP) */
- MCH_RETRY = (1U << 9), /* tport layer retry (SSP) */
- MCH_PROTECTION = (1U << 8), /* protection info rec (SSP) */
- MCH_RESET = (1U << 7), /* Reset (STP/SATA) */
- MCH_FPDMA = (1U << 6), /* First party DMA (STP/SATA) */
- MCH_ATAPI = (1U << 5), /* ATAPI (STP/SATA) */
- MCH_BIST = (1U << 4), /* BIST activate (STP/SATA) */
- MCH_PMP_MASK = 0xf, /* PMP from cmd FIS (STP/SATA)*/
-
- CCTL_RST = (1U << 5), /* port logic reset */
-
- /* 0(LSB first), 1(MSB first) */
- CCTL_ENDIAN_DATA = (1U << 3), /* PRD data */
- CCTL_ENDIAN_RSP = (1U << 2), /* response frame */
- CCTL_ENDIAN_OPEN = (1U << 1), /* open address frame */
- CCTL_ENDIAN_CMD = (1U << 0), /* command table */
-
- /* MVS_Px_SER_CTLSTAT (per-phy control) */
- PHY_SSP_RST = (1U << 3), /* reset SSP link layer */
- PHY_BCAST_CHG = (1U << 2), /* broadcast(change) notif */
- PHY_RST_HARD = (1U << 1), /* hard reset + phy reset */
- PHY_RST = (1U << 0), /* phy reset */
- PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0xF << 8),
- PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0xF << 12),
- PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (16),
- PHY_NEG_SPP_PHYS_LINK_RATE_MASK =
- (0xF << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET),
- PHY_READY_MASK = (1U << 20),
-
- /* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */
- PHYEV_DEC_ERR = (1U << 24), /* Phy Decoding Error */
- PHYEV_UNASSOC_FIS = (1U << 19), /* unassociated FIS rx'd */
- PHYEV_AN = (1U << 18), /* SATA async notification */
- PHYEV_BIST_ACT = (1U << 17), /* BIST activate FIS */
- PHYEV_SIG_FIS = (1U << 16), /* signature FIS */
- PHYEV_POOF = (1U << 12), /* phy ready from 1 -> 0 */
- PHYEV_IU_BIG = (1U << 11), /* IU too long err */
- PHYEV_IU_SMALL = (1U << 10), /* IU too short err */
- PHYEV_UNK_TAG = (1U << 9), /* unknown tag */
- PHYEV_BROAD_CH = (1U << 8), /* broadcast(CHANGE) */
- PHYEV_COMWAKE = (1U << 7), /* COMWAKE rx'd */
- PHYEV_PORT_SEL = (1U << 6), /* port selector present */
- PHYEV_HARD_RST = (1U << 5), /* hard reset rx'd */
- PHYEV_ID_TMOUT = (1U << 4), /* identify timeout */
- PHYEV_ID_FAIL = (1U << 3), /* identify failed */
- PHYEV_ID_DONE = (1U << 2), /* identify done */
- PHYEV_HARD_RST_DONE = (1U << 1), /* hard reset done */
- PHYEV_RDY_CH = (1U << 0), /* phy ready changed state */
-
- /* MVS_PCS */
- PCS_EN_SATA_REG_SHIFT = (16), /* Enable SATA Register Set */
- PCS_EN_PORT_XMT_SHIFT = (12), /* Enable Port Transmit */
- PCS_EN_PORT_XMT_SHIFT2 = (8), /* For 6480 */
- PCS_SATA_RETRY = (1U << 8), /* retry ctl FIS on R_ERR */
- PCS_RSP_RX_EN = (1U << 7), /* raw response rx */
- PCS_SELF_CLEAR = (1U << 5), /* self-clearing int mode */
- PCS_FIS_RX_EN = (1U << 4), /* FIS rx enable */
- PCS_CMD_STOP_ERR = (1U << 3), /* cmd stop-on-err enable */
- PCS_CMD_RST = (1U << 1), /* reset cmd issue */
- PCS_CMD_EN = (1U << 0), /* enable cmd issue */
-
- /* Port n Attached Device Info */
- PORT_DEV_SSP_TRGT = (1U << 19),
- PORT_DEV_SMP_TRGT = (1U << 18),
- PORT_DEV_STP_TRGT = (1U << 17),
- PORT_DEV_SSP_INIT = (1U << 11),
- PORT_DEV_SMP_INIT = (1U << 10),
- PORT_DEV_STP_INIT = (1U << 9),
- PORT_PHY_ID_MASK = (0xFFU << 24),
- PORT_DEV_TRGT_MASK = (0x7U << 17),
- PORT_DEV_INIT_MASK = (0x7U << 9),
- PORT_DEV_TYPE_MASK = (0x7U << 0),
-
- /* Port n PHY Status */
- PHY_RDY = (1U << 2),
- PHY_DW_SYNC = (1U << 1),
- PHY_OOB_DTCTD = (1U << 0),
-
- /* VSR */
- /* PHYMODE 6 (CDB) */
- PHY_MODE6_LATECLK = (1U << 29), /* Lock Clock */
- PHY_MODE6_DTL_SPEED = (1U << 27), /* Digital Loop Speed */
- PHY_MODE6_FC_ORDER = (1U << 26), /* Fibre Channel Mode Order*/
- PHY_MODE6_MUCNT_EN = (1U << 24), /* u Count Enable */
- PHY_MODE6_SEL_MUCNT_LEN = (1U << 22), /* Training Length Select */
- PHY_MODE6_SELMUPI = (1U << 20), /* Phase Multi Select (init) */
- PHY_MODE6_SELMUPF = (1U << 18), /* Phase Multi Select (final) */
- PHY_MODE6_SELMUFF = (1U << 16), /* Freq Loop Multi Sel(final) */
- PHY_MODE6_SELMUFI = (1U << 14), /* Freq Loop Multi Sel(init) */
- PHY_MODE6_FREEZE_LOOP = (1U << 12), /* Freeze Rx CDR Loop */
- PHY_MODE6_INT_RXFOFFS = (1U << 3), /* Rx CDR Freq Loop Enable */
- PHY_MODE6_FRC_RXFOFFS = (1U << 2), /* Initial Rx CDR Offset */
- PHY_MODE6_STAU_0D8 = (1U << 1), /* Rx CDR Freq Loop Saturate */
- PHY_MODE6_RXSAT_DIS = (1U << 0), /* Saturate Ctl */
-};
-
-enum mvs_info_flags {
- MVF_MSI = (1U << 0), /* MSI is enabled */
- MVF_PHY_PWR_FIX = (1U << 1), /* bug workaround */
-};
-
-enum sas_cmd_port_registers {
- CMD_CMRST_OOB_DET = 0x100, /* COMRESET OOB detect register */
- CMD_CMWK_OOB_DET = 0x104, /* COMWAKE OOB detect register */
- CMD_CMSAS_OOB_DET = 0x108, /* COMSAS OOB detect register */
- CMD_BRST_OOB_DET = 0x10c, /* burst OOB detect register */
- CMD_OOB_SPACE = 0x110, /* OOB space control register */
- CMD_OOB_BURST = 0x114, /* OOB burst control register */
- CMD_PHY_TIMER = 0x118, /* PHY timer control register */
- CMD_PHY_CONFIG0 = 0x11c, /* PHY config register 0 */
- CMD_PHY_CONFIG1 = 0x120, /* PHY config register 1 */
- CMD_SAS_CTL0 = 0x124, /* SAS control register 0 */
- CMD_SAS_CTL1 = 0x128, /* SAS control register 1 */
- CMD_SAS_CTL2 = 0x12c, /* SAS control register 2 */
- CMD_SAS_CTL3 = 0x130, /* SAS control register 3 */
- CMD_ID_TEST = 0x134, /* ID test register */
- CMD_PL_TIMER = 0x138, /* PL timer register */
- CMD_WD_TIMER = 0x13c, /* WD timer register */
- CMD_PORT_SEL_COUNT = 0x140, /* port selector count register */
- CMD_APP_MEM_CTL = 0x144, /* Application Memory Control */
- CMD_XOR_MEM_CTL = 0x148, /* XOR Block Memory Control */
- CMD_DMA_MEM_CTL = 0x14c, /* DMA Block Memory Control */
- CMD_PORT_MEM_CTL0 = 0x150, /* Port Memory Control 0 */
- CMD_PORT_MEM_CTL1 = 0x154, /* Port Memory Control 1 */
- CMD_SATA_PORT_MEM_CTL0 = 0x158, /* SATA Port Memory Control 0 */
- CMD_SATA_PORT_MEM_CTL1 = 0x15c, /* SATA Port Memory Control 1 */
- CMD_XOR_MEM_BIST_CTL = 0x160, /* XOR Memory BIST Control */
- CMD_XOR_MEM_BIST_STAT = 0x164, /* XOR Memroy BIST Status */
- CMD_DMA_MEM_BIST_CTL = 0x168, /* DMA Memory BIST Control */
- CMD_DMA_MEM_BIST_STAT = 0x16c, /* DMA Memory BIST Status */
- CMD_PORT_MEM_BIST_CTL = 0x170, /* Port Memory BIST Control */
- CMD_PORT_MEM_BIST_STAT0 = 0x174, /* Port Memory BIST Status 0 */
- CMD_PORT_MEM_BIST_STAT1 = 0x178, /* Port Memory BIST Status 1 */
- CMD_STP_MEM_BIST_CTL = 0x17c, /* STP Memory BIST Control */
- CMD_STP_MEM_BIST_STAT0 = 0x180, /* STP Memory BIST Status 0 */
- CMD_STP_MEM_BIST_STAT1 = 0x184, /* STP Memory BIST Status 1 */
- CMD_RESET_COUNT = 0x188, /* Reset Count */
- CMD_MONTR_DATA_SEL = 0x18C, /* Monitor Data/Select */
- CMD_PLL_PHY_CONFIG = 0x190, /* PLL/PHY Configuration */
- CMD_PHY_CTL = 0x194, /* PHY Control and Status */
- CMD_PHY_TEST_COUNT0 = 0x198, /* Phy Test Count 0 */
- CMD_PHY_TEST_COUNT1 = 0x19C, /* Phy Test Count 1 */
- CMD_PHY_TEST_COUNT2 = 0x1A0, /* Phy Test Count 2 */
- CMD_APP_ERR_CONFIG = 0x1A4, /* Application Error Configuration */
- CMD_PND_FIFO_CTL0 = 0x1A8, /* Pending FIFO Control 0 */
- CMD_HOST_CTL = 0x1AC, /* Host Control Status */
- CMD_HOST_WR_DATA = 0x1B0, /* Host Write Data */
- CMD_HOST_RD_DATA = 0x1B4, /* Host Read Data */
- CMD_PHY_MODE_21 = 0x1B8, /* Phy Mode 21 */
- CMD_SL_MODE0 = 0x1BC, /* SL Mode 0 */
- CMD_SL_MODE1 = 0x1C0, /* SL Mode 1 */
- CMD_PND_FIFO_CTL1 = 0x1C4, /* Pending FIFO Control 1 */
-};
-
-/* SAS/SATA configuration port registers, aka phy registers */
-enum sas_sata_config_port_regs {
- PHYR_IDENTIFY = 0x00, /* info for IDENTIFY frame */
- PHYR_ADDR_LO = 0x04, /* my SAS address (low) */
- PHYR_ADDR_HI = 0x08, /* my SAS address (high) */
- PHYR_ATT_DEV_INFO = 0x0C, /* attached device info */
- PHYR_ATT_ADDR_LO = 0x10, /* attached dev SAS addr (low) */
- PHYR_ATT_ADDR_HI = 0x14, /* attached dev SAS addr (high) */
- PHYR_SATA_CTL = 0x18, /* SATA control */
- PHYR_PHY_STAT = 0x1C, /* PHY status */
- PHYR_SATA_SIG0 = 0x20, /*port SATA signature FIS(Byte 0-3) */
- PHYR_SATA_SIG1 = 0x24, /*port SATA signature FIS(Byte 4-7) */
- PHYR_SATA_SIG2 = 0x28, /*port SATA signature FIS(Byte 8-11) */
- PHYR_SATA_SIG3 = 0x2c, /*port SATA signature FIS(Byte 12-15) */
- PHYR_R_ERR_COUNT = 0x30, /* port R_ERR count register */
- PHYR_CRC_ERR_COUNT = 0x34, /* port CRC error count register */
- PHYR_WIDE_PORT = 0x38, /* wide port participating */
- PHYR_CURRENT0 = 0x80, /* current connection info 0 */
- PHYR_CURRENT1 = 0x84, /* current connection info 1 */
- PHYR_CURRENT2 = 0x88, /* current connection info 2 */
-};
-
-/* SAS/SATA Vendor Specific Port Registers */
-enum sas_sata_vsp_regs {
- VSR_PHY_STAT = 0x00, /* Phy Status */
- VSR_PHY_MODE1 = 0x01, /* phy tx */
- VSR_PHY_MODE2 = 0x02, /* tx scc */
- VSR_PHY_MODE3 = 0x03, /* pll */
- VSR_PHY_MODE4 = 0x04, /* VCO */
- VSR_PHY_MODE5 = 0x05, /* Rx */
- VSR_PHY_MODE6 = 0x06, /* CDR */
- VSR_PHY_MODE7 = 0x07, /* Impedance */
- VSR_PHY_MODE8 = 0x08, /* Voltage */
- VSR_PHY_MODE9 = 0x09, /* Test */
- VSR_PHY_MODE10 = 0x0A, /* Power */
- VSR_PHY_MODE11 = 0x0B, /* Phy Mode */
- VSR_PHY_VS0 = 0x0C, /* Vednor Specific 0 */
- VSR_PHY_VS1 = 0x0D, /* Vednor Specific 1 */
-};
-
-enum pci_cfg_registers {
- PCR_PHY_CTL = 0x40,
- PCR_PHY_CTL2 = 0x90,
- PCR_DEV_CTRL = 0xE8,
-};
-
-enum pci_cfg_register_bits {
- PCTL_PWR_ON = (0xFU << 24),
- PCTL_OFF = (0xFU << 12),
- PRD_REQ_SIZE = (0x4000),
- PRD_REQ_MASK = (0x00007000),
-};
-
-enum nvram_layout_offsets {
- NVR_SIG = 0x00, /* 0xAA, 0x55 */
- NVR_SAS_ADDR = 0x02, /* 8-byte SAS address */
-};
-
-enum chip_flavors {
- chip_6320,
- chip_6440,
- chip_6480,
-};
-
-enum port_type {
- PORT_TYPE_SAS = (1L << 1),
- PORT_TYPE_SATA = (1L << 0),
-};
-
-/* Command Table Format */
-enum ct_format {
- /* SSP */
- SSP_F_H = 0x00,
- SSP_F_IU = 0x18,
- SSP_F_MAX = 0x4D,
- /* STP */
- STP_CMD_FIS = 0x00,
- STP_ATAPI_CMD = 0x40,
- STP_F_MAX = 0x10,
- /* SMP */
- SMP_F_T = 0x00,
- SMP_F_DEP = 0x01,
- SMP_F_MAX = 0x101,
-};
-
-enum status_buffer {
- SB_EIR_OFF = 0x00, /* Error Information Record */
- SB_RFB_OFF = 0x08, /* Response Frame Buffer */
- SB_RFB_MAX = 0x400, /* RFB size*/
-};
-
-enum error_info_rec {
- CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */
- CMD_PI_ERR = (1U << 30), /* Protection info error. see flags2 */
- RSP_OVER = (1U << 29), /* rsp buffer overflow */
- RETRY_LIM = (1U << 28), /* FIS/frame retry limit exceeded */
- UNK_FIS = (1U << 27), /* unknown FIS */
- DMA_TERM = (1U << 26), /* DMA terminate primitive rx'd */
- SYNC_ERR = (1U << 25), /* SYNC rx'd during frame xmit */
- TFILE_ERR = (1U << 24), /* SATA taskfile Error bit set */
- R_ERR = (1U << 23), /* SATA returned R_ERR prim */
- RD_OFS = (1U << 20), /* Read DATA frame invalid offset */
- XFER_RDY_OFS = (1U << 19), /* XFER_RDY offset error */
- UNEXP_XFER_RDY = (1U << 18), /* unexpected XFER_RDY error */
- DATA_OVER_UNDER = (1U << 16), /* data overflow/underflow */
- INTERLOCK = (1U << 15), /* interlock error */
- NAK = (1U << 14), /* NAK rx'd */
- ACK_NAK_TO = (1U << 13), /* ACK/NAK timeout */
- CXN_CLOSED = (1U << 12), /* cxn closed w/out ack/nak */
- OPEN_TO = (1U << 11), /* I_T nexus lost, open cxn timeout */
- PATH_BLOCKED = (1U << 10), /* I_T nexus lost, pathway blocked */
- NO_DEST = (1U << 9), /* I_T nexus lost, no destination */
- STP_RES_BSY = (1U << 8), /* STP resources busy */
- BREAK = (1U << 7), /* break received */
- BAD_DEST = (1U << 6), /* bad destination */
- BAD_PROTO = (1U << 5), /* protocol not supported */
- BAD_RATE = (1U << 4), /* cxn rate not supported */
- WRONG_DEST = (1U << 3), /* wrong destination error */
- CREDIT_TO = (1U << 2), /* credit timeout */
- WDOG_TO = (1U << 1), /* watchdog timeout */
- BUF_PAR = (1U << 0), /* buffer parity error */
-};
-
-enum error_info_rec_2 {
- SLOT_BSY_ERR = (1U << 31), /* Slot Busy Error */
- GRD_CHK_ERR = (1U << 14), /* Guard Check Error */
- APP_CHK_ERR = (1U << 13), /* Application Check error */
- REF_CHK_ERR = (1U << 12), /* Reference Check Error */
- USR_BLK_NM = (1U << 0), /* User Block Number */
-};
-
-struct mvs_chip_info {
- u32 n_phy;
- u32 srs_sz;
- u32 slot_width;
-};
-
-struct mvs_err_info {
- __le32 flags;
- __le32 flags2;
-};
-
-struct mvs_prd {
- __le64 addr; /* 64-bit buffer address */
- __le32 reserved;
- __le32 len; /* 16-bit length */
-};
-
-struct mvs_cmd_hdr {
- __le32 flags; /* PRD tbl len; SAS, SATA ctl */
- __le32 lens; /* cmd, max resp frame len */
- __le32 tags; /* targ port xfer tag; tag */
- __le32 data_len; /* data xfer len */
- __le64 cmd_tbl; /* command table address */
- __le64 open_frame; /* open addr frame address */
- __le64 status_buf; /* status buffer address */
- __le64 prd_tbl; /* PRD tbl address */
- __le32 reserved[4];
-};
-
-struct mvs_port {
- struct asd_sas_port sas_port;
- u8 port_attached;
- u8 taskfileset;
- u8 wide_port_phymap;
- struct list_head list;
-};
-
-struct mvs_phy {
- struct mvs_port *port;
- struct asd_sas_phy sas_phy;
- struct sas_identify identify;
- struct scsi_device *sdev;
- u64 dev_sas_addr;
- u64 att_dev_sas_addr;
- u32 att_dev_info;
- u32 dev_info;
- u32 phy_type;
- u32 phy_status;
- u32 irq_status;
- u32 frame_rcvd_size;
- u8 frame_rcvd[32];
- u8 phy_attached;
- enum sas_linkrate minimum_linkrate;
- enum sas_linkrate maximum_linkrate;
-};
-
-struct mvs_slot_info {
- struct list_head list;
- struct sas_task *task;
- u32 n_elem;
- u32 tx;
-
- /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
- * and PRD table
- */
- void *buf;
- dma_addr_t buf_dma;
-#if _MV_DUMP
- u32 cmd_size;
-#endif
-
- void *response;
- struct mvs_port *port;
-};
-
-struct mvs_info {
- unsigned long flags;
-
- spinlock_t lock; /* host-wide lock */
- struct pci_dev *pdev; /* our device */
- void __iomem *regs; /* enhanced mode registers */
- void __iomem *peri_regs; /* peripheral registers */
-
- u8 sas_addr[SAS_ADDR_SIZE];
- struct sas_ha_struct sas; /* SCSI/SAS glue */
- struct Scsi_Host *shost;
-
- __le32 *tx; /* TX (delivery) DMA ring */
- dma_addr_t tx_dma;
- u32 tx_prod; /* cached next-producer idx */
-
- __le32 *rx; /* RX (completion) DMA ring */
- dma_addr_t rx_dma;
- u32 rx_cons; /* RX consumer idx */
-
- __le32 *rx_fis; /* RX'd FIS area */
- dma_addr_t rx_fis_dma;
-
- struct mvs_cmd_hdr *slot; /* DMA command header slots */
- dma_addr_t slot_dma;
-
- const struct mvs_chip_info *chip;
-
- u8 tags[MVS_SLOTS];
- struct mvs_slot_info slot_info[MVS_SLOTS];
- /* further per-slot information */
- struct mvs_phy phy[MVS_MAX_PHYS];
- struct mvs_port port[MVS_MAX_PHYS];
-#ifdef MVS_USE_TASKLET
- struct tasklet_struct tasklet;
-#endif
-};
-
-static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
- void *funcdata);
-static u32 mvs_read_phy_ctl(struct mvs_info *mvi, u32 port);
-static void mvs_write_phy_ctl(struct mvs_info *mvi, u32 port, u32 val);
-static u32 mvs_read_port_irq_stat(struct mvs_info *mvi, u32 port);
-static void mvs_write_port_irq_stat(struct mvs_info *mvi, u32 port, u32 val);
-static void mvs_write_port_irq_mask(struct mvs_info *mvi, u32 port, u32 val);
-static u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port);
-
-static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i);
-static void mvs_detect_porttype(struct mvs_info *mvi, int i);
-static void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st);
-static void mvs_release_task(struct mvs_info *mvi, int phy_no);
-
-static int mvs_scan_finished(struct Scsi_Host *, unsigned long);
-static void mvs_scan_start(struct Scsi_Host *);
-static int mvs_slave_configure(struct scsi_device *sdev);
-
-static struct scsi_transport_template *mvs_stt;
-
-static const struct mvs_chip_info mvs_chips[] = {
- [chip_6320] = { 2, 16, 9 },
- [chip_6440] = { 4, 16, 9 },
- [chip_6480] = { 8, 32, 10 },
-};
-
-static struct scsi_host_template mvs_sht = {
- .module = THIS_MODULE,
- .name = DRV_NAME,
- .queuecommand = sas_queuecommand,
- .target_alloc = sas_target_alloc,
- .slave_configure = mvs_slave_configure,
- .slave_destroy = sas_slave_destroy,
- .scan_finished = mvs_scan_finished,
- .scan_start = mvs_scan_start,
- .change_queue_depth = sas_change_queue_depth,
- .change_queue_type = sas_change_queue_type,
- .bios_param = sas_bios_param,
- .can_queue = 1,
- .cmd_per_lun = 1,
- .this_id = -1,
- .sg_tablesize = SG_ALL,
- .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
- .use_clustering = ENABLE_CLUSTERING,
- .eh_device_reset_handler = sas_eh_device_reset_handler,
- .eh_bus_reset_handler = sas_eh_bus_reset_handler,
- .slave_alloc = sas_slave_alloc,
- .target_destroy = sas_target_destroy,
- .ioctl = sas_ioctl,
-};
-
-static void mvs_hexdump(u32 size, u8 *data, u32 baseaddr)
-{
- u32 i;
- u32 run;
- u32 offset;
-
- offset = 0;
- while (size) {
- printk("%08X : ", baseaddr + offset);
- if (size >= 16)
- run = 16;
- else
- run = size;
- size -= run;
- for (i = 0; i < 16; i++) {
- if (i < run)
- printk("%02X ", (u32)data[i]);
- else
- printk(" ");
- }
- printk(": ");
- for (i = 0; i < run; i++)
- printk("%c", isalnum(data[i]) ? data[i] : '.');
- printk("\n");
- data = &data[16];
- offset += run;
- }
- printk("\n");
-}
-
-#if _MV_DUMP
-static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag,
- enum sas_protocol proto)
-{
- u32 offset;
- struct pci_dev *pdev = mvi->pdev;
- struct mvs_slot_info *slot = &mvi->slot_info[tag];
-
- offset = slot->cmd_size + MVS_OAF_SZ +
- sizeof(struct mvs_prd) * slot->n_elem;
- dev_printk(KERN_DEBUG, &pdev->dev, "+---->Status buffer[%d] :\n",
- tag);
- mvs_hexdump(32, (u8 *) slot->response,
- (u32) slot->buf_dma + offset);
-}
-#endif
-
-static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
- enum sas_protocol proto)
-{
-#if _MV_DUMP
- u32 sz, w_ptr;
- u64 addr;
- void __iomem *regs = mvi->regs;
- struct pci_dev *pdev = mvi->pdev;
- struct mvs_slot_info *slot = &mvi->slot_info[tag];
-
- /*Delivery Queue */
- sz = mr32(TX_CFG) & TX_RING_SZ_MASK;
- w_ptr = slot->tx;
- addr = mr32(TX_HI) << 16 << 16 | mr32(TX_LO);
- dev_printk(KERN_DEBUG, &pdev->dev,
- "Delivery Queue Size=%04d , WRT_PTR=%04X\n", sz, w_ptr);
- dev_printk(KERN_DEBUG, &pdev->dev,
- "Delivery Queue Base Address=0x%llX (PA)"
- "(tx_dma=0x%llX), Entry=%04d\n",
- addr, mvi->tx_dma, w_ptr);
- mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]),
- (u32) mvi->tx_dma + sizeof(u32) * w_ptr);
- /*Command List */
- addr = mvi->slot_dma;
- dev_printk(KERN_DEBUG, &pdev->dev,
- "Command List Base Address=0x%llX (PA)"
- "(slot_dma=0x%llX), Header=%03d\n",
- addr, slot->buf_dma, tag);
- dev_printk(KERN_DEBUG, &pdev->dev, "Command Header[%03d]:\n", tag);
- /*mvs_cmd_hdr */
- mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]),
- (u32) mvi->slot_dma + tag * sizeof(struct mvs_cmd_hdr));
- /*1.command table area */
- dev_printk(KERN_DEBUG, &pdev->dev, "+---->Command Table :\n");
- mvs_hexdump(slot->cmd_size, (u8 *) slot->buf, (u32) slot->buf_dma);
- /*2.open address frame area */
- dev_printk(KERN_DEBUG, &pdev->dev, "+---->Open Address Frame :\n");
- mvs_hexdump(MVS_OAF_SZ, (u8 *) slot->buf + slot->cmd_size,
- (u32) slot->buf_dma + slot->cmd_size);
- /*3.status buffer */
- mvs_hba_sb_dump(mvi, tag, proto);
- /*4.PRD table */
- dev_printk(KERN_DEBUG, &pdev->dev, "+---->PRD table :\n");
- mvs_hexdump(sizeof(struct mvs_prd) * slot->n_elem,
- (u8 *) slot->buf + slot->cmd_size + MVS_OAF_SZ,
- (u32) slot->buf_dma + slot->cmd_size + MVS_OAF_SZ);
-#endif
-}
-
-static void mvs_hba_cq_dump(struct mvs_info *mvi)
-{
-#if (_MV_DUMP > 2)
- u64 addr;
- void __iomem *regs = mvi->regs;
- struct pci_dev *pdev = mvi->pdev;
- u32 entry = mvi->rx_cons + 1;
- u32 rx_desc = le32_to_cpu(mvi->rx[entry]);
-
- /*Completion Queue */
- addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO);
- dev_printk(KERN_DEBUG, &pdev->dev, "Completion Task = 0x%p\n",
- mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task);
- dev_printk(KERN_DEBUG, &pdev->dev,
- "Completion List Base Address=0x%llX (PA), "
- "CQ_Entry=%04d, CQ_WP=0x%08X\n",
- addr, entry - 1, mvi->rx[0]);
- mvs_hexdump(sizeof(u32), (u8 *)(&rx_desc),
- mvi->rx_dma + sizeof(u32) * entry);
-#endif
-}
-
-static void mvs_hba_interrupt_enable(struct mvs_info *mvi)
-{
- void __iomem *regs = mvi->regs;
- u32 tmp;
-
- tmp = mr32(GBL_CTL);
-
- mw32(GBL_CTL, tmp | INT_EN);
-}
-
-static void mvs_hba_interrupt_disable(struct mvs_info *mvi)
-{
- void __iomem *regs = mvi->regs;
- u32 tmp;
-
- tmp = mr32(GBL_CTL);
-
- mw32(GBL_CTL, tmp & ~INT_EN);
-}
-
-static int mvs_int_rx(struct mvs_info *mvi, bool self_clear);
-
-/* move to PCI layer or libata core? */
-static int pci_go_64(struct pci_dev *pdev)
-{
- int rc;
-
- if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
- rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
- if (rc) {
- rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
- if (rc) {
- dev_printk(KERN_ERR, &pdev->dev,
- "64-bit DMA enable failed\n");
- return rc;
- }
- }
- } else {
- rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
- if (rc) {
- dev_printk(KERN_ERR, &pdev->dev,
- "32-bit DMA enable failed\n");
- return rc;
- }
- rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
- if (rc) {
- dev_printk(KERN_ERR, &pdev->dev,
- "32-bit consistent DMA enable failed\n");
- return rc;
- }
- }
-
- return rc;
-}
-
-static int mvs_find_tag(struct mvs_info *mvi, struct sas_task *task, u32 *tag)
-{
- if (task->lldd_task) {
- struct mvs_slot_info *slot;
- slot = (struct mvs_slot_info *) task->lldd_task;
- *tag = slot - mvi->slot_info;
- return 1;
- }
- return 0;
-}
-
-static void mvs_tag_clear(struct mvs_info *mvi, u32 tag)
-{
- void *bitmap = (void *) &mvi->tags;
- clear_bit(tag, bitmap);
-}
-
-static void mvs_tag_free(struct mvs_info *mvi, u32 tag)
-{
- mvs_tag_clear(mvi, tag);
-}
-
-static void mvs_tag_set(struct mvs_info *mvi, unsigned int tag)
-{
- void *bitmap = (void *) &mvi->tags;
- set_bit(tag, bitmap);
-}
-
-static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out)
-{
- unsigned int index, tag;
- void *bitmap = (void *) &mvi->tags;
-
- index = find_first_zero_bit(bitmap, MVS_SLOTS);
- tag = index;
- if (tag >= MVS_SLOTS)
- return -SAS_QUEUE_FULL;
- mvs_tag_set(mvi, tag);
- *tag_out = tag;
- return 0;
-}
-
-static void mvs_tag_init(struct mvs_info *mvi)
-{
- int i;
- for (i = 0; i < MVS_SLOTS; ++i)
- mvs_tag_clear(mvi, i);
-}
-
-#ifndef MVS_DISABLE_NVRAM
-static int mvs_eep_read(void __iomem *regs, u32 addr, u32 *data)
-{
- int timeout = 1000;
-
- if (addr & ~SPI_ADDR_MASK)
- return -EINVAL;
-
- writel(addr, regs + SPI_CMD);
- writel(TWSI_RD, regs + SPI_CTL);
-
- while (timeout-- > 0) {
- if (readl(regs + SPI_CTL) & TWSI_RDY) {
- *data = readl(regs + SPI_DATA);
- return 0;
- }
-
- udelay(10);
- }
-
- return -EBUSY;
-}
-
-static int mvs_eep_read_buf(void __iomem *regs, u32 addr,
- void *buf, u32 buflen)
-{
- u32 addr_end, tmp_addr, i, j;
- u32 tmp = 0;
- int rc;
- u8 *tmp8, *buf8 = buf;
-
- addr_end = addr + buflen;
- tmp_addr = ALIGN(addr, 4);
- if (addr > 0xff)
- return -EINVAL;
-
- j = addr & 0x3;
- if (j) {
- rc = mvs_eep_read(regs, tmp_addr, &tmp);
- if (rc)
- return rc;
-
- tmp8 = (u8 *)&tmp;
- for (i = j; i < 4; i++)
- *buf8++ = tmp8[i];
-
- tmp_addr += 4;
- }
-
- for (j = ALIGN(addr_end, 4); tmp_addr < j; tmp_addr += 4) {
- rc = mvs_eep_read(regs, tmp_addr, &tmp);
- if (rc)
- return rc;
-
- memcpy(buf8, &tmp, 4);
- buf8 += 4;
- }
-
- if (tmp_addr < addr_end) {
- rc = mvs_eep_read(regs, tmp_addr, &tmp);
- if (rc)
- return rc;
-
- tmp8 = (u8 *)&tmp;
- j = addr_end - tmp_addr;
- for (i = 0; i < j; i++)
- *buf8++ = tmp8[i];
-
- tmp_addr += 4;
- }
-
- return 0;
-}
-#endif
-
-static int mvs_nvram_read(struct mvs_info *mvi, u32 addr,
- void *buf, u32 buflen)
-{
-#ifndef MVS_DISABLE_NVRAM
- void __iomem *regs = mvi->regs;
- int rc, i;
- u32 sum;
- u8 hdr[2], *tmp;
- const char *msg;
-
- rc = mvs_eep_read_buf(regs, addr, &hdr, 2);
- if (rc) {
- msg = "nvram hdr read failed";
- goto err_out;
- }
- rc = mvs_eep_read_buf(regs, addr + 2, buf, buflen);
- if (rc) {
- msg = "nvram read failed";
- goto err_out;
- }
-
- if (hdr[0] != 0x5A) {
- /* entry id */
- msg = "invalid nvram entry id";
- rc = -ENOENT;
- goto err_out;
- }
-
- tmp = buf;
- sum = ((u32)hdr[0]) + ((u32)hdr[1]);
- for (i = 0; i < buflen; i++)
- sum += ((u32)tmp[i]);
-
- if (sum) {
- msg = "nvram checksum failure";
- rc = -EILSEQ;
- goto err_out;
- }
-
- return 0;
-
-err_out:
- dev_printk(KERN_ERR, &mvi->pdev->dev, "%s", msg);
- return rc;
-#else
- /* FIXME , For SAS target mode */
- memcpy(buf, "\x50\x05\x04\x30\x11\xab\x00\x00", 8);
- return 0;
-#endif
-}
-
-static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)
-{
- struct mvs_phy *phy = &mvi->phy[i];
- struct asd_sas_phy *sas_phy = mvi->sas.sas_phy[i];
-
- if (!phy->phy_attached)
- return;
-
- if (sas_phy->phy) {
- struct sas_phy *sphy = sas_phy->phy;
-
- sphy->negotiated_linkrate = sas_phy->linkrate;
- sphy->minimum_linkrate = phy->minimum_linkrate;
- sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
- sphy->maximum_linkrate = phy->maximum_linkrate;
- sphy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
- }
-
- if (phy->phy_type & PORT_TYPE_SAS) {
- struct sas_identify_frame *id;
-
- id = (struct sas_identify_frame *)phy->frame_rcvd;
- id->dev_type = phy->identify.device_type;
- id->initiator_bits = SAS_PROTOCOL_ALL;
- id->target_bits = phy->identify.target_port_protocols;
- } else if (phy->phy_type & PORT_TYPE_SATA) {
- /* TODO */
- }
- mvi->sas.sas_phy[i]->frame_rcvd_size = phy->frame_rcvd_size;
- mvi->sas.notify_port_event(mvi->sas.sas_phy[i],
- PORTE_BYTES_DMAED);
-}
-
-static int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time)
-{
- /* give the phy enabling interrupt event time to come in (1s
- * is empirically about all it takes) */
- if (time < HZ)
- return 0;
- /* Wait for discovery to finish */
- scsi_flush_work(shost);
- return 1;
-}
-
-static void mvs_scan_start(struct Scsi_Host *shost)
-{
- int i;
- struct mvs_info *mvi = SHOST_TO_SAS_HA(shost)->lldd_ha;
-
- for (i = 0; i < mvi->chip->n_phy; ++i) {
- mvs_bytes_dmaed(mvi, i);
- }
-}
-
-static int mvs_slave_configure(struct scsi_device *sdev)
-{
- struct domain_device *dev = sdev_to_domain_dev(sdev);
- int ret = sas_slave_configure(sdev);
-
- if (ret)
- return ret;
-
- if (dev_is_sata(dev)) {
- /* struct ata_port *ap = dev->sata_dev.ap; */
- /* struct ata_device *adev = ap->link.device; */
-
- /* clamp at no NCQ for the time being */
- /* adev->flags |= ATA_DFLAG_NCQ_OFF; */
- scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 1);
- }
- return 0;
-}
-
-static void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events)
-{
- struct pci_dev *pdev = mvi->pdev;
- struct sas_ha_struct *sas_ha = &mvi->sas;
- struct mvs_phy *phy = &mvi->phy[phy_no];
- struct asd_sas_phy *sas_phy = &phy->sas_phy;
-
- phy->irq_status = mvs_read_port_irq_stat(mvi, phy_no);
- /*
- * events is port event now ,
- * we need check the interrupt status which belongs to per port.
- */
- dev_printk(KERN_DEBUG, &pdev->dev,
- "Port %d Event = %X\n",
- phy_no, phy->irq_status);
-
- if (phy->irq_status & (PHYEV_POOF | PHYEV_DEC_ERR)) {
- mvs_release_task(mvi, phy_no);
- if (!mvs_is_phy_ready(mvi, phy_no)) {
- sas_phy_disconnected(sas_phy);
- sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
- dev_printk(KERN_INFO, &pdev->dev,
- "Port %d Unplug Notice\n", phy_no);
-
- } else
- mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, NULL);
- }
- if (!(phy->irq_status & PHYEV_DEC_ERR)) {
- if (phy->irq_status & PHYEV_COMWAKE) {
- u32 tmp = mvs_read_port_irq_mask(mvi, phy_no);
- mvs_write_port_irq_mask(mvi, phy_no,
- tmp | PHYEV_SIG_FIS);
- }
- if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) {
- phy->phy_status = mvs_is_phy_ready(mvi, phy_no);
- if (phy->phy_status) {
- mvs_detect_porttype(mvi, phy_no);
-
- if (phy->phy_type & PORT_TYPE_SATA) {
- u32 tmp = mvs_read_port_irq_mask(mvi,
- phy_no);
- tmp &= ~PHYEV_SIG_FIS;
- mvs_write_port_irq_mask(mvi,
- phy_no, tmp);
- }
-
- mvs_update_phyinfo(mvi, phy_no, 0);
- sas_ha->notify_phy_event(sas_phy,
- PHYE_OOB_DONE);
- mvs_bytes_dmaed(mvi, phy_no);
- } else {
- dev_printk(KERN_DEBUG, &pdev->dev,
- "plugin interrupt but phy is gone\n");
- mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET,
- NULL);
- }
- } else if (phy->irq_status & PHYEV_BROAD_CH) {
- mvs_release_task(mvi, phy_no);
- sas_ha->notify_port_event(sas_phy,
- PORTE_BROADCAST_RCVD);
- }
- }
- mvs_write_port_irq_stat(mvi, phy_no, phy->irq_status);
-}
-
-static void mvs_int_sata(struct mvs_info *mvi)
-{
- u32 tmp;
- void __iomem *regs = mvi->regs;
- tmp = mr32(INT_STAT_SRS);
- mw32(INT_STAT_SRS, tmp & 0xFFFF);
-}
-
-static void mvs_slot_reset(struct mvs_info *mvi, struct sas_task *task,
- u32 slot_idx)
-{
- void __iomem *regs = mvi->regs;
- struct domain_device *dev = task->dev;
- struct asd_sas_port *sas_port = dev->port;
- struct mvs_port *port = mvi->slot_info[slot_idx].port;
- u32 reg_set, phy_mask;
-
- if (!sas_protocol_ata(task->task_proto)) {
- reg_set = 0;
- phy_mask = (port->wide_port_phymap) ? port->wide_port_phymap :
- sas_port->phy_mask;
- } else {
- reg_set = port->taskfileset;
- phy_mask = sas_port->phy_mask;
- }
- mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | slot_idx |
- (TXQ_CMD_SLOT_RESET << TXQ_CMD_SHIFT) |
- (phy_mask << TXQ_PHY_SHIFT) |
- (reg_set << TXQ_SRS_SHIFT));
-
- mw32(TX_PROD_IDX, mvi->tx_prod);
- mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
-}
-
-static int mvs_sata_done(struct mvs_info *mvi, struct sas_task *task,
- u32 slot_idx, int err)
-{
- struct mvs_port *port = mvi->slot_info[slot_idx].port;
- struct task_status_struct *tstat = &task->task_status;
- struct ata_task_resp *resp = (struct ata_task_resp *)tstat->buf;
- int stat = SAM_GOOD;
-
- resp->frame_len = sizeof(struct dev_to_host_fis);
- memcpy(&resp->ending_fis[0],
- SATA_RECEIVED_D2H_FIS(port->taskfileset),
- sizeof(struct dev_to_host_fis));
- tstat->buf_valid_size = sizeof(*resp);
- if (unlikely(err))
- stat = SAS_PROTO_RESPONSE;
- return stat;
-}
-
-static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
-{
- u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
- mvs_tag_clear(mvi, slot_idx);
-}
-
-static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
- struct mvs_slot_info *slot, u32 slot_idx)
-{
- if (!sas_protocol_ata(task->task_proto))
- if (slot->n_elem)
- pci_unmap_sg(mvi->pdev, task->scatter,
- slot->n_elem, task->data_dir);
-
- switch (task->task_proto) {
- case SAS_PROTOCOL_SMP:
- pci_unmap_sg(mvi->pdev, &task->smp_task.smp_resp, 1,
- PCI_DMA_FROMDEVICE);
- pci_unmap_sg(mvi->pdev, &task->smp_task.smp_req, 1,
- PCI_DMA_TODEVICE);
- break;
-
- case SAS_PROTOCOL_SATA:
- case SAS_PROTOCOL_STP:
- case SAS_PROTOCOL_SSP:
- default:
- /* do nothing */
- break;
- }
- list_del(&slot->list);
- task->lldd_task = NULL;
- slot->task = NULL;
- slot->port = NULL;
-}
-
-static int mvs_slot_err(struct mvs_info *mvi, struct sas_task *task,
- u32 slot_idx)
-{
- struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
- u32 err_dw0 = le32_to_cpu(*(u32 *) (slot->response));
- u32 err_dw1 = le32_to_cpu(*(u32 *) (slot->response + 4));
- int stat = SAM_CHECK_COND;
-
- if (err_dw1 & SLOT_BSY_ERR) {
- stat = SAS_QUEUE_FULL;
- mvs_slot_reset(mvi, task, slot_idx);
- }
- switch (task->task_proto) {
- case SAS_PROTOCOL_SSP:
- break;
- case SAS_PROTOCOL_SMP:
- break;
- case SAS_PROTOCOL_SATA:
- case SAS_PROTOCOL_STP:
- case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
- if (err_dw0 & TFILE_ERR)
- stat = mvs_sata_done(mvi, task, slot_idx, 1);
- break;
- default:
- break;
- }
-
- mvs_hexdump(16, (u8 *) slot->response, 0);
- return stat;
-}
-
-static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
-{
- u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
- struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
- struct sas_task *task = slot->task;
- struct task_status_struct *tstat;
- struct mvs_port *port;
- bool aborted;
- void *to;
-
- if (unlikely(!task || !task->lldd_task))
- return -1;
-
- mvs_hba_cq_dump(mvi);
-
- spin_lock(&task->task_state_lock);
- aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED;
- if (!aborted) {
- task->task_state_flags &=
- ~(SAS_TASK_STATE_PENDING | SAS_TASK_AT_INITIATOR);
- task->task_state_flags |= SAS_TASK_STATE_DONE;
- }
- spin_unlock(&task->task_state_lock);
-
- if (aborted) {
- mvs_slot_task_free(mvi, task, slot, slot_idx);
- mvs_slot_free(mvi, rx_desc);
- return -1;
- }
-
- port = slot->port;
- tstat = &task->task_status;
- memset(tstat, 0, sizeof(*tstat));
- tstat->resp = SAS_TASK_COMPLETE;
-
- if (unlikely(!port->port_attached || flags)) {
- mvs_slot_err(mvi, task, slot_idx);
- if (!sas_protocol_ata(task->task_proto))
- tstat->stat = SAS_PHY_DOWN;
- goto out;
- }
-
- /* error info record present */
- if (unlikely((rx_desc & RXQ_ERR) && (*(u64 *) slot->response))) {
- tstat->stat = mvs_slot_err(mvi, task, slot_idx);
- goto out;
- }
-
- switch (task->task_proto) {
- case SAS_PROTOCOL_SSP:
- /* hw says status == 0, datapres == 0 */
- if (rx_desc & RXQ_GOOD) {
- tstat->stat = SAM_GOOD;
- tstat->resp = SAS_TASK_COMPLETE;
- }
- /* response frame present */
- else if (rx_desc & RXQ_RSP) {
- struct ssp_response_iu *iu =
- slot->response + sizeof(struct mvs_err_info);
- sas_ssp_task_response(&mvi->pdev->dev, task, iu);
- }
-
- /* should never happen? */
- else
- tstat->stat = SAM_CHECK_COND;
- break;
-
- case SAS_PROTOCOL_SMP: {
- struct scatterlist *sg_resp = &task->smp_task.smp_resp;
- tstat->stat = SAM_GOOD;
- to = kmap_atomic(sg_page(sg_resp), KM_IRQ0);
- memcpy(to + sg_resp->offset,
- slot->response + sizeof(struct mvs_err_info),
- sg_dma_len(sg_resp));
- kunmap_atomic(to, KM_IRQ0);
- break;
- }
-
- case SAS_PROTOCOL_SATA:
- case SAS_PROTOCOL_STP:
- case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: {
- tstat->stat = mvs_sata_done(mvi, task, slot_idx, 0);
- break;
- }
-
- default:
- tstat->stat = SAM_CHECK_COND;
- break;
- }
-
-out:
- mvs_slot_task_free(mvi, task, slot, slot_idx);
- if (unlikely(tstat->stat != SAS_QUEUE_FULL))
- mvs_slot_free(mvi, rx_desc);
-
- spin_unlock(&mvi->lock);
- task->task_done(task);
- spin_lock(&mvi->lock);
- return tstat->stat;
-}
-
-static void mvs_release_task(struct mvs_info *mvi, int phy_no)
-{
- struct list_head *pos, *n;
- struct mvs_slot_info *slot;
- struct mvs_phy *phy = &mvi->phy[phy_no];
- struct mvs_port *port = phy->port;
- u32 rx_desc;
-
- if (!port)
- return;
-
- list_for_each_safe(pos, n, &port->list) {
- slot = container_of(pos, struct mvs_slot_info, list);
- rx_desc = (u32) (slot - mvi->slot_info);
- mvs_slot_complete(mvi, rx_desc, 1);
- }
-}
-
-static void mvs_int_full(struct mvs_info *mvi)
-{
- void __iomem *regs = mvi->regs;
- u32 tmp, stat;
- int i;
-
- stat = mr32(INT_STAT);
-
- mvs_int_rx(mvi, false);
-
- for (i = 0; i < MVS_MAX_PORTS; i++) {
- tmp = (stat >> i) & (CINT_PORT | CINT_PORT_STOPPED);
- if (tmp)
- mvs_int_port(mvi, i, tmp);
- }
-
- if (stat & CINT_SRS)
- mvs_int_sata(mvi);
-
- mw32(INT_STAT, stat);
-}
-
-static int mvs_int_rx(struct mvs_info *mvi, bool self_clear)
-{
- void __iomem *regs = mvi->regs;
- u32 rx_prod_idx, rx_desc;
- bool attn = false;
- struct pci_dev *pdev = mvi->pdev;
-
- /* the first dword in the RX ring is special: it contains
- * a mirror of the hardware's RX producer index, so that
- * we don't have to stall the CPU reading that register.
- * The actual RX ring is offset by one dword, due to this.
- */
- rx_prod_idx = mvi->rx_cons;
- mvi->rx_cons = le32_to_cpu(mvi->rx[0]);
- if (mvi->rx_cons == 0xfff) /* h/w hasn't touched RX ring yet */
- return 0;
-
- /* The CMPL_Q may come late, read from register and try again
- * note: if coalescing is enabled,
- * it will need to read from register every time for sure
- */
- if (mvi->rx_cons == rx_prod_idx)
- mvi->rx_cons = mr32(RX_CONS_IDX) & RX_RING_SZ_MASK;
-
- if (mvi->rx_cons == rx_prod_idx)
- return 0;
-
- while (mvi->rx_cons != rx_prod_idx) {
-
- /* increment our internal RX consumer pointer */
- rx_prod_idx = (rx_prod_idx + 1) & (MVS_RX_RING_SZ - 1);
-
- rx_desc = le32_to_cpu(mvi->rx[rx_prod_idx + 1]);
-
- if (likely(rx_desc & RXQ_DONE))
- mvs_slot_complete(mvi, rx_desc, 0);
- if (rx_desc & RXQ_ATTN) {
- attn = true;
- dev_printk(KERN_DEBUG, &pdev->dev, "ATTN %X\n",
- rx_desc);
- } else if (rx_desc & RXQ_ERR) {
- if (!(rx_desc & RXQ_DONE))
- mvs_slot_complete(mvi, rx_desc, 0);
- dev_printk(KERN_DEBUG, &pdev->dev, "RXQ_ERR %X\n",
- rx_desc);
- } else if (rx_desc & RXQ_SLOT_RESET) {
- dev_printk(KERN_DEBUG, &pdev->dev, "Slot reset[%X]\n",
- rx_desc);
- mvs_slot_free(mvi, rx_desc);
- }
- }
-
- if (attn && self_clear)
- mvs_int_full(mvi);
-
- return 0;
-}
-
-#ifdef MVS_USE_TASKLET
-static void mvs_tasklet(unsigned long data)
-{
- struct mvs_info *mvi = (struct mvs_info *) data;
- unsigned long flags;
-
- spin_lock_irqsave(&mvi->lock, flags);
-
-#ifdef MVS_DISABLE_MSI
- mvs_int_full(mvi);
-#else
- mvs_int_rx(mvi, true);
-#endif
- spin_unlock_irqrestore(&mvi->lock, flags);
-}
-#endif
-
-static irqreturn_t mvs_interrupt(int irq, void *opaque)
-{
- struct mvs_info *mvi = opaque;
- void __iomem *regs = mvi->regs;
- u32 stat;
-
- stat = mr32(GBL_INT_STAT);
-
- if (stat == 0 || stat == 0xffffffff)
- return IRQ_NONE;
-
- /* clear CMD_CMPLT ASAP */
- mw32_f(INT_STAT, CINT_DONE);
-
-#ifndef MVS_USE_TASKLET
- spin_lock(&mvi->lock);
-
- mvs_int_full(mvi);
-
- spin_unlock(&mvi->lock);
-#else
- tasklet_schedule(&mvi->tasklet);
-#endif
- return IRQ_HANDLED;
-}
-
-#ifndef MVS_DISABLE_MSI
-static irqreturn_t mvs_msi_interrupt(int irq, void *opaque)
-{
- struct mvs_info *mvi = opaque;
-
-#ifndef MVS_USE_TASKLET
- spin_lock(&mvi->lock);
-
- mvs_int_rx(mvi, true);
-
- spin_unlock(&mvi->lock);
-#else
- tasklet_schedule(&mvi->tasklet);
-#endif
- return IRQ_HANDLED;
-}
-#endif
-
-struct mvs_task_exec_info {
- struct sas_task *task;
- struct mvs_cmd_hdr *hdr;
- struct mvs_port *port;
- u32 tag;
- int n_elem;
-};
-
-static int mvs_task_prep_smp(struct mvs_info *mvi,
- struct mvs_task_exec_info *tei)
-{
- int elem, rc, i;
- struct sas_task *task = tei->task;
- struct mvs_cmd_hdr *hdr = tei->hdr;
- struct scatterlist *sg_req, *sg_resp;
- u32 req_len, resp_len, tag = tei->tag;
- void *buf_tmp;
- u8 *buf_oaf;
- dma_addr_t buf_tmp_dma;
- struct mvs_prd *buf_prd;
- struct scatterlist *sg;
- struct mvs_slot_info *slot = &mvi->slot_info[tag];
- struct asd_sas_port *sas_port = task->dev->port;
- u32 flags = (tei->n_elem << MCH_PRD_LEN_SHIFT);
-#if _MV_DUMP
- u8 *buf_cmd;
- void *from;
-#endif
- /*
- * DMA-map SMP request, response buffers
- */
- sg_req = &task->smp_task.smp_req;
- elem = pci_map_sg(mvi->pdev, sg_req, 1, PCI_DMA_TODEVICE);
- if (!elem)
- return -ENOMEM;
- req_len = sg_dma_len(sg_req);
-
- sg_resp = &task->smp_task.smp_resp;
- elem = pci_map_sg(mvi->pdev, sg_resp, 1, PCI_DMA_FROMDEVICE);
- if (!elem) {
- rc = -ENOMEM;
- goto err_out;
- }
- resp_len = sg_dma_len(sg_resp);
-
- /* must be in dwords */
- if ((req_len & 0x3) || (resp_len & 0x3)) {
- rc = -EINVAL;
- goto err_out_2;
- }
-
- /*
- * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs
- */
-
- /* region 1: command table area (MVS_SSP_CMD_SZ bytes) ************** */
- buf_tmp = slot->buf;
- buf_tmp_dma = slot->buf_dma;
-
-#if _MV_DUMP
- buf_cmd = buf_tmp;
- hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma);
- buf_tmp += req_len;
- buf_tmp_dma += req_len;
- slot->cmd_size = req_len;
-#else
- hdr->cmd_tbl = cpu_to_le64(sg_dma_address(sg_req));
-#endif
-
- /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */
- buf_oaf = buf_tmp;
- hdr->open_frame = cpu_to_le64(buf_tmp_dma);
-
- buf_tmp += MVS_OAF_SZ;
- buf_tmp_dma += MVS_OAF_SZ;
-
- /* region 3: PRD table ********************************************* */
- buf_prd = buf_tmp;
- if (tei->n_elem)
- hdr->prd_tbl = cpu_to_le64(buf_tmp_dma);
- else
- hdr->prd_tbl = 0;
-
- i = sizeof(struct mvs_prd) * tei->n_elem;
- buf_tmp += i;
- buf_tmp_dma += i;
-
- /* region 4: status buffer (larger the PRD, smaller this buf) ****** */
- slot->response = buf_tmp;
- hdr->status_buf = cpu_to_le64(buf_tmp_dma);
-
- /*
- * Fill in TX ring and command slot header
- */
- slot->tx = mvi->tx_prod;
- mvi->tx[mvi->tx_prod] = cpu_to_le32((TXQ_CMD_SMP << TXQ_CMD_SHIFT) |
- TXQ_MODE_I | tag |
- (sas_port->phy_mask << TXQ_PHY_SHIFT));
-
- hdr->flags |= flags;
- hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | ((req_len - 4) / 4));
- hdr->tags = cpu_to_le32(tag);
- hdr->data_len = 0;
-
- /* generate open address frame hdr (first 12 bytes) */
- buf_oaf[0] = (1 << 7) | (0 << 4) | 0x01; /* initiator, SMP, ftype 1h */
- buf_oaf[1] = task->dev->linkrate & 0xf;
- *(u16 *)(buf_oaf + 2) = 0xFFFF; /* SAS SPEC */
- memcpy(buf_oaf + 4, task->dev->sas_addr, SAS_ADDR_SIZE);
-
- /* fill in PRD (scatter/gather) table, if any */
- for_each_sg(task->scatter, sg, tei->n_elem, i) {
- buf_prd->addr = cpu_to_le64(sg_dma_address(sg));
- buf_prd->len = cpu_to_le32(sg_dma_len(sg));
- buf_prd++;
- }
-
-#if _MV_DUMP
- /* copy cmd table */
- from = kmap_atomic(sg_page(sg_req), KM_IRQ0);
- memcpy(buf_cmd, from + sg_req->offset, req_len);
- kunmap_atomic(from, KM_IRQ0);
-#endif
- return 0;
-
-err_out_2:
- pci_unmap_sg(mvi->pdev, &tei->task->smp_task.smp_resp, 1,
- PCI_DMA_FROMDEVICE);
-err_out:
- pci_unmap_sg(mvi->pdev, &tei->task->smp_task.smp_req, 1,
- PCI_DMA_TODEVICE);
- return rc;
-}
-
-static void mvs_free_reg_set(struct mvs_info *mvi, struct mvs_port *port)
-{
- void __iomem *regs = mvi->regs;
- u32 tmp, offs;
- u8 *tfs = &port->taskfileset;
-
- if (*tfs == MVS_ID_NOT_MAPPED)
- return;
-
- offs = 1U << ((*tfs & 0x0f) + PCS_EN_SATA_REG_SHIFT);
- if (*tfs < 16) {
- tmp = mr32(PCS);
- mw32(PCS, tmp & ~offs);
- } else {
- tmp = mr32(CTL);
- mw32(CTL, tmp & ~offs);
- }
-
- tmp = mr32(INT_STAT_SRS) & (1U << *tfs);
- if (tmp)
- mw32(INT_STAT_SRS, tmp);
-
- *tfs = MVS_ID_NOT_MAPPED;
-}
-
-static u8 mvs_assign_reg_set(struct mvs_info *mvi, struct mvs_port *port)
-{
- int i;
- u32 tmp, offs;
- void __iomem *regs = mvi->regs;
-
- if (port->taskfileset != MVS_ID_NOT_MAPPED)
- return 0;
-
- tmp = mr32(PCS);
-
- for (i = 0; i < mvi->chip->srs_sz; i++) {
- if (i == 16)
- tmp = mr32(CTL);
- offs = 1U << ((i & 0x0f) + PCS_EN_SATA_REG_SHIFT);
- if (!(tmp & offs)) {
- port->taskfileset = i;
-
- if (i < 16)
- mw32(PCS, tmp | offs);
- else
- mw32(CTL, tmp | offs);
- tmp = mr32(INT_STAT_SRS) & (1U << i);
- if (tmp)
- mw32(INT_STAT_SRS, tmp);
- return 0;
- }
- }
- return MVS_ID_NOT_MAPPED;
-}
-
-static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
-{
- struct ata_queued_cmd *qc = task->uldd_task;
-
- if (qc) {
- if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
- qc->tf.command == ATA_CMD_FPDMA_READ) {
- *tag = qc->tag;
- return 1;
- }
- }
-
- return 0;
-}
-
-static int mvs_task_prep_ata(struct mvs_info *mvi,
- struct mvs_task_exec_info *tei)
-{
- struct sas_task *task = tei->task;
- struct domain_device *dev = task->dev;
- struct mvs_cmd_hdr *hdr = tei->hdr;
- struct asd_sas_port *sas_port = dev->port;
- struct mvs_slot_info *slot;
- struct scatterlist *sg;
- struct mvs_prd *buf_prd;
- struct mvs_port *port = tei->port;
- u32 tag = tei->tag;
- u32 flags = (tei->n_elem << MCH_PRD_LEN_SHIFT);
- void *buf_tmp;
- u8 *buf_cmd, *buf_oaf;
- dma_addr_t buf_tmp_dma;
- u32 i, req_len, resp_len;
- const u32 max_resp_len = SB_RFB_MAX;
-
- if (mvs_assign_reg_set(mvi, port) == MVS_ID_NOT_MAPPED)
- return -EBUSY;
-
- slot = &mvi->slot_info[tag];
- slot->tx = mvi->tx_prod;
- mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag |
- (TXQ_CMD_STP << TXQ_CMD_SHIFT) |
- (sas_port->phy_mask << TXQ_PHY_SHIFT) |
- (port->taskfileset << TXQ_SRS_SHIFT));
-
- if (task->ata_task.use_ncq)
- flags |= MCH_FPDMA;
- if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) {
- if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI)
- flags |= MCH_ATAPI;
- }
-
- /* FIXME: fill in port multiplier number */
-
- hdr->flags = cpu_to_le32(flags);
-
- /* FIXME: the low order order 5 bits for the TAG if enable NCQ */
- if (task->ata_task.use_ncq && mvs_get_ncq_tag(task, &hdr->tags))
- task->ata_task.fis.sector_count |= hdr->tags << 3;
- else
- hdr->tags = cpu_to_le32(tag);
- hdr->data_len = cpu_to_le32(task->total_xfer_len);
-
- /*
- * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs
- */
-
- /* region 1: command table area (MVS_ATA_CMD_SZ bytes) ************** */
- buf_cmd = buf_tmp = slot->buf;
- buf_tmp_dma = slot->buf_dma;
-
- hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma);
-
- buf_tmp += MVS_ATA_CMD_SZ;
- buf_tmp_dma += MVS_ATA_CMD_SZ;
-#if _MV_DUMP
- slot->cmd_size = MVS_ATA_CMD_SZ;
-#endif
-
- /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */
- /* used for STP. unused for SATA? */
- buf_oaf = buf_tmp;
- hdr->open_frame = cpu_to_le64(buf_tmp_dma);
-
- buf_tmp += MVS_OAF_SZ;
- buf_tmp_dma += MVS_OAF_SZ;
-
- /* region 3: PRD table ********************************************* */
- buf_prd = buf_tmp;
- if (tei->n_elem)
- hdr->prd_tbl = cpu_to_le64(buf_tmp_dma);
- else
- hdr->prd_tbl = 0;
-
- i = sizeof(struct mvs_prd) * tei->n_elem;
- buf_tmp += i;
- buf_tmp_dma += i;
-
- /* region 4: status buffer (larger the PRD, smaller this buf) ****** */
- /* FIXME: probably unused, for SATA. kept here just in case
- * we get a STP/SATA error information record
- */
- slot->response = buf_tmp;
- hdr->status_buf = cpu_to_le64(buf_tmp_dma);
-
- req_len = sizeof(struct host_to_dev_fis);
- resp_len = MVS_SLOT_BUF_SZ - MVS_ATA_CMD_SZ -
- sizeof(struct mvs_err_info) - i;
-
- /* request, response lengths */
- resp_len = min(resp_len, max_resp_len);
- hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | (req_len / 4));
-
- task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
- /* fill in command FIS and ATAPI CDB */
- memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis));
- if (dev->sata_dev.command_set == ATAPI_COMMAND_SET)
- memcpy(buf_cmd + STP_ATAPI_CMD,
- task->ata_task.atapi_packet, 16);
-
- /* generate open address frame hdr (first 12 bytes) */
- buf_oaf[0] = (1 << 7) | (2 << 4) | 0x1; /* initiator, STP, ftype 1h */
- buf_oaf[1] = task->dev->linkrate & 0xf;
- *(u16 *)(buf_oaf + 2) = cpu_to_be16(tag);
- memcpy(buf_oaf + 4, task->dev->sas_addr, SAS_ADDR_SIZE);
-
- /* fill in PRD (scatter/gather) table, if any */
- for_each_sg(task->scatter, sg, tei->n_elem, i) {
- buf_prd->addr = cpu_to_le64(sg_dma_address(sg));
- buf_prd->len = cpu_to_le32(sg_dma_len(sg));
- buf_prd++;
- }
-
- return 0;
-}
-
-static int mvs_task_prep_ssp(struct mvs_info *mvi,
- struct mvs_task_exec_info *tei)
-{
- struct sas_task *task = tei->task;
- struct mvs_cmd_hdr *hdr = tei->hdr;
- struct mvs_port *port = tei->port;
- struct mvs_slot_info *slot;
- struct scatterlist *sg;
- struct mvs_prd *buf_prd;
- struct ssp_frame_hdr *ssp_hdr;
- void *buf_tmp;
- u8 *buf_cmd, *buf_oaf, fburst = 0;
- dma_addr_t buf_tmp_dma;
- u32 flags;
- u32 resp_len, req_len, i, tag = tei->tag;
- const u32 max_resp_len = SB_RFB_MAX;
- u8 phy_mask;
-
- slot = &mvi->slot_info[tag];
-
- phy_mask = (port->wide_port_phymap) ? port->wide_port_phymap :
- task->dev->port->phy_mask;
- slot->tx = mvi->tx_prod;
- mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag |
- (TXQ_CMD_SSP << TXQ_CMD_SHIFT) |
- (phy_mask << TXQ_PHY_SHIFT));
-
- flags = MCH_RETRY;
- if (task->ssp_task.enable_first_burst) {
- flags |= MCH_FBURST;
- fburst = (1 << 7);
- }
- hdr->flags = cpu_to_le32(flags |
- (tei->n_elem << MCH_PRD_LEN_SHIFT) |
- (MCH_SSP_FR_CMD << MCH_SSP_FR_TYPE_SHIFT));
-
- hdr->tags = cpu_to_le32(tag);
- hdr->data_len = cpu_to_le32(task->total_xfer_len);
-
- /*
- * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs
- */
-
- /* region 1: command table area (MVS_SSP_CMD_SZ bytes) ************** */
- buf_cmd = buf_tmp = slot->buf;
- buf_tmp_dma = slot->buf_dma;
-
- hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma);
-
- buf_tmp += MVS_SSP_CMD_SZ;
- buf_tmp_dma += MVS_SSP_CMD_SZ;
-#if _MV_DUMP
- slot->cmd_size = MVS_SSP_CMD_SZ;
-#endif
-
- /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */
- buf_oaf = buf_tmp;
- hdr->open_frame = cpu_to_le64(buf_tmp_dma);
-
- buf_tmp += MVS_OAF_SZ;
- buf_tmp_dma += MVS_OAF_SZ;
-
- /* region 3: PRD table ********************************************* */
- buf_prd = buf_tmp;
- if (tei->n_elem)
- hdr->prd_tbl = cpu_to_le64(buf_tmp_dma);
- else
- hdr->prd_tbl = 0;
-
- i = sizeof(struct mvs_prd) * tei->n_elem;
- buf_tmp += i;
- buf_tmp_dma += i;
-
- /* region 4: status buffer (larger the PRD, smaller this buf) ****** */
- slot->response = buf_tmp;
- hdr->status_buf = cpu_to_le64(buf_tmp_dma);
-
- resp_len = MVS_SLOT_BUF_SZ - MVS_SSP_CMD_SZ - MVS_OAF_SZ -
- sizeof(struct mvs_err_info) - i;
- resp_len = min(resp_len, max_resp_len);
-
- req_len = sizeof(struct ssp_frame_hdr) + 28;
-
- /* request, response lengths */
- hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | (req_len / 4));
-
- /* generate open address frame hdr (first 12 bytes) */
- buf_oaf[0] = (1 << 7) | (1 << 4) | 0x1; /* initiator, SSP, ftype 1h */
- buf_oaf[1] = task->dev->linkrate & 0xf;
- *(u16 *)(buf_oaf + 2) = cpu_to_be16(tag);
- memcpy(buf_oaf + 4, task->dev->sas_addr, SAS_ADDR_SIZE);
-
- /* fill in SSP frame header (Command Table.SSP frame header) */
- ssp_hdr = (struct ssp_frame_hdr *)buf_cmd;
- ssp_hdr->frame_type = SSP_COMMAND;
- memcpy(ssp_hdr->hashed_dest_addr, task->dev->hashed_sas_addr,
- HASHED_SAS_ADDR_SIZE);
- memcpy(ssp_hdr->hashed_src_addr,
- task->dev->port->ha->hashed_sas_addr, HASHED_SAS_ADDR_SIZE);
- ssp_hdr->tag = cpu_to_be16(tag);
-
- /* fill in command frame IU */
- buf_cmd += sizeof(*ssp_hdr);
- memcpy(buf_cmd, &task->ssp_task.LUN, 8);
- buf_cmd[9] = fburst | task->ssp_task.task_attr |
- (task->ssp_task.task_prio << 3);
- memcpy(buf_cmd + 12, &task->ssp_task.cdb, 16);
-
- /* fill in PRD (scatter/gather) table, if any */
- for_each_sg(task->scatter, sg, tei->n_elem, i) {
- buf_prd->addr = cpu_to_le64(sg_dma_address(sg));
- buf_prd->len = cpu_to_le32(sg_dma_len(sg));
- buf_prd++;
- }
-
- return 0;
-}
-
-static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
-{
- struct domain_device *dev = task->dev;
- struct mvs_info *mvi = dev->port->ha->lldd_ha;
- struct pci_dev *pdev = mvi->pdev;
- void __iomem *regs = mvi->regs;
- struct mvs_task_exec_info tei;
- struct sas_task *t = task;
- struct mvs_slot_info *slot;
- u32 tag = 0xdeadbeef, rc, n_elem = 0;
- unsigned long flags;
- u32 n = num, pass = 0;
-
- spin_lock_irqsave(&mvi->lock, flags);
- do {
- dev = t->dev;
- tei.port = &mvi->port[dev->port->id];
-
- if (!tei.port->port_attached) {
- if (sas_protocol_ata(t->task_proto)) {
- rc = SAS_PHY_DOWN;
- goto out_done;
- } else {
- struct task_status_struct *ts = &t->task_status;
- ts->resp = SAS_TASK_UNDELIVERED;
- ts->stat = SAS_PHY_DOWN;
- t->task_done(t);
- if (n > 1)
- t = list_entry(t->list.next,
- struct sas_task, list);
- continue;
- }
- }
-
- if (!sas_protocol_ata(t->task_proto)) {
- if (t->num_scatter) {
- n_elem = pci_map_sg(mvi->pdev, t->scatter,
- t->num_scatter,
- t->data_dir);
- if (!n_elem) {
- rc = -ENOMEM;
- goto err_out;
- }
- }
- } else {
- n_elem = t->num_scatter;
- }
-
- rc = mvs_tag_alloc(mvi, &tag);
- if (rc)
- goto err_out;
-
- slot = &mvi->slot_info[tag];
- t->lldd_task = NULL;
- slot->n_elem = n_elem;
- memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
- tei.task = t;
- tei.hdr = &mvi->slot[tag];
- tei.tag = tag;
- tei.n_elem = n_elem;
-
- switch (t->task_proto) {
- case SAS_PROTOCOL_SMP:
- rc = mvs_task_prep_smp(mvi, &tei);
- break;
- case SAS_PROTOCOL_SSP:
- rc = mvs_task_prep_ssp(mvi, &tei);
- break;
- case SAS_PROTOCOL_SATA:
- case SAS_PROTOCOL_STP:
- case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
- rc = mvs_task_prep_ata(mvi, &tei);
- break;
- default:
- dev_printk(KERN_ERR, &pdev->dev,
- "unknown sas_task proto: 0x%x\n",
- t->task_proto);
- rc = -EINVAL;
- break;
- }
-
- if (rc)
- goto err_out_tag;
-
- slot->task = t;
- slot->port = tei.port;
- t->lldd_task = (void *) slot;
- list_add_tail(&slot->list, &slot->port->list);
- /* TODO: select normal or high priority */
-
- spin_lock(&t->task_state_lock);
- t->task_state_flags |= SAS_TASK_AT_INITIATOR;
- spin_unlock(&t->task_state_lock);
-
- mvs_hba_memory_dump(mvi, tag, t->task_proto);
-
- ++pass;
- mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
- if (n > 1)
- t = list_entry(t->list.next, struct sas_task, list);
- } while (--n);
-
- rc = 0;
- goto out_done;
-
-err_out_tag:
- mvs_tag_free(mvi, tag);
-err_out:
- dev_printk(KERN_ERR, &pdev->dev, "mvsas exec failed[%d]!\n", rc);
- if (!sas_protocol_ata(t->task_proto))
- if (n_elem)
- pci_unmap_sg(mvi->pdev, t->scatter, n_elem,
- t->data_dir);
-out_done:
- if (pass)
- mw32(TX_PROD_IDX, (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1));
- spin_unlock_irqrestore(&mvi->lock, flags);
- return rc;
-}
-
-static int mvs_task_abort(struct sas_task *task)
-{
- int rc;
- unsigned long flags;
- struct mvs_info *mvi = task->dev->port->ha->lldd_ha;
- struct pci_dev *pdev = mvi->pdev;
- int tag;
-
- spin_lock_irqsave(&task->task_state_lock, flags);
- if (task->task_state_flags & SAS_TASK_STATE_DONE) {
- rc = TMF_RESP_FUNC_COMPLETE;
- spin_unlock_irqrestore(&task->task_state_lock, flags);
- goto out_done;
- }
- spin_unlock_irqrestore(&task->task_state_lock, flags);
-
- switch (task->task_proto) {
- case SAS_PROTOCOL_SMP:
- dev_printk(KERN_DEBUG, &pdev->dev, "SMP Abort! \n");
- break;
- case SAS_PROTOCOL_SSP:
- dev_printk(KERN_DEBUG, &pdev->dev, "SSP Abort! \n");
- break;
- case SAS_PROTOCOL_SATA:
- case SAS_PROTOCOL_STP:
- case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:{
- dev_printk(KERN_DEBUG, &pdev->dev, "STP Abort! \n");
-#if _MV_DUMP
- dev_printk(KERN_DEBUG, &pdev->dev, "Dump D2H FIS: \n");
- mvs_hexdump(sizeof(struct host_to_dev_fis),
- (void *)&task->ata_task.fis, 0);
- dev_printk(KERN_DEBUG, &pdev->dev, "Dump ATAPI Cmd : \n");
- mvs_hexdump(16, task->ata_task.atapi_packet, 0);
-#endif
- spin_lock_irqsave(&task->task_state_lock, flags);
- if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) {
- /* TODO */
- ;
- }
- spin_unlock_irqrestore(&task->task_state_lock, flags);
- break;
- }
- default:
- break;
- }
-
- if (mvs_find_tag(mvi, task, &tag)) {
- spin_lock_irqsave(&mvi->lock, flags);
- mvs_slot_task_free(mvi, task, &mvi->slot_info[tag], tag);
- spin_unlock_irqrestore(&mvi->lock, flags);
- }
- if (!mvs_task_exec(task, 1, GFP_ATOMIC))
- rc = TMF_RESP_FUNC_COMPLETE;
- else
- rc = TMF_RESP_FUNC_FAILED;
-out_done:
- return rc;
-}
-
-static void mvs_free(struct mvs_info *mvi)
-{
- int i;
-
- if (!mvi)
- return;
-
- for (i = 0; i < MVS_SLOTS; i++) {
- struct mvs_slot_info *slot = &mvi->slot_info[i];
-
- if (slot->buf)
- dma_free_coherent(&mvi->pdev->dev, MVS_SLOT_BUF_SZ,
- slot->buf, slot->buf_dma);
- }
-
- if (mvi->tx)
- dma_free_coherent(&mvi->pdev->dev,
- sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
- mvi->tx, mvi->tx_dma);
- if (mvi->rx_fis)
- dma_free_coherent(&mvi->pdev->dev, MVS_RX_FISL_SZ,
- mvi->rx_fis, mvi->rx_fis_dma);
- if (mvi->rx)
- dma_free_coherent(&mvi->pdev->dev,
- sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
- mvi->rx, mvi->rx_dma);
- if (mvi->slot)
- dma_free_coherent(&mvi->pdev->dev,
- sizeof(*mvi->slot) * MVS_SLOTS,
- mvi->slot, mvi->slot_dma);
-#ifdef MVS_ENABLE_PERI
- if (mvi->peri_regs)
- iounmap(mvi->peri_regs);
-#endif
- if (mvi->regs)
- iounmap(mvi->regs);
- if (mvi->shost)
- scsi_host_put(mvi->shost);
- kfree(mvi->sas.sas_port);
- kfree(mvi->sas.sas_phy);
- kfree(mvi);
-}
-
-/* FIXME: locking? */
-static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
- void *funcdata)
-{
- struct mvs_info *mvi = sas_phy->ha->lldd_ha;
- int rc = 0, phy_id = sas_phy->id;
- u32 tmp;
-
- tmp = mvs_read_phy_ctl(mvi, phy_id);
-
- switch (func) {
- case PHY_FUNC_SET_LINK_RATE:{
- struct sas_phy_linkrates *rates = funcdata;
- u32 lrmin = 0, lrmax = 0;
-
- lrmin = (rates->minimum_linkrate << 8);
- lrmax = (rates->maximum_linkrate << 12);
-
- if (lrmin) {
- tmp &= ~(0xf << 8);
- tmp |= lrmin;
- }
- if (lrmax) {
- tmp &= ~(0xf << 12);
- tmp |= lrmax;
- }
- mvs_write_phy_ctl(mvi, phy_id, tmp);
- break;
- }
-
- case PHY_FUNC_HARD_RESET:
- if (tmp & PHY_RST_HARD)
- break;
- mvs_write_phy_ctl(mvi, phy_id, tmp | PHY_RST_HARD);
- break;
-
- case PHY_FUNC_LINK_RESET:
- mvs_write_phy_ctl(mvi, phy_id, tmp | PHY_RST);
- break;
-
- case PHY_FUNC_DISABLE:
- case PHY_FUNC_RELEASE_SPINUP_HOLD:
- default:
- rc = -EOPNOTSUPP;
- }
-
- return rc;
-}
-
-static void __devinit mvs_phy_init(struct mvs_info *mvi, int phy_id)
-{
- struct mvs_phy *phy = &mvi->phy[phy_id];
- struct asd_sas_phy *sas_phy = &phy->sas_phy;
-
- sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0;
- sas_phy->class = SAS;
- sas_phy->iproto = SAS_PROTOCOL_ALL;
- sas_phy->tproto = 0;
- sas_phy->type = PHY_TYPE_PHYSICAL;
- sas_phy->role = PHY_ROLE_INITIATOR;
- sas_phy->oob_mode = OOB_NOT_CONNECTED;
- sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN;
-
- sas_phy->id = phy_id;
- sas_phy->sas_addr = &mvi->sas_addr[0];
- sas_phy->frame_rcvd = &phy->frame_rcvd[0];
- sas_phy->ha = &mvi->sas;
- sas_phy->lldd_phy = phy;
-}
-
-static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
- const struct pci_device_id *ent)
-{
- struct mvs_info *mvi;
- unsigned long res_start, res_len, res_flag;
- struct asd_sas_phy **arr_phy;
- struct asd_sas_port **arr_port;
- const struct mvs_chip_info *chip = &mvs_chips[ent->driver_data];
- int i;
-
- /*
- * alloc and init our per-HBA mvs_info struct
- */
-
- mvi = kzalloc(sizeof(*mvi), GFP_KERNEL);
- if (!mvi)
- return NULL;
-
- spin_lock_init(&mvi->lock);
-#ifdef MVS_USE_TASKLET
- tasklet_init(&mvi->tasklet, mvs_tasklet, (unsigned long)mvi);
-#endif
- mvi->pdev = pdev;
- mvi->chip = chip;
-
- if (pdev->device == 0x6440 && pdev->revision == 0)
- mvi->flags |= MVF_PHY_PWR_FIX;
-
- /*
- * alloc and init SCSI, SAS glue
- */
-
- mvi->shost = scsi_host_alloc(&mvs_sht, sizeof(void *));
- if (!mvi->shost)
- goto err_out;
-
- arr_phy = kcalloc(MVS_MAX_PHYS, sizeof(void *), GFP_KERNEL);
- arr_port = kcalloc(MVS_MAX_PHYS, sizeof(void *), GFP_KERNEL);
- if (!arr_phy || !arr_port)
- goto err_out;
-
- for (i = 0; i < MVS_MAX_PHYS; i++) {
- mvs_phy_init(mvi, i);
- arr_phy[i] = &mvi->phy[i].sas_phy;
- arr_port[i] = &mvi->port[i].sas_port;
- mvi->port[i].taskfileset = MVS_ID_NOT_MAPPED;
- mvi->port[i].wide_port_phymap = 0;
- mvi->port[i].port_attached = 0;
- INIT_LIST_HEAD(&mvi->port[i].list);
- }
-
- SHOST_TO_SAS_HA(mvi->shost) = &mvi->sas;
- mvi->shost->transportt = mvs_stt;
- mvi->shost->max_id = 21;
- mvi->shost->max_lun = ~0;
- mvi->shost->max_channel = 0;
- mvi->shost->max_cmd_len = 16;
-
- mvi->sas.sas_ha_name = DRV_NAME;
- mvi->sas.dev = &pdev->dev;
- mvi->sas.lldd_module = THIS_MODULE;
- mvi->sas.sas_addr = &mvi->sas_addr[0];
- mvi->sas.sas_phy = arr_phy;
- mvi->sas.sas_port = arr_port;
- mvi->sas.num_phys = chip->n_phy;
- mvi->sas.lldd_max_execute_num = 1;
- mvi->sas.lldd_queue_size = MVS_QUEUE_SIZE;
- mvi->shost->can_queue = MVS_CAN_QUEUE;
- mvi->shost->cmd_per_lun = MVS_SLOTS / mvi->sas.num_phys;
- mvi->sas.lldd_ha = mvi;
- mvi->sas.core.shost = mvi->shost;
-
- mvs_tag_init(mvi);
-
- /*
- * ioremap main and peripheral registers
- */
-
-#ifdef MVS_ENABLE_PERI
- res_start = pci_resource_start(pdev, 2);
- res_len = pci_resource_len(pdev, 2);
- if (!res_start || !res_len)
- goto err_out;
-
- mvi->peri_regs = ioremap_nocache(res_start, res_len);
- if (!mvi->peri_regs)
- goto err_out;
-#endif
-
- res_start = pci_resource_start(pdev, 4);
- res_len = pci_resource_len(pdev, 4);
- if (!res_start || !res_len)
- goto err_out;
-
- res_flag = pci_resource_flags(pdev, 4);
- if (res_flag & IORESOURCE_CACHEABLE)
- mvi->regs = ioremap(res_start, res_len);
- else
- mvi->regs = ioremap_nocache(res_start, res_len);
-
- if (!mvi->regs)
- goto err_out;
-
- /*
- * alloc and init our DMA areas
- */
-
- mvi->tx = dma_alloc_coherent(&pdev->dev,
- sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
- &mvi->tx_dma, GFP_KERNEL);
- if (!mvi->tx)
- goto err_out;
- memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ);
-
- mvi->rx_fis = dma_alloc_coherent(&pdev->dev, MVS_RX_FISL_SZ,
- &mvi->rx_fis_dma, GFP_KERNEL);
- if (!mvi->rx_fis)
- goto err_out;
- memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
-
- mvi->rx = dma_alloc_coherent(&pdev->dev,
- sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
- &mvi->rx_dma, GFP_KERNEL);
- if (!mvi->rx)
- goto err_out;
- memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
-
- mvi->rx[0] = cpu_to_le32(0xfff);
- mvi->rx_cons = 0xfff;
-
- mvi->slot = dma_alloc_coherent(&pdev->dev,
- sizeof(*mvi->slot) * MVS_SLOTS,
- &mvi->slot_dma, GFP_KERNEL);
- if (!mvi->slot)
- goto err_out;
- memset(mvi->slot, 0, sizeof(*mvi->slot) * MVS_SLOTS);
-
- for (i = 0; i < MVS_SLOTS; i++) {
- struct mvs_slot_info *slot = &mvi->slot_info[i];
-
- slot->buf = dma_alloc_coherent(&pdev->dev, MVS_SLOT_BUF_SZ,
- &slot->buf_dma, GFP_KERNEL);
- if (!slot->buf)
- goto err_out;
- memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
- }
-
- /* finally, read NVRAM to get our SAS address */
- if (mvs_nvram_read(mvi, NVR_SAS_ADDR, &mvi->sas_addr, 8))
- goto err_out;
- return mvi;
-
-err_out:
- mvs_free(mvi);
- return NULL;
-}
-
-static u32 mvs_cr32(void __iomem *regs, u32 addr)
-{
- mw32(CMD_ADDR, addr);
- return mr32(CMD_DATA);
-}
-
-static void mvs_cw32(void __iomem *regs, u32 addr, u32 val)
-{
- mw32(CMD_ADDR, addr);
- mw32(CMD_DATA, val);
-}
-
-static u32 mvs_read_phy_ctl(struct mvs_info *mvi, u32 port)
-{
- void __iomem *regs = mvi->regs;
- return (port < 4)?mr32(P0_SER_CTLSTAT + port * 4):
- mr32(P4_SER_CTLSTAT + (port - 4) * 4);
-}
-
-static void mvs_write_phy_ctl(struct mvs_info *mvi, u32 port, u32 val)
-{
- void __iomem *regs = mvi->regs;
- if (port < 4)
- mw32(P0_SER_CTLSTAT + port * 4, val);
- else
- mw32(P4_SER_CTLSTAT + (port - 4) * 4, val);
-}
-
-static u32 mvs_read_port(struct mvs_info *mvi, u32 off, u32 off2, u32 port)
-{
- void __iomem *regs = mvi->regs + off;
- void __iomem *regs2 = mvi->regs + off2;
- return (port < 4)?readl(regs + port * 8):
- readl(regs2 + (port - 4) * 8);
-}
-
-static void mvs_write_port(struct mvs_info *mvi, u32 off, u32 off2,
- u32 port, u32 val)
-{
- void __iomem *regs = mvi->regs + off;
- void __iomem *regs2 = mvi->regs + off2;
- if (port < 4)
- writel(val, regs + port * 8);
- else
- writel(val, regs2 + (port - 4) * 8);
-}
-
-static u32 mvs_read_port_cfg_data(struct mvs_info *mvi, u32 port)
-{
- return mvs_read_port(mvi, MVS_P0_CFG_DATA, MVS_P4_CFG_DATA, port);
-}
-
-static void mvs_write_port_cfg_data(struct mvs_info *mvi, u32 port, u32 val)
-{
- mvs_write_port(mvi, MVS_P0_CFG_DATA, MVS_P4_CFG_DATA, port, val);
-}
-
-static void mvs_write_port_cfg_addr(struct mvs_info *mvi, u32 port, u32 addr)
-{
- mvs_write_port(mvi, MVS_P0_CFG_ADDR, MVS_P4_CFG_ADDR, port, addr);
-}
-
-static u32 mvs_read_port_vsr_data(struct mvs_info *mvi, u32 port)
-{
- return mvs_read_port(mvi, MVS_P0_VSR_DATA, MVS_P4_VSR_DATA, port);
-}
-
-static void mvs_write_port_vsr_data(struct mvs_info *mvi, u32 port, u32 val)
-{
- mvs_write_port(mvi, MVS_P0_VSR_DATA, MVS_P4_VSR_DATA, port, val);
-}
-
-static void mvs_write_port_vsr_addr(struct mvs_info *mvi, u32 port, u32 addr)
-{
- mvs_write_port(mvi, MVS_P0_VSR_ADDR, MVS_P4_VSR_ADDR, port, addr);
-}
-
-static u32 mvs_read_port_irq_stat(struct mvs_info *mvi, u32 port)
-{
- return mvs_read_port(mvi, MVS_P0_INT_STAT, MVS_P4_INT_STAT, port);
-}
-
-static void mvs_write_port_irq_stat(struct mvs_info *mvi, u32 port, u32 val)
-{
- mvs_write_port(mvi, MVS_P0_INT_STAT, MVS_P4_INT_STAT, port, val);
-}
-
-static u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port)
-{
- return mvs_read_port(mvi, MVS_P0_INT_MASK, MVS_P4_INT_MASK, port);
-}
-
-static void mvs_write_port_irq_mask(struct mvs_info *mvi, u32 port, u32 val)
-{
- mvs_write_port(mvi, MVS_P0_INT_MASK, MVS_P4_INT_MASK, port, val);
-}
-
-static void __devinit mvs_phy_hacks(struct mvs_info *mvi)
-{
- void __iomem *regs = mvi->regs;
- u32 tmp;
-
- /* workaround for SATA R-ERR, to ignore phy glitch */
- tmp = mvs_cr32(regs, CMD_PHY_TIMER);
- tmp &= ~(1 << 9);
- tmp |= (1 << 10);
- mvs_cw32(regs, CMD_PHY_TIMER, tmp);
-
- /* enable retry 127 times */
- mvs_cw32(regs, CMD_SAS_CTL1, 0x7f7f);
-
- /* extend open frame timeout to max */
- tmp = mvs_cr32(regs, CMD_SAS_CTL0);
- tmp &= ~0xffff;
- tmp |= 0x3fff;
- mvs_cw32(regs, CMD_SAS_CTL0, tmp);
-
- /* workaround for WDTIMEOUT , set to 550 ms */
- mvs_cw32(regs, CMD_WD_TIMER, 0x86470);
-
- /* not to halt for different port op during wideport link change */
- mvs_cw32(regs, CMD_APP_ERR_CONFIG, 0xffefbf7d);
-
- /* workaround for Seagate disk not-found OOB sequence, recv
- * COMINIT before sending out COMWAKE */
- tmp = mvs_cr32(regs, CMD_PHY_MODE_21);
- tmp &= 0x0000ffff;
- tmp |= 0x00fa0000;
- mvs_cw32(regs, CMD_PHY_MODE_21, tmp);
-
- tmp = mvs_cr32(regs, CMD_PHY_TIMER);
- tmp &= 0x1fffffff;
- tmp |= (2U << 29); /* 8 ms retry */
- mvs_cw32(regs, CMD_PHY_TIMER, tmp);
-
- /* TEST - for phy decoding error, adjust voltage levels */
- mw32(P0_VSR_ADDR + 0, 0x8);
- mw32(P0_VSR_DATA + 0, 0x2F0);
-
- mw32(P0_VSR_ADDR + 8, 0x8);
- mw32(P0_VSR_DATA + 8, 0x2F0);
-
- mw32(P0_VSR_ADDR + 16, 0x8);
- mw32(P0_VSR_DATA + 16, 0x2F0);
-
- mw32(P0_VSR_ADDR + 24, 0x8);
- mw32(P0_VSR_DATA + 24, 0x2F0);
-
-}
-
-static void mvs_enable_xmt(struct mvs_info *mvi, int PhyId)
-{
- void __iomem *regs = mvi->regs;
- u32 tmp;
-
- tmp = mr32(PCS);
- if (mvi->chip->n_phy <= 4)
- tmp |= 1 << (PhyId + PCS_EN_PORT_XMT_SHIFT);
- else
- tmp |= 1 << (PhyId + PCS_EN_PORT_XMT_SHIFT2);
- mw32(PCS, tmp);
-}
-
-static void mvs_detect_porttype(struct mvs_info *mvi, int i)
-{
- void __iomem *regs = mvi->regs;
- u32 reg;
- struct mvs_phy *phy = &mvi->phy[i];
-
- /* TODO check & save device type */
- reg = mr32(GBL_PORT_TYPE);
-
- if (reg & MODE_SAS_SATA & (1 << i))
- phy->phy_type |= PORT_TYPE_SAS;
- else
- phy->phy_type |= PORT_TYPE_SATA;
-}
-
-static void *mvs_get_d2h_reg(struct mvs_info *mvi, int i, void *buf)
-{
- u32 *s = (u32 *) buf;
-
- if (!s)
- return NULL;
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG3);
- s[3] = mvs_read_port_cfg_data(mvi, i);
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG2);
- s[2] = mvs_read_port_cfg_data(mvi, i);
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG1);
- s[1] = mvs_read_port_cfg_data(mvi, i);
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG0);
- s[0] = mvs_read_port_cfg_data(mvi, i);
-
- return (void *)s;
-}
-
-static u32 mvs_is_sig_fis_received(u32 irq_status)
-{
- return irq_status & PHYEV_SIG_FIS;
-}
-
-static void mvs_update_wideport(struct mvs_info *mvi, int i)
-{
- struct mvs_phy *phy = &mvi->phy[i];
- struct mvs_port *port = phy->port;
- int j, no;
-
- for_each_phy(port->wide_port_phymap, no, j, mvi->chip->n_phy)
- if (no & 1) {
- mvs_write_port_cfg_addr(mvi, no, PHYR_WIDE_PORT);
- mvs_write_port_cfg_data(mvi, no,
- port->wide_port_phymap);
- } else {
- mvs_write_port_cfg_addr(mvi, no, PHYR_WIDE_PORT);
- mvs_write_port_cfg_data(mvi, no, 0);
- }
-}
-
-static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i)
-{
- u32 tmp;
- struct mvs_phy *phy = &mvi->phy[i];
- struct mvs_port *port = phy->port;;
-
- tmp = mvs_read_phy_ctl(mvi, i);
-
- if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) {
- if (!port)
- phy->phy_attached = 1;
- return tmp;
- }
-
- if (port) {
- if (phy->phy_type & PORT_TYPE_SAS) {
- port->wide_port_phymap &= ~(1U << i);
- if (!port->wide_port_phymap)
- port->port_attached = 0;
- mvs_update_wideport(mvi, i);
- } else if (phy->phy_type & PORT_TYPE_SATA)
- port->port_attached = 0;
- mvs_free_reg_set(mvi, phy->port);
- phy->port = NULL;
- phy->phy_attached = 0;
- phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA);
- }
- return 0;
-}
-
-static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
- int get_st)
-{
- struct mvs_phy *phy = &mvi->phy[i];
- struct pci_dev *pdev = mvi->pdev;
- u32 tmp;
- u64 tmp64;
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY);
- phy->dev_info = mvs_read_port_cfg_data(mvi, i);
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_HI);
- phy->dev_sas_addr = (u64) mvs_read_port_cfg_data(mvi, i) << 32;
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_LO);
- phy->dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
-
- if (get_st) {
- phy->irq_status = mvs_read_port_irq_stat(mvi, i);
- phy->phy_status = mvs_is_phy_ready(mvi, i);
- }
-
- if (phy->phy_status) {
- u32 phy_st;
- struct asd_sas_phy *sas_phy = mvi->sas.sas_phy[i];
-
- mvs_write_port_cfg_addr(mvi, i, PHYR_PHY_STAT);
- phy_st = mvs_read_port_cfg_data(mvi, i);
-
- sas_phy->linkrate =
- (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
- PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET;
- phy->minimum_linkrate =
- (phy->phy_status &
- PHY_MIN_SPP_PHYS_LINK_RATE_MASK) >> 8;
- phy->maximum_linkrate =
- (phy->phy_status &
- PHY_MAX_SPP_PHYS_LINK_RATE_MASK) >> 12;
-
- if (phy->phy_type & PORT_TYPE_SAS) {
- /* Updated attached_sas_addr */
- mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI);
- phy->att_dev_sas_addr =
- (u64) mvs_read_port_cfg_data(mvi, i) << 32;
- mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO);
- phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
- mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO);
- phy->att_dev_info = mvs_read_port_cfg_data(mvi, i);
- phy->identify.device_type =
- phy->att_dev_info & PORT_DEV_TYPE_MASK;
-
- if (phy->identify.device_type == SAS_END_DEV)
- phy->identify.target_port_protocols =
- SAS_PROTOCOL_SSP;
- else if (phy->identify.device_type != NO_DEVICE)
- phy->identify.target_port_protocols =
- SAS_PROTOCOL_SMP;
- if (phy_st & PHY_OOB_DTCTD)
- sas_phy->oob_mode = SAS_OOB_MODE;
- phy->frame_rcvd_size =
- sizeof(struct sas_identify_frame);
- } else if (phy->phy_type & PORT_TYPE_SATA) {
- phy->identify.target_port_protocols = SAS_PROTOCOL_STP;
- if (mvs_is_sig_fis_received(phy->irq_status)) {
- phy->att_dev_sas_addr = i; /* temp */
- if (phy_st & PHY_OOB_DTCTD)
- sas_phy->oob_mode = SATA_OOB_MODE;
- phy->frame_rcvd_size =
- sizeof(struct dev_to_host_fis);
- mvs_get_d2h_reg(mvi, i,
- (void *)sas_phy->frame_rcvd);
- } else {
- dev_printk(KERN_DEBUG, &pdev->dev,
- "No sig fis\n");
- phy->phy_type &= ~(PORT_TYPE_SATA);
- goto out_done;
- }
- }
- tmp64 = cpu_to_be64(phy->att_dev_sas_addr);
- memcpy(sas_phy->attached_sas_addr, &tmp64, SAS_ADDR_SIZE);
-
- dev_printk(KERN_DEBUG, &pdev->dev,
- "phy[%d] Get Attached Address 0x%llX ,"
- " SAS Address 0x%llX\n",
- i,
- (unsigned long long)phy->att_dev_sas_addr,
- (unsigned long long)phy->dev_sas_addr);
- dev_printk(KERN_DEBUG, &pdev->dev,
- "Rate = %x , type = %d\n",
- sas_phy->linkrate, phy->phy_type);
-
- /* workaround for HW phy decoding error on 1.5g disk drive */
- mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6);
- tmp = mvs_read_port_vsr_data(mvi, i);
- if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
- PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) ==
- SAS_LINK_RATE_1_5_GBPS)
- tmp &= ~PHY_MODE6_LATECLK;
- else
- tmp |= PHY_MODE6_LATECLK;
- mvs_write_port_vsr_data(mvi, i, tmp);
-
- }
-out_done:
- if (get_st)
- mvs_write_port_irq_stat(mvi, i, phy->irq_status);
-}
-
-static void mvs_port_formed(struct asd_sas_phy *sas_phy)
-{
- struct sas_ha_struct *sas_ha = sas_phy->ha;
- struct mvs_info *mvi = sas_ha->lldd_ha;
- struct asd_sas_port *sas_port = sas_phy->port;
- struct mvs_phy *phy = sas_phy->lldd_phy;
- struct mvs_port *port = &mvi->port[sas_port->id];
- unsigned long flags;
-
- spin_lock_irqsave(&mvi->lock, flags);
- port->port_attached = 1;
- phy->port = port;
- port->taskfileset = MVS_ID_NOT_MAPPED;
- if (phy->phy_type & PORT_TYPE_SAS) {
- port->wide_port_phymap = sas_port->phy_mask;
- mvs_update_wideport(mvi, sas_phy->id);
- }
- spin_unlock_irqrestore(&mvi->lock, flags);
-}
-
-static int mvs_I_T_nexus_reset(struct domain_device *dev)
-{
- return TMF_RESP_FUNC_FAILED;
-}
-
-static int __devinit mvs_hw_init(struct mvs_info *mvi)
-{
- void __iomem *regs = mvi->regs;
- int i;
- u32 tmp, cctl;
-
- /* make sure interrupts are masked immediately (paranoia) */
- mw32(GBL_CTL, 0);
- tmp = mr32(GBL_CTL);
-
- /* Reset Controller */
- if (!(tmp & HBA_RST)) {
- if (mvi->flags & MVF_PHY_PWR_FIX) {
- pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &tmp);
- tmp &= ~PCTL_PWR_ON;
- tmp |= PCTL_OFF;
- pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp);
-
- pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &tmp);
- tmp &= ~PCTL_PWR_ON;
- tmp |= PCTL_OFF;
- pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp);
- }
-
- /* global reset, incl. COMRESET/H_RESET_N (self-clearing) */
- mw32_f(GBL_CTL, HBA_RST);
- }
-
- /* wait for reset to finish; timeout is just a guess */
- i = 1000;
- while (i-- > 0) {
- msleep(10);
-
- if (!(mr32(GBL_CTL) & HBA_RST))
- break;
- }
- if (mr32(GBL_CTL) & HBA_RST) {
- dev_printk(KERN_ERR, &mvi->pdev->dev, "HBA reset failed\n");
- return -EBUSY;
- }
-
- /* Init Chip */
- /* make sure RST is set; HBA_RST /should/ have done that for us */
- cctl = mr32(CTL);
- if (cctl & CCTL_RST)
- cctl &= ~CCTL_RST;
- else
- mw32_f(CTL, cctl | CCTL_RST);
-
- /* write to device control _AND_ device status register? - A.C. */
- pci_read_config_dword(mvi->pdev, PCR_DEV_CTRL, &tmp);
- tmp &= ~PRD_REQ_MASK;
- tmp |= PRD_REQ_SIZE;
- pci_write_config_dword(mvi->pdev, PCR_DEV_CTRL, tmp);
-
- pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &tmp);
- tmp |= PCTL_PWR_ON;
- tmp &= ~PCTL_OFF;
- pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp);
-
- pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &tmp);
- tmp |= PCTL_PWR_ON;
- tmp &= ~PCTL_OFF;
- pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp);
-
- mw32_f(CTL, cctl);
-
- /* reset control */
- mw32(PCS, 0); /*MVS_PCS */
-
- mvs_phy_hacks(mvi);
-
- mw32(CMD_LIST_LO, mvi->slot_dma);
- mw32(CMD_LIST_HI, (mvi->slot_dma >> 16) >> 16);
-
- mw32(RX_FIS_LO, mvi->rx_fis_dma);
- mw32(RX_FIS_HI, (mvi->rx_fis_dma >> 16) >> 16);
-
- mw32(TX_CFG, MVS_CHIP_SLOT_SZ);
- mw32(TX_LO, mvi->tx_dma);
- mw32(TX_HI, (mvi->tx_dma >> 16) >> 16);
-
- mw32(RX_CFG, MVS_RX_RING_SZ);
- mw32(RX_LO, mvi->rx_dma);
- mw32(RX_HI, (mvi->rx_dma >> 16) >> 16);
-
- /* enable auto port detection */
- mw32(GBL_PORT_TYPE, MODE_AUTO_DET_EN);
- msleep(1100);
- /* init and reset phys */
- for (i = 0; i < mvi->chip->n_phy; i++) {
- u32 lo = be32_to_cpu(*(u32 *)&mvi->sas_addr[4]);
- u32 hi = be32_to_cpu(*(u32 *)&mvi->sas_addr[0]);
-
- mvs_detect_porttype(mvi, i);
-
- /* set phy local SAS address */
- mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_LO);
- mvs_write_port_cfg_data(mvi, i, lo);
- mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_HI);
- mvs_write_port_cfg_data(mvi, i, hi);
-
- /* reset phy */
- tmp = mvs_read_phy_ctl(mvi, i);
- tmp |= PHY_RST;
- mvs_write_phy_ctl(mvi, i, tmp);
- }
-
- msleep(100);
-
- for (i = 0; i < mvi->chip->n_phy; i++) {
- /* clear phy int status */
- tmp = mvs_read_port_irq_stat(mvi, i);
- tmp &= ~PHYEV_SIG_FIS;
- mvs_write_port_irq_stat(mvi, i, tmp);
-
- /* set phy int mask */
- tmp = PHYEV_RDY_CH | PHYEV_BROAD_CH | PHYEV_UNASSOC_FIS |
- PHYEV_ID_DONE | PHYEV_DEC_ERR;
- mvs_write_port_irq_mask(mvi, i, tmp);
-
- msleep(100);
- mvs_update_phyinfo(mvi, i, 1);
- mvs_enable_xmt(mvi, i);
- }
-
- /* FIXME: update wide port bitmaps */
-
- /* little endian for open address and command table, etc. */
- /* A.C.
- * it seems that ( from the spec ) turning on big-endian won't
- * do us any good on big-endian machines, need further confirmation
- */
- cctl = mr32(CTL);
- cctl |= CCTL_ENDIAN_CMD;
- cctl |= CCTL_ENDIAN_DATA;
- cctl &= ~CCTL_ENDIAN_OPEN;
- cctl |= CCTL_ENDIAN_RSP;
- mw32_f(CTL, cctl);
-
- /* reset CMD queue */
- tmp = mr32(PCS);
- tmp |= PCS_CMD_RST;
- mw32(PCS, tmp);
- /* interrupt coalescing may cause missing HW interrput in some case,
- * and the max count is 0x1ff, while our max slot is 0x200,
- * it will make count 0.
- */
- tmp = 0;
- mw32(INT_COAL, tmp);
-
- tmp = 0x100;
- mw32(INT_COAL_TMOUT, tmp);
-
- /* ladies and gentlemen, start your engines */
- mw32(TX_CFG, 0);
- mw32(TX_CFG, MVS_CHIP_SLOT_SZ | TX_EN);
- mw32(RX_CFG, MVS_RX_RING_SZ | RX_EN);
- /* enable CMD/CMPL_Q/RESP mode */
- mw32(PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN | PCS_CMD_EN);
-
- /* enable completion queue interrupt */
- tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM | CINT_SRS);
- mw32(INT_MASK, tmp);
-
- /* Enable SRS interrupt */
- mw32(INT_MASK_SRS, 0xFF);
- return 0;
-}
-
-static void __devinit mvs_print_info(struct mvs_info *mvi)
-{
- struct pci_dev *pdev = mvi->pdev;
- static int printed_version;
-
- if (!printed_version++)
- dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
-
- dev_printk(KERN_INFO, &pdev->dev, "%u phys, addr %llx\n",
- mvi->chip->n_phy, SAS_ADDR(mvi->sas_addr));
-}
-
-static int __devinit mvs_pci_init(struct pci_dev *pdev,
- const struct pci_device_id *ent)
-{
- int rc;
- struct mvs_info *mvi;
- irq_handler_t irq_handler = mvs_interrupt;
-
- rc = pci_enable_device(pdev);
- if (rc)
- return rc;
-
- pci_set_master(pdev);
-
- rc = pci_request_regions(pdev, DRV_NAME);
- if (rc)
- goto err_out_disable;
-
- rc = pci_go_64(pdev);
- if (rc)
- goto err_out_regions;
-
- mvi = mvs_alloc(pdev, ent);
- if (!mvi) {
- rc = -ENOMEM;
- goto err_out_regions;
- }
-
- rc = mvs_hw_init(mvi);
- if (rc)
- goto err_out_mvi;
-
-#ifndef MVS_DISABLE_MSI
- if (!pci_enable_msi(pdev)) {
- u32 tmp;
- void __iomem *regs = mvi->regs;
- mvi->flags |= MVF_MSI;
- irq_handler = mvs_msi_interrupt;
- tmp = mr32(PCS);
- mw32(PCS, tmp | PCS_SELF_CLEAR);
- }
-#endif
-
- rc = request_irq(pdev->irq, irq_handler, IRQF_SHARED, DRV_NAME, mvi);
- if (rc)
- goto err_out_msi;
-
- rc = scsi_add_host(mvi->shost, &pdev->dev);
- if (rc)
- goto err_out_irq;
-
- rc = sas_register_ha(&mvi->sas);
- if (rc)
- goto err_out_shost;
-
- pci_set_drvdata(pdev, mvi);
-
- mvs_print_info(mvi);
-
- mvs_hba_interrupt_enable(mvi);
-
- scsi_scan_host(mvi->shost);
-
- return 0;
-
-err_out_shost:
- scsi_remove_host(mvi->shost);
-err_out_irq:
- free_irq(pdev->irq, mvi);
-err_out_msi:
- if (mvi->flags |= MVF_MSI)
- pci_disable_msi(pdev);
-err_out_mvi:
- mvs_free(mvi);
-err_out_regions:
- pci_release_regions(pdev);
-err_out_disable:
- pci_disable_device(pdev);
- return rc;
-}
-
-static void __devexit mvs_pci_remove(struct pci_dev *pdev)
-{
- struct mvs_info *mvi = pci_get_drvdata(pdev);
-
- pci_set_drvdata(pdev, NULL);
-
- if (mvi) {
- sas_unregister_ha(&mvi->sas);
- mvs_hba_interrupt_disable(mvi);
- sas_remove_host(mvi->shost);
- scsi_remove_host(mvi->shost);
-
- free_irq(pdev->irq, mvi);
- if (mvi->flags & MVF_MSI)
- pci_disable_msi(pdev);
- mvs_free(mvi);
- pci_release_regions(pdev);
- }
- pci_disable_device(pdev);
-}
-
-static struct sas_domain_function_template mvs_transport_ops = {
- .lldd_execute_task = mvs_task_exec,
- .lldd_control_phy = mvs_phy_control,
- .lldd_abort_task = mvs_task_abort,
- .lldd_port_formed = mvs_port_formed,
- .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset,
-};
-
-static struct pci_device_id __devinitdata mvs_pci_table[] = {
- { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 },
- { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 },
- {
- .vendor = PCI_VENDOR_ID_MARVELL,
- .device = 0x6440,
- .subvendor = PCI_ANY_ID,
- .subdevice = 0x6480,
- .class = 0,
- .class_mask = 0,
- .driver_data = chip_6480,
- },
- { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 },
- { PCI_VDEVICE(MARVELL, 0x6480), chip_6480 },
-
- { } /* terminate list */
-};
-
-static struct pci_driver mvs_pci_driver = {
- .name = DRV_NAME,
- .id_table = mvs_pci_table,
- .probe = mvs_pci_init,
- .remove = __devexit_p(mvs_pci_remove),
-};
-
-static int __init mvs_init(void)
-{
- int rc;
-
- mvs_stt = sas_domain_attach_transport(&mvs_transport_ops);
- if (!mvs_stt)
- return -ENOMEM;
-
- rc = pci_register_driver(&mvs_pci_driver);
- if (rc)
- goto err_out;
-
- return 0;
-
-err_out:
- sas_release_transport(mvs_stt);
- return rc;
-}
-
-static void __exit mvs_exit(void)
-{
- pci_unregister_driver(&mvs_pci_driver);
- sas_release_transport(mvs_stt);
-}
-
-module_init(mvs_init);
-module_exit(mvs_exit);
-
-MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>");
-MODULE_DESCRIPTION("Marvell 88SE6440 SAS/SATA controller driver");
-MODULE_VERSION(DRV_VERSION);
-MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(pci, mvs_pci_table);
diff --git a/drivers/scsi/mvsas/Kconfig b/drivers/scsi/mvsas/Kconfig
new file mode 100644
index 000000000000..6de7af27e507
--- /dev/null
+++ b/drivers/scsi/mvsas/Kconfig
@@ -0,0 +1,42 @@
+#
+# Kernel configuration file for 88SE64XX/88SE94XX SAS/SATA driver.
+#
+# Copyright 2007 Red Hat, Inc.
+# Copyright 2008 Marvell. <kewei@marvell.com>
+#
+# This file is licensed under GPLv2.
+#
+# This file is part of the 88SE64XX/88SE94XX driver.
+#
+# The 88SE64XX/88SE94XX driver is free software; you can redistribute
+# it and/or modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2 of the
+# License.
+#
+# The 88SE64XX/88SE94XX driver is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with 88SE64XX/88SE94XX Driver; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+
+config SCSI_MVSAS
+ tristate "Marvell 88SE64XX/88SE94XX SAS/SATA support"
+ depends on PCI
+ select SCSI_SAS_LIBSAS
+ select FW_LOADER
+ help
+ This driver supports Marvell's SAS/SATA 3Gb/s PCI-E 88SE64XX and 6Gb/s
+ PCI-E 88SE94XX chip based host adapters.
+
+config SCSI_MVSAS_DEBUG
+ bool "Compile in debug mode"
+ default y
+ depends on SCSI_MVSAS
+ help
+ Compiles the 88SE64XX/88SE94XX driver in debug mode. In debug mode,
+ the driver prints some messages to the console.
diff --git a/drivers/scsi/mvsas/Makefile b/drivers/scsi/mvsas/Makefile
new file mode 100644
index 000000000000..52ac4264677d
--- /dev/null
+++ b/drivers/scsi/mvsas/Makefile
@@ -0,0 +1,32 @@
+#
+# Makefile for Marvell 88SE64xx/88SE84xx SAS/SATA driver.
+#
+# Copyright 2007 Red Hat, Inc.
+# Copyright 2008 Marvell. <kewei@marvell.com>
+#
+# This file is licensed under GPLv2.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+
+ifeq ($(CONFIG_SCSI_MVSAS_DEBUG),y)
+ EXTRA_CFLAGS += -DMV_DEBUG
+endif
+
+obj-$(CONFIG_SCSI_MVSAS) += mvsas.o
+mvsas-y += mv_init.o \
+ mv_sas.o \
+ mv_64xx.o \
+ mv_94xx.o
diff --git a/drivers/scsi/mvsas/mv_64xx.c b/drivers/scsi/mvsas/mv_64xx.c
new file mode 100644
index 000000000000..10a5077b6aed
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_64xx.c
@@ -0,0 +1,793 @@
+/*
+ * Marvell 88SE64xx hardware specific
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#include "mv_sas.h"
+#include "mv_64xx.h"
+#include "mv_chips.h"
+
+static void mvs_64xx_detect_porttype(struct mvs_info *mvi, int i)
+{
+ void __iomem *regs = mvi->regs;
+ u32 reg;
+ struct mvs_phy *phy = &mvi->phy[i];
+
+ /* TODO check & save device type */
+ reg = mr32(MVS_GBL_PORT_TYPE);
+ phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA);
+ if (reg & MODE_SAS_SATA & (1 << i))
+ phy->phy_type |= PORT_TYPE_SAS;
+ else
+ phy->phy_type |= PORT_TYPE_SATA;
+}
+
+static void __devinit mvs_64xx_enable_xmt(struct mvs_info *mvi, int phy_id)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+
+ tmp = mr32(MVS_PCS);
+ if (mvi->chip->n_phy <= 4)
+ tmp |= 1 << (phy_id + PCS_EN_PORT_XMT_SHIFT);
+ else
+ tmp |= 1 << (phy_id + PCS_EN_PORT_XMT_SHIFT2);
+ mw32(MVS_PCS, tmp);
+}
+
+static void __devinit mvs_64xx_phy_hacks(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+
+ mvs_phy_hacks(mvi);
+
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ /* TEST - for phy decoding error, adjust voltage levels */
+ mw32(MVS_P0_VSR_ADDR + 0, 0x8);
+ mw32(MVS_P0_VSR_DATA + 0, 0x2F0);
+
+ mw32(MVS_P0_VSR_ADDR + 8, 0x8);
+ mw32(MVS_P0_VSR_DATA + 8, 0x2F0);
+
+ mw32(MVS_P0_VSR_ADDR + 16, 0x8);
+ mw32(MVS_P0_VSR_DATA + 16, 0x2F0);
+
+ mw32(MVS_P0_VSR_ADDR + 24, 0x8);
+ mw32(MVS_P0_VSR_DATA + 24, 0x2F0);
+ } else {
+ int i;
+ /* disable auto port detection */
+ mw32(MVS_GBL_PORT_TYPE, 0);
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE7);
+ mvs_write_port_vsr_data(mvi, i, 0x90000000);
+ mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE9);
+ mvs_write_port_vsr_data(mvi, i, 0x50f2);
+ mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE11);
+ mvs_write_port_vsr_data(mvi, i, 0x0e);
+ }
+ }
+}
+
+static void mvs_64xx_stp_reset(struct mvs_info *mvi, u32 phy_id)
+{
+ void __iomem *regs = mvi->regs;
+ u32 reg, tmp;
+
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ if (phy_id < 4)
+ pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &reg);
+ else
+ pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &reg);
+
+ } else
+ reg = mr32(MVS_PHY_CTL);
+
+ tmp = reg;
+ if (phy_id < 4)
+ tmp |= (1U << phy_id) << PCTL_LINK_OFFS;
+ else
+ tmp |= (1U << (phy_id - 4)) << PCTL_LINK_OFFS;
+
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ if (phy_id < 4) {
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp);
+ mdelay(10);
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, reg);
+ } else {
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp);
+ mdelay(10);
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, reg);
+ }
+ } else {
+ mw32(MVS_PHY_CTL, tmp);
+ mdelay(10);
+ mw32(MVS_PHY_CTL, reg);
+ }
+}
+
+static void mvs_64xx_phy_reset(struct mvs_info *mvi, u32 phy_id, int hard)
+{
+ u32 tmp;
+ tmp = mvs_read_port_irq_stat(mvi, phy_id);
+ tmp &= ~PHYEV_RDY_CH;
+ mvs_write_port_irq_stat(mvi, phy_id, tmp);
+ tmp = mvs_read_phy_ctl(mvi, phy_id);
+ if (hard)
+ tmp |= PHY_RST_HARD;
+ else
+ tmp |= PHY_RST;
+ mvs_write_phy_ctl(mvi, phy_id, tmp);
+ if (hard) {
+ do {
+ tmp = mvs_read_phy_ctl(mvi, phy_id);
+ } while (tmp & PHY_RST_HARD);
+ }
+}
+
+static int __devinit mvs_64xx_chip_reset(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+ int i;
+
+ /* make sure interrupts are masked immediately (paranoia) */
+ mw32(MVS_GBL_CTL, 0);
+ tmp = mr32(MVS_GBL_CTL);
+
+ /* Reset Controller */
+ if (!(tmp & HBA_RST)) {
+ if (mvi->flags & MVF_PHY_PWR_FIX) {
+ pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &tmp);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp |= PCTL_PHY_DSBL;
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp);
+
+ pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &tmp);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp |= PCTL_PHY_DSBL;
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp);
+ }
+ }
+
+ /* make sure interrupts are masked immediately (paranoia) */
+ mw32(MVS_GBL_CTL, 0);
+ tmp = mr32(MVS_GBL_CTL);
+
+ /* Reset Controller */
+ if (!(tmp & HBA_RST)) {
+ /* global reset, incl. COMRESET/H_RESET_N (self-clearing) */
+ mw32_f(MVS_GBL_CTL, HBA_RST);
+ }
+
+ /* wait for reset to finish; timeout is just a guess */
+ i = 1000;
+ while (i-- > 0) {
+ msleep(10);
+
+ if (!(mr32(MVS_GBL_CTL) & HBA_RST))
+ break;
+ }
+ if (mr32(MVS_GBL_CTL) & HBA_RST) {
+ dev_printk(KERN_ERR, mvi->dev, "HBA reset failed\n");
+ return -EBUSY;
+ }
+ return 0;
+}
+
+static void mvs_64xx_phy_disable(struct mvs_info *mvi, u32 phy_id)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ u32 offs;
+ if (phy_id < 4)
+ offs = PCR_PHY_CTL;
+ else {
+ offs = PCR_PHY_CTL2;
+ phy_id -= 4;
+ }
+ pci_read_config_dword(mvi->pdev, offs, &tmp);
+ tmp |= 1U << (PCTL_PHY_DSBL_OFFS + phy_id);
+ pci_write_config_dword(mvi->pdev, offs, tmp);
+ } else {
+ tmp = mr32(MVS_PHY_CTL);
+ tmp |= 1U << (PCTL_PHY_DSBL_OFFS + phy_id);
+ mw32(MVS_PHY_CTL, tmp);
+ }
+}
+
+static void mvs_64xx_phy_enable(struct mvs_info *mvi, u32 phy_id)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ u32 offs;
+ if (phy_id < 4)
+ offs = PCR_PHY_CTL;
+ else {
+ offs = PCR_PHY_CTL2;
+ phy_id -= 4;
+ }
+ pci_read_config_dword(mvi->pdev, offs, &tmp);
+ tmp &= ~(1U << (PCTL_PHY_DSBL_OFFS + phy_id));
+ pci_write_config_dword(mvi->pdev, offs, tmp);
+ } else {
+ tmp = mr32(MVS_PHY_CTL);
+ tmp &= ~(1U << (PCTL_PHY_DSBL_OFFS + phy_id));
+ mw32(MVS_PHY_CTL, tmp);
+ }
+}
+
+static int __devinit mvs_64xx_init(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ int i;
+ u32 tmp, cctl;
+
+ if (mvi->pdev && mvi->pdev->revision == 0)
+ mvi->flags |= MVF_PHY_PWR_FIX;
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ mvs_show_pcie_usage(mvi);
+ tmp = mvs_64xx_chip_reset(mvi);
+ if (tmp)
+ return tmp;
+ } else {
+ tmp = mr32(MVS_PHY_CTL);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp |= PCTL_PHY_DSBL;
+ mw32(MVS_PHY_CTL, tmp);
+ }
+
+ /* Init Chip */
+ /* make sure RST is set; HBA_RST /should/ have done that for us */
+ cctl = mr32(MVS_CTL) & 0xFFFF;
+ if (cctl & CCTL_RST)
+ cctl &= ~CCTL_RST;
+ else
+ mw32_f(MVS_CTL, cctl | CCTL_RST);
+
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ /* write to device control _AND_ device status register */
+ pci_read_config_dword(mvi->pdev, PCR_DEV_CTRL, &tmp);
+ tmp &= ~PRD_REQ_MASK;
+ tmp |= PRD_REQ_SIZE;
+ pci_write_config_dword(mvi->pdev, PCR_DEV_CTRL, tmp);
+
+ pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &tmp);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp &= ~PCTL_PHY_DSBL;
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp);
+
+ pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &tmp);
+ tmp &= PCTL_PWR_OFF;
+ tmp &= ~PCTL_PHY_DSBL;
+ pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp);
+ } else {
+ tmp = mr32(MVS_PHY_CTL);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp |= PCTL_COM_ON;
+ tmp &= ~PCTL_PHY_DSBL;
+ tmp |= PCTL_LINK_RST;
+ mw32(MVS_PHY_CTL, tmp);
+ msleep(100);
+ tmp &= ~PCTL_LINK_RST;
+ mw32(MVS_PHY_CTL, tmp);
+ msleep(100);
+ }
+
+ /* reset control */
+ mw32(MVS_PCS, 0); /* MVS_PCS */
+ /* init phys */
+ mvs_64xx_phy_hacks(mvi);
+
+ /* enable auto port detection */
+ mw32(MVS_GBL_PORT_TYPE, MODE_AUTO_DET_EN);
+
+ mw32(MVS_CMD_LIST_LO, mvi->slot_dma);
+ mw32(MVS_CMD_LIST_HI, (mvi->slot_dma >> 16) >> 16);
+
+ mw32(MVS_RX_FIS_LO, mvi->rx_fis_dma);
+ mw32(MVS_RX_FIS_HI, (mvi->rx_fis_dma >> 16) >> 16);
+
+ mw32(MVS_TX_CFG, MVS_CHIP_SLOT_SZ);
+ mw32(MVS_TX_LO, mvi->tx_dma);
+ mw32(MVS_TX_HI, (mvi->tx_dma >> 16) >> 16);
+
+ mw32(MVS_RX_CFG, MVS_RX_RING_SZ);
+ mw32(MVS_RX_LO, mvi->rx_dma);
+ mw32(MVS_RX_HI, (mvi->rx_dma >> 16) >> 16);
+
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ /* set phy local SAS address */
+ /* should set little endian SAS address to 64xx chip */
+ mvs_set_sas_addr(mvi, i, PHYR_ADDR_LO, PHYR_ADDR_HI,
+ cpu_to_be64(mvi->phy[i].dev_sas_addr));
+
+ mvs_64xx_enable_xmt(mvi, i);
+
+ mvs_64xx_phy_reset(mvi, i, 1);
+ msleep(500);
+ mvs_64xx_detect_porttype(mvi, i);
+ }
+ if (mvi->flags & MVF_FLAG_SOC) {
+ /* set select registers */
+ writel(0x0E008000, regs + 0x000);
+ writel(0x59000008, regs + 0x004);
+ writel(0x20, regs + 0x008);
+ writel(0x20, regs + 0x00c);
+ writel(0x20, regs + 0x010);
+ writel(0x20, regs + 0x014);
+ writel(0x20, regs + 0x018);
+ writel(0x20, regs + 0x01c);
+ }
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ /* clear phy int status */
+ tmp = mvs_read_port_irq_stat(mvi, i);
+ tmp &= ~PHYEV_SIG_FIS;
+ mvs_write_port_irq_stat(mvi, i, tmp);
+
+ /* set phy int mask */
+ tmp = PHYEV_RDY_CH | PHYEV_BROAD_CH | PHYEV_UNASSOC_FIS |
+ PHYEV_ID_DONE | PHYEV_DCDR_ERR | PHYEV_CRC_ERR |
+ PHYEV_DEC_ERR;
+ mvs_write_port_irq_mask(mvi, i, tmp);
+
+ msleep(100);
+ mvs_update_phyinfo(mvi, i, 1);
+ }
+
+ /* FIXME: update wide port bitmaps */
+
+ /* little endian for open address and command table, etc. */
+ /*
+ * it seems that ( from the spec ) turning on big-endian won't
+ * do us any good on big-endian machines, need further confirmation
+ */
+ cctl = mr32(MVS_CTL);
+ cctl |= CCTL_ENDIAN_CMD;
+ cctl |= CCTL_ENDIAN_DATA;
+ cctl &= ~CCTL_ENDIAN_OPEN;
+ cctl |= CCTL_ENDIAN_RSP;
+ mw32_f(MVS_CTL, cctl);
+
+ /* reset CMD queue */
+ tmp = mr32(MVS_PCS);
+ tmp |= PCS_CMD_RST;
+ mw32(MVS_PCS, tmp);
+ /* interrupt coalescing may cause missing HW interrput in some case,
+ * and the max count is 0x1ff, while our max slot is 0x200,
+ * it will make count 0.
+ */
+ tmp = 0;
+ mw32(MVS_INT_COAL, tmp);
+
+ tmp = 0x100;
+ mw32(MVS_INT_COAL_TMOUT, tmp);
+
+ /* ladies and gentlemen, start your engines */
+ mw32(MVS_TX_CFG, 0);
+ mw32(MVS_TX_CFG, MVS_CHIP_SLOT_SZ | TX_EN);
+ mw32(MVS_RX_CFG, MVS_RX_RING_SZ | RX_EN);
+ /* enable CMD/CMPL_Q/RESP mode */
+ mw32(MVS_PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN |
+ PCS_CMD_EN | PCS_CMD_STOP_ERR);
+
+ /* enable completion queue interrupt */
+ tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM | CINT_SRS | CINT_CI_STOP |
+ CINT_DMA_PCIE);
+
+ mw32(MVS_INT_MASK, tmp);
+
+ /* Enable SRS interrupt */
+ mw32(MVS_INT_MASK_SRS_0, 0xFFFF);
+
+ return 0;
+}
+
+static int mvs_64xx_ioremap(struct mvs_info *mvi)
+{
+ if (!mvs_ioremap(mvi, 4, 2))
+ return 0;
+ return -1;
+}
+
+static void mvs_64xx_iounmap(struct mvs_info *mvi)
+{
+ mvs_iounmap(mvi->regs);
+ mvs_iounmap(mvi->regs_ex);
+}
+
+static void mvs_64xx_interrupt_enable(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+
+ tmp = mr32(MVS_GBL_CTL);
+ mw32(MVS_GBL_CTL, tmp | INT_EN);
+}
+
+static void mvs_64xx_interrupt_disable(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+
+ tmp = mr32(MVS_GBL_CTL);
+ mw32(MVS_GBL_CTL, tmp & ~INT_EN);
+}
+
+static u32 mvs_64xx_isr_status(struct mvs_info *mvi, int irq)
+{
+ void __iomem *regs = mvi->regs;
+ u32 stat;
+
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ stat = mr32(MVS_GBL_INT_STAT);
+
+ if (stat == 0 || stat == 0xffffffff)
+ return 0;
+ } else
+ stat = 1;
+ return stat;
+}
+
+static irqreturn_t mvs_64xx_isr(struct mvs_info *mvi, int irq, u32 stat)
+{
+ void __iomem *regs = mvi->regs;
+
+ /* clear CMD_CMPLT ASAP */
+ mw32_f(MVS_INT_STAT, CINT_DONE);
+#ifndef MVS_USE_TASKLET
+ spin_lock(&mvi->lock);
+#endif
+ mvs_int_full(mvi);
+#ifndef MVS_USE_TASKLET
+ spin_unlock(&mvi->lock);
+#endif
+ return IRQ_HANDLED;
+}
+
+static void mvs_64xx_command_active(struct mvs_info *mvi, u32 slot_idx)
+{
+ u32 tmp;
+ mvs_cw32(mvi, 0x40 + (slot_idx >> 3), 1 << (slot_idx % 32));
+ mvs_cw32(mvi, 0x00 + (slot_idx >> 3), 1 << (slot_idx % 32));
+ do {
+ tmp = mvs_cr32(mvi, 0x00 + (slot_idx >> 3));
+ } while (tmp & 1 << (slot_idx % 32));
+ do {
+ tmp = mvs_cr32(mvi, 0x40 + (slot_idx >> 3));
+ } while (tmp & 1 << (slot_idx % 32));
+}
+
+static void mvs_64xx_issue_stop(struct mvs_info *mvi, enum mvs_port_type type,
+ u32 tfs)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+
+ if (type == PORT_TYPE_SATA) {
+ tmp = mr32(MVS_INT_STAT_SRS_0) | (1U << tfs);
+ mw32(MVS_INT_STAT_SRS_0, tmp);
+ }
+ mw32(MVS_INT_STAT, CINT_CI_STOP);
+ tmp = mr32(MVS_PCS) | 0xFF00;
+ mw32(MVS_PCS, tmp);
+}
+
+static void mvs_64xx_free_reg_set(struct mvs_info *mvi, u8 *tfs)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp, offs;
+
+ if (*tfs == MVS_ID_NOT_MAPPED)
+ return;
+
+ offs = 1U << ((*tfs & 0x0f) + PCS_EN_SATA_REG_SHIFT);
+ if (*tfs < 16) {
+ tmp = mr32(MVS_PCS);
+ mw32(MVS_PCS, tmp & ~offs);
+ } else {
+ tmp = mr32(MVS_CTL);
+ mw32(MVS_CTL, tmp & ~offs);
+ }
+
+ tmp = mr32(MVS_INT_STAT_SRS_0) & (1U << *tfs);
+ if (tmp)
+ mw32(MVS_INT_STAT_SRS_0, tmp);
+
+ *tfs = MVS_ID_NOT_MAPPED;
+ return;
+}
+
+static u8 mvs_64xx_assign_reg_set(struct mvs_info *mvi, u8 *tfs)
+{
+ int i;
+ u32 tmp, offs;
+ void __iomem *regs = mvi->regs;
+
+ if (*tfs != MVS_ID_NOT_MAPPED)
+ return 0;
+
+ tmp = mr32(MVS_PCS);
+
+ for (i = 0; i < mvi->chip->srs_sz; i++) {
+ if (i == 16)
+ tmp = mr32(MVS_CTL);
+ offs = 1U << ((i & 0x0f) + PCS_EN_SATA_REG_SHIFT);
+ if (!(tmp & offs)) {
+ *tfs = i;
+
+ if (i < 16)
+ mw32(MVS_PCS, tmp | offs);
+ else
+ mw32(MVS_CTL, tmp | offs);
+ tmp = mr32(MVS_INT_STAT_SRS_0) & (1U << i);
+ if (tmp)
+ mw32(MVS_INT_STAT_SRS_0, tmp);
+ return 0;
+ }
+ }
+ return MVS_ID_NOT_MAPPED;
+}
+
+void mvs_64xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
+{
+ int i;
+ struct scatterlist *sg;
+ struct mvs_prd *buf_prd = prd;
+ for_each_sg(scatter, sg, nr, i) {
+ buf_prd->addr = cpu_to_le64(sg_dma_address(sg));
+ buf_prd->len = cpu_to_le32(sg_dma_len(sg));
+ buf_prd++;
+ }
+}
+
+static int mvs_64xx_oob_done(struct mvs_info *mvi, int i)
+{
+ u32 phy_st;
+ mvs_write_port_cfg_addr(mvi, i,
+ PHYR_PHY_STAT);
+ phy_st = mvs_read_port_cfg_data(mvi, i);
+ if (phy_st & PHY_OOB_DTCTD)
+ return 1;
+ return 0;
+}
+
+static void mvs_64xx_fix_phy_info(struct mvs_info *mvi, int i,
+ struct sas_identify_frame *id)
+
+{
+ struct mvs_phy *phy = &mvi->phy[i];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+
+ sas_phy->linkrate =
+ (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET;
+
+ phy->minimum_linkrate =
+ (phy->phy_status &
+ PHY_MIN_SPP_PHYS_LINK_RATE_MASK) >> 8;
+ phy->maximum_linkrate =
+ (phy->phy_status &
+ PHY_MAX_SPP_PHYS_LINK_RATE_MASK) >> 12;
+
+ mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY);
+ phy->dev_info = mvs_read_port_cfg_data(mvi, i);
+
+ mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO);
+ phy->att_dev_info = mvs_read_port_cfg_data(mvi, i);
+
+ mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI);
+ phy->att_dev_sas_addr =
+ (u64) mvs_read_port_cfg_data(mvi, i) << 32;
+ mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO);
+ phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
+ phy->att_dev_sas_addr = SAS_ADDR(&phy->att_dev_sas_addr);
+}
+
+static void mvs_64xx_phy_work_around(struct mvs_info *mvi, int i)
+{
+ u32 tmp;
+ struct mvs_phy *phy = &mvi->phy[i];
+ /* workaround for HW phy decoding error on 1.5g disk drive */
+ mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6);
+ tmp = mvs_read_port_vsr_data(mvi, i);
+ if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) ==
+ SAS_LINK_RATE_1_5_GBPS)
+ tmp &= ~PHY_MODE6_LATECLK;
+ else
+ tmp |= PHY_MODE6_LATECLK;
+ mvs_write_port_vsr_data(mvi, i, tmp);
+}
+
+void mvs_64xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
+ struct sas_phy_linkrates *rates)
+{
+ u32 lrmin = 0, lrmax = 0;
+ u32 tmp;
+
+ tmp = mvs_read_phy_ctl(mvi, phy_id);
+ lrmin = (rates->minimum_linkrate << 8);
+ lrmax = (rates->maximum_linkrate << 12);
+
+ if (lrmin) {
+ tmp &= ~(0xf << 8);
+ tmp |= lrmin;
+ }
+ if (lrmax) {
+ tmp &= ~(0xf << 12);
+ tmp |= lrmax;
+ }
+ mvs_write_phy_ctl(mvi, phy_id, tmp);
+ mvs_64xx_phy_reset(mvi, phy_id, 1);
+}
+
+static void mvs_64xx_clear_active_cmds(struct mvs_info *mvi)
+{
+ u32 tmp;
+ void __iomem *regs = mvi->regs;
+ tmp = mr32(MVS_PCS);
+ mw32(MVS_PCS, tmp & 0xFFFF);
+ mw32(MVS_PCS, tmp);
+ tmp = mr32(MVS_CTL);
+ mw32(MVS_CTL, tmp & 0xFFFF);
+ mw32(MVS_CTL, tmp);
+}
+
+
+u32 mvs_64xx_spi_read_data(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs_ex;
+ return ior32(SPI_DATA_REG_64XX);
+}
+
+void mvs_64xx_spi_write_data(struct mvs_info *mvi, u32 data)
+{
+ void __iomem *regs = mvi->regs_ex;
+ iow32(SPI_DATA_REG_64XX, data);
+}
+
+
+int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
+ u32 *dwCmd,
+ u8 cmd,
+ u8 read,
+ u8 length,
+ u32 addr
+ )
+{
+ u32 dwTmp;
+
+ dwTmp = ((u32)cmd << 24) | ((u32)length << 19);
+ if (read)
+ dwTmp |= 1U<<23;
+
+ if (addr != MV_MAX_U32) {
+ dwTmp |= 1U<<22;
+ dwTmp |= (addr & 0x0003FFFF);
+ }
+
+ *dwCmd = dwTmp;
+ return 0;
+}
+
+
+int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
+{
+ void __iomem *regs = mvi->regs_ex;
+ int retry;
+
+ for (retry = 0; retry < 1; retry++) {
+ iow32(SPI_CTRL_REG_64XX, SPI_CTRL_VENDOR_ENABLE);
+ iow32(SPI_CMD_REG_64XX, cmd);
+ iow32(SPI_CTRL_REG_64XX,
+ SPI_CTRL_VENDOR_ENABLE | SPI_CTRL_SPISTART);
+ }
+
+ return 0;
+}
+
+int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
+{
+ void __iomem *regs = mvi->regs_ex;
+ u32 i, dwTmp;
+
+ for (i = 0; i < timeout; i++) {
+ dwTmp = ior32(SPI_CTRL_REG_64XX);
+ if (!(dwTmp & SPI_CTRL_SPISTART))
+ return 0;
+ msleep(10);
+ }
+
+ return -1;
+}
+
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+void mvs_64xx_fix_dma(dma_addr_t buf_dma, int buf_len, int from, void *prd)
+{
+ int i;
+ struct mvs_prd *buf_prd = prd;
+ buf_prd += from;
+ for (i = 0; i < MAX_SG_ENTRY - from; i++) {
+ buf_prd->addr = cpu_to_le64(buf_dma);
+ buf_prd->len = cpu_to_le32(buf_len);
+ ++buf_prd;
+ }
+}
+#endif
+
+const struct mvs_dispatch mvs_64xx_dispatch = {
+ "mv64xx",
+ mvs_64xx_init,
+ NULL,
+ mvs_64xx_ioremap,
+ mvs_64xx_iounmap,
+ mvs_64xx_isr,
+ mvs_64xx_isr_status,
+ mvs_64xx_interrupt_enable,
+ mvs_64xx_interrupt_disable,
+ mvs_read_phy_ctl,
+ mvs_write_phy_ctl,
+ mvs_read_port_cfg_data,
+ mvs_write_port_cfg_data,
+ mvs_write_port_cfg_addr,
+ mvs_read_port_vsr_data,
+ mvs_write_port_vsr_data,
+ mvs_write_port_vsr_addr,
+ mvs_read_port_irq_stat,
+ mvs_write_port_irq_stat,
+ mvs_read_port_irq_mask,
+ mvs_write_port_irq_mask,
+ mvs_get_sas_addr,
+ mvs_64xx_command_active,
+ mvs_64xx_issue_stop,
+ mvs_start_delivery,
+ mvs_rx_update,
+ mvs_int_full,
+ mvs_64xx_assign_reg_set,
+ mvs_64xx_free_reg_set,
+ mvs_get_prd_size,
+ mvs_get_prd_count,
+ mvs_64xx_make_prd,
+ mvs_64xx_detect_porttype,
+ mvs_64xx_oob_done,
+ mvs_64xx_fix_phy_info,
+ mvs_64xx_phy_work_around,
+ mvs_64xx_phy_set_link_rate,
+ mvs_hw_max_link_rate,
+ mvs_64xx_phy_disable,
+ mvs_64xx_phy_enable,
+ mvs_64xx_phy_reset,
+ mvs_64xx_stp_reset,
+ mvs_64xx_clear_active_cmds,
+ mvs_64xx_spi_read_data,
+ mvs_64xx_spi_write_data,
+ mvs_64xx_spi_buildcmd,
+ mvs_64xx_spi_issuecmd,
+ mvs_64xx_spi_waitdataready,
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ mvs_64xx_fix_dma,
+#endif
+};
+
diff --git a/drivers/scsi/mvsas/mv_64xx.h b/drivers/scsi/mvsas/mv_64xx.h
new file mode 100644
index 000000000000..42e947d9795e
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_64xx.h
@@ -0,0 +1,151 @@
+/*
+ * Marvell 88SE64xx hardware specific head file
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#ifndef _MVS64XX_REG_H_
+#define _MVS64XX_REG_H_
+
+#include <linux/types.h>
+
+#define MAX_LINK_RATE SAS_LINK_RATE_3_0_GBPS
+
+/* enhanced mode registers (BAR4) */
+enum hw_registers {
+ MVS_GBL_CTL = 0x04, /* global control */
+ MVS_GBL_INT_STAT = 0x08, /* global irq status */
+ MVS_GBL_PI = 0x0C, /* ports implemented bitmask */
+
+ MVS_PHY_CTL = 0x40, /* SOC PHY Control */
+ MVS_PORTS_IMP = 0x9C, /* SOC Port Implemented */
+
+ MVS_GBL_PORT_TYPE = 0xa0, /* port type */
+
+ MVS_CTL = 0x100, /* SAS/SATA port configuration */
+ MVS_PCS = 0x104, /* SAS/SATA port control/status */
+ MVS_CMD_LIST_LO = 0x108, /* cmd list addr */
+ MVS_CMD_LIST_HI = 0x10C,
+ MVS_RX_FIS_LO = 0x110, /* RX FIS list addr */
+ MVS_RX_FIS_HI = 0x114,
+
+ MVS_TX_CFG = 0x120, /* TX configuration */
+ MVS_TX_LO = 0x124, /* TX (delivery) ring addr */
+ MVS_TX_HI = 0x128,
+
+ MVS_TX_PROD_IDX = 0x12C, /* TX producer pointer */
+ MVS_TX_CONS_IDX = 0x130, /* TX consumer pointer (RO) */
+ MVS_RX_CFG = 0x134, /* RX configuration */
+ MVS_RX_LO = 0x138, /* RX (completion) ring addr */
+ MVS_RX_HI = 0x13C,
+ MVS_RX_CONS_IDX = 0x140, /* RX consumer pointer (RO) */
+
+ MVS_INT_COAL = 0x148, /* Int coalescing config */
+ MVS_INT_COAL_TMOUT = 0x14C, /* Int coalescing timeout */
+ MVS_INT_STAT = 0x150, /* Central int status */
+ MVS_INT_MASK = 0x154, /* Central int enable */
+ MVS_INT_STAT_SRS_0 = 0x158, /* SATA register set status */
+ MVS_INT_MASK_SRS_0 = 0x15C,
+
+ /* ports 1-3 follow after this */
+ MVS_P0_INT_STAT = 0x160, /* port0 interrupt status */
+ MVS_P0_INT_MASK = 0x164, /* port0 interrupt mask */
+ /* ports 5-7 follow after this */
+ MVS_P4_INT_STAT = 0x200, /* Port4 interrupt status */
+ MVS_P4_INT_MASK = 0x204, /* Port4 interrupt enable mask */
+
+ /* ports 1-3 follow after this */
+ MVS_P0_SER_CTLSTAT = 0x180, /* port0 serial control/status */
+ /* ports 5-7 follow after this */
+ MVS_P4_SER_CTLSTAT = 0x220, /* port4 serial control/status */
+
+ MVS_CMD_ADDR = 0x1B8, /* Command register port (addr) */
+ MVS_CMD_DATA = 0x1BC, /* Command register port (data) */
+
+ /* ports 1-3 follow after this */
+ MVS_P0_CFG_ADDR = 0x1C0, /* port0 phy register address */
+ MVS_P0_CFG_DATA = 0x1C4, /* port0 phy register data */
+ /* ports 5-7 follow after this */
+ MVS_P4_CFG_ADDR = 0x230, /* Port4 config address */
+ MVS_P4_CFG_DATA = 0x234, /* Port4 config data */
+
+ /* ports 1-3 follow after this */
+ MVS_P0_VSR_ADDR = 0x1E0, /* port0 VSR address */
+ MVS_P0_VSR_DATA = 0x1E4, /* port0 VSR data */
+ /* ports 5-7 follow after this */
+ MVS_P4_VSR_ADDR = 0x250, /* port4 VSR addr */
+ MVS_P4_VSR_DATA = 0x254, /* port4 VSR data */
+};
+
+enum pci_cfg_registers {
+ PCR_PHY_CTL = 0x40,
+ PCR_PHY_CTL2 = 0x90,
+ PCR_DEV_CTRL = 0xE8,
+ PCR_LINK_STAT = 0xF2,
+};
+
+/* SAS/SATA Vendor Specific Port Registers */
+enum sas_sata_vsp_regs {
+ VSR_PHY_STAT = 0x00, /* Phy Status */
+ VSR_PHY_MODE1 = 0x01, /* phy tx */
+ VSR_PHY_MODE2 = 0x02, /* tx scc */
+ VSR_PHY_MODE3 = 0x03, /* pll */
+ VSR_PHY_MODE4 = 0x04, /* VCO */
+ VSR_PHY_MODE5 = 0x05, /* Rx */
+ VSR_PHY_MODE6 = 0x06, /* CDR */
+ VSR_PHY_MODE7 = 0x07, /* Impedance */
+ VSR_PHY_MODE8 = 0x08, /* Voltage */
+ VSR_PHY_MODE9 = 0x09, /* Test */
+ VSR_PHY_MODE10 = 0x0A, /* Power */
+ VSR_PHY_MODE11 = 0x0B, /* Phy Mode */
+ VSR_PHY_VS0 = 0x0C, /* Vednor Specific 0 */
+ VSR_PHY_VS1 = 0x0D, /* Vednor Specific 1 */
+};
+
+enum chip_register_bits {
+ PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0xF << 8),
+ PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0xF << 12),
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (16),
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK =
+ (0xF << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET),
+};
+
+#define MAX_SG_ENTRY 64
+
+struct mvs_prd {
+ __le64 addr; /* 64-bit buffer address */
+ __le32 reserved;
+ __le32 len; /* 16-bit length */
+};
+
+#define SPI_CTRL_REG 0xc0
+#define SPI_CTRL_VENDOR_ENABLE (1U<<29)
+#define SPI_CTRL_SPIRDY (1U<<22)
+#define SPI_CTRL_SPISTART (1U<<20)
+
+#define SPI_CMD_REG 0xc4
+#define SPI_DATA_REG 0xc8
+
+#define SPI_CTRL_REG_64XX 0x10
+#define SPI_CMD_REG_64XX 0x14
+#define SPI_DATA_REG_64XX 0x18
+
+#endif
diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c
new file mode 100644
index 000000000000..0940fae19d20
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_94xx.c
@@ -0,0 +1,672 @@
+/*
+ * Marvell 88SE94xx hardware specific
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#include "mv_sas.h"
+#include "mv_94xx.h"
+#include "mv_chips.h"
+
+static void mvs_94xx_detect_porttype(struct mvs_info *mvi, int i)
+{
+ u32 reg;
+ struct mvs_phy *phy = &mvi->phy[i];
+ u32 phy_status;
+
+ mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE3);
+ reg = mvs_read_port_vsr_data(mvi, i);
+ phy_status = ((reg & 0x3f0000) >> 16) & 0xff;
+ phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA);
+ switch (phy_status) {
+ case 0x10:
+ phy->phy_type |= PORT_TYPE_SAS;
+ break;
+ case 0x1d:
+ default:
+ phy->phy_type |= PORT_TYPE_SATA;
+ break;
+ }
+}
+
+static void __devinit mvs_94xx_enable_xmt(struct mvs_info *mvi, int phy_id)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+
+ tmp = mr32(MVS_PCS);
+ tmp |= 1 << (phy_id + PCS_EN_PORT_XMT_SHIFT2);
+ mw32(MVS_PCS, tmp);
+}
+
+static void mvs_94xx_phy_reset(struct mvs_info *mvi, u32 phy_id, int hard)
+{
+ u32 tmp;
+
+ tmp = mvs_read_port_irq_stat(mvi, phy_id);
+ tmp &= ~PHYEV_RDY_CH;
+ mvs_write_port_irq_stat(mvi, phy_id, tmp);
+ if (hard) {
+ tmp = mvs_read_phy_ctl(mvi, phy_id);
+ tmp |= PHY_RST_HARD;
+ mvs_write_phy_ctl(mvi, phy_id, tmp);
+ do {
+ tmp = mvs_read_phy_ctl(mvi, phy_id);
+ } while (tmp & PHY_RST_HARD);
+ } else {
+ mvs_write_port_vsr_addr(mvi, phy_id, VSR_PHY_STAT);
+ tmp = mvs_read_port_vsr_data(mvi, phy_id);
+ tmp |= PHY_RST;
+ mvs_write_port_vsr_data(mvi, phy_id, tmp);
+ }
+}
+
+static void mvs_94xx_phy_disable(struct mvs_info *mvi, u32 phy_id)
+{
+ u32 tmp;
+ mvs_write_port_vsr_addr(mvi, phy_id, VSR_PHY_MODE2);
+ tmp = mvs_read_port_vsr_data(mvi, phy_id);
+ mvs_write_port_vsr_data(mvi, phy_id, tmp | 0x00800000);
+}
+
+static void mvs_94xx_phy_enable(struct mvs_info *mvi, u32 phy_id)
+{
+ mvs_write_port_vsr_addr(mvi, phy_id, 0x1B4);
+ mvs_write_port_vsr_data(mvi, phy_id, 0x8300ffc1);
+ mvs_write_port_vsr_addr(mvi, phy_id, 0x104);
+ mvs_write_port_vsr_data(mvi, phy_id, 0x00018080);
+ mvs_write_port_vsr_addr(mvi, phy_id, VSR_PHY_MODE2);
+ mvs_write_port_vsr_data(mvi, phy_id, 0x00207fff);
+}
+
+static int __devinit mvs_94xx_init(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ int i;
+ u32 tmp, cctl;
+
+ mvs_show_pcie_usage(mvi);
+ if (mvi->flags & MVF_FLAG_SOC) {
+ tmp = mr32(MVS_PHY_CTL);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp |= PCTL_PHY_DSBL;
+ mw32(MVS_PHY_CTL, tmp);
+ }
+
+ /* Init Chip */
+ /* make sure RST is set; HBA_RST /should/ have done that for us */
+ cctl = mr32(MVS_CTL) & 0xFFFF;
+ if (cctl & CCTL_RST)
+ cctl &= ~CCTL_RST;
+ else
+ mw32_f(MVS_CTL, cctl | CCTL_RST);
+
+ if (mvi->flags & MVF_FLAG_SOC) {
+ tmp = mr32(MVS_PHY_CTL);
+ tmp &= ~PCTL_PWR_OFF;
+ tmp |= PCTL_COM_ON;
+ tmp &= ~PCTL_PHY_DSBL;
+ tmp |= PCTL_LINK_RST;
+ mw32(MVS_PHY_CTL, tmp);
+ msleep(100);
+ tmp &= ~PCTL_LINK_RST;
+ mw32(MVS_PHY_CTL, tmp);
+ msleep(100);
+ }
+
+ /* reset control */
+ mw32(MVS_PCS, 0); /* MVS_PCS */
+ mw32(MVS_STP_REG_SET_0, 0);
+ mw32(MVS_STP_REG_SET_1, 0);
+
+ /* init phys */
+ mvs_phy_hacks(mvi);
+
+ /* disable Multiplexing, enable phy implemented */
+ mw32(MVS_PORTS_IMP, 0xFF);
+
+
+ mw32(MVS_PA_VSR_ADDR, 0x00000104);
+ mw32(MVS_PA_VSR_PORT, 0x00018080);
+ mw32(MVS_PA_VSR_ADDR, VSR_PHY_MODE8);
+ mw32(MVS_PA_VSR_PORT, 0x0084ffff);
+
+ /* set LED blink when IO*/
+ mw32(MVS_PA_VSR_ADDR, 0x00000030);
+ tmp = mr32(MVS_PA_VSR_PORT);
+ tmp &= 0xFFFF00FF;
+ tmp |= 0x00003300;
+ mw32(MVS_PA_VSR_PORT, tmp);
+
+ mw32(MVS_CMD_LIST_LO, mvi->slot_dma);
+ mw32(MVS_CMD_LIST_HI, (mvi->slot_dma >> 16) >> 16);
+
+ mw32(MVS_RX_FIS_LO, mvi->rx_fis_dma);
+ mw32(MVS_RX_FIS_HI, (mvi->rx_fis_dma >> 16) >> 16);
+
+ mw32(MVS_TX_CFG, MVS_CHIP_SLOT_SZ);
+ mw32(MVS_TX_LO, mvi->tx_dma);
+ mw32(MVS_TX_HI, (mvi->tx_dma >> 16) >> 16);
+
+ mw32(MVS_RX_CFG, MVS_RX_RING_SZ);
+ mw32(MVS_RX_LO, mvi->rx_dma);
+ mw32(MVS_RX_HI, (mvi->rx_dma >> 16) >> 16);
+
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ mvs_94xx_phy_disable(mvi, i);
+ /* set phy local SAS address */
+ mvs_set_sas_addr(mvi, i, CONFIG_ID_FRAME3, CONFIG_ID_FRAME4,
+ (mvi->phy[i].dev_sas_addr));
+
+ mvs_94xx_enable_xmt(mvi, i);
+ mvs_94xx_phy_enable(mvi, i);
+
+ mvs_94xx_phy_reset(mvi, i, 1);
+ msleep(500);
+ mvs_94xx_detect_porttype(mvi, i);
+ }
+
+ if (mvi->flags & MVF_FLAG_SOC) {
+ /* set select registers */
+ writel(0x0E008000, regs + 0x000);
+ writel(0x59000008, regs + 0x004);
+ writel(0x20, regs + 0x008);
+ writel(0x20, regs + 0x00c);
+ writel(0x20, regs + 0x010);
+ writel(0x20, regs + 0x014);
+ writel(0x20, regs + 0x018);
+ writel(0x20, regs + 0x01c);
+ }
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ /* clear phy int status */
+ tmp = mvs_read_port_irq_stat(mvi, i);
+ tmp &= ~PHYEV_SIG_FIS;
+ mvs_write_port_irq_stat(mvi, i, tmp);
+
+ /* set phy int mask */
+ tmp = PHYEV_RDY_CH | PHYEV_BROAD_CH |
+ PHYEV_ID_DONE | PHYEV_DCDR_ERR | PHYEV_CRC_ERR ;
+ mvs_write_port_irq_mask(mvi, i, tmp);
+
+ msleep(100);
+ mvs_update_phyinfo(mvi, i, 1);
+ }
+
+ /* FIXME: update wide port bitmaps */
+
+ /* little endian for open address and command table, etc. */
+ /*
+ * it seems that ( from the spec ) turning on big-endian won't
+ * do us any good on big-endian machines, need further confirmation
+ */
+ cctl = mr32(MVS_CTL);
+ cctl |= CCTL_ENDIAN_CMD;
+ cctl |= CCTL_ENDIAN_DATA;
+ cctl &= ~CCTL_ENDIAN_OPEN;
+ cctl |= CCTL_ENDIAN_RSP;
+ mw32_f(MVS_CTL, cctl);
+
+ /* reset CMD queue */
+ tmp = mr32(MVS_PCS);
+ tmp |= PCS_CMD_RST;
+ mw32(MVS_PCS, tmp);
+ /* interrupt coalescing may cause missing HW interrput in some case,
+ * and the max count is 0x1ff, while our max slot is 0x200,
+ * it will make count 0.
+ */
+ tmp = 0;
+ mw32(MVS_INT_COAL, tmp);
+
+ tmp = 0x100;
+ mw32(MVS_INT_COAL_TMOUT, tmp);
+
+ /* ladies and gentlemen, start your engines */
+ mw32(MVS_TX_CFG, 0);
+ mw32(MVS_TX_CFG, MVS_CHIP_SLOT_SZ | TX_EN);
+ mw32(MVS_RX_CFG, MVS_RX_RING_SZ | RX_EN);
+ /* enable CMD/CMPL_Q/RESP mode */
+ mw32(MVS_PCS, PCS_SATA_RETRY_2 | PCS_FIS_RX_EN |
+ PCS_CMD_EN | PCS_CMD_STOP_ERR);
+
+ /* enable completion queue interrupt */
+ tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM | CINT_SRS | CINT_CI_STOP |
+ CINT_DMA_PCIE);
+ tmp |= CINT_PHY_MASK;
+ mw32(MVS_INT_MASK, tmp);
+
+ /* Enable SRS interrupt */
+ mw32(MVS_INT_MASK_SRS_0, 0xFFFF);
+
+ return 0;
+}
+
+static int mvs_94xx_ioremap(struct mvs_info *mvi)
+{
+ if (!mvs_ioremap(mvi, 2, -1)) {
+ mvi->regs_ex = mvi->regs + 0x10200;
+ mvi->regs += 0x20000;
+ if (mvi->id == 1)
+ mvi->regs += 0x4000;
+ return 0;
+ }
+ return -1;
+}
+
+static void mvs_94xx_iounmap(struct mvs_info *mvi)
+{
+ if (mvi->regs) {
+ mvi->regs -= 0x20000;
+ if (mvi->id == 1)
+ mvi->regs -= 0x4000;
+ mvs_iounmap(mvi->regs);
+ }
+}
+
+static void mvs_94xx_interrupt_enable(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs_ex;
+ u32 tmp;
+
+ tmp = mr32(MVS_GBL_CTL);
+ tmp |= (IRQ_SAS_A | IRQ_SAS_B);
+ mw32(MVS_GBL_INT_STAT, tmp);
+ writel(tmp, regs + 0x0C);
+ writel(tmp, regs + 0x10);
+ writel(tmp, regs + 0x14);
+ writel(tmp, regs + 0x18);
+ mw32(MVS_GBL_CTL, tmp);
+}
+
+static void mvs_94xx_interrupt_disable(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs_ex;
+ u32 tmp;
+
+ tmp = mr32(MVS_GBL_CTL);
+
+ tmp &= ~(IRQ_SAS_A | IRQ_SAS_B);
+ mw32(MVS_GBL_INT_STAT, tmp);
+ writel(tmp, regs + 0x0C);
+ writel(tmp, regs + 0x10);
+ writel(tmp, regs + 0x14);
+ writel(tmp, regs + 0x18);
+ mw32(MVS_GBL_CTL, tmp);
+}
+
+static u32 mvs_94xx_isr_status(struct mvs_info *mvi, int irq)
+{
+ void __iomem *regs = mvi->regs_ex;
+ u32 stat = 0;
+ if (!(mvi->flags & MVF_FLAG_SOC)) {
+ stat = mr32(MVS_GBL_INT_STAT);
+
+ if (!(stat & (IRQ_SAS_A | IRQ_SAS_B)))
+ return 0;
+ }
+ return stat;
+}
+
+static irqreturn_t mvs_94xx_isr(struct mvs_info *mvi, int irq, u32 stat)
+{
+ void __iomem *regs = mvi->regs;
+
+ if (((stat & IRQ_SAS_A) && mvi->id == 0) ||
+ ((stat & IRQ_SAS_B) && mvi->id == 1)) {
+ mw32_f(MVS_INT_STAT, CINT_DONE);
+ #ifndef MVS_USE_TASKLET
+ spin_lock(&mvi->lock);
+ #endif
+ mvs_int_full(mvi);
+ #ifndef MVS_USE_TASKLET
+ spin_unlock(&mvi->lock);
+ #endif
+ }
+ return IRQ_HANDLED;
+}
+
+static void mvs_94xx_command_active(struct mvs_info *mvi, u32 slot_idx)
+{
+ u32 tmp;
+ mvs_cw32(mvi, 0x300 + (slot_idx >> 3), 1 << (slot_idx % 32));
+ do {
+ tmp = mvs_cr32(mvi, 0x300 + (slot_idx >> 3));
+ } while (tmp & 1 << (slot_idx % 32));
+}
+
+static void mvs_94xx_issue_stop(struct mvs_info *mvi, enum mvs_port_type type,
+ u32 tfs)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+
+ if (type == PORT_TYPE_SATA) {
+ tmp = mr32(MVS_INT_STAT_SRS_0) | (1U << tfs);
+ mw32(MVS_INT_STAT_SRS_0, tmp);
+ }
+ mw32(MVS_INT_STAT, CINT_CI_STOP);
+ tmp = mr32(MVS_PCS) | 0xFF00;
+ mw32(MVS_PCS, tmp);
+}
+
+static void mvs_94xx_free_reg_set(struct mvs_info *mvi, u8 *tfs)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp;
+ u8 reg_set = *tfs;
+
+ if (*tfs == MVS_ID_NOT_MAPPED)
+ return;
+
+ mvi->sata_reg_set &= ~bit(reg_set);
+ if (reg_set < 32) {
+ w_reg_set_enable(reg_set, (u32)mvi->sata_reg_set);
+ tmp = mr32(MVS_INT_STAT_SRS_0) & (u32)mvi->sata_reg_set;
+ if (tmp)
+ mw32(MVS_INT_STAT_SRS_0, tmp);
+ } else {
+ w_reg_set_enable(reg_set, mvi->sata_reg_set);
+ tmp = mr32(MVS_INT_STAT_SRS_1) & mvi->sata_reg_set;
+ if (tmp)
+ mw32(MVS_INT_STAT_SRS_1, tmp);
+ }
+
+ *tfs = MVS_ID_NOT_MAPPED;
+
+ return;
+}
+
+static u8 mvs_94xx_assign_reg_set(struct mvs_info *mvi, u8 *tfs)
+{
+ int i;
+ void __iomem *regs = mvi->regs;
+
+ if (*tfs != MVS_ID_NOT_MAPPED)
+ return 0;
+
+ i = mv_ffc64(mvi->sata_reg_set);
+ if (i > 32) {
+ mvi->sata_reg_set |= bit(i);
+ w_reg_set_enable(i, (u32)(mvi->sata_reg_set >> 32));
+ *tfs = i;
+ return 0;
+ } else if (i >= 0) {
+ mvi->sata_reg_set |= bit(i);
+ w_reg_set_enable(i, (u32)mvi->sata_reg_set);
+ *tfs = i;
+ return 0;
+ }
+ return MVS_ID_NOT_MAPPED;
+}
+
+static void mvs_94xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
+{
+ int i;
+ struct scatterlist *sg;
+ struct mvs_prd *buf_prd = prd;
+ for_each_sg(scatter, sg, nr, i) {
+ buf_prd->addr = cpu_to_le64(sg_dma_address(sg));
+ buf_prd->im_len.len = cpu_to_le32(sg_dma_len(sg));
+ buf_prd++;
+ }
+}
+
+static int mvs_94xx_oob_done(struct mvs_info *mvi, int i)
+{
+ u32 phy_st;
+ phy_st = mvs_read_phy_ctl(mvi, i);
+ if (phy_st & PHY_READY_MASK) /* phy ready */
+ return 1;
+ return 0;
+}
+
+static void mvs_94xx_get_dev_identify_frame(struct mvs_info *mvi, int port_id,
+ struct sas_identify_frame *id)
+{
+ int i;
+ u32 id_frame[7];
+
+ for (i = 0; i < 7; i++) {
+ mvs_write_port_cfg_addr(mvi, port_id,
+ CONFIG_ID_FRAME0 + i * 4);
+ id_frame[i] = mvs_read_port_cfg_data(mvi, port_id);
+ }
+ memcpy(id, id_frame, 28);
+}
+
+static void mvs_94xx_get_att_identify_frame(struct mvs_info *mvi, int port_id,
+ struct sas_identify_frame *id)
+{
+ int i;
+ u32 id_frame[7];
+
+ /* mvs_hexdump(28, (u8 *)id_frame, 0); */
+ for (i = 0; i < 7; i++) {
+ mvs_write_port_cfg_addr(mvi, port_id,
+ CONFIG_ATT_ID_FRAME0 + i * 4);
+ id_frame[i] = mvs_read_port_cfg_data(mvi, port_id);
+ mv_dprintk("94xx phy %d atta frame %d %x.\n",
+ port_id + mvi->id * mvi->chip->n_phy, i, id_frame[i]);
+ }
+ /* mvs_hexdump(28, (u8 *)id_frame, 0); */
+ memcpy(id, id_frame, 28);
+}
+
+static u32 mvs_94xx_make_dev_info(struct sas_identify_frame *id)
+{
+ u32 att_dev_info = 0;
+
+ att_dev_info |= id->dev_type;
+ if (id->stp_iport)
+ att_dev_info |= PORT_DEV_STP_INIT;
+ if (id->smp_iport)
+ att_dev_info |= PORT_DEV_SMP_INIT;
+ if (id->ssp_iport)
+ att_dev_info |= PORT_DEV_SSP_INIT;
+ if (id->stp_tport)
+ att_dev_info |= PORT_DEV_STP_TRGT;
+ if (id->smp_tport)
+ att_dev_info |= PORT_DEV_SMP_TRGT;
+ if (id->ssp_tport)
+ att_dev_info |= PORT_DEV_SSP_TRGT;
+
+ att_dev_info |= (u32)id->phy_id<<24;
+ return att_dev_info;
+}
+
+static u32 mvs_94xx_make_att_info(struct sas_identify_frame *id)
+{
+ return mvs_94xx_make_dev_info(id);
+}
+
+static void mvs_94xx_fix_phy_info(struct mvs_info *mvi, int i,
+ struct sas_identify_frame *id)
+{
+ struct mvs_phy *phy = &mvi->phy[i];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+ mv_dprintk("get all reg link rate is 0x%x\n", phy->phy_status);
+ sas_phy->linkrate =
+ (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET;
+ sas_phy->linkrate += 0x8;
+ mv_dprintk("get link rate is %d\n", sas_phy->linkrate);
+ phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
+ phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS;
+ mvs_94xx_get_dev_identify_frame(mvi, i, id);
+ phy->dev_info = mvs_94xx_make_dev_info(id);
+
+ if (phy->phy_type & PORT_TYPE_SAS) {
+ mvs_94xx_get_att_identify_frame(mvi, i, id);
+ phy->att_dev_info = mvs_94xx_make_att_info(id);
+ phy->att_dev_sas_addr = *(u64 *)id->sas_addr;
+ } else {
+ phy->att_dev_info = PORT_DEV_STP_TRGT | 1;
+ }
+
+}
+
+void mvs_94xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
+ struct sas_phy_linkrates *rates)
+{
+ /* TODO */
+}
+
+static void mvs_94xx_clear_active_cmds(struct mvs_info *mvi)
+{
+ u32 tmp;
+ void __iomem *regs = mvi->regs;
+ tmp = mr32(MVS_STP_REG_SET_0);
+ mw32(MVS_STP_REG_SET_0, 0);
+ mw32(MVS_STP_REG_SET_0, tmp);
+ tmp = mr32(MVS_STP_REG_SET_1);
+ mw32(MVS_STP_REG_SET_1, 0);
+ mw32(MVS_STP_REG_SET_1, tmp);
+}
+
+
+u32 mvs_94xx_spi_read_data(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs_ex - 0x10200;
+ return mr32(SPI_RD_DATA_REG_94XX);
+}
+
+void mvs_94xx_spi_write_data(struct mvs_info *mvi, u32 data)
+{
+ void __iomem *regs = mvi->regs_ex - 0x10200;
+ mw32(SPI_RD_DATA_REG_94XX, data);
+}
+
+
+int mvs_94xx_spi_buildcmd(struct mvs_info *mvi,
+ u32 *dwCmd,
+ u8 cmd,
+ u8 read,
+ u8 length,
+ u32 addr
+ )
+{
+ void __iomem *regs = mvi->regs_ex - 0x10200;
+ u32 dwTmp;
+
+ dwTmp = ((u32)cmd << 8) | ((u32)length << 4);
+ if (read)
+ dwTmp |= SPI_CTRL_READ_94XX;
+
+ if (addr != MV_MAX_U32) {
+ mw32(SPI_ADDR_REG_94XX, (addr & 0x0003FFFFL));
+ dwTmp |= SPI_ADDR_VLD_94XX;
+ }
+
+ *dwCmd = dwTmp;
+ return 0;
+}
+
+
+int mvs_94xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
+{
+ void __iomem *regs = mvi->regs_ex - 0x10200;
+ mw32(SPI_CTRL_REG_94XX, cmd | SPI_CTRL_SpiStart_94XX);
+
+ return 0;
+}
+
+int mvs_94xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
+{
+ void __iomem *regs = mvi->regs_ex - 0x10200;
+ u32 i, dwTmp;
+
+ for (i = 0; i < timeout; i++) {
+ dwTmp = mr32(SPI_CTRL_REG_94XX);
+ if (!(dwTmp & SPI_CTRL_SpiStart_94XX))
+ return 0;
+ msleep(10);
+ }
+
+ return -1;
+}
+
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+void mvs_94xx_fix_dma(dma_addr_t buf_dma, int buf_len, int from, void *prd)
+{
+ int i;
+ struct mvs_prd *buf_prd = prd;
+ buf_prd += from;
+ for (i = 0; i < MAX_SG_ENTRY - from; i++) {
+ buf_prd->addr = cpu_to_le64(buf_dma);
+ buf_prd->im_len.len = cpu_to_le32(buf_len);
+ ++buf_prd;
+ }
+}
+#endif
+
+const struct mvs_dispatch mvs_94xx_dispatch = {
+ "mv94xx",
+ mvs_94xx_init,
+ NULL,
+ mvs_94xx_ioremap,
+ mvs_94xx_iounmap,
+ mvs_94xx_isr,
+ mvs_94xx_isr_status,
+ mvs_94xx_interrupt_enable,
+ mvs_94xx_interrupt_disable,
+ mvs_read_phy_ctl,
+ mvs_write_phy_ctl,
+ mvs_read_port_cfg_data,
+ mvs_write_port_cfg_data,
+ mvs_write_port_cfg_addr,
+ mvs_read_port_vsr_data,
+ mvs_write_port_vsr_data,
+ mvs_write_port_vsr_addr,
+ mvs_read_port_irq_stat,
+ mvs_write_port_irq_stat,
+ mvs_read_port_irq_mask,
+ mvs_write_port_irq_mask,
+ mvs_get_sas_addr,
+ mvs_94xx_command_active,
+ mvs_94xx_issue_stop,
+ mvs_start_delivery,
+ mvs_rx_update,
+ mvs_int_full,
+ mvs_94xx_assign_reg_set,
+ mvs_94xx_free_reg_set,
+ mvs_get_prd_size,
+ mvs_get_prd_count,
+ mvs_94xx_make_prd,
+ mvs_94xx_detect_porttype,
+ mvs_94xx_oob_done,
+ mvs_94xx_fix_phy_info,
+ NULL,
+ mvs_94xx_phy_set_link_rate,
+ mvs_hw_max_link_rate,
+ mvs_94xx_phy_disable,
+ mvs_94xx_phy_enable,
+ mvs_94xx_phy_reset,
+ NULL,
+ mvs_94xx_clear_active_cmds,
+ mvs_94xx_spi_read_data,
+ mvs_94xx_spi_write_data,
+ mvs_94xx_spi_buildcmd,
+ mvs_94xx_spi_issuecmd,
+ mvs_94xx_spi_waitdataready,
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ mvs_94xx_fix_dma,
+#endif
+};
+
diff --git a/drivers/scsi/mvsas/mv_94xx.h b/drivers/scsi/mvsas/mv_94xx.h
new file mode 100644
index 000000000000..23ed9b164669
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_94xx.h
@@ -0,0 +1,222 @@
+/*
+ * Marvell 88SE94xx hardware specific head file
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#ifndef _MVS94XX_REG_H_
+#define _MVS94XX_REG_H_
+
+#include <linux/types.h>
+
+#define MAX_LINK_RATE SAS_LINK_RATE_6_0_GBPS
+
+enum hw_registers {
+ MVS_GBL_CTL = 0x04, /* global control */
+ MVS_GBL_INT_STAT = 0x00, /* global irq status */
+ MVS_GBL_PI = 0x0C, /* ports implemented bitmask */
+
+ MVS_PHY_CTL = 0x40, /* SOC PHY Control */
+ MVS_PORTS_IMP = 0x9C, /* SOC Port Implemented */
+
+ MVS_GBL_PORT_TYPE = 0xa0, /* port type */
+
+ MVS_CTL = 0x100, /* SAS/SATA port configuration */
+ MVS_PCS = 0x104, /* SAS/SATA port control/status */
+ MVS_CMD_LIST_LO = 0x108, /* cmd list addr */
+ MVS_CMD_LIST_HI = 0x10C,
+ MVS_RX_FIS_LO = 0x110, /* RX FIS list addr */
+ MVS_RX_FIS_HI = 0x114,
+ MVS_STP_REG_SET_0 = 0x118, /* STP/SATA Register Set Enable */
+ MVS_STP_REG_SET_1 = 0x11C,
+ MVS_TX_CFG = 0x120, /* TX configuration */
+ MVS_TX_LO = 0x124, /* TX (delivery) ring addr */
+ MVS_TX_HI = 0x128,
+
+ MVS_TX_PROD_IDX = 0x12C, /* TX producer pointer */
+ MVS_TX_CONS_IDX = 0x130, /* TX consumer pointer (RO) */
+ MVS_RX_CFG = 0x134, /* RX configuration */
+ MVS_RX_LO = 0x138, /* RX (completion) ring addr */
+ MVS_RX_HI = 0x13C,
+ MVS_RX_CONS_IDX = 0x140, /* RX consumer pointer (RO) */
+
+ MVS_INT_COAL = 0x148, /* Int coalescing config */
+ MVS_INT_COAL_TMOUT = 0x14C, /* Int coalescing timeout */
+ MVS_INT_STAT = 0x150, /* Central int status */
+ MVS_INT_MASK = 0x154, /* Central int enable */
+ MVS_INT_STAT_SRS_0 = 0x158, /* SATA register set status */
+ MVS_INT_MASK_SRS_0 = 0x15C,
+ MVS_INT_STAT_SRS_1 = 0x160,
+ MVS_INT_MASK_SRS_1 = 0x164,
+ MVS_NON_NCQ_ERR_0 = 0x168, /* SRS Non-specific NCQ Error */
+ MVS_NON_NCQ_ERR_1 = 0x16C,
+ MVS_CMD_ADDR = 0x170, /* Command register port (addr) */
+ MVS_CMD_DATA = 0x174, /* Command register port (data) */
+ MVS_MEM_PARITY_ERR = 0x178, /* Memory parity error */
+
+ /* ports 1-3 follow after this */
+ MVS_P0_INT_STAT = 0x180, /* port0 interrupt status */
+ MVS_P0_INT_MASK = 0x184, /* port0 interrupt mask */
+ /* ports 5-7 follow after this */
+ MVS_P4_INT_STAT = 0x1A0, /* Port4 interrupt status */
+ MVS_P4_INT_MASK = 0x1A4, /* Port4 interrupt enable mask */
+
+ /* ports 1-3 follow after this */
+ MVS_P0_SER_CTLSTAT = 0x1D0, /* port0 serial control/status */
+ /* ports 5-7 follow after this */
+ MVS_P4_SER_CTLSTAT = 0x1E0, /* port4 serial control/status */
+
+ /* ports 1-3 follow after this */
+ MVS_P0_CFG_ADDR = 0x200, /* port0 phy register address */
+ MVS_P0_CFG_DATA = 0x204, /* port0 phy register data */
+ /* ports 5-7 follow after this */
+ MVS_P4_CFG_ADDR = 0x220, /* Port4 config address */
+ MVS_P4_CFG_DATA = 0x224, /* Port4 config data */
+
+ /* phys 1-3 follow after this */
+ MVS_P0_VSR_ADDR = 0x250, /* phy0 VSR address */
+ MVS_P0_VSR_DATA = 0x254, /* phy0 VSR data */
+ /* phys 1-3 follow after this */
+ /* multiplexing */
+ MVS_P4_VSR_ADDR = 0x250, /* phy4 VSR address */
+ MVS_P4_VSR_DATA = 0x254, /* phy4 VSR data */
+ MVS_PA_VSR_ADDR = 0x290, /* All port VSR addr */
+ MVS_PA_VSR_PORT = 0x294, /* All port VSR data */
+};
+
+enum pci_cfg_registers {
+ PCR_PHY_CTL = 0x40,
+ PCR_PHY_CTL2 = 0x90,
+ PCR_DEV_CTRL = 0x78,
+ PCR_LINK_STAT = 0x82,
+};
+
+/* SAS/SATA Vendor Specific Port Registers */
+enum sas_sata_vsp_regs {
+ VSR_PHY_STAT = 0x00 * 4, /* Phy Status */
+ VSR_PHY_MODE1 = 0x01 * 4, /* phy tx */
+ VSR_PHY_MODE2 = 0x02 * 4, /* tx scc */
+ VSR_PHY_MODE3 = 0x03 * 4, /* pll */
+ VSR_PHY_MODE4 = 0x04 * 4, /* VCO */
+ VSR_PHY_MODE5 = 0x05 * 4, /* Rx */
+ VSR_PHY_MODE6 = 0x06 * 4, /* CDR */
+ VSR_PHY_MODE7 = 0x07 * 4, /* Impedance */
+ VSR_PHY_MODE8 = 0x08 * 4, /* Voltage */
+ VSR_PHY_MODE9 = 0x09 * 4, /* Test */
+ VSR_PHY_MODE10 = 0x0A * 4, /* Power */
+ VSR_PHY_MODE11 = 0x0B * 4, /* Phy Mode */
+ VSR_PHY_VS0 = 0x0C * 4, /* Vednor Specific 0 */
+ VSR_PHY_VS1 = 0x0D * 4, /* Vednor Specific 1 */
+};
+
+enum chip_register_bits {
+ PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0x7 << 8),
+ PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0x7 << 8),
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (12),
+ PHY_NEG_SPP_PHYS_LINK_RATE_MASK =
+ (0x3 << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET),
+};
+
+enum pci_interrupt_cause {
+ /* MAIN_IRQ_CAUSE (R10200) Bits*/
+ IRQ_COM_IN_I2O_IOP0 = (1 << 0),
+ IRQ_COM_IN_I2O_IOP1 = (1 << 1),
+ IRQ_COM_IN_I2O_IOP2 = (1 << 2),
+ IRQ_COM_IN_I2O_IOP3 = (1 << 3),
+ IRQ_COM_OUT_I2O_HOS0 = (1 << 4),
+ IRQ_COM_OUT_I2O_HOS1 = (1 << 5),
+ IRQ_COM_OUT_I2O_HOS2 = (1 << 6),
+ IRQ_COM_OUT_I2O_HOS3 = (1 << 7),
+ IRQ_PCIF_TO_CPU_DRBL0 = (1 << 8),
+ IRQ_PCIF_TO_CPU_DRBL1 = (1 << 9),
+ IRQ_PCIF_TO_CPU_DRBL2 = (1 << 10),
+ IRQ_PCIF_TO_CPU_DRBL3 = (1 << 11),
+ IRQ_PCIF_DRBL0 = (1 << 12),
+ IRQ_PCIF_DRBL1 = (1 << 13),
+ IRQ_PCIF_DRBL2 = (1 << 14),
+ IRQ_PCIF_DRBL3 = (1 << 15),
+ IRQ_XOR_A = (1 << 16),
+ IRQ_XOR_B = (1 << 17),
+ IRQ_SAS_A = (1 << 18),
+ IRQ_SAS_B = (1 << 19),
+ IRQ_CPU_CNTRL = (1 << 20),
+ IRQ_GPIO = (1 << 21),
+ IRQ_UART = (1 << 22),
+ IRQ_SPI = (1 << 23),
+ IRQ_I2C = (1 << 24),
+ IRQ_SGPIO = (1 << 25),
+ IRQ_COM_ERR = (1 << 29),
+ IRQ_I2O_ERR = (1 << 30),
+ IRQ_PCIE_ERR = (1 << 31),
+};
+
+#define MAX_SG_ENTRY 255
+
+struct mvs_prd_imt {
+ __le32 len:22;
+ u8 _r_a:2;
+ u8 misc_ctl:4;
+ u8 inter_sel:4;
+};
+
+struct mvs_prd {
+ /* 64-bit buffer address */
+ __le64 addr;
+ /* 22-bit length */
+ struct mvs_prd_imt im_len;
+} __attribute__ ((packed));
+
+#define SPI_CTRL_REG_94XX 0xc800
+#define SPI_ADDR_REG_94XX 0xc804
+#define SPI_WR_DATA_REG_94XX 0xc808
+#define SPI_RD_DATA_REG_94XX 0xc80c
+#define SPI_CTRL_READ_94XX (1U << 2)
+#define SPI_ADDR_VLD_94XX (1U << 1)
+#define SPI_CTRL_SpiStart_94XX (1U << 0)
+
+#define mv_ffc(x) ffz(x)
+
+static inline int
+mv_ffc64(u64 v)
+{
+ int i;
+ i = mv_ffc((u32)v);
+ if (i >= 0)
+ return i;
+ i = mv_ffc((u32)(v>>32));
+
+ if (i != 0)
+ return 32 + i;
+
+ return -1;
+}
+
+#define r_reg_set_enable(i) \
+ (((i) > 31) ? mr32(MVS_STP_REG_SET_1) : \
+ mr32(MVS_STP_REG_SET_0))
+
+#define w_reg_set_enable(i, tmp) \
+ (((i) > 31) ? mw32(MVS_STP_REG_SET_1, tmp) : \
+ mw32(MVS_STP_REG_SET_0, tmp))
+
+extern const struct mvs_dispatch mvs_94xx_dispatch;
+#endif
+
diff --git a/drivers/scsi/mvsas/mv_chips.h b/drivers/scsi/mvsas/mv_chips.h
new file mode 100644
index 000000000000..a67e1c4172f9
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_chips.h
@@ -0,0 +1,280 @@
+/*
+ * Marvell 88SE64xx/88SE94xx register IO interface
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+
+#ifndef _MV_CHIPS_H_
+#define _MV_CHIPS_H_
+
+#define mr32(reg) readl(regs + reg)
+#define mw32(reg, val) writel((val), regs + reg)
+#define mw32_f(reg, val) do { \
+ mw32(reg, val); \
+ mr32(reg); \
+ } while (0)
+
+#define iow32(reg, val) outl(val, (unsigned long)(regs + reg))
+#define ior32(reg) inl((unsigned long)(regs + reg))
+#define iow16(reg, val) outw((unsigned long)(val, regs + reg))
+#define ior16(reg) inw((unsigned long)(regs + reg))
+#define iow8(reg, val) outb((unsigned long)(val, regs + reg))
+#define ior8(reg) inb((unsigned long)(regs + reg))
+
+static inline u32 mvs_cr32(struct mvs_info *mvi, u32 addr)
+{
+ void __iomem *regs = mvi->regs;
+ mw32(MVS_CMD_ADDR, addr);
+ return mr32(MVS_CMD_DATA);
+}
+
+static inline void mvs_cw32(struct mvs_info *mvi, u32 addr, u32 val)
+{
+ void __iomem *regs = mvi->regs;
+ mw32(MVS_CMD_ADDR, addr);
+ mw32(MVS_CMD_DATA, val);
+}
+
+static inline u32 mvs_read_phy_ctl(struct mvs_info *mvi, u32 port)
+{
+ void __iomem *regs = mvi->regs;
+ return (port < 4) ? mr32(MVS_P0_SER_CTLSTAT + port * 4) :
+ mr32(MVS_P4_SER_CTLSTAT + (port - 4) * 4);
+}
+
+static inline void mvs_write_phy_ctl(struct mvs_info *mvi, u32 port, u32 val)
+{
+ void __iomem *regs = mvi->regs;
+ if (port < 4)
+ mw32(MVS_P0_SER_CTLSTAT + port * 4, val);
+ else
+ mw32(MVS_P4_SER_CTLSTAT + (port - 4) * 4, val);
+}
+
+static inline u32 mvs_read_port(struct mvs_info *mvi, u32 off,
+ u32 off2, u32 port)
+{
+ void __iomem *regs = mvi->regs + off;
+ void __iomem *regs2 = mvi->regs + off2;
+ return (port < 4) ? readl(regs + port * 8) :
+ readl(regs2 + (port - 4) * 8);
+}
+
+static inline void mvs_write_port(struct mvs_info *mvi, u32 off, u32 off2,
+ u32 port, u32 val)
+{
+ void __iomem *regs = mvi->regs + off;
+ void __iomem *regs2 = mvi->regs + off2;
+ if (port < 4)
+ writel(val, regs + port * 8);
+ else
+ writel(val, regs2 + (port - 4) * 8);
+}
+
+static inline u32 mvs_read_port_cfg_data(struct mvs_info *mvi, u32 port)
+{
+ return mvs_read_port(mvi, MVS_P0_CFG_DATA,
+ MVS_P4_CFG_DATA, port);
+}
+
+static inline void mvs_write_port_cfg_data(struct mvs_info *mvi,
+ u32 port, u32 val)
+{
+ mvs_write_port(mvi, MVS_P0_CFG_DATA,
+ MVS_P4_CFG_DATA, port, val);
+}
+
+static inline void mvs_write_port_cfg_addr(struct mvs_info *mvi,
+ u32 port, u32 addr)
+{
+ mvs_write_port(mvi, MVS_P0_CFG_ADDR,
+ MVS_P4_CFG_ADDR, port, addr);
+ mdelay(10);
+}
+
+static inline u32 mvs_read_port_vsr_data(struct mvs_info *mvi, u32 port)
+{
+ return mvs_read_port(mvi, MVS_P0_VSR_DATA,
+ MVS_P4_VSR_DATA, port);
+}
+
+static inline void mvs_write_port_vsr_data(struct mvs_info *mvi,
+ u32 port, u32 val)
+{
+ mvs_write_port(mvi, MVS_P0_VSR_DATA,
+ MVS_P4_VSR_DATA, port, val);
+}
+
+static inline void mvs_write_port_vsr_addr(struct mvs_info *mvi,
+ u32 port, u32 addr)
+{
+ mvs_write_port(mvi, MVS_P0_VSR_ADDR,
+ MVS_P4_VSR_ADDR, port, addr);
+ mdelay(10);
+}
+
+static inline u32 mvs_read_port_irq_stat(struct mvs_info *mvi, u32 port)
+{
+ return mvs_read_port(mvi, MVS_P0_INT_STAT,
+ MVS_P4_INT_STAT, port);
+}
+
+static inline void mvs_write_port_irq_stat(struct mvs_info *mvi,
+ u32 port, u32 val)
+{
+ mvs_write_port(mvi, MVS_P0_INT_STAT,
+ MVS_P4_INT_STAT, port, val);
+}
+
+static inline u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port)
+{
+ return mvs_read_port(mvi, MVS_P0_INT_MASK,
+ MVS_P4_INT_MASK, port);
+
+}
+
+static inline void mvs_write_port_irq_mask(struct mvs_info *mvi,
+ u32 port, u32 val)
+{
+ mvs_write_port(mvi, MVS_P0_INT_MASK,
+ MVS_P4_INT_MASK, port, val);
+}
+
+static inline void __devinit mvs_phy_hacks(struct mvs_info *mvi)
+{
+ u32 tmp;
+
+ /* workaround for SATA R-ERR, to ignore phy glitch */
+ tmp = mvs_cr32(mvi, CMD_PHY_TIMER);
+ tmp &= ~(1 << 9);
+ tmp |= (1 << 10);
+ mvs_cw32(mvi, CMD_PHY_TIMER, tmp);
+
+ /* enable retry 127 times */
+ mvs_cw32(mvi, CMD_SAS_CTL1, 0x7f7f);
+
+ /* extend open frame timeout to max */
+ tmp = mvs_cr32(mvi, CMD_SAS_CTL0);
+ tmp &= ~0xffff;
+ tmp |= 0x3fff;
+ mvs_cw32(mvi, CMD_SAS_CTL0, tmp);
+
+ /* workaround for WDTIMEOUT , set to 550 ms */
+ mvs_cw32(mvi, CMD_WD_TIMER, 0x7a0000);
+
+ /* not to halt for different port op during wideport link change */
+ mvs_cw32(mvi, CMD_APP_ERR_CONFIG, 0xffefbf7d);
+
+ /* workaround for Seagate disk not-found OOB sequence, recv
+ * COMINIT before sending out COMWAKE */
+ tmp = mvs_cr32(mvi, CMD_PHY_MODE_21);
+ tmp &= 0x0000ffff;
+ tmp |= 0x00fa0000;
+ mvs_cw32(mvi, CMD_PHY_MODE_21, tmp);
+
+ tmp = mvs_cr32(mvi, CMD_PHY_TIMER);
+ tmp &= 0x1fffffff;
+ tmp |= (2U << 29); /* 8 ms retry */
+ mvs_cw32(mvi, CMD_PHY_TIMER, tmp);
+}
+
+static inline void mvs_int_sata(struct mvs_info *mvi)
+{
+ u32 tmp;
+ void __iomem *regs = mvi->regs;
+ tmp = mr32(MVS_INT_STAT_SRS_0);
+ if (tmp)
+ mw32(MVS_INT_STAT_SRS_0, tmp);
+ MVS_CHIP_DISP->clear_active_cmds(mvi);
+}
+
+static inline void mvs_int_full(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ u32 tmp, stat;
+ int i;
+
+ stat = mr32(MVS_INT_STAT);
+ mvs_int_rx(mvi, false);
+
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ tmp = (stat >> i) & (CINT_PORT | CINT_PORT_STOPPED);
+ if (tmp)
+ mvs_int_port(mvi, i, tmp);
+ }
+
+ if (stat & CINT_SRS)
+ mvs_int_sata(mvi);
+
+ mw32(MVS_INT_STAT, stat);
+}
+
+static inline void mvs_start_delivery(struct mvs_info *mvi, u32 tx)
+{
+ void __iomem *regs = mvi->regs;
+ mw32(MVS_TX_PROD_IDX, tx);
+}
+
+static inline u32 mvs_rx_update(struct mvs_info *mvi)
+{
+ void __iomem *regs = mvi->regs;
+ return mr32(MVS_RX_CONS_IDX);
+}
+
+static inline u32 mvs_get_prd_size(void)
+{
+ return sizeof(struct mvs_prd);
+}
+
+static inline u32 mvs_get_prd_count(void)
+{
+ return MAX_SG_ENTRY;
+}
+
+static inline void mvs_show_pcie_usage(struct mvs_info *mvi)
+{
+ u16 link_stat, link_spd;
+ const char *spd[] = {
+ "UnKnown",
+ "2.5",
+ "5.0",
+ };
+ if (mvi->flags & MVF_FLAG_SOC || mvi->id > 0)
+ return;
+
+ pci_read_config_word(mvi->pdev, PCR_LINK_STAT, &link_stat);
+ link_spd = (link_stat & PLS_LINK_SPD) >> PLS_LINK_SPD_OFFS;
+ if (link_spd >= 3)
+ link_spd = 0;
+ dev_printk(KERN_INFO, mvi->dev,
+ "mvsas: PCI-E x%u, Bandwidth Usage: %s Gbps\n",
+ (link_stat & PLS_NEG_LINK_WD) >> PLS_NEG_LINK_WD_OFFS,
+ spd[link_spd]);
+}
+
+static inline u32 mvs_hw_max_link_rate(void)
+{
+ return MAX_LINK_RATE;
+}
+
+#endif /* _MV_CHIPS_H_ */
+
diff --git a/drivers/scsi/mvsas/mv_defs.h b/drivers/scsi/mvsas/mv_defs.h
new file mode 100644
index 000000000000..f8cb9defb961
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_defs.h
@@ -0,0 +1,502 @@
+/*
+ * Marvell 88SE64xx/88SE94xx const head file
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#ifndef _MV_DEFS_H_
+#define _MV_DEFS_H_
+
+
+enum chip_flavors {
+ chip_6320,
+ chip_6440,
+ chip_6485,
+ chip_9480,
+ chip_9180,
+};
+
+/* driver compile-time configuration */
+enum driver_configuration {
+ MVS_SLOTS = 512, /* command slots */
+ MVS_TX_RING_SZ = 1024, /* TX ring size (12-bit) */
+ MVS_RX_RING_SZ = 1024, /* RX ring size (12-bit) */
+ /* software requires power-of-2
+ ring size */
+ MVS_SOC_SLOTS = 64,
+ MVS_SOC_TX_RING_SZ = MVS_SOC_SLOTS * 2,
+ MVS_SOC_RX_RING_SZ = MVS_SOC_SLOTS * 2,
+
+ MVS_SLOT_BUF_SZ = 8192, /* cmd tbl + IU + status + PRD */
+ MVS_SSP_CMD_SZ = 64, /* SSP command table buffer size */
+ MVS_ATA_CMD_SZ = 96, /* SATA command table buffer size */
+ MVS_OAF_SZ = 64, /* Open address frame buffer size */
+ MVS_QUEUE_SIZE = 32, /* Support Queue depth */
+ MVS_CAN_QUEUE = MVS_SLOTS - 2, /* SCSI Queue depth */
+ MVS_SOC_CAN_QUEUE = MVS_SOC_SLOTS - 2,
+};
+
+/* unchangeable hardware details */
+enum hardware_details {
+ MVS_MAX_PHYS = 8, /* max. possible phys */
+ MVS_MAX_PORTS = 8, /* max. possible ports */
+ MVS_SOC_PHYS = 4, /* soc phys */
+ MVS_SOC_PORTS = 4, /* soc phys */
+ MVS_MAX_DEVICES = 1024, /* max supported device */
+};
+
+/* peripheral registers (BAR2) */
+enum peripheral_registers {
+ SPI_CTL = 0x10, /* EEPROM control */
+ SPI_CMD = 0x14, /* EEPROM command */
+ SPI_DATA = 0x18, /* EEPROM data */
+};
+
+enum peripheral_register_bits {
+ TWSI_RDY = (1U << 7), /* EEPROM interface ready */
+ TWSI_RD = (1U << 4), /* EEPROM read access */
+
+ SPI_ADDR_MASK = 0x3ffff, /* bits 17:0 */
+};
+
+enum hw_register_bits {
+ /* MVS_GBL_CTL */
+ INT_EN = (1U << 1), /* Global int enable */
+ HBA_RST = (1U << 0), /* HBA reset */
+
+ /* MVS_GBL_INT_STAT */
+ INT_XOR = (1U << 4), /* XOR engine event */
+ INT_SAS_SATA = (1U << 0), /* SAS/SATA event */
+
+ /* MVS_GBL_PORT_TYPE */ /* shl for ports 1-3 */
+ SATA_TARGET = (1U << 16), /* port0 SATA target enable */
+ MODE_AUTO_DET_PORT7 = (1U << 15), /* port0 SAS/SATA autodetect */
+ MODE_AUTO_DET_PORT6 = (1U << 14),
+ MODE_AUTO_DET_PORT5 = (1U << 13),
+ MODE_AUTO_DET_PORT4 = (1U << 12),
+ MODE_AUTO_DET_PORT3 = (1U << 11),
+ MODE_AUTO_DET_PORT2 = (1U << 10),
+ MODE_AUTO_DET_PORT1 = (1U << 9),
+ MODE_AUTO_DET_PORT0 = (1U << 8),
+ MODE_AUTO_DET_EN = MODE_AUTO_DET_PORT0 | MODE_AUTO_DET_PORT1 |
+ MODE_AUTO_DET_PORT2 | MODE_AUTO_DET_PORT3 |
+ MODE_AUTO_DET_PORT4 | MODE_AUTO_DET_PORT5 |
+ MODE_AUTO_DET_PORT6 | MODE_AUTO_DET_PORT7,
+ MODE_SAS_PORT7_MASK = (1U << 7), /* port0 SAS(1), SATA(0) mode */
+ MODE_SAS_PORT6_MASK = (1U << 6),
+ MODE_SAS_PORT5_MASK = (1U << 5),
+ MODE_SAS_PORT4_MASK = (1U << 4),
+ MODE_SAS_PORT3_MASK = (1U << 3),
+ MODE_SAS_PORT2_MASK = (1U << 2),
+ MODE_SAS_PORT1_MASK = (1U << 1),
+ MODE_SAS_PORT0_MASK = (1U << 0),
+ MODE_SAS_SATA = MODE_SAS_PORT0_MASK | MODE_SAS_PORT1_MASK |
+ MODE_SAS_PORT2_MASK | MODE_SAS_PORT3_MASK |
+ MODE_SAS_PORT4_MASK | MODE_SAS_PORT5_MASK |
+ MODE_SAS_PORT6_MASK | MODE_SAS_PORT7_MASK,
+
+ /* SAS_MODE value may be
+ * dictated (in hw) by values
+ * of SATA_TARGET & AUTO_DET
+ */
+
+ /* MVS_TX_CFG */
+ TX_EN = (1U << 16), /* Enable TX */
+ TX_RING_SZ_MASK = 0xfff, /* TX ring size, bits 11:0 */
+
+ /* MVS_RX_CFG */
+ RX_EN = (1U << 16), /* Enable RX */
+ RX_RING_SZ_MASK = 0xfff, /* RX ring size, bits 11:0 */
+
+ /* MVS_INT_COAL */
+ COAL_EN = (1U << 16), /* Enable int coalescing */
+
+ /* MVS_INT_STAT, MVS_INT_MASK */
+ CINT_I2C = (1U << 31), /* I2C event */
+ CINT_SW0 = (1U << 30), /* software event 0 */
+ CINT_SW1 = (1U << 29), /* software event 1 */
+ CINT_PRD_BC = (1U << 28), /* PRD BC err for read cmd */
+ CINT_DMA_PCIE = (1U << 27), /* DMA to PCIE timeout */
+ CINT_MEM = (1U << 26), /* int mem parity err */
+ CINT_I2C_SLAVE = (1U << 25), /* slave I2C event */
+ CINT_SRS = (1U << 3), /* SRS event */
+ CINT_CI_STOP = (1U << 1), /* cmd issue stopped */
+ CINT_DONE = (1U << 0), /* cmd completion */
+
+ /* shl for ports 1-3 */
+ CINT_PORT_STOPPED = (1U << 16), /* port0 stopped */
+ CINT_PORT = (1U << 8), /* port0 event */
+ CINT_PORT_MASK_OFFSET = 8,
+ CINT_PORT_MASK = (0xFF << CINT_PORT_MASK_OFFSET),
+ CINT_PHY_MASK_OFFSET = 4,
+ CINT_PHY_MASK = (0x0F << CINT_PHY_MASK_OFFSET),
+
+ /* TX (delivery) ring bits */
+ TXQ_CMD_SHIFT = 29,
+ TXQ_CMD_SSP = 1, /* SSP protocol */
+ TXQ_CMD_SMP = 2, /* SMP protocol */
+ TXQ_CMD_STP = 3, /* STP/SATA protocol */
+ TXQ_CMD_SSP_FREE_LIST = 4, /* add to SSP targ free list */
+ TXQ_CMD_SLOT_RESET = 7, /* reset command slot */
+ TXQ_MODE_I = (1U << 28), /* mode: 0=target,1=initiator */
+ TXQ_MODE_TARGET = 0,
+ TXQ_MODE_INITIATOR = 1,
+ TXQ_PRIO_HI = (1U << 27), /* priority: 0=normal, 1=high */
+ TXQ_PRI_NORMAL = 0,
+ TXQ_PRI_HIGH = 1,
+ TXQ_SRS_SHIFT = 20, /* SATA register set */
+ TXQ_SRS_MASK = 0x7f,
+ TXQ_PHY_SHIFT = 12, /* PHY bitmap */
+ TXQ_PHY_MASK = 0xff,
+ TXQ_SLOT_MASK = 0xfff, /* slot number */
+
+ /* RX (completion) ring bits */
+ RXQ_GOOD = (1U << 23), /* Response good */
+ RXQ_SLOT_RESET = (1U << 21), /* Slot reset complete */
+ RXQ_CMD_RX = (1U << 20), /* target cmd received */
+ RXQ_ATTN = (1U << 19), /* attention */
+ RXQ_RSP = (1U << 18), /* response frame xfer'd */
+ RXQ_ERR = (1U << 17), /* err info rec xfer'd */
+ RXQ_DONE = (1U << 16), /* cmd complete */
+ RXQ_SLOT_MASK = 0xfff, /* slot number */
+
+ /* mvs_cmd_hdr bits */
+ MCH_PRD_LEN_SHIFT = 16, /* 16-bit PRD table len */
+ MCH_SSP_FR_TYPE_SHIFT = 13, /* SSP frame type */
+
+ /* SSP initiator only */
+ MCH_SSP_FR_CMD = 0x0, /* COMMAND frame */
+
+ /* SSP initiator or target */
+ MCH_SSP_FR_TASK = 0x1, /* TASK frame */
+
+ /* SSP target only */
+ MCH_SSP_FR_XFER_RDY = 0x4, /* XFER_RDY frame */
+ MCH_SSP_FR_RESP = 0x5, /* RESPONSE frame */
+ MCH_SSP_FR_READ = 0x6, /* Read DATA frame(s) */
+ MCH_SSP_FR_READ_RESP = 0x7, /* ditto, plus RESPONSE */
+
+ MCH_SSP_MODE_PASSTHRU = 1,
+ MCH_SSP_MODE_NORMAL = 0,
+ MCH_PASSTHRU = (1U << 12), /* pass-through (SSP) */
+ MCH_FBURST = (1U << 11), /* first burst (SSP) */
+ MCH_CHK_LEN = (1U << 10), /* chk xfer len (SSP) */
+ MCH_RETRY = (1U << 9), /* tport layer retry (SSP) */
+ MCH_PROTECTION = (1U << 8), /* protection info rec (SSP) */
+ MCH_RESET = (1U << 7), /* Reset (STP/SATA) */
+ MCH_FPDMA = (1U << 6), /* First party DMA (STP/SATA) */
+ MCH_ATAPI = (1U << 5), /* ATAPI (STP/SATA) */
+ MCH_BIST = (1U << 4), /* BIST activate (STP/SATA) */
+ MCH_PMP_MASK = 0xf, /* PMP from cmd FIS (STP/SATA)*/
+
+ CCTL_RST = (1U << 5), /* port logic reset */
+
+ /* 0(LSB first), 1(MSB first) */
+ CCTL_ENDIAN_DATA = (1U << 3), /* PRD data */
+ CCTL_ENDIAN_RSP = (1U << 2), /* response frame */
+ CCTL_ENDIAN_OPEN = (1U << 1), /* open address frame */
+ CCTL_ENDIAN_CMD = (1U << 0), /* command table */
+
+ /* MVS_Px_SER_CTLSTAT (per-phy control) */
+ PHY_SSP_RST = (1U << 3), /* reset SSP link layer */
+ PHY_BCAST_CHG = (1U << 2), /* broadcast(change) notif */
+ PHY_RST_HARD = (1U << 1), /* hard reset + phy reset */
+ PHY_RST = (1U << 0), /* phy reset */
+ PHY_READY_MASK = (1U << 20),
+
+ /* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */
+ PHYEV_DEC_ERR = (1U << 24), /* Phy Decoding Error */
+ PHYEV_DCDR_ERR = (1U << 23), /* STP Deocder Error */
+ PHYEV_CRC_ERR = (1U << 22), /* STP CRC Error */
+ PHYEV_UNASSOC_FIS = (1U << 19), /* unassociated FIS rx'd */
+ PHYEV_AN = (1U << 18), /* SATA async notification */
+ PHYEV_BIST_ACT = (1U << 17), /* BIST activate FIS */
+ PHYEV_SIG_FIS = (1U << 16), /* signature FIS */
+ PHYEV_POOF = (1U << 12), /* phy ready from 1 -> 0 */
+ PHYEV_IU_BIG = (1U << 11), /* IU too long err */
+ PHYEV_IU_SMALL = (1U << 10), /* IU too short err */
+ PHYEV_UNK_TAG = (1U << 9), /* unknown tag */
+ PHYEV_BROAD_CH = (1U << 8), /* broadcast(CHANGE) */
+ PHYEV_COMWAKE = (1U << 7), /* COMWAKE rx'd */
+ PHYEV_PORT_SEL = (1U << 6), /* port selector present */
+ PHYEV_HARD_RST = (1U << 5), /* hard reset rx'd */
+ PHYEV_ID_TMOUT = (1U << 4), /* identify timeout */
+ PHYEV_ID_FAIL = (1U << 3), /* identify failed */
+ PHYEV_ID_DONE = (1U << 2), /* identify done */
+ PHYEV_HARD_RST_DONE = (1U << 1), /* hard reset done */
+ PHYEV_RDY_CH = (1U << 0), /* phy ready changed state */
+
+ /* MVS_PCS */
+ PCS_EN_SATA_REG_SHIFT = (16), /* Enable SATA Register Set */
+ PCS_EN_PORT_XMT_SHIFT = (12), /* Enable Port Transmit */
+ PCS_EN_PORT_XMT_SHIFT2 = (8), /* For 6485 */
+ PCS_SATA_RETRY = (1U << 8), /* retry ctl FIS on R_ERR */
+ PCS_RSP_RX_EN = (1U << 7), /* raw response rx */
+ PCS_SATA_RETRY_2 = (1U << 6), /* For 9180 */
+ PCS_SELF_CLEAR = (1U << 5), /* self-clearing int mode */
+ PCS_FIS_RX_EN = (1U << 4), /* FIS rx enable */
+ PCS_CMD_STOP_ERR = (1U << 3), /* cmd stop-on-err enable */
+ PCS_CMD_RST = (1U << 1), /* reset cmd issue */
+ PCS_CMD_EN = (1U << 0), /* enable cmd issue */
+
+ /* Port n Attached Device Info */
+ PORT_DEV_SSP_TRGT = (1U << 19),
+ PORT_DEV_SMP_TRGT = (1U << 18),
+ PORT_DEV_STP_TRGT = (1U << 17),
+ PORT_DEV_SSP_INIT = (1U << 11),
+ PORT_DEV_SMP_INIT = (1U << 10),
+ PORT_DEV_STP_INIT = (1U << 9),
+ PORT_PHY_ID_MASK = (0xFFU << 24),
+ PORT_SSP_TRGT_MASK = (0x1U << 19),
+ PORT_SSP_INIT_MASK = (0x1U << 11),
+ PORT_DEV_TRGT_MASK = (0x7U << 17),
+ PORT_DEV_INIT_MASK = (0x7U << 9),
+ PORT_DEV_TYPE_MASK = (0x7U << 0),
+
+ /* Port n PHY Status */
+ PHY_RDY = (1U << 2),
+ PHY_DW_SYNC = (1U << 1),
+ PHY_OOB_DTCTD = (1U << 0),
+
+ /* VSR */
+ /* PHYMODE 6 (CDB) */
+ PHY_MODE6_LATECLK = (1U << 29), /* Lock Clock */
+ PHY_MODE6_DTL_SPEED = (1U << 27), /* Digital Loop Speed */
+ PHY_MODE6_FC_ORDER = (1U << 26), /* Fibre Channel Mode Order*/
+ PHY_MODE6_MUCNT_EN = (1U << 24), /* u Count Enable */
+ PHY_MODE6_SEL_MUCNT_LEN = (1U << 22), /* Training Length Select */
+ PHY_MODE6_SELMUPI = (1U << 20), /* Phase Multi Select (init) */
+ PHY_MODE6_SELMUPF = (1U << 18), /* Phase Multi Select (final) */
+ PHY_MODE6_SELMUFF = (1U << 16), /* Freq Loop Multi Sel(final) */
+ PHY_MODE6_SELMUFI = (1U << 14), /* Freq Loop Multi Sel(init) */
+ PHY_MODE6_FREEZE_LOOP = (1U << 12), /* Freeze Rx CDR Loop */
+ PHY_MODE6_INT_RXFOFFS = (1U << 3), /* Rx CDR Freq Loop Enable */
+ PHY_MODE6_FRC_RXFOFFS = (1U << 2), /* Initial Rx CDR Offset */
+ PHY_MODE6_STAU_0D8 = (1U << 1), /* Rx CDR Freq Loop Saturate */
+ PHY_MODE6_RXSAT_DIS = (1U << 0), /* Saturate Ctl */
+};
+
+/* SAS/SATA configuration port registers, aka phy registers */
+enum sas_sata_config_port_regs {
+ PHYR_IDENTIFY = 0x00, /* info for IDENTIFY frame */
+ PHYR_ADDR_LO = 0x04, /* my SAS address (low) */
+ PHYR_ADDR_HI = 0x08, /* my SAS address (high) */
+ PHYR_ATT_DEV_INFO = 0x0C, /* attached device info */
+ PHYR_ATT_ADDR_LO = 0x10, /* attached dev SAS addr (low) */
+ PHYR_ATT_ADDR_HI = 0x14, /* attached dev SAS addr (high) */
+ PHYR_SATA_CTL = 0x18, /* SATA control */
+ PHYR_PHY_STAT = 0x1C, /* PHY status */
+ PHYR_SATA_SIG0 = 0x20, /*port SATA signature FIS(Byte 0-3) */
+ PHYR_SATA_SIG1 = 0x24, /*port SATA signature FIS(Byte 4-7) */
+ PHYR_SATA_SIG2 = 0x28, /*port SATA signature FIS(Byte 8-11) */
+ PHYR_SATA_SIG3 = 0x2c, /*port SATA signature FIS(Byte 12-15) */
+ PHYR_R_ERR_COUNT = 0x30, /* port R_ERR count register */
+ PHYR_CRC_ERR_COUNT = 0x34, /* port CRC error count register */
+ PHYR_WIDE_PORT = 0x38, /* wide port participating */
+ PHYR_CURRENT0 = 0x80, /* current connection info 0 */
+ PHYR_CURRENT1 = 0x84, /* current connection info 1 */
+ PHYR_CURRENT2 = 0x88, /* current connection info 2 */
+ CONFIG_ID_FRAME0 = 0x100, /* Port device ID frame register 0 */
+ CONFIG_ID_FRAME1 = 0x104, /* Port device ID frame register 1 */
+ CONFIG_ID_FRAME2 = 0x108, /* Port device ID frame register 2 */
+ CONFIG_ID_FRAME3 = 0x10c, /* Port device ID frame register 3 */
+ CONFIG_ID_FRAME4 = 0x110, /* Port device ID frame register 4 */
+ CONFIG_ID_FRAME5 = 0x114, /* Port device ID frame register 5 */
+ CONFIG_ID_FRAME6 = 0x118, /* Port device ID frame register 6 */
+ CONFIG_ATT_ID_FRAME0 = 0x11c, /* attached ID frame register 0 */
+ CONFIG_ATT_ID_FRAME1 = 0x120, /* attached ID frame register 1 */
+ CONFIG_ATT_ID_FRAME2 = 0x124, /* attached ID frame register 2 */
+ CONFIG_ATT_ID_FRAME3 = 0x128, /* attached ID frame register 3 */
+ CONFIG_ATT_ID_FRAME4 = 0x12c, /* attached ID frame register 4 */
+ CONFIG_ATT_ID_FRAME5 = 0x130, /* attached ID frame register 5 */
+ CONFIG_ATT_ID_FRAME6 = 0x134, /* attached ID frame register 6 */
+};
+
+enum sas_cmd_port_registers {
+ CMD_CMRST_OOB_DET = 0x100, /* COMRESET OOB detect register */
+ CMD_CMWK_OOB_DET = 0x104, /* COMWAKE OOB detect register */
+ CMD_CMSAS_OOB_DET = 0x108, /* COMSAS OOB detect register */
+ CMD_BRST_OOB_DET = 0x10c, /* burst OOB detect register */
+ CMD_OOB_SPACE = 0x110, /* OOB space control register */
+ CMD_OOB_BURST = 0x114, /* OOB burst control register */
+ CMD_PHY_TIMER = 0x118, /* PHY timer control register */
+ CMD_PHY_CONFIG0 = 0x11c, /* PHY config register 0 */
+ CMD_PHY_CONFIG1 = 0x120, /* PHY config register 1 */
+ CMD_SAS_CTL0 = 0x124, /* SAS control register 0 */
+ CMD_SAS_CTL1 = 0x128, /* SAS control register 1 */
+ CMD_SAS_CTL2 = 0x12c, /* SAS control register 2 */
+ CMD_SAS_CTL3 = 0x130, /* SAS control register 3 */
+ CMD_ID_TEST = 0x134, /* ID test register */
+ CMD_PL_TIMER = 0x138, /* PL timer register */
+ CMD_WD_TIMER = 0x13c, /* WD timer register */
+ CMD_PORT_SEL_COUNT = 0x140, /* port selector count register */
+ CMD_APP_MEM_CTL = 0x144, /* Application Memory Control */
+ CMD_XOR_MEM_CTL = 0x148, /* XOR Block Memory Control */
+ CMD_DMA_MEM_CTL = 0x14c, /* DMA Block Memory Control */
+ CMD_PORT_MEM_CTL0 = 0x150, /* Port Memory Control 0 */
+ CMD_PORT_MEM_CTL1 = 0x154, /* Port Memory Control 1 */
+ CMD_SATA_PORT_MEM_CTL0 = 0x158, /* SATA Port Memory Control 0 */
+ CMD_SATA_PORT_MEM_CTL1 = 0x15c, /* SATA Port Memory Control 1 */
+ CMD_XOR_MEM_BIST_CTL = 0x160, /* XOR Memory BIST Control */
+ CMD_XOR_MEM_BIST_STAT = 0x164, /* XOR Memroy BIST Status */
+ CMD_DMA_MEM_BIST_CTL = 0x168, /* DMA Memory BIST Control */
+ CMD_DMA_MEM_BIST_STAT = 0x16c, /* DMA Memory BIST Status */
+ CMD_PORT_MEM_BIST_CTL = 0x170, /* Port Memory BIST Control */
+ CMD_PORT_MEM_BIST_STAT0 = 0x174, /* Port Memory BIST Status 0 */
+ CMD_PORT_MEM_BIST_STAT1 = 0x178, /* Port Memory BIST Status 1 */
+ CMD_STP_MEM_BIST_CTL = 0x17c, /* STP Memory BIST Control */
+ CMD_STP_MEM_BIST_STAT0 = 0x180, /* STP Memory BIST Status 0 */
+ CMD_STP_MEM_BIST_STAT1 = 0x184, /* STP Memory BIST Status 1 */
+ CMD_RESET_COUNT = 0x188, /* Reset Count */
+ CMD_MONTR_DATA_SEL = 0x18C, /* Monitor Data/Select */
+ CMD_PLL_PHY_CONFIG = 0x190, /* PLL/PHY Configuration */
+ CMD_PHY_CTL = 0x194, /* PHY Control and Status */
+ CMD_PHY_TEST_COUNT0 = 0x198, /* Phy Test Count 0 */
+ CMD_PHY_TEST_COUNT1 = 0x19C, /* Phy Test Count 1 */
+ CMD_PHY_TEST_COUNT2 = 0x1A0, /* Phy Test Count 2 */
+ CMD_APP_ERR_CONFIG = 0x1A4, /* Application Error Configuration */
+ CMD_PND_FIFO_CTL0 = 0x1A8, /* Pending FIFO Control 0 */
+ CMD_HOST_CTL = 0x1AC, /* Host Control Status */
+ CMD_HOST_WR_DATA = 0x1B0, /* Host Write Data */
+ CMD_HOST_RD_DATA = 0x1B4, /* Host Read Data */
+ CMD_PHY_MODE_21 = 0x1B8, /* Phy Mode 21 */
+ CMD_SL_MODE0 = 0x1BC, /* SL Mode 0 */
+ CMD_SL_MODE1 = 0x1C0, /* SL Mode 1 */
+ CMD_PND_FIFO_CTL1 = 0x1C4, /* Pending FIFO Control 1 */
+};
+
+enum mvs_info_flags {
+ MVF_MSI = (1U << 0), /* MSI is enabled */
+ MVF_PHY_PWR_FIX = (1U << 1), /* bug workaround */
+ MVF_FLAG_SOC = (1U << 2), /* SoC integrated controllers */
+};
+
+enum mvs_event_flags {
+ PHY_PLUG_EVENT = (3U),
+ PHY_PLUG_IN = (1U << 0), /* phy plug in */
+ PHY_PLUG_OUT = (1U << 1), /* phy plug out */
+};
+
+enum mvs_port_type {
+ PORT_TGT_MASK = (1U << 5),
+ PORT_INIT_PORT = (1U << 4),
+ PORT_TGT_PORT = (1U << 3),
+ PORT_INIT_TGT_PORT = (PORT_INIT_PORT | PORT_TGT_PORT),
+ PORT_TYPE_SAS = (1U << 1),
+ PORT_TYPE_SATA = (1U << 0),
+};
+
+/* Command Table Format */
+enum ct_format {
+ /* SSP */
+ SSP_F_H = 0x00,
+ SSP_F_IU = 0x18,
+ SSP_F_MAX = 0x4D,
+ /* STP */
+ STP_CMD_FIS = 0x00,
+ STP_ATAPI_CMD = 0x40,
+ STP_F_MAX = 0x10,
+ /* SMP */
+ SMP_F_T = 0x00,
+ SMP_F_DEP = 0x01,
+ SMP_F_MAX = 0x101,
+};
+
+enum status_buffer {
+ SB_EIR_OFF = 0x00, /* Error Information Record */
+ SB_RFB_OFF = 0x08, /* Response Frame Buffer */
+ SB_RFB_MAX = 0x400, /* RFB size*/
+};
+
+enum error_info_rec {
+ CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */
+ CMD_PI_ERR = (1U << 30), /* Protection info error. see flags2 */
+ RSP_OVER = (1U << 29), /* rsp buffer overflow */
+ RETRY_LIM = (1U << 28), /* FIS/frame retry limit exceeded */
+ UNK_FIS = (1U << 27), /* unknown FIS */
+ DMA_TERM = (1U << 26), /* DMA terminate primitive rx'd */
+ SYNC_ERR = (1U << 25), /* SYNC rx'd during frame xmit */
+ TFILE_ERR = (1U << 24), /* SATA taskfile Error bit set */
+ R_ERR = (1U << 23), /* SATA returned R_ERR prim */
+ RD_OFS = (1U << 20), /* Read DATA frame invalid offset */
+ XFER_RDY_OFS = (1U << 19), /* XFER_RDY offset error */
+ UNEXP_XFER_RDY = (1U << 18), /* unexpected XFER_RDY error */
+ DATA_OVER_UNDER = (1U << 16), /* data overflow/underflow */
+ INTERLOCK = (1U << 15), /* interlock error */
+ NAK = (1U << 14), /* NAK rx'd */
+ ACK_NAK_TO = (1U << 13), /* ACK/NAK timeout */
+ CXN_CLOSED = (1U << 12), /* cxn closed w/out ack/nak */
+ OPEN_TO = (1U << 11), /* I_T nexus lost, open cxn timeout */
+ PATH_BLOCKED = (1U << 10), /* I_T nexus lost, pathway blocked */
+ NO_DEST = (1U << 9), /* I_T nexus lost, no destination */
+ STP_RES_BSY = (1U << 8), /* STP resources busy */
+ BREAK = (1U << 7), /* break received */
+ BAD_DEST = (1U << 6), /* bad destination */
+ BAD_PROTO = (1U << 5), /* protocol not supported */
+ BAD_RATE = (1U << 4), /* cxn rate not supported */
+ WRONG_DEST = (1U << 3), /* wrong destination error */
+ CREDIT_TO = (1U << 2), /* credit timeout */
+ WDOG_TO = (1U << 1), /* watchdog timeout */
+ BUF_PAR = (1U << 0), /* buffer parity error */
+};
+
+enum error_info_rec_2 {
+ SLOT_BSY_ERR = (1U << 31), /* Slot Busy Error */
+ GRD_CHK_ERR = (1U << 14), /* Guard Check Error */
+ APP_CHK_ERR = (1U << 13), /* Application Check error */
+ REF_CHK_ERR = (1U << 12), /* Reference Check Error */
+ USR_BLK_NM = (1U << 0), /* User Block Number */
+};
+
+enum pci_cfg_register_bits {
+ PCTL_PWR_OFF = (0xFU << 24),
+ PCTL_COM_ON = (0xFU << 20),
+ PCTL_LINK_RST = (0xFU << 16),
+ PCTL_LINK_OFFS = (16),
+ PCTL_PHY_DSBL = (0xFU << 12),
+ PCTL_PHY_DSBL_OFFS = (12),
+ PRD_REQ_SIZE = (0x4000),
+ PRD_REQ_MASK = (0x00007000),
+ PLS_NEG_LINK_WD = (0x3FU << 4),
+ PLS_NEG_LINK_WD_OFFS = 4,
+ PLS_LINK_SPD = (0x0FU << 0),
+ PLS_LINK_SPD_OFFS = 0,
+};
+
+enum open_frame_protocol {
+ PROTOCOL_SMP = 0x0,
+ PROTOCOL_SSP = 0x1,
+ PROTOCOL_STP = 0x2,
+};
+
+/* define for response frame datapres field */
+enum datapres_field {
+ NO_DATA = 0,
+ RESPONSE_DATA = 1,
+ SENSE_DATA = 2,
+};
+
+/* define task management IU */
+struct mvs_tmf_task{
+ u8 tmf;
+ u16 tag_of_task_to_be_managed;
+};
+#endif
diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
new file mode 100644
index 000000000000..8646a19f999d
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -0,0 +1,703 @@
+/*
+ * Marvell 88SE64xx/88SE94xx pci init
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+
+#include "mv_sas.h"
+
+static struct scsi_transport_template *mvs_stt;
+static const struct mvs_chip_info mvs_chips[] = {
+ [chip_6320] = { 1, 2, 0x400, 17, 16, 9, &mvs_64xx_dispatch, },
+ [chip_6440] = { 1, 4, 0x400, 17, 16, 9, &mvs_64xx_dispatch, },
+ [chip_6485] = { 1, 8, 0x800, 33, 32, 10, &mvs_64xx_dispatch, },
+ [chip_9180] = { 2, 4, 0x800, 17, 64, 9, &mvs_94xx_dispatch, },
+ [chip_9480] = { 2, 4, 0x800, 17, 64, 9, &mvs_94xx_dispatch, },
+};
+
+#define SOC_SAS_NUM 2
+
+static struct scsi_host_template mvs_sht = {
+ .module = THIS_MODULE,
+ .name = DRV_NAME,
+ .queuecommand = sas_queuecommand,
+ .target_alloc = sas_target_alloc,
+ .slave_configure = mvs_slave_configure,
+ .slave_destroy = sas_slave_destroy,
+ .scan_finished = mvs_scan_finished,
+ .scan_start = mvs_scan_start,
+ .change_queue_depth = sas_change_queue_depth,
+ .change_queue_type = sas_change_queue_type,
+ .bios_param = sas_bios_param,
+ .can_queue = 1,
+ .cmd_per_lun = 1,
+ .this_id = -1,
+ .sg_tablesize = SG_ALL,
+ .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
+ .use_clustering = ENABLE_CLUSTERING,
+ .eh_device_reset_handler = sas_eh_device_reset_handler,
+ .eh_bus_reset_handler = sas_eh_bus_reset_handler,
+ .slave_alloc = mvs_slave_alloc,
+ .target_destroy = sas_target_destroy,
+ .ioctl = sas_ioctl,
+};
+
+static struct sas_domain_function_template mvs_transport_ops = {
+ .lldd_dev_found = mvs_dev_found,
+ .lldd_dev_gone = mvs_dev_gone,
+
+ .lldd_execute_task = mvs_queue_command,
+ .lldd_control_phy = mvs_phy_control,
+
+ .lldd_abort_task = mvs_abort_task,
+ .lldd_abort_task_set = mvs_abort_task_set,
+ .lldd_clear_aca = mvs_clear_aca,
+ .lldd_clear_task_set = mvs_clear_task_set,
+ .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset,
+ .lldd_lu_reset = mvs_lu_reset,
+ .lldd_query_task = mvs_query_task,
+
+ .lldd_port_formed = mvs_port_formed,
+ .lldd_port_deformed = mvs_port_deformed,
+
+};
+
+static void __devinit mvs_phy_init(struct mvs_info *mvi, int phy_id)
+{
+ struct mvs_phy *phy = &mvi->phy[phy_id];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+
+ phy->mvi = mvi;
+ init_timer(&phy->timer);
+ sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0;
+ sas_phy->class = SAS;
+ sas_phy->iproto = SAS_PROTOCOL_ALL;
+ sas_phy->tproto = 0;
+ sas_phy->type = PHY_TYPE_PHYSICAL;
+ sas_phy->role = PHY_ROLE_INITIATOR;
+ sas_phy->oob_mode = OOB_NOT_CONNECTED;
+ sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN;
+
+ sas_phy->id = phy_id;
+ sas_phy->sas_addr = &mvi->sas_addr[0];
+ sas_phy->frame_rcvd = &phy->frame_rcvd[0];
+ sas_phy->ha = (struct sas_ha_struct *)mvi->shost->hostdata;
+ sas_phy->lldd_phy = phy;
+}
+
+static void mvs_free(struct mvs_info *mvi)
+{
+ int i;
+ struct mvs_wq *mwq;
+ int slot_nr;
+
+ if (!mvi)
+ return;
+
+ if (mvi->flags & MVF_FLAG_SOC)
+ slot_nr = MVS_SOC_SLOTS;
+ else
+ slot_nr = MVS_SLOTS;
+
+ for (i = 0; i < mvi->tags_num; i++) {
+ struct mvs_slot_info *slot = &mvi->slot_info[i];
+ if (slot->buf)
+ dma_free_coherent(mvi->dev, MVS_SLOT_BUF_SZ,
+ slot->buf, slot->buf_dma);
+ }
+
+ if (mvi->tx)
+ dma_free_coherent(mvi->dev,
+ sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
+ mvi->tx, mvi->tx_dma);
+ if (mvi->rx_fis)
+ dma_free_coherent(mvi->dev, MVS_RX_FISL_SZ,
+ mvi->rx_fis, mvi->rx_fis_dma);
+ if (mvi->rx)
+ dma_free_coherent(mvi->dev,
+ sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
+ mvi->rx, mvi->rx_dma);
+ if (mvi->slot)
+ dma_free_coherent(mvi->dev,
+ sizeof(*mvi->slot) * slot_nr,
+ mvi->slot, mvi->slot_dma);
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ if (mvi->bulk_buffer)
+ dma_free_coherent(mvi->dev, TRASH_BUCKET_SIZE,
+ mvi->bulk_buffer, mvi->bulk_buffer_dma);
+#endif
+
+ MVS_CHIP_DISP->chip_iounmap(mvi);
+ if (mvi->shost)
+ scsi_host_put(mvi->shost);
+ list_for_each_entry(mwq, &mvi->wq_list, entry)
+ cancel_delayed_work(&mwq->work_q);
+ kfree(mvi);
+}
+
+#ifdef MVS_USE_TASKLET
+struct tasklet_struct mv_tasklet;
+static void mvs_tasklet(unsigned long opaque)
+{
+ unsigned long flags;
+ u32 stat;
+ u16 core_nr, i = 0;
+
+ struct mvs_info *mvi;
+ struct sas_ha_struct *sha = (struct sas_ha_struct *)opaque;
+
+ core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host;
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0];
+
+ if (unlikely(!mvi))
+ BUG_ON(1);
+
+ for (i = 0; i < core_nr; i++) {
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i];
+ stat = MVS_CHIP_DISP->isr_status(mvi, mvi->irq);
+ if (stat)
+ MVS_CHIP_DISP->isr(mvi, mvi->irq, stat);
+ }
+
+}
+#endif
+
+static irqreturn_t mvs_interrupt(int irq, void *opaque)
+{
+ u32 core_nr, i = 0;
+ u32 stat;
+ struct mvs_info *mvi;
+ struct sas_ha_struct *sha = opaque;
+
+ core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host;
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0];
+
+ if (unlikely(!mvi))
+ return IRQ_NONE;
+
+ stat = MVS_CHIP_DISP->isr_status(mvi, irq);
+ if (!stat)
+ return IRQ_NONE;
+
+#ifdef MVS_USE_TASKLET
+ tasklet_schedule(&mv_tasklet);
+#else
+ for (i = 0; i < core_nr; i++) {
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i];
+ MVS_CHIP_DISP->isr(mvi, irq, stat);
+ }
+#endif
+ return IRQ_HANDLED;
+}
+
+static int __devinit mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
+{
+ int i, slot_nr;
+
+ if (mvi->flags & MVF_FLAG_SOC)
+ slot_nr = MVS_SOC_SLOTS;
+ else
+ slot_nr = MVS_SLOTS;
+
+ spin_lock_init(&mvi->lock);
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ mvs_phy_init(mvi, i);
+ mvi->port[i].wide_port_phymap = 0;
+ mvi->port[i].port_attached = 0;
+ INIT_LIST_HEAD(&mvi->port[i].list);
+ }
+ for (i = 0; i < MVS_MAX_DEVICES; i++) {
+ mvi->devices[i].taskfileset = MVS_ID_NOT_MAPPED;
+ mvi->devices[i].dev_type = NO_DEVICE;
+ mvi->devices[i].device_id = i;
+ mvi->devices[i].dev_status = MVS_DEV_NORMAL;
+ }
+
+ /*
+ * alloc and init our DMA areas
+ */
+ mvi->tx = dma_alloc_coherent(mvi->dev,
+ sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
+ &mvi->tx_dma, GFP_KERNEL);
+ if (!mvi->tx)
+ goto err_out;
+ memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ);
+ mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
+ &mvi->rx_fis_dma, GFP_KERNEL);
+ if (!mvi->rx_fis)
+ goto err_out;
+ memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
+
+ mvi->rx = dma_alloc_coherent(mvi->dev,
+ sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
+ &mvi->rx_dma, GFP_KERNEL);
+ if (!mvi->rx)
+ goto err_out;
+ memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
+ mvi->rx[0] = cpu_to_le32(0xfff);
+ mvi->rx_cons = 0xfff;
+
+ mvi->slot = dma_alloc_coherent(mvi->dev,
+ sizeof(*mvi->slot) * slot_nr,
+ &mvi->slot_dma, GFP_KERNEL);
+ if (!mvi->slot)
+ goto err_out;
+ memset(mvi->slot, 0, sizeof(*mvi->slot) * slot_nr);
+
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
+ TRASH_BUCKET_SIZE,
+ &mvi->bulk_buffer_dma, GFP_KERNEL);
+ if (!mvi->bulk_buffer)
+ goto err_out;
+#endif
+ for (i = 0; i < slot_nr; i++) {
+ struct mvs_slot_info *slot = &mvi->slot_info[i];
+
+ slot->buf = dma_alloc_coherent(mvi->dev, MVS_SLOT_BUF_SZ,
+ &slot->buf_dma, GFP_KERNEL);
+ if (!slot->buf) {
+ printk(KERN_DEBUG"failed to allocate slot->buf.\n");
+ goto err_out;
+ }
+ memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
+ ++mvi->tags_num;
+ }
+ /* Initialize tags */
+ mvs_tag_init(mvi);
+ return 0;
+err_out:
+ return 1;
+}
+
+
+int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
+{
+ unsigned long res_start, res_len, res_flag, res_flag_ex = 0;
+ struct pci_dev *pdev = mvi->pdev;
+ if (bar_ex != -1) {
+ /*
+ * ioremap main and peripheral registers
+ */
+ res_start = pci_resource_start(pdev, bar_ex);
+ res_len = pci_resource_len(pdev, bar_ex);
+ if (!res_start || !res_len)
+ goto err_out;
+
+ res_flag_ex = pci_resource_flags(pdev, bar_ex);
+ if (res_flag_ex & IORESOURCE_MEM) {
+ if (res_flag_ex & IORESOURCE_CACHEABLE)
+ mvi->regs_ex = ioremap(res_start, res_len);
+ else
+ mvi->regs_ex = ioremap_nocache(res_start,
+ res_len);
+ } else
+ mvi->regs_ex = (void *)res_start;
+ if (!mvi->regs_ex)
+ goto err_out;
+ }
+
+ res_start = pci_resource_start(pdev, bar);
+ res_len = pci_resource_len(pdev, bar);
+ if (!res_start || !res_len)
+ goto err_out;
+
+ res_flag = pci_resource_flags(pdev, bar);
+ if (res_flag & IORESOURCE_CACHEABLE)
+ mvi->regs = ioremap(res_start, res_len);
+ else
+ mvi->regs = ioremap_nocache(res_start, res_len);
+
+ if (!mvi->regs) {
+ if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM))
+ iounmap(mvi->regs_ex);
+ mvi->regs_ex = NULL;
+ goto err_out;
+ }
+
+ return 0;
+err_out:
+ return -1;
+}
+
+void mvs_iounmap(void __iomem *regs)
+{
+ iounmap(regs);
+}
+
+static struct mvs_info *__devinit mvs_pci_alloc(struct pci_dev *pdev,
+ const struct pci_device_id *ent,
+ struct Scsi_Host *shost, unsigned int id)
+{
+ struct mvs_info *mvi;
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+
+ mvi = kzalloc(sizeof(*mvi) + MVS_SLOTS * sizeof(struct mvs_slot_info),
+ GFP_KERNEL);
+ if (!mvi)
+ return NULL;
+
+ mvi->pdev = pdev;
+ mvi->dev = &pdev->dev;
+ mvi->chip_id = ent->driver_data;
+ mvi->chip = &mvs_chips[mvi->chip_id];
+ INIT_LIST_HEAD(&mvi->wq_list);
+ mvi->irq = pdev->irq;
+
+ ((struct mvs_prv_info *)sha->lldd_ha)->mvi[id] = mvi;
+ ((struct mvs_prv_info *)sha->lldd_ha)->n_phy = mvi->chip->n_phy;
+
+ mvi->id = id;
+ mvi->sas = sha;
+ mvi->shost = shost;
+#ifdef MVS_USE_TASKLET
+ tasklet_init(&mv_tasklet, mvs_tasklet, (unsigned long)sha);
+#endif
+
+ if (MVS_CHIP_DISP->chip_ioremap(mvi))
+ goto err_out;
+ if (!mvs_alloc(mvi, shost))
+ return mvi;
+err_out:
+ mvs_free(mvi);
+ return NULL;
+}
+
+/* move to PCI layer or libata core? */
+static int pci_go_64(struct pci_dev *pdev)
+{
+ int rc;
+
+ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
+ rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (rc) {
+ rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (rc) {
+ dev_printk(KERN_ERR, &pdev->dev,
+ "64-bit DMA enable failed\n");
+ return rc;
+ }
+ }
+ } else {
+ rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (rc) {
+ dev_printk(KERN_ERR, &pdev->dev,
+ "32-bit DMA enable failed\n");
+ return rc;
+ }
+ rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (rc) {
+ dev_printk(KERN_ERR, &pdev->dev,
+ "32-bit consistent DMA enable failed\n");
+ return rc;
+ }
+ }
+
+ return rc;
+}
+
+static int __devinit mvs_prep_sas_ha_init(struct Scsi_Host *shost,
+ const struct mvs_chip_info *chip_info)
+{
+ int phy_nr, port_nr; unsigned short core_nr;
+ struct asd_sas_phy **arr_phy;
+ struct asd_sas_port **arr_port;
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+
+ core_nr = chip_info->n_host;
+ phy_nr = core_nr * chip_info->n_phy;
+ port_nr = phy_nr;
+
+ memset(sha, 0x00, sizeof(struct sas_ha_struct));
+ arr_phy = kcalloc(phy_nr, sizeof(void *), GFP_KERNEL);
+ arr_port = kcalloc(port_nr, sizeof(void *), GFP_KERNEL);
+ if (!arr_phy || !arr_port)
+ goto exit_free;
+
+ sha->sas_phy = arr_phy;
+ sha->sas_port = arr_port;
+
+ sha->lldd_ha = kzalloc(sizeof(struct mvs_prv_info), GFP_KERNEL);
+ if (!sha->lldd_ha)
+ goto exit_free;
+
+ ((struct mvs_prv_info *)sha->lldd_ha)->n_host = core_nr;
+
+ shost->transportt = mvs_stt;
+ shost->max_id = 128;
+ shost->max_lun = ~0;
+ shost->max_channel = 1;
+ shost->max_cmd_len = 16;
+
+ return 0;
+exit_free:
+ kfree(arr_phy);
+ kfree(arr_port);
+ return -1;
+
+}
+
+static void __devinit mvs_post_sas_ha_init(struct Scsi_Host *shost,
+ const struct mvs_chip_info *chip_info)
+{
+ int can_queue, i = 0, j = 0;
+ struct mvs_info *mvi = NULL;
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+ unsigned short nr_core = ((struct mvs_prv_info *)sha->lldd_ha)->n_host;
+
+ for (j = 0; j < nr_core; j++) {
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j];
+ for (i = 0; i < chip_info->n_phy; i++) {
+ sha->sas_phy[j * chip_info->n_phy + i] =
+ &mvi->phy[i].sas_phy;
+ sha->sas_port[j * chip_info->n_phy + i] =
+ &mvi->port[i].sas_port;
+ }
+ }
+
+ sha->sas_ha_name = DRV_NAME;
+ sha->dev = mvi->dev;
+ sha->lldd_module = THIS_MODULE;
+ sha->sas_addr = &mvi->sas_addr[0];
+
+ sha->num_phys = nr_core * chip_info->n_phy;
+
+ sha->lldd_max_execute_num = 1;
+
+ if (mvi->flags & MVF_FLAG_SOC)
+ can_queue = MVS_SOC_CAN_QUEUE;
+ else
+ can_queue = MVS_CAN_QUEUE;
+
+ sha->lldd_queue_size = can_queue;
+ shost->can_queue = can_queue;
+ mvi->shost->cmd_per_lun = MVS_SLOTS/sha->num_phys;
+ sha->core.shost = mvi->shost;
+}
+
+static void mvs_init_sas_add(struct mvs_info *mvi)
+{
+ u8 i;
+ for (i = 0; i < mvi->chip->n_phy; i++) {
+ mvi->phy[i].dev_sas_addr = 0x5005043011ab0000ULL;
+ mvi->phy[i].dev_sas_addr =
+ cpu_to_be64((u64)(*(u64 *)&mvi->phy[i].dev_sas_addr));
+ }
+
+ memcpy(mvi->sas_addr, &mvi->phy[0].dev_sas_addr, SAS_ADDR_SIZE);
+}
+
+static int __devinit mvs_pci_init(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ unsigned int rc, nhost = 0;
+ struct mvs_info *mvi;
+ irq_handler_t irq_handler = mvs_interrupt;
+ struct Scsi_Host *shost = NULL;
+ const struct mvs_chip_info *chip;
+
+ dev_printk(KERN_INFO, &pdev->dev,
+ "mvsas: driver version %s\n", DRV_VERSION);
+ rc = pci_enable_device(pdev);
+ if (rc)
+ goto err_out_enable;
+
+ pci_set_master(pdev);
+
+ rc = pci_request_regions(pdev, DRV_NAME);
+ if (rc)
+ goto err_out_disable;
+
+ rc = pci_go_64(pdev);
+ if (rc)
+ goto err_out_regions;
+
+ shost = scsi_host_alloc(&mvs_sht, sizeof(void *));
+ if (!shost) {
+ rc = -ENOMEM;
+ goto err_out_regions;
+ }
+
+ chip = &mvs_chips[ent->driver_data];
+ SHOST_TO_SAS_HA(shost) =
+ kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL);
+ if (!SHOST_TO_SAS_HA(shost)) {
+ kfree(shost);
+ rc = -ENOMEM;
+ goto err_out_regions;
+ }
+
+ rc = mvs_prep_sas_ha_init(shost, chip);
+ if (rc) {
+ kfree(shost);
+ rc = -ENOMEM;
+ goto err_out_regions;
+ }
+
+ pci_set_drvdata(pdev, SHOST_TO_SAS_HA(shost));
+
+ do {
+ mvi = mvs_pci_alloc(pdev, ent, shost, nhost);
+ if (!mvi) {
+ rc = -ENOMEM;
+ goto err_out_regions;
+ }
+
+ mvs_init_sas_add(mvi);
+
+ mvi->instance = nhost;
+ rc = MVS_CHIP_DISP->chip_init(mvi);
+ if (rc) {
+ mvs_free(mvi);
+ goto err_out_regions;
+ }
+ nhost++;
+ } while (nhost < chip->n_host);
+
+ mvs_post_sas_ha_init(shost, chip);
+
+ rc = scsi_add_host(shost, &pdev->dev);
+ if (rc)
+ goto err_out_shost;
+
+ rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
+ if (rc)
+ goto err_out_shost;
+ rc = request_irq(pdev->irq, irq_handler, IRQF_SHARED,
+ DRV_NAME, SHOST_TO_SAS_HA(shost));
+ if (rc)
+ goto err_not_sas;
+
+ MVS_CHIP_DISP->interrupt_enable(mvi);
+
+ scsi_scan_host(mvi->shost);
+
+ return 0;
+
+err_not_sas:
+ sas_unregister_ha(SHOST_TO_SAS_HA(shost));
+err_out_shost:
+ scsi_remove_host(mvi->shost);
+err_out_regions:
+ pci_release_regions(pdev);
+err_out_disable:
+ pci_disable_device(pdev);
+err_out_enable:
+ return rc;
+}
+
+static void __devexit mvs_pci_remove(struct pci_dev *pdev)
+{
+ unsigned short core_nr, i = 0;
+ struct sas_ha_struct *sha = pci_get_drvdata(pdev);
+ struct mvs_info *mvi = NULL;
+
+ core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host;
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0];
+
+#ifdef MVS_USE_TASKLET
+ tasklet_kill(&mv_tasklet);
+#endif
+
+ pci_set_drvdata(pdev, NULL);
+ sas_unregister_ha(sha);
+ sas_remove_host(mvi->shost);
+ scsi_remove_host(mvi->shost);
+
+ MVS_CHIP_DISP->interrupt_disable(mvi);
+ free_irq(mvi->irq, sha);
+ for (i = 0; i < core_nr; i++) {
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i];
+ mvs_free(mvi);
+ }
+ kfree(sha->sas_phy);
+ kfree(sha->sas_port);
+ kfree(sha);
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
+ return;
+}
+
+static struct pci_device_id __devinitdata mvs_pci_table[] = {
+ { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 },
+ { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 },
+ {
+ .vendor = PCI_VENDOR_ID_MARVELL,
+ .device = 0x6440,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = 0x6480,
+ .class = 0,
+ .class_mask = 0,
+ .driver_data = chip_6485,
+ },
+ { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 },
+ { PCI_VDEVICE(MARVELL, 0x6485), chip_6485 },
+ { PCI_VDEVICE(MARVELL, 0x9480), chip_9480 },
+ { PCI_VDEVICE(MARVELL, 0x9180), chip_9180 },
+
+ { } /* terminate list */
+};
+
+static struct pci_driver mvs_pci_driver = {
+ .name = DRV_NAME,
+ .id_table = mvs_pci_table,
+ .probe = mvs_pci_init,
+ .remove = __devexit_p(mvs_pci_remove),
+};
+
+/* task handler */
+struct task_struct *mvs_th;
+static int __init mvs_init(void)
+{
+ int rc;
+ mvs_stt = sas_domain_attach_transport(&mvs_transport_ops);
+ if (!mvs_stt)
+ return -ENOMEM;
+
+ rc = pci_register_driver(&mvs_pci_driver);
+
+ if (rc)
+ goto err_out;
+
+ return 0;
+
+err_out:
+ sas_release_transport(mvs_stt);
+ return rc;
+}
+
+static void __exit mvs_exit(void)
+{
+ pci_unregister_driver(&mvs_pci_driver);
+ sas_release_transport(mvs_stt);
+}
+
+module_init(mvs_init);
+module_exit(mvs_exit);
+
+MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>");
+MODULE_DESCRIPTION("Marvell 88SE6440 SAS/SATA controller driver");
+MODULE_VERSION(DRV_VERSION);
+MODULE_LICENSE("GPL");
+#ifdef CONFIG_PCI
+MODULE_DEVICE_TABLE(pci, mvs_pci_table);
+#endif
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
new file mode 100644
index 000000000000..0d2138641214
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -0,0 +1,2154 @@
+/*
+ * Marvell 88SE64xx/88SE94xx main function
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#include "mv_sas.h"
+
+static int mvs_find_tag(struct mvs_info *mvi, struct sas_task *task, u32 *tag)
+{
+ if (task->lldd_task) {
+ struct mvs_slot_info *slot;
+ slot = task->lldd_task;
+ *tag = slot->slot_tag;
+ return 1;
+ }
+ return 0;
+}
+
+void mvs_tag_clear(struct mvs_info *mvi, u32 tag)
+{
+ void *bitmap = &mvi->tags;
+ clear_bit(tag, bitmap);
+}
+
+void mvs_tag_free(struct mvs_info *mvi, u32 tag)
+{
+ mvs_tag_clear(mvi, tag);
+}
+
+void mvs_tag_set(struct mvs_info *mvi, unsigned int tag)
+{
+ void *bitmap = &mvi->tags;
+ set_bit(tag, bitmap);
+}
+
+inline int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out)
+{
+ unsigned int index, tag;
+ void *bitmap = &mvi->tags;
+
+ index = find_first_zero_bit(bitmap, mvi->tags_num);
+ tag = index;
+ if (tag >= mvi->tags_num)
+ return -SAS_QUEUE_FULL;
+ mvs_tag_set(mvi, tag);
+ *tag_out = tag;
+ return 0;
+}
+
+void mvs_tag_init(struct mvs_info *mvi)
+{
+ int i;
+ for (i = 0; i < mvi->tags_num; ++i)
+ mvs_tag_clear(mvi, i);
+}
+
+void mvs_hexdump(u32 size, u8 *data, u32 baseaddr)
+{
+ u32 i;
+ u32 run;
+ u32 offset;
+
+ offset = 0;
+ while (size) {
+ printk(KERN_DEBUG"%08X : ", baseaddr + offset);
+ if (size >= 16)
+ run = 16;
+ else
+ run = size;
+ size -= run;
+ for (i = 0; i < 16; i++) {
+ if (i < run)
+ printk(KERN_DEBUG"%02X ", (u32)data[i]);
+ else
+ printk(KERN_DEBUG" ");
+ }
+ printk(KERN_DEBUG": ");
+ for (i = 0; i < run; i++)
+ printk(KERN_DEBUG"%c",
+ isalnum(data[i]) ? data[i] : '.');
+ printk(KERN_DEBUG"\n");
+ data = &data[16];
+ offset += run;
+ }
+ printk(KERN_DEBUG"\n");
+}
+
+#if (_MV_DUMP > 1)
+static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag,
+ enum sas_protocol proto)
+{
+ u32 offset;
+ struct mvs_slot_info *slot = &mvi->slot_info[tag];
+
+ offset = slot->cmd_size + MVS_OAF_SZ +
+ MVS_CHIP_DISP->prd_size() * slot->n_elem;
+ dev_printk(KERN_DEBUG, mvi->dev, "+---->Status buffer[%d] :\n",
+ tag);
+ mvs_hexdump(32, (u8 *) slot->response,
+ (u32) slot->buf_dma + offset);
+}
+#endif
+
+static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
+ enum sas_protocol proto)
+{
+#if (_MV_DUMP > 1)
+ u32 sz, w_ptr;
+ u64 addr;
+ struct mvs_slot_info *slot = &mvi->slot_info[tag];
+
+ /*Delivery Queue */
+ sz = MVS_CHIP_SLOT_SZ;
+ w_ptr = slot->tx;
+ addr = mvi->tx_dma;
+ dev_printk(KERN_DEBUG, mvi->dev,
+ "Delivery Queue Size=%04d , WRT_PTR=%04X\n", sz, w_ptr);
+ dev_printk(KERN_DEBUG, mvi->dev,
+ "Delivery Queue Base Address=0x%llX (PA)"
+ "(tx_dma=0x%llX), Entry=%04d\n",
+ addr, (unsigned long long)mvi->tx_dma, w_ptr);
+ mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]),
+ (u32) mvi->tx_dma + sizeof(u32) * w_ptr);
+ /*Command List */
+ addr = mvi->slot_dma;
+ dev_printk(KERN_DEBUG, mvi->dev,
+ "Command List Base Address=0x%llX (PA)"
+ "(slot_dma=0x%llX), Header=%03d\n",
+ addr, (unsigned long long)slot->buf_dma, tag);
+ dev_printk(KERN_DEBUG, mvi->dev, "Command Header[%03d]:\n", tag);
+ /*mvs_cmd_hdr */
+ mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]),
+ (u32) mvi->slot_dma + tag * sizeof(struct mvs_cmd_hdr));
+ /*1.command table area */
+ dev_printk(KERN_DEBUG, mvi->dev, "+---->Command Table :\n");
+ mvs_hexdump(slot->cmd_size, (u8 *) slot->buf, (u32) slot->buf_dma);
+ /*2.open address frame area */
+ dev_printk(KERN_DEBUG, mvi->dev, "+---->Open Address Frame :\n");
+ mvs_hexdump(MVS_OAF_SZ, (u8 *) slot->buf + slot->cmd_size,
+ (u32) slot->buf_dma + slot->cmd_size);
+ /*3.status buffer */
+ mvs_hba_sb_dump(mvi, tag, proto);
+ /*4.PRD table */
+ dev_printk(KERN_DEBUG, mvi->dev, "+---->PRD table :\n");
+ mvs_hexdump(MVS_CHIP_DISP->prd_size() * slot->n_elem,
+ (u8 *) slot->buf + slot->cmd_size + MVS_OAF_SZ,
+ (u32) slot->buf_dma + slot->cmd_size + MVS_OAF_SZ);
+#endif
+}
+
+static void mvs_hba_cq_dump(struct mvs_info *mvi)
+{
+#if (_MV_DUMP > 2)
+ u64 addr;
+ void __iomem *regs = mvi->regs;
+ u32 entry = mvi->rx_cons + 1;
+ u32 rx_desc = le32_to_cpu(mvi->rx[entry]);
+
+ /*Completion Queue */
+ addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO);
+ dev_printk(KERN_DEBUG, mvi->dev, "Completion Task = 0x%p\n",
+ mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task);
+ dev_printk(KERN_DEBUG, mvi->dev,
+ "Completion List Base Address=0x%llX (PA), "
+ "CQ_Entry=%04d, CQ_WP=0x%08X\n",
+ addr, entry - 1, mvi->rx[0]);
+ mvs_hexdump(sizeof(u32), (u8 *)(&rx_desc),
+ mvi->rx_dma + sizeof(u32) * entry);
+#endif
+}
+
+void mvs_get_sas_addr(void *buf, u32 buflen)
+{
+ /*memcpy(buf, "\x50\x05\x04\x30\x11\xab\x64\x40", 8);*/
+}
+
+struct mvs_info *mvs_find_dev_mvi(struct domain_device *dev)
+{
+ unsigned long i = 0, j = 0, hi = 0;
+ struct sas_ha_struct *sha = dev->port->ha;
+ struct mvs_info *mvi = NULL;
+ struct asd_sas_phy *phy;
+
+ while (sha->sas_port[i]) {
+ if (sha->sas_port[i] == dev->port) {
+ phy = container_of(sha->sas_port[i]->phy_list.next,
+ struct asd_sas_phy, port_phy_el);
+ j = 0;
+ while (sha->sas_phy[j]) {
+ if (sha->sas_phy[j] == phy)
+ break;
+ j++;
+ }
+ break;
+ }
+ i++;
+ }
+ hi = j/((struct mvs_prv_info *)sha->lldd_ha)->n_phy;
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[hi];
+
+ return mvi;
+
+}
+
+/* FIXME */
+int mvs_find_dev_phyno(struct domain_device *dev, int *phyno)
+{
+ unsigned long i = 0, j = 0, n = 0, num = 0;
+ struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+ struct sas_ha_struct *sha = dev->port->ha;
+
+ while (sha->sas_port[i]) {
+ if (sha->sas_port[i] == dev->port) {
+ struct asd_sas_phy *phy;
+ list_for_each_entry(phy,
+ &sha->sas_port[i]->phy_list, port_phy_el) {
+ j = 0;
+ while (sha->sas_phy[j]) {
+ if (sha->sas_phy[j] == phy)
+ break;
+ j++;
+ }
+ phyno[n] = (j >= mvi->chip->n_phy) ?
+ (j - mvi->chip->n_phy) : j;
+ num++;
+ n++;
+ }
+ break;
+ }
+ i++;
+ }
+ return num;
+}
+
+static inline void mvs_free_reg_set(struct mvs_info *mvi,
+ struct mvs_device *dev)
+{
+ if (!dev) {
+ mv_printk("device has been free.\n");
+ return;
+ }
+ if (dev->runing_req != 0)
+ return;
+ if (dev->taskfileset == MVS_ID_NOT_MAPPED)
+ return;
+ MVS_CHIP_DISP->free_reg_set(mvi, &dev->taskfileset);
+}
+
+static inline u8 mvs_assign_reg_set(struct mvs_info *mvi,
+ struct mvs_device *dev)
+{
+ if (dev->taskfileset != MVS_ID_NOT_MAPPED)
+ return 0;
+ return MVS_CHIP_DISP->assign_reg_set(mvi, &dev->taskfileset);
+}
+
+void mvs_phys_reset(struct mvs_info *mvi, u32 phy_mask, int hard)
+{
+ u32 no;
+ for_each_phy(phy_mask, phy_mask, no) {
+ if (!(phy_mask & 1))
+ continue;
+ MVS_CHIP_DISP->phy_reset(mvi, no, hard);
+ }
+}
+
+/* FIXME: locking? */
+int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
+ void *funcdata)
+{
+ int rc = 0, phy_id = sas_phy->id;
+ u32 tmp, i = 0, hi;
+ struct sas_ha_struct *sha = sas_phy->ha;
+ struct mvs_info *mvi = NULL;
+
+ while (sha->sas_phy[i]) {
+ if (sha->sas_phy[i] == sas_phy)
+ break;
+ i++;
+ }
+ hi = i/((struct mvs_prv_info *)sha->lldd_ha)->n_phy;
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[hi];
+
+ switch (func) {
+ case PHY_FUNC_SET_LINK_RATE:
+ MVS_CHIP_DISP->phy_set_link_rate(mvi, phy_id, funcdata);
+ break;
+
+ case PHY_FUNC_HARD_RESET:
+ tmp = MVS_CHIP_DISP->read_phy_ctl(mvi, phy_id);
+ if (tmp & PHY_RST_HARD)
+ break;
+ MVS_CHIP_DISP->phy_reset(mvi, phy_id, 1);
+ break;
+
+ case PHY_FUNC_LINK_RESET:
+ MVS_CHIP_DISP->phy_enable(mvi, phy_id);
+ MVS_CHIP_DISP->phy_reset(mvi, phy_id, 0);
+ break;
+
+ case PHY_FUNC_DISABLE:
+ MVS_CHIP_DISP->phy_disable(mvi, phy_id);
+ break;
+ case PHY_FUNC_RELEASE_SPINUP_HOLD:
+ default:
+ rc = -EOPNOTSUPP;
+ }
+ msleep(200);
+ return rc;
+}
+
+void __devinit mvs_set_sas_addr(struct mvs_info *mvi, int port_id,
+ u32 off_lo, u32 off_hi, u64 sas_addr)
+{
+ u32 lo = (u32)sas_addr;
+ u32 hi = (u32)(sas_addr>>32);
+
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, port_id, off_lo);
+ MVS_CHIP_DISP->write_port_cfg_data(mvi, port_id, lo);
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, port_id, off_hi);
+ MVS_CHIP_DISP->write_port_cfg_data(mvi, port_id, hi);
+}
+
+static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)
+{
+ struct mvs_phy *phy = &mvi->phy[i];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+ struct sas_ha_struct *sas_ha;
+ if (!phy->phy_attached)
+ return;
+
+ if (!(phy->att_dev_info & PORT_DEV_TRGT_MASK)
+ && phy->phy_type & PORT_TYPE_SAS) {
+ return;
+ }
+
+ sas_ha = mvi->sas;
+ sas_ha->notify_phy_event(sas_phy, PHYE_OOB_DONE);
+
+ if (sas_phy->phy) {
+ struct sas_phy *sphy = sas_phy->phy;
+
+ sphy->negotiated_linkrate = sas_phy->linkrate;
+ sphy->minimum_linkrate = phy->minimum_linkrate;
+ sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
+ sphy->maximum_linkrate = phy->maximum_linkrate;
+ sphy->maximum_linkrate_hw = MVS_CHIP_DISP->phy_max_link_rate();
+ }
+
+ if (phy->phy_type & PORT_TYPE_SAS) {
+ struct sas_identify_frame *id;
+
+ id = (struct sas_identify_frame *)phy->frame_rcvd;
+ id->dev_type = phy->identify.device_type;
+ id->initiator_bits = SAS_PROTOCOL_ALL;
+ id->target_bits = phy->identify.target_port_protocols;
+ } else if (phy->phy_type & PORT_TYPE_SATA) {
+ /*Nothing*/
+ }
+ mv_dprintk("phy %d byte dmaded.\n", i + mvi->id * mvi->chip->n_phy);
+
+ sas_phy->frame_rcvd_size = phy->frame_rcvd_size;
+
+ mvi->sas->notify_port_event(sas_phy,
+ PORTE_BYTES_DMAED);
+}
+
+int mvs_slave_alloc(struct scsi_device *scsi_dev)
+{
+ struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
+ if (dev_is_sata(dev)) {
+ /* We don't need to rescan targets
+ * if REPORT_LUNS request is failed
+ */
+ if (scsi_dev->lun > 0)
+ return -ENXIO;
+ scsi_dev->tagged_supported = 1;
+ }
+
+ return sas_slave_alloc(scsi_dev);
+}
+
+int mvs_slave_configure(struct scsi_device *sdev)
+{
+ struct domain_device *dev = sdev_to_domain_dev(sdev);
+ int ret = sas_slave_configure(sdev);
+
+ if (ret)
+ return ret;
+ if (dev_is_sata(dev)) {
+ /* may set PIO mode */
+ #if MV_DISABLE_NCQ
+ struct ata_port *ap = dev->sata_dev.ap;
+ struct ata_device *adev = ap->link.device;
+ adev->flags |= ATA_DFLAG_NCQ_OFF;
+ scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 1);
+ #endif
+ }
+ return 0;
+}
+
+void mvs_scan_start(struct Scsi_Host *shost)
+{
+ int i, j;
+ unsigned short core_nr;
+ struct mvs_info *mvi;
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+
+ core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host;
+
+ for (j = 0; j < core_nr; j++) {
+ mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j];
+ for (i = 0; i < mvi->chip->n_phy; ++i)
+ mvs_bytes_dmaed(mvi, i);
+ }
+}
+
+int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time)
+{
+ /* give the phy enabling interrupt event time to come in (1s
+ * is empirically about all it takes) */
+ if (time < HZ)
+ return 0;
+ /* Wait for discovery to finish */
+ scsi_flush_work(shost);
+ return 1;
+}
+
+static int mvs_task_prep_smp(struct mvs_info *mvi,
+ struct mvs_task_exec_info *tei)
+{
+ int elem, rc, i;
+ struct sas_task *task = tei->task;
+ struct mvs_cmd_hdr *hdr = tei->hdr;
+ struct domain_device *dev = task->dev;
+ struct asd_sas_port *sas_port = dev->port;
+ struct scatterlist *sg_req, *sg_resp;
+ u32 req_len, resp_len, tag = tei->tag;
+ void *buf_tmp;
+ u8 *buf_oaf;
+ dma_addr_t buf_tmp_dma;
+ void *buf_prd;
+ struct mvs_slot_info *slot = &mvi->slot_info[tag];
+ u32 flags = (tei->n_elem << MCH_PRD_LEN_SHIFT);
+#if _MV_DUMP
+ u8 *buf_cmd;
+ void *from;
+#endif
+ /*
+ * DMA-map SMP request, response buffers
+ */
+ sg_req = &task->smp_task.smp_req;
+ elem = dma_map_sg(mvi->dev, sg_req, 1, PCI_DMA_TODEVICE);
+ if (!elem)
+ return -ENOMEM;
+ req_len = sg_dma_len(sg_req);
+
+ sg_resp = &task->smp_task.smp_resp;
+ elem = dma_map_sg(mvi->dev, sg_resp, 1, PCI_DMA_FROMDEVICE);
+ if (!elem) {
+ rc = -ENOMEM;
+ goto err_out;
+ }
+ resp_len = SB_RFB_MAX;
+
+ /* must be in dwords */
+ if ((req_len & 0x3) || (resp_len & 0x3)) {
+ rc = -EINVAL;
+ goto err_out_2;
+ }
+
+ /*
+ * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs
+ */
+
+ /* region 1: command table area (MVS_SSP_CMD_SZ bytes) ***** */
+ buf_tmp = slot->buf;
+ buf_tmp_dma = slot->buf_dma;
+
+#if _MV_DUMP
+ buf_cmd = buf_tmp;
+ hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma);
+ buf_tmp += req_len;
+ buf_tmp_dma += req_len;
+ slot->cmd_size = req_len;
+#else
+ hdr->cmd_tbl = cpu_to_le64(sg_dma_address(sg_req));
+#endif
+
+ /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */
+ buf_oaf = buf_tmp;
+ hdr->open_frame = cpu_to_le64(buf_tmp_dma);
+
+ buf_tmp += MVS_OAF_SZ;
+ buf_tmp_dma += MVS_OAF_SZ;
+
+ /* region 3: PRD table *********************************** */
+ buf_prd = buf_tmp;
+ if (tei->n_elem)
+ hdr->prd_tbl = cpu_to_le64(buf_tmp_dma);
+ else
+ hdr->prd_tbl = 0;
+
+ i = MVS_CHIP_DISP->prd_size() * tei->n_elem;
+ buf_tmp += i;
+ buf_tmp_dma += i;
+
+ /* region 4: status buffer (larger the PRD, smaller this buf) ****** */
+ slot->response = buf_tmp;
+ hdr->status_buf = cpu_to_le64(buf_tmp_dma);
+ if (mvi->flags & MVF_FLAG_SOC)
+ hdr->reserved[0] = 0;
+
+ /*
+ * Fill in TX ring and command slot header
+ */
+ slot->tx = mvi->tx_prod;
+ mvi->tx[mvi->tx_prod] = cpu_to_le32((TXQ_CMD_SMP << TXQ_CMD_SHIFT) |
+ TXQ_MODE_I | tag |
+ (sas_port->phy_mask << TXQ_PHY_SHIFT));
+
+ hdr->flags |= flags;
+ hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | ((req_len - 4) / 4));
+ hdr->tags = cpu_to_le32(tag);
+ hdr->data_len = 0;
+
+ /* generate open address frame hdr (first 12 bytes) */
+ /* initiator, SMP, ftype 1h */
+ buf_oaf[0] = (1 << 7) | (PROTOCOL_SMP << 4) | 0x01;
+ buf_oaf[1] = dev->linkrate & 0xf;
+ *(u16 *)(buf_oaf + 2) = 0xFFFF; /* SAS SPEC */
+ memcpy(buf_oaf + 4, dev->sas_addr, SAS_ADDR_SIZE);
+
+ /* fill in PRD (scatter/gather) table, if any */
+ MVS_CHIP_DISP->make_prd(task->scatter, tei->n_elem, buf_prd);
+
+#if _MV_DUMP
+ /* copy cmd table */
+ from = kmap_atomic(sg_page(sg_req), KM_IRQ0);
+ memcpy(buf_cmd, from + sg_req->offset, req_len);
+ kunmap_atomic(from, KM_IRQ0);
+#endif
+ return 0;
+
+err_out_2:
+ dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_resp, 1,
+ PCI_DMA_FROMDEVICE);
+err_out:
+ dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_req, 1,
+ PCI_DMA_TODEVICE);
+ return rc;
+}
+
+static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
+{
+ struct ata_queued_cmd *qc = task->uldd_task;
+
+ if (qc) {
+ if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
+ qc->tf.command == ATA_CMD_FPDMA_READ) {
+ *tag = qc->tag;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int mvs_task_prep_ata(struct mvs_info *mvi,
+ struct mvs_task_exec_info *tei)
+{
+ struct sas_task *task = tei->task;
+ struct domain_device *dev = task->dev;
+ struct mvs_device *mvi_dev = dev->lldd_dev;
+ struct mvs_cmd_hdr *hdr = tei->hdr;
+ struct asd_sas_port *sas_port = dev->port;
+ struct mvs_slot_info *slot;
+ void *buf_prd;
+ u32 tag = tei->tag, hdr_tag;
+ u32 flags, del_q;
+ void *buf_tmp;
+ u8 *buf_cmd, *buf_oaf;
+ dma_addr_t buf_tmp_dma;
+ u32 i, req_len, resp_len;
+ const u32 max_resp_len = SB_RFB_MAX;
+
+ if (mvs_assign_reg_set(mvi, mvi_dev) == MVS_ID_NOT_MAPPED) {
+ mv_dprintk("Have not enough regiset for dev %d.\n",
+ mvi_dev->device_id);
+ return -EBUSY;
+ }
+ slot = &mvi->slot_info[tag];
+ slot->tx = mvi->tx_prod;
+ del_q = TXQ_MODE_I | tag |
+ (TXQ_CMD_STP << TXQ_CMD_SHIFT) |
+ (sas_port->phy_mask << TXQ_PHY_SHIFT) |
+ (mvi_dev->taskfileset << TXQ_SRS_SHIFT);
+ mvi->tx[mvi->tx_prod] = cpu_to_le32(del_q);
+
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ if (task->data_dir == DMA_FROM_DEVICE)
+ flags = (MVS_CHIP_DISP->prd_count() << MCH_PRD_LEN_SHIFT);
+ else
+ flags = (tei->n_elem << MCH_PRD_LEN_SHIFT);
+#else
+ flags = (tei->n_elem << MCH_PRD_LEN_SHIFT);
+#endif
+ if (task->ata_task.use_ncq)
+ flags |= MCH_FPDMA;
+ if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) {
+ if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI)
+ flags |= MCH_ATAPI;
+ }
+
+ /* FIXME: fill in port multiplier number */
+
+ hdr->flags = cpu_to_le32(flags);
+
+ /* FIXME: the low order order 5 bits for the TAG if enable NCQ */
+ if (task->ata_task.use_ncq && mvs_get_ncq_tag(task, &hdr_tag))
+ task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3);
+ else
+ hdr_tag = tag;
+
+ hdr->tags = cpu_to_le32(hdr_tag);
+
+ hdr->data_len = cpu_to_le32(task->total_xfer_len);
+
+ /*
+ * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs
+ */
+
+ /* region 1: command table area (MVS_ATA_CMD_SZ bytes) ************** */
+ buf_cmd = buf_tmp = slot->buf;
+ buf_tmp_dma = slot->buf_dma;
+
+ hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma);
+
+ buf_tmp += MVS_ATA_CMD_SZ;
+ buf_tmp_dma += MVS_ATA_CMD_SZ;
+#if _MV_DUMP
+ slot->cmd_size = MVS_ATA_CMD_SZ;
+#endif
+
+ /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */
+ /* used for STP. unused for SATA? */
+ buf_oaf = buf_tmp;
+ hdr->open_frame = cpu_to_le64(buf_tmp_dma);
+
+ buf_tmp += MVS_OAF_SZ;
+ buf_tmp_dma += MVS_OAF_SZ;
+
+ /* region 3: PRD table ********************************************* */
+ buf_prd = buf_tmp;
+
+ if (tei->n_elem)
+ hdr->prd_tbl = cpu_to_le64(buf_tmp_dma);
+ else
+ hdr->prd_tbl = 0;
+ i = MVS_CHIP_DISP->prd_size() * MVS_CHIP_DISP->prd_count();
+
+ buf_tmp += i;
+ buf_tmp_dma += i;
+
+ /* region 4: status buffer (larger the PRD, smaller this buf) ****** */
+ /* FIXME: probably unused, for SATA. kept here just in case
+ * we get a STP/SATA error information record
+ */
+ slot->response = buf_tmp;
+ hdr->status_buf = cpu_to_le64(buf_tmp_dma);
+ if (mvi->flags & MVF_FLAG_SOC)
+ hdr->reserved[0] = 0;
+
+ req_len = sizeof(struct host_to_dev_fis);
+ resp_len = MVS_SLOT_BUF_SZ - MVS_ATA_CMD_SZ -
+ sizeof(struct mvs_err_info) - i;
+
+ /* request, response lengths */
+ resp_len = min(resp_len, max_resp_len);
+ hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | (req_len / 4));
+
+ if (likely(!task->ata_task.device_control_reg_update))
+ task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
+ /* fill in command FIS and ATAPI CDB */
+ memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis));
+ if (dev->sata_dev.command_set == ATAPI_COMMAND_SET)
+ memcpy(buf_cmd + STP_ATAPI_CMD,
+ task->ata_task.atapi_packet, 16);
+
+ /* generate open address frame hdr (first 12 bytes) */
+ /* initiator, STP, ftype 1h */
+ buf_oaf[0] = (1 << 7) | (PROTOCOL_STP << 4) | 0x1;
+ buf_oaf[1] = dev->linkrate & 0xf;
+ *(u16 *)(buf_oaf + 2) = cpu_to_be16(mvi_dev->device_id + 1);
+ memcpy(buf_oaf + 4, dev->sas_addr, SAS_ADDR_SIZE);
+
+ /* fill in PRD (scatter/gather) table, if any */
+ MVS_CHIP_DISP->make_prd(task->scatter, tei->n_elem, buf_prd);
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ if (task->data_dir == DMA_FROM_DEVICE)
+ MVS_CHIP_DISP->dma_fix(mvi->bulk_buffer_dma,
+ TRASH_BUCKET_SIZE, tei->n_elem, buf_prd);
+#endif
+ return 0;
+}
+
+static int mvs_task_prep_ssp(struct mvs_info *mvi,
+ struct mvs_task_exec_info *tei, int is_tmf,
+ struct mvs_tmf_task *tmf)
+{
+ struct sas_task *task = tei->task;
+ struct mvs_cmd_hdr *hdr = tei->hdr;
+ struct mvs_port *port = tei->port;
+ struct domain_device *dev = task->dev;
+ struct mvs_device *mvi_dev = dev->lldd_dev;
+ struct asd_sas_port *sas_port = dev->port;
+ struct mvs_slot_info *slot;
+ void *buf_prd;
+ struct ssp_frame_hdr *ssp_hdr;
+ void *buf_tmp;
+ u8 *buf_cmd, *buf_oaf, fburst = 0;
+ dma_addr_t buf_tmp_dma;
+ u32 flags;
+ u32 resp_len, req_len, i, tag = tei->tag;
+ const u32 max_resp_len = SB_RFB_MAX;
+ u32 phy_mask;
+
+ slot = &mvi->slot_info[tag];
+
+ phy_mask = ((port->wide_port_phymap) ? port->wide_port_phymap :
+ sas_port->phy_mask) & TXQ_PHY_MASK;
+
+ slot->tx = mvi->tx_prod;
+ mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag |
+ (TXQ_CMD_SSP << TXQ_CMD_SHIFT) |
+ (phy_mask << TXQ_PHY_SHIFT));
+
+ flags = MCH_RETRY;
+ if (task->ssp_task.enable_first_burst) {
+ flags |= MCH_FBURST;
+ fburst = (1 << 7);
+ }
+ if (is_tmf)
+ flags |= (MCH_SSP_FR_TASK << MCH_SSP_FR_TYPE_SHIFT);
+ else
+ flags |= (MCH_SSP_FR_CMD << MCH_SSP_FR_TYPE_SHIFT);
+ hdr->flags = cpu_to_le32(flags | (tei->n_elem << MCH_PRD_LEN_SHIFT));
+ hdr->tags = cpu_to_le32(tag);
+ hdr->data_len = cpu_to_le32(task->total_xfer_len);
+
+ /*
+ * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs
+ */
+
+ /* region 1: command table area (MVS_SSP_CMD_SZ bytes) ************** */
+ buf_cmd = buf_tmp = slot->buf;
+ buf_tmp_dma = slot->buf_dma;
+
+ hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma);
+
+ buf_tmp += MVS_SSP_CMD_SZ;
+ buf_tmp_dma += MVS_SSP_CMD_SZ;
+#if _MV_DUMP
+ slot->cmd_size = MVS_SSP_CMD_SZ;
+#endif
+
+ /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */
+ buf_oaf = buf_tmp;
+ hdr->open_frame = cpu_to_le64(buf_tmp_dma);
+
+ buf_tmp += MVS_OAF_SZ;
+ buf_tmp_dma += MVS_OAF_SZ;
+
+ /* region 3: PRD table ********************************************* */
+ buf_prd = buf_tmp;
+ if (tei->n_elem)
+ hdr->prd_tbl = cpu_to_le64(buf_tmp_dma);
+ else
+ hdr->prd_tbl = 0;
+
+ i = MVS_CHIP_DISP->prd_size() * tei->n_elem;
+ buf_tmp += i;
+ buf_tmp_dma += i;
+
+ /* region 4: status buffer (larger the PRD, smaller this buf) ****** */
+ slot->response = buf_tmp;
+ hdr->status_buf = cpu_to_le64(buf_tmp_dma);
+ if (mvi->flags & MVF_FLAG_SOC)
+ hdr->reserved[0] = 0;
+
+ resp_len = MVS_SLOT_BUF_SZ - MVS_SSP_CMD_SZ - MVS_OAF_SZ -
+ sizeof(struct mvs_err_info) - i;
+ resp_len = min(resp_len, max_resp_len);
+
+ req_len = sizeof(struct ssp_frame_hdr) + 28;
+
+ /* request, response lengths */
+ hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | (req_len / 4));
+
+ /* generate open address frame hdr (first 12 bytes) */
+ /* initiator, SSP, ftype 1h */
+ buf_oaf[0] = (1 << 7) | (PROTOCOL_SSP << 4) | 0x1;
+ buf_oaf[1] = dev->linkrate & 0xf;
+ *(u16 *)(buf_oaf + 2) = cpu_to_be16(mvi_dev->device_id + 1);
+ memcpy(buf_oaf + 4, dev->sas_addr, SAS_ADDR_SIZE);
+
+ /* fill in SSP frame header (Command Table.SSP frame header) */
+ ssp_hdr = (struct ssp_frame_hdr *)buf_cmd;
+
+ if (is_tmf)
+ ssp_hdr->frame_type = SSP_TASK;
+ else
+ ssp_hdr->frame_type = SSP_COMMAND;
+
+ memcpy(ssp_hdr->hashed_dest_addr, dev->hashed_sas_addr,
+ HASHED_SAS_ADDR_SIZE);
+ memcpy(ssp_hdr->hashed_src_addr,
+ dev->hashed_sas_addr, HASHED_SAS_ADDR_SIZE);
+ ssp_hdr->tag = cpu_to_be16(tag);
+
+ /* fill in IU for TASK and Command Frame */
+ buf_cmd += sizeof(*ssp_hdr);
+ memcpy(buf_cmd, &task->ssp_task.LUN, 8);
+
+ if (ssp_hdr->frame_type != SSP_TASK) {
+ buf_cmd[9] = fburst | task->ssp_task.task_attr |
+ (task->ssp_task.task_prio << 3);
+ memcpy(buf_cmd + 12, &task->ssp_task.cdb, 16);
+ } else{
+ buf_cmd[10] = tmf->tmf;
+ switch (tmf->tmf) {
+ case TMF_ABORT_TASK:
+ case TMF_QUERY_TASK:
+ buf_cmd[12] =
+ (tmf->tag_of_task_to_be_managed >> 8) & 0xff;
+ buf_cmd[13] =
+ tmf->tag_of_task_to_be_managed & 0xff;
+ break;
+ default:
+ break;
+ }
+ }
+ /* fill in PRD (scatter/gather) table, if any */
+ MVS_CHIP_DISP->make_prd(task->scatter, tei->n_elem, buf_prd);
+ return 0;
+}
+
+#define DEV_IS_GONE(mvi_dev) ((!mvi_dev || (mvi_dev->dev_type == NO_DEVICE)))
+static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags,
+ struct completion *completion,int is_tmf,
+ struct mvs_tmf_task *tmf)
+{
+ struct domain_device *dev = task->dev;
+ struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+ struct mvs_task_exec_info tei;
+ struct sas_task *t = task;
+ struct mvs_slot_info *slot;
+ u32 tag = 0xdeadbeef, rc, n_elem = 0;
+ u32 n = num, pass = 0;
+ unsigned long flags = 0;
+
+ if (!dev->port) {
+ struct task_status_struct *tsm = &t->task_status;
+
+ tsm->resp = SAS_TASK_UNDELIVERED;
+ tsm->stat = SAS_PHY_DOWN;
+ t->task_done(t);
+ return 0;
+ }
+
+ spin_lock_irqsave(&mvi->lock, flags);
+ do {
+ dev = t->dev;
+ mvi_dev = dev->lldd_dev;
+ if (DEV_IS_GONE(mvi_dev)) {
+ if (mvi_dev)
+ mv_dprintk("device %d not ready.\n",
+ mvi_dev->device_id);
+ else
+ mv_dprintk("device %016llx not ready.\n",
+ SAS_ADDR(dev->sas_addr));
+
+ rc = SAS_PHY_DOWN;
+ goto out_done;
+ }
+
+ if (dev->port->id >= mvi->chip->n_phy)
+ tei.port = &mvi->port[dev->port->id - mvi->chip->n_phy];
+ else
+ tei.port = &mvi->port[dev->port->id];
+
+ if (!tei.port->port_attached) {
+ if (sas_protocol_ata(t->task_proto)) {
+ mv_dprintk("port %d does not"
+ "attached device.\n", dev->port->id);
+ rc = SAS_PHY_DOWN;
+ goto out_done;
+ } else {
+ struct task_status_struct *ts = &t->task_status;
+ ts->resp = SAS_TASK_UNDELIVERED;
+ ts->stat = SAS_PHY_DOWN;
+ t->task_done(t);
+ if (n > 1)
+ t = list_entry(t->list.next,
+ struct sas_task, list);
+ continue;
+ }
+ }
+
+ if (!sas_protocol_ata(t->task_proto)) {
+ if (t->num_scatter) {
+ n_elem = dma_map_sg(mvi->dev,
+ t->scatter,
+ t->num_scatter,
+ t->data_dir);
+ if (!n_elem) {
+ rc = -ENOMEM;
+ goto err_out;
+ }
+ }
+ } else {
+ n_elem = t->num_scatter;
+ }
+
+ rc = mvs_tag_alloc(mvi, &tag);
+ if (rc)
+ goto err_out;
+
+ slot = &mvi->slot_info[tag];
+
+
+ t->lldd_task = NULL;
+ slot->n_elem = n_elem;
+ slot->slot_tag = tag;
+ memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
+
+ tei.task = t;
+ tei.hdr = &mvi->slot[tag];
+ tei.tag = tag;
+ tei.n_elem = n_elem;
+ switch (t->task_proto) {
+ case SAS_PROTOCOL_SMP:
+ rc = mvs_task_prep_smp(mvi, &tei);
+ break;
+ case SAS_PROTOCOL_SSP:
+ rc = mvs_task_prep_ssp(mvi, &tei, is_tmf, tmf);
+ break;
+ case SAS_PROTOCOL_SATA:
+ case SAS_PROTOCOL_STP:
+ case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
+ rc = mvs_task_prep_ata(mvi, &tei);
+ break;
+ default:
+ dev_printk(KERN_ERR, mvi->dev,
+ "unknown sas_task proto: 0x%x\n",
+ t->task_proto);
+ rc = -EINVAL;
+ break;
+ }
+
+ if (rc) {
+ mv_dprintk("rc is %x\n", rc);
+ goto err_out_tag;
+ }
+ slot->task = t;
+ slot->port = tei.port;
+ t->lldd_task = slot;
+ list_add_tail(&slot->entry, &tei.port->list);
+ /* TODO: select normal or high priority */
+ spin_lock(&t->task_state_lock);
+ t->task_state_flags |= SAS_TASK_AT_INITIATOR;
+ spin_unlock(&t->task_state_lock);
+
+ mvs_hba_memory_dump(mvi, tag, t->task_proto);
+ mvi_dev->runing_req++;
+ ++pass;
+ mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
+ if (n > 1)
+ t = list_entry(t->list.next, struct sas_task, list);
+ } while (--n);
+ rc = 0;
+ goto out_done;
+
+err_out_tag:
+ mvs_tag_free(mvi, tag);
+err_out:
+
+ dev_printk(KERN_ERR, mvi->dev, "mvsas exec failed[%d]!\n", rc);
+ if (!sas_protocol_ata(t->task_proto))
+ if (n_elem)
+ dma_unmap_sg(mvi->dev, t->scatter, n_elem,
+ t->data_dir);
+out_done:
+ if (likely(pass)) {
+ MVS_CHIP_DISP->start_delivery(mvi,
+ (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1));
+ }
+ spin_unlock_irqrestore(&mvi->lock, flags);
+ return rc;
+}
+
+int mvs_queue_command(struct sas_task *task, const int num,
+ gfp_t gfp_flags)
+{
+ return mvs_task_exec(task, num, gfp_flags, NULL, 0, NULL);
+}
+
+static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
+{
+ u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
+ mvs_tag_clear(mvi, slot_idx);
+}
+
+static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
+ struct mvs_slot_info *slot, u32 slot_idx)
+{
+ if (!slot->task)
+ return;
+ if (!sas_protocol_ata(task->task_proto))
+ if (slot->n_elem)
+ dma_unmap_sg(mvi->dev, task->scatter,
+ slot->n_elem, task->data_dir);
+
+ switch (task->task_proto) {
+ case SAS_PROTOCOL_SMP:
+ dma_unmap_sg(mvi->dev, &task->smp_task.smp_resp, 1,
+ PCI_DMA_FROMDEVICE);
+ dma_unmap_sg(mvi->dev, &task->smp_task.smp_req, 1,
+ PCI_DMA_TODEVICE);
+ break;
+
+ case SAS_PROTOCOL_SATA:
+ case SAS_PROTOCOL_STP:
+ case SAS_PROTOCOL_SSP:
+ default:
+ /* do nothing */
+ break;
+ }
+ list_del_init(&slot->entry);
+ task->lldd_task = NULL;
+ slot->task = NULL;
+ slot->port = NULL;
+ slot->slot_tag = 0xFFFFFFFF;
+ mvs_slot_free(mvi, slot_idx);
+}
+
+static void mvs_update_wideport(struct mvs_info *mvi, int i)
+{
+ struct mvs_phy *phy = &mvi->phy[i];
+ struct mvs_port *port = phy->port;
+ int j, no;
+
+ for_each_phy(port->wide_port_phymap, j, no) {
+ if (j & 1) {
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, no,
+ PHYR_WIDE_PORT);
+ MVS_CHIP_DISP->write_port_cfg_data(mvi, no,
+ port->wide_port_phymap);
+ } else {
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, no,
+ PHYR_WIDE_PORT);
+ MVS_CHIP_DISP->write_port_cfg_data(mvi, no,
+ 0);
+ }
+ }
+}
+
+static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i)
+{
+ u32 tmp;
+ struct mvs_phy *phy = &mvi->phy[i];
+ struct mvs_port *port = phy->port;
+
+ tmp = MVS_CHIP_DISP->read_phy_ctl(mvi, i);
+ if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) {
+ if (!port)
+ phy->phy_attached = 1;
+ return tmp;
+ }
+
+ if (port) {
+ if (phy->phy_type & PORT_TYPE_SAS) {
+ port->wide_port_phymap &= ~(1U << i);
+ if (!port->wide_port_phymap)
+ port->port_attached = 0;
+ mvs_update_wideport(mvi, i);
+ } else if (phy->phy_type & PORT_TYPE_SATA)
+ port->port_attached = 0;
+ phy->port = NULL;
+ phy->phy_attached = 0;
+ phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA);
+ }
+ return 0;
+}
+
+static void *mvs_get_d2h_reg(struct mvs_info *mvi, int i, void *buf)
+{
+ u32 *s = (u32 *) buf;
+
+ if (!s)
+ return NULL;
+
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, i, PHYR_SATA_SIG3);
+ s[3] = MVS_CHIP_DISP->read_port_cfg_data(mvi, i);
+
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, i, PHYR_SATA_SIG2);
+ s[2] = MVS_CHIP_DISP->read_port_cfg_data(mvi, i);
+
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, i, PHYR_SATA_SIG1);
+ s[1] = MVS_CHIP_DISP->read_port_cfg_data(mvi, i);
+
+ MVS_CHIP_DISP->write_port_cfg_addr(mvi, i, PHYR_SATA_SIG0);
+ s[0] = MVS_CHIP_DISP->read_port_cfg_data(mvi, i);
+
+ /* Workaround: take some ATAPI devices for ATA */
+ if (((s[1] & 0x00FFFFFF) == 0x00EB1401) && (*(u8 *)&s[3] == 0x01))
+ s[1] = 0x00EB1401 | (*((u8 *)&s[1] + 3) & 0x10);
+
+ return s;
+}
+
+static u32 mvs_is_sig_fis_received(u32 irq_status)
+{
+ return irq_status & PHYEV_SIG_FIS;
+}
+
+void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st)
+{
+ struct mvs_phy *phy = &mvi->phy[i];
+ struct sas_identify_frame *id;
+
+ id = (struct sas_identify_frame *)phy->frame_rcvd;
+
+ if (get_st) {
+ phy->irq_status = MVS_CHIP_DISP->read_port_irq_stat(mvi, i);
+ phy->phy_status = mvs_is_phy_ready(mvi, i);
+ }
+
+ if (phy->phy_status) {
+ int oob_done = 0;
+ struct asd_sas_phy *sas_phy = &mvi->phy[i].sas_phy;
+
+ oob_done = MVS_CHIP_DISP->oob_done(mvi, i);
+
+ MVS_CHIP_DISP->fix_phy_info(mvi, i, id);
+ if (phy->phy_type & PORT_TYPE_SATA) {
+ phy->identify.target_port_protocols = SAS_PROTOCOL_STP;
+ if (mvs_is_sig_fis_received(phy->irq_status)) {
+ phy->phy_attached = 1;
+ phy->att_dev_sas_addr =
+ i + mvi->id * mvi->chip->n_phy;
+ if (oob_done)
+ sas_phy->oob_mode = SATA_OOB_MODE;
+ phy->frame_rcvd_size =
+ sizeof(struct dev_to_host_fis);
+ mvs_get_d2h_reg(mvi, i, id);
+ } else {
+ u32 tmp;
+ dev_printk(KERN_DEBUG, mvi->dev,
+ "Phy%d : No sig fis\n", i);
+ tmp = MVS_CHIP_DISP->read_port_irq_mask(mvi, i);
+ MVS_CHIP_DISP->write_port_irq_mask(mvi, i,
+ tmp | PHYEV_SIG_FIS);
+ phy->phy_attached = 0;
+ phy->phy_type &= ~PORT_TYPE_SATA;
+ MVS_CHIP_DISP->phy_reset(mvi, i, 0);
+ goto out_done;
+ }
+ } else if (phy->phy_type & PORT_TYPE_SAS
+ || phy->att_dev_info & PORT_SSP_INIT_MASK) {
+ phy->phy_attached = 1;
+ phy->identify.device_type =
+ phy->att_dev_info & PORT_DEV_TYPE_MASK;
+
+ if (phy->identify.device_type == SAS_END_DEV)
+ phy->identify.target_port_protocols =
+ SAS_PROTOCOL_SSP;
+ else if (phy->identify.device_type != NO_DEVICE)
+ phy->identify.target_port_protocols =
+ SAS_PROTOCOL_SMP;
+ if (oob_done)
+ sas_phy->oob_mode = SAS_OOB_MODE;
+ phy->frame_rcvd_size =
+ sizeof(struct sas_identify_frame);
+ }
+ memcpy(sas_phy->attached_sas_addr,
+ &phy->att_dev_sas_addr, SAS_ADDR_SIZE);
+
+ if (MVS_CHIP_DISP->phy_work_around)
+ MVS_CHIP_DISP->phy_work_around(mvi, i);
+ }
+ mv_dprintk("port %d attach dev info is %x\n",
+ i + mvi->id * mvi->chip->n_phy, phy->att_dev_info);
+ mv_dprintk("port %d attach sas addr is %llx\n",
+ i + mvi->id * mvi->chip->n_phy, phy->att_dev_sas_addr);
+out_done:
+ if (get_st)
+ MVS_CHIP_DISP->write_port_irq_stat(mvi, i, phy->irq_status);
+}
+
+static void mvs_port_notify_formed(struct asd_sas_phy *sas_phy, int lock)
+{
+ struct sas_ha_struct *sas_ha = sas_phy->ha;
+ struct mvs_info *mvi = NULL; int i = 0, hi;
+ struct mvs_phy *phy = sas_phy->lldd_phy;
+ struct asd_sas_port *sas_port = sas_phy->port;
+ struct mvs_port *port;
+ unsigned long flags = 0;
+ if (!sas_port)
+ return;
+
+ while (sas_ha->sas_phy[i]) {
+ if (sas_ha->sas_phy[i] == sas_phy)
+ break;
+ i++;
+ }
+ hi = i/((struct mvs_prv_info *)sas_ha->lldd_ha)->n_phy;
+ mvi = ((struct mvs_prv_info *)sas_ha->lldd_ha)->mvi[hi];
+ if (sas_port->id >= mvi->chip->n_phy)
+ port = &mvi->port[sas_port->id - mvi->chip->n_phy];
+ else
+ port = &mvi->port[sas_port->id];
+ if (lock)
+ spin_lock_irqsave(&mvi->lock, flags);
+ port->port_attached = 1;
+ phy->port = port;
+ if (phy->phy_type & PORT_TYPE_SAS) {
+ port->wide_port_phymap = sas_port->phy_mask;
+ mv_printk("set wide port phy map %x\n", sas_port->phy_mask);
+ mvs_update_wideport(mvi, sas_phy->id);
+ }
+ if (lock)
+ spin_unlock_irqrestore(&mvi->lock, flags);
+}
+
+static void mvs_port_notify_deformed(struct asd_sas_phy *sas_phy, int lock)
+{
+ /*Nothing*/
+}
+
+
+void mvs_port_formed(struct asd_sas_phy *sas_phy)
+{
+ mvs_port_notify_formed(sas_phy, 1);
+}
+
+void mvs_port_deformed(struct asd_sas_phy *sas_phy)
+{
+ mvs_port_notify_deformed(sas_phy, 1);
+}
+
+struct mvs_device *mvs_alloc_dev(struct mvs_info *mvi)
+{
+ u32 dev;
+ for (dev = 0; dev < MVS_MAX_DEVICES; dev++) {
+ if (mvi->devices[dev].dev_type == NO_DEVICE) {
+ mvi->devices[dev].device_id = dev;
+ return &mvi->devices[dev];
+ }
+ }
+
+ if (dev == MVS_MAX_DEVICES)
+ mv_printk("max support %d devices, ignore ..\n",
+ MVS_MAX_DEVICES);
+
+ return NULL;
+}
+
+void mvs_free_dev(struct mvs_device *mvi_dev)
+{
+ u32 id = mvi_dev->device_id;
+ memset(mvi_dev, 0, sizeof(*mvi_dev));
+ mvi_dev->device_id = id;
+ mvi_dev->dev_type = NO_DEVICE;
+ mvi_dev->dev_status = MVS_DEV_NORMAL;
+ mvi_dev->taskfileset = MVS_ID_NOT_MAPPED;
+}
+
+int mvs_dev_found_notify(struct domain_device *dev, int lock)
+{
+ unsigned long flags = 0;
+ int res = 0;
+ struct mvs_info *mvi = NULL;
+ struct domain_device *parent_dev = dev->parent;
+ struct mvs_device *mvi_device;
+
+ mvi = mvs_find_dev_mvi(dev);
+
+ if (lock)
+ spin_lock_irqsave(&mvi->lock, flags);
+
+ mvi_device = mvs_alloc_dev(mvi);
+ if (!mvi_device) {
+ res = -1;
+ goto found_out;
+ }
+ dev->lldd_dev = mvi_device;
+ mvi_device->dev_type = dev->dev_type;
+ mvi_device->mvi_info = mvi;
+ if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) {
+ int phy_id;
+ u8 phy_num = parent_dev->ex_dev.num_phys;
+ struct ex_phy *phy;
+ for (phy_id = 0; phy_id < phy_num; phy_id++) {
+ phy = &parent_dev->ex_dev.ex_phy[phy_id];
+ if (SAS_ADDR(phy->attached_sas_addr) ==
+ SAS_ADDR(dev->sas_addr)) {
+ mvi_device->attached_phy = phy_id;
+ break;
+ }
+ }
+
+ if (phy_id == phy_num) {
+ mv_printk("Error: no attached dev:%016llx"
+ "at ex:%016llx.\n",
+ SAS_ADDR(dev->sas_addr),
+ SAS_ADDR(parent_dev->sas_addr));
+ res = -1;
+ }
+ }
+
+found_out:
+ if (lock)
+ spin_unlock_irqrestore(&mvi->lock, flags);
+ return res;
+}
+
+int mvs_dev_found(struct domain_device *dev)
+{
+ return mvs_dev_found_notify(dev, 1);
+}
+
+void mvs_dev_gone_notify(struct domain_device *dev, int lock)
+{
+ unsigned long flags = 0;
+ struct mvs_device *mvi_dev = dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+
+ if (lock)
+ spin_lock_irqsave(&mvi->lock, flags);
+
+ if (mvi_dev) {
+ mv_dprintk("found dev[%d:%x] is gone.\n",
+ mvi_dev->device_id, mvi_dev->dev_type);
+ mvs_free_reg_set(mvi, mvi_dev);
+ mvs_free_dev(mvi_dev);
+ } else {
+ mv_dprintk("found dev has gone.\n");
+ }
+ dev->lldd_dev = NULL;
+
+ if (lock)
+ spin_unlock_irqrestore(&mvi->lock, flags);
+}
+
+
+void mvs_dev_gone(struct domain_device *dev)
+{
+ mvs_dev_gone_notify(dev, 1);
+}
+
+static struct sas_task *mvs_alloc_task(void)
+{
+ struct sas_task *task = kzalloc(sizeof(struct sas_task), GFP_KERNEL);
+
+ if (task) {
+ INIT_LIST_HEAD(&task->list);
+ spin_lock_init(&task->task_state_lock);
+ task->task_state_flags = SAS_TASK_STATE_PENDING;
+ init_timer(&task->timer);
+ init_completion(&task->completion);
+ }
+ return task;
+}
+
+static void mvs_free_task(struct sas_task *task)
+{
+ if (task) {
+ BUG_ON(!list_empty(&task->list));
+ kfree(task);
+ }
+}
+
+static void mvs_task_done(struct sas_task *task)
+{
+ if (!del_timer(&task->timer))
+ return;
+ complete(&task->completion);
+}
+
+static void mvs_tmf_timedout(unsigned long data)
+{
+ struct sas_task *task = (struct sas_task *)data;
+
+ task->task_state_flags |= SAS_TASK_STATE_ABORTED;
+ complete(&task->completion);
+}
+
+/* XXX */
+#define MVS_TASK_TIMEOUT 20
+static int mvs_exec_internal_tmf_task(struct domain_device *dev,
+ void *parameter, u32 para_len, struct mvs_tmf_task *tmf)
+{
+ int res, retry;
+ struct sas_task *task = NULL;
+
+ for (retry = 0; retry < 3; retry++) {
+ task = mvs_alloc_task();
+ if (!task)
+ return -ENOMEM;
+
+ task->dev = dev;
+ task->task_proto = dev->tproto;
+
+ memcpy(&task->ssp_task, parameter, para_len);
+ task->task_done = mvs_task_done;
+
+ task->timer.data = (unsigned long) task;
+ task->timer.function = mvs_tmf_timedout;
+ task->timer.expires = jiffies + MVS_TASK_TIMEOUT*HZ;
+ add_timer(&task->timer);
+
+ res = mvs_task_exec(task, 1, GFP_KERNEL, NULL, 1, tmf);
+
+ if (res) {
+ del_timer(&task->timer);
+ mv_printk("executing internel task failed:%d\n", res);
+ goto ex_err;
+ }
+
+ wait_for_completion(&task->completion);
+ res = -TMF_RESP_FUNC_FAILED;
+ /* Even TMF timed out, return direct. */
+ if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
+ if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
+ mv_printk("TMF task[%x] timeout.\n", tmf->tmf);
+ goto ex_err;
+ }
+ }
+
+ if (task->task_status.resp == SAS_TASK_COMPLETE &&
+ task->task_status.stat == SAM_GOOD) {
+ res = TMF_RESP_FUNC_COMPLETE;
+ break;
+ }
+
+ if (task->task_status.resp == SAS_TASK_COMPLETE &&
+ task->task_status.stat == SAS_DATA_UNDERRUN) {
+ /* no error, but return the number of bytes of
+ * underrun */
+ res = task->task_status.residual;
+ break;
+ }
+
+ if (task->task_status.resp == SAS_TASK_COMPLETE &&
+ task->task_status.stat == SAS_DATA_OVERRUN) {
+ mv_dprintk("blocked task error.\n");
+ res = -EMSGSIZE;
+ break;
+ } else {
+ mv_dprintk(" task to dev %016llx response: 0x%x "
+ "status 0x%x\n",
+ SAS_ADDR(dev->sas_addr),
+ task->task_status.resp,
+ task->task_status.stat);
+ mvs_free_task(task);
+ task = NULL;
+
+ }
+ }
+ex_err:
+ BUG_ON(retry == 3 && task != NULL);
+ if (task != NULL)
+ mvs_free_task(task);
+ return res;
+}
+
+static int mvs_debug_issue_ssp_tmf(struct domain_device *dev,
+ u8 *lun, struct mvs_tmf_task *tmf)
+{
+ struct sas_ssp_task ssp_task;
+ DECLARE_COMPLETION_ONSTACK(completion);
+ if (!(dev->tproto & SAS_PROTOCOL_SSP))
+ return TMF_RESP_FUNC_ESUPP;
+
+ strncpy((u8 *)&ssp_task.LUN, lun, 8);
+
+ return mvs_exec_internal_tmf_task(dev, &ssp_task,
+ sizeof(ssp_task), tmf);
+}
+
+
+/* Standard mandates link reset for ATA (type 0)
+ and hard reset for SSP (type 1) , only for RECOVERY */
+static int mvs_debug_I_T_nexus_reset(struct domain_device *dev)
+{
+ int rc;
+ struct sas_phy *phy = sas_find_local_phy(dev);
+ int reset_type = (dev->dev_type == SATA_DEV ||
+ (dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
+ rc = sas_phy_reset(phy, reset_type);
+ msleep(2000);
+ return rc;
+}
+
+/* mandatory SAM-3 */
+int mvs_lu_reset(struct domain_device *dev, u8 *lun)
+{
+ unsigned long flags;
+ int i, phyno[WIDE_PORT_MAX_PHY], num , rc = TMF_RESP_FUNC_FAILED;
+ struct mvs_tmf_task tmf_task;
+ struct mvs_device * mvi_dev = dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+
+ tmf_task.tmf = TMF_LU_RESET;
+ mvi_dev->dev_status = MVS_DEV_EH;
+ rc = mvs_debug_issue_ssp_tmf(dev, lun, &tmf_task);
+ if (rc == TMF_RESP_FUNC_COMPLETE) {
+ num = mvs_find_dev_phyno(dev, phyno);
+ spin_lock_irqsave(&mvi->lock, flags);
+ for (i = 0; i < num; i++)
+ mvs_release_task(mvi, phyno[i], dev);
+ spin_unlock_irqrestore(&mvi->lock, flags);
+ }
+ /* If failed, fall-through I_T_Nexus reset */
+ mv_printk("%s for device[%x]:rc= %d\n", __func__,
+ mvi_dev->device_id, rc);
+ return rc;
+}
+
+int mvs_I_T_nexus_reset(struct domain_device *dev)
+{
+ unsigned long flags;
+ int i, phyno[WIDE_PORT_MAX_PHY], num , rc = TMF_RESP_FUNC_FAILED;
+ struct mvs_device * mvi_dev = (struct mvs_device *)dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+
+ if (mvi_dev->dev_status != MVS_DEV_EH)
+ return TMF_RESP_FUNC_COMPLETE;
+ rc = mvs_debug_I_T_nexus_reset(dev);
+ mv_printk("%s for device[%x]:rc= %d\n",
+ __func__, mvi_dev->device_id, rc);
+
+ /* housekeeper */
+ num = mvs_find_dev_phyno(dev, phyno);
+ spin_lock_irqsave(&mvi->lock, flags);
+ for (i = 0; i < num; i++)
+ mvs_release_task(mvi, phyno[i], dev);
+ spin_unlock_irqrestore(&mvi->lock, flags);
+
+ return rc;
+}
+/* optional SAM-3 */
+int mvs_query_task(struct sas_task *task)
+{
+ u32 tag;
+ struct scsi_lun lun;
+ struct mvs_tmf_task tmf_task;
+ int rc = TMF_RESP_FUNC_FAILED;
+
+ if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) {
+ struct scsi_cmnd * cmnd = (struct scsi_cmnd *)task->uldd_task;
+ struct domain_device *dev = task->dev;
+ struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+
+ int_to_scsilun(cmnd->device->lun, &lun);
+ rc = mvs_find_tag(mvi, task, &tag);
+ if (rc == 0) {
+ rc = TMF_RESP_FUNC_FAILED;
+ return rc;
+ }
+
+ tmf_task.tmf = TMF_QUERY_TASK;
+ tmf_task.tag_of_task_to_be_managed = cpu_to_le16(tag);
+
+ rc = mvs_debug_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
+ switch (rc) {
+ /* The task is still in Lun, release it then */
+ case TMF_RESP_FUNC_SUCC:
+ /* The task is not in Lun or failed, reset the phy */
+ case TMF_RESP_FUNC_FAILED:
+ case TMF_RESP_FUNC_COMPLETE:
+ break;
+ }
+ }
+ mv_printk("%s:rc= %d\n", __func__, rc);
+ return rc;
+}
+
+/* mandatory SAM-3, still need free task/slot info */
+int mvs_abort_task(struct sas_task *task)
+{
+ struct scsi_lun lun;
+ struct mvs_tmf_task tmf_task;
+ struct domain_device *dev = task->dev;
+ struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;
+ struct mvs_info *mvi = mvi_dev->mvi_info;
+ int rc = TMF_RESP_FUNC_FAILED;
+ unsigned long flags;
+ u32 tag;
+
+ if (mvi->exp_req)
+ mvi->exp_req--;
+ spin_lock_irqsave(&task->task_state_lock, flags);
+ if (task->task_state_flags & SAS_TASK_STATE_DONE) {
+ spin_unlock_irqrestore(&task->task_state_lock, flags);
+ rc = TMF_RESP_FUNC_COMPLETE;
+ goto out;
+ }
+ spin_unlock_irqrestore(&task->task_state_lock, flags);
+ if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) {
+ struct scsi_cmnd * cmnd = (struct scsi_cmnd *)task->uldd_task;
+
+ int_to_scsilun(cmnd->device->lun, &lun);
+ rc = mvs_find_tag(mvi, task, &tag);
+ if (rc == 0) {
+ mv_printk("No such tag in %s\n", __func__);
+ rc = TMF_RESP_FUNC_FAILED;
+ return rc;
+ }
+
+ tmf_task.tmf = TMF_ABORT_TASK;
+ tmf_task.tag_of_task_to_be_managed = cpu_to_le16(tag);
+
+ rc = mvs_debug_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
+
+ /* if successful, clear the task and callback forwards.*/
+ if (rc == TMF_RESP_FUNC_COMPLETE) {
+ u32 slot_no;
+ struct mvs_slot_info *slot;
+
+ if (task->lldd_task) {
+ slot = task->lldd_task;
+ slot_no = (u32) (slot - mvi->slot_info);
+ mvs_slot_complete(mvi, slot_no, 1);
+ }
+ }
+ } else if (task->task_proto & SAS_PROTOCOL_SATA ||
+ task->task_proto & SAS_PROTOCOL_STP) {
+ /* to do free register_set */
+ } else {
+ /* SMP */
+
+ }
+out:
+ if (rc != TMF_RESP_FUNC_COMPLETE)
+ mv_printk("%s:rc= %d\n", __func__, rc);
+ return rc;
+}
+
+int mvs_abort_task_set(struct domain_device *dev, u8 *lun)
+{
+ int rc = TMF_RESP_FUNC_FAILED;
+ struct mvs_tmf_task tmf_task;
+
+ tmf_task.tmf = TMF_ABORT_TASK_SET;
+ rc = mvs_debug_issue_ssp_tmf(dev, lun, &tmf_task);
+
+ return rc;
+}
+
+int mvs_clear_aca(struct domain_device *dev, u8 *lun)
+{
+ int rc = TMF_RESP_FUNC_FAILED;
+ struct mvs_tmf_task tmf_task;
+
+ tmf_task.tmf = TMF_CLEAR_ACA;
+ rc = mvs_debug_issue_ssp_tmf(dev, lun, &tmf_task);
+
+ return rc;
+}
+
+int mvs_clear_task_set(struct domain_device *dev, u8 *lun)
+{
+ int rc = TMF_RESP_FUNC_FAILED;
+ struct mvs_tmf_task tmf_task;
+
+ tmf_task.tmf = TMF_CLEAR_TASK_SET;
+ rc = mvs_debug_issue_ssp_tmf(dev, lun, &tmf_task);
+
+ return rc;
+}
+
+static int mvs_sata_done(struct mvs_info *mvi, struct sas_task *task,
+ u32 slot_idx, int err)
+{
+ struct mvs_device *mvi_dev = task->dev->lldd_dev;
+ struct task_status_struct *tstat = &task->task_status;
+ struct ata_task_resp *resp = (struct ata_task_resp *)tstat->buf;
+ int stat = SAM_GOOD;
+
+
+ resp->frame_len = sizeof(struct dev_to_host_fis);
+ memcpy(&resp->ending_fis[0],
+ SATA_RECEIVED_D2H_FIS(mvi_dev->taskfileset),
+ sizeof(struct dev_to_host_fis));
+ tstat->buf_valid_size = sizeof(*resp);
+ if (unlikely(err))
+ stat = SAS_PROTO_RESPONSE;
+ return stat;
+}
+
+static int mvs_slot_err(struct mvs_info *mvi, struct sas_task *task,
+ u32 slot_idx)
+{
+ struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
+ int stat;
+ u32 err_dw0 = le32_to_cpu(*(u32 *) (slot->response));
+ u32 tfs = 0;
+ enum mvs_port_type type = PORT_TYPE_SAS;
+
+ if (err_dw0 & CMD_ISS_STPD)
+ MVS_CHIP_DISP->issue_stop(mvi, type, tfs);
+
+ MVS_CHIP_DISP->command_active(mvi, slot_idx);
+
+ stat = SAM_CHECK_COND;
+ switch (task->task_proto) {
+ case SAS_PROTOCOL_SSP:
+ stat = SAS_ABORTED_TASK;
+ break;
+ case SAS_PROTOCOL_SMP:
+ stat = SAM_CHECK_COND;
+ break;
+
+ case SAS_PROTOCOL_SATA:
+ case SAS_PROTOCOL_STP:
+ case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
+ {
+ if (err_dw0 == 0x80400002)
+ mv_printk("find reserved error, why?\n");
+
+ task->ata_task.use_ncq = 0;
+ stat = SAS_PROTO_RESPONSE;
+ mvs_sata_done(mvi, task, slot_idx, 1);
+
+ }
+ break;
+ default:
+ break;
+ }
+
+ return stat;
+}
+
+int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
+{
+ u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
+ struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
+ struct sas_task *task = slot->task;
+ struct mvs_device *mvi_dev = NULL;
+ struct task_status_struct *tstat;
+
+ bool aborted;
+ void *to;
+ enum exec_status sts;
+
+ if (mvi->exp_req)
+ mvi->exp_req--;
+ if (unlikely(!task || !task->lldd_task))
+ return -1;
+
+ tstat = &task->task_status;
+ mvi_dev = task->dev->lldd_dev;
+
+ mvs_hba_cq_dump(mvi);
+
+ spin_lock(&task->task_state_lock);
+ task->task_state_flags &=
+ ~(SAS_TASK_STATE_PENDING | SAS_TASK_AT_INITIATOR);
+ task->task_state_flags |= SAS_TASK_STATE_DONE;
+ /* race condition*/
+ aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED;
+ spin_unlock(&task->task_state_lock);
+
+ memset(tstat, 0, sizeof(*tstat));
+ tstat->resp = SAS_TASK_COMPLETE;
+
+ if (unlikely(aborted)) {
+ tstat->stat = SAS_ABORTED_TASK;
+ if (mvi_dev)
+ mvi_dev->runing_req--;
+ if (sas_protocol_ata(task->task_proto))
+ mvs_free_reg_set(mvi, mvi_dev);
+
+ mvs_slot_task_free(mvi, task, slot, slot_idx);
+ return -1;
+ }
+
+ if (unlikely(!mvi_dev || !slot->port->port_attached || flags)) {
+ mv_dprintk("port has not device.\n");
+ tstat->stat = SAS_PHY_DOWN;
+ goto out;
+ }
+
+ /*
+ if (unlikely((rx_desc & RXQ_ERR) || (*(u64 *) slot->response))) {
+ mv_dprintk("Find device[%016llx] RXQ_ERR %X,
+ err info:%016llx\n",
+ SAS_ADDR(task->dev->sas_addr),
+ rx_desc, (u64)(*(u64 *) slot->response));
+ }
+ */
+
+ /* error info record present */
+ if (unlikely((rx_desc & RXQ_ERR) && (*(u64 *) slot->response))) {
+ tstat->stat = mvs_slot_err(mvi, task, slot_idx);
+ goto out;
+ }
+
+ switch (task->task_proto) {
+ case SAS_PROTOCOL_SSP:
+ /* hw says status == 0, datapres == 0 */
+ if (rx_desc & RXQ_GOOD) {
+ tstat->stat = SAM_GOOD;
+ tstat->resp = SAS_TASK_COMPLETE;
+ }
+ /* response frame present */
+ else if (rx_desc & RXQ_RSP) {
+ struct ssp_response_iu *iu = slot->response +
+ sizeof(struct mvs_err_info);
+ sas_ssp_task_response(mvi->dev, task, iu);
+ } else
+ tstat->stat = SAM_CHECK_COND;
+ break;
+
+ case SAS_PROTOCOL_SMP: {
+ struct scatterlist *sg_resp = &task->smp_task.smp_resp;
+ tstat->stat = SAM_GOOD;
+ to = kmap_atomic(sg_page(sg_resp), KM_IRQ0);
+ memcpy(to + sg_resp->offset,
+ slot->response + sizeof(struct mvs_err_info),
+ sg_dma_len(sg_resp));
+ kunmap_atomic(to, KM_IRQ0);
+ break;
+ }
+
+ case SAS_PROTOCOL_SATA:
+ case SAS_PROTOCOL_STP:
+ case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: {
+ tstat->stat = mvs_sata_done(mvi, task, slot_idx, 0);
+ break;
+ }
+
+ default:
+ tstat->stat = SAM_CHECK_COND;
+ break;
+ }
+
+out:
+ if (mvi_dev) {
+ mvi_dev->runing_req--;
+ if (sas_protocol_ata(task->task_proto))
+ mvs_free_reg_set(mvi, mvi_dev);
+ }
+ mvs_slot_task_free(mvi, task, slot, slot_idx);
+ sts = tstat->stat;
+
+ spin_unlock(&mvi->lock);
+ if (task->task_done)
+ task->task_done(task);
+ else
+ mv_dprintk("why has not task_done.\n");
+ spin_lock(&mvi->lock);
+
+ return sts;
+}
+
+void mvs_release_task(struct mvs_info *mvi,
+ int phy_no, struct domain_device *dev)
+{
+ int i = 0; u32 slot_idx;
+ struct mvs_phy *phy;
+ struct mvs_port *port;
+ struct mvs_slot_info *slot, *slot2;
+
+ phy = &mvi->phy[phy_no];
+ port = phy->port;
+ if (!port)
+ return;
+
+ list_for_each_entry_safe(slot, slot2, &port->list, entry) {
+ struct sas_task *task;
+ slot_idx = (u32) (slot - mvi->slot_info);
+ task = slot->task;
+
+ if (dev && task->dev != dev)
+ continue;
+
+ mv_printk("Release slot [%x] tag[%x], task [%p]:\n",
+ slot_idx, slot->slot_tag, task);
+
+ if (task->task_proto & SAS_PROTOCOL_SSP) {
+ mv_printk("attached with SSP task CDB[");
+ for (i = 0; i < 16; i++)
+ mv_printk(" %02x", task->ssp_task.cdb[i]);
+ mv_printk(" ]\n");
+ }
+
+ mvs_slot_complete(mvi, slot_idx, 1);
+ }
+}
+
+static void mvs_phy_disconnected(struct mvs_phy *phy)
+{
+ phy->phy_attached = 0;
+ phy->att_dev_info = 0;
+ phy->att_dev_sas_addr = 0;
+}
+
+static void mvs_work_queue(struct work_struct *work)
+{
+ struct delayed_work *dw = container_of(work, struct delayed_work, work);
+ struct mvs_wq *mwq = container_of(dw, struct mvs_wq, work_q);
+ struct mvs_info *mvi = mwq->mvi;
+ unsigned long flags;
+
+ spin_lock_irqsave(&mvi->lock, flags);
+ if (mwq->handler & PHY_PLUG_EVENT) {
+ u32 phy_no = (unsigned long) mwq->data;
+ struct sas_ha_struct *sas_ha = mvi->sas;
+ struct mvs_phy *phy = &mvi->phy[phy_no];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+
+ if (phy->phy_event & PHY_PLUG_OUT) {
+ u32 tmp;
+ struct sas_identify_frame *id;
+ id = (struct sas_identify_frame *)phy->frame_rcvd;
+ tmp = MVS_CHIP_DISP->read_phy_ctl(mvi, phy_no);
+ phy->phy_event &= ~PHY_PLUG_OUT;
+ if (!(tmp & PHY_READY_MASK)) {
+ sas_phy_disconnected(sas_phy);
+ mvs_phy_disconnected(phy);
+ sas_ha->notify_phy_event(sas_phy,
+ PHYE_LOSS_OF_SIGNAL);
+ mv_dprintk("phy%d Removed Device\n", phy_no);
+ } else {
+ MVS_CHIP_DISP->detect_porttype(mvi, phy_no);
+ mvs_update_phyinfo(mvi, phy_no, 1);
+ mvs_bytes_dmaed(mvi, phy_no);
+ mvs_port_notify_formed(sas_phy, 0);
+ mv_dprintk("phy%d Attached Device\n", phy_no);
+ }
+ }
+ }
+ list_del(&mwq->entry);
+ spin_unlock_irqrestore(&mvi->lock, flags);
+ kfree(mwq);
+}
+
+static int mvs_handle_event(struct mvs_info *mvi, void *data, int handler)
+{
+ struct mvs_wq *mwq;
+ int ret = 0;
+
+ mwq = kmalloc(sizeof(struct mvs_wq), GFP_ATOMIC);
+ if (mwq) {
+ mwq->mvi = mvi;
+ mwq->data = data;
+ mwq->handler = handler;
+ MV_INIT_DELAYED_WORK(&mwq->work_q, mvs_work_queue, mwq);
+ list_add_tail(&mwq->entry, &mvi->wq_list);
+ schedule_delayed_work(&mwq->work_q, HZ * 2);
+ } else
+ ret = -ENOMEM;
+
+ return ret;
+}
+
+static void mvs_sig_time_out(unsigned long tphy)
+{
+ struct mvs_phy *phy = (struct mvs_phy *)tphy;
+ struct mvs_info *mvi = phy->mvi;
+ u8 phy_no;
+
+ for (phy_no = 0; phy_no < mvi->chip->n_phy; phy_no++) {
+ if (&mvi->phy[phy_no] == phy) {
+ mv_dprintk("Get signature time out, reset phy %d\n",
+ phy_no+mvi->id*mvi->chip->n_phy);
+ MVS_CHIP_DISP->phy_reset(mvi, phy_no, 1);
+ }
+ }
+}
+
+static void mvs_sig_remove_timer(struct mvs_phy *phy)
+{
+ if (phy->timer.function)
+ del_timer(&phy->timer);
+ phy->timer.function = NULL;
+}
+
+void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events)
+{
+ u32 tmp;
+ struct sas_ha_struct *sas_ha = mvi->sas;
+ struct mvs_phy *phy = &mvi->phy[phy_no];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+
+ phy->irq_status = MVS_CHIP_DISP->read_port_irq_stat(mvi, phy_no);
+ mv_dprintk("port %d ctrl sts=0x%X.\n", phy_no+mvi->id*mvi->chip->n_phy,
+ MVS_CHIP_DISP->read_phy_ctl(mvi, phy_no));
+ mv_dprintk("Port %d irq sts = 0x%X\n", phy_no+mvi->id*mvi->chip->n_phy,
+ phy->irq_status);
+
+ /*
+ * events is port event now ,
+ * we need check the interrupt status which belongs to per port.
+ */
+
+ if (phy->irq_status & PHYEV_DCDR_ERR)
+ mv_dprintk("port %d STP decoding error.\n",
+ phy_no+mvi->id*mvi->chip->n_phy);
+
+ if (phy->irq_status & PHYEV_POOF) {
+ if (!(phy->phy_event & PHY_PLUG_OUT)) {
+ int dev_sata = phy->phy_type & PORT_TYPE_SATA;
+ int ready;
+ mvs_release_task(mvi, phy_no, NULL);
+ phy->phy_event |= PHY_PLUG_OUT;
+ mvs_handle_event(mvi,
+ (void *)(unsigned long)phy_no,
+ PHY_PLUG_EVENT);
+ ready = mvs_is_phy_ready(mvi, phy_no);
+ if (!ready)
+ mv_dprintk("phy%d Unplug Notice\n",
+ phy_no +
+ mvi->id * mvi->chip->n_phy);
+ if (ready || dev_sata) {
+ if (MVS_CHIP_DISP->stp_reset)
+ MVS_CHIP_DISP->stp_reset(mvi,
+ phy_no);
+ else
+ MVS_CHIP_DISP->phy_reset(mvi,
+ phy_no, 0);
+ return;
+ }
+ }
+ }
+
+ if (phy->irq_status & PHYEV_COMWAKE) {
+ tmp = MVS_CHIP_DISP->read_port_irq_mask(mvi, phy_no);
+ MVS_CHIP_DISP->write_port_irq_mask(mvi, phy_no,
+ tmp | PHYEV_SIG_FIS);
+ if (phy->timer.function == NULL) {
+ phy->timer.data = (unsigned long)phy;
+ phy->timer.function = mvs_sig_time_out;
+ phy->timer.expires = jiffies + 10*HZ;
+ add_timer(&phy->timer);
+ }
+ }
+ if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) {
+ phy->phy_status = mvs_is_phy_ready(mvi, phy_no);
+ mvs_sig_remove_timer(phy);
+ mv_dprintk("notify plug in on phy[%d]\n", phy_no);
+ if (phy->phy_status) {
+ mdelay(10);
+ MVS_CHIP_DISP->detect_porttype(mvi, phy_no);
+ if (phy->phy_type & PORT_TYPE_SATA) {
+ tmp = MVS_CHIP_DISP->read_port_irq_mask(
+ mvi, phy_no);
+ tmp &= ~PHYEV_SIG_FIS;
+ MVS_CHIP_DISP->write_port_irq_mask(mvi,
+ phy_no, tmp);
+ }
+ mvs_update_phyinfo(mvi, phy_no, 0);
+ mvs_bytes_dmaed(mvi, phy_no);
+ /* whether driver is going to handle hot plug */
+ if (phy->phy_event & PHY_PLUG_OUT) {
+ mvs_port_notify_formed(sas_phy, 0);
+ phy->phy_event &= ~PHY_PLUG_OUT;
+ }
+ } else {
+ mv_dprintk("plugin interrupt but phy%d is gone\n",
+ phy_no + mvi->id*mvi->chip->n_phy);
+ }
+ } else if (phy->irq_status & PHYEV_BROAD_CH) {
+ mv_dprintk("port %d broadcast change.\n",
+ phy_no + mvi->id*mvi->chip->n_phy);
+ /* exception for Samsung disk drive*/
+ mdelay(1000);
+ sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
+ }
+ MVS_CHIP_DISP->write_port_irq_stat(mvi, phy_no, phy->irq_status);
+}
+
+int mvs_int_rx(struct mvs_info *mvi, bool self_clear)
+{
+ u32 rx_prod_idx, rx_desc;
+ bool attn = false;
+
+ /* the first dword in the RX ring is special: it contains
+ * a mirror of the hardware's RX producer index, so that
+ * we don't have to stall the CPU reading that register.
+ * The actual RX ring is offset by one dword, due to this.
+ */
+ rx_prod_idx = mvi->rx_cons;
+ mvi->rx_cons = le32_to_cpu(mvi->rx[0]);
+ if (mvi->rx_cons == 0xfff) /* h/w hasn't touched RX ring yet */
+ return 0;
+
+ /* The CMPL_Q may come late, read from register and try again
+ * note: if coalescing is enabled,
+ * it will need to read from register every time for sure
+ */
+ if (unlikely(mvi->rx_cons == rx_prod_idx))
+ mvi->rx_cons = MVS_CHIP_DISP->rx_update(mvi) & RX_RING_SZ_MASK;
+
+ if (mvi->rx_cons == rx_prod_idx)
+ return 0;
+
+ while (mvi->rx_cons != rx_prod_idx) {
+ /* increment our internal RX consumer pointer */
+ rx_prod_idx = (rx_prod_idx + 1) & (MVS_RX_RING_SZ - 1);
+ rx_desc = le32_to_cpu(mvi->rx[rx_prod_idx + 1]);
+
+ if (likely(rx_desc & RXQ_DONE))
+ mvs_slot_complete(mvi, rx_desc, 0);
+ if (rx_desc & RXQ_ATTN) {
+ attn = true;
+ } else if (rx_desc & RXQ_ERR) {
+ if (!(rx_desc & RXQ_DONE))
+ mvs_slot_complete(mvi, rx_desc, 0);
+ } else if (rx_desc & RXQ_SLOT_RESET) {
+ mvs_slot_free(mvi, rx_desc);
+ }
+ }
+
+ if (attn && self_clear)
+ MVS_CHIP_DISP->int_full(mvi);
+ return 0;
+}
+
diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
new file mode 100644
index 000000000000..aa2270af1bac
--- /dev/null
+++ b/drivers/scsi/mvsas/mv_sas.h
@@ -0,0 +1,406 @@
+/*
+ * Marvell 88SE64xx/88SE94xx main function head file
+ *
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2008 Marvell. <kewei@marvell.com>
+ *
+ * This file is licensed under GPLv2.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+*/
+
+#ifndef _MV_SAS_H_
+#define _MV_SAS_H_
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/ctype.h>
+#include <linux/dma-mapping.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/vmalloc.h>
+#include <scsi/libsas.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/sas_ata.h>
+#include <linux/version.h>
+#include "mv_defs.h"
+
+#define DRV_NAME "mvsas"
+#define DRV_VERSION "0.8.2"
+#define _MV_DUMP 0
+#define MVS_ID_NOT_MAPPED 0x7f
+/* #define DISABLE_HOTPLUG_DMA_FIX */
+#define MAX_EXP_RUNNING_REQ 2
+#define WIDE_PORT_MAX_PHY 4
+#define MV_DISABLE_NCQ 0
+#define mv_printk(fmt, arg ...) \
+ printk(KERN_DEBUG"%s %d:" fmt, __FILE__, __LINE__, ## arg)
+#ifdef MV_DEBUG
+#define mv_dprintk(format, arg...) \
+ printk(KERN_DEBUG"%s %d:" format, __FILE__, __LINE__, ## arg)
+#else
+#define mv_dprintk(format, arg...)
+#endif
+#define MV_MAX_U32 0xffffffff
+
+extern struct mvs_tgt_initiator mvs_tgt;
+extern struct mvs_info *tgt_mvi;
+extern const struct mvs_dispatch mvs_64xx_dispatch;
+extern const struct mvs_dispatch mvs_94xx_dispatch;
+
+#define DEV_IS_EXPANDER(type) \
+ ((type == EDGE_DEV) || (type == FANOUT_DEV))
+
+#define bit(n) ((u32)1 << n)
+
+#define for_each_phy(__lseq_mask, __mc, __lseq) \
+ for ((__mc) = (__lseq_mask), (__lseq) = 0; \
+ (__mc) != 0 ; \
+ (++__lseq), (__mc) >>= 1)
+
+#define MV_INIT_DELAYED_WORK(w, f, d) INIT_DELAYED_WORK(w, f)
+#define UNASSOC_D2H_FIS(id) \
+ ((void *) mvi->rx_fis + 0x100 * id)
+#define SATA_RECEIVED_FIS_LIST(reg_set) \
+ ((void *) mvi->rx_fis + mvi->chip->fis_offs + 0x100 * reg_set)
+#define SATA_RECEIVED_SDB_FIS(reg_set) \
+ (SATA_RECEIVED_FIS_LIST(reg_set) + 0x58)
+#define SATA_RECEIVED_D2H_FIS(reg_set) \
+ (SATA_RECEIVED_FIS_LIST(reg_set) + 0x40)
+#define SATA_RECEIVED_PIO_FIS(reg_set) \
+ (SATA_RECEIVED_FIS_LIST(reg_set) + 0x20)
+#define SATA_RECEIVED_DMA_FIS(reg_set) \
+ (SATA_RECEIVED_FIS_LIST(reg_set) + 0x00)
+
+enum dev_status {
+ MVS_DEV_NORMAL = 0x0,
+ MVS_DEV_EH = 0x1,
+};
+
+
+struct mvs_info;
+
+struct mvs_dispatch {
+ char *name;
+ int (*chip_init)(struct mvs_info *mvi);
+ int (*spi_init)(struct mvs_info *mvi);
+ int (*chip_ioremap)(struct mvs_info *mvi);
+ void (*chip_iounmap)(struct mvs_info *mvi);
+ irqreturn_t (*isr)(struct mvs_info *mvi, int irq, u32 stat);
+ u32 (*isr_status)(struct mvs_info *mvi, int irq);
+ void (*interrupt_enable)(struct mvs_info *mvi);
+ void (*interrupt_disable)(struct mvs_info *mvi);
+
+ u32 (*read_phy_ctl)(struct mvs_info *mvi, u32 port);
+ void (*write_phy_ctl)(struct mvs_info *mvi, u32 port, u32 val);
+
+ u32 (*read_port_cfg_data)(struct mvs_info *mvi, u32 port);
+ void (*write_port_cfg_data)(struct mvs_info *mvi, u32 port, u32 val);
+ void (*write_port_cfg_addr)(struct mvs_info *mvi, u32 port, u32 addr);
+
+ u32 (*read_port_vsr_data)(struct mvs_info *mvi, u32 port);
+ void (*write_port_vsr_data)(struct mvs_info *mvi, u32 port, u32 val);
+ void (*write_port_vsr_addr)(struct mvs_info *mvi, u32 port, u32 addr);
+
+ u32 (*read_port_irq_stat)(struct mvs_info *mvi, u32 port);
+ void (*write_port_irq_stat)(struct mvs_info *mvi, u32 port, u32 val);
+
+ u32 (*read_port_irq_mask)(struct mvs_info *mvi, u32 port);
+ void (*write_port_irq_mask)(struct mvs_info *mvi, u32 port, u32 val);
+
+ void (*get_sas_addr)(void *buf, u32 buflen);
+ void (*command_active)(struct mvs_info *mvi, u32 slot_idx);
+ void (*issue_stop)(struct mvs_info *mvi, enum mvs_port_type type,
+ u32 tfs);
+ void (*start_delivery)(struct mvs_info *mvi, u32 tx);
+ u32 (*rx_update)(struct mvs_info *mvi);
+ void (*int_full)(struct mvs_info *mvi);
+ u8 (*assign_reg_set)(struct mvs_info *mvi, u8 *tfs);
+ void (*free_reg_set)(struct mvs_info *mvi, u8 *tfs);
+ u32 (*prd_size)(void);
+ u32 (*prd_count)(void);
+ void (*make_prd)(struct scatterlist *scatter, int nr, void *prd);
+ void (*detect_porttype)(struct mvs_info *mvi, int i);
+ int (*oob_done)(struct mvs_info *mvi, int i);
+ void (*fix_phy_info)(struct mvs_info *mvi, int i,
+ struct sas_identify_frame *id);
+ void (*phy_work_around)(struct mvs_info *mvi, int i);
+ void (*phy_set_link_rate)(struct mvs_info *mvi, u32 phy_id,
+ struct sas_phy_linkrates *rates);
+ u32 (*phy_max_link_rate)(void);
+ void (*phy_disable)(struct mvs_info *mvi, u32 phy_id);
+ void (*phy_enable)(struct mvs_info *mvi, u32 phy_id);
+ void (*phy_reset)(struct mvs_info *mvi, u32 phy_id, int hard);
+ void (*stp_reset)(struct mvs_info *mvi, u32 phy_id);
+ void (*clear_active_cmds)(struct mvs_info *mvi);
+ u32 (*spi_read_data)(struct mvs_info *mvi);
+ void (*spi_write_data)(struct mvs_info *mvi, u32 data);
+ int (*spi_buildcmd)(struct mvs_info *mvi,
+ u32 *dwCmd,
+ u8 cmd,
+ u8 read,
+ u8 length,
+ u32 addr
+ );
+ int (*spi_issuecmd)(struct mvs_info *mvi, u32 cmd);
+ int (*spi_waitdataready)(struct mvs_info *mvi, u32 timeout);
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ void (*dma_fix)(dma_addr_t buf_dma, int buf_len, int from, void *prd);
+#endif
+
+};
+
+struct mvs_chip_info {
+ u32 n_host;
+ u32 n_phy;
+ u32 fis_offs;
+ u32 fis_count;
+ u32 srs_sz;
+ u32 slot_width;
+ const struct mvs_dispatch *dispatch;
+};
+#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width)
+#define MVS_RX_FISL_SZ \
+ (mvi->chip->fis_offs + (mvi->chip->fis_count * 0x100))
+#define MVS_CHIP_DISP (mvi->chip->dispatch)
+
+struct mvs_err_info {
+ __le32 flags;
+ __le32 flags2;
+};
+
+struct mvs_cmd_hdr {
+ __le32 flags; /* PRD tbl len; SAS, SATA ctl */
+ __le32 lens; /* cmd, max resp frame len */
+ __le32 tags; /* targ port xfer tag; tag */
+ __le32 data_len; /* data xfer len */
+ __le64 cmd_tbl; /* command table address */
+ __le64 open_frame; /* open addr frame address */
+ __le64 status_buf; /* status buffer address */
+ __le64 prd_tbl; /* PRD tbl address */
+ __le32 reserved[4];
+};
+
+struct mvs_port {
+ struct asd_sas_port sas_port;
+ u8 port_attached;
+ u8 wide_port_phymap;
+ struct list_head list;
+};
+
+struct mvs_phy {
+ struct mvs_info *mvi;
+ struct mvs_port *port;
+ struct asd_sas_phy sas_phy;
+ struct sas_identify identify;
+ struct scsi_device *sdev;
+ struct timer_list timer;
+ u64 dev_sas_addr;
+ u64 att_dev_sas_addr;
+ u32 att_dev_info;
+ u32 dev_info;
+ u32 phy_type;
+ u32 phy_status;
+ u32 irq_status;
+ u32 frame_rcvd_size;
+ u8 frame_rcvd[32];
+ u8 phy_attached;
+ u8 phy_mode;
+ u8 reserved[2];
+ u32 phy_event;
+ enum sas_linkrate minimum_linkrate;
+ enum sas_linkrate maximum_linkrate;
+};
+
+struct mvs_device {
+ struct list_head dev_entry;
+ enum sas_dev_type dev_type;
+ struct mvs_info *mvi_info;
+ struct domain_device *sas_device;
+ u32 attached_phy;
+ u32 device_id;
+ u32 runing_req;
+ u8 taskfileset;
+ u8 dev_status;
+ u16 reserved;
+};
+
+struct mvs_slot_info {
+ struct list_head entry;
+ union {
+ struct sas_task *task;
+ void *tdata;
+ };
+ u32 n_elem;
+ u32 tx;
+ u32 slot_tag;
+
+ /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
+ * and PRD table
+ */
+ void *buf;
+ dma_addr_t buf_dma;
+#if _MV_DUMP
+ u32 cmd_size;
+#endif
+ void *response;
+ struct mvs_port *port;
+ struct mvs_device *device;
+ void *open_frame;
+};
+
+struct mvs_info {
+ unsigned long flags;
+
+ /* host-wide lock */
+ spinlock_t lock;
+
+ /* our device */
+ struct pci_dev *pdev;
+ struct device *dev;
+
+ /* enhanced mode registers */
+ void __iomem *regs;
+
+ /* peripheral or soc registers */
+ void __iomem *regs_ex;
+ u8 sas_addr[SAS_ADDR_SIZE];
+
+ /* SCSI/SAS glue */
+ struct sas_ha_struct *sas;
+ struct Scsi_Host *shost;
+
+ /* TX (delivery) DMA ring */
+ __le32 *tx;
+ dma_addr_t tx_dma;
+
+ /* cached next-producer idx */
+ u32 tx_prod;
+
+ /* RX (completion) DMA ring */
+ __le32 *rx;
+ dma_addr_t rx_dma;
+
+ /* RX consumer idx */
+ u32 rx_cons;
+
+ /* RX'd FIS area */
+ __le32 *rx_fis;
+ dma_addr_t rx_fis_dma;
+
+ /* DMA command header slots */
+ struct mvs_cmd_hdr *slot;
+ dma_addr_t slot_dma;
+
+ u32 chip_id;
+ const struct mvs_chip_info *chip;
+
+ int tags_num;
+ DECLARE_BITMAP(tags, MVS_SLOTS);
+ /* further per-slot information */
+ struct mvs_phy phy[MVS_MAX_PHYS];
+ struct mvs_port port[MVS_MAX_PHYS];
+ u32 irq;
+ u32 exp_req;
+ u32 id;
+ u64 sata_reg_set;
+ struct list_head *hba_list;
+ struct list_head soc_entry;
+ struct list_head wq_list;
+ unsigned long instance;
+ u16 flashid;
+ u32 flashsize;
+ u32 flashsectSize;
+
+ void *addon;
+ struct mvs_device devices[MVS_MAX_DEVICES];
+#ifndef DISABLE_HOTPLUG_DMA_FIX
+ void *bulk_buffer;
+ dma_addr_t bulk_buffer_dma;
+#define TRASH_BUCKET_SIZE 0x20000
+#endif
+ struct mvs_slot_info slot_info[0];
+};
+
+struct mvs_prv_info{
+ u8 n_host;
+ u8 n_phy;
+ u16 reserve;
+ struct mvs_info *mvi[2];
+};
+
+struct mvs_wq {
+ struct delayed_work work_q;
+ struct mvs_info *mvi;
+ void *data;
+ int handler;
+ struct list_head entry;
+};
+
+struct mvs_task_exec_info {
+ struct sas_task *task;
+ struct mvs_cmd_hdr *hdr;
+ struct mvs_port *port;
+ u32 tag;
+ int n_elem;
+};
+
+
+/******************** function prototype *********************/
+void mvs_get_sas_addr(void *buf, u32 buflen);
+void mvs_tag_clear(struct mvs_info *mvi, u32 tag);
+void mvs_tag_free(struct mvs_info *mvi, u32 tag);
+void mvs_tag_set(struct mvs_info *mvi, unsigned int tag);
+int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out);
+void mvs_tag_init(struct mvs_info *mvi);
+void mvs_iounmap(void __iomem *regs);
+int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex);
+void mvs_phys_reset(struct mvs_info *mvi, u32 phy_mask, int hard);
+int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
+ void *funcdata);
+void __devinit mvs_set_sas_addr(struct mvs_info *mvi, int port_id,
+ u32 off_lo, u32 off_hi, u64 sas_addr);
+int mvs_slave_alloc(struct scsi_device *scsi_dev);
+int mvs_slave_configure(struct scsi_device *sdev);
+void mvs_scan_start(struct Scsi_Host *shost);
+int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time);
+int mvs_queue_command(struct sas_task *task, const int num,
+ gfp_t gfp_flags);
+int mvs_abort_task(struct sas_task *task);
+int mvs_abort_task_set(struct domain_device *dev, u8 *lun);
+int mvs_clear_aca(struct domain_device *dev, u8 *lun);
+int mvs_clear_task_set(struct domain_device *dev, u8 * lun);
+void mvs_port_formed(struct asd_sas_phy *sas_phy);
+void mvs_port_deformed(struct asd_sas_phy *sas_phy);
+int mvs_dev_found(struct domain_device *dev);
+void mvs_dev_gone(struct domain_device *dev);
+int mvs_lu_reset(struct domain_device *dev, u8 *lun);
+int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags);
+int mvs_I_T_nexus_reset(struct domain_device *dev);
+int mvs_query_task(struct sas_task *task);
+void mvs_release_task(struct mvs_info *mvi, int phy_no,
+ struct domain_device *dev);
+void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events);
+void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st);
+int mvs_int_rx(struct mvs_info *mvi, bool self_clear);
+void mvs_hexdump(u32 size, u8 *data, u32 baseaddr);
+#endif
+
diff --git a/drivers/scsi/osd/Kbuild b/drivers/scsi/osd/Kbuild
index 0e207aa67d16..5fd73d77c3af 100644
--- a/drivers/scsi/osd/Kbuild
+++ b/drivers/scsi/osd/Kbuild
@@ -11,31 +11,6 @@
# it under the terms of the GNU General Public License version 2
#
-ifneq ($(OSD_INC),)
-# we are built out-of-tree Kconfigure everything as on
-
-CONFIG_SCSI_OSD_INITIATOR=m
-ccflags-y += -DCONFIG_SCSI_OSD_INITIATOR -DCONFIG_SCSI_OSD_INITIATOR_MODULE
-
-CONFIG_SCSI_OSD_ULD=m
-ccflags-y += -DCONFIG_SCSI_OSD_ULD -DCONFIG_SCSI_OSD_ULD_MODULE
-
-# CONFIG_SCSI_OSD_DPRINT_SENSE =
-# 0 - no print of errors
-# 1 - print errors
-# 2 - errors + warrnings
-ccflags-y += -DCONFIG_SCSI_OSD_DPRINT_SENSE=1
-
-# Uncomment to turn debug on
-# ccflags-y += -DCONFIG_SCSI_OSD_DEBUG
-
-# if we are built out-of-tree and the hosting kernel has OSD headers
-# then "ccflags-y +=" will not pick the out-off-tree headers. Only by doing
-# this it will work. This might break in future kernels
-LINUXINCLUDE := -I$(OSD_INC) $(LINUXINCLUDE)
-
-endif
-
# libosd.ko - osd-initiator library
libosd-y := osd_initiator.o
obj-$(CONFIG_SCSI_OSD_INITIATOR) += libosd.o
diff --git a/drivers/scsi/osd/Makefile b/drivers/scsi/osd/Makefile
deleted file mode 100755
index d905344f83ba..000000000000
--- a/drivers/scsi/osd/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Makefile for the OSD modules (out of tree)
-#
-# Copyright (C) 2008 Panasas Inc. All rights reserved.
-#
-# Authors:
-# Boaz Harrosh <bharrosh@panasas.com>
-# Benny Halevy <bhalevy@panasas.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2
-#
-# This Makefile is used to call the kernel Makefile in case of an out-of-tree
-# build.
-# $KSRC should point to a Kernel source tree otherwise host's default is
-# used. (eg. /lib/modules/`uname -r`/build)
-
-# include path for out-of-tree Headers
-OSD_INC ?= `pwd`/../../../include
-
-# allow users to override these
-# e.g. to compile for a kernel that you aren't currently running
-KSRC ?= /lib/modules/$(shell uname -r)/build
-KBUILD_OUTPUT ?=
-ARCH ?=
-V ?= 0
-
-# this is the basic Kbuild out-of-tree invocation, with the M= option
-KBUILD_BASE = +$(MAKE) -C $(KSRC) M=`pwd` KBUILD_OUTPUT=$(KBUILD_OUTPUT) ARCH=$(ARCH) V=$(V)
-
-all: libosd
-
-libosd: ;
- $(KBUILD_BASE) OSD_INC=$(OSD_INC) modules
-
-clean:
- $(KBUILD_BASE) clean
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 1ce6b24abab2..7a117c18114c 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -118,39 +118,39 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps)
_osd_ver_desc(or));
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_VENDOR_IDENTIFICATION [%s]\n",
+ OSD_INFO("VENDOR_IDENTIFICATION [%s]\n",
(char *)pFirst);
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_PRODUCT_IDENTIFICATION [%s]\n",
+ OSD_INFO("PRODUCT_IDENTIFICATION [%s]\n",
(char *)pFirst);
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_PRODUCT_MODEL [%s]\n",
+ OSD_INFO("PRODUCT_MODEL [%s]\n",
(char *)pFirst);
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_PRODUCT_REVISION_LEVEL [%u]\n",
+ OSD_INFO("PRODUCT_REVISION_LEVEL [%u]\n",
pFirst ? get_unaligned_be32(pFirst) : ~0U);
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_PRODUCT_SERIAL_NUMBER [%s]\n",
+ OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n",
(char *)pFirst);
pFirst = get_attrs[a].val_ptr;
- OSD_INFO("OSD_ATTR_RI_OSD_NAME [%s]\n", (char *)pFirst);
+ OSD_INFO("OSD_NAME [%s]\n", (char *)pFirst);
a++;
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_TOTAL_CAPACITY [0x%llx]\n",
+ OSD_INFO("TOTAL_CAPACITY [0x%llx]\n",
pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL);
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_USED_CAPACITY [0x%llx]\n",
+ OSD_INFO("USED_CAPACITY [0x%llx]\n",
pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL);
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_NUMBER_OF_PARTITIONS [%llu]\n",
+ OSD_INFO("NUMBER_OF_PARTITIONS [%llu]\n",
pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL);
if (a >= nelem)
@@ -158,7 +158,7 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps)
/* FIXME: Where are the time utilities */
pFirst = get_attrs[a++].val_ptr;
- OSD_INFO("OSD_ATTR_RI_CLOCK [0x%02x%02x%02x%02x%02x%02x]\n",
+ OSD_INFO("CLOCK [0x%02x%02x%02x%02x%02x%02x]\n",
((char *)pFirst)[0], ((char *)pFirst)[1],
((char *)pFirst)[2], ((char *)pFirst)[3],
((char *)pFirst)[4], ((char *)pFirst)[5]);
@@ -169,7 +169,8 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps)
hex_dump_to_buffer(get_attrs[a].val_ptr, len, 32, 1,
sid_dump, sizeof(sid_dump), true);
- OSD_INFO("OSD_ATTR_RI_OSD_SYSTEM_ID(%d) [%s]\n", len, sid_dump);
+ OSD_INFO("OSD_SYSTEM_ID(%d)\n"
+ " [%s]\n", len, sid_dump);
a++;
}
out:
@@ -669,7 +670,7 @@ static int _osd_req_list_objects(struct osd_request *or,
__be16 action, const struct osd_obj_id *obj, osd_id initial_id,
struct osd_obj_id_list *list, unsigned nelem)
{
- struct request_queue *q = or->osd_dev->scsi_device->request_queue;
+ struct request_queue *q = osd_request_queue(or->osd_dev);
u64 len = nelem * sizeof(osd_id) + sizeof(*list);
struct bio *bio;
@@ -778,16 +779,32 @@ EXPORT_SYMBOL(osd_req_remove_object);
*/
void osd_req_write(struct osd_request *or,
- const struct osd_obj_id *obj, struct bio *bio, u64 offset)
+ const struct osd_obj_id *obj, u64 offset,
+ struct bio *bio, u64 len)
{
- _osd_req_encode_common(or, OSD_ACT_WRITE, obj, offset, bio->bi_size);
+ _osd_req_encode_common(or, OSD_ACT_WRITE, obj, offset, len);
WARN_ON(or->out.bio || or->out.total_bytes);
- bio->bi_rw |= (1 << BIO_RW);
+ WARN_ON(0 == bio_rw_flagged(bio, BIO_RW));
or->out.bio = bio;
- or->out.total_bytes = bio->bi_size;
+ or->out.total_bytes = len;
}
EXPORT_SYMBOL(osd_req_write);
+int osd_req_write_kern(struct osd_request *or,
+ const struct osd_obj_id *obj, u64 offset, void* buff, u64 len)
+{
+ struct request_queue *req_q = osd_request_queue(or->osd_dev);
+ struct bio *bio = bio_map_kern(req_q, buff, len, GFP_KERNEL);
+
+ if (IS_ERR(bio))
+ return PTR_ERR(bio);
+
+ bio->bi_rw |= (1 << BIO_RW); /* FIXME: bio_set_dir() */
+ osd_req_write(or, obj, offset, bio, len);
+ return 0;
+}
+EXPORT_SYMBOL(osd_req_write_kern);
+
/*TODO: void osd_req_append(struct osd_request *,
const struct osd_obj_id *, struct bio *data_out); */
/*TODO: void osd_req_create_write(struct osd_request *,
@@ -813,16 +830,31 @@ void osd_req_flush_object(struct osd_request *or,
EXPORT_SYMBOL(osd_req_flush_object);
void osd_req_read(struct osd_request *or,
- const struct osd_obj_id *obj, struct bio *bio, u64 offset)
+ const struct osd_obj_id *obj, u64 offset,
+ struct bio *bio, u64 len)
{
- _osd_req_encode_common(or, OSD_ACT_READ, obj, offset, bio->bi_size);
+ _osd_req_encode_common(or, OSD_ACT_READ, obj, offset, len);
WARN_ON(or->in.bio || or->in.total_bytes);
- bio->bi_rw &= ~(1 << BIO_RW);
+ WARN_ON(1 == bio_rw_flagged(bio, BIO_RW));
or->in.bio = bio;
- or->in.total_bytes = bio->bi_size;
+ or->in.total_bytes = len;
}
EXPORT_SYMBOL(osd_req_read);
+int osd_req_read_kern(struct osd_request *or,
+ const struct osd_obj_id *obj, u64 offset, void* buff, u64 len)
+{
+ struct request_queue *req_q = osd_request_queue(or->osd_dev);
+ struct bio *bio = bio_map_kern(req_q, buff, len, GFP_KERNEL);
+
+ if (IS_ERR(bio))
+ return PTR_ERR(bio);
+
+ osd_req_read(or, obj, offset, bio, len);
+ return 0;
+}
+EXPORT_SYMBOL(osd_req_read_kern);
+
void osd_req_get_attributes(struct osd_request *or,
const struct osd_obj_id *obj)
{
@@ -889,26 +921,6 @@ int osd_req_add_set_attr_list(struct osd_request *or,
}
EXPORT_SYMBOL(osd_req_add_set_attr_list);
-static int _append_map_kern(struct request *req,
- void *buff, unsigned len, gfp_t flags)
-{
- struct bio *bio;
- int ret;
-
- bio = bio_map_kern(req->q, buff, len, flags);
- if (IS_ERR(bio)) {
- OSD_ERR("Failed bio_map_kern(%p, %d) => %ld\n", buff, len,
- PTR_ERR(bio));
- return PTR_ERR(bio);
- }
- ret = blk_rq_append_bio(req->q, req, bio);
- if (ret) {
- OSD_ERR("Failed blk_rq_append_bio(%p) => %d\n", bio, ret);
- bio_put(bio);
- }
- return ret;
-}
-
static int _req_append_segment(struct osd_request *or,
unsigned padding, struct _osd_req_data_segment *seg,
struct _osd_req_data_segment *last_seg, struct _osd_io_info *io)
@@ -924,14 +936,14 @@ static int _req_append_segment(struct osd_request *or,
else
pad_buff = io->pad_buff;
- ret = _append_map_kern(io->req, pad_buff, padding,
+ ret = blk_rq_map_kern(io->req->q, io->req, pad_buff, padding,
or->alloc_flags);
if (ret)
return ret;
io->total_bytes += padding;
}
- ret = _append_map_kern(io->req, seg->buff, seg->total_bytes,
+ ret = blk_rq_map_kern(io->req->q, io->req, seg->buff, seg->total_bytes,
or->alloc_flags);
if (ret)
return ret;
@@ -1233,7 +1245,7 @@ static inline void osd_sec_parms_set_in_offset(bool is_v1,
}
static int _osd_req_finalize_data_integrity(struct osd_request *or,
- bool has_in, bool has_out, const u8 *cap_key)
+ bool has_in, bool has_out, u64 out_data_bytes, const u8 *cap_key)
{
struct osd_security_parameters *sec_parms = _osd_req_sec_params(or);
int ret;
@@ -1248,8 +1260,7 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or,
};
unsigned pad;
- or->out_data_integ.data_bytes = cpu_to_be64(
- or->out.bio ? or->out.bio->bi_size : 0);
+ or->out_data_integ.data_bytes = cpu_to_be64(out_data_bytes);
or->out_data_integ.set_attributes_bytes = cpu_to_be64(
or->set_attr.total_bytes);
or->out_data_integ.get_attributes_bytes = cpu_to_be64(
@@ -1293,6 +1304,21 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or,
/*
* osd_finalize_request and helpers
*/
+static struct request *_make_request(struct request_queue *q, bool has_write,
+ struct _osd_io_info *oii, gfp_t flags)
+{
+ if (oii->bio)
+ return blk_make_request(q, oii->bio, flags);
+ else {
+ struct request *req;
+
+ req = blk_get_request(q, has_write ? WRITE : READ, flags);
+ if (unlikely(!req))
+ return ERR_PTR(-ENOMEM);
+
+ return req;
+ }
+}
static int _init_blk_request(struct osd_request *or,
bool has_in, bool has_out)
@@ -1301,14 +1327,18 @@ static int _init_blk_request(struct osd_request *or,
struct scsi_device *scsi_device = or->osd_dev->scsi_device;
struct request_queue *q = scsi_device->request_queue;
struct request *req;
- int ret = -ENOMEM;
+ int ret;
- req = blk_get_request(q, has_out, flags);
- if (!req)
+ req = _make_request(q, has_out, has_out ? &or->out : &or->in, flags);
+ if (IS_ERR(req)) {
+ ret = PTR_ERR(req);
goto out;
+ }
or->request = req;
req->cmd_type = REQ_TYPE_BLOCK_PC;
+ req->cmd_flags |= REQ_QUIET;
+
req->timeout = or->timeout;
req->retries = or->retries;
req->sense = or->sense;
@@ -1318,9 +1348,10 @@ static int _init_blk_request(struct osd_request *or,
or->out.req = req;
if (has_in) {
/* allocate bidi request */
- req = blk_get_request(q, READ, flags);
- if (!req) {
+ req = _make_request(q, false, &or->in, flags);
+ if (IS_ERR(req)) {
OSD_DEBUG("blk_get_request for bidi failed\n");
+ ret = PTR_ERR(req);
goto out;
}
req->cmd_type = REQ_TYPE_BLOCK_PC;
@@ -1341,6 +1372,7 @@ int osd_finalize_request(struct osd_request *or,
{
struct osd_cdb_head *cdbh = osd_cdb_head(&or->cdb);
bool has_in, has_out;
+ u64 out_data_bytes = or->out.total_bytes;
int ret;
if (options & OSD_REQ_FUA)
@@ -1364,26 +1396,6 @@ int osd_finalize_request(struct osd_request *or,
return ret;
}
- if (or->out.bio) {
- ret = blk_rq_append_bio(or->request->q, or->out.req,
- or->out.bio);
- if (ret) {
- OSD_DEBUG("blk_rq_append_bio out failed\n");
- return ret;
- }
- OSD_DEBUG("out bytes=%llu (bytes_req=%u)\n",
- _LLU(or->out.total_bytes), or->out.req->data_len);
- }
- if (or->in.bio) {
- ret = blk_rq_append_bio(or->request->q, or->in.req, or->in.bio);
- if (ret) {
- OSD_DEBUG("blk_rq_append_bio in failed\n");
- return ret;
- }
- OSD_DEBUG("in bytes=%llu (bytes_req=%u)\n",
- _LLU(or->in.total_bytes), or->in.req->data_len);
- }
-
or->out.pad_buff = sg_out_pad_buffer;
or->in.pad_buff = sg_in_pad_buffer;
@@ -1410,7 +1422,8 @@ int osd_finalize_request(struct osd_request *or,
}
}
- ret = _osd_req_finalize_data_integrity(or, has_in, has_out, cap_key);
+ ret = _osd_req_finalize_data_integrity(or, has_in, has_out,
+ out_data_bytes, cap_key);
if (ret)
return ret;
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 22b59e13ba83..0bdef3390902 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -49,6 +49,7 @@
#include <linux/device.h>
#include <linux/idr.h>
#include <linux/major.h>
+#include <linux/file.h>
#include <scsi/scsi.h>
#include <scsi/scsi_driver.h>
@@ -175,10 +176,9 @@ static const struct file_operations osd_fops = {
struct osd_dev *osduld_path_lookup(const char *name)
{
- struct path path;
- struct inode *inode;
- struct cdev *cdev;
- struct osd_uld_device *uninitialized_var(oud);
+ struct osd_uld_device *oud;
+ struct osd_dev *od;
+ struct file *file;
int error;
if (!name || !*name) {
@@ -186,52 +186,46 @@ struct osd_dev *osduld_path_lookup(const char *name)
return ERR_PTR(-EINVAL);
}
- error = kern_path(name, LOOKUP_FOLLOW, &path);
- if (error) {
- OSD_ERR("path_lookup of %s failed=>%d\n", name, error);
- return ERR_PTR(error);
- }
+ od = kzalloc(sizeof(*od), GFP_KERNEL);
+ if (!od)
+ return ERR_PTR(-ENOMEM);
- inode = path.dentry->d_inode;
- error = -EINVAL; /* Not the right device e.g osd_uld_device */
- if (!S_ISCHR(inode->i_mode)) {
- OSD_DEBUG("!S_ISCHR()\n");
- goto out;
+ file = filp_open(name, O_RDWR, 0);
+ if (IS_ERR(file)) {
+ error = PTR_ERR(file);
+ goto free_od;
}
- cdev = inode->i_cdev;
- if (!cdev) {
- OSD_ERR("Before mounting an OSD Based filesystem\n");
- OSD_ERR(" user-mode must open+close the %s device\n", name);
- OSD_ERR(" Example: bash: echo < %s\n", name);
- goto out;
+ if (file->f_op != &osd_fops){
+ error = -EINVAL;
+ goto close_file;
}
- /* The Magic wand. Is it our char-dev */
- /* TODO: Support sg devices */
- if (cdev->owner != THIS_MODULE) {
- OSD_ERR("Error mounting %s - is not an OSD device\n", name);
- goto out;
- }
+ oud = file->private_data;
- oud = container_of(cdev, struct osd_uld_device, cdev);
+ *od = oud->od;
+ od->file = file;
- __uld_get(oud);
- error = 0;
+ return od;
-out:
- path_put(&path);
- return error ? ERR_PTR(error) : &oud->od;
+close_file:
+ fput(file);
+free_od:
+ kfree(od);
+ return ERR_PTR(error);
}
EXPORT_SYMBOL(osduld_path_lookup);
void osduld_put_device(struct osd_dev *od)
{
- if (od) {
- struct osd_uld_device *oud = container_of(od,
- struct osd_uld_device, od);
- __uld_put(oud);
+ if (od && !IS_ERR(od)) {
+ struct osd_uld_device *oud = od->file->private_data;
+
+ BUG_ON(od->scsi_device != oud->od.scsi_device);
+
+ fput(od->file);
+ kfree(od);
}
}
EXPORT_SYMBOL(osduld_put_device);
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 5defe5ea5eda..8371d917a9a2 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -17,9 +17,12 @@
* General Public License for more details.
*
******************************************************************************/
-#define QLA1280_VERSION "3.26"
+#define QLA1280_VERSION "3.27"
/*****************************************************************************
Revision History:
+ Rev 3.27, February 10, 2009, Michael Reed
+ - General code cleanup.
+ - Improve error recovery.
Rev 3.26, January 16, 2006 Jes Sorensen
- Ditch all < 2.6 support
Rev 3.25.1, February 10, 2005 Christoph Hellwig
@@ -435,7 +438,6 @@ static int qla1280_mailbox_command(struct scsi_qla_host *,
uint8_t, uint16_t *);
static int qla1280_bus_reset(struct scsi_qla_host *, int);
static int qla1280_device_reset(struct scsi_qla_host *, int, int);
-static int qla1280_abort_device(struct scsi_qla_host *, int, int, int);
static int qla1280_abort_command(struct scsi_qla_host *, struct srb *, int);
static int qla1280_abort_isp(struct scsi_qla_host *);
#ifdef QLA_64BIT_PTR
@@ -698,7 +700,7 @@ qla1280_info(struct Scsi_Host *host)
}
/**************************************************************************
- * qla1200_queuecommand
+ * qla1280_queuecommand
* Queue a command to the controller.
*
* Note:
@@ -713,12 +715,14 @@ qla1280_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
{
struct Scsi_Host *host = cmd->device->host;
struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
- struct srb *sp = (struct srb *)&cmd->SCp;
+ struct srb *sp = (struct srb *)CMD_SP(cmd);
int status;
cmd->scsi_done = fn;
sp->cmd = cmd;
sp->flags = 0;
+ sp->wait = NULL;
+ CMD_HANDLE(cmd) = (unsigned char *)NULL;
qla1280_print_scsi_cmd(5, cmd);
@@ -738,21 +742,11 @@ qla1280_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
enum action {
ABORT_COMMAND,
- ABORT_DEVICE,
DEVICE_RESET,
BUS_RESET,
ADAPTER_RESET,
- FAIL
};
-/* timer action for error action processor */
-static void qla1280_error_wait_timeout(unsigned long __data)
-{
- struct scsi_cmnd *cmd = (struct scsi_cmnd *)__data;
- struct srb *sp = (struct srb *)CMD_SP(cmd);
-
- complete(sp->wait);
-}
static void qla1280_mailbox_timeout(unsigned long __data)
{
@@ -767,8 +761,67 @@ static void qla1280_mailbox_timeout(unsigned long __data)
complete(ha->mailbox_wait);
}
+static int
+_qla1280_wait_for_single_command(struct scsi_qla_host *ha, struct srb *sp,
+ struct completion *wait)
+{
+ int status = FAILED;
+ struct scsi_cmnd *cmd = sp->cmd;
+
+ spin_unlock_irq(ha->host->host_lock);
+ wait_for_completion_timeout(wait, 4*HZ);
+ spin_lock_irq(ha->host->host_lock);
+ sp->wait = NULL;
+ if(CMD_HANDLE(cmd) == COMPLETED_HANDLE) {
+ status = SUCCESS;
+ (*cmd->scsi_done)(cmd);
+ }
+ return status;
+}
+
+static int
+qla1280_wait_for_single_command(struct scsi_qla_host *ha, struct srb *sp)
+{
+ DECLARE_COMPLETION_ONSTACK(wait);
+
+ sp->wait = &wait;
+ return _qla1280_wait_for_single_command(ha, sp, &wait);
+}
+
+static int
+qla1280_wait_for_pending_commands(struct scsi_qla_host *ha, int bus, int target)
+{
+ int cnt;
+ int status;
+ struct srb *sp;
+ struct scsi_cmnd *cmd;
+
+ status = SUCCESS;
+
+ /*
+ * Wait for all commands with the designated bus/target
+ * to be completed by the firmware
+ */
+ for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
+ sp = ha->outstanding_cmds[cnt];
+ if (sp) {
+ cmd = sp->cmd;
+
+ if (bus >= 0 && SCSI_BUS_32(cmd) != bus)
+ continue;
+ if (target >= 0 && SCSI_TCN_32(cmd) != target)
+ continue;
+
+ status = qla1280_wait_for_single_command(ha, sp);
+ if (status == FAILED)
+ break;
+ }
+ }
+ return status;
+}
+
/**************************************************************************
- * qla1200_error_action
+ * qla1280_error_action
* The function will attempt to perform a specified error action and
* wait for the results (or time out).
*
@@ -780,11 +833,6 @@ static void qla1280_mailbox_timeout(unsigned long __data)
* Returns:
* SUCCESS or FAILED
*
- * Note:
- * Resetting the bus always succeeds - is has to, otherwise the
- * kernel will panic! Try a surgical technique - sending a BUS
- * DEVICE RESET message - on the offending target before pulling
- * the SCSI bus reset line.
**************************************************************************/
static int
qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
@@ -792,13 +840,19 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
struct scsi_qla_host *ha;
int bus, target, lun;
struct srb *sp;
- uint16_t data;
- unsigned char *handle;
- int result, i;
+ int i, found;
+ int result=FAILED;
+ int wait_for_bus=-1;
+ int wait_for_target = -1;
DECLARE_COMPLETION_ONSTACK(wait);
- struct timer_list timer;
+
+ ENTER("qla1280_error_action");
ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata);
+ sp = (struct srb *)CMD_SP(cmd);
+ bus = SCSI_BUS_32(cmd);
+ target = SCSI_TCN_32(cmd);
+ lun = SCSI_LUN_32(cmd);
dprintk(4, "error_action %i, istatus 0x%04x\n", action,
RD_REG_WORD(&ha->iobase->istatus));
@@ -807,99 +861,47 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
RD_REG_WORD(&ha->iobase->host_cmd),
RD_REG_WORD(&ha->iobase->ictrl), jiffies);
- ENTER("qla1280_error_action");
if (qla1280_verbose)
printk(KERN_INFO "scsi(%li): Resetting Cmnd=0x%p, "
"Handle=0x%p, action=0x%x\n",
ha->host_no, cmd, CMD_HANDLE(cmd), action);
- if (cmd == NULL) {
- printk(KERN_WARNING "(scsi?:?:?:?) Reset called with NULL "
- "si_Cmnd pointer, failing.\n");
- LEAVE("qla1280_error_action");
- return FAILED;
- }
-
- ha = (struct scsi_qla_host *)cmd->device->host->hostdata;
- sp = (struct srb *)CMD_SP(cmd);
- handle = CMD_HANDLE(cmd);
-
- /* Check for pending interrupts. */
- data = qla1280_debounce_register(&ha->iobase->istatus);
- /*
- * The io_request_lock is held when the reset handler is called, hence
- * the interrupt handler cannot be running in parallel as it also
- * grabs the lock. /Jes
- */
- if (data & RISC_INT)
- qla1280_isr(ha, &ha->done_q);
-
/*
- * Determine the suggested action that the mid-level driver wants
- * us to perform.
+ * Check to see if we have the command in the outstanding_cmds[]
+ * array. If not then it must have completed before this error
+ * action was initiated. If the error_action isn't ABORT_COMMAND
+ * then the driver must proceed with the requested action.
*/
- if (handle == (unsigned char *)INVALID_HANDLE || handle == NULL) {
- if(action == ABORT_COMMAND) {
- /* we never got this command */
- printk(KERN_INFO "qla1280: Aborting a NULL handle\n");
- return SUCCESS; /* no action - we don't have command */
+ found = -1;
+ for (i = 0; i < MAX_OUTSTANDING_COMMANDS; i++) {
+ if (sp == ha->outstanding_cmds[i]) {
+ found = i;
+ sp->wait = &wait; /* we'll wait for it to complete */
+ break;
}
- } else {
- sp->wait = &wait;
}
- bus = SCSI_BUS_32(cmd);
- target = SCSI_TCN_32(cmd);
- lun = SCSI_LUN_32(cmd);
+ if (found < 0) { /* driver doesn't have command */
+ result = SUCCESS;
+ if (qla1280_verbose) {
+ printk(KERN_INFO
+ "scsi(%ld:%d:%d:%d): specified command has "
+ "already completed.\n", ha->host_no, bus,
+ target, lun);
+ }
+ }
- /* Overloading result. Here it means the success or fail of the
- * *issue* of the action. When we return from the routine, it must
- * mean the actual success or fail of the action */
- result = FAILED;
switch (action) {
- case FAIL:
- break;
case ABORT_COMMAND:
- if ((sp->flags & SRB_ABORT_PENDING)) {
- printk(KERN_WARNING
- "scsi(): Command has a pending abort "
- "message - ABORT_PENDING.\n");
- /* This should technically be impossible since we
- * now wait for abort completion */
- break;
- }
-
- for (i = 0; i < MAX_OUTSTANDING_COMMANDS; i++) {
- if (sp == ha->outstanding_cmds[i]) {
- dprintk(1, "qla1280: RISC aborting command\n");
- if (qla1280_abort_command(ha, sp, i) == 0)
- result = SUCCESS;
- else {
- /*
- * Since we don't know what might
- * have happend to the command, it
- * is unsafe to remove it from the
- * device's queue at this point.
- * Wait and let the escalation
- * process take care of it.
- */
- printk(KERN_WARNING
- "scsi(%li:%i:%i:%i): Unable"
- " to abort command!\n",
- ha->host_no, bus, target, lun);
- }
- }
- }
- break;
-
- case ABORT_DEVICE:
- if (qla1280_verbose)
- printk(KERN_INFO
- "scsi(%ld:%d:%d:%d): Queueing abort device "
- "command.\n", ha->host_no, bus, target, lun);
- if (qla1280_abort_device(ha, bus, target, lun) == 0)
- result = SUCCESS;
+ dprintk(1, "qla1280: RISC aborting command\n");
+ /*
+ * The abort might fail due to race when the host_lock
+ * is released to issue the abort. As such, we
+ * don't bother to check the return status.
+ */
+ if (found >= 0)
+ qla1280_abort_command(ha, sp, found);
break;
case DEVICE_RESET:
@@ -907,16 +909,21 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
printk(KERN_INFO
"scsi(%ld:%d:%d:%d): Queueing device reset "
"command.\n", ha->host_no, bus, target, lun);
- if (qla1280_device_reset(ha, bus, target) == 0)
- result = SUCCESS;
+ if (qla1280_device_reset(ha, bus, target) == 0) {
+ /* issued device reset, set wait conditions */
+ wait_for_bus = bus;
+ wait_for_target = target;
+ }
break;
case BUS_RESET:
if (qla1280_verbose)
printk(KERN_INFO "qla1280(%ld:%d): Issued bus "
"reset.\n", ha->host_no, bus);
- if (qla1280_bus_reset(ha, bus) == 0)
- result = SUCCESS;
+ if (qla1280_bus_reset(ha, bus) == 0) {
+ /* issued bus reset, set wait conditions */
+ wait_for_bus = bus;
+ }
break;
case ADAPTER_RESET:
@@ -929,55 +936,48 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
"continue automatically\n", ha->host_no);
}
ha->flags.reset_active = 1;
- /*
- * We restarted all of the commands automatically, so the
- * mid-level code can expect completions momentitarily.
- */
- if (qla1280_abort_isp(ha) == 0)
- result = SUCCESS;
+
+ if (qla1280_abort_isp(ha) != 0) { /* it's dead */
+ result = FAILED;
+ }
ha->flags.reset_active = 0;
}
- if (!list_empty(&ha->done_q))
- qla1280_done(ha);
-
- /* If we didn't manage to issue the action, or we have no
- * command to wait for, exit here */
- if (result == FAILED || handle == NULL ||
- handle == (unsigned char *)INVALID_HANDLE) {
- /*
- * Clear completion queue to avoid qla1280_done() trying
- * to complete the command at a later stage after we
- * have exited the current context
- */
- sp->wait = NULL;
- goto leave;
- }
+ /*
+ * At this point, the host_lock has been released and retaken
+ * by the issuance of the mailbox command.
+ * Wait for the command passed in by the mid-layer if it
+ * was found by the driver. It might have been returned
+ * between eh recovery steps, hence the check of the "found"
+ * variable.
+ */
- /* set up a timer just in case we're really jammed */
- init_timer(&timer);
- timer.expires = jiffies + 4*HZ;
- timer.data = (unsigned long)cmd;
- timer.function = qla1280_error_wait_timeout;
- add_timer(&timer);
+ if (found >= 0)
+ result = _qla1280_wait_for_single_command(ha, sp, &wait);
- /* wait for the action to complete (or the timer to expire) */
- spin_unlock_irq(ha->host->host_lock);
- wait_for_completion(&wait);
- del_timer_sync(&timer);
- spin_lock_irq(ha->host->host_lock);
- sp->wait = NULL;
+ if (action == ABORT_COMMAND && result != SUCCESS) {
+ printk(KERN_WARNING
+ "scsi(%li:%i:%i:%i): "
+ "Unable to abort command!\n",
+ ha->host_no, bus, target, lun);
+ }
- /* the only action we might get a fail for is abort */
- if (action == ABORT_COMMAND) {
- if(sp->flags & SRB_ABORTED)
- result = SUCCESS;
- else
- result = FAILED;
+ /*
+ * If the command passed in by the mid-layer has been
+ * returned by the board, then wait for any additional
+ * commands which are supposed to complete based upon
+ * the error action.
+ *
+ * All commands are unconditionally returned during a
+ * call to qla1280_abort_isp(), ADAPTER_RESET. No need
+ * to wait for them.
+ */
+ if (result == SUCCESS && wait_for_bus >= 0) {
+ result = qla1280_wait_for_pending_commands(ha,
+ wait_for_bus, wait_for_target);
}
- leave:
dprintk(1, "RESET returning %d\n", result);
LEAVE("qla1280_error_action");
@@ -1280,13 +1280,12 @@ qla1280_done(struct scsi_qla_host *ha)
switch ((CMD_RESULT(cmd) >> 16)) {
case DID_RESET:
/* Issue marker command. */
- qla1280_marker(ha, bus, target, 0, MK_SYNC_ID);
+ if (!ha->flags.abort_isp_active)
+ qla1280_marker(ha, bus, target, 0, MK_SYNC_ID);
break;
case DID_ABORT:
sp->flags &= ~SRB_ABORT_PENDING;
sp->flags |= SRB_ABORTED;
- if (sp->flags & SRB_TIMEOUT)
- CMD_RESULT(sp->cmd) = DID_TIME_OUT << 16;
break;
default:
break;
@@ -1296,12 +1295,11 @@ qla1280_done(struct scsi_qla_host *ha)
scsi_dma_unmap(cmd);
/* Call the mid-level driver interrupt handler */
- CMD_HANDLE(sp->cmd) = (unsigned char *)INVALID_HANDLE;
ha->actthreads--;
- (*(cmd)->scsi_done)(cmd);
-
- if(sp->wait != NULL)
+ if (sp->wait == NULL)
+ (*(cmd)->scsi_done)(cmd);
+ else
complete(sp->wait);
}
LEAVE("qla1280_done");
@@ -2417,9 +2415,6 @@ static int
qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
{
struct device_reg __iomem *reg = ha->iobase;
-#if 0
- LIST_HEAD(done_q);
-#endif
int status = 0;
int cnt;
uint16_t *optr, *iptr;
@@ -2493,19 +2488,9 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
mr = MAILBOX_REGISTER_COUNT;
memcpy(optr, iptr, MAILBOX_REGISTER_COUNT * sizeof(uint16_t));
-#if 0
- /* Go check for any response interrupts pending. */
- qla1280_isr(ha, &done_q);
-#endif
-
if (ha->flags.reset_marker)
qla1280_rst_aen(ha);
-#if 0
- if (!list_empty(&done_q))
- qla1280_done(ha, &done_q);
-#endif
-
if (status)
dprintk(2, "qla1280_mailbox_command: **** FAILED, mailbox0 = "
"0x%x ****\n", mb[0]);
@@ -2641,41 +2626,6 @@ qla1280_device_reset(struct scsi_qla_host *ha, int bus, int target)
}
/*
- * qla1280_abort_device
- * Issue an abort message to the device
- *
- * Input:
- * ha = adapter block pointer.
- * bus = SCSI BUS.
- * target = SCSI ID.
- * lun = SCSI LUN.
- *
- * Returns:
- * 0 = success
- */
-static int
-qla1280_abort_device(struct scsi_qla_host *ha, int bus, int target, int lun)
-{
- uint16_t mb[MAILBOX_REGISTER_COUNT];
- int status;
-
- ENTER("qla1280_abort_device");
-
- mb[0] = MBC_ABORT_DEVICE;
- mb[1] = (bus ? target | BIT_7 : target) << 8 | lun;
- status = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
-
- /* Issue marker command. */
- qla1280_marker(ha, bus, target, lun, MK_SYNC_ID_LUN);
-
- if (status)
- dprintk(2, "qla1280_abort_device: **** FAILED ****\n");
-
- LEAVE("qla1280_abort_device");
- return status;
-}
-
-/*
* qla1280_abort_command
* Abort command aborts a specified IOCB.
*
@@ -2833,7 +2783,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
/* If room for request in request ring. */
if ((req_cnt + 2) >= ha->req_q_cnt) {
- status = 1;
+ status = SCSI_MLQUEUE_HOST_BUSY;
dprintk(2, "qla1280_start_scsi: in-ptr=0x%x req_q_cnt="
"0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt,
req_cnt);
@@ -2845,7 +2795,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
ha->outstanding_cmds[cnt] != NULL; cnt++);
if (cnt >= MAX_OUTSTANDING_COMMANDS) {
- status = 1;
+ status = SCSI_MLQUEUE_HOST_BUSY;
dprintk(2, "qla1280_start_scsi: NO ROOM IN "
"OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt);
goto out;
@@ -3108,7 +3058,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
ha->req_q_cnt, seg_cnt);
/* If room for request in request ring. */
if ((req_cnt + 2) >= ha->req_q_cnt) {
- status = 1;
+ status = SCSI_MLQUEUE_HOST_BUSY;
dprintk(2, "qla1280_32bit_start_scsi: in-ptr=0x%x, "
"req_q_cnt=0x%x, req_cnt=0x%x", ha->req_ring_index,
ha->req_q_cnt, req_cnt);
@@ -3120,7 +3070,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
(ha->outstanding_cmds[cnt] != 0); cnt++) ;
if (cnt >= MAX_OUTSTANDING_COMMANDS) {
- status = 1;
+ status = SCSI_MLQUEUE_HOST_BUSY;
dprintk(2, "qla1280_32bit_start_scsi: NO ROOM IN OUTSTANDING "
"ARRAY, req_q_cnt=0x%x\n", ha->req_q_cnt);
goto out;
@@ -3487,6 +3437,7 @@ qla1280_isr(struct scsi_qla_host *ha, struct list_head *done_q)
/* Save ISP completion status */
CMD_RESULT(sp->cmd) = 0;
+ CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE;
/* Place block on done queue */
list_add_tail(&sp->list, done_q);
@@ -3495,7 +3446,7 @@ qla1280_isr(struct scsi_qla_host *ha, struct list_head *done_q)
* If we get here we have a real problem!
*/
printk(KERN_WARNING
- "qla1280: ISP invalid handle");
+ "qla1280: ISP invalid handle\n");
}
}
break;
@@ -3753,6 +3704,8 @@ qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt,
}
}
+ CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE;
+
/* Place command on done queue. */
list_add_tail(&sp->list, done_q);
out:
@@ -3808,6 +3761,8 @@ qla1280_error_entry(struct scsi_qla_host *ha, struct response *pkt,
CMD_RESULT(sp->cmd) = DID_ERROR << 16;
}
+ CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE;
+
/* Place command on done queue. */
list_add_tail(&sp->list, done_q);
}
@@ -3858,19 +3813,16 @@ qla1280_abort_isp(struct scsi_qla_host *ha)
struct scsi_cmnd *cmd;
sp = ha->outstanding_cmds[cnt];
if (sp) {
-
cmd = sp->cmd;
CMD_RESULT(cmd) = DID_RESET << 16;
-
- sp->cmd = NULL;
+ CMD_HANDLE(cmd) = COMPLETED_HANDLE;
ha->outstanding_cmds[cnt] = NULL;
-
- (*cmd->scsi_done)(cmd);
-
- sp->flags = 0;
+ list_add_tail(&sp->list, &ha->done_q);
}
}
+ qla1280_done(ha);
+
status = qla1280_load_firmware(ha);
if (status)
goto out;
@@ -3955,13 +3907,6 @@ qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *ha, unsigned int bus)
if (scsi_control == SCSI_PHASE_INVALID) {
ha->bus_settings[bus].scsi_bus_dead = 1;
-#if 0
- CMD_RESULT(cp) = DID_NO_CONNECT << 16;
- CMD_HANDLE(cp) = INVALID_HANDLE;
- /* ha->actthreads--; */
-
- (*(cp)->scsi_done)(cp);
-#endif
return 1; /* bus is dead */
} else {
ha->bus_settings[bus].scsi_bus_dead = 0;
diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h
index d7c44b8d2b4f..834884b9eed5 100644
--- a/drivers/scsi/qla1280.h
+++ b/drivers/scsi/qla1280.h
@@ -88,7 +88,8 @@
/* Maximum outstanding commands in ISP queues */
#define MAX_OUTSTANDING_COMMANDS 512
-#define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS + 2)
+#define COMPLETED_HANDLE ((unsigned char *) \
+ (MAX_OUTSTANDING_COMMANDS + 2))
/* ISP request and response entry counts (37-65535) */
#define REQUEST_ENTRY_CNT 255 /* Number of request entries. */
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index b09993a06576..fc30f8e2f467 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -97,7 +97,7 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
return 0;
if (IS_NOCACHE_VPD_TYPE(ha))
- ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_nvram << 2,
+ ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2,
ha->nvram_size);
return memory_read_from_buffer(buf, count, &off, ha->nvram,
ha->nvram_size);
@@ -1088,6 +1088,33 @@ qla2x00_flash_block_size_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
}
+static ssize_t
+qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+
+ if (!IS_QLA81XX(vha->hw))
+ return snprintf(buf, PAGE_SIZE, "\n");
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
+}
+
+static ssize_t
+qla2x00_vn_port_mac_address_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+
+ if (!IS_QLA81XX(vha->hw))
+ return snprintf(buf, PAGE_SIZE, "\n");
+
+ return snprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n",
+ vha->fcoe_vn_port_mac[5], vha->fcoe_vn_port_mac[4],
+ vha->fcoe_vn_port_mac[3], vha->fcoe_vn_port_mac[2],
+ vha->fcoe_vn_port_mac[1], vha->fcoe_vn_port_mac[0]);
+}
+
static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
@@ -1116,6 +1143,9 @@ static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL);
static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show,
NULL);
+static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL);
+static DEVICE_ATTR(vn_port_mac_address, S_IRUGO,
+ qla2x00_vn_port_mac_address_show, NULL);
struct device_attribute *qla2x00_host_attrs[] = {
&dev_attr_driver_version,
@@ -1138,6 +1168,8 @@ struct device_attribute *qla2x00_host_attrs[] = {
&dev_attr_mpi_version,
&dev_attr_phy_version,
&dev_attr_flash_block_size,
+ &dev_attr_vlan_id,
+ &dev_attr_vn_port_mac_address,
NULL,
};
@@ -1437,11 +1469,12 @@ static int
qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
{
int ret = 0;
- int cnt = 0;
- uint8_t qos = QLA_DEFAULT_QUE_QOS;
+ uint8_t qos = 0;
scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
scsi_qla_host_t *vha = NULL;
struct qla_hw_data *ha = base_vha->hw;
+ uint16_t options = 0;
+ int cnt;
ret = qla24xx_vport_create_req_sanity_check(fc_vport);
if (ret) {
@@ -1497,23 +1530,35 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
qla24xx_vport_disable(fc_vport, disable);
- /* Create a queue pair for the vport */
- if (ha->mqenable) {
- if (ha->npiv_info) {
- for (; cnt < ha->nvram_npiv_size; cnt++) {
- if (ha->npiv_info[cnt].port_name ==
- vha->port_name &&
- ha->npiv_info[cnt].node_name ==
- vha->node_name) {
- qos = ha->npiv_info[cnt].q_qos;
- break;
- }
- }
+ ret = 0;
+ if (ha->cur_vport_count <= ha->flex_port_count || ql2xmultique_tag
+ || ha->max_req_queues == 1 || !ha->npiv_info)
+ goto vport_queue;
+ /* Create a request queue in QoS mode for the vport */
+ for (cnt = ha->flex_port_count; cnt < ha->nvram_npiv_size; cnt++) {
+ if (ha->npiv_info[cnt].port_name == vha->port_name &&
+ ha->npiv_info[cnt].node_name == vha->node_name) {
+ qos = ha->npiv_info[cnt].q_qos;
+ break;
}
- qla25xx_create_queues(vha, qos);
+ }
+ if (qos) {
+ ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
+ qos);
+ if (!ret)
+ qla_printk(KERN_WARNING, ha,
+ "Can't create request queue for vp_idx:%d\n",
+ vha->vp_idx);
+ else
+ DEBUG2(qla_printk(KERN_INFO, ha,
+ "Request Que:%d created for vp_idx:%d\n",
+ ret, vha->vp_idx));
}
+vport_queue:
+ vha->req = ha->req_q_map[ret];
return 0;
+
vport_create_failed_2:
qla24xx_disable_vp(vha);
qla24xx_deallocate_vp_id(vha);
@@ -1554,8 +1599,8 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
vha->host_no, vha->vp_idx, vha));
}
- if (ha->mqenable) {
- if (qla25xx_delete_queues(vha, 0) != QLA_SUCCESS)
+ if (vha->req->id && !ql2xmultique_tag) {
+ if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS)
qla_printk(KERN_WARNING, ha,
"Queue delete failed.\n");
}
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 34760f8d4f17..68671a2b8b7f 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -351,7 +351,7 @@ static inline void *
qla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
{
uint32_t cnt, que_idx;
- uint8_t req_cnt, rsp_cnt, que_cnt;
+ uint8_t que_cnt;
struct qla2xxx_mq_chain *mq = ptr;
struct device_reg_25xxmq __iomem *reg;
@@ -363,9 +363,8 @@ qla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
mq->type = __constant_htonl(DUMP_CHAIN_MQ);
mq->chain_size = __constant_htonl(sizeof(struct qla2xxx_mq_chain));
- req_cnt = find_first_zero_bit(ha->req_qid_map, ha->max_queues);
- rsp_cnt = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues);
- que_cnt = req_cnt > rsp_cnt ? req_cnt : rsp_cnt;
+ que_cnt = ha->max_req_queues > ha->max_rsp_queues ?
+ ha->max_req_queues : ha->max_rsp_queues;
mq->count = htonl(que_cnt);
for (cnt = 0; cnt < que_cnt; cnt++) {
reg = (struct device_reg_25xxmq *) ((void *)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 714ee67567e1..721bae94e437 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -93,6 +93,7 @@
#define LSD(x) ((uint32_t)((uint64_t)(x)))
#define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
+#define MAKE_HANDLE(x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y)))
/*
* I/O register
@@ -179,6 +180,7 @@
#define REQUEST_ENTRY_CNT_24XX 2048 /* Number of request entries. */
#define RESPONSE_ENTRY_CNT_2100 64 /* Number of response entries.*/
#define RESPONSE_ENTRY_CNT_2300 512 /* Number of response entries.*/
+#define RESPONSE_ENTRY_CNT_MQ 128 /* Number of response entries.*/
struct req_que;
@@ -186,7 +188,6 @@ struct req_que;
* SCSI Request Block
*/
typedef struct srb {
- struct req_que *que;
struct fc_port *fcport;
struct scsi_cmnd *cmd; /* Linux SCSI command pkt */
@@ -2008,7 +2009,7 @@ typedef struct vport_params {
#define VP_RET_CODE_NOT_FOUND 6
struct qla_hw_data;
-
+struct rsp_que;
/*
* ISP operations
*/
@@ -2030,10 +2031,9 @@ struct isp_operations {
void (*enable_intrs) (struct qla_hw_data *);
void (*disable_intrs) (struct qla_hw_data *);
- int (*abort_command) (struct scsi_qla_host *, srb_t *,
- struct req_que *);
- int (*target_reset) (struct fc_port *, unsigned int);
- int (*lun_reset) (struct fc_port *, unsigned int);
+ int (*abort_command) (srb_t *);
+ int (*target_reset) (struct fc_port *, unsigned int, int);
+ int (*lun_reset) (struct fc_port *, unsigned int, int);
int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
uint8_t, uint8_t, uint16_t *, uint8_t);
int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
@@ -2079,7 +2079,6 @@ struct isp_operations {
#define QLA_PCI_MSIX_CONTROL 0xa2
struct scsi_qla_host;
-struct rsp_que;
struct qla_msix_entry {
int have_irq;
@@ -2140,7 +2139,6 @@ struct qla_statistics {
#define MBC_INITIALIZE_MULTIQ 0x1f
#define QLA_QUE_PAGE 0X1000
#define QLA_MQ_SIZE 32
-#define QLA_MAX_HOST_QUES 16
#define QLA_MAX_QUEUES 256
#define ISP_QUE_REG(ha, id) \
((ha->mqenable) ? \
@@ -2170,6 +2168,8 @@ struct rsp_que {
struct qla_hw_data *hw;
struct qla_msix_entry *msix;
struct req_que *req;
+ srb_t *status_srb; /* status continuation entry */
+ struct work_struct q_work;
};
/* Request queue data structure */
@@ -2222,6 +2222,7 @@ struct qla_hw_data {
uint32_t fce_enabled :1;
uint32_t fac_supported :1;
uint32_t chip_reset_done :1;
+ uint32_t port0 :1;
} flags;
/* This spinlock is used to protect "io transactions", you must
@@ -2246,7 +2247,8 @@ struct qla_hw_data {
struct rsp_que **rsp_q_map;
unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
- uint16_t max_queues;
+ uint8_t max_req_queues;
+ uint8_t max_rsp_queues;
struct qla_npiv_entry *npiv_info;
uint16_t nvram_npiv_size;
@@ -2255,6 +2257,9 @@ struct qla_hw_data {
#define FLOGI_MID_SUPPORT BIT_10
#define FLOGI_VSAN_SUPPORT BIT_12
#define FLOGI_SP_SUPPORT BIT_13
+
+ uint8_t port_no; /* Physical port of adapter */
+
/* Timeout timers. */
uint8_t loop_down_abort_time; /* port down timer */
atomic_t loop_down_timer; /* loop down timer */
@@ -2532,10 +2537,12 @@ struct qla_hw_data {
uint16_t num_vsans; /* number of vsan created */
uint16_t max_npiv_vports; /* 63 or 125 per topoloty */
int cur_vport_count;
+ uint16_t flex_port_count;
struct qla_chip_state_84xx *cs84xx;
struct qla_statistics qla_stats;
struct isp_operations *isp_ops;
+ struct workqueue_struct *wq;
};
/*
@@ -2591,8 +2598,6 @@ typedef struct scsi_qla_host {
#define SWITCH_FOUND BIT_0
#define DFLG_NO_CABLE BIT_1
- srb_t *status_srb; /* Status continuation entry. */
-
/* ISP configuration data. */
uint16_t loop_id; /* Host adapter loop id */
@@ -2618,6 +2623,11 @@ typedef struct scsi_qla_host {
uint8_t node_name[WWN_SIZE];
uint8_t port_name[WWN_SIZE];
uint8_t fabric_node_name[WWN_SIZE];
+
+ uint16_t fcoe_vlan_id;
+ uint16_t fcoe_fcf_idx;
+ uint8_t fcoe_vn_port_mac[6];
+
uint32_t vp_abort_cnt;
struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
@@ -2643,7 +2653,7 @@ typedef struct scsi_qla_host {
#define VP_ERR_FAB_LOGOUT 4
#define VP_ERR_ADAP_NORESOURCES 5
struct qla_hw_data *hw;
- int req_ques[QLA_MAX_HOST_QUES];
+ struct req_que *req;
} scsi_qla_host_t;
/*
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index 96ccb9642ba0..f389f3da0bab 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -1711,7 +1711,7 @@ struct ex_init_cb_81xx {
#define FA_VPD0_ADDR_81 0xD0000
#define FA_VPD1_ADDR_81 0xD0400
#define FA_NVRAM0_ADDR_81 0xD0080
-#define FA_NVRAM1_ADDR_81 0xD0480
+#define FA_NVRAM1_ADDR_81 0xD0180
#define FA_FEATURE_ADDR_81 0xD4000
#define FA_FLASH_DESCR_ADDR_81 0xD8000
#define FA_FLASH_LAYOUT_ADDR_81 0xD8400
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 528913f6bed9..f17d525897a0 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -65,8 +65,11 @@ extern int ql2xfdmienable;
extern int ql2xallocfwdump;
extern int ql2xextended_error_logging;
extern int ql2xqfullrampup;
+extern int ql2xqfulltracking;
extern int ql2xiidmaenable;
extern int ql2xmaxqueues;
+extern int ql2xmultique_tag;
+extern int ql2xfwloadbin;
extern int qla2x00_loop_reset(scsi_qla_host_t *);
extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
@@ -165,13 +168,13 @@ extern int
qla2x00_issue_iocb(scsi_qla_host_t *, void *, dma_addr_t, size_t);
extern int
-qla2x00_abort_command(scsi_qla_host_t *, srb_t *, struct req_que *);
+qla2x00_abort_command(srb_t *);
extern int
-qla2x00_abort_target(struct fc_port *, unsigned int);
+qla2x00_abort_target(struct fc_port *, unsigned int, int);
extern int
-qla2x00_lun_reset(struct fc_port *, unsigned int);
+qla2x00_lun_reset(struct fc_port *, unsigned int, int);
extern int
qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *,
@@ -236,9 +239,11 @@ extern int
qla24xx_get_isp_stats(scsi_qla_host_t *, struct link_statistics *,
dma_addr_t);
-extern int qla24xx_abort_command(scsi_qla_host_t *, srb_t *, struct req_que *);
-extern int qla24xx_abort_target(struct fc_port *, unsigned int);
-extern int qla24xx_lun_reset(struct fc_port *, unsigned int);
+extern int qla24xx_abort_command(srb_t *);
+extern int
+qla24xx_abort_target(struct fc_port *, unsigned int, int);
+extern int
+qla24xx_lun_reset(struct fc_port *, unsigned int, int);
extern int
qla2x00_system_error(scsi_qla_host_t *);
@@ -295,8 +300,8 @@ extern irqreturn_t qla2100_intr_handler(int, void *);
extern irqreturn_t qla2300_intr_handler(int, void *);
extern irqreturn_t qla24xx_intr_handler(int, void *);
extern void qla2x00_process_response_queue(struct rsp_que *);
-extern void qla24xx_process_response_queue(struct rsp_que *);
-
+extern void
+qla24xx_process_response_queue(struct scsi_qla_host *, struct rsp_que *);
extern int qla2x00_request_irqs(struct qla_hw_data *, struct rsp_que *);
extern void qla2x00_free_irqs(scsi_qla_host_t *);
@@ -401,19 +406,21 @@ extern int qla25xx_request_irq(struct rsp_que *);
extern int qla25xx_init_req_que(struct scsi_qla_host *, struct req_que *);
extern int qla25xx_init_rsp_que(struct scsi_qla_host *, struct rsp_que *);
extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t,
- uint16_t, uint8_t, uint8_t);
+ uint16_t, int, uint8_t);
extern int qla25xx_create_rsp_que(struct qla_hw_data *, uint16_t, uint8_t,
- uint16_t);
+ uint16_t, int);
extern int qla25xx_update_req_que(struct scsi_qla_host *, uint8_t, uint8_t);
extern void qla2x00_init_response_q_entries(struct rsp_que *);
extern int qla25xx_delete_req_que(struct scsi_qla_host *, struct req_que *);
extern int qla25xx_delete_rsp_que(struct scsi_qla_host *, struct rsp_que *);
extern int qla25xx_create_queues(struct scsi_qla_host *, uint8_t);
-extern int qla25xx_delete_queues(struct scsi_qla_host *, uint8_t);
+extern int qla25xx_delete_queues(struct scsi_qla_host *);
extern uint16_t qla24xx_rd_req_reg(struct qla_hw_data *, uint16_t);
extern uint16_t qla25xx_rd_req_reg(struct qla_hw_data *, uint16_t);
extern void qla24xx_wrt_req_reg(struct qla_hw_data *, uint16_t, uint16_t);
extern void qla25xx_wrt_req_reg(struct qla_hw_data *, uint16_t, uint16_t);
extern void qla25xx_wrt_rsp_reg(struct qla_hw_data *, uint16_t, uint16_t);
extern void qla24xx_wrt_rsp_reg(struct qla_hw_data *, uint16_t, uint16_t);
+extern struct scsi_qla_host * qla25xx_get_host(struct rsp_que *);
+
#endif /* _QLA_GBL_H */
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 557f58d5bf88..3dbb9e73e80a 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1107,7 +1107,7 @@ qla2x00_mgmt_svr_login(scsi_qla_host_t *vha)
return ret;
ha->isp_ops->fabric_login(vha, vha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa,
- mb, BIT_1);
+ mb, BIT_1|BIT_0);
if (mb[0] != MBS_COMMAND_COMPLETE) {
DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
"loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index bd7dd84c0648..33e924810666 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -634,7 +634,7 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
goto chip_diag_failed;
DEBUG3(printk("scsi(%ld): Reset register cleared by chip reset\n",
- ha->host_no));
+ vha->host_no));
/* Reset RISC processor. */
WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
@@ -655,7 +655,7 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
goto chip_diag_failed;
/* Check product ID of chip */
- DEBUG3(printk("scsi(%ld): Checking product ID of chip\n", ha->host_no));
+ DEBUG3(printk("scsi(%ld): Checking product ID of chip\n", vha->host_no));
mb[1] = RD_MAILBOX_REG(ha, reg, 1);
mb[2] = RD_MAILBOX_REG(ha, reg, 2);
@@ -786,7 +786,6 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
sizeof(uint32_t);
if (ha->mqenable)
mq_size = sizeof(struct qla2xxx_mq_chain);
-
/* Allocate memory for Fibre Channel Event Buffer. */
if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))
goto try_eft;
@@ -850,8 +849,7 @@ cont_alloc:
rsp_q_size = rsp->length * sizeof(response_t);
dump_size = offsetof(struct qla2xxx_fw_dump, isp);
- dump_size += fixed_size + mem_size + req_q_size + rsp_q_size +
- eft_size;
+ dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + eft_size;
ha->chain_offset = dump_size;
dump_size += mq_size + fce_size;
@@ -1013,12 +1011,14 @@ qla2x00_init_response_q_entries(struct rsp_que *rsp)
uint16_t cnt;
response_t *pkt;
+ rsp->ring_ptr = rsp->ring;
+ rsp->ring_index = 0;
+ rsp->status_srb = NULL;
pkt = rsp->ring_ptr;
for (cnt = 0; cnt < rsp->length; cnt++) {
pkt->signature = RESPONSE_PROCESSED;
pkt++;
}
-
}
/**
@@ -1176,7 +1176,7 @@ qla24xx_config_rings(struct scsi_qla_host *vha)
if (ha->flags.msix_enabled) {
msix = &ha->msix_entries[1];
DEBUG2_17(printk(KERN_INFO
- "Reistering vector 0x%x for base que\n", msix->entry));
+ "Registering vector 0x%x for base que\n", msix->entry));
icb->msix = cpu_to_le16(msix->entry);
}
/* Use alternate PCI bus number */
@@ -1230,14 +1230,14 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
spin_lock_irqsave(&ha->hardware_lock, flags);
/* Clear outstanding commands array. */
- for (que = 0; que < ha->max_queues; que++) {
+ for (que = 0; que < ha->max_req_queues; que++) {
req = ha->req_q_map[que];
if (!req)
continue;
- for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++)
+ for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++)
req->outstanding_cmds[cnt] = NULL;
- req->current_outstanding_cmd = 0;
+ req->current_outstanding_cmd = 1;
/* Initialize firmware. */
req->ring_ptr = req->ring;
@@ -1245,13 +1245,10 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
req->cnt = req->length;
}
- for (que = 0; que < ha->max_queues; que++) {
+ for (que = 0; que < ha->max_rsp_queues; que++) {
rsp = ha->rsp_q_map[que];
if (!rsp)
continue;
- rsp->ring_ptr = rsp->ring;
- rsp->ring_index = 0;
-
/* Initialize response queue entries */
qla2x00_init_response_q_entries(rsp);
}
@@ -1541,6 +1538,7 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len,
char *st, *en;
uint16_t index;
struct qla_hw_data *ha = vha->hw;
+ int use_tbl = !IS_QLA25XX(ha) && IS_QLA81XX(ha);
if (memcmp(model, BINZERO, len) != 0) {
strncpy(ha->model_number, model, len);
@@ -1553,14 +1551,16 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len,
}
index = (ha->pdev->subsystem_device & 0xff);
- if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
+ if (use_tbl &&
+ ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
index < QLA_MODEL_NAMES)
strncpy(ha->model_desc,
qla2x00_model_name[index * 2 + 1],
sizeof(ha->model_desc) - 1);
} else {
index = (ha->pdev->subsystem_device & 0xff);
- if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
+ if (use_tbl &&
+ ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
index < QLA_MODEL_NAMES) {
strcpy(ha->model_number,
qla2x00_model_name[index * 2]);
@@ -2110,7 +2110,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
goto cleanup_allocation;
DEBUG3(printk("scsi(%ld): Entries in ID list (%d)\n",
- ha->host_no, entries));
+ vha->host_no, entries));
DEBUG3(qla2x00_dump_buffer((uint8_t *)ha->gid_list,
entries * sizeof(struct gid_list_info)));
@@ -3180,9 +3180,14 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
{
int rval = QLA_SUCCESS;
uint32_t wait_time;
- struct qla_hw_data *ha = vha->hw;
- struct req_que *req = ha->req_q_map[vha->req_ques[0]];
- struct rsp_que *rsp = req->rsp;
+ struct req_que *req;
+ struct rsp_que *rsp;
+
+ if (ql2xmultique_tag)
+ req = vha->hw->req_q_map[0];
+ else
+ req = vha->req;
+ rsp = req->rsp;
atomic_set(&vha->loop_state, LOOP_UPDATE);
clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags);
@@ -3448,7 +3453,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
int ret = -1;
int i;
- for (i = 1; i < ha->max_queues; i++) {
+ for (i = 1; i < ha->max_rsp_queues; i++) {
rsp = ha->rsp_q_map[i];
if (rsp) {
rsp->options &= ~BIT_0;
@@ -3462,6 +3467,8 @@ qla25xx_init_queues(struct qla_hw_data *ha)
"%s Rsp que:%d inited\n", __func__,
rsp->id));
}
+ }
+ for (i = 1; i < ha->max_req_queues; i++) {
req = ha->req_q_map[i];
if (req) {
/* Clear outstanding commands array. */
@@ -3566,14 +3573,15 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
nv = ha->nvram;
/* Determine NVRAM starting address. */
- ha->nvram_size = sizeof(struct nvram_24xx);
- ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
- ha->vpd_size = FA_NVRAM_VPD_SIZE;
- ha->vpd_base = FA_NVRAM_VPD0_ADDR;
- if (PCI_FUNC(ha->pdev->devfn)) {
+ if (ha->flags.port0) {
+ ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
+ ha->vpd_base = FA_NVRAM_VPD0_ADDR;
+ } else {
ha->nvram_base = FA_NVRAM_FUNC1_ADDR;
ha->vpd_base = FA_NVRAM_VPD1_ADDR;
}
+ ha->nvram_size = sizeof(struct nvram_24xx);
+ ha->vpd_size = FA_NVRAM_VPD_SIZE;
/* Get VPD data into cache */
ha->vpd = ha->nvram + VPD_OFFSET;
@@ -3587,7 +3595,7 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
chksum += le32_to_cpu(*dptr++);
- DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
+ DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", vha->host_no));
DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
/* Bad NVRAM data, set defaults parameters. */
@@ -3612,7 +3620,7 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
nv->exchange_count = __constant_cpu_to_le16(0);
nv->hard_address = __constant_cpu_to_le16(124);
nv->port_name[0] = 0x21;
- nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
+ nv->port_name[1] = 0x00 + ha->port_no;
nv->port_name[2] = 0x00;
nv->port_name[3] = 0xe0;
nv->port_name[4] = 0x8b;
@@ -4104,6 +4112,9 @@ qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
{
int rval;
+ if (ql2xfwloadbin == 1)
+ return qla81xx_load_risc(vha, srisc_addr);
+
/*
* FW Load priority:
* 1) Firmware via request-firmware interface (.bin file).
@@ -4121,6 +4132,9 @@ qla81xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
{
int rval;
+ if (ql2xfwloadbin == 2)
+ return qla24xx_load_risc(vha, srisc_addr);
+
/*
* FW Load priority:
* 1) Firmware residing in flash.
@@ -4146,7 +4160,7 @@ qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha)
ret = qla2x00_stop_firmware(vha);
for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT &&
- retries ; retries--) {
+ ret != QLA_INVALID_COMMAND && retries ; retries--) {
ha->isp_ops->reset_chip(vha);
if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS)
continue;
@@ -4165,13 +4179,19 @@ qla24xx_configure_vhba(scsi_qla_host_t *vha)
uint16_t mb[MAILBOX_REGISTER_COUNT];
struct qla_hw_data *ha = vha->hw;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
- struct req_que *req = ha->req_q_map[vha->req_ques[0]];
- struct rsp_que *rsp = req->rsp;
+ struct req_que *req;
+ struct rsp_que *rsp;
if (!vha->vp_idx)
return -EINVAL;
rval = qla2x00_fw_ready(base_vha);
+ if (ql2xmultique_tag)
+ req = ha->req_q_map[0];
+ else
+ req = vha->req;
+ rsp = req->rsp;
+
if (rval == QLA_SUCCESS) {
clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL);
@@ -4305,7 +4325,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
chksum += le32_to_cpu(*dptr++);
- DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
+ DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", vha->host_no));
DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
/* Bad NVRAM data, set defaults parameters. */
@@ -4329,7 +4349,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
nv->execution_throttle = __constant_cpu_to_le16(0xFFFF);
nv->exchange_count = __constant_cpu_to_le16(0);
nv->port_name[0] = 0x21;
- nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
+ nv->port_name[1] = 0x00 + ha->port_no;
nv->port_name[2] = 0x00;
nv->port_name[3] = 0xe0;
nv->port_name[4] = 0x8b;
@@ -4363,7 +4383,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
nv->enode_mac[2] = 0x03;
nv->enode_mac[3] = 0x04;
nv->enode_mac[4] = 0x05;
- nv->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
+ nv->enode_mac[5] = 0x06 + ha->port_no;
rval = 1;
}
@@ -4396,7 +4416,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
icb->enode_mac[2] = 0x03;
icb->enode_mac[3] = 0x04;
icb->enode_mac[4] = 0x05;
- icb->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
+ icb->enode_mac[5] = 0x06 + ha->port_no;
}
/* Use extended-initialization control block. */
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index a8abbb95730d..b4c6010ee5fa 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -15,6 +15,7 @@ static request_t *qla2x00_req_pkt(struct scsi_qla_host *, struct req_que *,
struct rsp_que *rsp);
static void qla2x00_isp_cmd(struct scsi_qla_host *, struct req_que *);
+static void qla25xx_set_que(srb_t *, struct req_que **, struct rsp_que **);
/**
* qla2x00_get_cmd_direction() - Determine control_flag data direction.
* @cmd: SCSI command
@@ -92,9 +93,10 @@ qla2x00_calc_iocbs_64(uint16_t dsds)
* Returns a pointer to the Continuation Type 0 IOCB packet.
*/
static inline cont_entry_t *
-qla2x00_prep_cont_type0_iocb(struct req_que *req, struct scsi_qla_host *vha)
+qla2x00_prep_cont_type0_iocb(struct scsi_qla_host *vha)
{
cont_entry_t *cont_pkt;
+ struct req_que *req = vha->req;
/* Adjust ring index. */
req->ring_index++;
if (req->ring_index == req->length) {
@@ -120,10 +122,11 @@ qla2x00_prep_cont_type0_iocb(struct req_que *req, struct scsi_qla_host *vha)
* Returns a pointer to the continuation type 1 IOCB packet.
*/
static inline cont_a64_entry_t *
-qla2x00_prep_cont_type1_iocb(struct req_que *req, scsi_qla_host_t *vha)
+qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *vha)
{
cont_a64_entry_t *cont_pkt;
+ struct req_que *req = vha->req;
/* Adjust ring index. */
req->ring_index++;
if (req->ring_index == req->length) {
@@ -159,7 +162,6 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
struct scsi_cmnd *cmd;
struct scatterlist *sg;
int i;
- struct req_que *req;
cmd = sp->cmd;
@@ -174,8 +176,6 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
}
vha = sp->fcport->vha;
- req = sp->que;
-
cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
/* Three DSDs are available in the Command Type 2 IOCB */
@@ -192,7 +192,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
* Seven DSDs are available in the Continuation
* Type 0 IOCB.
*/
- cont_pkt = qla2x00_prep_cont_type0_iocb(req, vha);
+ cont_pkt = qla2x00_prep_cont_type0_iocb(vha);
cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address;
avail_dsds = 7;
}
@@ -220,7 +220,6 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
struct scsi_cmnd *cmd;
struct scatterlist *sg;
int i;
- struct req_que *req;
cmd = sp->cmd;
@@ -235,8 +234,6 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
}
vha = sp->fcport->vha;
- req = sp->que;
-
cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
/* Two DSDs are available in the Command Type 3 IOCB */
@@ -254,7 +251,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
* Five DSDs are available in the Continuation
* Type 1 IOCB.
*/
- cont_pkt = qla2x00_prep_cont_type1_iocb(req, vha);
+ cont_pkt = qla2x00_prep_cont_type1_iocb(vha);
cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
avail_dsds = 5;
}
@@ -353,7 +350,6 @@ qla2x00_start_scsi(srb_t *sp)
/* Build command packet */
req->current_outstanding_cmd = handle;
req->outstanding_cmds[handle] = sp;
- sp->que = req;
sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
req->cnt -= req_cnt;
@@ -453,6 +449,7 @@ __qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
mrk24->lun[2] = MSB(lun);
host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun));
mrk24->vp_index = vha->vp_idx;
+ mrk24->handle = MAKE_HANDLE(req->id, mrk24->handle);
} else {
SET_TARGET_ID(ha, mrk->target, loop_id);
mrk->lun = cpu_to_le16(lun);
@@ -531,9 +528,6 @@ qla2x00_req_pkt(struct scsi_qla_host *vha, struct req_que *req,
for (cnt = 0; cnt < REQUEST_ENTRY_SIZE / 4; cnt++)
*dword_ptr++ = 0;
- /* Set system defined field. */
- pkt->sys_define = (uint8_t)req->ring_index;
-
/* Set entry count. */
pkt->entry_count = 1;
@@ -656,7 +650,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
}
vha = sp->fcport->vha;
- req = sp->que;
+ req = vha->req;
/* Set transfer direction */
if (cmd->sc_data_direction == DMA_TO_DEVICE) {
@@ -687,7 +681,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
* Five DSDs are available in the Continuation
* Type 1 IOCB.
*/
- cont_pkt = qla2x00_prep_cont_type1_iocb(req, vha);
+ cont_pkt = qla2x00_prep_cont_type1_iocb(vha);
cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
avail_dsds = 5;
}
@@ -724,19 +718,12 @@ qla24xx_start_scsi(srb_t *sp)
struct scsi_cmnd *cmd = sp->cmd;
struct scsi_qla_host *vha = sp->fcport->vha;
struct qla_hw_data *ha = vha->hw;
- uint16_t que_id;
/* Setup device pointers. */
ret = 0;
- que_id = vha->req_ques[0];
- req = ha->req_q_map[que_id];
- sp->que = req;
+ qla25xx_set_que(sp, &req, &rsp);
- if (req->rsp)
- rsp = req->rsp;
- else
- rsp = ha->rsp_q_map[que_id];
/* So we know we haven't pci_map'ed anything yet */
tot_dsds = 0;
@@ -794,7 +781,7 @@ qla24xx_start_scsi(srb_t *sp)
req->cnt -= req_cnt;
cmd_pkt = (struct cmd_type_7 *)req->ring_ptr;
- cmd_pkt->handle = handle;
+ cmd_pkt->handle = MAKE_HANDLE(req->id, handle);
/* Zero out remaining portion of packet. */
/* tagged queuing modifier -- default is TSK_SIMPLE (0). */
@@ -823,6 +810,8 @@ qla24xx_start_scsi(srb_t *sp)
/* Set total data segment count. */
cmd_pkt->entry_count = (uint8_t)req_cnt;
+ /* Specify response queue number where completion should happen */
+ cmd_pkt->entry_status = (uint8_t) rsp->id;
wmb();
/* Adjust ring index. */
@@ -842,7 +831,7 @@ qla24xx_start_scsi(srb_t *sp)
/* Manage unprocessed RIO/ZIO commands in response queue. */
if (vha->flags.process_response_queue &&
rsp->ring_ptr->signature != RESPONSE_PROCESSED)
- qla24xx_process_response_queue(rsp);
+ qla24xx_process_response_queue(vha, rsp);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
return QLA_SUCCESS;
@@ -855,3 +844,21 @@ queuing_error:
return QLA_FUNCTION_FAILED;
}
+
+static void qla25xx_set_que(srb_t *sp, struct req_que **req,
+ struct rsp_que **rsp)
+{
+ struct scsi_cmnd *cmd = sp->cmd;
+ struct scsi_qla_host *vha = sp->fcport->vha;
+ struct qla_hw_data *ha = sp->fcport->vha->hw;
+ int affinity = cmd->request->cpu;
+
+ if (ql2xmultique_tag && affinity >= 0 &&
+ affinity < ha->max_rsp_queues - 1) {
+ *rsp = ha->rsp_q_map[affinity + 1];
+ *req = ha->req_q_map[1];
+ } else {
+ *req = vha->req;
+ *rsp = ha->rsp_q_map[0];
+ }
+}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index d04981848e56..eb35d2050f7a 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -13,10 +13,9 @@ static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
static void qla2x00_process_completed_request(struct scsi_qla_host *,
struct req_que *, uint32_t);
static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *);
-static void qla2x00_status_cont_entry(scsi_qla_host_t *, sts_cont_entry_t *);
+static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *);
static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
sts_entry_t *);
-static struct scsi_qla_host *qla2x00_get_rsp_host(struct rsp_que *);
/**
* qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
@@ -51,7 +50,7 @@ qla2100_intr_handler(int irq, void *dev_id)
status = 0;
spin_lock(&ha->hardware_lock);
- vha = qla2x00_get_rsp_host(rsp);
+ vha = pci_get_drvdata(ha->pdev);
for (iter = 50; iter--; ) {
hccr = RD_REG_WORD(&reg->hccr);
if (hccr & HCCR_RISC_PAUSE) {
@@ -147,7 +146,7 @@ qla2300_intr_handler(int irq, void *dev_id)
status = 0;
spin_lock(&ha->hardware_lock);
- vha = qla2x00_get_rsp_host(rsp);
+ vha = pci_get_drvdata(ha->pdev);
for (iter = 50; iter--; ) {
stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
if (stat & HSR_RISC_PAUSED) {
@@ -685,7 +684,7 @@ skip_rio:
vha->host_no));
if (IS_FWI2_CAPABLE(ha))
- qla24xx_process_response_queue(rsp);
+ qla24xx_process_response_queue(vha, rsp);
else
qla2x00_process_response_queue(rsp);
break;
@@ -766,7 +765,10 @@ qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, void *data)
struct qla_hw_data *ha = vha->hw;
struct req_que *req = NULL;
- req = ha->req_q_map[vha->req_ques[0]];
+ if (!ql2xqfulltracking)
+ return;
+
+ req = vha->req;
if (!req)
return;
if (req->max_q_depth <= sdev->queue_depth)
@@ -808,6 +810,9 @@ qla2x00_ramp_up_queue_depth(scsi_qla_host_t *vha, struct req_que *req,
fc_port_t *fcport;
struct scsi_device *sdev;
+ if (!ql2xqfulltracking)
+ return;
+
sdev = sp->cmd->device;
if (sdev->queue_depth >= req->max_q_depth)
return;
@@ -858,8 +863,8 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha,
qla2x00_ramp_up_queue_depth(vha, req, sp);
qla2x00_sp_compl(ha, sp);
} else {
- DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
- vha->host_no));
+ DEBUG2(printk("scsi(%ld) Req:%d: Invalid ISP SCSI completion"
+ " handle(%d)\n", vha->host_no, req->id, index));
qla_printk(KERN_WARNING, ha,
"Invalid ISP SCSI completion handle\n");
@@ -881,7 +886,7 @@ qla2x00_process_response_queue(struct rsp_que *rsp)
uint16_t handle_cnt;
uint16_t cnt;
- vha = qla2x00_get_rsp_host(rsp);
+ vha = pci_get_drvdata(ha->pdev);
if (!vha->flags.online)
return;
@@ -926,7 +931,7 @@ qla2x00_process_response_queue(struct rsp_que *rsp)
}
break;
case STATUS_CONT_TYPE:
- qla2x00_status_cont_entry(vha, (sts_cont_entry_t *)pkt);
+ qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt);
break;
default:
/* Type Not Supported. */
@@ -945,7 +950,8 @@ qla2x00_process_response_queue(struct rsp_que *rsp)
}
static inline void
-qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len)
+qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len,
+ struct rsp_que *rsp)
{
struct scsi_cmnd *cp = sp->cmd;
@@ -962,7 +968,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len)
sp->request_sense_ptr += sense_len;
sp->request_sense_length -= sense_len;
if (sp->request_sense_length != 0)
- sp->fcport->vha->status_srb = sp;
+ rsp->status_srb = sp;
DEBUG5(printk("%s(): Check condition Sense data, scsi(%ld:%d:%d:%d) "
"cmd=%p pid=%ld\n", __func__, sp->fcport->vha->host_no,
@@ -992,7 +998,9 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
uint32_t sense_len, rsp_info_len, resid_len, fw_resid_len;
uint8_t *rsp_info, *sense_data;
struct qla_hw_data *ha = vha->hw;
- struct req_que *req = rsp->req;
+ uint32_t handle;
+ uint16_t que;
+ struct req_que *req;
sts = (sts_entry_t *) pkt;
sts24 = (struct sts_entry_24xx *) pkt;
@@ -1003,18 +1011,20 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
comp_status = le16_to_cpu(sts->comp_status);
scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK;
}
-
+ handle = (uint32_t) LSW(sts->handle);
+ que = MSW(sts->handle);
+ req = ha->req_q_map[que];
/* Fast path completion. */
if (comp_status == CS_COMPLETE && scsi_status == 0) {
- qla2x00_process_completed_request(vha, req, sts->handle);
+ qla2x00_process_completed_request(vha, req, handle);
return;
}
/* Validate handle. */
- if (sts->handle < MAX_OUTSTANDING_COMMANDS) {
- sp = req->outstanding_cmds[sts->handle];
- req->outstanding_cmds[sts->handle] = NULL;
+ if (handle < MAX_OUTSTANDING_COMMANDS) {
+ sp = req->outstanding_cmds[handle];
+ req->outstanding_cmds[handle] = NULL;
} else
sp = NULL;
@@ -1030,7 +1040,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
cp = sp->cmd;
if (cp == NULL) {
DEBUG2(printk("scsi(%ld): Command already returned back to OS "
- "pkt->handle=%d sp=%p.\n", vha->host_no, sts->handle, sp));
+ "pkt->handle=%d sp=%p.\n", vha->host_no, handle, sp));
qla_printk(KERN_WARNING, ha,
"Command is NULL: already returned to OS (sp=%p)\n", sp);
@@ -1121,6 +1131,8 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
scsi_status));
/* Adjust queue depth for all luns on the port. */
+ if (!ql2xqfulltracking)
+ break;
fcport->last_queue_full = jiffies;
starget_for_each_device(cp->device->sdev_target,
fcport, qla2x00_adjust_sdev_qdepth_down);
@@ -1133,7 +1145,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
if (!(scsi_status & SS_SENSE_LEN_VALID))
break;
- qla2x00_handle_sense(sp, sense_data, sense_len);
+ qla2x00_handle_sense(sp, sense_data, sense_len, rsp);
break;
case CS_DATA_UNDERRUN:
@@ -1179,6 +1191,8 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
* Adjust queue depth for all luns on the
* port.
*/
+ if (!ql2xqfulltracking)
+ break;
fcport->last_queue_full = jiffies;
starget_for_each_device(
cp->device->sdev_target, fcport,
@@ -1192,7 +1206,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
if (!(scsi_status & SS_SENSE_LEN_VALID))
break;
- qla2x00_handle_sense(sp, sense_data, sense_len);
+ qla2x00_handle_sense(sp, sense_data, sense_len, rsp);
} else {
/*
* If RISC reports underrun and target does not report
@@ -1334,7 +1348,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
}
/* Place command on done queue. */
- if (vha->status_srb == NULL)
+ if (rsp->status_srb == NULL)
qla2x00_sp_compl(ha, sp);
}
@@ -1346,11 +1360,11 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
* Extended sense data.
*/
static void
-qla2x00_status_cont_entry(scsi_qla_host_t *vha, sts_cont_entry_t *pkt)
+qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
{
uint8_t sense_sz = 0;
- struct qla_hw_data *ha = vha->hw;
- srb_t *sp = vha->status_srb;
+ struct qla_hw_data *ha = rsp->hw;
+ srb_t *sp = rsp->status_srb;
struct scsi_cmnd *cp;
if (sp != NULL && sp->request_sense_length != 0) {
@@ -1362,7 +1376,7 @@ qla2x00_status_cont_entry(scsi_qla_host_t *vha, sts_cont_entry_t *pkt)
"cmd is NULL: already returned to OS (sp=%p)\n",
sp);
- vha->status_srb = NULL;
+ rsp->status_srb = NULL;
return;
}
@@ -1383,7 +1397,7 @@ qla2x00_status_cont_entry(scsi_qla_host_t *vha, sts_cont_entry_t *pkt)
/* Place command on done queue. */
if (sp->request_sense_length == 0) {
- vha->status_srb = NULL;
+ rsp->status_srb = NULL;
qla2x00_sp_compl(ha, sp);
}
}
@@ -1399,7 +1413,9 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
{
srb_t *sp;
struct qla_hw_data *ha = vha->hw;
- struct req_que *req = rsp->req;
+ uint32_t handle = LSW(pkt->handle);
+ uint16_t que = MSW(pkt->handle);
+ struct req_que *req = ha->req_q_map[que];
#if defined(QL_DEBUG_LEVEL_2)
if (pkt->entry_status & RF_INV_E_ORDER)
qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__);
@@ -1417,14 +1433,14 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
#endif
/* Validate handle. */
- if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
- sp = req->outstanding_cmds[pkt->handle];
+ if (handle < MAX_OUTSTANDING_COMMANDS)
+ sp = req->outstanding_cmds[handle];
else
sp = NULL;
if (sp) {
/* Free outstanding command slot. */
- req->outstanding_cmds[pkt->handle] = NULL;
+ req->outstanding_cmds[handle] = NULL;
/* Bad payload or header */
if (pkt->entry_status &
@@ -1486,13 +1502,10 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0)
* qla24xx_process_response_queue() - Process response queue entries.
* @ha: SCSI driver HA context
*/
-void
-qla24xx_process_response_queue(struct rsp_que *rsp)
+void qla24xx_process_response_queue(struct scsi_qla_host *vha,
+ struct rsp_que *rsp)
{
struct sts_entry_24xx *pkt;
- struct scsi_qla_host *vha;
-
- vha = qla2x00_get_rsp_host(rsp);
if (!vha->flags.online)
return;
@@ -1523,7 +1536,7 @@ qla24xx_process_response_queue(struct rsp_que *rsp)
qla2x00_status_entry(vha, rsp, pkt);
break;
case STATUS_CONT_TYPE:
- qla2x00_status_cont_entry(vha, (sts_cont_entry_t *)pkt);
+ qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt);
break;
case VP_RPT_ID_IOCB_TYPE:
qla24xx_report_id_acquisition(vha,
@@ -1626,7 +1639,7 @@ qla24xx_intr_handler(int irq, void *dev_id)
status = 0;
spin_lock(&ha->hardware_lock);
- vha = qla2x00_get_rsp_host(rsp);
+ vha = pci_get_drvdata(ha->pdev);
for (iter = 50; iter--; ) {
stat = RD_REG_DWORD(&reg->host_status);
if (stat & HSRX_RISC_PAUSED) {
@@ -1664,7 +1677,7 @@ qla24xx_intr_handler(int irq, void *dev_id)
break;
case 0x13:
case 0x14:
- qla24xx_process_response_queue(rsp);
+ qla24xx_process_response_queue(vha, rsp);
break;
default:
DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
@@ -1692,6 +1705,7 @@ qla24xx_msix_rsp_q(int irq, void *dev_id)
struct qla_hw_data *ha;
struct rsp_que *rsp;
struct device_reg_24xx __iomem *reg;
+ struct scsi_qla_host *vha;
rsp = (struct rsp_que *) dev_id;
if (!rsp) {
@@ -1704,7 +1718,8 @@ qla24xx_msix_rsp_q(int irq, void *dev_id)
spin_lock_irq(&ha->hardware_lock);
- qla24xx_process_response_queue(rsp);
+ vha = qla25xx_get_host(rsp);
+ qla24xx_process_response_queue(vha, rsp);
WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
spin_unlock_irq(&ha->hardware_lock);
@@ -1717,7 +1732,6 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
{
struct qla_hw_data *ha;
struct rsp_que *rsp;
- struct device_reg_24xx __iomem *reg;
rsp = (struct rsp_que *) dev_id;
if (!rsp) {
@@ -1726,13 +1740,8 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
return IRQ_NONE;
}
ha = rsp->hw;
- reg = &ha->iobase->isp24;
- spin_lock_irq(&ha->hardware_lock);
-
- qla24xx_process_response_queue(rsp);
-
- spin_unlock_irq(&ha->hardware_lock);
+ queue_work_on((int) (rsp->id - 1), ha->wq, &rsp->q_work);
return IRQ_HANDLED;
}
@@ -1760,7 +1769,7 @@ qla24xx_msix_default(int irq, void *dev_id)
status = 0;
spin_lock_irq(&ha->hardware_lock);
- vha = qla2x00_get_rsp_host(rsp);
+ vha = pci_get_drvdata(ha->pdev);
do {
stat = RD_REG_DWORD(&reg->host_status);
if (stat & HSRX_RISC_PAUSED) {
@@ -1798,7 +1807,7 @@ qla24xx_msix_default(int irq, void *dev_id)
break;
case 0x13:
case 0x14:
- qla24xx_process_response_queue(rsp);
+ qla24xx_process_response_queue(vha, rsp);
break;
default:
DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
@@ -1822,31 +1831,14 @@ qla24xx_msix_default(int irq, void *dev_id)
/* Interrupt handling helpers. */
struct qla_init_msix_entry {
- uint16_t entry;
- uint16_t index;
const char *name;
irq_handler_t handler;
};
-static struct qla_init_msix_entry base_queue = {
- .entry = 0,
- .index = 0,
- .name = "qla2xxx (default)",
- .handler = qla24xx_msix_default,
-};
-
-static struct qla_init_msix_entry base_rsp_queue = {
- .entry = 1,
- .index = 1,
- .name = "qla2xxx (rsp_q)",
- .handler = qla24xx_msix_rsp_q,
-};
-
-static struct qla_init_msix_entry multi_rsp_queue = {
- .entry = 1,
- .index = 1,
- .name = "qla2xxx (multi_q)",
- .handler = qla25xx_msix_rsp_q,
+static struct qla_init_msix_entry msix_entries[3] = {
+ { "qla2xxx (default)", qla24xx_msix_default },
+ { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q },
+ { "qla2xxx (multiq)", qla25xx_msix_rsp_q },
};
static void
@@ -1873,7 +1865,6 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
int i, ret;
struct msix_entry *entries;
struct qla_msix_entry *qentry;
- struct qla_init_msix_entry *msix_queue;
entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count,
GFP_KERNEL);
@@ -1900,7 +1891,7 @@ msix_failed:
ha->msix_count, ret);
goto msix_out;
}
- ha->max_queues = ha->msix_count - 1;
+ ha->max_rsp_queues = ha->msix_count - 1;
}
ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) *
ha->msix_count, GFP_KERNEL);
@@ -1918,45 +1909,27 @@ msix_failed:
qentry->rsp = NULL;
}
- /* Enable MSI-X for AENs for queue 0 */
- qentry = &ha->msix_entries[0];
- ret = request_irq(qentry->vector, base_queue.handler, 0,
- base_queue.name, rsp);
- if (ret) {
- qla_printk(KERN_WARNING, ha,
+ /* Enable MSI-X vectors for the base queue */
+ for (i = 0; i < 2; i++) {
+ qentry = &ha->msix_entries[i];
+ ret = request_irq(qentry->vector, msix_entries[i].handler,
+ 0, msix_entries[i].name, rsp);
+ if (ret) {
+ qla_printk(KERN_WARNING, ha,
"MSI-X: Unable to register handler -- %x/%d.\n",
qentry->vector, ret);
- qla24xx_disable_msix(ha);
- goto msix_out;
+ qla24xx_disable_msix(ha);
+ ha->mqenable = 0;
+ goto msix_out;
+ }
+ qentry->have_irq = 1;
+ qentry->rsp = rsp;
+ rsp->msix = qentry;
}
- qentry->have_irq = 1;
- qentry->rsp = rsp;
/* Enable MSI-X vector for response queue update for queue 0 */
- if (ha->max_queues > 1 && ha->mqiobase) {
+ if (ha->mqiobase && (ha->max_rsp_queues > 1 || ha->max_req_queues > 1))
ha->mqenable = 1;
- msix_queue = &multi_rsp_queue;
- qla_printk(KERN_INFO, ha,
- "MQ enabled, Number of Queue Resources: %d \n",
- ha->max_queues);
- } else {
- ha->mqenable = 0;
- msix_queue = &base_rsp_queue;
- }
-
- qentry = &ha->msix_entries[1];
- ret = request_irq(qentry->vector, msix_queue->handler, 0,
- msix_queue->name, rsp);
- if (ret) {
- qla_printk(KERN_WARNING, ha,
- "MSI-X: Unable to register handler -- %x/%d.\n",
- qentry->vector, ret);
- qla24xx_disable_msix(ha);
- ha->mqenable = 0;
- goto msix_out;
- }
- qentry->have_irq = 1;
- qentry->rsp = rsp;
msix_out:
kfree(entries);
@@ -2063,35 +2036,11 @@ qla2x00_free_irqs(scsi_qla_host_t *vha)
}
}
-static struct scsi_qla_host *
-qla2x00_get_rsp_host(struct rsp_que *rsp)
-{
- srb_t *sp;
- struct qla_hw_data *ha = rsp->hw;
- struct scsi_qla_host *vha = NULL;
- struct sts_entry_24xx *pkt;
- struct req_que *req;
-
- if (rsp->id) {
- pkt = (struct sts_entry_24xx *) rsp->ring_ptr;
- req = rsp->req;
- if (pkt && pkt->handle < MAX_OUTSTANDING_COMMANDS) {
- sp = req->outstanding_cmds[pkt->handle];
- if (sp)
- vha = sp->fcport->vha;
- }
- }
- if (!vha)
- /* handle it in base queue */
- vha = pci_get_drvdata(ha->pdev);
-
- return vha;
-}
int qla25xx_request_irq(struct rsp_que *rsp)
{
struct qla_hw_data *ha = rsp->hw;
- struct qla_init_msix_entry *intr = &multi_rsp_queue;
+ struct qla_init_msix_entry *intr = &msix_entries[2];
struct qla_msix_entry *msix = rsp->msix;
int ret;
@@ -2106,3 +2055,30 @@ int qla25xx_request_irq(struct rsp_que *rsp)
msix->rsp = rsp;
return ret;
}
+
+struct scsi_qla_host *
+qla25xx_get_host(struct rsp_que *rsp)
+{
+ srb_t *sp;
+ struct qla_hw_data *ha = rsp->hw;
+ struct scsi_qla_host *vha = NULL;
+ struct sts_entry_24xx *pkt;
+ struct req_que *req;
+ uint16_t que;
+ uint32_t handle;
+
+ pkt = (struct sts_entry_24xx *) rsp->ring_ptr;
+ que = MSW(pkt->handle);
+ handle = (uint32_t) LSW(pkt->handle);
+ req = ha->req_q_map[que];
+ if (handle < MAX_OUTSTANDING_COMMANDS) {
+ sp = req->outstanding_cmds[handle];
+ if (sp)
+ return sp->fcport->vha;
+ else
+ goto base_que;
+ }
+base_que:
+ vha = pci_get_drvdata(ha->pdev);
+ return vha;
+}
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index e67c1660bf46..7d0eeec9ba57 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -748,20 +748,20 @@ qla2x00_issue_iocb(scsi_qla_host_t *vha, void *buffer, dma_addr_t phys_addr,
* Kernel context.
*/
int
-qla2x00_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req)
+qla2x00_abort_command(srb_t *sp)
{
unsigned long flags = 0;
- fc_port_t *fcport;
int rval;
uint32_t handle = 0;
mbx_cmd_t mc;
mbx_cmd_t *mcp = &mc;
+ fc_port_t *fcport = sp->fcport;
+ scsi_qla_host_t *vha = fcport->vha;
struct qla_hw_data *ha = vha->hw;
+ struct req_que *req = vha->req;
DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", vha->host_no));
- fcport = sp->fcport;
-
spin_lock_irqsave(&ha->hardware_lock, flags);
for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
if (req->outstanding_cmds[handle] == sp)
@@ -800,7 +800,7 @@ qla2x00_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req)
}
int
-qla2x00_abort_target(struct fc_port *fcport, unsigned int l)
+qla2x00_abort_target(struct fc_port *fcport, unsigned int l, int tag)
{
int rval, rval2;
mbx_cmd_t mc;
@@ -813,8 +813,8 @@ qla2x00_abort_target(struct fc_port *fcport, unsigned int l)
l = l;
vha = fcport->vha;
- req = vha->hw->req_q_map[0];
- rsp = vha->hw->rsp_q_map[0];
+ req = vha->hw->req_q_map[tag];
+ rsp = vha->hw->rsp_q_map[tag];
mcp->mb[0] = MBC_ABORT_TARGET;
mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
if (HAS_EXTENDED_IDS(vha->hw)) {
@@ -850,7 +850,7 @@ qla2x00_abort_target(struct fc_port *fcport, unsigned int l)
}
int
-qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
+qla2x00_lun_reset(struct fc_port *fcport, unsigned int l, int tag)
{
int rval, rval2;
mbx_cmd_t mc;
@@ -862,8 +862,8 @@ qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
vha = fcport->vha;
- req = vha->hw->req_q_map[0];
- rsp = vha->hw->rsp_q_map[0];
+ req = vha->hw->req_q_map[tag];
+ rsp = vha->hw->rsp_q_map[tag];
mcp->mb[0] = MBC_LUN_RESET;
mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
if (HAS_EXTENDED_IDS(vha->hw))
@@ -931,6 +931,8 @@ qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
mcp->mb[9] = vha->vp_idx;
mcp->out_mb = MBX_9|MBX_0;
mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+ if (IS_QLA81XX(vha->hw))
+ mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10;
mcp->tov = MBX_TOV_SECONDS;
mcp->flags = 0;
rval = qla2x00_mailbox_command(vha, mcp);
@@ -952,9 +954,19 @@ qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
vha->host_no, rval));
} else {
- /*EMPTY*/
DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
vha->host_no));
+
+ if (IS_QLA81XX(vha->hw)) {
+ vha->fcoe_vlan_id = mcp->mb[9] & 0xfff;
+ vha->fcoe_fcf_idx = mcp->mb[10];
+ vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8;
+ vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff;
+ vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8;
+ vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff;
+ vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8;
+ vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff;
+ }
}
return rval;
@@ -1480,9 +1492,17 @@ qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
dma_addr_t lg_dma;
uint32_t iop[2];
struct qla_hw_data *ha = vha->hw;
+ struct req_que *req;
+ struct rsp_que *rsp;
DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
+ if (ql2xmultique_tag)
+ req = ha->req_q_map[0];
+ else
+ req = vha->req;
+ rsp = req->rsp;
+
lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
if (lg == NULL) {
DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
@@ -1493,6 +1513,7 @@ qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
lg->entry_count = 1;
+ lg->handle = MAKE_HANDLE(req->id, lg->handle);
lg->nport_handle = cpu_to_le16(loop_id);
lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI);
if (opt & BIT_0)
@@ -1741,6 +1762,8 @@ qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
struct logio_entry_24xx *lg;
dma_addr_t lg_dma;
struct qla_hw_data *ha = vha->hw;
+ struct req_que *req;
+ struct rsp_que *rsp;
DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
@@ -1752,8 +1775,14 @@ qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
}
memset(lg, 0, sizeof(struct logio_entry_24xx));
+ if (ql2xmaxqueues > 1)
+ req = ha->req_q_map[0];
+ else
+ req = vha->req;
+ rsp = req->rsp;
lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
lg->entry_count = 1;
+ lg->handle = MAKE_HANDLE(req->id, lg->handle);
lg->nport_handle = cpu_to_le16(loop_id);
lg->control_flags =
__constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
@@ -1864,9 +1893,6 @@ qla2x00_full_login_lip(scsi_qla_host_t *vha)
mbx_cmd_t mc;
mbx_cmd_t *mcp = &mc;
- if (IS_QLA81XX(vha->hw))
- return QLA_SUCCESS;
-
DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
vha->host_no));
@@ -2195,21 +2221,21 @@ qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
}
int
-qla24xx_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req)
+qla24xx_abort_command(srb_t *sp)
{
int rval;
- fc_port_t *fcport;
unsigned long flags = 0;
struct abort_entry_24xx *abt;
dma_addr_t abt_dma;
uint32_t handle;
+ fc_port_t *fcport = sp->fcport;
+ struct scsi_qla_host *vha = fcport->vha;
struct qla_hw_data *ha = vha->hw;
+ struct req_que *req = vha->req;
DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
- fcport = sp->fcport;
-
spin_lock_irqsave(&ha->hardware_lock, flags);
for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
if (req->outstanding_cmds[handle] == sp)
@@ -2231,6 +2257,7 @@ qla24xx_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req)
abt->entry_type = ABORT_IOCB_TYPE;
abt->entry_count = 1;
+ abt->handle = MAKE_HANDLE(req->id, abt->handle);
abt->nport_handle = cpu_to_le16(fcport->loop_id);
abt->handle_to_abort = handle;
abt->port_id[0] = fcport->d_id.b.al_pa;
@@ -2272,7 +2299,7 @@ struct tsk_mgmt_cmd {
static int
__qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
- unsigned int l)
+ unsigned int l, int tag)
{
int rval, rval2;
struct tsk_mgmt_cmd *tsk;
@@ -2286,8 +2313,11 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
vha = fcport->vha;
ha = vha->hw;
- req = ha->req_q_map[0];
- rsp = ha->rsp_q_map[0];
+ req = vha->req;
+ if (ql2xmultique_tag)
+ rsp = ha->rsp_q_map[tag + 1];
+ else
+ rsp = req->rsp;
tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
if (tsk == NULL) {
DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
@@ -2298,6 +2328,7 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
tsk->p.tsk.entry_count = 1;
+ tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle);
tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id);
tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
tsk->p.tsk.control_flags = cpu_to_le32(type);
@@ -2344,15 +2375,15 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
}
int
-qla24xx_abort_target(struct fc_port *fcport, unsigned int l)
+qla24xx_abort_target(struct fc_port *fcport, unsigned int l, int tag)
{
- return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l);
+ return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag);
}
int
-qla24xx_lun_reset(struct fc_port *fcport, unsigned int l)
+qla24xx_lun_reset(struct fc_port *fcport, unsigned int l, int tag)
{
- return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l);
+ return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag);
}
int
@@ -2446,6 +2477,8 @@ qla2x00_stop_firmware(scsi_qla_host_t *vha)
if (rval != QLA_SUCCESS) {
DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
vha->host_no, rval));
+ if (mcp->mb[0] == MBS_INVALID_COMMAND)
+ rval = QLA_INVALID_COMMAND;
} else {
DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
}
@@ -3141,6 +3174,8 @@ qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req)
WRT_REG_DWORD(&reg->req_q_in, 0);
WRT_REG_DWORD(&reg->req_q_out, 0);
}
+ req->req_q_in = &reg->req_q_in;
+ req->req_q_out = &reg->req_q_out;
spin_unlock_irqrestore(&ha->hardware_lock, flags);
rval = qla2x00_mailbox_command(vha, mcp);
@@ -3167,7 +3202,6 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
mcp->mb[6] = MSW(MSD(rsp->dma));
mcp->mb[7] = LSW(MSD(rsp->dma));
mcp->mb[5] = rsp->length;
- mcp->mb[11] = rsp->vp_idx;
mcp->mb[14] = rsp->msix->entry;
mcp->mb[13] = rsp->rid;
@@ -3179,7 +3213,7 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
mcp->mb[8] = 0;
/* que out ptr index */
mcp->mb[9] = 0;
- mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7
+ mcp->out_mb = MBX_14|MBX_13|MBX_9|MBX_8|MBX_7
|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
mcp->in_mb = MBX_0;
mcp->flags = MBX_DMA_OUT;
@@ -3384,7 +3418,7 @@ qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
vha->host_no, rval, mcp->mb[0]));
} else {
- DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+ DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
}
return rval;
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 51716c7e3008..650bcef08f2a 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -398,9 +398,8 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL);
- memset(vha->req_ques, 0, sizeof(vha->req_ques));
- vha->req_ques[0] = ha->req_q_map[0]->id;
- host->can_queue = ha->req_q_map[0]->length + 128;
+ vha->req = base_vha->req;
+ host->can_queue = base_vha->req->length + 128;
host->this_id = 255;
host->cmd_per_lun = 3;
host->max_cmd_len = MAX_CMDSZ;
@@ -515,76 +514,53 @@ int qla25xx_update_req_que(struct scsi_qla_host *vha, uint8_t que, uint8_t qos)
/* Delete all queues for a given vhost */
int
-qla25xx_delete_queues(struct scsi_qla_host *vha, uint8_t que_no)
+qla25xx_delete_queues(struct scsi_qla_host *vha)
{
int cnt, ret = 0;
struct req_que *req = NULL;
struct rsp_que *rsp = NULL;
struct qla_hw_data *ha = vha->hw;
- if (que_no) {
- /* Delete request queue */
- req = ha->req_q_map[que_no];
+ /* Delete request queues */
+ for (cnt = 1; cnt < ha->max_req_queues; cnt++) {
+ req = ha->req_q_map[cnt];
if (req) {
- rsp = req->rsp;
ret = qla25xx_delete_req_que(vha, req);
if (ret != QLA_SUCCESS) {
qla_printk(KERN_WARNING, ha,
- "Couldn't delete req que %d\n", req->id);
+ "Couldn't delete req que %d\n",
+ req->id);
return ret;
}
- /* Delete associated response queue */
- if (rsp) {
- ret = qla25xx_delete_rsp_que(vha, rsp);
- if (ret != QLA_SUCCESS) {
- qla_printk(KERN_WARNING, ha,
- "Couldn't delete rsp que %d\n",
- rsp->id);
- return ret;
- }
- }
}
- } else { /* delete all queues of this host */
- for (cnt = 0; cnt < QLA_MAX_HOST_QUES; cnt++) {
- /* Delete request queues */
- req = ha->req_q_map[vha->req_ques[cnt]];
- if (req && req->id) {
- rsp = req->rsp;
- ret = qla25xx_delete_req_que(vha, req);
- if (ret != QLA_SUCCESS) {
- qla_printk(KERN_WARNING, ha,
- "Couldn't delete req que %d\n",
- vha->req_ques[cnt]);
- return ret;
- }
- vha->req_ques[cnt] = ha->req_q_map[0]->id;
- /* Delete associated response queue */
- if (rsp && rsp->id) {
- ret = qla25xx_delete_rsp_que(vha, rsp);
- if (ret != QLA_SUCCESS) {
- qla_printk(KERN_WARNING, ha,
- "Couldn't delete rsp que %d\n",
- rsp->id);
- return ret;
- }
- }
+ }
+
+ /* Delete response queues */
+ for (cnt = 1; cnt < ha->max_rsp_queues; cnt++) {
+ rsp = ha->rsp_q_map[cnt];
+ if (rsp) {
+ ret = qla25xx_delete_rsp_que(vha, rsp);
+ if (ret != QLA_SUCCESS) {
+ qla_printk(KERN_WARNING, ha,
+ "Couldn't delete rsp que %d\n",
+ rsp->id);
+ return ret;
}
}
}
- qla_printk(KERN_INFO, ha, "Queues deleted for vport:%d\n",
- vha->vp_idx);
return ret;
}
int
qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
- uint8_t vp_idx, uint16_t rid, uint8_t rsp_que, uint8_t qos)
+ uint8_t vp_idx, uint16_t rid, int rsp_que, uint8_t qos)
{
int ret = 0;
struct req_que *req = NULL;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
uint16_t que_id = 0;
device_reg_t __iomem *reg;
+ uint32_t cnt;
req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
if (req == NULL) {
@@ -604,8 +580,8 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
}
mutex_lock(&ha->vport_lock);
- que_id = find_first_zero_bit(ha->req_qid_map, ha->max_queues);
- if (que_id >= ha->max_queues) {
+ que_id = find_first_zero_bit(ha->req_qid_map, ha->max_req_queues);
+ if (que_id >= ha->max_req_queues) {
mutex_unlock(&ha->vport_lock);
qla_printk(KERN_INFO, ha, "No resources to create "
"additional request queue\n");
@@ -617,10 +593,10 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
req->vp_idx = vp_idx;
req->qos = qos;
- if (ha->rsp_q_map[rsp_que]) {
+ if (rsp_que < 0)
+ req->rsp = NULL;
+ else
req->rsp = ha->rsp_q_map[rsp_que];
- req->rsp->req = req;
- }
/* Use alternate PCI bus number */
if (MSB(req->rid))
options |= BIT_4;
@@ -628,13 +604,16 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
if (LSB(req->rid))
options |= BIT_5;
req->options = options;
+
+ for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++)
+ req->outstanding_cmds[cnt] = NULL;
+ req->current_outstanding_cmd = 1;
+
req->ring_ptr = req->ring;
req->ring_index = 0;
req->cnt = req->length;
req->id = que_id;
reg = ISP_QUE_REG(ha, que_id);
- req->req_q_in = &reg->isp25mq.req_q_in;
- req->req_q_out = &reg->isp25mq.req_q_out;
req->max_q_depth = ha->req_q_map[0]->max_q_depth;
mutex_unlock(&ha->vport_lock);
@@ -654,10 +633,19 @@ que_failed:
return 0;
}
+static void qla_do_work(struct work_struct *work)
+{
+ struct rsp_que *rsp = container_of(work, struct rsp_que, q_work);
+ struct scsi_qla_host *vha;
+
+ vha = qla25xx_get_host(rsp);
+ qla24xx_process_response_queue(vha, rsp);
+}
+
/* create response queue */
int
qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
- uint8_t vp_idx, uint16_t rid)
+ uint8_t vp_idx, uint16_t rid, int req)
{
int ret = 0;
struct rsp_que *rsp = NULL;
@@ -672,7 +660,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
goto que_failed;
}
- rsp->length = RESPONSE_ENTRY_CNT_2300;
+ rsp->length = RESPONSE_ENTRY_CNT_MQ;
rsp->ring = dma_alloc_coherent(&ha->pdev->dev,
(rsp->length + 1) * sizeof(response_t),
&rsp->dma, GFP_KERNEL);
@@ -683,8 +671,8 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
}
mutex_lock(&ha->vport_lock);
- que_id = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues);
- if (que_id >= ha->max_queues) {
+ que_id = find_first_zero_bit(ha->rsp_qid_map, ha->max_rsp_queues);
+ if (que_id >= ha->max_rsp_queues) {
mutex_unlock(&ha->vport_lock);
qla_printk(KERN_INFO, ha, "No resources to create "
"additional response queue\n");
@@ -708,8 +696,6 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
if (LSB(rsp->rid))
options |= BIT_5;
rsp->options = options;
- rsp->ring_ptr = rsp->ring;
- rsp->ring_index = 0;
rsp->id = que_id;
reg = ISP_QUE_REG(ha, que_id);
rsp->rsp_q_in = &reg->isp25mq.rsp_q_in;
@@ -728,9 +714,14 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
mutex_unlock(&ha->vport_lock);
goto que_failed;
}
+ if (req >= 0)
+ rsp->req = ha->req_q_map[req];
+ else
+ rsp->req = NULL;
qla2x00_init_response_q_entries(rsp);
-
+ if (rsp->hw->wq)
+ INIT_WORK(&rsp->q_work, qla_do_work);
return rsp->id;
que_failed:
@@ -744,14 +735,16 @@ qla25xx_create_queues(struct scsi_qla_host *vha, uint8_t qos)
uint16_t options = 0;
uint8_t ret = 0;
struct qla_hw_data *ha = vha->hw;
+ struct rsp_que *rsp;
options |= BIT_1;
- ret = qla25xx_create_rsp_que(ha, options, vha->vp_idx, 0);
+ ret = qla25xx_create_rsp_que(ha, options, vha->vp_idx, 0, -1);
if (!ret) {
qla_printk(KERN_WARNING, ha, "Response Que create failed\n");
return ret;
} else
qla_printk(KERN_INFO, ha, "Response Que:%d created.\n", ret);
+ rsp = ha->rsp_q_map[ret];
options = 0;
if (qos & BIT_7)
@@ -759,10 +752,11 @@ qla25xx_create_queues(struct scsi_qla_host *vha, uint8_t qos)
ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, ret,
qos & ~BIT_7);
if (ret) {
- vha->req_ques[0] = ret;
+ vha->req = ha->req_q_map[ret];
qla_printk(KERN_INFO, ha, "Request Que:%d created.\n", ret);
} else
qla_printk(KERN_WARNING, ha, "Request Que create failed\n");
+ rsp->req = ha->req_q_map[ret];
return ret;
}
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index e4fdcdad80d0..f4f535536952 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -77,6 +77,14 @@ module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(ql2xmaxqdepth,
"Maximum queue depth to report for target devices.");
+int ql2xqfulltracking = 1;
+module_param(ql2xqfulltracking, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(ql2xqfulltracking,
+ "Controls whether the driver tracks queue full status "
+ "returns and dynamically adjusts a scsi device's queue "
+ "depth. Default is 1, perform tracking. Set to 0 to "
+ "disable dynamic tracking and adjustment of queue depth.");
+
int ql2xqfullrampup = 120;
module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(ql2xqfullrampup,
@@ -96,6 +104,23 @@ MODULE_PARM_DESC(ql2xmaxqueues,
"Enables MQ settings "
"Default is 1 for single queue. Set it to number \
of queues in MQ mode.");
+
+int ql2xmultique_tag;
+module_param(ql2xmultique_tag, int, S_IRUGO|S_IRUSR);
+MODULE_PARM_DESC(ql2xmultique_tag,
+ "Enables CPU affinity settings for the driver "
+ "Default is 0 for no affinity of request and response IO. "
+ "Set it to 1 to turn on the cpu affinity.");
+
+int ql2xfwloadbin;
+module_param(ql2xfwloadbin, int, S_IRUGO|S_IRUSR);
+MODULE_PARM_DESC(ql2xfwloadbin,
+ "Option to specify location from which to load ISP firmware:\n"
+ " 2 -- load firmware via the request_firmware() (hotplug)\n"
+ " interface.\n"
+ " 1 -- load firmware from flash.\n"
+ " 0 -- use default semantics.\n");
+
/*
* SCSI host template entry points
*/
@@ -187,7 +212,7 @@ static void qla2x00_sp_free_dma(srb_t *);
/* -------------------------------------------------------------------------- */
static int qla2x00_alloc_queues(struct qla_hw_data *ha)
{
- ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_queues,
+ ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues,
GFP_KERNEL);
if (!ha->req_q_map) {
qla_printk(KERN_WARNING, ha,
@@ -195,7 +220,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha)
goto fail_req_map;
}
- ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_queues,
+ ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues,
GFP_KERNEL);
if (!ha->rsp_q_map) {
qla_printk(KERN_WARNING, ha,
@@ -213,16 +238,8 @@ fail_req_map:
return -ENOMEM;
}
-static void qla2x00_free_que(struct qla_hw_data *ha, struct req_que *req,
- struct rsp_que *rsp)
+static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
{
- if (rsp && rsp->ring)
- dma_free_coherent(&ha->pdev->dev,
- (rsp->length + 1) * sizeof(response_t),
- rsp->ring, rsp->dma);
-
- kfree(rsp);
- rsp = NULL;
if (req && req->ring)
dma_free_coherent(&ha->pdev->dev,
(req->length + 1) * sizeof(request_t),
@@ -232,22 +249,77 @@ static void qla2x00_free_que(struct qla_hw_data *ha, struct req_que *req,
req = NULL;
}
+static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
+{
+ if (rsp && rsp->ring)
+ dma_free_coherent(&ha->pdev->dev,
+ (rsp->length + 1) * sizeof(response_t),
+ rsp->ring, rsp->dma);
+
+ kfree(rsp);
+ rsp = NULL;
+}
+
static void qla2x00_free_queues(struct qla_hw_data *ha)
{
struct req_que *req;
struct rsp_que *rsp;
int cnt;
- for (cnt = 0; cnt < ha->max_queues; cnt++) {
- rsp = ha->rsp_q_map[cnt];
+ for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
req = ha->req_q_map[cnt];
- qla2x00_free_que(ha, req, rsp);
+ qla2x00_free_req_que(ha, req);
+ }
+ kfree(ha->req_q_map);
+ ha->req_q_map = NULL;
+
+ for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) {
+ rsp = ha->rsp_q_map[cnt];
+ qla2x00_free_rsp_que(ha, rsp);
}
kfree(ha->rsp_q_map);
ha->rsp_q_map = NULL;
+}
- kfree(ha->req_q_map);
- ha->req_q_map = NULL;
+static int qla25xx_setup_mode(struct scsi_qla_host *vha)
+{
+ uint16_t options = 0;
+ int ques, req, ret;
+ struct qla_hw_data *ha = vha->hw;
+
+ if (ql2xmultique_tag) {
+ /* CPU affinity mode */
+ ha->wq = create_workqueue("qla2xxx_wq");
+ /* create a request queue for IO */
+ options |= BIT_7;
+ req = qla25xx_create_req_que(ha, options, 0, 0, -1,
+ QLA_DEFAULT_QUE_QOS);
+ if (!req) {
+ qla_printk(KERN_WARNING, ha,
+ "Can't create request queue\n");
+ goto fail;
+ }
+ vha->req = ha->req_q_map[req];
+ options |= BIT_1;
+ for (ques = 1; ques < ha->max_rsp_queues; ques++) {
+ ret = qla25xx_create_rsp_que(ha, options, 0, 0, req);
+ if (!ret) {
+ qla_printk(KERN_WARNING, ha,
+ "Response Queue create failed\n");
+ goto fail2;
+ }
+ }
+ DEBUG2(qla_printk(KERN_INFO, ha,
+ "CPU affinity mode enabled, no. of response"
+ " queues:%d, no. of request queues:%d\n",
+ ha->max_rsp_queues, ha->max_req_queues));
+ }
+ return 0;
+fail2:
+ qla25xx_delete_queues(vha);
+fail:
+ ha->mqenable = 0;
+ return 1;
}
static char *
@@ -387,7 +459,6 @@ qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
sp->fcport = fcport;
sp->cmd = cmd;
- sp->que = ha->req_q_map[0];
sp->flags = 0;
CMD_SP(cmd) = (void *)sp;
cmd->scsi_done = done;
@@ -612,7 +683,7 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
void
qla2x00_abort_fcport_cmds(fc_port_t *fcport)
{
- int cnt, que, id;
+ int cnt;
unsigned long flags;
srb_t *sp;
scsi_qla_host_t *vha = fcport->vha;
@@ -620,32 +691,27 @@ qla2x00_abort_fcport_cmds(fc_port_t *fcport)
struct req_que *req;
spin_lock_irqsave(&ha->hardware_lock, flags);
- for (que = 0; que < QLA_MAX_HOST_QUES; que++) {
- id = vha->req_ques[que];
- req = ha->req_q_map[id];
- if (!req)
+ req = vha->req;
+ for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
+ sp = req->outstanding_cmds[cnt];
+ if (!sp)
+ continue;
+ if (sp->fcport != fcport)
continue;
- for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
- sp = req->outstanding_cmds[cnt];
- if (!sp)
- continue;
- if (sp->fcport != fcport)
- continue;
- spin_unlock_irqrestore(&ha->hardware_lock, flags);
- if (ha->isp_ops->abort_command(vha, sp, req)) {
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ if (ha->isp_ops->abort_command(sp)) {
+ DEBUG2(qla_printk(KERN_WARNING, ha,
+ "Abort failed -- %lx\n",
+ sp->cmd->serial_number));
+ } else {
+ if (qla2x00_eh_wait_on_command(sp->cmd) !=
+ QLA_SUCCESS)
DEBUG2(qla_printk(KERN_WARNING, ha,
- "Abort failed -- %lx\n",
+ "Abort failed while waiting -- %lx\n",
sp->cmd->serial_number));
- } else {
- if (qla2x00_eh_wait_on_command(sp->cmd) !=
- QLA_SUCCESS)
- DEBUG2(qla_printk(KERN_WARNING, ha,
- "Abort failed while waiting -- %lx\n",
- sp->cmd->serial_number));
- }
- spin_lock_irqsave(&ha->hardware_lock, flags);
}
+ spin_lock_irqsave(&ha->hardware_lock, flags);
}
spin_unlock_irqrestore(&ha->hardware_lock, flags);
}
@@ -693,7 +759,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
unsigned long flags;
int wait = 0;
struct qla_hw_data *ha = vha->hw;
- struct req_que *req;
+ struct req_que *req = vha->req;
srb_t *spt;
qla2x00_block_error_handler(cmd);
@@ -709,7 +775,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
spt = (srb_t *) CMD_SP(cmd);
if (!spt)
return SUCCESS;
- req = spt->que;
/* Check active list for command command. */
spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -726,7 +791,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
" pid=%ld.\n", __func__, vha->host_no, sp, serial));
spin_unlock_irqrestore(&ha->hardware_lock, flags);
- if (ha->isp_ops->abort_command(vha, sp, req)) {
+ if (ha->isp_ops->abort_command(sp)) {
DEBUG2(printk("%s(%ld): abort_command "
"mbx failed.\n", __func__, vha->host_no));
ret = FAILED;
@@ -777,7 +842,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
return status;
spin_lock_irqsave(&ha->hardware_lock, flags);
- req = sp->que;
+ req = vha->req;
for (cnt = 1; status == QLA_SUCCESS &&
cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
sp = req->outstanding_cmds[cnt];
@@ -820,7 +885,7 @@ static char *reset_errors[] = {
static int
__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
- struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int))
+ struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int, int))
{
scsi_qla_host_t *vha = shost_priv(cmd->device->host);
fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
@@ -841,7 +906,8 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS)
goto eh_reset_failed;
err = 2;
- if (do_reset(fcport, cmd->device->lun) != QLA_SUCCESS)
+ if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1)
+ != QLA_SUCCESS)
goto eh_reset_failed;
err = 3;
if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id,
@@ -996,6 +1062,9 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
if (qla2x00_vp_abort_isp(vha))
goto eh_host_reset_lock;
} else {
+ if (ha->wq)
+ flush_workqueue(ha->wq);
+
set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
if (qla2x00_abort_isp(base_vha)) {
clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
@@ -1037,7 +1106,8 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
struct fc_port *fcport;
struct qla_hw_data *ha = vha->hw;
- if (ha->flags.enable_lip_full_login && !vha->vp_idx) {
+ if (ha->flags.enable_lip_full_login && !vha->vp_idx &&
+ !IS_QLA81XX(ha)) {
ret = qla2x00_full_login_lip(vha);
if (ret != QLA_SUCCESS) {
DEBUG2_3(printk("%s(%ld): failed: "
@@ -1064,7 +1134,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
if (fcport->port_type != FCT_TARGET)
continue;
- ret = ha->isp_ops->target_reset(fcport, 0);
+ ret = ha->isp_ops->target_reset(fcport, 0, 0);
if (ret != QLA_SUCCESS) {
DEBUG2_3(printk("%s(%ld): bus_reset failed: "
"target_reset=%d d_id=%x.\n", __func__,
@@ -1088,7 +1158,7 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
struct req_que *req;
spin_lock_irqsave(&ha->hardware_lock, flags);
- for (que = 0; que < ha->max_queues; que++) {
+ for (que = 0; que < ha->max_req_queues; que++) {
req = ha->req_q_map[que];
if (!req)
continue;
@@ -1123,7 +1193,7 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
scsi_qla_host_t *vha = shost_priv(sdev->host);
struct qla_hw_data *ha = vha->hw;
struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
- struct req_que *req = ha->req_q_map[vha->req_ques[0]];
+ struct req_que *req = vha->req;
if (sdev->tagged_supported)
scsi_activate_tcq(sdev, req->max_q_depth);
@@ -1511,6 +1581,13 @@ qla2x00_set_isp_flags(struct qla_hw_data *ha)
ha->fw_srisc_address = RISC_START_ADDRESS_2400;
break;
}
+
+ /* Get adapter physical port no from interrupt pin register. */
+ pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no);
+ if (ha->port_no & 1)
+ ha->flags.port0 = 1;
+ else
+ ha->flags.port0 = 0;
}
static int
@@ -1518,6 +1595,7 @@ qla2x00_iospace_config(struct qla_hw_data *ha)
{
resource_size_t pio;
uint16_t msix;
+ int cpus;
if (pci_request_selected_regions(ha->pdev, ha->bars,
QLA2XXX_DRIVER_NAME)) {
@@ -1571,8 +1649,9 @@ skip_pio:
}
/* Determine queue resources */
- ha->max_queues = 1;
- if (ql2xmaxqueues <= 1 || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
+ ha->max_req_queues = ha->max_rsp_queues = 1;
+ if ((ql2xmaxqueues <= 1 || ql2xmultique_tag < 1) &&
+ (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
goto mqiobase_exit;
ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
pci_resource_len(ha->pdev, 3));
@@ -1582,18 +1661,24 @@ skip_pio:
ha->msix_count = msix;
/* Max queues are bounded by available msix vectors */
/* queue 0 uses two msix vectors */
- if (ha->msix_count - 1 < ql2xmaxqueues)
- ha->max_queues = ha->msix_count - 1;
- else if (ql2xmaxqueues > QLA_MQ_SIZE)
- ha->max_queues = QLA_MQ_SIZE;
- else
- ha->max_queues = ql2xmaxqueues;
+ if (ql2xmultique_tag) {
+ cpus = num_online_cpus();
+ ha->max_rsp_queues = (ha->msix_count - 1 - cpus) ?
+ (cpus + 1) : (ha->msix_count - 1);
+ ha->max_req_queues = 2;
+ } else if (ql2xmaxqueues > 1) {
+ ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ?
+ QLA_MQ_SIZE : ql2xmaxqueues;
+ DEBUG2(qla_printk(KERN_INFO, ha, "QoS mode set, max no"
+ " of request queues:%d\n", ha->max_req_queues));
+ }
qla_printk(KERN_INFO, ha,
"MSI-X vector count: %d\n", msix);
- }
+ } else
+ qla_printk(KERN_INFO, ha, "BAR 3 not enabled\n");
mqiobase_exit:
- ha->msix_count = ha->max_queues + 1;
+ ha->msix_count = ha->max_rsp_queues + 1;
return (0);
iospace_error_exit:
@@ -1803,14 +1888,15 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
ret = -ENOMEM;
qla2x00_mem_free(ha);
- qla2x00_free_que(ha, req, rsp);
+ qla2x00_free_req_que(ha, req);
+ qla2x00_free_rsp_que(ha, rsp);
goto probe_hw_failed;
}
pci_set_drvdata(pdev, base_vha);
host = base_vha->host;
- base_vha->req_ques[0] = req->id;
+ base_vha->req = req;
host->can_queue = req->length + 128;
if (IS_QLA2XXX_MIDTYPE(ha))
base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx;
@@ -1841,7 +1927,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
}
ha->rsp_q_map[0] = rsp;
ha->req_q_map[0] = req;
-
+ rsp->req = req;
+ req->rsp = rsp;
+ set_bit(0, ha->req_qid_map);
+ set_bit(0, ha->rsp_qid_map);
/* FWI2-capable only. */
req->req_q_in = &ha->iobase->isp24.req_q_in;
req->req_q_out = &ha->iobase->isp24.req_q_out;
@@ -1866,6 +1955,12 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
goto probe_failed;
}
+ if (ha->mqenable)
+ if (qla25xx_setup_mode(base_vha))
+ qla_printk(KERN_WARNING, ha,
+ "Can't create queues, falling back to single"
+ " queue mode\n");
+
/*
* Startup the kernel thread for this host adapter
*/
@@ -1917,8 +2012,9 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
return 0;
probe_init_failed:
- qla2x00_free_que(ha, req, rsp);
- ha->max_queues = 0;
+ qla2x00_free_req_que(ha, req);
+ qla2x00_free_rsp_que(ha, rsp);
+ ha->max_req_queues = ha->max_rsp_queues = 0;
probe_failed:
if (base_vha->timer_active)
@@ -1976,6 +2072,13 @@ qla2x00_remove_one(struct pci_dev *pdev)
base_vha->flags.online = 0;
+ /* Flush the work queue and remove it */
+ if (ha->wq) {
+ flush_workqueue(ha->wq);
+ destroy_workqueue(ha->wq);
+ ha->wq = NULL;
+ }
+
/* Kill the kernel thread for this host */
if (ha->dpc_thread) {
struct task_struct *t = ha->dpc_thread;
@@ -2017,6 +2120,8 @@ qla2x00_free_device(scsi_qla_host_t *vha)
{
struct qla_hw_data *ha = vha->hw;
+ qla25xx_delete_queues(vha);
+
if (ha->flags.fce_enabled)
qla2x00_disable_fce_trace(vha, NULL, NULL);
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 152ecfc26cd2..22f97eb50cf9 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -219,8 +219,8 @@ qla2x00_write_nvram_word(struct qla_hw_data *ha, uint32_t addr, uint16_t data)
wait_cnt = NVR_WAIT_CNT;
do {
if (!--wait_cnt) {
- DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n",
- __func__, vha->host_no));
+ DEBUG9_10(qla_printk(KERN_WARNING, ha,
+ "NVRAM didn't go ready...\n"));
break;
}
NVRAM_DELAY();
@@ -349,7 +349,7 @@ qla2x00_clear_nvram_protection(struct qla_hw_data *ha)
wait_cnt = NVR_WAIT_CNT;
do {
if (!--wait_cnt) {
- DEBUG9_10(qla_printk(
+ DEBUG9_10(qla_printk(KERN_WARNING, ha,
"NVRAM didn't go ready...\n"));
break;
}
@@ -408,7 +408,8 @@ qla2x00_set_nvram_protection(struct qla_hw_data *ha, int stat)
wait_cnt = NVR_WAIT_CNT;
do {
if (!--wait_cnt) {
- DEBUG9_10(qla_printk("NVRAM didn't go ready...\n"));
+ DEBUG9_10(qla_printk(KERN_WARNING, ha,
+ "NVRAM didn't go ready...\n"));
break;
}
NVRAM_DELAY();
@@ -701,30 +702,30 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
break;
case FLT_REG_VPD_0:
ha->flt_region_vpd_nvram = start;
- if (!(PCI_FUNC(ha->pdev->devfn) & 1))
+ if (ha->flags.port0)
ha->flt_region_vpd = start;
break;
case FLT_REG_VPD_1:
- if (PCI_FUNC(ha->pdev->devfn) & 1)
+ if (!ha->flags.port0)
ha->flt_region_vpd = start;
break;
case FLT_REG_NVRAM_0:
- if (!(PCI_FUNC(ha->pdev->devfn) & 1))
+ if (ha->flags.port0)
ha->flt_region_nvram = start;
break;
case FLT_REG_NVRAM_1:
- if (PCI_FUNC(ha->pdev->devfn) & 1)
+ if (!ha->flags.port0)
ha->flt_region_nvram = start;
break;
case FLT_REG_FDT:
ha->flt_region_fdt = start;
break;
case FLT_REG_NPIV_CONF_0:
- if (!(PCI_FUNC(ha->pdev->devfn) & 1))
+ if (ha->flags.port0)
ha->flt_region_npiv_conf = start;
break;
case FLT_REG_NPIV_CONF_1:
- if (PCI_FUNC(ha->pdev->devfn) & 1)
+ if (!ha->flags.port0)
ha->flt_region_npiv_conf = start;
break;
}
@@ -744,12 +745,12 @@ no_flash_data:
ha->flt_region_fw = def_fw[def];
ha->flt_region_boot = def_boot[def];
ha->flt_region_vpd_nvram = def_vpd_nvram[def];
- ha->flt_region_vpd = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
+ ha->flt_region_vpd = ha->flags.port0 ?
def_vpd0[def]: def_vpd1[def];
- ha->flt_region_nvram = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
+ ha->flt_region_nvram = ha->flags.port0 ?
def_nvram0[def]: def_nvram1[def];
ha->flt_region_fdt = def_fdt[def];
- ha->flt_region_npiv_conf = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
+ ha->flt_region_npiv_conf = ha->flags.port0 ?
def_npiv_conf0[def]: def_npiv_conf1[def];
done:
DEBUG2(qla_printk(KERN_DEBUG, ha, "FLT[%s]: boot=0x%x fw=0x%x "
@@ -919,6 +920,7 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
entry = data + sizeof(struct qla_npiv_header);
cnt = le16_to_cpu(hdr.entries);
+ ha->flex_port_count = cnt;
for (i = 0; cnt; cnt--, entry++, i++) {
uint16_t flags;
struct fc_vport_identifiers vid;
@@ -1079,8 +1081,9 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
0xff0000) | ((fdata >> 16) & 0xff));
ret = qla24xx_erase_sector(vha, fdata);
if (ret != QLA_SUCCESS) {
- DEBUG9(qla_printk("Unable to erase sector: "
- "address=%x.\n", faddr));
+ DEBUG9(qla_printk(KERN_WARNING, ha,
+ "Unable to erase sector: address=%x.\n",
+ faddr));
break;
}
}
@@ -1240,8 +1243,9 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
ret = qla24xx_write_flash_dword(ha,
nvram_data_addr(ha, naddr), cpu_to_le32(*dwptr));
if (ret != QLA_SUCCESS) {
- DEBUG9(qla_printk("Unable to program nvram address=%x "
- "data=%x.\n", naddr, *dwptr));
+ DEBUG9(qla_printk(KERN_WARNING, ha,
+ "Unable to program nvram address=%x data=%x.\n",
+ naddr, *dwptr));
break;
}
}
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 19d1afc3a343..a1094e7d2b44 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
/*
* Driver version
*/
-#define QLA2XXX_VERSION "8.03.01-k1"
+#define QLA2XXX_VERSION "8.03.01-k2"
#define QLA_DRIVER_MAJOR_VER 8
#define QLA_DRIVER_MINOR_VER 3
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 213123b0486b..41a21772df12 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -887,7 +887,7 @@ static int resp_start_stop(struct scsi_cmnd * scp,
static sector_t get_sdebug_capacity(void)
{
if (scsi_debug_virtual_gb > 0)
- return 2048 * 1024 * scsi_debug_virtual_gb;
+ return 2048 * 1024 * (sector_t)scsi_debug_virtual_gb;
else
return sdebug_store_sectors;
}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index bb218c8b6e98..30f3275e119e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -240,11 +240,11 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
* is invalid. Prevent the garbage from being misinterpreted
* and prevent security leaks by zeroing out the excess data.
*/
- if (unlikely(req->data_len > 0 && req->data_len <= bufflen))
- memset(buffer + (bufflen - req->data_len), 0, req->data_len);
+ if (unlikely(req->resid_len > 0 && req->resid_len <= bufflen))
+ memset(buffer + (bufflen - req->resid_len), 0, req->resid_len);
if (resid)
- *resid = req->data_len;
+ *resid = req->resid_len;
ret = req->errors;
out:
blk_put_request(req);
@@ -546,14 +546,9 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
* to queue the remainder of them.
*/
if (blk_end_request(req, error, bytes)) {
- int leftover = (req->hard_nr_sectors << 9);
-
- if (blk_pc_request(req))
- leftover = req->data_len;
-
/* kill remainder if no retrys */
if (error && scsi_noretry_cmd(cmd))
- blk_end_request(req, error, leftover);
+ blk_end_request_all(req, error);
else {
if (requeue) {
/*
@@ -673,34 +668,6 @@ void scsi_release_buffers(struct scsi_cmnd *cmd)
EXPORT_SYMBOL(scsi_release_buffers);
/*
- * Bidi commands Must be complete as a whole, both sides at once.
- * If part of the bytes were written and lld returned
- * scsi_in()->resid and/or scsi_out()->resid this information will be left
- * in req->data_len and req->next_rq->data_len. The upper-layer driver can
- * decide what to do with this information.
- */
-static void scsi_end_bidi_request(struct scsi_cmnd *cmd)
-{
- struct request *req = cmd->request;
- unsigned int dlen = req->data_len;
- unsigned int next_dlen = req->next_rq->data_len;
-
- req->data_len = scsi_out(cmd)->resid;
- req->next_rq->data_len = scsi_in(cmd)->resid;
-
- /* The req and req->next_rq have not been completed */
- BUG_ON(blk_end_bidi_request(req, 0, dlen, next_dlen));
-
- scsi_release_buffers(cmd);
-
- /*
- * This will goose the queue request function at the end, so we don't
- * need to worry about launching another command.
- */
- scsi_next_command(cmd);
-}
-
-/*
* Function: scsi_io_completion()
*
* Purpose: Completion processing for block device I/O requests.
@@ -739,7 +706,6 @@ static void scsi_end_bidi_request(struct scsi_cmnd *cmd)
void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
{
int result = cmd->result;
- int this_count;
struct request_queue *q = cmd->device->request_queue;
struct request *req = cmd->request;
int error = 0;
@@ -773,12 +739,22 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
if (!sense_deferred)
error = -EIO;
}
+
+ req->resid_len = scsi_get_resid(cmd);
+
if (scsi_bidi_cmnd(cmd)) {
- /* will also release_buffers */
- scsi_end_bidi_request(cmd);
+ /*
+ * Bidi commands Must be complete as a whole,
+ * both sides at once.
+ */
+ req->next_rq->resid_len = scsi_in(cmd)->resid;
+
+ blk_end_request_all(req, 0);
+
+ scsi_release_buffers(cmd);
+ scsi_next_command(cmd);
return;
}
- req->data_len = scsi_get_resid(cmd);
}
BUG_ON(blk_bidi_rq(req)); /* bidi not support for !blk_pc_request yet */
@@ -787,9 +763,9 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
* Next deal with any sectors which we were able to correctly
* handle.
*/
- SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, "
+ SCSI_LOG_HLCOMPLETE(1, printk("%u sectors total, "
"%d bytes done.\n",
- req->nr_sectors, good_bytes));
+ blk_rq_sectors(req), good_bytes));
/*
* Recovered errors need reporting, but they're always treated
@@ -812,7 +788,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
*/
if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
return;
- this_count = blk_rq_bytes(req);
error = -EIO;
@@ -922,7 +897,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
if (driver_byte(result) & DRIVER_SENSE)
scsi_print_sense("", cmd);
}
- blk_end_request(req, -EIO, blk_rq_bytes(req));
+ blk_end_request_all(req, -EIO);
scsi_next_command(cmd);
break;
case ACTION_REPREP:
@@ -965,10 +940,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb,
count = blk_rq_map_sg(req->q, req, sdb->table.sgl);
BUG_ON(count > sdb->table.nents);
sdb->table.nents = count;
- if (blk_pc_request(req))
- sdb->length = req->data_len;
- else
- sdb->length = req->nr_sectors << 9;
+ sdb->length = blk_rq_bytes(req);
return BLKPREP_OK;
}
@@ -1087,22 +1059,21 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
if (unlikely(ret))
return ret;
} else {
- BUG_ON(req->data_len);
- BUG_ON(req->data);
+ BUG_ON(blk_rq_bytes(req));
memset(&cmd->sdb, 0, sizeof(cmd->sdb));
req->buffer = NULL;
}
cmd->cmd_len = req->cmd_len;
- if (!req->data_len)
+ if (!blk_rq_bytes(req))
cmd->sc_data_direction = DMA_NONE;
else if (rq_data_dir(req) == WRITE)
cmd->sc_data_direction = DMA_TO_DEVICE;
else
cmd->sc_data_direction = DMA_FROM_DEVICE;
- cmd->transfersize = req->data_len;
+ cmd->transfersize = blk_rq_bytes(req);
cmd->allowed = req->retries;
return BLKPREP_OK;
}
@@ -1212,7 +1183,7 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
break;
case BLKPREP_DEFER:
/*
- * If we defer, the elv_next_request() returns NULL, but the
+ * If we defer, the blk_peek_request() returns NULL, but the
* queue must be restarted, so we plug here if no returning
* command will automatically do that.
*/
@@ -1388,7 +1359,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
struct scsi_target *starget = scsi_target(sdev);
struct Scsi_Host *shost = sdev->host;
- blkdev_dequeue_request(req);
+ blk_start_request(req);
if (unlikely(cmd == NULL)) {
printk(KERN_CRIT "impossible request in %s.\n",
@@ -1480,7 +1451,7 @@ static void scsi_request_fn(struct request_queue *q)
if (!sdev) {
printk("scsi: killing requests for dead queue\n");
- while ((req = elv_next_request(q)) != NULL)
+ while ((req = blk_peek_request(q)) != NULL)
scsi_kill_request(req, q);
return;
}
@@ -1501,7 +1472,7 @@ static void scsi_request_fn(struct request_queue *q)
* that the request is fully prepared even if we cannot
* accept it.
*/
- req = elv_next_request(q);
+ req = blk_peek_request(q);
if (!req || !scsi_dev_queue_ready(q, sdev))
break;
@@ -1517,7 +1488,7 @@ static void scsi_request_fn(struct request_queue *q)
* Remove the request from the request list.
*/
if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req)))
- blkdev_dequeue_request(req);
+ blk_start_request(req);
sdev->device_busy++;
spin_unlock(q->queue_lock);
@@ -2441,20 +2412,18 @@ int
scsi_internal_device_unblock(struct scsi_device *sdev)
{
struct request_queue *q = sdev->request_queue;
- int err;
unsigned long flags;
/*
* Try to transition the scsi device to SDEV_RUNNING
* and goose the device queue if successful.
*/
- err = scsi_device_set_state(sdev, SDEV_RUNNING);
- if (err) {
- err = scsi_device_set_state(sdev, SDEV_CREATED);
-
- if (err)
- return err;
- }
+ if (sdev->sdev_state == SDEV_BLOCK)
+ sdev->sdev_state = SDEV_RUNNING;
+ else if (sdev->sdev_state == SDEV_CREATED_BLOCK)
+ sdev->sdev_state = SDEV_CREATED;
+ else
+ return -EINVAL;
spin_lock_irqsave(q->queue_lock, flags);
blk_start_queue(q);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 6f51ca485f35..c44783801402 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -115,12 +115,12 @@ MODULE_PARM_DESC(max_report_luns,
"REPORT LUNS maximum number of LUNS received (should be"
" between 1 and 16384)");
-static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ+3;
+static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ + 18;
module_param_named(inq_timeout, scsi_inq_timeout, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(inq_timeout,
"Timeout (in seconds) waiting for devices to answer INQUIRY."
- " Default is 5. Some non-compliant devices need more.");
+ " Default is 20. Some devices may need more; most need less.");
/* This lock protects only this list */
static DEFINE_SPINLOCK(async_scan_lock);
@@ -425,6 +425,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
INIT_LIST_HEAD(&starget->devices);
starget->state = STARGET_CREATED;
starget->scsi_level = SCSI_2;
+ starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED;
retry:
spin_lock_irqsave(shost->host_lock, flags);
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index 48ba413f7f6a..10303272ba45 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -387,7 +387,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
* we use REQ_TYPE_BLOCK_PC so scsi_init_io doesn't set the
* length for us.
*/
- cmd->sdb.length = rq->data_len;
+ cmd->sdb.length = blk_rq_bytes(rq);
return 0;
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index a152f89ae51c..3f64d93b6c8b 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -35,6 +35,7 @@
#include <linux/netlink.h>
#include <net/netlink.h>
#include <scsi/scsi_netlink_fc.h>
+#include <scsi/scsi_bsg_fc.h>
#include "scsi_priv.h"
#include "scsi_transport_fc_internal.h"
@@ -43,6 +44,10 @@ static void fc_vport_sched_delete(struct work_struct *work);
static int fc_vport_setup(struct Scsi_Host *shost, int channel,
struct device *pdev, struct fc_vport_identifiers *ids,
struct fc_vport **vport);
+static int fc_bsg_hostadd(struct Scsi_Host *, struct fc_host_attrs *);
+static int fc_bsg_rportadd(struct Scsi_Host *, struct fc_rport *);
+static void fc_bsg_remove(struct request_queue *);
+static void fc_bsg_goose_queue(struct fc_rport *);
/*
* Redefine so that we can have same named attributes in the
@@ -411,13 +416,26 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
return -ENOMEM;
}
+ fc_bsg_hostadd(shost, fc_host);
+ /* ignore any bsg add error - we just can't do sgio */
+
+ return 0;
+}
+
+static int fc_host_remove(struct transport_container *tc, struct device *dev,
+ struct device *cdev)
+{
+ struct Scsi_Host *shost = dev_to_shost(dev);
+ struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
+
+ fc_bsg_remove(fc_host->rqst_q);
return 0;
}
static DECLARE_TRANSPORT_CLASS(fc_host_class,
"fc_host",
fc_host_setup,
- NULL,
+ fc_host_remove,
NULL);
/*
@@ -2375,6 +2393,7 @@ fc_rport_final_delete(struct work_struct *work)
scsi_flush_work(shost);
fc_terminate_rport_io(rport);
+
/*
* Cancel any outstanding timers. These should really exist
* only when rmmod'ing the LLDD and we're asking for
@@ -2407,6 +2426,8 @@ fc_rport_final_delete(struct work_struct *work)
(i->f->dev_loss_tmo_callbk))
i->f->dev_loss_tmo_callbk(rport);
+ fc_bsg_remove(rport->rqst_q);
+
transport_remove_device(dev);
device_del(dev);
transport_destroy_device(dev);
@@ -2494,6 +2515,9 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
transport_add_device(dev);
transport_configure_device(dev);
+ fc_bsg_rportadd(shost, rport);
+ /* ignore any bsg add error - we just can't do sgio */
+
if (rport->roles & FC_PORT_ROLE_FCP_TARGET) {
/* initiate a scan of the target */
rport->flags |= FC_RPORT_SCAN_PENDING;
@@ -2658,6 +2682,8 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
spin_unlock_irqrestore(shost->host_lock,
flags);
+ fc_bsg_goose_queue(rport);
+
return rport;
}
}
@@ -3343,6 +3369,592 @@ fc_vport_sched_delete(struct work_struct *work)
}
+/*
+ * BSG support
+ */
+
+
+/**
+ * fc_destroy_bsgjob - routine to teardown/delete a fc bsg job
+ * @job: fc_bsg_job that is to be torn down
+ */
+static void
+fc_destroy_bsgjob(struct fc_bsg_job *job)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&job->job_lock, flags);
+ if (job->ref_cnt) {
+ spin_unlock_irqrestore(&job->job_lock, flags);
+ return;
+ }
+ spin_unlock_irqrestore(&job->job_lock, flags);
+
+ put_device(job->dev); /* release reference for the request */
+
+ kfree(job->request_payload.sg_list);
+ kfree(job->reply_payload.sg_list);
+ kfree(job);
+}
+
+
+/**
+ * fc_bsg_jobdone - completion routine for bsg requests that the LLD has
+ * completed
+ * @job: fc_bsg_job that is complete
+ */
+static void
+fc_bsg_jobdone(struct fc_bsg_job *job)
+{
+ struct request *req = job->req;
+ struct request *rsp = req->next_rq;
+ unsigned long flags;
+ int err;
+
+ spin_lock_irqsave(&job->job_lock, flags);
+ job->state_flags |= FC_RQST_STATE_DONE;
+ job->ref_cnt--;
+ spin_unlock_irqrestore(&job->job_lock, flags);
+
+ err = job->req->errors = job->reply->result;
+ if (err < 0)
+ /* we're only returning the result field in the reply */
+ job->req->sense_len = sizeof(uint32_t);
+ else
+ job->req->sense_len = job->reply_len;
+
+ /* we assume all request payload was transferred, residual == 0 */
+ req->resid_len = 0;
+
+ if (rsp) {
+ WARN_ON(job->reply->reply_payload_rcv_len > rsp->resid_len);
+
+ /* set reply (bidi) residual */
+ rsp->resid_len -= min(job->reply->reply_payload_rcv_len,
+ rsp->resid_len);
+ }
+
+ blk_end_request_all(req, err);
+
+ fc_destroy_bsgjob(job);
+}
+
+
+/**
+ * fc_bsg_job_timeout - handler for when a bsg request timesout
+ * @req: request that timed out
+ */
+static enum blk_eh_timer_return
+fc_bsg_job_timeout(struct request *req)
+{
+ struct fc_bsg_job *job = (void *) req->special;
+ struct Scsi_Host *shost = job->shost;
+ struct fc_internal *i = to_fc_internal(shost->transportt);
+ unsigned long flags;
+ int err = 0, done = 0;
+
+ if (job->rport && job->rport->port_state == FC_PORTSTATE_BLOCKED)
+ return BLK_EH_RESET_TIMER;
+
+ spin_lock_irqsave(&job->job_lock, flags);
+ if (job->state_flags & FC_RQST_STATE_DONE)
+ done = 1;
+ else
+ job->ref_cnt++;
+ spin_unlock_irqrestore(&job->job_lock, flags);
+
+ if (!done && i->f->bsg_timeout) {
+ /* call LLDD to abort the i/o as it has timed out */
+ err = i->f->bsg_timeout(job);
+ if (err)
+ printk(KERN_ERR "ERROR: FC BSG request timeout - LLD "
+ "abort failed with status %d\n", err);
+ }
+
+ if (!done) {
+ spin_lock_irqsave(&job->job_lock, flags);
+ job->ref_cnt--;
+ spin_unlock_irqrestore(&job->job_lock, flags);
+ fc_destroy_bsgjob(job);
+ }
+
+ /* the blk_end_sync_io() doesn't check the error */
+ return BLK_EH_HANDLED;
+}
+
+
+
+static int
+fc_bsg_map_buffer(struct fc_bsg_buffer *buf, struct request *req)
+{
+ size_t sz = (sizeof(struct scatterlist) * req->nr_phys_segments);
+
+ BUG_ON(!req->nr_phys_segments);
+
+ buf->sg_list = kzalloc(sz, GFP_KERNEL);
+ if (!buf->sg_list)
+ return -ENOMEM;
+ sg_init_table(buf->sg_list, req->nr_phys_segments);
+ buf->sg_cnt = blk_rq_map_sg(req->q, req, buf->sg_list);
+ buf->payload_len = blk_rq_bytes(req);
+ return 0;
+}
+
+
+/**
+ * fc_req_to_bsgjob - Allocate/create the fc_bsg_job structure for the
+ * bsg request
+ * @shost: SCSI Host corresponding to the bsg object
+ * @rport: (optional) FC Remote Port corresponding to the bsg object
+ * @req: BSG request that needs a job structure
+ */
+static int
+fc_req_to_bsgjob(struct Scsi_Host *shost, struct fc_rport *rport,
+ struct request *req)
+{
+ struct fc_internal *i = to_fc_internal(shost->transportt);
+ struct request *rsp = req->next_rq;
+ struct fc_bsg_job *job;
+ int ret;
+
+ BUG_ON(req->special);
+
+ job = kzalloc(sizeof(struct fc_bsg_job) + i->f->dd_bsg_size,
+ GFP_KERNEL);
+ if (!job)
+ return -ENOMEM;
+
+ /*
+ * Note: this is a bit silly.
+ * The request gets formatted as a SGIO v4 ioctl request, which
+ * then gets reformatted as a blk request, which then gets
+ * reformatted as a fc bsg request. And on completion, we have
+ * to wrap return results such that SGIO v4 thinks it was a scsi
+ * status. I hope this was all worth it.
+ */
+
+ req->special = job;
+ job->shost = shost;
+ job->rport = rport;
+ job->req = req;
+ if (i->f->dd_bsg_size)
+ job->dd_data = (void *)&job[1];
+ spin_lock_init(&job->job_lock);
+ job->request = (struct fc_bsg_request *)req->cmd;
+ job->request_len = req->cmd_len;
+ job->reply = req->sense;
+ job->reply_len = SCSI_SENSE_BUFFERSIZE; /* Size of sense buffer
+ * allocated */
+ if (req->bio) {
+ ret = fc_bsg_map_buffer(&job->request_payload, req);
+ if (ret)
+ goto failjob_rls_job;
+ }
+ if (rsp && rsp->bio) {
+ ret = fc_bsg_map_buffer(&job->reply_payload, rsp);
+ if (ret)
+ goto failjob_rls_rqst_payload;
+ }
+ job->job_done = fc_bsg_jobdone;
+ if (rport)
+ job->dev = &rport->dev;
+ else
+ job->dev = &shost->shost_gendev;
+ get_device(job->dev); /* take a reference for the request */
+
+ job->ref_cnt = 1;
+
+ return 0;
+
+
+failjob_rls_rqst_payload:
+ kfree(job->request_payload.sg_list);
+failjob_rls_job:
+ kfree(job);
+ return -ENOMEM;
+}
+
+
+enum fc_dispatch_result {
+ FC_DISPATCH_BREAK, /* on return, q is locked, break from q loop */
+ FC_DISPATCH_LOCKED, /* on return, q is locked, continue on */
+ FC_DISPATCH_UNLOCKED, /* on return, q is unlocked, continue on */
+};
+
+
+/**
+ * fc_bsg_host_dispatch - process fc host bsg requests and dispatch to LLDD
+ * @shost: scsi host rport attached to
+ * @job: bsg job to be processed
+ */
+static enum fc_dispatch_result
+fc_bsg_host_dispatch(struct request_queue *q, struct Scsi_Host *shost,
+ struct fc_bsg_job *job)
+{
+ struct fc_internal *i = to_fc_internal(shost->transportt);
+ int cmdlen = sizeof(uint32_t); /* start with length of msgcode */
+ int ret;
+
+ /* Validate the host command */
+ switch (job->request->msgcode) {
+ case FC_BSG_HST_ADD_RPORT:
+ cmdlen += sizeof(struct fc_bsg_host_add_rport);
+ break;
+
+ case FC_BSG_HST_DEL_RPORT:
+ cmdlen += sizeof(struct fc_bsg_host_del_rport);
+ break;
+
+ case FC_BSG_HST_ELS_NOLOGIN:
+ cmdlen += sizeof(struct fc_bsg_host_els);
+ /* there better be a xmt and rcv payloads */
+ if ((!job->request_payload.payload_len) ||
+ (!job->reply_payload.payload_len)) {
+ ret = -EINVAL;
+ goto fail_host_msg;
+ }
+ break;
+
+ case FC_BSG_HST_CT:
+ cmdlen += sizeof(struct fc_bsg_host_ct);
+ /* there better be xmt and rcv payloads */
+ if ((!job->request_payload.payload_len) ||
+ (!job->reply_payload.payload_len)) {
+ ret = -EINVAL;
+ goto fail_host_msg;
+ }
+ break;
+
+ case FC_BSG_HST_VENDOR:
+ cmdlen += sizeof(struct fc_bsg_host_vendor);
+ if ((shost->hostt->vendor_id == 0L) ||
+ (job->request->rqst_data.h_vendor.vendor_id !=
+ shost->hostt->vendor_id)) {
+ ret = -ESRCH;
+ goto fail_host_msg;
+ }
+ break;
+
+ default:
+ ret = -EBADR;
+ goto fail_host_msg;
+ }
+
+ /* check if we really have all the request data needed */
+ if (job->request_len < cmdlen) {
+ ret = -ENOMSG;
+ goto fail_host_msg;
+ }
+
+ ret = i->f->bsg_request(job);
+ if (!ret)
+ return FC_DISPATCH_UNLOCKED;
+
+fail_host_msg:
+ /* return the errno failure code as the only status */
+ BUG_ON(job->reply_len < sizeof(uint32_t));
+ job->reply->result = ret;
+ job->reply_len = sizeof(uint32_t);
+ fc_bsg_jobdone(job);
+ return FC_DISPATCH_UNLOCKED;
+}
+
+
+/*
+ * fc_bsg_goose_queue - restart rport queue in case it was stopped
+ * @rport: rport to be restarted
+ */
+static void
+fc_bsg_goose_queue(struct fc_rport *rport)
+{
+ int flagset;
+
+ if (!rport->rqst_q)
+ return;
+
+ get_device(&rport->dev);
+
+ spin_lock(rport->rqst_q->queue_lock);
+ flagset = test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags) &&
+ !test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags);
+ if (flagset)
+ queue_flag_set(QUEUE_FLAG_REENTER, rport->rqst_q);
+ __blk_run_queue(rport->rqst_q);
+ if (flagset)
+ queue_flag_clear(QUEUE_FLAG_REENTER, rport->rqst_q);
+ spin_unlock(rport->rqst_q->queue_lock);
+
+ put_device(&rport->dev);
+}
+
+
+/**
+ * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD
+ * @shost: scsi host rport attached to
+ * @rport: rport request destined to
+ * @job: bsg job to be processed
+ */
+static enum fc_dispatch_result
+fc_bsg_rport_dispatch(struct request_queue *q, struct Scsi_Host *shost,
+ struct fc_rport *rport, struct fc_bsg_job *job)
+{
+ struct fc_internal *i = to_fc_internal(shost->transportt);
+ int cmdlen = sizeof(uint32_t); /* start with length of msgcode */
+ int ret;
+
+ /* Validate the rport command */
+ switch (job->request->msgcode) {
+ case FC_BSG_RPT_ELS:
+ cmdlen += sizeof(struct fc_bsg_rport_els);
+ goto check_bidi;
+
+ case FC_BSG_RPT_CT:
+ cmdlen += sizeof(struct fc_bsg_rport_ct);
+check_bidi:
+ /* there better be xmt and rcv payloads */
+ if ((!job->request_payload.payload_len) ||
+ (!job->reply_payload.payload_len)) {
+ ret = -EINVAL;
+ goto fail_rport_msg;
+ }
+ break;
+ default:
+ ret = -EBADR;
+ goto fail_rport_msg;
+ }
+
+ /* check if we really have all the request data needed */
+ if (job->request_len < cmdlen) {
+ ret = -ENOMSG;
+ goto fail_rport_msg;
+ }
+
+ ret = i->f->bsg_request(job);
+ if (!ret)
+ return FC_DISPATCH_UNLOCKED;
+
+fail_rport_msg:
+ /* return the errno failure code as the only status */
+ BUG_ON(job->reply_len < sizeof(uint32_t));
+ job->reply->result = ret;
+ job->reply_len = sizeof(uint32_t);
+ fc_bsg_jobdone(job);
+ return FC_DISPATCH_UNLOCKED;
+}
+
+
+/**
+ * fc_bsg_request_handler - generic handler for bsg requests
+ * @q: request queue to manage
+ * @shost: Scsi_Host related to the bsg object
+ * @rport: FC remote port related to the bsg object (optional)
+ * @dev: device structure for bsg object
+ */
+static void
+fc_bsg_request_handler(struct request_queue *q, struct Scsi_Host *shost,
+ struct fc_rport *rport, struct device *dev)
+{
+ struct request *req;
+ struct fc_bsg_job *job;
+ enum fc_dispatch_result ret;
+
+ if (!get_device(dev))
+ return;
+
+ while (!blk_queue_plugged(q)) {
+ if (rport && (rport->port_state == FC_PORTSTATE_BLOCKED))
+ break;
+
+ req = blk_fetch_request(q);
+ if (!req)
+ break;
+
+ if (rport && (rport->port_state != FC_PORTSTATE_ONLINE)) {
+ req->errors = -ENXIO;
+ spin_unlock_irq(q->queue_lock);
+ blk_end_request(req, -ENXIO, blk_rq_bytes(req));
+ spin_lock_irq(q->queue_lock);
+ continue;
+ }
+
+ spin_unlock_irq(q->queue_lock);
+
+ ret = fc_req_to_bsgjob(shost, rport, req);
+ if (ret) {
+ req->errors = ret;
+ blk_end_request(req, ret, blk_rq_bytes(req));
+ spin_lock_irq(q->queue_lock);
+ continue;
+ }
+
+ job = req->special;
+
+ /* check if we have the msgcode value at least */
+ if (job->request_len < sizeof(uint32_t)) {
+ BUG_ON(job->reply_len < sizeof(uint32_t));
+ job->reply->result = -ENOMSG;
+ job->reply_len = sizeof(uint32_t);
+ fc_bsg_jobdone(job);
+ spin_lock_irq(q->queue_lock);
+ continue;
+ }
+
+ /* the dispatch routines will unlock the queue_lock */
+ if (rport)
+ ret = fc_bsg_rport_dispatch(q, shost, rport, job);
+ else
+ ret = fc_bsg_host_dispatch(q, shost, job);
+
+ /* did dispatcher hit state that can't process any more */
+ if (ret == FC_DISPATCH_BREAK)
+ break;
+
+ /* did dispatcher had released the lock */
+ if (ret == FC_DISPATCH_UNLOCKED)
+ spin_lock_irq(q->queue_lock);
+ }
+
+ spin_unlock_irq(q->queue_lock);
+ put_device(dev);
+ spin_lock_irq(q->queue_lock);
+}
+
+
+/**
+ * fc_bsg_host_handler - handler for bsg requests for a fc host
+ * @q: fc host request queue
+ */
+static void
+fc_bsg_host_handler(struct request_queue *q)
+{
+ struct Scsi_Host *shost = q->queuedata;
+
+ fc_bsg_request_handler(q, shost, NULL, &shost->shost_gendev);
+}
+
+
+/**
+ * fc_bsg_rport_handler - handler for bsg requests for a fc rport
+ * @q: rport request queue
+ */
+static void
+fc_bsg_rport_handler(struct request_queue *q)
+{
+ struct fc_rport *rport = q->queuedata;
+ struct Scsi_Host *shost = rport_to_shost(rport);
+
+ fc_bsg_request_handler(q, shost, rport, &rport->dev);
+}
+
+
+/**
+ * fc_bsg_hostadd - Create and add the bsg hooks so we can receive requests
+ * @shost: shost for fc_host
+ * @fc_host: fc_host adding the structures to
+ */
+static int
+fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)
+{
+ struct device *dev = &shost->shost_gendev;
+ struct fc_internal *i = to_fc_internal(shost->transportt);
+ struct request_queue *q;
+ int err;
+ char bsg_name[BUS_ID_SIZE]; /*20*/
+
+ fc_host->rqst_q = NULL;
+
+ if (!i->f->bsg_request)
+ return -ENOTSUPP;
+
+ snprintf(bsg_name, sizeof(bsg_name),
+ "fc_host%d", shost->host_no);
+
+ q = __scsi_alloc_queue(shost, fc_bsg_host_handler);
+ if (!q) {
+ printk(KERN_ERR "fc_host%d: bsg interface failed to "
+ "initialize - no request queue\n",
+ shost->host_no);
+ return -ENOMEM;
+ }
+
+ q->queuedata = shost;
+ queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q);
+ blk_queue_rq_timed_out(q, fc_bsg_job_timeout);
+ blk_queue_rq_timeout(q, FC_DEFAULT_BSG_TIMEOUT);
+
+ err = bsg_register_queue(q, dev, bsg_name, NULL);
+ if (err) {
+ printk(KERN_ERR "fc_host%d: bsg interface failed to "
+ "initialize - register queue\n",
+ shost->host_no);
+ blk_cleanup_queue(q);
+ return err;
+ }
+
+ fc_host->rqst_q = q;
+ return 0;
+}
+
+
+/**
+ * fc_bsg_rportadd - Create and add the bsg hooks so we can receive requests
+ * @shost: shost that rport is attached to
+ * @rport: rport that the bsg hooks are being attached to
+ */
+static int
+fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
+{
+ struct device *dev = &rport->dev;
+ struct fc_internal *i = to_fc_internal(shost->transportt);
+ struct request_queue *q;
+ int err;
+
+ rport->rqst_q = NULL;
+
+ if (!i->f->bsg_request)
+ return -ENOTSUPP;
+
+ q = __scsi_alloc_queue(shost, fc_bsg_rport_handler);
+ if (!q) {
+ printk(KERN_ERR "%s: bsg interface failed to "
+ "initialize - no request queue\n",
+ dev->kobj.name);
+ return -ENOMEM;
+ }
+
+ q->queuedata = rport;
+ queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q);
+ blk_queue_rq_timed_out(q, fc_bsg_job_timeout);
+ blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT);
+
+ err = bsg_register_queue(q, dev, NULL, NULL);
+ if (err) {
+ printk(KERN_ERR "%s: bsg interface failed to "
+ "initialize - register queue\n",
+ dev->kobj.name);
+ blk_cleanup_queue(q);
+ return err;
+ }
+
+ rport->rqst_q = q;
+ return 0;
+}
+
+
+/**
+ * fc_bsg_remove - Deletes the bsg hooks on fchosts/rports
+ * @q: the request_queue that is to be torn down.
+ */
+static void
+fc_bsg_remove(struct request_queue *q)
+{
+ if (q) {
+ bsg_unregister_queue(q);
+ blk_cleanup_queue(q);
+ }
+}
+
+
/* Original Author: Martin Hicks */
MODULE_AUTHOR("James Smart");
MODULE_DESCRIPTION("FC Transport Attributes");
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 094795455293..d69a53aa406f 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -357,7 +357,7 @@ int iscsi_session_chkready(struct iscsi_cls_session *session)
err = 0;
break;
case ISCSI_SESSION_FAILED:
- err = DID_TRANSPORT_DISRUPTED << 16;
+ err = DID_IMM_RETRY << 16;
break;
case ISCSI_SESSION_FREE:
err = DID_TRANSPORT_FAILFAST << 16;
@@ -1268,26 +1268,54 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
return err;
}
+static int iscsi_if_ep_connect(struct iscsi_transport *transport,
+ struct iscsi_uevent *ev, int msg_type)
+{
+ struct iscsi_endpoint *ep;
+ struct sockaddr *dst_addr;
+ struct Scsi_Host *shost = NULL;
+ int non_blocking, err = 0;
+
+ if (!transport->ep_connect)
+ return -EINVAL;
+
+ if (msg_type == ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST) {
+ shost = scsi_host_lookup(ev->u.ep_connect_through_host.host_no);
+ if (!shost) {
+ printk(KERN_ERR "ep connect failed. Could not find "
+ "host no %u\n",
+ ev->u.ep_connect_through_host.host_no);
+ return -ENODEV;
+ }
+ non_blocking = ev->u.ep_connect_through_host.non_blocking;
+ } else
+ non_blocking = ev->u.ep_connect.non_blocking;
+
+ dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
+ ep = transport->ep_connect(shost, dst_addr, non_blocking);
+ if (IS_ERR(ep)) {
+ err = PTR_ERR(ep);
+ goto release_host;
+ }
+
+ ev->r.ep_connect_ret.handle = ep->id;
+release_host:
+ if (shost)
+ scsi_host_put(shost);
+ return err;
+}
+
static int
iscsi_if_transport_ep(struct iscsi_transport *transport,
struct iscsi_uevent *ev, int msg_type)
{
struct iscsi_endpoint *ep;
- struct sockaddr *dst_addr;
int rc = 0;
switch (msg_type) {
+ case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST:
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
- if (!transport->ep_connect)
- return -EINVAL;
-
- dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
- ep = transport->ep_connect(dst_addr,
- ev->u.ep_connect.non_blocking);
- if (IS_ERR(ep))
- return PTR_ERR(ep);
-
- ev->r.ep_connect_ret.handle = ep->id;
+ rc = iscsi_if_ep_connect(transport, ev, msg_type);
break;
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
if (!transport->ep_poll)
@@ -1469,6 +1497,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
+ case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST:
err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type);
break;
case ISCSI_UEVENT_TGT_DSCVR:
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 50988cbf7b2d..d606452297cf 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -163,12 +163,10 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
while (!blk_queue_plugged(q)) {
- req = elv_next_request(q);
+ req = blk_fetch_request(q);
if (!req)
break;
- blkdev_dequeue_request(req);
-
spin_unlock_irq(q->queue_lock);
handler = to_sas_internal(shost->transportt)->f->smp_handler;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 84044233b637..bcf3bd40bbd5 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -384,9 +384,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
struct scsi_device *sdp = q->queuedata;
struct gendisk *disk = rq->rq_disk;
struct scsi_disk *sdkp;
- sector_t block = rq->sector;
+ sector_t block = blk_rq_pos(rq);
sector_t threshold;
- unsigned int this_count = rq->nr_sectors;
+ unsigned int this_count = blk_rq_sectors(rq);
int ret, host_dif;
if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
@@ -413,10 +413,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
this_count));
if (!sdp || !scsi_device_online(sdp) ||
- block + rq->nr_sectors > get_capacity(disk)) {
+ block + blk_rq_sectors(rq) > get_capacity(disk)) {
SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
- "Finishing %ld sectors\n",
- rq->nr_sectors));
+ "Finishing %u sectors\n",
+ blk_rq_sectors(rq)));
SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
"Retry with 0x%p\n", SCpnt));
goto out;
@@ -463,7 +463,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
* for this.
*/
if (sdp->sector_size == 1024) {
- if ((block & 1) || (rq->nr_sectors & 1)) {
+ if ((block & 1) || (blk_rq_sectors(rq) & 1)) {
scmd_printk(KERN_ERR, SCpnt,
"Bad block number requested\n");
goto out;
@@ -473,7 +473,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
}
}
if (sdp->sector_size == 2048) {
- if ((block & 3) || (rq->nr_sectors & 3)) {
+ if ((block & 3) || (blk_rq_sectors(rq) & 3)) {
scmd_printk(KERN_ERR, SCpnt,
"Bad block number requested\n");
goto out;
@@ -483,7 +483,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
}
}
if (sdp->sector_size == 4096) {
- if ((block & 7) || (rq->nr_sectors & 7)) {
+ if ((block & 7) || (blk_rq_sectors(rq) & 7)) {
scmd_printk(KERN_ERR, SCpnt,
"Bad block number requested\n");
goto out;
@@ -512,10 +512,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
}
SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
- "%s %d/%ld 512 byte blocks.\n",
+ "%s %d/%u 512 byte blocks.\n",
(rq_data_dir(rq) == WRITE) ?
"writing" : "reading", this_count,
- rq->nr_sectors));
+ blk_rq_sectors(rq)));
/* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */
host_dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type);
@@ -971,8 +971,8 @@ static struct block_device_operations sd_fops = {
static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
{
- u64 start_lba = scmd->request->sector;
- u64 end_lba = scmd->request->sector + (scsi_bufflen(scmd) / 512);
+ u64 start_lba = blk_rq_pos(scmd->request);
+ u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
u64 bad_lba;
int info_valid;
@@ -1510,7 +1510,7 @@ got_data:
*/
sector_size = 512;
}
- blk_queue_hardsect_size(sdp->request_queue, sector_size);
+ blk_queue_logical_block_size(sdp->request_queue, sector_size);
{
char cap_str_2[10], cap_str_10[10];
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 184dff492797..82f14a9482d0 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -507,7 +507,7 @@ void sd_dif_complete(struct scsi_cmnd *scmd, unsigned int good_bytes)
sector_sz = scmd->device->sector_size;
sectors = good_bytes / sector_sz;
- phys = scmd->request->sector & 0xffffffff;
+ phys = blk_rq_pos(scmd->request) & 0xffffffff;
if (sector_sz == 4096)
phys >>= 3;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index e1716f14cd47..8201387b4daa 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -289,8 +289,8 @@ sg_open(struct inode *inode, struct file *filp)
if (list_empty(&sdp->sfds)) { /* no existing opens on this device */
sdp->sgdebug = 0;
q = sdp->device->request_queue;
- sdp->sg_tablesize = min(q->max_hw_segments,
- q->max_phys_segments);
+ sdp->sg_tablesize = min(queue_max_hw_segments(q),
+ queue_max_phys_segments(q));
}
if ((sfp = sg_add_sfp(sdp, dev)))
filp->private_data = sfp;
@@ -909,7 +909,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
if (val < 0)
return -EINVAL;
val = min_t(int, val,
- sdp->device->request_queue->max_sectors * 512);
+ queue_max_sectors(sdp->device->request_queue) * 512);
if (val != sfp->reserve.bufflen) {
if (sg_res_in_use(sfp) || sfp->mmap_called)
return -EBUSY;
@@ -919,7 +919,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
return 0;
case SG_GET_RESERVED_SIZE:
val = min_t(int, sfp->reserve.bufflen,
- sdp->device->request_queue->max_sectors * 512);
+ queue_max_sectors(sdp->device->request_queue) * 512);
return put_user(val, ip);
case SG_SET_COMMAND_Q:
result = get_user(val, ip);
@@ -1059,12 +1059,13 @@ sg_ioctl(struct inode *inode, struct file *filp,
return -ENODEV;
return scsi_ioctl(sdp->device, cmd_in, p);
case BLKSECTGET:
- return put_user(sdp->device->request_queue->max_sectors * 512,
+ return put_user(queue_max_sectors(sdp->device->request_queue) * 512,
ip);
case BLKTRACESETUP:
return blk_trace_setup(sdp->device->request_queue,
sdp->disk->disk_name,
MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
+ NULL,
(char *)arg);
case BLKTRACESTART:
return blk_trace_startstop(sdp->device->request_queue, 1);
@@ -1260,7 +1261,7 @@ static void sg_rq_end_io(struct request *rq, int uptodate)
sense = rq->sense;
result = rq->errors;
- resid = rq->data_len;
+ resid = rq->resid_len;
SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n",
sdp->disk->disk_name, srp->header.pack_id, result));
@@ -1377,7 +1378,8 @@ static Sg_device *sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
sdp->device = scsidp;
INIT_LIST_HEAD(&sdp->sfds);
init_waitqueue_head(&sdp->o_excl_wait);
- sdp->sg_tablesize = min(q->max_hw_segments, q->max_phys_segments);
+ sdp->sg_tablesize = min(queue_max_hw_segments(q),
+ queue_max_phys_segments(q));
sdp->index = k;
kref_init(&sdp->d_ref);
@@ -2055,7 +2057,7 @@ sg_add_sfp(Sg_device * sdp, int dev)
sg_big_buff = def_reserved_size;
bufflen = min_t(int, sg_big_buff,
- sdp->device->request_queue->max_sectors * 512);
+ queue_max_sectors(sdp->device->request_queue) * 512);
sg_build_reserve(sfp, bufflen);
SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n",
sfp->reserve.bufflen, sfp->reserve.k_use_sg));
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 0e1a0f2d2ad5..cd350dfc1216 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -292,7 +292,8 @@ static int sr_done(struct scsi_cmnd *SCpnt)
if (cd->device->sector_size == 2048)
error_sector <<= 2;
error_sector &= ~(block_sectors - 1);
- good_bytes = (error_sector - SCpnt->request->sector) << 9;
+ good_bytes = (error_sector -
+ blk_rq_pos(SCpnt->request)) << 9;
if (good_bytes < 0 || good_bytes >= this_count)
good_bytes = 0;
/*
@@ -349,8 +350,8 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
cd->disk->disk_name, block));
if (!cd->device || !scsi_device_online(cd->device)) {
- SCSI_LOG_HLQUEUE(2, printk("Finishing %ld sectors\n",
- rq->nr_sectors));
+ SCSI_LOG_HLQUEUE(2, printk("Finishing %u sectors\n",
+ blk_rq_sectors(rq)));
SCSI_LOG_HLQUEUE(2, printk("Retry with 0x%p\n", SCpnt));
goto out;
}
@@ -413,7 +414,7 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
/*
* request doesn't start on hw block boundary, add scatter pads
*/
- if (((unsigned int)rq->sector % (s_size >> 9)) ||
+ if (((unsigned int)blk_rq_pos(rq) % (s_size >> 9)) ||
(scsi_bufflen(SCpnt) % s_size)) {
scmd_printk(KERN_NOTICE, SCpnt, "unaligned transfer\n");
goto out;
@@ -422,14 +423,14 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
this_count = (scsi_bufflen(SCpnt) >> 9) / (s_size >> 9);
- SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%ld 512 byte blocks.\n",
+ SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%u 512 byte blocks.\n",
cd->cdi.name,
(rq_data_dir(rq) == WRITE) ?
"writing" : "reading",
- this_count, rq->nr_sectors));
+ this_count, blk_rq_sectors(rq)));
SCpnt->cmnd[1] = 0;
- block = (unsigned int)rq->sector / (s_size >> 9);
+ block = (unsigned int)blk_rq_pos(rq) / (s_size >> 9);
if (this_count > 0xffff) {
this_count = 0xffff;
@@ -726,7 +727,7 @@ static void get_sectorsize(struct scsi_cd *cd)
}
queue = cd->device->request_queue;
- blk_queue_hardsect_size(queue, sector_size);
+ blk_queue_logical_block_size(queue, sector_size);
return;
}
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index eb24efea8f14..b33d04250bbc 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -463,7 +463,7 @@ static void st_scsi_execute_end(struct request *req, int uptodate)
struct scsi_tape *STp = SRpnt->stp;
STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors;
- STp->buffer->cmdstat.residual = req->data_len;
+ STp->buffer->cmdstat.residual = req->resid_len;
if (SRpnt->waiting)
complete(SRpnt->waiting);
@@ -2964,7 +2964,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
!(STp->use_pf & PF_TESTED)) {
/* Try the other possible state of Page Format if not
already tried */
- STp->use_pf = !STp->use_pf | PF_TESTED;
+ STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED;
st_release_request(SRpnt);
SRpnt = NULL;
return st_int_ioctl(STp, cmd_in, arg);
@@ -3983,8 +3983,8 @@ static int st_probe(struct device *dev)
return -ENODEV;
}
- i = min(SDp->request_queue->max_hw_segments,
- SDp->request_queue->max_phys_segments);
+ i = min(queue_max_hw_segments(SDp->request_queue),
+ queue_max_phys_segments(SDp->request_queue));
if (st_max_sg_segs < i)
i = st_max_sg_segs;
buffer = new_tape_buffer((SDp->host)->unchecked_isa_dma, i);
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 583966ec8266..45374d66d26a 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -737,11 +737,14 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
struct sym_hcb *np = sym_get_hcb(sdev->host);
struct sym_tcb *tp = &np->target[sdev->id];
struct sym_lcb *lp;
+ unsigned long flags;
+ int error;
if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN)
return -ENXIO;
- tp->starget = sdev->sdev_target;
+ spin_lock_irqsave(np->s.host->host_lock, flags);
+
/*
* Fail the device init if the device is flagged NOSCAN at BOOT in
* the NVRAM. This may speed up boot and maintain coherency with
@@ -753,26 +756,37 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
if (tp->usrflags & SYM_SCAN_BOOT_DISABLED) {
tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED;
- starget_printk(KERN_INFO, tp->starget,
+ starget_printk(KERN_INFO, sdev->sdev_target,
"Scan at boot disabled in NVRAM\n");
- return -ENXIO;
+ error = -ENXIO;
+ goto out;
}
if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) {
- if (sdev->lun != 0)
- return -ENXIO;
- starget_printk(KERN_INFO, tp->starget,
+ if (sdev->lun != 0) {
+ error = -ENXIO;
+ goto out;
+ }
+ starget_printk(KERN_INFO, sdev->sdev_target,
"Multiple LUNs disabled in NVRAM\n");
}
lp = sym_alloc_lcb(np, sdev->id, sdev->lun);
- if (!lp)
- return -ENOMEM;
+ if (!lp) {
+ error = -ENOMEM;
+ goto out;
+ }
+ if (tp->nlcb == 1)
+ tp->starget = sdev->sdev_target;
spi_min_period(tp->starget) = tp->usr_period;
spi_max_width(tp->starget) = tp->usr_width;
- return 0;
+ error = 0;
+out:
+ spin_unlock_irqrestore(np->s.host->host_lock, flags);
+
+ return error;
}
/*
@@ -819,12 +833,34 @@ static int sym53c8xx_slave_configure(struct scsi_device *sdev)
static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
{
struct sym_hcb *np = sym_get_hcb(sdev->host);
- struct sym_lcb *lp = sym_lp(&np->target[sdev->id], sdev->lun);
+ struct sym_tcb *tp = &np->target[sdev->id];
+ struct sym_lcb *lp = sym_lp(tp, sdev->lun);
+ unsigned long flags;
+
+ spin_lock_irqsave(np->s.host->host_lock, flags);
+
+ if (lp->busy_itlq || lp->busy_itl) {
+ /*
+ * This really shouldn't happen, but we can't return an error
+ * so let's try to stop all on-going I/O.
+ */
+ starget_printk(KERN_WARNING, tp->starget,
+ "Removing busy LCB (%d)\n", sdev->lun);
+ sym_reset_scsi_bus(np, 1);
+ }
- if (lp->itlq_tbl)
- sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK * 4, "ITLQ_TBL");
- kfree(lp->cb_tags);
- sym_mfree_dma(lp, sizeof(*lp), "LCB");
+ if (sym_free_lcb(np, sdev->id, sdev->lun) == 0) {
+ /*
+ * It was the last unit for this target.
+ */
+ tp->head.sval = 0;
+ tp->head.wval = np->rv_scntl3;
+ tp->head.uval = 0;
+ tp->tgoal.check_nego = 1;
+ tp->starget = NULL;
+ }
+
+ spin_unlock_irqrestore(np->s.host->host_lock, flags);
}
/*
@@ -890,6 +926,8 @@ static void sym_exec_user_command (struct sym_hcb *np, struct sym_usrcmd *uc)
if (!((uc->target >> t) & 1))
continue;
tp = &np->target[t];
+ if (!tp->nlcb)
+ continue;
switch (uc->cmd) {
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index ffa70d1ed182..69ad4945c936 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -1896,6 +1896,15 @@ void sym_start_up(struct Scsi_Host *shost, int reason)
tp->head.sval = 0;
tp->head.wval = np->rv_scntl3;
tp->head.uval = 0;
+ if (tp->lun0p)
+ tp->lun0p->to_clear = 0;
+ if (tp->lunmp) {
+ int ln;
+
+ for (ln = 1; ln < SYM_CONF_MAX_LUN; ln++)
+ if (tp->lunmp[ln])
+ tp->lunmp[ln]->to_clear = 0;
+ }
}
/*
@@ -4988,7 +4997,7 @@ struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
*/
if (ln && !tp->lunmp) {
tp->lunmp = kcalloc(SYM_CONF_MAX_LUN, sizeof(struct sym_lcb *),
- GFP_KERNEL);
+ GFP_ATOMIC);
if (!tp->lunmp)
goto fail;
}
@@ -5008,6 +5017,7 @@ struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
tp->lun0p = lp;
tp->head.lun0_sa = cpu_to_scr(vtobus(lp));
}
+ tp->nlcb++;
/*
* Let the itl task point to error handling.
@@ -5085,6 +5095,43 @@ fail:
}
/*
+ * Lun control block deallocation. Returns the number of valid remaing LCBs
+ * for the target.
+ */
+int sym_free_lcb(struct sym_hcb *np, u_char tn, u_char ln)
+{
+ struct sym_tcb *tp = &np->target[tn];
+ struct sym_lcb *lp = sym_lp(tp, ln);
+
+ tp->nlcb--;
+
+ if (ln) {
+ if (!tp->nlcb) {
+ kfree(tp->lunmp);
+ sym_mfree_dma(tp->luntbl, 256, "LUNTBL");
+ tp->lunmp = NULL;
+ tp->luntbl = NULL;
+ tp->head.luntbl_sa = cpu_to_scr(vtobus(np->badluntbl));
+ } else {
+ tp->luntbl[ln] = cpu_to_scr(vtobus(&np->badlun_sa));
+ tp->lunmp[ln] = NULL;
+ }
+ } else {
+ tp->lun0p = NULL;
+ tp->head.lun0_sa = cpu_to_scr(vtobus(&np->badlun_sa));
+ }
+
+ if (lp->itlq_tbl) {
+ sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, "ITLQ_TBL");
+ kfree(lp->cb_tags);
+ }
+
+ sym_mfree_dma(lp, sizeof(*lp), "LCB");
+
+ return tp->nlcb;
+}
+
+/*
* Queue a SCSI IO to the controller.
*/
int sym_queue_scsiio(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp)
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index 9ebc8706b6bf..053e63c86822 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -401,6 +401,7 @@ struct sym_tcb {
* An array of bus addresses is used on reselection.
*/
u32 *luntbl; /* LCBs bus address table */
+ int nlcb; /* Number of valid LCBs (including LUN #0) */
/*
* LUN table used by the C code.
@@ -1065,6 +1066,7 @@ int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int
struct sym_ccb *sym_get_ccb(struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order);
void sym_free_ccb(struct sym_hcb *np, struct sym_ccb *cp);
struct sym_lcb *sym_alloc_lcb(struct sym_hcb *np, u_char tn, u_char ln);
+int sym_free_lcb(struct sym_hcb *np, u_char tn, u_char ln);
int sym_queue_scsiio(struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp);
int sym_abort_scsiio(struct sym_hcb *np, struct scsi_cmnd *ccb, int timed_out);
int sym_reset_scsi_target(struct sym_hcb *np, int target);
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index 601e95141cbe..54023d41fd15 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -1306,7 +1306,7 @@ static int u14_34f_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scs
if (linked_comm && SCpnt->device->queue_depth > 2
&& TLDEV(SCpnt->device->type)) {
HD(j)->cp_stat[i] = READY;
- flush_dev(SCpnt->device, SCpnt->request->sector, j, FALSE);
+ flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), j, FALSE);
return 0;
}
@@ -1610,11 +1610,13 @@ static int reorder(unsigned int j, unsigned long cursec,
if (!(cpp->xdir == DTD_IN)) input_only = FALSE;
- if (SCpnt->request->sector < minsec) minsec = SCpnt->request->sector;
- if (SCpnt->request->sector > maxsec) maxsec = SCpnt->request->sector;
+ if (blk_rq_pos(SCpnt->request) < minsec)
+ minsec = blk_rq_pos(SCpnt->request);
+ if (blk_rq_pos(SCpnt->request) > maxsec)
+ maxsec = blk_rq_pos(SCpnt->request);
- sl[n] = SCpnt->request->sector;
- ioseek += SCpnt->request->nr_sectors;
+ sl[n] = blk_rq_pos(SCpnt->request);
+ ioseek += blk_rq_sectors(SCpnt->request);
if (!n) continue;
@@ -1642,7 +1644,7 @@ static int reorder(unsigned int j, unsigned long cursec,
if (!input_only) for (n = 0; n < n_ready; n++) {
k = il[n]; cpp = &HD(j)->cp[k]; SCpnt = cpp->SCpnt;
- ll[n] = SCpnt->request->nr_sectors; pl[n] = SCpnt->serial_number;
+ ll[n] = blk_rq_sectors(SCpnt->request); pl[n] = SCpnt->serial_number;
if (!n) continue;
@@ -1666,12 +1668,12 @@ static int reorder(unsigned int j, unsigned long cursec,
if (link_statistics && (overlap || !(flushcount % link_statistics)))
for (n = 0; n < n_ready; n++) {
k = il[n]; cpp = &HD(j)->cp[k]; SCpnt = cpp->SCpnt;
- printk("%s %d.%d:%d pid %ld mb %d fc %d nr %d sec %ld ns %ld"\
+ printk("%s %d.%d:%d pid %ld mb %d fc %d nr %d sec %ld ns %u"\
" cur %ld s:%c r:%c rev:%c in:%c ov:%c xd %d.\n",
(ihdlr ? "ihdlr" : "qcomm"), SCpnt->channel, SCpnt->target,
SCpnt->lun, SCpnt->serial_number, k, flushcount, n_ready,
- SCpnt->request->sector, SCpnt->request->nr_sectors, cursec,
- YESNO(s), YESNO(r), YESNO(rev), YESNO(input_only),
+ blk_rq_pos(SCpnt->request), blk_rq_sectors(SCpnt->request),
+ cursec, YESNO(s), YESNO(r), YESNO(rev), YESNO(input_only),
YESNO(overlap), cpp->xdir);
}
#endif
@@ -1799,7 +1801,7 @@ static irqreturn_t ihdlr(unsigned int j)
if (linked_comm && SCpnt->device->queue_depth > 2
&& TLDEV(SCpnt->device->type))
- flush_dev(SCpnt->device, SCpnt->request->sector, j, TRUE);
+ flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), j, TRUE);
tstatus = status_byte(spp->target_status);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 938bc1b6c3fa..e371a9c15341 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -2776,6 +2776,9 @@ static struct pci_device_id serial_pci_tbl[] = {
{ PCI_VENDOR_ID_OXSEMI, 0x950a,
PCI_ANY_ID, PCI_ANY_ID, 0, 0,
pbn_b0_2_1130000 },
+ { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_C950,
+ PCI_VENDOR_ID_OXSEMI, PCI_SUBDEVICE_ID_OXSEMI_C950, 0, 0,
+ pbn_b0_1_921600 },
{ PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954,
PCI_ANY_ID, PCI_ANY_ID, 0, 0,
pbn_b0_4_115200 },
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c
index 6579e2be1dd1..a461b3b2c72d 100644
--- a/drivers/serial/icom.c
+++ b/drivers/serial/icom.c
@@ -1472,8 +1472,8 @@ static void icom_remove_adapter(struct icom_adapter *icom_adapter)
free_irq(icom_adapter->pci_dev->irq, (void *) icom_adapter);
iounmap(icom_adapter->base_addr);
- icom_free_adapter(icom_adapter);
pci_release_regions(icom_adapter->pci_dev);
+ icom_free_adapter(icom_adapter);
}
static void icom_kref_release(struct kref *kref)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 9f460b175c50..3f5d5a200481 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -66,7 +66,7 @@
#define ONEMS 0xb0 /* One Millisecond register */
#define UTS 0xb4 /* UART Test Register */
#endif
-#if defined(CONFIG_ARCH_IMX) || defined(CONFIG_ARCH_MX1)
+#ifdef CONFIG_ARCH_MX1
#define BIPR1 0xb0 /* Incremental Preset Register 1 */
#define BIPR2 0xb4 /* Incremental Preset Register 2 */
#define BIPR3 0xb8 /* Incremental Preset Register 3 */
@@ -96,7 +96,7 @@
#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */
#define UCR1_SNDBRK (1<<4) /* Send break */
#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */
-#if defined(CONFIG_ARCH_IMX) || defined(CONFIG_ARCH_MX1)
+#ifdef CONFIG_ARCH_MX1
#define UCR1_UARTCLKEN (1<<2) /* UART clock enabled */
#endif
#if defined CONFIG_ARCH_MX3 || defined CONFIG_ARCH_MX2
@@ -127,7 +127,7 @@
#define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */
#define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */
#define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */
-#ifdef CONFIG_ARCH_IMX
+#ifdef CONFIG_ARCH_MX1
#define UCR3_REF25 (1<<3) /* Ref freq 25 MHz, only on mx1 */
#define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz, only on mx1 */
#endif
@@ -180,13 +180,6 @@
#define UTS_SOFTRST (1<<0) /* Software reset */
/* We've been assigned a range on the "Low-density serial ports" major */
-#ifdef CONFIG_ARCH_IMX
-#define SERIAL_IMX_MAJOR 204
-#define MINOR_START 41
-#define DEV_NAME "ttySMX"
-#define MAX_INTERNAL_IRQ IMX_IRQS
-#endif
-
#ifdef CONFIG_ARCH_MXC
#define SERIAL_IMX_MAJOR 207
#define MINOR_START 16
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index 14f8fa9135be..54483cd3529e 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -122,7 +122,7 @@ static int __devinit of_platform_serial_probe(struct of_device *ofdev,
info->type = port_type;
info->line = ret;
- ofdev->dev.driver_data = info;
+ dev_set_drvdata(&ofdev->dev, info);
return 0;
out:
kfree(info);
@@ -135,7 +135,7 @@ out:
*/
static int of_platform_serial_remove(struct of_device *ofdev)
{
- struct of_serial_info *info = ofdev->dev.driver_data;
+ struct of_serial_info *info = dev_get_drvdata(&ofdev->dev);
switch (info->type) {
#ifdef CONFIG_SERIAL_8250
case PORT_8250 ... PORT_MAX_8250:
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 7546aa887fa7..79c9c5f5cdba 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -681,7 +681,7 @@ static int serial_config(struct pcmcia_device * link)
u_char *buf;
cisparse_t *parse;
cistpl_cftable_entry_t *cf;
- int i;
+ int i, last_ret, last_fn;
DEBUG(0, "serial_config(0x%p)\n", link);
@@ -699,6 +699,16 @@ static int serial_config(struct pcmcia_device * link)
tuple->TupleDataMax = 255;
tuple->Attributes = 0;
+ /* Get configuration register information */
+ tuple->DesiredTuple = CISTPL_CONFIG;
+ last_ret = first_tuple(link, tuple, parse);
+ if (last_ret != 0) {
+ last_fn = ParseTuple;
+ goto cs_failed;
+ }
+ link->conf.ConfigBase = parse->config.base;
+ link->conf.Present = parse->config.rmask[0];
+
/* Is this a compliant multifunction card? */
tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
@@ -761,7 +771,9 @@ static int serial_config(struct pcmcia_device * link)
kfree(cfg_mem);
return 0;
- failed:
+cs_failed:
+ cs_error(link, last_fn, last_ret);
+failed:
serial_remove(link);
kfree(cfg_mem);
return -ENODEV;
@@ -863,10 +875,10 @@ static struct pcmcia_device_id serial_ids[] = {
PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"),
PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"),
PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"),
- PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "3CCFEM556.cis"),
+ PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"),
PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0175, 0x0000, "DP83903.cis"),
- PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"),
- PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"),
+ PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "cis/3CXEM556.cis"),
+ PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "cis/3CXEM556.cis"),
PCMCIA_DEVICE_CIS_PROD_ID12("Sierra Wireless", "AC850", 0xd85f6206, 0x42a2c018, "SW_8xx_SER.cis"), /* Sierra Wireless AC850 3G Network Adapter R1 */
PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */
PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index dbf5357a77b3..fa4d52a6c032 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -47,12 +47,17 @@
#include <linux/clk.h>
#include <linux/ctype.h>
#include <linux/err.h>
+#include <linux/list.h>
#ifdef CONFIG_SUPERH
#include <asm/clock.h>
#include <asm/sh_bios.h>
#endif
+#ifdef CONFIG_H8300
+#include <asm/gpio.h>
+#endif
+
#include "sh-sci.h"
struct sci_port {
@@ -75,14 +80,22 @@ struct sci_port {
int break_flag;
#ifdef CONFIG_HAVE_CLK
- /* Port clock */
- struct clk *clk;
+ /* Interface clock */
+ struct clk *iclk;
+ /* Data clock */
+ struct clk *dclk;
#endif
+ struct list_head node;
};
-#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
-static struct sci_port *serial_console_port;
+struct sh_sci_priv {
+ spinlock_t lock;
+ struct list_head ports;
+
+#ifdef CONFIG_HAVE_CLK
+ struct notifier_block clk_nb;
#endif
+};
/* Function prototypes */
static void sci_stop_tx(struct uart_port *port);
@@ -159,12 +172,12 @@ static void h8300_sci_config(struct uart_port *port, unsigned int ctrl)
*mstpcrl &= ~mask;
}
-static inline void h8300_sci_enable(struct uart_port *port)
+static void h8300_sci_enable(struct uart_port *port)
{
h8300_sci_config(port, sci_enable);
}
-static inline void h8300_sci_disable(struct uart_port *port)
+static void h8300_sci_disable(struct uart_port *port)
{
h8300_sci_config(port, sci_disable);
}
@@ -611,7 +624,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
int copied = 0;
unsigned short status = sci_in(port, SCxSR);
struct tty_struct *tty = port->info->port.tty;
- struct sci_port *s = &sci_ports[port->line];
+ struct sci_port *s = to_sci_port(port);
if (uart_handle_break(port))
return 0;
@@ -726,19 +739,43 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
static int sci_notifier(struct notifier_block *self,
unsigned long phase, void *p)
{
- int i;
+ struct sh_sci_priv *priv = container_of(self,
+ struct sh_sci_priv, clk_nb);
+ struct sci_port *sci_port;
+ unsigned long flags;
if ((phase == CPUFREQ_POSTCHANGE) ||
- (phase == CPUFREQ_RESUMECHANGE))
- for (i = 0; i < SCI_NPORTS; i++) {
- struct sci_port *s = &sci_ports[i];
- s->port.uartclk = clk_get_rate(s->clk);
- }
+ (phase == CPUFREQ_RESUMECHANGE)) {
+ spin_lock_irqsave(&priv->lock, flags);
+ list_for_each_entry(sci_port, &priv->ports, node)
+ sci_port->port.uartclk = clk_get_rate(sci_port->dclk);
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+ }
return NOTIFY_OK;
}
-static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
+static void sci_clk_enable(struct uart_port *port)
+{
+ struct sci_port *sci_port = to_sci_port(port);
+
+ clk_enable(sci_port->dclk);
+ sci_port->port.uartclk = clk_get_rate(sci_port->dclk);
+
+ if (sci_port->iclk)
+ clk_enable(sci_port->iclk);
+}
+
+static void sci_clk_disable(struct uart_port *port)
+{
+ struct sci_port *sci_port = to_sci_port(port);
+
+ if (sci_port->iclk)
+ clk_disable(sci_port->iclk);
+
+ clk_disable(sci_port->dclk);
+}
#endif
static int sci_request_irq(struct sci_port *port)
@@ -865,15 +902,11 @@ static void sci_break_ctl(struct uart_port *port, int break_state)
static int sci_startup(struct uart_port *port)
{
- struct sci_port *s = &sci_ports[port->line];
+ struct sci_port *s = to_sci_port(port);
if (s->enable)
s->enable(port);
-#ifdef CONFIG_HAVE_CLK
- s->clk = clk_get(NULL, "module_clk");
-#endif
-
sci_request_irq(s);
sci_start_tx(port);
sci_start_rx(port, 1);
@@ -883,7 +916,7 @@ static int sci_startup(struct uart_port *port)
static void sci_shutdown(struct uart_port *port)
{
- struct sci_port *s = &sci_ports[port->line];
+ struct sci_port *s = to_sci_port(port);
sci_stop_rx(port);
sci_stop_tx(port);
@@ -891,11 +924,6 @@ static void sci_shutdown(struct uart_port *port)
if (s->disable)
s->disable(port);
-
-#ifdef CONFIG_HAVE_CLK
- clk_put(s->clk);
- s->clk = NULL;
-#endif
}
static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
@@ -980,25 +1008,31 @@ static int sci_request_port(struct uart_port *port)
static void sci_config_port(struct uart_port *port, int flags)
{
- struct sci_port *s = &sci_ports[port->line];
+ struct sci_port *s = to_sci_port(port);
port->type = s->type;
- if (port->flags & UPF_IOREMAP && !port->membase) {
-#if defined(CONFIG_SUPERH64)
- port->mapbase = onchip_remap(SCIF_ADDR_SH5, 1024, "SCIF");
- port->membase = (void __iomem *)port->mapbase;
-#else
+ if (port->membase)
+ return;
+
+ if (port->flags & UPF_IOREMAP) {
port->membase = ioremap_nocache(port->mapbase, 0x40);
-#endif
- dev_err(port->dev, "can't remap port#%d\n", port->line);
+ if (IS_ERR(port->membase))
+ dev_err(port->dev, "can't remap port#%d\n", port->line);
+ } else {
+ /*
+ * For the simple (and majority of) cases where we don't
+ * need to do any remapping, just cast the cookie
+ * directly.
+ */
+ port->membase = (void __iomem *)port->mapbase;
}
}
static int sci_verify_port(struct uart_port *port, struct serial_struct *ser)
{
- struct sci_port *s = &sci_ports[port->line];
+ struct sci_port *s = to_sci_port(port);
if (ser->irq != s->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs)
return -EINVAL;
@@ -1032,63 +1066,60 @@ static struct uart_ops sci_uart_ops = {
#endif
};
-static void __init sci_init_ports(void)
+static void __devinit sci_init_single(struct platform_device *dev,
+ struct sci_port *sci_port,
+ unsigned int index,
+ struct plat_sci_port *p)
{
- static int first = 1;
- int i;
-
- if (!first)
- return;
-
- first = 0;
-
- for (i = 0; i < SCI_NPORTS; i++) {
- sci_ports[i].port.ops = &sci_uart_ops;
- sci_ports[i].port.iotype = UPIO_MEM;
- sci_ports[i].port.line = i;
- sci_ports[i].port.fifosize = 1;
+ sci_port->port.ops = &sci_uart_ops;
+ sci_port->port.iotype = UPIO_MEM;
+ sci_port->port.line = index;
+ sci_port->port.fifosize = 1;
#if defined(__H8300H__) || defined(__H8300S__)
#ifdef __H8300S__
- sci_ports[i].enable = h8300_sci_enable;
- sci_ports[i].disable = h8300_sci_disable;
+ sci_port->enable = h8300_sci_enable;
+ sci_port->disable = h8300_sci_disable;
#endif
- sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK;
+ sci_port->port.uartclk = CONFIG_CPU_CLOCK;
#elif defined(CONFIG_HAVE_CLK)
- /*
- * XXX: We should use a proper SCI/SCIF clock
- */
- {
- struct clk *clk = clk_get(NULL, "module_clk");
- sci_ports[i].port.uartclk = clk_get_rate(clk);
- clk_put(clk);
- }
+ sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL;
+ sci_port->dclk = clk_get(&dev->dev, "peripheral_clk");
+ sci_port->enable = sci_clk_enable;
+ sci_port->disable = sci_clk_disable;
#else
#error "Need a valid uartclk"
#endif
- sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i];
- sci_ports[i].break_timer.function = sci_break_timer;
-
- init_timer(&sci_ports[i].break_timer);
- }
-}
+ sci_port->break_timer.data = (unsigned long)sci_port;
+ sci_port->break_timer.function = sci_break_timer;
+ init_timer(&sci_port->break_timer);
-int __init early_sci_setup(struct uart_port *port)
-{
- if (unlikely(port->line > SCI_NPORTS))
- return -ENODEV;
+ sci_port->port.mapbase = p->mapbase;
+ sci_port->port.membase = p->membase;
- sci_init_ports();
+ sci_port->port.irq = p->irqs[SCIx_TXI_IRQ];
+ sci_port->port.flags = p->flags;
+ sci_port->port.dev = &dev->dev;
+ sci_port->type = sci_port->port.type = p->type;
- sci_ports[port->line].port.membase = port->membase;
- sci_ports[port->line].port.mapbase = port->mapbase;
- sci_ports[port->line].port.type = port->type;
+ memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs));
- return 0;
}
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
+static struct tty_driver *serial_console_device(struct console *co, int *index)
+{
+ struct uart_driver *p = &sci_uart_driver;
+ *index = co->index;
+ return p->tty_driver;
+}
+
+static void serial_console_putchar(struct uart_port *port, int ch)
+{
+ sci_poll_put_char(port, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -1096,25 +1127,27 @@ int __init early_sci_setup(struct uart_port *port)
static void serial_console_write(struct console *co, const char *s,
unsigned count)
{
- struct uart_port *port = &serial_console_port->port;
+ struct uart_port *port = co->data;
+ struct sci_port *sci_port = to_sci_port(port);
unsigned short bits;
- int i;
- for (i = 0; i < count; i++) {
- if (*s == 10)
- sci_poll_put_char(port, '\r');
+ if (sci_port->enable)
+ sci_port->enable(port);
- sci_poll_put_char(port, *s++);
- }
+ uart_console_write(port, s, count, serial_console_putchar);
/* wait until fifo is empty and last bit has been transmitted */
bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
while ((sci_in(port, SCxSR) & bits) != bits)
cpu_relax();
+
+ if (sci_port->disable);
+ sci_port->disable(port);
}
static int __init serial_console_setup(struct console *co, char *options)
{
+ struct sci_port *sci_port;
struct uart_port *port;
int baud = 115200;
int bits = 8;
@@ -1130,8 +1163,9 @@ static int __init serial_console_setup(struct console *co, char *options)
if (co->index >= SCI_NPORTS)
co->index = 0;
- serial_console_port = &sci_ports[co->index];
- port = &serial_console_port->port;
+ sci_port = &sci_ports[co->index];
+ port = &sci_port->port;
+ co->data = port;
/*
* Also need to check port->type, we don't actually have any
@@ -1141,21 +1175,11 @@ static int __init serial_console_setup(struct console *co, char *options)
*/
if (!port->type)
return -ENODEV;
- if (!port->membase || !port->mapbase)
- return -ENODEV;
-
- port->type = serial_console_port->type;
-
-#ifdef CONFIG_HAVE_CLK
- if (!serial_console_port->clk)
- serial_console_port->clk = clk_get(NULL, "module_clk");
-#endif
- if (port->flags & UPF_IOREMAP)
- sci_config_port(port, 0);
+ sci_config_port(port, 0);
- if (serial_console_port->enable)
- serial_console_port->enable(port);
+ if (sci_port->enable)
+ sci_port->enable(port);
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
@@ -1166,22 +1190,21 @@ static int __init serial_console_setup(struct console *co, char *options)
if (ret == 0)
sci_stop_rx(port);
#endif
+ /* TODO: disable clock */
return ret;
}
static struct console serial_console = {
.name = "ttySC",
- .device = uart_console_device,
+ .device = serial_console_device,
.write = serial_console_write,
.setup = serial_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
- .data = &sci_uart_driver,
};
static int __init sci_console_init(void)
{
- sci_init_ports();
register_console(&serial_console);
return 0;
}
@@ -1207,6 +1230,61 @@ static struct uart_driver sci_uart_driver = {
.cons = SCI_CONSOLE,
};
+
+static int sci_remove(struct platform_device *dev)
+{
+ struct sh_sci_priv *priv = platform_get_drvdata(dev);
+ struct sci_port *p;
+ unsigned long flags;
+
+#ifdef CONFIG_HAVE_CLK
+ cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER);
+#endif
+
+ spin_lock_irqsave(&priv->lock, flags);
+ list_for_each_entry(p, &priv->ports, node)
+ uart_remove_one_port(&sci_uart_driver, &p->port);
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ kfree(priv);
+ return 0;
+}
+
+static int __devinit sci_probe_single(struct platform_device *dev,
+ unsigned int index,
+ struct plat_sci_port *p,
+ struct sci_port *sciport)
+{
+ struct sh_sci_priv *priv = platform_get_drvdata(dev);
+ unsigned long flags;
+ int ret;
+
+ /* Sanity check */
+ if (unlikely(index >= SCI_NPORTS)) {
+ dev_notice(&dev->dev, "Attempting to register port "
+ "%d when only %d are available.\n",
+ index+1, SCI_NPORTS);
+ dev_notice(&dev->dev, "Consider bumping "
+ "CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
+ return 0;
+ }
+
+ sci_init_single(dev, sciport, index, p);
+
+ ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
+ if (ret)
+ return ret;
+
+ INIT_LIST_HEAD(&sciport->node);
+
+ spin_lock_irqsave(&priv->lock, flags);
+ list_add(&sciport->node, &priv->ports);
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ return 0;
+}
+
/*
* Register a set of serial devices attached to a platform device. The
* list is terminated with a zero flags entry, which means we expect
@@ -1216,57 +1294,34 @@ static struct uart_driver sci_uart_driver = {
static int __devinit sci_probe(struct platform_device *dev)
{
struct plat_sci_port *p = dev->dev.platform_data;
+ struct sh_sci_priv *priv;
int i, ret = -EINVAL;
- for (i = 0; p && p->flags != 0; p++, i++) {
- struct sci_port *sciport = &sci_ports[i];
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
- /* Sanity check */
- if (unlikely(i == SCI_NPORTS)) {
- dev_notice(&dev->dev, "Attempting to register port "
- "%d when only %d are available.\n",
- i+1, SCI_NPORTS);
- dev_notice(&dev->dev, "Consider bumping "
- "CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
- break;
- }
+ INIT_LIST_HEAD(&priv->ports);
+ spin_lock_init(&priv->lock);
+ platform_set_drvdata(dev, priv);
- sciport->port.mapbase = p->mapbase;
+#ifdef CONFIG_HAVE_CLK
+ priv->clk_nb.notifier_call = sci_notifier;
+ cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER);
+#endif
- if (p->mapbase && !p->membase) {
- if (p->flags & UPF_IOREMAP) {
- p->membase = ioremap_nocache(p->mapbase, 0x40);
- if (IS_ERR(p->membase)) {
- ret = PTR_ERR(p->membase);
- goto err_unreg;
- }
- } else {
- /*
- * For the simple (and majority of) cases
- * where we don't need to do any remapping,
- * just cast the cookie directly.
- */
- p->membase = (void __iomem *)p->mapbase;
- }
+ if (dev->id != -1) {
+ ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]);
+ if (ret)
+ goto err_unreg;
+ } else {
+ for (i = 0; p && p->flags != 0; p++, i++) {
+ ret = sci_probe_single(dev, i, p, &sci_ports[i]);
+ if (ret)
+ goto err_unreg;
}
-
- sciport->port.membase = p->membase;
-
- sciport->port.irq = p->irqs[SCIx_TXI_IRQ];
- sciport->port.flags = p->flags;
- sciport->port.dev = &dev->dev;
-
- sciport->type = sciport->port.type = p->type;
-
- memcpy(&sciport->irqs, &p->irqs, sizeof(p->irqs));
-
- uart_add_one_port(&sci_uart_driver, &sciport->port);
}
-#ifdef CONFIG_HAVE_CLK
- cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
-#endif
-
#ifdef CONFIG_SH_STANDARD_BIOS
sh_bios_gdb_detach();
#endif
@@ -1274,50 +1329,36 @@ static int __devinit sci_probe(struct platform_device *dev)
return 0;
err_unreg:
- for (i = i - 1; i >= 0; i--)
- uart_remove_one_port(&sci_uart_driver, &sci_ports[i].port);
-
+ sci_remove(dev);
return ret;
}
-static int __devexit sci_remove(struct platform_device *dev)
-{
- int i;
-
-#ifdef CONFIG_HAVE_CLK
- cpufreq_unregister_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
-#endif
-
- for (i = 0; i < SCI_NPORTS; i++)
- uart_remove_one_port(&sci_uart_driver, &sci_ports[i].port);
-
- return 0;
-}
-
static int sci_suspend(struct platform_device *dev, pm_message_t state)
{
- int i;
+ struct sh_sci_priv *priv = platform_get_drvdata(dev);
+ struct sci_port *p;
+ unsigned long flags;
- for (i = 0; i < SCI_NPORTS; i++) {
- struct sci_port *p = &sci_ports[i];
+ spin_lock_irqsave(&priv->lock, flags);
+ list_for_each_entry(p, &priv->ports, node)
+ uart_suspend_port(&sci_uart_driver, &p->port);
- if (p->type != PORT_UNKNOWN && p->port.dev == &dev->dev)
- uart_suspend_port(&sci_uart_driver, &p->port);
- }
+ spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
static int sci_resume(struct platform_device *dev)
{
- int i;
+ struct sh_sci_priv *priv = platform_get_drvdata(dev);
+ struct sci_port *p;
+ unsigned long flags;
- for (i = 0; i < SCI_NPORTS; i++) {
- struct sci_port *p = &sci_ports[i];
+ spin_lock_irqsave(&priv->lock, flags);
+ list_for_each_entry(p, &priv->ports, node)
+ uart_resume_port(&sci_uart_driver, &p->port);
- if (p->type != PORT_UNKNOWN && p->port.dev == &dev->dev)
- uart_resume_port(&sci_uart_driver, &p->port);
- }
+ spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
@@ -1339,8 +1380,6 @@ static int __init sci_init(void)
printk(banner);
- sci_init_ports();
-
ret = uart_register_driver(&sci_uart_driver);
if (likely(ret == 0)) {
ret = platform_driver_register(&sci_driver);
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index d0aa82d7fce0..38072c15b845 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -91,6 +91,9 @@
# define SCSPTR5 0xa4050128
# define SCIF_ORER 0x0001 /* overrun error bit */
# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
+#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
+# define SCIF_ORER 0x0001 /* overrun error bit */
+# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -314,7 +317,18 @@
} \
}
-#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
+#ifdef CONFIG_H8300
+/* h8300 don't have SCIF */
+#define CPU_SCIF_FNS(name) \
+ static inline unsigned int sci_##name##_in(struct uart_port *port) \
+ { \
+ return 0; \
+ } \
+ static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
+ { \
+ }
+#else
+#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
static inline unsigned int sci_##name##_in(struct uart_port *port) \
{ \
SCI_IN(scif_size, scif_offset); \
@@ -323,6 +337,7 @@
{ \
SCI_OUT(scif_size, scif_offset, value); \
}
+#endif
#define CPU_SCI_FNS(name, sci_offset, sci_size) \
static inline unsigned int sci_##name##_in(struct uart_port* port) \
@@ -360,8 +375,10 @@
sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
h8_sci_offset, h8_sci_size) \
CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
-#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
+#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
+ CPU_SCIF_FNS(name)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
+ defined(CONFIG_CPU_SUBTYPE_SH7724)
#define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \
CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size)
#define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
@@ -390,7 +407,8 @@ SCIF_FNS(SCFDR, 0x1c, 16)
SCIF_FNS(SCxTDR, 0x20, 8)
SCIF_FNS(SCxRDR, 0x24, 8)
SCIF_FNS(SCLSR, 0x24, 16)
-#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
+ defined(CONFIG_CPU_SUBTYPE_SH7724)
SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
@@ -604,10 +622,21 @@ static inline int sci_rxd_in(struct uart_port *port)
return ctrl_inb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */
return 1;
}
+#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
+# define SCFSR 0x0010
+# define SCASSR 0x0014
+static inline int sci_rxd_in(struct uart_port *port)
+{
+ if (port->type == PORT_SCIF)
+ return ctrl_inw((port->mapbase + SCFSR)) & SCIF_BRK ? 1 : 0;
+ if (port->type == PORT_SCIFA)
+ return ctrl_inw((port->mapbase + SCASSR)) & SCIF_BRK ? 1 : 0;
+ return 1;
+}
#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
static inline int sci_rxd_in(struct uart_port *port)
{
- return sci_in(port, SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
+ return sci_in(port, SCSPTR)&0x0001 ? 1 : 0; /* SCIF */
}
#elif defined(__H8300H__) || defined(__H8300S__)
static inline int sci_rxd_in(struct uart_port *port)
@@ -757,7 +786,8 @@ static inline int sci_rxd_in(struct uart_port *port)
defined(CONFIG_CPU_SUBTYPE_SH7720) || \
defined(CONFIG_CPU_SUBTYPE_SH7721)
#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
-#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
+ defined(CONFIG_CPU_SUBTYPE_SH7724)
static inline int scbrr_calc(struct uart_port *port, int bps, int clk)
{
if (port->type == PORT_SCIF)
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c
index 12d13d99b6f0..caf065694042 100644
--- a/drivers/sh/intc.c
+++ b/drivers/sh/intc.c
@@ -671,7 +671,7 @@ unsigned int intc_evt2irq(unsigned int vector)
void __init register_intc_controller(struct intc_desc *desc)
{
- unsigned int i, k, smp;
+ unsigned int i, k, smp, cpu = smp_processor_id();
struct intc_desc_int *d;
d = alloc_bootmem(sizeof(*d));
@@ -770,11 +770,22 @@ void __init register_intc_controller(struct intc_desc *desc)
/* register the vectors one by one */
for (i = 0; i < desc->nr_vectors; i++) {
struct intc_vect *vect = desc->vectors + i;
-
+ unsigned int irq = evt2irq(vect->vect);
+#ifdef CONFIG_SPARSE_IRQ
+ struct irq_desc *irq_desc;
+#endif
if (!vect->enum_id)
continue;
- intc_register_irq(desc, d, vect->enum_id, evt2irq(vect->vect));
+#ifdef CONFIG_SPARSE_IRQ
+ irq_desc = irq_to_desc_alloc_cpu(irq, cpu);
+ if (unlikely(!irq_desc)) {
+ printk(KERN_INFO "can not get irq_desc for %d\n", irq);
+ continue;
+ }
+#endif
+
+ intc_register_irq(desc, d, vect->enum_id, irq);
}
}
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 957494775413..a1dfc541e4d9 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -118,7 +118,7 @@ config SPI_GPIO
config SPI_IMX
tristate "Freescale iMX SPI controller"
- depends on ARCH_IMX && EXPERIMENTAL
+ depends on ARCH_MX1 && EXPERIMENTAL
help
This enables using the Freescale iMX SPI controller in master
mode.
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
index f2447a5476bb..bbf9371cd284 100644
--- a/drivers/spi/spi_s3c24xx_gpio.c
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -17,6 +17,7 @@
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h>
+#include <linux/gpio.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 0dcf9ca0b0ac..a53dc3249a29 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -85,6 +85,8 @@ source "drivers/staging/altpciechdma/Kconfig"
source "drivers/staging/rtl8187se/Kconfig"
+source "drivers/staging/rtl8192su/Kconfig"
+
source "drivers/staging/rspiusb/Kconfig"
source "drivers/staging/mimio/Kconfig"
@@ -115,5 +117,7 @@ source "drivers/staging/line6/Kconfig"
source "drivers/staging/serqt_usb/Kconfig"
+source "drivers/staging/cpc-usb/Kconfig"
+
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 47dfd5b4288b..2978319532eb 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_ASUS_OLED) += asus_oled/
obj-$(CONFIG_PANEL) += panel/
obj-$(CONFIG_ALTERA_PCIE_CHDMA) += altpciechdma/
obj-$(CONFIG_RTL8187SE) += rtl8187se/
+obj-$(CONFIG_RTL8192SU) += rtl8192su/
obj-$(CONFIG_USB_RSPI) += rspiusb/
obj-$(CONFIG_INPUT_MIMIO) += mimio/
obj-$(CONFIG_TRANZPORT) += frontier/
@@ -40,3 +41,4 @@ obj-$(CONFIG_PLAN9AUTH) += p9auth/
obj-$(CONFIG_HECI) += heci/
obj-$(CONFIG_LINE6_USB) += line6/
obj-$(CONFIG_USB_SERIAL_QUATECH_ESU100) += serqt_usb/
+obj-$(CONFIG_USB_CPC) += cpc-usb/
diff --git a/drivers/staging/agnx/debug.h b/drivers/staging/agnx/debug.h
index 761d99c2d3f0..7947f327a214 100644
--- a/drivers/staging/agnx/debug.h
+++ b/drivers/staging/agnx/debug.h
@@ -312,7 +312,6 @@ static inline void dump_ieee80211_hdr(struct ieee80211_hdr *hdr, char *tag)
{
u16 fctl;
int hdrlen;
- DECLARE_MAC_BUF(mac);
fctl = le16_to_cpu(hdr->frame_control);
switch (fctl & IEEE80211_FCTL_FTYPE) {
@@ -375,13 +374,13 @@ static inline void dump_ieee80211_hdr(struct ieee80211_hdr *hdr, char *tag)
printk("FC=0x%04x DUR=0x%04x",
fctl, le16_to_cpu(hdr->duration_id));
if (hdrlen >= 10)
- printk(" A1=%s", print_mac(mac, hdr->addr1));
+ printk(" A1=%pM", hdr->addr1);
if (hdrlen >= 16)
- printk(" A2=%s", print_mac(mac, hdr->addr2));
+ printk(" A2=%pM", hdr->addr2);
if (hdrlen >= 24)
- printk(" A3=%s", print_mac(mac, hdr->addr3));
+ printk(" A3=%pM", hdr->addr3);
if (hdrlen >= 30)
- printk(" A4=%s", print_mac(mac, hdr->addr4));
+ printk(" A4=%pM", hdr->addr4);
printk("\n");
}
diff --git a/drivers/staging/agnx/pci.c b/drivers/staging/agnx/pci.c
index 25c0ffd2faa0..0df7d43c4c32 100644
--- a/drivers/staging/agnx/pci.c
+++ b/drivers/staging/agnx/pci.c
@@ -150,8 +150,7 @@ static int agnx_get_mac_address(struct agnx_priv *priv)
*((u32 *)(priv->mac_addr + 2)) = cpu_to_le32(reg);
if (!is_valid_ether_addr(priv->mac_addr)) {
- DECLARE_MAC_BUF(mbuf);
- printk(KERN_WARNING PFX "read mac %s\n", print_mac(mbuf, priv->mac_addr));
+ printk(KERN_WARNING PFX "read mac %pM\n", priv->mac_addr);
printk(KERN_WARNING PFX "Invalid hwaddr! Using random hwaddr\n");
random_ether_addr(priv->mac_addr);
}
@@ -303,14 +302,18 @@ static int agnx_config(struct ieee80211_hw *dev, u32 changed)
return 0;
}
-static int agnx_config_interface(struct ieee80211_hw *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
+static void agnx_bss_info_changed(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *conf,
+ u32 changed)
{
struct agnx_priv *priv = dev->priv;
void __iomem *ctl = priv->ctl;
AGNX_TRACE;
+ if (!(changed & BSS_CHANGED_BSSID))
+ return;
+
spin_lock(&priv->lock);
if (memcmp(conf->bssid, priv->bssid, ETH_ALEN)) {
@@ -323,8 +326,7 @@ static int agnx_config_interface(struct ieee80211_hw *dev,
agnx_write32(ctl, AGNX_BM_MTSM, 0xff & ~0x1);
}
spin_unlock(&priv->lock);
- return 0;
-} /* agnx_config_interface */
+} /* agnx_bss_info_changed */
static void agnx_configure_filter(struct ieee80211_hw *dev,
@@ -422,7 +424,7 @@ static struct ieee80211_ops agnx_ops = {
.add_interface = agnx_add_interface,
.remove_interface = agnx_remove_interface,
.config = agnx_config,
- .config_interface = agnx_config_interface,
+ .bss_info_changed = agnx_bss_info_changed,
.configure_filter = agnx_configure_filter,
.get_stats = agnx_get_stats,
.get_tx_stats = agnx_get_tx_stats,
@@ -452,47 +454,35 @@ static int __devinit agnx_pci_probe(struct pci_dev *pdev,
{
struct ieee80211_hw *dev;
struct agnx_priv *priv;
- u32 mem_addr0, mem_len0;
- u32 mem_addr1, mem_len1;
int err;
- DECLARE_MAC_BUF(mac);
err = pci_enable_device(pdev);
if (err) {
- printk(KERN_ERR PFX "Can't enable new PCI device\n");
+ dev_err(&pdev->dev, "can't enable pci device\n");
return err;
}
- /* get pci resource */
- mem_addr0 = pci_resource_start(pdev, 0);
- mem_len0 = pci_resource_len(pdev, 0);
- mem_addr1 = pci_resource_start(pdev, 1);
- mem_len1 = pci_resource_len(pdev, 1);
- printk(KERN_DEBUG PFX "Memaddr0 is %x, length is %x\n", mem_addr0, mem_len0);
- printk(KERN_DEBUG PFX "Memaddr1 is %x, length is %x\n", mem_addr1, mem_len1);
-
err = pci_request_regions(pdev, "agnx-pci");
if (err) {
- printk(KERN_ERR PFX "Can't obtain PCI resource\n");
+ dev_err(&pdev->dev, "can't reserve PCI resources\n");
return err;
}
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) ||
pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
- printk(KERN_ERR PFX "No suitable DMA available\n");
+ dev_err(&pdev->dev, "no suitable DMA available\n");
+ err = -EIO;
goto err_free_reg;
}
pci_set_master(pdev);
- printk(KERN_DEBUG PFX "pdev->irq is %d\n", pdev->irq);
dev = ieee80211_alloc_hw(sizeof(*priv), &agnx_ops);
if (!dev) {
- printk(KERN_ERR PFX "ieee80211 alloc failed\n");
+ dev_err(&pdev->dev, "ieee80211 alloc failed\n");
err = -ENOMEM;
goto err_free_reg;
}
- /* init priv */
priv = dev->priv;
memset(priv, 0, sizeof(*priv));
priv->mode = NL80211_IFTYPE_MONITOR;
@@ -501,17 +491,17 @@ static int __devinit agnx_pci_probe(struct pci_dev *pdev,
spin_lock_init(&priv->lock);
priv->init_status = AGNX_UNINIT;
- /* Map mem #1 and #2 */
- priv->ctl = pci_iomap(pdev, 0, mem_len0);
-/* printk(KERN_DEBUG PFX"MEM1 mapped address is 0x%p\n", priv->ctl); */
+ priv->ctl = pci_iomap(pdev, 0, 0);
+/* dev_dbg(&pdev->dev, "MEM1 mapped address is 0x%p\n", priv->ctl); */
if (!priv->ctl) {
- printk(KERN_ERR PFX "Can't map device memory\n");
+ dev_err(&pdev->dev, "can't map device memory\n");
+ err = -ENOMEM;
goto err_free_dev;
}
- priv->data = pci_iomap(pdev, 1, mem_len1);
- printk(KERN_DEBUG PFX "MEM2 mapped address is 0x%p\n", priv->data);
+ priv->data = pci_iomap(pdev, 1, 0);
if (!priv->data) {
- printk(KERN_ERR PFX "Can't map device memory\n");
+ dev_err(&pdev->dev, "can't map device memory\n");
+ err = -ENOMEM;
goto err_iounmap2;
}
@@ -552,15 +542,15 @@ static int __devinit agnx_pci_probe(struct pci_dev *pdev,
err = ieee80211_register_hw(dev);
if (err) {
- printk(KERN_ERR PFX "Can't register hardware\n");
+ dev_err(&pdev->dev, "can't register hardware\n");
goto err_iounmap;
}
agnx_hw_reset(priv);
-
- printk(PFX "%s: hwaddr %s, Rev 0x%02x\n", wiphy_name(dev->wiphy),
- print_mac(mac, dev->wiphy->perm_addr), priv->revid);
+ dev_info(&pdev->dev, "%s: hwaddr %pM, Rev 0x%02x\n",
+ wiphy_name(dev->wiphy),
+ dev->wiphy->perm_addr, priv->revid);
return 0;
err_iounmap:
diff --git a/drivers/staging/agnx/phy.c b/drivers/staging/agnx/phy.c
index 2be63312b727..ec1ca86fa0c4 100644
--- a/drivers/staging/agnx/phy.c
+++ b/drivers/staging/agnx/phy.c
@@ -118,7 +118,7 @@ static void mac_address_set(struct agnx_priv *priv)
iowrite32(reg, ctl + AGNX_RXM_MACLO);
}
-static void receiver_bssid_set(struct agnx_priv *priv, u8 *bssid)
+static void receiver_bssid_set(struct agnx_priv *priv, const u8 *bssid)
{
void __iomem *ctl = priv->ctl;
u32 reg;
@@ -954,7 +954,7 @@ int agnx_set_ssid(struct agnx_priv *priv, u8 *ssid, size_t ssid_len)
return 0;
}
-void agnx_set_bssid(struct agnx_priv *priv, u8 *bssid)
+void agnx_set_bssid(struct agnx_priv *priv, const u8 *bssid)
{
receiver_bssid_set(priv, bssid);
}
diff --git a/drivers/staging/agnx/phy.h b/drivers/staging/agnx/phy.h
index 55e1e222179e..a955f05361e7 100644
--- a/drivers/staging/agnx/phy.h
+++ b/drivers/staging/agnx/phy.h
@@ -401,7 +401,7 @@ u8 read_from_eeprom(struct agnx_priv *priv, u16 address);
void agnx_hw_init(struct agnx_priv *priv);
int agnx_hw_reset(struct agnx_priv *priv);
int agnx_set_ssid(struct agnx_priv *priv, u8 *ssid, size_t ssid_len);
-void agnx_set_bssid(struct agnx_priv *priv, u8 *bssid);
+void agnx_set_bssid(struct agnx_priv *priv, const u8 *bssid);
void enable_power_saving(struct agnx_priv *priv);
void disable_power_saving(struct agnx_priv *priv);
void calibrate_antenna_period(unsigned long data);
diff --git a/drivers/staging/agnx/sta.c b/drivers/staging/agnx/sta.c
index 5b2d54a587c8..3e7db5e2811a 100644
--- a/drivers/staging/agnx/sta.c
+++ b/drivers/staging/agnx/sta.c
@@ -22,7 +22,7 @@ void hash_read(struct agnx_priv *priv, u32 reghi, u32 reglo, u8 sta_id)
printk(PFX "RX hash cmd are : %.8x%.8x\n", reghi, reglo);
}
-void hash_write(struct agnx_priv *priv, u8 *mac_addr, u8 sta_id)
+void hash_write(struct agnx_priv *priv, const u8 *mac_addr, u8 sta_id)
{
void __iomem *ctl = priv->ctl;
u32 reghi, reglo;
diff --git a/drivers/staging/agnx/sta.h b/drivers/staging/agnx/sta.h
index 94e2cf1f973f..fd504e3f3870 100644
--- a/drivers/staging/agnx/sta.h
+++ b/drivers/staging/agnx/sta.h
@@ -201,7 +201,7 @@ struct agnx_beacon_hdr {
/* 802.11(abg) beacon */
} __attribute__((__packed__));
-void hash_write(struct agnx_priv *priv, u8 *mac_addr, u8 sta_id);
+void hash_write(struct agnx_priv *priv, const u8 *mac_addr, u8 sta_id);
void hash_dump(struct agnx_priv *priv, u8 sta_id);
void hash_read(struct agnx_priv *priv, u32 reghi, u32 reglo, u8 sta_id);
void hash_delete(struct agnx_priv *priv, u32 reghi, u32 reglo, u8 sta_id);
diff --git a/drivers/staging/altpciechdma/altpciechdma.c b/drivers/staging/altpciechdma/altpciechdma.c
index 5869e1484a95..f5004d3cef63 100644
--- a/drivers/staging/altpciechdma/altpciechdma.c
+++ b/drivers/staging/altpciechdma/altpciechdma.c
@@ -783,7 +783,7 @@ static int __devinit probe(struct pci_dev *dev, const struct pci_device_id *id)
goto err_ape;
}
ape->pci_dev = dev;
- dev->dev.driver_data = (void *)ape;
+ dev_set_drvdata(&dev->dev, ape);
printk(KERN_DEBUG "probe() ape = 0x%p\n", ape);
printk(KERN_DEBUG "sizeof(struct ape_chdma_table) = %d.\n",
@@ -946,19 +946,11 @@ end:
static void __devexit remove(struct pci_dev *dev)
{
- struct ape_dev *ape;
+ struct ape_dev *ape = dev_get_drvdata(&dev->dev);
+
printk(KERN_DEBUG "remove(0x%p)\n", dev);
- if ((dev == 0) || (dev->dev.driver_data == 0)) {
- printk(KERN_DEBUG "remove(dev = 0x%p) dev->dev.driver_data = 0x%p\n",
- dev, (dev? dev->dev.driver_data: NULL));
- return;
- }
- ape = (struct ape_dev *)dev->dev.driver_data;
- printk(KERN_DEBUG "remove(dev = 0x%p) where dev->dev.driver_data = 0x%p\n", dev, ape);
- if (ape->pci_dev != dev) {
- printk(KERN_DEBUG "dev->dev.driver_data->pci_dev (0x%08lx) != dev (0x%08lx)\n",
- (unsigned long)ape->pci_dev, (unsigned long)dev);
- }
+ printk(KERN_DEBUG "remove(dev = 0x%p) where ape = 0x%p\n", dev, ape);
+
/* remove character device */
#if ALTPCIECHDMA_CDEV
sg_exit(ape);
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 604bd1e0d546..178450876314 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -73,9 +73,13 @@ config ANDROID_RAM_CONSOLE_EARLY_SIZE
default 0
depends on ANDROID_RAM_CONSOLE_EARLY_INIT
+config ANDROID_TIMED_OUTPUT
+ bool "Timed output class driver"
+ default y
+
config ANDROID_TIMED_GPIO
tristate "Android timed gpio driver"
- depends on GENERIC_GPIO
+ depends on GENERIC_GPIO && ANDROID_TIMED_OUTPUT
default n
config ANDROID_LOW_MEMORY_KILLER
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index 95209d6273a1..8e057e626d11 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o
obj-$(CONFIG_ANDROID_LOGGER) += logger.o
obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o
+obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o
obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o
obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 299d29d1dadb..17d89a8124ad 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -44,8 +44,8 @@ static struct hlist_head binder_dead_nodes;
static HLIST_HEAD(binder_deferred_list);
static DEFINE_MUTEX(binder_deferred_lock);
-static int binder_read_proc_proc(
- char *page, char **start, off_t off, int count, int *eof, void *data);
+static int binder_read_proc_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
/* This is only defined in include/asm-arm/sizes.h */
#ifndef SZ_1K
@@ -81,12 +81,15 @@ enum {
static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR |
BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION;
module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO);
+
static int binder_debug_no_lock;
module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO);
+
static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait);
static int binder_stop_on_user_error;
-static int binder_set_stop_on_user_error(
- const char *val, struct kernel_param *kp)
+
+static int binder_set_stop_on_user_error(const char *val,
+ struct kernel_param *kp)
{
int ret;
ret = param_set_int(val, kp);
@@ -185,13 +188,13 @@ struct binder_node {
int local_strong_refs;
void __user *ptr;
void __user *cookie;
- unsigned has_strong_ref : 1;
- unsigned pending_strong_ref : 1;
- unsigned has_weak_ref : 1;
- unsigned pending_weak_ref : 1;
- unsigned has_async_transaction : 1;
- unsigned accept_fds : 1;
- int min_priority : 8;
+ unsigned has_strong_ref:1;
+ unsigned pending_strong_ref:1;
+ unsigned has_weak_ref:1;
+ unsigned pending_weak_ref:1;
+ unsigned has_async_transaction:1;
+ unsigned accept_fds:1;
+ unsigned min_priority:8;
struct list_head async_todo;
};
@@ -221,10 +224,10 @@ struct binder_buffer {
struct list_head entry; /* free and allocated entries by addesss */
struct rb_node rb_node; /* free entry by size or allocated entry */
/* by address */
- unsigned free : 1;
- unsigned allow_user_free : 1;
- unsigned async_transaction : 1;
- unsigned debug_id : 29;
+ unsigned free:1;
+ unsigned allow_user_free:1;
+ unsigned async_transaction:1;
+ unsigned debug_id:29;
struct binder_transaction *transaction;
@@ -306,8 +309,8 @@ struct binder_transaction {
struct binder_proc *to_proc;
struct binder_thread *to_thread;
struct binder_transaction *to_parent;
- unsigned need_reply : 1;
- /*unsigned is_dead : 1;*/ /* not used at the moment */
+ unsigned need_reply:1;
+ /* unsigned is_dead:1; */ /* not used at the moment */
struct binder_buffer *buffer;
unsigned int code;
@@ -474,8 +477,8 @@ static void binder_set_nice(long nice)
binder_user_error("binder: %d RLIMIT_NICE not set\n", current->pid);
}
-static size_t binder_buffer_size(
- struct binder_proc *proc, struct binder_buffer *buffer)
+static size_t binder_buffer_size(struct binder_proc *proc,
+ struct binder_buffer *buffer)
{
if (list_is_last(&buffer->entry, &proc->buffers))
return proc->buffer + proc->buffer_size - (void *)buffer->data;
@@ -484,8 +487,8 @@ static size_t binder_buffer_size(
struct binder_buffer, entry) - (size_t)buffer->data;
}
-static void binder_insert_free_buffer(
- struct binder_proc *proc, struct binder_buffer *new_buffer)
+static void binder_insert_free_buffer(struct binder_proc *proc,
+ struct binder_buffer *new_buffer)
{
struct rb_node **p = &proc->free_buffers.rb_node;
struct rb_node *parent = NULL;
@@ -517,8 +520,8 @@ static void binder_insert_free_buffer(
rb_insert_color(&new_buffer->rb_node, &proc->free_buffers);
}
-static void binder_insert_allocated_buffer(
- struct binder_proc *proc, struct binder_buffer *new_buffer)
+static void binder_insert_allocated_buffer(struct binder_proc *proc,
+ struct binder_buffer *new_buffer)
{
struct rb_node **p = &proc->allocated_buffers.rb_node;
struct rb_node *parent = NULL;
@@ -542,8 +545,8 @@ static void binder_insert_allocated_buffer(
rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers);
}
-static struct binder_buffer *binder_buffer_lookup(
- struct binder_proc *proc, void __user *user_ptr)
+static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc,
+ void __user *user_ptr)
{
struct rb_node *n = proc->allocated_buffers.rb_node;
struct binder_buffer *buffer;
@@ -567,7 +570,8 @@ static struct binder_buffer *binder_buffer_lookup(
}
static int binder_update_page_range(struct binder_proc *proc, int allocate,
- void *start, void *end, struct vm_area_struct *vma)
+ void *start, void *end,
+ struct vm_area_struct *vma)
{
void *page_addr;
unsigned long user_page_addr;
@@ -664,7 +668,8 @@ err_no_vma:
}
static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
- size_t data_size, size_t offsets_size, int is_async)
+ size_t data_size,
+ size_t offsets_size, int is_async)
{
struct rb_node *n = proc->free_buffers.rb_node;
struct binder_buffer *buffer;
@@ -692,8 +697,9 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
if (is_async &&
proc->free_async_space < size + sizeof(struct binder_buffer)) {
if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_ERR "binder: %d: binder_alloc_buf size %zd f"
- "ailed, no async space left\n", proc->pid, size);
+ printk(KERN_ERR
+ "binder: %d: binder_alloc_buf size %zd failed, "
+ "no async space left\n", proc->pid, size);
return NULL;
}
@@ -777,8 +783,8 @@ static void *buffer_end_page(struct binder_buffer *buffer)
return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK);
}
-static void binder_delete_free_buffer(
- struct binder_proc *proc, struct binder_buffer *buffer)
+static void binder_delete_free_buffer(struct binder_proc *proc,
+ struct binder_buffer *buffer)
{
struct binder_buffer *prev, *next = NULL;
int free_page_end = 1;
@@ -824,8 +830,8 @@ static void binder_delete_free_buffer(
}
}
-static void binder_free_buf(
- struct binder_proc *proc, struct binder_buffer *buffer)
+static void binder_free_buf(struct binder_proc *proc,
+ struct binder_buffer *buffer)
{
size_t size, buffer_size;
@@ -877,8 +883,8 @@ static void binder_free_buf(
binder_insert_free_buffer(proc, buffer);
}
-static struct binder_node *
-binder_get_node(struct binder_proc *proc, void __user *ptr)
+static struct binder_node *binder_get_node(struct binder_proc *proc,
+ void __user *ptr)
{
struct rb_node *n = proc->nodes.rb_node;
struct binder_node *node;
@@ -896,8 +902,9 @@ binder_get_node(struct binder_proc *proc, void __user *ptr)
return NULL;
}
-static struct binder_node *
-binder_new_node(struct binder_proc *proc, void __user *ptr, void __user *cookie)
+static struct binder_node *binder_new_node(struct binder_proc *proc,
+ void __user *ptr,
+ void __user *cookie)
{
struct rb_node **p = &proc->nodes.rb_node;
struct rb_node *parent = NULL;
@@ -935,9 +942,8 @@ binder_new_node(struct binder_proc *proc, void __user *ptr, void __user *cookie)
return node;
}
-static int
-binder_inc_node(struct binder_node *node, int strong, int internal,
- struct list_head *target_list)
+static int binder_inc_node(struct binder_node *node, int strong, int internal,
+ struct list_head *target_list)
{
if (strong) {
if (internal) {
@@ -971,8 +977,7 @@ binder_inc_node(struct binder_node *node, int strong, int internal,
return 0;
}
-static int
-binder_dec_node(struct binder_node *node, int strong, int internal)
+static int binder_dec_node(struct binder_node *node, int strong, int internal)
{
if (strong) {
if (internal)
@@ -1014,8 +1019,8 @@ binder_dec_node(struct binder_node *node, int strong, int internal)
}
-static struct binder_ref *
-binder_get_ref(struct binder_proc *proc, uint32_t desc)
+static struct binder_ref *binder_get_ref(struct binder_proc *proc,
+ uint32_t desc)
{
struct rb_node *n = proc->refs_by_desc.rb_node;
struct binder_ref *ref;
@@ -1033,8 +1038,8 @@ binder_get_ref(struct binder_proc *proc, uint32_t desc)
return NULL;
}
-static struct binder_ref *
-binder_get_ref_for_node(struct binder_proc *proc, struct binder_node *node)
+static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc,
+ struct binder_node *node)
{
struct rb_node *n;
struct rb_node **p = &proc->refs_by_node.rb_node;
@@ -1099,8 +1104,7 @@ binder_get_ref_for_node(struct binder_proc *proc, struct binder_node *node)
return new_ref;
}
-static void
-binder_delete_ref(struct binder_ref *ref)
+static void binder_delete_ref(struct binder_ref *ref)
{
if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
printk(KERN_INFO "binder: %d delete ref %d desc %d for "
@@ -1125,9 +1129,8 @@ binder_delete_ref(struct binder_ref *ref)
binder_stats.obj_deleted[BINDER_STAT_REF]++;
}
-static int
-binder_inc_ref(
- struct binder_ref *ref, int strong, struct list_head *target_list)
+static int binder_inc_ref(struct binder_ref *ref, int strong,
+ struct list_head *target_list)
{
int ret;
if (strong) {
@@ -1149,8 +1152,7 @@ binder_inc_ref(
}
-static int
-binder_dec_ref(struct binder_ref *ref, int strong)
+static int binder_dec_ref(struct binder_ref *ref, int strong)
{
if (strong) {
if (ref->strong == 0) {
@@ -1182,9 +1184,8 @@ binder_dec_ref(struct binder_ref *ref, int strong)
return 0;
}
-static void
-binder_pop_transaction(
- struct binder_thread *target_thread, struct binder_transaction *t)
+static void binder_pop_transaction(struct binder_thread *target_thread,
+ struct binder_transaction *t)
{
if (target_thread) {
BUG_ON(target_thread->transaction_stack != t);
@@ -1200,8 +1201,8 @@ binder_pop_transaction(
binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++;
}
-static void
-binder_send_failed_reply(struct binder_transaction *t, uint32_t error_code)
+static void binder_send_failed_reply(struct binder_transaction *t,
+ uint32_t error_code)
{
struct binder_thread *target_thread;
BUG_ON(t->flags & TF_ONE_WAY);
@@ -1253,13 +1254,13 @@ binder_send_failed_reply(struct binder_transaction *t, uint32_t error_code)
}
}
-static void
-binder_transaction_buffer_release(struct binder_proc *proc,
- struct binder_buffer *buffer, size_t *failed_at);
+static void binder_transaction_buffer_release(struct binder_proc *proc,
+ struct binder_buffer *buffer,
+ size_t *failed_at);
-static void
-binder_transaction(struct binder_proc *proc, struct binder_thread *thread,
- struct binder_transaction_data *tr, int reply)
+static void binder_transaction(struct binder_proc *proc,
+ struct binder_thread *thread,
+ struct binder_transaction_data *tr, int reply)
{
struct binder_transaction *t;
struct binder_work *tcomplete;
@@ -1661,8 +1662,9 @@ err_no_context_mgr_node:
thread->return_error = return_error;
}
-static void
-binder_transaction_buffer_release(struct binder_proc *proc, struct binder_buffer *buffer, size_t *failed_at)
+static void binder_transaction_buffer_release(struct binder_proc *proc,
+ struct binder_buffer *buffer,
+ size_t *failed_at)
{
size_t *offp, *off_end;
int debug_id = buffer->debug_id;
@@ -1730,9 +1732,8 @@ binder_transaction_buffer_release(struct binder_proc *proc, struct binder_buffer
}
}
-int
-binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
- void __user *buffer, int size, signed long *consumed)
+int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
+ void __user *buffer, int size, signed long *consumed)
{
uint32_t cmd;
void __user *ptr = buffer + *consumed;
@@ -2104,7 +2105,8 @@ binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
} break;
default:
- printk(KERN_ERR "binder: %d:%d unknown command %d\n", proc->pid, thread->pid, cmd);
+ printk(KERN_ERR "binder: %d:%d unknown command %d\n",
+ proc->pid, thread->pid, cmd);
return -EINVAL;
}
*consumed = ptr - buffer;
@@ -2112,8 +2114,8 @@ binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
return 0;
}
-void
-binder_stat_br(struct binder_proc *proc, struct binder_thread *thread, uint32_t cmd)
+void binder_stat_br(struct binder_proc *proc, struct binder_thread *thread,
+ uint32_t cmd)
{
if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) {
binder_stats.br[_IOC_NR(cmd)]++;
@@ -2122,22 +2124,23 @@ binder_stat_br(struct binder_proc *proc, struct binder_thread *thread, uint32_t
}
}
-static int
-binder_has_proc_work(struct binder_proc *proc, struct binder_thread *thread)
+static int binder_has_proc_work(struct binder_proc *proc,
+ struct binder_thread *thread)
{
- return !list_empty(&proc->todo) || (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
+ return !list_empty(&proc->todo) ||
+ (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
}
-static int
-binder_has_thread_work(struct binder_thread *thread)
+static int binder_has_thread_work(struct binder_thread *thread)
{
return !list_empty(&thread->todo) || thread->return_error != BR_OK ||
(thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
}
-static int
-binder_thread_read(struct binder_proc *proc, struct binder_thread *thread,
- void __user *buffer, int size, signed long *consumed, int non_block)
+static int binder_thread_read(struct binder_proc *proc,
+ struct binder_thread *thread,
+ void __user *buffer, int size,
+ signed long *consumed, int non_block)
{
void __user *ptr = buffer + *consumed;
void __user *end = buffer + size;
@@ -2152,7 +2155,8 @@ binder_thread_read(struct binder_proc *proc, struct binder_thread *thread,
}
retry:
- wait_for_proc_work = thread->transaction_stack == NULL && list_empty(&thread->todo);
+ wait_for_proc_work = thread->transaction_stack == NULL &&
+ list_empty(&thread->todo);
if (thread->return_error != BR_OK && ptr < end) {
if (thread->return_error2 != BR_OK) {
@@ -2182,7 +2186,8 @@ retry:
"for process work before calling BC_REGISTER_"
"LOOPER or BC_ENTER_LOOPER (state %x)\n",
proc->pid, thread->pid, thread->looper);
- wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
+ wait_event_interruptible(binder_user_error_wait,
+ binder_stop_on_user_error < 2);
}
binder_set_nice(proc->default_priority);
if (non_block) {
@@ -2304,8 +2309,10 @@ retry:
case BINDER_WORK_DEAD_BINDER:
case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
- struct binder_ref_death *death = container_of(w, struct binder_ref_death, work);
+ struct binder_ref_death *death;
uint32_t cmd;
+
+ death = container_of(w, struct binder_ref_death, work);
if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION)
cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE;
else
@@ -2362,15 +2369,19 @@ retry:
if (t->from) {
struct task_struct *sender = t->from->proc->tsk;
- tr.sender_pid = task_tgid_nr_ns(sender, current->nsproxy->pid_ns);
+ tr.sender_pid = task_tgid_nr_ns(sender,
+ current->nsproxy->pid_ns);
} else {
tr.sender_pid = 0;
}
tr.data_size = t->buffer->data_size;
tr.offsets_size = t->buffer->offsets_size;
- tr.data.ptr.buffer = (void *)t->buffer->data + proc->user_buffer_offset;
- tr.data.ptr.offsets = tr.data.ptr.buffer + ALIGN(t->buffer->data_size, sizeof(void *));
+ tr.data.ptr.buffer = (void *)t->buffer->data +
+ proc->user_buffer_offset;
+ tr.data.ptr.offsets = tr.data.ptr.buffer +
+ ALIGN(t->buffer->data_size,
+ sizeof(void *));
if (put_user(cmd, (uint32_t __user *)ptr))
return -EFAULT;
@@ -2384,7 +2395,8 @@ retry:
printk(KERN_INFO "binder: %d:%d %s %d %d:%d, cmd %d"
"size %zd-%zd ptr %p-%p\n",
proc->pid, thread->pid,
- (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" : "BR_REPLY",
+ (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
+ "BR_REPLY",
t->debug_id, t->from ? t->from->proc->pid : 0,
t->from ? t->from->pid : 0, cmd,
t->buffer->data_size, t->buffer->offsets_size,
@@ -2430,7 +2442,9 @@ static void binder_release_work(struct list_head *list)
list_del_init(&w->entry);
switch (w->type) {
case BINDER_WORK_TRANSACTION: {
- struct binder_transaction *t = container_of(w, struct binder_transaction, work);
+ struct binder_transaction *t;
+
+ t = container_of(w, struct binder_transaction, work);
if (t->buffer->target_node && !(t->flags & TF_ONE_WAY))
binder_send_failed_reply(t, BR_DEAD_REPLY);
} break;
@@ -2480,7 +2494,8 @@ static struct binder_thread *binder_get_thread(struct binder_proc *proc)
return thread;
}
-static int binder_free_thread(struct binder_proc *proc, struct binder_thread *thread)
+static int binder_free_thread(struct binder_proc *proc,
+ struct binder_thread *thread)
{
struct binder_transaction *t;
struct binder_transaction *send_reply = NULL;
@@ -2493,8 +2508,10 @@ static int binder_free_thread(struct binder_proc *proc, struct binder_thread *th
while (t) {
active_transactions++;
if (binder_debug_mask & BINDER_DEBUG_DEAD_TRANSACTION)
- printk(KERN_INFO "binder: release %d:%d transaction %d %s, still active\n",
- proc->pid, thread->pid, t->debug_id, (t->to_thread == thread) ? "in" : "out");
+ printk(KERN_INFO "binder: release %d:%d transaction %d "
+ "%s, still active\n", proc->pid, thread->pid,
+ t->debug_id,
+ (t->to_thread == thread) ? "in" : "out");
if (t->to_thread == thread) {
t->to_proc = NULL;
t->to_thread = NULL;
@@ -2517,7 +2534,8 @@ static int binder_free_thread(struct binder_proc *proc, struct binder_thread *th
return active_transactions;
}
-static unsigned int binder_poll(struct file *filp, struct poll_table_struct *wait)
+static unsigned int binder_poll(struct file *filp,
+ struct poll_table_struct *wait)
{
struct binder_proc *proc = filp->private_data;
struct binder_thread *thread = NULL;
@@ -2778,7 +2796,8 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
proc->files = get_files_struct(current);
proc->vma = vma;
- /*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
+ /*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n",
+ proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
return 0;
err_alloc_small_buf_failed:
@@ -2790,7 +2809,8 @@ err_alloc_pages_failed:
err_get_vm_area_failed:
err_already_mapped:
err_bad_arg:
- printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n", proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
+ printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n",
+ proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
return ret;
}
@@ -2799,7 +2819,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
struct binder_proc *proc;
if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
- printk(KERN_INFO "binder_open: %d:%d\n", current->group_leader->pid, current->pid);
+ printk(KERN_INFO "binder_open: %d:%d\n",
+ current->group_leader->pid, current->pid);
proc = kzalloc(sizeof(*proc), GFP_KERNEL);
if (proc == NULL)
@@ -2821,7 +2842,9 @@ static int binder_open(struct inode *nodp, struct file *filp)
char strbuf[11];
snprintf(strbuf, sizeof(strbuf), "%u", proc->pid);
remove_proc_entry(strbuf, binder_proc_dir_entry_proc);
- create_proc_read_entry(strbuf, S_IRUGO, binder_proc_dir_entry_proc, binder_read_proc_proc, proc);
+ create_proc_read_entry(strbuf, S_IRUGO,
+ binder_proc_dir_entry_proc,
+ binder_read_proc_proc, proc);
}
return 0;
@@ -2925,12 +2948,15 @@ static void binder_deferred_release(struct binder_proc *proc)
}
}
if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
- printk(KERN_INFO "binder: node %d now dead, refs %d, death %d\n", node->debug_id, incoming_refs, death);
+ printk(KERN_INFO "binder: node %d now dead, "
+ "refs %d, death %d\n", node->debug_id,
+ incoming_refs, death);
}
}
outgoing_refs = 0;
while ((n = rb_first(&proc->refs_by_desc))) {
- struct binder_ref *ref = rb_entry(n, struct binder_ref, rb_node_desc);
+ struct binder_ref *ref = rb_entry(n, struct binder_ref,
+ rb_node_desc);
outgoing_refs++;
binder_delete_ref(ref);
}
@@ -2938,12 +2964,15 @@ static void binder_deferred_release(struct binder_proc *proc)
buffers = 0;
while ((n = rb_first(&proc->allocated_buffers))) {
- struct binder_buffer *buffer = rb_entry(n, struct binder_buffer, rb_node);
+ struct binder_buffer *buffer = rb_entry(n, struct binder_buffer,
+ rb_node);
t = buffer->transaction;
if (t) {
t->buffer = NULL;
buffer->transaction = NULL;
- printk(KERN_ERR "binder: release proc %d, transaction %d, not freed\n", proc->pid, t->debug_id);
+ printk(KERN_ERR "binder: release proc %d, "
+ "transaction %d, not freed\n",
+ proc->pid, t->debug_id);
/*BUG();*/
}
binder_free_buf(proc, buffer);
@@ -2957,8 +2986,13 @@ static void binder_deferred_release(struct binder_proc *proc)
int i;
for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) {
if (proc->pages[i]) {
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder_release: %d: page %d at %p not freed\n", proc->pid, i, proc->buffer + i * PAGE_SIZE);
+ if (binder_debug_mask &
+ BINDER_DEBUG_BUFFER_ALLOC)
+ printk(KERN_INFO
+ "binder_release: %d: "
+ "page %d at %p not freed\n",
+ proc->pid, i,
+ proc->buffer + i * PAGE_SIZE);
__free_page(proc->pages[i]);
page_count++;
}
@@ -2970,8 +3004,12 @@ static void binder_deferred_release(struct binder_proc *proc)
put_task_struct(proc->tsk);
if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
- printk(KERN_INFO "binder_release: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n",
- proc->pid, threads, nodes, incoming_refs, outgoing_refs, active_transactions, buffers, page_count);
+ printk(KERN_INFO
+ "binder_release: %d threads %d, nodes %d (ref %d), "
+ "refs %d, active transactions %d, buffers %d, "
+ "pages %d\n",
+ proc->pid, threads, nodes, incoming_refs, outgoing_refs,
+ active_transactions, buffers, page_count);
kfree(proc);
}
@@ -2998,9 +3036,11 @@ static void binder_deferred_func(struct work_struct *work)
mutex_unlock(&binder_deferred_lock);
files = NULL;
- if (defer & BINDER_DEFERRED_PUT_FILES)
- if ((files = proc->files))
+ if (defer & BINDER_DEFERRED_PUT_FILES) {
+ files = proc->files;
+ if (files)
proc->files = NULL;
+ }
if (defer & BINDER_DEFERRED_FLUSH)
binder_deferred_flush(proc);
@@ -3027,10 +3067,14 @@ static void binder_defer_work(struct binder_proc *proc, int defer)
mutex_unlock(&binder_deferred_lock);
}
-static char *print_binder_transaction(char *buf, char *end, const char *prefix, struct binder_transaction *t)
+static char *print_binder_transaction(char *buf, char *end, const char *prefix,
+ struct binder_transaction *t)
{
- buf += snprintf(buf, end - buf, "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d",
- prefix, t->debug_id, t, t->from ? t->from->proc->pid : 0,
+ buf += snprintf(buf, end - buf,
+ "%s %d: %p from %d:%d to %d:%d code %x "
+ "flags %x pri %ld r%d",
+ prefix, t->debug_id, t,
+ t->from ? t->from->proc->pid : 0,
t->from ? t->from->pid : 0,
t->to_proc ? t->to_proc->pid : 0,
t->to_thread ? t->to_thread->pid : 0,
@@ -3053,7 +3097,8 @@ static char *print_binder_transaction(char *buf, char *end, const char *prefix,
return buf;
}
-static char *print_binder_buffer(char *buf, char *end, const char *prefix, struct binder_buffer *buffer)
+static char *print_binder_buffer(char *buf, char *end, const char *prefix,
+ struct binder_buffer *buffer)
{
buf += snprintf(buf, end - buf, "%s %d: %p size %zd:%zd %s\n",
prefix, buffer->debug_id, buffer->data,
@@ -3063,7 +3108,8 @@ static char *print_binder_buffer(char *buf, char *end, const char *prefix, struc
}
static char *print_binder_work(char *buf, char *end, const char *prefix,
- const char *transaction_prefix, struct binder_work *w)
+ const char *transaction_prefix,
+ struct binder_work *w)
{
struct binder_node *node;
struct binder_transaction *t;
@@ -3080,7 +3126,8 @@ static char *print_binder_work(char *buf, char *end, const char *prefix,
case BINDER_WORK_NODE:
node = container_of(w, struct binder_node, work);
buf += snprintf(buf, end - buf, "%snode work %d: u%p c%p\n",
- prefix, node->debug_id, node->ptr, node->cookie);
+ prefix, node->debug_id, node->ptr,
+ node->cookie);
break;
case BINDER_WORK_DEAD_BINDER:
buf += snprintf(buf, end - buf, "%shas dead binder\n", prefix);
@@ -3101,27 +3148,33 @@ static char *print_binder_work(char *buf, char *end, const char *prefix,
return buf;
}
-static char *print_binder_thread(char *buf, char *end, struct binder_thread *thread, int print_always)
+static char *print_binder_thread(char *buf, char *end,
+ struct binder_thread *thread,
+ int print_always)
{
struct binder_transaction *t;
struct binder_work *w;
char *start_buf = buf;
char *header_buf;
- buf += snprintf(buf, end - buf, " thread %d: l %02x\n", thread->pid, thread->looper);
+ buf += snprintf(buf, end - buf, " thread %d: l %02x\n",
+ thread->pid, thread->looper);
header_buf = buf;
t = thread->transaction_stack;
while (t) {
if (buf >= end)
break;
if (t->from == thread) {
- buf = print_binder_transaction(buf, end, " outgoing transaction", t);
+ buf = print_binder_transaction(buf, end,
+ " outgoing transaction", t);
t = t->from_parent;
} else if (t->to_thread == thread) {
- buf = print_binder_transaction(buf, end, " incoming transaction", t);
+ buf = print_binder_transaction(buf, end,
+ " incoming transaction", t);
t = t->to_parent;
} else {
- buf = print_binder_transaction(buf, end, " bad transaction", t);
+ buf = print_binder_transaction(buf, end,
+ " bad transaction", t);
t = NULL;
}
}
@@ -3142,11 +3195,14 @@ static char *print_binder_node(char *buf, char *end, struct binder_node *node)
struct hlist_node *pos;
struct binder_work *w;
int count;
+
count = 0;
hlist_for_each_entry(ref, pos, &node->refs, node_entry)
count++;
- buf += snprintf(buf, end - buf, " node %d: u%p c%p hs %d hw %d ls %d lw %d is %d iw %d",
+ buf += snprintf(buf, end - buf,
+ " node %d: u%p c%p hs %d hw %d ls %d lw %d "
+ "is %d iw %d",
node->debug_id, node->ptr, node->cookie,
node->has_strong_ref, node->has_weak_ref,
node->local_strong_refs, node->local_weak_refs,
@@ -3175,13 +3231,16 @@ static char *print_binder_node(char *buf, char *end, struct binder_node *node)
static char *print_binder_ref(char *buf, char *end, struct binder_ref *ref)
{
- buf += snprintf(buf, end - buf, " ref %d: desc %d %snode %d s %d w %d d %p\n",
- ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ",
- ref->node->debug_id, ref->strong, ref->weak, ref->death);
+ buf += snprintf(buf, end - buf,
+ " ref %d: desc %d %snode %d s %d w %d d %p\n",
+ ref->debug_id, ref->desc,
+ ref->node->proc ? "" : "dead ", ref->node->debug_id,
+ ref->strong, ref->weak, ref->death);
return buf;
}
-static char *print_binder_proc(char *buf, char *end, struct binder_proc *proc, int print_all)
+static char *print_binder_proc(char *buf, char *end,
+ struct binder_proc *proc, int print_all)
{
struct binder_work *w;
struct rb_node *n;
@@ -3191,19 +3250,34 @@ static char *print_binder_proc(char *buf, char *end, struct binder_proc *proc, i
buf += snprintf(buf, end - buf, "proc %d\n", proc->pid);
header_buf = buf;
- for (n = rb_first(&proc->threads); n != NULL && buf < end; n = rb_next(n))
- buf = print_binder_thread(buf, end, rb_entry(n, struct binder_thread, rb_node), print_all);
- for (n = rb_first(&proc->nodes); n != NULL && buf < end; n = rb_next(n)) {
- struct binder_node *node = rb_entry(n, struct binder_node, rb_node);
+ for (n = rb_first(&proc->threads);
+ n != NULL && buf < end;
+ n = rb_next(n))
+ buf = print_binder_thread(buf, end,
+ rb_entry(n, struct binder_thread,
+ rb_node), print_all);
+ for (n = rb_first(&proc->nodes);
+ n != NULL && buf < end;
+ n = rb_next(n)) {
+ struct binder_node *node = rb_entry(n, struct binder_node,
+ rb_node);
if (print_all || node->has_async_transaction)
buf = print_binder_node(buf, end, node);
}
if (print_all) {
- for (n = rb_first(&proc->refs_by_desc); n != NULL && buf < end; n = rb_next(n))
- buf = print_binder_ref(buf, end, rb_entry(n, struct binder_ref, rb_node_desc));
- }
- for (n = rb_first(&proc->allocated_buffers); n != NULL && buf < end; n = rb_next(n))
- buf = print_binder_buffer(buf, end, " buffer", rb_entry(n, struct binder_buffer, rb_node));
+ for (n = rb_first(&proc->refs_by_desc);
+ n != NULL && buf < end;
+ n = rb_next(n))
+ buf = print_binder_ref(buf, end,
+ rb_entry(n, struct binder_ref,
+ rb_node_desc));
+ }
+ for (n = rb_first(&proc->allocated_buffers);
+ n != NULL && buf < end;
+ n = rb_next(n))
+ buf = print_binder_buffer(buf, end, " buffer",
+ rb_entry(n, struct binder_buffer,
+ rb_node));
list_for_each_entry(w, &proc->todo, entry) {
if (buf >= end)
break;
@@ -3213,7 +3287,8 @@ static char *print_binder_proc(char *buf, char *end, struct binder_proc *proc, i
list_for_each_entry(w, &proc->delivered_death, entry) {
if (buf >= end)
break;
- buf += snprintf(buf, end - buf, " has delivered dead binder\n");
+ buf += snprintf(buf, end - buf,
+ " has delivered dead binder\n");
break;
}
if (!print_all && buf == header_buf)
@@ -3272,20 +3347,24 @@ static const char *binder_objstat_strings[] = {
"transaction_complete"
};
-static char *print_binder_stats(char *buf, char *end, const char *prefix, struct binder_stats *stats)
+static char *print_binder_stats(char *buf, char *end, const char *prefix,
+ struct binder_stats *stats)
{
int i;
- BUILD_BUG_ON(ARRAY_SIZE(stats->bc) != ARRAY_SIZE(binder_command_strings));
+ BUILD_BUG_ON(ARRAY_SIZE(stats->bc) !=
+ ARRAY_SIZE(binder_command_strings));
for (i = 0; i < ARRAY_SIZE(stats->bc); i++) {
if (stats->bc[i])
buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix,
- binder_command_strings[i], stats->bc[i]);
+ binder_command_strings[i],
+ stats->bc[i]);
if (buf >= end)
return buf;
}
- BUILD_BUG_ON(ARRAY_SIZE(stats->br) != ARRAY_SIZE(binder_return_strings));
+ BUILD_BUG_ON(ARRAY_SIZE(stats->br) !=
+ ARRAY_SIZE(binder_return_strings));
for (i = 0; i < ARRAY_SIZE(stats->br); i++) {
if (stats->br[i])
buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix,
@@ -3294,13 +3373,17 @@ static char *print_binder_stats(char *buf, char *end, const char *prefix, struct
return buf;
}
- BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != ARRAY_SIZE(binder_objstat_strings));
- BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != ARRAY_SIZE(stats->obj_deleted));
+ BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
+ ARRAY_SIZE(binder_objstat_strings));
+ BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
+ ARRAY_SIZE(stats->obj_deleted));
for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) {
if (stats->obj_created[i] || stats->obj_deleted[i])
- buf += snprintf(buf, end - buf, "%s%s: active %d total %d\n", prefix,
+ buf += snprintf(buf, end - buf,
+ "%s%s: active %d total %d\n", prefix,
binder_objstat_strings[i],
- stats->obj_created[i] - stats->obj_deleted[i],
+ stats->obj_created[i] -
+ stats->obj_deleted[i],
stats->obj_created[i]);
if (buf >= end)
return buf;
@@ -3308,7 +3391,8 @@ static char *print_binder_stats(char *buf, char *end, const char *prefix, struct
return buf;
}
-static char *print_binder_proc_stats(char *buf, char *end, struct binder_proc *proc)
+static char *print_binder_proc_stats(char *buf, char *end,
+ struct binder_proc *proc)
{
struct binder_work *w;
struct rb_node *n;
@@ -3340,12 +3424,14 @@ static char *print_binder_proc_stats(char *buf, char *end, struct binder_proc *p
strong = 0;
weak = 0;
for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) {
- struct binder_ref *ref = rb_entry(n, struct binder_ref, rb_node_desc);
+ struct binder_ref *ref = rb_entry(n, struct binder_ref,
+ rb_node_desc);
count++;
strong += ref->strong;
weak += ref->weak;
}
- buf += snprintf(buf, end - buf, " refs: %d s %d w %d\n", count, strong, weak);
+ buf += snprintf(buf, end - buf, " refs: %d s %d w %d\n",
+ count, strong, weak);
if (buf >= end)
return buf;
@@ -3376,8 +3462,8 @@ static char *print_binder_proc_stats(char *buf, char *end, struct binder_proc *p
}
-static int binder_read_proc_state(
- char *page, char **start, off_t off, int count, int *eof, void *data)
+static int binder_read_proc_state(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
struct binder_proc *proc;
struct hlist_node *pos;
@@ -3424,8 +3510,8 @@ static int binder_read_proc_state(
return len < count ? len : count;
}
-static int binder_read_proc_stats(
- char *page, char **start, off_t off, int count, int *eof, void *data)
+static int binder_read_proc_stats(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
struct binder_proc *proc;
struct hlist_node *pos;
@@ -3464,8 +3550,8 @@ static int binder_read_proc_stats(
return len < count ? len : count;
}
-static int binder_read_proc_transactions(
- char *page, char **start, off_t off, int count, int *eof, void *data)
+static int binder_read_proc_transactions(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
struct binder_proc *proc;
struct hlist_node *pos;
@@ -3502,8 +3588,8 @@ static int binder_read_proc_transactions(
return len < count ? len : count;
}
-static int binder_read_proc_proc(
- char *page, char **start, off_t off, int count, int *eof, void *data)
+static int binder_read_proc_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
struct binder_proc *proc = data;
int len = 0;
@@ -3533,9 +3619,12 @@ static int binder_read_proc_proc(
return len < count ? len : count;
}
-static char *print_binder_transaction_log_entry(char *buf, char *end, struct binder_transaction_log_entry *e)
+static char *print_binder_transaction_log_entry(char *buf, char *end,
+ struct binder_transaction_log_entry *e)
{
- buf += snprintf(buf, end - buf, "%d: %s from %d:%d to %d:%d node %d handle %d size %d:%d\n",
+ buf += snprintf(buf, end - buf,
+ "%d: %s from %d:%d to %d:%d node %d handle %d "
+ "size %d:%d\n",
e->debug_id, (e->call_type == 2) ? "reply" :
((e->call_type == 1) ? "async" : "call "), e->from_proc,
e->from_thread, e->to_proc, e->to_thread, e->to_node,
@@ -3559,13 +3648,15 @@ static int binder_read_proc_transaction_log(
for (i = log->next; i < ARRAY_SIZE(log->entry); i++) {
if (buf >= end)
break;
- buf = print_binder_transaction_log_entry(buf, end, &log->entry[i]);
+ buf = print_binder_transaction_log_entry(buf, end,
+ &log->entry[i]);
}
}
for (i = 0; i < log->next; i++) {
if (buf >= end)
break;
- buf = print_binder_transaction_log_entry(buf, end, &log->entry[i]);
+ buf = print_binder_transaction_log_entry(buf, end,
+ &log->entry[i]);
}
*start = page + off;
@@ -3579,7 +3670,7 @@ static int binder_read_proc_transaction_log(
return len < count ? len : count;
}
-static struct file_operations binder_fops = {
+static const struct file_operations binder_fops = {
.owner = THIS_MODULE,
.poll = binder_poll,
.unlocked_ioctl = binder_ioctl,
@@ -3601,14 +3692,35 @@ static int __init binder_init(void)
binder_proc_dir_entry_root = proc_mkdir("binder", NULL);
if (binder_proc_dir_entry_root)
- binder_proc_dir_entry_proc = proc_mkdir("proc", binder_proc_dir_entry_root);
+ binder_proc_dir_entry_proc = proc_mkdir("proc",
+ binder_proc_dir_entry_root);
ret = misc_register(&binder_miscdev);
if (binder_proc_dir_entry_root) {
- create_proc_read_entry("state", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_state, NULL);
- create_proc_read_entry("stats", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_stats, NULL);
- create_proc_read_entry("transactions", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_transactions, NULL);
- create_proc_read_entry("transaction_log", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_transaction_log, &binder_transaction_log);
- create_proc_read_entry("failed_transaction_log", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_transaction_log, &binder_transaction_log_failed);
+ create_proc_read_entry("state",
+ S_IRUGO,
+ binder_proc_dir_entry_root,
+ binder_read_proc_state,
+ NULL);
+ create_proc_read_entry("stats",
+ S_IRUGO,
+ binder_proc_dir_entry_root,
+ binder_read_proc_stats,
+ NULL);
+ create_proc_read_entry("transactions",
+ S_IRUGO,
+ binder_proc_dir_entry_root,
+ binder_read_proc_transactions,
+ NULL);
+ create_proc_read_entry("transaction_log",
+ S_IRUGO,
+ binder_proc_dir_entry_root,
+ binder_read_proc_transaction_log,
+ &binder_transaction_log);
+ create_proc_read_entry("failed_transaction_log",
+ S_IRUGO,
+ binder_proc_dir_entry_root,
+ binder_read_proc_transaction_log,
+ &binder_transaction_log_failed);
}
return ret;
}
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index ab32003ecd0b..6c10b456c6cc 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -35,7 +35,7 @@
* mutex 'mutex'.
*/
struct logger_log {
- unsigned char * buffer; /* the ring buffer itself */
+ unsigned char *buffer;/* the ring buffer itself */
struct miscdevice misc; /* misc device representing the log */
wait_queue_head_t wq; /* wait queue for readers */
struct list_head readers; /* this log's readers */
@@ -52,7 +52,7 @@ struct logger_log {
* reference counting. The structure is protected by log->mutex.
*/
struct logger_reader {
- struct logger_log * log; /* associated log */
+ struct logger_log *log; /* associated log */
struct list_head list; /* entry in logger_log's list */
size_t r_off; /* current read head offset */
};
@@ -74,7 +74,7 @@ struct logger_reader {
* file->logger_log. Thus what file->private_data points at depends on whether
* or not the file was opened for reading. This function hides that dirtiness.
*/
-static inline struct logger_log * file_get_log(struct file *file)
+static inline struct logger_log *file_get_log(struct file *file)
{
if (file->f_mode & FMODE_READ) {
struct logger_reader *reader = file->private_data;
@@ -379,7 +379,7 @@ ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
return ret;
}
-static struct logger_log * get_log_from_minor(int);
+static struct logger_log *get_log_from_minor(int);
/*
* logger_open - the log's open() file operation
@@ -519,7 +519,7 @@ static long logger_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return ret;
}
-static struct file_operations logger_fops = {
+static const struct file_operations logger_fops = {
.owner = THIS_MODULE,
.read = logger_read,
.aio_write = logger_aio_write,
@@ -557,7 +557,7 @@ DEFINE_LOGGER_DEVICE(log_main, LOGGER_LOG_MAIN, 64*1024)
DEFINE_LOGGER_DEVICE(log_events, LOGGER_LOG_EVENTS, 256*1024)
DEFINE_LOGGER_DEVICE(log_radio, LOGGER_LOG_RADIO, 64*1024)
-static struct logger_log * get_log_from_minor(int minor)
+static struct logger_log *get_log_from_minor(int minor)
{
if (log_main.misc.minor == minor)
return &log_main;
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 3715d56ca96b..fe72240f5a9e 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -34,18 +34,24 @@ static int lowmem_adj[6] = {
};
static int lowmem_adj_size = 4;
static size_t lowmem_minfree[6] = {
- 3*512, // 6MB
- 2*1024, // 8MB
- 4*1024, // 16MB
- 16*1024, // 64MB
+ 3 * 512, /* 6MB */
+ 2 * 1024, /* 8MB */
+ 4 * 1024, /* 16MB */
+ 16 * 1024, /* 64MB */
};
static int lowmem_minfree_size = 4;
-#define lowmem_print(level, x...) do { if(lowmem_debug_level >= (level)) printk(x); } while(0)
+#define lowmem_print(level, x...) \
+ do { \
+ if (lowmem_debug_level >= (level)) \
+ printk(x); \
+ } while (0)
module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);
-module_param_array_named(adj, lowmem_adj, int, &lowmem_adj_size, S_IRUGO | S_IWUSR);
-module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size, S_IRUGO | S_IWUSR);
+module_param_array_named(adj, lowmem_adj, int, &lowmem_adj_size,
+ S_IRUGO | S_IWUSR);
+module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size,
+ S_IRUGO | S_IWUSR);
module_param_named(debug_level, lowmem_debug_level, uint, S_IRUGO | S_IWUSR);
static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
@@ -57,46 +63,77 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
int i;
int min_adj = OOM_ADJUST_MAX + 1;
int selected_tasksize = 0;
+ int selected_oom_adj;
int array_size = ARRAY_SIZE(lowmem_adj);
- int other_free = global_page_state(NR_FREE_PAGES) + global_page_state(NR_FILE_PAGES);
- if(lowmem_adj_size < array_size)
+ int other_free = global_page_state(NR_FREE_PAGES);
+ int other_file = global_page_state(NR_FILE_PAGES);
+
+ if (lowmem_adj_size < array_size)
array_size = lowmem_adj_size;
- if(lowmem_minfree_size < array_size)
+ if (lowmem_minfree_size < array_size)
array_size = lowmem_minfree_size;
- for(i = 0; i < array_size; i++) {
- if(other_free < lowmem_minfree[i]) {
+ for (i = 0; i < array_size; i++) {
+ if (other_free < lowmem_minfree[i] &&
+ other_file < lowmem_minfree[i]) {
min_adj = lowmem_adj[i];
break;
}
}
- if(nr_to_scan > 0)
- lowmem_print(3, "lowmem_shrink %d, %x, ofree %d, ma %d\n", nr_to_scan, gfp_mask, other_free, min_adj);
+ if (nr_to_scan > 0)
+ lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n",
+ nr_to_scan, gfp_mask, other_free, other_file,
+ min_adj);
+ rem = global_page_state(NR_ACTIVE_ANON) +
+ global_page_state(NR_ACTIVE_FILE) +
+ global_page_state(NR_INACTIVE_ANON) +
+ global_page_state(NR_INACTIVE_FILE);
+ if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) {
+ lowmem_print(5, "lowmem_shrink %d, %x, return %d\n",
+ nr_to_scan, gfp_mask, rem);
+ return rem;
+ }
+ selected_oom_adj = min_adj;
+
read_lock(&tasklist_lock);
for_each_process(p) {
- if(p->oomkilladj >= 0 && p->mm) {
- tasksize = get_mm_rss(p->mm);
- if(nr_to_scan > 0 && tasksize > 0 && p->oomkilladj >= min_adj) {
- if(selected == NULL ||
- p->oomkilladj > selected->oomkilladj ||
- (p->oomkilladj == selected->oomkilladj &&
- tasksize > selected_tasksize)) {
- selected = p;
- selected_tasksize = tasksize;
- lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
- p->pid, p->comm, p->oomkilladj, tasksize);
- }
- }
- rem += tasksize;
+ int oom_adj;
+
+ task_lock(p);
+ if (!p->mm) {
+ task_unlock(p);
+ continue;
+ }
+ oom_adj = p->oomkilladj;
+ if (oom_adj < min_adj) {
+ task_unlock(p);
+ continue;
+ }
+ tasksize = get_mm_rss(p->mm);
+ task_unlock(p);
+ if (tasksize <= 0)
+ continue;
+ if (selected) {
+ if (oom_adj < selected_oom_adj)
+ continue;
+ if (oom_adj == selected_oom_adj &&
+ tasksize <= selected_tasksize)
+ continue;
}
+ selected = p;
+ selected_tasksize = tasksize;
+ selected_oom_adj = oom_adj;
+ lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
+ p->pid, p->comm, oom_adj, tasksize);
}
- if(selected != NULL) {
+ if (selected) {
lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",
- selected->pid, selected->comm,
- selected->oomkilladj, selected_tasksize);
+ selected->pid, selected->comm,
+ selected_oom_adj, selected_tasksize);
force_sig(SIGKILL, selected);
rem -= selected_tasksize;
}
- lowmem_print(4, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem);
+ lowmem_print(4, "lowmem_shrink %d, %x, return %d\n",
+ nr_to_scan, gfp_mask, rem);
read_unlock(&tasklist_lock);
return rem;
}
diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c
index 3375c1cce2b3..8f18a59744cd 100644
--- a/drivers/staging/android/ram_console.c
+++ b/drivers/staging/android/ram_console.c
@@ -20,7 +20,7 @@
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/uaccess.h>
-#include <asm/io.h>
+#include <linux/io.h>
#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
#include <linux/rslib.h>
@@ -225,8 +225,9 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,
buffer_size - sizeof(struct ram_console_buffer);
if (ram_console_buffer_size > buffer_size) {
- pr_err("ram_console: buffer %p, invalid size %zu, datasize %zu\n",
- buffer, buffer_size, ram_console_buffer_size);
+ pr_err("ram_console: buffer %p, invalid size %zu, "
+ "datasize %zu\n", buffer, buffer_size,
+ ram_console_buffer_size);
return 0;
}
@@ -365,7 +366,7 @@ static ssize_t ram_console_read_old(struct file *file, char __user *buf,
return count;
}
-static struct file_operations ram_console_file_ops = {
+static const struct file_operations ram_console_file_ops = {
.owner = THIS_MODULE,
.read = ram_console_read_old,
};
diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 33daff0481d2..be7cdaa783ae 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -20,13 +20,12 @@
#include <linux/err.h>
#include <linux/gpio.h>
+#include "timed_output.h"
#include "timed_gpio.h"
-static struct class *timed_gpio_class;
-
struct timed_gpio_data {
- struct device *dev;
+ struct timed_output_dev dev;
struct hrtimer timer;
spinlock_t lock;
unsigned gpio;
@@ -36,70 +35,62 @@ struct timed_gpio_data {
static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer)
{
- struct timed_gpio_data *gpio_data = container_of(timer, struct timed_gpio_data, timer);
+ struct timed_gpio_data *data =
+ container_of(timer, struct timed_gpio_data, timer);
- gpio_direction_output(gpio_data->gpio, gpio_data->active_low ? 1 : 0);
+ gpio_direction_output(data->gpio, data->active_low ? 1 : 0);
return HRTIMER_NORESTART;
}
-static ssize_t gpio_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
+static int gpio_get_time(struct timed_output_dev *dev)
{
- struct timed_gpio_data *gpio_data = dev_get_drvdata(dev);
- int remaining;
+ struct timed_gpio_data *data =
+ container_of(dev, struct timed_gpio_data, dev);
- if (hrtimer_active(&gpio_data->timer)) {
- ktime_t r = hrtimer_get_remaining(&gpio_data->timer);
+ if (hrtimer_active(&data->timer)) {
+ ktime_t r = hrtimer_get_remaining(&data->timer);
struct timeval t = ktime_to_timeval(r);
- remaining = t.tv_sec * 1000 + t.tv_usec / 1000;
+ return t.tv_sec * 1000 + t.tv_usec / 1000;
} else
- remaining = 0;
-
- return sprintf(buf, "%d\n", remaining);
+ return 0;
}
-static ssize_t gpio_enable_store(
- struct device *dev, struct device_attribute *attr,
- const char *buf, size_t size)
+static void gpio_enable(struct timed_output_dev *dev, int value)
{
- struct timed_gpio_data *gpio_data = dev_get_drvdata(dev);
- int value;
+ struct timed_gpio_data *data =
+ container_of(dev, struct timed_gpio_data, dev);
unsigned long flags;
- sscanf(buf, "%d", &value);
-
- spin_lock_irqsave(&gpio_data->lock, flags);
+ spin_lock_irqsave(&data->lock, flags);
/* cancel previous timer and set GPIO according to value */
- hrtimer_cancel(&gpio_data->timer);
- gpio_direction_output(gpio_data->gpio, gpio_data->active_low ? !value : !!value);
+ hrtimer_cancel(&data->timer);
+ gpio_direction_output(data->gpio, data->active_low ? !value : !!value);
if (value > 0) {
- if (value > gpio_data->max_timeout)
- value = gpio_data->max_timeout;
+ if (value > data->max_timeout)
+ value = data->max_timeout;
- hrtimer_start(&gpio_data->timer,
- ktime_set(value / 1000, (value % 1000) * 1000000),
- HRTIMER_MODE_REL);
+ hrtimer_start(&data->timer,
+ ktime_set(value / 1000, (value % 1000) * 1000000),
+ HRTIMER_MODE_REL);
}
- spin_unlock_irqrestore(&gpio_data->lock, flags);
-
- return size;
+ spin_unlock_irqrestore(&data->lock, flags);
}
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, gpio_enable_show, gpio_enable_store);
-
static int timed_gpio_probe(struct platform_device *pdev)
{
struct timed_gpio_platform_data *pdata = pdev->dev.platform_data;
struct timed_gpio *cur_gpio;
struct timed_gpio_data *gpio_data, *gpio_dat;
- int i, ret = 0;
+ int i, j, ret = 0;
if (!pdata)
return -EBUSY;
- gpio_data = kzalloc(sizeof(struct timed_gpio_data) * pdata->num_gpios, GFP_KERNEL);
+ gpio_data = kzalloc(sizeof(struct timed_gpio_data) * pdata->num_gpios,
+ GFP_KERNEL);
if (!gpio_data)
return -ENOMEM;
@@ -107,23 +98,26 @@ static int timed_gpio_probe(struct platform_device *pdev)
cur_gpio = &pdata->gpios[i];
gpio_dat = &gpio_data[i];
- hrtimer_init(&gpio_dat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ hrtimer_init(&gpio_dat->timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
gpio_dat->timer.function = gpio_timer_func;
spin_lock_init(&gpio_dat->lock);
+ gpio_dat->dev.name = cur_gpio->name;
+ gpio_dat->dev.get_time = gpio_get_time;
+ gpio_dat->dev.enable = gpio_enable;
+ ret = timed_output_dev_register(&gpio_dat->dev);
+ if (ret < 0) {
+ for (j = 0; j < i; j++)
+ timed_output_dev_unregister(&gpio_data[i].dev);
+ kfree(gpio_data);
+ return ret;
+ }
+
gpio_dat->gpio = cur_gpio->gpio;
gpio_dat->max_timeout = cur_gpio->max_timeout;
gpio_dat->active_low = cur_gpio->active_low;
gpio_direction_output(gpio_dat->gpio, gpio_dat->active_low);
-
- gpio_dat->dev = device_create(timed_gpio_class, &pdev->dev, 0, "%s", cur_gpio->name);
- if (unlikely(IS_ERR(gpio_dat->dev)))
- return PTR_ERR(gpio_dat->dev);
-
- dev_set_drvdata(gpio_dat->dev, gpio_dat);
- ret = device_create_file(gpio_dat->dev, &dev_attr_enable);
- if (ret)
- return ret;
}
platform_set_drvdata(pdev, gpio_data);
@@ -137,10 +131,8 @@ static int timed_gpio_remove(struct platform_device *pdev)
struct timed_gpio_data *gpio_data = platform_get_drvdata(pdev);
int i;
- for (i = 0; i < pdata->num_gpios; i++) {
- device_remove_file(gpio_data[i].dev, &dev_attr_enable);
- device_unregister(gpio_data[i].dev);
- }
+ for (i = 0; i < pdata->num_gpios; i++)
+ timed_output_dev_unregister(&gpio_data[i].dev);
kfree(gpio_data);
@@ -151,22 +143,18 @@ static struct platform_driver timed_gpio_driver = {
.probe = timed_gpio_probe,
.remove = timed_gpio_remove,
.driver = {
- .name = "timed-gpio",
+ .name = TIMED_GPIO_NAME,
.owner = THIS_MODULE,
},
};
static int __init timed_gpio_init(void)
{
- timed_gpio_class = class_create(THIS_MODULE, "timed_output");
- if (IS_ERR(timed_gpio_class))
- return PTR_ERR(timed_gpio_class);
return platform_driver_register(&timed_gpio_driver);
}
static void __exit timed_gpio_exit(void)
{
- class_destroy(timed_gpio_class);
platform_driver_unregister(&timed_gpio_driver);
}
diff --git a/drivers/staging/android/timed_gpio.h b/drivers/staging/android/timed_gpio.h
index 78449b2161cf..a0e15f8be3f7 100644
--- a/drivers/staging/android/timed_gpio.h
+++ b/drivers/staging/android/timed_gpio.h
@@ -16,10 +16,12 @@
#ifndef _LINUX_TIMED_GPIO_H
#define _LINUX_TIMED_GPIO_H
+#define TIMED_GPIO_NAME "timed-gpio"
+
struct timed_gpio {
const char *name;
unsigned gpio;
- int max_timeout;
+ int max_timeout;
u8 active_low;
};
diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
new file mode 100644
index 000000000000..62e79180421b
--- /dev/null
+++ b/drivers/staging/android/timed_output.c
@@ -0,0 +1,121 @@
+/* drivers/misc/timed_output.c
+ *
+ * Copyright (C) 2009 Google, Inc.
+ * Author: Mike Lockwood <lockwood@android.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+
+#include "timed_output.h"
+
+static struct class *timed_output_class;
+static atomic_t device_count;
+
+static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct timed_output_dev *tdev = dev_get_drvdata(dev);
+ int remaining = tdev->get_time(tdev);
+
+ return sprintf(buf, "%d\n", remaining);
+}
+
+static ssize_t enable_store(
+ struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ struct timed_output_dev *tdev = dev_get_drvdata(dev);
+ int value;
+
+ sscanf(buf, "%d", &value);
+ tdev->enable(tdev, value);
+
+ return size;
+}
+
+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store);
+
+static int create_timed_output_class(void)
+{
+ if (!timed_output_class) {
+ timed_output_class = class_create(THIS_MODULE, "timed_output");
+ if (IS_ERR(timed_output_class))
+ return PTR_ERR(timed_output_class);
+ atomic_set(&device_count, 0);
+ }
+
+ return 0;
+}
+
+int timed_output_dev_register(struct timed_output_dev *tdev)
+{
+ int ret;
+
+ if (!tdev || !tdev->name || !tdev->enable || !tdev->get_time)
+ return -EINVAL;
+
+ ret = create_timed_output_class();
+ if (ret < 0)
+ return ret;
+
+ tdev->index = atomic_inc_return(&device_count);
+ tdev->dev = device_create(timed_output_class, NULL,
+ MKDEV(0, tdev->index), NULL, tdev->name);
+ if (IS_ERR(tdev->dev))
+ return PTR_ERR(tdev->dev);
+
+ ret = device_create_file(tdev->dev, &dev_attr_enable);
+ if (ret < 0)
+ goto err_create_file;
+
+ dev_set_drvdata(tdev->dev, tdev);
+ tdev->state = 0;
+ return 0;
+
+err_create_file:
+ device_destroy(timed_output_class, MKDEV(0, tdev->index));
+ printk(KERN_ERR "timed_output: Failed to register driver %s\n",
+ tdev->name);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(timed_output_dev_register);
+
+void timed_output_dev_unregister(struct timed_output_dev *tdev)
+{
+ device_remove_file(tdev->dev, &dev_attr_enable);
+ device_destroy(timed_output_class, MKDEV(0, tdev->index));
+ dev_set_drvdata(tdev->dev, NULL);
+}
+EXPORT_SYMBOL_GPL(timed_output_dev_unregister);
+
+static int __init timed_output_init(void)
+{
+ return create_timed_output_class();
+}
+
+static void __exit timed_output_exit(void)
+{
+ class_destroy(timed_output_class);
+}
+
+module_init(timed_output_init);
+module_exit(timed_output_exit);
+
+MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
+MODULE_DESCRIPTION("timed output class driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/android/timed_output.h b/drivers/staging/android/timed_output.h
new file mode 100644
index 000000000000..ec907ab2ff54
--- /dev/null
+++ b/drivers/staging/android/timed_output.h
@@ -0,0 +1,37 @@
+/* include/linux/timed_output.h
+ *
+ * Copyright (C) 2008 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+*/
+
+#ifndef _LINUX_TIMED_OUTPUT_H
+#define _LINUX_TIMED_OUTPUT_H
+
+struct timed_output_dev {
+ const char *name;
+
+ /* enable the output and set the timer */
+ void (*enable)(struct timed_output_dev *sdev, int timeout);
+
+ /* returns the current number of milliseconds remaining on the timer */
+ int (*get_time)(struct timed_output_dev *sdev);
+
+ /* private data */
+ struct device *dev;
+ int index;
+ int state;
+};
+
+extern int timed_output_dev_register(struct timed_output_dev *dev);
+extern void timed_output_dev_unregister(struct timed_output_dev *dev);
+
+#endif
diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
index 75ebe338c6f2..ddade6c486ba 100644
--- a/drivers/staging/b3dfg/b3dfg.c
+++ b/drivers/staging/b3dfg/b3dfg.c
@@ -35,7 +35,6 @@
#include <linux/poll.h>
#include <linux/wait.h>
#include <linux/mm.h>
-#include <linux/version.h>
#include <linux/uaccess.h>
static unsigned int b3dfg_nbuf = 2;
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 2d819d278b0e..86991f657900 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -13,13 +13,6 @@ config COMEDI_DEBUG
This is an option for use by developers; most people should
say N here. This enables comedi core and driver debugging.
-config COMEDI_RT
- tristate "Comedi Real-time support"
- depends on COMEDI && RT
- default N
- ---help---
- Enable Real time support for the Comedi core.
-
config COMEDI_PCI_DRIVERS
tristate "Comedi PCI drivers"
depends on COMEDI && PCI
@@ -29,7 +22,7 @@ config COMEDI_PCI_DRIVERS
config COMEDI_PCMCIA_DRIVERS
tristate "Comedi PCMCIA drivers"
- depends on COMEDI && PCMCIAI
+ depends on COMEDI && PCMCIA
default N
---help---
Enable lots of comedi PCMCIA drivers to be built
diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile
index afd1a19c1b87..05811f79d85b 100644
--- a/drivers/staging/comedi/Makefile
+++ b/drivers/staging/comedi/Makefile
@@ -1,5 +1,4 @@
obj-$(CONFIG_COMEDI) += comedi.o
-obj-$(CONFIG_COMEDI_RT) += comedi_rt.o
obj-$(CONFIG_COMEDI) += kcomedilib/
obj-$(CONFIG_COMEDI) += drivers/
@@ -11,7 +10,3 @@ comedi-objs := \
drivers.o \
comedi_compat32.o \
comedi_ksyms.o \
-
-comedi_rt-objs := \
- rt_pend_tq.o \
- rt.o
diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index e6b5f16edb02..8101cea84528 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -188,7 +188,6 @@ extern "C" {
#define SDF_WRITABLE 0x00020000 /* subdevice can be written (e.g. analog output) */
#define SDF_WRITEABLE SDF_WRITABLE /* spelling error in API */
#define SDF_INTERNAL 0x00040000 /* subdevice does not have externally visible lines */
-#define SDF_RT 0x00080000 /* DEPRECATED: subdevice is RT capable */
#define SDF_GROUND 0x00100000 /* can do aref=ground */
#define SDF_COMMON 0x00200000 /* can do aref=common */
#define SDF_DIFF 0x00400000 /* can do aref=diff */
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 19dce2ebfc19..9d7c99394ec6 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -44,6 +44,7 @@
#include <linux/fs.h>
#include "comedidev.h"
#include <linux/cdev.h>
+#include <linux/stat.h>
#include <linux/io.h>
#include <linux/uaccess.h>
@@ -92,6 +93,15 @@ static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int comedi_fasync(int fd, struct file *file, int on);
static int is_device_busy(struct comedi_device *dev);
+static int resize_async_buffer(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_async *async, unsigned new_size);
+
+/* declarations for sysfs attribute files */
+static struct device_attribute dev_attr_max_read_buffer_kb;
+static struct device_attribute dev_attr_read_buffer_kb;
+static struct device_attribute dev_attr_max_write_buffer_kb;
+static struct device_attribute dev_attr_write_buffer_kb;
#ifdef HAVE_UNLOCKED_IOCTL
static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
@@ -277,7 +287,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg)
struct comedi_bufconfig bc;
struct comedi_async *async;
struct comedi_subdevice *s;
- int ret = 0;
+ int retval = 0;
if (copy_from_user(&bc, arg, sizeof(struct comedi_bufconfig)))
return -EFAULT;
@@ -303,37 +313,9 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg)
}
if (bc.size) {
- if (bc.size > async->max_bufsize)
- return -EPERM;
-
- if (s->busy) {
- DPRINTK("subdevice is busy, cannot resize buffer\n");
- return -EBUSY;
- }
- if (async->mmap_count) {
- DPRINTK("subdevice is mmapped, cannot resize buffer\n");
- return -EBUSY;
- }
-
- if (!async->prealloc_buf)
- return -EINVAL;
-
- /* make sure buffer is an integral number of pages
- * (we round up) */
- bc.size = (bc.size + PAGE_SIZE - 1) & PAGE_MASK;
-
- ret = comedi_buf_alloc(dev, s, bc.size);
- if (ret < 0)
- return ret;
-
- if (s->buf_change) {
- ret = s->buf_change(dev, s, bc.size);
- if (ret < 0)
- return ret;
- }
-
- DPRINTK("comedi%i subd %d buffer resized to %i bytes\n",
- dev->minor, bc.subdevice, async->prealloc_bufsz);
+ retval = resize_async_buffer(dev, s, async, bc.size);
+ if (retval < 0)
+ return retval;
}
bc.size = async->prealloc_bufsz;
@@ -746,7 +728,7 @@ static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data
/* by default we allow the insn since we don't have checks for
* all possible cases yet */
default:
- rt_printk("comedi: no check for data length of config insn id "
+ printk("comedi: no check for data length of config insn id "
"%i is implemented.\n"
" Add a check to %s in %s.\n"
" Assuming n=%i is correct.\n", data[0], __func__,
@@ -1097,13 +1079,6 @@ static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file)
comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING);
-#ifdef CONFIG_COMEDI_RT
- if (async->cmd.flags & TRIG_RT) {
- if (comedi_switch_to_rt(dev) == 0)
- comedi_set_subdevice_runflags(s, SRF_RT, SRF_RT);
- }
-#endif
-
ret = s->do_cmd(dev, s);
if (ret == 0)
return 0;
@@ -1237,12 +1212,12 @@ static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file
return -EINVAL;
s = dev->subdevices + arg;
- comedi_spin_lock_irqsave(&s->spin_lock, flags);
+ spin_lock_irqsave(&s->spin_lock, flags);
if (s->busy || s->lock)
ret = -EBUSY;
else
s->lock = file;
- comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
+ spin_unlock_irqrestore(&s->spin_lock, flags);
if (ret < 0)
return ret;
@@ -1738,12 +1713,6 @@ void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s)
struct comedi_async *async = s->async;
comedi_set_subdevice_runflags(s, SRF_RUNNING, 0);
-#ifdef CONFIG_COMEDI_RT
- if (comedi_get_subdevice_runflags(s) & SRF_RT) {
- comedi_switch_to_non_rt(dev);
- comedi_set_subdevice_runflags(s, SRF_RT, 0);
- }
-#endif
if (async) {
comedi_reset_async_buf(async);
async->inttrig = NULL;
@@ -1970,8 +1939,6 @@ static int __init comedi_init(void)
}
}
- comedi_rt_init();
-
comedi_register_ioctl32();
return 0;
@@ -1992,8 +1959,6 @@ static void __exit comedi_cleanup(void)
comedi_proc_cleanup();
- comedi_rt_cleanup();
-
comedi_unregister_ioctl32();
}
@@ -2002,8 +1967,7 @@ module_exit(comedi_cleanup);
void comedi_error(const struct comedi_device *dev, const char *s)
{
- rt_printk("comedi%d: %s: %s\n", dev->minor, dev->driver->driver_name,
- s);
+ printk("comedi%d: %s: %s\n", dev->minor, dev->driver->driver_name, s);
}
void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -2034,34 +1998,18 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
if (async->cb_mask & s->async->events) {
if (comedi_get_subdevice_runflags(s) & SRF_USER) {
-
- if (dev->rt) {
-#ifdef CONFIG_COMEDI_RT
- /* pend wake up */
- comedi_rt_pend_wakeup(&async->wait_head);
-#else
- printk
- ("BUG: comedi_event() code unreachable\n");
-#endif
- } else {
- wake_up_interruptible(&async->wait_head);
- if (s->subdev_flags & SDF_CMD_READ) {
- kill_fasync(&dev->async_queue, SIGIO,
- POLL_IN);
- }
- if (s->subdev_flags & SDF_CMD_WRITE) {
- kill_fasync(&dev->async_queue, SIGIO,
- POLL_OUT);
- }
+ wake_up_interruptible(&async->wait_head);
+ if (s->subdev_flags & SDF_CMD_READ) {
+ kill_fasync(&dev->async_queue, SIGIO,
+ POLL_IN);
+ }
+ if (s->subdev_flags & SDF_CMD_WRITE) {
+ kill_fasync(&dev->async_queue, SIGIO,
+ POLL_OUT);
}
} else {
if (async->cb_func)
async->cb_func(s->async->events, async->cb_arg);
- /* XXX bug here. If subdevice A is rt, and
- * subdevice B tries to callback to a normal
- * linux kernel function, it will be at the
- * wrong priority. Since this isn't very
- * common, I'm not going to worry about it. */
}
}
s->async->events = 0;
@@ -2072,10 +2020,10 @@ void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask,
{
unsigned long flags;
- comedi_spin_lock_irqsave(&s->spin_lock, flags);
+ spin_lock_irqsave(&s->spin_lock, flags);
s->runflags &= ~mask;
s->runflags |= (bits & mask);
- comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
+ spin_unlock_irqrestore(&s->spin_lock, flags);
}
unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s)
@@ -2083,9 +2031,9 @@ unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s)
unsigned long flags;
unsigned runflags;
- comedi_spin_lock_irqsave(&s->spin_lock, flags);
+ spin_lock_irqsave(&s->spin_lock, flags);
runflags = s->runflags;
- comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
+ spin_unlock_irqrestore(&s->spin_lock, flags);
return runflags;
}
@@ -2132,6 +2080,7 @@ int comedi_alloc_board_minor(struct device *hardware_device)
struct comedi_device_file_info *info;
struct device *csdev;
unsigned i;
+ int retval;
info = kzalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL);
if (info == NULL)
@@ -2142,20 +2091,19 @@ int comedi_alloc_board_minor(struct device *hardware_device)
return -ENOMEM;
}
comedi_device_init(info->device);
- comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock_irqsave(&comedi_file_info_table_lock, flags);
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
}
}
- comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
if (i == COMEDI_NUM_BOARD_MINORS) {
comedi_device_cleanup(info->device);
kfree(info->device);
kfree(info);
- rt_printk
- ("comedi: error: ran out of minor numbers for board device files.\n");
+ printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n");
return -EBUSY;
}
info->device->minor = i;
@@ -2164,7 +2112,35 @@ int comedi_alloc_board_minor(struct device *hardware_device)
hardware_device, "comedi%i", i);
if (!IS_ERR(csdev))
info->device->class_dev = csdev;
-
+ dev_set_drvdata(csdev, info);
+ retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_max_read_buffer_kb.attr.name);
+ comedi_free_board_minor(i);
+ return retval;
+ }
+ retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_read_buffer_kb.attr.name);
+ comedi_free_board_minor(i);
+ return retval;
+ }
+ retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_max_write_buffer_kb.attr.name);
+ comedi_free_board_minor(i);
+ return retval;
+ }
+ retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_write_buffer_kb.attr.name);
+ comedi_free_board_minor(i);
+ return retval;
+ }
return i;
}
@@ -2174,10 +2150,10 @@ void comedi_free_board_minor(unsigned minor)
struct comedi_device_file_info *info;
BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
- comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock_irqsave(&comedi_file_info_table_lock, flags);
info = comedi_file_info_table[minor];
comedi_file_info_table[minor] = NULL;
- comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
if (info) {
struct comedi_device *dev = info->device;
@@ -2193,12 +2169,14 @@ void comedi_free_board_minor(unsigned minor)
}
}
-int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdevice *s)
+int comedi_alloc_subdevice_minor(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned long flags;
struct comedi_device_file_info *info;
struct device *csdev;
unsigned i;
+ int retval;
info = kmalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL);
if (info == NULL)
@@ -2206,18 +2184,17 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdev
info->device = dev;
info->read_subdevice = s;
info->write_subdevice = s;
- comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock_irqsave(&comedi_file_info_table_lock, flags);
for (i = COMEDI_FIRST_SUBDEVICE_MINOR; i < COMEDI_NUM_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
}
}
- comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
if (i == COMEDI_NUM_MINORS) {
kfree(info);
- rt_printk
- ("comedi: error: ran out of minor numbers for board device files.\n");
+ printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n");
return -EBUSY;
}
s->minor = i;
@@ -2227,7 +2204,35 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdev
(int)(s - dev->subdevices));
if (!IS_ERR(csdev))
s->class_dev = csdev;
-
+ dev_set_drvdata(csdev, info);
+ retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_max_read_buffer_kb.attr.name);
+ comedi_free_subdevice_minor(s);
+ return retval;
+ }
+ retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_read_buffer_kb.attr.name);
+ comedi_free_subdevice_minor(s);
+ return retval;
+ }
+ retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_max_write_buffer_kb.attr.name);
+ comedi_free_subdevice_minor(s);
+ return retval;
+ }
+ retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
+ if (retval) {
+ printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
+ dev_attr_write_buffer_kb.attr.name);
+ comedi_free_subdevice_minor(s);
+ return retval;
+ }
return i;
}
@@ -2244,10 +2249,10 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
BUG_ON(s->minor >= COMEDI_NUM_MINORS);
BUG_ON(s->minor < COMEDI_FIRST_SUBDEVICE_MINOR);
- comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock_irqsave(&comedi_file_info_table_lock, flags);
info = comedi_file_info_table[s->minor];
comedi_file_info_table[s->minor] = NULL;
- comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
if (s->class_dev) {
device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, s->minor));
@@ -2262,8 +2267,309 @@ struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor)
struct comedi_device_file_info *info;
BUG_ON(minor >= COMEDI_NUM_MINORS);
- comedi_spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock_irqsave(&comedi_file_info_table_lock, flags);
info = comedi_file_info_table[minor];
- comedi_spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
return info;
}
+
+static int resize_async_buffer(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_async *async, unsigned new_size)
+{
+ int retval;
+
+ if (new_size > async->max_bufsize)
+ return -EPERM;
+
+ if (s->busy) {
+ DPRINTK("subdevice is busy, cannot resize buffer\n");
+ return -EBUSY;
+ }
+ if (async->mmap_count) {
+ DPRINTK("subdevice is mmapped, cannot resize buffer\n");
+ return -EBUSY;
+ }
+
+ if (!async->prealloc_buf)
+ return -EINVAL;
+
+ /* make sure buffer is an integral number of pages
+ * (we round up) */
+ new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
+
+ retval = comedi_buf_alloc(dev, s, new_size);
+ if (retval < 0)
+ return retval;
+
+ if (s->buf_change) {
+ retval = s->buf_change(dev, s, new_size);
+ if (retval < 0)
+ return retval;
+ }
+
+ DPRINTK("comedi%i subd %d buffer resized to %i bytes\n",
+ dev->minor, s - dev->subdevices, async->prealloc_bufsz);
+ return 0;
+}
+
+/* sysfs attribute files */
+
+static const unsigned bytes_per_kibi = 1024;
+
+static ssize_t show_max_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t retval;
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned max_buffer_size_kb = 0;
+ struct comedi_subdevice *const read_subdevice =
+ comedi_get_read_subdevice(info);
+
+ mutex_lock(&info->device->mutex);
+ if (read_subdevice &&
+ (read_subdevice->subdev_flags & SDF_CMD_READ) &&
+ read_subdevice->async) {
+ max_buffer_size_kb = read_subdevice->async->max_bufsize /
+ bytes_per_kibi;
+ }
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
+ mutex_unlock(&info->device->mutex);
+
+ return retval;
+}
+
+static ssize_t store_max_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned long new_max_size_kb;
+ uint64_t new_max_size;
+ struct comedi_subdevice *const read_subdevice =
+ comedi_get_read_subdevice(info);
+
+ if (strict_strtoul(buf, 10, &new_max_size_kb))
+ return -EINVAL;
+ if (new_max_size_kb != (uint32_t)new_max_size_kb)
+ return -EINVAL;
+ new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi;
+ if (new_max_size != (uint32_t)new_max_size)
+ return -EINVAL;
+
+ mutex_lock(&info->device->mutex);
+ if (read_subdevice == NULL ||
+ (read_subdevice->subdev_flags & SDF_CMD_READ) == 0 ||
+ read_subdevice->async == NULL) {
+ mutex_unlock(&info->device->mutex);
+ return -EINVAL;
+ }
+ read_subdevice->async->max_bufsize = new_max_size;
+ mutex_unlock(&info->device->mutex);
+
+ return count;
+}
+
+static struct device_attribute dev_attr_max_read_buffer_kb = {
+ .attr = {
+ .name = "max_read_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR
+ },
+ .show = &show_max_read_buffer_kb,
+ .store = &store_max_read_buffer_kb
+};
+
+static ssize_t show_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t retval;
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned buffer_size_kb = 0;
+ struct comedi_subdevice *const read_subdevice =
+ comedi_get_read_subdevice(info);
+
+ mutex_lock(&info->device->mutex);
+ if (read_subdevice &&
+ (read_subdevice->subdev_flags & SDF_CMD_READ) &&
+ read_subdevice->async) {
+ buffer_size_kb = read_subdevice->async->prealloc_bufsz /
+ bytes_per_kibi;
+ }
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
+ mutex_unlock(&info->device->mutex);
+
+ return retval;
+}
+
+static ssize_t store_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned long new_size_kb;
+ uint64_t new_size;
+ int retval;
+ struct comedi_subdevice *const read_subdevice =
+ comedi_get_read_subdevice(info);
+
+ if (strict_strtoul(buf, 10, &new_size_kb))
+ return -EINVAL;
+ if (new_size_kb != (uint32_t)new_size_kb)
+ return -EINVAL;
+ new_size = ((uint64_t)new_size_kb) * bytes_per_kibi;
+ if (new_size != (uint32_t)new_size)
+ return -EINVAL;
+
+ mutex_lock(&info->device->mutex);
+ if (read_subdevice == NULL ||
+ (read_subdevice->subdev_flags & SDF_CMD_READ) == 0 ||
+ read_subdevice->async == NULL) {
+ mutex_unlock(&info->device->mutex);
+ return -EINVAL;
+ }
+ retval = resize_async_buffer(info->device, read_subdevice,
+ read_subdevice->async, new_size);
+ mutex_unlock(&info->device->mutex);
+
+ if (retval < 0)
+ return retval;
+ return count;
+}
+
+static struct device_attribute dev_attr_read_buffer_kb = {
+ .attr = {
+ .name = "read_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR | S_IWGRP
+ },
+ .show = &show_read_buffer_kb,
+ .store = &store_read_buffer_kb
+};
+
+static ssize_t show_max_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ ssize_t retval;
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned max_buffer_size_kb = 0;
+ struct comedi_subdevice *const write_subdevice =
+ comedi_get_write_subdevice(info);
+
+ mutex_lock(&info->device->mutex);
+ if (write_subdevice &&
+ (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
+ write_subdevice->async) {
+ max_buffer_size_kb = write_subdevice->async->max_bufsize /
+ bytes_per_kibi;
+ }
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
+ mutex_unlock(&info->device->mutex);
+
+ return retval;
+}
+
+static ssize_t store_max_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned long new_max_size_kb;
+ uint64_t new_max_size;
+ struct comedi_subdevice *const write_subdevice =
+ comedi_get_write_subdevice(info);
+
+ if (strict_strtoul(buf, 10, &new_max_size_kb))
+ return -EINVAL;
+ if (new_max_size_kb != (uint32_t)new_max_size_kb)
+ return -EINVAL;
+ new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi;
+ if (new_max_size != (uint32_t)new_max_size)
+ return -EINVAL;
+
+ mutex_lock(&info->device->mutex);
+ if (write_subdevice == NULL ||
+ (write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 ||
+ write_subdevice->async == NULL) {
+ mutex_unlock(&info->device->mutex);
+ return -EINVAL;
+ }
+ write_subdevice->async->max_bufsize = new_max_size;
+ mutex_unlock(&info->device->mutex);
+
+ return count;
+}
+
+static struct device_attribute dev_attr_max_write_buffer_kb = {
+ .attr = {
+ .name = "max_write_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR
+ },
+ .show = &show_max_write_buffer_kb,
+ .store = &store_max_write_buffer_kb
+};
+
+static ssize_t show_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t retval;
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned buffer_size_kb = 0;
+ struct comedi_subdevice *const write_subdevice =
+ comedi_get_write_subdevice(info);
+
+ mutex_lock(&info->device->mutex);
+ if (write_subdevice &&
+ (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
+ write_subdevice->async) {
+ buffer_size_kb = write_subdevice->async->prealloc_bufsz /
+ bytes_per_kibi;
+ }
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
+ mutex_unlock(&info->device->mutex);
+
+ return retval;
+}
+
+static ssize_t store_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ unsigned long new_size_kb;
+ uint64_t new_size;
+ int retval;
+ struct comedi_subdevice *const write_subdevice =
+ comedi_get_write_subdevice(info);
+
+ if (strict_strtoul(buf, 10, &new_size_kb))
+ return -EINVAL;
+ if (new_size_kb != (uint32_t)new_size_kb)
+ return -EINVAL;
+ new_size = ((uint64_t)new_size_kb) * bytes_per_kibi;
+ if (new_size != (uint32_t)new_size)
+ return -EINVAL;
+
+ mutex_lock(&info->device->mutex);
+ if (write_subdevice == NULL ||
+ (write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 ||
+ write_subdevice->async == NULL) {
+ mutex_unlock(&info->device->mutex);
+ return -EINVAL;
+ }
+ retval = resize_async_buffer(info->device, write_subdevice,
+ write_subdevice->async, new_size);
+ mutex_unlock(&info->device->mutex);
+
+ if (retval < 0)
+ return retval;
+ return count;
+}
+
+static struct device_attribute dev_attr_write_buffer_kb = {
+ .attr = {
+ .name = "write_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR | S_IWGRP
+ },
+ .show = &show_write_buffer_kb,
+ .store = &store_write_buffer_kb
+};
diff --git a/drivers/staging/comedi/comedi_ksyms.c b/drivers/staging/comedi/comedi_ksyms.c
index 6e6fb979ef54..a732e342dcd2 100644
--- a/drivers/staging/comedi/comedi_ksyms.c
+++ b/drivers/staging/comedi/comedi_ksyms.c
@@ -46,13 +46,6 @@ EXPORT_SYMBOL(range_bipolar2_5);
EXPORT_SYMBOL(range_unipolar10);
EXPORT_SYMBOL(range_unipolar5);
EXPORT_SYMBOL(range_unknown);
-#ifdef CONFIG_COMEDI_RT
-EXPORT_SYMBOL(comedi_free_irq);
-EXPORT_SYMBOL(comedi_request_irq);
-EXPORT_SYMBOL(comedi_switch_to_rt);
-EXPORT_SYMBOL(comedi_switch_to_non_rt);
-EXPORT_SYMBOL(rt_pend_call);
-#endif
#ifdef CONFIG_COMEDI_DEBUG
EXPORT_SYMBOL(comedi_debug);
#endif
diff --git a/drivers/staging/comedi/comedi_rt.h b/drivers/staging/comedi/comedi_rt.h
deleted file mode 100644
index 169ca963312a..000000000000
--- a/drivers/staging/comedi/comedi_rt.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- module/comedi_rt.h
- header file for real-time structures, variables, and constants
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef _COMEDI_RT_H
-#define _COMEDI_RT_H
-
-#ifndef _COMEDIDEV_H
-#error comedi_rt.h should only be included by comedidev.h
-#endif
-
-#include <linux/kdev_t.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/spinlock.h>
-#include <linux/delay.h>
-
-#ifdef CONFIG_COMEDI_RT
-
-#ifdef CONFIG_COMEDI_RTAI
-#include <rtai.h>
-#include <rtai_sched.h>
-#include <rtai_version.h>
-#endif
-#ifdef CONFIG_COMEDI_RTL
-#include <rtl_core.h>
-#include <rtl_time.h>
-/* #ifdef RTLINUX_VERSION_CODE */
-#include <rtl_sync.h>
-/* #endif */
-#define rt_printk rtl_printf
-#endif
-#ifdef CONFIG_COMEDI_FUSION
-#define rt_printk(format, args...) printk(format , ## args)
-#endif /* CONFIG_COMEDI_FUSION */
-#ifdef CONFIG_PRIORITY_IRQ
-#define rt_printk printk
-#endif
-
-int comedi_request_irq(unsigned int irq, irqreturn_t(*handler) (int,
- void *PT_REGS_ARG), unsigned long flags, const char *device,
- struct comedi_device *dev_id);
-void comedi_free_irq(unsigned int irq, struct comedi_device *dev_id);
-void comedi_rt_init(void);
-void comedi_rt_cleanup(void);
-int comedi_switch_to_rt(struct comedi_device *dev);
-void comedi_switch_to_non_rt(struct comedi_device *dev);
-void comedi_rt_pend_wakeup(wait_queue_head_t *q);
-extern int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1,
- void *arg2);
-
-#else
-
-#define comedi_request_irq(a, b, c, d, e) request_irq(a, b, c, d, e)
-#define comedi_free_irq(a, b) free_irq(a, b)
-#define comedi_rt_init() do {} while (0)
-#define comedi_rt_cleanup() do {} while (0)
-#define comedi_switch_to_rt(a) (-1)
-#define comedi_switch_to_non_rt(a) do {} while (0)
-#define comedi_rt_pend_wakeup(a) do {} while (0)
-
-#define rt_printk(format, args...) printk(format, ##args)
-
-#endif
-
-/* Define a spin_lock_irqsave function that will work with rt or without.
- * Use inline functions instead of just macros to enforce some type checking.
- */
-#define comedi_spin_lock_irqsave(lock_ptr, flags) \
- (flags = __comedi_spin_lock_irqsave(lock_ptr))
-
-static inline unsigned long __comedi_spin_lock_irqsave(spinlock_t *lock_ptr)
-{
- unsigned long flags;
-
-#if defined(CONFIG_COMEDI_RTAI)
- flags = rt_spin_lock_irqsave(lock_ptr);
-
-#elif defined(CONFIG_COMEDI_RTL)
- rtl_spin_lock_irqsave(lock_ptr, flags);
-
-#elif defined(CONFIG_COMEDI_RTL_V1)
- rtl_spin_lock_irqsave(lock_ptr, flags);
-
-#elif defined(CONFIG_COMEDI_FUSION)
- rthal_spin_lock_irqsave(lock_ptr, flags);
-#else
- spin_lock_irqsave(lock_ptr, flags);
-
-#endif
-
- return flags;
-}
-
-static inline void comedi_spin_unlock_irqrestore(spinlock_t *lock_ptr,
- unsigned long flags)
-{
-
-#if defined(CONFIG_COMEDI_RTAI)
- rt_spin_unlock_irqrestore(flags, lock_ptr);
-
-#elif defined(CONFIG_COMEDI_RTL)
- rtl_spin_unlock_irqrestore(lock_ptr, flags);
-
-#elif defined(CONFIG_COMEDI_RTL_V1)
- rtl_spin_unlock_irqrestore(lock_ptr, flags);
-#elif defined(CONFIG_COMEDI_FUSION)
- rthal_spin_unlock_irqrestore(lock_ptr, flags);
-#else
- spin_unlock_irqrestore(lock_ptr, flags);
-
-#endif
-
-}
-
-/* define a RT safe udelay */
-static inline void comedi_udelay(unsigned int usec)
-{
-#if defined(CONFIG_COMEDI_RTAI)
- static const int nanosec_per_usec = 1000;
- rt_busy_sleep(usec * nanosec_per_usec);
-#elif defined(CONFIG_COMEDI_RTL)
- static const int nanosec_per_usec = 1000;
- rtl_delay(usec * nanosec_per_usec);
-#else
- udelay(usec);
-#endif
-}
-
-#endif
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index ea319360ae68..7a1ccde83589 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -35,7 +35,6 @@
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
-#include "interrupt.h"
#include <linux/dma-mapping.h>
#include <linux/uaccess.h>
#include <linux/io.h>
@@ -264,7 +263,6 @@ struct comedi_device {
const char *board_name;
const void *board_ptr;
int attached;
- int rt;
spinlock_t spinlock;
struct mutex mutex;
int in_request_module;
@@ -524,6 +522,17 @@ struct usb_device; /* forward declaration */
int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name);
void comedi_usb_auto_unconfig(struct usb_device *usbdev);
-#include "comedi_rt.h"
+#ifdef CONFIG_COMEDI_PCI_DRIVERS
+ #define CONFIG_COMEDI_PCI
+#endif
+#ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE
+ #define CONFIG_COMEDI_PCI
+#endif
+#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
+ #define CONFIG_COMEDI_PCMCIA
+#endif
+#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE
+ #define CONFIG_COMEDI_PCMCIA
+#endif
#endif /* _COMEDIDEV_H */
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 6e13e450dc73..42a02571ff1b 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -198,7 +198,7 @@ int comedi_driver_unregister(struct comedi_driver *driver)
struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(i);
struct comedi_device *dev;
- if(dev_file_info == NULL) continue;
+ if (dev_file_info == NULL) continue;
dev = dev_file_info->device;
mutex_lock(&dev->mutex);
@@ -554,7 +554,7 @@ unsigned int comedi_buf_munge(struct comedi_async *async, unsigned int num_bytes
block_size = num_bytes - count;
if (block_size < 0) {
- rt_printk("%s: %s: bug! block_size is negative\n",
+ printk("%s: %s: bug! block_size is negative\n",
__FILE__, __func__);
break;
}
@@ -633,8 +633,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
{
if ((int)(async->buf_write_count + nbytes -
async->buf_write_alloc_count) > 0) {
- rt_printk
- ("comedi: attempted to write-free more bytes than have been write-allocated.\n");
+ printk("comedi: attempted to write-free more bytes than have been write-allocated.\n");
nbytes = async->buf_write_alloc_count - async->buf_write_count;
}
async->buf_write_count += nbytes;
@@ -667,8 +666,7 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
smp_mb();
if ((int)(async->buf_read_count + nbytes -
async->buf_read_alloc_count) > 0) {
- rt_printk
- ("comedi: attempted to read-free more bytes than have been read-allocated.\n");
+ printk("comedi: attempted to read-free more bytes than have been read-allocated.\n");
nbytes = async->buf_read_alloc_count - async->buf_read_count;
}
async->buf_read_count += nbytes;
@@ -801,7 +799,7 @@ int comedi_auto_config(struct device *hardware_device, const char *board_name, c
}
minor = comedi_alloc_board_minor(hardware_device);
- if(minor < 0) return minor;
+ if (minor < 0) return minor;
private_data = kmalloc(sizeof(unsigned), GFP_KERNEL);
if (private_data == NULL) {
@@ -824,7 +822,7 @@ int comedi_auto_config(struct device *hardware_device, const char *board_name, c
mutex_unlock(&dev_file_info->device->mutex);
cleanup:
- if(retval < 0)
+ if (retval < 0)
{
kfree(private_data);
comedi_free_board_minor(minor);
@@ -835,7 +833,7 @@ cleanup:
void comedi_auto_unconfig(struct device *hardware_device)
{
unsigned *minor = (unsigned *)dev_get_drvdata(hardware_device);
- if(minor == NULL) return;
+ if (minor == NULL) return;
BUG_ON(*minor >= COMEDI_NUM_BOARD_MINORS);
@@ -853,7 +851,8 @@ int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name)
/* pci slot */
options[1] = PCI_SLOT(pcidev->devfn);
- return comedi_auto_config(&pcidev->dev, board_name, options, sizeof(options) / sizeof(options[0]));
+ return comedi_auto_config(&pcidev->dev, board_name,
+ options, ARRAY_SIZE(options));
}
void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h
index 08a11a5a16e6..ad467ac290a3 100644
--- a/drivers/staging/comedi/drivers/8253.h
+++ b/drivers/staging/comedi/drivers/8253.h
@@ -24,11 +24,7 @@
#ifndef _8253_H
#define _8253_H
-#ifndef CMDTEST
-#include "../comedi.h"
-#else
#include "../comedi.h"
-#endif
#define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div
@@ -205,7 +201,7 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
}
*nanosec = div1 * div2 * i8253_osc_base;
- *d1 = div1 & 0xffff; // masking is done since counter maps zero to 0x10000
+ *d1 = div1 & 0xffff; /* masking is done since counter maps zero to 0x10000 */
*d2 = div2 & 0xffff;
return;
}
@@ -247,12 +243,12 @@ static inline int i8254_load(unsigned long base_address, unsigned int regshift,
return -1;
byte = counter_number << 6;
- byte |= 0x30; // load low then high byte
- byte |= (mode << 1); // set counter mode
+ byte |= 0x30; /* load low then high byte */
+ byte |= (mode << 1); /* set counter mode */
outb(byte, base_address + (i8254_control_reg << regshift));
- byte = count & 0xff; // lsb of counter value
+ byte = count & 0xff; /* lsb of counter value */
outb(byte, base_address + (counter_number << regshift));
- byte = (count >> 8) & 0xff; // msb of counter value
+ byte = (count >> 8) & 0xff; /* msb of counter value */
outb(byte, base_address + (counter_number << regshift));
return 0;
@@ -273,12 +269,12 @@ static inline int i8254_mm_load(void *base_address, unsigned int regshift,
return -1;
byte = counter_number << 6;
- byte |= 0x30; // load low then high byte
- byte |= (mode << 1); // set counter mode
+ byte |= 0x30; /* load low then high byte */
+ byte |= (mode << 1); /* set counter mode */
writeb(byte, base_address + (i8254_control_reg << regshift));
- byte = count & 0xff; // lsb of counter value
+ byte = count & 0xff; /* lsb of counter value */
writeb(byte, base_address + (counter_number << regshift));
- byte = (count >> 8) & 0xff; // msb of counter value
+ byte = (count >> 8) & 0xff; /* msb of counter value */
writeb(byte, base_address + (counter_number << regshift));
return 0;
@@ -294,13 +290,13 @@ static inline int i8254_read(unsigned long base_address, unsigned int regshift,
if (counter_number > 2)
return -1;
- // latch counter
+ /* latch counter */
byte = counter_number << 6;
outb(byte, base_address + (i8254_control_reg << regshift));
- // read lsb
+ /* read lsb */
ret = inb(base_address + (counter_number << regshift));
- // read msb
+ /* read msb */
ret += inb(base_address + (counter_number << regshift)) << 8;
return ret;
@@ -315,13 +311,13 @@ static inline int i8254_mm_read(void *base_address, unsigned int regshift,
if (counter_number > 2)
return -1;
- // latch counter
+ /* latch counter */
byte = counter_number << 6;
writeb(byte, base_address + (i8254_control_reg << regshift));
- // read lsb
+ /* read lsb */
ret = readb(base_address + (counter_number << regshift));
- // read msb
+ /* read msb */
ret += readb(base_address + (counter_number << regshift)) << 8;
return ret;
@@ -336,9 +332,9 @@ static inline void i8254_write(unsigned long base_address,
if (counter_number > 2)
return;
- byte = count & 0xff; // lsb of counter value
+ byte = count & 0xff; /* lsb of counter value */
outb(byte, base_address + (counter_number << regshift));
- byte = (count >> 8) & 0xff; // msb of counter value
+ byte = (count >> 8) & 0xff; /* msb of counter value */
outb(byte, base_address + (counter_number << regshift));
}
@@ -350,9 +346,9 @@ static inline void i8254_mm_write(void *base_address,
if (counter_number > 2)
return;
- byte = count & 0xff; // lsb of counter value
+ byte = count & 0xff; /* lsb of counter value */
writeb(byte, base_address + (counter_number << regshift));
- byte = (count >> 8) & 0xff; // msb of counter value
+ byte = (count >> 8) & 0xff; /* msb of counter value */
writeb(byte, base_address + (counter_number << regshift));
}
@@ -374,8 +370,8 @@ static inline int i8254_set_mode(unsigned long base_address,
return -1;
byte = counter_number << 6;
- byte |= 0x30; // load low then high byte
- byte |= mode; // set counter mode and BCD|binary
+ byte |= 0x30; /* load low then high byte */
+ byte |= mode; /* set counter mode and BCD|binary */
outb(byte, base_address + (i8254_control_reg << regshift));
return 0;
@@ -392,8 +388,8 @@ static inline int i8254_mm_set_mode(void *base_address,
return -1;
byte = counter_number << 6;
- byte |= 0x30; // load low then high byte
- byte |= mode; // set counter mode and BCD|binary
+ byte |= 0x30; /* load low then high byte */
+ byte |= mode; /* set counter mode and BCD|binary */
writeb(byte, base_address + (i8254_control_reg << regshift));
return 0;
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index 0369c7c84ac5..bdc3957bceb8 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -108,10 +108,10 @@ struct subdev_8255_struct {
static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it);
static int dev_8255_detach(struct comedi_device *dev);
static struct comedi_driver driver_8255 = {
- driver_name:"8255",
- module:THIS_MODULE,
- attach:dev_8255_attach,
- detach:dev_8255_detach,
+ .driver_name = "8255",
+ .module = THIS_MODULE,
+ .attach = dev_8255_attach,
+ .detach = dev_8255_detach,
};
COMEDI_INITCLEANUP(driver_8255);
@@ -144,7 +144,7 @@ static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
}
static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -169,7 +169,7 @@ static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice *
}
static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask;
unsigned int bits;
@@ -223,7 +223,7 @@ static void do_config(struct comedi_device *dev, struct comedi_subdevice * s)
}
static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -361,8 +361,10 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice * s,
void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s)
{
if (s->private) {
- if (subdevpriv->have_irq) {
- }
+ /* this test does nothing, so comment it out
+ * if (subdevpriv->have_irq) {
+ * }
+ */
kfree(s->private);
}
@@ -394,7 +396,8 @@ static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig *
return -EINVAL;
}
- if ((ret = alloc_subdevices(dev, i)) < 0)
+ ret = alloc_subdevices(dev, i);
+ if (ret < 0)
return ret;
for (i = 0; i < dev->n_subdevices; i++) {
diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h
index 979311b99275..5457c6b2d22e 100644
--- a/drivers/staging/comedi/drivers/8255.h
+++ b/drivers/staging/comedi/drivers/8255.h
@@ -28,16 +28,16 @@
#if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE)
-int subdev_8255_init(struct comedi_device * dev, struct comedi_subdevice * s,
+int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
int (*cb) (int, int, int, unsigned long), unsigned long arg);
-int subdev_8255_init_irq(struct comedi_device * dev, struct comedi_subdevice * s,
+int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
int (*cb) (int, int, int, unsigned long), unsigned long arg);
-void subdev_8255_cleanup(struct comedi_device * dev, struct comedi_subdevice * s);
-void subdev_8255_interrupt(struct comedi_device * dev, struct comedi_subdevice * s);
+void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s);
+void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice *s);
#else
-static inline int subdev_8255_init(struct comedi_device * dev, struct comedi_subdevice * s,
+static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
void *x, unsigned long y)
{
printk("8255 support not configured -- disabling subdevice\n");
@@ -47,8 +47,8 @@ static inline int subdev_8255_init(struct comedi_device * dev, struct comedi_sub
return 0;
}
-static inline void subdev_8255_cleanup(struct comedi_device * dev,
- struct comedi_subdevice * s)
+static inline void subdev_8255_cleanup(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
}
diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile
index 12d6e4312f3a..4b56c07823b7 100644
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -125,6 +125,8 @@ obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += ni_mio_cs.o
obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += quatech_daqp_cs.o
# Comedi USB drivers
+obj-$(CONFIG_COMEDI_USB_DRIVERS) += dt9812.o
obj-$(CONFIG_COMEDI_USB_DRIVERS) += usbdux.o
obj-$(CONFIG_COMEDI_USB_DRIVERS) += usbduxfast.o
-obj-$(CONFIG_COMEDI_USB_DRIVERS) += dt9812.o
+obj-$(CONFIG_COMEDI_USB_DRIVERS) += vmk80xx.o
+
diff --git a/drivers/staging/comedi/drivers/acl7225b.c b/drivers/staging/comedi/drivers/acl7225b.c
index b21320f0959f..5b986aa7398b 100644
--- a/drivers/staging/comedi/drivers/acl7225b.c
+++ b/drivers/staging/comedi/drivers/acl7225b.c
@@ -26,8 +26,8 @@ static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig *
static int acl7225b_detach(struct comedi_device *dev);
struct boardtype {
- const char *name; // driver name
- int io_range; // len of I/O space
+ const char *name; /* driver name */
+ int io_range; /* len of I/O space */
};
static const struct boardtype boardtypes[] = {
@@ -39,19 +39,19 @@ static const struct boardtype boardtypes[] = {
#define this_board ((const struct boardtype *)dev->board_ptr)
static struct comedi_driver driver_acl7225b = {
- driver_name:"acl7225b",
- module:THIS_MODULE,
- attach:acl7225b_attach,
- detach:acl7225b_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct boardtype),
+ .driver_name = "acl7225b",
+ .module = THIS_MODULE,
+ .attach = acl7225b_attach,
+ .detach = acl7225b_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct boardtype),
};
COMEDI_INITCLEANUP(driver_acl7225b);
static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -72,7 +72,7 @@ static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice *
}
static int acl7225b_di_insn(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c
index c96aee09e1b6..60213d292a5f 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c
@@ -23,16 +23,16 @@
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitTimer |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TimerNbr, |
-| BYTE_ b_TimerMode, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TimerNbr, |
+| unsigned char_ b_TimerMode, |
| ULONG_ ul_ReloadValue, |
-| BYTE_ b_InputClockSelection, |
-| BYTE_ b_InputClockLevel, |
-| BYTE_ b_OutputLevel, |
-| BYTE_ b_HardwareGateLevel)
-INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
+| unsigned char_ b_InputClockSelection, |
+| unsigned char_ b_InputClockLevel, |
+| unsigned char_ b_OutputLevel, |
+| unsigned char_ b_HardwareGateLevel)
+int i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data)
|
+----------------------------------------------------------------------------+
@@ -148,13 +148,13 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
| +--------------------------------+------------------------------------+ |
| |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to |
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| BYTE_ b_TimerNbr : Timer number to |
+| unsigned char_ b_TimerNbr : Timer number to |
| configure (0 to 2) |
-| BYTE_ b_TimerMode : Timer mode selection |
+| unsigned char_ b_TimerMode : Timer mode selection |
| (0 to 5) |
| 0: Interrupt on terminal|
| count |
@@ -173,21 +173,21 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
| or division factor |
| See timer mode |
| description table. |
-| BYTE_ b_InputClockSelection : Selection from input |
+| unsigned char_ b_InputClockSelection : Selection from input |
| timer clock. |
| See input clock |
| selection table. |
-| BYTE_ b_InputClockLevel : Selection from input |
+| unsigned char_ b_InputClockLevel : Selection from input |
| clock level. |
| 0 : Low active |
| (Input inverted) |
| 1 : High active |
-| BYTE_ b_OutputLevel, : Selection from output |
+| unsigned char_ b_OutputLevel, : Selection from output |
| clock level. |
| 0 : Low active |
| 1 : High active |
| (Output inverted) |
-| BYTE_ b_HardwareGateLevel : Selection from |
+| unsigned char_ b_HardwareGateLevel : Selection from |
| hardware gate level. |
| 0 : Low active |
| (Input inverted) |
@@ -195,14 +195,14 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
| If you will not used |
| the hardware gate set |
| this value to 0.
-|b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec);
- b_TimerMode = (BYTE) data[0];
- ul_ReloadValue = (ULONG) data[1];
- b_InputClockSelection =(BYTE) data[2];
- b_InputClockLevel =(BYTE) data[3];
- b_OutputLevel =(BYTE) data[4];
- b_HardwareGateLevel =(BYTE) data[5];
+|b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec);
+ b_TimerMode = (unsigned char) data[0];
+ ul_ReloadValue = (unsigned int) data[1];
+ b_InputClockSelection =(unsigned char) data[2];
+ b_InputClockLevel =(unsigned char) data[3];
+ b_OutputLevel =(unsigned char) data[4];
+ b_HardwareGateLevel =(unsigned char) data[5];
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -219,33 +219,33 @@ INT i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_ModulNbr;
- BYTE b_TimerNbr;
- BYTE b_TimerMode;
- ULONG ul_ReloadValue;
- BYTE b_InputClockSelection;
- BYTE b_InputClockLevel;
- BYTE b_OutputLevel;
- BYTE b_HardwareGateLevel;
+ int i_ReturnValue = 0;
+ unsigned char b_ModulNbr;
+ unsigned char b_TimerNbr;
+ unsigned char b_TimerMode;
+ unsigned int ul_ReloadValue;
+ unsigned char b_InputClockSelection;
+ unsigned char b_InputClockLevel;
+ unsigned char b_OutputLevel;
+ unsigned char b_HardwareGateLevel;
- //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
- DWORD dw_Test = 0;
- //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+ /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */
+ unsigned int dw_Test = 0;
+ /* END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec);
- b_TimerMode = (BYTE) data[0];
- ul_ReloadValue = (ULONG) data[1];
- b_InputClockSelection = (BYTE) data[2];
- b_InputClockLevel = (BYTE) data[3];
- b_OutputLevel = (BYTE) data[4];
- b_HardwareGateLevel = (BYTE) data[5];
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec);
+ b_TimerMode = (unsigned char) data[0];
+ ul_ReloadValue = (unsigned int) data[1];
+ b_InputClockSelection = (unsigned char) data[2];
+ b_InputClockLevel = (unsigned char) data[3];
+ b_OutputLevel = (unsigned char) data[4];
+ b_HardwareGateLevel = (unsigned char) data[5];
/* Test the module number */
if (b_ModulNbr < 4) {
@@ -256,7 +256,7 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
if (b_TimerNbr <= 2) {
/* Test the timer mode */
if (b_TimerMode <= 5) {
- //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+ /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */
/* Test te imput clock selection */
/*
if (((b_TimerNbr == 0) && (b_InputClockSelection == 0)) ||
@@ -271,11 +271,11 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
((b_InputClockSelection == APCI1710_PCI_BUS_CLOCK) ||
(b_InputClockSelection == APCI1710_FRONT_CONNECTOR_INPUT) ||
(b_InputClockSelection == APCI1710_10MHZ)))) {
- //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+ /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */
if (((b_InputClockSelection == APCI1710_10MHZ) &&
((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0x0000FFFFUL) >= 0x3131)) ||
(b_InputClockSelection != APCI1710_10MHZ)) {
- //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+ /* END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */
/* Test the input clock level selection */
if ((b_InputClockLevel == 0) ||
@@ -284,7 +284,7 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) {
/* Test the hardware gate level selection */
if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) {
- //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+ /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
/* Test if version > 1.1 and clock selection = 10MHz */
if ((b_InputClockSelection == APCI1710_10MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0x0000FFFFUL) > 0x3131)) {
/* Test if 40MHz quartz on board */
@@ -297,7 +297,7 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
/* Test if detection OK */
if (dw_Test == 1) {
- //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+ /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
/* Initialisation OK */
devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init = 1;
@@ -314,12 +314,12 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_HardwareGateLevel = b_HardwareGateLevel;
/* Set the configuration word and disable the timer */
- //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+ /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
/*
devpriv->s_ModuleInfo [b_ModulNbr].
s_82X54ModuleInfo.
s_82X54TimerInfo [b_TimerNbr].
- dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel << 0) & 0x1) |
+ dw_ConfigurationWord = (unsigned int) (((b_HardwareGateLevel << 0) & 0x1) |
((b_InputClockLevel << 1) & 0x2) |
(((~b_OutputLevel & 1) << 2) & 0x4) |
((b_InputClockSelection << 4) & 0x10));
@@ -329,40 +329,40 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
b_InputClockSelection = 2;
}
- devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = (DWORD)(((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x30));
- //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+ devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = (unsigned int)(((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x30));
+ /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
/* Initialise the 82X54 Timer */
- outl((DWORD) b_TimerMode, devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+ outl((unsigned int) b_TimerMode, devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
/* Write the reload value */
outl(ul_ReloadValue, devpriv->s_BoardInfos.ui_Address + 0 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
- //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
- } // if (dw_Test == 1)
+ /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
+ } /* if (dw_Test == 1) */
else {
/* Input timer clock selection is wrong */
i_ReturnValue = -6;
- } // if (dw_Test == 1)
- //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
- } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))
+ } /* if (dw_Test == 1) */
+ /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
+ } /* if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) */
else {
/* Selection from hardware gate level is wrong */
DPRINTK("Selection from hardware gate level is wrong\n");
i_ReturnValue = -9;
- } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))
- } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1))
+ } /* if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) */
+ } /* if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) */
else {
/* Selection from output clock level is wrong */
DPRINTK("Selection from output clock level is wrong\n");
i_ReturnValue = -8;
- } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1))
- } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))
+ } /* if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) */
+ } /* if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) */
else {
/* Selection from input clock level is wrong */
DPRINTK("Selection from input clock level is wrong\n");
i_ReturnValue = -7;
- } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))
+ } /* if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) */
} else {
/* Input timer clock selection is wrong */
DPRINTK("Input timer clock selection is wrong\n");
@@ -373,18 +373,18 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
DPRINTK("Input timer clock selection is wrong\n");
i_ReturnValue = -6;
}
- } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5))
+ } /* if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) */
else {
/* Timer mode selection is wrong */
DPRINTK("Timer mode selection is wrong\n");
i_ReturnValue = -5;
- } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5))
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) */
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
else {
/* Timer selection wrong */
DPRINTK("Timer selection wrong\n");
i_ReturnValue = -3;
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
} else {
/* The module is not a TIMER module */
DPRINTK("The module is not a TIMER module\n");
@@ -396,17 +396,17 @@ INT i_APCI1710_InsnConfigInitTimer(struct comedi_device * dev, struct comedi_sub
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnableTimer |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TimerNbr, |
-| BYTE_ b_InterruptEnable)
-INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct comedi_subdevice *s,
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TimerNbr, |
+| unsigned char_ b_InterruptEnable)
+int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Enable OR Disable the Timer (b_TimerNbr) from selected module |
@@ -416,22 +416,22 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct come
| generate a interrupt after the timer value reach |
| the zero. See function "i_APCI1710_SetBoardIntRoutineX"|
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number |
+| unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
-| BYTE_ b_TimerNbr : Timer number to enable |
+| unsigned char_ b_TimerNbr : Timer number to enable |
| (0 to 2) |
-| BYTE_ b_InterruptEnable : Enable or disable the |
+| unsigned char_ b_InterruptEnable : Enable or disable the |
| timer interrupt. |
| APCI1710_ENABLE : |
| Enable the timer interrupt |
| APCI1710_DISABLE : |
| Disable the timer interrupt|
i_ReturnValue=insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec);
- b_ActionType = (BYTE) data[0]; // enable disable
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec);
+ b_ActionType = (unsigned char) data[0]; /* enable disable */
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -448,21 +448,21 @@ i_ReturnValue=insn->n;
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
- struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_DummyRead;
- BYTE b_ModulNbr;
- BYTE b_TimerNbr;
- BYTE b_ActionType;
- BYTE b_InterruptEnable;
+ int i_ReturnValue = 0;
+ unsigned int dw_DummyRead;
+ unsigned char b_ModulNbr;
+ unsigned char b_TimerNbr;
+ unsigned char b_ActionType;
+ unsigned char b_InterruptEnable;
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec);
- b_ActionType = (BYTE) data[0]; // enable disable
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec);
+ b_ActionType = (unsigned char) data[0]; /* enable disable */
/* Test the module number */
if (b_ModulNbr < 4) {
@@ -475,7 +475,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
switch (b_ActionType) {
case APCI1710_ENABLE:
- b_InterruptEnable = (BYTE) data[1];
+ b_InterruptEnable = (unsigned char) data[1];
/* Test the interrupt selection */
if ((b_InterruptEnable == APCI1710_ENABLE) ||
(b_InterruptEnable == APCI1710_DISABLE)) {
@@ -487,9 +487,9 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord | 0x8;
outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
- } // if (b_InterruptEnable == APCI1710_ENABLE)
+ } /* if (b_InterruptEnable == APCI1710_ENABLE) */
else {
/* Disable the interrupt */
devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord & 0xF7;
@@ -498,7 +498,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
/* Save the interrupt flag */
devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask & (0xFF - (1 << b_TimerNbr));
- } // if (b_InterruptEnable == APCI1710_ENABLE)
+ } /* if (b_InterruptEnable == APCI1710_ENABLE) */
/* Test if error occur */
if (i_ReturnValue >= 0) {
@@ -530,7 +530,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
/* Disable the timer */
outl(0, devpriv->s_BoardInfos.ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
break;
- } // Switch end
+ } /* Switch end */
} else {
/* Timer not initialised see function */
DPRINTK ("Timer not initialised see function\n");
@@ -540,7 +540,7 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
/* Timer selection wrong */
DPRINTK("Timer selection wrong\n");
i_ReturnValue = -3;
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
} else {
/* The module is not a TIMER module */
DPRINTK("The module is not a TIMER module\n");
@@ -552,24 +552,24 @@ INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadAllTimerValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
| PULONG_ pul_TimerValueArray)
-INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_subdevice *s,
+int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Return the all timer values from selected timer |
| module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number |
+| unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_TimerValueArray : Timer value array. |
@@ -590,16 +590,16 @@ INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_sub
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_ModulNbr, b_ReadType;
- PULONG pul_TimerValueArray;
+ int i_ReturnValue = 0;
+ unsigned char b_ModulNbr, b_ReadType;
+ unsigned int *pul_TimerValueArray;
b_ModulNbr = CR_AREF(insn->chanspec);
b_ReadType = CR_CHAN(insn->chanspec);
- pul_TimerValueArray = (PULONG) data;
+ pul_TimerValueArray = (unsigned int *) data;
i_ReturnValue = insn->n;
switch (b_ReadType) {
@@ -662,8 +662,8 @@ INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_su
i_ReturnValue = -2;
}
- } // End of Switch
- return (i_ReturnValue);
+ } /* End of Switch */
+ return i_ReturnValue;
}
/*
@@ -681,11 +681,11 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_BitsType;
- INT i_ReturnValue = 0;
+ unsigned char b_BitsType;
+ int i_ReturnValue = 0;
b_BitsType = data[0];
printk("\n82X54");
@@ -693,30 +693,30 @@ INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice
switch (b_BitsType) {
case APCI1710_TIMER_READVALUE:
i_ReturnValue = i_APCI1710_ReadTimerValue(dev,
- (BYTE)CR_AREF(insn->chanspec),
- (BYTE)CR_CHAN(insn->chanspec),
- (PULONG) & data[0]);
+ (unsigned char)CR_AREF(insn->chanspec),
+ (unsigned char)CR_CHAN(insn->chanspec),
+ (unsigned int *) &data[0]);
break;
case APCI1710_TIMER_GETOUTPUTLEVEL:
i_ReturnValue = i_APCI1710_GetTimerOutputLevel(dev,
- (BYTE)CR_AREF(insn->chanspec),
- (BYTE)CR_CHAN(insn->chanspec),
- (PBYTE) &data[0]);
+ (unsigned char)CR_AREF(insn->chanspec),
+ (unsigned char)CR_CHAN(insn->chanspec),
+ (unsigned char *) &data[0]);
break;
case APCI1710_TIMER_GETPROGRESSSTATUS:
i_ReturnValue = i_APCI1710_GetTimerProgressStatus(dev,
- (BYTE)CR_AREF(insn->chanspec),
- (BYTE)CR_CHAN(insn->chanspec),
- (PBYTE)&data[0]);
+ (unsigned char)CR_AREF(insn->chanspec),
+ (unsigned char)CR_CHAN(insn->chanspec),
+ (unsigned char *)&data[0]);
break;
case APCI1710_TIMER_WRITEVALUE:
i_ReturnValue = i_APCI1710_WriteTimerValue(dev,
- (BYTE)CR_AREF(insn->chanspec),
- (BYTE)CR_CHAN(insn->chanspec),
- (ULONG)data[1]);
+ (unsigned char)CR_AREF(insn->chanspec),
+ (unsigned char)CR_CHAN(insn->chanspec),
+ (unsigned int)data[1]);
break;
@@ -727,25 +727,25 @@ INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadTimerValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TimerNbr, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TimerNbr, |
| PULONG_ pul_TimerValue) |
+----------------------------------------------------------------------------+
| Task : Return the timer value from selected digital timer |
| (b_TimerNbr) from selected timer module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number |
+| unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
-| BYTE_ b_TimerNbr : Timer number to read |
+| unsigned char_ b_TimerNbr : Timer number to read |
| (0 to 2) |
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_TimerValue : Timer value |
@@ -760,11 +760,11 @@ INT i_APCI1710_InsnBitsTimer(struct comedi_device * dev, struct comedi_subdevice
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ReadTimerValue(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- PULONG pul_TimerValue)
+int i_APCI1710_ReadTimerValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned int *pul_TimerValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/* Test the module number */
if (b_ModulNbr < 4) {
@@ -800,7 +800,7 @@ INT i_APCI1710_ReadTimerValue(struct comedi_device * dev,
/* Timer selection wrong */
DPRINTK("Timer selection wrong\n");
i_ReturnValue = -3;
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
} else {
/* The module is not a TIMER module */
DPRINTK("The module is not a TIMER module\n");
@@ -812,29 +812,29 @@ INT i_APCI1710_ReadTimerValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetTimerOutputLevel |
- | (BYTE_ b_BoardHandle, |
- | BYTE_ b_ModulNbr, |
- | BYTE_ b_TimerNbr, |
- | PBYTE_ pb_OutputLevel) |
+ | (unsigned char_ b_BoardHandle, |
+ | unsigned char_ b_ModulNbr, |
+ | unsigned char_ b_TimerNbr, |
+ | unsigned char *_ pb_OutputLevel) |
+----------------------------------------------------------------------------+
| Task : Return the output signal level (pb_OutputLevel) from |
| selected digital timer (b_TimerNbr) from selected timer|
| module (b_ModulNbr). |
+----------------------------------------------------------------------------+
- | Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+ | Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
- | BYTE_ b_ModulNbr : Selected module number |
+ | unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
- | BYTE_ b_TimerNbr : Timer number to test |
+ | unsigned char_ b_TimerNbr : Timer number to test |
| (0 to 2) |
+----------------------------------------------------------------------------+
- | Output Parameters : PBYTE_ pb_OutputLevel : Output signal level |
+ | Output Parameters : unsigned char *_ pb_OutputLevel : Output signal level |
| 0 : The output is low |
| 1 : The output is high |
+----------------------------------------------------------------------------+
@@ -848,12 +848,12 @@ INT i_APCI1710_ReadTimerValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- PBYTE pb_OutputLevel)
+int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned char *pb_OutputLevel)
{
- INT i_ReturnValue = 0;
- DWORD dw_TimerStatus;
+ int i_ReturnValue = 0;
+ unsigned int dw_TimerStatus;
/* Test the module number */
if (b_ModulNbr < 4) {
@@ -869,7 +869,7 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev,
/* Read the timer status */
dw_TimerStatus = inl(devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
- *pb_OutputLevel = (BYTE) (((dw_TimerStatus >> 7) & 1) ^ devpriv-> s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_OutputLevel);
+ *pb_OutputLevel = (unsigned char) (((dw_TimerStatus >> 7) & 1) ^ devpriv-> s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_OutputLevel);
} else {
/* Timer not initialised see function */
DPRINTK("Timer not initialised see function\n");
@@ -879,7 +879,7 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev,
/* Timer selection wrong */
DPRINTK("Timer selection wrong\n");
i_ReturnValue = -3;
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
} else {
/* The module is not a TIMER module */
DPRINTK("The module is not a TIMER module\n");
@@ -891,29 +891,29 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetTimerProgressStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TimerNbr, |
-| PBYTE_ pb_TimerStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TimerNbr, |
+| unsigned char *_ pb_TimerStatus) |
+----------------------------------------------------------------------------+
| Task : Return the progress status (pb_TimerStatus) from |
| selected digital timer (b_TimerNbr) from selected timer|
| module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number |
+| unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
-| BYTE_ b_TimerNbr : Timer number to test |
+| unsigned char_ b_TimerNbr : Timer number to test |
| (0 to 2) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_TimerStatus : Output signal level |
+| Output Parameters : unsigned char *_ pb_TimerStatus : Output signal level |
| 0 : Timer not in progress |
| 1 : Timer in progress |
+----------------------------------------------------------------------------+
@@ -927,12 +927,12 @@ INT i_APCI1710_GetTimerOutputLevel(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- PBYTE pb_TimerStatus)
+int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned char *pb_TimerStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_TimerStatus;
+ int i_ReturnValue = 0;
+ unsigned int dw_TimerStatus;
/* Test the module number */
if (b_ModulNbr < 4) {
@@ -949,7 +949,7 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
/* Read the timer status */
dw_TimerStatus = inl(devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
- *pb_TimerStatus = (BYTE) ((dw_TimerStatus) >> 8) & 1;
+ *pb_TimerStatus = (unsigned char) ((dw_TimerStatus) >> 8) & 1;
printk("ProgressStatus : %d", *pb_TimerStatus);
} else {
/* Timer not initialised see function */
@@ -958,7 +958,7 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
} else {
/* Timer selection wrong */
i_ReturnValue = -3;
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
} else {
/* The module is not a TIMER module */
@@ -976,9 +976,9 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_WriteTimerValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TimerNbr, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TimerNbr, |
| ULONG_ ul_WriteValue) |
+----------------------------------------------------------------------------+
| Task : Write the value (ul_WriteValue) into the selected timer|
@@ -986,11 +986,11 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
| The action in depend of the time mode selection. |
| See timer mode description table. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board |
| APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number |
+| unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
-| BYTE_ b_TimerNbr : Timer number to write |
+| unsigned char_ b_TimerNbr : Timer number to write |
| (0 to 2) |
| ULONG_ ul_WriteValue : Value to write |
+----------------------------------------------------------------------------+
@@ -1006,11 +1006,11 @@ INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_WriteTimerValue(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- ULONG ul_WriteValue)
+int i_APCI1710_WriteTimerValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned int ul_WriteValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/* Test the module number */
if (b_ModulNbr < 4) {
@@ -1031,7 +1031,7 @@ INT i_APCI1710_WriteTimerValue(struct comedi_device * dev,
/* Timer selection wrong */
DPRINTK("Timer selection wrong\n");
i_ReturnValue = -3;
- } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+ } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */
} else {
/* The module is not a TIMER module */
DPRINTK("The module is not a TIMER module\n");
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h
index 4797c0b77a43..9698ae13509d 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h
@@ -34,40 +34,40 @@
/*
* 82X54 TIMER INISIALISATION FUNCTION
*/
-INT i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,
+int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/*
* 82X54 READ FUNCTION
*/
-INT i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/*
* 82X54 READ & WRITE FUNCTION
*/
-INT i_APCI1710_ReadTimerValue(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- PULONG pul_TimerValue);
+int i_APCI1710_ReadTimerValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned int *pul_TimerValue);
-INT i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- PBYTE pb_OutputLevel);
+int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned char *pb_OutputLevel);
-INT i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- PBYTE pb_TimerStatus);
+int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned char *pb_TimerStatus);
/*
* 82X54 WRITE FUNCTION
*/
-INT i_APCI1710_WriteTimerValue(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_TimerNbr,
- ULONG ul_WriteValue);
+int i_APCI1710_WriteTimerValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_TimerNbr,
+ unsigned int ul_WriteValue);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c
index 1a54d3b2c694..ccb109a851f2 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -62,11 +62,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitChrono |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_ChronoMode, |
-| BYTE_ b_PCIInputClock, |
-| BYTE_ b_TimingUnit, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_ChronoMode, |
+| unsigned char_ b_PCIInputClock, |
+| unsigned char_ b_TimingUnit, |
| ULONG_ ul_TimingInterval, |
| PULONG_ pul_RealTimingInterval)
@@ -88,12 +88,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| The mode 4 to 7 is appropriate for measuring the timing|
| between two event. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr CR_AREF(insn->chanspec) : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr CR_AREF(insn->chanspec) : Module number to configure |
| (0 to 3) |
-| BYTE_ b_ChronoMode data[0] : Chronometer action mode |
+| unsigned char_ b_ChronoMode data[0] : Chronometer action mode |
| (0 to 7). |
-| BYTE_ b_PCIInputClock data[1] : Selection from PCI bus clock|
+| unsigned char_ b_PCIInputClock data[1] : Selection from PCI bus clock|
| - APCI1710_30MHZ : |
| The PC have a PCI bus |
| clock from 30 MHz |
@@ -104,7 +104,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| The APCI-1710 have a |
| integrated 40Mhz |
| quartz. |
-| BYTE_ b_TimingUnit data[2] : Base timing unity (0 to 4) |
+| unsigned char_ b_TimingUnit data[2] : Base timing unity (0 to 4) |
| 0 : ns |
| 1 : µs |
| 2 : ms |
@@ -131,23 +131,23 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- ULONG ul_TimerValue = 0;
- ULONG ul_TimingInterval = 0;
- ULONG ul_RealTimingInterval = 0;
+ int i_ReturnValue = 0;
+ unsigned int ul_TimerValue = 0;
+ unsigned int ul_TimingInterval = 0;
+ unsigned int ul_RealTimingInterval = 0;
double d_RealTimingInterval = 0;
- DWORD dw_ModeArray[8] =
+ unsigned int dw_ModeArray[8] =
{ 0x01, 0x05, 0x00, 0x04, 0x02, 0x0E, 0x0A, 0x06 };
- BYTE b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit;
+ unsigned char b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit;
b_ModulNbr = CR_AREF(insn->chanspec);
- b_ChronoMode = (BYTE) data[0];
- b_PCIInputClock = (BYTE) data[1];
- b_TimingUnit = (BYTE) data[2];
- ul_TimingInterval = (ULONG) data[3];
+ b_ChronoMode = (unsigned char) data[0];
+ b_PCIInputClock = (unsigned char) data[1];
+ b_TimingUnit = (unsigned char) data[2];
+ ul_TimingInterval = (unsigned int) data[3];
i_ReturnValue = insn->n;
/**************************/
@@ -214,7 +214,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(0.001 * b_PCIInputClock));
@@ -237,7 +237,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(0.001 * (double)b_PCIInputClock));
@@ -272,7 +272,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -294,7 +294,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(1.0 * b_PCIInputClock));
@@ -317,7 +317,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(1.0 * (double)b_PCIInputClock));
@@ -354,7 +354,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -400,7 +400,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(1000.0 * (double)b_PCIInputClock));
@@ -435,7 +435,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -457,7 +457,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(1000000.0
@@ -482,7 +482,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(1000000.0
@@ -520,7 +520,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -542,7 +542,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(ul_TimingInterval
*
@@ -570,7 +570,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(1000000.0
@@ -608,7 +608,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -736,7 +736,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
DPRINTK("Base timing selection is wrong\n");
i_ReturnValue = -7;
}
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
else {
/***********************************/
/* Timing unity selection is wrong */
@@ -744,8 +744,8 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
DPRINTK("Timing unity selection is wrong\n");
i_ReturnValue = -6;
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
- } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
+ } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */
else {
/*****************************************/
/* The selected PCI input clock is wrong */
@@ -753,8 +753,8 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
DPRINTK("The selected PCI input clock is wrong\n");
i_ReturnValue = -5;
- } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))
- } // if (b_ChronoMode >= 0 && b_ChronoMode <= 7)
+ } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */
+ } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */
else {
/***************************************/
/* Chronometer mode selection is wrong */
@@ -762,7 +762,7 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
DPRINTK("Chronometer mode selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_ChronoMode >= 0 && b_ChronoMode <= 7)
+ } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */
} else {
/******************************************/
/* The module is not a Chronometer module */
@@ -780,17 +780,17 @@ INT i_APCI1710_InsnConfigInitChrono(struct comedi_device * dev, struct comedi_su
i_ReturnValue = -2;
}
data[0] = ul_RealTimingInterval;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnableChrono |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_CycleMode, |
-| BYTE_ b_InterruptEnable)
-INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_CycleMode, |
+| unsigned char_ b_InterruptEnable)
+int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Enable the chronometer from selected module |
@@ -810,12 +810,12 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
| witch the " i_APCI1710_EnableChrono" function, if no |
| stop signal occur this start signal is ignored.
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr CR_AREF(chanspec) : Selected module number (0 to 3) |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number (0 to 3) |
data[0] ENABle/Disable chrono
-| BYTE_ b_CycleMode : Selected the chronometer |
+| unsigned char_ b_CycleMode : Selected the chronometer |
| data[1] acquisition mode |
-| BYTE_ b_InterruptEnable : Enable or disable the |
+| unsigned char_ b_InterruptEnable : Enable or disable the |
| data[2] chronometer interrupt. |
| APCI1710_ENABLE: |
| Enable the chronometer |
@@ -840,15 +840,15 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_ModulNbr, b_CycleMode, b_InterruptEnable, b_Action;
+ int i_ReturnValue = 0;
+ unsigned char b_ModulNbr, b_CycleMode, b_InterruptEnable, b_Action;
b_ModulNbr = CR_AREF(insn->chanspec);
- b_Action = (BYTE) data[0];
- b_CycleMode = (BYTE) data[1];
- b_InterruptEnable = (BYTE) data[2];
+ b_Action = (unsigned char) data[0];
+ b_CycleMode = (unsigned char) data[1];
+ b_InterruptEnable = (unsigned char) data[2];
i_ReturnValue = insn->n;
/**************************/
@@ -951,7 +951,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
ui_Address
+ 32 +
(64 * b_ModulNbr));
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
}
/***********************************/
@@ -980,7 +980,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
36 +
(64 * b_ModulNbr));
- } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))
+ } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */
else {
/********************************/
/* Interrupt parameter is wrong */
@@ -988,8 +988,8 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
DPRINTK("Interrupt parameter is wrong\n");
i_ReturnValue = -6;
- } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))
- } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))
+ } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */
+ } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */
else {
/***********************************************/
/* Chronometer acquisition mode cycle is wrong */
@@ -997,7 +997,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
DPRINTK("Chronometer acquisition mode cycle is wrong\n");
i_ReturnValue = -5;
- } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))
+ } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */
break;
case APCI1710_DISABLE:
@@ -1046,7 +1046,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
default:
DPRINTK("Inputs wrong! Enable or Disable chrono\n");
i_ReturnValue = -8;
- } // switch ENABLE/DISABLE
+ } /* switch ENABLE/DISABLE */
} else {
/*******************************/
/* Chronometer not initialised */
@@ -1072,7 +1072,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1090,36 +1090,36 @@ struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadChrono(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_ReadType;
- INT i_ReturnValue = insn->n;
+ unsigned char b_ReadType;
+ int i_ReturnValue = insn->n;
b_ReadType = CR_CHAN(insn->chanspec);
switch (b_ReadType) {
case APCI1710_CHRONO_PROGRESS_STATUS:
i_ReturnValue = i_APCI1710_GetChronoProgressStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_CHRONO_READVALUE:
i_ReturnValue = i_APCI1710_ReadChronoValue(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (UINT) insn->unused[0],
- (PBYTE) & data[0], (PULONG) & data[1]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned int) insn->unused[0],
+ (unsigned char *) &data[0], (unsigned int *) &data[1]);
break;
case APCI1710_CHRONO_CONVERTVALUE:
i_ReturnValue = i_APCI1710_ConvertChronoValue(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (ULONG) insn->unused[0],
- (PULONG) & data[0],
- (PBYTE) & data[1],
- (PBYTE) & data[2],
- (PUINT) & data[3],
- (PUINT) & data[4], (PUINT) & data[5]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned int) insn->unused[0],
+ (unsigned int *) &data[0],
+ (unsigned char *) &data[1],
+ (unsigned char *) &data[2],
+ (unsigned int *) &data[3],
+ (unsigned int *) &data[4], (unsigned int *) &data[5]);
break;
case APCI1710_CHRONO_READINTERRUPT:
@@ -1152,22 +1152,22 @@ INT i_APCI1710_InsnReadChrono(struct comedi_device * dev, struct comedi_subdevic
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetChronoProgressStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_ChronoStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_ChronoStatus) |
+----------------------------------------------------------------------------+
| Task : Return the chronometer status (pb_ChronoStatus) from |
| selected chronometer module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer |
| status. |
@@ -1194,11 +1194,11 @@ INT i_APCI1710_InsnReadChrono(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_ChronoStatus)
+int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
/**************************/
/* Test the module number */
@@ -1233,7 +1233,7 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
/******************/
*pb_ChronoStatus = 3;
- } // if ((dw_Status & 8) == 8)
+ } /* if ((dw_Status & 8) == 8) */
else {
/*******************************/
/* Test if measurement stopped */
@@ -1245,7 +1245,7 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
/***********************/
*pb_ChronoStatus = 2;
- } // if ((dw_Status & 2) == 2)
+ } /* if ((dw_Status & 2) == 2) */
else {
/*******************************/
/* Test if measurement started */
@@ -1257,16 +1257,16 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
/************************/
*pb_ChronoStatus = 1;
- } // if ((dw_Status & 1) == 1)
+ } /* if ((dw_Status & 1) == 1) */
else {
/***************************/
/* Measurement not started */
/***************************/
*pb_ChronoStatus = 0;
- } // if ((dw_Status & 1) == 1)
- } // if ((dw_Status & 2) == 2)
- } // if ((dw_Status & 8) == 8)
+ } /* if ((dw_Status & 1) == 1) */
+ } /* if ((dw_Status & 2) == 2) */
+ } /* if ((dw_Status & 8) == 8) */
} else {
/*******************************/
/* Chronometer not initialised */
@@ -1289,16 +1289,16 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadChronoValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| UINT_ ui_TimeOut, |
-| PBYTE_ pb_ChronoStatus, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned int_ ui_TimeOut, |
+| unsigned char *_ pb_ChronoStatus, |
| PULONG_ pul_ChronoValue) |
+----------------------------------------------------------------------------+
| Task : Return the chronometer status (pb_ChronoStatus) and the|
@@ -1323,8 +1323,8 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
| "i_APCI1710_InitChrono" function and the time unity is |
| the b_TimingUnit from "i_APCI1710_InitChrono" function|
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer |
| status. |
@@ -1341,7 +1341,7 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
| timing witch the |
| function |
| "i_APCI1710_InitChrono" |
-| PULONG pul_ChronoValue : Chronometer timing value. |
+| unsigned int * pul_ChronoValue : Chronometer timing value. |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
@@ -1355,13 +1355,13 @@ INT i_APCI1710_GetChronoProgressStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
- BYTE b_ModulNbr,
- UINT ui_TimeOut, PBYTE pb_ChronoStatus, PULONG pul_ChronoValue)
+int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus, unsigned int *pul_ChronoValue)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
- DWORD dw_TimeOut = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
+ unsigned int dw_TimeOut = 0;
/**************************/
/* Test the module number */
@@ -1430,7 +1430,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
}
break;
- } // if ((dw_Status & 8) == 8)
+ } /* if ((dw_Status & 8) == 8) */
else {
/*******************************/
/* Test if measurement stopped */
@@ -1464,7 +1464,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
outl(0, devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));
}
break;
- } // if ((dw_Status & 2) == 2)
+ } /* if ((dw_Status & 2) == 2) */
else {
/*******************************/
/* Test if measurement started */
@@ -1478,7 +1478,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
*pb_ChronoStatus
=
1;
- } // if ((dw_Status & 1) == 1)
+ } /* if ((dw_Status & 1) == 1) */
else {
/***************************/
/* Measurement not started */
@@ -1487,9 +1487,9 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
*pb_ChronoStatus
=
0;
- } // if ((dw_Status & 1) == 1)
- } // if ((dw_Status & 2) == 2)
- } // if ((dw_Status & 8) == 8)
+ } /* if ((dw_Status & 1) == 1) */
+ } /* if ((dw_Status & 2) == 2) */
+ } /* if ((dw_Status & 8) == 8) */
if (dw_TimeOut == ui_TimeOut) {
/*****************/
@@ -1507,7 +1507,7 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
mdelay(1000);
}
- } // for (;;)
+ } /* for (;;) */
/*****************************/
/* Test if stop signal occur */
@@ -1575,39 +1575,39 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ConvertChronoValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
| ULONG_ ul_ChronoValue, |
| PULONG_ pul_Hour, |
-| PBYTE_ pb_Minute, |
-| PBYTE_ pb_Second, |
-| PUINT_ pui_MilliSecond, |
-| PUINT_ pui_MicroSecond, |
-| PUINT_ pui_NanoSecond) |
+| unsigned char *_ pb_Minute, |
+| unsigned char *_ pb_Second, |
+| unsigned int *_ pui_MilliSecond, |
+| unsigned int *_ pui_MicroSecond, |
+| unsigned int *_ pui_NanoSecond) |
+----------------------------------------------------------------------------+
| Task : Convert the chronometer measured timing |
| (ul_ChronoValue) in to h, mn, s, ms, µs, ns. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3)|
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
| ULONG_ ul_ChronoValue : Measured chronometer timing |
| value. |
| See"i_APCI1710_ReadChronoValue"|
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_Hour : Chronometer timing hour |
-| PBYTE_ pb_Minute : Chronometer timing minute |
-| PBYTE_ pb_Second : Chronometer timing second |
-| PUINT_ pui_MilliSecond : Chronometer timing mini |
+| unsigned char *_ pb_Minute : Chronometer timing minute |
+| unsigned char *_ pb_Second : Chronometer timing second |
+| unsigned int *_ pui_MilliSecond : Chronometer timing mini |
| second |
-| PUINT_ pui_MicroSecond : Chronometer timing micro |
+| unsigned int *_ pui_MicroSecond : Chronometer timing micro |
| second |
-| PUINT_ pui_NanoSecond : Chronometer timing nano |
+| unsigned int *_ pui_NanoSecond : Chronometer timing nano |
| second |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -1619,15 +1619,15 @@ INT i_APCI1710_ReadChronoValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
- BYTE b_ModulNbr,
- ULONG ul_ChronoValue,
- PULONG pul_Hour,
- PBYTE pb_Minute,
- PBYTE pb_Second,
- PUINT pui_MilliSecond, PUINT pui_MicroSecond, PUINT pui_NanoSecond)
+int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned int ul_ChronoValue,
+ unsigned int *pul_Hour,
+ unsigned char *pb_Minute,
+ unsigned char *pb_Second,
+ unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond, unsigned int *pui_NanoSecond)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
double d_Hour;
double d_Minute;
double d_Second;
@@ -1681,7 +1681,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
/**********************/
d_Hour = d_Hour / (double)60.0;
- *pul_Hour = (ULONG) d_Hour;
+ *pul_Hour = (unsigned int) d_Hour;
/************************/
/* Calculate the minute */
@@ -1689,7 +1689,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
d_Minute = d_Hour - *pul_Hour;
d_Minute = d_Minute * 60;
- *pb_Minute = (BYTE) d_Minute;
+ *pb_Minute = (unsigned char) d_Minute;
/************************/
/* Calculate the second */
@@ -1697,7 +1697,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
d_Second = d_Minute - *pb_Minute;
d_Second = d_Second * 60;
- *pb_Second = (BYTE) d_Second;
+ *pb_Second = (unsigned char) d_Second;
/*****************************/
/* Calculate the mini second */
@@ -1705,7 +1705,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
d_MilliSecond = d_Second - *pb_Second;
d_MilliSecond = d_MilliSecond * 1000;
- *pui_MilliSecond = (UINT) d_MilliSecond;
+ *pui_MilliSecond = (unsigned int) d_MilliSecond;
/******************************/
/* Calculate the micro second */
@@ -1715,7 +1715,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
d_MilliSecond -
*pui_MilliSecond;
d_MicroSecond = d_MicroSecond * 1000;
- *pui_MicroSecond = (UINT) d_MicroSecond;
+ *pui_MicroSecond = (unsigned int) d_MicroSecond;
/******************************/
/* Calculate the micro second */
@@ -1725,7 +1725,7 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
d_MicroSecond -
*pui_MicroSecond;
d_NanoSecond = d_NanoSecond * 1000;
- *pui_NanoSecond = (UINT) d_NanoSecond;
+ *pui_NanoSecond = (unsigned int) d_NanoSecond;
break;
}
@@ -1752,21 +1752,21 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s,
+| Function Name : int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Sets the output witch has been passed with the |
| parameter b_Channel. Setting an output means setting an|
| output high. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3)|
-| BYTE_ b_OutputChannel : Selection from digital output |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
+| unsigned char_ b_OutputChannel : Selection from digital output |
| CR_CHAN() channel (0 to 2) |
| 0 : Channel H |
| 1 : Channel A |
@@ -1787,19 +1787,19 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetChronoChlOff |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_OutputChannel) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_OutputChannel) |
+----------------------------------------------------------------------------+
| Task : Resets the output witch has been passed with the |
| parameter b_Channel. Resetting an output means setting |
| an output low. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710
data[0] : Chl ON, Chl OFF , Chl Read , Port Read
-| BYTE_ b_ModulNbr CR_AREF : Selected module number (0 to 3)|
-| BYTE_ b_OutputChannel CR_CHAN : Selection from digital output |
+| unsigned char_ b_ModulNbr CR_AREF : Selected module number (0 to 3)|
+| unsigned char_ b_OutputChannel CR_CHAN : Selection from digital output |
| channel (0 to 2) |
| 0 : Channel H |
| 1 : Channel A |
@@ -1820,24 +1820,24 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadChronoChlValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_InputChannel, |
-| PBYTE_ pb_ChannelStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_InputChannel, |
+| unsigned char *_ pb_ChannelStatus) |
+----------------------------------------------------------------------------+
| Task : Return the status from selected digital input |
| (b_InputChannel) from selected chronometer |
| module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3)|
-| BYTE_ b_InputChannel : Selection from digital input |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
+| unsigned char_ b_InputChannel : Selection from digital input |
| channel (0 to 2) |
| CR_CHAN() 0 : Channel E |
| 1 : Channel F |
| 2 : Channel G |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_ChannelStatus : Digital input channel status.|
+| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel status.|
| data[0] 0 : Channel is not active |
| 1 : Channel is active |
+----------------------------------------------------------------------------+
@@ -1854,17 +1854,17 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadChronoPortValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_PortValue) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_PortValue) |
+----------------------------------------------------------------------------+
| Task : Return the status from digital inputs port from |
| selected (b_ModulNbr) chronometer module. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3)|
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_PortValue : Digital inputs port status.
+| Output Parameters : unsigned char *_ pb_PortValue : Digital inputs port status.
| data[0]
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -1876,18 +1876,18 @@ INT i_APCI1710_ConvertChronoValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_ModulNbr, b_OutputChannel, b_InputChannel, b_IOType;
- DWORD dw_Status;
- PBYTE pb_ChannelStatus;
- PBYTE pb_PortValue;
+ int i_ReturnValue = 0;
+ unsigned char b_ModulNbr, b_OutputChannel, b_InputChannel, b_IOType;
+ unsigned int dw_Status;
+ unsigned char *pb_ChannelStatus;
+ unsigned char *pb_PortValue;
b_ModulNbr = CR_AREF(insn->chanspec);
i_ReturnValue = insn->n;
- b_IOType = (BYTE) data[0];
+ b_IOType = (unsigned char) data[0];
/**************************/
/* Test the module number */
@@ -1915,14 +1915,14 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
case APCI1710_CHRONO_SET_CHANNELOFF:
b_OutputChannel =
- (BYTE) CR_CHAN(insn->chanspec);
+ (unsigned char) CR_CHAN(insn->chanspec);
if (b_OutputChannel <= 2) {
outl(0, devpriv->s_BoardInfos.
ui_Address + 20 +
(b_OutputChannel * 4) +
(64 * b_ModulNbr));
- } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))
+ } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
else {
/****************************************/
/* The selected digital output is wrong */
@@ -1931,21 +1931,21 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
DPRINTK("The selected digital output is wrong\n");
i_ReturnValue = -4;
- } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))
+ } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
break;
case APCI1710_CHRONO_SET_CHANNELON:
b_OutputChannel =
- (BYTE) CR_CHAN(insn->chanspec);
+ (unsigned char) CR_CHAN(insn->chanspec);
if (b_OutputChannel <= 2) {
outl(1, devpriv->s_BoardInfos.
ui_Address + 20 +
(b_OutputChannel * 4) +
(64 * b_ModulNbr));
- } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))
+ } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
else {
/****************************************/
/* The selected digital output is wrong */
@@ -1954,7 +1954,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
DPRINTK("The selected digital output is wrong\n");
i_ReturnValue = -4;
- } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))
+ } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
break;
@@ -1962,9 +1962,9 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
/**********************************/
/* Test the digital input channel */
/**********************************/
- pb_ChannelStatus = (PBYTE) & data[0];
+ pb_ChannelStatus = (unsigned char *) &data[0];
b_InputChannel =
- (BYTE) CR_CHAN(insn->chanspec);
+ (unsigned char) CR_CHAN(insn->chanspec);
if (b_InputChannel <= 2) {
@@ -1975,10 +1975,10 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
(64 * b_ModulNbr));
*pb_ChannelStatus =
- (BYTE) (((dw_Status >>
+ (unsigned char) (((dw_Status >>
b_InputChannel)
& 1) ^ 1);
- } // if ((b_InputChannel >= 0) && (b_InputChannel <= 2))
+ } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */
else {
/***************************************/
/* The selected digital input is wrong */
@@ -1986,13 +1986,13 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
DPRINTK("The selected digital input is wrong\n");
i_ReturnValue = -4;
- } // if ((b_InputChannel >= 0) && (b_InputChannel <= 2))
+ } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */
break;
case APCI1710_CHRONO_READ_PORT:
- pb_PortValue = (PBYTE) & data[0];
+ pb_PortValue = (unsigned char *) &data[0];
dw_Status =
inl(devpriv->s_BoardInfos.
@@ -2000,7 +2000,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
(64 * b_ModulNbr));
*pb_PortValue =
- (BYTE) ((dw_Status & 0x7) ^ 7);
+ (unsigned char) ((dw_Status & 0x7) ^ 7);
break;
}
} else {
@@ -2028,5 +2028,5 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h
index 26b50cefee5a..29bad1d144a1 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h
@@ -35,10 +35,10 @@
/*
* CHRONOMETER INISIALISATION FUNCTION
*/
-INT i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
+int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
@@ -46,29 +46,29 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
/*
* CHRONOMETER READ FUNCTION
*/
-INT i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_ChronoStatus);
+int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus);
-INT i_APCI1710_ReadChronoValue(struct comedi_device *dev,
- BYTE b_ModulNbr,
- UINT ui_TimeOut, PBYTE pb_ChronoStatus,
- PULONG pul_ChronoValue);
+int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus,
+ unsigned int *pul_ChronoValue);
-INT i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
- BYTE b_ModulNbr,
- ULONG ul_ChronoValue,
- PULONG pul_Hour,
- PBYTE pb_Minute,
- PBYTE pb_Second,
- PUINT pui_MilliSecond, PUINT pui_MicroSecond,
- PUINT pui_NanoSecond);
+int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned int ul_ChronoValue,
+ unsigned int *pul_Hour,
+ unsigned char *pb_Minute,
+ unsigned char *pb_Second,
+ unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond,
+ unsigned int *pui_NanoSecond);
/*
* CHRONOMETER DIGITAL INPUT OUTPUT FUNCTION
*/
-INT i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
+int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c
index 8be27aedaaf5..f3e47e5791db 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -61,7 +61,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, |
+| Function Name : int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, |
| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)|
+----------------------------------------------------------------------------+
| Task : Configure the digital I/O operating mode from selected |
@@ -70,14 +70,14 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| I/O. |
+----------------------------------------------------------------------------+
| Input Parameters : |
-| BYTE_ b_ModulNbr data[0]: Module number to |
+| unsigned char_ b_ModulNbr data[0]: Module number to |
| configure (0 to 3) |
-| BYTE_ b_ChannelAMode data[1] : Channel A mode selection |
+| unsigned char_ b_ChannelAMode data[1] : Channel A mode selection |
| 0 : Channel used for digital |
| input |
| 1 : Channel used for digital |
| output |
-| BYTE_ b_ChannelBMode data[2] : Channel B mode selection |
+| unsigned char_ b_ChannelBMode data[2] : Channel B mode selection |
| 0 : Channel used for digital |
| input |
| 1 : Channel used for digital |
@@ -99,19 +99,19 @@ Activates and deactivates the digital output memory.
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_ModulNbr, b_ChannelAMode, b_ChannelBMode;
- BYTE b_MemoryOnOff, b_ConfigType;
- INT i_ReturnValue = 0;
- DWORD dw_WriteConfig = 0;
-
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_ConfigType = (BYTE) data[0]; // Memory or Init
- b_ChannelAMode = (BYTE) data[1];
- b_ChannelBMode = (BYTE) data[2];
- b_MemoryOnOff = (BYTE) data[1]; // if memory operation
+ unsigned char b_ModulNbr, b_ChannelAMode, b_ChannelBMode;
+ unsigned char b_MemoryOnOff, b_ConfigType;
+ int i_ReturnValue = 0;
+ unsigned int dw_WriteConfig = 0;
+
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_ConfigType = (unsigned char) data[0]; /* Memory or Init */
+ b_ChannelAMode = (unsigned char) data[1];
+ b_ChannelBMode = (unsigned char) data[2];
+ b_MemoryOnOff = (unsigned char) data[1]; /* if memory operation */
i_ReturnValue = insn->n;
/**************************/
@@ -126,7 +126,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub
switch (b_ConfigType) {
case APCI1710_DIGIO_MEMORYONOFF:
- if (b_MemoryOnOff) // If Memory ON
+ if (b_MemoryOnOff) /* If Memory ON */
{
/****************************/
/* Set the output memory on */
@@ -140,7 +140,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub
/***************************/
devpriv->s_ModuleInfo[b_ModulNbr].
s_DigitalIOInfo.dw_OutputMemory = 0;
- } else // If memory off
+ } else /* If memory off */
{
/*****************************/
/* Set the output memory off */
@@ -197,7 +197,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub
/*****************************************/
dw_WriteConfig =
- (DWORD) (b_ChannelAMode |
+ (unsigned int) (b_ChannelAMode |
(b_ChannelBMode * 2));
/***************************/
@@ -233,7 +233,7 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub
DPRINTK("The module is not a digital I/O module\n");
i_ReturnValue = -3;
}
- } // end of Switch
+ } /* end of Switch */
printk("Return Value %d\n", i_ReturnValue);
return i_ReturnValue;
}
@@ -257,9 +257,9 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub
|
-| BYTE_ b_ModulNbr CR_AREF(chanspec) : Selected module number |
+| unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number |
| (0 to 3) |
-| BYTE_ b_InputChannel CR_CHAN(chanspec) : Selection from digital |
+| unsigned char_ b_InputChannel CR_CHAN(chanspec) : Selection from digital |
| input ( 0 to 6) |
| 0 : Channel C |
| 1 : Channel D |
@@ -288,22 +288,22 @@ INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
*/
-//_INT_ i_APCI1710_ReadDigitalIOChlValue (BYTE_ b_BoardHandle,
-// BYTE_ b_ModulNbr,
-// BYTE_ b_InputChannel,
-//
-// PBYTE_ pb_ChannelStatus)
-INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+/* _INT_ i_APCI1710_ReadDigitalIOChlValue (unsigned char_ b_BoardHandle, */
+/*
+* unsigned char_ b_ModulNbr, unsigned char_ b_InputChannel,
+* unsigned char *_ pb_ChannelStatus)
+*/
+int i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg;
- BYTE b_ModulNbr, b_InputChannel;
- PBYTE pb_ChannelStatus;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_InputChannel = (BYTE) CR_CHAN(insn->chanspec);
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg;
+ unsigned char b_ModulNbr, b_InputChannel;
+ unsigned char *pb_ChannelStatus;
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec);
data[0] = 0;
- pb_ChannelStatus = (PBYTE) & data[0];
+ pb_ChannelStatus = (unsigned char *) &data[0];
i_ReturnValue = insn->n;
/**************************/
@@ -356,7 +356,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
i_ReturnValue =
-6;
}
- } // if (b_InputChannel == 5)
+ } /* if (b_InputChannel == 5) */
else {
/***************************/
/* Test the channel B mode */
@@ -375,8 +375,8 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
i_ReturnValue =
-7;
}
- } // if (b_InputChannel == 5)
- } // if (b_InputChannel > 4)
+ } /* if (b_InputChannel == 5) */
+ } /* if (b_InputChannel > 4) */
/***********************/
/* Test if error occur */
@@ -387,11 +387,10 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
/* Read all digital input */
/**************************/
- //INPDW (ps_APCI1710Variable->
- // s_Board [b_BoardHandle].
- // s_BoardInfos.
- // ui_Address + (64 * b_ModulNbr),
- // &dw_StatusReg);
+/*
+* INPDW (ps_APCI1710Variable-> s_Board [b_BoardHandle].
+* s_BoardInfos. ui_Address + (64 * b_ModulNbr), &dw_StatusReg);
+*/
dw_StatusReg =
inl(devpriv->
@@ -400,11 +399,11 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
(64 * b_ModulNbr));
*pb_ChannelStatus =
- (BYTE) ((dw_StatusReg ^
+ (unsigned char) ((dw_StatusReg ^
0x1C) >>
b_InputChannel) & 1;
- } // if (i_ReturnValue == 0)
+ } /* if (i_ReturnValue == 0) */
} else {
/*******************************/
/* Digital I/O not initialised */
@@ -434,7 +433,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -445,7 +444,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device
+| Function Name : int i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device
|*dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)
+----------------------------------------------------------------------------+
@@ -453,9 +452,9 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
| parameter b_Channel. Setting an output means setting |
| an ouput high. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr (aref ) : Selected module number (0 to 3)|
-| BYTE_ b_OutputChannel (CR_CHAN) : Selection from digital output |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr (aref ) : Selected module number (0 to 3)|
+| unsigned char_ b_OutputChannel (CR_CHAN) : Selection from digital output |
| channel (0 to 2) |
| 0 : Channel H |
| 1 : Channel A |
@@ -478,15 +477,16 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-//_INT_ i_APCI1710_SetDigitalIOChlOn (BYTE_ b_BoardHandle,
-// BYTE_ b_ModulNbr,
-// BYTE_ b_OutputChannel)
-INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+/*
+* _INT_ i_APCI1710_SetDigitalIOChlOn (unsigned char_ b_BoardHandle,
+* unsigned char_ b_ModulNbr, unsigned char_ b_OutputChannel)
+*/
+int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_WriteValue = 0;
- BYTE b_ModulNbr, b_OutputChannel;
+ int i_ReturnValue = 0;
+ unsigned int dw_WriteValue = 0;
+ unsigned char b_ModulNbr, b_OutputChannel;
i_ReturnValue = insn->n;
b_ModulNbr = CR_AREF(insn->chanspec);
b_OutputChannel = CR_CHAN(insn->chanspec);
@@ -602,7 +602,7 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev,
1 <<
b_OutputChannel;
}
- } // set channel off
+ } /* set channel off */
else {
if (devpriv->
s_ModuleInfo
@@ -627,23 +627,24 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev,
dw_OutputMemory
= dw_WriteValue;
} else {
- /*****************************/
+ /*****************************/
/* Digital Output Memory OFF */
- /*****************************/
- // +Use previously the function "i_APCI1710_SetDigitalIOMemoryOn"
+ /*****************************/
+ /* +Use previously the function "i_APCI1710_SetDigitalIOMemoryOn" */
i_ReturnValue = -8;
}
}
- /*******************/
+ /*******************/
/* Write the value */
- /*******************/
+ /*******************/
- //OUTPDW (ps_APCI1710Variable->
- // s_Board [b_BoardHandle].
- // s_BoardInfos.
- // ui_Address + (64 * b_ModulNbr),
- // dw_WriteValue);
+ /* OUTPDW (ps_APCI1710Variable->
+ * s_Board [b_BoardHandle].
+ * s_BoardInfos. ui_Address + (64 * b_ModulNbr),
+ * dw_WriteValue);
+ */
+*/
outl(dw_WriteValue,
devpriv->s_BoardInfos.
ui_Address + (64 * b_ModulNbr));
@@ -670,7 +671,7 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -690,19 +691,19 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev,
| from selected digital I/O module (b_ModulNbr)
+----------------------------------------------------------------------------+
| Input Parameters :
- BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr CR_AREF(aref) : Selected module number (0 to 3)|
-| BYTE_ b_PortValue CR_CHAN(chanspec) : Output Value ( 0 To 7 )
+ unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr CR_AREF(aref) : Selected module number (0 to 3)|
+| unsigned char_ b_PortValue CR_CHAN(chanspec) : Output Value ( 0 To 7 )
| data[0] read or write port
- data[1] if write then indicate ON or OFF
+| data[1] if write then indicate ON or OFF
- if read : data[1] will return port status.
+| if read : data[1] will return port status.
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
| Return Value :
- INPUT :
+| INPUT :
0: No error |
| -1: The handle parameter of the board is wrong |
@@ -725,75 +726,78 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-//_INT_ i_APCI1710_SetDigitalIOPortOn (BYTE_ b_BoardHandle,
-// BYTE_ b_ModulNbr,
-// BYTE_ b_PortValue)
-INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+/*
+ * _INT_ i_APCI1710_SetDigitalIOPortOn (unsigned char_
+ * b_BoardHandle, unsigned char_ b_ModulNbr, unsigned char_
+ * b_PortValue)
+*/
+int i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_WriteValue = 0;
- DWORD dw_StatusReg;
- BYTE b_ModulNbr, b_PortValue;
- BYTE b_PortOperation, b_PortOnOFF;
-
- PBYTE pb_PortValue;
-
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_PortOperation = (BYTE) data[0]; // Input or output
- b_PortOnOFF = (BYTE) data[1]; // if output then On or Off
- b_PortValue = (BYTE) data[2]; // if out put then Value
+ int i_ReturnValue = 0;
+ unsigned int dw_WriteValue = 0;
+ unsigned int dw_StatusReg;
+ unsigned char b_ModulNbr, b_PortValue;
+ unsigned char b_PortOperation, b_PortOnOFF;
+
+ unsigned char *pb_PortValue;
+
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_PortOperation = (unsigned char) data[0]; /* Input or output */
+ b_PortOnOFF = (unsigned char) data[1]; /* if output then On or Off */
+ b_PortValue = (unsigned char) data[2]; /* if out put then Value */
i_ReturnValue = insn->n;
- pb_PortValue = (PBYTE) & data[0];
-// if input then read value
+ pb_PortValue = (unsigned char *) &data[0];
+/* if input then read value */
switch (b_PortOperation) {
case APCI1710_INPUT:
- /**************************/
+ /**************************/
/* Test the module number */
- /**************************/
+ /**************************/
if (b_ModulNbr < 4) {
- /*******************************/
+ /*******************************/
/* Test if digital I/O counter */
- /*******************************/
+ /*******************************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_DIGITAL_IO) {
- /**********************************************/
+ /**********************************************/
/* Test if the digital I/O module initialised */
- /**********************************************/
+ /**********************************************/
if (devpriv->s_ModuleInfo[b_ModulNbr].
s_DigitalIOInfo.b_DigitalInit == 1) {
- /**************************/
+ /**************************/
/* Read all digital input */
- /**************************/
+ /**************************/
- //INPDW (ps_APCI1710Variable->
- // s_Board [b_BoardHandle].
- // s_BoardInfos.
- // ui_Address + (64 * b_ModulNbr),
- // &dw_StatusReg);
+ /* INPDW (ps_APCI1710Variable->
+ * s_Board [b_BoardHandle].
+ * s_BoardInfos.
+ * ui_Address + (64 * b_ModulNbr),
+ * &dw_StatusReg);
+ */
dw_StatusReg =
inl(devpriv->s_BoardInfos.
ui_Address + (64 * b_ModulNbr));
*pb_PortValue =
- (BYTE) (dw_StatusReg ^ 0x1C);
+ (unsigned char) (dw_StatusReg ^ 0x1C);
} else {
- /*******************************/
+ /*******************************/
/* Digital I/O not initialised */
- /*******************************/
+ /*******************************/
i_ReturnValue = -4;
}
} else {
- /******************************************/
+ /******************************************/
/* The module is not a digital I/O module */
- /******************************************/
+ /******************************************/
i_ReturnValue = -3;
}
@@ -853,11 +857,11 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
i_ReturnValue =
-6;
}
- } // if ((b_PortValue & 2) == 2)
+ } /* if ((b_PortValue & 2) == 2) */
- /**************************/
+ /**************************/
/* Test if channel B used */
- /**************************/
+ /**************************/
if ((b_PortValue & 4) == 4) {
if (devpriv->
@@ -866,33 +870,33 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
s_DigitalIOInfo.
b_ChannelBMode
!= 1) {
- /*******************************************/
+ /*******************************************/
/* The digital channel B is used for input */
- /*******************************************/
+ /*******************************************/
i_ReturnValue =
-7;
}
- } // if ((b_PortValue & 4) == 4)
+ } /* if ((b_PortValue & 4) == 4) */
- /***********************/
+ /***********************/
/* Test if error occur */
- /***********************/
+ /***********************/
if (i_ReturnValue >= 0) {
- //if(data[1])
- //{
+ /* if(data[1]) { */
+
switch (b_PortOnOFF) {
- /*********************************/
+ /*********************************/
/* Test if set Port ON */
- /*********************************/
+ /*********************************/
case APCI1710_ON:
- /*********************************/
+ /*********************************/
/* Test if output memory enabled */
- /*********************************/
+ /*********************************/
if (devpriv->
s_ModuleInfo
@@ -924,7 +928,7 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
}
break;
- // If Set PORT OFF
+ /* If Set PORT OFF */
case APCI1710_OFF:
/*********************************/
@@ -957,25 +961,26 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
=
dw_WriteValue;
} else {
- /*****************************/
+ /*****************************/
/* Digital Output Memory OFF */
- /*****************************/
+ /*****************************/
i_ReturnValue
=
-8;
}
- } // switch
+ } /* switch */
- /*******************/
+ /*******************/
/* Write the value */
- /*******************/
+ /*******************/
+
+ /* OUTPDW (ps_APCI1710Variable->
+ * s_Board [b_BoardHandle].
+ * s_BoardInfos.
+ * ui_Address + (64 * b_ModulNbr),
+ * dw_WriteValue); */
- // OUTPDW (ps_APCI1710Variable->
- // s_Board [b_BoardHandle].
- // s_BoardInfos.
- // ui_Address + (64 * b_ModulNbr),
- // dw_WriteValue);
outl(dw_WriteValue,
devpriv->
s_BoardInfos.
@@ -983,16 +988,16 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
(64 * b_ModulNbr));
}
} else {
- /**********************/
+ /**********************/
/* Output value wrong */
- /**********************/
+ /**********************/
i_ReturnValue = -4;
}
} else {
- /*******************************/
+ /*******************************/
/* Digital I/O not initialised */
- /*******************************/
+ /*******************************/
i_ReturnValue = -5;
}
@@ -1015,6 +1020,6 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device * dev,
default:
i_ReturnValue = -9;
DPRINTK("NO INPUT/OUTPUT specified\n");
- } //switch INPUT / OUTPUT
- return (i_ReturnValue);
+ } /* switch INPUT / OUTPUT */
+ return i_ReturnValue;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h
index 5ef157a55ca1..af1b9cdecfb3 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h
@@ -27,20 +27,20 @@
/*
* DIGITAL I/O INISIALISATION FUNCTION
*/
-INT i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/*
* INPUT OUTPUT FUNCTIONS
*/
-INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev,
+int i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev,
+int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev,
+int i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c
index 1062f2fdec30..6c092efee7bd 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -61,7 +61,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
-| INT i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,struct comedi_subdevice *s,
+| int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data)
+----------------------------------------------------------------------------+
@@ -75,58 +75,58 @@ struct comedi_insn *insn,unsigned int *data)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_ConfigType;
- INT i_ReturnValue = 0;
+ unsigned int ui_ConfigType;
+ int i_ReturnValue = 0;
ui_ConfigType = CR_CHAN(insn->chanspec);
printk("\nINC_CPT");
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
switch (ui_ConfigType) {
case APCI1710_INCCPT_INITCOUNTER:
i_ReturnValue = i_APCI1710_InitCounter(dev,
CR_AREF(insn->chanspec),
- (BYTE) data[0],
- (BYTE) data[1],
- (BYTE) data[2], (BYTE) data[3], (BYTE) data[4]);
+ (unsigned char) data[0],
+ (unsigned char) data[1],
+ (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]);
break;
case APCI1710_INCCPT_COUNTERAUTOTEST:
i_ReturnValue = i_APCI1710_CounterAutoTest(dev,
- (PBYTE) & data[0]);
+ (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_INITINDEX:
i_ReturnValue = i_APCI1710_InitIndex(dev,
CR_AREF(insn->chanspec),
- (BYTE) data[0],
- (BYTE) data[1], (BYTE) data[2], (BYTE) data[3]);
+ (unsigned char) data[0],
+ (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]);
break;
case APCI1710_INCCPT_INITREFERENCE:
i_ReturnValue = i_APCI1710_InitReference(dev,
- CR_AREF(insn->chanspec), (BYTE) data[0]);
+ CR_AREF(insn->chanspec), (unsigned char) data[0]);
break;
case APCI1710_INCCPT_INITEXTERNALSTROBE:
i_ReturnValue = i_APCI1710_InitExternalStrobe(dev,
CR_AREF(insn->chanspec),
- (BYTE) data[0], (BYTE) data[1]);
+ (unsigned char) data[0], (unsigned char) data[1]);
break;
case APCI1710_INCCPT_INITCOMPARELOGIC:
i_ReturnValue = i_APCI1710_InitCompareLogic(dev,
- CR_AREF(insn->chanspec), (UINT) data[0]);
+ CR_AREF(insn->chanspec), (unsigned int) data[0]);
break;
case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT:
i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev,
CR_AREF(insn->chanspec),
- (BYTE) data[0],
- (BYTE) data[1], (ULONG) data[2], (PULONG) & data[0]);
+ (unsigned char) data[0],
+ (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]);
break;
default:
@@ -136,19 +136,19 @@ INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdev
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitCounter |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_CounterRange, |
-| BYTE_ b_FirstCounterModus, |
-| BYTE_ b_FirstCounterOption, |
-| BYTE_ b_SecondCounterModus, |
-| BYTE_ b_SecondCounterOption) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_CounterRange, |
+| unsigned char_ b_FirstCounterModus, |
+| unsigned char_ b_FirstCounterOption, |
+| unsigned char_ b_SecondCounterModus, |
+| unsigned char_ b_SecondCounterOption) |
+----------------------------------------------------------------------------+
| Task : Configure the counter operating mode from selected |
| module (b_ModulNbr). You must calling this function be |
@@ -273,17 +273,17 @@ INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdev
| +----------------------+--------------------+----------------------------+ |
| |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| BYTE_ b_CounterRange : Selection form counter |
+| unsigned char_ b_CounterRange : Selection form counter |
| range. |
-| BYTE_ b_FirstCounterModus : First counter operating |
+| unsigned char_ b_FirstCounterModus : First counter operating |
| mode. |
-| BYTE_ b_FirstCounterOption : First counter option. |
-| BYTE_ b_SecondCounterModus : Second counter operating |
+| unsigned char_ b_FirstCounterOption : First counter option. |
+| unsigned char_ b_SecondCounterModus : Second counter operating |
| mode. |
-| BYTE_ b_SecondCounterOption : Second counter option. |
+| unsigned char_ b_SecondCounterOption : Second counter option. |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -299,14 +299,14 @@ INT i_APCI1710_InsnConfigINCCPT(struct comedi_device * dev, struct comedi_subdev
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitCounter(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_CounterRange,
- BYTE b_FirstCounterModus,
- BYTE b_FirstCounterOption,
- BYTE b_SecondCounterModus, BYTE b_SecondCounterOption)
+int i_APCI1710_InitCounter(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_CounterRange,
+ unsigned char b_FirstCounterModus,
+ unsigned char b_FirstCounterOption,
+ unsigned char b_SecondCounterModus, unsigned char b_SecondCounterOption)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/*******************************/
/* Test if incremental counter */
@@ -502,14 +502,14 @@ INT i_APCI1710_InitCounter(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_CounterAutoTest |
-| (BYTE_ b_BoardHandle, |
-| PBYTE_ pb_TestStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char *_ pb_TestStatus) |
+----------------------------------------------------------------------------+
| Task : A test mode is intended for testing the component and |
| the connected periphery. All the 8-bit counter chains |
@@ -535,9 +535,9 @@ INT i_APCI1710_InitCounter(struct comedi_device * dev,
| | 1000 | Error detected of counter 3 | |
| +-----------------+-----------------------------+ |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 | |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_TestStatus : Auto test conclusion. See table|
+| Output Parameters : unsigned char *_ pb_TestStatus : Auto test conclusion. See table|
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
@@ -545,11 +545,11 @@ INT i_APCI1710_InitCounter(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus)
+int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char *pb_TestStatus)
{
- BYTE b_ModulCpt = 0;
- INT i_ReturnValue = 0;
- DWORD dw_LathchValue;
+ unsigned char b_ModulCpt = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_LathchValue;
*pb_TestStatus = 0;
@@ -627,17 +627,17 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : _INT_ i_APCI1710_InitIndex (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_ReferenceAction, |
-| BYTE_ b_IndexOperation, |
-| BYTE_ b_AutoMode, |
-| BYTE_ b_InterruptEnable) |
+| Function Name : _INT_ i_APCI1710_InitIndex (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_ReferenceAction, |
+| unsigned char_ b_IndexOperation, |
+| unsigned char_ b_AutoMode, |
+| unsigned char_ b_InterruptEnable) |
+----------------------------------------------------------------------------+
| Task : Initialise the index corresponding to the selected |
| module (b_ModulNbr). If a INDEX flag occur, you have |
@@ -665,10 +665,10 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus)
| | | value is cleared (32-Bit) | |
| +------------------------+------------------------------------+ |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_ReferenceAction : Determine if the reference |
+| unsigned char_ b_ReferenceAction : Determine if the reference |
| must set or no for the |
| acceptance from index |
| APCI1710_ENABLE : |
@@ -677,15 +677,15 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus)
| APCI1710_DISABLE : |
| Reference have not |
| importance |
-| BYTE_ b_IndexOperation : Index operating mode. |
+| unsigned char_ b_IndexOperation : Index operating mode. |
| See table. |
-| BYTE_ b_AutoMode : Enable or disable the |
+| unsigned char_ b_AutoMode : Enable or disable the |
| automatic index reset. |
| APCI1710_ENABLE : |
| Enable the automatic mode |
| APCI1710_DISABLE : |
| Disable the automatic mode |
-| BYTE_ b_InterruptEnable : Enable or disable the |
+| unsigned char_ b_InterruptEnable : Enable or disable the |
| interrupt. |
| APCI1710_ENABLE : |
| Enable the interrupt |
@@ -708,12 +708,12 @@ INT i_APCI1710_CounterAutoTest(struct comedi_device * dev, PBYTE pb_TestStatus)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitIndex(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_ReferenceAction,
- BYTE b_IndexOperation, BYTE b_AutoMode, BYTE b_InterruptEnable)
+int i_APCI1710_InitIndex(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_ReferenceAction,
+ unsigned char b_IndexOperation, unsigned char b_AutoMode, unsigned char b_InterruptEnable)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -902,7 +902,7 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev,
b_ModeRegister4
|
APCI1710_ENABLE_LATCH_AND_CLEAR;
- } // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
+ } /* if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */
else {
/*****************************************/
/* Clear the latch and clear flag (DQ27) */
@@ -975,7 +975,7 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev,
&
(~APCI1710_INDEX_LATCH_COUNTER);
}
- } // // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
+ } /* // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */
if (b_AutoMode ==
APCI1710_DISABLE)
@@ -1113,15 +1113,15 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitReference |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_ReferenceLevel) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_ReferenceLevel) |
+----------------------------------------------------------------------------+
| Task : Initialise the reference corresponding to the selected |
| module (b_ModulNbr). |
@@ -1136,10 +1136,10 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev,
| | APCI1710_HIGH | Reference occur if "1" | |
| +--------------------+-------------------------+ |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_ReferenceLevel : Reference level. |
+| unsigned char_ b_ReferenceLevel : Reference level. |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -1152,10 +1152,10 @@ INT i_APCI1710_InitIndex(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitReference(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_ReferenceLevel)
+int i_APCI1710_InitReference(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_ReferenceLevel)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -1239,27 +1239,27 @@ INT i_APCI1710_InitReference(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitExternalStrobe |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_ExternalStrobe, |
-| BYTE_ b_ExternalStrobeLevel) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_ExternalStrobe, |
+| unsigned char_ b_ExternalStrobeLevel) |
+----------------------------------------------------------------------------+
| Task : Initialises the external strobe level corresponding to |
| the selected module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_ExternalStrobe : External strobe selection |
+| unsigned char_ b_ExternalStrobe : External strobe selection |
| 0 : External strobe A |
| 1 : External strobe B |
-| BYTE_ b_ExternalStrobeLevel : External strobe level |
+| unsigned char_ b_ExternalStrobeLevel : External strobe level |
| APCI1710_LOW : |
| External latch occurs if "0" |
| APCI1710_HIGH : |
@@ -1277,10 +1277,10 @@ INT i_APCI1710_InitReference(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_ExternalStrobe, BYTE b_ExternalStrobeLevel)
+int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_ExternalStrobe, unsigned char b_ExternalStrobeLevel)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -1335,7 +1335,7 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev,
DPRINTK("External strobe level parameter is wrong\n");
i_ReturnValue = -5;
}
- } // if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1)
+ } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */
else {
/**************************************/
/* External strobe selection is wrong */
@@ -1343,7 +1343,7 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev,
DPRINTK("External strobe selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1)
+ } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */
} else {
/****************************************/
/* Counter not initialised see function */
@@ -1362,24 +1362,24 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitCompareLogic |
- | (BYTE_ b_BoardHandle, |
- | BYTE_ b_ModulNbr, |
- | UINT_ ui_CompareValue) |
+ | (unsigned char_ b_BoardHandle, |
+ | unsigned char_ b_ModulNbr, |
+ | unsigned int_ ui_CompareValue) |
+----------------------------------------------------------------------------+
| Task : Set the 32-Bit compare value. At that moment that the |
| incremental counter arrive to the compare value |
| (ui_CompareValue) a interrupt is generated. |
+----------------------------------------------------------------------------+
- | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
- | BYTE_ b_ModulNbr : Module number to configure |
+ | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+ | unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
- | UINT_ ui_CompareValue : 32-Bit compare value |
+ | unsigned int_ ui_CompareValue : 32-Bit compare value |
+----------------------------------------------------------------------------+
| Output Parameters : -
+----------------------------------------------------------------------------+
@@ -1391,10 +1391,10 @@ INT i_APCI1710_InitExternalStrobe(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitCompareLogic(struct comedi_device * dev,
- BYTE b_ModulNbr, UINT ui_CompareValue)
+int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned int ui_CompareValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -1434,16 +1434,16 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitFrequencyMeasurement |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PCIInputClock, |
-| BYTE_ b_TimingUnity, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PCIInputClock, |
+| unsigned char_ b_TimingUnity, |
| ULONG_ ul_TimingInterval, |
| PULONG_ pul_RealTimingInterval) |
+----------------------------------------------------------------------------+
@@ -1456,10 +1456,10 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev,
| you call up any other function which gives access to |
| the frequency measurement. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Number of the module to be |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
-| BYTE_ b_PCIInputClock : Selection of the PCI bus |
+| unsigned char_ b_PCIInputClock : Selection of the PCI bus |
| clock |
| - APCI1710_30MHZ : |
| The PC has a PCI bus clock |
@@ -1467,7 +1467,7 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev,
| - APCI1710_33MHZ : |
| The PC has a PCI bus clock |
| of 33 MHz |
-| BYTE_ b_TimingUnity : Base time unit (0 to 2) |
+| unsigned char_ b_TimingUnity : Base time unit (0 to 2) |
| 0 : ns |
| 1 : æs |
| 2 : ms |
@@ -1487,16 +1487,16 @@ INT i_APCI1710_InitCompareLogic(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_PCIInputClock,
- BYTE b_TimingUnity,
- ULONG ul_TimingInterval, PULONG pul_RealTimingInterval)
+int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PCIInputClock,
+ unsigned char b_TimingUnity,
+ unsigned int ul_TimingInterval, unsigned int *pul_RealTimingInterval)
{
- INT i_ReturnValue = 0;
- ULONG ul_TimerValue = 0;
+ int i_ReturnValue = 0;
+ unsigned int ul_TimerValue = 0;
double d_RealTimingInterval;
- DWORD dw_Status = 0;
+ unsigned int dw_Status = 0;
/**************************/
/* Test the module number */
@@ -1637,7 +1637,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
i_ReturnValue =
-7;
}
- } // if (b_PCIInputClock == APCI1710_40MHZ)
+ } /* if (b_PCIInputClock == APCI1710_40MHZ) */
/***************************/
/* Test if not error occur */
@@ -1676,7 +1676,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
b_ModeRegister4
|
APCI1710_ENABLE_40MHZ_FREQUENCY;
- } // if (b_PCIInputClock == APCI1710_40MHZ)
+ } /* if (b_PCIInputClock == APCI1710_40MHZ) */
else {
/**********************************/
/* Disable the 40MHz quarz (DQ30) */
@@ -1700,7 +1700,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
&
APCI1710_DISABLE_40MHZ_FREQUENCY;
- } // if (b_PCIInputClock == APCI1710_40MHZ)
+ } /* if (b_PCIInputClock == APCI1710_40MHZ) */
/********************************/
/* Calculate the division fator */
@@ -1720,7 +1720,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(0.00025 * b_PCIInputClock));
@@ -1743,7 +1743,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
*pul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(0.00025 * (double)b_PCIInputClock));
@@ -1790,7 +1790,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(0.25 * b_PCIInputClock));
@@ -1813,7 +1813,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
*pul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(0.25 * (double)b_PCIInputClock));
@@ -1886,7 +1886,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
*pul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(250.0 * (double)b_PCIInputClock));
@@ -1949,7 +1949,7 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
i_ReturnValue =
-3;
}
- } // if (i_ReturnValue == 0)
+ } /* if (i_ReturnValue == 0) */
} else {
/**********************************/
/* Base timing selection is wrong */
@@ -1992,12 +1992,12 @@ INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*########################################################################### */
- //INSN BITS
+ /* INSN BITS */
/*########################################################################### */
/*
@@ -2015,18 +2015,18 @@ struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_BitsType;
- INT i_ReturnValue = 0;
+ unsigned int ui_BitsType;
+ int i_ReturnValue = 0;
ui_BitsType = CR_CHAN(insn->chanspec);
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
switch (ui_BitsType) {
case APCI1710_INCCPT_CLEARCOUNTERVALUE:
i_ReturnValue = i_APCI1710_ClearCounterValue(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_CLEARALLCOUNTERVALUE:
@@ -2035,28 +2035,28 @@ INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevic
case APCI1710_INCCPT_SETINPUTFILTER:
i_ReturnValue = i_APCI1710_SetInputFilter(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) data[0], (BYTE) data[1]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) data[0], (unsigned char) data[1]);
break;
case APCI1710_INCCPT_LATCHCOUNTER:
i_ReturnValue = i_APCI1710_LatchCounter(dev,
- (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
break;
case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE:
i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev,
- (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
break;
case APCI1710_INCCPT_SETDIGITALCHLON:
i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_SETDIGITALCHLOFF:
i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
default:
@@ -2065,20 +2065,20 @@ INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevic
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ClearCounterValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Clear the counter value from selected module |
| (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -2091,9 +2091,9 @@ INT i_APCI1710_InsnBitsINCCPT(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ClearCounterValue(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -2131,17 +2131,17 @@ INT i_APCI1710_ClearCounterValue(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ClearAllCounterValue |
-| (BYTE_ b_BoardHandle) |
+| (unsigned char_ b_BoardHandle) |
+----------------------------------------------------------------------------+
| Task : Clear all counter value. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -2151,10 +2151,10 @@ INT i_APCI1710_ClearCounterValue(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev)
+int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev)
{
- BYTE b_ModulCpt = 0;
- INT i_ReturnValue = 0;
+ unsigned char b_ModulCpt = 0;
+ int i_ReturnValue = 0;
/********************************/
/* Test if counter module found */
@@ -2198,24 +2198,24 @@ INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetInputFilter |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_Module, |
-| BYTE_ b_PCIInputClock, |
-| BYTE_ b_Filter) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_Module, |
+| unsigned char_ b_PCIInputClock, |
+| unsigned char_ b_Filter) |
+----------------------------------------------------------------------------+
| Task : Disable or enable the software filter from selected |
| module (b_ModulNbr). b_Filter determine the filter time|
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Number of the module to be |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
-| BYTE_ b_PCIInputClock : Selection of the PCI bus |
+| unsigned char_ b_PCIInputClock : Selection of the PCI bus |
| clock |
| - APCI1710_30MHZ : |
| The PC has a PCI bus clock |
@@ -2226,7 +2226,7 @@ INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev)
| - APCI1710_40MHZ : |
| The APCI1710 has a 40MHz |
| quartz |
-| BYTE_ b_Filter : Filter selection |
+| unsigned char_ b_Filter : Filter selection |
| |
| 30 MHz |
| ------ |
@@ -2297,11 +2297,11 @@ INT i_APCI1710_ClearAllCounterValue(struct comedi_device * dev)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_PCIInputClock, BYTE b_Filter)
+int i_APCI1710_SetInputFilter(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_PCIInputClock, unsigned char b_Filter)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status = 0;
/**************************/
/* Test the module number */
@@ -2365,7 +2365,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
i_ReturnValue =
-6;
}
- } // if (b_PCIInputClock == APCI1710_40MHZ)
+ } /* if (b_PCIInputClock == APCI1710_40MHZ) */
/***************************/
/* Test if error not occur */
@@ -2401,7 +2401,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
|
APCI1710_ENABLE_40MHZ_FILTER;
- } // if (b_PCIInputClock == APCI1710_40MHZ)
+ } /* if (b_PCIInputClock == APCI1710_40MHZ) */
else {
/**********************************/
/* Disable the 40MHz quarz (DQ31) */
@@ -2425,7 +2425,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
&
APCI1710_DISABLE_40MHZ_FILTER;
- } // if (b_PCIInputClock == APCI1710_40MHZ)
+ } /* if (b_PCIInputClock == APCI1710_40MHZ) */
/************************/
/* Set the filter value */
@@ -2486,8 +2486,8 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
ui_Address +
20 +
(64 * b_ModulNbr));
- } // if (i_ReturnValue == 0)
- } // if (b_Filter < 16)
+ } /* if (i_ReturnValue == 0) */
+ } /* if (b_Filter < 16) */
else {
/**************************************/
/* The selected filter value is wrong */
@@ -2495,8 +2495,8 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
DPRINTK("The selected filter value is wrong\n");
i_ReturnValue = -5;
- } // if (b_Filter < 16)
- } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ))
+ } /* if (b_Filter < 16) */
+ } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */
else {
/*****************************************/
/* The selected PCI input clock is wrong */
@@ -2504,7 +2504,7 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
DPRINTK("The selected PCI input clock is wrong\n");
i_ReturnValue = 4;
- } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ))
+ } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */
} else {
/**************************************/
/* The module is not a counter module */
@@ -2530,23 +2530,23 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : _INT_ i_APCI1710_LatchCounter (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_LatchReg) |
+| Function Name : _INT_ i_APCI1710_LatchCounter (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_LatchReg) |
+----------------------------------------------------------------------------+
| Task : Latch the courant value from selected module |
| (b_ModulNbr) in to the selected latch register |
| (b_LatchReg). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_LatchReg : Selected latch register |
+| unsigned char_ b_LatchReg : Selected latch register |
| 0 : for the first latch register |
| 1 : for the second latch register |
+----------------------------------------------------------------------------+
@@ -2561,10 +2561,10 @@ INT i_APCI1710_SetInputFilter(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_LatchCounter(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_LatchReg)
+int i_APCI1710_LatchCounter(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_LatchReg)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -2616,25 +2616,25 @@ INT i_APCI1710_LatchCounter(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetIndexAndReferenceSource |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_SourceSelection) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_SourceSelection) |
+----------------------------------------------------------------------------+
| Task : Determine the hardware source for the index and the |
| reference logic. Per default the index logic is |
| connected to the difference input C and the reference |
| logic is connected to the 24V input E |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_SourceSelection : APCI1710_SOURCE_0 : |
+| unsigned char_ b_SourceSelection : APCI1710_SOURCE_0 : |
| The index logic is connected |
| to the difference input C and|
| the reference logic is |
@@ -2658,10 +2658,10 @@ INT i_APCI1710_LatchCounter(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_SourceSelection)
+int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_SourceSelection)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -2735,7 +2735,7 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev,
b_ModeRegister4 &
APCI1710_DEFAULT_INDEX_RFERENCE;
}
- } // if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1)
+ } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */
else {
/*********************************/
/* The source selection is wrong */
@@ -2743,7 +2743,7 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev,
DPRINTK("The source selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1)
+ } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */
} else {
/**************************************/
/* The module is not a counter module */
@@ -2769,20 +2769,20 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetDigitalChlOn |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Sets the digital output H Setting an output means |
| setting an ouput high. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Number of the module to be |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -2795,9 +2795,9 @@ INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_SetDigitalChlOn(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -2849,20 +2849,20 @@ INT i_APCI1710_SetDigitalChlOn(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetDigitalChlOff |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Resets the digital output H. Resetting an output means |
| setting an ouput low. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Number of the module to be |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -2875,9 +2875,9 @@ INT i_APCI1710_SetDigitalChlOn(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_SetDigitalChlOff(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -2929,12 +2929,12 @@ INT i_APCI1710_SetDigitalChlOff(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*########################################################################### */
- // INSN WRITE
+ /* INSN WRITE */
/*########################################################################### */
/*
@@ -2951,65 +2951,65 @@ struct comedi_insn *insn,unsigned int *data) |
| Return Value :
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWriteINCCPT(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_WriteType;
- INT i_ReturnValue = 0;
+ unsigned int ui_WriteType;
+ int i_ReturnValue = 0;
ui_WriteType = CR_CHAN(insn->chanspec);
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
switch (ui_WriteType) {
case APCI1710_INCCPT_ENABLELATCHINTERRUPT:
i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_DISABLELATCHINTERRUPT:
i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE:
i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) data[0], (UINT) data[1]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) data[0], (unsigned int) data[1]);
break;
case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE:
i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev,
- (BYTE) CR_AREF(insn->chanspec), (ULONG) data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]);
break;
case APCI1710_INCCPT_ENABLEINDEX:
- i_APCI1710_EnableIndex(dev, (BYTE) CR_AREF(insn->chanspec));
+ i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_DISABLEINDEX:
i_ReturnValue = i_APCI1710_DisableIndex(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_ENABLECOMPARELOGIC:
i_ReturnValue = i_APCI1710_EnableCompareLogic(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_DISABLECOMPARELOGIC:
i_ReturnValue = i_APCI1710_DisableCompareLogic(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT:
i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev,
- (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
break;
case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT:
i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev,
- (BYTE) CR_AREF(insn->chanspec));
+ (unsigned char) CR_AREF(insn->chanspec));
break;
default:
@@ -3018,21 +3018,21 @@ INT i_APCI1710_InsnWriteINCCPT(struct comedi_device * dev, struct comedi_subdevi
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnableLatchInterrupt |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Enable the latch interrupt from selected module |
| (b_ModulNbr). Each software or hardware latch occur a |
| interrupt. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -3047,9 +3047,9 @@ INT i_APCI1710_InsnWriteINCCPT(struct comedi_device * dev, struct comedi_subdevi
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_EnableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3105,20 +3105,20 @@ INT i_APCI1710_EnableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_DisableLatchInterrupt |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Disable the latch interrupt from selected module |
| (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -3133,9 +3133,9 @@ INT i_APCI1710_EnableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_DisableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3198,27 +3198,27 @@ INT i_APCI1710_DisableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Write16BitCounterValue |
-| (BYTE_ b_BoardHandle |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_SelectedCounter, |
-| UINT_ ui_WriteValue) |
+| (unsigned char_ b_BoardHandle |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_SelectedCounter, |
+| unsigned int_ ui_WriteValue) |
+----------------------------------------------------------------------------+
| Task : Write a 16-Bit value (ui_WriteValue) in to the selected|
| 16-Bit counter (b_SelectedCounter) from selected module|
| (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_SelectedCounter : Selected 16-Bit counter |
+| unsigned char_ b_SelectedCounter : Selected 16-Bit counter |
| (0 or 1) |
-| UINT_ ui_WriteValue : 16-Bit write value |
+| unsigned int_ ui_WriteValue : 16-Bit write value |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -3231,10 +3231,10 @@ INT i_APCI1710_DisableLatchInterrupt(struct comedi_device * dev, BYTE b_ModulNbr
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_SelectedCounter, UINT ui_WriteValue)
+int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_SelectedCounter, unsigned int ui_WriteValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3257,7 +3257,7 @@ INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev,
/* Write the value */
/*******************/
- outl((ULONG) ((ULONG) (ui_WriteValue) << (16 *
+ outl((unsigned int) ((unsigned int) (ui_WriteValue) << (16 *
b_SelectedCounter)),
devpriv->s_BoardInfos.ui_Address + 8 +
(b_SelectedCounter * 4) +
@@ -3288,21 +3288,21 @@ INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Write32BitCounterValue |
-| (BYTE_ b_BoardHandle |
-| BYTE_ b_ModulNbr, |
+| (unsigned char_ b_BoardHandle |
+| unsigned char_ b_ModulNbr, |
| ULONG_ ul_WriteValue) |
+----------------------------------------------------------------------------+
| Task : Write a 32-Bit value (ui_WriteValue) in to the selected|
| module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
| ULONG_ ul_WriteValue : 32-Bit write value |
+----------------------------------------------------------------------------+
@@ -3316,10 +3316,10 @@ INT i_APCI1710_Write16BitCounterValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_Write32BitCounterValue(struct comedi_device * dev,
- BYTE b_ModulNbr, ULONG ul_WriteValue)
+int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned int ul_WriteValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3357,18 +3357,18 @@ INT i_APCI1710_Write32BitCounterValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : _INT_ i_APCI1710_EnableIndex (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| Function Name : _INT_ i_APCI1710_EnableIndex (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Enable the INDEX actions |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -3383,10 +3383,10 @@ INT i_APCI1710_Write32BitCounterValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_EnableIndex(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
- ULONG ul_InterruptLatchReg;
+ int i_ReturnValue = 0;
+ unsigned int ul_InterruptLatchReg;
/**************************/
/* Test the module number */
@@ -3455,18 +3455,18 @@ INT i_APCI1710_EnableIndex(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : _INT_ i_APCI1710_DisableIndex (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| Function Name : _INT_ i_APCI1710_DisableIndex (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Disable the INDEX actions |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -3481,9 +3481,9 @@ INT i_APCI1710_EnableIndex(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_DisableIndex(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3549,21 +3549,21 @@ INT i_APCI1710_DisableIndex(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnableCompareLogic |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Enable the 32-Bit compare logic. At that moment that |
| the incremental counter arrive to the compare value a |
| interrupt is generated. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : -
@@ -3580,9 +3580,9 @@ INT i_APCI1710_DisableIndex(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_EnableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3653,19 +3653,19 @@ INT i_APCI1710_EnableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_DisableCompareLogic |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Disable the 32-Bit compare logic.
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : -
@@ -3680,9 +3680,9 @@ INT i_APCI1710_EnableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_DisableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3753,22 +3753,22 @@ INT i_APCI1710_DisableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr)
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnableFrequencyMeasurement |
- | (BYTE_ b_BoardHandle, |
- | BYTE_ b_ModulNbr, |
- | BYTE_ b_InterruptEnable) |
+ | (unsigned char_ b_BoardHandle, |
+ | unsigned char_ b_ModulNbr, |
+ | unsigned char_ b_InterruptEnable) |
+----------------------------------------------------------------------------+
| Task : Enables the frequency measurement function |
+----------------------------------------------------------------------------+
- | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
- | BYTE_ b_ModulNbr : Number of the module to be |
+ | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+ | unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
- | BYTE_ b_InterruptEnable: Enable or disable the |
+ | unsigned char_ b_InterruptEnable: Enable or disable the |
| interrupt. |
| APCI1710_ENABLE: |
| Enable the interrupt |
@@ -3789,10 +3789,10 @@ INT i_APCI1710_DisableCompareLogic(struct comedi_device * dev, BYTE b_ModulNbr)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_InterruptEnable)
+int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_InterruptEnable)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3909,19 +3909,19 @@ INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_DisableFrequencyMeasurement |
- | (BYTE_ b_BoardHandle, |
- | BYTE_ b_ModulNbr) |
+ | (unsigned char_ b_BoardHandle, |
+ | unsigned char_ b_ModulNbr) |
+----------------------------------------------------------------------------+
| Task : Disables the frequency measurement function |
+----------------------------------------------------------------------------+
- | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
- | BYTE_ b_ModulNbr : Number of the module to be |
+ | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+ | unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -3936,9 +3936,9 @@ INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device * dev, BYTE b_ModulNbr)
+int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, unsigned char b_ModulNbr)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -3976,9 +3976,9 @@ INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device * dev, BYTE b_Mo
s_ByteModeRegister.
b_ModeRegister3 &
APCI1710_DISABLE_FREQUENCY
- // Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared
+ /* Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */
& APCI1710_DISABLE_FREQUENCY_INT;
- // End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared
+ /* End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */
/***************************/
/* Write the configuration */
@@ -4026,12 +4026,12 @@ INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device * dev, BYTE b_Mo
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*########################################################################### */
- // INSN READ
+ /* INSN READ */
/*########################################################################### */
@@ -4049,82 +4049,82 @@ struct comedi_insn *insn,unsigned int *data) |
| Return Value :
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadINCCPT(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_ReadType;
- INT i_ReturnValue = 0;
+ unsigned int ui_ReadType;
+ int i_ReturnValue = 0;
ui_ReadType = CR_CHAN(insn->chanspec);
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
switch (ui_ReadType) {
case APCI1710_INCCPT_READLATCHREGISTERSTATUS:
i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) CR_RANGE(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_READLATCHREGISTERVALUE:
i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) CR_RANGE(insn->chanspec), (PULONG) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
printk("Latch Register Value %d\n", data[0]);
break;
case APCI1710_INCCPT_READ16BITCOUNTERVALUE:
i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) CR_RANGE(insn->chanspec), (PUINT) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
break;
case APCI1710_INCCPT_READ32BITCOUNTERVALUE:
i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev,
- (BYTE) CR_AREF(insn->chanspec), (PULONG) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]);
break;
case APCI1710_INCCPT_GETINDEXSTATUS:
i_ReturnValue = i_APCI1710_GetIndexStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_GETREFERENCESTATUS:
i_ReturnValue = i_APCI1710_GetReferenceStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_GETUASSTATUS:
i_ReturnValue = i_APCI1710_GetUASStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_GETCBSTATUS:
i_ReturnValue = i_APCI1710_GetCBStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_GET16BITCBSTATUS:
i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (PBYTE) & data[0], (PBYTE) & data[1]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char *) &data[0], (unsigned char *) &data[1]);
break;
case APCI1710_INCCPT_GETUDSTATUS:
i_ReturnValue = i_APCI1710_GetUDStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS:
i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev,
- (BYTE) CR_AREF(insn->chanspec), (PBYTE) & data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
break;
case APCI1710_INCCPT_READFREQUENCYMEASUREMENT:
i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (PBYTE) & data[0],
- (PBYTE) & data[1], (PULONG) & data[2]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char *) &data[0],
+ (unsigned char *) &data[1], (unsigned int *) &data[2]);
break;
case APCI1710_INCCPT_READINTERRUPT:
@@ -4155,29 +4155,29 @@ INT i_APCI1710_InsnReadINCCPT(struct comedi_device * dev, struct comedi_subdevic
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadLatchRegisterStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_LatchReg, |
-| PBYTE_ pb_LatchStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_LatchReg, |
+| unsigned char *_ pb_LatchStatus) |
+----------------------------------------------------------------------------+
| Task : Read the latch register status from selected module |
| (b_ModulNbr) and selected latch register (b_LatchReg). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_LatchReg : Selected latch register |
+| unsigned char_ b_LatchReg : Selected latch register |
| 0 : for the first latch register |
| 1 : for the second latch register |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_LatchStatus : Latch register status. |
+| Output Parameters : unsigned char *_ pb_LatchStatus : Latch register status. |
| 0 : No latch occur |
| 1 : A software latch occur |
| 2 : A hardware latch occur |
@@ -4193,11 +4193,11 @@ INT i_APCI1710_InsnReadINCCPT(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_LatchReg, PBYTE pb_LatchStatus)
+int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_LatchReg, unsigned char *pb_LatchStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_LatchReg;
+ int i_ReturnValue = 0;
+ unsigned int dw_LatchReg;
/**************************/
/* Test the module number */
@@ -4220,7 +4220,7 @@ INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev,
ui_Address + (64 * b_ModulNbr));
*pb_LatchStatus =
- (BYTE) ((dw_LatchReg >> (b_LatchReg *
+ (unsigned char) ((dw_LatchReg >> (b_LatchReg *
4)) & 0x3);
} else {
/**************************************************/
@@ -4248,24 +4248,24 @@ INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadLatchRegisterValue |
-| (BYTE_ b_BoardHandle,|
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_LatchReg, |
+| (unsigned char_ b_BoardHandle,|
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_LatchReg, |
| PULONG_ pul_LatchValue) |
+----------------------------------------------------------------------------+
| Task : Read the latch register value from selected module |
| (b_ModulNbr) and selected latch register (b_LatchReg). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_LatchReg : Selected latch register |
+| unsigned char_ b_LatchReg : Selected latch register |
| 0 : for the first latch register |
| 1 : for the second latch register |
+----------------------------------------------------------------------------+
@@ -4280,10 +4280,10 @@ INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_LatchReg, PULONG pul_LatchValue)
+int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_LatchReg, unsigned int *pul_LatchValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -4332,28 +4332,28 @@ INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Read16BitCounterValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_SelectedCounter, |
-| PUINT_ pui_CounterValue) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_SelectedCounter, |
+| unsigned int *_ pui_CounterValue) |
+----------------------------------------------------------------------------+
| Task : Latch the selected 16-Bit counter (b_SelectedCounter) |
| from selected module (b_ModulNbr) in to the first |
| latch register and return the latched value. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| BYTE_ b_SelectedCounter : Selected 16-Bit counter |
+| unsigned char_ b_SelectedCounter : Selected 16-Bit counter |
| (0 or 1) |
+----------------------------------------------------------------------------+
-| Output Parameters : PUINT_ pui_CounterValue : 16-Bit counter value |
+| Output Parameters : unsigned int *_ pui_CounterValue : 16-Bit counter value |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
@@ -4364,11 +4364,11 @@ INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev,
- BYTE b_ModulNbr, BYTE b_SelectedCounter, PUINT pui_CounterValue)
+int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_SelectedCounter, unsigned int *pui_CounterValue)
{
- INT i_ReturnValue = 0;
- DWORD dw_LathchValue = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_LathchValue = 0;
/**************************/
/* Test the module number */
@@ -4402,7 +4402,7 @@ INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev,
ui_Address + 4 + (64 * b_ModulNbr));
*pui_CounterValue =
- (UINT) ((dw_LathchValue >> (16 *
+ (unsigned int) ((dw_LathchValue >> (16 *
b_SelectedCounter)) &
0xFFFFU);
} else {
@@ -4431,22 +4431,22 @@ INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Read32BitCounterValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
| PULONG_ pul_CounterValue) |
+----------------------------------------------------------------------------+
| Task : Latch the 32-Bit counter from selected module |
| (b_ModulNbr) in to the first latch register and return |
| the latched value. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_CounterValue : 32-Bit counter value |
@@ -4459,10 +4459,10 @@ INT i_APCI1710_Read16BitCounterValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_Read32BitCounterValue(struct comedi_device * dev,
- BYTE b_ModulNbr, PULONG pul_CounterValue)
+int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned int *pul_CounterValue)
{
- INT i_ReturnValue = 0;
+ int i_ReturnValue = 0;
/**************************/
/* Test the module number */
@@ -4507,22 +4507,22 @@ INT i_APCI1710_Read32BitCounterValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : _INT_ i_APCI1710_GetIndexStatus (BYTE_ b_BoardHandle,|
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_IndexStatus)|
+| Function Name : _INT_ i_APCI1710_GetIndexStatus (unsigned char_ b_BoardHandle,|
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_IndexStatus)|
+----------------------------------------------------------------------------+
| Task : Return the index status |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_IndexStatus : 0 : No INDEX occur |
+| Output Parameters : unsigned char *_ pb_IndexStatus : 0 : No INDEX occur |
| 1 : A INDEX occur |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -4535,11 +4535,11 @@ INT i_APCI1710_Read32BitCounterValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetIndexStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_IndexStatus)
+int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_IndexStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -4563,7 +4563,7 @@ INT i_APCI1710_GetIndexStatus(struct comedi_device * dev,
dw_StatusReg = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (64 * b_ModulNbr));
- *pb_IndexStatus = (BYTE) (dw_StatusReg & 1);
+ *pb_IndexStatus = (unsigned char) (dw_StatusReg & 1);
} else {
/*************************************************************/
/* Index not initialised see function "i_APCI1710_InitIndex" */
@@ -4590,23 +4590,23 @@ INT i_APCI1710_GetIndexStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetReferenceStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_ReferenceStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_ReferenceStatus) |
+----------------------------------------------------------------------------+
| Task : Return the reference status |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_ReferenceStatus : 0 : No REFERENCE occur |
+| Output Parameters : unsigned char *_ pb_ReferenceStatus : 0 : No REFERENCE occur |
| 1 : A REFERENCE occur |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -4619,11 +4619,11 @@ INT i_APCI1710_GetIndexStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_ReferenceStatus)
+int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -4649,7 +4649,7 @@ INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev,
ui_Address + 24 + (64 * b_ModulNbr));
*pb_ReferenceStatus =
- (BYTE) (~dw_StatusReg & 1);
+ (unsigned char) (~dw_StatusReg & 1);
} else {
/*********************************************************************/
/* Reference not initialised see function "i_APCI1710_InitReference" */
@@ -4676,23 +4676,23 @@ INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetUASStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_UASStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_UASStatus) |
+----------------------------------------------------------------------------+
| Task : Return the error signal (UAS) status |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_UASStatus : 0 : UAS is low "0" |
+| Output Parameters : unsigned char *_ pb_UASStatus : 0 : UAS is low "0" |
| 1 : UAS is high "1" |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -4703,11 +4703,11 @@ INT i_APCI1710_GetReferenceStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetUASStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_UASStatus)
+int i_APCI1710_GetUASStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_UASStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -4724,7 +4724,7 @@ INT i_APCI1710_GetUASStatus(struct comedi_device * dev,
dw_StatusReg = inl(devpriv->s_BoardInfos.
ui_Address + 24 + (64 * b_ModulNbr));
- *pb_UASStatus = (BYTE) ((dw_StatusReg >> 1) & 1);
+ *pb_UASStatus = (unsigned char) ((dw_StatusReg >> 1) & 1);
} else {
/****************************************/
/* Counter not initialised see function */
@@ -4744,23 +4744,23 @@ INT i_APCI1710_GetUASStatus(struct comedi_device * dev,
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetCBStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_CBStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_CBStatus) |
+----------------------------------------------------------------------------+
| Task : Return the counter overflow status |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_CBStatus : 0 : Counter no overflow |
+| Output Parameters : unsigned char *_ pb_CBStatus : 0 : Counter no overflow |
| 1 : Counter overflow |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -4771,11 +4771,11 @@ INT i_APCI1710_GetUASStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetCBStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_CBStatus)
+int i_APCI1710_GetCBStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_CBStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -4792,7 +4792,7 @@ INT i_APCI1710_GetCBStatus(struct comedi_device * dev,
dw_StatusReg = inl(devpriv->s_BoardInfos.
ui_Address + 16 + (64 * b_ModulNbr));
- *pb_CBStatus = (BYTE) (dw_StatusReg & 1);
+ *pb_CBStatus = (unsigned char) (dw_StatusReg & 1);
} else {
/****************************************/
@@ -4812,31 +4812,31 @@ INT i_APCI1710_GetCBStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Get16BitCBStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_CBStatusCounter0, |
-| PBYTE_ pb_CBStatusCounter1) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_CBStatusCounter0, |
+| unsigned char *_ pb_CBStatusCounter1) |
+----------------------------------------------------------------------------+
| Task : Returns the counter overflow (counter initialised to |
| 2*16-bit) status from selected incremental counter |
| module |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_CBStatusCounter0 : 0 : No overflow occur for |
+| Output Parameters : unsigned char *_ pb_CBStatusCounter0 : 0 : No overflow occur for |
| the first 16-bit |
| counter |
| 1 : Overflow occur for the|
| first 16-bit counter |
-| PBYTE_ pb_CBStatusCounter1 : 0 : No overflow occur for |
+| unsigned char *_ pb_CBStatusCounter1 : 0 : No overflow occur for |
| the second 16-bit |
| counter |
| 1 : Overflow occur for the|
@@ -4853,11 +4853,11 @@ INT i_APCI1710_GetCBStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_CBStatusCounter0, PBYTE pb_CBStatusCounter1)
+int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0, unsigned char *pb_CBStatusCounter1)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -4894,20 +4894,20 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev,
(64 * b_ModulNbr));
*pb_CBStatusCounter1 =
- (BYTE) ((dw_StatusReg >> 0) &
+ (unsigned char) ((dw_StatusReg >> 0) &
1);
*pb_CBStatusCounter0 =
- (BYTE) ((dw_StatusReg >> 1) &
+ (unsigned char) ((dw_StatusReg >> 1) &
1);
- } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136)
+ } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */
else {
/****************************/
/* Firmware revision error */
/****************************/
i_ReturnValue = -5;
- } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136)
- } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10)
+ } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */
+ } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */
else {
/********************************************/
/* Counter not initialised to 2*16-bit mode */
@@ -4916,8 +4916,8 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev,
DPRINTK("Counter not initialised\n");
i_ReturnValue = -4;
- } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10)
- } // if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1)
+ } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */
+ } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */
else {
/****************************************/
/* Counter not initialised see function */
@@ -4926,8 +4926,8 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev,
DPRINTK("Counter not initialised\n");
i_ReturnValue = -3;
- } // if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1)
- } // if (b_ModulNbr < 4)
+ } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */
+ } /* if (b_ModulNbr < 4) */
else {
/*************************************************/
/* The selected module number parameter is wrong */
@@ -4935,25 +4935,25 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev,
DPRINTK("The selected module number parameter is wrong\n");
i_ReturnValue = -2;
- } // if (b_ModulNbr < 4)
+ } /* if (b_ModulNbr < 4) */
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetUDStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_UDStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_UDStatus) |
+----------------------------------------------------------------------------+
| Task : Return the counter progress status |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_UDStatus : 0 : Counter progress in the |
+| Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
| selected mode down |
| 1 : Counter progress in the |
| selected mode up |
@@ -4966,11 +4966,11 @@ INT i_APCI1710_Get16BitCBStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetUDStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_UDStatus)
+int i_APCI1710_GetUDStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_UDStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -4987,7 +4987,7 @@ INT i_APCI1710_GetUDStatus(struct comedi_device * dev,
dw_StatusReg = inl(devpriv->s_BoardInfos.
ui_Address + 24 + (64 * b_ModulNbr));
- *pb_UDStatus = (BYTE) ((dw_StatusReg >> 2) & 1);
+ *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 2) & 1);
} else {
/****************************************/
@@ -5007,24 +5007,24 @@ INT i_APCI1710_GetUDStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetInterruptUDLatchedStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| PBYTE_ pb_UDStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char *_ pb_UDStatus) |
+----------------------------------------------------------------------------+
| Task : Return the counter progress latched status after a |
| index interrupt occur. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_UDStatus : 0 : Counter progress in the |
+| Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
| selected mode down |
| 1 : Counter progress in the |
| selected mode up |
@@ -5040,11 +5040,11 @@ INT i_APCI1710_GetUDStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev,
- BYTE b_ModulNbr, PBYTE pb_UDStatus)
+int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_UDStatus)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
/**************************/
/* Test the module number */
@@ -5074,7 +5074,7 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev,
dw_StatusReg = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (64 * b_ModulNbr));
- *pb_UDStatus = (BYTE) ((dw_StatusReg >> 1) & 1);
+ *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 1) & 1);
} else {
/****************************/
/* No index interrupt occur */
@@ -5100,26 +5100,26 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadFrequencyMeasurement |
- | (BYTE_ b_BoardHandle, |
- | BYTE_ b_ModulNbr, |
- | PBYTE_ pb_Status, |
+ | (unsigned char_ b_BoardHandle, |
+ | unsigned char_ b_ModulNbr, |
+ | unsigned char *_ pb_Status, |
| PULONG_ pul_ReadValue) |
+----------------------------------------------------------------------------+
| Task : Returns the status (pb_Status) and the number of |
| increments in the set time. |
| See function " i_APCI1710_InitFrequencyMeasurement " |
+----------------------------------------------------------------------------+
- | Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
- | BYTE_ b_ModulNbr : Number of the module to be |
+ | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+ | unsigned char_ b_ModulNbr : Number of the module to be |
| configured (0 to 3) |
+----------------------------------------------------------------------------+
- | Output Parameters : PBYTE_ pb_Status : Returns the frequency |
+ | Output Parameters : unsigned char *_ pb_Status : Returns the frequency |
| measurement status |
| 0 : Counting cycle not |
| started. |
@@ -5127,7 +5127,7 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev,
| 2 : Counting cycle stopped. |
| The measurement cycle is |
| completed. |
- | PBYTE_ pb_UDStatus : 0 : Counter progress in the |
+ | unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
| selected mode down |
| 1 : Counter progress in the |
| selected mode up |
@@ -5145,13 +5145,13 @@ INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
- BYTE b_ModulNbr,
- PBYTE pb_Status, PBYTE pb_UDStatus, PULONG pul_ReadValue)
+int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char *pb_Status, unsigned char *pb_UDStatus, unsigned int *pul_ReadValue)
{
- INT i_ReturnValue = 0;
- UINT ui_16BitValue;
- DWORD dw_StatusReg;
+ int i_ReturnValue = 0;
+ unsigned int ui_16BitValue;
+ unsigned int dw_StatusReg;
/**************************/
/* Test the module number */
@@ -5198,7 +5198,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
if (dw_StatusReg & 1) {
*pb_Status = 2;
*pb_UDStatus =
- (BYTE) ((dw_StatusReg >>
+ (unsigned char) ((dw_StatusReg >>
1) & 3);
/******************/
@@ -5224,7 +5224,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
if ((*pul_ReadValue & 0xFFFFU) != 0) {
ui_16BitValue
=
- (UINT)
+ (unsigned int)
*
pul_ReadValue
&
@@ -5247,7 +5247,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
if ((*pul_ReadValue & 0xFFFF0000UL) != 0) {
ui_16BitValue
=
- (UINT)
+ (unsigned int)
(
(*pul_ReadValue
>>
@@ -5281,7 +5281,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
if ((*pul_ReadValue & 0xFFFF0000UL) != 0) {
ui_16BitValue
=
- (UINT)
+ (unsigned int)
(
(*pul_ReadValue
>>
@@ -5307,7 +5307,7 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
if ((*pul_ReadValue & 0xFFFFU) != 0) {
ui_16BitValue
=
- (UINT)
+ (unsigned int)
*
pul_ReadValue
&
@@ -5359,5 +5359,5 @@ INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h
index 5153cf686658..7b481107fe1d 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h
@@ -132,140 +132,140 @@
#define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT 409
/************ Main Functions *************/
-INT i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int * data);
-INT i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
+int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
struct comedi_insn *insn, unsigned int * data);
-INT i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
+int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
struct comedi_insn *insn, unsigned int * data);
-INT i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
+int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
struct comedi_insn *insn, unsigned int * data);
/*********** Supplementary Functions********/
/* INSN CONFIG */
-INT i_APCI1710_InitCounter(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_CounterRange,
- BYTE b_FirstCounterModus,
- BYTE b_FirstCounterOption,
- BYTE b_SecondCounterModus,
- BYTE b_SecondCounterOption);
-
-INT i_APCI1710_CounterAutoTest(struct comedi_device *dev, PBYTE pb_TestStatus);
-
-INT i_APCI1710_InitIndex(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_ReferenceAction,
- BYTE b_IndexOperation, BYTE b_AutoMode,
- BYTE b_InterruptEnable);
-
-INT i_APCI1710_InitReference(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_ReferenceLevel);
-
-INT i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_ExternalStrobe,
- BYTE b_ExternalStrobeLevel);
-
-INT i_APCI1710_InitCompareLogic(struct comedi_device *dev,
- BYTE b_ModulNbr, UINT ui_CompareValue);
-
-INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_PCIInputClock,
- BYTE b_TimingUnity,
- ULONG ul_TimingInterval,
- PULONG pul_RealTimingInterval);
+int i_APCI1710_InitCounter(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_CounterRange,
+ unsigned char b_FirstCounterModus,
+ unsigned char b_FirstCounterOption,
+ unsigned char b_SecondCounterModus,
+ unsigned char b_SecondCounterOption);
+
+int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char * pb_TestStatus);
+
+int i_APCI1710_InitIndex(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_ReferenceAction,
+ unsigned char b_IndexOperation, unsigned char b_AutoMode,
+ unsigned char b_InterruptEnable);
+
+int i_APCI1710_InitReference(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_ReferenceLevel);
+
+int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_ExternalStrobe,
+ unsigned char b_ExternalStrobeLevel);
+
+int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned int ui_CompareValue);
+
+int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PCIInputClock,
+ unsigned char b_TimingUnity,
+ unsigned int ul_TimingInterval,
+ unsigned int *pul_RealTimingInterval);
/* INSN BITS */
-INT i_APCI1710_ClearCounterValue(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_ClearAllCounterValue(struct comedi_device *dev);
+int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev);
-INT i_APCI1710_SetInputFilter(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_PCIInputClock,
- BYTE b_Filter);
+int i_APCI1710_SetInputFilter(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_PCIInputClock,
+ unsigned char b_Filter);
-INT i_APCI1710_LatchCounter(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_LatchReg);
+int i_APCI1710_LatchCounter(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_LatchReg);
-INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_SourceSelection);
+int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_SourceSelection);
-INT i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr);
/* INSN WRITE */
-INT i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_SelectedCounter,
- UINT ui_WriteValue);
+int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_SelectedCounter,
+ unsigned int ui_WriteValue);
-INT i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
- BYTE b_ModulNbr, ULONG ul_WriteValue);
+int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned int ul_WriteValue);
-INT i_APCI1710_EnableIndex(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_DisableIndex(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_EnableCompareLogic(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_DisableCompareLogic(struct comedi_device *dev, BYTE b_ModulNbr);
+int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr);
-INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_InterruptEnable);
+int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_InterruptEnable);
-INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev,
- BYTE b_ModulNbr);
+int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr);
/* INSN READ */
-INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_LatchReg,
- PBYTE pb_LatchStatus);
+int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_LatchReg,
+ unsigned char *pb_LatchStatus);
-INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_LatchReg,
- PULONG pul_LatchValue);
+int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_LatchReg,
+ unsigned int *pul_LatchValue);
-INT i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
- BYTE b_ModulNbr, BYTE b_SelectedCounter,
- PUINT pui_CounterValue);
+int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char b_SelectedCounter,
+ unsigned int *pui_CounterValue);
-INT i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
- BYTE b_ModulNbr, PULONG pul_CounterValue);
+int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned int *pul_CounterValue);
-INT i_APCI1710_GetIndexStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_IndexStatus);
+int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_IndexStatus);
-INT i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_ReferenceStatus);
+int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus);
-INT i_APCI1710_GetUASStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_UASStatus);
+int i_APCI1710_GetUASStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_UASStatus);
-INT i_APCI1710_GetCBStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_CBStatus);
+int i_APCI1710_GetCBStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_CBStatus);
-INT i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_CBStatusCounter0,
- PBYTE pb_CBStatusCounter1);
+int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0,
+ unsigned char *pb_CBStatusCounter1);
-INT i_APCI1710_GetUDStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_UDStatus);
+int i_APCI1710_GetUDStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_UDStatus);
-INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
- BYTE b_ModulNbr, PBYTE pb_UDStatus);
+int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
+ unsigned char b_ModulNbr, unsigned char *pb_UDStatus);
-INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
- BYTE b_ModulNbr,
- PBYTE pb_Status, PBYTE pb_UDStatus,
- PULONG pul_ReadValue);
+int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char *pb_Status, unsigned char *pb_UDStatus,
+ unsigned int *pul_ReadValue);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c
index 3ac6a264ef54..0fc2285c9ef8 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -60,11 +60,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitPulseEncoder |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PulseEncoderNbr, |
-| BYTE_ b_InputLevelSelection, |
-| BYTE_ b_TriggerOutputAction, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PulseEncoderNbr, |
+| unsigned char_ b_InputLevelSelection, |
+| unsigned char_ b_TriggerOutputAction, |
| ULONG_ ul_StartValue) |
+----------------------------------------------------------------------------+
| Task : Configure the pulse encoder operating mode selected via|
@@ -74,12 +74,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| You must calling this function be for you call any |
| other function witch access of pulse encoders. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| BYTE_ b_PulseEncoderNbr : Pulse encoder selection |
+| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection |
| (0 to 3) |
-| BYTE_ b_InputLevelSelection : Input level selection |
+| unsigned char_ b_InputLevelSelection : Input level selection |
| (0 or 1) |
| 0 : Set pulse encoder|
| count the the low|
@@ -87,7 +87,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| 1 : Set pulse encoder|
| count the the |
| high level pulse.|
-| BYTE_ b_TriggerOutputAction : Digital TRIGGER output |
+| unsigned char_ b_TriggerOutputAction : Digital TRIGGER output |
| action |
| 0 : No action |
| 1 : Set the trigger |
@@ -104,11 +104,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| encoder |
| ULONG_ ul_StartValue : Pulse encoder start value|
| (1 to 4294967295)
- b_ModulNbr =(BYTE) CR_AREF(insn->chanspec);
- b_PulseEncoderNbr =(BYTE) data[0];
- b_InputLevelSelection =(BYTE) data[1];
- b_TriggerOutputAction =(BYTE) data[2];
- ul_StartValue =(ULONG) data[3];
+ b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec);
+ b_PulseEncoderNbr =(unsigned char) data[0];
+ b_InputLevelSelection =(unsigned char) data[1];
+ b_TriggerOutputAction =(unsigned char) data[2];
+ ul_StartValue =(unsigned int) data[3];
|
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -123,23 +123,23 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_IntRegister;
+ int i_ReturnValue = 0;
+ unsigned int dw_IntRegister;
- BYTE b_ModulNbr;
- BYTE b_PulseEncoderNbr;
- BYTE b_InputLevelSelection;
- BYTE b_TriggerOutputAction;
- ULONG ul_StartValue;
+ unsigned char b_ModulNbr;
+ unsigned char b_PulseEncoderNbr;
+ unsigned char b_InputLevelSelection;
+ unsigned char b_TriggerOutputAction;
+ unsigned int ul_StartValue;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_PulseEncoderNbr = (BYTE) data[0];
- b_InputLevelSelection = (BYTE) data[1];
- b_TriggerOutputAction = (BYTE) data[2];
- ul_StartValue = (ULONG) data[3];
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_PulseEncoderNbr = (unsigned char) data[0];
+ b_InputLevelSelection = (unsigned char) data[1];
+ b_TriggerOutputAction = (unsigned char) data[2];
+ ul_StartValue = (unsigned int) data[3];
i_ReturnValue = insn->n;
@@ -346,17 +346,17 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnablePulseEncoder |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PulseEncoderNbr, |
-| BYTE_ b_CycleSelection, |
-| BYTE_ b_InterruptHandling) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PulseEncoderNbr, |
+| unsigned char_ b_CycleSelection, |
+| unsigned char_ b_InterruptHandling) |
+----------------------------------------------------------------------------+
| Task : Enableor disable the selected pulse encoder (b_PulseEncoderNbr) |
| from selected module (b_ModulNbr). Each input pulse |
@@ -365,12 +365,12 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev,
| interrupt is generated when the pulse encoder has run |
| down. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| BYTE_ b_PulseEncoderNbr : Pulse encoder selection |
+| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection |
| (0 to 3) |
-| BYTE_ b_CycleSelection : APCI1710_CONTINUOUS: |
+| unsigned char_ b_CycleSelection : APCI1710_CONTINUOUS: |
| Each time the |
| counting value is set|
| on "0", the pulse |
@@ -381,7 +381,7 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev,
| If the counter is set|
| on "0", the pulse |
| encoder is stopped. |
-| BYTE_ b_InterruptHandling : Interrupts can be |
+| unsigned char_ b_InterruptHandling : Interrupts can be |
| generated, when the pulse|
| encoder has run down. |
| With this parameter the |
@@ -393,11 +393,11 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev,
| APCI1710_DISABLE: |
| Interrupts are disabled
- b_ModulNbr =(BYTE) CR_AREF(insn->chanspec);
- b_Action =(BYTE) data[0];
- b_PulseEncoderNbr =(BYTE) data[1];
- b_CycleSelection =(BYTE) data[2];
- b_InterruptHandling =(BYTE) data[3];|
+ b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec);
+ b_Action =(unsigned char) data[0];
+ b_PulseEncoderNbr =(unsigned char) data[1];
+ b_CycleSelection =(unsigned char) data[2];
+ b_InterruptHandling =(unsigned char) data[3];|
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -414,22 +414,22 @@ INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_ModulNbr;
- BYTE b_PulseEncoderNbr;
- BYTE b_CycleSelection;
- BYTE b_InterruptHandling;
- BYTE b_Action;
+ int i_ReturnValue = 0;
+ unsigned char b_ModulNbr;
+ unsigned char b_PulseEncoderNbr;
+ unsigned char b_CycleSelection;
+ unsigned char b_InterruptHandling;
+ unsigned char b_Action;
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_Action = (BYTE) data[0];
- b_PulseEncoderNbr = (BYTE) data[1];
- b_CycleSelection = (BYTE) data[2];
- b_InterruptHandling = (BYTE) data[3];
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_Action = (unsigned char) data[0];
+ b_PulseEncoderNbr = (unsigned char) data[1];
+ b_CycleSelection = (unsigned char) data[2];
+ b_InterruptHandling = (unsigned char) data[3];
/***********************************/
/* Test the selected module number */
@@ -515,7 +515,7 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev,
| (1UL
<<
b_PulseEncoderNbr);
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
}
@@ -629,7 +629,7 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev,
(64 * b_ModulNbr));
break;
- } // switch End
+ } /* switch End */
} else {
/*********************************/
@@ -656,39 +656,39 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadPulseEncoderStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PulseEncoderNbr, |
-| PBYTE_ pb_Status) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PulseEncoderNbr, |
+| unsigned char *_ pb_Status) |
+----------------------------------------------------------------------------+
| Task APCI1710_PULSEENCODER_READ : Reads the pulse encoder status
and valuefrom selected pulse |
| encoder (b_PulseEncoderNbr) from selected module |
| (b_ModulNbr). |
+----------------------------------------------------------------------------+
- BYTE b_Type; data[0]
+ unsigned char b_Type; data[0]
APCI1710_PULSEENCODER_WRITE
Writes a 32-bit value (ul_WriteValue) into the selected|
| pulse encoder (b_PulseEncoderNbr) from selected module |
| (b_ModulNbr). This operation set the new start pulse |
| encoder value.
APCI1710_PULSEENCODER_READ
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| CRAREF() BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| CRAREF() unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| data[1] BYTE_ b_PulseEncoderNbr : Pulse encoder selection |
+| data[1] unsigned char_ b_PulseEncoderNbr : Pulse encoder selection |
| (0 to 3)
APCI1710_PULSEENCODER_WRITE
data[2] ULONG_ ul_WriteValue : 32-bit value to be |
| written |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_Status : Pulse encoder status. |
+| Output Parameters : unsigned char *_ pb_Status : Pulse encoder status. |
| 0 : No overflow occur|
| 1 : Overflow occur
PULONG_ pul_ReadValue : Pulse encoder value | |
@@ -702,30 +702,30 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-/*_INT_ i_APCI1710_ReadPulseEncoderStatus (BYTE_ b_BoardHandle,
- BYTE_ b_ModulNbr,
- BYTE_ b_PulseEncoderNbr,
+/*_INT_ i_APCI1710_ReadPulseEncoderStatus (unsigned char_ b_BoardHandle,
+ unsigned char_ b_ModulNbr,
+ unsigned char_ b_PulseEncoderNbr,
- PBYTE_ pb_Status)
+ unsigned char *_ pb_Status)
*/
-INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusRegister;
- BYTE b_ModulNbr;
- BYTE b_PulseEncoderNbr;
- PBYTE pb_Status;
- BYTE b_Type;
- PULONG pul_ReadValue;
- ULONG ul_WriteValue;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusRegister;
+ unsigned char b_ModulNbr;
+ unsigned char b_PulseEncoderNbr;
+ unsigned char *pb_Status;
+ unsigned char b_Type;
+ unsigned int *pul_ReadValue;
+ unsigned int ul_WriteValue;
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_Type = (BYTE) data[0];
- b_PulseEncoderNbr = (BYTE) data[1];
- pb_Status = (PBYTE) & data[0];
- pul_ReadValue = (PULONG) & data[1];
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_Type = (unsigned char) data[0];
+ b_PulseEncoderNbr = (unsigned char) data[1];
+ pb_Status = (unsigned char *) &data[0];
+ pul_ReadValue = (unsigned int *) &data[1];
/***********************************/
/* Test the selected module number */
@@ -766,7 +766,7 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev,
dw_StatusRegister;
*pb_Status =
- (BYTE) (devpriv->
+ (unsigned char) (devpriv->
s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_StatusRegister >> (1 +
@@ -794,7 +794,7 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev,
break;
case APCI1710_PULSEENCODER_WRITE:
- ul_WriteValue = (ULONG) data[2];
+ ul_WriteValue = (unsigned int) data[2];
/*******************/
/* Write the value */
/*******************/
@@ -805,7 +805,7 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev,
(4 * b_PulseEncoderNbr) +
(64 * b_ModulNbr));
- } //end of switch
+ } /* end of switch */
} else {
/*********************************/
/* Pulse encoder not initialised */
@@ -831,11 +831,11 @@ INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
-INT i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->s_InterruptParameters.
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h
index 28252873e862..61a21cc94063 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h
@@ -21,11 +21,11 @@
#define APCI1710_PULSEENCODER_READ 0
#define APCI1710_PULSEENCODER_WRITE 1
-INT i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev,
+int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev,
+int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
@@ -33,7 +33,7 @@ INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev,
/*
* READ PULSE ENCODER FUNCTIONS
*/
-INT i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev,
+int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
@@ -41,7 +41,7 @@ INT i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev,
/*
* WRITE PULSE ENCODER FUNCTIONS
*/
-INT i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev,
+int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c
index 5ddd092a656a..138a84f572c8 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -70,38 +70,38 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_ConfigType;
- INT i_ReturnValue = 0;
+ unsigned char b_ConfigType;
+ int i_ReturnValue = 0;
b_ConfigType = CR_CHAN(insn->chanspec);
switch (b_ConfigType) {
case APCI1710_PWM_INIT:
- i_ReturnValue = i_APCI1710_InitPWM(dev, (BYTE) CR_AREF(insn->chanspec), // b_ModulNbr
- (BYTE) data[0], //b_PWM
- (BYTE) data[1], // b_ClockSelection
- (BYTE) data[2], // b_TimingUnit
- (ULONG) data[3], //ul_LowTiming
- (ULONG) data[4], //ul_HighTiming
- (PULONG) & data[0], //pul_RealLowTiming
- (PULONG) & data[1] //pul_RealHighTiming
+ i_ReturnValue = i_APCI1710_InitPWM(dev, (unsigned char) CR_AREF(insn->chanspec), /* b_ModulNbr */
+ (unsigned char) data[0], /* b_PWM */
+ (unsigned char) data[1], /* b_ClockSelection */
+ (unsigned char) data[2], /* b_TimingUnit */
+ (unsigned int) data[3], /* ul_LowTiming */
+ (unsigned int) data[4], /* ul_HighTiming */
+ (unsigned int *) &data[0], /* pul_RealLowTiming */
+ (unsigned int *) &data[1] /* pul_RealHighTiming */
);
break;
case APCI1710_PWM_GETINITDATA:
- i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (BYTE) CR_AREF(insn->chanspec), // b_ModulNbr
- (BYTE) data[0], //b_PWM
- (PBYTE) & data[0], //pb_TimingUnit
- (PULONG) & data[1], //pul_LowTiming
- (PULONG) & data[2], //pul_HighTiming
- (PBYTE) & data[3], // pb_StartLevel
- (PBYTE) & data[4], // pb_StopMode
- (PBYTE) & data[5], // pb_StopLevel
- (PBYTE) & data[6], // pb_ExternGate
- (PBYTE) & data[7], // pb_InterruptEnable
- (PBYTE) & data[8] // pb_Enable
+ i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (unsigned char) CR_AREF(insn->chanspec), /* b_ModulNbr */
+ (unsigned char) data[0], /* b_PWM */
+ (unsigned char *) &data[0], /* pb_TimingUnit */
+ (unsigned int *) &data[1], /* pul_LowTiming */
+ (unsigned int *) &data[2], /* pul_HighTiming */
+ (unsigned char *) &data[3], /* pb_StartLevel */
+ (unsigned char *) &data[4], /* pb_StopMode */
+ (unsigned char *) &data[5], /* pb_StopLevel */
+ (unsigned char *) &data[6], /* pb_ExternGate */
+ (unsigned char *) &data[7], /* pb_InterruptEnable */
+ (unsigned char *) &data[8] /* pb_Enable */
);
break;
@@ -111,17 +111,17 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitPWM |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PWM, |
-| BYTE_ b_ClockSelection, |
-| BYTE_ b_TimingUnit, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PWM, |
+| unsigned char_ b_ClockSelection, |
+| unsigned char_ b_TimingUnit, |
| ULONG_ ul_LowTiming, |
| ULONG_ ul_HighTiming, |
| PULONG_ pul_RealLowTiming, |
@@ -135,11 +135,11 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice
| You must calling this function be for you call any |
| other function witch access of the PWM. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure|
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure|
| (0 to 3) |
-| BYTE_ b_PWM : Selected PWM (0 or 1). |
-| BYTE_ b_ClockSelection : Selection from PCI bus |
+| unsigned char_ b_PWM : Selected PWM (0 or 1). |
+| unsigned char_ b_ClockSelection : Selection from PCI bus |
| clock |
| - APCI1710_30MHZ : |
| The PC have a 30 MHz |
@@ -151,7 +151,7 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice
| The APCI-1710 have a |
| integrated 40Mhz |
| quartz. |
-| BYTE_ b_TimingUnit : Base timing Unit (0 to 4) |
+| unsigned char_ b_TimingUnit : Base timing Unit (0 to 4) |
| 0 : ns |
| 1 : æs |
| 2 : ms |
@@ -179,19 +179,19 @@ INT i_APCI1710_InsnConfigPWM(struct comedi_device * dev, struct comedi_subdevice
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InitPWM(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_PWM,
- BYTE b_ClockSelection,
- BYTE b_TimingUnit,
- ULONG ul_LowTiming,
- ULONG ul_HighTiming,
- PULONG pul_RealLowTiming, PULONG pul_RealHighTiming)
+int i_APCI1710_InitPWM(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM,
+ unsigned char b_ClockSelection,
+ unsigned char b_TimingUnit,
+ unsigned int ul_LowTiming,
+ unsigned int ul_HighTiming,
+ unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming)
{
- INT i_ReturnValue = 0;
- ULONG ul_LowTimerValue = 0;
- ULONG ul_HighTimerValue = 0;
- DWORD dw_Command;
+ int i_ReturnValue = 0;
+ unsigned int ul_LowTimerValue = 0;
+ unsigned int ul_HighTimerValue = 0;
+ unsigned int dw_Command;
double d_RealLowTiming = 0;
double d_RealHighTiming = 0;
@@ -200,33 +200,33 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
/**************************/
if (b_ModulNbr < 4) {
- /***************/
+ /***************/
/* Test if PWM */
- /***************/
+ /***************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_PWM) {
- /**************************/
+ /**************************/
/* Test the PWM selection */
- /**************************/
+ /**************************/
if (b_PWM <= 1) {
- /******************/
+ /******************/
/* Test the clock */
- /******************/
+ /******************/
if ((b_ClockSelection == APCI1710_30MHZ) ||
(b_ClockSelection == APCI1710_33MHZ) ||
(b_ClockSelection == APCI1710_40MHZ)) {
- /************************/
+ /************************/
/* Test the timing unit */
- /************************/
+ /************************/
if (b_TimingUnit <= 4) {
- /*********************************/
+ /*********************************/
/* Test the low timing selection */
- /*********************************/
+ /*********************************/
if (((b_ClockSelection ==
APCI1710_30MHZ)
@@ -361,45 +361,45 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
&& (ul_LowTiming
<=
7UL))) {
- /**********************************/
+ /**********************************/
/* Test the High timing selection */
- /**********************************/
+ /**********************************/
if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230650UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 9UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691043UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 520UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 8UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496729UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 7UL))) {
- /**************************/
+ /**************************/
/* Test the board version */
- /**************************/
+ /**************************/
if (((b_ClockSelection == APCI1710_40MHZ) && (devpriv->s_BoardInfos.b_BoardVersion > 0)) || (b_ClockSelection != APCI1710_40MHZ)) {
- /************************************/
+ /************************************/
/* Calculate the low division fator */
- /************************************/
+ /************************************/
fpu_begin
();
switch (b_TimingUnit) {
- /******/
+ /******/
/* ns */
- /******/
+ /******/
case 0:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_LowTiming
*
(0.00025 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -409,13 +409,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(0.00025 * (double)b_ClockSelection));
@@ -451,7 +451,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -461,26 +461,26 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /******/
+ /******/
/* æs */
- /******/
+ /******/
case 1:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_LowTiming
*
(0.25 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -490,13 +490,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(0.25 * (double)b_ClockSelection));
@@ -534,7 +534,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -544,15 +544,15 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /******/
+ /******/
/* ms */
- /******/
+ /******/
case 2:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
@@ -562,9 +562,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
*
b_ClockSelection);
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -574,13 +574,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(250.0 * (double)b_ClockSelection));
@@ -616,7 +616,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -626,27 +626,27 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /*****/
+ /*****/
/* s */
- /*****/
+ /*****/
case 3:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_LowTiming
*
(250000.0
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -656,13 +656,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(250000.0
@@ -701,7 +701,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -711,19 +711,19 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /******/
+ /******/
/* mn */
- /******/
+ /******/
case 4:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(ul_LowTiming
*
@@ -733,9 +733,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)(ul_LowTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -745,13 +745,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(250000.0
@@ -795,7 +795,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -806,31 +806,31 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
}
- /*************************************/
+ /*************************************/
/* Calculate the high division fator */
- /*************************************/
+ /*************************************/
switch (b_TimingUnit) {
- /******/
+ /******/
/* ns */
- /******/
+ /******/
case 0:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_HighTiming
*
(0.00025 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -840,13 +840,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(0.00025 * (double)b_ClockSelection));
@@ -882,7 +882,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -892,26 +892,26 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /******/
+ /******/
/* æs */
- /******/
+ /******/
case 1:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_HighTiming
*
(0.25 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -921,13 +921,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(0.25 * (double)b_ClockSelection));
@@ -965,7 +965,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -975,15 +975,15 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /******/
+ /******/
/* ms */
- /******/
+ /******/
case 2:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
@@ -993,9 +993,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
*
b_ClockSelection);
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -1005,13 +1005,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(250.0 * (double)b_ClockSelection));
@@ -1047,7 +1047,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -1057,28 +1057,28 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /*****/
+ /*****/
/* s */
- /*****/
+ /*****/
case 3:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_HighTiming
*
(250000.0
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -1088,13 +1088,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(250000.0
@@ -1133,7 +1133,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -1143,19 +1143,19 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
break;
- /******/
+ /******/
/* mn */
- /******/
+ /******/
case 4:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(ul_HighTiming
*
@@ -1165,9 +1165,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)(ul_HighTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -1177,13 +1177,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
*pul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(250000.0
@@ -1227,7 +1227,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -1239,9 +1239,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
}
fpu_end();
- /****************************/
+ /****************************/
/* Save the clock selection */
- /****************************/
+ /****************************/
devpriv->
s_ModuleInfo
@@ -1251,9 +1251,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
=
b_ClockSelection;
- /************************/
+ /************************/
/* Save the timing unit */
- /************************/
+ /************************/
devpriv->
s_ModuleInfo
@@ -1265,9 +1265,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
=
b_TimingUnit;
- /****************************/
+ /****************************/
/* Save the low base timing */
- /****************************/
+ /****************************/
devpriv->
s_ModuleInfo
@@ -1289,9 +1289,9 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
=
*pul_RealLowTiming;
- /****************************/
+ /****************************/
/* Save the high base timing */
- /****************************/
+ /****************************/
devpriv->
s_ModuleInfo
@@ -1313,21 +1313,21 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
=
*pul_RealHighTiming;
- /************************/
+ /************************/
/* Write the low timing */
- /************************/
+ /************************/
outl(ul_LowTimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));
- /*************************/
+ /*************************/
/* Write the high timing */
- /*************************/
+ /*************************/
outl(ul_HighTimerValue, devpriv->s_BoardInfos.ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));
- /***************************/
+ /***************************/
/* Set the clock selection */
- /***************************/
+ /***************************/
dw_Command
=
@@ -1354,15 +1354,15 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
0x80;
}
- /***************************/
+ /***************************/
/* Set the clock selection */
- /***************************/
+ /***************************/
outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
- /*************/
+ /*************/
/* PWM init. */
- /*************/
+ /*************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
@@ -1373,98 +1373,98 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
=
1;
} else {
- /***************************************************/
+ /***************************************************/
/* You can not used the 40MHz clock selection with */
/* this board */
- /***************************************************/
+ /***************************************************/
DPRINTK("You can not used the 40MHz clock selection with this board\n");
i_ReturnValue
=
-9;
}
} else {
- /***************************************/
+ /***************************************/
/* High base timing selection is wrong */
- /***************************************/
+ /***************************************/
DPRINTK("High base timing selection is wrong\n");
i_ReturnValue =
-8;
}
} else {
- /**************************************/
+ /**************************************/
/* Low base timing selection is wrong */
- /**************************************/
+ /**************************************/
DPRINTK("Low base timing selection is wrong\n");
i_ReturnValue = -7;
}
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
else {
- /**********************************/
+ /**********************************/
/* Timing unit selection is wrong */
- /**********************************/
+ /**********************************/
DPRINTK("Timing unit selection is wrong\n");
i_ReturnValue = -6;
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
- } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
+ } /* if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) */
else {
- /*******************************/
+ /*******************************/
/* The selected clock is wrong */
- /*******************************/
+ /*******************************/
DPRINTK("The selected clock is wrong\n");
i_ReturnValue = -5;
- } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ))
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) */
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
else {
- /******************************/
+ /******************************/
/* Tor PWM selection is wrong */
- /******************************/
+ /******************************/
DPRINTK("Tor PWM selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
} else {
- /**********************************/
+ /**********************************/
/* The module is not a PWM module */
- /**********************************/
+ /**********************************/
DPRINTK("The module is not a PWM module\n");
i_ReturnValue = -3;
}
} else {
- /***********************/
+ /***********************/
/* Module number error */
- /***********************/
+ /***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetPWMInitialisation |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PWM, |
-| PBYTE_ pb_TimingUnit, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PWM, |
+| unsigned char *_ pb_TimingUnit, |
| PULONG_ pul_LowTiming, |
| PULONG_ pul_HighTiming, |
-| PBYTE_ pb_StartLevel, |
-| PBYTE_ pb_StopMode, |
-| PBYTE_ pb_StopLevel, |
-| PBYTE_ pb_ExternGate, |
-| PBYTE_ pb_InterruptEnable, |
-| PBYTE_ pb_Enable) |
+| unsigned char *_ pb_StartLevel, |
+| unsigned char *_ pb_StopMode, |
+| unsigned char *_ pb_StopLevel, |
+| unsigned char *_ pb_ExternGate, |
+| unsigned char *_ pb_InterruptEnable, |
+| unsigned char *_ pb_Enable) |
+----------------------------------------------------------------------------+
| Task : Return the PWM (b_PWM) initialisation from selected |
| module (b_ModulNbr). You must calling the |
| "i_APCI1710_InitPWM" function be for you call this |
| function. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
-| BYTE_ b_PWM : Selected PWM (0 or 1) |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+| unsigned char_ b_PWM : Selected PWM (0 or 1) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_TimingUnit : Base timing Unit (0 to 4) |
+| Output Parameters : unsigned char *_ pb_TimingUnit : Base timing Unit (0 to 4) |
| 0 : ns |
| 1 : æs |
| 2 : ms |
@@ -1472,13 +1472,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
| 4 : mn |
| PULONG_ pul_LowTiming : Low base timing value. |
| PULONG_ pul_HighTiming : High base timing value. |
-| PBYTE_ pb_StartLevel : Start period level |
+| unsigned char *_ pb_StartLevel : Start period level |
| selection |
| 0 : The period start |
| with a low level |
| 1 : The period start |
| with a high level|
-| PBYTE_ pb_StopMode : Stop mode selection |
+| unsigned char *_ pb_StopMode : Stop mode selection |
| 0 : The PWM is stopped |
| directly after the |
| "i_APCI1710_DisablePWM"|
@@ -1489,7 +1489,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
| function the PWM is |
| stopped at the end |
| from last period cycle|
-| PBYTE_ pb_StopLevel : Stop PWM level selection |
+| unsigned char *_ pb_StopLevel : Stop PWM level selection |
| 0 : The output signal |
| keep the level after|
| the |
@@ -1504,13 +1504,13 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
| the |
| "i_APCI1710_DisablePWM"|
| function |
-| PBYTE_ pb_ExternGate : Extern gate action |
+| unsigned char *_ pb_ExternGate : Extern gate action |
| selection |
| 0 : Extern gate signal |
| not used. |
| 1 : Extern gate signal |
| used. |
-| PBYTE_ pb_InterruptEnable : Enable or disable the PWM |
+| unsigned char *_ pb_InterruptEnable : Enable or disable the PWM |
| interrupt. |
| - APCI1710_ENABLE : |
| Enable the PWM interrupt|
@@ -1519,7 +1519,7 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
| - APCI1710_DISABLE : |
| Disable the PWM |
| interrupt |
-| PBYTE_ pb_Enable : Indicate if the PWM is |
+| unsigned char *_ pb_Enable : Indicate if the PWM is |
| enabled or no |
| 0 : PWM not enabled |
| 1 : PWM enabled |
@@ -1534,138 +1534,138 @@ INT i_APCI1710_InitPWM(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_GetPWMInitialisation(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_PWM,
- PBYTE pb_TimingUnit,
- PULONG pul_LowTiming,
- PULONG pul_HighTiming,
- PBYTE pb_StartLevel,
- PBYTE pb_StopMode,
- PBYTE pb_StopLevel,
- PBYTE pb_ExternGate, PBYTE pb_InterruptEnable, PBYTE pb_Enable)
+int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM,
+ unsigned char *pb_TimingUnit,
+ unsigned int *pul_LowTiming,
+ unsigned int *pul_HighTiming,
+ unsigned char *pb_StartLevel,
+ unsigned char *pb_StopMode,
+ unsigned char *pb_StopLevel,
+ unsigned char *pb_ExternGate, unsigned char *pb_InterruptEnable, unsigned char *pb_Enable)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
- DWORD dw_Command;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
+ unsigned int dw_Command;
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
- /***************/
+ /***************/
/* Test if PWM */
- /***************/
+ /***************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_PWM) {
- /**************************/
+ /**************************/
/* Test the PWM selection */
- /**************************/
+ /**************************/
if (b_PWM <= 1) {
- /***************************/
+ /***************************/
/* Test if PWM initialised */
- /***************************/
+ /***************************/
dw_Status = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (20 * b_PWM) +
(64 * b_ModulNbr));
if (dw_Status & 0x10) {
- /***********************/
+ /***********************/
/* Read the low timing */
- /***********************/
+ /***********************/
*pul_LowTiming =
inl(devpriv->s_BoardInfos.
ui_Address + 0 + (20 * b_PWM) +
(64 * b_ModulNbr));
- /************************/
+ /************************/
/* Read the high timing */
- /************************/
+ /************************/
*pul_HighTiming =
inl(devpriv->s_BoardInfos.
ui_Address + 4 + (20 * b_PWM) +
(64 * b_ModulNbr));
- /********************/
+ /********************/
/* Read the command */
- /********************/
+ /********************/
dw_Command = inl(devpriv->s_BoardInfos.
ui_Address + 8 + (20 * b_PWM) +
(64 * b_ModulNbr));
*pb_StartLevel =
- (BYTE) ((dw_Command >> 5) & 1);
+ (unsigned char) ((dw_Command >> 5) & 1);
*pb_StopMode =
- (BYTE) ((dw_Command >> 0) & 1);
+ (unsigned char) ((dw_Command >> 0) & 1);
*pb_StopLevel =
- (BYTE) ((dw_Command >> 1) & 1);
+ (unsigned char) ((dw_Command >> 1) & 1);
*pb_ExternGate =
- (BYTE) ((dw_Command >> 4) & 1);
+ (unsigned char) ((dw_Command >> 4) & 1);
*pb_InterruptEnable =
- (BYTE) ((dw_Command >> 3) & 1);
+ (unsigned char) ((dw_Command >> 3) & 1);
if (*pb_StopLevel) {
*pb_StopLevel =
*pb_StopLevel +
- (BYTE) ((dw_Command >>
+ (unsigned char) ((dw_Command >>
2) & 1);
}
- /********************/
+ /********************/
/* Read the command */
- /********************/
+ /********************/
dw_Command = inl(devpriv->s_BoardInfos.
ui_Address + 8 + (20 * b_PWM) +
(64 * b_ModulNbr));
*pb_Enable =
- (BYTE) ((dw_Command >> 0) & 1);
+ (unsigned char) ((dw_Command >> 0) & 1);
*pb_TimingUnit = devpriv->
s_ModuleInfo[b_ModulNbr].
s_PWMModuleInfo.
s_PWMInfo[b_PWM].b_TimingUnit;
- } // if (dw_Status & 0x10)
+ } /* if (dw_Status & 0x10) */
else {
- /***********************/
+ /***********************/
/* PWM not initialised */
- /***********************/
+ /***********************/
DPRINTK("PWM not initialised\n");
i_ReturnValue = -5;
- } // if (dw_Status & 0x10)
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (dw_Status & 0x10) */
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
else {
- /******************************/
+ /******************************/
/* Tor PWM selection is wrong */
- /******************************/
+ /******************************/
DPRINTK("Tor PWM selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
} else {
- /**********************************/
+ /**********************************/
/* The module is not a PWM module */
- /**********************************/
+ /**********************************/
DPRINTK("The module is not a PWM module\n");
i_ReturnValue = -3;
}
} else {
- /***********************/
+ /***********************/
/* Module number error */
- /***********************/
+ /***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1683,33 +1683,33 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_WriteType;
- INT i_ReturnValue = 0;
+ unsigned char b_WriteType;
+ int i_ReturnValue = 0;
b_WriteType = CR_CHAN(insn->chanspec);
switch (b_WriteType) {
case APCI1710_PWM_ENABLE:
i_ReturnValue = i_APCI1710_EnablePWM(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) data[0],
- (BYTE) data[1],
- (BYTE) data[2],
- (BYTE) data[3], (BYTE) data[4], (BYTE) data[5]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) data[0],
+ (unsigned char) data[1],
+ (unsigned char) data[2],
+ (unsigned char) data[3], (unsigned char) data[4], (unsigned char) data[5]);
break;
case APCI1710_PWM_DISABLE:
i_ReturnValue = i_APCI1710_DisablePWM(dev,
- (BYTE) CR_AREF(insn->chanspec), (BYTE) data[0]);
+ (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
break;
case APCI1710_PWM_NEWTIMING:
i_ReturnValue = i_APCI1710_SetNewPWMTiming(dev,
- (BYTE) CR_AREF(insn->chanspec),
- (BYTE) data[0],
- (BYTE) data[1], (ULONG) data[2], (ULONG) data[3]);
+ (unsigned char) CR_AREF(insn->chanspec),
+ (unsigned char) data[0],
+ (unsigned char) data[1], (unsigned int) data[2], (unsigned int) data[3]);
break;
default:
@@ -1718,20 +1718,20 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice
if (i_ReturnValue >= 0)
i_ReturnValue = insn->n;
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnablePWM |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PWM, |
-| BYTE_ b_StartLevel, |
-| BYTE_ b_StopMode, |
-| BYTE_ b_StopLevel, |
-| BYTE_ b_ExternGate, |
-| BYTE_ b_InterruptEnable) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PWM, |
+| unsigned char_ b_StartLevel, |
+| unsigned char_ b_StopMode, |
+| unsigned char_ b_StopLevel, |
+| unsigned char_ b_ExternGate, |
+| unsigned char_ b_InterruptEnable) |
+----------------------------------------------------------------------------+
| Task : Enable the selected PWM (b_PWM) from selected module |
| (b_ModulNbr). You must calling the "i_APCI1710_InitPWM"|
@@ -1741,16 +1741,16 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice
| See function "i_APCI1710_SetBoardIntRoutineX" and the |
| Interrupt mask description chapter. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number |
| (0 to 3) |
-| BYTE_ b_PWM : Selected PWM (0 or 1) |
-| BYTE_ b_StartLevel : Start period level selection |
+| unsigned char_ b_PWM : Selected PWM (0 or 1) |
+| unsigned char_ b_StartLevel : Start period level selection |
| 0 : The period start with a |
| low level |
| 1 : The period start with a |
| high level |
-| BYTE_ b_StopMode : Stop mode selection |
+| unsigned char_ b_StopMode : Stop mode selection |
| 0 : The PWM is stopped |
| directly after the |
| "i_APCI1710_DisablePWM" |
@@ -1761,7 +1761,7 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice
| function the PWM is |
| stopped at the end from|
| last period cycle. |
-| BYTE_ b_StopLevel : Stop PWM level selection |
+| unsigned char_ b_StopLevel : Stop PWM level selection |
| 0 : The output signal keep |
| the level after the |
| "i_APCI1710_DisablePWM" |
@@ -1774,11 +1774,11 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice
| to high after the |
| "i_APCI1710_DisablePWM" |
| function |
-| BYTE_ b_ExternGate : Extern gate action selection |
+| unsigned char_ b_ExternGate : Extern gate action selection |
| 0 : Extern gate signal not |
| used. |
| 1 : Extern gate signal used.|
-| BYTE_ b_InterruptEnable : Enable or disable the PWM |
+| unsigned char_ b_InterruptEnable : Enable or disable the PWM |
| interrupt. |
| - APCI1710_ENABLE : |
| Enable the PWM interrupt |
@@ -1806,77 +1806,77 @@ INT i_APCI1710_InsnWritePWM(struct comedi_device * dev, struct comedi_subdevice
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_EnablePWM(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_PWM,
- BYTE b_StartLevel,
- BYTE b_StopMode,
- BYTE b_StopLevel, BYTE b_ExternGate, BYTE b_InterruptEnable)
+int i_APCI1710_EnablePWM(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM,
+ unsigned char b_StartLevel,
+ unsigned char b_StopMode,
+ unsigned char b_StopLevel, unsigned char b_ExternGate, unsigned char b_InterruptEnable)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
- DWORD dw_Command;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
+ unsigned int dw_Command;
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
- /***************/
+ /***************/
/* Test if PWM */
- /***************/
+ /***************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_PWM) {
- /**************************/
+ /**************************/
/* Test the PWM selection */
- /**************************/
+ /**************************/
if (b_PWM <= 1) {
- /***************************/
+ /***************************/
/* Test if PWM initialised */
- /***************************/
+ /***************************/
dw_Status = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (20 * b_PWM) +
(64 * b_ModulNbr));
if (dw_Status & 0x10) {
- /**********************************/
+ /**********************************/
/* Test the start level selection */
- /**********************************/
+ /**********************************/
if (b_StartLevel <= 1) {
- /**********************/
+ /**********************/
/* Test the stop mode */
- /**********************/
+ /**********************/
if (b_StopMode <= 1) {
- /***********************/
+ /***********************/
/* Test the stop level */
- /***********************/
+ /***********************/
if (b_StopLevel <= 2) {
- /*****************************/
+ /*****************************/
/* Test the extern gate mode */
- /*****************************/
+ /*****************************/
if (b_ExternGate
<= 1) {
- /*****************************/
+ /*****************************/
/* Test the interrupt action */
- /*****************************/
+ /*****************************/
if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) {
- /******************************************/
+ /******************************************/
/* Test if interrupt function initialised */
- /******************************************/
+ /******************************************/
- /********************/
+ /********************/
/* Read the command */
- /********************/
+ /********************/
dw_Command
=
@@ -1895,9 +1895,9 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev,
&
0x80;
- /********************/
+ /********************/
/* Make the command */
- /********************/
+ /********************/
dw_Command
=
@@ -1943,100 +1943,100 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev,
=
b_InterruptEnable;
- /*******************/
+ /*******************/
/* Set the command */
- /*******************/
+ /*******************/
outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
- /******************/
+ /******************/
/* Enable the PWM */
- /******************/
+ /******************/
outl(1, devpriv->s_BoardInfos.ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
- } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)
+ } /* if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) */
else {
- /********************************/
+ /********************************/
/* Interrupt parameter is wrong */
- /********************************/
+ /********************************/
DPRINTK("Interrupt parameter is wrong\n");
i_ReturnValue
=
-10;
- } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)
- } // if (b_ExternGate >= 0 && b_ExternGate <= 1)
+ } /* if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) */
+ } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */
else {
- /*****************************************/
+ /*****************************************/
/* Extern gate signal selection is wrong */
- /*****************************************/
+ /*****************************************/
DPRINTK("Extern gate signal selection is wrong\n");
i_ReturnValue
=
-9;
- } // if (b_ExternGate >= 0 && b_ExternGate <= 1)
- } // if (b_StopLevel >= 0 && b_StopLevel <= 2)
+ } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */
+ } /* if (b_StopLevel >= 0 && b_StopLevel <= 2) */
else {
- /*************************************/
+ /*************************************/
/* PWM stop level selection is wrong */
- /*************************************/
+ /*************************************/
DPRINTK("PWM stop level selection is wrong\n");
i_ReturnValue =
-8;
- } // if (b_StopLevel >= 0 && b_StopLevel <= 2)
- } // if (b_StopMode >= 0 && b_StopMode <= 1)
+ } /* if (b_StopLevel >= 0 && b_StopLevel <= 2) */
+ } /* if (b_StopMode >= 0 && b_StopMode <= 1) */
else {
- /************************************/
+ /************************************/
/* PWM stop mode selection is wrong */
- /************************************/
+ /************************************/
DPRINTK("PWM stop mode selection is wrong\n");
i_ReturnValue = -7;
- } // if (b_StopMode >= 0 && b_StopMode <= 1)
- } // if (b_StartLevel >= 0 && b_StartLevel <= 1)
+ } /* if (b_StopMode >= 0 && b_StopMode <= 1) */
+ } /* if (b_StartLevel >= 0 && b_StartLevel <= 1) */
else {
- /**************************************/
+ /**************************************/
/* PWM start level selection is wrong */
- /**************************************/
+ /**************************************/
DPRINTK("PWM start level selection is wrong\n");
i_ReturnValue = -6;
- } // if (b_StartLevel >= 0 && b_StartLevel <= 1)
- } // if (dw_Status & 0x10)
+ } /* if (b_StartLevel >= 0 && b_StartLevel <= 1) */
+ } /* if (dw_Status & 0x10) */
else {
- /***********************/
+ /***********************/
/* PWM not initialised */
- /***********************/
+ /***********************/
DPRINTK("PWM not initialised\n");
i_ReturnValue = -5;
- } // if (dw_Status & 0x10)
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (dw_Status & 0x10) */
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
else {
- /******************************/
+ /******************************/
/* Tor PWM selection is wrong */
- /******************************/
+ /******************************/
DPRINTK("Tor PWM selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
} else {
- /**********************************/
+ /**********************************/
/* The module is not a PWM module */
- /**********************************/
+ /**********************************/
DPRINTK("The module is not a PWM module\n");
i_ReturnValue = -3;
}
} else {
- /***********************/
+ /***********************/
/* Module number error */
- /***********************/
+ /***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : _INT_ i_APCI1710_DisablePWM (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PWM) |
+| Function Name : _INT_ i_APCI1710_DisablePWM (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PWM) |
+----------------------------------------------------------------------------+
| Task : Disable the selected PWM (b_PWM) from selected module |
| (b_ModulNbr). The output signal level depend of the |
@@ -2045,8 +2045,8 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev,
| parameters from this function. |
+----------------------------------------------------------------------------+
| Input Parameters :BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
-| BYTE_ b_PWM : Selected PWM (0 or 1) |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+| unsigned char_ b_PWM : Selected PWM (0 or 1) |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -2062,99 +2062,99 @@ INT i_APCI1710_EnablePWM(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_DisablePWM(struct comedi_device * dev, BYTE b_ModulNbr, BYTE b_PWM)
+int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
- /***************/
+ /***************/
/* Test if PWM */
- /***************/
+ /***************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_PWM) {
- /**************************/
+ /**************************/
/* Test the PWM selection */
- /**************************/
+ /**************************/
if (b_PWM <= 1) {
- /***************************/
+ /***************************/
/* Test if PWM initialised */
- /***************************/
+ /***************************/
dw_Status = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (20 * b_PWM) +
(64 * b_ModulNbr));
if (dw_Status & 0x10) {
- /***********************/
+ /***********************/
/* Test if PWM enabled */
- /***********************/
+ /***********************/
if (dw_Status & 0x1) {
- /*******************/
+ /*******************/
/* Disable the PWM */
- /*******************/
+ /*******************/
outl(0, devpriv->s_BoardInfos.
ui_Address + 12 +
(20 * b_PWM) +
(64 * b_ModulNbr));
- } // if (dw_Status & 0x1)
+ } /* if (dw_Status & 0x1) */
else {
- /*******************/
+ /*******************/
/* PWM not enabled */
- /*******************/
+ /*******************/
DPRINTK("PWM not enabled\n");
i_ReturnValue = -6;
- } // if (dw_Status & 0x1)
- } // if (dw_Status & 0x10)
+ } /* if (dw_Status & 0x1) */
+ } /* if (dw_Status & 0x10) */
else {
- /***********************/
+ /***********************/
/* PWM not initialised */
- /***********************/
+ /***********************/
DPRINTK(" PWM not initialised\n");
i_ReturnValue = -5;
- } // if (dw_Status & 0x10)
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (dw_Status & 0x10) */
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
else {
- /******************************/
+ /******************************/
/* Tor PWM selection is wrong */
- /******************************/
+ /******************************/
DPRINTK("Tor PWM selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
} else {
- /**********************************/
+ /**********************************/
/* The module is not a PWM module */
- /**********************************/
+ /**********************************/
DPRINTK("The module is not a PWM module\n");
i_ReturnValue = -3;
}
} else {
- /***********************/
+ /***********************/
/* Module number error */
- /***********************/
+ /***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetNewPWMTiming |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PWM, |
-| BYTE_ b_ClockSelection, |
-| BYTE_ b_TimingUnit, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PWM, |
+| unsigned char_ b_ClockSelection, |
+| unsigned char_ b_TimingUnit, |
| ULONG_ ul_LowTiming, |
| ULONG_ ul_HighTiming) |
+----------------------------------------------------------------------------+
@@ -2162,11 +2162,11 @@ INT i_APCI1710_DisablePWM(struct comedi_device * dev, BYTE b_ModulNbr, BYTE b_PW
| ul_TimingUnit determine the low/high timing base for |
| the period. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Module number to configure|
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Module number to configure|
| (0 to 3) |
-| BYTE_ b_PWM : Selected PWM (0 or 1). |
-| BYTE_ b_TimingUnit : Base timing Unit (0 to 4) |
+| unsigned char_ b_PWM : Selected PWM (0 or 1). |
+| unsigned char_ b_TimingUnit : Base timing Unit (0 to 4) |
| 0 : ns |
| 1 : æs |
| 2 : ms |
@@ -2189,18 +2189,18 @@ INT i_APCI1710_DisablePWM(struct comedi_device * dev, BYTE b_ModulNbr, BYTE b_PW
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
- BYTE b_ModulNbr,
- BYTE b_PWM, BYTE b_TimingUnit, ULONG ul_LowTiming, ULONG ul_HighTiming)
+int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM, unsigned char b_TimingUnit, unsigned int ul_LowTiming, unsigned int ul_HighTiming)
{
- BYTE b_ClockSelection;
- INT i_ReturnValue = 0;
- ULONG ul_LowTimerValue = 0;
- ULONG ul_HighTimerValue = 0;
- ULONG ul_RealLowTiming = 0;
- ULONG ul_RealHighTiming = 0;
- DWORD dw_Status;
- DWORD dw_Command;
+ unsigned char b_ClockSelection;
+ int i_ReturnValue = 0;
+ unsigned int ul_LowTimerValue = 0;
+ unsigned int ul_HighTimerValue = 0;
+ unsigned int ul_RealLowTiming = 0;
+ unsigned int ul_RealHighTiming = 0;
+ unsigned int dw_Status;
+ unsigned int dw_Command;
double d_RealLowTiming = 0;
double d_RealHighTiming = 0;
@@ -2209,21 +2209,21 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
/**************************/
if (b_ModulNbr < 4) {
- /***************/
+ /***************/
/* Test if PWM */
- /***************/
+ /***************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_PWM) {
- /**************************/
+ /**************************/
/* Test the PWM selection */
- /**************************/
+ /**************************/
if (b_PWM <= 1) {
- /***************************/
+ /***************************/
/* Test if PWM initialised */
- /***************************/
+ /***************************/
dw_Status = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (20 * b_PWM) +
@@ -2235,14 +2235,14 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
s_PWMModuleInfo.
b_ClockSelection;
- /************************/
+ /************************/
/* Test the timing unit */
- /************************/
+ /************************/
if (b_TimingUnit <= 4) {
- /*********************************/
+ /*********************************/
/* Test the low timing selection */
- /*********************************/
+ /*********************************/
if (((b_ClockSelection ==
APCI1710_30MHZ)
@@ -2377,37 +2377,37 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
&& (ul_LowTiming
<=
7UL))) {
- /**********************************/
+ /**********************************/
/* Test the High timing selection */
- /**********************************/
+ /**********************************/
if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230650UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 9UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691043UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 520UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 8UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496729UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 7UL))) {
- /************************************/
+ /************************************/
/* Calculate the low division fator */
- /************************************/
+ /************************************/
fpu_begin();
switch (b_TimingUnit) {
- /******/
+ /******/
/* ns */
- /******/
+ /******/
case 0:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_LowTiming
*
(0.00025 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -2417,13 +2417,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(0.00025 * (double)b_ClockSelection));
@@ -2459,7 +2459,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -2469,26 +2469,26 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /******/
+ /******/
/* æs */
- /******/
+ /******/
case 1:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_LowTiming
*
(0.25 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -2498,13 +2498,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(0.25 * (double)b_ClockSelection));
@@ -2542,7 +2542,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -2552,15 +2552,15 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /******/
+ /******/
/* ms */
- /******/
+ /******/
case 2:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
@@ -2570,9 +2570,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
*
b_ClockSelection);
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -2582,13 +2582,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(250.0 * (double)b_ClockSelection));
@@ -2624,7 +2624,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -2634,28 +2634,28 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /*****/
+ /*****/
/* s */
- /*****/
+ /*****/
case 3:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_LowTiming
*
(250000.0
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_LowTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -2665,13 +2665,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(250000.0
@@ -2710,7 +2710,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -2720,19 +2720,19 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /******/
+ /******/
/* mn */
- /******/
+ /******/
case 4:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(ul_LowTiming
*
@@ -2742,9 +2742,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)(ul_LowTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) {
ul_LowTimerValue
@@ -2754,13 +2754,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealLowTiming
=
- (ULONG)
+ (unsigned int)
(ul_LowTimerValue
/
(250000.0
@@ -2804,7 +2804,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_LowTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_LowTimerValue)
@@ -2815,31 +2815,31 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
}
- /*************************************/
+ /*************************************/
/* Calculate the high division fator */
- /*************************************/
+ /*************************************/
switch (b_TimingUnit) {
- /******/
+ /******/
/* ns */
- /******/
+ /******/
case 0:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_HighTiming
*
(0.00025 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -2849,13 +2849,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(0.00025 * (double)b_ClockSelection));
@@ -2891,7 +2891,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -2901,26 +2901,26 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /******/
+ /******/
/* æs */
- /******/
+ /******/
case 1:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_HighTiming
*
(0.25 * b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -2930,13 +2930,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(0.25 * (double)b_ClockSelection));
@@ -2974,7 +2974,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -2984,15 +2984,15 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /******/
+ /******/
/* ms */
- /******/
+ /******/
case 2:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
@@ -3002,9 +3002,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
*
b_ClockSelection);
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -3014,13 +3014,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(250.0 * (double)b_ClockSelection));
@@ -3056,7 +3056,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -3066,28 +3066,28 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /*****/
+ /*****/
/* s */
- /*****/
+ /*****/
case 3:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(ul_HighTiming
*
(250000.0
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)ul_HighTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -3097,13 +3097,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(250000.0
@@ -3142,7 +3142,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -3152,19 +3152,19 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
break;
- /******/
+ /******/
/* mn */
- /******/
+ /******/
case 4:
- /******************/
+ /******************/
/* Timer 0 factor */
- /******************/
+ /******************/
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(ul_HighTiming
*
@@ -3174,9 +3174,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
*
b_ClockSelection));
- /*******************/
+ /*******************/
/* Round the value */
- /*******************/
+ /*******************/
if ((double)((double)(ul_HighTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) {
ul_HighTimerValue
@@ -3186,13 +3186,13 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
1;
}
- /*****************************/
+ /*****************************/
/* Calculate the real timing */
- /*****************************/
+ /*****************************/
ul_RealHighTiming
=
- (ULONG)
+ (unsigned int)
(ul_HighTimerValue
/
(250000.0
@@ -3236,7 +3236,7 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
if (b_ClockSelection != APCI1710_40MHZ) {
ul_HighTimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_HighTimerValue)
@@ -3249,9 +3249,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
fpu_end();
- /************************/
+ /************************/
/* Save the timing unit */
- /************************/
+ /************************/
devpriv->
s_ModuleInfo
@@ -3263,9 +3263,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
=
b_TimingUnit;
- /****************************/
+ /****************************/
/* Save the low base timing */
- /****************************/
+ /****************************/
devpriv->
s_ModuleInfo
@@ -3287,9 +3287,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
=
ul_RealLowTiming;
- /****************************/
+ /****************************/
/* Save the high base timing */
- /****************************/
+ /****************************/
devpriv->
s_ModuleInfo
@@ -3311,21 +3311,21 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
=
ul_RealHighTiming;
- /************************/
+ /************************/
/* Write the low timing */
- /************************/
+ /************************/
outl(ul_LowTimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));
- /*************************/
+ /*************************/
/* Write the high timing */
- /*************************/
+ /*************************/
outl(ul_HighTimerValue, devpriv->s_BoardInfos.ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));
- /***************************/
+ /***************************/
/* Set the clock selection */
- /***************************/
+ /***************************/
dw_Command =
inl
@@ -3347,9 +3347,9 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
0x80;
}
- /***************************/
+ /***************************/
/* Set the clock selection */
- /***************************/
+ /***************************/
outl(dw_Command,
devpriv->
@@ -3358,96 +3358,96 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
+ 8 +
(20 * b_PWM) + (64 * b_ModulNbr));
} else {
- /***************************************/
+ /***************************************/
/* High base timing selection is wrong */
- /***************************************/
+ /***************************************/
DPRINTK("High base timing selection is wrong\n");
i_ReturnValue =
-8;
}
} else {
- /**************************************/
+ /**************************************/
/* Low base timing selection is wrong */
- /**************************************/
+ /**************************************/
DPRINTK("Low base timing selection is wrong\n");
i_ReturnValue = -7;
}
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
else {
- /**********************************/
+ /**********************************/
/* Timing unit selection is wrong */
- /**********************************/
+ /**********************************/
DPRINTK("Timing unit selection is wrong\n");
i_ReturnValue = -6;
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
- } // if (dw_Status & 0x10)
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
+ } /* if (dw_Status & 0x10) */
else {
- /***********************/
+ /***********************/
/* PWM not initialised */
- /***********************/
+ /***********************/
DPRINTK("PWM not initialised\n");
i_ReturnValue = -5;
- } // if (dw_Status & 0x10)
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (dw_Status & 0x10) */
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
else {
- /******************************/
+ /******************************/
/* Tor PWM selection is wrong */
- /******************************/
+ /******************************/
DPRINTK("Tor PWM selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
} else {
- /**********************************/
+ /**********************************/
/* The module is not a PWM module */
- /**********************************/
+ /**********************************/
DPRINTK("The module is not a PWM module\n");
i_ReturnValue = -3;
}
} else {
- /***********************/
+ /***********************/
/* Module number error */
- /***********************/
+ /***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetPWMStatus |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PWM, |
-| PBYTE_ pb_PWMOutputStatus, |
-| PBYTE_ pb_ExternGateStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PWM, |
+| unsigned char *_ pb_PWMOutputStatus, |
+| unsigned char *_ pb_ExternGateStatus) |
+----------------------------------------------------------------------------+
| Task : Return the status from selected PWM (b_PWM) from |
| selected module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_PWM : Selected PWM (0 or 1) |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3)
- b_ModulNbr =(BYTE) CR_AREF(insn->chanspec);
- b_PWM =(BYTE) data[0];
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_PWM : Selected PWM (0 or 1) |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3)
+ b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec);
+ b_PWM =(unsigned char) data[0];
|
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_PWMOutputStatus : Return the PWM output |
+| Output Parameters : unsigned char *_ pb_PWMOutputStatus : Return the PWM output |
| level status. |
| 0 : The PWM output level|
| is low. |
| 1 : The PWM output level|
| is high. |
-| PBYTE_ pb_ExternGateStatus : Return the extern gate |
+| unsigned char *_ pb_ExternGateStatus : Return the extern gate |
| level status. |
| 0 : The extern gate is |
| low. |
| 1 : The extern gate is |
| high.
- pb_PWMOutputStatus =(PBYTE) data[0];
- pb_ExternGateStatus =(PBYTE) data[1]; |
+ pb_PWMOutputStatus =(unsigned char *) data[0];
+ pb_ExternGateStatus =(unsigned char *) data[1]; |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
@@ -3460,109 +3460,109 @@ INT i_APCI1710_SetNewPWMTiming(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadGetPWMStatus(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
- BYTE b_ModulNbr;
- BYTE b_PWM;
- PBYTE pb_PWMOutputStatus;
- PBYTE pb_ExternGateStatus;
+ unsigned char b_ModulNbr;
+ unsigned char b_PWM;
+ unsigned char *pb_PWMOutputStatus;
+ unsigned char *pb_ExternGateStatus;
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_PWM = (BYTE) CR_CHAN(insn->chanspec);
- pb_PWMOutputStatus = (PBYTE) & data[0];
- pb_ExternGateStatus = (PBYTE) & data[1];
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_PWM = (unsigned char) CR_CHAN(insn->chanspec);
+ pb_PWMOutputStatus = (unsigned char *) &data[0];
+ pb_ExternGateStatus = (unsigned char *) &data[1];
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
- /***************/
+ /***************/
/* Test if PWM */
- /***************/
+ /***************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_PWM) {
- /**************************/
+ /**************************/
/* Test the PWM selection */
- /**************************/
+ /**************************/
if (b_PWM <= 1) {
- /***************************/
+ /***************************/
/* Test if PWM initialised */
- /***************************/
+ /***************************/
dw_Status = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (20 * b_PWM) +
(64 * b_ModulNbr));
if (dw_Status & 0x10) {
- /***********************/
+ /***********************/
/* Test if PWM enabled */
- /***********************/
+ /***********************/
if (dw_Status & 0x1) {
*pb_PWMOutputStatus =
- (BYTE) ((dw_Status >> 7)
+ (unsigned char) ((dw_Status >> 7)
& 1);
*pb_ExternGateStatus =
- (BYTE) ((dw_Status >> 6)
+ (unsigned char) ((dw_Status >> 6)
& 1);
- } // if (dw_Status & 0x1)
+ } /* if (dw_Status & 0x1) */
else {
- /*******************/
+ /*******************/
/* PWM not enabled */
- /*******************/
+ /*******************/
DPRINTK("PWM not enabled \n");
i_ReturnValue = -6;
- } // if (dw_Status & 0x1)
- } // if (dw_Status & 0x10)
+ } /* if (dw_Status & 0x1) */
+ } /* if (dw_Status & 0x10) */
else {
- /***********************/
+ /***********************/
/* PWM not initialised */
- /***********************/
+ /***********************/
DPRINTK("PWM not initialised\n");
i_ReturnValue = -5;
- } // if (dw_Status & 0x10)
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (dw_Status & 0x10) */
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
else {
- /******************************/
+ /******************************/
/* Tor PWM selection is wrong */
- /******************************/
+ /******************************/
DPRINTK("Tor PWM selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_PWM >= 0 && b_PWM <= 1)
+ } /* if (b_PWM >= 0 && b_PWM <= 1) */
} else {
- /**********************************/
+ /**********************************/
/* The module is not a PWM module */
- /**********************************/
+ /**********************************/
DPRINTK("The module is not a PWM module\n");
i_ReturnValue = -3;
}
} else {
- /***********************/
+ /***********************/
/* Module number error */
- /***********************/
+ /***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
-INT i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->s_InterruptParameters.
s_FIFOInterruptParameters[devpriv->
@@ -3574,9 +3574,9 @@ INT i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device * dev,
s_FIFOInterruptParameters[devpriv->
s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
- /**************************/
+ /**************************/
/* Increment the read FIFO */
- /***************************/
+ /***************************/
devpriv->
s_InterruptParameters.
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h
index c1b7f4ca47c3..bf1b4c39a1cd 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h
@@ -26,51 +26,51 @@
#define APCI1710_PWM_ENABLE 1
#define APCI1710_PWM_NEWTIMING 2
-INT i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InitPWM(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_PWM,
- BYTE b_ClockSelection,
- BYTE b_TimingUnit,
- ULONG ul_LowTiming,
- ULONG ul_HighTiming,
- PULONG pul_RealLowTiming, PULONG pul_RealHighTiming);
+int i_APCI1710_InitPWM(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM,
+ unsigned char b_ClockSelection,
+ unsigned char b_TimingUnit,
+ unsigned int ul_LowTiming,
+ unsigned int ul_HighTiming,
+ unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming);
-INT i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_PWM,
- PBYTE pb_TimingUnit,
- PULONG pul_LowTiming,
- PULONG pul_HighTiming,
- PBYTE pb_StartLevel,
- PBYTE pb_StopMode,
- PBYTE pb_StopLevel,
- PBYTE pb_ExternGate,
- PBYTE pb_InterruptEnable, PBYTE pb_Enable);
+int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM,
+ unsigned char *pb_TimingUnit,
+ unsigned int *pul_LowTiming,
+ unsigned int *pul_HighTiming,
+ unsigned char *pb_StartLevel,
+ unsigned char *pb_StopMode,
+ unsigned char *pb_StopLevel,
+ unsigned char *pb_ExternGate,
+ unsigned char *pb_InterruptEnable, unsigned char *pb_Enable);
-INT i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_EnablePWM(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_PWM,
- BYTE b_StartLevel,
- BYTE b_StopMode,
- BYTE b_StopLevel, BYTE b_ExternGate,
- BYTE b_InterruptEnable);
+int i_APCI1710_EnablePWM(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM,
+ unsigned char b_StartLevel,
+ unsigned char b_StopMode,
+ unsigned char b_StopLevel, unsigned char b_ExternGate,
+ unsigned char b_InterruptEnable);
-INT i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
- BYTE b_ModulNbr,
- BYTE b_PWM, BYTE b_TimingUnit,
- ULONG ul_LowTiming, ULONG ul_HighTiming);
+int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
+ unsigned char b_ModulNbr,
+ unsigned char b_PWM, unsigned char b_TimingUnit,
+ unsigned int ul_LowTiming, unsigned int ul_HighTiming);
-INT i_APCI1710_DisablePWM(struct comedi_device *dev, BYTE b_ModulNbr, BYTE b_PWM);
+int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM);
-INT i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev,
+int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c
index bb6e1622e379..a445dab50eac 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -65,31 +65,31 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitSSI |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_SSIProfile, |
-| BYTE_ b_PositionTurnLength, |
-| BYTE_ b_TurnCptLength, |
-| BYTE_ b_PCIInputClock, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_SSIProfile, |
+| unsigned char_ b_PositionTurnLength, |
+| unsigned char_ b_TurnCptLength, |
+| unsigned char_ b_PCIInputClock, |
| ULONG_ ul_SSIOutputClock, |
-| BYTE_ b_SSICountingMode) |
+| unsigned char_ b_SSICountingMode) |
+----------------------------------------------------------------------------+
| Task : Configure the SSI operating mode from selected module |
| (b_ModulNbr). You must calling this function be for you|
| call any other function witch access of SSI. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| BYTE_ b_SSIProfile : Selection from SSI |
+| unsigned char_ b_SSIProfile : Selection from SSI |
| profile length (2 to 32).|
-| BYTE_ b_PositionTurnLength : Selection from SSI |
+| unsigned char_ b_PositionTurnLength : Selection from SSI |
| position data length |
| (1 to 31). |
-| BYTE_ b_TurnCptLength : Selection from SSI turn |
+| unsigned char_ b_TurnCptLength : Selection from SSI turn |
| counter data length |
| (1 to 31). |
-| BYTE b_PCIInputClock : Selection from PCI bus |
+| unsigned char b_PCIInputClock : Selection from PCI bus |
| clock |
| - APCI1710_30MHZ : |
| The PC have a PCI bus |
@@ -103,7 +103,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| for 30 MHz selection. |
| From 252 to 5 000 000 Hz|
| for 33 MHz selection. |
-| BYTE b_SSICountingMode : SSI counting mode |
+| unsigned char b_SSICountingMode : SSI counting mode |
| selection |
| - APCI1710_BINARY_MODE : |
| Binary counting mode. |
@@ -111,12 +111,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| Gray counting mode.
b_ModulNbr = CR_AREF(insn->chanspec);
- b_SSIProfile = (BYTE) data[0];
- b_PositionTurnLength= (BYTE) data[1];
- b_TurnCptLength = (BYTE) data[2];
- b_PCIInputClock = (BYTE) data[3];
- ul_SSIOutputClock = (ULONG) data[4];
- b_SSICountingMode = (BYTE) data[5]; |
+ b_SSIProfile = (unsigned char) data[0];
+ b_PositionTurnLength= (unsigned char) data[1];
+ b_TurnCptLength = (unsigned char) data[2];
+ b_PCIInputClock = (unsigned char) data[3];
+ ul_SSIOutputClock = (unsigned int) data[4];
+ b_SSICountingMode = (unsigned char) data[5]; |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -133,22 +133,22 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- UINT ui_TimerValue;
- BYTE b_ModulNbr, b_SSIProfile, b_PositionTurnLength, b_TurnCptLength,
+ int i_ReturnValue = 0;
+ unsigned int ui_TimerValue;
+ unsigned char b_ModulNbr, b_SSIProfile, b_PositionTurnLength, b_TurnCptLength,
b_PCIInputClock, b_SSICountingMode;
- ULONG ul_SSIOutputClock;
+ unsigned int ul_SSIOutputClock;
b_ModulNbr = CR_AREF(insn->chanspec);
- b_SSIProfile = (BYTE) data[0];
- b_PositionTurnLength = (BYTE) data[1];
- b_TurnCptLength = (BYTE) data[2];
- b_PCIInputClock = (BYTE) data[3];
- ul_SSIOutputClock = (ULONG) data[4];
- b_SSICountingMode = (BYTE) data[5];
+ b_SSIProfile = (unsigned char) data[0];
+ b_PositionTurnLength = (unsigned char) data[1];
+ b_TurnCptLength = (unsigned char) data[2];
+ b_PCIInputClock = (unsigned char) data[3];
+ ul_SSIOutputClock = (unsigned int) data[4];
+ b_SSICountingMode = (unsigned char) data[5];
i_ReturnValue = insn->n;
/**************************/
@@ -167,7 +167,7 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde
/* Test the SSI profile length */
/*******************************/
- // CG 22/03/00 b_SSIProfile >= 2 anstatt b_SSIProfile > 2
+ /* CG 22/03/00 b_SSIProfile >= 2 anstatt b_SSIProfile > 2 */
if (b_SSIProfile >= 2 && b_SSIProfile < 33) {
/*************************************/
/* Test the SSI position data length */
@@ -250,9 +250,9 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde
ui_TimerValue
=
- (UINT)
+ (unsigned int)
(
- ((ULONG) (b_PCIInputClock) * 500000UL) / ul_SSIOutputClock);
+ ((unsigned int) (b_PCIInputClock) * 500000UL) / ul_SSIOutputClock);
/************************/
/* Initialise the timer */
@@ -351,18 +351,18 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Read1SSIValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_SelectedSSI, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_SelectedSSI, |
| PULONG_ pul_Position, |
| PULONG_ pul_TurnCpt)
- INT i_APCI1710_ReadSSIValue(struct comedi_device *dev,struct comedi_subdevice *s,
+ int i_APCI1710_ReadSSIValue(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task :
@@ -373,22 +373,22 @@ INT i_APCI1710_InsnConfigInitSSI(struct comedi_device * dev, struct comedi_subde
or Read all SSI counter (b_SelectedSSI) from |
| selected module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
-| BYTE_ b_SelectedSSI : Selection from SSI |
+| unsigned char_ b_SelectedSSI : Selection from SSI |
| counter (0 to 2)
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_SelectedSSI = (BYTE) CR_CHAN(insn->chanspec); (in case of single ssi)
- b_ReadType = (BYTE) CR_RANGE(insn->chanspec);
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec); (in case of single ssi)
+ b_ReadType = (unsigned char) CR_RANGE(insn->chanspec);
|
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_Position : SSI position in the turn |
| PULONG_ pul_TurnCpt : Number of turns
-pul_Position = (PULONG) &data[0];
- pul_TurnCpt = (PULONG) &data[1]; |
+pul_Position = (unsigned int *) &data[0];
+ pul_TurnCpt = (unsigned int *) &data[1]; |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
@@ -400,37 +400,37 @@ pul_Position = (PULONG) &data[0];
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_Cpt;
- BYTE b_Length;
- BYTE b_Schift;
- BYTE b_SSICpt;
- DWORD dw_And;
- DWORD dw_And1;
- DWORD dw_And2;
- DWORD dw_StatusReg;
- DWORD dw_CounterValue;
- BYTE b_ModulNbr;
- BYTE b_SelectedSSI;
- BYTE b_ReadType;
- PULONG pul_Position;
- PULONG pul_TurnCpt;
- PULONG pul_Position1;
- PULONG pul_TurnCpt1;
+ int i_ReturnValue = 0;
+ unsigned char b_Cpt;
+ unsigned char b_Length;
+ unsigned char b_Schift;
+ unsigned char b_SSICpt;
+ unsigned int dw_And;
+ unsigned int dw_And1;
+ unsigned int dw_And2;
+ unsigned int dw_StatusReg;
+ unsigned int dw_CounterValue;
+ unsigned char b_ModulNbr;
+ unsigned char b_SelectedSSI;
+ unsigned char b_ReadType;
+ unsigned int *pul_Position;
+ unsigned int *pul_TurnCpt;
+ unsigned int *pul_Position1;
+ unsigned int *pul_TurnCpt1;
i_ReturnValue = insn->n;
- pul_Position1 = (PULONG) & data[0];
-// For Read1
- pul_TurnCpt1 = (PULONG) & data[1];
-// For Read all
- pul_Position = (PULONG) & data[0]; //0-2
- pul_TurnCpt = (PULONG) & data[3]; //3-5
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_SelectedSSI = (BYTE) CR_CHAN(insn->chanspec);
- b_ReadType = (BYTE) CR_RANGE(insn->chanspec);
+ pul_Position1 = (unsigned int *) &data[0];
+/* For Read1 */
+ pul_TurnCpt1 = (unsigned int *) &data[1];
+/* For Read all */
+ pul_Position = (unsigned int *) &data[0]; /* 0-2 */
+ pul_TurnCpt = (unsigned int *) &data[3]; /* 3-5 */
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec);
+ b_ReadType = (unsigned char) CR_RANGE(insn->chanspec);
/**************************/
/* Test the module number */
@@ -477,9 +477,8 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev
s_BoardInfos.
ui_Address +
(64 * b_ModulNbr));
- }
- while ((dw_StatusReg & 0x1) !=
- 0);
+ } while ((dw_StatusReg & 0x1)
+ != 0);
/******************************/
/* Read the SSI counter value */
@@ -608,8 +607,7 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev
s_BoardInfos.
ui_Address +
(64 * b_ModulNbr));
- }
- while ((dw_StatusReg & 0x1) != 0);
+ } while ((dw_StatusReg & 0x1) != 0);
for (b_SSICpt = 0; b_SSICpt < 3;
b_SSICpt++) {
@@ -667,7 +665,7 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev
default:
printk("Read Type Inputs Wrong\n");
- } // switch ending
+ } /* switch ending */
} else {
/***********************/
@@ -695,16 +693,16 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadSSI1DigitalInput |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_InputChannel, |
-| PBYTE_ pb_ChannelStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_InputChannel, |
+| unsigned char *_ pb_ChannelStatus) |
+----------------------------------------------------------------------------+
| Task :
(0) Set the digital output from selected SSI moule |
@@ -716,13 +714,13 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev
(3)Read the status from all SSI digital inputs from |
| selected SSI module (b_ModulNbr) |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr CR_AREF : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr CR_AREF : Module number to |
| configure (0 to 3) |
-| BYTE_ b_InputChannel CR_CHAN : Selection from digital |
+| unsigned char_ b_InputChannel CR_CHAN : Selection from digital |
| data[0] which IOTYPE input ( 0 to 2) |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_ChannelStatus : Digital input channel |
+| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel |
| data[0] status |
| 0 : Channle is not active|
| 1 : Channle is active |
@@ -735,19 +733,19 @@ INT i_APCI1710_InsnReadSSIValue(struct comedi_device * dev, struct comedi_subdev
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg;
- BYTE b_ModulNbr;
- BYTE b_InputChannel;
- PBYTE pb_ChannelStatus;
- PBYTE pb_InputStatus;
- BYTE b_IOType;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg;
+ unsigned char b_ModulNbr;
+ unsigned char b_InputChannel;
+ unsigned char *pb_ChannelStatus;
+ unsigned char *pb_InputStatus;
+ unsigned char b_IOType;
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_IOType = (BYTE) data[0];
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_IOType = (unsigned char) data[0];
/**************************/
/* Test the module number */
@@ -785,8 +783,8 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su
/* Test the digital imnput channel number */
/******************************************/
- b_InputChannel = (BYTE) CR_CHAN(insn->chanspec);
- pb_ChannelStatus = (PBYTE) & data[0];
+ b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec);
+ pb_ChannelStatus = (unsigned char *) &data[0];
if (b_InputChannel <= 2) {
/**************************/
@@ -797,7 +795,7 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su
inl(devpriv->s_BoardInfos.
ui_Address + (64 * b_ModulNbr));
*pb_ChannelStatus =
- (BYTE) (((~dw_StatusReg) >> (4 +
+ (unsigned char) (((~dw_StatusReg) >> (4 +
b_InputChannel))
& 1);
} else {
@@ -814,19 +812,19 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su
/**************************/
/* Read all digital input */
/**************************/
- pb_InputStatus = (PBYTE) & data[0];
+ pb_InputStatus = (unsigned char *) &data[0];
dw_StatusReg =
inl(devpriv->s_BoardInfos.ui_Address +
(64 * b_ModulNbr));
*pb_InputStatus =
- (BYTE) (((~dw_StatusReg) >> 4) & 7);
+ (unsigned char) (((~dw_StatusReg) >> 4) & 7);
break;
default:
printk("IO type wrong\n");
- } //switch end
+ } /* switch end */
} else {
/**********************************/
/* The module is not a SSI module */
@@ -844,5 +842,5 @@ INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device * dev, struct comedi_su
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h
index 88daad1a3912..eb7f101d2d61 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h
@@ -33,11 +33,11 @@
/*
* SSI INISIALISATION FUNCTION
*/
-INT i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c
index 90316e10a3bd..43198aafb2dc 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -63,11 +63,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitTorCounter |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TorCounter, |
-| BYTE_ b_PCIInputClock, |
-| BYTE_ b_TimingUnit, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TorCounter, |
+| unsigned char_ b_PCIInputClock, |
+| unsigned char_ b_TimingUnit, |
| ULONG_ ul_TimingInterval, |
| PULONG_ pul_RealTimingInterval) |
+----------------------------------------------------------------------------+
@@ -82,11 +82,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
| Input Parameters : |
|
- CR_AREF BYTE_ b_ModulNbr : Module number to configure |
+ CR_AREF unsigned char_ b_ModulNbr : Module number to configure |
| (0 to 3) |
-| data[0] BYTE_ b_TorCounter : Tor counter selection |
+| data[0] unsigned char_ b_TorCounter : Tor counter selection |
| (0 or 1). |
-| data[1] BYTE_ b_PCIInputClock : Selection from PCI bus clock|
+| data[1] unsigned char_ b_PCIInputClock : Selection from PCI bus clock|
| - APCI1710_30MHZ : |
| The PC have a PCI bus |
| clock from 30 MHz |
@@ -104,7 +104,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| than it is not possibl to |
| used the gate input for |
| enabled the acquisition |
-| data[2] BYTE_ b_TimingUnit : Base timing unit (0 to 4) |
+| data[2] unsigned char_ b_TimingUnit : Base timing unit (0 to 4) |
| 0 : ns |
| 1 : µs |
| 2 : ms |
@@ -130,27 +130,27 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- ULONG ul_TimerValue = 0;
- DWORD dw_Command;
+ int i_ReturnValue = 0;
+ unsigned int ul_TimerValue = 0;
+ unsigned int dw_Command;
double d_RealTimingInterval = 0;
- BYTE b_ModulNbr;
- BYTE b_TorCounter;
- BYTE b_PCIInputClock;
- BYTE b_TimingUnit;
- ULONG ul_TimingInterval;
- ULONG ul_RealTimingInterval = 0;
+ unsigned char b_ModulNbr;
+ unsigned char b_TorCounter;
+ unsigned char b_PCIInputClock;
+ unsigned char b_TimingUnit;
+ unsigned int ul_TimingInterval;
+ unsigned int ul_RealTimingInterval = 0;
i_ReturnValue = insn->n;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
- b_TorCounter = (BYTE) data[0];
- b_PCIInputClock = (BYTE) data[1];
- b_TimingUnit = (BYTE) data[2];
- ul_TimingInterval = (ULONG) data[3];
+ b_TorCounter = (unsigned char) data[0];
+ b_PCIInputClock = (unsigned char) data[1];
+ b_TimingUnit = (unsigned char) data[2];
+ ul_TimingInterval = (unsigned int) data[3];
printk("INPUT clock %d\n", b_PCIInputClock);
/**************************/
@@ -225,7 +225,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(0.00025 * b_PCIInputClock));
@@ -248,7 +248,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(0.00025 * (double)b_PCIInputClock));
@@ -284,7 +284,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -306,7 +306,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(0.25 * b_PCIInputClock));
@@ -329,7 +329,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(0.25 * (double)b_PCIInputClock));
@@ -367,7 +367,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -413,7 +413,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(250.0 * (double)b_PCIInputClock));
@@ -449,7 +449,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -471,7 +471,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(ul_TimingInterval
*
(250000.0
@@ -496,7 +496,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(250000.0
@@ -535,7 +535,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -557,7 +557,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(ul_TimingInterval
*
@@ -585,7 +585,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_RealTimingInterval
=
- (ULONG)
+ (unsigned int)
(ul_TimerValue
/
(250000.0
@@ -629,7 +629,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
if (b_PCIInputClock != APCI1710_40MHZ) {
ul_TimerValue
=
- (ULONG)
+ (unsigned int)
(
(double)
(ul_TimerValue)
@@ -641,7 +641,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
}
fpu_end();
- } // if (b_PCIInputClock != APCI1710_GATE_INPUT)
+ } /* if (b_PCIInputClock != APCI1710_GATE_INPUT) */
else {
/*************************************************************/
/* 2 Clock used for the overflow and the reload from counter */
@@ -652,7 +652,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
ul_TimingInterval
-
2;
- } // if (b_PCIInputClock != APCI1710_GATE_INPUT)
+ } /* if (b_PCIInputClock != APCI1710_GATE_INPUT) */
/****************************/
/* Save the PCI input clock */
@@ -814,7 +814,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
DPRINTK("Base timing selection is wrong\n");
i_ReturnValue = -7;
}
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
else {
/**********************************/
/* Timing unit selection is wrong */
@@ -822,8 +822,8 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
DPRINTK("Timing unit selection is wrong\n");
i_ReturnValue = -6;
- } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
- } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))
+ } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
+ } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */
else {
/*****************************************/
/* The selected PCI input clock is wrong */
@@ -831,8 +831,8 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
DPRINTK("The selected PCI input clock is wrong\n");
i_ReturnValue = -5;
- } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))
- } // if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7)
+ } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */
+ } /* if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) */
else {
/**********************************/
/* Tor Counter selection is wrong */
@@ -840,7 +840,7 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
DPRINTK("Tor Counter selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7)
+ } /* if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) */
} else {
/******************************************/
/* The module is not a tor counter module */
@@ -857,20 +857,20 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
- data[0] = (UINT) ul_RealTimingInterval;
- return (i_ReturnValue);
+ data[0] = (unsigned int) ul_RealTimingInterval;
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnableTorCounter |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TorCounter, |
-| BYTE_ b_InputMode, |
-| BYTE_ b_ExternGate, |
-| BYTE_ b_CycleMode, |
-| BYTE_ b_InterruptEnable) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TorCounter, |
+| unsigned char_ b_InputMode, |
+| unsigned char_ b_ExternGate, |
+| unsigned char_ b_CycleMode, |
+| unsigned char_ b_InterruptEnable) |
+----------------------------------------------------------------------------+
| Task : Enable the tor counter (b_TorCounter) from selected |
| module (b_ModulNbr). You must calling the |
@@ -883,13 +883,13 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
| The b_CycleMode parameter determine if you will |
| measured a single or more cycle. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
-| BYTE_ b_TorCounter : Tor counter selection (0 or 1). |
-| BYTE_ b_InputMode : Input signal level selection |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). |
+| unsigned char_ b_InputMode : Input signal level selection |
| 0 : Tor count each low level |
| 1 : Tor count each high level|
-| BYTE_ b_ExternGate : Extern gate action selection |
+| unsigned char_ b_ExternGate : Extern gate action selection |
| 0 : Extern gate signal not |
| used |
| 1 : Extern gate signal used. |
@@ -928,9 +928,9 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
| The gate input is used for the |
| signal B |
| |
-| BYTE_ b_CycleMode : Selected the tor counter |
+| unsigned char_ b_CycleMode : Selected the tor counter |
| acquisition mode |
-| BYTE_ b_InterruptEnable : Enable or disable the |
+| unsigned char_ b_InterruptEnable : Enable or disable the |
| tor counter interrupt. |
| APCI1710_ENABLE: |
| Enable the tor counter |
@@ -959,9 +959,9 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_DisableTorCounter |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TorCounter) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TorCounter) |
+----------------------------------------------------------------------------+
| Task : Disable the tor counter (b_TorCounter) from selected |
| module (b_ModulNbr). If you disable the tor counter |
@@ -969,9 +969,9 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
| counter witch the " i_APCI1710_EnableTorCounter" |
| function, the status register is cleared |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
-| BYTE_ b_TorCounter : Tor counter selection (0 or 1). |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -987,29 +987,29 @@ INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
- DWORD dw_DummyRead;
- DWORD dw_ConfigReg;
- BYTE b_ModulNbr, b_Action;
- BYTE b_TorCounter;
- BYTE b_InputMode;
- BYTE b_ExternGate;
- BYTE b_CycleMode;
- BYTE b_InterruptEnable;
-
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_Action = (BYTE) data[0]; // enable or disable
- b_TorCounter = (BYTE) data[1];
- b_InputMode = (BYTE) data[2];
- b_ExternGate = (BYTE) data[3];
- b_CycleMode = (BYTE) data[4];
- b_InterruptEnable = (BYTE) data[5];
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
+ unsigned int dw_DummyRead;
+ unsigned int dw_ConfigReg;
+ unsigned char b_ModulNbr, b_Action;
+ unsigned char b_TorCounter;
+ unsigned char b_InputMode;
+ unsigned char b_ExternGate;
+ unsigned char b_CycleMode;
+ unsigned char b_InterruptEnable;
+
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_Action = (unsigned char) data[0]; /* enable or disable */
+ b_TorCounter = (unsigned char) data[1];
+ b_InputMode = (unsigned char) data[2];
+ b_ExternGate = (unsigned char) data[3];
+ b_CycleMode = (unsigned char) data[4];
+ b_InterruptEnable = (unsigned char) data[5];
i_ReturnValue = insn->n;;
- devpriv->tsk_Current = current; // Save the current process task structure
+ devpriv->tsk_Current = current; /* Save the current process task structure */
/**************************/
/* Test the module number */
/**************************/
@@ -1027,7 +1027,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
/**********************************/
if (b_TorCounter <= 1) {
- switch (b_Action) // Enable or Disable
+ switch (b_Action) /* Enable or Disable */
{
case APCI1710_ENABLE:
/***********************************/
@@ -1149,7 +1149,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
|
0x780;
- } // if (b_InputMode == APCI1710_TOR_SIMPLE_MODE)
+ } /* if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) */
/***********************/
/* Test if double mode */
@@ -1166,12 +1166,12 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
|
0x180;
- } // if (b_InputMode == APCI1710_TOR_DOUBLE_MODE)
+ } /* if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) */
b_InputMode
=
0;
- } // if (b_InputMode > 1)
+ } /* if (b_InputMode > 1) */
/*******************/
/* Set the command */
@@ -1237,7 +1237,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
outl(1, devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));
- } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))
+ } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */
else {
/********************************/
/* Interrupt parameter is wrong */
@@ -1247,8 +1247,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
i_ReturnValue
=
-9;
- } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))
- } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))
+ } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */
+ } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */
else {
/***********************************************/
/* Tor counter acquisition mode cycle is wrong */
@@ -1258,8 +1258,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
i_ReturnValue
=
-8;
- } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))
- } // if (b_ExternGate >= 0 && b_ExternGate <= 1)
+ } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */
+ } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */
else {
/***********************************/
/* Extern gate input mode is wrong */
@@ -1268,8 +1268,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
DPRINTK("Extern gate input mode is wrong\n");
i_ReturnValue =
-7;
- } // if (b_ExternGate >= 0 && b_ExternGate <= 1)
- } // if (b_InputMode >= 0 && b_InputMode <= 1)
+ } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */
+ } /* if (b_InputMode >= 0 && b_InputMode <= 1) */
else {
/***************************************/
/* Tor input signal selection is wrong */
@@ -1329,7 +1329,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
s_BoardInfos.
ui_Address + 8 +
(16 * b_TorCounter) + (64 * b_ModulNbr));
- } // if (dw_Status & 0x1)
+ } /* if (dw_Status & 0x1) */
else {
/***************************/
/* Tor counter not enabled */
@@ -1337,8 +1337,8 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
DPRINTK("Tor counter not enabled \n");
i_ReturnValue = -6;
- } // if (dw_Status & 0x1)
- } // if (dw_Status & 0x10)
+ } /* if (dw_Status & 0x1) */
+ } /* if (dw_Status & 0x10) */
else {
/*******************************/
/* Tor counter not initialised */
@@ -1346,10 +1346,10 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
DPRINTK("Tor counter not initialised\n");
i_ReturnValue = -5;
- } // // if (dw_Status & 0x10)
+ } /* // if (dw_Status & 0x10) */
- } // switch
- } // if (b_TorCounter <= 1)
+ } /* switch */
+ } /* if (b_TorCounter <= 1) */
else {
/**********************************/
/* Tor counter selection is wrong */
@@ -1357,7 +1357,7 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
DPRINTK("Tor counter selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_TorCounter <= 1)
+ } /* if (b_TorCounter <= 1) */
} else {
/******************************************/
/* The module is not a tor counter module */
@@ -1375,22 +1375,22 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_GetTorCounterInitialisation |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TorCounter, |
-| PBYTE_ pb_TimingUnit, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TorCounter, |
+| unsigned char *_ pb_TimingUnit, |
| PULONG_ pul_TimingInterval, |
-| PBYTE_ pb_InputMode, |
-| PBYTE_ pb_ExternGate, |
-| PBYTE_ pb_CycleMode, |
-| PBYTE_ pb_Enable, |
-| PBYTE_ pb_InterruptEnable)|
+| unsigned char *_ pb_InputMode, |
+| unsigned char *_ pb_ExternGate, |
+| unsigned char *_ pb_CycleMode, |
+| unsigned char *_ pb_Enable, |
+| unsigned char *_ pb_InterruptEnable)|
+----------------------------------------------------------------------------+
| Task : Enable the tor counter (b_TorCounter) from selected |
| module (b_ModulNbr). You must calling the |
@@ -1403,37 +1403,37 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
| The b_CycleMode parameter determine if you will |
| measured a single or more cycle. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
-| BYTE_ b_TorCounter : Tor counter selection (0 or 1)
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+| unsigned char_ b_TorCounter : Tor counter selection (0 or 1)
b_ModulNbr = CR_AREF(insn->chanspec);
b_TorCounter = CR_CHAN(insn->chanspec);
. |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_TimingUnit : Base timing unit (0 to 4) |
+| Output Parameters : unsigned char *_ pb_TimingUnit : Base timing unit (0 to 4) |
| 0 : ns |
| 1 : µs |
| 2 : ms |
| 3 : s |
| 4 : mn |
| PULONG_ pul_TimingInterval : Base timing value. |
-| PBYTE_ pb_InputMode : Input signal level |
+| unsigned char *_ pb_InputMode : Input signal level |
| selection |
| 0 : Tor count each low level |
| 1 : Tor count each high level|
-| PBYTE_ pb_ExternGate : Extern gate action |
+| unsigned char *_ pb_ExternGate : Extern gate action |
| selection |
| 0 : Extern gate signal not |
| used |
| 1 : Extern gate signal used|
-| PBYTE_ pb_CycleMode : Tor counter acquisition |
+| unsigned char *_ pb_CycleMode : Tor counter acquisition |
| mode |
-| PBYTE_ pb_Enable : Indicate if the tor counter|
+| unsigned char *_ pb_Enable : Indicate if the tor counter|
| is enabled or no |
| 0 : Tor counter disabled |
| 1 : Tor counter enabled |
-| PBYTE_ pb_InterruptEnable : Enable or disable the |
+| unsigned char *_ pb_InterruptEnable : Enable or disable the |
| tor counter interrupt. |
| APCI1710_ENABLE: |
| Enable the tor counter |
@@ -1441,13 +1441,13 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
| APCI1710_DISABLE: |
| Disable the tor counter |
| interrupt
- pb_TimingUnit = (PBYTE) &data[0];
- pul_TimingInterval = (PULONG) &data[1];
- pb_InputMode = (PBYTE) &data[2];
- pb_ExternGate = (PBYTE) &data[3];
- pb_CycleMode = (PBYTE) &data[4];
- pb_Enable = (PBYTE) &data[5];
- pb_InterruptEnable = (PBYTE) &data[6];
+ pb_TimingUnit = (unsigned char *) &data[0];
+ pul_TimingInterval = (unsigned int *) &data[1];
+ pb_InputMode = (unsigned char *) &data[2];
+ pb_ExternGate = (unsigned char *) &data[3];
+ pb_CycleMode = (unsigned char *) &data[4];
+ pb_Enable = (unsigned char *) &data[5];
+ pb_InterruptEnable = (unsigned char *) &data[6];
|
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
@@ -1460,32 +1460,32 @@ INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
- BYTE b_ModulNbr;
- BYTE b_TorCounter;
- PBYTE pb_TimingUnit;
- PULONG pul_TimingInterval;
- PBYTE pb_InputMode;
- PBYTE pb_ExternGate;
- PBYTE pb_CycleMode;
- PBYTE pb_Enable;
- PBYTE pb_InterruptEnable;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
+ unsigned char b_ModulNbr;
+ unsigned char b_TorCounter;
+ unsigned char *pb_TimingUnit;
+ unsigned int *pul_TimingInterval;
+ unsigned char *pb_InputMode;
+ unsigned char *pb_ExternGate;
+ unsigned char *pb_CycleMode;
+ unsigned char *pb_Enable;
+ unsigned char *pb_InterruptEnable;
i_ReturnValue = insn->n;
b_ModulNbr = CR_AREF(insn->chanspec);
b_TorCounter = CR_CHAN(insn->chanspec);
- pb_TimingUnit = (PBYTE) & data[0];
- pul_TimingInterval = (PULONG) & data[1];
- pb_InputMode = (PBYTE) & data[2];
- pb_ExternGate = (PBYTE) & data[3];
- pb_CycleMode = (PBYTE) & data[4];
- pb_Enable = (PBYTE) & data[5];
- pb_InterruptEnable = (PBYTE) & data[6];
+ pb_TimingUnit = (unsigned char *) &data[0];
+ pul_TimingInterval = (unsigned int *) &data[1];
+ pb_InputMode = (unsigned char *) &data[2];
+ pb_ExternGate = (unsigned char *) &data[3];
+ pb_CycleMode = (unsigned char *) &data[4];
+ pb_Enable = (unsigned char *) &data[5];
+ pb_InterruptEnable = (unsigned char *) &data[6];
/**************************/
/* Test the module number */
@@ -1526,9 +1526,9 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
(64 * b_ModulNbr));
*pb_CycleMode =
- (BYTE) ((dw_Status >> 4) & 1);
+ (unsigned char) ((dw_Status >> 4) & 1);
*pb_InterruptEnable =
- (BYTE) ((dw_Status >> 5) & 1);
+ (unsigned char) ((dw_Status >> 5) & 1);
/******************************************************/
/* Test if extern gate used for clock or for signal B */
@@ -1569,25 +1569,25 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
*pb_InputMode =
APCI1710_TOR_QUADRUPLE_MODE;
}
- } // if (dw_Status & 0x400)
+ } /* if (dw_Status & 0x400) */
else {
*pb_InputMode = 1;
- } // // if (dw_Status & 0x400)
+ } /* // if (dw_Status & 0x400) */
/************************/
/* Extern gate not used */
/************************/
*pb_ExternGate = 0;
- } // if (dw_Status & 0x600)
+ } /* if (dw_Status & 0x600) */
else {
*pb_InputMode =
- (BYTE) ((dw_Status >> 6)
+ (unsigned char) ((dw_Status >> 6)
& 1);
*pb_ExternGate =
- (BYTE) ((dw_Status >> 7)
+ (unsigned char) ((dw_Status >> 7)
& 1);
- } // if (dw_Status & 0x600)
+ } /* if (dw_Status & 0x600) */
*pb_TimingUnit =
devpriv->
@@ -1611,7 +1611,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
i_ReturnValue = -5;
}
- } // if (b_TorCounter <= 1)
+ } /* if (b_TorCounter <= 1) */
else {
/**********************************/
/* Tor counter selection is wrong */
@@ -1619,7 +1619,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
DPRINTK("Tor counter selection is wrong \n");
i_ReturnValue = -4;
- } // if (b_TorCounter <= 1)
+ } /* if (b_TorCounter <= 1) */
} else {
/******************************************/
/* The module is not a tor counter module */
@@ -1637,17 +1637,17 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadTorCounterValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_TorCounter, |
-| UINT_ ui_TimeOut, |
-| PBYTE_ pb_TorCounterStatus, |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_TorCounter, |
+| unsigned int_ ui_TimeOut, |
+| unsigned char *_ pb_TorCounterStatus, |
| PULONG_ pul_TorCounterValue) |
+----------------------------------------------------------------------------+
| Task case APCI1710_TOR_GETPROGRESSSTATUS: Return the tor counter
@@ -1660,15 +1660,15 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
| (pul_TorCounterValue) after a conting cycle stop |
| from selected tor counter module (b_ModulNbr). |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3) |
-| BYTE_ b_TorCounter : Tor counter selection (0 or 1).
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
+| unsigned char_ b_TorCounter : Tor counter selection (0 or 1).
b_ModulNbr = CR_AREF(insn->chanspec);
- b_ReadType = (BYTE) data[0];
- b_TorCounter = (BYTE) data[1];
- ui_TimeOut = (UINT) data[2]; |
+ b_ReadType = (unsigned char) data[0];
+ b_TorCounter = (unsigned char) data[1];
+ ui_TimeOut = (unsigned int) data[2]; |
+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_ pb_TorCounterStatus : Return the tor counter |
+| Output Parameters : unsigned char *_ pb_TorCounterStatus : Return the tor counter |
| status. |
| 0 : Conting cycle not started|
| Software gate not set. |
@@ -1683,9 +1683,9 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
| function |
| "i_APCI1710_InitTorCounter"|
| 4 : Timeeout occur |
-| PULONG pul_TorCounterValue : Tor counter value.
- pb_TorCounterStatus=(PBYTE) &data[0];
- pul_TorCounterValue=(PULONG) &data[1]; |
+| unsigned int * pul_TorCounterValue : Tor counter value.
+ pb_TorCounterStatus=(unsigned char *) &data[0];
+ pul_TorCounterValue=(unsigned int *) &data[1]; |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
@@ -1700,27 +1700,27 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_Status;
- DWORD dw_TimeOut = 0;
+ int i_ReturnValue = 0;
+ unsigned int dw_Status;
+ unsigned int dw_TimeOut = 0;
- BYTE b_ModulNbr;
- BYTE b_TorCounter;
- BYTE b_ReadType;
- UINT ui_TimeOut;
- PBYTE pb_TorCounterStatus;
- PULONG pul_TorCounterValue;
+ unsigned char b_ModulNbr;
+ unsigned char b_TorCounter;
+ unsigned char b_ReadType;
+ unsigned int ui_TimeOut;
+ unsigned char *pb_TorCounterStatus;
+ unsigned int *pul_TorCounterValue;
i_ReturnValue = insn->n;
b_ModulNbr = CR_AREF(insn->chanspec);
- b_ReadType = (BYTE) data[0];
- b_TorCounter = (BYTE) data[1];
- ui_TimeOut = (UINT) data[2];
- pb_TorCounterStatus = (PBYTE) & data[0];
- pul_TorCounterValue = (PULONG) & data[1];
+ b_ReadType = (unsigned char) data[0];
+ b_TorCounter = (unsigned char) data[1];
+ ui_TimeOut = (unsigned int) data[2];
+ pb_TorCounterStatus = (unsigned char *) &data[0];
+ pul_TorCounterValue = (unsigned int *) &data[1];
/**************************/
/* Test the module number */
@@ -1896,7 +1896,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
+
(16 * b_TorCounter) + (64 * b_ModulNbr));
break;
- } // if ((dw_Status & 4) == 4)
+ } /* if ((dw_Status & 4) == 4) */
else {
/*******************************/
/* Test if measurement stopped */
@@ -1927,7 +1927,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
(16 * b_TorCounter) + (64 * b_ModulNbr));
break;
- } // if ((dw_Status & 2) == 2)
+ } /* if ((dw_Status & 2) == 2) */
else {
/*******************************/
/* Test if measurement started */
@@ -1941,7 +1941,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
*pb_TorCounterStatus
=
1;
- } // if ((dw_Status & 1) == 1)
+ } /* if ((dw_Status & 1) == 1) */
else {
/***************************/
/* Measurement not started */
@@ -1950,9 +1950,9 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
*pb_TorCounterStatus
=
0;
- } // if ((dw_Status & 1) == 1)
- } // if ((dw_Status & 2) == 2)
- } // if ((dw_Status & 8) == 8)
+ } /* if ((dw_Status & 1) == 1) */
+ } /* if ((dw_Status & 2) == 2) */
+ } /* if ((dw_Status & 8) == 8) */
if (dw_TimeOut == ui_TimeOut) {
/*****************/
@@ -1973,7 +1973,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
mdelay(1000);
}
- } // for (;;)
+ } /* for (;;) */
/*************************/
/* Test if timeout occur */
@@ -2001,8 +2001,8 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
default:
printk("Inputs wrong\n");
- } // switch end
- } // if (dw_Status & 0x1)
+ } /* switch end */
+ } /* if (dw_Status & 0x1) */
else {
/***************************/
/* Tor counter not enabled */
@@ -2010,7 +2010,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
DPRINTK("Tor counter not enabled\n");
i_ReturnValue = -6;
- } // if (dw_Status & 0x1)
+ } /* if (dw_Status & 0x1) */
} else {
/*******************************/
/* Tor counter not initialised */
@@ -2019,7 +2019,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
DPRINTK("Tor counter not initialised\n");
i_ReturnValue = -5;
}
- } // if (b_TorCounter <= 1)
+ } /* if (b_TorCounter <= 1) */
else {
/**********************************/
/* Tor counter selection is wrong */
@@ -2027,7 +2027,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
DPRINTK("Tor counter selection is wrong\n");
i_ReturnValue = -4;
- } // if (b_TorCounter <= 1)
+ } /* if (b_TorCounter <= 1) */
} else {
/******************************************/
/* The module is not a tor counter module */
@@ -2045,5 +2045,5 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h
index c245d16207b8..03a93cb26d7a 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h
@@ -35,23 +35,23 @@
/*
* TOR_COUNTER INISIALISATION FUNCTION
*/
-INT i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev,
+int i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev,
+int i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
-INT i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev,
+int i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
/*
* TOR_COUNTER READ FUNCTION
*/
-INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev,
+int i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c
index 68b1d26bae13..d3d78d37de5c 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -63,12 +63,12 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitTTLIODirection |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_PortAMode, |
-| BYTE_ b_PortBMode, |
-| BYTE_ b_PortCMode, |
-| BYTE_ b_PortDMode) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_PortAMode, |
+| unsigned char_ b_PortBMode, |
+| unsigned char_ b_PortCMode, |
+| unsigned char_ b_PortDMode) |
+----------------------------------------------------------------------------+
| Task APCI1710_TTL_INIT (using defaults) : Configure the TTL I/O operating mode from selected |
| module (b_ModulNbr). You must calling this function be|
@@ -76,15 +76,15 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
APCI1710_TTL_INITDIRECTION(user inputs for direction)
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3)
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_InitType = (BYTE) data[0];
- b_PortAMode = (BYTE) data[1];
- b_PortBMode = (BYTE) data[2];
- b_PortCMode = (BYTE) data[3];
- b_PortDMode = (BYTE) data[4];|
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_InitType = (unsigned char) data[0];
+ b_PortAMode = (unsigned char) data[1];
+ b_PortBMode = (unsigned char) data[2];
+ b_PortCMode = (unsigned char) data[3];
+ b_PortDMode = (unsigned char) data[4];|
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -100,19 +100,19 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- BYTE b_ModulNbr;
- BYTE b_InitType;
- BYTE b_PortAMode;
- BYTE b_PortBMode;
- BYTE b_PortCMode;
- BYTE b_PortDMode;
-
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
- b_InitType = (BYTE) data[0];
+ int i_ReturnValue = 0;
+ unsigned char b_ModulNbr;
+ unsigned char b_InitType;
+ unsigned char b_PortAMode;
+ unsigned char b_PortBMode;
+ unsigned char b_PortCMode;
+ unsigned char b_PortDMode;
+
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
+ b_InitType = (unsigned char) data[0];
i_ReturnValue = insn->n;
/**************************/
@@ -172,10 +172,10 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub
case APCI1710_TTL_INITDIRECTION:
- b_PortAMode = (BYTE) data[1];
- b_PortBMode = (BYTE) data[2];
- b_PortCMode = (BYTE) data[3];
- b_PortDMode = (BYTE) data[4];
+ b_PortAMode = (unsigned char) data[1];
+ b_PortBMode = (unsigned char) data[2];
+ b_PortCMode = (unsigned char) data[3];
+ b_PortDMode = (unsigned char) data[4];
/********************/
/* Test the version */
@@ -322,7 +322,7 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub
DPRINTK("\n");
default:
printk("Bad Config Type\n");
- } // switch end
+ } /* switch end */
} else {
/**********************************/
/* The module is not a TTL module */
@@ -340,7 +340,7 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -352,11 +352,11 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadTTLIOChannelValue |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_SelectedPort, |
-| BYTE_ b_InputChannel, |
-| PBYTE_ pb_ChannelStatus) |
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_SelectedPort, |
+| unsigned char_ b_InputChannel, |
+| unsigned char *_ pb_ChannelStatus) |
+----------------------------------------------------------------------------+
| Task : Read the status from selected TTL digital input |
| (b_InputChannel)
@@ -366,32 +366,32 @@ INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 7) |
-| BYTE_ b_SelectedPort, : Selection from TTL I/O |
+| unsigned char_ b_SelectedPort, : Selection from TTL I/O |
| port (0 to 2) |
| 0 : Port A selection |
| 1 : Port B selection |
| 2 : Port C selection |
| 3 : Port D selection |
-| BYTE_ b_InputChannel : Selection from digital |
+| unsigned char_ b_InputChannel : Selection from digital |
| input ( 0 to 2)
APCI1710_TTL_READCHANNEL
b_ModulNbr = CR_AREF(insn->chanspec);
b_SelectedPort= CR_RANGE(insn->chanspec);
b_InputChannel= CR_CHAN(insn->chanspec);
- b_ReadType = (BYTE) data[0];
+ b_ReadType = (unsigned char) data[0];
APCI1710_TTL_READPORT|
b_ModulNbr = CR_AREF(insn->chanspec);
b_SelectedPort= CR_RANGE(insn->chanspec);
- b_ReadType = (BYTE) data[0];
+ b_ReadType = (unsigned char) data[0];
+----------------------------------------------------------------------------+
| Output Parameters : data[0]
- PBYTE_ pb_ChannelStatus : Digital input channel |
+ unsigned char *_ pb_ChannelStatus : Digital input channel |
| status |
| 0 : Channle is not active|
| 1 : Channle is active |
@@ -406,20 +406,20 @@ APCI1710_TTL_READCHANNEL
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg;
- BYTE b_ModulNbr;
- BYTE b_SelectedPort;
- BYTE b_InputChannel;
- BYTE b_ReadType;
- PBYTE pb_ChannelStatus;
- PBYTE pb_PortValue;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg;
+ unsigned char b_ModulNbr;
+ unsigned char b_SelectedPort;
+ unsigned char b_InputChannel;
+ unsigned char b_ReadType;
+ unsigned char *pb_ChannelStatus;
+ unsigned char *pb_PortValue;
i_ReturnValue = insn->n;
- b_ReadType = (BYTE) data[0];
+ b_ReadType = (unsigned char) data[0];
b_ModulNbr = CR_AREF(insn->chanspec);
b_SelectedPort = CR_RANGE(insn->chanspec);
b_InputChannel = CR_CHAN(insn->chanspec);
@@ -439,7 +439,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
switch (b_ReadType) {
case APCI1710_TTL_READCHANNEL:
- pb_ChannelStatus = (PBYTE) & data[0];
+ pb_ChannelStatus = (unsigned char *) &data[0];
/********************************/
/* Test the TTL I/O port number */
/********************************/
@@ -493,7 +493,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
*pb_ChannelStatus
=
- (BYTE) (
+ (unsigned char) (
(dw_StatusReg
>>
(8 * b_SelectedPort)) >> b_InputChannel) & 1;
@@ -533,7 +533,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
break;
case APCI1710_TTL_READPORT:
- pb_PortValue = (PBYTE) & data[0];
+ pb_PortValue = (unsigned char *) &data[0];
/********************************/
/* Test the TTL I/O port number */
/********************************/
@@ -578,7 +578,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
(64 * b_ModulNbr));
*pb_PortValue =
- (BYTE) (
+ (unsigned char) (
(dw_StatusReg >>
(8 * b_SelectedPort)) & 0xFF);
} else {
@@ -610,7 +610,7 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
default:
printk("Bad ReadType\n");
- } //End Switch
+ } /* End Switch */
} else {
/**********************************/
/* The module is not a TTL module */
@@ -628,20 +628,20 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device
+| Function Name : int i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device
*dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Read the status from all digital input ports |
| (port A, port B and port C) from selected TTL |
| module (b_ModulNbr) |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710|
-| BYTE_ b_ModulNbr : Module number to |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
+| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_PortValue : Digital TTL inputs port |
@@ -655,17 +655,17 @@ INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg;
- BYTE b_ModulNbr;
- PULONG pul_PortValue;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg;
+ unsigned char b_ModulNbr;
+ unsigned int *pul_PortValue;
- b_ModulNbr = (BYTE) CR_AREF(insn->chanspec);
+ b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
i_ReturnValue = insn->n;
- pul_PortValue = (PULONG) & data[0];
+ pul_PortValue = (unsigned int *) &data[0];
/**************************/
/* Test the module number */
@@ -777,7 +777,7 @@ INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -789,19 +789,19 @@ INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_SetTTLIOChlOn |
-| (BYTE_ b_BoardHandle, |
-| BYTE_ b_ModulNbr, |
-| BYTE_ b_OutputChannel)
-INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi_subdevice *s,
+| (unsigned char_ b_BoardHandle, |
+| unsigned char_ b_ModulNbr, |
+| unsigned char_ b_OutputChannel)
+int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Sets or resets the output witch has been passed with the |
| parameter b_Channel. Setting an output means setting |
| an ouput high. |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 |
-| BYTE_ b_ModulNbr : Selected module number (0 to 3)|
-| BYTE_ b_OutputChannel : Selection from digital output |
+| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
+| unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
+| unsigned char_ b_OutputChannel : Selection from digital output |
| channel (0 or 1) |
| 0 : PD0 |
| 1 : PD1 |
@@ -811,7 +811,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi
b_ModulNbr = CR_AREF(insn->chanspec);
b_OutputChannel= CR_CHAN(insn->chanspec);
- ui_State = data[0]; // ON or OFF
+ ui_State = data[0]; /* ON or OFF */
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -825,19 +825,19 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi
+----------------------------------------------------------------------------+
*/
-INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = 0;
- DWORD dw_StatusReg = 0;
- BYTE b_ModulNbr;
- BYTE b_OutputChannel;
- UINT ui_State;
+ int i_ReturnValue = 0;
+ unsigned int dw_StatusReg = 0;
+ unsigned char b_ModulNbr;
+ unsigned char b_OutputChannel;
+ unsigned int ui_State;
i_ReturnValue = insn->n;
b_ModulNbr = CR_AREF(insn->chanspec);
b_OutputChannel = CR_CHAN(insn->chanspec);
- ui_State = data[0]; // ON or OFF
+ ui_State = data[0]; /* ON or OFF */
/**************************/
/* Test the module number */
@@ -953,7 +953,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev,
ui_Address
+
(64 * b_ModulNbr));
- if (ui_State) // ON
+ if (ui_State) /* ON */
{
dw_StatusReg
=
@@ -969,7 +969,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev,
(b_OutputChannel
%
8));
- } else // Off
+ } else /* Off */
{
dw_StatusReg
=
@@ -1034,5 +1034,5 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device * dev,
i_ReturnValue = -2;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h
index 00915ddf9218..c4f11347f243 100644
--- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h
+++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h
@@ -24,21 +24,21 @@
/*
* TTL INISIALISATION FUNCTION
*/
-INT i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/*
* TTL INPUT FUNCTION
*/
-INT i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev,
+int i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/*
* TTL OUTPUT FUNCTIONS
*/
-INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,
+int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
index b0907ec14667..6e9e7ed4dba9 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
+++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -49,37 +49,37 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
#include "addi_amcc_S5920.h"
/*+----------------------------------------------------------------------------+*/
-/*| Function Name : INT i_AddiHeaderRW_ReadEeprom |*/
-/*| (INT i_NbOfWordsToRead, |*/
-/*| DWORD dw_PCIBoardEepromAddress, |*/
-/*| WORD w_EepromStartAddress, |*/
-/*| PWORD pw_DataRead) |*/
+/*| Function Name : int i_AddiHeaderRW_ReadEeprom |*/
+/*| (int i_NbOfWordsToRead, |*/
+/*| unsigned int dw_PCIBoardEepromAddress, |*/
+/*| unsigned short w_EepromStartAddress, |*/
+/*| unsigned short * pw_DataRead) |*/
/*+----------------------------------------------------------------------------+*/
/*| Task : Read word from the 5920 eeprom. |*/
/*+----------------------------------------------------------------------------+*/
-/*| Input Parameters : INT i_NbOfWordsToRead : Nbr. of word to read |*/
-/*| DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/
-/*| WORD w_EepromStartAddress : Eeprom strat address |*/
+/*| Input Parameters : int i_NbOfWordsToRead : Nbr. of word to read |*/
+/*| unsigned int dw_PCIBoardEepromAddress : Address of the eeprom |*/
+/*| unsigned short w_EepromStartAddress : Eeprom strat address |*/
/*+----------------------------------------------------------------------------+*/
-/*| Output Parameters : PWORD pw_DataRead : Read data |*/
+/*| Output Parameters : unsigned short * pw_DataRead : Read data |*/
/*+----------------------------------------------------------------------------+*/
/*| Return Value : - |*/
/*+----------------------------------------------------------------------------+*/
-INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
- DWORD dw_PCIBoardEepromAddress,
- WORD w_EepromStartAddress, PWORD pw_DataRead)
+int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
+ unsigned int dw_PCIBoardEepromAddress,
+ unsigned short w_EepromStartAddress, unsigned short *pw_DataRead)
{
- DWORD dw_eeprom_busy = 0;
- INT i_Counter = 0;
- INT i_WordCounter;
- INT i;
- BYTE pb_ReadByte[1];
- BYTE b_ReadLowByte = 0;
- BYTE b_ReadHighByte = 0;
- BYTE b_SelectedAddressLow = 0;
- BYTE b_SelectedAddressHigh = 0;
- WORD w_ReadWord = 0;
+ unsigned int dw_eeprom_busy = 0;
+ int i_Counter = 0;
+ int i_WordCounter;
+ int i;
+ unsigned char pb_ReadByte[1];
+ unsigned char b_ReadLowByte = 0;
+ unsigned char b_ReadHighByte = 0;
+ unsigned char b_SelectedAddressLow = 0;
+ unsigned char b_SelectedAddressHigh = 0;
+ unsigned short w_ReadWord = 0;
for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead;
i_WordCounter++) {
@@ -88,106 +88,99 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
for (i_Counter = 0; i_Counter < 2; i_Counter++) {
- b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; //Read the low 8 bit part
- b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; //Read the high 8 bit part
+ b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; /* Read the low 8 bit part */
+ b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; /* Read the high 8 bit part */
- //Select the load low address mode
+ /* Select the load low address mode */
outb(NVCMD_LOAD_LOW,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
3);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Load the low address
+ /* Load the low address */
outb(b_SelectedAddressLow,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
2);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Select the load high address mode
+ /* Select the load high address mode */
outb(NVCMD_LOAD_HIGH,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
3);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Load the high address
+ /* Load the high address */
outb(b_SelectedAddressHigh,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
2);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Select the READ mode
+ /* Select the READ mode */
outb(NVCMD_BEGIN_READ,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
3);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Read data into the EEPROM
+ /* Read data into the EEPROM */
*pb_ReadByte =
inb(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR + 2);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Select the upper address part
+ /* Select the upper address part */
if (i_Counter == 0) {
b_ReadLowByte = pb_ReadByte[0];
} else {
b_ReadHighByte = pb_ReadByte[0];
}
- //Sleep
- for (i = 0; i < 10000; i++) ;
+ /* Sleep */
+ msleep(1);
}
w_ReadWord =
@@ -196,8 +189,8 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
pw_DataRead[i_WordCounter] = w_ReadWord;
- w_EepromStartAddress += 2; // to read the next word
+ w_EepromStartAddress += 2; /* to read the next word */
- } // for (...) i_NbOfWordsToRead
- return (0);
+ } /* for (...) i_NbOfWordsToRead */
+ return 0;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h
index 9ae56bc3adad..622a4ac2b799 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h
+++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h
@@ -22,6 +22,6 @@
#define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */
#define NVCMD_BEGIN_WRITE (0x6 << 5) /* EEPROM begin write command */
-INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
- DWORD dw_PCIBoardEepromAddress,
- WORD w_EepromStartAddress, PWORD pw_DataRead);
+int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
+ unsigned int dw_PCIBoardEepromAddress,
+ unsigned short w_EepromStartAddress, unsigned short *pw_DataRead);
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
index b50774cdcf77..d288289143ea 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
+++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
@@ -85,7 +85,7 @@
#define AMCC_OP_REG_MRTC 0x30
#define AMCC_OP_REG_MBEF 0x34
#define AMCC_OP_REG_INTCSR 0x38
-/* INT source */
+/* int source */
#define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2)
/* FIFO ctrl */
#define AMCC_OP_REG_INTCSR_FEC (AMCC_OP_REG_INTCSR + 3)
@@ -343,7 +343,7 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id,
*card = amcc;
return 0; /* ok, card is found */
} else {
- rt_printk(" - \nCard on requested position is used b:s %d:%d!\n",
+ printk(" - \nCard on requested position is used b:s %d:%d!\n",
pci_bus, pci_slot);
return 2; /* card exist but is used */
}
@@ -447,7 +447,7 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
/* use autodetection */
card = ptr_find_free_pci_card_by_device(vendor_id, device_id);
if (card == NULL) {
- rt_printk(" - Unused card not found in system!\n");
+ printk(" - Unused card not found in system!\n");
return NULL;
}
} else {
@@ -455,18 +455,18 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
pci_bus, pci_slot,
&card)) {
case 1:
- rt_printk(" - Card not found on requested position b:s %d:%d!\n",
+ printk(" - Card not found on requested position b:s %d:%d!\n",
pci_bus, pci_slot);
return NULL;
case 2:
- rt_printk(" - Card on requested position is used b:s %d:%d!\n",
+ printk(" - Card on requested position is used b:s %d:%d!\n",
pci_bus, pci_slot);
return NULL;
}
}
if (pci_card_alloc(card, i_Master) != 0) {
- rt_printk(" - Can't allocate card!\n");
+ printk(" - Can't allocate card!\n");
return NULL;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c
index 618c69b6838d..a56535fbcd3e 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_common.c
+++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -68,25 +68,25 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
#include "addi_common.h"
#include "addi_amcc_s5933.h"
-//Update-0.7.57->0.7.68MODULE_AUTHOR("ADDI-DATA GmbH <info@addi-data.com>");
-//Update-0.7.57->0.7.68MODULE_DESCRIPTION("Comedi ADDI-DATA module");
-//Update-0.7.57->0.7.68MODULE_LICENSE("GPL");
+/* Update-0.7.57->0.7.68MODULE_AUTHOR("ADDI-DATA GmbH <info@addi-data.com>"); */
+/* Update-0.7.57->0.7.68MODULE_DESCRIPTION("Comedi ADDI-DATA module"); */
+/* Update-0.7.57->0.7.68MODULE_LICENSE("GPL"); */
-#define devpriv ((addi_private *)dev->private)
-#define this_board ((boardtype *)dev->board_ptr)
+#define devpriv ((struct addi_private *)dev->private)
+#define this_board ((struct addi_board *)dev->board_ptr)
#if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300)
-//BYTE b_SaveFPUReg [94];
+/* BYTE b_SaveFPUReg [94]; */
void fpu_begin(void)
{
- //asm ("fstenv b_SaveFPUReg");
+ /* asm ("fstenv b_SaveFPUReg"); */
kernel_fpu_begin();
}
void fpu_end(void)
{
- // asm ("frstor b_SaveFPUReg");
+ /* asm ("frstor b_SaveFPUReg"); */
kernel_fpu_end();
}
#endif
@@ -219,7 +219,7 @@ static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
-static const boardtype boardtypes[] = {
+static const struct addi_board boardtypes[] = {
#ifdef CONFIG_APCI_3120
{"apci3120",
APCI3120_BOARD_VENDOR_ID,
@@ -901,7 +901,7 @@ static const boardtype boardtypes[] = {
NULL},
#endif
#ifdef CONFIG_APCI_3300
- //Begin JK 20.10.2004: APCI-3300 integration
+ /* Begin JK .20.10.2004 = APCI-3300 integration */
{"apci3300",
APCI3200_BOARD_VENDOR_ID,
0x3007,
@@ -2525,16 +2525,16 @@ static const boardtype boardtypes[] = {
#endif
};
-#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define n_boardtypes (sizeof(boardtypes)/sizeof(struct addi_board))
struct comedi_driver driver_addi = {
- driver_name:"addi_common",
- module:THIS_MODULE,
- attach:i_ADDI_Attach,
- detach:i_ADDI_Detach,
- num_names:n_boardtypes,
- board_name:&boardtypes[0].pc_DriverName,
- offset:sizeof(boardtype),
+ .driver_name = "addi_common",
+ .module = THIS_MODULE,
+ .attach = i_ADDI_Attach,
+ .detach = i_ADDI_Detach,
+ .num_names = n_boardtypes,
+ .board_name = &boardtypes[0].pc_DriverName,
+ .offset = sizeof(struct addi_board),
};
COMEDI_PCI_INITCLEANUP(driver_addi, addi_apci_tbl);
@@ -2559,11 +2559,11 @@ COMEDI_PCI_INITCLEANUP(driver_addi, addi_apci_tbl);
+----------------------------------------------------------------------------+
*/
-static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret, pages, i, n_subdevices;
- DWORD dw_Dummy;
+ unsigned int dw_Dummy;
resource_size_t io_addr[5];
unsigned int irq;
resource_size_t iobase_a, iobase_main, iobase_addon, iobase_reserved;
@@ -2575,26 +2575,28 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
sprintf(c_Identifier, "Addi-Data GmbH Comedi %s",
this_board->pc_DriverName);
- if ((ret = alloc_private(dev, sizeof(addi_private))) < 0) {
- return -ENOMEM;
- }
+ ret = alloc_private(dev, sizeof(struct addi_private));
+ if (ret < 0)
+ return -ENOMEM;
if (!pci_list_builded) {
- v_pci_card_list_init(this_board->i_VendorId, 1); //1 for displaying the list..
+ v_pci_card_list_init(this_board->i_VendorId, 1); /* 1 for displaying the list.. */
pci_list_builded = 1;
}
- //rt_printk("comedi%d: addi_common: board=%s",dev->minor,this_board->pc_DriverName);
+ /* printk("comedi%d: addi_common: board=%s",dev->minor,this_board->pc_DriverName); */
if ((this_board->i_Dma) && (it->options[2] == 0)) {
i_Dma = 1;
}
- if ((card = ptr_select_and_alloc_pci_card(this_board->i_VendorId,
- this_board->i_DeviceId,
- it->options[0],
- it->options[1], i_Dma)) == NULL) {
+ card = ptr_select_and_alloc_pci_card(this_board->i_VendorId,
+ this_board->i_DeviceId,
+ it->options[0],
+ it->options[1], i_Dma);
+
+ if (card == NULL)
return -EIO;
- }
+
devpriv->allocated = 1;
if ((i_pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0],
@@ -2617,63 +2619,63 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
/************************************/
if (this_board->i_IorangeBase1 != 0) {
- dev->iobase = (unsigned long)iobase_main; // DAQ base address...
+ dev->iobase = (unsigned long)iobase_main; /* DAQ base address... */
} else {
- dev->iobase = (unsigned long)iobase_a; // DAQ base address...
+ dev->iobase = (unsigned long)iobase_a; /* DAQ base address... */
}
dev->board_name = this_board->pc_DriverName;
devpriv->amcc = card;
- devpriv->iobase = (INT) dev->iobase;
- devpriv->i_IobaseAmcc = (INT) iobase_a; //AMCC base address...
- devpriv->i_IobaseAddon = (INT) iobase_addon; //ADD ON base address....
- devpriv->i_IobaseReserved = (INT) iobase_reserved;
+ devpriv->iobase = (int) dev->iobase;
+ devpriv->i_IobaseAmcc = (int) iobase_a; /* AMCC base address... */
+ devpriv->i_IobaseAddon = (int) iobase_addon; /* ADD ON base address.... */
+ devpriv->i_IobaseReserved = (int) iobase_reserved;
devpriv->ps_BoardInfo = this_board;
} else {
dev->board_name = this_board->pc_DriverName;
dev->iobase = (unsigned long)io_addr[2];
devpriv->amcc = card;
- devpriv->iobase = (INT) io_addr[2];
+ devpriv->iobase = (int) io_addr[2];
devpriv->ps_BoardInfo = this_board;
- devpriv->i_IobaseReserved = (INT) io_addr[3];
+ devpriv->i_IobaseReserved = (int) io_addr[3];
printk("\nioremap begin");
devpriv->dw_AiBase =
- (ULONG_PTR) ioremap(io_addr[3],
+ (unsigned long) ioremap(io_addr[3],
this_board->i_IorangeBase3);
printk("\nioremap end");
}
- //##
+ /* ## */
if (irq > 0) {
- if (comedi_request_irq(irq, v_ADDI_Interrupt, IRQF_SHARED,
+ if (request_irq(irq, v_ADDI_Interrupt, IRQF_SHARED,
c_Identifier, dev) < 0) {
printk(", unable to allocate IRQ %u, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk("\nirq=%u", irq);
+ printk("\nirq=%u", irq);
}
} else {
- rt_printk(", IRQ disabled");
+ printk(", IRQ disabled");
}
printk("\nOption %d %d %d\n", it->options[0], it->options[1],
it->options[2]);
dev->irq = irq;
- // Read eepeom and fill boardtype Structure
+ /* Read eepeom and fill addi_board Structure */
if (this_board->i_PCIEeprom) {
printk("\nPCI Eeprom used");
if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
- // Set 3 wait stait
+ /* Set 3 wait stait */
if (!(strcmp(this_board->pc_DriverName, "apci035"))) {
outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
} else {
outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
}
- // Enable the interrupt for the controler
+ /* Enable the interrupt for the controler */
dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
printk("\nEnable the interrupt for the controler");
@@ -2694,16 +2696,15 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
if (this_board->i_Dma) {
printk("\nDMA used");
if (devpriv->us_UseDma == ADDI_ENABLE) {
- // alloc DMA buffers
+ /* alloc DMA buffers */
devpriv->b_DmaDoubleBuffer = 0;
for (i = 0; i < 2; i++) {
for (pages = 4; pages >= 0; pages--) {
- if ((devpriv->ul_DmaBufferVirtual[i] =
- (void *)
- __get_free_pages
- (GFP_KERNEL, pages))) {
+ devpriv->ul_DmaBufferVirtual[i] =
+ (void *) __get_free_pages(GFP_KERNEL, pages);
+
+ if (devpriv->ul_DmaBufferVirtual[i])
break;
- }
}
if (devpriv->ul_DmaBufferVirtual[i]) {
devpriv->ui_DmaBufferPages[i] = pages;
@@ -2718,7 +2719,7 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
}
}
if (!devpriv->ul_DmaBufferVirtual[0]) {
- rt_printk
+ printk
(", Can't allocate DMA buffer, DMA disabled!");
devpriv->us_UseDma = ADDI_DISABLE;
}
@@ -2729,7 +2730,7 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
}
if ((devpriv->us_UseDma == ADDI_ENABLE)) {
- rt_printk("\nDMA ENABLED\n");
+ printk("\nDMA ENABLED\n");
} else {
printk("\nDMA DISABLED\n");
}
@@ -2739,23 +2740,24 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
#ifdef CONFIG_APCI_1710
i_ADDI_AttachPCI1710(dev);
- // save base address
+ /* save base address */
devpriv->s_BoardInfos.ui_Address = io_addr[2];
#endif
} else {
- //Update-0.7.57->0.7.68dev->n_subdevices = 7;
+ /* Update-0.7.57->0.7.68dev->n_subdevices = 7; */
n_subdevices = 7;
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0)
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0)
return ret;
- // Allocate and Initialise AI Subdevice Structures
+ /* Allocate and Initialise AI Subdevice Structures */
s = dev->subdevices + 0;
if ((this_board->i_NbrAiChannel)
|| (this_board->i_NbrAiChannelDiff)) {
dev->read_subdev = s;
s->type = COMEDI_SUBD_AI;
s->subdev_flags =
- SDF_READABLE | SDF_RT | SDF_COMMON | SDF_GROUND
+ SDF_READABLE | SDF_COMMON | SDF_GROUND
| SDF_DIFF;
if (this_board->i_NbrAiChannel) {
s->n_chan = this_board->i_NbrAiChannel;
@@ -2786,13 +2788,11 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
s->type = COMEDI_SUBD_UNUSED;
}
- // Allocate and Initialise AO Subdevice Structures
+ /* Allocate and Initialise AO Subdevice Structures */
s = dev->subdevices + 1;
if (this_board->i_NbrAoChannel) {
s->type = COMEDI_SUBD_AO;
- s->subdev_flags =
- SDF_WRITEABLE | SDF_GROUND | SDF_COMMON |
- SDF_RT;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->i_NbrAoChannel;
s->maxdata = this_board->i_AoMaxdata;
s->len_chanlist = this_board->i_NbrAoChannel;
@@ -2804,12 +2804,11 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
} else {
s->type = COMEDI_SUBD_UNUSED;
}
- // Allocate and Initialise DI Subdevice Structures
+ /* Allocate and Initialise DI Subdevice Structures */
s = dev->subdevices + 2;
if (this_board->i_NbrDiChannel) {
s->type = COMEDI_SUBD_DI;
- s->subdev_flags =
- SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->i_NbrDiChannel;
s->maxdata = 1;
s->len_chanlist = this_board->i_NbrDiChannel;
@@ -2824,20 +2823,19 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
} else {
s->type = COMEDI_SUBD_UNUSED;
}
- // Allocate and Initialise DO Subdevice Structures
+ /* Allocate and Initialise DO Subdevice Structures */
s = dev->subdevices + 3;
if (this_board->i_NbrDoChannel) {
s->type = COMEDI_SUBD_DO;
s->subdev_flags =
- SDF_READABLE | SDF_WRITEABLE | SDF_RT |
- SDF_GROUND | SDF_COMMON;
+ SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->i_NbrDoChannel;
s->maxdata = this_board->i_DoMaxdata;
s->len_chanlist = this_board->i_NbrDoChannel;
s->range_table = &range_digital;
s->io_bits = 0xf; /* all bits output */
- s->insn_config = this_board->i_hwdrv_InsnConfigDigitalOutput; //for digital output memory..
+ s->insn_config = this_board->i_hwdrv_InsnConfigDigitalOutput; /* for digital output memory.. */
s->insn_write =
this_board->i_hwdrv_InsnWriteDigitalOutput;
s->insn_bits =
@@ -2848,13 +2846,11 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
s->type = COMEDI_SUBD_UNUSED;
}
- // Allocate and Initialise Timer Subdevice Structures
+ /* Allocate and Initialise Timer Subdevice Structures */
s = dev->subdevices + 4;
if (this_board->i_Timer) {
s->type = COMEDI_SUBD_TIMER;
- s->subdev_flags =
- SDF_WRITEABLE | SDF_RT | SDF_GROUND |
- SDF_COMMON;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 1;
s->maxdata = 0;
s->len_chanlist = 1;
@@ -2868,13 +2864,12 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
s->type = COMEDI_SUBD_UNUSED;
}
- // Allocate and Initialise TTL
+ /* Allocate and Initialise TTL */
s = dev->subdevices + 5;
if (this_board->i_NbrTTLChannel) {
s->type = COMEDI_SUBD_TTLIO;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT |
- SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->i_NbrTTLChannel;
s->maxdata = 1;
s->io_bits = 0; /* all bits input */
@@ -2926,7 +2921,7 @@ static int i_ADDI_Attach(struct comedi_device * dev, struct comedi_devconfig * i
+----------------------------------------------------------------------------+
*/
-static int i_ADDI_Detach(struct comedi_device * dev)
+static int i_ADDI_Detach(struct comedi_device *dev)
{
if (dev->private) {
@@ -2935,7 +2930,7 @@ static int i_ADDI_Detach(struct comedi_device * dev)
}
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if ((devpriv->ps_BoardInfo->pc_EepromChip == NULL)
@@ -2965,7 +2960,7 @@ static int i_ADDI_Detach(struct comedi_device * dev)
}
if (pci_list_builded) {
- //v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC);
+ /* v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC); */
v_pci_card_list_cleanup(this_board->i_VendorId);
pci_list_builded = 0;
}
@@ -2992,18 +2987,18 @@ static int i_ADDI_Detach(struct comedi_device * dev)
+----------------------------------------------------------------------------+
*/
-static int i_ADDI_Reset(struct comedi_device * dev)
+static int i_ADDI_Reset(struct comedi_device *dev)
{
this_board->i_hwdrv_Reset(dev);
return 0;
}
-// Interrupt function
+/* Interrupt function */
/*
+----------------------------------------------------------------------------+
| Function name : |
-|static void v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG) |
+|static void v_ADDI_Interrupt(int irq, void *d) |
| |
+----------------------------------------------------------------------------+
| Task : Registerd interrupt routine |
@@ -3018,14 +3013,14 @@ static int i_ADDI_Reset(struct comedi_device * dev)
+----------------------------------------------------------------------------+
*/
-static irqreturn_t v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
this_board->v_hwdrv_Interrupt(irq, d);
return IRQ_RETVAL(1);
}
-// EEPROM Read Function
+/* EEPROM Read Function */
/*
+----------------------------------------------------------------------------+
| Function name : |
@@ -3046,17 +3041,17 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG)
+----------------------------------------------------------------------------+
*/
-static int i_ADDIDATA_InsnReadEeprom(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- WORD w_Data;
- WORD w_Address;
- w_Address = CR_CHAN(insn->chanspec); // address to be read as 0,1,2,3...255
+ unsigned short w_Data;
+ unsigned short w_Address;
+ w_Address = CR_CHAN(insn->chanspec); /* address to be read as 0,1,2,3...255 */
w_Data = w_EepromReadWord(devpriv->i_IobaseAmcc,
this_board->pc_EepromChip, 0x100 + (2 * w_Address));
data[0] = w_Data;
- //multiplied by 2 bcozinput will be like 0,1,2...255
+ /* multiplied by 2 bcozinput will be like 0,1,2...255 */
return insn->n;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h
index 19df5c1444a4..edd657b902aa 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_common.h
+++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h
@@ -36,26 +36,12 @@
#define ERROR -1
#define SUCCESS 1
-/* variable type definition */
-typedef unsigned char BYTE, *PBYTE;
-typedef short SHORT, *PSHORT;
-typedef unsigned short USHORT, *PUSHORT;
-typedef unsigned short WORD, *PWORD;
-typedef int INT, *PINT;;
-typedef unsigned int UINT, *PUINT;
-typedef int LONG, *PLONG; /* 32-bit */
-typedef unsigned int ULONG, *PULONG; /* 32-bit */
-typedef unsigned int DWORD, *PDWORD; /* 32-bit */
-typedef unsigned long ULONG_PTR;
-
-typedef const struct comedi_lrange *PCRANGE;
-
-#define LOBYTE(W) (BYTE)((W) & 0xFF)
-#define HIBYTE(W) (BYTE)(((W) >> 8) & 0xFF)
-#define MAKEWORD(H, L) (USHORT)((L) | ((H) << 8))
-#define LOWORD(W) (USHORT)((W) & 0xFFFF)
-#define HIWORD(W) (USHORT)(((W) >> 16) & 0xFFFF)
-#define MAKEDWORD(H, L) (UINT)((L) | ((H) << 16))
+#define LOBYTE(W) (unsigned char)((W) & 0xFF)
+#define HIBYTE(W) (unsigned char)(((W) >> 8) & 0xFF)
+#define MAKEWORD(H, L) (unsigned short)((L) | ((H) << 8))
+#define LOWORD(W) (unsigned short)((W) & 0xFFFF)
+#define HIWORD(W) (unsigned short)(((W) >> 16) & 0xFFFF)
+#define MAKEDWORD(H, L) (unsigned int)((L) | ((H) << 16))
#define ADDI_ENABLE 1
#define ADDI_DISABLE 0
@@ -75,37 +61,37 @@ typedef const struct comedi_lrange *PCRANGE;
/* Structures */
/* structure for the boardtype */
-typedef struct {
- const char *pc_DriverName; // driver name
- INT i_VendorId; //PCI vendor a device ID of card
- INT i_DeviceId;
- INT i_IorangeBase0;
- INT i_IorangeBase1;
- INT i_IorangeBase2; // base 2 range
- INT i_IorangeBase3; // base 3 range
- INT i_PCIEeprom; // eeprom present or not
- char *pc_EepromChip; // type of chip
- INT i_NbrAiChannel; // num of A/D chans
- INT i_NbrAiChannelDiff; // num of A/D chans in diff mode
- INT i_AiChannelList; // len of chanlist
- INT i_NbrAoChannel; // num of D/A chans
- INT i_AiMaxdata; // resolution of A/D
- INT i_AoMaxdata; // resolution of D/A
- PCRANGE pr_AiRangelist; // rangelist for A/D
- PCRANGE pr_AoRangelist; // rangelist for D/A
-
- INT i_NbrDiChannel; // Number of DI channels
- INT i_NbrDoChannel; // Number of DO channels
- INT i_DoMaxdata; // data to set all chanels high
-
- INT i_NbrTTLChannel; // Number of TTL channels
- PCRANGE pr_TTLRangelist; // rangelist for TTL
-
- INT i_Dma; // dma present or not
- INT i_Timer; // timer subdevice present or not
- BYTE b_AvailableConvertUnit;
- UINT ui_MinAcquisitiontimeNs; // Minimum Acquisition in Nano secs
- UINT ui_MinDelaytimeNs; // Minimum Delay in Nano secs
+struct addi_board {
+ const char *pc_DriverName; /* driver name */
+ int i_VendorId; /* PCI vendor a device ID of card */
+ int i_DeviceId;
+ int i_IorangeBase0;
+ int i_IorangeBase1;
+ int i_IorangeBase2; /* base 2 range */
+ int i_IorangeBase3; /* base 3 range */
+ int i_PCIEeprom; /* eeprom present or not */
+ char *pc_EepromChip; /* type of chip */
+ int i_NbrAiChannel; /* num of A/D chans */
+ int i_NbrAiChannelDiff; /* num of A/D chans in diff mode */
+ int i_AiChannelList; /* len of chanlist */
+ int i_NbrAoChannel; /* num of D/A chans */
+ int i_AiMaxdata; /* resolution of A/D */
+ int i_AoMaxdata; /* resolution of D/A */
+ const struct comedi_lrange *pr_AiRangelist; /* rangelist for A/D */
+ const struct comedi_lrange *pr_AoRangelist; /* rangelist for D/A */
+
+ int i_NbrDiChannel; /* Number of DI channels */
+ int i_NbrDoChannel; /* Number of DO channels */
+ int i_DoMaxdata; /* data to set all chanels high */
+
+ int i_NbrTTLChannel; /* Number of TTL channels */
+ const struct comedi_lrange *pr_TTLRangelist; /* rangelist for TTL */
+
+ int i_Dma; /* dma present or not */
+ int i_Timer; /* timer subdevice present or not */
+ unsigned char b_AvailableConvertUnit;
+ unsigned int ui_MinAcquisitiontimeNs; /* Minimum Acquisition in Nano secs */
+ unsigned int ui_MinDelaytimeNs; /* Minimum Delay in Nano secs */
/* interrupt and reset */
void (*v_hwdrv_Interrupt)(int irq, void *d);
@@ -213,21 +199,21 @@ typedef struct {
int (*i_hwdr_WriteTTLIOChlOnOff)(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-} boardtype;
+};
-//MODULE INFO STRUCTURE
+/* MODULE INFO STRUCTURE */
-typedef union {
+union str_ModuleInfo {
/* Incremental counter infos */
struct {
union {
struct {
- BYTE b_ModeRegister1;
- BYTE b_ModeRegister2;
- BYTE b_ModeRegister3;
- BYTE b_ModeRegister4;
+ unsigned char b_ModeRegister1;
+ unsigned char b_ModeRegister2;
+ unsigned char b_ModeRegister3;
+ unsigned char b_ModeRegister4;
} s_ByteModeRegister;
- DWORD dw_ModeRegister1_2_3_4;
+ unsigned int dw_ModeRegister1_2_3_4;
} s_ModeRegister;
struct {
@@ -244,25 +230,25 @@ typedef union {
/* SSI infos */
struct {
- BYTE b_SSIProfile;
- BYTE b_PositionTurnLength;
- BYTE b_TurnCptLength;
- BYTE b_SSIInit;
+ unsigned char b_SSIProfile;
+ unsigned char b_PositionTurnLength;
+ unsigned char b_TurnCptLength;
+ unsigned char b_SSIInit;
} s_SSICounterInfo;
/* TTL I/O infos */
struct {
- BYTE b_TTLInit;
- BYTE b_PortConfiguration[4];
+ unsigned char b_TTLInit;
+ unsigned char b_PortConfiguration[4];
} s_TTLIOInfo;
/* Digital I/O infos */
struct {
- BYTE b_DigitalInit;
- BYTE b_ChannelAMode;
- BYTE b_ChannelBMode;
- BYTE b_OutputMemoryEnabled;
- DWORD dw_OutputMemory;
+ unsigned char b_DigitalInit;
+ unsigned char b_ChannelAMode;
+ unsigned char b_ChannelBMode;
+ unsigned char b_OutputMemoryEnabled;
+ unsigned int dw_OutputMemory;
} s_DigitalIOInfo;
/*********************/
@@ -271,14 +257,14 @@ typedef union {
struct {
struct {
- BYTE b_82X54Init;
- BYTE b_InputClockSelection;
- BYTE b_InputClockLevel;
- BYTE b_OutputLevel;
- BYTE b_HardwareGateLevel;
- DWORD dw_ConfigurationWord;
+ unsigned char b_82X54Init;
+ unsigned char b_InputClockSelection;
+ unsigned char b_InputClockLevel;
+ unsigned char b_OutputLevel;
+ unsigned char b_HardwareGateLevel;
+ unsigned int dw_ConfigurationWord;
} s_82X54TimerInfo[3];
- BYTE b_InterruptMask;
+ unsigned char b_InterruptMask;
} s_82X54ModuleInfo;
/*********************/
@@ -286,13 +272,13 @@ typedef union {
/*********************/
struct {
- BYTE b_ChronoInit;
- BYTE b_InterruptMask;
- BYTE b_PCIInputClock;
- BYTE b_TimingUnit;
- BYTE b_CycleMode;
+ unsigned char b_ChronoInit;
+ unsigned char b_InterruptMask;
+ unsigned char b_PCIInputClock;
+ unsigned char b_TimingUnit;
+ unsigned char b_CycleMode;
double d_TimingInterval;
- DWORD dw_ConfigReg;
+ unsigned int dw_ConfigReg;
} s_ChronoModuleInfo;
/***********************/
@@ -301,154 +287,154 @@ typedef union {
struct {
struct {
- BYTE b_PulseEncoderInit;
+ unsigned char b_PulseEncoderInit;
} s_PulseEncoderInfo[4];
- DWORD dw_SetRegister;
- DWORD dw_ControlRegister;
- DWORD dw_StatusRegister;
+ unsigned int dw_SetRegister;
+ unsigned int dw_ControlRegister;
+ unsigned int dw_StatusRegister;
} s_PulseEncoderModuleInfo;
/* Tor conter infos */
struct {
struct {
- BYTE b_TorCounterInit;
- BYTE b_TimingUnit;
- BYTE b_InterruptEnable;
+ unsigned char b_TorCounterInit;
+ unsigned char b_TimingUnit;
+ unsigned char b_InterruptEnable;
double d_TimingInterval;
- ULONG ul_RealTimingInterval;
+ unsigned int ul_RealTimingInterval;
} s_TorCounterInfo[2];
- BYTE b_PCIInputClock;
+ unsigned char b_PCIInputClock;
} s_TorCounterModuleInfo;
/* PWM infos */
struct {
struct {
- BYTE b_PWMInit;
- BYTE b_TimingUnit;
- BYTE b_InterruptEnable;
+ unsigned char b_PWMInit;
+ unsigned char b_TimingUnit;
+ unsigned char b_InterruptEnable;
double d_LowTiming;
double d_HighTiming;
- ULONG ul_RealLowTiming;
- ULONG ul_RealHighTiming;
+ unsigned int ul_RealLowTiming;
+ unsigned int ul_RealHighTiming;
} s_PWMInfo[2];
- BYTE b_ClockSelection;
+ unsigned char b_ClockSelection;
} s_PWMModuleInfo;
/* ETM infos */
struct {
struct {
- BYTE b_ETMEnable;
- BYTE b_ETMInterrupt;
+ unsigned char b_ETMEnable;
+ unsigned char b_ETMInterrupt;
} s_ETMInfo[2];
- BYTE b_ETMInit;
- BYTE b_TimingUnit;
- BYTE b_ClockSelection;
+ unsigned char b_ETMInit;
+ unsigned char b_TimingUnit;
+ unsigned char b_ClockSelection;
double d_TimingInterval;
- ULONG ul_Timing;
+ unsigned int ul_Timing;
} s_ETMModuleInfo;
/* CDA infos */
struct {
- BYTE b_CDAEnable;
- BYTE b_CDAInterrupt;
- BYTE b_CDAInit;
- BYTE b_FctSelection;
- BYTE b_CDAReadFIFOOverflow;
+ unsigned char b_CDAEnable;
+ unsigned char b_CDAInterrupt;
+ unsigned char b_CDAInit;
+ unsigned char b_FctSelection;
+ unsigned char b_CDAReadFIFOOverflow;
} s_CDAModuleInfo;
-} str_ModuleInfo;
+};
/* Private structure for the addi_apci3120 driver */
-typedef struct {
-
- INT iobase;
- INT i_IobaseAmcc; // base+size for AMCC chip
- INT i_IobaseAddon; //addon base address
- INT i_IobaseReserved;
- ULONG_PTR dw_AiBase;
- struct pcilst_struct *amcc; // ptr too AMCC data
- BYTE allocated; // we have blocked card
- BYTE b_ValidDriver; // driver is ok
- BYTE b_AiContinuous; // we do unlimited AI
- BYTE b_AiInitialisation;
- UINT ui_AiActualScan; //how many scans we finished
- UINT ui_AiBufferPtr; // data buffer ptr in samples
- UINT ui_AiNbrofChannels; // how many channels is measured
- UINT ui_AiScanLength; // Length of actual scanlist
- UINT ui_AiActualScanPosition; // position in actual scan
- PUINT pui_AiChannelList; // actual chanlist
- UINT ui_AiChannelList[32]; // actual chanlist
- BYTE b_AiChannelConfiguration[32]; // actual chanlist
- UINT ui_AiReadData[32];
- DWORD dw_AiInitialised;
- UINT ui_AiTimer0; //Timer Constant for Timer0
- UINT ui_AiTimer1; //Timer constant for Timer1
- UINT ui_AiFlags;
- UINT ui_AiDataLength;
- short *AiData; // Pointer to sample data
- UINT ui_AiNbrofScans; // number of scans to do
- USHORT us_UseDma; // To use Dma or not
- BYTE b_DmaDoubleBuffer; // we can use double buffering
- UINT ui_DmaActualBuffer; // which buffer is used now
- //*UPDATE-0.7.57->0.7.68
- //ULONG ul_DmaBufferVirtual[2];// pointers to begin of DMA buffer
- short *ul_DmaBufferVirtual[2]; // pointers to begin of DMA buffer
- ULONG ul_DmaBufferHw[2]; // hw address of DMA buff
- UINT ui_DmaBufferSize[2]; // size of dma buffer in bytes
- UINT ui_DmaBufferUsesize[2]; // which size we may now used for transfer
- UINT ui_DmaBufferSamples[2]; // size in samples
- UINT ui_DmaBufferPages[2]; // number of pages in buffer
- BYTE b_DigitalOutputRegister; // Digital Output Register
- BYTE b_OutputMemoryStatus;
- BYTE b_AnalogInputChannelNbr; // Analog input channel Nbr
- BYTE b_AnalogOutputChannelNbr; // Analog input Output Nbr
- BYTE b_TimerSelectMode; // Contain data written at iobase + 0C
- BYTE b_ModeSelectRegister; // Contain data written at iobase + 0E
- USHORT us_OutputRegister; // Contain data written at iobase + 0
- BYTE b_InterruptState;
- BYTE b_TimerInit; // Specify if InitTimerWatchdog was load
- BYTE b_TimerStarted; // Specify if timer 2 is running or not
- BYTE b_Timer2Mode; // Specify the timer 2 mode
- BYTE b_Timer2Interrupt; //Timer2 interrupt enable or disable
- BYTE b_AiCyclicAcquisition; // indicate cyclic acquisition
- BYTE b_InterruptMode; // eoc eos or dma
- BYTE b_EocEosInterrupt; // Enable disable eoc eos interrupt
- UINT ui_EocEosConversionTime;
- BYTE b_EocEosConversionTimeBase;
- BYTE b_SingelDiff;
- BYTE b_ExttrigEnable; /* To enable or disable external trigger */
+struct addi_private {
+
+ int iobase;
+ int i_IobaseAmcc; /* base+size for AMCC chip */
+ int i_IobaseAddon; /* addon base address */
+ int i_IobaseReserved;
+ unsigned long dw_AiBase;
+ struct pcilst_struct *amcc; /* ptr too AMCC data */
+ unsigned char allocated; /* we have blocked card */
+ unsigned char b_ValidDriver; /* driver is ok */
+ unsigned char b_AiContinuous; /* we do unlimited AI */
+ unsigned char b_AiInitialisation;
+ unsigned int ui_AiActualScan; /* how many scans we finished */
+ unsigned int ui_AiBufferPtr; /* data buffer ptr in samples */
+ unsigned int ui_AiNbrofChannels; /* how many channels is measured */
+ unsigned int ui_AiScanLength; /* Length of actual scanlist */
+ unsigned int ui_AiActualScanPosition; /* position in actual scan */
+ unsigned int *pui_AiChannelList; /* actual chanlist */
+ unsigned int ui_AiChannelList[32]; /* actual chanlist */
+ unsigned char b_AiChannelConfiguration[32]; /* actual chanlist */
+ unsigned int ui_AiReadData[32];
+ unsigned int dw_AiInitialised;
+ unsigned int ui_AiTimer0; /* Timer Constant for Timer0 */
+ unsigned int ui_AiTimer1; /* Timer constant for Timer1 */
+ unsigned int ui_AiFlags;
+ unsigned int ui_AiDataLength;
+ short *AiData; /* Pointer to sample data */
+ unsigned int ui_AiNbrofScans; /* number of scans to do */
+ unsigned short us_UseDma; /* To use Dma or not */
+ unsigned char b_DmaDoubleBuffer; /* we can use double buffering */
+ unsigned int ui_DmaActualBuffer; /* which buffer is used now */
+ /* UPDATE-0.7.57->0.7.68 */
+ /* unsigned int ul_DmaBufferVirtual[2]; pointers to begin of DMA buffer */
+ short *ul_DmaBufferVirtual[2]; /* pointers to begin of DMA buffer */
+ unsigned int ul_DmaBufferHw[2]; /* hw address of DMA buff */
+ unsigned int ui_DmaBufferSize[2]; /* size of dma buffer in bytes */
+ unsigned int ui_DmaBufferUsesize[2]; /* which size we may now used for transfer */
+ unsigned int ui_DmaBufferSamples[2]; /* size in samples */
+ unsigned int ui_DmaBufferPages[2]; /* number of pages in buffer */
+ unsigned char b_DigitalOutputRegister; /* Digital Output Register */
+ unsigned char b_OutputMemoryStatus;
+ unsigned char b_AnalogInputChannelNbr; /* Analog input channel Nbr */
+ unsigned char b_AnalogOutputChannelNbr; /* Analog input Output Nbr */
+ unsigned char b_TimerSelectMode; /* Contain data written at iobase + 0C */
+ unsigned char b_ModeSelectRegister; /* Contain data written at iobase + 0E */
+ unsigned short us_OutputRegister; /* Contain data written at iobase + 0 */
+ unsigned char b_InterruptState;
+ unsigned char b_TimerInit; /* Specify if InitTimerWatchdog was load */
+ unsigned char b_TimerStarted; /* Specify if timer 2 is running or not */
+ unsigned char b_Timer2Mode; /* Specify the timer 2 mode */
+ unsigned char b_Timer2Interrupt; /* Timer2 interrupt enable or disable */
+ unsigned char b_AiCyclicAcquisition; /* indicate cyclic acquisition */
+ unsigned char b_InterruptMode; /* eoc eos or dma */
+ unsigned char b_EocEosInterrupt; /* Enable disable eoc eos interrupt */
+ unsigned int ui_EocEosConversionTime;
+ unsigned char b_EocEosConversionTimeBase;
+ unsigned char b_SingelDiff;
+ unsigned char b_ExttrigEnable; /* To enable or disable external trigger */
/* Pointer to the current process */
struct task_struct *tsk_Current;
- boardtype *ps_BoardInfo;
+ struct addi_board *ps_BoardInfo;
/* Hardware board infos for 1710 */
struct {
- UINT ui_Address; /* Board address */
- UINT ui_FlashAddress;
- BYTE b_InterruptNbr; /* Board interrupt number */
- BYTE b_SlotNumber; /* PCI slot number */
- BYTE b_BoardVersion;
- DWORD dw_MolduleConfiguration[4]; /* Module config */
+ unsigned int ui_Address; /* Board address */
+ unsigned int ui_FlashAddress;
+ unsigned char b_InterruptNbr; /* Board interrupt number */
+ unsigned char b_SlotNumber; /* PCI slot number */
+ unsigned char b_BoardVersion;
+ unsigned int dw_MolduleConfiguration[4]; /* Module config */
} s_BoardInfos;
/* Interrupt infos */
struct {
- ULONG ul_InterruptOccur; /* 0 : No interrupt occur */
+ unsigned int ul_InterruptOccur; /* 0 : No interrupt occur */
/* > 0 : Interrupt occur */
- UINT ui_Read; /* Read FIFO */
- UINT ui_Write; /* Write FIFO */
+ unsigned int ui_Read; /* Read FIFO */
+ unsigned int ui_Write; /* Write FIFO */
struct {
- BYTE b_OldModuleMask;
- ULONG ul_OldInterruptMask; /* Interrupt mask */
- ULONG ul_OldCounterLatchValue; /* Interrupt counter value */
+ unsigned char b_OldModuleMask;
+ unsigned int ul_OldInterruptMask; /* Interrupt mask */
+ unsigned int ul_OldCounterLatchValue; /* Interrupt counter value */
} s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT];
} s_InterruptParameters;
- str_ModuleInfo s_ModuleInfo[4];
- ULONG ul_TTLPortConfiguration[10];
+ union str_ModuleInfo s_ModuleInfo[4];
+ unsigned int ul_TTLPortConfiguration[10];
-} addi_private;
+};
static unsigned short pci_list_builded; /* set to 1 when list of card is known */
@@ -457,6 +443,6 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
static int i_ADDI_Detach(struct comedi_device *dev);
static int i_ADDI_Reset(struct comedi_device *dev);
-static irqreturn_t v_ADDI_Interrupt(int irq, void *d PT_REGS_ARG);
+static irqreturn_t v_ADDI_Interrupt(int irq, void *d);
static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c
index a8a1bb2e8fa5..69b427390e53 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c
+++ b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -45,19 +45,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------+-----------+------------------------------------------------+
*/
-#define NVCMD_BEGIN_READ (0x7 << 5 ) // nvRam begin read command
-#define NVCMD_LOAD_LOW (0x4 << 5 ) // nvRam load low command
-#define NVCMD_LOAD_HIGH (0x5 << 5 ) // nvRam load high command
-#define EE76_CMD_LEN 13 // bits in instructions
-#define EE_READ 0x0180 // 01 1000 0000 read instruction
-
-#define WORD unsigned short
-#define PWORD unsigned short *
-#define PDWORD unsigned int *
-
-#ifndef DWORD
-#define DWORD unsigned int
-#endif
+#define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */
+#define NVCMD_LOAD_LOW (0x4 << 5) /* nvRam load low command */
+#define NVCMD_LOAD_HIGH (0x5 << 5) /* nvRam load high command */
+#define EE76_CMD_LEN 13 /* bits in instructions */
+#define EE_READ 0x0180 /* 01 1000 0000 read instruction */
#define EEPROM_DIGITALINPUT 0
#define EEPROM_DIGITALOUTPUT 1
@@ -68,107 +60,114 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
#define EEPROM_TIMER_WATCHDOG_COUNTER 10
struct str_Functionality {
- BYTE b_Type;
- WORD w_Address;
+ unsigned char b_Type;
+ unsigned short w_Address;
};
-typedef struct {
- WORD w_HeaderSize;
- BYTE b_Nfunctions;
+struct str_MainHeader {
+ unsigned short w_HeaderSize;
+ unsigned char b_Nfunctions;
struct str_Functionality s_Functions[7];
-} str_MainHeader;
+};
-typedef struct {
- WORD w_Nchannel;
- BYTE b_Interruptible;
- WORD w_NinterruptLogic;
-} str_DigitalInputHeader;
+struct str_DigitalInputHeader {
+ unsigned short w_Nchannel;
+ unsigned char b_Interruptible;
+ unsigned short w_NinterruptLogic;
+};
-typedef struct {
- WORD w_Nchannel;
-} str_DigitalOutputHeader;
+struct str_DigitalOutputHeader {
-// used for timer as well as watchdog
+ unsigned short w_Nchannel;
+};
-typedef struct {
- WORD w_HeaderSize;
- BYTE b_Resolution;
- BYTE b_Mode; // in case of Watchdog it is functionality
- WORD w_MinTiming;
- BYTE b_TimeBase;
-} str_TimerDetails;
-typedef struct {
- WORD w_Ntimer;
- str_TimerDetails s_TimerDetails[4]; // supports 4 timers
-} str_TimerMainHeader;
+/* used for timer as well as watchdog */
+
+struct str_TimerDetails {
+
+ unsigned short w_HeaderSize;
+ unsigned char b_Resolution;
+ unsigned char b_Mode; /* in case of Watchdog it is functionality */
+ unsigned short w_MinTiming;
+ unsigned char b_TimeBase;
+};
+
+struct str_TimerMainHeader {
+
+
+ unsigned short w_Ntimer;
+ struct str_TimerDetails s_TimerDetails[4]; /* supports 4 timers */
+};
+
typedef struct {
- WORD w_Nchannel;
- BYTE b_Resolution;
+ unsigned short w_Nchannel;
+ unsigned char b_Resolution;
} str_AnalogOutputHeader;
-typedef struct {
- WORD w_Nchannel;
- WORD w_MinConvertTiming;
- WORD w_MinDelayTiming;
- BYTE b_HasDma;
- BYTE b_Resolution;
-} str_AnalogInputHeader;
+struct str_AnalogInputHeader {
+ unsigned short w_Nchannel;
+ unsigned short w_MinConvertTiming;
+ unsigned short w_MinDelayTiming;
+ unsigned char b_HasDma;
+ unsigned char b_Resolution;
+};
+
/*****************************************/
/* Read Header Functions */
/*****************************************/
-INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
+int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
char *pc_PCIChipInformation, struct comedi_device *dev);
-INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_DigitalInputHeader * s_Header);
+int i_EepromReadDigitalInputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_DigitalInputHeader *s_Header);
-INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_DigitalOutputHeader * s_Header);
+int i_EepromReadDigitalOutputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_DigitalOutputHeader *s_Header);
-INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_TimerMainHeader * s_Header);
+int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_TimerMainHeader *s_Header);
-INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_AnalogOutputHeader * s_Header);
+int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ str_AnalogOutputHeader *s_Header);
-INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_AnalogInputHeader * s_Header);
+int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_AnalogInputHeader *s_Header);
/******************************************/
/* Eeprom Specific Functions */
/******************************************/
-WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
- WORD w_EepromStartAddress);
-void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress);
-void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue);
-void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress);
-void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
- BYTE b_DataLengthInBits);
-void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value);
+unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
+ unsigned short w_EepromStartAddress);
+void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress);
+void v_EepromClock76(unsigned int dw_Address, unsigned int dw_RegisterValue);
+void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress);
+void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromCommand,
+ unsigned char b_DataLengthInBits);
+void v_EepromCs76Read(unsigned int dw_Address, unsigned short w_offset, unsigned short *pw_Value);
/*
+----------------------------------------------------------------------------+
-| Function Name : WORD w_EepromReadWord |
-| (WORD w_PCIBoardEepromAddress, |
+| Function Name : unsigned short w_EepromReadWord |
+| (unsigned short w_PCIBoardEepromAddress, |
| char * pc_PCIChipInformation, |
-| WORD w_EepromStartAddress) |
+| unsigned short w_EepromStartAddress) |
+----------------------------------------------------------------------------+
| Task : Read from eepromn a word |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
-| WORD w_EepromStartAddress : Selected eeprom address |
+| unsigned short w_EepromStartAddress : Selected eeprom address |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -176,23 +175,23 @@ void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value);
+----------------------------------------------------------------------------+
*/
-WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
- WORD w_EepromStartAddress)
+unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
+ unsigned short w_EepromStartAddress)
{
- BYTE b_Counter = 0;
+ unsigned char b_Counter = 0;
- BYTE b_ReadByte = 0;
+ unsigned char b_ReadByte = 0;
- BYTE b_ReadLowByte = 0;
+ unsigned char b_ReadLowByte = 0;
- BYTE b_ReadHighByte = 0;
+ unsigned char b_ReadHighByte = 0;
- BYTE b_SelectedAddressLow = 0;
+ unsigned char b_SelectedAddressLow = 0;
- BYTE b_SelectedAddressHigh = 0;
+ unsigned char b_SelectedAddressHigh = 0;
- WORD w_ReadWord = 0;
+ unsigned short w_ReadWord = 0;
/**************************/
@@ -207,9 +206,9 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
for (b_Counter = 0; b_Counter < 2; b_Counter++)
{
- b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256; //Read the low 8 bit part
+ b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256; /* Read the low 8 bit part */
- b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; //Read the high 8 bit part
+ b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; /* Read the high 8 bit part */
/************************************/
@@ -320,20 +319,20 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
b_ReadLowByte = b_ReadByte;
- } // if(b_Counter==0)
+ } /* if(b_Counter==0) */
else
{
b_ReadHighByte = b_ReadByte;
- } // if(b_Counter==0)
+ } /* if(b_Counter==0) */
- } // for (b_Counter=0; b_Counter<2; b_Counter++)
+ } /* for (b_Counter=0; b_Counter<2; b_Counter++) */
- w_ReadWord = (b_ReadLowByte | (((WORD) b_ReadHighByte) * 256));
+ w_ReadWord = (b_ReadLowByte | (((unsigned short) b_ReadHighByte) * 256));
- } // end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933")))
+ } /* end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933"))) */
if (!strcmp(pc_PCIChipInformation, "93C76"))
{
@@ -349,7 +348,7 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
}
- return (w_ReadWord);
+ return w_ReadWord;
}
@@ -359,7 +358,7 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
| Function Name : void v_EepromWaitBusy |
-| (WORD w_PCIBoardEepromAddress) |
+| (unsigned short w_PCIBoardEepromAddress) |
+----------------------------------------------------------------------------+
@@ -367,7 +366,7 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom base address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom base address |
+----------------------------------------------------------------------------+
@@ -381,10 +380,10 @@ WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
*/
-void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress)
+void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress)
{
- BYTE b_EepromBusy = 0;
+ unsigned char b_EepromBusy = 0;
do
{
@@ -403,17 +402,16 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress)
/* the operator register is AMCC_OP_REG_MCSR+3 */
- /* WORD read EEPROM=0x8000 andAMCC_OP_REG_MCSR+2 */
+ /* unsigned short read EEPROM=0x8000 andAMCC_OP_REG_MCSR+2 */
- /* DWORD read EEPROM=0x80000000 and AMCC_OP_REG_MCSR */
+ /* unsigned int read EEPROM=0x80000000 and AMCC_OP_REG_MCSR */
/************************************************************************/
b_EepromBusy = inb(w_PCIBoardEepromAddress + 0x3F);
b_EepromBusy = b_EepromBusy & 0x80;
- }
- while (b_EepromBusy == 0x80);
+ } while (b_EepromBusy == 0x80);
}
@@ -421,9 +419,9 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress)
+---------------------------------------------------------------------------------+
-| Function Name : void v_EepromClock76(DWORD dw_Address, |
+| Function Name : void v_EepromClock76(unsigned int dw_Address, |
-| DWORD dw_RegisterValue) |
+| unsigned int dw_RegisterValue) |
+---------------------------------------------------------------------------------+
@@ -431,9 +429,9 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress)
+---------------------------------------------------------------------------------+
-| Input Parameters : DWORD dw_Address : PCI eeprom base address |
+| Input Parameters : unsigned int dw_Address : PCI eeprom base address |
-| DWORD dw_RegisterValue : PCI eeprom register value to write.|
+| unsigned int dw_RegisterValue : PCI eeprom register value to write.|
+---------------------------------------------------------------------------------+
@@ -447,7 +445,7 @@ void v_EepromWaitBusy(WORD w_PCIBoardEepromAddress)
*/
-void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue)
+void v_EepromClock76(unsigned int dw_Address, unsigned int dw_RegisterValue)
{
/************************/
@@ -488,11 +486,11 @@ void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue)
+---------------------------------------------------------------------------------+
-| Function Name : void v_EepromSendCommand76(DWORD dw_Address, |
+| Function Name : void v_EepromSendCommand76(unsigned int dw_Address, |
-| DWORD dw_EepromCommand, |
+| unsigned int dw_EepromCommand, |
-| BYTE b_DataLengthInBits) |
+| unsigned char b_DataLengthInBits) |
+---------------------------------------------------------------------------------+
@@ -500,11 +498,11 @@ void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue)
+---------------------------------------------------------------------------------+
-| Input Parameters : DWORD dw_Address : PCI eeprom base address |
+| Input Parameters : unsigned int dw_Address : PCI eeprom base address |
-| DWORD dw_EepromCommand : PCI eeprom command to write. |
+| unsigned int dw_EepromCommand : PCI eeprom command to write. |
-| BYTE b_DataLengthInBits : PCI eeprom command data length. |
+| unsigned char b_DataLengthInBits : PCI eeprom command data length. |
+---------------------------------------------------------------------------------+
@@ -518,13 +516,13 @@ void v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue)
*/
-void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
- BYTE b_DataLengthInBits)
+void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromCommand,
+ unsigned char b_DataLengthInBits)
{
char c_BitPos = 0;
- DWORD dw_RegisterValue = 0;
+ unsigned int dw_RegisterValue = 0;
/*****************************/
@@ -623,11 +621,11 @@ void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
+---------------------------------------------------------------------------------+
-| Function Name : void v_EepromCs76Read(DWORD dw_Address, |
+| Function Name : void v_EepromCs76Read(unsigned int dw_Address, |
-| WORD w_offset, |
+| unsigned short w_offset, |
-| PWORD pw_Value) |
+| unsigned short * pw_Value) |
+---------------------------------------------------------------------------------+
@@ -635,11 +633,11 @@ void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
+---------------------------------------------------------------------------------+
-| Input Parameters : DWORD dw_Address : PCI eeprom base address |
+| Input Parameters : unsigned int dw_Address : PCI eeprom base address |
-| WORD w_offset : Offset of the adress to read |
+| unsigned short w_offset : Offset of the adress to read |
-| PWORD pw_Value : PCI eeprom 16 bit read value. |
+| unsigned short * pw_Value : PCI eeprom 16 bit read value. |
+---------------------------------------------------------------------------------+
@@ -653,14 +651,14 @@ void v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
*/
-void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value)
+void v_EepromCs76Read(unsigned int dw_Address, unsigned short w_offset, unsigned short *pw_Value)
{
char c_BitPos = 0;
- DWORD dw_RegisterValue = 0;
+ unsigned int dw_RegisterValue = 0;
- DWORD dw_RegisterValueRead = 0;
+ unsigned int dw_RegisterValueRead = 0;
/*************************************************/
@@ -786,12 +784,12 @@ void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value)
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, |
+| Function Name : int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, |
| char * pc_PCIChipInformation,struct comedi_device *dev) |
+----------------------------------------------------------------------------+
| Task : Read from eeprom Main Header |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
@@ -804,43 +802,43 @@ void v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value)
+----------------------------------------------------------------------------+
*/
-INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
+int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
char *pc_PCIChipInformation, struct comedi_device *dev)
{
- WORD w_Temp, i, w_Count = 0;
- UINT ui_Temp;
- str_MainHeader s_MainHeader;
- str_DigitalInputHeader s_DigitalInputHeader;
- str_DigitalOutputHeader s_DigitalOutputHeader;
- //str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader;
+ unsigned short w_Temp, i, w_Count = 0;
+ unsigned int ui_Temp;
+ struct str_MainHeader s_MainHeader;
+ struct str_DigitalInputHeader s_DigitalInputHeader;
+ struct str_DigitalOutputHeader s_DigitalOutputHeader;
+ /* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */
str_AnalogOutputHeader s_AnalogOutputHeader;
- str_AnalogInputHeader s_AnalogInputHeader;
+ struct str_AnalogInputHeader s_AnalogInputHeader;
- // Read size
+ /* Read size */
s_MainHeader.w_HeaderSize =
w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
0x100 + 8);
- // Read nbr of functionality
+ /* Read nbr of functionality */
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + 10);
- s_MainHeader.b_Nfunctions = (BYTE) w_Temp & 0x00FF;
+ s_MainHeader.b_Nfunctions = (unsigned char) w_Temp & 0x00FF;
- // Read functionality details
+ /* Read functionality details */
for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
- // Read Type
+ /* Read Type */
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + 12 + w_Count);
- s_MainHeader.s_Functions[i].b_Type = (BYTE) w_Temp & 0x3F;
+ s_MainHeader.s_Functions[i].b_Type = (unsigned char) w_Temp & 0x3F;
w_Count = w_Count + 2;
- //Read Address
+ /* Read Address */
s_MainHeader.s_Functions[i].w_Address =
w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + 12 + w_Count);
w_Count = w_Count + 2;
}
- // Display main header info
+ /* Display main header info */
for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
switch (s_MainHeader.s_Functions[i].b_Type) {
@@ -878,10 +876,10 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
s_AnalogInputHeader.w_Nchannel;
this_board->i_Dma = s_AnalogInputHeader.b_HasDma;
this_board->ui_MinAcquisitiontimeNs =
- (UINT) s_AnalogInputHeader.w_MinConvertTiming *
+ (unsigned int) s_AnalogInputHeader.w_MinConvertTiming *
1000;
this_board->ui_MinDelaytimeNs =
- (UINT) s_AnalogInputHeader.w_MinDelayTiming *
+ (unsigned int) s_AnalogInputHeader.w_MinDelayTiming *
1000;
ui_Temp = 0xffff;
this_board->i_AiMaxdata =
@@ -903,15 +901,15 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
break;
case EEPROM_TIMER:
- this_board->i_Timer = 1; //Timer subdevice present
+ this_board->i_Timer = 1; /* Timer subdevice present */
break;
case EEPROM_WATCHDOG:
- this_board->i_Timer = 1; //Timer subdevice present
+ this_board->i_Timer = 1; /* Timer subdevice present */
break;
case EEPROM_TIMER_WATCHDOG_COUNTER:
- this_board->i_Timer = 1; //Timer subdevice present
+ this_board->i_Timer = 1; /* Timer subdevice present */
}
}
@@ -920,18 +918,18 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_EepromReadDigitalInputHeader(WORD |
+| Function Name : int i_EepromReadDigitalInputHeader(unsigned short |
| w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
-| WORD w_Address,str_DigitalInputHeader *s_Header) |
+| unsigned short w_Address,struct str_DigitalInputHeader *s_Header) |
| |
+----------------------------------------------------------------------------+
| Task : Read Digital Input Header |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
-| str_DigitalInputHeader *s_Header: Digita Input Header |
+| struct str_DigitalInputHeader *s_Header: Digita Input Header |
| Pointer |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -939,23 +937,23 @@ INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
| Return Value : 0 |
+----------------------------------------------------------------------------+
*/
-INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_DigitalInputHeader * s_Header)
+int i_EepromReadDigitalInputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_DigitalInputHeader *s_Header)
{
- WORD w_Temp;
+ unsigned short w_Temp;
- // read nbr of channels
+ /* read nbr of channels */
s_Header->w_Nchannel =
w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
0x100 + w_Address + 6);
- // interruptible or not
+ /* interruptible or not */
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + w_Address + 8);
- s_Header->b_Interruptible = (BYTE) (w_Temp >> 7) & 0x01;
+ s_Header->b_Interruptible = (unsigned char) (w_Temp >> 7) & 0x01;
-// How many interruptible logic
+/* How many interruptible logic */
s_Header->w_NinterruptLogic =
w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
0x100 + w_Address + 10);
@@ -965,18 +963,18 @@ INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_EepromReadDigitalOutputHeader(WORD |
+| Function Name : int i_EepromReadDigitalOutputHeader(unsigned short |
| w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
-| WORD w_Address,str_DigitalOutputHeader *s_Header) |
+| unsigned short w_Address,struct str_DigitalOutputHeader *s_Header) |
| |
+----------------------------------------------------------------------------+
| Task : Read Digital Output Header |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
-| str_DigitalOutputHeader *s_Header: Digital Output Header|
+| struct str_DigitalOutputHeader *s_Header: Digital Output Header|
| Pointer |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -984,11 +982,11 @@ INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,
| Return Value : 0 |
+----------------------------------------------------------------------------+
*/
-INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_DigitalOutputHeader * s_Header)
+int i_EepromReadDigitalOutputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_DigitalOutputHeader *s_Header)
{
-// Read Nbr channels
+/* Read Nbr channels */
s_Header->w_Nchannel =
w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
0x100 + w_Address + 6);
@@ -997,17 +995,17 @@ INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, |
+| Function Name : int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, |
| char *pc_PCIChipInformation,WORD w_Address, |
-| str_TimerMainHeader *s_Header) |
+| struct str_TimerMainHeader *s_Header) |
+----------------------------------------------------------------------------+
| Task : Read Timer or Watchdog Header |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
-| str_TimerMainHeader *s_Header: Timer Header |
+| struct str_TimerMainHeader *s_Header: Timer Header |
| Pointer |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -1015,18 +1013,18 @@ INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,
| Return Value : 0 |
+----------------------------------------------------------------------------+
*/
-INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_TimerMainHeader * s_Header)
+int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_TimerMainHeader *s_Header)
{
- WORD i, w_Size = 0, w_Temp;
+ unsigned short i, w_Size = 0, w_Temp;
-//Read No of Timer
+/* Read No of Timer */
s_Header->w_Ntimer =
w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
0x100 + w_Address + 6);
-//Read header size
+/* Read header size */
for (i = 0; i < s_Header->w_Ntimer; i++) {
s_Header->s_TimerDetails[i].w_HeaderSize =
@@ -1037,23 +1035,23 @@ INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
pc_PCIChipInformation,
0x100 + w_Address + 8 + w_Size + 2);
- //Read Resolution
+ /* Read Resolution */
s_Header->s_TimerDetails[i].b_Resolution =
- (BYTE) (w_Temp >> 10) & 0x3F;
+ (unsigned char) (w_Temp >> 10) & 0x3F;
- //Read Mode
+ /* Read Mode */
s_Header->s_TimerDetails[i].b_Mode =
- (BYTE) (w_Temp >> 4) & 0x3F;
+ (unsigned char) (w_Temp >> 4) & 0x3F;
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation,
0x100 + w_Address + 8 + w_Size + 4);
- //Read MinTiming
+ /* Read MinTiming */
s_Header->s_TimerDetails[i].w_MinTiming = (w_Temp >> 6) & 0x3FF;
- //Read Timebase
- s_Header->s_TimerDetails[i].b_TimeBase = (BYTE) (w_Temp) & 0x3F;
+ /* Read Timebase */
+ s_Header->s_TimerDetails[i].b_TimeBase = (unsigned char) (w_Temp) & 0x3F;
w_Size += s_Header->s_TimerDetails[i].w_HeaderSize;
}
@@ -1062,13 +1060,13 @@ INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_EepromReadAnlogOutputHeader(WORD |
+| Function Name : int i_EepromReadAnlogOutputHeader(unsigned short |
| w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
-| WORD w_Address,str_AnalogOutputHeader *s_Header) |
+| unsigned short w_Address,str_AnalogOutputHeader *s_Header) |
+----------------------------------------------------------------------------+
| Task : Read Nalog Output Header |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
@@ -1081,35 +1079,35 @@ INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
+----------------------------------------------------------------------------+
*/
-INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_AnalogOutputHeader * s_Header)
+int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ str_AnalogOutputHeader *s_Header)
{
- WORD w_Temp;
- // No of channels for 1st hard component
+ unsigned short w_Temp;
+ /* No of channels for 1st hard component */
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + w_Address + 10);
s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF;
- // Resolution for 1st hard component
+ /* Resolution for 1st hard component */
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + w_Address + 16);
- s_Header->b_Resolution = (BYTE) (w_Temp >> 8) & 0xFF;
+ s_Header->b_Resolution = (unsigned char) (w_Temp >> 8) & 0xFF;
return 0;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_EepromReadAnlogInputHeader(WORD |
+| Function Name : int i_EepromReadAnlogInputHeader(unsigned short |
| w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
-| WORD w_Address,str_AnalogInputHeader *s_Header) |
+| unsigned short w_Address,struct str_AnalogInputHeader *s_Header) |
+----------------------------------------------------------------------------+
| Task : Read Nalog Output Header |
+----------------------------------------------------------------------------+
-| Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
+| Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
| |
| char *pc_PCIChipInformation : PCI Chip Type. |
| |
-| str_AnalogInputHeader *s_Header:Anlog Input Header |
+| struct str_AnalogInputHeader *s_Header:Anlog Input Header |
| Pointer |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -1118,12 +1116,12 @@ INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,
+----------------------------------------------------------------------------+
*/
-// Reads only for ONE hardware component
-INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,
- char *pc_PCIChipInformation, WORD w_Address,
- str_AnalogInputHeader * s_Header)
+/* Reads only for ONE hardware component */
+int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress,
+ char *pc_PCIChipInformation, unsigned short w_Address,
+ struct str_AnalogInputHeader *s_Header)
{
- WORD w_Temp, w_Offset;
+ unsigned short w_Temp, w_Offset;
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + w_Address + 10);
s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF;
@@ -1135,24 +1133,24 @@ INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,
0x100 + w_Address + 30);
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + w_Address + 20);
- s_Header->b_HasDma = (w_Temp >> 13) & 0x01; // whether dma present or not
+ s_Header->b_HasDma = (w_Temp >> 13) & 0x01; /* whether dma present or not */
- w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 72); // reading Y
+ w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 72); /* reading Y */
w_Temp = w_Temp & 0x00FF;
- if (w_Temp) //Y>0
+ if (w_Temp) /* Y>0 */
{
- w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); // offset of first analog input single header
- w_Offset = w_Offset + 2; // resolution
- } else //Y=0
+ w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); /* offset of first analog input single header */
+ w_Offset = w_Offset + 2; /* resolution */
+ } else /* Y=0 */
{
w_Offset = 74;
- w_Offset = w_Offset + 2; // resolution
+ w_Offset = w_Offset + 2; /* resolution */
}
-// read Resolution
+/* read Resolution */
w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
pc_PCIChipInformation, 0x100 + w_Address + w_Offset);
- s_Header->b_Resolution = w_Temp & 0x001F; // last 5 bits
+ s_Header->b_Resolution = w_Temp & 0x001F; /* last 5 bits */
return 0;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
index 617dc087dcbf..b76f877f250a 100644
--- a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
+++ b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
@@ -31,15 +31,15 @@
*************************/
-#define FIFO_ADVANCE_ON_BYTE_2 0x20000000 // written on base0
+#define FIFO_ADVANCE_ON_BYTE_2 0x20000000 /* written on base0 */
-#define AMWEN_ENABLE 0x02 // added for step 6 dma written on base2
+#define AMWEN_ENABLE 0x02 /* added for step 6 dma written on base2 */
#define A2P_FIFO_WRITE_ENABLE 0x01
-#define AGCSTS_TC_ENABLE 0x10000000 // Added for transfer count enable bit
+#define AGCSTS_TC_ENABLE 0x10000000 /* Added for transfer count enable bit */
-// ADDON RELATED ADDITIONS
-// Constant
+/* ADDON RELATED ADDITIONS */
+/* Constant */
#define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW 0x00
#define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH 0x1200
#define APCI3120_A2P_FIFO_MANAGEMENT 0x04000400L
@@ -52,7 +52,7 @@
#define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0
#define APCI3120_DISABLE_BUS_MASTER_PCI 0x0
- // ADD_ON ::: this needed since apci supports 16 bit interface to add on
+ /* ADD_ON ::: this needed since apci supports 16 bit interface to add on */
#define APCI3120_ADD_ON_AGCSTS_LOW 0x3C
#define APCI3120_ADD_ON_AGCSTS_HIGH APCI3120_ADD_ON_AGCSTS_LOW + 2
#define APCI3120_ADD_ON_MWAR_LOW 0x24
@@ -60,7 +60,7 @@
#define APCI3120_ADD_ON_MWTC_LOW 0x058
#define APCI3120_ADD_ON_MWTC_HIGH APCI3120_ADD_ON_MWTC_LOW + 2
-// AMCC
+/* AMCC */
#define APCI3120_AMCC_OP_MCSR 0x3C
#define APCI3120_AMCC_OP_REG_INTCSR 0x38
@@ -85,7 +85,7 @@
#define AMCC_OP_REG_MRTC 0x30
#define AMCC_OP_REG_MBEF 0x34
#define AMCC_OP_REG_INTCSR 0x38
-#define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) /* INT source */
+#define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) /* int source */
#define AMCC_OP_REG_INTCSR_FEC (AMCC_OP_REG_INTCSR + 3) /* FIFO ctrl */
#define AMCC_OP_REG_MCSR 0x3c
#define AMCC_OP_REG_MCSR_NVDATA (AMCC_OP_REG_MCSR + 2) /* Data in byte 2 */
@@ -212,7 +212,7 @@ struct pcilst_struct {
unsigned int irq;
};
-struct pcilst_struct *amcc_devices; // ptr to root list of all amcc devices
+struct pcilst_struct *amcc_devices; /* ptr to root list of all amcc devices */
/****************************************************************************/
@@ -267,7 +267,7 @@ void v_pci_card_list_init(unsigned short pci_vendor, char display)
amcc->vendor = pcidev->vendor;
amcc->device = pcidev->device;
#if 0
- amcc->master = pcidev->master; // how get this information under 2.4 kernels?
+ amcc->master = pcidev->master; /* how get this information under 2.4 kernels? */
#endif
amcc->pci_bus = pcidev->bus->number;
amcc->pci_slot = PCI_SLOT(pcidev->devfn);
@@ -333,17 +333,17 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id,
&& (amcc->pci_slot == pci_slot)) {
if (!(amcc->used)) {
*card = amcc;
- return 0; // ok, card is found
+ return 0; /* ok, card is found */
} else {
- rt_printk
+ printk
(" - \nCard on requested position is used b:s %d:%d!\n",
pci_bus, pci_slot);
- return 2; // card exist but is used
+ return 2; /* card exist but is used */
}
}
}
- return 1; // no card found
+ return 1; /* no card found */
}
/****************************************************************************/
@@ -422,11 +422,10 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
{
struct pcilst_struct *card;
- if ((pci_bus < 1) & (pci_slot < 1)) { // use autodetection
- if ((card = ptr_find_free_pci_card_by_device(vendor_id,
- device_id)) ==
- NULL) {
- rt_printk(" - Unused card not found in system!\n");
+ if ((pci_bus < 1) & (pci_slot < 1)) { /* use autodetection */
+ card = ptr_find_free_pci_card_by_device(vendor_id, device_id);
+ if (card == NULL) {
+ printk(" - Unused card not found in system!\n");
return NULL;
}
} else {
@@ -434,12 +433,12 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
pci_bus, pci_slot,
&card)) {
case 1:
- rt_printk
+ printk
(" - Card not found on requested position b:s %d:%d!\n",
pci_bus, pci_slot);
return NULL;
case 2:
- rt_printk
+ printk
(" - Card on requested position is used b:s %d:%d!\n",
pci_bus, pci_slot);
return NULL;
@@ -447,7 +446,7 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
}
if (i_pci_card_alloc(card) != 0) {
- rt_printk(" - Can't allocate card!\n");
+ printk(" - Can't allocate card!\n");
return NULL;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
index 3f8929c09070..47517a938ec5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
@@ -1,15 +1,15 @@
-/**
+//**
@verbatim
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -56,21 +56,22 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
#include "APCI1710_Pwm.c"
#include "APCI1710_INCCPT.c"
-void i_ADDI_AttachPCI1710(struct comedi_device * dev)
+void i_ADDI_AttachPCI1710(struct comedi_device *dev)
{
struct comedi_subdevice *s;
int ret = 0;
int n_subdevices = 9;
- //Update-0.7.57->0.7.68dev->n_subdevices = 9;
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0)
+ /* Update-0.7.57->0.7.68dev->n_subdevices = 9; */
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0)
return;
- // Allocate and Initialise Timer Subdevice Structures
+ /* Allocate and Initialise Timer Subdevice Structures */
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_TIMER;
- s->subdev_flags = SDF_WRITEABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 3;
s->maxdata = 0;
s->len_chanlist = 3;
@@ -80,12 +81,12 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev)
s->insn_config = i_APCI1710_InsnConfigInitTimer;
s->insn_bits = i_APCI1710_InsnBitsTimer;
- // Allocate and Initialise DIO Subdevice Structures
+ /* Allocate and Initialise DIO Subdevice Structures */
s = dev->subdevices + 1;
s->type = COMEDI_SUBD_DIO;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 7;
s->maxdata = 1;
s->len_chanlist = 7;
@@ -95,11 +96,11 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev)
s->insn_bits = i_APCI1710_InsnBitsDigitalIOPortOnOff;
s->insn_write = i_APCI1710_InsnWriteDigitalIOChlOnOff;
- // Allocate and Initialise Chrono Subdevice Structures
+ /* Allocate and Initialise Chrono Subdevice Structures */
s = dev->subdevices + 2;
s->type = COMEDI_SUBD_CHRONO;
- s->subdev_flags = SDF_WRITEABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 4;
s->maxdata = 0;
s->len_chanlist = 4;
@@ -109,55 +110,55 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev)
s->insn_config = i_APCI1710_InsnConfigInitChrono;
s->insn_bits = i_APCI1710_InsnBitsChronoDigitalIO;
- // Allocate and Initialise PWM Subdevice Structures
+ /* Allocate and Initialise PWM Subdevice Structures */
s = dev->subdevices + 3;
s->type = COMEDI_SUBD_PWM;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 3;
s->maxdata = 1;
s->len_chanlist = 3;
s->range_table = &range_digital;
- s->io_bits = 0; //all bits input
+ s->io_bits = 0; /* all bits input */
s->insn_config = i_APCI1710_InsnConfigPWM;
s->insn_read = i_APCI1710_InsnReadGetPWMStatus;
s->insn_write = i_APCI1710_InsnWritePWM;
s->insn_bits = i_APCI1710_InsnBitsReadPWMInterrupt;
- // Allocate and Initialise TTLIO Subdevice Structures
+ /* Allocate and Initialise TTLIO Subdevice Structures */
s = dev->subdevices + 4;
s->type = COMEDI_SUBD_TTLIO;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 8;
s->maxdata = 1;
s->len_chanlist = 8;
- s->range_table = &range_apci1710_ttl; // to pass arguments in range
+ s->range_table = &range_apci1710_ttl; /* to pass arguments in range */
s->insn_config = i_APCI1710_InsnConfigInitTTLIO;
s->insn_bits = i_APCI1710_InsnBitsReadTTLIO;
s->insn_write = i_APCI1710_InsnWriteSetTTLIOChlOnOff;
s->insn_read = i_APCI1710_InsnReadTTLIOAllPortValue;
- // Allocate and Initialise TOR Subdevice Structures
+ /* Allocate and Initialise TOR Subdevice Structures */
s = dev->subdevices + 5;
s->type = COMEDI_SUBD_TOR;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 8;
s->maxdata = 1;
s->len_chanlist = 8;
s->range_table = &range_digital;
- s->io_bits = 0; //all bits input
+ s->io_bits = 0; /* all bits input */
s->insn_config = i_APCI1710_InsnConfigInitTorCounter;
s->insn_read = i_APCI1710_InsnReadGetTorCounterInitialisation;
s->insn_write = i_APCI1710_InsnWriteEnableDisableTorCounter;
s->insn_bits = i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue;
- // Allocate and Initialise SSI Subdevice Structures
+ /* Allocate and Initialise SSI Subdevice Structures */
s = dev->subdevices + 6;
s->type = COMEDI_SUBD_SSI;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 4;
s->maxdata = 1;
s->len_chanlist = 4;
@@ -166,11 +167,11 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev)
s->insn_read = i_APCI1710_InsnReadSSIValue;
s->insn_bits = i_APCI1710_InsnBitsSSIDigitalIO;
- // Allocate and Initialise PULSEENCODER Subdevice Structures
+ /* Allocate and Initialise PULSEENCODER Subdevice Structures */
s = dev->subdevices + 7;
s->type = COMEDI_SUBD_PULSEENCODER;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 4;
s->maxdata = 1;
s->len_chanlist = 4;
@@ -180,11 +181,11 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev)
s->insn_bits = i_APCI1710_InsnBitsReadWritePulseEncoder;
s->insn_read = i_APCI1710_InsnReadInterruptPulseEncoder;
- // Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures
+ /* Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures */
s = dev->subdevices + 8;
s->type = COMEDI_SUBD_INCREMENTALCOUNTER;
s->subdev_flags =
- SDF_WRITEABLE | SDF_READABLE | SDF_RT | SDF_GROUND | SDF_COMMON;
+ SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 500;
s->maxdata = 1;
s->len_chanlist = 500;
@@ -195,14 +196,14 @@ void i_ADDI_AttachPCI1710(struct comedi_device * dev)
s->insn_bits = i_APCI1710_InsnBitsINCCPT;
}
-int i_APCI1710_Reset(struct comedi_device * dev);
+int i_APCI1710_Reset(struct comedi_device *dev);
void v_APCI1710_Interrupt(int irq, void *d);
-//for 1710
+/* for 1710 */
-int i_APCI1710_Reset(struct comedi_device * dev)
+int i_APCI1710_Reset(struct comedi_device *dev)
{
int ret;
- DWORD dw_Dummy;
+ unsigned int dw_Dummy;
/*********************************/
/* Read all module configuration */
@@ -219,12 +220,12 @@ int i_APCI1710_Reset(struct comedi_device * dev)
ret = inl(devpriv->s_BoardInfos.ui_Address + 252);
devpriv->s_BoardInfos.dw_MolduleConfiguration[3] = ret;
- // outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60);
+ /* outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60); */
outl(0x83838383, devpriv->s_BoardInfos.ui_Address + 0x60);
devpriv->s_BoardInfos.b_BoardVersion = 1;
- // Enable the interrupt for the controler
+ /* Enable the interrupt for the controler */
dw_Dummy = inl(devpriv->s_BoardInfos.ui_Address + 0x38);
outl(dw_Dummy | 0x2000, devpriv->s_BoardInfos.ui_Address + 0x38);
@@ -234,11 +235,11 @@ int i_APCI1710_Reset(struct comedi_device * dev)
/*
+----------------------------------------------------------------------------+
| Function's Name : __void__ v_APCI1710_InterruptFunction |
-| (BYTE b_Interrupt, __CPPARGS) |
+| (unsigned char b_Interrupt, __CPPARGS) |
+----------------------------------------------------------------------------+
| Task : APCI-1710 interrupt function |
+----------------------------------------------------------------------------+
-| Input Parameters : BYTE b_Interrupt : Interrupt number |
+| Input Parameters : unsigned char b_Interrupt : Interrupt number |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -250,18 +251,18 @@ int i_APCI1710_Reset(struct comedi_device * dev)
void v_APCI1710_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- BYTE b_ModuleCpt = 0;
- BYTE b_InterruptFlag = 0;
- BYTE b_PWMCpt = 0;
- BYTE b_TorCounterCpt = 0;
- BYTE b_PulseIncoderCpt = 0;
- UINT ui_16BitValue;
- ULONG ul_InterruptLatchReg = 0;
- ULONG ul_LatchRegisterValue = 0;
- ULONG ul_82X54InterruptStatus;
- ULONG ul_StatusRegister;
-
- str_ModuleInfo *ps_ModuleInfo;
+ unsigned char b_ModuleCpt = 0;
+ unsigned char b_InterruptFlag = 0;
+ unsigned char b_PWMCpt = 0;
+ unsigned char b_TorCounterCpt = 0;
+ unsigned char b_PulseIncoderCpt = 0;
+ unsigned int ui_16BitValue;
+ unsigned int ul_InterruptLatchReg = 0;
+ unsigned int ul_LatchRegisterValue = 0;
+ unsigned int ul_82X54InterruptStatus;
+ unsigned int ul_StatusRegister;
+
+ union str_ModuleInfo *ps_ModuleInfo;
printk("APCI1710 Interrupt\n");
for (b_ModuleCpt = 0; b_ModuleCpt < 4; b_ModuleCpt++, ps_ModuleInfo++) {
@@ -279,7 +280,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
dw_MolduleConfiguration[b_ModuleCpt] &
0xFFFF0000UL) == APCI1710_82X54_TIMER) {
- //printk("TIMER Interrupt Occurred\n");
+ /* printk("TIMER Interrupt Occurred\n"); */
ul_82X54InterruptStatus = inl(devpriv->s_BoardInfos.
ui_Address + 12 + (64 * b_ModuleCpt));
@@ -332,11 +333,11 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
- } // if ((ul_82X54InterruptStatus & 0x7) != 0)
- } // 82X54 timer
+ } /* if ((ul_82X54InterruptStatus & 0x7) != 0) */
+ } /* 82X54 timer */
/***************************/
/* Test if increm. counter */
@@ -412,7 +413,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current,
0);
@@ -473,7 +474,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current,
0);
@@ -562,7 +563,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current,
0);
@@ -628,7 +629,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current,
0);
@@ -675,7 +676,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
if ((ul_LatchRegisterValue &
0xFFFFU) != 0) {
ui_16BitValue =
- (UINT)
+ (unsigned int)
ul_LatchRegisterValue
& 0xFFFFU;
ul_LatchRegisterValue =
@@ -693,7 +694,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
0xFFFF0000UL) !=
0) {
ui_16BitValue =
- (UINT) (
+ (unsigned int) (
(ul_LatchRegisterValue
>> 16) &
0xFFFFU);
@@ -721,7 +722,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
if ((ul_LatchRegisterValue &
0xFFFF0000UL) != 0) {
ui_16BitValue =
- (UINT) (
+ (unsigned int) (
(ul_LatchRegisterValue
>> 16) &
0xFFFFU);
@@ -741,7 +742,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
if ((ul_LatchRegisterValue & 0xFFFFU) !=
0) {
ui_16BitValue =
- (UINT)
+ (unsigned int)
ul_LatchRegisterValue &
0xFFFFU;
ul_LatchRegisterValue =
@@ -795,11 +796,11 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
}
- } // Incremental counter
+ } /* Incremental counter */
/***************/
/* Test if CDA */
@@ -870,14 +871,14 @@ void v_APCI1710_Interrupt(int irq, void *d)
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current,
0);
- } // if (ul_StatusRegister & 1)
+ } /* if (ul_StatusRegister & 1) */
}
- } // CDA
+ } /* CDA */
/***********************/
/* Test if PWM counter */
@@ -950,15 +951,15 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO,
devpriv->tsk_Current,
0);
- } // if (ul_StatusRegister & 0x1)
- } // if (APCI1710_ENABLE)
- } // for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++)
- } // PWM counter
+ } /* if (ul_StatusRegister & 0x1) */
+ } /* if (APCI1710_ENABLE) */
+ } /* for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++) */
+ } /* PWM counter */
/***********************/
/* Test if tor counter */
@@ -1054,14 +1055,14 @@ void v_APCI1710_Interrupt(int irq, void *d)
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO,
devpriv->tsk_Current,
0);
- } // if (ul_StatusRegister & 0x1)
- } // if (APCI1710_ENABLE)
- } // for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++)
- } // Tor counter
+ } /* if (ul_StatusRegister & 0x1) */
+ } /* if (APCI1710_ENABLE) */
+ } /* for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++) */
+ } /* Tor counter */
/***********************/
/* Test if chronometer */
@@ -1071,7 +1072,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
dw_MolduleConfiguration[b_ModuleCpt] &
0xFFFF0000UL) == APCI1710_CHRONOMETER) {
- //printk("APCI1710 Chrono Interrupt\n");
+ /* printk("APCI1710 Chrono Interrupt\n"); */
/*****************************/
/* Read the interrupt status */
/*****************************/
@@ -1163,13 +1164,13 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current,
0);
}
}
- } // Chronometer
+ } /* Chronometer */
/*************************/
/* Test if pulse encoder */
@@ -1249,7 +1250,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
/**********************/
/* Call user function */
/**********************/
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO,
devpriv->tsk_Current,
0);
@@ -1257,7 +1258,7 @@ void v_APCI1710_Interrupt(int irq, void *d)
}
}
}
- } //pulse encoder
+ } /* pulse encoder */
}
return;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h
index 998cbba8afeb..22b3e569ecd5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h
@@ -44,7 +44,7 @@
#define APCI1710_SYNCHRONOUS_MODE 1
#define APCI1710_ASYNCHRONOUS_MODE 0
-//MODULE INFO STRUCTURE
+/* MODULE INFO STRUCTURE */
static const struct comedi_lrange range_apci1710_ttl = { 4, {
BIP_RANGE(10),
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c
index e4527926c2df..016721efdbfb 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -52,9 +52,9 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
#include "hwdrv_apci035.h"
-INT i_WatchdogNbr = 0;
-INT i_Temp = 0;
-INT i_Flag = 1;
+int i_WatchdogNbr = 0;
+int i_Temp = 0;
+int i_Flag = 1;
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI035_ConfigTimerWatchdog |
@@ -64,42 +64,42 @@ INT i_Flag = 1;
| Task : Configures The Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 Configure As Timer |
| 1 Configure As Watchdog |
- data[1] : Watchdog number
+| data[1] : Watchdog number
| data[2] : Time base Unit |
| data[3] : Reload Value |
- data[4] : External Trigger |
- 1:Enable
- 0:Disable
- data[5] :External Trigger Level
- 00 Trigger Disabled
- 01 Trigger Enabled (Low level)
- 10 Trigger Enabled (High Level)
- 11 Trigger Enabled (High/Low level)
- data[6] : External Gate |
- 1:Enable
- 0:Disable
- data[7] : External Gate level
- 00 Gate Disabled
- 01 Gate Enabled (Low level)
- 10 Gate Enabled (High Level)
- data[8] :Warning Relay
- 1: ENABLE
- 0: DISABLE
- data[9] :Warning Delay available
- data[10] :Warning Relay Time unit
- data[11] :Warning Relay Time Reload value
- data[12] :Reset Relay
- 1 : ENABLE
- 0 : DISABLE
- data[13] :Interrupt
- 1 : ENABLE
- 0 : DISABLE
-
+| data[4] : External Trigger |
+| 1:Enable
+| 0:Disable
+| data[5] :External Trigger Level
+| 00 Trigger Disabled
+| 01 Trigger Enabled (Low level)
+| 10 Trigger Enabled (High Level)
+| 11 Trigger Enabled (High/Low level)
+| data[6] : External Gate |
+| 1:Enable
+| 0:Disable
+| data[7] : External Gate level
+| 00 Gate Disabled
+| 01 Gate Enabled (Low level)
+| 10 Gate Enabled (High Level)
+| data[8] :Warning Relay
+| 1: ENABLE
+| 0: DISABLE
+| data[9] :Warning Delay available
+| data[10] :Warning Relay Time unit
+| data[11] :Warning Relay Time Reload value
+| data[12] :Reset Relay
+| 1 : ENABLE
+| 0 : DISABLE
+| data[13] :Interrupt
+| 1 : ENABLE
+| 0 : DISABLE
+|
|
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -109,12 +109,12 @@ INT i_Flag = 1;
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Status = 0;
- UINT ui_Command = 0;
- UINT ui_Mode = 0;
+ unsigned int ui_Status = 0;
+ unsigned int ui_Command = 0;
+ unsigned int ui_Mode = 0;
i_Temp = 0;
devpriv->tsk_Current = current;
devpriv->b_TimerSelectMode = data[0];
@@ -124,9 +124,9 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd
} else {
ui_Mode = 0;
}
-//ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
+/* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); */
ui_Command = 0;
-//ui_Command = ui_Command & 0xFFFFF9FEUL;
+/* ui_Command = ui_Command & 0xFFFFF9FEUL; */
outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
ui_Command = 0;
ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
@@ -153,7 +153,7 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd
ui_Command =
(ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;
- } //if (data[0] == ADDIDATA_TIMER)
+ } /* if (data[0] == ADDIDATA_TIMER) */
else {
if (data[0] == ADDIDATA_WATCHDOG) {
@@ -260,7 +260,7 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd
| Task : Start / Stop The Selected Timer , or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 - Stop Selected Timer/Watchdog |
@@ -278,11 +278,11 @@ INT i_APCI035_ConfigTimerWatchdog(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Command = 0;
- INT i_Count = 0;
+ unsigned int ui_Command = 0;
+ int i_Count = 0;
if (data[0] == 1) {
ui_Command =
inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
@@ -292,7 +292,7 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;
outl(ui_Command,
devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
- } // if (data[0]==1)
+ } /* if (data[0]==1) */
if (data[0] == 2) {
ui_Command =
inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
@@ -304,16 +304,18 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
}
- if (data[0] == 0) //Stop The Watchdog
+ if (data[0] == 0) /* Stop The Watchdog */
{
- //Stop The Watchdog
+ /* Stop The Watchdog */
ui_Command = 0;
- //ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
- //ui_Command = ui_Command & 0xFFFFF9FEUL;
+/*
+* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
+* ui_Command = ui_Command & 0xFFFFF9FEUL;
+*/
outl(ui_Command,
devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
- } // if (data[1]==0)
- if (data[0] == 3) //stop all Watchdogs
+ } /* if (data[1]==0) */
+ if (data[0] == 3) /* stop all Watchdogs */
{
ui_Command = 0;
for (i_Count = 1; i_Count <= 4; i_Count++) {
@@ -329,7 +331,7 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
}
}
- if (data[0] == 4) //start all Watchdogs
+ if (data[0] == 4) /* start all Watchdogs */
{
ui_Command = 0;
for (i_Count = 1; i_Count <= 4; i_Count++) {
@@ -344,7 +346,7 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
0);
}
}
- if (data[0] == 5) //trigger all Watchdogs
+ if (data[0] == 5) /* trigger all Watchdogs */
{
ui_Command = 0;
for (i_Count = 1; i_Count <= 4; i_Count++) {
@@ -373,17 +375,17 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
| Task : Read The Selected Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| |
+----------------------------------------------------------------------------+
| Output Parameters : data[0] : software trigger status
- data[1] : hardware trigger status
-| data[2] : Software clear status
- data[3] : Overflow status
- data[4] : Timer actual value
-
+| data[1] : hardware trigger status
+| data[2] : Software clear status
+| data[3] : Overflow status
+| data[4] : Timer actual value
+|
+----------------------------------------------------------------------------+
| Return Value : TRUE : No error occur |
@@ -391,42 +393,46 @@ INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI035_ReadTimerWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Status = 0; // Status register
+ unsigned int ui_Status = 0; /* Status register */
i_WatchdogNbr = insn->unused[0];
- /******************/
+
+ /******************/
/* Get the status */
- /******************/
+ /******************/
+
ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
- /***********************************/
+
+ /***********************************/
/* Get the software trigger status */
- /***********************************/
+ /***********************************/
+
data[0] = ((ui_Status >> 1) & 1);
- /***********************************/
+ /***********************************/
/* Get the hardware trigger status */
- /***********************************/
+ /***********************************/
data[1] = ((ui_Status >> 2) & 1);
- /*********************************/
+ /*********************************/
/* Get the software clear status */
- /*********************************/
+ /*********************************/
data[2] = ((ui_Status >> 3) & 1);
- /***************************/
+ /***************************/
/* Get the overflow status */
- /***************************/
+ /***************************/
data[3] = ((ui_Status >> 0) & 1);
if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0);
- } // if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
+ } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI035_ConfigAnalogInput |
+| Function Name : int i_APCI035_ConfigAnalogInput |
| (struct comedi_device *dev,struct comedi_subdevice *s, |
| struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
@@ -447,8 +453,8 @@ INT i_APCI035_ReadTimerWatchdog(struct comedi_device * dev, struct comedi_subdev
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI035_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
devpriv->tsk_Current = current;
outl(0x200 | 0, devpriv->iobase + 128 + 0x4);
@@ -472,8 +478,8 @@ INT i_APCI035_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdev
| Task : Read value of the selected channel |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : Digital Value Of Input |
@@ -484,10 +490,10 @@ INT i_APCI035_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdev
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI035_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_CommandRegister = 0;
+ unsigned int ui_CommandRegister = 0;
/******************/
/* Set the start */
/******************/
@@ -519,14 +525,14 @@ INT i_APCI035_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevic
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI035_Reset(struct comedi_device * dev)
+int i_APCI035_Reset(struct comedi_device *dev)
{
- INT i_Count = 0;
+ int i_Count = 0;
for (i_Count = 1; i_Count <= 4; i_Count++) {
i_WatchdogNbr = i_Count;
- outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); //stop all timers
+ outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); /* stop all timers */
}
- outl(0x0, devpriv->iobase + 128 + 12); //Disable the warning delay
+ outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */
return 0;
}
@@ -551,11 +557,11 @@ INT i_APCI035_Reset(struct comedi_device * dev)
static void v_APCI035_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- UINT ui_StatusRegister1 = 0;
- UINT ui_StatusRegister2 = 0;
- UINT ui_ReadCommand = 0;
- UINT ui_ChannelNumber = 0;
- UINT ui_DigitalTemperature = 0;
+ unsigned int ui_StatusRegister1 = 0;
+ unsigned int ui_StatusRegister2 = 0;
+ unsigned int ui_ReadCommand = 0;
+ unsigned int ui_ChannelNumber = 0;
+ unsigned int ui_DigitalTemperature = 0;
if (i_Temp == 1) {
i_WatchdogNbr = i_Flag;
i_Flag = i_Flag + 1;
@@ -571,7 +577,7 @@ static void v_APCI035_Interrupt(int irq, void *d)
ui_StatusRegister2 =
inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20);
- if ((((ui_StatusRegister1) & 0x8) == 0x8)) //Test if warning relay interrupt
+ if ((((ui_StatusRegister1) & 0x8) == 0x8)) /* Test if warning relay interrupt */
{
/**********************************/
/* Disable the temperature warning */
@@ -587,14 +593,14 @@ static void v_APCI035_Interrupt(int irq, void *d)
/* Read the digital temperature value */
/**************************************/
ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60);
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
- } //if (((ui_StatusRegister1 & 0x8) == 0x8))
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
+ } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */
else {
if ((ui_StatusRegister2 & 0x1) == 0x1) {
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
}
- } //else if (((ui_StatusRegister1 & 0x8) == 0x8))
+ } /* else if (((ui_StatusRegister1 & 0x8) == 0x8)) */
return;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h
index 80d7c0d39aab..e0023c8cb628 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h
@@ -19,18 +19,18 @@
#define APCI035_BOARD_VENDOR_ID 0x15B8
#define APCI035_ADDRESS_RANGE 255
-INT i_TW_Number;
+int i_TW_Number;
struct {
- INT i_Gain;
- INT i_Polarity;
- INT i_OffsetRange;
- INT i_Coupling;
- INT i_SingleDiff;
- INT i_AutoCalibration;
- UINT ui_ReloadValue;
- UINT ui_TimeUnitReloadVal;
- INT i_Interrupt;
- INT i_ModuleSelection;
+ int i_Gain;
+ int i_Polarity;
+ int i_OffsetRange;
+ int i_Coupling;
+ int i_SingleDiff;
+ int i_AutoCalibration;
+ unsigned int ui_ReloadValue;
+ unsigned int ui_TimeUnitReloadVal;
+ int i_Interrupt;
+ int i_ModuleSelection;
} Config_Parameters_Main;
/* ANALOG INPUT RANGE */
@@ -101,23 +101,23 @@ struct comedi_lrange range_apci035_ai = { 8, {
/* TIMER */
/* timer value is passed as u seconds */
-INT i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev,
+int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/* Temperature Related Defines (Analog Input Subdevice) */
-INT i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/* Interrupt */
static void v_APCI035_Interrupt(int irq, void *d);
/* Reset functions */
-INT i_APCI035_Reset(struct comedi_device *dev);
+int i_APCI035_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c
index 32796ceb946e..e9021cd4d341 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -53,8 +53,8 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
*/
#include "hwdrv_apci1032.h"
#include <linux/delay.h>
-//Global variables
-UINT ui_InterruptStatus = 0;
+/* Global variables */
+unsigned int ui_InterruptStatus = 0;
/*
+----------------------------------------------------------------------------+
@@ -84,13 +84,13 @@ UINT ui_InterruptStatus = 0;
+----------------------------------------------------------------------------+
*/
-INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_TmpValue;
+ unsigned int ui_TmpValue;
- ULONG ul_Command1 = 0;
- ULONG ul_Command2 = 0;
+ unsigned int ul_Command1 = 0;
+ unsigned int ul_Command2 = 0;
devpriv->tsk_Current = current;
/*******************************/
@@ -107,11 +107,11 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
outl(0x4, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ);
ui_TmpValue =
inl(devpriv->iobase + APCI1032_DIGITAL_IP_IRQ);
- } //if (data[1] == ADDIDATA_OR)
+ } /* if (data[1] == ADDIDATA_OR) */
else {
outl(0x6, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ);
- } //else if(data[1] == ADDIDATA_OR)
- } // if( data[0] == ADDIDATA_ENABLE)
+ } /* else if(data[1] == ADDIDATA_OR) */
+ } /* if( data[0] == ADDIDATA_ENABLE) */
else {
ul_Command1 = ul_Command1 & 0xFFFF0000;
ul_Command2 = ul_Command2 & 0xFFFF0000;
@@ -120,7 +120,7 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
outl(ul_Command2,
devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2);
outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ);
- } //else if ( data[0] == ADDIDATA_ENABLE)
+ } /* else if ( data[0] == ADDIDATA_ENABLE) */
return insn->n;
}
@@ -134,7 +134,7 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
| Task : Return the status of the digital input |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_Channel : Channel number to read |
+| unsigned int ui_Channel : Channel number to read |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -144,22 +144,24 @@ INT i_APCI1032_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1032_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_TmpValue = 0;
- UINT ui_Channel;
+ unsigned int ui_TmpValue = 0;
+ unsigned int ui_Channel;
ui_Channel = CR_CHAN(insn->chanspec);
if (ui_Channel >= 0 && ui_Channel <= 31) {
- ui_TmpValue = (UINT) inl(devpriv->iobase + APCI1032_DIGITAL_IP);
- // since only 1 channel reqd to bring it to last bit it is rotated
- // 8 +(chan - 1) times then ANDed with 1 for last bit.
+ ui_TmpValue = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP);
+/*
+* since only 1 channel reqd to bring it to last bit it is rotated 8
+* +(chan - 1) times then ANDed with 1 for last bit.
+*/
*data = (ui_TmpValue >> ui_Channel) & 0x1;
- } //if(ui_Channel >= 0 && ui_Channel <=31)
+ } /* if(ui_Channel >= 0 && ui_Channel <=31) */
else {
- //comedi_error(dev," \n chan spec wrong\n");
- return -EINVAL; // "sorry channel spec wrong "
- } //else if(ui_Channel >= 0 && ui_Channel <=31)
+ /* comedi_error(dev," \n chan spec wrong\n"); */
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* else if(ui_Channel >= 0 && ui_Channel <=31) */
return insn->n;
}
@@ -172,8 +174,8 @@ INT i_APCI1032_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
| Task : Return the status of the Requested digital inputs |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To be Read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To be Read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -183,16 +185,16 @@ INT i_APCI1032_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
*/
-INT i_APCI1032_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_PortValue = data[0];
- UINT ui_Mask = 0;
- UINT ui_NoOfChannels;
+ unsigned int ui_PortValue = data[0];
+ unsigned int ui_Mask = 0;
+ unsigned int ui_NoOfChannels;
ui_NoOfChannels = CR_CHAN(insn->chanspec);
if (data[1] == 0) {
- *data = (UINT) inl(devpriv->iobase + APCI1032_DIGITAL_IP);
+ *data = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP);
switch (ui_NoOfChannels) {
case 2:
ui_Mask = 3;
@@ -213,16 +215,16 @@ INT i_APCI1032_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
case 31:
break;
default:
- //comedi_error(dev," \nchan spec wrong\n");
- return -EINVAL; // "sorry channel spec wrong "
+ /* comedi_error(dev," \nchan spec wrong\n"); */
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } //switch(ui_NoOfChannels)
- } //if(data[1]==0)
+ } /* switch(ui_NoOfChannels) */
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
*data = ui_InterruptStatus;
- } //if(data[1]==1)
- } //else if(data[1]==0)
+ } /* if(data[1]==1) */
+ } /* else if(data[1]==0) */
return insn->n;
}
@@ -247,16 +249,16 @@ static void v_APCI1032_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- UINT ui_Temp;
- //disable the interrupt
+ unsigned int ui_Temp;
+ /* disable the interrupt */
ui_Temp = inl(devpriv->iobase + APCI1032_DIGITAL_IP_IRQ);
outl(ui_Temp & APCI1032_DIGITAL_IP_INTERRUPT_DISABLE,
devpriv->iobase + APCI1032_DIGITAL_IP_IRQ);
ui_InterruptStatus =
inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS);
ui_InterruptStatus = ui_InterruptStatus & 0X0000FFFF;
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
- outl(ui_Temp, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); //enable the interrupt
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
+ outl(ui_Temp, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); /* enable the interrupt */
return;
}
@@ -275,11 +277,11 @@ static void v_APCI1032_Interrupt(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1032_Reset(struct comedi_device * dev)
+int i_APCI1032_Reset(struct comedi_device *dev)
{
- outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); //disable the interrupts
- inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); //Reset the interrupt status register
- outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); //Disable the and/or interrupt
+ outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); /* disable the interrupts */
+ inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); /* Reset the interrupt status register */
+ outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); /* Disable the and/or interrupt */
outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2);
return 0;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h
index 659ef85088cd..e29a72a568f3 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h
@@ -19,45 +19,46 @@
#define APCI1032_BOARD_VENDOR_ID 0x15B8
#define APCI1032_ADDRESS_RANGE 20
-//DIGITAL INPUT DEFINE
+/* DIGITAL INPUT DEFINE */
#define APCI1032_DIGITAL_IP 0
#define APCI1032_DIGITAL_IP_INTERRUPT_MODE1 4
#define APCI1032_DIGITAL_IP_INTERRUPT_MODE2 8
#define APCI1032_DIGITAL_IP_IRQ 16
-//Digital Input IRQ Function Selection
+/* Digital Input IRQ Function Selection */
#define ADDIDATA_OR 0
#define ADDIDATA_AND 1
-//Digital Input Interrupt Status
+/* Digital Input Interrupt Status */
#define APCI1032_DIGITAL_IP_INTERRUPT_STATUS 12
-//Digital Input Interrupt Enable Disable.
+/* Digital Input Interrupt Enable Disable. */
#define APCI1032_DIGITAL_IP_INTERRUPT_ENABLE 0x4
#define APCI1032_DIGITAL_IP_INTERRUPT_DISABLE 0xFFFFFFFB
-//ADDIDATA Enable Disable
+/* ADDIDATA Enable Disable */
#define ADDIDATA_ENABLE 1
#define ADDIDATA_DISABLE 0
-// Hardware Layer functions for Apci1032
+/* Hardware Layer functions for Apci1032 */
-//DI
-// for di read
+/*
+* DI for di read
+*/
-INT i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// Interrupt functions.....
+/* Interrupt functions..... */
static void v_APCI1032_Interrupt(int irq, void *d);
-//Reset
-INT i_APCI1032_Reset(struct comedi_device *dev);
+/* Reset */
+int i_APCI1032_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
index 2d6adcff41e3..236b8a31c824 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -77,7 +77,7 @@ int i_TimerCounter1Enabled = 0, i_TimerCounter2Enabled =
| data[0] :Number of the input port on |
| which the event will take place |
| (1 or 2)
- data[1] : The event logic for port 1 has |
+| data[1] : The event logic for port 1 has |
| three possibilities |
| :0 APCI1500_AND :This logic |
| links |
@@ -137,8 +137,8 @@ int i_TimerCounter1Enabled = 0, i_TimerCounter2Enabled =
+----------------------------------------------------------------------------+
*/
-INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ConfigDigitalInputEvent(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i_PatternPolarity = 0, i_PatternTransition = 0, i_PatternMask = 0;
int i_MaxChannel = 0, i_Count = 0, i_EventMask = 0;
@@ -157,16 +157,16 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
if (data[0] == 1) {
i_MaxChannel = 8;
- } // if (data[0] == 1)
+ } /* if (data[0] == 1) */
else {
if (data[0] == 2) {
i_MaxChannel = 6;
- } // if(data[0]==2)
+ } /* if(data[0]==2) */
else {
printk("\nThe specified port event does not exist\n");
return -EINVAL;
- } //else if(data[0]==2)
- } //else if (data[0] == 1)
+ } /* else if(data[0]==2) */
+ } /* else if (data[0] == 1) */
switch (data[1]) {
case 0:
data[1] = APCI1500_AND;
@@ -180,7 +180,7 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
default:
printk("\nThe specified interrupt logic does not exist\n");
return -EINVAL;
- } //switch(data[1]);
+ } /* switch(data[1]); */
i_Logic = data[1];
for (i_Count = i_MaxChannel, i = 0; i_Count > 0; i_Count--, i++) {
@@ -224,8 +224,8 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
default:
printk("\nThe option indicated in the event mask does not exist\n");
return -EINVAL;
- } // switch(i_EventMask)
- } //for (i_Count = i_MaxChannel; i_Count >0;i_Count --)
+ } /* switch(i_EventMask) */
+ } /* for (i_Count = i_MaxChannel; i_Count >0;i_Count --) */
if (data[0] == 1) {
/****************************/
@@ -247,7 +247,7 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
/********************************************/
printk("\nTransition error on an OR PRIORITY logic\n");
return -EINVAL;
- } // if (data[1]== APCI1500_OR_PRIORITY && i_PatternTransition != 0)
+ } /* if (data[1]== APCI1500_OR_PRIORITY && i_PatternTransition != 0) */
/*************************************/
/* Tests if more than one transition */
@@ -261,7 +261,7 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
((i_PatternTransition >>
i_Count) & 0x1);
- } //for (i_Count = 0; i_Count < 8; i_Count++)
+ } /* for (i_Count = 0; i_Count < 8; i_Count++) */
if (i_PatternTransitionCount > 1) {
/****************************************/
@@ -269,8 +269,8 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
/****************************************/
printk("\n Transition error on an AND logic\n");
return -EINVAL;
- } // if (i_PatternTransitionCount > 1)
- } // if (data[1]== APCI1500_AND)
+ } /* if (i_PatternTransitionCount > 1) */
+ } /* if (data[1]== APCI1500_AND) */
/*****************************************************************/
/* Selects the APCI1500_RW_MASTER_CONFIGURATION_CONTROL register */
@@ -359,12 +359,12 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } // if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY)
+ } /* if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY) */
else {
printk("\nThe choice for interrupt logic does not exist\n");
return -EINVAL;
- } // else }// if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY)
- } // if (data[0]== 1)
+ } /* else }// if(data[1]==APCI1500_AND||data[1]==APCI1500_OR||data[1]==APCI1500_OR_PRIORITY) */
+ } /* if (data[0]== 1) */
/************************************/
/* Test if event setting for port 2 */
@@ -487,12 +487,12 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
outb(0xF4,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } // if (data[1] == APCI1500_OR)
+ } /* if (data[1] == APCI1500_OR) */
else {
printk("\nThe choice for interrupt logic does not exist\n");
return -EINVAL;
- } //elseif (data[1] == APCI1500_OR)
- } //if(data[0]==2)
+ } /* elseif (data[1] == APCI1500_OR) */
+ } /* if(data[0]==2) */
return insn->n;
}
@@ -506,11 +506,11 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
| Task : Allows or disallows a port event |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_Channel : Channel number to read |
+| unsigned int ui_Channel : Channel number to read |
| unsigned int *data : Data Pointer to read status |
- data[0] :0 Start input event
- 1 Stop input event
- data[1] :No of port (1 or 2)
+| data[0] :0 Start input event
+| 1 Stop input event
+| data[1] :No of port (1 or 2)
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -519,8 +519,8 @@ INT i_APCI1500_ConfigDigitalInputEvent(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_StartStopInputEvent(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i_Event1InterruptStatus = 0, i_Event2InterruptStatus =
0, i_RegValue;
@@ -589,12 +589,12 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } // if(i_Event1Status==1)
+ } /* if(i_Event1Status==1) */
else {
printk("\nEvent 1 not initialised\n");
return -EINVAL;
- } //else if(i_Event1Status==1)
- } //if (data[1]==1)
+ } /* else if(i_Event1Status==1) */
+ } /* if (data[1]==1) */
if (data[1] == 2) {
if (i_Event2Status == 1) {
@@ -640,17 +640,17 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
i_Event2InterruptStatus = 1;
- } // if(i_Event2Status==1)
+ } /* if(i_Event2Status==1) */
else {
printk("\nEvent 2 not initialised\n");
return -EINVAL;
- } //else if(i_Event2Status==1)
- } // if(data[1]==2)
- } // if (data[1] == 1 || data[0] == 2)
+ } /* else if(i_Event2Status==1) */
+ } /* if(data[1]==2) */
+ } /* if (data[1] == 1 || data[0] == 2) */
else {
printk("\nThe port parameter is in error\n");
return -EINVAL;
- } //else if (data[1] == 1 || data[0] == 2)
+ } /* else if (data[1] == 1 || data[0] == 2) */
break;
@@ -701,12 +701,12 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
i_Event1InterruptStatus = 0;
- } // if(i_Event1Status==1)
+ } /* if(i_Event1Status==1) */
else {
printk("\nEvent 1 not initialised\n");
return -EINVAL;
- } //else if(i_Event1Status==1)
- } //if (data[1]==1)
+ } /* else if(i_Event1Status==1) */
+ } /* if (data[1]==1) */
if (data[1] == 2) {
/*****************************/
/* Test if event initialised */
@@ -744,23 +744,23 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
i_Event2InterruptStatus = 0;
- } // if(i_Event2Status==1)
+ } /* if(i_Event2Status==1) */
else {
printk("\nEvent 2 not initialised\n");
return -EINVAL;
- } //else if(i_Event2Status==1)
- } //if(data[1]==2)
+ } /* else if(i_Event2Status==1) */
+ } /* if(data[1]==2) */
- } // if (data[1] == 1 || data[1] == 2)
+ } /* if (data[1] == 1 || data[1] == 2) */
else {
printk("\nThe port parameter is in error\n");
return -EINVAL;
- } //else if (data[1] == 1 || data[1] == 2)
+ } /* else if (data[1] == 1 || data[1] == 2) */
break;
default:
printk("\nThe option of START/STOP logic does not exist\n");
return -EINVAL;
- } //switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
@@ -774,7 +774,7 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub
| Task : Return the status of the digital input |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_Channel : Channel number to read |
+| unsigned int ui_Channel : Channel number to read |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -784,8 +784,8 @@ int i_APCI1500_StartStopInputEvent(struct comedi_device * dev, struct comedi_sub
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1500_Initialisation(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_Initialisation(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i_DummyRead = 0;
/******************/
@@ -943,11 +943,11 @@ INT i_APCI1500_Initialisation(struct comedi_device * dev, struct comedi_subdevic
| Task : Return the status of the Requested digital inputs |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To be Read |
-| UINT *data : Data Pointer
- data[0] : 0 Read a single channel
- 1 read a port value
- data[1] : port value
+| unsigned int ui_NoOfChannels : No Of Channels To be Read |
+| unsigned int *data : Data Pointer
+| data[0] : 0 Read a single channel
+| 1 read a port value
+| data[1] : port value
+----------------------------------------------------------------------------+
| Output Parameters : -- data[0] :The read status value
+----------------------------------------------------------------------------+
@@ -957,31 +957,31 @@ INT i_APCI1500_Initialisation(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-INT i_APCI1500_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_PortValue = data[1];
- UINT ui_Mask = 0;
- UINT ui_Channel;
- UINT ui_TmpValue = 0;
+ unsigned int ui_PortValue = data[1];
+ unsigned int ui_Mask = 0;
+ unsigned int ui_Channel;
+ unsigned int ui_TmpValue = 0;
ui_Channel = CR_CHAN(insn->chanspec);
switch (data[0]) {
case 0:
if (ui_Channel >= 0 && ui_Channel <= 15) {
ui_TmpValue =
- (UINT) inw(devpriv->i_IobaseAddon +
+ (unsigned int) inw(devpriv->i_IobaseAddon +
APCI1500_DIGITAL_IP);
*data = (ui_TmpValue >> ui_Channel) & 0x1;
- } //if(ui_Channel >= 0 && ui_Channel <=15)
+ } /* if(ui_Channel >= 0 && ui_Channel <=15) */
else {
printk("\nThe channel specification are in error\n");
- return -EINVAL; // "sorry channel spec wrong "
- } //else if(ui_Channel >= 0 && ui_Channel <=15)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* else if(ui_Channel >= 0 && ui_Channel <=15) */
break;
case 1:
- *data = (UINT) inw(devpriv->i_IobaseAddon +
+ *data = (unsigned int) inw(devpriv->i_IobaseAddon +
APCI1500_DIGITAL_IP);
switch (ui_Channel) {
case 2:
@@ -1001,35 +1001,35 @@ INT i_APCI1500_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
default:
printk("\nSpecified channel cannot be read \n");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } //switch(ui_Channel)
+ } /* switch(ui_Channel) */
break;
default:
printk("\nThe specified functionality does not exist\n");
return -EINVAL;
- } //switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1500_ConfigDigitalOutputErrorInterrupt
- (struct comedi_device *dev,struct comedi_subdevice *s struct comedi_insn
- *insn,unsigned int *data) |
+| (struct comedi_device *dev,struct comedi_subdevice *s struct comedi_insn
+| *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Configures the digital output memory and the digital
- output error interrupt |
+| output error interrupt |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| data[0] :1:Memory on |
| 0:Memory off |
- data[1] :1 Enable the voltage error interrupt
+| data[1] :1 Enable the voltage error interrupt
| :0 Disable the voltage error interrupt |
| |
+----------------------------------------------------------------------------+
@@ -1040,8 +1040,8 @@ INT i_APCI1500_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
devpriv->b_OutputMemoryStatus = data[0];
return insn->n;
@@ -1056,8 +1056,8 @@ int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device * dev,
| Task : Writes port value To the selected port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To Write |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To Write |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -1067,24 +1067,24 @@ int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- static UINT ui_Temp = 0;
- UINT ui_Temp1;
+ static unsigned int ui_Temp = 0;
+ unsigned int ui_Temp1;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
if (!devpriv->b_OutputMemoryStatus) {
ui_Temp = 0;
- } //if(!devpriv->b_OutputMemoryStatus )
+ } /* if(!devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outw(data[0],
devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -1113,19 +1113,19 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->i_IobaseAddon +
APCI1500_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==0)
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -1140,7 +1140,7 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
outw(data[0],
devpriv->i_IobaseAddon +
APCI1500_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -1190,48 +1190,48 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->i_IobaseAddon +
APCI1500_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
ui_Temp = data[0];
- return (insn->n);;
+ return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1500_ConfigCounterTimerWatchdog(comedi_device
- *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)|
+| *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)|
| |
+----------------------------------------------------------------------------+
| Task : Configures The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status data[0] : 2 APCI1500_1_8_KHZ
| 1 APCI1500_3_6_KHZ |
| 0 APCI1500_115_KHZ
- data[1] : 0 Counter1/Timer1
- 1 Counter2/Timer2
- 2 Counter3/Watchdog
- data[2] : 0 Counter
- 1 Timer/Watchdog
- data[3] : This parameter has |
+| data[1] : 0 Counter1/Timer1
+| 1 Counter2/Timer2
+| 2 Counter3/Watchdog
+| data[2] : 0 Counter
+| 1 Timer/Watchdog
+| data[3] : This parameter has |
| two meanings. |
| - If the counter/timer |
| is used as a counter |
@@ -1243,15 +1243,15 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| the divider factor |
| for the output is |
| given.
- data[4] : 0 APCI1500_CONTINUOUS
- 1 APCI1500_SINGLE
- data[5] : 0 Software Trigger
- 1 Hardware Trigger
-
- data[6] :0 Software gate
- 1 Hardware gate
- data[7] :0 Interrupt Disable
- 1 Interrupt Enable
+| data[4] : 0 APCI1500_CONTINUOUS
+| 1 APCI1500_SINGLE
+| data[5] : 0 Software Trigger
+| 1 Hardware Trigger
+|
+| data[6] :0 Software gate
+| 1 Hardware gate
+| data[7] :0 Interrupt Disable
+| 1 Interrupt Enable
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -1261,27 +1261,27 @@ INT i_APCI1500_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i_TimerCounterMode, i_MasterConfiguration;
devpriv->tsk_Current = current;
-//Selection of the input clock
+/* Selection of the input clock */
if (data[0] == 0 || data[0] == 1 || data[0] == 2) {
outw(data[0], devpriv->i_IobaseAddon + APCI1500_CLK_SELECT);
- } // if(data[0]==0||data[0]==1||data[0]==2)
+ } /* if(data[0]==0||data[0]==1||data[0]==2) */
else {
if (data[0] != 3) {
printk("\nThe option for input clock selection does not exist\n");
return -EINVAL;
- } // if(data[0]!=3)
- } //elseif(data[0]==0||data[0]==1||data[0]==2)
- //Select the counter/timer
+ } /* if(data[0]!=3) */
+ } /* elseif(data[0]==0||data[0]==1||data[0]==2) */
+ /* Select the counter/timer */
switch (data[1]) {
case COUNTER1:
- //selecting counter or timer
+ /* selecting counter or timer */
switch (data[2]) {
case 0:
data[2] = APCI1500_COUNTER;
@@ -1292,9 +1292,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis choice is not a timer nor a counter\n");
return -EINVAL;
- } // switch(data[2])
+ } /* switch(data[2]) */
- //Selecting single or continuous mode
+ /* Selecting single or continuous mode */
switch (data[4]) {
case 0:
data[4] = APCI1500_CONTINUOUS;
@@ -1305,7 +1305,7 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis option for single/continuous mode does not exist\n");
return -EINVAL;
- } // switch(data[4])
+ } /* switch(data[4]) */
i_TimerCounterMode = data[2] | data[4] | 7;
/*************************/
@@ -1428,21 +1428,21 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
outb(0x2,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)
+ } /* if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */
else {
printk("\nError in selection of interrupt enable or disable\n");
return -EINVAL;
- } //elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)
- } // if ((data[3]>= 0) && (data[3] <= 65535))
+ } /* elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */
+ } /* if ((data[3]>= 0) && (data[3] <= 65535)) */
else {
printk("\nError in selection of reload value\n");
return -EINVAL;
- } //else if ((data[3]>= 0) && (data[3] <= 65535))
+ } /* else if ((data[3]>= 0) && (data[3] <= 65535)) */
i_TimerCounterWatchdogInterrupt = data[7];
i_TimerCounter1Init = 1;
break;
- case COUNTER2: //selecting counter or timer
+ case COUNTER2: /* selecting counter or timer */
switch (data[2]) {
case 0:
data[2] = APCI1500_COUNTER;
@@ -1453,9 +1453,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis choice is not a timer nor a counter\n");
return -EINVAL;
- } // switch(data[2])
+ } /* switch(data[2]) */
- //Selecting single or continuous mode
+ /* Selecting single or continuous mode */
switch (data[4]) {
case 0:
data[4] = APCI1500_CONTINUOUS;
@@ -1466,9 +1466,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis option for single/continuous mode does not exist\n");
return -EINVAL;
- } // switch(data[4])
+ } /* switch(data[4]) */
- //Selecting software or hardware trigger
+ /* Selecting software or hardware trigger */
switch (data[5]) {
case 0:
data[5] = APCI1500_SOFTWARE_TRIGGER;
@@ -1479,9 +1479,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis choice for software or hardware trigger does not exist\n");
return -EINVAL;
- } // switch(data[5])
+ } /* switch(data[5]) */
- //Selecting software or hardware gate
+ /* Selecting software or hardware gate */
switch (data[6]) {
case 0:
data[6] = APCI1500_SOFTWARE_GATE;
@@ -1492,7 +1492,7 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis choice for software or hardware gate does not exist\n");
return -EINVAL;
- } // switch(data[6])
+ } /* switch(data[6]) */
i_TimerCounterMode = data[2] | data[4] | data[5] | data[6] | 7;
@@ -1616,21 +1616,21 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
outb(0x2,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)
+ } /* if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */
else {
printk("\nError in selection of interrupt enable or disable\n");
return -EINVAL;
- } //elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)
- } // if ((data[3]>= 0) && (data[3] <= 65535))
+ } /* elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */
+ } /* if ((data[3]>= 0) && (data[3] <= 65535)) */
else {
printk("\nError in selection of reload value\n");
return -EINVAL;
- } //else if ((data[3]>= 0) && (data[3] <= 65535))
+ } /* else if ((data[3]>= 0) && (data[3] <= 65535)) */
i_TimerCounterWatchdogInterrupt = data[7];
i_TimerCounter2Init = 1;
break;
- case COUNTER3: //selecting counter or watchdog
+ case COUNTER3: /* selecting counter or watchdog */
switch (data[2]) {
case 0:
data[2] = APCI1500_COUNTER;
@@ -1641,9 +1641,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis choice is not a watchdog nor a counter\n");
return -EINVAL;
- } // switch(data[2])
+ } /* switch(data[2]) */
- //Selecting single or continuous mode
+ /* Selecting single or continuous mode */
switch (data[4]) {
case 0:
data[4] = APCI1500_CONTINUOUS;
@@ -1654,9 +1654,9 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis option for single/continuous mode does not exist\n");
return -EINVAL;
- } // switch(data[4])
+ } /* switch(data[4]) */
- //Selecting software or hardware gate
+ /* Selecting software or hardware gate */
switch (data[6]) {
case 0:
data[6] = APCI1500_SOFTWARE_GATE;
@@ -1667,7 +1667,7 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
default:
printk("\nThis choice for software or hardware gate does not exist\n");
return -EINVAL;
- } // switch(data[6])
+ } /* switch(data[6]) */
/*****************************/
/* Test if used for watchdog */
@@ -1680,10 +1680,10 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
/* - Pulses output */
/*****************************/
i_TimerCounterMode = data[2] | data[4] | 0x54;
- } //if (data[2] == APCI1500_WATCHDOG)
+ } /* if (data[2] == APCI1500_WATCHDOG) */
else {
i_TimerCounterMode = data[2] | data[4] | data[6] | 7;
- } //elseif (data[2] == APCI1500_WATCHDOG)
+ } /* elseif (data[2] == APCI1500_WATCHDOG) */
/*************************/
/* Test the reload value */
/*************************/
@@ -1809,25 +1809,25 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //elseif(data[2]==APCI1500_COUNTER)
+ } /* elseif(data[2]==APCI1500_COUNTER) */
- } //if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)
+ } /* if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */
else {
printk("\nError in selection of interrupt enable or disable\n");
return -EINVAL;
- } //elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)
- } // if ((data[3]>= 0) && (data[3] <= 65535))
+ } /* elseif(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE) */
+ } /* if ((data[3]>= 0) && (data[3] <= 65535)) */
else {
printk("\nError in selection of reload value\n");
return -EINVAL;
- } //else if ((data[3]>= 0) && (data[3] <= 65535))
+ } /* else if ((data[3]>= 0) && (data[3] <= 65535)) */
i_TimerCounterWatchdogInterrupt = data[7];
i_WatchdogCounter3Init = 1;
break;
default:
printk("\nThe specified counter\timer option does not exist\n");
- } //switch(data[1])
+ } /* switch(data[1]) */
i_CounterLogic = data[2];
return insn->n;
}
@@ -1836,22 +1836,22 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1500_StartStopTriggerTimerCounterWatchdog |
| (struct comedi_device *dev,struct comedi_subdevice *s,
- struct comedi_insn *insn,unsigned int *data); |
+| struct comedi_insn *insn,unsigned int *data); |
+----------------------------------------------------------------------------+
| Task : Start / Stop or trigger the timer counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
- data[0] : 0 Counter1/Timer1
- 1 Counter2/Timer2
- 2 Counter3/Watchdog
- data[1] : 0 start
- 1 stop
- 2 Trigger
- data[2] : 0 Counter
- 1 Timer/Watchdog
+| data[0] : 0 Counter1/Timer1
+| 1 Counter2/Timer2
+| 2 Counter3/Watchdog
+| data[1] : 0 start
+| 1 stop
+| 2 Trigger
+| data[2] : 0 Counter
+| 1 Timer/Watchdog
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -1860,8 +1860,8 @@ int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i_CommandAndStatusValue;
@@ -1871,11 +1871,11 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
case START:
if (i_TimerCounter1Init == 1) {
if (i_TimerCounterWatchdogInterrupt == 1) {
- i_CommandAndStatusValue = 0xC4; //Enable the interrupt
- } // if(i_TimerCounterWatchdogInterrupt==1)
+ i_CommandAndStatusValue = 0xC4; /* Enable the interrupt */
+ } /* if(i_TimerCounterWatchdogInterrupt==1) */
else {
- i_CommandAndStatusValue = 0xE4; //disable the interrupt
- } //elseif(i_TimerCounterWatchdogInterrupt==1)
+ i_CommandAndStatusValue = 0xE4; /* disable the interrupt */
+ } /* elseif(i_TimerCounterWatchdogInterrupt==1) */
/**************************/
/* Starts timer/counter 1 */
/**************************/
@@ -1889,7 +1889,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
outb(i_CommandAndStatusValue,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_TimerCounter1Init==1)
+ } /* if( i_TimerCounter1Init==1) */
else {
printk("\nCounter/Timer1 not configured\n");
return -EINVAL;
@@ -1922,14 +1922,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
/************************/
i_CommandAndStatusValue = 0x6;
- } //if( i_TimerCounter1Enabled==1)
+ } /* if( i_TimerCounter1Enabled==1) */
else {
/***************/
/* Set Trigger */
/***************/
i_CommandAndStatusValue = 0x2;
- } //elseif(i_TimerCounter1Enabled==1)
+ } /* elseif(i_TimerCounter1Enabled==1) */
/********************************************/
/* Selects the commands and status register */
@@ -1940,7 +1940,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
outb(i_CommandAndStatusValue,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_TimerCounter1Init==1)
+ } /* if( i_TimerCounter1Init==1) */
else {
printk("\nCounter/Timer1 not configured\n");
return -EINVAL;
@@ -1950,7 +1950,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
default:
printk("\nThe specified option for start/stop/trigger does not exist\n");
return -EINVAL;
- } //switch(data[1])
+ } /* switch(data[1]) */
break;
case COUNTER2:
@@ -1958,11 +1958,11 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
case START:
if (i_TimerCounter2Init == 1) {
if (i_TimerCounterWatchdogInterrupt == 1) {
- i_CommandAndStatusValue = 0xC4; //Enable the interrupt
- } // if(i_TimerCounterWatchdogInterrupt==1)
+ i_CommandAndStatusValue = 0xC4; /* Enable the interrupt */
+ } /* if(i_TimerCounterWatchdogInterrupt==1) */
else {
- i_CommandAndStatusValue = 0xE4; //disable the interrupt
- } //elseif(i_TimerCounterWatchdogInterrupt==1)
+ i_CommandAndStatusValue = 0xE4; /* disable the interrupt */
+ } /* elseif(i_TimerCounterWatchdogInterrupt==1) */
/**************************/
/* Starts timer/counter 2 */
/**************************/
@@ -1976,7 +1976,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
outb(i_CommandAndStatusValue,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_TimerCounter2Init==1)
+ } /* if( i_TimerCounter2Init==1) */
else {
printk("\nCounter/Timer2 not configured\n");
return -EINVAL;
@@ -2008,14 +2008,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
/************************/
i_CommandAndStatusValue = 0x6;
- } //if( i_TimerCounter2Enabled==1)
+ } /* if( i_TimerCounter2Enabled==1) */
else {
/***************/
/* Set Trigger */
/***************/
i_CommandAndStatusValue = 0x2;
- } //elseif(i_TimerCounter2Enabled==1)
+ } /* elseif(i_TimerCounter2Enabled==1) */
/********************************************/
/* Selects the commands and status register */
@@ -2026,7 +2026,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
outb(i_CommandAndStatusValue,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_TimerCounter2Init==1)
+ } /* if( i_TimerCounter2Init==1) */
else {
printk("\nCounter/Timer2 not configured\n");
return -EINVAL;
@@ -2035,7 +2035,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
default:
printk("\nThe specified option for start/stop/trigger does not exist\n");
return -EINVAL;
- } //switch(data[1])
+ } /* switch(data[1]) */
break;
case COUNTER3:
switch (data[1]) {
@@ -2043,11 +2043,11 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
if (i_WatchdogCounter3Init == 1) {
if (i_TimerCounterWatchdogInterrupt == 1) {
- i_CommandAndStatusValue = 0xC4; //Enable the interrupt
- } // if(i_TimerCounterWatchdogInterrupt==1)
+ i_CommandAndStatusValue = 0xC4; /* Enable the interrupt */
+ } /* if(i_TimerCounterWatchdogInterrupt==1) */
else {
- i_CommandAndStatusValue = 0xE4; //disable the interrupt
- } //elseif(i_TimerCounterWatchdogInterrupt==1)
+ i_CommandAndStatusValue = 0xE4; /* disable the interrupt */
+ } /* elseif(i_TimerCounterWatchdogInterrupt==1) */
/**************************/
/* Starts Watchdog/counter 3 */
/**************************/
@@ -2062,7 +2062,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } // if( i_WatchdogCounter3init==1)
+ } /* if( i_WatchdogCounter3init==1) */
else {
printk("\nWatchdog/Counter3 not configured\n");
return -EINVAL;
@@ -2089,7 +2089,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
case TRIGGER:
switch (data[2]) {
- case 0: //triggering counter 3
+ case 0: /* triggering counter 3 */
if (i_WatchdogCounter3Init == 1) {
if (i_WatchdogCounter3Enabled == 1) {
/************************/
@@ -2097,14 +2097,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
/************************/
i_CommandAndStatusValue = 0x6;
- } //if( i_WatchdogCounter3Enabled==1)
+ } /* if( i_WatchdogCounter3Enabled==1) */
else {
/***************/
/* Set Trigger */
/***************/
i_CommandAndStatusValue = 0x2;
- } //elseif(i_WatchdogCounter3Enabled==1)
+ } /* elseif(i_WatchdogCounter3Enabled==1) */
/********************************************/
/* Selects the commands and status register */
@@ -2115,14 +2115,14 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
outb(i_CommandAndStatusValue,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_WatchdogCounter3Init==1)
+ } /* if( i_WatchdogCounter3Init==1) */
else {
printk("\nCounter3 not configured\n");
return -EINVAL;
}
break;
case 1:
- //triggering Watchdog 3
+ /* triggering Watchdog 3 */
if (i_WatchdogCounter3Init == 1) {
/********************************************/
@@ -2134,7 +2134,7 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
outb(0x6,
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_WatchdogCounter3Init==1)
+ } /* if( i_WatchdogCounter3Init==1) */
else {
printk("\nWatchdog 3 not configured\n");
return -EINVAL;
@@ -2143,17 +2143,17 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
default:
printk("\nWrong choice of watchdog/counter3\n");
return -EINVAL;
- } //switch(data[2])
+ } /* switch(data[2]) */
break;
default:
printk("\nThe specified option for start/stop/trigger does not exist\n");
return -EINVAL;
- } //switch(data[1])
+ } /* switch(data[1]) */
break;
default:
printk("\nThe specified choice for counter/watchdog/timer does not exist\n");
return -EINVAL;
- } //switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
@@ -2161,18 +2161,18 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1500_ReadCounterTimerWatchdog |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data); |
+| unsigned int *data); |
+----------------------------------------------------------------------------+
| Task : Read The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
- data[0] : 0 Counter1/Timer1
- 1 Counter2/Timer2
- 2 Counter3/Watchdog
-
+| data[0] : 0 Counter1/Timer1
+| 1 Counter2/Timer2
+| 2 Counter3/Watchdog
+|
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -2182,13 +2182,13 @@ int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i_CommandAndStatusValue;
switch (data[0]) {
case COUNTER1:
- //Read counter/timer1
+ /* Read counter/timer1 */
if (i_TimerCounter1Init == 1) {
if (i_TimerCounter1Enabled == 1) {
/************************/
@@ -2196,14 +2196,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
/************************/
i_CommandAndStatusValue = 0xC;
- } //if( i_TimerCounter1Init==1)
+ } /* if( i_TimerCounter1Init==1) */
else {
/***************/
/* Set RCC */
/***************/
i_CommandAndStatusValue = 0x8;
- } //elseif(i_TimerCounter1Init==1)
+ } /* elseif(i_TimerCounter1Init==1) */
/********************************************/
/* Selects the commands and status register */
@@ -2232,14 +2232,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
data[0] =
data[0] | inb(devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_TimerCounter1Init==1)
+ } /* if( i_TimerCounter1Init==1) */
else {
printk("\nTimer/Counter1 not configured\n");
return -EINVAL;
- } //elseif( i_TimerCounter1Init==1)
+ } /* elseif( i_TimerCounter1Init==1) */
break;
case COUNTER2:
- //Read counter/timer2
+ /* Read counter/timer2 */
if (i_TimerCounter2Init == 1) {
if (i_TimerCounter2Enabled == 1) {
/************************/
@@ -2247,14 +2247,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
/************************/
i_CommandAndStatusValue = 0xC;
- } //if( i_TimerCounter2Init==1)
+ } /* if( i_TimerCounter2Init==1) */
else {
/***************/
/* Set RCC */
/***************/
i_CommandAndStatusValue = 0x8;
- } //elseif(i_TimerCounter2Init==1)
+ } /* elseif(i_TimerCounter2Init==1) */
/********************************************/
/* Selects the commands and status register */
@@ -2283,14 +2283,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
data[0] =
data[0] | inb(devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_TimerCounter2Init==1)
+ } /* if( i_TimerCounter2Init==1) */
else {
printk("\nTimer/Counter2 not configured\n");
return -EINVAL;
- } //elseif( i_TimerCounter2Init==1)
+ } /* elseif( i_TimerCounter2Init==1) */
break;
case COUNTER3:
- //Read counter/watchdog2
+ /* Read counter/watchdog2 */
if (i_WatchdogCounter3Init == 1) {
if (i_WatchdogCounter3Enabled == 1) {
/************************/
@@ -2298,14 +2298,14 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
/************************/
i_CommandAndStatusValue = 0xC;
- } //if( i_TimerCounter2Init==1)
+ } /* if( i_TimerCounter2Init==1) */
else {
/***************/
/* Set RCC */
/***************/
i_CommandAndStatusValue = 0x8;
- } //elseif(i_WatchdogCounter3Init==1)
+ } /* elseif(i_WatchdogCounter3Init==1) */
/********************************************/
/* Selects the commands and status register */
@@ -2334,16 +2334,16 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
data[0] =
data[0] | inb(devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
- } //if( i_WatchdogCounter3Init==1)
+ } /* if( i_WatchdogCounter3Init==1) */
else {
printk("\nWatchdogCounter3 not configured\n");
return -EINVAL;
- } //elseif( i_WatchdogCounter3Init==1)
+ } /* elseif( i_WatchdogCounter3Init==1) */
break;
default:
printk("\nThe choice of timer/counter/watchdog does not exist\n");
return -EINVAL;
- } //switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
@@ -2352,13 +2352,13 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1500_ReadInterruptMask |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data); |
+| unsigned int *data); |
+----------------------------------------------------------------------------+
| Task : Read the interrupt mask |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
@@ -2370,8 +2370,8 @@ int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_ReadInterruptMask(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ReadInterruptMask(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = i_InterruptMask;
data[1] = i_InputChannel;
@@ -2383,15 +2383,15 @@ int i_APCI1500_ReadInterruptMask(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1500_ConfigureInterrupt |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data); |
+| unsigned int *data); |
+----------------------------------------------------------------------------+
| Task : Configures the interrupt registers |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer |
-
+|
+----------------------------------------------------------------------------+
| Output Parameters : --
@@ -2401,26 +2401,26 @@ int i_APCI1500_ReadInterruptMask(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI1500_ConfigureInterrupt(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1500_ConfigureInterrupt(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Status;
+ unsigned int ui_Status;
int i_RegValue;
int i_Constant;
devpriv->tsk_Current = current;
outl(0x0, devpriv->i_IobaseAmcc + 0x38);
if (data[0] == 1) {
i_Constant = 0xC0;
- } //if(data[0]==1)
+ } /* if(data[0]==1) */
else {
if (data[0] == 0) {
i_Constant = 0x00;
- } //if{data[0]==0)
+ } /* if{data[0]==0) */
else {
printk("\nThe parameter passed to driver is in error for enabling the voltage interrupt\n");
return -EINVAL;
- } //else if(data[0]==0)
- } //elseif(data[0]==1)
+ } /* else if(data[0]==0) */
+ } /* elseif(data[0]==1) */
/*****************************************************/
/* Selects the mode specification register of port B */
@@ -2580,7 +2580,7 @@ static void v_APCI1500_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- UINT ui_InterruptStatus = 0;
+ unsigned int ui_InterruptStatus = 0;
int i_RegValue = 0;
i_InterruptMask = 0;
@@ -2599,11 +2599,11 @@ static void v_APCI1500_Interrupt(int irq, void *d)
/*************************************************/
/* Selects the master interrupt control register */
/*************************************************/
- //outb(APCI1500_RW_MASTER_INTERRUPT_CONTROL,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);
+ /* outb(APCI1500_RW_MASTER_INTERRUPT_CONTROL,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER); */
/**********************************************/
/* Disables the main interrupt on the board */
/**********************************************/
- //outb(0x00,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);
+ /* outb(0x00,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER); */
/*****************************************************/
/* Selects the command and status register of port A */
@@ -2647,11 +2647,11 @@ static void v_APCI1500_Interrupt(int irq, void *d)
i_InputChannel = 1 + (i_RegValue >> 1);
- } // if(i_Logic==APCI1500_OR_PRIORITY)
+ } /* if(i_Logic==APCI1500_OR_PRIORITY) */
else {
i_InputChannel = 0;
- } //elseif(i_Logic==APCI1500_OR_PRIORITY)
- } // if ((i_RegValue & 0x60) == 0x60)
+ } /* elseif(i_Logic==APCI1500_OR_PRIORITY) */
+ } /* if ((i_RegValue & 0x60) == 0x60) */
/*****************************************************/
/* Selects the command and status register of port B */
@@ -2679,7 +2679,7 @@ static void v_APCI1500_Interrupt(int irq, void *d)
/* Reads port B */
/****************/
i_RegValue =
- inb((UINT) devpriv->iobase +
+ inb((unsigned int) devpriv->iobase +
APCI1500_Z8536_PORT_B);
i_RegValue = i_RegValue & 0xC0;
@@ -2688,7 +2688,7 @@ static void v_APCI1500_Interrupt(int irq, void *d)
/**************************************/
if (i_RegValue) {
- //Disable the interrupt
+ /* Disable the interrupt */
/*****************************************************/
/* Selects the command and status register of port B */
/*****************************************************/
@@ -2697,17 +2697,17 @@ static void v_APCI1500_Interrupt(int irq, void *d)
if (i_RegValue & 0x80) {
i_InterruptMask =
i_InterruptMask | 0x40;
- } //if (i_RegValue & 0x80)
+ } /* if (i_RegValue & 0x80) */
if (i_RegValue & 0x40) {
i_InterruptMask =
i_InterruptMask | 0x80;
- } //if (i_RegValue & 0x40)
- } // if (i_RegValue)
+ } /* if (i_RegValue & 0x40) */
+ } /* if (i_RegValue) */
else {
i_InterruptMask = i_InterruptMask | 2;
- } // if (i_RegValue)
- } //if ((i_RegValue & 0x60) == 0x60)
+ } /* if (i_RegValue) */
+ } /* if ((i_RegValue & 0x60) == 0x60) */
/*****************************************************/
/* Selects the command and status register of timer 1 */
@@ -2731,7 +2731,7 @@ static void v_APCI1500_Interrupt(int irq, void *d)
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
i_InterruptMask = i_InterruptMask | 4;
- } // if ((i_RegValue & 0x60) == 0x60)
+ } /* if ((i_RegValue & 0x60) == 0x60) */
/*****************************************************/
/* Selects the command and status register of timer 2 */
/*****************************************************/
@@ -2754,7 +2754,7 @@ static void v_APCI1500_Interrupt(int irq, void *d)
devpriv->iobase +
APCI1500_Z8536_CONTROL_REGISTER);
i_InterruptMask = i_InterruptMask | 8;
- } // if ((i_RegValue & 0x60) == 0x60)
+ } /* if ((i_RegValue & 0x60) == 0x60) */
/*****************************************************/
/* Selects the command and status register of timer 3 */
@@ -2779,13 +2779,13 @@ static void v_APCI1500_Interrupt(int irq, void *d)
APCI1500_Z8536_CONTROL_REGISTER);
if (i_CounterLogic == APCI1500_COUNTER) {
i_InterruptMask = i_InterruptMask | 0x10;
- } //if(i_CounterLogic==APCI1500_COUNTER)
+ } /* if(i_CounterLogic==APCI1500_COUNTER) */
else {
i_InterruptMask = i_InterruptMask | 0x20;
}
- } // if ((i_RegValue & 0x60) == 0x60)
+ } /* if ((i_RegValue & 0x60) == 0x60) */
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
/***********************/
/* Enable all Interrupts */
/***********************/
@@ -2799,11 +2799,11 @@ static void v_APCI1500_Interrupt(int irq, void *d)
/* Authorizes the main interrupt on the board */
/**********************************************/
outb(0xD0, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER);
- } // if ((ui_InterruptStatus & 0x800000) == 0x800000)
+ } /* if ((ui_InterruptStatus & 0x800000) == 0x800000) */
else {
printk("\nInterrupt from unknown source\n");
- } //else if ((ui_InterruptStatus & 0x800000) == 0x800000)
+ } /* else if ((ui_InterruptStatus & 0x800000) == 0x800000) */
return;
}
@@ -2822,7 +2822,7 @@ static void v_APCI1500_Interrupt(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1500_Reset(struct comedi_device * dev)
+int i_APCI1500_Reset(struct comedi_device *dev)
{
int i_DummyRead = 0;
i_TimerCounter1Init = 0;
@@ -2982,7 +2982,7 @@ INT i_APCI1500_Reset(struct comedi_device * dev)
devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER);
/* Deletes all interrupts */
outb(0, devpriv->iobase + APCI1500_Z8536_CONTROL_REGISTER);
- //reset all the digital outputs
+ /* reset all the digital outputs */
outw(0x0, devpriv->i_IobaseAddon + APCI1500_DIGITAL_OP);
/*******************************/
/* Disable the board interrupt */
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h
index 5d960b40a6a8..057903366a80 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h
@@ -17,11 +17,11 @@
/********* Definitions for APCI-1500 card *****/
-// Card Specific information
+/* Card Specific information */
#define APCI1500_BOARD_VENDOR_ID 0x10e8
#define APCI1500_ADDRESS_RANGE 4
-//DIGITAL INPUT-OUTPUT DEFINE
+/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI1500_DIGITAL_OP 2
#define APCI1500_DIGITAL_IP 0
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c
index 5ae9a93844e7..38416356628d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -63,7 +63,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -73,22 +73,22 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1516_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_TmpValue = 0;
- UINT ui_Channel;
+ unsigned int ui_TmpValue = 0;
+ unsigned int ui_Channel;
ui_Channel = CR_CHAN(insn->chanspec);
if (ui_Channel >= 0 && ui_Channel <= 7) {
- ui_TmpValue = (UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP);
- // since only 1 channel reqd to bring it to last bit it is rotated
- // 8 +(chan - 1) times then ANDed with 1 for last bit.
+ ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP);
+ /* since only 1 channel reqd to bring it to last bit it is rotated */
+ /* 8 +(chan - 1) times then ANDed with 1 for last bit. */
*data = (ui_TmpValue >> ui_Channel) & 0x1;
- } //if(ui_Channel >= 0 && ui_Channel <=7)
+ } /* if(ui_Channel >= 0 && ui_Channel <=7) */
else {
- //comedi_error(dev," \n chan spec wrong\n");
- return -EINVAL; // "sorry channel spec wrong "
- } //else if(ui_Channel >= 0 && ui_Channel <=7)
+ /* comedi_error(dev," \n chan spec wrong\n"); */
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* else if(ui_Channel >= 0 && ui_Channel <=7) */
return insn->n;
}
@@ -103,7 +103,7 @@ INT i_APCI1516_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -114,17 +114,17 @@ INT i_APCI1516_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
*/
-INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_PortValue = data[0];
- UINT ui_Mask = 0;
- UINT ui_NoOfChannels;
+ unsigned int ui_PortValue = data[0];
+ unsigned int ui_Mask = 0;
+ unsigned int ui_NoOfChannels;
ui_NoOfChannels = CR_CHAN(insn->chanspec);
- *data = (UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP);
+ *data = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP);
switch (ui_NoOfChannels) {
case 2:
ui_Mask = 3;
@@ -139,9 +139,9 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
default:
printk("\nWrong parameters\n");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
return insn->n;
}
@@ -149,7 +149,7 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1516_ConfigDigitalOutput (struct comedi_device *dev,
- struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) |
+| struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Configures The Digital Output Subdevice. |
@@ -158,7 +158,7 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| data[0] :1:Memory on |
| 0:Memory off |
| |
@@ -171,8 +171,8 @@ INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI1516_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
devpriv->b_OutputMemoryStatus = data[0];
return insn->n;
@@ -182,13 +182,13 @@ int i_APCI1516_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1516_WriteDigitalOutput |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data) |
+| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Writes port value To the selected port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -199,21 +199,21 @@ int i_APCI1516_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
*/
-INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp, ui_Temp1;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp, ui_Temp1;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
printk("EL311003 : @=%x\n", devpriv->iobase + APCI1516_DIGITAL_OP);
if (devpriv->b_OutputMemoryStatus) {
ui_Temp = inw(devpriv->iobase + APCI1516_DIGITAL_OP);
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
@@ -222,7 +222,7 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
printk("EL311003 : d=%d @=%x\n", data[0],
devpriv->iobase + APCI1516_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -245,21 +245,21 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->iobase + APCI1516_DIGITAL_OP);
printk("EL311003 : d=%d @=%x\n", data[0],
devpriv->iobase + APCI1516_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==0)
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -275,7 +275,7 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
printk("EL311003 : d=%d @=%x\n", data[0],
devpriv->iobase + APCI1516_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -312,9 +312,9 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->iobase +
@@ -324,17 +324,17 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
data[0],
devpriv->iobase +
APCI1516_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
return (insn->n);;
}
@@ -342,13 +342,13 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1516_ReadDigitalOutput |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data) |
+| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -359,17 +359,17 @@ INT i_APCI1516_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
*/
-INT i_APCI1516_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
ui_Temp = data[0];
*data = inw(devpriv->iobase + APCI1516_DIGITAL_OP_RW);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } //if(ui_Temp==0)
+ } /* if(ui_Temp==0) */
else {
if (ui_Temp == 1) {
switch (ui_NoOfChannel) {
@@ -387,28 +387,28 @@ INT i_APCI1516_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
- } //if(ui_Temp==1)
+ } /* switch(ui_NoOfChannels) */
+ } /* if(ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } //elseif(ui_Temp==1)
- } //elseif(ui_Temp==0)
+ } /* elseif(ui_Temp==1) */
+ } /* elseif(ui_Temp==0) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI1516_ConfigWatchdog(struct comedi_device *dev,
- struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
+| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Configures The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -419,15 +419,15 @@ INT i_APCI1516_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
*/
-int i_APCI1516_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0] == 0) {
- //Disable the watchdog
+ /* Disable the watchdog */
outw(0x0,
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_ENABLEDISABLE);
- //Loading the Reload value
+ /* Loading the Reload value */
outw(data[1],
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_RELOAD_VALUE);
@@ -435,11 +435,11 @@ int i_APCI1516_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic
outw(data[1],
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_RELOAD_VALUE + 2);
- } //if(data[0]==0)
+ } /* if(data[0]==0) */
else {
printk("\nThe input parameters are wrong\n");
return -EINVAL;
- } //elseif(data[0]==0)
+ } /* elseif(data[0]==0) */
return insn->n;
}
@@ -465,19 +465,19 @@ int i_APCI1516_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-int i_APCI1516_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
- case 0: //stop the watchdog
- outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); //disable the watchdog
+ case 0: /* stop the watchdog */
+ outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */
break;
- case 1: //start the watchdog
+ case 1: /* start the watchdog */
outw(0x0001,
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_ENABLEDISABLE);
break;
- case 2: //Software trigger
+ case 2: /* Software trigger */
outw(0x0201,
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_ENABLEDISABLE);
@@ -485,7 +485,7 @@ int i_APCI1516_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
default:
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } // switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
@@ -510,8 +510,8 @@ int i_APCI1516_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
*/
-int i_APCI1516_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1516_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = inw(devpriv->i_IobaseAddon + APCI1516_WATCHDOG_STATUS) & 0x1;
return insn->n;
@@ -532,9 +532,9 @@ int i_APCI1516_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice
+----------------------------------------------------------------------------+
*/
-INT i_APCI1516_Reset(struct comedi_device * dev)
+int i_APCI1516_Reset(struct comedi_device *dev)
{
- outw(0x0, devpriv->iobase + APCI1516_DIGITAL_OP); //RESETS THE DIGITAL OUTPUTS
+ outw(0x0, devpriv->iobase + APCI1516_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE + 2);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h
index 398baa04a163..21c09ed01b1d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h
@@ -17,17 +17,17 @@
/********* Definitions for APCI-1516 card *****/
-// Card Specific information
+/* Card Specific information */
#define APCI1516_BOARD_VENDOR_ID 0x15B8
#define APCI1516_ADDRESS_RANGE 8
-//DIGITAL INPUT-OUTPUT DEFINE
+/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI1516_DIGITAL_OP 4
#define APCI1516_DIGITAL_OP_RW 4
#define APCI1516_DIGITAL_IP 0
-// TIMER COUNTER WATCHDOG DEFINES
+/* TIMER COUNTER WATCHDOG DEFINES */
#define ADDIDATA_WATCHDOG 2
#define APCI1516_DIGITAL_OP_WATCHDOG 0
@@ -35,24 +35,25 @@
#define APCI1516_WATCHDOG_RELOAD_VALUE 4
#define APCI1516_WATCHDOG_STATUS 16
-// Hardware Layer functions for Apci1516
+/* Hardware Layer functions for Apci1516 */
-//Digital Input
-INT i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+/* Digital Input */
+int i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//Digital Output
+/* Digital Output */
int i_APCI1516_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// TIMER
-// timer value is passed as u seconds
+/*
+* TIMER timer value is passed as u seconds
+*/
int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -60,5 +61,5 @@ int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_s
int i_APCI1516_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//reset
-INT i_APCI1516_Reset(struct comedi_device *dev);
+/* reset */
+int i_APCI1516_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index a6b504c3d391..3a47c3034229 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -55,9 +55,9 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
#include <linux/delay.h>
#include "hwdrv_apci1564.h"
-//Global variables
-UINT ui_InterruptStatus_1564 = 0;
-UINT ui_InterruptData, ui_Type;
+/* Global variables */
+unsigned int ui_InterruptStatus_1564 = 0;
+unsigned int ui_InterruptData, ui_Type;
/*
+----------------------------------------------------------------------------+
@@ -86,8 +86,8 @@ UINT ui_InterruptData, ui_Type;
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
devpriv->tsk_Current = current;
/*******************************/
@@ -106,13 +106,13 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
outl(0x4,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
APCI1564_DIGITAL_IP_IRQ);
- } // if (data[1] == ADDIDATA_OR)
+ } /* if (data[1] == ADDIDATA_OR) */
else {
outl(0x6,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
APCI1564_DIGITAL_IP_IRQ);
- } // else if (data[1] == ADDIDATA_OR)
- } // if (data[0] == ADDIDATA_ENABLE)
+ } /* else if (data[1] == ADDIDATA_OR) */
+ } /* if (data[0] == ADDIDATA_ENABLE) */
else {
outl(0x0,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
@@ -123,7 +123,7 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
outl(0x0,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
APCI1564_DIGITAL_IP_IRQ);
- } // else if (data[0] == ADDIDATA_ENABLE)
+ } /* else if (data[0] == ADDIDATA_ENABLE) */
return insn->n;
}
@@ -137,7 +137,7 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
| Task : Return the status of the digital input |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_Channel : Channel number to read |
+| unsigned int ui_Channel : Channel number to read |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -147,24 +147,26 @@ INT i_APCI1564_ConfigDigitalInput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_TmpValue = 0;
- UINT ui_Channel;
+ unsigned int ui_TmpValue = 0;
+ unsigned int ui_Channel;
ui_Channel = CR_CHAN(insn->chanspec);
if (ui_Channel >= 0 && ui_Channel <= 31) {
ui_TmpValue =
- (UINT) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP);
- // since only 1 channel reqd to bring it to last bit it is rotated
- // 8 +(chan - 1) times then ANDed with 1 for last bit.
+ (unsigned int) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP);
+/*
+* since only 1 channel reqd to bring it to last bit it is rotated 8
+* +(chan - 1) times then ANDed with 1 for last bit.
+*/
*data = (ui_TmpValue >> ui_Channel) & 0x1;
- } // if (ui_Channel >= 0 && ui_Channel <=31)
+ } /* if (ui_Channel >= 0 && ui_Channel <=31) */
else {
comedi_error(dev, "Not a valid channel number !!! \n");
- return -EINVAL; // "sorry channel spec wrong "
- } //else if (ui_Channel >= 0 && ui_Channel <=31)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* else if (ui_Channel >= 0 && ui_Channel <=31) */
return insn->n;
}
@@ -177,8 +179,8 @@ INT i_APCI1564_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
| Task : Return the status of the Requested digital inputs |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To be Read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To be Read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -187,16 +189,16 @@ INT i_APCI1564_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_PortValue = data[0];
- UINT ui_Mask = 0;
- UINT ui_NoOfChannels;
+ unsigned int ui_PortValue = data[0];
+ unsigned int ui_Mask = 0;
+ unsigned int ui_NoOfChannels;
ui_NoOfChannels = CR_CHAN(insn->chanspec);
if (data[1] == 0) {
- *data = (UINT) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP);
+ *data = (unsigned int) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP);
switch (ui_NoOfChannels) {
case 2:
ui_Mask = 3;
@@ -218,15 +220,15 @@ INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
break;
default:
comedi_error(dev, "Not a valid Channel number !!!\n");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } // switch (ui_NoOfChannels)
- } // if (data[1]==0)
+ } /* switch (ui_NoOfChannels) */
+ } /* if (data[1]==0) */
else {
if (data[1] == 1) {
*data = ui_InterruptStatus_1564;
- } // if (data[1]==1)
- } // else if (data[1]==0)
+ } /* if (data[1]==1) */
+ } /* else if (data[1]==0) */
return insn->n;
}
@@ -239,7 +241,7 @@ INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| Task : Configures The Digital Output Subdevice. |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[1] : 1 Enable VCC Interrupt |
@@ -255,34 +257,34 @@ INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command = 0;
+ unsigned int ul_Command = 0;
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
"Not a valid Data !!! ,Data should be 1 or 0\n");
return -EINVAL;
- } // if ((data[0]!=0) && (data[0]!=1))
+ } /* if ((data[0]!=0) && (data[0]!=1)) */
if (data[0]) {
devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE;
- } // if (data[0])
+ } /* if (data[0]) */
else {
devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
- } // else if (data[0])
+ } /* else if (data[0]) */
if (data[1] == ADDIDATA_ENABLE) {
ul_Command = ul_Command | 0x1;
- } // if (data[1] == ADDIDATA_ENABLE)
+ } /* if (data[1] == ADDIDATA_ENABLE) */
else {
ul_Command = ul_Command & 0xFFFFFFFE;
- } // else if (data[1] == ADDIDATA_ENABLE)
+ } /* else if (data[1] == ADDIDATA_ENABLE) */
if (data[2] == ADDIDATA_ENABLE) {
ul_Command = ul_Command | 0x2;
- } // if (data[2] == ADDIDATA_ENABLE)
+ } /* if (data[2] == ADDIDATA_ENABLE) */
else {
ul_Command = ul_Command & 0xFFFFFFFD;
- } // else if (data[2] == ADDIDATA_ENABLE)
+ } /* else if (data[2] == ADDIDATA_ENABLE) */
outl(ul_Command,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_INTERRUPT);
@@ -302,8 +304,8 @@ INT i_APCI1564_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| Task : Writes port value To the selected port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To Write |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To Write |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -312,28 +314,28 @@ INT i_APCI1564_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp, ui_Temp1;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp, ui_Temp1;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
if (devpriv->b_OutputMemoryStatus) {
ui_Temp =
inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
- } // if (devpriv->b_OutputMemoryStatus )
+ } /* if (devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } // else if (devpriv->b_OutputMemoryStatus )
+ } /* else if (devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outl(data[0],
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
- } // if (data[1]==0)
+ } /* if (data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -362,18 +364,18 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
break;
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
- } // switch (ui_NoOfChannels)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* switch (ui_NoOfChannels) */
outl(data[0],
devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
- } // if (data[1]==1)
+ } /* if (data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } // else if (data[1]==1)
- } // else if (data[1]==0)
- } //if(data[3]==0)
+ } /* else if (data[1]==1) */
+ } /* else if (data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -389,7 +391,7 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
- } // if (data[1]==0)
+ } /* if (data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -447,23 +449,23 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
- } //switch(ui_NoOfChannels)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* switch(ui_NoOfChannels) */
outl(data[0],
devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
- } // if (data[1]==1)
+ } /* if (data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } // else if (data[1]==1)
- } // else if (data[1]==0)
- } // if (data[3]==1);
+ } /* else if (data[1]==1) */
+ } /* else if (data[1]==0) */
+ } /* if (data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } // else if (data[3]==1)
- } // else if (data[3]==0)
+ } /* else if (data[3]==1) */
+ } /* else if (data[3]==0) */
return insn->n;
}
@@ -476,8 +478,8 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -486,11 +488,11 @@ INT i_APCI1564_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
ui_Temp = data[0];
@@ -498,7 +500,7 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
APCI1564_DIGITAL_OP_RW);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } // if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
switch (ui_NoOfChannel) {
@@ -523,14 +525,14 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } // switch(ui_NoOfChannels)
- } // if (ui_Temp==1)
+ } /* switch(ui_NoOfChannels) */
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } // else if (ui_Temp==1)
- } // else if (ui_Temp==0)
+ } /* else if (ui_Temp==1) */
+ } /* else if (ui_Temp==0) */
return insn->n;
}
@@ -543,7 +545,7 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
| Task : Configures The Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 Configure As Timer |
@@ -564,34 +566,34 @@ INT i_APCI1564_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command1 = 0;
+ unsigned int ul_Command1 = 0;
devpriv->tsk_Current = current;
if (data[0] == ADDIDATA_WATCHDOG) {
devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;
- //Disable the watchdog
+ /* Disable the watchdog */
outl(0x0,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG +
APCI1564_TCW_PROG);
- //Loading the Reload value
+ /* Loading the Reload value */
outl(data[3],
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG +
APCI1564_TCW_RELOAD_VALUE);
- } // if (data[0]==ADDIDATA_WATCHDOG)
+ } /* if (data[0]==ADDIDATA_WATCHDOG) */
else if (data[0] == ADDIDATA_TIMER) {
- //First Stop The Timer
+ /* First Stop The Timer */
ul_Command1 =
inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
APCI1564_TCW_PROG);
ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
- outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //Stop The Timer
+ outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* Stop The Timer */
devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
if (data[1] == 1) {
- outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //Enable TIMER int & DISABLE ALL THE OTHER int SOURCES
+ outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
outl(0x0,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
APCI1564_DIGITAL_IP_IRQ);
@@ -614,18 +616,18 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
outl(0x0,
devpriv->iobase + APCI1564_COUNTER4 +
APCI1564_TCW_IRQ);
- } // if (data[1]==1)
+ } /* if (data[1]==1) */
else {
- outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //disable Timer interrupt
- } // else if (data[1]==1)
+ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* disable Timer interrupt */
+ } /* else if (data[1]==1) */
- // Loading Timebase
+ /* Loading Timebase */
outl(data[2],
devpriv->i_IobaseAmcc + APCI1564_TIMER +
APCI1564_TCW_TIMEBASE);
- //Loading the Reload value
+ /* Loading the Reload value */
outl(data[3],
devpriv->i_IobaseAmcc + APCI1564_TIMER +
APCI1564_TCW_RELOAD_VALUE);
@@ -635,18 +637,18 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
APCI1564_TCW_PROG);
ul_Command1 =
(ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL;
- outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); //mode 2
- } // else if (data[0]==ADDIDATA_TIMER)
+ outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* mode 2 */
+ } /* else if (data[0]==ADDIDATA_TIMER) */
else if (data[0] == ADDIDATA_COUNTER) {
devpriv->b_TimerSelectMode = ADDIDATA_COUNTER;
devpriv->b_ModeSelectRegister = data[5];
- //First Stop The Counter
+ /* First Stop The Counter */
ul_Command1 =
inl(devpriv->iobase + ((data[5] - 1) * 0x20) +
APCI1564_TCW_PROG);
ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
- outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); //Stop The Timer
+ outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); /* Stop The Timer */
/************************/
/* Set the reload value */
@@ -666,12 +668,12 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
/******************************/
ul_Command1 =
(ul_Command1 & 0xFFFC19E2UL) | 0x80000UL |
- (ULONG) ((ULONG) data[4] << 16UL);
+ (unsigned int) ((unsigned int) data[4] << 16UL);
outl(ul_Command1,
devpriv->iobase + ((data[5] - 1) * 0x20) +
APCI1564_TCW_PROG);
- // Enable or Disable Interrupt
+ /* Enable or Disable Interrupt */
ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1);
outl(ul_Command1,
devpriv->iobase + ((data[5] - 1) * 0x20) +
@@ -684,10 +686,10 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
outl(ul_Command1,
devpriv->iobase + ((data[5] - 1) * 0x20) +
APCI1564_TCW_PROG);
- } // else if (data[0]==ADDIDATA_COUNTER)
+ } /* else if (data[0]==ADDIDATA_COUNTER) */
else {
printk(" Invalid subdevice.");
- } // else if (data[0]==ADDIDATA_WATCHDOG)
+ } /* else if (data[0]==ADDIDATA_WATCHDOG) */
return insn->n;
}
@@ -701,7 +703,7 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
| Task : Start / Stop The Selected Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 Timer |
@@ -718,22 +720,22 @@ INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command1 = 0;
+ unsigned int ul_Command1 = 0;
if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
switch (data[1]) {
- case 0: //stop the watchdog
- outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG); //disable the watchdog
+ case 0: /* stop the watchdog */
+ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_PROG); /* disable the watchdog */
break;
- case 1: //start the watchdog
+ case 1: /* start the watchdog */
outl(0x0001,
devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP_WATCHDOG +
APCI1564_TCW_PROG);
break;
- case 2: //Software trigger
+ case 2: /* Software trigger */
outl(0x0201,
devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP_WATCHDOG +
@@ -742,8 +744,8 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
default:
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } // switch (data[1])
- } // if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
+ } /* switch (data[1]) */
+ } /* if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */
if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
if (data[1] == 1) {
ul_Command1 =
@@ -751,13 +753,13 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
APCI1564_TCW_PROG);
ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
- //Enable the Timer
+ /* Enable the Timer */
outl(ul_Command1,
devpriv->i_IobaseAmcc + APCI1564_TIMER +
APCI1564_TCW_PROG);
- } // if (data[1]==1)
+ } /* if (data[1]==1) */
else if (data[1] == 0) {
- //Stop The Timer
+ /* Stop The Timer */
ul_Command1 =
inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
@@ -766,29 +768,29 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
outl(ul_Command1,
devpriv->i_IobaseAmcc + APCI1564_TIMER +
APCI1564_TCW_PROG);
- } // else if(data[1]==0)
- } // if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
+ } /* else if(data[1]==0) */
+ } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) {
ul_Command1 =
inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister -
1) * 0x20) + APCI1564_TCW_PROG);
if (data[1] == 1) {
- //Start the Counter subdevice
+ /* Start the Counter subdevice */
ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
- } // if (data[1] == 1)
+ } /* if (data[1] == 1) */
else if (data[1] == 0) {
- // Stops the Counter subdevice
+ /* Stops the Counter subdevice */
ul_Command1 = 0;
- } // else if (data[1] == 0)
+ } /* else if (data[1] == 0) */
else if (data[1] == 2) {
- // Clears the Counter subdevice
+ /* Clears the Counter subdevice */
ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400;
- } // else if (data[1] == 3)
+ } /* else if (data[1] == 3) */
outl(ul_Command1,
devpriv->iobase + ((devpriv->b_ModeSelectRegister -
1) * 0x20) + APCI1564_TCW_PROG);
- } // if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER)
+ } /* if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) */
return insn->n;
}
@@ -801,7 +803,7 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
| Task : Read The Selected Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
@@ -813,13 +815,13 @@ INT i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command1 = 0;
+ unsigned int ul_Command1 = 0;
if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
- // Stores the status of the Watchdog
+ /* Stores the status of the Watchdog */
data[0] =
inl(devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP_WATCHDOG +
@@ -827,18 +829,18 @@ INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev,
data[1] =
inl(devpriv->i_IobaseAmcc +
APCI1564_DIGITAL_OP_WATCHDOG);
- } // if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
+ } /* if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */
else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
- // Stores the status of the Timer
+ /* Stores the status of the Timer */
data[0] =
inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
APCI1564_TCW_TRIG_STATUS) & 0x1;
- // Stores the Actual value of the Timer
+ /* Stores the Actual value of the Timer */
data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER);
- } // else if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
+ } /* else if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) {
- // Read the Counter Actual Value.
+ /* Read the Counter Actual Value. */
data[0] =
inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister -
1) * 0x20) +
@@ -850,28 +852,28 @@ INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev,
/***********************************/
/* Get the software trigger status */
/***********************************/
- data[1] = (BYTE) ((ul_Command1 >> 1) & 1);
+ data[1] = (unsigned char) ((ul_Command1 >> 1) & 1);
/***********************************/
/* Get the hardware trigger status */
/***********************************/
- data[2] = (BYTE) ((ul_Command1 >> 2) & 1);
+ data[2] = (unsigned char) ((ul_Command1 >> 2) & 1);
/*********************************/
/* Get the software clear status */
/*********************************/
- data[3] = (BYTE) ((ul_Command1 >> 3) & 1);
+ data[3] = (unsigned char) ((ul_Command1 >> 3) & 1);
/***************************/
/* Get the overflow status */
/***************************/
- data[4] = (BYTE) ((ul_Command1 >> 0) & 1);
- } // else if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER)
+ data[4] = (unsigned char) ((ul_Command1 >> 0) & 1);
+ } /* else if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) */
else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER)
&& (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG)
&& (devpriv->b_TimerSelectMode != ADDIDATA_COUNTER)) {
printk("\n Invalid Subdevice !!!\n");
- } // else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER))
+ } /* else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER)) */
return insn->n;
}
@@ -892,8 +894,8 @@ INT i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI1564_ReadInterruptStatus(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI1564_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
*data = ui_Type;
return insn->n;
@@ -919,10 +921,10 @@ int i_APCI1564_ReadInterruptStatus(struct comedi_device * dev, struct comedi_sub
static void v_APCI1564_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- UINT ui_DO, ui_DI;
- UINT ui_Timer;
- UINT ui_C1, ui_C2, ui_C3, ui_C4;
- ULONG ul_Command2 = 0;
+ unsigned int ui_DO, ui_DI;
+ unsigned int ui_Timer;
+ unsigned int ui_C1, ui_C2, ui_C3, ui_C4;
+ unsigned int ul_Command2 = 0;
ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
APCI1564_DIGITAL_IP_IRQ) & 0x01;
ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
@@ -941,7 +943,7 @@ static void v_APCI1564_Interrupt(int irq, void *d)
if (ui_DI == 0 && ui_DO == 0 && ui_Timer == 0 && ui_C1 == 0
&& ui_C2 == 0 && ui_C3 == 0 && ui_C4 == 0) {
printk("\nInterrupt from unknown source\n");
- } // if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0)
+ } /* if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0) */
if (ui_DI == 1) {
ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
@@ -953,116 +955,137 @@ static void v_APCI1564_Interrupt(int irq, void *d)
inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
APCI1564_DIGITAL_IP_INTERRUPT_STATUS);
ui_InterruptStatus_1564 = ui_InterruptStatus_1564 & 0X000FFFF0;
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
- outl(ui_DI, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); //enable the interrupt
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
+ outl(ui_DI, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); /* enable the interrupt */
return;
}
if (ui_DO == 1) {
- // Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt.
+ /* Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. */
ui_Type =
inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_INTERRUPT_STATUS) & 0x3;
- //Disable the Interrupt
+ /* Disable the Interrupt */
outl(0x0,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_INTERRUPT);
- //Sends signal to user space
+ /* Sends signal to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
- } // if (ui_DO)
+ } /* if (ui_DO) */
- if ((ui_Timer == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_TIMER)) {
- // Disable Timer Interrupt
- ul_Command2 =
- inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
- APCI1564_TCW_PROG);
- outl(0x0,
- devpriv->i_IobaseAmcc + APCI1564_TIMER +
- APCI1564_TCW_PROG);
+ if (ui_Timer == 1) {
+ devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
+ if (devpriv->b_TimerSelectMode) {
- //Send a signal to from kernel to user space
- send_sig(SIGIO, devpriv->tsk_Current, 0);
+ /* Disable Timer Interrupt */
+ ul_Command2 =
+ inl(devpriv->i_IobaseAmcc + APCI1564_TIMER +
+ APCI1564_TCW_PROG);
+ outl(0x0,
+ devpriv->i_IobaseAmcc + APCI1564_TIMER +
+ APCI1564_TCW_PROG);
- // Enable Timer Interrupt
+ /* Send a signal to from kernel to user space */
+ send_sig(SIGIO, devpriv->tsk_Current, 0);
- outl(ul_Command2,
- devpriv->i_IobaseAmcc + APCI1564_TIMER +
- APCI1564_TCW_PROG);
- } // if ((ui_Timer == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_TIMER))
+ /* Enable Timer Interrupt */
- if ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) {
- // Disable Counter Interrupt
- ul_Command2 =
- inl(devpriv->iobase + APCI1564_COUNTER1 +
- APCI1564_TCW_PROG);
- outl(0x0,
- devpriv->iobase + APCI1564_COUNTER1 +
- APCI1564_TCW_PROG);
+ outl(ul_Command2,
+ devpriv->i_IobaseAmcc + APCI1564_TIMER +
+ APCI1564_TCW_PROG);
+ }
+ }/* if (ui_Timer == 1) */
- //Send a signal to from kernel to user space
- send_sig(SIGIO, devpriv->tsk_Current, 0);
- // Enable Counter Interrupt
- outl(ul_Command2,
- devpriv->iobase + APCI1564_COUNTER1 +
- APCI1564_TCW_PROG);
- } // if ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER))
+ if (ui_C1 == 1) {
+ devpriv->b_TimerSelectMode = ADDIDATA_COUNTER;
+ if (devpriv->b_TimerSelectMode) {
- if ((ui_C2 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) {
- // Disable Counter Interrupt
- ul_Command2 =
- inl(devpriv->iobase + APCI1564_COUNTER2 +
- APCI1564_TCW_PROG);
- outl(0x0,
- devpriv->iobase + APCI1564_COUNTER2 +
- APCI1564_TCW_PROG);
+ /* Disable Counter Interrupt */
+ ul_Command2 =
+ inl(devpriv->iobase + APCI1564_COUNTER1 +
+ APCI1564_TCW_PROG);
+ outl(0x0,
+ devpriv->iobase + APCI1564_COUNTER1 +
+ APCI1564_TCW_PROG);
- //Send a signal to from kernel to user space
- send_sig(SIGIO, devpriv->tsk_Current, 0);
+ /* Send a signal to from kernel to user space */
+ send_sig(SIGIO, devpriv->tsk_Current, 0);
- // Enable Counter Interrupt
- outl(ul_Command2,
- devpriv->iobase + APCI1564_COUNTER2 +
- APCI1564_TCW_PROG);
- } // if ((ui_C2 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
+ /* Enable Counter Interrupt */
+ outl(ul_Command2,
+ devpriv->iobase + APCI1564_COUNTER1 +
+ APCI1564_TCW_PROG);
+ }
+ } /* if (ui_C1 == 1) */
- if ((ui_C3 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) {
- // Disable Counter Interrupt
- ul_Command2 =
- inl(devpriv->iobase + APCI1564_COUNTER3 +
- APCI1564_TCW_PROG);
- outl(0x0,
- devpriv->iobase + APCI1564_COUNTER3 +
- APCI1564_TCW_PROG);
+ if (ui_C2 == 1) {
+ devpriv->b_TimerSelectMode = ADDIDATA_COUNTER;
+ if (devpriv->b_TimerSelectMode) {
- //Send a signal to from kernel to user space
- send_sig(SIGIO, devpriv->tsk_Current, 0);
+ /* Disable Counter Interrupt */
+ ul_Command2 =
+ inl(devpriv->iobase + APCI1564_COUNTER2 +
+ APCI1564_TCW_PROG);
+ outl(0x0,
+ devpriv->iobase + APCI1564_COUNTER2 +
+ APCI1564_TCW_PROG);
- // Enable Counter Interrupt
- outl(ul_Command2,
- devpriv->iobase + APCI1564_COUNTER3 +
- APCI1564_TCW_PROG);
- } // if ((ui_C3 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
+ /* Send a signal to from kernel to user space */
+ send_sig(SIGIO, devpriv->tsk_Current, 0);
- if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER)) {
- // Disable Counter Interrupt
- ul_Command2 =
- inl(devpriv->iobase + APCI1564_COUNTER4 +
- APCI1564_TCW_PROG);
- outl(0x0,
- devpriv->iobase + APCI1564_COUNTER4 +
- APCI1564_TCW_PROG);
+ /* Enable Counter Interrupt */
+ outl(ul_Command2,
+ devpriv->iobase + APCI1564_COUNTER2 +
+ APCI1564_TCW_PROG);
+ }
+ } /* if ((ui_C2 == 1) */
- //Send a signal to from kernel to user space
- send_sig(SIGIO, devpriv->tsk_Current, 0);
+ if (ui_C3 == 1) {
+ devpriv->b_TimerSelectMode = ADDIDATA_COUNTER;
+ if (devpriv->b_TimerSelectMode) {
- // Enable Counter Interrupt
- outl(ul_Command2,
- devpriv->iobase + APCI1564_COUNTER4 +
- APCI1564_TCW_PROG);
- } // if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
+ /* Disable Counter Interrupt */
+ ul_Command2 =
+ inl(devpriv->iobase + APCI1564_COUNTER3 +
+ APCI1564_TCW_PROG);
+ outl(0x0,
+ devpriv->iobase + APCI1564_COUNTER3 +
+ APCI1564_TCW_PROG);
+
+ /* Send a signal to from kernel to user space */
+ send_sig(SIGIO, devpriv->tsk_Current, 0);
+
+ /* Enable Counter Interrupt */
+ outl(ul_Command2,
+ devpriv->iobase + APCI1564_COUNTER3 +
+ APCI1564_TCW_PROG);
+ }
+ } /* if ((ui_C3 == 1) */
+
+ if (ui_C4 == 1) {
+ devpriv->b_TimerSelectMode = ADDIDATA_COUNTER;
+ if (devpriv->b_TimerSelectMode) {
+
+ /* Disable Counter Interrupt */
+ ul_Command2 =
+ inl(devpriv->iobase + APCI1564_COUNTER4 +
+ APCI1564_TCW_PROG);
+ outl(0x0,
+ devpriv->iobase + APCI1564_COUNTER4 +
+ APCI1564_TCW_PROG);
+
+ /* Send a signal to from kernel to user space */
+ send_sig(SIGIO, devpriv->tsk_Current, 0);
+
+ /* Enable Counter Interrupt */
+ outl(ul_Command2,
+ devpriv->iobase + APCI1564_COUNTER4 +
+ APCI1564_TCW_PROG);
+ }
+ } /* if (ui_C4 == 1) */
return;
}
@@ -1081,16 +1104,16 @@ static void v_APCI1564_Interrupt(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-INT i_APCI1564_Reset(struct comedi_device * dev)
+int i_APCI1564_Reset(struct comedi_device *dev)
{
- outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_IRQ); //disable the interrupts
- inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_STATUS); //Reset the interrupt status register
- outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE1); //Disable the and/or interrupt
+ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_IRQ); /* disable the interrupts */
+ inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_STATUS); /* Reset the interrupt status register */
+ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE1); /* Disable the and/or interrupt */
outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
devpriv->b_DigitalOutputRegister = 0;
ui_Type = 0;
- outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP); //Resets the output channels
- outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_INTERRUPT); //Disables the interrupt.
+ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP); /* Resets the output channels */
+ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_INTERRUPT); /* Disables the interrupt. */
outl(0x0,
devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG +
APCI1564_TCW_RELOAD_VALUE);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h
index f0c461ca5396..0780c440c44a 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h
@@ -20,45 +20,45 @@
#define APCI1564_BOARD_VENDOR_ID 0x15B8
#define APCI1564_ADDRESS_RANGE 128
-//DIGITAL INPUT-OUTPUT DEFINE
-// Input defines
+/* DIGITAL INPUT-OUTPUT DEFINE */
+/* Input defines */
#define APCI1564_DIGITAL_IP 0x04
#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1 4
#define APCI1564_DIGITAL_IP_INTERRUPT_MODE2 8
#define APCI1564_DIGITAL_IP_IRQ 16
-// Output defines
+/* Output defines */
#define APCI1564_DIGITAL_OP 0x18
#define APCI1564_DIGITAL_OP_RW 0
#define APCI1564_DIGITAL_OP_INTERRUPT 4
#define APCI1564_DIGITAL_OP_IRQ 12
-//Digital Input IRQ Function Selection
+/* Digital Input IRQ Function Selection */
#define ADDIDATA_OR 0
#define ADDIDATA_AND 1
-//Digital Input Interrupt Status
+/* Digital Input Interrupt Status */
#define APCI1564_DIGITAL_IP_INTERRUPT_STATUS 12
-//Digital Output Interrupt Status
+/* Digital Output Interrupt Status */
#define APCI1564_DIGITAL_OP_INTERRUPT_STATUS 8
-//Digital Input Interrupt Enable Disable.
+/* Digital Input Interrupt Enable Disable. */
#define APCI1564_DIGITAL_IP_INTERRUPT_ENABLE 0x4
#define APCI1564_DIGITAL_IP_INTERRUPT_DISABLE 0xFFFFFFFB
-//Digital Output Interrupt Enable Disable.
+/* Digital Output Interrupt Enable Disable. */
#define APCI1564_DIGITAL_OP_VCC_INTERRUPT_ENABLE 0x1
#define APCI1564_DIGITAL_OP_VCC_INTERRUPT_DISABLE 0xFFFFFFFE
#define APCI1564_DIGITAL_OP_CC_INTERRUPT_ENABLE 0x2
#define APCI1564_DIGITAL_OP_CC_INTERRUPT_DISABLE 0xFFFFFFFD
-//ADDIDATA Enable Disable
+/* ADDIDATA Enable Disable */
#define ADDIDATA_ENABLE 1
#define ADDIDATA_DISABLE 0
-// TIMER COUNTER WATCHDOG DEFINES
+/* TIMER COUNTER WATCHDOG DEFINES */
#define ADDIDATA_TIMER 0
#define ADDIDATA_COUNTER 1
@@ -78,30 +78,32 @@
#define APCI1564_TCW_WARN_TIMEVAL 24
#define APCI1564_TCW_WARN_TIMEBASE 28
-// Hardware Layer functions for Apci1564
+/* Hardware Layer functions for Apci1564 */
-//DI
-// for di read
-INT i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+/*
+* DI for di read
+*/
+int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//DO
+/* DO */
int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI1564_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// TIMER
-// timer value is passed as u seconds
-INT i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev,
+/*
+* TIMER timer value is passed as u seconds
+*/
+int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev,
@@ -112,8 +114,8 @@ int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// INTERRUPT
+/* intERRUPT */
static void v_APCI1564_Interrupt(int irq, void *d);
-// RESET
-INT i_APCI1564_Reset(struct comedi_device *dev);
+/* RESET */
+int i_APCI1564_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c
index 906d635da6b2..988e3fc2b857 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -57,7 +57,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI16XX_InsnConfigInitTTLIO |
+| Function Name : int i_APCI16XX_InsnConfigInitTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -69,11 +69,11 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| for you call any other function witch access of TTL. |
| APCI16XX_TTL_INITDIRECTION(user inputs for direction) |
+----------------------------------------------------------------------------+
-| Input Parameters : b_InitType = (BYTE) data[0]; |
-| b_Port0Mode = (BYTE) data[1]; |
-| b_Port1Mode = (BYTE) data[2]; |
-| b_Port2Mode = (BYTE) data[3]; |
-| b_Port3Mode = (BYTE) data[4]; |
+| Input Parameters : b_InitType = (unsigned char) data[0]; |
+| b_Port0Mode = (unsigned char) data[1]; |
+| b_Port1Mode = (unsigned char) data[2]; |
+| b_Port2Mode = (unsigned char) data[3]; |
+| b_Port3Mode = (unsigned char) data[4]; |
| ........ |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -90,14 +90,14 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Command = 0;
- BYTE b_Cpt = 0;
- BYTE b_NumberOfPort =
- (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
+ int i_ReturnValue = insn->n;
+ unsigned char b_Command = 0;
+ unsigned char b_Cpt = 0;
+ unsigned char b_NumberOfPort =
+ (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
/************************/
/* Test the buffer size */
@@ -108,7 +108,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
/* Get the command */
/* **************** */
- b_Command = (BYTE) data[0];
+ b_Command = (unsigned char) data[0];
/********************/
/* Test the command */
@@ -122,7 +122,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
/***************************************/
if ((b_Command == APCI16XX_TTL_INITDIRECTION)
- && ((BYTE) (insn->n - 1) != b_NumberOfPort)) {
+ && ((unsigned char) (insn->n - 1) != b_NumberOfPort)) {
/*******************/
/* Data size error */
/*******************/
@@ -132,7 +132,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
}
if ((b_Command == APCI16XX_TTL_OUTPUTMEMORY)
- && ((BYTE) (insn->n) != 2)) {
+ && ((unsigned char) (insn->n) != 2)) {
/*******************/
/* Data size error */
/*******************/
@@ -182,8 +182,8 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
/************************/
printk("\nPort %d direction selection error",
- (INT) b_Cpt);
- i_ReturnValue = -(INT) b_Cpt;
+ (int) b_Cpt);
+ i_ReturnValue = -(int) b_Cpt;
}
/**************************/
@@ -239,7 +239,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
}
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -250,7 +250,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI16XX_InsnBitsReadTTLIO |
+| Function Name : int i_APCI16XX_InsnBitsReadTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -266,11 +266,11 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
| APCI16XX_TTL_READCHANNEL |
| b_SelectedPort= CR_RANGE(insn->chanspec); |
| b_InputChannel= CR_CHAN(insn->chanspec); |
-| b_ReadType = (BYTE) data[0]; |
+| b_ReadType = (unsigned char) data[0]; |
| |
| APCI16XX_TTL_READPORT |
| b_SelectedPort= CR_RANGE(insn->chanspec); |
-| b_ReadType = (BYTE) data[0]; |
+| b_ReadType = (unsigned char) data[0]; |
+----------------------------------------------------------------------------+
| Output Parameters : data[0] 0 : Channle is not active |
| 1 : Channle is active |
@@ -283,17 +283,17 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Command = 0;
- BYTE b_NumberOfPort =
- (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
- BYTE b_SelectedPort = CR_RANGE(insn->chanspec);
- BYTE b_InputChannel = CR_CHAN(insn->chanspec);
- BYTE *pb_Status;
- DWORD dw_Status;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Command = 0;
+ unsigned char b_NumberOfPort =
+ (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
+ unsigned char b_SelectedPort = CR_RANGE(insn->chanspec);
+ unsigned char b_InputChannel = CR_CHAN(insn->chanspec);
+ unsigned char *pb_Status;
+ unsigned int dw_Status;
/************************/
/* Test the buffer size */
@@ -304,7 +304,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev,
/* Get the command */
/* **************** */
- b_Command = (BYTE) data[0];
+ b_Command = (unsigned char) data[0];
/********************/
/* Test the command */
@@ -380,7 +380,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev,
/**************************/
if (i_ReturnValue >= 0) {
- pb_Status = (PBYTE) & data[0];
+ pb_Status = (unsigned char *) &data[0];
/*******************************/
/* Get the digital inpu status */
@@ -394,7 +394,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev,
/* Save the port value */
/***********************/
- *pb_Status = (BYTE) dw_Status;
+ *pb_Status = (unsigned char) dw_Status;
/***************************************/
/* Test if read channel status command */
@@ -405,12 +405,12 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev,
}
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI16XX_InsnReadTTLIOAllPortValue |
+| Function Name : int i_APCI16XX_InsnReadTTLIOAllPortValue |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -430,13 +430,13 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_Command = (BYTE) CR_AREF(insn->chanspec);
- INT i_ReturnValue = insn->n;
- BYTE b_Cpt = 0;
- BYTE b_NumberOfPort = 0;
+ unsigned char b_Command = (unsigned char) CR_AREF(insn->chanspec);
+ int i_ReturnValue = insn->n;
+ unsigned char b_Cpt = 0;
+ unsigned char b_NumberOfPort = 0;
unsigned int *pls_ReadData = data;
/********************/
@@ -450,7 +450,7 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
/**********************************/
b_NumberOfPort =
- (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 32);
+ (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 32);
if ((b_NumberOfPort * 32) <
devpriv->ps_BoardInfo->i_NbrTTLChannel) {
b_NumberOfPort = b_NumberOfPort + 1;
@@ -524,7 +524,7 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
i_ReturnValue = -100;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -535,7 +535,7 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI16XX_InsnBitsWriteTTLIO |
+| Function Name : int i_APCI16XX_InsnBitsWriteTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -551,11 +551,11 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
| APCI16XX_TTL_WRITECHANNEL_ON | APCI16XX_TTL_WRITECHANNEL_OFF |
| b_SelectedPort = CR_RANGE(insn->chanspec); |
| b_OutputChannel= CR_CHAN(insn->chanspec); |
-| b_Command = (BYTE) data[0]; |
+| b_Command = (unsigned char) data[0]; |
| |
| APCI16XX_TTL_WRITEPORT_ON | APCI16XX_TTL_WRITEPORT_OFF |
| b_SelectedPort = CR_RANGE(insn->chanspec); |
-| b_Command = (BYTE) data[0]; |
+| b_Command = (unsigned char) data[0]; |
+----------------------------------------------------------------------------+
| Output Parameters : data[0] : TTL output port 0 to 3 data |
| data[1] : TTL output port 4 to 7 data |
@@ -570,16 +570,16 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Command = 0;
- BYTE b_NumberOfPort =
- (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
- BYTE b_SelectedPort = CR_RANGE(insn->chanspec);
- BYTE b_OutputChannel = CR_CHAN(insn->chanspec);
- DWORD dw_Status = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Command = 0;
+ unsigned char b_NumberOfPort =
+ (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
+ unsigned char b_SelectedPort = CR_RANGE(insn->chanspec);
+ unsigned char b_OutputChannel = CR_CHAN(insn->chanspec);
+ unsigned int dw_Status = 0;
/************************/
/* Test the buffer size */
@@ -590,7 +590,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev,
/* Get the command */
/* **************** */
- b_Command = (BYTE) data[0];
+ b_Command = (unsigned char) data[0];
/********************/
/* Test the command */
@@ -758,7 +758,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev,
devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4));
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -774,7 +774,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI16XX_Reset(struct comedi_device * dev)
+int i_APCI16XX_Reset(struct comedi_device *dev)
{
return 0;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c
index 31f55da39ea8..457917f292b7 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -62,7 +62,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| Task : Configures The Digital Output Subdevice. |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 1 Digital Memory On |
@@ -75,20 +75,20 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2016_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2016_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
"Not a valid Data !!! ,Data should be 1 or 0\n");
return -EINVAL;
- } // if ((data[0]!=0) && (data[0]!=1))
+ } /* if ((data[0]!=0) && (data[0]!=1)) */
if (data[0]) {
devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE;
- } // if (data[0]
+ } /* if (data[0] */
else {
devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
- } // else if (data[0]
+ } /* else if (data[0] */
return insn->n;
}
@@ -101,8 +101,8 @@ int i_APCI2016_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| Task : Writes port value To the selected port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To Write |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To Write |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -111,34 +111,34 @@ int i_APCI2016_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2016_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_NoOfChannel;
- UINT ui_Temp, ui_Temp1;
+ unsigned int ui_NoOfChannel;
+ unsigned int ui_Temp, ui_Temp1;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
if ((ui_NoOfChannel < 0) || (ui_NoOfChannel > 15)) {
comedi_error(dev,
"Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n");
return -EINVAL;
- } // if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15))
+ } /* if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) */
if (devpriv->b_OutputMemoryStatus) {
ui_Temp = inw(devpriv->iobase + APCI2016_DIGITAL_OP);
- } // if (devpriv->b_OutputMemoryStatus )
+ } /* if (devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } // else if (devpriv->b_OutputMemoryStatus )
+ } /* else if (devpriv->b_OutputMemoryStatus ) */
if ((data[1] != 0) && (data[1] != 1)) {
comedi_error(dev,
"Invalid Data[1] value !!!, Data[1] should be 0 or 1\n");
return -EINVAL;
- } // if ((data[1]!=0) && (data[1]!=1))
+ } /* if ((data[1]!=0) && (data[1]!=1)) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outw(data[0], devpriv->iobase + APCI2016_DIGITAL_OP);
- } // if (data[1]==0)
+ } /* if (data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -162,16 +162,16 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
break;
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
- } //switch(ui_NoOfChannels)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->iobase + APCI2016_DIGITAL_OP);
- } // if (data[1]==1)
+ } /* if (data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } // else if (data[1]==1)
- } // else if (data[1]==0)
- } // if (data[3]==0)
+ } /* else if (data[1]==1) */
+ } /* else if (data[1]==0) */
+ } /* if (data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -183,7 +183,7 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
data[0] = data[0] & ui_Temp;
outw(data[0],
devpriv->iobase + APCI2016_DIGITAL_OP);
- } // if (data[1]==0)
+ } /* if (data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -228,22 +228,22 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
- } //switch(ui_NoOfChannels)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->iobase +
APCI2016_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
return insn->n;
}
@@ -256,8 +256,8 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -266,27 +266,27 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2016_BitsDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2016_BitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
if ((ui_NoOfChannel < 0) || (ui_NoOfChannel > 15)) {
comedi_error(dev,
"Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n");
return -EINVAL;
- } // if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15))
+ } /* if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) */
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
"Invalid Data[0] value !!!, Data[0] should be 0 or 1\n");
return -EINVAL;
- } // if ((data[0]!=0) && (data[0]!=1))
+ } /* if ((data[0]!=0) && (data[0]!=1)) */
ui_Temp = data[0];
*data = inw(devpriv->iobase + APCI2016_DIGITAL_OP_RW);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } // if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
switch (ui_NoOfChannel) {
@@ -307,13 +307,13 @@ int i_APCI2016_BitsDigitalOutput(struct comedi_device * dev, struct comedi_subde
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
- } //switch(ui_NoOfChannel)
- } // if (ui_Temp==1)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* switch(ui_NoOfChannel) */
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } // else if (ui_Temp==1)
- } // if (ui_Temp==0)
+ } /* else if (ui_Temp==1) */
+ } /* if (ui_Temp==0) */
return insn->n;
}
@@ -337,16 +337,16 @@ int i_APCI2016_BitsDigitalOutput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2016_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2016_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0] == 0) {
- //Disable the watchdog
+ /* Disable the watchdog */
outw(0x0,
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_ENABLEDISABLE);
- //Loading the Reload value
+ /* Loading the Reload value */
outw(data[1],
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_RELOAD_VALUE);
@@ -380,20 +380,20 @@ int i_APCI2016_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2016_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
- case 0: //stop the watchdog
- outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); //disable the watchdog
+ case 0: /* stop the watchdog */
+ outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */
break;
- case 1: //start the watchdog
+ case 1: /* start the watchdog */
outw(0x0001,
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_ENABLEDISABLE);
break;
- case 2: //Software trigger
+ case 2: /* Software trigger */
outw(0x0201,
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_ENABLEDISABLE);
@@ -401,7 +401,7 @@ int i_APCI2016_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
default:
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } // switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
@@ -427,8 +427,8 @@ int i_APCI2016_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
*/
-int i_APCI2016_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2016_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
udelay(5);
data[0] = inw(devpriv->i_IobaseAddon + APCI2016_WATCHDOG_STATUS) & 0x1;
@@ -450,9 +450,9 @@ int i_APCI2016_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice
+----------------------------------------------------------------------------+
*/
-INT i_APCI2016_Reset(struct comedi_device * dev)
+int i_APCI2016_Reset(struct comedi_device *dev)
{
- outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); // Resets the digital output channels
+ outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); /* Resets the digital output channels */
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE);
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE);
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE + 2);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h
index 9261aacd25f1..639944c44469 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h
@@ -19,17 +19,17 @@
#define APCI2016_BOARD_VENDOR_ID 0x15B8
#define APCI2016_ADDRESS_RANGE 8
-//DIGITAL INPUT-OUTPUT DEFINE
+/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI2016_DIGITAL_OP 0x04
#define APCI2016_DIGITAL_OP_RW 4
-//ADDIDATA Enable Disable
+/* ADDIDATA Enable Disable */
#define ADDIDATA_ENABLE 1
#define ADDIDATA_DISABLE 0
-// TIMER COUNTER WATCHDOG DEFINES
+/* TIMER COUNTER WATCHDOG DEFINES */
#define ADDIDATA_WATCHDOG 2
#define APCI2016_DIGITAL_OP_WATCHDOG 0
@@ -37,9 +37,9 @@
#define APCI2016_WATCHDOG_RELOAD_VALUE 4
#define APCI2016_WATCHDOG_STATUS 16
-// Hardware Layer functions for Apci2016
+/* Hardware Layer functions for Apci2016 */
-//DO
+/* DO */
int i_APCI2016_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
@@ -49,8 +49,10 @@ int i_APCI2016_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subde
int i_APCI2016_BitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// TIMER
-// timer value is passed as u seconds
+/*
+* TIMER
+* timer value is passed as u seconds
+*/
int i_APCI2016_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
@@ -61,10 +63,10 @@ int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_s
int i_APCI2016_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// Interrupt functions.....
+/* Interrupt functions..... */
-// void v_APCI2016_Interrupt(int irq, void *d) ;
+/* void v_APCI2016_Interrupt(int irq, void *d); */
- //void v_APCI2016_Interrupt(int irq, void *d);
-// RESET
-INT i_APCI2016_Reset(struct comedi_device *dev);
+/* void v_APCI2016_Interrupt(int irq, void *d); */
+/* RESET */
+int i_APCI2016_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c
index 1347bc388f3e..ec817082d170 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -53,7 +53,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
*/
#include "hwdrv_apci2032.h"
-UINT ui_InterruptData, ui_Type;
+unsigned int ui_InterruptData, ui_Type;
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2032_ConfigDigitalOutput |
@@ -63,7 +63,7 @@ UINT ui_InterruptData, ui_Type;
| Task : Configures The Digital Output Subdevice. |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[1] : 1 Enable VCC Interrupt |
@@ -79,36 +79,36 @@ UINT ui_InterruptData, ui_Type;
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2032_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command = 0;
+ unsigned int ul_Command = 0;
devpriv->tsk_Current = current;
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
"Not a valid Data !!! ,Data should be 1 or 0\n");
return -EINVAL;
- } //if ( (data[0]!=0) && (data[0]!=1) )
+ } /* if ( (data[0]!=0) && (data[0]!=1) ) */
if (data[0]) {
devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE;
- } // if (data[0])
+ } /* if (data[0]) */
else {
devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
- } //else if (data[0])
+ } /* else if (data[0]) */
if (data[1] == ADDIDATA_ENABLE) {
ul_Command = ul_Command | 0x1;
- } //if (data[1] == ADDIDATA_ENABLE)
+ } /* if (data[1] == ADDIDATA_ENABLE) */
else {
ul_Command = ul_Command & 0xFFFFFFFE;
- } //elseif (data[1] == ADDIDATA_ENABLE)
+ } /* elseif (data[1] == ADDIDATA_ENABLE) */
if (data[2] == ADDIDATA_ENABLE) {
ul_Command = ul_Command | 0x2;
- } //if (data[2] == ADDIDATA_ENABLE)
+ } /* if (data[2] == ADDIDATA_ENABLE) */
else {
ul_Command = ul_Command & 0xFFFFFFFD;
- } //elseif (data[2] == ADDIDATA_ENABLE)
+ } /* elseif (data[2] == ADDIDATA_ENABLE) */
outl(ul_Command, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT);
ui_InterruptData = inl(devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT);
return insn->n;
@@ -123,8 +123,8 @@ int i_APCI2032_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| Task : Writes port value To the selected port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To Write |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To Write |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -134,23 +134,23 @@ int i_APCI2032_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
*/
-INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp, ui_Temp1;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp, ui_Temp1;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
if (devpriv->b_OutputMemoryStatus) {
ui_Temp = inl(devpriv->iobase + APCI2032_DIGITAL_OP);
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outl(data[0], devpriv->iobase + APCI2032_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -184,18 +184,18 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outl(data[0],
devpriv->iobase + APCI2032_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==0)
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -209,7 +209,7 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
data[0] = data[0] & ui_Temp;
outl(data[0],
devpriv->iobase + APCI2032_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -272,25 +272,25 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outl(data[0],
devpriv->iobase +
APCI2032_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
- return (insn->n);;
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
+ return insn->n;
}
/*
@@ -302,8 +302,8 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -313,17 +313,17 @@ INT i_APCI2032_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
*/
-INT i_APCI2032_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
ui_Temp = data[0];
*data = inl(devpriv->iobase + APCI2032_DIGITAL_OP_RW);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } //if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
switch (ui_NoOfChannel) {
@@ -349,28 +349,28 @@ INT i_APCI2032_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
- } //if (ui_Temp==1)
+ } /* switch(ui_NoOfChannels) */
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } //elseif (ui_Temp==1)
+ } /* elseif (ui_Temp==1) */
}
return insn->n;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI2032_ConfigWatchdog(comedi_device
- *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)|
+| Function Name : int i_APCI2032_ConfigWatchdog(comedi_device
+| *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)|
| |
+----------------------------------------------------------------------------+
| Task : Configures The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -380,15 +380,15 @@ INT i_APCI2032_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI2032_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0] == 0) {
- //Disable the watchdog
+ /* Disable the watchdog */
outl(0x0,
devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG +
APCI2032_TCW_PROG);
- //Loading the Reload value
+ /* Loading the Reload value */
outl(data[1],
devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG +
APCI2032_TCW_RELOAD_VALUE);
@@ -421,19 +421,19 @@ INT i_APCI2032_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-int i_APCI2032_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
- case 0: //stop the watchdog
- outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); //disable the watchdog
+ case 0: /* stop the watchdog */
+ outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); /* disable the watchdog */
break;
- case 1: //start the watchdog
+ case 1: /* start the watchdog */
outl(0x0001,
devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG +
APCI2032_TCW_PROG);
break;
- case 2: //Software trigger
+ case 2: /* Software trigger */
outl(0x0201,
devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG +
APCI2032_TCW_PROG);
@@ -449,13 +449,13 @@ int i_APCI2032_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2032_ReadWatchdog |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data); |
+| unsigned int *data); |
+----------------------------------------------------------------------------+
| Task : Read The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -466,8 +466,8 @@ int i_APCI2032_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
*/
-int i_APCI2032_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] =
@@ -498,13 +498,13 @@ void v_APCI2032_Interrupt(int irq, void *d)
struct comedi_device *dev = d;
unsigned int ui_DO;
- ui_DO = inl(devpriv->iobase + APCI2032_DIGITAL_OP_IRQ) & 0x1; //Check if VCC OR CC interrupt has occured.
+ ui_DO = inl(devpriv->iobase + APCI2032_DIGITAL_OP_IRQ) & 0x1; /* Check if VCC OR CC interrupt has occured. */
if (ui_DO == 0) {
printk("\nInterrupt from unKnown source\n");
- } // if(ui_DO==0)
+ } /* if(ui_DO==0) */
if (ui_DO) {
- // Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt.
+ /* Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. */
ui_Type =
inl(devpriv->iobase +
APCI2032_DIGITAL_OP_INTERRUPT_STATUS) & 0x3;
@@ -512,16 +512,16 @@ void v_APCI2032_Interrupt(int irq, void *d)
devpriv->iobase + APCI2032_DIGITAL_OP +
APCI2032_DIGITAL_OP_INTERRUPT);
if (ui_Type == 1) {
- //Sends signal to user space
+ /* Sends signal to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
- } // if (ui_Type==1)
+ } /* if (ui_Type==1) */
else {
if (ui_Type == 2) {
- // Sends signal to user space
+ /* Sends signal to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
- } //if (ui_Type==2)
- } //else if (ui_Type==1)
- } //if(ui_DO)
+ } /* if (ui_Type==2) */
+ } /* else if (ui_Type==1) */
+ } /* if(ui_DO) */
return;
@@ -544,8 +544,8 @@ void v_APCI2032_Interrupt(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-int i_APCI2032_ReadInterruptStatus(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2032_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
*data = ui_Type;
return insn->n;
@@ -567,13 +567,13 @@ int i_APCI2032_ReadInterruptStatus(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
*/
-int i_APCI2032_Reset(struct comedi_device * dev)
+int i_APCI2032_Reset(struct comedi_device *dev)
{
devpriv->b_DigitalOutputRegister = 0;
ui_Type = 0;
- outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP); //Resets the output channels
- outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); //Disables the interrupt.
- outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); //disable the watchdog
- outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_RELOAD_VALUE); //reload=0
+ outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP); /* Resets the output channels */
+ outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); /* Disables the interrupt. */
+ outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); /* disable the watchdog */
+ outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_RELOAD_VALUE); /* reload=0 */
return 0;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h
index 55002e0288b5..c971d143c249 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h
@@ -17,32 +17,32 @@
/********* Definitions for APCI-2032 card *****/
-// Card Specific information
+/* Card Specific information */
#define APCI2032_BOARD_VENDOR_ID 0x15B8
#define APCI2032_ADDRESS_RANGE 63
-//DIGITAL INPUT-OUTPUT DEFINE
+/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI2032_DIGITAL_OP 0
#define APCI2032_DIGITAL_OP_RW 0
#define APCI2032_DIGITAL_OP_INTERRUPT 4
#define APCI2032_DIGITAL_OP_IRQ 12
-//Digital Output Interrupt Status
+/* Digital Output Interrupt Status */
#define APCI2032_DIGITAL_OP_INTERRUPT_STATUS 8
-//Digital Output Interrupt Enable Disable.
+/* Digital Output Interrupt Enable Disable. */
#define APCI2032_DIGITAL_OP_VCC_INTERRUPT_ENABLE 0x1
#define APCI2032_DIGITAL_OP_VCC_INTERRUPT_DISABLE 0xFFFFFFFE
#define APCI2032_DIGITAL_OP_CC_INTERRUPT_ENABLE 0x2
#define APCI2032_DIGITAL_OP_CC_INTERRUPT_DISABLE 0xFFFFFFFD
-//ADDIDATA Enable Disable
+/* ADDIDATA Enable Disable */
#define ADDIDATA_ENABLE 1
#define ADDIDATA_DISABLE 0
-// TIMER COUNTER WATCHDOG DEFINES
+/* TIMER COUNTER WATCHDOG DEFINES */
#define ADDIDATA_WATCHDOG 2
#define APCI2032_DIGITAL_OP_WATCHDOG 16
@@ -52,30 +52,32 @@
#define APCI2032_TCW_TRIG_STATUS 16
#define APCI2032_TCW_IRQ 20
-// Hardware Layer functions for Apci2032
+/* Hardware Layer functions for Apci2032 */
-//DO
+/* DO */
int i_APCI2032_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI2032_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// TIMER
-// timer value is passed as u seconds
-INT i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+/* TIMER
+ * timer value is passed as u seconds
+*/
+
+int i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI2032_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI2032_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// Interrupt functions.....
+/* Interrupt functions..... */
void v_APCI2032_Interrupt(int irq, void *d);
-//Reset functions
+/* Reset functions */
int i_APCI2032_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
index 947e18ef3ab3..a853c62a4fd9 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -63,7 +63,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -73,20 +73,20 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI2200_Read1DigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_TmpValue = 0;
- UINT ui_Channel;
+ unsigned int ui_TmpValue = 0;
+ unsigned int ui_Channel;
ui_Channel = CR_CHAN(insn->chanspec);
if (ui_Channel >= 0 && ui_Channel <= 7) {
- ui_TmpValue = (UINT) inw(devpriv->iobase + APCI2200_DIGITAL_IP);
+ ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI2200_DIGITAL_IP);
*data = (ui_TmpValue >> ui_Channel) & 0x1;
- } //if(ui_Channel >= 0 && ui_Channel <=7)
+ } /* if(ui_Channel >= 0 && ui_Channel <=7) */
else {
printk("\nThe specified channel does not exist\n");
- return -EINVAL; // "sorry channel spec wrong "
- } //else if(ui_Channel >= 0 && ui_Channel <=7)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* else if(ui_Channel >= 0 && ui_Channel <=7) */
return insn->n;
}
@@ -101,7 +101,7 @@ INT i_APCI2200_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -112,17 +112,17 @@ INT i_APCI2200_Read1DigitalInput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
*/
-INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_PortValue = data[0];
- UINT ui_Mask = 0;
- UINT ui_NoOfChannels;
+ unsigned int ui_PortValue = data[0];
+ unsigned int ui_Mask = 0;
+ unsigned int ui_NoOfChannels;
ui_NoOfChannels = CR_CHAN(insn->chanspec);
- *data = (UINT) inw(devpriv->iobase + APCI2200_DIGITAL_IP);
+ *data = (unsigned int) inw(devpriv->iobase + APCI2200_DIGITAL_IP);
switch (ui_NoOfChannels) {
case 2:
ui_Mask = 3;
@@ -137,9 +137,9 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
default:
printk("\nWrong parameters\n");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
return insn->n;
}
@@ -147,7 +147,7 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_ConfigDigitalOutput (struct comedi_device *dev,
- struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) |
+| struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Configures The Digital Output Subdevice. |
@@ -156,7 +156,7 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| data[0] :1:Memory on |
| 0:Memory off |
| |
@@ -169,8 +169,8 @@ INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device * dev, struct comedi_su
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI2200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
devpriv->b_OutputMemoryStatus = data[0];
return insn->n;
@@ -180,13 +180,13 @@ int i_APCI2200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_WriteDigitalOutput |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data) |
+| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Writes port value To the selected port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -197,23 +197,23 @@ int i_APCI2200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
*/
-INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp, ui_Temp1;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp, ui_Temp1;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
if (devpriv->b_OutputMemoryStatus) {
ui_Temp = inw(devpriv->iobase + APCI2200_DIGITAL_OP);
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outw(data[0], devpriv->iobase + APCI2200_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -240,18 +240,18 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
break;
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->iobase + APCI2200_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==0)
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -263,7 +263,7 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
data[0] = data[0] & ui_Temp;
outw(data[0],
devpriv->iobase + APCI2200_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -312,38 +312,38 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outw(data[0],
devpriv->iobase +
APCI2200_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
- return (insn->n);;
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
+ return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_ReadDigitalOutput |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data) |
+| unsigned int *data) |
+----------------------------------------------------------------------------+
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -354,17 +354,17 @@ INT i_APCI2200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
*/
-INT i_APCI2200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
ui_Temp = data[0];
*data = inw(devpriv->iobase + APCI2200_DIGITAL_OP);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } //if(ui_Temp==0)
+ } /* if(ui_Temp==0) */
else {
if (ui_Temp == 1) {
switch (ui_NoOfChannel) {
@@ -386,28 +386,28 @@ INT i_APCI2200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
- } //if(ui_Temp==1)
+ } /* switch(ui_NoOfChannels) */
+ } /* if(ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } //elseif(ui_Temp==1)
- } //elseif(ui_Temp==0)
+ } /* elseif(ui_Temp==1) */
+ } /* elseif(ui_Temp==0) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_ConfigWatchdog(struct comedi_device *dev,
- struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
+| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Configures The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -418,15 +418,15 @@ INT i_APCI2200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
+----------------------------------------------------------------------------+
*/
-int i_APCI2200_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0] == 0) {
- //Disable the watchdog
+ /* Disable the watchdog */
outw(0x0,
devpriv->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
- //Loading the Reload value
+ /* Loading the Reload value */
outw(data[1],
devpriv->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_RELOAD_VALUE);
@@ -434,11 +434,11 @@ int i_APCI2200_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic
outw(data[1],
devpriv->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_RELOAD_VALUE + 2);
- } //if(data[0]==0)
+ } /* if(data[0]==0) */
else {
printk("\nThe input parameters are wrong\n");
return -EINVAL;
- } //elseif(data[0]==0)
+ } /* elseif(data[0]==0) */
return insn->n;
}
@@ -464,19 +464,19 @@ int i_APCI2200_ConfigWatchdog(struct comedi_device * dev, struct comedi_subdevic
+----------------------------------------------------------------------------+
*/
-int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
- case 0: //stop the watchdog
- outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); //disable the watchdog
+ case 0: /* stop the watchdog */
+ outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */
break;
- case 1: //start the watchdog
+ case 1: /* start the watchdog */
outw(0x0001,
devpriv->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
break;
- case 2: //Software trigger
+ case 2: /* Software trigger */
outw(0x0201,
devpriv->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
@@ -484,7 +484,7 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
default:
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } // switch(data[0])
+ } /* switch(data[0]) */
return insn->n;
}
@@ -492,13 +492,13 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_ReadWatchdog |
| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
- unsigned int *data); |
+| unsigned int *data); |
+----------------------------------------------------------------------------+
| Task : Read The Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
| struct comedi_subdevice *s, :pointer to subdevice structure
- struct comedi_insn *insn :pointer to insn structure |
+| struct comedi_insn *insn :pointer to insn structure |
| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
@@ -509,8 +509,8 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
*/
-int i_APCI2200_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI2200_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] =
inw(devpriv->iobase + APCI2200_WATCHDOG +
@@ -533,9 +533,9 @@ int i_APCI2200_ReadWatchdog(struct comedi_device * dev, struct comedi_subdevice
+----------------------------------------------------------------------------+
*/
-INT i_APCI2200_Reset(struct comedi_device * dev)
+int i_APCI2200_Reset(struct comedi_device *dev)
{
- outw(0x0, devpriv->iobase + APCI2200_DIGITAL_OP); //RESETS THE DIGITAL OUTPUTS
+ outw(0x0, devpriv->iobase + APCI2200_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */
outw(0x0,
devpriv->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h
index 0a115b4c44c9..63e5f1fcecc7 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h
@@ -17,39 +17,39 @@
/********* Definitions for APCI-2200 card *****/
-// Card Specific information
+/* Card Specific information */
#define APCI2200_BOARD_VENDOR_ID 0x15b8
#define APCI2200_ADDRESS_RANGE 64
-//DIGITAL INPUT-OUTPUT DEFINE
+/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI2200_DIGITAL_OP 4
#define APCI2200_DIGITAL_IP 0
-// TIMER COUNTER WATCHDOG DEFINES
+/* TIMER COUNTER WATCHDOG DEFINES */
#define APCI2200_WATCHDOG 0x08
#define APCI2200_WATCHDOG_ENABLEDISABLE 12
#define APCI2200_WATCHDOG_RELOAD_VALUE 4
#define APCI2200_WATCHDOG_STATUS 16
-// Hardware Layer functions for Apci2200
+/* Hardware Layer functions for Apci2200 */
-//Digital Input
-INT i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+/* Digital Input */
+int i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//Digital Output
+/* Digital Output */
int i_APCI2200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// TIMER
+/* TIMER */
int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -57,5 +57,5 @@ int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_s
int i_APCI2200_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//reset
-INT i_APCI2200_Reset(struct comedi_device *dev);
+/* reset */
+int i_APCI2200_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 68eb8dfd5139..169cee41b871 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -45,9 +45,9 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
*/
#include "hwdrv_apci3120.h"
-static UINT ui_Temp = 0;
+static unsigned int ui_Temp = 0;
-// FUNCTION DEFINITIONS
+/* FUNCTION DEFINITIONS */
/*
+----------------------------------------------------------------------------+
@@ -74,20 +74,20 @@ static UINT ui_Temp = 0;
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnConfigAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT i;
+ unsigned int i;
if ((data[0] != APCI3120_EOC_MODE) && (data[0] != APCI3120_EOS_MODE))
return -1;
- // Check for Conversion time to be added ??
+ /* Check for Conversion time to be added ?? */
devpriv->ui_EocEosConversionTime = data[2];
if (data[0] == APCI3120_EOS_MODE) {
- //Test the number of the channel
+ /* Test the number of the channel */
for (i = 0; i < data[3]; i++) {
if (CR_CHAN(data[4 + i]) >= this_board->i_NbrAiChannel) {
@@ -102,14 +102,14 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device * dev, struct comedi_s
devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
} else
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
- // Copy channel list and Range List to devpriv
+ /* Copy channel list and Range List to devpriv */
devpriv->ui_AiNbrofChannels = data[3];
for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) {
devpriv->ui_AiChannelList[i] = data[4 + i];
}
- } else // EOC
+ } else /* EOC */
{
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
if (data[1]) {
@@ -145,28 +145,28 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device * dev, struct comedi_s
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- USHORT us_ConvertTiming, us_TmpValue, i;
- BYTE b_Tmp;
+ unsigned short us_ConvertTiming, us_TmpValue, i;
+ unsigned char b_Tmp;
- // fix convertion time to 10 us
+ /* fix convertion time to 10 us */
if (!devpriv->ui_EocEosConversionTime) {
printk("No timer0 Value using 10 us\n");
us_ConvertTiming = 10;
} else
- us_ConvertTiming = (USHORT) (devpriv->ui_EocEosConversionTime / 1000); // nano to useconds
+ us_ConvertTiming = (unsigned short) (devpriv->ui_EocEosConversionTime / 1000); /* nano to useconds */
- // this_board->i_hwdrv_InsnReadAnalogInput(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]);
+ /* this_board->i_hwdrv_InsnReadAnalogInput(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]); */
- // Clear software registers
+ /* Clear software registers */
devpriv->b_TimerSelectMode = 0;
devpriv->b_ModeSelectRegister = 0;
devpriv->us_OutputRegister = 0;
-// devpriv->b_DigitalOutputRegister=0;
+/* devpriv->b_DigitalOutputRegister=0; */
- if (insn->unused[0] == 222) // second insn read
+ if (insn->unused[0] == 222) /* second insn read */
{
for (i = 0; i < insn->n; i++) {
@@ -174,14 +174,16 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
}
} else {
- devpriv->tsk_Current = current; // Save the current process task structure
- //Testing if board have the new Quartz and calculate the time value
- //to set in the timer
+ devpriv->tsk_Current = current; /* Save the current process task structure */
+/*
+ * Testing if board have the new Quartz and calculate the time value
+ * to set in the timer
+ */
us_TmpValue =
- (USHORT) inw(devpriv->iobase + APCI3120_RD_STATUS);
+ (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
- //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
+ /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */
if ((us_TmpValue & 0x00B0) == 0x00B0
|| !strcmp(this_board->pc_DriverName, "apci3001")) {
us_ConvertTiming = (us_ConvertTiming * 2) - 2;
@@ -190,25 +192,26 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
((us_ConvertTiming * 12926) / 10000) - 1;
}
- us_TmpValue = (USHORT) devpriv->b_InterruptMode;
+ us_TmpValue = (unsigned short) devpriv->b_InterruptMode;
switch (us_TmpValue) {
case APCI3120_EOC_MODE:
- // Testing the interrupt flag and set the EOC bit
- // Clears the FIFO
+/*
+ * Testing the interrupt flag and set the EOC bit Clears the FIFO
+ */
inw(devpriv->iobase + APCI3120_RESET_FIFO);
- // Initialize the sequence array
+ /* Initialize the sequence array */
- //if (!i_APCI3120_SetupChannelList(dev,s,1,chanlist,0)) return -EINVAL;
+ /* if (!i_APCI3120_SetupChannelList(dev,s,1,chanlist,0)) return -EINVAL; */
if (!i_APCI3120_SetupChannelList(dev, s, 1,
&insn->chanspec, 0))
return -EINVAL;
- //Initialize Timer 0 mode 4
+ /* Initialize Timer 0 mode 4 */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0xFC) |
@@ -216,14 +219,14 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
outb(devpriv->b_TimerSelectMode,
devpriv->iobase + APCI3120_TIMER_CRT1);
- // Reset the scan bit and Disables the EOS, DMA, EOC interrupt
+ /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister & APCI3120_DISABLE_SCAN;
if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
- //Disables the EOS,DMA and enables the EOC interrupt
+ /* Disables the EOS,DMA and enables the EOC interrupt */
devpriv->b_ModeSelectRegister =
(devpriv->
b_ModeSelectRegister &
@@ -241,7 +244,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
- // Sets gate 0
+ /* Sets gate 0 */
devpriv->us_OutputRegister =
(devpriv->
us_OutputRegister & APCI3120_CLEAR_PA_PR) |
@@ -249,30 +252,30 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
outw(devpriv->us_OutputRegister,
devpriv->iobase + APCI3120_WR_ADDRESS);
- // Select Timer 0
+ /* Select Timer 0 */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_0_WORD;
outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
- //Set the convertion time
+ /* Set the convertion time */
outw(us_ConvertTiming,
devpriv->iobase + APCI3120_TIMER_VALUE);
us_TmpValue =
- (USHORT) inw(dev->iobase + APCI3120_RD_STATUS);
+ (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS);
if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) {
do {
- // Waiting for the end of conversion
+ /* Waiting for the end of conversion */
us_TmpValue =
inw(devpriv->iobase +
APCI3120_RD_STATUS);
} while ((us_TmpValue & APCI3120_EOC) ==
APCI3120_EOC);
- //Read the result in FIFO and put it in insn data pointer
+ /* Read the result in FIFO and put it in insn data pointer */
us_TmpValue = inw(devpriv->iobase + 0);
*data = us_TmpValue;
@@ -284,9 +287,9 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
case APCI3120_EOS_MODE:
inw(devpriv->iobase);
- // Clears the FIFO
+ /* Clears the FIFO */
inw(devpriv->iobase + APCI3120_RESET_FIFO);
- // clear PA PR and disable timer 0
+ /* clear PA PR and disable timer 0 */
devpriv->us_OutputRegister =
(devpriv->
@@ -301,7 +304,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
devpriv->ui_AiChannelList, 0))
return -EINVAL;
- //Initialize Timer 0 mode 2
+ /* Initialize Timer 0 mode 2 */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0xFC) |
@@ -309,26 +312,26 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
outb(devpriv->b_TimerSelectMode,
devpriv->iobase + APCI3120_TIMER_CRT1);
- //Select Timer 0
+ /* Select Timer 0 */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_0_WORD;
outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
- //Set the convertion time
+ /* Set the convertion time */
outw(us_ConvertTiming,
devpriv->iobase + APCI3120_TIMER_VALUE);
- //Set the scan bit
+ /* Set the scan bit */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister | APCI3120_ENABLE_SCAN;
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
- //If Interrupt function is loaded
+ /* If Interrupt function is loaded */
if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
- //Disables the EOC,DMA and enables the EOS interrupt
+ /* Disables the EOC,DMA and enables the EOS interrupt */
devpriv->b_ModeSelectRegister =
(devpriv->
b_ModeSelectRegister &
@@ -347,7 +350,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
inw(devpriv->iobase + APCI3120_RD_STATUS);
- //Sets gate 0
+ /* Sets gate 0 */
devpriv->us_OutputRegister =
devpriv->
@@ -355,28 +358,27 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
outw(devpriv->us_OutputRegister,
devpriv->iobase + APCI3120_WR_ADDRESS);
- //Start conversion
+ /* Start conversion */
outw(0, devpriv->iobase + APCI3120_START_CONVERSION);
- //Waiting of end of convertion if interrupt is not installed
+ /* Waiting of end of convertion if interrupt is not installed */
if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) {
- //Waiting the end of convertion
+ /* Waiting the end of convertion */
do {
us_TmpValue =
inw(devpriv->iobase +
APCI3120_RD_STATUS);
- }
- while ((us_TmpValue & APCI3120_EOS) !=
- APCI3120_EOS);
+ } while ((us_TmpValue & APCI3120_EOS) !=
+ APCI3120_EOS);
for (i = 0; i < devpriv->ui_AiNbrofChannels;
i++) {
- //Read the result in FIFO and write them in shared memory
+ /* Read the result in FIFO and write them in shared memory */
us_TmpValue = inw(devpriv->iobase);
- data[i] = (UINT) us_TmpValue;
+ data[i] = (unsigned int) us_TmpValue;
}
- devpriv->b_InterruptMode = APCI3120_EOC_MODE; // Restore defaults.
+ devpriv->b_InterruptMode = APCI3120_EOC_MODE; /* Restore defaults. */
}
break;
@@ -384,7 +386,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
printk("inputs wrong\n");
}
- devpriv->ui_EocEosConversionTime = 0; // re initializing the variable;
+ devpriv->ui_EocEosConversionTime = 0; /* re initializing the variable; */
}
return insn->n;
@@ -409,38 +411,41 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device * dev, struct comedi_sub
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_subdevice * s)
+int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s)
{
- // Disable A2P Fifo write and AMWEN signal
+ /* Disable A2P Fifo write and AMWEN signal */
outw(0, devpriv->i_IobaseAddon + 4);
- //Disable Bus Master ADD ON
+ /* Disable Bus Master ADD ON */
outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
outw(0, devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
outw(0, devpriv->i_IobaseAddon + 2);
- //Disable BUS Master PCI
+ /* Disable BUS Master PCI */
outl(0, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
- //outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR)&(~AINT_WRITE_COMPL), devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); // stop amcc irqs
- //outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR)&(~EN_A2P_TRANSFERS), devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR); // stop DMA
+ /* outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR)&(~AINT_WRITE_COMPL),
+ * devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); stop amcc irqs */
+
+ /* outl(inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR)&(~EN_A2P_TRANSFERS),
+ * devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR); stop DMA */
- //Disable ext trigger
+ /* Disable ext trigger */
i_APCI3120_ExttrigDisable(dev);
devpriv->us_OutputRegister = 0;
- //stop counters
+ /* stop counters */
outw(devpriv->
us_OutputRegister & APCI3120_DISABLE_TIMER0 &
APCI3120_DISABLE_TIMER1, dev->iobase + APCI3120_WR_ADDRESS);
outw(APCI3120_DISABLE_ALL_TIMER, dev->iobase + APCI3120_WR_ADDRESS);
- //DISABLE_ALL_INTERRUPT
+ /* DISABLE_ALL_INTERRUPT */
outb(APCI3120_DISABLE_ALL_INTERRUPT,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- //Flush FIFO
+ /* Flush FIFO */
inb(dev->iobase + APCI3120_RESET_FIFO);
inw(dev->iobase + APCI3120_RD_STATUS);
devpriv->ui_AiActualScan = 0;
@@ -476,13 +481,13 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_s
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
- int tmp; // divisor1,divisor2;
+ int tmp; /* divisor1,divisor2; */
- // step 1: make sure trigger sources are trivially valid
+ /* step 1: make sure trigger sources are trivially valid */
tmp = cmd->start_src;
cmd->start_src &= TRIG_NOW | TRIG_EXT;
@@ -512,7 +517,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
if (err)
return 1;
- //step 2: make sure trigger sources are unique and mutually compatible
+ /* step 2: make sure trigger sources are unique and mutually compatible */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) {
err++;
@@ -536,14 +541,14 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
if (err)
return 2;
- // step 3: make sure arguments are trivially compatible
+ /* step 3: make sure arguments are trivially compatible */
if (cmd->start_arg != 0) {
cmd->start_arg = 0;
err++;
}
- if (cmd->scan_begin_src == TRIG_TIMER) // Test Delay timing
+ if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */
{
if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) {
cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs;
@@ -551,7 +556,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
}
}
- if (cmd->convert_src == TRIG_TIMER) // Test Acquisition timing
+ if (cmd->convert_src == TRIG_TIMER) /* Test Acquisition timing */
{
if (cmd->scan_begin_src == TRIG_TIMER) {
if ((cmd->convert_arg)
@@ -585,7 +590,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
cmd->stop_arg = 1;
err++;
}
- } else { // TRIG_NONE
+ } else { /* TRIG_NONE */
if (cmd->stop_arg != 0) {
cmd->stop_arg = 0;
err++;
@@ -595,7 +600,7 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
if (err)
return 3;
- // step 4: fix up any arguments
+ /* step 4: fix up any arguments */
if (cmd->convert_src == TRIG_TIMER) {
@@ -633,19 +638,19 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s)
+int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
- //loading private structure with cmd structure inputs
+ /* loading private structure with cmd structure inputs */
devpriv->ui_AiFlags = cmd->flags;
devpriv->ui_AiNbrofChannels = cmd->chanlist_len;
devpriv->ui_AiScanLength = cmd->scan_end_arg;
devpriv->pui_AiChannelList = cmd->chanlist;
- //UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data;
+ /* UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; */
devpriv->AiData = s->async->prealloc_buf;
- //UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len;
+ /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
devpriv->ui_AiDataLength = s->async->prealloc_bufsz;
if (cmd->stop_src == TRIG_COUNT) {
@@ -654,11 +659,11 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd
devpriv->ui_AiNbrofScans = 0;
}
- devpriv->ui_AiTimer0 = 0; // variables changed to timer0,timer1
+ devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */
devpriv->ui_AiTimer1 = 0;
if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1))
- devpriv->b_AiContinuous = 1; // user want neverending analog acquisition
- // stopped using cancel
+ devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */
+ /* stopped using cancel */
if (cmd->start_src == TRIG_EXT)
devpriv->b_ExttrigEnable = APCI3120_ENABLE;
@@ -666,22 +671,22 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd
devpriv->b_ExttrigEnable = APCI3120_DISABLE;
if (cmd->scan_begin_src == TRIG_FOLLOW) {
- // mode 1 or 3
+ /* mode 1 or 3 */
if (cmd->convert_src == TRIG_TIMER) {
- // mode 1
+ /* mode 1 */
- devpriv->ui_AiTimer0 = cmd->convert_arg; // timer constant in nano seconds
- //return this_board->i_hwdrv_CommandAnalogInput(1,dev,s);
+ devpriv->ui_AiTimer0 = cmd->convert_arg; /* timer constant in nano seconds */
+ /* return this_board->i_hwdrv_CommandAnalogInput(1,dev,s); */
return i_APCI3120_CyclicAnalogInput(1, dev, s);
}
}
if ((cmd->scan_begin_src == TRIG_TIMER)
&& (cmd->convert_src == TRIG_TIMER)) {
- // mode 2
+ /* mode 2 */
devpriv->ui_AiTimer1 = cmd->scan_begin_arg;
- devpriv->ui_AiTimer0 = cmd->convert_arg; // variable changed timer2 to timer0
- //return this_board->i_hwdrv_CommandAnalogInput(2,dev,s);
+ devpriv->ui_AiTimer0 = cmd->convert_arg; /* variable changed timer2 to timer0 */
+ /* return this_board->i_hwdrv_CommandAnalogInput(2,dev,s); */
return i_APCI3120_CyclicAnalogInput(2, dev, s);
}
return -1;
@@ -707,73 +712,74 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
- BYTE b_Tmp;
- UINT ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 =
+ unsigned char b_Tmp;
+ unsigned int ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 =
0, dmalen1 = 0, ui_TimerValue2 =
0, ui_TimerValue0, ui_ConvertTiming;
- USHORT us_TmpValue;
+ unsigned short us_TmpValue;
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
- //devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE;
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
+ /* devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE; */
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
/*******************/
/* Resets the FIFO */
/*******************/
inb(dev->iobase + APCI3120_RESET_FIFO);
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
- //inw(dev->iobase+APCI3120_RD_STATUS);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
+ /* inw(dev->iobase+APCI3120_RD_STATUS); */
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
/***************************/
/* Acquisition initialized */
/***************************/
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
devpriv->b_AiCyclicAcquisition = APCI3120_ENABLE;
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
- // clear software registers
+ /* clear software registers */
devpriv->b_TimerSelectMode = 0;
devpriv->us_OutputRegister = 0;
devpriv->b_ModeSelectRegister = 0;
- //devpriv->b_DigitalOutputRegister=0;
+ /* devpriv->b_DigitalOutputRegister=0; */
- //COMMENT JK 07.05.04: Followings calls are in i_APCI3120_StartAnalogInputAcquisition
+ /* COMMENT JK 07.05.04: Followings calls are in i_APCI3120_StartAnalogInputAcquisition */
- /****************************/
- /* Clear Timer Write TC INT */
- /****************************/
+ /****************************/
+ /* Clear Timer Write TC int */
+ /****************************/
outl(APCI3120_CLEAR_WRITE_TC_INT,
devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_REG_INTCSR);
- /************************************/
+ /************************************/
/* Clears the timer status register */
- /************************************/
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
- //inw(dev->iobase+APCI3120_TIMER_STATUS_REGISTER);
- inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /************************************/
+
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
+ /* inw(dev->iobase+APCI3120_TIMER_STATUS_REGISTER); */
+ /* inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); */
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
- /**************************/
+ /**************************/
/* Disables All Timer */
/* Sets PR and PA to 0 */
- /**************************/
+ /**************************/
devpriv->us_OutputRegister = devpriv->us_OutputRegister &
APCI3120_DISABLE_TIMER0 &
APCI3120_DISABLE_TIMER1 & APCI3120_CLEAR_PA_PR;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
- /*******************/
+ /*******************/
/* Resets the FIFO */
- /*******************/
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+ /*******************/
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
inb(devpriv->iobase + APCI3120_RESET_FIFO);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
devpriv->ui_AiActualScan = 0;
devpriv->ui_AiActualScanPosition = 0;
@@ -781,7 +787,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
devpriv->ui_AiBufferPtr = 0;
devpriv->ui_DmaActualBuffer = 0;
- // value for timer2 minus -2 has to be done .....dunno y??
+ /* value for timer2 minus -2 has to be done .....dunno y?? */
ui_TimerValue2 = devpriv->ui_AiNbrofScans - 2;
ui_ConvertTiming = devpriv->ui_AiTimer0;
@@ -795,31 +801,31 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
devpriv->pui_AiChannelList, 0))
return -EINVAL;
- us_TmpValue = (USHORT) inw(dev->iobase + APCI3120_RD_STATUS);
+ us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS);
/*** EL241003 : add this section in comment because floats must not be used
- if((us_TmpValue & 0x00B0)==0x00B0)
+ if((us_TmpValue & 0x00B0)==0x00B0)
{
- f_ConvertValue=(((float)ui_ConvertTiming * 0.002) - 2);
- ui_TimerValue0=(UINT)f_ConvertValue;
+ f_ConvertValue=(((float)ui_ConvertTiming * 0.002) - 2);
+ ui_TimerValue0=(unsigned int)f_ConvertValue;
if (mode==2)
{
f_DelayValue = (((float)ui_DelayTiming * 0.00002) - 2);
- ui_TimerValue1 = (UINT) f_DelayValue;
+ ui_TimerValue1 = (unsigned int) f_DelayValue;
}
}
- else
+ else
{
f_ConvertValue=(((float)ui_ConvertTiming * 0.0012926) - 1);
- ui_TimerValue0=(UINT)f_ConvertValue;
+ ui_TimerValue0=(unsigned int)f_ConvertValue;
if (mode == 2)
{
f_DelayValue = (((float)ui_DelayTiming * 0.000012926) - 1);
- ui_TimerValue1 = (UINT) f_DelayValue;
+ ui_TimerValue1 = (unsigned int) f_DelayValue;
}
}
***********************************************************************************************/
/*** EL241003 Begin : add this section to replace floats calculation by integer calculations **/
- //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
+ /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */
if ((us_TmpValue & 0x00B0) == 0x00B0
|| !strcmp(this_board->pc_DriverName, "apci3001")) {
ui_TimerValue0 = ui_ConvertTiming * 2 - 2000;
@@ -844,79 +850,82 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
/*** EL241003 End ******************************************************************************/
if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
- i_APCI3120_ExttrigEnable(dev); // activate EXT trigger
+ i_APCI3120_ExttrigEnable(dev); /* activate EXT trigger */
}
switch (mode) {
case 1:
- // init timer0 in mode 2
+ /* init timer0 in mode 2 */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2;
outb(devpriv->b_TimerSelectMode,
dev->iobase + APCI3120_TIMER_CRT1);
- //Select Timer 0
+ /* Select Timer 0 */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_0_WORD;
outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
- //Set the convertion time
- outw(((USHORT) ui_TimerValue0),
+ /* Set the convertion time */
+ outw(((unsigned short) ui_TimerValue0),
dev->iobase + APCI3120_TIMER_VALUE);
break;
case 2:
- // init timer1 in mode 2
+ /* init timer1 in mode 2 */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0xF3) | APCI3120_TIMER_1_MODE_2;
outb(devpriv->b_TimerSelectMode,
dev->iobase + APCI3120_TIMER_CRT1);
- //Select Timer 1
+ /* Select Timer 1 */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_1_WORD;
outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
- //Set the convertion time
- outw(((USHORT) ui_TimerValue1),
+ /* Set the convertion time */
+ outw(((unsigned short) ui_TimerValue1),
dev->iobase + APCI3120_TIMER_VALUE);
- // init timer0 in mode 2
+ /* init timer0 in mode 2 */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2;
outb(devpriv->b_TimerSelectMode,
dev->iobase + APCI3120_TIMER_CRT1);
- //Select Timer 0
+ /* Select Timer 0 */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_0_WORD;
outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0);
- //Set the convertion time
- outw(((USHORT) ui_TimerValue0),
+ /* Set the convertion time */
+ outw(((unsigned short) ui_TimerValue0),
dev->iobase + APCI3120_TIMER_VALUE);
break;
}
- // ##########common for all modes#################
+ /* ##########common for all modes################# */
/***********************/
/* Clears the SCAN bit */
/***********************/
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
- //devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_DISABLE_SCAN;
+
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
+ /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_DISABLE_SCAN; */
+
devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister &
APCI3120_DISABLE_SCAN;
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- // If DMA is disabled
+ /* If DMA is disabled */
if (devpriv->us_UseDma == APCI3120_DISABLE) {
- // disable EOC and enable EOS
+ /* disable EOC and enable EOS */
devpriv->b_InterruptMode = APCI3120_EOS_MODE;
devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
@@ -928,15 +937,17 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
if (!devpriv->b_AiContinuous) {
- // configure Timer2 For counting EOS
- //Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0)
+/*
+ * configure Timer2 For counting EOS Reset gate 2 of Timer 2 to
+ * disable it (Set Bit D14 to 0)
+ */
devpriv->us_OutputRegister =
devpriv->
us_OutputRegister & APCI3120_DISABLE_TIMER2;
outw(devpriv->us_OutputRegister,
dev->iobase + APCI3120_WR_ADDRESS);
- // DISABLE TIMER INTERRUPT
+ /* DISABLE TIMER intERRUPT */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister &
@@ -944,7 +955,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- //(1) Init timer 2 in mode 0 and write timer value
+ /* (1) Init timer 2 in mode 0 and write timer value */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0x0F) |
@@ -952,7 +963,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
outb(devpriv->b_TimerSelectMode,
dev->iobase + APCI3120_TIMER_CRT1);
- //Writing LOW WORD
+ /* Writing LOW unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_LOW_WORD;
@@ -960,7 +971,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
outw(LOWORD(ui_TimerValue2),
dev->iobase + APCI3120_TIMER_VALUE);
- //Writing HIGH WORD
+ /* Writing HIGH unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_HIGH_WORD;
@@ -968,20 +979,20 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
outw(HIWORD(ui_TimerValue2),
dev->iobase + APCI3120_TIMER_VALUE);
- //(2) Reset FC_TIMER BIT Clearing timer status register
+ /* (2) Reset FC_TIMER BIT Clearing timer status register */
inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
- // enable timer counter and disable watch dog
+ /* enable timer counter and disable watch dog */
devpriv->b_ModeSelectRegister =
(devpriv->
b_ModeSelectRegister |
APCI3120_ENABLE_TIMER_COUNTER) &
APCI3120_DISABLE_WATCHDOG;
- // select EOS clock input for timer 2
+ /* select EOS clock input for timer 2 */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister |
APCI3120_TIMER2_SELECT_EOS;
- // Enable timer2 interrupt
+ /* Enable timer2 interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister |
@@ -992,15 +1003,16 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
devpriv->b_Timer2Interrupt = APCI3120_ENABLE;
}
} else {
- // If DMA Enabled
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
- //inw(dev->iobase+0);// reset EOC bit
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* If DMA Enabled */
+
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
+ /* inw(dev->iobase+0); reset EOC bit */
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
devpriv->b_InterruptMode = APCI3120_DMA_MODE;
- /************************************/
+ /************************************/
/* Disables the EOC, EOS interrupt */
- /************************************/
+ /************************************/
devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister &
APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT;
@@ -1012,18 +1024,18 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
if (!devpriv->b_AiContinuous) {
- if (dmalen0 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2)) { // must we fill full first buffer?
+ if (dmalen0 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2)) { /* must we fill full first buffer? */
dmalen0 =
devpriv->ui_AiNbrofScans *
devpriv->ui_AiScanLength * 2;
- } else if (dmalen1 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2 - dmalen0)) // and must we fill full second buffer when first is once filled?
+ } else if (dmalen1 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2 - dmalen0)) /* and must we fill full second buffer when first is once filled? */
dmalen1 =
devpriv->ui_AiNbrofScans *
devpriv->ui_AiScanLength * 2 - dmalen0;
}
if (devpriv->ui_AiFlags & TRIG_WAKE_EOS) {
- // don't we want wake up every scan?
+ /* don't we want wake up every scan? */
if (dmalen0 > (devpriv->ui_AiScanLength * 2)) {
dmalen0 = devpriv->ui_AiScanLength * 2;
if (devpriv->ui_AiScanLength & 1)
@@ -1036,7 +1048,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
if (dmalen1 < 4)
dmalen1 = 4;
}
- } else { // isn't output buff smaller that our DMA buff?
+ } else { /* isn't output buff smaller that our DMA buff? */
if (dmalen0 > (devpriv->ui_AiDataLength)) {
dmalen0 = devpriv->ui_AiDataLength;
}
@@ -1047,14 +1059,16 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
devpriv->ui_DmaBufferUsesize[0] = dmalen0;
devpriv->ui_DmaBufferUsesize[1] = dmalen1;
- //Initialize DMA
+ /* Initialize DMA */
- // Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS register
- //1
+/*
+ * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS
+ * register 1
+ */
ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS);
- // changed since 16 bit interface for add on
+ /* changed since 16 bit interface for add on */
/*********************/
/* ENABLE BUS MASTER */
/*********************/
@@ -1066,104 +1080,121 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH,
devpriv->i_IobaseAddon + 2);
- // TO VERIFIED
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+/*
+ * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux
+ * driver
+ */
outw(0x1000, devpriv->i_IobaseAddon + 2);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
- //2 No change
- // A2P FIFO MANAGEMENT
- // A2P fifo reset & transfer control enable
- /***********************/
+ /* 2 No change */
/* A2P FIFO MANAGEMENT */
- /***********************/
+ /* A2P fifo reset & transfer control enable */
+
+ /***********************/
+ /* A2P FIFO MANAGEMENT */
+ /***********************/
outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc +
APCI3120_AMCC_OP_MCSR);
- //3
- //beginning address of dma buf
- //The 32 bit address of dma buffer is converted into two 16 bit addresses
- // Can done by using _attach and put into into an array
- // array used may be for differnet pages
+/*
+ * 3
+ * beginning address of dma buf The 32 bit address of dma buffer
+ * is converted into two 16 bit addresses Can done by using _attach
+ * and put into into an array array used may be for differnet pages
+ */
- // DMA Start Adress Low
+ /* DMA Start Adress Low */
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
outw((devpriv->ul_DmaBufferHw[0] & 0xFFFF),
devpriv->i_IobaseAddon + 2);
- /*************************/
+ /*************************/
/* DMA Start Adress High */
- /*************************/
+ /*************************/
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw((devpriv->ul_DmaBufferHw[0] / 65536),
devpriv->i_IobaseAddon + 2);
- //4
- // amount of bytes to be transfered set transfer count
- // used ADDON MWTC register
- //commented testing outl(devpriv->ui_DmaBufferUsesize[0], devpriv->i_IobaseAddon+AMCC_OP_REG_AMWTC);
-
- /**************************/
+/*
+ * 4
+ * amount of bytes to be transfered set transfer count used ADDON
+ * MWTC register commented testing
+ * outl(devpriv->ui_DmaBufferUsesize[0],
+ * devpriv->i_IobaseAddon+AMCC_OP_REG_AMWTC);
+ */
+
+ /**************************/
/* Nbr of acquisition LOW */
- /**************************/
+ /**************************/
outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
outw((devpriv->ui_DmaBufferUsesize[0] & 0xFFFF),
devpriv->i_IobaseAddon + 2);
- /***************************/
+ /***************************/
/* Nbr of acquisition HIGH */
- /***************************/
+ /***************************/
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw((devpriv->ui_DmaBufferUsesize[0] / 65536),
devpriv->i_IobaseAddon + 2);
- //5
- // To configure A2P FIFO
- // testing outl( FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);
+/*
+ * 5
+ * To configure A2P FIFO testing outl(
+ * FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);
+ */
/******************/
/* A2P FIFO RESET */
/******************/
- // TO VERIFY
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+/*
+ * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux
+ * driver
+ */
outl(0x04000000UL, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+
+/*
+ * 6
+ * ENABLE A2P FIFO WRITE AND ENABLE AMWEN AMWEN_ENABLE |
+ * A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+ */
- //6
- //ENABLE A2P FIFO WRITE AND ENABLE AMWEN
- // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
- //outw(3,devpriv->i_IobaseAddon + 4);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
+ /* outw(3,devpriv->i_IobaseAddon + 4); */
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
- //7
- //initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI)
+/*
+ * 7
+ * initialise end of dma interrupt AINT_WRITE_COMPL =
+ * ENABLE_WRITE_TC_INT(ADDI)
+ */
/***************************************************/
- /* A2P FIFO CONFIGURATE, END OF DMA INTERRUPT INIT */
+ /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */
/***************************************************/
outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
APCI3120_ENABLE_WRITE_TC_INT),
devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
/******************************************/
/* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */
/******************************************/
outw(3, devpriv->i_IobaseAddon + 4);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
/******************/
/* A2P FIFO RESET */
/******************/
- //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
outl(0x04000000UL,
devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_MCSR);
- //END JK 07.05.04: Comparison between WIN32 and Linux driver
+ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
}
if ((devpriv->us_UseDma == APCI3120_DISABLE)
&& !devpriv->b_AiContinuous) {
- // set gate 2 to start conversion
+ /* set gate 2 to start conversion */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER2;
outw(devpriv->us_OutputRegister,
@@ -1172,14 +1203,14 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
switch (mode) {
case 1:
- // set gate 0 to start conversion
+ /* set gate 0 to start conversion */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER0;
outw(devpriv->us_OutputRegister,
dev->iobase + APCI3120_WR_ADDRESS);
break;
case 2:
- // set gate 0 and gate 1
+ /* set gate 0 and gate 1 */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER1;
devpriv->us_OutputRegister =
@@ -1196,7 +1227,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| INTERNAL FUNCTIONS |
+| intERNAL FUNCTIONS |
+----------------------------------------------------------------------------+
*/
@@ -1218,7 +1249,7 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_Reset(struct comedi_device * dev)
+int i_APCI3120_Reset(struct comedi_device *dev)
{
unsigned int i;
unsigned short us_TmpValue;
@@ -1226,47 +1257,49 @@ int i_APCI3120_Reset(struct comedi_device * dev)
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
- devpriv->ui_EocEosConversionTime = 0; // set eoc eos conv time to 0
+ devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */
devpriv->b_OutputMemoryStatus = 0;
- // variables used in timer subdevice
+ /* variables used in timer subdevice */
devpriv->b_Timer2Mode = 0;
devpriv->b_Timer2Interrupt = 0;
- devpriv->b_ExttrigEnable = 0; // Disable ext trigger
+ devpriv->b_ExttrigEnable = 0; /* Disable ext trigger */
/* Disable all interrupts, watchdog for the anolog output */
devpriv->b_ModeSelectRegister = 0;
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- // Disables all counters, ext trigger and clears PA, PR
+ /* Disables all counters, ext trigger and clears PA, PR */
devpriv->us_OutputRegister = 0;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
- //Code to set the all anolog o/p channel to 0v
- //8191 is decimal value for zero(0 v)volt in bipolar mode(default)
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 1
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 2
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 3
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); //channel 4
-
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 5
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 6
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 7
- outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); //channel 8
-
- // Reset digital output to L0W
-
-//ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT);
+/*
+ * Code to set the all anolog o/p channel to 0v 8191 is decimal
+ * value for zero(0 v)volt in bipolar mode(default)
+ */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 1 */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 2 */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 3 */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 4 */
+
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 5 */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 6 */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 7 */
+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 8 */
+
+ /* Reset digital output to L0W */
+
+/* ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); */
udelay(10);
- inw(dev->iobase + 0); //make a dummy read
- inb(dev->iobase + APCI3120_RESET_FIFO); // flush FIFO
- inw(dev->iobase + APCI3120_RD_STATUS); // flush A/D status register
+ inw(dev->iobase + 0); /* make a dummy read */
+ inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */
+ inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */
- //code to reset the RAM sequence
+ /* code to reset the RAM sequence */
for (i = 0; i < 16; i++) {
- us_TmpValue = i << 8; //select the location
+ us_TmpValue = i << 8; /* select the location */
outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
}
return 0;
@@ -1296,10 +1329,10 @@ int i_APCI3120_Reset(struct comedi_device * dev)
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdevice * s,
+int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, char check)
{
- unsigned int i; //, differencial=0, bipolar=0;
+ unsigned int i; /* , differencial=0, bipolar=0; */
unsigned int gain;
unsigned short us_TmpValue;
@@ -1309,29 +1342,29 @@ int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdev
comedi_error(dev, "range/channel list is empty!");
return 0;
}
- // All is ok, so we can setup channel/range list
+ /* All is ok, so we can setup channel/range list */
if (check)
return 1;
- //Code to set the PA and PR...Here it set PA to 0..
+ /* Code to set the PA and PR...Here it set PA to 0.. */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR;
devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
for (i = 0; i < n_chan; i++) {
- // store range list to card
- us_TmpValue = CR_CHAN(chanlist[i]); // get channel number;
+ /* store range list to card */
+ us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */
if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) {
- us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); // set bipolar
+ us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */
} else {
- us_TmpValue |= APCI3120_UNIPOLAR; // enable unipolar......
+ us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar...... */
}
- gain = CR_RANGE(chanlist[i]); // get gain number
- us_TmpValue |= ((gain & 0x03) << 4); //<<4 for G0 and G1 bit in RAM
- us_TmpValue |= i << 8; //To select the RAM LOCATION....
+ gain = CR_RANGE(chanlist[i]); /* get gain number */
+ us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */
+ us_TmpValue |= i << 8; /* To select the RAM LOCATION.... */
outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
printk("\n Gain = %i",
@@ -1339,7 +1372,7 @@ int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdev
printk("\n Channel = %i", CR_CHAN(chanlist[i]));
printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
}
- return 1; // we can serve this with scan logic
+ return 1; /* we can serve this with scan logic */
}
/*
@@ -1360,7 +1393,7 @@ int i_APCI3120_SetupChannelList(struct comedi_device * dev, struct comedi_subdev
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_ExttrigEnable(struct comedi_device * dev)
+int i_APCI3120_ExttrigEnable(struct comedi_device *dev)
{
devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER;
@@ -1385,7 +1418,7 @@ int i_APCI3120_ExttrigEnable(struct comedi_device * dev)
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_ExttrigDisable(struct comedi_device * dev)
+int i_APCI3120_ExttrigDisable(struct comedi_device *dev)
{
devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
@@ -1394,7 +1427,7 @@ int i_APCI3120_ExttrigDisable(struct comedi_device * dev)
/*
+----------------------------------------------------------------------------+
-| INTERRUPT FUNCTIONS |
+| intERRUPT FUNCTIONS |
+----------------------------------------------------------------------------+
*/
@@ -1422,33 +1455,33 @@ int i_APCI3120_ExttrigDisable(struct comedi_device * dev)
void v_APCI3120_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- USHORT int_daq;
+ unsigned short int_daq;
unsigned int int_amcc, ui_Check, i;
- USHORT us_TmpValue;
- BYTE b_DummyRead;
+ unsigned short us_TmpValue;
+ unsigned char b_DummyRead;
struct comedi_subdevice *s = dev->subdevices + 0;
ui_Check = 1;
- int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; // get IRQ reasons
- int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); // get AMCC INT register
+ int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; /* get IRQ reasons */
+ int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* get AMCC int register */
if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) {
comedi_error(dev, "IRQ from unknow source");
return;
}
- outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); // shutdown IRQ reasons in AMCC
+ outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */
int_daq = (int_daq >> 12) & 0xF;
if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
- //Disable ext trigger
+ /* Disable ext trigger */
i_APCI3120_ExttrigDisable(dev);
devpriv->b_ExttrigEnable = APCI3120_DISABLE;
}
- //clear the timer 2 interrupt
+ /* clear the timer 2 interrupt */
inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER);
if (int_amcc & MASTER_ABORT_INT)
@@ -1456,19 +1489,19 @@ void v_APCI3120_Interrupt(int irq, void *d)
if (int_amcc & TARGET_ABORT_INT)
comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!");
- // Ckeck if EOC interrupt
+ /* Ckeck if EOC interrupt */
if (((int_daq & 0x8) == 0)
&& (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) {
if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
- // Read the AI Value
+ /* Read the AI Value */
devpriv->ui_AiReadData[0] =
- (UINT) inw(devpriv->iobase + 0);
+ (unsigned int) inw(devpriv->iobase + 0);
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
} else {
- //Disable EOC Interrupt
+ /* Disable EOC Interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT;
@@ -1478,10 +1511,10 @@ void v_APCI3120_Interrupt(int irq, void *d)
}
}
- // Check If EOS interrupt
+ /* Check If EOS interrupt */
if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) {
- if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) // enable this in without DMA ???
+ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) /* enable this in without DMA ??? */
{
if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
@@ -1501,12 +1534,12 @@ void v_APCI3120_Interrupt(int irq, void *d)
i++) {
us_TmpValue = inw(devpriv->iobase + 0);
devpriv->ui_AiReadData[i] =
- (UINT) us_TmpValue;
+ (unsigned int) us_TmpValue;
}
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
}
@@ -1516,12 +1549,12 @@ void v_APCI3120_Interrupt(int irq, void *d)
b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT;
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- devpriv->b_EocEosInterrupt = APCI3120_DISABLE; //Default settings
+ devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
}
}
- //Timer2 interrupt
+ /* Timer2 interrupt */
if (int_daq & 0x1) {
switch (devpriv->b_Timer2Mode) {
@@ -1534,18 +1567,18 @@ void v_APCI3120_Interrupt(int irq, void *d)
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- // stop timer 2
+ /* stop timer 2 */
devpriv->us_OutputRegister =
devpriv->
us_OutputRegister & APCI3120_DISABLE_ALL_TIMER;
outw(devpriv->us_OutputRegister,
dev->iobase + APCI3120_WR_ADDRESS);
- //stop timer 0 and timer 1
+ /* stop timer 0 and timer 1 */
i_APCI3120_StopCyclicAcquisition(dev, s);
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
- //UPDATE-0.7.57->0.7.68comedi_done(dev,s);
+ /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
@@ -1553,19 +1586,19 @@ void v_APCI3120_Interrupt(int irq, void *d)
case APCI3120_TIMER:
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
break;
case APCI3120_WATCHDOG:
- //Send a signal to from kernel to user space
+ /* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
break;
default:
- // disable Timer Interrupt
+ /* disable Timer Interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
@@ -1585,7 +1618,7 @@ void v_APCI3120_Interrupt(int irq, void *d)
if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
/****************************/
- /* Clear Timer Write TC INT */
+ /* Clear Timer Write TC int */
/****************************/
outl(APCI3120_CLEAR_WRITE_TC_INT,
@@ -1596,7 +1629,7 @@ void v_APCI3120_Interrupt(int irq, void *d)
/* Clears the timer status register */
/************************************/
inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
- v_APCI3120_InterruptDma(irq, d); // do some data transfer
+ v_APCI3120_InterruptDma(irq, d); /* do some data transfer */
} else {
/* Stops the Timer */
outw(devpriv->
@@ -1630,32 +1663,8 @@ void v_APCI3120_Interrupt(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-/*
- * int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)
-{
- int n_chan,i;
- short *data;
- struct comedi_subdevice *s=dev->subdevices+0;
- struct comedi_async *async = s->async;
- data=async->data+async->buf_int_ptr;
- n_chan=devpriv->ui_AiNbrofChannels;
-
- for(i=0;i<n_chan;i++)
- {
- data[i]=inw(dev->iobase+0);
- }
- async->buf_int_count+=n_chan*sizeof(short);
- async->buf_int_ptr+=n_chan*sizeof(short);
- comedi_eos(dev,s);
- if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over
- {
-*//* buffer rollover */
-/* s->async->buf_int_ptr=0;
- comedi_eobuf(dev,s);
- }
- return 0;
-}*/
-int i_APCI3120_InterruptHandleEos(struct comedi_device * dev)
+
+int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)
{
int n_chan, i;
struct comedi_subdevice *s = dev->subdevices + 0;
@@ -1704,7 +1713,7 @@ void v_APCI3120_InterruptDma(int irq, void *d)
unsigned int next_dma_buf, samplesinbuf;
unsigned long low_word, high_word, var;
- UINT ui_Tmp;
+ unsigned int ui_Tmp;
samplesinbuf =
devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer] -
inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC);
@@ -1720,20 +1729,20 @@ void v_APCI3120_InterruptDma(int irq, void *d)
return;
}
- samplesinbuf = samplesinbuf >> 1; // number of received samples
+ samplesinbuf = samplesinbuf >> 1; /* number of received samples */
if (devpriv->b_DmaDoubleBuffer) {
- // switch DMA buffers if is used double buffering
+ /* switch DMA buffers if is used double buffering */
next_dma_buf = 1 - devpriv->ui_DmaActualBuffer;
ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
- // changed since 16 bit interface for add on
+ /* changed since 16 bit interface for add on */
outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
- outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); // 0x1000 is out putted in windows driver
+ outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* 0x1000 is out putted in windows driver */
var = devpriv->ul_DmaBufferHw[next_dma_buf];
low_word = var & 0xffff;
@@ -1761,54 +1770,18 @@ void v_APCI3120_InterruptDma(int irq, void *d)
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
- // To configure A2P FIFO
- // ENABLE A2P FIFO WRITE AND ENABLE AMWEN
- // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+/*
+ * To configure A2P FIFO
+ * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
+ * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+ */
outw(3, devpriv->i_IobaseAddon + 4);
- //initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI)
+ /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
APCI3120_ENABLE_WRITE_TC_INT),
devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
}
-/*UPDATE-0.7.57->0.7.68
- ptr=(short *)devpriv->ul_DmaBufferVirtual[devpriv->ui_DmaActualBuffer];
-
-
- // if there is not enough space left in the buffer to copy all data contained in the DMABufferVirtual
- if(s->async->buf_int_ptr+samplesinbuf*sizeof(short)>=devpriv->ui_AiDataLength)
- {
- m=(devpriv->ui_AiDataLength-s->async->buf_int_ptr)/sizeof(short);
- v_APCI3120_InterruptDmaMoveBlock16bit(dev,s,(void *)ptr,((void *)(devpriv->AiData))+s->async->buf_int_ptr,m);
- s->async->buf_int_count+=m*sizeof(short);
- ptr+=m*sizeof(short);
- samplesinbuf-=m;
- s->async->buf_int_ptr=0;
- comedi_eobuf(dev,s);
- }
-
- if (samplesinbuf)
- {
- v_APCI3120_InterruptDmaMoveBlock16bit(dev,s,(void *)ptr,((void *)(devpriv->AiData))+s->async->buf_int_ptr,samplesinbuf);
-
- s->async->buf_int_count+=samplesinbuf*sizeof(short);
- s->async->buf_int_ptr+=samplesinbuf*sizeof(short);
- if (!(devpriv->ui_AiFlags & TRIG_WAKE_EOS))
- {
- comedi_bufcheck(dev,s);
- }
- }
- if (!devpriv->b_AiContinuous)
- if ( devpriv->ui_AiActualScan>=devpriv->ui_AiNbrofScans )
- {
- // all data sampled
- i_APCI3120_StopCyclicAcquisition(dev,s);
- devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE;
- //DPRINTK("\n Single DMA completed..\n");
- comedi_done(dev,s);
- return;
- }
-*/
if (samplesinbuf) {
v_APCI3120_InterruptDmaMoveBlock16bit(dev, s,
devpriv->ul_DmaBufferVirtual[devpriv->
@@ -1821,7 +1794,7 @@ void v_APCI3120_InterruptDma(int irq, void *d)
}
if (!devpriv->b_AiContinuous)
if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) {
- // all data sampled
+ /* all data sampled */
i_APCI3120_StopCyclicAcquisition(dev, s);
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
s->async->events |= COMEDI_CB_EOA;
@@ -1829,22 +1802,26 @@ void v_APCI3120_InterruptDma(int irq, void *d)
return;
}
- if (devpriv->b_DmaDoubleBuffer) { // switch dma buffers
+ if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */
devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer;
} else {
- // restart DMA if is not used double buffering
- //ADDED REINITIALISE THE DMA
+/*
+ * restart DMA if is not used double buffering
+ * ADDED REINITIALISE THE DMA
+ */
ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
- // changed since 16 bit interface for add on
+ /* changed since 16 bit interface for add on */
outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
- outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); //
- // A2P FIFO MANAGEMENT
- // A2P fifo reset & transfer control enable
+ outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* */
+/*
+ * A2P FIFO MANAGEMENT
+ * A2P fifo reset & transfer control enable
+ */
outl(APCI3120_A2P_FIFO_MANAGEMENT,
devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
@@ -1858,7 +1835,7 @@ void v_APCI3120_InterruptDma(int irq, void *d)
outw(high_word, devpriv->i_IobaseAddon + 2);
var = devpriv->ui_DmaBufferUsesize[0];
- low_word = var & 0xffff; //changed
+ low_word = var & 0xffff; /* changed */
var = devpriv->ui_DmaBufferUsesize[0];
high_word = var / 65536;
outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
@@ -1866,11 +1843,13 @@ void v_APCI3120_InterruptDma(int irq, void *d)
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
- // To configure A2P FIFO
- //ENABLE A2P FIFO WRITE AND ENABLE AMWEN
- // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+/*
+ * To configure A2P FIFO
+ * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
+ * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+ */
outw(3, devpriv->i_IobaseAddon + 4);
- //initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI)
+ /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
APCI3120_ENABLE_WRITE_TC_INT),
devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
@@ -1897,37 +1876,8 @@ void v_APCI3120_InterruptDma(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-/*void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n)
-{
- int i,j,m;
-
- j=s->async->cur_chan;
- m=devpriv->ui_AiActualScanPosition;
- for(i=0;i<n;i++)
- {
- *data=*dma;
- data++; dma++;
- j++;
- if(j>=devpriv->ui_AiNbrofChannels)
- {
- m+=j;
- j=0;
- if(m>=devpriv->ui_AiScanLength)
- {
- m=0;
- devpriv->ui_AiActualScan++;
- if (devpriv->ui_AiFlags & TRIG_WAKE_EOS)
-;//UPDATE-0.7.57->0.7.68 comedi_eos(dev,s);
- }
- }
- }
- devpriv->ui_AiActualScanPosition=m;
- s->async->cur_chan=j;
-
-}
-*/
-void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device * dev,
- struct comedi_subdevice * s, short * dma_buffer, unsigned int num_samples)
+void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
+ struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples)
{
devpriv->ui_AiActualScan +=
(s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength;
@@ -1968,71 +1918,77 @@ void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Timervalue2;
- USHORT us_TmpValue;
- BYTE b_Tmp;
+ unsigned int ui_Timervalue2;
+ unsigned short us_TmpValue;
+ unsigned char b_Tmp;
if (!data[1])
comedi_error(dev, "config:No timer constant !");
- devpriv->b_Timer2Interrupt = (BYTE) data[2]; // save info whether to enable or disable interrupt
+ devpriv->b_Timer2Interrupt = (unsigned char) data[2]; /* save info whether to enable or disable interrupt */
- ui_Timervalue2 = data[1] / 1000; // convert nano seconds to u seconds
+ ui_Timervalue2 = data[1] / 1000; /* convert nano seconds to u seconds */
- //this_board->i_hwdrv_InsnConfigTimer(dev, ui_Timervalue2,(BYTE)data[0]);
- us_TmpValue = (USHORT) inw(devpriv->iobase + APCI3120_RD_STATUS);
+ /* this_board->i_hwdrv_InsnConfigTimer(dev, ui_Timervalue2,(unsigned char)data[0]); */
+ us_TmpValue = (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
- //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
- // and calculate the time value to set in the timer
+/*
+ * EL250804: Testing if board APCI3120 have the new Quartz or if it
+ * is an APCI3001 and calculate the time value to set in the timer
+ */
if ((us_TmpValue & 0x00B0) == 0x00B0
|| !strcmp(this_board->pc_DriverName, "apci3001")) {
- //Calculate the time value to set in the timer
+ /* Calculate the time value to set in the timer */
ui_Timervalue2 = ui_Timervalue2 / 50;
} else {
- //Calculate the time value to set in the timer
+ /* Calculate the time value to set in the timer */
ui_Timervalue2 = ui_Timervalue2 / 70;
}
- //Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0)
+ /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER2;
outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS);
- // Disable TIMER Interrupt
+ /* Disable TIMER Interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister & APCI3120_DISABLE_TIMER_INT & 0xEF;
- // Disable Eoc and Eos Interrupts
+ /* Disable Eoc and Eos Interrupts */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT &
APCI3120_DISABLE_EOS_INT;
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
- if (data[0] == APCI3120_TIMER) //initialize timer
+ if (data[0] == APCI3120_TIMER) /* initialize timer */
{
+ /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister |
+ * APCI3120_ENABLE_TIMER_INT; */
- //devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister| APCI3120_ENABLE_TIMER_INT ;
- //outb(devpriv->b_ModeSelectRegister,devpriv->iobase+APCI3120_WRITE_MODE_SELECT);
+ /* outb(devpriv->b_ModeSelectRegister,devpriv->iobase+APCI3120_WRITE_MODE_SELECT); */
- //Set the Timer 2 in mode 2(Timer)
+ /* Set the Timer 2 in mode 2(Timer) */
devpriv->b_TimerSelectMode =
(devpriv->
b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_2;
outb(devpriv->b_TimerSelectMode,
devpriv->iobase + APCI3120_TIMER_CRT1);
- //Configure the timer 2 for writing the LOW WORD of timer is Delay value
- //You must make a b_tmp variable with DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0
- //you can set the digital output and configure the timer 2,and if you don't make this, digital output
- //are erase (Set to 0)
-
- //Writing LOW WORD
+/*
+ * Configure the timer 2 for writing the LOW unsigned short of timer
+ * is Delay value You must make a b_tmp variable with
+ * DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0
+ * you can set the digital output and configure the timer 2,and if
+ * you don't make this, digital output are erase (Set to 0)
+ */
+
+ /* Writing LOW unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_LOW_WORD;
@@ -2040,20 +1996,20 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi
outw(LOWORD(ui_Timervalue2),
devpriv->iobase + APCI3120_TIMER_VALUE);
- //Writing HIGH WORD
+ /* Writing HIGH unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_HIGH_WORD;
outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0);
outw(HIWORD(ui_Timervalue2),
devpriv->iobase + APCI3120_TIMER_VALUE);
- // timer2 in Timer mode enabled
+ /* timer2 in Timer mode enabled */
devpriv->b_Timer2Mode = APCI3120_TIMER;
- } else // Initialize Watch dog
+ } else /* Initialize Watch dog */
{
- //Set the Timer 2 in mode 5(Watchdog)
+ /* Set the Timer 2 in mode 5(Watchdog) */
devpriv->b_TimerSelectMode =
(devpriv->
@@ -2061,12 +2017,15 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi
outb(devpriv->b_TimerSelectMode,
devpriv->iobase + APCI3120_TIMER_CRT1);
- //Configure the timer 2 for writing the LOW WORD of timer is Delay value
- //You must make a b_tmp variable with DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0
- //you can set the digital output and configure the timer 2,and if you don't make this, digital output
- //are erase (Set to 0)
-
- //Writing LOW WORD
+/*
+ * Configure the timer 2 for writing the LOW unsigned short of timer
+ * is Delay value You must make a b_tmp variable with
+ * DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0
+ * you can set the digital output and configure the timer 2,and if
+ * you don't make this, digital output are erase (Set to 0)
+ */
+
+ /* Writing LOW unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_LOW_WORD;
@@ -2074,7 +2033,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi
outw(LOWORD(ui_Timervalue2),
devpriv->iobase + APCI3120_TIMER_VALUE);
- //Writing HIGH WORD
+ /* Writing HIGH unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_HIGH_WORD;
@@ -2082,7 +2041,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi
outw(HIWORD(ui_Timervalue2),
devpriv->iobase + APCI3120_TIMER_VALUE);
- //watchdog enabled
+ /* watchdog enabled */
devpriv->b_Timer2Mode = APCI3120_WATCHDOG;
}
@@ -2119,13 +2078,13 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device * dev, struct comedi_subdevi
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Timervalue2 = 0;
- USHORT us_TmpValue;
- BYTE b_Tmp;
+ unsigned int ui_Timervalue2 = 0;
+ unsigned short us_TmpValue;
+ unsigned char b_Tmp;
if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG)
&& (devpriv->b_Timer2Mode != APCI3120_TIMER)) {
@@ -2133,7 +2092,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
return -EINVAL;
}
- if (data[0] == 2) // write new value
+ if (data[0] == 2) /* write new value */
{
if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
comedi_error(dev,
@@ -2147,35 +2106,35 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
ui_Timervalue2 = 0;
}
- //this_board->i_hwdrv_InsnWriteTimer(dev,data[0],ui_Timervalue2);
+ /* this_board->i_hwdrv_InsnWriteTimer(dev,data[0],ui_Timervalue2); */
switch (data[0]) {
case APCI3120_START:
- // Reset FC_TIMER BIT
+ /* Reset FC_TIMER BIT */
inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
- if (devpriv->b_Timer2Mode == APCI3120_TIMER) //start timer
+ if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */
{
- //Enable Timer
+ /* Enable Timer */
devpriv->b_ModeSelectRegister =
devpriv->b_ModeSelectRegister & 0x0B;
- } else //start watch dog
+ } else /* start watch dog */
{
- //Enable WatchDog
+ /* Enable WatchDog */
devpriv->b_ModeSelectRegister =
(devpriv->
b_ModeSelectRegister & 0x0B) |
APCI3120_ENABLE_WATCHDOG;
}
- //enable disable interrupt
+ /* enable disable interrupt */
if ((devpriv->b_Timer2Interrupt) == APCI3120_ENABLE) {
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister |
APCI3120_ENABLE_TIMER_INT;
- // save the task structure to pass info to user
+ /* save the task structure to pass info to user */
devpriv->tsk_Current = current;
} else {
@@ -2187,9 +2146,9 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
- if (devpriv->b_Timer2Mode == APCI3120_TIMER) //start timer
+ if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */
{
- //For Timer mode is Gate2 must be activated **timer started
+ /* For Timer mode is Gate2 must be activated **timer started */
devpriv->us_OutputRegister =
devpriv->
us_OutputRegister | APCI3120_ENABLE_TIMER2;
@@ -2201,62 +2160,64 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
case APCI3120_STOP:
if (devpriv->b_Timer2Mode == APCI3120_TIMER) {
- //Disable timer
+ /* Disable timer */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister &
APCI3120_DISABLE_TIMER_COUNTER;
} else {
- //Disable WatchDog
+ /* Disable WatchDog */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister &
APCI3120_DISABLE_WATCHDOG;
}
- // Disable timer interrupt
+ /* Disable timer interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister & APCI3120_DISABLE_TIMER_INT;
- // Write above states to register
+ /* Write above states to register */
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
- // Reset Gate 2
+ /* Reset Gate 2 */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER_INT;
outw(devpriv->us_OutputRegister,
devpriv->iobase + APCI3120_WR_ADDRESS);
- // Reset FC_TIMER BIT
+ /* Reset FC_TIMER BIT */
inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
- // Disable timer
- //devpriv->b_Timer2Mode=APCI3120_DISABLE;
+ /* Disable timer */
+ /* devpriv->b_Timer2Mode=APCI3120_DISABLE; */
break;
- case 2: //write new value to Timer
+ case 2: /* write new value to Timer */
if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
comedi_error(dev,
"write :timer2 not configured in TIMER MODE");
return -EINVAL;
}
- // ui_Timervalue2=data[1]; // passed as argument
+ /* ui_Timervalue2=data[1]; // passed as argument */
us_TmpValue =
- (USHORT) inw(devpriv->iobase + APCI3120_RD_STATUS);
+ (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
- //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
- // and calculate the time value to set in the timer
+/*
+ * EL250804: Testing if board APCI3120 have the new Quartz or if it
+ * is an APCI3001 and calculate the time value to set in the timer
+ */
if ((us_TmpValue & 0x00B0) == 0x00B0
|| !strcmp(this_board->pc_DriverName, "apci3001")) {
- //Calculate the time value to set in the timer
+ /* Calculate the time value to set in the timer */
ui_Timervalue2 = ui_Timervalue2 / 50;
} else {
- //Calculate the time value to set in the timer
+ /* Calculate the time value to set in the timer */
ui_Timervalue2 = ui_Timervalue2 / 70;
}
- //Writing LOW WORD
+ /* Writing LOW unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_LOW_WORD;
@@ -2265,7 +2226,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
outw(LOWORD(ui_Timervalue2),
devpriv->iobase + APCI3120_TIMER_VALUE);
- //Writing HIGH WORD
+ /* Writing HIGH unsigned short */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_HIGH_WORD;
@@ -2276,7 +2237,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
break;
default:
- return -EINVAL; // Not a valid input
+ return -EINVAL; /* Not a valid input */
}
return insn->n;
@@ -2305,21 +2266,21 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device * dev, struct comedi_subdevic
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnReadTimer(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_Tmp;
- USHORT us_TmpValue, us_TmpValue_2, us_StatusValue;
+ unsigned char b_Tmp;
+ unsigned short us_TmpValue, us_TmpValue_2, us_StatusValue;
if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG)
&& (devpriv->b_Timer2Mode != APCI3120_TIMER)) {
comedi_error(dev, "\nread:timer2 not configured ");
}
- //this_board->i_hwdrv_InsnReadTimer(dev,data);
+ /* this_board->i_hwdrv_InsnReadTimer(dev,data); */
if (devpriv->b_Timer2Mode == APCI3120_TIMER) {
- //Read the LOW WORD of Timer 2 register
+ /* Read the LOW unsigned short of Timer 2 register */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_LOW_WORD;
@@ -2327,7 +2288,7 @@ int i_APCI3120_InsnReadTimer(struct comedi_device * dev, struct comedi_subdevice
us_TmpValue = inw(devpriv->iobase + APCI3120_TIMER_VALUE);
- //Read the HIGH WORD of Timer 2 register
+ /* Read the HIGH unsigned short of Timer 2 register */
b_Tmp = ((devpriv->
b_DigitalOutputRegister) & 0xF0) |
APCI3120_SELECT_TIMER_2_HIGH_WORD;
@@ -2335,20 +2296,20 @@ int i_APCI3120_InsnReadTimer(struct comedi_device * dev, struct comedi_subdevice
us_TmpValue_2 = inw(devpriv->iobase + APCI3120_TIMER_VALUE);
- // combining both words
- data[0] = (UINT) ((us_TmpValue) | ((us_TmpValue_2) << 16));
+ /* combining both words */
+ data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16));
- } else // Read watch dog status
+ } else /* Read watch dog status */
{
us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS);
us_StatusValue =
((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1;
if (us_StatusValue == 1) {
- // RESET FC_TIMER BIT
+ /* RESET FC_TIMER BIT */
inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
}
- data[0] = us_StatusValue; // when data[0] = 1 then the watch dog has rundown
+ data[0] = us_StatusValue; /* when data[0] = 1 then the watch dog has rundown */
}
return insn->n;
}
@@ -2384,21 +2345,23 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
- UINT ui_Chan, ui_TmpValue;
+ unsigned int ui_Chan, ui_TmpValue;
- ui_Chan = CR_CHAN(insn->chanspec); // channel specified
+ ui_Chan = CR_CHAN(insn->chanspec); /* channel specified */
- //this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data);
+ /* this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data); */
if (ui_Chan >= 0 && ui_Chan <= 3) {
- ui_TmpValue = (UINT) inw(devpriv->iobase + APCI3120_RD_STATUS);
+ ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS);
- // since only 1 channel reqd to bring it to last bit it is rotated
- // 8 +(chan - 1) times then ANDed with 1 for last bit.
+/*
+ * since only 1 channel reqd to bring it to last bit it is rotated 8
+ * +(chan - 1) times then ANDed with 1 for last bit.
+ */
*data = (ui_TmpValue >> (ui_Chan + 8)) & 1;
- //return 0;
+ /* return 0; */
} else {
- // comedi_error(dev," chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ /* comedi_error(dev," chan spec wrong"); */
+ return -EINVAL; /* "sorry channel spec wrong " */
}
return insn->n;
@@ -2423,18 +2386,18 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnBitsDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_TmpValue;
- ui_TmpValue = (UINT) inw(devpriv->iobase + APCI3120_RD_STATUS);
+ unsigned int ui_TmpValue;
+ ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS);
/***** state of 4 channels in the 11, 10, 9, 8 bits of status reg
rotated right 8 times to bring them to last four bits
ANDed with oxf for value.
*****/
*data = (ui_TmpValue >> 8) & 0xf;
- //this_board->i_hwdrv_InsnBitsDigitalInput(dev,data);
+ /* this_board->i_hwdrv_InsnBitsDigitalInput(dev,data); */
return insn->n;
}
@@ -2462,8 +2425,8 @@ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device * dev, struct comedi_su
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
if ((data[0] != 0) && (data[0] != 1)) {
@@ -2481,7 +2444,7 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device * dev,
if (!devpriv->b_OutputMemoryStatus) {
ui_Temp = 0;
- } //if(!devpriv->b_OutputMemoryStatus )
+ } /* if(!devpriv->b_OutputMemoryStatus ) */
return insn->n;
}
@@ -2499,16 +2462,16 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device * dev,
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
- data[0] Value to be written
- data[1] :1 Set digital o/p ON
- data[1] 2 Set digital o/p OFF with memory ON
+| data[0] Value to be written
+| data[1] :1 Set digital o/p ON
+| data[1] 2 Set digital o/p OFF with memory ON
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device * dev,
+int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
@@ -2530,7 +2493,7 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device * dev,
default:
printk("\nThe parameter passed is in error \n");
return -EINVAL;
- } // switch(data[1])
+ } /* switch(data[1]) */
outb(data[0], devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
devpriv->b_DigitalOutputRegister = data[0] & 0xF0;
@@ -2567,9 +2530,9 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
unsigned int *data)
{
- UINT ui_Temp1;
+ unsigned int ui_Temp1;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
@@ -2586,7 +2549,7 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
switch (data[1]) {
case 1:
data[0] = (data[0] << ui_NoOfChannel);
-//ES05 data[0]=(data[0]<<4)|ui_Temp;
+/* ES05 data[0]=(data[0]<<4)|ui_Temp; */
data[0] = (data[0] << 4) | devpriv->b_DigitalOutputRegister;
break;
@@ -2595,24 +2558,24 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
ui_Temp1 = 1;
ui_Temp1 = ui_Temp1 << ui_NoOfChannel;
ui_Temp1 = ui_Temp1 << 4;
-//ES05 ui_Temp=ui_Temp|ui_Temp1;
+/* ES05 ui_Temp=ui_Temp|ui_Temp1; */
devpriv->b_DigitalOutputRegister =
devpriv->b_DigitalOutputRegister | ui_Temp1;
data[0] = (data[0] << ui_NoOfChannel) ^ 0xf;
data[0] = data[0] << 4;
-//ES05 data[0]=data[0]& ui_Temp;
+/* ES05 data[0]=data[0]& ui_Temp; */
data[0] = data[0] & devpriv->b_DigitalOutputRegister;
break;
default:
printk("\nThe parameter passed is in error \n");
return -EINVAL;
- } // switch(data[1])
+ } /* switch(data[1]) */
outb(data[0], devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
-//ES05 ui_Temp=data[0] & 0xf0;
+/* ES05 ui_Temp=data[0] & 0xf0; */
devpriv->b_DigitalOutputRegister = data[0] & 0xf0;
- return (insn->n);
+ return insn->n;
}
@@ -2646,14 +2609,14 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
- UINT ui_Range, ui_Channel;
- USHORT us_TmpValue;
+ unsigned int ui_Range, ui_Channel;
+ unsigned short us_TmpValue;
ui_Range = CR_RANGE(insn->chanspec);
ui_Channel = CR_CHAN(insn->chanspec);
- //this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]);
- if (ui_Range) // if 1 then unipolar
+ /* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */
+ if (ui_Range) /* if 1 then unipolar */
{
if (data[0] != 0)
@@ -2665,7 +2628,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
((((ui_Channel & 0x03) << 14) & 0xC000) | (1 <<
13) | 8192);
- } else // if 0 then bipolar
+ } else /* if 0 then bipolar */
{
data[0] =
((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) |
@@ -2673,24 +2636,30 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
}
- //out put n values at the given channel.
- // rt_printk("\nwaiting for DA_READY BIT");
- do //Waiting of DA_READY BIT
+/*
+ * out put n values at the given channel. printk("\nwaiting for
+ * DA_READY BIT");
+ */
+ do /* Waiting of DA_READY BIT */
{
us_TmpValue =
- ((USHORT) inw(devpriv->iobase +
+ ((unsigned short) inw(devpriv->iobase +
APCI3120_RD_STATUS)) & 0x0001;
} while (us_TmpValue != 0x0001);
if (ui_Channel <= 3)
- // for channel 0-3 out at the register 1 (wrDac1-8)
- // data[i] typecasted to ushort since word write is to be done
- outw((USHORT) data[0],
+/*
+ * for channel 0-3 out at the register 1 (wrDac1-8) data[i]
+ * typecasted to ushort since word write is to be done
+ */
+ outw((unsigned short) data[0],
devpriv->iobase + APCI3120_ANALOG_OUTPUT_1);
else
- // for channel 4-7 out at the register 2 (wrDac5-8)
- //data[i] typecasted to ushort since word write is to be done
- outw((USHORT) data[0],
+/*
+ * for channel 4-7 out at the register 2 (wrDac5-8) data[i]
+ * typecasted to ushort since word write is to be done
+ */
+ outw((unsigned short) data[0],
devpriv->iobase + APCI3120_ANALOG_OUTPUT_2);
return insn->n;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h
index 59d5d87a845b..fedfc9c58a88 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h
@@ -1,5 +1,5 @@
-// hwdrv_apci3120.h
+/* hwdrv_apci3120.h */
/*
* Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
@@ -18,9 +18,9 @@
* any later version.
*/
-// comedi related defines
+/* comedi related defines */
-//ANALOG INPUT RANGE
+/* ANALOG INPUT RANGE */
static const struct comedi_lrange range_apci3120_ai = { 8, {
BIP_RANGE(10),
BIP_RANGE(5),
@@ -33,14 +33,14 @@ static const struct comedi_lrange range_apci3120_ai = { 8, {
}
};
-// ANALOG OUTPUT RANGE
+/* ANALOG OUTPUT RANGE */
static const struct comedi_lrange range_apci3120_ao = { 2, {
BIP_RANGE(10),
UNI_RANGE(10)
}
};
-#define APCI3120_BIPOLAR_RANGES 4 // used for test on mixture of BIP/UNI ranges
+#define APCI3120_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */
#define APCI3120_BOARD_VENDOR_ID 0x10E8
#define APCI3120_ADDRESS_RANGE 16
@@ -55,17 +55,17 @@ static const struct comedi_lrange range_apci3120_ao = { 2, {
#define APCI3120_EOS_MODE 2
#define APCI3120_DMA_MODE 3
-//DIGITAL INPUT-OUTPUT DEFINE
+/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI3120_DIGITAL_OUTPUT 0x0D
#define APCI3120_RD_STATUS 0x02
#define APCI3120_RD_FIFO 0x00
-// digital output insn_write ON /OFF selection
+/* digital output insn_write ON /OFF selection */
#define APCI3120_SET4DIGITALOUTPUTON 1
#define APCI3120_SET4DIGITALOUTPUTOFF 0
-// analog output SELECT BIT
+/* analog output SELECT BIT */
#define APCI3120_ANALOG_OP_CHANNEL_1 0x0000
#define APCI3120_ANALOG_OP_CHANNEL_2 0x4000
#define APCI3120_ANALOG_OP_CHANNEL_3 0x8000
@@ -75,32 +75,32 @@ static const struct comedi_lrange range_apci3120_ao = { 2, {
#define APCI3120_ANALOG_OP_CHANNEL_7 0x8000
#define APCI3120_ANALOG_OP_CHANNEL_8 0xC000
-// Enable external trigger bit in nWrAddress
+/* Enable external trigger bit in nWrAddress */
#define APCI3120_ENABLE_EXT_TRIGGER 0x8000
-//ANALOG OUTPUT AND INPUT DEFINE
-#define APCI3120_UNIPOLAR 0x80 //$$ RAM sequence polarity BIT
-#define APCI3120_BIPOLAR 0x00 //$$ RAM sequence polarity BIT
-#define APCI3120_ANALOG_OUTPUT_1 0x08 // (ADDRESS )
-#define APCI3120_ANALOG_OUTPUT_2 0x0A // (ADDRESS )
-#define APCI3120_1_GAIN 0x00 //$$ RAM sequence Gain Bits for gain 1
-#define APCI3120_2_GAIN 0x10 //$$ RAM sequence Gain Bits for gain 2
-#define APCI3120_5_GAIN 0x20 //$$ RAM sequence Gain Bits for gain 5
-#define APCI3120_10_GAIN 0x30 //$$ RAM sequence Gain Bits for gain 10
-#define APCI3120_SEQ_RAM_ADDRESS 0x06 //$$ EARLIER NAMED APCI3120_FIFO_ADDRESS
-#define APCI3120_RESET_FIFO 0x0C //(ADDRESS)
-#define APCI3120_TIMER_0_MODE_2 0x01 //$$ Bits for timer mode
+/* ANALOG OUTPUT AND INPUT DEFINE */
+#define APCI3120_UNIPOLAR 0x80 /* $$ RAM sequence polarity BIT */
+#define APCI3120_BIPOLAR 0x00 /* $$ RAM sequence polarity BIT */
+#define APCI3120_ANALOG_OUTPUT_1 0x08 /* (ADDRESS ) */
+#define APCI3120_ANALOG_OUTPUT_2 0x0A /* (ADDRESS ) */
+#define APCI3120_1_GAIN 0x00 /* $$ RAM sequence Gain Bits for gain 1 */
+#define APCI3120_2_GAIN 0x10 /* $$ RAM sequence Gain Bits for gain 2 */
+#define APCI3120_5_GAIN 0x20 /* $$ RAM sequence Gain Bits for gain 5 */
+#define APCI3120_10_GAIN 0x30 /* $$ RAM sequence Gain Bits for gain 10 */
+#define APCI3120_SEQ_RAM_ADDRESS 0x06 /* $$ EARLIER NAMED APCI3120_FIFO_ADDRESS */
+#define APCI3120_RESET_FIFO 0x0C /* (ADDRESS) */
+#define APCI3120_TIMER_0_MODE_2 0x01 /* $$ Bits for timer mode */
#define APCI3120_TIMER_0_MODE_4 0x2
#define APCI3120_SELECT_TIMER_0_WORD 0x00
-#define APCI3120_ENABLE_TIMER0 0x1000 //$$Gatebit 0 in nWrAddress
+#define APCI3120_ENABLE_TIMER0 0x1000 /* $$Gatebit 0 in nWrAddress */
#define APCI3120_CLEAR_PR 0xF0FF
#define APCI3120_CLEAR_PA 0xFFF0
#define APCI3120_CLEAR_PA_PR (APCI3120_CLEAR_PR & APCI3120_CLEAR_PA)
-// nWrMode_Select
-#define APCI3120_ENABLE_SCAN 0x8 //$$ bit in nWrMode_Select
+/* nWrMode_Select */
+#define APCI3120_ENABLE_SCAN 0x8 /* $$ bit in nWrMode_Select */
#define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN)
-#define APCI3120_ENABLE_EOS_INT 0x2 //$$ bit in nWrMode_Select
+#define APCI3120_ENABLE_EOS_INT 0x2 /* $$ bit in nWrMode_Select */
#define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT)
#define APCI3120_ENABLE_EOC_INT 0x1
@@ -108,50 +108,50 @@ static const struct comedi_lrange range_apci3120_ao = { 2, {
#define APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER (APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT)
#define APCI3120_DISABLE_ALL_INTERRUPT (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT)
-//status register bits
+/* status register bits */
#define APCI3120_EOC 0x8000
#define APCI3120_EOS 0x2000
-// software trigger dummy register
-#define APCI3120_START_CONVERSION 0x02 //(ADDRESS)
+/* software trigger dummy register */
+#define APCI3120_START_CONVERSION 0x02 /* (ADDRESS) */
-//TIMER DEFINE
+/* TIMER DEFINE */
#define APCI3120_QUARTZ_A 70
#define APCI3120_QUARTZ_B 50
#define APCI3120_TIMER 1
#define APCI3120_WATCHDOG 2
#define APCI3120_TIMER_DISABLE 0
#define APCI3120_TIMER_ENABLE 1
-#define APCI3120_ENABLE_TIMER2 0x4000 //$$ gatebit 2 in nWrAddress
+#define APCI3120_ENABLE_TIMER2 0x4000 /* $$ gatebit 2 in nWrAddress */
#define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2)
-#define APCI3120_ENABLE_TIMER_INT 0x04 //$$ ENAIRQ_FC_Bit in nWrModeSelect
+#define APCI3120_ENABLE_TIMER_INT 0x04 /* $$ ENAIRQ_FC_Bit in nWrModeSelect */
#define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
-#define APCI3120_WRITE_MODE_SELECT 0x0E // (ADDRESS)
+#define APCI3120_WRITE_MODE_SELECT 0x0E /* (ADDRESS) */
#define APCI3120_SELECT_TIMER_0_WORD 0x00
#define APCI3120_SELECT_TIMER_1_WORD 0x01
#define APCI3120_TIMER_1_MODE_2 0x4
-//$$ BIT FOR MODE IN nCsTimerCtr1
+/* $$ BIT FOR MODE IN nCsTimerCtr1 */
#define APCI3120_TIMER_2_MODE_0 0x0
#define APCI3120_TIMER_2_MODE_2 0x10
#define APCI3120_TIMER_2_MODE_5 0x30
-//$$ BIT FOR MODE IN nCsTimerCtr0
+/* $$ BIT FOR MODE IN nCsTimerCtr0 */
#define APCI3120_SELECT_TIMER_2_LOW_WORD 0x02
#define APCI3120_SELECT_TIMER_2_HIGH_WORD 0x03
-#define APCI3120_TIMER_CRT0 0x0D //(ADDRESS for cCsTimerCtr0)
-#define APCI3120_TIMER_CRT1 0x0C //(ADDRESS for cCsTimerCtr1)
+#define APCI3120_TIMER_CRT0 0x0D /* (ADDRESS for cCsTimerCtr0) */
+#define APCI3120_TIMER_CRT1 0x0C /* (ADDRESS for cCsTimerCtr1) */
-#define APCI3120_TIMER_VALUE 0x04 //ADDRESS for nCsTimerWert
-#define APCI3120_TIMER_STATUS_REGISTER 0x0D //ADDRESS for delete timer 2 interrupt
-#define APCI3120_RD_STATUS 0x02 //ADDRESS
-#define APCI3120_WR_ADDRESS 0x00 //ADDRESS
-#define APCI3120_ENABLE_WATCHDOG 0x20 //$$BIT in nWrMode_Select
+#define APCI3120_TIMER_VALUE 0x04 /* ADDRESS for nCsTimerWert */
+#define APCI3120_TIMER_STATUS_REGISTER 0x0D /* ADDRESS for delete timer 2 interrupt */
+#define APCI3120_RD_STATUS 0x02 /* ADDRESS */
+#define APCI3120_WR_ADDRESS 0x00 /* ADDRESS */
+#define APCI3120_ENABLE_WATCHDOG 0x20 /* $$BIT in nWrMode_Select */
#define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG)
-#define APCI3120_ENABLE_TIMER_COUNTER 0x10 //$$BIT in nWrMode_Select
+#define APCI3120_ENABLE_TIMER_COUNTER 0x10 /* $$BIT in nWrMode_Select */
#define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER)
-#define APCI3120_FC_TIMER 0x1000 //bit in status register
+#define APCI3120_FC_TIMER 0x1000 /* bit in status register */
#define APCI3120_ENABLE_TIMER0 0x1000
#define APCI3120_ENABLE_TIMER1 0x2000
#define APCI3120_ENABLE_TIMER2 0x4000
@@ -159,25 +159,27 @@ static const struct comedi_lrange range_apci3120_ao = { 2, {
#define APCI3120_DISABLE_TIMER1 (~APCI3120_ENABLE_TIMER1)
#define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2)
-#define APCI3120_TIMER2_SELECT_EOS 0xC0 // ADDED on 20-6
-#define APCI3120_COUNTER 3 // on 20-6
-#define APCI3120_DISABLE_ALL_TIMER ( APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_DISABLE_TIMER2 ) // on 20-6
+#define APCI3120_TIMER2_SELECT_EOS 0xC0 /* ADDED on 20-6 */
+#define APCI3120_COUNTER 3 /* on 20-6 */
+#define APCI3120_DISABLE_ALL_TIMER (APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_DISABLE_TIMER2) /* on 20-6 */
#define MAX_ANALOGINPUT_CHANNELS 32
-typedef struct {
- BYTE b_Type; /* EOC or EOS */
- BYTE b_InterruptFlag; /* Interrupt use or not */
- UINT ui_ConvertTiming; /* Selection of the convertion time */
- BYTE b_NbrOfChannel; /* Number of channel to read */
- UINT ui_ChannelList[MAX_ANALOGINPUT_CHANNELS]; /* Number of the channel to be read */
- UINT ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */
+struct str_AnalogReadInformation {
-} str_AnalogReadInformation;
+ unsigned char b_Type; /* EOC or EOS */
+ unsigned char b_InterruptFlag; /* Interrupt use or not */
+ unsigned int ui_ConvertTiming; /* Selection of the convertion time */
+ unsigned char b_NbrOfChannel; /* Number of channel to read */
+ unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS]; /* Number of the channel to be read */
+ unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */
+
+};
-// Function Declaration For APCI-3120
-// Internal functions
+/* Function Declaration For APCI-3120 */
+
+/* Internal functions */
int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, char check);
int i_APCI3120_ExttrigEnable(struct comedi_device *dev);
@@ -186,9 +188,9 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_su
int i_APCI3120_Reset(struct comedi_device *dev);
int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
struct comedi_subdevice *s);
-// Interrupt functions
+/* Interrupt functions */
void v_APCI3120_Interrupt(int irq, void *d);
-//UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n);
+/* UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n); */
void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
struct comedi_subdevice *s,
short *dma_buffer,
@@ -196,7 +198,7 @@ void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
int i_APCI3120_InterruptHandleEos(struct comedi_device *dev);
void v_APCI3120_InterruptDma(int irq, void *d);
-// TIMER
+/* TIMER */
int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
@@ -205,16 +207,19 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//DI
-// for di read
+/*
+* DI for di read
+*/
int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//DO
-//int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev, BYTE data);
+/* DO */
+/* int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev,
+ * unsigned char data);
+ */
int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data);
@@ -223,12 +228,15 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, struct comedi_su
int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//AO
-//int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range,UINT ui_Channel,UINT data );
+/* AO */
+/* int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range,
+ * UINT ui_Channel,UINT data );
+ */
+
int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//AI HArdware layer
+/* AI HArdware layer */
int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
@@ -237,5 +245,5 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd);
int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
-//int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
+/* int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); */
int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
index 1ff66bee548d..9b53255bd45b 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -57,73 +57,73 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
#include "hwdrv_apci3200.h"
-//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+/* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
#include "addi_amcc_S5920.h"
-//#define PRINT_INFO
+/* #define PRINT_INFO */
-//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-//BEGIN JK 06.07.04: Management of sevrals boards
+/* BEGIN JK 06.07.04: Management of sevrals boards */
/*
- INT i_CJCAvailable=1;
- INT i_CJCPolarity=0;
- INT i_CJCGain=2;//changed from 0 to 2
- INT i_InterruptFlag=0;
- INT i_ADDIDATAPolarity;
- INT i_ADDIDATAGain;
- INT i_AutoCalibration=0; //: auto calibration
- INT i_ADDIDATAConversionTime;
- INT i_ADDIDATAConversionTimeUnit;
- INT i_ADDIDATAType;
- INT i_ChannelNo;
- INT i_ChannelCount=0;
- INT i_ScanType;
- INT i_FirstChannel;
- INT i_LastChannel;
- INT i_Sum=0;
- INT i_Offset;
- UINT ui_Channel_num=0;
+ int i_CJCAvailable=1;
+ int i_CJCPolarity=0;
+ int i_CJCGain=2;/* changed from 0 to 2 */
+ int i_InterruptFlag=0;
+ int i_ADDIDATAPolarity;
+ int i_ADDIDATAGain;
+ int i_AutoCalibration=0; /* : auto calibration */
+ int i_ADDIDATAConversionTime;
+ int i_ADDIDATAConversionTimeUnit;
+ int i_ADDIDATAType;
+ int i_ChannelNo;
+ int i_ChannelCount=0;
+ int i_ScanType;
+ int i_FirstChannel;
+ int i_LastChannel;
+ int i_Sum=0;
+ int i_Offset;
+ unsigned int ui_Channel_num=0;
static int i_Count=0;
- INT i_Initialised=0;
- UINT ui_InterruptChannelValue[96]; //Buffer
+ int i_Initialised=0;
+ unsigned int ui_InterruptChannelValue[96]; /* Buffer */
*/
-str_BoardInfos s_BoardInfos[100]; // 100 will be the max number of boards to be used
-//END JK 06.07.04: Management of sevrals boards
+struct str_BoardInfos s_BoardInfos[100]; /* 100 will be the max number of boards to be used */
+/* END JK 06.07.04: Management of sevrals boards */
-//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+/* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
/*+----------------------------------------------------------------------------+*/
-/*| Function Name : INT i_AddiHeaderRW_ReadEeprom |*/
-/*| (INT i_NbOfWordsToRead, |*/
-/*| DWORD dw_PCIBoardEepromAddress, |*/
-/*| WORD w_EepromStartAddress, |*/
-/*| PWORD pw_DataRead) |*/
+/*| Function Name : int i_AddiHeaderRW_ReadEeprom |*/
+/*| (int i_NbOfWordsToRead, |*/
+/*| unsigned int dw_PCIBoardEepromAddress, |*/
+/*| unsigned short w_EepromStartAddress, |*/
+/*| unsigned short * pw_DataRead) |*/
/*+----------------------------------------------------------------------------+*/
/*| Task : Read word from the 5920 eeprom. |*/
/*+----------------------------------------------------------------------------+*/
-/*| Input Parameters : INT i_NbOfWordsToRead : Nbr. of word to read |*/
-/*| DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/
-/*| WORD w_EepromStartAddress : Eeprom strat address |*/
+/*| Input Parameters : int i_NbOfWordsToRead : Nbr. of word to read |*/
+/*| unsigned int dw_PCIBoardEepromAddress : Address of the eeprom |*/
+/*| unsigned short w_EepromStartAddress : Eeprom strat address |*/
/*+----------------------------------------------------------------------------+*/
-/*| Output Parameters : PWORD pw_DataRead : Read data |*/
+/*| Output Parameters : unsigned short * pw_DataRead : Read data |*/
/*+----------------------------------------------------------------------------+*/
/*| Return Value : - |*/
/*+----------------------------------------------------------------------------+*/
-INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
- DWORD dw_PCIBoardEepromAddress,
- WORD w_EepromStartAddress, PWORD pw_DataRead)
+int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
+ unsigned int dw_PCIBoardEepromAddress,
+ unsigned short w_EepromStartAddress, unsigned short *pw_DataRead)
{
- DWORD dw_eeprom_busy = 0;
- INT i_Counter = 0;
- INT i_WordCounter;
- INT i;
- BYTE pb_ReadByte[1];
- BYTE b_ReadLowByte = 0;
- BYTE b_ReadHighByte = 0;
- BYTE b_SelectedAddressLow = 0;
- BYTE b_SelectedAddressHigh = 0;
- WORD w_ReadWord = 0;
+ unsigned int dw_eeprom_busy = 0;
+ int i_Counter = 0;
+ int i_WordCounter;
+ int i;
+ unsigned char pb_ReadByte[1];
+ unsigned char b_ReadLowByte = 0;
+ unsigned char b_ReadHighByte = 0;
+ unsigned char b_SelectedAddressLow = 0;
+ unsigned char b_SelectedAddressHigh = 0;
+ unsigned short w_ReadWord = 0;
for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead;
i_WordCounter++) {
@@ -132,106 +132,99 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
for (i_Counter = 0; i_Counter < 2; i_Counter++) {
- b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; //Read the low 8 bit part
- b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; //Read the high 8 bit part
+ b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; /* Read the low 8 bit part */
+ b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; /* Read the high 8 bit part */
- //Select the load low address mode
+ /* Select the load low address mode */
outb(NVCMD_LOAD_LOW,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
3);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Load the low address
+ /* Load the low address */
outb(b_SelectedAddressLow,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
2);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Select the load high address mode
+ /* Select the load high address mode */
outb(NVCMD_LOAD_HIGH,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
3);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Load the high address
+ /* Load the high address */
outb(b_SelectedAddressHigh,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
2);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Select the READ mode
+ /* Select the READ mode */
outb(NVCMD_BEGIN_READ,
dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
3);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Read data into the EEPROM
+ /* Read data into the EEPROM */
*pb_ReadByte =
inb(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR + 2);
- //Wait on busy
+ /* Wait on busy */
do {
dw_eeprom_busy =
inl(dw_PCIBoardEepromAddress +
AMCC_OP_REG_MCSR);
dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
- }
- while (dw_eeprom_busy == EEPROM_BUSY);
+ } while (dw_eeprom_busy == EEPROM_BUSY);
- //Select the upper address part
- if (i_Counter == 0) {
+ /* Select the upper address part */
+ if (i_Counter == 0)
b_ReadLowByte = pb_ReadByte[0];
- } else {
+ else
b_ReadHighByte = pb_ReadByte[0];
- }
- //Sleep
- for (i = 0; i < 10000; i++) ;
+
+ /* Sleep */
+ msleep(1);
}
w_ReadWord =
@@ -240,10 +233,10 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
pw_DataRead[i_WordCounter] = w_ReadWord;
- w_EepromStartAddress += 2; // to read the next word
+ w_EepromStartAddress += 2; /* to read the next word */
- } // for (...) i_NbOfWordsToRead
- return (0);
+ } /* for (...) i_NbOfWordsToRead */
+ return 0;
}
/*+----------------------------------------------------------------------------+*/
@@ -258,31 +251,31 @@ INT i_AddiHeaderRW_ReadEeprom(INT i_NbOfWordsToRead,
/*| Return Value : - |*/
/*+----------------------------------------------------------------------------+*/
-void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
- str_BoardInfos * BoardInformations)
+void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress,
+ struct str_BoardInfos *BoardInformations)
{
- WORD w_AnalogInputMainHeaderAddress;
- WORD w_AnalogInputComponentAddress;
- WORD w_NumberOfModuls = 0;
- WORD w_CurrentSources[2];
- WORD w_ModulCounter = 0;
- WORD w_FirstHeaderSize = 0;
- WORD w_NumberOfInputs = 0;
- WORD w_CJCFlag = 0;
- WORD w_NumberOfGainValue = 0;
- WORD w_SingleHeaderAddress = 0;
- WORD w_SingleHeaderSize = 0;
- WORD w_Input = 0;
- WORD w_GainFactorAddress = 0;
- WORD w_GainFactorValue[2];
- WORD w_GainIndex = 0;
- WORD w_GainValue = 0;
+ unsigned short w_AnalogInputMainHeaderAddress;
+ unsigned short w_AnalogInputComponentAddress;
+ unsigned short w_NumberOfModuls = 0;
+ unsigned short w_CurrentSources[2];
+ unsigned short w_ModulCounter = 0;
+ unsigned short w_FirstHeaderSize = 0;
+ unsigned short w_NumberOfInputs = 0;
+ unsigned short w_CJCFlag = 0;
+ unsigned short w_NumberOfGainValue = 0;
+ unsigned short w_SingleHeaderAddress = 0;
+ unsigned short w_SingleHeaderSize = 0;
+ unsigned short w_Input = 0;
+ unsigned short w_GainFactorAddress = 0;
+ unsigned short w_GainFactorValue[2];
+ unsigned short w_GainIndex = 0;
+ unsigned short w_GainValue = 0;
/*****************************************/
/** Get the Analog input header address **/
/*****************************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, 0x116, //w_EepromStartAddress: Analog input header address
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, 0x116, /* w_EepromStartAddress: Analog input header address */
&w_AnalogInputMainHeaderAddress);
/*******************************************/
@@ -293,8 +286,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/******************************/
/** Get the number of moduls **/
/******************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputMainHeaderAddress + 0x02, //w_EepromStartAddress: Number of conponment
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputMainHeaderAddress + 0x02, /* w_EepromStartAddress: Number of conponment */
&w_NumberOfModuls);
for (w_ModulCounter = 0; w_ModulCounter < w_NumberOfModuls;
@@ -309,8 +302,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/****************************/
/** Read first header size **/
/****************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress, // Address of the first header
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress, /* Address of the first header */
&w_FirstHeaderSize);
w_FirstHeaderSize = w_FirstHeaderSize >> 4;
@@ -318,8 +311,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/***************************/
/** Read number of inputs **/
/***************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x06, // Number of inputs for the first modul
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x06, /* Number of inputs for the first modul */
&w_NumberOfInputs);
w_NumberOfInputs = w_NumberOfInputs >> 4;
@@ -327,17 +320,17 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/***********************/
/** Read the CJC flag **/
/***********************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x08, // CJC flag
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x08, /* CJC flag */
&w_CJCFlag);
- w_CJCFlag = (w_CJCFlag >> 3) & 0x1; // Get only the CJC flag
+ w_CJCFlag = (w_CJCFlag >> 3) & 0x1; /* Get only the CJC flag */
/*******************************/
/** Read number of gain value **/
/*******************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x44, // Number of gain value
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x44, /* Number of gain value */
&w_NumberOfGainValue);
w_NumberOfGainValue = w_NumberOfGainValue & 0xFF;
@@ -354,8 +347,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/********************************************/
/** Read current sources value for input 1 **/
/********************************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_SingleHeaderAddress, //w_EepromStartAddress: Single header address
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_SingleHeaderAddress, /* w_EepromStartAddress: Single header address */
&w_SingleHeaderSize);
w_SingleHeaderSize = w_SingleHeaderSize >> 4;
@@ -370,8 +363,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/************************************/
/** Read gain value for the module **/
/************************************/
- i_AddiHeaderRW_ReadEeprom(1, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + (2 * (1 + (w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), // Gain value
+ i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + (2 * (1 + (w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), /* Gain value */
&w_GainValue);
BoardInformations->s_Module[w_ModulCounter].
@@ -386,8 +379,8 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/*************************************/
/** Read gain factor for the module **/
/*************************************/
- i_AddiHeaderRW_ReadEeprom(2, //i_NbOfWordsToRead
- dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + (w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), // Gain factor
+ i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */
+ dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + (w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), /* Gain factor */
w_GainFactorValue);
BoardInformations->s_Module[w_ModulCounter].
@@ -409,7 +402,7 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/********************************************/
/** Read current sources value for input 1 **/
/********************************************/
- i_AddiHeaderRW_ReadEeprom(2, //i_NbOfWordsToRead
+ i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */
dw_PCIBoardEepromAddress,
(w_Input * w_SingleHeaderSize) +
w_SingleHeaderAddress + 0x0C, w_CurrentSources);
@@ -432,7 +425,7 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
/***************************************/
/** Read the CJC current source value **/
/***************************************/
- i_AddiHeaderRW_ReadEeprom(2, //i_NbOfWordsToRead
+ i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */
dw_PCIBoardEepromAddress,
(w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress +
0x0C, w_CurrentSources);
@@ -453,9 +446,9 @@ void v_GetAPCI3200EepromCalibrationValue(DWORD dw_PCIBoardEepromAddress,
}
}
-INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
- unsigned int ui_Channel_num, unsigned int * CJCCurrentSource,
- unsigned int * ChannelCurrentSource, unsigned int * ChannelGainFactor)
+int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev,
+ unsigned int ui_Channel_num, unsigned int *CJCCurrentSource,
+ unsigned int *ChannelCurrentSource, unsigned int *ChannelGainFactor)
{
int i_DiffChannel = 0;
int i_Module = 0;
@@ -464,9 +457,9 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
printk("\n Channel = %u", ui_Channel_num);
#endif
- //Test if single or differential mode
+ /* Test if single or differential mode */
if (s_BoardInfos[dev->minor].i_ConnectionType == 1) {
- //if diff
+ /* if diff */
if ((ui_Channel_num >= 0) && (ui_Channel_num <= 1))
i_DiffChannel = ui_Channel_num, i_Module = 0;
@@ -478,7 +471,7 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
i_DiffChannel = ui_Channel_num - 6, i_Module = 3;
} else {
- // if single
+ /* if single */
if ((ui_Channel_num == 0) || (ui_Channel_num == 1))
i_DiffChannel = 0, i_Module = 0;
else if ((ui_Channel_num == 2) || (ui_Channel_num == 3))
@@ -497,7 +490,7 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
i_DiffChannel = 1, i_Module = 3;
}
- //Test if thermocouple or RTD mode
+ /* Test if thermocouple or RTD mode */
*CJCCurrentSource =
s_BoardInfos[dev->minor].s_Module[i_Module].ul_CurrentSourceCJC;
#ifdef PRINT_INFO
@@ -510,22 +503,22 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
#ifdef PRINT_INFO
printk("\n ChannelCurrentSource = %lu", *ChannelCurrentSource);
#endif
- // }
- // }
+ /* } */
+ /* } */
- //Channle gain factor
+ /* Channle gain factor */
*ChannelGainFactor =
s_BoardInfos[dev->minor].s_Module[i_Module].
ul_GainFactor[s_BoardInfos[dev->minor].i_ADDIDATAGain];
#ifdef PRINT_INFO
printk("\n ChannelGainFactor = %lu", *ChannelGainFactor);
#endif
- //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
- return (0);
+ return 0;
}
-//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
/*
+----------------------------------------------------------------------------+
@@ -536,9 +529,9 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT ui_NoOfChannels : No Of Channels To read for Port
+ | unsigned int ui_NoOfChannels : No Of Channels To read for Port
Channel Numberfor single channel
- | UINT data[0] : 0: Read single channel
+ | unsigned int data[0] : 0: Read single channel
1: Read port value
data[1] Port number
+----------------------------------------------------------------------------+
@@ -550,24 +543,24 @@ INT i_APCI3200_GetChannelCalibrationValue(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp = 0;
- UINT ui_NoOfChannel = 0;
+ unsigned int ui_Temp = 0;
+ unsigned int ui_NoOfChannel = 0;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
ui_Temp = data[0];
*data = inl(devpriv->i_IobaseReserved);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } //if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
if (data[1] < 0 || data[1] > 1) {
printk("\nThe port number is in error\n");
return -EINVAL;
- } //if(data[1] < 0 || data[1] >1)
+ } /* if(data[1] < 0 || data[1] >1) */
switch (ui_NoOfChannel) {
case 2:
@@ -578,13 +571,13 @@ INT i_APCI3200_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev
break;
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
- } //switch(ui_NoOfChannels)
- } //if (ui_Temp==1)
+ } /* switch(ui_NoOfChannels) */
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } //elseif (ui_Temp==1)
+ } /* elseif (ui_Temp==1) */
}
return insn->n;
}
@@ -608,21 +601,21 @@ INT i_APCI3200_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
"Not a valid Data !!! ,Data should be 1 or 0\n");
return -EINVAL;
- } //if ( (data[0]!=0) && (data[0]!=1) )
+ } /* if ( (data[0]!=0) && (data[0]!=1) ) */
if (data[0]) {
devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE;
- } // if (data[0])
+ } /* if (data[0]) */
else {
devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
- } //else if (data[0])
+ } /* else if (data[0]) */
return insn->n;
}
@@ -653,23 +646,23 @@ int i_APCI3200_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp = 0, ui_Temp1 = 0;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp = 0, ui_Temp1 = 0;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
if (devpriv->b_OutputMemoryStatus) {
ui_Temp = inl(devpriv->i_IobaseAddon);
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outl(data[0], devpriv->i_IobaseAddon);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -682,15 +675,15 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
case 3:
data[0] = (data[0] | ui_Temp);
break;
- } //switch(ui_NoOfChannels)
+ } /* switch(ui_NoOfChannels) */
outl(data[0], devpriv->i_IobaseAddon);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==0)
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -701,7 +694,7 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
data[0] = (data[0] << ui_NoOfChannel) ^ 0xf;
data[0] = data[0] & ui_Temp;
outl(data[0], devpriv->i_IobaseAddon);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
switch (ui_NoOfChannel) {
@@ -725,21 +718,21 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
default:
comedi_error(dev,
" chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
- } //switch(ui_NoOfChannels)
+ return -EINVAL; /* "sorry channel spec wrong " */
+ } /* switch(ui_NoOfChannels) */
outl(data[0], devpriv->i_IobaseAddon);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
return insn->n;
}
@@ -752,8 +745,8 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT ui_NoOfChannels : No Of Channels To read |
- | UINT *data : Data Pointer to read status |
+ | unsigned int ui_NoOfChannels : No Of Channels To read |
+ | unsigned int *data : Data Pointer to read status |
data[0] :0 read single channel
1 read port value
data[1] port no
@@ -766,23 +759,23 @@ INT i_APCI3200_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
ui_Temp = data[0];
*data = inl(devpriv->i_IobaseAddon);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } // if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
if (data[1] < 0 || data[1] > 1) {
printk("\nThe port selection is in error\n");
return -EINVAL;
- } //if(data[1] <0 ||data[1] >1)
+ } /* if(data[1] <0 ||data[1] >1) */
switch (ui_NoOfChannel) {
case 2:
*data = (*data >> (2 * data[1])) & 3;
@@ -793,20 +786,20 @@ INT i_APCI3200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
default:
comedi_error(dev, " chan spec wrong");
- return -EINVAL; // "sorry channel spec wrong "
+ return -EINVAL; /* "sorry channel spec wrong " */
break;
- } // switch(ui_NoOfChannels)
- } // if (ui_Temp==1)
+ } /* switch(ui_NoOfChannels) */
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } // else if (ui_Temp==1)
- } // else if (ui_Temp==0)
+ } /* else if (ui_Temp==1) */
+ } /* else if (ui_Temp==0) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
- | Function Name : INT i_APCI3200_ConfigAnalogInput |
+ | Function Name : int i_APCI3200_ConfigAnalogInput |
| (struct comedi_device *dev,struct comedi_subdevice *s, |
| struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
@@ -874,30 +867,30 @@ INT i_APCI3200_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ul_Config = 0, ul_Temp = 0;
- UINT ui_ChannelNo = 0;
- UINT ui_Dummy = 0;
- INT i_err = 0;
+ unsigned int ul_Config = 0, ul_Temp = 0;
+ unsigned int ui_ChannelNo = 0;
+ unsigned int ui_Dummy = 0;
+ int i_err = 0;
- //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
#ifdef PRINT_INFO
- INT i = 0, i2 = 0;
+ int i = 0, i2 = 0;
#endif
- //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
- //BEGIN JK 06.07.04: Management of sevrals boards
- // Initialize the structure
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* Initialize the structure */
if (s_BoardInfos[dev->minor].b_StructInitialized != 1) {
s_BoardInfos[dev->minor].i_CJCAvailable = 1;
s_BoardInfos[dev->minor].i_CJCPolarity = 0;
- s_BoardInfos[dev->minor].i_CJCGain = 2; //changed from 0 to 2
+ s_BoardInfos[dev->minor].i_CJCGain = 2; /* changed from 0 to 2 */
s_BoardInfos[dev->minor].i_InterruptFlag = 0;
- s_BoardInfos[dev->minor].i_AutoCalibration = 0; //: auto calibration
+ s_BoardInfos[dev->minor].i_AutoCalibration = 0; /* : auto calibration */
s_BoardInfos[dev->minor].i_ChannelCount = 0;
s_BoardInfos[dev->minor].i_Sum = 0;
s_BoardInfos[dev->minor].ui_Channel_num = 0;
@@ -905,11 +898,11 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde
s_BoardInfos[dev->minor].i_Initialised = 0;
s_BoardInfos[dev->minor].b_StructInitialized = 1;
- //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
s_BoardInfos[dev->minor].i_ConnectionType = 0;
- //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
- //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
memset(s_BoardInfos[dev->minor].s_Module, 0,
sizeof(s_BoardInfos[dev->minor].s_Module[MAX_MODULE]));
@@ -938,72 +931,72 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde
}
}
#endif
- //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
}
if (data[0] != 0 && data[0] != 1 && data[0] != 2) {
printk("\nThe selection of acquisition type is in error\n");
i_err++;
- } //if(data[0]!=0 && data[0]!=1 && data[0]!=2)
+ } /* if(data[0]!=0 && data[0]!=1 && data[0]!=2) */
if (data[0] == 1) {
if (data[14] != 0 && data[14] != 1 && data[14] != 2
&& data[14] != 4) {
printk("\n Error in selection of RTD connection type\n");
i_err++;
- } //if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4)
- } //if(data[0]==1 )
+ } /* if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) */
+ } /* if(data[0]==1 ) */
if (data[1] < 0 || data[1] > 7) {
printk("\nThe selection of gain is in error\n");
i_err++;
- } // if(data[1]<0 || data[1]>7)
+ } /* if(data[1]<0 || data[1]>7) */
if (data[2] != 0 && data[2] != 1) {
printk("\nThe selection of polarity is in error\n");
i_err++;
- } //if(data[2]!=0 && data[2]!=1)
+ } /* if(data[2]!=0 && data[2]!=1) */
if (data[3] != 0) {
printk("\nThe selection of offset range is in error\n");
i_err++;
- } // if(data[3]!=0)
+ } /* if(data[3]!=0) */
if (data[4] != 0 && data[4] != 1) {
printk("\nThe selection of coupling is in error\n");
i_err++;
- } //if(data[4]!=0 && data[4]!=1)
+ } /* if(data[4]!=0 && data[4]!=1) */
if (data[5] != 0 && data[5] != 1) {
printk("\nThe selection of single/differential mode is in error\n");
i_err++;
- } //if(data[5]!=0 && data[5]!=1)
+ } /* if(data[5]!=0 && data[5]!=1) */
if (data[8] != 0 && data[8] != 1 && data[2] != 2) {
printk("\nError in selection of functionality\n");
- } //if(data[8]!=0 && data[8]!=1 && data[2]!=2)
+ } /* if(data[8]!=0 && data[8]!=1 && data[2]!=2) */
if (data[12] == 0 || data[12] == 1) {
if (data[6] != 20 && data[6] != 40 && data[6] != 80
&& data[6] != 160) {
printk("\nThe selection of conversion time reload value is in error\n");
i_err++;
- } // if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 )
+ } /* if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) */
if (data[7] != 2) {
printk("\nThe selection of conversion time unit is in error\n");
i_err++;
- } // if(data[7]!=2)
+ } /* if(data[7]!=2) */
}
if (data[9] != 0 && data[9] != 1) {
printk("\nThe selection of interrupt enable is in error\n");
i_err++;
- } //if(data[9]!=0 && data[9]!=1)
+ } /* if(data[9]!=0 && data[9]!=1) */
if (data[11] < 0 || data[11] > 4) {
printk("\nThe selection of module is in error\n");
i_err++;
- } //if(data[11] <0 || data[11]>1)
+ } /* if(data[11] <0 || data[11]>1) */
if (data[12] < 0 || data[12] > 3) {
printk("\nThe selection of singlechannel/scan selection is in error\n");
i_err++;
- } //if(data[12] < 0 || data[12]> 3)
+ } /* if(data[12] < 0 || data[12]> 3) */
if (data[13] < 0 || data[13] > 16) {
printk("\nThe selection of number of channels is in error\n");
i_err++;
- } // if(data[13] <0 ||data[13] >15)
+ } /* if(data[13] <0 ||data[13] >15) */
- //BEGIN JK 06.07.04: Management of sevrals boards
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
/*
i_ChannelCount=data[13];
i_ScanType=data[12];
@@ -1014,7 +1007,7 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde
i_ADDIDATAType=data[0];
*/
- // Save acquisition configuration for the actual board
+ /* Save acquisition configuration for the actual board */
s_BoardInfos[dev->minor].i_ChannelCount = data[13];
s_BoardInfos[dev->minor].i_ScanType = data[12];
s_BoardInfos[dev->minor].i_ADDIDATAPolarity = data[2];
@@ -1022,307 +1015,307 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde
s_BoardInfos[dev->minor].i_ADDIDATAConversionTime = data[6];
s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit = data[7];
s_BoardInfos[dev->minor].i_ADDIDATAType = data[0];
- //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+ /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
s_BoardInfos[dev->minor].i_ConnectionType = data[5];
- //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //END JK 06.07.04: Management of sevrals boards
+ /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* END JK 06.07.04: Management of sevrals boards */
- //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); // 7 is the maximal number of channels
- //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+ /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); /* 7 is the maximal number of channels */
+ /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
- //BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards
- //while(i_InterruptFlag==1)
+ /* BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards */
+ /* while(i_InterruptFlag==1) */
while (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
#ifndef MSXBOX
udelay(1);
#else
- // In the case where the driver is compiled for the MSX-Box
- // we used a printk to have a little delay because udelay
- // seems to be broken under the MSX-Box.
- // This solution hat to be studied.
+ /* In the case where the driver is compiled for the MSX-Box */
+ /* we used a printk to have a little delay because udelay */
+ /* seems to be broken under the MSX-Box. */
+ /* This solution hat to be studied. */
printk("");
#endif
}
- //END JK 02.07.04 : This while can't be do, it block the process when using severals boards
+ /* END JK 02.07.04 : This while can't be do, it block the process when using severals boards */
- ui_ChannelNo = CR_CHAN(insn->chanspec); // get the channel
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_ChannelNo=ui_ChannelNo;
- //ui_Channel_num =ui_ChannelNo;
+ ui_ChannelNo = CR_CHAN(insn->chanspec); /* get the channel */
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_ChannelNo=ui_ChannelNo; */
+ /* ui_Channel_num =ui_ChannelNo; */
s_BoardInfos[dev->minor].i_ChannelNo = ui_ChannelNo;
s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNo;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
if (data[5] == 0) {
if (ui_ChannelNo < 0 || ui_ChannelNo > 15) {
printk("\nThe Selection of the channel is in error\n");
i_err++;
- } // if(ui_ChannelNo<0 || ui_ChannelNo>15)
- } //if(data[5]==0)
+ } /* if(ui_ChannelNo<0 || ui_ChannelNo>15) */
+ } /* if(data[5]==0) */
else {
if (data[14] == 2) {
if (ui_ChannelNo < 0 || ui_ChannelNo > 3) {
printk("\nThe Selection of the channel is in error\n");
i_err++;
- } // if(ui_ChannelNo<0 || ui_ChannelNo>3)
- } //if(data[14]==2)
+ } /* if(ui_ChannelNo<0 || ui_ChannelNo>3) */
+ } /* if(data[14]==2) */
else {
if (ui_ChannelNo < 0 || ui_ChannelNo > 7) {
printk("\nThe Selection of the channel is in error\n");
i_err++;
- } // if(ui_ChannelNo<0 || ui_ChannelNo>7)
- } //elseif(data[14]==2)
- } //elseif(data[5]==0)
+ } /* if(ui_ChannelNo<0 || ui_ChannelNo>7) */
+ } /* elseif(data[14]==2) */
+ } /* elseif(data[5]==0) */
if (data[12] == 0 || data[12] == 1) {
switch (data[5]) {
case 0:
if (ui_ChannelNo >= 0 && ui_ChannelNo <= 3) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=0; */
s_BoardInfos[dev->minor].i_Offset = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo >=0 && ui_ChannelNo <=3)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo >=0 && ui_ChannelNo <=3) */
if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=64;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=64; */
s_BoardInfos[dev->minor].i_Offset = 64;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo >=4 && ui_ChannelNo <=7)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo >=4 && ui_ChannelNo <=7) */
if (ui_ChannelNo >= 8 && ui_ChannelNo <= 11) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=128;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=128; */
s_BoardInfos[dev->minor].i_Offset = 128;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo >=8 && ui_ChannelNo <=11)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo >=8 && ui_ChannelNo <=11) */
if (ui_ChannelNo >= 12 && ui_ChannelNo <= 15) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=192;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=192; */
s_BoardInfos[dev->minor].i_Offset = 192;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo >=12 && ui_ChannelNo <=15)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo >=12 && ui_ChannelNo <=15) */
break;
case 1:
if (data[14] == 2) {
if (ui_ChannelNo == 0) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=0; */
s_BoardInfos[dev->minor].i_Offset = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo ==0 )
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo ==0 ) */
if (ui_ChannelNo == 1) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=0; */
s_BoardInfos[dev->minor].i_Offset = 64;
- //END JK 06.07.04: Management of sevrals boards
- } // if(ui_ChannelNo ==1)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo ==1) */
if (ui_ChannelNo == 2) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=128;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=128; */
s_BoardInfos[dev->minor].i_Offset = 128;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo ==2 )
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo ==2 ) */
if (ui_ChannelNo == 3) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=192;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=192; */
s_BoardInfos[dev->minor].i_Offset = 192;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo ==3)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo ==3) */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_ChannelNo=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_ChannelNo=0; */
s_BoardInfos[dev->minor].i_ChannelNo = 0;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
ui_ChannelNo = 0;
break;
- } //if(data[14]==2)
+ } /* if(data[14]==2) */
if (ui_ChannelNo >= 0 && ui_ChannelNo <= 1) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=0; */
s_BoardInfos[dev->minor].i_Offset = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //if(ui_ChannelNo >=0 && ui_ChannelNo <=1)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(ui_ChannelNo >=0 && ui_ChannelNo <=1) */
if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_ChannelNo=i_ChannelNo-2;
- //i_Offset=64;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_ChannelNo=i_ChannelNo-2; */
+ /* i_Offset=64; */
s_BoardInfos[dev->minor].i_ChannelNo =
s_BoardInfos[dev->minor].i_ChannelNo -
2;
s_BoardInfos[dev->minor].i_Offset = 64;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
ui_ChannelNo = ui_ChannelNo - 2;
- } //if(ui_ChannelNo >=2 && ui_ChannelNo <=3)
+ } /* if(ui_ChannelNo >=2 && ui_ChannelNo <=3) */
if (ui_ChannelNo >= 4 && ui_ChannelNo <= 5) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_ChannelNo=i_ChannelNo-4;
- //i_Offset=128;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_ChannelNo=i_ChannelNo-4; */
+ /* i_Offset=128; */
s_BoardInfos[dev->minor].i_ChannelNo =
s_BoardInfos[dev->minor].i_ChannelNo -
4;
s_BoardInfos[dev->minor].i_Offset = 128;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
ui_ChannelNo = ui_ChannelNo - 4;
- } //if(ui_ChannelNo >=4 && ui_ChannelNo <=5)
+ } /* if(ui_ChannelNo >=4 && ui_ChannelNo <=5) */
if (ui_ChannelNo >= 6 && ui_ChannelNo <= 7) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_ChannelNo=i_ChannelNo-6;
- //i_Offset=192;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_ChannelNo=i_ChannelNo-6; */
+ /* i_Offset=192; */
s_BoardInfos[dev->minor].i_ChannelNo =
s_BoardInfos[dev->minor].i_ChannelNo -
6;
s_BoardInfos[dev->minor].i_Offset = 192;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
ui_ChannelNo = ui_ChannelNo - 6;
- } //if(ui_ChannelNo >=6 && ui_ChannelNo <=7)
+ } /* if(ui_ChannelNo >=6 && ui_ChannelNo <=7) */
break;
default:
printk("\n This selection of polarity does not exist\n");
i_err++;
- } //switch(data[2])
- } //if(data[12]==0 || data[12]==1)
+ } /* switch(data[2]) */
+ } /* if(data[12]==0 || data[12]==1) */
else {
switch (data[11]) {
case 1:
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=0; */
s_BoardInfos[dev->minor].i_Offset = 0;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
break;
case 2:
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=64;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=64; */
s_BoardInfos[dev->minor].i_Offset = 64;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
break;
case 3:
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=128;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=128; */
s_BoardInfos[dev->minor].i_Offset = 128;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
break;
case 4:
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Offset=192;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Offset=192; */
s_BoardInfos[dev->minor].i_Offset = 192;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
break;
default:
printk("\nError in module selection\n");
i_err++;
- } // switch(data[11])
- } // elseif(data[12]==0 || data[12]==1)
+ } /* switch(data[11]) */
+ } /* elseif(data[12]==0 || data[12]==1) */
if (i_err) {
i_APCI3200_Reset(dev);
return -EINVAL;
}
- //if(i_ScanType!=1)
+ /* if(i_ScanType!=1) */
if (s_BoardInfos[dev->minor].i_ScanType != 1) {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Count=0;
- //i_Sum=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Count=0; */
+ /* i_Sum=0; */
s_BoardInfos[dev->minor].i_Count = 0;
s_BoardInfos[dev->minor].i_Sum = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //if(i_ScanType!=1)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(i_ScanType!=1) */
ul_Config =
data[1] | (data[2] << 6) | (data[5] << 7) | (data[3] << 8) |
(data[4] << 9);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
/*********************************/
/* Write the channel to configure */
/*********************************/
- //BEGIN JK 06.07.04: Management of sevrals boards
- //outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); */
outl(0 | ui_ChannelNo,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
/**************************/
/* Reset the configuration */
/**************************/
- //BEGIN JK 06.07.04: Management of sevrals boards
- //outl(0 , devpriv->iobase+i_Offset + 0x0);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* outl(0 , devpriv->iobase+i_Offset + 0x0); */
outl(0, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
/***************************/
/* Write the configuration */
/***************************/
- //BEGIN JK 06.07.04: Management of sevrals boards
- //outl(ul_Config , devpriv->iobase+i_Offset + 0x0);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* outl(ul_Config , devpriv->iobase+i_Offset + 0x0); */
outl(ul_Config,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
/***************************/
/*Reset the calibration bit */
/***************************/
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ul_Temp = inl(devpriv->iobase+i_Offset + 12);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ul_Temp = inl(devpriv->iobase+i_Offset + 12); */
ul_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); */
outl((ul_Temp & 0xFFF9FFFF),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
if (data[9] == 1) {
devpriv->tsk_Current = current;
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_InterruptFlag=1;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_InterruptFlag=1; */
s_BoardInfos[dev->minor].i_InterruptFlag = 1;
- //END JK 06.07.04: Management of sevrals boards
- } // if(data[9]==1)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(data[9]==1) */
else {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_InterruptFlag=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_InterruptFlag=0; */
s_BoardInfos[dev->minor].i_InterruptFlag = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //else if(data[9]==1)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* else if(data[9]==1) */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Initialised=1;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Initialised=1; */
s_BoardInfos[dev->minor].i_Initialised = 1;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if(i_ScanType==1)
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if(i_ScanType==1) */
if (s_BoardInfos[dev->minor].i_ScanType == 1)
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
- //BEGIN JK 06.07.04: Management of sevrals boards
- //i_Sum=i_Sum+1;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* i_Sum=i_Sum+1; */
s_BoardInfos[dev->minor].i_Sum =
s_BoardInfos[dev->minor].i_Sum + 1;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
insn->unused[0] = 0;
i_APCI3200_ReadAnalogInput(dev, s, insn, &ui_Dummy);
@@ -1340,8 +1333,8 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde
| Task : Read value of the selected channel |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT ui_NoOfChannels : No Of Channels To read |
- | UINT *data : Data Pointer to read status |
+ | unsigned int ui_NoOfChannels : No Of Channels To read |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : Digital Value Of Input |
@@ -1361,21 +1354,21 @@ INT i_APCI3200_ConfigAnalogInput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_DummyValue = 0;
+ unsigned int ui_DummyValue = 0;
int i_ConvertCJCCalibration;
int i = 0;
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if(i_Initialised==0)
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if(i_Initialised==0) */
if (s_BoardInfos[dev->minor].i_Initialised == 0)
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
i_APCI3200_Reset(dev);
return -EINVAL;
- } //if(i_Initialised==0);
+ } /* if(i_Initialised==0); */
#ifdef PRINT_INFO
printk("\n insn->unused[0] = %i", insn->unused[0]);
@@ -1386,14 +1379,14 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
i_APCI3200_Read1AnalogInputChannel(dev, s, insn,
&ui_DummyValue);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count+0]=ui_DummyValue;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos[dev->minor].
i_Count + 0] = ui_DummyValue;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- //Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
i_APCI3200_GetChannelCalibrationValue(dev,
s_BoardInfos[dev->minor].ui_Channel_num,
&s_BoardInfos[dev->minor].
@@ -1414,62 +1407,62 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 8]);
#endif
- //End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1))
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
&& (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
&& (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
i_APCI3200_ReadCJCValue(dev, &ui_DummyValue);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos[dev->
minor].i_Count + 3] = ui_DummyValue;
- //END JK 06.07.04: Management of sevrals boards
- } //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE))
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
else {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count + 3]=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count + 3]=0; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos[dev->
minor].i_Count + 3] = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1))
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE))
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
if ((s_BoardInfos[dev->minor].i_AutoCalibration == FALSE)
&& (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE))
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
i_APCI3200_ReadCalibrationOffsetValue(dev,
&ui_DummyValue);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos[dev->
minor].i_Count + 1] = ui_DummyValue;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
i_APCI3200_ReadCalibrationGainValue(dev,
&ui_DummyValue);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos[dev->
minor].i_Count + 2] = ui_DummyValue;
- //END JK 06.07.04: Management of sevrals boards
- } //if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE))
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1))
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) */
if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
&& (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
&& (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
/**********************************************************/
/*Test if the Calibration channel must be read for the CJC */
@@ -1477,52 +1470,52 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
/**********************************/
/*Test if the polarity is the same */
/**********************************/
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if(i_CJCPolarity!=i_ADDIDATAPolarity)
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
if (s_BoardInfos[dev->minor].i_CJCPolarity !=
s_BoardInfos[dev->minor].i_ADDIDATAPolarity)
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
i_ConvertCJCCalibration = 1;
- } //if(i_CJCPolarity!=i_ADDIDATAPolarity)
+ } /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
else {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if(i_CJCGain==i_ADDIDATAGain)
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if(i_CJCGain==i_ADDIDATAGain) */
if (s_BoardInfos[dev->minor].i_CJCGain ==
s_BoardInfos[dev->minor].i_ADDIDATAGain)
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
{
i_ConvertCJCCalibration = 0;
- } //if(i_CJCGain==i_ADDIDATAGain)
+ } /* if(i_CJCGain==i_ADDIDATAGain) */
else {
i_ConvertCJCCalibration = 1;
- } //elseif(i_CJCGain==i_ADDIDATAGain)
- } //elseif(i_CJCPolarity!=i_ADDIDATAPolarity)
+ } /* elseif(i_CJCGain==i_ADDIDATAGain) */
+ } /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */
if (i_ConvertCJCCalibration == 1) {
i_APCI3200_ReadCJCCalOffset(dev,
&ui_DummyValue);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count+4]=ui_DummyValue;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos
[dev->minor].i_Count + 4] =
ui_DummyValue;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue);
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count+5]=ui_DummyValue;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos
[dev->minor].i_Count + 5] =
ui_DummyValue;
- //END JK 06.07.04: Management of sevrals boards
- } //if(i_ConvertCJCCalibration==1)
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* if(i_ConvertCJCCalibration==1) */
else {
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_InterruptChannelValue[i_Count+4]=0;
- //ui_InterruptChannelValue[i_Count+5]=0;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_InterruptChannelValue[i_Count+4]=0; */
+ /* ui_InterruptChannelValue[i_Count+5]=0; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos
@@ -1530,36 +1523,36 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[s_BoardInfos
[dev->minor].i_Count + 5] = 0;
- //END JK 06.07.04: Management of sevrals boards
- } //elseif(i_ConvertCJCCalibration==1)
- } //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE))
+ /* END JK 06.07.04: Management of sevrals boards */
+ } /* elseif(i_ConvertCJCCalibration==1) */
+ } /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
- //BEGIN JK 06.07.04: Management of sevrals boards
- //if(i_ScanType!=1)
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* if(i_ScanType!=1) */
if (s_BoardInfos[dev->minor].i_ScanType != 1) {
- //i_Count=0;
+ /* i_Count=0; */
s_BoardInfos[dev->minor].i_Count = 0;
- } //if(i_ScanType!=1)
+ } /* if(i_ScanType!=1) */
else {
- //i_Count=i_Count +6;
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6;
+ /* i_Count=i_Count +6; */
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; */
s_BoardInfos[dev->minor].i_Count =
s_BoardInfos[dev->minor].i_Count + 9;
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- } //else if(i_ScanType!=1)
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ } /* else if(i_ScanType!=1) */
- //if((i_ScanType==1) &&(i_InterruptFlag==1))
+ /* if((i_ScanType==1) &&(i_InterruptFlag==1)) */
if ((s_BoardInfos[dev->minor].i_ScanType == 1)
&& (s_BoardInfos[dev->minor].i_InterruptFlag == 1)) {
- //i_Count=i_Count-6;
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6;
+ /* i_Count=i_Count-6; */
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; */
s_BoardInfos[dev->minor].i_Count =
s_BoardInfos[dev->minor].i_Count - 9;
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
}
- //if(i_ScanType==0)
+ /* if(i_ScanType==0) */
if (s_BoardInfos[dev->minor].i_ScanType == 0) {
/*
data[0]= ui_InterruptChannelValue[0];
@@ -1591,41 +1584,41 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[5];
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- //printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]);
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ /* printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]); */
i_APCI3200_GetChannelCalibrationValue(dev,
s_BoardInfos[dev->minor].ui_Channel_num,
&data[6], &data[7], &data[8]);
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
}
break;
case 1:
for (i = 0; i < insn->n; i++) {
- //data[i]=ui_InterruptChannelValue[i];
+ /* data[i]=ui_InterruptChannelValue[i]; */
data[i] =
s_BoardInfos[dev->minor].
ui_InterruptChannelValue[i];
}
- //i_Count=0;
- //i_Sum=0;
- //if(i_ScanType==1)
+ /* i_Count=0; */
+ /* i_Sum=0; */
+ /* if(i_ScanType==1) */
s_BoardInfos[dev->minor].i_Count = 0;
s_BoardInfos[dev->minor].i_Sum = 0;
if (s_BoardInfos[dev->minor].i_ScanType == 1) {
- //i_Initialised=0;
- //i_InterruptFlag=0;
+ /* i_Initialised=0; */
+ /* i_InterruptFlag=0; */
s_BoardInfos[dev->minor].i_Initialised = 0;
s_BoardInfos[dev->minor].i_InterruptFlag = 0;
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
}
break;
default:
printk("\nThe parameters passed are in error\n");
i_APCI3200_Reset(dev);
return -EINVAL;
- } //switch(insn->unused[0])
+ } /* switch(insn->unused[0]) */
return insn->n;
}
@@ -1639,8 +1632,8 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
| Task : Read value of the selected channel |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT ui_NoOfChannel : Channel No to read |
- | UINT *data : Data Pointer to read status |
+ | unsigned int ui_NoOfChannel : Channel No to read |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : Digital Value read |
@@ -1651,49 +1644,49 @@ INT i_APCI3200_ReadAnalogInput(struct comedi_device * dev, struct comedi_subdevi
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_EOC = 0;
- UINT ui_ChannelNo = 0;
- UINT ui_CommandRegister = 0;
+ unsigned int ui_EOC = 0;
+ unsigned int ui_ChannelNo = 0;
+ unsigned int ui_CommandRegister = 0;
- //BEGIN JK 06.07.04: Management of sevrals boards
- //ui_ChannelNo=i_ChannelNo;
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* ui_ChannelNo=i_ChannelNo; */
ui_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo;
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
/*********************************/
/* Write the channel to configure */
/*********************************/
- //Begin JK 20.10.2004: Bad channel value is used when using differential mode
- //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
- //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
+ /* Begin JK 20.10.2004: Bad channel value is used when using differential mode */
+ /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
+ /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
outl(0 | s_BoardInfos[dev->minor].i_ChannelNo,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
- //End JK 20.10.2004: Bad channel value is used when using differential mode
+ /* End JK 20.10.2004: Bad channel value is used when using differential mode */
/*******************************/
/* Set the convert timing unit */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+ /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/**************************/
/* Set the convert timing */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+ /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
@@ -1707,36 +1700,36 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev,
/*Test if the interrupt is enable */
/*********************************/
- //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
/************************/
/* Enable the interrupt */
/************************/
ui_CommandRegister = ui_CommandRegister | 0x00100000;
- } //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
/******************************/
/* Write the command register */
/******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8);
+ /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
outl(ui_CommandRegister,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
/*****************************/
/*Test if interrupt is enable */
/*****************************/
- //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
do {
/*************************/
/*Read the EOC Status bit */
/*************************/
- //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+ /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
ui_EOC = inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 20) & 1;
@@ -1746,13 +1739,13 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev,
/* Read the digital value of the input */
/***************************************/
- //data[0] = inl (devpriv->iobase+i_Offset + 28);
+ /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
data[0] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- //END JK 06.07.04: Management of sevrals boards
+ /* END JK 06.07.04: Management of sevrals boards */
- } // if (i_InterruptFlag == ADDIDATA_DISABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
return 0;
}
@@ -1765,7 +1758,7 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev,
| Task : Read calibration offset value of the selected channel|
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT *data : Data Pointer to read status |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : Calibration offset Value |
@@ -1776,54 +1769,54 @@ INT i_APCI3200_Read1AnalogInputChannel(struct comedi_device * dev,
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * data)
+int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data)
{
- UINT ui_Temp = 0, ui_EOC = 0;
- UINT ui_CommandRegister = 0;
+ unsigned int ui_Temp = 0, ui_EOC = 0;
+ unsigned int ui_CommandRegister = 0;
- //BEGIN JK 06.07.04: Management of sevrals boards
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* BEGIN JK 06.07.04: Management of sevrals boards */
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
/*********************************/
/* Write the channel to configure */
/*********************************/
- //Begin JK 20.10.2004: This seems not necessary !
- //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
- //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
- //End JK 20.10.2004: This seems not necessary !
+ /* Begin JK 20.10.2004: This seems not necessary ! */
+ /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
+ /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
+ /* End JK 20.10.2004: This seems not necessary ! */
/*******************************/
/* Set the convert timing unit */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+ /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/**************************/
/* Set the convert timing */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+ /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
/*****************************/
/*Read the calibration offset */
/*****************************/
- //ui_Temp = inl(devpriv->iobase+i_Offset + 12);
+ /* ui_Temp = inl(devpriv->iobase+i_Offset + 12); */
ui_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
/*********************************/
/*Configure the Offset Conversion */
/*********************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12);
+ /* outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); */
outl((ui_Temp | 0x00020000),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
/*******************************/
@@ -1836,7 +1829,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
/*Test if the interrupt is enable */
/*********************************/
- //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
/**********************/
@@ -1845,7 +1838,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
ui_CommandRegister = ui_CommandRegister | 0x00100000;
- } //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
/**********************/
/*Start the conversion */
@@ -1855,10 +1848,10 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
/***************************/
/*Write the command regiter */
/***************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8);
+ /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
outl(ui_CommandRegister,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
@@ -1866,7 +1859,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
/*Test if interrupt is enable */
/*****************************/
- //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
do {
@@ -1874,7 +1867,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
/*Read the EOC flag */
/*******************/
- //ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1;
+ /* ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; */
ui_EOC = inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 20) & 1;
@@ -1884,11 +1877,11 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
/*Read the digital value of the calibration Offset */
/**************************************************/
- //data[0] = inl(devpriv->iobase+i_Offset+ 28);
+ /* data[0] = inl(devpriv->iobase+i_Offset+ 28); */
data[0] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- } //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
return 0;
}
@@ -1901,7 +1894,7 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
| Task : Read calibration gain value of the selected channel |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT *data : Data Pointer to read status |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : Calibration gain Value Of Input |
@@ -1912,21 +1905,21 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device * dev, UINT * dat
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
+int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data)
{
- UINT ui_EOC = 0;
- INT ui_CommandRegister = 0;
+ unsigned int ui_EOC = 0;
+ int ui_CommandRegister = 0;
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
/*********************************/
/* Write the channel to configure */
/*********************************/
- //Begin JK 20.10.2004: This seems not necessary !
- //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
- //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
- //End JK 20.10.2004: This seems not necessary !
+ /* Begin JK 20.10.2004: This seems not necessary ! */
+ /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
+ /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
+ /* End JK 20.10.2004: This seems not necessary ! */
/***************************/
/*Read the calibration gain */
@@ -1934,28 +1927,28 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
/*******************************/
/* Set the convert timing unit */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+ /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/**************************/
/* Set the convert timing */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+ /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
/*******************************/
/*Configure the Gain Conversion */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(0x00040000 , devpriv->iobase+i_Offset + 12);
+ /* outl(0x00040000 , devpriv->iobase+i_Offset + 12); */
outl(0x00040000,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
@@ -1969,7 +1962,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
/*Test if the interrupt is enable */
/*********************************/
- //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
/**********************/
@@ -1978,7 +1971,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
ui_CommandRegister = ui_CommandRegister | 0x00100000;
- } //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
/**********************/
/*Start the conversion */
@@ -1988,10 +1981,10 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
/***************************/
/*Write the command regiter */
/***************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8);
+ /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
outl(ui_CommandRegister,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
@@ -1999,7 +1992,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
/*Test if interrupt is enable */
/*****************************/
- //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
do {
@@ -2008,7 +2001,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
/*Read the EOC flag */
/*******************/
- //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+ /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
ui_EOC = inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 20) & 1;
@@ -2018,12 +2011,12 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
/*Read the digital value of the calibration Gain */
/************************************************/
- //data[0] = inl(devpriv->iobase+i_Offset + 28);
+ /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
data[0] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- } //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
return 0;
}
@@ -2036,7 +2029,7 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
| Task : Read CJC value of the selected channel |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT *data : Data Pointer to read status |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : CJC Value |
@@ -2048,41 +2041,41 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device * dev, UINT * data)
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
+int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data)
{
- UINT ui_EOC = 0;
- INT ui_CommandRegister = 0;
+ unsigned int ui_EOC = 0;
+ int ui_CommandRegister = 0;
/******************************/
/*Set the converting time unit */
/******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+ /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/**************************/
/* Set the convert timing */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+ /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
/******************************/
/*Configure the CJC Conversion */
/******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl( 0x00000400 , devpriv->iobase+i_Offset + 4);
+ /* outl( 0x00000400 , devpriv->iobase+i_Offset + 4); */
outl(0x00000400,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
/*******************************/
@@ -2092,7 +2085,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
/*********************************/
/*Test if the interrupt is enable */
/*********************************/
- //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
/**********************/
/*Enable the interrupt */
@@ -2109,10 +2102,10 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
/***************************/
/*Write the command regiter */
/***************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8);
+ /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
outl(ui_CommandRegister,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
@@ -2120,7 +2113,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
/*Test if interrupt is enable */
/*****************************/
- //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
do {
@@ -2128,7 +2121,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
/*Read the EOC flag */
/*******************/
- //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+ /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
ui_EOC = inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 20) & 1;
@@ -2138,12 +2131,12 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
/*Read the digital value of the CJC */
/***********************************/
- //data[0] = inl(devpriv->iobase+i_Offset + 28);
+ /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
data[0] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- } //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
return 0;
}
@@ -2156,7 +2149,7 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
| Task : Read CJC calibration offset value of the selected channel
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT *data : Data Pointer to read status |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : CJC calibration offset Value
@@ -2167,47 +2160,47 @@ int i_APCI3200_ReadCJCValue(struct comedi_device * dev, unsigned int * data)
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data)
+int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data)
{
- UINT ui_EOC = 0;
- INT ui_CommandRegister = 0;
+ unsigned int ui_EOC = 0;
+ int ui_CommandRegister = 0;
/*******************************************/
/*Read calibration offset value for the CJC */
/*******************************************/
/*******************************/
/* Set the convert timing unit */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+ /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/**************************/
/* Set the convert timing */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+ /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
/******************************/
/*Configure the CJC Conversion */
/******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(0x00000400 , devpriv->iobase+i_Offset + 4);
+ /* outl(0x00000400 , devpriv->iobase+i_Offset + 4); */
outl(0x00000400,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
/*********************************/
/*Configure the Offset Conversion */
/*********************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(0x00020000, devpriv->iobase+i_Offset + 12);
+ /* outl(0x00020000, devpriv->iobase+i_Offset + 12); */
outl(0x00020000,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
/*******************************/
@@ -2218,7 +2211,7 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data)
/*Test if the interrupt is enable */
/*********************************/
- //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
/**********************/
/*Enable the interrupt */
@@ -2234,19 +2227,19 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data)
/***************************/
/*Write the command regiter */
/***************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8);
+ /* outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); */
outl(ui_CommandRegister,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
- //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
do {
/*******************/
/*Read the EOC flag */
/*******************/
- //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+ /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
ui_EOC = inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 20) & 1;
} while (ui_EOC != 1);
@@ -2254,11 +2247,11 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data)
/**************************************************/
/*Read the digital value of the calibration Offset */
/**************************************************/
- //data[0] = inl(devpriv->iobase+i_Offset + 28);
+ /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
data[0] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- } //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
return 0;
}
@@ -2271,8 +2264,8 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data)
| Task : Read CJC calibration gain value
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
- | UINT ui_NoOfChannels : No Of Channels To read |
- | UINT *data : Data Pointer to read status |
+ | unsigned int ui_NoOfChannels : No Of Channels To read |
+ | unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
| data[0] : CJC calibration gain value
@@ -2283,44 +2276,44 @@ int i_APCI3200_ReadCJCCalOffset(struct comedi_device * dev, unsigned int * data)
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data)
+int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev, unsigned int *data)
{
- UINT ui_EOC = 0;
- INT ui_CommandRegister = 0;
+ unsigned int ui_EOC = 0;
+ int ui_CommandRegister = 0;
/*******************************/
/* Set the convert timing unit */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+ /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/**************************/
/* Set the convert timing */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+ /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
/******************************/
/*Configure the CJC Conversion */
/******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(0x00000400,devpriv->iobase+i_Offset + 4);
+ /* outl(0x00000400,devpriv->iobase+i_Offset + 4); */
outl(0x00000400,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
/*******************************/
/*Configure the Gain Conversion */
/*******************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(0x00040000,devpriv->iobase+i_Offset + 12);
+ /* outl(0x00040000,devpriv->iobase+i_Offset + 12); */
outl(0x00040000,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
@@ -2331,7 +2324,7 @@ int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data)
/*********************************/
/*Test if the interrupt is enable */
/*********************************/
- //if (i_InterruptFlag == ADDIDATA_ENABLE)
+ /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
/**********************/
/*Enable the interrupt */
@@ -2345,30 +2338,30 @@ int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data)
/***************************/
/*Write the command regiter */
/***************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8);
+ /* outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); */
outl(ui_CommandRegister,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
- //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
do {
/*******************/
/*Read the EOC flag */
/*******************/
- //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+ /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
ui_EOC = inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 20) & 1;
} while (ui_EOC != 1);
/************************************************/
/*Read the digital value of the calibration Gain */
/************************************************/
- //data[0] = inl (devpriv->iobase+i_Offset + 28);
+ /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
data[0] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- } //if (i_InterruptFlag == ADDIDATA_DISABLE)
+ } /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
return 0;
}
@@ -2404,33 +2397,33 @@ int i_APCI3200_ReadCJCCalGain(struct comedi_device * dev, unsigned int * data)
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Configuration = 0;
- INT i_Temp; //,i_TimeUnit;
- //if(i_Initialised==0)
+ unsigned int ui_Configuration = 0;
+ int i_Temp; /* ,i_TimeUnit; */
+ /* if(i_Initialised==0) */
if (s_BoardInfos[dev->minor].i_Initialised == 0) {
i_APCI3200_Reset(dev);
return -EINVAL;
- } //if(i_Initialised==0);
+ } /* if(i_Initialised==0); */
if (data[0] != 0 && data[0] != 1) {
printk("\nError in selection of functionality\n");
i_APCI3200_Reset(dev);
return -EINVAL;
- } //if(data[0]!=0 && data[0]!=1)
+ } /* if(data[0]!=0 && data[0]!=1) */
- if (data[0] == 1) //Perform Short Circuit TEST
+ if (data[0] == 1) /* Perform Short Circuit TEST */
{
/**************************/
/*Set the short-cicuit bit */
/**************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
i_Offset + 12) >> 19) & 1) !=
1) ;
- //outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+ /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
outl((0x00001000 | s_BoardInfos[dev->minor].i_ChannelNo),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
4);
@@ -2439,19 +2432,19 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev,
/*************************/
/* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
i_ADDIDATAConversionTimeUnit= 1; */
- //i_Temp= i_InterruptFlag ;
+ /* i_Temp= i_InterruptFlag ; */
i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag;
- //i_InterruptFlag = ADDIDATA_DISABLE;
+ /* i_InterruptFlag = ADDIDATA_DISABLE; */
s_BoardInfos[dev->minor].i_InterruptFlag = ADDIDATA_DISABLE;
i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data);
- //if(i_AutoCalibration == FALSE)
+ /* if(i_AutoCalibration == FALSE) */
if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) {
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
i_Offset +
12) >> 19) & 1) != 1) ;
- //outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+ /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
outl((0x00001000 | s_BoardInfos[dev->minor].
i_ChannelNo),
devpriv->iobase +
@@ -2462,15 +2455,15 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev,
i_APCI3200_ReadCalibrationGainValue(dev, data);
}
} else {
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
i_Offset + 12) >> 19) & 1) !=
1) ;
- //outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+ /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
outl((0x00000800 | s_BoardInfos[dev->minor].i_ChannelNo),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
4);
- //ui_Configuration = inl(devpriv->iobase+i_Offset + 0);
+ /* ui_Configuration = inl(devpriv->iobase+i_Offset + 0); */
ui_Configuration =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 0);
@@ -2479,18 +2472,18 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev,
/*************************/
/* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
i_ADDIDATAConversionTimeUnit= 1; */
- //i_Temp= i_InterruptFlag ;
+ /* i_Temp= i_InterruptFlag ; */
i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag;
- //i_InterruptFlag = ADDIDATA_DISABLE;
+ /* i_InterruptFlag = ADDIDATA_DISABLE; */
s_BoardInfos[dev->minor].i_InterruptFlag = ADDIDATA_DISABLE;
i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data);
- //if(i_AutoCalibration == FALSE)
+ /* if(i_AutoCalibration == FALSE) */
if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) {
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].
i_Offset +
12) >> 19) & 1) != 1) ;
- //outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+ /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */
outl((0x00000800 | s_BoardInfos[dev->minor].
i_ChannelNo),
devpriv->iobase +
@@ -2501,9 +2494,9 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev,
i_APCI3200_ReadCalibrationGainValue(dev, data);
}
}
- //i_InterruptFlag=i_Temp ;
+ /* i_InterruptFlag=i_Temp ; */
s_BoardInfos[dev->minor].i_InterruptFlag = i_Temp;
- //printk("\ni_InterruptFlag=%d\n",i_InterruptFlag);
+ /* printk("\ni_InterruptFlag=%d\n",i_InterruptFlag); */
return insn->n;
}
@@ -2529,8 +2522,8 @@ INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-INT i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
i_APCI3200_Reset(dev);
return insn->n;
@@ -2560,23 +2553,23 @@ INT i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
- int tmp; // divisor1,divisor2;
- UINT ui_ConvertTime = 0;
- UINT ui_ConvertTimeBase = 0;
- UINT ui_DelayTime = 0;
- UINT ui_DelayTimeBase = 0;
- INT i_Triggermode = 0;
- INT i_TriggerEdge = 0;
- INT i_NbrOfChannel = 0;
- INT i_Cpt = 0;
+ int tmp; /* divisor1,divisor2; */
+ unsigned int ui_ConvertTime = 0;
+ unsigned int ui_ConvertTimeBase = 0;
+ unsigned int ui_DelayTime = 0;
+ unsigned int ui_DelayTimeBase = 0;
+ int i_Triggermode = 0;
+ int i_TriggerEdge = 0;
+ int i_NbrOfChannel = 0;
+ int i_Cpt = 0;
double d_ConversionTimeForAllChannels = 0.0;
double d_SCANTimeNewUnit = 0.0;
- // step 1: make sure trigger sources are trivially valid
+ /* step 1: make sure trigger sources are trivially valid */
tmp = cmd->start_src;
cmd->start_src &= TRIG_NOW | TRIG_EXT;
@@ -2598,10 +2591,10 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
cmd->stop_src &= TRIG_COUNT | TRIG_NONE;
if (!cmd->stop_src || tmp != cmd->stop_src)
err++;
- //if(i_InterruptFlag==0)
+ /* if(i_InterruptFlag==0) */
if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
err++;
- // printk("\nThe interrupt should be enabled\n");
+ /* printk("\nThe interrupt should be enabled\n"); */
}
if (err) {
i_APCI3200_Reset(dev);
@@ -2643,9 +2636,9 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
i_APCI3200_Reset(dev);
return 2;
}
- //i_FirstChannel=cmd->chanlist[0];
+ /* i_FirstChannel=cmd->chanlist[0]; */
s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0];
- //i_LastChannel=cmd->chanlist[1];
+ /* i_LastChannel=cmd->chanlist[1]; */
s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1];
if (cmd->convert_src == TRIG_TIMER) {
@@ -2656,11 +2649,11 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
{
printk("\nThe selection of conversion time reload value is in error\n");
err++;
- } // if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 )
+ } /* if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) */
if (ui_ConvertTimeBase != 2) {
printk("\nThe selection of conversion time unit is in error\n");
err++;
- } //if(ui_ConvertTimeBase!=2)
+ } /* if(ui_ConvertTimeBase!=2) */
} else {
ui_ConvertTime = 0;
ui_ConvertTimeBase = 0;
@@ -2668,7 +2661,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
if (cmd->scan_begin_src == TRIG_FOLLOW) {
ui_DelayTime = 0;
ui_DelayTimeBase = 0;
- } //if(cmd->scan_begin_src==TRIG_FOLLOW)
+ } /* if(cmd->scan_begin_src==TRIG_FOLLOW) */
else {
ui_DelayTime = cmd->scan_begin_arg & 0xFFFF;
ui_DelayTimeBase = cmd->scan_begin_arg >> 16;
@@ -2686,7 +2679,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
}
fpu_begin();
d_SCANTimeNewUnit = (double)ui_DelayTime;
- //i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4;
+ /* i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4; */
i_NbrOfChannel =
s_BoardInfos[dev->minor].i_LastChannel -
s_BoardInfos[dev->minor].i_FirstChannel + 4;
@@ -2736,7 +2729,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
err++;
}
fpu_end();
- } //else if(cmd->scan_begin_src==TRIG_FOLLOW)
+ } /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */
if (err) {
i_APCI3200_Reset(dev);
@@ -2764,13 +2757,13 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device * dev, struct comedi_
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_subdevice * s)
+int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s)
{
- UINT ui_Configuration = 0;
- //i_InterruptFlag=0;
- //i_Initialised=0;
- //i_Count=0;
- //i_Sum=0;
+ unsigned int ui_Configuration = 0;
+ /* i_InterruptFlag=0; */
+ /* i_Initialised=0; */
+ /* i_Count=0; */
+ /* i_Sum=0; */
s_BoardInfos[dev->minor].i_InterruptFlag = 0;
s_BoardInfos[dev->minor].i_Initialised = 0;
s_BoardInfos[dev->minor].i_Count = 0;
@@ -2779,16 +2772,16 @@ int i_APCI3200_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_s
/*******************/
/*Read the register */
/*******************/
- //ui_Configuration = inl(devpriv->iobase+i_Offset + 8);
+ /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */
ui_Configuration =
inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
/*****************************/
/*Reset the START and IRQ bit */
/*****************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8);
+ /* outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8); */
outl((ui_Configuration & 0xFFE7FFFF),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
return 0;
@@ -2814,52 +2807,52 @@ int i_APCI3200_StopCyclicAcquisition(struct comedi_device * dev, struct comedi_s
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subdevice * s)
+int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
- UINT ui_Configuration = 0;
- //INT i_CurrentSource = 0;
- UINT ui_Trigger = 0;
- UINT ui_TriggerEdge = 0;
- UINT ui_Triggermode = 0;
- UINT ui_ScanMode = 0;
- UINT ui_ConvertTime = 0;
- UINT ui_ConvertTimeBase = 0;
- UINT ui_DelayTime = 0;
- UINT ui_DelayTimeBase = 0;
- UINT ui_DelayMode = 0;
- //i_FirstChannel=cmd->chanlist[0];
- //i_LastChannel=cmd->chanlist[1];
+ unsigned int ui_Configuration = 0;
+ /* INT i_CurrentSource = 0; */
+ unsigned int ui_Trigger = 0;
+ unsigned int ui_TriggerEdge = 0;
+ unsigned int ui_Triggermode = 0;
+ unsigned int ui_ScanMode = 0;
+ unsigned int ui_ConvertTime = 0;
+ unsigned int ui_ConvertTimeBase = 0;
+ unsigned int ui_DelayTime = 0;
+ unsigned int ui_DelayTimeBase = 0;
+ unsigned int ui_DelayMode = 0;
+ /* i_FirstChannel=cmd->chanlist[0]; */
+ /* i_LastChannel=cmd->chanlist[1]; */
s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0];
s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1];
if (cmd->start_src == TRIG_EXT) {
ui_Trigger = 1;
ui_TriggerEdge = cmd->start_arg & 0xFFFF;
ui_Triggermode = cmd->start_arg >> 16;
- } //if(cmd->start_src==TRIG_EXT)
+ } /* if(cmd->start_src==TRIG_EXT) */
else {
ui_Trigger = 0;
- } //elseif(cmd->start_src==TRIG_EXT)
+ } /* elseif(cmd->start_src==TRIG_EXT) */
if (cmd->stop_src == TRIG_COUNT) {
ui_ScanMode = 0;
- } // if (cmd->stop_src==TRIG_COUNT)
+ } /* if (cmd->stop_src==TRIG_COUNT) */
else {
ui_ScanMode = 2;
- } //else if (cmd->stop_src==TRIG_COUNT)
+ } /* else if (cmd->stop_src==TRIG_COUNT) */
if (cmd->scan_begin_src == TRIG_FOLLOW) {
ui_DelayTime = 0;
ui_DelayTimeBase = 0;
ui_DelayMode = 0;
- } //if(cmd->scan_begin_src==TRIG_FOLLOW)
+ } /* if(cmd->scan_begin_src==TRIG_FOLLOW) */
else {
ui_DelayTime = cmd->scan_begin_arg & 0xFFFF;
ui_DelayTimeBase = cmd->scan_begin_arg >> 16;
ui_DelayMode = 1;
- } //else if(cmd->scan_begin_src==TRIG_FOLLOW)
- // printk("\nui_DelayTime=%u\n",ui_DelayTime);
- // printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase);
+ } /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */
+ /* printk("\nui_DelayTime=%u\n",ui_DelayTime); */
+ /* printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase); */
if (cmd->convert_src == TRIG_TIMER) {
ui_ConvertTime = cmd->convert_arg & 0xFFFF;
ui_ConvertTimeBase = cmd->convert_arg >> 16;
@@ -2868,34 +2861,34 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd
ui_ConvertTimeBase = 0;
}
- // if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2)))
- // {
+ /* if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2))) */
+ /* { */
/**************************************************/
/*Read the old configuration of the current source */
/**************************************************/
- //ui_Configuration = inl(devpriv->iobase+i_Offset + 12);
+ /* ui_Configuration = inl(devpriv->iobase+i_Offset + 12); */
ui_Configuration =
inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
/***********************************************/
/*Write the configuration of the current source */
/***********************************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12);
+ /* outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12); */
outl((ui_Configuration & 0xFFC00000),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
- // }
+ /* } */
ui_Configuration = 0;
- // printk("\nfirstchannel=%u\n",i_FirstChannel);
- // printk("\nlastchannel=%u\n",i_LastChannel);
- // printk("\nui_Trigger=%u\n",ui_Trigger);
- // printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge);
- // printk("\nui_Triggermode=%u\n",ui_Triggermode);
- // printk("\nui_DelayMode=%u\n",ui_DelayMode);
- // printk("\nui_ScanMode=%u\n",ui_ScanMode);
-
- //ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 |
+ /* printk("\nfirstchannel=%u\n",i_FirstChannel); */
+ /* printk("\nlastchannel=%u\n",i_LastChannel); */
+ /* printk("\nui_Trigger=%u\n",ui_Trigger); */
+ /* printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge); */
+ /* printk("\nui_Triggermode=%u\n",ui_Triggermode); */
+ /* printk("\nui_DelayMode=%u\n",ui_DelayMode); */
+ /* printk("\nui_ScanMode=%u\n",ui_ScanMode); */
+
+ /* ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 | */
ui_Configuration =
s_BoardInfos[dev->minor].i_FirstChannel | (s_BoardInfos[dev->
minor].
@@ -2906,80 +2899,80 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd
/*************************/
/*Write the Configuration */
/*************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8);
+ /* outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8); */
outl(ui_Configuration,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x8);
/***********************/
/*Write the Delay Value */
/***********************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_DelayTime,devpriv->iobase+i_Offset + 40);
+ /* outl(ui_DelayTime,devpriv->iobase+i_Offset + 40); */
outl(ui_DelayTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 40);
/***************************/
/*Write the Delay time base */
/***************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44);
+ /* outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44); */
outl(ui_DelayTimeBase,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 44);
/*********************************/
/*Write the conversion time value */
/*********************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32);
+ /* outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32); */
outl(ui_ConvertTime,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
/********************************/
/*Write the conversion time base */
/********************************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36);
+ /* outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36); */
outl(ui_ConvertTimeBase,
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
/*******************/
/*Read the register */
/*******************/
- //ui_Configuration = inl(devpriv->iobase+i_Offset + 4);
+ /* ui_Configuration = inl(devpriv->iobase+i_Offset + 4); */
ui_Configuration =
inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
/******************/
/*Set the SCAN bit */
/******************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4);
+ /* outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); */
outl(((ui_Configuration & 0x1E0FF) | 0x00002000),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
/*******************/
/*Read the register */
/*******************/
ui_Configuration = 0;
- //ui_Configuration = inl(devpriv->iobase+i_Offset + 8);
+ /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */
ui_Configuration =
inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
/*******************/
/*Set the START bit */
/*******************/
- //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+ /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
12) >> 19) & 1) != 1) ;
- //outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8);
+ /* outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); */
outl((ui_Configuration | 0x00080000),
devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
return 0;
@@ -3001,14 +2994,14 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device * dev, struct comedi_subd
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_Reset(struct comedi_device * dev)
+int i_APCI3200_Reset(struct comedi_device *dev)
{
- INT i_Temp;
- DWORD dw_Dummy;
- //i_InterruptFlag=0;
- //i_Initialised==0;
- //i_Count=0;
- //i_Sum=0;
+ int i_Temp;
+ unsigned int dw_Dummy;
+ /* i_InterruptFlag=0; */
+ /* i_Initialised==0; */
+ /* i_Count=0; */
+ /* i_Sum=0; */
s_BoardInfos[dev->minor].i_InterruptFlag = 0;
s_BoardInfos[dev->minor].i_Initialised = 0;
@@ -3018,17 +3011,17 @@ int i_APCI3200_Reset(struct comedi_device * dev)
outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
- // Enable the interrupt for the controler
+ /* Enable the interrupt for the controler */
dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
- outl(0, devpriv->i_IobaseAddon); //Resets the output
+ outl(0, devpriv->i_IobaseAddon); /* Resets the output */
/***************/
/*Empty the buffer */
/**************/
for (i_Temp = 0; i_Temp <= 95; i_Temp++) {
- //ui_InterruptChannelValue[i_Temp]=0;
+ /* ui_InterruptChannelValue[i_Temp]=0; */
s_BoardInfos[dev->minor].ui_InterruptChannelValue[i_Temp] = 0;
- } //for(i_Temp=0;i_Temp<=95;i_Temp++)
+ } /* for(i_Temp=0;i_Temp<=95;i_Temp++) */
/*****************************/
/*Reset the START and IRQ bit */
/*****************************/
@@ -3036,7 +3029,7 @@ int i_APCI3200_Reset(struct comedi_device * dev)
while (((inl(devpriv->iobase + i_Temp + 12) >> 19) & 1) != 1) ;
outl(0, devpriv->iobase + i_Temp + 8);
i_Temp = i_Temp + 64;
- } //for(i_Temp=0;i_Temp<=192;i_Temp+64)
+ } /* for(i_Temp=0;i_Temp<=192;i_Temp+64) */
return 0;
}
@@ -3060,26 +3053,26 @@ int i_APCI3200_Reset(struct comedi_device * dev)
void v_APCI3200_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- UINT ui_StatusRegister = 0;
- UINT ui_ChannelNumber = 0;
- INT i_CalibrationFlag = 0;
- INT i_CJCFlag = 0;
- UINT ui_DummyValue = 0;
- UINT ui_DigitalTemperature = 0;
- UINT ui_DigitalInput = 0;
+ unsigned int ui_StatusRegister = 0;
+ unsigned int ui_ChannelNumber = 0;
+ int i_CalibrationFlag = 0;
+ int i_CJCFlag = 0;
+ unsigned int ui_DummyValue = 0;
+ unsigned int ui_DigitalTemperature = 0;
+ unsigned int ui_DigitalInput = 0;
int i_ConvertCJCCalibration;
- //BEGIN JK TEST
+ /* BEGIN JK TEST */
int i_ReturnValue = 0;
- //END JK TEST
+ /* END JK TEST */
- //printk ("\n i_ScanType = %i i_ADDIDATAType = %i", s_BoardInfos [dev->minor].i_ScanType, s_BoardInfos [dev->minor].i_ADDIDATAType);
+ /* printk ("\n i_ScanType = %i i_ADDIDATAType = %i", s_BoardInfos [dev->minor].i_ScanType, s_BoardInfos [dev->minor].i_ADDIDATAType); */
- //switch(i_ScanType)
+ /* switch(i_ScanType) */
switch (s_BoardInfos[dev->minor].i_ScanType) {
case 0:
case 1:
- //switch(i_ADDIDATAType)
+ /* switch(i_ADDIDATAType) */
switch (s_BoardInfos[dev->minor].i_ADDIDATAType) {
case 0:
case 1:
@@ -3087,12 +3080,12 @@ void v_APCI3200_Interrupt(int irq, void *d)
/************************************/
/*Read the interrupt status register */
/************************************/
- //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
+ /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
ui_StatusRegister =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 16);
if ((ui_StatusRegister & 0x2) == 0x2) {
- //i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17);
+ /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */
i_CalibrationFlag =
((inl(devpriv->iobase +
s_BoardInfos[dev->
@@ -3103,12 +3096,12 @@ void v_APCI3200_Interrupt(int irq, void *d)
/*************************/
/*Read the channel number */
/*************************/
- //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
+ /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
/*************************************/
/*Read the digital analog input value */
/*************************************/
- //ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28);
+ /* ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28); */
ui_DigitalInput =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
@@ -3117,13 +3110,13 @@ void v_APCI3200_Interrupt(int irq, void *d)
/* Test if the value read is the channel value */
/***********************************************/
if (i_CalibrationFlag == 0) {
- //ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput;
+ /* ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
i_Count + 0] = ui_DigitalInput;
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
/*
printk("\n 1 - i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos %i", ui_ChannelNumber);
i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num,
@@ -3131,14 +3124,14 @@ void v_APCI3200_Interrupt(int irq, void *d)
&s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 7],
&s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 8]);
*/
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
/******************************************************/
/*Start the conversion of the calibration offset value */
/******************************************************/
i_APCI3200_ReadCalibrationOffsetValue
(dev, &ui_DummyValue);
- } //if (i_CalibrationFlag == 0)
+ } /* if (i_CalibrationFlag == 0) */
/**********************************************************/
/* Test if the value read is the calibration offset value */
/**********************************************************/
@@ -3149,7 +3142,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
/* Save the value */
/******************/
- //ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput;
+ /* ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
@@ -3160,7 +3153,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
/******************************************************/
i_APCI3200_ReadCalibrationGainValue(dev,
&ui_DummyValue);
- } //if (i_CalibrationFlag == 1)
+ } /* if (i_CalibrationFlag == 1) */
/******************************************************/
/*Test if the value read is the calibration gain value */
/******************************************************/
@@ -3170,48 +3163,48 @@ void v_APCI3200_Interrupt(int irq, void *d)
/****************/
/*Save the value */
/****************/
- //ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput;
+ /* ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
i_Count + 2] = ui_DigitalInput;
- //if(i_ScanType==1)
+ /* if(i_ScanType==1) */
if (s_BoardInfos[dev->minor].
i_ScanType == 1) {
- //i_InterruptFlag=0;
+ /* i_InterruptFlag=0; */
s_BoardInfos[dev->minor].
i_InterruptFlag = 0;
- //i_Count=i_Count + 6;
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6;
+ /* i_Count=i_Count + 6; */
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */
s_BoardInfos[dev->minor].
i_Count =
s_BoardInfos[dev->
minor].i_Count + 9;
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- } //if(i_ScanType==1)
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ } /* if(i_ScanType==1) */
else {
- //i_Count=0;
+ /* i_Count=0; */
s_BoardInfos[dev->minor].
i_Count = 0;
- } //elseif(i_ScanType==1)
- //if(i_ScanType!=1)
+ } /* elseif(i_ScanType==1) */
+ /* if(i_ScanType!=1) */
if (s_BoardInfos[dev->minor].
i_ScanType != 1) {
- i_ReturnValue = send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
- } //if(i_ScanType!=1)
+ i_ReturnValue = send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
+ } /* if(i_ScanType!=1) */
else {
- //if(i_ChannelCount==i_Sum)
+ /* if(i_ChannelCount==i_Sum) */
if (s_BoardInfos[dev->minor].
i_ChannelCount ==
s_BoardInfos[dev->
minor].i_Sum) {
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
}
- } //if(i_ScanType!=1)
- } //if (i_CalibrationFlag == 2)
- } // if ((ui_StatusRegister & 0x2) == 0x2)
+ } /* if(i_ScanType!=1) */
+ } /* if (i_CalibrationFlag == 2) */
+ } /* if ((ui_StatusRegister & 0x2) == 0x2) */
break;
@@ -3220,7 +3213,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
/*Read the interrupt status register */
/************************************/
- //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
+ /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
ui_StatusRegister =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 16);
@@ -3230,7 +3223,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((ui_StatusRegister & 0x2) == 0x2) {
- //i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10);
+ /* i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10); */
i_CJCFlag =
((inl(devpriv->iobase +
s_BoardInfos[dev->
@@ -3238,7 +3231,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
i_Offset +
4) & 0x00000400) >> 10);
- //i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17);
+ /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */
i_CalibrationFlag =
((inl(devpriv->iobase +
s_BoardInfos[dev->
@@ -3251,19 +3244,19 @@ void v_APCI3200_Interrupt(int irq, void *d)
/*Read the channel number */
/*************************/
- //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
+ /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
ui_ChannelNumber =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 24);
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
s_BoardInfos[dev->minor].ui_Channel_num =
ui_ChannelNumber;
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
/************************************/
/*Read the digital temperature value */
/************************************/
- //ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28);
+ /* ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28); */
ui_DigitalTemperature =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
@@ -3274,7 +3267,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((i_CalibrationFlag == 0)
&& (i_CJCFlag == 0)) {
- //ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature;
+ /* ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
@@ -3287,7 +3280,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
i_APCI3200_ReadCJCValue(dev,
&ui_DummyValue);
- } //if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0))
+ } /* if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0)) */
/*****************************************/
/*Test if the value read is the CJC value */
@@ -3295,7 +3288,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((i_CJCFlag == 1)
&& (i_CalibrationFlag == 0)) {
- //ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature;
+ /* ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
@@ -3307,7 +3300,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
/******************************************************/
i_APCI3200_ReadCalibrationOffsetValue
(dev, &ui_DummyValue);
- } // if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0))
+ } /* if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0)) */
/********************************************************/
/*Test if the value read is the calibration offset value */
@@ -3315,7 +3308,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((i_CalibrationFlag == 1)
&& (i_CJCFlag == 0)) {
- //ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature;
+ /* ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
@@ -3328,7 +3321,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
i_APCI3200_ReadCalibrationGainValue(dev,
&ui_DummyValue);
- } //if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0))
+ } /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0)) */
/******************************************************/
/*Test if the value read is the calibration gain value */
@@ -3336,7 +3329,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((i_CalibrationFlag == 2)
&& (i_CJCFlag == 0)) {
- //ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature;
+ /* ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
@@ -3349,15 +3342,15 @@ void v_APCI3200_Interrupt(int irq, void *d)
/*Test if the polarity is the same */
/**********************************/
- //if(i_CJCPolarity!=i_ADDIDATAPolarity)
+ /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
if (s_BoardInfos[dev->minor].
i_CJCPolarity !=
s_BoardInfos[dev->minor].
i_ADDIDATAPolarity) {
i_ConvertCJCCalibration = 1;
- } //if(i_CJCPolarity!=i_ADDIDATAPolarity)
+ } /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
else {
- //if(i_CJCGain==i_ADDIDATAGain)
+ /* if(i_CJCGain==i_ADDIDATAGain) */
if (s_BoardInfos[dev->minor].
i_CJCGain ==
s_BoardInfos[dev->
@@ -3365,12 +3358,12 @@ void v_APCI3200_Interrupt(int irq, void *d)
i_ADDIDATAGain) {
i_ConvertCJCCalibration
= 0;
- } //if(i_CJCGain==i_ADDIDATAGain)
+ } /* if(i_CJCGain==i_ADDIDATAGain) */
else {
i_ConvertCJCCalibration
= 1;
- } //elseif(i_CJCGain==i_ADDIDATAGain)
- } //elseif(i_CJCPolarity!=i_ADDIDATAPolarity)
+ } /* elseif(i_CJCGain==i_ADDIDATAGain) */
+ } /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */
if (i_ConvertCJCCalibration == 1) {
/****************************************************************/
/*Start the conversion of the calibration gain value for the CJC */
@@ -3378,10 +3371,10 @@ void v_APCI3200_Interrupt(int irq, void *d)
i_APCI3200_ReadCJCCalOffset(dev,
&ui_DummyValue);
- } //if(i_ConvertCJCCalibration==1)
+ } /* if(i_ConvertCJCCalibration==1) */
else {
- //ui_InterruptChannelValue[i_Count + 4]=0;
- //ui_InterruptChannelValue[i_Count + 5]=0;
+ /* ui_InterruptChannelValue[i_Count + 4]=0; */
+ /* ui_InterruptChannelValue[i_Count + 5]=0; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->
@@ -3392,8 +3385,8 @@ void v_APCI3200_Interrupt(int irq, void *d)
[s_BoardInfos[dev->
minor].i_Count +
5] = 0;
- } //elseif(i_ConvertCJCCalibration==1)
- } //else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0))
+ } /* elseif(i_ConvertCJCCalibration==1) */
+ } /* else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0)) */
/********************************************************************/
/*Test if the value read is the calibration offset value for the CJC */
@@ -3401,7 +3394,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((i_CalibrationFlag == 1)
&& (i_CJCFlag == 1)) {
- //ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature;
+ /* ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
@@ -3414,7 +3407,7 @@ void v_APCI3200_Interrupt(int irq, void *d)
i_APCI3200_ReadCJCCalGain(dev,
&ui_DummyValue);
- } //if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1))
+ } /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1)) */
/******************************************************************/
/*Test if the value read is the calibration gain value for the CJC */
@@ -3422,61 +3415,61 @@ void v_APCI3200_Interrupt(int irq, void *d)
if ((i_CalibrationFlag == 2)
&& (i_CJCFlag == 1)) {
- //ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature;
+ /* ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature; */
s_BoardInfos[dev->minor].
ui_InterruptChannelValue
[s_BoardInfos[dev->minor].
i_Count + 5] =
ui_DigitalTemperature;
- //if(i_ScanType==1)
+ /* if(i_ScanType==1) */
if (s_BoardInfos[dev->minor].
i_ScanType == 1) {
- //i_InterruptFlag=0;
+ /* i_InterruptFlag=0; */
s_BoardInfos[dev->minor].
i_InterruptFlag = 0;
- //i_Count=i_Count + 6;
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6;
+ /* i_Count=i_Count + 6; */
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */
s_BoardInfos[dev->minor].
i_Count =
s_BoardInfos[dev->
minor].i_Count + 9;
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- } //if(i_ScanType==1)
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ } /* if(i_ScanType==1) */
else {
- //i_Count=0;
+ /* i_Count=0; */
s_BoardInfos[dev->minor].
i_Count = 0;
- } //elseif(i_ScanType==1)
+ } /* elseif(i_ScanType==1) */
- //if(i_ScanType!=1)
+ /* if(i_ScanType!=1) */
if (s_BoardInfos[dev->minor].
i_ScanType != 1) {
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
- } //if(i_ScanType!=1)
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
+ } /* if(i_ScanType!=1) */
else {
- //if(i_ChannelCount==i_Sum)
+ /* if(i_ChannelCount==i_Sum) */
if (s_BoardInfos[dev->minor].
i_ChannelCount ==
s_BoardInfos[dev->
minor].i_Sum) {
- send_sig(SIGIO, devpriv->tsk_Current, 0); // send signal to the sample
+ send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
- } //if(i_ChannelCount==i_Sum)
- } //else if(i_ScanType!=1)
- } //if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1))
+ } /* if(i_ChannelCount==i_Sum) */
+ } /* else if(i_ScanType!=1) */
+ } /* if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1)) */
- } //else if ((ui_StatusRegister & 0x2) == 0x2)
+ } /* else if ((ui_StatusRegister & 0x2) == 0x2) */
break;
- } //switch(i_ADDIDATAType)
+ } /* switch(i_ADDIDATAType) */
break;
case 2:
case 3:
i_APCI3200_InterruptHandleEos(dev);
break;
- } //switch(i_ScanType)
+ } /* switch(i_ScanType) */
return;
}
@@ -3499,22 +3492,22 @@ void v_APCI3200_Interrupt(int irq, void *d)
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3200_InterruptHandleEos(struct comedi_device * dev)
+int i_APCI3200_InterruptHandleEos(struct comedi_device *dev)
{
- UINT ui_StatusRegister = 0;
+ unsigned int ui_StatusRegister = 0;
struct comedi_subdevice *s = dev->subdevices + 0;
- //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //comedi_async *async = s->async;
- //UINT *data;
- //data=async->data+async->buf_int_ptr;//new samples added from here onwards
+ /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* comedi_async *async = s->async; */
+ /* UINT *data; */
+ /* data=async->data+async->buf_int_ptr;//new samples added from here onwards */
int n = 0, i = 0;
- //END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+ /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
/************************************/
/*Read the interrupt status register */
/************************************/
- //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
+ /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
ui_StatusRegister =
inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16);
@@ -3526,33 +3519,33 @@ int i_APCI3200_InterruptHandleEos(struct comedi_device * dev)
/*************************/
/*Read the channel number */
/*************************/
- //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
- //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //This value is not used
- //ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24);
+ /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
+ /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* This value is not used */
+ /* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); */
s->async->events = 0;
- //END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+ /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
/*************************************/
/*Read the digital Analog Input value */
/*************************************/
- //data[i_Count] = inl(devpriv->iobase+i_Offset + 28);
- //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
+ /* data[i_Count] = inl(devpriv->iobase+i_Offset + 28); */
+ /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); */
s_BoardInfos[dev->minor].ui_ScanValueArray[s_BoardInfos[dev->
minor].i_Count] =
inl(devpriv->iobase +
s_BoardInfos[dev->minor].i_Offset + 28);
- //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+ /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
- //if((i_Count == (i_LastChannel-i_FirstChannel+3)))
+ /* if((i_Count == (i_LastChannel-i_FirstChannel+3))) */
if ((s_BoardInfos[dev->minor].i_Count ==
(s_BoardInfos[dev->minor].i_LastChannel -
s_BoardInfos[dev->minor].
i_FirstChannel + 3))) {
- //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
s_BoardInfos[dev->minor].i_Count++;
for (i = s_BoardInfos[dev->minor].i_FirstChannel;
@@ -3582,61 +3575,61 @@ int i_APCI3200_InterruptHandleEos(struct comedi_device * dev)
* 3) + 2]);
}
- //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+ /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
- //i_Count=-1;
+ /* i_Count=-1; */
s_BoardInfos[dev->minor].i_Count = -1;
- //async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT);
- //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(UINT);
- //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT);
- //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(UINT);
- //comedi_eos(dev,s);
+ /* async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
+ /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
+ /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
+ /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
+ /* comedi_eos(dev,s); */
- // Set the event type (Comedi Buffer End Of Scan)
+ /* Set the event type (Comedi Buffer End Of Scan) */
s->async->events |= COMEDI_CB_EOS;
- // Test if enougth memory is available and allocate it for 7 values
- //n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int));
+ /* Test if enougth memory is available and allocate it for 7 values */
+ /* n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); */
n = comedi_buf_write_alloc(s->async,
(7 + 12) * sizeof(unsigned int));
- // If not enougth memory available, event is set to Comedi Buffer Errror
+ /* If not enougth memory available, event is set to Comedi Buffer Errror */
if (n > ((7 + 12) * sizeof(unsigned int))) {
printk("\ncomedi_buf_write_alloc n = %i", n);
s->async->events |= COMEDI_CB_ERROR;
}
- // Write all 7 scan values in the comedi buffer
+ /* Write all 7 scan values in the comedi buffer */
comedi_buf_memcpy_to(s->async, 0,
(unsigned int *) s_BoardInfos[dev->minor].
ui_ScanValueArray, (7 + 12) * sizeof(unsigned int));
- // Update comedi buffer pinters indexes
+ /* Update comedi buffer pinters indexes */
comedi_buf_write_free(s->async,
(7 + 12) * sizeof(unsigned int));
- // Send events
+ /* Send events */
comedi_event(dev, s);
- //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
-
- //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- //
- //if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over
- // {
- // /* buffer rollover */
- // s->async->buf_int_ptr=0;
- // comedi_eobuf(dev,s);
- // }
- //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+ /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+ /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ /* */
+ /* if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over */
+ /* { */
+ /* /* buffer rollover */ */
+ /* s->async->buf_int_ptr=0; */
+ /* comedi_eobuf(dev,s); */
+ /* } */
+ /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
}
- //i_Count++;
+ /* i_Count++; */
s_BoardInfos[dev->minor].i_Count++;
}
- //i_InterruptFlag=0;
+ /* i_InterruptFlag=0; */
s_BoardInfos[dev->minor].i_InterruptFlag = 0;
return 0;
}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h
index a6f57f55e79c..f3e7ebf8c1f3 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h
@@ -15,26 +15,26 @@
* any later version.
*/
-// Card Specific information
+/* Card Specific information */
#define APCI3200_BOARD_VENDOR_ID 0x15B8
-//#define APCI3200_ADDRESS_RANGE 264
+/* #define APCI3200_ADDRESS_RANGE 264 */
int MODULE_NO;
struct {
- INT i_Gain;
- INT i_Polarity;
- INT i_OffsetRange;
- INT i_Coupling;
- INT i_SingleDiff;
- INT i_AutoCalibration;
- UINT ui_ReloadValue;
- UINT ui_TimeUnitReloadVal;
- INT i_Interrupt;
- INT i_ModuleSelection;
+ int i_Gain;
+ int i_Polarity;
+ int i_OffsetRange;
+ int i_Coupling;
+ int i_SingleDiff;
+ int i_AutoCalibration;
+ unsigned int ui_ReloadValue;
+ unsigned int ui_TimeUnitReloadVal;
+ int i_Interrupt;
+ int i_ModuleSelection;
} Config_Parameters_Module1, Config_Parameters_Module2,
Config_Parameters_Module3, Config_Parameters_Module4;
-//ANALOG INPUT RANGE
+/* ANALOG INPUT RANGE */
static const struct comedi_lrange range_apci3200_ai = { 8, {
BIP_RANGE(10),
BIP_RANGE(5),
@@ -55,7 +55,7 @@ static const struct comedi_lrange range_apci3300_ai = { 4, {
}
};
-//Analog Input related Defines
+/* Analog Input related Defines */
#define APCI3200_AI_OFFSET_GAIN 0
#define APCI3200_AI_SC_TEST 4
#define APCI3200_AI_IRQ 8
@@ -89,98 +89,102 @@ static const struct comedi_lrange range_apci3300_ai = { 4, {
#define ADDIDATA_UNIPOLAR 1
#define ADDIDATA_BIPOLAR 2
-//BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+/* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
#define MAX_MODULE 4
-//END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+/* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-typedef struct {
- ULONG ul_NumberOfValue;
- ULONG *pul_ResistanceValue;
- ULONG *pul_TemperatureValue;
-} str_ADDIDATA_RTDStruct, *pstr_ADDIDATA_RTDStruct;
+struct str_ADDIDATA_RTDStruct {
+ unsigned int ul_NumberOfValue;
+ unsigned int *pul_ResistanceValue;
+ unsigned int *pul_TemperatureValue;
+};
+
+/* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+struct str_Module {
-//BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
-typedef struct {
- // Begin JK 05/08/2003 change for Linux
+ /* Begin JK 05/08/2003 change for Linux */
unsigned long ul_CurrentSourceCJC;
unsigned long ul_CurrentSource[5];
- // End JK 05/08/2003 change for Linux
+ /* End JK 05/08/2003 change for Linux */
- // Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1
- unsigned long ul_GainFactor[8]; // Gain Factor
+ /* Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */
+ unsigned long ul_GainFactor[8]; /* Gain Factor */
unsigned int w_GainValue[10];
- // End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1
-} str_Module;
-//END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
-
-//BEGIN JK 06.07.04: Management of sevrals boards
-typedef struct {
- INT i_CJCAvailable;
- INT i_CJCPolarity;
- INT i_CJCGain;
- INT i_InterruptFlag;
- INT i_ADDIDATAPolarity;
- INT i_ADDIDATAGain;
- INT i_AutoCalibration;
- INT i_ADDIDATAConversionTime;
- INT i_ADDIDATAConversionTimeUnit;
- INT i_ADDIDATAType;
- INT i_ChannelNo;
- INT i_ChannelCount;
- INT i_ScanType;
- INT i_FirstChannel;
- INT i_LastChannel;
- INT i_Sum;
- INT i_Offset;
- UINT ui_Channel_num;
- INT i_Count;
- INT i_Initialised;
- //UINT ui_InterruptChannelValue[96]; //Buffer
- UINT ui_InterruptChannelValue[144]; //Buffer
- BYTE b_StructInitialized;
- //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
- unsigned int ui_ScanValueArray[7 + 12]; // 7 is the maximal number of channels
- //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
-
- //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
- INT i_ConnectionType;
- INT i_NbrOfModule;
- str_Module s_Module[MAX_MODULE];
- //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
-} str_BoardInfos;
-//END JK 06.07.04: Management of sevrals boards
-
-// Hardware Layer functions for Apci3200
-
-//AI
-
-INT i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ /* End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */
+};
+
+/* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+
+/* BEGIN JK 06.07.04: Management of sevrals boards */
+struct str_BoardInfos {
+
+ int i_CJCAvailable;
+ int i_CJCPolarity;
+ int i_CJCGain;
+ int i_InterruptFlag;
+ int i_ADDIDATAPolarity;
+ int i_ADDIDATAGain;
+ int i_AutoCalibration;
+ int i_ADDIDATAConversionTime;
+ int i_ADDIDATAConversionTimeUnit;
+ int i_ADDIDATAType;
+ int i_ChannelNo;
+ int i_ChannelCount;
+ int i_ScanType;
+ int i_FirstChannel;
+ int i_LastChannel;
+ int i_Sum;
+ int i_Offset;
+ unsigned int ui_Channel_num;
+ int i_Count;
+ int i_Initialised;
+ /* UINT ui_InterruptChannelValue[96]; //Buffer */
+ unsigned int ui_InterruptChannelValue[144]; /* Buffer */
+ unsigned char b_StructInitialized;
+ /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+ unsigned int ui_ScanValueArray[7 + 12]; /* 7 is the maximal number of channels */
+ /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+ /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+ int i_ConnectionType;
+ int i_NbrOfModule;
+ struct str_Module s_Module[MAX_MODULE];
+ /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+};
+
+/* END JK 06.07.04: Management of sevrals boards */
+
+/* Hardware Layer functions for Apci3200 */
+
+/* AI */
+
+int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev,
+int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
+int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
-INT i_APCI3200_InterruptHandleEos(struct comedi_device *dev);
-INT i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
+int i_APCI3200_InterruptHandleEos(struct comedi_device *dev);
+int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd);
-INT i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
-INT i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
+int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//Interrupt
+/* Interrupt */
void v_APCI3200_Interrupt(int irq, void *d);
int i_APCI3200_InterruptHandleEos(struct comedi_device *dev);
-//Reset functions
-INT i_APCI3200_Reset(struct comedi_device *dev);
+/* Reset functions */
+int i_APCI3200_Reset(struct comedi_device *dev);
int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data);
int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data);
-int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, UINT *data);
-int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, UINT *data);
+int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data);
+int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data);
int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 20391a91da03..ef21f03fc961 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -62,8 +62,8 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -73,26 +73,26 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-INT i_APCI3501_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
ui_Temp = data[0];
*data = inl(devpriv->iobase + APCI3501_DIGITAL_IP);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } //if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
*data = *data & 0x3;
- } //if (ui_Temp==1)
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } //elseif (ui_Temp==1)
- } //elseif (ui_Temp==0)
+ } /* elseif (ui_Temp==1) */
+ } /* elseif (ui_Temp==0) */
return insn->n;
}
@@ -105,7 +105,7 @@ INT i_APCI3501_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev
| Task : Configures The Digital Output Subdevice. |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[1] : 1 Enable VCC Interrupt |
@@ -121,21 +121,21 @@ INT i_APCI3501_ReadDigitalInput(struct comedi_device * dev, struct comedi_subdev
| |
+----------------------------------------------------------------------------+
*/
-int i_APCI3501_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if ((data[0] != 0) && (data[0] != 1)) {
comedi_error(dev,
"Not a valid Data !!! ,Data should be 1 or 0\n");
return -EINVAL;
- } //if ( (data[0]!=0) && (data[0]!=1) )
+ } /* if ( (data[0]!=0) && (data[0]!=1) ) */
if (data[0]) {
devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE;
- } // if (data[0])
+ } /* if (data[0]) */
else {
devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
- } //else if (data[0])
+ } /* else if (data[0]) */
return insn->n;
}
@@ -161,33 +161,33 @@ int i_APCI3501_ConfigDigitalOutput(struct comedi_device * dev, struct comedi_sub
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp, ui_Temp1;
- UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
+ unsigned int ui_Temp, ui_Temp1;
+ unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */
if (devpriv->b_OutputMemoryStatus) {
ui_Temp = inl(devpriv->iobase + APCI3501_DIGITAL_OP);
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
else {
ui_Temp = 0;
- } //if(devpriv->b_OutputMemoryStatus )
+ } /* if(devpriv->b_OutputMemoryStatus ) */
if (data[3] == 0) {
if (data[1] == 0) {
data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
outl(data[0], devpriv->iobase + APCI3501_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
data[0] = (data[0] << (2 * data[2])) | ui_Temp;
outl(data[0],
devpriv->iobase + APCI3501_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==0)
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==0) */
else {
if (data[3] == 1) {
if (data[1] == 0) {
@@ -201,7 +201,7 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
data[0] = data[0] & ui_Temp;
outl(data[0],
devpriv->iobase + APCI3501_DIGITAL_OP);
- } //if(data[1]==0)
+ } /* if(data[1]==0) */
else {
if (data[1] == 1) {
data[0] = ~data[0] & 0x3;
@@ -215,17 +215,17 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
outl(data[0],
devpriv->iobase +
APCI3501_DIGITAL_OP);
- } // if(data[1]==1)
+ } /* if(data[1]==1) */
else {
printk("\nSpecified channel not supported\n");
- } //else if(data[1]==1)
- } //elseif(data[1]==0)
- } //if(data[3]==1);
+ } /* else if(data[1]==1) */
+ } /* elseif(data[1]==0) */
+ } /* if(data[3]==1); */
else {
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
- } //if else data[3]==1)
- } //if else data[3]==0)
+ } /* if else data[3]==1) */
+ } /* if else data[3]==0) */
return insn->n;
}
@@ -238,8 +238,8 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| Task : Read value of the selected channel or port |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT ui_NoOfChannels : No Of Channels To read |
-| UINT *data : Data Pointer to read status |
+| unsigned int ui_NoOfChannels : No Of Channels To read |
+| unsigned int *data : Data Pointer to read status |
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
@@ -248,27 +248,27 @@ INT i_APCI3501_WriteDigitalOutput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3501_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- UINT ui_Temp;
- UINT ui_NoOfChannel;
+ unsigned int ui_Temp;
+ unsigned int ui_NoOfChannel;
ui_NoOfChannel = CR_CHAN(insn->chanspec);
ui_Temp = data[0];
*data = inl(devpriv->iobase + APCI3501_DIGITAL_OP);
if (ui_Temp == 0) {
*data = (*data >> ui_NoOfChannel) & 0x1;
- } // if (ui_Temp==0)
+ } /* if (ui_Temp==0) */
else {
if (ui_Temp == 1) {
*data = *data & 0x3;
- } // if (ui_Temp==1)
+ } /* if (ui_Temp==1) */
else {
printk("\nSpecified channel not supported \n");
- } // else if (ui_Temp==1)
- } // else if (ui_Temp==0)
+ } /* else if (ui_Temp==1) */
+ } /* else if (ui_Temp==0) */
return insn->n;
}
@@ -298,8 +298,8 @@ INT i_APCI3501_ReadDigitalOutput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3501_ConfigAnalogOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
outl(data[0],
devpriv->iobase + APCI3501_ANALOG_OUTPUT +
@@ -336,10 +336,10 @@ INT i_APCI3501_ConfigAnalogOutput(struct comedi_device * dev, struct comedi_subd
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command1 = 0, ul_Channel_no, ul_Polarity, ul_DAC_Ready = 0;;
+ unsigned int ul_Command1 = 0, ul_Channel_no, ul_Polarity, ul_DAC_Ready = 0;;
ul_Channel_no = CR_CHAN(insn->chanspec);
@@ -349,18 +349,18 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde
printk("\nIn WriteAnalogOutput :: Not Valid Data\n");
}
- } // end if(devpriv->b_InterruptMode==MODE1)
+ } /* end if(devpriv->b_InterruptMode==MODE1) */
else {
ul_Polarity = 0;
if ((*data < 0) || (*data > 8192)) {
printk("\nIn WriteAnalogOutput :: Not Valid Data\n");
}
- } // end else
+ } /* end else */
if ((ul_Channel_no < 0) || (ul_Channel_no > 7)) {
printk("\nIn WriteAnalogOutput :: Not Valid Channel\n");
- } // end if((ul_Channel_no<0)||(ul_Channel_no>7))
+ } /* end if((ul_Channel_no<0)||(ul_Channel_no>7)) */
ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT);
@@ -370,11 +370,11 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde
}
if (ul_DAC_Ready) {
-// Output the Value on the output channels.
+/* Output the Value on the output channels. */
ul_Command1 =
- (ULONG) ((ULONG) (ul_Channel_no & 0xFF) |
- (ULONG) ((*data << 0x8) & 0x7FFFFF00L) |
- (ULONG) (ul_Polarity));
+ (unsigned int) ((unsigned int) (ul_Channel_no & 0xFF) |
+ (unsigned int) ((*data << 0x8) & 0x7FFFFF00L) |
+ (unsigned int) (ul_Polarity));
outl(ul_Command1,
devpriv->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_PROG);
@@ -392,7 +392,7 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde
| Task : Configures The Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 Configure As Timer |
@@ -410,78 +410,78 @@ INT i_APCI3501_WriteAnalogOutput(struct comedi_device * dev, struct comedi_subde
| |
+----------------------------------------------------------------------------+
*/
-INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command1 = 0;
+ unsigned int ul_Command1 = 0;
devpriv->tsk_Current = current;
if (data[0] == ADDIDATA_WATCHDOG) {
devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;
- //Disable the watchdog
- outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //disable Wa
+ /* Disable the watchdog */
+ outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Wa */
if (data[1] == 1) {
- //Enable TIMER int & DISABLE ALL THE OTHER int SOURCES
+ /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
outl(0x02,
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
} else {
- outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //disable Timer interrupt
+ outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Timer interrupt */
}
- //Loading the Timebase value
+ /* Loading the Timebase value */
outl(data[2],
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_TIMEBASE);
- //Loading the Reload value
+ /* Loading the Reload value */
outl(data[3],
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_RELOAD_VALUE);
- //Set the mode
- ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG) | 0xFFF819E0UL; //e2->e0
+ /* Set the mode */
+ ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG) | 0xFFF819E0UL; /* e2->e0 */
outl(ul_Command1,
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
- } //end if(data[0]==ADDIDATA_WATCHDOG)
+ } /* end if(data[0]==ADDIDATA_WATCHDOG) */
else if (data[0] == ADDIDATA_TIMER) {
- //First Stop The Timer
+ /* First Stop The Timer */
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
- outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //Stop The Timer
+ outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* Stop The Timer */
devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
if (data[1] == 1) {
- //Enable TIMER int & DISABLE ALL THE OTHER int SOURCES
+ /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
outl(0x02,
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
} else {
- outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //disable Timer interrupt
+ outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Timer interrupt */
}
- // Loading Timebase
+ /* Loading Timebase */
outl(data[2],
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_TIMEBASE);
- //Loading the Reload value
+ /* Loading the Reload value */
outl(data[3],
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_RELOAD_VALUE);
- // printk ("\nTimer Address :: %x\n", (devpriv->iobase+APCI3501_WATCHDOG));
+ /* printk ("\nTimer Address :: %x\n", (devpriv->iobase+APCI3501_WATCHDOG)); */
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
ul_Command1 =
(ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL;
- outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); //mode 2
+ outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* mode 2 */
- } //end if(data[0]==ADDIDATA_TIMER)
+ } /* end if(data[0]==ADDIDATA_TIMER) */
return insn->n;
}
@@ -495,7 +495,7 @@ INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device * dev,
| Task : Start / Stop The Selected Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 Timer |
@@ -511,10 +511,10 @@ INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- ULONG ul_Command1 = 0;
+ unsigned int ul_Command1 = 0;
int i_Temp;
if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
@@ -523,15 +523,15 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
- //Enable the Watchdog
+ /* Enable the Watchdog */
outl(ul_Command1,
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
}
- else if (data[1] == 0) //Stop The Watchdog
+ else if (data[1] == 0) /* Stop The Watchdog */
{
- //Stop The Watchdog
+ /* Stop The Watchdog */
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
@@ -547,8 +547,8 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
outl(ul_Command1,
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
- } //if(data[1]==2)
- } // end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
+ } /* if(data[1]==2) */
+ } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */
if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
if (data[1] == 1) {
@@ -557,12 +557,12 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
- //Enable the Timer
+ /* Enable the Timer */
outl(ul_Command1,
devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
} else if (data[1] == 0) {
- //Stop The Timer
+ /* Stop The Timer */
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
@@ -573,7 +573,7 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
}
else if (data[1] == 2) {
- //Trigger the Timer
+ /* Trigger the Timer */
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_PROG);
@@ -583,7 +583,7 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
APCI3501_TCW_PROG);
}
- } // end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
+ } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
i_Temp = inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_TRIG_STATUS) & 0x1;
return insn->n;
@@ -598,7 +598,7 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
| Task : Read The Selected Timer , Counter or Watchdog |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev : Driver handle |
-| UINT *data : Data Pointer contains |
+| unsigned int *data : Data Pointer contains |
| configuration parameters as below |
| |
| data[0] : 0 Timer |
@@ -613,8 +613,8 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
@@ -622,14 +622,14 @@ int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device * dev,
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_TRIG_STATUS) & 0x1;
data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG);
- } // end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
+ } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */
else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
data[0] =
inl(devpriv->iobase + APCI3501_WATCHDOG +
APCI3501_TCW_TRIG_STATUS) & 0x1;
data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG);
- } // end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
+ } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER)
&& (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG)) {
@@ -654,10 +654,10 @@ int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3501_Reset(struct comedi_device * dev)
+int i_APCI3501_Reset(struct comedi_device *dev)
{
int i_Count = 0, i_temp = 0;
- ULONG ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0;
+ unsigned int ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0;
outl(0x0, devpriv->iobase + APCI3501_DIGITAL_OP);
outl(1, devpriv->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_VOLT_MODE);
@@ -674,11 +674,11 @@ int i_APCI3501_Reset(struct comedi_device * dev)
}
if (ul_DAC_Ready) {
- // Output the Value on the output channels.
+ /* Output the Value on the output channels. */
ul_Command1 =
- (ULONG) ((ULONG) (i_Count & 0xFF) |
- (ULONG) ((i_temp << 0x8) & 0x7FFFFF00L) |
- (ULONG) (ul_Polarity));
+ (unsigned int) ((unsigned int) (i_Count & 0xFF) |
+ (unsigned int) ((i_temp << 0x8) & 0x7FFFFF00L) |
+ (unsigned int) (ul_Polarity));
outl(ul_Command1,
devpriv->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_PROG);
@@ -711,7 +711,7 @@ void v_APCI3501_Interrupt(int irq, void *d)
struct comedi_device *dev = d;
unsigned int ui_Timer_AOWatchdog;
unsigned long ul_Command1;
- // Disable Interrupt
+ /* Disable Interrupt */
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);
@@ -728,8 +728,9 @@ void v_APCI3501_Interrupt(int irq, void *d)
return;
}
- // Enable Interrupt
- //Send a signal to from kernel to user space
+/*
+* Enable Interrupt Send a signal to from kernel to user space
+*/
send_sig(SIGIO, devpriv->tsk_Current, 0);
ul_Command1 =
inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h
index 51e7b66544ac..c456d75674b8 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h
@@ -15,7 +15,7 @@
* any later version.
*/
-// Card Specific information
+/* Card Specific information */
#define APCI3501_BOARD_VENDOR_ID 0x15B8
#define APCI3501_ADDRESS_RANGE 255
@@ -23,7 +23,7 @@
#define APCI3501_DIGITAL_OP 0x40
#define APCI3501_ANALOG_OUTPUT 0x00
-//Analog Output related Defines
+/* Analog Output related Defines */
#define APCI3501_AO_VOLT_MODE 0
#define APCI3501_AO_PROG 4
#define APCI3501_AO_TRIG_SCS 8
@@ -31,14 +31,14 @@
#define BIPOLAR 1
#define MODE0 0
#define MODE1 1
-// ANALOG OUTPUT RANGE
+/* ANALOG OUTPUT RANGE */
struct comedi_lrange range_apci3501_ao = { 2, {
BIP_RANGE(10),
UNI_RANGE(10)
}
};
-//Watchdog Related Defines
+/* Watchdog Related Defines */
#define APCI3501_WATCHDOG 0x20
#define APCI3501_TCW_SYNC_ENABLEDISABLE 0
@@ -52,32 +52,36 @@ struct comedi_lrange range_apci3501_ao = { 2, {
#define ADDIDATA_TIMER 0
#define ADDIDATA_WATCHDOG 2
-// Hardware Layer functions for Apci3501
+/* Hardware Layer functions for Apci3501 */
-//AO
-INT i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+/* AO */
+int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//DI
-// for di read
-//INT i_APCI3501_ReadDigitalInput(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data);
+/*
+* DI for di read INT i_APCI3501_ReadDigitalInput(struct
+* comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn
+* *insn,unsigned int *data);
+*/
-INT i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//DO
+/* DO */
int i_APCI3501_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-INT i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
+int i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-// TIMER
-// timer value is passed as u seconds
-INT i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev,
+/* TIMER
+ * timer value is passed as u seconds
+ */
+
+int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev,
@@ -87,8 +91,8 @@ int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev,
int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-//Interrupt
+/* Interrupt */
void v_APCI3501_Interrupt(int irq, void *d);
-//Reset functions
+/* Reset functions */
int i_APCI3501_Reset(struct comedi_device *dev);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
index b7268e4da64e..338727879827 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
@@ -3,13 +3,13 @@
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
- ADDI-DATA GmbH
- Dieselstrasse 3
- D-77833 Ottersweier
- Tel: +19(0)7223/9493-0
- Fax: +49(0)7223/9493-92
- http://www.addi-data-com
- info@addi-data.com
+ ADDI-DATA GmbH
+ Dieselstrasse 3
+ D-77833 Ottersweier
+ Tel: +19(0)7223/9493-0
+ Fax: +49(0)7223/9493-92
+ http://www.addi-data-com
+ info@addi-data.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -54,7 +54,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_TestConversionStarted |
+| Function Name : int i_APCI3XXX_TestConversionStarted |
| (struct comedi_device *dev) |
+----------------------------------------------------------------------------+
| Task Test if any conversion started |
@@ -68,18 +68,18 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_TestConversionStarted(struct comedi_device * dev)
+int i_APCI3XXX_TestConversionStarted(struct comedi_device *dev)
{
- if ((readl((void *)(devpriv->dw_AiBase + 8)) & 0x80000UL) == 0x80000UL) {
- return (1);
- } else {
- return (0);
- }
+ if ((readl((void *)(devpriv->dw_AiBase + 8)) & 0x80000UL) == 0x80000UL)
+ return 1;
+ else
+ return 0;
+
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_AnalogInputConfigOperatingMode |
+| Function Name : int i_APCI3XXX_AnalogInputConfigOperatingMode |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -87,9 +87,9 @@ int i_APCI3XXX_TestConversionStarted(struct comedi_device * dev)
+----------------------------------------------------------------------------+
| Task Converting mode and convert time selection |
+----------------------------------------------------------------------------+
-| Input Parameters : b_SingleDiff = (BYTE) data[1]; |
-| b_TimeBase = (BYTE) data[2]; (0: ns, 1:micros 2:ms)|
-| dw_ReloadValue = (DWORD) data[3]; |
+| Input Parameters : b_SingleDiff = (unsigned char) data[1]; |
+| b_TimeBase = (unsigned char) data[2]; (0: ns, 1:micros 2:ms)|
+| dw_ReloadValue = (unsigned int) data[3]; |
| ........ |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -105,14 +105,14 @@ int i_APCI3XXX_TestConversionStarted(struct comedi_device * dev)
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_TimeBase = 0;
- BYTE b_SingleDiff = 0;
- DWORD dw_ReloadValue = 0;
- DWORD dw_TestReloadValue = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_TimeBase = 0;
+ unsigned char b_SingleDiff = 0;
+ unsigned int dw_ReloadValue = 0;
+ unsigned int dw_TestReloadValue = 0;
/************************/
/* Test the buffer size */
@@ -123,19 +123,19 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
/* Get the Singel/Diff flag */
/****************************/
- b_SingleDiff = (BYTE) data[1];
+ b_SingleDiff = (unsigned char) data[1];
/****************************/
/* Get the time base unitiy */
/****************************/
- b_TimeBase = (BYTE) data[2];
+ b_TimeBase = (unsigned char) data[2];
/*************************************/
/* Get the convert time reload value */
/*************************************/
- dw_ReloadValue = (DWORD) data[3];
+ dw_ReloadValue = (unsigned int) data[3];
/**********************/
/* Test the time base */
@@ -186,7 +186,7 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
devpriv->
ui_EocEosConversionTime
=
- (UINT)
+ (unsigned int)
dw_ReloadValue;
devpriv->
b_EocEosConversionTimeBase
@@ -204,7 +204,7 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
/* Set the convert timing unit */
/*******************************/
- writel((DWORD)
+ writel((unsigned int)
b_TimeBase,
(void *)
(devpriv->
@@ -268,12 +268,12 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnConfigAnalogInput |
+| Function Name : int i_APCI3XXX_InsnConfigAnalogInput |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -281,9 +281,9 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
+----------------------------------------------------------------------------+
| Task Converting mode and convert time selection |
+----------------------------------------------------------------------------+
-| Input Parameters : b_ConvertMode = (BYTE) data[0]; |
-| b_TimeBase = (BYTE) data[1]; (0: ns, 1:micros 2:ms)|
-| dw_ReloadValue = (DWORD) data[2]; |
+| Input Parameters : b_ConvertMode = (unsigned char) data[0]; |
+| b_TimeBase = (unsigned char) data[1]; (0: ns, 1:micros 2:ms)|
+| dw_ReloadValue = (unsigned int) data[2]; |
| ........ |
+----------------------------------------------------------------------------+
| Output Parameters : - |
@@ -295,17 +295,17 @@ int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
+ int i_ReturnValue = insn->n;
/************************/
/* Test the buffer size */
/************************/
if (insn->n >= 1) {
- switch ((BYTE) data[0]) {
+ switch ((unsigned char) data[0]) {
case APCI3XXX_CONFIGURATION:
i_ReturnValue =
i_APCI3XXX_AnalogInputConfigOperatingMode(dev,
@@ -326,12 +326,12 @@ int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnReadAnalogInput |
+| Function Name : int i_APCI3XXX_InsnReadAnalogInput |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -355,16 +355,16 @@ int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Configuration = (BYTE) CR_RANGE(insn->chanspec);
- BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec);
- DWORD dw_Temp = 0;
- DWORD dw_Configuration = 0;
- DWORD dw_AcquisitionCpt = 0;
- BYTE b_Interrupt = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Configuration = (unsigned char) CR_RANGE(insn->chanspec);
+ unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec);
+ unsigned int dw_Temp = 0;
+ unsigned int dw_Configuration = 0;
+ unsigned int dw_AcquisitionCpt = 0;
+ unsigned char b_Interrupt = 0;
/*************************************/
/* Test if operating mode configured */
@@ -449,8 +449,8 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev,
dw_Configuration =
(b_Configuration & 3) |
- ((DWORD) (b_Configuration >> 2)
- << 6) | ((DWORD) devpriv->
+ ((unsigned int) (b_Configuration >> 2)
+ << 6) | ((unsigned int) devpriv->
b_SingelDiff << 7);
/***************************/
@@ -468,7 +468,7 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev,
writel(dw_Temp | 0x100UL,
(void *)(devpriv->dw_AiBase +
4));
- writel((DWORD) b_Channel,
+ writel((unsigned int) b_Channel,
(void *)(devpriv->dw_AiBase +
0));
@@ -535,8 +535,7 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev,
dw_Temp =
dw_Temp
& 1;
- }
- while (dw_Temp != 1);
+ } while (dw_Temp != 1);
/*************************/
/* Read the analog value */
@@ -585,7 +584,7 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev,
printk("Operating mode not configured\n");
i_ReturnValue = -1;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -607,15 +606,15 @@ int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device * dev,
void v_APCI3XXX_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- BYTE b_CopyCpt = 0;
- DWORD dw_Status = 0;
+ unsigned char b_CopyCpt = 0;
+ unsigned int dw_Status = 0;
/***************************/
/* Test if interrupt occur */
/***************************/
- if (((dw_Status = readl((void *)(devpriv->dw_AiBase + 16))) & 0x2UL) ==
- 0x2UL) {
+ dw_Status = readl((void *)(devpriv->dw_AiBase + 16));
+ if ( (dw_Status & 0x2UL) == 0x2UL) {
/***********************/
/* Reset the interrupt */
/***********************/
@@ -635,7 +634,7 @@ void v_APCI3XXX_Interrupt(int irq, void *d)
b_CopyCpt < devpriv->ui_AiNbrofChannels;
b_CopyCpt++) {
devpriv->ui_AiReadData[b_CopyCpt] =
- (UINT) readl((void *)(devpriv->
+ (unsigned int) readl((void *)(devpriv->
dw_AiBase + 28));
}
@@ -662,7 +661,7 @@ void v_APCI3XXX_Interrupt(int irq, void *d)
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnWriteAnalogOutput |
+| Function Name : int i_APCI3XXX_InsnWriteAnalogOutput |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -684,13 +683,13 @@ void v_APCI3XXX_Interrupt(int irq, void *d)
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_Range = (BYTE) CR_RANGE(insn->chanspec);
- BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec);
- DWORD dw_Status = 0;
- INT i_ReturnValue = insn->n;
+ unsigned char b_Range = (unsigned char) CR_RANGE(insn->chanspec);
+ unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec);
+ unsigned int dw_Status = 0;
+ int i_ReturnValue = insn->n;
/************************/
/* Test the buffer size */
@@ -729,8 +728,7 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev,
dw_Status =
readl((void *)(devpriv->
dw_AiBase + 96));
- }
- while ((dw_Status & 0x100) != 0x100);
+ } while ((dw_Status & 0x100) != 0x100);
} else {
/***************************/
/* Channel not initialised */
@@ -757,7 +755,7 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -768,7 +766,7 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnConfigInitTTLIO |
+| Function Name : int i_APCI3XXX_InsnConfigInitTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -778,8 +776,8 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev,
| for you call any other function witch access of TTL. |
| APCI3XXX_TTL_INIT_DIRECTION_PORT2(user inputs for direction)|
+----------------------------------------------------------------------------+
-| Input Parameters : b_InitType = (BYTE) data[0]; |
-| b_Port2Mode = (BYTE) data[1]; |
+| Input Parameters : b_InitType = (unsigned char) data[0]; |
+| b_Port2Mode = (unsigned char) data[1]; |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
@@ -791,11 +789,11 @@ int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Command = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Command = 0;
/************************/
/* Test the buffer size */
@@ -806,7 +804,7 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev,
/* Get the command */
/* **************** */
- b_Command = (BYTE) data[0];
+ b_Command = (unsigned char) data[0];
/********************/
/* Test the command */
@@ -888,7 +886,7 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev,
}
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -899,7 +897,7 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnBitsTTLIO |
+| Function Name : int i_APCI3XXX_InsnBitsTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -919,14 +917,14 @@ int i_APCI3XXX_InsnConfigInitTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_ChannelCpt = 0;
- DWORD dw_ChannelMask = 0;
- DWORD dw_BitMask = 0;
- DWORD dw_Status = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_ChannelCpt = 0;
+ unsigned int dw_ChannelMask = 0;
+ unsigned int dw_BitMask = 0;
+ unsigned int dw_Status = 0;
/************************/
/* Test the buffer size */
@@ -1051,12 +1049,12 @@ int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnReadTTLIO |
+| Function Name : int i_APCI3XXX_InsnReadTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -1074,11 +1072,11 @@ int i_APCI3XXX_InsnBitsTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnReadTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec);
- INT i_ReturnValue = insn->n;
+ unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec);
+ int i_ReturnValue = insn->n;
unsigned int *pls_ReadData = data;
/************************/
@@ -1157,7 +1155,7 @@ int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1168,7 +1166,7 @@ int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev,
/*
+----------------------------------------------------------------------------+
-| Function Name : INT i_APCI3XXX_InsnWriteTTLIO |
+| Function Name : int i_APCI3XXX_InsnWriteTTLIO |
| (struct comedi_device *dev, |
| struct comedi_subdevice *s, |
| struct comedi_insn *insn, |
@@ -1187,20 +1185,20 @@ int i_APCI3XXX_InsnReadTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec);
- BYTE b_State = 0;
- DWORD dw_Status = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec);
+ unsigned char b_State = 0;
+ unsigned int dw_Status = 0;
/************************/
/* Test the buffer size */
/************************/
if (insn->n >= 1) {
- b_State = (BYTE) data[0];
+ b_State = (unsigned char) data[0];
/***********************/
/* Test if read port 0 */
@@ -1269,7 +1267,7 @@ int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1298,12 +1296,12 @@ int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Channel = (BYTE) CR_CHAN(insn->chanspec);
- DWORD dw_Temp = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec);
+ unsigned int dw_Temp = 0;
/***************************/
/* Test the channel number */
@@ -1334,7 +1332,7 @@ int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device * dev,
i_ReturnValue = -3;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1356,11 +1354,11 @@ int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device * dev,
| -101 : Data size error |
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- DWORD dw_Temp = 0;
+ int i_ReturnValue = insn->n;
+ unsigned int dw_Temp = 0;
/************************/
/* Test the buffer size */
@@ -1378,7 +1376,7 @@ int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1409,14 +1407,14 @@ int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device * dev,
| -101 : Data size error |
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_ChannelCpt = 0;
- DWORD dw_ChannelMask = 0;
- DWORD dw_BitMask = 0;
- DWORD dw_Status = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_ChannelCpt = 0;
+ unsigned int dw_ChannelMask = 0;
+ unsigned int dw_BitMask = 0;
+ unsigned int dw_Status = 0;
/************************/
/* Test the buffer size */
@@ -1481,7 +1479,7 @@ int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1505,13 +1503,13 @@ int i_APCI3XXX_InsnBitsDigitalOutput(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Channel = CR_CHAN(insn->chanspec);
- BYTE b_State = 0;
- DWORD dw_Status = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Channel = CR_CHAN(insn->chanspec);
+ unsigned char b_State = 0;
+ unsigned int dw_Status = 0;
/************************/
/* Test the buffer size */
@@ -1527,7 +1525,7 @@ int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev,
/* Get the command */
/*******************/
- b_State = (BYTE) data[0];
+ b_State = (unsigned char) data[0];
/********************************/
/* Read the digital output port */
@@ -1557,7 +1555,7 @@ int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1580,12 +1578,12 @@ int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- INT i_ReturnValue = insn->n;
- BYTE b_Channel = CR_CHAN(insn->chanspec);
- DWORD dw_Status = 0;
+ int i_ReturnValue = insn->n;
+ unsigned char b_Channel = CR_CHAN(insn->chanspec);
+ unsigned int dw_Status = 0;
/************************/
/* Test the buffer size */
@@ -1622,7 +1620,7 @@ int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device * dev,
i_ReturnValue = -101;
}
- return (i_ReturnValue);
+ return i_ReturnValue;
}
/*
@@ -1638,7 +1636,7 @@ int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device * dev,
+----------------------------------------------------------------------------+
*/
-int i_APCI3XXX_Reset(struct comedi_device * dev)
+int i_APCI3XXX_Reset(struct comedi_device *dev)
{
unsigned char b_Cpt = 0;
diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c
index bac018202fe8..da454e854c4c 100644
--- a/drivers/staging/comedi/drivers/addi_apci_035.c
+++ b/drivers/staging/comedi/drivers/addi_apci_035.c
@@ -1,5 +1,5 @@
#define CONFIG_APCI_035 1
-#define ADDIDATA_WATCHDOG 2 // Or shold it be something else
+#define ADDIDATA_WATCHDOG 2 /* Or shold it be something else */
#include "addi-data/addi_common.c"
diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index f710f551820d..b4807fc7eb01 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -61,35 +61,35 @@ struct pci6208_board {
const char *name;
unsigned short dev_id; /* `lspci` will show you this */
int ao_chans;
- //int ao_bits;
+ /* int ao_bits; */
};
static const struct pci6208_board pci6208_boards[] = {
/*{
- name : "pci6208v",
- dev_id : 0x6208, //not sure
- ao_chans: 8
- //, ao_bits : 16
+ .name = "pci6208v",
+ .dev_id = 0x6208, // not sure
+ .ao_chans = 8
+ // , .ao_bits = 16
},
{
- name : "pci6216v",
- dev_id : 0x6208, //not sure
- ao_chans: 16
- //, ao_bits : 16
+ .name = "pci6216v",
+ .dev_id = 0x6208, // not sure
+ .ao_chans = 16
+ // , .ao_bits = 16
}, */
{
- name: "pci6208a",
- dev_id: 0x6208,
- ao_chans:8
- //, ao_bits : 16
+ .name = "pci6208a",
+ .dev_id = 0x6208,
+ .ao_chans = 8
+ /* , .ao_bits = 16 */
}
};
/* This is used by modprobe to translate PCI IDs to drivers. Should
* only be used for PCI and ISA-PnP devices */
static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
- //{ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
- //{ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+ /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
+ /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
{PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0}
};
@@ -107,35 +107,32 @@ struct pci6208_private {
#define devpriv ((struct pci6208_private *)dev->private)
-static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci6208_detach(struct comedi_device * dev);
-
-#define pci6208_board_nbr \
- (sizeof(pci6208_boards) / sizeof(struct pci6208_board))
+static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci6208_detach(struct comedi_device *dev);
static struct comedi_driver driver_pci6208 = {
- driver_name:PCI6208_DRIVER_NAME,
- module:THIS_MODULE,
- attach:pci6208_attach,
- detach:pci6208_detach,
+ .driver_name = PCI6208_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pci6208_attach,
+ .detach = pci6208_detach,
};
COMEDI_PCI_INITCLEANUP(driver_pci6208, pci6208_pci_table);
-static int pci6208_find_device(struct comedi_device * dev, int bus, int slot);
+static int pci6208_find_device(struct comedi_device *dev, int bus, int slot);
static int
pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
int dev_minor);
/*read/write functions*/
-static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-//static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s,
-// struct comedi_insn *insn,unsigned int *data);
-//static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s,
-// struct comedi_insn *insn,unsigned int *data);
+static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data); */
+/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data); */
/*
* Attach is called by the Comedi core to configure the driver
@@ -143,7 +140,7 @@ static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int retval;
@@ -176,22 +173,22 @@ static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig *
s = dev->subdevices + 0;
/* analog output subdevice */
s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE; //anything else to add here??
+ s->subdev_flags = SDF_WRITABLE; /* anything else to add here?? */
s->n_chan = thisboard->ao_chans;
- s->maxdata = 0xffff; //16-bit DAC
- s->range_table = &range_bipolar10; //this needs to be checked.
+ s->maxdata = 0xffff; /* 16-bit DAC */
+ s->range_table = &range_bipolar10; /* this needs to be checked. */
s->insn_write = pci6208_ao_winsn;
s->insn_read = pci6208_ao_rinsn;
- //s=dev->subdevices+1;
+ /* s=dev->subdevices+1; */
/* digital i/o subdevice */
- //s->type=COMEDI_SUBD_DIO;
- //s->subdev_flags=SDF_READABLE|SDF_WRITABLE;
- //s->n_chan=16;
- //s->maxdata=1;
- //s->range_table=&range_digital;
- //s->insn_bits = pci6208_dio_insn_bits;
- //s->insn_config = pci6208_dio_insn_config;
+ /* s->type=COMEDI_SUBD_DIO; */
+ /* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */
+ /* s->n_chan=16; */
+ /* s->maxdata=1; */
+ /* s->range_table=&range_digital; */
+ /* s->insn_bits = pci6208_dio_insn_bits; */
+ /* s->insn_config = pci6208_dio_insn_config; */
printk("attached\n");
@@ -206,7 +203,7 @@ static int pci6208_attach(struct comedi_device * dev, struct comedi_devconfig *
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pci6208_detach(struct comedi_device * dev)
+static int pci6208_detach(struct comedi_device *dev)
{
printk("comedi%d: pci6208: remove\n", dev->minor);
@@ -220,8 +217,8 @@ static int pci6208_detach(struct comedi_device * dev)
return 0;
}
-static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i = 0, Data_Read;
unsigned short chan = CR_CHAN(insn->chanspec);
@@ -245,8 +242,8 @@ static int pci6208_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -262,51 +259,51 @@ static int pci6208_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-//static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s,
-// struct comedi_insn *insn,unsigned int *data)
-//{
-// if(insn->n!=2)return -EINVAL;
+/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data) */
+/* { */
+/* if(insn->n!=2)return -EINVAL; */
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
-// if(data[0]){
-// s->state &= ~data[0];
-// s->state |= data[0]&data[1];
+/* if(data[0]){ */
+/* s->state &= ~data[0]; */
+/* s->state |= data[0]&data[1]; */
/* Write out the new digital output lines */
- //outw(s->state,dev->iobase + SKEL_DIO);
-// }
+ /* outw(s->state,dev->iobase + SKEL_DIO); */
+/* } */
/* on return, data[1] contains the value of the digital
* input and output lines. */
- //data[1]=inw(dev->iobase + SKEL_DIO);
+ /* data[1]=inw(dev->iobase + SKEL_DIO); */
/* or we could just return the software copy of the output values if
* it was a purely digital output subdevice */
- //data[1]=s->state;
+ /* data[1]=s->state; */
-// return 2;
-//}
+/* return 2; */
+/* } */
-//static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s,
-// struct comedi_insn *insn,unsigned int *data)
-//{
-// int chan=CR_CHAN(insn->chanspec);
+/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
+/* struct comedi_insn *insn,unsigned int *data) */
+/* { */
+/* int chan=CR_CHAN(insn->chanspec); */
/* The input or output configuration of each digital line is
* configured by a special insn_config instruction. chanspec
* contains the channel to be changed, and data[0] contains the
* value COMEDI_INPUT or COMEDI_OUTPUT. */
-// if(data[0]==COMEDI_OUTPUT){
-// s->io_bits |= 1<<chan;
-// }else{
-// s->io_bits &= ~(1<<chan);
-// }
- //outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG);
+/* if(data[0]==COMEDI_OUTPUT){ */
+/* s->io_bits |= 1<<chan; */
+/* }else{ */
+/* s->io_bits &= ~(1<<chan); */
+/* } */
+ /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
-// return 1;
-//}
+/* return 1; */
+/* } */
-static int pci6208_find_device(struct comedi_device * dev, int bus, int slot)
+static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
{
struct pci_dev *pci_dev;
int i;
@@ -315,11 +312,11 @@ static int pci6208_find_device(struct comedi_device * dev, int bus, int slot)
pci_dev != NULL;
pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
- for (i = 0; i < pci6208_board_nbr; i++) {
+ for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
if (pci6208_boards[i].dev_id == pci_dev->device) {
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if ((bus != 0) || (slot != 0)) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pci_dev->bus->number
!= bus ||
PCI_SLOT(pci_dev->devfn)
@@ -346,10 +343,10 @@ static int pci6208_find_device(struct comedi_device * dev, int bus, int slot)
PCI_SLOT(pci_dev->devfn),
PCI_FUNC(pci_dev->devfn), pci_dev->irq);
- // TODO: Warn about non-tested boards.
- //switch(board->device_id)
- //{
- //};
+ /* TODO: Warn about non-tested boards. */
+ /* switch(board->device_id) */
+ /* { */
+ /* }; */
devpriv->pci_dev = pci_dev;
@@ -362,19 +359,19 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
{
unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
- // Enable PCI device and request regions
+ /* Enable PCI device and request regions */
if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) {
printk("comedi%d: Failed to enable PCI device and request regions\n", dev_minor);
return -EIO;
}
- // Read local configuration register base address [PCI_BASE_ADDRESS #1].
+ /* Read local configuration register base address [PCI_BASE_ADDRESS #1]. */
lcr_io_base = pci_resource_start(pci_dev, 1);
lcr_io_range = pci_resource_len(pci_dev, 1);
printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n",
dev_minor, lcr_io_base, lcr_io_range);
- // Read PCI6208 register base address [PCI_BASE_ADDRESS #2].
+ /* Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */
io_base = pci_resource_start(pci_dev, 2);
io_range = pci_resource_end(pci_dev, 2) - io_base + 1;
@@ -382,10 +379,10 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
dev_minor, io_base, io_range);
*io_base_ptr = io_base;
- //devpriv->io_range = io_range;
- //devpriv->is_valid=0;
- //devpriv->lcr_io_base=lcr_io_base;
- //devpriv->lcr_io_range=lcr_io_range;
+ /* devpriv->io_range = io_range; */
+ /* devpriv->is_valid=0; */
+ /* devpriv->lcr_io_base=lcr_io_base; */
+ /* devpriv->lcr_io_range=lcr_io_range; */
return 0;
}
diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c
index bd0f9ab226ef..d2f23a88608d 100644
--- a/drivers/staging/comedi/drivers/adl_pci7296.c
+++ b/drivers/staging/comedi/drivers/adl_pci7296.c
@@ -39,7 +39,7 @@ Configuration Options:
#include "comedi_pci.h"
#include "8255.h"
-// #include "8253.h"
+/* #include "8253.h" */
#define PORT1A 0
#define PORT2A 4
@@ -64,16 +64,16 @@ struct adl_pci7296_private {
#define devpriv ((struct adl_pci7296_private *)dev->private)
-static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int adl_pci7296_detach(struct comedi_device * dev);
+static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adl_pci7296_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci7296 = {
- driver_name:"adl_pci7296",
- module:THIS_MODULE,
- attach:adl_pci7296_attach,
- detach:adl_pci7296_detach,
+ .driver_name = "adl_pci7296",
+ .module = THIS_MODULE,
+ .attach = adl_pci7296_attach,
+ .detach = adl_pci7296_detach,
};
-static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
struct comedi_subdevice *s;
@@ -115,7 +115,7 @@ static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfi
dev->iobase = pci_resource_start(pcidev, 2);
printk("comedi: base addr %4lx\n", dev->iobase);
- // four 8255 digital io subdevices
+ /* four 8255 digital io subdevices */
s = dev->subdevices + 0;
subdev_8255_init(dev, s, NULL,
(unsigned long)(dev->iobase));
@@ -149,7 +149,7 @@ static int adl_pci7296_attach(struct comedi_device * dev, struct comedi_devconfi
return -EIO;
}
-static int adl_pci7296_detach(struct comedi_device * dev)
+static int adl_pci7296_detach(struct comedi_device *dev)
{
printk("comedi%d: pci7432: remove\n", dev->minor);
@@ -159,7 +159,7 @@ static int adl_pci7296_detach(struct comedi_device * dev)
}
pci_dev_put(devpriv->pci_dev);
}
- // detach four 8255 digital io subdevices
+ /* detach four 8255 digital io subdevices */
if (dev->subdevices) {
subdev_8255_cleanup(dev, dev->subdevices + 0);
subdev_8255_cleanup(dev, dev->subdevices + 1);
diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c
index a8f1715608d1..78becbdd17a8 100644
--- a/drivers/staging/comedi/drivers/adl_pci7432.c
+++ b/drivers/staging/comedi/drivers/adl_pci7432.c
@@ -58,26 +58,26 @@ struct adl_pci7432_private {
#define devpriv ((struct adl_pci7432_private *)dev->private)
-static int adl_pci7432_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int adl_pci7432_detach(struct comedi_device * dev);
+static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adl_pci7432_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci7432 = {
- driver_name:"adl_pci7432",
- module:THIS_MODULE,
- attach:adl_pci7432_attach,
- detach:adl_pci7432_detach,
+ .driver_name = "adl_pci7432",
+ .module = THIS_MODULE,
+ .attach = adl_pci7432_attach,
+ .detach = adl_pci7432_detach,
};
/* Digital IO */
-static int adl_pci7432_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci7432_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/* */
-static int adl_pci7432_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
struct comedi_subdevice *s;
@@ -150,7 +150,7 @@ static int adl_pci7432_attach(struct comedi_device * dev, struct comedi_devconfi
return -EIO;
}
-static int adl_pci7432_detach(struct comedi_device * dev)
+static int adl_pci7432_detach(struct comedi_device *dev)
{
printk("comedi%d: pci7432: remove\n", dev->minor);
@@ -164,8 +164,8 @@ static int adl_pci7432_detach(struct comedi_device * dev)
return 0;
}
-static int adl_pci7432_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
printk("comedi: pci7432_do_insn_bits called\n");
printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]);
@@ -184,8 +184,8 @@ static int adl_pci7432_do_insn_bits(struct comedi_device * dev, struct comedi_su
return 2;
}
-static int adl_pci7432_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
printk("comedi: pci7432_di_insn_bits called\n");
printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]);
diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c
index adf90be79983..2d7d68af6b1e 100644
--- a/drivers/staging/comedi/drivers/adl_pci8164.c
+++ b/drivers/staging/comedi/drivers/adl_pci8164.c
@@ -70,40 +70,40 @@ struct adl_pci8164_private {
#define devpriv ((struct adl_pci8164_private *)dev->private)
-static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int adl_pci8164_detach(struct comedi_device * dev);
+static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adl_pci8164_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci8164 = {
- driver_name:"adl_pci8164",
- module:THIS_MODULE,
- attach:adl_pci8164_attach,
- detach:adl_pci8164_detach,
+ .driver_name = "adl_pci8164",
+ .module = THIS_MODULE,
+ .attach = adl_pci8164_attach,
+ .detach = adl_pci8164_detach,
};
-static int adl_pci8164_insn_read_msts(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_read_msts(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_read_ssts(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_read_buf0(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_read_buf1(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_write_cmd(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_write_otp(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_write_buf0(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_insn_write_buf1(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
struct comedi_subdevice *s;
@@ -149,7 +149,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
- //s->range_table = &range_axis;
+ /* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_msts;
s->insn_write = adl_pci8164_insn_write_cmd;
@@ -159,7 +159,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
- //s->range_table = &range_axis;
+ /* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_ssts;
s->insn_write = adl_pci8164_insn_write_otp;
@@ -169,7 +169,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
- //s->range_table = &range_axis;
+ /* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_buf0;
s->insn_write = adl_pci8164_insn_write_buf0;
@@ -179,7 +179,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
- //s->range_table = &range_axis;
+ /* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_buf1;
s->insn_write = adl_pci8164_insn_write_buf1;
@@ -194,7 +194,7 @@ static int adl_pci8164_attach(struct comedi_device * dev, struct comedi_devconfi
return -EIO;
}
-static int adl_pci8164_detach(struct comedi_device * dev)
+static int adl_pci8164_detach(struct comedi_device *dev)
{
printk("comedi%d: pci8164: remove\n", dev->minor);
@@ -208,8 +208,16 @@ static int adl_pci8164_detach(struct comedi_device * dev)
return 0;
}
-static int adl_pci8164_insn_read_msts(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/*
+ all the read commands are the same except for the addition a constant
+ * const to the data for inw()
+ */
+static void adl_pci8164_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data,
+ char *action,
+ unsigned short offset)
{
int axis, axis_reg;
char *axisname;
@@ -238,127 +246,51 @@ static int adl_pci8164_insn_read_msts(struct comedi_device * dev, struct comedi_
axisname = "X";
}
- data[0] = inw(dev->iobase + axis_reg + PCI8164_MSTS);
- printk("comedi: pci8164 MSTS read -> %04X:%04X on axis %s\n", data[0],
+ data[0] = inw(dev->iobase + axis_reg + offset);
+ printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action, data[0],
data[1], axisname);
+}
+static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ adl_pci8164_insn_read(dev, s, insn, data, "MSTS", PCI8164_MSTS);
return 2;
}
-static int adl_pci8164_insn_read_ssts(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int axis, axis_reg;
- char *axisname;
-
- axis = CR_CHAN(insn->chanspec);
-
- switch (axis) {
- case 0:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- break;
- case 1:
- axis_reg = PCI8164_AXIS_Y;
- axisname = "Y";
- break;
- case 2:
- axis_reg = PCI8164_AXIS_Z;
- axisname = "Z";
- break;
- case 3:
- axis_reg = PCI8164_AXIS_U;
- axisname = "U";
- break;
- default:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- }
-
- data[0] = inw(dev->iobase + axis_reg + PCI8164_SSTS);
- printk("comedi: pci8164 SSTS read -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
-
+ adl_pci8164_insn_read(dev, s, insn, data, "SSTS", PCI8164_SSTS);
return 2;
}
-static int adl_pci8164_insn_read_buf0(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int axis, axis_reg;
- char *axisname;
-
- axis = CR_CHAN(insn->chanspec);
-
- switch (axis) {
- case 0:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- break;
- case 1:
- axis_reg = PCI8164_AXIS_Y;
- axisname = "Y";
- break;
- case 2:
- axis_reg = PCI8164_AXIS_Z;
- axisname = "Z";
- break;
- case 3:
- axis_reg = PCI8164_AXIS_U;
- axisname = "U";
- break;
- default:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- }
-
- data[0] = inw(dev->iobase + axis_reg + PCI8164_BUF0);
- printk("comedi: pci8164 BUF0 read -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
-
+ adl_pci8164_insn_read(dev, s, insn, data, "BUF0", PCI8164_BUF0);
return 2;
}
-static int adl_pci8164_insn_read_buf1(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int axis, axis_reg;
-
- char *axisname;
-
- axis = CR_CHAN(insn->chanspec);
-
- switch (axis) {
- case 0:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- break;
- case 1:
- axis_reg = PCI8164_AXIS_Y;
- axisname = "Y";
- break;
- case 2:
- axis_reg = PCI8164_AXIS_Z;
- axisname = "Z";
- break;
- case 3:
- axis_reg = PCI8164_AXIS_U;
- axisname = "U";
- break;
- default:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- }
-
- data[0] = inw(dev->iobase + axis_reg + PCI8164_BUF1);
- printk("comedi: pci8164 BUF1 read -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
-
+ adl_pci8164_insn_read(dev, s, insn, data, "BUF1", PCI8164_BUF1);
return 2;
}
-static int adl_pci8164_insn_write_cmd(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/*
+ all the write commands are the same except for the addition a constant
+ * const to the data for outw()
+ */
+static void adl_pci8164_insn_out(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data,
+ char *action,
+ unsigned short offset)
{
unsigned int axis, axis_reg;
@@ -388,124 +320,39 @@ static int adl_pci8164_insn_write_cmd(struct comedi_device * dev, struct comedi_
axisname = "X";
}
- outw(data[0], dev->iobase + axis_reg + PCI8164_CMD);
- printk("comedi: pci8164 CMD write -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
-
- return 2;
-}
-
-static int adl_pci8164_insn_write_otp(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
-{
- int axis, axis_reg;
-
- char *axisname;
+ outw(data[0], dev->iobase + axis_reg + offset);
- axis = CR_CHAN(insn->chanspec);
+ printk("comedi: pci8164 %s write -> %04X:%04X on axis %s\n", action,
+ data[0], data[1], axisname);
- switch (axis) {
- case 0:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- break;
- case 1:
- axis_reg = PCI8164_AXIS_Y;
- axisname = "Y";
- break;
- case 2:
- axis_reg = PCI8164_AXIS_Z;
- axisname = "Z";
- break;
- case 3:
- axis_reg = PCI8164_AXIS_U;
- axisname = "U";
- break;
- default:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- }
+}
- outw(data[0], dev->iobase + axis_reg + PCI8164_OTP);
- printk("comedi: pci8164 OTP write -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
+static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ adl_pci8164_insn_out(dev, s, insn, data, "CMD", PCI8164_CMD);
return 2;
}
-static int adl_pci8164_insn_write_buf0(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int axis, axis_reg;
-
- char *axisname;
-
- axis = CR_CHAN(insn->chanspec);
-
- switch (axis) {
- case 0:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- break;
- case 1:
- axis_reg = PCI8164_AXIS_Y;
- axisname = "Y";
- break;
- case 2:
- axis_reg = PCI8164_AXIS_Z;
- axisname = "Z";
- break;
- case 3:
- axis_reg = PCI8164_AXIS_U;
- axisname = "U";
- break;
- default:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- }
-
- outw(data[0], dev->iobase + axis_reg + PCI8164_BUF0);
- printk("comedi: pci8164 BUF0 write -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
-
+ adl_pci8164_insn_out(dev, s, insn, data, "OTP", PCI8164_OTP);
return 2;
}
-static int adl_pci8164_insn_write_buf1(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- int axis, axis_reg;
-
- char *axisname;
-
- axis = CR_CHAN(insn->chanspec);
-
- switch (axis) {
- case 0:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- break;
- case 1:
- axis_reg = PCI8164_AXIS_Y;
- axisname = "Y";
- break;
- case 2:
- axis_reg = PCI8164_AXIS_Z;
- axisname = "Z";
- break;
- case 3:
- axis_reg = PCI8164_AXIS_U;
- axisname = "U";
- break;
- default:
- axis_reg = PCI8164_AXIS_X;
- axisname = "X";
- }
-
- outw(data[0], dev->iobase + axis_reg + PCI8164_BUF1);
- printk("comedi: pci8164 BUF1 write -> %04X:%04X on axis %s\n", data[0],
- data[1], axisname);
+ adl_pci8164_insn_out(dev, s, insn, data, "BUF0", PCI8164_BUF0);
+ return 2;
+}
+static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+{
+ adl_pci8164_insn_out(dev, s, insn, data, "BUF1", PCI8164_BUF1);
return 2;
}
diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c
index b4a61c560c5b..0ac722e6f37a 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -77,6 +77,7 @@ TODO:
#include "../comedidev.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include "8253.h"
#include "comedi_pci.h"
@@ -186,24 +187,24 @@ TODO:
(inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK)&0x0F)
#define pci9111_trigger_and_autoscan_set(flags) \
- outb(flags,PCI9111_IO_BASE+PCI9111_REGISTER_TRIGGER_MODE_CONTROL)
+ outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_TRIGGER_MODE_CONTROL)
#define pci9111_interrupt_and_fifo_get() \
((inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK) >> 4) &0x03)
#define pci9111_interrupt_and_fifo_set(flags) \
- outb(flags,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL)
+ outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL)
#define pci9111_interrupt_clear() \
- outb(0,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CLEAR)
+ outb(0, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CLEAR)
#define pci9111_software_trigger() \
- outb(0,PCI9111_IO_BASE+PCI9111_REGISTER_SOFTWARE_TRIGGER)
+ outb(0, PCI9111_IO_BASE+PCI9111_REGISTER_SOFTWARE_TRIGGER)
#define pci9111_fifo_reset() \
- outb(PCI9111_FFEN_SET_FIFO_ENABLE,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
- outb(PCI9111_FFEN_SET_FIFO_DISABLE,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
- outb(PCI9111_FFEN_SET_FIFO_ENABLE,PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL)
+ outb(PCI9111_FFEN_SET_FIFO_ENABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
+ outb(PCI9111_FFEN_SET_FIFO_DISABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
+ outb(PCI9111_FFEN_SET_FIFO_ENABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL)
#define pci9111_is_fifo_full() \
((inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)& \
@@ -218,13 +219,13 @@ TODO:
PCI9111_FIFO_EMPTY_MASK)==0)
#define pci9111_ai_channel_set(channel) \
- outb((channel)&PCI9111_CHANNEL_MASK,PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_CONTROL)
+ outb((channel)&PCI9111_CHANNEL_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_CONTROL)
#define pci9111_ai_channel_get() \
inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_READBACK)&PCI9111_CHANNEL_MASK
#define pci9111_ai_range_set(range) \
- outb((range)&PCI9111_RANGE_MASK,PCI9111_IO_BASE+PCI9111_REGISTER_INPUT_SIGNAL_RANGE)
+ outb((range)&PCI9111_RANGE_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_INPUT_SIGNAL_RANGE)
#define pci9111_ai_range_get() \
inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)&PCI9111_RANGE_MASK
@@ -238,34 +239,34 @@ TODO:
^ PCI9111_HR_AI_RESOLUTION_2_CMP_BIT
#define pci9111_ao_set_data(data) \
- outw(data&PCI9111_AO_RESOLUTION_MASK,PCI9111_IO_BASE+PCI9111_REGISTER_DA_OUTPUT)
+ outw(data&PCI9111_AO_RESOLUTION_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_DA_OUTPUT)
#define pci9111_di_get_bits() \
inw(PCI9111_IO_BASE+PCI9111_REGISTER_DIGITAL_IO)
#define pci9111_do_set_bits(bits) \
- outw(bits,PCI9111_IO_BASE+PCI9111_REGISTER_DIGITAL_IO)
+ outw(bits, PCI9111_IO_BASE+PCI9111_REGISTER_DIGITAL_IO)
#define pci9111_8254_control_set(flags) \
- outb(flags,PCI9111_IO_BASE+PCI9111_REGISTER_8254_CONTROL)
+ outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_8254_CONTROL)
#define pci9111_8254_counter_0_set(data) \
outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0); \
- outb( (data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0)
+ outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0)
#define pci9111_8254_counter_1_set(data) \
outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1); \
- outb( (data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1)
+ outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1)
#define pci9111_8254_counter_2_set(data) \
outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \
- outb( (data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2)
+ outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2)
/* Function prototypes */
-static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci9111_detach(struct comedi_device * dev);
-static void pci9111_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci9111_detach(struct comedi_device *dev);
+static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *data, unsigned int num_bytes, unsigned int start_chan_index);
static const struct comedi_lrange pci9111_hr_ai_range = {
@@ -308,27 +309,27 @@ struct pci9111_board {
static const struct pci9111_board pci9111_boards[] = {
{
- name: "pci9111_hr",
- device_id:PCI9111_HR_DEVICE_ID,
- ai_channel_nbr:PCI9111_AI_CHANNEL_NBR,
- ao_channel_nbr:PCI9111_AO_CHANNEL_NBR,
- ai_resolution:PCI9111_HR_AI_RESOLUTION,
- ai_resolution_mask:PCI9111_HR_AI_RESOLUTION_MASK,
- ao_resolution:PCI9111_AO_RESOLUTION,
- ao_resolution_mask:PCI9111_AO_RESOLUTION_MASK,
- ai_range_list:&pci9111_hr_ai_range,
- ao_range_list:&range_bipolar10,
- ai_acquisition_period_min_ns:PCI9111_AI_ACQUISITION_PERIOD_MIN_NS}
+ .name = "pci9111_hr",
+ .device_id = PCI9111_HR_DEVICE_ID,
+ .ai_channel_nbr = PCI9111_AI_CHANNEL_NBR,
+ .ao_channel_nbr = PCI9111_AO_CHANNEL_NBR,
+ .ai_resolution = PCI9111_HR_AI_RESOLUTION,
+ .ai_resolution_mask = PCI9111_HR_AI_RESOLUTION_MASK,
+ .ao_resolution = PCI9111_AO_RESOLUTION,
+ .ao_resolution_mask = PCI9111_AO_RESOLUTION_MASK,
+ .ai_range_list = &pci9111_hr_ai_range,
+ .ao_range_list = &range_bipolar10,
+ .ai_acquisition_period_min_ns = PCI9111_AI_ACQUISITION_PERIOD_MIN_NS}
};
#define pci9111_board_nbr \
(sizeof(pci9111_boards)/sizeof(struct pci9111_board))
static struct comedi_driver pci9111_driver = {
- driver_name:PCI9111_DRIVER_NAME,
- module:THIS_MODULE,
- attach:pci9111_attach,
- detach:pci9111_detach,
+ .driver_name = PCI9111_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pci9111_attach,
+ .detach = pci9111_detach,
};
COMEDI_PCI_INITCLEANUP(pci9111_driver, pci9111_pci_table);
@@ -405,7 +406,7 @@ static void plx9050_interrupt_control(unsigned long io_base,
/* 8254 timer */
-static void pci9111_timer_set(struct comedi_device * dev)
+static void pci9111_timer_set(struct comedi_device *dev)
{
pci9111_8254_control_set(PCI9111_8254_COUNTER_0 |
PCI9111_8254_READ_LOAD_LSB_MSB |
@@ -419,7 +420,7 @@ static void pci9111_timer_set(struct comedi_device * dev)
PCI9111_8254_READ_LOAD_LSB_MSB |
PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER);
- comedi_udelay(1);
+ udelay(1);
pci9111_8254_counter_2_set(dev_private->timer_divisor_2);
pci9111_8254_counter_1_set(dev_private->timer_divisor_1);
@@ -431,7 +432,7 @@ enum pci9111_trigger_sources {
external
};
-static void pci9111_trigger_source_set(struct comedi_device * dev,
+static void pci9111_trigger_source_set(struct comedi_device *dev,
enum pci9111_trigger_sources source)
{
int flags;
@@ -455,7 +456,7 @@ static void pci9111_trigger_source_set(struct comedi_device * dev,
pci9111_trigger_and_autoscan_set(flags);
}
-static void pci9111_pretrigger_set(struct comedi_device * dev, bool pretrigger)
+static void pci9111_pretrigger_set(struct comedi_device *dev, bool pretrigger)
{
int flags;
@@ -467,7 +468,7 @@ static void pci9111_pretrigger_set(struct comedi_device * dev, bool pretrigger)
pci9111_trigger_and_autoscan_set(flags);
}
-static void pci9111_autoscan_set(struct comedi_device * dev, bool autoscan)
+static void pci9111_autoscan_set(struct comedi_device *dev, bool autoscan)
{
int flags;
@@ -489,7 +490,7 @@ enum pci9111_ISC1_sources {
irq_on_external_trigger
};
-static void pci9111_interrupt_source_set(struct comedi_device * dev,
+static void pci9111_interrupt_source_set(struct comedi_device *dev,
enum pci9111_ISC0_sources irq_0_source, enum pci9111_ISC1_sources irq_1_source)
{
int flags;
@@ -513,7 +514,7 @@ static void pci9111_interrupt_source_set(struct comedi_device * dev,
#undef AI_DO_CMD_DEBUG
-static int pci9111_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci9111_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
/* Disable interrupts */
@@ -535,14 +536,14 @@ static int pci9111_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
/* Test analog input command */
-#define pci9111_check_trigger_src(src,flags) \
+#define pci9111_check_trigger_src(src, flags) \
tmp = src; \
src &= flags; \
if (!src || tmp != src) error++
static int
-pci9111_ai_do_cmd_test(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_cmd * cmd)
+pci9111_ai_do_cmd_test(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int tmp;
int error = 0;
@@ -740,7 +741,7 @@ pci9111_ai_do_cmd_test(struct comedi_device * dev,
/* Analog input command */
-static int pci9111_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * subdevice)
+static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subdevice)
{
struct comedi_cmd *async_cmd = &subdevice->async->cmd;
@@ -858,7 +859,7 @@ static int pci9111_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static void pci9111_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *data, unsigned int num_bytes, unsigned int start_chan_index)
{
unsigned int i, num_samples = num_bytes / sizeof(short);
@@ -884,7 +885,7 @@ static void pci9111_ai_munge(struct comedi_device * dev, struct comedi_subdevice
#undef INTERRUPT_DEBUG
-static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG)
+static irqreturn_t pci9111_interrupt(int irq, void *p_device)
{
struct comedi_device *dev = p_device;
struct comedi_subdevice *subdevice = dev->read_subdev;
@@ -900,7 +901,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG)
async = subdevice->async;
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
/* Check if we are source of interrupt */
intcsr = inb(dev_private->lcr_io_base +
@@ -918,7 +919,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG)
PLX9050_LINTI2_STATUS))))) {
/* Not the source of the interrupt. */
/* (N.B. not using PLX9050_SOFTWARE_INTERRUPT) */
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return IRQ_NONE;
}
@@ -927,7 +928,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG)
/* Interrupt comes from fifo_half-full signal */
if (pci9111_is_fifo_full()) {
- comedi_spin_unlock_irqrestore(&dev->spinlock,
+ spin_unlock_irqrestore(&dev->spinlock,
irq_flags);
comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow");
pci9111_interrupt_clear();
@@ -1027,7 +1028,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG)
pci9111_interrupt_clear();
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
comedi_event(dev, subdevice);
@@ -1042,8 +1043,8 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device PT_REGS_ARG)
#undef AI_INSN_DEBUG
-static int pci9111_ai_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * subdevice, struct comedi_insn * insn, unsigned int * data)
+static int pci9111_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
{
int resolution =
((struct pci9111_board *) dev->board_ptr)->ai_resolution;
@@ -1100,8 +1101,8 @@ static int pci9111_ai_insn_read(struct comedi_device * dev,
/* Analog instant output */
static int
-pci9111_ao_insn_write(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+pci9111_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -1115,8 +1116,8 @@ pci9111_ao_insn_write(struct comedi_device * dev,
/* Analog output readback */
-static int pci9111_ao_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int pci9111_ao_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -1133,8 +1134,8 @@ static int pci9111_ao_insn_read(struct comedi_device * dev,
/* Digital inputs */
-static int pci9111_di_insn_bits(struct comedi_device * dev,
- struct comedi_subdevice * subdevice, struct comedi_insn * insn, unsigned int * data)
+static int pci9111_di_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -1146,8 +1147,8 @@ static int pci9111_di_insn_bits(struct comedi_device * dev,
/* Digital outputs */
-static int pci9111_do_insn_bits(struct comedi_device * dev,
- struct comedi_subdevice * subdevice, struct comedi_insn * insn, unsigned int * data)
+static int pci9111_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -1175,7 +1176,7 @@ static int pci9111_do_insn_bits(struct comedi_device * dev,
/* Reset device */
-static int pci9111_reset(struct comedi_device * dev)
+static int pci9111_reset(struct comedi_device *dev)
{
/* Set trigger source to software */
@@ -1200,7 +1201,7 @@ static int pci9111_reset(struct comedi_device * dev)
/* - Register PCI device */
/* - Declare device driver capability */
-static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *subdevice;
unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
@@ -1297,8 +1298,7 @@ static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig *
dev->irq = 0;
if (pci_device->irq > 0) {
- if (comedi_request_irq(pci_device->irq,
- pci9111_interrupt,
+ if (request_irq(pci_device->irq, pci9111_interrupt,
IRQF_SHARED, PCI9111_DRIVER_NAME, dev) != 0) {
printk("comedi%d: unable to allocate irq %u\n",
dev->minor, pci_device->irq);
@@ -1309,7 +1309,8 @@ static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig *
/* TODO: Add external multiplexer setup (according to option[2]). */
- if ((error = alloc_subdevices(dev, 4)) < 0)
+ error = alloc_subdevices(dev, 4);
+ if (error < 0)
return error;
subdevice = dev->subdevices + 0;
@@ -1365,7 +1366,7 @@ static int pci9111_attach(struct comedi_device * dev, struct comedi_devconfig *
/* Detach */
-static int pci9111_detach(struct comedi_device * dev)
+static int pci9111_detach(struct comedi_device *dev)
{
/* Reset device */
@@ -1377,7 +1378,7 @@ static int pci9111_detach(struct comedi_device * dev)
/* Release previously allocated irq */
if (dev->irq != 0) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev_private != 0 && dev_private->pci_device != 0) {
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index 278cf30cc4a3..65f522be9124 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -66,6 +66,7 @@ Configuration options:
#include "../pci_ids.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include "amcc_s5933.h"
#include "8253.h"
@@ -79,7 +80,7 @@ Configuration options:
#undef DPRINTK
#ifdef PCI9118_EXTDEBUG
-#define DPRINTK(fmt, args...) rt_printk(fmt, ## args)
+#define DPRINTK(fmt, args...) printk(fmt, ## args)
#else
#define DPRINTK(fmt, args...)
#endif
@@ -107,7 +108,7 @@ Configuration options:
#define PCI9118_INTSRC 0x38 /* R: interrupt reason register */
#define PCI9118_INTCTRL 0x38 /* W: interrupt control register */
-// bits from A/D control register (PCI9118_ADCNTRL)
+/* bits from A/D control register (PCI9118_ADCNTRL) */
#define AdControl_UniP 0x80 /* 1=bipolar, 0=unipolar */
#define AdControl_Diff 0x40 /* 1=differential, 0= single end inputs */
#define AdControl_SoftG 0x20 /* 1=8254 counter works, 0=counter stops */
@@ -117,7 +118,7 @@ Configuration options:
#define AdControl_Int 0x02 /* 1=enable INT, 0=disable */
#define AdControl_Dma 0x01 /* 1=enable DMA, 0=disable */
-// bits from A/D function register (PCI9118_ADFUNC)
+/* bits from A/D function register (PCI9118_ADFUNC) */
#define AdFunction_PDTrg 0x80 /* 1=positive, 0=negative digital trigger (only positive is correct) */
#define AdFunction_PETrg 0x40 /* 1=positive, 0=negative external trigger (only positive is correct) */
#define AdFunction_BSSH 0x20 /* 1=with sample&hold, 0=without */
@@ -127,7 +128,7 @@ Configuration options:
#define AdFunction_AM 0x02 /* 1=about trigger mode, 0=not about trigger */
#define AdFunction_Start 0x01 /* 1=trigger start, 0=trigger stop */
-// bits from A/D status register (PCI9118_ADSTAT)
+/* bits from A/D status register (PCI9118_ADSTAT) */
#define AdStatus_nFull 0x100 /* 0=FIFO full (fatal), 1=not full */
#define AdStatus_nHfull 0x080 /* 0=FIFO half full, 1=FIFO not half full */
#define AdStatus_nEpty 0x040 /* 0=FIFO empty, 1=FIFO not empty */
@@ -138,8 +139,8 @@ Configuration options:
#define AdStatus_ADOR 0x002 /* 1=A/D overrun (fatal) */
#define AdStatus_ADrdy 0x001 /* 1=A/D already ready, 0=not ready */
-// bits for interrupt reason and control (PCI9118_INTSRC, PCI9118_INTCTRL)
-// 1=interrupt occur, enable source, 0=interrupt not occur, disable source
+/* bits for interrupt reason and control (PCI9118_INTSRC, PCI9118_INTCTRL) */
+/* 1=interrupt occur, enable source, 0=interrupt not occur, disable source */
#define Int_Timer 0x08 /* timer interrupt */
#define Int_About 0x04 /* about trigger complete */
#define Int_Hfull 0x02 /* A/D FIFO hlaf full */
@@ -178,27 +179,27 @@ static const struct comedi_lrange range_pci9118hg = { 8, {
#define PCI9118_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */
-static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci9118_detach(struct comedi_device * dev);
+static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci9118_detach(struct comedi_device *dev);
struct boardtype {
- const char *name; // board name
- int vendor_id; // PCI vendor a device ID of card
+ const char *name; /* board name */
+ int vendor_id; /* PCI vendor a device ID of card */
int device_id;
- int iorange_amcc; // iorange for own S5933 region
- int iorange_9118; // pass thru card region size
- int n_aichan; // num of A/D chans
- int n_aichand; // num of A/D chans in diff mode
- int mux_aichan; // num of A/D chans with external multiplexor
- int n_aichanlist; // len of chanlist
- int n_aochan; // num of D/A chans
- int ai_maxdata; // resolution of A/D
- int ao_maxdata; // resolution of D/A
- const struct comedi_lrange *rangelist_ai; // rangelist for A/D
- const struct comedi_lrange *rangelist_ao; // rangelist for D/A
- unsigned int ai_ns_min; // max sample speed of card v ns
- unsigned int ai_pacer_min; // minimal pacer value (c1*c2 or c1 in burst)
- int half_fifo_size; // size of FIFO/2
+ int iorange_amcc; /* iorange for own S5933 region */
+ int iorange_9118; /* pass thru card region size */
+ int n_aichan; /* num of A/D chans */
+ int n_aichand; /* num of A/D chans in diff mode */
+ int mux_aichan; /* num of A/D chans with external multiplexor */
+ int n_aichanlist; /* len of chanlist */
+ int n_aochan; /* num of D/A chans */
+ int ai_maxdata; /* resolution of A/D */
+ int ao_maxdata; /* resolution of D/A */
+ const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */
+ const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
+ unsigned int ai_ns_min; /* max sample speed of card v ns */
+ unsigned int ai_pacer_min; /* minimal pacer value (c1*c2 or c1 in burst) */
+ int half_fifo_size; /* size of FIFO/2 */
};
@@ -230,75 +231,75 @@ static const struct boardtype boardtypes[] = {
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
static struct comedi_driver driver_pci9118 = {
- driver_name:"adl_pci9118",
- module:THIS_MODULE,
- attach:pci9118_attach,
- detach:pci9118_detach,
- num_names:n_boardtypes,
- board_name:&boardtypes[0].name,
- offset:sizeof(struct boardtype),
+ .driver_name = "adl_pci9118",
+ .module = THIS_MODULE,
+ .attach = pci9118_attach,
+ .detach = pci9118_detach,
+ .num_names = n_boardtypes,
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct boardtype),
};
COMEDI_PCI_INITCLEANUP(driver_pci9118, pci9118_pci_table);
struct pci9118_private {
- unsigned long iobase_a; // base+size for AMCC chip
- unsigned int master; // master capable
- struct pci_dev *pcidev; // ptr to actual pcidev
- unsigned int usemux; // we want to use external multiplexor!
+ unsigned long iobase_a; /* base+size for AMCC chip */
+ unsigned int master; /* master capable */
+ struct pci_dev *pcidev; /* ptr to actual pcidev */
+ unsigned int usemux; /* we want to use external multiplexor! */
#ifdef PCI9118_PARANOIDCHECK
- unsigned short chanlist[PCI9118_CHANLEN + 1]; // list of scaned channel
- unsigned char chanlistlen; // number of scanlist
+ unsigned short chanlist[PCI9118_CHANLEN + 1]; /* list of scaned channel */
+ unsigned char chanlistlen; /* number of scanlist */
#endif
- unsigned char AdControlReg; // A/D control register
- unsigned char IntControlReg; // Interrupt control register
- unsigned char AdFunctionReg; // A/D function register
- char valid; // driver is ok
- char ai_neverending; // we do unlimited AI
- unsigned int i8254_osc_base; // frequence of onboard oscilator
- unsigned int ai_do; // what do AI? 0=nothing, 1 to 4 mode
- unsigned int ai_act_scan; // how many scans we finished
- unsigned int ai_buf_ptr; // data buffer ptr in samples
- unsigned int ai_n_chan; // how many channels is measured
- unsigned int ai_n_scanlen; // len of actual scanlist
- unsigned int ai_n_realscanlen; // what we must transfer for one outgoing scan include front/back adds
- unsigned int ai_act_dmapos; // position in actual real stream
- unsigned int ai_add_front; // how many channels we must add before scan to satisfy S&H?
- unsigned int ai_add_back; // how many channels we must add before scan to satisfy DMA?
- unsigned int *ai_chanlist; // actaul chanlist
+ unsigned char AdControlReg; /* A/D control register */
+ unsigned char IntControlReg; /* Interrupt control register */
+ unsigned char AdFunctionReg; /* A/D function register */
+ char valid; /* driver is ok */
+ char ai_neverending; /* we do unlimited AI */
+ unsigned int i8254_osc_base; /* frequence of onboard oscilator */
+ unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */
+ unsigned int ai_act_scan; /* how many scans we finished */
+ unsigned int ai_buf_ptr; /* data buffer ptr in samples */
+ unsigned int ai_n_chan; /* how many channels is measured */
+ unsigned int ai_n_scanlen; /* len of actual scanlist */
+ unsigned int ai_n_realscanlen; /* what we must transfer for one outgoing scan include front/back adds */
+ unsigned int ai_act_dmapos; /* position in actual real stream */
+ unsigned int ai_add_front; /* how many channels we must add before scan to satisfy S&H? */
+ unsigned int ai_add_back; /* how many channels we must add before scan to satisfy DMA? */
+ unsigned int *ai_chanlist; /* actaul chanlist */
unsigned int ai_timer1;
unsigned int ai_timer2;
unsigned int ai_flags;
- char ai12_startstop; // measure can start/stop on external trigger
- unsigned int ai_divisor1, ai_divisor2; // divisors for start of measure on external start
+ char ai12_startstop; /* measure can start/stop on external trigger */
+ unsigned int ai_divisor1, ai_divisor2; /* divisors for start of measure on external start */
unsigned int ai_data_len;
short *ai_data;
- short ao_data[2]; // data output buffer
- unsigned int ai_scans; // number of scans to do
- char dma_doublebuf; // we can use double buffring
- unsigned int dma_actbuf; // which buffer is used now
- short *dmabuf_virt[2]; // pointers to begin of DMA buffer
- unsigned long dmabuf_hw[2]; // hw address of DMA buff
- unsigned int dmabuf_size[2]; // size of dma buffer in bytes
- unsigned int dmabuf_use_size[2]; // which size we may now used for transfer
- unsigned int dmabuf_used_size[2]; // which size was trully used
+ short ao_data[2]; /* data output buffer */
+ unsigned int ai_scans; /* number of scans to do */
+ char dma_doublebuf; /* we can use double buffring */
+ unsigned int dma_actbuf; /* which buffer is used now */
+ short *dmabuf_virt[2]; /* pointers to begin of DMA buffer */
+ unsigned long dmabuf_hw[2]; /* hw address of DMA buff */
+ unsigned int dmabuf_size[2]; /* size of dma buffer in bytes */
+ unsigned int dmabuf_use_size[2]; /* which size we may now used for transfer */
+ unsigned int dmabuf_used_size[2]; /* which size was trully used */
unsigned int dmabuf_panic_size[2];
- unsigned int dmabuf_samples[2]; // size in samples
- int dmabuf_pages[2]; // number of pages in buffer
- unsigned char cnt0_users; // bit field of 8254 CNT0 users (0-unused, 1-AO, 2-DI, 3-DO)
- unsigned char exttrg_users; // bit field of external trigger users (0-AI, 1-AO, 2-DI, 3-DO)
- unsigned int cnt0_divisor; // actual CNT0 divisor
- void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); // ptr to actual interrupt AI function
- unsigned char ai16bits; // =1 16 bit card
- unsigned char usedma; // =1 use DMA transfer and not INT
- unsigned char useeoshandle; // =1 change WAKE_EOS DMA transfer to fit on every second
- unsigned char usessh; // =1 turn on S&H support
- int softsshdelay; // >0 use software S&H, numer is requested delay in ns
- unsigned char softsshsample; // polarity of S&H signal in sample state
- unsigned char softsshhold; // polarity of S&H signal in hold state
- unsigned int ai_maskerr; // which warning was printed
- unsigned int ai_maskharderr; // on which error bits stops
- unsigned int ai_inttrig_start; // TRIG_INT for start
+ unsigned int dmabuf_samples[2]; /* size in samples */
+ int dmabuf_pages[2]; /* number of pages in buffer */
+ unsigned char cnt0_users; /* bit field of 8254 CNT0 users (0-unused, 1-AO, 2-DI, 3-DO) */
+ unsigned char exttrg_users; /* bit field of external trigger users (0-AI, 1-AO, 2-DI, 3-DO) */
+ unsigned int cnt0_divisor; /* actual CNT0 divisor */
+ void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); /* ptr to actual interrupt AI function */
+ unsigned char ai16bits; /* =1 16 bit card */
+ unsigned char usedma; /* =1 use DMA transfer and not INT */
+ unsigned char useeoshandle; /* =1 change WAKE_EOS DMA transfer to fit on every second */
+ unsigned char usessh; /* =1 turn on S&H support */
+ int softsshdelay; /* >0 use software S&H, numer is requested delay in ns */
+ unsigned char softsshsample; /* polarity of S&H signal in sample state */
+ unsigned char softsshhold; /* polarity of S&H signal in hold state */
+ unsigned int ai_maskerr; /* which warning was printed */
+ unsigned int ai_maskharderr; /* on which error bits stops */
+ unsigned int ai_inttrig_start; /* TRIG_INT for start */
};
#define devpriv ((struct pci9118_private *)dev->private)
@@ -308,53 +309,53 @@ struct pci9118_private {
==============================================================================
*/
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, int frontadd, int backadd);
-static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, int rot, int frontadd, int backadd,
int usedma, char eoshandle);
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2);
-static int pci9118_reset(struct comedi_device * dev);
-static int pci9118_exttrg_add(struct comedi_device * dev, unsigned char source);
-static int pci9118_exttrg_del(struct comedi_device * dev, unsigned char source);
-static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void pci9118_calc_divisors(char mode, struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned int *tim1, unsigned int *tim2,
+static int pci9118_reset(struct comedi_device *dev);
+static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source);
+static int pci9118_exttrg_del(struct comedi_device *dev, unsigned char source);
+static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void pci9118_calc_divisors(char mode, struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int *tim1, unsigned int *tim2,
unsigned int flags, int chans, unsigned int *div1, unsigned int *div2,
char usessh, unsigned int chnsshfront);
/*
==============================================================================
*/
-static int pci9118_insn_read_ai(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, timeout;
devpriv->AdControlReg = AdControl_Int & 0xff;
devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg;
- outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop
+ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */
if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0, 0))
return -EINVAL;
- outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO
+ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
for (n = 0; n < insn->n; n++) {
outw(0, dev->iobase + PCI9118_SOFTTRG); /* start conversion */
- comedi_udelay(2);
+ udelay(2);
timeout = 100;
while (timeout--) {
if (inl(dev->iobase + PCI9118_ADSTAT) & AdStatus_ADrdy)
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
comedi_error(dev, "A/D insn timeout");
data[n] = 0;
- outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO
+ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
return -ETIME;
conv_finish:
@@ -369,7 +370,7 @@ static int pci9118_insn_read_ai(struct comedi_device * dev, struct comedi_subdev
}
}
- outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO
+ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
return n;
}
@@ -377,8 +378,8 @@ static int pci9118_insn_read_ai(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci9118_insn_write_ao(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci9118_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chanreg, ch;
@@ -400,8 +401,8 @@ static int pci9118_insn_write_ao(struct comedi_device * dev, struct comedi_subde
/*
==============================================================================
*/
-static int pci9118_insn_read_ao(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci9118_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan;
@@ -415,8 +416,8 @@ static int pci9118_insn_read_ao(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci9118_insn_bits_di(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci9118_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[1] = inl(dev->iobase + PCI9118_DI) & 0xf;
@@ -426,8 +427,8 @@ static int pci9118_insn_bits_di(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci9118_insn_bits_do(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci9118_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -442,7 +443,7 @@ static int pci9118_insn_bits_do(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static void interrupt_pci9118_ai_mode4_switch(struct comedi_device * dev)
+static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev)
{
devpriv->AdFunctionReg =
AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM;
@@ -456,8 +457,8 @@ static void interrupt_pci9118_ai_mode4_switch(struct comedi_device * dev)
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
}
-static unsigned int defragment_dma_buffer(struct comedi_device * dev,
- struct comedi_subdevice * s, short * dma_buffer, unsigned int num_samples)
+static unsigned int defragment_dma_buffer(struct comedi_device *dev,
+ struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples)
{
unsigned int i = 0, j = 0;
unsigned int start_pos = devpriv->ai_add_front,
@@ -480,8 +481,8 @@ static unsigned int defragment_dma_buffer(struct comedi_device * dev,
/*
==============================================================================
*/
-static unsigned int move_block_from_dma(struct comedi_device * dev,
- struct comedi_subdevice * s, short * dma_buffer, unsigned int num_samples)
+static unsigned int move_block_from_dma(struct comedi_device *dev,
+ struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples)
{
unsigned int num_bytes;
@@ -501,8 +502,8 @@ static unsigned int move_block_from_dma(struct comedi_device * dev,
/*
==============================================================================
*/
-static char pci9118_decode_error_status(struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned char m)
+static char pci9118_decode_error_status(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned char m)
{
if (m & 0x100) {
comedi_error(dev, "A/D FIFO Full status (Fatal Error!)");
@@ -531,7 +532,7 @@ static char pci9118_decode_error_status(struct comedi_device * dev,
return 0;
}
-static void pci9118_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static void pci9118_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *data, unsigned int num_bytes, unsigned int start_chan_index)
{
unsigned int i, num_samples = num_bytes / sizeof(short);
@@ -551,8 +552,8 @@ static void pci9118_ai_munge(struct comedi_device * dev, struct comedi_subdevice
/*
==============================================================================
*/
-static void interrupt_pci9118_ai_onesample(struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned short int_adstat, unsigned int int_amcc,
+static void interrupt_pci9118_ai_onesample(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned short int_adstat, unsigned int int_amcc,
unsigned short int_daq)
{
register short sampl;
@@ -567,8 +568,8 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device * dev,
#ifdef PCI9118_PARANOIDCHECK
if (devpriv->ai16bits == 0) {
- if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { // data dropout!
- rt_printk
+ if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { /* data dropout! */
+ printk
("comedi: A/D SAMPL - data dropout: received channel %d, expected %d!\n",
sampl & 0x000f,
devpriv->chanlist[s->async->cur_chan]);
@@ -598,7 +599,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device * dev,
/*
==============================================================================
*/
-static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_subdevice * s,
+static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned short int_adstat, unsigned int int_amcc,
unsigned short int_daq)
{
@@ -621,14 +622,14 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s
}
if (int_adstat & devpriv->ai_maskerr)
-// if (int_adstat & 0x106)
+/* if (int_adstat & 0x106) */
if (pci9118_decode_error_status(dev, s, int_adstat))
return;
- samplesinbuf = devpriv->dmabuf_use_size[devpriv->dma_actbuf] >> 1; // number of received real samples
-// DPRINTK("dma_actbuf=%d\n",devpriv->dma_actbuf);
+ samplesinbuf = devpriv->dmabuf_use_size[devpriv->dma_actbuf] >> 1; /* number of received real samples */
+/* DPRINTK("dma_actbuf=%d\n",devpriv->dma_actbuf); */
- if (devpriv->dma_doublebuf) { // switch DMA buffers if is used double buffering
+ if (devpriv->dma_doublebuf) { /* switch DMA buffers if is used double buffering */
next_dma_buf = 1 - devpriv->dma_actbuf;
outl(devpriv->dmabuf_hw[next_dma_buf],
devpriv->iobase_a + AMCC_OP_REG_MWAR);
@@ -641,15 +642,15 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s
}
if (samplesinbuf) {
- m = devpriv->ai_data_len >> 1; // how many samples is to end of buffer
-// DPRINTK("samps=%d m=%d %d %d\n",samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr);
+ m = devpriv->ai_data_len >> 1; /* how many samples is to end of buffer */
+/* DPRINTK("samps=%d m=%d %d %d\n",samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr); */
sampls = m;
move_block_from_dma(dev, s,
devpriv->dmabuf_virt[devpriv->dma_actbuf],
samplesinbuf);
- m = m - sampls; // m= how many samples was transfered
+ m = m - sampls; /* m= how many samples was transfered */
}
-// DPRINTK("YYY\n");
+/* DPRINTK("YYY\n"); */
if (!devpriv->ai_neverending)
if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */
@@ -657,9 +658,9 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s
s->async->events |= COMEDI_CB_EOA;
}
- if (devpriv->dma_doublebuf) { // switch dma buffers
+ if (devpriv->dma_doublebuf) { /* switch dma buffers */
devpriv->dma_actbuf = 1 - devpriv->dma_actbuf;
- } else { // restart DMA if is not used double buffering
+ } else { /* restart DMA if is not used double buffering */
outl(devpriv->dmabuf_hw[0],
devpriv->iobase_a + AMCC_OP_REG_MWAR);
outl(devpriv->dmabuf_use_size[0],
@@ -674,36 +675,36 @@ static void interrupt_pci9118_ai_dma(struct comedi_device * dev, struct comedi_s
/*
==============================================================================
*/
-static irqreturn_t interrupt_pci9118(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pci9118(int irq, void *d)
{
struct comedi_device *dev = d;
unsigned int int_daq = 0, int_amcc, int_adstat;
if (!dev->attached)
- return IRQ_NONE; // not fully initialized
+ return IRQ_NONE; /* not fully initialized */
- int_daq = inl(dev->iobase + PCI9118_INTSRC) & 0xf; // get IRQ reasons from card
- int_amcc = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); // get INT register from AMCC chip
+ int_daq = inl(dev->iobase + PCI9118_INTSRC) & 0xf; /* get IRQ reasons from card */
+ int_amcc = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* get INT register from AMCC chip */
-// DPRINTK("INT daq=0x%01x amcc=0x%08x MWAR=0x%08x MWTC=0x%08x ADSTAT=0x%02x ai_do=%d\n", int_daq, int_amcc, inl(devpriv->iobase_a+AMCC_OP_REG_MWAR), inl(devpriv->iobase_a+AMCC_OP_REG_MWTC), inw(dev->iobase+PCI9118_ADSTAT)&0x1ff,devpriv->ai_do);
+/* DPRINTK("INT daq=0x%01x amcc=0x%08x MWAR=0x%08x MWTC=0x%08x ADSTAT=0x%02x ai_do=%d\n", int_daq, int_amcc, inl(devpriv->iobase_a+AMCC_OP_REG_MWAR), inl(devpriv->iobase_a+AMCC_OP_REG_MWTC), inw(dev->iobase+PCI9118_ADSTAT)&0x1ff,devpriv->ai_do); */
if ((!int_daq) && (!(int_amcc & ANY_S593X_INT)))
- return IRQ_NONE; // interrupt from other source
+ return IRQ_NONE; /* interrupt from other source */
- outl(int_amcc | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // shutdown IRQ reasons in AMCC
+ outl(int_amcc | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */
- int_adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; // get STATUS register
+ int_adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; /* get STATUS register */
if (devpriv->ai_do) {
if (devpriv->ai12_startstop)
- if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { // start stop of measure
+ if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { /* start stop of measure */
if (devpriv->ai12_startstop & START_AI_EXT) {
devpriv->ai12_startstop &=
~START_AI_EXT;
if (!(devpriv->ai12_startstop &
STOP_AI_EXT))
- pci9118_exttrg_del(dev, EXTTRG_AI); // deactivate EXT trigger
- start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, devpriv->ai_divisor2); // start pacer
+ pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */
+ start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, devpriv->ai_divisor2); /* start pacer */
outl(devpriv->AdControlReg,
dev->iobase + PCI9118_ADCNTRL);
} else {
@@ -711,8 +712,8 @@ static irqreturn_t interrupt_pci9118(int irq, void *d PT_REGS_ARG)
ai12_startstop & STOP_AI_EXT) {
devpriv->ai12_startstop &=
~STOP_AI_EXT;
- pci9118_exttrg_del(dev, EXTTRG_AI); // deactivate EXT trigger
- devpriv->ai_neverending = 0; //well, on next interrupt from DMA/EOC measure will stop
+ pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */
+ devpriv->ai_neverending = 0; /* well, on next interrupt from DMA/EOC measure will stop */
}
}
}
@@ -727,7 +728,7 @@ static irqreturn_t interrupt_pci9118(int irq, void *d PT_REGS_ARG)
/*
==============================================================================
*/
-static int pci9118_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
if (trignum != devpriv->ai_inttrig_start)
@@ -751,8 +752,8 @@ static int pci9118_ai_inttrig(struct comedi_device * dev, struct comedi_subdevic
/*
==============================================================================
*/
-static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
@@ -949,11 +950,11 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
-// rt_printk("S1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg);
+/* printk("S1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
&divisor2, &cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
-// rt_printk("S2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg);
+/* printk("S2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
if (cmd->scan_begin_arg < this_board->ai_ns_min)
cmd->scan_begin_arg = this_board->ai_ns_min;
if (tmp != cmd->scan_begin_arg)
@@ -965,7 +966,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
-// rt_printk("s1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg);
+/* printk("s1 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
if (tmp != cmd->convert_arg)
@@ -979,7 +980,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
cmd->scan_begin_arg =
this_board->ai_ns_min *
(cmd->scan_end_arg + 2);
-// rt_printk("s2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg);
+/* printk("s2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
err++;
}
} else {
@@ -988,7 +989,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
cmd->scan_begin_arg =
cmd->convert_arg *
cmd->chanlist_len;
-// rt_printk("s3 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg);
+/* printk("s3 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
err++;
}
}
@@ -1001,7 +1002,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
if (cmd->chanlist)
if (!check_channel_list(dev, s, cmd->chanlist_len,
cmd->chanlist, 0, 0))
- return 5; // incorrect channels list
+ return 5; /* incorrect channels list */
return 0;
}
@@ -1009,7 +1010,7 @@ static int pci9118_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
/*
==============================================================================
*/
-static int Compute_and_setup_dma(struct comedi_device * dev)
+static int Compute_and_setup_dma(struct comedi_device *dev)
{
unsigned int dmalen0, dmalen1, i;
@@ -1018,32 +1019,32 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
dmalen1 = devpriv->dmabuf_size[1];
DPRINTK("1 dmalen0=%d dmalen1=%d ai_data_len=%d\n", dmalen0, dmalen1,
devpriv->ai_data_len);
- // isn't output buff smaller that our DMA buff?
+ /* isn't output buff smaller that our DMA buff? */
if (dmalen0 > (devpriv->ai_data_len)) {
- dmalen0 = devpriv->ai_data_len & ~3L; // allign to 32bit down
+ dmalen0 = devpriv->ai_data_len & ~3L; /* allign to 32bit down */
}
if (dmalen1 > (devpriv->ai_data_len)) {
- dmalen1 = devpriv->ai_data_len & ~3L; // allign to 32bit down
+ dmalen1 = devpriv->ai_data_len & ~3L; /* allign to 32bit down */
}
DPRINTK("2 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1);
- // we want wake up every scan?
+ /* we want wake up every scan? */
if (devpriv->ai_flags & TRIG_WAKE_EOS) {
if (dmalen0 < (devpriv->ai_n_realscanlen << 1)) {
- // uff, too short DMA buffer, disable EOS support!
+ /* uff, too short DMA buffer, disable EOS support! */
devpriv->ai_flags &= (~TRIG_WAKE_EOS);
- rt_printk
+ printk
("comedi%d: WAR: DMA0 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n",
dev->minor, dmalen0,
devpriv->ai_n_realscanlen << 1);
} else {
- // short first DMA buffer to one scan
+ /* short first DMA buffer to one scan */
dmalen0 = devpriv->ai_n_realscanlen << 1;
DPRINTK("21 dmalen0=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen0, devpriv->ai_n_realscanlen, devpriv->useeoshandle);
if (devpriv->useeoshandle)
dmalen0 += 2;
if (dmalen0 < 4) {
- rt_printk
+ printk
("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n",
dev->minor, dmalen0);
dmalen0 = 4;
@@ -1052,20 +1053,20 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
}
if (devpriv->ai_flags & TRIG_WAKE_EOS) {
if (dmalen1 < (devpriv->ai_n_realscanlen << 1)) {
- // uff, too short DMA buffer, disable EOS support!
+ /* uff, too short DMA buffer, disable EOS support! */
devpriv->ai_flags &= (~TRIG_WAKE_EOS);
- rt_printk
+ printk
("comedi%d: WAR: DMA1 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n",
dev->minor, dmalen1,
devpriv->ai_n_realscanlen << 1);
} else {
- // short second DMA buffer to one scan
+ /* short second DMA buffer to one scan */
dmalen1 = devpriv->ai_n_realscanlen << 1;
DPRINTK("22 dmalen1=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen1, devpriv->ai_n_realscanlen, devpriv->useeoshandle);
if (devpriv->useeoshandle)
dmalen1 -= 2;
if (dmalen1 < 4) {
- rt_printk
+ printk
("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n",
dev->minor, dmalen1);
dmalen1 = 4;
@@ -1074,26 +1075,26 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
}
DPRINTK("3 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1);
- // transfer without TRIG_WAKE_EOS
+ /* transfer without TRIG_WAKE_EOS */
if (!(devpriv->ai_flags & TRIG_WAKE_EOS)) {
- // if it's possible then allign DMA buffers to length of scan
+ /* if it's possible then allign DMA buffers to length of scan */
i = dmalen0;
dmalen0 =
(dmalen0 / (devpriv->ai_n_realscanlen << 1)) *
(devpriv->ai_n_realscanlen << 1);
dmalen0 &= ~3L;
if (!dmalen0)
- dmalen0 = i; // uff. very long scan?
+ dmalen0 = i; /* uff. very long scan? */
i = dmalen1;
dmalen1 =
(dmalen1 / (devpriv->ai_n_realscanlen << 1)) *
(devpriv->ai_n_realscanlen << 1);
dmalen1 &= ~3L;
if (!dmalen1)
- dmalen1 = i; // uff. very long scan?
- // if measure isn't neverending then test, if it whole fits into one or two DMA buffers
+ dmalen1 = i; /* uff. very long scan? */
+ /* if measure isn't neverending then test, if it whole fits into one or two DMA buffers */
if (!devpriv->ai_neverending) {
- // fits whole measure into one DMA buffer?
+ /* fits whole measure into one DMA buffer? */
if (dmalen0 >
((devpriv->ai_n_realscanlen << 1) *
devpriv->ai_scans)) {
@@ -1104,7 +1105,7 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
DPRINTK("3.1 dmalen0=%d dmalen1=%d \n", dmalen0,
dmalen1);
dmalen0 &= ~3L;
- } else { // fits whole measure into two DMA buffer?
+ } else { /* fits whole measure into two DMA buffer? */
if (dmalen1 >
((devpriv->ai_n_realscanlen << 1) *
devpriv->ai_scans - dmalen0))
@@ -1121,7 +1122,7 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
DPRINTK("4 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1);
- // these DMA buffer size we'll be used
+ /* these DMA buffer size we'll be used */
devpriv->dma_actbuf = 0;
devpriv->dmabuf_use_size[0] = dmalen0;
devpriv->dmabuf_use_size[1] = dmalen1;
@@ -1143,18 +1144,18 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
}
#endif
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); // stop DMA
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */
outl(devpriv->dmabuf_hw[0], devpriv->iobase_a + AMCC_OP_REG_MWAR);
outl(devpriv->dmabuf_use_size[0], devpriv->iobase_a + AMCC_OP_REG_MWTC);
- // init DMA transfer
+ /* init DMA transfer */
outl(0x00000000 | AINT_WRITE_COMPL,
devpriv->iobase_a + AMCC_OP_REG_INTCSR);
-// outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR);
+/* outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR); */
outl(inl(devpriv->iobase_a +
AMCC_OP_REG_MCSR) | RESET_A2P_FLAGS | A2P_HI_PRIORITY |
EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_MCSR);
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow bus mastering
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow bus mastering */
DPRINTK("adl_pci9118 EDBG: END: Compute_and_setup_dma()\n");
return 0;
@@ -1163,7 +1164,7 @@ static int Compute_and_setup_dma(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci9118_ai_docmd_sampl(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci9118_ai_docmd_sampl(struct comedi_device *dev, struct comedi_subdevice *s)
{
DPRINTK("adl_pci9118 EDBG: BGN: pci9118_ai_docmd_sampl(%d,) [%d]\n",
dev->minor, devpriv->ai_do);
@@ -1186,17 +1187,17 @@ static int pci9118_ai_docmd_sampl(struct comedi_device * dev, struct comedi_subd
return -EIO;
};
- devpriv->int_ai_func = interrupt_pci9118_ai_onesample; //transfer function
+ devpriv->int_ai_func = interrupt_pci9118_ai_onesample; /* transfer function */
if (devpriv->ai12_startstop)
- pci9118_exttrg_add(dev, EXTTRG_AI); // activate EXT trigger
+ pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */
if ((devpriv->ai_do == 1) || (devpriv->ai_do == 2))
devpriv->IntControlReg |= Int_Timer;
devpriv->AdControlReg |= AdControl_Int;
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow INT in AMCC
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */
if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) {
outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL);
@@ -1216,7 +1217,7 @@ static int pci9118_ai_docmd_sampl(struct comedi_device * dev, struct comedi_subd
/*
==============================================================================
*/
-static int pci9118_ai_docmd_dma(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci9118_ai_docmd_dma(struct comedi_device *dev, struct comedi_subdevice *s)
{
DPRINTK("adl_pci9118 EDBG: BGN: pci9118_ai_docmd_dma(%d,) [%d,%d]\n",
dev->minor, devpriv->ai_do, devpriv->usedma);
@@ -1261,10 +1262,10 @@ static int pci9118_ai_docmd_dma(struct comedi_device * dev, struct comedi_subdev
};
if (devpriv->ai12_startstop) {
- pci9118_exttrg_add(dev, EXTTRG_AI); // activate EXT trigger
+ pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */
}
- devpriv->int_ai_func = interrupt_pci9118_ai_dma; //transfer function
+ devpriv->int_ai_func = interrupt_pci9118_ai_dma; /* transfer function */
outl(0x02000000 | AINT_WRITE_COMPL,
devpriv->iobase_a + AMCC_OP_REG_INTCSR);
@@ -1287,7 +1288,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int addchans = 0;
@@ -1307,7 +1308,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_add_back = 0;
devpriv->ai_maskerr = 0x10e;
- // prepare for start/stop conditions
+ /* prepare for start/stop conditions */
if (cmd->start_src == TRIG_EXT)
devpriv->ai12_startstop |= START_AI_EXT;
if (cmd->stop_src == TRIG_EXT) {
@@ -1334,19 +1335,19 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_scans = 0;
}
- // use sample&hold signal?
+ /* use sample&hold signal? */
if (cmd->convert_src == TRIG_NOW) {
devpriv->usessh = 1;
- } // yes
+ } /* yes */
else {
devpriv->usessh = 0;
- } // no
+ } /* no */
DPRINTK("1 neverending=%d scans=%u usessh=%d ai_startstop=0x%2x\n",
devpriv->ai_neverending, devpriv->ai_scans, devpriv->usessh,
devpriv->ai12_startstop);
- // use additional sample at end of every scan to satisty DMA 32 bit transfer?
+ /* use additional sample at end of every scan to satisty DMA 32 bit transfer? */
devpriv->ai_add_front = 0;
devpriv->ai_add_back = 0;
devpriv->useeoshandle = 0;
@@ -1358,27 +1359,27 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_add_back = 1;
}
if (cmd->convert_src == TRIG_TIMER) {
- devpriv->usedma = 0; // use INT transfer if scanlist have only one channel
+ devpriv->usedma = 0; /* use INT transfer if scanlist have only one channel */
}
}
if ((cmd->flags & TRIG_WAKE_EOS) &&
(devpriv->ai_n_scanlen & 1) &&
(devpriv->ai_n_scanlen > 1)) {
if (cmd->scan_begin_src == TRIG_FOLLOW) {
- //vpriv->useeoshandle=1; // change DMA transfer block to fit EOS on every second call
- devpriv->usedma = 0; // XXX maybe can be corrected to use 16 bit DMA
- } else { // well, we must insert one sample to end of EOS to meet 32 bit transfer
+ /* vpriv->useeoshandle=1; // change DMA transfer block to fit EOS on every second call */
+ devpriv->usedma = 0; /* XXX maybe can be corrected to use 16 bit DMA */
+ } else { /* well, we must insert one sample to end of EOS to meet 32 bit transfer */
devpriv->ai_add_back = 1;
}
}
- } else { // interrupt transfer don't need any correction
+ } else { /* interrupt transfer don't need any correction */
devpriv->usedma = 0;
}
- // we need software S&H signal? It add two samples before every scan as minimum
+ /* we need software S&H signal? It add two samples before every scan as minimum */
if (devpriv->usessh && devpriv->softsshdelay) {
devpriv->ai_add_front = 2;
- if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { // move it to front
+ if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { /* move it to front */
devpriv->ai_add_front++;
devpriv->ai_add_back = 0;
}
@@ -1387,17 +1388,17 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
addchans = devpriv->softsshdelay / cmd->convert_arg;
if (devpriv->softsshdelay % cmd->convert_arg)
addchans++;
- if (addchans > (devpriv->ai_add_front - 1)) { // uff, still short :-(
+ if (addchans > (devpriv->ai_add_front - 1)) { /* uff, still short :-( */
devpriv->ai_add_front = addchans + 1;
if (devpriv->usedma == 1)
if ((devpriv->ai_add_front +
devpriv->ai_n_chan +
devpriv->ai_add_back) & 1)
- devpriv->ai_add_front++; // round up to 32 bit
+ devpriv->ai_add_front++; /* round up to 32 bit */
}
- } // well, we now know what must be all added
+ } /* well, we now know what must be all added */
- devpriv->ai_n_realscanlen = // what we must take from card in real to have ai_n_scanlen on output?
+ devpriv->ai_n_realscanlen = /* what we must take from card in real to have ai_n_scanlen on output? */
(devpriv->ai_add_front + devpriv->ai_n_chan +
devpriv->ai_add_back) * (devpriv->ai_n_scanlen /
devpriv->ai_n_chan);
@@ -1408,7 +1409,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_n_chan, devpriv->ai_add_back,
devpriv->ai_n_scanlen);
- // check and setup channel list
+ /* check and setup channel list */
if (!check_channel_list(dev, s, devpriv->ai_n_chan,
devpriv->ai_chanlist, devpriv->ai_add_front,
devpriv->ai_add_back))
@@ -1419,9 +1420,9 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->useeoshandle))
return -EINVAL;
- // compute timers settings
- // simplest way, fr=4Mhz/(tim1*tim2), channel manipulation without timers effect
- if (((cmd->scan_begin_src == TRIG_FOLLOW) || (cmd->scan_begin_src == TRIG_EXT) || (cmd->scan_begin_src == TRIG_INT)) && (cmd->convert_src == TRIG_TIMER)) { // both timer is used for one time
+ /* compute timers settings */
+ /* simplest way, fr=4Mhz/(tim1*tim2), channel manipulation without timers effect */
+ if (((cmd->scan_begin_src == TRIG_FOLLOW) || (cmd->scan_begin_src == TRIG_EXT) || (cmd->scan_begin_src == TRIG_INT)) && (cmd->convert_src == TRIG_TIMER)) { /* both timer is used for one time */
if (cmd->scan_begin_src == TRIG_EXT) {
devpriv->ai_do = 4;
} else {
@@ -1435,7 +1436,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_timer2 = cmd->convert_arg;
}
- if ((cmd->scan_begin_src == TRIG_TIMER) && ((cmd->convert_src == TRIG_TIMER) || (cmd->convert_src == TRIG_NOW))) { // double timed action
+ if ((cmd->scan_begin_src == TRIG_TIMER) && ((cmd->convert_src == TRIG_TIMER) || (cmd->convert_src == TRIG_NOW))) { /* double timed action */
if (!devpriv->usedma) {
comedi_error(dev,
"cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!");
@@ -1457,15 +1458,15 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_do = 3;
}
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
- devpriv->AdControlReg = 0; // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable DMA
+ devpriv->AdControlReg = 0; /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable DMA */
outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL);
- devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop
+ devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
- comedi_udelay(1);
- outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO
- inl(dev->iobase + PCI9118_ADSTAT); // flush A/D and INT status register
+ udelay(1);
+ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
+ inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D and INT status register */
inl(dev->iobase + PCI9118_INTSRC);
devpriv->ai_act_scan = 0;
@@ -1473,11 +1474,10 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
s->async->cur_chan = 0;
devpriv->ai_buf_ptr = 0;
- if (devpriv->usedma) {
+ if (devpriv->usedma)
ret = pci9118_ai_docmd_dma(dev, s);
- } else {
+ else
ret = pci9118_ai_docmd_sampl(dev, s);
- }
DPRINTK("adl_pci9118 EDBG: END: pci9118_ai_cmd()\n");
return ret;
@@ -1486,7 +1486,7 @@ static int pci9118_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
/*
==============================================================================
*/
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, int frontadd, int backadd)
{
unsigned int i, differencial = 0, bipolar = 0;
@@ -1497,7 +1497,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
return 0;
}
if ((frontadd + n_chan + backadd) > s->len_chanlist) {
- rt_printk
+ printk
("comedi%d: range/channel list is too long for actual configuration (%d>%d)!",
dev->minor, n_chan,
s->len_chanlist - frontadd - backadd);
@@ -1505,11 +1505,11 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
}
if (CR_AREF(chanlist[0]) == AREF_DIFF)
- differencial = 1; // all input must be diff
+ differencial = 1; /* all input must be diff */
if (CR_RANGE(chanlist[0]) < PCI9118_BIPOLAR_RANGES)
- bipolar = 1; // all input must be bipolar
+ bipolar = 1; /* all input must be bipolar */
if (n_chan > 1)
- for (i = 1; i < n_chan; i++) { // check S.E/diff
+ for (i = 1; i < n_chan; i++) { /* check S.E/diff */
if ((CR_AREF(chanlist[i]) == AREF_DIFF) !=
(differencial)) {
comedi_error(dev,
@@ -1537,7 +1537,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
/*
==============================================================================
*/
-static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, int rot, int frontadd, int backadd,
int usedma, char useeos)
{
@@ -1552,27 +1552,27 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic
}
if (CR_AREF(chanlist[0]) == AREF_DIFF)
- differencial = 1; // all input must be diff
+ differencial = 1; /* all input must be diff */
if (CR_RANGE(chanlist[0]) < PCI9118_BIPOLAR_RANGES)
- bipolar = 1; // all input must be bipolar
+ bipolar = 1; /* all input must be bipolar */
- // All is ok, so we can setup channel/range list
+ /* All is ok, so we can setup channel/range list */
if (!bipolar) {
- devpriv->AdControlReg |= AdControl_UniP; // set unibipolar
+ devpriv->AdControlReg |= AdControl_UniP; /* set unibipolar */
} else {
- devpriv->AdControlReg &= ((~AdControl_UniP) & 0xff); // enable bipolar
+ devpriv->AdControlReg &= ((~AdControl_UniP) & 0xff); /* enable bipolar */
}
if (differencial) {
- devpriv->AdControlReg |= AdControl_Diff; // enable diff inputs
+ devpriv->AdControlReg |= AdControl_Diff; /* enable diff inputs */
} else {
- devpriv->AdControlReg &= ((~AdControl_Diff) & 0xff); // set single ended inputs
+ devpriv->AdControlReg &= ((~AdControl_Diff) & 0xff); /* set single ended inputs */
}
- outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // setup mode
+ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* setup mode */
- outl(2, dev->iobase + PCI9118_SCANMOD); // gods know why this sequence!
+ outl(2, dev->iobase + PCI9118_SCANMOD); /* gods know why this sequence! */
outl(0, dev->iobase + PCI9118_SCANMOD);
outl(1, dev->iobase + PCI9118_SCANMOD);
@@ -1582,12 +1582,12 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic
devpriv->chanlist[i] = 0x55aa;
#endif
- if (frontadd) { // insert channels for S&H
+ if (frontadd) { /* insert channels for S&H */
ssh = devpriv->softsshsample;
DPRINTK("FA: %04x: ", ssh);
- for (i = 0; i < frontadd; i++) { // store range list to card
- scanquad = CR_CHAN(chanlist[0]); // get channel number;
- gain = CR_RANGE(chanlist[0]); // get gain number
+ for (i = 0; i < frontadd; i++) { /* store range list to card */
+ scanquad = CR_CHAN(chanlist[0]); /* get channel number; */
+ gain = CR_RANGE(chanlist[0]); /* get gain number */
scanquad |= ((gain & 0x03) << 8);
outl(scanquad | ssh, dev->iobase + PCI9118_GAIN);
DPRINTK("%02x ", scanquad | ssh);
@@ -1597,23 +1597,23 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic
}
DPRINTK("SL: ", ssh);
- for (i = 0; i < n_chan; i++) { // store range list to card
- scanquad = CR_CHAN(chanlist[i]); // get channel number;
+ for (i = 0; i < n_chan; i++) { /* store range list to card */
+ scanquad = CR_CHAN(chanlist[i]); /* get channel number; */
#ifdef PCI9118_PARANOIDCHECK
devpriv->chanlist[i ^ usedma] = (scanquad & 0xf) << rot;
#endif
- gain = CR_RANGE(chanlist[i]); // get gain number
+ gain = CR_RANGE(chanlist[i]); /* get gain number */
scanquad |= ((gain & 0x03) << 8);
outl(scanquad | ssh, dev->iobase + PCI9118_GAIN);
DPRINTK("%02x ", scanquad | ssh);
}
DPRINTK("\n ");
- if (backadd) { // insert channels for fit onto 32bit DMA
+ if (backadd) { /* insert channels for fit onto 32bit DMA */
DPRINTK("BA: %04x: ", ssh);
- for (i = 0; i < backadd; i++) { // store range list to card
- scanquad = CR_CHAN(chanlist[0]); // get channel number;
- gain = CR_RANGE(chanlist[0]); // get gain number
+ for (i = 0; i < backadd; i++) { /* store range list to card */
+ scanquad = CR_CHAN(chanlist[0]); /* get channel number; */
+ gain = CR_RANGE(chanlist[0]); /* get gain number */
scanquad |= ((gain & 0x03) << 8);
outl(scanquad | ssh, dev->iobase + PCI9118_GAIN);
DPRINTK("%02x ", scanquad | ssh);
@@ -1621,13 +1621,13 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic
DPRINTK("\n ");
}
#ifdef PCI9118_PARANOIDCHECK
- devpriv->chanlist[n_chan ^ usedma] = devpriv->chanlist[0 ^ usedma]; // for 32bit oerations
+ devpriv->chanlist[n_chan ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */
if (useeos) {
- for (i = 1; i < n_chan; i++) { // store range list to card
+ for (i = 1; i < n_chan; i++) { /* store range list to card */
devpriv->chanlist[(n_chan + i) ^ usedma] =
(CR_CHAN(chanlist[i]) & 0xf) << rot;
}
- devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; // for 32bit oerations
+ devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */
useeos = 2;
} else {
useeos = 1;
@@ -1640,19 +1640,19 @@ static int setup_channel_list(struct comedi_device * dev, struct comedi_subdevic
DPRINTK("\n ");
#endif
#endif
- outl(0, dev->iobase + PCI9118_SCANMOD); // close scan queue
-// comedi_udelay(100); // important delay, or first sample will be cripled
+ outl(0, dev->iobase + PCI9118_SCANMOD); /* close scan queue */
+/* udelay(100); important delay, or first sample will be cripled */
DPRINTK("adl_pci9118 EDBG: END: setup_channel_list()\n");
- return 1; // we can serve this with scan logic
+ return 1; /* we can serve this with scan logic */
}
/*
==============================================================================
calculate 8254 divisors if they are used for dual timing
*/
-static void pci9118_calc_divisors(char mode, struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned int *tim1, unsigned int *tim2,
+static void pci9118_calc_divisors(char mode, struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int *tim1, unsigned int *tim2,
unsigned int flags, int chans, unsigned int *div1, unsigned int *div2,
char usessh, unsigned int chnsshfront)
{
@@ -1672,17 +1672,17 @@ static void pci9118_calc_divisors(char mode, struct comedi_device * dev,
*tim2 = this_board->ai_ns_min;
DPRINTK("1 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2,
*tim1, *tim2);
- *div1 = *tim2 / devpriv->i8254_osc_base; // convert timer (burst)
+ *div1 = *tim2 / devpriv->i8254_osc_base; /* convert timer (burst) */
DPRINTK("2 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2,
*tim1, *tim2);
if (*div1 < this_board->ai_pacer_min)
*div1 = this_board->ai_pacer_min;
DPRINTK("3 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2,
*tim1, *tim2);
- *div2 = *tim1 / devpriv->i8254_osc_base; // scan timer
+ *div2 = *tim1 / devpriv->i8254_osc_base; /* scan timer */
DPRINTK("4 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2,
*tim1, *tim2);
- *div2 = *div2 / *div1; // major timer is c1*c2
+ *div2 = *div2 / *div1; /* major timer is c1*c2 */
DPRINTK("5 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2,
*tim1, *tim2);
if (*div2 < chans)
@@ -1690,9 +1690,9 @@ static void pci9118_calc_divisors(char mode, struct comedi_device * dev,
DPRINTK("6 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2,
*tim1, *tim2);
- *tim2 = *div1 * devpriv->i8254_osc_base; // real convert timer
+ *tim2 = *div1 * devpriv->i8254_osc_base; /* real convert timer */
- if (usessh & (chnsshfront == 0)) // use BSSH signal
+ if (usessh & (chnsshfront == 0)) /* use BSSH signal */
if (*div2 < (chans + 2))
*div2 = chans + 2;
@@ -1710,13 +1710,13 @@ static void pci9118_calc_divisors(char mode, struct comedi_device * dev,
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2)
{
outl(0x74, dev->iobase + PCI9118_CNTCTRL);
outl(0xb4, dev->iobase + PCI9118_CNTCTRL);
-// outl(0x30, dev->iobase + PCI9118_CNTCTRL);
- comedi_udelay(1);
+/* outl(0x30, dev->iobase + PCI9118_CNTCTRL); */
+ udelay(1);
if ((mode == 1) || (mode == 2) || (mode == 4)) {
outl(divisor2 & 0xff, dev->iobase + PCI9118_CNT2);
@@ -1729,29 +1729,29 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis
/*
==============================================================================
*/
-static int pci9118_exttrg_add(struct comedi_device * dev, unsigned char source)
+static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source)
{
if (source > 3)
- return -1; // incorrect source
+ return -1; /* incorrect source */
devpriv->exttrg_users |= (1 << source);
devpriv->IntControlReg |= Int_DTrg;
outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL);
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow INT in AMCC
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */
return 0;
}
/*
==============================================================================
*/
-static int pci9118_exttrg_del(struct comedi_device * dev, unsigned char source)
+static int pci9118_exttrg_del(struct comedi_device *dev, unsigned char source)
{
if (source > 3)
- return -1; // incorrect source
+ return -1; /* incorrect source */
devpriv->exttrg_users &= ~(1 << source);
- if (!devpriv->exttrg_users) { // shutdown ext trg intterrupts
+ if (!devpriv->exttrg_users) { /* shutdown ext trg intterrupts */
devpriv->IntControlReg &= ~Int_DTrg;
- if (!devpriv->IntControlReg) // all IRQ disabled
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) & (~0x00001f00), devpriv->iobase_a + AMCC_OP_REG_INTCSR); // disable int in AMCC
+ if (!devpriv->IntControlReg) /* all IRQ disabled */
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) & (~0x00001f00), devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* disable int in AMCC */
outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL);
}
return 0;
@@ -1760,20 +1760,20 @@ static int pci9118_exttrg_del(struct comedi_device * dev, unsigned char source)
/*
==============================================================================
*/
-static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (devpriv->usedma)
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); // stop DMA
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */
pci9118_exttrg_del(dev, EXTTRG_AI);
- start_pacer(dev, 0, 0, 0); // stop 8254 counters
+ start_pacer(dev, 0, 0, 0); /* stop 8254 counters */
devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg;
- outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop
+ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */
devpriv->AdControlReg = 0x00;
- outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA
+ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */
outl(0, dev->iobase + PCI9118_BURST);
outl(1, dev->iobase + PCI9118_SCANMOD);
- outl(2, dev->iobase + PCI9118_SCANMOD); // reset scan queue
- outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO
+ outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */
+ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
devpriv->ai_do = 0;
devpriv->usedma = 0;
@@ -1787,7 +1787,7 @@ static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
devpriv->dma_actbuf = 0;
if (!devpriv->IntControlReg)
- outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); // allow INT in AMCC
+ outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */
return 0;
}
@@ -1795,36 +1795,36 @@ static int pci9118_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
/*
==============================================================================
*/
-static int pci9118_reset(struct comedi_device * dev)
+static int pci9118_reset(struct comedi_device *dev)
{
devpriv->IntControlReg = 0;
devpriv->exttrg_users = 0;
inl(dev->iobase + PCI9118_INTCTRL);
- outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); // disable interrupts source
+ outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); /* disable interrupts source */
outl(0x30, dev->iobase + PCI9118_CNTCTRL);
-// outl(0xb4, dev->iobase + PCI9118_CNTCTRL);
- start_pacer(dev, 0, 0, 0); // stop 8254 counters
+/* outl(0xb4, dev->iobase + PCI9118_CNTCTRL); */
+ start_pacer(dev, 0, 0, 0); /* stop 8254 counters */
devpriv->AdControlReg = 0;
- outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA
+ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */
outl(0, dev->iobase + PCI9118_BURST);
outl(1, dev->iobase + PCI9118_SCANMOD);
- outl(2, dev->iobase + PCI9118_SCANMOD); // reset scan queue
+ outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */
devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg;
- outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); // positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop
+ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */
devpriv->ao_data[0] = 2047;
devpriv->ao_data[1] = 2047;
- outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1); // reset A/D outs to 0V
+ outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1); /* reset A/D outs to 0V */
outl(devpriv->ao_data[1], dev->iobase + PCI9118_DA2);
- outl(0, dev->iobase + PCI9118_DO); // reset digi outs to L
- comedi_udelay(10);
+ outl(0, dev->iobase + PCI9118_DO); /* reset digi outs to L */
+ udelay(10);
inl(dev->iobase + PCI9118_AD_DATA);
- outl(0, dev->iobase + PCI9118_DELFIFO); // flush FIFO
- outl(0, dev->iobase + PCI9118_INTSRC); // remove INT requests
- inl(dev->iobase + PCI9118_ADSTAT); // flush A/D status register
- inl(dev->iobase + PCI9118_INTSRC); // flush INT requests
+ outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
+ outl(0, dev->iobase + PCI9118_INTSRC); /* remove INT requests */
+ inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D status register */
+ inl(dev->iobase + PCI9118_INTSRC); /* flush INT requests */
devpriv->AdControlReg = 0;
- outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); // bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA
+ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */
devpriv->cnt0_users = 0;
devpriv->exttrg_users = 0;
@@ -1835,7 +1835,7 @@ static int pci9118_reset(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret, pages, i;
@@ -1848,19 +1848,20 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
unsigned char pci_bus, pci_slot, pci_func;
u16 u16w;
- rt_printk("comedi%d: adl_pci9118: board=%s", dev->minor,
+ printk("comedi%d: adl_pci9118: board=%s", dev->minor,
this_board->name);
opt_bus = it->options[0];
opt_slot = it->options[1];
if (it->options[3] & 1) {
- master = 0; // user don't want use bus master
+ master = 0; /* user don't want use bus master */
} else {
master = 1;
}
- if ((ret = alloc_private(dev, sizeof(struct pci9118_private))) < 0) {
- rt_printk(" - Allocation failed!\n");
+ ret = alloc_private(dev, sizeof(struct pci9118_private));
+ if (ret < 0) {
+ printk(" - Allocation failed!\n");
return -ENOMEM;
}
@@ -1889,10 +1890,10 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
if (!pcidev) {
if (opt_bus || opt_slot) {
- rt_printk(" - Card at b:s %d:%d %s\n",
+ printk(" - Card at b:s %d:%d %s\n",
opt_bus, opt_slot, errstr);
} else {
- rt_printk(" - Card %s\n", errstr);
+ printk(" - Card %s\n", errstr);
}
return -EIO;
}
@@ -1908,7 +1909,7 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
iobase_a = pci_resource_start(pcidev, 0);
iobase_9 = pci_resource_start(pcidev, 2);
- rt_printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot,
+ printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot,
pci_func, iobase_9, iobase_a);
dev->iobase = iobase_9;
@@ -1920,30 +1921,32 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
pci9118_reset(dev);
if (it->options[3] & 2)
- irq = 0; // user don't want use IRQ
+ irq = 0; /* user don't want use IRQ */
if (irq > 0) {
- if (comedi_request_irq(irq, interrupt_pci9118, IRQF_SHARED,
+ if (request_irq(irq, interrupt_pci9118, IRQF_SHARED,
"ADLink PCI-9118", dev)) {
- rt_printk(", unable to allocate IRQ %d, DISABLING IT",
+ printk(", unable to allocate IRQ %d, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%u", irq);
+ printk(", irq=%u", irq);
}
} else {
- rt_printk(", IRQ disabled");
+ printk(", IRQ disabled");
}
dev->irq = irq;
- if (master) { // alloc DMA buffers
+ if (master) { /* alloc DMA buffers */
devpriv->dma_doublebuf = 0;
for (i = 0; i < 2; i++) {
- for (pages = 4; pages >= 0; pages--)
- if ((devpriv->dmabuf_virt[i] = (short *)
- __get_free_pages(GFP_KERNEL,
- pages)))
+ for (pages = 4; pages >= 0; pages--) {
+ devpriv->dmabuf_virt[i] =
+ (short *) __get_free_pages(GFP_KERNEL,
+ pages);
+ if (devpriv->dmabuf_virt[i])
break;
+ }
if (devpriv->dmabuf_virt[i]) {
devpriv->dmabuf_pages[i] = pages;
devpriv->dmabuf_size[i] = PAGE_SIZE * pages;
@@ -1955,7 +1958,7 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
}
}
if (!devpriv->dmabuf_virt[0]) {
- rt_printk(", Can't allocate DMA buffer, DMA disabled!");
+ printk(", Can't allocate DMA buffer, DMA disabled!");
master = 0;
}
@@ -1964,26 +1967,26 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
}
- if ((devpriv->master = master)) {
- rt_printk(", bus master");
- } else {
- rt_printk(", no bus master");
- }
+ devpriv->master = master;
+ if (devpriv->master)
+ printk(", bus master");
+ else
+ printk(", no bus master");
devpriv->usemux = 0;
if (it->options[2] > 0) {
devpriv->usemux = it->options[2];
if (devpriv->usemux > 256)
- devpriv->usemux = 256; // max 256 channels!
+ devpriv->usemux = 256; /* max 256 channels! */
if (it->options[4] > 0)
if (devpriv->usemux > 128) {
- devpriv->usemux = 128; // max 128 channels with softare S&H!
+ devpriv->usemux = 128; /* max 128 channels with softare S&H! */
}
- rt_printk(", ext. mux %d channels", devpriv->usemux);
+ printk(", ext. mux %d channels", devpriv->usemux);
}
devpriv->softsshdelay = it->options[4];
- if (devpriv->softsshdelay < 0) { // select sample&hold signal polarity
+ if (devpriv->softsshdelay < 0) { /* select sample&hold signal polarity */
devpriv->softsshdelay = -devpriv->softsshdelay;
devpriv->softsshsample = 0x80;
devpriv->softsshhold = 0x00;
@@ -1992,12 +1995,13 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
devpriv->softsshhold = 0x80;
}
- rt_printk(".\n");
+ printk(".\n");
pci_read_config_word(devpriv->pcidev, PCI_COMMAND, &u16w);
- pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64); // Enable parity check for parity error
+ pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64); /* Enable parity check for parity error */
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -2052,9 +2056,9 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
s->insn_bits = pci9118_insn_bits_do;
devpriv->valid = 1;
- devpriv->i8254_osc_base = 250; // 250ns=4MHz
- devpriv->ai_maskharderr = 0x10a; // default measure crash condition
- if (it->options[5]) // disable some requested
+ devpriv->i8254_osc_base = 250; /* 250ns=4MHz */
+ devpriv->ai_maskharderr = 0x10a; /* default measure crash condition */
+ if (it->options[5]) /* disable some requested */
devpriv->ai_maskharderr &= ~it->options[5];
switch (this_board->ai_maxdata) {
@@ -2071,13 +2075,13 @@ static int pci9118_attach(struct comedi_device * dev, struct comedi_devconfig *
/*
==============================================================================
*/
-static int pci9118_detach(struct comedi_device * dev)
+static int pci9118_detach(struct comedi_device *dev)
{
if (dev->private) {
if (devpriv->valid)
pci9118_reset(dev);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv->pcidev) {
if (dev->iobase) {
comedi_pci_disable(devpriv->pcidev);
diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c
index 92f62854d6dc..d09d1493a8b7 100644
--- a/drivers/staging/comedi/drivers/adq12b.c
+++ b/drivers/staging/comedi/drivers/adq12b.c
@@ -81,7 +81,7 @@ If you do not specify any options, they will default to
#include "../comedidev.h"
-// address scheme (page 2.17 of the manual)
+/* address scheme (page 2.17 of the manual) */
#define ADQ12B_SIZE 16
#define ADQ12B_CTREG 0x00
@@ -94,24 +94,24 @@ If you do not specify any options, they will default to
#define ADQ12B_CONT2 0x0e
#define ADQ12B_COWORD 0x0f
-// mask of the bit at STINR to check end of conversion
+/* mask of the bit at STINR to check end of conversion */
#define ADQ12B_EOC 0x20
#define TIMEOUT 20
-// available ranges through the PGA gains
+/* available ranges through the PGA gains */
static const struct comedi_lrange range_adq12b_ai_bipolar = { 4, {
- BIP_RANGE( 5 ),
- BIP_RANGE( 2 ),
- BIP_RANGE( 1 ),
- BIP_RANGE( 0.5 )
+ BIP_RANGE(5),
+ BIP_RANGE(2),
+ BIP_RANGE(1),
+ BIP_RANGE(0.5)
}};
static const struct comedi_lrange range_adq12b_ai_unipolar = { 4, {
- UNI_RANGE( 5 ),
- UNI_RANGE( 2 ),
- UNI_RANGE( 1 ),
- UNI_RANGE( 0.5 )
+ UNI_RANGE(5),
+ UNI_RANGE(2),
+ UNI_RANGE(1),
+ UNI_RANGE(0.5)
}};
@@ -127,20 +127,20 @@ struct adq12b_board {
static const struct adq12b_board adq12b_boards[] = {
{
- name: "adq12b",
- ai_se_chans: 16,
- ai_diff_chans: 8,
- ai_bits: 12,
- di_chans: 5,
- do_chans: 8
+ .name = "adq12b",
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .di_chans = 5,
+ .do_chans = 8
}
-// potentially, more adq-based deviced will be added
+/* potentially, more adq-based deviced will be added */
/*,
- name: "adq12b",
- ai_chans: 16, // this is just for reference, hardcoded again later
- ai_bits: 12,
- di_chans: 8,
- do_chans: 5
+ .name = "adq12b",
+ .ai_chans = 16, // this is just for reference, hardcoded again later
+ .ai_bits = 12,
+ .di_chans = 8,
+ .do_chans = 5
}*/
};
@@ -162,7 +162,7 @@ struct adq12b_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it);
+static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static int adq12b_detach(struct comedi_device *dev);
static struct comedi_driver driver_adq12b={
driver_name: "adq12b",
@@ -171,12 +171,12 @@ static struct comedi_driver driver_adq12b={
detach: adq12b_detach,
board_name: &adq12b_boards[0].name,
offset: sizeof(struct adq12b_board),
- num_names: sizeof(adq12b_boards) / sizeof(struct adq12b_board),
+ num_names: ARRAY_SIZE(adq12b_boards),
};
-static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data);
-static int adq12b_di_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data);
-static int adq12b_do_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data);
+static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
/*
* Attach is called by the Comedi core to configure the driver
@@ -184,7 +184,7 @@ static int adq12b_do_insn_bits(struct comedi_device *dev,struct comedi_subdevice
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it)
+static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -194,7 +194,7 @@ static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it)
unipolar = it->options[1];
differential = it->options[2];
- printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n",dev->minor, iobase, (unipolar==1)?"unipolar":"bipolar", (differential==1)?"differential":"single-ended");
+ printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n", dev->minor, iobase, (unipolar==1)?"unipolar":"bipolar", (differential==1) ? "differential" : "single-ended");
/* if no address was specified, try the default 0x300 */
if (iobase == 0) {
@@ -219,7 +219,7 @@ static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it)
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
*/
- if(alloc_private(dev, sizeof(struct adq12b_private)) < 0)
+ if (alloc_private (dev, sizeof (struct adq12b_private)) < 0)
return -ENOMEM;
/* fill in devpriv structure */
@@ -236,7 +236,7 @@ static int adq12b_attach(struct comedi_device *dev,struct comedi_devconfig *it)
* Allocate the subdevice structures. alloc_subdevice() is a
* convenient macro defined in comedidev.h.
*/
- if(alloc_subdevices(dev, 3)<0)
+ if (alloc_subdevices (dev, 3)<0)
return -ENOMEM;
s = dev->subdevices+0;
@@ -304,7 +304,7 @@ static int adq12b_detach(struct comedi_device *dev)
kfree(devpriv);
- printk("comedi%d: adq12b: removed\n",dev->minor);
+ printk("comedi%d: adq12b: removed\n", dev->minor);
return 0;
}
@@ -314,7 +314,7 @@ static int adq12b_detach(struct comedi_device *dev)
* mode.
*/
-static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)
+static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int n, i;
int range, channel;
@@ -325,29 +325,29 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,
channel = CR_CHAN(insn->chanspec);
if (channel != devpriv->last_channel || range != devpriv->last_range) {
outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
- comedi_udelay(50); /* wait for the mux to settle */
+ udelay(50); /* wait for the mux to settle */
}
/* trigger conversion */
status = inb(dev->iobase + ADQ12B_ADLOW);
/* convert n samples */
- for(n=0; n < insn->n; n++){
+ for (n=0; n < insn->n; n++){
/* wait for end of convertion */
i = 0;
do {
-// comedi_udelay(1);
+/* udelay(1); */
status = inb(dev->iobase + ADQ12B_STINR);
status = status & ADQ12B_EOC;
} while (status == 0 && ++i < TIMEOUT);
-// } while (++i < 10);
+/* } while (++i < 10); */
/* read data */
hi = inb(dev->iobase + ADQ12B_ADHIG);
lo = inb(dev->iobase + ADQ12B_ADLOW);
- //rt_printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo);
+ /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); */
data[n] = (hi << 8) | lo;
}
@@ -357,7 +357,7 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,
}
-static int adq12b_di_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)
+static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
/* only bits 0-4 have information about digital inputs */
@@ -367,7 +367,7 @@ static int adq12b_di_insn_bits(struct comedi_device *dev,struct comedi_subdevice
}
-static int adq12b_do_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)
+static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int channel;
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index 29eac743c8e0..0b56c14e2d59 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -41,6 +41,8 @@ Configuration options:
device will be used.
*/
+#include <linux/interrupt.h>
+
#include "../comedidev.h"
#include "comedi_pci.h"
@@ -56,12 +58,12 @@ Configuration options:
#undef DPRINTK
#ifdef PCI171X_EXTDEBUG
-#define DPRINTK(fmt, args...) rt_printk(fmt, ## args)
+#define DPRINTK(fmt, args...) printk(fmt, ## args)
#else
#define DPRINTK(fmt, args...)
#endif
-// hardware types of the cards
+/* hardware types of the cards */
#define TYPE_PCI171X 0
#define TYPE_PCI1713 2
#define TYPE_PCI1720 3
@@ -87,12 +89,12 @@ Configuration options:
#define PCI171x_CNT2 28 /* R/W: 8254 couter 2 */
#define PCI171x_CNTCTRL 30 /* W: 8254 counter control */
-// upper bits from status register (PCI171x_STATUS) (lower is same woth control reg)
+/* upper bits from status register (PCI171x_STATUS) (lower is same woth control reg) */
#define Status_FE 0x0100 /* 1=FIFO is empty */
#define Status_FH 0x0200 /* 1=FIFO is half full */
#define Status_FF 0x0400 /* 1=FIFO is full, fatal error */
#define Status_IRQ 0x0800 /* 1=IRQ occured */
-// bits from control register (PCI171x_CONTROL)
+/* bits from control register (PCI171x_CONTROL) */
#define Control_CNT0 0x0040 /* 1=CNT0 have external source, 0=have internal 100kHz source */
#define Control_ONEFH 0x0020 /* 1=IRQ on FIFO is half full, 0=every sample */
#define Control_IRQEN 0x0010 /* 1=enable IRQ */
@@ -100,7 +102,7 @@ Configuration options:
#define Control_EXT 0x0004 /* 1=external trigger source */
#define Control_PACER 0x0002 /* 1=enable internal 8254 trigger source */
#define Control_SW 0x0001 /* 1=enable software trigger source */
-// bits from counter control register (PCI171x_CNTCTRL)
+/* bits from counter control register (PCI171x_CNTCTRL) */
#define Counter_BCD 0x0001 /* 0 = binary counter, 1 = BCD counter */
#define Counter_M0 0x0002 /* M0-M2 select modes 0-5 */
#define Counter_M1 0x0004 /* 000 = mode 0, 010 = mode 2 ... */
@@ -118,7 +120,7 @@ Configuration options:
#define PCI1720_SYNCOUT 9 /* W: D/A synchronized output register */
#define PCI1720_SYNCONT 15 /* R/W: D/A synchronized control */
-// D/A synchronized control (PCI1720_SYNCONT)
+/* D/A synchronized control (PCI1720_SYNCONT) */
#define Syncont_SC0 1 /* set synchronous output mode */
static const struct comedi_lrange range_pci1710_3 = { 9, {
@@ -182,28 +184,28 @@ static const struct comedi_lrange range_pci171x_da = { 2, {
}
};
-static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci1710_detach(struct comedi_device * dev);
+static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci1710_detach(struct comedi_device *dev);
struct boardtype {
- const char *name; // board name
+ const char *name; /* board name */
int device_id;
- int iorange; // I/O range len
- char have_irq; // 1=card support IRQ
- char cardtype; // 0=1710& co. 2=1713, ...
- int n_aichan; // num of A/D chans
- int n_aichand; // num of A/D chans in diff mode
- int n_aochan; // num of D/A chans
- int n_dichan; // num of DI chans
- int n_dochan; // num of DO chans
- int n_counter; // num of counters
- int ai_maxdata; // resolution of A/D
- int ao_maxdata; // resolution of D/A
- const struct comedi_lrange *rangelist_ai; // rangelist for A/D
- const char *rangecode_ai; // range codes for programming
- const struct comedi_lrange *rangelist_ao; // rangelist for D/A
- unsigned int ai_ns_min; // max sample speed of card v ns
- unsigned int fifo_half_size; // size of FIFO/2
+ int iorange; /* I/O range len */
+ char have_irq; /* 1=card support IRQ */
+ char cardtype; /* 0=1710& co. 2=1713, ... */
+ int n_aichan; /* num of A/D chans */
+ int n_aichand; /* num of A/D chans in diff mode */
+ int n_aochan; /* num of D/A chans */
+ int n_dichan; /* num of DI chans */
+ int n_dochan; /* num of DO chans */
+ int n_counter; /* num of counters */
+ int ai_maxdata; /* resolution of A/D */
+ int ao_maxdata; /* resolution of D/A */
+ const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */
+ const char *rangecode_ai; /* range codes for programming */
+ const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
+ unsigned int ai_ns_min; /* max sample speed of card v ns */
+ unsigned int fifo_half_size; /* size of FIFO/2 */
};
static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
@@ -250,7 +252,7 @@ static const struct boardtype boardtypes[] = {
16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
&range_pci17x1, range_codes_pci17x1, NULL,
10000, 512},
- // dummy entry corresponding to driver name
+ /* dummy entry corresponding to driver name */
{.name = DRV_NAME},
};
@@ -267,34 +269,34 @@ static struct comedi_driver driver_pci1710 = {
};
struct pci1710_private {
- struct pci_dev *pcidev; // ptr to PCI device
- char valid; // card is usable
- char neverending_ai; // we do unlimited AI
- unsigned int CntrlReg; // Control register
- unsigned int i8254_osc_base; // frequence of onboard oscilator
- unsigned int ai_do; // what do AI? 0=nothing, 1 to 4 mode
- unsigned int ai_act_scan; // how many scans we finished
- unsigned int ai_act_chan; // actual position in actual scan
- unsigned int ai_buf_ptr; // data buffer ptr in samples
- unsigned char ai_eos; // 1=EOS wake up
+ struct pci_dev *pcidev; /* ptr to PCI device */
+ char valid; /* card is usable */
+ char neverending_ai; /* we do unlimited AI */
+ unsigned int CntrlReg; /* Control register */
+ unsigned int i8254_osc_base; /* frequence of onboard oscilator */
+ unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */
+ unsigned int ai_act_scan; /* how many scans we finished */
+ unsigned int ai_act_chan; /* actual position in actual scan */
+ unsigned int ai_buf_ptr; /* data buffer ptr in samples */
+ unsigned char ai_eos; /* 1=EOS wake up */
unsigned char ai_et;
unsigned int ai_et_CntrlReg;
unsigned int ai_et_MuxVal;
unsigned int ai_et_div1, ai_et_div2;
- unsigned int act_chanlist[32]; // list of scaned channel
- unsigned char act_chanlist_len; // len of scanlist
- unsigned char act_chanlist_pos; // actual position in MUX list
- unsigned char da_ranges; // copy of D/A outpit range register
- unsigned int ai_scans; // len of scanlist
- unsigned int ai_n_chan; // how many channels is measured
- unsigned int *ai_chanlist; // actaul chanlist
- unsigned int ai_flags; // flaglist
- unsigned int ai_data_len; // len of data buffer
- short *ai_data; // data buffer
- unsigned int ai_timer1; // timers
+ unsigned int act_chanlist[32]; /* list of scaned channel */
+ unsigned char act_chanlist_len; /* len of scanlist */
+ unsigned char act_chanlist_pos; /* actual position in MUX list */
+ unsigned char da_ranges; /* copy of D/A outpit range register */
+ unsigned int ai_scans; /* len of scanlist */
+ unsigned int ai_n_chan; /* how many channels is measured */
+ unsigned int *ai_chanlist; /* actaul chanlist */
+ unsigned int ai_flags; /* flaglist */
+ unsigned int ai_data_len; /* len of data buffer */
+ short *ai_data; /* data buffer */
+ unsigned int ai_timer1; /* timers */
unsigned int ai_timer2;
- short ao_data[4]; // data output buffer
- unsigned int cnt0_write_wait; // after a write, wait for update of the internal state
+ short ao_data[4]; /* data output buffer */
+ unsigned int cnt0_write_wait; /* after a write, wait for update of the internal state */
};
#define devpriv ((struct pci1710_private *)dev->private)
@@ -304,16 +306,16 @@ struct pci1710_private {
==============================================================================
*/
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan);
-static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan, unsigned int seglen);
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2);
-static int pci1710_reset(struct comedi_device * dev);
-static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int pci1710_reset(struct comedi_device *dev);
+static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707, // used for gain list programming
+static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707, /* used for gain list programming */
0x0808, 0x0909, 0x0a0a, 0x0b0b, 0x0c0c, 0x0d0d, 0x0e0e, 0x0f0f,
0x1010, 0x1111, 0x1212, 0x1313, 0x1414, 0x1515, 0x1616, 0x1717,
0x1818, 0x1919, 0x1a1a, 0x1b1b, 0x1c1c, 0x1d1d, 0x1e1e, 0x1f1f
@@ -322,8 +324,8 @@ static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x040
/*
==============================================================================
*/
-static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, timeout;
#ifdef PCI171x_PARANOIDCHECK
@@ -332,7 +334,7 @@ static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdev
DPRINTK("adv_pci1710 EDBG: BGN: pci171x_insn_read_ai(...)\n");
devpriv->CntrlReg &= Control_CNT0;
- devpriv->CntrlReg |= Control_SW; // set software trigger
+ devpriv->CntrlReg |= Control_SW; /* set software trigger */
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
outb(0, dev->iobase + PCI171x_CLRFIFO);
outb(0, dev->iobase + PCI171x_CLRINT);
@@ -346,7 +348,7 @@ static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdev
outw(0, dev->iobase + PCI171x_SOFTTRG); /* start conversion */
DPRINTK("adv_pci1710 B n=%d ST=%4x\n", n,
inw(dev->iobase + PCI171x_STATUS));
- //comedi_udelay(1);
+ /* udelay(1); */
DPRINTK("adv_pci1710 C n=%d ST=%4x\n", n,
inw(dev->iobase + PCI171x_STATUS));
timeout = 100;
@@ -390,8 +392,8 @@ static int pci171x_insn_read_ai(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci171x_insn_write_ao(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan, range, ofs;
@@ -421,8 +423,8 @@ static int pci171x_insn_write_ao(struct comedi_device * dev, struct comedi_subde
/*
==============================================================================
*/
-static int pci171x_insn_read_ao(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan;
@@ -436,8 +438,8 @@ static int pci171x_insn_read_ao(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci171x_insn_bits_di(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[1] = inw(dev->iobase + PCI171x_DI);
@@ -447,8 +449,8 @@ static int pci171x_insn_bits_di(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci171x_insn_bits_do(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -463,8 +465,8 @@ static int pci171x_insn_bits_do(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci171x_insn_counter_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_counter_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int msb, lsb, ccntrl;
int i;
@@ -485,8 +487,8 @@ static int pci171x_insn_counter_read(struct comedi_device * dev, struct comedi_s
/*
==============================================================================
*/
-static int pci171x_insn_counter_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_counter_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
uint msb, lsb, ccntrl, status;
@@ -512,8 +514,8 @@ static int pci171x_insn_counter_write(struct comedi_device * dev, struct comedi_
/*
==============================================================================
*/
-static int pci171x_insn_counter_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int pci171x_insn_counter_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
#ifdef unused
/* This doesn't work like a normal Comedi counter config */
@@ -548,8 +550,8 @@ static int pci171x_insn_counter_config(struct comedi_device * dev,
/*
==============================================================================
*/
-static int pci1720_insn_write_ao(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1720_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, rangereg, chan;
@@ -563,7 +565,7 @@ static int pci1720_insn_write_ao(struct comedi_device * dev, struct comedi_subde
for (n = 0; n < insn->n; n++) {
outw(data[n], dev->iobase + PCI1720_DA0 + (chan << 1));
- outb(0, dev->iobase + PCI1720_SYNCOUT); // update outputs
+ outb(0, dev->iobase + PCI1720_SYNCOUT); /* update outputs */
}
devpriv->ao_data[chan] = data[n];
@@ -586,14 +588,14 @@ static void interrupt_pci1710_every_sample(void *d)
DPRINTK("adv_pci1710 EDBG: BGN: interrupt_pci1710_every_sample(...)\n");
m = inw(dev->iobase + PCI171x_STATUS);
if (m & Status_FE) {
- rt_printk("comedi%d: A/D FIFO empty (%4x)\n", dev->minor, m);
+ printk("comedi%d: A/D FIFO empty (%4x)\n", dev->minor, m);
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
return;
}
if (m & Status_FF) {
- rt_printk
+ printk
("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
dev->minor, m);
pci171x_ai_cancel(dev, s);
@@ -602,7 +604,7 @@ static void interrupt_pci1710_every_sample(void *d)
return;
}
- outb(0, dev->iobase + PCI171x_CLRINT); // clear our INT request
+ outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */
DPRINTK("FOR ");
for (; !(inw(dev->iobase + PCI171x_STATUS) & Status_FE);) {
@@ -612,7 +614,7 @@ static void interrupt_pci1710_every_sample(void *d)
if (this_board->cardtype != TYPE_PCI1713)
if ((sampl & 0xf000) !=
devpriv->act_chanlist[s->async->cur_chan]) {
- rt_printk
+ printk
("comedi: A/D data dropout: received data from channel %d, expected %d!\n",
(sampl & 0xf000) >> 12,
(devpriv->act_chanlist[s->async->
@@ -637,11 +639,11 @@ static void interrupt_pci1710_every_sample(void *d)
s->async->cur_chan = 0;
}
- if (s->async->cur_chan == 0) { // one scan done
+ if (s->async->cur_chan == 0) { /* one scan done */
devpriv->ai_act_scan++;
DPRINTK("adv_pci1710 EDBG: EOS1 bic %d bip %d buc %d bup %d\n", s->async->buf_int_count, s->async->buf_int_ptr, s->async->buf_user_count, s->async->buf_user_ptr);
DPRINTK("adv_pci1710 EDBG: EOS2\n");
- if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { // all data sampled
+ if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { /* all data sampled */
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
@@ -650,7 +652,7 @@ static void interrupt_pci1710_every_sample(void *d)
}
}
- outb(0, dev->iobase + PCI171x_CLRINT); // clear our INT request
+ outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */
DPRINTK("adv_pci1710 EDBG: END: interrupt_pci1710_every_sample(...)\n");
comedi_event(dev, s);
@@ -659,7 +661,7 @@ static void interrupt_pci1710_every_sample(void *d)
/*
==============================================================================
*/
-static int move_block_from_fifo(struct comedi_device * dev, struct comedi_subdevice * s,
+static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s,
int n, int turn)
{
int i, j;
@@ -674,7 +676,7 @@ static int move_block_from_fifo(struct comedi_device * dev, struct comedi_subdev
sampl = inw(dev->iobase + PCI171x_AD_DATA);
if (this_board->cardtype != TYPE_PCI1713)
if ((sampl & 0xf000) != devpriv->act_chanlist[j]) {
- rt_printk
+ printk
("comedi%d: A/D FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n",
dev->minor, (sampl & 0xf000) >> 12,
(devpriv->
@@ -714,7 +716,7 @@ static void interrupt_pci1710_half_fifo(void *d)
DPRINTK("adv_pci1710 EDBG: BGN: interrupt_pci1710_half_fifo(...)\n");
m = inw(dev->iobase + PCI171x_STATUS);
if (!(m & Status_FH)) {
- rt_printk("comedi%d: A/D FIFO not half full! (%4x)\n",
+ printk("comedi%d: A/D FIFO not half full! (%4x)\n",
dev->minor, m);
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
@@ -722,7 +724,7 @@ static void interrupt_pci1710_half_fifo(void *d)
return;
}
if (m & Status_FF) {
- rt_printk
+ printk
("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
dev->minor, m);
pci171x_ai_cancel(dev, s);
@@ -751,7 +753,7 @@ static void interrupt_pci1710_half_fifo(void *d)
comedi_event(dev, s);
return;
}
- outb(0, dev->iobase + PCI171x_CLRINT); // clear our INT request
+ outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */
DPRINTK("adv_pci1710 EDBG: END: interrupt_pci1710_half_fifo(...)\n");
comedi_event(dev, s);
@@ -760,36 +762,36 @@ static void interrupt_pci1710_half_fifo(void *d)
/*
==============================================================================
*/
-static irqreturn_t interrupt_service_pci1710(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_service_pci1710(int irq, void *d)
{
struct comedi_device *dev = d;
DPRINTK("adv_pci1710 EDBG: BGN: interrupt_service_pci1710(%d,...)\n",
irq);
- if (!dev->attached) // is device attached?
- return IRQ_NONE; // no, exit
+ if (!dev->attached) /* is device attached? */
+ return IRQ_NONE; /* no, exit */
- if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) // is this interrupt from our board?
- return IRQ_NONE; // no, exit
+ if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) /* is this interrupt from our board? */
+ return IRQ_NONE; /* no, exit */
DPRINTK("adv_pci1710 EDBG: interrupt_service_pci1710() ST: %4x\n",
inw(dev->iobase + PCI171x_STATUS));
- if (devpriv->ai_et) { // Switch from initial TRIG_EXT to TRIG_xxx.
+ if (devpriv->ai_et) { /* Switch from initial TRIG_EXT to TRIG_xxx. */
devpriv->ai_et = 0;
devpriv->CntrlReg &= Control_CNT0;
- devpriv->CntrlReg |= Control_SW; // set software trigger
+ devpriv->CntrlReg |= Control_SW; /* set software trigger */
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
devpriv->CntrlReg = devpriv->ai_et_CntrlReg;
outb(0, dev->iobase + PCI171x_CLRFIFO);
outb(0, dev->iobase + PCI171x_CLRINT);
outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX);
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
- // start pacer
+ /* start pacer */
start_pacer(dev, 1, devpriv->ai_et_div1, devpriv->ai_et_div2);
return IRQ_HANDLED;
}
- if (devpriv->ai_eos) { // We use FIFO half full INT or not?
+ if (devpriv->ai_eos) { /* We use FIFO half full INT or not? */
interrupt_pci1710_every_sample(d);
} else {
interrupt_pci1710_half_fifo(d);
@@ -801,15 +803,15 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d PT_REGS_ARG)
/*
==============================================================================
*/
-static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned int divisor1, divisor2;
unsigned int seglen;
DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_docmd_and_mode(%d,...)\n",
mode);
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
devpriv->ai_n_chan);
@@ -829,7 +831,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev,
devpriv->neverending_ai = 0;
devpriv->CntrlReg &= Control_CNT0;
- if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { // don't we want wake up every scan? devpriv->ai_eos=1;
+ if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? devpriv->ai_eos=1; */
devpriv->ai_eos = 1;
} else {
devpriv->CntrlReg |= Control_ONEFH;
@@ -838,7 +840,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev,
if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) {
devpriv->neverending_ai = 1;
- } //well, user want neverending
+ } /* well, user want neverending */
else {
devpriv->neverending_ai = 0;
}
@@ -863,7 +865,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev,
DPRINTK("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n", devpriv->i8254_osc_base, divisor1, divisor2, devpriv->ai_timer1);
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
if (mode != 2) {
- // start pacer
+ /* start pacer */
start_pacer(dev, mode, divisor1, divisor2);
} else {
devpriv->ai_et_div1 = divisor1;
@@ -884,15 +886,15 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device * dev,
/*
==============================================================================
*/
-static void pci171x_cmdtest_out(int e, struct comedi_cmd * cmd)
+static void pci171x_cmdtest_out(int e, struct comedi_cmd *cmd)
{
- rt_printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
+ printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
- rt_printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
+ printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
- rt_printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
+ printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
cmd->scan_end_src);
- rt_printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n",
+ printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n",
e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
}
#endif
@@ -900,8 +902,8 @@ static void pci171x_cmdtest_out(int e, struct comedi_cmd * cmd)
/*
==============================================================================
*/
-static int pci171x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
@@ -1055,7 +1057,7 @@ static int pci171x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
if (cmd->chanlist) {
if (!check_channel_list(dev, s, cmd->chanlist,
cmd->chanlist_len))
- return 5; // incorrect channels list
+ return 5; /* incorrect channels list */
}
DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) ret=0\n");
@@ -1065,7 +1067,7 @@ static int pci171x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
/*
==============================================================================
*/
-static int pci171x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
@@ -1084,13 +1086,13 @@ static int pci171x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
devpriv->ai_scans = 0;
}
- if (cmd->scan_begin_src == TRIG_FOLLOW) { // mode 1, 2, 3
- if (cmd->convert_src == TRIG_TIMER) { // mode 1 and 2
+ if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 2, 3 */
+ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */
devpriv->ai_timer1 = cmd->convert_arg;
return pci171x_ai_docmd_and_mode(cmd->start_src ==
TRIG_EXT ? 2 : 1, dev, s);
}
- if (cmd->convert_src == TRIG_EXT) { // mode 3
+ if (cmd->convert_src == TRIG_EXT) { /* mode 3 */
return pci171x_ai_docmd_and_mode(3, dev, s);
}
}
@@ -1104,7 +1106,7 @@ static int pci171x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
If it's ok, then program scan/gain logic.
This works for all cards.
*/
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan)
{
unsigned int chansegment[32];
@@ -1118,12 +1120,12 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
}
if (n_chan > 1) {
- chansegment[0] = chanlist[0]; // first channel is everytime ok
- for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { // build part of chanlist
- // rt_printk("%d. %d %d\n",i,CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i]));
+ chansegment[0] = chanlist[0]; /* first channel is everytime ok */
+ for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { /* build part of chanlist */
+ /* printk("%d. %d %d\n",i,CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */
if (chanlist[0] == chanlist[i])
- break; // we detect loop, this must by finish
- if (CR_CHAN(chanlist[i]) & 1) // odd channel cann't by differencial
+ break; /* we detect loop, this must by finish */
+ if (CR_CHAN(chanlist[i]) & 1) /* odd channel cann't by differencial */
if (CR_AREF(chanlist[i]) == AREF_DIFF) {
comedi_error(dev,
"Odd channel can't be differential input!\n");
@@ -1133,20 +1135,20 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
(CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
if (CR_AREF(chansegment[i - 1]) == AREF_DIFF)
nowmustbechan = (nowmustbechan + 1) % s->n_chan;
- if (nowmustbechan != CR_CHAN(chanlist[i])) { // channel list isn't continous :-(
- rt_printk
+ if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */
+ printk
("channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n",
i, CR_CHAN(chanlist[i]), nowmustbechan,
CR_CHAN(chanlist[0]));
return 0;
}
- chansegment[i] = chanlist[i]; // well, this is next correct channel in list
+ chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */
}
- for (i = 0, segpos = 0; i < n_chan; i++) { // check whole chanlist
- //rt_printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i]));
+ for (i = 0, segpos = 0; i < n_chan; i++) { /* check whole chanlist */
+ /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */
if (chanlist[i] != chansegment[i % seglen]) {
- rt_printk
+ printk
("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
i, CR_CHAN(chansegment[i]),
CR_RANGE(chansegment[i]),
@@ -1154,7 +1156,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
CR_CHAN(chanlist[i % seglen]),
CR_RANGE(chanlist[i % seglen]),
CR_AREF(chansegment[i % seglen]));
- return 0; // chan/gain list is strange
+ return 0; /* chan/gain list is strange */
}
}
} else {
@@ -1163,7 +1165,7 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
return seglen;
}
-static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan, unsigned int seglen)
{
unsigned int i, range, chanprog;
@@ -1174,7 +1176,7 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi
devpriv->act_chanlist_pos = 0;
DPRINTK("SegLen: %d\n", seglen);
- for (i = 0; i < seglen; i++) { // store range list to card
+ for (i = 0; i < seglen; i++) { /* store range list to card */
chanprog = muxonechan[CR_CHAN(chanlist[i])];
outw(chanprog, dev->iobase + PCI171x_MUX); /* select channel */
range = this_board->rangecode_ai[CR_RANGE(chanlist[i])];
@@ -1200,7 +1202,7 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2)
{
DPRINTK("adv_pci1710 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode,
@@ -1220,7 +1222,7 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis
/*
==============================================================================
*/
-static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cancel(...)\n");
@@ -1229,7 +1231,7 @@ static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
devpriv->CntrlReg &= Control_CNT0;
devpriv->CntrlReg |= Control_SW;
- outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); // reset any operations
+ outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */
start_pacer(dev, -1, 0, 0);
outb(0, dev->iobase + PCI171x_CLRFIFO);
outb(0, dev->iobase + PCI171x_CLRINT);
@@ -1249,28 +1251,28 @@ static int pci171x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
/*
==============================================================================
*/
-static int pci171x_reset(struct comedi_device * dev)
+static int pci171x_reset(struct comedi_device *dev)
{
DPRINTK("adv_pci1710 EDBG: BGN: pci171x_reset(...)\n");
outw(0x30, dev->iobase + PCI171x_CNTCTRL);
- devpriv->CntrlReg = Control_SW | Control_CNT0; // Software trigger, CNT0=external
- outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); // reset any operations
- outb(0, dev->iobase + PCI171x_CLRFIFO); // clear FIFO
- outb(0, dev->iobase + PCI171x_CLRINT); // clear INT request
- start_pacer(dev, -1, 0, 0); // stop 8254
+ devpriv->CntrlReg = Control_SW | Control_CNT0; /* Software trigger, CNT0=external */
+ outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */
+ outb(0, dev->iobase + PCI171x_CLRFIFO); /* clear FIFO */
+ outb(0, dev->iobase + PCI171x_CLRINT); /* clear INT request */
+ start_pacer(dev, -1, 0, 0); /* stop 8254 */
devpriv->da_ranges = 0;
if (this_board->n_aochan) {
- outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF); // set DACs to 0..5V
- outw(0, dev->iobase + PCI171x_DA1); // set DA outputs to 0V
+ outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF); /* set DACs to 0..5V */
+ outw(0, dev->iobase + PCI171x_DA1); /* set DA outputs to 0V */
devpriv->ao_data[0] = 0x0000;
if (this_board->n_aochan > 1) {
outw(0, dev->iobase + PCI171x_DA2);
devpriv->ao_data[1] = 0x0000;
}
}
- outw(0, dev->iobase + PCI171x_DO); // digital outputs to 0
- outb(0, dev->iobase + PCI171x_CLRFIFO); // clear FIFO
- outb(0, dev->iobase + PCI171x_CLRINT); // clear INT request
+ outw(0, dev->iobase + PCI171x_DO); /* digital outputs to 0 */
+ outb(0, dev->iobase + PCI171x_CLRFIFO); /* clear FIFO */
+ outb(0, dev->iobase + PCI171x_CLRINT); /* clear INT request */
DPRINTK("adv_pci1710 EDBG: END: pci171x_reset(...)\n");
return 0;
@@ -1279,17 +1281,17 @@ static int pci171x_reset(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci1720_reset(struct comedi_device * dev)
+static int pci1720_reset(struct comedi_device *dev)
{
DPRINTK("adv_pci1710 EDBG: BGN: pci1720_reset(...)\n");
- outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT); // set synchronous output mode
+ outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT); /* set synchronous output mode */
devpriv->da_ranges = 0xAA;
- outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE); // set all ranges to +/-5V
- outw(0x0800, dev->iobase + PCI1720_DA0); // set outputs to 0V
+ outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE); /* set all ranges to +/-5V */
+ outw(0x0800, dev->iobase + PCI1720_DA0); /* set outputs to 0V */
outw(0x0800, dev->iobase + PCI1720_DA1);
outw(0x0800, dev->iobase + PCI1720_DA2);
outw(0x0800, dev->iobase + PCI1720_DA3);
- outb(0, dev->iobase + PCI1720_SYNCOUT); // update outputs
+ outb(0, dev->iobase + PCI1720_SYNCOUT); /* update outputs */
devpriv->ao_data[0] = 0x0800;
devpriv->ao_data[1] = 0x0800;
devpriv->ao_data[2] = 0x0800;
@@ -1301,7 +1303,7 @@ static int pci1720_reset(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci1710_reset(struct comedi_device * dev)
+static int pci1710_reset(struct comedi_device *dev)
{
DPRINTK("adv_pci1710 EDBG: BGN: pci1710_reset(...)\n");
switch (this_board->cardtype) {
@@ -1316,7 +1318,7 @@ static int pci1710_reset(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret, subdev, n_subdevices;
@@ -1329,13 +1331,14 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
int i;
int board_index;
- rt_printk("comedi%d: adv_pci1710: ", dev->minor);
+ printk("comedi%d: adv_pci1710: ", dev->minor);
opt_bus = it->options[0];
opt_slot = it->options[1];
- if ((ret = alloc_private(dev, sizeof(struct pci1710_private))) < 0) {
- rt_printk(" - Allocation failed!\n");
+ ret = alloc_private(dev, sizeof(struct pci1710_private));
+ if (ret < 0) {
+ printk(" - Allocation failed!\n");
return -ENOMEM;
}
@@ -1345,20 +1348,20 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
board_index = this_board - boardtypes;
while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
PCI_ANY_ID, pcidev))) {
- if(strcmp(this_board->name, DRV_NAME) == 0)
+ if (strcmp (this_board->name, DRV_NAME) == 0)
{
- for(i = 0; i < n_boardtypes; ++i)
+ for (i = 0; i < n_boardtypes; ++i)
{
- if(pcidev->device == boardtypes[i].device_id)
+ if (pcidev->device == boardtypes[i].device_id)
{
board_index = i;
break;
}
}
- if(i == n_boardtypes) continue;
+ if (i == n_boardtypes) continue;
}else
{
- if(pcidev->device != boardtypes[board_index].device_id) continue;
+ if (pcidev->device != boardtypes[board_index].device_id) continue;
}
/* Found matching vendor/device. */
@@ -1376,17 +1379,17 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
errstr = "failed to enable PCI device and request regions!";
continue;
}
- // fixup board_ptr in case we were using the dummy entry with the driver name
+ /* fixup board_ptr in case we were using the dummy entry with the driver name */
dev->board_ptr = &boardtypes[board_index];
break;
}
if (!pcidev) {
if (opt_bus || opt_slot) {
- rt_printk(" - Card at b:s %d:%d %s\n",
+ printk(" - Card at b:s %d:%d %s\n",
opt_bus, opt_slot, errstr);
} else {
- rt_printk(" - Card %s\n", errstr);
+ printk(" - Card %s\n", errstr);
}
return -EIO;
}
@@ -1397,7 +1400,7 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
irq = pcidev->irq;
iobase = pci_resource_start(pcidev, 2);
- rt_printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func,
+ printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func,
iobase);
dev->iobase = iobase;
@@ -1417,8 +1420,9 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
if (this_board->n_counter)
n_subdevices++;
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) {
- rt_printk(" - Allocation failed!\n");
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0) {
+ printk(" - Allocation failed!\n");
return ret;
}
@@ -1426,18 +1430,18 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
if (this_board->have_irq) {
if (irq) {
- if (comedi_request_irq(irq, interrupt_service_pci1710,
+ if (request_irq(irq, interrupt_service_pci1710,
IRQF_SHARED, "Advantech PCI-1710",
dev)) {
- rt_printk
+ printk
(", unable to allocate IRQ %d, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%u", irq);
+ printk(", irq=%u", irq);
}
} else {
- rt_printk(", IRQ disabled");
+ printk(", IRQ disabled");
}
} else {
irq = 0;
@@ -1467,7 +1471,7 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
s->do_cmdtest = pci171x_ai_cmdtest;
s->do_cmd = pci171x_ai_cmd;
}
- devpriv->i8254_osc_base = 100; // 100ns=10MHz
+ devpriv->i8254_osc_base = 100; /* 100ns=10MHz */
subdev++;
}
@@ -1540,14 +1544,14 @@ static int pci1710_attach(struct comedi_device * dev, struct comedi_devconfig *
/*
==============================================================================
*/
-static int pci1710_detach(struct comedi_device * dev)
+static int pci1710_detach(struct comedi_device *dev)
{
if (dev->private) {
if (devpriv->valid)
pci1710_reset(dev);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv->pcidev) {
if (dev->iobase) {
comedi_pci_disable(devpriv->pcidev);
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c
index 81f7ee18c150..e1994a5290bd 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/staging/comedi/drivers/adv_pci1723.c
@@ -54,7 +54,7 @@ TODO:
#define ADVANTECH_VENDOR 0x13fe /* Advantech PCI vendor ID */
-// hardware types of the cards
+/* hardware types of the cards */
#define TYPE_PCI1723 0
#define IORANGE_1723 0x2A
@@ -92,7 +92,7 @@ TODO:
#define PCI1723_SELECT_CALIBRATION 0x28 /* Select the calibration Ref_V */
-//static unsigned short pci_list_builded=0; /*=1 list of card is know */
+/* static unsigned short pci_list_builded=0; =1 list of card is know */
static const struct comedi_lrange range_pci1723 = { 1, {
BIP_RANGE(10)
@@ -104,27 +104,27 @@ static const struct comedi_lrange range_pci1723 = { 1, {
*/
struct pci1723_board {
const char *name;
- int vendor_id; // PCI vendor a device ID of card
+ int vendor_id; /* PCI vendor a device ID of card */
int device_id;
int iorange;
char cardtype;
- int n_aochan; // num of D/A chans
- int n_diochan; // num of DIO chans
- int ao_maxdata; // resolution of D/A
- const struct comedi_lrange *rangelist_ao; // rangelist for D/A
+ int n_aochan; /* num of D/A chans */
+ int n_diochan; /* num of DIO chans */
+ int ao_maxdata; /* resolution of D/A */
+ const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
};
static const struct pci1723_board boardtypes[] = {
{
- name: "pci1723",
- vendor_id:ADVANTECH_VENDOR,
- device_id:0x1723,
- iorange: IORANGE_1723,
- cardtype:TYPE_PCI1723,
- n_aochan:8,
- n_diochan:16,
- ao_maxdata:0xffff,
- rangelist_ao:&range_pci1723,
+ .name = "pci1723",
+ .vendor_id = ADVANTECH_VENDOR,
+ .device_id = 0x1723,
+ .iorange = IORANGE_1723,
+ .cardtype = TYPE_PCI1723,
+ .n_aochan = 8,
+ .n_diochan = 16,
+ .ao_maxdata = 0xffff,
+ .rangelist_ao = &range_pci1723,
},
};
@@ -143,26 +143,26 @@ MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci1723_detach(struct comedi_device * dev);
+static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci1723_detach(struct comedi_device *dev);
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board))
static struct comedi_driver driver_pci1723 = {
- driver_name:"adv_pci1723",
- module:THIS_MODULE,
- attach:pci1723_attach,
- detach:pci1723_detach,
+ .driver_name = "adv_pci1723",
+ .module = THIS_MODULE,
+ .attach = pci1723_attach,
+ .detach = pci1723_detach,
};
/* this structure is for data unique to this hardware driver. */
struct pci1723_private {
- int valid; //card is usable;
+ int valid; /* card is usable; */
struct pci_dev *pcidev;
- unsigned char da_range[8]; // D/A output range for each channel
+ unsigned char da_range[8]; /* D/A output range for each channel */
- short ao_data[8]; // data output buffer
+ short ao_data[8]; /* data output buffer */
};
/*the following macro to make it easy to
@@ -175,35 +175,35 @@ struct pci1723_private {
/*
* the pci1723 card reset;
*/
-static int pci1723_reset(struct comedi_device * dev)
+static int pci1723_reset(struct comedi_device *dev)
{
int i;
DPRINTK("adv_pci1723 EDBG: BGN: pci1723_reset(...)\n");
- outw(0x01, dev->iobase + PCI1723_SYN_SET); // set synchronous output mode
+ outw(0x01, dev->iobase + PCI1723_SYN_SET); /* set synchronous output mode */
for (i = 0; i < 8; i++) {
- // set all outputs to 0V
+ /* set all outputs to 0V */
devpriv->ao_data[i] = 0x8000;
outw(devpriv->ao_data[i], dev->iobase + PCI1723_DA(i));
- // set all ranges to +/- 10V
+ /* set all ranges to +/- 10V */
devpriv->da_range[i] = 0;
outw(((devpriv->da_range[i] << 4) | i),
PCI1723_RANGE_CALIBRATION_MODE);
}
- outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); // update ranges
- outw(0, dev->iobase + PCI1723_SYN_STROBE); // update outputs
+ outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); /* update ranges */
+ outw(0, dev->iobase + PCI1723_SYN_STROBE); /* update outputs */
- // set asynchronous output mode
+ /* set asynchronous output mode */
outw(0, dev->iobase + PCI1723_SYN_SET);
DPRINTK("adv_pci1723 EDBG: END: pci1723_reset(...)\n");
return 0;
}
-static int pci1723_insn_read_ao(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan;
@@ -218,8 +218,8 @@ static int pci1723_insn_read_ao(struct comedi_device * dev, struct comedi_subdev
/*
analog data output;
*/
-static int pci1723_ao_write_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1723_ao_write_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan;
chan = CR_CHAN(insn->chanspec);
@@ -238,8 +238,8 @@ static int pci1723_ao_write_winsn(struct comedi_device * dev, struct comedi_subd
/*
digital i/o config/query
*/
-static int pci1723_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask;
unsigned int bits;
@@ -265,12 +265,12 @@ static int pci1723_dio_insn_config(struct comedi_device * dev, struct comedi_sub
return -EINVAL;
}
- // update hardware DIO mode
- dio_mode = 0x0000; // low byte output, high byte output
+ /* update hardware DIO mode */
+ dio_mode = 0x0000; /* low byte output, high byte output */
if ((s->io_bits & 0x00FF) == 0)
- dio_mode |= 0x0001; // low byte input
+ dio_mode |= 0x0001; /* low byte input */
if ((s->io_bits & 0xFF00) == 0)
- dio_mode |= 0x0002; // high byte input
+ dio_mode |= 0x0002; /* high byte input */
outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET);
return 1;
}
@@ -278,8 +278,8 @@ static int pci1723_dio_insn_config(struct comedi_device * dev, struct comedi_sub
/*
digital i/o bits read/write
*/
-static int pci1723_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1723_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -294,7 +294,7 @@ static int pci1723_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
* Attach is called by the Comedi core to configure the driver
* for a pci1723 board.
*/
-static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret, subdev, n_subdevices;
@@ -304,14 +304,15 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig *
int opt_bus, opt_slot;
const char *errstr;
- rt_printk("comedi%d: adv_pci1723: board=%s", dev->minor,
+ printk("comedi%d: adv_pci1723: board=%s", dev->minor,
this_board->name);
opt_bus = it->options[0];
opt_slot = it->options[1];
- if ((ret = alloc_private(dev, sizeof(struct pci1723_private))) < 0) {
- rt_printk(" - Allocation failed!\n");
+ ret = alloc_private(dev, sizeof(struct pci1723_private));
+ if (ret < 0) {
+ printk(" - Allocation failed!\n");
return -ENOMEM;
}
@@ -341,10 +342,10 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig *
if (!pcidev) {
if (opt_bus || opt_slot) {
- rt_printk(" - Card at b:s %d:%d %s\n",
+ printk(" - Card at b:s %d:%d %s\n",
opt_bus, opt_slot, errstr);
} else {
- rt_printk(" - Card %s\n", errstr);
+ printk(" - Card %s\n", errstr);
}
return -EIO;
}
@@ -354,7 +355,7 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig *
pci_func = PCI_FUNC(pcidev->devfn);
iobase = pci_resource_start(pcidev, 2);
- rt_printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func,
+ printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func,
iobase);
dev->iobase = iobase;
@@ -369,8 +370,9 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig *
if (this_board->n_diochan)
n_subdevices++;
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) {
- rt_printk(" - Allocation failed!\n");
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0) {
+ printk(" - Allocation failed!\n");
return ret;
}
@@ -389,22 +391,22 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig *
s->insn_write = pci1723_ao_write_winsn;
s->insn_read = pci1723_insn_read_ao;
- // read DIO config
+ /* read DIO config */
switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE) & 0x03) {
- case 0x00: // low byte output, high byte output
+ case 0x00: /* low byte output, high byte output */
s->io_bits = 0xFFFF;
break;
- case 0x01: // low byte input, high byte output
+ case 0x01: /* low byte input, high byte output */
s->io_bits = 0xFF00;
break;
- case 0x02: // low byte output, high byte input
+ case 0x02: /* low byte output, high byte input */
s->io_bits = 0x00FF;
break;
- case 0x03: // low byte input, high byte input
+ case 0x03: /* low byte input, high byte input */
s->io_bits = 0x0000;
break;
}
- // read DIO port state
+ /* read DIO port state */
s->state = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA);
subdev++;
@@ -439,7 +441,7 @@ static int pci1723_attach(struct comedi_device * dev, struct comedi_devconfig *
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pci1723_detach(struct comedi_device * dev)
+static int pci1723_detach(struct comedi_device *dev)
{
printk("comedi%d: pci1723: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c
index 2604425c3a0f..5a8c0a3bb2f8 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -40,7 +40,7 @@ Configuration options:
#undef DPRINTK
#ifdef PCI_DIO_EXTDEBUG
-#define DPRINTK(fmt, args...) rt_printk(fmt, ## args)
+#define DPRINTK(fmt, args...) printk(fmt, ## args)
#else
#define DPRINTK(fmt, args...)
#endif
@@ -183,8 +183,8 @@ enum hw_io_access {
#define OMBCMD_RETRY 0x03 /* 3 times try request before error */
-static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci_dio_detach(struct comedi_device * dev);
+static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci_dio_detach(struct comedi_device *dev);
struct diosubd_data {
int chans; /* num of chans */
@@ -323,10 +323,10 @@ static const struct dio_boardtype boardtypes[] = {
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
static struct comedi_driver driver_pci_dio = {
- driver_name:"adv_pci_dio",
- module:THIS_MODULE,
- attach:pci_dio_attach,
- detach:pci_dio_detach
+ .driver_name = "adv_pci_dio",
+ .module = THIS_MODULE,
+ .attach = pci_dio_attach,
+ .detach = pci_dio_detach
};
struct pci_dio_private {
@@ -357,8 +357,8 @@ static struct pci_dio_private *pci_priv = NULL; /* list of allocated cards */
/*
==============================================================================
*/
-static int pci_dio_insn_bits_di_b(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
const struct diosubd_data *d = (const struct diosubd_data *)s->private;
int i;
@@ -374,8 +374,8 @@ static int pci_dio_insn_bits_di_b(struct comedi_device * dev, struct comedi_subd
/*
==============================================================================
*/
-static int pci_dio_insn_bits_di_w(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
const struct diosubd_data *d = (const struct diosubd_data *)s->private;
int i;
@@ -390,8 +390,8 @@ static int pci_dio_insn_bits_di_w(struct comedi_device * dev, struct comedi_subd
/*
==============================================================================
*/
-static int pci_dio_insn_bits_do_b(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
const struct diosubd_data *d = (const struct diosubd_data *)s->private;
int i;
@@ -411,8 +411,8 @@ static int pci_dio_insn_bits_do_b(struct comedi_device * dev, struct comedi_subd
/*
==============================================================================
*/
-static int pci_dio_insn_bits_do_w(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
const struct diosubd_data *d = (const struct diosubd_data *)s->private;
int i;
@@ -432,7 +432,7 @@ static int pci_dio_insn_bits_do_w(struct comedi_device * dev, struct comedi_subd
/*
==============================================================================
*/
-static int pci1760_unchecked_mbxrequest(struct comedi_device * dev,
+static int pci1760_unchecked_mbxrequest(struct comedi_device *dev,
unsigned char *omb, unsigned char *imb, int repeats)
{
int cnt, tout, ok = 0;
@@ -443,14 +443,15 @@ static int pci1760_unchecked_mbxrequest(struct comedi_device * dev,
outb(omb[2], dev->iobase + OMB2);
outb(omb[3], dev->iobase + OMB3);
for (tout = 0; tout < 251; tout++) {
- if ((imb[2] = inb(dev->iobase + IMB2)) == omb[2]) {
+ imb[2] = inb(dev->iobase + IMB2);
+ if (imb[2] == omb[2]) {
imb[0] = inb(dev->iobase + IMB0);
imb[1] = inb(dev->iobase + IMB1);
imb[3] = inb(dev->iobase + IMB3);
ok = 1;
break;
}
- comedi_udelay(1);
+ udelay(1);
}
if (ok)
return 0;
@@ -460,7 +461,7 @@ static int pci1760_unchecked_mbxrequest(struct comedi_device * dev,
return -ETIME;
}
-static int pci1760_clear_imb2(struct comedi_device * dev)
+static int pci1760_clear_imb2(struct comedi_device *dev)
{
unsigned char omb[4] = { 0x0, 0x0, CMD_ClearIMB2, 0x0 };
unsigned char imb[4];
@@ -470,7 +471,7 @@ static int pci1760_clear_imb2(struct comedi_device * dev)
return pci1760_unchecked_mbxrequest(dev, omb, imb, OMBCMD_RETRY);
}
-static int pci1760_mbxrequest(struct comedi_device * dev,
+static int pci1760_mbxrequest(struct comedi_device *dev,
unsigned char *omb, unsigned char *imb)
{
if (omb[2] == CMD_ClearIMB2) {
@@ -490,8 +491,8 @@ static int pci1760_mbxrequest(struct comedi_device * dev,
/*
==============================================================================
*/
-static int pci1760_insn_bits_di(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1760_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[1] = inb(dev->iobase + IMB3);
@@ -501,8 +502,8 @@ static int pci1760_insn_bits_di(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci1760_insn_bits_do(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1760_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int ret;
unsigned char omb[4] = {
@@ -517,7 +518,8 @@ static int pci1760_insn_bits_do(struct comedi_device * dev, struct comedi_subdev
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
omb[0] = s->state;
- if (!(ret = pci1760_mbxrequest(dev, omb, imb)))
+ ret = pci1760_mbxrequest(dev, omb, imb);
+ if (!ret)
return ret;
}
data[1] = s->state;
@@ -528,8 +530,8 @@ static int pci1760_insn_bits_do(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pci1760_insn_cnt_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1760_insn_cnt_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int ret, n;
unsigned char omb[4] = {
@@ -541,7 +543,8 @@ static int pci1760_insn_cnt_read(struct comedi_device * dev, struct comedi_subde
unsigned char imb[4];
for (n = 0; n < insn->n; n++) {
- if (!(ret = pci1760_mbxrequest(dev, omb, imb)))
+ ret = pci1760_mbxrequest(dev, omb, imb);
+ if (!ret)
return ret;
data[n] = (imb[1] << 8) + imb[0];
}
@@ -552,8 +555,8 @@ static int pci1760_insn_cnt_read(struct comedi_device * dev, struct comedi_subde
/*
==============================================================================
*/
-static int pci1760_insn_cnt_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci1760_insn_cnt_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int ret;
unsigned char chan = CR_CHAN(insn->chanspec) & 0x07;
@@ -567,20 +570,23 @@ static int pci1760_insn_cnt_write(struct comedi_device * dev, struct comedi_subd
unsigned char imb[4];
if (devpriv->CntResValue[chan] != (data[0] & 0xffff)) { /* Set reset value if different */
- if (!(ret = pci1760_mbxrequest(dev, omb, imb)))
+ ret = pci1760_mbxrequest(dev, omb, imb);
+ if (!ret)
return ret;
devpriv->CntResValue[chan] = data[0] & 0xffff;
}
omb[0] = bitmask; /* reset counter to it reset value */
omb[2] = CMD_ResetIDICounters;
- if (!(ret = pci1760_mbxrequest(dev, omb, imb)))
+ ret = pci1760_mbxrequest(dev, omb, imb);
+ if (!ret)
return ret;
if (!(bitmask & devpriv->IDICntEnable)) { /* start counter if it don't run */
omb[0] = bitmask;
omb[2] = CMD_EnableIDICounters;
- if (!(ret = pci1760_mbxrequest(dev, omb, imb)))
+ ret = pci1760_mbxrequest(dev, omb, imb);
+ if (!ret)
return ret;
devpriv->IDICntEnable |= bitmask;
}
@@ -590,7 +596,7 @@ static int pci1760_insn_cnt_write(struct comedi_device * dev, struct comedi_subd
/*
==============================================================================
*/
-static int pci1760_reset(struct comedi_device * dev)
+static int pci1760_reset(struct comedi_device *dev)
{
int i;
unsigned char omb[4] = { 0x00, 0x00, 0x00, 0x00 };
@@ -667,7 +673,7 @@ static int pci1760_reset(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci_dio_reset(struct comedi_device * dev)
+static int pci_dio_reset(struct comedi_device *dev)
{
DPRINTK("adv_pci_dio EDBG: BGN: pci171x_reset(...)\n");
@@ -750,7 +756,7 @@ static int pci_dio_reset(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pci1760_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci1760_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int subdev = 0;
@@ -802,8 +808,8 @@ static int pci1760_attach(struct comedi_device * dev, struct comedi_devconfig *
/*
==============================================================================
*/
-static int pci_dio_add_di(struct comedi_device * dev, struct comedi_subdevice * s,
- const struct diosubd_data * d, int subdev)
+static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
+ const struct diosubd_data *d, int subdev)
{
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags;
@@ -829,8 +835,8 @@ static int pci_dio_add_di(struct comedi_device * dev, struct comedi_subdevice *
/*
==============================================================================
*/
-static int pci_dio_add_do(struct comedi_device * dev, struct comedi_subdevice * s,
- const struct diosubd_data * d, int subdev)
+static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
+ const struct diosubd_data *d, int subdev)
{
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
@@ -857,7 +863,7 @@ static int pci_dio_add_do(struct comedi_device * dev, struct comedi_subdevice *
/*
==============================================================================
*/
-static int CheckAndAllocCard(struct comedi_device * dev, struct comedi_devconfig * it,
+static int CheckAndAllocCard(struct comedi_device *dev, struct comedi_devconfig *it,
struct pci_dev *pcidev)
{
struct pci_dio_private *pr, *prev;
@@ -883,17 +889,18 @@ static int CheckAndAllocCard(struct comedi_device * dev, struct comedi_devconfig
/*
==============================================================================
*/
-static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret, subdev, n_subdevices, i, j;
unsigned long iobase;
struct pci_dev *pcidev;
- rt_printk("comedi%d: adv_pci_dio: ", dev->minor);
+ printk("comedi%d: adv_pci_dio: ", dev->minor);
- if ((ret = alloc_private(dev, sizeof(struct pci_dio_private))) < 0) {
- rt_printk(", Error: Cann't allocate private memory!\n");
+ ret = alloc_private(dev, sizeof(struct pci_dio_private));
+ if (ret < 0) {
+ printk(", Error: Cann't allocate private memory!\n");
return -ENOMEM;
}
@@ -925,18 +932,18 @@ static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig *
}
if (!dev->board_ptr) {
- rt_printk
+ printk
(", Error: Requested type of the card was not found!\n");
return -EIO;
}
if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) {
- rt_printk
+ printk
(", Error: Can't enable PCI device and request regions!\n");
return -EIO;
}
iobase = pci_resource_start(pcidev, this_board->main_pci_region);
- rt_printk(", b:s:f=%d:%d:%d, io=0x%4lx",
+ printk(", b:s:f=%d:%d:%d, io=0x%4lx",
pcidev->bus->number, PCI_SLOT(pcidev->devfn),
PCI_FUNC(pcidev->devfn), iobase);
@@ -959,12 +966,13 @@ static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig *
n_subdevices++;
}
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) {
- rt_printk(", Error: Cann't allocate subdevice memory!\n");
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0) {
+ printk(", Error: Cann't allocate subdevice memory!\n");
return ret;
}
- rt_printk(".\n");
+ printk(".\n");
subdev = 0;
@@ -1011,7 +1019,7 @@ static int pci_dio_attach(struct comedi_device * dev, struct comedi_devconfig *
/*
==============================================================================
*/
-static int pci_dio_detach(struct comedi_device * dev)
+static int pci_dio_detach(struct comedi_device *dev)
{
int i, j;
struct comedi_subdevice *s;
diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c
index b97b4d82611b..72283ae81368 100644
--- a/drivers/staging/comedi/drivers/aio_aio12_8.c
+++ b/drivers/staging/comedi/drivers/aio_aio12_8.c
@@ -77,7 +77,7 @@ struct aio12_8_boardtype {
static const struct aio12_8_boardtype board_types[] = {
{
- name: "aio_aio12_8"},
+ .name = "aio_aio12_8"},
};
#define thisboard ((const struct aio12_8_boardtype *) dev->board_ptr)
@@ -88,29 +88,29 @@ struct aio12_8_private {
#define devpriv ((struct aio12_8_private *) dev->private)
-static int aio_aio12_8_ai_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned char control =
ADC_MODE_NORMAL |
(CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec);
- //read status to clear EOC latch
+ /* read status to clear EOC latch */
inb(dev->iobase + AIO12_8_STATUS);
for (n = 0; n < insn->n; n++) {
int timeout = 5;
- // Setup and start conversion
+ /* Setup and start conversion */
outb(control, dev->iobase + AIO12_8_ADC);
- // Wait for conversion to complete
+ /* Wait for conversion to complete */
while (timeout &&
!(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) {
timeout--;
printk("timeout %d\n", timeout);
- comedi_udelay(1);
+ udelay(1);
}
if (timeout == 0) {
comedi_error(dev, "ADC timeout");
@@ -122,8 +122,8 @@ static int aio_aio12_8_ai_read(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int aio_aio12_8_ao_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int aio_aio12_8_ao_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int val = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
@@ -133,19 +133,19 @@ static int aio_aio12_8_ao_read(struct comedi_device * dev, struct comedi_subdevi
return insn->n;
}
-static int aio_aio12_8_ao_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int aio_aio12_8_ao_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned long port = dev->iobase + AIO12_8_DAC_0 + (2 * chan);
- //enable DACs
+ /* enable DACs */
outb(0x01, dev->iobase + DAC_ENABLE);
for (i = 0; i < insn->n; i++) {
- outb(data[i] & 0xFF, port); // LSB
- outb((data[i] >> 8) & 0x0F, port + 1); // MSB
+ outb(data[i] & 0xFF, port); /* LSB */
+ outb((data[i] >> 8) & 0x0F, port + 1); /* MSB */
devpriv->ao_readback[chan] = data[i];
}
return insn->n;
@@ -161,7 +161,7 @@ static const struct comedi_lrange range_aio_aio12_8 = {
}
};
-static int aio_aio12_8_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int aio_aio12_8_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int iobase;
struct comedi_subdevice *s;
@@ -205,7 +205,7 @@ static int aio_aio12_8_attach(struct comedi_device * dev, struct comedi_devconfi
return 0;
}
-static int aio_aio12_8_detach(struct comedi_device * dev)
+static int aio_aio12_8_detach(struct comedi_device *dev)
{
subdev_8255_cleanup(dev, &dev->subdevices[2]);
if (dev->iobase)
@@ -214,13 +214,13 @@ static int aio_aio12_8_detach(struct comedi_device * dev)
}
static struct comedi_driver driver_aio_aio12_8 = {
- driver_name:"aio_aio12_8",
- module:THIS_MODULE,
- attach:aio_aio12_8_attach,
- detach:aio_aio12_8_detach,
- board_name:&board_types[0].name,
- num_names:1,
- offset:sizeof(struct aio12_8_boardtype),
+ .driver_name = "aio_aio12_8",
+ .module = THIS_MODULE,
+ .attach = aio_aio12_8_attach,
+ .detach = aio_aio12_8_detach,
+ .board_name = &board_types[0].name,
+ .num_names = 1,
+ .offset = sizeof(struct aio12_8_boardtype),
};
COMEDI_INITCLEANUP(driver_aio_aio12_8);
diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c
index 9160fdf0ca37..d062f8619b6e 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -52,9 +52,9 @@ struct aio_iiro_16_board {
static const struct aio_iiro_16_board aio_iiro_16_boards[] = {
{
- name: "aio_iiro_16",
- di: 16,
- do_: 16},
+ .name = "aio_iiro_16",
+ .di = 16,
+ .do_ = 16},
};
#define thisboard ((const struct aio_iiro_16_board *) dev->board_ptr)
@@ -67,27 +67,27 @@ struct aio_iiro_16_private {
#define devpriv ((struct aio_iiro_16_private *) dev->private)
-static int aio_iiro_16_attach(struct comedi_device * dev, struct comedi_devconfig * it);
+static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int aio_iiro_16_detach(struct comedi_device * dev);
+static int aio_iiro_16_detach(struct comedi_device *dev);
static struct comedi_driver driver_aio_iiro_16 = {
- driver_name:"aio_iiro_16",
- module:THIS_MODULE,
- attach:aio_iiro_16_attach,
- detach:aio_iiro_16_detach,
- board_name:&aio_iiro_16_boards[0].name,
- offset:sizeof(struct aio_iiro_16_board),
- num_names:sizeof(aio_iiro_16_boards) / sizeof(struct aio_iiro_16_board),
+ .driver_name = "aio_iiro_16",
+ .module = THIS_MODULE,
+ .attach = aio_iiro_16_attach,
+ .detach = aio_iiro_16_detach,
+ .board_name = &aio_iiro_16_boards[0].name,
+ .offset = sizeof(struct aio_iiro_16_board),
+ .num_names = ARRAY_SIZE(aio_iiro_16_boards),
};
-static int aio_iiro_16_dio_insn_bits_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int aio_iiro_16_dio_insn_bits_write(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int aio_iiro_16_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int iobase;
struct comedi_subdevice *s;
@@ -132,7 +132,7 @@ static int aio_iiro_16_attach(struct comedi_device * dev, struct comedi_devconfi
return 1;
}
-static int aio_iiro_16_detach(struct comedi_device * dev)
+static int aio_iiro_16_detach(struct comedi_device *dev)
{
printk("comedi%d: aio_iiro_16: remove\n", dev->minor);
@@ -142,8 +142,8 @@ static int aio_iiro_16_detach(struct comedi_device * dev)
return 0;
}
-static int aio_iiro_16_dio_insn_bits_write(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -161,8 +161,8 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device * dev,
return 2;
}
-static int aio_iiro_16_dio_insn_bits_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/am9513.h b/drivers/staging/comedi/drivers/am9513.h
index f533cf1658cf..73367d6afffe 100644
--- a/drivers/staging/comedi/drivers/am9513.h
+++ b/drivers/staging/comedi/drivers/am9513.h
@@ -46,33 +46,33 @@
#ifdef Am9513_8BITBUS
-#define Am9513_write_register(reg,val) \
+#define Am9513_write_register(reg, val) \
do{ \
Am9513_output_control(reg); \
Am9513_output_data(val>>8); \
Am9513_output_data(val&0xff); \
- }while(0)
+ }while (0)
-#define Am9513_read_register(reg,val) \
+#define Am9513_read_register(reg, val) \
do{ \
Am9513_output_control(reg); \
val=Am9513_input_data()<<8; \
val|=Am9513_input_data(); \
- }while(0)
+ }while (0)
#else /* Am9513_16BITBUS */
-#define Am9513_write_register(reg,val) \
+#define Am9513_write_register(reg, val) \
do{ \
Am9513_output_control(reg); \
Am9513_output_data(val); \
- }while(0)
+ }while (0)
-#define Am9513_read_register(reg,val) \
+#define Am9513_read_register(reg, val) \
do{ \
Am9513_output_control(reg); \
val=Am9513_input_data(); \
- }while(0)
+ }while (0)
#endif
diff --git a/drivers/staging/comedi/drivers/amcc_s5933.h b/drivers/staging/comedi/drivers/amcc_s5933.h
index aceffce7ef3f..b810d5f3d971 100644
--- a/drivers/staging/comedi/drivers/amcc_s5933.h
+++ b/drivers/staging/comedi/drivers/amcc_s5933.h
@@ -48,12 +48,12 @@
/****************************************************************************/
#define INTCSR_OUTBOX_BYTE(x) ((x) & 0x3)
#define INTCSR_OUTBOX_SELECT(x) (((x) & 0x3) << 2)
-#define INTCSR_OUTBOX_EMPTY_INT 0x10 // enable outbox empty interrupt
+#define INTCSR_OUTBOX_EMPTY_INT 0x10 /* enable outbox empty interrupt */
#define INTCSR_INBOX_BYTE(x) (((x) & 0x3) << 8)
#define INTCSR_INBOX_SELECT(x) (((x) & 0x3) << 10)
-#define INTCSR_INBOX_FULL_INT 0x1000 // enable inbox full interrupt
-#define INTCSR_INBOX_INTR_STATUS 0x20000 // read, or write clear inbox full interrupt
-#define INTCSR_INTR_ASSERTED 0x800000 // read only, interrupt asserted
+#define INTCSR_INBOX_FULL_INT 0x1000 /* enable inbox full interrupt */
+#define INTCSR_INBOX_INTR_STATUS 0x20000 /* read, or write clear inbox full interrupt */
+#define INTCSR_INTR_ASSERTED 0x800000 /* read only, interrupt asserted */
/****************************************************************************/
/* AMCC - PCI non-volatile ram command register (byte 3 of master control/status register) */
@@ -153,7 +153,7 @@
#define AINT_IMB_SELECT 0x0000000c
#define AINT_IMB_BYTE 0x00000003
-// these are bits from various different registers, needs cleanup XXX
+/* these are bits from various different registers, needs cleanup XXX */
/* Enable Bus Mastering */
#define EN_A2P_TRANSFERS 0x00000400
/* FIFO Flag Reset */
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 8555e272a861..744680059faf 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -205,6 +205,8 @@ is packed into a short value, one bit per requested channel, in the
order they appear in the channel list.
*/
+#include <linux/interrupt.h>
+
#include "../comedidev.h"
#include "comedi_pci.h"
@@ -288,59 +290,59 @@ struct dio200_board {
static const struct dio200_board dio200_boards[] = {
{
- name: "pc212e",
- bustype: isa_bustype,
- model: pc212e_model,
- layout: pc212_layout,
+ .name = "pc212e",
+ .bustype = isa_bustype,
+ .model = pc212e_model,
+ .layout = pc212_layout,
},
{
- name: "pc214e",
- bustype: isa_bustype,
- model: pc214e_model,
- layout: pc214_layout,
+ .name = "pc214e",
+ .bustype = isa_bustype,
+ .model = pc214e_model,
+ .layout = pc214_layout,
},
{
- name: "pc215e",
- bustype: isa_bustype,
- model: pc215e_model,
- layout: pc215_layout,
+ .name = "pc215e",
+ .bustype = isa_bustype,
+ .model = pc215e_model,
+ .layout = pc215_layout,
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "pci215",
- devid: PCI_DEVICE_ID_AMPLICON_PCI215,
- bustype: pci_bustype,
- model: pci215_model,
- layout: pc215_layout,
+ .name = "pci215",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI215,
+ .bustype = pci_bustype,
+ .model = pci215_model,
+ .layout = pc215_layout,
},
#endif
{
- name: "pc218e",
- bustype: isa_bustype,
- model: pc218e_model,
- layout: pc218_layout,
+ .name = "pc218e",
+ .bustype = isa_bustype,
+ .model = pc218e_model,
+ .layout = pc218_layout,
},
{
- name: "pc272e",
- bustype: isa_bustype,
- model: pc272e_model,
- layout: pc272_layout,
+ .name = "pc272e",
+ .bustype = isa_bustype,
+ .model = pc272e_model,
+ .layout = pc272_layout,
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "pci272",
- devid: PCI_DEVICE_ID_AMPLICON_PCI272,
- bustype: pci_bustype,
- model: pci272_model,
- layout: pc272_layout,
+ .name = "pci272",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI272,
+ .bustype = pci_bustype,
+ .model = pci272_model,
+ .layout = pc272_layout,
},
#endif
#ifdef CONFIG_COMEDI_PCI
{
- name: DIO200_DRIVER_NAME,
- devid: PCI_DEVICE_ID_INVALID,
- bustype: pci_bustype,
- model: anypci_model, /* wildcard */
+ .name = DIO200_DRIVER_NAME,
+ .devid = PCI_DEVICE_ID_INVALID,
+ .bustype = pci_bustype,
+ .model = anypci_model, /* wildcard */
},
#endif
};
@@ -365,50 +367,50 @@ struct dio200_layout_struct {
static const struct dio200_layout_struct dio200_layouts[] = {
[pc212_layout] = {
- n_subdevs:6,
- sdtype: {sd_8255, sd_8254, sd_8254, sd_8254,
+ .n_subdevs = 6,
+ .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254,
sd_8254,
sd_intr},
- sdinfo: {0x00, 0x08, 0x0C, 0x10, 0x14,
+ .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14,
0x3F},
- has_int_sce:1,
- has_clk_gat_sce:1,
+ .has_int_sce = 1,
+ .has_clk_gat_sce = 1,
},
[pc214_layout] = {
- n_subdevs:4,
- sdtype: {sd_8255, sd_8255, sd_8254,
+ .n_subdevs = 4,
+ .sdtype = {sd_8255, sd_8255, sd_8254,
sd_intr},
- sdinfo: {0x00, 0x08, 0x10, 0x01},
- has_int_sce:0,
- has_clk_gat_sce:0,
+ .sdinfo = {0x00, 0x08, 0x10, 0x01},
+ .has_int_sce = 0,
+ .has_clk_gat_sce = 0,
},
[pc215_layout] = {
- n_subdevs:5,
- sdtype: {sd_8255, sd_8255, sd_8254,
+ .n_subdevs = 5,
+ .sdtype = {sd_8255, sd_8255, sd_8254,
sd_8254,
sd_intr},
- sdinfo: {0x00, 0x08, 0x10, 0x14, 0x3F},
- has_int_sce:1,
- has_clk_gat_sce:1,
+ .sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F},
+ .has_int_sce = 1,
+ .has_clk_gat_sce = 1,
},
[pc218_layout] = {
- n_subdevs:7,
- sdtype: {sd_8254, sd_8254, sd_8255, sd_8254,
+ .n_subdevs = 7,
+ .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254,
sd_8254,
sd_intr},
- sdinfo: {0x00, 0x04, 0x08, 0x0C, 0x10,
+ .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10,
0x14,
0x3F},
- has_int_sce:1,
- has_clk_gat_sce:1,
+ .has_int_sce = 1,
+ .has_clk_gat_sce = 1,
},
[pc272_layout] = {
- n_subdevs:4,
- sdtype: {sd_8255, sd_8255, sd_8255,
+ .n_subdevs = 4,
+ .sdtype = {sd_8255, sd_8255, sd_8255,
sd_intr},
- sdinfo: {0x00, 0x08, 0x10, 0x3F},
- has_int_sce:1,
- has_clk_gat_sce:0,
+ .sdinfo = {0x00, 0x08, 0x10, 0x3F},
+ .has_int_sce = 1,
+ .has_clk_gat_sce = 0,
},
};
@@ -473,16 +475,16 @@ struct dio200_subdev_intr {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dio200_detach(struct comedi_device * dev);
+static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dio200_detach(struct comedi_device *dev);
static struct comedi_driver driver_amplc_dio200 = {
- driver_name:DIO200_DRIVER_NAME,
- module:THIS_MODULE,
- attach:dio200_attach,
- detach:dio200_detach,
- board_name:&dio200_boards[0].name,
- offset:sizeof(struct dio200_board),
- num_names:sizeof(dio200_boards) / sizeof(struct dio200_board),
+ .driver_name = DIO200_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = dio200_attach,
+ .detach = dio200_detach,
+ .board_name = &dio200_boards[0].name,
+ .offset = sizeof(struct dio200_board),
+ .num_names = ARRAY_SIZE(dio200_boards),
};
#ifdef CONFIG_COMEDI_PCI
@@ -497,7 +499,7 @@ COMEDI_INITCLEANUP(driver_amplc_dio200);
*/
#ifdef CONFIG_COMEDI_PCI
static int
-dio200_find_pci(struct comedi_device * dev, int bus, int slot,
+dio200_find_pci(struct comedi_device *dev, int bus, int slot,
struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -572,8 +574,8 @@ dio200_request_region(unsigned minor, unsigned long from, unsigned long extent)
* 'insn_bits' function for an 'INTERRUPT' subdevice.
*/
static int
-dio200_subdev_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+dio200_subdev_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_intr *subpriv = s->private;
@@ -591,7 +593,7 @@ dio200_subdev_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice
/*
* Called to stop acquisition for an 'INTERRUPT' subdevice.
*/
-static void dio200_stop_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static void dio200_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct dio200_subdev_intr *subpriv = s->private;
@@ -605,7 +607,7 @@ static void dio200_stop_intr(struct comedi_device * dev, struct comedi_subdevice
/*
* Called to start acquisition for an 'INTERRUPT' subdevice.
*/
-static int dio200_start_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dio200_start_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned int n;
unsigned isn_bits;
@@ -641,7 +643,7 @@ static int dio200_start_intr(struct comedi_device * dev, struct comedi_subdevice
* Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
*/
static int
-dio200_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * s,
+dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
struct dio200_subdev_intr *subpriv;
@@ -653,12 +655,12 @@ dio200_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice *
subpriv = s->private;
- comedi_spin_lock_irqsave(&subpriv->spinlock, flags);
+ spin_lock_irqsave(&subpriv->spinlock, flags);
s->async->inttrig = 0;
if (subpriv->active) {
event = dio200_start_intr(dev, s);
}
- comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->spinlock, flags);
if (event) {
comedi_event(dev, s);
@@ -671,7 +673,7 @@ dio200_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice *
* This is called from the interrupt service routine to handle a read
* scan on an 'INTERRUPT' subdevice.
*/
-static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct dio200_subdev_intr *subpriv = s->private;
unsigned triggered;
@@ -682,7 +684,7 @@ static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_sub
triggered = 0;
- comedi_spin_lock_irqsave(&subpriv->spinlock, flags);
+ spin_lock_irqsave(&subpriv->spinlock, flags);
oldevents = s->async->events;
if (subpriv->has_int_sce) {
/*
@@ -771,7 +773,7 @@ static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_sub
}
}
}
- comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->spinlock, flags);
if (oldevents != s->async->events) {
comedi_event(dev, s);
@@ -783,16 +785,16 @@ static int dio200_handle_read_intr(struct comedi_device * dev, struct comedi_sub
/*
* 'cancel' function for an 'INTERRUPT' subdevice.
*/
-static int dio200_subdev_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dio200_subdev_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct dio200_subdev_intr *subpriv = s->private;
unsigned long flags;
- comedi_spin_lock_irqsave(&subpriv->spinlock, flags);
+ spin_lock_irqsave(&subpriv->spinlock, flags);
if (subpriv->active) {
dio200_stop_intr(dev, s);
}
- comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->spinlock, flags);
return 0;
}
@@ -801,8 +803,8 @@ static int dio200_subdev_intr_cancel(struct comedi_device * dev, struct comedi_s
* 'do_cmdtest' function for an 'INTERRUPT' subdevice.
*/
static int
-dio200_subdev_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+dio200_subdev_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -907,14 +909,14 @@ dio200_subdev_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
/*
* 'do_cmd' function for an 'INTERRUPT' subdevice.
*/
-static int dio200_subdev_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dio200_subdev_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
struct dio200_subdev_intr *subpriv = s->private;
unsigned long flags;
int event = 0;
- comedi_spin_lock_irqsave(&subpriv->spinlock, flags);
+ spin_lock_irqsave(&subpriv->spinlock, flags);
subpriv->active = 1;
/* Set up end of acquisition. */
@@ -940,7 +942,7 @@ static int dio200_subdev_intr_cmd(struct comedi_device * dev, struct comedi_subd
event = dio200_start_intr(dev, s);
break;
}
- comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->spinlock, flags);
if (event) {
comedi_event(dev, s);
@@ -953,7 +955,7 @@ static int dio200_subdev_intr_cmd(struct comedi_device * dev, struct comedi_subd
* This function initializes an 'INTERRUPT' subdevice.
*/
static int
-dio200_subdev_intr_init(struct comedi_device * dev, struct comedi_subdevice * s,
+dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long iobase, unsigned valid_isns, int has_int_sce)
{
struct dio200_subdev_intr *subpriv;
@@ -998,7 +1000,7 @@ dio200_subdev_intr_init(struct comedi_device * dev, struct comedi_subdevice * s,
* This function cleans up an 'INTERRUPT' subdevice.
*/
static void
-dio200_subdev_intr_cleanup(struct comedi_device * dev, struct comedi_subdevice * s)
+dio200_subdev_intr_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct dio200_subdev_intr *subpriv = s->private;
@@ -1010,7 +1012,7 @@ dio200_subdev_intr_cleanup(struct comedi_device * dev, struct comedi_subdevice *
/*
* Interrupt service routine.
*/
-static irqreturn_t dio200_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t dio200_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
int handled;
@@ -1033,8 +1035,8 @@ static irqreturn_t dio200_interrupt(int irq, void *d PT_REGS_ARG)
* Handle 'insn_read' for an '8254' counter subdevice.
*/
static int
-dio200_subdev_8254_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_8254 *subpriv = s->private;
int chan = CR_CHAN(insn->chanspec);
@@ -1048,8 +1050,8 @@ dio200_subdev_8254_read(struct comedi_device * dev, struct comedi_subdevice * s,
* Handle 'insn_write' for an '8254' counter subdevice.
*/
static int
-dio200_subdev_8254_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_8254 *subpriv = s->private;
int chan = CR_CHAN(insn->chanspec);
@@ -1063,7 +1065,7 @@ dio200_subdev_8254_write(struct comedi_device * dev, struct comedi_subdevice * s
* Set gate source for an '8254' counter subdevice channel.
*/
static int
-dio200_set_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number,
+dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
unsigned int gate_src)
{
unsigned char byte;
@@ -1086,7 +1088,7 @@ dio200_set_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_nu
* Get gate source for an '8254' counter subdevice channel.
*/
static int
-dio200_get_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number)
+dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number)
{
if (!subpriv->has_clk_gat_sce)
return -1;
@@ -1100,7 +1102,7 @@ dio200_get_gate_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_nu
* Set clock source for an '8254' counter subdevice channel.
*/
static int
-dio200_set_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number,
+dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
unsigned int clock_src)
{
unsigned char byte;
@@ -1123,8 +1125,8 @@ dio200_set_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_n
* Get clock source for an '8254' counter subdevice channel.
*/
static int
-dio200_get_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_number,
- unsigned int * period_ns)
+dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
+ unsigned int *period_ns)
{
unsigned clock_src;
@@ -1142,8 +1144,8 @@ dio200_get_clock_src(struct dio200_subdev_8254 * subpriv, unsigned int counter_n
* Handle 'insn_config' for an '8254' counter subdevice.
*/
static int
-dio200_subdev_8254_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_8254 *subpriv = s->private;
int ret;
@@ -1194,7 +1196,7 @@ dio200_subdev_8254_config(struct comedi_device * dev, struct comedi_subdevice *
* offset is the offset to the 8254 chip.
*/
static int
-dio200_subdev_8254_init(struct comedi_device * dev, struct comedi_subdevice * s,
+dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long iobase, unsigned offset, int has_clk_gat_sce)
{
struct dio200_subdev_8254 *subpriv;
@@ -1247,7 +1249,7 @@ dio200_subdev_8254_init(struct comedi_device * dev, struct comedi_subdevice * s,
* This function cleans up an '8254' counter subdevice.
*/
static void
-dio200_subdev_8254_cleanup(struct comedi_device * dev, struct comedi_subdevice * s)
+dio200_subdev_8254_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct dio200_subdev_intr *subpriv = s->private;
@@ -1262,7 +1264,7 @@ dio200_subdev_8254_cleanup(struct comedi_device * dev, struct comedi_subdevice *
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = 0;
@@ -1280,7 +1282,8 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
DIO200_DRIVER_NAME);
- if ((ret = alloc_private(dev, sizeof(struct dio200_private))) < 0) {
+ ret = alloc_private(dev, sizeof(struct dio200_private));
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -1299,7 +1302,8 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i
slot = it->options[1];
share_irq = 1;
- if ((ret = dio200_find_pci(dev, bus, slot, &pci_dev)) < 0)
+ ret = dio200_find_pci(dev, bus, slot, &pci_dev);
+ if (ret < 0)
return ret;
devpriv->pci_dev = pci_dev;
break;
@@ -1337,7 +1341,9 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->iobase = iobase;
layout = thislayout;
- if ((ret = alloc_subdevices(dev, layout->n_subdevs)) < 0) {
+
+ ret = alloc_subdevices(dev, layout->n_subdevs);
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -1392,7 +1398,7 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (irq) {
unsigned long flags = share_irq ? IRQF_SHARED : 0;
- if (comedi_request_irq(irq, dio200_interrupt, flags,
+ if (request_irq(irq, dio200_interrupt, flags,
DIO200_DRIVER_NAME, dev) >= 0) {
dev->irq = irq;
} else {
@@ -1429,7 +1435,7 @@ static int dio200_attach(struct comedi_device * dev, struct comedi_devconfig * i
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int dio200_detach(struct comedi_device * dev)
+static int dio200_detach(struct comedi_device *dev)
{
const struct dio200_layout_struct *layout;
unsigned n;
@@ -1438,7 +1444,7 @@ static int dio200_detach(struct comedi_device * dev)
DIO200_DRIVER_NAME);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev->subdevices) {
layout = thislayout;
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index 2027c75feaca..48d7ccb4a3fe 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -27,7 +27,7 @@ Driver: amplc_pc236
Description: Amplicon PC36AT, PCI236
Author: Ian Abbott <abbotti@mev.co.uk>
Devices: [Amplicon] PC36AT (pc36at), PCI236 (pci236 or amplc_pc236)
-Updated: Wed, 22 Oct 2008 13:40:03 +0100
+Updated: Wed, 01 Apr 2009 15:41:25 +0100
Status: works
Configuration options - PC36AT:
@@ -45,13 +45,15 @@ as subdevice 0.
Subdevice 1 pretends to be a digital input device, but it always returns
0 when read. However, if you run a command with scan_begin_src=TRIG_EXT,
-a rising edge on port C bit 7 acts as an external trigger, which can be
+a rising edge on port C bit 3 acts as an external trigger, which can be
used to wake up tasks. This is like the comedi_parport device, but the
only way to physically disable the interrupt on the PC36AT is to remove
the IRQ jumper. If no interrupt is connected, then subdevice 1 is
unused.
*/
+#include <linux/interrupt.h>
+
#include "../comedidev.h"
#include "comedi_pci.h"
@@ -75,19 +77,19 @@ unused.
* INTCSR values for PCI236.
*/
/* Disable interrupt, also clear any interrupt there */
-#define PCI236_INTR_DISABLE ( PLX9052_INTCSR_LI1ENAB_DISABLED \
+#define PCI236_INTR_DISABLE (PLX9052_INTCSR_LI1ENAB_DISABLED \
| PLX9052_INTCSR_LI1POL_HIGH \
| PLX9052_INTCSR_LI2POL_HIGH \
| PLX9052_INTCSR_PCIENAB_DISABLED \
| PLX9052_INTCSR_LI1SEL_EDGE \
- | PLX9052_INTCSR_LI1CLRINT_ASSERTED )
+ | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
/* Enable interrupt, also clear any interrupt there. */
-#define PCI236_INTR_ENABLE ( PLX9052_INTCSR_LI1ENAB_ENABLED \
+#define PCI236_INTR_ENABLE (PLX9052_INTCSR_LI1ENAB_ENABLED \
| PLX9052_INTCSR_LI1POL_HIGH \
| PLX9052_INTCSR_LI2POL_HIGH \
| PLX9052_INTCSR_PCIENAB_ENABLED \
| PLX9052_INTCSR_LI1SEL_EDGE \
- | PLX9052_INTCSR_LI1CLRINT_ASSERTED )
+ | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
/*
* Board descriptions for Amplicon PC36AT and PCI236.
@@ -105,27 +107,27 @@ struct pc236_board {
};
static const struct pc236_board pc236_boards[] = {
{
- name: "pc36at",
- fancy_name:"PC36AT",
- bustype: isa_bustype,
- model: pc36at_model,
+ .name = "pc36at",
+ .fancy_name = "PC36AT",
+ .bustype = isa_bustype,
+ .model = pc36at_model,
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "pci236",
- fancy_name:"PCI236",
- devid: PCI_DEVICE_ID_AMPLICON_PCI236,
- bustype: pci_bustype,
- model: pci236_model,
+ .name = "pci236",
+ .fancy_name = "PCI236",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI236,
+ .bustype = pci_bustype,
+ .model = pci236_model,
},
#endif
#ifdef CONFIG_COMEDI_PCI
{
- name: PC236_DRIVER_NAME,
- fancy_name:PC236_DRIVER_NAME,
- devid: PCI_DEVICE_ID_INVALID,
- bustype: pci_bustype,
- model: anypci_model, /* wildcard */
+ .name = PC236_DRIVER_NAME,
+ .fancy_name = PC236_DRIVER_NAME,
+ .devid = PCI_DEVICE_ID_INVALID,
+ .bustype = pci_bustype,
+ .model = anypci_model, /* wildcard */
},
#endif
};
@@ -165,16 +167,16 @@ struct pc236_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pc236_detach(struct comedi_device * dev);
+static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pc236_detach(struct comedi_device *dev);
static struct comedi_driver driver_amplc_pc236 = {
- driver_name:PC236_DRIVER_NAME,
- module:THIS_MODULE,
- attach:pc236_attach,
- detach:pc236_detach,
- board_name:&pc236_boards[0].name,
- offset:sizeof(struct pc236_board),
- num_names:sizeof(pc236_boards) / sizeof(struct pc236_board),
+ .driver_name = PC236_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pc236_attach,
+ .detach = pc236_detach,
+ .board_name = &pc236_boards[0].name,
+ .offset = sizeof(struct pc236_board),
+ .num_names = ARRAY_SIZE(pc236_boards),
};
#ifdef CONFIG_COMEDI_PCI
@@ -185,16 +187,16 @@ COMEDI_INITCLEANUP(driver_amplc_pc236);
static int pc236_request_region(unsigned minor, unsigned long from,
unsigned long extent);
-static void pc236_intr_disable(struct comedi_device * dev);
-static void pc236_intr_enable(struct comedi_device * dev);
-static int pc236_intr_check(struct comedi_device * dev);
-static int pc236_intr_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pc236_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int pc236_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pc236_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static irqreturn_t pc236_interrupt(int irq, void *d PT_REGS_ARG);
+static void pc236_intr_disable(struct comedi_device *dev);
+static void pc236_intr_enable(struct comedi_device *dev);
+static int pc236_intr_check(struct comedi_device *dev);
+static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static irqreturn_t pc236_interrupt(int irq, void *d);
/*
* This function looks for a PCI device matching the requested board name,
@@ -202,7 +204,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d PT_REGS_ARG);
*/
#ifdef CONFIG_COMEDI_PCI
static int
-pc236_find_pci(struct comedi_device * dev, int bus, int slot,
+pc236_find_pci(struct comedi_device *dev, int bus, int slot,
struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -264,7 +266,7 @@ pc236_find_pci(struct comedi_device * dev, int bus, int slot,
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = 0;
@@ -282,7 +284,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
*/
- if ((ret = alloc_private(dev, sizeof(struct pc236_private))) < 0) {
+ ret = alloc_private(dev, sizeof(struct pc236_private));
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -300,7 +303,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
slot = it->options[1];
share_irq = 1;
- if ((ret = pc236_find_pci(dev, bus, slot, &pci_dev)) < 0)
+ ret = pc236_find_pci(dev, bus, slot, &pci_dev);
+ if (ret < 0)
return ret;
devpriv->pci_dev = pci_dev;
break;
@@ -321,7 +325,9 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
/* Enable device and reserve I/O spaces. */
#ifdef CONFIG_COMEDI_PCI
if (pci_dev) {
- if ((ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME)) < 0) {
+
+ ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
+ if (ret < 0) {
printk(KERN_ERR
"comedi%d: error! cannot enable PCI device and request regions!\n",
dev->minor);
@@ -344,7 +350,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
* Allocate the subdevice structures. alloc_subdevice() is a
* convenient macro defined in comedidev.h.
*/
- if ((ret = alloc_subdevices(dev, 2)) < 0) {
+ ret = alloc_subdevices(dev, 2);
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -352,7 +359,8 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
s = dev->subdevices + 0;
/* digital i/o subdevice (8255) */
- if ((ret = subdev_8255_init(dev, s, NULL, iobase)) < 0) {
+ ret = subdev_8255_init(dev, s, NULL, iobase);
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -364,7 +372,7 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
if (irq) {
unsigned long flags = share_irq ? IRQF_SHARED : 0;
- if (comedi_request_irq(irq, pc236_interrupt, flags,
+ if (request_irq(irq, pc236_interrupt, flags,
PC236_DRIVER_NAME, dev) >= 0) {
dev->irq = irq;
s->type = COMEDI_SUBD_DI;
@@ -405,7 +413,7 @@ static int pc236_attach(struct comedi_device * dev, struct comedi_devconfig * it
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pc236_detach(struct comedi_device * dev)
+static int pc236_detach(struct comedi_device *dev)
{
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
PC236_DRIVER_NAME);
@@ -413,7 +421,7 @@ static int pc236_detach(struct comedi_device * dev)
pc236_intr_disable(dev);
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->subdevices) {
subdev_8255_cleanup(dev, dev->subdevices + 0);
}
@@ -459,17 +467,17 @@ static int pc236_request_region(unsigned minor, unsigned long from,
* configured on subdevice 1) and to physically disable the interrupt
* (not possible on the PC36AT, except by removing the IRQ jumper!).
*/
-static void pc236_intr_disable(struct comedi_device * dev)
+static void pc236_intr_disable(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->enable_irq = 0;
#ifdef CONFIG_COMEDI_PCI
if (devpriv->lcr_iobase)
outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
#endif
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
/*
@@ -477,17 +485,17 @@ static void pc236_intr_disable(struct comedi_device * dev)
* configured on subdevice 1) and to physically enable the interrupt
* (not possible on the PC36AT, except by (re)connecting the IRQ jumper!).
*/
-static void pc236_intr_enable(struct comedi_device * dev)
+static void pc236_intr_enable(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->enable_irq = 1;
#ifdef CONFIG_COMEDI_PCI
if (devpriv->lcr_iobase)
outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
#endif
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
/*
@@ -497,12 +505,12 @@ static void pc236_intr_enable(struct comedi_device * dev)
* interrupt.
* Returns 0 if the interrupt should be ignored.
*/
-static int pc236_intr_check(struct comedi_device * dev)
+static int pc236_intr_check(struct comedi_device *dev)
{
int retval = 0;
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
if (devpriv->enable_irq) {
retval = 1;
#ifdef CONFIG_COMEDI_PCI
@@ -519,7 +527,7 @@ static int pc236_intr_check(struct comedi_device * dev)
}
#endif
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return retval;
}
@@ -528,8 +536,8 @@ static int pc236_intr_check(struct comedi_device * dev)
* Input from subdevice 1.
* Copied from the comedi_parport driver.
*/
-static int pc236_intr_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[1] = 0;
return 2;
@@ -539,8 +547,8 @@ static int pc236_intr_insn(struct comedi_device * dev, struct comedi_subdevice *
* Subdevice 1 command test.
* Copied from the comedi_parport driver.
*/
-static int pc236_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -617,7 +625,7 @@ static int pc236_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevic
/*
* Subdevice 1 command.
*/
-static int pc236_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
pc236_intr_enable(dev);
@@ -627,7 +635,7 @@ static int pc236_intr_cmd(struct comedi_device * dev, struct comedi_subdevice *
/*
* Subdevice 1 cancel command.
*/
-static int pc236_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
pc236_intr_disable(dev);
@@ -638,7 +646,7 @@ static int pc236_intr_cancel(struct comedi_device * dev, struct comedi_subdevice
* Interrupt service routine.
* Based on the comedi_parport driver.
*/
-static irqreturn_t pc236_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t pc236_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices + 1;
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 97ac4157adaf..730b67743f0e 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -74,27 +74,27 @@ struct pc263_board {
};
static const struct pc263_board pc263_boards[] = {
{
- name: "pc263",
- fancy_name:"PC263",
- bustype: isa_bustype,
- model: pc263_model,
+ .name = "pc263",
+ .fancy_name = "PC263",
+ .bustype = isa_bustype,
+ .model = pc263_model,
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "pci263",
- fancy_name:"PCI263",
- devid: PCI_DEVICE_ID_AMPLICON_PCI263,
- bustype: pci_bustype,
- model: pci263_model,
+ .name = "pci263",
+ .fancy_name = "PCI263",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI263,
+ .bustype = pci_bustype,
+ .model = pci263_model,
},
#endif
#ifdef CONFIG_COMEDI_PCI
{
- name: PC263_DRIVER_NAME,
- fancy_name:PC263_DRIVER_NAME,
- devid: PCI_DEVICE_ID_INVALID,
- bustype: pci_bustype,
- model: anypci_model, /* wildcard */
+ .name = PC263_DRIVER_NAME,
+ .fancy_name = PC263_DRIVER_NAME,
+ .devid = PCI_DEVICE_ID_INVALID,
+ .bustype = pci_bustype,
+ .model = anypci_model, /* wildcard */
},
#endif
};
@@ -132,24 +132,24 @@ struct pc263_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pc263_detach(struct comedi_device * dev);
+static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pc263_detach(struct comedi_device *dev);
static struct comedi_driver driver_amplc_pc263 = {
- driver_name:PC263_DRIVER_NAME,
- module:THIS_MODULE,
- attach:pc263_attach,
- detach:pc263_detach,
- board_name:&pc263_boards[0].name,
- offset:sizeof(struct pc263_board),
- num_names:sizeof(pc263_boards) / sizeof(struct pc263_board),
+ .driver_name = PC263_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pc263_attach,
+ .detach = pc263_detach,
+ .board_name = &pc263_boards[0].name,
+ .offset = sizeof(struct pc263_board),
+ .num_names = ARRAY_SIZE(pc263_boards),
};
static int pc263_request_region(unsigned minor, unsigned long from,
unsigned long extent);
-static int pc263_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pc263_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/*
* This function looks for a PCI device matching the requested board name,
@@ -157,7 +157,7 @@ static int pc263_dio_insn_config(struct comedi_device * dev, struct comedi_subde
*/
#ifdef CONFIG_COMEDI_PCI
static int
-pc263_find_pci(struct comedi_device * dev, int bus, int slot,
+pc263_find_pci(struct comedi_device *dev, int bus, int slot,
struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -219,7 +219,7 @@ pc263_find_pci(struct comedi_device * dev, int bus, int slot,
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = 0;
@@ -236,7 +236,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it
* convenient macro defined in comedidev.h.
*/
#ifdef CONFIG_COMEDI_PCI
- if ((ret = alloc_private(dev, sizeof(struct pc263_private))) < 0) {
+ ret = alloc_private(dev, sizeof(struct pc263_private));
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -252,7 +253,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it
bus = it->options[0];
slot = it->options[1];
- if ((ret = pc263_find_pci(dev, bus, slot, &pci_dev)) < 0)
+ ret = pc263_find_pci(dev, bus, slot, &pci_dev);
+ if (ret < 0)
return ret;
devpriv->pci_dev = pci_dev;
break;
@@ -273,7 +275,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it
/* Enable device and reserve I/O spaces. */
#ifdef CONFIG_COMEDI_PCI
if (pci_dev) {
- if ((ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME)) < 0) {
+ ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
+ if (ret < 0) {
printk(KERN_ERR
"comedi%d: error! cannot enable PCI device and request regions!\n",
dev->minor);
@@ -294,7 +297,8 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it
* Allocate the subdevice structures. alloc_subdevice() is a
* convenient macro defined in comedidev.h.
*/
- if ((ret = alloc_subdevices(dev, 1)) < 0) {
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -303,7 +307,7 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it
s = dev->subdevices + 0;
/* digital i/o subdevice */
s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_RT;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
@@ -337,7 +341,7 @@ static int pc263_attach(struct comedi_device * dev, struct comedi_devconfig * it
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pc263_detach(struct comedi_device * dev)
+static int pc263_detach(struct comedi_device *dev)
{
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
PC263_DRIVER_NAME);
@@ -387,8 +391,8 @@ static int pc263_request_region(unsigned minor, unsigned long from,
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int pc263_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -412,8 +416,8 @@ static int pc263_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int pc263_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 1)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
index 770b96648932..d1a64e80cddb 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -103,6 +103,8 @@ Caveats:
correctly.
*/
+#include <linux/interrupt.h>
+
#include "../comedidev.h"
#include "comedi_pci.h"
@@ -356,23 +358,23 @@ struct pci224_board {
static const struct pci224_board pci224_boards[] = {
{
- name: "pci224",
- devid: PCI_DEVICE_ID_AMPLICON_PCI224,
- model: pci224_model,
- ao_chans:16,
- ao_bits: 12,
+ .name = "pci224",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI224,
+ .model = pci224_model,
+ .ao_chans = 16,
+ .ao_bits = 12,
},
{
- name: "pci234",
- devid: PCI_DEVICE_ID_AMPLICON_PCI234,
- model: pci234_model,
- ao_chans:4,
- ao_bits: 16,
+ .name = "pci234",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI234,
+ .model = pci234_model,
+ .ao_chans = 4,
+ .ao_bits = 16,
},
{
- name: DRIVER_NAME,
- devid: PCI_DEVICE_ID_INVALID,
- model: any_model, /* wildcard */
+ .name = DRIVER_NAME,
+ .devid = PCI_DEVICE_ID_INVALID,
+ .model = any_model, /* wildcard */
},
};
@@ -426,16 +428,16 @@ struct pci224_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci224_detach(struct comedi_device * dev);
+static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci224_detach(struct comedi_device *dev);
static struct comedi_driver driver_amplc_pci224 = {
- driver_name:DRIVER_NAME,
- module:THIS_MODULE,
- attach:pci224_attach,
- detach:pci224_detach,
- board_name:&pci224_boards[0].name,
- offset:sizeof(struct pci224_board),
- num_names:sizeof(pci224_boards) / sizeof(struct pci224_board),
+ .driver_name = DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pci224_attach,
+ .detach = pci224_detach,
+ .board_name = &pci224_boards[0].name,
+ .offset = sizeof(struct pci224_board),
+ .num_names = ARRAY_SIZE(pci224_boards),
};
COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table);
@@ -444,7 +446,7 @@ COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table);
* Called from the 'insn_write' function to perform a single write.
*/
static void
-pci224_ao_set_data(struct comedi_device * dev, int chan, int range, unsigned int data)
+pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int data)
{
unsigned short mangled;
@@ -477,8 +479,8 @@ pci224_ao_set_data(struct comedi_device * dev, int chan, int range, unsigned int
* 'insn_write' function for AO subdevice.
*/
static int
-pci224_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan, range;
@@ -504,8 +506,8 @@ pci224_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
* command.
*/
static int
-pci224_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -532,7 +534,7 @@ pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
/*
* Kills a command running on the AO subdevice.
*/
-static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci224_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
@@ -540,7 +542,7 @@ static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice *
return;
}
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
/* Kill the interrupts. */
devpriv->intsce = 0;
outb(0, devpriv->iobase1 + PCI224_INT_SCE);
@@ -556,10 +558,10 @@ static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice *
* routine.
*/
while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
}
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
/* Reconfigure DAC for insn_write usage. */
outw(0, dev->iobase + PCI224_DACCEN); /* Disable channels. */
devpriv->daccon = COMBINE(devpriv->daccon,
@@ -572,7 +574,7 @@ static void pci224_ao_stop(struct comedi_device * dev, struct comedi_subdevice *
/*
* Handles start of acquisition for the AO subdevice.
*/
-static void pci224_ao_start(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci224_ao_start(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned long flags;
@@ -585,21 +587,21 @@ static void pci224_ao_start(struct comedi_device * dev, struct comedi_subdevice
comedi_event(dev, s);
} else {
/* Enable interrupts. */
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
if (cmd->stop_src == TRIG_EXT) {
devpriv->intsce = PCI224_INTR_EXT | PCI224_INTR_DAC;
} else {
devpriv->intsce = PCI224_INTR_DAC;
}
outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE);
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
}
}
/*
* Handles interrupts from the DAC FIFO.
*/
-static void pci224_ao_handle_fifo(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int num_scans;
@@ -653,7 +655,7 @@ static void pci224_ao_handle_fifo(struct comedi_device * dev, struct comedi_subd
/* Nothing left to put in the FIFO. */
pci224_ao_stop(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW;
- rt_printk(KERN_ERR "comedi%d: "
+ printk(KERN_ERR "comedi%d: "
"AO buffer underrun\n", dev->minor);
}
}
@@ -728,7 +730,7 @@ static void pci224_ao_handle_fifo(struct comedi_device * dev, struct comedi_subd
* Internal trigger function to start acquisition on AO subdevice.
*/
static int
-pci224_ao_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s,
+pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
if (trignum != 0)
@@ -748,7 +750,7 @@ pci224_ao_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s,
* 'do_cmdtest' function for AO subdevice.
*/
static int
-pci224_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struct comedi_cmd * cmd)
+pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -1015,7 +1017,7 @@ pci224_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struc
/*
* 'do_cmd' function for AO subdevice.
*/
-static int pci224_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int range;
@@ -1153,16 +1155,16 @@ static int pci224_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s
*/
switch (cmd->start_src) {
case TRIG_INT:
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
s->async->inttrig = &pci224_ao_inttrig_start;
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
break;
case TRIG_EXT:
/* Enable external interrupt trigger to start acquisition. */
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
devpriv->intsce |= PCI224_INTR_EXT;
outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE);
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
break;
}
@@ -1172,7 +1174,7 @@ static int pci224_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s
/*
* 'cancel' function for AO subdevice.
*/
-static int pci224_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci224_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
pci224_ao_stop(dev, s);
return 0;
@@ -1182,7 +1184,7 @@ static int pci224_ao_cancel(struct comedi_device * dev, struct comedi_subdevice
* 'munge' data for AO command.
*/
static void
-pci224_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s, void *data,
+pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data,
unsigned int num_bytes, unsigned int chan_index)
{
struct comedi_async *async = s->async;
@@ -1212,7 +1214,7 @@ pci224_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s, void *d
/*
* Interrupt handler.
*/
-static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t pci224_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = &dev->subdevices[0];
@@ -1225,14 +1227,14 @@ static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG)
intstat = inb(devpriv->iobase1 + PCI224_INT_SCE) & 0x3F;
if (intstat) {
retval = 1;
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
valid_intstat = devpriv->intsce & intstat;
/* Temporarily disable interrupt sources. */
curenab = devpriv->intsce & ~intstat;
outb(curenab, devpriv->iobase1 + PCI224_INT_SCE);
devpriv->intr_running = 1;
devpriv->intr_cpuid = THISCPU;
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
if (valid_intstat != 0) {
cmd = &s->async->cmd;
if (valid_intstat & PCI224_INTR_EXT) {
@@ -1248,13 +1250,13 @@ static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG)
}
}
/* Reenable interrupt sources. */
- comedi_spin_lock_irqsave(&devpriv->ao_spinlock, flags);
+ spin_lock_irqsave(&devpriv->ao_spinlock, flags);
if (curenab != devpriv->intsce) {
outb(devpriv->intsce,
devpriv->iobase1 + PCI224_INT_SCE);
}
devpriv->intr_running = 0;
- comedi_spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
}
return IRQ_RETVAL(retval);
}
@@ -1264,7 +1266,7 @@ static irqreturn_t pci224_interrupt(int irq, void *d PT_REGS_ARG)
* bus and slot.
*/
static int
-pci224_find_pci(struct comedi_device * dev, int bus, int slot,
+pci224_find_pci(struct comedi_device *dev, int bus, int slot,
struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -1323,7 +1325,7 @@ pci224_find_pci(struct comedi_device * dev, int bus, int slot,
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
struct pci_dev *pci_dev;
@@ -1336,16 +1338,20 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i
bus = it->options[0];
slot = it->options[1];
- if ((ret = alloc_private(dev, sizeof(struct pci224_private))) < 0) {
+ ret = alloc_private(dev, sizeof(struct pci224_private));
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
}
- if ((ret = pci224_find_pci(dev, bus, slot, &pci_dev)) < 0)
+
+ ret = pci224_find_pci(dev, bus, slot, &pci_dev);
+ if (ret < 0)
return ret;
- devpriv->pci_dev = pci_dev;
- if ((ret = comedi_pci_enable(pci_dev, DRIVER_NAME)) < 0) {
+ devpriv->pci_dev = pci_dev;
+ ret = comedi_pci_enable(pci_dev, DRIVER_NAME);
+ if (ret < 0) {
printk(KERN_ERR
"comedi%d: error! cannot enable PCI device "
"and request regions!\n", dev->minor);
@@ -1392,7 +1398,8 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->iobase + PCI224_DACCON);
/* Allocate subdevices. There is only one! */
- if ((ret = alloc_subdevices(dev, 1)) < 0) {
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
dev->minor);
return ret;
@@ -1471,8 +1478,8 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->board_name = thisboard->name;
if (irq) {
- ret = comedi_request_irq(irq, pci224_interrupt, IRQF_SHARED,
- DRIVER_NAME, dev);
+ ret = request_irq(irq, pci224_interrupt, IRQF_SHARED,
+ DRIVER_NAME, dev);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! "
"unable to allocate irq %u\n", dev->minor, irq);
@@ -1503,12 +1510,12 @@ static int pci224_attach(struct comedi_device * dev, struct comedi_devconfig * i
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pci224_detach(struct comedi_device * dev)
+static int pci224_detach(struct comedi_device *dev)
{
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, DRIVER_NAME);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev->subdevices) {
struct comedi_subdevice *s;
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 0c9e5737e100..21133f068bf3 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -187,9 +187,11 @@ Extra triggered scan functionality, interrupt bug-fix added by Steve Sharples.
Support for PCI230+/260+, more triggered scan functionality, and workarounds
for (or detection of) various hardware problems added by Ian Abbott.
*/
+
#include "../comedidev.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include "comedi_pci.h"
#include "8253.h"
@@ -455,46 +457,46 @@ struct pci230_board {
};
static const struct pci230_board pci230_boards[] = {
{
- name: "pci230+",
- id: PCI_DEVICE_ID_PCI230,
- ai_chans:16,
- ai_bits: 16,
- ao_chans:2,
- ao_bits: 12,
- have_dio:1,
- min_hwver:1,
+ .name = "pci230+",
+ .id = PCI_DEVICE_ID_PCI230,
+ .ai_chans = 16,
+ .ai_bits = 16,
+ .ao_chans = 2,
+ .ao_bits = 12,
+ .have_dio = 1,
+ .min_hwver = 1,
},
{
- name: "pci260+",
- id: PCI_DEVICE_ID_PCI260,
- ai_chans:16,
- ai_bits: 16,
- ao_chans:0,
- ao_bits: 0,
- have_dio:0,
- min_hwver:1,
+ .name = "pci260+",
+ .id = PCI_DEVICE_ID_PCI260,
+ .ai_chans = 16,
+ .ai_bits = 16,
+ .ao_chans = 0,
+ .ao_bits = 0,
+ .have_dio = 0,
+ .min_hwver = 1,
},
{
- name: "pci230",
- id: PCI_DEVICE_ID_PCI230,
- ai_chans:16,
- ai_bits: 12,
- ao_chans:2,
- ao_bits: 12,
- have_dio:1,
+ .name = "pci230",
+ .id = PCI_DEVICE_ID_PCI230,
+ .ai_chans = 16,
+ .ai_bits = 12,
+ .ao_chans = 2,
+ .ao_bits = 12,
+ .have_dio = 1,
},
{
- name: "pci260",
- id: PCI_DEVICE_ID_PCI260,
- ai_chans:16,
- ai_bits: 12,
- ao_chans:0,
- ao_bits: 0,
- have_dio:0,
+ .name = "pci260",
+ .id = PCI_DEVICE_ID_PCI260,
+ .ai_chans = 16,
+ .ai_bits = 12,
+ .ao_chans = 0,
+ .ao_bits = 0,
+ .have_dio = 0,
},
{
- name: "amplc_pci230", /* Wildcard matches any above */
- id: PCI_DEVICE_ID_INVALID,
+ .name = "amplc_pci230", /* Wildcard matches any above */
+ .id = PCI_DEVICE_ID_INVALID,
},
};
@@ -601,46 +603,46 @@ static const unsigned char pci230_ao_bipolar[2] = { 0, 1 };
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci230_detach(struct comedi_device * dev);
+static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci230_detach(struct comedi_device *dev);
static struct comedi_driver driver_amplc_pci230 = {
- driver_name:"amplc_pci230",
- module:THIS_MODULE,
- attach:pci230_attach,
- detach:pci230_detach,
- board_name:&pci230_boards[0].name,
- offset:sizeof(pci230_boards[0]),
- num_names:sizeof(pci230_boards) / sizeof(pci230_boards[0]),
+ .driver_name = "amplc_pci230",
+ .module = THIS_MODULE,
+ .attach = pci230_attach,
+ .detach = pci230_detach,
+ .board_name = &pci230_boards[0].name,
+ .offset = sizeof(pci230_boards[0]),
+ .num_names = ARRAY_SIZE(pci230_boards),
};
COMEDI_PCI_INITCLEANUP(driver_amplc_pci230, pci230_pci_table);
-static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pci230_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pci230_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static void pci230_ct_setup_ns_mode(struct comedi_device * dev, unsigned int ct,
+static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pci230_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
unsigned int mode, uint64_t ns, unsigned int round);
static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round);
-static void pci230_cancel_ct(struct comedi_device * dev, unsigned int ct);
-static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG);
-static int pci230_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int pci230_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pci230_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice * s);
-static void pci230_handle_ao_nofifo(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pci230_handle_ao_fifo(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pci230_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int pci230_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pci230_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice * s);
-static void pci230_handle_ai(struct comedi_device * dev, struct comedi_subdevice * s);
-
-static short pci230_ai_read(struct comedi_device * dev)
+static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct);
+static irqreturn_t pci230_interrupt(int irq, void *d);
+static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pci230_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s);
+static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pci230_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s);
+static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s);
+
+static short pci230_ai_read(struct comedi_device *dev)
{
/* Read sample. */
short data = (short) inw(dev->iobase + PCI230_ADCDATA);
@@ -658,7 +660,7 @@ static short pci230_ai_read(struct comedi_device * dev)
return data;
}
-static inline unsigned short pci230_ao_mangle_datum(struct comedi_device * dev,
+static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev,
short datum)
{
/* If a bipolar range was specified, mangle it (straight binary->twos
@@ -674,7 +676,7 @@ static inline unsigned short pci230_ao_mangle_datum(struct comedi_device * dev,
return (unsigned short)datum;
}
-static inline void pci230_ao_write_nofifo(struct comedi_device * dev, short datum,
+static inline void pci230_ao_write_nofifo(struct comedi_device *dev, short datum,
unsigned int chan)
{
/* Store unmangled datum to be read back later. */
@@ -685,7 +687,7 @@ static inline void pci230_ao_write_nofifo(struct comedi_device * dev, short datu
? PCI230_DACOUT1 : PCI230_DACOUT2));
}
-static inline void pci230_ao_write_fifo(struct comedi_device * dev, short datum,
+static inline void pci230_ao_write_fifo(struct comedi_device *dev, short datum,
unsigned int chan)
{
/* Store unmangled datum to be read back later. */
@@ -702,7 +704,7 @@ static inline void pci230_ao_write_fifo(struct comedi_device * dev, short datum,
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase1, iobase2;
@@ -874,8 +876,8 @@ static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->iobase + PCI230_ADCCON);
/* Register the interrupt handler. */
- irq_hdl = comedi_request_irq(devpriv->pci_dev->irq, pci230_interrupt,
- IRQF_SHARED, "amplc_pci230", dev);
+ irq_hdl = request_irq(devpriv->pci_dev->irq, pci230_interrupt,
+ IRQF_SHARED, "amplc_pci230", dev);
if (irq_hdl < 0) {
printk("comedi%d: unable to register irq, "
"commands will not be available %d\n", dev->minor,
@@ -959,7 +961,7 @@ static int pci230_attach(struct comedi_device * dev, struct comedi_devconfig * i
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pci230_detach(struct comedi_device * dev)
+static int pci230_detach(struct comedi_device *dev)
{
printk("comedi%d: amplc_pci230: remove\n", dev->minor);
@@ -968,7 +970,7 @@ static int pci230_detach(struct comedi_device * dev)
subdev_8255_cleanup(dev, dev->subdevices + 2);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->pci_dev) {
@@ -982,7 +984,7 @@ static int pci230_detach(struct comedi_device * dev)
return 0;
}
-static int get_resources(struct comedi_device * dev, unsigned int res_mask,
+static int get_resources(struct comedi_device *dev, unsigned int res_mask,
unsigned char owner)
{
int ok;
@@ -993,7 +995,7 @@ static int get_resources(struct comedi_device * dev, unsigned int res_mask,
ok = 1;
claimed = 0;
- comedi_spin_lock_irqsave(&devpriv->res_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->res_spinlock, irqflags);
for (b = 1, i = 0; (i < NUM_RESOURCES)
&& (res_mask != 0); b <<= 1, i++) {
if ((res_mask & b) != 0) {
@@ -1014,24 +1016,24 @@ static int get_resources(struct comedi_device * dev, unsigned int res_mask,
}
}
}
- comedi_spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags);
return ok;
}
-static inline int get_one_resource(struct comedi_device * dev, unsigned int resource,
+static inline int get_one_resource(struct comedi_device *dev, unsigned int resource,
unsigned char owner)
{
return get_resources(dev, (1U << resource), owner);
}
-static void put_resources(struct comedi_device * dev, unsigned int res_mask,
+static void put_resources(struct comedi_device *dev, unsigned int res_mask,
unsigned char owner)
{
unsigned int i;
unsigned int b;
unsigned long irqflags;
- comedi_spin_lock_irqsave(&devpriv->res_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->res_spinlock, irqflags);
for (b = 1, i = 0; (i < NUM_RESOURCES)
&& (res_mask != 0); b <<= 1, i++) {
if ((res_mask & b) != 0) {
@@ -1041,16 +1043,16 @@ static void put_resources(struct comedi_device * dev, unsigned int res_mask,
}
}
}
- comedi_spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags);
}
-static inline void put_one_resource(struct comedi_device * dev, unsigned int resource,
+static inline void put_one_resource(struct comedi_device *dev, unsigned int resource,
unsigned char owner)
{
put_resources(dev, (1U << resource), owner);
}
-static inline void put_all_resources(struct comedi_device * dev, unsigned char owner)
+static inline void put_all_resources(struct comedi_device *dev, unsigned char owner)
{
put_resources(dev, (1U << NUM_RESOURCES) - 1, owner);
}
@@ -1058,8 +1060,8 @@ static inline void put_all_resources(struct comedi_device * dev, unsigned char o
/*
* COMEDI_SUBD_AI instruction;
*/
-static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int n, i;
unsigned int chan, range, aref;
@@ -1143,12 +1145,12 @@ static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
status = inw(dev->iobase + PCI230_ADCCON);
if (!(status & PCI230_ADC_FIFO_EMPTY))
break;
- comedi_udelay(1);
+ udelay(1);
}
if (i == TIMEOUT) {
- /* rt_printk() should be used instead of printk()
+ /* printk() should be used instead of printk()
* whenever the code can be called from real-time. */
- rt_printk("timeout\n");
+ printk("timeout\n");
return -ETIMEDOUT;
}
@@ -1163,8 +1165,8 @@ static int pci230_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
/*
* COMEDI_SUBD_AO instructions;
*/
-static int pci230_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci230_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan, range;
@@ -1191,8 +1193,8 @@ static int pci230_ao_winsn(struct comedi_device * dev, struct comedi_subdevice *
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int pci230_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -1203,8 +1205,8 @@ static int pci230_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice *
return i;
}
-static int pci230_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -1416,20 +1418,20 @@ static int pci230_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pci230_ao_inttrig_scan_begin(struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned int trig_num)
+static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trig_num)
{
unsigned long irqflags;
if (trig_num != 0)
return -EINVAL;
- comedi_spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
if (test_bit(AO_CMD_STARTED, &devpriv->state)) {
/* Perform scan. */
if (devpriv->hwver < 2) {
/* Not using DAC FIFO. */
- comedi_spin_unlock_irqrestore(&devpriv->
+ spin_unlock_irqrestore(&devpriv->
ao_stop_spinlock, irqflags);
pci230_handle_ao_nofifo(dev, s);
comedi_event(dev, s);
@@ -1437,18 +1439,18 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device * dev,
/* Using DAC FIFO. */
/* Read DACSWTRIG register to trigger conversion. */
inw(dev->iobase + PCI230P2_DACSWTRIG);
- comedi_spin_unlock_irqrestore(&devpriv->
+ spin_unlock_irqrestore(&devpriv->
ao_stop_spinlock, irqflags);
}
/* Delay. Should driver be responsible for this? */
/* XXX TODO: See if DAC busy bit can be used. */
- comedi_udelay(8);
+ udelay(8);
}
return 1;
}
-static void pci230_ao_start(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci230_ao_start(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -1506,13 +1508,13 @@ static void pci230_ao_start(struct comedi_device * dev, struct comedi_subdevice
if (devpriv->hwver < 2) {
/* Not using DAC FIFO. */
/* Enable CT1 timer interrupt. */
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock,
+ spin_lock_irqsave(&devpriv->isr_spinlock,
irqflags);
devpriv->int_en |= PCI230_INT_ZCLK_CT1;
devpriv->ier |= PCI230_INT_ZCLK_CT1;
outb(devpriv->ier,
devpriv->iobase1 + PCI230_INT_SCE);
- comedi_spin_unlock_irqrestore(&devpriv->
+ spin_unlock_irqrestore(&devpriv->
isr_spinlock, irqflags);
}
/* Set CT1 gate high to start counting. */
@@ -1525,18 +1527,18 @@ static void pci230_ao_start(struct comedi_device * dev, struct comedi_subdevice
}
if (devpriv->hwver >= 2) {
/* Using DAC FIFO. Enable DAC FIFO interrupt. */
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock,
+ spin_lock_irqsave(&devpriv->isr_spinlock,
irqflags);
devpriv->int_en |= PCI230P2_INT_DAC;
devpriv->ier |= PCI230P2_INT_DAC;
outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock,
+ spin_unlock_irqrestore(&devpriv->isr_spinlock,
irqflags);
}
}
}
-static int pci230_ao_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci230_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trig_num)
{
if (trig_num != 0)
@@ -1548,7 +1550,7 @@ static int pci230_ao_inttrig_start(struct comedi_device * dev, struct comedi_sub
return 1;
}
-static int pci230_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned short daccon;
unsigned int range;
@@ -1624,7 +1626,7 @@ static int pci230_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int pci230_ai_check_scan_period(struct comedi_cmd * cmd)
+static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
{
unsigned int min_scan_period, chanlist_len;
int err = 0;
@@ -1648,8 +1650,8 @@ static int pci230_ai_check_scan_period(struct comedi_cmd * cmd)
return !err;
}
-static int pci230_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -2034,8 +2036,8 @@ static int pci230_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static void pci230_ai_update_fifo_trigger_level(struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int scanlen = cmd->scan_end_arg;
@@ -2078,7 +2080,7 @@ static void pci230_ai_update_fifo_trigger_level(struct comedi_device * dev,
}
}
-static int pci230_ai_inttrig_convert(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci230_ai_inttrig_convert(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trig_num)
{
unsigned long irqflags;
@@ -2086,7 +2088,7 @@ static int pci230_ai_inttrig_convert(struct comedi_device * dev, struct comedi_s
if (trig_num != 0)
return -EINVAL;
- comedi_spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
if (test_bit(AI_CMD_STARTED, &devpriv->state)) {
unsigned int delayus;
@@ -2110,19 +2112,19 @@ static int pci230_ai_inttrig_convert(struct comedi_device * dev, struct comedi_s
/* single-ended or PCI230+/260+ */
delayus = 4;
}
- comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock,
+ spin_unlock_irqrestore(&devpriv->ai_stop_spinlock,
irqflags);
- comedi_udelay(delayus);
+ udelay(delayus);
} else {
- comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock,
+ spin_unlock_irqrestore(&devpriv->ai_stop_spinlock,
irqflags);
}
return 1;
}
-static int pci230_ai_inttrig_scan_begin(struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned int trig_num)
+static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trig_num)
{
unsigned long irqflags;
unsigned char zgat;
@@ -2130,7 +2132,7 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device * dev,
if (trig_num != 0)
return -EINVAL;
- comedi_spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
if (test_bit(AI_CMD_STARTED, &devpriv->state)) {
/* Trigger scan by waggling CT0 gate source. */
zgat = GAT_CONFIG(0, GAT_GND);
@@ -2138,12 +2140,12 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device * dev,
zgat = GAT_CONFIG(0, GAT_VCC);
outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE);
}
- comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
return 1;
}
-static void pci230_ai_start(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci230_ai_start(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long irqflags;
unsigned short conv;
@@ -2158,11 +2160,11 @@ static void pci230_ai_start(struct comedi_device * dev, struct comedi_subdevice
comedi_event(dev, s);
} else {
/* Enable ADC FIFO trigger level interrupt. */
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
devpriv->int_en |= PCI230_INT_ADC;
devpriv->ier |= PCI230_INT_ADC;
outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
/* Update conversion trigger source which is currently set
* to CT2 output, which is currently stuck high. */
@@ -2280,7 +2282,7 @@ static void pci230_ai_start(struct comedi_device * dev, struct comedi_subdevice
}
}
-static int pci230_ai_inttrig_start(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci230_ai_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trig_num)
{
if (trig_num != 0)
@@ -2292,7 +2294,7 @@ static int pci230_ai_inttrig_start(struct comedi_device * dev, struct comedi_sub
return 1;
}
-static int pci230_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned int i, chan, range, diff;
unsigned int res_mask;
@@ -2424,7 +2426,7 @@ static int pci230_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
* FIFO reset (above) and the second FIFO reset (below). Setting the
* channel gains and scan list _before_ the first FIFO reset also
* helps, though only slightly. */
- comedi_udelay(25);
+ udelay(25);
/* Reset FIFO again. */
outw(adccon | PCI230_ADC_FIFO_RESET, dev->iobase + PCI230_ADCCON);
@@ -2532,7 +2534,7 @@ static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round)
return;
}
-static void pci230_ct_setup_ns_mode(struct comedi_device * dev, unsigned int ct,
+static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
unsigned int mode, uint64_t ns, unsigned int round)
{
unsigned int clk_src;
@@ -2551,7 +2553,7 @@ static void pci230_ct_setup_ns_mode(struct comedi_device * dev, unsigned int ct,
i8254_write(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, count);
}
-static void pci230_cancel_ct(struct comedi_device * dev, unsigned int ct)
+static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct)
{
i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct,
I8254_MODE1);
@@ -2559,7 +2561,7 @@ static void pci230_cancel_ct(struct comedi_device * dev, unsigned int ct)
}
/* Interrupt handler */
-static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t pci230_interrupt(int irq, void *d)
{
unsigned char status_int, valid_status_int;
struct comedi_device *dev = (struct comedi_device *) d;
@@ -2573,7 +2575,7 @@ static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_NONE;
}
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
valid_status_int = devpriv->int_en & status_int;
/* Disable triggered interrupts.
* (Only those interrupts that need re-enabling, are, later in the
@@ -2582,7 +2584,7 @@ static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG)
outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
devpriv->intr_running = 1;
devpriv->intr_cpuid = THISCPU;
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
/*
* Check the source of interrupt and handle it.
@@ -2611,18 +2613,18 @@ static irqreturn_t pci230_interrupt(int irq, void *d PT_REGS_ARG)
}
/* Reenable interrupts. */
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
if (devpriv->ier != devpriv->int_en) {
devpriv->ier = devpriv->int_en;
outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
}
devpriv->intr_running = 0;
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
return IRQ_HANDLED;
}
-static void pci230_handle_ao_nofifo(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s)
{
short data;
int i, ret;
@@ -2659,7 +2661,7 @@ static void pci230_handle_ao_nofifo(struct comedi_device * dev, struct comedi_su
/* Loads DAC FIFO (if using it) from buffer. */
/* Returns 0 if AO finished due to completion or error, 1 if still going. */
-static int pci230_handle_ao_fifo(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -2762,7 +2764,7 @@ static int pci230_handle_ao_fifo(struct comedi_device * dev, struct comedi_subde
return running;
}
-static void pci230_handle_ai(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned int events = 0;
unsigned int status_fifo;
@@ -2861,16 +2863,16 @@ static void pci230_handle_ai(struct comedi_device * dev, struct comedi_subdevice
}
}
-static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long irqflags;
unsigned char intsrc;
int started;
struct comedi_cmd *cmd;
- comedi_spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
started = test_and_clear_bit(AO_CMD_STARTED, &devpriv->state);
- comedi_spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
if (!started) {
return;
}
@@ -2891,17 +2893,17 @@ static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice *
}
/* Disable interrupt and wait for interrupt routine to finish running
* unless we are called from the interrupt routine. */
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
devpriv->int_en &= ~intsrc;
while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
}
if (devpriv->ier != devpriv->int_en) {
devpriv->ier = devpriv->int_en;
outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
}
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
if (devpriv->hwver >= 2) {
/* Using DAC FIFO. Reset FIFO, clear underrun error,
@@ -2916,21 +2918,21 @@ static void pci230_ao_stop(struct comedi_device * dev, struct comedi_subdevice *
put_all_resources(dev, OWNER_AOCMD);
}
-static int pci230_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci230_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
pci230_ao_stop(dev, s);
return 0;
}
-static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long irqflags;
struct comedi_cmd *cmd;
int started;
- comedi_spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
started = test_and_clear_bit(AI_CMD_STARTED, &devpriv->state);
- comedi_spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
if (!started) {
return;
}
@@ -2945,19 +2947,19 @@ static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice *
pci230_cancel_ct(dev, 0);
}
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
/* Disable ADC interrupt and wait for interrupt routine to finish
* running unless we are called from the interrupt routine. */
devpriv->int_en &= ~PCI230_INT_ADC;
while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
- comedi_spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
}
if (devpriv->ier != devpriv->int_en) {
devpriv->ier = devpriv->int_en;
outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
}
- comedi_spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
/* Reset FIFO, disable FIFO and set start conversion source to none.
* Keep se/diff and bip/uni settings */
@@ -2970,7 +2972,7 @@ static void pci230_ai_stop(struct comedi_device * dev, struct comedi_subdevice *
put_all_resources(dev, OWNER_AICMD);
}
-static int pci230_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci230_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
pci230_ai_stop(dev, s);
return 0;
diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c
index 2efffb14610d..b204793040e2 100644
--- a/drivers/staging/comedi/drivers/c6xdigio.c
+++ b/drivers/staging/comedi/drivers/c6xdigio.c
@@ -77,7 +77,7 @@ struct pwmbitstype {
unsigned sb4:2;
};
union pwmcmdtype {
- unsigned cmd; // assuming here that int is 32bit
+ unsigned cmd; /* assuming here that int is 32bit */
struct pwmbitstype bits;
};
struct encbitstype {
@@ -97,20 +97,20 @@ union encvaluetype {
#define C6XDIGIO_TIME_OUT 20
-static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int c6xdigio_detach(struct comedi_device * dev);
+static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int c6xdigio_detach(struct comedi_device *dev);
struct comedi_driver driver_c6xdigio = {
- driver_name:"c6xdigio",
- module:THIS_MODULE,
- attach:c6xdigio_attach,
- detach:c6xdigio_detach,
+ .driver_name = "c6xdigio",
+ .module = THIS_MODULE,
+ .attach = c6xdigio_attach,
+ .detach = c6xdigio_detach,
};
static void C6X_pwmInit(unsigned long baseAddr)
{
int timeout = 0;
-//printk("Inside C6X_pwmInit\n");
+/* printk("Inside C6X_pwmInit\n"); */
WriteByteToHwPort(baseAddr, 0x70);
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
@@ -148,7 +148,7 @@ static void C6X_pwmOutput(unsigned long baseAddr, unsigned channel, int value)
int timeout = 0;
unsigned tmp;
- //printk("Inside C6X_pwmOutput\n");
+ /* printk("Inside C6X_pwmOutput\n"); */
pwm.cmd = value;
if (pwm.cmd > 498)
@@ -158,7 +158,7 @@ static void C6X_pwmOutput(unsigned long baseAddr, unsigned channel, int value)
if (channel == 0) {
ppcmd = 0x28;
- } else { // if channel == 1
+ } else { /* if channel == 1 */
ppcmd = 0x30;
} /* endif */
@@ -216,7 +216,7 @@ static int C6X_encInput(unsigned long baseAddr, unsigned channel)
int timeout = 0;
int tmp;
- //printk("Inside C6X_encInput\n");
+ /* printk("Inside C6X_encInput\n"); */
enc.value = 0;
if (channel == 0) {
@@ -304,14 +304,14 @@ static int C6X_encInput(unsigned long baseAddr, unsigned channel)
timeout++;
}
- return (enc.value ^ 0x800000);
+ return enc.value ^ 0x800000;
}
static void C6X_encResetAll(unsigned long baseAddr)
{
unsigned timeout = 0;
-//printk("Inside C6X_encResetAll\n");
+/* printk("Inside C6X_encResetAll\n"); */
WriteByteToHwPort(baseAddr, 0x68);
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
@@ -338,20 +338,20 @@ static void C6X_encResetAll(unsigned long baseAddr)
}
}
-static int c6xdigio_pwmo_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int c6xdigio_pwmo_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
printk("c6xdigio_pwmo_insn_read %x\n", insn->n);
return insn->n;
}
-static int c6xdigio_pwmo_insn_write(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int c6xdigio_pwmo_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
- // printk("c6xdigio_pwmo_insn_write %x\n", insn->n);
+ /* printk("c6xdigio_pwmo_insn_write %x\n", insn->n); */
for (i = 0; i < insn->n; i++) {
C6X_pwmOutput(dev->iobase, chan, data[i]);
/* devpriv->ao_readback[chan] = data[i]; */
@@ -359,32 +359,30 @@ static int c6xdigio_pwmo_insn_write(struct comedi_device * dev,
return i;
}
-//static int c6xdigio_ei_init_insn_read(struct comedi_device *dev,
-// struct comedi_subdevice *s,
-// struct comedi_insn *insn,
-// unsigned int *data)
-//{
-// printk("c6xdigio_ei_init_insn_read %x\n", insn->n);
-// return insn->n;
-//}
-
-//static int c6xdigio_ei_init_insn_write(struct comedi_device *dev,
-// struct comedi_subdevice *s,
-// struct comedi_insn *insn,
-// unsigned int *data)
-//{
-// int i;
-// int chan = CR_CHAN(insn->chanspec);
-//
-// C6X_encResetAll( dev->iobase );
-//
-// return insn->n;
-//}
-
-static int c6xdigio_ei_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+/* static int c6xdigio_ei_init_insn_read(struct comedi_device *dev, */
+/* struct comedi_subdevice *s, */
+/* struct comedi_insn *insn, */
+/* unsigned int *data) */
+/* { */
+/* printk("c6xdigio_ei_init_insn_read %x\n", insn->n); */
+/* return insn->n; */
+/* } */
+
+/* static int c6xdigio_ei_init_insn_write(struct comedi_device *dev, */
+/* struct comedi_subdevice *s, */
+/* struct comedi_insn *insn, */
+/* unsigned int *data) */
+/* { */
+/* int i; */
+/* int chan = CR_CHAN(insn->chanspec); */
+/* *//* C6X_encResetAll( dev->iobase ); */
+/* *//* return insn->n; */
+/* } */
+
+static int c6xdigio_ei_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
- // printk("c6xdigio_ei__insn_read %x\n", insn->n);
+ /* printk("c6xdigio_ei__insn_read %x\n", insn->n); */
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -395,19 +393,19 @@ static int c6xdigio_ei_insn_read(struct comedi_device * dev,
return n;
}
-static void board_init(struct comedi_device * dev)
+static void board_init(struct comedi_device *dev)
{
- //printk("Inside board_init\n");
+ /* printk("Inside board_init\n"); */
C6X_pwmInit(dev->iobase);
C6X_encResetAll(dev->iobase);
}
-//static void board_halt(struct comedi_device *dev) {
-// C6X_pwmInit(dev->iobase);
-//}
+/* static void board_halt(struct comedi_device *dev) { */
+/* C6X_pwmInit(dev->iobase); */
+/* } */
/*
options[0] - I/O port
@@ -417,9 +415,9 @@ static void board_init(struct comedi_device * dev)
static const struct pnp_device_id c6xdigio_pnp_tbl[] = {
/* Standard LPT Printer Port */
- {.id = "PNP0400",.driver_data = 0},
+ {.id = "PNP0400", .driver_data = 0},
/* ECP Printer Port */
- {.id = "PNP0401",.driver_data = 0},
+ {.id = "PNP0401", .driver_data = 0},
{}
};
@@ -428,7 +426,7 @@ static struct pnp_driver c6xdigio_pnp_driver = {
.id_table = c6xdigio_pnp_tbl,
};
-static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int result = 0;
unsigned long iobase;
@@ -444,11 +442,11 @@ static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig *
dev->iobase = iobase;
dev->board_name = "c6xdigio";
- result = alloc_subdevices(dev, 2); // 3 with encoder_init write
+ result = alloc_subdevices(dev, 2); /* 3 with encoder_init write */
if (result < 0)
return result;
- // Make sure that PnP ports gets activated
+ /* Make sure that PnP ports gets activated */
pnp_register_driver(&c6xdigio_pnp_driver);
irq = it->options[1];
@@ -460,14 +458,14 @@ static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig *
s = dev->subdevices + 0;
/* pwm output subdevice */
- s->type = COMEDI_SUBD_AO; // Not sure what to put here
+ s->type = COMEDI_SUBD_AO; /* Not sure what to put here */
s->subdev_flags = SDF_WRITEABLE;
s->n_chan = 2;
/* s->trig[0] = c6xdigio_pwmo; */
s->insn_read = c6xdigio_pwmo_insn_read;
s->insn_write = c6xdigio_pwmo_insn_write;
s->maxdata = 500;
- s->range_table = &range_bipolar10; // A suitable lie
+ s->range_table = &range_bipolar10; /* A suitable lie */
s = dev->subdevices + 1;
/* encoder (counter) subdevice */
@@ -479,27 +477,27 @@ static int c6xdigio_attach(struct comedi_device * dev, struct comedi_devconfig *
s->maxdata = 0xffffff;
s->range_table = &range_unknown;
- // s = dev->subdevices + 2;
- // /* pwm output subdevice */
- // s->type = COMEDI_SUBD_COUNTER; // Not sure what to put here
- // s->subdev_flags = SDF_WRITEABLE;
- // s->n_chan = 1;
- // /* s->trig[0] = c6xdigio_ei_init; */
- // s->insn_read = c6xdigio_ei_init_insn_read;
- // s->insn_write = c6xdigio_ei_init_insn_write;
- // s->maxdata = 0xFFFF; // Really just a don't care
- // s->range_table = &range_unknown; // Not sure what to put here
-
- // I will call this init anyway but more than likely the DSP board will not be connect
- // when device driver is loaded.
+ /* s = dev->subdevices + 2; */
+ /* pwm output subdevice */
+ /* s->type = COMEDI_SUBD_COUNTER; // Not sure what to put here */
+ /* s->subdev_flags = SDF_WRITEABLE; */
+ /* s->n_chan = 1; */
+ /* s->trig[0] = c6xdigio_ei_init; */
+ /* s->insn_read = c6xdigio_ei_init_insn_read; */
+ /* s->insn_write = c6xdigio_ei_init_insn_write; */
+ /* s->maxdata = 0xFFFF; // Really just a don't care */
+ /* s->range_table = &range_unknown; // Not sure what to put here */
+
+ /* I will call this init anyway but more than likely the DSP board will not be connect */
+ /* when device driver is loaded. */
board_init(dev);
return 0;
}
-static int c6xdigio_detach(struct comedi_device * dev)
+static int c6xdigio_detach(struct comedi_device *dev)
{
-// board_halt(dev); // may not need this
+/* board_halt(dev); may not need this */
printk("comedi%d: c6xdigio: remove\n", dev->minor);
@@ -508,7 +506,7 @@ static int c6xdigio_detach(struct comedi_device * dev)
}
if (dev->irq) {
free_irq(dev->irq, dev);
- } // Not using IRQ so I am not sure if I need this
+ } /* Not using IRQ so I am not sure if I need this */
pnp_unregister_driver(&c6xdigio_pnp_driver);
return 0;
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index 0bfe4c954eb5..7af245b42e51 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -31,6 +31,7 @@ Status: experimental
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
#include <linux/pci.h>
@@ -61,19 +62,19 @@ struct das16cs_board {
};
static const struct das16cs_board das16cs_boards[] = {
{
- device_id:0x0000,/* unknown */
- name: "PC-CARD DAS16/16",
- n_ao_chans:0,
+ .device_id = 0x0000,/* unknown */
+ .name = "PC-CARD DAS16/16",
+ .n_ao_chans = 0,
},
{
- device_id:0x0039,
- name: "PC-CARD DAS16/16-AO",
- n_ao_chans:2,
+ .device_id = 0x0039,
+ .name = "PC-CARD DAS16/16-AO",
+ .n_ao_chans = 2,
},
{
- device_id:0x4009,
- name: "PCM-DAS16s/16",
- n_ao_chans:0,
+ .device_id = 0x4009,
+ .name = "PCM-DAS16s/16",
+ .n_ao_chans = 0,
},
};
@@ -89,13 +90,13 @@ struct das16cs_private {
};
#define devpriv ((struct das16cs_private *)dev->private)
-static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int das16cs_detach(struct comedi_device * dev);
+static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das16cs_detach(struct comedi_device *dev);
static struct comedi_driver driver_das16cs = {
- driver_name:"cb_das16_cs",
- module:THIS_MODULE,
- attach:das16cs_attach,
- detach:das16cs_detach,
+ .driver_name = "cb_das16_cs",
+ .module = THIS_MODULE,
+ .attach = das16cs_attach,
+ .detach = das16cs_detach,
};
static struct pcmcia_device *cur_dev = NULL;
@@ -108,26 +109,26 @@ static const struct comedi_lrange das16cs_ai_range = { 4, {
}
};
-static irqreturn_t das16cs_interrupt(int irq, void *d PT_REGS_ARG);
-static int das16cs_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16cs_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int das16cs_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16cs_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16cs_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16cs_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16cs_timer_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16cs_timer_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-
-static int get_prodid(struct comedi_device * dev, struct pcmcia_device *link)
+static irqreturn_t das16cs_interrupt(int irq, void *d);
+static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+
+static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
{
tuple_t tuple;
u_short buf[128];
@@ -165,7 +166,7 @@ static const struct das16cs_board *das16cs_probe(struct comedi_device * dev,
return NULL;
}
-static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pcmcia_device *link;
struct comedi_subdevice *s;
@@ -187,8 +188,8 @@ static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig *
}
printk("\n");
- ret = comedi_request_irq(link->irq.AssignedIRQ, das16cs_interrupt,
- IRQF_SHARED, "cb_das16_cs", dev);
+ ret = request_irq(link->irq.AssignedIRQ, das16cs_interrupt,
+ IRQF_SHARED, "cb_das16_cs", dev);
if (ret < 0) {
return ret;
}
@@ -265,20 +266,20 @@ static int das16cs_attach(struct comedi_device * dev, struct comedi_devconfig *
return 1;
}
-static int das16cs_detach(struct comedi_device * dev)
+static int das16cs_detach(struct comedi_device *dev)
{
printk("comedi%d: das16cs: remove\n", dev->minor);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
return 0;
}
-static irqreturn_t das16cs_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t das16cs_interrupt(int irq, void *d)
{
- //struct comedi_device *dev = d;
+ /* struct comedi_device *dev = d; */
return IRQ_HANDLED;
}
@@ -286,8 +287,8 @@ static irqreturn_t das16cs_interrupt(int irq, void *d PT_REGS_ARG)
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
-static int das16cs_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int to;
@@ -328,13 +329,13 @@ static int das16cs_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice
return i;
}
-static int das16cs_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
return -EINVAL;
}
-static int das16cs_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -489,8 +490,8 @@ static int das16cs_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
return 0;
}
-static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -503,7 +504,7 @@ static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
d = data[i];
outw(devpriv->status1, dev->iobase + 4);
- comedi_udelay(1);
+ udelay(1);
status1 = devpriv->status1 & ~0xf;
if (chan)
@@ -513,17 +514,17 @@ static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
/* printk("0x%04x\n",status1);*/
outw(status1, dev->iobase + 4);
- comedi_udelay(1);
+ udelay(1);
for (bit = 15; bit >= 0; bit--) {
int b = (d >> bit) & 0x1;
b <<= 1;
/* printk("0x%04x\n",status1 | b | 0x0000);*/
outw(status1 | b | 0x0000, dev->iobase + 4);
- comedi_udelay(1);
+ udelay(1);
/* printk("0x%04x\n",status1 | b | 0x0004);*/
outw(status1 | b | 0x0004, dev->iobase + 4);
- comedi_udelay(1);
+ udelay(1);
}
/* make high both DAC0CS and DAC1CS to load
new data and update analog output*/
@@ -535,8 +536,8 @@ static int das16cs_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int das16cs_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -552,8 +553,8 @@ static int das16cs_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int das16cs_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -572,8 +573,8 @@ static int das16cs_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
return 2;
}
-static int das16cs_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int bits;
@@ -610,14 +611,14 @@ static int das16cs_dio_insn_config(struct comedi_device * dev, struct comedi_sub
return insn->n;
}
-static int das16cs_timer_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return -EINVAL;
}
-static int das16cs_timer_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return -EINVAL;
}
@@ -766,15 +767,22 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
+
last_fn = GetFirstTuple;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0)
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret != 0)
goto cs_failed;
+
last_fn = GetTupleData;
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0)
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret != 0)
goto cs_failed;
+
last_fn = ParseTuple;
- if ((last_ret = pcmcia_parse_tuple(link, &tuple, &parse)) != 0)
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret != 0)
goto cs_failed;
+
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
@@ -792,13 +800,16 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
last_fn = GetFirstTuple;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret)
goto cs_failed;
+
while (1) {
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
if (pcmcia_get_tuple_data(link, &tuple))
goto next_entry;
- if (pcmcia_parse_tuple(link, &tuple, &parse))
+ if (pcmcia_parse_tuple(&tuple, &parse))
goto next_entry;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
@@ -844,7 +855,9 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
next_entry:
last_fn = GetNextTuple;
- if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_next_tuple(link, &tuple);
+ if (last_ret)
goto cs_failed;
}
@@ -855,7 +868,9 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
*/
if (link->conf.Attributes & CONF_ENABLE_IRQ) {
last_fn = RequestIRQ;
- if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0)
+
+ last_ret = pcmcia_request_irq(link, &link->irq);
+ if (last_ret)
goto cs_failed;
}
/*
@@ -864,7 +879,8 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
card and host interface into "Memory and IO" mode.
*/
last_fn = RequestConfiguration;
- if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0)
+ last_ret = pcmcia_request_configuration(link, &link->conf);
+ if (last_ret)
goto cs_failed;
/*
@@ -973,4 +989,4 @@ void __exit cleanup_module(void)
#else
COMEDI_INITCLEANUP(driver_das16cs);
-#endif //CONFIG_PCMCIA
+#endif /* CONFIG_PCMCIA */
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index fcc551651367..28212ad6461b 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -63,6 +63,7 @@ analog triggering on 1602 series
#include "../comedidev.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include "8253.h"
#include "8255.h"
@@ -70,14 +71,14 @@ analog triggering on 1602 series
#include "comedi_pci.h"
#include "comedi_fc.h"
-#undef CB_PCIDAS_DEBUG // disable debugging code
-//#define CB_PCIDAS_DEBUG // enable debugging code
+#undef CB_PCIDAS_DEBUG /* disable debugging code */
+/* #define CB_PCIDAS_DEBUG enable debugging code */
-// PCI vendor number of ComputerBoards/MeasurementComputing
+/* PCI vendor number of ComputerBoards/MeasurementComputing */
#define PCI_VENDOR_ID_CB 0x1307
-#define TIMER_BASE 100 // 10MHz master clock
-#define AI_BUFFER_SIZE 1024 // maximum fifo size of any supported board
-#define AO_BUFFER_SIZE 1024 // maximum fifo size of any supported board
+#define TIMER_BASE 100 /* 10MHz master clock */
+#define AI_BUFFER_SIZE 1024 /* maximum fifo size of any supported board */
+#define AO_BUFFER_SIZE 1024 /* maximum fifo size of any supported board */
#define NUM_CHANNELS_8800 8
#define NUM_CHANNELS_7376 1
#define NUM_CHANNELS_8402 2
@@ -85,71 +86,71 @@ analog triggering on 1602 series
/* PCI-DAS base addresses */
-// indices of base address regions
+/* indices of base address regions */
#define S5933_BADRINDEX 0
#define CONT_STAT_BADRINDEX 1
#define ADC_FIFO_BADRINDEX 2
#define PACER_BADRINDEX 3
#define AO_BADRINDEX 4
-// sizes of io regions
+/* sizes of io regions */
#define CONT_STAT_SIZE 10
#define ADC_FIFO_SIZE 4
#define PACER_SIZE 12
#define AO_SIZE 4
/* Control/Status registers */
-#define INT_ADCFIFO 0 // INTERRUPT / ADC FIFO register
-#define INT_EOS 0x1 // interrupt end of scan
-#define INT_FHF 0x2 // interrupt fifo half full
-#define INT_FNE 0x3 // interrupt fifo not empty
-#define INT_MASK 0x3 // mask of interrupt select bits
-#define INTE 0x4 // interrupt enable
-#define DAHFIE 0x8 // dac half full interrupt enable
-#define EOAIE 0x10 // end of aquisition interrupt enable
-#define DAHFI 0x20 // dac half full read status / write interrupt clear
-#define EOAI 0x40 // read end of acq. interrupt status / write clear
-#define INT 0x80 // read interrupt status / write clear
-#define EOBI 0x200 // read end of burst interrupt status
-#define ADHFI 0x400 // read half-full interrupt status
-#define ADNEI 0x800 // read fifo not empty interrupt latch status
-#define ADNE 0x1000 // read, fifo not empty (realtime, not latched) status
-#define DAEMIE 0x1000 // write, dac empty interrupt enable
-#define LADFUL 0x2000 // read fifo overflow / write clear
-#define DAEMI 0x4000 // dac fifo empty interrupt status / write clear
-
-#define ADCMUX_CONT 2 // ADC CHANNEL MUX AND CONTROL register
+#define INT_ADCFIFO 0 /* INTERRUPT / ADC FIFO register */
+#define INT_EOS 0x1 /* interrupt end of scan */
+#define INT_FHF 0x2 /* interrupt fifo half full */
+#define INT_FNE 0x3 /* interrupt fifo not empty */
+#define INT_MASK 0x3 /* mask of interrupt select bits */
+#define INTE 0x4 /* interrupt enable */
+#define DAHFIE 0x8 /* dac half full interrupt enable */
+#define EOAIE 0x10 /* end of aquisition interrupt enable */
+#define DAHFI 0x20 /* dac half full read status / write interrupt clear */
+#define EOAI 0x40 /* read end of acq. interrupt status / write clear */
+#define INT 0x80 /* read interrupt status / write clear */
+#define EOBI 0x200 /* read end of burst interrupt status */
+#define ADHFI 0x400 /* read half-full interrupt status */
+#define ADNEI 0x800 /* read fifo not empty interrupt latch status */
+#define ADNE 0x1000 /* read, fifo not empty (realtime, not latched) status */
+#define DAEMIE 0x1000 /* write, dac empty interrupt enable */
+#define LADFUL 0x2000 /* read fifo overflow / write clear */
+#define DAEMI 0x4000 /* dac fifo empty interrupt status / write clear */
+
+#define ADCMUX_CONT 2 /* ADC CHANNEL MUX AND CONTROL register */
#define BEGIN_SCAN(x) ((x) & 0xf)
#define END_SCAN(x) (((x) & 0xf) << 4)
#define GAIN_BITS(x) (((x) & 0x3) << 8)
-#define UNIP 0x800 // Analog front-end unipolar for range
-#define SE 0x400 // Inputs in single-ended mode
-#define PACER_MASK 0x3000 // pacer source bits
-#define PACER_INT 0x1000 // internal pacer
-#define PACER_EXT_FALL 0x2000 // external falling edge
-#define PACER_EXT_RISE 0x3000 // external rising edge
-#define EOC 0x4000 // adc not busy
-
-#define TRIG_CONTSTAT 4 // TRIGGER CONTROL/STATUS register
-#define SW_TRIGGER 0x1 // software start trigger
-#define EXT_TRIGGER 0x2 // external start trigger
-#define ANALOG_TRIGGER 0x3 // external analog trigger
-#define TRIGGER_MASK 0x3 // mask of bits that determine start trigger
-#define TGEN 0x10 // enable external start trigger
-#define BURSTE 0x20 // burst mode enable
-#define XTRCL 0x80 // clear external trigger
-
-#define CALIBRATION_REG 6 // CALIBRATION register
-#define SELECT_8800_BIT 0x100 // select 8800 caldac
-#define SELECT_TRIMPOT_BIT 0x200 // select ad7376 trim pot
-#define SELECT_DAC08_BIT 0x400 // select dac08 caldac
+#define UNIP 0x800 /* Analog front-end unipolar for range */
+#define SE 0x400 /* Inputs in single-ended mode */
+#define PACER_MASK 0x3000 /* pacer source bits */
+#define PACER_INT 0x1000 /* internal pacer */
+#define PACER_EXT_FALL 0x2000 /* external falling edge */
+#define PACER_EXT_RISE 0x3000 /* external rising edge */
+#define EOC 0x4000 /* adc not busy */
+
+#define TRIG_CONTSTAT 4 /* TRIGGER CONTROL/STATUS register */
+#define SW_TRIGGER 0x1 /* software start trigger */
+#define EXT_TRIGGER 0x2 /* external start trigger */
+#define ANALOG_TRIGGER 0x3 /* external analog trigger */
+#define TRIGGER_MASK 0x3 /* mask of bits that determine start trigger */
+#define TGEN 0x10 /* enable external start trigger */
+#define BURSTE 0x20 /* burst mode enable */
+#define XTRCL 0x80 /* clear external trigger */
+
+#define CALIBRATION_REG 6 /* CALIBRATION register */
+#define SELECT_8800_BIT 0x100 /* select 8800 caldac */
+#define SELECT_TRIMPOT_BIT 0x200 /* select ad7376 trim pot */
+#define SELECT_DAC08_BIT 0x400 /* select dac08 caldac */
#define CAL_SRC_BITS(x) (((x) & 0x7) << 11)
-#define CAL_EN_BIT 0x4000 // read calibration source instead of analog input channel 0
-#define SERIAL_DATA_IN_BIT 0x8000 // serial data stream going to 8800 and 7376
+#define CAL_EN_BIT 0x4000 /* read calibration source instead of analog input channel 0 */
+#define SERIAL_DATA_IN_BIT 0x8000 /* serial data stream going to 8800 and 7376 */
-#define DAC_CSR 0x8 // dac control and status register
+#define DAC_CSR 0x8 /* dac control and status register */
enum dac_csr_bits {
- DACEN = 0x2, // dac enable
- DAC_MODE_UPDATE_BOTH = 0x80, // update both dacs when dac0 is written
+ DACEN = 0x2, /* dac enable */
+ DAC_MODE_UPDATE_BOTH = 0x80, /* update both dacs when dac0 is written */
};
static inline unsigned int DAC_RANGE(unsigned int channel, unsigned int range)
{
@@ -160,42 +161,42 @@ static inline unsigned int DAC_RANGE_MASK(unsigned int channel)
return 0x3 << (8 + 2 * (channel & 0x1));
};
-// bits for 1602 series only
+/* bits for 1602 series only */
enum dac_csr_bits_1602 {
- DAC_EMPTY = 0x1, // dac fifo empty, read, write clear
- DAC_START = 0x4, // start/arm dac fifo operations
- DAC_PACER_MASK = 0x18, // bits that set dac pacer source
- DAC_PACER_INT = 0x8, // dac internal pacing
- DAC_PACER_EXT_FALL = 0x10, // dac external pacing, falling edge
- DAC_PACER_EXT_RISE = 0x18, // dac external pacing, rising edge
+ DAC_EMPTY = 0x1, /* dac fifo empty, read, write clear */
+ DAC_START = 0x4, /* start/arm dac fifo operations */
+ DAC_PACER_MASK = 0x18, /* bits that set dac pacer source */
+ DAC_PACER_INT = 0x8, /* dac internal pacing */
+ DAC_PACER_EXT_FALL = 0x10, /* dac external pacing, falling edge */
+ DAC_PACER_EXT_RISE = 0x18, /* dac external pacing, rising edge */
};
static inline unsigned int DAC_CHAN_EN(unsigned int channel)
{
- return 1 << (5 + (channel & 0x1)); // enable channel 0 or 1
+ return 1 << (5 + (channel & 0x1)); /* enable channel 0 or 1 */
};
/* analog input fifo */
-#define ADCDATA 0 // ADC DATA register
-#define ADCFIFOCLR 2 // ADC FIFO CLEAR
+#define ADCDATA 0 /* ADC DATA register */
+#define ADCFIFOCLR 2 /* ADC FIFO CLEAR */
-// pacer, counter, dio registers
+/* pacer, counter, dio registers */
#define ADC8254 0
#define DIO_8255 4
#define DAC8254 8
-// analog output registers for 100x, 1200 series
+/* analog output registers for 100x, 1200 series */
static inline unsigned int DAC_DATA_REG(unsigned int channel)
{
return 2 * (channel & 0x1);
}
/* analog output registers for 1602 series*/
-#define DACDATA 0 // DAC DATA register
-#define DACFIFOCLR 2 // DAC FIFO CLEAR
+#define DACDATA 0 /* DAC DATA register */
+#define DACFIFOCLR 2 /* DAC FIFO CLEAR */
-// bit in hexadecimal representation of range index that indicates unipolar input range
+/* bit in hexadecimal representation of range index that indicates unipolar input range */
#define IS_UNIPOLAR 0x4
-// analog input ranges for most boards
+/* analog input ranges for most boards */
static const struct comedi_lrange cb_pcidas_ranges = {
8,
{
@@ -210,7 +211,7 @@ static const struct comedi_lrange cb_pcidas_ranges = {
}
};
-// pci-das1001 input ranges
+/* pci-das1001 input ranges */
static const struct comedi_lrange cb_pcidas_alt_ranges = {
8,
{
@@ -225,7 +226,7 @@ static const struct comedi_lrange cb_pcidas_alt_ranges = {
}
};
-// analog output ranges
+/* analog output ranges */
static const struct comedi_lrange cb_pcidas_ao_ranges = {
4,
{
@@ -244,14 +245,14 @@ enum trimpot_model {
struct cb_pcidas_board {
const char *name;
unsigned short device_id;
- int ai_se_chans; // Inputs in single-ended mode
- int ai_diff_chans; // Inputs in differential mode
- int ai_bits; // analog input resolution
- int ai_speed; // fastest conversion period in ns
- int ao_nchan; // number of analog out channels
- int has_ao_fifo; // analog output has fifo
- int ao_scan_speed; // analog output speed for 1602 series (for a scan, not conversion)
- int fifo_size; // number of samples fifo can hold
+ int ai_se_chans; /* Inputs in single-ended mode */
+ int ai_diff_chans; /* Inputs in differential mode */
+ int ai_bits; /* analog input resolution */
+ int ai_speed; /* fastest conversion period in ns */
+ int ao_nchan; /* number of analog out channels */
+ int has_ao_fifo; /* analog output has fifo */
+ int ao_scan_speed; /* analog output speed for 1602 series (for a scan, not conversion) */
+ int fifo_size; /* number of samples fifo can hold */
const struct comedi_lrange *ranges;
enum trimpot_model trimpot;
unsigned has_dac08:1;
@@ -259,124 +260,121 @@ struct cb_pcidas_board {
static const struct cb_pcidas_board cb_pcidas_boards[] = {
{
- name: "pci-das1602/16",
- device_id:0x1,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:2,
- has_ao_fifo:1,
- ao_scan_speed:10000,
- fifo_size:512,
- ranges: &cb_pcidas_ranges,
- trimpot: AD8402,
- has_dac08:1,
+ .name = "pci-das1602/16",
+ .device_id = 0x1,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .has_ao_fifo = 1,
+ .ao_scan_speed = 10000,
+ .fifo_size = 512,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD8402,
+ .has_dac08 = 1,
},
{
- name: "pci-das1200",
- device_id:0xF,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 12,
- ai_speed:3200,
- ao_nchan:2,
- has_ao_fifo:0,
- fifo_size:1024,
- ranges: &cb_pcidas_ranges,
- trimpot: AD7376,
- has_dac08:0,
+ .name = "pci-das1200",
+ .device_id = 0xF,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .ai_speed = 3200,
+ .ao_nchan = 2,
+ .has_ao_fifo = 0,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ .has_dac08 = 0,
},
{
- name: "pci-das1602/12",
- device_id:0x10,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 12,
- ai_speed:3200,
- ao_nchan:2,
- has_ao_fifo:1,
- ao_scan_speed:4000,
- fifo_size:1024,
- ranges: &cb_pcidas_ranges,
- trimpot: AD7376,
- has_dac08:0,
+ .name = "pci-das1602/12",
+ .device_id = 0x10,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .ai_speed = 3200,
+ .ao_nchan = 2,
+ .has_ao_fifo = 1,
+ .ao_scan_speed = 4000,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ .has_dac08 = 0,
},
{
- name: "pci-das1200/jr",
- device_id:0x19,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 12,
- ai_speed:3200,
- ao_nchan:0,
- has_ao_fifo:0,
- fifo_size:1024,
- ranges: &cb_pcidas_ranges,
- trimpot: AD7376,
- has_dac08:0,
+ .name = "pci-das1200/jr",
+ .device_id = 0x19,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .ai_speed = 3200,
+ .ao_nchan = 0,
+ .has_ao_fifo = 0,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ .has_dac08 = 0,
},
{
- name: "pci-das1602/16/jr",
- device_id:0x1C,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:0,
- has_ao_fifo:0,
- fifo_size:512,
- ranges: &cb_pcidas_ranges,
- trimpot: AD8402,
- has_dac08:1,
+ .name = "pci-das1602/16/jr",
+ .device_id = 0x1C,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 0,
+ .has_ao_fifo = 0,
+ .fifo_size = 512,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD8402,
+ .has_dac08 = 1,
},
{
- name: "pci-das1000",
- device_id:0x4C,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 12,
- ai_speed:4000,
- ao_nchan:0,
- has_ao_fifo:0,
- fifo_size:1024,
- ranges: &cb_pcidas_ranges,
- trimpot: AD7376,
- has_dac08:0,
+ .name = "pci-das1000",
+ .device_id = 0x4C,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .ai_speed = 4000,
+ .ao_nchan = 0,
+ .has_ao_fifo = 0,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ .has_dac08 = 0,
},
{
- name: "pci-das1001",
- device_id:0x1a,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 12,
- ai_speed:6800,
- ao_nchan:2,
- has_ao_fifo:0,
- fifo_size:1024,
- ranges: &cb_pcidas_alt_ranges,
- trimpot: AD7376,
- has_dac08:0,
+ .name = "pci-das1001",
+ .device_id = 0x1a,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .ai_speed = 6800,
+ .ao_nchan = 2,
+ .has_ao_fifo = 0,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_alt_ranges,
+ .trimpot = AD7376,
+ .has_dac08 = 0,
},
{
- name: "pci-das1002",
- device_id:0x1b,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 12,
- ai_speed:6800,
- ao_nchan:2,
- has_ao_fifo:0,
- fifo_size:1024,
- ranges: &cb_pcidas_ranges,
- trimpot: AD7376,
- has_dac08:0,
+ .name = "pci-das1002",
+ .device_id = 0x1b,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .ai_speed = 6800,
+ .ao_nchan = 2,
+ .has_ao_fifo = 0,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ .has_dac08 = 0,
},
};
-// Number of boards in cb_pcidas_boards
-#define N_BOARDS (sizeof(cb_pcidas_boards) / sizeof(struct cb_pcidas_board))
-
static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
{PCI_VENDOR_ID_CB, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_CB, 0x000f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -402,28 +400,28 @@ MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table);
struct cb_pcidas_private {
/* would be useful for a PCI device */
struct pci_dev *pci_dev;
- // base addresses
+ /* base addresses */
unsigned long s5933_config;
unsigned long control_status;
unsigned long adc_fifo;
unsigned long pacer_counter_dio;
unsigned long ao_registers;
- // divisors of master clock for analog input pacing
+ /* divisors of master clock for analog input pacing */
unsigned int divisor1;
unsigned int divisor2;
- volatile unsigned int count; // number of analog input samples remaining
- volatile unsigned int adc_fifo_bits; // bits to write to interupt/adcfifo register
- volatile unsigned int s5933_intcsr_bits; // bits to write to amcc s5933 interrupt control/status register
- volatile unsigned int ao_control_bits; // bits to write to ao control and status register
+ volatile unsigned int count; /* number of analog input samples remaining */
+ volatile unsigned int adc_fifo_bits; /* bits to write to interupt/adcfifo register */
+ volatile unsigned int s5933_intcsr_bits; /* bits to write to amcc s5933 interrupt control/status register */
+ volatile unsigned int ao_control_bits; /* bits to write to ao control and status register */
short ai_buffer[AI_BUFFER_SIZE];
short ao_buffer[AO_BUFFER_SIZE];
- // divisors of master clock for analog output pacing
+ /* divisors of master clock for analog output pacing */
unsigned int ao_divisor1;
unsigned int ao_divisor2;
- volatile unsigned int ao_count; // number of analog output samples remaining
- int ao_value[2]; // remember what the analog outputs are set to, to allow readback
- unsigned int caldac_value[NUM_CHANNELS_8800]; // for readback of caldac
- unsigned int trimpot_value[NUM_CHANNELS_8402]; // for readback of trimpot
+ volatile unsigned int ao_count; /* number of analog output samples remaining */
+ int ao_value[2]; /* remember what the analog outputs are set to, to allow readback */
+ unsigned int caldac_value[NUM_CHANNELS_8800]; /* for readback of caldac */
+ unsigned int trimpot_value[NUM_CHANNELS_8402]; /* for readback of trimpot */
unsigned int dac08_value;
unsigned int calibration_source;
};
@@ -440,66 +438,66 @@ struct cb_pcidas_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int cb_pcidas_detach(struct comedi_device * dev);
+static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int cb_pcidas_detach(struct comedi_device *dev);
static struct comedi_driver driver_cb_pcidas = {
- driver_name:"cb_pcidas",
- module:THIS_MODULE,
- attach:cb_pcidas_attach,
- detach:cb_pcidas_detach,
+ .driver_name = "cb_pcidas",
+ .module = THIS_MODULE,
+ .attach = cb_pcidas_attach,
+ .detach = cb_pcidas_detach,
};
static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcidas_ao_nofifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcidas_ao_fifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcidas_ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
+ struct comedi_insn *insn, unsigned int *data);
+static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcidas_ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
struct comedi_subdevice *subdev,
unsigned int trig_num);
-static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG);
-static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status);
-static int cb_pcidas_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static int cb_pcidas_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void cb_pcidas_load_counters(struct comedi_device * dev, unsigned int *ns,
+static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static irqreturn_t cb_pcidas_interrupt(int irq, void *d);
+static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status);
+static int cb_pcidas_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int cb_pcidas_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
int round_flags);
-static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int caldac_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int caldac_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int trimpot_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcidas_trimpot_write(struct comedi_device * dev, unsigned int channel,
+static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int caldac_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int caldac_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int trimpot_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcidas_trimpot_write(struct comedi_device *dev, unsigned int channel,
unsigned int value);
-static int trimpot_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dac08_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dac08_write(struct comedi_device * dev, unsigned int value);
-static int dac08_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int caldac_8800_write(struct comedi_device * dev, unsigned int address,
+static int trimpot_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dac08_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dac08_write(struct comedi_device *dev, unsigned int value);
+static int dac08_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value);
-static int trimpot_7376_write(struct comedi_device * dev, uint8_t value);
-static int trimpot_8402_write(struct comedi_device * dev, unsigned int channel,
+static int trimpot_7376_write(struct comedi_device *dev, uint8_t value);
+static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
uint8_t value);
-static int nvram_read(struct comedi_device * dev, unsigned int address,
- uint8_t * data);
+static int nvram_read(struct comedi_device *dev, unsigned int address,
+ uint8_t *data);
-static inline unsigned int cal_enable_bits(struct comedi_device * dev)
+static inline unsigned int cal_enable_bits(struct comedi_device *dev)
{
return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source);
}
@@ -508,7 +506,7 @@ static inline unsigned int cal_enable_bits(struct comedi_device * dev)
* Attach is called by the Comedi core to configure the driver
* for a particular board.
*/
-static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
struct pci_dev *pcidev;
@@ -531,16 +529,16 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
- // is it not a computer boards card?
+ /* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_CB)
continue;
- // loop through cards supported by this driver
- for (index = 0; index < N_BOARDS; index++) {
+ /* loop through cards supported by this driver */
+ for (index = 0; index < ARRAY_SIZE(cb_pcidas_boards); index++) {
if (cb_pcidas_boards[index].device_id != pcidev->device)
continue;
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
PCI_SLOT(pcidev->devfn) !=
it->options[1]) {
@@ -585,19 +583,19 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
devpriv->ao_registers =
pci_resource_start(devpriv->pci_dev, AO_BADRINDEX);
}
- // disable and clear interrupts on amcc s5933
+ /* disable and clear interrupts on amcc s5933 */
outl(INTCSR_INBOX_INTR_STATUS,
devpriv->s5933_config + AMCC_OP_REG_INTCSR);
- // get irq
- if (comedi_request_irq(devpriv->pci_dev->irq, cb_pcidas_interrupt,
+ /* get irq */
+ if (request_irq(devpriv->pci_dev->irq, cb_pcidas_interrupt,
IRQF_SHARED, "cb_pcidas", dev)) {
printk(" unable to allocate irq %d\n", devpriv->pci_dev->irq);
return -EINVAL;
}
dev->irq = devpriv->pci_dev->irq;
- //Initialize dev->board_name
+ /* Initialize dev->board_name */
dev->board_name = thisboard->name;
/*
@@ -628,7 +626,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND;
s->n_chan = thisboard->ao_nchan;
- // analog out resolution is the same as analog input resolution, so use ai_bits
+ /* analog out resolution is the same as analog input resolution, so use ai_bits */
s->maxdata = (1 << thisboard->ai_bits) - 1;
s->range_table = &cb_pcidas_ao_ranges;
s->insn_read = cb_pcidas_ao_readback_insn;
@@ -650,7 +648,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
s = dev->subdevices + 2;
subdev_8255_init(dev, s, NULL, devpriv->pacer_counter_dio + DIO_8255);
- // serial EEPROM,
+ /* serial EEPROM, */
s = dev->subdevices + 3;
s->type = COMEDI_SUBD_MEMORY;
s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
@@ -658,7 +656,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
s->maxdata = 0xff;
s->insn_read = eeprom_read_insn;
- // 8800 caldac
+ /* 8800 caldac */
s = dev->subdevices + 4;
s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
@@ -669,7 +667,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
for (i = 0; i < s->n_chan; i++)
caldac_8800_write(dev, i, s->maxdata / 2);
- // trim potentiometer
+ /* trim potentiometer */
s = dev->subdevices + 5;
s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
@@ -685,7 +683,7 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
for (i = 0; i < s->n_chan; i++)
cb_pcidas_trimpot_write(dev, i, s->maxdata / 2);
- // dac08 caldac
+ /* dac08 caldac */
s = dev->subdevices + 6;
if (thisboard->has_dac08) {
s->type = COMEDI_SUBD_CALIB;
@@ -698,13 +696,13 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
} else
s->type = COMEDI_SUBD_UNUSED;
- // make sure mailbox 4 is empty
+ /* make sure mailbox 4 is empty */
inl(devpriv->s5933_config + AMCC_OP_REG_IMB4);
/* Set bits to enable incoming mailbox interrupts on amcc s5933. */
devpriv->s5933_intcsr_bits =
INTCSR_INBOX_BYTE(3) | INTCSR_INBOX_SELECT(3) |
INTCSR_INBOX_FULL_INT;
- // clear and enable interrupt on amcc s5933
+ /* clear and enable interrupt on amcc s5933 */
outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS,
devpriv->s5933_config + AMCC_OP_REG_INTCSR);
@@ -719,24 +717,24 @@ static int cb_pcidas_attach(struct comedi_device * dev, struct comedi_devconfig
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int cb_pcidas_detach(struct comedi_device * dev)
+static int cb_pcidas_detach(struct comedi_device *dev)
{
printk("comedi%d: cb_pcidas: remove\n", dev->minor);
if (devpriv) {
if (devpriv->s5933_config) {
- // disable and clear interrupts on amcc s5933
+ /* disable and clear interrupts on amcc s5933 */
outl(INTCSR_INBOX_INTR_STATUS,
devpriv->s5933_config + AMCC_OP_REG_INTCSR);
#ifdef CB_PCIDAS_DEBUG
- rt_printk("detaching, incsr is 0x%x\n",
+ printk("detaching, incsr is 0x%x\n",
inl(devpriv->s5933_config +
AMCC_OP_REG_INTCSR));
#endif
}
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 2);
if (devpriv && devpriv->pci_dev) {
@@ -753,14 +751,14 @@ static int cb_pcidas_detach(struct comedi_device * dev)
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
-static int cb_pcidas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
unsigned int bits;
static const int timeout = 10000;
int channel;
- // enable calibration input if appropriate
+ /* enable calibration input if appropriate */
if (insn->chanspec & CR_ALT_SOURCE) {
outw(cal_enable_bits(dev),
devpriv->control_status + CALIBRATION_REG);
@@ -769,13 +767,13 @@ static int cb_pcidas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevic
outw(0, devpriv->control_status + CALIBRATION_REG);
channel = CR_CHAN(insn->chanspec);
}
- // set mux limits and gain
+ /* set mux limits and gain */
bits = BEGIN_SCAN(channel) |
END_SCAN(channel) | GAIN_BITS(CR_RANGE(insn->chanspec));
- // set unipolar/bipolar
+ /* set unipolar/bipolar */
if (CR_RANGE(insn->chanspec) & IS_UNIPOLAR)
bits |= UNIP;
- // set singleended/differential
+ /* set singleended/differential */
if (CR_AREF(insn->chanspec) != AREF_DIFF)
bits |= SE;
outw(bits, devpriv->control_status + ADCMUX_CONT);
@@ -805,7 +803,7 @@ static int cb_pcidas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevic
return n;
}
-static int ai_config_calibration_source(struct comedi_device * dev, unsigned int * data)
+static int ai_config_calibration_source(struct comedi_device *dev, unsigned int *data)
{
static const int num_calibration_sources = 8;
unsigned int source = data[1];
@@ -820,8 +818,8 @@ static int ai_config_calibration_source(struct comedi_device * dev, unsigned int
return 2;
}
-static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int id = data[0];
@@ -836,44 +834,44 @@ static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice *
return -EINVAL;
}
-// analog output insn for pcidas-1000 and 1200 series
-static int cb_pcidas_ao_nofifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/* analog output insn for pcidas-1000 and 1200 series */
+static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel;
unsigned long flags;
- // set channel and range
+ /* set channel and range */
channel = CR_CHAN(insn->chanspec);
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->ao_control_bits &=
~DAC_MODE_UPDATE_BOTH & ~DAC_RANGE_MASK(channel);
devpriv->ao_control_bits |=
DACEN | DAC_RANGE(channel, CR_RANGE(insn->chanspec));
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // remember value for readback
+ /* remember value for readback */
devpriv->ao_value[channel] = data[0];
- // send data
+ /* send data */
outw(data[0], devpriv->ao_registers + DAC_DATA_REG(channel));
return 1;
}
-// analog output insn for pcidas-1602 series
-static int cb_pcidas_ao_fifo_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/* analog output insn for pcidas-1602 series */
+static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel;
unsigned long flags;
- // clear dac fifo
+ /* clear dac fifo */
outw(0, devpriv->ao_registers + DACFIFOCLR);
- // set channel and range
+ /* set channel and range */
channel = CR_CHAN(insn->chanspec);
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->ao_control_bits &=
~DAC_CHAN_EN(0) & ~DAC_CHAN_EN(1) & ~DAC_RANGE_MASK(channel) &
~DAC_PACER_MASK;
@@ -881,28 +879,28 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device * dev, struct comedi_sub
DACEN | DAC_RANGE(channel,
CR_RANGE(insn->chanspec)) | DAC_CHAN_EN(channel) | DAC_START;
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // remember value for readback
+ /* remember value for readback */
devpriv->ao_value[channel] = data[0];
- // send data
+ /* send data */
outw(data[0], devpriv->ao_registers + DACDATA);
return 1;
}
-// analog output readback insn
-// XXX loses track of analog output value back after an analog ouput command is executed
-static int cb_pcidas_ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/* analog output readback insn */
+/* XXX loses track of analog output value back after an analog ouput command is executed */
+static int cb_pcidas_ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];
return 1;
}
-static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
uint8_t nvram_data;
int retval;
@@ -916,16 +914,16 @@ static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int caldac_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int caldac_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
const unsigned int channel = CR_CHAN(insn->chanspec);
return caldac_8800_write(dev, channel, data[0]);
}
-static int caldac_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int caldac_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)];
@@ -933,7 +931,7 @@ static int caldac_read_insn(struct comedi_device * dev, struct comedi_subdevice
}
/* 1602/16 pregain offset */
-static int dac08_write(struct comedi_device * dev, unsigned int value)
+static int dac08_write(struct comedi_device *dev, unsigned int value)
{
if (devpriv->dac08_value == value)
return 1;
@@ -942,32 +940,32 @@ static int dac08_write(struct comedi_device * dev, unsigned int value)
outw(cal_enable_bits(dev) | (value & 0xff),
devpriv->control_status + CALIBRATION_REG);
- comedi_udelay(1);
+ udelay(1);
outw(cal_enable_bits(dev) | SELECT_DAC08_BIT | (value & 0xff),
devpriv->control_status + CALIBRATION_REG);
- comedi_udelay(1);
+ udelay(1);
outw(cal_enable_bits(dev) | (value & 0xff),
devpriv->control_status + CALIBRATION_REG);
- comedi_udelay(1);
+ udelay(1);
return 1;
}
-static int dac08_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dac08_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return dac08_write(dev, data[0]);
}
-static int dac08_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dac08_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->dac08_value;
return 1;
}
-static int cb_pcidas_trimpot_write(struct comedi_device * dev,
+static int cb_pcidas_trimpot_write(struct comedi_device *dev,
unsigned int channel, unsigned int value)
{
if (devpriv->trimpot_value[channel] == value)
@@ -990,16 +988,16 @@ static int cb_pcidas_trimpot_write(struct comedi_device * dev,
return 1;
}
-static int trimpot_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int trimpot_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int channel = CR_CHAN(insn->chanspec);
return cb_pcidas_trimpot_write(dev, channel, data[0]);
}
-static int trimpot_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int trimpot_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int channel = CR_CHAN(insn->chanspec);
@@ -1008,8 +1006,8 @@ static int trimpot_read_insn(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1066,7 +1064,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdev
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
- // make sure trigger sources are compatible with each other
+ /* make sure trigger sources are compatible with each other */
if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW)
@@ -1138,7 +1136,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdev
if (err)
return 4;
- // check channel/gain list against card's limitations
+ /* check channel/gain list against card's limitations */
if (cmd->chanlist) {
gain = CR_RANGE(cmd->chanlist[0]);
start_chan = CR_CHAN(cmd->chanlist[0]);
@@ -1163,31 +1161,31 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device * dev, struct comedi_subdev
return 0;
}
-static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int bits;
unsigned long flags;
- // make sure CAL_EN_BIT is disabled
+ /* make sure CAL_EN_BIT is disabled */
outw(0, devpriv->control_status + CALIBRATION_REG);
- // initialize before settings pacer source and count values
+ /* initialize before settings pacer source and count values */
outw(0, devpriv->control_status + TRIG_CONTSTAT);
- // clear fifo
+ /* clear fifo */
outw(0, devpriv->adc_fifo + ADCFIFOCLR);
- // set mux limits, gain and pacer source
+ /* set mux limits, gain and pacer source */
bits = BEGIN_SCAN(CR_CHAN(cmd->chanlist[0])) |
END_SCAN(CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1])) |
GAIN_BITS(CR_RANGE(cmd->chanlist[0]));
- // set unipolar/bipolar
+ /* set unipolar/bipolar */
if (CR_RANGE(cmd->chanlist[0]) & IS_UNIPOLAR)
bits |= UNIP;
- // set singleended/differential
+ /* set singleended/differential */
if (CR_AREF(cmd->chanlist[0]) != AREF_DIFF)
bits |= SE;
- // set pacer source
+ /* set pacer source */
if (cmd->convert_src == TRIG_EXT || cmd->scan_begin_src == TRIG_EXT)
bits |= PACER_EXT_RISE;
else
@@ -1195,10 +1193,10 @@ static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice
outw(bits, devpriv->control_status + ADCMUX_CONT);
#ifdef CB_PCIDAS_DEBUG
- rt_printk("comedi: sent 0x%x to adcmux control\n", bits);
+ printk("comedi: sent 0x%x to adcmux control\n", bits);
#endif
- // load counters
+ /* load counters */
if (cmd->convert_src == TRIG_TIMER)
cb_pcidas_load_counters(dev, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
@@ -1206,31 +1204,31 @@ static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice
cb_pcidas_load_counters(dev, &cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
- // set number of conversions
+ /* set number of conversions */
if (cmd->stop_src == TRIG_COUNT) {
devpriv->count = cmd->chanlist_len * cmd->stop_arg;
}
- // enable interrupts
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* enable interrupts */
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->adc_fifo_bits |= INTE;
devpriv->adc_fifo_bits &= ~INT_MASK;
if (cmd->flags & TRIG_WAKE_EOS) {
if (cmd->convert_src == TRIG_NOW && cmd->chanlist_len > 1)
- devpriv->adc_fifo_bits |= INT_EOS; // interrupt end of burst
+ devpriv->adc_fifo_bits |= INT_EOS; /* interrupt end of burst */
else
- devpriv->adc_fifo_bits |= INT_FNE; // interrupt fifo not empty
+ devpriv->adc_fifo_bits |= INT_FNE; /* interrupt fifo not empty */
} else {
- devpriv->adc_fifo_bits |= INT_FHF; //interrupt fifo half full
+ devpriv->adc_fifo_bits |= INT_FHF; /* interrupt fifo half full */
}
#ifdef CB_PCIDAS_DEBUG
- rt_printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits);
+ printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits);
#endif
- // enable (and clear) interrupts
+ /* enable (and clear) interrupts */
outw(devpriv->adc_fifo_bits | EOAI | INT | LADFUL,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // set start trigger and burst mode
+ /* set start trigger and burst mode */
bits = 0;
if (cmd->start_src == TRIG_NOW)
bits |= SW_TRIGGER;
@@ -1244,14 +1242,14 @@ static int cb_pcidas_ai_cmd(struct comedi_device * dev, struct comedi_subdevice
bits |= BURSTE;
outw(bits, devpriv->control_status + TRIG_CONTSTAT);
#ifdef CB_PCIDAS_DEBUG
- rt_printk("comedi: sent 0x%x to trig control\n", bits);
+ printk("comedi: sent 0x%x to trig control\n", bits);
#endif
return 0;
}
-static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1347,7 +1345,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdev
if (err)
return 4;
- // check channel/gain list against card's limitations
+ /* check channel/gain list against card's limitations */
if (cmd->chanlist && cmd->chanlist_len > 1) {
if (CR_CHAN(cmd->chanlist[0]) != 0 ||
CR_CHAN(cmd->chanlist[1]) != 1) {
@@ -1363,32 +1361,32 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device * dev, struct comedi_subdev
return 0;
}
-static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int i;
unsigned long flags;
- // set channel limits, gain
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* set channel limits, gain */
+ spin_lock_irqsave(&dev->spinlock, flags);
for (i = 0; i < cmd->chanlist_len; i++) {
- // enable channel
+ /* enable channel */
devpriv->ao_control_bits |=
DAC_CHAN_EN(CR_CHAN(cmd->chanlist[i]));
- // set range
+ /* set range */
devpriv->ao_control_bits |= DAC_RANGE(CR_CHAN(cmd->chanlist[i]),
CR_RANGE(cmd->chanlist[i]));
}
- // disable analog out before settings pacer source and count values
+ /* disable analog out before settings pacer source and count values */
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // clear fifo
+ /* clear fifo */
outw(0, devpriv->ao_registers + DACFIFOCLR);
- // load counters
+ /* load counters */
if (cmd->scan_begin_src == TRIG_TIMER) {
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->ao_divisor1), &(devpriv->ao_divisor2),
@@ -1400,12 +1398,12 @@ static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice
i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 2,
devpriv->ao_divisor2, 2);
}
- // set number of conversions
+ /* set number of conversions */
if (cmd->stop_src == TRIG_COUNT) {
devpriv->ao_count = cmd->chanlist_len * cmd->stop_arg;
}
- // set pacer source
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* set pacer source */
+ spin_lock_irqsave(&dev->spinlock, flags);
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
devpriv->ao_control_bits |= DAC_PACER_INT;
@@ -1414,12 +1412,12 @@ static int cb_pcidas_ao_cmd(struct comedi_device * dev, struct comedi_subdevice
devpriv->ao_control_bits |= DAC_PACER_EXT_RISE;
break;
default:
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
comedi_error(dev, "error setting dac pacer source");
return -1;
break;
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
async->inttrig = cb_pcidas_ao_inttrig;
@@ -1438,7 +1436,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
if (trig_num != 0)
return -EINVAL;
- // load up fifo
+ /* load up fifo */
if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points)
num_points = devpriv->ao_count;
@@ -1449,34 +1447,34 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
if (cmd->stop_src == TRIG_COUNT) {
devpriv->ao_count -= num_points;
}
- // write data to board's fifo
+ /* write data to board's fifo */
outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes);
- // enable dac half-full and empty interrupts
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* enable dac half-full and empty interrupts */
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->adc_fifo_bits |= DAEMIE | DAHFIE;
#ifdef CB_PCIDAS_DEBUG
- rt_printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits);
+ printk("comedi: adc_fifo_bits are 0x%x\n", devpriv->adc_fifo_bits);
#endif
- // enable and clear interrupts
+ /* enable and clear interrupts */
outw(devpriv->adc_fifo_bits | DAEMI | DAHFI,
devpriv->control_status + INT_ADCFIFO);
- // start dac
+ /* start dac */
devpriv->ao_control_bits |= DAC_START | DACEN | DAC_EMPTY;
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
#ifdef CB_PCIDAS_DEBUG
- rt_printk("comedi: sent 0x%x to dac control\n",
+ printk("comedi: sent 0x%x to dac control\n",
devpriv->ao_control_bits);
#endif
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
async->inttrig = NULL;
return 0;
}
-static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
{
struct comedi_device *dev = (struct comedi_device *) d;
struct comedi_subdevice *s = dev->read_subdev;
@@ -1496,16 +1494,16 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG)
s5933_status = inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR);
#ifdef CB_PCIDAS_DEBUG
- rt_printk("intcsr 0x%x\n", s5933_status);
- rt_printk("mbef 0x%x\n", inl(devpriv->s5933_config + AMCC_OP_REG_MBEF));
+ printk("intcsr 0x%x\n", s5933_status);
+ printk("mbef 0x%x\n", inl(devpriv->s5933_config + AMCC_OP_REG_MBEF));
#endif
if ((INTCSR_INTR_ASSERTED & s5933_status) == 0)
return IRQ_NONE;
- // make sure mailbox 4 is empty
+ /* make sure mailbox 4 is empty */
inl_p(devpriv->s5933_config + AMCC_OP_REG_IMB4);
- // clear interrupt on amcc s5933
+ /* clear interrupt on amcc s5933 */
outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS,
devpriv->s5933_config + AMCC_OP_REG_INTCSR);
@@ -1516,14 +1514,14 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG)
}
#endif
- // check for analog output interrupt
+ /* check for analog output interrupt */
if (status & (DAHFI | DAEMI)) {
handle_ao_interrupt(dev, status);
}
- // check for analog input interrupts
- // if fifo half-full
+ /* check for analog input interrupts */
+ /* if fifo half-full */
if (status & ADHFI) {
- // read data
+ /* read data */
num_samples = half_fifo;
if (async->cmd.stop_src == TRIG_COUNT &&
num_samples > devpriv->count) {
@@ -1538,15 +1536,15 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG)
async->events |= COMEDI_CB_EOA;
cb_pcidas_cancel(dev, s);
}
- // clear half-full interrupt latch
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* clear half-full interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | INT,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
- // else if fifo not empty
+ spin_unlock_irqrestore(&dev->spinlock, flags);
+ /* else if fifo not empty */
} else if (status & (ADNEI | EOBI)) {
for (i = 0; i < timeout; i++) {
- // break if fifo is empty
+ /* break if fifo is empty */
if ((ADNE & inw(devpriv->control_status +
INT_ADCFIFO)) == 0)
break;
@@ -1557,28 +1555,28 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG)
break;
}
}
- // clear not-empty interrupt latch
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* clear not-empty interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | INT,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
} else if (status & EOAI) {
comedi_error(dev,
"bug! encountered end of aquisition interrupt?");
- // clear EOA interrupt latch
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* clear EOA interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | EOAI,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
- //check for fifo overflow
+ /* check for fifo overflow */
if (status & LADFUL) {
comedi_error(dev, "fifo overflow");
- // clear overflow interrupt latch
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* clear overflow interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | LADFUL,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
cb_pcidas_cancel(dev, s);
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
@@ -1588,7 +1586,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status)
+static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
{
struct comedi_subdevice *s = dev->write_subdev;
struct comedi_async *async = s->async;
@@ -1600,11 +1598,11 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status)
async->events = 0;
if (status & DAEMI) {
- // clear dac empty interrupt latch
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* clear dac empty interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | DAEMI,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
if (inw(devpriv->ao_registers + DAC_CSR) & DAC_EMPTY) {
if (cmd->stop_src == TRIG_NONE ||
(cmd->stop_src == TRIG_COUNT
@@ -1618,7 +1616,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status)
} else if (status & DAHFI) {
unsigned int num_bytes;
- // figure out how many points we are writing to fifo
+ /* figure out how many points we are writing to fifo */
num_points = half_fifo;
if (cmd->stop_src == TRIG_COUNT &&
devpriv->ao_count < num_points)
@@ -1631,33 +1629,33 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned int status)
if (async->cmd.stop_src == TRIG_COUNT) {
devpriv->ao_count -= num_points;
}
- // write data to board's fifo
+ /* write data to board's fifo */
outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer,
num_points);
- // clear half-full interrupt latch
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* clear half-full interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | DAHFI,
devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
comedi_event(dev, s);
}
/* cancel analog input command */
-static int cb_pcidas_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int cb_pcidas_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
- // disable interrupts
+ spin_lock_irqsave(&dev->spinlock, flags);
+ /* disable interrupts */
devpriv->adc_fifo_bits &= ~INTE & ~EOAIE;
outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // disable start trigger source and burst mode
+ /* disable start trigger source and burst mode */
outw(0, devpriv->control_status + TRIG_CONTSTAT);
- // software pacer source
+ /* software pacer source */
outw(0, devpriv->control_status + ADCMUX_CONT);
return 0;
@@ -1669,20 +1667,20 @@ static int cb_pcidas_ao_cancel(struct comedi_device *dev,
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
- // disable interrupts
+ spin_lock_irqsave(&dev->spinlock, flags);
+ /* disable interrupts */
devpriv->adc_fifo_bits &= ~DAHFIE & ~DAEMIE;
outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO);
- // disable output
+ /* disable output */
devpriv->ao_control_bits &= ~DACEN & ~DAC_PACER_MASK;
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
-static void cb_pcidas_load_counters(struct comedi_device * dev, unsigned int *ns,
+static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
int rounding_flags)
{
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
@@ -1695,7 +1693,7 @@ static void cb_pcidas_load_counters(struct comedi_device * dev, unsigned int *ns
devpriv->divisor2, 2);
}
-static void write_calibration_bitstream(struct comedi_device * dev,
+static void write_calibration_bitstream(struct comedi_device *dev,
unsigned int register_bits, unsigned int bitstream,
unsigned int bitstream_length)
{
@@ -1707,18 +1705,18 @@ static void write_calibration_bitstream(struct comedi_device * dev,
register_bits |= SERIAL_DATA_IN_BIT;
else
register_bits &= ~SERIAL_DATA_IN_BIT;
- comedi_udelay(write_delay);
+ udelay(write_delay);
outw(register_bits, devpriv->control_status + CALIBRATION_REG);
}
}
-static int caldac_8800_write(struct comedi_device * dev, unsigned int address,
+static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value)
{
static const int num_caldac_channels = 8;
static const int bitstream_length = 11;
unsigned int bitstream = ((address & 0x7) << 8) | value;
- static const int caldac_8800_comedi_udelay = 1;
+ static const int caldac_8800_udelay = 1;
if (address >= num_caldac_channels) {
comedi_error(dev, "illegal caldac channel");
@@ -1733,30 +1731,30 @@ static int caldac_8800_write(struct comedi_device * dev, unsigned int address,
write_calibration_bitstream(dev, cal_enable_bits(dev), bitstream,
bitstream_length);
- comedi_udelay(caldac_8800_comedi_udelay);
+ udelay(caldac_8800_udelay);
outw(cal_enable_bits(dev) | SELECT_8800_BIT,
devpriv->control_status + CALIBRATION_REG);
- comedi_udelay(caldac_8800_comedi_udelay);
+ udelay(caldac_8800_udelay);
outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
return 1;
}
-static int trimpot_7376_write(struct comedi_device * dev, uint8_t value)
+static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
{
static const int bitstream_length = 7;
unsigned int bitstream = value & 0x7f;
unsigned int register_bits;
- static const int ad7376_comedi_udelay = 1;
+ static const int ad7376_udelay = 1;
register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT;
- comedi_udelay(ad7376_comedi_udelay);
+ udelay(ad7376_udelay);
outw(register_bits, devpriv->control_status + CALIBRATION_REG);
write_calibration_bitstream(dev, register_bits, bitstream,
bitstream_length);
- comedi_udelay(ad7376_comedi_udelay);
+ udelay(ad7376_udelay);
outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
return 0;
@@ -1765,22 +1763,22 @@ static int trimpot_7376_write(struct comedi_device * dev, uint8_t value)
/* For 1602/16 only
* ch 0 : adc gain
* ch 1 : adc postgain offset */
-static int trimpot_8402_write(struct comedi_device * dev, unsigned int channel,
+static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
uint8_t value)
{
static const int bitstream_length = 10;
unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
unsigned int register_bits;
- static const int ad8402_comedi_udelay = 1;
+ static const int ad8402_udelay = 1;
register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT;
- comedi_udelay(ad8402_comedi_udelay);
+ udelay(ad8402_udelay);
outw(register_bits, devpriv->control_status + CALIBRATION_REG);
write_calibration_bitstream(dev, register_bits, bitstream,
bitstream_length);
- comedi_udelay(ad8402_comedi_udelay);
+ udelay(ad8402_udelay);
outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
return 0;
@@ -1796,12 +1794,12 @@ static int wait_for_nvram_ready(unsigned long s5933_base_addr)
AMCC_OP_REG_MCSR_NVCMD) & MCSR_NV_BUSY)
== 0)
return 0;
- comedi_udelay(1);
+ udelay(1);
}
return -1;
}
-static int nvram_read(struct comedi_device * dev, unsigned int address, uint8_t * data)
+static int nvram_read(struct comedi_device *dev, unsigned int address, uint8_t *data)
{
unsigned long iobase = devpriv->s5933_config;
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 1a580bd2247a..210b462868b7 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -85,6 +85,7 @@ TODO:
#include "../comedidev.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include <asm/system.h>
#include "comedi_pci.h"
@@ -93,17 +94,17 @@ TODO:
#include "plx9080.h"
#include "comedi_fc.h"
-#undef PCIDAS64_DEBUG // disable debugging code
-//#define PCIDAS64_DEBUG // enable debugging code
+#undef PCIDAS64_DEBUG /* disable debugging code */
+/* #define PCIDAS64_DEBUG enable debugging code */
#ifdef PCIDAS64_DEBUG
-#define DEBUG_PRINT(format, args...) rt_printk(format , ## args )
+#define DEBUG_PRINT(format, args...) printk(format , ## args)
#else
#define DEBUG_PRINT(format, args...)
#endif
-#define TIMER_BASE 25 // 40MHz master clock
-#define PRESCALED_TIMER_BASE 10000 // 100kHz 'prescaled' clock for slow aquisition, maybe I'll support this someday
+#define TIMER_BASE 25 /* 40MHz master clock */
+#define PRESCALED_TIMER_BASE 10000 /* 100kHz 'prescaled' clock for slow aquisition, maybe I'll support this someday */
#define DMA_BUFFER_SIZE 0x1000
/* maximum value that can be loaded into board's 24-bit counters*/
@@ -111,41 +112,41 @@ static const int max_counter_value = 0xffffff;
/* PCI-DAS64xxx base addresses */
-// indices of base address regions
+/* indices of base address regions */
enum base_address_regions {
PLX9080_BADDRINDEX = 0,
MAIN_BADDRINDEX = 2,
DIO_COUNTER_BADDRINDEX = 3,
};
-// priv(dev)->main_iobase registers
+/* priv(dev)->main_iobase registers */
enum write_only_registers {
- INTR_ENABLE_REG = 0x0, // interrupt enable register
- HW_CONFIG_REG = 0x2, // hardware config register
+ INTR_ENABLE_REG = 0x0, /* interrupt enable register */
+ HW_CONFIG_REG = 0x2, /* hardware config register */
DAQ_SYNC_REG = 0xc,
DAQ_ATRIG_LOW_4020_REG = 0xc,
- ADC_CONTROL0_REG = 0x10, // adc control register 0
- ADC_CONTROL1_REG = 0x12, // adc control register 1
+ ADC_CONTROL0_REG = 0x10, /* adc control register 0 */
+ ADC_CONTROL1_REG = 0x12, /* adc control register 1 */
CALIBRATION_REG = 0x14,
- ADC_SAMPLE_INTERVAL_LOWER_REG = 0x16, // lower 16 bits of adc sample interval counter
- ADC_SAMPLE_INTERVAL_UPPER_REG = 0x18, // upper 8 bits of adc sample interval counter
- ADC_DELAY_INTERVAL_LOWER_REG = 0x1a, // lower 16 bits of delay interval counter
- ADC_DELAY_INTERVAL_UPPER_REG = 0x1c, // upper 8 bits of delay interval counter
- ADC_COUNT_LOWER_REG = 0x1e, // lower 16 bits of hardware conversion/scan counter
- ADC_COUNT_UPPER_REG = 0x20, // upper 8 bits of hardware conversion/scan counter
- ADC_START_REG = 0x22, // software trigger to start aquisition
- ADC_CONVERT_REG = 0x24, // initiates single conversion
- ADC_QUEUE_CLEAR_REG = 0x26, // clears adc queue
- ADC_QUEUE_LOAD_REG = 0x28, // loads adc queue
+ ADC_SAMPLE_INTERVAL_LOWER_REG = 0x16, /* lower 16 bits of adc sample interval counter */
+ ADC_SAMPLE_INTERVAL_UPPER_REG = 0x18, /* upper 8 bits of adc sample interval counter */
+ ADC_DELAY_INTERVAL_LOWER_REG = 0x1a, /* lower 16 bits of delay interval counter */
+ ADC_DELAY_INTERVAL_UPPER_REG = 0x1c, /* upper 8 bits of delay interval counter */
+ ADC_COUNT_LOWER_REG = 0x1e, /* lower 16 bits of hardware conversion/scan counter */
+ ADC_COUNT_UPPER_REG = 0x20, /* upper 8 bits of hardware conversion/scan counter */
+ ADC_START_REG = 0x22, /* software trigger to start aquisition */
+ ADC_CONVERT_REG = 0x24, /* initiates single conversion */
+ ADC_QUEUE_CLEAR_REG = 0x26, /* clears adc queue */
+ ADC_QUEUE_LOAD_REG = 0x28, /* loads adc queue */
ADC_BUFFER_CLEAR_REG = 0x2a,
- ADC_QUEUE_HIGH_REG = 0x2c, // high channel for internal queue, use adc_chan_bits() inline above
- DAC_CONTROL0_REG = 0x50, // dac control register 0
- DAC_CONTROL1_REG = 0x52, // dac control register 0
- DAC_SAMPLE_INTERVAL_LOWER_REG = 0x54, // lower 16 bits of dac sample interval counter
- DAC_SAMPLE_INTERVAL_UPPER_REG = 0x56, // upper 8 bits of dac sample interval counter
+ ADC_QUEUE_HIGH_REG = 0x2c, /* high channel for internal queue, use adc_chan_bits() inline above */
+ DAC_CONTROL0_REG = 0x50, /* dac control register 0 */
+ DAC_CONTROL1_REG = 0x52, /* dac control register 0 */
+ DAC_SAMPLE_INTERVAL_LOWER_REG = 0x54, /* lower 16 bits of dac sample interval counter */
+ DAC_SAMPLE_INTERVAL_UPPER_REG = 0x56, /* upper 8 bits of dac sample interval counter */
DAC_SELECT_REG = 0x60,
DAC_START_REG = 0x64,
- DAC_BUFFER_CLEAR_REG = 0x66, // clear dac buffer
+ DAC_BUFFER_CLEAR_REG = 0x66, /* clear dac buffer */
};
static inline unsigned int dac_convert_reg(unsigned int channel)
{
@@ -161,7 +162,7 @@ static inline unsigned int dac_msb_4020_reg(unsigned int channel)
}
enum read_only_registers {
- HW_STATUS_REG = 0x0, // hardware status register, reading this apparently clears pending interrupts as well
+ HW_STATUS_REG = 0x0, /* hardware status register, reading this apparently clears pending interrupts as well */
PIPE1_READ_REG = 0x4,
ADC_READ_PNTR_REG = 0x8,
LOWER_XFER_REG = 0x10,
@@ -170,13 +171,13 @@ enum read_only_registers {
};
enum read_write_registers {
- I8255_4020_REG = 0x48, // 8255 offset, for 4020 only
- ADC_QUEUE_FIFO_REG = 0x100, // external channel/gain queue, uses same bits as ADC_QUEUE_LOAD_REG
+ I8255_4020_REG = 0x48, /* 8255 offset, for 4020 only */
+ ADC_QUEUE_FIFO_REG = 0x100, /* external channel/gain queue, uses same bits as ADC_QUEUE_LOAD_REG */
ADC_FIFO_REG = 0x200, /* adc data fifo */
DAC_FIFO_REG = 0x300, /* dac data fifo, has weird interactions with external channel queue */
};
-// priv(dev)->dio_counter_iobase registers
+/* priv(dev)->dio_counter_iobase registers */
enum dio_counter_registers {
DIO_8255_OFFSET = 0x0,
DO_REG = 0x20,
@@ -185,47 +186,47 @@ enum dio_counter_registers {
DIO_DATA_60XX_REG = 0x48,
};
-// bit definitions for write-only registers
+/* bit definitions for write-only registers */
enum intr_enable_contents {
- ADC_INTR_SRC_MASK = 0x3, // bits that set adc interrupt source
- ADC_INTR_QFULL_BITS = 0x0, // interrupt fifo quater full
- ADC_INTR_EOC_BITS = 0x1, // interrupt end of conversion
- ADC_INTR_EOSCAN_BITS = 0x2, // interrupt end of scan
- ADC_INTR_EOSEQ_BITS = 0x3, // interrupt end of sequence (probably wont use this it's pretty fancy)
- EN_ADC_INTR_SRC_BIT = 0x4, // enable adc interrupt source
- EN_ADC_DONE_INTR_BIT = 0x8, // enable adc aquisition done interrupt
+ ADC_INTR_SRC_MASK = 0x3, /* bits that set adc interrupt source */
+ ADC_INTR_QFULL_BITS = 0x0, /* interrupt fifo quater full */
+ ADC_INTR_EOC_BITS = 0x1, /* interrupt end of conversion */
+ ADC_INTR_EOSCAN_BITS = 0x2, /* interrupt end of scan */
+ ADC_INTR_EOSEQ_BITS = 0x3, /* interrupt end of sequence (probably wont use this it's pretty fancy) */
+ EN_ADC_INTR_SRC_BIT = 0x4, /* enable adc interrupt source */
+ EN_ADC_DONE_INTR_BIT = 0x8, /* enable adc aquisition done interrupt */
DAC_INTR_SRC_MASK = 0x30,
DAC_INTR_QEMPTY_BITS = 0x0,
DAC_INTR_HIGH_CHAN_BITS = 0x10,
- EN_DAC_INTR_SRC_BIT = 0x40, // enable dac interrupt source
+ EN_DAC_INTR_SRC_BIT = 0x40, /* enable dac interrupt source */
EN_DAC_DONE_INTR_BIT = 0x80,
- EN_ADC_ACTIVE_INTR_BIT = 0x200, // enable adc active interrupt
- EN_ADC_STOP_INTR_BIT = 0x400, // enable adc stop trigger interrupt
- EN_DAC_ACTIVE_INTR_BIT = 0x800, // enable dac active interrupt
- EN_DAC_UNDERRUN_BIT = 0x4000, // enable dac underrun status bit
- EN_ADC_OVERRUN_BIT = 0x8000, // enable adc overrun status bit
+ EN_ADC_ACTIVE_INTR_BIT = 0x200, /* enable adc active interrupt */
+ EN_ADC_STOP_INTR_BIT = 0x400, /* enable adc stop trigger interrupt */
+ EN_DAC_ACTIVE_INTR_BIT = 0x800, /* enable dac active interrupt */
+ EN_DAC_UNDERRUN_BIT = 0x4000, /* enable dac underrun status bit */
+ EN_ADC_OVERRUN_BIT = 0x8000, /* enable adc overrun status bit */
};
enum hw_config_contents {
- MASTER_CLOCK_4020_MASK = 0x3, // bits that specify master clock source for 4020
- INTERNAL_CLOCK_4020_BITS = 0x1, // use 40 MHz internal master clock for 4020
- BNC_CLOCK_4020_BITS = 0x2, // use BNC input for master clock
- EXT_CLOCK_4020_BITS = 0x3, // use dio input for master clock
- EXT_QUEUE_BIT = 0x200, // use external channel/gain queue (more versatile than internal queue)
- SLOW_DAC_BIT = 0x400, // use 225 nanosec strobe when loading dac instead of 50 nanosec
- HW_CONFIG_DUMMY_BITS = 0x2000, // bit with unknown function yet given as default value in pci-das64 manual
- DMA_CH_SELECT_BIT = 0x8000, // bit selects channels 1/0 for analog input/output, otherwise 0/1
- FIFO_SIZE_REG = 0x4, // allows adjustment of fifo sizes
- DAC_FIFO_SIZE_MASK = 0xff00, // bits that set dac fifo size
+ MASTER_CLOCK_4020_MASK = 0x3, /* bits that specify master clock source for 4020 */
+ INTERNAL_CLOCK_4020_BITS = 0x1, /* use 40 MHz internal master clock for 4020 */
+ BNC_CLOCK_4020_BITS = 0x2, /* use BNC input for master clock */
+ EXT_CLOCK_4020_BITS = 0x3, /* use dio input for master clock */
+ EXT_QUEUE_BIT = 0x200, /* use external channel/gain queue (more versatile than internal queue) */
+ SLOW_DAC_BIT = 0x400, /* use 225 nanosec strobe when loading dac instead of 50 nanosec */
+ HW_CONFIG_DUMMY_BITS = 0x2000, /* bit with unknown function yet given as default value in pci-das64 manual */
+ DMA_CH_SELECT_BIT = 0x8000, /* bit selects channels 1/0 for analog input/output, otherwise 0/1 */
+ FIFO_SIZE_REG = 0x4, /* allows adjustment of fifo sizes */
+ DAC_FIFO_SIZE_MASK = 0xff00, /* bits that set dac fifo size */
DAC_FIFO_BITS = 0xf800, /* 8k sample ao fifo */
};
#define DAC_FIFO_SIZE 0x2000
enum daq_atrig_low_4020_contents {
- EXT_AGATE_BNC_BIT = 0x8000, // use trig/ext clk bnc input for analog gate signal
- EXT_STOP_TRIG_BNC_BIT = 0x4000, // use trig/ext clk bnc input for external stop trigger signal
- EXT_START_TRIG_BNC_BIT = 0x2000, // use trig/ext clk bnc input for external start trigger signal
+ EXT_AGATE_BNC_BIT = 0x8000, /* use trig/ext clk bnc input for analog gate signal */
+ EXT_STOP_TRIG_BNC_BIT = 0x4000, /* use trig/ext clk bnc input for external stop trigger signal */
+ EXT_START_TRIG_BNC_BIT = 0x2000, /* use trig/ext clk bnc input for external start trigger signal */
};
static inline uint16_t analog_trig_low_threshold_bits(uint16_t threshold)
{
@@ -233,34 +234,34 @@ static inline uint16_t analog_trig_low_threshold_bits(uint16_t threshold)
}
enum adc_control0_contents {
- ADC_GATE_SRC_MASK = 0x3, // bits that select gate
- ADC_SOFT_GATE_BITS = 0x1, // software gate
- ADC_EXT_GATE_BITS = 0x2, // external digital gate
- ADC_ANALOG_GATE_BITS = 0x3, // analog level gate
- ADC_GATE_LEVEL_BIT = 0x4, // level-sensitive gate (for digital)
- ADC_GATE_POLARITY_BIT = 0x8, // gate active low
+ ADC_GATE_SRC_MASK = 0x3, /* bits that select gate */
+ ADC_SOFT_GATE_BITS = 0x1, /* software gate */
+ ADC_EXT_GATE_BITS = 0x2, /* external digital gate */
+ ADC_ANALOG_GATE_BITS = 0x3, /* analog level gate */
+ ADC_GATE_LEVEL_BIT = 0x4, /* level-sensitive gate (for digital) */
+ ADC_GATE_POLARITY_BIT = 0x8, /* gate active low */
ADC_START_TRIG_SOFT_BITS = 0x10,
ADC_START_TRIG_EXT_BITS = 0x20,
ADC_START_TRIG_ANALOG_BITS = 0x30,
ADC_START_TRIG_MASK = 0x30,
- ADC_START_TRIG_FALLING_BIT = 0x40, // trig 1 uses falling edge
- ADC_EXT_CONV_FALLING_BIT = 0x800, // external pacing uses falling edge
- ADC_SAMPLE_COUNTER_EN_BIT = 0x1000, // enable hardware scan counter
- ADC_DMA_DISABLE_BIT = 0x4000, // disables dma
- ADC_ENABLE_BIT = 0x8000, // master adc enable
+ ADC_START_TRIG_FALLING_BIT = 0x40, /* trig 1 uses falling edge */
+ ADC_EXT_CONV_FALLING_BIT = 0x800, /* external pacing uses falling edge */
+ ADC_SAMPLE_COUNTER_EN_BIT = 0x1000, /* enable hardware scan counter */
+ ADC_DMA_DISABLE_BIT = 0x4000, /* disables dma */
+ ADC_ENABLE_BIT = 0x8000, /* master adc enable */
};
enum adc_control1_contents {
- ADC_QUEUE_CONFIG_BIT = 0x1, // should be set for boards with > 16 channels
+ ADC_QUEUE_CONFIG_BIT = 0x1, /* should be set for boards with > 16 channels */
CONVERT_POLARITY_BIT = 0x10,
EOC_POLARITY_BIT = 0x20,
- ADC_SW_GATE_BIT = 0x40, // software gate of adc
- ADC_DITHER_BIT = 0x200, // turn on extra noise for dithering
+ ADC_SW_GATE_BIT = 0x40, /* software gate of adc */
+ ADC_DITHER_BIT = 0x200, /* turn on extra noise for dithering */
RETRIGGER_BIT = 0x800,
ADC_LO_CHANNEL_4020_MASK = 0x300,
ADC_HI_CHANNEL_4020_MASK = 0xc00,
- TWO_CHANNEL_4020_BITS = 0x1000, // two channel mode for 4020
- FOUR_CHANNEL_4020_BITS = 0x2000, // four channel mode for 4020
+ TWO_CHANNEL_4020_BITS = 0x1000, /* two channel mode for 4020 */
+ FOUR_CHANNEL_4020_BITS = 0x2000, /* four channel mode for 4020 */
CHANNEL_MODE_4020_MASK = 0x3000,
ADC_MODE_MASK = 0xf000,
};
@@ -281,10 +282,10 @@ enum calibration_contents {
SELECT_8800_BIT = 0x1,
SELECT_8402_64XX_BIT = 0x2,
SELECT_1590_60XX_BIT = 0x2,
- CAL_EN_64XX_BIT = 0x40, // calibration enable for 64xx series
+ CAL_EN_64XX_BIT = 0x40, /* calibration enable for 64xx series */
SERIAL_DATA_IN_BIT = 0x80,
SERIAL_CLOCK_BIT = 0x100,
- CAL_EN_60XX_BIT = 0x200, // calibration enable for 60xx series
+ CAL_EN_60XX_BIT = 0x200, /* calibration enable for 60xx series */
CAL_GAIN_BIT = 0x800,
};
/* calibration sources for 6025 are:
@@ -308,11 +309,11 @@ static inline uint16_t adc_convert_chan_4020_bits(unsigned int channel)
};
enum adc_queue_load_contents {
- UNIP_BIT = 0x800, // unipolar/bipolar bit
- ADC_SE_DIFF_BIT = 0x1000, // single-ended/ differential bit
- ADC_COMMON_BIT = 0x2000, // non-referenced single-ended (common-mode input)
- QUEUE_EOSEQ_BIT = 0x4000, // queue end of sequence
- QUEUE_EOSCAN_BIT = 0x8000, // queue end of scan
+ UNIP_BIT = 0x800, /* unipolar/bipolar bit */
+ ADC_SE_DIFF_BIT = 0x1000, /* single-ended/ differential bit */
+ ADC_COMMON_BIT = 0x2000, /* non-referenced single-ended (common-mode input) */
+ QUEUE_EOSEQ_BIT = 0x4000, /* queue end of sequence */
+ QUEUE_EOSCAN_BIT = 0x8000, /* queue end of scan */
};
static inline uint16_t adc_chan_bits(unsigned int channel)
{
@@ -320,7 +321,7 @@ static inline uint16_t adc_chan_bits(unsigned int channel)
};
enum dac_control0_contents {
- DAC_ENABLE_BIT = 0x8000, // dac controller enable bit
+ DAC_ENABLE_BIT = 0x8000, /* dac controller enable bit */
DAC_CYCLIC_STOP_BIT = 0x4000,
DAC_WAVEFORM_MODE_BIT = 0x100,
DAC_EXT_UPDATE_FALLING_BIT = 0x80,
@@ -340,14 +341,14 @@ enum dac_control1_contents {
DAC_WRITE_POLARITY_BIT = 0x800, /* board-dependent setting */
DAC1_EXT_REF_BIT = 0x200,
DAC0_EXT_REF_BIT = 0x100,
- DAC_OUTPUT_ENABLE_BIT = 0x80, // dac output enable bit
+ DAC_OUTPUT_ENABLE_BIT = 0x80, /* dac output enable bit */
DAC_UPDATE_POLARITY_BIT = 0x40, /* board-dependent setting */
DAC_SW_GATE_BIT = 0x20,
DAC1_UNIPOLAR_BIT = 0x8,
DAC0_UNIPOLAR_BIT = 0x2,
};
-// bit definitions for read-only registers
+/* bit definitions for read-only registers */
enum hw_status_contents {
DAC_UNDERRUN_BIT = 0x1,
ADC_OVERRUN_BIT = 0x2,
@@ -378,7 +379,7 @@ static inline unsigned int adc_upper_write_ptr_code(uint16_t prepost_bits)
return (prepost_bits >> 14) & 0x3;
}
-// I2C addresses for 4020
+/* I2C addresses for 4020 */
enum i2c_addresses {
RANGE_CAL_I2C_ADDR = 0x20,
CALDAC0_I2C_ADDR = 0xc,
@@ -386,8 +387,8 @@ enum i2c_addresses {
};
enum range_cal_i2c_contents {
- ADC_SRC_4020_MASK = 0x70, // bits that set what source the adc converter measures
- BNC_TRIG_THRESHOLD_0V_BIT = 0x80, // make bnc trig/ext clock threshold 0V instead of 2.5V
+ ADC_SRC_4020_MASK = 0x70, /* bits that set what source the adc converter measures */
+ BNC_TRIG_THRESHOLD_0V_BIT = 0x80, /* make bnc trig/ext clock threshold 0V instead of 2.5V */
};
static inline uint8_t adc_src_4020_bits(unsigned int source)
{
@@ -395,11 +396,11 @@ static inline uint8_t adc_src_4020_bits(unsigned int source)
};
static inline uint8_t attenuate_bit(unsigned int channel)
{
- // attenuate channel (+-5V input range)
+ /* attenuate channel (+-5V input range) */
return 1 << (channel & 0x3);
};
-// analog input ranges for 64xx boards
+/* analog input ranges for 64xx boards */
static const struct comedi_lrange ai_ranges_64xx = {
8,
{
@@ -468,7 +469,7 @@ static const struct comedi_lrange ai_ranges_6052 = {
}
};
-// analog input ranges for 4020 board
+/* analog input ranges for 4020 board */
static const struct comedi_lrange ai_ranges_4020 = {
2,
{
@@ -477,7 +478,7 @@ static const struct comedi_lrange ai_ranges_4020 = {
}
};
-// analog output ranges
+/* analog output ranges */
static const struct comedi_lrange ao_ranges_64xx = {
4,
{
@@ -543,40 +544,40 @@ struct hw_fifo_info {
struct pcidas64_board {
const char *name;
- int device_id; // pci device id
- int ai_se_chans; // number of ai inputs in single-ended mode
- int ai_bits; // analog input resolution
- int ai_speed; // fastest conversion period in ns
+ int device_id; /* pci device id */
+ int ai_se_chans; /* number of ai inputs in single-ended mode */
+ int ai_bits; /* analog input resolution */
+ int ai_speed; /* fastest conversion period in ns */
const struct comedi_lrange *ai_range_table;
- int ao_nchan; // number of analog out channels
- int ao_bits; // analog output resolution
- int ao_scan_speed; // analog output speed (for a scan, not conversion)
+ int ao_nchan; /* number of analog out channels */
+ int ao_bits; /* analog output resolution */
+ int ao_scan_speed; /* analog output speed (for a scan, not conversion) */
const struct comedi_lrange *ao_range_table;
const int *ao_range_code;
const struct hw_fifo_info *const ai_fifo;
- enum register_layout layout; // different board families have slightly different registers
+ enum register_layout layout; /* different board families have slightly different registers */
unsigned has_8255:1;
};
static const struct hw_fifo_info ai_fifo_4020 = {
- num_segments:2,
- max_segment_length:0x8000,
- sample_packing_ratio:2,
- fifo_size_reg_mask:0x7f,
+ .num_segments = 2,
+ .max_segment_length = 0x8000,
+ .sample_packing_ratio = 2,
+ .fifo_size_reg_mask = 0x7f,
};
static const struct hw_fifo_info ai_fifo_64xx = {
- num_segments:4,
- max_segment_length:0x800,
- sample_packing_ratio:1,
- fifo_size_reg_mask:0x3f,
+ .num_segments = 4,
+ .max_segment_length = 0x800,
+ .sample_packing_ratio = 1,
+ .fifo_size_reg_mask = 0x3f,
};
static const struct hw_fifo_info ai_fifo_60xx = {
- num_segments:4,
- max_segment_length:0x800,
- sample_packing_ratio:1,
- fifo_size_reg_mask:0x7f,
+ .num_segments = 4,
+ .max_segment_length = 0x800,
+ .sample_packing_ratio = 1,
+ .fifo_size_reg_mask = 0x7f,
};
/* maximum number of dma transfers we will chain together into a ring
@@ -584,7 +585,7 @@ static const struct hw_fifo_info ai_fifo_60xx = {
#define MAX_AI_DMA_RING_COUNT (0x80000 / DMA_BUFFER_SIZE)
#define MIN_AI_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE)
#define AO_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE)
-static inline unsigned int ai_dma_ring_count(struct pcidas64_board * board)
+static inline unsigned int ai_dma_ring_count(struct pcidas64_board *board)
{
if (board->layout == LAYOUT_4020)
return MAX_AI_DMA_RING_COUNT;
@@ -596,84 +597,84 @@ static const int bytes_in_sample = 2;
static const struct pcidas64_board pcidas64_boards[] = {
{
- name: "pci-das6402/16",
- device_id:0x1d,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ao_range_table:&ao_ranges_64xx,
- ao_range_code:ao_range_code_64xx,
- ai_fifo: &ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das6402/16",
+ .device_id = 0x1d,
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ao_range_table = &ao_ranges_64xx,
+ .ao_range_code = ao_range_code_64xx,
+ .ai_fifo = &ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das6402/12", // XXX check
- device_id:0x1e,
- ai_se_chans:64,
- ai_bits: 12,
- ai_speed:5000,
- ao_nchan:2,
- ao_bits: 12,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ao_range_table:&ao_ranges_64xx,
- ao_range_code:ao_range_code_64xx,
- ai_fifo: &ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das6402/12", /* XXX check */
+ .device_id = 0x1e,
+ .ai_se_chans = 64,
+ .ai_bits = 12,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ao_range_table = &ao_ranges_64xx,
+ .ao_range_code = ao_range_code_64xx,
+ .ai_fifo = &ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m1/16",
- device_id:0x35,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:1000,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ao_range_table:&ao_ranges_64xx,
- ao_range_code:ao_range_code_64xx,
- ai_fifo: &ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m1/16",
+ .device_id = 0x35,
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 1000,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ao_range_table = &ao_ranges_64xx,
+ .ao_range_code = ao_range_code_64xx,
+ .ai_fifo = &ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m2/16",
- device_id:0x36,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:500,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ao_range_table:&ao_ranges_64xx,
- ao_range_code:ao_range_code_64xx,
- ai_fifo: &ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m2/16",
+ .device_id = 0x36,
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 500,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ao_range_table = &ao_ranges_64xx,
+ .ao_range_code = ao_range_code_64xx,
+ .ai_fifo = &ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m3/16",
- device_id:0x37,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:333,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ao_range_table:&ao_ranges_64xx,
- ao_range_code:ao_range_code_64xx,
- ai_fifo: &ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m3/16",
+ .device_id = 0x37,
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 333,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ao_range_table = &ao_ranges_64xx,
+ .ao_range_code = ao_range_code_64xx,
+ .ai_fifo = &ai_fifo_64xx,
+ .has_8255 = 1,
},
{
.name = "pci-das6013",
@@ -691,334 +692,328 @@ static const struct pcidas64_board pcidas64_boards[] = {
.has_8255 = 0,
},
{
- name: "pci-das6014",
- device_id:0x79,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:100000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_60xx,
- ao_range_table:&ao_ranges_60xx,
- ao_range_code:ao_range_code_60xx,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6014",
+ .device_id = 0x79,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 100000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_60xx,
+ .ao_range_table = &ao_ranges_60xx,
+ .ao_range_code = ao_range_code_60xx,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6023",
- device_id:0x5d,
- ai_se_chans:16,
- ai_bits: 12,
- ai_speed:5000,
- ao_nchan:0,
- ao_scan_speed:100000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_60xx,
- ao_range_table:&ao_ranges_60xx,
- ao_range_code:ao_range_code_60xx,
- ai_fifo: &ai_fifo_60xx,
- has_8255:1,
+ .name = "pci-das6023",
+ .device_id = 0x5d,
+ .ai_se_chans = 16,
+ .ai_bits = 12,
+ .ai_speed = 5000,
+ .ao_nchan = 0,
+ .ao_scan_speed = 100000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_60xx,
+ .ao_range_table = &ao_ranges_60xx,
+ .ao_range_code = ao_range_code_60xx,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 1,
},
{
- name: "pci-das6025",
- device_id:0x5e,
- ai_se_chans:16,
- ai_bits: 12,
- ai_speed:5000,
- ao_nchan:2,
- ao_bits: 12,
- ao_scan_speed:100000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_60xx,
- ao_range_table:&ao_ranges_60xx,
- ao_range_code:ao_range_code_60xx,
- ai_fifo: &ai_fifo_60xx,
- has_8255:1,
+ .name = "pci-das6025",
+ .device_id = 0x5e,
+ .ai_se_chans = 16,
+ .ai_bits = 12,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .ao_scan_speed = 100000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_60xx,
+ .ao_range_table = &ao_ranges_60xx,
+ .ao_range_code = ao_range_code_60xx,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 1,
},
{
- name: "pci-das6030",
- device_id:0x5f,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:10000,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:10000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6030,
- ao_range_table:&ao_ranges_6030,
- ao_range_code:ao_range_code_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6030",
+ .device_id = 0x5f,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 10000,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6030,
+ .ao_range_table = &ao_ranges_6030,
+ .ao_range_code = ao_range_code_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6031",
- device_id:0x60,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:10000,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:10000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6030,
- ao_range_table:&ao_ranges_6030,
- ao_range_code:ao_range_code_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6031",
+ .device_id = 0x60,
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 10000,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6030,
+ .ao_range_table = &ao_ranges_6030,
+ .ao_range_code = ao_range_code_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6032",
- device_id:0x61,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:10000,
- ao_nchan:0,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6032",
+ .device_id = 0x61,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 10000,
+ .ao_nchan = 0,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6033",
- device_id:0x62,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:10000,
- ao_nchan:0,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6033",
+ .device_id = 0x62,
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 10000,
+ .ao_nchan = 0,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6034",
- device_id:0x63,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:0,
- ao_scan_speed:0,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_60xx,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6034",
+ .device_id = 0x63,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 0,
+ .ao_scan_speed = 0,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_60xx,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6035",
- device_id:0x64,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:2,
- ao_bits: 12,
- ao_scan_speed:100000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_60xx,
- ao_range_table:&ao_ranges_60xx,
- ao_range_code:ao_range_code_60xx,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6035",
+ .device_id = 0x64,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .ao_scan_speed = 100000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_60xx,
+ .ao_range_table = &ao_ranges_60xx,
+ .ao_range_code = ao_range_code_60xx,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6036",
- device_id:0x6f,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:100000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_60xx,
- ao_range_table:&ao_ranges_60xx,
- ao_range_code:ao_range_code_60xx,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6036",
+ .device_id = 0x6f,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 100000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_60xx,
+ .ao_range_table = &ao_ranges_60xx,
+ .ao_range_code = ao_range_code_60xx,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6040",
- device_id:0x65,
- ai_se_chans:16,
- ai_bits: 12,
- ai_speed:2000,
- ao_nchan:2,
- ao_bits: 12,
- ao_scan_speed:1000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6052,
- ao_range_table:&ao_ranges_6030,
- ao_range_code:ao_range_code_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6040",
+ .device_id = 0x65,
+ .ai_se_chans = 16,
+ .ai_bits = 12,
+ .ai_speed = 2000,
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .ao_scan_speed = 1000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6052,
+ .ao_range_table = &ao_ranges_6030,
+ .ao_range_code = ao_range_code_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6052",
- device_id:0x66,
- ai_se_chans:16,
- ai_bits: 16,
- ai_speed:3333,
- ao_nchan:2,
- ao_bits: 16,
- ao_scan_speed:3333,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6052,
- ao_range_table:&ao_ranges_6030,
- ao_range_code:ao_range_code_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6052",
+ .device_id = 0x66,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 3333,
+ .ao_nchan = 2,
+ .ao_bits = 16,
+ .ao_scan_speed = 3333,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6052,
+ .ao_range_table = &ao_ranges_6030,
+ .ao_range_code = ao_range_code_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6070",
- device_id:0x67,
- ai_se_chans:16,
- ai_bits: 12,
- ai_speed:800,
- ao_nchan:2,
- ao_bits: 12,
- ao_scan_speed:1000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6052,
- ao_range_table:&ao_ranges_6030,
- ao_range_code:ao_range_code_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6070",
+ .device_id = 0x67,
+ .ai_se_chans = 16,
+ .ai_bits = 12,
+ .ai_speed = 800,
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .ao_scan_speed = 1000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6052,
+ .ao_range_table = &ao_ranges_6030,
+ .ao_range_code = ao_range_code_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das6071",
- device_id:0x68,
- ai_se_chans:64,
- ai_bits: 12,
- ai_speed:800,
- ao_nchan:2,
- ao_bits: 12,
- ao_scan_speed:1000,
- layout: LAYOUT_60XX,
- ai_range_table:&ai_ranges_6052,
- ao_range_table:&ao_ranges_6030,
- ao_range_code:ao_range_code_6030,
- ai_fifo: &ai_fifo_60xx,
- has_8255:0,
+ .name = "pci-das6071",
+ .device_id = 0x68,
+ .ai_se_chans = 64,
+ .ai_bits = 12,
+ .ai_speed = 800,
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .ao_scan_speed = 1000,
+ .layout = LAYOUT_60XX,
+ .ai_range_table = &ai_ranges_6052,
+ .ao_range_table = &ao_ranges_6030,
+ .ao_range_code = ao_range_code_6030,
+ .ai_fifo = &ai_fifo_60xx,
+ .has_8255 = 0,
},
{
- name: "pci-das4020/12",
- device_id:0x52,
- ai_se_chans:4,
- ai_bits: 12,
- ai_speed:50,
- ao_bits: 12,
- ao_nchan:2,
- ao_scan_speed:0, // no hardware pacing on ao
- layout: LAYOUT_4020,
- ai_range_table:&ai_ranges_4020,
- ao_range_table:&ao_ranges_4020,
- ao_range_code:ao_range_code_4020,
- ai_fifo: &ai_fifo_4020,
- has_8255:1,
+ .name = "pci-das4020/12",
+ .device_id = 0x52,
+ .ai_se_chans = 4,
+ .ai_bits = 12,
+ .ai_speed = 50,
+ .ao_bits = 12,
+ .ao_nchan = 2,
+ .ao_scan_speed = 0, /* no hardware pacing on ao */
+ .layout = LAYOUT_4020,
+ .ai_range_table = &ai_ranges_4020,
+ .ao_range_table = &ao_ranges_4020,
+ .ao_range_code = ao_range_code_4020,
+ .ai_fifo = &ai_fifo_4020,
+ .has_8255 = 1,
},
#if 0
{
- name: "pci-das6402/16/jr",
- device_id:0 // XXX,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:5000,
- ao_nchan:0,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das6402/16/jr",
+ .device_id = 0 /* XXX, */
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 0,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m1/16/jr",
- device_id:0 // XXX,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:1000,
- ao_nchan:0,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m1/16/jr",
+ .device_id = 0 /* XXX, */
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 1000,
+ .ao_nchan = 0,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m2/16/jr",
- device_id:0 // XXX,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:500,
- ao_nchan:0,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m2/16/jr",
+ .device_id = 0 /* XXX, */
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 500,
+ .ao_nchan = 0,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m3/16/jr",
- device_id:0 // XXX,
- ai_se_chans:64,
- ai_bits: 16,
- ai_speed:333,
- ao_nchan:0,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m3/16/jr",
+ .device_id = 0 /* XXX, */
+ .ai_se_chans = 64,
+ .ai_bits = 16,
+ .ai_speed = 333,
+ .ao_nchan = 0,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m1/14",
- device_id:0, // XXX
- ai_se_chans:64,
- ai_bits: 14,
- ai_speed:1000,
- ao_nchan:2,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m1/14",
+ .device_id = 0, /* XXX */
+ .ai_se_chans = 64,
+ .ai_bits = 14,
+ .ai_speed = 1000,
+ .ao_nchan = 2,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m2/14",
- device_id:0, // XXX
- ai_se_chans:64,
- ai_bits: 14,
- ai_speed:500,
- ao_nchan:2,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m2/14",
+ .device_id = 0, /* XXX */
+ .ai_se_chans = 64,
+ .ai_bits = 14,
+ .ai_speed = 500,
+ .ao_nchan = 2,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
{
- name: "pci-das64/m3/14",
- device_id:0, // XXX
- ai_se_chans:64,
- ai_bits: 14,
- ai_speed:333,
- ao_nchan:2,
- ao_scan_speed:10000,
- layout: LAYOUT_64XX,
- ai_range_table:&ai_ranges_64xx,
- ai_fifo: ai_fifo_64xx,
- has_8255:1,
+ .name = "pci-das64/m3/14",
+ .device_id = 0, /* XXX */
+ .ai_se_chans = 64,
+ .ai_bits = 14,
+ .ai_speed = 333,
+ .ao_nchan = 2,
+ .ao_scan_speed = 10000,
+ .layout = LAYOUT_64XX,
+ .ai_range_table = &ai_ranges_64xx,
+ .ai_fifo = ai_fifo_64xx,
+ .has_8255 = 1,
},
#endif
};
-// Number of boards in cb_pcidas_boards
-static inline unsigned int num_boards(void)
-{
- return sizeof(pcidas64_boards) / sizeof(struct pcidas64_board);
-}
-
static DEFINE_PCI_DEVICE_TABLE(pcidas64_pci_table) = {
{PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -1049,7 +1044,7 @@ static inline struct pcidas64_board *board(const struct comedi_device * dev)
return (struct pcidas64_board *) dev->board_ptr;
}
-static inline unsigned short se_diff_bit_6xxx(struct comedi_device * dev,
+static inline unsigned short se_diff_bit_6xxx(struct comedi_device *dev,
int use_differential)
{
if ((board(dev)->layout == LAYOUT_64XX && !use_differential) ||
@@ -1060,50 +1055,50 @@ static inline unsigned short se_diff_bit_6xxx(struct comedi_device * dev,
};
struct ext_clock_info {
- unsigned int divisor; // master clock divisor to use for scans with external master clock
- unsigned int chanspec; // chanspec for master clock input when used as scan begin src
+ unsigned int divisor; /* master clock divisor to use for scans with external master clock */
+ unsigned int chanspec; /* chanspec for master clock input when used as scan begin src */
};
/* this structure is for data unique to this hardware driver. */
struct pcidas64_private {
- struct pci_dev *hw_dev; // pointer to board's pci_dev struct
- // base addresses (physical)
+ struct pci_dev *hw_dev; /* pointer to board's pci_dev struct */
+ /* base addresses (physical) */
resource_size_t plx9080_phys_iobase;
resource_size_t main_phys_iobase;
resource_size_t dio_counter_phys_iobase;
- // base addresses (ioremapped)
+ /* base addresses (ioremapped) */
void *plx9080_iobase;
void *main_iobase;
void *dio_counter_iobase;
- // local address (used by dma controller)
+ /* local address (used by dma controller) */
uint32_t local0_iobase;
uint32_t local1_iobase;
- volatile unsigned int ai_count; // number of analog input samples remaining
- uint16_t *ai_buffer[MAX_AI_DMA_RING_COUNT]; // dma buffers for analog input
- dma_addr_t ai_buffer_bus_addr[MAX_AI_DMA_RING_COUNT]; // physical addresses of ai dma buffers
- struct plx_dma_desc *ai_dma_desc; // array of ai dma descriptors read by plx9080, allocated to get proper alignment
- dma_addr_t ai_dma_desc_bus_addr; // physical address of ai dma descriptor array
- volatile unsigned int ai_dma_index; // index of the ai dma descriptor/buffer that is currently being used
- uint16_t *ao_buffer[AO_DMA_RING_COUNT]; // dma buffers for analog output
- dma_addr_t ao_buffer_bus_addr[AO_DMA_RING_COUNT]; // physical addresses of ao dma buffers
+ volatile unsigned int ai_count; /* number of analog input samples remaining */
+ uint16_t *ai_buffer[MAX_AI_DMA_RING_COUNT]; /* dma buffers for analog input */
+ dma_addr_t ai_buffer_bus_addr[MAX_AI_DMA_RING_COUNT]; /* physical addresses of ai dma buffers */
+ struct plx_dma_desc *ai_dma_desc; /* array of ai dma descriptors read by plx9080, allocated to get proper alignment */
+ dma_addr_t ai_dma_desc_bus_addr; /* physical address of ai dma descriptor array */
+ volatile unsigned int ai_dma_index; /* index of the ai dma descriptor/buffer that is currently being used */
+ uint16_t *ao_buffer[AO_DMA_RING_COUNT]; /* dma buffers for analog output */
+ dma_addr_t ao_buffer_bus_addr[AO_DMA_RING_COUNT]; /* physical addresses of ao dma buffers */
struct plx_dma_desc *ao_dma_desc;
dma_addr_t ao_dma_desc_bus_addr;
- volatile unsigned int ao_dma_index; // keeps track of buffer where the next ao sample should go
- volatile unsigned long ao_count; // number of analog output samples remaining
- volatile unsigned int ao_value[2]; // remember what the analog outputs are set to, to allow readback
- unsigned int hw_revision; // stc chip hardware revision number
- volatile unsigned int intr_enable_bits; // last bits sent to INTR_ENABLE_REG register
- volatile uint16_t adc_control1_bits; // last bits sent to ADC_CONTROL1_REG register
- volatile uint16_t fifo_size_bits; // last bits sent to FIFO_SIZE_REG register
- volatile uint16_t hw_config_bits; // last bits sent to HW_CONFIG_REG register
+ volatile unsigned int ao_dma_index; /* keeps track of buffer where the next ao sample should go */
+ volatile unsigned long ao_count; /* number of analog output samples remaining */
+ volatile unsigned int ao_value[2]; /* remember what the analog outputs are set to, to allow readback */
+ unsigned int hw_revision; /* stc chip hardware revision number */
+ volatile unsigned int intr_enable_bits; /* last bits sent to INTR_ENABLE_REG register */
+ volatile uint16_t adc_control1_bits; /* last bits sent to ADC_CONTROL1_REG register */
+ volatile uint16_t fifo_size_bits; /* last bits sent to FIFO_SIZE_REG register */
+ volatile uint16_t hw_config_bits; /* last bits sent to HW_CONFIG_REG register */
volatile uint16_t dac_control1_bits;
- volatile uint32_t plx_control_bits; // last bits written to plx9080 control register
- volatile uint32_t plx_intcsr_bits; // last bits written to plx interrupt control and status register
- volatile int calibration_source; // index of calibration source readable through ai ch0
- volatile uint8_t i2c_cal_range_bits; // bits written to i2c calibration/range register
- volatile unsigned int ext_trig_falling; // configure digital triggers to trigger on falling edge
- // states of various devices stored to enable read-back
+ volatile uint32_t plx_control_bits; /* last bits written to plx9080 control register */
+ volatile uint32_t plx_intcsr_bits; /* last bits written to plx interrupt control and status register */
+ volatile int calibration_source; /* index of calibration source readable through ai ch0 */
+ volatile uint8_t i2c_cal_range_bits; /* bits written to i2c calibration/range register */
+ volatile unsigned int ext_trig_falling; /* configure digital triggers to trigger on falling edge */
+ /* states of various devices stored to enable read-back */
unsigned int ad8402_state[2];
unsigned int caldac_state[8];
volatile short ai_cmd_running;
@@ -1127,82 +1122,82 @@ static inline struct pcidas64_private *priv(struct comedi_device * dev)
* the board, and also about the kernel module that contains
* the device code.
*/
-static int attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int detach(struct comedi_device * dev);
+static int attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int detach(struct comedi_device *dev);
static struct comedi_driver driver_cb_pcidas = {
- driver_name:"cb_pcidas64",
- module:THIS_MODULE,
- attach:attach,
- detach:detach,
+ .driver_name = "cb_pcidas64",
+ .module = THIS_MODULE,
+ .attach = attach,
+ .detach = detach,
};
-static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * subdev,
+static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *subdev,
unsigned int trig_num);
-static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG);
-static int ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static irqreturn_t handle_interrupt(int irq, void *d);
+static int ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int dio_callback(int dir, int port, int data, unsigned long arg);
static int dio_callback_4020(int dir, int port, int data, unsigned long arg);
-static int di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dio_60xx_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dio_60xx_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ad8402_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static void ad8402_write(struct comedi_device * dev, unsigned int channel,
+static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ad8402_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static void ad8402_write(struct comedi_device *dev, unsigned int channel,
unsigned int value);
-static int ad8402_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static void check_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd);
+static int ad8402_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd);
static unsigned int get_divisor(unsigned int ns, unsigned int flags);
-static void i2c_write(struct comedi_device * dev, unsigned int address,
- const uint8_t * data, unsigned int length);
-static void caldac_write(struct comedi_device * dev, unsigned int channel,
+static void i2c_write(struct comedi_device *dev, unsigned int address,
+ const uint8_t *data, unsigned int length);
+static void caldac_write(struct comedi_device *dev, unsigned int channel,
unsigned int value);
-static int caldac_8800_write(struct comedi_device * dev, unsigned int address,
+static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value);
-//static int dac_1590_write(struct comedi_device *dev, unsigned int dac_a, unsigned int dac_b);
-static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_channel,
+/* static int dac_1590_write(struct comedi_device *dev, unsigned int dac_a, unsigned int dac_b); */
+static int caldac_i2c_write(struct comedi_device *dev, unsigned int caldac_channel,
unsigned int value);
-static void abort_dma(struct comedi_device * dev, unsigned int channel);
-static void disable_plx_interrupts(struct comedi_device * dev);
-static int set_ai_fifo_size(struct comedi_device * dev, unsigned int num_samples);
-static unsigned int ai_fifo_size(struct comedi_device * dev);
-static int set_ai_fifo_segment_length(struct comedi_device * dev,
+static void abort_dma(struct comedi_device *dev, unsigned int channel);
+static void disable_plx_interrupts(struct comedi_device *dev);
+static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples);
+static unsigned int ai_fifo_size(struct comedi_device *dev);
+static int set_ai_fifo_segment_length(struct comedi_device *dev,
unsigned int num_entries);
-static void disable_ai_pacing(struct comedi_device * dev);
-static void disable_ai_interrupts(struct comedi_device * dev);
-static void enable_ai_interrupts(struct comedi_device * dev, const struct comedi_cmd * cmd);
+static void disable_ai_pacing(struct comedi_device *dev);
+static void disable_ai_interrupts(struct comedi_device *dev);
+static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_cmd *cmd);
static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags);
-static void load_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd);
+static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd);
COMEDI_PCI_INITCLEANUP(driver_cb_pcidas, pcidas64_pci_table);
-static unsigned int ai_range_bits_6xxx(const struct comedi_device * dev,
+static unsigned int ai_range_bits_6xxx(const struct comedi_device *dev,
unsigned int range_index)
{
const struct comedi_krange *range =
@@ -1246,7 +1241,7 @@ static unsigned int ai_range_bits_6xxx(const struct comedi_device * dev,
return bits;
}
-static unsigned int hw_revision(const struct comedi_device * dev,
+static unsigned int hw_revision(const struct comedi_device *dev,
uint16_t hw_status_bits)
{
if (board(dev)->layout == LAYOUT_4020)
@@ -1255,7 +1250,7 @@ static unsigned int hw_revision(const struct comedi_device * dev,
return (hw_status_bits >> 12) & 0xf;
}
-static void set_dac_range_bits(struct comedi_device * dev, volatile uint16_t * bits,
+static void set_dac_range_bits(struct comedi_device *dev, volatile uint16_t *bits,
unsigned int channel, unsigned int range)
{
unsigned int code = board(dev)->ao_range_code[range];
@@ -1269,13 +1264,13 @@ static void set_dac_range_bits(struct comedi_device * dev, volatile uint16_t * b
*bits |= code << (2 * channel);
};
-static inline int ao_cmd_is_supported(const struct pcidas64_board * board)
+static inline int ao_cmd_is_supported(const struct pcidas64_board *board)
{
return board->ao_nchan && board->layout != LAYOUT_4020;
}
-// initialize plx9080 chip
-static void init_plx9080(struct comedi_device * dev)
+/* initialize plx9080 chip */
+static void init_plx9080(struct comedi_device *dev)
{
uint32_t bits;
void *plx_iobase = priv(dev)->plx9080_iobase;
@@ -1283,7 +1278,7 @@ static void init_plx9080(struct comedi_device * dev)
priv(dev)->plx_control_bits =
readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG);
- // plx9080 dump
+ /* plx9080 dump */
DEBUG_PRINT(" plx interrupt status 0x%x\n",
readl(plx_iobase + PLX_INTRCS_REG));
DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG));
@@ -1327,35 +1322,35 @@ static void init_plx9080(struct comedi_device * dev)
abort_dma(dev, 0);
abort_dma(dev, 1);
- // configure dma0 mode
+ /* configure dma0 mode */
bits = 0;
- // enable ready input, not sure if this is necessary
+ /* enable ready input, not sure if this is necessary */
bits |= PLX_DMA_EN_READYIN_BIT;
- // enable bterm, not sure if this is necessary
+ /* enable bterm, not sure if this is necessary */
bits |= PLX_EN_BTERM_BIT;
- // enable dma chaining
+ /* enable dma chaining */
bits |= PLX_EN_CHAIN_BIT;
- // enable interrupt on dma done (probably don't need this, since chain never finishes)
+ /* enable interrupt on dma done (probably don't need this, since chain never finishes) */
bits |= PLX_EN_DMA_DONE_INTR_BIT;
- // don't increment local address during transfers (we are transferring from a fixed fifo register)
+ /* don't increment local address during transfers (we are transferring from a fixed fifo register) */
bits |= PLX_LOCAL_ADDR_CONST_BIT;
- // route dma interrupt to pci bus
+ /* route dma interrupt to pci bus */
bits |= PLX_DMA_INTR_PCI_BIT;
- // enable demand mode
+ /* enable demand mode */
bits |= PLX_DEMAND_MODE_BIT;
- // enable local burst mode
+ /* enable local burst mode */
bits |= PLX_DMA_LOCAL_BURST_EN_BIT;
- // 4020 uses 32 bit dma
+ /* 4020 uses 32 bit dma */
if (board(dev)->layout == LAYOUT_4020) {
bits |= PLX_LOCAL_BUS_32_WIDE_BITS;
- } else { // localspace0 bus is 16 bits wide
+ } else { /* localspace0 bus is 16 bits wide */
bits |= PLX_LOCAL_BUS_16_WIDE_BITS;
}
writel(bits, plx_iobase + PLX_DMA1_MODE_REG);
if (ao_cmd_is_supported(board(dev)))
writel(bits, plx_iobase + PLX_DMA0_MODE_REG);
- // enable interrupts on plx 9080
+ /* enable interrupts on plx 9080 */
priv(dev)->plx_intcsr_bits |=
ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
ICS_DMA0_E | ICS_DMA1_E;
@@ -1365,7 +1360,7 @@ static void init_plx9080(struct comedi_device * dev)
/* Allocate and initialize the subdevice structures.
*/
-static int setup_subdevices(struct comedi_device * dev)
+static int setup_subdevices(struct comedi_device *dev)
{
struct comedi_subdevice *s;
void *dio_8255_iobase;
@@ -1396,9 +1391,9 @@ static int setup_subdevices(struct comedi_device * dev)
if (board(dev)->layout == LAYOUT_4020) {
unsigned int i;
uint8_t data;
- // set adc to read from inputs (not internal calibration sources)
+ /* set adc to read from inputs (not internal calibration sources) */
priv(dev)->i2c_cal_range_bits = adc_src_4020_bits(4);
- // set channels to +-5 volt input ranges
+ /* set channels to +-5 volt input ranges */
for (i = 0; i < s->n_chan; i++)
priv(dev)->i2c_cal_range_bits |= attenuate_bit(i);
data = priv(dev)->i2c_cal_range_bits;
@@ -1428,7 +1423,7 @@ static int setup_subdevices(struct comedi_device * dev)
s->type = COMEDI_SUBD_UNUSED;
}
- // digital input
+ /* digital input */
s = dev->subdevices + 2;
if (board(dev)->layout == LAYOUT_64XX) {
s->type = COMEDI_SUBD_DI;
@@ -1440,7 +1435,7 @@ static int setup_subdevices(struct comedi_device * dev)
} else
s->type = COMEDI_SUBD_UNUSED;
- // digital output
+ /* digital output */
if (board(dev)->layout == LAYOUT_64XX) {
s = dev->subdevices + 3;
s->type = COMEDI_SUBD_DO;
@@ -1469,7 +1464,7 @@ static int setup_subdevices(struct comedi_device * dev)
} else
s->type = COMEDI_SUBD_UNUSED;
- // 8 channel dio for 60xx
+ /* 8 channel dio for 60xx */
s = dev->subdevices + 5;
if (board(dev)->layout == LAYOUT_60XX) {
s->type = COMEDI_SUBD_DIO;
@@ -1482,7 +1477,7 @@ static int setup_subdevices(struct comedi_device * dev)
} else
s->type = COMEDI_SUBD_UNUSED;
- // caldac
+ /* caldac */
s = dev->subdevices + 6;
s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
@@ -1496,7 +1491,7 @@ static int setup_subdevices(struct comedi_device * dev)
for (i = 0; i < s->n_chan; i++)
caldac_write(dev, i, s->maxdata / 2);
- // 2 channel ad8402 potentiometer
+ /* 2 channel ad8402 potentiometer */
s = dev->subdevices + 7;
if (board(dev)->layout == LAYOUT_64XX) {
s->type = COMEDI_SUBD_CALIB;
@@ -1510,7 +1505,7 @@ static int setup_subdevices(struct comedi_device * dev)
} else
s->type = COMEDI_SUBD_UNUSED;
- //serial EEPROM, if present
+ /* serial EEPROM, if present */
s = dev->subdevices + 8;
if (readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG) & CTL_EECHK) {
s->type = COMEDI_SUBD_MEMORY;
@@ -1521,34 +1516,34 @@ static int setup_subdevices(struct comedi_device * dev)
} else
s->type = COMEDI_SUBD_UNUSED;
- // user counter subd XXX
+ /* user counter subd XXX */
s = dev->subdevices + 9;
s->type = COMEDI_SUBD_UNUSED;
return 0;
}
-static void disable_plx_interrupts(struct comedi_device * dev)
+static void disable_plx_interrupts(struct comedi_device *dev)
{
priv(dev)->plx_intcsr_bits = 0;
writel(priv(dev)->plx_intcsr_bits,
priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
}
-static void init_stc_registers(struct comedi_device * dev)
+static void init_stc_registers(struct comedi_device *dev)
{
uint16_t bits;
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
- // bit should be set for 6025, although docs say boards with <= 16 chans should be cleared XXX
+ /* bit should be set for 6025, although docs say boards with <= 16 chans should be cleared XXX */
if (1)
priv(dev)->adc_control1_bits |= ADC_QUEUE_CONFIG_BIT;
writew(priv(dev)->adc_control1_bits,
priv(dev)->main_iobase + ADC_CONTROL1_REG);
- // 6402/16 manual says this register must be initialized to 0xff?
+ /* 6402/16 manual says this register must be initialized to 0xff? */
writew(0xff, priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
bits = SLOW_DAC_BIT | DMA_CH_SELECT_BIT;
@@ -1561,9 +1556,9 @@ static void init_stc_registers(struct comedi_device * dev)
writew(0, priv(dev)->main_iobase + DAQ_SYNC_REG);
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // set fifos to maximum size
+ /* set fifos to maximum size */
priv(dev)->fifo_size_bits |= DAC_FIFO_BITS;
set_ai_fifo_segment_length(dev,
board(dev)->ai_fifo->max_segment_length);
@@ -1577,11 +1572,11 @@ static void init_stc_registers(struct comedi_device * dev)
disable_ai_pacing(dev);
};
-int alloc_and_init_dma_members(struct comedi_device * dev)
+int alloc_and_init_dma_members(struct comedi_device *dev)
{
int i;
- // alocate pci dma buffers
+ /* alocate pci dma buffers */
for (i = 0; i < ai_dma_ring_count(board(dev)); i++) {
priv(dev)->ai_buffer[i] =
pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
@@ -1601,7 +1596,7 @@ int alloc_and_init_dma_members(struct comedi_device * dev)
}
}
}
- // allocate dma descriptors
+ /* allocate dma descriptors */
priv(dev)->ai_dma_desc =
pci_alloc_consistent(priv(dev)->hw_dev,
sizeof(struct plx_dma_desc) * ai_dma_ring_count(board(dev)),
@@ -1622,7 +1617,7 @@ int alloc_and_init_dma_members(struct comedi_device * dev)
DEBUG_PRINT("ao dma descriptors start at bus addr 0x%x\n",
priv(dev)->ao_dma_desc_bus_addr);
}
- // initialize dma descriptors
+ /* initialize dma descriptors */
for (i = 0; i < ai_dma_ring_count(board(dev)); i++) {
priv(dev)->ai_dma_desc[i].pci_start_addr =
cpu_to_le32(priv(dev)->ai_buffer_bus_addr[i]);
@@ -1663,7 +1658,7 @@ int alloc_and_init_dma_members(struct comedi_device * dev)
return 0;
}
-static inline void warn_external_queue(struct comedi_device * dev)
+static inline void warn_external_queue(struct comedi_device *dev)
{
comedi_error(dev,
"AO command and AI external channel queue cannot be used simultaneously.");
@@ -1697,16 +1692,16 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
- // is it not a computer boards card?
+ /* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
continue;
- // loop through cards supported by this driver
- for (index = 0; index < num_boards(); index++) {
+ /* loop through cards supported by this driver */
+ for (index = 0; index < ARRAY_SIZE(pcidas64_boards); index++) {
if (pcidas64_boards[index].device_id != pcidev->device)
continue;
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
PCI_SLOT(pcidev->devfn) !=
it->options[1]) {
@@ -1736,7 +1731,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
pci_set_master(pcidev);
- //Initialize dev->board_name
+ /* Initialize dev->board_name */
dev->board_name = board(dev)->name;
priv(dev)->plx9080_phys_iobase =
@@ -1746,7 +1741,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
priv(dev)->dio_counter_phys_iobase =
pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX);
- // remap, won't work with 2.0 kernels but who cares
+ /* remap, won't work with 2.0 kernels but who cares */
priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase,
pci_resource_len(pcidev, PLX9080_BADDRINDEX));
priv(dev)->main_iobase = ioremap(priv(dev)->main_phys_iobase,
@@ -1766,7 +1761,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
DEBUG_PRINT(" diocounter remapped to 0x%p\n",
priv(dev)->dio_counter_iobase);
- // figure out what local addresses are
+ /* figure out what local addresses are */
local_range =
readl(priv(dev)->plx9080_iobase +
PLX_LAS0RNG_REG) & LRNG_MEM_MASK;
@@ -1798,8 +1793,8 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(" stc hardware revision %i\n", priv(dev)->hw_revision);
init_plx9080(dev);
init_stc_registers(dev);
- // get irq
- if (comedi_request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
+ /* get irq */
+ if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
"cb_pcidas64", dev)) {
printk(" unable to allocate irq %u\n", pcidev->irq);
return -EINVAL;
@@ -1823,14 +1818,14 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int detach(struct comedi_device * dev)
+static int detach(struct comedi_device *dev)
{
unsigned int i;
printk("comedi%d: cb_pcidas: remove\n", dev->minor);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (priv(dev)) {
if (priv(dev)->hw_dev) {
if (priv(dev)->plx9080_iobase) {
@@ -1841,7 +1836,7 @@ static int detach(struct comedi_device * dev)
iounmap((void *)priv(dev)->main_iobase);
if (priv(dev)->dio_counter_iobase)
iounmap((void *)priv(dev)->dio_counter_iobase);
- // free pci dma buffers
+ /* free pci dma buffers */
for (i = 0; i < ai_dma_ring_count(board(dev)); i++) {
if (priv(dev)->ai_buffer[i])
pci_free_consistent(priv(dev)->hw_dev,
@@ -1858,7 +1853,7 @@ static int detach(struct comedi_device * dev)
priv(dev)->
ao_buffer_bus_addr[i]);
}
- // free dma descriptors
+ /* free dma descriptors */
if (priv(dev)->ai_dma_desc)
pci_free_consistent(priv(dev)->hw_dev,
sizeof(struct plx_dma_desc) *
@@ -1883,8 +1878,8 @@ static int detach(struct comedi_device * dev)
return 0;
}
-static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits = 0, n, i;
unsigned int channel, range, aref;
@@ -1896,26 +1891,26 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
range = CR_RANGE(insn->chanspec);
aref = CR_AREF(insn->chanspec);
- // disable card's analog input interrupt sources and pacing
- // 4020 generates dac done interrupts even though they are disabled
+ /* disable card's analog input interrupt sources and pacing */
+ /* 4020 generates dac done interrupts even though they are disabled */
disable_ai_pacing(dev);
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
if (insn->chanspec & CR_ALT_FILTER)
priv(dev)->adc_control1_bits |= ADC_DITHER_BIT;
else
priv(dev)->adc_control1_bits &= ~ADC_DITHER_BIT;
writew(priv(dev)->adc_control1_bits,
priv(dev)->main_iobase + ADC_CONTROL1_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
if (board(dev)->layout != LAYOUT_4020) {
- // use internal queue
+ /* use internal queue */
priv(dev)->hw_config_bits &= ~EXT_QUEUE_BIT;
writew(priv(dev)->hw_config_bits,
priv(dev)->main_iobase + HW_CONFIG_REG);
- // ALT_SOURCE is internal calibration reference
+ /* ALT_SOURCE is internal calibration reference */
if (insn->chanspec & CR_ALT_SOURCE) {
unsigned int cal_en_bit;
@@ -1924,27 +1919,27 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
cal_en_bit = CAL_EN_60XX_BIT;
else
cal_en_bit = CAL_EN_64XX_BIT;
- // select internal reference source to connect to channel 0
+ /* select internal reference source to connect to channel 0 */
writew(cal_en_bit | adc_src_bits(priv(dev)->
calibration_source),
priv(dev)->main_iobase + CALIBRATION_REG);
} else {
- // make sure internal calibration source is turned off
+ /* make sure internal calibration source is turned off */
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
}
- // load internal queue
+ /* load internal queue */
bits = 0;
- // set gain
+ /* set gain */
bits |= ai_range_bits_6xxx(dev, CR_RANGE(insn->chanspec));
- // set single-ended / differential
+ /* set single-ended / differential */
bits |= se_diff_bit_6xxx(dev, aref == AREF_DIFF);
if (aref == AREF_COMMON)
bits |= ADC_COMMON_BIT;
bits |= adc_chan_bits(channel);
- // set stop channel
+ /* set stop channel */
writew(adc_chan_bits(channel),
priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG);
- // set start channel, and rest of settings
+ /* set start channel, and rest of settings */
writew(bits, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG);
} else {
uint8_t old_cal_range_bits = priv(dev)->i2c_cal_range_bits;
@@ -1955,16 +1950,16 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
priv(dev)->i2c_cal_range_bits |=
adc_src_4020_bits(priv(dev)->
calibration_source);
- } else { //select BNC inputs
+ } else { /* select BNC inputs */
priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(4);
}
- // select range
+ /* select range */
if (range == 0)
priv(dev)->i2c_cal_range_bits |= attenuate_bit(channel);
else
priv(dev)->i2c_cal_range_bits &=
~attenuate_bit(channel);
- // update calibration/range i2c register only if necessary, as it is very slow
+ /* update calibration/range i2c register only if necessary, as it is very slow */
if (old_cal_range_bits != priv(dev)->i2c_cal_range_bits) {
uint8_t i2c_data = priv(dev)->i2c_cal_range_bits;
i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data,
@@ -1981,14 +1976,14 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
for (n = 0; n < insn->n; n++) {
- // clear adc buffer (inside loop for 4020 sake)
+ /* clear adc buffer (inside loop for 4020 sake) */
writew(0, priv(dev)->main_iobase + ADC_BUFFER_CLEAR_REG);
/* trigger conversion, bits sent only matter for 4020 */
writew(adc_convert_chan_4020_bits(CR_CHAN(insn->chanspec)),
priv(dev)->main_iobase + ADC_CONVERT_REG);
- // wait for data
+ /* wait for data */
for (i = 0; i < timeout; i++) {
bits = readw(priv(dev)->main_iobase + HW_STATUS_REG);
DEBUG_PRINT(" pipe bits 0x%x\n", pipe_full_bits(bits));
@@ -2000,12 +1995,12 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
if (pipe_full_bits(bits))
break;
}
- comedi_udelay(1);
+ udelay(1);
}
DEBUG_PRINT(" looped %i times waiting for data\n", i);
if (i == timeout) {
comedi_error(dev, " analog input read insn timed out");
- rt_printk(" status 0x%x\n", bits);
+ printk(" status 0x%x\n", bits);
return -ETIME;
}
if (board(dev)->layout == LAYOUT_4020)
@@ -2020,7 +2015,7 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
return n;
}
-static int ai_config_calibration_source(struct comedi_device * dev, unsigned int * data)
+static int ai_config_calibration_source(struct comedi_device *dev, unsigned int *data)
{
unsigned int source = data[1];
int num_calibration_sources;
@@ -2040,7 +2035,7 @@ static int ai_config_calibration_source(struct comedi_device * dev, unsigned int
return 2;
}
-static int ai_config_block_size(struct comedi_device * dev, unsigned int * data)
+static int ai_config_block_size(struct comedi_device *dev, unsigned int *data)
{
int fifo_size;
const struct hw_fifo_info *const fifo = board(dev)->ai_fifo;
@@ -2067,7 +2062,7 @@ static int ai_config_block_size(struct comedi_device * dev, unsigned int * data)
return 2;
}
-static int ai_config_master_clock_4020(struct comedi_device * dev, unsigned int * data)
+static int ai_config_master_clock_4020(struct comedi_device *dev, unsigned int *data)
{
unsigned int divisor = data[4];
int retval = 0;
@@ -2092,8 +2087,8 @@ static int ai_config_master_clock_4020(struct comedi_device * dev, unsigned int
return retval ? retval : 5;
}
-// XXX could add support for 60xx series
-static int ai_config_master_clock(struct comedi_device * dev, unsigned int * data)
+/* XXX could add support for 60xx series */
+static int ai_config_master_clock(struct comedi_device *dev, unsigned int *data)
{
switch (board(dev)->layout) {
@@ -2108,8 +2103,8 @@ static int ai_config_master_clock(struct comedi_device * dev, unsigned int * dat
return -EINVAL;
}
-static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int id = data[0];
@@ -2130,8 +2125,8 @@ static int ai_config_insn(struct comedi_device * dev, struct comedi_subdevice *
return -EINVAL;
}
-static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -2182,7 +2177,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
/* step 2: make sure trigger sources are unique and mutually compatible */
- // uniqueness check
+ /* uniqueness check */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
@@ -2196,7 +2191,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
err++;
- // compatibility check
+ /* compatibility check */
if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT &&
@@ -2220,7 +2215,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
err++;
}
if (cmd->scan_begin_src == TRIG_TIMER) {
- // if scans are timed faster than conversion rate allows
+ /* if scans are timed faster than conversion rate allows */
if (cmd->convert_arg * cmd->chanlist_len >
cmd->scan_begin_arg) {
cmd->scan_begin_arg =
@@ -2278,7 +2273,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
if (err)
return 4;
- // make sure user is doesn't change analog reference mid chanlist
+ /* make sure user is doesn't change analog reference mid chanlist */
if (cmd->chanlist) {
aref = CR_AREF(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
@@ -2289,7 +2284,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
break;
}
}
- // check 4020 chanlist
+ /* check 4020 chanlist */
if (board(dev)->layout == LAYOUT_4020) {
unsigned int first_channel = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
@@ -2315,9 +2310,9 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
return 0;
}
-static int use_hw_sample_counter(struct comedi_cmd * cmd)
+static int use_hw_sample_counter(struct comedi_cmd *cmd)
{
-// disable for now until I work out a race
+/* disable for now until I work out a race */
return 0;
if (cmd->stop_src == TRIG_COUNT && cmd->stop_arg <= max_counter_value)
@@ -2326,13 +2321,13 @@ static int use_hw_sample_counter(struct comedi_cmd * cmd)
return 0;
}
-static void setup_sample_counters(struct comedi_device * dev, struct comedi_cmd * cmd)
+static void setup_sample_counters(struct comedi_device *dev, struct comedi_cmd *cmd)
{
if (cmd->stop_src == TRIG_COUNT) {
- // set software count
+ /* set software count */
priv(dev)->ai_count = cmd->stop_arg * cmd->chanlist_len;
}
- // load hardware conversion counter
+ /* load hardware conversion counter */
if (use_hw_sample_counter(cmd)) {
writew(cmd->stop_arg & 0xffff,
priv(dev)->main_iobase + ADC_COUNT_LOWER_REG);
@@ -2343,7 +2338,7 @@ static void setup_sample_counters(struct comedi_device * dev, struct comedi_cmd
}
}
-static inline unsigned int dma_transfer_size(struct comedi_device * dev)
+static inline unsigned int dma_transfer_size(struct comedi_device *dev)
{
unsigned int num_samples;
@@ -2356,71 +2351,71 @@ static inline unsigned int dma_transfer_size(struct comedi_device * dev)
return num_samples;
}
-static void disable_ai_pacing(struct comedi_device * dev)
+static void disable_ai_pacing(struct comedi_device *dev)
{
unsigned long flags;
disable_ai_interrupts(dev);
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
priv(dev)->adc_control1_bits &= ~ADC_SW_GATE_BIT;
writew(priv(dev)->adc_control1_bits,
priv(dev)->main_iobase + ADC_CONTROL1_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
/* disable pacing, triggering, etc */
writew(ADC_DMA_DISABLE_BIT | ADC_SOFT_GATE_BITS | ADC_GATE_LEVEL_BIT,
priv(dev)->main_iobase + ADC_CONTROL0_REG);
}
-static void disable_ai_interrupts(struct comedi_device * dev)
+static void disable_ai_interrupts(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
priv(dev)->intr_enable_bits &=
~EN_ADC_INTR_SRC_BIT & ~EN_ADC_DONE_INTR_BIT &
~EN_ADC_ACTIVE_INTR_BIT & ~EN_ADC_STOP_INTR_BIT &
~EN_ADC_OVERRUN_BIT & ~ADC_INTR_SRC_MASK;
writew(priv(dev)->intr_enable_bits,
priv(dev)->main_iobase + INTR_ENABLE_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits);
}
-static void enable_ai_interrupts(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
uint32_t bits;
unsigned long flags;
bits = EN_ADC_OVERRUN_BIT | EN_ADC_DONE_INTR_BIT |
EN_ADC_ACTIVE_INTR_BIT | EN_ADC_STOP_INTR_BIT;
- // Use pio transfer and interrupt on end of conversion if TRIG_WAKE_EOS flag is set.
+ /* Use pio transfer and interrupt on end of conversion if TRIG_WAKE_EOS flag is set. */
if (cmd->flags & TRIG_WAKE_EOS) {
- // 4020 doesn't support pio transfers except for fifo dregs
+ /* 4020 doesn't support pio transfers except for fifo dregs */
if (board(dev)->layout != LAYOUT_4020)
bits |= ADC_INTR_EOSCAN_BITS | EN_ADC_INTR_SRC_BIT;
}
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
priv(dev)->intr_enable_bits |= bits;
writew(priv(dev)->intr_enable_bits,
priv(dev)->main_iobase + INTR_ENABLE_REG);
DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
-static uint32_t ai_convert_counter_6xxx(const struct comedi_device * dev,
- const struct comedi_cmd * cmd)
+static uint32_t ai_convert_counter_6xxx(const struct comedi_device *dev,
+ const struct comedi_cmd *cmd)
{
- // supposed to load counter with desired divisor minus 3
+ /* supposed to load counter with desired divisor minus 3 */
return cmd->convert_arg / TIMER_BASE - 3;
}
-static uint32_t ai_scan_counter_6xxx(struct comedi_device * dev, struct comedi_cmd * cmd)
+static uint32_t ai_scan_counter_6xxx(struct comedi_device *dev, struct comedi_cmd *cmd)
{
uint32_t count;
- // figure out how long we need to delay at end of scan
+ /* figure out how long we need to delay at end of scan */
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
count = (cmd->scan_begin_arg -
@@ -2437,7 +2432,7 @@ static uint32_t ai_scan_counter_6xxx(struct comedi_device * dev, struct comedi_c
return count - 3;
}
-static uint32_t ai_convert_counter_4020(struct comedi_device * dev, struct comedi_cmd * cmd)
+static uint32_t ai_convert_counter_4020(struct comedi_device *dev, struct comedi_cmd *cmd)
{
unsigned int divisor;
@@ -2448,20 +2443,20 @@ static uint32_t ai_convert_counter_4020(struct comedi_device * dev, struct comed
case TRIG_OTHER:
divisor = priv(dev)->ext_clock.divisor;
break;
- default: // should never happen
+ default: /* should never happen */
comedi_error(dev, "bug! failed to set ai pacing!");
divisor = 1000;
break;
}
- // supposed to load counter with desired divisor minus 2 for 4020
+ /* supposed to load counter with desired divisor minus 2 for 4020 */
return divisor - 2;
}
-static void select_master_clock_4020(struct comedi_device * dev,
- const struct comedi_cmd * cmd)
+static void select_master_clock_4020(struct comedi_device *dev,
+ const struct comedi_cmd *cmd)
{
- // select internal/external master clock
+ /* select internal/external master clock */
priv(dev)->hw_config_bits &= ~MASTER_CLOCK_4020_MASK;
if (cmd->scan_begin_src == TRIG_OTHER) {
int chanspec = priv(dev)->ext_clock.chanspec;
@@ -2477,7 +2472,7 @@ static void select_master_clock_4020(struct comedi_device * dev,
priv(dev)->main_iobase + HW_CONFIG_REG);
}
-static void select_master_clock(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void select_master_clock(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
switch (board(dev)->layout) {
case LAYOUT_4020:
@@ -2488,12 +2483,12 @@ static void select_master_clock(struct comedi_device * dev, const struct comedi_
}
}
-static inline void dma_start_sync(struct comedi_device * dev, unsigned int channel)
+static inline void dma_start_sync(struct comedi_device *dev, unsigned int channel)
{
unsigned long flags;
- // spinlock for plx dma control/status reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spinlock for plx dma control/status reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
if (channel)
writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT |
PLX_CLEAR_DMA_INTR_BIT,
@@ -2502,10 +2497,10 @@ static inline void dma_start_sync(struct comedi_device * dev, unsigned int chann
writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT |
PLX_CLEAR_DMA_INTR_BIT,
priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
-static void set_ai_pacing(struct comedi_device * dev, struct comedi_cmd * cmd)
+static void set_ai_pacing(struct comedi_device *dev, struct comedi_cmd *cmd)
{
uint32_t convert_counter = 0, scan_counter = 0;
@@ -2520,23 +2515,23 @@ static void set_ai_pacing(struct comedi_device * dev, struct comedi_cmd * cmd)
scan_counter = ai_scan_counter_6xxx(dev, cmd);
}
- // load lower 16 bits of convert interval
+ /* load lower 16 bits of convert interval */
writew(convert_counter & 0xffff,
priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG);
DEBUG_PRINT("convert counter 0x%x\n", convert_counter);
- // load upper 8 bits of convert interval
+ /* load upper 8 bits of convert interval */
writew((convert_counter >> 16) & 0xff,
priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
- // load lower 16 bits of scan delay
+ /* load lower 16 bits of scan delay */
writew(scan_counter & 0xffff,
priv(dev)->main_iobase + ADC_DELAY_INTERVAL_LOWER_REG);
- // load upper 8 bits of scan delay
+ /* load upper 8 bits of scan delay */
writew((scan_counter >> 16) & 0xff,
priv(dev)->main_iobase + ADC_DELAY_INTERVAL_UPPER_REG);
DEBUG_PRINT("scan counter 0x%x\n", scan_counter);
}
-static int use_internal_queue_6xxx(const struct comedi_cmd * cmd)
+static int use_internal_queue_6xxx(const struct comedi_cmd *cmd)
{
int i;
for (i = 0; i + 1 < cmd->chanlist_len; i++) {
@@ -2552,7 +2547,7 @@ static int use_internal_queue_6xxx(const struct comedi_cmd * cmd)
return 1;
}
-static int setup_channel_queue(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
unsigned short bits;
int i;
@@ -2563,25 +2558,25 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c
writew(priv(dev)->hw_config_bits,
priv(dev)->main_iobase + HW_CONFIG_REG);
bits = 0;
- // set channel
+ /* set channel */
bits |= adc_chan_bits(CR_CHAN(cmd->chanlist[0]));
- // set gain
+ /* set gain */
bits |= ai_range_bits_6xxx(dev,
CR_RANGE(cmd->chanlist[0]));
- // set single-ended / differential
+ /* set single-ended / differential */
bits |= se_diff_bit_6xxx(dev,
CR_AREF(cmd->chanlist[0]) == AREF_DIFF);
if (CR_AREF(cmd->chanlist[0]) == AREF_COMMON)
bits |= ADC_COMMON_BIT;
- // set stop channel
+ /* set stop channel */
writew(adc_chan_bits(CR_CHAN(cmd->chanlist[cmd->
chanlist_len - 1])),
priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG);
- // set start channel, and rest of settings
+ /* set start channel, and rest of settings */
writew(bits,
priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG);
} else {
- // use external queue
+ /* use external queue */
if (dev->write_subdev && dev->write_subdev->busy) {
warn_external_queue(dev);
return -EBUSY;
@@ -2589,26 +2584,26 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c
priv(dev)->hw_config_bits |= EXT_QUEUE_BIT;
writew(priv(dev)->hw_config_bits,
priv(dev)->main_iobase + HW_CONFIG_REG);
- // clear DAC buffer to prevent weird interactions
+ /* clear DAC buffer to prevent weird interactions */
writew(0,
priv(dev)->main_iobase + DAC_BUFFER_CLEAR_REG);
- // clear queue pointer
+ /* clear queue pointer */
writew(0, priv(dev)->main_iobase + ADC_QUEUE_CLEAR_REG);
- // load external queue
+ /* load external queue */
for (i = 0; i < cmd->chanlist_len; i++) {
bits = 0;
- // set channel
+ /* set channel */
bits |= adc_chan_bits(CR_CHAN(cmd->
chanlist[i]));
- // set gain
+ /* set gain */
bits |= ai_range_bits_6xxx(dev,
CR_RANGE(cmd->chanlist[i]));
- // set single-ended / differential
+ /* set single-ended / differential */
bits |= se_diff_bit_6xxx(dev,
CR_AREF(cmd->chanlist[i]) == AREF_DIFF);
if (CR_AREF(cmd->chanlist[i]) == AREF_COMMON)
bits |= ADC_COMMON_BIT;
- // mark end of queue
+ /* mark end of queue */
if (i == cmd->chanlist_len - 1)
bits |= QUEUE_EOSCAN_BIT |
QUEUE_EOSEQ_BIT;
@@ -2622,7 +2617,7 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c
/* doing a queue clear is not specified in board docs,
* but required for reliable operation */
writew(0, priv(dev)->main_iobase + ADC_QUEUE_CLEAR_REG);
- // prime queue holding register
+ /* prime queue holding register */
writew(0, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG);
}
} else {
@@ -2630,9 +2625,9 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c
priv(dev)->i2c_cal_range_bits;
priv(dev)->i2c_cal_range_bits &= ~ADC_SRC_4020_MASK;
- //select BNC inputs
+ /* select BNC inputs */
priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(4);
- // select ranges
+ /* select ranges */
for (i = 0; i < cmd->chanlist_len; i++) {
unsigned int channel = CR_CHAN(cmd->chanlist[i]);
unsigned int range = CR_RANGE(cmd->chanlist[i]);
@@ -2644,7 +2639,7 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c
priv(dev)->i2c_cal_range_bits &=
~attenuate_bit(channel);
}
- // update calibration/range i2c register only if necessary, as it is very slow
+ /* update calibration/range i2c register only if necessary, as it is very slow */
if (old_cal_range_bits != priv(dev)->i2c_cal_range_bits) {
uint8_t i2c_data = priv(dev)->i2c_cal_range_bits;
i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data,
@@ -2654,7 +2649,7 @@ static int setup_channel_queue(struct comedi_device * dev, const struct comedi_c
return 0;
}
-static inline void load_first_dma_descriptor(struct comedi_device * dev,
+static inline void load_first_dma_descriptor(struct comedi_device *dev,
unsigned int dma_channel, unsigned int descriptor_bits)
{
/* The transfer size, pci address, and local address registers
@@ -2681,7 +2676,7 @@ static inline void load_first_dma_descriptor(struct comedi_device * dev,
}
}
-static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -2697,7 +2692,7 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
if (retval < 0)
return retval;
- // make sure internal calibration source is turned off
+ /* make sure internal calibration source is turned off */
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
set_ai_pacing(dev, cmd);
@@ -2706,16 +2701,16 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
enable_ai_interrupts(dev, cmd);
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
/* set mode, allow conversions through software gate */
priv(dev)->adc_control1_bits |= ADC_SW_GATE_BIT;
priv(dev)->adc_control1_bits &= ~ADC_DITHER_BIT;
if (board(dev)->layout != LAYOUT_4020) {
priv(dev)->adc_control1_bits &= ~ADC_MODE_MASK;
if (cmd->convert_src == TRIG_EXT)
- priv(dev)->adc_control1_bits |= adc_mode_bits(13); // good old mode 13
+ priv(dev)->adc_control1_bits |= adc_mode_bits(13); /* good old mode 13 */
else
- priv(dev)->adc_control1_bits |= adc_mode_bits(8); // mode 8. What else could you need?
+ priv(dev)->adc_control1_bits |= adc_mode_bits(8); /* mode 8. What else could you need? */
} else {
priv(dev)->adc_control1_bits &= ~CHANNEL_MODE_4020_MASK;
if (cmd->chanlist_len == 4)
@@ -2733,22 +2728,22 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
writew(priv(dev)->adc_control1_bits,
priv(dev)->main_iobase + ADC_CONTROL1_REG);
DEBUG_PRINT("control1 bits 0x%x\n", priv(dev)->adc_control1_bits);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // clear adc buffer
+ /* clear adc buffer */
writew(0, priv(dev)->main_iobase + ADC_BUFFER_CLEAR_REG);
if ((cmd->flags & TRIG_WAKE_EOS) == 0 ||
board(dev)->layout == LAYOUT_4020) {
priv(dev)->ai_dma_index = 0;
- // set dma transfer size
+ /* set dma transfer size */
for (i = 0; i < ai_dma_ring_count(board(dev)); i++)
priv(dev)->ai_dma_desc[i].transfer_size =
cpu_to_le32(dma_transfer_size(dev) *
sizeof(uint16_t));
- // give location of first dma descriptor
+ /* give location of first dma descriptor */
load_first_dma_descriptor(dev, 1,
priv(dev)->
ai_dma_desc_bus_addr | PLX_DESC_IN_PCI_BIT |
@@ -2767,13 +2762,13 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
writew(bits, priv(dev)->main_iobase + DAQ_ATRIG_LOW_4020_REG);
}
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
/* enable pacing, triggering, etc */
bits = ADC_ENABLE_BIT | ADC_SOFT_GATE_BITS | ADC_GATE_LEVEL_BIT;
if (cmd->flags & TRIG_WAKE_EOS)
bits |= ADC_DMA_DISABLE_BIT;
- // set start trigger
+ /* set start trigger */
if (cmd->start_src == TRIG_EXT) {
bits |= ADC_START_TRIG_EXT_BITS;
if (cmd->start_arg & CR_INVERT)
@@ -2787,9 +2782,9 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
priv(dev)->ai_cmd_running = 1;
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // start aquisition
+ /* start aquisition */
if (cmd->start_src == TRIG_NOW) {
writew(0, priv(dev)->main_iobase + ADC_START_REG);
DEBUG_PRINT("soft trig\n");
@@ -2798,8 +2793,8 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-// read num_samples from 16 bit wide ai fifo
-static void pio_drain_ai_fifo_16(struct comedi_device * dev)
+/* read num_samples from 16 bit wide ai fifo */
+static void pio_drain_ai_fifo_16(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
@@ -2810,7 +2805,7 @@ static void pio_drain_ai_fifo_16(struct comedi_device * dev)
int num_samples;
do {
- // get least significant 15 bits
+ /* get least significant 15 bits */
read_index =
readw(priv(dev)->main_iobase +
ADC_READ_PNTR_REG) & 0x7fff;
@@ -2847,7 +2842,7 @@ static void pio_drain_ai_fifo_16(struct comedi_device * dev)
}
if (num_samples < 0) {
- rt_printk(" cb_pcidas64: bug! num_samples < 0\n");
+ printk(" cb_pcidas64: bug! num_samples < 0\n");
break;
}
@@ -2866,7 +2861,7 @@ static void pio_drain_ai_fifo_16(struct comedi_device * dev)
* dma transfers (it only supports the use of pio for draining the last remaining
* points from the fifo when a data aquisition operation has completed).
*/
-static void pio_drain_ai_fifo_32(struct comedi_device * dev)
+static void pio_drain_ai_fifo_32(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
@@ -2899,8 +2894,8 @@ static void pio_drain_ai_fifo_32(struct comedi_device * dev)
priv(dev)->ai_count -= i;
}
-// empty fifo
-static void pio_drain_ai_fifo(struct comedi_device * dev)
+/* empty fifo */
+static void pio_drain_ai_fifo(struct comedi_device *dev)
{
if (board(dev)->layout == LAYOUT_4020) {
pio_drain_ai_fifo_32(dev);
@@ -2908,7 +2903,7 @@ static void pio_drain_ai_fifo(struct comedi_device * dev)
pio_drain_ai_fifo_16(dev);
}
-static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
+static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
{
struct comedi_async *async = dev->read_subdev->async;
uint32_t next_transfer_addr;
@@ -2923,7 +2918,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
pci_addr_reg =
priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
- // loop until we have read all the full buffers
+ /* loop until we have read all the full buffers */
for (j = 0, next_transfer_addr = readl(pci_addr_reg);
(next_transfer_addr <
priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index]
@@ -2931,7 +2926,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] +
DMA_BUFFER_SIZE) && j < ai_dma_ring_count(board(dev));
j++) {
- // transfer data from dma buffer to comedi buffer
+ /* transfer data from dma buffer to comedi buffer */
num_samples = dma_transfer_size(dev);
if (async->cmd.stop_src == TRIG_COUNT) {
if (num_samples > priv(dev)->ai_count)
@@ -2954,7 +2949,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
* unused buffer) */
}
-void handle_ai_interrupt(struct comedi_device * dev, unsigned short status,
+void handle_ai_interrupt(struct comedi_device *dev, unsigned short status,
unsigned int plx_status)
{
struct comedi_subdevice *s = dev->read_subdev;
@@ -2963,15 +2958,15 @@ void handle_ai_interrupt(struct comedi_device * dev, unsigned short status,
uint8_t dma1_status;
unsigned long flags;
- // check for fifo overrun
+ /* check for fifo overrun */
if (status & ADC_OVERRUN_BIT) {
comedi_error(dev, "fifo overrun");
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
- // spin lock makes sure noone else changes plx dma control reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spin lock makes sure noone else changes plx dma control reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
- if (plx_status & ICS_DMA1_A) { // dma chan 1 interrupt
+ if (plx_status & ICS_DMA1_A) { /* dma chan 1 interrupt */
writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
DEBUG_PRINT("dma1 status 0x%x\n", dma1_status);
@@ -2981,25 +2976,25 @@ void handle_ai_interrupt(struct comedi_device * dev, unsigned short status,
}
DEBUG_PRINT(" cleared dma ch1 interrupt\n");
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
if (status & ADC_DONE_BIT)
DEBUG_PRINT("adc done interrupt\n");
- // drain fifo with pio
+ /* drain fifo with pio */
if ((status & ADC_DONE_BIT) ||
((cmd->flags & TRIG_WAKE_EOS) &&
(status & ADC_INTR_PENDING_BIT) &&
(board(dev)->layout != LAYOUT_4020))) {
DEBUG_PRINT("pio fifo drain\n");
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
if (priv(dev)->ai_cmd_running) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
pio_drain_ai_fifo(dev);
} else
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
- // if we are have all the data, then quit
+ /* if we are have all the data, then quit */
if ((cmd->stop_src == TRIG_COUNT && priv(dev)->ai_count <= 0) ||
(cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) {
async->events |= COMEDI_CB_EOA;
@@ -3008,7 +3003,7 @@ void handle_ai_interrupt(struct comedi_device * dev, unsigned short status,
cfc_handle_events(dev, s);
}
-static inline unsigned int prev_ao_dma_index(struct comedi_device * dev)
+static inline unsigned int prev_ao_dma_index(struct comedi_device *dev)
{
unsigned int buffer_index;
@@ -3019,7 +3014,7 @@ static inline unsigned int prev_ao_dma_index(struct comedi_device * dev)
return buffer_index;
}
-static int last_ao_dma_load_completed(struct comedi_device * dev)
+static int last_ao_dma_load_completed(struct comedi_device *dev)
{
unsigned int buffer_index;
unsigned int transfer_address;
@@ -3038,7 +3033,7 @@ static int last_ao_dma_load_completed(struct comedi_device * dev)
return 1;
}
-static int ao_stopped_by_error(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static int ao_stopped_by_error(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
if (cmd->stop_src == TRIG_NONE)
return 1;
@@ -3051,7 +3046,7 @@ static int ao_stopped_by_error(struct comedi_device * dev, const struct comedi_c
return 0;
}
-static inline int ao_dma_needs_restart(struct comedi_device * dev,
+static inline int ao_dma_needs_restart(struct comedi_device *dev,
unsigned short dma_status)
{
if ((dma_status & PLX_DMA_DONE_BIT) == 0 ||
@@ -3063,7 +3058,7 @@ static inline int ao_dma_needs_restart(struct comedi_device * dev,
return 1;
}
-static void restart_ao_dma(struct comedi_device * dev)
+static void restart_ao_dma(struct comedi_device *dev)
{
unsigned int dma_desc_bits;
@@ -3076,7 +3071,7 @@ static void restart_ao_dma(struct comedi_device * dev)
dma_start_sync(dev, 0);
}
-static void handle_ao_interrupt(struct comedi_device * dev, unsigned short status,
+static void handle_ao_interrupt(struct comedi_device *dev, unsigned short status,
unsigned int plx_status)
{
struct comedi_subdevice *s = dev->write_subdev;
@@ -3091,10 +3086,10 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu
async = s->async;
cmd = &async->cmd;
- // spin lock makes sure noone else changes plx dma control reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spin lock makes sure noone else changes plx dma control reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
- if (plx_status & ICS_DMA0_A) { // dma chan 0 interrupt
+ if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */
if ((dma0_status & PLX_DMA_EN_BIT)
&& !(dma0_status & PLX_DMA_DONE_BIT))
writeb(PLX_DMA_EN_BIT | PLX_CLEAR_DMA_INTR_BIT,
@@ -3102,7 +3097,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu
else
writeb(PLX_CLEAR_DMA_INTR_BIT,
priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
DEBUG_PRINT("dma0 status 0x%x\n", dma0_status);
if (dma0_status & PLX_DMA_EN_BIT) {
load_ao_dma(dev, cmd);
@@ -3112,7 +3107,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu
}
DEBUG_PRINT(" cleared dma ch0 interrupt\n");
} else
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
if ((status & DAC_DONE_BIT)) {
async->events |= COMEDI_CB_EOA;
@@ -3128,7 +3123,7 @@ static void handle_ao_interrupt(struct comedi_device * dev, unsigned short statu
cfc_handle_events(dev, s);
}
-static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t handle_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
unsigned short status;
@@ -3152,8 +3147,8 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
handle_ai_interrupt(dev, status, plx_status);
handle_ao_interrupt(dev, status, plx_status);
- // clear possible plx9080 interrupt sources
- if (plx_status & ICS_LDIA) { // clear local doorbell interrupt
+ /* clear possible plx9080 interrupt sources */
+ if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */
plx_bits = readl(priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG);
writel(plx_bits, priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG);
DEBUG_PRINT(" cleared local doorbell bits 0x%x\n", plx_bits);
@@ -3164,29 +3159,29 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-void abort_dma(struct comedi_device * dev, unsigned int channel)
+void abort_dma(struct comedi_device *dev, unsigned int channel)
{
unsigned long flags;
- // spinlock for plx dma control/status reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spinlock for plx dma control/status reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
plx9080_abort_dma(priv(dev)->plx9080_iobase, channel);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
-static int ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
if (priv(dev)->ai_cmd_running == 0) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
priv(dev)->ai_cmd_running = 0;
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
disable_ai_pacing(dev);
@@ -3196,21 +3191,21 @@ static int ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int range = CR_RANGE(insn->chanspec);
- // do some initializing
+ /* do some initializing */
writew(0, priv(dev)->main_iobase + DAC_CONTROL0_REG);
- // set range
+ /* set range */
set_dac_range_bits(dev, &priv(dev)->dac_control1_bits, chan, range);
writew(priv(dev)->dac_control1_bits,
priv(dev)->main_iobase + DAC_CONTROL1_REG);
- // write to channel
+ /* write to channel */
if (board(dev)->layout == LAYOUT_4020) {
writew(data[0] & 0xff,
priv(dev)->main_iobase + dac_lsb_4020_reg(chan));
@@ -3220,21 +3215,21 @@ static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
writew(data[0], priv(dev)->main_iobase + dac_convert_reg(chan));
}
- // remember output value
+ /* remember output value */
priv(dev)->ao_value[chan] = data[0];
return 1;
}
-static int ao_readback_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = priv(dev)->ao_value[CR_CHAN(insn->chanspec)];
return 1;
}
-static void set_dac_control0_reg(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void set_dac_control0_reg(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
unsigned int bits = DAC_ENABLE_BIT | WAVEFORM_GATE_LEVEL_BIT |
WAVEFORM_GATE_ENABLE_BIT | WAVEFORM_GATE_SELECT_BIT;
@@ -3254,7 +3249,7 @@ static void set_dac_control0_reg(struct comedi_device * dev, const struct comedi
writew(bits, priv(dev)->main_iobase + DAC_CONTROL0_REG);
}
-static void set_dac_control1_reg(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void set_dac_control1_reg(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
int i;
@@ -3271,7 +3266,7 @@ static void set_dac_control1_reg(struct comedi_device * dev, const struct comedi
priv(dev)->main_iobase + DAC_CONTROL1_REG);
}
-static void set_dac_select_reg(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void set_dac_select_reg(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
uint16_t bits;
unsigned int first_channel, last_channel;
@@ -3286,7 +3281,7 @@ static void set_dac_select_reg(struct comedi_device * dev, const struct comedi_c
writew(bits, priv(dev)->main_iobase + DAC_SELECT_REG);
}
-static void set_dac_interval_regs(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void set_dac_interval_regs(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
unsigned int divisor;
@@ -3304,8 +3299,8 @@ static void set_dac_interval_regs(struct comedi_device * dev, const struct comed
priv(dev)->main_iobase + DAC_SAMPLE_INTERVAL_UPPER_REG);
}
-static unsigned int load_ao_dma_buffer(struct comedi_device * dev,
- const struct comedi_cmd * cmd)
+static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
+ const struct comedi_cmd *cmd)
{
unsigned int num_bytes, buffer_index, prev_buffer_index;
unsigned int next_bits;
@@ -3348,7 +3343,7 @@ static unsigned int load_ao_dma_buffer(struct comedi_device * dev,
return num_bytes;
}
-static void load_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
unsigned int num_bytes;
unsigned int next_transfer_addr;
@@ -3370,7 +3365,7 @@ static void load_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cm
} while (num_bytes >= DMA_BUFFER_SIZE);
}
-static int prep_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd)
+static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
unsigned int num_bytes;
int i;
@@ -3404,7 +3399,7 @@ static int prep_ao_dma(struct comedi_device * dev, const struct comedi_cmd * cmd
return 0;
}
-static inline int external_ai_queue_in_use(struct comedi_device * dev)
+static inline int external_ai_queue_in_use(struct comedi_device *dev)
{
if (dev->read_subdev->busy)
return 0;
@@ -3415,7 +3410,7 @@ static inline int external_ai_queue_in_use(struct comedi_device * dev)
return 1;
}
-static int ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
@@ -3440,7 +3435,7 @@ static int ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trig_num)
{
struct comedi_cmd *cmd = &s->async->cmd;
@@ -3463,8 +3458,8 @@ static int ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
return 0;
}
-static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -3503,14 +3498,14 @@ static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
/* step 2: make sure trigger sources are unique and mutually compatible */
- // uniqueness check
+ /* uniqueness check */
if (cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
cmd->scan_begin_src != TRIG_EXT)
err++;
- // compatibility check
+ /* compatibility check */
if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT &&
@@ -3579,7 +3574,7 @@ static int ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
return 0;
}
-static int ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
writew(0x0, priv(dev)->main_iobase + DAC_CONTROL0_REG);
abort_dma(dev, 0);
@@ -3607,8 +3602,8 @@ static int dio_callback_4020(int dir, int port, int data, unsigned long iobase)
}
}
-static int di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -3620,13 +3615,13 @@ static int di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
return 2;
}
-static int do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] &= 0xf;
- // zero bits we are going to change
+ /* zero bits we are going to change */
s->state &= ~data[0];
- // set new bits
+ /* set new bits */
s->state |= data[0] & data[1];
writeb(s->state, priv(dev)->dio_counter_iobase + DO_REG);
@@ -3636,8 +3631,8 @@ static int do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
return 2;
}
-static int dio_60xx_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask;
@@ -3663,8 +3658,8 @@ static int dio_60xx_config_insn(struct comedi_device * dev, struct comedi_subdev
return 1;
}
-static int dio_60xx_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -3678,7 +3673,7 @@ static int dio_60xx_wbits(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static void caldac_write(struct comedi_device * dev, unsigned int channel,
+static void caldac_write(struct comedi_device *dev, unsigned int channel,
unsigned int value)
{
priv(dev)->caldac_state[channel] = value;
@@ -3696,8 +3691,8 @@ static void caldac_write(struct comedi_device * dev, unsigned int channel,
}
}
-static int calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel = CR_CHAN(insn->chanspec);
@@ -3711,8 +3706,8 @@ static int calib_write_insn(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int channel = CR_CHAN(insn->chanspec);
@@ -3721,18 +3716,18 @@ static int calib_read_insn(struct comedi_device * dev, struct comedi_subdevice *
return 1;
}
-static void ad8402_write(struct comedi_device * dev, unsigned int channel,
+static void ad8402_write(struct comedi_device *dev, unsigned int channel,
unsigned int value)
{
static const int bitstream_length = 10;
unsigned int bit, register_bits;
unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
- static const int ad8402_comedi_udelay = 1;
+ static const int ad8402_udelay = 1;
priv(dev)->ad8402_state[channel] = value;
register_bits = SELECT_8402_64XX_BIT;
- comedi_udelay(ad8402_comedi_udelay);
+ udelay(ad8402_udelay);
writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG);
for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) {
@@ -3740,20 +3735,20 @@ static void ad8402_write(struct comedi_device * dev, unsigned int channel,
register_bits |= SERIAL_DATA_IN_BIT;
else
register_bits &= ~SERIAL_DATA_IN_BIT;
- comedi_udelay(ad8402_comedi_udelay);
+ udelay(ad8402_udelay);
writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG);
- comedi_udelay(ad8402_comedi_udelay);
+ udelay(ad8402_udelay);
writew(register_bits | SERIAL_CLOCK_BIT,
priv(dev)->main_iobase + CALIBRATION_REG);
}
- comedi_udelay(ad8402_comedi_udelay);
+ udelay(ad8402_udelay);
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
}
/* for pci-das6402/16, channel 0 is analog input gain and channel 1 is offset */
-static int ad8402_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ad8402_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel = CR_CHAN(insn->chanspec);
@@ -3769,8 +3764,8 @@ static int ad8402_write_insn(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int ad8402_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ad8402_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int channel = CR_CHAN(insn->chanspec);
@@ -3779,7 +3774,7 @@ static int ad8402_read_insn(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static uint16_t read_eeprom(struct comedi_device * dev, uint8_t address)
+static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address)
{
static const int bitstream_length = 11;
static const int read_command = 0x6;
@@ -3789,60 +3784,60 @@ static uint16_t read_eeprom(struct comedi_device * dev, uint8_t address)
priv(dev)->plx9080_iobase + PLX_CONTROL_REG;
uint16_t value;
static const int value_length = 16;
- static const int eeprom_comedi_udelay = 1;
+ static const int eeprom_udelay = 1;
- comedi_udelay(eeprom_comedi_udelay);
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits &= ~CTL_EE_CLK & ~CTL_EE_CS;
- // make sure we don't send anything to the i2c bus on 4020
+ /* make sure we don't send anything to the i2c bus on 4020 */
priv(dev)->plx_control_bits |= CTL_USERO;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- // activate serial eeprom
- comedi_udelay(eeprom_comedi_udelay);
+ /* activate serial eeprom */
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits |= CTL_EE_CS;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- // write read command and desired memory address
+ /* write read command and desired memory address */
for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) {
- // set bit to be written
- comedi_udelay(eeprom_comedi_udelay);
+ /* set bit to be written */
+ udelay(eeprom_udelay);
if (bitstream & bit)
priv(dev)->plx_control_bits |= CTL_EE_W;
else
priv(dev)->plx_control_bits &= ~CTL_EE_W;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- // clock in bit
- comedi_udelay(eeprom_comedi_udelay);
+ /* clock in bit */
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits |= CTL_EE_CLK;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(eeprom_comedi_udelay);
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits &= ~CTL_EE_CLK;
writel(priv(dev)->plx_control_bits, plx_control_addr);
}
- // read back value from eeprom memory location
+ /* read back value from eeprom memory location */
value = 0;
for (bit = 1 << (value_length - 1); bit; bit >>= 1) {
- // clock out bit
- comedi_udelay(eeprom_comedi_udelay);
+ /* clock out bit */
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits |= CTL_EE_CLK;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(eeprom_comedi_udelay);
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits &= ~CTL_EE_CLK;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(eeprom_comedi_udelay);
+ udelay(eeprom_udelay);
if (readl(plx_control_addr) & CTL_EE_R)
value |= bit;
}
- // deactivate eeprom serial input
- comedi_udelay(eeprom_comedi_udelay);
+ /* deactivate eeprom serial input */
+ udelay(eeprom_udelay);
priv(dev)->plx_control_bits &= ~CTL_EE_CS;
writel(priv(dev)->plx_control_bits, plx_control_addr);
return value;
}
-static int eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = read_eeprom(dev, CR_CHAN(insn->chanspec));
@@ -3880,7 +3875,7 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
if (cmd->scan_begin_src == TRIG_TIMER) {
scan_divisor = get_divisor(cmd->scan_begin_arg, cmd->flags);
if (cmd->convert_src == TRIG_TIMER) {
- // XXX check for integer overflows
+ /* XXX check for integer overflows */
min_scan_divisor = convert_divisor * cmd->chanlist_len;
max_scan_divisor =
(convert_divisor * cmd->chanlist_len - 1) +
@@ -3926,8 +3921,8 @@ static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags)
return get_divisor(ns, flags) - 2;
}
-// adjusts the size of hardware fifo (which determines block size for dma xfers)
-static int set_ai_fifo_size(struct comedi_device * dev, unsigned int num_samples)
+/* adjusts the size of hardware fifo (which determines block size for dma xfers) */
+static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples)
{
unsigned int num_fifo_entries;
int retval;
@@ -3947,15 +3942,15 @@ static int set_ai_fifo_size(struct comedi_device * dev, unsigned int num_samples
return num_samples;
}
-// query length of fifo
-static unsigned int ai_fifo_size(struct comedi_device * dev)
+/* query length of fifo */
+static unsigned int ai_fifo_size(struct comedi_device *dev)
{
return priv(dev)->ai_fifo_segment_length *
board(dev)->ai_fifo->num_segments *
board(dev)->ai_fifo->sample_packing_ratio;
}
-static int set_ai_fifo_segment_length(struct comedi_device * dev,
+static int set_ai_fifo_segment_length(struct comedi_device *dev,
unsigned int num_entries)
{
static const int increment_size = 0x100;
@@ -3968,7 +3963,7 @@ static int set_ai_fifo_segment_length(struct comedi_device * dev,
if (num_entries > fifo->max_segment_length)
num_entries = fifo->max_segment_length;
- // 1 == 256 entries, 2 == 512 entries, etc
+ /* 1 == 256 entries, 2 == 512 entries, etc */
num_increments = (num_entries + increment_size / 2) / increment_size;
bits = (~(num_increments - 1)) & fifo->fifo_size_reg_mask;
@@ -4006,7 +4001,7 @@ static int set_ai_fifo_segment_length(struct comedi_device * dev,
* address 7 == dac channel 1 fine offset
*/
-static int caldac_8800_write(struct comedi_device * dev, unsigned int address,
+static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value)
{
static const int num_caldac_channels = 8;
@@ -4023,28 +4018,28 @@ static int caldac_8800_write(struct comedi_device * dev, unsigned int address,
register_bits = 0;
if (bitstream & bit)
register_bits |= SERIAL_DATA_IN_BIT;
- comedi_udelay(caldac_8800_udelay);
+ udelay(caldac_8800_udelay);
writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG);
register_bits |= SERIAL_CLOCK_BIT;
- comedi_udelay(caldac_8800_udelay);
+ udelay(caldac_8800_udelay);
writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG);
}
- comedi_udelay(caldac_8800_udelay);
+ udelay(caldac_8800_udelay);
writew(SELECT_8800_BIT, priv(dev)->main_iobase + CALIBRATION_REG);
- comedi_udelay(caldac_8800_udelay);
+ udelay(caldac_8800_udelay);
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
- comedi_udelay(caldac_8800_udelay);
+ udelay(caldac_8800_udelay);
return 0;
}
-// 4020 caldacs
-static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_channel,
+/* 4020 caldacs */
+static int caldac_i2c_write(struct comedi_device *dev, unsigned int caldac_channel,
unsigned int value)
{
uint8_t serial_bytes[3];
uint8_t i2c_addr;
enum pointer_bits {
- // manual has gain and offset bits switched
+ /* manual has gain and offset bits switched */
OFFSET_0_2 = 0x1,
GAIN_0_2 = 0x2,
OFFSET_1_3 = 0x4,
@@ -4055,35 +4050,35 @@ static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_chan
};
switch (caldac_channel) {
- case 0: // chan 0 offset
+ case 0: /* chan 0 offset */
i2c_addr = CALDAC0_I2C_ADDR;
serial_bytes[0] = OFFSET_0_2;
break;
- case 1: // chan 1 offset
+ case 1: /* chan 1 offset */
i2c_addr = CALDAC0_I2C_ADDR;
serial_bytes[0] = OFFSET_1_3;
break;
- case 2: // chan 2 offset
+ case 2: /* chan 2 offset */
i2c_addr = CALDAC1_I2C_ADDR;
serial_bytes[0] = OFFSET_0_2;
break;
- case 3: // chan 3 offset
+ case 3: /* chan 3 offset */
i2c_addr = CALDAC1_I2C_ADDR;
serial_bytes[0] = OFFSET_1_3;
break;
- case 4: // chan 0 gain
+ case 4: /* chan 0 gain */
i2c_addr = CALDAC0_I2C_ADDR;
serial_bytes[0] = GAIN_0_2;
break;
- case 5: // chan 1 gain
+ case 5: /* chan 1 gain */
i2c_addr = CALDAC0_I2C_ADDR;
serial_bytes[0] = GAIN_1_3;
break;
- case 6: // chan 2 gain
+ case 6: /* chan 2 gain */
i2c_addr = CALDAC1_I2C_ADDR;
serial_bytes[0] = GAIN_0_2;
break;
- case 7: // chan 3 gain
+ case 7: /* chan 3 gain */
i2c_addr = CALDAC1_I2C_ADDR;
serial_bytes[0] = GAIN_1_3;
break;
@@ -4098,49 +4093,49 @@ static int caldac_i2c_write(struct comedi_device * dev, unsigned int caldac_chan
return 0;
}
-// Their i2c requires a huge delay on setting clock or data high for some reason
-static const int i2c_high_comedi_udelay = 1000;
-static const int i2c_low_comedi_udelay = 10;
+/* Their i2c requires a huge delay on setting clock or data high for some reason */
+static const int i2c_high_udelay = 1000;
+static const int i2c_low_udelay = 10;
-// set i2c data line high or low
-static void i2c_set_sda(struct comedi_device * dev, int state)
+/* set i2c data line high or low */
+static void i2c_set_sda(struct comedi_device *dev, int state)
{
static const int data_bit = CTL_EE_W;
void *plx_control_addr = priv(dev)->plx9080_iobase + PLX_CONTROL_REG;
if (state) {
- // set data line high
+ /* set data line high */
priv(dev)->plx_control_bits &= ~data_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(i2c_high_comedi_udelay);
- } else // set data line low
+ udelay(i2c_high_udelay);
+ } else /* set data line low */
{
priv(dev)->plx_control_bits |= data_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(i2c_low_comedi_udelay);
+ udelay(i2c_low_udelay);
}
}
-// set i2c clock line high or low
-static void i2c_set_scl(struct comedi_device * dev, int state)
+/* set i2c clock line high or low */
+static void i2c_set_scl(struct comedi_device *dev, int state)
{
static const int clock_bit = CTL_USERO;
void *plx_control_addr = priv(dev)->plx9080_iobase + PLX_CONTROL_REG;
if (state) {
- // set clock line high
+ /* set clock line high */
priv(dev)->plx_control_bits &= ~clock_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(i2c_high_comedi_udelay);
- } else // set clock line low
+ udelay(i2c_high_udelay);
+ } else /* set clock line low */
{
priv(dev)->plx_control_bits |= clock_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
- comedi_udelay(i2c_low_comedi_udelay);
+ udelay(i2c_low_udelay);
}
}
-static void i2c_write_byte(struct comedi_device * dev, uint8_t byte)
+static void i2c_write_byte(struct comedi_device *dev, uint8_t byte)
{
uint8_t bit;
unsigned int num_bits = 8;
@@ -4157,26 +4152,26 @@ static void i2c_write_byte(struct comedi_device * dev, uint8_t byte)
}
}
-// we can't really read the lines, so fake it
-static int i2c_read_ack(struct comedi_device * dev)
+/* we can't really read the lines, so fake it */
+static int i2c_read_ack(struct comedi_device *dev)
{
i2c_set_scl(dev, 0);
i2c_set_sda(dev, 1);
i2c_set_scl(dev, 1);
- return 0; // return fake acknowledge bit
+ return 0; /* return fake acknowledge bit */
}
-// send start bit
-static void i2c_start(struct comedi_device * dev)
+/* send start bit */
+static void i2c_start(struct comedi_device *dev)
{
i2c_set_scl(dev, 1);
i2c_set_sda(dev, 1);
i2c_set_sda(dev, 0);
}
-// send stop bit
-static void i2c_stop(struct comedi_device * dev)
+/* send stop bit */
+static void i2c_stop(struct comedi_device *dev)
{
i2c_set_scl(dev, 0);
i2c_set_sda(dev, 0);
@@ -4184,32 +4179,32 @@ static void i2c_stop(struct comedi_device * dev)
i2c_set_sda(dev, 1);
}
-static void i2c_write(struct comedi_device * dev, unsigned int address,
- const uint8_t * data, unsigned int length)
+static void i2c_write(struct comedi_device *dev, unsigned int address,
+ const uint8_t *data, unsigned int length)
{
unsigned int i;
uint8_t bitstream;
static const int read_bit = 0x1;
-//XXX need mutex to prevent simultaneous attempts to access eeprom and i2c bus
+/* XXX need mutex to prevent simultaneous attempts to access eeprom and i2c bus */
- // make sure we dont send anything to eeprom
+ /* make sure we dont send anything to eeprom */
priv(dev)->plx_control_bits &= ~CTL_EE_CS;
i2c_stop(dev);
i2c_start(dev);
- // send address and write bit
+ /* send address and write bit */
bitstream = (address << 1) & ~read_bit;
i2c_write_byte(dev, bitstream);
- // get acknowledge
+ /* get acknowledge */
if (i2c_read_ack(dev) != 0) {
comedi_error(dev, "i2c write failed: no acknowledge");
i2c_stop(dev);
return;
}
- // write data bytes
+ /* write data bytes */
for (i = 0; i < length; i++) {
i2c_write_byte(dev, data[i]);
if (i2c_read_ack(dev) != 0) {
diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c
index ed0a5eb3dd91..8f3629416188 100644
--- a/drivers/staging/comedi/drivers/cb_pcidda.c
+++ b/drivers/staging/comedi/drivers/cb_pcidda.c
@@ -51,66 +51,66 @@ Please report success/failure with other different cards to
#include "comedi_pci.h"
#include "8255.h"
-#define PCI_VENDOR_ID_CB 0x1307 // PCI vendor number of ComputerBoards
-#define N_BOARDS 10 // Number of boards in cb_pcidda_boards
-#define EEPROM_SIZE 128 // number of entries in eeprom
-#define MAX_AO_CHANNELS 8 // maximum number of ao channels for supported boards
+#define PCI_VENDOR_ID_CB 0x1307 /* PCI vendor number of ComputerBoards */
+#define N_BOARDS 10 /* Number of boards in cb_pcidda_boards */
+#define EEPROM_SIZE 128 /* number of entries in eeprom */
+#define MAX_AO_CHANNELS 8 /* maximum number of ao channels for supported boards */
/* PCI-DDA base addresses */
#define DIGITALIO_BADRINDEX 2
- // DIGITAL I/O is pci_dev->resource[2]
+ /* DIGITAL I/O is pci_dev->resource[2] */
#define DIGITALIO_SIZE 8
- // DIGITAL I/O uses 8 I/O port addresses
+ /* DIGITAL I/O uses 8 I/O port addresses */
#define DAC_BADRINDEX 3
- // DAC is pci_dev->resource[3]
+ /* DAC is pci_dev->resource[3] */
/* Digital I/O registers */
-#define PORT1A 0 // PORT 1A DATA
+#define PORT1A 0 /* PORT 1A DATA */
-#define PORT1B 1 // PORT 1B DATA
+#define PORT1B 1 /* PORT 1B DATA */
-#define PORT1C 2 // PORT 1C DATA
+#define PORT1C 2 /* PORT 1C DATA */
-#define CONTROL1 3 // CONTROL REGISTER 1
+#define CONTROL1 3 /* CONTROL REGISTER 1 */
-#define PORT2A 4 // PORT 2A DATA
+#define PORT2A 4 /* PORT 2A DATA */
-#define PORT2B 5 // PORT 2B DATA
+#define PORT2B 5 /* PORT 2B DATA */
-#define PORT2C 6 // PORT 2C DATA
+#define PORT2C 6 /* PORT 2C DATA */
-#define CONTROL2 7 // CONTROL REGISTER 2
+#define CONTROL2 7 /* CONTROL REGISTER 2 */
/* DAC registers */
-#define DACONTROL 0 // D/A CONTROL REGISTER
-#define SU 0000001 // Simultaneous update enabled
-#define NOSU 0000000 // Simultaneous update disabled
-#define ENABLEDAC 0000002 // Enable specified DAC
-#define DISABLEDAC 0000000 // Disable specified DAC
-#define RANGE2V5 0000000 // 2.5V
-#define RANGE5V 0000200 // 5V
-#define RANGE10V 0000300 // 10V
-#define UNIP 0000400 // Unipolar outputs
-#define BIP 0000000 // Bipolar outputs
-
-#define DACALIBRATION1 4 // D/A CALIBRATION REGISTER 1
-//write bits
-#define SERIAL_IN_BIT 0x1 // serial data input for eeprom, caldacs, reference dac
+#define DACONTROL 0 /* D/A CONTROL REGISTER */
+#define SU 0000001 /* Simultaneous update enabled */
+#define NOSU 0000000 /* Simultaneous update disabled */
+#define ENABLEDAC 0000002 /* Enable specified DAC */
+#define DISABLEDAC 0000000 /* Disable specified DAC */
+#define RANGE2V5 0000000 /* 2.5V */
+#define RANGE5V 0000200 /* 5V */
+#define RANGE10V 0000300 /* 10V */
+#define UNIP 0000400 /* Unipolar outputs */
+#define BIP 0000000 /* Bipolar outputs */
+
+#define DACALIBRATION1 4 /* D/A CALIBRATION REGISTER 1 */
+/* write bits */
+#define SERIAL_IN_BIT 0x1 /* serial data input for eeprom, caldacs, reference dac */
#define CAL_CHANNEL_MASK (0x7 << 1)
#define CAL_CHANNEL_BITS(channel) (((channel) << 1) & CAL_CHANNEL_MASK)
-//read bits
+/* read bits */
#define CAL_COUNTER_MASK 0x1f
-#define CAL_COUNTER_OVERFLOW_BIT 0x20 // calibration counter overflow status bit
-#define AO_BELOW_REF_BIT 0x40 // analog output is less than reference dac voltage
-#define SERIAL_OUT_BIT 0x80 // serial data out, for reading from eeprom
+#define CAL_COUNTER_OVERFLOW_BIT 0x20 /* calibration counter overflow status bit */
+#define AO_BELOW_REF_BIT 0x40 /* analog output is less than reference dac voltage */
+#define SERIAL_OUT_BIT 0x80 /* serial data out, for reading from eeprom */
-#define DACALIBRATION2 6 // D/A CALIBRATION REGISTER 2
-#define SELECT_EEPROM_BIT 0x1 // send serial data in to eeprom
-#define DESELECT_REF_DAC_BIT 0x2 // don't send serial data to MAX542 reference dac
-#define DESELECT_CALDAC_BIT(n) (0x4 << (n)) // don't send serial data to caldac n
-#define DUMMY_BIT 0x40 // manual says to set this bit with no explanation
+#define DACALIBRATION2 6 /* D/A CALIBRATION REGISTER 2 */
+#define SELECT_EEPROM_BIT 0x1 /* send serial data in to eeprom */
+#define DESELECT_REF_DAC_BIT 0x2 /* don't send serial data to MAX542 reference dac */
+#define DESELECT_CALDAC_BIT(n) (0x4 << (n)) /* don't send serial data to caldac n */
+#define DUMMY_BIT 0x40 /* manual says to set this bit with no explanation */
-#define DADATA 8 // FIRST D/A DATA REGISTER (0)
+#define DADATA 8 /* FIRST D/A DATA REGISTER (0) */
static const struct comedi_lrange cb_pcidda_ranges = {
6,
@@ -131,63 +131,68 @@ static const struct comedi_lrange cb_pcidda_ranges = {
*/
struct cb_pcidda_board {
const char *name;
- char status; // Driver status:
- // 0 - tested
- // 1 - manual read, not tested
- // 2 - manual not read
+ char status; /* Driver status: */
+
+ /*
+ * 0 - tested
+ * 1 - manual read, not tested
+ * 2 - manual not read
+ */
+
unsigned short device_id;
int ao_chans;
int ao_bits;
const struct comedi_lrange *ranges;
};
+
static const struct cb_pcidda_board cb_pcidda_boards[] = {
{
- name: "pci-dda02/12",
- status: 1,
- device_id:0x20,
- ao_chans:2,
- ao_bits: 12,
- ranges: &cb_pcidda_ranges,
+ .name = "pci-dda02/12",
+ .status = 1,
+ .device_id = 0x20,
+ .ao_chans = 2,
+ .ao_bits = 12,
+ .ranges = &cb_pcidda_ranges,
},
{
- name: "pci-dda04/12",
- status: 1,
- device_id:0x21,
- ao_chans:4,
- ao_bits: 12,
- ranges: &cb_pcidda_ranges,
+ .name = "pci-dda04/12",
+ .status = 1,
+ .device_id = 0x21,
+ .ao_chans = 4,
+ .ao_bits = 12,
+ .ranges = &cb_pcidda_ranges,
},
{
- name: "pci-dda08/12",
- status: 0,
- device_id:0x22,
- ao_chans:8,
- ao_bits: 12,
- ranges: &cb_pcidda_ranges,
+ .name = "pci-dda08/12",
+ .status = 0,
+ .device_id = 0x22,
+ .ao_chans = 8,
+ .ao_bits = 12,
+ .ranges = &cb_pcidda_ranges,
},
{
- name: "pci-dda02/16",
- status: 2,
- device_id:0x23,
- ao_chans:2,
- ao_bits: 16,
- ranges: &cb_pcidda_ranges,
+ .name = "pci-dda02/16",
+ .status = 2,
+ .device_id = 0x23,
+ .ao_chans = 2,
+ .ao_bits = 16,
+ .ranges = &cb_pcidda_ranges,
},
{
- name: "pci-dda04/16",
- status: 2,
- device_id:0x24,
- ao_chans:4,
- ao_bits: 16,
- ranges: &cb_pcidda_ranges,
+ .name = "pci-dda04/16",
+ .status = 2,
+ .device_id = 0x24,
+ .ao_chans = 4,
+ .ao_bits = 16,
+ .ranges = &cb_pcidda_ranges,
},
{
- name: "pci-dda08/16",
- status: 0,
- device_id:0x25,
- ao_chans:8,
- ao_bits: 16,
- ranges: &cb_pcidda_ranges,
+ .name = "pci-dda08/16",
+ .status = 0,
+ .device_id = 0x25,
+ .ao_chans = 8,
+ .ao_bits = 16,
+ .ranges = &cb_pcidda_ranges,
},
};
@@ -219,11 +224,13 @@ struct cb_pcidda_private {
unsigned long digitalio;
unsigned long dac;
- //unsigned long control_status;
- //unsigned long adc_fifo;
- unsigned int dac_cal1_bits; // bits last written to da calibration register 1
- unsigned int ao_range[MAX_AO_CHANNELS]; // current range settings for output channels
- u16 eeprom_data[EEPROM_SIZE]; // software copy of board's eeprom
+
+ /* unsigned long control_status; */
+ /* unsigned long adc_fifo; */
+
+ unsigned int dac_cal1_bits; /* bits last written to da calibration register 1 */
+ unsigned int ao_range[MAX_AO_CHANNELS]; /* current range settings for output channels */
+ u16 eeprom_data[EEPROM_SIZE]; /* software copy of board's eeprom */
};
/*
@@ -232,20 +239,22 @@ struct cb_pcidda_private {
*/
#define devpriv ((struct cb_pcidda_private *)dev->private)
-static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int cb_pcidda_detach(struct comedi_device * dev);
-//static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data);
-static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-//static int cb_pcidda_ai_cmd(struct comedi_device *dev,struct comedi_subdevice *s);
-//static int cb_pcidda_ai_cmdtest(struct comedi_device *dev,struct comedi_subdevice *s, struct comedi_cmd *cmd);
-//static int cb_pcidda_ns_to_timer(unsigned int *ns,int round);
-static unsigned int cb_pcidda_serial_in(struct comedi_device * dev);
-static void cb_pcidda_serial_out(struct comedi_device * dev, unsigned int value,
+static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int cb_pcidda_detach(struct comedi_device *dev);
+/* static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */
+static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+
+/* static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct *comedi_subdevice *s);*/
+/* static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); */
+/* static int cb_pcidda_ns_to_timer(unsigned int *ns,int *round); */
+
+static unsigned int cb_pcidda_serial_in(struct comedi_device *dev);
+static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
unsigned int num_bits);
-static unsigned int cb_pcidda_read_eeprom(struct comedi_device * dev,
+static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
unsigned int address);
-static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel,
+static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
unsigned int range);
/*
@@ -255,17 +264,17 @@ static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel
* the device code.
*/
static struct comedi_driver driver_cb_pcidda = {
- driver_name:"cb_pcidda",
- module:THIS_MODULE,
- attach:cb_pcidda_attach,
- detach:cb_pcidda_detach,
+ .driver_name = "cb_pcidda",
+ .module = THIS_MODULE,
+ .attach = cb_pcidda_attach,
+ .detach = cb_pcidda_detach,
};
/*
* Attach is called by the Comedi core to configure the driver
* for a particular board.
*/
-static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
struct pci_dev *pcidev;
@@ -310,7 +319,7 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig
found:
devpriv->pci_dev = pcidev;
dev->board_ptr = cb_pcidda_boards + index;
- // "thisboard" macro can be used from here.
+ /* "thisboard" macro can be used from here. */
printk("Found %s at requested position\n", thisboard->name);
/*
@@ -353,11 +362,12 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig
s->maxdata = (1 << thisboard->ao_bits) - 1;
s->range_table = thisboard->ranges;
s->insn_write = cb_pcidda_ao_winsn;
-// s->subdev_flags |= SDF_CMD_READ;
-// s->do_cmd = cb_pcidda_ai_cmd;
-// s->do_cmdtest = cb_pcidda_ai_cmdtest;
- // two 8255 digital io subdevices
+ /* s->subdev_flags |= SDF_CMD_READ; */
+ /* s->do_cmd = cb_pcidda_ai_cmd; */
+ /* s->do_cmdtest = cb_pcidda_ai_cmdtest; */
+
+ /* two 8255 digital io subdevices */
s = dev->subdevices + 1;
subdev_8255_init(dev, s, NULL, devpriv->digitalio);
s = dev->subdevices + 2;
@@ -370,7 +380,7 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig
}
printk("\n");
- // set calibrations dacs
+ /* set calibrations dacs */
for (index = 0; index < thisboard->ao_chans; index++)
cb_pcidda_calibrate(dev, index, devpriv->ao_range[index]);
@@ -385,7 +395,7 @@ static int cb_pcidda_attach(struct comedi_device * dev, struct comedi_devconfig
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int cb_pcidda_detach(struct comedi_device * dev)
+static int cb_pcidda_detach(struct comedi_device *dev)
{
/*
* Deallocate the I/O ports.
@@ -398,7 +408,7 @@ static int cb_pcidda_detach(struct comedi_device * dev)
pci_dev_put(devpriv->pci_dev);
}
}
- // cleanup 8255
+ /* cleanup 8255 */
if (dev->subdevices) {
subdev_8255_cleanup(dev, dev->subdevices + 1);
subdev_8255_cleanup(dev, dev->subdevices + 2);
@@ -413,7 +423,7 @@ static int cb_pcidda_detach(struct comedi_device * dev)
* I will program this later... ;-)
*/
#if 0
-static int cb_pcidda_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
printk("cb_pcidda_ai_cmd\n");
printk("subdev: %d\n", cmd->subdev);
@@ -432,8 +442,8 @@ static int cb_pcidda_ai_cmd(struct comedi_device * dev, struct comedi_subdevice
#endif
#if 0
-static int cb_pcidda_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -598,8 +608,8 @@ static int cb_pcidda_ns_to_timer(unsigned int *ns, int round)
}
#endif
-static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int command;
unsigned int channel, range;
@@ -607,7 +617,7 @@ static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevic
channel = CR_CHAN(insn->chanspec);
range = CR_RANGE(insn->chanspec);
- // adjust calibration dacs if range has changed
+ /* adjust calibration dacs if range has changed */
if (range != devpriv->ao_range[channel])
cb_pcidda_calibrate(dev, channel, range);
@@ -647,15 +657,15 @@ static int cb_pcidda_ao_winsn(struct comedi_device * dev, struct comedi_subdevic
return 1;
}
-// lowlevel read from eeprom
-static unsigned int cb_pcidda_serial_in(struct comedi_device * dev)
+/* lowlevel read from eeprom */
+static unsigned int cb_pcidda_serial_in(struct comedi_device *dev)
{
unsigned int value = 0;
int i;
- const int value_width = 16; // number of bits wide values are
+ const int value_width = 16; /* number of bits wide values are */
for (i = 1; i <= value_width; i++) {
- // read bits most significant bit first
+ /* read bits most significant bit first */
if (inw_p(devpriv->dac + DACALIBRATION1) & SERIAL_OUT_BIT) {
value |= 1 << (value_width - i);
}
@@ -664,14 +674,14 @@ static unsigned int cb_pcidda_serial_in(struct comedi_device * dev)
return value;
}
-// lowlevel write to eeprom/dac
-static void cb_pcidda_serial_out(struct comedi_device * dev, unsigned int value,
+/* lowlevel write to eeprom/dac */
+static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
unsigned int num_bits)
{
int i;
for (i = 1; i <= num_bits; i++) {
- // send bits most significant bit first
+ /* send bits most significant bit first */
if (value & (1 << (num_bits - i)))
devpriv->dac_cal1_bits |= SERIAL_IN_BIT;
else
@@ -680,136 +690,137 @@ static void cb_pcidda_serial_out(struct comedi_device * dev, unsigned int value,
}
}
-// reads a 16 bit value from board's eeprom
-static unsigned int cb_pcidda_read_eeprom(struct comedi_device * dev,
+/* reads a 16 bit value from board's eeprom */
+static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
unsigned int address)
{
unsigned int i;
unsigned int cal2_bits;
unsigned int value;
- const int max_num_caldacs = 4; // one caldac for every two dac channels
- const int read_instruction = 0x6; // bits to send to tell eeprom we want to read
+ const int max_num_caldacs = 4; /* one caldac for every two dac channels */
+ const int read_instruction = 0x6; /* bits to send to tell eeprom we want to read */
const int instruction_length = 3;
const int address_length = 8;
- // send serial output stream to eeprom
+ /* send serial output stream to eeprom */
cal2_bits = SELECT_EEPROM_BIT | DESELECT_REF_DAC_BIT | DUMMY_BIT;
- // deactivate caldacs (one caldac for every two channels)
+ /* deactivate caldacs (one caldac for every two channels) */
for (i = 0; i < max_num_caldacs; i++) {
cal2_bits |= DESELECT_CALDAC_BIT(i);
}
outw_p(cal2_bits, devpriv->dac + DACALIBRATION2);
- // tell eeprom we want to read
+ /* tell eeprom we want to read */
cb_pcidda_serial_out(dev, read_instruction, instruction_length);
- // send address we want to read from
+ /* send address we want to read from */
cb_pcidda_serial_out(dev, address, address_length);
value = cb_pcidda_serial_in(dev);
- // deactivate eeprom
+ /* deactivate eeprom */
cal2_bits &= ~SELECT_EEPROM_BIT;
outw_p(cal2_bits, devpriv->dac + DACALIBRATION2);
return value;
}
-// writes to 8 bit calibration dacs
-static void cb_pcidda_write_caldac(struct comedi_device * dev, unsigned int caldac,
+/* writes to 8 bit calibration dacs */
+static void cb_pcidda_write_caldac(struct comedi_device *dev, unsigned int caldac,
unsigned int channel, unsigned int value)
{
unsigned int cal2_bits;
unsigned int i;
- const int num_channel_bits = 3; // caldacs use 3 bit channel specification
- const int num_caldac_bits = 8; // 8 bit calibration dacs
- const int max_num_caldacs = 4; // one caldac for every two dac channels
+ const int num_channel_bits = 3; /* caldacs use 3 bit channel specification */
+ const int num_caldac_bits = 8; /* 8 bit calibration dacs */
+ const int max_num_caldacs = 4; /* one caldac for every two dac channels */
/* write 3 bit channel */
cb_pcidda_serial_out(dev, channel, num_channel_bits);
- // write 8 bit caldac value
+ /* write 8 bit caldac value */
cb_pcidda_serial_out(dev, value, num_caldac_bits);
- // latch stream into appropriate caldac
- // deselect reference dac
+/*
+* latch stream into appropriate caldac deselect reference dac
+*/
cal2_bits = DESELECT_REF_DAC_BIT | DUMMY_BIT;
- // deactivate caldacs (one caldac for every two channels)
+ /* deactivate caldacs (one caldac for every two channels) */
for (i = 0; i < max_num_caldacs; i++) {
cal2_bits |= DESELECT_CALDAC_BIT(i);
}
- // activate the caldac we want
+ /* activate the caldac we want */
cal2_bits &= ~DESELECT_CALDAC_BIT(caldac);
outw_p(cal2_bits, devpriv->dac + DACALIBRATION2);
- // deactivate caldac
+ /* deactivate caldac */
cal2_bits |= DESELECT_CALDAC_BIT(caldac);
outw_p(cal2_bits, devpriv->dac + DACALIBRATION2);
}
-// returns caldac that calibrates given analog out channel
+/* returns caldac that calibrates given analog out channel */
static unsigned int caldac_number(unsigned int channel)
{
return channel / 2;
}
-// returns caldac channel that provides fine gain for given ao channel
+/* returns caldac channel that provides fine gain for given ao channel */
static unsigned int fine_gain_channel(unsigned int ao_channel)
{
return 4 * (ao_channel % 2);
}
-// returns caldac channel that provides coarse gain for given ao channel
+/* returns caldac channel that provides coarse gain for given ao channel */
static unsigned int coarse_gain_channel(unsigned int ao_channel)
{
return 1 + 4 * (ao_channel % 2);
}
-// returns caldac channel that provides coarse offset for given ao channel
+/* returns caldac channel that provides coarse offset for given ao channel */
static unsigned int coarse_offset_channel(unsigned int ao_channel)
{
return 2 + 4 * (ao_channel % 2);
}
-// returns caldac channel that provides fine offset for given ao channel
+/* returns caldac channel that provides fine offset for given ao channel */
static unsigned int fine_offset_channel(unsigned int ao_channel)
{
return 3 + 4 * (ao_channel % 2);
}
-// returns eeprom address that provides offset for given ao channel and range
+/* returns eeprom address that provides offset for given ao channel and range */
static unsigned int offset_eeprom_address(unsigned int ao_channel,
unsigned int range)
{
return 0x7 + 2 * range + 12 * ao_channel;
}
-// returns eeprom address that provides gain calibration for given ao channel and range
+/* returns eeprom address that provides gain calibration for given ao channel and range */
static unsigned int gain_eeprom_address(unsigned int ao_channel,
unsigned int range)
{
return 0x8 + 2 * range + 12 * ao_channel;
}
-// returns upper byte of eeprom entry, which gives the coarse adjustment values
+/* returns upper byte of eeprom entry, which gives the coarse adjustment values */
static unsigned int eeprom_coarse_byte(unsigned int word)
{
return (word >> 8) & 0xff;
}
-// returns lower byte of eeprom entry, which gives the fine adjustment values
+/* returns lower byte of eeprom entry, which gives the fine adjustment values */
static unsigned int eeprom_fine_byte(unsigned int word)
{
return word & 0xff;
}
-// set caldacs to eeprom values for given channel and range
-static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel,
+/* set caldacs to eeprom values for given channel and range */
+static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
unsigned int range)
{
unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain;
- // remember range so we can tell when we need to readjust calibration
+ /* remember range so we can tell when we need to readjust calibration */
devpriv->ao_range[channel] = range;
- // get values from eeprom data
+ /* get values from eeprom data */
coarse_offset =
eeprom_coarse_byte(devpriv->
eeprom_data[offset_eeprom_address(channel, range)]);
@@ -823,7 +834,7 @@ static void cb_pcidda_calibrate(struct comedi_device * dev, unsigned int channel
eeprom_fine_byte(devpriv->
eeprom_data[gain_eeprom_address(channel, range)]);
- // set caldacs
+ /* set caldacs */
cb_pcidda_write_caldac(dev, caldac_number(channel),
coarse_offset_channel(channel), coarse_offset);
cb_pcidda_write_caldac(dev, caldac_number(channel),
diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c
index 71a4b1482e36..dc701273167c 100644
--- a/drivers/staging/comedi/drivers/cb_pcidio.c
+++ b/drivers/staging/comedi/drivers/cb_pcidio.c
@@ -53,32 +53,32 @@ Passing a zero for an option is the same as leaving it unspecified.
* Some drivers use arrays such as this, other do not.
*/
struct pcidio_board {
- const char *name; // anme of the board
- int n_8255; // number of 8255 chips on board
+ const char *name; /* anme of the board */
+ int n_8255; /* number of 8255 chips on board */
- // indices of base address regions
+ /* indices of base address regions */
int pcicontroler_badrindex;
int dioregs_badrindex;
};
static const struct pcidio_board pcidio_boards[] = {
{
- name: "pci-dio24",
- n_8255: 1,
- pcicontroler_badrindex:1,
- dioregs_badrindex:2,
+ .name = "pci-dio24",
+ .n_8255 = 1,
+ .pcicontroler_badrindex = 1,
+ .dioregs_badrindex = 2,
},
{
- name: "pci-dio24h",
- n_8255: 1,
- pcicontroler_badrindex:1,
- dioregs_badrindex:2,
+ .name = "pci-dio24h",
+ .n_8255 = 1,
+ .pcicontroler_badrindex = 1,
+ .dioregs_badrindex = 2,
},
{
- name: "pci-dio48h",
- n_8255: 2,
- pcicontroler_badrindex:0,
- dioregs_badrindex:1,
+ .name = "pci-dio48h",
+ .n_8255 = 2,
+ .pcicontroler_badrindex = 0,
+ .dioregs_badrindex = 1,
},
};
@@ -104,7 +104,7 @@ MODULE_DEVICE_TABLE(pci, pcidio_pci_table);
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. */
struct pcidio_private {
- int data; // curently unused
+ int data; /* curently unused */
/* would be useful for a PCI device */
struct pci_dev *pci_dev;
@@ -112,7 +112,7 @@ struct pcidio_private {
/* used for DO readback, curently unused */
unsigned int do_readback[4]; /* up to 4 unsigned int suffice to hold 96 bits for PCI-DIO96 */
- unsigned long dio_reg_base; // address of port A of the first 8255 chip on board
+ unsigned long dio_reg_base; /* address of port A of the first 8255 chip on board */
};
/*
@@ -127,15 +127,17 @@ struct pcidio_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcidio_detach(struct comedi_device * dev);
+static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcidio_detach(struct comedi_device *dev);
static struct comedi_driver driver_cb_pcidio = {
- driver_name:"cb_pcidio",
- module:THIS_MODULE,
- attach:pcidio_attach,
- detach:pcidio_detach,
+ .driver_name = "cb_pcidio",
+ .module = THIS_MODULE,
+ .attach = pcidio_attach,
+ .detach = pcidio_detach,
+
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
+
/* Most drivers will support multiple types of boards by
* having an array of board structures. These were defined
* in pcidio_boards[] above. Note that the element 'name'
@@ -152,10 +154,15 @@ static struct comedi_driver driver_cb_pcidio = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
-// The following fields should NOT be initialized if you are dealing with PCI devices
-// board_name: pcidio_boards,
-// offset: sizeof(struct pcidio_board),
-// num_names: sizeof(pcidio_boards) / sizeof(struct pcidio_board),
+
+/* The following fields should NOT be initialized if you are dealing
+ * with PCI devices
+ *
+ * .board_name = pcidio_boards,
+ * .offset = sizeof(struct pcidio_board),
+ * .num_names = sizeof(pcidio_boards) / sizeof(structpcidio_board),
+ */
+
};
/*------------------------------- FUNCTIONS -----------------------------------*/
@@ -166,7 +173,7 @@ static struct comedi_driver driver_cb_pcidio = {
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pcidev = NULL;
int index;
@@ -192,19 +199,19 @@ static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * i
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
- // is it not a computer boards card?
+ /* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_CB)
continue;
- // loop through cards supported by this driver
+ /* loop through cards supported by this driver */
for (index = 0;
- index < sizeof pcidio_boards / sizeof(struct pcidio_board);
+ index < ARRAY_SIZE(pcidio_boards);
index++) {
if (pcidio_pci_table[index].device != pcidev->device)
continue;
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
PCI_SLOT(pcidev->devfn) !=
it->options[1]) {
@@ -267,7 +274,7 @@ static int pcidio_attach(struct comedi_device * dev, struct comedi_devconfig * i
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pcidio_detach(struct comedi_device * dev)
+static int pcidio_detach(struct comedi_device *dev)
{
printk("comedi%d: cb_pcidio: remove\n", dev->minor);
if (devpriv) {
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c
index af705fa092c0..57d250c73abc 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -43,29 +43,30 @@ See http://www.measurementcomputing.com/PDFManuals/pcim-das1602_16.pdf for more
#include "../comedidev.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include "comedi_pci.h"
#include "plx9052.h"
#include "8255.h"
-//#define CBPCIMDAS_DEBUG
+/* #define CBPCIMDAS_DEBUG */
#undef CBPCIMDAS_DEBUG
/* Registers for the PCIM-DAS1602/16 */
-// sizes of io regions (bytes)
-#define BADR0_SIZE 2 //??
+/* sizes of io regions (bytes) */
+#define BADR0_SIZE 2 /* ?? */
#define BADR1_SIZE 4
#define BADR2_SIZE 6
#define BADR3_SIZE 16
#define BADR4_SIZE 4
-//DAC Offsets
+/* DAC Offsets */
#define ADC_TRIG 0
#define DAC0_OFFSET 2
#define DAC1_OFFSET 4
-//AI and Counter Constants
+/* AI and Counter Constants */
#define MUX_LIMITS 0
#define MAIN_CONN_DIO 1
#define ADC_STAT 2
@@ -86,37 +87,37 @@ See http://www.measurementcomputing.com/PDFManuals/pcim-das1602_16.pdf for more
struct cb_pcimdas_board {
const char *name;
unsigned short device_id;
- int ai_se_chans; // Inputs in single-ended mode
- int ai_diff_chans; // Inputs in differential mode
- int ai_bits; // analog input resolution
- int ai_speed; // fastest conversion period in ns
- int ao_nchan; // number of analog out channels
- int ao_bits; // analogue output resolution
- int has_ao_fifo; // analog output has fifo
- int ao_scan_speed; // analog output speed for 1602 series (for a scan, not conversion)
- int fifo_size; // number of samples fifo can hold
- int dio_bits; // number of dio bits
- int has_dio; // has DIO
+ int ai_se_chans; /* Inputs in single-ended mode */
+ int ai_diff_chans; /* Inputs in differential mode */
+ int ai_bits; /* analog input resolution */
+ int ai_speed; /* fastest conversion period in ns */
+ int ao_nchan; /* number of analog out channels */
+ int ao_bits; /* analogue output resolution */
+ int has_ao_fifo; /* analog output has fifo */
+ int ao_scan_speed; /* analog output speed for 1602 series (for a scan, not conversion) */
+ int fifo_size; /* number of samples fifo can hold */
+ int dio_bits; /* number of dio bits */
+ int has_dio; /* has DIO */
const struct comedi_lrange *ranges;
};
static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
{
- name: "PCIM-DAS1602/16",
- device_id:0x56,
- ai_se_chans:16,
- ai_diff_chans:8,
- ai_bits: 16,
- ai_speed:10000, //??
- ao_nchan:2,
- ao_bits: 12,
- has_ao_fifo:0, //??
- ao_scan_speed:10000,
- //??
- fifo_size:1024,
- dio_bits:24,
- has_dio: 1,
-// ranges: &cb_pcimdas_ranges,
+ .name = "PCIM-DAS1602/16",
+ .device_id = 0x56,
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 16,
+ .ai_speed = 10000, /* ?? */
+ .ao_nchan = 2,
+ .ao_bits = 12,
+ .has_ao_fifo = 0, /* ?? */
+ .ao_scan_speed = 10000,
+ /* ?? */
+ .fifo_size = 1024,
+ .dio_bits = 24,
+ .has_dio = 1,
+/* .ranges = &cb_pcimdas_ranges, */
},
};
@@ -129,7 +130,7 @@ static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
-#define N_BOARDS 1 // Max number of boards supported
+#define N_BOARDS 1 /* Max number of boards supported */
/*
* Useful for shorthand access to the particular board structure
@@ -142,10 +143,10 @@ MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
struct cb_pcimdas_private {
int data;
- // would be useful for a PCI device
+ /* would be useful for a PCI device */
struct pci_dev *pci_dev;
- //base addresses
+ /* base addresses */
unsigned long BADR0;
unsigned long BADR1;
unsigned long BADR2;
@@ -155,11 +156,11 @@ struct cb_pcimdas_private {
/* Used for AO readback */
unsigned int ao_readback[2];
- // Used for DIO
- unsigned short int port_a; // copy of BADR4+0
- unsigned short int port_b; // copy of BADR4+1
- unsigned short int port_c; // copy of BADR4+2
- unsigned short int dio_mode; // copy of BADR4+3
+ /* Used for DIO */
+ unsigned short int port_a; /* copy of BADR4+0 */
+ unsigned short int port_b; /* copy of BADR4+1 */
+ unsigned short int port_c; /* copy of BADR4+2 */
+ unsigned short int dio_mode; /* copy of BADR4+3 */
};
@@ -175,21 +176,21 @@ struct cb_pcimdas_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int cb_pcimdas_detach(struct comedi_device * dev);
+static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int cb_pcimdas_detach(struct comedi_device *dev);
static struct comedi_driver driver_cb_pcimdas = {
- driver_name:"cb_pcimdas",
- module:THIS_MODULE,
- attach:cb_pcimdas_attach,
- detach:cb_pcimdas_detach,
+ .driver_name = "cb_pcimdas",
+ .module = THIS_MODULE,
+ .attach = cb_pcimdas_attach,
+ .detach = cb_pcimdas_detach,
};
-static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcimdas_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int cb_pcimdas_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/*
* Attach is called by the Comedi core to configure the driver
@@ -197,12 +198,12 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device * dev, struct comedi_subdevi
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
struct pci_dev *pcidev;
int index;
- //int i;
+ /* int i; */
printk("comedi%d: cb_pcimdas: ", dev->minor);
@@ -220,17 +221,17 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
- // is it not a computer boards card?
+ /* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
continue;
- // loop through cards supported by this driver
+ /* loop through cards supported by this driver */
for (index = 0; index < N_BOARDS; index++) {
if (cb_pcimdas_boards[index].device_id !=
pcidev->device)
continue;
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
PCI_SLOT(pcidev->devfn) !=
it->options[1]) {
@@ -252,7 +253,7 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig
printk("Found %s on bus %i, slot %i\n", cb_pcimdas_boards[index].name,
pcidev->bus->number, PCI_SLOT(pcidev->devfn));
- // Warn about non-tested features
+ /* Warn about non-tested features */
switch (thisboard->device_id) {
case 0x56:
break;
@@ -280,16 +281,16 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig
printk("devpriv->BADR4 = 0x%lx\n", devpriv->BADR4);
#endif
-// Dont support IRQ yet
-// // get irq
-// if(comedi_request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, "cb_pcimdas", dev ))
-// {
-// printk(" unable to allocate irq %u\n", devpriv->pci_dev->irq);
-// return -EINVAL;
-// }
-// dev->irq = devpriv->pci_dev->irq;
+/* Dont support IRQ yet */
+/* get irq */
+/* if(request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, "cb_pcimdas", dev )) */
+/* { */
+/* printk(" unable to allocate irq %u\n", devpriv->pci_dev->irq); */
+/* return -EINVAL; */
+/* } */
+/* dev->irq = devpriv->pci_dev->irq; */
- //Initialize dev->board_name
+ /* Initialize dev->board_name */
dev->board_name = thisboard->name;
/*
@@ -300,24 +301,24 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig
return -ENOMEM;
s = dev->subdevices + 0;
- //dev->read_subdev=s;
- // analog input subdevice
+ /* dev->read_subdev=s; */
+ /* analog input subdevice */
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = thisboard->ai_se_chans;
s->maxdata = (1 << thisboard->ai_bits) - 1;
s->range_table = &range_unknown;
- s->len_chanlist = 1; // This is the maximum chanlist length that
- // the board can handle
+ s->len_chanlist = 1; /* This is the maximum chanlist length that */
+ /* the board can handle */
s->insn_read = cb_pcimdas_ai_rinsn;
s = dev->subdevices + 1;
- // analog output subdevice
+ /* analog output subdevice */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = thisboard->ao_nchan;
s->maxdata = 1 << thisboard->ao_bits;
- s->range_table = &range_unknown; //ranges are hardware settable, but not software readable.
+ s->range_table = &range_unknown; /* ranges are hardware settable, but not software readable. */
s->insn_write = &cb_pcimdas_ao_winsn;
s->insn_read = &cb_pcimdas_ao_rinsn;
@@ -342,7 +343,7 @@ static int cb_pcimdas_attach(struct comedi_device * dev, struct comedi_devconfig
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int cb_pcimdas_detach(struct comedi_device * dev)
+static int cb_pcimdas_detach(struct comedi_device *dev)
{
#ifdef CBPCIMDAS_DEBUG
if (devpriv) {
@@ -355,7 +356,7 @@ static int cb_pcimdas_detach(struct comedi_device * dev)
#endif
printk("comedi%d: cb_pcimdas: remove\n", dev->minor);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->pci_dev) {
if (devpriv->BADR0) {
@@ -372,8 +373,8 @@ static int cb_pcimdas_detach(struct comedi_device * dev)
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
-static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
unsigned int d;
@@ -382,27 +383,27 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi
unsigned short chanlims;
int maxchans;
- // only support sw initiated reads from a single channel
+ /* only support sw initiated reads from a single channel */
- //check channel number
- if ((inb(devpriv->BADR3 + 2) & 0x20) == 0) //differential mode
+ /* check channel number */
+ if ((inb(devpriv->BADR3 + 2) & 0x20) == 0) /* differential mode */
maxchans = thisboard->ai_diff_chans;
else
maxchans = thisboard->ai_se_chans;
if (chan > (maxchans - 1))
- return -ETIMEDOUT; //*** Wrong error code. Fixme.
+ return -ETIMEDOUT; /* *** Wrong error code. Fixme. */
- //configure for sw initiated read
+ /* configure for sw initiated read */
d = inb(devpriv->BADR3 + 5);
- if ((d & 0x03) > 0) { //only reset if needed.
+ if ((d & 0x03) > 0) { /* only reset if needed. */
d = d & 0xfd;
outb(d, devpriv->BADR3 + 5);
}
- outb(0x01, devpriv->BADR3 + 6); //set bursting off, conversions on
- outb(0x00, devpriv->BADR3 + 7); //set range to 10V. UP/BP is controlled by a switch on the board
+ outb(0x01, devpriv->BADR3 + 6); /* set bursting off, conversions on */
+ outb(0x00, devpriv->BADR3 + 7); /* set range to 10V. UP/BP is controlled by a switch on the board */
- // write channel limits to multiplexer, set Low (bits 0-3) and High (bits 4-7) channels to chan.
+ /* write channel limits to multiplexer, set Low (bits 0-3) and High (bits 4-7) channels to chan. */
chanlims = chan | (chan << 4);
outb(chanlims, devpriv->BADR3 + 0);
@@ -411,8 +412,8 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi
/* trigger conversion */
outw(0, devpriv->BADR2 + 0);
-#define TIMEOUT 1000 //typically takes 5 loops on a lightly loaded Pentium 100MHz,
- //this is likely to be 100 loops on a 2GHz machine, so set 1000 as the limit.
+#define TIMEOUT 1000 /* typically takes 5 loops on a lightly loaded Pentium 100MHz, */
+ /* this is likely to be 100 loops on a 2GHz machine, so set 1000 as the limit. */
/* wait for conversion to end */
for (i = 0; i < TIMEOUT; i++) {
@@ -428,7 +429,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi
d = inw(devpriv->BADR2 + 0);
/* mangle the data as necessary */
- //d ^= 1<<(thisboard->ai_bits-1); // 16 bit data from ADC, so no mangle needed.
+ /* d ^= 1<<(thisboard->ai_bits-1); // 16 bit data from ADC, so no mangle needed. */
data[n] = d;
}
@@ -437,8 +438,8 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int cb_pcimdas_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -465,8 +466,8 @@ static int cb_pcimdas_ao_winsn(struct comedi_device * dev, struct comedi_subdevi
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int cb_pcimdas_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c
index e4c5b460fbd5..57bb1182480d 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdda.c
@@ -118,15 +118,15 @@ enum DIO_METHODS {
static const struct board_struct boards[] = {
{
- name: "cb_pcimdda06-16",
- device_id:PCI_ID_PCIM_DDA06_16,
- ao_chans:6,
- ao_bits: 16,
- dio_chans:24,
- dio_method:DIO_8255,
- dio_offset:12,
- regs_badrindex:3,
- reg_sz: 16,
+ .name = "cb_pcimdda06-16",
+ .device_id = PCI_ID_PCIM_DDA06_16,
+ .ao_chans = 6,
+ .ao_bits = 16,
+ .dio_chans = 24,
+ .dio_method = DIO_8255,
+ .dio_offset = 12,
+ .regs_badrindex = 3,
+ .reg_sz = 16,
}
};
@@ -135,8 +135,6 @@ static const struct board_struct boards[] = {
*/
#define thisboard ((const struct board_struct *)dev->board_ptr)
-/* Number of boards in boards[] */
-#define N_BOARDS (sizeof(boards) / sizeof(struct board_struct))
#define REG_SZ (thisboard->reg_sz)
#define REGS_BADRINDEX (thisboard->regs_badrindex)
@@ -181,13 +179,13 @@ struct board_private_struct {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int detach(struct comedi_device * dev);
+static int attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int detach(struct comedi_device *dev);
static struct comedi_driver cb_pcimdda_driver = {
- driver_name:"cb_pcimdda",
- module:THIS_MODULE,
- attach:attach,
- detach:detach,
+ .driver_name = "cb_pcimdda",
+ .module = THIS_MODULE,
+ .attach = attach,
+ .detach = detach,
};
MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
@@ -197,10 +195,10 @@ MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
MODULE_LICENSE("GPL");
COMEDI_PCI_INITCLEANUP_NOMODULE(cb_pcimdda_driver, pci_table);
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/*---------------------------------------------------------------------------
HELPER FUNCTION DECLARATIONS
@@ -209,7 +207,7 @@ static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
/* returns a maxdata value for a given n_bits */
static inline unsigned int figure_out_maxdata(int bits)
{
- return (((unsigned int) 1 << bits) - 1);
+ return ((unsigned int) 1 << bits) - 1;
}
/*
@@ -226,7 +224,7 @@ static inline unsigned int figure_out_maxdata(int bits)
*
* Otherwise, returns a -errno on error
*/
-static int probe(struct comedi_device * dev, const struct comedi_devconfig * it);
+static int probe(struct comedi_device *dev, const struct comedi_devconfig *it);
/*---------------------------------------------------------------------------
FUNCTION DEFINITIONS
@@ -238,7 +236,7 @@ static int probe(struct comedi_device * dev, const struct comedi_devconfig * it)
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int err;
@@ -257,7 +255,8 @@ static int attach(struct comedi_device * dev, struct comedi_devconfig * it)
* it is, this is the place to do it. Otherwise, dev->board_ptr
* should already be initialized.
*/
- if ((err = probe(dev, it)))
+ err = probe(dev, it);
+ if (err)
return err;
/* Output some info */
@@ -326,7 +325,7 @@ static int attach(struct comedi_device * dev, struct comedi_devconfig * it)
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int detach(struct comedi_device * dev)
+static int detach(struct comedi_device *dev)
{
if (devpriv) {
@@ -352,8 +351,8 @@ static int detach(struct comedi_device * dev)
return 0;
}
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -391,8 +390,8 @@ static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
all AO channels update simultaneously. This is useful for some control
applications, I would imagine.
*/
-static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -425,7 +424,7 @@ static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
*
* Otherwise, returns a -errno on error
*/
-static int probe(struct comedi_device * dev, const struct comedi_devconfig * it)
+static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
int index;
@@ -434,16 +433,16 @@ static int probe(struct comedi_device * dev, const struct comedi_devconfig * it)
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
- // is it not a computer boards card?
+ /* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
continue;
- // loop through cards supported by this driver
- for (index = 0; index < N_BOARDS; index++) {
+ /* loop through cards supported by this driver */
+ for (index = 0; index < ARRAY_SIZE(boards); index++) {
if (boards[index].device_id != pcidev->device)
continue;
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
PCI_SLOT(pcidev->devfn) !=
it->options[1]) {
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index 1ee489864d3b..45cd41f7fd29 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -210,7 +210,7 @@ static struct comedi_driver driver_bonding = {
*/
.board_name = &bondingBoards[0].name,
.offset = sizeof(struct BondingBoard),
- .num_names = sizeof(bondingBoards) / sizeof(struct BondingBoard),
+ .num_names = ARRAY_SIZE(bondingBoards),
};
static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c
index 9fa4cdc84d44..8ab8e733afb6 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -53,7 +53,7 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd, void *data
retval = comedi_buf_write_alloc(async, num_bytes);
if (retval != num_bytes) {
- rt_printk("comedi: buffer overrun\n");
+ printk("comedi: buffer overrun\n");
async->events |= COMEDI_CB_OVERFLOW;
return 0;
}
diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c
index a23339155ffc..f42897de640e 100644
--- a/drivers/staging/comedi/drivers/comedi_parport.c
+++ b/drivers/staging/comedi/drivers/comedi_parport.c
@@ -82,6 +82,7 @@ pin, which can be used to wake up tasks.
*/
#include "../comedidev.h"
+#include <linux/interrupt.h>
#include <linux/ioport.h>
#define PARPORT_SIZE 3
@@ -274,7 +275,7 @@ static int parport_intr_cancel(struct comedi_device *dev, struct comedi_subdevic
return 0;
}
-static irqreturn_t parport_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t parport_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices + 3;
@@ -309,8 +310,8 @@ static int parport_attach(struct comedi_device *dev, struct comedi_devconfig *it
irq = it->options[1];
if (irq) {
printk(" irq=%u", irq);
- ret = comedi_request_irq(irq, parport_interrupt, 0,
- "comedi_parport", dev);
+ ret = request_irq(irq, parport_interrupt, 0, "comedi_parport",
+ dev);
if (ret < 0) {
printk(" irq not available\n");
return -EINVAL;
@@ -384,7 +385,7 @@ static int parport_detach(struct comedi_device *dev)
release_region(dev->iobase, PARPORT_SIZE);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
return 0;
}
diff --git a/drivers/staging/comedi/drivers/comedi_rt_timer.c b/drivers/staging/comedi/drivers/comedi_rt_timer.c
deleted file mode 100644
index f40c8cffd4bb..000000000000
--- a/drivers/staging/comedi/drivers/comedi_rt_timer.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- comedi/drivers/comedi_rt_timer.c
- virtual driver for using RTL timing sources
-
- Authors: David A. Schleef, Frank M. Hess
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1999,2001 David A. Schleef <ds@schleef.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-**************************************************************************
-*/
-/*
-Driver: comedi_rt_timer
-Description: Command emulator using real-time tasks
-Author: ds, fmhess
-Devices:
-Status: works
-
-This driver requires RTAI or RTLinux to work correctly. It doesn't
-actually drive hardware directly, but calls other drivers and uses
-a real-time task to emulate commands for drivers and devices that
-are incapable of native commands. Thus, you can get accurately
-timed I/O on any device.
-
-Since the timing is all done in software, sampling jitter is much
-higher than with a device that has an on-board timer, and maximum
-sample rate is much lower.
-
-Configuration options:
- [0] - minor number of device you wish to emulate commands for
- [1] - subdevice number you wish to emulate commands for
-*/
-/*
-TODO:
- Support for digital io commands could be added, except I can't see why
- anyone would want to use them
- What happens if device we are emulating for is de-configured?
-*/
-
-#include "../comedidev.h"
-#include "../comedilib.h"
-
-#include "comedi_fc.h"
-
-#ifdef CONFIG_COMEDI_RTL_V1
-#include <rtl_sched.h>
-#include <asm/rt_irq.h>
-#endif
-#ifdef CONFIG_COMEDI_RTL
-#include <rtl.h>
-#include <rtl_sched.h>
-#include <rtl_compat.h>
-#include <asm/div64.h>
-
-#ifndef RTLINUX_VERSION_CODE
-#define RTLINUX_VERSION_CODE 0
-#endif
-#ifndef RTLINUX_VERSION
-#define RTLINUX_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
-
-// begin hack to workaround broken HRT_TO_8254() function on rtlinux
-#if RTLINUX_VERSION_CODE <= RTLINUX_VERSION(3,0,100)
-// this function sole purpose is to divide a long long by 838
-static inline RTIME nano2count(long long ns)
-{
- do_div(ns, 838);
- return ns;
-}
-
-#ifdef rt_get_time()
-#undef rt_get_time()
-#endif
-#define rt_get_time() nano2count(gethrtime())
-
-#else
-
-#define nano2count(x) HRT_TO_8254(x)
-#endif
-// end hack
-
-// rtl-rtai compatibility
-#define rt_task_wait_period() rt_task_wait()
-#define rt_pend_linux_srq(irq) rtl_global_pend_irq(irq)
-#define rt_free_srq(irq) rtl_free_soft_irq(irq)
-#define rt_request_srq(x,y,z) rtl_get_soft_irq(y,"timer")
-#define rt_task_init(a,b,c,d,e,f,g) rt_task_init(a,b,c,d,(e)+1)
-#define rt_task_resume(x) rt_task_wakeup(x)
-#define rt_set_oneshot_mode()
-#define start_rt_timer(x)
-#define stop_rt_timer()
-
-#endif
-#ifdef CONFIG_COMEDI_RTAI
-#include <rtai.h>
-#include <rtai_sched.h>
-
-#if RTAI_VERSION_CODE < RTAI_MANGLE_VERSION(3,3,0)
-#define comedi_rt_task_context_t int
-#else
-#define comedi_rt_task_context_t long
-#endif
-
-#endif
-
-/* This defines the fastest speed we will emulate. Note that
- * without a watchdog (like in RTAI), we could easily overrun our
- * task period because analog input tends to be slow. */
-#define SPEED_LIMIT 100000 /* in nanoseconds */
-
-static int timer_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int timer_detach(struct comedi_device * dev);
-static int timer_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
- unsigned int trig_num);
-static int timer_start_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-
-static struct comedi_driver driver_timer = {
- module:THIS_MODULE,
- driver_name:"comedi_rt_timer",
- attach:timer_attach,
- detach:timer_detach,
-// open: timer_open,
-};
-
-COMEDI_INITCLEANUP(driver_timer);
-
-struct timer_private {
- comedi_t *device; // device we are emulating commands for
- int subd; // subdevice we are emulating commands for
- RT_TASK *rt_task; // rt task that starts scans
- RT_TASK *scan_task; // rt task that controls conversion timing in a scan
- /* io_function can point to either an input or output function
- * depending on what kind of subdevice we are emulating for */
- int (*io_function) (struct comedi_device * dev, struct comedi_cmd * cmd,
- unsigned int index);
- // RTIME has units of 1 = 838 nanoseconds
- // time at which first scan started, used to check scan timing
- RTIME start;
- // time between scans
- RTIME scan_period;
- // time between conversions in a scan
- RTIME convert_period;
- // flags
- volatile int stop; // indicates we should stop
- volatile int rt_task_active; // indicates rt_task is servicing a struct comedi_cmd
- volatile int scan_task_active; // indicates scan_task is servicing a struct comedi_cmd
- unsigned timer_running:1;
-};
-#define devpriv ((struct timer_private *)dev->private)
-
-static int timer_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
-{
- devpriv->stop = 1;
-
- return 0;
-}
-
-// checks for scan timing error
-inline static int check_scan_timing(struct comedi_device * dev,
- unsigned long long scan)
-{
- RTIME now, timing_error;
-
- now = rt_get_time();
- timing_error = now - (devpriv->start + scan * devpriv->scan_period);
- if (timing_error > devpriv->scan_period) {
- comedi_error(dev, "timing error");
- rt_printk("scan started %i ns late\n", timing_error * 838);
- return -1;
- }
-
- return 0;
-}
-
-// checks for conversion timing error
-inline static int check_conversion_timing(struct comedi_device * dev,
- RTIME scan_start, unsigned int conversion)
-{
- RTIME now, timing_error;
-
- now = rt_get_time();
- timing_error =
- now - (scan_start + conversion * devpriv->convert_period);
- if (timing_error > devpriv->convert_period) {
- comedi_error(dev, "timing error");
- rt_printk("conversion started %i ns late\n",
- timing_error * 838);
- return -1;
- }
-
- return 0;
-}
-
-// devpriv->io_function for an input subdevice
-static int timer_data_read(struct comedi_device * dev, struct comedi_cmd * cmd,
- unsigned int index)
-{
- struct comedi_subdevice *s = dev->read_subdev;
- int ret;
- unsigned int data;
-
- ret = comedi_data_read(devpriv->device, devpriv->subd,
- CR_CHAN(cmd->chanlist[index]),
- CR_RANGE(cmd->chanlist[index]),
- CR_AREF(cmd->chanlist[index]), &data);
- if (ret < 0) {
- comedi_error(dev, "read error");
- return -EIO;
- }
- if (s->flags & SDF_LSAMPL) {
- cfc_write_long_to_buffer(s, data);
- } else {
- comedi_buf_put(s->async, data);
- }
-
- return 0;
-}
-
-// devpriv->io_function for an output subdevice
-static int timer_data_write(struct comedi_device * dev, struct comedi_cmd * cmd,
- unsigned int index)
-{
- struct comedi_subdevice *s = dev->write_subdev;
- unsigned int num_bytes;
- short data;
- unsigned int long_data;
- int ret;
-
- if (s->flags & SDF_LSAMPL) {
- num_bytes =
- cfc_read_array_from_buffer(s, &long_data,
- sizeof(long_data));
- } else {
- num_bytes = cfc_read_array_from_buffer(s, &data, sizeof(data));
- long_data = data;
- }
-
- if (num_bytes == 0) {
- comedi_error(dev, "buffer underrun");
- return -EAGAIN;
- }
- ret = comedi_data_write(devpriv->device, devpriv->subd,
- CR_CHAN(cmd->chanlist[index]),
- CR_RANGE(cmd->chanlist[index]),
- CR_AREF(cmd->chanlist[index]), long_data);
- if (ret < 0) {
- comedi_error(dev, "write error");
- return -EIO;
- }
-
- return 0;
-}
-
-// devpriv->io_function for DIO subdevices
-static int timer_dio_read(struct comedi_device * dev, struct comedi_cmd * cmd,
- unsigned int index)
-{
- struct comedi_subdevice *s = dev->read_subdev;
- int ret;
- unsigned int data;
-
- ret = comedi_dio_bitfield(devpriv->device, devpriv->subd, 0, &data);
- if (ret < 0) {
- comedi_error(dev, "read error");
- return -EIO;
- }
-
- if (s->flags & SDF_LSAMPL)
- cfc_write_long_to_buffer(s, data);
- else
- cfc_write_to_buffer(s, data);
-
- return 0;
-}
-
-// performs scans
-static void scan_task_func(comedi_rt_task_context_t d)
-{
- struct comedi_device *dev = (struct comedi_device *) d;
- struct comedi_subdevice *s = dev->subdevices + 0;
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &async->cmd;
- int i, ret;
- unsigned long long n;
- RTIME scan_start;
-
- // every struct comedi_cmd causes one execution of while loop
- while (1) {
- devpriv->scan_task_active = 1;
- // each for loop completes one scan
- for (n = 0; n < cmd->stop_arg || cmd->stop_src == TRIG_NONE;
- n++) {
- if (n) {
- // suspend task until next scan
- ret = rt_task_suspend(devpriv->scan_task);
- if (ret < 0) {
- comedi_error(dev,
- "error suspending scan task");
- async->events |= COMEDI_CB_ERROR;
- goto cleanup;
- }
- }
- // check if stop flag was set (by timer_cancel())
- if (devpriv->stop)
- goto cleanup;
- ret = check_scan_timing(dev, n);
- if (ret < 0) {
- async->events |= COMEDI_CB_ERROR;
- goto cleanup;
- }
- scan_start = rt_get_time();
- for (i = 0; i < cmd->scan_end_arg; i++) {
- // conversion timing
- if (cmd->convert_src == TRIG_TIMER && i) {
- rt_task_wait_period();
- ret = check_conversion_timing(dev,
- scan_start, i);
- if (ret < 0) {
- async->events |=
- COMEDI_CB_ERROR;
- goto cleanup;
- }
- }
- ret = devpriv->io_function(dev, cmd, i);
- if (ret < 0) {
- async->events |= COMEDI_CB_ERROR;
- goto cleanup;
- }
- }
- s->async->events |= COMEDI_CB_BLOCK;
- comedi_event(dev, s);
- s->async->events = 0;
- }
-
- cleanup:
-
- comedi_unlock(devpriv->device, devpriv->subd);
- async->events |= COMEDI_CB_EOA;
- comedi_event(dev, s);
- async->events = 0;
- devpriv->scan_task_active = 0;
- // suspend task until next struct comedi_cmd
- rt_task_suspend(devpriv->scan_task);
- }
-}
-
-static void timer_task_func(comedi_rt_task_context_t d)
-{
- struct comedi_device *dev = (struct comedi_device *) d;
- struct comedi_subdevice *s = dev->subdevices + 0;
- struct comedi_cmd *cmd = &s->async->cmd;
- int ret;
- unsigned long long n;
-
- // every struct comedi_cmd causes one execution of while loop
- while (1) {
- devpriv->rt_task_active = 1;
- devpriv->scan_task_active = 1;
- devpriv->start = rt_get_time();
-
- for (n = 0; n < cmd->stop_arg || cmd->stop_src == TRIG_NONE;
- n++) {
- // scan timing
- if (n)
- rt_task_wait_period();
- if (devpriv->scan_task_active == 0) {
- goto cleanup;
- }
- ret = rt_task_make_periodic(devpriv->scan_task,
- devpriv->start + devpriv->scan_period * n,
- devpriv->convert_period);
- if (ret < 0) {
- comedi_error(dev, "bug!");
- }
- }
-
- cleanup:
-
- devpriv->rt_task_active = 0;
- // suspend until next struct comedi_cmd
- rt_task_suspend(devpriv->rt_task);
- }
-}
-
-static int timer_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
-{
- struct comedi_insn xinsn = *insn;
-
- xinsn.data = data;
- xinsn.subdev = devpriv->subd;
-
- return comedi_do_insn(devpriv->device, &xinsn);
-}
-
-static int cmdtest_helper(struct comedi_cmd * cmd,
- unsigned int start_src,
- unsigned int scan_begin_src,
- unsigned int convert_src,
- unsigned int scan_end_src, unsigned int stop_src)
-{
- int err = 0;
- int tmp;
-
- tmp = cmd->start_src;
- cmd->start_src &= start_src;
- if (!cmd->start_src || tmp != cmd->start_src)
- err++;
-
- tmp = cmd->scan_begin_src;
- cmd->scan_begin_src &= scan_begin_src;
- if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
- err++;
-
- tmp = cmd->convert_src;
- cmd->convert_src &= convert_src;
- if (!cmd->convert_src || tmp != cmd->convert_src)
- err++;
-
- tmp = cmd->scan_end_src;
- cmd->scan_end_src &= scan_end_src;
- if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
- err++;
-
- tmp = cmd->stop_src;
- cmd->stop_src &= stop_src;
- if (!cmd->stop_src || tmp != cmd->stop_src)
- err++;
-
- return err;
-}
-
-static int timer_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
-{
- int err = 0;
- unsigned int start_src = 0;
-
- if (s->type == COMEDI_SUBD_AO)
- start_src = TRIG_INT;
- else
- start_src = TRIG_NOW;
-
- err = cmdtest_helper(cmd, start_src, /* start_src */
- TRIG_TIMER | TRIG_FOLLOW, /* scan_begin_src */
- TRIG_NOW | TRIG_TIMER, /* convert_src */
- TRIG_COUNT, /* scan_end_src */
- TRIG_COUNT | TRIG_NONE); /* stop_src */
- if (err)
- return 1;
-
- /* step 2: make sure trigger sources are unique and mutually
- * compatible */
-
- if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_INT)
- err++;
- if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_FOLLOW)
- err++;
- if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_NOW)
- err++;
- if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
- err++;
- if (cmd->scan_begin_src == TRIG_FOLLOW
- && cmd->convert_src != TRIG_TIMER)
- err++;
- if (cmd->convert_src == TRIG_NOW && cmd->scan_begin_src != TRIG_TIMER)
- err++;
-
- if (err)
- return 2;
-
- /* step 3: make sure arguments are trivially compatible */
- // limit frequency, this is fairly arbitrary
- if (cmd->scan_begin_src == TRIG_TIMER) {
- if (cmd->scan_begin_arg < SPEED_LIMIT) {
- cmd->scan_begin_arg = SPEED_LIMIT;
- err++;
- }
- }
- if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < SPEED_LIMIT) {
- cmd->convert_arg = SPEED_LIMIT;
- err++;
- }
- }
- // make sure conversion and scan frequencies are compatible
- if (cmd->convert_src == TRIG_TIMER && cmd->scan_begin_src == TRIG_TIMER) {
- if (cmd->convert_arg * cmd->scan_end_arg > cmd->scan_begin_arg) {
- cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
- err++;
- }
- }
- if (err)
- return 3;
-
- /* step 4: fix up and arguments */
- if (err)
- return 4;
-
- return 0;
-}
-
-static int timer_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
-{
- int ret;
- struct comedi_cmd *cmd = &s->async->cmd;
-
- /* hack attack: drivers are not supposed to do this: */
- dev->rt = 1;
-
- // make sure tasks have finished cleanup of last struct comedi_cmd
- if (devpriv->rt_task_active || devpriv->scan_task_active)
- return -EBUSY;
-
- ret = comedi_lock(devpriv->device, devpriv->subd);
- if (ret < 0) {
- comedi_error(dev, "failed to obtain lock");
- return ret;
- }
- switch (cmd->scan_begin_src) {
- case TRIG_TIMER:
- devpriv->scan_period = nano2count(cmd->scan_begin_arg);
- break;
- case TRIG_FOLLOW:
- devpriv->scan_period =
- nano2count(cmd->convert_arg * cmd->scan_end_arg);
- break;
- default:
- comedi_error(dev, "bug setting scan period!");
- return -1;
- break;
- }
- switch (cmd->convert_src) {
- case TRIG_TIMER:
- devpriv->convert_period = nano2count(cmd->convert_arg);
- break;
- case TRIG_NOW:
- devpriv->convert_period = 1;
- break;
- default:
- comedi_error(dev, "bug setting conversion period!");
- return -1;
- break;
- }
-
- if (cmd->start_src == TRIG_NOW)
- return timer_start_cmd(dev, s);
-
- s->async->inttrig = timer_inttrig;
-
- return 0;
-}
-
-static int timer_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
- unsigned int trig_num)
-{
- if (trig_num != 0)
- return -EINVAL;
-
- s->async->inttrig = NULL;
-
- return timer_start_cmd(dev, s);
-}
-
-static int timer_start_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
-{
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &async->cmd;
- RTIME now, delay, period;
- int ret;
-
- devpriv->stop = 0;
- s->async->events = 0;
-
- if (cmd->start_src == TRIG_NOW)
- delay = nano2count(cmd->start_arg);
- else
- delay = 0;
-
- now = rt_get_time();
- /* Using 'period' this way gets around some weird bug in gcc-2.95.2
- * that generates the compile error 'internal error--unrecognizable insn'
- * when rt_task_make_period() is called (observed with rtlinux-3.1, linux-2.2.19).
- * - fmhess */
- period = devpriv->scan_period;
- ret = rt_task_make_periodic(devpriv->rt_task, now + delay, period);
- if (ret < 0) {
- comedi_error(dev, "error starting rt_task");
- return ret;
- }
- return 0;
-}
-
-static int timer_attach(struct comedi_device * dev, struct comedi_devconfig * it)
-{
- int ret;
- struct comedi_subdevice *s, *emul_s;
- struct comedi_device *emul_dev;
- /* These should probably be devconfig options[] */
- const int timer_priority = 4;
- const int scan_priority = timer_priority + 1;
- char path[20];
-
- printk("comedi%d: timer: ", dev->minor);
-
- dev->board_name = "timer";
-
- if ((ret = alloc_subdevices(dev, 1)) < 0)
- return ret;
- if ((ret = alloc_private(dev, sizeof(struct timer_private))) < 0)
- return ret;
-
- sprintf(path, "/dev/comedi%d", it->options[0]);
- devpriv->device = comedi_open(path);
- devpriv->subd = it->options[1];
-
- printk("emulating commands for minor %i, subdevice %d\n",
- it->options[0], devpriv->subd);
-
- emul_dev = devpriv->device;
- emul_s = emul_dev->subdevices + devpriv->subd;
-
- // input or output subdevice
- s = dev->subdevices + 0;
- s->type = emul_s->type;
- s->subdev_flags = emul_s->subdev_flags; /* SDF_GROUND (to fool check_driver) */
- s->n_chan = emul_s->n_chan;
- s->len_chanlist = 1024;
- s->do_cmd = timer_cmd;
- s->do_cmdtest = timer_cmdtest;
- s->cancel = timer_cancel;
- s->maxdata = emul_s->maxdata;
- s->range_table = emul_s->range_table;
- s->range_table_list = emul_s->range_table_list;
- switch (emul_s->type) {
- case COMEDI_SUBD_AI:
- s->insn_read = timer_insn;
- dev->read_subdev = s;
- s->subdev_flags |= SDF_CMD_READ;
- devpriv->io_function = timer_data_read;
- break;
- case COMEDI_SUBD_AO:
- s->insn_write = timer_insn;
- s->insn_read = timer_insn;
- dev->write_subdev = s;
- s->subdev_flags |= SDF_CMD_WRITE;
- devpriv->io_function = timer_data_write;
- break;
- case COMEDI_SUBD_DIO:
- s->insn_write = timer_insn;
- s->insn_read = timer_insn;
- s->insn_bits = timer_insn;
- dev->read_subdev = s;
- s->subdev_flags |= SDF_CMD_READ;
- devpriv->io_function = timer_dio_read;
- break;
- default:
- comedi_error(dev, "failed to determine subdevice type!");
- return -EINVAL;
- }
-
- rt_set_oneshot_mode();
- start_rt_timer(1);
- devpriv->timer_running = 1;
-
- devpriv->rt_task = kzalloc(sizeof(RT_TASK), GFP_KERNEL);
-
- // initialize real-time tasks
- ret = rt_task_init(devpriv->rt_task, timer_task_func,
- (comedi_rt_task_context_t) dev, 3000, timer_priority, 0, 0);
- if (ret < 0) {
- comedi_error(dev, "error initalizing rt_task");
- kfree(devpriv->rt_task);
- devpriv->rt_task = 0;
- return ret;
- }
-
- devpriv->scan_task = kzalloc(sizeof(RT_TASK), GFP_KERNEL);
-
- ret = rt_task_init(devpriv->scan_task, scan_task_func,
- (comedi_rt_task_context_t) dev, 3000, scan_priority, 0, 0);
- if (ret < 0) {
- comedi_error(dev, "error initalizing scan_task");
- kfree(devpriv->scan_task);
- devpriv->scan_task = 0;
- return ret;
- }
-
- return 1;
-}
-
-// free allocated resources
-static int timer_detach(struct comedi_device * dev)
-{
- printk("comedi%d: timer: remove\n", dev->minor);
-
- if (devpriv) {
- if (devpriv->rt_task) {
- rt_task_delete(devpriv->rt_task);
- kfree(devpriv->rt_task);
- }
- if (devpriv->scan_task) {
- rt_task_delete(devpriv->scan_task);
- kfree(devpriv->scan_task);
- }
- if (devpriv->timer_running)
- stop_rt_timer();
- if (devpriv->device)
- comedi_close(devpriv->device);
- }
- return 0;
-}
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index e679328a4f8f..93ed1a0ae126 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -102,7 +102,7 @@ static struct comedi_driver driver_waveform = {
.detach = waveform_detach,
.board_name = &waveform_boards[0].name,
.offset = sizeof(struct waveform_board),
- .num_names = sizeof(waveform_boards) / sizeof(struct waveform_board),
+ .num_names = ARRAY_SIZE(waveform_boards),
};
COMEDI_INITCLEANUP(driver_waveform);
diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c
index 1f194a0a45d6..6c58e9990323 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -75,29 +75,29 @@ struct contec_private {
#define devpriv ((struct contec_private *)dev->private)
-static int contec_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int contec_detach(struct comedi_device * dev);
+static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int contec_detach(struct comedi_device *dev);
static struct comedi_driver driver_contec = {
- driver_name:"contec_pci_dio",
- module:THIS_MODULE,
- attach:contec_attach,
- detach:contec_detach,
+ .driver_name = "contec_pci_dio",
+ .module = THIS_MODULE,
+ .attach = contec_attach,
+ .detach = contec_detach,
};
/* Classic digital IO */
-static int contec_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int contec_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
#if 0
-static int contec_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
+static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
static int contec_ns_to_timer(unsigned int *ns, int round);
#endif
-static int contec_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
struct comedi_subdevice *s;
@@ -164,7 +164,7 @@ static int contec_attach(struct comedi_device * dev, struct comedi_devconfig * i
return -EIO;
}
-static int contec_detach(struct comedi_device * dev)
+static int contec_detach(struct comedi_device *dev)
{
printk("comedi%d: contec: remove\n", dev->minor);
@@ -179,8 +179,8 @@ static int contec_detach(struct comedi_device * dev)
}
#if 0
-static int contec_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
printk("contec_cmdtest called\n");
return 0;
@@ -192,8 +192,8 @@ static int contec_ns_to_timer(unsigned int *ns, int round)
}
#endif
-static int contec_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
printk("contec_do_insn_bits called\n");
@@ -205,19 +205,19 @@ static int contec_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
- rt_printk(" out: %d on %lx\n", s->state,
+ printk(" out: %d on %lx\n", s->state,
dev->iobase + thisboard->out_offs);
outw(s->state, dev->iobase + thisboard->out_offs);
}
return 2;
}
-static int contec_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- rt_printk("contec_di_insn_bits called\n");
- rt_printk(" data: %d %d\n", data[0], data[1]);
+ printk("contec_di_insn_bits called\n");
+ printk(" data: %d %d\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index 3b8444f09f28..d4526c616a99 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -119,6 +119,7 @@ Configuration options:
#include "../comedidev.h"
#include <linux/delay.h>
+#include <linux/interrupt.h>
#include "comedi_pci.h"
#include "8255.h"
@@ -129,7 +130,7 @@ Configuration options:
#define DAQBOARD2000_DAQ_SIZE 0x1002
#define DAQBOARD2000_PLX_SIZE 0x100
-// Initialization bits for the Serial EEPROM Control Register
+/* Initialization bits for the Serial EEPROM Control Register */
#define DAQBOARD2000_SECRProgPinHi 0x8001767e
#define DAQBOARD2000_SECRProgPinLo 0x8000767e
#define DAQBOARD2000_SECRLocalBusHi 0xc000767e
@@ -137,14 +138,14 @@ Configuration options:
#define DAQBOARD2000_SECRReloadHi 0xa000767e
#define DAQBOARD2000_SECRReloadLo 0x8000767e
-// SECR status bits
+/* SECR status bits */
#define DAQBOARD2000_EEPROM_PRESENT 0x10000000
-// CPLD status bits
+/* CPLD status bits */
#define DAQBOARD2000_CPLD_INIT 0x0002
#define DAQBOARD2000_CPLD_DONE 0x0004
-// Available ranges
+/* Available ranges */
static const struct comedi_lrange range_daqboard2000_ai = { 13, {
RANGE(-10, 10),
RANGE(-5, 5),
@@ -168,65 +169,65 @@ static const struct comedi_lrange range_daqboard2000_ao = { 1, {
};
struct daqboard2000_hw {
- volatile u16 acqControl; // 0x00
- volatile u16 acqScanListFIFO; // 0x02
- volatile u32 acqPacerClockDivLow; // 0x04
-
- volatile u16 acqScanCounter; // 0x08
- volatile u16 acqPacerClockDivHigh; // 0x0a
- volatile u16 acqTriggerCount; // 0x0c
- volatile u16 fill2; // 0x0e
- volatile u16 acqResultsFIFO; // 0x10
- volatile u16 fill3; // 0x12
- volatile u16 acqResultsShadow; // 0x14
- volatile u16 fill4; // 0x16
- volatile u16 acqAdcResult; // 0x18
- volatile u16 fill5; // 0x1a
- volatile u16 dacScanCounter; // 0x1c
- volatile u16 fill6; // 0x1e
-
- volatile u16 dacControl; // 0x20
- volatile u16 fill7; // 0x22
- volatile s16 dacFIFO; // 0x24
- volatile u16 fill8[2]; // 0x26
- volatile u16 dacPacerClockDiv; // 0x2a
- volatile u16 refDacs; // 0x2c
- volatile u16 fill9; // 0x2e
-
- volatile u16 dioControl; // 0x30
- volatile s16 dioP3hsioData; // 0x32
- volatile u16 dioP3Control; // 0x34
- volatile u16 calEepromControl; // 0x36
- volatile s16 dacSetting[4]; // 0x38
- volatile s16 dioP2ExpansionIO8Bit[32]; // 0x40
-
- volatile u16 ctrTmrControl; // 0x80
- volatile u16 fill10[3]; // 0x82
- volatile s16 ctrInput[4]; // 0x88
- volatile u16 fill11[8]; // 0x90
- volatile u16 timerDivisor[2]; // 0xa0
- volatile u16 fill12[6]; // 0xa4
-
- volatile u16 dmaControl; // 0xb0
- volatile u16 trigControl; // 0xb2
- volatile u16 fill13[2]; // 0xb4
- volatile u16 calEeprom; // 0xb8
- volatile u16 acqDigitalMark; // 0xba
- volatile u16 trigDacs; // 0xbc
- volatile u16 fill14; // 0xbe
- volatile s16 dioP2ExpansionIO16Bit[32]; // 0xc0
+ volatile u16 acqControl; /* 0x00 */
+ volatile u16 acqScanListFIFO; /* 0x02 */
+ volatile u32 acqPacerClockDivLow; /* 0x04 */
+
+ volatile u16 acqScanCounter; /* 0x08 */
+ volatile u16 acqPacerClockDivHigh; /* 0x0a */
+ volatile u16 acqTriggerCount; /* 0x0c */
+ volatile u16 fill2; /* 0x0e */
+ volatile u16 acqResultsFIFO; /* 0x10 */
+ volatile u16 fill3; /* 0x12 */
+ volatile u16 acqResultsShadow; /* 0x14 */
+ volatile u16 fill4; /* 0x16 */
+ volatile u16 acqAdcResult; /* 0x18 */
+ volatile u16 fill5; /* 0x1a */
+ volatile u16 dacScanCounter; /* 0x1c */
+ volatile u16 fill6; /* 0x1e */
+
+ volatile u16 dacControl; /* 0x20 */
+ volatile u16 fill7; /* 0x22 */
+ volatile s16 dacFIFO; /* 0x24 */
+ volatile u16 fill8[2]; /* 0x26 */
+ volatile u16 dacPacerClockDiv; /* 0x2a */
+ volatile u16 refDacs; /* 0x2c */
+ volatile u16 fill9; /* 0x2e */
+
+ volatile u16 dioControl; /* 0x30 */
+ volatile s16 dioP3hsioData; /* 0x32 */
+ volatile u16 dioP3Control; /* 0x34 */
+ volatile u16 calEepromControl; /* 0x36 */
+ volatile s16 dacSetting[4]; /* 0x38 */
+ volatile s16 dioP2ExpansionIO8Bit[32]; /* 0x40 */
+
+ volatile u16 ctrTmrControl; /* 0x80 */
+ volatile u16 fill10[3]; /* 0x82 */
+ volatile s16 ctrInput[4]; /* 0x88 */
+ volatile u16 fill11[8]; /* 0x90 */
+ volatile u16 timerDivisor[2]; /* 0xa0 */
+ volatile u16 fill12[6]; /* 0xa4 */
+
+ volatile u16 dmaControl; /* 0xb0 */
+ volatile u16 trigControl; /* 0xb2 */
+ volatile u16 fill13[2]; /* 0xb4 */
+ volatile u16 calEeprom; /* 0xb8 */
+ volatile u16 acqDigitalMark; /* 0xba */
+ volatile u16 trigDacs; /* 0xbc */
+ volatile u16 fill14; /* 0xbe */
+ volatile s16 dioP2ExpansionIO16Bit[32]; /* 0xc0 */
};
/* Scan Sequencer programming */
#define DAQBOARD2000_SeqStartScanList 0x0011
#define DAQBOARD2000_SeqStopScanList 0x0010
-// Prepare for acquisition
+/* Prepare for acquisition */
#define DAQBOARD2000_AcqResetScanListFifo 0x0004
#define DAQBOARD2000_AcqResetResultsFifo 0x0002
#define DAQBOARD2000_AcqResetConfigPipe 0x0001
-// Acqusition status bits
+/* Acqusition status bits */
#define DAQBOARD2000_AcqResultsFIFOMore1Sample 0x0001
#define DAQBOARD2000_AcqResultsFIFOHasValidData 0x0002
#define DAQBOARD2000_AcqResultsFIFOOverrun 0x0004
@@ -239,7 +240,7 @@ struct daqboard2000_hw {
#define DAQBOARD2000_DacPacerOverrun 0x0200
#define DAQBOARD2000_AcqHardwareError 0x01c0
-// Scan Sequencer programming
+/* Scan Sequencer programming */
#define DAQBOARD2000_SeqStartScanList 0x0011
#define DAQBOARD2000_SeqStopScanList 0x0010
@@ -254,7 +255,7 @@ struct daqboard2000_hw {
#define DAQBOARD2000_AdcPacerInternalOutEnable 0x0008
#define DAQBOARD2000_AdcPacerExternalRising 0x0100
-// DAC status
+/* DAC status */
#define DAQBOARD2000_DacFull 0x0001
#define DAQBOARD2000_RefBusy 0x0002
#define DAQBOARD2000_TrgBusy 0x0004
@@ -264,7 +265,7 @@ struct daqboard2000_hw {
#define DAQBOARD2000_Dac2Busy 0x0040
#define DAQBOARD2000_Dac3Busy 0x0080
-// DAC control
+/* DAC control */
#define DAQBOARD2000_Dac0Enable 0x0021
#define DAQBOARD2000_Dac1Enable 0x0031
#define DAQBOARD2000_Dac2Enable 0x0041
@@ -292,18 +293,18 @@ struct daqboard2000_hw {
#define DAQBOARD2000_TrigEnable 0x0001
#define DAQBOARD2000_TrigDisable 0x0000
-// Reference Dac Selection
+/* Reference Dac Selection */
#define DAQBOARD2000_PosRefDacSelect 0x0100
#define DAQBOARD2000_NegRefDacSelect 0x0000
-static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int daqboard2000_detach(struct comedi_device * dev);
+static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int daqboard2000_detach(struct comedi_device *dev);
static struct comedi_driver driver_daqboard2000 = {
- driver_name:"daqboard2000",
- module:THIS_MODULE,
- attach:daqboard2000_attach,
- detach:daqboard2000_detach,
+ .driver_name = "daqboard2000",
+ .module = THIS_MODULE,
+ .attach = daqboard2000_attach,
+ .detach = daqboard2000_detach,
};
struct daq200_boardtype {
@@ -338,17 +339,17 @@ struct daqboard2000_private {
#define devpriv ((struct daqboard2000_private *)dev->private)
-static void writeAcqScanListEntry(struct comedi_device * dev, u16 entry)
+static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry)
{
struct daqboard2000_hw *fpga = devpriv->daq;
-// comedi_udelay(4);
+/* udelay(4); */
fpga->acqScanListFIFO = entry & 0x00ff;
-// comedi_udelay(4);
+/* udelay(4); */
fpga->acqScanListFIFO = (entry >> 8) & 0x00ff;
}
-static void setup_sampling(struct comedi_device * dev, int chan, int gain)
+static void setup_sampling(struct comedi_device *dev, int chan, int gain)
{
u16 word0, word1, word2, word3;
@@ -393,8 +394,8 @@ static void setup_sampling(struct comedi_device * dev, int chan, int gain)
writeAcqScanListEntry(dev, word3);
}
-static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
struct daqboard2000_hw *fpga = devpriv->daq;
@@ -425,14 +426,14 @@ static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_s
if (fpga->acqControl & DAQBOARD2000_AcqConfigPipeFull) {
break;
}
- //comedi_udelay(2);
+ /* udelay(2); */
}
fpga->acqControl = DAQBOARD2000_AdcPacerEnable;
for (timeout = 0; timeout < 20; timeout++) {
if (fpga->acqControl & DAQBOARD2000_AcqLogicScanning) {
break;
}
- //comedi_udelay(2);
+ /* udelay(2); */
}
for (timeout = 0; timeout < 20; timeout++) {
if (fpga->
@@ -440,7 +441,7 @@ static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_s
DAQBOARD2000_AcqResultsFIFOHasValidData) {
break;
}
- //comedi_udelay(2);
+ /* udelay(2); */
}
data[i] = fpga->acqResultsFIFO;
fpga->acqControl = DAQBOARD2000_AdcPacerDisable;
@@ -450,8 +451,8 @@ static int daqboard2000_ai_insn_read(struct comedi_device * dev, struct comedi_s
return i;
}
-static int daqboard2000_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqboard2000_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -463,8 +464,8 @@ static int daqboard2000_ao_insn_read(struct comedi_device * dev, struct comedi_s
return i;
}
-static int daqboard2000_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqboard2000_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -476,54 +477,54 @@ static int daqboard2000_ao_insn_write(struct comedi_device * dev, struct comedi_
* OK, since it works OK without enabling the DAC's, let's keep
* it as simple as possible...
*/
- //fpga->dacControl = (chan + 2) * 0x0010 | 0x0001; comedi_udelay(1000);
+ /* fpga->dacControl = (chan + 2) * 0x0010 | 0x0001; udelay(1000); */
fpga->dacSetting[chan] = data[i];
for (timeout = 0; timeout < 20; timeout++) {
if ((fpga->dacControl & ((chan + 1) * 0x0010)) == 0) {
break;
}
- //comedi_udelay(2);
+ /* udelay(2); */
}
devpriv->ao_readback[chan] = data[i];
/*
* Since we never enabled the DAC's, we don't need to disable it...
- * fpga->dacControl = (chan + 2) * 0x0010 | 0x0000; comedi_udelay(1000);
+ * fpga->dacControl = (chan + 2) * 0x0010 | 0x0000; udelay(1000);
*/
}
return i;
}
-static void daqboard2000_resetLocalBus(struct comedi_device * dev)
+static void daqboard2000_resetLocalBus(struct comedi_device *dev)
{
printk("daqboard2000_resetLocalBus\n");
writel(DAQBOARD2000_SECRLocalBusHi, devpriv->plx + 0x6c);
- comedi_udelay(10000);
+ udelay(10000);
writel(DAQBOARD2000_SECRLocalBusLo, devpriv->plx + 0x6c);
- comedi_udelay(10000);
+ udelay(10000);
}
-static void daqboard2000_reloadPLX(struct comedi_device * dev)
+static void daqboard2000_reloadPLX(struct comedi_device *dev)
{
printk("daqboard2000_reloadPLX\n");
writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c);
- comedi_udelay(10000);
+ udelay(10000);
writel(DAQBOARD2000_SECRReloadHi, devpriv->plx + 0x6c);
- comedi_udelay(10000);
+ udelay(10000);
writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c);
- comedi_udelay(10000);
+ udelay(10000);
}
-static void daqboard2000_pulseProgPin(struct comedi_device * dev)
+static void daqboard2000_pulseProgPin(struct comedi_device *dev)
{
printk("daqboard2000_pulseProgPin 1\n");
writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c);
- comedi_udelay(10000);
+ udelay(10000);
writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c);
- comedi_udelay(10000); /* Not in the original code, but I like symmetry... */
+ udelay(10000); /* Not in the original code, but I like symmetry... */
}
-static int daqboard2000_pollCPLD(struct comedi_device * dev, int mask)
+static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask)
{
int result = 0;
int i;
@@ -536,17 +537,17 @@ static int daqboard2000_pollCPLD(struct comedi_device * dev, int mask)
result = 1;
break;
}
- comedi_udelay(100);
+ udelay(100);
}
- comedi_udelay(5);
+ udelay(5);
return result;
}
-static int daqboard2000_writeCPLD(struct comedi_device * dev, int data)
+static int daqboard2000_writeCPLD(struct comedi_device *dev, int data)
{
int result = 0;
- comedi_udelay(10);
+ udelay(10);
writew(data, devpriv->daq + 0x1000);
if ((readw(devpriv->daq + 0x1000) & DAQBOARD2000_CPLD_INIT) ==
DAQBOARD2000_CPLD_INIT) {
@@ -555,7 +556,7 @@ static int daqboard2000_writeCPLD(struct comedi_device * dev, int data)
return result;
}
-static int initialize_daqboard2000(struct comedi_device * dev,
+static int initialize_daqboard2000(struct comedi_device *dev,
unsigned char *cpld_array, int len)
{
int result = -EIO;
@@ -613,75 +614,75 @@ static int initialize_daqboard2000(struct comedi_device * dev,
return result;
}
-static void daqboard2000_adcStopDmaTransfer(struct comedi_device * dev)
+static void daqboard2000_adcStopDmaTransfer(struct comedi_device *dev)
{
/* printk("Implement: daqboard2000_adcStopDmaTransfer\n");*/
}
-static void daqboard2000_adcDisarm(struct comedi_device * dev)
+static void daqboard2000_adcDisarm(struct comedi_device *dev)
{
struct daqboard2000_hw *fpga = devpriv->daq;
/* Disable hardware triggers */
- comedi_udelay(2);
+ udelay(2);
fpga->trigControl = DAQBOARD2000_TrigAnalog | DAQBOARD2000_TrigDisable;
- comedi_udelay(2);
+ udelay(2);
fpga->trigControl = DAQBOARD2000_TrigTTL | DAQBOARD2000_TrigDisable;
/* Stop the scan list FIFO from loading the configuration pipe */
- comedi_udelay(2);
+ udelay(2);
fpga->acqControl = DAQBOARD2000_SeqStopScanList;
/* Stop the pacer clock */
- comedi_udelay(2);
+ udelay(2);
fpga->acqControl = DAQBOARD2000_AdcPacerDisable;
/* Stop the input dma (abort channel 1) */
daqboard2000_adcStopDmaTransfer(dev);
}
-static void daqboard2000_activateReferenceDacs(struct comedi_device * dev)
+static void daqboard2000_activateReferenceDacs(struct comedi_device *dev)
{
struct daqboard2000_hw *fpga = devpriv->daq;
int timeout;
- // Set the + reference dac value in the FPGA
+ /* Set the + reference dac value in the FPGA */
fpga->refDacs = 0x80 | DAQBOARD2000_PosRefDacSelect;
for (timeout = 0; timeout < 20; timeout++) {
if ((fpga->dacControl & DAQBOARD2000_RefBusy) == 0) {
break;
}
- comedi_udelay(2);
+ udelay(2);
}
/* printk("DAQBOARD2000_PosRefDacSelect %d\n", timeout);*/
- // Set the - reference dac value in the FPGA
+ /* Set the - reference dac value in the FPGA */
fpga->refDacs = 0x80 | DAQBOARD2000_NegRefDacSelect;
for (timeout = 0; timeout < 20; timeout++) {
if ((fpga->dacControl & DAQBOARD2000_RefBusy) == 0) {
break;
}
- comedi_udelay(2);
+ udelay(2);
}
/* printk("DAQBOARD2000_NegRefDacSelect %d\n", timeout);*/
}
-static void daqboard2000_initializeCtrs(struct comedi_device * dev)
+static void daqboard2000_initializeCtrs(struct comedi_device *dev)
{
/* printk("Implement: daqboard2000_initializeCtrs\n");*/
}
-static void daqboard2000_initializeTmrs(struct comedi_device * dev)
+static void daqboard2000_initializeTmrs(struct comedi_device *dev)
{
/* printk("Implement: daqboard2000_initializeTmrs\n");*/
}
-static void daqboard2000_dacDisarm(struct comedi_device * dev)
+static void daqboard2000_dacDisarm(struct comedi_device *dev)
{
/* printk("Implement: daqboard2000_dacDisarm\n");*/
}
-static void daqboard2000_initializeAdc(struct comedi_device * dev)
+static void daqboard2000_initializeAdc(struct comedi_device *dev)
{
daqboard2000_adcDisarm(dev);
daqboard2000_activateReferenceDacs(dev);
@@ -689,7 +690,7 @@ static void daqboard2000_initializeAdc(struct comedi_device * dev)
daqboard2000_initializeTmrs(dev);
}
-static void daqboard2000_initializeDac(struct comedi_device * dev)
+static void daqboard2000_initializeDac(struct comedi_device *dev)
{
daqboard2000_dacDisarm(dev);
}
@@ -717,7 +718,7 @@ static int daqboard2000_8255_cb(int dir, int port, int data,
return result;
}
-static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int result = 0;
struct comedi_subdevice *s;
@@ -772,7 +773,8 @@ static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconf
}
}
- if ((result = comedi_pci_enable(card, "daqboard2000")) < 0) {
+ result = comedi_pci_enable(card, "daqboard2000");
+ if (result < 0) {
printk(" failed to enable PCI device and request regions\n");
return -EIO;
}
@@ -849,7 +851,7 @@ static int daqboard2000_attach(struct comedi_device * dev, struct comedi_devconf
return result;
}
-static int daqboard2000_detach(struct comedi_device * dev)
+static int daqboard2000_detach(struct comedi_device *dev)
{
printk("comedi%d: daqboard2000: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index e4563331e963..c20cd8feb13d 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -65,12 +65,12 @@ driver.
#define PCI_DEVICE_ID_PCIDAS08 0x29
#define PCIDAS08_SIZE 0x54
-// pci configuration registers
+/* pci configuration registers */
#define INTCSR 0x4c
#define INTR1_ENABLE 0x1
#define INTR1_HIGH_POLARITY 0x2
#define PCI_INTR_ENABLE 0x40
-#define INTR1_EDGE_TRIG 0x100 // requires high polarity
+#define INTR1_EDGE_TRIG 0x100 /* requires high polarity */
#define CNTRL 0x50
#define CNTRL_DIR 0x2
#define CNTRL_INTR 0x4
@@ -154,20 +154,20 @@ driver.
/* gainlist same as _pgx_ below */
-static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das08_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das08_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das08jr_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das08jr_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das08jr_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das08ao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static void i8254_set_mode_low(unsigned int base, int channel,
unsigned int mode);
@@ -248,211 +248,211 @@ static const int *const das08_gainlists[] = {
static const struct das08_board_struct das08_boards[] = {
{
- name: "isa-das08", // cio-das08.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pg_none,
- ai_encoding:das08_encode12,
- ao: NULL,
- ao_nbits:12,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:8,
- i8254_offset:4,
- iosize: 16, // unchecked
+ .name = "isa-das08", /* cio-das08.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 8,
+ .i8254_offset = 4,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08-pgm", // cio-das08pgx.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pgm,
- ai_encoding:das08_encode12,
- ao: NULL,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08-pgm", /* cio-das08pgx.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgm,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08-pgh", // cio-das08pgx.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pgh,
- ai_encoding:das08_encode12,
- ao: NULL,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08-pgh", /* cio-das08pgx.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgh,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08-pgl", // cio-das08pgx.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pgl,
- ai_encoding:das08_encode12,
- ao: NULL,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08-pgl", /* cio-das08pgx.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgl,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08-aoh", // cio-das08_aox.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pgh,
- ai_encoding:das08_encode12,
- ao: das08ao_ao_winsn, // 8
- ao_nbits:12,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0x0c,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08-aoh", /* cio-das08_aox.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgh,
+ .ai_encoding = das08_encode12,
+ .ao = das08ao_ao_winsn, /* 8 */
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0x0c,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08-aol", // cio-das08_aox.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pgl,
- ai_encoding:das08_encode12,
- ao: das08ao_ao_winsn, // 8
- ao_nbits:12,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0x0c,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08-aol", /* cio-das08_aox.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgl,
+ .ai_encoding = das08_encode12,
+ .ao = das08ao_ao_winsn, /* 8 */
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0x0c,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08-aom", // cio-das08_aox.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pgm,
- ai_encoding:das08_encode12,
- ao: das08ao_ao_winsn, // 8
- ao_nbits:12,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0x0c,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08-aom", /* cio-das08_aox.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgm,
+ .ai_encoding = das08_encode12,
+ .ao = das08ao_ao_winsn, /* 8 */
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0x0c,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08/jr-ao", // cio-das08-jr-ao.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pg_none,
- ai_encoding:das08_encode12,
- ao: das08jr_ao_winsn,
- ao_nbits:12,
- di: das08jr_di_rbits,
- do_: das08jr_do_wbits,
- do_nchan:8,
- i8255_offset:0,
- i8254_offset:0,
- iosize: 16, // unchecked
+ .name = "das08/jr-ao", /* cio-das08-jr-ao.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = das08jr_ao_winsn,
+ .ao_nbits = 12,
+ .di = das08jr_di_rbits,
+ .do_ = das08jr_do_wbits,
+ .do_nchan = 8,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16, /* unchecked */
},
{
- name: "das08jr-16-ao", // cio-das08jr-16-ao.pdf
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:16,
- ai_pg: das08_pg_none,
- ai_encoding:das08_encode12,
- ao: das08jr_ao_winsn,
- ao_nbits:16,
- di: das08jr_di_rbits,
- do_: das08jr_do_wbits,
- do_nchan:8,
- i8255_offset:0,
- i8254_offset:0x04,
- iosize: 16, // unchecked
+ .name = "das08jr-16-ao", /* cio-das08jr-16-ao.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = das08jr_ao_winsn,
+ .ao_nbits = 16,
+ .di = das08jr_di_rbits,
+ .do_ = das08jr_do_wbits,
+ .do_nchan = 8,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "das08", // pci-das08
- id: PCI_DEVICE_ID_PCIDAS08,
- bustype: pci,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_bipolar5,
- ai_encoding:das08_encode12,
- ao: NULL,
- ao_nbits:0,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0,
- i8254_offset:4,
- iosize: 8,
+ .name = "das08", /* pci-das08 */
+ .id = PCI_DEVICE_ID_PCIDAS08,
+ .bustype = pci,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_bipolar5,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 4,
+ .iosize = 8,
},
#endif
{
- name: "pc104-das08",
- bustype: pc104,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_pg_none,
- ai_encoding:das08_encode12,
- ao: NULL,
- ao_nbits:0,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:4,
- i8255_offset:0,
- i8254_offset:4,
- iosize: 16, // unchecked
+ .name = "pc104-das08",
+ .bustype = pc104,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 4,
+ .iosize = 16, /* unchecked */
},
#if 0
{
- name: "das08/f",
+ .name = "das08/f",
},
{
- name: "das08jr",
+ .name = "das08jr",
},
#endif
{
- name: "das08jr/16",
- bustype: isa,
- ai: das08_ai_rinsn,
- ai_nbits:16,
- ai_pg: das08_pg_none,
- ai_encoding:das08_encode16,
- ao: NULL,
- ao_nbits:0,
- di: das08jr_di_rbits,
- do_: das08jr_do_wbits,
- do_nchan:8,
- i8255_offset:0,
- i8254_offset:0,
- iosize: 16, // unchecked
+ .name = "das08jr/16",
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode16,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08jr_di_rbits,
+ .do_ = das08jr_do_wbits,
+ .do_nchan = 8,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16, /* unchecked */
},
#if 0
{
- name: "das48-pga", // cio-das48-pga.pdf
+ .name = "das48-pga", /* cio-das48-pga.pdf */
},
{
- name: "das08-pga-g2", // a KM board
+ .name = "das08-pga-g2", /* a KM board */
},
#endif
};
@@ -460,39 +460,39 @@ static const struct das08_board_struct das08_boards[] = {
#ifdef CONFIG_COMEDI_PCMCIA
struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
{
- name: "pcm-das08",
- id: 0x0, // XXX
- bustype: pcmcia,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_bipolar5,
- ai_encoding:das08_pcm_encode12,
- ao: NULL,
- ao_nbits:0,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:3,
- i8255_offset:0,
- i8254_offset:0,
- iosize: 16,
+ .name = "pcm-das08",
+ .id = 0x0, /* XXX */
+ .bustype = pcmcia,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_bipolar5,
+ .ai_encoding = das08_pcm_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 3,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16,
},
- // duplicate so driver name can be used also
+ /* duplicate so driver name can be used also */
{
- name: "das08_cs",
- id: 0x0, // XXX
- bustype: pcmcia,
- ai: das08_ai_rinsn,
- ai_nbits:12,
- ai_pg: das08_bipolar5,
- ai_encoding:das08_pcm_encode12,
- ao: NULL,
- ao_nbits:0,
- di: das08_di_rbits,
- do_: das08_do_wbits,
- do_nchan:3,
- i8255_offset:0,
- i8254_offset:0,
- iosize: 16,
+ .name = "das08_cs",
+ .id = 0x0, /* XXX */
+ .bustype = pcmcia,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_bipolar5,
+ .ai_encoding = das08_pcm_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 3,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16,
},
};
#endif
@@ -512,8 +512,8 @@ MODULE_DEVICE_TABLE(pci, das08_pci_table);
#define TIMEOUT 100000
-static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan;
@@ -528,7 +528,7 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
inb(dev->iobase + DAS08_MSB);
/* set multiplexer */
- spin_lock(&dev->spinlock); // lock to prevent race with digital output
+ spin_lock(&dev->spinlock); /* lock to prevent race with digital output */
devpriv->do_mux_bits &= ~DAS08_MUX_MASK;
devpriv->do_mux_bits |= DAS08_MUX(chan);
outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL);
@@ -545,7 +545,7 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
/* clear over-range bits for 16-bit boards */
if (thisboard->ai_nbits == 16)
if (inb(dev->iobase + DAS08_MSB) & 0x80)
- rt_printk("das08: over-range\n");
+ printk("das08: over-range\n");
/* trigger conversion */
outb_p(0, dev->iobase + DAS08_TRIG_12BIT);
@@ -555,7 +555,7 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
break;
}
if (i == TIMEOUT) {
- rt_printk("das08: timeout\n");
+ printk("das08: timeout\n");
return -ETIME;
}
msb = inb(dev->iobase + DAS08_MSB);
@@ -579,8 +579,8 @@ static int das08_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static int das08_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = 0;
data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS));
@@ -588,19 +588,19 @@ static int das08_di_rbits(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int das08_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int wbits;
- // get current settings of digital output lines
+ /* get current settings of digital output lines */
wbits = (devpriv->do_mux_bits >> 4) & 0xf;
- // null bits we are going to set
+ /* null bits we are going to set */
wbits &= ~data[0];
- // set new bit values
+ /* set new bit values */
wbits |= data[0] & data[1];
- // remember digital output bits
- spin_lock(&dev->spinlock); // prevent race with setting of analog input mux
+ /* remember digital output bits */
+ spin_lock(&dev->spinlock); /* prevent race with setting of analog input mux */
devpriv->do_mux_bits &= ~DAS08_DO_MASK;
devpriv->do_mux_bits |= DAS08_OP(wbits);
outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL);
@@ -611,8 +611,8 @@ static int das08_do_wbits(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int das08jr_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = 0;
data[1] = inb(dev->iobase + DAS08JR_DIO);
@@ -620,12 +620,12 @@ static int das08jr_di_rbits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int das08jr_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- // null bits we are going to set
+ /* null bits we are going to set */
devpriv->do_bits &= ~data[0];
- // set new bit values
+ /* set new bit values */
devpriv->do_bits |= data[0] & data[1];
outb(devpriv->do_bits, dev->iobase + DAS08JR_DIO);
@@ -634,8 +634,8 @@ static int das08jr_do_wbits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int das08jr_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int lsb, msb;
@@ -668,8 +668,8 @@ static int das08jr_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
* a different method to force an update.
*
*/
-static int das08ao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int lsb, msb;
@@ -782,31 +782,31 @@ static unsigned int i8254_read_status(struct i8254_struct *st, int channel)
return i8254_read_status_low(st->iobase, chan);
}
-static int das08_counter_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08_counter_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = insn->chanspec;
- //printk("Reading counter channel %d ",chan);
+ /* printk("Reading counter channel %d ",chan); */
data[0] = i8254_read_channel(&devpriv->i8254, chan);
- //printk("=> 0x%08X\n",data[0]);
+ /* printk("=> 0x%08X\n",data[0]); */
return 1;
}
-static int das08_counter_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08_counter_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = insn->chanspec;
- //printk("Writing counter channel %d with 0x%04X\n",chan,data[0]);
+ /* printk("Writing counter channel %d with 0x%04X\n",chan,data[0]); */
i8254_write_channel(&devpriv->i8254, chan, data[0]);
return 1;
}
-static int das08_counter_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das08_counter_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = insn->chanspec;
@@ -827,25 +827,25 @@ static int das08_counter_config(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it);
+static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static struct comedi_driver driver_das08 = {
- driver_name: DRV_NAME,
- module:THIS_MODULE,
- attach:das08_attach,
- detach:das08_common_detach,
- board_name:&das08_boards[0].name,
- num_names:sizeof(das08_boards) /
+ .driver_name = DRV_NAME,
+ .module = THIS_MODULE,
+ .attach = das08_attach,
+ .detach = das08_common_detach,
+ .board_name = &das08_boards[0].name,
+ .num_names = sizeof(das08_boards) /
sizeof(struct das08_board_struct),
- offset:sizeof(struct das08_board_struct),
+ .offset = sizeof(struct das08_board_struct),
};
-int das08_common_attach(struct comedi_device * dev, unsigned long iobase)
+int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
{
struct comedi_subdevice *s;
int ret;
- // allocate ioports for non-pcmcia, non-pci boards
+ /* allocate ioports for non-pcmcia, non-pci boards */
if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) {
printk(" iobase 0x%lx\n", iobase);
if (!request_region(iobase, thisboard->iosize, DRV_NAME)) {
@@ -857,7 +857,8 @@ int das08_common_attach(struct comedi_device * dev, unsigned long iobase)
dev->board_name = thisboard->name;
- if ((ret = alloc_subdevices(dev, 6)) < 0)
+ ret = alloc_subdevices(dev, 6);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -880,7 +881,7 @@ int das08_common_attach(struct comedi_device * dev, unsigned long iobase)
/* ao */
if (thisboard->ao) {
s->type = COMEDI_SUBD_AO;
-// XXX lacks read-back insn
+/* XXX lacks read-back insn */
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
s->maxdata = (1 << thisboard->ao_nbits) - 1;
@@ -952,7 +953,7 @@ int das08_common_attach(struct comedi_device * dev, unsigned long iobase)
return 0;
}
-static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
@@ -961,11 +962,12 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it
struct pci_dev *pdev;
#endif
- if ((ret = alloc_private(dev, sizeof(struct das08_private_struct))) < 0)
+ ret = alloc_private(dev, sizeof(struct das08_private_struct));
+ if (ret < 0)
return ret;
printk("comedi%d: das08: ", dev->minor);
- // deal with a pci board
+ /* deal with a pci board */
if (thisboard->bustype == pci) {
#ifdef CONFIG_COMEDI_PCI
if (it->options[0] || it->options[1]) {
@@ -973,7 +975,7 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it
it->options[0], it->options[1]);
}
printk("\n");
- // find card
+ /* find card */
for (pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pdev != NULL;
pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) {
@@ -995,12 +997,12 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it
return -EIO;
}
devpriv->pdev = pdev;
- // enable PCI device and reserve I/O spaces
+ /* enable PCI device and reserve I/O spaces */
if (comedi_pci_enable(pdev, DRV_NAME)) {
printk(" Error enabling PCI device and requesting regions\n");
return -EIO;
}
- // read base addresses
+ /* read base addresses */
pci_iobase = pci_resource_start(pdev, 1);
iobase = pci_resource_start(pdev, 2);
printk("pcibase 0x%lx iobase 0x%lx\n", pci_iobase, iobase);
@@ -1028,14 +1030,14 @@ static int das08_attach(struct comedi_device * dev, struct comedi_devconfig * it
return das08_common_attach(dev, iobase);
}
-int das08_common_detach(struct comedi_device * dev)
+int das08_common_detach(struct comedi_device *dev)
{
printk(KERN_INFO "comedi%d: das08: remove\n", dev->minor);
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 4);
- // deallocate ioports for non-pcmcia, non-pci boards
+ /* deallocate ioports for non-pcmcia, non-pci boards */
if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) {
if (dev->iobase)
release_region(dev->iobase, thisboard->iosize);
diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h
index 69089ce690f2..7cdb3fc4daee 100644
--- a/drivers/staging/comedi/drivers/das08.h
+++ b/drivers/staging/comedi/drivers/das08.h
@@ -25,14 +25,14 @@
#define _DAS08_H
enum das08_bustype { isa, pci, pcmcia, pc104 };
-// different ways ai data is encoded in first two registers
+/* different ways ai data is encoded in first two registers */
enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 };
enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl,
das08_pgm };
struct das08_board_struct {
const char *name;
- unsigned int id; // id for pci/pcmcia boards
+ unsigned int id; /* id for pci/pcmcia boards */
enum das08_bustype bustype;
void *ai;
unsigned int ai_nbits;
@@ -45,13 +45,13 @@ struct das08_board_struct {
unsigned int do_nchan;
unsigned int i8255_offset;
unsigned int i8254_offset;
- unsigned int iosize; // number of ioports used
+ unsigned int iosize; /* number of ioports used */
};
struct i8254_struct {
- int channels; // available channels. Some could be used internally.
- int logic2phys[3]; // to know which physical channel is.
- int mode[3]; // the index is the real counter.
+ int channels; /* available channels. Some could be used internally. */
+ int logic2phys[3]; /* to know which physical channel is. */
+ int mode[3]; /* the index is the real counter. */
unsigned int iobase;
};
@@ -61,18 +61,18 @@ struct i8254_struct {
#define I8254_CTRL 3
struct das08_private_struct {
- unsigned int do_mux_bits; // bits for do/mux register on boards without seperate do register
- unsigned int do_bits; // bits for do register on boards with register dedicated to digital out only
+ unsigned int do_mux_bits; /* bits for do/mux register on boards without seperate do register */
+ unsigned int do_bits; /* bits for do register on boards with register dedicated to digital out only */
const unsigned int *pg_gainlist;
- struct pci_dev *pdev; // struct for pci-das08
- unsigned int pci_iobase; // additional base address for pci-das08
+ struct pci_dev *pdev; /* struct for pci-das08 */
+ unsigned int pci_iobase; /* additional base address for pci-das08 */
struct i8254_struct i8254;
};
#define NUM_DAS08_CS_BOARDS 2
extern struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS];
-int das08_common_attach(struct comedi_device * dev, unsigned long iobase);
-int das08_common_detach(struct comedi_device * dev);
+int das08_common_attach(struct comedi_device *dev, unsigned long iobase);
+int das08_common_detach(struct comedi_device *dev);
#endif /* _DAS08_H */
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c
index be6c88788c4b..8e4464100e1e 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/staging/comedi/drivers/das08_cs.c
@@ -46,7 +46,7 @@ Command support does not exist, but could be added for this board.
#include "das08.h"
-// pcmcia includes
+/* pcmcia includes */
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
@@ -56,30 +56,31 @@ static struct pcmcia_device *cur_dev = NULL;
#define thisboard ((const struct das08_board_struct *)dev->board_ptr)
-static int das08_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it);
+static int das08_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static struct comedi_driver driver_das08_cs = {
- driver_name:"das08_cs",
- module:THIS_MODULE,
- attach:das08_cs_attach,
- detach:das08_common_detach,
- board_name:&das08_cs_boards[0].name,
- num_names:sizeof(das08_cs_boards) /
+ .driver_name = "das08_cs",
+ .module = THIS_MODULE,
+ .attach = das08_cs_attach,
+ .detach = das08_common_detach,
+ .board_name = &das08_cs_boards[0].name,
+ .num_names = sizeof(das08_cs_boards) /
sizeof(struct das08_board_struct),
- offset:sizeof(struct das08_board_struct),
+ .offset = sizeof(struct das08_board_struct),
};
-static int das08_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das08_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
- struct pcmcia_device *link = cur_dev; // XXX hack
+ struct pcmcia_device *link = cur_dev; /* XXX hack */
- if ((ret = alloc_private(dev, sizeof(struct das08_private_struct))) < 0)
+ ret = alloc_private(dev, sizeof(struct das08_private_struct));
+ if (ret < 0)
return ret;
printk("comedi%d: das08_cs: ", dev->minor);
- // deal with a pci board
+ /* deal with a pci board */
if (thisboard->bustype == pcmcia) {
if (link == NULL) {
@@ -264,14 +265,23 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
last_fn = GetFirstTuple;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret)
goto cs_failed;
+
last_fn = GetTupleData;
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret)
goto cs_failed;
+
last_fn = ParseTuple;
- if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0)
+
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret)
goto cs_failed;
+
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
@@ -289,13 +299,20 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
last_fn = GetFirstTuple;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret)
goto cs_failed;
+
while (1) {
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret)
goto next_entry;
- if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0)
+
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret)
goto next_entry;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
@@ -341,13 +358,16 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
next_entry:
last_fn = GetNextTuple;
- if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0)
+
+ last_ret = pcmcia_get_next_tuple(link, &tuple);
+ if (last_ret)
goto cs_failed;
}
if (link->conf.Attributes & CONF_ENABLE_IRQ) {
last_fn = RequestIRQ;
- if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0)
+ last_ret = pcmcia_request_irq(link, &link->irq);
+ if (last_ret)
goto cs_failed;
}
@@ -357,7 +377,8 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
card and host interface into "Memory and IO" mode.
*/
last_fn = RequestConfiguration;
- if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0)
+ last_ret = pcmcia_request_configuration(link, &link->conf);
+ if (last_ret)
goto cs_failed;
/*
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 6b6b042099de..59af86a8bbfb 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -79,6 +79,7 @@ Computer boards manuals also available from their website www.measurementcomputi
*/
#include <linux/pci.h>
+#include <linux/interrupt.h>
#include <asm/dma.h>
#include "../comedidev.h"
@@ -87,16 +88,16 @@ Computer boards manuals also available from their website www.measurementcomputi
#include "comedi_fc.h"
#undef DEBUG
-//#define DEBUG
+/* #define DEBUG */
#ifdef DEBUG
-#define DEBUG_PRINT(format, args...) rt_printk("das16: " format, ## args)
+#define DEBUG_PRINT(format, args...) printk("das16: " format, ## args)
#else
#define DEBUG_PRINT(format, args...)
#endif
-#define DAS16_SIZE 20 // number of ioports
-#define DAS16_DMA_SIZE 0xff00 // size in bytes of allocated dma buffer
+#define DAS16_SIZE 20 /* number of ioports */
+#define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */
/*
cio-das16.pdf
@@ -184,7 +185,7 @@ Computer boards manuals also available from their website www.measurementcomputi
*/
-static const int sample_size = 2; // size in bytes of a sample from board
+static const int sample_size = 2; /* size in bytes of a sample from board */
#define DAS16_TRIG 0
#define DAS16_AI_LSB 0
@@ -265,7 +266,7 @@ static const struct comedi_lrange range_das1x02_unip = { 4, {
}
};
static const struct comedi_lrange range_das16jr = { 9, {
- // also used by 16/330
+ /* also used by 16/330 */
BIP_RANGE(10),
BIP_RANGE(5),
BIP_RANGE(2.5),
@@ -326,40 +327,40 @@ struct munge_info {
unsigned have_byte:1;
};
-static int das16_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-
-static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s);
-static int das16_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void das16_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+
+static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s);
+static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void das16_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *array, unsigned int num_bytes, unsigned int start_chan_index);
-static void das16_reset(struct comedi_device * dev);
-static irqreturn_t das16_dma_interrupt(int irq, void *d PT_REGS_ARG);
+static void das16_reset(struct comedi_device *dev);
+static irqreturn_t das16_dma_interrupt(int irq, void *d);
static void das16_timer_interrupt(unsigned long arg);
-static void das16_interrupt(struct comedi_device * dev);
+static void das16_interrupt(struct comedi_device *dev);
-static unsigned int das16_set_pacer(struct comedi_device * dev, unsigned int ns,
+static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
int flags);
-static int das1600_mode_detect(struct comedi_device * dev);
-static unsigned int das16_suggest_transfer_size(struct comedi_device * dev,
+static int das1600_mode_detect(struct comedi_device *dev);
+static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
struct comedi_cmd cmd);
-static void reg_dump(struct comedi_device * dev);
+static void reg_dump(struct comedi_device *dev);
struct das16_board {
const char *name;
void *ai;
unsigned int ai_nbits;
- unsigned int ai_speed; // max conversion speed in nanosec
+ unsigned int ai_speed; /* max conversion speed in nanosec */
unsigned int ai_pg;
void *ao;
unsigned int ao_nbits;
@@ -375,339 +376,337 @@ struct das16_board {
static const struct das16_board das16_boards[] = {
{
- name: "das-16",
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:15000,
- ai_pg: das16_pg_none,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x10,
- i8254_offset:0x0c,
- size: 0x14,
- id: 0x00,
+ .name = "das-16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 15000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x00,
},
{
- name: "das-16g",
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:15000,
- ai_pg: das16_pg_none,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x10,
- i8254_offset:0x0c,
- size: 0x14,
- id: 0x00,
+ .name = "das-16g",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 15000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x00,
},
{
- name: "das-16f",
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:8500,
- ai_pg: das16_pg_none,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x10,
- i8254_offset:0x0c,
- size: 0x14,
- id: 0x00,
+ .name = "das-16f",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 8500,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x00,
},
{
- name: "cio-das16", // cio-das16.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:20000,
- ai_pg: das16_pg_none,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x10,
- i8254_offset:0x0c,
- size: 0x14,
- id: 0x80,
+ .name = "cio-das16", /* cio-das16.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 20000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x80,
},
{
- name: "cio-das16/f", // das16.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_none,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x10,
- i8254_offset:0x0c,
- size: 0x14,
- id: 0x80,
+ .name = "cio-das16/f", /* das16.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x80,
},
{
- name: "cio-das16/jr", // cio-das16jr.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:7692,
- ai_pg: das16_pg_16jr,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x10,
- id: 0x00,
+ .name = "cio-das16/jr", /* cio-das16jr.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 7692,
+ .ai_pg = das16_pg_16jr,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
},
{
- name: "pc104-das16jr", // pc104-das16jr_xx.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:3300,
- ai_pg: das16_pg_16jr,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x10,
- id: 0x00,
+ .name = "pc104-das16jr", /* pc104-das16jr_xx.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 3300,
+ .ai_pg = das16_pg_16jr,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
},
{
- name: "cio-das16jr/16", // cio-das16jr_16.pdf
- ai: das16_ai_rinsn,
- ai_nbits:16,
- ai_speed:10000,
- ai_pg: das16_pg_16jr_16,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x10,
- id: 0x00,
+ .name = "cio-das16jr/16", /* cio-das16jr_16.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_16jr_16,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
},
{
- name: "pc104-das16jr/16", // pc104-das16jr_xx.pdf
- ai: das16_ai_rinsn,
- ai_nbits:16,
- ai_speed:10000,
- ai_pg: das16_pg_16jr_16,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x10,
- id: 0x00,
+ .name = "pc104-das16jr/16", /* pc104-das16jr_xx.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_16jr_16,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
},
{
- name: "das-1201", // 4924.pdf (keithley user's manual)
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:20000,
- ai_pg: das16_pg_none,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0x20,
+ .name = "das-1201", /* 4924.pdf (keithley user's manual) */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 20000,
+ .ai_pg = das16_pg_none,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0x20,
},
{
- name: "das-1202", // 4924.pdf (keithley user's manual)
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_none,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0x20,
+ .name = "das-1202", /* 4924.pdf (keithley user's manual) */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_none,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0x20,
},
{
- name: "das-1401", // 4919.pdf and 4922.pdf (keithley user's manual)
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_1601,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x0,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0 // 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0
+ .name = "das-1401", /* 4919.pdf and 4922.pdf (keithley user's manual) */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1601,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */
},
{
- name: "das-1402", // 4919.pdf and 4922.pdf (keithley user's manual)
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_1602,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x0,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0 // 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0
+ .name = "das-1402", /* 4919.pdf and 4922.pdf (keithley user's manual) */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */
},
{
- name: "das-1601", // 4919.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_1601,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "das-1601", /* 4919.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1601,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "das-1602", // 4919.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_1602,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "das-1602", /* 4919.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das1401/12", // cio-das1400_series.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:6250,
- ai_pg: das16_pg_1601,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "cio-das1401/12", /* cio-das1400_series.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 6250,
+ .ai_pg = das16_pg_1601,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das1402/12", // cio-das1400_series.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:6250,
- ai_pg: das16_pg_1602,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "cio-das1402/12", /* cio-das1400_series.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 6250,
+ .ai_pg = das16_pg_1602,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das1402/16", // cio-das1400_series.pdf
- ai: das16_ai_rinsn,
- ai_nbits:16,
- ai_speed:10000,
- ai_pg: das16_pg_1602,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "cio-das1402/16", /* cio-das1400_series.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das1601/12", // cio-das160x-1x.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:6250,
- ai_pg: das16_pg_1601,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "cio-das1601/12", /* cio-das160x-1x.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 6250,
+ .ai_pg = das16_pg_1601,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das1602/12", // cio-das160x-1x.pdf
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:10000,
- ai_pg: das16_pg_1602,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "cio-das1602/12", /* cio-das160x-1x.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das1602/16", // cio-das160x-1x.pdf
- ai: das16_ai_rinsn,
- ai_nbits:16,
- ai_speed:10000,
- ai_pg: das16_pg_1602,
- ao: das16_ao_winsn,
- ao_nbits:12,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0x400,
- i8254_offset:0x0c,
- size: 0x408,
- id: 0xc0},
+ .name = "cio-das1602/16", /* cio-das160x-1x.pdf */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0},
{
- name: "cio-das16/330", // ?
- ai: das16_ai_rinsn,
- ai_nbits:12,
- ai_speed:3030,
- ai_pg: das16_pg_16jr,
- ao: NULL,
- di: das16_di_rbits,
- do_: das16_do_wbits,
- i8255_offset:0,
- i8254_offset:0x0c,
- size: 0x14,
- id: 0xf0},
+ .name = "cio-das16/330", /* ? */
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 3030,
+ .ai_pg = das16_pg_16jr,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0xf0},
#if 0
{
- name: "das16/330i", // ?
+ .name = "das16/330i", /* ? */
},
{
- name: "das16/jr/ctr5", // ?
+ .name = "das16/jr/ctr5", /* ? */
},
{
- name: "cio-das16/m1/16", // cio-das16_m1_16.pdf, this board is a bit quirky, no dma
+ .name = "cio-das16/m1/16", /* cio-das16_m1_16.pdf, this board is a bit quirky, no dma */
},
#endif
};
-#define n_das16_boards ((sizeof(das16_boards))/(sizeof(struct das16_board)))
-
-static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int das16_detach(struct comedi_device * dev);
+static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das16_detach(struct comedi_device *dev);
static struct comedi_driver driver_das16 = {
- driver_name:"das16",
- module:THIS_MODULE,
- attach:das16_attach,
- detach:das16_detach,
- board_name:&das16_boards[0].name,
- num_names:n_das16_boards,
- offset:sizeof(das16_boards[0]),
+ .driver_name = "das16",
+ .module = THIS_MODULE,
+ .attach = das16_attach,
+ .detach = das16_detach,
+ .board_name = &das16_boards[0].name,
+ .num_names = ARRAY_SIZE(das16_boards),
+ .offset = sizeof(das16_boards[0]),
};
#define DAS16_TIMEOUT 1000
@@ -719,31 +718,31 @@ static inline int timer_period(void)
return HZ / 20;
}
struct das16_private_struct {
- unsigned int ai_unipolar; // unipolar flag
- unsigned int ai_singleended; // single ended flag
- unsigned int clockbase; // master clock speed in ns
- volatile unsigned int control_state; // dma, interrupt and trigger control bits
- volatile unsigned long adc_byte_count; // number of bytes remaining
- unsigned int divisor1; // divisor dividing master clock to get conversion frequency
- unsigned int divisor2; // divisor dividing master clock to get conversion frequency
- unsigned int dma_chan; // dma channel
+ unsigned int ai_unipolar; /* unipolar flag */
+ unsigned int ai_singleended; /* single ended flag */
+ unsigned int clockbase; /* master clock speed in ns */
+ volatile unsigned int control_state; /* dma, interrupt and trigger control bits */
+ volatile unsigned long adc_byte_count; /* number of bytes remaining */
+ unsigned int divisor1; /* divisor dividing master clock to get conversion frequency */
+ unsigned int divisor2; /* divisor dividing master clock to get conversion frequency */
+ unsigned int dma_chan; /* dma channel */
uint16_t *dma_buffer[2];
dma_addr_t dma_buffer_addr[2];
unsigned int current_buffer;
- volatile unsigned int dma_transfer_size; // target number of bytes to transfer per dma shot
- // user-defined analog input and output ranges defined from config options
+ volatile unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */
+ /* user-defined analog input and output ranges defined from config options */
struct comedi_lrange *user_ai_range_table;
struct comedi_lrange *user_ao_range_table;
- struct timer_list timer; // for timed interrupt
+ struct timer_list timer; /* for timed interrupt */
volatile short timer_running;
- volatile short timer_mode; // true if using timer mode
+ volatile short timer_mode; /* true if using timer mode */
};
#define devpriv ((struct das16_private_struct *)(dev->private))
#define thisboard ((struct das16_board *)(dev->board_ptr))
-static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0, tmp;
int gain, start_chan, i;
@@ -757,7 +756,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
tmp = cmd->scan_begin_src;
mask = TRIG_FOLLOW;
- // if board supports burst mode
+ /* if board supports burst mode */
if (thisboard->size > 0x400)
mask |= TRIG_TIMER | TRIG_EXT;
cmd->scan_begin_src &= mask;
@@ -766,7 +765,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
tmp = cmd->convert_src;
mask = TRIG_TIMER | TRIG_EXT;
- // if board supports burst mode
+ /* if board supports burst mode */
if (thisboard->size > 0x400)
mask |= TRIG_NOW;
cmd->convert_src &= mask;
@@ -797,7 +796,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT)
err++;
- // make sure scan_begin_src and convert_src dont conflict
+ /* make sure scan_begin_src and convert_src dont conflict */
if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW)
@@ -824,7 +823,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
cmd->scan_end_arg = cmd->chanlist_len;
err++;
}
- // check against maximum frequency
+ /* check against maximum frequency */
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->scan_begin_arg <
thisboard->ai_speed * cmd->chanlist_len) {
@@ -849,10 +848,10 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
if (err)
return 3;
- // step 4: fix up arguments
+ /* step 4: fix up arguments */
if (cmd->scan_begin_src == TRIG_TIMER) {
unsigned int tmp = cmd->scan_begin_arg;
- // set divisors, correct timing arguments
+ /* set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&(devpriv->divisor1), &(devpriv->divisor2),
&(cmd->scan_begin_arg), cmd->flags & TRIG_ROUND_MASK);
@@ -860,7 +859,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
}
if (cmd->convert_src == TRIG_TIMER) {
unsigned int tmp = cmd->convert_arg;
- // set divisors, correct timing arguments
+ /* set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&(devpriv->divisor1), &(devpriv->divisor2),
&(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
@@ -869,7 +868,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
if (err)
return 4;
- // check channel/gain list against card's limitations
+ /* check channel/gain list against card's limitations */
if (cmd->chanlist) {
gain = CR_RANGE(cmd->chanlist[0]);
start_chan = CR_CHAN(cmd->chanlist[0]);
@@ -893,7 +892,7 @@ static int das16_cmd_test(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -916,11 +915,11 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice *
devpriv->adc_byte_count =
cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
- // disable conversions for das1600 mode
+ /* disable conversions for das1600 mode */
if (thisboard->size > 0x400) {
outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV);
}
- // set scan limits
+ /* set scan limits */
byte = CR_CHAN(cmd->chanlist[0]);
byte |= CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]) << 4;
outb(byte, dev->iobase + DAS16_MUX);
@@ -945,7 +944,7 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice *
if (thisboard->size > 0x400) {
if (cmd->convert_src == TRIG_NOW) {
outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST);
- // set burst length
+ /* set burst length */
byte |= BURST_LEN_BITS(cmd->chanlist_len - 1);
} else {
outb(0, dev->iobase + DAS1600_BURST);
@@ -953,7 +952,7 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice *
}
outb(byte, dev->iobase + DAS16_PACER);
- // set up dma transfer
+ /* set up dma transfer */
flags = claim_dma_lock();
disable_dma(devpriv->dma_chan);
/* clear flip-flop to make sure 2-byte registers for
@@ -962,13 +961,13 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice *
devpriv->current_buffer = 0;
set_dma_addr(devpriv->dma_chan,
devpriv->dma_buffer_addr[devpriv->current_buffer]);
- // set appropriate size of transfer
+ /* set appropriate size of transfer */
devpriv->dma_transfer_size = das16_suggest_transfer_size(dev, *cmd);
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
release_dma_lock(flags);
- // set up interrupt
+ /* set up interrupt */
if (devpriv->timer_mode) {
devpriv->timer_running = 1;
devpriv->timer.expires = jiffies + timer_period();
@@ -996,18 +995,18 @@ static int das16_cmd_exec(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int das16_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
/* disable interrupts, dma and pacer clocked conversions */
devpriv->control_state &= ~DAS16_INTE & ~PACING_MASK & ~DMA_ENABLE;
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
if (devpriv->dma_chan)
disable_dma(devpriv->dma_chan);
- // disable SW timer
+ /* disable SW timer */
if (devpriv->timer_mode && devpriv->timer_running) {
devpriv->timer_running = 0;
del_timer(&devpriv->timer);
@@ -1018,12 +1017,12 @@ static int das16_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
outb(0, dev->iobase + DAS1600_BURST);
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
-static void das16_reset(struct comedi_device * dev)
+static void das16_reset(struct comedi_device *dev)
{
outb(0, dev->iobase + DAS16_STATUS);
outb(0, dev->iobase + DAS16_CONTROL);
@@ -1031,15 +1030,15 @@ static void das16_reset(struct comedi_device * dev)
outb(0, dev->iobase + DAS16_CNTR_CONTROL);
}
-static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int range;
int chan;
int msb, lsb;
- // disable interrupts and pacing
+ /* disable interrupts and pacing */
devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK;
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
@@ -1064,7 +1063,7 @@ static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
break;
}
if (i == DAS16_TIMEOUT) {
- rt_printk("das16: timeout\n");
+ printk("das16: timeout\n");
return -ETIME;
}
msb = inb(dev->iobase + DAS16_AI_MSB);
@@ -1079,8 +1078,8 @@ static int das16_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static int das16_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -1091,17 +1090,17 @@ static int das16_di_rbits(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int das16_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int wbits;
- // only set bits that have been masked
+ /* only set bits that have been masked */
data[0] &= 0xf;
wbits = s->state;
- // zero bits that have been masked
+ /* zero bits that have been masked */
wbits &= ~data[0];
- // set masked bits
+ /* set masked bits */
wbits |= data[0] & data[1];
s->state = wbits;
data[1] = wbits;
@@ -1111,8 +1110,8 @@ static int das16_do_wbits(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int das16_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int lsb, msb;
@@ -1135,7 +1134,7 @@ static int das16_ao_winsn(struct comedi_device * dev, struct comedi_subdevice *
return i;
}
-static irqreturn_t das16_dma_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t das16_dma_interrupt(int irq, void *d)
{
int status;
struct comedi_device *dev = d;
@@ -1169,7 +1168,7 @@ static void das16_timer_interrupt(unsigned long arg)
an even transfer count after disabling dma
channel.
*/
-static int disable_dma_on_even(struct comedi_device * dev)
+static int disable_dma_on_even(struct comedi_device *dev)
{
int residue;
int i;
@@ -1182,7 +1181,7 @@ static int disable_dma_on_even(struct comedi_device * dev)
enable_dma(devpriv->dma_chan);
for (j = 0; j < enable_timeout; ++j) {
int new_residue;
- comedi_udelay(2);
+ udelay(2);
new_residue = get_dma_residue(devpriv->dma_chan);
if (new_residue != residue)
break;
@@ -1197,7 +1196,7 @@ static int disable_dma_on_even(struct comedi_device * dev)
return residue;
}
-static void das16_interrupt(struct comedi_device * dev)
+static void das16_interrupt(struct comedi_device *dev)
{
unsigned long dma_flags, spin_flags;
struct comedi_subdevice *s = dev->read_subdev;
@@ -1210,7 +1209,7 @@ static void das16_interrupt(struct comedi_device * dev)
comedi_error(dev, "premature interrupt");
return;
}
- // initialize async here to make sure it is not NULL
+ /* initialize async here to make sure it is not NULL */
async = s->async;
cmd = &async->cmd;
@@ -1219,9 +1218,9 @@ static void das16_interrupt(struct comedi_device * dev)
return;
}
- comedi_spin_lock_irqsave(&dev->spinlock, spin_flags);
+ spin_lock_irqsave(&dev->spinlock, spin_flags);
if ((devpriv->control_state & DMA_ENABLE) == 0) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, spin_flags);
+ spin_unlock_irqrestore(&dev->spinlock, spin_flags);
DEBUG_PRINT("interrupt while dma disabled?\n");
return;
}
@@ -1230,7 +1229,7 @@ static void das16_interrupt(struct comedi_device * dev)
clear_dma_ff(devpriv->dma_chan);
residue = disable_dma_on_even(dev);
- // figure out how many points to read
+ /* figure out how many points to read */
if (residue > devpriv->dma_transfer_size) {
comedi_error(dev, "residue > transfer size!\n");
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
@@ -1247,12 +1246,12 @@ static void das16_interrupt(struct comedi_device * dev)
devpriv->current_buffer = (devpriv->current_buffer + 1) % 2;
devpriv->adc_byte_count -= num_bytes;
- // figure out how many bytes for next transfer
+ /* figure out how many bytes for next transfer */
if (cmd->stop_src == TRIG_COUNT && devpriv->timer_mode == 0 &&
devpriv->dma_transfer_size > devpriv->adc_byte_count)
devpriv->dma_transfer_size = devpriv->adc_byte_count;
- // re-enable dma
+ /* re-enable dma */
if ((async->events & COMEDI_CB_EOA) == 0) {
set_dma_addr(devpriv->dma_chan,
devpriv->dma_buffer_addr[devpriv->current_buffer]);
@@ -1265,7 +1264,7 @@ static void das16_interrupt(struct comedi_device * dev)
}
release_dma_lock(dma_flags);
- comedi_spin_unlock_irqrestore(&dev->spinlock, spin_flags);
+ spin_unlock_irqrestore(&dev->spinlock, spin_flags);
cfc_write_array_to_buffer(s,
devpriv->dma_buffer[buffer_index], num_bytes);
@@ -1273,7 +1272,7 @@ static void das16_interrupt(struct comedi_device * dev)
cfc_handle_events(dev, s);
}
-static unsigned int das16_set_pacer(struct comedi_device * dev, unsigned int ns,
+static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
int rounding_flags)
{
i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1),
@@ -1286,7 +1285,7 @@ static unsigned int das16_set_pacer(struct comedi_device * dev, unsigned int ns,
return ns;
}
-static void reg_dump(struct comedi_device * dev)
+static void reg_dump(struct comedi_device *dev)
{
DEBUG_PRINT("********DAS1600 REGISTER DUMP********\n");
DEBUG_PRINT("DAS16_MUX: %x\n", inb(dev->iobase + DAS16_MUX));
@@ -1304,7 +1303,7 @@ static void reg_dump(struct comedi_device * dev)
inb(dev->iobase + DAS1600_STATUS_B));
}
-static int das16_probe(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
{
int status;
int diobits;
@@ -1338,7 +1337,7 @@ static int das16_probe(struct comedi_device * dev, struct comedi_devconfig * it)
return 0;
}
-static int das1600_mode_detect(struct comedi_device * dev)
+static int das1600_mode_detect(struct comedi_device *dev)
{
int status = 0;
@@ -1366,7 +1365,7 @@ static int das1600_mode_detect(struct comedi_device * dev)
* 3 Clock speed (in MHz)
*/
-static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret;
@@ -1391,7 +1390,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
printk("comedi%d: das16:", dev->minor);
- // check that clock setting is valid
+ /* check that clock setting is valid */
if (it->options[3]) {
if (it->options[3] != 0 &&
it->options[3] != 1 && it->options[3] != 10) {
@@ -1400,7 +1399,8 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
}
}
- if ((ret = alloc_private(dev, sizeof(struct das16_private_struct))) < 0)
+ ret = alloc_private(dev, sizeof(struct das16_private_struct));
+ if (ret < 0)
return ret;
if (thisboard->size < 0x400) {
@@ -1431,27 +1431,28 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
dev->iobase = iobase;
- // probe id bits to make sure they are consistent
+ /* probe id bits to make sure they are consistent */
if (das16_probe(dev, it)) {
printk(" id bits do not match selected board, aborting\n");
return -EINVAL;
}
dev->board_name = thisboard->name;
- // get master clock speed
+ /* get master clock speed */
if (thisboard->size < 0x400) {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
else
- devpriv->clockbase = 1000; // 1 MHz default
+ devpriv->clockbase = 1000; /* 1 MHz default */
} else {
das1600_mode_detect(dev);
}
/* now for the irq */
if (irq > 1 && irq < 8) {
- if ((ret = comedi_request_irq(irq, das16_dma_interrupt, 0,
- "das16", dev)) < 0)
+ ret = request_irq(irq, das16_dma_interrupt, 0, "das16", dev);
+
+ if (ret < 0)
return ret;
dev->irq = irq;
printk(" ( irq = %u )", irq);
@@ -1462,10 +1463,10 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
return -EINVAL;
}
- // initialize dma
+ /* initialize dma */
dma_chan = it->options[2];
if (dma_chan == 1 || dma_chan == 3) {
- // allocate dma buffers
+ /* allocate dma buffers */
int i;
for (i = 0; i < 2; i++) {
devpriv->dma_buffer[i] = pci_alloc_consistent(NULL,
@@ -1491,27 +1492,27 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
return -EINVAL;
}
- // get any user-defined input range
+ /* get any user-defined input range */
if (thisboard->ai_pg == das16_pg_none &&
(it->options[4] || it->options[5])) {
- // allocate single-range range table
+ /* allocate single-range range table */
devpriv->user_ai_range_table =
kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange),
GFP_KERNEL);
- // initialize ai range
+ /* initialize ai range */
devpriv->user_ai_range_table->length = 1;
user_ai_range = devpriv->user_ai_range_table->range;
user_ai_range->min = it->options[4];
user_ai_range->max = it->options[5];
user_ai_range->flags = UNIT_volt;
}
- // get any user-defined output range
+ /* get any user-defined output range */
if (it->options[6] || it->options[7]) {
- // allocate single-range range table
+ /* allocate single-range range table */
devpriv->user_ao_range_table =
kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange),
GFP_KERNEL);
- // initialize ao range
+ /* initialize ao range */
devpriv->user_ao_range_table->length = 1;
user_ao_range = devpriv->user_ao_range_table->range;
user_ao_range->min = it->options[6];
@@ -1526,7 +1527,8 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
}
devpriv->timer_mode = timer_mode ? 1 : 0;
- if ((ret = alloc_subdevices(dev, 5)) < 0)
+ ret = alloc_subdevices(dev, 5);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -1545,7 +1547,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
s->subdev_flags |= SDF_DIFF;
}
s->maxdata = (1 << thisboard->ai_nbits) - 1;
- if (devpriv->user_ai_range_table) { // user defined ai range
+ if (devpriv->user_ai_range_table) { /* user defined ai range */
s->range_table = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
s->range_table = das16_ai_uni_lranges[thisboard->ai_pg];
@@ -1568,7 +1570,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
s->maxdata = (1 << thisboard->ao_nbits) - 1;
- if (devpriv->user_ao_range_table) { // user defined ao range
+ if (devpriv->user_ao_range_table) { /* user defined ao range */
s->range_table = devpriv->user_ao_range_table;
} else {
s->range_table = &range_unknown;
@@ -1600,7 +1602,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = thisboard->do_;
- // initialize digital output lines
+ /* initialize digital output lines */
outb(s->state, dev->iobase + DAS16_DIO);
} else {
s->type = COMEDI_SUBD_UNUSED;
@@ -1620,7 +1622,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
devpriv->control_state = DAS16_IRQ(dev->irq);
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
- // turn on das1600 mode if available
+ /* turn on das1600 mode if available */
if (thisboard->size > 0x400) {
outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE);
outb(0, dev->iobase + DAS1600_CONV);
@@ -1630,7 +1632,7 @@ static int das16_attach(struct comedi_device * dev, struct comedi_devconfig * it
return 0;
}
-static int das16_detach(struct comedi_device * dev)
+static int das16_detach(struct comedi_device *dev)
{
printk("comedi%d: das16: remove\n", dev->minor);
@@ -1656,7 +1658,7 @@ static int das16_detach(struct comedi_device * dev)
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->iobase) {
if (thisboard->size < 0x400) {
@@ -1673,8 +1675,8 @@ static int das16_detach(struct comedi_device * dev)
COMEDI_INITCLEANUP(driver_das16);
-// utility function that suggests a dma transfer size in bytes
-static unsigned int das16_suggest_transfer_size(struct comedi_device * dev,
+/* utility function that suggests a dma transfer size in bytes */
+static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
struct comedi_cmd cmd)
{
unsigned int size;
@@ -1692,18 +1694,18 @@ static unsigned int das16_suggest_transfer_size(struct comedi_device * dev,
freq = 1000000000 / cmd.convert_arg;
else if (cmd.scan_begin_src == TRIG_TIMER)
freq = (1000000000 / cmd.scan_begin_arg) * cmd.chanlist_len;
- // return some default value
+ /* return some default value */
else
freq = 0xffffffff;
if (cmd.flags & TRIG_WAKE_EOS) {
size = sample_size * cmd.chanlist_len;
} else {
- // make buffer fill in no more than 1/3 second
+ /* make buffer fill in no more than 1/3 second */
size = (freq / 3) * sample_size;
}
- // set a minimum and maximum size allowed
+ /* set a minimum and maximum size allowed */
if (size > DAS16_DMA_SIZE)
size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size;
else if (size < sample_size)
@@ -1715,7 +1717,7 @@ static unsigned int das16_suggest_transfer_size(struct comedi_device * dev,
return size;
}
-static void das16_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static void das16_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *array, unsigned int num_bytes, unsigned int start_chan_index)
{
unsigned int i, num_samples = num_bytes / sizeof(short);
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 0e423e199ed6..3da8bf47cbf6 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -59,6 +59,7 @@ irq can be omitted, although the cmd interface will not work without it.
*/
#include <linux/ioport.h>
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "8255.h"
@@ -68,9 +69,9 @@ irq can be omitted, although the cmd interface will not work without it.
#define DAS16M1_SIZE 16
#define DAS16M1_SIZE2 8
-#define DAS16M1_XTAL 100 //10 MHz master clock
+#define DAS16M1_XTAL 100 /* 10 MHz master clock */
-#define FIFO_SIZE 1024 // 1024 sample fifo
+#define FIFO_SIZE 1024 /* 1024 sample fifo */
/*
CIO-DAS16_M1.pdf
@@ -92,7 +93,7 @@ irq can be omitted, although the cmd interface will not work without it.
*/
-#define DAS16M1_AI 0 // 16-bit wide register
+#define DAS16M1_AI 0 /* 16-bit wide register */
#define AI_CHAN(x) ((x) & 0xf)
#define DAS16M1_CS 2
#define EXT_TRIG_BIT 0x1
@@ -131,23 +132,23 @@ static const struct comedi_lrange range_das16m1 = { 9,
}
};
-static int das16m1_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16m1_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das16m1_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int das16m1_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s);
-static int das16m1_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s);
+static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int das16m1_poll(struct comedi_device * dev, struct comedi_subdevice * s);
-static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG);
-static void das16m1_handler(struct comedi_device * dev, unsigned int status);
+static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s);
+static irqreturn_t das16m1_interrupt(int irq, void *d);
+static void das16m1_handler(struct comedi_device *dev, unsigned int status);
-static unsigned int das16m1_set_pacer(struct comedi_device * dev, unsigned int ns,
+static unsigned int das16m1_set_pacer(struct comedi_device *dev, unsigned int ns,
int round_flag);
static int das16m1_irq_bits(unsigned int irq);
@@ -159,36 +160,34 @@ struct das16m1_board {
static const struct das16m1_board das16m1_boards[] = {
{
- name: "cio-das16/m1", // CIO-DAS16_M1.pdf
- ai_speed:1000, // 1MHz max speed
+ .name = "cio-das16/m1", /* CIO-DAS16_M1.pdf */
+ .ai_speed = 1000, /* 1MHz max speed */
},
};
-#define das16m1_num_boards ((sizeof(das16m1_boards)) / (sizeof(das16m1_boards[0])))
-
-static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int das16m1_detach(struct comedi_device * dev);
+static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das16m1_detach(struct comedi_device *dev);
static struct comedi_driver driver_das16m1 = {
- driver_name:"das16m1",
- module:THIS_MODULE,
- attach:das16m1_attach,
- detach:das16m1_detach,
- board_name:&das16m1_boards[0].name,
- num_names:das16m1_num_boards,
- offset:sizeof(das16m1_boards[0]),
+ .driver_name = "das16m1",
+ .module = THIS_MODULE,
+ .attach = das16m1_attach,
+ .detach = das16m1_detach,
+ .board_name = &das16m1_boards[0].name,
+ .num_names = ARRAY_SIZE(das16m1_boards),
+ .offset = sizeof(das16m1_boards[0]),
};
struct das16m1_private_struct {
unsigned int control_state;
- volatile unsigned int adc_count; // number of samples completed
+ volatile unsigned int adc_count; /* number of samples completed */
/* initial value in lower half of hardware conversion counter,
* needed to keep track of whether new count has been loaded into
* counter yet (loaded by first sample conversion) */
u16 initial_hw_count;
short ai_buffer[FIFO_SIZE];
- unsigned int do_bits; // saves status of digital output bits
- unsigned int divisor1; // divides master clock to obtain conversion speed
- unsigned int divisor2; // divides master clock to obtain conversion speed
+ unsigned int do_bits; /* saves status of digital output bits */
+ unsigned int divisor1; /* divides master clock to obtain conversion speed */
+ unsigned int divisor2; /* divides master clock to obtain conversion speed */
};
#define devpriv ((struct das16m1_private_struct *)(dev->private))
#define thisboard ((const struct das16m1_board *)(dev->board_ptr))
@@ -200,8 +199,8 @@ static inline short munge_sample(short data)
return (data >> 4) & 0xfff;
}
-static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
unsigned int err = 0, tmp, i;
@@ -299,10 +298,10 @@ static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice
if (err)
return 4;
- // check chanlist against board's peculiarities
+ /* check chanlist against board's peculiarities */
if (cmd->chanlist && cmd->chanlist_len > 1) {
for (i = 0; i < cmd->chanlist_len; i++) {
- // even/odd channels must go into even/odd queue addresses
+ /* even/odd channels must go into even/odd queue addresses */
if ((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2)) {
comedi_error(dev, "bad chanlist:\n"
" even/odd channels must go have even/odd chanlist indices");
@@ -322,7 +321,7 @@ static int das16m1_cmd_test(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -337,7 +336,7 @@ static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice
devpriv->control_state &= ~INTE & ~PACER_MASK;
outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL);
- // set software count
+ /* set software count */
devpriv->adc_count = 0;
/* Initialize lower half of hardware counter, used to determine how
* many samples are in fifo. Value doesn't actually load into counter
@@ -361,7 +360,7 @@ static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice
das16m1_set_pacer(dev, cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
- // set control & status register
+ /* set control & status register */
byte = 0;
/* if we are using external start trigger (also board dislikes having
* both start and conversion triggers external simultaneously) */
@@ -385,7 +384,7 @@ static int das16m1_cmd_exec(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int das16m1_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
devpriv->control_state &= ~INTE & ~PACER_MASK;
outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL);
@@ -393,8 +392,8 @@ static int das16m1_cancel(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int das16m1_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int byte;
@@ -430,8 +429,8 @@ static int das16m1_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice
return n;
}
-static int das16m1_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -442,17 +441,17 @@ static int das16m1_di_rbits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int das16m1_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das16m1_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int wbits;
- // only set bits that have been masked
+ /* only set bits that have been masked */
data[0] &= 0xf;
wbits = devpriv->do_bits;
- // zero bits that have been masked
+ /* zero bits that have been masked */
wbits &= ~data[0];
- // set masked bits
+ /* set masked bits */
wbits |= data[0] & data[1];
devpriv->do_bits = wbits;
data[1] = wbits;
@@ -462,21 +461,21 @@ static int das16m1_do_wbits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int das16m1_poll(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
unsigned int status;
- // prevent race with interrupt handler
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* prevent race with interrupt handler */
+ spin_lock_irqsave(&dev->spinlock, flags);
status = inb(dev->iobase + DAS16M1_CS);
das16m1_handler(dev, status);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return s->async->buf_write_count - s->async->buf_read_count;
}
-static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t das16m1_interrupt(int irq, void *d)
{
int status;
struct comedi_device *dev = d;
@@ -485,7 +484,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG)
comedi_error(dev, "premature interrupt");
return IRQ_HANDLED;
}
- // prevent race with comedi_poll()
+ /* prevent race with comedi_poll() */
spin_lock(&dev->spinlock);
status = inb(dev->iobase + DAS16M1_CS);
@@ -505,7 +504,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static void munge_sample_array(short * array, unsigned int num_elements)
+static void munge_sample_array(short *array, unsigned int num_elements)
{
unsigned int i;
@@ -514,7 +513,7 @@ static void munge_sample_array(short * array, unsigned int num_elements)
}
}
-static void das16m1_handler(struct comedi_device * dev, unsigned int status)
+static void das16m1_handler(struct comedi_device *dev, unsigned int status)
{
struct comedi_subdevice *s;
struct comedi_async *async;
@@ -527,7 +526,7 @@ static void das16m1_handler(struct comedi_device * dev, unsigned int status)
async->events = 0;
cmd = &async->cmd;
- // figure out how many samples are in fifo
+ /* figure out how many samples are in fifo */
hw_counter = i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1);
/* make sure hardware counter reading is not bogus due to initial value
* not having been loaded yet */
@@ -542,12 +541,12 @@ static void das16m1_handler(struct comedi_device * dev, unsigned int status)
* hardware counter. Work it out, and this is what you get. */
num_samples = -hw_counter - devpriv->adc_count;
}
- // check if we only need some of the points
+ /* check if we only need some of the points */
if (cmd->stop_src == TRIG_COUNT) {
if (num_samples > cmd->stop_arg * cmd->chanlist_len)
num_samples = cmd->stop_arg * cmd->chanlist_len;
}
- // make sure we dont try to get too many points if fifo has overrun
+ /* make sure we dont try to get too many points if fifo has overrun */
if (num_samples > FIFO_SIZE)
num_samples = FIFO_SIZE;
insw(dev->iobase, devpriv->ai_buffer, num_samples);
@@ -578,7 +577,7 @@ static void das16m1_handler(struct comedi_device * dev, unsigned int status)
/* This function takes a time in nanoseconds and sets the *
* 2 pacer clocks to the closest frequency possible. It also *
* returns the actual sampling period. */
-static unsigned int das16m1_set_pacer(struct comedi_device * dev, unsigned int ns,
+static unsigned int das16m1_set_pacer(struct comedi_device *dev, unsigned int ns,
int rounding_flags)
{
i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
@@ -626,7 +625,7 @@ static int das16m1_irq_bits(unsigned int irq)
return -1;
break;
}
- return (ret << 4);
+ return ret << 4;
}
/*
@@ -635,7 +634,7 @@ static int das16m1_irq_bits(unsigned int irq)
* 1 IRQ
*/
-static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret;
@@ -646,8 +645,8 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig *
printk("comedi%d: das16m1:", dev->minor);
- if ((ret = alloc_private(dev,
- sizeof(struct das16m1_private_struct))) < 0)
+ ret = alloc_private(dev, sizeof(struct das16m1_private_struct));
+ if (ret < 0)
return ret;
dev->board_name = thisboard->name;
@@ -669,10 +668,10 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig *
/* now for the irq */
irq = it->options[1];
- // make sure it is valid
+ /* make sure it is valid */
if (das16m1_irq_bits(irq) >= 0) {
- ret = comedi_request_irq(irq, das16m1_interrupt, 0,
- driver_das16m1.driver_name, dev);
+ ret = request_irq(irq, das16m1_interrupt, 0,
+ driver_das16m1.driver_name, dev);
if (ret < 0) {
printk(", irq unavailable\n");
return ret;
@@ -687,7 +686,8 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig *
return -EINVAL;
}
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -728,10 +728,10 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig *
/* 8255 */
subdev_8255_init(dev, s, NULL, dev->iobase + DAS16M1_82C55);
- // disable upper half of hardware conversion counter so it doesn't mess with us
+ /* disable upper half of hardware conversion counter so it doesn't mess with us */
outb(TOTAL_CLEAR, dev->iobase + DAS16M1_8254_FIRST_CNTRL);
- // initialize digital output lines
+ /* initialize digital output lines */
outb(devpriv->do_bits, dev->iobase + DAS16M1_DIO);
/* set the interrupt level */
@@ -744,17 +744,17 @@ static int das16m1_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int das16m1_detach(struct comedi_device * dev)
+static int das16m1_detach(struct comedi_device *dev)
{
printk("comedi%d: das16m1: remove\n", dev->minor);
-// das16m1_reset(dev);
+/* das16m1_reset(dev); */
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 3);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->iobase) {
release_region(dev->iobase, DAS16M1_SIZE);
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index cd4cd4e6a79b..a3434088c9e6 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -100,6 +100,7 @@ TODO:
read insn for analog out
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -108,12 +109,12 @@ TODO:
#include "8253.h"
#include "comedi_fc.h"
-// misc. defines
-#define DAS1800_SIZE 16 //uses 16 io addresses
-#define FIFO_SIZE 1024 // 1024 sample fifo
-#define TIMER_BASE 200 // 5 Mhz master clock
-#define UNIPOLAR 0x4 // bit that determines whether input range is uni/bipolar
-#define DMA_BUF_SIZE 0x1ff00 // size in bytes of dma buffers
+/* misc. defines */
+#define DAS1800_SIZE 16 /* uses 16 io addresses */
+#define FIFO_SIZE 1024 /* 1024 sample fifo */
+#define TIMER_BASE 200 /* 5 Mhz master clock */
+#define UNIPOLAR 0x4 /* bit that determines whether input range is uni/bipolar */
+#define DMA_BUF_SIZE 0x1ff00 /* size in bytes of dma buffers */
/* Registers for the das1800 */
#define DAS1800_FIFO 0x0
@@ -138,7 +139,7 @@ TODO:
#define DMA_CH5_CH6 0x5
#define DMA_CH6_CH7 0x6
#define DMA_CH7_CH5 0x7
-#define DMA_ENABLED 0x3 //mask used to determine if dma is enabled
+#define DMA_ENABLED 0x3 /* mask used to determine if dma is enabled */
#define DMA_DUAL 0x4
#define IRQ3 0x8
#define IRQ5 0x10
@@ -156,7 +157,7 @@ TODO:
#define SD 0x40
#define UB 0x80
#define DAS1800_STATUS 0x7
-// bits that prevent interrupt status bits (and CVEN) from being cleared on write
+/* bits that prevent interrupt status bits (and CVEN) from being cleared on write */
#define CLEAR_INTR_MASK (CVEN_MASK | 0x1f)
#define INT 0x1
#define DMATC 0x2
@@ -164,14 +165,14 @@ TODO:
#define OVF 0x10
#define FHF 0x20
#define FNE 0x40
-#define CVEN_MASK 0x40 // masks CVEN on write
+#define CVEN_MASK 0x40 /* masks CVEN on write */
#define CVEN 0x80
#define DAS1800_BURST_LENGTH 0x8
#define DAS1800_BURST_RATE 0x9
#define DAS1800_QRAM_ADDRESS 0xa
#define DAS1800_COUNTER 0xc
-#define IOBASE2 0x400 //offset of additional ioports used on 'ao' cards
+#define IOBASE2 0x400 /* offset of additional ioports used on 'ao' cards */
enum {
das1701st, das1701st_da, das1702st, das1702st_da, das1702hr,
@@ -180,39 +181,39 @@ enum {
das1802hr, das1802hr_da, das1801hc, das1802hc, das1801ao, das1802ao
};
-static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int das1800_detach(struct comedi_device * dev);
-static int das1800_probe(struct comedi_device * dev);
-static int das1800_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static irqreturn_t das1800_interrupt(int irq, void *d PT_REGS_ARG);
-static int das1800_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s);
-static void das1800_ai_handler(struct comedi_device * dev);
-static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevice * s,
+static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das1800_detach(struct comedi_device *dev);
+static int das1800_probe(struct comedi_device *dev);
+static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static irqreturn_t das1800_interrupt(int irq, void *d);
+static int das1800_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s);
+static void das1800_ai_handler(struct comedi_device *dev);
+static void das1800_handle_dma(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int status);
-static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevice * s);
-static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_subdevice * s,
- unsigned int channel, uint16_t * buffer);
-static void das1800_handle_fifo_half_full(struct comedi_device * dev,
- struct comedi_subdevice * s);
-static void das1800_handle_fifo_not_empty(struct comedi_device * dev,
- struct comedi_subdevice * s);
-static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das1800_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das1800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das1800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-
-static int das1800_set_frequency(struct comedi_device * dev);
+static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice *s);
+static void das1800_flush_dma_channel(struct comedi_device *dev, struct comedi_subdevice *s,
+ unsigned int channel, uint16_t *buffer);
+static void das1800_handle_fifo_half_full(struct comedi_device *dev,
+ struct comedi_subdevice *s);
+static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
+ struct comedi_subdevice *s);
+static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int das1800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das1800_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das1800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das1800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+
+static int das1800_set_frequency(struct comedi_device *dev);
static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode);
-static unsigned int suggest_transfer_size(struct comedi_cmd * cmd);
+static unsigned int suggest_transfer_size(struct comedi_cmd *cmd);
-// analog input ranges
+/* analog input ranges */
static const struct comedi_lrange range_ai_das1801 = {
8,
{
@@ -259,202 +260,202 @@ struct das1800_board {
*/
static const struct das1800_board das1800_boards[] = {
{
- name: "das-1701st",
- ai_speed:6250,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:0,
- range_ai:&range_ai_das1801,
+ .name = "das-1701st",
+ .ai_speed = 6250,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 0,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1701st-da",
- ai_speed:6250,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:1,
- ao_n_chan:4,
- range_ai:&range_ai_das1801,
+ .name = "das-1701st-da",
+ .ai_speed = 6250,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 1,
+ .ao_n_chan = 4,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1702st",
- ai_speed:6250,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:0,
- range_ai:&range_ai_das1802,
+ .name = "das-1702st",
+ .ai_speed = 6250,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 0,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1702st-da",
- ai_speed:6250,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:1,
- ao_n_chan:4,
- range_ai:&range_ai_das1802,
+ .name = "das-1702st-da",
+ .ai_speed = 6250,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 1,
+ .ao_n_chan = 4,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1702hr",
- ai_speed:20000,
- resolution:16,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:0,
- range_ai:&range_ai_das1802,
+ .name = "das-1702hr",
+ .ai_speed = 20000,
+ .resolution = 16,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 0,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1702hr-da",
- ai_speed:20000,
- resolution:16,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:1,
- ao_n_chan:2,
- range_ai:&range_ai_das1802,
+ .name = "das-1702hr-da",
+ .ai_speed = 20000,
+ .resolution = 16,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 1,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1701ao",
- ai_speed:6250,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:2,
- ao_n_chan:2,
- range_ai:&range_ai_das1801,
+ .name = "das-1701ao",
+ .ai_speed = 6250,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 2,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1702ao",
- ai_speed:6250,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:2,
- ao_n_chan:2,
- range_ai:&range_ai_das1802,
+ .name = "das-1702ao",
+ .ai_speed = 6250,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 2,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1801st",
- ai_speed:3000,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:0,
- range_ai:&range_ai_das1801,
+ .name = "das-1801st",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 0,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1801st-da",
- ai_speed:3000,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:4,
- range_ai:&range_ai_das1801,
+ .name = "das-1801st-da",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 4,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1802st",
- ai_speed:3000,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:0,
- range_ai:&range_ai_das1802,
+ .name = "das-1802st",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 0,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1802st-da",
- ai_speed:3000,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:1,
- ao_n_chan:4,
- range_ai:&range_ai_das1802,
+ .name = "das-1802st-da",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 1,
+ .ao_n_chan = 4,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1802hr",
- ai_speed:10000,
- resolution:16,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:0,
- ao_n_chan:0,
- range_ai:&range_ai_das1802,
+ .name = "das-1802hr",
+ .ai_speed = 10000,
+ .resolution = 16,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 0,
+ .ao_n_chan = 0,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1802hr-da",
- ai_speed:10000,
- resolution:16,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:1,
- ao_n_chan:2,
- range_ai:&range_ai_das1802,
+ .name = "das-1802hr-da",
+ .ai_speed = 10000,
+ .resolution = 16,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 1,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1801hc",
- ai_speed:3000,
- resolution:12,
- qram_len:64,
- common: 0,
- do_n_chan:8,
- ao_ability:1,
- ao_n_chan:2,
- range_ai:&range_ai_das1801,
+ .name = "das-1801hc",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 64,
+ .common = 0,
+ .do_n_chan = 8,
+ .ao_ability = 1,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1802hc",
- ai_speed:3000,
- resolution:12,
- qram_len:64,
- common: 0,
- do_n_chan:8,
- ao_ability:1,
- ao_n_chan:2,
- range_ai:&range_ai_das1802,
+ .name = "das-1802hc",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 64,
+ .common = 0,
+ .do_n_chan = 8,
+ .ao_ability = 1,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1802,
},
{
- name: "das-1801ao",
- ai_speed:3000,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:2,
- ao_n_chan:2,
- range_ai:&range_ai_das1801,
+ .name = "das-1801ao",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 2,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1801,
},
{
- name: "das-1802ao",
- ai_speed:3000,
- resolution:12,
- qram_len:256,
- common: 1,
- do_n_chan:4,
- ao_ability:2,
- ao_n_chan:2,
- range_ai:&range_ai_das1802,
+ .name = "das-1802ao",
+ .ai_speed = 3000,
+ .resolution = 12,
+ .qram_len = 256,
+ .common = 1,
+ .do_n_chan = 4,
+ .ao_ability = 2,
+ .ao_n_chan = 2,
+ .range_ai = &range_ai_das1802,
},
};
@@ -485,7 +486,7 @@ struct das1800_private {
#define devpriv ((struct das1800_private *)dev->private)
-// analog out range for boards with basic analog out
+/* analog out range for boards with basic analog out */
static const struct comedi_lrange range_ao_1 = {
1,
{
@@ -493,7 +494,7 @@ static const struct comedi_lrange range_ao_1 = {
}
};
-// analog out range for 'ao' boards
+/* analog out range for 'ao' boards */
/*
static const struct comedi_lrange range_ao_2 = {
2,
@@ -505,13 +506,13 @@ static const struct comedi_lrange range_ao_2 = {
*/
static struct comedi_driver driver_das1800 = {
- driver_name:"das1800",
- module:THIS_MODULE,
- attach:das1800_attach,
- detach:das1800_detach,
- num_names:sizeof(das1800_boards) / sizeof(struct das1800_board),
- board_name:&das1800_boards[0].name,
- offset:sizeof(struct das1800_board),
+ .driver_name = "das1800",
+ .module = THIS_MODULE,
+ .attach = das1800_attach,
+ .detach = das1800_detach,
+ .num_names = ARRAY_SIZE(das1800_boards),
+ .board_name = &das1800_boards[0].name,
+ .offset = sizeof(struct das1800_board),
};
/*
@@ -520,31 +521,31 @@ static struct comedi_driver driver_das1800 = {
*/
COMEDI_INITCLEANUP(driver_das1800);
-static int das1800_init_dma(struct comedi_device * dev, unsigned int dma0,
+static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
unsigned int dma1)
{
unsigned long flags;
- // need an irq to do dma
+ /* need an irq to do dma */
if (dev->irq && dma0) {
- //encode dma0 and dma1 into 2 digit hexadecimal for switch
+ /* encode dma0 and dma1 into 2 digit hexadecimal for switch */
switch ((dma0 & 0x7) | (dma1 << 4)) {
- case 0x5: // dma0 == 5
+ case 0x5: /* dma0 == 5 */
devpriv->dma_bits |= DMA_CH5;
break;
- case 0x6: // dma0 == 6
+ case 0x6: /* dma0 == 6 */
devpriv->dma_bits |= DMA_CH6;
break;
- case 0x7: // dma0 == 7
+ case 0x7: /* dma0 == 7 */
devpriv->dma_bits |= DMA_CH7;
break;
- case 0x65: // dma0 == 5, dma1 == 6
+ case 0x65: /* dma0 == 5, dma1 == 6 */
devpriv->dma_bits |= DMA_CH5_CH6;
break;
- case 0x76: // dma0 == 6, dma1 == 7
+ case 0x76: /* dma0 == 6, dma1 == 7 */
devpriv->dma_bits |= DMA_CH6_CH7;
break;
- case 0x57: // dma0 == 7, dma1 == 5
+ case 0x57: /* dma0 == 7, dma1 == 5 */
devpriv->dma_bits |= DMA_CH7_CH5;
break;
default:
@@ -590,7 +591,7 @@ static int das1800_init_dma(struct comedi_device * dev, unsigned int dma0,
return 0;
}
-static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = it->options[0];
@@ -638,7 +639,7 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig *
dev->board_ptr = das1800_boards + board;
dev->board_name = thisboard->name;
- // if it is an 'ao' board with fancy analog out then we need extra io ports
+ /* if it is an 'ao' board with fancy analog out then we need extra io ports */
if (thisboard->ao_ability == 2) {
iobase2 = iobase + IOBASE2;
if (!request_region(iobase2, DAS1800_SIZE,
@@ -651,7 +652,7 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig *
/* grab our IRQ */
if (irq) {
- if (comedi_request_irq(irq, das1800_interrupt, 0,
+ if (request_irq(irq, das1800_interrupt, 0,
driver_das1800.driver_name, dev)) {
printk(" unable to allocate irq %u\n", irq);
return -EINVAL;
@@ -659,7 +660,7 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig *
}
dev->irq = irq;
- // set bits that tell card which irq to use
+ /* set bits that tell card which irq to use */
switch (irq) {
case 0:
break;
@@ -751,12 +752,12 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig *
das1800_cancel(dev, dev->read_subdev);
- // initialize digital out channels
+ /* initialize digital out channels */
outb(devpriv->do_bits, dev->iobase + DAS1800_DIGITAL);
- // initialize analog out channels
+ /* initialize analog out channels */
if (thisboard->ao_ability == 1) {
- // select 'update' dac channel for baseAddress + 0x0
+ /* select 'update' dac channel for baseAddress + 0x0 */
outb(DAC(thisboard->ao_n_chan - 1),
dev->iobase + DAS1800_SELECT);
outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC);
@@ -765,13 +766,13 @@ static int das1800_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
};
-static int das1800_detach(struct comedi_device * dev)
+static int das1800_detach(struct comedi_device *dev)
{
/* only free stuff if it has been allocated by _attach */
if (dev->iobase)
release_region(dev->iobase, DAS1800_SIZE);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->private) {
if (devpriv->iobase2)
release_region(devpriv->iobase2, DAS1800_SIZE);
@@ -793,7 +794,7 @@ static int das1800_detach(struct comedi_device * dev)
/* probes and checks das-1800 series board type
*/
-static int das1800_probe(struct comedi_device * dev)
+static int das1800_probe(struct comedi_device *dev)
{
int id;
int board;
@@ -867,19 +868,19 @@ static int das1800_probe(struct comedi_device * dev)
return -1;
}
-static int das1800_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das1800_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- // prevent race with interrupt handler
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* prevent race with interrupt handler */
+ spin_lock_irqsave(&dev->spinlock, flags);
das1800_ai_handler(dev);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return s->async->buf_write_count - s->async->buf_read_count;
}
-static irqreturn_t das1800_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t das1800_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
unsigned int status;
@@ -901,15 +902,15 @@ static irqreturn_t das1800_interrupt(int irq, void *d PT_REGS_ARG)
}
/* clear the interrupt status bit INT */
outb(CLEAR_INTR_MASK & ~INT, dev->iobase + DAS1800_STATUS);
- // handle interrupt
+ /* handle interrupt */
das1800_ai_handler(dev);
spin_unlock(&dev->spinlock);
return IRQ_HANDLED;
}
-// the guts of the interrupt handler, that is shared with das1800_ai_poll
-static void das1800_ai_handler(struct comedi_device * dev)
+/* the guts of the interrupt handler, that is shared with das1800_ai_poll */
+static void das1800_ai_handler(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + 0; /* analog input subdevice */
struct comedi_async *async = s->async;
@@ -917,22 +918,22 @@ static void das1800_ai_handler(struct comedi_device * dev)
unsigned int status = inb(dev->iobase + DAS1800_STATUS);
async->events = 0;
- // select adc for base address + 0
+ /* select adc for base address + 0 */
outb(ADC, dev->iobase + DAS1800_SELECT);
- // dma buffer full
+ /* dma buffer full */
if (devpriv->irq_dma_bits & DMA_ENABLED) {
- // look for data from dma transfer even if dma terminal count hasn't happened yet
+ /* look for data from dma transfer even if dma terminal count hasn't happened yet */
das1800_handle_dma(dev, s, status);
- } else if (status & FHF) { // if fifo half full
+ } else if (status & FHF) { /* if fifo half full */
das1800_handle_fifo_half_full(dev, s);
- } else if (status & FNE) { // if fifo not empty
+ } else if (status & FNE) { /* if fifo not empty */
das1800_handle_fifo_not_empty(dev, s);
}
async->events |= COMEDI_CB_BLOCK;
/* if the card's fifo has overflowed */
if (status & OVF) {
- // clear OVF interrupt bit
+ /* clear OVF interrupt bit */
outb(CLEAR_INTR_MASK & ~OVF, dev->iobase + DAS1800_STATUS);
comedi_error(dev, "DAS1800 FIFO overflow");
das1800_cancel(dev, s);
@@ -940,19 +941,19 @@ static void das1800_ai_handler(struct comedi_device * dev)
comedi_event(dev, s);
return;
}
- // stop taking data if appropriate
+ /* stop taking data if appropriate */
/* stop_src TRIG_EXT */
if (status & CT0TC) {
- // clear CT0TC interrupt bit
+ /* clear CT0TC interrupt bit */
outb(CLEAR_INTR_MASK & ~CT0TC, dev->iobase + DAS1800_STATUS);
- // make sure we get all remaining data from board before quitting
+ /* make sure we get all remaining data from board before quitting */
if (devpriv->irq_dma_bits & DMA_ENABLED)
das1800_flush_dma(dev, s);
else
das1800_handle_fifo_not_empty(dev, s);
das1800_cancel(dev, s); /* disable hardware conversions */
async->events |= COMEDI_CB_EOA;
- } else if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) { // stop_src TRIG_COUNT
+ } else if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) { /* stop_src TRIG_COUNT */
das1800_cancel(dev, s); /* disable hardware conversions */
async->events |= COMEDI_CB_EOA;
}
@@ -962,7 +963,7 @@ static void das1800_ai_handler(struct comedi_device * dev)
return;
}
-static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevice * s,
+static void das1800_handle_dma(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int status)
{
unsigned long flags;
@@ -971,7 +972,7 @@ static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevi
flags = claim_dma_lock();
das1800_flush_dma_channel(dev, s, devpriv->dma_current,
devpriv->dma_current_buf);
- // re-enable dma channel
+ /* re-enable dma channel */
set_dma_addr(devpriv->dma_current,
virt_to_bus(devpriv->dma_current_buf));
set_dma_count(devpriv->dma_current, devpriv->dma_transfer_size);
@@ -979,11 +980,11 @@ static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevi
release_dma_lock(flags);
if (status & DMATC) {
- // clear DMATC interrupt bit
+ /* clear DMATC interrupt bit */
outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS);
- // switch dma channels for next time, if appropriate
+ /* switch dma channels for next time, if appropriate */
if (dual_dma) {
- // read data from the other channel next time
+ /* read data from the other channel next time */
if (devpriv->dma_current == devpriv->dma0) {
devpriv->dma_current = devpriv->dma1;
devpriv->dma_current_buf = devpriv->ai_buf1;
@@ -997,14 +998,14 @@ static void das1800_handle_dma(struct comedi_device * dev, struct comedi_subdevi
return;
}
-static inline uint16_t munge_bipolar_sample(const struct comedi_device * dev,
+static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev,
uint16_t sample)
{
sample += 1 << (thisboard->resolution - 1);
return sample;
}
-static void munge_data(struct comedi_device * dev, uint16_t * array,
+static void munge_data(struct comedi_device *dev, uint16_t *array,
unsigned int num_elements)
{
unsigned int i;
@@ -1023,8 +1024,8 @@ static void munge_data(struct comedi_device * dev, uint16_t * array,
/* Utility function used by das1800_flush_dma() and das1800_handle_dma().
* Assumes dma lock is held */
-static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_subdevice * s,
- unsigned int channel, uint16_t * buffer)
+static void das1800_flush_dma_channel(struct comedi_device *dev, struct comedi_subdevice *s,
+ unsigned int channel, uint16_t *buffer)
{
unsigned int num_bytes, num_samples;
struct comedi_cmd *cmd = &s->async->cmd;
@@ -1035,7 +1036,7 @@ static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_
* get set correctly */
clear_dma_ff(channel);
- // figure out how many points to read
+ /* figure out how many points to read */
num_bytes = devpriv->dma_transfer_size - get_dma_residue(channel);
num_samples = num_bytes / sizeof(short);
@@ -1053,7 +1054,7 @@ static void das1800_flush_dma_channel(struct comedi_device * dev, struct comedi_
/* flushes remaining data from board when external trigger has stopped aquisition
* and we are using dma transfers */
-static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevice * s)
+static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
@@ -1063,7 +1064,7 @@ static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevic
devpriv->dma_current_buf);
if (dual_dma) {
- // switch to other channel and flush it
+ /* switch to other channel and flush it */
if (devpriv->dma_current == devpriv->dma0) {
devpriv->dma_current = devpriv->dma1;
devpriv->dma_current_buf = devpriv->ai_buf1;
@@ -1077,14 +1078,14 @@ static void das1800_flush_dma(struct comedi_device * dev, struct comedi_subdevic
release_dma_lock(flags);
- // get any remaining samples in fifo
+ /* get any remaining samples in fifo */
das1800_handle_fifo_not_empty(dev, s);
return;
}
-static void das1800_handle_fifo_half_full(struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void das1800_handle_fifo_half_full(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
int numPoints = 0; /* number of points to read */
struct comedi_cmd *cmd = &s->async->cmd;
@@ -1102,8 +1103,8 @@ static void das1800_handle_fifo_half_full(struct comedi_device * dev,
return;
}
-static void das1800_handle_fifo_not_empty(struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
short dpnt;
int unipolar;
@@ -1126,7 +1127,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device * dev,
return;
}
-static int das1800_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */
outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */
@@ -1139,8 +1140,8 @@ static int das1800_cancel(struct comedi_device * dev, struct comedi_subdevice *
}
/* test analog input cmd */
-static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1180,7 +1181,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
/* step 2: make sure trigger sources are unique and mutually compatible */
- // uniqueness check
+ /* uniqueness check */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW &&
@@ -1192,7 +1193,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
if (cmd->stop_src != TRIG_COUNT &&
cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
err++;
- //compatibility check
+ /* compatibility check */
if (cmd->scan_begin_src != TRIG_FOLLOW &&
cmd->convert_src != TRIG_TIMER)
err++;
@@ -1244,7 +1245,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
/* step 4: fix up any arguments */
if (cmd->convert_src == TRIG_TIMER) {
- // if we are not in burst mode
+ /* if we are not in burst mode */
if (cmd->scan_begin_src == TRIG_FOLLOW) {
tmp_arg = cmd->convert_arg;
/* calculate counter values that give desired timing */
@@ -1255,9 +1256,9 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
if (tmp_arg != cmd->convert_arg)
err++;
}
- // if we are in burst mode
+ /* if we are in burst mode */
else {
- // check that convert_arg is compatible
+ /* check that convert_arg is compatible */
tmp_arg = cmd->convert_arg;
cmd->convert_arg =
burst_convert_arg(cmd->convert_arg,
@@ -1266,7 +1267,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
err++;
if (cmd->scan_begin_src == TRIG_TIMER) {
- // if scans are timed faster than conversion rate allows
+ /* if scans are timed faster than conversion rate allows */
if (cmd->convert_arg * cmd->chanlist_len >
cmd->scan_begin_arg) {
cmd->scan_begin_arg =
@@ -1290,7 +1291,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
if (err)
return 4;
- // make sure user is not trying to mix unipolar and bipolar ranges
+ /* make sure user is not trying to mix unipolar and bipolar ranges */
if (cmd->chanlist) {
unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
for (i = 1; i < cmd->chanlist_len; i++) {
@@ -1311,14 +1312,14 @@ static int das1800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subde
/* analog input cmd interface */
-// first, some utility functions used in the main ai_do_cmd()
+/* first, some utility functions used in the main ai_do_cmd() */
-// returns appropriate bits for control register a, depending on command
+/* returns appropriate bits for control register a, depending on command */
static int control_a_bits(struct comedi_cmd cmd)
{
int control_a;
- control_a = FFEN; //enable fifo
+ control_a = FFEN; /* enable fifo */
if (cmd.stop_src == TRIG_EXT) {
control_a |= ATEN;
}
@@ -1336,7 +1337,7 @@ static int control_a_bits(struct comedi_cmd cmd)
return control_a;
}
-// returns appropriate bits for control register c, depending on command
+/* returns appropriate bits for control register c, depending on command */
static int control_c_bits(struct comedi_cmd cmd)
{
int control_c;
@@ -1346,7 +1347,7 @@ static int control_c_bits(struct comedi_cmd cmd)
* select unipolar / bipolar
*/
aref = CR_AREF(cmd.chanlist[0]);
- control_c = UQEN; //enable upper qram addresses
+ control_c = UQEN; /* enable upper qram addresses */
if (aref != AREF_DIFF)
control_c |= SD;
if (aref == AREF_COMMON)
@@ -1355,7 +1356,7 @@ static int control_c_bits(struct comedi_cmd cmd)
if (CR_RANGE(cmd.chanlist[0]) & UNIPOLAR)
control_c |= UB;
switch (cmd.scan_begin_src) {
- case TRIG_FOLLOW: // not in burst mode
+ case TRIG_FOLLOW: /* not in burst mode */
switch (cmd.convert_src) {
case TRIG_TIMER:
/* trig on cascaded counters */
@@ -1370,11 +1371,11 @@ static int control_c_bits(struct comedi_cmd cmd)
}
break;
case TRIG_TIMER:
- // burst mode with internal pacer clock
+ /* burst mode with internal pacer clock */
control_c |= BMDE | IPCLK;
break;
case TRIG_EXT:
- // burst mode with external trigger
+ /* burst mode with external trigger */
control_c |= BMDE | XPCLK;
break;
default:
@@ -1384,12 +1385,12 @@ static int control_c_bits(struct comedi_cmd cmd)
return control_c;
}
-// sets up counters
-static int setup_counters(struct comedi_device * dev, struct comedi_cmd cmd)
+/* sets up counters */
+static int setup_counters(struct comedi_device *dev, struct comedi_cmd cmd)
{
- // setup cascaded counters for conversion/scan frequency
+ /* setup cascaded counters for conversion/scan frequency */
switch (cmd.scan_begin_src) {
- case TRIG_FOLLOW: // not in burst mode
+ case TRIG_FOLLOW: /* not in burst mode */
if (cmd.convert_src == TRIG_TIMER) {
/* set conversion frequency */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
@@ -1401,7 +1402,7 @@ static int setup_counters(struct comedi_device * dev, struct comedi_cmd cmd)
}
}
break;
- case TRIG_TIMER: // in burst mode
+ case TRIG_TIMER: /* in burst mode */
/* set scan frequency */
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
&(devpriv->divisor2), &(cmd.scan_begin_arg),
@@ -1414,17 +1415,17 @@ static int setup_counters(struct comedi_device * dev, struct comedi_cmd cmd)
break;
}
- // setup counter 0 for 'about triggering'
+ /* setup counter 0 for 'about triggering' */
if (cmd.stop_src == TRIG_EXT) {
- // load counter 0 in mode 0
+ /* load counter 0 in mode 0 */
i8254_load(dev->iobase + DAS1800_COUNTER, 0, 0, 1, 0);
}
return 0;
}
-// sets up dma
-static void setup_dma(struct comedi_device * dev, struct comedi_cmd cmd)
+/* sets up dma */
+static void setup_dma(struct comedi_device *dev, struct comedi_cmd cmd)
{
unsigned long lock_flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
@@ -1440,19 +1441,19 @@ static void setup_dma(struct comedi_device * dev, struct comedi_cmd cmd)
* count and address get set correctly */
clear_dma_ff(devpriv->dma0);
set_dma_addr(devpriv->dma0, virt_to_bus(devpriv->ai_buf0));
- // set appropriate size of transfer
+ /* set appropriate size of transfer */
set_dma_count(devpriv->dma0, devpriv->dma_transfer_size);
devpriv->dma_current = devpriv->dma0;
devpriv->dma_current_buf = devpriv->ai_buf0;
enable_dma(devpriv->dma0);
- // set up dual dma if appropriate
+ /* set up dual dma if appropriate */
if (dual_dma) {
disable_dma(devpriv->dma1);
/* clear flip-flop to make sure 2-byte registers for
* count and address get set correctly */
clear_dma_ff(devpriv->dma1);
set_dma_addr(devpriv->dma1, virt_to_bus(devpriv->ai_buf1));
- // set appropriate size of transfer
+ /* set appropriate size of transfer */
set_dma_count(devpriv->dma1, devpriv->dma_transfer_size);
enable_dma(devpriv->dma1);
}
@@ -1461,17 +1462,17 @@ static void setup_dma(struct comedi_device * dev, struct comedi_cmd cmd)
return;
}
-// programs channel/gain list into card
-static void program_chanlist(struct comedi_device * dev, struct comedi_cmd cmd)
+/* programs channel/gain list into card */
+static void program_chanlist(struct comedi_device *dev, struct comedi_cmd cmd)
{
int i, n, chan_range;
unsigned long irq_flags;
- const int range_mask = 0x3; //masks unipolar/bipolar bit off range
+ const int range_mask = 0x3; /* masks unipolar/bipolar bit off range */
const int range_bitshift = 8;
n = cmd.chanlist_len;
- // spinlock protects indirect addressing
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ /* spinlock protects indirect addressing */
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */
outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*set QRAM address start */
/* make channel / gain list */
@@ -1483,13 +1484,13 @@ static void program_chanlist(struct comedi_device * dev, struct comedi_cmd cmd)
outw(chan_range, dev->iobase + DAS1800_QRAM);
}
outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*finish write to QRAM */
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return;
}
-// analog input do_cmd
-static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+/* analog input do_cmd */
+static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int ret;
int control_a, control_c;
@@ -1509,22 +1510,22 @@ static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice
} else {
devpriv->irq_dma_bits |= devpriv->dma_bits;
}
- // interrupt on end of conversion for TRIG_WAKE_EOS
+ /* interrupt on end of conversion for TRIG_WAKE_EOS */
if (cmd.flags & TRIG_WAKE_EOS) {
- // interrupt fifo not empty
+ /* interrupt fifo not empty */
devpriv->irq_dma_bits &= ~FIMD;
} else {
- // interrupt fifo half full
+ /* interrupt fifo half full */
devpriv->irq_dma_bits |= FIMD;
}
- // determine how many conversions we need
+ /* determine how many conversions we need */
if (cmd.stop_src == TRIG_COUNT) {
devpriv->count = cmd.stop_arg * cmd.chanlist_len;
}
das1800_cancel(dev, s);
- // determine proper bits for control registers
+ /* determine proper bits for control registers */
control_a = control_a_bits(cmd);
control_c = control_c_bits(cmd);
@@ -1537,14 +1538,14 @@ static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice
}
setup_dma(dev, cmd);
outb(control_c, dev->iobase + DAS1800_CONTROL_C);
- // set conversion rate and length for burst mode
+ /* set conversion rate and length for burst mode */
if (control_c & BMDE) {
- // program conversion period with number of microseconds minus 1
+ /* program conversion period with number of microseconds minus 1 */
outb(cmd.convert_arg / 1000 - 1,
dev->iobase + DAS1800_BURST_RATE);
outb(cmd.chanlist_len - 1, dev->iobase + DAS1800_BURST_LENGTH);
}
- outb(devpriv->irq_dma_bits, dev->iobase + DAS1800_CONTROL_B); // enable irq/dma
+ outb(devpriv->irq_dma_bits, dev->iobase + DAS1800_CONTROL_B); /* enable irq/dma */
outb(control_a, dev->iobase + DAS1800_CONTROL_A); /* enable fifo and triggering */
outb(CVEN, dev->iobase + DAS1800_STATUS); /* enable conversions */
@@ -1552,8 +1553,8 @@ static int das1800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice
}
/* read analog input */
-static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das1800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan, range, aref, chan_range;
@@ -1582,7 +1583,7 @@ static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice
/* mask of unipolar/bipolar bit from range */
range = CR_RANGE(insn->chanspec) & 0x3;
chan_range = chan | (range << 8);
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */
outb(0x0, dev->iobase + DAS1800_QRAM_ADDRESS); /* set QRAM address start */
outw(chan_range, dev->iobase + DAS1800_QRAM);
@@ -1606,43 +1607,43 @@ static int das1800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice
dpnt += 1 << (thisboard->resolution - 1);
data[n] = dpnt;
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return n;
}
/* writes to an analog output channel */
-static int das1800_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das1800_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
-// int range = CR_RANGE(insn->chanspec);
+/* int range = CR_RANGE(insn->chanspec); */
int update_chan = thisboard->ao_n_chan - 1;
short output;
unsigned long irq_flags;
- // card expects two's complement data
+ /* card expects two's complement data */
output = data[0] - (1 << (thisboard->resolution - 1));
- // if the write is to the 'update' channel, we need to remember its value
+ /* if the write is to the 'update' channel, we need to remember its value */
if (chan == update_chan)
devpriv->ao_update_bits = output;
- // write to channel
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ /* write to channel */
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(DAC(chan), dev->iobase + DAS1800_SELECT); /* select dac channel for baseAddress + 0x0 */
outw(output, dev->iobase + DAS1800_DAC);
- // now we need to write to 'update' channel to update all dac channels
+ /* now we need to write to 'update' channel to update all dac channels */
if (chan != update_chan) {
outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); /* select 'update' channel for baseAddress + 0x0 */
outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC);
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return 1;
}
/* reads from digital input channels */
-static int das1800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das1800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[1] = inb(dev->iobase + DAS1800_DIGITAL) & 0xf;
@@ -1652,12 +1653,12 @@ static int das1800_di_rbits(struct comedi_device * dev, struct comedi_subdevice
}
/* writes to digital output channels */
-static int das1800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das1800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int wbits;
- // only set bits that have been masked
+ /* only set bits that have been masked */
data[0] &= (1 << s->n_chan) - 1;
wbits = devpriv->do_bits;
wbits &= ~data[0];
@@ -1672,15 +1673,15 @@ static int das1800_do_wbits(struct comedi_device * dev, struct comedi_subdevice
}
/* loads counters with divisor1, divisor2 from private structure */
-static int das1800_set_frequency(struct comedi_device * dev)
+static int das1800_set_frequency(struct comedi_device *dev)
{
int err = 0;
- // counter 1, mode 2
+ /* counter 1, mode 2 */
if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 1, devpriv->divisor1,
2))
err++;
- // counter 2, mode 2
+ /* counter 2, mode 2 */
if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 2, devpriv->divisor2,
2))
err++;
@@ -1697,11 +1698,11 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
{
unsigned int micro_sec;
- // in burst mode, the maximum conversion time is 64 microseconds
+ /* in burst mode, the maximum conversion time is 64 microseconds */
if (convert_arg > 64000)
convert_arg = 64000;
- // the conversion time must be an integral number of microseconds
+ /* the conversion time must be an integral number of microseconds */
switch (round_mode) {
case TRIG_ROUND_NEAREST:
default:
@@ -1715,21 +1716,21 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
break;
}
- // return number of nanoseconds
+ /* return number of nanoseconds */
return micro_sec * 1000;
}
-// utility function that suggests a dma transfer size based on the conversion period 'ns'
-static unsigned int suggest_transfer_size(struct comedi_cmd * cmd)
+/* utility function that suggests a dma transfer size based on the conversion period 'ns' */
+static unsigned int suggest_transfer_size(struct comedi_cmd *cmd)
{
unsigned int size = DMA_BUF_SIZE;
- static const int sample_size = 2; // size in bytes of one sample from board
- unsigned int fill_time = 300000000; // target time in nanoseconds for filling dma buffer
- unsigned int max_size; // maximum size we will allow for a transfer
+ static const int sample_size = 2; /* size in bytes of one sample from board */
+ unsigned int fill_time = 300000000; /* target time in nanoseconds for filling dma buffer */
+ unsigned int max_size; /* maximum size we will allow for a transfer */
- // make dma buffer fill in 0.3 seconds for timed modes
+ /* make dma buffer fill in 0.3 seconds for timed modes */
switch (cmd->scan_begin_src) {
- case TRIG_FOLLOW: // not in burst mode
+ case TRIG_FOLLOW: /* not in burst mode */
if (cmd->convert_src == TRIG_TIMER)
size = (fill_time / cmd->convert_arg) * sample_size;
break;
@@ -1742,9 +1743,9 @@ static unsigned int suggest_transfer_size(struct comedi_cmd * cmd)
break;
}
- // set a minimum and maximum size allowed
+ /* set a minimum and maximum size allowed */
max_size = DMA_BUF_SIZE;
- // if we are taking limited number of conversions, limit transfer size to that
+ /* if we are taking limited number of conversions, limit transfer size to that */
if (cmd->stop_src == TRIG_COUNT &&
cmd->stop_arg * cmd->chanlist_len * sample_size < max_size)
max_size = cmd->stop_arg * cmd->chanlist_len * sample_size;
diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c
index 2a8ca0525104..0114eb935305 100644
--- a/drivers/staging/comedi/drivers/das6402.c
+++ b/drivers/staging/comedi/drivers/das6402.c
@@ -38,6 +38,7 @@ Devices: [Keithley Metrabyte] DAS6402 (das6402)
This driver has suffered bitrot.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -98,13 +99,13 @@ This driver has suffered bitrot.
#define C2 0x80
#define RWLH 0x30
-static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int das6402_detach(struct comedi_device * dev);
+static int das6402_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das6402_detach(struct comedi_device *dev);
static struct comedi_driver driver_das6402 = {
- driver_name:"das6402",
- module:THIS_MODULE,
- attach:das6402_attach,
- detach:das6402_detach,
+ .driver_name = "das6402",
+ .module = THIS_MODULE,
+ .attach = das6402_attach,
+ .detach = das6402_detach,
};
COMEDI_INITCLEANUP(driver_das6402);
@@ -116,9 +117,9 @@ struct das6402_private {
};
#define devpriv ((struct das6402_private *)dev->private)
-static void das6402_ai_fifo_dregs(struct comedi_device * dev, struct comedi_subdevice * s);
+static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subdevice *s);
-static void das6402_setcounter(struct comedi_device * dev)
+static void das6402_setcounter(struct comedi_device *dev)
{
BYTE p;
unsigned short ctrlwrd;
@@ -151,7 +152,7 @@ static void das6402_setcounter(struct comedi_device * dev)
outb_p(p, dev->iobase + 14);
}
-static irqreturn_t intr_handler(int irq, void *d PT_REGS_ARG)
+static irqreturn_t intr_handler(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices;
@@ -186,7 +187,7 @@ static irqreturn_t intr_handler(int irq, void *d PT_REGS_ARG)
}
#if 0
-static void das6402_ai_fifo_read(struct comedi_device * dev, short * data, int n)
+static void das6402_ai_fifo_read(struct comedi_device *dev, short *data, int n)
{
int i;
@@ -195,7 +196,7 @@ static void das6402_ai_fifo_read(struct comedi_device * dev, short * data, int n
}
#endif
-static void das6402_ai_fifo_dregs(struct comedi_device * dev, struct comedi_subdevice * s)
+static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subdevice *s)
{
while (1) {
if (!(inb(dev->iobase + 8) & 0x01))
@@ -204,7 +205,7 @@ static void das6402_ai_fifo_dregs(struct comedi_device * dev, struct comedi_subd
}
}
-static int das6402_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das6402_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
/*
* This function should reset the board from whatever condition it
@@ -226,8 +227,8 @@ static int das6402_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
}
#ifdef unused
-static int das6402_ai_mode2(struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int das6402_ai_mode2(struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
devpriv->das6402_ignoreirq = 1;
@@ -249,7 +250,7 @@ static int das6402_ai_mode2(struct comedi_device * dev, struct comedi_subdevice
}
#endif
-static int board_init(struct comedi_device * dev)
+static int board_init(struct comedi_device *dev)
{
BYTE b;
@@ -289,17 +290,17 @@ static int board_init(struct comedi_device * dev)
return 0;
}
-static int das6402_detach(struct comedi_device * dev)
+static int das6402_detach(struct comedi_device *dev)
{
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, DAS6402_SIZE);
return 0;
}
-static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das6402_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned int irq;
unsigned long iobase;
@@ -324,17 +325,19 @@ static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig *
irq = it->options[0];
printk(" ( irq = %u )", irq);
- ret = comedi_request_irq(irq, intr_handler, 0, "das6402", dev);
+ ret = request_irq(irq, intr_handler, 0, "das6402", dev);
if (ret < 0) {
printk("irq conflict\n");
return ret;
}
dev->irq = irq;
- if ((ret = alloc_private(dev, sizeof(struct das6402_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct das6402_private));
+ if (ret < 0)
return ret;
- if ((ret = alloc_subdevices(dev, 1)) < 0)
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0)
return ret;
/* ai subdevice */
@@ -342,7 +345,7 @@ static int das6402_attach(struct comedi_device * dev, struct comedi_devconfig *
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = 8;
- //s->trig[2]=das6402_ai_mode2;
+ /* s->trig[2]=das6402_ai_mode2; */
s->cancel = das6402_ai_cancel;
s->maxdata = (1 << 12) - 1;
s->len_chanlist = 16; /* ? */
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
index 7a6656bf809c..70e9d699c7a3 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -62,6 +62,7 @@ cmd triggers supported:
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -72,7 +73,7 @@ cmd triggers supported:
#define DAS800_SIZE 8
#define TIMER_BASE 1000
-#define N_CHAN_AI 8 // number of analog input channels
+#define N_CHAN_AI 8 /* number of analog input channels */
/* Registers for the das800 */
@@ -94,8 +95,8 @@ cmd triggers supported:
#define IRQ 0x8
#define BUSY 0x80
#define DAS800_GAIN 3
-#define CIO_FFOV 0x8 // fifo overflow for cio-das802/16
-#define CIO_ENHF 0x90 // interrupt fifo half full for cio-das802/16
+#define CIO_FFOV 0x8 /* fifo overflow for cio-das802/16 */
+#define CIO_ENHF 0x90 /* interrupt fifo half full for cio-das802/16 */
#define CONTROL1 0x80
#define CONV_CONTROL 0xa0
#define SCAN_LIMITS 0xc0
@@ -113,7 +114,7 @@ struct das800_board {
int resolution;
};
-//analog input ranges
+/* analog input ranges */
static const struct comedi_lrange range_das800_ai = {
1,
{
@@ -184,46 +185,46 @@ enum { das800, ciodas800, das801, ciodas801, das802, ciodas802, ciodas80216 };
static const struct das800_board das800_boards[] = {
{
- name: "das-800",
- ai_speed:25000,
- ai_range:&range_das800_ai,
- resolution:12,
+ .name = "das-800",
+ .ai_speed = 25000,
+ .ai_range = &range_das800_ai,
+ .resolution = 12,
},
{
- name: "cio-das800",
- ai_speed:20000,
- ai_range:&range_das800_ai,
- resolution:12,
+ .name = "cio-das800",
+ .ai_speed = 20000,
+ .ai_range = &range_das800_ai,
+ .resolution = 12,
},
{
- name: "das-801",
- ai_speed:25000,
- ai_range:&range_das801_ai,
- resolution:12,
+ .name = "das-801",
+ .ai_speed = 25000,
+ .ai_range = &range_das801_ai,
+ .resolution = 12,
},
{
- name: "cio-das801",
- ai_speed:20000,
- ai_range:&range_cio_das801_ai,
- resolution:12,
+ .name = "cio-das801",
+ .ai_speed = 20000,
+ .ai_range = &range_cio_das801_ai,
+ .resolution = 12,
},
{
- name: "das-802",
- ai_speed:25000,
- ai_range:&range_das802_ai,
- resolution:12,
+ .name = "das-802",
+ .ai_speed = 25000,
+ .ai_range = &range_das802_ai,
+ .resolution = 12,
},
{
- name: "cio-das802",
- ai_speed:20000,
- ai_range:&range_das802_ai,
- resolution:12,
+ .name = "cio-das802",
+ .ai_speed = 20000,
+ .ai_range = &range_das802_ai,
+ .resolution = 12,
},
{
- name: "cio-das802/16",
- ai_speed:10000,
- ai_range:&range_das80216_ai,
- resolution:16,
+ .name = "cio-das802/16",
+ .ai_speed = 10000,
+ .ai_range = &range_das80216_ai,
+ .resolution = 16,
},
};
@@ -242,47 +243,47 @@ struct das800_private {
#define devpriv ((struct das800_private *)dev->private)
-static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int das800_detach(struct comedi_device * dev);
-static int das800_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das800_detach(struct comedi_device *dev);
+static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static struct comedi_driver driver_das800 = {
- driver_name:"das800",
- module:THIS_MODULE,
- attach:das800_attach,
- detach:das800_detach,
- num_names:sizeof(das800_boards) / sizeof(struct das800_board),
- board_name:&das800_boards[0].name,
- offset:sizeof(struct das800_board),
+ .driver_name = "das800",
+ .module = THIS_MODULE,
+ .attach = das800_attach,
+ .detach = das800_detach,
+ .num_names = ARRAY_SIZE(das800_boards),
+ .board_name = &das800_boards[0].name,
+ .offset = sizeof(struct das800_board),
};
-static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG);
-static void enable_das800(struct comedi_device * dev);
-static void disable_das800(struct comedi_device * dev);
-static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int das800_probe(struct comedi_device * dev);
-static int das800_set_frequency(struct comedi_device * dev);
+static irqreturn_t das800_interrupt(int irq, void *d);
+static void enable_das800(struct comedi_device *dev);
+static void disable_das800(struct comedi_device *dev);
+static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int das800_probe(struct comedi_device *dev);
+static int das800_set_frequency(struct comedi_device *dev);
/* checks and probes das-800 series board type */
-static int das800_probe(struct comedi_device * dev)
+static int das800_probe(struct comedi_device *dev)
{
int id_bits;
unsigned long irq_flags;
int board;
- // 'comedi spin lock irqsave' disables even rt interrupts, we use them to protect indirect addressing
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ /* 'comedi spin lock irqsave' disables even rt interrupts, we use them to protect indirect addressing */
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(ID, dev->iobase + DAS800_GAIN); /* select base address + 7 to be ID register */
id_bits = inb(dev->iobase + DAS800_ID) & 0x3; /* get id bits */
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
board = thisboard - das800_boards;
@@ -343,7 +344,7 @@ static int das800_probe(struct comedi_device * dev)
COMEDI_INITCLEANUP(driver_das800);
/* interrupt service routine */
-static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t das800_interrupt(int irq, void *d)
{
short i; /* loop index */
short dataPoint = 0;
@@ -352,8 +353,8 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
struct comedi_async *async;
int status;
unsigned long irq_flags;
- static const int max_loops = 128; // half-fifo size for cio-das802/16
- // flags
+ static const int max_loops = 128; /* half-fifo size for cio-das802/16 */
+ /* flags */
int fifo_empty = 0;
int fifo_overflow = 0;
@@ -369,13 +370,13 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
*/
async = s->async;
- // if hardware conversions are not enabled, then quit
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ /* if hardware conversions are not enabled, then quit */
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */
status = inb(dev->iobase + DAS800_STATUS2) & STATUS2_HCEN;
/* don't release spinlock yet since we want to make sure noone else disables hardware conversions */
if (status == 0) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return IRQ_HANDLED;
}
@@ -390,7 +391,7 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
if (fifo_overflow)
break;
} else {
- fifo_empty = 0; // cio-das802/16 has no fifo empty status bit
+ fifo_empty = 0; /* cio-das802/16 has no fifo empty status bit */
}
if (fifo_empty) {
break;
@@ -410,12 +411,12 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
/* check for fifo overflow */
if (thisboard->resolution == 12) {
fifo_overflow = dataPoint & FIFO_OVF;
- // else cio-das802/16
+ /* else cio-das802/16 */
} else {
fifo_overflow = inb(dev->iobase + DAS800_GAIN) & CIO_FFOV;
}
if (fifo_overflow) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
comedi_error(dev, "DAS800 FIFO overflow");
das800_cancel(dev, dev->subdevices + 0);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
@@ -429,10 +430,10 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits,
dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* otherwise, stop taking data */
} else {
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
disable_das800(dev); /* diable hardware triggered conversions */
async->events |= COMEDI_CB_EOA;
}
@@ -441,7 +442,7 @@ static irqreturn_t das800_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = it->options[0];
@@ -484,7 +485,7 @@ static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * i
return -EINVAL;
}
if (irq) {
- if (comedi_request_irq(irq, das800_interrupt, 0, "das800", dev)) {
+ if (request_irq(irq, das800_interrupt, 0, "das800", dev)) {
printk("unable to allocate irq %u\n", irq);
return -EINVAL;
}
@@ -531,15 +532,15 @@ static int das800_attach(struct comedi_device * dev, struct comedi_devconfig * i
disable_das800(dev);
/* initialize digital out channels */
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return 0;
};
-static int das800_detach(struct comedi_device * dev)
+static int das800_detach(struct comedi_device *dev)
{
printk("comedi%d: das800: remove\n", dev->minor);
@@ -547,11 +548,11 @@ static int das800_detach(struct comedi_device * dev)
if (dev->iobase)
release_region(dev->iobase, DAS800_SIZE);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
return 0;
};
-static int das800_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
devpriv->forever = 0;
devpriv->count = 0;
@@ -560,32 +561,32 @@ static int das800_cancel(struct comedi_device * dev, struct comedi_subdevice * s
}
/* enable_das800 makes the card start taking hardware triggered conversions */
-static void enable_das800(struct comedi_device * dev)
+static void enable_das800(struct comedi_device *dev)
{
unsigned long irq_flags;
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
- // enable fifo-half full interrupts for cio-das802/16
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
+ /* enable fifo-half full interrupts for cio-das802/16 */
if (thisboard->resolution == 16)
outb(CIO_ENHF, dev->iobase + DAS800_GAIN);
outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */
outb(CONV_HCEN, dev->iobase + DAS800_CONV_CONTROL); /* enable hardware triggering */
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1); /* enable card's interrupt */
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
}
/* disable_das800 stops hardware triggered conversions */
-static void disable_das800(struct comedi_device * dev)
+static void disable_das800(struct comedi_device *dev)
{
unsigned long irq_flags;
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */
outb(0x0, dev->iobase + DAS800_CONV_CONTROL); /* disable hardware triggering of conversions */
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
}
-static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -684,7 +685,7 @@ static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdev
if (err)
return 4;
- // check channel/gain list against card's limitations
+ /* check channel/gain list against card's limitations */
if (cmd->chanlist) {
gain = CR_RANGE(cmd->chanlist[0]);
startChan = CR_CHAN(cmd->chanlist[0]);
@@ -709,7 +710,7 @@ static int das800_ai_do_cmdtest(struct comedi_device * dev, struct comedi_subdev
return 0;
}
-static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int startChan, endChan, scan, gain;
int conv_bits;
@@ -729,10 +730,10 @@ static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice
endChan = (startChan + async->cmd.chanlist_len - 1) % 8;
scan = (endChan << 3) | startChan;
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(SCAN_LIMITS, dev->iobase + DAS800_GAIN); /* select base address + 2 to be scan limits register */
outb(scan, dev->iobase + DAS800_SCAN_LIMITS); /* set scan limits */
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* set gain */
gain = CR_RANGE(async->cmd.chanlist[0]);
@@ -779,17 +780,17 @@ static int das800_ai_do_cmd(struct comedi_device * dev, struct comedi_subdevice
break;
}
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */
outb(conv_bits, dev->iobase + DAS800_CONV_CONTROL);
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
async->events = 0;
enable_das800(dev);
return 0;
}
-static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan;
@@ -803,10 +804,10 @@ static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
/* set multiplexer */
chan = CR_CHAN(insn->chanspec);
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(chan | devpriv->do_bits, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* set gain / range */
range = CR_RANGE(insn->chanspec);
@@ -815,7 +816,7 @@ static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
range &= 0xf;
outb(range, dev->iobase + DAS800_GAIN);
- comedi_udelay(5);
+ udelay(5);
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
@@ -842,8 +843,8 @@ static int das800_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static int das800_di_rbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -855,23 +856,23 @@ static int das800_di_rbits(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int das800_do_wbits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int das800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int wbits;
unsigned long irq_flags;
- // only set bits that have been masked
+ /* only set bits that have been masked */
data[0] &= 0xf;
wbits = devpriv->do_bits >> 4;
wbits &= ~data[0];
wbits |= data[0] & data[1];
devpriv->do_bits = wbits << 4;
- comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
+ spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(devpriv->do_bits | CONTROL1_INTE, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
data[1] = wbits;
@@ -879,7 +880,7 @@ static int das800_do_wbits(struct comedi_device * dev, struct comedi_subdevice *
}
/* loads counters with divisor1, divisor2 from private structure */
-static int das800_set_frequency(struct comedi_device * dev)
+static int das800_set_frequency(struct comedi_device *dev)
{
int err = 0;
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
index 829083651edc..573cbe72b20b 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
@@ -74,6 +74,7 @@ Configuration Options:
* options that are used with comedi_config.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -114,8 +115,8 @@ Configuration Options:
#define DMM32AT_DIOC 0x0e
#define DMM32AT_DIOCONF 0x0f
-#define dmm_inb(cdev,reg) inb((cdev->iobase)+reg)
-#define dmm_outb(cdev,reg,valu) outb(valu,(cdev->iobase)+reg)
+#define dmm_inb(cdev, reg) inb((cdev->iobase)+reg)
+#define dmm_outb(cdev, reg, valu) outb(valu, (cdev->iobase)+reg)
/* Board register values. */
@@ -213,15 +214,15 @@ struct dmm32at_board {
};
static const struct dmm32at_board dmm32at_boards[] = {
{
- name: "dmm32at",
- ai_chans:32,
- ai_bits: 16,
- ai_ranges:&dmm32at_airanges,
- ao_chans:4,
- ao_bits: 12,
- ao_ranges:&dmm32at_aoranges,
- have_dio:1,
- dio_chans:24,
+ .name = "dmm32at",
+ .ai_chans = 32,
+ .ai_bits = 16,
+ .ai_ranges = &dmm32at_airanges,
+ .ao_chans = 4,
+ .ao_bits = 12,
+ .ao_ranges = &dmm32at_aoranges,
+ .have_dio = 1,
+ .dio_chans = 24,
},
};
@@ -258,13 +259,13 @@ struct dmm32at_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dmm32at_detach(struct comedi_device * dev);
+static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dmm32at_detach(struct comedi_device *dev);
static struct comedi_driver driver_dmm32at = {
- driver_name:"dmm32at",
- module:THIS_MODULE,
- attach:dmm32at_attach,
- detach:dmm32at_detach,
+ .driver_name = "dmm32at",
+ .module = THIS_MODULE,
+ .attach = dmm32at_attach,
+ .detach = dmm32at_detach,
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by
@@ -283,29 +284,29 @@ static struct comedi_driver driver_dmm32at = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- board_name:&dmm32at_boards[0].name,
- offset:sizeof(struct dmm32at_board),
- num_names:sizeof(dmm32at_boards) / sizeof(struct dmm32at_board),
+ .board_name = &dmm32at_boards[0].name,
+ .offset = sizeof(struct dmm32at_board),
+ .num_names = ARRAY_SIZE(dmm32at_boards),
};
/* prototypes for driver functions below */
-static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dmm32at_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dmm32at_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dmm32at_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int dmm32at_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int dmm32at_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int dmm32at_ns_to_timer(unsigned int *ns, int round);
-static irqreturn_t dmm32at_isr(int irq, void *d PT_REGS_ARG);
-void dmm32at_setaitimer(struct comedi_device * dev, unsigned int nansec);
+static irqreturn_t dmm32at_isr(int irq, void *d);
+void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec);
/*
* Attach is called by the Comedi core to configure the driver
@@ -313,7 +314,7 @@ void dmm32at_setaitimer(struct comedi_device * dev, unsigned int nansec);
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
struct comedi_subdevice *s;
@@ -380,8 +381,7 @@ static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig *
/* board is there, register interrupt */
if (irq) {
- ret = comedi_request_irq(irq, dmm32at_isr, 0, thisboard->name,
- dev);
+ ret = request_irq(irq, dmm32at_isr, 0, thisboard->name, dev);
if (ret < 0) {
printk("irq conflict\n");
return ret;
@@ -394,7 +394,7 @@ static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig *
* it is, this is the place to do it. Otherwise, dev->board_ptr
* should already be initialized.
*/
- //dev->board_ptr = dmm32at_probe(dev);
+ /* dev->board_ptr = dmm32at_probe(dev); */
/*
* Initialize dev->board_name. Note that we can use the "thisboard"
@@ -481,11 +481,11 @@ static int dmm32at_attach(struct comedi_device * dev, struct comedi_devconfig *
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int dmm32at_detach(struct comedi_device * dev)
+static int dmm32at_detach(struct comedi_device *dev)
{
printk("comedi%d: dmm32at: remove\n", dev->minor);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, DMM32AT_MEMSIZE);
@@ -497,8 +497,8 @@ static int dmm32at_detach(struct comedi_device * dev)
* mode.
*/
-static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
unsigned int d;
@@ -512,7 +512,7 @@ static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice
chan = CR_CHAN(insn->chanspec) & (s->n_chan - 1);
range = CR_RANGE(insn->chanspec);
- //printk("channel=0x%02x, range=%d\n",chan,range);
+ /* printk("channel=0x%02x, range=%d\n",chan,range); */
/* zero scan and fifo control and reset fifo */
dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_FIFORESET);
@@ -568,14 +568,14 @@ static int dmm32at_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice
return n;
}
-static int dmm32at_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
int start_chan, gain, i;
- //printk("dmmat32 in command test\n");
+ /* printk("dmmat32 in command test\n"); */
/* cmdtest tests a particular command to see if it is valid.
* Using the cmdtest ioctl, a user can create a valid cmd
@@ -752,7 +752,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevic
return 0;
}
-static int dmm32at_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int i, range;
@@ -822,13 +822,13 @@ static int dmm32at_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
}
-static int dmm32at_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
devpriv->ai_scans_left = 1;
return 0;
}
-static irqreturn_t dmm32at_isr(int irq, void *d PT_REGS_ARG)
+static irqreturn_t dmm32at_isr(int irq, void *d)
{
unsigned char intstat;
unsigned int samp;
@@ -893,8 +893,8 @@ static int dmm32at_ns_to_timer(unsigned int *ns, int round)
return *ns;
}
-static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -910,7 +910,7 @@ static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
lo = data[i] & 0x00ff;
/* high byte also contains channel number */
hi = (data[i] >> 8) + chan * (1 << 6);
- //printk("writing 0x%02x 0x%02x\n",hi,lo);
+ /* printk("writing 0x%02x 0x%02x\n",hi,lo); */
/* write the low and high values to the board */
dmm_outb(dev, DMM32AT_DACLSB, lo);
dmm_outb(dev, DMM32AT_DACMSB, hi);
@@ -936,8 +936,8 @@ static int dmm32at_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int dmm32at_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -953,8 +953,8 @@ static int dmm32at_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned char diobits;
@@ -967,7 +967,7 @@ static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
s->state &= ~data[0];
s->state |= data[0] & data[1];
/* Write out the new digital output lines */
- //outw(s->state,dev->iobase + DMM32AT_DIO);
+ /* outw(s->state,dev->iobase + DMM32AT_DIO); */
}
/* get access to the DIO regs */
@@ -998,16 +998,16 @@ static int dmm32at_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
/* on return, data[1] contains the value of the digital
* input and output lines. */
- //data[1]=inw(dev->iobase + DMM32AT_DIO);
+ /* data[1]=inw(dev->iobase + DMM32AT_DIO); */
/* or we could just return the software copy of the output values if
* it was a purely digital output subdevice */
- //data[1]=s->state;
+ /* data[1]=s->state; */
return 2;
}
-static int dmm32at_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned char chanbit;
int chan = CR_CHAN(insn->chanspec);
@@ -1043,7 +1043,7 @@ static int dmm32at_dio_insn_config(struct comedi_device * dev, struct comedi_sub
return 1;
}
-void dmm32at_setaitimer(struct comedi_device * dev, unsigned int nansec)
+void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec)
{
unsigned char lo1, lo2, hi2;
unsigned short both2;
diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c
index 5e0eed835d1a..25a9b213b6f1 100644
--- a/drivers/staging/comedi/drivers/dt2801.c
+++ b/drivers/staging/comedi/drivers/dt2801.c
@@ -88,19 +88,19 @@ Configuration options:
#define DT2801_STATUS 1
#define DT2801_CMD 1
-static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt2801_detach(struct comedi_device * dev);
+static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2801_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt2801 = {
- driver_name:"dt2801",
- module:THIS_MODULE,
- attach:dt2801_attach,
- detach:dt2801_detach,
+ .driver_name = "dt2801",
+ .module = THIS_MODULE,
+ .attach = dt2801_attach,
+ .detach = dt2801_detach,
};
COMEDI_INITCLEANUP(driver_dt2801);
#if 0
-// ignore 'defined but not used' warning
+/* ignore 'defined but not used' warning */
static const struct comedi_lrange range_dt2801_ai_pgh_bipolar = { 4, {
RANGE(-10, 10),
RANGE(-5, 5),
@@ -118,7 +118,7 @@ static const struct comedi_lrange range_dt2801_ai_pgl_bipolar = { 4, {
};
#if 0
-// ignore 'defined but not used' warning
+/* ignore 'defined but not used' warning */
static const struct comedi_lrange range_dt2801_ai_pgh_unipolar = { 4, {
RANGE(0, 10),
RANGE(0, 5),
@@ -152,72 +152,71 @@ struct dt2801_board {
*/
static const struct dt2801_board boardtypes[] = {
{
- name: "dt2801",
- boardcode:0x09,
- ad_diff: 2,
- ad_chan: 16,
- adbits: 12,
- adrangetype:0,
- dabits: 12},
+ .name = "dt2801",
+ .boardcode = 0x09,
+ .ad_diff = 2,
+ .ad_chan = 16,
+ .adbits = 12,
+ .adrangetype = 0,
+ .dabits = 12},
{
- name: "dt2801-a",
- boardcode:0x52,
- ad_diff: 2,
- ad_chan: 16,
- adbits: 12,
- adrangetype:0,
- dabits: 12},
+ .name = "dt2801-a",
+ .boardcode = 0x52,
+ .ad_diff = 2,
+ .ad_chan = 16,
+ .adbits = 12,
+ .adrangetype = 0,
+ .dabits = 12},
{
- name: "dt2801/5716a",
- boardcode:0x82,
- ad_diff: 1,
- ad_chan: 16,
- adbits: 16,
- adrangetype:1,
- dabits: 12},
+ .name = "dt2801/5716a",
+ .boardcode = 0x82,
+ .ad_diff = 1,
+ .ad_chan = 16,
+ .adbits = 16,
+ .adrangetype = 1,
+ .dabits = 12},
{
- name: "dt2805",
- boardcode:0x12,
- ad_diff: 1,
- ad_chan: 16,
- adbits: 12,
- adrangetype:0,
- dabits: 12},
+ .name = "dt2805",
+ .boardcode = 0x12,
+ .ad_diff = 1,
+ .ad_chan = 16,
+ .adbits = 12,
+ .adrangetype = 0,
+ .dabits = 12},
{
- name: "dt2805/5716a",
- boardcode:0x92,
- ad_diff: 1,
- ad_chan: 16,
- adbits: 16,
- adrangetype:1,
- dabits: 12},
+ .name = "dt2805/5716a",
+ .boardcode = 0x92,
+ .ad_diff = 1,
+ .ad_chan = 16,
+ .adbits = 16,
+ .adrangetype = 1,
+ .dabits = 12},
{
- name: "dt2808",
- boardcode:0x20,
- ad_diff: 0,
- ad_chan: 16,
- adbits: 12,
- adrangetype:2,
- dabits: 8},
+ .name = "dt2808",
+ .boardcode = 0x20,
+ .ad_diff = 0,
+ .ad_chan = 16,
+ .adbits = 12,
+ .adrangetype = 2,
+ .dabits = 8},
{
- name: "dt2818",
- boardcode:0xa2,
- ad_diff: 0,
- ad_chan: 4,
- adbits: 12,
- adrangetype:0,
- dabits: 12},
+ .name = "dt2818",
+ .boardcode = 0xa2,
+ .ad_diff = 0,
+ .ad_chan = 4,
+ .adbits = 12,
+ .adrangetype = 0,
+ .dabits = 12},
{
- name: "dt2809",
- boardcode:0xb0,
- ad_diff: 0,
- ad_chan: 8,
- adbits: 12,
- adrangetype:1,
- dabits: 12},
+ .name = "dt2809",
+ .boardcode = 0xb0,
+ .ad_diff = 0,
+ .ad_chan = 8,
+ .adbits = 12,
+ .adrangetype = 1,
+ .dabits = 12},
};
-#define n_boardtypes ((sizeof(boardtypes))/(sizeof(boardtypes[0])))
#define boardtype (*(const struct dt2801_board *)dev->board_ptr)
struct dt2801_private {
@@ -228,16 +227,16 @@ struct dt2801_private {
#define devpriv ((struct dt2801_private *)dev->private)
-static int dt2801_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2801_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2801_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2801_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2801_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2801_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/* These are the low-level routines:
writecommand: write a command to the board
@@ -248,7 +247,7 @@ static int dt2801_dio_insn_config(struct comedi_device * dev, struct comedi_subd
/* Only checks DataOutReady-flag, not the Ready-flag as it is done
in the examples of the manual. I don't see why this should be
necessary. */
-static int dt2801_readdata(struct comedi_device * dev, int *data)
+static int dt2801_readdata(struct comedi_device *dev, int *data)
{
int stat = 0;
int timeout = DT2801_TIMEOUT;
@@ -267,7 +266,7 @@ static int dt2801_readdata(struct comedi_device * dev, int *data)
return -ETIME;
}
-static int dt2801_readdata2(struct comedi_device * dev, int *data)
+static int dt2801_readdata2(struct comedi_device *dev, int *data)
{
int lb, hb;
int ret;
@@ -283,7 +282,7 @@ static int dt2801_readdata2(struct comedi_device * dev, int *data)
return 0;
}
-static int dt2801_writedata(struct comedi_device * dev, unsigned int data)
+static int dt2801_writedata(struct comedi_device *dev, unsigned int data)
{
int stat = 0;
int timeout = DT2801_TIMEOUT;
@@ -309,7 +308,7 @@ static int dt2801_writedata(struct comedi_device * dev, unsigned int data)
return -ETIME;
}
-static int dt2801_writedata2(struct comedi_device * dev, unsigned int data)
+static int dt2801_writedata2(struct comedi_device *dev, unsigned int data)
{
int ret;
@@ -323,7 +322,7 @@ static int dt2801_writedata2(struct comedi_device * dev, unsigned int data)
return 0;
}
-static int dt2801_wait_for_ready(struct comedi_device * dev)
+static int dt2801_wait_for_ready(struct comedi_device *dev)
{
int timeout = DT2801_TIMEOUT;
int stat;
@@ -346,7 +345,7 @@ static int dt2801_wait_for_ready(struct comedi_device * dev)
return -ETIME;
}
-static int dt2801_writecmd(struct comedi_device * dev, int command)
+static int dt2801_writecmd(struct comedi_device *dev, int command)
{
int stat;
@@ -364,7 +363,7 @@ static int dt2801_writecmd(struct comedi_device * dev, int command)
return 0;
}
-static int dt2801_reset(struct comedi_device * dev)
+static int dt2801_reset(struct comedi_device *dev)
{
int board_code = 0;
unsigned int stat;
@@ -381,11 +380,11 @@ static int dt2801_reset(struct comedi_device * dev)
inb_p(dev->iobase + DT2801_DATA);
DPRINTK("dt2801: stop\n");
- //dt2801_writecmd(dev,DT_C_STOP);
+ /* dt2801_writecmd(dev,DT_C_STOP); */
outb_p(DT_C_STOP, dev->iobase + DT2801_CMD);
- //dt2801_wait_for_ready(dev);
- comedi_udelay(100);
+ /* dt2801_wait_for_ready(dev); */
+ udelay(100);
timeout = 10000;
do {
stat = inb_p(dev->iobase + DT2801_STATUS);
@@ -395,14 +394,15 @@ static int dt2801_reset(struct comedi_device * dev)
if (!timeout) {
printk("dt2801: timeout 1 status=0x%02x\n", stat);
}
- //printk("dt2801: reading dummy\n");
- //dt2801_readdata(dev,&board_code);
+
+ /* printk("dt2801: reading dummy\n"); */
+ /* dt2801_readdata(dev,&board_code); */
DPRINTK("dt2801: reset\n");
outb_p(DT_C_RESET, dev->iobase + DT2801_CMD);
- //dt2801_writecmd(dev,DT_C_RESET);
+ /* dt2801_writecmd(dev,DT_C_RESET); */
- comedi_udelay(100);
+ udelay(100);
timeout = 10000;
do {
stat = inb_p(dev->iobase + DT2801_STATUS);
@@ -421,7 +421,7 @@ static int dt2801_reset(struct comedi_device * dev)
return board_code;
}
-static int probe_number_of_ai_chans(struct comedi_device * dev)
+static int probe_number_of_ai_chans(struct comedi_device *dev)
{
int n_chans;
int stat;
@@ -482,7 +482,7 @@ static const struct comedi_lrange *ai_range_lkup(int type, int opt)
[4] - dac0 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5]
[5] - dac1 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5]
*/
-static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -505,7 +505,7 @@ static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (!board_code)
board_code = dt2801_reset(dev);
- for (type = 0; type < n_boardtypes; type++) {
+ for (type = 0; type < ARRAY_SIZE(boardtypes); type++) {
if (boardtypes[type].boardcode == board_code)
goto havetype;
}
@@ -520,10 +520,12 @@ static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * i
n_ai_chans = probe_number_of_ai_chans(dev);
printk(" (ai channels = %d)", n_ai_chans);
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
goto out;
- if ((ret = alloc_private(dev, sizeof(struct dt2801_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct dt2801_private));
+ if (ret < 0)
goto out;
dev->board_name = boardtype.name;
@@ -583,7 +585,7 @@ static int dt2801_attach(struct comedi_device * dev, struct comedi_devconfig * i
return ret;
}
-static int dt2801_detach(struct comedi_device * dev)
+static int dt2801_detach(struct comedi_device *dev)
{
if (dev->iobase)
release_region(dev->iobase, DT2801_IOSIZE);
@@ -591,7 +593,7 @@ static int dt2801_detach(struct comedi_device * dev)
return 0;
}
-static int dt2801_error(struct comedi_device * dev, int stat)
+static int dt2801_error(struct comedi_device *dev, int stat)
{
if (stat < 0) {
if (stat == -ETIME) {
@@ -609,8 +611,8 @@ static int dt2801_error(struct comedi_device * dev, int stat)
return -EIO;
}
-static int dt2801_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int d;
int stat;
@@ -631,16 +633,16 @@ static int dt2801_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int dt2801_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2801_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
return 1;
}
-static int dt2801_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
dt2801_writecmd(dev, DT_C_WRITE_DAIM);
dt2801_writedata(dev, CR_CHAN(insn->chanspec));
@@ -651,8 +653,8 @@ static int dt2801_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
return 1;
}
-static int dt2801_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int which = 0;
@@ -675,8 +677,8 @@ static int dt2801_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int dt2801_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int which = 0;
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
index 795932ec67d3..7853902be621 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -45,6 +45,7 @@ Configuration options:
[4] - D/A 1 range (same choices)
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -214,30 +215,30 @@ static const struct dt2811_board boardtypes[] = {
#define this_board ((const struct dt2811_board *)dev->board_ptr)
-static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt2811_detach(struct comedi_device * dev);
+static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2811_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt2811 = {
- driver_name:"dt2811",
- module:THIS_MODULE,
- attach:dt2811_attach,
- detach:dt2811_detach,
- board_name:&boardtypes[0].name,
- num_names:sizeof(boardtypes) / sizeof(struct dt2811_board),
- offset:sizeof(struct dt2811_board),
+ .driver_name = "dt2811",
+ .module = THIS_MODULE,
+ .attach = dt2811_attach,
+ .detach = dt2811_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct dt2811_board),
};
COMEDI_INITCLEANUP(driver_dt2811);
-static int dt2811_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2811_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2811_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2811_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int dt2811_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int dt2811_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
enum { card_2811_pgh, card_2811_pgl };
@@ -265,7 +266,7 @@ static const struct comedi_lrange *dac_range_types[] = {
#define DT2811_TIMEOUT 5
#if 0
-static irqreturn_t dt2811_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t dt2811_interrupt(int irq, void *d)
{
int lo, hi;
int data;
@@ -311,11 +312,12 @@ static irqreturn_t dt2811_interrupt(int irq, void *d PT_REGS_ARG)
2 == unipolar 5V (0V -- +5V)
*/
-static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- //int i, irq;
- //unsigned long irqs;
- //long flags;
+ /* int i, irq; */
+ /* unsigned long irqs; */
+ /* long flags; */
+
int ret;
struct comedi_subdevice *s;
unsigned long iobase;
@@ -334,7 +336,7 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i
#if 0
outb(0, dev->iobase + DT2811_ADCSR);
- comedi_udelay(100);
+ udelay(100);
i = inb(dev->iobase + DT2811_ADDATLO);
i = inb(dev->iobase + DT2811_ADDATHI);
#endif
@@ -350,7 +352,7 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->iobase + DT2811_ADCSR);
outb(0, dev->iobase + DT2811_ADGCR);
- comedi_udelay(100);
+ udelay(100);
irq = probe_irq_off(irqs);
restore_flags(flags);
@@ -365,7 +367,7 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i
i = inb(dev->iobase + DT2811_ADDATLO);
i = inb(dev->iobase + DT2811_ADDATHI);
printk("(irq = %d)\n", irq);
- ret = comedi_request_irq(irq, dt2811_interrupt, 0,
+ ret = request_irq(irq, dt2811_interrupt, 0,
driver_name, dev);
if (ret < 0)
return -EIO;
@@ -378,10 +380,14 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i
}
#endif
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct dt2811_private))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct dt2811_private));
+ if (ret < 0)
return ret;
+
switch (it->options[2]) {
case 0:
devpriv->adc_mux = adc_singleended;
@@ -479,12 +485,12 @@ static int dt2811_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int dt2811_detach(struct comedi_device * dev)
+static int dt2811_detach(struct comedi_device *dev)
{
printk("comedi%d: dt2811: remove\n", dev->minor);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev->iobase) {
release_region(dev->iobase, DT2811_SIZE);
@@ -493,8 +499,8 @@ static int dt2811_detach(struct comedi_device * dev)
return 0;
}
-static int dt2811_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int timeout = DT2811_TIMEOUT;
@@ -520,7 +526,7 @@ static int dt2811_ai_insn(struct comedi_device * dev, struct comedi_subdevice *
#if 0
/* Wow. This is code from the Comedi stone age. But it hasn't been
* replaced, so I'll let it stay. */
-int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig)
+int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig)
{
struct comedi_device *dev = comedi_devices + minor;
@@ -531,7 +537,7 @@ int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig)
case COMEDI_MDEMAND:
dev->ntrig = adtrig->n - 1;
/*printk("dt2811: AD soft trigger\n"); */
- /*outb(DT2811_CLRERROR|DT2811_INTENB,dev->iobase+DT2811_ADCSR); *//* not neccessary */
+ /*outb(DT2811_CLRERROR|DT2811_INTENB,dev->iobase+DT2811_ADCSR); */ /* not neccessary */
outb(dev->curadchan, dev->iobase + DT2811_ADGCR);
do_gettimeofday(&trigtime);
break;
@@ -544,8 +550,8 @@ int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig)
}
#endif
-static int dt2811_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -562,8 +568,8 @@ static int dt2811_ao_insn(struct comedi_device * dev, struct comedi_subdevice *
return i;
}
-static int dt2811_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -577,8 +583,8 @@ static int dt2811_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int dt2811_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -588,8 +594,8 @@ static int dt2811_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int dt2811_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2811_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c
index 8320139160a4..5906ddddf65c 100644
--- a/drivers/staging/comedi/drivers/dt2814.c
+++ b/drivers/staging/comedi/drivers/dt2814.c
@@ -39,6 +39,7 @@ a power of 10, from 1 to 10^7, of which only 3 or 4 are useful. In
addition, the clock does not seem to be very accurate.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -59,18 +60,18 @@ addition, the clock does not seem to be very accurate.
#define DT2814_ENB 0x10
#define DT2814_CHANMASK 0x0f
-static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt2814_detach(struct comedi_device * dev);
+static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2814_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt2814 = {
- driver_name:"dt2814",
- module:THIS_MODULE,
- attach:dt2814_attach,
- detach:dt2814_detach,
+ .driver_name = "dt2814",
+ .module = THIS_MODULE,
+ .attach = dt2814_attach,
+ .detach = dt2814_detach,
};
COMEDI_INITCLEANUP(driver_dt2814);
-static irqreturn_t dt2814_interrupt(int irq, void *dev PT_REGS_ARG);
+static irqreturn_t dt2814_interrupt(int irq, void *dev);
struct dt2814_private {
@@ -83,8 +84,8 @@ struct dt2814_private {
#define DT2814_TIMEOUT 10
#define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */
-static int dt2814_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2814_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i, hi, lo;
int chan;
@@ -97,7 +98,7 @@ static int dt2814_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
for (i = 0; i < DT2814_TIMEOUT; i++) {
status = inb(dev->iobase + DT2814_CSR);
printk("dt2814: status: %02x\n", status);
- comedi_udelay(10);
+ udelay(10);
if (status & DT2814_FINISH)
break;
}
@@ -134,8 +135,8 @@ static int dt2814_ns_to_timer(unsigned int *ns, unsigned int flags)
return i;
}
-static int dt2814_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int dt2814_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -226,7 +227,7 @@ static int dt2814_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int dt2814_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int chan;
@@ -245,7 +246,7 @@ static int dt2814_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
}
-static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int i, irq;
int ret;
@@ -262,7 +263,7 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->board_name = "dt2814";
outb(0, dev->iobase + DT2814_CSR);
- comedi_udelay(100);
+ udelay(100);
if (inb(dev->iobase + DT2814_CSR) & DT2814_ERR) {
printk("reset error (fatal)\n");
return -EIO;
@@ -279,7 +280,7 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i
outb(0, dev->iobase + DT2814_CSR);
- comedi_udelay(100);
+ udelay(100);
irq = probe_irq_off(irqs);
restore_flags(flags);
@@ -293,7 +294,7 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i
#endif
dev->irq = 0;
if (irq > 0) {
- if (comedi_request_irq(irq, dt2814_interrupt, 0, "dt2814", dev)) {
+ if (request_irq(irq, dt2814_interrupt, 0, "dt2814", dev)) {
printk("(irq %d unavailable)\n", irq);
} else {
printk("( irq = %d )\n", irq);
@@ -309,9 +310,12 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i
#endif
}
- if ((ret = alloc_subdevices(dev, 1)) < 0)
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct dt2814_private))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct dt2814_private));
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -329,12 +333,12 @@ static int dt2814_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int dt2814_detach(struct comedi_device * dev)
+static int dt2814_detach(struct comedi_device *dev)
{
printk("comedi%d: dt2814: remove\n", dev->minor);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev->iobase) {
release_region(dev->iobase, DT2814_SIZE);
@@ -343,7 +347,7 @@ static int dt2814_detach(struct comedi_device * dev)
return 0;
}
-static irqreturn_t dt2814_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t dt2814_interrupt(int irq, void *d)
{
int lo, hi;
struct comedi_device *dev = d;
diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c
index fccec8a77d50..b42dec60e1b7 100644
--- a/drivers/staging/comedi/drivers/dt2815.c
+++ b/drivers/staging/comedi/drivers/dt2815.c
@@ -75,18 +75,18 @@ static const struct comedi_lrange range_dt2815_ao_20_current = { 1, {
#define DT2815_DATA 0
#define DT2815_STATUS 1
-static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt2815_detach(struct comedi_device * dev);
+static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2815_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt2815 = {
- driver_name:"dt2815",
- module:THIS_MODULE,
- attach:dt2815_attach,
- detach:dt2815_detach,
+ .driver_name = "dt2815",
+ .module = THIS_MODULE,
+ .attach = dt2815_attach,
+ .detach = dt2815_detach,
};
COMEDI_INITCLEANUP(driver_dt2815);
-static void dt2815_free_resources(struct comedi_device * dev);
+static void dt2815_free_resources(struct comedi_device *dev);
struct dt2815_private {
@@ -97,7 +97,7 @@ struct dt2815_private {
#define devpriv ((struct dt2815_private *)dev->private)
-static int dt2815_wait_for_status(struct comedi_device * dev, int status)
+static int dt2815_wait_for_status(struct comedi_device *dev, int status)
{
int i;
@@ -108,8 +108,8 @@ static int dt2815_wait_for_status(struct comedi_device * dev, int status)
return status;
}
-static int dt2815_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2815_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -121,8 +121,8 @@ static int dt2815_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -135,7 +135,7 @@ static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice *
status = dt2815_wait_for_status(dev, 0x00);
if (status != 0) {
- rt_printk
+ printk
("dt2815: failed to write low byte on %d reason %x\n",
chan, status);
return -EBUSY;
@@ -145,7 +145,7 @@ static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice *
status = dt2815_wait_for_status(dev, 0x10);
if (status != 0x10) {
- rt_printk
+ printk
("dt2815: failed to write high byte on %d reason %x\n",
chan, status);
return -EBUSY;
@@ -179,7 +179,7 @@ static int dt2815_ao_insn(struct comedi_device * dev, struct comedi_subdevice *
1 == current
*/
-static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int i;
@@ -226,7 +226,7 @@ static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * i
/* This is incredibly slow (approx 20 ms) */
unsigned int status;
- comedi_udelay(1000);
+ udelay(1000);
status = inb(dev->iobase + DT2815_STATUS);
if (status == 4) {
unsigned int program;
@@ -248,13 +248,13 @@ static int dt2815_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static void dt2815_free_resources(struct comedi_device * dev)
+static void dt2815_free_resources(struct comedi_device *dev)
{
if (dev->iobase)
release_region(dev->iobase, DT2815_SIZE);
}
-static int dt2815_detach(struct comedi_device * dev)
+static int dt2815_detach(struct comedi_device *dev)
{
printk("comedi%d: dt2815: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c
index 2dc396a44e6f..b36f85632f87 100644
--- a/drivers/staging/comedi/drivers/dt2817.c
+++ b/drivers/staging/comedi/drivers/dt2817.c
@@ -47,19 +47,19 @@ Configuration options:
#define DT2817_CR 0
#define DT2817_DATA 1
-static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt2817_detach(struct comedi_device * dev);
+static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2817_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt2817 = {
- driver_name:"dt2817",
- module:THIS_MODULE,
- attach:dt2817_attach,
- detach:dt2817_detach,
+ .driver_name = "dt2817",
+ .module = THIS_MODULE,
+ .attach = dt2817_attach,
+ .detach = dt2817_detach,
};
COMEDI_INITCLEANUP(driver_dt2817);
-static int dt2817_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int mask;
int chan;
@@ -96,8 +96,8 @@ static int dt2817_dio_insn_config(struct comedi_device * dev, struct comedi_subd
return 1;
}
-static int dt2817_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt2817_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int changed;
@@ -131,7 +131,7 @@ static int dt2817_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
struct comedi_subdevice *s;
@@ -146,7 +146,8 @@ static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->iobase = iobase;
dev->board_name = "dt2817";
- if ((ret = alloc_subdevices(dev, 1)) < 0)
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -167,7 +168,7 @@ static int dt2817_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int dt2817_detach(struct comedi_device * dev)
+static int dt2817_detach(struct comedi_device *dev)
{
printk("comedi%d: dt2817: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 4882c3e679cc..22b7304af396 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -209,132 +209,132 @@ struct dt282x_board {
};
static const struct dt282x_board boardtypes[] = {
- {name:"dt2821",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:20000,
- ispgl: 0,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt2821-f",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:6500,
- ispgl: 0,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt2821-g",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:4000,
- ispgl: 0,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt2823",
- adbits: 16,
- adchan_se:0,
- adchan_di:4,
- ai_speed:10000,
- ispgl: 0,
- dachan: 2,
- dabits: 16,
- },
- {name:"dt2824-pgh",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:20000,
- ispgl: 0,
- dachan: 0,
- dabits: 0,
- },
- {name:"dt2824-pgl",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:20000,
- ispgl: 1,
- dachan: 0,
- dabits: 0,
- },
- {name:"dt2825",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:20000,
- ispgl: 1,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt2827",
- adbits: 16,
- adchan_se:0,
- adchan_di:4,
- ai_speed:10000,
- ispgl: 0,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt2828",
- adbits: 12,
- adchan_se:4,
- adchan_di:0,
- ai_speed:10000,
- ispgl: 0,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt2829",
- adbits: 16,
- adchan_se:8,
- adchan_di:0,
- ai_speed:33250,
- ispgl: 0,
- dachan: 2,
- dabits: 16,
- },
- {name:"dt21-ez",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:10000,
- ispgl: 0,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt23-ez",
- adbits: 16,
- adchan_se:16,
- adchan_di:8,
- ai_speed:10000,
- ispgl: 0,
- dachan: 0,
- dabits: 0,
- },
- {name:"dt24-ez",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:10000,
- ispgl: 0,
- dachan: 0,
- dabits: 0,
- },
- {name:"dt24-ez-pgl",
- adbits: 12,
- adchan_se:16,
- adchan_di:8,
- ai_speed:10000,
- ispgl: 1,
- dachan: 0,
- dabits: 0,
- },
+ {.name = "dt2821",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt2821-f",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 6500,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt2821-g",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 4000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt2823",
+ .adbits = 16,
+ .adchan_se = 0,
+ .adchan_di = 4,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 16,
+ },
+ {.name = "dt2824-pgh",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ },
+ {.name = "dt2824-pgl",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 1,
+ .dachan = 0,
+ .dabits = 0,
+ },
+ {.name = "dt2825",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 1,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt2827",
+ .adbits = 16,
+ .adchan_se = 0,
+ .adchan_di = 4,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt2828",
+ .adbits = 12,
+ .adchan_se = 4,
+ .adchan_di = 0,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt2829",
+ .adbits = 16,
+ .adchan_se = 8,
+ .adchan_di = 0,
+ .ai_speed = 33250,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 16,
+ },
+ {.name = "dt21-ez",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt23-ez",
+ .adbits = 16,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ },
+ {.name = "dt24-ez",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ },
+ {.name = "dt24-ez-pgl",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 1,
+ .dachan = 0,
+ .dabits = 0,
+ },
};
#define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board)
@@ -374,51 +374,51 @@ struct dt282x_private {
* Some useless abstractions
*/
#define chan_to_DAC(a) ((a)&1)
-#define update_dacsr(a) outw(devpriv->dacsr|(a),dev->iobase+DT2821_DACSR)
-#define update_adcsr(a) outw(devpriv->adcsr|(a),dev->iobase+DT2821_ADCSR)
+#define update_dacsr(a) outw(devpriv->dacsr|(a), dev->iobase+DT2821_DACSR)
+#define update_adcsr(a) outw(devpriv->adcsr|(a), dev->iobase+DT2821_ADCSR)
#define mux_busy() (inw(dev->iobase+DT2821_ADCSR)&DT2821_MUXBUSY)
#define ad_done() (inw(dev->iobase+DT2821_ADCSR)&DT2821_ADDONE)
-#define update_supcsr(a) outw(devpriv->supcsr|(a),dev->iobase+DT2821_SUPCSR)
+#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR)
/*
* danger! macro abuse... a is the expression to wait on, and b is
* the statement(s) to execute if it doesn't happen.
*/
-#define wait_for(a,b) \
+#define wait_for(a, b) \
do{ \
int _i; \
- for(_i=0;_i<DT2821_TIMEOUT;_i++){ \
- if(a){_i=0;break;} \
- comedi_udelay(5); \
+ for (_i=0;_i<DT2821_TIMEOUT;_i++){ \
+ if (a){_i=0;break;} \
+ udelay(5); \
} \
- if(_i){b} \
- }while(0)
+ if (_i){b} \
+ }while (0)
-static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt282x_detach(struct comedi_device * dev);
+static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt282x_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt282x = {
- driver_name:"dt282x",
- module:THIS_MODULE,
- attach:dt282x_attach,
- detach:dt282x_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct dt282x_board),
+ .driver_name = "dt282x",
+ .module = THIS_MODULE,
+ .attach = dt282x_attach,
+ .detach = dt282x_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct dt282x_board),
};
COMEDI_INITCLEANUP(driver_dt282x);
-static void free_resources(struct comedi_device * dev);
-static int prep_ai_dma(struct comedi_device * dev, int chan, int size);
-static int prep_ao_dma(struct comedi_device * dev, int chan, int size);
-static int dt282x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static int dt282x_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static void free_resources(struct comedi_device *dev);
+static int prep_ai_dma(struct comedi_device *dev, int chan, int size);
+static int prep_ao_dma(struct comedi_device *dev, int chan, int size);
+static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int dt282x_ns_to_timer(int *nanosec, int round_mode);
-static void dt282x_disable_dma(struct comedi_device * dev);
+static void dt282x_disable_dma(struct comedi_device *dev);
-static int dt282x_grab_dma(struct comedi_device * dev, int dma1, int dma2);
+static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2);
-static void dt282x_munge(struct comedi_device * dev, short * buf,
+static void dt282x_munge(struct comedi_device *dev, short *buf,
unsigned int nbytes)
{
unsigned int i;
@@ -440,7 +440,7 @@ static void dt282x_munge(struct comedi_device * dev, short * buf,
}
}
-static void dt282x_ao_dma_interrupt(struct comedi_device * dev)
+static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
{
void *ptr;
int size;
@@ -463,7 +463,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device * dev)
size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize);
if (size == 0) {
- rt_printk("dt282x: AO underrun\n");
+ printk("dt282x: AO underrun\n");
dt282x_ao_cancel(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW;
return;
@@ -472,7 +472,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device * dev)
return;
}
-static void dt282x_ai_dma_interrupt(struct comedi_device * dev)
+static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
{
void *ptr;
int size;
@@ -524,7 +524,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device * dev)
prep_ai_dma(dev, i, 0);
}
-static int prep_ai_dma(struct comedi_device * dev, int dma_index, int n)
+static int prep_ai_dma(struct comedi_device *dev, int dma_index, int n)
{
int dma_chan;
unsigned long dma_ptr;
@@ -555,7 +555,7 @@ static int prep_ai_dma(struct comedi_device * dev, int dma_index, int n)
return n;
}
-static int prep_ao_dma(struct comedi_device * dev, int dma_index, int n)
+static int prep_ao_dma(struct comedi_device *dev, int dma_index, int n)
{
int dma_chan;
unsigned long dma_ptr;
@@ -577,7 +577,7 @@ static int prep_ao_dma(struct comedi_device * dev, int dma_index, int n)
return n;
}
-static irqreturn_t dt282x_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t dt282x_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s;
@@ -653,7 +653,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_RETVAL(handled);
}
-static void dt282x_load_changain(struct comedi_device * dev, int n,
+static void dt282x_load_changain(struct comedi_device *dev, int n,
unsigned int *chanlist)
{
unsigned int i;
@@ -674,8 +674,8 @@ static void dt282x_load_changain(struct comedi_device * dev, int n,
* - preload multiplexer
* - trigger conversion and wait for it to finish
*/
-static int dt282x_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -706,8 +706,8 @@ static int dt282x_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int dt282x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -818,7 +818,7 @@ static int dt282x_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int dt282x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int timer;
@@ -879,7 +879,7 @@ static int dt282x_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static void dt282x_disable_dma(struct comedi_device * dev)
+static void dt282x_disable_dma(struct comedi_device *dev)
{
if (devpriv->usedma) {
disable_dma(devpriv->dma[0].chan);
@@ -887,7 +887,7 @@ static void dt282x_disable_dma(struct comedi_device * dev)
}
}
-static int dt282x_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
dt282x_disable_dma(dev);
@@ -937,16 +937,16 @@ static int dt282x_ns_to_timer(int *nanosec, int round_mode)
* offset binary if necessary, loads the data into the DAC
* data register, and performs the conversion.
*/
-static int dt282x_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt282x_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
return 1;
}
-static int dt282x_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
short d;
unsigned int chan;
@@ -978,8 +978,8 @@ static int dt282x_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
return 1;
}
-static int dt282x_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1029,7 +1029,7 @@ static int dt282x_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice
cmd->start_arg = 0;
err++;
}
- if (cmd->scan_begin_arg < 5000 /* XXX unknown */ ) {
+ if (cmd->scan_begin_arg < 5000 /* XXX unknown */) {
cmd->scan_begin_arg = 5000;
err++;
}
@@ -1069,7 +1069,7 @@ static int dt282x_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice
}
-static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int x)
{
int size;
@@ -1080,7 +1080,7 @@ static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice
size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
devpriv->dma_maxsize);
if (size == 0) {
- rt_printk("dt282x: AO underrun\n");
+ printk("dt282x: AO underrun\n");
return -EPIPE;
}
prep_ao_dma(dev, 0, size);
@@ -1088,7 +1088,7 @@ static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice
size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
devpriv->dma_maxsize);
if (size == 0) {
- rt_printk("dt282x: AO underrun\n");
+ printk("dt282x: AO underrun\n");
return -EPIPE;
}
prep_ao_dma(dev, 1, size);
@@ -1099,7 +1099,7 @@ static int dt282x_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int dt282x_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int timer;
struct comedi_cmd *cmd = &s->async->cmd;
@@ -1132,7 +1132,7 @@ static int dt282x_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int dt282x_ao_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
dt282x_disable_dma(dev);
@@ -1145,8 +1145,8 @@ static int dt282x_ao_cancel(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int dt282x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -1159,8 +1159,8 @@ static int dt282x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int dt282x_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt282x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int mask;
@@ -1240,7 +1240,7 @@ enum { opt_iobase = 0, opt_irq, opt_dma1, opt_dma2, /* i/o base, irq, dma channe
9 ao0 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V, 4=±2.5 V
10 ao1 0=±10 V, 1=0-10 V, 2=±5 V, 3=0-5 V, 4=±2.5 V
*/
-static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int i, irq;
int ret;
@@ -1298,19 +1298,18 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i
/* trigger interrupt */
- comedi_udelay(100);
+ udelay(100);
irq = probe_irq_off(irqs);
restore_flags(flags);
- if (0 /* error */ ) {
+ if (0 /* error */) {
printk(" error probing irq (bad)");
}
}
#endif
if (irq > 0) {
printk(" ( irq = %d )", irq);
- ret = comedi_request_irq(irq, dt282x_interrupt, 0, "dt282x",
- dev);
+ ret = request_irq(irq, dt282x_interrupt, 0, "dt282x", dev);
if (ret < 0) {
printk(" failed to get irq\n");
return -EIO;
@@ -1326,7 +1325,8 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i
#endif
}
- if ((ret = alloc_private(dev, sizeof(struct dt282x_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct dt282x_private));
+ if (ret < 0)
return ret;
ret = dt282x_grab_dma(dev, it->options[opt_dma1],
@@ -1334,7 +1334,8 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (ret < 0)
return ret;
- if ((ret = alloc_subdevices(dev, 3)) < 0)
+ ret = alloc_subdevices(dev, 3);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -1358,7 +1359,9 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->ad_2scomp = it->options[opt_ai_twos];
s++;
- if ((s->n_chan = boardtype.dachan)) {
+
+ s->n_chan = boardtype.dachan;
+ if (s->n_chan) {
/* ao subsystem */
s->type = COMEDI_SUBD_AO;
dev->write_subdev = s;
@@ -1396,10 +1399,10 @@ static int dt282x_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static void free_resources(struct comedi_device * dev)
+static void free_resources(struct comedi_device *dev)
{
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev->iobase)
release_region(dev->iobase, DT2821_SIZE);
@@ -1415,7 +1418,7 @@ static void free_resources(struct comedi_device * dev)
}
}
-static int dt282x_detach(struct comedi_device * dev)
+static int dt282x_detach(struct comedi_device *dev)
{
printk("comedi%d: dt282x: remove\n", dev->minor);
@@ -1424,7 +1427,7 @@ static int dt282x_detach(struct comedi_device * dev)
return 0;
}
-static int dt282x_grab_dma(struct comedi_device * dev, int dma1, int dma2)
+static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
{
int ret;
diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c
index d9467984706e..2af8b59f9061 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -59,6 +59,7 @@ AO commands are not supported.
#define DEBUG 1
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -95,69 +96,69 @@ struct dt3k_boardtype {
static const struct dt3k_boardtype dt3k_boardtypes[] = {
- {name:"dt3001",
- device_id:0x22,
- adchan: 16,
- adbits: 12,
- adrange: &range_dt3000_ai,
- ai_speed:3000,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt3001-pgl",
- device_id:0x27,
- adchan: 16,
- adbits: 12,
- adrange: &range_dt3000_ai_pgl,
- ai_speed:3000,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt3002",
- device_id:0x23,
- adchan: 32,
- adbits: 12,
- adrange: &range_dt3000_ai,
- ai_speed:3000,
- dachan: 0,
- dabits: 0,
- },
- {name:"dt3003",
- device_id:0x24,
- adchan: 64,
- adbits: 12,
- adrange: &range_dt3000_ai,
- ai_speed:3000,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt3003-pgl",
- device_id:0x28,
- adchan: 64,
- adbits: 12,
- adrange: &range_dt3000_ai_pgl,
- ai_speed:3000,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt3004",
- device_id:0x25,
- adchan: 16,
- adbits: 16,
- adrange: &range_dt3000_ai,
- ai_speed:10000,
- dachan: 2,
- dabits: 12,
- },
- {name:"dt3005", /* a.k.a. 3004-200 */
- device_id:0x26,
- adchan: 16,
- adbits: 16,
- adrange: &range_dt3000_ai,
- ai_speed:5000,
- dachan: 2,
- dabits: 12,
- },
+ {.name = "dt3001",
+ .device_id = 0x22,
+ .adchan = 16,
+ .adbits = 12,
+ .adrange = &range_dt3000_ai,
+ .ai_speed = 3000,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt3001-pgl",
+ .device_id = 0x27,
+ .adchan = 16,
+ .adbits = 12,
+ .adrange = &range_dt3000_ai_pgl,
+ .ai_speed = 3000,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt3002",
+ .device_id = 0x23,
+ .adchan = 32,
+ .adbits = 12,
+ .adrange = &range_dt3000_ai,
+ .ai_speed = 3000,
+ .dachan = 0,
+ .dabits = 0,
+ },
+ {.name = "dt3003",
+ .device_id = 0x24,
+ .adchan = 64,
+ .adbits = 12,
+ .adrange = &range_dt3000_ai,
+ .ai_speed = 3000,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt3003-pgl",
+ .device_id = 0x28,
+ .adchan = 64,
+ .adbits = 12,
+ .adrange = &range_dt3000_ai_pgl,
+ .ai_speed = 3000,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt3004",
+ .device_id = 0x25,
+ .adchan = 16,
+ .adbits = 16,
+ .adrange = &range_dt3000_ai,
+ .ai_speed = 10000,
+ .dachan = 2,
+ .dabits = 12,
+ },
+ {.name = "dt3005", /* a.k.a. 3004-200 */
+ .device_id = 0x26,
+ .adchan = 16,
+ .adbits = 16,
+ .adrange = &range_dt3000_ai,
+ .ai_speed = 5000,
+ .dachan = 2,
+ .dabits = 12,
+ },
};
#define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
@@ -275,28 +276,28 @@ struct dt3k_private {
#define devpriv ((struct dt3k_private *)dev->private)
-static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dt3000_detach(struct comedi_device * dev);
+static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt3000_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt3000 = {
- driver_name:"dt3000",
- module:THIS_MODULE,
- attach:dt3000_attach,
- detach:dt3000_detach,
+ .driver_name = "dt3000",
+ .module = THIS_MODULE,
+ .attach = dt3000_attach,
+ .detach = dt3000_detach,
};
COMEDI_PCI_INITCLEANUP(driver_dt3000, dt3k_pci_table);
-static void dt3k_ai_empty_fifo(struct comedi_device * dev, struct comedi_subdevice * s);
+static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s);
static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg,
unsigned int round_mode);
-static int dt3k_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
#ifdef DEBUG
static void debug_intr_flags(unsigned int flags);
#endif
#define TIMEOUT 100
-static int dt3k_send_cmd(struct comedi_device * dev, unsigned int cmd)
+static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd)
{
int i;
unsigned int status = 0;
@@ -307,7 +308,7 @@ static int dt3k_send_cmd(struct comedi_device * dev, unsigned int cmd)
status = readw(devpriv->io_addr + DPR_Command_Mbx);
if ((status & DT3000_COMPLETION_MASK) != DT3000_NOTPROCESSED)
break;
- comedi_udelay(1);
+ udelay(1);
}
if ((status & DT3000_COMPLETION_MASK) == DT3000_NOERROR) {
return 0;
@@ -318,7 +319,7 @@ static int dt3k_send_cmd(struct comedi_device * dev, unsigned int cmd)
return -ETIME;
}
-static unsigned int dt3k_readsingle(struct comedi_device * dev, unsigned int subsys,
+static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subsys,
unsigned int chan, unsigned int gain)
{
writew(subsys, devpriv->io_addr + DPR_SubSys);
@@ -331,7 +332,7 @@ static unsigned int dt3k_readsingle(struct comedi_device * dev, unsigned int sub
return readw(devpriv->io_addr + DPR_Params(2));
}
-static void dt3k_writesingle(struct comedi_device * dev, unsigned int subsys,
+static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
unsigned int chan, unsigned int data)
{
writew(subsys, devpriv->io_addr + DPR_SubSys);
@@ -345,9 +346,9 @@ static void dt3k_writesingle(struct comedi_device * dev, unsigned int subsys,
static int debug_n_ints = 0;
-// FIXME! Assumes shared interrupt is for this card.
-// What's this debug_n_ints stuff? Obviously needs some work...
-static irqreturn_t dt3k_interrupt(int irq, void *d PT_REGS_ARG)
+/* FIXME! Assumes shared interrupt is for this card. */
+/* What's this debug_n_ints stuff? Obviously needs some work... */
+static irqreturn_t dt3k_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s;
@@ -400,7 +401,7 @@ static void debug_intr_flags(unsigned int flags)
}
#endif
-static void dt3k_ai_empty_fifo(struct comedi_device * dev, struct comedi_subdevice * s)
+static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
{
int front;
int rear;
@@ -429,8 +430,8 @@ static void dt3k_ai_empty_fifo(struct comedi_device * dev, struct comedi_subdevi
writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear);
}
-static int dt3k_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -591,7 +592,7 @@ static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
return (prescale << 16) | (divider);
}
-static int dt3k_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int i;
@@ -659,7 +660,7 @@ static int dt3k_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int dt3k_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
int ret;
@@ -671,8 +672,8 @@ static int dt3k_ai_cancel(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int dt3k_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
unsigned int chan, gain, aref;
@@ -689,8 +690,8 @@ static int dt3k_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s,
return i;
}
-static int dt3k_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
unsigned int chan;
@@ -704,8 +705,8 @@ static int dt3k_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
return i;
}
-static int dt3k_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt3k_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
unsigned int chan;
@@ -718,7 +719,7 @@ static int dt3k_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice
return i;
}
-static void dt3k_dio_config(struct comedi_device * dev, int bits)
+static void dt3k_dio_config(struct comedi_device *dev, int bits)
{
/* XXX */
writew(SUBS_DOUT, devpriv->io_addr + DPR_SubSys);
@@ -733,8 +734,8 @@ static void dt3k_dio_config(struct comedi_device * dev, int bits)
dt3k_send_cmd(dev, CMD_CONFIG);
}
-static int dt3k_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int mask;
@@ -764,8 +765,8 @@ static int dt3k_dio_insn_config(struct comedi_device * dev, struct comedi_subdev
return insn->n;
}
-static int dt3k_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -780,8 +781,8 @@ static int dt3k_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic
return 2;
}
-static int dt3k_mem_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dt3k_mem_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int addr = CR_CHAN(insn->chanspec);
int i;
@@ -799,9 +800,9 @@ static int dt3k_mem_insn_read(struct comedi_device * dev, struct comedi_subdevic
return i;
}
-static int dt_pci_probe(struct comedi_device * dev, int bus, int slot);
+static int dt_pci_probe(struct comedi_device *dev, int bus, int slot);
-static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int bus, slot;
@@ -811,7 +812,8 @@ static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * i
bus = it->options[0];
slot = it->options[1];
- if ((ret = alloc_private(dev, sizeof(struct dt3k_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct dt3k_private));
+ if (ret < 0)
return ret;
ret = dt_pci_probe(dev, bus, slot);
@@ -824,14 +826,15 @@ static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->board_name = this_board->name;
- if (comedi_request_irq(devpriv->pci_dev->irq, dt3k_interrupt,
- IRQF_SHARED, "dt3000", dev)) {
+ if (request_irq(devpriv->pci_dev->irq, dt3k_interrupt, IRQF_SHARED,
+ "dt3000", dev)) {
printk(" unable to allocate IRQ %u\n", devpriv->pci_dev->irq);
return -EINVAL;
}
dev->irq = devpriv->pci_dev->irq;
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
s = dev->subdevices;
@@ -890,10 +893,10 @@ static int dt3000_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int dt3000_detach(struct comedi_device * dev)
+static int dt3000_detach(struct comedi_device *dev)
{
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->pci_dev) {
@@ -911,9 +914,9 @@ static int dt3000_detach(struct comedi_device * dev)
}
static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board);
-static int setup_pci(struct comedi_device * dev);
+static int setup_pci(struct comedi_device *dev);
-static int dt_pci_probe(struct comedi_device * dev, int bus, int slot)
+static int dt_pci_probe(struct comedi_device *dev, int bus, int slot)
{
int board;
int ret;
@@ -935,13 +938,14 @@ static int dt_pci_probe(struct comedi_device * dev, int bus, int slot)
if (!devpriv->pci_dev)
return 0;
- if ((ret = setup_pci(dev)) < 0)
+ ret = setup_pci(dev);
+ if (ret < 0)
return ret;
return 1;
}
-static int setup_pci(struct comedi_device * dev)
+static int setup_pci(struct comedi_device *dev)
{
resource_size_t addr;
int ret;
diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c
index 6d7bb37d2b1c..b8657c47d4cc 100644
--- a/drivers/staging/comedi/drivers/fl512.c
+++ b/drivers/staging/comedi/drivers/fl512.c
@@ -42,30 +42,30 @@ static const struct comedi_lrange range_fl512 = { 4, {
}
};
-static int fl512_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int fl512_detach(struct comedi_device * dev);
+static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int fl512_detach(struct comedi_device *dev);
static struct comedi_driver driver_fl512 = {
- driver_name:"fl512",
- module:THIS_MODULE,
- attach:fl512_attach,
- detach:fl512_detach,
+ .driver_name = "fl512",
+ .module = THIS_MODULE,
+ .attach = fl512_attach,
+ .detach = fl512_detach,
};
COMEDI_INITCLEANUP(driver_fl512);
-static int fl512_ai_insn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
-static int fl512_ao_insn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
-static int fl512_ao_insn_readback(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int fl512_ai_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int fl512_ao_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int fl512_ao_insn_readback(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
/*
* fl512_ai_insn : this is the analog input function
*/
-static int fl512_ai_insn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int fl512_ai_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned int lo_byte, hi_byte;
@@ -78,7 +78,7 @@ static int fl512_ai_insn(struct comedi_device * dev,
outb(chan, iobase + 2); /* select chan */
outb(0, iobase + 3); /* start conversion */
/* XXX should test "done" flag instead of delay */
- comedi_udelay(30); /* sleep 30 usec */
+ udelay(30); /* sleep 30 usec */
lo_byte = inb(iobase + 2); /* low 8 byte */
hi_byte = inb(iobase + 3) & 0xf; /* high 4 bit and mask */
data[n] = lo_byte + (hi_byte << 8);
@@ -89,8 +89,8 @@ static int fl512_ai_insn(struct comedi_device * dev,
/*
* fl512_ao_insn : used to write to a DA port n times
*/
-static int fl512_ao_insn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int fl512_ao_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec); /* get chan to write */
@@ -110,8 +110,8 @@ static int fl512_ao_insn(struct comedi_device * dev,
* fl512_ao_insn_readback : used to read previous values written to
* DA port
*/
-static int fl512_ao_insn_readback(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int fl512_ao_insn_readback(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -126,7 +126,7 @@ static int fl512_ao_insn_readback(struct comedi_device * dev,
/*
* start attach
*/
-static int fl512_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase;
struct comedi_subdevice *s; /* pointer to the subdevice:
@@ -177,7 +177,7 @@ static int fl512_attach(struct comedi_device * dev, struct comedi_devconfig * it
return 1;
}
-static int fl512_detach(struct comedi_device * dev)
+static int fl512_detach(struct comedi_device *dev)
{
if (dev->iobase)
release_region(dev->iobase, FL512_SIZE);
diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
index 49e5c86c2dd8..b156ae717ae4 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -45,6 +45,7 @@ support could be added to this driver.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -52,31 +53,31 @@ support could be added to this driver.
#include "plx9080.h"
#include "comedi_fc.h"
-static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int hpdi_detach(struct comedi_device * dev);
-void abort_dma(struct comedi_device * dev, unsigned int channel);
-static int hpdi_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int hpdi_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int hpdi_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG);
-static int dio_config_block_size(struct comedi_device * dev, unsigned int * data);
+static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int hpdi_detach(struct comedi_device *dev);
+void abort_dma(struct comedi_device *dev, unsigned int channel);
+static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static irqreturn_t handle_interrupt(int irq, void *d);
+static int dio_config_block_size(struct comedi_device *dev, unsigned int *data);
-#undef HPDI_DEBUG // disable debugging messages
-//#define HPDI_DEBUG // enable debugging code
+#undef HPDI_DEBUG /* disable debugging messages */
+/* #define HPDI_DEBUG enable debugging code */
#ifdef HPDI_DEBUG
-#define DEBUG_PRINT(format, args...) rt_printk(format , ## args )
+#define DEBUG_PRINT(format, args...) printk(format , ## args)
#else
#define DEBUG_PRINT(format, args...)
#endif
-#define TIMER_BASE 50 // 20MHz master clock
+#define TIMER_BASE 50 /* 20MHz master clock */
#define DMA_BUFFER_SIZE 0x10000
#define NUM_DMA_BUFFERS 4
#define NUM_DMA_DESCRIPTORS 256
-// indices of base address regions
+/* indices of base address regions */
enum base_address_regions {
PLX9080_BADDRINDEX = 0,
HPDI_BADDRINDEX = 2,
@@ -109,13 +110,13 @@ enum hpdi_registers {
int command_channel_valid(unsigned int channel)
{
if (channel == 0 || channel > 6) {
- rt_printk("gsc_hpdi: bug! invalid cable command channel\n");
+ printk("gsc_hpdi: bug! invalid cable command channel\n");
return 0;
}
return 1;
}
-// bit definitions
+/* bit definitions */
enum firmware_revision_bits {
FEATURES_REG_PRESENT_BIT = 0x8000,
@@ -184,7 +185,7 @@ enum board_status_bits {
uint32_t almost_full_bits(unsigned int num_words)
{
-// XXX need to add or subtract one?
+/* XXX need to add or subtract one? */
return (num_words << 16) & 0xff0000;
}
@@ -194,7 +195,7 @@ uint32_t almost_empty_bits(unsigned int num_words)
}
unsigned int almost_full_num_words(uint32_t bits)
{
-// XXX need to add or subtract one?
+/* XXX need to add or subtract one? */
return (bits >> 16) & 0xffff;
}
unsigned int almost_empty_num_words(uint32_t bits)
@@ -263,31 +264,26 @@ uint32_t intr_active_high_bit(int interrupt_source)
struct hpdi_board {
char *name;
- int device_id; // pci device id
- int subdevice_id; // pci subdevice id
+ int device_id; /* pci device id */
+ int subdevice_id; /* pci subdevice id */
};
static const struct hpdi_board hpdi_boards[] = {
{
- name: "pci-hpdi32",
- device_id:PCI_DEVICE_ID_PLX_9080,
- subdevice_id:0x2400,
+ .name = "pci-hpdi32",
+ .device_id = PCI_DEVICE_ID_PLX_9080,
+ .subdevice_id = 0x2400,
},
#if 0
{
- name: "pxi-hpdi32",
- device_id:0x9656,
- subdevice_id:0x2705,
+ .name = "pxi-hpdi32",
+ .device_id = 0x9656,
+ .subdevice_id = 0x2705,
},
#endif
};
-static inline unsigned int num_boards(void)
-{
- return sizeof(hpdi_boards) / sizeof(struct hpdi_board);
-}
-
static DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = {
{PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, 0x2400,
0, 0, 0},
@@ -303,25 +299,25 @@ static inline struct hpdi_board *board(const struct comedi_device * dev)
struct hpdi_private {
- struct pci_dev *hw_dev; // pointer to board's pci_dev struct
- // base addresses (physical)
+ struct pci_dev *hw_dev; /* pointer to board's pci_dev struct */
+ /* base addresses (physical) */
resource_size_t plx9080_phys_iobase;
resource_size_t hpdi_phys_iobase;
- // base addresses (ioremapped)
+ /* base addresses (ioremapped) */
void *plx9080_iobase;
void *hpdi_iobase;
- uint32_t *dio_buffer[NUM_DMA_BUFFERS]; // dma buffers
- dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; // physical addresses of dma buffers
- struct plx_dma_desc *dma_desc; // array of dma descriptors read by plx9080, allocated to get proper alignment
- dma_addr_t dma_desc_phys_addr; // physical address of dma descriptor array
+ uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */
+ dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; /* physical addresses of dma buffers */
+ struct plx_dma_desc *dma_desc; /* array of dma descriptors read by plx9080, allocated to get proper alignment */
+ dma_addr_t dma_desc_phys_addr; /* physical address of dma descriptor array */
unsigned int num_dma_descriptors;
- uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; // pointer to start of buffers indexed by descriptor
- volatile unsigned int dma_desc_index; // index of the dma descriptor that is currently being used
+ uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; /* pointer to start of buffers indexed by descriptor */
+ volatile unsigned int dma_desc_index; /* index of the dma descriptor that is currently being used */
unsigned int tx_fifo_size;
unsigned int rx_fifo_size;
volatile unsigned long dio_count;
- volatile uint32_t bits[24]; // software copies of values written to hpdi registers
- volatile unsigned int block_size; // number of bytes at which to generate COMEDI_CB_BLOCK events
+ volatile uint32_t bits[24]; /* software copies of values written to hpdi registers */
+ volatile unsigned int block_size; /* number of bytes at which to generate COMEDI_CB_BLOCK events */
unsigned dio_config_output:1;
};
@@ -332,16 +328,16 @@ static inline struct hpdi_private *priv(struct comedi_device * dev)
}
static struct comedi_driver driver_hpdi = {
- driver_name:"gsc_hpdi",
- module:THIS_MODULE,
- attach:hpdi_attach,
- detach:hpdi_detach,
+ .driver_name = "gsc_hpdi",
+ .module = THIS_MODULE,
+ .attach = hpdi_attach,
+ .detach = hpdi_detach,
};
COMEDI_PCI_INITCLEANUP(driver_hpdi, hpdi_pci_table);
-static int dio_config_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dio_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
case INSN_CONFIG_DIO_OUTPUT:
@@ -368,18 +364,18 @@ static int dio_config_insn(struct comedi_device * dev, struct comedi_subdevice *
return -EINVAL;
}
-static void disable_plx_interrupts(struct comedi_device * dev)
+static void disable_plx_interrupts(struct comedi_device *dev)
{
writel(0, priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
}
-// initialize plx9080 chip
-static void init_plx9080(struct comedi_device * dev)
+/* initialize plx9080 chip */
+static void init_plx9080(struct comedi_device *dev)
{
uint32_t bits;
void *plx_iobase = priv(dev)->plx9080_iobase;
- // plx9080 dump
+ /* plx9080 dump */
DEBUG_PRINT(" plx interrupt status 0x%x\n",
readl(plx_iobase + PLX_INTRCS_REG));
DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG));
@@ -417,21 +413,21 @@ static void init_plx9080(struct comedi_device * dev)
abort_dma(dev, 0);
abort_dma(dev, 1);
- // configure dma0 mode
+ /* configure dma0 mode */
bits = 0;
- // enable ready input
+ /* enable ready input */
bits |= PLX_DMA_EN_READYIN_BIT;
- // enable dma chaining
+ /* enable dma chaining */
bits |= PLX_EN_CHAIN_BIT;
- // enable interrupt on dma done (probably don't need this, since chain never finishes)
+ /* enable interrupt on dma done (probably don't need this, since chain never finishes) */
bits |= PLX_EN_DMA_DONE_INTR_BIT;
- // don't increment local address during transfers (we are transferring from a fixed fifo register)
+ /* don't increment local address during transfers (we are transferring from a fixed fifo register) */
bits |= PLX_LOCAL_ADDR_CONST_BIT;
- // route dma interrupt to pci bus
+ /* route dma interrupt to pci bus */
bits |= PLX_DMA_INTR_PCI_BIT;
- // enable demand mode
+ /* enable demand mode */
bits |= PLX_DEMAND_MODE_BIT;
- // enable local burst mode
+ /* enable local burst mode */
bits |= PLX_DMA_LOCAL_BURST_EN_BIT;
bits |= PLX_LOCAL_BUS_32_WIDE_BITS;
writel(bits, plx_iobase + PLX_DMA0_MODE_REG);
@@ -439,7 +435,7 @@ static void init_plx9080(struct comedi_device * dev)
/* Allocate and initialize the subdevice structures.
*/
-static int setup_subdevices(struct comedi_device * dev)
+static int setup_subdevices(struct comedi_device *dev)
{
struct comedi_subdevice *s;
@@ -465,12 +461,12 @@ static int setup_subdevices(struct comedi_device * dev)
return 0;
}
-static int init_hpdi(struct comedi_device * dev)
+static int init_hpdi(struct comedi_device *dev)
{
uint32_t plx_intcsr_bits;
writel(BOARD_RESET_BIT, priv(dev)->hpdi_iobase + BOARD_CONTROL_REG);
- comedi_udelay(10);
+ udelay(10);
writel(almost_empty_bits(32) | almost_full_bits(32),
priv(dev)->hpdi_iobase + RX_PROG_ALMOST_REG);
@@ -484,7 +480,7 @@ static int init_hpdi(struct comedi_device * dev)
writel(0, priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
- // enable interrupts
+ /* enable interrupts */
plx_intcsr_bits =
ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
ICS_DMA0_E;
@@ -493,8 +489,8 @@ static int init_hpdi(struct comedi_device * dev)
return 0;
}
-// setup dma descriptors so a link completes every 'transfer_size' bytes
-static int setup_dma_descriptors(struct comedi_device * dev,
+/* setup dma descriptors so a link completes every 'transfer_size' bytes */
+static int setup_dma_descriptors(struct comedi_device *dev,
unsigned int transfer_size)
{
unsigned int buffer_index, buffer_offset;
@@ -545,7 +541,7 @@ static int setup_dma_descriptors(struct comedi_device * dev,
(unsigned long)priv(dev)->dma_desc[i].next);
}
priv(dev)->num_dma_descriptors = i;
- // fix last descriptor to point back to first
+ /* fix last descriptor to point back to first */
priv(dev)->dma_desc[i - 1].next =
cpu_to_le32(priv(dev)->dma_desc_phys_addr | next_bits);
DEBUG_PRINT(" desc %i next fixup 0x%lx\n", i - 1,
@@ -556,7 +552,7 @@ static int setup_dma_descriptors(struct comedi_device * dev,
return transfer_size;
}
-static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
int i;
@@ -568,14 +564,14 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
return -ENOMEM;
pcidev = NULL;
- for (i = 0; i < num_boards() && dev->board_ptr == NULL; i++) {
+ for (i = 0; i < ARRAY_SIZE(hpdi_boards) && dev->board_ptr == NULL; i++) {
do {
pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX,
hpdi_boards[i].device_id, PCI_VENDOR_ID_PLX,
hpdi_boards[i].subdevice_id, pcidev);
- // was a particular bus/slot requested?
+ /* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
- // are we on the wrong bus/slot?
+ /* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
PCI_SLOT(pcidev->devfn) !=
it->options[1])
@@ -603,7 +599,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
}
pci_set_master(pcidev);
- //Initialize dev->board_name
+ /* Initialize dev->board_name */
dev->board_name = board(dev)->name;
priv(dev)->plx9080_phys_iobase =
@@ -611,7 +607,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
priv(dev)->hpdi_phys_iobase =
pci_resource_start(pcidev, HPDI_BADDRINDEX);
- // remap, won't work with 2.0 kernels but who cares
+ /* remap, won't work with 2.0 kernels but who cares */
priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase,
pci_resource_len(pcidev, PLX9080_BADDRINDEX));
priv(dev)->hpdi_iobase = ioremap(priv(dev)->hpdi_phys_iobase,
@@ -626,8 +622,8 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
init_plx9080(dev);
- // get irq
- if (comedi_request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
+ /* get irq */
+ if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
driver_hpdi.driver_name, dev)) {
printk(" unable to allocate irq %u\n", pcidev->irq);
return -EINVAL;
@@ -636,7 +632,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
printk(" irq %u\n", dev->irq);
- // alocate pci dma buffers
+ /* alocate pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) {
priv(dev)->dio_buffer[i] =
pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
@@ -645,7 +641,7 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
priv(dev)->dio_buffer[i],
(unsigned long)priv(dev)->dio_buffer_phys_addr[i]);
}
- // allocate dma descriptors
+ /* allocate dma descriptors */
priv(dev)->dma_desc = pci_alloc_consistent(priv(dev)->hw_dev,
sizeof(struct plx_dma_desc) * NUM_DMA_DESCRIPTORS,
&priv(dev)->dma_desc_phys_addr);
@@ -665,14 +661,14 @@ static int hpdi_attach(struct comedi_device * dev, struct comedi_devconfig * it)
return init_hpdi(dev);
}
-static int hpdi_detach(struct comedi_device * dev)
+static int hpdi_detach(struct comedi_device *dev)
{
unsigned int i;
printk("comedi%d: gsc_hpdi: remove\n", dev->minor);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (priv(dev)) {
if (priv(dev)->hw_dev) {
if (priv(dev)->plx9080_iobase) {
@@ -681,7 +677,7 @@ static int hpdi_detach(struct comedi_device * dev)
}
if (priv(dev)->hpdi_iobase)
iounmap((void *)priv(dev)->hpdi_iobase);
- // free pci dma buffers
+ /* free pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) {
if (priv(dev)->dio_buffer[i])
pci_free_consistent(priv(dev)->hw_dev,
@@ -690,7 +686,7 @@ static int hpdi_detach(struct comedi_device * dev)
priv(dev)->
dio_buffer_phys_addr[i]);
}
- // free dma descriptors
+ /* free dma descriptors */
if (priv(dev)->dma_desc)
pci_free_consistent(priv(dev)->hw_dev,
sizeof(struct plx_dma_desc) *
@@ -706,7 +702,7 @@ static int hpdi_detach(struct comedi_device * dev)
return 0;
}
-static int dio_config_block_size(struct comedi_device * dev, unsigned int * data)
+static int dio_config_block_size(struct comedi_device *dev, unsigned int *data)
{
unsigned int requested_block_size;
int retval;
@@ -722,8 +718,8 @@ static int dio_config_block_size(struct comedi_device * dev, unsigned int * data
return 2;
}
-static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -761,7 +757,7 @@ static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
/* step 2: make sure trigger sources are unique and mutually compatible */
- // uniqueness check
+ /* uniqueness check */
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -807,7 +803,7 @@ static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
if (cmd->chanlist) {
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) != i) {
- // XXX could support 8 channels or 16 channels
+ /* XXX could support 8 channels or 16 channels */
comedi_error(dev,
"chanlist must be channels 0 to 31 in order");
err++;
@@ -822,8 +818,8 @@ static int di_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
return 0;
}
-static int hpdi_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
if (priv(dev)->dio_config_output) {
return -EINVAL;
@@ -831,14 +827,14 @@ static int hpdi_cmd_test(struct comedi_device * dev, struct comedi_subdevice * s
return di_cmd_test(dev, s, cmd);
}
-static inline void hpdi_writel(struct comedi_device * dev, uint32_t bits,
+static inline void hpdi_writel(struct comedi_device *dev, uint32_t bits,
unsigned int offset)
{
writel(bits | priv(dev)->bits[offset / sizeof(uint32_t)],
priv(dev)->hpdi_iobase + offset);
}
-static int di_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
uint32_t bits;
unsigned long flags;
@@ -860,28 +856,28 @@ static int di_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_TRANSFER_SIZE_REG);
writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG);
writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG);
- // give location of first dma descriptor
+ /* give location of first dma descriptor */
bits = priv(dev)->
dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
PLX_XFER_LOCAL_TO_PCI;
writel(bits, priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
- // spinlock for plx dma control/status reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
- // enable dma transfer
+ /* spinlock for plx dma control/status reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
+ /* enable dma transfer */
writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT,
priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
if (cmd->stop_src == TRIG_COUNT)
priv(dev)->dio_count = cmd->stop_arg;
else
priv(dev)->dio_count = 1;
- // clear over/under run status flags
+ /* clear over/under run status flags */
writel(RX_UNDERRUN_BIT | RX_OVERRUN_BIT,
priv(dev)->hpdi_iobase + BOARD_STATUS_REG);
- // enable interrupts
+ /* enable interrupts */
writel(intr_bit(RX_FULL_INTR),
priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
@@ -891,7 +887,7 @@ static int di_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int hpdi_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (priv(dev)->dio_config_output) {
return -EINVAL;
@@ -899,7 +895,7 @@ static int hpdi_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return di_cmd(dev, s);
}
-static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
+static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
{
struct comedi_async *async = dev->read_subdev->async;
uint32_t next_transfer_addr;
@@ -914,7 +910,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
pci_addr_reg =
priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
- // loop until we have read all the full buffers
+ /* loop until we have read all the full buffers */
j = 0;
for (next_transfer_addr = readl(pci_addr_reg);
(next_transfer_addr <
@@ -925,7 +921,7 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
dma_desc_index].pci_start_addr) +
priv(dev)->block_size)
&& j < priv(dev)->num_dma_descriptors; j++) {
- // transfer data from dma buffer to comedi buffer
+ /* transfer data from dma buffer to comedi buffer */
num_samples = priv(dev)->block_size / sizeof(uint32_t);
if (async->cmd.stop_src == TRIG_COUNT) {
if (num_samples > priv(dev)->dio_count)
@@ -942,10 +938,10 @@ static void drain_dma_buffers(struct comedi_device * dev, unsigned int channel)
priv(dev)->dma_desc[priv(dev)->dma_desc_index].next);
DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr);
}
- // XXX check for buffer overrun somehow
+ /* XXX check for buffer overrun somehow */
}
-static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t handle_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
@@ -975,10 +971,10 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
writel(hpdi_intr_status,
priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG);
}
- // spin lock makes sure noone else changes plx dma control reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spin lock makes sure noone else changes plx dma control reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
- if (plx_status & ICS_DMA0_A) { // dma chan 0 interrupt
+ if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */
writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
@@ -988,23 +984,23 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
}
DEBUG_PRINT(" cleared dma ch0 interrupt\n");
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // spin lock makes sure noone else changes plx dma control reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spin lock makes sure noone else changes plx dma control reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
- if (plx_status & ICS_DMA1_A) // XXX
- { // dma chan 1 interrupt
+ if (plx_status & ICS_DMA1_A) /* XXX */
+ { /* dma chan 1 interrupt */
writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
DEBUG_PRINT("dma1 status 0x%x\n", dma1_status);
DEBUG_PRINT(" cleared dma ch1 interrupt\n");
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // clear possible plx9080 interrupt sources
- if (plx_status & ICS_LDIA) { // clear local doorbell interrupt
+ /* clear possible plx9080 interrupt sources */
+ if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */
plx_bits = readl(priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG);
writel(plx_bits, priv(dev)->plx9080_iobase + PLX_DBR_OUT_REG);
DEBUG_PRINT(" cleared local doorbell bits 0x%x\n", plx_bits);
@@ -1036,19 +1032,19 @@ static irqreturn_t handle_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-void abort_dma(struct comedi_device * dev, unsigned int channel)
+void abort_dma(struct comedi_device *dev, unsigned int channel)
{
unsigned long flags;
- // spinlock for plx dma control/status reg
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* spinlock for plx dma control/status reg */
+ spin_lock_irqsave(&dev->spinlock, flags);
plx9080_abort_dma(priv(dev)->plx9080_iobase, channel);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
}
-static int hpdi_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
hpdi_writel(dev, 0, BOARD_CONTROL_REG);
diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c
index 15fce0190b2f..984f995149b6 100644
--- a/drivers/staging/comedi/drivers/icp_multi.c
+++ b/drivers/staging/comedi/drivers/icp_multi.c
@@ -50,6 +50,7 @@ Options:
[1] - PCI slot number
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -282,7 +283,7 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
#endif
- comedi_udelay(1);
+ udelay(1);
#ifdef ICP_MULTI_EXTDEBUG
printk("icp multi C n=%d ST=%4x\n", n,
@@ -304,7 +305,7 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
ICP_MULTI_ADC_CSR));
#endif
- comedi_udelay(1);
+ udelay(1);
}
/* If we reach here, a timeout has occurred */
@@ -411,7 +412,7 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
ICP_MULTI_DAC_CSR));
#endif
- comedi_udelay(1);
+ udelay(1);
}
/* If we reach here, a timeout has occurred */
@@ -618,7 +619,7 @@ static int icp_multi_insn_write_ctr(struct comedi_device *dev, struct comedi_sub
==============================================================================
*/
-static irqreturn_t interrupt_service_icp_multi(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
{
struct comedi_device *dev = d;
int int_no;
@@ -842,7 +843,7 @@ static int icp_multi_reset(struct comedi_device *dev)
devpriv->io_addr + ICP_MULTI_DAC_CSR);
/* Delay to allow DAC time to recover */
- comedi_udelay(1);
+ udelay(1);
}
/* Digital outputs to 0 */
writew(0, devpriv->io_addr + ICP_MULTI_DO);
@@ -954,7 +955,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
if (this_board->have_irq) {
if (irq) {
- if (comedi_request_irq(irq, interrupt_service_icp_multi,
+ if (request_irq(irq, interrupt_service_icp_multi,
IRQF_SHARED, "Inova Icp Multi", dev)) {
printk(", unable to allocate IRQ %u, DISABLING IT", irq);
irq = 0; /* Can't use IRQ */
@@ -1072,7 +1073,7 @@ static int icp_multi_detach(struct comedi_device *dev)
icp_multi_reset(dev);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->private && devpriv->io_addr)
iounmap(devpriv->io_addr);
diff --git a/drivers/staging/comedi/drivers/icp_multi.h b/drivers/staging/comedi/drivers/icp_multi.h
index 21d84766fea8..354ba8f14f81 100644
--- a/drivers/staging/comedi/drivers/icp_multi.h
+++ b/drivers/staging/comedi/drivers/icp_multi.h
@@ -168,14 +168,14 @@ static int pci_card_alloc(struct pcilst_struct *inova)
int i;
if (!inova) {
- rt_printk(" - BUG!! inova is NULL!\n");
+ printk(" - BUG!! inova is NULL!\n");
return -1;
}
if (inova->used)
return 1;
if (comedi_pci_enable(inova->pcidev, "icp_multi")) {
- rt_printk(" - Can't enable PCI device and request regions!\n");
+ printk(" - Can't enable PCI device and request regions!\n");
return -1;
}
/* Resources will be accurate now. */
@@ -248,19 +248,19 @@ static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
card = find_free_pci_card_by_device(vendor_id, device_id);
if (card == NULL) {
- rt_printk(" - Unused card not found in system!\n");
+ printk(" - Unused card not found in system!\n");
return NULL;
}
} else {
switch (find_free_pci_card_by_position(vendor_id, device_id,
pci_bus, pci_slot, &card)) {
case 1:
- rt_printk
+ printk
(" - Card not found on requested position b:s %d:%d!\n",
pci_bus, pci_slot);
return NULL;
case 2:
- rt_printk
+ printk
(" - Card on requested position is used b:s %d:%d!\n",
pci_bus, pci_slot);
return NULL;
@@ -270,7 +270,7 @@ static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
err = pci_card_alloc(card);
if (err != 0) {
if (err > 0)
- rt_printk(" - Can't allocate card!\n");
+ printk(" - Can't allocate card!\n");
/* else: error already printed. */
return NULL;
}
diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c
index 80825ba25418..a90d65fde31e 100644
--- a/drivers/staging/comedi/drivers/ii_pci20kc.c
+++ b/drivers/staging/comedi/drivers/ii_pci20kc.c
@@ -158,21 +158,21 @@ struct pci20xxx_private {
#define devpriv ((struct pci20xxx_private *)dev->private)
#define CHAN (CR_CHAN(it->chanlist[0]))
-static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pci20xxx_detach(struct comedi_device * dev);
+static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci20xxx_detach(struct comedi_device *dev);
static struct comedi_driver driver_pci20xxx = {
- driver_name:"ii_pci20kc",
- module:THIS_MODULE,
- attach:pci20xxx_attach,
- detach:pci20xxx_detach,
+ .driver_name = "ii_pci20kc",
+ .module = THIS_MODULE,
+ .attach = pci20xxx_attach,
+ .detach = pci20xxx_detach,
};
-static int pci20006_init(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
int opt0, int opt1);
-static int pci20341_init(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
int opt0, int opt1);
-static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice * s);
+static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice *s);
/*
options[0] Board base address
@@ -201,7 +201,7 @@ static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice
1 == unipolar 10V (0V -- +10V)
2 == bipolar 5V (-5V -- +5V)
*/
-static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned char i;
int ret;
@@ -209,9 +209,12 @@ static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig *
struct comedi_subdevice *s;
union pci20xxx_subdev_private *sdp;
- if ((ret = alloc_subdevices(dev, 1 + PCI20000_MODULES)) < 0)
+ ret = alloc_subdevices(dev, 1 + PCI20000_MODULES);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct pci20xxx_private))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct pci20xxx_private));
+ if (ret < 0)
return ret;
devpriv->ioaddr = (void *)(unsigned long)it->options[0];
@@ -263,7 +266,7 @@ static int pci20xxx_attach(struct comedi_device * dev, struct comedi_devconfig *
return 1;
}
-static int pci20xxx_detach(struct comedi_device * dev)
+static int pci20xxx_detach(struct comedi_device *dev)
{
printk("comedi%d: pci20xxx: remove\n", dev->minor);
@@ -272,10 +275,10 @@ static int pci20xxx_detach(struct comedi_device * dev)
/* pci20006m */
-static int pci20006_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pci20006_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static const struct comedi_lrange *pci20006_range_list[] = {
&range_bipolar10,
@@ -283,7 +286,7 @@ static const struct comedi_lrange *pci20006_range_list[] = {
&range_bipolar5,
};
-static int pci20006_init(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
int opt0, int opt1)
{
union pci20xxx_subdev_private *sdp = s->private;
@@ -308,8 +311,8 @@ static int pci20006_init(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int pci20006_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
union pci20xxx_subdev_private *sdp = s->private;
@@ -318,8 +321,8 @@ static int pci20006_insn_read(struct comedi_device * dev, struct comedi_subdevic
return 1;
}
-static int pci20006_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
union pci20xxx_subdev_private *sdp = s->private;
int hi, lo;
@@ -351,8 +354,8 @@ static int pci20006_insn_write(struct comedi_device * dev, struct comedi_subdevi
/* PCI20341M */
-static int pci20341_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 };
static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 };
@@ -368,7 +371,7 @@ static const struct comedi_lrange *const pci20341_ranges[] = {
&range_bipolar0_025,
};
-static int pci20341_init(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
int opt0, int opt1)
{
union pci20xxx_subdev_private *sdp = s->private;
@@ -399,8 +402,8 @@ static int pci20341_init(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int pci20341_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
union pci20xxx_subdev_private *sdp = s->private;
unsigned int i = 0, j = 0;
@@ -445,14 +448,14 @@ static int pci20341_insn_read(struct comedi_device * dev, struct comedi_subdevic
/* native DIO */
-static void pci20xxx_dio_config(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pci20xxx_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pci20xxx_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/* initialize struct pci20xxx_private */
-static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice *s)
{
s->type = COMEDI_SUBD_DIO;
@@ -471,8 +474,8 @@ static int pci20xxx_dio_init(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pci20xxx_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int mask, bits;
@@ -496,8 +499,8 @@ static int pci20xxx_dio_insn_config(struct comedi_device * dev, struct comedi_su
return 1;
}
-static int pci20xxx_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask = data[0];
@@ -526,7 +529,7 @@ static int pci20xxx_dio_insn_bits(struct comedi_device * dev, struct comedi_subd
return 2;
}
-static void pci20xxx_dio_config(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned char control_01;
unsigned char control_23;
@@ -582,7 +585,7 @@ static void pci20xxx_dio_config(struct comedi_device * dev, struct comedi_subdev
}
#if 0
-static void pci20xxx_do(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s)
{
/* XXX if the channel is configured for input, does this
do bad things? */
@@ -595,7 +598,7 @@ static void pci20xxx_do(struct comedi_device * dev, struct comedi_subdevice * s)
writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3);
}
-static unsigned int pci20xxx_di(struct comedi_device * dev, struct comedi_subdevice * s)
+static unsigned int pci20xxx_di(struct comedi_device *dev, struct comedi_subdevice *s)
{
/* XXX same note as above */
unsigned int bits;
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index a3c887f3b2c6..baf83c6a9412 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -48,69 +48,20 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
#include "comedi_pci.h"
#include "jr3_pci.h"
-/* Hotplug firmware loading stuff */
-
-static void comedi_fw_release(struct device *dev)
-{
- printk(KERN_DEBUG "firmware_sample_driver: ghost_release\n");
-}
-
-static struct device comedi_fw_device = {
- .init_name = "comedi",
- .release = comedi_fw_release
-};
-
-typedef int comedi_firmware_callback(struct comedi_device * dev,
- const u8 * data, size_t size);
-
-static int comedi_load_firmware(struct comedi_device * dev,
- char *name, comedi_firmware_callback cb)
-{
- int result = 0;
- const struct firmware *fw;
- char *firmware_path;
- static const char *prefix = "comedi/";
-
- firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL);
- if (!firmware_path) {
- result = -ENOMEM;
- } else {
- firmware_path[0] = '\0';
- strcat(firmware_path, prefix);
- strcat(firmware_path, name);
- result = device_register(&comedi_fw_device);
- if (result == 0) {
- result = request_firmware(&fw, firmware_path,
- &comedi_fw_device);
- if (result == 0) {
- if (!cb) {
- result = -EINVAL;
- } else {
- result = cb(dev, fw->data, fw->size);
- }
- release_firmware(fw);
- }
- device_unregister(&comedi_fw_device);
- }
- kfree(firmware_path);
- }
- return result;
-}
-
#define PCI_VENDOR_ID_JR3 0x1762
#define PCI_DEVICE_ID_JR3_1_CHANNEL 0x3111
#define PCI_DEVICE_ID_JR3_2_CHANNEL 0x3112
#define PCI_DEVICE_ID_JR3_3_CHANNEL 0x3113
#define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114
-static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int jr3_pci_detach(struct comedi_device * dev);
+static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int jr3_pci_detach(struct comedi_device *dev);
static struct comedi_driver driver_jr3_pci = {
- driver_name:"jr3_pci",
- module:THIS_MODULE,
- attach:jr3_pci_attach,
- detach:jr3_pci_detach,
+ .driver_name = "jr3_pci",
+ .module = THIS_MODULE,
+ .attach = jr3_pci_attach,
+ .detach = jr3_pci_detach,
};
static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
@@ -168,6 +119,41 @@ struct jr3_pci_subdev_private {
int retries;
};
+/* Hotplug firmware loading stuff */
+
+typedef int comedi_firmware_callback(struct comedi_device *dev,
+ const u8 *data, size_t size);
+
+static int comedi_load_firmware(struct comedi_device *dev, char *name,
+ comedi_firmware_callback cb)
+{
+ int result = 0;
+ const struct firmware *fw;
+ char *firmware_path;
+ static const char *prefix = "comedi/";
+ struct jr3_pci_dev_private *devpriv = dev->private;
+
+ firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL);
+ if (!firmware_path) {
+ result = -ENOMEM;
+ } else {
+ firmware_path[0] = '\0';
+ strcat(firmware_path, prefix);
+ strcat(firmware_path, name);
+ result = request_firmware(&fw, firmware_path,
+ &devpriv->pci_dev->dev);
+ if (result == 0) {
+ if (!cb)
+ result = -EINVAL;
+ else
+ result = cb(dev, fw->data, fw->size);
+ release_firmware(fw);
+ }
+ kfree(firmware_path);
+ }
+ return result;
+}
+
static struct poll_delay_t poll_delay_min_max(int min, int max)
{
struct poll_delay_t result;
@@ -194,15 +180,15 @@ static void set_transforms(volatile struct jr3_channel *channel,
{
int i;
- num &= 0x000f; // Make sure that 0 <= num <= 15
+ num &= 0x000f; /* Make sure that 0 <= num <= 15 */
for (i = 0; i < 8; i++) {
set_u16(&channel->transforms[num].link[i].link_type,
transf.link[i].link_type);
- comedi_udelay(1);
+ udelay(1);
set_s16(&channel->transforms[num].link[i].link_amount,
transf.link[i].link_amount);
- comedi_udelay(1);
+ udelay(1);
if (transf.link[i].link_type == end_x_form) {
break;
}
@@ -273,8 +259,8 @@ static struct six_axis_t get_max_full_scales(volatile struct jr3_channel *channe
return result;
}
-static int jr3_pci_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int result;
struct jr3_pci_subdev_private *p;
@@ -389,7 +375,7 @@ static int jr3_pci_ai_insn_read(struct comedi_device * dev, struct comedi_subdev
return result;
}
-static void jr3_pci_open(struct comedi_device * dev)
+static void jr3_pci_open(struct comedi_device *dev)
{
int i;
struct jr3_pci_dev_private *devpriv = dev->private;
@@ -406,14 +392,14 @@ static void jr3_pci_open(struct comedi_device * dev)
}
}
-int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val)
+int read_idm_word(const u8 *data, size_t size, int *pos, unsigned int *val)
{
int result = 0;
if (pos != 0 && val != 0) {
- // Skip over non hex
+ /* Skip over non hex */
for (; *pos < size && !isxdigit(data[*pos]); (*pos)++) {
}
- // Collect value
+ /* Collect value */
*val = 0;
for (; *pos < size && isxdigit(data[*pos]); (*pos)++) {
char ch = tolower(data[*pos]);
@@ -428,7 +414,7 @@ int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val)
return result;
}
-static int jr3_download_firmware(struct comedi_device * dev, const u8 * data,
+static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
size_t size)
{
/*
@@ -485,17 +471,17 @@ static int jr3_download_firmware(struct comedi_device * dev, const u8 * data,
count, addr);
while (more && count > 0) {
if (addr & 0x4000) {
- // 16 bit data, never seen in real life!!
+ /* 16 bit data, never seen in real life!! */
unsigned int data1;
more = more
&& read_idm_word(data,
size, &pos, &data1);
count--;
- // printk("jr3_data, not tested\n");
- // jr3[addr + 0x20000 * pnum] = data1;
+ /* printk("jr3_data, not tested\n"); */
+ /* jr3[addr + 0x20000 * pnum] = data1; */
} else {
- // Download 24 bit program
+ /* Download 24 bit program */
unsigned int data1, data2;
more = more
@@ -510,12 +496,12 @@ static int jr3_download_firmware(struct comedi_device * dev, const u8 * data,
channel[i].
program_low
[addr], data1);
- comedi_udelay(1);
+ udelay(1);
set_u16(&p->iobase->
channel[i].
program_high
[addr], data2);
- comedi_udelay(1);
+ udelay(1);
}
}
@@ -527,7 +513,7 @@ static int jr3_download_firmware(struct comedi_device * dev, const u8 * data,
return result;
}
-static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
+static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
{
struct poll_delay_t result = poll_delay_min_max(1000, 2000);
struct jr3_pci_subdev_private *p = s->private;
@@ -541,7 +527,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
p->errors = errors;
}
if (errors & (watch_dog | watch_dog2 | sensor_change)) {
- // Sensor communication lost, force poll mode
+ /* Sensor communication lost, force poll mode */
p->state = state_jr3_poll;
}
@@ -551,9 +537,10 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
u16 serial_no = get_u16(&channel->serial_no);
if ((errors & (watch_dog | watch_dog2)) ||
model_no == 0 || serial_no == 0) {
- // Still no sensor, keep on polling. Since it takes up to
- // 10 seconds for offsets to stabilize, polling each
- // second should suffice.
+/*
+ * Still no sensor, keep on polling. Since it takes up to 10 seconds
+ * for offsets to stabilize, polling each second should suffice.
+ */
result = poll_delay_min_max(1000, 2000);
} else {
p->retries = 0;
@@ -566,7 +553,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
case state_jr3_init_wait_for_offset:{
p->retries++;
if (p->retries < 10) {
- // Wait for offeset to stabilize (< 10 s according to manual)
+ /* Wait for offeset to stabilize (< 10 s according to manual) */
result = poll_delay_min_max(1000, 2000);
} else {
struct transform_t transf;
@@ -582,7 +569,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
printk("Sensor Serial = %i\n",
p->serial_no);
- // Transformation all zeros
+ /* Transformation all zeros */
transf.link[0].link_type =
(enum link_types)0;
transf.link[0].link_amount = 0;
@@ -600,7 +587,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
use_transform(channel, 0);
p->state =
state_jr3_init_transform_complete;
- result = poll_delay_min_max(20, 100); // Allow 20 ms for completion
+ result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */
}
} break;
case state_jr3_init_transform_complete:{
@@ -608,7 +595,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
printk("state_jr3_init_transform_complete complete = %d\n", is_complete(channel));
result = poll_delay_min_max(20, 100);
} else {
- // Set full scale
+ /* Set full scale */
struct six_axis_t min_full_scale;
struct six_axis_t max_full_scale;
@@ -639,7 +626,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
p->state =
state_jr3_init_set_full_scale_complete;
- result = poll_delay_min_max(20, 100); // Allow 20 ms for completion
+ result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */
}
}
break;
@@ -650,7 +637,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
} else {
volatile struct force_array *full_scale;
- // Use ranges in kN or we will overflow arount 2000N!
+ /* Use ranges in kN or we will overflow arount 2000N! */
full_scale = &channel->full_scale;
p->range[0].range.min =
-get_s16(&full_scale->fx) *
@@ -679,10 +666,10 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
-get_s16(&full_scale->mz) * 100;
p->range[5].range.max =
get_s16(&full_scale->mz) * 100;
- p->range[6].range.min = -get_s16(&full_scale->v1) * 100; // ??
- p->range[6].range.max = get_s16(&full_scale->v1) * 100; // ??
- p->range[7].range.min = -get_s16(&full_scale->v2) * 100; // ??
- p->range[7].range.max = get_s16(&full_scale->v2) * 100; // ??
+ p->range[6].range.min = -get_s16(&full_scale->v1) * 100; /* ?? */
+ p->range[6].range.max = get_s16(&full_scale->v1) * 100; /* ?? */
+ p->range[7].range.min = -get_s16(&full_scale->v2) * 100; /* ?? */
+ p->range[7].range.max = get_s16(&full_scale->v2) * 100; /* ?? */
p->range[8].range.min = 0;
p->range[8].range.max = 65535;
@@ -701,7 +688,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice * s)
use_offset(channel, 0);
p->state =
state_jr3_init_use_offset_complete;
- result = poll_delay_min_max(40, 100); // Allow 40 ms for completion
+ result = poll_delay_min_max(40, 100); /* Allow 40 ms for completion */
}
}
break;
@@ -747,10 +734,10 @@ static void jr3_pci_poll_dev(unsigned long data)
int delay;
int i;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
delay = 1000;
now = jiffies;
- // Poll all channels that are ready to be polled
+ /* Poll all channels that are ready to be polled */
for (i = 0; i < devpriv->n_channels; i++) {
struct jr3_pci_subdev_private *subdevpriv = dev->subdevices[i].private;
if (now > subdevpriv->next_time_min) {
@@ -762,19 +749,21 @@ static void jr3_pci_poll_dev(unsigned long data)
subdevpriv->next_time_max =
jiffies + msecs_to_jiffies(sub_delay.max);
if (sub_delay.max && sub_delay.max < delay) {
- // Wake up as late as possible -> poll as many channels as
- // possible at once
+/*
+* Wake up as late as possible -> poll as many channels as possible
+* at once
+*/
delay = sub_delay.max;
}
}
}
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
devpriv->timer.expires = jiffies + msecs_to_jiffies(delay);
add_timer(&devpriv->timer);
}
-static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int result = 0;
struct pci_dev *card = NULL;
@@ -845,9 +834,12 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
devpriv->pci_dev = card;
dev->board_name = "jr3_pci";
}
- if ((result = comedi_pci_enable(card, "jr3_pci")) < 0) {
+
+ result = comedi_pci_enable(card, "jr3_pci");
+ if (result < 0) {
return -EIO;
}
+
devpriv->pci_enabled = 1;
devpriv->iobase = ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
result = alloc_subdevices(dev, devpriv->n_channels);
@@ -881,7 +873,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
p->range[j].range.max = 1000000;
for (k = 0; k < 7; k++) {
p->range_table_list[j + k * 8] =
- (struct comedi_lrange *) & p->range[j];
+ (struct comedi_lrange *) &p->range[j];
p->maxdata_list[j + k * 8] = 0x7fff;
}
}
@@ -890,12 +882,12 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
p->range[8].range.max = 65536;
p->range_table_list[56] =
- (struct comedi_lrange *) & p->range[8];
+ (struct comedi_lrange *) &p->range[8];
p->range_table_list[57] =
- (struct comedi_lrange *) & p->range[8];
+ (struct comedi_lrange *) &p->range[8];
p->maxdata_list[56] = 0xffff;
p->maxdata_list[57] = 0xffff;
- // Channel specific range and maxdata
+ /* Channel specific range and maxdata */
dev->subdevices[i].range_table = 0;
dev->subdevices[i].range_table_list =
p->range_table_list;
@@ -904,7 +896,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
}
}
- // Reset DSP card
+ /* Reset DSP card */
devpriv->iobase->channel[0].reset = 0;
result = comedi_load_firmware(dev, "jr3pci.idm", jr3_download_firmware);
@@ -913,13 +905,18 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
if (result < 0) {
goto out;
}
- // TODO: use firmware to load preferred offset tables. Suggested format:
- // model serial Fx Fy Fz Mx My Mz\n
- //
- // comedi_load_firmware(dev, "jr3_offsets_table", jr3_download_firmware);
+/*
+ * TODO: use firmware to load preferred offset tables. Suggested
+ * format:
+ * model serial Fx Fy Fz Mx My Mz\n
+ *
+ * comedi_load_firmware(dev, "jr3_offsets_table", jr3_download_firmware);
+ */
- // It takes a few milliseconds for software to settle
- // as much as we can read firmware version
+/*
+ * It takes a few milliseconds for software to settle as much as we
+ * can read firmware version
+ */
msleep_interruptible(25);
for (i = 0; i < 0x18; i++) {
printk("%c",
@@ -927,7 +924,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
copyright[i]) >> 8);
}
- // Start card timer
+ /* Start card timer */
for (i = 0; i < devpriv->n_channels; i++) {
struct jr3_pci_subdev_private *p = dev->subdevices[i].private;
@@ -944,7 +941,7 @@ static int jr3_pci_attach(struct comedi_device * dev, struct comedi_devconfig *
return result;
}
-static int jr3_pci_detach(struct comedi_device * dev)
+static int jr3_pci_detach(struct comedi_device *dev)
{
int i;
struct jr3_pci_dev_private *devpriv = dev->private;
diff --git a/drivers/staging/comedi/drivers/jr3_pci.h b/drivers/staging/comedi/drivers/jr3_pci.h
index 3585f2941bca..4f4bfb24c6d6 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.h
+++ b/drivers/staging/comedi/drivers/jr3_pci.h
@@ -2,22 +2,22 @@
* is 16 bits, but aligned on a 32 bit PCI boundary
*/
-static inline u16 get_u16(volatile const u32 * p)
+static inline u16 get_u16(volatile const u32 *p)
{
return (u16) readl(p);
}
-static inline void set_u16(volatile u32 * p, u16 val)
+static inline void set_u16(volatile u32 *p, u16 val)
{
writel(val, p);
}
-static inline s16 get_s16(volatile const s32 * p)
+static inline s16 get_s16(volatile const s32 *p)
{
return (s16) readl(p);
}
-static inline void set_s16(volatile s32 * p, s16 val)
+static inline void set_s16(volatile s32 *p, s16 val)
{
writel(val, p);
}
diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c
index 79f6fe5646c5..b49aed5c4a02 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -48,8 +48,8 @@ Kolter Electronic PCI Counter Card.
/*-- function prototypes ----------------------------------------------------*/
-static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int cnt_detach(struct comedi_device * dev);
+static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int cnt_detach(struct comedi_device *dev);
static DEFINE_PCI_DEVICE_TABLE(cnt_pci_table) = {
{PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
@@ -72,10 +72,10 @@ struct cnt_board_struct {
static const struct cnt_board_struct cnt_boards[] = {
{
- name: CNT_DRIVER_NAME,
- device_id:CNT_CARD_DEVICE_ID,
- cnt_channel_nbr:3,
- cnt_bits:24}
+ .name = CNT_DRIVER_NAME,
+ .device_id = CNT_CARD_DEVICE_ID,
+ .cnt_channel_nbr = 3,
+ .cnt_bits = 24}
};
#define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct))
@@ -91,10 +91,10 @@ struct cnt_device_private {
#define devpriv ((struct cnt_device_private *)dev->private)
static struct comedi_driver cnt_driver = {
- driver_name:CNT_DRIVER_NAME,
- module:THIS_MODULE,
- attach:cnt_attach,
- detach:cnt_detach,
+ .driver_name = CNT_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = cnt_attach,
+ .detach = cnt_detach,
};
COMEDI_PCI_INITCLEANUP(cnt_driver, cnt_pci_table);
@@ -103,8 +103,8 @@ COMEDI_PCI_INITCLEANUP(cnt_driver, cnt_pci_table);
/* This should be used only for resetting the counters; maybe it is better
to make a special command 'reset'. */
-static int cnt_winsn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int cnt_winsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
@@ -123,8 +123,8 @@ static int cnt_winsn(struct comedi_device * dev,
/*-- counter read -----------------------------------------------------------*/
-static int cnt_rinsn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int cnt_rinsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
unsigned char a0, a1, a2, a3, a4;
int chan = CR_CHAN(insn->chanspec);
@@ -148,7 +148,7 @@ static int cnt_rinsn(struct comedi_device * dev,
/*-- attach -----------------------------------------------------------------*/
-static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *subdevice;
struct pci_dev *pci_device;
@@ -157,9 +157,9 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it)
int error, i;
/* allocate device private structure */
- if ((error = alloc_private(dev, sizeof(struct cnt_device_private))) < 0) {
+ error = alloc_private(dev, sizeof(struct cnt_device_private));
+ if (error < 0)
return error;
- }
/* Probe the device to determine what device in the series it is. */
for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
@@ -203,7 +203,8 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it)
dev->board_name = board->name;
/* enable PCI device and request regions */
- if ((error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME)) < 0) {
+ error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME);
+ if (error < 0) {
printk("comedi%d: failed to enable PCI device and request regions!\n", dev->minor);
return error;
}
@@ -213,9 +214,9 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it)
dev->iobase = io_base;
/* allocate the subdevice structures */
- if ((error = alloc_subdevices(dev, 1)) < 0) {
+ error = alloc_subdevices(dev, 1);
+ if (error < 0)
return error;
- }
subdevice = dev->subdevices + 0;
dev->read_subdev = subdevice;
@@ -227,10 +228,10 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it)
subdevice->insn_read = cnt_rinsn;
subdevice->insn_write = cnt_winsn;
- // select 20MHz clock
+ /* select 20MHz clock */
outb(3, dev->iobase + 248);
- // reset all counters
+ /* reset all counters */
outb(0, dev->iobase);
outb(0, dev->iobase + 0x20);
outb(0, dev->iobase + 0x40);
@@ -241,7 +242,7 @@ static int cnt_attach(struct comedi_device * dev, struct comedi_devconfig * it)
/*-- detach -----------------------------------------------------------------*/
-static int cnt_detach(struct comedi_device * dev)
+static int cnt_detach(struct comedi_device *dev)
{
if (devpriv && devpriv->pcidev) {
if (dev->iobase) {
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index 12481a032b9f..236845871735 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -51,6 +51,7 @@ broken.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -113,7 +114,7 @@ static const struct me4000_board me4000_boards[] = {
{0},
};
-#define ME4000_BOARD_VERSIONS (sizeof(me4000_boards) / sizeof(struct me4000_board) - 1)
+#define ME4000_BOARD_VERSIONS (ARRAY_SIZE(me4000_boards) - 1)
/*-----------------------------------------------------------------------------
Comedi function prototypes
@@ -183,7 +184,7 @@ static int ai_prepare(struct comedi_device *dev,
static int ai_write_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd);
-static irqreturn_t me4000_ai_isr(int irq, void *dev_id PT_REGS_ARG);
+static irqreturn_t me4000_ai_isr(int irq, void *dev_id);
static int me4000_ai_do_cmd_test(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd);
@@ -283,7 +284,7 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->insn_read = me4000_ai_insn_read;
if (info->irq > 0) {
- if (comedi_request_irq(info->irq, me4000_ai_isr,
+ if (request_irq(info->irq, me4000_ai_isr,
IRQF_SHARED, "ME-4000", dev)) {
printk("comedi%d: me4000: me4000_attach(): Unable to allocate irq\n", dev->minor);
} else {
@@ -1740,7 +1741,7 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
return 0;
}
-static irqreturn_t me4000_ai_isr(int irq, void *dev_id PT_REGS_ARG)
+static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
{
unsigned int tmp;
struct comedi_device *dev = dev_id;
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c
index 0f023d009e61..f21cecaa2e09 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -50,6 +50,7 @@ from http://www.comedi.org
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "comedi_pci.h"
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index ae9017744537..22a4029c30b5 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -258,7 +258,7 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
struct mite_channel *channel = NULL;
/* spin lock so mite_release_channel can be called safely from interrupts */
- comedi_spin_lock_irqsave(&mite->lock, flags);
+ spin_lock_irqsave(&mite->lock, flags);
for (i = min_channel; i <= max_channel; ++i) {
if (mite->channel_allocated[i] == 0) {
mite->channel_allocated[i] = 1;
@@ -267,7 +267,7 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
break;
}
}
- comedi_spin_unlock_irqrestore(&mite->lock, flags);
+ spin_unlock_irqrestore(&mite->lock, flags);
return channel;
}
@@ -277,7 +277,7 @@ void mite_release_channel(struct mite_channel *mite_chan)
unsigned long flags;
/* spin lock to prevent races with mite_request_channel */
- comedi_spin_lock_irqsave(&mite->lock, flags);
+ spin_lock_irqsave(&mite->lock, flags);
if (mite->channel_allocated[mite_chan->channel]) {
mite_dma_disarm(mite_chan);
mite_dma_reset(mite_chan);
@@ -292,7 +292,7 @@ MITE_CHCR reg isn't changed while dma is still active!) */
mite_chan->ring = NULL;
mmiowb();
}
- comedi_spin_unlock_irqrestore(&mite->lock, flags);
+ spin_unlock_irqrestore(&mite->lock, flags);
}
void mite_dma_arm(struct mite_channel *mite_chan)
@@ -307,11 +307,11 @@ void mite_dma_arm(struct mite_channel *mite_chan)
smp_mb();
/* arm */
chor = CHOR_START;
- comedi_spin_lock_irqsave(&mite->lock, flags);
+ spin_lock_irqsave(&mite->lock, flags);
mite_chan->done = 0;
writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
mmiowb();
- comedi_spin_unlock_irqrestore(&mite->lock, flags);
+ spin_unlock_irqrestore(&mite->lock, flags);
/* mite_dma_tcr(mite, channel); */
}
@@ -413,7 +413,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
mcr |= CR_PSIZE32;
break;
default:
- rt_printk
+ printk
("mite: bug! invalid mem bit width for dma transfer\n");
break;
}
@@ -433,7 +433,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
dcr |= CR_PSIZE32;
break;
default:
- rt_printk
+ printk
("mite: bug! invalid dev bit width for dma transfer\n");
break;
}
@@ -539,7 +539,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * as
nbytes = mite_bytes_written_to_memory_lb(mite_chan);
if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
old_alloc_count) > 0) {
- rt_printk("mite: DMA overwrite of free area\n");
+ printk("mite: DMA overwrite of free area\n");
async->events |= COMEDI_CB_OVERFLOW;
return -1;
}
@@ -581,7 +581,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async * a
(int)(nbytes_ub - stop_count) > 0)
nbytes_ub = stop_count;
if ((int)(nbytes_ub - old_alloc_count) > 0) {
- rt_printk("mite: DMA underrun\n");
+ printk("mite: DMA underrun\n");
async->events |= COMEDI_CB_OVERFLOW;
return -1;
}
@@ -602,7 +602,7 @@ unsigned mite_get_status(struct mite_channel *mite_chan)
unsigned status;
unsigned long flags;
- comedi_spin_lock_irqsave(&mite->lock, flags);
+ spin_lock_irqsave(&mite->lock, flags);
status = readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel));
if (status & CHSR_DONE) {
mite_chan->done = 1;
@@ -610,7 +610,7 @@ unsigned mite_get_status(struct mite_channel *mite_chan)
mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
}
mmiowb();
- comedi_spin_unlock_irqrestore(&mite->lock, flags);
+ spin_unlock_irqrestore(&mite->lock, flags);
return status;
}
@@ -621,9 +621,9 @@ int mite_done(struct mite_channel *mite_chan)
int done;
mite_get_status(mite_chan);
- comedi_spin_lock_irqsave(&mite->lock, flags);
+ spin_lock_irqsave(&mite->lock, flags);
done = mite_chan->done;
- comedi_spin_unlock_irqrestore(&mite->lock, flags);
+ spin_unlock_irqrestore(&mite->lock, flags);
return done;
}
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index cdaf8a31688a..31942319aa38 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -405,7 +405,7 @@ static inline int CR_RL(unsigned int retry_limit)
value++;
}
if (value > 0x7)
- rt_printk("comedi: bug! retry_limit too large\n");
+ printk("comedi: bug! retry_limit too large\n");
return (value & 0x7) << 21;
}
diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c
index a151602929d9..4a0e647f631a 100644
--- a/drivers/staging/comedi/drivers/mpc624.c
+++ b/drivers/staging/comedi/drivers/mpc624.c
@@ -61,19 +61,19 @@ Configuration Options:
#include <linux/ioport.h>
#include <linux/delay.h>
-// Consecutive I/O port addresses
+/* Consecutive I/O port addresses */
#define MPC624_SIZE 16
-// Offsets of different ports
-#define MPC624_MASTER_CONTROL 0 // not used
-#define MPC624_GNMUXCH 1 // Gain, Mux, Channel of ADC
-#define MPC624_ADC 2 // read/write to/from ADC
-#define MPC624_EE 3 // read/write to/from serial EEPROM via I2C
-#define MPC624_LEDS 4 // write to LEDs
-#define MPC624_DIO 5 // read/write to/from digital I/O ports
-#define MPC624_IRQ_MASK 6 // IRQ masking enable/disable
+/* Offsets of different ports */
+#define MPC624_MASTER_CONTROL 0 /* not used */
+#define MPC624_GNMUXCH 1 /* Gain, Mux, Channel of ADC */
+#define MPC624_ADC 2 /* read/write to/from ADC */
+#define MPC624_EE 3 /* read/write to/from serial EEPROM via I2C */
+#define MPC624_LEDS 4 /* write to LEDs */
+#define MPC624_DIO 5 /* read/write to/from digital I/O ports */
+#define MPC624_IRQ_MASK 6 /* IRQ masking enable/disable */
-// Register bits' names
+/* Register bits' names */
#define MPC624_ADBUSY (1<<5)
#define MPC624_ADSDO (1<<4)
#define MPC624_ADFO (1<<3)
@@ -81,19 +81,19 @@ Configuration Options:
#define MPC624_ADSCK (1<<1)
#define MPC624_ADSDI (1<<0)
-// SDI Speed/Resolution Programming bits
+/* SDI Speed/Resolution Programming bits */
#define MPC624_OSR4 (1<<31)
#define MPC624_OSR3 (1<<30)
#define MPC624_OSR2 (1<<29)
#define MPC624_OSR1 (1<<28)
#define MPC624_OSR0 (1<<27)
-// 32-bit output value bits' names
+/* 32-bit output value bits' names */
#define MPC624_EOC_BIT (1<<31)
#define MPC624_DMY_BIT (1<<30)
#define MPC624_SGN_BIT (1<<29)
-// Convertion speeds
+/* Convertion speeds */
/* OSR4 OSR3 OSR2 OSR1 OSR0 Convertion rate RMS noise ENOB^
* X 0 0 0 1 3.52kHz 23uV 17
* X 0 0 1 0 1.76kHz 3.5uV 20
@@ -110,123 +110,123 @@ Configuration Options:
*/
#define MPC624_SPEED_3_52_kHz (MPC624_OSR4 | MPC624_OSR0)
-#define MPC624_SPEED_1_76_kHz (MPC624_OSR4 | MPC624_OSR1 )
+#define MPC624_SPEED_1_76_kHz (MPC624_OSR4 | MPC624_OSR1)
#define MPC624_SPEED_880_Hz (MPC624_OSR4 | MPC624_OSR1 | MPC624_OSR0)
-#define MPC624_SPEED_440_Hz (MPC624_OSR4 | MPC624_OSR2 )
+#define MPC624_SPEED_440_Hz (MPC624_OSR4 | MPC624_OSR2)
#define MPC624_SPEED_220_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR0)
-#define MPC624_SPEED_110_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1 )
+#define MPC624_SPEED_110_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1)
#define MPC624_SPEED_55_Hz (MPC624_OSR4 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0)
-#define MPC624_SPEED_27_5_Hz (MPC624_OSR4 | MPC624_OSR3 )
+#define MPC624_SPEED_27_5_Hz (MPC624_OSR4 | MPC624_OSR3)
#define MPC624_SPEED_13_75_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR0)
#define MPC624_SPEED_6_875_Hz (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0)
-//----------------------------------------------------------------------------
+/* ---------------------------------------------------------------------------- */
struct skel_private {
- unsigned long int ulConvertionRate; // set by mpc624_attach() from driver's parameters
+ unsigned long int ulConvertionRate; /* set by mpc624_attach() from driver's parameters */
};
#define devpriv ((struct skel_private *)dev->private)
-//----------------------------------------------------------------------------
+/* ---------------------------------------------------------------------------- */
static const struct comedi_lrange range_mpc624_bipolar1 = {
1,
{
-// BIP_RANGE(1.01) // this is correct,
- // but my MPC-624 actually seems to have a range of 2.02
+/* BIP_RANGE(1.01) this is correct, */
+ /* but my MPC-624 actually seems to have a range of 2.02 */
BIP_RANGE(2.02)
}
};
static const struct comedi_lrange range_mpc624_bipolar10 = {
1,
{
-// BIP_RANGE(10.1) // this is correct,
- // but my MPC-624 actually seems to have a range of 20.2
+/* BIP_RANGE(10.1) this is correct, */
+ /* but my MPC-624 actually seems to have a range of 20.2 */
BIP_RANGE(20.2)
}
};
-//----------------------------------------------------------------------------
-static int mpc624_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int mpc624_detach(struct comedi_device * dev);
-//----------------------------------------------------------------------------
+/* ---------------------------------------------------------------------------- */
+static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int mpc624_detach(struct comedi_device *dev);
+/* ---------------------------------------------------------------------------- */
static struct comedi_driver driver_mpc624 = {
- driver_name:"mpc624",
- module:THIS_MODULE,
- attach:mpc624_attach,
- detach:mpc624_detach
+ .driver_name = "mpc624",
+ .module = THIS_MODULE,
+ .attach = mpc624_attach,
+ .detach = mpc624_detach
};
-//----------------------------------------------------------------------------
-static int mpc624_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-//----------------------------------------------------------------------------
-static int mpc624_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+/* ---------------------------------------------------------------------------- */
+static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+/* ---------------------------------------------------------------------------- */
+static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
iobase = it->options[0];
- rt_printk("comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase);
+ printk("comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase);
if (request_region(iobase, MPC624_SIZE, "mpc624") == NULL) {
- rt_printk("I/O port(s) in use\n");
+ printk("I/O port(s) in use\n");
return -EIO;
}
dev->iobase = iobase;
dev->board_name = "mpc624";
- // Private structure initialization
+ /* Private structure initialization */
if (alloc_private(dev, sizeof(struct skel_private)) < 0)
return -ENOMEM;
switch (it->options[1]) {
case 0:
devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
- rt_printk("3.52 kHz, ");
+ printk("3.52 kHz, ");
break;
case 1:
devpriv->ulConvertionRate = MPC624_SPEED_1_76_kHz;
- rt_printk("1.76 kHz, ");
+ printk("1.76 kHz, ");
break;
case 2:
devpriv->ulConvertionRate = MPC624_SPEED_880_Hz;
- rt_printk("880 Hz, ");
+ printk("880 Hz, ");
break;
case 3:
devpriv->ulConvertionRate = MPC624_SPEED_440_Hz;
- rt_printk("440 Hz, ");
+ printk("440 Hz, ");
break;
case 4:
devpriv->ulConvertionRate = MPC624_SPEED_220_Hz;
- rt_printk("220 Hz, ");
+ printk("220 Hz, ");
break;
case 5:
devpriv->ulConvertionRate = MPC624_SPEED_110_Hz;
- rt_printk("110 Hz, ");
+ printk("110 Hz, ");
break;
case 6:
devpriv->ulConvertionRate = MPC624_SPEED_55_Hz;
- rt_printk("55 Hz, ");
+ printk("55 Hz, ");
break;
case 7:
devpriv->ulConvertionRate = MPC624_SPEED_27_5_Hz;
- rt_printk("27.5 Hz, ");
+ printk("27.5 Hz, ");
break;
case 8:
devpriv->ulConvertionRate = MPC624_SPEED_13_75_Hz;
- rt_printk("13.75 Hz, ");
+ printk("13.75 Hz, ");
break;
case 9:
devpriv->ulConvertionRate = MPC624_SPEED_6_875_Hz;
- rt_printk("6.875 Hz, ");
+ printk("6.875 Hz, ");
break;
default:
- rt_printk
+ printk
("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
}
- // Subdevices structures
+ /* Subdevices structures */
if (alloc_subdevices(dev, 1) < 0)
return -ENOMEM;
@@ -237,29 +237,29 @@ static int mpc624_attach(struct comedi_device * dev, struct comedi_devconfig * i
switch (it->options[1]) {
default:
s->maxdata = 0x3FFFFFFF;
- rt_printk("30 bit, ");
+ printk("30 bit, ");
}
switch (it->options[1]) {
case 0:
s->range_table = &range_mpc624_bipolar1;
- rt_printk("1.01V]: ");
+ printk("1.01V]: ");
break;
default:
s->range_table = &range_mpc624_bipolar10;
- rt_printk("10.1V]: ");
+ printk("10.1V]: ");
}
s->len_chanlist = 1;
s->insn_read = mpc624_ai_rinsn;
- rt_printk("attached\n");
+ printk("attached\n");
return 1;
}
-static int mpc624_detach(struct comedi_device * dev)
+static int mpc624_detach(struct comedi_device *dev)
{
- rt_printk("comedi%d: mpc624: remove\n", dev->minor);
+ printk("comedi%d: mpc624: remove\n", dev->minor);
if (dev->iobase)
release_region(dev->iobase, MPC624_SIZE);
@@ -267,119 +267,119 @@ static int mpc624_detach(struct comedi_device * dev)
return 0;
}
-// Timeout 200ms
+/* Timeout 200ms */
#define TIMEOUT 200
-static int mpc624_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
unsigned long int data_in, data_out;
unsigned char ucPort;
- // WARNING: We always write 0 to GNSWA bit, so the channel range is +-/10.1Vdc
+ /* WARNING: We always write 0 to GNSWA bit, so the channel range is +-/10.1Vdc */
outb(insn->chanspec, dev->iobase + MPC624_GNMUXCH);
-// rt_printk("Channel %d: \n", insn->chanspec);
+/* printk("Channel %d: \n", insn->chanspec); */
if (!insn->n) {
- rt_printk("MPC624: Warning, no data to aquire\n");
+ printk("MPC624: Warning, no data to aquire\n");
return 0;
}
for (n = 0; n < insn->n; n++) {
- // Trigger the convertion
+ /* Trigger the convertion */
outb(MPC624_ADSCK, dev->iobase + MPC624_ADC);
- comedi_udelay(1);
+ udelay(1);
outb(MPC624_ADCS | MPC624_ADSCK, dev->iobase + MPC624_ADC);
- comedi_udelay(1);
+ udelay(1);
outb(0, dev->iobase + MPC624_ADC);
- comedi_udelay(1);
+ udelay(1);
- // Wait for the convertion to end
+ /* Wait for the convertion to end */
for (i = 0; i < TIMEOUT; i++) {
ucPort = inb(dev->iobase + MPC624_ADC);
if (ucPort & MPC624_ADBUSY)
- comedi_udelay(1000);
+ udelay(1000);
else
break;
}
if (i == TIMEOUT) {
- rt_printk("MPC624: timeout (%dms)\n", TIMEOUT);
+ printk("MPC624: timeout (%dms)\n", TIMEOUT);
data[n] = 0;
return -ETIMEDOUT;
}
- // Start reading data
+ /* Start reading data */
data_in = 0;
data_out = devpriv->ulConvertionRate;
- comedi_udelay(1);
+ udelay(1);
for (i = 0; i < 32; i++) {
- // Set the clock low
+ /* Set the clock low */
outb(0, dev->iobase + MPC624_ADC);
- comedi_udelay(1);
+ udelay(1);
- if (data_out & (1 << 31)) // the next bit is a 1
+ if (data_out & (1 << 31)) /* the next bit is a 1 */
{
- // Set the ADSDI line (send to MPC624)
+ /* Set the ADSDI line (send to MPC624) */
outb(MPC624_ADSDI, dev->iobase + MPC624_ADC);
- comedi_udelay(1);
- // Set the clock high
+ udelay(1);
+ /* Set the clock high */
outb(MPC624_ADSCK | MPC624_ADSDI,
dev->iobase + MPC624_ADC);
- } else // the next bit is a 0
+ } else /* the next bit is a 0 */
{
- // Set the ADSDI line (send to MPC624)
+ /* Set the ADSDI line (send to MPC624) */
outb(0, dev->iobase + MPC624_ADC);
- comedi_udelay(1);
- // Set the clock high
+ udelay(1);
+ /* Set the clock high */
outb(MPC624_ADSCK, dev->iobase + MPC624_ADC);
}
- // Read ADSDO on high clock (receive from MPC624)
- comedi_udelay(1);
+ /* Read ADSDO on high clock (receive from MPC624) */
+ udelay(1);
data_in <<= 1;
data_in |=
(inb(dev->iobase +
MPC624_ADC) & MPC624_ADSDO) >> 4;
- comedi_udelay(1);
+ udelay(1);
data_out <<= 1;
}
- // Received 32-bit long value consist of:
- // 31: EOC (End Of Transmission) bit - should be 0
- // 30: DMY (Dummy) bit - should be 0
- // 29: SIG (Sign) bit - 1 if the voltage is positive, 0 if negative
- // 28: MSB (Most Significant Bit) - the first bit of convertion result
- // ....
- // 05: LSB (Least Significant Bit) - the last bit of convertion result
- // 04: sub-LSB - sub-LSBs are basically noise, but when
- // 03: sub-LSB averaged properly, they can increase convertion
- // 02: sub-LSB precision up to 29 bits; they can be discarded
- // 01: sub-LSB without loss of resolution.
- // 00: sub-LSB
+ /* Received 32-bit long value consist of: */
+ /* 31: EOC (End Of Transmission) bit - should be 0 */
+ /* 30: DMY (Dummy) bit - should be 0 */
+ /* 29: SIG (Sign) bit - 1 if the voltage is positive, 0 if negative */
+ /* 28: MSB (Most Significant Bit) - the first bit of convertion result */
+ /* .... */
+ /* 05: LSB (Least Significant Bit) - the last bit of convertion result */
+ /* 04: sub-LSB - sub-LSBs are basically noise, but when */
+ /* 03: sub-LSB averaged properly, they can increase convertion */
+ /* 02: sub-LSB precision up to 29 bits; they can be discarded */
+ /* 01: sub-LSB without loss of resolution. */
+ /* 00: sub-LSB */
if (data_in & MPC624_EOC_BIT)
- rt_printk("MPC624: EOC bit is set (data_in=%lu)!",
+ printk("MPC624: EOC bit is set (data_in=%lu)!",
data_in);
if (data_in & MPC624_DMY_BIT)
- rt_printk("MPC624: DMY bit is set (data_in=%lu)!",
+ printk("MPC624: DMY bit is set (data_in=%lu)!",
data_in);
- if (data_in & MPC624_SGN_BIT) // check the sign bit
- { // The voltage is positive
- data_in &= 0x3FFFFFFF; // EOC and DMY should be 0, but we will mask them out just to be sure
- data[n] = data_in; // comedi operates on unsigned numbers, so we don't clear the SGN bit
- // SGN bit is still set! It's correct, since we're converting to unsigned.
- } else { // The voltage is negative
- // data_in contains a number in 30-bit two's complement code and we must deal with it
+ if (data_in & MPC624_SGN_BIT) /* check the sign bit */
+ { /* The voltage is positive */
+ data_in &= 0x3FFFFFFF; /* EOC and DMY should be 0, but we will mask them out just to be sure */
+ data[n] = data_in; /* comedi operates on unsigned numbers, so we don't clear the SGN bit */
+ /* SGN bit is still set! It's correct, since we're converting to unsigned. */
+ } else { /* The voltage is negative */
+ /* data_in contains a number in 30-bit two's complement code and we must deal with it */
data_in |= MPC624_SGN_BIT;
data_in = ~data_in;
data_in += 1;
data_in &= ~(MPC624_EOC_BIT | MPC624_DMY_BIT);
- // clear EOC and DMY bits
+ /* clear EOC and DMY bits */
data_in = 0x20000000 - data_in;
data[n] = data_in;
}
}
- // Return the number of samples read/written
+ /* Return the number of samples read/written */
return n;
}
diff --git a/drivers/staging/comedi/drivers/mpc8260cpm.c b/drivers/staging/comedi/drivers/mpc8260cpm.c
index bac0a7bb9cbd..c7ee3ef10130 100644
--- a/drivers/staging/comedi/drivers/mpc8260cpm.c
+++ b/drivers/staging/comedi/drivers/mpc8260cpm.c
@@ -46,23 +46,23 @@ struct mpc8260cpm_private {
#define devpriv ((struct mpc8260cpm_private *)dev->private)
-static int mpc8260cpm_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int mpc8260cpm_detach(struct comedi_device * dev);
+static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int mpc8260cpm_detach(struct comedi_device *dev);
static struct comedi_driver driver_mpc8260cpm = {
- driver_name:"mpc8260cpm",
- module:THIS_MODULE,
- attach:mpc8260cpm_attach,
- detach:mpc8260cpm_detach,
+ .driver_name = "mpc8260cpm",
+ .module = THIS_MODULE,
+ .attach = mpc8260cpm_attach,
+ .detach = mpc8260cpm_detach,
};
COMEDI_INITCLEANUP(driver_mpc8260cpm);
-static int mpc8260cpm_dio_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int mpc8260cpm_dio_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int mpc8260cpm_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int i;
@@ -93,7 +93,7 @@ static int mpc8260cpm_attach(struct comedi_device * dev, struct comedi_devconfig
return 1;
}
-static int mpc8260cpm_detach(struct comedi_device * dev)
+static int mpc8260cpm_detach(struct comedi_device *dev)
{
printk("comedi%d: mpc8260cpm: remove\n", dev->minor);
@@ -114,8 +114,8 @@ static unsigned long *cpm_pdat(int port)
}
}
-static int mpc8260cpm_dio_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned int d;
@@ -157,8 +157,8 @@ static int mpc8260cpm_dio_config(struct comedi_device * dev, struct comedi_subde
return 1;
}
-static int mpc8260cpm_dio_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int port;
unsigned long *p;
diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c
index 9e47574171de..f7cce6cc7766 100644
--- a/drivers/staging/comedi/drivers/multiq3.c
+++ b/drivers/staging/comedi/drivers/multiq3.c
@@ -29,6 +29,7 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3)
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -82,13 +83,13 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3)
#define MULTIQ3_TIMEOUT 30
-static int multiq3_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int multiq3_detach(struct comedi_device * dev);
+static int multiq3_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int multiq3_detach(struct comedi_device *dev);
static struct comedi_driver driver_multiq3 = {
- driver_name:"multiq3",
- module:THIS_MODULE,
- attach:multiq3_attach,
- detach:multiq3_detach,
+ .driver_name = "multiq3",
+ .module = THIS_MODULE,
+ .attach = multiq3_attach,
+ .detach = multiq3_detach,
};
COMEDI_INITCLEANUP(driver_multiq3);
@@ -98,8 +99,8 @@ struct multiq3_private {
};
#define devpriv ((struct multiq3_private *)dev->private)
-static int multiq3_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan;
@@ -134,8 +135,8 @@ static int multiq3_ai_insn_read(struct comedi_device * dev, struct comedi_subdev
return n;
}
-static int multiq3_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int multiq3_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -147,8 +148,8 @@ static int multiq3_ao_insn_read(struct comedi_device * dev, struct comedi_subdev
return i;
}
-static int multiq3_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int multiq3_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -165,8 +166,8 @@ static int multiq3_ao_insn_write(struct comedi_device * dev, struct comedi_subde
return i;
}
-static int multiq3_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int multiq3_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -176,8 +177,8 @@ static int multiq3_di_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int multiq3_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int multiq3_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -191,8 +192,8 @@ static int multiq3_do_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int multiq3_encoder_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int multiq3_encoder_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -212,7 +213,7 @@ static int multiq3_encoder_insn_read(struct comedi_device * dev, struct comedi_s
return n;
}
-static void encoder_reset(struct comedi_device * dev)
+static void encoder_reset(struct comedi_device *dev)
{
int chan;
for (chan = 0; chan < dev->subdevices[4].n_chan; chan++) {
@@ -235,7 +236,7 @@ static void encoder_reset(struct comedi_device * dev)
options[2] - number of encoder chips installed
*/
-static int multiq3_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int multiq3_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int result = 0;
unsigned long iobase;
@@ -318,7 +319,7 @@ static int multiq3_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int multiq3_detach(struct comedi_device * dev)
+static int multiq3_detach(struct comedi_device *dev)
{
printk("comedi%d: multiq3: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c
index e01ecb6760f9..67adc97265bd 100644
--- a/drivers/staging/comedi/drivers/ni_6527.c
+++ b/drivers/staging/comedi/drivers/ni_6527.c
@@ -41,6 +41,7 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800
#define DEBUG 1
#define DEBUG_FLAGS
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "mite.h"
@@ -75,13 +76,13 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800
#define Rising_Edge_Detection_Enable(x) (0x018+(x))
#define Falling_Edge_Detection_Enable(x) (0x020+(x))
-static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int ni6527_detach(struct comedi_device * dev);
+static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni6527_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni6527 = {
- driver_name:"ni6527",
- module:THIS_MODULE,
- attach:ni6527_attach,
- detach:ni6527_detach,
+ .driver_name = "ni6527",
+ .module = THIS_MODULE,
+ .attach = ni6527_attach,
+ .detach = ni6527_detach,
};
struct ni6527_board {
@@ -92,12 +93,12 @@ struct ni6527_board {
static const struct ni6527_board ni6527_boards[] = {
{
- dev_id: 0x2b20,
- name: "pci-6527",
+ .dev_id = 0x2b20,
+ .name = "pci-6527",
},
{
- dev_id: 0x2b10,
- name: "pxi-6527",
+ .dev_id = 0x2b10,
+ .name = "pxi-6527",
},
};
@@ -120,10 +121,10 @@ struct ni6527_private {
#define devpriv ((struct ni6527_private *)dev->private)
-static int ni6527_find_device(struct comedi_device * dev, int bus, int slot);
+static int ni6527_find_device(struct comedi_device *dev, int bus, int slot);
-static int ni6527_di_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
unsigned int interval;
@@ -170,8 +171,8 @@ static int ni6527_di_insn_config(struct comedi_device * dev, struct comedi_subde
return 2;
}
-static int ni6527_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni6527_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -183,8 +184,8 @@ static int ni6527_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int ni6527_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni6527_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -212,7 +213,7 @@ static int ni6527_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static irqreturn_t ni6527_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t ni6527_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices + 2;
@@ -233,8 +234,8 @@ static irqreturn_t ni6527_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static int ni6527_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni6527_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -309,9 +310,9 @@ static int ni6527_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevi
return 0;
}
-static int ni6527_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni6527_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
- //struct comedi_cmd *cmd = &s->async->cmd;
+ /* struct comedi_cmd *cmd = &s->async->cmd; */
writeb(ClrEdge | ClrOverflow,
devpriv->mite->daq_io_addr + Clear_Register);
@@ -322,15 +323,15 @@ static int ni6527_intr_cmd(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int ni6527_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni6527_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
return 0;
}
-static int ni6527_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni6527_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
@@ -339,8 +340,8 @@ static int ni6527_intr_insn_bits(struct comedi_device * dev, struct comedi_subde
return 2;
}
-static int ni6527_intr_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni6527_intr_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
@@ -364,14 +365,15 @@ static int ni6527_intr_insn_config(struct comedi_device * dev, struct comedi_sub
return 2;
}
-static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret;
printk("comedi%d: ni6527:", dev->minor);
- if ((ret = alloc_private(dev, sizeof(struct ni6527_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct ni6527_private));
+ if (ret < 0)
return ret;
ret = ni6527_find_device(dev, it->options[0], it->options[1]);
@@ -389,7 +391,8 @@ static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk(" ID=0x%02x", readb(devpriv->mite->daq_io_addr + ID_Register));
- if ((ret = alloc_subdevices(dev, 3)) < 0)
+ ret = alloc_subdevices(dev, 3);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -430,8 +433,8 @@ static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->mite->daq_io_addr + Clear_Register);
writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
- ret = comedi_request_irq(mite_irq(devpriv->mite), ni6527_interrupt,
- IRQF_SHARED, "ni6527", dev);
+ ret = request_irq(mite_irq(devpriv->mite), ni6527_interrupt,
+ IRQF_SHARED, "ni6527", dev);
if (ret < 0) {
printk(" irq not available");
} else
@@ -442,7 +445,7 @@ static int ni6527_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int ni6527_detach(struct comedi_device * dev)
+static int ni6527_detach(struct comedi_device *dev)
{
if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) {
writeb(0x00,
@@ -450,7 +453,7 @@ static int ni6527_detach(struct comedi_device * dev)
}
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (devpriv && devpriv->mite) {
@@ -460,7 +463,7 @@ static int ni6527_detach(struct comedi_device * dev)
return 0;
}
-static int ni6527_find_device(struct comedi_device * dev, int bus, int slot)
+static int ni6527_find_device(struct comedi_device *dev, int bus, int slot)
{
struct mite_struct *mite;
int i;
diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 6e85da16a241..35708503dec3 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -50,6 +50,7 @@ except maybe the 6514.
#define _GNU_SOURCE
#define DEBUG 1
#define DEBUG_FLAGS
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "mite.h"
@@ -102,13 +103,13 @@ static inline unsigned Filter_Enable(unsigned port)
#define OverflowIntEnable 0x02
#define EdgeIntEnable 0x01
-static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int ni_65xx_detach(struct comedi_device * dev);
+static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_65xx_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni_65xx = {
- driver_name:"ni_65xx",
- module:THIS_MODULE,
- attach:ni_65xx_attach,
- detach:ni_65xx_detach,
+ .driver_name = "ni_65xx",
+ .module = THIS_MODULE,
+ .attach = ni_65xx_attach,
+ .detach = ni_65xx_detach,
};
struct ni_65xx_board {
@@ -123,120 +124,120 @@ struct ni_65xx_board {
static const struct ni_65xx_board ni_65xx_boards[] = {
{
- dev_id: 0x7085,
- name: "pci-6509",
- num_dio_ports:12,
- invert_outputs:0},
+ .dev_id = 0x7085,
+ .name = "pci-6509",
+ .num_dio_ports = 12,
+ .invert_outputs = 0},
{
- dev_id: 0x1710,
- name: "pxi-6509",
- num_dio_ports:12,
- invert_outputs:0},
+ .dev_id = 0x1710,
+ .name = "pxi-6509",
+ .num_dio_ports = 12,
+ .invert_outputs = 0},
{
- dev_id: 0x7124,
- name: "pci-6510",
- num_di_ports:4},
+ .dev_id = 0x7124,
+ .name = "pci-6510",
+ .num_di_ports = 4},
{
- dev_id: 0x70c3,
- name: "pci-6511",
- num_di_ports:8},
+ .dev_id = 0x70c3,
+ .name = "pci-6511",
+ .num_di_ports = 8},
{
- dev_id: 0x70d3,
- name: "pxi-6511",
- num_di_ports:8},
+ .dev_id = 0x70d3,
+ .name = "pxi-6511",
+ .num_di_ports = 8},
{
- dev_id: 0x70cc,
- name: "pci-6512",
- num_do_ports:8},
+ .dev_id = 0x70cc,
+ .name = "pci-6512",
+ .num_do_ports = 8},
{
- dev_id: 0x70d2,
- name: "pxi-6512",
- num_do_ports:8},
+ .dev_id = 0x70d2,
+ .name = "pxi-6512",
+ .num_do_ports = 8},
{
- dev_id: 0x70c8,
- name: "pci-6513",
- num_do_ports:8,
- invert_outputs:1},
+ .dev_id = 0x70c8,
+ .name = "pci-6513",
+ .num_do_ports = 8,
+ .invert_outputs = 1},
{
- dev_id: 0x70d1,
- name: "pxi-6513",
- num_do_ports:8,
- invert_outputs:1},
+ .dev_id = 0x70d1,
+ .name = "pxi-6513",
+ .num_do_ports = 8,
+ .invert_outputs = 1},
{
- dev_id: 0x7088,
- name: "pci-6514",
- num_di_ports:4,
- num_do_ports:4,
- invert_outputs:1},
+ .dev_id = 0x7088,
+ .name = "pci-6514",
+ .num_di_ports = 4,
+ .num_do_ports = 4,
+ .invert_outputs = 1},
{
- dev_id: 0x70CD,
- name: "pxi-6514",
- num_di_ports:4,
- num_do_ports:4,
- invert_outputs:1},
+ .dev_id = 0x70CD,
+ .name = "pxi-6514",
+ .num_di_ports = 4,
+ .num_do_ports = 4,
+ .invert_outputs = 1},
{
- dev_id: 0x7087,
- name: "pci-6515",
- num_di_ports:4,
- num_do_ports:4,
- invert_outputs:1},
+ .dev_id = 0x7087,
+ .name = "pci-6515",
+ .num_di_ports = 4,
+ .num_do_ports = 4,
+ .invert_outputs = 1},
{
- dev_id: 0x70c9,
- name: "pxi-6515",
- num_di_ports:4,
- num_do_ports:4,
- invert_outputs:1},
+ .dev_id = 0x70c9,
+ .name = "pxi-6515",
+ .num_di_ports = 4,
+ .num_do_ports = 4,
+ .invert_outputs = 1},
{
- dev_id: 0x7125,
- name: "pci-6516",
- num_do_ports:4,
- invert_outputs:1},
+ .dev_id = 0x7125,
+ .name = "pci-6516",
+ .num_do_ports = 4,
+ .invert_outputs = 1},
{
- dev_id: 0x7126,
- name: "pci-6517",
- num_do_ports:4,
- invert_outputs:1},
+ .dev_id = 0x7126,
+ .name = "pci-6517",
+ .num_do_ports = 4,
+ .invert_outputs = 1},
{
- dev_id: 0x7127,
- name: "pci-6518",
- num_di_ports:2,
- num_do_ports:2,
- invert_outputs:1},
+ .dev_id = 0x7127,
+ .name = "pci-6518",
+ .num_di_ports = 2,
+ .num_do_ports = 2,
+ .invert_outputs = 1},
{
- dev_id: 0x7128,
- name: "pci-6519",
- num_di_ports:2,
- num_do_ports:2,
- invert_outputs:1},
+ .dev_id = 0x7128,
+ .name = "pci-6519",
+ .num_di_ports = 2,
+ .num_do_ports = 2,
+ .invert_outputs = 1},
{
- dev_id: 0x71c5,
- name: "pci-6520",
- num_di_ports:1,
- num_do_ports:1,
+ .dev_id = 0x71c5,
+ .name = "pci-6520",
+ .num_di_ports = 1,
+ .num_do_ports = 1,
},
{
- dev_id: 0x718b,
- name: "pci-6521",
- num_di_ports:1,
- num_do_ports:1,
+ .dev_id = 0x718b,
+ .name = "pci-6521",
+ .num_di_ports = 1,
+ .num_do_ports = 1,
},
{
- dev_id: 0x718c,
- name: "pxi-6521",
- num_di_ports:1,
- num_do_ports:1,
+ .dev_id = 0x718c,
+ .name = "pxi-6521",
+ .num_di_ports = 1,
+ .num_do_ports = 1,
},
{
- dev_id: 0x70a9,
- name: "pci-6528",
- num_di_ports:3,
- num_do_ports:3,
+ .dev_id = 0x70a9,
+ .name = "pci-6528",
+ .num_di_ports = 3,
+ .num_do_ports = 3,
},
{
- dev_id: 0x7086,
- name: "pxi-6528",
- num_di_ports:3,
- num_do_ports:3,
+ .dev_id = 0x7086,
+ .name = "pxi-6528",
+ .num_di_ports = 3,
+ .num_do_ports = 3,
},
};
@@ -249,7 +250,7 @@ static inline unsigned ni_65xx_port_by_channel(unsigned channel)
{
return channel / ni_65xx_channels_per_port;
}
-static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board * board)
+static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board *board)
{
return board->num_dio_ports + board->num_di_ports + board->num_do_ports;
}
@@ -312,10 +313,10 @@ static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void)
return subdev_private;
}
-static int ni_65xx_find_device(struct comedi_device * dev, int bus, int slot);
+static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot);
-static int ni_65xx_config_filter(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_65xx_config_filter(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
const unsigned chan = CR_CHAN(insn->chanspec);
const unsigned port =
@@ -353,8 +354,8 @@ static int ni_65xx_config_filter(struct comedi_device * dev, struct comedi_subde
return 2;
}
-static int ni_65xx_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_65xx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned port;
@@ -392,8 +393,8 @@ static int ni_65xx_dio_insn_config(struct comedi_device * dev, struct comedi_sub
return -EINVAL;
}
-static int ni_65xx_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned base_bitfield_channel;
const unsigned max_ports_per_bitfield = 5;
@@ -437,12 +438,12 @@ static int ni_65xx_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
writeb(bits,
private(dev)->mite->daq_io_addr +
Port_Data(port));
-// rt_printk("wrote 0x%x to port %i\n", bits, port);
+/* printk("wrote 0x%x to port %i\n", bits, port); */
}
port_read_bits =
readb(private(dev)->mite->daq_io_addr +
Port_Data(port));
-// rt_printk("read 0x%x from port %i\n", port_read_bits, port);
+/* printk("read 0x%x from port %i\n", port_read_bits, port); */
if (bitshift > 0) {
port_read_bits <<= bitshift;
} else {
@@ -454,7 +455,7 @@ static int ni_65xx_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
return insn->n;
}
-static irqreturn_t ni_65xx_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t ni_65xx_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices + 2;
@@ -475,8 +476,8 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static int ni_65xx_intr_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_65xx_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -551,9 +552,9 @@ static int ni_65xx_intr_cmdtest(struct comedi_device * dev, struct comedi_subdev
return 0;
}
-static int ni_65xx_intr_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_65xx_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
- //struct comedi_cmd *cmd = &s->async->cmd;
+ /* struct comedi_cmd *cmd = &s->async->cmd; */
writeb(ClrEdge | ClrOverflow,
private(dev)->mite->daq_io_addr + Clear_Register);
@@ -564,7 +565,7 @@ static int ni_65xx_intr_cmd(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int ni_65xx_intr_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_65xx_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
writeb(0x00,
private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
@@ -572,8 +573,8 @@ static int ni_65xx_intr_cancel(struct comedi_device * dev, struct comedi_subdevi
return 0;
}
-static int ni_65xx_intr_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_65xx_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
@@ -582,8 +583,8 @@ static int ni_65xx_intr_insn_bits(struct comedi_device * dev, struct comedi_subd
return 2;
}
-static int ni_65xx_intr_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_65xx_intr_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
@@ -619,7 +620,7 @@ static int ni_65xx_intr_insn_config(struct comedi_device * dev, struct comedi_su
return 2;
}
-static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned i;
@@ -627,7 +628,8 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig *
printk("comedi%d: ni_65xx:", dev->minor);
- if ((ret = alloc_private(dev, sizeof(struct ni_65xx_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct ni_65xx_private));
+ if (ret < 0)
return ret;
ret = ni_65xx_find_device(dev, it->options[0], it->options[1]);
@@ -647,7 +649,8 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig *
printk(" ID=0x%02x",
readb(private(dev)->mite->daq_io_addr + ID_Register));
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -700,7 +703,7 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig *
return -ENOMEM;
sprivate(s)->base_port = 0;
for (i = 0; i < board(dev)->num_dio_ports; ++i) {
- // configure all ports for input
+ /* configure all ports for input */
writeb(0x1,
private(dev)->mite->daq_io_addr +
Port_Select(i));
@@ -740,8 +743,8 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig *
/* Set filter interval to 0 (32bit reg) */
writeb(0x00000000, private(dev)->mite->daq_io_addr + Filter_Interval);
- ret = comedi_request_irq(dev->irq, ni_65xx_interrupt, IRQF_SHARED,
- "ni_65xx", dev);
+ ret = request_irq(dev->irq, ni_65xx_interrupt, IRQF_SHARED,
+ "ni_65xx", dev);
if (ret < 0) {
dev->irq = 0;
printk(" irq not available");
@@ -752,7 +755,7 @@ static int ni_65xx_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int ni_65xx_detach(struct comedi_device * dev)
+static int ni_65xx_detach(struct comedi_device *dev)
{
if (private(dev) && private(dev)->mite
&& private(dev)->mite->daq_io_addr) {
@@ -762,7 +765,7 @@ static int ni_65xx_detach(struct comedi_device * dev)
}
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (private(dev)) {
@@ -780,7 +783,7 @@ static int ni_65xx_detach(struct comedi_device * dev)
return 0;
}
-static int ni_65xx_find_device(struct comedi_device * dev, int bus, int slot)
+static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot)
{
struct mite_struct *mite;
int i;
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index 14e35ba721e9..11e9b0411805 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -40,6 +40,7 @@ DAQ 6601/6602 User Manual (NI 322137B-01)
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "mite.h"
#include "ni_tio.h"
@@ -51,7 +52,7 @@ enum ni_660x_constants {
};
#define NUM_PFI_CHANNELS 40
-// really there are only up to 3 dma channels, but the register layout allows for 4
+/* really there are only up to 3 dma channels, but the register layout allows for 4 */
#define MAX_DMA_CHANNEL 4
/* See Register-Level Programmer Manual page 3.1 */
@@ -194,10 +195,10 @@ static inline unsigned NI_660X_GPCT_SUBDEV(unsigned index)
struct NI_660xRegisterData {
- const char *name; // Register Name
- int offset; // Offset from base address from GPCT chip
+ const char *name; /* Register Name */
+ int offset; /* Offset from base address from GPCT chip */
enum ni_660x_register_direction direction;
- enum ni_660x_register_width size; // 1 byte, 2 bytes, or 4 bytes
+ enum ni_660x_register_width size; /* 1 byte, 2 bytes, or 4 bytes */
};
@@ -302,12 +303,12 @@ static const struct NI_660xRegisterData registerData[NumRegisters] = {
{"IO Config Register 38-39", 0x7A2, NI_660x_READ_WRITE, DATA_2B}
};
-// kind of ENABLE for the second counter
+/* kind of ENABLE for the second counter */
enum clock_config_register_bits {
CounterSwap = 0x1 << 21
};
-// ioconfigreg
+/* ioconfigreg */
static inline unsigned ioconfig_bitshift(unsigned pfi_channel)
{
if (pfi_channel % 2)
@@ -334,7 +335,7 @@ static inline unsigned pfi_input_select_bits(unsigned pfi_channel,
return (input_select & 0x7) << (4 + ioconfig_bitshift(pfi_channel));
}
-// dma configuration register bits
+/* dma configuration register bits */
static inline unsigned dma_select_mask(unsigned dma_channel)
{
BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
@@ -374,7 +375,7 @@ enum global_interrupt_config_register_bits {
Global_Int_Enable_Bit = 0x80000000
};
-// Offset of the GPCT chips from the base-adress of the card
+/* Offset of the GPCT chips from the base-adress of the card */
static const unsigned GPCT_OFFSET[2] = { 0x0, 0x800 }; /* First chip is at base-address +
0x00, etc. */
@@ -387,24 +388,24 @@ struct ni_660x_board {
static const struct ni_660x_board ni_660x_boards[] = {
{
- dev_id: 0x2c60,
- name: "PCI-6601",
- n_chips: 1,
+ .dev_id = 0x2c60,
+ .name = "PCI-6601",
+ .n_chips = 1,
},
{
- dev_id: 0x1310,
- name: "PCI-6602",
- n_chips: 2,
+ .dev_id = 0x1310,
+ .name = "PCI-6602",
+ .n_chips = 2,
},
{
- dev_id: 0x1360,
- name: "PXI-6602",
- n_chips: 2,
+ .dev_id = 0x1360,
+ .name = "PXI-6602",
+ .n_chips = 2,
},
{
- dev_id: 0x2cc0,
- name: "PXI-6608",
- n_chips: 2,
+ .dev_id = 0x2cc0,
+ .name = "PXI-6608",
+ .n_chips = 2,
},
};
@@ -428,6 +429,8 @@ struct ni_660x_private {
struct mite_dma_descriptor_ring
*mite_rings[NI_660X_MAX_NUM_CHIPS][counters_per_chip];
spinlock_t mite_channel_lock;
+ /* interrupt_lock prevents races between interrupt and comedi_poll */
+ spinlock_t interrupt_lock;
unsigned dma_configuration_soft_copies[NI_660X_MAX_NUM_CHIPS];
spinlock_t soft_reg_copy_lock;
unsigned short pfi_output_selects[NUM_PFI_CHANNELS];
@@ -446,40 +449,40 @@ static inline const struct ni_660x_board *board(struct comedi_device * dev)
#define n_ni_660x_boards (sizeof(ni_660x_boards)/sizeof(ni_660x_boards[0]))
-static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int ni_660x_detach(struct comedi_device * dev);
-static void init_tio_chip(struct comedi_device * dev, int chipset);
-static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_channel,
+static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_660x_detach(struct comedi_device *dev);
+static void init_tio_chip(struct comedi_device *dev, int chipset);
+static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel,
unsigned output_select);
static struct comedi_driver driver_ni_660x = {
- driver_name:"ni_660x",
- module:THIS_MODULE,
- attach:ni_660x_attach,
- detach:ni_660x_detach,
+ .driver_name = "ni_660x",
+ .module = THIS_MODULE,
+ .attach = ni_660x_attach,
+ .detach = ni_660x_detach,
};
COMEDI_PCI_INITCLEANUP(driver_ni_660x, ni_660x_pci_table);
-static int ni_660x_find_device(struct comedi_device * dev, int bus, int slot);
-static int ni_660x_set_pfi_routing(struct comedi_device * dev, unsigned chan,
+static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot);
+static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
unsigned source);
/* Possible instructions for a GPCT */
-static int ni_660x_GPCT_rinsn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
-static int ni_660x_GPCT_insn_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
-static int ni_660x_GPCT_winsn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int ni_660x_GPCT_rinsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int ni_660x_GPCT_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int ni_660x_GPCT_winsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
/* Possible instructions for Digital IO */
-static int ni_660x_dio_insn_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
-static int ni_660x_dio_insn_bits(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int ni_660x_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int ni_660x_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static inline unsigned ni_660x_num_counters(struct comedi_device * dev)
+static inline unsigned ni_660x_num_counters(struct comedi_device *dev)
{
return board(dev)->n_chips * counters_per_chip;
}
@@ -693,8 +696,8 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
ni_660x_register = G3InterruptEnable;
break;
default:
- rt_printk("%s: unhandled register 0x%x in switch.\n",
- __FUNCTION__, reg);
+ printk("%s: unhandled register 0x%x in switch.\n",
+ __func__, reg);
BUG();
return 0;
break;
@@ -702,7 +705,7 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
return ni_660x_register;
}
-static inline void ni_660x_write_register(struct comedi_device * dev,
+static inline void ni_660x_write_register(struct comedi_device *dev,
unsigned chip_index, unsigned bits, enum NI_660x_Register reg)
{
void *const write_address =
@@ -717,14 +720,14 @@ static inline void ni_660x_write_register(struct comedi_device * dev,
writel(bits, write_address);
break;
default:
- rt_printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
- __FILE__, __FUNCTION__, reg);
+ printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
+ __FILE__, __func__, reg);
BUG();
break;
}
}
-static inline unsigned ni_660x_read_register(struct comedi_device * dev,
+static inline unsigned ni_660x_read_register(struct comedi_device *dev,
unsigned chip_index, enum NI_660x_Register reg)
{
void *const read_address =
@@ -739,8 +742,8 @@ static inline unsigned ni_660x_read_register(struct comedi_device * dev,
return readl(read_address);
break;
default:
- rt_printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
- __FILE__, __FUNCTION__, reg);
+ printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
+ __FILE__, __func__, reg);
BUG();
break;
}
@@ -771,11 +774,11 @@ static inline struct mite_dma_descriptor_ring *mite_ring(struct ni_660x_private
return priv->mite_rings[counter->chip_index][counter->counter_index];
}
-static inline void ni_660x_set_dma_channel(struct comedi_device * dev,
+static inline void ni_660x_set_dma_channel(struct comedi_device *dev,
unsigned mite_channel, struct ni_gpct *counter)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
+ spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
private(dev)->dma_configuration_soft_copies[counter->chip_index] &=
~dma_select_mask(mite_channel);
private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
@@ -786,14 +789,14 @@ static inline void ni_660x_set_dma_channel(struct comedi_device * dev,
chip_index] | dma_reset_bit(mite_channel),
DMAConfigRegister);
mmiowb();
- comedi_spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
+ spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
}
-static inline void ni_660x_unset_dma_channel(struct comedi_device * dev,
+static inline void ni_660x_unset_dma_channel(struct comedi_device *dev,
unsigned mite_channel, struct ni_gpct *counter)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
+ spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
private(dev)->dma_configuration_soft_copies[counter->chip_index] &=
~dma_select_mask(mite_channel);
private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
@@ -802,22 +805,22 @@ static inline void ni_660x_unset_dma_channel(struct comedi_device * dev,
private(dev)->dma_configuration_soft_copies[counter->
chip_index], DMAConfigRegister);
mmiowb();
- comedi_spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
+ spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
}
-static int ni_660x_request_mite_channel(struct comedi_device * dev,
+static int ni_660x_request_mite_channel(struct comedi_device *dev,
struct ni_gpct *counter, enum comedi_io_direction direction)
{
unsigned long flags;
struct mite_channel *mite_chan;
- comedi_spin_lock_irqsave(&private(dev)->mite_channel_lock, flags);
+ spin_lock_irqsave(&private(dev)->mite_channel_lock, flags);
BUG_ON(counter->mite_chan);
mite_chan =
mite_request_channel(private(dev)->mite, mite_ring(private(dev),
counter));
if (mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&private(dev)->mite_channel_lock,
+ spin_unlock_irqrestore(&private(dev)->mite_channel_lock,
flags);
comedi_error(dev,
"failed to reserve mite dma channel for counter.");
@@ -826,15 +829,15 @@ static int ni_660x_request_mite_channel(struct comedi_device * dev,
mite_chan->dir = direction;
ni_tio_set_mite_channel(counter, mite_chan);
ni_660x_set_dma_channel(dev, mite_chan->channel, counter);
- comedi_spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags);
return 0;
}
-void ni_660x_release_mite_channel(struct comedi_device * dev, struct ni_gpct *counter)
+void ni_660x_release_mite_channel(struct comedi_device *dev, struct ni_gpct *counter)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&private(dev)->mite_channel_lock, flags);
+ spin_lock_irqsave(&private(dev)->mite_channel_lock, flags);
if (counter->mite_chan) {
struct mite_channel *mite_chan = counter->mite_chan;
@@ -842,15 +845,15 @@ void ni_660x_release_mite_channel(struct comedi_device * dev, struct ni_gpct *co
ni_tio_set_mite_channel(counter, NULL);
mite_release_channel(mite_chan);
}
- comedi_spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags);
}
-static int ni_660x_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_660x_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int retval;
struct ni_gpct *counter = subdev_to_counter(s);
-// const struct comedi_cmd *cmd = &s->async->cmd;
+/* const struct comedi_cmd *cmd = &s->async->cmd; */
retval = ni_660x_request_mite_channel(dev, counter, COMEDI_INPUT);
if (retval) {
@@ -864,15 +867,15 @@ static int ni_660x_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return retval;
}
-static int ni_660x_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_660x_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
struct ni_gpct *counter = subdev_to_counter(s);
return ni_tio_cmdtest(counter, cmd);
}
-static int ni_660x_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_660x_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct ni_gpct *counter = subdev_to_counter(s);
int retval;
@@ -882,7 +885,7 @@ static int ni_660x_cancel(struct comedi_device * dev, struct comedi_subdevice *
return retval;
}
-static void set_tio_counterswap(struct comedi_device * dev, int chipset)
+static void set_tio_counterswap(struct comedi_device *dev, int chipset)
{
/* See P. 3.5 of the Register-Level Programming manual. The
CounterSwap bit has to be set on the second chip, otherwise
@@ -895,8 +898,8 @@ static void set_tio_counterswap(struct comedi_device * dev, int chipset)
ni_660x_write_register(dev, chipset, 0, ClockConfigRegister);
}
-static void ni_660x_handle_gpct_interrupt(struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
ni_tio_handle_interrupt(subdev_to_counter(s), s);
if (s->async->events) {
@@ -909,23 +912,38 @@ static void ni_660x_handle_gpct_interrupt(struct comedi_device * dev,
}
}
-static irqreturn_t ni_660x_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t ni_660x_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s;
unsigned i;
+ unsigned long flags;
if (dev->attached == 0)
return IRQ_NONE;
+ /* lock to avoid race with comedi_poll */
+ spin_lock_irqsave(&private(dev)->interrupt_lock, flags);
smp_mb();
for (i = 0; i < ni_660x_num_counters(dev); ++i) {
s = dev->subdevices + NI_660X_GPCT_SUBDEV(i);
ni_660x_handle_gpct_interrupt(dev, s);
}
+ spin_unlock_irqrestore(&private(dev)->interrupt_lock, flags);
return IRQ_HANDLED;
}
-static int ni_660x_buf_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_660x_input_poll(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ unsigned long flags;
+ /* lock to avoid race with comedi_poll */
+ spin_lock_irqsave(&private(dev)->interrupt_lock, flags);
+ mite_sync_input_dma(subdev_to_counter(s)->mite_chan, s->async);
+ spin_unlock_irqrestore(&private(dev)->interrupt_lock, flags);
+ return comedi_buf_read_n_available(s->async);
+}
+
+static int ni_660x_buf_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
int ret;
@@ -938,14 +956,17 @@ static int ni_660x_buf_change(struct comedi_device * dev, struct comedi_subdevic
return 0;
}
-static int ni_660x_allocate_private(struct comedi_device * dev)
+static int ni_660x_allocate_private(struct comedi_device *dev)
{
int retval;
unsigned i;
- if ((retval = alloc_private(dev, sizeof(struct ni_660x_private))) < 0)
+ retval = alloc_private(dev, sizeof(struct ni_660x_private));
+ if (retval < 0)
return retval;
+
spin_lock_init(&private(dev)->mite_channel_lock);
+ spin_lock_init(&private(dev)->interrupt_lock);
spin_lock_init(&private(dev)->soft_reg_copy_lock);
for (i = 0; i < NUM_PFI_CHANNELS; ++i) {
private(dev)->pfi_output_selects[i] = pfi_output_select_counter;
@@ -953,7 +974,7 @@ static int ni_660x_allocate_private(struct comedi_device * dev)
return 0;
}
-static int ni_660x_alloc_mite_rings(struct comedi_device * dev)
+static int ni_660x_alloc_mite_rings(struct comedi_device *dev)
{
unsigned i;
unsigned j;
@@ -970,7 +991,7 @@ static int ni_660x_alloc_mite_rings(struct comedi_device * dev)
return 0;
}
-static void ni_660x_free_mite_rings(struct comedi_device * dev)
+static void ni_660x_free_mite_rings(struct comedi_device *dev)
{
unsigned i;
unsigned j;
@@ -982,7 +1003,7 @@ static void ni_660x_free_mite_rings(struct comedi_device * dev)
}
}
-static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret;
@@ -1031,7 +1052,7 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig *
s->insn_bits = ni_660x_dio_insn_bits;
s->insn_config = ni_660x_dio_insn_config;
s->io_bits = 0; /* all bits default to input */
- // we use the ioconfig registers to control dio direction, so zero output enables in stc dio control reg
+ /* we use the ioconfig registers to control dio direction, so zero output enables in stc dio control reg */
ni_660x_write_register(dev, 0, 0, STCDIOControl);
private(dev)->counter_dev = ni_gpct_device_construct(dev,
@@ -1055,6 +1076,7 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig *
s->len_chanlist = 1;
s->do_cmdtest = &ni_660x_cmdtest;
s->cancel = &ni_660x_cancel;
+ s->poll = &ni_660x_input_poll;
s->async_dma_dir = DMA_BIDIRECTIONAL;
s->buf_change = &ni_660x_buf_change;
s->private = &private(dev)->counter_dev->counters[i];
@@ -1086,9 +1108,9 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig *
for (i = 0; i < board(dev)->n_chips; ++i) {
set_tio_counterswap(dev, i);
}
- if ((ret = comedi_request_irq(mite_irq(private(dev)->mite),
- &ni_660x_interrupt, IRQF_SHARED, "ni_660x",
- dev)) < 0) {
+ ret = request_irq(mite_irq(private(dev)->mite), ni_660x_interrupt,
+ IRQF_SHARED, "ni_660x", dev);
+ if (ret < 0) {
printk(" irq not available\n");
return ret;
}
@@ -1102,13 +1124,13 @@ static int ni_660x_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int ni_660x_detach(struct comedi_device * dev)
+static int ni_660x_detach(struct comedi_device *dev)
{
printk("comedi%d: ni_660x: remove\n", dev->minor);
/* Free irq */
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->private) {
if (private(dev)->counter_dev)
@@ -1122,17 +1144,17 @@ static int ni_660x_detach(struct comedi_device * dev)
}
static int
-ni_660x_GPCT_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+ni_660x_GPCT_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return ni_tio_rinsn(subdev_to_counter(s), insn, data);
}
-static void init_tio_chip(struct comedi_device * dev, int chipset)
+static void init_tio_chip(struct comedi_device *dev, int chipset)
{
unsigned i;
- // init dma configuration register
+ /* init dma configuration register */
private(dev)->dma_configuration_soft_copies[chipset] = 0;
for (i = 0; i < MAX_DMA_CHANNEL; ++i) {
private(dev)->dma_configuration_soft_copies[chipset] |=
@@ -1142,26 +1164,26 @@ static void init_tio_chip(struct comedi_device * dev, int chipset)
ni_660x_write_register(dev, chipset,
private(dev)->dma_configuration_soft_copies[chipset],
DMAConfigRegister);
- for(i = 0; i < NUM_PFI_CHANNELS; ++i)
+ for (i = 0; i < NUM_PFI_CHANNELS; ++i)
{
ni_660x_write_register(dev, chipset, 0, IOConfigReg(i));
}
}
static int
-ni_660x_GPCT_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+ni_660x_GPCT_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return ni_tio_insn_config(subdev_to_counter(s), insn, data);
}
-static int ni_660x_GPCT_winsn(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_660x_GPCT_winsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
return ni_tio_winsn(subdev_to_counter(s), insn, data);
}
-static int ni_660x_find_device(struct comedi_device * dev, int bus, int slot)
+static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot)
{
struct mite_struct *mite;
int i;
@@ -1188,12 +1210,12 @@ static int ni_660x_find_device(struct comedi_device * dev, int bus, int slot)
return -EIO;
}
-static int ni_660x_dio_insn_bits(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_660x_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
unsigned base_bitfield_channel = CR_CHAN(insn->chanspec);
- // Check if we have to write some bits
+ /* Check if we have to write some bits */
if (data[0]) {
s->state &= ~(data[0] << base_bitfield_channel);
s->state |= (data[0] & data[1]) << base_bitfield_channel;
@@ -1208,7 +1230,7 @@ static int ni_660x_dio_insn_bits(struct comedi_device * dev,
return 2;
}
-static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_channel,
+static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel,
unsigned output_select)
{
static const unsigned counter_4_7_first_pfi = 8;
@@ -1218,8 +1240,8 @@ static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_c
unsigned active_bits;
unsigned idle_bits;
- if(board(dev)->n_chips > 1) {
- if(output_select == pfi_output_select_counter &&
+ if (board (dev)->n_chips > 1) {
+ if (output_select == pfi_output_select_counter &&
pfi_channel >= counter_4_7_first_pfi &&
pfi_channel <= counter_4_7_last_pfi) {
active_chipset = 1;
@@ -1230,7 +1252,7 @@ static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_c
}
}
- if(idle_chipset != active_chipset) {
+ if (idle_chipset != active_chipset) {
idle_bits = ni_660x_read_register(dev, idle_chipset, IOConfigReg(pfi_channel));
idle_bits &= ~pfi_output_select_mask(pfi_channel);
idle_bits |= pfi_output_select_bits(pfi_channel, pfi_output_select_high_Z);
@@ -1243,7 +1265,7 @@ static void ni_660x_select_pfi_output(struct comedi_device * dev, unsigned pfi_c
ni_660x_write_register(dev, active_chipset, active_bits, IOConfigReg(pfi_channel));
}
-static int ni_660x_set_pfi_routing(struct comedi_device * dev, unsigned chan,
+static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
unsigned source)
{
if (source > num_pfi_output_selects)
@@ -1266,13 +1288,13 @@ static int ni_660x_set_pfi_routing(struct comedi_device * dev, unsigned chan,
return 0;
}
-static unsigned ni_660x_get_pfi_routing(struct comedi_device * dev, unsigned chan)
+static unsigned ni_660x_get_pfi_routing(struct comedi_device *dev, unsigned chan)
{
BUG_ON(chan >= NUM_PFI_CHANNELS);
return private(dev)->pfi_output_selects[chan];
}
-static void ni660x_config_filter(struct comedi_device * dev, unsigned pfi_channel,
+static void ni660x_config_filter(struct comedi_device *dev, unsigned pfi_channel,
enum ni_gpct_filter_select filter)
{
unsigned bits = ni_660x_read_register(dev, 0, IOConfigReg(pfi_channel));
@@ -1281,8 +1303,8 @@ static void ni660x_config_filter(struct comedi_device * dev, unsigned pfi_channe
ni_660x_write_register(dev, 0, bits, IOConfigReg(pfi_channel));
}
-static int ni_660x_dio_insn_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_660x_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c
index d1312e073a65..71f7d3ab3aa1 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/staging/comedi/drivers/ni_670x.c
@@ -41,6 +41,7 @@ Commands are not supported.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "mite.h"
@@ -69,29 +70,29 @@ struct ni_670x_board {
static const struct ni_670x_board ni_670x_boards[] = {
{
- dev_id: 0x2c90,
- name: "PCI-6703",
- ao_chans:16,
- ao_bits: 16,
+ .dev_id = 0x2c90,
+ .name = "PCI-6703",
+ .ao_chans = 16,
+ .ao_bits = 16,
},
{
- dev_id: 0x1920,
- name: "PXI-6704",
- ao_chans:32,
- ao_bits: 16,
+ .dev_id = 0x1920,
+ .name = "PXI-6704",
+ .ao_chans = 32,
+ .ao_bits = 16,
},
{
- dev_id: 0x1290,
- name: "PCI-6704",
- ao_chans:32,
- ao_bits: 16,
+ .dev_id = 0x1290,
+ .name = "PCI-6704",
+ .ao_chans = 32,
+ .ao_bits = 16,
},
};
static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
{PCI_VENDOR_ID_NATINST, 0x2c90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_NATINST, 0x1920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- //{ PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+ /* { PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
{0}
};
@@ -111,32 +112,32 @@ struct ni_670x_private {
#define devpriv ((struct ni_670x_private *)dev->private)
#define n_ni_670x_boards (sizeof(ni_670x_boards)/sizeof(ni_670x_boards[0]))
-static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int ni_670x_detach(struct comedi_device * dev);
+static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_670x_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni_670x = {
- driver_name:"ni_670x",
- module:THIS_MODULE,
- attach:ni_670x_attach,
- detach:ni_670x_detach,
+ .driver_name = "ni_670x",
+ .module = THIS_MODULE,
+ .attach = ni_670x_attach,
+ .detach = ni_670x_detach,
};
COMEDI_PCI_INITCLEANUP(driver_ni_670x, ni_670x_pci_table);
static struct comedi_lrange range_0_20mA = { 1, {RANGE_mA(0, 20)} };
-static int ni_670x_find_device(struct comedi_device * dev, int bus, int slot);
+static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot);
-static int ni_670x_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_670x_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_670x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_670x_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret;
@@ -144,7 +145,8 @@ static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig *
printk("comedi%d: ni_670x: ", dev->minor);
- if ((ret = alloc_private(dev, sizeof(struct ni_670x_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct ni_670x_private));
+ if (ret < 0)
return ret;
ret = ni_670x_find_device(dev, it->options[0], it->options[1]);
@@ -205,7 +207,7 @@ static int ni_670x_attach(struct comedi_device * dev, struct comedi_devconfig *
return 1;
}
-static int ni_670x_detach(struct comedi_device * dev)
+static int ni_670x_detach(struct comedi_device *dev)
{
printk("comedi%d: ni_670x: remove\n", dev->minor);
@@ -216,13 +218,13 @@ static int ni_670x_detach(struct comedi_device * dev)
mite_unsetup(devpriv->mite);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
return 0;
}
-static int ni_670x_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -247,8 +249,8 @@ static int ni_670x_ao_winsn(struct comedi_device * dev, struct comedi_subdevice
return i;
}
-static int ni_670x_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -259,8 +261,8 @@ static int ni_670x_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice
return i;
}
-static int ni_670x_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -281,8 +283,8 @@ static int ni_670x_dio_insn_bits(struct comedi_device * dev, struct comedi_subde
return 2;
}
-static int ni_670x_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
@@ -308,7 +310,7 @@ static int ni_670x_dio_insn_config(struct comedi_device * dev, struct comedi_sub
return insn->n;
}
-static int ni_670x_find_device(struct comedi_device * dev, int bus, int slot)
+static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot)
{
struct mite_struct *mite;
int i;
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index 5d45bf24a5ef..45c6809031db 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -64,6 +64,7 @@ TRIG_WAKE_EOS
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -73,10 +74,10 @@ TRIG_WAKE_EOS
#include "comedi_fc.h"
#define A2150_SIZE 28
-#define A2150_DMA_BUFFER_SIZE 0xff00 // size in bytes of dma buffer
+#define A2150_DMA_BUFFER_SIZE 0xff00 /* size in bytes of dma buffer */
-//#define A2150_DEBUG // enable debugging code
-#undef A2150_DEBUG // disable debugging code
+/* #define A2150_DEBUG enable debugging code */
+#undef A2150_DEBUG /* disable debugging code */
/* Registers and bits */
#define CONFIG_REG 0x0
@@ -85,48 +86,48 @@ TRIG_WAKE_EOS
#define CLOCK_SELECT_BITS(x) (((x) & 0x3) << 3)
#define CLOCK_DIVISOR_BITS(x) (((x) & 0x3) << 5)
#define CLOCK_MASK (0xf << 3)
-#define ENABLE0_BIT 0x80 // enable (don't internally ground) channels 0 and 1
-#define ENABLE1_BIT 0x100 // enable (don't internally ground) channels 2 and 3
-#define AC0_BIT 0x200 // ac couple channels 0,1
-#define AC1_BIT 0x400 // ac couple channels 2,3
-#define APD_BIT 0x800 // analog power down
-#define DPD_BIT 0x1000 // digital power down
-#define TRIGGER_REG 0x2 // trigger config register
+#define ENABLE0_BIT 0x80 /* enable (don't internally ground) channels 0 and 1 */
+#define ENABLE1_BIT 0x100 /* enable (don't internally ground) channels 2 and 3 */
+#define AC0_BIT 0x200 /* ac couple channels 0,1 */
+#define AC1_BIT 0x400 /* ac couple channels 2,3 */
+#define APD_BIT 0x800 /* analog power down */
+#define DPD_BIT 0x1000 /* digital power down */
+#define TRIGGER_REG 0x2 /* trigger config register */
#define POST_TRIGGER_BITS 0x2
#define DELAY_TRIGGER_BITS 0x3
-#define HW_TRIG_EN 0x10 // enable hardware trigger
-#define FIFO_START_REG 0x6 // software start aquistion trigger
-#define FIFO_RESET_REG 0x8 // clears fifo + fifo flags
-#define FIFO_DATA_REG 0xa // read data
-#define DMA_TC_CLEAR_REG 0xe // clear dma terminal count interrupt
-#define STATUS_REG 0x12 // read only
-#define FNE_BIT 0x1 // fifo not empty
-#define OVFL_BIT 0x8 // fifo overflow
-#define EDAQ_BIT 0x10 // end of aquisition interrupt
-#define DCAL_BIT 0x20 // offset calibration in progress
-#define INTR_BIT 0x40 // interrupt has occured
-#define DMA_TC_BIT 0x80 // dma terminal count interrupt has occured
+#define HW_TRIG_EN 0x10 /* enable hardware trigger */
+#define FIFO_START_REG 0x6 /* software start aquistion trigger */
+#define FIFO_RESET_REG 0x8 /* clears fifo + fifo flags */
+#define FIFO_DATA_REG 0xa /* read data */
+#define DMA_TC_CLEAR_REG 0xe /* clear dma terminal count interrupt */
+#define STATUS_REG 0x12 /* read only */
+#define FNE_BIT 0x1 /* fifo not empty */
+#define OVFL_BIT 0x8 /* fifo overflow */
+#define EDAQ_BIT 0x10 /* end of aquisition interrupt */
+#define DCAL_BIT 0x20 /* offset calibration in progress */
+#define INTR_BIT 0x40 /* interrupt has occured */
+#define DMA_TC_BIT 0x80 /* dma terminal count interrupt has occured */
#define ID_BITS(x) (((x) >> 8) & 0x3)
-#define IRQ_DMA_CNTRL_REG 0x12 // write only
-#define DMA_CHAN_BITS(x) ((x) & 0x7) // sets dma channel
-#define DMA_EN_BIT 0x8 // enables dma
-#define IRQ_LVL_BITS(x) (((x) & 0xf) << 4) // sets irq level
-#define FIFO_INTR_EN_BIT 0x100 // enable fifo interrupts
-#define FIFO_INTR_FHF_BIT 0x200 // interrupt fifo half full
-#define DMA_INTR_EN_BIT 0x800 // enable interrupt on dma terminal count
-#define DMA_DEM_EN_BIT 0x1000 // enables demand mode dma
+#define IRQ_DMA_CNTRL_REG 0x12 /* write only */
+#define DMA_CHAN_BITS(x) ((x) & 0x7) /* sets dma channel */
+#define DMA_EN_BIT 0x8 /* enables dma */
+#define IRQ_LVL_BITS(x) (((x) & 0xf) << 4) /* sets irq level */
+#define FIFO_INTR_EN_BIT 0x100 /* enable fifo interrupts */
+#define FIFO_INTR_FHF_BIT 0x200 /* interrupt fifo half full */
+#define DMA_INTR_EN_BIT 0x800 /* enable interrupt on dma terminal count */
+#define DMA_DEM_EN_BIT 0x1000 /* enables demand mode dma */
#define I8253_BASE_REG 0x14
#define I8253_MODE_REG 0x17
-#define HW_COUNT_DISABLE 0x30 // disable hardware counting of conversions
+#define HW_COUNT_DISABLE 0x30 /* disable hardware counting of conversions */
struct a2150_board {
const char *name;
- int clock[4]; // master clock periods, in nanoseconds
- int num_clocks; // number of available master clock speeds
- int ai_speed; // maximum conversion rate in nanoseconds
+ int clock[4]; /* master clock periods, in nanoseconds */
+ int num_clocks; /* number of available master clock speeds */
+ int ai_speed; /* maximum conversion rate in nanoseconds */
};
-//analog input range
+/* analog input range */
static const struct comedi_lrange range_a2150 = {
1,
{
@@ -134,20 +135,20 @@ static const struct comedi_lrange range_a2150 = {
}
};
-// enum must match board indices
+/* enum must match board indices */
enum { a2150_c, a2150_s };
static const struct a2150_board a2150_boards[] = {
{
- name: "at-a2150c",
- clock: {31250, 22676, 20833, 19531},
- num_clocks:4,
- ai_speed:19531,
+ .name = "at-a2150c",
+ .clock = {31250, 22676, 20833, 19531},
+ .num_clocks = 4,
+ .ai_speed = 19531,
},
{
- name: "at-a2150s",
- clock: {62500, 50000, 41667, 0},
- num_clocks:3,
- ai_speed:41667,
+ .name = "at-a2150s",
+ .clock = {62500, 50000, 41667, 0},
+ .num_clocks = 3,
+ .ai_speed = 41667,
},
};
@@ -159,37 +160,37 @@ static const struct a2150_board a2150_boards[] = {
struct a2150_private {
volatile unsigned int count; /* number of data points left to be taken */
- unsigned int dma; // dma channel
- s16 *dma_buffer; // dma buffer
- unsigned int dma_transfer_size; // size in bytes of dma transfers
- int irq_dma_bits; // irq/dma register bits
- int config_bits; // config register bits
+ unsigned int dma; /* dma channel */
+ s16 *dma_buffer; /* dma buffer */
+ unsigned int dma_transfer_size; /* size in bytes of dma transfers */
+ int irq_dma_bits; /* irq/dma register bits */
+ int config_bits; /* config register bits */
};
#define devpriv ((struct a2150_private *)dev->private)
-static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int a2150_detach(struct comedi_device * dev);
-static int a2150_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int a2150_detach(struct comedi_device *dev);
+static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static struct comedi_driver driver_a2150 = {
- driver_name:"ni_at_a2150",
- module:THIS_MODULE,
- attach:a2150_attach,
- detach:a2150_detach,
+ .driver_name = "ni_at_a2150",
+ .module = THIS_MODULE,
+ .attach = a2150_attach,
+ .detach = a2150_detach,
};
-static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG);
-static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int a2150_get_timing(struct comedi_device * dev, unsigned int *period,
+static irqreturn_t a2150_interrupt(int irq, void *d);
+static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
int flags);
-static int a2150_probe(struct comedi_device * dev);
-static int a2150_set_chanlist(struct comedi_device * dev, unsigned int start_channel,
+static int a2150_probe(struct comedi_device *dev);
+static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel,
unsigned int num_channels);
/*
* A convenient macro that defines init_module() and cleanup_module(),
@@ -199,17 +200,17 @@ COMEDI_INITCLEANUP(driver_a2150);
#ifdef A2150_DEBUG
-static void ni_dump_regs(struct comedi_device * dev)
+static void ni_dump_regs(struct comedi_device *dev)
{
- rt_printk("config bits 0x%x\n", devpriv->config_bits);
- rt_printk("irq dma bits 0x%x\n", devpriv->irq_dma_bits);
- rt_printk("status bits 0x%x\n", inw(dev->iobase + STATUS_REG));
+ printk("config bits 0x%x\n", devpriv->config_bits);
+ printk("irq dma bits 0x%x\n", devpriv->irq_dma_bits);
+ printk("status bits 0x%x\n", inw(dev->iobase + STATUS_REG));
}
#endif
/* interrupt service routine */
-static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t a2150_interrupt(int irq, void *d)
{
int i;
int status;
@@ -226,7 +227,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
comedi_error(dev, "premature interrupt");
return IRQ_HANDLED;
}
- // initialize async here to make sure s is not NULL
+ /* initialize async here to make sure s is not NULL */
async = s->async;
async->events = 0;
cmd = &async->cmd;
@@ -258,7 +259,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
* count and address get set correctly */
clear_dma_ff(devpriv->dma);
- // figure out how many points to read
+ /* figure out how many points to read */
max_points = devpriv->dma_transfer_size / sample_size;
/* residue is the number of points left to be done on the dma
* transfer. It should always be zero at this point unless
@@ -269,7 +270,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
if (devpriv->count < num_points && cmd->stop_src == TRIG_COUNT)
num_points = devpriv->count;
- // figure out how many points will be stored next time
+ /* figure out how many points will be stored next time */
leftover = 0;
if (cmd->stop_src == TRIG_NONE) {
leftover = devpriv->dma_transfer_size / sample_size;
@@ -288,7 +289,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
for (i = 0; i < num_points; i++) {
/* write data point to comedi buffer */
dpnt = devpriv->dma_buffer[i];
- // convert from 2's complement to unsigned coding
+ /* convert from 2's complement to unsigned coding */
dpnt ^= 0x8000;
cfc_write_to_buffer(s, dpnt);
if (cmd->stop_src == TRIG_COUNT) {
@@ -299,7 +300,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
}
}
}
- // re-enable dma
+ /* re-enable dma */
if (leftover) {
set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer));
set_dma_count(devpriv->dma, leftover * sample_size);
@@ -317,14 +318,14 @@ static irqreturn_t a2150_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-// probes board type, returns offset
-static int a2150_probe(struct comedi_device * dev)
+/* probes board type, returns offset */
+static int a2150_probe(struct comedi_device *dev)
{
int status = inw(dev->iobase + STATUS_REG);
return ID_BITS(status);
}
-static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = it->options[0];
@@ -365,12 +366,12 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it
/* grab our IRQ */
if (irq) {
- // check that irq is supported
+ /* check that irq is supported */
if (irq < 3 || irq == 8 || irq == 13 || irq > 15) {
printk(" invalid irq line %u\n", irq);
return -EINVAL;
}
- if (comedi_request_irq(irq, a2150_interrupt, 0,
+ if (request_irq(irq, a2150_interrupt, 0,
driver_a2150.driver_name, dev)) {
printk("unable to allocate irq %u\n", irq);
return -EINVAL;
@@ -378,7 +379,7 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it
devpriv->irq_dma_bits |= IRQ_LVL_BITS(irq);
dev->irq = irq;
}
- // initialize dma
+ /* initialize dma */
if (dma) {
if (dma == 4 || dma > 7) {
printk(" invalid dma channel %u\n", dma);
@@ -424,20 +425,20 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it
* prevent hardware count from stopping aquisition */
outw(HW_COUNT_DISABLE, dev->iobase + I8253_MODE_REG);
- // set card's irq and dma levels
+ /* set card's irq and dma levels */
outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
- // reset and sync adc clock circuitry
+ /* reset and sync adc clock circuitry */
outw_p(DPD_BIT | APD_BIT, dev->iobase + CONFIG_REG);
outw_p(DPD_BIT, dev->iobase + CONFIG_REG);
- // initialize configuration register
+ /* initialize configuration register */
devpriv->config_bits = 0;
outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
- // wait until offset calibration is done, then enable analog inputs
+ /* wait until offset calibration is done, then enable analog inputs */
for (i = 0; i < timeout; i++) {
if ((DCAL_BIT & inw(dev->iobase + STATUS_REG)) == 0)
break;
- comedi_udelay(1000);
+ udelay(1000);
}
if (i == timeout) {
printk(" timed out waiting for offset calibration to complete\n");
@@ -449,19 +450,19 @@ static int a2150_attach(struct comedi_device * dev, struct comedi_devconfig * it
return 0;
};
-static int a2150_detach(struct comedi_device * dev)
+static int a2150_detach(struct comedi_device *dev)
{
printk("comedi%d: %s: remove\n", dev->minor, driver_a2150.driver_name);
/* only free stuff if it has been allocated by _attach */
if (dev->iobase) {
- // put board in power-down mode
+ /* put board in power-down mode */
outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG);
release_region(dev->iobase, A2150_SIZE);
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->dma)
free_dma(devpriv->dma);
@@ -472,23 +473,23 @@ static int a2150_detach(struct comedi_device * dev)
return 0;
};
-static int a2150_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
- // disable dma on card
+ /* disable dma on card */
devpriv->irq_dma_bits &= ~DMA_INTR_EN_BIT & ~DMA_EN_BIT;
outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
- // disable computer's dma
+ /* disable computer's dma */
disable_dma(devpriv->dma);
- // clear fifo and reset triggering circuitry
+ /* clear fifo and reset triggering circuitry */
outw(0, dev->iobase + FIFO_RESET_REG);
return 0;
}
-static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -582,7 +583,7 @@ static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (err)
return 4;
- // check channel/gain list against card's limitations
+ /* check channel/gain list against card's limitations */
if (cmd->chanlist) {
startChan = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
@@ -617,7 +618,7 @@ static int a2150_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -635,7 +636,7 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
" dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
return -1;
}
- // clear fifo and reset triggering circuitry
+ /* clear fifo and reset triggering circuitry */
outw(0, dev->iobase + FIFO_RESET_REG);
/* setup chanlist */
@@ -643,7 +644,7 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
cmd->chanlist_len) < 0)
return -1;
- // setup ac/dc coupling
+ /* setup ac/dc coupling */
if (CR_AREF(cmd->chanlist[0]) == AREF_OTHER)
devpriv->config_bits |= AC0_BIT;
else
@@ -653,23 +654,23 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
else
devpriv->config_bits &= ~AC1_BIT;
- // setup timing
+ /* setup timing */
a2150_get_timing(dev, &cmd->scan_begin_arg, cmd->flags);
- // send timing, channel, config bits
+ /* send timing, channel, config bits */
outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
- // initialize number of samples remaining
+ /* initialize number of samples remaining */
devpriv->count = cmd->stop_arg * cmd->chanlist_len;
- // enable computer's dma
+ /* enable computer's dma */
lock_flags = claim_dma_lock();
disable_dma(devpriv->dma);
/* clear flip-flop to make sure 2-byte registers for
* count and address get set correctly */
clear_dma_ff(devpriv->dma);
set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer));
- // set size of transfer to fill in 1/3 second
+ /* set size of transfer to fill in 1/3 second */
#define ONE_THIRD_SECOND 333333333
devpriv->dma_transfer_size =
sizeof(devpriv->dma_buffer[0]) * cmd->chanlist_len *
@@ -688,36 +689,36 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
* one spurious interrupt that has been happening */
outw(0x00, dev->iobase + DMA_TC_CLEAR_REG);
- // enable dma on card
+ /* enable dma on card */
devpriv->irq_dma_bits |= DMA_INTR_EN_BIT | DMA_EN_BIT;
outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
- // may need to wait 72 sampling periods if timing was changed
+ /* may need to wait 72 sampling periods if timing was changed */
i8254_load(dev->iobase + I8253_BASE_REG, 0, 2, 72, 0);
- // setup start triggering
+ /* setup start triggering */
trigger_bits = 0;
- // decide if we need to wait 72 periods for valid data
+ /* decide if we need to wait 72 periods for valid data */
if (cmd->start_src == TRIG_NOW &&
(old_config_bits & CLOCK_MASK) !=
(devpriv->config_bits & CLOCK_MASK)) {
- // set trigger source to delay trigger
+ /* set trigger source to delay trigger */
trigger_bits |= DELAY_TRIGGER_BITS;
} else {
- // otherwise no delay
+ /* otherwise no delay */
trigger_bits |= POST_TRIGGER_BITS;
}
- // enable external hardware trigger
+ /* enable external hardware trigger */
if (cmd->start_src == TRIG_EXT) {
trigger_bits |= HW_TRIG_EN;
} else if (cmd->start_src == TRIG_OTHER) {
- // XXX add support for level/slope start trigger using TRIG_OTHER
+ /* XXX add support for level/slope start trigger using TRIG_OTHER */
comedi_error(dev, "you shouldn't see this?");
}
- // send trigger config bits
+ /* send trigger config bits */
outw(trigger_bits, dev->iobase + TRIGGER_REG);
- // start aquisition for soft trigger
+ /* start aquisition for soft trigger */
if (cmd->start_src == TRIG_NOW) {
outw(0, dev->iobase + FIFO_START_REG);
}
@@ -728,35 +729,35 @@ static int a2150_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int i, n;
static const int timeout = 100000;
static const int filter_delay = 36;
- // clear fifo and reset triggering circuitry
+ /* clear fifo and reset triggering circuitry */
outw(0, dev->iobase + FIFO_RESET_REG);
/* setup chanlist */
if (a2150_set_chanlist(dev, CR_CHAN(insn->chanspec), 1) < 0)
return -1;
- // set dc coupling
+ /* set dc coupling */
devpriv->config_bits &= ~AC0_BIT;
devpriv->config_bits &= ~AC1_BIT;
- // send timing, channel, config bits
+ /* send timing, channel, config bits */
outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
- // disable dma on card
+ /* disable dma on card */
devpriv->irq_dma_bits &= ~DMA_INTR_EN_BIT & ~DMA_EN_BIT;
outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
- // setup start triggering
+ /* setup start triggering */
outw(0, dev->iobase + TRIGGER_REG);
- // start aquisition for soft trigger
+ /* start aquisition for soft trigger */
outw(0, dev->iobase + FIFO_START_REG);
/* there is a 35.6 sample delay for data to get through the antialias filter */
@@ -764,7 +765,7 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
for (i = 0; i < timeout; i++) {
if (inw(dev->iobase + STATUS_REG) & FNE_BIT)
break;
- comedi_udelay(1);
+ udelay(1);
}
if (i == timeout) {
comedi_error(dev, "timeout");
@@ -773,12 +774,12 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
inw(dev->iobase + FIFO_DATA_REG);
}
- // read data
+ /* read data */
for (n = 0; n < insn->n; n++) {
for (i = 0; i < timeout; i++) {
if (inw(dev->iobase + STATUS_REG) & FNE_BIT)
break;
- comedi_udelay(1);
+ udelay(1);
}
if (i == timeout) {
comedi_error(dev, "timeout");
@@ -789,12 +790,12 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
#endif
data[n] = inw(dev->iobase + FIFO_DATA_REG);
#ifdef A2150_DEBUG
- rt_printk(" data is %i\n", data[n]);
+ printk(" data is %i\n", data[n]);
#endif
data[n] ^= 0x8000;
}
- // clear fifo and reset triggering circuitry
+ /* clear fifo and reset triggering circuitry */
outw(0, dev->iobase + FIFO_RESET_REG);
return n;
@@ -802,14 +803,14 @@ static int a2150_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
/* sets bits in devpriv->clock_bits to nearest approximation of requested period,
* adjusts requested period to actual timing. */
-static int a2150_get_timing(struct comedi_device * dev, unsigned int *period,
+static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
int flags)
{
int lub, glb, temp;
int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
int i, j;
- // initialize greatest lower and least upper bounds
+ /* initialize greatest lower and least upper bounds */
lub_divisor_shift = 3;
lub_index = 0;
lub = thisboard->clock[lub_index] * (1 << lub_divisor_shift);
@@ -817,19 +818,19 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period,
glb_index = thisboard->num_clocks - 1;
glb = thisboard->clock[glb_index] * (1 << glb_divisor_shift);
- // make sure period is in available range
+ /* make sure period is in available range */
if (*period < glb)
*period = glb;
if (*period > lub)
*period = lub;
- // we can multiply period by 1, 2, 4, or 8, using (1 << i)
+ /* we can multiply period by 1, 2, 4, or 8, using (1 << i) */
for (i = 0; i < 4; i++) {
- // there are a maximum of 4 master clocks
+ /* there are a maximum of 4 master clocks */
for (j = 0; j < thisboard->num_clocks; j++) {
- // temp is the period in nanosec we are evaluating
+ /* temp is the period in nanosec we are evaluating */
temp = thisboard->clock[j] * (1 << i);
- // if it is the best match yet
+ /* if it is the best match yet */
if (temp < lub && temp >= *period) {
lub_divisor_shift = i;
lub_index = j;
@@ -846,7 +847,7 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period,
switch (flags) {
case TRIG_ROUND_NEAREST:
default:
- // if least upper bound is better approximation
+ /* if least upper bound is better approximation */
if (lub - *period < *period - glb) {
*period = lub;
} else {
@@ -861,7 +862,7 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period,
break;
}
- // set clock bits for config register appropriately
+ /* set clock bits for config register appropriately */
devpriv->config_bits &= ~CLOCK_MASK;
if (*period == lub) {
devpriv->config_bits |=
@@ -876,7 +877,7 @@ static int a2150_get_timing(struct comedi_device * dev, unsigned int *period,
return 0;
}
-static int a2150_set_chanlist(struct comedi_device * dev, unsigned int start_channel,
+static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel,
unsigned int num_channels)
{
if (start_channel + num_channels > 4)
diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c
index 2cc46b672588..4e8bf9ed167c 100644
--- a/drivers/staging/comedi/drivers/ni_at_ao.c
+++ b/drivers/staging/comedi/drivers/ni_at_ao.c
@@ -158,12 +158,12 @@ struct atao_board {
static const struct atao_board atao_boards[] = {
{
- name: "ai-ao-6",
- n_ao_chans:6,
+ .name = "ai-ao-6",
+ .n_ao_chans = 6,
},
{
- name: "ai-ao-10",
- n_ao_chans:10,
+ .name = "ai-ao-10",
+ .n_ao_chans = 10,
},
};
@@ -181,36 +181,36 @@ struct atao_private {
#define devpriv ((struct atao_private *)dev->private)
-static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int atao_detach(struct comedi_device * dev);
+static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int atao_detach(struct comedi_device *dev);
static struct comedi_driver driver_atao = {
- driver_name:"ni_at_ao",
- module:THIS_MODULE,
- attach:atao_attach,
- detach:atao_detach,
- board_name:&atao_boards[0].name,
- offset:sizeof(struct atao_board),
- num_names:sizeof(atao_boards) / sizeof(struct atao_board),
+ .driver_name = "ni_at_ao",
+ .module = THIS_MODULE,
+ .attach = atao_attach,
+ .detach = atao_detach,
+ .board_name = &atao_boards[0].name,
+ .offset = sizeof(struct atao_board),
+ .num_names = ARRAY_SIZE(atao_boards),
};
COMEDI_INITCLEANUP(driver_atao);
-static void atao_reset(struct comedi_device * dev);
-
-static int atao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int atao_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int atao_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int atao_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int atao_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int atao_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-
-static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static void atao_reset(struct comedi_device *dev);
+
+static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+
+static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -229,7 +229,7 @@ static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it)
}
dev->iobase = iobase;
- //dev->board_ptr = atao_probe(dev);
+ /* dev->board_ptr = atao_probe(dev); */
dev->board_name = thisboard->name;
@@ -273,7 +273,7 @@ static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it)
s = dev->subdevices + 3;
/* eeprom subdevice */
- //s->type=COMEDI_SUBD_EEPROM;
+ /* s->type=COMEDI_SUBD_EEPROM; */
s->type = COMEDI_SUBD_UNUSED;
atao_reset(dev);
@@ -283,7 +283,7 @@ static int atao_attach(struct comedi_device * dev, struct comedi_devconfig * it)
return 0;
}
-static int atao_detach(struct comedi_device * dev)
+static int atao_detach(struct comedi_device *dev)
{
printk("comedi%d: atao: remove\n", dev->minor);
@@ -293,7 +293,7 @@ static int atao_detach(struct comedi_device * dev)
return 0;
}
-static void atao_reset(struct comedi_device * dev)
+static void atao_reset(struct comedi_device *dev)
{
/* This is the reset sequence described in the manual */
@@ -323,8 +323,8 @@ static void atao_reset(struct comedi_device * dev)
outw(devpriv->cfg1, dev->iobase + ATAO_CFG1);
}
-static int atao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -347,8 +347,8 @@ static int atao_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s
return i;
}
-static int atao_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -359,8 +359,8 @@ static int atao_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
return i;
}
-static int atao_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -376,8 +376,8 @@ static int atao_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic
return 2;
}
-static int atao_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
unsigned int mask, bit;
@@ -421,8 +421,8 @@ static int atao_dio_insn_config(struct comedi_device * dev, struct comedi_subdev
* DACs. It is not explicitly stated in the manual how to access
* the caldacs, but we can guess.
*/
-static int atao_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
for (i = 0; i < insn->n; i++) {
@@ -431,8 +431,8 @@ static int atao_calib_insn_read(struct comedi_device * dev, struct comedi_subdev
return insn->n;
}
-static int atao_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bitstring, bit;
unsigned int chan = CR_CHAN(insn->chanspec);
diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c
index fcc38535afc5..8839447538f2 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -93,6 +93,7 @@ are not supported.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -114,156 +115,156 @@ are not supported.
#define MAX_N_CALDACS 32
-static const ni_board ni_boards[] = {
- {device_id:44,
- isapnp_id:0x0000,/* XXX unknown */
- name: "at-mio-16e-1",
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:8192,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:800,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:2048,
+static const struct ni_board_struct ni_boards[] = {
+ {.device_id = 44,
+ .isapnp_id = 0x0000,/* XXX unknown */
+ .name = "at-mio-16e-1",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 8192,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 800,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext,
- ao_unipolar:1,
- ao_speed:1000,
- has_8255:0,
+ .ao_unipolar = 1,
+ .ao_speed = 1000,
+ .has_8255 = 0,
.num_p0_dio_channels = 8,
- caldac: {mb88341},
+ .caldac = {mb88341},
},
- {device_id:25,
- isapnp_id:0x1900,
- name: "at-mio-16e-2",
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:2048,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:2000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:2048,
+ {.device_id = 25,
+ .isapnp_id = 0x1900,
+ .name = "at-mio-16e-2",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 2048,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 2000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext,
- ao_unipolar:1,
- ao_speed:1000,
- has_8255:0,
+ .ao_unipolar = 1,
+ .ao_speed = 1000,
+ .has_8255 = 0,
.num_p0_dio_channels = 8,
- caldac: {mb88341},
+ .caldac = {mb88341},
},
- {device_id:36,
- isapnp_id:0x2400,
- name: "at-mio-16e-10",
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:512,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:10000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:0,
+ {.device_id = 36,
+ .isapnp_id = 0x2400,
+ .name = "at-mio-16e-10",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 10000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
.ao_range_table = &range_ni_E_ao_ext,
- ao_unipolar:1,
- ao_speed:10000,
+ .ao_unipolar = 1,
+ .ao_speed = 10000,
.num_p0_dio_channels = 8,
- caldac: {ad8804_debug},
- has_8255:0,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
},
- {device_id:37,
- isapnp_id:0x2500,
- name: "at-mio-16de-10",
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:512,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:10000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:0,
+ {.device_id = 37,
+ .isapnp_id = 0x2500,
+ .name = "at-mio-16de-10",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 10000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
.ao_range_table = &range_ni_E_ao_ext,
- ao_unipolar:1,
- ao_speed:10000,
+ .ao_unipolar = 1,
+ .ao_speed = 10000,
.num_p0_dio_channels = 8,
- caldac: {ad8804_debug},
- has_8255:1,
+ .caldac = {ad8804_debug},
+ .has_8255 = 1,
},
- {device_id:38,
- isapnp_id:0x2600,
- name: "at-mio-64e-3",
- n_adchan:64,
- adbits: 12,
- ai_fifo_depth:2048,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:2000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:2048,
+ {.device_id = 38,
+ .isapnp_id = 0x2600,
+ .name = "at-mio-64e-3",
+ .n_adchan = 64,
+ .adbits = 12,
+ .ai_fifo_depth = 2048,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 2000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext,
- ao_unipolar:1,
- ao_speed:1000,
- has_8255:0,
+ .ao_unipolar = 1,
+ .ao_speed = 1000,
+ .has_8255 = 0,
.num_p0_dio_channels = 8,
- caldac: {ad8804_debug},
+ .caldac = {ad8804_debug},
},
- {device_id:39,
- isapnp_id:0x2700,
- name: "at-mio-16xe-50",
- n_adchan:16,
- adbits: 16,
- ai_fifo_depth:512,
- alwaysdither:1,
- gainlkup:ai_gain_8,
- ai_speed:50000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:0,
+ {.device_id = 39,
+ .isapnp_id = 0x2700,
+ .name = "at-mio-16xe-50",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_8,
+ .ai_speed = 50000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
.ao_range_table = &range_bipolar10,
- ao_unipolar:0,
- ao_speed:50000,
+ .ao_unipolar = 0,
+ .ao_speed = 50000,
.num_p0_dio_channels = 8,
- caldac: {dac8800, dac8043},
- has_8255:0,
+ .caldac = {dac8800, dac8043},
+ .has_8255 = 0,
},
- {device_id:50,
- isapnp_id:0x0000,/* XXX unknown */
- name: "at-mio-16xe-10",
- n_adchan:16,
- adbits: 16,
- ai_fifo_depth:512,
- alwaysdither:1,
- gainlkup:ai_gain_14,
- ai_speed:10000,
- n_aochan:2,
- aobits: 16,
- ao_fifo_depth:2048,
+ {.device_id = 50,
+ .isapnp_id = 0x0000,/* XXX unknown */
+ .name = "at-mio-16xe-10",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_14,
+ .ai_speed = 10000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext,
- ao_unipolar:1,
- ao_speed:1000,
+ .ao_unipolar = 1,
+ .ao_speed = 1000,
.num_p0_dio_channels = 8,
- caldac: {dac8800, dac8043, ad8522},
- has_8255:0,
+ .caldac = {dac8800, dac8043, ad8522},
+ .has_8255 = 0,
},
- {device_id:51,
- isapnp_id:0x0000,/* XXX unknown */
- name: "at-ai-16xe-10",
- n_adchan:16,
- adbits: 16,
- ai_fifo_depth:512,
- alwaysdither:1, /* unknown */
- gainlkup:ai_gain_14,
- ai_speed:10000,
- n_aochan:0,
- aobits: 0,
- ao_fifo_depth:0,
- ao_unipolar:0,
+ {.device_id = 51,
+ .isapnp_id = 0x0000,/* XXX unknown */
+ .name = "at-ai-16xe-10",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1, /* unknown */
+ .gainlkup = ai_gain_14,
+ .ai_speed = 10000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .ao_unipolar = 0,
.num_p0_dio_channels = 8,
- caldac: {dac8800, dac8043, ad8522},
- has_8255:0,
+ .caldac = {dac8800, dac8043, ad8522},
+ .has_8255 = 0,
}
};
@@ -276,18 +277,19 @@ static const int ni_irqpin[] =
#define NI_E_IRQ_FLAGS 0
-typedef struct {
+struct ni_private {
struct pnp_dev *isapnp_dev;
- NI_PRIVATE_COMMON} ni_private;
-#define devpriv ((ni_private *)dev->private)
+ NI_PRIVATE_COMMON
+};
+#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
-#define ni_writel(a,b) (outl((a),(b)+dev->iobase))
+#define ni_writel(a, b) (outl((a), (b)+dev->iobase))
#define ni_readl(a) (inl((a)+dev->iobase))
-#define ni_writew(a,b) (outw((a),(b)+dev->iobase))
+#define ni_writew(a, b) (outw((a), (b)+dev->iobase))
#define ni_readw(a) (inw((a)+dev->iobase))
-#define ni_writeb(a,b) (outb((a),(b)+dev->iobase))
+#define ni_writeb(a, b) (outb((a), (b)+dev->iobase))
#define ni_readb(a) (inb((a)+dev->iobase))
/* How we access windowed registers */
@@ -296,72 +298,72 @@ typedef struct {
* read/written directly in the I/O space of the board. The
* AT-MIO devices map the low 8 STC registers to iobase+addr*2. */
-static void ni_atmio_win_out(struct comedi_device * dev, uint16_t data, int addr)
+static void ni_atmio_win_out(struct comedi_device *dev, uint16_t data, int addr)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
if ((addr) < 8) {
ni_writew(data, addr * 2);
} else {
ni_writew(addr, Window_Address);
ni_writew(data, Window_Data);
}
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
-static uint16_t ni_atmio_win_in(struct comedi_device * dev, int addr)
+static uint16_t ni_atmio_win_in(struct comedi_device *dev, int addr)
{
unsigned long flags;
uint16_t ret;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
if (addr < 8) {
ret = ni_readw(addr * 2);
} else {
ni_writew(addr, Window_Address);
ret = ni_readw(Window_Data);
}
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
return ret;
}
static struct pnp_device_id device_ids[] = {
- {.id = "NIC1900",.driver_data = 0},
- {.id = "NIC2400",.driver_data = 0},
- {.id = "NIC2500",.driver_data = 0},
- {.id = "NIC2600",.driver_data = 0},
- {.id = "NIC2700",.driver_data = 0},
+ {.id = "NIC1900", .driver_data = 0},
+ {.id = "NIC2400", .driver_data = 0},
+ {.id = "NIC2500", .driver_data = 0},
+ {.id = "NIC2600", .driver_data = 0},
+ {.id = "NIC2700", .driver_data = 0},
{.id = ""}
};
MODULE_DEVICE_TABLE(pnp, device_ids);
-static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int ni_atmio_detach(struct comedi_device * dev);
+static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_atmio_detach(struct comedi_device *dev);
static struct comedi_driver driver_atmio = {
- driver_name:"ni_atmio",
- module:THIS_MODULE,
- attach:ni_atmio_attach,
- detach:ni_atmio_detach,
+ .driver_name = "ni_atmio",
+ .module = THIS_MODULE,
+ .attach = ni_atmio_attach,
+ .detach = ni_atmio_detach,
};
COMEDI_INITCLEANUP(driver_atmio);
#include "ni_mio_common.c"
-static int ni_getboardtype(struct comedi_device * dev);
+static int ni_getboardtype(struct comedi_device *dev);
/* clean up allocated resources */
-static int ni_atmio_detach(struct comedi_device * dev)
+static int ni_atmio_detach(struct comedi_device *dev)
{
mio_common_detach(dev);
if (dev->iobase)
release_region(dev->iobase, NI_SIZE);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (devpriv->isapnp_dev)
pnp_device_detach(devpriv->isapnp_dev);
@@ -404,7 +406,7 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
return 0;
}
-static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pnp_dev *isapnp_dev;
int ret;
@@ -413,8 +415,10 @@ static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig *
unsigned int irq;
/* allocate private area */
- if ((ret = ni_alloc_private(dev)) < 0)
+ ret = ni_alloc_private(dev);
+ if (ret < 0)
return ret;
+
devpriv->stc_writew = &ni_atmio_win_out;
devpriv->stc_readw = &ni_atmio_win_in;
devpriv->stc_writel = &win_out2;
@@ -475,8 +479,10 @@ static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig *
return -EINVAL;
}
printk(" ( irq = %u )", irq);
- if ((ret = comedi_request_irq(irq, ni_E_interrupt,
- NI_E_IRQ_FLAGS, "ni_atmio", dev)) < 0) {
+ ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS,
+ "ni_atmio", dev);
+
+ if (ret < 0) {
printk(" irq not available\n");
return -EINVAL;
}
@@ -485,14 +491,15 @@ static int ni_atmio_attach(struct comedi_device * dev, struct comedi_devconfig *
/* generic E series stuff in ni_mio_common.c */
- if ((ret = ni_E_init(dev, it)) < 0) {
+ ret = ni_E_init(dev, it);
+ if (ret < 0) {
return ret;
}
return 0;
}
-static int ni_getboardtype(struct comedi_device * dev)
+static int ni_getboardtype(struct comedi_device *dev)
{
int device_id = ni_read_eeprom(dev, 511);
int i;
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c
index 35fcd172af2e..1a8c2ab20d3d 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
@@ -35,6 +35,7 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d)
*
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -111,12 +112,12 @@ struct atmio16_board_t {
static const struct atmio16_board_t atmio16_boards[] = {
{
- name: "atmio16",
- has_8255:0,
+ .name = "atmio16",
+ .has_8255 = 0,
},
{
- name: "atmio16d",
- has_8255:1,
+ .name = "atmio16d",
+ .has_8255 = 1,
},
};
@@ -125,25 +126,25 @@ static const struct atmio16_board_t atmio16_boards[] = {
#define boardtype ((const struct atmio16_board_t *)dev->board_ptr)
/* function prototypes */
-static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int atmio16d_detach(struct comedi_device * dev);
-static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG);
-static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void reset_counters(struct comedi_device * dev);
-static void reset_atmio16d(struct comedi_device * dev);
+static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int atmio16d_detach(struct comedi_device *dev);
+static irqreturn_t atmio16d_interrupt(int irq, void *d);
+static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void reset_counters(struct comedi_device *dev);
+static void reset_atmio16d(struct comedi_device *dev);
/* main driver struct */
static struct comedi_driver driver_atmio16d = {
- driver_name:"atmio16",
- module:THIS_MODULE,
- attach:atmio16d_attach,
- detach:atmio16d_detach,
- board_name:&atmio16_boards[0].name,
- num_names:n_atmio16_boards,
- offset:sizeof(struct atmio16_board_t),
+ .driver_name = "atmio16",
+ .module = THIS_MODULE,
+ .attach = atmio16d_attach,
+ .detach = atmio16d_detach,
+ .board_name = &atmio16_boards[0].name,
+ .num_names = n_atmio16_boards,
+ .offset = sizeof(struct atmio16_board_t),
};
COMEDI_INITCLEANUP(driver_atmio16d);
@@ -187,7 +188,7 @@ struct atmio16d_private {
unsigned int com_reg_2_state; /* current state of command register 2 */
};
-static void reset_counters(struct comedi_device * dev)
+static void reset_counters(struct comedi_device *dev)
{
/* Counter 2 */
outw(0xFFC2, dev->iobase + AM9513A_COM_REG);
@@ -225,7 +226,7 @@ static void reset_counters(struct comedi_device * dev)
outw(0, dev->iobase + AD_CLEAR_REG);
}
-static void reset_atmio16d(struct comedi_device * dev)
+static void reset_atmio16d(struct comedi_device *dev)
{
int i;
@@ -257,12 +258,12 @@ static void reset_atmio16d(struct comedi_device * dev)
outw(2048, dev->iobase + DAC1_REG);
}
-static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t atmio16d_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices + 0;
-// printk("atmio16d_interrupt!\n");
+/* printk("atmio16d_interrupt!\n"); */
comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG));
@@ -270,8 +271,8 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0, tmp;
#ifdef DEBUG1
@@ -371,7 +372,7 @@ static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevi
return 0;
}
-static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int timer, base_clock;
@@ -417,10 +418,10 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
} else if (cmd->convert_arg < 655360000) {
base_clock = CLOCK_100_KHZ;
timer = cmd->convert_arg / 10000;
- } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */ ) {
+ } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */) {
base_clock = CLOCK_10_KHZ;
timer = cmd->convert_arg / 100000;
- } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */ ) {
+ } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */) {
base_clock = CLOCK_1_KHZ;
timer = cmd->convert_arg / 1000000;
}
@@ -449,11 +450,13 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
outw(devpriv->com_reg_1_state, dev->iobase + COM_REG_1);
} else {
/* Counter 4 and 5 are needed */
- if ((tmp = sample_count & 0xFFFF)) {
+
+ tmp = sample_count & 0xFFFF;
+ if (tmp)
outw(tmp - 1, dev->iobase + AM9513A_DATA_REG);
- } else {
+ else
outw(0xFFFF, dev->iobase + AM9513A_DATA_REG);
- }
+
outw(0xFF48, dev->iobase + AM9513A_COM_REG);
outw(0, dev->iobase + AM9513A_DATA_REG);
outw(0xFF28, dev->iobase + AM9513A_COM_REG);
@@ -483,10 +486,10 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
} else if (cmd->scan_begin_arg < 655360000) {
base_clock = CLOCK_100_KHZ;
timer = cmd->scan_begin_arg / 10000;
- } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */ ) {
+ } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */) {
base_clock = CLOCK_10_KHZ;
timer = cmd->scan_begin_arg / 100000;
- } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */ ) {
+ } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */) {
base_clock = CLOCK_1_KHZ;
timer = cmd->scan_begin_arg / 1000000;
}
@@ -519,7 +522,7 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice *
}
/* This will cancel a running acquisition operation */
-static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
reset_atmio16d(dev);
@@ -527,8 +530,8 @@ static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevic
}
/* Mode 0 is used to get a single conversion on demand */
-static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atmio16d_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, t;
int chan;
@@ -542,9 +545,9 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde
gain = CR_RANGE(insn->chanspec);
/* reset the Analog input circuitry */
- //outw( 0, dev->iobase+AD_CLEAR_REG );
+ /* outw( 0, dev->iobase+AD_CLEAR_REG ); */
/* reset the Analog Input MUX Counter to 0 */
- //outw( 0, dev->iobase+MUX_CNTR_REG );
+ /* outw( 0, dev->iobase+MUX_CNTR_REG ); */
/* set the Input MUX gain */
outw(chan | (gain << 6), dev->iobase + MUX_GAIN_REG);
@@ -577,7 +580,7 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde
}
/* end waiting, now check if it timed out */
if (t == ATMIO16D_TIMEOUT) {
- rt_printk("atmio16d: timeout\n");
+ printk("atmio16d: timeout\n");
return -ETIME;
}
@@ -586,8 +589,8 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde
return i;
}
-static int atmio16d_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atmio16d_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
#ifdef DEBUG1
@@ -601,8 +604,8 @@ static int atmio16d_ao_insn_read(struct comedi_device * dev, struct comedi_subde
return i;
}
-static int atmio16d_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atmio16d_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -636,8 +639,8 @@ static int atmio16d_ao_insn_write(struct comedi_device * dev, struct comedi_subd
return i;
}
-static int atmio16d_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atmio16d_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -652,8 +655,8 @@ static int atmio16d_dio_insn_bits(struct comedi_device * dev, struct comedi_subd
return 2;
}
-static int atmio16d_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int atmio16d_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int mask;
@@ -706,7 +709,7 @@ static int atmio16d_dio_insn_config(struct comedi_device * dev, struct comedi_su
options[12] - dac1 coding
*/
-static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned int irq;
unsigned long iobase;
@@ -726,9 +729,12 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig *
/* board name */
dev->board_name = boardtype->name;
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct atmio16d_private))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct atmio16d_private));
+ if (ret < 0)
return ret;
/* reset the atmio16d hardware */
@@ -737,8 +743,9 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig *
/* check if our interrupt is available and get it */
irq = it->options[1];
if (irq) {
- if ((ret = comedi_request_irq(irq, atmio16d_interrupt,
- 0, "atmio16d", dev)) < 0) {
+
+ ret = request_irq(irq, atmio16d_interrupt, 0, "atmio16d", dev);
+ if (ret < 0) {
printk("failed to allocate irq %u\n", irq);
return ret;
}
@@ -841,7 +848,7 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int atmio16d_detach(struct comedi_device * dev)
+static int atmio16d_detach(struct comedi_device *dev)
{
printk("comedi%d: atmio16d: remove\n", dev->minor);
@@ -849,7 +856,7 @@ static int atmio16d_detach(struct comedi_device * dev)
subdev_8255_cleanup(dev, dev->subdevices + 3);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
reset_atmio16d(dev);
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index 61a31ad2d030..e34948205320 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -41,6 +41,7 @@ emu as port A output, port B input, port C N/A).
IRQ is assigned but not used.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -53,36 +54,36 @@ IRQ is assigned but not used.
static struct pcmcia_device *pcmcia_cur_dev = NULL;
-#define DIO700_SIZE 8 // size of io region used by board
+#define DIO700_SIZE 8 /* size of io region used by board */
-static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dio700_detach(struct comedi_device * dev);
+static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dio700_detach(struct comedi_device *dev);
enum dio700_bustype { pcmcia_bustype };
struct dio700_board {
const char *name;
- int device_id; // device id for pcmcia board
- enum dio700_bustype bustype; // PCMCIA
- int have_dio; // have daqcard-700 dio
- // function pointers so we can use inb/outb or readb/writeb
- // as appropriate
+ int device_id; /* device id for pcmcia board */
+ enum dio700_bustype bustype; /* PCMCIA */
+ int have_dio; /* have daqcard-700 dio */
+ /* function pointers so we can use inb/outb or readb/writeb */
+ /* as appropriate */
unsigned int (*read_byte) (unsigned int address);
void (*write_byte) (unsigned int byte, unsigned int address);
};
static const struct dio700_board dio700_boards[] = {
{
- name: "daqcard-700",
- device_id:0x4743,// 0x10b is manufacturer id, 0x4743 is device id
- bustype: pcmcia_bustype,
- have_dio:1,
+ .name = "daqcard-700",
+ .device_id = 0x4743,/* 0x10b is manufacturer id, 0x4743 is device id */
+ .bustype = pcmcia_bustype,
+ .have_dio = 1,
},
{
- name: "ni_daq_700",
- device_id:0x4743,// 0x10b is manufacturer id, 0x4743 is device id
- bustype: pcmcia_bustype,
- have_dio:1,
+ .name = "ni_daq_700",
+ .device_id = 0x4743,/* 0x10b is manufacturer id, 0x4743 is device id */
+ .bustype = pcmcia_bustype,
+ .have_dio = 1,
},
};
@@ -100,13 +101,13 @@ struct dio700_private {
#define devpriv ((struct dio700_private *)dev->private)
static struct comedi_driver driver_dio700 = {
- driver_name:"ni_daq_700",
- module:THIS_MODULE,
- attach:dio700_attach,
- detach:dio700_detach,
- num_names:sizeof(dio700_boards) / sizeof(struct dio700_board),
- board_name:&dio700_boards[0].name,
- offset:sizeof(struct dio700_board),
+ .driver_name = "ni_daq_700",
+ .module = THIS_MODULE,
+ .attach = dio700_attach,
+ .detach = dio700_detach,
+ .num_names = ARRAY_SIZE(dio700_boards),
+ .board_name = &dio700_boards[0].name,
+ .offset = sizeof(struct dio700_board),
};
/* the real driver routines */
@@ -128,9 +129,9 @@ struct subdev_700_struct {
#define CALLBACK_FUNC (((struct subdev_700_struct *)s->private)->cb_func)
#define subdevpriv ((struct subdev_700_struct *)s->private)
-static void do_config(struct comedi_device * dev, struct comedi_subdevice * s);
+static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
-void subdev_700_interrupt(struct comedi_device * dev, struct comedi_subdevice * s)
+void subdev_700_interrupt(struct comedi_device *dev, struct comedi_subdevice *s)
{
short d;
@@ -155,8 +156,8 @@ static int subdev_700_cb(int dir, int port, int data, unsigned long arg)
}
}
-static int subdev_700_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int subdev_700_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -173,8 +174,8 @@ static int subdev_700_insn(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int subdev_700_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int subdev_700_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
@@ -196,13 +197,13 @@ static int subdev_700_insn_config(struct comedi_device * dev, struct comedi_subd
return 1;
}
-static void do_config(struct comedi_device * dev, struct comedi_subdevice * s)
+static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
{ /* use powerup defaults */
return;
}
-static int subdev_700_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int subdev_700_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -276,21 +277,21 @@ static int subdev_700_cmdtest(struct comedi_device * dev, struct comedi_subdevic
return 0;
}
-static int subdev_700_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int subdev_700_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
/* FIXME */
return 0;
}
-static int subdev_700_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int subdev_700_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
/* FIXME */
return 0;
}
-int subdev_700_init(struct comedi_device * dev, struct comedi_subdevice * s, int (*cb) (int,
+int subdev_700_init(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int,
int, int, unsigned long), unsigned long arg)
{
s->type = COMEDI_SUBD_DIO;
@@ -319,7 +320,7 @@ int subdev_700_init(struct comedi_device * dev, struct comedi_subdevice * s, int
return 0;
}
-int subdev_700_init_irq(struct comedi_device * dev, struct comedi_subdevice * s,
+int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
int (*cb) (int, int, int, unsigned long), unsigned long arg)
{
int ret;
@@ -337,7 +338,7 @@ int subdev_700_init_irq(struct comedi_device * dev, struct comedi_subdevice * s,
return 0;
}
-void subdev_700_cleanup(struct comedi_device * dev, struct comedi_subdevice * s)
+void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (s->private) {
if (subdevpriv->have_irq) {
@@ -352,7 +353,7 @@ EXPORT_SYMBOL(subdev_700_init_irq);
EXPORT_SYMBOL(subdev_700_cleanup);
EXPORT_SYMBOL(subdev_700_interrupt);
-static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = 0;
@@ -365,7 +366,7 @@ static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (alloc_private(dev, sizeof(struct dio700_private)) < 0)
return -ENOMEM;
- // get base address, irq etc. based on bustype
+ /* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
case pcmcia_bustype:
link = pcmcia_cur_dev; /* XXX hack */
@@ -415,7 +416,7 @@ static int dio700_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
};
-static int dio700_detach(struct comedi_device * dev)
+static int dio700_detach(struct comedi_device *dev)
{
printk("comedi%d: ni_daq_700: cs-remove\n", dev->minor);
@@ -425,12 +426,12 @@ static int dio700_detach(struct comedi_device * dev)
if (thisboard->bustype != pcmcia_bustype && dev->iobase)
release_region(dev->iobase, DIO700_SIZE);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
return 0;
};
-// PCMCIA crap
+/* PCMCIA crap */
/*
All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
@@ -594,15 +595,21 @@ static void dio700_config(struct pcmcia_device *link)
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret) {
cs_error(link, GetTupleData, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) {
+
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret) {
cs_error(link, ParseTuple, last_ret);
goto cs_failed;
}
@@ -622,7 +629,8 @@ static void dio700_config(struct pcmcia_device *link)
will only use the CIS to fill in implementation-defined details.
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) {
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret != 0) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
@@ -692,7 +700,9 @@ static void dio700_config(struct pcmcia_device *link)
break;
next_entry:
- if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_next_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetNextTuple, last_ret);
goto cs_failed;
}
@@ -703,18 +713,21 @@ static void dio700_config(struct pcmcia_device *link)
handler to the interrupt, unless the 'Handler' member of the
irq structure is initialized.
*/
- if (link->conf.Attributes & CONF_ENABLE_IRQ)
- if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0) {
+ if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+ last_ret = pcmcia_request_irq(link, &link->irq);
+ if (last_ret) {
cs_error(link, RequestIRQ, last_ret);
goto cs_failed;
}
+ }
/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
- if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0) {
+ last_ret = pcmcia_request_configuration(link, &link->conf);
+ if (last_ret != 0) {
cs_error(link, RequestConfiguration, last_ret);
goto cs_failed;
}
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c
index daec5c4b4c95..a8ac02febc66 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c
@@ -37,9 +37,10 @@ This is just a wrapper around the 8255.o driver to properly handle
the PCMCIA interface.
*/
-//#define LABPC_DEBUG // enable debugging messages
+/* #define LABPC_DEBUG */ /* enable debugging messages */
#undef LABPC_DEBUG
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -54,42 +55,42 @@ the PCMCIA interface.
static struct pcmcia_device *pcmcia_cur_dev = NULL;
-#define DIO24_SIZE 4 // size of io region used by board
+#define DIO24_SIZE 4 /* size of io region used by board */
-static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dio24_detach(struct comedi_device * dev);
+static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dio24_detach(struct comedi_device *dev);
enum dio24_bustype { pcmcia_bustype };
-typedef struct dio24_board_struct {
+struct dio24_board_struct {
const char *name;
- int device_id; // device id for pcmcia board
- enum dio24_bustype bustype; // PCMCIA
- int have_dio; // have 8255 chip
- // function pointers so we can use inb/outb or readb/writeb as appropriate
+ int device_id; /* device id for pcmcia board */
+ enum dio24_bustype bustype; /* PCMCIA */
+ int have_dio; /* have 8255 chip */
+ /* function pointers so we can use inb/outb or readb/writeb as appropriate */
unsigned int (*read_byte) (unsigned int address);
void (*write_byte) (unsigned int byte, unsigned int address);
-} dio24_board;
+};
-static const dio24_board dio24_boards[] = {
+static const struct dio24_board_struct dio24_boards[] = {
{
- name: "daqcard-dio24",
- device_id:0x475c,// 0x10b is manufacturer id, 0x475c is device id
- bustype: pcmcia_bustype,
- have_dio:1,
+ .name = "daqcard-dio24",
+ .device_id = 0x475c,/* 0x10b is manufacturer id, 0x475c is device id */
+ .bustype = pcmcia_bustype,
+ .have_dio = 1,
},
{
- name: "ni_daq_dio24",
- device_id:0x475c,// 0x10b is manufacturer id, 0x475c is device id
- bustype: pcmcia_bustype,
- have_dio:1,
+ .name = "ni_daq_dio24",
+ .device_id = 0x475c,/* 0x10b is manufacturer id, 0x475c is device id */
+ .bustype = pcmcia_bustype,
+ .have_dio = 1,
},
};
/*
* Useful for shorthand access to the particular board structure
*/
-#define thisboard ((const dio24_board *)dev->board_ptr)
+#define thisboard ((const struct dio24_board_struct *)dev->board_ptr)
struct dio24_private {
@@ -100,16 +101,16 @@ struct dio24_private {
#define devpriv ((struct dio24_private *)dev->private)
static struct comedi_driver driver_dio24 = {
- driver_name:"ni_daq_dio24",
- module:THIS_MODULE,
- attach:dio24_attach,
- detach:dio24_detach,
- num_names:sizeof(dio24_boards) / sizeof(dio24_board),
- board_name:&dio24_boards[0].name,
- offset:sizeof(dio24_board),
+ .driver_name = "ni_daq_dio24",
+ .module = THIS_MODULE,
+ .attach = dio24_attach,
+ .detach = dio24_detach,
+ .num_names = ARRAY_SIZE(dio24_boards),
+ .board_name = &dio24_boards[0].name,
+ .offset = sizeof(struct dio24_board_struct),
};
-static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = 0;
@@ -122,7 +123,7 @@ static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it
if (alloc_private(dev, sizeof(struct dio24_private)) < 0)
return -ENOMEM;
- // get base address, irq etc. based on bustype
+ /* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
case pcmcia_bustype:
link = pcmcia_cur_dev; /* XXX hack */
@@ -172,7 +173,7 @@ static int dio24_attach(struct comedi_device * dev, struct comedi_devconfig * it
return 0;
};
-static int dio24_detach(struct comedi_device * dev)
+static int dio24_detach(struct comedi_device *dev)
{
printk("comedi%d: ni_daq_dio24: remove\n", dev->minor);
@@ -182,12 +183,12 @@ static int dio24_detach(struct comedi_device * dev)
if (thisboard->bustype != pcmcia_bustype && dev->iobase)
release_region(dev->iobase, DIO24_SIZE);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
return 0;
};
-// PCMCIA crap
+/* PCMCIA crap */
/*
All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
@@ -236,12 +237,12 @@ static void dio24_cs_detach(struct pcmcia_device *);
static const dev_info_t dev_info = "ni_daq_dio24";
-typedef struct local_info_t {
+struct local_info_t {
struct pcmcia_device *link;
dev_node_t node;
int stop;
struct bus_operations *bus;
-} local_info_t;
+};
/*======================================================================
@@ -257,14 +258,14 @@ typedef struct local_info_t {
static int dio24_cs_attach(struct pcmcia_device *link)
{
- local_info_t *local;
+ struct local_info_t *local;
printk(KERN_INFO "ni_daq_dio24: HOLA SOY YO - CS-attach!\n");
DEBUG(0, "dio24_cs_attach()\n");
/* Allocate space for private device-specific data */
- local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
+ local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
if (!local)
return -ENOMEM;
local->link = link;
@@ -309,7 +310,7 @@ static void dio24_cs_detach(struct pcmcia_device *link)
DEBUG(0, "dio24_cs_detach(0x%p)\n", link);
if (link->dev_node) {
- ((local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *) link->priv)->stop = 1;
dio24_release(link);
}
@@ -329,7 +330,7 @@ static void dio24_cs_detach(struct pcmcia_device *link)
static void dio24_config(struct pcmcia_device *link)
{
- local_info_t *dev = link->priv;
+ struct local_info_t *dev = link->priv;
tuple_t tuple;
cisparse_t parse;
int last_ret;
@@ -351,15 +352,21 @@ static void dio24_config(struct pcmcia_device *link)
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret) {
cs_error(link, GetTupleData, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) {
+
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret) {
cs_error(link, ParseTuple, last_ret);
goto cs_failed;
}
@@ -379,7 +386,9 @@ static void dio24_config(struct pcmcia_device *link)
will only use the CIS to fill in implementation-defined details.
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
@@ -449,7 +458,9 @@ static void dio24_config(struct pcmcia_device *link)
break;
next_entry:
- if ((last_ret = pcmcia_get_next_tuple(link, &tuple)) != 0) {
+
+ last_ret = pcmcia_get_next_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetNextTuple, last_ret);
goto cs_failed;
}
@@ -460,18 +471,21 @@ static void dio24_config(struct pcmcia_device *link)
handler to the interrupt, unless the 'Handler' member of the
irq structure is initialized.
*/
- if (link->conf.Attributes & CONF_ENABLE_IRQ)
- if ((last_ret = pcmcia_request_irq(link, &link->irq)) != 0) {
+ if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+ last_ret = pcmcia_request_irq(link, &link->irq);
+ if (last_ret) {
cs_error(link, RequestIRQ, last_ret);
goto cs_failed;
}
+ }
/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
- if ((last_ret = pcmcia_request_configuration(link, &link->conf)) != 0) {
+ last_ret = pcmcia_request_configuration(link, &link->conf);
+ if (last_ret) {
cs_error(link, RequestConfiguration, last_ret);
goto cs_failed;
}
@@ -529,7 +543,7 @@ static void dio24_release(struct pcmcia_device *link)
static int dio24_cs_suspend(struct pcmcia_device *link)
{
- local_info_t *local = link->priv;
+ struct local_info_t *local = link->priv;
/* Mark the device as stopped, to block IO until later */
local->stop = 1;
@@ -538,7 +552,7 @@ static int dio24_cs_suspend(struct pcmcia_device *link)
static int dio24_cs_resume(struct pcmcia_device *link)
{
- local_info_t *local = link->priv;
+ struct local_info_t *local = link->priv;
local->stop = 0;
return 0;
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 37898d8474cd..30e11f46a640 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -74,8 +74,9 @@ NI manuals:
*/
#undef LABPC_DEBUG
-//#define LABPC_DEBUG // enable debugging messages
+/* #define LABPC_DEBUG enable debugging messages */
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -89,120 +90,120 @@ NI manuals:
#define DRV_NAME "ni_labpc"
-#define LABPC_SIZE 32 // size of io region used by board
-#define LABPC_TIMER_BASE 500 // 2 MHz master clock
+#define LABPC_SIZE 32 /* size of io region used by board */
+#define LABPC_TIMER_BASE 500 /* 2 MHz master clock */
/* Registers for the lab-pc+ */
-//write-only registers
+/* write-only registers */
#define COMMAND1_REG 0x0
#define ADC_GAIN_MASK (0x7 << 4)
#define ADC_CHAN_BITS(x) ((x) & 0x7)
-#define ADC_SCAN_EN_BIT 0x80 // enables multi channel scans
+#define ADC_SCAN_EN_BIT 0x80 /* enables multi channel scans */
#define COMMAND2_REG 0x1
-#define PRETRIG_BIT 0x1 // enable pretriggering (used in conjunction with SWTRIG)
-#define HWTRIG_BIT 0x2 // enable paced conversions on external trigger
-#define SWTRIG_BIT 0x4 // enable paced conversions
-#define CASCADE_BIT 0x8 // use two cascaded counters for pacing
+#define PRETRIG_BIT 0x1 /* enable pretriggering (used in conjunction with SWTRIG) */
+#define HWTRIG_BIT 0x2 /* enable paced conversions on external trigger */
+#define SWTRIG_BIT 0x4 /* enable paced conversions */
+#define CASCADE_BIT 0x8 /* use two cascaded counters for pacing */
#define DAC_PACED_BIT(channel) (0x40 << ((channel) & 0x1))
#define COMMAND3_REG 0x2
-#define DMA_EN_BIT 0x1 // enable dma transfers
-#define DIO_INTR_EN_BIT 0x2 // enable interrupts for 8255
-#define DMATC_INTR_EN_BIT 0x4 // enable dma terminal count interrupt
-#define TIMER_INTR_EN_BIT 0x8 // enable timer interrupt
-#define ERR_INTR_EN_BIT 0x10 // enable error interrupt
-#define ADC_FNE_INTR_EN_BIT 0x20 // enable fifo not empty interrupt
+#define DMA_EN_BIT 0x1 /* enable dma transfers */
+#define DIO_INTR_EN_BIT 0x2 /* enable interrupts for 8255 */
+#define DMATC_INTR_EN_BIT 0x4 /* enable dma terminal count interrupt */
+#define TIMER_INTR_EN_BIT 0x8 /* enable timer interrupt */
+#define ERR_INTR_EN_BIT 0x10 /* enable error interrupt */
+#define ADC_FNE_INTR_EN_BIT 0x20 /* enable fifo not empty interrupt */
#define ADC_CONVERT_REG 0x3
#define DAC_LSB_REG(channel) (0x4 + 2 * ((channel) & 0x1))
#define DAC_MSB_REG(channel) (0x5 + 2 * ((channel) & 0x1))
#define ADC_CLEAR_REG 0x8
#define DMATC_CLEAR_REG 0xa
#define TIMER_CLEAR_REG 0xc
-#define COMMAND6_REG 0xe // 1200 boards only
-#define ADC_COMMON_BIT 0x1 // select ground or common-mode reference
-#define ADC_UNIP_BIT 0x2 // adc unipolar
-#define DAC_UNIP_BIT(channel) (0x4 << ((channel) & 0x1)) // dac unipolar
-#define ADC_FHF_INTR_EN_BIT 0x20 // enable fifo half full interrupt
-#define A1_INTR_EN_BIT 0x40 // enable interrupt on end of hardware count
-#define ADC_SCAN_UP_BIT 0x80 // scan up from channel zero instead of down to zero
+#define COMMAND6_REG 0xe /* 1200 boards only */
+#define ADC_COMMON_BIT 0x1 /* select ground or common-mode reference */
+#define ADC_UNIP_BIT 0x2 /* adc unipolar */
+#define DAC_UNIP_BIT(channel) (0x4 << ((channel) & 0x1)) /* dac unipolar */
+#define ADC_FHF_INTR_EN_BIT 0x20 /* enable fifo half full interrupt */
+#define A1_INTR_EN_BIT 0x40 /* enable interrupt on end of hardware count */
+#define ADC_SCAN_UP_BIT 0x80 /* scan up from channel zero instead of down to zero */
#define COMMAND4_REG 0xf
-#define INTERVAL_SCAN_EN_BIT 0x1 // enables 'interval' scanning
-#define EXT_SCAN_EN_BIT 0x2 // enables external signal on counter b1 output to trigger scan
-#define EXT_CONVERT_OUT_BIT 0x4 // chooses direction (output or input) for EXTCONV* line
-#define ADC_DIFF_BIT 0x8 // chooses differential inputs for adc (in conjunction with board jumper)
+#define INTERVAL_SCAN_EN_BIT 0x1 /* enables 'interval' scanning */
+#define EXT_SCAN_EN_BIT 0x2 /* enables external signal on counter b1 output to trigger scan */
+#define EXT_CONVERT_OUT_BIT 0x4 /* chooses direction (output or input) for EXTCONV* line */
+#define ADC_DIFF_BIT 0x8 /* chooses differential inputs for adc (in conjunction with board jumper) */
#define EXT_CONVERT_DISABLE_BIT 0x10
-#define COMMAND5_REG 0x1c // 1200 boards only, calibration stuff
-#define EEPROM_WRITE_UNPROTECT_BIT 0x4 // enable eeprom for write
-#define DITHER_EN_BIT 0x8 // enable dithering
-#define CALDAC_LOAD_BIT 0x10 // load calibration dac
-#define SCLOCK_BIT 0x20 // serial clock - rising edge writes, falling edge reads
-#define SDATA_BIT 0x40 // serial data bit for writing to eeprom or calibration dacs
-#define EEPROM_EN_BIT 0x80 // enable eeprom for read/write
+#define COMMAND5_REG 0x1c /* 1200 boards only, calibration stuff */
+#define EEPROM_WRITE_UNPROTECT_BIT 0x4 /* enable eeprom for write */
+#define DITHER_EN_BIT 0x8 /* enable dithering */
+#define CALDAC_LOAD_BIT 0x10 /* load calibration dac */
+#define SCLOCK_BIT 0x20 /* serial clock - rising edge writes, falling edge reads */
+#define SDATA_BIT 0x40 /* serial data bit for writing to eeprom or calibration dacs */
+#define EEPROM_EN_BIT 0x80 /* enable eeprom for read/write */
#define INTERVAL_COUNT_REG 0x1e
#define INTERVAL_LOAD_REG 0x1f
#define INTERVAL_LOAD_BITS 0x1
-// read-only registers
+/* read-only registers */
#define STATUS1_REG 0x0
-#define DATA_AVAIL_BIT 0x1 // data is available in fifo
-#define OVERRUN_BIT 0x2 // overrun has occurred
-#define OVERFLOW_BIT 0x4 // fifo overflow
-#define TIMER_BIT 0x8 // timer interrupt has occured
-#define DMATC_BIT 0x10 // dma terminal count has occured
-#define EXT_TRIG_BIT 0x40 // external trigger has occured
-#define STATUS2_REG 0x1d // 1200 boards only
-#define EEPROM_OUT_BIT 0x1 // programmable eeprom serial output
-#define A1_TC_BIT 0x2 // counter A1 terminal count
-#define FNHF_BIT 0x4 // fifo not half full
+#define DATA_AVAIL_BIT 0x1 /* data is available in fifo */
+#define OVERRUN_BIT 0x2 /* overrun has occurred */
+#define OVERFLOW_BIT 0x4 /* fifo overflow */
+#define TIMER_BIT 0x8 /* timer interrupt has occured */
+#define DMATC_BIT 0x10 /* dma terminal count has occured */
+#define EXT_TRIG_BIT 0x40 /* external trigger has occured */
+#define STATUS2_REG 0x1d /* 1200 boards only */
+#define EEPROM_OUT_BIT 0x1 /* programmable eeprom serial output */
+#define A1_TC_BIT 0x2 /* counter A1 terminal count */
+#define FNHF_BIT 0x4 /* fifo not half full */
#define ADC_FIFO_REG 0xa
#define DIO_BASE_REG 0x10
#define COUNTER_A_BASE_REG 0x14
#define COUNTER_A_CONTROL_REG (COUNTER_A_BASE_REG + 0x3)
-#define INIT_A0_BITS 0x14 // check modes put conversion pacer output in harmless state (a0 mode 2)
-#define INIT_A1_BITS 0x70 // put hardware conversion counter output in harmless state (a1 mode 0)
+#define INIT_A0_BITS 0x14 /* check modes put conversion pacer output in harmless state (a0 mode 2) */
+#define INIT_A1_BITS 0x70 /* put hardware conversion counter output in harmless state (a1 mode 0) */
#define COUNTER_B_BASE_REG 0x18
-static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int labpc_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG);
-static int labpc_drain_fifo(struct comedi_device * dev);
-static void labpc_drain_dma(struct comedi_device * dev);
-static void handle_isa_dma(struct comedi_device * dev);
-static void labpc_drain_dregs(struct comedi_device * dev);
-static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int labpc_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int labpc_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int labpc_calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int labpc_calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int labpc_eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int labpc_eeprom_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static irqreturn_t labpc_interrupt(int irq, void *d);
+static int labpc_drain_fifo(struct comedi_device *dev);
+static void labpc_drain_dma(struct comedi_device *dev);
+static void handle_isa_dma(struct comedi_device *dev);
+static void labpc_drain_dregs(struct comedi_device *dev);
+static int labpc_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int labpc_calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int labpc_calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int labpc_eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int labpc_eeprom_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd);
-static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd);
+static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd);
#ifdef CONFIG_COMEDI_PCI
static int labpc_find_device(struct comedi_device *dev, int bus, int slot);
#endif
static int labpc_dio_mem_callback(int dir, int port, int data,
unsigned long arg);
-static void labpc_serial_out(struct comedi_device * dev, unsigned int value,
+static void labpc_serial_out(struct comedi_device *dev, unsigned int value,
unsigned int num_bits);
-static unsigned int labpc_serial_in(struct comedi_device * dev);
-static unsigned int labpc_eeprom_read(struct comedi_device * dev,
+static unsigned int labpc_serial_in(struct comedi_device *dev);
+static unsigned int labpc_eeprom_read(struct comedi_device *dev,
unsigned int address);
-static unsigned int labpc_eeprom_read_status(struct comedi_device * dev);
-static unsigned int labpc_eeprom_write(struct comedi_device * dev,
+static unsigned int labpc_eeprom_read_status(struct comedi_device *dev);
+static unsigned int labpc_eeprom_write(struct comedi_device *dev,
unsigned int address, unsigned int value);
-static void write_caldac(struct comedi_device * dev, unsigned int channel,
+static void write_caldac(struct comedi_device *dev, unsigned int channel,
unsigned int value);
enum scan_mode {
@@ -212,9 +213,9 @@ enum scan_mode {
MODE_MULT_CHAN_DOWN,
};
-//analog input ranges
+/* analog input ranges */
#define NUM_LABPC_PLUS_AI_RANGES 16
-// indicates unipolar ranges
+/* indicates unipolar ranges */
static const int labpc_plus_is_unipolar[NUM_LABPC_PLUS_AI_RANGES] = {
0,
0,
@@ -234,7 +235,7 @@ static const int labpc_plus_is_unipolar[NUM_LABPC_PLUS_AI_RANGES] = {
1,
};
-// map range index to gain bits
+/* map range index to gain bits */
static const int labpc_plus_ai_gain_bits[NUM_LABPC_PLUS_AI_RANGES] = {
0x00,
0x10,
@@ -276,7 +277,7 @@ static const struct comedi_lrange range_labpc_plus_ai = {
};
#define NUM_LABPC_1200_AI_RANGES 14
-// indicates unipolar ranges
+/* indicates unipolar ranges */
const int labpc_1200_is_unipolar[NUM_LABPC_1200_AI_RANGES] = {
0,
0,
@@ -294,7 +295,7 @@ const int labpc_1200_is_unipolar[NUM_LABPC_1200_AI_RANGES] = {
1,
};
-// map range index to gain bits
+/* map range index to gain bits */
const int labpc_1200_ai_gain_bits[NUM_LABPC_1200_AI_RANGES] = {
0x00,
0x20,
@@ -331,7 +332,7 @@ const struct comedi_lrange range_labpc_1200_ai = {
}
};
-//analog output ranges
+/* analog output ranges */
#define AO_RANGE_IS_UNIPOLAR 0x1
static const struct comedi_lrange range_labpc_ao = {
2,
@@ -360,58 +361,58 @@ static inline void labpc_writeb(unsigned int byte, unsigned long address)
writeb(byte, (void *)address);
}
-static const labpc_board labpc_boards[] = {
+static const struct labpc_board_struct labpc_boards[] = {
{
- name: "lab-pc-1200",
- ai_speed:10000,
- bustype: isa_bustype,
- register_layout:labpc_1200_layout,
- has_ao: 1,
- ai_range_table:&range_labpc_1200_ai,
- ai_range_code:labpc_1200_ai_gain_bits,
- ai_range_is_unipolar:labpc_1200_is_unipolar,
- ai_scan_up:1,
- memory_mapped_io:0,
+ .name = "lab-pc-1200",
+ .ai_speed = 10000,
+ .bustype = isa_bustype,
+ .register_layout = labpc_1200_layout,
+ .has_ao = 1,
+ .ai_range_table = &range_labpc_1200_ai,
+ .ai_range_code = labpc_1200_ai_gain_bits,
+ .ai_range_is_unipolar = labpc_1200_is_unipolar,
+ .ai_scan_up = 1,
+ .memory_mapped_io = 0,
},
{
- name: "lab-pc-1200ai",
- ai_speed:10000,
- bustype: isa_bustype,
- register_layout:labpc_1200_layout,
- has_ao: 0,
- ai_range_table:&range_labpc_1200_ai,
- ai_range_code:labpc_1200_ai_gain_bits,
- ai_range_is_unipolar:labpc_1200_is_unipolar,
- ai_scan_up:1,
- memory_mapped_io:0,
+ .name = "lab-pc-1200ai",
+ .ai_speed = 10000,
+ .bustype = isa_bustype,
+ .register_layout = labpc_1200_layout,
+ .has_ao = 0,
+ .ai_range_table = &range_labpc_1200_ai,
+ .ai_range_code = labpc_1200_ai_gain_bits,
+ .ai_range_is_unipolar = labpc_1200_is_unipolar,
+ .ai_scan_up = 1,
+ .memory_mapped_io = 0,
},
{
- name: "lab-pc+",
- ai_speed:12000,
- bustype: isa_bustype,
- register_layout:labpc_plus_layout,
- has_ao: 1,
- ai_range_table:&range_labpc_plus_ai,
- ai_range_code:labpc_plus_ai_gain_bits,
- ai_range_is_unipolar:labpc_plus_is_unipolar,
- ai_scan_up:0,
- memory_mapped_io:0,
+ .name = "lab-pc+",
+ .ai_speed = 12000,
+ .bustype = isa_bustype,
+ .register_layout = labpc_plus_layout,
+ .has_ao = 1,
+ .ai_range_table = &range_labpc_plus_ai,
+ .ai_range_code = labpc_plus_ai_gain_bits,
+ .ai_range_is_unipolar = labpc_plus_is_unipolar,
+ .ai_scan_up = 0,
+ .memory_mapped_io = 0,
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "pci-1200",
- device_id:0x161,
- ai_speed:10000,
- bustype: pci_bustype,
- register_layout:labpc_1200_layout,
- has_ao: 1,
- ai_range_table:&range_labpc_1200_ai,
- ai_range_code:labpc_1200_ai_gain_bits,
- ai_range_is_unipolar:labpc_1200_is_unipolar,
- ai_scan_up:1,
- memory_mapped_io:1,
+ .name = "pci-1200",
+ .device_id = 0x161,
+ .ai_speed = 10000,
+ .bustype = pci_bustype,
+ .register_layout = labpc_1200_layout,
+ .has_ao = 1,
+ .ai_range_table = &range_labpc_1200_ai,
+ .ai_range_code = labpc_1200_ai_gain_bits,
+ .ai_range_is_unipolar = labpc_1200_is_unipolar,
+ .ai_scan_up = 1,
+ .memory_mapped_io = 1,
},
- // dummy entry so pci board works when comedi_config is passed driver name
+ /* dummy entry so pci board works when comedi_config is passed driver name */
{
.name = DRV_NAME,
.bustype = pci_bustype,
@@ -422,21 +423,21 @@ static const labpc_board labpc_boards[] = {
/*
* Useful for shorthand access to the particular board structure
*/
-#define thisboard ((labpc_board *)dev->board_ptr)
+#define thisboard ((struct labpc_board_struct *)dev->board_ptr)
-static const int dma_buffer_size = 0xff00; // size in bytes of dma buffer
-static const int sample_size = 2; // 2 bytes per sample
+static const int dma_buffer_size = 0xff00; /* size in bytes of dma buffer */
+static const int sample_size = 2; /* 2 bytes per sample */
-#define devpriv ((labpc_private *)dev->private)
+#define devpriv ((struct labpc_private *)dev->private)
static struct comedi_driver driver_labpc = {
.driver_name = DRV_NAME,
.module = THIS_MODULE,
.attach = labpc_attach,
.detach = labpc_common_detach,
- .num_names = sizeof(labpc_boards) / sizeof(labpc_board),
+ .num_names = ARRAY_SIZE(labpc_boards),
.board_name = &labpc_boards[0].name,
- .offset = sizeof(labpc_board),
+ .offset = sizeof(struct labpc_board_struct),
};
#ifdef CONFIG_COMEDI_PCI
@@ -448,7 +449,7 @@ static DEFINE_PCI_DEVICE_TABLE(labpc_pci_table) = {
MODULE_DEVICE_TABLE(pci, labpc_pci_table);
#endif /* CONFIG_COMEDI_PCI */
-static inline int labpc_counter_load(struct comedi_device * dev,
+static inline int labpc_counter_load(struct comedi_device *dev,
unsigned long base_address, unsigned int counter_number,
unsigned int count, unsigned int mode)
{
@@ -459,7 +460,7 @@ static inline int labpc_counter_load(struct comedi_device * dev,
return i8254_load(base_address, 0, counter_number, count, mode);
}
-int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
+int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
unsigned int irq, unsigned int dma_chan)
{
struct comedi_subdevice *s;
@@ -481,7 +482,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
printk("io base address is zero!\n");
return -EINVAL;
}
- // request io regions for isa boards
+ /* request io regions for isa boards */
if (thisboard->bustype == isa_bustype) {
/* check if io addresses are available */
if (!request_region(iobase, LABPC_SIZE,
@@ -499,7 +500,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
devpriv->read_byte = labpc_inb;
devpriv->write_byte = labpc_outb;
}
- // initialize board's command registers
+ /* initialize board's command registers */
devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG);
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG);
@@ -516,7 +517,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
isr_flags = 0;
if (thisboard->bustype == pci_bustype)
isr_flags |= IRQF_SHARED;
- if (comedi_request_irq(irq, labpc_interrupt, isr_flags,
+ if (request_irq(irq, labpc_interrupt, isr_flags,
driver_labpc.driver_name, dev)) {
printk("unable to allocate irq %u\n", irq);
return -EINVAL;
@@ -524,12 +525,12 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
}
dev->irq = irq;
- // grab dma channel
+ /* grab dma channel */
if (dma_chan > 3) {
printk(" invalid dma channel %u\n", dma_chan);
return -EINVAL;
} else if (dma_chan) {
- // allocate dma buffer
+ /* allocate dma buffer */
devpriv->dma_buffer =
kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA);
if (devpriv->dma_buffer == NULL) {
@@ -562,7 +563,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
SDF_CMD_READ;
s->n_chan = 8;
s->len_chanlist = 8;
- s->maxdata = (1 << 12) - 1; // 12 bit resolution
+ s->maxdata = (1 << 12) - 1; /* 12 bit resolution */
s->range_table = thisboard->ai_range_table;
s->do_cmd = labpc_ai_cmd;
s->do_cmdtest = labpc_ai_cmdtest;
@@ -577,7 +578,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND;
s->n_chan = NUM_AO_CHAN;
- s->maxdata = (1 << 12) - 1; // 12 bit resolution
+ s->maxdata = (1 << 12) - 1; /* 12 bit resolution */
s->range_table = &range_labpc_ao;
s->insn_read = labpc_ao_rinsn;
s->insn_write = labpc_ao_winsn;
@@ -595,14 +596,14 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
/* 8255 dio */
s = dev->subdevices + 2;
- // if board uses io memory we have to give a custom callback function to the 8255 driver
+ /* if board uses io memory we have to give a custom callback function to the 8255 driver */
if (thisboard->memory_mapped_io)
subdev_8255_init(dev, s, labpc_dio_mem_callback,
(unsigned long)(dev->iobase + DIO_BASE_REG));
else
subdev_8255_init(dev, s, NULL, dev->iobase + DIO_BASE_REG);
- // calibration subdevices for boards that have one
+ /* calibration subdevices for boards that have one */
s = dev->subdevices + 3;
if (thisboard->register_layout == labpc_1200_layout) {
s->type = COMEDI_SUBD_CALIB;
@@ -643,7 +644,7 @@ int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
return 0;
}
-static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase = 0;
unsigned int irq = 0;
@@ -653,10 +654,10 @@ static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it
#endif
/* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(labpc_private)) < 0)
+ if (alloc_private(dev, sizeof(struct labpc_private)) < 0)
return -ENOMEM;
- // get base address, irq etc. based on bustype
+ /* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
case isa_bustype:
iobase = it->options[0];
@@ -692,7 +693,7 @@ static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it
return labpc_common_attach(dev, iobase, irq, dma_chan);
}
-// adapted from ni_pcimio for finding mite based boards (pc-1200)
+/* adapted from ni_pcimio for finding mite based boards (pc-1200) */
#ifdef CONFIG_COMEDI_PCI
static int labpc_find_device(struct comedi_device *dev, int bus, int slot)
{
@@ -701,7 +702,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot)
for (mite = mite_devices; mite; mite = mite->next) {
if (mite->used)
continue;
- // if bus/slot are specified then make sure we have the right bus/slot
+ /* if bus/slot are specified then make sure we have the right bus/slot */
if (bus || slot) {
if (bus != mite->pcidev->bus->number
|| slot != PCI_SLOT(mite->pcidev->devfn))
@@ -712,7 +713,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot)
continue;
if (mite_device_id(mite) == labpc_boards[i].device_id) {
devpriv->mite = mite;
- // fixup board pointer, in case we were using the dummy "ni_labpc" entry
+ /* fixup board pointer, in case we were using the dummy "ni_labpc" entry */
dev->board_ptr = &labpc_boards[i];
return 0;
}
@@ -724,7 +725,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot)
}
#endif
-int labpc_common_detach(struct comedi_device * dev)
+int labpc_common_detach(struct comedi_device *dev)
{
printk("comedi%d: ni_labpc: detach\n", dev->minor);
@@ -737,7 +738,7 @@ int labpc_common_detach(struct comedi_device * dev)
if (devpriv->dma_chan)
free_dma(devpriv->dma_chan);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (thisboard->bustype == isa_bustype && dev->iobase)
release_region(dev->iobase, LABPC_SIZE);
#ifdef CONFIG_COMEDI_PCI
@@ -748,21 +749,21 @@ int labpc_common_detach(struct comedi_device * dev)
return 0;
};
-static void labpc_clear_adc_fifo(const struct comedi_device * dev)
+static void labpc_clear_adc_fifo(const struct comedi_device *dev)
{
devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG);
devpriv->read_byte(dev->iobase + ADC_FIFO_REG);
devpriv->read_byte(dev->iobase + ADC_FIFO_REG);
}
-static int labpc_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->command2_bits &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT;
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
devpriv->command3_bits = 0;
devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG);
@@ -770,7 +771,7 @@ static int labpc_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd * cmd)
+static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd)
{
if (cmd->chanlist_len == 1)
return MODE_SINGLE_CHAN;
@@ -788,13 +789,13 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd * cmd)
if (CR_CHAN(cmd->chanlist[0]) > CR_CHAN(cmd->chanlist[1]))
return MODE_MULT_CHAN_DOWN;
- rt_printk("ni_labpc: bug! this should never happen\n");
+ printk("ni_labpc: bug! this should never happen\n");
return 0;
}
-static int labpc_ai_chanlist_invalid(const struct comedi_device * dev,
- const struct comedi_cmd * cmd)
+static int labpc_ai_chanlist_invalid(const struct comedi_device *dev,
+ const struct comedi_cmd *cmd)
{
int mode, channel, range, aref, i;
@@ -844,7 +845,7 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device * dev,
}
break;
default:
- rt_printk("ni_labpc: bug! in chanlist check\n");
+ printk("ni_labpc: bug! in chanlist check\n");
return 1;
break;
}
@@ -865,7 +866,7 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device * dev,
return 0;
}
-static int labpc_use_continuous_mode(const struct comedi_cmd * cmd)
+static int labpc_use_continuous_mode(const struct comedi_cmd *cmd)
{
if (labpc_ai_scan_mode(cmd) == MODE_SINGLE_CHAN)
return 1;
@@ -876,7 +877,7 @@ static int labpc_use_continuous_mode(const struct comedi_cmd * cmd)
return 0;
}
-static unsigned int labpc_ai_convert_period(const struct comedi_cmd * cmd)
+static unsigned int labpc_ai_convert_period(const struct comedi_cmd *cmd)
{
if (cmd->convert_src != TRIG_TIMER)
return 0;
@@ -888,7 +889,7 @@ static unsigned int labpc_ai_convert_period(const struct comedi_cmd * cmd)
return cmd->convert_arg;
}
-static void labpc_set_ai_convert_period(struct comedi_cmd * cmd, unsigned int ns)
+static void labpc_set_ai_convert_period(struct comedi_cmd *cmd, unsigned int ns)
{
if (cmd->convert_src != TRIG_TIMER)
return;
@@ -902,7 +903,7 @@ static void labpc_set_ai_convert_period(struct comedi_cmd * cmd, unsigned int ns
cmd->convert_arg = ns;
}
-static unsigned int labpc_ai_scan_period(const struct comedi_cmd * cmd)
+static unsigned int labpc_ai_scan_period(const struct comedi_cmd *cmd)
{
if (cmd->scan_begin_src != TRIG_TIMER)
return 0;
@@ -914,7 +915,7 @@ static unsigned int labpc_ai_scan_period(const struct comedi_cmd * cmd)
return cmd->scan_begin_arg;
}
-static void labpc_set_ai_scan_period(struct comedi_cmd * cmd, unsigned int ns)
+static void labpc_set_ai_scan_period(struct comedi_cmd *cmd, unsigned int ns)
{
if (cmd->scan_begin_src != TRIG_TIMER)
return;
@@ -926,8 +927,8 @@ static void labpc_set_ai_scan_period(struct comedi_cmd * cmd, unsigned int ns)
cmd->scan_begin_arg = ns;
}
-static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int labpc_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, tmp2;
@@ -980,7 +981,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
cmd->stop_src != TRIG_EXT && cmd->stop_src != TRIG_NONE)
err++;
- // can't have external stop and start triggers at once
+ /* can't have external stop and start triggers at once */
if (cmd->start_src == TRIG_EXT && cmd->stop_src == TRIG_EXT)
err++;
@@ -1008,7 +1009,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
err++;
}
}
- // make sure scan timing is not too fast
+ /* make sure scan timing is not too fast */
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->convert_src == TRIG_TIMER &&
cmd->scan_begin_arg <
@@ -1024,7 +1025,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
err++;
}
}
- // stop source
+ /* stop source */
switch (cmd->stop_src) {
case TRIG_COUNT:
if (!cmd->stop_arg) {
@@ -1038,7 +1039,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
err++;
}
break;
- // TRIG_EXT doesn't care since it doesn't trigger off a numbered channel
+ /* TRIG_EXT doesn't care since it doesn't trigger off a numbered channel */
default:
break;
}
@@ -1063,7 +1064,7 @@ static int labpc_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int channel, range, aref;
unsigned long irq_flags;
@@ -1081,77 +1082,77 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
range = CR_RANGE(cmd->chanlist[0]);
aref = CR_AREF(cmd->chanlist[0]);
- // make sure board is disabled before setting up aquisition
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* make sure board is disabled before setting up aquisition */
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->command2_bits &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT;
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
devpriv->command3_bits = 0;
devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG);
- // initialize software conversion count
+ /* initialize software conversion count */
if (cmd->stop_src == TRIG_COUNT) {
devpriv->count = cmd->stop_arg * cmd->chanlist_len;
}
- // setup hardware conversion counter
+ /* setup hardware conversion counter */
if (cmd->stop_src == TRIG_EXT) {
- // load counter a1 with count of 3 (pc+ manual says this is minimum allowed) using mode 0
+ /* load counter a1 with count of 3 (pc+ manual says this is minimum allowed) using mode 0 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG,
1, 3, 0);
if (ret < 0) {
comedi_error(dev, "error loading counter a1");
return -1;
}
- } else // otherwise, just put a1 in mode 0 with no count to set its output low
+ } else /* otherwise, just put a1 in mode 0 with no count to set its output low */
devpriv->write_byte(INIT_A1_BITS,
dev->iobase + COUNTER_A_CONTROL_REG);
- // figure out what method we will use to transfer data
- if (devpriv->dma_chan && // need a dma channel allocated
- // dma unsafe at RT priority, and too much setup time for TRIG_WAKE_EOS for
+ /* figure out what method we will use to transfer data */
+ if (devpriv->dma_chan && /* need a dma channel allocated */
+ /* dma unsafe at RT priority, and too much setup time for TRIG_WAKE_EOS for */
(cmd->flags & (TRIG_WAKE_EOS | TRIG_RT)) == 0 &&
- // only available on the isa boards
+ /* only available on the isa boards */
thisboard->bustype == isa_bustype) {
xfer = isa_dma_transfer;
- } else if (thisboard->register_layout == labpc_1200_layout && // pc-plus has no fifo-half full interrupt
- // wake-end-of-scan should interrupt on fifo not empty
+ } else if (thisboard->register_layout == labpc_1200_layout && /* pc-plus has no fifo-half full interrupt */
+ /* wake-end-of-scan should interrupt on fifo not empty */
(cmd->flags & TRIG_WAKE_EOS) == 0 &&
- // make sure we are taking more than just a few points
+ /* make sure we are taking more than just a few points */
(cmd->stop_src != TRIG_COUNT || devpriv->count > 256)) {
xfer = fifo_half_full_transfer;
} else
xfer = fifo_not_empty_transfer;
devpriv->current_transfer = xfer;
- // setup command6 register for 1200 boards
+ /* setup command6 register for 1200 boards */
if (thisboard->register_layout == labpc_1200_layout) {
- // reference inputs to ground or common?
+ /* reference inputs to ground or common? */
if (aref != AREF_GROUND)
devpriv->command6_bits |= ADC_COMMON_BIT;
else
devpriv->command6_bits &= ~ADC_COMMON_BIT;
- // bipolar or unipolar range?
+ /* bipolar or unipolar range? */
if (thisboard->ai_range_is_unipolar[range])
devpriv->command6_bits |= ADC_UNIP_BIT;
else
devpriv->command6_bits &= ~ADC_UNIP_BIT;
- // interrupt on fifo half full?
+ /* interrupt on fifo half full? */
if (xfer == fifo_half_full_transfer)
devpriv->command6_bits |= ADC_FHF_INTR_EN_BIT;
else
devpriv->command6_bits &= ~ADC_FHF_INTR_EN_BIT;
- // enable interrupt on counter a1 terminal count?
+ /* enable interrupt on counter a1 terminal count? */
if (cmd->stop_src == TRIG_EXT)
devpriv->command6_bits |= A1_INTR_EN_BIT;
else
devpriv->command6_bits &= ~A1_INTR_EN_BIT;
- // are we scanning up or down through channels?
+ /* are we scanning up or down through channels? */
if (labpc_ai_scan_mode(cmd) == MODE_MULT_CHAN_UP)
devpriv->command6_bits |= ADC_SCAN_UP_BIT;
else
devpriv->command6_bits &= ~ADC_SCAN_UP_BIT;
- // write to register
+ /* write to register */
devpriv->write_byte(devpriv->command6_bits,
dev->iobase + COMMAND6_REG);
}
@@ -1162,23 +1163,23 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
channel = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]);
else
channel = CR_CHAN(cmd->chanlist[0]);
- // munge channel bits for differential / scan disabled mode
+ /* munge channel bits for differential / scan disabled mode */
if (labpc_ai_scan_mode(cmd) != MODE_SINGLE_CHAN && aref == AREF_DIFF)
channel *= 2;
devpriv->command1_bits |= ADC_CHAN_BITS(channel);
devpriv->command1_bits |= thisboard->ai_range_code[range];
devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG);
- // manual says to set scan enable bit on second pass
+ /* manual says to set scan enable bit on second pass */
if (labpc_ai_scan_mode(cmd) == MODE_MULT_CHAN_UP ||
labpc_ai_scan_mode(cmd) == MODE_MULT_CHAN_DOWN) {
devpriv->command1_bits |= ADC_SCAN_EN_BIT;
/* need a brief delay before enabling scan, or scan list will get screwed when you switch
* between scan up to scan down mode - dunno why */
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command1_bits,
dev->iobase + COMMAND1_REG);
}
- // setup any external triggering/pacing (command4 register)
+ /* setup any external triggering/pacing (command4 register) */
devpriv->command4_bits = 0;
if (cmd->convert_src != TRIG_EXT)
devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT;
@@ -1189,21 +1190,21 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
if (cmd->scan_begin_src == TRIG_EXT)
devpriv->command4_bits |= EXT_SCAN_EN_BIT;
}
- // single-ended/differential
+ /* single-ended/differential */
if (aref == AREF_DIFF)
devpriv->command4_bits |= ADC_DIFF_BIT;
devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG);
devpriv->write_byte(cmd->chanlist_len,
dev->iobase + INTERVAL_COUNT_REG);
- // load count
+ /* load count */
devpriv->write_byte(INTERVAL_LOAD_BITS,
dev->iobase + INTERVAL_LOAD_REG);
if (cmd->convert_src == TRIG_TIMER || cmd->scan_begin_src == TRIG_TIMER) {
- // set up pacing
+ /* set up pacing */
labpc_adc_timing(dev, cmd);
- // load counter b0 in mode 3
+ /* load counter b0 in mode 3 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG,
0, devpriv->divisor_b0, 3);
if (ret < 0) {
@@ -1211,9 +1212,9 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return -1;
}
}
- // set up conversion pacing
+ /* set up conversion pacing */
if (labpc_ai_convert_period(cmd)) {
- // load counter a0 in mode 2
+ /* load counter a0 in mode 2 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG,
0, devpriv->divisor_a0, 2);
if (ret < 0) {
@@ -1224,9 +1225,9 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
devpriv->write_byte(INIT_A0_BITS,
dev->iobase + COUNTER_A_CONTROL_REG);
- // set up scan pacing
+ /* set up scan pacing */
if (labpc_ai_scan_period(cmd)) {
- // load counter b1 in mode 2
+ /* load counter b1 in mode 2 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG,
1, devpriv->divisor_b1, 2);
if (ret < 0) {
@@ -1237,7 +1238,7 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
labpc_clear_adc_fifo(dev);
- // set up dma transfer
+ /* set up dma transfer */
if (xfer == isa_dma_transfer) {
irq_flags = claim_dma_lock();
disable_dma(devpriv->dma_chan);
@@ -1246,7 +1247,7 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
clear_dma_ff(devpriv->dma_chan);
set_dma_addr(devpriv->dma_chan,
virt_to_bus(devpriv->dma_buffer));
- // set appropriate size of transfer
+ /* set appropriate size of transfer */
devpriv->dma_transfer_size = labpc_suggest_transfer_size(*cmd);
if (cmd->stop_src == TRIG_COUNT &&
devpriv->count * sample_size <
@@ -1257,25 +1258,25 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
release_dma_lock(irq_flags);
- // enable board's dma
+ /* enable board's dma */
devpriv->command3_bits |= DMA_EN_BIT | DMATC_INTR_EN_BIT;
} else
devpriv->command3_bits &= ~DMA_EN_BIT & ~DMATC_INTR_EN_BIT;
- // enable error interrupts
+ /* enable error interrupts */
devpriv->command3_bits |= ERR_INTR_EN_BIT;
- // enable fifo not empty interrupt?
+ /* enable fifo not empty interrupt? */
if (xfer == fifo_not_empty_transfer)
devpriv->command3_bits |= ADC_FNE_INTR_EN_BIT;
else
devpriv->command3_bits &= ~ADC_FNE_INTR_EN_BIT;
devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG);
- // startup aquisition
+ /* startup aquisition */
- // command2 reg
- // use 2 cascaded counters for pacing
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* command2 reg */
+ /* use 2 cascaded counters for pacing */
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->command2_bits |= CASCADE_BIT;
switch (cmd->start_src) {
case TRIG_EXT:
@@ -1303,13 +1304,13 @@ static int labpc_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return -1;
}
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
/* interrupt service routine */
-static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t labpc_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
@@ -1325,7 +1326,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG)
cmd = &async->cmd;
async->events = 0;
- // read board status
+ /* read board status */
devpriv->status1_bits = devpriv->read_byte(dev->iobase + STATUS1_REG);
if (thisboard->register_layout == labpc_1200_layout)
devpriv->status2_bits =
@@ -1339,7 +1340,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG)
}
if (devpriv->status1_bits & OVERRUN_BIT) {
- // clear error interrupt
+ /* clear error interrupt */
devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
comedi_event(dev, s);
@@ -1348,7 +1349,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG)
}
if (devpriv->current_transfer == isa_dma_transfer) {
- // if a dma terminal count of external stop trigger has occurred
+ /* if a dma terminal count of external stop trigger has occurred */
if (devpriv->status1_bits & DMATC_BIT ||
(thisboard->register_layout == labpc_1200_layout
&& devpriv->status2_bits & A1_TC_BIT)) {
@@ -1359,19 +1360,19 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG)
if (devpriv->status1_bits & TIMER_BIT) {
comedi_error(dev, "handled timer interrupt?");
- // clear it
+ /* clear it */
devpriv->write_byte(0x1, dev->iobase + TIMER_CLEAR_REG);
}
if (devpriv->status1_bits & OVERFLOW_BIT) {
- // clear error interrupt
+ /* clear error interrupt */
devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG);
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
comedi_event(dev, s);
comedi_error(dev, "overflow");
return IRQ_HANDLED;
}
- // handle external stop trigger
+ /* handle external stop trigger */
if (cmd->stop_src == TRIG_EXT) {
if (devpriv->status2_bits & A1_TC_BIT) {
labpc_drain_dregs(dev);
@@ -1392,8 +1393,8 @@ static irqreturn_t labpc_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-// read all available samples from ai fifo
-static int labpc_drain_fifo(struct comedi_device * dev)
+/* read all available samples from ai fifo */
+static int labpc_drain_fifo(struct comedi_device *dev)
{
unsigned int lsb, msb;
short data;
@@ -1405,7 +1406,7 @@ static int labpc_drain_fifo(struct comedi_device * dev)
for (i = 0; (devpriv->status1_bits & DATA_AVAIL_BIT) && i < timeout;
i++) {
- // quit if we have all the data we want
+ /* quit if we have all the data we want */
if (async->cmd.stop_src == TRIG_COUNT) {
if (devpriv->count == 0)
break;
@@ -1427,7 +1428,7 @@ static int labpc_drain_fifo(struct comedi_device * dev)
return 0;
}
-static void labpc_drain_dma(struct comedi_device * dev)
+static void labpc_drain_dma(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
@@ -1444,7 +1445,7 @@ static void labpc_drain_dma(struct comedi_device * dev)
* count and address get set correctly */
clear_dma_ff(devpriv->dma_chan);
- // figure out how many points to read
+ /* figure out how many points to read */
max_points = devpriv->dma_transfer_size / sample_size;
/* residue is the number of points left to be done on the dma
* transfer. It should always be zero at this point unless
@@ -1455,7 +1456,7 @@ static void labpc_drain_dma(struct comedi_device * dev)
if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT)
num_points = devpriv->count;
- // figure out how many points will be stored next time
+ /* figure out how many points will be stored next time */
leftover = 0;
if (async->cmd.stop_src != TRIG_COUNT) {
leftover = devpriv->dma_transfer_size / sample_size;
@@ -1472,7 +1473,7 @@ static void labpc_drain_dma(struct comedi_device * dev)
if (async->cmd.stop_src == TRIG_COUNT)
devpriv->count -= num_points;
- // set address and count for next transfer
+ /* set address and count for next transfer */
set_dma_addr(devpriv->dma_chan, virt_to_bus(devpriv->dma_buffer));
set_dma_count(devpriv->dma_chan, leftover * sample_size);
release_dma_lock(flags);
@@ -1480,19 +1481,19 @@ static void labpc_drain_dma(struct comedi_device * dev)
async->events |= COMEDI_CB_BLOCK;
}
-static void handle_isa_dma(struct comedi_device * dev)
+static void handle_isa_dma(struct comedi_device *dev)
{
labpc_drain_dma(dev);
enable_dma(devpriv->dma_chan);
- // clear dma tc interrupt
+ /* clear dma tc interrupt */
devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG);
}
/* makes sure all data aquired by board is transfered to comedi (used
* when aquisition is terminated by stop_src == TRIG_EXT). */
-static void labpc_drain_dregs(struct comedi_device * dev)
+static void labpc_drain_dregs(struct comedi_device *dev)
{
if (devpriv->current_transfer == isa_dma_transfer)
labpc_drain_dma(dev);
@@ -1500,8 +1501,8 @@ static void labpc_drain_dregs(struct comedi_device * dev)
labpc_drain_fifo(dev);
}
-static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan, range;
@@ -1509,13 +1510,13 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
int timeout = 1000;
unsigned long flags;
- // disable timed conversions
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* disable timed conversions */
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->command2_bits &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT;
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // disable interrupt generation and dma
+ /* disable interrupt generation and dma */
devpriv->command3_bits = 0;
devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG);
@@ -1524,41 +1525,41 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
chan = CR_CHAN(insn->chanspec);
range = CR_RANGE(insn->chanspec);
devpriv->command1_bits |= thisboard->ai_range_code[range];
- // munge channel bits for differential/scan disabled mode
+ /* munge channel bits for differential/scan disabled mode */
if (CR_AREF(insn->chanspec) == AREF_DIFF)
chan *= 2;
devpriv->command1_bits |= ADC_CHAN_BITS(chan);
devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG);
- // setup command6 register for 1200 boards
+ /* setup command6 register for 1200 boards */
if (thisboard->register_layout == labpc_1200_layout) {
- // reference inputs to ground or common?
+ /* reference inputs to ground or common? */
if (CR_AREF(insn->chanspec) != AREF_GROUND)
devpriv->command6_bits |= ADC_COMMON_BIT;
else
devpriv->command6_bits &= ~ADC_COMMON_BIT;
- // bipolar or unipolar range?
+ /* bipolar or unipolar range? */
if (thisboard->ai_range_is_unipolar[range])
devpriv->command6_bits |= ADC_UNIP_BIT;
else
devpriv->command6_bits &= ~ADC_UNIP_BIT;
- // don't interrupt on fifo half full
+ /* don't interrupt on fifo half full */
devpriv->command6_bits &= ~ADC_FHF_INTR_EN_BIT;
- // don't enable interrupt on counter a1 terminal count?
+ /* don't enable interrupt on counter a1 terminal count? */
devpriv->command6_bits &= ~A1_INTR_EN_BIT;
- // write to register
+ /* write to register */
devpriv->write_byte(devpriv->command6_bits,
dev->iobase + COMMAND6_REG);
}
- // setup command4 register
+ /* setup command4 register */
devpriv->command4_bits = 0;
devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT;
- // single-ended/differential
+ /* single-ended/differential */
if (CR_AREF(insn->chanspec) == AREF_DIFF)
devpriv->command4_bits |= ADC_DIFF_BIT;
devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG);
- // initialize pacer counter output to make sure it doesn't cause any problems
+ /* initialize pacer counter output to make sure it doesn't cause any problems */
devpriv->write_byte(INIT_A0_BITS, dev->iobase + COUNTER_A_CONTROL_REG);
labpc_clear_adc_fifo(dev);
@@ -1571,7 +1572,7 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
if (devpriv->read_byte(dev->iobase +
STATUS1_REG) & DATA_AVAIL_BIT)
break;
- comedi_udelay(1);
+ udelay(1);
}
if (i == timeout) {
comedi_error(dev, "timeout");
@@ -1585,9 +1586,9 @@ static int labpc_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-// analog output insn
-static int labpc_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/* analog output insn */
+static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel, range;
unsigned long flags;
@@ -1595,56 +1596,56 @@ static int labpc_ao_winsn(struct comedi_device * dev, struct comedi_subdevice *
channel = CR_CHAN(insn->chanspec);
- // turn off pacing of analog output channel
+ /* turn off pacing of analog output channel */
/* note: hardware bug in daqcard-1200 means pacing cannot
* be independently enabled/disabled for its the two channels */
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
devpriv->command2_bits &= ~DAC_PACED_BIT(channel);
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- // set range
+ /* set range */
if (thisboard->register_layout == labpc_1200_layout) {
range = CR_RANGE(insn->chanspec);
if (range & AO_RANGE_IS_UNIPOLAR)
devpriv->command6_bits |= DAC_UNIP_BIT(channel);
else
devpriv->command6_bits &= ~DAC_UNIP_BIT(channel);
- // write to register
+ /* write to register */
devpriv->write_byte(devpriv->command6_bits,
dev->iobase + COMMAND6_REG);
}
- // send data
+ /* send data */
lsb = data[0] & 0xff;
msb = (data[0] >> 8) & 0xff;
devpriv->write_byte(lsb, dev->iobase + DAC_LSB_REG(channel));
devpriv->write_byte(msb, dev->iobase + DAC_MSB_REG(channel));
- // remember value for readback
+ /* remember value for readback */
devpriv->ao_value[channel] = data[0];
return 1;
}
-// analog output readback insn
-static int labpc_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+/* analog output readback insn */
+static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];
return 1;
}
-static int labpc_calib_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int labpc_calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->caldac[CR_CHAN(insn->chanspec)];
return 1;
}
-static int labpc_calib_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int labpc_calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel = CR_CHAN(insn->chanspec);
@@ -1652,21 +1653,21 @@ static int labpc_calib_write_insn(struct comedi_device * dev, struct comedi_subd
return 1;
}
-static int labpc_eeprom_read_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int labpc_eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->eeprom_data[CR_CHAN(insn->chanspec)];
return 1;
}
-static int labpc_eeprom_write_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int labpc_eeprom_write_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel = CR_CHAN(insn->chanspec);
int ret;
- // only allow writes to user area of eeprom
+ /* only allow writes to user area of eeprom */
if (channel < 16 || channel > 127) {
printk("eeprom writes are only allowed to channels 16 through 127 (the pointer and user areas)");
return -EINVAL;
@@ -1679,7 +1680,7 @@ static int labpc_eeprom_write_insn(struct comedi_device * dev, struct comedi_sub
return 1;
}
-// utility function that suggests a dma transfer size in bytes
+/* utility function that suggests a dma transfer size in bytes */
static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd)
{
unsigned int size;
@@ -1687,14 +1688,14 @@ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd)
if (cmd.convert_src == TRIG_TIMER)
freq = 1000000000 / cmd.convert_arg;
- // return some default value
+ /* return some default value */
else
freq = 0xffffffff;
- // make buffer fill in no more than 1/3 second
+ /* make buffer fill in no more than 1/3 second */
size = (freq / 3) * sample_size;
- // set a minimum and maximum size allowed
+ /* set a minimum and maximum size allowed */
if (size > dma_buffer_size)
size = dma_buffer_size - dma_buffer_size % sample_size;
else if (size < sample_size)
@@ -1703,16 +1704,16 @@ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd)
return size;
}
-// figures out what counter values to use based on command
-static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd)
+/* figures out what counter values to use based on command */
+static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
{
- const int max_counter_value = 0x10000; // max value for 16 bit counter in mode 2
- const int min_counter_value = 2; // min value for 16 bit counter in mode 2
+ const int max_counter_value = 0x10000; /* max value for 16 bit counter in mode 2 */
+ const int min_counter_value = 2; /* min value for 16 bit counter in mode 2 */
unsigned int base_period;
- // if both convert and scan triggers are TRIG_TIMER, then they both rely on counter b0
+ /* if both convert and scan triggers are TRIG_TIMER, then they both rely on counter b0 */
if (labpc_ai_convert_period(cmd) && labpc_ai_scan_period(cmd)) {
- // pick the lowest b0 divisor value we can (for maximum input clock speed on convert and scan counters)
+ /* pick the lowest b0 divisor value we can (for maximum input clock speed on convert and scan counters) */
devpriv->divisor_b0 = (labpc_ai_scan_period(cmd) - 1) /
(LABPC_TIMER_BASE * max_counter_value) + 1;
if (devpriv->divisor_b0 < min_counter_value)
@@ -1722,7 +1723,7 @@ static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd
base_period = LABPC_TIMER_BASE * devpriv->divisor_b0;
- // set a0 for conversion frequency and b1 for scan frequency
+ /* set a0 for conversion frequency and b1 for scan frequency */
switch (cmd->flags & TRIG_ROUND_MASK) {
default:
case TRIG_ROUND_NEAREST:
@@ -1748,7 +1749,7 @@ static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd
labpc_ai_scan_period(cmd) / base_period;
break;
}
- // make sure a0 and b1 values are acceptable
+ /* make sure a0 and b1 values are acceptable */
if (devpriv->divisor_a0 < min_counter_value)
devpriv->divisor_a0 = min_counter_value;
if (devpriv->divisor_a0 > max_counter_value)
@@ -1757,12 +1758,12 @@ static void labpc_adc_timing(struct comedi_device * dev, struct comedi_cmd * cmd
devpriv->divisor_b1 = min_counter_value;
if (devpriv->divisor_b1 > max_counter_value)
devpriv->divisor_b1 = max_counter_value;
- // write corrected timings to command
+ /* write corrected timings to command */
labpc_set_ai_convert_period(cmd,
base_period * devpriv->divisor_a0);
labpc_set_ai_scan_period(cmd,
base_period * devpriv->divisor_b1);
- // if only one TRIG_TIMER is used, we can employ the generic cascaded timing functions
+ /* if only one TRIG_TIMER is used, we can employ the generic cascaded timing functions */
} else if (labpc_ai_scan_period(cmd)) {
unsigned int scan_period;
@@ -1795,51 +1796,51 @@ static int labpc_dio_mem_callback(int dir, int port, int data,
}
}
-// lowlevel write to eeprom/dac
-static void labpc_serial_out(struct comedi_device * dev, unsigned int value,
+/* lowlevel write to eeprom/dac */
+static void labpc_serial_out(struct comedi_device *dev, unsigned int value,
unsigned int value_width)
{
int i;
for (i = 1; i <= value_width; i++) {
- // clear serial clock
+ /* clear serial clock */
devpriv->command5_bits &= ~SCLOCK_BIT;
- // send bits most significant bit first
+ /* send bits most significant bit first */
if (value & (1 << (value_width - i)))
devpriv->command5_bits |= SDATA_BIT;
else
devpriv->command5_bits &= ~SDATA_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits,
dev->iobase + COMMAND5_REG);
- // set clock to load bit
+ /* set clock to load bit */
devpriv->command5_bits |= SCLOCK_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits,
dev->iobase + COMMAND5_REG);
}
}
-// lowlevel read from eeprom
-static unsigned int labpc_serial_in(struct comedi_device * dev)
+/* lowlevel read from eeprom */
+static unsigned int labpc_serial_in(struct comedi_device *dev)
{
unsigned int value = 0;
int i;
- const int value_width = 8; // number of bits wide values are
+ const int value_width = 8; /* number of bits wide values are */
for (i = 1; i <= value_width; i++) {
- // set serial clock
+ /* set serial clock */
devpriv->command5_bits |= SCLOCK_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits,
dev->iobase + COMMAND5_REG);
- // clear clock bit
+ /* clear clock bit */
devpriv->command5_bits &= ~SCLOCK_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits,
dev->iobase + COMMAND5_REG);
- // read bits most significant bit first
- comedi_udelay(1);
+ /* read bits most significant bit first */
+ udelay(1);
devpriv->status2_bits =
devpriv->read_byte(dev->iobase + STATUS2_REG);
if (devpriv->status2_bits & EEPROM_OUT_BIT) {
@@ -1850,46 +1851,46 @@ static unsigned int labpc_serial_in(struct comedi_device * dev)
return value;
}
-static unsigned int labpc_eeprom_read(struct comedi_device * dev, unsigned int address)
+static unsigned int labpc_eeprom_read(struct comedi_device *dev, unsigned int address)
{
unsigned int value;
- const int read_instruction = 0x3; // bits to tell eeprom to expect a read
- const int write_length = 8; // 8 bit write lengths to eeprom
+ const int read_instruction = 0x3; /* bits to tell eeprom to expect a read */
+ const int write_length = 8; /* 8 bit write lengths to eeprom */
- // enable read/write to eeprom
+ /* enable read/write to eeprom */
devpriv->command5_bits &= ~EEPROM_EN_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
devpriv->command5_bits |= EEPROM_EN_BIT | EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
- // send read instruction
+ /* send read instruction */
labpc_serial_out(dev, read_instruction, write_length);
- // send 8 bit address to read from
+ /* send 8 bit address to read from */
labpc_serial_out(dev, address, write_length);
- // read result
+ /* read result */
value = labpc_serial_in(dev);
- // disable read/write to eeprom
+ /* disable read/write to eeprom */
devpriv->command5_bits &= ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
return value;
}
-static unsigned int labpc_eeprom_write(struct comedi_device * dev,
+static unsigned int labpc_eeprom_write(struct comedi_device *dev,
unsigned int address, unsigned int value)
{
const int write_enable_instruction = 0x6;
const int write_instruction = 0x2;
- const int write_length = 8; // 8 bit write lengths to eeprom
+ const int write_length = 8; /* 8 bit write lengths to eeprom */
const int write_in_progress_bit = 0x1;
const int timeout = 10000;
int i;
- // make sure there isn't already a write in progress
+ /* make sure there isn't already a write in progress */
for (i = 0; i < timeout; i++) {
if ((labpc_eeprom_read_status(dev) & write_in_progress_bit) ==
0)
@@ -1899,96 +1900,96 @@ static unsigned int labpc_eeprom_write(struct comedi_device * dev,
comedi_error(dev, "eeprom write timed out");
return -ETIME;
}
- // update software copy of eeprom
+ /* update software copy of eeprom */
devpriv->eeprom_data[address] = value;
- // enable read/write to eeprom
+ /* enable read/write to eeprom */
devpriv->command5_bits &= ~EEPROM_EN_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
devpriv->command5_bits |= EEPROM_EN_BIT | EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
- // send write_enable instruction
+ /* send write_enable instruction */
labpc_serial_out(dev, write_enable_instruction, write_length);
devpriv->command5_bits &= ~EEPROM_EN_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
- // send write instruction
+ /* send write instruction */
devpriv->command5_bits |= EEPROM_EN_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
labpc_serial_out(dev, write_instruction, write_length);
- // send 8 bit address to write to
+ /* send 8 bit address to write to */
labpc_serial_out(dev, address, write_length);
- // write value
+ /* write value */
labpc_serial_out(dev, value, write_length);
devpriv->command5_bits &= ~EEPROM_EN_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
- // disable read/write to eeprom
+ /* disable read/write to eeprom */
devpriv->command5_bits &= ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
return 0;
}
-static unsigned int labpc_eeprom_read_status(struct comedi_device * dev)
+static unsigned int labpc_eeprom_read_status(struct comedi_device *dev)
{
unsigned int value;
const int read_status_instruction = 0x5;
- const int write_length = 8; // 8 bit write lengths to eeprom
+ const int write_length = 8; /* 8 bit write lengths to eeprom */
- // enable read/write to eeprom
+ /* enable read/write to eeprom */
devpriv->command5_bits &= ~EEPROM_EN_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
devpriv->command5_bits |= EEPROM_EN_BIT | EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
- // send read status instruction
+ /* send read status instruction */
labpc_serial_out(dev, read_status_instruction, write_length);
- // read result
+ /* read result */
value = labpc_serial_in(dev);
- // disable read/write to eeprom
+ /* disable read/write to eeprom */
devpriv->command5_bits &= ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
return value;
}
-// writes to 8 bit calibration dacs
-static void write_caldac(struct comedi_device * dev, unsigned int channel,
+/* writes to 8 bit calibration dacs */
+static void write_caldac(struct comedi_device *dev, unsigned int channel,
unsigned int value)
{
if (value == devpriv->caldac[channel])
return;
devpriv->caldac[channel] = value;
- // clear caldac load bit and make sure we don't write to eeprom
+ /* clear caldac load bit and make sure we don't write to eeprom */
devpriv->command5_bits &=
~CALDAC_LOAD_BIT & ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
- // write 4 bit channel
+ /* write 4 bit channel */
labpc_serial_out(dev, channel, 4);
- // write 8 bit caldac value
+ /* write 8 bit caldac value */
labpc_serial_out(dev, value, 8);
- // set and clear caldac bit to load caldac value
+ /* set and clear caldac bit to load caldac value */
devpriv->command5_bits |= CALDAC_LOAD_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
devpriv->command5_bits &= ~CALDAC_LOAD_BIT;
- comedi_udelay(1);
+ udelay(1);
devpriv->write_byte(devpriv->command5_bits, dev->iobase + COMMAND5_REG);
}
diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h
index b44b0d3d02f1..c5d2d212612c 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.h
+++ b/drivers/staging/comedi/drivers/ni_labpc.h
@@ -24,59 +24,59 @@
#ifndef _NI_LABPC_H
#define _NI_LABPC_H
-#define EEPROM_SIZE 256 // 256 byte eeprom
-#define NUM_AO_CHAN 2 // boards have two analog output channels
+#define EEPROM_SIZE 256 /* 256 byte eeprom */
+#define NUM_AO_CHAN 2 /* boards have two analog output channels */
enum labpc_bustype { isa_bustype, pci_bustype, pcmcia_bustype };
enum labpc_register_layout { labpc_plus_layout, labpc_1200_layout };
enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer,
isa_dma_transfer };
-typedef struct labpc_board_struct {
+struct labpc_board_struct {
const char *name;
- int device_id; // device id for pci and pcmcia boards
- int ai_speed; // maximum input speed in nanoseconds
- enum labpc_bustype bustype; // ISA/PCI/etc.
- enum labpc_register_layout register_layout; // 1200 has extra registers compared to pc+
- int has_ao; // has analog output true/false
+ int device_id; /* device id for pci and pcmcia boards */
+ int ai_speed; /* maximum input speed in nanoseconds */
+ enum labpc_bustype bustype; /* ISA/PCI/etc. */
+ enum labpc_register_layout register_layout; /* 1200 has extra registers compared to pc+ */
+ int has_ao; /* has analog output true/false */
const struct comedi_lrange *ai_range_table;
const int *ai_range_code;
const int *ai_range_is_unipolar;
- unsigned ai_scan_up:1; // board can auto scan up in ai channels, not just down
+ unsigned ai_scan_up:1; /* board can auto scan up in ai channels, not just down */
unsigned memory_mapped_io:1; /* uses memory mapped io instead of ioports */
-} labpc_board;
+};
-typedef struct {
- struct mite_struct *mite; // for mite chip on pci-1200
+struct labpc_private {
+ struct mite_struct *mite; /* for mite chip on pci-1200 */
volatile unsigned long long count; /* number of data points left to be taken */
- unsigned int ao_value[NUM_AO_CHAN]; // software copy of analog output values
- // software copys of bits written to command registers
+ unsigned int ao_value[NUM_AO_CHAN]; /* software copy of analog output values */
+ /* software copys of bits written to command registers */
volatile unsigned int command1_bits;
volatile unsigned int command2_bits;
volatile unsigned int command3_bits;
volatile unsigned int command4_bits;
volatile unsigned int command5_bits;
volatile unsigned int command6_bits;
- // store last read of board status registers
+ /* store last read of board status registers */
volatile unsigned int status1_bits;
volatile unsigned int status2_bits;
unsigned int divisor_a0; /* value to load into board's counter a0 (conversion pacing) for timed conversions */
unsigned int divisor_b0; /* value to load into board's counter b0 (master) for timed conversions */
unsigned int divisor_b1; /* value to load into board's counter b1 (scan pacing) for timed conversions */
- unsigned int dma_chan; // dma channel to use
- u16 *dma_buffer; // buffer ai will dma into
- unsigned int dma_transfer_size; // transfer size in bytes for current transfer
- enum transfer_type current_transfer; // we are using dma/fifo-half-full/etc.
- unsigned int eeprom_data[EEPROM_SIZE]; // stores contents of board's eeprom
- unsigned int caldac[16]; // stores settings of calibration dacs
- // function pointers so we can use inb/outb or readb/writeb as appropriate
+ unsigned int dma_chan; /* dma channel to use */
+ u16 *dma_buffer; /* buffer ai will dma into */
+ unsigned int dma_transfer_size; /* transfer size in bytes for current transfer */
+ enum transfer_type current_transfer; /* we are using dma/fifo-half-full/etc. */
+ unsigned int eeprom_data[EEPROM_SIZE]; /* stores contents of board's eeprom */
+ unsigned int caldac[16]; /* stores settings of calibration dacs */
+ /* function pointers so we can use inb/outb or readb/writeb as appropriate */
unsigned int (*read_byte) (unsigned long address);
void (*write_byte) (unsigned int byte, unsigned long address);
-} labpc_private;
+};
-int labpc_common_attach(struct comedi_device * dev, unsigned long iobase,
+int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
unsigned int irq, unsigned int dma);
-int labpc_common_detach(struct comedi_device * dev);
+int labpc_common_detach(struct comedi_device *dev);
extern const int labpc_1200_is_unipolar[];
extern const int labpc_1200_ai_gain_bits[];
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index ac0ce2f58f5f..fb56c03a1b9f 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -60,7 +60,7 @@ NI manuals:
*/
#undef LABPC_DEBUG
-//#define LABPC_DEBUG // enable debugging messages
+/* #define LABPC_DEBUG */ /* enable debugging messages */
#include "../comedidev.h"
@@ -79,64 +79,64 @@ NI manuals:
static struct pcmcia_device *pcmcia_cur_dev = NULL;
-static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it);
+static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static const labpc_board labpc_cs_boards[] = {
+static const struct labpc_board_struct labpc_cs_boards[] = {
{
- name: "daqcard-1200",
- device_id:0x103, // 0x10b is manufacturer id, 0x103 is device id
- ai_speed:10000,
- bustype: pcmcia_bustype,
- register_layout:labpc_1200_layout,
- has_ao: 1,
- ai_range_table:&range_labpc_1200_ai,
- ai_range_code:labpc_1200_ai_gain_bits,
- ai_range_is_unipolar:labpc_1200_is_unipolar,
- ai_scan_up:0,
- memory_mapped_io:0,
+ .name = "daqcard-1200",
+ .device_id = 0x103, /* 0x10b is manufacturer id, 0x103 is device id */
+ .ai_speed = 10000,
+ .bustype = pcmcia_bustype,
+ .register_layout = labpc_1200_layout,
+ .has_ao = 1,
+ .ai_range_table = &range_labpc_1200_ai,
+ .ai_range_code = labpc_1200_ai_gain_bits,
+ .ai_range_is_unipolar = labpc_1200_is_unipolar,
+ .ai_scan_up = 0,
+ .memory_mapped_io = 0,
},
/* duplicate entry, to support using alternate name */
{
- name: "ni_labpc_cs",
- device_id:0x103,
- ai_speed:10000,
- bustype: pcmcia_bustype,
- register_layout:labpc_1200_layout,
- has_ao: 1,
- ai_range_table:&range_labpc_1200_ai,
- ai_range_code:labpc_1200_ai_gain_bits,
- ai_range_is_unipolar:labpc_1200_is_unipolar,
- ai_scan_up:0,
- memory_mapped_io:0,
+ .name = "ni_labpc_cs",
+ .device_id = 0x103,
+ .ai_speed = 10000,
+ .bustype = pcmcia_bustype,
+ .register_layout = labpc_1200_layout,
+ .has_ao = 1,
+ .ai_range_table = &range_labpc_1200_ai,
+ .ai_range_code = labpc_1200_ai_gain_bits,
+ .ai_range_is_unipolar = labpc_1200_is_unipolar,
+ .ai_scan_up = 0,
+ .memory_mapped_io = 0,
},
};
/*
* Useful for shorthand access to the particular board structure
*/
-#define thisboard ((const labpc_board *)dev->board_ptr)
+#define thisboard ((const struct labpc_board_struct *)dev->board_ptr)
static struct comedi_driver driver_labpc_cs = {
.driver_name = "ni_labpc_cs",
.module = THIS_MODULE,
.attach = &labpc_attach,
.detach = &labpc_common_detach,
- .num_names = sizeof(labpc_cs_boards) / sizeof(labpc_board),
+ .num_names = ARRAY_SIZE(labpc_cs_boards),
.board_name = &labpc_cs_boards[0].name,
- .offset = sizeof(labpc_board),
+ .offset = sizeof(struct labpc_board_struct),
};
-static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase = 0;
unsigned int irq = 0;
struct pcmcia_device *link;
/* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(labpc_private)) < 0)
+ if (alloc_private(dev, sizeof(struct labpc_private)) < 0)
return -ENOMEM;
- // get base address, irq etc. based on bustype
+ /* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
case pcmcia_bustype:
link = pcmcia_cur_dev; /* XXX hack */
@@ -213,12 +213,12 @@ static void labpc_cs_detach(struct pcmcia_device *);
static const dev_info_t dev_info = "daqcard-1200";
-typedef struct local_info_t {
+struct local_info_t {
struct pcmcia_device *link;
dev_node_t node;
int stop;
struct bus_operations *bus;
-} local_info_t;
+};
/*======================================================================
@@ -234,12 +234,12 @@ typedef struct local_info_t {
static int labpc_cs_attach(struct pcmcia_device *link)
{
- local_info_t *local;
+ struct local_info_t *local;
DEBUG(0, "labpc_cs_attach()\n");
/* Allocate space for private device-specific data */
- local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
+ local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
if (!local)
return -ENOMEM;
local->link = link;
@@ -287,7 +287,7 @@ static void labpc_cs_detach(struct pcmcia_device *link)
detach().
*/
if (link->dev_node) {
- ((local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *) link->priv)->stop = 1;
labpc_release(link);
}
@@ -307,7 +307,7 @@ static void labpc_cs_detach(struct pcmcia_device *link)
static void labpc_config(struct pcmcia_device *link)
{
- local_info_t *dev = link->priv;
+ struct local_info_t *dev = link->priv;
tuple_t tuple;
cisparse_t parse;
int last_ret;
@@ -327,15 +327,21 @@ static void labpc_config(struct pcmcia_device *link)
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple))) {
+
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret) {
cs_error(link, GetTupleData, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_parse_tuple(&tuple, &parse))) {
+
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret) {
cs_error(link, ParseTuple, last_ret);
goto cs_failed;
}
@@ -355,7 +361,8 @@ static void labpc_config(struct pcmcia_device *link)
will only use the CIS to fill in implementation-defined details.
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
@@ -422,7 +429,8 @@ static void labpc_config(struct pcmcia_device *link)
break;
next_entry:
- if ((last_ret = pcmcia_get_next_tuple(link, &tuple))) {
+ last_ret = pcmcia_get_next_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetNextTuple, last_ret);
goto cs_failed;
}
@@ -433,18 +441,21 @@ static void labpc_config(struct pcmcia_device *link)
handler to the interrupt, unless the 'Handler' member of the
irq structure is initialized.
*/
- if (link->conf.Attributes & CONF_ENABLE_IRQ)
- if ((last_ret = pcmcia_request_irq(link, &link->irq))) {
+ if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+ last_ret = pcmcia_request_irq(link, &link->irq);
+ if (last_ret) {
cs_error(link, RequestIRQ, last_ret);
goto cs_failed;
}
+ }
/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
- if ((last_ret = pcmcia_request_configuration(link, &link->conf))) {
+ last_ret = pcmcia_request_configuration(link, &link->conf);
+ if (last_ret) {
cs_error(link, RequestConfiguration, last_ret);
goto cs_failed;
}
@@ -501,7 +512,7 @@ static void labpc_release(struct pcmcia_device *link)
static int labpc_cs_suspend(struct pcmcia_device *link)
{
- local_info_t *local = link->priv;
+ struct local_info_t *local = link->priv;
/* Mark the device as stopped, to block IO until later */
local->stop = 1;
@@ -510,7 +521,7 @@ static int labpc_cs_suspend(struct pcmcia_device *link)
static int labpc_cs_resume(struct pcmcia_device *link)
{
- local_info_t *local = link->priv;
+ struct local_info_t *local = link->priv;
local->stop = 0;
return 0;
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index 542bd0dcd44d..d727d7533fc8 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -57,16 +57,17 @@
fully tested as yet. Terry Barnaby, BEAM Ltd.
*/
-//#define DEBUG_INTERRUPT
-//#define DEBUG_STATUS_A
-//#define DEBUG_STATUS_B
+/* #define DEBUG_INTERRUPT */
+/* #define DEBUG_STATUS_A */
+/* #define DEBUG_STATUS_B */
+#include <linux/interrupt.h>
#include "8255.h"
#include "mite.h"
#include "comedi_fc.h"
#ifndef MDPRINTK
-#define MDPRINTK(format,args...)
+#define MDPRINTK(format, args...)
#endif
/* A timeout count */
@@ -193,49 +194,49 @@ static const struct comedi_lrange *const ni_range_lkup[] = {
[ai_gain_6143] = &range_ni_S_ai_6143
};
-static int ni_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_cdio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int ni_cdio_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ni_cdio_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void handle_cdio_interrupt(struct comedi_device * dev);
-static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_cdio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void handle_cdio_interrupt(struct comedi_device *dev);
+static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum);
-static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_serial_hw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned char data_out, unsigned char *data_in);
-static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_serial_sw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned char data_out, unsigned char *data_in);
-static int ni_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int ni_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int ni_eeprom_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_m_series_eeprom_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int ni_eeprom_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_m_series_eeprom_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int ni_pfi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_pfi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static unsigned ni_old_get_pfi_routing(struct comedi_device * dev, unsigned chan);
+static int ni_pfi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_pfi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static unsigned ni_old_get_pfi_routing(struct comedi_device *dev, unsigned chan);
-static void ni_rtsi_init(struct comedi_device * dev);
-static int ni_rtsi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_rtsi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static void ni_rtsi_init(struct comedi_device *dev);
+static int ni_rtsi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_rtsi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static void caldac_setup(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ni_read_eeprom(struct comedi_device * dev, int addr);
+static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ni_read_eeprom(struct comedi_device *dev, int addr);
#ifdef DEBUG_STATUS_A
static void ni_mio_print_status_a(int status);
@@ -248,58 +249,58 @@ static void ni_mio_print_status_b(int status);
#define ni_mio_print_status_b(a)
#endif
-static int ni_ai_reset(struct comedi_device * dev, struct comedi_subdevice * s);
+static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s);
#ifndef PCIDMA
-static void ni_handle_fifo_half_full(struct comedi_device * dev);
-static int ni_ao_fifo_half_empty(struct comedi_device * dev, struct comedi_subdevice * s);
+static void ni_handle_fifo_half_full(struct comedi_device *dev);
+static int ni_ao_fifo_half_empty(struct comedi_device *dev, struct comedi_subdevice *s);
#endif
-static void ni_handle_fifo_dregs(struct comedi_device * dev);
-static int ni_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static void ni_handle_fifo_dregs(struct comedi_device *dev);
+static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum);
-static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_chan,
+static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan,
unsigned int *list);
-static void shutdown_ai_command(struct comedi_device * dev);
+static void shutdown_ai_command(struct comedi_device *dev);
-static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum);
-static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s);
+static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s);
static int ni_8255_callback(int dir, int port, int data, unsigned long arg);
-static int ni_gpct_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_gpct_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_gpct_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ni_gpct_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int ni_gpct_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void handle_gpct_interrupt(struct comedi_device * dev,
+static int ni_gpct_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_gpct_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ni_gpct_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void handle_gpct_interrupt(struct comedi_device *dev,
unsigned short counter_index);
-static int init_cs5529(struct comedi_device * dev);
-static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data);
-static int cs5529_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int init_cs5529(struct comedi_device *dev);
+static int cs5529_do_conversion(struct comedi_device *dev, unsigned short *data);
+static int cs5529_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
#ifdef NI_CS5529_DEBUG
-static unsigned int cs5529_config_read(struct comedi_device * dev,
+static unsigned int cs5529_config_read(struct comedi_device *dev,
unsigned int reg_select_bits);
#endif
-static void cs5529_config_write(struct comedi_device * dev, unsigned int value,
+static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
unsigned int reg_select_bits);
-static int ni_m_series_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ni_6143_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ni_6143_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int ni_set_master_clock(struct comedi_device * dev, unsigned source,
+static int ni_set_master_clock(struct comedi_device *dev, unsigned source,
unsigned period_ns);
-static void ack_a_interrupt(struct comedi_device * dev, unsigned short a_status);
-static void ack_b_interrupt(struct comedi_device * dev, unsigned short b_status);
+static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status);
+static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status);
enum aimodes {
AIMODE_NONE = 0,
@@ -353,19 +354,19 @@ enum timebase_nanoseconds {
static const int num_adc_stages_611x = 3;
-static void handle_a_interrupt(struct comedi_device * dev, unsigned short status,
+static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
unsigned ai_mite_status);
-static void handle_b_interrupt(struct comedi_device * dev, unsigned short status,
+static void handle_b_interrupt(struct comedi_device *dev, unsigned short status,
unsigned ao_mite_status);
-static void get_last_sample_611x(struct comedi_device * dev);
-static void get_last_sample_6143(struct comedi_device * dev);
+static void get_last_sample_611x(struct comedi_device *dev);
+static void get_last_sample_6143(struct comedi_device *dev);
-static inline void ni_set_bitfield(struct comedi_device * dev, int reg,
+static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
unsigned bit_mask, unsigned bit_values)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags);
+ spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags);
switch (reg) {
case Interrupt_A_Enable_Register:
devpriv->int_a_enable_reg &= ~bit_mask;
@@ -396,22 +397,22 @@ static inline void ni_set_bitfield(struct comedi_device * dev, int reg,
ni_writeb(devpriv->g0_g1_select_reg, G0_G1_Select);
break;
default:
- rt_printk("Warning %s() called with invalid register\n",
- __FUNCTION__);
- rt_printk("reg is %d\n", reg);
+ printk("Warning %s() called with invalid register\n",
+ __func__);
+ printk("reg is %d\n", reg);
break;
}
mmiowb();
- comedi_spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags);
+ spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags);
}
#ifdef PCIDMA
-static int ni_ai_drain_dma(struct comedi_device * dev);
+static int ni_ai_drain_dma(struct comedi_device *dev);
/* DMA channel setup */
-// negative channel means no channel
-static inline void ni_set_ai_dma_channel(struct comedi_device * dev, int channel)
+/* negative channel means no channel */
+static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel)
{
unsigned bitfield;
@@ -425,8 +426,8 @@ static inline void ni_set_ai_dma_channel(struct comedi_device * dev, int channel
ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield);
}
-// negative channel means no channel
-static inline void ni_set_ao_dma_channel(struct comedi_device * dev, int channel)
+/* negative channel means no channel */
+static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel)
{
unsigned bitfield;
@@ -440,8 +441,8 @@ static inline void ni_set_ao_dma_channel(struct comedi_device * dev, int channel
ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield);
}
-// negative mite_channel means no channel
-static inline void ni_set_gpct_dma_channel(struct comedi_device * dev,
+/* negative mite_channel means no channel */
+static inline void ni_set_gpct_dma_channel(struct comedi_device *dev,
unsigned gpct_index, int mite_channel)
{
unsigned bitfield;
@@ -455,12 +456,12 @@ static inline void ni_set_gpct_dma_channel(struct comedi_device * dev,
bitfield);
}
-// negative mite_channel means no channel
-static inline void ni_set_cdo_dma_channel(struct comedi_device * dev, int mite_channel)
+/* negative mite_channel means no channel */
+static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, int mite_channel)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags);
+ spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags);
devpriv->cdio_dma_select_reg &= ~CDO_DMA_Select_Mask;
if (mite_channel >= 0) {
/*XXX just guessing ni_stc_dma_channel_select_bitfield() returns the right bits,
@@ -472,19 +473,19 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device * dev, int mite_c
}
ni_writeb(devpriv->cdio_dma_select_reg, M_Offset_CDIO_DMA_Select);
mmiowb();
- comedi_spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags);
+ spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags);
}
-static int ni_request_ai_mite_channel(struct comedi_device * dev)
+static int ni_request_ai_mite_channel(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
BUG_ON(devpriv->ai_mite_chan);
devpriv->ai_mite_chan =
mite_request_channel(devpriv->mite, devpriv->ai_mite_ring);
if (devpriv->ai_mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock,
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock,
flags);
comedi_error(dev,
"failed to reserve mite dma channel for analog input.");
@@ -492,20 +493,20 @@ static int ni_request_ai_mite_channel(struct comedi_device * dev)
}
devpriv->ai_mite_chan->dir = COMEDI_INPUT;
ni_set_ai_dma_channel(dev, devpriv->ai_mite_chan->channel);
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
}
-static int ni_request_ao_mite_channel(struct comedi_device * dev)
+static int ni_request_ao_mite_channel(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
BUG_ON(devpriv->ao_mite_chan);
devpriv->ao_mite_chan =
mite_request_channel(devpriv->mite, devpriv->ao_mite_ring);
if (devpriv->ao_mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock,
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock,
flags);
comedi_error(dev,
"failed to reserve mite dma channel for analog outut.");
@@ -513,24 +514,24 @@ static int ni_request_ao_mite_channel(struct comedi_device * dev)
}
devpriv->ao_mite_chan->dir = COMEDI_OUTPUT;
ni_set_ao_dma_channel(dev, devpriv->ao_mite_chan->channel);
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
}
-static int ni_request_gpct_mite_channel(struct comedi_device * dev,
+static int ni_request_gpct_mite_channel(struct comedi_device *dev,
unsigned gpct_index, enum comedi_io_direction direction)
{
unsigned long flags;
struct mite_channel *mite_chan;
BUG_ON(gpct_index >= NUM_GPCT);
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
BUG_ON(devpriv->counter_dev->counters[gpct_index].mite_chan);
mite_chan =
mite_request_channel(devpriv->mite,
devpriv->gpct_mite_ring[gpct_index]);
if (mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock,
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock,
flags);
comedi_error(dev,
"failed to reserve mite dma channel for counter.");
@@ -540,23 +541,23 @@ static int ni_request_gpct_mite_channel(struct comedi_device * dev,
ni_tio_set_mite_channel(&devpriv->counter_dev->counters[gpct_index],
mite_chan);
ni_set_gpct_dma_channel(dev, gpct_index, mite_chan->channel);
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
}
-#endif // PCIDMA
+#endif /* PCIDMA */
-static int ni_request_cdo_mite_channel(struct comedi_device * dev)
+static int ni_request_cdo_mite_channel(struct comedi_device *dev)
{
#ifdef PCIDMA
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
BUG_ON(devpriv->cdo_mite_chan);
devpriv->cdo_mite_chan =
mite_request_channel(devpriv->mite, devpriv->cdo_mite_ring);
if (devpriv->cdo_mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock,
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock,
flags);
comedi_error(dev,
"failed to reserve mite dma channel for correlated digital outut.");
@@ -564,48 +565,48 @@ static int ni_request_cdo_mite_channel(struct comedi_device * dev)
}
devpriv->cdo_mite_chan->dir = COMEDI_OUTPUT;
ni_set_cdo_dma_channel(dev, devpriv->cdo_mite_chan->channel);
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-#endif // PCIDMA
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+#endif /* PCIDMA */
return 0;
}
-static void ni_release_ai_mite_channel(struct comedi_device * dev)
+static void ni_release_ai_mite_channel(struct comedi_device *dev)
{
#ifdef PCIDMA
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ai_mite_chan) {
ni_set_ai_dma_channel(dev, -1);
mite_release_channel(devpriv->ai_mite_chan);
devpriv->ai_mite_chan = NULL;
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-#endif // PCIDMA
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+#endif /* PCIDMA */
}
-static void ni_release_ao_mite_channel(struct comedi_device * dev)
+static void ni_release_ao_mite_channel(struct comedi_device *dev)
{
#ifdef PCIDMA
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ao_mite_chan) {
ni_set_ao_dma_channel(dev, -1);
mite_release_channel(devpriv->ao_mite_chan);
devpriv->ao_mite_chan = NULL;
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-#endif // PCIDMA
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+#endif /* PCIDMA */
}
-void ni_release_gpct_mite_channel(struct comedi_device * dev, unsigned gpct_index)
+void ni_release_gpct_mite_channel(struct comedi_device *dev, unsigned gpct_index)
{
#ifdef PCIDMA
unsigned long flags;
BUG_ON(gpct_index >= NUM_GPCT);
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->counter_dev->counters[gpct_index].mite_chan) {
struct mite_channel *mite_chan =
devpriv->counter_dev->counters[gpct_index].mite_chan;
@@ -615,28 +616,28 @@ void ni_release_gpct_mite_channel(struct comedi_device * dev, unsigned gpct_inde
counters[gpct_index], NULL);
mite_release_channel(mite_chan);
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-#endif // PCIDMA
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+#endif /* PCIDMA */
}
-static void ni_release_cdo_mite_channel(struct comedi_device * dev)
+static void ni_release_cdo_mite_channel(struct comedi_device *dev)
{
#ifdef PCIDMA
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->cdo_mite_chan) {
ni_set_cdo_dma_channel(dev, -1);
mite_release_channel(devpriv->cdo_mite_chan);
devpriv->cdo_mite_chan = NULL;
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-#endif // PCIDMA
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+#endif /* PCIDMA */
}
-// e-series boards use the second irq signals to generate dma requests for their counters
+/* e-series boards use the second irq signals to generate dma requests for their counters */
#ifdef PCIDMA
-static void ni_e_series_enable_second_irq(struct comedi_device * dev,
+static void ni_e_series_enable_second_irq(struct comedi_device *dev,
unsigned gpct_index, short enable)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
@@ -665,15 +666,15 @@ static void ni_e_series_enable_second_irq(struct comedi_device * dev,
break;
}
}
-#endif // PCIDMA
+#endif /* PCIDMA */
-static void ni_clear_ai_fifo(struct comedi_device * dev)
+static void ni_clear_ai_fifo(struct comedi_device *dev)
{
if (boardtype.reg_type == ni_reg_6143) {
- // Flush the 6143 data FIFO
- ni_writel(0x10, AIFIFO_Control_6143); // Flush fifo
- ni_writel(0x00, AIFIFO_Control_6143); // Flush fifo
- while (ni_readl(AIFIFO_Status_6143) & 0x10) ; // Wait for complete
+ /* Flush the 6143 data FIFO */
+ ni_writel(0x10, AIFIFO_Control_6143); /* Flush fifo */
+ ni_writel(0x00, AIFIFO_Control_6143); /* Flush fifo */
+ while (ni_readl(AIFIFO_Status_6143) & 0x10) ; /* Wait for complete */
} else {
devpriv->stc_writew(dev, 1, ADC_FIFO_Clear);
if (boardtype.reg_type == ni_reg_625x) {
@@ -693,13 +694,13 @@ static void ni_clear_ai_fifo(struct comedi_device * dev)
}
}
-static void win_out2(struct comedi_device * dev, uint32_t data, int reg)
+static void win_out2(struct comedi_device *dev, uint32_t data, int reg)
{
devpriv->stc_writew(dev, data >> 16, reg);
devpriv->stc_writew(dev, data & 0xffff, reg + 1);
}
-static uint32_t win_in2(struct comedi_device * dev, int reg)
+static uint32_t win_in2(struct comedi_device *dev, int reg)
{
uint32_t bits;
bits = devpriv->stc_readw(dev, reg) << 16;
@@ -707,36 +708,36 @@ static uint32_t win_in2(struct comedi_device * dev, int reg)
return bits;
}
-#define ao_win_out(data,addr) ni_ao_win_outw(dev,data,addr)
-static inline void ni_ao_win_outw(struct comedi_device * dev, uint16_t data, int addr)
+#define ao_win_out(data, addr) ni_ao_win_outw(dev, data, addr)
+static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data, int addr)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
ni_writew(addr, AO_Window_Address_611x);
ni_writew(data, AO_Window_Data_611x);
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
-static inline void ni_ao_win_outl(struct comedi_device * dev, uint32_t data, int addr)
+static inline void ni_ao_win_outl(struct comedi_device *dev, uint32_t data, int addr)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
ni_writew(addr, AO_Window_Address_611x);
ni_writel(data, AO_Window_Data_611x);
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
-static inline unsigned short ni_ao_win_inw(struct comedi_device * dev, int addr)
+static inline unsigned short ni_ao_win_inw(struct comedi_device *dev, int addr)
{
unsigned long flags;
unsigned short data;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
ni_writew(addr, AO_Window_Address_611x);
data = ni_readw(AO_Window_Data_611x);
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
return data;
}
@@ -750,7 +751,7 @@ static inline unsigned short ni_ao_win_inw(struct comedi_device * dev, int addr)
*
* value should only be 1 or 0.
*/
-static inline void ni_set_bits(struct comedi_device * dev, int reg, unsigned bits,
+static inline void ni_set_bits(struct comedi_device *dev, int reg, unsigned bits,
unsigned value)
{
unsigned bit_values;
@@ -762,7 +763,7 @@ static inline void ni_set_bits(struct comedi_device * dev, int reg, unsigned bit
ni_set_bitfield(dev, reg, bits, bit_values);
}
-static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t ni_E_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
unsigned short a_status;
@@ -776,18 +777,17 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG)
if (dev->attached == 0)
return IRQ_NONE;
- smp_mb(); // make sure dev->attached is checked before handler does anything else.
+ smp_mb(); /* make sure dev->attached is checked before handler does anything else. */
- // lock to avoid race with comedi_poll
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ /* lock to avoid race with comedi_poll */
+ spin_lock_irqsave(&dev->spinlock, flags);
a_status = devpriv->stc_readw(dev, AI_Status_1_Register);
b_status = devpriv->stc_readw(dev, AO_Status_1_Register);
#ifdef PCIDMA
if (mite) {
unsigned long flags_too;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock,
- flags_too);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags_too);
if (devpriv->ai_mite_chan) {
ai_mite_status = mite_get_status(devpriv->ai_mite_chan);
if (ai_mite_status & CHSR_LINKC)
@@ -804,8 +804,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG)
MITE_CHOR(devpriv->ao_mite_chan->
channel));
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock,
- flags_too);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags_too);
}
#endif
ack_a_interrupt(dev, a_status);
@@ -818,20 +817,20 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG)
handle_gpct_interrupt(dev, 1);
handle_cdio_interrupt(dev);
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return IRQ_HANDLED;
}
#ifdef PCIDMA
-static void ni_sync_ai_dma(struct comedi_device * dev)
+static void ni_sync_ai_dma(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ai_mite_chan)
mite_sync_input_dma(devpriv->ai_mite_chan, s->async);
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
}
static void mite_handle_b_linkc(struct mite_struct *mite, struct comedi_device * dev)
@@ -839,14 +838,14 @@ static void mite_handle_b_linkc(struct mite_struct *mite, struct comedi_device *
struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV;
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ao_mite_chan) {
mite_sync_output_dma(devpriv->ao_mite_chan, s->async);
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
}
-static int ni_ao_wait_for_dma_load(struct comedi_device * dev)
+static int ni_ao_wait_for_dma_load(struct comedi_device *dev)
{
static const int timeout = 10000;
int i;
@@ -858,7 +857,7 @@ static int ni_ao_wait_for_dma_load(struct comedi_device * dev)
break;
/* if we poll too often, the pci bus activity seems
to slow the dma transfer down */
- comedi_udelay(10);
+ udelay(10);
}
if (i == timeout) {
comedi_error(dev, "timed out waiting for dma load");
@@ -867,8 +866,8 @@ static int ni_ao_wait_for_dma_load(struct comedi_device * dev)
return 0;
}
-#endif //PCIDMA
-static void ni_handle_eos(struct comedi_device * dev, struct comedi_subdevice * s)
+#endif /* PCIDMA */
+static void ni_handle_eos(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (devpriv->aimode == AIMODE_SCAN) {
#ifdef PCIDMA
@@ -879,7 +878,7 @@ static void ni_handle_eos(struct comedi_device * dev, struct comedi_subdevice *
ni_sync_ai_dma(dev);
if ((s->async->events & COMEDI_CB_EOS))
break;
- comedi_udelay(1);
+ udelay(1);
}
#else
ni_handle_fifo_dregs(dev);
@@ -892,7 +891,7 @@ static void ni_handle_eos(struct comedi_device * dev, struct comedi_subdevice *
}
}
-static void shutdown_ai_command(struct comedi_device * dev)
+static void shutdown_ai_command(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
@@ -906,7 +905,7 @@ static void shutdown_ai_command(struct comedi_device * dev)
s->async->events |= COMEDI_CB_EOA;
}
-static void ni_event(struct comedi_device * dev, struct comedi_subdevice * s)
+static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (s->async->
events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW | COMEDI_CB_EOA))
@@ -932,7 +931,7 @@ static void ni_event(struct comedi_device * dev, struct comedi_subdevice * s)
comedi_event(dev, s);
}
-static void handle_gpct_interrupt(struct comedi_device * dev,
+static void handle_gpct_interrupt(struct comedi_device *dev,
unsigned short counter_index)
{
#ifdef PCIDMA
@@ -945,7 +944,7 @@ static void handle_gpct_interrupt(struct comedi_device * dev,
#endif
}
-static void ack_a_interrupt(struct comedi_device * dev, unsigned short a_status)
+static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status)
{
unsigned short ack = 0;
@@ -966,17 +965,17 @@ static void ack_a_interrupt(struct comedi_device * dev, unsigned short a_status)
devpriv->stc_writew(dev, ack, Interrupt_A_Ack_Register);
}
-static void handle_a_interrupt(struct comedi_device * dev, unsigned short status,
+static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
unsigned ai_mite_status)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
- //67xx boards don't have ai subdevice, but their gpct0 might generate an a interrupt
+ /* 67xx boards don't have ai subdevice, but their gpct0 might generate an a interrupt */
if (s->type == COMEDI_SUBD_UNUSED)
return;
#ifdef DEBUG_INTERRUPT
- rt_printk
+ printk
("ni_mio_common: interrupt: a_status=%04x ai_mite_status=%08x\n",
status, ai_mite_status);
ni_mio_print_status_a(status);
@@ -989,12 +988,12 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status
if (ai_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY |
CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR |
CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) {
- rt_printk
+ printk
("unknown mite interrupt, ack! (ai_mite_status=%08x)\n",
ai_mite_status);
- //mite_print_chsr(ai_mite_status);
+ /* mite_print_chsr(ai_mite_status); */
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
- //disable_irq(dev->irq);
+ /* disable_irq(dev->irq); */
}
#endif
@@ -1002,7 +1001,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status
if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St |
AI_SC_TC_St | AI_START1_St)) {
if (status == 0xffff) {
- rt_printk
+ printk
("ni_mio_common: a_status=0xffff. Card removed?\n");
/* we probably aren't even running a command now,
* so it's a good idea to be careful. */
@@ -1015,7 +1014,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status
}
if (status & (AI_Overrun_St | AI_Overflow_St |
AI_SC_TC_Error_St)) {
- rt_printk("ni_mio_common: ai error a_status=%04x\n",
+ printk("ni_mio_common: ai error a_status=%04x\n",
status);
ni_mio_print_status_a(status);
@@ -1031,7 +1030,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status
}
if (status & AI_SC_TC_St) {
#ifdef DEBUG_INTERRUPT
- rt_printk("ni_mio_common: SC_TC interrupt\n");
+ printk("ni_mio_common: SC_TC interrupt\n");
#endif
if (!devpriv->ai_continuous) {
shutdown_ai_command(dev);
@@ -1052,7 +1051,7 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status
break;
}
}
-#endif // !PCIDMA
+#endif /* !PCIDMA */
if ((status & AI_STOP_St)) {
ni_handle_eos(dev, s);
@@ -1063,14 +1062,14 @@ static void handle_a_interrupt(struct comedi_device * dev, unsigned short status
#ifdef DEBUG_INTERRUPT
status = devpriv->stc_readw(dev, AI_Status_1_Register);
if (status & Interrupt_A_St) {
- rt_printk
+ printk
("handle_a_interrupt: didn't clear interrupt? status=0x%x\n",
status);
}
#endif
}
-static void ack_b_interrupt(struct comedi_device * dev, unsigned short b_status)
+static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status)
{
unsigned short ack = 0;
if (b_status & AO_BC_TC_St) {
@@ -1098,13 +1097,13 @@ static void ack_b_interrupt(struct comedi_device * dev, unsigned short b_status)
devpriv->stc_writew(dev, ack, Interrupt_B_Ack_Register);
}
-static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_status,
+static void handle_b_interrupt(struct comedi_device *dev, unsigned short b_status,
unsigned ao_mite_status)
{
struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV;
- //unsigned short ack=0;
+ /* unsigned short ack=0; */
#ifdef DEBUG_INTERRUPT
- rt_printk("ni_mio_common: interrupt: b_status=%04x m1_status=%08x\n",
+ printk("ni_mio_common: interrupt: b_status=%04x m1_status=%08x\n",
b_status, ao_mite_status);
ni_mio_print_status_b(b_status);
#endif
@@ -1118,10 +1117,10 @@ static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_stat
if (ao_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY |
CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR |
CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) {
- rt_printk
+ printk
("unknown mite interrupt, ack! (ao_mite_status=%08x)\n",
ao_mite_status);
- //mite_print_chsr(ao_mite_status);
+ /* mite_print_chsr(ao_mite_status); */
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
#endif
@@ -1129,7 +1128,7 @@ static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_stat
if (b_status == 0xffff)
return;
if (b_status & AO_Overrun_St) {
- rt_printk
+ printk
("ni_mio_common: AO FIFO underrun status=0x%04x status2=0x%04x\n",
b_status, devpriv->stc_readw(dev,
AO_Status_2_Register));
@@ -1146,7 +1145,7 @@ static void handle_b_interrupt(struct comedi_device * dev, unsigned short b_stat
ret = ni_ao_fifo_half_empty(dev, s);
if (!ret) {
- rt_printk("ni_mio_common: AO buffer underrun\n");
+ printk("ni_mio_common: AO buffer underrun\n");
ni_set_bits(dev, Interrupt_B_Enable_Register,
AO_FIFO_Interrupt_Enable |
AO_Error_Interrupt_Enable, 0);
@@ -1170,13 +1169,13 @@ static void ni_mio_print_status_a(int status)
{
int i;
- rt_printk("A status:");
+ printk("A status:");
for (i = 15; i >= 0; i--) {
if (status & (1 << i)) {
- rt_printk(" %s", status_a_strings[i]);
+ printk(" %s", status_a_strings[i]);
}
}
- rt_printk("\n");
+ printk("\n");
}
#endif
@@ -1192,19 +1191,19 @@ static void ni_mio_print_status_b(int status)
{
int i;
- rt_printk("B status:");
+ printk("B status:");
for (i = 15; i >= 0; i--) {
if (status & (1 << i)) {
- rt_printk(" %s", status_b_strings[i]);
+ printk(" %s", status_b_strings[i]);
}
}
- rt_printk("\n");
+ printk("\n");
}
#endif
#ifndef PCIDMA
-static void ni_ao_fifo_load(struct comedi_device * dev, struct comedi_subdevice * s, int n)
+static void ni_ao_fifo_load(struct comedi_device *dev, struct comedi_subdevice *s, int n)
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
@@ -1263,7 +1262,7 @@ static void ni_ao_fifo_load(struct comedi_device * dev, struct comedi_subdevice
* RT code, as RT code might purposely be running close to the
* metal. Needs to be fixed eventually.
*/
-static int ni_ao_fifo_half_empty(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ao_fifo_half_empty(struct comedi_device *dev, struct comedi_subdevice *s)
{
int n;
@@ -1284,7 +1283,7 @@ static int ni_ao_fifo_half_empty(struct comedi_device * dev, struct comedi_subde
return 1;
}
-static int ni_ao_prep_fifo(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ao_prep_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
{
int n;
@@ -1307,7 +1306,7 @@ static int ni_ao_prep_fifo(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice * s, int n)
+static void ni_ai_fifo_read(struct comedi_device *dev, struct comedi_subdevice *s, int n)
{
struct comedi_async *async = s->async;
int i;
@@ -1333,7 +1332,7 @@ static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice
short data[2];
u32 dl;
- // This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed
+ /* This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */
for (i = 0; i < n / 2; i++) {
dl = ni_readl(AIFIFO_Data_6143);
@@ -1343,7 +1342,7 @@ static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice
}
if (n % 2) {
/* Assume there is a single sample stuck in the FIFO */
- ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO
+ ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */
dl = ni_readl(AIFIFO_Data_6143);
data[0] = (dl >> 16) & 0xffff;
cfc_write_to_buffer(s, data[0]);
@@ -1364,7 +1363,7 @@ static void ni_ai_fifo_read(struct comedi_device * dev, struct comedi_subdevice
}
}
-static void ni_handle_fifo_half_full(struct comedi_device * dev)
+static void ni_handle_fifo_half_full(struct comedi_device *dev)
{
int n;
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
@@ -1376,14 +1375,14 @@ static void ni_handle_fifo_half_full(struct comedi_device * dev)
#endif
#ifdef PCIDMA
-static int ni_ai_drain_dma(struct comedi_device * dev)
+static int ni_ai_drain_dma(struct comedi_device *dev)
{
int i;
static const int timeout = 10000;
unsigned long flags;
int retval = 0;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ai_mite_chan) {
for (i = 0; i < timeout; i++) {
if ((devpriv->stc_readw(dev,
@@ -1392,19 +1391,19 @@ static int ni_ai_drain_dma(struct comedi_device * dev)
&& mite_bytes_in_transit(devpriv->
ai_mite_chan) == 0)
break;
- comedi_udelay(5);
+ udelay(5);
}
if (i == timeout) {
- rt_printk
+ printk
("ni_mio_common: wait for dma drain timed out\n");
- rt_printk
+ printk
("mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n",
mite_bytes_in_transit(devpriv->ai_mite_chan),
devpriv->stc_readw(dev, AI_Status_1_Register));
retval = -1;
}
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
ni_sync_ai_dma(dev);
@@ -1414,7 +1413,7 @@ static int ni_ai_drain_dma(struct comedi_device * dev)
/*
Empties the AI fifo
*/
-static void ni_handle_fifo_dregs(struct comedi_device * dev)
+static void ni_handle_fifo_dregs(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
short data[2];
@@ -1444,9 +1443,9 @@ static void ni_handle_fifo_dregs(struct comedi_device * dev)
cfc_write_array_to_buffer(s, data, sizeof(data));
i += 2;
}
- // Check if stranded sample is present
+ /* Check if stranded sample is present */
if (ni_readl(AIFIFO_Status_6143) & 0x01) {
- ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO
+ ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */
dl = ni_readl(AIFIFO_Data_6143);
data[0] = (dl >> 16) & 0xffff;
cfc_write_to_buffer(s, data[0]);
@@ -1476,7 +1475,7 @@ static void ni_handle_fifo_dregs(struct comedi_device * dev)
}
}
-static void get_last_sample_611x(struct comedi_device * dev)
+static void get_last_sample_611x(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
short data;
@@ -1493,7 +1492,7 @@ static void get_last_sample_611x(struct comedi_device * dev)
}
}
-static void get_last_sample_6143(struct comedi_device * dev)
+static void get_last_sample_6143(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
short data;
@@ -1504,7 +1503,7 @@ static void get_last_sample_6143(struct comedi_device * dev)
/* Check if there's a single sample stuck in the FIFO */
if (ni_readl(AIFIFO_Status_6143) & 0x01) {
- ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO
+ ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */
dl = ni_readl(AIFIFO_Data_6143);
/* This may get the hi/lo data in the wrong order */
@@ -1513,7 +1512,7 @@ static void get_last_sample_6143(struct comedi_device * dev)
}
}
-static void ni_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *data, unsigned int num_bytes, unsigned int chan_index)
{
struct comedi_async *async = s->async;
@@ -1539,7 +1538,7 @@ static void ni_ai_munge(struct comedi_device * dev, struct comedi_subdevice * s,
#ifdef PCIDMA
-static int ni_ai_setup_MITE_dma(struct comedi_device * dev)
+static int ni_ai_setup_MITE_dma(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
int retval;
@@ -1548,15 +1547,14 @@ static int ni_ai_setup_MITE_dma(struct comedi_device * dev)
retval = ni_request_ai_mite_channel(dev);
if (retval)
return retval;
-// rt_printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel);
+/* printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel); */
/* write alloc the entire buffer */
comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz);
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
- if(devpriv->ai_mite_chan == NULL)
- {
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ if (devpriv->ai_mite_chan == NULL) {
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return -EIO;
}
@@ -1574,12 +1572,12 @@ static int ni_ai_setup_MITE_dma(struct comedi_device * dev)
};
/*start the MITE */
mite_dma_arm(devpriv->ai_mite_chan);
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
}
-static int ni_ao_setup_MITE_dma(struct comedi_device * dev)
+static int ni_ao_setup_MITE_dma(struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV;
int retval;
@@ -1592,7 +1590,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device * dev)
/* read alloc the entire buffer */
comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz);
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ao_mite_chan) {
if (boardtype.reg_type & (ni_reg_611x | ni_reg_6713)) {
mite_prep_dma(devpriv->ao_mite_chan, 32, 32);
@@ -1604,12 +1602,12 @@ static int ni_ao_setup_MITE_dma(struct comedi_device * dev)
mite_dma_arm(devpriv->ao_mite_chan);
} else
retval = -EIO;
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return retval;
}
-#endif // PCIDMA
+#endif /* PCIDMA */
/*
used for both cancel ioctl and board initialization
@@ -1617,7 +1615,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device * dev)
this is pretty harsh for a cancel, but it works...
*/
-static int ni_ai_reset(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
{
ni_release_ai_mite_channel(dev);
/* ai configuration */
@@ -1698,14 +1696,14 @@ static int ni_ai_reset(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int ni_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags = 0;
int count;
- // lock to avoid race with interrupt handler
+ /* lock to avoid race with interrupt handler */
if (in_interrupt() == 0)
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
#ifndef PCIDMA
ni_handle_fifo_dregs(dev);
#else
@@ -1713,13 +1711,13 @@ static int ni_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s)
#endif
count = s->async->buf_write_count - s->async->buf_read_count;
if (in_interrupt() == 0)
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return count;
}
-static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
const unsigned int mask = (1 << boardtype.adbits) - 1;
@@ -1736,7 +1734,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice *
for (n = 0; n < num_adc_stages_611x; n++) {
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
AI_Command_1_Register);
- comedi_udelay(1);
+ udelay(1);
}
for (n = 0; n < insn->n; n++) {
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
@@ -1758,7 +1756,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice *
}
}
if (i == NI_TIMEOUT) {
- rt_printk
+ printk
("ni_mio_common: timeout in 611x ni_ai_insn_read\n");
return -ETIME;
}
@@ -1774,13 +1772,13 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice *
dl = 0;
for (i = 0; i < NI_TIMEOUT; i++) {
if (ni_readl(AIFIFO_Status_6143) & 0x01) {
- ni_writel(0x01, AIFIFO_Control_6143); // Get stranded sample into FIFO
+ ni_writel(0x01, AIFIFO_Control_6143); /* Get stranded sample into FIFO */
dl = ni_readl(AIFIFO_Data_6143);
break;
}
}
if (i == NI_TIMEOUT) {
- rt_printk
+ printk
("ni_mio_common: timeout in 6143 ni_ai_insn_read\n");
return -ETIME;
}
@@ -1797,7 +1795,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice *
break;
}
if (i == NI_TIMEOUT) {
- rt_printk
+ printk
("ni_mio_common: timeout in ni_ai_insn_read\n");
return -ETIME;
}
@@ -1814,7 +1812,7 @@ static int ni_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice *
return insn->n;
}
-void ni_prime_channelgain_list(struct comedi_device * dev)
+void ni_prime_channelgain_list(struct comedi_device *dev)
{
int i;
devpriv->stc_writew(dev, AI_CONVERT_Pulse, AI_Command_1_Register);
@@ -1825,12 +1823,12 @@ void ni_prime_channelgain_list(struct comedi_device * dev)
devpriv->stc_writew(dev, 1, ADC_FIFO_Clear);
return;
}
- comedi_udelay(1);
+ udelay(1);
}
- rt_printk("ni_mio_common: timeout loading channel/gain list\n");
+ printk("ni_mio_common: timeout loading channel/gain list\n");
}
-static void ni_m_series_load_channelgain_list(struct comedi_device * dev,
+static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
unsigned int n_chan, unsigned int *list)
{
unsigned int chan, range, aref;
@@ -1841,7 +1839,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev,
devpriv->stc_writew(dev, 1, Configuration_Memory_Clear);
-// offset = 1 << (boardtype.adbits - 1);
+/* offset = 1 << (boardtype.adbits - 1); */
if ((list[0] & CR_ALT_SOURCE)) {
unsigned bypass_bits;
chan = CR_CHAN(list[0]);
@@ -1859,7 +1857,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev,
bypass_bits |= MSeries_AI_Bypass_Gain_Bits(range_code);
if (dither)
bypass_bits |= MSeries_AI_Bypass_Dither_Bit;
- // don't use 2's complement encoding
+ /* don't use 2's complement encoding */
bypass_bits |= MSeries_AI_Bypass_Polarity_Bit;
ni_writel(bypass_bits, M_Offset_AI_Config_FIFO_Bypass);
} else {
@@ -1899,7 +1897,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev,
config_bits |= MSeries_AI_Config_Last_Channel_Bit;
if (dither)
config_bits |= MSeries_AI_Config_Dither_Bit;
- // don't use 2's complement encoding
+ /* don't use 2's complement encoding */
config_bits |= MSeries_AI_Config_Polarity_Bit;
ni_writew(config_bits, M_Offset_AI_Config_FIFO_Data);
}
@@ -1935,7 +1933,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device * dev,
* bits 0-2: channel
* valid channels are 0-3
*/
-static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_chan,
+static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan,
unsigned int *list)
{
unsigned int chan, range, aref;
@@ -1952,7 +1950,7 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_
&& (boardtype.reg_type != ni_reg_6143)) {
if (devpriv->changain_state
&& devpriv->changain_spec == list[0]) {
- // ready to go.
+ /* ready to go. */
return;
}
devpriv->changain_state = 1;
@@ -1963,11 +1961,11 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_
devpriv->stc_writew(dev, 1, Configuration_Memory_Clear);
- // Set up Calibration mode if required
+ /* Set up Calibration mode if required */
if (boardtype.reg_type == ni_reg_6143) {
if ((list[0] & CR_ALT_SOURCE)
&& !devpriv->ai_calib_source_enabled) {
- // Strobe Relay enable bit
+ /* Strobe Relay enable bit */
ni_writew(devpriv->
ai_calib_source |
Calibration_Channel_6143_RelayOn,
@@ -1975,10 +1973,10 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_
ni_writew(devpriv->ai_calib_source,
Calibration_Channel_6143);
devpriv->ai_calib_source_enabled = 1;
- msleep_interruptible(100); // Allow relays to change
+ msleep_interruptible(100); /* Allow relays to change */
} else if (!(list[0] & CR_ALT_SOURCE)
&& devpriv->ai_calib_source_enabled) {
- // Strobe Relay disable bit
+ /* Strobe Relay disable bit */
ni_writew(devpriv->
ai_calib_source |
Calibration_Channel_6143_RelayOff,
@@ -1986,7 +1984,7 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_
ni_writew(devpriv->ai_calib_source,
Calibration_Channel_6143);
devpriv->ai_calib_source_enabled = 0;
- msleep_interruptible(100); // Allow relays to change
+ msleep_interruptible(100); /* Allow relays to change */
}
}
@@ -2055,7 +2053,7 @@ static void ni_load_channelgain_list(struct comedi_device * dev, unsigned int n_
}
}
-static int ni_ns_to_timer(const struct comedi_device * dev, unsigned nanosec,
+static int ni_ns_to_timer(const struct comedi_device *dev, unsigned nanosec,
int round_mode)
{
int divider;
@@ -2074,29 +2072,29 @@ static int ni_ns_to_timer(const struct comedi_device * dev, unsigned nanosec,
return divider - 1;
}
-static unsigned ni_timer_to_ns(const struct comedi_device * dev, int timer)
+static unsigned ni_timer_to_ns(const struct comedi_device *dev, int timer)
{
return devpriv->clock_ns * (timer + 1);
}
-static unsigned ni_min_ai_scan_period_ns(struct comedi_device * dev,
+static unsigned ni_min_ai_scan_period_ns(struct comedi_device *dev,
unsigned num_channels)
{
switch (boardtype.reg_type) {
case ni_reg_611x:
case ni_reg_6143:
- // simultaneously-sampled inputs
+ /* simultaneously-sampled inputs */
return boardtype.ai_speed;
break;
default:
- // multiplexed inputs
+ /* multiplexed inputs */
break;
};
return boardtype.ai_speed * num_channels;
}
-static int ni_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -2308,7 +2306,7 @@ static int ni_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct comedi_cmd *cmd = &s->async->cmd;
int timer;
@@ -2367,10 +2365,10 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
if (cmd->chanlist_len == 1 || (boardtype.reg_type == ni_reg_611x)
|| (boardtype.reg_type == ni_reg_6143)) {
start_stop_select |= AI_STOP_Polarity;
- start_stop_select |= AI_STOP_Select(31); // logic low
+ start_stop_select |= AI_STOP_Select(31); /* logic low */
start_stop_select |= AI_STOP_Sync;
} else {
- start_stop_select |= AI_STOP_Select(19); // ai configuration memory
+ start_stop_select |= AI_STOP_Select(19); /* ai configuration memory */
}
devpriv->stc_writew(dev, start_stop_select,
AI_START_STOP_Select_Register);
@@ -2381,7 +2379,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
stop_count = cmd->stop_arg - 1;
if (boardtype.reg_type == ni_reg_611x) {
- // have to take 3 stage adc pipeline into account
+ /* have to take 3 stage adc pipeline into account */
stop_count += num_adc_stages_611x;
}
/* stage number of scans */
@@ -2396,7 +2394,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
if (stop_count == 0) {
devpriv->ai_cmd2 |= AI_End_On_End_Of_Scan;
interrupt_a_enable |= AI_STOP_Interrupt_Enable;
- // this is required to get the last sample for chanlist_len > 1, not sure why
+ /* this is required to get the last sample for chanlist_len > 1, not sure why */
if (cmd->chanlist_len > 1)
start_stop_select |=
AI_STOP_Polarity | AI_STOP_Edge;
@@ -2440,7 +2438,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
mode2 |= AI_SI_Reload_Mode(0);
/* AI_SI_Initial_Load_Source=A */
mode2 &= ~AI_SI_Initial_Load_Source;
- //mode2 |= AI_SC_Reload_Mode;
+ /* mode2 |= AI_SC_Reload_Mode; */
devpriv->stc_writew(dev, mode2, AI_Mode_2_Register);
/* load SI */
@@ -2486,8 +2484,8 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
/* AI_SI2_Load */
devpriv->stc_writew(dev, AI_SI2_Load, AI_Command_1_Register);
- mode2 |= AI_SI2_Reload_Mode; // alternate
- mode2 |= AI_SI2_Initial_Load_Source; // B
+ mode2 |= AI_SI2_Reload_Mode; /* alternate */
+ mode2 |= AI_SI2_Initial_Load_Source; /* B */
devpriv->stc_writew(dev, mode2, AI_Mode_2_Register);
break;
@@ -2589,7 +2587,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
if (retval)
return retval;
}
- //mite_dump_regs(devpriv->mite);
+ /* mite_dump_regs(devpriv->mite); */
#endif
switch (cmd->start_src) {
@@ -2612,7 +2610,7 @@ static int ni_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int ni_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
if (trignum != 0)
@@ -2625,11 +2623,11 @@ static int ni_ai_inttrig(struct comedi_device * dev, struct comedi_subdevice * s
return 1;
}
-static int ni_ai_config_analog_trig(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int ni_ai_config_analog_trig(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static int ni_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
@@ -2679,8 +2677,8 @@ static int ni_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice
return -EINVAL;
}
-static int ni_ai_config_analog_trig(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ai_config_analog_trig(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int a, b, modebits;
int err = 0;
@@ -2777,7 +2775,7 @@ static int ni_ai_config_analog_trig(struct comedi_device * dev, struct comedi_su
}
/* munge data from unsigned to 2's complement for analog output bipolar modes */
-static void ni_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s,
+static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *data, unsigned int num_bytes, unsigned int chan_index)
{
struct comedi_async *async = s->async;
@@ -2800,8 +2798,8 @@ static void ni_ao_munge(struct comedi_device * dev, struct comedi_subdevice * s,
}
}
-static int ni_m_series_ao_config_chanlist(struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned int chanspec[], unsigned int n_chans,
+static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int chanspec[], unsigned int n_chans,
int timed)
{
unsigned int range;
@@ -2810,7 +2808,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev,
int i;
int invert = 0;
- if(timed) {
+ if (timed) {
for (i = 0; i < boardtype.n_aochan; ++i) {
devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit;
ni_writeb(devpriv->ao_conf[i], M_Offset_AO_Config_Bank(i));
@@ -2844,8 +2842,8 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev,
M_Offset_AO_Reference_Attenuation(chan));
break;
default:
- rt_printk("%s: bug! unhandled ao reference voltage\n",
- __FUNCTION__);
+ printk("%s: bug! unhandled ao reference voltage\n",
+ __func__);
break;
}
switch (krange->max + krange->min) {
@@ -2856,8 +2854,8 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev,
conf |= MSeries_AO_DAC_Offset_5V_Bits;
break;
default:
- rt_printk("%s: bug! unhandled ao offset voltage\n",
- __FUNCTION__);
+ printk("%s: bug! unhandled ao offset voltage\n",
+ __func__);
break;
}
if (timed)
@@ -2869,7 +2867,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device * dev,
return invert;
}
-static int ni_old_ao_config_chanlist(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_old_ao_config_chanlist(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int chanspec[], unsigned int n_chans)
{
unsigned int range;
@@ -2912,7 +2910,7 @@ static int ni_old_ao_config_chanlist(struct comedi_device * dev, struct comedi_s
return invert;
}
-static int ni_ao_config_chanlist(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_ao_config_chanlist(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int chanspec[], unsigned int n_chans, int timed)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
@@ -2921,16 +2919,16 @@ static int ni_ao_config_chanlist(struct comedi_device * dev, struct comedi_subde
else
return ni_old_ao_config_chanlist(dev, s, chanspec, n_chans);
}
-static int ni_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
return 1;
}
-static int ni_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int invert;
@@ -2948,8 +2946,8 @@ static int ni_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int ni_ao_insn_write_671x(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ao_insn_write_671x(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int invert;
@@ -2965,16 +2963,16 @@ static int ni_ao_insn_write_671x(struct comedi_device * dev, struct comedi_subde
return 1;
}
-static int ni_ao_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_ao_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
case INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE:
- switch(data[1])
+ switch (data[1])
{
case COMEDI_OUTPUT:
data[2] = 1 + boardtype.ao_fifo_depth * sizeof(short);
- if(devpriv->mite) data[2] += devpriv->mite->fifo_size;
+ if (devpriv->mite) data[2] += devpriv->mite->fifo_size;
break;
case COMEDI_INPUT:
data[2] = 0;
@@ -2991,7 +2989,7 @@ static int ni_ao_insn_config(struct comedi_device * dev, struct comedi_subdevice
return -EINVAL;
}
-static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
int ret;
@@ -3033,7 +3031,7 @@ static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s
devpriv->stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
/* wait for DACs to be loaded */
for (i = 0; i < timeout; i++) {
- comedi_udelay(1);
+ udelay(1);
if ((devpriv->stc_readw(dev,
Joint_Status_2_Register) &
AO_TMRDACWRs_In_Progress_St) == 0)
@@ -3044,7 +3042,7 @@ static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s
"timed out waiting for AO_TMRDACWRs_In_Progress_St to clear");
return -EIO;
}
- // stc manual says we are need to clear error interrupt after AO_TMRDACWRs_In_Progress_St clears
+ /* stc manual says we are need to clear error interrupt after AO_TMRDACWRs_In_Progress_St clears */
devpriv->stc_writew(dev, AO_Error_Interrupt_Ack,
Interrupt_B_Ack_Register);
@@ -3062,7 +3060,7 @@ static int ni_ao_inttrig(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct comedi_cmd *cmd = &s->async->cmd;
int bits;
@@ -3114,9 +3112,9 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
case TRIG_EXT:
devpriv->ao_trigger_select = AO_START1_Select(CR_CHAN(cmd->start_arg)+1);
if (cmd->start_arg & CR_INVERT)
- devpriv->ao_trigger_select |= AO_START1_Polarity; // 0=active high, 1=active low. see daq-stc 3-24 (p186)
+ devpriv->ao_trigger_select |= AO_START1_Polarity; /* 0=active high, 1=active low. see daq-stc 3-24 (p186) */
if (cmd->start_arg & CR_EDGE)
- devpriv->ao_trigger_select |= AO_START1_Edge; // 0=edge detection disabled, 1=enabled
+ devpriv->ao_trigger_select |= AO_START1_Edge; /* 0=edge detection disabled, 1=enabled */
devpriv->stc_writew(dev, devpriv->ao_trigger_select, AO_Trigger_Select_Register);
break;
default:
@@ -3139,9 +3137,9 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
switch (cmd->stop_src) {
case TRIG_COUNT:
- if(boardtype.reg_type & ni_reg_m_series_mask)
+ if (boardtype.reg_type & ni_reg_m_series_mask)
{
- // this is how the NI example code does it for m-series boards, verified correct with 6259
+ /* this is how the NI example code does it for m-series boards, verified correct with 6259 */
devpriv->stc_writel(dev, cmd->stop_arg - 1, AO_UC_Load_A_Register);
devpriv->stc_writew(dev, AO_UC_Load, AO_Command_1_Register);
}else
@@ -3244,7 +3242,7 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
bits |= AO_Number_Of_DAC_Packages;
#endif
devpriv->stc_writew(dev, bits, AO_Personal_Register);
- // enable sending of ao dma requests
+ /* enable sending of ao dma requests */
devpriv->stc_writew(dev, AO_AOFREQ_Enable, AO_Start_Select_Register);
devpriv->stc_writew(dev, AO_Configuration_End, Joint_Reset_Register);
@@ -3261,8 +3259,8 @@ static int ni_ao_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int ni_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -3384,13 +3382,13 @@ static int ni_ao_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
{
- //devpriv->ao0p=0x0000;
- //ni_writew(devpriv->ao0p,AO_Configuration);
+ /* devpriv->ao0p=0x0000; */
+ /* ni_writew(devpriv->ao0p,AO_Configuration); */
- //devpriv->ao1p=AO_Channel(1);
- //ni_writew(devpriv->ao1p,AO_Configuration);
+ /* devpriv->ao1p=AO_Channel(1); */
+ /* ni_writew(devpriv->ao1p,AO_Configuration); */
ni_release_ao_mite_channel(dev);
@@ -3422,7 +3420,7 @@ static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s)
if (boardtype.reg_type & ni_reg_6xxx_mask) {
unsigned immediate_bits = 0;
unsigned i;
- for(i = 0; i < s->n_chan; ++i)
+ for (i = 0; i < s->n_chan; ++i)
{
immediate_bits |= 1 << i;
}
@@ -3434,13 +3432,13 @@ static int ni_ao_reset(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-// digital io
+/* digital io */
-static int ni_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
#ifdef DEBUG_DIO
- rt_printk("ni_dio_insn_config() chan=%d io=%d\n",
+ printk("ni_dio_insn_config() chan=%d io=%d\n",
CR_CHAN(insn->chanspec), data[0]);
#endif
switch (data[0]) {
@@ -3468,11 +3466,11 @@ static int ni_dio_insn_config(struct comedi_device * dev, struct comedi_subdevic
return 1;
}
-static int ni_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
#ifdef DEBUG_DIO
- rt_printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]);
+ printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]);
#endif
if (insn->n != 2)
return -EINVAL;
@@ -3495,11 +3493,11 @@ static int ni_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int ni_m_series_dio_insn_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_m_series_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
#ifdef DEBUG_DIO
- rt_printk("ni_m_series_dio_insn_config() chan=%d io=%d\n",
+ printk("ni_m_series_dio_insn_config() chan=%d io=%d\n",
CR_CHAN(insn->chanspec), data[0]);
#endif
switch (data[0]) {
@@ -3525,11 +3523,11 @@ static int ni_m_series_dio_insn_config(struct comedi_device * dev,
return 1;
}
-static int ni_m_series_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_m_series_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
#ifdef DEBUG_DIO
- rt_printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
+ printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
data[1]);
#endif
if (insn->n != 2)
@@ -3544,8 +3542,8 @@ static int ni_m_series_dio_insn_bits(struct comedi_device * dev, struct comedi_s
return 2;
}
-static int ni_cdio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_cdio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -3653,7 +3651,7 @@ static int ni_cdio_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int ni_cdio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct comedi_cmd *cmd = &s->async->cmd;
unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit;
@@ -3690,7 +3688,7 @@ static int ni_cdio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return 0;
}
-static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
#ifdef PCIDMA
@@ -3706,7 +3704,7 @@ static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice *
comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz);
#ifdef PCIDMA
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->cdo_mite_chan) {
mite_prep_dma(devpriv->cdo_mite_chan, 32, 32);
mite_dma_arm(devpriv->cdo_mite_chan);
@@ -3714,17 +3712,19 @@ static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice *
comedi_error(dev, "BUG: no cdo mite channel?");
retval = -EIO;
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
if (retval < 0)
return retval;
#endif
-// XXX not sure what interrupt C group does
-// ni_writeb(Interrupt_Group_C_Enable_Bit, M_Offset_Interrupt_C_Enable);
- //wait for dma to fill output fifo
+/*
+* XXX not sure what interrupt C group does
+* ni_writeb(Interrupt_Group_C_Enable_Bit,
+* M_Offset_Interrupt_C_Enable); wait for dma to fill output fifo
+*/
for (i = 0; i < timeout; ++i) {
if (ni_readl(M_Offset_CDIO_Status) & CDO_FIFO_Full_Bit)
break;
- comedi_udelay(10);
+ udelay(10);
}
if (i == timeout) {
comedi_error(dev, "dma failed to fill cdo fifo!");
@@ -3736,20 +3736,22 @@ static int ni_cdo_inttrig(struct comedi_device * dev, struct comedi_subdevice *
return retval;
}
-static int ni_cdio_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
ni_writel(CDO_Disarm_Bit | CDO_Error_Interrupt_Enable_Clear_Bit |
CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit |
CDO_FIFO_Request_Interrupt_Enable_Clear_Bit,
M_Offset_CDIO_Command);
-// XXX not sure what interrupt C group does
-// ni_writeb(0, M_Offset_Interrupt_C_Enable);
+/*
+* XXX not sure what interrupt C group does ni_writeb(0,
+* M_Offset_Interrupt_C_Enable);
+*/
ni_writel(0, M_Offset_CDO_Mask_Enable);
ni_release_cdo_mite_channel(dev);
return 0;
}
-static void handle_cdio_interrupt(struct comedi_device * dev)
+static void handle_cdio_interrupt(struct comedi_device *dev)
{
unsigned cdio_status;
struct comedi_subdevice *s = dev->subdevices + NI_DIO_SUBDEV;
@@ -3761,7 +3763,7 @@ static void handle_cdio_interrupt(struct comedi_device * dev)
return;
}
#ifdef PCIDMA
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->cdo_mite_chan) {
unsigned cdo_mite_status =
mite_get_status(devpriv->cdo_mite_chan);
@@ -3772,26 +3774,26 @@ static void handle_cdio_interrupt(struct comedi_device * dev)
}
mite_sync_output_dma(devpriv->cdo_mite_chan, s->async);
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
#endif
cdio_status = ni_readl(M_Offset_CDIO_Status);
if (cdio_status & (CDO_Overrun_Bit | CDO_Underflow_Bit)) {
-// rt_printk("cdio error: statux=0x%x\n", cdio_status);
- ni_writel(CDO_Error_Interrupt_Confirm_Bit, M_Offset_CDIO_Command); // XXX just guessing this is needed and does something useful
+/* printk("cdio error: statux=0x%x\n", cdio_status); */
+ ni_writel(CDO_Error_Interrupt_Confirm_Bit, M_Offset_CDIO_Command); /* XXX just guessing this is needed and does something useful */
s->async->events |= COMEDI_CB_OVERFLOW;
}
if (cdio_status & CDO_FIFO_Empty_Bit) {
-// rt_printk("cdio fifo empty\n");
+/* printk("cdio fifo empty\n"); */
ni_writel(CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit,
M_Offset_CDIO_Command);
-// s->async->events |= COMEDI_CB_EOA;
+/* s->async->events |= COMEDI_CB_EOA; */
}
ni_event(dev, s);
}
-static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int err = insn->n;
unsigned char byte_out, byte_in = 0;
@@ -3803,7 +3805,7 @@ static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subde
case INSN_CONFIG_SERIAL_CLOCK:
#ifdef DEBUG_DIO
- rt_printk("SPI serial clock Config cd\n", data[1]);
+ printk("SPI serial clock Config cd\n", data[1]);
#endif
devpriv->serial_hw_mode = 1;
devpriv->dio_control |= DIO_HW_Serial_Enable;
@@ -3869,7 +3871,7 @@ static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subde
err = ni_serial_sw_readwrite8(dev, s, byte_out,
&byte_in);
} else {
- rt_printk("ni_serial_insn_config: serial disabled!\n");
+ printk("ni_serial_insn_config: serial disabled!\n");
return -EINVAL;
}
if (err < 0)
@@ -3884,14 +3886,14 @@ static int ni_serial_insn_config(struct comedi_device * dev, struct comedi_subde
}
-static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_serial_hw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned char data_out, unsigned char *data_in)
{
unsigned int status1;
int err = 0, count = 20;
#ifdef DEBUG_DIO
- rt_printk("ni_serial_hw_readwrite8: outputting 0x%x\n", data_out);
+ printk("ni_serial_hw_readwrite8: outputting 0x%x\n", data_out);
#endif
devpriv->dio_output &= ~DIO_Serial_Data_Mask;
@@ -3914,9 +3916,9 @@ static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_sub
Joint_Status_1_Register)) &
DIO_Serial_IO_In_Progress_St) {
/* Delay one bit per loop */
- comedi_udelay((devpriv->serial_interval_ns + 999) / 1000);
+ udelay((devpriv->serial_interval_ns + 999) / 1000);
if (--count < 0) {
- rt_printk
+ printk
("ni_serial_hw_readwrite8: SPI serial I/O didn't finish in time!\n");
err = -ETIME;
goto Error;
@@ -3925,12 +3927,12 @@ static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_sub
/* Delay for last bit. This delay is absolutely necessary, because
DIO_Serial_IO_In_Progress_St goes high one bit too early. */
- comedi_udelay((devpriv->serial_interval_ns + 999) / 1000);
+ udelay((devpriv->serial_interval_ns + 999) / 1000);
if (data_in != NULL) {
*data_in = devpriv->stc_readw(dev, DIO_Serial_Input_Register);
#ifdef DEBUG_DIO
- rt_printk("ni_serial_hw_readwrite8: inputted 0x%x\n", *data_in);
+ printk("ni_serial_hw_readwrite8: inputted 0x%x\n", *data_in);
#endif
}
@@ -3940,17 +3942,17 @@ static int ni_serial_hw_readwrite8(struct comedi_device * dev, struct comedi_sub
return err;
}
-static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_serial_sw_readwrite8(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned char data_out, unsigned char *data_in)
{
unsigned char mask, input = 0;
#ifdef DEBUG_DIO
- rt_printk("ni_serial_sw_readwrite8: outputting 0x%x\n", data_out);
+ printk("ni_serial_sw_readwrite8: outputting 0x%x\n", data_out);
#endif
/* Wait for one bit before transfer */
- comedi_udelay((devpriv->serial_interval_ns + 999) / 1000);
+ udelay((devpriv->serial_interval_ns + 999) / 1000);
for (mask = 0x80; mask; mask >>= 1) {
/* Output current bit; note that we cannot touch s->state
@@ -3969,23 +3971,23 @@ static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_sub
devpriv->stc_writew(dev, devpriv->dio_control,
DIO_Control_Register);
- comedi_udelay((devpriv->serial_interval_ns + 999) / 2000);
+ udelay((devpriv->serial_interval_ns + 999) / 2000);
devpriv->dio_control &= ~DIO_Software_Serial_Control;
devpriv->stc_writew(dev, devpriv->dio_control,
DIO_Control_Register);
- comedi_udelay((devpriv->serial_interval_ns + 999) / 2000);
+ udelay((devpriv->serial_interval_ns + 999) / 2000);
/* Input current bit */
if (devpriv->stc_readw(dev,
DIO_Parallel_Input_Register) & DIO_SDIN) {
-/* rt_printk("DIO_P_I_R: 0x%x\n", devpriv->stc_readw(dev, DIO_Parallel_Input_Register)); */
+/* printk("DIO_P_I_R: 0x%x\n", devpriv->stc_readw(dev, DIO_Parallel_Input_Register)); */
input |= mask;
}
}
#ifdef DEBUG_DIO
- rt_printk("ni_serial_sw_readwrite8: inputted 0x%x\n", input);
+ printk("ni_serial_sw_readwrite8: inputted 0x%x\n", input);
#endif
if (data_in)
*data_in = input;
@@ -3993,7 +3995,7 @@ static int ni_serial_sw_readwrite8(struct comedi_device * dev, struct comedi_sub
return 0;
}
-static void mio_common_detach(struct comedi_device * dev)
+static void mio_common_detach(struct comedi_device *dev)
{
if (dev->private) {
if (devpriv->counter_dev) {
@@ -4004,7 +4006,7 @@ static void mio_common_detach(struct comedi_device * dev)
subdev_8255_cleanup(dev, dev->subdevices + NI_8255_DIO_SUBDEV);
}
-static void init_ao_67xx(struct comedi_device * dev, struct comedi_subdevice * s)
+static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s)
{
int i;
@@ -4099,8 +4101,8 @@ static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg)
stc_register = Interrupt_B_Enable_Register;
break;
default:
- rt_printk("%s: unhandled register 0x%x in switch.\n",
- __FUNCTION__, reg);
+ printk("%s: unhandled register 0x%x in switch.\n",
+ __func__, reg);
BUG();
return 0;
break;
@@ -4208,15 +4210,15 @@ static unsigned ni_gpct_read_register(struct ni_gpct *counter,
return 0;
}
-static int ni_freq_out_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_freq_out_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->clock_and_fout & FOUT_Divider_mask;
return 1;
}
-static int ni_freq_out_insn_write(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_freq_out_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
devpriv->clock_and_fout &= ~FOUT_Enable;
devpriv->stc_writew(dev, devpriv->clock_and_fout,
@@ -4229,7 +4231,7 @@ static int ni_freq_out_insn_write(struct comedi_device * dev,
return insn->n;
}
-static int ni_set_freq_out_clock(struct comedi_device * dev, unsigned int clock_source)
+static int ni_set_freq_out_clock(struct comedi_device *dev, unsigned int clock_source)
{
switch (clock_source) {
case NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC:
@@ -4246,8 +4248,8 @@ static int ni_set_freq_out_clock(struct comedi_device * dev, unsigned int clock_
return 3;
}
-static void ni_get_freq_out_clock(struct comedi_device * dev, unsigned int * clock_source,
- unsigned int * clock_period_ns)
+static void ni_get_freq_out_clock(struct comedi_device *dev, unsigned int *clock_source,
+ unsigned int *clock_period_ns)
{
if (devpriv->clock_and_fout & FOUT_Timebase_Select) {
*clock_source = NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC;
@@ -4258,8 +4260,8 @@ static void ni_get_freq_out_clock(struct comedi_device * dev, unsigned int * clo
}
}
-static int ni_freq_out_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_freq_out_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
case INSN_CONFIG_SET_CLOCK_SRC:
@@ -4274,11 +4276,11 @@ static int ni_freq_out_insn_config(struct comedi_device * dev, struct comedi_sub
return -EINVAL;
}
-static int ni_alloc_private(struct comedi_device * dev)
+static int ni_alloc_private(struct comedi_device *dev)
{
int ret;
- ret = alloc_private(dev, sizeof(ni_private));
+ ret = alloc_private(dev, sizeof(struct ni_private));
if (ret < 0)
return ret;
@@ -4289,7 +4291,7 @@ static int ni_alloc_private(struct comedi_device * dev)
return 0;
};
-static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it)
+static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned j;
@@ -4419,14 +4421,14 @@ static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it)
s = dev->subdevices + NI_CALIBRATION_SUBDEV;
s->type = COMEDI_SUBD_CALIB;
if (boardtype.reg_type & ni_reg_m_series_mask) {
- // internal PWM analog output used for AI nonlinearity calibration
+ /* internal PWM analog output used for AI nonlinearity calibration */
s->subdev_flags = SDF_INTERNAL;
s->insn_config = &ni_m_series_pwm_config;
s->n_chan = 1;
s->maxdata = 0;
ni_writel(0x0, M_Offset_Cal_PWM);
} else if (boardtype.reg_type == ni_reg_6143) {
- // internal PWM analog output used for AI nonlinearity calibration
+ /* internal PWM analog output used for AI nonlinearity calibration */
s->subdev_flags = SDF_INTERNAL;
s->insn_config = &ni_6143_pwm_config;
s->n_chan = 1;
@@ -4478,7 +4480,7 @@ static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it)
if (boardtype.reg_type & ni_reg_67xx_mask) {
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_INTERNAL;
- // one channel for each analog output channel
+ /* one channel for each analog output channel */
s->n_chan = boardtype.n_aochan;
s->maxdata = (1 << 16) - 1;
s->range_table = &range_unknown; /* XXX */
@@ -4557,7 +4559,7 @@ static int ni_E_init(struct comedi_device * dev, struct comedi_devconfig * it)
/* ai configuration */
ni_ai_reset(dev, dev->subdevices + NI_AI_SUBDEV);
if ((boardtype.reg_type & ni_reg_6xxx_mask) == 0) {
- // BEAM is this needed for PCI-6143 ??
+ /* BEAM is this needed for PCI-6143 ?? */
devpriv->clock_and_fout =
Slow_Internal_Time_Divide_By_2 |
Slow_Internal_Timebase |
@@ -4623,8 +4625,8 @@ static int ni_8255_callback(int dir, int port, int data, unsigned long arg)
presents the EEPROM as a subdevice
*/
-static int ni_eeprom_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_eeprom_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = ni_read_eeprom(dev, CR_CHAN(insn->chanspec));
@@ -4635,7 +4637,7 @@ static int ni_eeprom_insn_read(struct comedi_device * dev, struct comedi_subdevi
reads bytes out of eeprom
*/
-static int ni_read_eeprom(struct comedi_device * dev, int addr)
+static int ni_read_eeprom(struct comedi_device *dev, int addr)
{
int bit;
int bitstring;
@@ -4659,23 +4661,23 @@ static int ni_read_eeprom(struct comedi_device * dev, int addr)
return bitstring;
}
-static int ni_m_series_eeprom_insn_read(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int ni_m_series_eeprom_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->eeprom_buffer[CR_CHAN(insn->chanspec)];
return 1;
}
-static int ni_get_pwm_config(struct comedi_device * dev, unsigned int * data)
+static int ni_get_pwm_config(struct comedi_device *dev, unsigned int *data)
{
data[1] = devpriv->pwm_up_count * devpriv->clock_ns;
data[2] = devpriv->pwm_down_count * devpriv->clock_ns;
return 3;
}
-static int ni_m_series_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned up_count, down_count;
switch (data[0]) {
@@ -4739,8 +4741,8 @@ static int ni_m_series_pwm_config(struct comedi_device * dev, struct comedi_subd
return 0;
}
-static int ni_6143_pwm_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_6143_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned up_count, down_count;
switch (data[0]) {
@@ -4802,20 +4804,20 @@ static int ni_6143_pwm_config(struct comedi_device * dev, struct comedi_subdevic
return 0;
}
-static void ni_write_caldac(struct comedi_device * dev, int addr, int val);
+static void ni_write_caldac(struct comedi_device *dev, int addr, int val);
/*
calibration subdevice
*/
-static int ni_calib_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
ni_write_caldac(dev, CR_CHAN(insn->chanspec), data[0]);
return 1;
}
-static int ni_calib_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->caldacs[CR_CHAN(insn->chanspec)];
@@ -4845,7 +4847,7 @@ static struct caldac_struct caldacs[] = {
[ad8804_debug] = {16, 8, pack_ad8804},
};
-static void caldac_setup(struct comedi_device * dev, struct comedi_subdevice * s)
+static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s)
{
int i, j;
int n_dacs;
@@ -4898,13 +4900,13 @@ static void caldac_setup(struct comedi_device * dev, struct comedi_subdevice * s
}
}
-static void ni_write_caldac(struct comedi_device * dev, int addr, int val)
+static void ni_write_caldac(struct comedi_device *dev, int addr, int val)
{
unsigned int loadbit = 0, bits = 0, bit, bitstring = 0;
int i;
int type;
- //printk("ni_write_caldac: chan=%d val=%d\n",addr,val);
+ /* printk("ni_write_caldac: chan=%d val=%d\n",addr,val); */
if (devpriv->caldacs[addr] == val)
return;
devpriv->caldacs[addr] = val;
@@ -4916,7 +4918,7 @@ static void ni_write_caldac(struct comedi_device * dev, int addr, int val)
if (addr < caldacs[type].n_chans) {
bits = caldacs[type].packbits(addr, val, &bitstring);
loadbit = SerDacLd(i);
- //printk("caldac: using i=%d addr=%d %x\n",i,addr,bitstring);
+ /* printk("caldac: using i=%d addr=%d %x\n",i,addr,bitstring); */
break;
}
addr -= caldacs[type].n_chans;
@@ -4924,12 +4926,12 @@ static void ni_write_caldac(struct comedi_device * dev, int addr, int val)
for (bit = 1 << (bits - 1); bit; bit >>= 1) {
ni_writeb(((bit & bitstring) ? 0x02 : 0), Serial_Command);
- comedi_udelay(1);
+ udelay(1);
ni_writeb(1 | ((bit & bitstring) ? 0x02 : 0), Serial_Command);
- comedi_udelay(1);
+ udelay(1);
}
ni_writeb(loadbit, Serial_Command);
- comedi_udelay(1);
+ udelay(1);
ni_writeb(0, Serial_Command);
}
@@ -4985,7 +4987,7 @@ static int pack_ad8842(int addr, int val, int *bitstring)
/*
* Read the GPCTs current value.
*/
-static int GPCT_G_Watch(struct comedi_device * dev, int chan)
+static int GPCT_G_Watch(struct comedi_device *dev, int chan)
{
unsigned int hi1, hi2, lo;
@@ -5008,11 +5010,11 @@ static int GPCT_G_Watch(struct comedi_device * dev, int chan)
return (hi1 << 16) | lo;
}
-static void GPCT_Reset(struct comedi_device * dev, int chan)
+static void GPCT_Reset(struct comedi_device *dev, int chan)
{
int temp_ack_reg = 0;
- //printk("GPCT_Reset...");
+ /* printk("GPCT_Reset..."); */
devpriv->gpct_cur_operation[chan] = GPCT_RESET;
switch (chan) {
@@ -5029,7 +5031,7 @@ static void GPCT_Reset(struct comedi_device * dev, int chan)
devpriv->stc_writew(dev, temp_ack_reg,
Interrupt_A_Ack_Register);
- //problem...this interferes with the other ctr...
+ /* problem...this interferes with the other ctr... */
devpriv->an_trig_etc_reg |= GPFO_0_Output_Enable;
devpriv->stc_writew(dev, devpriv->an_trig_etc_reg,
Analog_Trigger_Etc_Register);
@@ -5065,38 +5067,38 @@ static void GPCT_Reset(struct comedi_device * dev, int chan)
G_Input_Select_Register(chan));
devpriv->stc_writew(dev, 0, G_Autoincrement_Register(chan));
- //printk("exit GPCT_Reset\n");
+ /* printk("exit GPCT_Reset\n"); */
}
#endif
-static int ni_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct ni_gpct *counter = s->private;
return ni_tio_insn_config(counter, insn, data);
}
-static int ni_gpct_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_gpct_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct ni_gpct *counter = s->private;
return ni_tio_rinsn(counter, insn, data);
}
-static int ni_gpct_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_gpct_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct ni_gpct *counter = s->private;
return ni_tio_winsn(counter, insn, data);
}
-static int ni_gpct_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int retval;
#ifdef PCIDMA
struct ni_gpct *counter = s->private;
-// const struct comedi_cmd *cmd = &s->async->cmd;
+/* const struct comedi_cmd *cmd = &s->async->cmd; */
retval = ni_request_gpct_mite_channel(dev, counter->counter_index,
COMEDI_INPUT);
@@ -5114,8 +5116,8 @@ static int ni_gpct_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
return retval;
}
-static int ni_gpct_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_gpct_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
#ifdef PCIDMA
struct ni_gpct *counter = s->private;
@@ -5126,7 +5128,7 @@ static int ni_gpct_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
#endif
}
-static int ni_gpct_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
#ifdef PCIDMA
struct ni_gpct *counter = s->private;
@@ -5147,7 +5149,7 @@ static int ni_gpct_cancel(struct comedi_device * dev, struct comedi_subdevice *
*
*/
-static int ni_m_series_set_pfi_routing(struct comedi_device * dev, unsigned chan,
+static int ni_m_series_set_pfi_routing(struct comedi_device *dev, unsigned chan,
unsigned source)
{
unsigned pfi_reg_index;
@@ -5165,16 +5167,16 @@ static int ni_m_series_set_pfi_routing(struct comedi_device * dev, unsigned chan
return 2;
}
-static int ni_old_set_pfi_routing(struct comedi_device * dev, unsigned chan,
+static int ni_old_set_pfi_routing(struct comedi_device *dev, unsigned chan,
unsigned source)
{
- // pre-m-series boards have fixed signals on pfi pins
+ /* pre-m-series boards have fixed signals on pfi pins */
if (source != ni_old_get_pfi_routing(dev, chan))
return -EINVAL;
return 2;
}
-static int ni_set_pfi_routing(struct comedi_device * dev, unsigned chan,
+static int ni_set_pfi_routing(struct comedi_device *dev, unsigned chan,
unsigned source)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
@@ -5183,16 +5185,16 @@ static int ni_set_pfi_routing(struct comedi_device * dev, unsigned chan,
return ni_old_set_pfi_routing(dev, chan, source);
}
-static unsigned ni_m_series_get_pfi_routing(struct comedi_device * dev, unsigned chan)
+static unsigned ni_m_series_get_pfi_routing(struct comedi_device *dev, unsigned chan)
{
const unsigned array_offset = chan / 3;
return MSeries_PFI_Output_Select_Source(chan,
devpriv->pfi_output_select_reg[array_offset]);
}
-static unsigned ni_old_get_pfi_routing(struct comedi_device * dev, unsigned chan)
+static unsigned ni_old_get_pfi_routing(struct comedi_device *dev, unsigned chan)
{
- // pre-m-series boards have fixed signals on pfi pins
+ /* pre-m-series boards have fixed signals on pfi pins */
switch (chan) {
case 0:
return NI_PFI_OUTPUT_AI_START1;
@@ -5225,13 +5227,13 @@ static unsigned ni_old_get_pfi_routing(struct comedi_device * dev, unsigned chan
return NI_PFI_OUTPUT_G_GATE0;
break;
default:
- rt_printk("%s: bug, unhandled case in switch.\n", __FUNCTION__);
+ printk("%s: bug, unhandled case in switch.\n", __func__);
break;
}
return 0;
}
-static unsigned ni_get_pfi_routing(struct comedi_device * dev, unsigned chan)
+static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
return ni_m_series_get_pfi_routing(dev, chan);
@@ -5239,7 +5241,7 @@ static unsigned ni_get_pfi_routing(struct comedi_device * dev, unsigned chan)
return ni_old_get_pfi_routing(dev, chan);
}
-static int ni_config_filter(struct comedi_device * dev, unsigned pfi_channel,
+static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel,
enum ni_pfi_filter_select filter)
{
unsigned bits;
@@ -5253,8 +5255,8 @@ static int ni_config_filter(struct comedi_device * dev, unsigned pfi_channel,
return 0;
}
-static int ni_pfi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_pfi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if ((boardtype.reg_type & ni_reg_m_series_mask) == 0) {
return -ENOTSUPP;
@@ -5268,8 +5270,8 @@ static int ni_pfi_insn_bits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int ni_pfi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_pfi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int chan;
@@ -5312,16 +5314,16 @@ static int ni_pfi_insn_config(struct comedi_device * dev, struct comedi_subdevic
* NI RTSI Bus Functions
*
*/
-static void ni_rtsi_init(struct comedi_device * dev)
+static void ni_rtsi_init(struct comedi_device *dev)
{
- // Initialises the RTSI bus signal switch to a default state
+ /* Initialises the RTSI bus signal switch to a default state */
- // Set clock mode to internal
+ /* Set clock mode to internal */
devpriv->clock_and_fout2 = MSeries_RTSI_10MHz_Bit;
if (ni_set_master_clock(dev, NI_MIO_INTERNAL_CLOCK, 0) < 0) {
- rt_printk("ni_set_master_clock failed, bug?");
+ printk("ni_set_master_clock failed, bug?");
}
- // default internal lines routing to RTSI bus lines
+ /* default internal lines routing to RTSI bus lines */
devpriv->rtsi_trig_a_output_reg =
RTSI_Trig_Output_Bits(0,
NI_RTSI_OUTPUT_ADR_START1) | RTSI_Trig_Output_Bits(1,
@@ -5341,12 +5343,14 @@ static void ni_rtsi_init(struct comedi_device * dev)
devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
RTSI_Trig_B_Output_Register);
- // Sets the source and direction of the 4 on board lines
-// devpriv->stc_writew(dev, 0x0000, RTSI_Board_Register);
+/*
+* Sets the source and direction of the 4 on board lines
+* devpriv->stc_writew(dev, 0x0000, RTSI_Board_Register);
+*/
}
-static int ni_rtsi_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_rtsi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -5389,8 +5393,8 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
}
}
if (best_period_picosec == 0) {
- rt_printk("%s: bug, failed to find pll parameters\n",
- __FUNCTION__);
+ printk("%s: bug, failed to find pll parameters\n",
+ __func__);
return -EIO;
}
*freq_divider = best_div;
@@ -5401,7 +5405,7 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
return 0;
}
-static inline unsigned num_configurable_rtsi_channels(struct comedi_device * dev)
+static inline unsigned num_configurable_rtsi_channels(struct comedi_device *dev)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
return 8;
@@ -5409,7 +5413,7 @@ static inline unsigned num_configurable_rtsi_channels(struct comedi_device * dev
return 7;
}
-static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned source,
+static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned source,
unsigned period_ns)
{
static const unsigned min_period_ns = 50;
@@ -5422,11 +5426,11 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned
int retval;
if (source == NI_MIO_PLL_PXI10_CLOCK)
period_ns = 100;
- // these limits are somewhat arbitrary, but NI advertises 1 to 20MHz range so we'll use that
+ /* these limits are somewhat arbitrary, but NI advertises 1 to 20MHz range so we'll use that */
if (period_ns < min_period_ns || period_ns > max_period_ns) {
- rt_printk
+ printk
("%s: you must specify an input clock frequency between %i and %i nanosec "
- "for the phased-lock loop.\n", __FUNCTION__,
+ "for the phased-lock loop.\n", __func__,
min_period_ns, max_period_ns);
return -EINVAL;
}
@@ -5484,8 +5488,10 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned
pll_control_bits |=
MSeries_PLL_Divisor_Bits(freq_divider) |
MSeries_PLL_Multiplier_Bits(freq_multiplier);
-// rt_printk("using divider=%i, multiplier=%i for PLL. pll_control_bits = 0x%x\n", freq_divider, freq_multiplier, pll_control_bits);
-// rt_printk("clock_ns=%d\n", devpriv->clock_ns);
+
+ /* printk("using divider=%i, multiplier=%i for PLL. pll_control_bits = 0x%x\n",
+ * freq_divider, freq_multiplier, pll_control_bits); */
+ /* printk("clock_ns=%d\n", devpriv->clock_ns); */
ni_writew(pll_control_bits, M_Offset_PLL_Control);
devpriv->clock_source = source;
/* it seems to typically take a few hundred microseconds for PLL to lock */
@@ -5496,15 +5502,15 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device * dev, unsigned
udelay(1);
}
if (i == timeout) {
- rt_printk
+ printk
("%s: timed out waiting for PLL to lock to reference clock source %i with period %i ns.\n",
- __FUNCTION__, source, period_ns);
+ __func__, source, period_ns);
return -ETIMEDOUT;
}
return 3;
}
-static int ni_set_master_clock(struct comedi_device * dev, unsigned source,
+static int ni_set_master_clock(struct comedi_device *dev, unsigned source,
unsigned period_ns)
{
if (source == NI_MIO_INTERNAL_CLOCK) {
@@ -5533,9 +5539,9 @@ static int ni_set_master_clock(struct comedi_device * dev, unsigned source,
devpriv->rtsi_trig_direction_reg,
RTSI_Trig_Direction_Register);
if (period_ns == 0) {
- rt_printk
+ printk
("%s: we don't handle an unspecified clock period correctly yet, returning error.\n",
- __FUNCTION__);
+ __func__);
return -EINVAL;
} else {
devpriv->clock_ns = period_ns;
@@ -5548,7 +5554,7 @@ static int ni_set_master_clock(struct comedi_device * dev, unsigned source,
return 3;
}
-static int ni_valid_rtsi_output_source(struct comedi_device * dev, unsigned chan,
+static int ni_valid_rtsi_output_source(struct comedi_device *dev, unsigned chan,
unsigned source)
{
if (chan >= num_configurable_rtsi_channels(dev)) {
@@ -5556,9 +5562,9 @@ static int ni_valid_rtsi_output_source(struct comedi_device * dev, unsigned chan
if (source == NI_RTSI_OUTPUT_RTSI_OSC)
return 1;
else {
- rt_printk
+ printk
("%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards.\n",
- __FUNCTION__, chan,
+ __func__, chan,
old_RTSI_clock_channel);
return 0;
}
@@ -5589,7 +5595,7 @@ static int ni_valid_rtsi_output_source(struct comedi_device * dev, unsigned chan
}
}
-static int ni_set_rtsi_routing(struct comedi_device * dev, unsigned chan,
+static int ni_set_rtsi_routing(struct comedi_device *dev, unsigned chan,
unsigned source)
{
if (ni_valid_rtsi_output_source(dev, chan, source) == 0)
@@ -5610,7 +5616,7 @@ static int ni_set_rtsi_routing(struct comedi_device * dev, unsigned chan,
return 2;
}
-static unsigned ni_get_rtsi_routing(struct comedi_device * dev, unsigned chan)
+static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan)
{
if (chan < 4) {
return RTSI_Trig_Output_Source(chan,
@@ -5621,13 +5627,13 @@ static unsigned ni_get_rtsi_routing(struct comedi_device * dev, unsigned chan)
} else {
if (chan == old_RTSI_clock_channel)
return NI_RTSI_OUTPUT_RTSI_OSC;
- rt_printk("%s: bug! should never get here?\n", __FUNCTION__);
+ printk("%s: bug! should never get here?\n", __func__);
return 0;
}
}
-static int ni_rtsi_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_rtsi_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
switch (data[0]) {
@@ -5698,7 +5704,7 @@ static int ni_rtsi_insn_config(struct comedi_device * dev, struct comedi_subdevi
return 1;
}
-static int cs5529_wait_for_idle(struct comedi_device * dev)
+static int cs5529_wait_for_idle(struct comedi_device *dev)
{
unsigned short status;
const int timeout = HZ;
@@ -5714,15 +5720,15 @@ static int cs5529_wait_for_idle(struct comedi_device * dev)
return -EIO;
}
}
-//printk("looped %i times waiting for idle\n", i);
+/* printk("looped %i times waiting for idle\n", i); */
if (i == timeout) {
- rt_printk("%s: %s: timeout\n", __FILE__, __FUNCTION__);
+ printk("%s: %s: timeout\n", __FILE__, __func__);
return -ETIME;
}
return 0;
}
-static void cs5529_command(struct comedi_device * dev, unsigned short value)
+static void cs5529_command(struct comedi_device *dev, unsigned short value)
{
static const int timeout = 100;
int i;
@@ -5735,16 +5741,16 @@ static void cs5529_command(struct comedi_device * dev, unsigned short value)
for (i = 0; i < timeout; i++) {
if ((ni_ao_win_inw(dev, CAL_ADC_Status_67xx) & CSS_ADC_BUSY))
break;
- comedi_udelay(1);
+ udelay(1);
}
-//printk("looped %i times writing command to cs5529\n", i);
+/* printk("looped %i times writing command to cs5529\n", i); */
if (i == timeout) {
comedi_error(dev, "possible problem - never saw adc go busy?");
}
}
/* write to cs5529 register */
-static void cs5529_config_write(struct comedi_device * dev, unsigned int value,
+static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
unsigned int reg_select_bits)
{
ni_ao_win_outw(dev, ((value >> 16) & 0xff),
@@ -5759,7 +5765,7 @@ static void cs5529_config_write(struct comedi_device * dev, unsigned int value,
#ifdef NI_CS5529_DEBUG
/* read from cs5529 register */
-static unsigned int cs5529_config_read(struct comedi_device * dev,
+static unsigned int cs5529_config_read(struct comedi_device *dev,
unsigned int reg_select_bits)
{
unsigned int value;
@@ -5775,7 +5781,7 @@ static unsigned int cs5529_config_read(struct comedi_device * dev,
}
#endif
-static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data)
+static int cs5529_do_conversion(struct comedi_device *dev, unsigned short *data)
{
int retval;
unsigned short status;
@@ -5789,12 +5795,12 @@ static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data
}
status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
if (status & CSS_OSC_DETECT) {
- rt_printk
+ printk
("ni_mio_common: cs5529 conversion error, status CSS_OSC_DETECT\n");
return -EIO;
}
if (status & CSS_OVERRANGE) {
- rt_printk
+ printk
("ni_mio_common: cs5529 conversion error, overrange (ignoring)\n");
}
if (data) {
@@ -5805,8 +5811,8 @@ static int cs5529_do_conversion(struct comedi_device * dev, unsigned short *data
return 0;
}
-static int cs5529_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int cs5529_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, retval;
unsigned short sample;
@@ -5831,7 +5837,7 @@ static int cs5529_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
return insn->n;
}
-static int init_cs5529(struct comedi_device * dev)
+static int init_cs5529(struct comedi_device *dev)
{
unsigned int config_bits =
CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES;
@@ -5851,11 +5857,11 @@ static int init_cs5529(struct comedi_device * dev)
comedi_error(dev, "timeout or signal in init_cs5529()\n");
#endif
#ifdef NI_CS5529_DEBUG
- rt_printk("config: 0x%x\n", cs5529_config_read(dev,
+ printk("config: 0x%x\n", cs5529_config_read(dev,
CSCMD_CONFIG_REGISTER));
- rt_printk("gain: 0x%x\n", cs5529_config_read(dev,
+ printk("gain: 0x%x\n", cs5529_config_read(dev,
CSCMD_GAIN_REGISTER));
- rt_printk("offset: 0x%x\n", cs5529_config_read(dev,
+ printk("offset: 0x%x\n", cs5529_config_read(dev,
CSCMD_OFFSET_REGISTER));
#endif
return 0;
diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c
index d6357c25aca5..4d408d410c24 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/staging/comedi/drivers/ni_mio_cs.c
@@ -66,103 +66,103 @@ See the notes in the ni_atmio.o driver.
#define MAX_N_CALDACS 32
-static const ni_board ni_boards[] = {
- {device_id:0x010d,
- name: "DAQCard-ai-16xe-50",
- n_adchan:16,
- adbits: 16,
- ai_fifo_depth:1024,
- alwaysdither:0,
- gainlkup:ai_gain_8,
- ai_speed:5000,
- n_aochan:0,
- aobits: 0,
- ao_fifo_depth:0,
- ao_unipolar:0,
- num_p0_dio_channels:8,
- has_8255:0,
- caldac: {dac8800, dac8043},
- },
- {device_id:0x010c,
- name: "DAQCard-ai-16e-4",
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:1024,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:4000,
- n_aochan:0,
- aobits: 0,
- ao_fifo_depth:0,
- ao_unipolar:0,
- num_p0_dio_channels:8,
- has_8255:0,
- caldac: {mb88341}, /* verified */
- },
- {device_id:0x02c4,
- name: "DAQCard-6062E",
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:8192,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:2000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:2048,
- ao_range_table:&range_bipolar10,
- ao_unipolar:0,
- ao_speed:1176,
- num_p0_dio_channels:8,
- has_8255:0,
- caldac: {ad8804_debug}, /* verified */
- },
- {device_id:0x075e,
- name: "DAQCard-6024E", /* specs incorrect! */
- n_adchan:16,
- adbits: 12,
- ai_fifo_depth:1024,
- alwaysdither:0,
- gainlkup:ai_gain_16,
- ai_speed:5000,
- n_aochan:2,
- aobits: 12,
- ao_fifo_depth:0,
- ao_range_table:&range_bipolar10,
- ao_unipolar:0,
- ao_speed:1000000,
- num_p0_dio_channels:8,
- has_8255:0,
- caldac: {ad8804_debug},
- },
- {device_id:0x0245,
- name: "DAQCard-6036E", /* specs incorrect! */
- n_adchan:16,
- adbits: 16,
- ai_fifo_depth:1024,
- alwaysdither:1,
- gainlkup:ai_gain_4,
- ai_speed:5000,
- n_aochan:2,
- aobits: 16,
- ao_fifo_depth:0,
- ao_range_table:&range_bipolar10,
- ao_unipolar:0,
- ao_speed:1000000,
- num_p0_dio_channels:8,
- has_8255:0,
- caldac: {ad8804_debug},
- },
+static const struct ni_board_struct ni_boards[] = {
+ {.device_id = 0x010d,
+ .name = "DAQCard-ai-16xe-50",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 1024,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_8,
+ .ai_speed = 5000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 8,
+ .has_8255 = 0,
+ .caldac = {dac8800, dac8043},
+ },
+ {.device_id = 0x010c,
+ .name = "DAQCard-ai-16e-4",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 1024,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 4000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 8,
+ .has_8255 = 0,
+ .caldac = {mb88341}, /* verified */
+ },
+ {.device_id = 0x02c4,
+ .name = "DAQCard-6062E",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 8192,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 2000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 2048,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_speed = 1176,
+ .num_p0_dio_channels = 8,
+ .has_8255 = 0,
+ .caldac = {ad8804_debug}, /* verified */
+ },
+ {.device_id = 0x075e,
+ .name = "DAQCard-6024E", /* specs incorrect! */
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 1024,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 5000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_speed = 1000000,
+ .num_p0_dio_channels = 8,
+ .has_8255 = 0,
+ .caldac = {ad8804_debug},
+ },
+ {.device_id = 0x0245,
+ .name = "DAQCard-6036E", /* specs incorrect! */
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 1024,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 0,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_speed = 1000000,
+ .num_p0_dio_channels = 8,
+ .has_8255 = 0,
+ .caldac = {ad8804_debug},
+ },
#if 0
- {device_id:0x0000, /* unknown */
- name: "DAQCard-6715",
- n_adchan:0,
- n_aochan:8,
- aobits: 12,
- ao_671x: 8192,
- num_p0_dio_channels:8,
- caldac: {mb88341, mb88341},
- },
+ {.device_id = 0x0000, /* unknown */
+ .name = "DAQCard-6715",
+ .n_adchan = 0,
+ .n_aochan = 8,
+ .aobits = 12,
+ .ao_671x = 8192,
+ .num_p0_dio_channels = 8,
+ .caldac = {mb88341, mb88341},
+ },
#endif
/* N.B. Update ni_mio_cs_ids[] when entries added above. */
};
@@ -183,11 +183,11 @@ struct ni_private {
/* How we access registers */
-#define ni_writel(a,b) (outl((a),(b)+dev->iobase))
+#define ni_writel(a, b) (outl((a), (b)+dev->iobase))
#define ni_readl(a) (inl((a)+dev->iobase))
-#define ni_writew(a,b) (outw((a),(b)+dev->iobase))
+#define ni_writew(a, b) (outw((a), (b)+dev->iobase))
#define ni_readw(a) (inw((a)+dev->iobase))
-#define ni_writeb(a,b) (outb((a),(b)+dev->iobase))
+#define ni_writeb(a, b) (outb((a), (b)+dev->iobase))
#define ni_readb(a) (inb((a)+dev->iobase))
/* How we access windowed registers */
@@ -196,60 +196,60 @@ struct ni_private {
* read/written directly in the I/O space of the board. The
* DAQCard devices map the low 8 STC registers to iobase+addr*2. */
-static void mio_cs_win_out(struct comedi_device * dev, uint16_t data, int addr)
+static void mio_cs_win_out(struct comedi_device *dev, uint16_t data, int addr)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
if (addr < 8) {
ni_writew(data, addr * 2);
} else {
ni_writew(addr, Window_Address);
ni_writew(data, Window_Data);
}
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
-static uint16_t mio_cs_win_in(struct comedi_device * dev, int addr)
+static uint16_t mio_cs_win_in(struct comedi_device *dev, int addr)
{
unsigned long flags;
uint16_t ret;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
if (addr < 8) {
ret = ni_readw(addr * 2);
} else {
ni_writew(addr, Window_Address);
ret = ni_readw(Window_Data);
}
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
return ret;
}
-static int mio_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int mio_cs_detach(struct comedi_device * dev);
+static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int mio_cs_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni_mio_cs = {
- driver_name:"ni_mio_cs",
- module:THIS_MODULE,
- attach:mio_cs_attach,
- detach:mio_cs_detach,
+ .driver_name = "ni_mio_cs",
+ .module = THIS_MODULE,
+ .attach = mio_cs_attach,
+ .detach = mio_cs_detach,
};
#include "ni_mio_common.c"
-static int ni_getboardtype(struct comedi_device * dev, struct pcmcia_device *link);
+static int ni_getboardtype(struct comedi_device *dev, struct pcmcia_device *link);
/* clean up allocated resources */
/* called when driver is removed */
-static int mio_cs_detach(struct comedi_device * dev)
+static int mio_cs_detach(struct comedi_device *dev)
{
mio_common_detach(dev);
/* PCMCIA layer frees the IO region */
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
return 0;
@@ -344,7 +344,7 @@ static void mio_cs_config(struct pcmcia_device *link)
manfid = le16_to_cpu(buf[0]);
prodid = le16_to_cpu(buf[1]);
}
- //printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid);
+ /* printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid); */
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
tuple.Attributes = 0;
@@ -381,7 +381,7 @@ static void mio_cs_config(struct pcmcia_device *link)
for (base = 0x000; base < 0x400; base += 0x20) {
link->io.BasePort1 = base;
ret = pcmcia_request_io(link, &link->io);
- //printk("RequestIO 0x%02x\n",ret);
+ /* printk("RequestIO 0x%02x\n",ret); */
if (!ret)
break;
}
@@ -393,17 +393,17 @@ static void mio_cs_config(struct pcmcia_device *link)
if (ret) {
printk("pcmcia_request_irq() returned error: %i\n", ret);
}
- //printk("RequestIRQ 0x%02x\n",ret);
+ /* printk("RequestIRQ 0x%02x\n",ret); */
link->conf.ConfigIndex = 1;
ret = pcmcia_request_configuration(link, &link->conf);
- //printk("RequestConfiguration %d\n",ret);
+ /* printk("RequestConfiguration %d\n",ret); */
link->dev_node = &dev_node;
}
-static int mio_cs_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pcmcia_device *link;
unsigned int irq;
@@ -446,29 +446,33 @@ static int mio_cs_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk(" %s", boardtype.name);
dev->board_name = boardtype.name;
- if ((ret = comedi_request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS,
- "ni_mio_cs", dev)) < 0) {
+ ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS,
+ "ni_mio_cs", dev);
+ if (ret < 0) {
printk(" irq not available\n");
return -EINVAL;
}
dev->irq = irq;
/* allocate private area */
- if ((ret = ni_alloc_private(dev)) < 0)
+ ret = ni_alloc_private(dev);
+ if (ret < 0)
return ret;
+
devpriv->stc_writew = &mio_cs_win_out;
devpriv->stc_readw = &mio_cs_win_in;
devpriv->stc_writel = &win_out2;
devpriv->stc_readl = &win_in2;
- if ((ret = ni_E_init(dev, it)) < 0) {
+ ret = ni_E_init(dev, it);
+
+ if (ret < 0)
return ret;
- }
return 0;
}
-static int get_prodid(struct comedi_device * dev, struct pcmcia_device *link)
+static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
{
tuple_t tuple;
u_short buf[128];
@@ -487,7 +491,7 @@ static int get_prodid(struct comedi_device * dev, struct pcmcia_device *link)
return prodid;
}
-static int ni_getboardtype(struct comedi_device * dev, struct pcmcia_device *link)
+static int ni_getboardtype(struct comedi_device *dev, struct pcmcia_device *link)
{
int id;
int i;
diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c
index 87def2cc9a29..6b86a39aac5e 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -66,9 +66,10 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org
*/
#define USE_DMA
-//#define DEBUG 1
-//#define DEBUG_FLAGS
+/* #define DEBUG 1 */
+/* #define DEBUG_FLAGS */
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include "mite.h"
@@ -117,9 +118,9 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org
#define Waited (1<<5)
#define PrimaryTC (1<<6)
#define SecondaryTC (1<<7)
- //#define SerialRose
- //#define ReqRose
- //#define Paused
+ /* #define SerialRose */
+ /* #define ReqRose */
+ /* #define Paused */
#define Group_1_First_Clear 6 /* W */
#define Group_2_First_Clear 7 /* W */
@@ -206,7 +207,7 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org
#define DMA_Line_Control_Group1 76
#define DMA_Line_Control_Group2 108
-// channel zero is none
+/* channel zero is none */
static inline unsigned primary_DMAChannel_bits(unsigned channel)
{
return channel & 0x3;
@@ -287,15 +288,15 @@ enum FPGA_Control_Bits {
#define IntEn (TransferReady|CountExpired|Waited|PrimaryTC|SecondaryTC)
#endif
-static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int nidio_detach(struct comedi_device * dev);
-static int ni_pcidio_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int nidio_detach(struct comedi_device *dev);
+static int ni_pcidio_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static struct comedi_driver driver_pcidio = {
- driver_name:"ni_pcidio",
- module:THIS_MODULE,
- attach:nidio_attach,
- detach:nidio_detach,
+ .driver_name = "ni_pcidio",
+ .module = THIS_MODULE,
+ .attach = nidio_attach,
+ .detach = nidio_detach,
};
struct nidio_board {
@@ -309,65 +310,65 @@ struct nidio_board {
static const struct nidio_board nidio_boards[] = {
{
- dev_id: 0x1150,
- name: "pci-dio-32hs",
- n_8255: 0,
- is_diodaq:1,
+ .dev_id = 0x1150,
+ .name = "pci-dio-32hs",
+ .n_8255 = 0,
+ .is_diodaq = 1,
},
{
- dev_id: 0x1320,
- name: "pxi-6533",
- n_8255: 0,
- is_diodaq:1,
+ .dev_id = 0x1320,
+ .name = "pxi-6533",
+ .n_8255 = 0,
+ .is_diodaq = 1,
},
{
- dev_id: 0x12b0,
- name: "pci-6534",
- n_8255: 0,
- is_diodaq:1,
- uses_firmware:1,
+ .dev_id = 0x12b0,
+ .name = "pci-6534",
+ .n_8255 = 0,
+ .is_diodaq = 1,
+ .uses_firmware = 1,
},
{
- dev_id: 0x0160,
- name: "pci-dio-96",
- n_8255: 4,
- is_diodaq:0,
+ .dev_id = 0x0160,
+ .name = "pci-dio-96",
+ .n_8255 = 4,
+ .is_diodaq = 0,
},
{
- dev_id: 0x1630,
- name: "pci-dio-96b",
- n_8255: 4,
- is_diodaq:0,
+ .dev_id = 0x1630,
+ .name = "pci-dio-96b",
+ .n_8255 = 4,
+ .is_diodaq = 0,
},
{
- dev_id: 0x13c0,
- name: "pxi-6508",
- n_8255: 4,
- is_diodaq:0,
+ .dev_id = 0x13c0,
+ .name = "pxi-6508",
+ .n_8255 = 4,
+ .is_diodaq = 0,
},
{
- dev_id: 0x0400,
- name: "pci-6503",
- n_8255: 1,
- is_diodaq:0,
+ .dev_id = 0x0400,
+ .name = "pci-6503",
+ .n_8255 = 1,
+ .is_diodaq = 0,
},
{
- dev_id: 0x1250,
- name: "pci-6503b",
- n_8255: 1,
- is_diodaq:0,
+ .dev_id = 0x1250,
+ .name = "pci-6503b",
+ .n_8255 = 1,
+ .is_diodaq = 0,
},
{
- dev_id: 0x17d0,
- name: "pci-6503x",
- n_8255: 1,
- is_diodaq:0,
+ .dev_id = 0x17d0,
+ .name = "pci-6503x",
+ .n_8255 = 1,
+ .is_diodaq = 0,
},
{
- dev_id: 0x1800,
- name: "pxi-6503",
- n_8255: 1,
- is_diodaq:0,
+ .dev_id = 0x1800,
+ .name = "pxi-6503",
+ .n_8255 = 1,
+ .is_diodaq = 0,
},
};
@@ -401,14 +402,14 @@ struct nidio96_private {
};
#define devpriv ((struct nidio96_private *)dev->private)
-static int ni_pcidio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int ni_pcidio_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_pcidio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int ni_pcidio_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum);
-static int nidio_find_device(struct comedi_device * dev, int bus, int slot);
+static int nidio_find_device(struct comedi_device *dev, int bus, int slot);
static int ni_pcidio_ns_to_timer(int *nanosec, int round_mode);
-static int setup_mite_dma(struct comedi_device * dev, struct comedi_subdevice * s);
+static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s);
#ifdef DEBUG_FLAGS
static void ni_pcidio_print_flags(unsigned int flags);
@@ -418,18 +419,17 @@ static void ni_pcidio_print_status(unsigned int status);
#define ni_pcidio_print_status(x)
#endif
-static int ni_pcidio_request_di_mite_channel(struct comedi_device * dev)
+static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
BUG_ON(devpriv->di_mite_chan);
devpriv->di_mite_chan =
mite_request_channel_in_range(devpriv->mite,
devpriv->di_mite_ring, 1, 2);
if (devpriv->di_mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock,
- flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
comedi_error(dev, "failed to reserve mite dma channel.");
return -EBUSY;
}
@@ -437,15 +437,15 @@ static int ni_pcidio_request_di_mite_channel(struct comedi_device * dev)
secondary_DMAChannel_bits(devpriv->di_mite_chan->channel),
devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
mmiowb();
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
}
-static void ni_pcidio_release_di_mite_channel(struct comedi_device * dev)
+static void ni_pcidio_release_di_mite_channel(struct comedi_device *dev)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->di_mite_chan) {
mite_dma_disarm(devpriv->di_mite_chan);
mite_dma_reset(devpriv->di_mite_chan);
@@ -456,7 +456,7 @@ static void ni_pcidio_release_di_mite_channel(struct comedi_device * dev)
devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
mmiowb();
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
}
static int nidio96_8255_cb(int dir, int port, int data, unsigned long iobase)
@@ -469,7 +469,7 @@ static int nidio96_8255_cb(int dir, int port, int data, unsigned long iobase)
}
}
-void ni_pcidio_event(struct comedi_device * dev, struct comedi_subdevice * s)
+void ni_pcidio_event(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (s->async->
events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
@@ -479,14 +479,14 @@ void ni_pcidio_event(struct comedi_device * dev, struct comedi_subdevice * s)
comedi_event(dev, s);
}
-static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t nidio_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices;
struct comedi_async *async = s->async;
struct mite_struct *mite = devpriv->mite;
- //int i, j;
+ /* int i, j; */
long int AuxData = 0;
short data1 = 0;
short data2 = 0;
@@ -496,9 +496,9 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
unsigned int m_status = 0;
unsigned long irq_flags;
- //interrupcions parasites
+ /* interrupcions parasites */
if (dev->attached == 0) {
- // assume it's from another card
+ /* assume it's from another card */
return IRQ_NONE;
}
@@ -511,17 +511,17 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
ni_pcidio_print_flags(flags);
ni_pcidio_print_status(status);
- //printk("buf[0]=%08x\n",*(unsigned int *)async->prealloc_buf);
- //printk("buf[4096]=%08x\n",*(unsigned int *)(async->prealloc_buf+4096));
+ /* printk("buf[0]=%08x\n",*(unsigned int *)async->prealloc_buf); */
+ /* printk("buf[4096]=%08x\n",*(unsigned int *)(async->prealloc_buf+4096)); */
- comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, irq_flags);
+ spin_lock_irqsave(&devpriv->mite_channel_lock, irq_flags);
if (devpriv->di_mite_chan)
m_status = mite_get_status(devpriv->di_mite_chan);
#ifdef MITE_DEBUG
mite_print_chsr(m_status);
#endif
- //printk("mite_bytes_transferred: %d\n",mite_bytes_transferred(mite,DI_DMA_CHAN));
- //mite_dump_regs(mite);
+ /* printk("mite_bytes_transferred: %d\n",mite_bytes_transferred(mite,DI_DMA_CHAN)); */
+ /* mite_dump_regs(mite); */
if (m_status & CHSR_INT) {
if (m_status & CHSR_LINKC) {
writel(CHOR_CLRLC,
@@ -537,7 +537,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
disable_irq(dev->irq);
}
}
- comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, irq_flags);
+ spin_unlock_irqrestore(&devpriv->mite_channel_lock, irq_flags);
while (status & DataLeft) {
work++;
@@ -552,7 +552,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
flags &= IntEn;
if (flags & TransferReady) {
- //DPRINTK("TransferReady\n");
+ /* DPRINTK("TransferReady\n"); */
while (flags & TransferReady) {
work++;
if (work > 100) {
@@ -569,14 +569,14 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
data2 = (AuxData & 0xffff0000) >> 16;
comedi_buf_put(async, data1);
comedi_buf_put(async, data2);
- //DPRINTK("read:%d, %d\n",data1,data2);
+ /* DPRINTK("read:%d, %d\n",data1,data2); */
flags = readb(devpriv->mite->daq_io_addr +
Group_1_Flags);
}
- //DPRINTK("buf_int_count: %d\n",async->buf_int_count);
- //DPRINTK("1) IntEn=%d,flags=%d,status=%d\n",IntEn,flags,status);
- //ni_pcidio_print_flags(flags);
- //ni_pcidio_print_status(status);
+ /* DPRINTK("buf_int_count: %d\n",async->buf_int_count); */
+ /* DPRINTK("1) IntEn=%d,flags=%d,status=%d\n",IntEn,flags,status); */
+ /* ni_pcidio_print_flags(flags); */
+ /* ni_pcidio_print_status(status); */
async->events |= COMEDI_CB_BLOCK;
}
@@ -621,10 +621,10 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG)
flags = readb(devpriv->mite->daq_io_addr + Group_1_Flags);
status = readb(devpriv->mite->daq_io_addr +
Interrupt_And_Window_Status);
- //DPRINTK("loop end: IntEn=0x%02x,flags=0x%02x,status=0x%02x\n",
- // IntEn,flags,status);
- //ni_pcidio_print_flags(flags);
- //ni_pcidio_print_status(status);
+ /* DPRINTK("loop end: IntEn=0x%02x,flags=0x%02x,status=0x%02x\n", */
+ /* IntEn,flags,status); */
+ /* ni_pcidio_print_flags(flags); */
+ /* ni_pcidio_print_status(status); */
}
out:
@@ -963,7 +963,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
/* clear and enable interrupts */
writeb(0xff, devpriv->mite->daq_io_addr + Group_1_First_Clear);
- //writeb(ClearExpired,devpriv->mite->daq_io_addr+Group_1_Second_Clear);
+ /* writeb(ClearExpired,devpriv->mite->daq_io_addr+Group_1_Second_Clear); */
writeb(IntEn, devpriv->mite->daq_io_addr + Interrupt_Control);
writeb(0x03,
@@ -971,7 +971,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
if (cmd->stop_src == TRIG_NONE) {
devpriv->OpModeBits = DataLatching(0) | RunMode(7);
- } else { // TRIG_TIMER
+ } else { /* TRIG_TIMER */
devpriv->OpModeBits = Numbered | RunMode(7);
}
if (cmd->start_src == TRIG_NOW) {
@@ -1235,8 +1235,8 @@ static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it
devpriv->mite->daq_io_addr +
Master_DMA_And_Interrupt_Control);
- ret = comedi_request_irq(irq, nidio_interrupt, IRQF_SHARED,
- "ni_pcidio", dev);
+ ret = request_irq(irq, nidio_interrupt, IRQF_SHARED,
+ "ni_pcidio", dev);
if (ret < 0) {
printk(" irq not available");
}
@@ -1259,7 +1259,7 @@ static int nidio_detach(struct comedi_device * dev)
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->di_mite_ring) {
diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c
index 3a2aba7c8dd3..1d04b75dec22 100644
--- a/drivers/staging/comedi/drivers/ni_pcimio.c
+++ b/drivers/staging/comedi/drivers/ni_pcimio.c
@@ -101,7 +101,7 @@ Bugs:
need to slow down DAC loading. I don't trust NI's claim that
two writes to the PCI bus slows IO enough. I would prefer to
- use comedi_udelay(). Timing specs: (clock)
+ use udelay(). Timing specs: (clock)
AD8522 30ns
DAC8043 120ns
DAC8800 60ns
@@ -117,7 +117,7 @@ Bugs:
#include "ni_stc.h"
#include "mite.h"
-//#define PCI_DEBUG
+/* #define PCI_DEBUG */
#define PCIDMA
@@ -216,9 +216,9 @@ static const struct comedi_lrange range_ni_M_622x_ao = { 1, {
}
};
-static const ni_board ni_boards[] = {
+static const struct ni_board_struct ni_boards[] = {
{
- .device_id = 0x0162, // NI also says 0x1620. typo?
+ .device_id = 0x0162, /* NI also says 0x1620. typo? */
.name = "pci-mio-16xe-50",
.n_adchan = 16,
.adbits = 16,
@@ -238,7 +238,7 @@ static const ni_board ni_boards[] = {
},
{
.device_id = 0x1170,
- .name = "pci-mio-16xe-10", // aka pci-6030E
+ .name = "pci-mio-16xe-10", /* aka pci-6030E */
.n_adchan = 16,
.adbits = 16,
.ai_fifo_depth = 512,
@@ -320,7 +320,7 @@ static const ni_board ni_boards[] = {
.ai_fifo_depth = 512,
.alwaysdither = 0,
.gainlkup = ai_gain_16,
- /* Note: there have been reported problems with full speed
+ /* .Note = there have been reported problems with full speed
* on this board */
.ai_speed = 2000,
.n_aochan = 2,
@@ -330,7 +330,7 @@ static const ni_board ni_boards[] = {
.ao_unipolar = 1,
.ao_speed = 1000,
.num_p0_dio_channels = 8,
- .caldac = {ad8804_debug}, // doc says mb88341
+ .caldac = {ad8804_debug}, /* doc says mb88341 */
.has_8255 = 0,
},
{
@@ -846,7 +846,7 @@ static const ni_board ni_boards[] = {
.n_adchan = 16,
.adbits = 16,
.ai_fifo_depth = 512,
- //FIXME: guess
+ /* .FIXME = guess */
.gainlkup = ai_gain_622x,
.ai_speed = 4000,
.n_aochan = 0,
@@ -1207,28 +1207,29 @@ static const ni_board ni_boards[] = {
#define n_pcimio_boards ((sizeof(ni_boards)/sizeof(ni_boards[0])))
-static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcimio_detach(struct comedi_device * dev);
+static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcimio_detach(struct comedi_device *dev);
static struct comedi_driver driver_pcimio = {
- driver_name: DRV_NAME,
- module:THIS_MODULE,
- attach:pcimio_attach,
- detach:pcimio_detach,
+ .driver_name = DRV_NAME,
+ .module = THIS_MODULE,
+ .attach = pcimio_attach,
+ .detach = pcimio_detach,
};
COMEDI_PCI_INITCLEANUP(driver_pcimio, ni_pci_table)
-typedef struct {
-NI_PRIVATE_COMMON} ni_private;
-#define devpriv ((ni_private *)dev->private)
+struct ni_private {
+ NI_PRIVATE_COMMON
+};
+#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
-#define ni_writel(a,b) (writel((a), devpriv->mite->daq_io_addr + (b)))
+#define ni_writel(a, b) (writel((a), devpriv->mite->daq_io_addr + (b)))
#define ni_readl(a) (readl(devpriv->mite->daq_io_addr + (a)))
-#define ni_writew(a,b) (writew((a), devpriv->mite->daq_io_addr + (b)))
+#define ni_writew(a, b) (writew((a), devpriv->mite->daq_io_addr + (b)))
#define ni_readw(a) (readw(devpriv->mite->daq_io_addr + (a)))
-#define ni_writeb(a,b) (writeb((a), devpriv->mite->daq_io_addr + (b)))
+#define ni_writeb(a, b) (writeb((a), devpriv->mite->daq_io_addr + (b)))
#define ni_readb(a) (readb(devpriv->mite->daq_io_addr + (a)))
/* How we access STC registers */
@@ -1241,30 +1242,30 @@ NI_PRIVATE_COMMON} ni_private;
/* However, the 611x boards still aren't working, so I'm disabling
* non-windowed STC access temporarily */
-static void e_series_win_out(struct comedi_device * dev, uint16_t data, int reg)
+static void e_series_win_out(struct comedi_device *dev, uint16_t data, int reg)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
ni_writew(reg, Window_Address);
ni_writew(data, Window_Data);
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
-static uint16_t e_series_win_in(struct comedi_device * dev, int reg)
+static uint16_t e_series_win_in(struct comedi_device *dev, int reg)
{
unsigned long flags;
uint16_t ret;
- comedi_spin_lock_irqsave(&devpriv->window_lock, flags);
+ spin_lock_irqsave(&devpriv->window_lock, flags);
ni_writew(reg, Window_Address);
ret = ni_readw(Window_Data);
- comedi_spin_unlock_irqrestore(&devpriv->window_lock, flags);
+ spin_unlock_irqrestore(&devpriv->window_lock, flags);
return ret;
}
-static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int reg)
+static void m_series_stc_writew(struct comedi_device *dev, uint16_t data, int reg)
{
unsigned offset;
switch (reg) {
@@ -1293,12 +1294,12 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r
offset = M_Offset_AI_Personal;
break;
case AI_SI2_Load_A_Register:
- // this is actually a 32 bit register on m series boards
+ /* this is actually a 32 bit register on m series boards */
ni_writel(data, M_Offset_AI_SI2_Load_A);
return;
break;
case AI_SI2_Load_B_Register:
- // this is actually a 32 bit register on m series boards
+ /* this is actually a 32 bit register on m series boards */
ni_writel(data, M_Offset_AI_SI2_Load_B);
return;
break;
@@ -1348,9 +1349,9 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r
offset = M_Offset_AO_FIFO_Clear;
break;
case DIO_Control_Register:
- rt_printk
+ printk
("%s: FIXME: register 0x%x does not map cleanly on to m-series boards.\n",
- __FUNCTION__, reg);
+ __func__, reg);
return;
break;
case G_Autoincrement_Register(0):
@@ -1410,8 +1411,8 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r
/* FIXME: DIO_Output_Register (16 bit reg) is replaced by M_Offset_Static_Digital_Output (32 bit)
and M_Offset_SCXI_Serial_Data_Out (8 bit) */
default:
- rt_printk("%s: bug! unhandled register=0x%x in switch.\n",
- __FUNCTION__, reg);
+ printk("%s: bug! unhandled register=0x%x in switch.\n",
+ __func__, reg);
BUG();
return;
break;
@@ -1419,7 +1420,7 @@ static void m_series_stc_writew(struct comedi_device * dev, uint16_t data, int r
ni_writew(data, offset);
}
-static uint16_t m_series_stc_readw(struct comedi_device * dev, int reg)
+static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg)
{
unsigned offset;
switch (reg) {
@@ -1445,8 +1446,8 @@ static uint16_t m_series_stc_readw(struct comedi_device * dev, int reg)
offset = M_Offset_G01_Status;
break;
default:
- rt_printk("%s: bug! unhandled register=0x%x in switch.\n",
- __FUNCTION__, reg);
+ printk("%s: bug! unhandled register=0x%x in switch.\n",
+ __func__, reg);
BUG();
return 0;
break;
@@ -1454,7 +1455,7 @@ static uint16_t m_series_stc_readw(struct comedi_device * dev, int reg)
return ni_readw(offset);
}
-static void m_series_stc_writel(struct comedi_device * dev, uint32_t data, int reg)
+static void m_series_stc_writel(struct comedi_device *dev, uint32_t data, int reg)
{
unsigned offset;
switch (reg) {
@@ -1486,8 +1487,8 @@ static void m_series_stc_writel(struct comedi_device * dev, uint32_t data, int r
offset = M_Offset_G1_Load_B;
break;
default:
- rt_printk("%s: bug! unhandled register=0x%x in switch.\n",
- __FUNCTION__, reg);
+ printk("%s: bug! unhandled register=0x%x in switch.\n",
+ __func__, reg);
BUG();
return;
break;
@@ -1495,7 +1496,7 @@ static void m_series_stc_writel(struct comedi_device * dev, uint32_t data, int r
ni_writel(data, offset);
}
-static uint32_t m_series_stc_readl(struct comedi_device * dev, int reg)
+static uint32_t m_series_stc_readl(struct comedi_device *dev, int reg)
{
unsigned offset;
switch (reg) {
@@ -1512,8 +1513,8 @@ static uint32_t m_series_stc_readl(struct comedi_device * dev, int reg)
offset = M_Offset_G1_Save;
break;
default:
- rt_printk("%s: bug! unhandled register=0x%x in switch.\n",
- __FUNCTION__, reg);
+ printk("%s: bug! unhandled register=0x%x in switch.\n",
+ __func__, reg);
BUG();
return 0;
break;
@@ -1528,19 +1529,19 @@ static uint32_t m_series_stc_readl(struct comedi_device * dev, int reg)
#include "ni_mio_common.c"
-static int pcimio_find_device(struct comedi_device * dev, int bus, int slot);
-static int pcimio_ai_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_find_device(struct comedi_device *dev, int bus, int slot);
+static int pcimio_ai_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size);
-static int pcimio_ao_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_ao_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size);
-static int pcimio_gpct0_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_gpct0_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size);
-static int pcimio_gpct1_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_gpct1_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size);
-static int pcimio_dio_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_dio_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size);
-static void m_series_init_eeprom_buffer(struct comedi_device * dev)
+static void m_series_init_eeprom_buffer(struct comedi_device *dev)
{
static const int Start_Cal_EEPROM = 0x400;
static const unsigned window_size = 10;
@@ -1577,19 +1578,19 @@ static void m_series_init_eeprom_buffer(struct comedi_device * dev)
writel(0x0, devpriv->mite->mite_io_addr + 0x30);
}
-static void init_6143(struct comedi_device * dev)
+static void init_6143(struct comedi_device *dev)
{
- // Disable interrupts
+ /* Disable interrupts */
devpriv->stc_writew(dev, 0, Interrupt_Control_Register);
- // Initialise 6143 AI specific bits
- ni_writeb(0x00, Magic_6143); // Set G0,G1 DMA mode to E series version
- ni_writeb(0x80, PipelineDelay_6143); // Set EOCMode, ADCMode and pipelinedelay
- ni_writeb(0x00, EOC_Set_6143); // Set EOC Delay
+ /* Initialise 6143 AI specific bits */
+ ni_writeb(0x00, Magic_6143); /* Set G0,G1 DMA mode to E series version */
+ ni_writeb(0x80, PipelineDelay_6143); /* Set EOCMode, ADCMode and pipelinedelay */
+ ni_writeb(0x00, EOC_Set_6143); /* Set EOC Delay */
- ni_writel(boardtype.ai_fifo_depth / 2, AIFIFO_Flag_6143); // Set the FIFO half full level
+ ni_writel(boardtype.ai_fifo_depth / 2, AIFIFO_Flag_6143); /* Set the FIFO half full level */
- // Strobe Relay disable bit
+ /* Strobe Relay disable bit */
devpriv->ai_calib_source_enabled = 0;
ni_writew(devpriv->ai_calib_source | Calibration_Channel_6143_RelayOff,
Calibration_Channel_6143);
@@ -1597,11 +1598,11 @@ static void init_6143(struct comedi_device * dev)
}
/* cleans up allocated resources */
-static int pcimio_detach(struct comedi_device * dev)
+static int pcimio_detach(struct comedi_device *dev)
{
mio_common_detach(dev);
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
if (dev->private) {
mite_free_ring(devpriv->ai_mite_ring);
@@ -1616,7 +1617,7 @@ static int pcimio_detach(struct comedi_device * dev)
return 0;
}
-static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
@@ -1678,9 +1679,9 @@ static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk(" unknown irq (bad)\n");
} else {
printk(" ( irq = %u )", dev->irq);
- if ((ret = comedi_request_irq(dev->irq, ni_E_interrupt,
- NI_E_IRQ_FLAGS, DRV_NAME,
- dev)) < 0) {
+ ret = request_irq(dev->irq, ni_E_interrupt, NI_E_IRQ_FLAGS,
+ DRV_NAME, dev);
+ if (ret < 0) {
printk(" irq not available\n");
dev->irq = 0;
}
@@ -1699,7 +1700,7 @@ static int pcimio_attach(struct comedi_device * dev, struct comedi_devconfig * i
return ret;
}
-static int pcimio_find_device(struct comedi_device * dev, int bus, int slot)
+static int pcimio_find_device(struct comedi_device *dev, int bus, int slot)
{
struct mite_struct *mite;
int i;
@@ -1727,7 +1728,7 @@ static int pcimio_find_device(struct comedi_device * dev, int bus, int slot)
return -EIO;
}
-static int pcimio_ai_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_ai_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
int ret;
@@ -1739,7 +1740,7 @@ static int pcimio_ai_change(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pcimio_ao_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_ao_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
int ret;
@@ -1751,7 +1752,7 @@ static int pcimio_ao_change(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pcimio_gpct0_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_gpct0_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
int ret;
@@ -1763,7 +1764,7 @@ static int pcimio_gpct0_change(struct comedi_device * dev, struct comedi_subdevi
return 0;
}
-static int pcimio_gpct1_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_gpct1_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
int ret;
@@ -1775,7 +1776,7 @@ static int pcimio_gpct1_change(struct comedi_device * dev, struct comedi_subdevi
return 0;
}
-static int pcimio_dio_change(struct comedi_device * dev, struct comedi_subdevice * s,
+static int pcimio_dio_change(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
int ret;
diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
index 1ebf521ab773..fcaedb346c44 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -262,7 +262,7 @@ enum Joint_Status_2_Bits {
#define AO_Trigger_Once _bit0
#define AO_Mode_2_Register 39
-#define AO_FIFO_Mode_Mask ( 0x3 << 14 )
+#define AO_FIFO_Mode_Mask (0x3 << 14)
enum AO_FIFO_Mode_Bits {
AO_FIFO_Mode_HF_to_F = (3 << 14),
AO_FIFO_Mode_F = (2 << 14),
@@ -318,7 +318,7 @@ enum Clock_and_FOUT_bits {
};
static inline unsigned FOUT_Divider(unsigned divider)
{
- return (divider & FOUT_Divider_mask);
+ return divider & FOUT_Divider_mask;
}
#define IO_Bidirection_Pin_Register 57
@@ -339,7 +339,7 @@ static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries)
max_channel = 6;
}
if (channel > max_channel) {
- rt_printk("%s: bug, invalid RTSI_channel=%i\n", __FUNCTION__,
+ printk("%s: bug, invalid RTSI_channel=%i\n", __func__,
channel);
return 0;
}
@@ -521,13 +521,13 @@ enum AO_Personal_Bits {
AO_FIFO_Flags_Polarity = 1 << 11, /* M Series: reserved */
AO_TMRDACWR_Pulse_Width = 1 << 12,
AO_Fast_CPU = 1 << 13, /* M Series: reserved */
- AO_Number_Of_DAC_Packages = 1 << 14, // 1 for "single" mode, 0 for "dual"
- AO_Multiple_DACS_Per_Package = 1 << 15 // m-series only
+ AO_Number_Of_DAC_Packages = 1 << 14, /* 1 for "single" mode, 0 for "dual" */
+ AO_Multiple_DACS_Per_Package = 1 << 15 /* m-series only */
};
#define RTSI_Trig_A_Output_Register 79
#define RTSI_Trig_B_Output_Register 80
enum RTSI_Trig_B_Output_Bits {
- RTSI_Sub_Selection_1_Bit = 0x8000 // not for m-series
+ RTSI_Sub_Selection_1_Bit = 0x8000 /* not for m-series */
};
static inline unsigned RTSI_Trig_Output_Bits(unsigned rtsi_channel,
unsigned source)
@@ -539,7 +539,7 @@ static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel)
return 0xf << ((rtsi_channel % 4) * 4);
};
-// inverse to RTSI_Trig_Output_Bits()
+/* inverse to RTSI_Trig_Output_Bits() */
static inline unsigned RTSI_Trig_Output_Source(unsigned rtsi_channel,
unsigned bits)
{
@@ -759,7 +759,7 @@ enum Configuration_Memory_High_Bits {
};
static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel)
{
- return (channel & 0x3f);
+ return channel & 0x3f;
}
#define ADC_FIFO_Data_Register 0x1c
@@ -920,42 +920,42 @@ enum ni_reg_type {
static const struct comedi_lrange range_ni_E_ao_ext;
enum m_series_register_offsets {
- M_Offset_CDIO_DMA_Select = 0x7, // write
- M_Offset_SCXI_Status = 0x7, // read
- M_Offset_AI_AO_Select = 0x9, // write, same offset as e-series
- M_Offset_SCXI_Serial_Data_In = 0x9, // read
- M_Offset_G0_G1_Select = 0xb, // write, same offset as e-series
+ M_Offset_CDIO_DMA_Select = 0x7, /* write */
+ M_Offset_SCXI_Status = 0x7, /* read */
+ M_Offset_AI_AO_Select = 0x9, /* write, same offset as e-series */
+ M_Offset_SCXI_Serial_Data_In = 0x9, /* read */
+ M_Offset_G0_G1_Select = 0xb, /* write, same offset as e-series */
M_Offset_Misc_Command = 0xf,
M_Offset_SCXI_Serial_Data_Out = 0x11,
M_Offset_SCXI_Control = 0x13,
M_Offset_SCXI_Output_Enable = 0x15,
M_Offset_AI_FIFO_Data = 0x1c,
- M_Offset_Static_Digital_Output = 0x24, // write
- M_Offset_Static_Digital_Input = 0x24, // read
+ M_Offset_Static_Digital_Output = 0x24, /* write */
+ M_Offset_Static_Digital_Input = 0x24, /* read */
M_Offset_DIO_Direction = 0x28,
M_Offset_Cal_PWM = 0x40,
M_Offset_AI_Config_FIFO_Data = 0x5e,
- M_Offset_Interrupt_C_Enable = 0x88, // write
- M_Offset_Interrupt_C_Status = 0x88, // read
+ M_Offset_Interrupt_C_Enable = 0x88, /* write */
+ M_Offset_Interrupt_C_Status = 0x88, /* read */
M_Offset_Analog_Trigger_Control = 0x8c,
M_Offset_AO_Serial_Interrupt_Enable = 0xa0,
- M_Offset_AO_Serial_Interrupt_Ack = 0xa1, // write
- M_Offset_AO_Serial_Interrupt_Status = 0xa1, // read
+ M_Offset_AO_Serial_Interrupt_Ack = 0xa1, /* write */
+ M_Offset_AO_Serial_Interrupt_Status = 0xa1, /* read */
M_Offset_AO_Calibration = 0xa3,
M_Offset_AO_FIFO_Data = 0xa4,
M_Offset_PFI_Filter = 0xb0,
M_Offset_RTSI_Filter = 0xb4,
M_Offset_SCXI_Legacy_Compatibility = 0xbc,
- M_Offset_Interrupt_A_Ack = 0x104, // write
- M_Offset_AI_Status_1 = 0x104, // read
- M_Offset_Interrupt_B_Ack = 0x106, // write
- M_Offset_AO_Status_1 = 0x106, // read
- M_Offset_AI_Command_2 = 0x108, // write
- M_Offset_G01_Status = 0x108, // read
+ M_Offset_Interrupt_A_Ack = 0x104, /* write */
+ M_Offset_AI_Status_1 = 0x104, /* read */
+ M_Offset_Interrupt_B_Ack = 0x106, /* write */
+ M_Offset_AO_Status_1 = 0x106, /* read */
+ M_Offset_AI_Command_2 = 0x108, /* write */
+ M_Offset_G01_Status = 0x108, /* read */
M_Offset_AO_Command_2 = 0x10a,
- M_Offset_AO_Status_2 = 0x10c, // read
- M_Offset_G0_Command = 0x10c, // write
- M_Offset_G1_Command = 0x10e, // write
+ M_Offset_AO_Status_2 = 0x10c, /* read */
+ M_Offset_G0_Command = 0x10c, /* write */
+ M_Offset_G1_Command = 0x10e, /* write */
M_Offset_G0_HW_Save = 0x110,
M_Offset_G0_HW_Save_High = 0x110,
M_Offset_AI_Command_1 = 0x110,
@@ -973,17 +973,17 @@ enum m_series_register_offsets {
M_Offset_G1_Save = 0x11c,
M_Offset_G1_Save_High = 0x11c,
M_Offset_G1_Save_Low = 0x11e,
- M_Offset_AI_SI_Load_B = 0x120, // write
- M_Offset_AO_UI_Save = 0x120, // read
- M_Offset_AI_SC_Load_A = 0x124, // write
- M_Offset_AO_BC_Save = 0x124, // read
- M_Offset_AI_SC_Load_B = 0x128, // write
- M_Offset_AO_UC_Save = 0x128, //read
+ M_Offset_AI_SI_Load_B = 0x120, /* write */
+ M_Offset_AO_UI_Save = 0x120, /* read */
+ M_Offset_AI_SC_Load_A = 0x124, /* write */
+ M_Offset_AO_BC_Save = 0x124, /* read */
+ M_Offset_AI_SC_Load_B = 0x128, /* write */
+ M_Offset_AO_UC_Save = 0x128, /* read */
M_Offset_AI_SI2_Load_A = 0x12c,
M_Offset_AI_SI2_Load_B = 0x130,
M_Offset_G0_Mode = 0x134,
- M_Offset_G1_Mode = 0x136, // write
- M_Offset_Joint_Status_1 = 0x136, // read
+ M_Offset_G1_Mode = 0x136, /* write */
+ M_Offset_Joint_Status_1 = 0x136, /* read */
M_Offset_G0_Load_A = 0x138,
M_Offset_Joint_Status_2 = 0x13a,
M_Offset_G0_Load_B = 0x13c,
@@ -1007,10 +1007,10 @@ enum m_series_register_offsets {
M_Offset_Analog_Trigger_Etc = 0x17a,
M_Offset_AI_START_STOP_Select = 0x17c,
M_Offset_AI_Trigger_Select = 0x17e,
- M_Offset_AI_SI_Save = 0x180, // read
- M_Offset_AI_DIV_Load_A = 0x180, // write
- M_Offset_AI_SC_Save = 0x184, // read
- M_Offset_AO_Start_Select = 0x184, // write
+ M_Offset_AI_SI_Save = 0x180, /* read */
+ M_Offset_AI_DIV_Load_A = 0x180, /* write */
+ M_Offset_AI_SC_Save = 0x184, /* read */
+ M_Offset_AO_Start_Select = 0x184, /* write */
M_Offset_AO_Trigger_Select = 0x186,
M_Offset_AO_Mode_3 = 0x18c,
M_Offset_G0_Autoincrement = 0x188,
@@ -1032,10 +1032,10 @@ enum m_series_register_offsets {
M_Offset_G1_Counting_Mode = 0x1b2,
M_Offset_G0_Second_Gate = 0x1b4,
M_Offset_G1_Second_Gate = 0x1b6,
- M_Offset_G0_DMA_Config = 0x1b8, // write
- M_Offset_G0_DMA_Status = 0x1b8, // read
- M_Offset_G1_DMA_Config = 0x1ba, // write
- M_Offset_G1_DMA_Status = 0x1ba, // read
+ M_Offset_G0_DMA_Config = 0x1b8, /* write */
+ M_Offset_G0_DMA_Status = 0x1b8, /* read */
+ M_Offset_G1_DMA_Config = 0x1ba, /* write */
+ M_Offset_G1_DMA_Status = 0x1ba, /* read */
M_Offset_G0_MSeries_ABZ = 0x1c0,
M_Offset_G1_MSeries_ABZ = 0x1c2,
M_Offset_Clock_and_Fout2 = 0x1c4,
@@ -1051,10 +1051,10 @@ enum m_series_register_offsets {
M_Offset_PFI_DO = 0x1de,
M_Offset_AI_Config_FIFO_Bypass = 0x218,
M_Offset_SCXI_DIO_Enable = 0x21c,
- M_Offset_CDI_FIFO_Data = 0x220, // read
- M_Offset_CDO_FIFO_Data = 0x220, // write
- M_Offset_CDIO_Status = 0x224, // read
- M_Offset_CDIO_Command = 0x224, // write
+ M_Offset_CDI_FIFO_Data = 0x220, /* read */
+ M_Offset_CDO_FIFO_Data = 0x220, /* write */
+ M_Offset_CDIO_Status = 0x224, /* read */
+ M_Offset_CDIO_Command = 0x224, /* write */
M_Offset_CDI_Mode = 0x228,
M_Offset_CDO_Mode = 0x22c,
M_Offset_CDI_Mask_Enable = 0x230,
@@ -1084,8 +1084,8 @@ static inline int M_Offset_Static_AI_Control(int i)
0x262,
0x263,
};
- if (((unsigned)i) >= sizeof(offset) / sizeof(offset[0])) {
- rt_printk("%s: invalid channel=%i\n", __FUNCTION__, i);
+ if (((unsigned)i) >= ARRAY_SIZE(offset)) {
+ printk("%s: invalid channel=%i\n", __func__, i);
return offset[0];
}
return offset[i];
@@ -1098,8 +1098,8 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel)
0x266,
0x267
};
- if (((unsigned)channel) >= sizeof(offset) / sizeof(offset[0])) {
- rt_printk("%s: invalid channel=%i\n", __FUNCTION__, channel);
+ if (((unsigned)channel) >= ARRAY_SIZE(offset)) {
+ printk("%s: invalid channel=%i\n", __func__, channel);
return offset[0];
}
return offset[channel];
@@ -1107,8 +1107,8 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel)
static inline unsigned M_Offset_PFI_Output_Select(unsigned n)
{
if (n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS) {
- rt_printk("%s: invalid pfi output select register=%i\n",
- __FUNCTION__, n);
+ printk("%s: invalid pfi output select register=%i\n",
+ __func__, n);
return M_Offset_PFI_Output_Select_1;
}
return M_Offset_PFI_Output_Select_1 + (n - 1) * 2;
@@ -1122,7 +1122,7 @@ enum MSeries_AI_Config_FIFO_Data_Bits {
MSeries_AI_Config_Channel_Type_Ground_Ref_Bits = 0x3 << 6,
MSeries_AI_Config_Channel_Type_Aux_Bits = 0x5 << 6,
MSeries_AI_Config_Channel_Type_Ghost_Bits = 0x7 << 6,
- MSeries_AI_Config_Polarity_Bit = 0x1000, // 0 for 2's complement encoding
+ MSeries_AI_Config_Polarity_Bit = 0x1000, /* 0 for 2's complement encoding */
MSeries_AI_Config_Dither_Bit = 0x2000,
MSeries_AI_Config_Last_Channel_Bit = 0x4000,
};
@@ -1151,8 +1151,8 @@ enum MSeries_Clock_and_Fout2_Bits {
MSeries_PLL_In_Source_Select_RTSI7_Bits = 0x1b,
MSeries_PLL_In_Source_Select_PXI_Clock10 = 0x1d,
MSeries_PLL_In_Source_Select_Mask = 0x1f,
- MSeries_Timebase1_Select_Bit = 0x20, // use PLL for timebase 1
- MSeries_Timebase3_Select_Bit = 0x40, // use PLL for timebase 3
+ MSeries_Timebase1_Select_Bit = 0x20, /* use PLL for timebase 1 */
+ MSeries_Timebase3_Select_Bit = 0x40, /* use PLL for timebase 3 */
/* use 10MHz instead of 20MHz for RTSI clock frequency. Appears
to have no effect, at least on pxi-6281, which always uses
20MHz rtsi clock frequency */
@@ -1162,7 +1162,7 @@ static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned
RTSI_channel)
{
if (RTSI_channel > 7) {
- rt_printk("%s: bug, invalid RTSI_channel=%i\n", __FUNCTION__,
+ printk("%s: bug, invalid RTSI_channel=%i\n", __func__,
RTSI_channel);
return 0;
}
@@ -1183,7 +1183,7 @@ static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor)
{
static const unsigned max_divisor = 0x10;
if (divisor < 1 || divisor > max_divisor) {
- rt_printk("%s: bug, invalid divisor=%i\n", __FUNCTION__,
+ printk("%s: bug, invalid divisor=%i\n", __func__,
divisor);
return 0;
}
@@ -1193,7 +1193,7 @@ static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier)
{
static const unsigned max_multiplier = 0x100;
if (multiplier < 1 || multiplier > max_multiplier) {
- rt_printk("%s: bug, invalid multiplier=%i\n", __FUNCTION__,
+ printk("%s: bug, invalid multiplier=%i\n", __func__,
multiplier);
return 0;
}
@@ -1213,7 +1213,7 @@ enum MSeries_AI_Config_FIFO_Bypass_Bits {
MSeries_AO_Bypass_AO_Cal_Sel_Mask = 0x38000,
MSeries_AI_Bypass_Gain_Mask = 0x1c0000,
MSeries_AI_Bypass_Dither_Bit = 0x200000,
- MSeries_AI_Bypass_Polarity_Bit = 0x400000, // 0 for 2's complement encoding
+ MSeries_AI_Bypass_Polarity_Bit = 0x400000, /* 0 for 2's complement encoding */
MSeries_AI_Bypass_Config_FIFO_Bit = 0x80000000
};
static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(int
@@ -1239,7 +1239,7 @@ enum MSeries_AO_Config_Bank_Bits {
MSeries_AO_DAC_Reference_10V_Internal_Bits = 0x0,
MSeries_AO_DAC_Reference_5V_Internal_Bits = 0x8,
MSeries_AO_Update_Timed_Bit = 0x40,
- MSeries_AO_Bipolar_Bit = 0x80 // turns on 2's complement encoding
+ MSeries_AO_Bipolar_Bit = 0x80 /* turns on 2's complement encoding */
};
enum MSeries_AO_Reference_Attenuation_Bits {
@@ -1266,7 +1266,7 @@ static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel,
return (source & 0x1f) << ((channel % 3) * 5);
};
-// inverse to MSeries_PFI_Output_Select_Bits
+/* inverse to MSeries_PFI_Output_Select_Bits */
static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel,
unsigned bits)
{
@@ -1338,9 +1338,9 @@ enum CDIO_Command_Bits {
enum CDI_Mode_Bits {
CDI_Sample_Source_Select_Mask = 0x3f,
CDI_Halt_On_Error_Bit = 0x200,
- CDI_Polarity_Bit = 0x400, // sample clock on falling edge
- CDI_FIFO_Mode_Bit = 0x800, // set for half full mode, clear for not empty mode
- CDI_Data_Lane_Mask = 0x3000, // data lanes specify which dio channels map to byte or word accesses to the dio fifos
+ CDI_Polarity_Bit = 0x400, /* sample clock on falling edge */
+ CDI_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not empty mode */
+ CDI_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */
CDI_Data_Lane_0_15_Bits = 0x0,
CDI_Data_Lane_16_31_Bits = 0x1000,
CDI_Data_Lane_0_7_Bits = 0x0,
@@ -1353,9 +1353,9 @@ enum CDO_Mode_Bits {
CDO_Sample_Source_Select_Mask = 0x3f,
CDO_Retransmit_Bit = 0x100,
CDO_Halt_On_Error_Bit = 0x200,
- CDO_Polarity_Bit = 0x400, // sample clock on falling edge
- CDO_FIFO_Mode_Bit = 0x800, // set for half full mode, clear for not full mode
- CDO_Data_Lane_Mask = 0x3000, // data lanes specify which dio channels map to byte or word accesses to the dio fifos
+ CDO_Polarity_Bit = 0x400, /* sample clock on falling edge */
+ CDO_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not full mode */
+ CDO_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */
CDO_Data_Lane_0_15_Bits = 0x0,
CDO_Data_Lane_16_31_Bits = 0x1000,
CDO_Data_Lane_0_7_Bits = 0x0,
@@ -1374,7 +1374,7 @@ enum Interrupt_C_Status_Bits {
#define M_SERIES_EEPROM_SIZE 1024
-typedef struct ni_board_struct {
+struct ni_board_struct {
int device_id;
int isapnp_id;
char *name;
@@ -1401,11 +1401,11 @@ typedef struct ni_board_struct {
unsigned int has_analog_trig:1;
enum caldac_enum caldac[3];
-} ni_board;
+};
-#define n_ni_boards (sizeof(ni_boards)/sizeof(ni_board))
+#define n_ni_boards (sizeof(ni_boards)/sizeof(struct ni_board_struct))
-#define boardtype (*(ni_board *)dev->board_ptr)
+#define boardtype (*(struct ni_board_struct *)dev->board_ptr)
#define MAX_N_AO_CHAN 8
#define NUM_GPCT 2
@@ -1418,7 +1418,7 @@ typedef struct ni_board_struct {
\
unsigned short dio_output; \
unsigned short dio_control; \
- int ao0p,ao1p; \
+ int ao0p, ao1p; \
int lastchan; \
int last_do; \
int rt_irq; \
diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c
index 05a957540398..785553d0cc9d 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -149,13 +149,13 @@ static const unsigned ni_660x_max_rtsi_channel = 6;
static inline unsigned NI_660x_RTSI_Clock(unsigned n)
{
BUG_ON(n > ni_660x_max_rtsi_channel);
- return (0xb + n);
+ return 0xb + n;
}
static const unsigned ni_660x_max_source_pin = 7;
static inline unsigned NI_660x_Source_Pin_Clock(unsigned n)
{
BUG_ON(n > ni_660x_max_source_pin);
- return (0x2 + n);
+ return 0x2 + n;
}
/* clock sources for ni e and m series boards, get bits with Gi_Source_Select_Bits() */
@@ -279,9 +279,9 @@ static void __exit ni_tio_cleanup_module(void)
module_exit(ni_tio_cleanup_module);
struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device * dev,
- void (*write_register) (struct ni_gpct * counter, unsigned bits,
+ void (*write_register) (struct ni_gpct *counter, unsigned bits,
enum ni_gpct_register reg),
- unsigned (*read_register) (struct ni_gpct * counter,
+ unsigned (*read_register) (struct ni_gpct *counter,
enum ni_gpct_register reg), enum ni_gpct_variant variant,
unsigned num_counters)
{
@@ -669,7 +669,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int clock_source)
}
if (i <= ni_m_series_max_pfi_channel)
break;
- rt_printk("invalid clock source 0x%lx\n",
+ printk("invalid clock source 0x%lx\n",
(unsigned long)clock_source);
BUG();
ni_m_series_clock = 0;
@@ -965,7 +965,7 @@ static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
}
static void ni_tio_get_clock_src(struct ni_gpct *counter,
- unsigned int * clock_source, unsigned int * period_ns)
+ unsigned int *clock_source, unsigned int *period_ns)
{
static const unsigned pico_per_nano = 1000;
uint64_t temp64;
@@ -1273,7 +1273,7 @@ static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index,
counter_dev->regs[abz_reg] &= ~mask;
counter_dev->regs[abz_reg] |= (source << shift) & mask;
write_register(counter, counter_dev->regs[abz_reg], abz_reg);
-// rt_printk("%s %x %d %d\n", __FUNCTION__, counter_dev->regs[abz_reg], index, source);
+/* printk("%s %x %d %d\n", __func__, counter_dev->regs[abz_reg], index, source); */
return 0;
}
return -EINVAL;
@@ -1442,7 +1442,7 @@ static unsigned ni_m_series_second_gate_to_generic_gate_source(unsigned
};
static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
- unsigned int * gate_source)
+ unsigned int *gate_source)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned mode_bits = ni_tio_get_soft_copy(counter,
@@ -1534,7 +1534,7 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
}
int ni_tio_insn_config(struct ni_gpct *counter,
- struct comedi_insn * insn, unsigned int * data)
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
case INSN_CONFIG_SET_COUNTER_MODE:
diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h
index 0729d60b01cc..3aacfe2f2420 100644
--- a/drivers/staging/comedi/drivers/ni_tio.h
+++ b/drivers/staging/comedi/drivers/ni_tio.h
@@ -25,7 +25,7 @@
#include "../comedidev.h"
-// forward declarations
+/* forward declarations */
struct mite_struct;
struct ni_gpct_device;
@@ -120,9 +120,9 @@ struct ni_gpct {
struct ni_gpct_device {
struct comedi_device *dev;
- void (*write_register) (struct ni_gpct * counter, unsigned bits,
+ void (*write_register) (struct ni_gpct *counter, unsigned bits,
enum ni_gpct_register reg);
- unsigned (*read_register) (struct ni_gpct * counter,
+ unsigned (*read_register) (struct ni_gpct *counter,
enum ni_gpct_register reg);
enum ni_gpct_variant variant;
struct ni_gpct *counters;
@@ -132,24 +132,24 @@ struct ni_gpct_device {
};
extern struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device * dev,
- void (*write_register) (struct ni_gpct * counter, unsigned bits,
+ void (*write_register) (struct ni_gpct *counter, unsigned bits,
enum ni_gpct_register reg),
- unsigned (*read_register) (struct ni_gpct * counter,
+ unsigned (*read_register) (struct ni_gpct *counter,
enum ni_gpct_register reg), enum ni_gpct_variant variant,
unsigned num_counters);
extern void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev);
extern void ni_tio_init_counter(struct ni_gpct *counter);
extern int ni_tio_rinsn(struct ni_gpct *counter,
- struct comedi_insn * insn, unsigned int * data);
+ struct comedi_insn *insn, unsigned int *data);
extern int ni_tio_insn_config(struct ni_gpct *counter,
- struct comedi_insn * insn, unsigned int * data);
+ struct comedi_insn *insn, unsigned int *data);
extern int ni_tio_winsn(struct ni_gpct *counter,
- struct comedi_insn * insn, unsigned int * data);
+ struct comedi_insn *insn, unsigned int *data);
extern int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async);
extern int ni_tio_cmdtest(struct ni_gpct *counter, struct comedi_cmd * cmd);
extern int ni_tio_cancel(struct ni_gpct *counter);
extern void ni_tio_handle_interrupt(struct ni_gpct *counter,
- struct comedi_subdevice * s);
+ struct comedi_subdevice *s);
extern void ni_tio_set_mite_channel(struct ni_gpct *counter,
struct mite_channel *mite_chan);
extern void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter,
diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h
index ac5b171cbe18..920dd221da0d 100644
--- a/drivers/staging/comedi/drivers/ni_tio_internal.h
+++ b/drivers/staging/comedi/drivers/ni_tio_internal.h
@@ -487,8 +487,8 @@ enum Gi_Counting_Mode_Reg_Bits {
#define Gi_Source_Select_Shift 2
#define Gi_Gate_Select_Shift 7
enum Gi_Input_Select_Bits {
- Gi_Read_Acknowledges_Irq = 0x1, // not present on 660x
- Gi_Write_Acknowledges_Irq = 0x2, // not present on 660x
+ Gi_Read_Acknowledges_Irq = 0x1, /* not present on 660x */
+ Gi_Write_Acknowledges_Irq = 0x2, /* not present on 660x */
Gi_Source_Select_Mask = 0x7c,
Gi_Gate_Select_Mask = 0x1f << Gi_Gate_Select_Shift,
Gi_Gate_Select_Load_Source_Bit = 0x1000,
@@ -656,7 +656,7 @@ static inline unsigned Gi_TC_Error_Confirm_Bit(unsigned counter_index)
return G0_TC_Error_Confirm_Bit;
}
-// bits that are the same in G0/G2 and G1/G3 interrupt acknowledge registers
+/* bits that are the same in G0/G2 and G1/G3 interrupt acknowledge registers */
enum Gxx_Interrupt_Acknowledge_Bits {
Gi_TC_Interrupt_Ack_Bit = 0x4000,
Gi_Gate_Interrupt_Ack_Bit = 0x8000
@@ -728,14 +728,14 @@ static inline void ni_tio_set_bits_transient(struct ni_gpct *counter,
unsigned long flags;
BUG_ON(register_index >= NITIO_Num_Registers);
- comedi_spin_lock_irqsave(&counter_dev->regs_lock, flags);
+ spin_lock_irqsave(&counter_dev->regs_lock, flags);
counter_dev->regs[register_index] &= ~bit_mask;
counter_dev->regs[register_index] |= (bit_values & bit_mask);
write_register(counter,
counter_dev->regs[register_index] | transient_bit_values,
register_index);
mmiowb();
- comedi_spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
+ spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
}
/* ni_tio_set_bits( ) is for safely writing to registers whose bits may be
@@ -761,9 +761,9 @@ static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter,
unsigned value;
BUG_ON(register_index >= NITIO_Num_Registers);
- comedi_spin_lock_irqsave(&counter_dev->regs_lock, flags);
+ spin_lock_irqsave(&counter_dev->regs_lock, flags);
value = counter_dev->regs[register_index];
- comedi_spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
+ spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
return value;
}
diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c
index 16a26e73c994..5be1e1a62c0a 100644
--- a/drivers/staging/comedi/drivers/ni_tiocmd.c
+++ b/drivers/staging/comedi/drivers/ni_tiocmd.c
@@ -96,7 +96,7 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, short enable,
}
}
-static int ni_tio_input_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
+static int ni_tio_input_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
unsigned long flags;
@@ -107,12 +107,12 @@ static int ni_tio_input_inttrig(struct comedi_device * dev, struct comedi_subdev
if (trignum != 0)
return -EINVAL;
- comedi_spin_lock_irqsave(&counter->lock, flags);
+ spin_lock_irqsave(&counter->lock, flags);
if (counter->mite_chan)
mite_dma_arm(counter->mite_chan);
else
retval = -EIO;
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
if (retval < 0)
return retval;
retval = ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE);
@@ -171,7 +171,7 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async)
static int ni_tio_output_cmd(struct ni_gpct *counter, struct comedi_async *async)
{
- rt_printk("ni_tio: output commands not yet implemented.\n");
+ printk("ni_tio: output commands not yet implemented.\n");
return -ENOTSUPP;
counter->mite_chan->dir = COMEDI_OUTPUT;
@@ -213,9 +213,9 @@ int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async)
int retval = 0;
unsigned long flags;
- comedi_spin_lock_irqsave(&counter->lock, flags);
+ spin_lock_irqsave(&counter->lock, flags);
if (counter->mite_chan == NULL) {
- rt_printk
+ printk
("ni_tio: commands only supported with DMA. Interrupt-driven commands not yet implemented.\n");
retval = -EIO;
} else {
@@ -228,7 +228,7 @@ int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async)
}
}
}
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
return retval;
}
@@ -342,11 +342,11 @@ int ni_tio_cancel(struct ni_gpct *counter)
unsigned long flags;
ni_tio_arm(counter, 0, 0);
- comedi_spin_lock_irqsave(&counter->lock, flags);
+ spin_lock_irqsave(&counter->lock, flags);
if (counter->mite_chan) {
mite_dma_disarm(counter->mite_chan);
}
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
ni_tio_configure_dma(counter, 0, 0);
ni_tio_set_bits(counter,
@@ -365,11 +365,11 @@ static int should_ack_gate(struct ni_gpct *counter)
switch (counter->counter_dev->variant) {
case ni_gpct_variant_m_series:
- case ni_gpct_variant_660x: // not sure if 660x really supports gate interrupts (the bits are not listed in register-level manual)
+ case ni_gpct_variant_660x: /* not sure if 660x really supports gate interrupts (the bits are not listed in register-level manual) */
return 1;
break;
case ni_gpct_variant_e_series:
- comedi_spin_lock_irqsave(&counter->lock, flags);
+ spin_lock_irqsave(&counter->lock, flags);
{
if (counter->mite_chan == NULL ||
counter->mite_chan->dir != COMEDI_INPUT ||
@@ -377,7 +377,7 @@ static int should_ack_gate(struct ni_gpct *counter)
retval = 1;
}
}
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
break;
}
return retval;
@@ -439,7 +439,7 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
NITIO_Gxx_Joint_Status2_Reg(counter->
counter_index)) &
Gi_Permanent_Stale_Bit(counter->counter_index)) {
- rt_printk("%s: Gi_Permanent_Stale_Data detected.\n",
+ printk("%s: Gi_Permanent_Stale_Data detected.\n",
__FUNCTION__);
if (perm_stale_data)
*perm_stale_data = 1;
@@ -458,7 +458,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *
ni_tio_acknowledge_and_confirm(counter, &gate_error, &tc_error,
&perm_stale_data, NULL);
if (gate_error) {
- rt_printk("%s: Gi_Gate_Error detected.\n", __FUNCTION__);
+ printk("%s: Gi_Gate_Error detected.\n", __FUNCTION__);
s->async->events |= COMEDI_CB_OVERFLOW;
}
if (perm_stale_data) {
@@ -470,16 +470,16 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *
if (read_register(counter,
NITIO_Gi_DMA_Status_Reg(counter->
counter_index)) & Gi_DRQ_Error_Bit) {
- rt_printk("%s: Gi_DRQ_Error detected.\n", __FUNCTION__);
+ printk("%s: Gi_DRQ_Error detected.\n", __FUNCTION__);
s->async->events |= COMEDI_CB_OVERFLOW;
}
break;
case ni_gpct_variant_e_series:
break;
}
- comedi_spin_lock_irqsave(&counter->lock, flags);
+ spin_lock_irqsave(&counter->lock, flags);
if (counter->mite_chan == NULL) {
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
return;
}
gpct_mite_status = mite_get_status(counter->mite_chan);
@@ -489,7 +489,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *
MITE_CHOR(counter->mite_chan->channel));
}
mite_sync_input_dma(counter->mite_chan, s->async);
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
}
void ni_tio_set_mite_channel(struct ni_gpct *counter,
@@ -497,9 +497,9 @@ void ni_tio_set_mite_channel(struct ni_gpct *counter,
{
unsigned long flags;
- comedi_spin_lock_irqsave(&counter->lock, flags);
+ spin_lock_irqsave(&counter->lock, flags);
counter->mite_chan = mite_chan;
- comedi_spin_unlock_irqrestore(&counter->lock, flags);
+ spin_unlock_irqrestore(&counter->lock, flags);
}
static int __init ni_tiocmd_init_module(void)
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index ce42506d47b5..7b72b7af75c8 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -58,6 +58,7 @@ supported.
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -156,16 +157,16 @@ static const struct pcl711_board boardtypes[] = {
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl711_board))
#define this_board ((const struct pcl711_board *)dev->board_ptr)
-static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl711_detach(struct comedi_device * dev);
+static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl711_detach(struct comedi_device *dev);
static struct comedi_driver driver_pcl711 = {
- driver_name:"pcl711",
- module:THIS_MODULE,
- attach:pcl711_attach,
- detach:pcl711_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl711_board),
+ .driver_name = "pcl711",
+ .module = THIS_MODULE,
+ .attach = pcl711_attach,
+ .detach = pcl711_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl711_board),
};
COMEDI_INITCLEANUP(driver_pcl711);
@@ -185,7 +186,7 @@ struct pcl711_private {
#define devpriv ((struct pcl711_private *)dev->private)
-static irqreturn_t pcl711_interrupt(int irq, void *d PT_REGS_ARG)
+static irqreturn_t pcl711_interrupt(int irq, void *d)
{
int lo, hi;
int data;
@@ -217,7 +218,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static void pcl711_set_changain(struct comedi_device * dev, int chan)
+static void pcl711_set_changain(struct comedi_device *dev, int chan)
{
int chan_register;
@@ -244,8 +245,8 @@ static void pcl711_set_changain(struct comedi_device * dev, int chan)
}
}
-static int pcl711_ai_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int hi, lo;
@@ -269,9 +270,9 @@ static int pcl711_ai_insn(struct comedi_device * dev, struct comedi_subdevice *
hi = inb(dev->iobase + PCL711_AD_HI);
if (!(hi & PCL711_DRDY))
goto ok;
- comedi_udelay(1);
+ udelay(1);
}
- rt_printk("comedi%d: pcl711: A/D timeout\n", dev->minor);
+ printk("comedi%d: pcl711: A/D timeout\n", dev->minor);
return -ETIME;
ok:
@@ -283,8 +284,8 @@ static int pcl711_ai_insn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static int pcl711_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pcl711_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int tmp;
int err = 0;
@@ -385,7 +386,7 @@ static int pcl711_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pcl711_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
int timer1, timer2;
struct comedi_cmd *cmd = &s->async->cmd;
@@ -431,8 +432,8 @@ static int pcl711_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
/*
analog output
*/
-static int pcl711_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl711_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -449,8 +450,8 @@ static int pcl711_ao_insn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static int pcl711_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl711_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -464,8 +465,8 @@ static int pcl711_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
}
/* Digital port read - Untested on 8112 */
-static int pcl711_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl711_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -477,8 +478,8 @@ static int pcl711_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
}
/* Digital port write - Untested on 8112 */
-static int pcl711_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl711_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -498,12 +499,12 @@ static int pcl711_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi
}
/* Free any resources that we have claimed */
-static int pcl711_detach(struct comedi_device * dev)
+static int pcl711_detach(struct comedi_device *dev)
{
printk("comedi%d: pcl711: remove\n", dev->minor);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, PCL711_SIZE);
@@ -512,7 +513,7 @@ static int pcl711_detach(struct comedi_device * dev)
}
/* Initialization */
-static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
@@ -541,7 +542,7 @@ static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * i
return -EINVAL;
}
if (irq) {
- if (comedi_request_irq(irq, pcl711_interrupt, 0, "pcl711", dev)) {
+ if (request_irq(irq, pcl711_interrupt, 0, "pcl711", dev)) {
printk("unable to allocate irq %u\n", irq);
return -EINVAL;
} else {
@@ -550,9 +551,12 @@ static int pcl711_attach(struct comedi_device * dev, struct comedi_devconfig * i
}
dev->irq = irq;
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct pcl711_private))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct pcl711_private));
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c
index cd1e784f25f9..699daff3035a 100644
--- a/drivers/staging/comedi/drivers/pcl724.c
+++ b/drivers/staging/comedi/drivers/pcl724.c
@@ -54,18 +54,18 @@ See the source for configuration details.
#define SIZE_8255 4
-// #define PCL724_IRQ 1 /* no IRQ support now */
+/* #define PCL724_IRQ 1 no IRQ support now */
-static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl724_detach(struct comedi_device * dev);
+static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl724_detach(struct comedi_device *dev);
struct pcl724_board {
- const char *name; // board name
- int dio; // num of DIO
- int numofports; // num of 8255 subdevices
- unsigned int IRQbits; // allowed interrupts
- unsigned int io_range; // len of IO space
+ const char *name; /* board name */
+ int dio; /* num of DIO */
+ int numofports; /* num of 8255 subdevices */
+ unsigned int IRQbits; /* allowed interrupts */
+ unsigned int io_range; /* len of IO space */
char can_have96;
char is_pet48;
};
@@ -84,13 +84,13 @@ static const struct pcl724_board boardtypes[] = {
#define this_board ((const struct pcl724_board *)dev->board_ptr)
static struct comedi_driver driver_pcl724 = {
- driver_name:"pcl724",
- module:THIS_MODULE,
- attach:pcl724_attach,
- detach:pcl724_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl724_board),
+ .driver_name = "pcl724",
+ .module = THIS_MODULE,
+ .attach = pcl724_attach,
+ .detach = pcl724_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl724_board),
};
COMEDI_INITCLEANUP(driver_pcl724);
@@ -124,7 +124,7 @@ static int subdev_8255mapped_cb(int dir, int port, int data,
}
}
-static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase;
unsigned int iorange;
@@ -137,7 +137,7 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i
iorange = this_board->io_range;
if ((this_board->can_have96) && ((it->options[1] == 1)
|| (it->options[1] == 96)))
- iorange = PCL722_96_SIZE; // PCL-724 in 96 DIO configuration
+ iorange = PCL722_96_SIZE; /* PCL-724 in 96 DIO configuration */
printk("comedi%d: pcl724: board=%s, 0x%03lx ", dev->minor,
this_board->name, iobase);
if (!request_region(iobase, iorange, "pcl724")) {
@@ -155,19 +155,18 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i
irq = it->options[1];
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
- rt_printk
+ printk
(", IRQ %u is out of allowed range, DISABLING IT",
irq);
irq = 0; /* Bad IRQ */
} else {
- if (comedi_request_irq(irq, interrupt_pcl724, 0,
- "pcl724", dev)) {
- rt_printk
+ if (request_irq(irq, interrupt_pcl724, 0, "pcl724", dev)) {
+ printk
(", unable to allocate IRQ %u, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%u", irq);
+ printk(", irq=%u", irq);
}
}
}
@@ -181,9 +180,10 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i
n_subdevices = this_board->numofports;
if ((this_board->can_have96) && ((it->options[1] == 1)
|| (it->options[1] == 96)))
- n_subdevices = 4; // PCL-724 in 96 DIO configuration
+ n_subdevices = 4; /* PCL-724 in 96 DIO configuration */
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0)
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0)
return ret;
for (i = 0; i < dev->n_subdevices; i++) {
@@ -200,11 +200,11 @@ static int pcl724_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int pcl724_detach(struct comedi_device * dev)
+static int pcl724_detach(struct comedi_device *dev)
{
int i;
-// printk("comedi%d: pcl724: remove\n",dev->minor);
+/* printk("comedi%d: pcl724: remove\n",dev->minor); */
for (i = 0; i < dev->n_subdevices; i++) {
subdev_8255_cleanup(dev, dev->subdevices + i);
@@ -212,7 +212,7 @@ static int pcl724_detach(struct comedi_device * dev)
#ifdef PCL724_IRQ
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
#endif
diff --git a/drivers/staging/comedi/drivers/pcl725.c b/drivers/staging/comedi/drivers/pcl725.c
index 0766ba02bd03..1347624d0519 100644
--- a/drivers/staging/comedi/drivers/pcl725.c
+++ b/drivers/staging/comedi/drivers/pcl725.c
@@ -20,19 +20,19 @@ Devices: [Advantech] PCL-725 (pcl725)
#define PCL725_DO 0
#define PCL725_DI 1
-static int pcl725_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl725_detach(struct comedi_device * dev);
+static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl725_detach(struct comedi_device *dev);
static struct comedi_driver driver_pcl725 = {
- driver_name:"pcl725",
- module:THIS_MODULE,
- attach:pcl725_attach,
- detach:pcl725_detach,
+ .driver_name = "pcl725",
+ .module = THIS_MODULE,
+ .attach = pcl725_attach,
+ .detach = pcl725_detach,
};
COMEDI_INITCLEANUP(driver_pcl725);
-static int pcl725_do_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -48,8 +48,8 @@ static int pcl725_do_insn(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int pcl725_di_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl725_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -59,7 +59,7 @@ static int pcl725_di_insn(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int pcl725_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -100,7 +100,7 @@ static int pcl725_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int pcl725_detach(struct comedi_device * dev)
+static int pcl725_detach(struct comedi_device *dev)
{
printk("comedi%d: pcl725: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c
index 6dbd33d7907b..149e75f0e09c 100644
--- a/drivers/staging/comedi/drivers/pcl726.c
+++ b/drivers/staging/comedi/drivers/pcl726.c
@@ -111,22 +111,22 @@ static const struct comedi_lrange *const rangelist_728[] = {
&range_4_20mA, &range_0_20mA
};
-static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl726_detach(struct comedi_device * dev);
+static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl726_detach(struct comedi_device *dev);
struct pcl726_board {
- const char *name; // driver name
- int n_aochan; // num of D/A chans
- int num_of_ranges; // num of ranges
- unsigned int IRQbits; // allowed interrupts
- unsigned int io_range; // len of IO space
- char have_dio; // 1=card have DI/DO ports
- int di_hi; // ports for DI/DO operations
+ const char *name; /* driver name */
+ int n_aochan; /* num of D/A chans */
+ int num_of_ranges; /* num of ranges */
+ unsigned int IRQbits; /* allowed interrupts */
+ unsigned int io_range; /* len of IO space */
+ char have_dio; /* 1=card have DI/DO ports */
+ int di_hi; /* ports for DI/DO operations */
int di_lo;
int do_hi;
int do_lo;
- const struct comedi_lrange *const *range_type_list; // list of supported ranges
+ const struct comedi_lrange *const *range_type_list; /* list of supported ranges */
};
@@ -152,13 +152,13 @@ static const struct pcl726_board boardtypes[] = {
#define this_board ((const struct pcl726_board *)dev->board_ptr)
static struct comedi_driver driver_pcl726 = {
- driver_name:"pcl726",
- module:THIS_MODULE,
- attach:pcl726_attach,
- detach:pcl726_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl726_board),
+ .driver_name = "pcl726",
+ .module = THIS_MODULE,
+ .attach = pcl726_attach,
+ .detach = pcl726_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl726_board),
};
COMEDI_INITCLEANUP(driver_pcl726);
@@ -172,8 +172,8 @@ struct pcl726_private {
#define devpriv ((struct pcl726_private *)dev->private)
-static int pcl726_ao_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl726_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int hi, lo;
int n;
@@ -197,8 +197,8 @@ static int pcl726_ao_insn(struct comedi_device * dev, struct comedi_subdevice *
return n;
}
-static int pcl726_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl726_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int n;
@@ -209,8 +209,8 @@ static int pcl726_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int pcl726_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl726_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -221,8 +221,8 @@ static int pcl726_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int pcl726_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl726_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -241,7 +241,7 @@ static int pcl726_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -264,7 +264,8 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->board_name = this_board->name;
- if ((ret = alloc_private(dev, sizeof(struct pcl726_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct pcl726_private));
+ if (ret < 0)
return -ENOMEM;
for (i = 0; i < 12; i++) {
@@ -279,19 +280,19 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->first_chan = 2;
if (irq) { /* we want to use IRQ */
if (((1 << irq) & boardtypes[board].IRQbits) == 0) {
- rt_printk
+ printk
(", IRQ %d is out of allowed range, DISABLING IT",
irq);
irq = 0; /* Bad IRQ */
} else {
- if (comedi_request_irq(irq, interrupt_pcl818, 0,
+ if (request_irq(irq, interrupt_pcl818, 0,
"pcl726", dev)) {
- rt_printk
+ printk
(", unable to allocate IRQ %d, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%d", irq);
+ printk(", irq=%d", irq);
}
}
}
@@ -302,7 +303,8 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk("\n");
- if ((ret = alloc_subdevices(dev, 3)) < 0)
+ ret = alloc_subdevices(dev, 3);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -360,13 +362,13 @@ static int pcl726_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int pcl726_detach(struct comedi_device * dev)
+static int pcl726_detach(struct comedi_device *dev)
{
-// printk("comedi%d: pcl726: remove\n",dev->minor);
+/* printk("comedi%d: pcl726: remove\n",dev->minor); */
#ifdef ACL6126_IRQ
if (dev->irq) {
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
#endif
diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c
index f2c6d7c5693c..408cbffae418 100644
--- a/drivers/staging/comedi/drivers/pcl730.c
+++ b/drivers/staging/comedi/drivers/pcl730.c
@@ -26,13 +26,13 @@ The ACL-7130 card have an 8254 timer/counter not supported by this driver.
#define PCL730_DIO_LO 2 /* TTL Digital I/O low byte (D0-D7) */
#define PCL730_DIO_HI 3 /* TTL Digital I/O high byte (D8-D15) */
-static int pcl730_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl730_detach(struct comedi_device * dev);
+static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl730_detach(struct comedi_device *dev);
struct pcl730_board {
- const char *name; // board name
- unsigned int io_range; // len of I/O space
+ const char *name; /* board name */
+ unsigned int io_range; /* len of I/O space */
};
@@ -46,19 +46,19 @@ static const struct pcl730_board boardtypes[] = {
#define this_board ((const struct pcl730_board *)dev->board_ptr)
static struct comedi_driver driver_pcl730 = {
- driver_name:"pcl730",
- module:THIS_MODULE,
- attach:pcl730_attach,
- detach:pcl730_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl730_board),
+ .driver_name = "pcl730",
+ .module = THIS_MODULE,
+ .attach = pcl730_attach,
+ .detach = pcl730_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl730_board),
};
COMEDI_INITCLEANUP(driver_pcl730);
-static int pcl730_do_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -79,8 +79,8 @@ static int pcl730_do_insn(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int pcl730_di_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl730_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -91,7 +91,7 @@ static int pcl730_di_insn(struct comedi_device * dev, struct comedi_subdevice *
return 2;
}
-static int pcl730_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -157,7 +157,7 @@ static int pcl730_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int pcl730_detach(struct comedi_device * dev)
+static int pcl730_detach(struct comedi_device *dev)
{
printk("comedi%d: pcl730: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c
index 11dfd230e565..dd91fe9f5f51 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -107,6 +107,7 @@ Options for ACL-8113, ISO-813:
3= 20V unipolar inputs
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/delay.h>
@@ -117,7 +118,7 @@ Options for ACL-8113, ISO-813:
#undef PCL812_EXTDEBUG /* if this is defined then a lot of messages is printed */
-// hardware types of the cards
+/* hardware types of the cards */
#define boardPCL812PG 0 /* and ACL-8112PG */
#define boardPCL813B 1
#define boardPCL812 2
@@ -292,27 +293,27 @@ static const struct comedi_lrange range_a821pgh_ai = { 4, {
}
};
-static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl812_detach(struct comedi_device * dev);
+static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl812_detach(struct comedi_device *dev);
struct pcl812_board {
- const char *name; // board name
- int board_type; // type of this board
- int n_aichan; // num of AI chans in S.E.
- int n_aichan_diff; // DIFF num of chans
- int n_aochan; // num of DA chans
- int n_dichan; // DI and DO chans
+ const char *name; /* board name */
+ int board_type; /* type of this board */
+ int n_aichan; /* num of AI chans in S.E. */
+ int n_aichan_diff; /* DIFF num of chans */
+ int n_aochan; /* num of DA chans */
+ int n_dichan; /* DI and DO chans */
int n_dochan;
- int ai_maxdata; // AI resolution
- unsigned int ai_ns_min; // max sample speed of card v ns
- unsigned int i8254_osc_base; // clock base
- const struct comedi_lrange *rangelist_ai; // rangelist for A/D
- const struct comedi_lrange *rangelist_ao; // rangelist for D/A
- unsigned int IRQbits; // allowed IRQ
- unsigned char DMAbits; // allowed DMA chans
- unsigned char io_range; // iorange for this board
- unsigned char haveMPC508; // 1=board use MPC508A multiplexor
+ int ai_maxdata; /* AI resolution */
+ unsigned int ai_ns_min; /* max sample speed of card v ns */
+ unsigned int i8254_osc_base; /* clock base */
+ const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */
+ const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
+ unsigned int IRQbits; /* allowed IRQ */
+ unsigned char DMAbits; /* allowed DMA chans */
+ unsigned char io_range; /* iorange for this board */
+ unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */
};
@@ -377,50 +378,50 @@ static const struct pcl812_board boardtypes[] = {
#define this_board ((const struct pcl812_board *)dev->board_ptr)
static struct comedi_driver driver_pcl812 = {
- driver_name:"pcl812",
- module:THIS_MODULE,
- attach:pcl812_attach,
- detach:pcl812_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl812_board),
+ .driver_name = "pcl812",
+ .module = THIS_MODULE,
+ .attach = pcl812_attach,
+ .detach = pcl812_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl812_board),
};
COMEDI_INITCLEANUP(driver_pcl812);
struct pcl812_private {
- unsigned char valid; // =1 device is OK
- unsigned char dma; // >0 use dma ( usedDMA channel)
- unsigned char use_diff; // =1 diff inputs
- unsigned char use_MPC; // 1=board uses MPC508A multiplexor
- unsigned char use_ext_trg; // 1=board uses external trigger
- unsigned char range_correction; // =1 we must add 1 to range number
- unsigned char old_chan_reg; // lastly used chan/gain pair
+ unsigned char valid; /* =1 device is OK */
+ unsigned char dma; /* >0 use dma ( usedDMA channel) */
+ unsigned char use_diff; /* =1 diff inputs */
+ unsigned char use_MPC; /* 1=board uses MPC508A multiplexor */
+ unsigned char use_ext_trg; /* 1=board uses external trigger */
+ unsigned char range_correction; /* =1 we must add 1 to range number */
+ unsigned char old_chan_reg; /* lastly used chan/gain pair */
unsigned char old_gain_reg;
- unsigned char mode_reg_int; // there is stored INT number for some card
- unsigned char ai_neverending; // =1 we do unlimited AI
- unsigned char ai_eos; // 1=EOS wake up
- unsigned char ai_dma; // =1 we use DMA
- unsigned int ai_poll_ptr; // how many sampes transfer poll
- unsigned int ai_scans; // len of scanlist
- unsigned int ai_act_scan; // how many scans we finished
- unsigned int ai_chanlist[MAX_CHANLIST_LEN]; // our copy of channel/range list
- unsigned int ai_n_chan; // how many channels is measured
- unsigned int ai_flags; // flaglist
- unsigned int ai_data_len; // len of data buffer
- short *ai_data; // data buffer
- unsigned int ai_is16b; // =1 we have 16 bit card
- unsigned long dmabuf[2]; // PTR to DMA buf
- unsigned int dmapages[2]; // how many pages we have allocated
- unsigned int hwdmaptr[2]; // HW PTR to DMA buf
- unsigned int hwdmasize[2]; // DMA buf size in bytes
- unsigned int dmabytestomove[2]; // how many bytes DMA transfer
- int next_dma_buf; // which buffer is next to use
- unsigned int dma_runs_to_end; // how many times we must switch DMA buffers
- unsigned int last_dma_run; // how many bytes to transfer on last DMA buffer
- unsigned int max_812_ai_mode0_rangewait; // setling time for gain
- unsigned int ao_readback[2]; // data for AO readback
+ unsigned char mode_reg_int; /* there is stored INT number for some card */
+ unsigned char ai_neverending; /* =1 we do unlimited AI */
+ unsigned char ai_eos; /* 1=EOS wake up */
+ unsigned char ai_dma; /* =1 we use DMA */
+ unsigned int ai_poll_ptr; /* how many sampes transfer poll */
+ unsigned int ai_scans; /* len of scanlist */
+ unsigned int ai_act_scan; /* how many scans we finished */
+ unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */
+ unsigned int ai_n_chan; /* how many channels is measured */
+ unsigned int ai_flags; /* flaglist */
+ unsigned int ai_data_len; /* len of data buffer */
+ short *ai_data; /* data buffer */
+ unsigned int ai_is16b; /* =1 we have 16 bit card */
+ unsigned long dmabuf[2]; /* PTR to DMA buf */
+ unsigned int dmapages[2]; /* how many pages we have allocated */
+ unsigned int hwdmaptr[2]; /* HW PTR to DMA buf */
+ unsigned int hwdmasize[2]; /* DMA buf size in bytes */
+ unsigned int dmabytestomove[2]; /* how many bytes DMA transfer */
+ int next_dma_buf; /* which buffer is next to use */
+ unsigned int dma_runs_to_end; /* how many times we must switch DMA buffers */
+ unsigned int last_dma_run; /* how many bytes to transfer on last DMA buffer */
+ unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */
+ unsigned int ao_readback[2]; /* data for AO readback */
};
@@ -429,33 +430,33 @@ struct pcl812_private {
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2);
-static void setup_range_channel(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int rangechan, char wait);
-static int pcl812_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
+static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
/*
==============================================================================
*/
-static int pcl812_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl812_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int timeout, hi;
outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE); /* select software trigger */
- setup_range_channel(dev, s, insn->chanspec, 1); // select channel and renge
+ setup_range_channel(dev, s, insn->chanspec, 1); /* select channel and renge */
for (n = 0; n < insn->n; n++) {
outb(255, dev->iobase + PCL812_SOFTTRIG); /* start conversion */
- comedi_udelay(5);
+ udelay(5);
timeout = 50; /* wait max 50us, it must finish under 33us */
while (timeout--) {
hi = inb(dev->iobase + PCL812_AD_HI);
if (!(hi & PCL812_DRDY))
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
- rt_printk
+ printk
("comedi%d: pcl812: (%s at 0x%lx) A/D insn read timeout\n",
dev->minor, dev->board_name, dev->iobase);
outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
@@ -471,24 +472,24 @@ static int pcl812_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
/*
==============================================================================
*/
-static int acl8216_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int acl8216_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int timeout;
outb(1, dev->iobase + PCL812_MODE); /* select software trigger */
- setup_range_channel(dev, s, insn->chanspec, 1); // select channel and renge
+ setup_range_channel(dev, s, insn->chanspec, 1); /* select channel and renge */
for (n = 0; n < insn->n; n++) {
outb(255, dev->iobase + PCL812_SOFTTRIG); /* start conversion */
- comedi_udelay(5);
+ udelay(5);
timeout = 50; /* wait max 50us, it must finish under 33us */
while (timeout--) {
if (!(inb(dev->iobase + ACL8216_STATUS) & ACL8216_DRDY))
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
- rt_printk
+ printk
("comedi%d: pcl812: (%s at 0x%lx) A/D insn read timeout\n",
dev->minor, dev->board_name, dev->iobase);
outb(0, dev->iobase + PCL812_MODE);
@@ -507,8 +508,8 @@ static int acl8216_ai_insn_read(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pcl812_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl812_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int i;
@@ -527,8 +528,8 @@ static int pcl812_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
/*
==============================================================================
*/
-static int pcl812_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl812_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int i;
@@ -543,8 +544,8 @@ static int pcl812_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
/*
==============================================================================
*/
-static int pcl812_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl812_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -558,8 +559,8 @@ static int pcl812_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
/*
==============================================================================
*/
-static int pcl812_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl812_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -579,15 +580,15 @@ static int pcl812_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi
/*
==============================================================================
*/
-static void pcl812_cmdtest_out(int e, struct comedi_cmd * cmd)
+static void pcl812_cmdtest_out(int e, struct comedi_cmd *cmd)
{
- rt_printk("pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
+ printk("pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
- rt_printk("pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
+ printk("pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
- rt_printk("pcl812 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
+ printk("pcl812 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
cmd->scan_end_src);
- rt_printk("pcl812 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e,
+ printk("pcl812 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e,
cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
}
#endif
@@ -595,14 +596,14 @@ static void pcl812_cmdtest_out(int e, struct comedi_cmd * cmd)
/*
==============================================================================
*/
-static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...)\n");
+ printk("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...)\n");
pcl812_cmdtest_out(-1, cmd);
#endif
/* step 1: make sure trigger sources are trivially valid */
@@ -639,7 +640,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (err) {
#ifdef PCL812_EXTDEBUG
pcl812_cmdtest_out(1, cmd);
- rt_printk
+ printk
("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=1\n",
err);
#endif
@@ -681,7 +682,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (err) {
#ifdef PCL812_EXTDEBUG
pcl812_cmdtest_out(2, cmd);
- rt_printk
+ printk
("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=2\n",
err);
#endif
@@ -739,7 +740,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (err) {
#ifdef PCL812_EXTDEBUG
pcl812_cmdtest_out(3, cmd);
- rt_printk
+ printk
("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=3\n",
err);
#endif
@@ -761,7 +762,7 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (err) {
#ifdef PCL812_EXTDEBUG
- rt_printk
+ printk
("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=4\n",
err);
#endif
@@ -774,13 +775,13 @@ static int pcl812_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
/*
==============================================================================
*/
-static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes;
struct comedi_cmd *cmd = &s->async->cmd;
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n");
+ printk("pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n");
#endif
if (cmd->start_src != TRIG_NOW)
@@ -809,18 +810,18 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
cmd->flags & TRIG_ROUND_MASK);
}
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
devpriv->ai_n_chan = cmd->chanlist_len;
memcpy(devpriv->ai_chanlist, cmd->chanlist,
sizeof(unsigned int) * cmd->scan_end_arg);
- setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); // select first channel and range
+ setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); /* select first channel and range */
- if (devpriv->dma) { // check if we can use DMA transfer
+ if (devpriv->dma) { /* check if we can use DMA transfer */
devpriv->ai_dma = 1;
for (i = 1; i < devpriv->ai_n_chan; i++)
if (devpriv->ai_chanlist[0] != devpriv->ai_chanlist[i]) {
- devpriv->ai_dma = 0; // we cann't use DMA :-(
+ devpriv->ai_dma = 0; /* we cann't use DMA :-( */
break;
}
} else
@@ -841,14 +842,14 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
devpriv->ai_poll_ptr = 0;
s->async->cur_chan = 0;
- if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { // don't we want wake up every scan?
+ if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? */
devpriv->ai_eos = 1;
if (devpriv->ai_n_chan == 1)
- devpriv->ai_dma = 0; // DMA is useless for this situation
+ devpriv->ai_dma = 0; /* DMA is useless for this situation */
}
if (devpriv->ai_dma) {
- if (devpriv->ai_eos) { // we use EOS, so adapt DMA buffer to one scan
+ if (devpriv->ai_eos) { /* we use EOS, so adapt DMA buffer to one scan */
devpriv->dmabytestomove[0] =
devpriv->ai_n_chan * sizeof(short);
devpriv->dmabytestomove[1] =
@@ -866,9 +867,9 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
if (devpriv->ai_neverending) {
devpriv->dma_runs_to_end = 1;
} else {
- bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); // how many samples we must transfer?
- devpriv->dma_runs_to_end = bytes / devpriv->dmabytestomove[0]; // how many DMA pages we must fill
- devpriv->last_dma_run = bytes % devpriv->dmabytestomove[0]; //on last dma transfer must be moved
+ bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many samples we must transfer? */
+ devpriv->dma_runs_to_end = bytes / devpriv->dmabytestomove[0]; /* how many DMA pages we must fill */
+ devpriv->last_dma_run = bytes % devpriv->dmabytestomove[0]; /* on last dma transfer must be moved */
if (devpriv->dma_runs_to_end == 0)
devpriv->dmabytestomove[0] =
devpriv->last_dma_run;
@@ -892,7 +893,7 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
release_dma_lock(dma_flags);
enable_dma(devpriv->dma);
#ifdef PCL812_EXTDEBUG
- rt_printk
+ printk
("pcl812 EDBG: DMA %d PTR 0x%0x/0x%0x LEN %u/%u EOS %d\n",
devpriv->dma, devpriv->hwdmaptr[0],
devpriv->hwdmaptr[1], devpriv->dmabytestomove[0],
@@ -907,13 +908,13 @@ static int pcl812_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
}
if (devpriv->ai_dma) {
- outb(devpriv->mode_reg_int | 2, dev->iobase + PCL812_MODE); // let's go!
+ outb(devpriv->mode_reg_int | 2, dev->iobase + PCL812_MODE); /* let's go! */
} else {
- outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE); // let's go!
+ outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE); /* let's go! */
}
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: END: pcl812_ai_cmd(...)\n");
+ printk("pcl812 EDBG: END: pcl812_ai_cmd(...)\n");
#endif
return 0;
@@ -939,7 +940,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d)
err = 0;
break;
}
- comedi_udelay(1);
+ udelay(1);
}
} else {
mask = 0x0fff;
@@ -948,12 +949,12 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d)
err = 0;
break;
}
- comedi_udelay(1);
+ udelay(1);
}
}
if (err) {
- rt_printk
+ printk
("comedi%d: pcl812: (%s at 0x%lx) A/D cmd IRQ without DRDY!\n",
dev->minor, dev->board_name, dev->iobase);
pcl812_ai_cancel(dev, s);
@@ -984,14 +985,14 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d)
/*
==============================================================================
*/
-static void transfer_from_dma_buf(struct comedi_device * dev, struct comedi_subdevice * s,
- short * ptr, unsigned int bufptr, unsigned int len)
+static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subdevice *s,
+ short *ptr, unsigned int bufptr, unsigned int len)
{
unsigned int i;
s->async->events = 0;
for (i = len; i; i--) {
- comedi_buf_put(s->async, ptr[bufptr++]); // get one sample
+ comedi_buf_put(s->async, ptr[bufptr++]); /* get one sample */
if (s->async->cur_chan == 0) {
devpriv->ai_act_scan++;
@@ -1019,7 +1020,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
short *ptr;
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n");
+ printk("pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n");
#endif
ptr = (short *) devpriv->dmabuf[devpriv->next_dma_buf];
len = (devpriv->dmabytestomove[devpriv->next_dma_buf] >> 1) -
@@ -1053,7 +1054,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
transfer_from_dma_buf(dev, s, ptr, bufptr, len);
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n");
+ printk("pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n");
#endif
return IRQ_HANDLED;
}
@@ -1061,7 +1062,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
/*
==============================================================================
*/
-static irqreturn_t interrupt_pcl812(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pcl812(int irq, void *d)
{
struct comedi_device *dev = d;
@@ -1079,33 +1080,33 @@ static irqreturn_t interrupt_pcl812(int irq, void *d PT_REGS_ARG)
/*
==============================================================================
*/
-static int pcl812_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
unsigned int top1, top2, i;
if (!devpriv->ai_dma)
- return 0; // poll is valid only for DMA transfer
+ return 0; /* poll is valid only for DMA transfer */
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
for (i = 0; i < 10; i++) {
- top1 = get_dma_residue(devpriv->ai_dma); // where is now DMA
+ top1 = get_dma_residue(devpriv->ai_dma); /* where is now DMA */
top2 = get_dma_residue(devpriv->ai_dma);
if (top1 == top2)
break;
}
if (top1 != top2) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
- top1 = devpriv->dmabytestomove[1 - devpriv->next_dma_buf] - top1; // where is now DMA in buffer
- top1 >>= 1; // sample position
+ top1 = devpriv->dmabytestomove[1 - devpriv->next_dma_buf] - top1; /* where is now DMA in buffer */
+ top1 >>= 1; /* sample position */
top2 = top1 - devpriv->ai_poll_ptr;
- if (top2 < 1) { // no new samples
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ if (top2 < 1) { /* no new samples */
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
@@ -1113,9 +1114,9 @@ static int pcl812_ai_poll(struct comedi_device * dev, struct comedi_subdevice *
(void *)devpriv->dmabuf[1 - devpriv->next_dma_buf],
devpriv->ai_poll_ptr, top2);
- devpriv->ai_poll_ptr = top1; // new buffer position
+ devpriv->ai_poll_ptr = top1; /* new buffer position */
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return s->async->buf_write_count - s->async->buf_read_count;
}
@@ -1123,27 +1124,27 @@ static int pcl812_ai_poll(struct comedi_device * dev, struct comedi_subdevice *
/*
==============================================================================
*/
-static void setup_range_channel(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int rangechan, char wait)
{
- unsigned char chan_reg = CR_CHAN(rangechan); // normal board
- unsigned char gain_reg = CR_RANGE(rangechan) + devpriv->range_correction; // gain index
+ unsigned char chan_reg = CR_CHAN(rangechan); /* normal board */
+ unsigned char gain_reg = CR_RANGE(rangechan) + devpriv->range_correction; /* gain index */
if ((chan_reg == devpriv->old_chan_reg)
&& (gain_reg == devpriv->old_gain_reg))
- return; // we can return, no change
+ return; /* we can return, no change */
devpriv->old_chan_reg = chan_reg;
devpriv->old_gain_reg = gain_reg;
if (devpriv->use_MPC) {
if (devpriv->use_diff) {
- chan_reg = chan_reg | 0x30; // DIFF inputs
+ chan_reg = chan_reg | 0x30; /* DIFF inputs */
} else {
if (chan_reg & 0x80) {
- chan_reg = chan_reg | 0x20; // SE inputs 8-15
+ chan_reg = chan_reg | 0x20; /* SE inputs 8-15 */
} else {
- chan_reg = chan_reg | 0x10; // SE inputs 0-7
+ chan_reg = chan_reg | 0x10; /* SE inputs 0-7 */
}
}
}
@@ -1152,23 +1153,23 @@ static void setup_range_channel(struct comedi_device * dev, struct comedi_subdev
outb(gain_reg, dev->iobase + PCL812_GAIN); /* select gain */
if (wait) {
- comedi_udelay(devpriv->max_812_ai_mode0_rangewait); // XXX this depends on selected range and can be very long for some high gain ranges!
+ udelay(devpriv->max_812_ai_mode0_rangewait); /* XXX this depends on selected range and can be very long for some high gain ranges! */
}
}
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2)
{
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1,
+ printk("pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1,
divisor2);
#endif
outb(0xb4, dev->iobase + PCL812_CTRCTL);
outb(0x74, dev->iobase + PCL812_CTRCTL);
- comedi_udelay(1);
+ udelay(1);
if (mode == 1) {
outb(divisor2 & 0xff, dev->iobase + PCL812_CTR2);
@@ -1177,14 +1178,14 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis
outb((divisor1 >> 8) & 0xff, dev->iobase + PCL812_CTR1);
}
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: END: start_pacer(...)\n");
+ printk("pcl812 EDBG: END: start_pacer(...)\n");
#endif
}
/*
==============================================================================
*/
-static void free_resources(struct comedi_device * dev)
+static void free_resources(struct comedi_device *dev)
{
if (dev->private) {
@@ -1196,7 +1197,7 @@ static void free_resources(struct comedi_device * dev)
free_dma(devpriv->dma);
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, this_board->io_range);
}
@@ -1204,19 +1205,19 @@ static void free_resources(struct comedi_device * dev)
/*
==============================================================================
*/
-static int pcl812_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n");
+ printk("pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n");
#endif
if (devpriv->ai_dma)
disable_dma(devpriv->dma);
outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */
outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); /* Stop A/D */
- start_pacer(dev, -1, 0, 0); // stop 8254
+ start_pacer(dev, -1, 0, 0); /* stop 8254 */
outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: END: pcl812_ai_cancel(...)\n");
+ printk("pcl812 EDBG: END: pcl812_ai_cancel(...)\n");
#endif
return 0;
}
@@ -1224,14 +1225,14 @@ static int pcl812_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
/*
==============================================================================
*/
-static void pcl812_reset(struct comedi_device * dev)
+static void pcl812_reset(struct comedi_device *dev)
{
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: BGN: pcl812_reset(...)\n");
+ printk("pcl812 EDBG: BGN: pcl812_reset(...)\n");
#endif
outb(0, dev->iobase + PCL812_MUX);
outb(0 + devpriv->range_correction, dev->iobase + PCL812_GAIN);
- devpriv->old_chan_reg = -1; // invalidate chain/gain memory
+ devpriv->old_chan_reg = -1; /* invalidate chain/gain memory */
devpriv->old_gain_reg = -1;
switch (this_board->board_type) {
@@ -1244,7 +1245,7 @@ static void pcl812_reset(struct comedi_device * dev)
case boardA821:
outb(0, dev->iobase + PCL812_DA1_LO);
outb(0, dev->iobase + PCL812_DA1_HI);
- start_pacer(dev, -1, 0, 0); // stop 8254
+ start_pacer(dev, -1, 0, 0); /* stop 8254 */
outb(0, dev->iobase + PCL812_DO_HI);
outb(0, dev->iobase + PCL812_DO_LO);
outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
@@ -1254,19 +1255,19 @@ static void pcl812_reset(struct comedi_device * dev)
case boardPCL813:
case boardISO813:
case boardACL8113:
- comedi_udelay(5);
+ udelay(5);
break;
}
- comedi_udelay(5);
+ udelay(5);
#ifdef PCL812_EXTDEBUG
- rt_printk("pcl812 EDBG: END: pcl812_reset(...)\n");
+ printk("pcl812 EDBG: END: pcl812_reset(...)\n");
#endif
}
/*
==============================================================================
*/
-static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret, subdev;
unsigned long iobase;
@@ -1286,7 +1287,8 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i
}
dev->iobase = iobase;
- if ((ret = alloc_private(dev, sizeof(struct pcl812_private))) < 0) {
+ ret = alloc_private(dev, sizeof(struct pcl812_private));
+ if (ret < 0) {
free_resources(dev);
return ret; /* Can't alloc mem */
}
@@ -1301,8 +1303,7 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk(", IRQ %u is out of allowed range, DISABLING IT", irq);
irq = 0; /* Bad IRQ */
} else {
- if (comedi_request_irq(irq, interrupt_pcl812, 0,
- "pcl812", dev)) {
+ if (request_irq(irq, interrupt_pcl812, 0, "pcl812", dev)) {
printk(", unable to allocate IRQ %u, DISABLING IT", irq);
irq = 0; /* Can't use IRQ */
} else {
@@ -1364,7 +1365,8 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (this_board->n_dochan > 0)
n_subdevices++;
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) {
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0) {
free_resources(dev);
return ret;
}
@@ -1570,7 +1572,7 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i
case boardACL8112:
devpriv->max_812_ai_mode0_rangewait = 1;
if (it->options[3] > 0)
- devpriv->use_ext_trg = 1; // we use external trigger
+ devpriv->use_ext_trg = 1; /* we use external trigger */
case boardA821:
devpriv->max_812_ai_mode0_rangewait = 1;
devpriv->mode_reg_int = (irq << 4) & 0xf0;
@@ -1594,11 +1596,11 @@ static int pcl812_attach(struct comedi_device * dev, struct comedi_devconfig * i
/*
==============================================================================
*/
-static int pcl812_detach(struct comedi_device * dev)
+static int pcl812_detach(struct comedi_device *dev)
{
#ifdef PCL812_EXTDEBUG
- rt_printk("comedi%d: pcl812: remove\n", dev->minor);
+ printk("comedi%d: pcl812: remove\n", dev->minor);
#endif
free_resources(dev);
return 0;
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 515ba74cc7fe..19465c1b53c3 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -43,38 +43,38 @@ Configuration Options:
#define DEBUG(x) x
-// boards constants
-// IO space len
+/* boards constants */
+/* IO space len */
#define PCLx1x_RANGE 16
-//#define outb(x,y) printk("OUTB(%x, 200+%d)\n", x,y-0x200); outb(x,y)
+/* #define outb(x,y) printk("OUTB(%x, 200+%d)\n", x,y-0x200); outb(x,y) */
-// INTEL 8254 counters
+/* INTEL 8254 counters */
#define PCL816_CTR0 4
#define PCL816_CTR1 5
#define PCL816_CTR2 6
-// R: counter read-back register W: counter control
+/* R: counter read-back register W: counter control */
#define PCL816_CTRCTL 7
-// R: A/D high byte W: A/D range control
+/* R: A/D high byte W: A/D range control */
#define PCL816_RANGE 9
-// W: clear INT request
+/* W: clear INT request */
#define PCL816_CLRINT 10
-// R: next mux scan channel W: mux scan channel & range control pointer
+/* R: next mux scan channel W: mux scan channel & range control pointer */
#define PCL816_MUX 11
-// R/W: operation control register
+/* R/W: operation control register */
#define PCL816_CONTROL 12
-// R: return status byte W: set DMA/IRQ
+/* R: return status byte W: set DMA/IRQ */
#define PCL816_STATUS 13
#define PCL816_STATUS_DRDY_MASK 0x80
-// R: low byte of A/D W: soft A/D trigger
+/* R: low byte of A/D W: soft A/D trigger */
#define PCL816_AD_LO 8
-// R: high byte of A/D W: A/D range control
+/* R: high byte of A/D W: A/D range control */
#define PCL816_AD_HI 9
-// type of interrupt handler
+/* type of interrupt handler */
#define INT_TYPE_AI1_INT 1
#define INT_TYPE_AI1_DMA 2
#define INT_TYPE_AI3_INT 4
@@ -83,7 +83,7 @@ Configuration Options:
#define INT_TYPE_AI1_DMA_RTC 9
#define INT_TYPE_AI3_DMA_RTC 10
-// RTC stuff...
+/* RTC stuff... */
#define RTC_IRQ 8
#define RTC_IO_EXTENT 0x10
#endif
@@ -103,35 +103,35 @@ static const struct comedi_lrange range_pcl816 = { 8, {
};
struct pcl816_board {
- const char *name; // board name
- int n_ranges; // len of range list
- int n_aichan; // num of A/D chans in diferencial mode
- unsigned int ai_ns_min; // minimal alllowed delay between samples (in ns)
- int n_aochan; // num of D/A chans
- int n_dichan; // num of DI chans
- int n_dochan; // num of DO chans
- const struct comedi_lrange *ai_range_type; // default A/D rangelist
- const struct comedi_lrange *ao_range_type; // dafault D/A rangelist
- unsigned int io_range; // len of IO space
- unsigned int IRQbits; // allowed interrupts
- unsigned int DMAbits; // allowed DMA chans
- int ai_maxdata; // maxdata for A/D
- int ao_maxdata; // maxdata for D/A
- int ai_chanlist; // allowed len of channel list A/D
- int ao_chanlist; // allowed len of channel list D/A
- int i8254_osc_base; // 1/frequency of on board oscilator in ns
+ const char *name; /* board name */
+ int n_ranges; /* len of range list */
+ int n_aichan; /* num of A/D chans in diferencial mode */
+ unsigned int ai_ns_min; /* minimal alllowed delay between samples (in ns) */
+ int n_aochan; /* num of D/A chans */
+ int n_dichan; /* num of DI chans */
+ int n_dochan; /* num of DO chans */
+ const struct comedi_lrange *ai_range_type; /* default A/D rangelist */
+ const struct comedi_lrange *ao_range_type; /* dafault D/A rangelist */
+ unsigned int io_range; /* len of IO space */
+ unsigned int IRQbits; /* allowed interrupts */
+ unsigned int DMAbits; /* allowed DMA chans */
+ int ai_maxdata; /* maxdata for A/D */
+ int ao_maxdata; /* maxdata for D/A */
+ int ai_chanlist; /* allowed len of channel list A/D */
+ int ao_chanlist; /* allowed len of channel list D/A */
+ int i8254_osc_base; /* 1/frequency of on board oscilator in ns */
};
static const struct pcl816_board boardtypes[] = {
{"pcl816", 8, 16, 10000, 1, 16, 16, &range_pcl816,
&range_pcl816, PCLx1x_RANGE,
- 0x00fc, // IRQ mask
- 0x0a, // DMA mask
- 0xffff, // 16-bit card
- 0xffff, // D/A maxdata
+ 0x00fc, /* IRQ mask */
+ 0x0a, /* DMA mask */
+ 0xffff, /* 16-bit card */
+ 0xffff, /* D/A maxdata */
1024,
- 1, // ao chan list
+ 1, /* ao chan list */
100},
{"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816,
&range_pcl816, PCLx1x_RANGE,
@@ -148,8 +148,8 @@ static const struct pcl816_board boardtypes[] = {
#define devpriv ((struct pcl816_private *)dev->private)
#define this_board ((const struct pcl816_board *)dev->board_ptr)
-static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl816_detach(struct comedi_device * dev);
+static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl816_detach(struct comedi_device *dev);
#ifdef unused
static int RTC_lock = 0; /* RTC lock */
@@ -157,55 +157,55 @@ static int RTC_timer_lock = 0; /* RTC int lock */
#endif
static struct comedi_driver driver_pcl816 = {
- driver_name:"pcl816",
- module:THIS_MODULE,
- attach:pcl816_attach,
- detach:pcl816_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl816_board),
+ .driver_name = "pcl816",
+ .module = THIS_MODULE,
+ .attach = pcl816_attach,
+ .detach = pcl816_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl816_board),
};
COMEDI_INITCLEANUP(driver_pcl816);
struct pcl816_private {
- unsigned int dma; // used DMA, 0=don't use DMA
- int dma_rtc; // 1=RTC used with DMA, 0=no RTC alloc
+ unsigned int dma; /* used DMA, 0=don't use DMA */
+ int dma_rtc; /* 1=RTC used with DMA, 0=no RTC alloc */
#ifdef unused
- unsigned long rtc_iobase; // RTC port region
+ unsigned long rtc_iobase; /* RTC port region */
unsigned int rtc_iosize;
unsigned int rtc_irq;
#endif
- unsigned long dmabuf[2]; // pointers to begin of DMA buffers
- unsigned int dmapages[2]; // len of DMA buffers in PAGE_SIZEs
- unsigned int hwdmaptr[2]; // hardware address of DMA buffers
- unsigned int hwdmasize[2]; // len of DMA buffers in Bytes
- unsigned int dmasamplsize; // size in samples hwdmasize[0]/2
- unsigned int last_top_dma; // DMA pointer in last RTC int
- int next_dma_buf; // which DMA buffer will be used next round
- long dma_runs_to_end; // how many we must permorm DMA transfer to end of record
- unsigned long last_dma_run; // how many bytes we must transfer on last DMA page
-
- unsigned int ai_scans; // len of scanlist
- unsigned char ai_neverending; // if=1, then we do neverending record (you must use cancel())
- int irq_free; // 1=have allocated IRQ
- int irq_blocked; // 1=IRQ now uses any subdev
+ unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */
+ unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */
+ unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */
+ unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */
+ unsigned int dmasamplsize; /* size in samples hwdmasize[0]/2 */
+ unsigned int last_top_dma; /* DMA pointer in last RTC int */
+ int next_dma_buf; /* which DMA buffer will be used next round */
+ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */
+ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */
+
+ unsigned int ai_scans; /* len of scanlist */
+ unsigned char ai_neverending; /* if=1, then we do neverending record (you must use cancel()) */
+ int irq_free; /* 1=have allocated IRQ */
+ int irq_blocked; /* 1=IRQ now uses any subdev */
#ifdef unused
- int rtc_irq_blocked; // 1=we now do AI with DMA&RTC
+ int rtc_irq_blocked; /* 1=we now do AI with DMA&RTC */
#endif
- int irq_was_now_closed; // when IRQ finish, there's stored int816_mode for last interrupt
- int int816_mode; // who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma
- struct comedi_subdevice *last_int_sub; // ptr to subdevice which now finish
- int ai_act_scan; // how many scans we finished
- unsigned int ai_act_chanlist[16]; // MUX setting for actual AI operations
- unsigned int ai_act_chanlist_len; // how long is actual MUX list
- unsigned int ai_act_chanlist_pos; // actual position in MUX list
- unsigned int ai_poll_ptr; // how many sampes transfer poll
- struct comedi_subdevice *sub_ai; // ptr to AI subdevice
+ int irq_was_now_closed; /* when IRQ finish, there's stored int816_mode for last interrupt */
+ int int816_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */
+ struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */
+ int ai_act_scan; /* how many scans we finished */
+ unsigned int ai_act_chanlist[16]; /* MUX setting for actual AI operations */
+ unsigned int ai_act_chanlist_len; /* how long is actual MUX list */
+ unsigned int ai_act_chanlist_pos; /* actual position in MUX list */
+ unsigned int ai_poll_ptr; /* how many sampes transfer poll */
+ struct comedi_subdevice *sub_ai; /* ptr to AI subdevice */
#ifdef unused
- struct timer_list rtc_irq_timer; // timer for RTC sanity check
- unsigned long rtc_freq; // RTC int freq
+ struct timer_list rtc_irq_timer; /* timer for RTC sanity check */
+ unsigned long rtc_freq; /* RTC int freq */
#endif
};
@@ -213,36 +213,36 @@ struct pcl816_private {
/*
==============================================================================
*/
-static int check_and_setup_channel_list(struct comedi_device * dev,
- struct comedi_subdevice * s, unsigned int *chanlist, int chanlen);
-static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static int check_and_setup_channel_list(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int *chanlist, int chanlen);
+static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2);
#ifdef unused
static int set_rtc_irq_bit(unsigned char bit);
#endif
-static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
-static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
+static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
+static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
/*
==============================================================================
ANALOG INPUT MODE0, 816 cards, slow version
*/
-static int pcl816_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl816_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int timeout;
DPRINTK("mode 0 analog input\n");
- // software trigger, DMA and INT off
+ /* software trigger, DMA and INT off */
outb(0, dev->iobase + PCL816_CONTROL);
- // clear INT (conversion end) flag
+ /* clear INT (conversion end) flag */
outb(0, dev->iobase + PCL816_CLRINT);
- // Set the input channel
+ /* Set the input channel */
outb(CR_CHAN(insn->chanspec) & 0xf, dev->iobase + PCL816_MUX);
outb(CR_RANGE(insn->chanspec), dev->iobase + PCL816_RANGE); /* select gain */
@@ -254,7 +254,7 @@ static int pcl816_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
while (timeout--) {
if (!(inb(dev->iobase + PCL816_STATUS) &
PCL816_STATUS_DRDY_MASK)) {
- // return read value
+ /* return read value */
data[n] =
((inb(dev->iobase +
PCL816_AD_HI) << 8) |
@@ -263,9 +263,9 @@ static int pcl816_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
outb(0, dev->iobase + PCL816_CLRINT); /* clear INT (conversion end) flag */
break;
}
- comedi_udelay(1);
+ udelay(1);
}
- // Return timeout error
+ /* Return timeout error */
if (!timeout) {
comedi_error(dev, "A/D insn timeout\n");
data[0] = 0;
@@ -293,9 +293,9 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d)
if (!(inb(dev->iobase + PCL816_STATUS) &
PCL816_STATUS_DRDY_MASK))
break;
- comedi_udelay(1);
+ udelay(1);
}
- if (!timeout) { // timeout, bail error
+ if (!timeout) { /* timeout, bail error */
outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */
comedi_error(dev, "A/D mode1/3 IRQ without DRDY!");
pcl816_ai_cancel(dev, s);
@@ -305,7 +305,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d)
}
- // get the sample
+ /* get the sample */
low = inb(dev->iobase + PCL816_AD_LO);
hi = inb(dev->iobase + PCL816_AD_HI);
@@ -334,8 +334,8 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d)
==============================================================================
analog input dma mode 1 & 3, 816 cards
*/
-static void transfer_from_dma_buf(struct comedi_device * dev, struct comedi_subdevice * s,
- short * ptr, unsigned int bufptr, unsigned int len)
+static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subdevice *s,
+ short *ptr, unsigned int bufptr, unsigned int len)
{
int i;
@@ -352,7 +352,7 @@ static void transfer_from_dma_buf(struct comedi_device * dev, struct comedi_subd
}
if (!devpriv->ai_neverending)
- if (devpriv->ai_act_scan >= devpriv->ai_scans) { // all data sampled
+ if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */
pcl816_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_BLOCK;
@@ -374,12 +374,12 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d)
disable_dma(devpriv->dma);
this_dma_buf = devpriv->next_dma_buf;
- if ((devpriv->dma_runs_to_end > -1) || devpriv->ai_neverending) { // switch dma bufs
+ if ((devpriv->dma_runs_to_end > -1) || devpriv->ai_neverending) { /* switch dma bufs */
devpriv->next_dma_buf = 1 - devpriv->next_dma_buf;
set_dma_mode(devpriv->dma, DMA_MODE_READ);
dma_flags = claim_dma_lock();
-// clear_dma_ff (devpriv->dma);
+/* clear_dma_ff (devpriv->dma); */
set_dma_addr(devpriv->dma,
devpriv->hwdmaptr[devpriv->next_dma_buf]);
if (devpriv->dma_runs_to_end) {
@@ -409,7 +409,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d)
==============================================================================
INT procedure
*/
-static irqreturn_t interrupt_pcl816(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pcl816(int irq, void *d)
{
struct comedi_device *dev = d;
DPRINTK("<I>");
@@ -433,7 +433,7 @@ static irqreturn_t interrupt_pcl816(int irq, void *d PT_REGS_ARG)
(!devpriv->int816_mode)) {
if (devpriv->irq_was_now_closed) {
devpriv->irq_was_now_closed = 0;
- // comedi_error(dev,"last IRQ..");
+ /* comedi_error(dev,"last IRQ.."); */
return IRQ_HANDLED;
}
comedi_error(dev, "bad IRQ!");
@@ -447,28 +447,28 @@ static irqreturn_t interrupt_pcl816(int irq, void *d PT_REGS_ARG)
==============================================================================
COMMAND MODE
*/
-static void pcl816_cmdtest_out(int e, struct comedi_cmd * cmd)
+static void pcl816_cmdtest_out(int e, struct comedi_cmd *cmd)
{
- rt_printk("pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
+ printk("pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
- rt_printk("pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
+ printk("pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
- rt_printk("pcl816 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
+ printk("pcl816 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
cmd->scan_end_src);
- rt_printk("pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e,
+ printk("pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e,
cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
}
/*
==============================================================================
*/
-static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
- DEBUG(rt_printk("pcl816 pcl812_ai_cmdtest\n");
+ DEBUG(printk("pcl816 pcl812_ai_cmdtest\n");
pcl816_cmdtest_out(-1, cmd););
/* step 1: make sure trigger sources are trivially valid */
@@ -482,7 +482,7 @@ static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
err++;
- if (!cmd->convert_src & (TRIG_EXT | TRIG_TIMER))
+ if (!(cmd->convert_src & (TRIG_EXT | TRIG_TIMER)))
err++;
tmp = cmd->scan_end_src;
@@ -597,7 +597,7 @@ static int pcl816_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned int divisor1 = 0, divisor2 = 0, dma_flags, bytes, dmairq;
struct comedi_cmd *cmd = &s->async->cmd;
@@ -610,7 +610,7 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
return -EINVAL;
if (cmd->scan_end_arg != cmd->chanlist_len)
return -EINVAL;
-// if(cmd->chanlist_len>MAX_CHANLIST_LEN) return -EINVAL;
+/* if(cmd->chanlist_len>MAX_CHANLIST_LEN) return -EINVAL; */
if (devpriv->irq_blocked)
return -EBUSY;
@@ -621,7 +621,7 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
- if (divisor1 == 1) { // PCL816 crash if any divisor is set to 1
+ if (divisor1 == 1) { /* PCL816 crash if any divisor is set to 1 */
divisor1 = 2;
divisor2 /= 2;
}
@@ -631,12 +631,12 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
}
}
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
if (!check_and_setup_channel_list(dev, s, cmd->chanlist,
cmd->chanlist_len))
return -EINVAL;
- comedi_udelay(1);
+ udelay(1);
devpriv->ai_act_scan = 0;
s->async->cur_chan = 0;
@@ -652,19 +652,19 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
devpriv->ai_neverending = 1;
}
- if ((cmd->flags & TRIG_WAKE_EOS)) { // don't we want wake up every scan?
+ if ((cmd->flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? */
printk("pl816: You wankt WAKE_EOS but I dont want handle it");
- // devpriv->ai_eos=1;
- //if (devpriv->ai_n_chan==1)
- // devpriv->dma=0; // DMA is useless for this situation
+ /* devpriv->ai_eos=1; */
+ /* if (devpriv->ai_n_chan==1) */
+ /* devpriv->dma=0; // DMA is useless for this situation */
}
if (devpriv->dma) {
bytes = devpriv->hwdmasize[0];
if (!devpriv->ai_neverending) {
- bytes = s->async->cmd.chanlist_len * s->async->cmd.chanlist_len * sizeof(short); // how many
- devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; // how many DMA pages we must fill
- devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; //on last dma transfer must be moved
+ bytes = s->async->cmd.chanlist_len * s->async->cmd.chanlist_len * sizeof(short); /* how many */
+ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fill */
+ devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */
devpriv->dma_runs_to_end--;
if (devpriv->dma_runs_to_end >= 0)
bytes = devpriv->hwdmasize[0];
@@ -687,14 +687,14 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
switch (cmd->convert_src) {
case TRIG_TIMER:
devpriv->int816_mode = INT_TYPE_AI1_DMA;
- outb(0x32, dev->iobase + PCL816_CONTROL); // Pacer+IRQ+DMA
- outb(dmairq, dev->iobase + PCL816_STATUS); // write irq and DMA to card
+ outb(0x32, dev->iobase + PCL816_CONTROL); /* Pacer+IRQ+DMA */
+ outb(dmairq, dev->iobase + PCL816_STATUS); /* write irq and DMA to card */
break;
default:
devpriv->int816_mode = INT_TYPE_AI3_DMA;
- outb(0x34, dev->iobase + PCL816_CONTROL); // Ext trig+IRQ+DMA
- outb(dmairq, dev->iobase + PCL816_STATUS); // write irq to card
+ outb(0x34, dev->iobase + PCL816_CONTROL); /* Ext trig+IRQ+DMA */
+ outb(dmairq, dev->iobase + PCL816_STATUS); /* write irq to card */
break;
}
@@ -702,32 +702,32 @@ static int pcl816_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-static int pcl816_ai_poll(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
unsigned int top1, top2, i;
if (!devpriv->dma)
- return 0; // poll is valid only for DMA transfer
+ return 0; /* poll is valid only for DMA transfer */
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
for (i = 0; i < 20; i++) {
- top1 = get_dma_residue(devpriv->dma); // where is now DMA
+ top1 = get_dma_residue(devpriv->dma); /* where is now DMA */
top2 = get_dma_residue(devpriv->dma);
if (top1 == top2)
break;
}
if (top1 != top2) {
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
- top1 = devpriv->hwdmasize[0] - top1; // where is now DMA in buffer
- top1 >>= 1; // sample position
+ top1 = devpriv->hwdmasize[0] - top1; /* where is now DMA in buffer */
+ top1 >>= 1; /* sample position */
top2 = top1 - devpriv->ai_poll_ptr;
- if (top2 < 1) { // no new samples
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ if (top2 < 1) { /* no new samples */
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
}
@@ -735,8 +735,8 @@ static int pcl816_ai_poll(struct comedi_device * dev, struct comedi_subdevice *
(short *) devpriv->dmabuf[devpriv->next_dma_buf],
devpriv->ai_poll_ptr, top2);
- devpriv->ai_poll_ptr = top1; // new buffer position
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ devpriv->ai_poll_ptr = top1; /* new buffer position */
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return s->async->buf_write_count - s->async->buf_read_count;
}
@@ -745,16 +745,16 @@ static int pcl816_ai_poll(struct comedi_device * dev, struct comedi_subdevice *
==============================================================================
cancel any mode 1-4 AI
*/
-static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
-// DEBUG(rt_printk("pcl816_ai_cancel()\n");)
+/* DEBUG(printk("pcl816_ai_cancel()\n");) */
if (devpriv->irq_blocked > 0) {
switch (devpriv->int816_mode) {
#ifdef unused
case INT_TYPE_AI1_DMA_RTC:
case INT_TYPE_AI3_DMA_RTC:
- set_rtc_irq_bit(0); // stop RTC
+ set_rtc_irq_bit(0); /* stop RTC */
del_timer(&devpriv->rtc_irq_timer);
#endif
case INT_TYPE_AI1_DMA:
@@ -763,7 +763,7 @@ static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
case INT_TYPE_AI1_INT:
case INT_TYPE_AI3_INT:
outb(inb(dev->iobase + PCL816_CONTROL) & 0x73, dev->iobase + PCL816_CONTROL); /* Stop A/D */
- comedi_udelay(1);
+ udelay(1);
outb(0, dev->iobase + PCL816_CONTROL); /* Stop A/D */
outb(0xb0, dev->iobase + PCL816_CTRCTL); /* Stop pacer */
outb(0x70, dev->iobase + PCL816_CTRCTL);
@@ -776,12 +776,12 @@ static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
devpriv->irq_was_now_closed = devpriv->int816_mode;
devpriv->int816_mode = 0;
devpriv->last_int_sub = s;
-// s->busy = 0;
+/* s->busy = 0; */
break;
}
}
- DEBUG(rt_printk("comedi: pcl816_ai_cancel() successful\n");
+ DEBUG(printk("comedi: pcl816_ai_cancel() successful\n");
)
return 0;
}
@@ -793,34 +793,34 @@ static int pcl816_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
static int pcl816_check(unsigned long iobase)
{
outb(0x00, iobase + PCL816_MUX);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL816_MUX) != 0x00)
- return 1; //there isn't card
+ return 1; /* there isn't card */
outb(0x55, iobase + PCL816_MUX);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL816_MUX) != 0x55)
- return 1; //there isn't card
+ return 1; /* there isn't card */
outb(0x00, iobase + PCL816_MUX);
- comedi_udelay(1);
+ udelay(1);
outb(0x18, iobase + PCL816_CONTROL);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL816_CONTROL) != 0x18)
- return 1; //there isn't card
- return 0; // ok, card exist
+ return 1; /* there isn't card */
+ return 0; /* ok, card exist */
}
/*
==============================================================================
reset whole PCL-816 cards
*/
-static void pcl816_reset(struct comedi_device * dev)
+static void pcl816_reset(struct comedi_device *dev)
{
-// outb (0, dev->iobase + PCL818_DA_LO); // DAC=0V
-// outb (0, dev->iobase + PCL818_DA_HI);
-// comedi_udelay (1);
-// outb (0, dev->iobase + PCL818_DO_HI); // DO=$0000
-// outb (0, dev->iobase + PCL818_DO_LO);
-// comedi_udelay (1);
+/* outb (0, dev->iobase + PCL818_DA_LO); DAC=0V */
+/* outb (0, dev->iobase + PCL818_DA_HI); */
+/* udelay (1); */
+/* outb (0, dev->iobase + PCL818_DO_HI); DO=$0000 */
+/* outb (0, dev->iobase + PCL818_DO_LO); */
+/* udelay (1); */
outb(0, dev->iobase + PCL816_CONTROL);
outb(0, dev->iobase + PCL816_MUX);
outb(0, dev->iobase + PCL816_CLRINT);
@@ -835,16 +835,16 @@ static void pcl816_reset(struct comedi_device * dev)
Start/stop pacer onboard pacer
*/
static void
-start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2)
{
outb(0x32, dev->iobase + PCL816_CTRCTL);
outb(0xff, dev->iobase + PCL816_CTR0);
outb(0x00, dev->iobase + PCL816_CTR0);
- comedi_udelay(1);
- outb(0xb4, dev->iobase + PCL816_CTRCTL); // set counter 2 as mode 3
- outb(0x74, dev->iobase + PCL816_CTRCTL); // set counter 1 as mode 3
- comedi_udelay(1);
+ udelay(1);
+ outb(0xb4, dev->iobase + PCL816_CTRCTL); /* set counter 2 as mode 3 */
+ outb(0x74, dev->iobase + PCL816_CTRCTL); /* set counter 1 as mode 3 */
+ udelay(1);
if (mode == 1) {
DPRINTK("mode %d, divisor1 %d, divisor2 %d\n", mode, divisor1,
@@ -856,7 +856,7 @@ start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
}
/* clear pending interrupts (just in case) */
-// outb(0, dev->iobase + PCL816_CLRINT);
+/* outb(0, dev->iobase + PCL816_CLRINT); */
}
/*
@@ -865,49 +865,49 @@ start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
If it's ok, then program scan/gain logic
*/
static int
-check_and_setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+check_and_setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, int chanlen)
{
unsigned int chansegment[16];
unsigned int i, nowmustbechan, seglen, segpos;
- // correct channel and range number check itself comedi/range.c
+ /* correct channel and range number check itself comedi/range.c */
if (chanlen < 1) {
comedi_error(dev, "range/channel list is empty!");
return 0;
}
if (chanlen > 1) {
- chansegment[0] = chanlist[0]; // first channel is everytime ok
+ chansegment[0] = chanlist[0]; /* first channel is everytime ok */
for (i = 1, seglen = 1; i < chanlen; i++, seglen++) {
- // build part of chanlist
- DEBUG(rt_printk("%d. %d %d\n", i, CR_CHAN(chanlist[i]),
+ /* build part of chanlist */
+ DEBUG(printk("%d. %d %d\n", i, CR_CHAN(chanlist[i]),
CR_RANGE(chanlist[i]));
)
if (chanlist[0] == chanlist[i])
- break; // we detect loop, this must by finish
+ break; /* we detect loop, this must by finish */
nowmustbechan =
(CR_CHAN(chansegment[i - 1]) + 1) % chanlen;
if (nowmustbechan != CR_CHAN(chanlist[i])) {
- // channel list isn't continous :-(
- rt_printk
+ /* channel list isn't continous :-( */
+ printk
("comedi%d: pcl816: channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n",
dev->minor, i, CR_CHAN(chanlist[i]),
nowmustbechan, CR_CHAN(chanlist[0]));
return 0;
}
- chansegment[i] = chanlist[i]; // well, this is next correct channel in list
+ chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */
}
- for (i = 0, segpos = 0; i < chanlen; i++) { // check whole chanlist
- DEBUG(rt_printk("%d %d=%d %d\n",
+ for (i = 0, segpos = 0; i < chanlen; i++) { /* check whole chanlist */
+ DEBUG(printk("%d %d=%d %d\n",
CR_CHAN(chansegment[i % seglen]),
CR_RANGE(chansegment[i % seglen]),
CR_CHAN(chanlist[i]),
CR_RANGE(chanlist[i]));
)
if (chanlist[i] != chansegment[i % seglen]) {
- rt_printk
+ printk
("comedi%d: pcl816: bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
dev->minor, i, CR_CHAN(chansegment[i]),
CR_RANGE(chansegment[i]),
@@ -915,7 +915,7 @@ check_and_setup_channel_list(struct comedi_device * dev, struct comedi_subdevice
CR_CHAN(chanlist[i % seglen]),
CR_RANGE(chanlist[i % seglen]),
CR_AREF(chansegment[i % seglen]));
- return 0; // chan/gain list is strange
+ return 0; /* chan/gain list is strange */
}
}
} else {
@@ -925,17 +925,17 @@ check_and_setup_channel_list(struct comedi_device * dev, struct comedi_subdevice
devpriv->ai_act_chanlist_len = seglen;
devpriv->ai_act_chanlist_pos = 0;
- for (i = 0; i < seglen; i++) { // store range list to card
+ for (i = 0; i < seglen; i++) { /* store range list to card */
devpriv->ai_act_chanlist[i] = CR_CHAN(chanlist[i]);
outb(CR_CHAN(chanlist[0]) & 0xf, dev->iobase + PCL816_MUX);
outb(CR_RANGE(chanlist[0]), dev->iobase + PCL816_RANGE); /* select gain */
}
- comedi_udelay(1);
+ udelay(1);
outb(devpriv->ai_act_chanlist[0] | (devpriv->ai_act_chanlist[seglen - 1] << 4), dev->iobase + PCL816_MUX); /* select channel interval to scan */
- return 1; // we can serve this with MUX logic
+ return 1; /* we can serve this with MUX logic */
}
#ifdef unused
@@ -979,9 +979,9 @@ static int set_rtc_irq_bit(unsigned char bit)
==============================================================================
Free any resources that we have claimed
*/
-static void free_resources(struct comedi_device * dev)
+static void free_resources(struct comedi_device *dev)
{
- //rt_printk("free_resource()\n");
+ /* printk("free_resource()\n"); */
if (dev->private) {
pcl816_ai_cancel(dev, devpriv->sub_ai);
pcl816_reset(dev);
@@ -993,7 +993,7 @@ static void free_resources(struct comedi_device * dev)
free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
#ifdef unused
if (devpriv->rtc_irq)
- comedi_free_irq(devpriv->rtc_irq, dev);
+ free_irq(devpriv->rtc_irq, dev);
if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
@@ -1006,7 +1006,7 @@ static void free_resources(struct comedi_device * dev)
free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, this_board->io_range);
- //rt_printk("free_resource() end\n");
+ /* printk("free_resource() end\n"); */
}
/*
@@ -1015,13 +1015,13 @@ static void free_resources(struct comedi_device * dev)
Initialization
*/
-static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
unsigned int irq, dma;
unsigned long pages;
- //int i;
+ /* int i; */
struct comedi_subdevice *s;
/* claim our I/O space */
@@ -1030,18 +1030,19 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
this_board->name, iobase);
if (!request_region(iobase, this_board->io_range, "pcl816")) {
- rt_printk("I/O port conflict\n");
+ printk("I/O port conflict\n");
return -EIO;
}
dev->iobase = iobase;
if (pcl816_check(iobase)) {
- rt_printk(", I cann't detect board. FAIL!\n");
+ printk(", I cann't detect board. FAIL!\n");
return -EIO;
}
- if ((ret = alloc_private(dev, sizeof(struct pcl816_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct pcl816_private));
+ if (ret < 0)
return ret; /* Can't alloc mem */
/* set up some name stuff */
@@ -1053,19 +1054,18 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
irq = it->options[1];
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
- rt_printk
+ printk
(", IRQ %u is out of allowed range, DISABLING IT",
irq);
irq = 0; /* Bad IRQ */
} else {
- if (comedi_request_irq(irq, interrupt_pcl816, 0,
- "pcl816", dev)) {
- rt_printk
+ if (request_irq(irq, interrupt_pcl816, 0, "pcl816", dev)) {
+ printk
(", unable to allocate IRQ %u, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%u", irq);
+ printk(", irq=%u", irq);
}
}
}
@@ -1084,7 +1084,7 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
#ifdef unused
/* grab RTC for DMA operations */
devpriv->dma_rtc = 0;
- if (it->options[2] > 0) { // we want to use DMA
+ if (it->options[2] > 0) { /* we want to use DMA */
if (RTC_lock == 0) {
if (!request_region(RTC_PORT(0), RTC_IO_EXTENT,
"pcl816 (RTC)"))
@@ -1094,12 +1094,11 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->rtc_iosize = RTC_IO_EXTENT;
RTC_lock++;
#ifdef UNTESTED_CODE
- if (!comedi_request_irq(RTC_IRQ,
- interrupt_pcl816_ai_mode13_dma_rtc, 0,
+ if (!request_irq(RTC_IRQ, interrupt_pcl816_ai_mode13_dma_rtc, 0,
"pcl816 DMA (RTC)", dev)) {
devpriv->dma_rtc = 1;
devpriv->rtc_irq = RTC_IRQ;
- rt_printk(", dma_irq=%u", devpriv->rtc_irq);
+ printk(", dma_irq=%u", devpriv->rtc_irq);
} else {
RTC_lock--;
if (RTC_lock == 0) {
@@ -1130,34 +1129,34 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
goto no_dma; /* DMA disabled */
if (((1 << dma) & this_board->DMAbits) == 0) {
- rt_printk(", DMA is out of allowed range, FAIL!\n");
+ printk(", DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
ret = request_dma(dma, "pcl816");
if (ret) {
- rt_printk(", unable to allocate DMA %u, FAIL!\n", dma);
+ printk(", unable to allocate DMA %u, FAIL!\n", dma);
return -EBUSY; /* DMA isn't free */
}
devpriv->dma = dma;
- rt_printk(", dma=%u", dma);
+ printk(", dma=%u", dma);
pages = 2; /* we need 16KB */
devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[0]) {
- rt_printk(", unable to allocate DMA buffer, FAIL!\n");
+ printk(", unable to allocate DMA buffer, FAIL!\n");
/* maybe experiment with try_to_free_pages() will help .... */
return -EBUSY; /* no buffer :-( */
}
devpriv->dmapages[0] = pages;
devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]);
devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE;
- //rt_printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE);
+ /* printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); */
- if (devpriv->dma_rtc == 0) { // we must do duble buff :-(
+ if (devpriv->dma_rtc == 0) { /* we must do duble buff :-( */
devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[1]) {
- rt_printk
+ printk
(", unable to allocate DMA buffer, FAIL!\n");
return -EBUSY;
}
@@ -1177,7 +1176,9 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (this_board->n_dochan > 0)
subdevs[3] = COMEDI_SUBD_DO;
*/
- if ((ret = alloc_subdevices(dev, 1)) < 0)
+
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -1188,7 +1189,7 @@ static int pcl816_attach(struct comedi_device * dev, struct comedi_devconfig * i
s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
s->n_chan = this_board->n_aichan;
s->subdev_flags |= SDF_DIFF;
- //printk (", %dchans DIFF DAC - %d", s->n_chan, i);
+ /* printk (", %dchans DIFF DAC - %d", s->n_chan, i); */
s->maxdata = this_board->ai_maxdata;
s->len_chanlist = this_board->ai_chanlist;
s->range_table = this_board->ai_range_type;
@@ -1229,7 +1230,7 @@ case COMEDI_SUBD_DO:
pcl816_reset(dev);
- rt_printk("\n");
+ printk("\n");
return 0;
}
@@ -1238,9 +1239,9 @@ case COMEDI_SUBD_DO:
==============================================================================
Removes device
*/
-static int pcl816_detach(struct comedi_device * dev)
+static int pcl816_detach(struct comedi_device *dev)
{
- DEBUG(rt_printk("comedi%d: pcl816: remove\n", dev->minor);
+ DEBUG(printk("comedi%d: pcl816: remove\n", dev->minor);
)
free_resources(dev);
#ifdef unused
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
index 43a9d56c6a43..607c71744bfc 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -107,9 +107,9 @@ A word or two about DMA. Driver support DMA operations at two ways:
#include "8253.h"
-// #define PCL818_MODE13_AO 1
+/* #define PCL818_MODE13_AO 1 */
-// boards constants
+/* boards constants */
#define boardPCL818L 0
#define boardPCL818H 1
@@ -118,60 +118,60 @@ A word or two about DMA. Driver support DMA operations at two ways:
#define boardPCL818 4
#define boardPCL718 5
-// IO space len
+/* IO space len */
#define PCLx1x_RANGE 16
-// IO space len if we use FIFO
+/* IO space len if we use FIFO */
#define PCLx1xFIFO_RANGE 32
-// W: clear INT request
+/* W: clear INT request */
#define PCL818_CLRINT 8
-// R: return status byte
+/* R: return status byte */
#define PCL818_STATUS 8
-// R: A/D high byte W: A/D range control
+/* R: A/D high byte W: A/D range control */
#define PCL818_RANGE 1
-// R: next mux scan channel W: mux scan channel & range control pointer
+/* R: next mux scan channel W: mux scan channel & range control pointer */
#define PCL818_MUX 2
-// R/W: operation control register
+/* R/W: operation control register */
#define PCL818_CONTROL 9
-// W: counter enable
+/* W: counter enable */
#define PCL818_CNTENABLE 10
-// R: low byte of A/D W: soft A/D trigger
+/* R: low byte of A/D W: soft A/D trigger */
#define PCL818_AD_LO 0
-// R: high byte of A/D W: A/D range control
+/* R: high byte of A/D W: A/D range control */
#define PCL818_AD_HI 1
-// W: D/A low&high byte
+/* W: D/A low&high byte */
#define PCL818_DA_LO 4
#define PCL818_DA_HI 5
-// R: low&high byte of DI
+/* R: low&high byte of DI */
#define PCL818_DI_LO 3
#define PCL818_DI_HI 11
-// W: low&high byte of DO
+/* W: low&high byte of DO */
#define PCL818_DO_LO 3
#define PCL818_DO_HI 11
-// W: PCL718 second D/A
+/* W: PCL718 second D/A */
#define PCL718_DA2_LO 6
#define PCL718_DA2_HI 7
-// counters
+/* counters */
#define PCL818_CTR0 12
#define PCL818_CTR1 13
#define PCL818_CTR2 14
-// W: counter control
+/* W: counter control */
#define PCL818_CTRCTL 15
-// W: fifo enable/disable
+/* W: fifo enable/disable */
#define PCL818_FI_ENABLE 6
-// W: fifo interrupt clear
+/* W: fifo interrupt clear */
#define PCL818_FI_INTCLR 20
-// W: fifo interrupt clear
+/* W: fifo interrupt clear */
#define PCL818_FI_FLUSH 25
-// R: fifo status
+/* R: fifo status */
#define PCL818_FI_STATUS 25
-// R: one record from FIFO
+/* R: one record from FIFO */
#define PCL818_FI_DATALO 23
#define PCL818_FI_DATAHI 23
-// type of interrupt handler
+/* type of interrupt handler */
#define INT_TYPE_AI1_INT 1
#define INT_TYPE_AI1_DMA 2
#define INT_TYPE_AI1_FIFO 3
@@ -184,7 +184,7 @@ A word or two about DMA. Driver support DMA operations at two ways:
#endif
#ifdef unused
-// RTC stuff...
+/* RTC stuff... */
#define INT_TYPE_AI1_DMA_RTC 9
#define INT_TYPE_AI3_DMA_RTC 10
@@ -244,8 +244,8 @@ static const struct comedi_lrange range718_bipolar0_5 = { 1, {BIP_RANGE(0.5),} }
static const struct comedi_lrange range718_unipolar2 = { 1, {UNI_RANGE(2),} };
static const struct comedi_lrange range718_unipolar1 = { 1, {BIP_RANGE(1),} };
-static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl818_detach(struct comedi_device * dev);
+static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl818_detach(struct comedi_device *dev);
#ifdef unused
static int RTC_lock = 0; /* RTC lock */
@@ -254,22 +254,22 @@ static int RTC_timer_lock = 0; /* RTC int lock */
struct pcl818_board {
- const char *name; // driver name
- int n_ranges; // len of range list
- int n_aichan_se; // num of A/D chans in single ended mode
- int n_aichan_diff; // num of A/D chans in diferencial mode
- unsigned int ns_min; // minimal alllowed delay between samples (in ns)
- int n_aochan; // num of D/A chans
- int n_dichan; // num of DI chans
- int n_dochan; // num of DO chans
- const struct comedi_lrange *ai_range_type; // default A/D rangelist
- const struct comedi_lrange *ao_range_type; // default D/A rangelist
- unsigned int io_range; // len of IO space
- unsigned int IRQbits; // allowed interrupts
- unsigned int DMAbits; // allowed DMA chans
- int ai_maxdata; // maxdata for A/D
- int ao_maxdata; // maxdata for D/A
- unsigned char fifo; // 1=board has FIFO
+ const char *name; /* driver name */
+ int n_ranges; /* len of range list */
+ int n_aichan_se; /* num of A/D chans in single ended mode */
+ int n_aichan_diff; /* num of A/D chans in diferencial mode */
+ unsigned int ns_min; /* minimal alllowed delay between samples (in ns) */
+ int n_aochan; /* num of D/A chans */
+ int n_dichan; /* num of DI chans */
+ int n_dochan; /* num of DO chans */
+ const struct comedi_lrange *ai_range_type; /* default A/D rangelist */
+ const struct comedi_lrange *ao_range_type; /* default D/A rangelist */
+ unsigned int io_range; /* len of IO space */
+ unsigned int IRQbits; /* allowed interrupts */
+ unsigned int DMAbits; /* allowed DMA chans */
+ int ai_maxdata; /* maxdata for A/D */
+ int ao_maxdata; /* maxdata for D/A */
+ unsigned char fifo; /* 1=board has FIFO */
int is_818;
};
@@ -302,67 +302,67 @@ static const struct pcl818_board boardtypes[] = {
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl818_board))
static struct comedi_driver driver_pcl818 = {
- driver_name:"pcl818",
- module:THIS_MODULE,
- attach:pcl818_attach,
- detach:pcl818_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl818_board),
+ .driver_name = "pcl818",
+ .module = THIS_MODULE,
+ .attach = pcl818_attach,
+ .detach = pcl818_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl818_board),
};
COMEDI_INITCLEANUP(driver_pcl818);
struct pcl818_private {
- unsigned int dma; // used DMA, 0=don't use DMA
- int dma_rtc; // 1=RTC used with DMA, 0=no RTC alloc
+ unsigned int dma; /* used DMA, 0=don't use DMA */
+ int dma_rtc; /* 1=RTC used with DMA, 0=no RTC alloc */
unsigned int io_range;
#ifdef unused
- unsigned long rtc_iobase; // RTC port region
+ unsigned long rtc_iobase; /* RTC port region */
unsigned int rtc_iosize;
unsigned int rtc_irq;
- struct timer_list rtc_irq_timer; // timer for RTC sanity check
- unsigned long rtc_freq; // RTC int freq
- int rtc_irq_blocked; // 1=we now do AI with DMA&RTC
+ struct timer_list rtc_irq_timer; /* timer for RTC sanity check */
+ unsigned long rtc_freq; /* RTC int freq */
+ int rtc_irq_blocked; /* 1=we now do AI with DMA&RTC */
#endif
- unsigned long dmabuf[2]; // pointers to begin of DMA buffers
- unsigned int dmapages[2]; // len of DMA buffers in PAGE_SIZEs
- unsigned int hwdmaptr[2]; // hardware address of DMA buffers
- unsigned int hwdmasize[2]; // len of DMA buffers in Bytes
- unsigned int dmasamplsize; // size in samples hwdmasize[0]/2
- unsigned int last_top_dma; // DMA pointer in last RTC int
- int next_dma_buf; // which DMA buffer will be used next round
- long dma_runs_to_end; // how many we must permorm DMA transfer to end of record
- unsigned long last_dma_run; // how many bytes we must transfer on last DMA page
- unsigned char neverending_ai; // if=1, then we do neverending record (you must use cancel())
- unsigned int ns_min; // manimal alllowed delay between samples (in us) for actual card
- int i8253_osc_base; // 1/frequency of on board oscilator in ns
- int irq_free; // 1=have allocated IRQ
- int irq_blocked; // 1=IRQ now uses any subdev
- int irq_was_now_closed; // when IRQ finish, there's stored int818_mode for last interrupt
- int ai_mode; // who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma
- struct comedi_subdevice *last_int_sub; // ptr to subdevice which now finish
- int ai_act_scan; // how many scans we finished
- int ai_act_chan; // actual position in actual scan
- unsigned int act_chanlist[16]; // MUX setting for actual AI operations
- unsigned int act_chanlist_len; // how long is actual MUX list
- unsigned int act_chanlist_pos; // actual position in MUX list
- unsigned int ai_scans; // len of scanlist
- unsigned int ai_n_chan; // how many channels is measured
- unsigned int *ai_chanlist; // actaul chanlist
- unsigned int ai_flags; // flaglist
- unsigned int ai_data_len; // len of data buffer
- short *ai_data; // data buffer
- unsigned int ai_timer1; // timers
+ unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */
+ unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */
+ unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */
+ unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */
+ unsigned int dmasamplsize; /* size in samples hwdmasize[0]/2 */
+ unsigned int last_top_dma; /* DMA pointer in last RTC int */
+ int next_dma_buf; /* which DMA buffer will be used next round */
+ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */
+ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */
+ unsigned char neverending_ai; /* if=1, then we do neverending record (you must use cancel()) */
+ unsigned int ns_min; /* manimal alllowed delay between samples (in us) for actual card */
+ int i8253_osc_base; /* 1/frequency of on board oscilator in ns */
+ int irq_free; /* 1=have allocated IRQ */
+ int irq_blocked; /* 1=IRQ now uses any subdev */
+ int irq_was_now_closed; /* when IRQ finish, there's stored int818_mode for last interrupt */
+ int ai_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */
+ struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */
+ int ai_act_scan; /* how many scans we finished */
+ int ai_act_chan; /* actual position in actual scan */
+ unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */
+ unsigned int act_chanlist_len; /* how long is actual MUX list */
+ unsigned int act_chanlist_pos; /* actual position in MUX list */
+ unsigned int ai_scans; /* len of scanlist */
+ unsigned int ai_n_chan; /* how many channels is measured */
+ unsigned int *ai_chanlist; /* actaul chanlist */
+ unsigned int ai_flags; /* flaglist */
+ unsigned int ai_data_len; /* len of data buffer */
+ short *ai_data; /* data buffer */
+ unsigned int ai_timer1; /* timers */
unsigned int ai_timer2;
- struct comedi_subdevice *sub_ai; // ptr to AI subdevice
- unsigned char usefifo; // 1=use fifo
+ struct comedi_subdevice *sub_ai; /* ptr to AI subdevice */
+ unsigned char usefifo; /* 1=use fifo */
unsigned int ao_readback[2];
};
-static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // used for gain list programming
+static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, /* used for gain list programming */
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
};
@@ -372,13 +372,13 @@ static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0
/*
==============================================================================
*/
-static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan, unsigned int seglen);
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan);
-static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2);
#ifdef unused
@@ -391,8 +391,8 @@ static int rtc_setfreq_irq(int freq);
==============================================================================
ANALOG INPUT MODE0, 818 cards, slow version
*/
-static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int timeout;
@@ -418,7 +418,7 @@ static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
while (timeout--) {
if (inb(dev->iobase + PCL818_STATUS) & 0x10)
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
comedi_error(dev, "A/D insn timeout");
/* clear INT (conversion end) flag */
@@ -438,8 +438,8 @@ static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
ANALOG OUTPUT MODE0, 818 cards
only one sample per call is supported
*/
-static int pcl818_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -451,8 +451,8 @@ static int pcl818_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -474,8 +474,8 @@ static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
only one sample per call is supported
*/
-static int pcl818_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -492,8 +492,8 @@ static int pcl818_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
only one sample per call is supported
*/
-static int pcl818_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -524,7 +524,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
while (timeout--) {
if (inb(dev->iobase + PCL818_STATUS) & 0x10)
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
outb(0, dev->iobase + PCL818_STATUS); /* clear INT request */
comedi_error(dev, "A/D mode1/3 IRQ without DRDY!");
@@ -535,11 +535,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
conv_finish:
low = inb(dev->iobase + PCL818_AD_LO);
- comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); // get one sample
+ comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); /* get one sample */
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
- if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 IRQ - channel dropout %x!=%x !\n",
(low & 0xf),
devpriv->act_chanlist[devpriv->act_chanlist_pos]);
@@ -549,7 +549,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
return IRQ_HANDLED;
}
if (s->async->cur_chan == 0) {
- // rt_printk("E");
+ /* printk("E"); */
devpriv->ai_act_scan--;
}
@@ -577,7 +577,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
disable_dma(devpriv->dma);
devpriv->next_dma_buf = 1 - devpriv->next_dma_buf;
- if ((devpriv->dma_runs_to_end) > -1 || devpriv->neverending_ai) { // switch dma bufs
+ if ((devpriv->dma_runs_to_end) > -1 || devpriv->neverending_ai) { /* switch dma bufs */
set_dma_mode(devpriv->dma, DMA_MODE_READ);
flags = claim_dma_lock();
set_dma_addr(devpriv->dma,
@@ -591,7 +591,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
release_dma_lock(flags);
enable_dma(devpriv->dma);
}
- rt_printk("comedi: A/D mode1/3 IRQ \n");
+ printk("comedi: A/D mode1/3 IRQ \n");
devpriv->dma_runs_to_end--;
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
@@ -601,8 +601,8 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
bufptr = 0;
for (i = 0; i < len; i++) {
- if ((ptr[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((ptr[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 DMA - channel dropout %d(card)!=%d(chanlist) at %d !\n",
(ptr[bufptr] & 0xf),
devpriv->act_chanlist[devpriv->
@@ -614,7 +614,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
return IRQ_HANDLED;
}
- comedi_buf_put(s->async, ptr[bufptr++] >> 4); // get one sample
+ comedi_buf_put(s->async, ptr[bufptr++] >> 4); /* get one sample */
devpriv->act_chanlist_pos++;
if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len) {
@@ -627,7 +627,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
- // printk("done int ai13 dma\n");
+ /* printk("done int ai13 dma\n"); */
return IRQ_HANDLED;
}
}
@@ -651,7 +651,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
long ofs_dats;
short *dmabuf = (short *) devpriv->dmabuf[0];
- //outb(2,0x378);
+ /* outb(2,0x378); */
switch (devpriv->ai_mode) {
case INT_TYPE_AI1_DMA_RTC:
case INT_TYPE_AI3_DMA_RTC:
@@ -668,32 +668,32 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
if (top1 != top2)
return IRQ_HANDLED;
- top1 = devpriv->hwdmasize[0] - top1; // where is now DMA in buffer
+ top1 = devpriv->hwdmasize[0] - top1; /* where is now DMA in buffer */
top1 >>= 1;
- ofs_dats = top1 - devpriv->last_top_dma; // new samples from last call
+ ofs_dats = top1 - devpriv->last_top_dma; /* new samples from last call */
if (ofs_dats < 0)
ofs_dats = (devpriv->dmasamplsize) + ofs_dats;
if (!ofs_dats)
- return IRQ_HANDLED; // exit=no new samples from last call
- // obsluz data
+ return IRQ_HANDLED; /* exit=no new samples from last call */
+ /* obsluz data */
i = devpriv->last_top_dma - 1;
i &= (devpriv->dmasamplsize - 1);
- if (dmabuf[i] != MAGIC_DMA_WORD) { // DMA overflow!
+ if (dmabuf[i] != MAGIC_DMA_WORD) { /* DMA overflow! */
comedi_error(dev, "A/D mode1/3 DMA buffer overflow!");
- //rt_printk("I %d dmabuf[i] %d %d\n",i,dmabuf[i],devpriv->dmasamplsize);
+ /* printk("I %d dmabuf[i] %d %d\n",i,dmabuf[i],devpriv->dmasamplsize); */
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
return IRQ_HANDLED;
}
- //rt_printk("r %ld ",ofs_dats);
+ /* printk("r %ld ",ofs_dats); */
bufptr = devpriv->last_top_dma;
for (i = 0; i < ofs_dats; i++) {
- if ((dmabuf[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((dmabuf[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 DMA - channel dropout %d!=%d !\n",
(dmabuf[bufptr] & 0xf),
devpriv->act_chanlist[devpriv->
@@ -705,7 +705,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
return IRQ_HANDLED;
}
- comedi_buf_put(s->async, dmabuf[bufptr++] >> 4); // get one sample
+ comedi_buf_put(s->async, dmabuf[bufptr++] >> 4); /* get one sample */
bufptr &= (devpriv->dmasamplsize - 1);
if (s->async->cur_chan == 0) {
@@ -717,7 +717,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
- //printk("done int ai13 dma\n");
+ /* printk("done int ai13 dma\n"); */
return IRQ_HANDLED;
}
}
@@ -727,11 +727,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
bufptr &= (devpriv->dmasamplsize - 1);
dmabuf[bufptr] = MAGIC_DMA_WORD;
comedi_event(dev, s);
- //outb(0,0x378);
+ /* outb(0,0x378); */
return IRQ_HANDLED;
}
- //outb(0,0x378);
+ /* outb(0,0x378); */
return IRQ_HANDLED;
}
#endif
@@ -746,7 +746,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
struct comedi_subdevice *s = dev->subdevices + 0;
int i, len, lo;
- outb(0, dev->iobase + PCL818_FI_INTCLR); // clear fifo int request
+ outb(0, dev->iobase + PCL818_FI_INTCLR); /* clear fifo int request */
lo = inb(dev->iobase + PCL818_FI_STATUS);
@@ -774,8 +774,8 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
for (i = 0; i < len; i++) {
lo = inb(dev->iobase + PCL818_FI_DATALO);
- if ((lo & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((lo & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 FIFO - channel dropout %d!=%d !\n",
(lo & 0xf),
devpriv->act_chanlist[devpriv->
@@ -786,7 +786,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
return IRQ_HANDLED;
}
- comedi_buf_put(s->async, (lo >> 4) | (inb(dev->iobase + PCL818_FI_DATAHI) << 4)); // get one sample
+ comedi_buf_put(s->async, (lo >> 4) | (inb(dev->iobase + PCL818_FI_DATAHI) << 4)); /* get one sample */
if (s->async->cur_chan == 0) {
devpriv->ai_act_scan--;
@@ -810,7 +810,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
==============================================================================
INT procedure
*/
-static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pcl818(int irq, void *d)
{
struct comedi_device *dev = d;
@@ -818,7 +818,28 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
comedi_error(dev, "premature interrupt");
return IRQ_HANDLED;
}
- //rt_printk("I\n");
+ /* printk("I\n"); */
+
+ if (devpriv->irq_blocked && devpriv->irq_was_now_closed) {
+ if ((devpriv->neverending_ai || (!devpriv->neverending_ai &&
+ devpriv->ai_act_scan > 0)) &&
+ (devpriv->ai_mode == INT_TYPE_AI1_DMA ||
+ devpriv->ai_mode == INT_TYPE_AI3_DMA)) {
+ /* The cleanup from ai_cancel() has been delayed
+ until now because the card doesn't seem to like
+ being reprogrammed while a DMA transfer is in
+ progress.
+ */
+ struct comedi_subdevice *s = dev->subdevices + 0;
+ devpriv->ai_act_scan = 0;
+ devpriv->neverending_ai = 0;
+ pcl818_ai_cancel(dev, s);
+ }
+
+ outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
+
+ return IRQ_HANDLED;
+ }
switch (devpriv->ai_mode) {
case INT_TYPE_AI1_DMA:
@@ -843,25 +864,6 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
if ((!dev->irq) || (!devpriv->irq_free) || (!devpriv->irq_blocked)
|| (!devpriv->ai_mode)) {
- if (devpriv->irq_was_now_closed) {
- if (devpriv->neverending_ai &&
- (devpriv->ai_mode == INT_TYPE_AI1_DMA
- || devpriv->ai_mode ==
- INT_TYPE_AI3_DMA)) {
- /* we had neverending ai but ai_cancel() has been called
- the cleanup from ai_cancel() has been delayed until know
- because the card doesn't seem to like being reprogrammed
- while a DMA transfer is in progress
- */
- struct comedi_subdevice *s = dev->subdevices + 0;
- devpriv->ai_mode = devpriv->irq_was_now_closed;
- devpriv->irq_was_now_closed = 0;
- devpriv->neverending_ai = 0;
- pcl818_ai_cancel(dev, s);
- }
- devpriv->irq_was_now_closed = 0;
- return IRQ_HANDLED;
- }
comedi_error(dev, "bad IRQ!");
return IRQ_NONE;
}
@@ -874,19 +876,19 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
==============================================================================
ANALOG INPUT MODE 1 or 3 DMA , 818 cards
*/
-static void pcl818_ai_mode13dma_int(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned int flags;
unsigned int bytes;
- rt_printk("mode13dma_int, mode: %d\n", mode);
- disable_dma(devpriv->dma); // disable dma
+ printk("mode13dma_int, mode: %d\n", mode);
+ disable_dma(devpriv->dma); /* disable dma */
bytes = devpriv->hwdmasize[0];
if (!devpriv->neverending_ai) {
- bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); // how many
- devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; // how many DMA pages we must fiil
- devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; //on last dma transfer must be moved
+ bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many */
+ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fiil */
+ devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */
devpriv->dma_runs_to_end--;
if (devpriv->dma_runs_to_end >= 0)
bytes = devpriv->hwdmasize[0];
@@ -915,8 +917,8 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device * dev,
==============================================================================
ANALOG INPUT MODE 1 or 3 DMA rtc, 818 cards
*/
-static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned int flags;
short *pole;
@@ -928,7 +930,7 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev,
set_dma_count(devpriv->dma, devpriv->hwdmasize[0]);
release_dma_lock(flags);
enable_dma(devpriv->dma);
- devpriv->last_top_dma = 0; //devpriv->hwdmasize[0];
+ devpriv->last_top_dma = 0; /* devpriv->hwdmasize[0]; */
pole = (short *) devpriv->dmabuf[0];
devpriv->dmasamplsize = devpriv->hwdmasize[0] / 2;
pole[devpriv->dmasamplsize - 1] = MAGIC_DMA_WORD;
@@ -956,14 +958,14 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev,
==============================================================================
ANALOG INPUT MODE 1 or 3, 818 cards
*/
-static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int divisor1, divisor2;
unsigned int seglen;
- rt_printk("pcl818_ai_cmd_mode()\n");
+ printk("pcl818_ai_cmd_mode()\n");
if ((!dev->irq) && (!devpriv->dma_rtc)) {
comedi_error(dev, "IRQ not defined!");
return -EINVAL;
@@ -972,7 +974,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
if (devpriv->irq_blocked)
return -EBUSY;
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
devpriv->ai_n_chan);
@@ -981,7 +983,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
setup_channel_list(dev, s, devpriv->ai_chanlist,
devpriv->ai_n_chan, seglen);
- comedi_udelay(1);
+ udelay(1);
devpriv->ai_act_scan = devpriv->ai_scans;
devpriv->ai_act_chan = 0;
@@ -992,7 +994,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
devpriv->dma_runs_to_end = 0;
if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1))
- devpriv->neverending_ai = 1; //well, user want neverending
+ devpriv->neverending_ai = 1; /* well, user want neverending */
if (mode == 1) {
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
@@ -1010,7 +1012,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
outb(0, dev->iobase + PCL818_CNTENABLE); /* enable pacer */
switch (devpriv->dma) {
- case 1: // DMA
+ case 1: /* DMA */
case 3:
if (devpriv->dma_rtc == 0) {
pcl818_ai_mode13dma_int(mode, dev, s);
@@ -1025,26 +1027,32 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
}
#endif
break;
- case 0: // IRQ
- // rt_printk("IRQ\n");
- if (mode == 1) {
- devpriv->ai_mode = INT_TYPE_AI1_INT;
- outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); /* Pacer+IRQ */
- } else {
- devpriv->ai_mode = INT_TYPE_AI3_INT;
- outb(0x82 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); /* Ext trig+IRQ */
- };
- break;
- case -1: // FIFO
- outb(1, dev->iobase + PCL818_FI_ENABLE); // enable FIFO
- if (mode == 1) {
- devpriv->ai_mode = INT_TYPE_AI1_FIFO;
- outb(0x03, dev->iobase + PCL818_CONTROL); /* Pacer */
+ case 0:
+ if (!devpriv->usefifo) {
+ /* IRQ */
+ /* printk("IRQ\n"); */
+ if (mode == 1) {
+ devpriv->ai_mode = INT_TYPE_AI1_INT;
+ /* Pacer+IRQ */
+ outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL);
+ } else {
+ devpriv->ai_mode = INT_TYPE_AI3_INT;
+ /* Ext trig+IRQ */
+ outb(0x82 | (dev->irq << 4), dev->iobase + PCL818_CONTROL);
+ }
} else {
- devpriv->ai_mode = INT_TYPE_AI3_FIFO;
- outb(0x02, dev->iobase + PCL818_CONTROL);
- }; /* Ext trig */
- break;
+ /* FIFO */
+ /* enable FIFO */
+ outb(1, dev->iobase + PCL818_FI_ENABLE);
+ if (mode == 1) {
+ devpriv->ai_mode = INT_TYPE_AI1_FIFO;
+ /* Pacer */
+ outb(0x03, dev->iobase + PCL818_CONTROL);
+ } else {
+ devpriv->ai_mode = INT_TYPE_AI3_FIFO;
+ outb(0x02, dev->iobase + PCL818_CONTROL);
+ }
+ }
}
start_pacer(dev, mode, divisor1, divisor2);
@@ -1057,7 +1065,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
break;
}
#endif
- rt_printk("pcl818_ai_cmd_mode() end\n");
+ printk("pcl818_ai_cmd_mode() end\n");
return 0;
}
@@ -1067,8 +1075,8 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
ANALOG OUTPUT MODE 1 or 3, 818 cards
*/
#ifdef PCL818_MODE13_AO
-static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int pcl818_ao_mode13(int mode, struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
int divisor1, divisor2;
@@ -1080,7 +1088,7 @@ static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_
if (devpriv->irq_blocked)
return -EBUSY;
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
devpriv->int13_act_scan = it->n;
devpriv->int13_act_chan = 0;
@@ -1120,8 +1128,8 @@ static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_
==============================================================================
ANALOG OUTPUT MODE 1, 818 cards
*/
-static int pcl818_ao_mode1(struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int pcl818_ao_mode1(struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
return pcl818_ao_mode13(1, dev, s, it);
}
@@ -1130,8 +1138,8 @@ static int pcl818_ao_mode1(struct comedi_device * dev, struct comedi_subdevice *
==============================================================================
ANALOG OUTPUT MODE 3, 818 cards
*/
-static int pcl818_ao_mode3(struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int pcl818_ao_mode3(struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
return pcl818_ao_mode13(3, dev, s, it);
}
@@ -1142,12 +1150,12 @@ static int pcl818_ao_mode3(struct comedi_device * dev, struct comedi_subdevice *
==============================================================================
Start/stop pacer onboard pacer
*/
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2)
{
outb(0xb4, dev->iobase + PCL818_CTRCTL);
outb(0x74, dev->iobase + PCL818_CTRCTL);
- comedi_udelay(1);
+ udelay(1);
if (mode == 1) {
outb(divisor2 & 0xff, dev->iobase + PCL818_CTR2);
@@ -1162,7 +1170,7 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis
Check if channel list from user is builded correctly
If it's ok, then program scan/gain logic
*/
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan)
{
unsigned int chansegment[16];
@@ -1175,32 +1183,36 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
}
if (n_chan > 1) {
- // first channel is everytime ok
+ /* first channel is everytime ok */
chansegment[0] = chanlist[0];
- // build part of chanlist
+ /* build part of chanlist */
for (i = 1, seglen = 1; i < n_chan; i++, seglen++) {
- // rt_printk("%d. %d %d\n",i,CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));
- // we detect loop, this must by finish
+
+ /* printk("%d. %d * %d\n",i,
+ * CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));*/
+
+ /* we detect loop, this must by finish */
+
if (chanlist[0] == chanlist[i])
break;
nowmustbechan =
(CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
- if (nowmustbechan != CR_CHAN(chanlist[i])) { // channel list isn't continous :-(
- rt_printk
+ if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */
+ printk
("comedi%d: pcl818: channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n",
dev->minor, i, CR_CHAN(chanlist[i]),
nowmustbechan, CR_CHAN(chanlist[0]));
return 0;
}
- // well, this is next correct channel in list
+ /* well, this is next correct channel in list */
chansegment[i] = chanlist[i];
}
- // check whole chanlist
+ /* check whole chanlist */
for (i = 0, segpos = 0; i < n_chan; i++) {
- //rt_printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));
+ /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i])); */
if (chanlist[i] != chansegment[i % seglen]) {
- rt_printk
+ printk
("comedi%d: pcl818: bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
dev->minor, i, CR_CHAN(chansegment[i]),
CR_RANGE(chansegment[i]),
@@ -1208,17 +1220,17 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
CR_CHAN(chanlist[i % seglen]),
CR_RANGE(chanlist[i % seglen]),
CR_AREF(chansegment[i % seglen]));
- return 0; // chan/gain list is strange
+ return 0; /* chan/gain list is strange */
}
}
} else {
seglen = 1;
}
- rt_printk("check_channel_list: seglen %d\n", seglen);
+ printk("check_channel_list: seglen %d\n", seglen);
return seglen;
}
-static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan, unsigned int seglen)
{
int i;
@@ -1226,13 +1238,13 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi
devpriv->act_chanlist_len = seglen;
devpriv->act_chanlist_pos = 0;
- for (i = 0; i < seglen; i++) { // store range list to card
+ for (i = 0; i < seglen; i++) { /* store range list to card */
devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
outb(muxonechan[CR_CHAN(chanlist[i])], dev->iobase + PCL818_MUX); /* select channel */
outb(CR_RANGE(chanlist[i]), dev->iobase + PCL818_RANGE); /* select gain */
}
- comedi_udelay(1);
+ udelay(1);
/* select channel interval to scan */
outb(devpriv->act_chanlist[0] | (devpriv->act_chanlist[seglen -
@@ -1255,8 +1267,8 @@ static int check_single_ended(unsigned int port)
/*
==============================================================================
*/
-static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
@@ -1391,7 +1403,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
if (cmd->chanlist) {
if (!check_channel_list(dev, s, cmd->chanlist,
cmd->chanlist_len))
- return 5; // incorrect channels list
+ return 5; /* incorrect channels list */
}
return 0;
@@ -1400,12 +1412,12 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
/*
==============================================================================
*/
-static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int retval;
- rt_printk("pcl818_ai_cmd()\n");
+ printk("pcl818_ai_cmd()\n");
devpriv->ai_n_chan = cmd->chanlist_len;
devpriv->ai_chanlist = cmd->chanlist;
devpriv->ai_flags = cmd->flags;
@@ -1420,14 +1432,14 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
devpriv->ai_scans = 0;
}
- if (cmd->scan_begin_src == TRIG_FOLLOW) { // mode 1, 3
- if (cmd->convert_src == TRIG_TIMER) { // mode 1
+ if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 3 */
+ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */
devpriv->ai_timer1 = cmd->convert_arg;
retval = pcl818_ai_cmd_mode(1, dev, s);
- rt_printk("pcl818_ai_cmd() end\n");
+ printk("pcl818_ai_cmd() end\n");
return retval;
}
- if (cmd->convert_src == TRIG_EXT) { // mode 3
+ if (cmd->convert_src == TRIG_EXT) { /* mode 3 */
return pcl818_ai_cmd_mode(3, dev, s);
}
}
@@ -1439,23 +1451,24 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
==============================================================================
cancel any mode 1-4 AI
*/
-static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (devpriv->irq_blocked > 0) {
- rt_printk("pcl818_ai_cancel()\n");
- devpriv->irq_was_now_closed = devpriv->ai_mode;
- devpriv->ai_mode = 0;
+ printk("pcl818_ai_cancel()\n");
+ devpriv->irq_was_now_closed = 1;
- switch (devpriv->irq_was_now_closed) {
+ switch (devpriv->ai_mode) {
#ifdef unused
case INT_TYPE_AI1_DMA_RTC:
case INT_TYPE_AI3_DMA_RTC:
- set_rtc_irq_bit(0); // stop RTC
+ set_rtc_irq_bit(0); /* stop RTC */
del_timer(&devpriv->rtc_irq_timer);
#endif
case INT_TYPE_AI1_DMA:
case INT_TYPE_AI3_DMA:
- if (devpriv->neverending_ai) {
+ if (devpriv->neverending_ai ||
+ (!devpriv->neverending_ai &&
+ devpriv->ai_act_scan > 0)) {
/* wait for running dma transfer to end, do cleanup in interrupt */
goto end;
}
@@ -1469,14 +1482,14 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
case INT_TYPE_AO3_INT:
#endif
outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, dev->iobase + PCL818_CONTROL); /* Stop A/D */
- comedi_udelay(1);
+ udelay(1);
start_pacer(dev, -1, 0, 0);
outb(0, dev->iobase + PCL818_AD_LO);
inb(dev->iobase + PCL818_AD_LO);
inb(dev->iobase + PCL818_AD_HI);
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
outb(0, dev->iobase + PCL818_CONTROL); /* Stop A/D */
- if (devpriv->usefifo) { // FIFO shutdown
+ if (devpriv->usefifo) { /* FIFO shutdown */
outb(0, dev->iobase + PCL818_FI_INTCLR);
outb(0, dev->iobase + PCL818_FI_FLUSH);
outb(0, dev->iobase + PCL818_FI_ENABLE);
@@ -1484,12 +1497,14 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
devpriv->irq_blocked = 0;
devpriv->last_int_sub = s;
devpriv->neverending_ai = 0;
+ devpriv->ai_mode = 0;
+ devpriv->irq_was_now_closed = 0;
break;
}
}
end:
- rt_printk("pcl818_ai_cancel() end\n");
+ printk("pcl818_ai_cancel() end\n");
return 0;
}
@@ -1500,39 +1515,39 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
static int pcl818_check(unsigned long iobase)
{
outb(0x00, iobase + PCL818_MUX);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL818_MUX) != 0x00)
- return 1; //there isn't card
+ return 1; /* there isn't card */
outb(0x55, iobase + PCL818_MUX);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL818_MUX) != 0x55)
- return 1; //there isn't card
+ return 1; /* there isn't card */
outb(0x00, iobase + PCL818_MUX);
- comedi_udelay(1);
+ udelay(1);
outb(0x18, iobase + PCL818_CONTROL);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL818_CONTROL) != 0x18)
- return 1; //there isn't card
- return 0; // ok, card exist
+ return 1; /* there isn't card */
+ return 0; /* ok, card exist */
}
/*
==============================================================================
reset whole PCL-818 cards
*/
-static void pcl818_reset(struct comedi_device * dev)
+static void pcl818_reset(struct comedi_device *dev)
{
- if (devpriv->usefifo) { // FIFO shutdown
+ if (devpriv->usefifo) { /* FIFO shutdown */
outb(0, dev->iobase + PCL818_FI_INTCLR);
outb(0, dev->iobase + PCL818_FI_FLUSH);
outb(0, dev->iobase + PCL818_FI_ENABLE);
}
- outb(0, dev->iobase + PCL818_DA_LO); // DAC=0V
+ outb(0, dev->iobase + PCL818_DA_LO); /* DAC=0V */
outb(0, dev->iobase + PCL818_DA_HI);
- comedi_udelay(1);
- outb(0, dev->iobase + PCL818_DO_HI); // DO=$0000
+ udelay(1);
+ outb(0, dev->iobase + PCL818_DO_HI); /* DO=$0000 */
outb(0, dev->iobase + PCL818_DO_LO);
- comedi_udelay(1);
+ udelay(1);
outb(0, dev->iobase + PCL818_CONTROL);
outb(0, dev->iobase + PCL818_CNTENABLE);
outb(0, dev->iobase + PCL818_MUX);
@@ -1641,9 +1656,9 @@ static int rtc_setfreq_irq(int freq)
==============================================================================
Free any resources that we have claimed
*/
-static void free_resources(struct comedi_device * dev)
+static void free_resources(struct comedi_device *dev)
{
- //rt_printk("free_resource()\n");
+ /* printk("free_resource()\n"); */
if (dev->private) {
pcl818_ai_cancel(dev, devpriv->sub_ai);
pcl818_reset(dev);
@@ -1655,7 +1670,7 @@ static void free_resources(struct comedi_device * dev)
free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
#ifdef unused
if (devpriv->rtc_irq)
- comedi_free_irq(devpriv->rtc_irq, dev);
+ free_irq(devpriv->rtc_irq, dev);
if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
@@ -1670,7 +1685,7 @@ static void free_resources(struct comedi_device * dev)
free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, devpriv->io_range);
- //rt_printk("free_resource() end\n");
+ /* printk("free_resource() end\n"); */
}
/*
@@ -1679,15 +1694,17 @@ static void free_resources(struct comedi_device * dev)
Initialization
*/
-static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
- unsigned int irq, dma;
+ unsigned int irq;
+ int dma;
unsigned long pages;
struct comedi_subdevice *s;
- if ((ret = alloc_private(dev, sizeof(struct pcl818_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct pcl818_private));
+ if (ret < 0)
return ret; /* Can't alloc mem */
/* claim our I/O space */
@@ -1695,19 +1712,19 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk("comedi%d: pcl818: board=%s, ioport=0x%03lx",
dev->minor, this_board->name, iobase);
devpriv->io_range = this_board->io_range;
- if ((this_board->fifo) && (it->options[2] == -1)) { // we've board with FIFO and we want to use FIFO
+ if ((this_board->fifo) && (it->options[2] == -1)) { /* we've board with FIFO and we want to use FIFO */
devpriv->io_range = PCLx1xFIFO_RANGE;
devpriv->usefifo = 1;
}
if (!request_region(iobase, devpriv->io_range, "pcl818")) {
- rt_printk("I/O port conflict\n");
+ printk("I/O port conflict\n");
return -EIO;
}
dev->iobase = iobase;
if (pcl818_check(iobase)) {
- rt_printk(", I can't detect board. FAIL!\n");
+ printk(", I can't detect board. FAIL!\n");
return -EIO;
}
@@ -1719,19 +1736,18 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
irq = it->options[1];
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
- rt_printk
+ printk
(", IRQ %u is out of allowed range, DISABLING IT",
irq);
irq = 0; /* Bad IRQ */
} else {
- if (comedi_request_irq(irq, interrupt_pcl818, 0,
- "pcl818", dev)) {
- rt_printk
+ if (request_irq(irq, interrupt_pcl818, 0, "pcl818", dev)) {
+ printk
(", unable to allocate IRQ %u, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%u", irq);
+ printk(", irq=%u", irq);
}
}
}
@@ -1750,7 +1766,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
#ifdef unused
/* grab RTC for DMA operations */
devpriv->dma_rtc = 0;
- if (it->options[2] > 0) { // we want to use DMA
+ if (it->options[2] > 0) { /* we want to use DMA */
if (RTC_lock == 0) {
if (!request_region(RTC_PORT(0), RTC_IO_EXTENT,
"pcl818 (RTC)"))
@@ -1759,12 +1775,11 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->rtc_iobase = RTC_PORT(0);
devpriv->rtc_iosize = RTC_IO_EXTENT;
RTC_lock++;
- if (!comedi_request_irq(RTC_IRQ,
- interrupt_pcl818_ai_mode13_dma_rtc, 0,
+ if (!request_irq(RTC_IRQ, interrupt_pcl818_ai_mode13_dma_rtc, 0,
"pcl818 DMA (RTC)", dev)) {
devpriv->dma_rtc = 1;
devpriv->rtc_irq = RTC_IRQ;
- rt_printk(", dma_irq=%u", devpriv->rtc_irq);
+ printk(", dma_irq=%u", devpriv->rtc_irq);
} else {
RTC_lock--;
if (RTC_lock == 0) {
@@ -1789,31 +1804,31 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (dma < 1)
goto no_dma; /* DMA disabled */
if (((1 << dma) & this_board->DMAbits) == 0) {
- rt_printk(", DMA is out of allowed range, FAIL!\n");
+ printk(", DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
ret = request_dma(dma, "pcl818");
if (ret) {
- rt_printk(", unable to allocate DMA %u, FAIL!\n", dma);
+ printk(", unable to allocate DMA %u, FAIL!\n", dma);
return -EBUSY; /* DMA isn't free */
}
devpriv->dma = dma;
- rt_printk(", dma=%u", dma);
+ printk(", dma=%u", dma);
pages = 2; /* we need 16KB */
devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[0]) {
- rt_printk(", unable to allocate DMA buffer, FAIL!\n");
+ printk(", unable to allocate DMA buffer, FAIL!\n");
/* maybe experiment with try_to_free_pages() will help .... */
return -EBUSY; /* no buffer :-( */
}
devpriv->dmapages[0] = pages;
devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]);
devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE;
- //rt_printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE);
- if (devpriv->dma_rtc == 0) { // we must do duble buff :-(
+ /* printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); */
+ if (devpriv->dma_rtc == 0) { /* we must do duble buff :-( */
devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[1]) {
- rt_printk
+ printk
(", unable to allocate DMA buffer, FAIL!\n");
return -EBUSY;
}
@@ -1826,7 +1841,8 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
no_dma:
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -1858,7 +1874,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
}
if (this_board->is_818) {
if ((it->options[4] == 1) || (it->options[4] == 10))
- s->range_table = &range_pcl818l_h_ai; // secondary range list jumper selectable
+ s->range_table = &range_pcl818l_h_ai; /* secondary range list jumper selectable */
} else {
switch (it->options[4]) {
case 0:
@@ -1971,7 +1987,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
pcl818_reset(dev);
- rt_printk("\n");
+ printk("\n");
return 0;
}
@@ -1980,9 +1996,9 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
==============================================================================
Removes device
*/
-static int pcl818_detach(struct comedi_device * dev)
+static int pcl818_detach(struct comedi_device *dev)
{
- // rt_printk("comedi%d: pcl818: remove\n", dev->minor);
+ /* printk("comedi%d: pcl818: remove\n", dev->minor); */
free_resources(dev);
return 0;
}
diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c
index a3ed3a0e855a..a5d6b1d9a1aa 100644
--- a/drivers/staging/comedi/drivers/pcm3724.c
+++ b/drivers/staging/comedi/drivers/pcm3724.c
@@ -62,18 +62,18 @@ Copy/pasted/hacked from pcm724.c
#define CR_A_MODE(a) ((a)<<5)
#define CR_CW 0x80
-static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcm3724_detach(struct comedi_device * dev);
+static int pcm3724_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcm3724_detach(struct comedi_device *dev);
struct pcm3724_board {
- const char *name; // driver name
- int dio; // num of DIO
- int numofports; // num of 8255 subdevices
- unsigned int IRQbits; // allowed interrupts
- unsigned int io_range; // len of IO space
+ const char *name; /* driver name */
+ int dio; /* num of DIO */
+ int numofports; /* num of 8255 subdevices */
+ unsigned int IRQbits; /* allowed interrupts */
+ unsigned int io_range; /* len of IO space */
};
-//used to track configured dios
+/* used to track configured dios */
struct priv_pcm3724 {
int dio_1;
int dio_2;
@@ -87,36 +87,36 @@ static const struct pcm3724_board boardtypes[] = {
#define this_board ((const struct pcm3724_board *)dev->board_ptr)
static struct comedi_driver driver_pcm3724 = {
- driver_name:"pcm3724",
- module:THIS_MODULE,
- attach:pcm3724_attach,
- detach:pcm3724_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcm3724_board),
+ .driver_name = "pcm3724",
+ .module = THIS_MODULE,
+ .attach = pcm3724_attach,
+ .detach = pcm3724_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcm3724_board),
};
COMEDI_INITCLEANUP(driver_pcm3724);
-// (setq c-basic-offset 8)
+/* (setq c-basic-offset 8) */
static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
{
unsigned long iobase = arg;
unsigned char inbres;
- //printk("8255cb %d %d %d %lx\n", dir,port,data,arg);
+ /* printk("8255cb %d %d %d %lx\n", dir,port,data,arg); */
if (dir) {
- //printk("8255 cb outb(%x, %lx)\n", data, iobase+port);
+ /* printk("8255 cb outb(%x, %lx)\n", data, iobase+port); */
outb(data, iobase + port);
return 0;
} else {
inbres = inb(iobase + port);
- //printk("8255 cb inb(%lx) = %x\n", iobase+port, inbres);
+ /* printk("8255 cb inb(%lx) = %x\n", iobase+port, inbres); */
return inbres;
}
}
-static int compute_buffer(int config, int devno, struct comedi_subdevice * s)
+static int compute_buffer(int config, int devno, struct comedi_subdevice *s)
{
/* 1 in io_bits indicates output */
if (s->io_bits & 0x0000ff) {
@@ -143,7 +143,7 @@ static int compute_buffer(int config, int devno, struct comedi_subdevice * s)
return config;
}
-static void do_3724_config(struct comedi_device * dev, struct comedi_subdevice * s,
+static void do_3724_config(struct comedi_device *dev, struct comedi_subdevice *s,
int chanspec)
{
int config;
@@ -173,11 +173,11 @@ static void do_3724_config(struct comedi_device * dev, struct comedi_subdevice *
port_8255_cfg = dev->iobase + SIZE_8255 + _8255_CR;
}
outb(buffer_config, dev->iobase + 8); /* update buffer register */
- //printk("pcm3724 buffer_config (%lx) %d, %x\n", dev->iobase + _8255_CR, chanspec, buffer_config);
+ /* printk("pcm3724 buffer_config (%lx) %d, %x\n", dev->iobase + _8255_CR, chanspec, buffer_config); */
outb(config, port_8255_cfg);
}
-static void enable_chan(struct comedi_device * dev, struct comedi_subdevice * s, int chanspec)
+static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, int chanspec)
{
unsigned int mask;
int gatecfg;
@@ -187,9 +187,9 @@ static void enable_chan(struct comedi_device * dev, struct comedi_subdevice * s,
priv = (struct priv_pcm3724 *) (dev->private);
mask = 1 << CR_CHAN(chanspec);
- if (s == dev->subdevices) { // subdev 0
+ if (s == dev->subdevices) { /* subdev 0 */
priv->dio_1 |= mask;
- } else { //subdev 1
+ } else { /* subdev 1 */
priv->dio_2 |= mask;
}
if (priv->dio_1 & 0xff0000) {
@@ -210,13 +210,13 @@ static void enable_chan(struct comedi_device * dev, struct comedi_subdevice * s,
if (priv->dio_2 & 0xff) {
gatecfg |= GATE_A1;
}
- // printk("gate control %x\n", gatecfg);
+ /* printk("gate control %x\n", gatecfg); */
outb(gatecfg, dev->iobase + 9);
}
/* overriding the 8255 insn config */
-static int subdev_3724_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int subdev_3724_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask;
unsigned int bits;
@@ -252,7 +252,7 @@ static int subdev_3724_insn_config(struct comedi_device * dev, struct comedi_sub
return 1;
}
-static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcm3724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase;
unsigned int iorange;
@@ -260,7 +260,9 @@ static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig *
iobase = it->options[0];
iorange = this_board->io_range;
- if ((ret = alloc_private(dev, sizeof(struct priv_pcm3724))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct priv_pcm3724));
+ if (ret < 0)
return -ENOMEM;
((struct priv_pcm3724 *) (dev->private))->dio_1 = 0;
@@ -279,7 +281,8 @@ static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig *
n_subdevices = this_board->numofports;
- if ((ret = alloc_subdevices(dev, n_subdevices)) < 0)
+ ret = alloc_subdevices(dev, n_subdevices);
+ if (ret < 0)
return ret;
for (i = 0; i < dev->n_subdevices; i++) {
@@ -290,7 +293,7 @@ static int pcm3724_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int pcm3724_detach(struct comedi_device * dev)
+static int pcm3724_detach(struct comedi_device *dev)
{
int i;
diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c
index 1de555fe645c..ae90ea4ae3c9 100644
--- a/drivers/staging/comedi/drivers/pcm3730.c
+++ b/drivers/staging/comedi/drivers/pcm3730.c
@@ -19,28 +19,28 @@ Configuration options:
#include <linux/ioport.h>
-#define PCM3730_SIZE 4 // consecutive io port addresses
+#define PCM3730_SIZE 4 /* consecutive io port addresses */
-#define PCM3730_DOA 0 // offsets for each port
+#define PCM3730_DOA 0 /* offsets for each port */
#define PCM3730_DOB 2
#define PCM3730_DOC 3
#define PCM3730_DIA 0
#define PCM3730_DIB 2
#define PCM3730_DIC 3
-static int pcm3730_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcm3730_detach(struct comedi_device * dev);
+static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcm3730_detach(struct comedi_device *dev);
static struct comedi_driver driver_pcm3730 = {
- driver_name:"pcm3730",
- module:THIS_MODULE,
- attach:pcm3730_attach,
- detach:pcm3730_detach,
+ .driver_name = "pcm3730",
+ .module = THIS_MODULE,
+ .attach = pcm3730_attach,
+ .detach = pcm3730_detach,
};
COMEDI_INITCLEANUP(driver_pcm3730);
-static int pcm3730_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcm3730_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -54,8 +54,8 @@ static int pcm3730_do_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int pcm3730_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcm3730_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -63,7 +63,7 @@ static int pcm3730_di_insn_bits(struct comedi_device * dev, struct comedi_subdev
return 2;
}
-static int pcm3730_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -141,7 +141,7 @@ static int pcm3730_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int pcm3730_detach(struct comedi_device * dev)
+static int pcm3730_detach(struct comedi_device *dev)
{
printk("comedi%d: pcm3730: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c
index fc2a73d97c24..9bb26699f47e 100644
--- a/drivers/staging/comedi/drivers/pcmad.c
+++ b/drivers/staging/comedi/drivers/pcmad.c
@@ -41,6 +41,7 @@ Configuration options:
1 = two's complement
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -58,12 +59,12 @@ struct pcmad_board_struct {
};
static const struct pcmad_board_struct pcmad_boards[] = {
{
- name: "pcmad12",
- n_ai_bits:12,
+ .name = "pcmad12",
+ .n_ai_bits = 12,
},
{
- name: "pcmad16",
- n_ai_bits:16,
+ .name = "pcmad16",
+ .n_ai_bits = 16,
},
};
@@ -76,24 +77,24 @@ struct pcmad_priv_struct {
};
#define devpriv ((struct pcmad_priv_struct *)dev->private)
-static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcmad_detach(struct comedi_device * dev);
+static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcmad_detach(struct comedi_device *dev);
static struct comedi_driver driver_pcmad = {
- driver_name:"pcmad",
- module:THIS_MODULE,
- attach:pcmad_attach,
- detach:pcmad_detach,
- board_name:&pcmad_boards[0].name,
- num_names:n_pcmad_boards,
- offset:sizeof(pcmad_boards[0]),
+ .driver_name = "pcmad",
+ .module = THIS_MODULE,
+ .attach = pcmad_attach,
+ .detach = pcmad_detach,
+ .board_name = &pcmad_boards[0].name,
+ .num_names = n_pcmad_boards,
+ .offset = sizeof(pcmad_boards[0]),
};
COMEDI_INITCLEANUP(driver_pcmad);
#define TIMEOUT 100
-static int pcmad_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcmad_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -126,7 +127,7 @@ static int pcmad_ai_insn_read(struct comedi_device * dev, struct comedi_subdevic
* 2 0=single ended 1=differential
* 3 0=straight binary 1=two's comp
*/
-static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
struct comedi_subdevice *s;
@@ -140,9 +141,12 @@ static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it
}
dev->iobase = iobase;
- if ((ret = alloc_subdevices(dev, 1)) < 0)
+ ret = alloc_subdevices(dev, 1);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct pcmad_priv_struct))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct pcmad_priv_struct));
+ if (ret < 0)
return ret;
dev->board_name = this_board->name;
@@ -159,7 +163,7 @@ static int pcmad_attach(struct comedi_device * dev, struct comedi_devconfig * it
return 0;
}
-static int pcmad_detach(struct comedi_device * dev)
+static int pcmad_detach(struct comedi_device *dev)
{
printk("comedi%d: pcmad: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c
index 2a1ff465602a..f1a8cdfaaa48 100644
--- a/drivers/staging/comedi/drivers/pcmda12.c
+++ b/drivers/staging/comedi/drivers/pcmda12.c
@@ -55,7 +55,7 @@ Configuration Options:
#include <linux/pci.h> /* for PCI devices */
-#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define SDEV_NO ((int)(s - dev->subdevices))
#define CHANS 8
#define IOSIZE 16
@@ -83,7 +83,7 @@ static const struct comedi_lrange pcmda12_ranges = {
static const struct pcmda12_board pcmda12_boards[] = {
{
- name: "pcmda12",
+ .name = "pcmda12",
},
};
@@ -107,16 +107,16 @@ struct pcmda12_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pcmda12_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcmda12_detach(struct comedi_device * dev);
+static int pcmda12_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcmda12_detach(struct comedi_device *dev);
-static void zero_chans(struct comedi_device * dev);
+static void zero_chans(struct comedi_device *dev);
static struct comedi_driver driver = {
- driver_name:"pcmda12",
- module:THIS_MODULE,
- attach:pcmda12_attach,
- detach:pcmda12_detach,
+ .driver_name = "pcmda12",
+ .module = THIS_MODULE,
+ .attach = pcmda12_attach,
+ .detach = pcmda12_detach,
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by
@@ -135,15 +135,15 @@ static struct comedi_driver driver = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- board_name:&pcmda12_boards[0].name,
- offset:sizeof(struct pcmda12_board),
- num_names:sizeof(pcmda12_boards) / sizeof(struct pcmda12_board),
+ .board_name = &pcmda12_boards[0].name,
+ .offset = sizeof(struct pcmda12_board),
+ .num_names = ARRAY_SIZE(pcmda12_boards),
};
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/*
* Attach is called by the Comedi core to configure the driver
@@ -151,7 +151,7 @@ static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pcmda12_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcmda12_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -220,7 +220,7 @@ static int pcmda12_attach(struct comedi_device * dev, struct comedi_devconfig *
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pcmda12_detach(struct comedi_device * dev)
+static int pcmda12_detach(struct comedi_device *dev)
{
printk("comedi%d: %s: remove\n", dev->minor, driver.driver_name);
if (dev->iobase)
@@ -228,7 +228,7 @@ static int pcmda12_detach(struct comedi_device * dev)
return 0;
}
-static void zero_chans(struct comedi_device * dev)
+static void zero_chans(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
int i;
@@ -241,8 +241,8 @@ static void zero_chans(struct comedi_device * dev)
inb(LSB_PORT(0)); /* update chans. */
}
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -283,8 +283,8 @@ static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
DAC outputs, which makes all AO channels update simultaneously.
This is useful for some control applications, I would imagine.
*/
-static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c
index 01e40f1b5628..6931f1075089 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/staging/comedi/drivers/pcmmio.c
@@ -73,10 +73,11 @@ Configuration Options:
[1] - IRQ (optional -- for edge-detect interrupt support only, leave out if you don't need this feature)
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/pci.h> /* for PCI devices */
-#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
/* This stuff is all from pcmuio.c -- it refers to the DIO subdevices only */
#define CHANS_PER_PORT 8
@@ -179,19 +180,19 @@ static const struct comedi_lrange ranges_ao =
static const struct pcmmio_board pcmmio_boards[] = {
{
- name: "pcmmio",
- dio_num_asics:1,
- dio_num_ports:6,
- total_iosize:32,
- ai_bits: 16,
- ao_bits: 16,
- n_ai_chans:16,
- n_ao_chans:8,
- ai_range_table:&ranges_ai,
- ao_range_table:&ranges_ao,
- ai_rinsn:ai_rinsn,
- ao_rinsn:ao_rinsn,
- ao_winsn:ao_winsn},
+ .name = "pcmmio",
+ .dio_num_asics = 1,
+ .dio_num_ports = 6,
+ .total_iosize = 32,
+ .ai_bits = 16,
+ .ao_bits = 16,
+ .n_ai_chans = 16,
+ .n_ao_chans = 8,
+ .ai_range_table = &ranges_ai,
+ .ao_range_table = &ranges_ao,
+ .ai_rinsn = ai_rinsn,
+ .ao_rinsn = ao_rinsn,
+ .ao_winsn = ao_winsn},
};
/*
@@ -264,14 +265,14 @@ struct pcmmio_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcmmio_detach(struct comedi_device * dev);
+static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcmmio_detach(struct comedi_device *dev);
static struct comedi_driver driver = {
- driver_name:"pcmmio",
- module:THIS_MODULE,
- attach:pcmmio_attach,
- detach:pcmmio_detach,
+ .driver_name = "pcmmio",
+ .module = THIS_MODULE,
+ .attach = pcmmio_attach,
+ .detach = pcmmio_detach,
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by
@@ -290,29 +291,29 @@ static struct comedi_driver driver = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- board_name:&pcmmio_boards[0].name,
- offset:sizeof(struct pcmmio_board),
- num_names:sizeof(pcmmio_boards) / sizeof(struct pcmmio_board),
+ .board_name = &pcmmio_boards[0].name,
+ .offset = sizeof(struct pcmmio_board),
+ .num_names = ARRAY_SIZE(pcmmio_boards),
};
-static int pcmmio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pcmmio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG);
+static irqreturn_t interrupt_pcmmio(int irq, void *d);
static void pcmmio_stop_intr(struct comedi_device *, struct comedi_subdevice *);
-static int pcmmio_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pcmmio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
+static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
/* some helper functions to deal with specifics of this device's registers */
-static void init_asics(struct comedi_device * dev); /* sets up/clears ASIC chips to defaults */
-static void switch_page(struct comedi_device * dev, int asic, int page);
+static void init_asics(struct comedi_device *dev); /* sets up/clears ASIC chips to defaults */
+static void switch_page(struct comedi_device *dev, int asic, int page);
#ifdef notused
-static void lock_port(struct comedi_device * dev, int asic, int port);
-static void unlock_port(struct comedi_device * dev, int asic, int port);
+static void lock_port(struct comedi_device *dev, int asic, int port);
+static void unlock_port(struct comedi_device *dev, int asic, int port);
#endif
/*
@@ -321,7 +322,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port);
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int sdev_no, chans_left, n_dio_subdevs, n_subdevs, port, asic,
@@ -364,7 +365,7 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->iobase + 16 + asic * ASIC_IOSIZE;
devpriv->asics[asic].irq = 0; /* this gets actually set at the end of
this function when we
- comedi_request_irqs */
+ request_irqs */
spin_lock_init(&devpriv->asics[asic].spinlock);
}
@@ -489,12 +490,12 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i
for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
if (irq[asic]
- && comedi_request_irq(irq[asic], interrupt_pcmmio,
+ && request_irq(irq[asic], interrupt_pcmmio,
IRQF_SHARED, thisboard->name, dev)) {
int i;
/* unroll the allocated irqs.. */
for (i = asic - 1; i >= 0; --i) {
- comedi_free_irq(irq[i], dev);
+ free_irq(irq[i], dev);
devpriv->asics[i].irq = irq[i] = 0;
}
irq[asic] = 0;
@@ -526,7 +527,7 @@ static int pcmmio_attach(struct comedi_device * dev, struct comedi_devconfig * i
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pcmmio_detach(struct comedi_device * dev)
+static int pcmmio_detach(struct comedi_device *dev)
{
int i;
@@ -536,7 +537,7 @@ static int pcmmio_detach(struct comedi_device * dev)
for (i = 0; i < MAX_ASICS; ++i) {
if (devpriv && devpriv->asics[i].irq)
- comedi_free_irq(devpriv->asics[i].irq, dev);
+ free_irq(devpriv->asics[i].irq, dev);
}
if (devpriv && devpriv->sprivs)
@@ -550,8 +551,8 @@ static int pcmmio_detach(struct comedi_device * dev)
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int pcmmio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int byte_no;
if (insn->n != 2)
@@ -624,8 +625,8 @@ static int pcmmio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev
* configured by a special insn_config instruction. chanspec
* contains the channel to be changed, and data[0] contains the
* value COMEDI_INPUT or COMEDI_OUTPUT. */
-static int pcmmio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no =
chan % 8;
@@ -685,7 +686,7 @@ static int pcmmio_dio_insn_config(struct comedi_device * dev, struct comedi_subd
return insn->n;
}
-static void init_asics(struct comedi_device * dev)
+static void init_asics(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
int asic;
@@ -722,7 +723,7 @@ static void init_asics(struct comedi_device * dev)
}
}
-static void switch_page(struct comedi_device * dev, int asic, int page)
+static void switch_page(struct comedi_device *dev, int asic, int page)
{
if (asic < 0 || asic >= thisboard->dio_num_asics)
return; /* paranoia */
@@ -738,7 +739,7 @@ static void switch_page(struct comedi_device * dev, int asic, int page)
}
#ifdef notused
-static void lock_port(struct comedi_device * dev, int asic, int port)
+static void lock_port(struct comedi_device *dev, int asic, int port)
{
if (asic < 0 || asic >= thisboard->dio_num_asics)
return; /* paranoia */
@@ -752,7 +753,7 @@ static void lock_port(struct comedi_device * dev, int asic, int port)
return;
}
-static void unlock_port(struct comedi_device * dev, int asic, int port)
+static void unlock_port(struct comedi_device *dev, int asic, int port)
{
if (asic < 0 || asic >= thisboard->dio_num_asics)
return; /* paranoia */
@@ -765,7 +766,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port)
}
#endif /* notused */
-static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pcmmio(int irq, void *d)
{
int asic, got1 = 0;
struct comedi_device *dev = (struct comedi_device *) d;
@@ -778,8 +779,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
/* it is an interrupt for ASIC #asic */
unsigned char int_pend;
- comedi_spin_lock_irqsave(&devpriv->asics[asic].spinlock,
- flags);
+ spin_lock_irqsave(&devpriv->asics[asic].spinlock, flags);
int_pend = inb(iobase + REG_INT_PENDING) & 0x07;
@@ -811,8 +811,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
++got1;
}
- comedi_spin_unlock_irqrestore(&devpriv->asics[asic].
- spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->asics[asic]. spinlock, flags);
if (triggered) {
struct comedi_subdevice *s;
@@ -825,9 +824,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
unsigned long flags;
unsigned oldevents;
- comedi_spin_lock_irqsave
- (&subpriv->dio.intr.
- spinlock, flags);
+ spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
oldevents = s->async->events;
@@ -859,10 +856,10 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
}
}
/* Write the scan to the buffer. */
- if (comedi_buf_put(s->async, ((short *) & val)[0])
+ if (comedi_buf_put(s->async, ((short *) &val)[0])
&&
comedi_buf_put
- (s->async, ((short *) & val)[1])) {
+ (s->async, ((short *) &val)[1])) {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Overflow! Stop acquisition!! */
@@ -896,9 +893,7 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
}
}
- comedi_spin_unlock_irqrestore
- (&subpriv->dio.intr.
- spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
if (oldevents !=
s->async->events) {
@@ -917,11 +912,12 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static void pcmmio_stop_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pcmmio_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
int nports, firstport, asic, port;
- if ((asic = subpriv->dio.intr.asic) < 0)
+ asic = subpriv->dio.intr.asic;
+ if (asic < 0)
return; /* not an interrupt subdev */
subpriv->dio.intr.enabled_mask = 0;
@@ -936,7 +932,7 @@ static void pcmmio_stop_intr(struct comedi_device * dev, struct comedi_subdevice
}
}
-static int pcmmio_start_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcmmio_start_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (!subpriv->dio.intr.continuous && subpriv->dio.intr.stop_count == 0) {
/* An empty acquisition! */
@@ -948,7 +944,8 @@ static int pcmmio_start_intr(struct comedi_device * dev, struct comedi_subdevice
int nports, firstport, asic, port;
struct comedi_cmd *cmd = &s->async->cmd;
- if ((asic = subpriv->dio.intr.asic) < 0)
+ asic = subpriv->dio.intr.asic;
+ if (asic < 0)
return 1; /* not an interrupt
subdev */
subpriv->dio.intr.enabled_mask = 0;
@@ -995,14 +992,14 @@ static int pcmmio_start_intr(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pcmmio_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
if (subpriv->dio.intr.active)
pcmmio_stop_intr(dev, s);
- comedi_spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
return 0;
}
@@ -1011,7 +1008,7 @@ static int pcmmio_cancel(struct comedi_device * dev, struct comedi_subdevice * s
* Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
*/
static int
-pcmmio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * s,
+pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
unsigned long flags;
@@ -1020,12 +1017,12 @@ pcmmio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice *
if (trignum != 0)
return -EINVAL;
- comedi_spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
s->async->inttrig = 0;
if (subpriv->dio.intr.active) {
event = pcmmio_start_intr(dev, s);
}
- comedi_spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
if (event) {
comedi_event(dev, s);
@@ -1037,13 +1034,13 @@ pcmmio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice *
/*
* 'do_cmd' function for an 'INTERRUPT' subdevice.
*/
-static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned long flags;
int event = 0;
- comedi_spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
subpriv->dio.intr.active = 1;
/* Set up end of acquisition. */
@@ -1069,7 +1066,7 @@ static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
event = pcmmio_start_intr(dev, s);
break;
}
- comedi_spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
if (event) {
comedi_event(dev, s);
@@ -1082,7 +1079,7 @@ static int pcmmio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
* 'do_cmdtest' function for an 'INTERRUPT' subdevice.
*/
static int
-pcmmio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struct comedi_cmd * cmd)
+pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -1194,8 +1191,8 @@ static int adc_wait_ready(unsigned long iobase)
}
/* All this is for AI and AO */
-static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned long iobase = subpriv->iobase;
@@ -1258,8 +1255,8 @@ static int ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
return n;
}
-static int ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
for (n = 0; n < insn->n; n++) {
@@ -1288,8 +1285,8 @@ static int wait_dac_ready(unsigned long iobase)
return 1;
}
-static int ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned iobase = subpriv->iobase, iooffset = 0;
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
index 4e7d8b6327fd..8df67c37795b 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/staging/comedi/drivers/pcmuio.c
@@ -75,11 +75,12 @@ Configuration Options:
[2] - IRQ for second ASIC (pcmuio96 only - IRQ for chans 48-72 .. can be the same as first irq!)
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/pci.h> /* for PCI devices */
-#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define CHANS_PER_PORT 8
#define PORTS_PER_ASIC 6
#define INTR_PORTS_PER_ASIC 3
@@ -155,14 +156,14 @@ struct pcmuio_board {
static const struct pcmuio_board pcmuio_boards[] = {
{
- name: "pcmuio48",
- num_asics:1,
- num_ports:6,
+ .name = "pcmuio48",
+ .num_asics = 1,
+ .num_ports = 6,
},
{
- name: "pcmuio96",
- num_asics:2,
- num_ports:12,
+ .name = "pcmuio96",
+ .num_asics = 2,
+ .num_ports = 12,
},
};
@@ -222,14 +223,14 @@ struct pcmuio_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcmuio_detach(struct comedi_device * dev);
+static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcmuio_detach(struct comedi_device *dev);
static struct comedi_driver driver = {
- driver_name:"pcmuio",
- module:THIS_MODULE,
- attach:pcmuio_attach,
- detach:pcmuio_detach,
+ .driver_name = "pcmuio",
+ .module = THIS_MODULE,
+ .attach = pcmuio_attach,
+ .detach = pcmuio_detach,
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by
@@ -248,29 +249,29 @@ static struct comedi_driver driver = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- board_name:&pcmuio_boards[0].name,
- offset:sizeof(struct pcmuio_board),
- num_names:sizeof(pcmuio_boards) / sizeof(struct pcmuio_board),
+ .board_name = &pcmuio_boards[0].name,
+ .offset = sizeof(struct pcmuio_board),
+ .num_names = ARRAY_SIZE(pcmuio_boards),
};
-static int pcmuio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pcmuio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pcmuio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
-static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG);
+static irqreturn_t interrupt_pcmuio(int irq, void *d);
static void pcmuio_stop_intr(struct comedi_device *, struct comedi_subdevice *);
-static int pcmuio_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s);
-static int pcmuio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
+static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
/* some helper functions to deal with specifics of this device's registers */
-static void init_asics(struct comedi_device * dev); /* sets up/clears ASIC chips to defaults */
-static void switch_page(struct comedi_device * dev, int asic, int page);
+static void init_asics(struct comedi_device *dev); /* sets up/clears ASIC chips to defaults */
+static void switch_page(struct comedi_device *dev, int asic, int page);
#ifdef notused
-static void lock_port(struct comedi_device * dev, int asic, int port);
-static void unlock_port(struct comedi_device * dev, int asic, int port);
+static void lock_port(struct comedi_device *dev, int asic, int port);
+static void unlock_port(struct comedi_device *dev, int asic, int port);
#endif
/*
@@ -279,7 +280,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port);
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0;
@@ -322,7 +323,7 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->asics[asic].iobase = dev->iobase + asic * ASIC_IOSIZE;
devpriv->asics[asic].irq = 0; /* this gets actually set at the end of
this function when we
- comedi_request_irqs */
+ request_irqs */
spin_lock_init(&devpriv->asics[asic].spinlock);
}
@@ -413,12 +414,12 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i
for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
if (irq[asic]
- && comedi_request_irq(irq[asic], interrupt_pcmuio,
+ && request_irq(irq[asic], interrupt_pcmuio,
IRQF_SHARED, thisboard->name, dev)) {
int i;
/* unroll the allocated irqs.. */
for (i = asic - 1; i >= 0; --i) {
- comedi_free_irq(irq[i], dev);
+ free_irq(irq[i], dev);
devpriv->asics[i].irq = irq[i] = 0;
}
irq[asic] = 0;
@@ -450,7 +451,7 @@ static int pcmuio_attach(struct comedi_device * dev, struct comedi_devconfig * i
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int pcmuio_detach(struct comedi_device * dev)
+static int pcmuio_detach(struct comedi_device *dev)
{
int i;
@@ -460,7 +461,7 @@ static int pcmuio_detach(struct comedi_device * dev)
for (i = 0; i < MAX_ASICS; ++i) {
if (devpriv->asics[i].irq)
- comedi_free_irq(devpriv->asics[i].irq, dev);
+ free_irq(devpriv->asics[i].irq, dev);
}
if (devpriv && devpriv->sprivs)
@@ -474,8 +475,8 @@ static int pcmuio_detach(struct comedi_device * dev)
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int pcmuio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int byte_no;
if (insn->n != 2)
@@ -548,8 +549,8 @@ static int pcmuio_dio_insn_bits(struct comedi_device * dev, struct comedi_subdev
* configured by a special insn_config instruction. chanspec
* contains the channel to be changed, and data[0] contains the
* value COMEDI_INPUT or COMEDI_OUTPUT. */
-static int pcmuio_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcmuio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no =
chan % 8;
@@ -609,7 +610,7 @@ static int pcmuio_dio_insn_config(struct comedi_device * dev, struct comedi_subd
return insn->n;
}
-static void init_asics(struct comedi_device * dev)
+static void init_asics(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
int asic;
@@ -646,7 +647,7 @@ static void init_asics(struct comedi_device * dev)
}
}
-static void switch_page(struct comedi_device * dev, int asic, int page)
+static void switch_page(struct comedi_device *dev, int asic, int page)
{
if (asic < 0 || asic >= thisboard->num_asics)
return; /* paranoia */
@@ -662,7 +663,7 @@ static void switch_page(struct comedi_device * dev, int asic, int page)
}
#ifdef notused
-static void lock_port(struct comedi_device * dev, int asic, int port)
+static void lock_port(struct comedi_device *dev, int asic, int port)
{
if (asic < 0 || asic >= thisboard->num_asics)
return; /* paranoia */
@@ -675,7 +676,7 @@ static void lock_port(struct comedi_device * dev, int asic, int port)
dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
}
-static void unlock_port(struct comedi_device * dev, int asic, int port)
+static void unlock_port(struct comedi_device *dev, int asic, int port)
{
if (asic < 0 || asic >= thisboard->num_asics)
return; /* paranoia */
@@ -688,7 +689,7 @@ static void unlock_port(struct comedi_device * dev, int asic, int port)
}
#endif /* notused */
-static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pcmuio(int irq, void *d)
{
int asic, got1 = 0;
struct comedi_device *dev = (struct comedi_device *) d;
@@ -701,8 +702,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
/* it is an interrupt for ASIC #asic */
unsigned char int_pend;
- comedi_spin_lock_irqsave(&devpriv->asics[asic].spinlock,
- flags);
+ spin_lock_irqsave(&devpriv->asics[asic].spinlock, flags);
int_pend = inb(iobase + REG_INT_PENDING) & 0x07;
@@ -734,8 +734,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
++got1;
}
- comedi_spin_unlock_irqrestore(&devpriv->asics[asic].
- spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->asics[asic].spinlock, flags);
if (triggered) {
struct comedi_subdevice *s;
@@ -748,9 +747,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
unsigned long flags;
unsigned oldevents;
- comedi_spin_lock_irqsave
- (&subpriv->intr.
- spinlock, flags);
+ spin_lock_irqsave (&subpriv->intr.spinlock, flags);
oldevents = s->async->events;
@@ -781,10 +778,10 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
}
}
/* Write the scan to the buffer. */
- if (comedi_buf_put(s->async, ((short *) & val)[0])
+ if (comedi_buf_put(s->async, ((short *) &val)[0])
&&
comedi_buf_put
- (s->async, ((short *) & val)[1])) {
+ (s->async, ((short *) &val)[1])) {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Overflow! Stop acquisition!! */
@@ -816,9 +813,7 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
}
}
- comedi_spin_unlock_irqrestore
- (&subpriv->intr.
- spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
if (oldevents !=
s->async->events) {
@@ -837,11 +832,12 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d PT_REGS_ARG)
return IRQ_HANDLED;
}
-static void pcmuio_stop_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static void pcmuio_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
int nports, firstport, asic, port;
- if ((asic = subpriv->intr.asic) < 0)
+ asic = subpriv->intr.asic;
+ if (asic < 0)
return; /* not an interrupt subdev */
subpriv->intr.enabled_mask = 0;
@@ -856,7 +852,7 @@ static void pcmuio_stop_intr(struct comedi_device * dev, struct comedi_subdevice
}
}
-static int pcmuio_start_intr(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcmuio_start_intr(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (!subpriv->intr.continuous && subpriv->intr.stop_count == 0) {
/* An empty acquisition! */
@@ -868,7 +864,8 @@ static int pcmuio_start_intr(struct comedi_device * dev, struct comedi_subdevice
int nports, firstport, asic, port;
struct comedi_cmd *cmd = &s->async->cmd;
- if ((asic = subpriv->intr.asic) < 0)
+ asic = subpriv->intr.asic;
+ if (asic < 0)
return 1; /* not an interrupt
subdev */
subpriv->intr.enabled_mask = 0;
@@ -905,14 +902,14 @@ static int pcmuio_start_intr(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pcmuio_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&subpriv->intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->intr.spinlock, flags);
if (subpriv->intr.active)
pcmuio_stop_intr(dev, s);
- comedi_spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
return 0;
}
@@ -921,7 +918,7 @@ static int pcmuio_cancel(struct comedi_device * dev, struct comedi_subdevice * s
* Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
*/
static int
-pcmuio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice * s,
+pcmuio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum)
{
unsigned long flags;
@@ -930,12 +927,12 @@ pcmuio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice *
if (trignum != 0)
return -EINVAL;
- comedi_spin_lock_irqsave(&subpriv->intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->intr.spinlock, flags);
s->async->inttrig = 0;
if (subpriv->intr.active) {
event = pcmuio_start_intr(dev, s);
}
- comedi_spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
if (event) {
comedi_event(dev, s);
@@ -947,13 +944,13 @@ pcmuio_inttrig_start_intr(struct comedi_device * dev, struct comedi_subdevice *
/*
* 'do_cmd' function for an 'INTERRUPT' subdevice.
*/
-static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned long flags;
int event = 0;
- comedi_spin_lock_irqsave(&subpriv->intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->intr.spinlock, flags);
subpriv->intr.active = 1;
/* Set up end of acquisition. */
@@ -979,7 +976,7 @@ static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
event = pcmuio_start_intr(dev, s);
break;
}
- comedi_spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
+ spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
if (event) {
comedi_event(dev, s);
@@ -992,7 +989,7 @@ static int pcmuio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
* 'do_cmdtest' function for an 'INTERRUPT' subdevice.
*/
static int
-pcmuio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, struct comedi_cmd * cmd)
+pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h
index 9231ba802030..e4bbd5dc9a61 100644
--- a/drivers/staging/comedi/drivers/plx9080.h
+++ b/drivers/staging/comedi/drivers/plx9080.h
@@ -399,11 +399,11 @@ static inline int plx9080_abort_dma(void *iobase, unsigned int channel)
/* wait to make sure done bit is zero */
for (i = 0; (dma_status & PLX_DMA_DONE_BIT) && i < timeout; i++) {
- comedi_udelay(1);
+ udelay(1);
dma_status = readb(dma_cs_addr);
}
if (i == timeout) {
- rt_printk
+ printk
("plx9080: cancel() timed out waiting for dma %i done clear\n",
channel);
return -ETIMEDOUT;
@@ -413,11 +413,11 @@ static inline int plx9080_abort_dma(void *iobase, unsigned int channel)
/* wait for dma done bit */
dma_status = readb(dma_cs_addr);
for (i = 0; (dma_status & PLX_DMA_DONE_BIT) == 0 && i < timeout; i++) {
- comedi_udelay(1);
+ udelay(1);
dma_status = readb(dma_cs_addr);
}
if (i == timeout) {
- rt_printk
+ printk
("plx9080: cancel() timed out waiting for dma %i done set\n",
channel);
return -ETIMEDOUT;
diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c
index 8a0bf6854939..47850bd15484 100644
--- a/drivers/staging/comedi/drivers/poc.c
+++ b/drivers/staging/comedi/drivers/poc.c
@@ -41,17 +41,17 @@ Configuration options:
#include <linux/ioport.h>
-static int poc_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int poc_detach(struct comedi_device * dev);
-static int readback_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-
-static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pcl733_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int pcl734_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int poc_detach(struct comedi_device *dev);
+static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+
+static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pcl733_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int pcl734_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
struct boarddef_struct {
const char *name;
@@ -70,33 +70,33 @@ struct boarddef_struct {
};
static const struct boarddef_struct boards[] = {
{
- name: "dac02",
- iosize: 8,
- //setup: dac02_setup,
- type: COMEDI_SUBD_AO,
- n_chan: 2,
- n_bits: 12,
- winsn: dac02_ao_winsn,
- rinsn: readback_insn,
- range: &range_unknown,
+ .name = "dac02",
+ .iosize = 8,
+ /* .setup = dac02_setup, */
+ .type = COMEDI_SUBD_AO,
+ .n_chan = 2,
+ .n_bits = 12,
+ .winsn = dac02_ao_winsn,
+ .rinsn = readback_insn,
+ .range = &range_unknown,
},
{
- name: "pcl733",
- iosize: 4,
- type: COMEDI_SUBD_DI,
- n_chan: 32,
- n_bits: 1,
- insnbits:pcl733_insn_bits,
- range: &range_digital,
+ .name = "pcl733",
+ .iosize = 4,
+ .type = COMEDI_SUBD_DI,
+ .n_chan = 32,
+ .n_bits = 1,
+ .insnbits = pcl733_insn_bits,
+ .range = &range_digital,
},
{
- name: "pcl734",
- iosize: 4,
- type: COMEDI_SUBD_DO,
- n_chan: 32,
- n_bits: 1,
- insnbits:pcl734_insn_bits,
- range: &range_digital,
+ .name = "pcl734",
+ .iosize = 4,
+ .type = COMEDI_SUBD_DO,
+ .n_chan = 32,
+ .n_bits = 1,
+ .insnbits = pcl734_insn_bits,
+ .range = &range_digital,
},
};
@@ -104,16 +104,16 @@ static const struct boarddef_struct boards[] = {
#define this_board ((const struct boarddef_struct *)dev->board_ptr)
static struct comedi_driver driver_poc = {
- driver_name:"poc",
- module:THIS_MODULE,
- attach:poc_attach,
- detach:poc_detach,
- board_name:&boards[0].name,
- num_names:n_boards,
- offset:sizeof(boards[0]),
+ .driver_name = "poc",
+ .module = THIS_MODULE,
+ .attach = poc_attach,
+ .detach = poc_detach,
+ .board_name = &boards[0].name,
+ .num_names = n_boards,
+ .offset = sizeof(boards[0]),
};
-static int poc_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
@@ -159,7 +159,7 @@ static int poc_attach(struct comedi_device * dev, struct comedi_devconfig * it)
return 0;
}
-static int poc_detach(struct comedi_device * dev)
+static int poc_detach(struct comedi_device *dev)
{
/* only free stuff if it has been allocated by _attach */
if (dev->iobase)
@@ -170,8 +170,8 @@ static int poc_detach(struct comedi_device * dev)
return 0;
}
-static int readback_insn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan;
@@ -185,8 +185,8 @@ static int readback_insn(struct comedi_device * dev, struct comedi_subdevice * s
#define DAC02_LSB(a) (2 * a)
#define DAC02_MSB(a) (2 * a + 1)
-static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int temp;
int chan;
@@ -196,7 +196,7 @@ static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice *
((unsigned int *) dev->private)[chan] = data[0];
output = data[0];
#ifdef wrong
- // convert to complementary binary if range is bipolar
+ /* convert to complementary binary if range is bipolar */
if ((CR_RANGE(insn->chanspec) & 0x2) == 0)
output = ~output;
#endif
@@ -208,8 +208,8 @@ static int dac02_ao_winsn(struct comedi_device * dev, struct comedi_subdevice *
return 1;
}
-static int pcl733_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl733_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -222,8 +222,8 @@ static int pcl733_insn_bits(struct comedi_device * dev, struct comedi_subdevice
return 2;
}
-static int pcl734_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl734_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 795c4522867f..85b53c93e135 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -179,8 +179,8 @@ static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */ };
#define DAQP_AUX_FIFO_EMPTY 0x01
/* These range structures tell COMEDI how the sample values map to
- * voltages. The A/D converter has four ranges: +/- 10V through
- * +/- 1.25V, and the D/A converter has only one: +/- 5V.
+ * voltages. The A/D converter has four .ranges = +/- 10V through
+ * +/- 1.25V, and the D/A converter has only .one = +/- 5V.
*/
static const struct comedi_lrange range_daqp_ai = { 4, {
@@ -197,18 +197,18 @@ static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} };
/* comedi interface code */
-static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int daqp_detach(struct comedi_device * dev);
+static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int daqp_detach(struct comedi_device *dev);
static struct comedi_driver driver_daqp = {
- driver_name:"quatech_daqp_cs",
- module:THIS_MODULE,
- attach:daqp_attach,
- detach:daqp_detach,
+ .driver_name = "quatech_daqp_cs",
+ .module = THIS_MODULE,
+ .attach = daqp_attach,
+ .detach = daqp_detach,
};
#ifdef DAQP_DEBUG
-static void daqp_dump(struct comedi_device * dev)
+static void daqp_dump(struct comedi_device *dev)
{
printk("DAQP: status %02x; aux status %02x\n",
inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX));
@@ -234,7 +234,7 @@ static void hex_dump(char *str, void *ptr, int len)
/* Cancel a running acquisition */
-static int daqp_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct local_info_t *local = (struct local_info_t *) s->private;
@@ -262,7 +262,7 @@ static int daqp_ai_cancel(struct comedi_device * dev, struct comedi_subdevice *
* which run pretty quick.
*/
-static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
+static void daqp_interrupt(int irq, void *dev_id)
{
struct local_info_t *local = (struct local_info_t *) dev_id;
struct comedi_device *dev;
@@ -361,8 +361,8 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
/* One-shot analog data acquisition routine */
-static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct local_info_t *local = (struct local_info_t *) s->private;
int i;
@@ -467,8 +467,8 @@ static int daqp_ns_to_timer(unsigned int *ns, int round)
* the command passes.
*/
-static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -593,7 +593,7 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct local_info_t *local = (struct local_info_t *) s->private;
struct comedi_cmd *cmd = &s->async->cmd;
@@ -793,8 +793,8 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
/* Single-shot analog output routine */
-static int daqp_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqp_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct local_info_t *local = (struct local_info_t *) s->private;
int d;
@@ -820,8 +820,8 @@ static int daqp_ao_insn_write(struct comedi_device * dev, struct comedi_subdevic
/* Digital input routine */
-static int daqp_di_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqp_di_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct local_info_t *local = (struct local_info_t *) s->private;
@@ -836,8 +836,8 @@ static int daqp_di_insn_read(struct comedi_device * dev, struct comedi_subdevice
/* Digital output routine */
-static int daqp_do_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int daqp_do_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct local_info_t *local = (struct local_info_t *) s->private;
@@ -856,7 +856,7 @@ static int daqp_do_insn_write(struct comedi_device * dev, struct comedi_subdevic
* when it is inserted.
*/
-static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
struct local_info_t *local = dev_table[it->options[0]];
@@ -908,7 +908,8 @@ static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it)
dev->iobase = local->link->io.BasePort1;
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
printk("comedi%d: attaching daqp%d (io 0x%04lx)\n",
@@ -962,7 +963,7 @@ static int daqp_attach(struct comedi_device * dev, struct comedi_devconfig * it)
* card is removed, daqp_cs_detach() is called by the pcmcia subsystem.
*/
-static int daqp_detach(struct comedi_device * dev)
+static int daqp_detach(struct comedi_device *dev)
{
printk("comedi%d: detaching daqp\n", dev->minor);
@@ -1149,15 +1150,21 @@ static void daqp_cs_config(struct pcmcia_device *link)
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
+
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_get_tuple_data(link, &tuple))) {
+
+ last_ret = pcmcia_get_tuple_data(link, &tuple);
+ if (last_ret) {
cs_error(link, GetTupleData, last_ret);
goto cs_failed;
}
- if ((last_ret = pcmcia_parse_tuple(&tuple, &parse))) {
+
+ last_ret = pcmcia_parse_tuple(&tuple, &parse);
+ if (last_ret) {
cs_error(link, ParseTuple, last_ret);
goto cs_failed;
}
@@ -1177,10 +1184,12 @@ static void daqp_cs_config(struct pcmcia_device *link)
will only use the CIS to fill in implementation-defined details.
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
- if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
+ last_ret = pcmcia_get_first_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
+
while (1) {
cistpl_cftable_entry_t dflt = { 0 };
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
@@ -1226,7 +1235,8 @@ static void daqp_cs_config(struct pcmcia_device *link)
break;
next_entry:
- if ((last_ret = pcmcia_get_next_tuple(link, &tuple))) {
+ last_ret = pcmcia_get_next_tuple(link, &tuple);
+ if (last_ret) {
cs_error(link, GetNextTuple, last_ret);
goto cs_failed;
}
@@ -1237,18 +1247,21 @@ static void daqp_cs_config(struct pcmcia_device *link)
handler to the interrupt, unless the 'Handler' member of the
irq structure is initialized.
*/
- if (link->conf.Attributes & CONF_ENABLE_IRQ)
- if ((last_ret = pcmcia_request_irq(link, &link->irq))) {
+ if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+ last_ret = pcmcia_request_irq(link, &link->irq);
+ if (last_ret) {
cs_error(link, RequestIRQ, last_ret);
goto cs_failed;
}
+ }
/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
- if ((last_ret = pcmcia_request_configuration(link, &link->conf))) {
+ last_ret = pcmcia_request_configuration(link, &link->conf);
+ if (last_ret) {
cs_error(link, RequestConfiguration, last_ret);
goto cs_failed;
}
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c
index ca347f21d140..243ee76c836d 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -101,6 +101,7 @@ Configuration options:
*/
+#include <linux/interrupt.h>
#include <linux/delay.h>
#include "../comedidev.h"
@@ -135,7 +136,7 @@ Configuration options:
#define RTD_DMA_TIMEOUT 33000 /* 1 msec */
#else
/* by delaying, power and electrical noise are reduced somewhat */
-#define WAIT_QUIETLY comedi_udelay (1)
+#define WAIT_QUIETLY udelay (1)
#define RTD_ADC_TIMEOUT 2000 /* in usec */
#define RTD_DAC_TIMEOUT 2000 /* in usec */
#define RTD_DMA_TIMEOUT 1000 /* in usec */
@@ -278,22 +279,22 @@ struct rtdBoard {
static const struct rtdBoard rtd520Boards[] = {
{
- name: "DM7520",
- device_id : 0x7520,
- aiChans: 16,
- aiBits: 12,
- aiMaxGain:32,
- range10Start:6,
- rangeUniStart:12,
+ .name = "DM7520",
+ .device_id = 0x7520,
+ .aiChans = 16,
+ .aiBits = 12,
+ .aiMaxGain = 32,
+ .range10Start = 6,
+ .rangeUniStart = 12,
},
{
- name: "PCI4520",
- device_id : 0x4520,
- aiChans: 16,
- aiBits: 12,
- aiMaxGain:128,
- range10Start:8,
- rangeUniStart:16,
+ .name = "PCI4520",
+ .device_id = 0x4520,
+ .aiChans = 16,
+ .aiBits = 12,
+ .aiMaxGain = 128,
+ .range10Start = 8,
+ .rangeUniStart = 16,
},
};
@@ -684,10 +685,10 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static int rtd_detach(struct comedi_device *dev);
static struct comedi_driver rtd520Driver = {
- driver_name: DRV_NAME,
- module : THIS_MODULE,
- attach : rtd_attach,
- detach : rtd_detach,
+ .driver_name = DRV_NAME,
+ .module = THIS_MODULE,
+ .attach = rtd_attach,
+ .detach = rtd_detach,
};
static int rtd_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -706,7 +707,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
/* static int rtd_ai_poll (struct comedi_device *dev,struct comedi_subdevice *s); */
static int rtd_ns_to_timer(unsigned int *ns, int roundMode);
-static irqreturn_t rtd_interrupt(int irq, void *d PT_REGS_ARG);
+static irqreturn_t rtd_interrupt(int irq, void *d);
static int rtd520_probe_fifo_depth(struct comedi_device *dev);
/*
@@ -757,15 +758,15 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
continue;
}
}
- for(i = 0; i < sizeof(rtd520Boards) / sizeof(rtd520Boards[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(rtd520Boards); ++i)
{
- if(pcidev->device == rtd520Boards[i].device_id)
+ if (pcidev->device == rtd520Boards[i].device_id)
{
dev->board_ptr = &rtd520Boards[i];
break;
}
}
- if(dev->board_ptr) break; /* found one */
+ if (dev->board_ptr) break; /* found one */
}
if (!pcidev) {
if (it->options[0] && it->options[1]) {
@@ -900,7 +901,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* initialize board, per RTD spec */
/* also, initialize shadow registers */
RtdResetBoard(dev);
- comedi_udelay(100); /* needed? */
+ udelay(100); /* needed? */
RtdPlxInterruptWrite(dev, 0);
RtdInterruptMask(dev, 0); /* and sets shadow */
RtdInterruptClearMask(dev, ~0); /* and sets shadow */
@@ -919,7 +920,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* TODO: set user out source ??? */
/* check if our interrupt is available and get it */
- ret = comedi_request_irq(devpriv->pci_dev->irq, rtd_interrupt,
+ ret = request_irq(devpriv->pci_dev->irq, rtd_interrupt,
IRQF_SHARED, DRV_NAME, dev);
if (ret < 0) {
@@ -931,7 +932,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk("( irq=%u )", dev->irq);
ret = rtd520_probe_fifo_depth(dev);
- if(ret < 0) {
+ if (ret < 0) {
return ret;
}
devpriv->fifoLen = ret;
@@ -1032,7 +1033,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* disable interrupt controller */
RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev)
& ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E));
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
/* release all regions that were allocated */
@@ -1111,7 +1112,7 @@ static int rtd_detach(struct comedi_device *dev)
/* disable interrupt controller */
RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev)
& ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E));
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
}
/* release all regions that were allocated */
@@ -1224,22 +1225,22 @@ static int rtd520_probe_fifo_depth(struct comedi_device *dev)
unsigned fifo_status;
/* trigger conversion */
RtdAdcStart(dev);
- comedi_udelay(1);
+ udelay(1);
fifo_status = RtdFifoStatus(dev);
- if((fifo_status & FS_ADC_HEMPTY) == 0) {
+ if ((fifo_status & FS_ADC_HEMPTY) == 0) {
fifo_size = 2 * i;
break;
}
}
- if(i == limit)
+ if (i == limit)
{
- rt_printk("\ncomedi: %s: failed to probe fifo size.\n", DRV_NAME);
+ printk("\ncomedi: %s: failed to probe fifo size.\n", DRV_NAME);
return -EIO;
}
RtdAdcClearFifo(dev);
- if(fifo_size != 0x400 && fifo_size != 0x2000)
+ if (fifo_size != 0x400 && fifo_size != 0x2000)
{
- rt_printk("\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n",
+ printk("\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n",
DRV_NAME, fifo_size);
return -EIO;
}
@@ -1386,7 +1387,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel)
+ ((channel == 0) ? LCFG_DMACSR0 : LCFG_DMACSR1);
/* spinlock for plx dma control/status reg */
- /* comedi_spin_lock_irqsave( &dev->spinlock, flags ); */
+ /* spin_lock_irqsave( &dev->spinlock, flags ); */
/* abort dma transfer if necessary */
status = readb(dma_cs_addr);
@@ -1409,7 +1410,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel)
/* disable channel (required) */
writeb(0, dma_cs_addr);
- comedi_udelay(1); /* needed?? */
+ udelay(1); /* needed?? */
/* set abort bit for channel */
writeb(PLX_DMA_ABORT_BIT, dma_cs_addr);
@@ -1427,7 +1428,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel)
}
abortDmaExit:
- /* comedi_spin_unlock_irqrestore( &dev->spinlock, flags ); */
+ /* spin_unlock_irqrestore( &dev->spinlock, flags ); */
}
/*
@@ -1494,8 +1495,7 @@ static int ai_process_dma(struct comedi_device *dev, struct comedi_subdevice *s)
The data conversion may someday happen in a "bottom half".
*/
static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
- void *d /* our data */
- PT_REGS_ARG)
+ void *d) /* our data */
{ /* cpu context (ignored) */
struct comedi_device *dev = d; /* must be called "dev" for devpriv */
u16 status;
diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c
index 334ac5773a13..f1b7e0252f13 100644
--- a/drivers/staging/comedi/drivers/rti800.c
+++ b/drivers/staging/comedi/drivers/rti800.c
@@ -52,6 +52,7 @@ Configuration options:
[8] - DAC 1 encoding (same as DAC 0)
*/
+#include <linux/interrupt.h>
#include "../comedidev.h"
#include <linux/ioport.h>
@@ -89,8 +90,8 @@ Configuration options:
#define Am9513_8BITBUS
-#define Am9513_output_control(a) outb(a,dev->iobase+RTI800_9513A_CNTRL)
-#define Am9513_output_data(a) outb(a,dev->iobase+RTI800_9513A_DATA)
+#define Am9513_output_control(a) outb(a, dev->iobase+RTI800_9513A_CNTRL)
+#define Am9513_output_data(a) outb(a, dev->iobase+RTI800_9513A_DATA)
#define Am9513_input_data() inb(dev->iobase+RTI800_9513A_DATA)
#define Am9513_input_status() inb(dev->iobase+RTI800_9513A_STATUS)
@@ -131,21 +132,21 @@ static const struct rti800_board boardtypes[] = {
#define this_board ((const struct rti800_board *)dev->board_ptr)
-static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int rti800_detach(struct comedi_device * dev);
+static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int rti800_detach(struct comedi_device *dev);
static struct comedi_driver driver_rti800 = {
- driver_name:"rti800",
- module:THIS_MODULE,
- attach:rti800_attach,
- detach:rti800_detach,
- num_names:sizeof(boardtypes) / sizeof(struct rti800_board),
- board_name:&boardtypes[0].name,
- offset:sizeof(struct rti800_board),
+ .driver_name = "rti800",
+ .module = THIS_MODULE,
+ .attach = rti800_attach,
+ .detach = rti800_detach,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct rti800_board),
};
COMEDI_INITCLEANUP(driver_rti800);
-static irqreturn_t rti800_interrupt(int irq, void *dev PT_REGS_ARG);
+static irqreturn_t rti800_interrupt(int irq, void *dev);
struct rti800_private {
enum {
@@ -172,16 +173,16 @@ struct rti800_private {
#define RTI800_TIMEOUT 100
-static irqreturn_t rti800_interrupt(int irq, void *dev PT_REGS_ARG)
+static irqreturn_t rti800_interrupt(int irq, void *dev)
{
return IRQ_HANDLED;
}
-// settling delay times in usec for different gains
+/* settling delay times in usec for different gains */
static const int gaindelay[] = { 10, 20, 40, 80 };
-static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti800_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, t;
int status;
@@ -199,9 +200,8 @@ static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
/* without a delay here, the RTI_OVERRUN bit
* gets set, and you will have an error. */
if (insn->n > 0) {
- BUG_ON(gain >=
- sizeof(gaindelay) / sizeof(gaindelay[0]));
- comedi_udelay(gaindelay[gain]);
+ BUG_ON(gain >= ARRAY_SIZE(gaindelay));
+ udelay(gaindelay[gain]);
}
}
@@ -210,16 +210,16 @@ static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
for (t = RTI800_TIMEOUT; t; t--) {
status = inb(dev->iobase + RTI800_CSR);
if (status & RTI800_OVERRUN) {
- rt_printk("rti800: a/d overrun\n");
+ printk("rti800: a/d overrun\n");
outb(0, dev->iobase + RTI800_CLRFLAGS);
return -EIO;
}
if (status & RTI800_DONE)
break;
- comedi_udelay(1);
+ udelay(1);
}
if (t == 0) {
- rt_printk("rti800: timeout\n");
+ printk("rti800: timeout\n");
return -ETIME;
}
data[i] = inb(dev->iobase + RTI800_ADCLO);
@@ -233,8 +233,8 @@ static int rti800_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int rti800_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti800_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -245,8 +245,8 @@ static int rti800_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int rti800_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti800_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int d;
@@ -265,8 +265,8 @@ static int rti800_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
return i;
}
-static int rti800_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti800_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -274,8 +274,8 @@ static int rti800_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int rti800_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti800_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -309,7 +309,7 @@ static int rti800_do_insn_bits(struct comedi_device * dev, struct comedi_subdevi
options[8] - dac1 coding
*/
-static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned int irq;
unsigned long iobase;
@@ -339,8 +339,8 @@ static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * i
irq = it->options[1];
if (irq) {
printk("( irq = %u )", irq);
- if ((ret = comedi_request_irq(irq, rti800_interrupt, 0,
- "rti800", dev)) < 0) {
+ ret = request_irq(irq, rti800_interrupt, 0, "rti800", dev);
+ if (ret < 0) {
printk(" Failed to allocate IRQ\n");
return ret;
}
@@ -351,9 +351,12 @@ static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * i
dev->board_name = this_board->name;
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
- if ((ret = alloc_private(dev, sizeof(struct rti800_private))) < 0)
+
+ ret = alloc_private(dev, sizeof(struct rti800_private));
+ if (ret < 0)
return ret;
devpriv->adc_mux = it->options[2];
@@ -444,7 +447,7 @@ static int rti800_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int rti800_detach(struct comedi_device * dev)
+static int rti800_detach(struct comedi_device *dev)
{
printk("comedi%d: rti800: remove\n", dev->minor);
@@ -452,7 +455,7 @@ static int rti800_detach(struct comedi_device * dev)
release_region(dev->iobase, RTI800_SIZE);
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
return 0;
}
diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c
index cc2c385db0b0..fffde45a352b 100644
--- a/drivers/staging/comedi/drivers/rti802.c
+++ b/drivers/staging/comedi/drivers/rti802.c
@@ -47,13 +47,13 @@ Configuration Options:
#define RTI802_DATALOW 1
#define RTI802_DATAHIGH 2
-static int rti802_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int rti802_detach(struct comedi_device * dev);
+static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int rti802_detach(struct comedi_device *dev);
static struct comedi_driver driver_rti802 = {
- driver_name:"rti802",
- module:THIS_MODULE,
- attach:rti802_attach,
- detach:rti802_detach,
+ .driver_name = "rti802",
+ .module = THIS_MODULE,
+ .attach = rti802_attach,
+ .detach = rti802_detach,
};
COMEDI_INITCLEANUP(driver_rti802);
@@ -68,8 +68,8 @@ struct rti802_private {
#define devpriv ((struct rti802_private *)dev->private)
-static int rti802_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti802_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -79,8 +79,8 @@ static int rti802_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return i;
}
-static int rti802_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int rti802_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i, d;
int chan = CR_CHAN(insn->chanspec);
@@ -96,7 +96,7 @@ static int rti802_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
return i;
}
-static int rti802_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int i;
@@ -140,7 +140,7 @@ static int rti802_attach(struct comedi_device * dev, struct comedi_devconfig * i
return 0;
}
-static int rti802_detach(struct comedi_device * dev)
+static int rti802_detach(struct comedi_device *dev)
{
printk("comedi%d: rti802: remove\n", dev->minor);
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index a7b6f711afca..d9509d7a3283 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -169,14 +169,14 @@ struct s526_board {
static const struct s526_board s526_boards[] = {
{
- name: "s526",
- gpct_chans:4,
- gpct_bits:24,
- ad_chans:8,
- ad_bits: 16,
- da_chans:4,
- da_bits: 16,
- have_dio:1,
+ .name = "s526",
+ .gpct_chans = 4,
+ .gpct_bits = 24,
+ .ad_chans = 8,
+ .ad_bits = 16,
+ .da_chans = 4,
+ .da_bits = 16,
+ .have_dio = 1,
}
};
@@ -217,13 +217,13 @@ struct s526_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int s526_detach(struct comedi_device * dev);
+static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int s526_detach(struct comedi_device *dev);
static struct comedi_driver driver_s526 = {
- driver_name:"s526",
- module:THIS_MODULE,
- attach:s526_attach,
- detach:s526_detach,
+ .driver_name = "s526",
+ .module = THIS_MODULE,
+ .attach = s526_attach,
+ .detach = s526_detach,
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by
@@ -242,29 +242,29 @@ static struct comedi_driver driver_s526 = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- board_name:&s526_boards[0].name,
- offset:sizeof(struct s526_board),
- num_names:sizeof(s526_boards) / sizeof(struct s526_board),
+ .board_name = &s526_boards[0].name,
+ .offset = sizeof(struct s526_board),
+ .num_names = ARRAY_SIZE(s526_boards),
};
-static int s526_gpct_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int s526_gpct_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/*
* Attach is called by the Comedi core to configure the driver
@@ -272,13 +272,13 @@ static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdev
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int iobase;
int i, n;
-// short value;
-// int subdev_channel = 0;
+/* short value; */
+/* int subdev_channel = 0; */
printk("comedi%d: s526: ", dev->minor);
@@ -334,12 +334,12 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
/* Command are not implemented yet, however they are necessary to
allocate the necessary memory for the comedi_async struct (used
to trigger the GPCT in case of pulsegenerator function */
- //s->do_cmd = s526_gpct_cmd;
- //s->do_cmdtest = s526_gpct_cmdtest;
- //s->cancel = s526_gpct_cancel;
+ /* s->do_cmd = s526_gpct_cmd; */
+ /* s->do_cmdtest = s526_gpct_cmdtest; */
+ /* s->cancel = s526_gpct_cancel; */
s = dev->subdevices + 1;
- //dev->read_subdev=s;
+ /* dev->read_subdev=s; */
/* analog input subdevice */
s->type = COMEDI_SUBD_AI;
/* we support differential */
@@ -383,18 +383,18 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
return 1;
#if 0
- // Example of Counter Application
- //One-shot (software trigger)
- cmReg.reg.coutSource = 0; // out RCAP
- cmReg.reg.coutPolarity = 1; // Polarity inverted
- cmReg.reg.autoLoadResetRcap = 1; // Auto load 0:disabled, 1:enabled
- cmReg.reg.hwCtEnableSource = 3; // NOT RCAP
- cmReg.reg.ctEnableCtrl = 2; // Hardware
- cmReg.reg.clockSource = 2; // Internal
- cmReg.reg.countDir = 1; // Down
- cmReg.reg.countDirCtrl = 1; // Software
- cmReg.reg.outputRegLatchCtrl = 0; // latch on read
- cmReg.reg.preloadRegSel = 0; // PR0
+ /* Example of Counter Application */
+ /* One-shot (software trigger) */
+ cmReg.reg.coutSource = 0; /* out RCAP */
+ cmReg.reg.coutPolarity = 1; /* Polarity inverted */
+ cmReg.reg.autoLoadResetRcap = 1; /* Auto load 0:disabled, 1:enabled */
+ cmReg.reg.hwCtEnableSource = 3; /* NOT RCAP */
+ cmReg.reg.ctEnableCtrl = 2; /* Hardware */
+ cmReg.reg.clockSource = 2; /* Internal */
+ cmReg.reg.countDir = 1; /* Down */
+ cmReg.reg.countDirCtrl = 1; /* Software */
+ cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
cmReg.reg.reserved = 0;
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
@@ -402,24 +402,24 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel));
outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter
- outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */
+ outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Load the counter from PR0 */
- outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset RCAP (fires one-shot)
+ outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset RCAP (fires one-shot) */
#else
- // Set Counter Mode Register
- cmReg.reg.coutSource = 0; // out RCAP
- cmReg.reg.coutPolarity = 0; // Polarity inverted
- cmReg.reg.autoLoadResetRcap = 0; // Auto load disabled
- cmReg.reg.hwCtEnableSource = 2; // NOT RCAP
- cmReg.reg.ctEnableCtrl = 1; // 1: Software, >1 : Hardware
- cmReg.reg.clockSource = 3; // x4
- cmReg.reg.countDir = 0; // up
- cmReg.reg.countDirCtrl = 0; // quadrature
- cmReg.reg.outputRegLatchCtrl = 0; // latch on read
- cmReg.reg.preloadRegSel = 0; // PR0
+ /* Set Counter Mode Register */
+ cmReg.reg.coutSource = 0; /* out RCAP */
+ cmReg.reg.coutPolarity = 0; /* Polarity inverted */
+ cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */
+ cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */
+ cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */
+ cmReg.reg.clockSource = 3; /* x4 */
+ cmReg.reg.countDir = 0; /* up */
+ cmReg.reg.countDirCtrl = 0; /* quadrature */
+ cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
cmReg.reg.reserved = 0;
n = 0;
@@ -429,21 +429,21 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
udelay(1000);
printk("Read back mode reg=0x%04x\n", inw(ADDR_CHAN_REG(REG_C0M, n)));
- // Load the pre-laod register high word
-// value = (short) (0x55);
-// outw(value, ADDR_CHAN_REG(REG_C0H, n));
+ /* Load the pre-laod register high word */
+/* value = (short) (0x55); */
+/* outw(value, ADDR_CHAN_REG(REG_C0H, n)); */
- // Load the pre-laod register low word
-// value = (short)(0xaa55);
-// outw(value, ADDR_CHAN_REG(REG_C0L, n));
+ /* Load the pre-laod register low word */
+/* value = (short)(0xaa55); */
+/* outw(value, ADDR_CHAN_REG(REG_C0L, n)); */
- // Write the Counter Control Register
-// outw(value, ADDR_CHAN_REG(REG_C0C, 0));
+ /* Write the Counter Control Register */
+/* outw(value, ADDR_CHAN_REG(REG_C0C, 0)); */
- // Reset the counter if it is software preload
+ /* Reset the counter if it is software preload */
if (cmReg.reg.autoLoadResetRcap == 0) {
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, n)); // Reset the counter
- outw(0x4000, ADDR_CHAN_REG(REG_C0C, n)); // Load the counter from PR0
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, n)); /* Reset the counter */
+ outw(0x4000, ADDR_CHAN_REG(REG_C0C, n)); /* Load the counter from PR0 */
}
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
@@ -468,7 +468,7 @@ static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int s526_detach(struct comedi_device * dev)
+static int s526_detach(struct comedi_device *dev)
{
printk("comedi%d: s526: remove\n", dev->minor);
@@ -478,47 +478,47 @@ static int s526_detach(struct comedi_device * dev)
return 0;
}
-static int s526_gpct_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_gpct_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int i; // counts the Data
+ int i; /* counts the Data */
int counter_channel = CR_CHAN(insn->chanspec);
unsigned short datalow;
unsigned short datahigh;
- // Check if (n > 0)
+ /* Check if (n > 0) */
if (insn->n <= 0) {
printk("s526: INSN_READ: n should be > 0\n");
return -EINVAL;
}
- // Read the low word first
+ /* Read the low word first */
for (i = 0; i < insn->n; i++) {
datalow = inw(ADDR_CHAN_REG(REG_C0L, counter_channel));
datahigh = inw(ADDR_CHAN_REG(REG_C0H, counter_channel));
data[i] = (int)(datahigh & 0x00FF);
data[i] = (data[i] << 16) | (datalow & 0xFFFF);
-// printk("s526 GPCT[%d]: %x(0x%04x, 0x%04x)\n", counter_channel, data[i], datahigh, datalow);
+/* printk("s526 GPCT[%d]: %x(0x%04x, 0x%04x)\n", counter_channel, data[i], datahigh, datalow); */
}
return i;
}
-static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int subdev_channel = CR_CHAN(insn->chanspec); // Unpack chanspec
+ int subdev_channel = CR_CHAN(insn->chanspec); /* Unpack chanspec */
int i;
short value;
-// printk("s526: GPCT_INSN_CONFIG: Configuring Channel %d\n", subdev_channel);
+/* printk("s526: GPCT_INSN_CONFIG: Configuring Channel %d\n", subdev_channel); */
for (i = 0; i < MAX_GPCT_CONFIG_DATA; i++) {
devpriv->s526_gpct_config[subdev_channel].data[i] =
insn->data[i];
-// printk("data[%d]=%x\n", i, insn->data[i]);
+/* printk("data[%d]=%x\n", i, insn->data[i]); */
}
- // Check what type of Counter the user requested, data[0] contains
- // the Application type
+ /* Check what type of Counter the user requested, data[0] contains */
+ /* the Application type */
switch (insn->data[0]) {
case INSN_CONFIG_GPCT_QUADRATURE_ENCODER:
/*
@@ -531,19 +531,19 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde
devpriv->s526_gpct_config[subdev_channel].app =
PositionMeasurement;
-/*
- // Example of Counter Application
- //One-shot (software trigger)
- cmReg.reg.coutSource = 0; // out RCAP
- cmReg.reg.coutPolarity = 1; // Polarity inverted
- cmReg.reg.autoLoadResetRcap = 0; // Auto load disabled
- cmReg.reg.hwCtEnableSource = 3; // NOT RCAP
- cmReg.reg.ctEnableCtrl = 2; // Hardware
- cmReg.reg.clockSource = 2; // Internal
- cmReg.reg.countDir = 1; // Down
- cmReg.reg.countDirCtrl = 1; // Software
- cmReg.reg.outputRegLatchCtrl = 0; // latch on read
- cmReg.reg.preloadRegSel = 0; // PR0
+#if 0
+ /* Example of Counter Application */
+ /* One-shot (software trigger) */
+ cmReg.reg.coutSource = 0; /* out RCAP */
+ cmReg.reg.coutPolarity = 1; /* Polarity inverted */
+ cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */
+ cmReg.reg.hwCtEnableSource = 3; /* NOT RCAP */
+ cmReg.reg.ctEnableCtrl = 2; /* Hardware */
+ cmReg.reg.clockSource = 2; /* Internal */
+ cmReg.reg.countDir = 1; /* Down */
+ cmReg.reg.countDirCtrl = 1; /* Software */
+ cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
cmReg.reg.reserved = 0;
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
@@ -551,40 +551,40 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde
outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel));
outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter
- outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */
+ outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Load the counter from PR0 */
- outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset RCAP (fires one-shot)
+ outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset RCAP (fires one-shot) */
-*/
+#endif
#if 1
- // Set Counter Mode Register
- cmReg.reg.coutSource = 0; // out RCAP
- cmReg.reg.coutPolarity = 0; // Polarity inverted
- cmReg.reg.autoLoadResetRcap = 0; // Auto load disabled
- cmReg.reg.hwCtEnableSource = 2; // NOT RCAP
- cmReg.reg.ctEnableCtrl = 1; // 1: Software, >1 : Hardware
- cmReg.reg.clockSource = 3; // x4
- cmReg.reg.countDir = 0; // up
- cmReg.reg.countDirCtrl = 0; // quadrature
- cmReg.reg.outputRegLatchCtrl = 0; // latch on read
- cmReg.reg.preloadRegSel = 0; // PR0
+ /* Set Counter Mode Register */
+ cmReg.reg.coutSource = 0; /* out RCAP */
+ cmReg.reg.coutPolarity = 0; /* Polarity inverted */
+ cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */
+ cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */
+ cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */
+ cmReg.reg.clockSource = 3; /* x4 */
+ cmReg.reg.countDir = 0; /* up */
+ cmReg.reg.countDirCtrl = 0; /* quadrature */
+ cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
cmReg.reg.reserved = 0;
- // Set Counter Mode Register
-// printk("s526: Counter Mode register=%x\n", cmReg.value);
+ /* Set Counter Mode Register */
+/* printk("s526: Counter Mode register=%x\n", cmReg.value); */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
- // Reset the counter if it is software preload
+ /* Reset the counter if it is software preload */
if (cmReg.reg.autoLoadResetRcap == 0) {
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter
-// outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */
+/* outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); Load the counter from PR0 */
}
#else
- cmReg.reg.countDirCtrl = 0; // 0 quadrature, 1 software control
+ cmReg.reg.countDirCtrl = 0; /* 0 quadrature, 1 software control */
- // data[1] contains GPCT_X1, GPCT_X2 or GPCT_X4
+ /* data[1] contains GPCT_X1, GPCT_X2 or GPCT_X4 */
if (insn->data[1] == GPCT_X2) {
cmReg.reg.clockSource = 1;
} else if (insn->data[1] == GPCT_X4) {
@@ -593,37 +593,37 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde
cmReg.reg.clockSource = 0;
}
- // When to take into account the indexpulse:
+ /* When to take into account the indexpulse: */
if (insn->data[2] == GPCT_IndexPhaseLowLow) {
} else if (insn->data[2] == GPCT_IndexPhaseLowHigh) {
} else if (insn->data[2] == GPCT_IndexPhaseHighLow) {
} else if (insn->data[2] == GPCT_IndexPhaseHighHigh) {
}
- // Take into account the index pulse?
+ /* Take into account the index pulse? */
if (insn->data[3] == GPCT_RESET_COUNTER_ON_INDEX)
- cmReg.reg.autoLoadResetRcap = 4; // Auto load with INDEX^
+ cmReg.reg.autoLoadResetRcap = 4; /* Auto load with INDEX^ */
- // Set Counter Mode Register
+ /* Set Counter Mode Register */
cmReg.value = (short) (insn->data[1] & 0xFFFF);
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
- // Load the pre-laod register high word
+ /* Load the pre-laod register high word */
value = (short) ((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- // Load the pre-laod register low word
+ /* Load the pre-laod register low word */
value = (short) (insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- // Write the Counter Control Register
+ /* Write the Counter Control Register */
if (insn->data[3] != 0) {
value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
- // Reset the counter if it is software preload
+ /* Reset the counter if it is software preload */
if (cmReg.reg.autoLoadResetRcap == 0) {
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Reset the counter
- outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); // Load the counter from PR0
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Reset the counter */
+ outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel)); /* Load the counter from PR0 */
}
#endif
break;
@@ -640,33 +640,33 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde
devpriv->s526_gpct_config[subdev_channel].app =
SinglePulseGeneration;
- // Set Counter Mode Register
+ /* Set Counter Mode Register */
cmReg.value = (short) (insn->data[1] & 0xFFFF);
- cmReg.reg.preloadRegSel = 0; // PR0
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
- // Load the pre-laod register 0 high word
+ /* Load the pre-laod register 0 high word */
value = (short) ((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- // Load the pre-laod register 0 low word
+ /* Load the pre-laod register 0 low word */
value = (short) (insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- // Set Counter Mode Register
+ /* Set Counter Mode Register */
cmReg.value = (short) (insn->data[1] & 0xFFFF);
- cmReg.reg.preloadRegSel = 1; // PR1
+ cmReg.reg.preloadRegSel = 1; /* PR1 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
- // Load the pre-laod register 1 high word
+ /* Load the pre-laod register 1 high word */
value = (short) ((insn->data[3] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- // Load the pre-laod register 1 low word
+ /* Load the pre-laod register 1 low word */
value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- // Write the Counter Control Register
+ /* Write the Counter Control Register */
if (insn->data[3] != 0) {
value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
@@ -685,33 +685,33 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde
devpriv->s526_gpct_config[subdev_channel].app =
PulseTrainGeneration;
- // Set Counter Mode Register
+ /* Set Counter Mode Register */
cmReg.value = (short) (insn->data[1] & 0xFFFF);
- cmReg.reg.preloadRegSel = 0; // PR0
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
- // Load the pre-laod register 0 high word
+ /* Load the pre-laod register 0 high word */
value = (short) ((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- // Load the pre-laod register 0 low word
+ /* Load the pre-laod register 0 low word */
value = (short) (insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- // Set Counter Mode Register
+ /* Set Counter Mode Register */
cmReg.value = (short) (insn->data[1] & 0xFFFF);
- cmReg.reg.preloadRegSel = 1; // PR1
+ cmReg.reg.preloadRegSel = 1; /* PR1 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
- // Load the pre-laod register 1 high word
+ /* Load the pre-laod register 1 high word */
value = (short) ((insn->data[3] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- // Load the pre-laod register 1 low word
+ /* Load the pre-laod register 1 low word */
value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
- // Write the Counter Control Register
+ /* Write the Counter Control Register */
if (insn->data[3] != 0) {
value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
@@ -727,16 +727,16 @@ static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subde
return insn->n;
}
-static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- int subdev_channel = CR_CHAN(insn->chanspec); // Unpack chanspec
+ int subdev_channel = CR_CHAN(insn->chanspec); /* Unpack chanspec */
short value;
printk("s526: GPCT_INSN_WRITE on channel %d\n", subdev_channel);
cmReg.value = inw(ADDR_CHAN_REG(REG_C0M, subdev_channel));
printk("s526: Counter Mode Register: %x\n", cmReg.value);
- // Check what Application of Counter this channel is configured for
+ /* Check what Application of Counter this channel is configured for */
switch (devpriv->s526_gpct_config[subdev_channel].app) {
case PositionMeasurement:
printk("S526: INSN_WRITE: PM\n");
@@ -776,18 +776,18 @@ static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice *
value = (short) (*data & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
break;
- default: // Impossible
+ default: /* Impossible */
printk("s526: INSN_WRITE: Functionality %d not implemented yet\n", devpriv->s526_gpct_config[subdev_channel].app);
return -EINVAL;
break;
}
- // return the number of samples written
+ /* return the number of samples written */
return insn->n;
}
#define ISR_ADC_DONE 0x4
-static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int result = -EINVAL;
@@ -803,14 +803,14 @@ static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevi
* enable channels here. The channel should be enabled in the
* INSN_READ handler. */
- // Enable ADC interrupt
+ /* Enable ADC interrupt */
outw(ISR_ADC_DONE, ADDR_REG(REG_IER));
-// printk("s526: ADC current value: 0x%04x\n", inw(ADDR_REG(REG_ADC)));
+/* printk("s526: ADC current value: 0x%04x\n", inw(ADDR_REG(REG_ADC))); */
devpriv->s526_ai_config = (data[0] & 0x3FF) << 5;
if (data[1] > 0)
- devpriv->s526_ai_config |= 0x8000; //set the delay
+ devpriv->s526_ai_config |= 0x8000; /* set the delay */
- devpriv->s526_ai_config |= 0x0001; // ADC start bit.
+ devpriv->s526_ai_config |= 0x0001; /* ADC start bit. */
return result;
}
@@ -819,8 +819,8 @@ static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevi
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
-static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
int chan = CR_CHAN(insn->chanspec);
@@ -837,8 +837,8 @@ static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
outw(value, ADDR_REG(REG_ADC));
-// printk("s526: Wrote 0x%04x to ADC\n", value);
-// printk("s526: ADC reg=0x%04x\n", inw(ADDR_REG(REG_ADC)));
+/* printk("s526: Wrote 0x%04x to ADC\n", value); */
+/* printk("s526: ADC reg=0x%04x\n", inw(ADDR_REG(REG_ADC))); */
#define TIMEOUT 100
/* wait for conversion to end */
@@ -850,16 +850,16 @@ static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
}
}
if (i == TIMEOUT) {
- /* rt_printk() should be used instead of printk()
+ /* printk() should be used instead of printk()
* whenever the code can be called from real-time. */
- rt_printk("s526: ADC(0x%04x) timeout\n",
+ printk("s526: ADC(0x%04x) timeout\n",
inw(ADDR_REG(REG_ISR)));
return -ETIMEDOUT;
}
/* read data */
d = inw(ADDR_REG(REG_ADD));
-// printk("AI[%d]=0x%04x\n", n, (unsigned short)(d & 0xFFFF));
+/* printk("AI[%d]=0x%04x\n", n, (unsigned short)(d & 0xFFFF)); */
/* munge data */
data[n] = d ^ 0x8000;
@@ -869,27 +869,27 @@ static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
return n;
}
-static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned short val;
-// printk("s526_ao_winsn\n");
+/* printk("s526_ao_winsn\n"); */
val = chan << 1;
-// outw(val, dev->iobase + REG_DAC);
+/* outw(val, dev->iobase + REG_DAC); */
outw(val, ADDR_REG(REG_DAC));
/* Writing a list of values to an AO channel is probably not
* very useful, but that's how the interface is defined. */
for (i = 0; i < insn->n; i++) {
/* a typical programming sequence */
-// outw(data[i], dev->iobase + REG_ADD); // write the data to preload register
- outw(data[i], ADDR_REG(REG_ADD)); // write the data to preload register
+/* outw(data[i], dev->iobase + REG_ADD); write the data to preload register */
+ outw(data[i], ADDR_REG(REG_ADD)); /* write the data to preload register */
devpriv->ao_readback[chan] = data[i];
-// outw(val + 1, dev->iobase + REG_DAC); // starts the D/A conversion.
- outw(val + 1, ADDR_REG(REG_DAC)); // starts the D/A conversion.
+/* outw(val + 1, dev->iobase + REG_DAC); starts the D/A conversion. */
+ outw(val + 1, ADDR_REG(REG_DAC)); /* starts the D/A conversion. */
}
/* return the number of samples read/written */
@@ -898,8 +898,8 @@ static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -915,8 +915,8 @@ static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -932,16 +932,16 @@ static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic
/* on return, data[1] contains the value of the digital
* input and output lines. */
- data[1] = inw(ADDR_REG(REG_DIO)) & 0xFF; // low 8 bits are the data
+ data[1] = inw(ADDR_REG(REG_DIO)) & 0xFF; /* low 8 bits are the data */
/* or we could just return the software copy of the output values if
* it was a purely digital output subdevice */
- //data[1]=s->state;
+ /* data[1]=s->state; */
return 2;
}
-static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
short value;
@@ -959,10 +959,10 @@ static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdev
* value COMEDI_INPUT or COMEDI_OUTPUT. */
if (data[0] == COMEDI_OUTPUT) {
- value |= 1 << (chan + 10); // bit 10/11 set the group 1/2's mode
+ value |= 1 << (chan + 10); /* bit 10/11 set the group 1/2's mode */
s->io_bits |= (0xF << chan);
} else {
- value &= ~(1 << (chan + 10)); // 1 is output, 0 is input.
+ value &= ~(1 << (chan + 10)); /* 1 is output, 0 is input. */
s->io_bits &= ~(0xF << chan);
}
outw(value, ADDR_REG(REG_DIO));
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 30dec9dab19b..92121cf8c45c 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -68,6 +68,7 @@ INSN_CONFIG instructions:
comedi_do_insn(cf,&insn); //executing configuration
*/
+#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/types.h>
@@ -95,14 +96,14 @@ struct s626_board {
static const struct s626_board s626_boards[] = {
{
- name: "s626",
- ai_chans : S626_ADC_CHANNELS,
- ai_bits: 14,
- ao_chans : S626_DAC_CHANNELS,
- ao_bits: 13,
- dio_chans : S626_DIO_CHANNELS,
- dio_banks : S626_DIO_BANKS,
- enc_chans : S626_ENCODER_CHANNELS,
+ .name = "s626",
+ .ai_chans = S626_ADC_CHANNELS,
+ .ai_bits = 14,
+ .ao_chans = S626_DAC_CHANNELS,
+ .ao_bits = 13,
+ .dio_chans = S626_DIO_CHANNELS,
+ .dio_banks = S626_DIO_BANKS,
+ .enc_chans = S626_ENCODER_CHANNELS,
}
};
@@ -122,10 +123,10 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static int s626_detach(struct comedi_device *dev);
static struct comedi_driver driver_s626 = {
- driver_name:"s626",
- module : THIS_MODULE,
- attach : s626_attach,
- detach : s626_detach,
+ .driver_name = "s626",
+ .module = THIS_MODULE,
+ .attach = s626_attach,
+ .detach = s626_detach,
};
struct s626_private {
@@ -173,39 +174,39 @@ struct dio_private {
};
static struct dio_private dio_private_A = {
- RDDIn:LP_RDDINA,
- WRDOut : LP_WRDOUTA,
- RDEdgSel : LP_RDEDGSELA,
- WREdgSel : LP_WREDGSELA,
- RDCapSel : LP_RDCAPSELA,
- WRCapSel : LP_WRCAPSELA,
- RDCapFlg : LP_RDCAPFLGA,
- RDIntSel : LP_RDINTSELA,
- WRIntSel : LP_WRINTSELA,
+ .RDDIn = LP_RDDINA,
+ .WRDOut = LP_WRDOUTA,
+ .RDEdgSel = LP_RDEDGSELA,
+ .WREdgSel = LP_WREDGSELA,
+ .RDCapSel = LP_RDCAPSELA,
+ .WRCapSel = LP_WRCAPSELA,
+ .RDCapFlg = LP_RDCAPFLGA,
+ .RDIntSel = LP_RDINTSELA,
+ .WRIntSel = LP_WRINTSELA,
};
static struct dio_private dio_private_B = {
- RDDIn:LP_RDDINB,
- WRDOut : LP_WRDOUTB,
- RDEdgSel : LP_RDEDGSELB,
- WREdgSel : LP_WREDGSELB,
- RDCapSel : LP_RDCAPSELB,
- WRCapSel : LP_WRCAPSELB,
- RDCapFlg : LP_RDCAPFLGB,
- RDIntSel : LP_RDINTSELB,
- WRIntSel : LP_WRINTSELB,
+ .RDDIn = LP_RDDINB,
+ .WRDOut = LP_WRDOUTB,
+ .RDEdgSel = LP_RDEDGSELB,
+ .WREdgSel = LP_WREDGSELB,
+ .RDCapSel = LP_RDCAPSELB,
+ .WRCapSel = LP_WRCAPSELB,
+ .RDCapFlg = LP_RDCAPFLGB,
+ .RDIntSel = LP_RDINTSELB,
+ .WRIntSel = LP_WRINTSELB,
};
static struct dio_private dio_private_C = {
- RDDIn:LP_RDDINC,
- WRDOut : LP_WRDOUTC,
- RDEdgSel : LP_RDEDGSELC,
- WREdgSel : LP_WREDGSELC,
- RDCapSel : LP_RDCAPSELC,
- WRCapSel : LP_WRCAPSELC,
- RDCapFlg : LP_RDCAPFLGC,
- RDIntSel : LP_RDINTSELC,
- WRIntSel : LP_WRINTSELC,
+ .RDDIn = LP_RDDINC,
+ .WRDOut = LP_WRDOUTC,
+ .RDEdgSel = LP_RDEDGSELC,
+ .WREdgSel = LP_WREDGSELC,
+ .RDCapSel = LP_RDCAPSELC,
+ .WRCapSel = LP_WRCAPSELC,
+ .RDCapFlg = LP_RDCAPFLGC,
+ .RDIntSel = LP_RDINTSELC,
+ .WRIntSel = LP_WRINTSELC,
};
/* to group dio devices (48 bits mask and data are not allowed ???)
@@ -253,7 +254,7 @@ static int s626_ns_to_timer(int *nanosec, int round_mode);
static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd);
static int s626_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum);
-static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG);
+static irqreturn_t s626_irq_handler(int irq, void *d);
static unsigned int s626_ai_reg_to_uint(int data);
/* static unsigned int s626_uint_to_reg(struct comedi_subdevice *s, int data); */
@@ -355,100 +356,100 @@ static void CountersInit(struct comedi_device *dev);
/* struct enc_private; */
static struct enc_private enc_private_data[] = {
{
- GetEnable:GetEnable_A,
- GetIntSrc : GetIntSrc_A,
- GetLoadTrig : GetLoadTrig_A,
- GetMode : GetMode_A,
- PulseIndex : PulseIndex_A,
- SetEnable : SetEnable_A,
- SetIntSrc : SetIntSrc_A,
- SetLoadTrig : SetLoadTrig_A,
- SetMode : SetMode_A,
- ResetCapFlags : ResetCapFlags_A,
- MyCRA : LP_CR0A,
- MyCRB : LP_CR0B,
- MyLatchLsw : LP_CNTR0ALSW,
- MyEventBits : EVBITS(0),
+ .GetEnable = GetEnable_A,
+ .GetIntSrc = GetIntSrc_A,
+ .GetLoadTrig = GetLoadTrig_A,
+ .GetMode = GetMode_A,
+ .PulseIndex = PulseIndex_A,
+ .SetEnable = SetEnable_A,
+ .SetIntSrc = SetIntSrc_A,
+ .SetLoadTrig = SetLoadTrig_A,
+ .SetMode = SetMode_A,
+ .ResetCapFlags = ResetCapFlags_A,
+ .MyCRA = LP_CR0A,
+ .MyCRB = LP_CR0B,
+ .MyLatchLsw = LP_CNTR0ALSW,
+ .MyEventBits = EVBITS(0),
},
{
- GetEnable:GetEnable_A,
- GetIntSrc : GetIntSrc_A,
- GetLoadTrig : GetLoadTrig_A,
- GetMode : GetMode_A,
- PulseIndex : PulseIndex_A,
- SetEnable : SetEnable_A,
- SetIntSrc : SetIntSrc_A,
- SetLoadTrig : SetLoadTrig_A,
- SetMode : SetMode_A,
- ResetCapFlags : ResetCapFlags_A,
- MyCRA : LP_CR1A,
- MyCRB : LP_CR1B,
- MyLatchLsw : LP_CNTR1ALSW,
- MyEventBits : EVBITS(1),
+ .GetEnable = GetEnable_A,
+ .GetIntSrc = GetIntSrc_A,
+ .GetLoadTrig = GetLoadTrig_A,
+ .GetMode = GetMode_A,
+ .PulseIndex = PulseIndex_A,
+ .SetEnable = SetEnable_A,
+ .SetIntSrc = SetIntSrc_A,
+ .SetLoadTrig = SetLoadTrig_A,
+ .SetMode = SetMode_A,
+ .ResetCapFlags = ResetCapFlags_A,
+ .MyCRA = LP_CR1A,
+ .MyCRB = LP_CR1B,
+ .MyLatchLsw = LP_CNTR1ALSW,
+ .MyEventBits = EVBITS(1),
},
{
- GetEnable:GetEnable_A,
- GetIntSrc : GetIntSrc_A,
- GetLoadTrig : GetLoadTrig_A,
- GetMode : GetMode_A,
- PulseIndex : PulseIndex_A,
- SetEnable : SetEnable_A,
- SetIntSrc : SetIntSrc_A,
- SetLoadTrig : SetLoadTrig_A,
- SetMode : SetMode_A,
- ResetCapFlags : ResetCapFlags_A,
- MyCRA : LP_CR2A,
- MyCRB : LP_CR2B,
- MyLatchLsw : LP_CNTR2ALSW,
- MyEventBits : EVBITS(2),
+ .GetEnable = GetEnable_A,
+ .GetIntSrc = GetIntSrc_A,
+ .GetLoadTrig = GetLoadTrig_A,
+ .GetMode = GetMode_A,
+ .PulseIndex = PulseIndex_A,
+ .SetEnable = SetEnable_A,
+ .SetIntSrc = SetIntSrc_A,
+ .SetLoadTrig = SetLoadTrig_A,
+ .SetMode = SetMode_A,
+ .ResetCapFlags = ResetCapFlags_A,
+ .MyCRA = LP_CR2A,
+ .MyCRB = LP_CR2B,
+ .MyLatchLsw = LP_CNTR2ALSW,
+ .MyEventBits = EVBITS(2),
},
{
- GetEnable:GetEnable_B,
- GetIntSrc : GetIntSrc_B,
- GetLoadTrig : GetLoadTrig_B,
- GetMode : GetMode_B,
- PulseIndex : PulseIndex_B,
- SetEnable : SetEnable_B,
- SetIntSrc : SetIntSrc_B,
- SetLoadTrig : SetLoadTrig_B,
- SetMode : SetMode_B,
- ResetCapFlags : ResetCapFlags_B,
- MyCRA : LP_CR0A,
- MyCRB : LP_CR0B,
- MyLatchLsw : LP_CNTR0BLSW,
- MyEventBits : EVBITS(3),
+ .GetEnable = GetEnable_B,
+ .GetIntSrc = GetIntSrc_B,
+ .GetLoadTrig = GetLoadTrig_B,
+ .GetMode = GetMode_B,
+ .PulseIndex = PulseIndex_B,
+ .SetEnable = SetEnable_B,
+ .SetIntSrc = SetIntSrc_B,
+ .SetLoadTrig = SetLoadTrig_B,
+ .SetMode = SetMode_B,
+ .ResetCapFlags = ResetCapFlags_B,
+ .MyCRA = LP_CR0A,
+ .MyCRB = LP_CR0B,
+ .MyLatchLsw = LP_CNTR0BLSW,
+ .MyEventBits = EVBITS(3),
},
{
- GetEnable:GetEnable_B,
- GetIntSrc : GetIntSrc_B,
- GetLoadTrig : GetLoadTrig_B,
- GetMode : GetMode_B,
- PulseIndex : PulseIndex_B,
- SetEnable : SetEnable_B,
- SetIntSrc : SetIntSrc_B,
- SetLoadTrig : SetLoadTrig_B,
- SetMode : SetMode_B,
- ResetCapFlags : ResetCapFlags_B,
- MyCRA : LP_CR1A,
- MyCRB : LP_CR1B,
- MyLatchLsw : LP_CNTR1BLSW,
- MyEventBits : EVBITS(4),
+ .GetEnable = GetEnable_B,
+ .GetIntSrc = GetIntSrc_B,
+ .GetLoadTrig = GetLoadTrig_B,
+ .GetMode = GetMode_B,
+ .PulseIndex = PulseIndex_B,
+ .SetEnable = SetEnable_B,
+ .SetIntSrc = SetIntSrc_B,
+ .SetLoadTrig = SetLoadTrig_B,
+ .SetMode = SetMode_B,
+ .ResetCapFlags = ResetCapFlags_B,
+ .MyCRA = LP_CR1A,
+ .MyCRB = LP_CR1B,
+ .MyLatchLsw = LP_CNTR1BLSW,
+ .MyEventBits = EVBITS(4),
},
{
- GetEnable:GetEnable_B,
- GetIntSrc : GetIntSrc_B,
- GetLoadTrig : GetLoadTrig_B,
- GetMode : GetMode_B,
- PulseIndex : PulseIndex_B,
- SetEnable : SetEnable_B,
- SetIntSrc : SetIntSrc_B,
- SetLoadTrig : SetLoadTrig_B,
- SetMode : SetMode_B,
- ResetCapFlags : ResetCapFlags_B,
- MyCRA : LP_CR2A,
- MyCRB : LP_CR2B,
- MyLatchLsw : LP_CNTR2BLSW,
- MyEventBits : EVBITS(5),
+ .GetEnable = GetEnable_B,
+ .GetIntSrc = GetIntSrc_B,
+ .GetLoadTrig = GetLoadTrig_B,
+ .GetMode = GetMode_B,
+ .PulseIndex = PulseIndex_B,
+ .SetEnable = SetEnable_B,
+ .SetIntSrc = SetIntSrc_B,
+ .SetLoadTrig = SetLoadTrig_B,
+ .SetMode = SetMode_B,
+ .ResetCapFlags = ResetCapFlags_B,
+ .MyCRA = LP_CR2A,
+ .MyCRB = LP_CR2B,
+ .MyLatchLsw = LP_CNTR2BLSW,
+ .MyEventBits = EVBITS(5),
},
};
@@ -596,8 +597,8 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (dev->irq == 0) {
printk(" unknown irq (bad)\n");
} else {
- ret = comedi_request_irq(dev->irq, s626_irq_handler,
- IRQF_SHARED, "s626", dev);
+ ret = request_irq(dev->irq, s626_irq_handler, IRQF_SHARED,
+ "s626", dev);
if (ret < 0) {
printk(" irq not available\n");
@@ -968,7 +969,7 @@ static unsigned int s626_ai_reg_to_uint(int data)
/* return 0; */
/* } */
-static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG)
+static irqreturn_t s626_irq_handler(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s;
@@ -987,7 +988,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG)
if (dev->attached == 0)
return IRQ_NONE;
/* lock to avoid race with comedi_poll */
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
+ spin_lock_irqsave(&dev->spinlock, flags);
/* save interrupt enable register state */
irqstatus = readl(devpriv->base_addr + P_IER);
@@ -1264,7 +1265,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d PT_REGS_ARG)
DEBUG("s626_irq_handler: exit interrupt service routine.\n");
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return IRQ_HANDLED;
}
@@ -1291,7 +1292,7 @@ static int s626_detach(struct comedi_device *dev)
}
if (dev->irq)
- comedi_free_irq(dev->irq, dev);
+ free_irq(dev->irq, dev);
if (devpriv->base_addr)
iounmap(devpriv->base_addr);
@@ -1574,7 +1575,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
for (n = 0; n < insn->n; n++) {
/* Delay 10 microseconds for analog input settling. */
- comedi_udelay(10);
+ udelay(10);
/* Start ADC by pulsing GPIO1 low. */
GpioImage = RR7146(P_GPIO);
@@ -1606,7 +1607,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
* data value is sometimes set to the previous
* conversion's data value.
*/
- comedi_udelay(4);
+ udelay(4);
}
/* Start a dummy conversion to cause the data from the
@@ -1886,31 +1887,16 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
err++;
}
- if (cmd->start_src == TRIG_EXT && cmd->start_arg < 0) {
- cmd->start_arg = 0;
- err++;
- }
-
if (cmd->start_src == TRIG_EXT && cmd->start_arg > 39) {
cmd->start_arg = 39;
err++;
}
- if (cmd->scan_begin_src == TRIG_EXT && cmd->scan_begin_arg < 0) {
- cmd->scan_begin_arg = 0;
- err++;
- }
-
if (cmd->scan_begin_src == TRIG_EXT && cmd->scan_begin_arg > 39) {
cmd->scan_begin_arg = 39;
err++;
}
- if (cmd->convert_src == TRIG_EXT && cmd->convert_arg < 0) {
- cmd->convert_arg = 0;
- err++;
- }
-
if (cmd->convert_src == TRIG_EXT && cmd->convert_arg > 39) {
cmd->convert_arg = 39;
err++;
@@ -2373,7 +2359,7 @@ static void LoadTrimDACs(struct comedi_device *dev)
register uint8_t i;
/* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
- for (i = 0; i < (sizeof(trimchan) / sizeof(trimchan[0])); i++)
+ for (i = 0; i < ARRAY_SIZE(trimchan); i++)
WriteTrimDAC(dev, i, I2Cread(dev, trimadrs[i]));
}
diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h
index 891126f25099..27ae02be5300 100644
--- a/drivers/staging/comedi/drivers/s626.h
+++ b/drivers/staging/comedi/drivers/s626.h
@@ -63,7 +63,7 @@
*/
#ifdef _DEBUG_
-#define DEBUG(...); rt_printk(__VA_ARGS__);
+#define DEBUG(...); printk(__VA_ARGS__);
#else
#define DEBUG(...)
#endif
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index 844fd5e2e3a9..db18b11b9d30 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -52,7 +52,7 @@ struct serial2002_board {
static const struct serial2002_board serial2002_boards[] = {
{
- name: "serial2002"}
+ .name = "serial2002"}
};
/*
@@ -62,7 +62,7 @@ static const struct serial2002_board serial2002_boards[] = {
struct serial2002_range_table_t {
- // HACK...
+ /* HACK... */
int length;
struct comedi_krange range;
};
@@ -70,8 +70,8 @@ struct serial2002_range_table_t {
struct serial2002_private {
- int port; // /dev/ttyS<port>
- int speed; // baudrate
+ int port; /* /dev/ttyS<port> */
+ int speed; /* baudrate */
struct file *tty;
unsigned int ao_readback[32];
unsigned char digital_in_mapping[32];
@@ -89,28 +89,28 @@ struct serial2002_private {
*/
#define devpriv ((struct serial2002_private *)dev->private)
-static int serial2002_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int serial2002_detach(struct comedi_device * dev);
+static int serial2002_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int serial2002_detach(struct comedi_device *dev);
struct comedi_driver driver_serial2002 = {
- driver_name:"serial2002",
- module:THIS_MODULE,
- attach:serial2002_attach,
- detach:serial2002_detach,
- board_name:&serial2002_boards[0].name,
- offset:sizeof(struct serial2002_board),
- num_names:sizeof(serial2002_boards) / sizeof(struct serial2002_board),
+ .driver_name = "serial2002",
+ .module = THIS_MODULE,
+ .attach = serial2002_attach,
+ .detach = serial2002_detach,
+ .board_name = &serial2002_boards[0].name,
+ .offset = sizeof(struct serial2002_board),
+ .num_names = ARRAY_SIZE(serial2002_boards),
};
-static int serial2002_di_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int serial2002_do_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int serial2002_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int serial2002_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int serial2002_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
+static int serial2002_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int serial2002_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int serial2002_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int serial2002_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int serial2002_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
struct serial_data {
enum { is_invalid, is_digital, is_channel } kind;
@@ -121,12 +121,12 @@ struct serial_data {
static long tty_ioctl(struct file *f, unsigned op, unsigned long param)
{
#ifdef HAVE_UNLOCKED_IOCTL
- if (f->f_op->unlocked_ioctl) {
+ if (f->f_op->unlocked_ioctl) {
return f->f_op->unlocked_ioctl(f, op, param);
}
#endif
if (f->f_op->ioctl) {
- return f->f_op->ioctl(f->f_dentry->d_inode, f, op, param);
+ return f->f_op->ioctl(f->f_dentry->d_inode, f, op, param);
}
return -ENOSYS;
}
@@ -211,7 +211,7 @@ static int tty_read(struct file *f, int timeout)
/* Device does not support poll, busy wait */
int retries = 0;
while (1) {
- unsigned char ch;
+ unsigned char ch;
retries++;
if (retries >= timeout) {
@@ -220,10 +220,10 @@ static int tty_read(struct file *f, int timeout)
f->f_pos = 0;
if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) {
- result = ch;
+ result = ch;
break;
}
- comedi_udelay(100);
+ udelay(100);
}
}
set_fs(oldfs);
@@ -238,11 +238,11 @@ static void tty_setspeed(struct file *f, int speed)
oldfs = get_fs();
set_fs(KERNEL_DS);
{
- // Set speed
+ /* Set speed */
struct termios settings;
tty_ioctl(f, TCGETS, (unsigned long)&settings);
-// printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX));
+/* printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX)); */
settings.c_iflag = 0;
settings.c_oflag = 0;
settings.c_lflag = 0;
@@ -284,10 +284,10 @@ static void tty_setspeed(struct file *f, int speed)
break;
}
tty_ioctl(f, TCSETS, (unsigned long)&settings);
-// printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX));
+/* printk("Speed: %d\n", settings.c_cflag & (CBAUD | CBAUDEX)); */
}
{
- // Set low latency
+ /* Set low latency */
struct serial_struct settings;
tty_ioctl(f, TIOCGSERIAL, (unsigned long)&settings);
@@ -393,7 +393,7 @@ static void serial_write(struct file *f, struct serial_data data)
}
}
-static void serial_2002_open(struct comedi_device * dev)
+static void serial_2002_open(struct comedi_device *dev)
{
char port[20];
@@ -437,7 +437,7 @@ static void serial_2002_open(struct comedi_device * dev)
}
tty_setspeed(devpriv->tty, devpriv->speed);
- poll_channel(devpriv->tty, 31); // Start reading configuration
+ poll_channel(devpriv->tty, 31); /* Start reading configuration */
while (1) {
struct serial_data data;
@@ -557,7 +557,7 @@ static void serial_2002_open(struct comedi_device * dev)
}
}
for (i = 0; i <= 4; i++) {
- // Fill in subdev data
+ /* Fill in subdev data */
struct config_t *c;
unsigned char *mapping = 0;
struct serial2002_range_table_t *range = 0;
@@ -659,15 +659,15 @@ static void serial_2002_open(struct comedi_device * dev)
}
}
-static void serial_2002_close(struct comedi_device * dev)
+static void serial_2002_close(struct comedi_device *dev)
{
if (!IS_ERR(devpriv->tty) && (devpriv->tty != 0)) {
filp_close(devpriv->tty, 0);
}
}
-static int serial2002_di_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int serial2002_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan;
@@ -688,8 +688,8 @@ static int serial2002_di_rinsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int serial2002_do_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int serial2002_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan;
@@ -706,8 +706,8 @@ static int serial2002_do_winsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int serial2002_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int serial2002_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan;
@@ -728,8 +728,8 @@ static int serial2002_ai_rinsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int serial2002_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int serial2002_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan;
@@ -747,8 +747,8 @@ static int serial2002_ao_winsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int serial2002_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int serial2002_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -760,8 +760,8 @@ static int serial2002_ao_rinsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int serial2002_ei_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int serial2002_ei_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan;
@@ -782,7 +782,7 @@ static int serial2002_ei_rinsn(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int serial2002_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int serial2002_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
@@ -849,7 +849,7 @@ static int serial2002_attach(struct comedi_device * dev, struct comedi_devconfig
return 1;
}
-static int serial2002_detach(struct comedi_device * dev)
+static int serial2002_detach(struct comedi_device *dev)
{
struct comedi_subdevice *s;
int i;
diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c
index c7700d134cc1..07f580a48206 100644
--- a/drivers/staging/comedi/drivers/skel.c
+++ b/drivers/staging/comedi/drivers/skel.c
@@ -97,16 +97,16 @@ struct skel_board {
static const struct skel_board skel_boards[] = {
{
- name: "skel-100",
- ai_chans:16,
- ai_bits: 12,
- have_dio:1,
+ .name = "skel-100",
+ .ai_chans = 16,
+ .ai_bits = 12,
+ .have_dio = 1,
},
{
- name: "skel-200",
- ai_chans:8,
- ai_bits: 16,
- have_dio:0,
+ .name = "skel-200",
+ .ai_chans = 8,
+ .ai_bits = 16,
+ .have_dio = 0,
},
};
@@ -154,13 +154,13 @@ struct skel_private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int skel_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int skel_detach(struct comedi_device * dev);
+static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int skel_detach(struct comedi_device *dev);
static struct comedi_driver driver_skel = {
- driver_name:"dummy",
- module:THIS_MODULE,
- attach:skel_attach,
- detach:skel_detach,
+ .driver_name = "dummy",
+ .module = THIS_MODULE,
+ .attach = skel_attach,
+ .detach = skel_detach,
/* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by
@@ -179,23 +179,23 @@ static struct comedi_driver driver_skel = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- board_name:&skel_boards[0].name,
- offset:sizeof(struct skel_board),
- num_names:sizeof(skel_boards) / sizeof(struct skel_board),
+ .board_name = &skel_boards[0].name,
+ .offset = sizeof(struct skel_board),
+ .num_names = ARRAY_SIZE(skel_boards),
};
-static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int skel_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int skel_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int skel_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int skel_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data);
-static int skel_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd);
+static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int skel_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
static int skel_ns_to_timer(unsigned int *ns, int round);
/*
@@ -204,7 +204,7 @@ static int skel_ns_to_timer(unsigned int *ns, int round);
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int skel_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
@@ -292,7 +292,7 @@ static int skel_attach(struct comedi_device * dev, struct comedi_devconfig * it)
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int skel_detach(struct comedi_device * dev)
+static int skel_detach(struct comedi_device *dev)
{
printk("comedi%d: skel: remove\n", dev->minor);
@@ -303,8 +303,8 @@ static int skel_detach(struct comedi_device * dev)
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
-static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
unsigned int d;
@@ -331,9 +331,9 @@ static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
break;
}
if (i == TIMEOUT) {
- /* rt_printk() should be used instead of printk()
+ /* printk() should be used instead of printk()
* whenever the code can be called from real-time. */
- rt_printk("timeout\n");
+ printk("timeout\n");
return -ETIMEDOUT;
}
@@ -351,8 +351,8 @@ static int skel_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
return n;
}
-static int skel_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -520,8 +520,8 @@ static int skel_ns_to_timer(unsigned int *ns, int round)
return *ns;
}
-static int skel_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -541,8 +541,8 @@ static int skel_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int skel_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -558,8 +558,8 @@ static int skel_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int skel_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int skel_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -583,8 +583,8 @@ static int skel_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevic
return 2;
}
-static int skel_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c
index 1628d216cdd4..13c29bb99100 100644
--- a/drivers/staging/comedi/drivers/ssv_dnp.c
+++ b/drivers/staging/comedi/drivers/ssv_dnp.c
@@ -61,10 +61,10 @@ struct dnp_board {
static const struct dnp_board dnp_boards[] = { /* we only support one DNP 'board' */
{ /* variant at the moment */
- name: "dnp-1486",
- ai_chans:16,
- ai_bits: 12,
- have_dio:1,
+ .name = "dnp-1486",
+ .ai_chans = 16,
+ .ai_bits = 12,
+ .have_dio = 1,
},
};
@@ -74,7 +74,6 @@ static const struct dnp_board dnp_boards[] = { /* we only support one DNP 'board
/* This structure is for data unique to the DNP driver --------------------- */
struct dnp_private_data {
- //
};
@@ -89,27 +88,27 @@ struct dnp_private_data {
/* In the following section we define the API of this driver. */
/* ------------------------------------------------------------------------- */
-static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int dnp_detach(struct comedi_device * dev);
+static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dnp_detach(struct comedi_device *dev);
static struct comedi_driver driver_dnp = {
- driver_name:"ssv_dnp",
- module:THIS_MODULE,
- attach:dnp_attach,
- detach:dnp_detach,
- board_name:&dnp_boards[0].name,
+ .driver_name = "ssv_dnp",
+ .module = THIS_MODULE,
+ .attach = dnp_attach,
+ .detach = dnp_detach,
+ .board_name = &dnp_boards[0].name,
/* only necessary for non-PnP devs */
- offset:sizeof(struct dnp_board),/* like ISA-PnP, PCI or PCMCIA. */
- num_names:sizeof(dnp_boards) / sizeof(struct dnp_board),
+ .offset = sizeof(struct dnp_board),/* like ISA-PnP, PCI or PCMCIA. */
+ .num_names = ARRAY_SIZE(dnp_boards),
};
COMEDI_INITCLEANUP(driver_dnp);
-static int dnp_dio_insn_bits(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int dnp_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int dnp_dio_insn_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int dnp_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
/* ------------------------------------------------------------------------- */
/* Attach is called by comedi core to configure the driver for a particular */
@@ -117,7 +116,7 @@ static int dnp_dio_insn_config(struct comedi_device * dev,
/* dev->board_ptr contains that address. */
/* ------------------------------------------------------------------------- */
-static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
@@ -126,7 +125,7 @@ static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it)
/* Autoprobing: this should find out which board we have. Currently only */
/* the 1486 board is supported and autoprobing is not implemented :-) */
- //dev->board_ptr = dnp_probe(dev);
+ /* dev->board_ptr = dnp_probe(dev); */
/* Initialize the name of the board. We can use the "thisboard" macro now. */
dev->board_name = thisboard->name;
@@ -178,7 +177,7 @@ static int dnp_attach(struct comedi_device * dev, struct comedi_devconfig * it)
/* deallocated automatically by the core. */
/* ------------------------------------------------------------------------- */
-static int dnp_detach(struct comedi_device * dev)
+static int dnp_detach(struct comedi_device *dev)
{
/* configure all ports as input (default) */
@@ -202,8 +201,8 @@ static int dnp_detach(struct comedi_device * dev)
/* are able to use these instructions as well. */
/* ------------------------------------------------------------------------- */
-static int dnp_dio_insn_bits(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int dnp_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
@@ -252,8 +251,8 @@ static int dnp_dio_insn_bits(struct comedi_device * dev,
/* COMEDI_INPUT or COMEDI_OUTPUT. */
/* ------------------------------------------------------------------------- */
-static int dnp_dio_insn_config(struct comedi_device * dev,
- struct comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data)
+static int dnp_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{
u8 register_buffer;
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c
index dd3b1119319b..96bb15ccccb1 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -80,38 +80,38 @@ struct unioxx5_subd_priv {
unsigned char usp_prev_cn_val[3]; /* previous channel value */
};
-static int unioxx5_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int unioxx5_subdev_write(struct comedi_device * dev, struct comedi_subdevice * subdev,
- struct comedi_insn * insn, unsigned int * data);
-static int unioxx5_subdev_read(struct comedi_device * dev, struct comedi_subdevice * subdev,
- struct comedi_insn * insn, unsigned int * data);
-static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevice * subdev,
- struct comedi_insn * insn, unsigned int * data);
-static int unioxx5_detach(struct comedi_device * dev);
-static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_iobase,
+static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int unioxx5_subdev_write(struct comedi_device *dev, struct comedi_subdevice *subdev,
+ struct comedi_insn *insn, unsigned int *data);
+static int unioxx5_subdev_read(struct comedi_device *dev, struct comedi_subdevice *subdev,
+ struct comedi_insn *insn, unsigned int *data);
+static int unioxx5_insn_config(struct comedi_device *dev, struct comedi_subdevice *subdev,
+ struct comedi_insn *insn, unsigned int *data);
+static int unioxx5_detach(struct comedi_device *dev);
+static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, int subdev_iobase,
int minor);
-static int __unioxx5_digital_write(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor);
-static int __unioxx5_digital_read(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor);
-//static void __unioxx5_digital_config(struct unioxx5_subd_priv* usp, int mode);
-static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int * data,
+/* static void __unioxx5_digital_config(struct unioxx5_subd_priv* usp, int mode); */
+static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor);
-static int __unioxx5_analog_read(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor);
static int __unioxx5_define_chan_offset(int chan_num);
-static void __unioxx5_analog_config(struct unioxx5_subd_priv * usp, int channel);
+static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel);
static struct comedi_driver unioxx5_driver = {
- driver_name:DRIVER_NAME,
- module:THIS_MODULE,
- attach:unioxx5_attach,
- detach:unioxx5_detach
+ .driver_name = DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = unioxx5_attach,
+ .detach = unioxx5_detach
};
COMEDI_INITCLEANUP(unioxx5_driver);
-static int unioxx5_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int iobase, i, n_subd;
int id, num, ba;
@@ -156,8 +156,8 @@ static int unioxx5_attach(struct comedi_device * dev, struct comedi_devconfig *
return 0;
}
-static int unioxx5_subdev_read(struct comedi_device * dev, struct comedi_subdevice * subdev,
- struct comedi_insn * insn, unsigned int * data)
+static int unioxx5_subdev_read(struct comedi_device *dev, struct comedi_subdevice *subdev,
+ struct comedi_insn *insn, unsigned int *data)
{
struct unioxx5_subd_priv *usp = subdev->private;
int channel, type;
@@ -176,8 +176,8 @@ static int unioxx5_subdev_read(struct comedi_device * dev, struct comedi_subdevi
return 1;
}
-static int unioxx5_subdev_write(struct comedi_device * dev, struct comedi_subdevice * subdev,
- struct comedi_insn * insn, unsigned int * data)
+static int unioxx5_subdev_write(struct comedi_device *dev, struct comedi_subdevice *subdev,
+ struct comedi_insn *insn, unsigned int *data)
{
struct unioxx5_subd_priv *usp = subdev->private;
int channel, type;
@@ -197,8 +197,8 @@ static int unioxx5_subdev_write(struct comedi_device * dev, struct comedi_subdev
}
/* for digital modules only */
-static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevice * subdev,
- struct comedi_insn * insn, unsigned int * data)
+static int unioxx5_insn_config(struct comedi_device *dev, struct comedi_subdevice *subdev,
+ struct comedi_insn *insn, unsigned int *data)
{
int channel_offset, flags, channel = CR_CHAN(insn->chanspec), type;
struct unioxx5_subd_priv *usp = subdev->private;
@@ -213,7 +213,8 @@ static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevi
return -1;
}
- if ((channel_offset = __unioxx5_define_chan_offset(channel)) < 0) {
+ channel_offset = __unioxx5_define_chan_offset(channel);
+ if (channel_offset < 0) {
printk(KERN_ERR
"comedi%d: undefined channel %d. channel range is 0 .. 23\n",
dev->minor, channel);
@@ -247,7 +248,7 @@ static int unioxx5_insn_config(struct comedi_device * dev, struct comedi_subdevi
return 0;
}
-static int unioxx5_detach(struct comedi_device * dev)
+static int unioxx5_detach(struct comedi_device *dev)
{
int i;
struct comedi_subdevice *subdev;
@@ -264,7 +265,7 @@ static int unioxx5_detach(struct comedi_device * dev)
}
/* initializing subdevice with given address */
-static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_iobase,
+static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, int subdev_iobase,
int minor)
{
struct unioxx5_subd_priv *usp;
@@ -275,8 +276,9 @@ static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_io
return -EIO;
}
- if ((usp = (struct unioxx5_subd_priv *) kzalloc(sizeof(*usp),
- GFP_KERNEL)) == NULL) {
+ usp = (struct unioxx5_subd_priv *) kzalloc(sizeof(*usp), GFP_KERNEL);
+
+ if (usp == NULL) {
printk(KERN_ERR "comedi%d: erorr! --> out of memory!\n", minor);
return -1;
}
@@ -309,7 +311,7 @@ static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_io
usp->usp_module_type[i] = inb(subdev_iobase + 6);
printk(" [%d] 0x%02x |", i, usp->usp_module_type[i]);
- comedi_udelay(1);
+ udelay(1);
}
printk("\n");
@@ -330,13 +332,14 @@ static int __unioxx5_subdev_init(struct comedi_subdevice * subdev, int subdev_io
return 0;
}
-static int __unioxx5_digital_write(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor)
{
int channel_offset, val;
int mask = 1 << (channel & 0x07);
- if ((channel_offset = __unioxx5_define_chan_offset(channel)) < 0) {
+ channel_offset = __unioxx5_define_chan_offset(channel);
+ if (channel_offset < 0) {
printk(KERN_ERR
"comedi%d: undefined channel %d. channel range is 0 .. 23\n",
minor, channel);
@@ -357,12 +360,13 @@ static int __unioxx5_digital_write(struct unioxx5_subd_priv * usp, unsigned int
}
/* function for digital reading */
-static int __unioxx5_digital_read(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor)
{
int channel_offset, mask = 1 << (channel & 0x07);
- if ((channel_offset = __unioxx5_define_chan_offset(channel)) < 0) {
+ channel_offset = __unioxx5_define_chan_offset(channel);
+ if (channel_offset < 0) {
printk(KERN_ERR
"comedi%d: undefined channel %d. channel range is 0 .. 23\n",
minor, channel);
@@ -380,7 +384,7 @@ static int __unioxx5_digital_read(struct unioxx5_subd_priv * usp, unsigned int *
}
#if 0 /* not used? */
-static void __unioxx5_digital_config(struct unioxx5_subd_priv * usp, int mode)
+static void __unioxx5_digital_config(struct unioxx5_subd_priv *usp, int mode)
{
int i, mask;
@@ -396,7 +400,7 @@ static void __unioxx5_digital_config(struct unioxx5_subd_priv * usp, int mode)
}
#endif
-static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor)
{
int module, i;
@@ -418,7 +422,7 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int *
/* saving major byte */
usp->usp_extra_data[module][i] = (unsigned char)((*data & 0xFF00) >> 8);
- //while(!((inb(usp->usp_iobase + 0)) & TxBE));
+ /* while(!((inb(usp->usp_iobase + 0)) & TxBE)); */
outb(module + 1, usp->usp_iobase + 5); /* sending module number to card(1 .. 12) */
outb('W', usp->usp_iobase + 6); /* sends (W)rite command to module */
@@ -431,7 +435,7 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv * usp, unsigned int *
return 1;
}
-static int __unioxx5_analog_read(struct unioxx5_subd_priv * usp, unsigned int * data,
+static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, unsigned int *data,
int channel, int minor)
{
int module_no, read_ch;
@@ -471,7 +475,7 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv * usp, unsigned int *
}
/* configure channels for analog i/o (even to output, odd to input) */
-static void __unioxx5_analog_config(struct unioxx5_subd_priv * usp, int channel)
+static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel)
{
int chan_a, chan_b, conf, channel_offset;
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index d0b59e98314b..eea7dbdde0be 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -809,32 +809,56 @@ static int usbduxsub_upload(struct usbduxsub *usbduxsub,
return 0;
}
-static int firmwareUpload(struct usbduxsub *usbduxsub, uint8_t *firmwareBinary,
+#define FIRMWARE_MAX_LEN 0x2000
+
+static int firmwareUpload(struct usbduxsub *usbduxsub,
+ const u8 *firmwareBinary,
int sizeFirmware)
{
int ret;
+ uint8_t *fwBuf;
if (!firmwareBinary)
return 0;
+ if (sizeFirmware>FIRMWARE_MAX_LEN) {
+ dev_err(&usbduxsub->interface->dev,
+ "comedi_: usbdux firmware binary it too large for FX2.\n");
+ return -ENOMEM;
+ }
+
+ /* we generate a local buffer for the firmware */
+ fwBuf = kzalloc(sizeFirmware, GFP_KERNEL);
+ if (!fwBuf) {
+ dev_err(&usbduxsub->interface->dev,
+ "comedi_: mem alloc for firmware failed\n");
+ return -ENOMEM;
+ }
+ memcpy(fwBuf,firmwareBinary,sizeFirmware);
+
ret = usbduxsub_stop(usbduxsub);
if (ret < 0) {
dev_err(&usbduxsub->interface->dev,
"comedi_: can not stop firmware\n");
+ kfree(fwBuf);
return ret;
}
- ret = usbduxsub_upload(usbduxsub, firmwareBinary, 0, sizeFirmware);
+
+ ret = usbduxsub_upload(usbduxsub, fwBuf, 0, sizeFirmware);
if (ret < 0) {
dev_err(&usbduxsub->interface->dev,
"comedi_: firmware upload failed\n");
+ kfree(fwBuf);
return ret;
}
ret = usbduxsub_start(usbduxsub);
if (ret < 0) {
dev_err(&usbduxsub->interface->dev,
"comedi_: can not start firmware\n");
+ kfree(fwBuf);
return ret;
}
+ kfree(fwBuf);
return 0;
}
@@ -2260,134 +2284,6 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
usbduxsub_tmp->pwm_cmd_running = 0;
}
-static unsigned hex2unsigned(char *h)
-{
- unsigned hi, lo;
-
- if (h[0] > '9')
- hi = h[0] - 'A' + 0x0a;
- else
- hi = h[0] - '0';
-
- if (h[1] > '9')
- lo = h[1] - 'A' + 0x0a;
- else
- lo = h[1] - '0';
-
- return hi * 0x10 + lo;
-}
-
-/* for FX2 */
-#define FIRMWARE_MAX_LEN 0x2000
-
-/* taken from David Brownell's fxload and adjusted for this driver */
-static int read_firmware(struct usbduxsub *usbduxsub, const void *firmwarePtr,
- long size)
-{
- struct device *dev = &usbduxsub->interface->dev;
- int i = 0;
- unsigned char *fp = (char *)firmwarePtr;
- unsigned char *firmwareBinary;
- int res = 0;
- int maxAddr = 0;
-
- firmwareBinary = kzalloc(FIRMWARE_MAX_LEN, GFP_KERNEL);
- if (!firmwareBinary) {
- dev_err(dev, "comedi_: mem alloc for firmware failed\n");
- return -ENOMEM;
- }
-
- for (;;) {
- char buf[256], *cp;
- char type;
- int len;
- int idx, off;
- int j = 0;
-
- /* get one line */
- while ((i < size) && (fp[i] != 13) && (fp[i] != 10)) {
- buf[j] = fp[i];
- i++;
- j++;
- if (j >= sizeof(buf)) {
- dev_err(dev, "comedi_: bogus firmware file!\n");
- kfree(firmwareBinary);
- return -1;
- }
- }
- /* get rid of LF/CR/... */
- while ((i < size) && ((fp[i] == 13) || (fp[i] == 10)
- || (fp[i] == 0))) {
- i++;
- }
-
- buf[j] = 0;
- /* dev_dbg(dev, "comedi_: buf=%s\n", buf); */
-
- /*
- * EXTENSION:
- * "# comment-till-end-of-line", for copyrights etc
- */
- if (buf[0] == '#')
- continue;
-
- if (buf[0] != ':') {
- dev_err(dev, "comedi_: upload: not an ihex record: %s",
- buf);
- kfree(firmwareBinary);
- return -EFAULT;
- }
-
- /* Read the length field (up to 16 bytes) */
- len = hex2unsigned(buf + 1);
-
- /* Read the target offset */
- off = (hex2unsigned(buf + 3) * 0x0100) + hex2unsigned(buf + 5);
-
- if ((off + len) > maxAddr)
- maxAddr = off + len;
-
-
- if (maxAddr >= FIRMWARE_MAX_LEN) {
- dev_err(dev, "comedi_: firmware upload goes "
- "beyond FX2 RAM boundaries.\n");
- kfree(firmwareBinary);
- return -EFAULT;
- }
- /* dev_dbg(dev, "comedi_: off=%x, len=%x:\n", off, len); */
-
- /* Read the record type */
- type = hex2unsigned(buf + 7);
-
- /* If this is an EOF record, then make it so. */
- if (type == 1)
- break;
-
-
- if (type != 0) {
- dev_err(dev, "comedi_: unsupported record type: %u\n",
- type);
- kfree(firmwareBinary);
- return -EFAULT;
- }
-
- for (idx = 0, cp = buf + 9; idx < len; idx += 1, cp += 2) {
- firmwareBinary[idx + off] = hex2unsigned(cp);
- /*printk("%02x ",firmwareBinary[idx+off]); */
- }
- /*printk("\n"); */
-
- if (i >= size) {
- dev_err(dev, "comedi_: unexpected end of hex file\n");
- break;
- }
-
- }
- res = firmwareUpload(usbduxsub, firmwareBinary, maxAddr + 1);
- kfree(firmwareBinary);
- return res;
-}
-
static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
void *context)
{
@@ -2405,7 +2301,7 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
* we need to upload the firmware here because fw will be
* freed once we've left this function
*/
- ret = read_firmware(usbduxsub_tmp, fw->data, fw->size);
+ ret = firmwareUpload(usbduxsub_tmp, fw->data, fw->size);
if (ret) {
dev_err(&usbdev->dev,
@@ -2662,11 +2558,13 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
ret = request_firmware_nowait(THIS_MODULE,
FW_ACTION_HOTPLUG,
- "usbdux_firmware.hex",
+ "usbdux_firmware.bin",
&udev->dev,
usbduxsub + index,
usbdux_firmware_request_complete_handler);
+
+
if (ret) {
dev_err(dev, "Could not load firmware (err=%d)\n", ret);
return ret;
@@ -2739,8 +2637,8 @@ static int usbdux_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* trying to upload the firmware into the chip */
if (comedi_aux_data(it->options, 0) &&
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
- read_firmware(udev, comedi_aux_data(it->options, 0),
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
+ firmwareUpload(udev, comedi_aux_data(it->options, 0),
+ it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
}
dev->board_name = BOARDNAME;
diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index 2fb64de3f86b..5862078bfbb9 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -314,7 +314,7 @@ static int usbduxfast_ai_cancel(struct comedi_device *dev, struct comedi_subdevi
* analogue IN
* interrupt service routine
*/
-static void usbduxfastsub_ai_Irq(struct urb *urb PT_REGS_ARG)
+static void usbduxfastsub_ai_Irq(struct urb *urb)
{
int n, err;
struct usbduxfastsub_s *udfs;
@@ -524,33 +524,6 @@ static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs,
return 0;
}
-int firmwareUpload(struct usbduxfastsub_s *udfs, unsigned char *firmwareBinary,
- int sizeFirmware)
-{
- int ret;
-
- if (!firmwareBinary)
- return 0;
-
- ret = usbduxfastsub_stop(udfs);
- if (ret < 0) {
- printk(KERN_ERR "comedi_: usbduxfast: can not stop firmware\n");
- return ret;
- }
- ret = usbduxfastsub_upload(udfs, firmwareBinary, 0, sizeFirmware);
- if (ret < 0) {
- printk(KERN_ERR "comedi_: usbduxfast: firmware upload failed\n");
- return ret;
- }
- ret = usbduxfastsub_start(udfs);
- if (ret < 0) {
- printk(KERN_ERR "comedi_: usbduxfast: can not start firmware\n");
- return ret;
- }
-
- return 0;
-}
-
int usbduxfastsub_submit_InURBs(struct usbduxfastsub_s *udfs)
{
int ret;
@@ -1365,136 +1338,61 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
return i;
}
-static unsigned hex2unsigned(char *h)
-{
- unsigned hi, lo;
-
- if (h[0] > '9')
- hi = h[0] - 'A' + 0x0a;
- else
- hi = h[0] - '0';
-
- if (h[1] > '9')
- lo = h[1] - 'A' + 0x0a;
- else
- lo = h[1] - '0';
-
- return hi * 0x10 + lo;
-}
-
-/* for FX2 */
#define FIRMWARE_MAX_LEN 0x2000
-/*
- * taken from David Brownell's fxload and adjusted for this driver
- */
-static int read_firmware(struct usbduxfastsub_s *udfs, const void *firmwarePtr,
- long size)
+static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub,
+ const u8 *firmwareBinary,
+ int sizeFirmware)
{
- int i = 0;
- unsigned char *fp = (char *)firmwarePtr;
- unsigned char *firmwareBinary;
- int res = 0;
- int maxAddr = 0;
-
- firmwareBinary = kmalloc(FIRMWARE_MAX_LEN, GFP_KERNEL);
- if (!firmwareBinary) {
- printk(KERN_ERR "comedi_: usbduxfast: mem alloc for firmware "
- " failed\n");
- return -ENOMEM;
- }
-
- for (;;) {
- char buf[256], *cp;
- char type;
- int len;
- int idx, off;
- int j = 0;
-
- /* get one line */
- while ((i < size) && (fp[i] != 13) && (fp[i] != 10)) {
- buf[j] = fp[i];
- i++;
- j++;
- if (j >= sizeof(buf)) {
- printk(KERN_ERR "comedi_: usbduxfast: bogus "
- "firmware file!\n");
- kfree(firmwareBinary);
- return -1;
- }
- }
- /* get rid of LF/CR/... */
- while ((i < size) && ((fp[i] == 13) || (fp[i] == 10)
- || (fp[i] == 0)))
- i++;
-
- buf[j] = 0;
- /* printk("comedi_: buf=%s\n",buf); */
-
- /*
- * EXTENSION: "# comment-till-end-of-line",
- * for copyrights etc
- */
- if (buf[0] == '#')
- continue;
-
- if (buf[0] != ':') {
- printk(KERN_ERR "comedi_: usbduxfast: upload: not an "
- "ihex record: %s", buf);
- kfree(firmwareBinary);
- return -EFAULT;
- }
-
- /* Read the length field (up to 16 bytes) */
- len = hex2unsigned(buf + 1);
-
- /* Read the target offset */
- off = (hex2unsigned(buf + 3) * 0x0100) + hex2unsigned(buf + 5);
-
- if ((off + len) > maxAddr)
- maxAddr = off + len;
-
- if (maxAddr >= FIRMWARE_MAX_LEN) {
- printk(KERN_ERR "comedi_: usbduxfast: firmware upload "
- "goes beyond FX2 RAM boundaries.");
- kfree(firmwareBinary);
- return -EFAULT;
- }
- /* printk("comedi_: usbduxfast: off=%x, len=%x:",off,len); */
-
- /* Read the record type */
- type = hex2unsigned(buf + 7);
-
- /* If this is an EOF record, then make it so. */
- if (type == 1)
- break;
+ int ret;
+ uint8_t *fwBuf;
- if (type != 0) {
- printk(KERN_ERR "comedi_: usbduxfast: unsupported "
- "record type: %u\n", type);
- kfree(firmwareBinary);
- return -EFAULT;
- }
+ if (!firmwareBinary)
+ return 0;
- for (idx = 0, cp = buf + 9; idx < len; idx += 1, cp += 2) {
- firmwareBinary[idx + off] = hex2unsigned(cp);
- /* printk("%02x ",firmwareBinary[idx+off]); */
- }
+ if (sizeFirmware>FIRMWARE_MAX_LEN) {
+ dev_err(&usbduxfastsub->interface->dev,
+ "comedi_: usbduxfast firmware binary it too large for FX2.\n");
+ return -ENOMEM;
+ }
- /* printk("\n"); */
+ /* we generate a local buffer for the firmware */
+ fwBuf = kzalloc(sizeFirmware, GFP_KERNEL);
+ if (!fwBuf) {
+ dev_err(&usbduxfastsub->interface->dev,
+ "comedi_: mem alloc for firmware failed\n");
+ return -ENOMEM;
+ }
+ memcpy(fwBuf,firmwareBinary,sizeFirmware);
- if (i >= size) {
- printk(KERN_ERR "comedi_: usbduxfast: unexpected end "
- "of hex file\n");
- break;
- }
+ ret = usbduxfastsub_stop(usbduxfastsub);
+ if (ret < 0) {
+ dev_err(&usbduxfastsub->interface->dev,
+ "comedi_: can not stop firmware\n");
+ kfree(fwBuf);
+ return ret;
+ }
+ ret = usbduxfastsub_upload(usbduxfastsub, fwBuf, 0, sizeFirmware);
+ if (ret < 0) {
+ dev_err(&usbduxfastsub->interface->dev,
+ "comedi_: firmware upload failed\n");
+ kfree(fwBuf);
+ return ret;
}
- res = firmwareUpload(udfs, firmwareBinary, maxAddr + 1);
- kfree(firmwareBinary);
- return res;
+ ret = usbduxfastsub_start(usbduxfastsub);
+ if (ret < 0) {
+ dev_err(&usbduxfastsub->interface->dev,
+ "comedi_: can not start firmware\n");
+ kfree(fwBuf);
+ return ret;
+ }
+ kfree(fwBuf);
+ return 0;
}
+
+
static void tidy_up(struct usbduxfastsub_s *udfs)
{
#ifdef CONFIG_COMEDI_DEBUG
@@ -1544,7 +1442,7 @@ static void usbduxfast_firmware_request_complete_handler(const struct firmware *
* we need to upload the firmware here because fw will be
* freed once we've left this function
*/
- ret = read_firmware(usbduxfastsub_tmp, fw->data, fw->size);
+ ret = firmwareUpload(usbduxfastsub_tmp, fw->data, fw->size);
if (ret) {
dev_err(&usbdev->dev,
@@ -1666,7 +1564,7 @@ static int usbduxfastsub_probe(struct usb_interface *uinterf,
ret = request_firmware_nowait(THIS_MODULE,
FW_ACTION_HOTPLUG,
- "usbduxfast_firmware.hex",
+ "usbduxfast_firmware.bin",
&udev->dev,
usbduxfastsub + index,
usbduxfast_firmware_request_complete_handler);
@@ -1751,9 +1649,9 @@ static int usbduxfast_attach(struct comedi_device *dev, struct comedi_devconfig
/* trying to upload the firmware into the chip */
if (comedi_aux_data(it->options, 0) &&
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
- read_firmware(&usbduxfastsub[index],
- comedi_aux_data(it->options, 0),
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
+ firmwareUpload(&usbduxfastsub[index],
+ comedi_aux_data(it->options, 0),
+ it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
}
dev->board_name = BOARDNAME;
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
new file mode 100644
index 000000000000..9de43b5310d7
--- /dev/null
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -0,0 +1,1399 @@
+/*
+ comedi/drivers/vmk80xx.c
+ Velleman USB Board Low-Level Driver
+
+ Copyright (C) 2009 Manuel Gebele <forensixs@gmx.de>, Germany
+
+ COMEDI - Linux Control and Measurement Device Interface
+ Copyright (C) 2000 David A. Schleef <ds@schleef.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+/*
+Driver: vmk80xx
+Description: Velleman USB Board Low-Level Driver
+Devices: K8055/K8061 aka VM110/VM140
+Author: Manuel Gebele <forensixs@gmx.de>
+Updated: Sun, 10 May 2009 11:14:59 +0200
+Status: works
+
+Supports:
+ - analog input
+ - analog output
+ - digital input
+ - digital output
+ - counter
+ - pwm
+*/
+/*
+Changelog:
+
+0.8.81 -3- code completely rewritten (adjust driver logic)
+0.8.81 -2- full support for K8061
+0.8.81 -1- fix some mistaken among others the number of
+ supported boards and I/O handling
+
+0.7.76 -4- renamed to vmk80xx
+0.7.76 -3- detect K8061 (only theoretically supported)
+0.7.76 -2- code completely rewritten (adjust driver logic)
+0.7.76 -1- support for digital and counter subdevice
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/errno.h>
+#include <linux/input.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/usb.h>
+#include <linux/uaccess.h>
+
+#include "../comedidev.h"
+
+MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
+MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
+MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
+MODULE_VERSION("0.8.01");
+MODULE_LICENSE("GPL");
+
+enum {
+ DEVICE_VMK8055,
+ DEVICE_VMK8061
+};
+
+static struct usb_device_id vmk80xx_id_table[] = {
+ { USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061 },
+ { } /* terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, vmk80xx_id_table);
+
+#define VMK8055_DI_REG 0x00
+#define VMK8055_DO_REG 0x01
+#define VMK8055_AO1_REG 0x02
+#define VMK8055_AO2_REG 0x03
+#define VMK8055_AI1_REG 0x02
+#define VMK8055_AI2_REG 0x03
+#define VMK8055_CNT1_REG 0x04
+#define VMK8055_CNT2_REG 0x06
+
+#define VMK8061_CH_REG 0x01
+#define VMK8061_DI_REG 0x01
+#define VMK8061_DO_REG 0x01
+#define VMK8061_PWM_REG1 0x01
+#define VMK8061_PWM_REG2 0x02
+#define VMK8061_CNT_REG 0x02
+#define VMK8061_AO_REG 0x02
+#define VMK8061_AI_REG1 0x02
+#define VMK8061_AI_REG2 0x03
+
+#define VMK8055_CMD_RST 0x00
+#define VMK8055_CMD_DEB1_TIME 0x01
+#define VMK8055_CMD_DEB2_TIME 0x02
+#define VMK8055_CMD_RST_CNT1 0x03
+#define VMK8055_CMD_RST_CNT2 0x04
+#define VMK8055_CMD_WRT_AD 0x05
+
+#define VMK8061_CMD_RD_AI 0x00
+#define VMK8061_CMR_RD_ALL_AI 0x01 /* !non-active! */
+#define VMK8061_CMD_SET_AO 0x02
+#define VMK8061_CMD_SET_ALL_AO 0x03 /* !non-active! */
+#define VMK8061_CMD_OUT_PWM 0x04
+#define VMK8061_CMD_RD_DI 0x05
+#define VMK8061_CMD_DO 0x06 /* !non-active! */
+#define VMK8061_CMD_CLR_DO 0x07
+#define VMK8061_CMD_SET_DO 0x08
+#define VMK8061_CMD_RD_CNT 0x09 /* TODO: completely pointless? */
+#define VMK8061_CMD_RST_CNT 0x0a /* TODO: completely pointless? */
+#define VMK8061_CMD_RD_VERSION 0x0b /* internal usage */
+#define VMK8061_CMD_RD_JMP_STAT 0x0c /* TODO: not implemented yet */
+#define VMK8061_CMD_RD_PWR_STAT 0x0d /* internal usage */
+#define VMK8061_CMD_RD_DO 0x0e
+#define VMK8061_CMD_RD_AO 0x0f
+#define VMK8061_CMD_RD_PWM 0x10
+
+#define VMK80XX_MAX_BOARDS COMEDI_NUM_BOARD_MINORS
+
+#define TRANS_OUT_BUSY 1
+#define TRANS_IN_BUSY 2
+#define TRANS_IN_RUNNING 3
+
+#define IC3_VERSION (1 << 0)
+#define IC6_VERSION (1 << 1)
+
+#define URB_RCV_FLAG (1 << 0)
+#define URB_SND_FLAG (1 << 1)
+
+#define CONFIG_VMK80XX_DEBUG
+#undef CONFIG_VMK80XX_DEBUG
+
+#ifdef CONFIG_VMK80XX_DEBUG
+ static int dbgvm = 1;
+#else
+ static int dbgvm;
+#endif
+
+#ifdef CONFIG_COMEDI_DEBUG
+ static int dbgcm = 1;
+#else
+ static int dbgcm;
+#endif
+
+#define dbgvm(fmt, arg...) \
+do { \
+ if (dbgvm) \
+ printk(KERN_DEBUG fmt, ##arg); \
+} while (0)
+
+#define dbgcm(fmt, arg...) \
+do { \
+ if (dbgcm) \
+ printk(KERN_DEBUG fmt, ##arg); \
+} while (0)
+
+enum vmk80xx_model {
+ VMK8055_MODEL,
+ VMK8061_MODEL
+};
+
+struct firmware_version {
+ unsigned char ic3_vers[32]; /* USB-Controller */
+ unsigned char ic6_vers[32]; /* CPU */
+};
+
+static const struct comedi_lrange vmk8055_range = {
+ 1, { UNI_RANGE(5) }
+};
+
+static const struct comedi_lrange vmk8061_range = {
+ 2, { UNI_RANGE(5), UNI_RANGE(10) }
+};
+
+struct vmk80xx_board {
+ const char *name;
+ enum vmk80xx_model model;
+ const struct comedi_lrange *range;
+ __u8 ai_chans;
+ __le16 ai_bits;
+ __u8 ao_chans;
+ __le16 ao_bits;
+ __u8 di_chans;
+ __le16 di_bits;
+ __u8 do_chans;
+ __le16 do_bits;
+ __u8 cnt_chans;
+ __le16 cnt_bits;
+ __u8 pwm_chans;
+ __le16 pwm_bits;
+};
+
+enum {
+ VMK80XX_SUBD_AI,
+ VMK80XX_SUBD_AO,
+ VMK80XX_SUBD_DI,
+ VMK80XX_SUBD_DO,
+ VMK80XX_SUBD_CNT,
+ VMK80XX_SUBD_PWM,
+};
+
+struct vmk80xx_usb {
+ struct usb_device *udev;
+ struct usb_interface *intf;
+ struct usb_endpoint_descriptor *ep_rx;
+ struct usb_endpoint_descriptor *ep_tx;
+ struct usb_anchor rx_anchor;
+ struct usb_anchor tx_anchor;
+ struct vmk80xx_board board;
+ struct firmware_version fw;
+ struct semaphore limit_sem;
+ wait_queue_head_t read_wait;
+ wait_queue_head_t write_wait;
+ unsigned char *usb_rx_buf;
+ unsigned char *usb_tx_buf;
+ unsigned long flags;
+ int probed;
+ int attached;
+ int count;
+};
+
+static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS];
+
+static DEFINE_MUTEX(glb_mutex);
+
+static void vmk80xx_tx_callback(struct urb *urb)
+{
+ struct vmk80xx_usb *dev = urb->context;
+ int stat = urb->status;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ if (stat && !(stat == -ENOENT
+ || stat == -ECONNRESET
+ || stat == -ESHUTDOWN))
+ dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n",
+ __func__, stat);
+
+ if (!test_bit(TRANS_OUT_BUSY, &dev->flags))
+ return;
+
+ clear_bit(TRANS_OUT_BUSY, &dev->flags);
+
+ wake_up_interruptible(&dev->write_wait);
+}
+
+static void vmk80xx_rx_callback(struct urb *urb)
+{
+ struct vmk80xx_usb *dev = urb->context;
+ int stat = urb->status;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ switch (stat) {
+ case 0:
+ break;
+ case -ENOENT:
+ case -ECONNRESET:
+ case -ESHUTDOWN:
+ break;
+ default:
+ dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n",
+ __func__, stat);
+ goto resubmit;
+ }
+
+ goto exit;
+resubmit:
+ if (test_bit(TRANS_IN_RUNNING, &dev->flags) && dev->intf) {
+ usb_anchor_urb(urb, &dev->rx_anchor);
+
+ if (!usb_submit_urb(urb, GFP_KERNEL))
+ goto exit;
+
+ err("comedi#: vmk80xx: %s - submit urb failed\n", __func__);
+
+ usb_unanchor_urb(urb);
+ }
+exit:
+ clear_bit(TRANS_IN_BUSY, &dev->flags);
+
+ wake_up_interruptible(&dev->read_wait);
+}
+
+static int vmk80xx_check_data_link(struct vmk80xx_usb *dev)
+{
+ unsigned int tx_pipe, rx_pipe;
+ unsigned char tx[1], rx[2];
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ tx_pipe = usb_sndbulkpipe(dev->udev, 0x01);
+ rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81);
+
+ tx[0] = VMK8061_CMD_RD_PWR_STAT;
+
+ /* Check that IC6 (PIC16F871) is powered and
+ * running and the data link between IC3 and
+ * IC6 is working properly */
+ usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL,
+ dev->ep_tx->bInterval);
+ usb_bulk_msg(dev->udev, rx_pipe, rx, 2, NULL,
+ HZ * 10);
+
+ return (int)rx[1];
+}
+
+static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag)
+{
+ unsigned int tx_pipe, rx_pipe;
+ unsigned char tx[1], rx[64];
+ int cnt;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ tx_pipe = usb_sndbulkpipe(dev->udev, 0x01);
+ rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81);
+
+ tx[0] = VMK8061_CMD_RD_VERSION;
+
+ /* Read the firmware version info of IC3 and
+ * IC6 from the internal EEPROM of the IC */
+ usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL,
+ dev->ep_tx->bInterval);
+ usb_bulk_msg(dev->udev, rx_pipe, rx, 64, &cnt,
+ HZ * 10);
+
+ rx[cnt] = '\0';
+
+ if (flag & IC3_VERSION)
+ strncpy(dev->fw.ic3_vers, rx + 1, 24);
+ else /* IC6_VERSION */
+ strncpy(dev->fw.ic6_vers, rx + 25, 24);
+}
+
+static int vmk80xx_reset_device(struct vmk80xx_usb *dev)
+{
+ struct urb *urb;
+ unsigned int tx_pipe;
+ int ival;
+ size_t size;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!urb)
+ return -ENOMEM;
+
+ tx_pipe = usb_sndintpipe(dev->udev, 0x01);
+
+ ival = dev->ep_tx->bInterval;
+ size = le16_to_cpu(dev->ep_tx->wMaxPacketSize);
+
+ dev->usb_tx_buf[0] = VMK8055_CMD_RST;
+ dev->usb_tx_buf[1] = 0x00;
+ dev->usb_tx_buf[2] = 0x00;
+ dev->usb_tx_buf[3] = 0x00;
+ dev->usb_tx_buf[4] = 0x00;
+ dev->usb_tx_buf[5] = 0x00;
+ dev->usb_tx_buf[6] = 0x00;
+ dev->usb_tx_buf[7] = 0x00;
+
+ usb_fill_int_urb(urb, dev->udev, tx_pipe, dev->usb_tx_buf,
+ size, vmk80xx_tx_callback, dev, ival);
+
+ usb_anchor_urb(urb, &dev->tx_anchor);
+
+ return usb_submit_urb(urb, GFP_KERNEL);
+}
+
+static void vmk80xx_build_int_urb(struct urb *urb, int flag)
+{
+ struct vmk80xx_usb *dev = urb->context;
+ __u8 rx_addr, tx_addr;
+ unsigned int pipe;
+ unsigned char *buf;
+ size_t size;
+ void (*callback)(struct urb *);
+ int ival;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ if (flag & URB_RCV_FLAG) {
+ rx_addr = dev->ep_rx->bEndpointAddress;
+ pipe = usb_rcvintpipe(dev->udev, rx_addr);
+ buf = dev->usb_rx_buf;
+ size = le16_to_cpu(dev->ep_rx->wMaxPacketSize);
+ callback = vmk80xx_rx_callback;
+ ival = dev->ep_rx->bInterval;
+ } else { /* URB_SND_FLAG */
+ tx_addr = dev->ep_tx->bEndpointAddress;
+ pipe = usb_sndintpipe(dev->udev, tx_addr);
+ buf = dev->usb_tx_buf;
+ size = le16_to_cpu(dev->ep_tx->wMaxPacketSize);
+ callback = vmk80xx_tx_callback;
+ ival = dev->ep_tx->bInterval;
+ }
+
+ usb_fill_int_urb(urb, dev->udev, pipe, buf,
+ size, callback, dev, ival);
+}
+
+static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev)
+{
+ __u8 tx_addr, rx_addr;
+ unsigned int tx_pipe, rx_pipe;
+ size_t size;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ set_bit(TRANS_IN_BUSY, &dev->flags);
+ set_bit(TRANS_OUT_BUSY, &dev->flags);
+
+ tx_addr = dev->ep_tx->bEndpointAddress;
+ rx_addr = dev->ep_rx->bEndpointAddress;
+ tx_pipe = usb_sndbulkpipe(dev->udev, tx_addr);
+ rx_pipe = usb_rcvbulkpipe(dev->udev, rx_addr);
+
+ /* The max packet size attributes of the K8061
+ * input/output endpoints are identical */
+ size = le16_to_cpu(dev->ep_tx->wMaxPacketSize);
+
+ usb_bulk_msg(dev->udev, tx_pipe, dev->usb_tx_buf,
+ size, NULL, dev->ep_tx->bInterval);
+ usb_bulk_msg(dev->udev, rx_pipe, dev->usb_rx_buf,
+ size, NULL, HZ * 10);
+
+ clear_bit(TRANS_OUT_BUSY, &dev->flags);
+ clear_bit(TRANS_IN_BUSY, &dev->flags);
+}
+
+static int vmk80xx_read_packet(struct vmk80xx_usb *dev)
+{
+ struct urb *urb;
+ int retval;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ if (!dev->intf)
+ return -ENODEV;
+
+ /* Only useful for interrupt transfers */
+ if (test_bit(TRANS_IN_BUSY, &dev->flags))
+ if (wait_event_interruptible(dev->read_wait,
+ !test_bit(TRANS_IN_BUSY, &dev->flags)))
+ return -ERESTART;
+
+ if (dev->board.model == VMK8061_MODEL) {
+ vmk80xx_do_bulk_msg(dev);
+
+ return 0;
+ }
+
+ urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!urb)
+ return -ENOMEM;
+
+ urb->context = dev;
+ vmk80xx_build_int_urb(urb, URB_RCV_FLAG);
+
+ set_bit(TRANS_IN_RUNNING, &dev->flags);
+ set_bit(TRANS_IN_BUSY, &dev->flags);
+
+ usb_anchor_urb(urb, &dev->rx_anchor);
+
+ retval = usb_submit_urb(urb, GFP_KERNEL);
+ if (!retval)
+ goto exit;
+
+ clear_bit(TRANS_IN_RUNNING, &dev->flags);
+ usb_unanchor_urb(urb);
+
+exit:
+ usb_free_urb(urb);
+
+ return retval;
+}
+
+static int vmk80xx_write_packet(struct vmk80xx_usb *dev, int cmd)
+{
+ struct urb *urb;
+ int retval;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ if (!dev->intf)
+ return -ENODEV;
+
+ if (test_bit(TRANS_OUT_BUSY, &dev->flags))
+ if (wait_event_interruptible(dev->write_wait,
+ !test_bit(TRANS_OUT_BUSY, &dev->flags)))
+ return -ERESTART;
+
+ if (dev->board.model == VMK8061_MODEL) {
+ dev->usb_tx_buf[0] = cmd;
+ vmk80xx_do_bulk_msg(dev);
+
+ return 0;
+ }
+
+ urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!urb)
+ return -ENOMEM;
+
+ urb->context = dev;
+ vmk80xx_build_int_urb(urb, URB_SND_FLAG);
+
+ set_bit(TRANS_OUT_BUSY, &dev->flags);
+
+ usb_anchor_urb(urb, &dev->tx_anchor);
+
+ dev->usb_tx_buf[0] = cmd;
+
+ retval = usb_submit_urb(urb, GFP_KERNEL);
+ if (!retval)
+ goto exit;
+
+ clear_bit(TRANS_OUT_BUSY, &dev->flags);
+ usb_unanchor_urb(urb);
+
+exit:
+ usb_free_urb(urb);
+
+ return retval;
+}
+
+#define DIR_IN 1
+#define DIR_OUT 2
+
+#define rudimentary_check(dir) \
+do { \
+ if (!dev) \
+ return -EFAULT; \
+ if (!dev->probed) \
+ return -ENODEV; \
+ if (!dev->attached) \
+ return -ENODEV; \
+ if ((dir) & DIR_IN) { \
+ if (test_bit(TRANS_IN_BUSY, &dev->flags)) \
+ return -EBUSY; \
+ } else { /* DIR_OUT */ \
+ if (test_bit(TRANS_OUT_BUSY, &dev->flags)) \
+ return -EBUSY; \
+ } \
+} while (0)
+
+static int vmk80xx_ai_rinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan, reg[2];
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_IN);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ switch (dev->board.model) {
+ case VMK8055_MODEL:
+ if (!chan)
+ reg[0] = VMK8055_AI1_REG;
+ else
+ reg[0] = VMK8055_AI2_REG;
+ break;
+ case VMK8061_MODEL:
+ reg[0] = VMK8061_AI_REG1;
+ reg[1] = VMK8061_AI_REG2;
+ dev->usb_tx_buf[0] = VMK8061_CMD_RD_AI;
+ dev->usb_tx_buf[VMK8061_CH_REG] = chan;
+ break;
+ }
+
+ for (n = 0; n < insn->n; n++) {
+ if (vmk80xx_read_packet(dev))
+ break;
+
+ if (dev->board.model == VMK8055_MODEL) {
+ data[n] = dev->usb_rx_buf[reg[0]];
+ continue;
+ }
+
+ /* VMK8061_MODEL */
+ data[n] = dev->usb_rx_buf[reg[0]] + 256 *
+ dev->usb_rx_buf[reg[1]];
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_ao_winsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan, cmd, reg;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_OUT);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ switch (dev->board.model) {
+ case VMK8055_MODEL:
+ cmd = VMK8055_CMD_WRT_AD;
+ if (!chan)
+ reg = VMK8055_AO1_REG;
+ else
+ reg = VMK8055_AO2_REG;
+ break;
+ default: /* NOTE: avoid compiler warnings */
+ cmd = VMK8061_CMD_SET_AO;
+ reg = VMK8061_AO_REG;
+ dev->usb_tx_buf[VMK8061_CH_REG] = chan;
+ break;
+ }
+
+ for (n = 0; n < insn->n; n++) {
+ dev->usb_tx_buf[reg] = data[n];
+
+ if (vmk80xx_write_packet(dev, cmd))
+ break;
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_ao_rinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan, reg;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_IN);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ reg = VMK8061_AO_REG - 1;
+
+ dev->usb_tx_buf[0] = VMK8061_CMD_RD_AO;
+
+ for (n = 0; n < insn->n; n++) {
+ if (vmk80xx_read_packet(dev))
+ break;
+
+ data[n] = dev->usb_rx_buf[reg+chan];
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_di_rinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan;
+ unsigned char *rx_buf;
+ int reg, inp;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_IN);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ rx_buf = dev->usb_rx_buf;
+
+ if (dev->board.model == VMK8061_MODEL) {
+ reg = VMK8061_DI_REG;
+ dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
+ } else
+ reg = VMK8055_DI_REG;
+
+ for (n = 0; n < insn->n; n++) {
+ if (vmk80xx_read_packet(dev))
+ break;
+
+ if (dev->board.model == VMK8055_MODEL)
+ inp = (((rx_buf[reg] >> 4) & 0x03) |
+ ((rx_buf[reg] << 2) & 0x04) |
+ ((rx_buf[reg] >> 3) & 0x18));
+ else
+ inp = rx_buf[reg];
+
+ data[n] = ((inp & (1 << chan)) > 0);
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_do_winsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan;
+ unsigned char *tx_buf;
+ int reg, cmd;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_OUT);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ tx_buf = dev->usb_tx_buf;
+
+ for (n = 0; n < insn->n; n++) {
+ if (dev->board.model == VMK8055_MODEL) {
+ reg = VMK8055_DO_REG;
+ cmd = VMK8055_CMD_WRT_AD;
+ if (data[n] == 1)
+ tx_buf[reg] |= (1 << chan);
+ else
+ tx_buf[reg] ^= (1 << chan);
+
+ goto write_packet;
+ }
+
+ /* VMK8061_MODEL */
+ reg = VMK8061_DO_REG;
+ if (data[n] == 1) {
+ cmd = VMK8061_CMD_SET_DO;
+ tx_buf[reg] = 1 << chan;
+ } else {
+ cmd = VMK8061_CMD_CLR_DO;
+ tx_buf[reg] = 0xff - (1 << chan);
+ }
+
+write_packet:
+ if (vmk80xx_write_packet(dev, cmd))
+ break;
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_do_rinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan, reg, mask;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_IN);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ reg = VMK8061_DO_REG;
+ mask = 1 << chan;
+
+ dev->usb_tx_buf[0] = VMK8061_CMD_RD_DO;
+
+ for (n = 0; n < insn->n; n++) {
+ if (vmk80xx_read_packet(dev))
+ break;
+
+ data[n] = (dev->usb_rx_buf[reg] & mask) >> chan;
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_cnt_rinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int chan, reg[2];
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_IN);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ switch (dev->board.model) {
+ case VMK8055_MODEL:
+ if (!chan)
+ reg[0] = VMK8055_CNT1_REG;
+ else
+ reg[0] = VMK8055_CNT2_REG;
+ break;
+ case VMK8061_MODEL:
+ reg[0] = VMK8061_CNT_REG;
+ reg[1] = VMK8061_CNT_REG;
+ dev->usb_tx_buf[0] = VMK8061_CMD_RD_CNT;
+ break;
+ }
+
+ for (n = 0; n < insn->n; n++) {
+ if (vmk80xx_read_packet(dev))
+ break;
+
+ if (dev->board.model == VMK8055_MODEL) {
+ data[n] = dev->usb_rx_buf[reg[0]];
+ continue;
+ }
+
+ /* VMK8061_MODEL */
+ data[n] = dev->usb_rx_buf[reg[0]*(chan+1)+1]
+ + 256 * dev->usb_rx_buf[reg[1]*2+2];
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_cnt_cinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ unsigned int insn_cmd;
+ int chan, cmd, reg;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_OUT);
+
+ down(&dev->limit_sem);
+
+ insn_cmd = data[0];
+ if (insn_cmd != INSN_CONFIG_RESET && insn_cmd != GPCT_RESET)
+ return -EINVAL;
+
+ chan = CR_CHAN(insn->chanspec);
+
+ if (dev->board.model == VMK8055_MODEL) {
+ if (!chan) {
+ cmd = VMK8055_CMD_RST_CNT1;
+ reg = VMK8055_CNT1_REG;
+ } else {
+ cmd = VMK8055_CMD_RST_CNT2;
+ reg = VMK8055_CNT2_REG;
+ }
+
+ dev->usb_tx_buf[reg] = 0x00;
+ } else
+ cmd = VMK8061_CMD_RST_CNT;
+
+ for (n = 0; n < insn->n; n++)
+ if (vmk80xx_write_packet(dev, cmd))
+ break;
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_cnt_winsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ unsigned long debtime, val;
+ int chan, cmd;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_OUT);
+
+ down(&dev->limit_sem);
+ chan = CR_CHAN(insn->chanspec);
+
+ if (!chan)
+ cmd = VMK8055_CMD_DEB1_TIME;
+ else
+ cmd = VMK8055_CMD_DEB2_TIME;
+
+ for (n = 0; n < insn->n; n++) {
+ debtime = data[n];
+ if (debtime == 0)
+ debtime = 1;
+
+ /* TODO: Prevent overflows */
+ if (debtime > 7450)
+ debtime = 7450;
+
+ val = int_sqrt(debtime * 1000 / 115);
+ if (((val + 1) * val) < debtime * 1000 / 115)
+ val += 1;
+
+ dev->usb_tx_buf[6+chan] = val;
+
+ if (vmk80xx_write_packet(dev, cmd))
+ break;
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_pwm_rinsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ int reg[2];
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_IN);
+
+ down(&dev->limit_sem);
+
+ reg[0] = VMK8061_PWM_REG1;
+ reg[1] = VMK8061_PWM_REG2;
+
+ dev->usb_tx_buf[0] = VMK8061_CMD_RD_PWM;
+
+ for (n = 0; n < insn->n; n++) {
+ if (vmk80xx_read_packet(dev))
+ break;
+
+ data[n] = dev->usb_rx_buf[reg[0]] + 4 *
+ dev->usb_rx_buf[reg[1]];
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int vmk80xx_pwm_winsn(struct comedi_device *cdev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ struct vmk80xx_usb *dev = cdev->private;
+ unsigned char *tx_buf;
+ int reg[2], cmd;
+ int n;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ rudimentary_check(DIR_OUT);
+
+ down(&dev->limit_sem);
+
+ tx_buf = dev->usb_tx_buf;
+
+ reg[0] = VMK8061_PWM_REG1;
+ reg[1] = VMK8061_PWM_REG2;
+
+ cmd = VMK8061_CMD_OUT_PWM;
+
+ /*
+ * The followin piece of code was translated from the inline
+ * assembler code in the DLL source code.
+ *
+ * asm
+ * mov eax, k ; k is the value (data[n])
+ * and al, 03h ; al are the lower 8 bits of eax
+ * mov lo, al ; lo is the low part (tx_buf[reg[0]])
+ * mov eax, k
+ * shr eax, 2 ; right shift eax register by 2
+ * mov hi, al ; hi is the high part (tx_buf[reg[1]])
+ * end;
+ */
+ for (n = 0; n < insn->n; n++) {
+ tx_buf[reg[0]] = (unsigned char)(data[n] & 0x03);
+ tx_buf[reg[1]] = (unsigned char)(data[n] >> 2) & 0xff;
+
+ if (vmk80xx_write_packet(dev, cmd))
+ break;
+ }
+
+ up(&dev->limit_sem);
+
+ return n;
+}
+
+static int
+vmk80xx_attach(struct comedi_device *cdev, struct comedi_devconfig *it)
+{
+ int i;
+ struct vmk80xx_usb *dev;
+ int n_subd;
+ struct comedi_subdevice *s;
+ int minor;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ mutex_lock(&glb_mutex);
+
+ for (i = 0; i < VMK80XX_MAX_BOARDS; i++)
+ if (vmb[i].probed && !vmb[i].attached)
+ break;
+
+ if (i == VMK80XX_MAX_BOARDS) {
+ mutex_unlock(&glb_mutex);
+ return -ENODEV;
+ }
+
+ dev = &vmb[i];
+
+ down(&dev->limit_sem);
+
+ cdev->board_name = dev->board.name;
+ cdev->private = dev;
+
+ if (dev->board.model == VMK8055_MODEL)
+ n_subd = 5;
+ else
+ n_subd = 6;
+
+ if (alloc_subdevices(cdev, n_subd) < 0) {
+ up(&dev->limit_sem);
+ mutex_unlock(&glb_mutex);
+ return -ENOMEM;
+ }
+
+ /* Analog input subdevice */
+ s = cdev->subdevices + VMK80XX_SUBD_AI;
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND;
+ s->n_chan = dev->board.ai_chans;
+ s->maxdata = (1 << dev->board.ai_bits) - 1;
+ s->range_table = dev->board.range;
+ s->insn_read = vmk80xx_ai_rinsn;
+
+ /* Analog output subdevice */
+ s = cdev->subdevices + VMK80XX_SUBD_AO;
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
+ s->n_chan = dev->board.ao_chans;
+ s->maxdata = (1 << dev->board.ao_bits) - 1;
+ s->range_table = dev->board.range;
+ s->insn_write = vmk80xx_ao_winsn;
+
+ if (dev->board.model == VMK8061_MODEL) {
+ s->subdev_flags |= SDF_READABLE;
+ s->insn_read = vmk80xx_ao_rinsn;
+ }
+
+ /* Digital input subdevice */
+ s = cdev->subdevices + VMK80XX_SUBD_DI;
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND;
+ s->n_chan = dev->board.di_chans;
+ s->maxdata = (1 << dev->board.di_bits) - 1;
+ s->insn_read = vmk80xx_di_rinsn;
+
+ /* Digital output subdevice */
+ s = cdev->subdevices + VMK80XX_SUBD_DO;
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
+ s->n_chan = dev->board.do_chans;
+ s->maxdata = (1 << dev->board.do_bits) - 1;
+ s->insn_write = vmk80xx_do_winsn;
+
+ if (dev->board.model == VMK8061_MODEL) {
+ s->subdev_flags |= SDF_READABLE;
+ s->insn_read = vmk80xx_do_rinsn;
+ }
+
+ /* Counter subdevice */
+ s = cdev->subdevices + VMK80XX_SUBD_CNT;
+ s->type = COMEDI_SUBD_COUNTER;
+ s->subdev_flags = SDF_READABLE;
+ s->n_chan = dev->board.cnt_chans;
+ s->insn_read = vmk80xx_cnt_rinsn;
+ s->insn_config = vmk80xx_cnt_cinsn;
+
+ if (dev->board.model == VMK8055_MODEL) {
+ s->subdev_flags |= SDF_WRITEABLE;
+ s->maxdata = (1 << dev->board.cnt_bits) - 1;
+ s->insn_write = vmk80xx_cnt_winsn;
+ }
+
+ /* PWM subdevice */
+ if (dev->board.model == VMK8061_MODEL) {
+ s = cdev->subdevices + VMK80XX_SUBD_PWM;
+ s->type = COMEDI_SUBD_PWM;
+ s->subdev_flags = SDF_READABLE | SDF_WRITEABLE;
+ s->n_chan = dev->board.pwm_chans;
+ s->maxdata = (1 << dev->board.pwm_bits) - 1;
+ s->insn_read = vmk80xx_pwm_rinsn;
+ s->insn_write = vmk80xx_pwm_winsn;
+ }
+
+ dev->attached = 1;
+
+ minor = cdev->minor;
+
+ printk(KERN_INFO
+ "comedi%d: vmk80xx: board #%d [%s] attached to comedi\n",
+ minor, dev->count, dev->board.name);
+
+ up(&dev->limit_sem);
+ mutex_unlock(&glb_mutex);
+
+ return 0;
+}
+
+static int vmk80xx_detach(struct comedi_device *cdev)
+{
+ struct vmk80xx_usb *dev;
+ int minor;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ if (!cdev)
+ return -EFAULT;
+
+ dev = cdev->private;
+ if (!dev)
+ return -EFAULT;
+
+ down(&dev->limit_sem);
+
+ cdev->private = NULL;
+ dev->attached = 0;
+
+ minor = cdev->minor;
+
+ printk(KERN_INFO
+ "comedi%d: vmk80xx: board #%d [%s] detached from comedi\n",
+ minor, dev->count, dev->board.name);
+
+ up(&dev->limit_sem);
+
+ return 0;
+}
+
+static int
+vmk80xx_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+ int i;
+ struct vmk80xx_usb *dev;
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *ep_desc;
+ size_t size;
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ mutex_lock(&glb_mutex);
+
+ for (i = 0; i < VMK80XX_MAX_BOARDS; i++)
+ if (!vmb[i].probed)
+ break;
+
+ if (i == VMK80XX_MAX_BOARDS) {
+ mutex_unlock(&glb_mutex);
+ return -EMFILE;
+ }
+
+ dev = &vmb[i];
+
+ memset(dev, 0x00, sizeof(struct vmk80xx_usb));
+ dev->count = i;
+
+ iface_desc = intf->cur_altsetting;
+ if (iface_desc->desc.bNumEndpoints != 2)
+ goto error;
+
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
+ ep_desc = &iface_desc->endpoint[i].desc;
+
+ if (usb_endpoint_is_int_in(ep_desc)) {
+ dev->ep_rx = ep_desc;
+ continue;
+ }
+
+ if (usb_endpoint_is_int_out(ep_desc)) {
+ dev->ep_tx = ep_desc;
+ continue;
+ }
+
+ if (usb_endpoint_is_bulk_in(ep_desc)) {
+ dev->ep_rx = ep_desc;
+ continue;
+ }
+
+ if (usb_endpoint_is_bulk_out(ep_desc)) {
+ dev->ep_tx = ep_desc;
+ continue;
+ }
+ }
+
+ if (!dev->ep_rx || !dev->ep_tx)
+ goto error;
+
+ size = le16_to_cpu(dev->ep_rx->wMaxPacketSize);
+ dev->usb_rx_buf = kmalloc(size, GFP_KERNEL);
+ if (!dev->usb_rx_buf) {
+ mutex_unlock(&glb_mutex);
+ return -ENOMEM;
+ }
+
+ size = le16_to_cpu(dev->ep_tx->wMaxPacketSize);
+ dev->usb_tx_buf = kmalloc(size, GFP_KERNEL);
+ if (!dev->usb_tx_buf) {
+ kfree(dev->usb_rx_buf);
+ mutex_unlock(&glb_mutex);
+ return -ENOMEM;
+ }
+
+ dev->udev = interface_to_usbdev(intf);
+ dev->intf = intf;
+
+ sema_init(&dev->limit_sem, 8);
+ init_waitqueue_head(&dev->read_wait);
+ init_waitqueue_head(&dev->write_wait);
+
+ init_usb_anchor(&dev->rx_anchor);
+ init_usb_anchor(&dev->tx_anchor);
+
+ usb_set_intfdata(intf, dev);
+
+ switch (id->driver_info) {
+ case DEVICE_VMK8055:
+ dev->board.name = "K8055 (VM110)";
+ dev->board.model = VMK8055_MODEL;
+ dev->board.range = &vmk8055_range;
+ dev->board.ai_chans = 2;
+ dev->board.ai_bits = 8;
+ dev->board.ao_chans = 2;
+ dev->board.ao_bits = 8;
+ dev->board.di_chans = 5;
+ dev->board.di_bits = 1;
+ dev->board.do_chans = 8;
+ dev->board.do_bits = 1;
+ dev->board.cnt_chans = 2;
+ dev->board.cnt_bits = 16;
+ dev->board.pwm_chans = 0;
+ dev->board.pwm_bits = 0;
+ break;
+ case DEVICE_VMK8061:
+ dev->board.name = "K8061 (VM140)";
+ dev->board.model = VMK8061_MODEL;
+ dev->board.range = &vmk8061_range;
+ dev->board.ai_chans = 8;
+ dev->board.ai_bits = 10;
+ dev->board.ao_chans = 8;
+ dev->board.ao_bits = 8;
+ dev->board.di_chans = 8;
+ dev->board.di_bits = 1;
+ dev->board.do_chans = 8;
+ dev->board.do_bits = 1;
+ dev->board.cnt_chans = 2;
+ dev->board.cnt_bits = 0;
+ dev->board.pwm_chans = 1;
+ dev->board.pwm_bits = 10;
+ break;
+ }
+
+ if (dev->board.model == VMK8061_MODEL) {
+ vmk80xx_read_eeprom(dev, IC3_VERSION);
+ printk(KERN_INFO "comedi#: vmk80xx: %s\n",
+ dev->fw.ic3_vers);
+
+ if (vmk80xx_check_data_link(dev)) {
+ vmk80xx_read_eeprom(dev, IC6_VERSION);
+ printk(KERN_INFO "comedi#: vmk80xx: %s\n",
+ dev->fw.ic6_vers);
+ } else
+ dbgcm("comedi#: vmk80xx: no conn. to CPU\n");
+ }
+
+ if (dev->board.model == VMK8055_MODEL)
+ vmk80xx_reset_device(dev);
+
+ dev->probed = 1;
+
+ printk(KERN_INFO "comedi#: vmk80xx: board #%d [%s] now attached\n",
+ dev->count, dev->board.name);
+
+ mutex_unlock(&glb_mutex);
+
+ return 0;
+error:
+ mutex_unlock(&glb_mutex);
+
+ return -ENODEV;
+}
+
+static void vmk80xx_disconnect(struct usb_interface *intf)
+{
+ struct vmk80xx_usb *dev = usb_get_intfdata(intf);
+
+ dbgvm("vmk80xx: %s\n", __func__);
+
+ if (!dev)
+ return;
+
+ mutex_lock(&glb_mutex);
+ down(&dev->limit_sem);
+
+ dev->probed = 0;
+ usb_set_intfdata(dev->intf, NULL);
+
+ usb_kill_anchored_urbs(&dev->rx_anchor);
+ usb_kill_anchored_urbs(&dev->tx_anchor);
+
+ kfree(dev->usb_rx_buf);
+ kfree(dev->usb_tx_buf);
+
+ printk(KERN_INFO "comedi#: vmk80xx: board #%d [%s] now detached\n",
+ dev->count, dev->board.name);
+
+ up(&dev->limit_sem);
+ mutex_unlock(&glb_mutex);
+}
+
+/* TODO: Add support for suspend, resume, pre_reset,
+ * post_reset and flush */
+static struct usb_driver vmk80xx_driver = {
+ .name = "vmk80xx",
+ .probe = vmk80xx_probe,
+ .disconnect = vmk80xx_disconnect,
+ .id_table = vmk80xx_id_table
+};
+
+static struct comedi_driver driver_vmk80xx = {
+ .module = THIS_MODULE,
+ .driver_name = "vmk80xx",
+ .attach = vmk80xx_attach,
+ .detach = vmk80xx_detach
+};
+
+static int __init vmk80xx_init(void)
+{
+ printk(KERN_INFO "vmk80xx: version 0.8.01 "
+ "Manuel Gebele <forensixs@gmx.de>\n");
+ usb_register(&vmk80xx_driver);
+ return comedi_driver_register(&driver_vmk80xx);
+}
+
+static void __exit vmk80xx_exit(void)
+{
+ comedi_driver_unregister(&driver_vmk80xx);
+ usb_deregister(&vmk80xx_driver);
+}
+
+module_init(vmk80xx_init);
+module_exit(vmk80xx_exit);
diff --git a/drivers/staging/comedi/interrupt.h b/drivers/staging/comedi/interrupt.h
deleted file mode 100644
index d1f09892da2e..000000000000
--- a/drivers/staging/comedi/interrupt.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- linux/interrupt.h compatibility header
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __COMPAT_LINUX_INTERRUPT_H_
-#define __COMPAT_LINUX_INTERRUPT_H_
-
-#include <linux/interrupt.h>
-
-#ifndef IRQF_DISABLED
-#define IRQF_DISABLED SA_INTERRUPT
-#define IRQF_SAMPLE_RANDOM SA_SAMPLE_RANDOM
-#define IRQF_SHARED SA_SHIRQ
-#define IRQF_PROBE_SHARED SA_PROBEIRQ
-#define IRQF_PERCPU SA_PERCPU
-#ifdef SA_TRIGGER_MASK
-#define IRQF_TRIGGER_NONE 0
-#define IRQF_TRIGGER_LOW SA_TRIGGER_LOW
-#define IRQF_TRIGGER_HIGH SA_TRIGGER_HIGH
-#define IRQF_TRIGGER_FALLING SA_TRIGGER_FALLING
-#define IRQF_TRIGGER_RISING SA_TRIGGER_RISING
-#define IRQF_TRIGGER_MASK SA_TRIGGER_MASK
-#else
-#define IRQF_TRIGGER_NONE 0
-#define IRQF_TRIGGER_LOW 0
-#define IRQF_TRIGGER_HIGH 0
-#define IRQF_TRIGGER_FALLING 0
-#define IRQF_TRIGGER_RISING 0
-#define IRQF_TRIGGER_MASK 0
-#endif
-#endif
-
-#define PT_REGS_ARG
-#define PT_REGS_CALL
-#define PT_REGS_NULL
-
-#endif
diff --git a/drivers/staging/comedi/kcomedilib/data.c b/drivers/staging/comedi/kcomedilib/data.c
index 9797e13e3774..3e5fe2c87092 100644
--- a/drivers/staging/comedi/kcomedilib/data.c
+++ b/drivers/staging/comedi/kcomedilib/data.c
@@ -23,7 +23,7 @@
#include "../comedi.h"
#include "../comedilib.h"
-#include "../comedidev.h" /* for comedi_udelay() */
+#include "../comedidev.h"
#include <linux/string.h>
@@ -83,7 +83,7 @@ int comedi_data_read_delayed(void *dev, unsigned int subdev,
if (retval < 0)
return retval;
- comedi_udelay((nano_sec + 999) / 1000);
+ udelay((nano_sec + 999) / 1000);
return comedi_data_read(dev, subdev, chan, range, aref, data);
}
diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
index a4fa9571c58f..b39ea7c50b87 100644
--- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
+++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
@@ -105,7 +105,7 @@ int comedi_loglevel(int newlevel)
void comedi_perror(const char *message)
{
- rt_printk("%s: unknown error\n", message);
+ printk("%s: unknown error\n", message);
}
char *comedi_strerror(int err)
@@ -150,10 +150,6 @@ int comedi_command(void *d, struct comedi_cmd *cmd)
runflags = SRF_RUNNING;
-#ifdef CONFIG_COMEDI_RT
- if (comedi_switch_to_rt(dev) == 0)
- runflags |= SRF_RT;
-#endif
comedi_set_subdevice_runflags(s, ~0, runflags);
comedi_reset_async_buf(async);
@@ -208,7 +204,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
ret = -EINVAL;
break;
}
- comedi_udelay(insn->data[0]);
+ udelay(insn->data[0]);
ret = 1;
break;
case INSN_INTTRIG:
@@ -217,19 +213,19 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
break;
}
if (insn->subdev >= dev->n_subdevices) {
- rt_printk("%d not usable subdevice\n",
+ printk("%d not usable subdevice\n",
insn->subdev);
ret = -EINVAL;
break;
}
s = dev->subdevices + insn->subdev;
if (!s->async) {
- rt_printk("no async\n");
+ printk("no async\n");
ret = -EINVAL;
break;
}
if (!s->async->inttrig) {
- rt_printk("no inttrig\n");
+ printk("no inttrig\n");
ret = -EAGAIN;
break;
}
@@ -249,7 +245,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
s = dev->subdevices + insn->subdev;
if (s->type == COMEDI_SUBD_UNUSED) {
- rt_printk("%d not useable subdevice\n", insn->subdev);
+ printk("%d not useable subdevice\n", insn->subdev);
ret = -EIO;
goto error;
}
@@ -258,7 +254,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
ret = check_chanlist(s, 1, &insn->chanspec);
if (ret < 0) {
- rt_printk("bad chanspec\n");
+ printk("bad chanspec\n");
ret = -EINVAL;
goto error;
}
@@ -295,7 +291,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
#if 0
/* XXX do we want this? -- abbotti #if'ed it out for now. */
if (ret != insn->n) {
- rt_printk("BUG: result of insn != insn.n\n");
+ printk("BUG: result of insn != insn.n\n");
ret = -EINVAL;
goto error;
}
@@ -336,7 +332,7 @@ int comedi_lock(void *d, unsigned int subdevice)
s = dev->subdevices + subdevice;
- comedi_spin_lock_irqsave(&s->spin_lock, flags);
+ spin_lock_irqsave(&s->spin_lock, flags);
if (s->busy) {
ret = -EBUSY;
@@ -348,7 +344,7 @@ int comedi_lock(void *d, unsigned int subdevice)
}
}
- comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
+ spin_unlock_irqrestore(&s->spin_lock, flags);
return ret;
}
@@ -382,7 +378,7 @@ int comedi_unlock(void *d, unsigned int subdevice)
async = s->async;
- comedi_spin_lock_irqsave(&s->spin_lock, flags);
+ spin_lock_irqsave(&s->spin_lock, flags);
if (s->busy) {
ret = -EBUSY;
@@ -400,7 +396,7 @@ int comedi_unlock(void *d, unsigned int subdevice)
ret = 0;
}
- comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
+ spin_unlock_irqrestore(&s->spin_lock, flags);
return ret;
}
@@ -449,11 +445,6 @@ int comedi_cancel(void *d, unsigned int subdevice)
if (ret)
return ret;
-#ifdef CONFIG_COMEDI_RT
- if (comedi_get_subdevice_runflags(s) & SRF_RT)
- comedi_switch_to_non_rt(dev);
-
-#endif
comedi_set_subdevice_runflags(s, SRF_RUNNING | SRF_RT, 0);
s->async->inttrig = NULL;
s->busy = NULL;
diff --git a/drivers/staging/comedi/kcomedilib/ksyms.c b/drivers/staging/comedi/kcomedilib/ksyms.c
index 3db86dabf878..314765db51fe 100644
--- a/drivers/staging/comedi/kcomedilib/ksyms.c
+++ b/drivers/staging/comedi/kcomedilib/ksyms.c
@@ -59,7 +59,7 @@ EXPORT_SYMBOL(comedi_close);
EXPORT_SYMBOL(comedi_loglevel);
EXPORT_SYMBOL(comedi_perror);
EXPORT_SYMBOL(comedi_strerror);
-//EXPORT_SYMBOL(comedi_errno);
+/* EXPORT_SYMBOL(comedi_errno); */
EXPORT_SYMBOL(comedi_fileno);
/* device queries */
@@ -73,8 +73,10 @@ EXPORT_SYMBOL(comedi_get_subdevice_type);
EXPORT_SYMBOL(comedi_find_subdevice_by_type);
EXPORT_SYMBOL(comedi_get_subdevice_flags);
EXPORT_SYMBOL(comedi_get_n_channels);
-//EXPORT_SYMBOL(comedi_range_is_chan_specific);
-//EXPORT_SYMBOL(comedi_maxdata_is_chan_specific);
+/*
+* EXPORT_SYMBOL(comedi_range_is_chan_specific);
+* EXPORT_SYMBOL(comedi_maxdata_is_chan_specific);
+*/
/* channel queries */
EXPORT_SYMBOL(comedi_get_maxdata);
@@ -82,25 +84,29 @@ EXPORT_SYMBOL(comedi_get_maxdata);
EXPORT_SYMBOL(comedi_get_rangetype);
#endif
EXPORT_SYMBOL(comedi_get_n_ranges);
-//EXPORT_SYMBOL(comedi_find_range);
+/* EXPORT_SYMBOL(comedi_find_range); */
/* buffer queries */
EXPORT_SYMBOL(comedi_get_buffer_size);
-//EXPORT_SYMBOL(comedi_get_max_buffer_size);
-//EXPORT_SYMBOL(comedi_set_buffer_size);
+/*
+* EXPORT_SYMBOL(comedi_get_max_buffer_size);
+* EXPORT_SYMBOL(comedi_set_buffer_size);
+*/
EXPORT_SYMBOL(comedi_get_buffer_contents);
EXPORT_SYMBOL(comedi_get_buffer_offset);
/* low-level stuff */
-//EXPORT_SYMBOL(comedi_trigger);
-//EXPORT_SYMBOL(comedi_do_insnlist);
+/*
+* EXPORT_SYMBOL(comedi_trigger); EXPORT_SYMBOL(comedi_do_insnlist);
+*/
EXPORT_SYMBOL(comedi_do_insn);
EXPORT_SYMBOL(comedi_lock);
EXPORT_SYMBOL(comedi_unlock);
/* physical units */
-//EXPORT_SYMBOL(comedi_to_phys);
-//EXPORT_SYMBOL(comedi_from_phys);
+/*
+* EXPORT_SYMBOL(comedi_to_phys); EXPORT_SYMBOL(comedi_from_phys);
+*/
/* synchronous stuff */
EXPORT_SYMBOL(comedi_data_read);
@@ -113,13 +119,16 @@ EXPORT_SYMBOL(comedi_dio_write);
EXPORT_SYMBOL(comedi_dio_bitfield);
/* slowly varying stuff */
-//EXPORT_SYMBOL(comedi_sv_init);
-//EXPORT_SYMBOL(comedi_sv_update);
-//EXPORT_SYMBOL(comedi_sv_measure);
+/*
+* EXPORT_SYMBOL(comedi_sv_init); EXPORT_SYMBOL(comedi_sv_update);
+* EXPORT_SYMBOL(comedi_sv_measure);
+*/
/* commands */
-//EXPORT_SYMBOL(comedi_get_cmd_src_mask);
-//EXPORT_SYMBOL(comedi_get_cmd_generic_timed);
+/*
+* EXPORT_SYMBOL(comedi_get_cmd_src_mask);
+* EXPORT_SYMBOL(comedi_get_cmd_generic_timed);
+*/
EXPORT_SYMBOL(comedi_cancel);
EXPORT_SYMBOL(comedi_command);
EXPORT_SYMBOL(comedi_command_test);
@@ -129,12 +138,14 @@ EXPORT_SYMBOL(comedi_poll);
EXPORT_SYMBOL(comedi_mark_buffer_read);
EXPORT_SYMBOL(comedi_mark_buffer_written);
-//EXPORT_SYMBOL(comedi_get_range);
+/* EXPORT_SYMBOL(comedi_get_range); */
EXPORT_SYMBOL(comedi_get_len_chanlist);
/* deprecated */
-//EXPORT_SYMBOL(comedi_get_timer);
-//EXPORT_SYMBOL(comedi_timed_1chan);
+/*
+* EXPORT_SYMBOL(comedi_get_timer);
+* EXPORT_SYMBOL(comedi_timed_1chan);
+*/
/* alpha */
-//EXPORT_SYMBOL(comedi_set_global_oor_behavior);
+/* EXPORT_SYMBOL(comedi_set_global_oor_behavior); */
diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
index ac200d929f35..445909e6f334 100644
--- a/drivers/staging/comedi/range.c
+++ b/drivers/staging/comedi/range.c
@@ -32,7 +32,7 @@ const struct comedi_lrange range_unipolar5 = { 1, {UNI_RANGE(5)} };
const struct comedi_lrange range_unknown = { 1, {{0, 1000000, UNIT_none}} };
/*
- COMEDI_RANGEINFO
+ COMEDI_RANGEINFO
range information ioctl
arg:
@@ -130,8 +130,7 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist)
if (CR_CHAN(chanlist[i]) >= s->n_chan ||
CR_RANGE(chanlist[i]) >= s->range_table->length
|| aref_invalid(s, chanlist[i])) {
- rt_printk
- ("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n",
+ printk("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n",
i, chanlist[i], s->n_chan,
s->range_table->length);
#if 0
@@ -147,13 +146,13 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist)
CR_RANGE(chanlist[i]) >=
s->range_table_list[chan]->length
|| aref_invalid(s, chanlist[i])) {
- rt_printk("bad chanlist[%d]=0x%08x\n", i,
+ printk("bad chanlist[%d]=0x%08x\n", i,
chanlist[i]);
return -EINVAL;
}
}
} else {
- rt_printk("comedi: (bug) no range type list!\n");
+ printk("comedi: (bug) no range type list!\n");
return -EINVAL;
}
return 0;
diff --git a/drivers/staging/comedi/rt.c b/drivers/staging/comedi/rt.c
deleted file mode 100644
index e9f5777595ab..000000000000
--- a/drivers/staging/comedi/rt.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- comedi/rt.c
- comedi kernel module
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#undef DEBUG
-
-#define __NO_VERSION__
-#include <linux/comedidev.h>
-
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/ioport.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <asm/io.h>
-
-#include "rt_pend_tq.h"
-
-#ifdef CONFIG_COMEDI_RTAI
-#include <rtai.h>
-#endif
-
-#ifdef CONFIG_COMEDI_FUSION
-#include <nucleus/asm/hal.h>
-#endif
-
-#ifdef CONFIG_COMEDI_RTL
-#include <rtl_core.h>
-#include <rtl_sync.h>
-#endif
-
-struct comedi_irq_struct {
- int rt;
- int irq;
- irqreturn_t(*handler) (int irq, void *dev_id PT_REGS_ARG);
- unsigned long flags;
- const char *device;
- struct comedi_device *dev_id;
-};
-
-static int comedi_rt_get_irq(struct comedi_irq_struct *it);
-static int comedi_rt_release_irq(struct comedi_irq_struct *it);
-
-static struct comedi_irq_struct *comedi_irqs[NR_IRQS];
-
-int comedi_request_irq(unsigned irq, irqreturn_t(*handler) (int,
- void *PT_REGS_ARG), unsigned long flags, const char *device,
- struct comedi_device *dev_id)
-{
- struct comedi_irq_struct *it;
- int ret;
- /* null shared interrupt flag, since rt interrupt handlers do not
- * support it, and this version of comedi_request_irq() is only
- * called for kernels with rt support */
- unsigned long unshared_flags = flags & ~IRQF_SHARED;
-
- ret = request_irq(irq, handler, unshared_flags, device, dev_id);
- if (ret < 0) {
- /* we failed, so fall back on allowing shared interrupt (which we won't ever make RT) */
- if (flags & IRQF_SHARED) {
- rt_printk
- ("comedi: cannot get unshared interrupt, will not use RT interrupts.\n");
- ret = request_irq(irq, handler, flags, device, dev_id);
- }
- if (ret < 0)
- return ret;
-
- } else {
- it = kzalloc(sizeof(struct comedi_irq_struct), GFP_KERNEL);
- if (!it)
- return -ENOMEM;
-
- it->handler = handler;
- it->irq = irq;
- it->dev_id = dev_id;
- it->device = device;
- it->flags = unshared_flags;
- comedi_irqs[irq] = it;
- }
- return 0;
-}
-
-void comedi_free_irq(unsigned int irq, struct comedi_device *dev_id)
-{
- struct comedi_irq_struct *it;
-
- free_irq(irq, dev_id);
-
- it = comedi_irqs[irq];
- if (it == NULL)
- return;
-
- if (it->rt) {
- printk("real-time IRQ allocated at board removal (ignore)\n");
- comedi_rt_release_irq(it);
- }
-
- kfree(it);
- comedi_irqs[irq] = NULL;
-}
-
-int comedi_switch_to_rt(struct comedi_device *dev)
-{
- struct comedi_irq_struct *it;
- unsigned long flags;
-
- it = comedi_irqs[dev->irq];
- /* drivers might not be using an interrupt for commands,
- or we might not have been able to get an unshared irq */
- if (it == NULL)
- return -1;
-
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
-
- if (!dev->rt)
- comedi_rt_get_irq(it);
-
- dev->rt++;
- it->rt = 1;
-
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
-
- return 0;
-}
-
-void comedi_switch_to_non_rt(struct comedi_device *dev)
-{
- struct comedi_irq_struct *it;
- unsigned long flags;
-
- it = comedi_irqs[dev->irq];
- if (it == NULL)
- return;
-
- comedi_spin_lock_irqsave(&dev->spinlock, flags);
-
- dev->rt--;
- if (!dev->rt)
- comedi_rt_release_irq(it);
-
- it->rt = 0;
-
- comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
-}
-
-void wake_up_int_handler(int arg1, void *arg2)
-{
- wake_up_interruptible((wait_queue_head_t *) arg2);
-}
-
-void comedi_rt_pend_wakeup(wait_queue_head_t *q)
-{
- rt_pend_call(wake_up_int_handler, 0, q);
-}
-
-/* RTAI section */
-#ifdef CONFIG_COMEDI_RTAI
-
-#ifndef HAVE_RT_REQUEST_IRQ_WITH_ARG
-#define DECLARE_VOID_IRQ(irq) \
-static void handle_void_irq_ ## irq (void){ handle_void_irq(irq); }
-
-static void handle_void_irq(int irq)
-{
- struct comedi_irq_struct *it;
-
- it = comedi_irqs[irq];
- if (it == NULL) {
- rt_printk("comedi: null irq struct?\n");
- return;
- }
- it->handler(irq, it->dev_id PT_REGS_NULL);
- rt_enable_irq(irq); /* needed by rtai-adeos, seems like it shouldn't hurt earlier versions */
-}
-
-DECLARE_VOID_IRQ(0);
-DECLARE_VOID_IRQ(1);
-DECLARE_VOID_IRQ(2);
-DECLARE_VOID_IRQ(3);
-DECLARE_VOID_IRQ(4);
-DECLARE_VOID_IRQ(5);
-DECLARE_VOID_IRQ(6);
-DECLARE_VOID_IRQ(7);
-DECLARE_VOID_IRQ(8);
-DECLARE_VOID_IRQ(9);
-DECLARE_VOID_IRQ(10);
-DECLARE_VOID_IRQ(11);
-DECLARE_VOID_IRQ(12);
-DECLARE_VOID_IRQ(13);
-DECLARE_VOID_IRQ(14);
-DECLARE_VOID_IRQ(15);
-DECLARE_VOID_IRQ(16);
-DECLARE_VOID_IRQ(17);
-DECLARE_VOID_IRQ(18);
-DECLARE_VOID_IRQ(19);
-DECLARE_VOID_IRQ(20);
-DECLARE_VOID_IRQ(21);
-DECLARE_VOID_IRQ(22);
-DECLARE_VOID_IRQ(23);
-
-static void handle_void_irq_ptrs[] = {
- handle_void_irq_0,
- handle_void_irq_1,
- handle_void_irq_2,
- handle_void_irq_3,
- handle_void_irq_4,
- handle_void_irq_5,
- handle_void_irq_6,
- handle_void_irq_7,
- handle_void_irq_8,
- handle_void_irq_9,
- handle_void_irq_10,
- handle_void_irq_11,
- handle_void_irq_12,
- handle_void_irq_13,
- handle_void_irq_14,
- handle_void_irq_15,
- handle_void_irq_16,
- handle_void_irq_17,
- handle_void_irq_18,
- handle_void_irq_19,
- handle_void_irq_20,
- handle_void_irq_21,
- handle_void_irq_22,
- handle_void_irq_23,
-};
-
-static int comedi_rt_get_irq(struct comedi_irq_struct *it)
-{
- rt_request_global_irq(it->irq, handle_void_irq_ptrs[it->irq]);
- rt_startup_irq(it->irq);
-
- return 0;
-}
-
-static int comedi_rt_release_irq(struct comedi_irq_struct *it)
-{
- rt_shutdown_irq(it->irq);
- rt_free_global_irq(it->irq);
- return 0;
-}
-#else
-
-static int comedi_rt_get_irq(struct comedi_irq_struct *it)
-{
- int ret;
-
- ret = rt_request_global_irq_arg(it->irq, it->handler, it->flags,
- it->device, it->dev_id);
- if (ret < 0) {
- rt_printk("rt_request_global_irq_arg() returned %d\n", ret);
- return ret;
- }
- rt_startup_irq(it->irq);
-
- return 0;
-}
-
-static int comedi_rt_release_irq(struct comedi_irq_struct *it)
-{
- rt_shutdown_irq(it->irq);
- rt_free_global_irq(it->irq);
- return 0;
-}
-#endif
-
-void comedi_rt_init(void)
-{
- rt_mount_rtai();
- rt_pend_tq_init();
-}
-
-void comedi_rt_cleanup(void)
-{
- rt_umount_rtai();
- rt_pend_tq_cleanup();
-}
-
-#endif
-
-/* Fusion section */
-#ifdef CONFIG_COMEDI_FUSION
-
-static void fusion_handle_irq(unsigned int irq, void *cookie)
-{
- struct comedi_irq_struct *it = cookie;
-
- it->handler(irq, it->dev_id PT_REGS_NULL);
- rthal_irq_enable(irq);
-}
-
-static int comedi_rt_get_irq(struct comedi_irq_struct *it)
-{
- rthal_irq_request(it->irq, fusion_handle_irq, it);
- rthal_irq_enable(it->irq);
- return 0;
-}
-
-static int comedi_rt_release_irq(struct comedi_irq_struct *it)
-{
- rthal_irq_disable(it->irq);
- rthal_irq_release(it->irq);
- return 0;
-}
-
-void comedi_rt_init(void)
-{
- rt_pend_tq_init();
-}
-
-void comedi_rt_cleanup(void)
-{
- rt_pend_tq_cleanup();
-}
-
-#endif /*CONFIG_COMEDI_FUSION */
-
-/* RTLinux section */
-#ifdef CONFIG_COMEDI_RTL
-
-static unsigned int handle_rtl_irq(unsigned int irq PT_REGS_ARG)
-{
- struct comedi_irq_struct *it;
-
- it = comedi_irqs[irq];
- if (it == NULL)
- return 0;
- it->handler(irq, it->dev_id PT_REGS_NULL);
- rtl_hard_enable_irq(irq);
- return 0;
-}
-
-static int comedi_rt_get_irq(struct comedi_irq_struct *it)
-{
- rtl_request_global_irq(it->irq, handle_rtl_irq);
- return 0;
-}
-
-static int comedi_rt_release_irq(struct comedi_irq_struct *it)
-{
- rtl_free_global_irq(it->irq);
- return 0;
-}
-
-void comedi_rt_init(void)
-{
- rt_pend_tq_init();
-}
-
-void comedi_rt_cleanup(void)
-{
- rt_pend_tq_cleanup();
-}
-
-#endif
-
-#ifdef CONFIG_COMEDI_PIRQ
-static int comedi_rt_get_irq(struct comedi_irq_struct *it)
-{
- int ret;
-
- free_irq(it->irq, it->dev_id);
- ret = request_irq(it->irq, it->handler, it->flags | SA_PRIORITY,
- it->device, it->dev_id);
-
- return ret;
-}
-
-static int comedi_rt_release_irq(struct comedi_irq_struct *it)
-{
- int ret;
-
- free_irq(it->irq, it->dev_id);
- ret = request_irq(it->irq, it->handler, it->flags,
- it->device, it->dev_id);
-
- return ret;
-}
-
-void comedi_rt_init(void)
-{
- /* rt_pend_tq_init(); */
-}
-
-void comedi_rt_cleanup(void)
-{
- /* rt_pend_tq_cleanup(); */
-}
-#endif
diff --git a/drivers/staging/comedi/rt_pend_tq.c b/drivers/staging/comedi/rt_pend_tq.c
deleted file mode 100644
index f9dfd9d40cd3..000000000000
--- a/drivers/staging/comedi/rt_pend_tq.c
+++ /dev/null
@@ -1,113 +0,0 @@
-#define __NO_VERSION__
-/* rt_pend_tq.c */
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include "comedidev.h" /* for rt spinlocks */
-#include "rt_pend_tq.h"
-#ifdef CONFIG_COMEDI_RTAI
-#include <rtai.h>
-#endif
-#ifdef CONFIG_COMEDI_FUSION
-#include <nucleus/asm/hal.h>
-#endif
-#ifdef CONFIG_COMEDI_RTL
-#include <rtl_core.h>
-#endif
-
-#ifdef standalone
-#include <linux/module.h>
-#define rt_pend_tq_init init_module
-#define rt_pend_tq_cleanup cleanup_module
-#endif
-
-volatile static struct rt_pend_tq rt_pend_tq[RT_PEND_TQ_SIZE];
-volatile static struct rt_pend_tq *volatile rt_pend_head = rt_pend_tq,
- *volatile rt_pend_tail = rt_pend_tq;
-int rt_pend_tq_irq = 0;
-DEFINE_SPINLOCK(rt_pend_tq_lock);
-
-/* WARNING: following code not checked against race conditions yet. */
-#define INC_CIRCULAR_PTR(ptr,begin,size) do {if(++(ptr)>=(begin)+(size)) (ptr)=(begin); } while(0)
-#define DEC_CIRCULAR_PTR(ptr,begin,size) do {if(--(ptr)<(begin)) (ptr)=(begin)+(size)-1; } while(0)
-
-int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1, void *arg2)
-{
- unsigned long flags;
-
- if (func == NULL)
- return -EINVAL;
- if (rt_pend_tq_irq <= 0)
- return -ENODEV;
- comedi_spin_lock_irqsave(&rt_pend_tq_lock, flags);
- INC_CIRCULAR_PTR(rt_pend_head, rt_pend_tq, RT_PEND_TQ_SIZE);
- if (rt_pend_head == rt_pend_tail) {
- /* overflow, we just refuse to take this request */
- DEC_CIRCULAR_PTR(rt_pend_head, rt_pend_tq, RT_PEND_TQ_SIZE);
- comedi_spin_unlock_irqrestore(&rt_pend_tq_lock, flags);
- return -EAGAIN;
- }
- rt_pend_head->func = func;
- rt_pend_head->arg1 = arg1;
- rt_pend_head->arg2 = arg2;
- comedi_spin_unlock_irqrestore(&rt_pend_tq_lock, flags);
-#ifdef CONFIG_COMEDI_RTAI
- rt_pend_linux_srq(rt_pend_tq_irq);
-#endif
-#ifdef CONFIG_COMEDI_FUSION
- rthal_apc_schedule(rt_pend_tq_irq);
-#endif
-#ifdef CONFIG_COMEDI_RTL
- rtl_global_pend_irq(rt_pend_tq_irq);
-
-#endif
- return 0;
-}
-
-#ifdef CONFIG_COMEDI_RTAI
-void rt_pend_irq_handler(void)
-#elif defined(CONFIG_COMEDI_FUSION)
-void rt_pend_irq_handler(void *cookie)
-#elif defined(CONFIG_COMEDI_RTL)
-void rt_pend_irq_handler(int irq, void *dev PT_REGS_ARG)
-#endif
-{
- while (rt_pend_head != rt_pend_tail) {
- INC_CIRCULAR_PTR(rt_pend_tail, rt_pend_tq, RT_PEND_TQ_SIZE);
- rt_pend_tail->func(rt_pend_tail->arg1, rt_pend_tail->arg2);
- }
-}
-
-int rt_pend_tq_init(void)
-{
- rt_pend_head = rt_pend_tail = rt_pend_tq;
-#ifdef CONFIG_COMEDI_RTAI
- rt_pend_tq_irq = rt_request_srq(0, rt_pend_irq_handler, NULL);
-#endif
-#ifdef CONFIG_COMEDI_FUSION
- rt_pend_tq_irq =
- rthal_apc_alloc("comedi APC", rt_pend_irq_handler, NULL);
-#endif
-#ifdef CONFIG_COMEDI_RTL
- rt_pend_tq_irq = rtl_get_soft_irq(rt_pend_irq_handler, "rt_pend_irq");
-#endif
- if (rt_pend_tq_irq > 0)
- printk("rt_pend_tq: RT bottom half scheduler initialized OK\n");
- else
- printk("rt_pend_tq: rtl_get_soft_irq failed\n");
- return 0;
-}
-
-void rt_pend_tq_cleanup(void)
-{
- printk("rt_pend_tq: unloading\n");
-#ifdef CONFIG_COMEDI_RTAI
- rt_free_srq(rt_pend_tq_irq);
-#endif
-#ifdef CONFIG_COMEDI_FUSION
- rthal_apc_free(rt_pend_tq_irq);
-#endif
-#ifdef CONFIG_COMEDI_RTL
- free_irq(rt_pend_tq_irq, NULL);
-#endif
-}
diff --git a/drivers/staging/comedi/rt_pend_tq.h b/drivers/staging/comedi/rt_pend_tq.h
deleted file mode 100644
index 01ed71bf409d..000000000000
--- a/drivers/staging/comedi/rt_pend_tq.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#define RT_PEND_TQ_SIZE 16
-struct rt_pend_tq {
- void (*func) (int arg1, void *arg2);
- int arg1;
- void *arg2;
-};
-extern int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1,
- void *arg2);
-extern int rt_pend_tq_init(void);
-extern void rt_pend_tq_cleanup(void);
diff --git a/drivers/staging/cpc-usb/Kconfig b/drivers/staging/cpc-usb/Kconfig
new file mode 100644
index 000000000000..00924ce81956
--- /dev/null
+++ b/drivers/staging/cpc-usb/Kconfig
@@ -0,0 +1,4 @@
+config USB_CPC
+ tristate "CPC CAN USB driver"
+ depends on USB
+ default n
diff --git a/drivers/staging/cpc-usb/Makefile b/drivers/staging/cpc-usb/Makefile
new file mode 100644
index 000000000000..3f83170a8fab
--- /dev/null
+++ b/drivers/staging/cpc-usb/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_USB_CPC) += cpc-usb.o
+
+cpc-usb-y := cpc-usb_drv.o sja2m16c_2.o
diff --git a/drivers/staging/cpc-usb/TODO b/drivers/staging/cpc-usb/TODO
new file mode 100644
index 000000000000..000e8bbc6188
--- /dev/null
+++ b/drivers/staging/cpc-usb/TODO
@@ -0,0 +1,9 @@
+Things to do for this driver to get merged into the main portion of the
+kernel:
+ - checkpatch cleanups
+ - sparse clean
+ - remove proc code
+ - tie into CAN socket interfaces if possible
+ - figure out sane userspace api
+
+Send patches to Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/cpc-usb/cpc-usb_drv.c b/drivers/staging/cpc-usb/cpc-usb_drv.c
new file mode 100644
index 000000000000..14aca399fc4c
--- /dev/null
+++ b/drivers/staging/cpc-usb/cpc-usb_drv.c
@@ -0,0 +1,1191 @@
+/*
+ * CPC-USB CAN Interface Kernel Driver
+ *
+ * Copyright (C) 2004-2009 EMS Dr. Thomas Wuensche
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/module.h>
+#include <linux/poll.h>
+#include <linux/smp_lock.h>
+#include <linux/completion.h>
+#include <asm/uaccess.h>
+#include <linux/usb.h>
+
+#include <linux/version.h>
+
+#ifdef CONFIG_PROC_FS
+# include <linux/proc_fs.h>
+#endif
+
+#include "cpc.h"
+
+#include "cpc_int.h"
+#include "cpcusb.h"
+
+#include "sja2m16c.h"
+
+/* Version Information */
+#define DRIVER_AUTHOR "Sebastian Haas <haas@ems-wuensche.com>"
+#define DRIVER_DESC "CPC-USB Driver for Linux Kernel 2.6"
+#define DRIVER_VERSION CPC_DRIVER_VERSION
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL v2");
+
+/* Define these values to match your devices */
+#define USB_CPCUSB_VENDOR_ID 0x12D6
+
+#define USB_CPCUSB_M16C_PRODUCT_ID 0x0888
+#define USB_CPCUSB_LPC2119_PRODUCT_ID 0x0444
+
+#ifndef CONFIG_PROC_FS
+#error "PROCFS needed"
+#endif
+
+#define CPC_USB_PROC_DIR CPC_PROC_DIR "cpc-usb"
+
+static struct proc_dir_entry *procDir;
+static struct proc_dir_entry *procEntry;
+
+/* Module parameters */
+static int debug;
+module_param(debug, int, S_IRUGO);
+
+/* table of devices that work with this driver */
+static struct usb_device_id cpcusb_table[] = {
+ {USB_DEVICE(USB_CPCUSB_VENDOR_ID, USB_CPCUSB_M16C_PRODUCT_ID)},
+ {USB_DEVICE(USB_CPCUSB_VENDOR_ID, USB_CPCUSB_LPC2119_PRODUCT_ID)},
+ {} /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, cpcusb_table);
+
+/* use to prevent kernel panic if driver is unloaded
+ * while a programm has still open the device
+ */
+DECLARE_WAIT_QUEUE_HEAD(rmmodWq);
+atomic_t useCount;
+
+static CPC_USB_T *CPCUSB_Table[CPC_USB_CARD_CNT] = { 0 };
+static unsigned int CPCUsbCnt;
+
+/* prevent races between open() and disconnect() */
+static DECLARE_MUTEX(disconnect_sem);
+
+/* local function prototypes */
+static ssize_t cpcusb_read(struct file *file, char *buffer, size_t count,
+ loff_t *ppos);
+static ssize_t cpcusb_write(struct file *file, const char *buffer,
+ size_t count, loff_t *ppos);
+static unsigned int cpcusb_poll(struct file *file, poll_table * wait);
+static int cpcusb_open(struct inode *inode, struct file *file);
+static int cpcusb_release(struct inode *inode, struct file *file);
+
+static int cpcusb_probe(struct usb_interface *interface,
+ const struct usb_device_id *id);
+static void cpcusb_disconnect(struct usb_interface *interface);
+
+static void cpcusb_read_bulk_callback(struct urb *urb);
+static void cpcusb_write_bulk_callback(struct urb *urb);
+static void cpcusb_read_interrupt_callback(struct urb *urb);
+
+static int cpcusb_setup_intrep(CPC_USB_T *card);
+
+static struct file_operations cpcusb_fops = {
+ /*
+ * The owner field is part of the module-locking
+ * mechanism. The idea is that the kernel knows
+ * which module to increment the use-counter of
+ * BEFORE it calls the device's open() function.
+ * This also means that the kernel can decrement
+ * the use-counter again before calling release()
+ * or should the open() function fail.
+ */
+ .owner = THIS_MODULE,
+
+ .read = cpcusb_read,
+ .write = cpcusb_write,
+ .poll = cpcusb_poll,
+ .open = cpcusb_open,
+ .release = cpcusb_release,
+};
+
+/*
+ * usb class driver info in order to get a minor number from the usb core,
+ * and to have the device registered with devfs and the driver core
+ */
+static struct usb_class_driver cpcusb_class = {
+ .name = "usb/cpc_usb%d",
+ .fops = &cpcusb_fops,
+ .minor_base = CPC_USB_BASE_MNR,
+};
+
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver cpcusb_driver = {
+ .name = "cpc-usb",
+ .probe = cpcusb_probe,
+ .disconnect = cpcusb_disconnect,
+ .id_table = cpcusb_table,
+};
+
+static int cpcusb_create_info_output(char *buf)
+{
+ int i = 0, j;
+
+ for (j = 0; j < CPC_USB_CARD_CNT; j++) {
+ if (CPCUSB_Table[j]) {
+ CPC_USB_T *card = CPCUSB_Table[j];
+ CPC_CHAN_T *chan = card->chan;
+
+ /* MINOR CHANNELNO BUSNO SLOTNO */
+ i += sprintf(&buf[i], "%d %s\n", chan->minor,
+ card->serialNumber);
+ }
+ }
+
+ return i;
+}
+
+static int cpcusb_proc_read_info(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len = cpcusb_create_info_output(page);
+
+ if (len <= off + count)
+ *eof = 1;
+ *start = page + off;
+ len -= off;
+ if (len > count)
+ len = count;
+ if (len < 0)
+ len = 0;
+
+ return len;
+}
+
+/*
+ * Remove CPC-USB and cleanup
+ */
+static inline void cpcusb_delete(CPC_USB_T *card)
+{
+ if (card) {
+ if (card->chan) {
+ if (card->chan->buf)
+ vfree(card->chan->buf);
+
+ if (card->chan->CPCWait_q)
+ kfree(card->chan->CPCWait_q);
+
+ kfree(card->chan);
+ }
+
+ CPCUSB_Table[card->idx] = NULL;
+ kfree(card);
+ }
+}
+
+/*
+ * setup the interrupt IN endpoint of a specific CPC-USB device
+ */
+static int cpcusb_setup_intrep(CPC_USB_T *card)
+{
+ int retval = 0;
+ struct usb_endpoint_descriptor *ep;
+
+ ep = &card->interface->altsetting[0].endpoint[card->num_intr_in].desc;
+
+ card->intr_in_buffer[0] = 0;
+ card->free_slots = 15; /* initial size */
+
+ /* setup the urb */
+ usb_fill_int_urb(card->intr_in_urb, card->udev,
+ usb_rcvintpipe(card->udev, card->num_intr_in),
+ card->intr_in_buffer,
+ sizeof(card->intr_in_buffer),
+ cpcusb_read_interrupt_callback,
+ card,
+ ep->bInterval);
+
+ card->intr_in_urb->status = 0; /* needed! */
+
+ /* submit the urb */
+ retval = usb_submit_urb(card->intr_in_urb, GFP_KERNEL);
+
+ if (retval)
+ err("%s - failed submitting intr urb, error %d", __func__,
+ retval);
+
+ return retval;
+}
+
+static int cpcusb_open(struct inode *inode, struct file *file)
+{
+ CPC_USB_T *card = NULL;
+ struct usb_interface *interface;
+ int subminor;
+ int j, retval = 0;
+
+ subminor = iminor(inode);
+
+ /* prevent disconnects */
+ down(&disconnect_sem);
+
+ interface = usb_find_interface(&cpcusb_driver, subminor);
+ if (!interface) {
+ err("%s - error, can't find device for minor %d",
+ __func__, subminor);
+ retval = CPC_ERR_NO_INTERFACE_PRESENT;
+ goto exit_no_device;
+ }
+
+ card = usb_get_intfdata(interface);
+ if (!card) {
+ retval = CPC_ERR_NO_INTERFACE_PRESENT;
+ goto exit_no_device;
+ }
+
+ /* lock this device */
+ down(&card->sem);
+
+ /* increment our usage count for the driver */
+ if (card->open) {
+ dbg("device already opened");
+ retval = CPC_ERR_CHANNEL_ALREADY_OPEN;
+ goto exit_on_error;
+ }
+
+ /* save our object in the file's private structure */
+ file->private_data = card;
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ usb_fill_bulk_urb(card->urbs[j].urb, card->udev,
+ usb_rcvbulkpipe(card->udev, card->num_bulk_in),
+ card->urbs[j].buffer, card->urbs[j].size,
+ cpcusb_read_bulk_callback, card);
+
+ retval = usb_submit_urb(card->urbs[j].urb, GFP_KERNEL);
+
+ if (retval) {
+ err("%s - failed submitting read urb, error %d",
+ __func__, retval);
+ retval = CPC_ERR_TRANSMISSION_FAILED;
+ goto exit_on_error;
+ }
+ }
+
+ info("%s - %d URB's submitted", __func__, j);
+
+ ResetBuffer(card->chan);
+
+ cpcusb_setup_intrep(card);
+ card->open = 1;
+
+ atomic_inc(&useCount);
+
+exit_on_error:
+ /* unlock this device */
+ up(&card->sem);
+
+exit_no_device:
+ up(&disconnect_sem);
+
+ return retval;
+}
+
+static unsigned int cpcusb_poll(struct file *file, poll_table * wait)
+{
+ CPC_USB_T *card = (CPC_USB_T *) file->private_data;
+ unsigned int retval = 0;
+
+ if (!card) {
+ err("%s - device object lost", __func__);
+ return -EIO;
+ }
+
+ poll_wait(file, card->chan->CPCWait_q, wait);
+
+ if (IsBufferNotEmpty(card->chan) || !(card->present))
+ retval |= (POLLIN | POLLRDNORM);
+
+ if (card->free_slots)
+ retval |= (POLLOUT | POLLWRNORM);
+
+ return retval;
+}
+
+static int cpcusb_release(struct inode *inode, struct file *file)
+{
+ CPC_USB_T *card = (CPC_USB_T *) file->private_data;
+ int j, retval = 0;
+
+ if (card == NULL) {
+ dbg("%s - object is NULL", __func__);
+ return CPC_ERR_NO_INTERFACE_PRESENT;
+ }
+
+ /* lock our device */
+ down(&card->sem);
+
+ if (!card->open) {
+ dbg("%s - device not opened", __func__);
+ retval = CPC_ERR_NO_INTERFACE_PRESENT;
+ goto exit_not_opened;
+ }
+
+ /* if device wasn't unplugged kill all urbs */
+ if (card->present) {
+ /* kill read urbs */
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ usb_kill_urb(card->urbs[j].urb);
+ }
+
+ /* kill irq urb */
+ usb_kill_urb(card->intr_in_urb);
+
+ /* kill write urbs */
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ if (atomic_read(&card->wrUrbs[j].busy)) {
+ usb_kill_urb(card->wrUrbs[j].urb);
+ wait_for_completion(&card->wrUrbs[j].finished);
+ }
+ }
+ }
+
+ atomic_dec(&useCount);
+
+ /* last process detached */
+ if (atomic_read(&useCount) == 0) {
+ wake_up(&rmmodWq);
+ }
+
+ if (!card->present && card->open) {
+ /* the device was unplugged before the file was released */
+ up(&card->sem);
+ cpcusb_delete(card);
+ return 0;
+ }
+
+ card->open = 0;
+
+exit_not_opened:
+ up(&card->sem);
+
+ return 0;
+}
+
+static ssize_t cpcusb_read(struct file *file, char *buffer, size_t count,
+ loff_t *ppos)
+{
+ CPC_USB_T *card = (CPC_USB_T *) file->private_data;
+ CPC_CHAN_T *chan;
+ int retval = 0;
+
+ if (count < sizeof(CPC_MSG_T))
+ return CPC_ERR_UNKNOWN;
+
+ /* check if can read from the given address */
+ if (!access_ok(VERIFY_WRITE, buffer, count))
+ return CPC_ERR_UNKNOWN;
+
+ /* lock this object */
+ down(&card->sem);
+
+ /* verify that the device wasn't unplugged */
+ if (!card->present) {
+ up(&card->sem);
+ return CPC_ERR_NO_INTERFACE_PRESENT;
+ }
+
+ if (IsBufferEmpty(card->chan)) {
+ retval = 0;
+ } else {
+ chan = card->chan;
+
+#if 0
+ /* convert LPC2119 params back to SJA1000 params */
+ if (card->deviceRevision >= 0x0200
+ && chan->buf[chan->oidx].type == CPC_MSG_T_CAN_PRMS) {
+ LPC2119_TO_SJA1000_Params(&chan->buf[chan->oidx]);
+ }
+#endif
+
+ if (copy_to_user(buffer, &chan->buf[chan->oidx], count) != 0) {
+ retval = CPC_ERR_IO_TRANSFER;
+ } else {
+ chan->oidx = (chan->oidx + 1) % CPC_MSG_BUF_CNT;
+ chan->WnR = 1;
+ retval = sizeof(CPC_MSG_T);
+ }
+ }
+/* spin_unlock_irqrestore(&card->slock, flags); */
+
+ /* unlock the device */
+ up(&card->sem);
+
+ return retval;
+}
+
+#define SHIFT 1
+static inline void cpcusb_align_buffer_alignment(unsigned char *buf)
+{
+ /* CPC-USB uploads packed bytes. */
+ CPC_MSG_T *cpc = (CPC_MSG_T *) buf;
+ unsigned int i;
+
+ for (i = 0; i < cpc->length + (2 * sizeof(unsigned long)); i++) {
+ ((unsigned char *) &cpc->msgid)[1 + i] =
+ ((unsigned char *) &cpc->msgid)[1 + SHIFT + i];
+ }
+}
+
+static int cpc_get_buffer_count(CPC_CHAN_T *chan)
+{
+ /* check the buffer parameters */
+ if (chan->iidx == chan->oidx)
+ return !chan->WnR ? CPC_MSG_BUF_CNT : 0;
+ else if (chan->iidx >= chan->oidx)
+ return (chan->iidx - chan->oidx) % CPC_MSG_BUF_CNT;
+
+ return (chan->iidx + CPC_MSG_BUF_CNT - chan->oidx) % CPC_MSG_BUF_CNT;
+}
+
+static ssize_t cpcusb_write(struct file *file, const char *buffer,
+ size_t count, loff_t *ppos)
+{
+ CPC_USB_T *card = (CPC_USB_T *) file->private_data;
+ CPC_USB_WRITE_URB_T *wrUrb = NULL;
+
+ ssize_t bytes_written = 0;
+ int retval = 0;
+ int j;
+
+ unsigned char *obuf = NULL;
+ unsigned char type = 0;
+ CPC_MSG_T *info = NULL;
+
+ dbg("%s - entered minor %d, count = %d, present = %d",
+ __func__, card->minor, count, card->present);
+
+ if (count > sizeof(CPC_MSG_T))
+ return CPC_ERR_UNKNOWN;
+
+ /* check if can read from the given address */
+ if (!access_ok(VERIFY_READ, buffer, count))
+ return CPC_ERR_UNKNOWN;
+
+ /* lock this object */
+ down(&card->sem);
+
+ /* verify that the device wasn't unplugged */
+ if (!card->present) {
+ retval = CPC_ERR_NO_INTERFACE_PRESENT;
+ goto exit;
+ }
+
+ /* verify that we actually have some data to write */
+ if (count == 0) {
+ dbg("%s - write request of 0 bytes", __func__);
+ goto exit;
+ }
+
+ if (card->free_slots <= 5) {
+ info = (CPC_MSG_T *) buffer;
+
+ if (info->type != CPC_CMD_T_CLEAR_CMD_QUEUE
+ || card->free_slots <= 0) {
+ dbg("%s - send buffer full please try again %d",
+ __func__, card->free_slots);
+ retval = CPC_ERR_CAN_NO_TRANSMIT_BUF;
+ goto exit;
+ }
+ }
+
+ /* Find a free write urb */
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ if (!atomic_read(&card->wrUrbs[j].busy)) {
+ wrUrb = &card->wrUrbs[j]; /* remember found URB */
+ atomic_set(&wrUrb->busy, 1); /* lock this URB */
+ init_completion(&wrUrb->finished); /* init completion */
+ dbg("WR URB no. %d started", j);
+ break;
+ }
+ }
+
+ /* don't found write urb say error */
+ if (!wrUrb) {
+ dbg("%s - no free send urb available", __func__);
+ retval = CPC_ERR_CAN_NO_TRANSMIT_BUF;
+ goto exit;
+ }
+ dbg("URB write req");
+
+ obuf = (unsigned char *) wrUrb->urb->transfer_buffer;
+
+ /* copy the data from userspace into our transfer buffer;
+ * this is the only copy required.
+ */
+ if (copy_from_user(&obuf[4], buffer, count) != 0) {
+ atomic_set(&wrUrb->busy, 0); /* release urb */
+ retval = CPC_ERR_IO_TRANSFER;
+ goto exit;
+ }
+
+ /* check if it is a DRIVER information message, so we can
+ * response to that message and not the USB
+ */
+ info = (CPC_MSG_T *) &obuf[4];
+
+ bytes_written = 11 + info->length;
+ if (bytes_written >= wrUrb->size) {
+ retval = CPC_ERR_IO_TRANSFER;
+ goto exit;
+ }
+
+ switch (info->type) {
+ case CPC_CMD_T_CLEAR_MSG_QUEUE:
+ ResetBuffer(card->chan);
+ break;
+
+ case CPC_CMD_T_INQ_MSG_QUEUE_CNT:
+ retval = cpc_get_buffer_count(card->chan);
+ atomic_set(&wrUrb->busy, 0);
+
+ goto exit;
+
+ case CPC_CMD_T_INQ_INFO:
+ if (info->msg.info.source == CPC_INFOMSG_T_DRIVER) {
+ /* release urb cause we'll use it for driver
+ * information
+ */
+ atomic_set(&wrUrb->busy, 0);
+ if (IsBufferFull(card->chan)) {
+ retval = CPC_ERR_IO_TRANSFER;
+ goto exit;
+ }
+
+ /* it is a driver information request message and we have
+ * free rx slots to store the response
+ */
+ type = info->msg.info.type;
+ info = &card->chan->buf[card->chan->iidx];
+
+ info->type = CPC_MSG_T_INFO;
+ info->msg.info.source = CPC_INFOMSG_T_DRIVER;
+ info->msg.info.type = type;
+
+ switch (type) {
+ case CPC_INFOMSG_T_VERSION:
+ info->length = strlen(CPC_DRIVER_VERSION) + 2;
+ sprintf(info->msg.info.msg, "%s\n",
+ CPC_DRIVER_VERSION);
+ break;
+
+ case CPC_INFOMSG_T_SERIAL:
+ info->length = strlen(CPC_DRIVER_SERIAL) + 2;
+ sprintf(info->msg.info.msg, "%s\n",
+ CPC_DRIVER_SERIAL);
+ break;
+
+ default:
+ info->length = 2;
+ info->msg.info.type =
+ CPC_INFOMSG_T_UNKNOWN_TYPE;
+ }
+
+ card->chan->WnR = 0;
+ card->chan->iidx =
+ (card->chan->iidx + 1) % CPC_MSG_BUF_CNT;
+
+ retval = info->length;
+ goto exit;
+ }
+ break;
+ case CPC_CMD_T_CAN_PRMS:
+ /* Check the controller type. If it's the new CPC-USB, make sure if these are SJA1000 params */
+ if (info->msg.canparams.cc_type != SJA1000
+ && info->msg.canparams.cc_type != M16C_BASIC
+ && (card->productId == USB_CPCUSB_LPC2119_PRODUCT_ID
+ && info->msg.canparams.cc_type != SJA1000)) {
+ /* don't forget to release the urb */
+ atomic_set(&wrUrb->busy, 0);
+ retval = CPC_ERR_WRONG_CONTROLLER_TYPE;
+ goto exit;
+ }
+ break;
+ }
+
+ /* just convert the params if it is an old CPC-USB with M16C controller */
+ if (card->productId == USB_CPCUSB_M16C_PRODUCT_ID) {
+ /* if it is a parameter message convert it from SJA1000 controller
+ * settings to M16C Basic controller settings
+ */
+ SJA1000_TO_M16C_BASIC_Params((CPC_MSG_T *) &obuf[4]);
+ }
+
+ /* don't forget the byte alignment */
+ cpcusb_align_buffer_alignment(&obuf[4]);
+
+ /* setup a the 4 byte header */
+ obuf[0] = obuf[1] = obuf[2] = obuf[3] = 0;
+
+ /* this urb was already set up, except for this write size */
+ wrUrb->urb->transfer_buffer_length = bytes_written + 4;
+
+ /* send the data out the bulk port */
+ /* a character device write uses GFP_KERNEL,
+ unless a spinlock is held */
+ retval = usb_submit_urb(wrUrb->urb, GFP_KERNEL);
+ if (retval) {
+ atomic_set(&wrUrb->busy, 0); /* release urb */
+ err("%s - failed submitting write urb, error %d",
+ __func__, retval);
+ } else {
+ retval = bytes_written;
+ }
+
+exit:
+ /* unlock the device */
+ up(&card->sem);
+
+ dbg("%s - leaved", __func__);
+
+ return retval;
+}
+
+/*
+ * callback for interrupt IN urb
+ */
+static void cpcusb_read_interrupt_callback(struct urb *urb)
+{
+ CPC_USB_T *card = (CPC_USB_T *) urb->context;
+ int retval;
+ unsigned long flags;
+
+ spin_lock_irqsave(&card->slock, flags);
+
+ if (!card->present) {
+ spin_unlock_irqrestore(&card->slock, flags);
+ info("%s - no such device", __func__);
+ return;
+ }
+
+ switch (urb->status) {
+ case 0: /* success */
+ card->free_slots = card->intr_in_buffer[1];
+ break;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ /* urb was killed */
+ spin_unlock_irqrestore(&card->slock, flags);
+ dbg("%s - intr urb killed", __func__);
+ return;
+ default:
+ info("%s - nonzero urb status %d", __func__, urb->status);
+ break;
+ }
+
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval) {
+ err("%s - failed resubmitting intr urb, error %d",
+ __func__, retval);
+ }
+
+ spin_unlock_irqrestore(&card->slock, flags);
+ wake_up_interruptible(card->chan->CPCWait_q);
+
+ return;
+}
+
+#define UN_SHIFT 1
+#define CPCMSG_HEADER_LEN_FIRMWARE 11
+static inline int cpcusb_unalign_and_copy_buffy(unsigned char *out,
+ unsigned char *in)
+{
+ unsigned int i, j;
+
+ for (i = 0; i < 3; i++)
+ out[i] = in[i];
+
+ for (j = 0; j < (in[1] + (CPCMSG_HEADER_LEN_FIRMWARE - 3)); j++)
+ out[j + i + UN_SHIFT] = in[j + i];
+
+ return i + j;
+}
+
+/*
+ * callback for bulk IN urb
+ */
+static void cpcusb_read_bulk_callback(struct urb *urb)
+{
+ CPC_USB_T *card = (CPC_USB_T *) urb->context;
+ CPC_CHAN_T *chan;
+ unsigned char *ibuf = urb->transfer_buffer;
+ int retval, msgCnt, start, again = 0;
+ unsigned long flags;
+
+ if (!card) {
+ err("%s - device object lost", __func__);
+ return;
+ }
+
+ spin_lock_irqsave(&card->slock, flags);
+
+ if (!card->present) {
+ spin_unlock_irqrestore(&card->slock, flags);
+ info("%s - no such device", __func__);
+ return;
+ }
+
+ switch (urb->status) {
+ case 0: /* success */
+ break;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ /* urb was killed */
+ spin_unlock_irqrestore(&card->slock, flags);
+ dbg("%s - read urb killed", __func__);
+ return;
+ default:
+ info("%s - nonzero urb status %d", __func__, urb->status);
+ break;
+ }
+
+ if (urb->actual_length) {
+ msgCnt = ibuf[0] & ~0x80;
+ again = ibuf[0] & 0x80;
+
+ /* we have a 4 byte header */
+ start = 4;
+ chan = card->chan;
+ while (msgCnt) {
+ if (!(IsBufferFull(card->chan))) {
+ start +=
+ cpcusb_unalign_and_copy_buffy((unsigned char *)
+ &chan->buf[chan->iidx], &ibuf[start]);
+
+ if (start > urb->transfer_buffer_length) {
+ err("%d > %d", start, urb->transfer_buffer_length);
+ break;
+ }
+
+ chan->WnR = 0;
+ chan->iidx = (chan->iidx + 1) % CPC_MSG_BUF_CNT;
+ msgCnt--;
+ } else {
+ break;
+ }
+ }
+ }
+
+ usb_fill_bulk_urb(urb, card->udev,
+ usb_rcvbulkpipe(card->udev, card->num_bulk_in),
+ urb->transfer_buffer,
+ urb->transfer_buffer_length,
+ cpcusb_read_bulk_callback, card);
+
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+
+ if (retval) {
+ err("%s - failed resubmitting read urb, error %d", __func__, retval);
+ }
+
+ spin_unlock_irqrestore(&card->slock, flags);
+
+ wake_up_interruptible(card->chan->CPCWait_q);
+}
+
+/*
+ * callback for bulk IN urb
+ */
+static void cpcusb_write_bulk_callback(struct urb *urb)
+{
+ CPC_USB_T *card = (CPC_USB_T *) urb->context;
+ unsigned long flags;
+ int j;
+
+ spin_lock_irqsave(&card->slock, flags);
+
+ /* find this urb */
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ if (card->wrUrbs[j].urb == urb) {
+ dbg("URB found no. %d", j);
+ /* notify anyone waiting that the write has finished */
+ complete(&card->wrUrbs[j].finished);
+ atomic_set(&card->wrUrbs[j].busy, 0);
+ break;
+ }
+ }
+
+ switch (urb->status) {
+ case 0: /* success */
+ break;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ /* urb was killed */
+ spin_unlock_irqrestore(&card->slock, flags);
+ dbg("%s - write urb no. %d killed", __func__, j);
+ return;
+ default:
+ info("%s - nonzero urb status %d", __func__, urb->status);
+ break;
+ }
+
+ spin_unlock_irqrestore(&card->slock, flags);
+
+ wake_up_interruptible(card->chan->CPCWait_q);
+}
+
+static inline int cpcusb_get_free_slot(void)
+{
+ int i;
+
+ for (i = 0; i < CPC_USB_CARD_CNT; i++) {
+ if (!CPCUSB_Table[i])
+ return i;
+ }
+
+ return -1;
+}
+
+/*
+ * probe function for new CPC-USB devices
+ */
+static int cpcusb_probe(struct usb_interface *interface,
+ const struct usb_device_id *id)
+{
+ CPC_USB_T *card = NULL;
+ CPC_CHAN_T *chan = NULL;
+
+ struct usb_device *udev = interface_to_usbdev(interface);
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *endpoint;
+
+ int i, j, retval = -ENOMEM, slot;
+
+ slot = cpcusb_get_free_slot();
+ if (slot < 0) {
+ info("No more devices supported");
+ return -ENOMEM;
+ }
+
+ /* allocate memory for our device state and initialize it */
+ card = kzalloc(sizeof(CPC_USB_T), GFP_KERNEL);
+ if (!card) {
+ err("Out of memory");
+ return -ENOMEM;
+ }
+ CPCUSB_Table[slot] = card;
+
+ /* allocate and initialize the channel struct */
+ card->chan = kmalloc(sizeof(CPC_CHAN_T), GFP_KERNEL);
+ if (!card) {
+ kfree(card);
+ err("Out of memory");
+ return -ENOMEM;
+ }
+
+ chan = card->chan;
+ memset(chan, 0, sizeof(CPC_CHAN_T));
+ ResetBuffer(chan);
+
+ init_MUTEX(&card->sem);
+ spin_lock_init(&card->slock);
+
+ card->udev = udev;
+ card->interface = interface;
+ if (udev->descriptor.iSerialNumber) {
+ usb_string(udev, udev->descriptor.iSerialNumber, card->serialNumber,
+ 128);
+ info("Serial %s", card->serialNumber);
+ }
+
+ card->productId = udev->descriptor.idProduct;
+ info("Product %s",
+ card->productId == USB_CPCUSB_LPC2119_PRODUCT_ID ?
+ "CPC-USB/ARM7" : "CPC-USB/M16C");
+
+ /* set up the endpoint information */
+ /* check out the endpoints */
+ /* use only the first bulk-in and bulk-out endpoints */
+ iface_desc = &interface->altsetting[0];
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
+ endpoint = &iface_desc->endpoint[i].desc;
+
+ if (!card->num_intr_in &&
+ (endpoint->bEndpointAddress & USB_DIR_IN) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
+ == USB_ENDPOINT_XFER_INT)) {
+ card->intr_in_urb = usb_alloc_urb(0, GFP_KERNEL);
+ card->num_intr_in = 1;
+
+ if (!card->intr_in_urb) {
+ err("No free urbs available");
+ goto error;
+ }
+
+ dbg("intr_in urb %d", card->num_intr_in);
+ }
+
+ if (!card->num_bulk_in &&
+ (endpoint->bEndpointAddress & USB_DIR_IN) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
+ == USB_ENDPOINT_XFER_BULK)) {
+ card->num_bulk_in = 2;
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ card->urbs[j].size = endpoint->wMaxPacketSize;
+ card->urbs[j].urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!card->urbs[j].urb) {
+ err("No free urbs available");
+ goto error;
+ }
+ card->urbs[j].buffer =
+ usb_buffer_alloc(udev,
+ card->urbs[j].size,
+ GFP_KERNEL,
+ &card->urbs[j].urb->transfer_dma);
+ if (!card->urbs[j].buffer) {
+ err("Couldn't allocate bulk_in_buffer");
+ goto error;
+ }
+ }
+ info("%s - %d reading URB's allocated",
+ __func__, CPC_USB_URB_CNT);
+ }
+
+ if (!card->num_bulk_out &&
+ !(endpoint->bEndpointAddress & USB_DIR_IN) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
+ == USB_ENDPOINT_XFER_BULK)) {
+
+ card->num_bulk_out = 2;
+
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ card->wrUrbs[j].size =
+ endpoint->wMaxPacketSize;
+ card->wrUrbs[j].urb =
+ usb_alloc_urb(0, GFP_KERNEL);
+ if (!card->wrUrbs[j].urb) {
+ err("No free urbs available");
+ goto error;
+ }
+ card->wrUrbs[j].buffer = usb_buffer_alloc(udev,
+ card->wrUrbs[j].size, GFP_KERNEL,
+ &card->wrUrbs[j].urb->transfer_dma);
+
+ if (!card->wrUrbs[j].buffer) {
+ err("Couldn't allocate bulk_out_buffer");
+ goto error;
+ }
+
+ usb_fill_bulk_urb(card->wrUrbs[j].urb, udev,
+ usb_sndbulkpipe(udev, endpoint->bEndpointAddress),
+ card->wrUrbs[j].buffer,
+ card->wrUrbs[j].size,
+ cpcusb_write_bulk_callback,
+ card);
+ }
+
+ info("%s - %d writing URB's allocated", __func__, CPC_USB_URB_CNT);
+ }
+ }
+
+ if (!(card->num_bulk_in && card->num_bulk_out)) {
+ err("Couldn't find both bulk-in and bulk-out endpoints");
+ goto error;
+ }
+
+ /* allow device read, write and ioctl */
+ card->present = 1;
+
+ /* we can register the device now, as it is ready */
+ usb_set_intfdata(interface, card);
+ retval = usb_register_dev(interface, &cpcusb_class);
+
+ if (retval) {
+ /* something prevented us from registering this driver */
+ err("Not able to get a minor for this device.");
+ usb_set_intfdata(interface, NULL);
+ goto error;
+ }
+
+ card->chan->minor = card->minor = interface->minor;
+
+ chan->buf = vmalloc(sizeof(CPC_MSG_T) * CPC_MSG_BUF_CNT);
+ if (chan->buf == NULL) {
+ err("Out of memory");
+ retval = -ENOMEM;
+ goto error;
+ }
+ info("Allocated memory for %d messages (%d kbytes)",
+ CPC_MSG_BUF_CNT, (sizeof(CPC_MSG_T) * CPC_MSG_BUF_CNT) / 1000);
+ memset(chan->buf, 0, sizeof(CPC_MSG_T) * CPC_MSG_BUF_CNT);
+
+ ResetBuffer(chan);
+
+ card->chan->CPCWait_q = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
+ if (!card->chan->CPCWait_q) {
+ err("Out of memory");
+ retval = -ENOMEM;
+ goto error;
+ }
+ init_waitqueue_head(card->chan->CPCWait_q);
+
+ CPCUSB_Table[slot] = card;
+ card->idx = slot;
+ CPCUsbCnt++;
+
+ /* let the user know what node this device is now attached to */
+ info("Device now attached to USB-%d", card->minor);
+ return 0;
+
+error:
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ if (card->urbs[j].buffer) {
+ usb_buffer_free(card->udev, card->urbs[j].size,
+ card->urbs[j].buffer,
+ card->urbs[j].urb->transfer_dma);
+ card->urbs[j].buffer = NULL;
+ }
+ if (card->urbs[j].urb) {
+ usb_free_urb(card->urbs[j].urb);
+ card->urbs[j].urb = NULL;
+ }
+ }
+
+ cpcusb_delete(card);
+ return retval;
+}
+
+/*
+ * called by the usb core when the device is removed from the system
+ */
+static void cpcusb_disconnect(struct usb_interface *interface)
+{
+ CPC_USB_T *card = NULL;
+ int minor, j;
+
+ /* prevent races with open() */
+ down(&disconnect_sem);
+
+ card = usb_get_intfdata(interface);
+ usb_set_intfdata(interface, NULL);
+
+ down(&card->sem);
+
+ /* prevent device read, write and ioctl */
+ card->present = 0;
+
+ minor = card->minor;
+
+ /* free all urbs and their buffers */
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ /* terminate an ongoing write */
+ if (atomic_read(&card->wrUrbs[j].busy)) {
+ usb_kill_urb(card->wrUrbs[j].urb);
+ wait_for_completion(&card->wrUrbs[j].finished);
+ }
+ usb_buffer_free(card->udev, card->wrUrbs[j].size,
+ card->wrUrbs[j].buffer,
+ card->wrUrbs[j].urb->transfer_dma);
+ usb_free_urb(card->wrUrbs[j].urb);
+ }
+ info("%d write URBs freed", CPC_USB_URB_CNT);
+
+ /* free all urbs and their buffers */
+ for (j = 0; j < CPC_USB_URB_CNT; j++) {
+ usb_buffer_free(card->udev, card->urbs[j].size,
+ card->urbs[j].buffer,
+ card->urbs[j].urb->transfer_dma);
+ usb_free_urb(card->urbs[j].urb);
+ }
+ info("%d read URBs freed", CPC_USB_URB_CNT);
+ usb_free_urb(card->intr_in_urb);
+
+ /* give back our minor */
+ usb_deregister_dev(interface, &cpcusb_class);
+
+ up(&card->sem);
+
+ /* if the device is opened, cpcusb_release will clean this up */
+ if (!card->open)
+ cpcusb_delete(card);
+ else
+ wake_up_interruptible(card->chan->CPCWait_q);
+
+ up(&disconnect_sem);
+
+ CPCUsbCnt--;
+ info("USB-%d now disconnected", minor);
+}
+
+static int __init CPCUsb_Init(void)
+{
+ int result, i;
+
+ info(DRIVER_DESC " v" DRIVER_VERSION);
+ info("Build on " __DATE__ " at " __TIME__);
+
+ for (i = 0; i < CPC_USB_CARD_CNT; i++)
+ CPCUSB_Table[i] = 0;
+
+ /* register this driver with the USB subsystem */
+ result = usb_register(&cpcusb_driver);
+ if (result) {
+ err("usb_register failed. Error number %d", result);
+ return result;
+ }
+
+ procDir = proc_mkdir(CPC_USB_PROC_DIR, NULL);
+ if (!procDir) {
+ err("Could not create proc entry");
+ } else {
+ procEntry = create_proc_read_entry("info", 0444, procDir,
+ cpcusb_proc_read_info,
+ NULL);
+ if (!procEntry) {
+ err("Could not create proc entry %s", CPC_USB_PROC_DIR "/info");
+ remove_proc_entry(CPC_USB_PROC_DIR, NULL);
+ procDir = NULL;
+ }
+ }
+
+ return 0;
+}
+
+static void __exit CPCUsb_Exit(void)
+{
+ wait_event(rmmodWq, !atomic_read(&useCount));
+
+ /* deregister this driver with the USB subsystem */
+ usb_deregister(&cpcusb_driver);
+
+ if (procDir) {
+ if (procEntry)
+ remove_proc_entry("info", procDir);
+ remove_proc_entry(CPC_USB_PROC_DIR, NULL);
+ }
+}
+
+module_init(CPCUsb_Init);
+module_exit(CPCUsb_Exit);
diff --git a/drivers/staging/cpc-usb/cpc.h b/drivers/staging/cpc-usb/cpc.h
new file mode 100644
index 000000000000..ed8cb34d4763
--- /dev/null
+++ b/drivers/staging/cpc-usb/cpc.h
@@ -0,0 +1,440 @@
+/*
+ * CPC CAN Interface Definitions
+ *
+ * Copyright (C) 2000-2008 EMS Dr. Thomas Wuensche
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+#ifndef CPC_HEADER
+#define CPC_HEADER
+
+// the maximum length of the union members within a CPC_MSG
+// this value can be defined by the customer, but has to be
+// >= 64 bytes
+// however, if not defined before, we set a length of 64 byte
+#if !defined(CPC_MSG_LEN) || (CPC_MSG_LEN < 64)
+#undef CPC_MSG_LEN
+#define CPC_MSG_LEN 64
+#endif
+
+// check the operating system used
+#ifdef _WIN32 // running a Windows OS
+
+// define basic types on Windows platforms
+#ifdef _MSC_VER // Visual Studio
+ typedef unsigned __int8 u8;
+ typedef unsigned __int16 u16;
+ typedef unsigned __int32 u32;
+#else // Borland Compiler
+ typedef unsigned char u8;
+ typedef unsigned short u16;
+ typedef unsigned int u32;
+#endif
+ // on Windows OS we use a byte alignment of 1
+ #pragma pack(push, 1)
+
+ // set the calling conventions for the library function calls
+ #define CALL_CONV __stdcall
+#else
+ // Kernel headers already define this types
+ #ifndef __KERNEL__
+ // define basic types
+ typedef unsigned char u8;
+ typedef unsigned short u16;
+ typedef unsigned int u32;
+ #endif
+
+ // Linux does not use this calling convention
+ #define CALL_CONV
+#endif
+
+// Transmission of events from CPC interfaces to PC can be individually
+// controlled per event type. Default state is: don't transmit
+// Control values are constructed by bit-or of Subject and Action
+// and passed to CPC_Control()
+
+// Control-Values for CPC_Control() Command Subject Selection
+#define CONTR_CAN_Message 0x04
+#define CONTR_Busload 0x08
+#define CONTR_CAN_State 0x0C
+#define CONTR_SendAck 0x10
+#define CONTR_Filter 0x14
+#define CONTR_CmdQueue 0x18 // reserved, do not use
+#define CONTR_BusError 0x1C
+
+// Control Command Actions
+#define CONTR_CONT_OFF 0
+#define CONTR_CONT_ON 1
+#define CONTR_SING_ON 2
+// CONTR_SING_ON doesn't change CONTR_CONT_ON state, so it should be
+// read as: transmit at least once
+
+// defines for confirmed request
+#define DO_NOT_CONFIRM 0
+#define DO_CONFIRM 1
+
+// event flags
+#define EVENT_READ 0x01
+#define EVENT_WRITE 0x02
+
+// Messages from CPC to PC contain a message object type field.
+// The following message types are sent by CPC and can be used in
+// handlers, others should be ignored.
+#define CPC_MSG_T_RESYNC 0 // Normally to be ignored
+#define CPC_MSG_T_CAN 1 // CAN data frame
+#define CPC_MSG_T_BUSLOAD 2 // Busload message
+#define CPC_MSG_T_STRING 3 // Normally to be ignored
+#define CPC_MSG_T_CONTI 4 // Normally to be ignored
+#define CPC_MSG_T_MEM 7 // Normally not to be handled
+#define CPC_MSG_T_RTR 8 // CAN remote frame
+#define CPC_MSG_T_TXACK 9 // Send acknowledge
+#define CPC_MSG_T_POWERUP 10 // Power-up message
+#define CPC_MSG_T_CMD_NO 11 // Normally to be ignored
+#define CPC_MSG_T_CAN_PRMS 12 // Actual CAN parameters
+#define CPC_MSG_T_ABORTED 13 // Command aborted message
+#define CPC_MSG_T_CANSTATE 14 // CAN state message
+#define CPC_MSG_T_RESET 15 // used to reset CAN-Controller
+#define CPC_MSG_T_XCAN 16 // XCAN data frame
+#define CPC_MSG_T_XRTR 17 // XCAN remote frame
+#define CPC_MSG_T_INFO 18 // information strings
+#define CPC_MSG_T_CONTROL 19 // used for control of interface/driver behaviour
+#define CPC_MSG_T_CONFIRM 20 // response type for confirmed requests
+#define CPC_MSG_T_OVERRUN 21 // response type for overrun conditions
+#define CPC_MSG_T_KEEPALIVE 22 // response type for keep alive conditions
+#define CPC_MSG_T_CANERROR 23 // response type for bus error conditions
+#define CPC_MSG_T_DISCONNECTED 24 // response type for a disconnected interface
+#define CPC_MSG_T_ERR_COUNTER 25 // RX/TX error counter of CAN controller
+
+#define CPC_MSG_T_FIRMWARE 100 // response type for USB firmware download
+
+// Messages from the PC to the CPC interface contain a command field
+// Most of the command types are wrapped by the library functions and have therefore
+// normally not to be used.
+// However, programmers who wish to circumvent the library and talk directly
+// to the drivers (mainly Linux programmers) can use the following
+// command types:
+
+#define CPC_CMD_T_CAN 1 // CAN data frame
+#define CPC_CMD_T_CONTROL 3 // used for control of interface/driver behaviour
+#define CPC_CMD_T_CAN_PRMS 6 // set CAN parameters
+#define CPC_CMD_T_CLEARBUF 8 // clears input queue; this is depricated, use CPC_CMD_T_CLEAR_MSG_QUEUE instead
+#define CPC_CMD_T_INQ_CAN_PARMS 11 // inquire actual CAN parameters
+#define CPC_CMD_T_FILTER_PRMS 12 // set filter parameter
+#define CPC_CMD_T_RTR 13 // CAN remote frame
+#define CPC_CMD_T_CANSTATE 14 // CAN state message
+#define CPC_CMD_T_XCAN 15 // XCAN data frame
+#define CPC_CMD_T_XRTR 16 // XCAN remote frame
+#define CPC_CMD_T_RESET 17 // used to reset CAN-Controller
+#define CPC_CMD_T_INQ_INFO 18 // miscellanous information strings
+#define CPC_CMD_T_OPEN_CHAN 19 // open a channel
+#define CPC_CMD_T_CLOSE_CHAN 20 // close a channel
+#define CPC_CMD_T_CNTBUF 21 // this is depricated, use CPC_CMD_T_INQ_MSG_QUEUE_CNT instead
+#define CPC_CMD_T_CAN_EXIT 200 // exit the CAN (disable interrupts; reset bootrate; reset output_cntr; mode = 1)
+
+#define CPC_CMD_T_INQ_MSG_QUEUE_CNT CPC_CMD_T_CNTBUF // inquires the count of elements in the message queue
+#define CPC_CMD_T_INQ_ERR_COUNTER 25 // request the CAN controllers error counter
+#define CPC_CMD_T_CLEAR_MSG_QUEUE CPC_CMD_T_CLEARBUF // clear CPC_MSG queue
+#define CPC_CMD_T_CLEAR_CMD_QUEUE 28 // clear CPC_CMD queue
+#define CPC_CMD_T_FIRMWARE 100 // reserved, must not be used
+#define CPC_CMD_T_USB_RESET 101 // reserved, must not be used
+#define CPC_CMD_T_WAIT_NOTIFY 102 // reserved, must not be used
+#define CPC_CMD_T_WAIT_SETUP 103 // reserved, must not be used
+#define CPC_CMD_T_ABORT 255 // Normally not to be used
+
+// definitions for CPC_MSG_T_INFO
+// information sources
+#define CPC_INFOMSG_T_UNKNOWN_SOURCE 0
+#define CPC_INFOMSG_T_INTERFACE 1
+#define CPC_INFOMSG_T_DRIVER 2
+#define CPC_INFOMSG_T_LIBRARY 3
+
+// information types
+#define CPC_INFOMSG_T_UNKNOWN_TYPE 0
+#define CPC_INFOMSG_T_VERSION 1
+#define CPC_INFOMSG_T_SERIAL 2
+
+// definitions for controller types
+#define PCA82C200 1 // Philips basic CAN controller, replaced by SJA1000
+#define SJA1000 2 // Philips basic CAN controller
+#define AN82527 3 // Intel full CAN controller
+#define M16C_BASIC 4 // M16C controller running in basic CAN (not full CAN) mode
+
+// channel open error codes
+#define CPC_ERR_NO_FREE_CHANNEL -1 // no more free space within the channel array
+#define CPC_ERR_CHANNEL_ALREADY_OPEN -2 // the channel is already open
+#define CPC_ERR_CHANNEL_NOT_ACTIVE -3 // access to a channel not active failed
+#define CPC_ERR_NO_DRIVER_PRESENT -4 // no driver at the location searched by the library
+#define CPC_ERR_NO_INIFILE_PRESENT -5 // the library could not find the inifile
+#define CPC_ERR_WRONG_PARAMETERS -6 // wrong parameters in the inifile
+#define CPC_ERR_NO_INTERFACE_PRESENT -7 // 1. The specified interface is not connected
+ // 2. The interface (mostly CPC-USB) was disconnected upon operation
+#define CPC_ERR_NO_MATCHING_CHANNEL -8 // the driver couldn't find a matching channel
+#define CPC_ERR_NO_BUFFER_AVAILABLE -9 // the driver couldn't allocate buffer for messages
+#define CPC_ERR_NO_INTERRUPT -10 // the requested interrupt couldn't be claimed
+#define CPC_ERR_NO_MATCHING_INTERFACE -11 // no interface type related to this channel was found
+#define CPC_ERR_NO_RESOURCES -12 // the requested resources could not be claimed
+#define CPC_ERR_SOCKET -13 // error concerning TCP sockets
+
+// init error codes
+#define CPC_ERR_WRONG_CONTROLLER_TYPE -14 // wrong CAN controller type within initialization
+#define CPC_ERR_NO_RESET_MODE -15 // the controller could not be set into reset mode
+#define CPC_ERR_NO_CAN_ACCESS -16 // the CAN controller could not be accessed
+
+// transmit error codes
+#define CPC_ERR_CAN_WRONG_ID -20 // the provided CAN id is too big
+#define CPC_ERR_CAN_WRONG_LENGTH -21 // the provided CAN length is too long
+#define CPC_ERR_CAN_NO_TRANSMIT_BUF -22 // the transmit buffer was occupied
+#define CPC_ERR_CAN_TRANSMIT_TIMEOUT -23 // The message could not be sent within a
+ // specified time
+
+// other error codes
+#define CPC_ERR_SERVICE_NOT_SUPPORTED -30 // the requested service is not supported by the interface
+#define CPC_ERR_IO_TRANSFER -31 // a transmission error down to the driver occurred
+#define CPC_ERR_TRANSMISSION_FAILED -32 // a transmission error down to the interface occurred
+#define CPC_ERR_TRANSMISSION_TIMEOUT -33 // a timeout occurred within transmission to the interface
+#define CPC_ERR_OP_SYS_NOT_SUPPORTED -35 // the operating system is not supported
+#define CPC_ERR_UNKNOWN -40 // an unknown error ocurred (mostly IOCTL errors)
+
+#define CPC_ERR_LOADING_DLL -50 // the library 'cpcwin.dll' could not be loaded
+#define CPC_ERR_ASSIGNING_FUNCTION -51 // the specified function could not be assigned
+#define CPC_ERR_DLL_INITIALIZATION -52 // the DLL was not initialized correctly
+#define CPC_ERR_MISSING_LICFILE -55 // the file containing the licenses does not exist
+#define CPC_ERR_MISSING_LICENSE -56 // a required license was not found
+
+// CAN state bit values. Ignore any bits not listed
+#define CPC_CAN_STATE_BUSOFF 0x80
+#define CPC_CAN_STATE_ERROR 0x40
+
+// Mask to help ignore undefined bits
+#define CPC_CAN_STATE_MASK 0xc0
+
+// CAN-Message representation in a CPC_MSG
+// Message object type is CPC_MSG_T_CAN or CPC_MSG_T_RTR
+// or CPC_MSG_T_XCAN or CPC_MSG_T_XRTR
+typedef struct CPC_CAN_MSG {
+ u32 id;
+ u8 length;
+ u8 msg[8];
+} CPC_CAN_MSG_T;
+
+
+// representation of the CAN parameters for the PCA82C200 controller
+typedef struct CPC_PCA82C200_PARAMS {
+ u8 acc_code; // Acceptance-code for receive, Standard: 0
+ u8 acc_mask; // Acceptance-mask for receive, Standard: 0xff (everything)
+ u8 btr0; // Bus-timing register 0
+ u8 btr1; // Bus-timing register 1
+ u8 outp_contr; // Output-control register
+} CPC_PCA82C200_PARAMS_T;
+
+// representation of the CAN parameters for the SJA1000 controller
+typedef struct CPC_SJA1000_PARAMS {
+ u8 mode; // enables single or dual acceptance filtering
+ u8 acc_code0; // Acceptance-code for receive, Standard: 0
+ u8 acc_code1;
+ u8 acc_code2;
+ u8 acc_code3;
+ u8 acc_mask0; // Acceptance-mask for receive, Standard: 0xff (everything)
+ u8 acc_mask1;
+ u8 acc_mask2;
+ u8 acc_mask3;
+ u8 btr0; // Bus-timing register 0
+ u8 btr1; // Bus-timing register 1
+ u8 outp_contr; // Output-control register
+} CPC_SJA1000_PARAMS_T;
+
+// representation of the CAN parameters for the M16C controller
+// in basic CAN mode (means no full CAN)
+typedef struct CPC_M16C_BASIC_PARAMS {
+ u8 con0;
+ u8 con1;
+ u8 ctlr0;
+ u8 ctlr1;
+ u8 clk;
+ u8 acc_std_code0;
+ u8 acc_std_code1;
+ u8 acc_ext_code0;
+ u8 acc_ext_code1;
+ u8 acc_ext_code2;
+ u8 acc_ext_code3;
+ u8 acc_std_mask0;
+ u8 acc_std_mask1;
+ u8 acc_ext_mask0;
+ u8 acc_ext_mask1;
+ u8 acc_ext_mask2;
+ u8 acc_ext_mask3;
+} CPC_M16C_BASIC_PARAMS_T;
+
+// CAN params message representation
+typedef struct CPC_CAN_PARAMS {
+ u8 cc_type; // represents the controller type
+ union {
+ CPC_M16C_BASIC_PARAMS_T m16c_basic;
+ CPC_SJA1000_PARAMS_T sja1000;
+ CPC_PCA82C200_PARAMS_T pca82c200;
+ } cc_params;
+} CPC_CAN_PARAMS_T;
+
+// the following structures are slightly different for Windows and Linux
+// To be able to use the 'Select' mechanism with Linux the application
+// needs to know the devices file desciptor.
+// This mechanism is not implemented within Windows and the file descriptor
+// is therefore not needed
+#ifdef _WIN32
+
+// CAN init params message representation
+typedef struct CPC_INIT_PARAMS {
+ CPC_CAN_PARAMS_T canparams;
+} CPC_INIT_PARAMS_T;
+
+#else// Linux
+
+// CHAN init params representation
+typedef struct CPC_CHAN_PARAMS {
+ int fd;
+} CPC_CHAN_PARAMS_T;
+
+// CAN init params message representation
+typedef struct CPC_INIT_PARAMS {
+ CPC_CHAN_PARAMS_T chanparams;
+ CPC_CAN_PARAMS_T canparams;
+} CPC_INIT_PARAMS_T;
+
+#endif
+
+// structure for confirmed message handling
+typedef struct CPC_CONFIRM {
+ u8 result; // error code
+} CPC_CONFIRM_T;
+
+// structure for information requests
+typedef struct CPC_INFO {
+ u8 source; // interface, driver or library
+ u8 type; // version or serial number
+ char msg[CPC_MSG_LEN - 2]; // string holding the requested information
+} CPC_INFO_T;
+
+// OVERRUN ///////////////////////////////////////
+// In general two types of overrun may occur.
+// A hardware overrun, where the CAN controller
+// lost a message, because the interrupt was
+// not handled before the next messgae comes in.
+// Or a software overrun, where i.e. a received
+// message could not be stored in the CPC_MSG
+// buffer.
+
+// After a software overrun has occurred
+// we wait until we have CPC_OVR_GAP slots
+// free in the CPC_MSG buffer.
+#define CPC_OVR_GAP 10
+
+// Two types of software overrun may occur.
+// A received CAN message or a CAN state event
+// can cause an overrun.
+// Note: A CPC_CMD which would normally store
+// its result immediately in the CPC_MSG
+// queue may fail, because the message queue is full.
+// This will not generate an overrun message, but
+// will halt command execution, until this command
+// is able to store its message in the message queue.
+#define CPC_OVR_EVENT_CAN 0x01
+#define CPC_OVR_EVENT_CANSTATE 0x02
+#define CPC_OVR_EVENT_BUSERROR 0x04
+
+// If the CAN controller lost a message
+// we indicate it with the highest bit
+// set in the count field.
+#define CPC_OVR_HW 0x80
+
+// structure for overrun conditions
+typedef struct {
+ u8 event;
+ u8 count;
+} CPC_OVERRUN_T;
+
+// CAN errors ////////////////////////////////////
+// Each CAN controller type has different
+// registers to record errors.
+// Therefor a structure containing the specific
+// errors is set up for each controller here
+
+// SJA1000 error structure
+// see the SJA1000 datasheet for detailed
+// explanation of the registers
+typedef struct CPC_SJA1000_CAN_ERROR {
+ u8 ecc; // error capture code register
+ u8 rxerr; // RX error counter register
+ u8 txerr; // TX error counter register
+} CPC_SJA1000_CAN_ERROR_T;
+
+// M16C error structure
+// see the M16C datasheet for detailed
+// explanation of the registers
+typedef struct CPC_M16C_CAN_ERROR {
+ u8 tbd; // to be defined
+} CPC_M16C_CAN_ERROR_T;
+
+// structure for CAN error conditions
+#define CPC_CAN_ECODE_ERRFRAME 0x01
+typedef struct CPC_CAN_ERROR {
+ u8 ecode;
+ struct {
+ u8 cc_type; // CAN controller type
+ union {
+ CPC_SJA1000_CAN_ERROR_T sja1000;
+ CPC_M16C_CAN_ERROR_T m16c;
+ } regs;
+ } cc;
+} CPC_CAN_ERROR_T;
+
+// Structure containing RX/TX error counter.
+// This structure is used to request the
+// values of the CAN controllers TX and RX
+// error counter.
+typedef struct CPC_CAN_ERR_COUNTER {
+ u8 rx;
+ u8 tx;
+} CPC_CAN_ERR_COUNTER_T;
+
+// If this flag is set, transmissions from PC to CPC are protected against loss
+#define CPC_SECURE_TO_CPC 0x01
+
+// If this flag is set, transmissions from CPC to PC are protected against loss
+#define CPC_SECURE_TO_PC 0x02
+
+// If this flag is set, the CAN-transmit buffer is checked to be free before sending a message
+#define CPC_SECURE_SEND 0x04
+
+// If this flag is set, the transmission complete flag is checked
+// after sending a message
+// THIS IS CURRENTLY ONLY IMPLEMENTED IN THE PASSIVE INTERFACE DRIVERS
+#define CPC_SECURE_TRANSMIT 0x08
+
+// main message type used between library and application
+typedef struct CPC_MSG {
+ u8 type; // type of message
+ u8 length; // length of data within union 'msg'
+ u8 msgid; // confirmation handle
+ u32 ts_sec; // timestamp in seconds
+ u32 ts_nsec; // timestamp in nano seconds
+ union {
+ u8 generic[CPC_MSG_LEN];
+ CPC_CAN_MSG_T canmsg;
+ CPC_CAN_PARAMS_T canparams;
+ CPC_CONFIRM_T confirmation;
+ CPC_INFO_T info;
+ CPC_OVERRUN_T overrun;
+ CPC_CAN_ERROR_T error;
+ CPC_CAN_ERR_COUNTER_T err_counter;
+ u8 busload;
+ u8 canstate;
+ } msg;
+} CPC_MSG_T;
+
+#ifdef _WIN32
+#pragma pack(pop) // reset the byte alignment
+#endif
+
+#endif // CPC_HEADER
diff --git a/drivers/staging/cpc-usb/cpc_int.h b/drivers/staging/cpc-usb/cpc_int.h
new file mode 100644
index 000000000000..dfdbed1c1f96
--- /dev/null
+++ b/drivers/staging/cpc-usb/cpc_int.h
@@ -0,0 +1,85 @@
+/*
+ * CPCLIB
+ *
+ * Copyright (C) 2000-2008 EMS Dr. Thomas Wuensche
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef CPC_INT_H
+#define CPC_INT_H
+
+#include <linux/wait.h>
+
+#define CPC_MSG_BUF_CNT 1500
+
+#ifdef CONFIG_PROC_FS
+# define CPC_PROC_DIR "driver/"
+#endif
+
+#undef dbg
+#undef err
+#undef info
+
+/* Use our own dbg macro */
+#define dbg(format, arg...) do { if (debug) printk( KERN_INFO format "\n" , ## arg); } while (0)
+#define err(format, arg...) do { printk( KERN_INFO "ERROR " format "\n" , ## arg); } while (0)
+#define info(format, arg...) do { printk( KERN_INFO format "\n" , ## arg); } while (0)
+
+/* Macros help using of our buffers */
+#define IsBufferFull(x) (!(x)->WnR) && ((x)->iidx == (x)->oidx)
+#define IsBufferEmpty(x) ((x)->WnR) && ((x)->iidx == (x)->oidx)
+#define IsBufferNotEmpty(x) (!(x)->WnR) || ((x)->iidx != (x)->oidx)
+#define ResetBuffer(x) do { (x)->oidx = (x)->iidx=0; (x)->WnR = 1; } while(0);
+
+#define CPC_BufWriteAllowed ((chan->oidx != chan->iidx) || chan->WnR)
+
+typedef void (*chan_write_byte_t) (void *chan, unsigned int reg,
+ unsigned char val);
+typedef unsigned char (*chan_read_byte_t) (void *chan, unsigned int reg);
+
+typedef struct CPC_CHAN {
+ void __iomem * canBase; // base address of SJA1000
+ chan_read_byte_t read_byte; // CAN controller read access routine
+ chan_write_byte_t write_byte; // CAN controller write access routine
+ CPC_MSG_T *buf; // buffer for CPC msg
+ unsigned int iidx;
+ unsigned int oidx;
+ unsigned int WnR;
+ unsigned int minor;
+ unsigned int locked;
+ unsigned int irqDisabled;
+
+ unsigned char cpcCtrlCANMessage;
+ unsigned char cpcCtrlCANState;
+ unsigned char cpcCtrlBUSState;
+
+ unsigned char controllerType;
+
+ unsigned long ovrTimeSec;
+ unsigned long ovrTimeNSec;
+ unsigned long ovrLockedBuffer;
+ CPC_OVERRUN_T ovr;
+
+ /* for debugging only */
+ unsigned int handledIrqs;
+ unsigned int lostMessages;
+
+ unsigned int sentStdCan;
+ unsigned int sentExtCan;
+ unsigned int sentStdRtr;
+ unsigned int sentExtRtr;
+
+ unsigned int recvStdCan;
+ unsigned int recvExtCan;
+ unsigned int recvStdRtr;
+ unsigned int recvExtRtr;
+
+ wait_queue_head_t *CPCWait_q;
+
+ void *private;
+} CPC_CHAN_T;
+
+#endif
diff --git a/drivers/staging/cpc-usb/cpcusb.h b/drivers/staging/cpc-usb/cpcusb.h
new file mode 100644
index 000000000000..e5273ddd9e0a
--- /dev/null
+++ b/drivers/staging/cpc-usb/cpcusb.h
@@ -0,0 +1,86 @@
+/* Header for CPC-USB Driver ********************
+ * Copyright 1999, 2000, 2001
+ *
+ * Company: EMS Dr. Thomas Wuensche
+ * Sonnenhang 3
+ * 85304 Ilmmuenster
+ * Phone: +49-8441-490260
+ * Fax: +49-8441-81860
+ * email: support@ems-wuensche.com
+ * WWW: www.ems-wuensche.com
+ */
+
+#ifndef CPCUSB_H
+#define CPCUSB_H
+
+#undef err
+#undef dbg
+#undef info
+
+/* Use our own dbg macro */
+#define dbg(format, arg...) do { if (debug) printk(KERN_INFO "CPC-USB: " format "\n" , ## arg); } while (0)
+#define info(format, arg...) do { printk(KERN_INFO "CPC-USB: " format "\n" , ## arg); } while (0)
+#define err(format, arg...) do { printk(KERN_INFO "CPC-USB(ERROR): " format "\n" , ## arg); } while (0)
+
+#define CPC_USB_CARD_CNT 4
+
+typedef struct CPC_USB_READ_URB {
+ unsigned char *buffer; /* the buffer to send data */
+ size_t size; /* the size of the send buffer */
+ struct urb *urb; /* the urb used to send data */
+} CPC_USB_READ_URB_T;
+
+typedef struct CPC_USB_WRITE_URB {
+ unsigned char *buffer; /* the buffer to send data */
+ size_t size; /* the size of the send buffer */
+ struct urb *urb; /* the urb used to send data */
+ atomic_t busy; /* true if write urb is busy */
+ struct completion finished; /* wait for the write to finish */
+} CPC_USB_WRITE_URB_T;
+
+#define CPC_USB_URB_CNT 10
+
+typedef struct CPC_USB {
+ struct usb_device *udev; /* save off the usb device pointer */
+ struct usb_interface *interface; /* the interface for this device */
+ unsigned char minor; /* the starting minor number for this device */
+ unsigned char num_ports; /* the number of ports this device has */
+ int num_intr_in; /* number of interrupt in endpoints we have */
+ int num_bulk_in; /* number of bulk in endpoints we have */
+ int num_bulk_out; /* number of bulk out endpoints we have */
+
+ CPC_USB_READ_URB_T urbs[CPC_USB_URB_CNT];
+
+ unsigned char intr_in_buffer[4]; /* interrupt transfer buffer */
+ struct urb *intr_in_urb; /* interrupt transfer urb */
+
+ CPC_USB_WRITE_URB_T wrUrbs[CPC_USB_URB_CNT];
+
+ int open; /* if the port is open or not */
+ int present; /* if the device is not disconnected */
+ struct semaphore sem; /* locks this structure */
+
+ int free_slots; /* free send slots of CPC-USB */
+ int idx;
+
+ spinlock_t slock;
+
+ char serialNumber[128]; /* serial number */
+ int productId; /* product id to differ between M16C and LPC2119 */
+ CPC_CHAN_T *chan;
+} CPC_USB_T;
+
+#define CPCTable CPCUSB_Table
+
+#define CPC_DRIVER_VERSION "0.724"
+#define CPC_DRIVER_SERIAL "not applicable"
+
+#define OBUF_SIZE 255 // 4096
+
+/* read timeouts -- RD_NAK_TIMEOUT * RD_EXPIRE = Number of seconds */
+#define RD_NAK_TIMEOUT (10*HZ) /* Default number of X seconds to wait */
+#define RD_EXPIRE 12 /* Number of attempts to wait X seconds */
+
+#define CPC_USB_BASE_MNR 0 /* CPC-USB start at minor 0 */
+
+#endif
diff --git a/drivers/staging/cpc-usb/sja2m16c.h b/drivers/staging/cpc-usb/sja2m16c.h
new file mode 100644
index 000000000000..654bd3fc91dc
--- /dev/null
+++ b/drivers/staging/cpc-usb/sja2m16c.h
@@ -0,0 +1,41 @@
+#ifndef _SJA2M16C_H
+#define _SJA2M16C_H
+
+#include "cpc.h"
+
+#define BAUDRATE_TOLERANCE_PERCENT 1
+#define SAMPLEPOINT_TOLERANCE_PERCENT 5
+#define SAMPLEPOINT_UPPER_LIMIT 88
+
+/* M16C parameters */
+struct FIELD_C0CONR {
+ unsigned int brp:4;
+ unsigned int sam:1;
+ unsigned int pr:3;
+ unsigned int dummy:8;
+};
+struct FIELD_C1CONR {
+ unsigned int ph1:3;
+ unsigned int ph2:3;
+ unsigned int sjw:2;
+ unsigned int dummy:8;
+};
+typedef union C0CONR {
+ unsigned char c0con;
+ struct FIELD_C0CONR bc0con;
+} C0CONR_T;
+typedef union C1CONR {
+ unsigned char c1con;
+ struct FIELD_C1CONR bc1con;
+} C1CONR_T;
+
+#define SJA_TSEG1 ((pParams->btr1 & 0x0f)+1)
+#define SJA_TSEG2 (((pParams->btr1 & 0x70)>>4)+1)
+#define SJA_BRP ((pParams->btr0 & 0x3f)+1)
+#define SJA_SJW ((pParams->btr0 & 0xc0)>>6)
+#define SJA_SAM ((pParams->btr1 & 0x80)>>7)
+int baudrate_m16c(int clk, int brp, int pr, int ph1, int ph2);
+int samplepoint_m16c(int brp, int pr, int ph1, int ph2);
+int SJA1000_TO_M16C_BASIC_Params(CPC_MSG_T *pMsg);
+
+#endif
diff --git a/drivers/staging/cpc-usb/sja2m16c_2.c b/drivers/staging/cpc-usb/sja2m16c_2.c
new file mode 100644
index 000000000000..bf0230fb7780
--- /dev/null
+++ b/drivers/staging/cpc-usb/sja2m16c_2.c
@@ -0,0 +1,452 @@
+/****************************************************************************
+*
+* Copyright (c) 2003,2004 by EMS Dr. Thomas Wuensche
+*
+* - All rights reserved -
+*
+* This code is provided "as is" without warranty of any kind, either
+* expressed or implied, including but not limited to the liability
+* concerning the freedom from material defects, the fitness for parti-
+* cular purposes or the freedom of proprietary rights of third parties.
+*
+*****************************************************************************
+* Module name.: cpcusb
+*****************************************************************************
+* Include file: cpc.h
+*****************************************************************************
+* Project.....: Windows Driver Development Kit
+* Filename....: sja2m16c.cpp
+* Authors.....: (GU) Gerhard Uttenthaler
+* (CS) Christian Schoett
+*****************************************************************************
+* Short descr.: converts baudrate between SJA1000 and M16C
+*****************************************************************************
+* Description.: handles the baudrate conversion from SJA1000 parameters to
+* M16C parameters
+*****************************************************************************
+* Address : EMS Dr. Thomas Wuensche
+* Sonnenhang 3
+* D-85304 Ilmmuenster
+* Tel. : +49-8441-490260
+* Fax. : +49-8441-81860
+* email: support@ems-wuensche.com
+*****************************************************************************
+* History
+*****************************************************************************
+* Version Date Auth Remark
+*
+* 01.00 ?? GU - initial release
+* 01.10 ?????????? CS - adapted to fit into the USB Windows driver
+* 02.00 18.08.2004 GU - improved the baudrate calculating algorithm
+* - implemented acceptance filtering
+* 02.10 10.09.2004 CS - adapted to fit into the USB Windows driver
+*****************************************************************************
+* ToDo's
+*****************************************************************************
+*/
+
+/****************************************************************************/
+/* I N C L U D E S
+*/
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/module.h>
+#include <linux/poll.h>
+#include <linux/smp_lock.h>
+#include <linux/completion.h>
+#include <asm/uaccess.h>
+#include <linux/usb.h>
+
+#include "cpc.h"
+#include "cpc_int.h"
+#include "cpcusb.h"
+
+#include "sja2m16c.h"
+
+/*********************************************************************/
+int baudrate_m16c(int clk, int brp, int pr, int ph1, int ph2)
+{
+ return (16000000 / (1 << clk)) / 2 / (brp + 1) / (1 + pr + 1 +
+ ph1 + 1 + ph2 +
+ 1);
+}
+
+
+/*********************************************************************/
+int samplepoint_m16c(int brp, int pr, int ph1, int ph2)
+{
+ return (100 * (1 + pr + 1 + ph1 + 1)) / (1 + pr + 1 + ph1 + 1 +
+ ph2 + 1);
+}
+
+
+/****************************************************************************
+* Function.....: SJA1000_TO_M16C_BASIC_Params
+*
+* Task.........: This routine converts SJA1000 CAN btr parameters into M16C
+* parameters based on the sample point and the error. In
+* addition it converts the acceptance filter parameters to
+* suit the M16C parameters
+*
+* Parameters...: None
+*
+* Return values: None
+*
+* Comments.....:
+*****************************************************************************
+* History
+*****************************************************************************
+* 19.01.2005 CS - modifed the conversion of SJA1000 filter params into
+* M16C params. Due to compatibility reasons with the
+* older 82C200 CAN controller the SJA1000
+****************************************************************************/
+int SJA1000_TO_M16C_BASIC_Params(CPC_MSG_T * in)
+{
+ int sjaBaudrate;
+ int sjaSamplepoint;
+ int *baudrate_error; // BRP[0..15], PR[0..7], PH1[0..7], PH2[0..7]
+ int *samplepoint_error; // BRP[0..15], PR[0..7], PH1[0..7], PH2[0..7]
+ int baudrate_error_merk;
+ int clk, brp, pr, ph1, ph2;
+ int clk_merk, brp_merk, pr_merk, ph1_merk, ph2_merk;
+ int index;
+ unsigned char acc_code0, acc_code1, acc_code2, acc_code3;
+ unsigned char acc_mask0, acc_mask1, acc_mask2, acc_mask3;
+ CPC_MSG_T * out;
+ C0CONR_T c0con;
+ C1CONR_T c1con;
+ int tmpAccCode;
+ int tmpAccMask;
+
+ // we have to convert the parameters into M16C parameters
+ CPC_SJA1000_PARAMS_T * pParams;
+
+ // check if the type is CAN parameters and if we have to convert the given params
+ if (in->type != CPC_CMD_T_CAN_PRMS
+ || in->msg.canparams.cc_type != SJA1000)
+ return 0;
+ pParams =
+ (CPC_SJA1000_PARAMS_T *) & in->msg.canparams.cc_params.sja1000;
+ acc_code0 = pParams->acc_code0;
+ acc_code1 = pParams->acc_code1;
+ acc_code2 = pParams->acc_code2;
+ acc_code3 = pParams->acc_code3;
+ acc_mask0 = pParams->acc_mask0;
+ acc_mask1 = pParams->acc_mask1;
+ acc_mask2 = pParams->acc_mask2;
+ acc_mask3 = pParams->acc_mask3;
+
+#ifdef _DEBUG_OUTPUT_CAN_PARAMS
+ info("acc_code0: %2.2Xh\n", acc_code0);
+ info("acc_code1: %2.2Xh\n", acc_code1);
+ info("acc_code2: %2.2Xh\n", acc_code2);
+ info("acc_code3: %2.2Xh\n", acc_code3);
+ info("acc_mask0: %2.2Xh\n", acc_mask0);
+ info("acc_mask1: %2.2Xh\n", acc_mask1);
+ info("acc_mask2: %2.2Xh\n", acc_mask2);
+ info("acc_mask3: %2.2Xh\n", acc_mask3);
+
+#endif /* */
+ if (!
+ (baudrate_error =
+ (int *) vmalloc(sizeof(int) * 16 * 8 * 8 * 8 * 5))) {
+ err("Could not allocate memory\n");
+ return -3;
+ }
+ if (!
+ (samplepoint_error =
+ (int *) vmalloc(sizeof(int) * 16 * 8 * 8 * 8 * 5))) {
+ err("Could not allocate memory\n");
+ vfree(baudrate_error);
+ return -3;
+ }
+ memset(baudrate_error, 0xff, sizeof(baudrate_error));
+ memset(samplepoint_error, 0xff, sizeof(baudrate_error));
+ sjaBaudrate =
+ 16000000 / 2 / SJA_BRP / (1 + SJA_TSEG1 + SJA_TSEG2);
+ sjaSamplepoint =
+ 100 * (1 + SJA_TSEG1) / (1 + SJA_TSEG1 + SJA_TSEG2);
+ if (sjaBaudrate == 0) {
+ vfree(baudrate_error);
+ vfree(samplepoint_error);
+ return -2;
+ }
+
+#ifdef _DEBUG_OUTPUT_CAN_PARAMS
+ info("\nStarting SJA CAN params\n");
+ info("-------------------------\n");
+ info("TS1 : %2.2Xh TS2 : %2.2Xh\n", SJA_TSEG1, SJA_TSEG2);
+ info("BTR0 : %2.2Xh BTR1: %2.2Xh\n", pParams->btr0,
+ pParams->btr1);
+ info("Baudrate: %d.%dkBaud\n", sjaBaudrate / 1000,
+ sjaBaudrate % 1000);
+ info("Sample P: 0.%d\n", sjaSamplepoint);
+ info("\n");
+
+#endif /* */
+ c0con.bc0con.sam = SJA_SAM;
+ c1con.bc1con.sjw = SJA_SJW;
+
+ // calculate errors for all baudrates
+ index = 0;
+ for (clk = 0; clk < 5; clk++) {
+ for (brp = 0; brp < 16; brp++) {
+ for (pr = 0; pr < 8; pr++) {
+ for (ph1 = 0; ph1 < 8; ph1++) {
+ for (ph2 = 0; ph2 < 8; ph2++) {
+ baudrate_error[index] =
+ 100 *
+ abs(baudrate_m16c
+ (clk, brp, pr, ph1,
+ ph2) -
+ sjaBaudrate) /
+ sjaBaudrate;
+ samplepoint_error[index] =
+ abs(samplepoint_m16c
+ (brp, pr, ph1,
+ ph2) -
+ sjaSamplepoint);
+
+#if 0
+ info
+ ("Baudrate : %d kBaud\n",
+ baudrate_m16c(clk,
+ brp, pr,
+ ph1,
+ ph2));
+ info
+ ("Baudrate Error: %d\n",
+ baudrate_error
+ [index]);
+ info
+ ("Sample P Error: %d\n",
+ samplepoint_error
+ [index]);
+ info
+ ("clk : %d\n",
+ clk);
+
+#endif /* */
+ index++;
+ }
+ }
+ }
+ }
+ }
+
+ // mark all baudrate_error entries which are outer limits
+ index = 0;
+ for (clk = 0; clk < 5; clk++) {
+ for (brp = 0; brp < 16; brp++) {
+ for (pr = 0; pr < 8; pr++) {
+ for (ph1 = 0; ph1 < 8; ph1++) {
+ for (ph2 = 0; ph2 < 8; ph2++) {
+ if ((baudrate_error[index]
+ >
+ BAUDRATE_TOLERANCE_PERCENT)
+ ||
+ (samplepoint_error
+ [index] >
+ SAMPLEPOINT_TOLERANCE_PERCENT)
+ ||
+ (samplepoint_m16c
+ (brp, pr, ph1,
+ ph2) >
+ SAMPLEPOINT_UPPER_LIMIT))
+ {
+ baudrate_error
+ [index] = -1;
+ } else
+ if (((1 + pr + 1 +
+ ph1 + 1 + ph2 +
+ 1) < 8)
+ ||
+ ((1 + pr + 1 +
+ ph1 + 1 + ph2 +
+ 1) > 25)) {
+ baudrate_error
+ [index] = -1;
+ }
+
+#if 0
+ else {
+ info
+ ("Baudrate : %d kBaud\n",
+ baudrate_m16c
+ (clk, brp, pr,
+ ph1, ph2));
+ info
+ ("Baudrate Error: %d\n",
+ baudrate_error
+ [index]);
+ info
+ ("Sample P Error: %d\n",
+ samplepoint_error
+ [index]);
+ }
+
+#endif /* */
+ index++;
+ }
+ }
+ }
+ }
+ }
+
+ // find list of minimum of baudrate_error within unmarked entries
+ clk_merk = brp_merk = pr_merk = ph1_merk = ph2_merk = 0;
+ baudrate_error_merk = 100;
+ index = 0;
+ for (clk = 0; clk < 5; clk++) {
+ for (brp = 0; brp < 16; brp++) {
+ for (pr = 0; pr < 8; pr++) {
+ for (ph1 = 0; ph1 < 8; ph1++) {
+ for (ph2 = 0; ph2 < 8; ph2++) {
+ if (baudrate_error[index]
+ != -1) {
+ if (baudrate_error
+ [index] <
+ baudrate_error_merk)
+ {
+ baudrate_error_merk
+ =
+ baudrate_error
+ [index];
+ brp_merk =
+ brp;
+ pr_merk =
+ pr;
+ ph1_merk =
+ ph1;
+ ph2_merk =
+ ph2;
+ clk_merk =
+ clk;
+
+#if 0
+ info
+ ("brp: %2.2Xh pr: %2.2Xh ph1: %2.2Xh ph2: %2.2Xh\n",
+ brp,
+ pr,
+ ph1,
+ ph2);
+ info
+ ("Baudrate : %d kBaud\n",
+ baudrate_m16c
+ (clk,
+ brp,
+ pr,
+ ph1,
+ ph2));
+ info
+ ("Baudrate Error: %d\n",
+ baudrate_error
+ [index]);
+ info
+ ("Sample P Error: %d\n",
+ samplepoint_error
+ [index]);
+
+#endif /* */
+ }
+ }
+ index++;
+ }
+ }
+ }
+ }
+ }
+ if (baudrate_error_merk == 100) {
+ info("ERROR: Could not convert CAN init parameter\n");
+ vfree(baudrate_error);
+ vfree(samplepoint_error);
+ return -1;
+ }
+
+ // setting m16c CAN parameter
+ c0con.bc0con.brp = brp_merk;
+ c0con.bc0con.pr = pr_merk;
+ c1con.bc1con.ph1 = ph1_merk;
+ c1con.bc1con.ph2 = ph2_merk;
+
+#ifdef _DEBUG_OUTPUT_CAN_PARAMS
+ info("\nResulting M16C CAN params\n");
+ info("-------------------------\n");
+ info("clk : %2.2Xh\n", clk_merk);
+ info("ph1 : %2.2Xh ph2: %2.2Xh\n", c1con.bc1con.ph1 + 1,
+ c1con.bc1con.ph2 + 1);
+ info("pr : %2.2Xh brp: %2.2Xh\n", c0con.bc0con.pr + 1,
+ c0con.bc0con.brp + 1);
+ info("sjw : %2.2Xh sam: %2.2Xh\n", c1con.bc1con.sjw,
+ c0con.bc0con.sam);
+ info("co1 : %2.2Xh co0: %2.2Xh\n", c1con.c1con, c0con.c0con);
+ info("Baudrate: %d.%dBaud\n",
+ baudrate_m16c(clk_merk, c0con.bc0con.brp, c0con.bc0con.pr,
+ c1con.bc1con.ph1, c1con.bc1con.ph2) / 1000,
+ baudrate_m16c(clk_merk, c0con.bc0con.brp, c0con.bc0con.pr,
+ c1con.bc1con.ph1, c1con.bc1con.ph2) % 1000);
+ info("Sample P: 0.%d\n",
+ samplepoint_m16c(c0con.bc0con.brp, c0con.bc0con.pr,
+ c1con.bc1con.ph1, c1con.bc1con.ph2));
+ info("\n");
+
+#endif /* */
+ out = in;
+ out->type = 6;
+ out->length = sizeof(CPC_M16C_BASIC_PARAMS_T) + 1;
+ out->msg.canparams.cc_type = M16C_BASIC;
+ out->msg.canparams.cc_params.m16c_basic.con0 = c0con.c0con;
+ out->msg.canparams.cc_params.m16c_basic.con1 = c1con.c1con;
+ out->msg.canparams.cc_params.m16c_basic.ctlr0 = 0x4C;
+ out->msg.canparams.cc_params.m16c_basic.ctlr1 = 0x00;
+ out->msg.canparams.cc_params.m16c_basic.clk = clk_merk;
+ out->msg.canparams.cc_params.m16c_basic.acc_std_code0 =
+ acc_code0;
+ out->msg.canparams.cc_params.m16c_basic.acc_std_code1 = acc_code1;
+
+// info("code0: 0x%2.2X, code1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_code0, out->msg.canparams.cc_params.m16c_basic.acc_std_code1);
+ tmpAccCode = (acc_code1 >> 5) + (acc_code0 << 3);
+ out->msg.canparams.cc_params.m16c_basic.acc_std_code0 =
+ (unsigned char) tmpAccCode;
+ out->msg.canparams.cc_params.m16c_basic.acc_std_code1 =
+ (unsigned char) (tmpAccCode >> 8);
+
+// info("code0: 0x%2.2X, code1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_code0, out->msg.canparams.cc_params.m16c_basic.acc_std_code1);
+ out->msg.canparams.cc_params.m16c_basic.acc_std_mask0 =
+ ~acc_mask0;
+ out->msg.canparams.cc_params.m16c_basic.acc_std_mask1 =
+ ~acc_mask1;
+
+// info("mask0: 0x%2.2X, mask1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_mask0, out->msg.canparams.cc_params.m16c_basic.acc_std_mask1);
+ tmpAccMask = ((acc_mask1) >> 5) + ((acc_mask0) << 3);
+
+// info("tmpAccMask: 0x%4.4X\n", tmpAccMask);
+ out->msg.canparams.cc_params.m16c_basic.acc_std_mask0 =
+ (unsigned char) ~tmpAccMask;
+ out->msg.canparams.cc_params.m16c_basic.acc_std_mask1 =
+ (unsigned char) ~(tmpAccMask >> 8);
+
+// info("mask0: 0x%2.2X, mask1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_mask0, out->msg.canparams.cc_params.m16c_basic.acc_std_mask1);
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_code0 =
+ (unsigned char) tmpAccCode;
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_code1 =
+ (unsigned char) (tmpAccCode >> 8);
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_code2 = acc_code2;
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_code3 = acc_code3;
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_mask0 =
+ (unsigned char) ~tmpAccMask;
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_mask1 =
+ (unsigned char) ~(tmpAccMask >> 8);
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_mask2 =
+ ~acc_mask2;
+ out->msg.canparams.cc_params.m16c_basic.acc_ext_mask3 =
+ ~acc_mask3;
+ vfree(baudrate_error);
+ vfree(samplepoint_error);
+ return 0;
+}
+
+
diff --git a/drivers/staging/epl/EplSdoUdpu.c b/drivers/staging/epl/EplSdoUdpu.c
index b409c9b7be48..c8e950fa8353 100644
--- a/drivers/staging/epl/EplSdoUdpu.c
+++ b/drivers/staging/epl/EplSdoUdpu.c
@@ -334,7 +334,8 @@ tEplKernel EplSdoUdpuConfig(unsigned long ulIpAddr_p, unsigned int uiPort_p)
}
// create Listen-Thread
SdoUdpInstance_g.m_ThreadHandle =
- kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
+ kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g,
+ CLONE_FS | CLONE_FILES);
if (SdoUdpInstance_g.m_ThreadHandle == 0) {
Ret = kEplSdoUdpThreadError;
goto Exit;
diff --git a/drivers/staging/epl/ShbIpc-LinuxKernel.c b/drivers/staging/epl/ShbIpc-LinuxKernel.c
index 497938bd09b9..12d1eccde252 100644
--- a/drivers/staging/epl/ShbIpc-LinuxKernel.c
+++ b/drivers/staging/epl/ShbIpc-LinuxKernel.c
@@ -532,8 +532,8 @@ tShbError ShbIpcStartSignalingNewData(tShbInstance pShbInstance_p,
//create thread for signalling new data
pShbMemInst->m_tThreadNewDataId =
- kernel_thread(ShbIpcThreadSignalNewData, pShbInstance_p,
- CLONE_KERNEL);
+ kernel_thread(ShbIpcThreadSignalNewData, pShbInstance_p,
+ CLONE_FS | CLONE_FILES);
Exit:
return ShbError;
@@ -636,8 +636,8 @@ tShbError ShbIpcStartSignalingJobReady(tShbInstance pShbInstance_p,
pShbMemHeader->m_fJobReady = FALSE;
//create thread for signalling new data
pShbMemInst->m_tThreadJobReadyId =
- kernel_thread(ShbIpcThreadSignalJobReady, pShbInstance_p,
- CLONE_KERNEL);
+ kernel_thread(ShbIpcThreadSignalJobReady, pShbInstance_p,
+ CLONE_FS | CLONE_FILES);
Exit:
return ShbError;
}
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c
index bcba17eae926..15aed87fe1bb 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -39,7 +39,6 @@
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/mutex.h>
-#include <linux/version.h>
#include <linux/uaccess.h>
#include <linux/input.h>
diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c
index 274b82bd7863..ef8fcc8c67bd 100644
--- a/drivers/staging/frontier/tranzport.c
+++ b/drivers/staging/frontier/tranzport.c
@@ -38,7 +38,6 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/mutex.h>
-#include <linux/version.h>
#include <linux/uaccess.h>
#include <linux/input.h>
diff --git a/drivers/staging/go7007/go7007.txt b/drivers/staging/go7007/go7007.txt
index 9f6772bc68c2..1c2907c1dc81 100644
--- a/drivers/staging/go7007/go7007.txt
+++ b/drivers/staging/go7007/go7007.txt
@@ -2,7 +2,7 @@ This is a driver for the WIS GO7007SB multi-format video encoder.
Pete Eberlein <pete@sensoray.com>
-The driver was orignally released under the GPL and is currently hosted at:
+The driver was originally released under the GPL and is currently hosted at:
http://nikosapi.org/wiki/index.php/WIS_Go7007_Linux_driver
The go7007 firmware can be acquired from the package on the site above.
@@ -24,7 +24,7 @@ These should be used instead of the non-standard GO7007 ioctls described
below.
-The README files from the orignal package appear below:
+The README files from the original package appears below:
---------------------------------------------------------------------------
WIS GO7007SB Public Linux Driver
diff --git a/drivers/staging/heci/heci.h b/drivers/staging/heci/heci.h
index 14192e0cc227..48f120dc3b27 100644
--- a/drivers/staging/heci/heci.h
+++ b/drivers/staging/heci/heci.h
@@ -41,7 +41,6 @@
#ifndef _HECI_H_
#define _HECI_H_
-#include <linux/version.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/pci.h>
diff --git a/drivers/staging/heci/heci_data_structures.h b/drivers/staging/heci/heci_data_structures.h
index 575e8f8e88a3..ff30386d097a 100644
--- a/drivers/staging/heci/heci_data_structures.h
+++ b/drivers/staging/heci/heci_data_structures.h
@@ -41,7 +41,6 @@
#ifndef _HECI_DATA_STRUCTURES_H_
#define _HECI_DATA_STRUCTURES_H_
-#include <linux/version.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/pci.h>
diff --git a/drivers/staging/heci/heci_interface.h b/drivers/staging/heci/heci_interface.h
index 37336ebc0a5b..d9193cf6d9e9 100644
--- a/drivers/staging/heci/heci_interface.h
+++ b/drivers/staging/heci/heci_interface.h
@@ -42,7 +42,6 @@
#ifndef _HECI_INTERFACE_H_
#define _HECI_INTERFACE_H_
-#include <linux/version.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/pci.h>
diff --git a/drivers/staging/meilhaus/me0600_ext_irq.c b/drivers/staging/meilhaus/me0600_ext_irq.c
index 2f6fedca3223..1d098420a548 100644
--- a/drivers/staging/meilhaus/me0600_ext_irq.c
+++ b/drivers/staging/meilhaus/me0600_ext_irq.c
@@ -32,7 +32,6 @@
/*
* Includes
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -434,11 +433,7 @@ me0600_ext_irq_subdevice_t *me0600_ext_irq_constructor(uint32_t plx_reg_base,
subdevice->irq = irq;
err = request_irq(subdevice->irq, me0600_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME0600_NAME, (void *)subdevice);
if (err) {
diff --git a/drivers/staging/meilhaus/me0900_di.c b/drivers/staging/meilhaus/me0900_di.c
index 4665b2acbea4..b8c448f58e36 100644
--- a/drivers/staging/meilhaus/me0900_di.c
+++ b/drivers/staging/meilhaus/me0900_di.c
@@ -38,7 +38,6 @@
#include <linux/io.h>
#include <linux/types.h>
#include <linux/interrupt.h>
-#include <linux/version.h>
#include "medefines.h"
#include "meinternal.h"
diff --git a/drivers/staging/meilhaus/me1400_device.c b/drivers/staging/meilhaus/me1400_device.c
index ca7498b9056c..a018b5f7a19b 100644
--- a/drivers/staging/meilhaus/me1400_device.c
+++ b/drivers/staging/meilhaus/me1400_device.c
@@ -47,7 +47,6 @@
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
-#include <linux/version.h>
#include "meids.h"
#include "meerror.h"
diff --git a/drivers/staging/meilhaus/me1400_ext_irq.c b/drivers/staging/meilhaus/me1400_ext_irq.c
index 0dc6b4519b5b..6841f41860a2 100644
--- a/drivers/staging/meilhaus/me1400_ext_irq.c
+++ b/drivers/staging/meilhaus/me1400_ext_irq.c
@@ -32,7 +32,6 @@
/*
* Includes
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -458,11 +457,7 @@ me1400_ext_irq_subdevice_t *me1400_ext_irq_constructor(uint32_t device_id,
subdevice->irq = irq;
err = request_irq(irq, me1400_ext_irq_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME1400_NAME, (void *)subdevice);
if (err) {
diff --git a/drivers/staging/meilhaus/me4600_ai.c b/drivers/staging/meilhaus/me4600_ai.c
index a3cfef09a4de..e496d0c8d484 100644
--- a/drivers/staging/meilhaus/me4600_ai.c
+++ b/drivers/staging/meilhaus/me4600_ai.c
@@ -299,11 +299,7 @@ me4600_ai_subdevice_t *me4600_ai_constructor(uint32_t reg_base,
// Register interrupt service routine.
subdevice->irq = irq;
if (request_irq(subdevice->irq, me4600_ai_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME4600_NAME, subdevice)) {
PERROR("Cannot register interrupt service routine.\n");
me_subdevice_deinit((me_subdevice_t *) subdevice);
diff --git a/drivers/staging/meilhaus/me4600_ai.h b/drivers/staging/meilhaus/me4600_ai.h
index 106e1959f9f1..7055e44f32ea 100644
--- a/drivers/staging/meilhaus/me4600_ai.h
+++ b/drivers/staging/meilhaus/me4600_ai.h
@@ -28,7 +28,6 @@
#ifndef _ME4600_AI_H_
#define _ME4600_AI_H_
-#include <linux/version.h>
#include "mesubdevice.h"
#include "meioctl.h"
#include "mecirc_buf.h"
diff --git a/drivers/staging/meilhaus/me4600_ao.c b/drivers/staging/meilhaus/me4600_ao.c
index eb472692a7c5..4000dac057ed 100644
--- a/drivers/staging/meilhaus/me4600_ao.c
+++ b/drivers/staging/meilhaus/me4600_ao.c
@@ -2567,11 +2567,7 @@ me4600_ao_subdevice_t *me4600_ao_constructor(uint32_t reg_base,
if (subdevice->fifo) {
subdevice->irq = irq;
if (request_irq(subdevice->irq, me4600_ao_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME4600_NAME, subdevice)) {
PERROR("Cannot get interrupt line.\n");
PDEBUG("free circ_buf = %p size=%d",
@@ -5737,7 +5733,7 @@ me4600_ao_subdevice_t *me4600_ao_constructor(uint32_t reg_base,
subdevice->irq = irq;
if (request_irq
- (subdevice->irq, me4600_ao_isr, SA_INTERRUPT | SA_SHIRQ,
+ (subdevice->irq, me4600_ao_isr, IRQF_DISABLED | IRQF_SHARED,
ME4600_NAME, subdevice)) {
PERROR("Cannot get interrupt line.\n");
me_subdevice_deinit((me_subdevice_t *) subdevice);
diff --git a/drivers/staging/meilhaus/me4600_ext_irq.c b/drivers/staging/meilhaus/me4600_ext_irq.c
index 6b33cba3da8b..cfb4adbd41ab 100644
--- a/drivers/staging/meilhaus/me4600_ext_irq.c
+++ b/drivers/staging/meilhaus/me4600_ext_irq.c
@@ -39,7 +39,6 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/types.h>
-#include <linux/version.h>
#include "medefines.h"
#include "meinternal.h"
@@ -420,11 +419,7 @@ me4600_ext_irq_subdevice_t *me4600_ext_irq_constructor(uint32_t reg_base,
subdevice->irq = irq;
if (request_irq(subdevice->irq, me4600_ext_irq_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME4600_NAME, subdevice)) {
PERROR("Cannot register interrupt.\n");
kfree(subdevice);
diff --git a/drivers/staging/meilhaus/me6000_ao.c b/drivers/staging/meilhaus/me6000_ao.c
index f7abdbd485e4..66652dc5b967 100644
--- a/drivers/staging/meilhaus/me6000_ao.c
+++ b/drivers/staging/meilhaus/me6000_ao.c
@@ -2627,11 +2627,7 @@ me6000_ao_subdevice_t *me6000_ao_constructor(uint32_t reg_base,
if (subdevice->fifo & ME6000_AO_HAS_FIFO) {
subdevice->irq = irq;
if (request_irq(subdevice->irq, me6000_ao_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME6000_NAME, subdevice)) {
PERROR("Cannot get interrupt line.\n");
PDEBUG("free circ_buf = %p size=%d",
diff --git a/drivers/staging/meilhaus/me6000_ao.h b/drivers/staging/meilhaus/me6000_ao.h
index ef4d0189bdea..d86fb29265f5 100644
--- a/drivers/staging/meilhaus/me6000_ao.h
+++ b/drivers/staging/meilhaus/me6000_ao.h
@@ -27,7 +27,6 @@
#ifndef _ME6000_AO_H_
#define _ME6000_AO_H_
-#include <linux/version.h>
#include "mesubdevice.h"
#include "mecirc_buf.h"
#include "meioctl.h"
diff --git a/drivers/staging/meilhaus/me8100_di.c b/drivers/staging/meilhaus/me8100_di.c
index 301dbd8f96a1..1a3f2692d7ab 100644
--- a/drivers/staging/meilhaus/me8100_di.c
+++ b/drivers/staging/meilhaus/me8100_di.c
@@ -39,7 +39,6 @@
#include <linux/io.h>
#include <linux/types.h>
#include <linux/interrupt.h>
-#include <linux/version.h>
#include "medefines.h"
#include "meerror.h"
@@ -633,11 +632,7 @@ me8100_di_subdevice_t *me8100_di_constructor(uint32_t me8100_reg_base,
/* Register interrupt service routine. */
subdevice->irq = irq;
err = request_irq(subdevice->irq, me8100_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME8100_NAME, (void *)subdevice);
if (err) {
diff --git a/drivers/staging/meilhaus/me8200_di.c b/drivers/staging/meilhaus/me8200_di.c
index a931fb817c7d..fd1af0f0565e 100644
--- a/drivers/staging/meilhaus/me8200_di.c
+++ b/drivers/staging/meilhaus/me8200_di.c
@@ -37,7 +37,6 @@
#include <linux/io.h>
#include <linux/types.h>
#include <linux/interrupt.h>
-#include <linux/version.h>
#include "medefines.h"
#include "meerror.h"
@@ -801,19 +800,11 @@ me8200_di_subdevice_t *me8200_di_constructor(uint32_t me8200_regbase,
subdevice->irq = irq;
if (subdevice->version > 0) { // NEW
err = request_irq(subdevice->irq, me8200_isr_EX,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME8200_NAME, (void *)subdevice);
} else { //OLD
err = request_irq(subdevice->irq, me8200_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME8200_NAME, (void *)subdevice);
}
diff --git a/drivers/staging/meilhaus/me8200_do.c b/drivers/staging/meilhaus/me8200_do.c
index 40d536c71d50..e42a137617a1 100644
--- a/drivers/staging/meilhaus/me8200_do.c
+++ b/drivers/staging/meilhaus/me8200_do.c
@@ -39,7 +39,6 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/types.h>
-#include <linux/version.h>
#include "medefines.h"
#include "meinternal.h"
@@ -556,11 +555,7 @@ me8200_do_subdevice_t *me8200_do_constructor(uint32_t reg_base,
/* Request the interrupt line */
err = request_irq(irq, me8200_do_isr,
-#ifdef IRQF_DISABLED
IRQF_DISABLED | IRQF_SHARED,
-#else
- SA_INTERRUPT | SA_SHIRQ,
-#endif
ME8200_NAME, (void *)subdevice);
if (err) {
diff --git a/drivers/staging/meilhaus/memain.c b/drivers/staging/meilhaus/memain.c
index fd9f079b0ed1..0dc2878931bb 100644
--- a/drivers/staging/meilhaus/memain.c
+++ b/drivers/staging/meilhaus/memain.c
@@ -38,7 +38,7 @@
//#include <linux/usb.h>
#include <linux/errno.h>
#include <linux/uaccess.h>
-#include <linux/cdev.h>
+#include <linux/miscdevice.h>
#include <linux/rwsem.h>
#include "medefines.h"
@@ -68,13 +68,6 @@ MODULE_PARM_DESC(me_bosch_fw,
"Flags which signals the ME-4600 driver to load the bosch firmware (default = 0).");
#endif //BOSCH
-static unsigned int major = 0;
-#ifdef module_param
-module_param(major, int, S_IRUGO);
-#else
-MODULE_PARM(major, "i");
-#endif
-
/* Global Driver Lock
*/
@@ -100,29 +93,131 @@ static int me_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
//static int me_probe_usb(struct usb_interface *interface, const struct usb_device_id *id);
//static void me_disconnect_usb(struct usb_interface *interface);
-/* Character device structure
-*/
-
-static struct cdev *cdevp;
-
/* File operations provided by the module
*/
-static struct file_operations me_file_operations = {
+static const struct file_operations me_file_operations = {
.owner = THIS_MODULE,
.ioctl = me_ioctl,
.open = me_open,
.release = me_release,
};
-struct pci_driver me_pci_driver = {
+static const struct pci_device_id me_pci_table[] = {
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1000) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1000_A) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1000_B) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1400) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140A) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140B) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME14E0) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME14EA) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME14EB) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140C) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140D) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_4U) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_8U) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_12U) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_16U) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_16U_8I) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4610) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4650) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4660) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4660I) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670I) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670S) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670IS) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680I) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680S) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680IS) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6004) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6008) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME600F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6014) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6018) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME601F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6034) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6038) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME603F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6104) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6108) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME610F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6114) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6118) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME611F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6134) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6138) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME613F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6044) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6048) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME604F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6054) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6058) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME605F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6074) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6078) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME607F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6144) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6148) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME614F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6154) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6158) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME615F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6174) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6178) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME617F) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6259) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6359) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0630) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8100_A) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8100_B) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8200_A) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8200_B) },
+
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0940) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0950) },
+ { PCI_VDEVICE(MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0960) },
+
+ { }
+};
+MODULE_DEVICE_TABLE(pci, me_pci_table);
+
+static struct pci_driver me_pci_driver = {
.name = MEMAIN_NAME,
.id_table = me_pci_table,
.probe = me_probe_pci,
- .remove = me_remove_pci
+ .remove = __devexit_p(me_remove_pci),
};
-/* //me_usb_driver
+/*
+static struct usb_device_id me_usb_table[] = {
+ { USB_DEVICE(USB_VENDOR_ID_MEPHISTO_S1, USB_DEVICE_ID_MEPHISTO_S1) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE (usb, me_usb_table);
+
static struct usb_driver me_usb_driver =
{
.name = MEMAIN_NAME,
@@ -396,7 +491,8 @@ static me_device_t *get_dummy_instance(unsigned short vendor_id,
return instance;
}
-static int me_probe_pci(struct pci_dev *dev, const struct pci_device_id *id)
+static int __devinit me_probe_pci(struct pci_dev *dev,
+ const struct pci_device_id *id)
{
int err;
me_pci_constructor_t constructor = NULL;
@@ -594,7 +690,7 @@ static int insert_to_device_list(me_device_t *n_device)
return 0;
}
-static void me_remove_pci(struct pci_dev *dev)
+static void __devexit me_remove_pci(struct pci_dev *dev)
{
int vendor_id = dev->vendor;
int device_id = dev->device;
@@ -1910,11 +2006,16 @@ static int me_ioctl(struct inode *inodep,
return -ENOTTY;
}
+static struct miscdevice me_miscdev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = MEMAIN_NAME,
+ .fops = &me_file_operations,
+};
+
// Init and exit of module.
static int memain_init(void)
{
int result = 0;
- dev_t dev = MKDEV(major, 0);
PDEBUG("executed.\n");
@@ -1943,46 +2044,14 @@ static int memain_init(void)
}
}
*/
- // Register the character device.
- if (major) {
- result = register_chrdev_region(dev, 1, MEMAIN_NAME);
- } else {
- result = alloc_chrdev_region(&dev, 0, 1, MEMAIN_NAME);
- major = MAJOR(dev);
- }
-
+ result = misc_register(&me_miscdev);
if (result < 0) {
- PERROR("Can't get major driver no.\n");
+ printk(KERN_ERR MEMAIN_NAME ": can't register misc device\n");
goto INIT_ERROR_3;
}
- cdevp = cdev_alloc();
-
- if (!cdevp) {
- PERROR("Can't get character device structure.\n");
- result = -ENOMEM;
- goto INIT_ERROR_4;
- }
-
- cdevp->ops = &me_file_operations;
-
- cdevp->owner = THIS_MODULE;
-
- result = cdev_add(cdevp, dev, 1);
-
- if (result < 0) {
- PERROR("Cannot add character device structure.\n");
- goto INIT_ERROR_5;
- }
-
return 0;
- INIT_ERROR_5:
- cdev_del(cdevp);
-
- INIT_ERROR_4:
- unregister_chrdev_region(dev, 1);
-
INIT_ERROR_3:
// usb_deregister(&me_usb_driver);
@@ -1996,12 +2065,9 @@ static int memain_init(void)
static void __exit memain_exit(void)
{
- dev_t dev = MKDEV(major, 0);
-
PDEBUG("executed.\n");
- cdev_del(cdevp);
- unregister_chrdev_region(dev, 1);
+ misc_deregister(&me_miscdev);
pci_unregister_driver(&me_pci_driver);
// usb_deregister(&me_usb_driver);
clear_device_list();
diff --git a/drivers/staging/meilhaus/memain.h b/drivers/staging/meilhaus/memain.h
index 7616ff7f65cb..48f83679379e 100644
--- a/drivers/staging/meilhaus/memain.h
+++ b/drivers/staging/meilhaus/memain.h
@@ -28,200 +28,6 @@
#ifdef __KERNEL__
/*=============================================================================
- PCI device table.
- This is used by modprobe to translate PCI IDs to drivers.
- ===========================================================================*/
-
-static struct pci_device_id me_pci_table[] __devinitdata = {
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1000, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1000_A, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1000_B, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1400, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140A, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140B, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME14E0, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME14EA, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME14EB, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140C, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME140D, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_4U, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_8U, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_12U, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_16U, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME1600_16U_8I,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4610, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4650, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4660, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4660I, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670I, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670S, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4670IS, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680I, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680S, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4680IS, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6004, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6008, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME600F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6014, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6018, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME601F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6034, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6038, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME603F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6104, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6108, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME610F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6114, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6118, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME611F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6134, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6138, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME613F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6044, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6048, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME604F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6054, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6058, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME605F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6074, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6078, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME607F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6144, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6148, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME614F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6154, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6158, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME615F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6174, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6178, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME617F, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6259, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME6359, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0630, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8100_A, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8100_B, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8200_A, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME8200_B, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0940, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0950, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME0960, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
-
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, me_pci_table);
-
-/*=============================================================================
- USB device table.
- This is used by modprobe to translate USB IDs to drivers.
- ===========================================================================*/
-/*
-static struct usb_device_id me_usb_table[] __devinitdata = {
- { USB_DEVICE(USB_VENDOR_ID_MEPHISTO_S1, USB_DEVICE_ID_MEPHISTO_S1) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE (usb, me_usb_table);
-*/
-
-/*=============================================================================
Templates
===========================================================================*/
diff --git a/drivers/staging/otus/80211core/ccmd.c b/drivers/staging/otus/80211core/ccmd.c
index 479977973671..83dd8ba1328c 100644
--- a/drivers/staging/otus/80211core/ccmd.c
+++ b/drivers/staging/otus/80211core/ccmd.c
@@ -27,1019 +27,941 @@
#include "../hal/hpreg.h"
-u16_t zfWlanReset(zdev_t* dev);
-u32_t zfUpdateRxRate(zdev_t* dev);
+u16_t zfWlanReset(zdev_t *dev);
+u32_t zfUpdateRxRate(zdev_t *dev);
extern void zfiUsbRecv(zdev_t *dev, zbuf_t *buf);
-extern void zfiUsbRegIn(zdev_t* dev, u32_t* rsp, u16_t rspLen);
-extern void zfiUsbOutComplete(zdev_t* dev, zbuf_t *buf, u8_t status, u8_t *hdr);
-extern void zfiUsbRegOutComplete(zdev_t* dev);
-extern u16_t zfHpReinit(zdev_t* dev, u32_t frequency);
+extern void zfiUsbRegIn(zdev_t *dev, u32_t *rsp, u16_t rspLen);
+extern void zfiUsbOutComplete(zdev_t *dev, zbuf_t *buf, u8_t status, u8_t *hdr);
+extern void zfiUsbRegOutComplete(zdev_t *dev);
+extern u16_t zfHpReinit(zdev_t *dev, u32_t frequency);
/* Get size (byte) of driver core global data structure. */
/* This size will be used by driver wrapper to allocate */
/* a memory space for driver core to store global variables */
-u16_t zfiGlobalDataSize(zdev_t* dev)
+u16_t zfiGlobalDataSize(zdev_t *dev)
{
- u32_t ret;
- ret = (sizeof(struct zsWlanDev));
- zm_assert((ret>>16) == 0);
- return (u16_t)ret;
+ u32_t ret;
+ ret = (sizeof(struct zsWlanDev));
+ zm_assert((ret>>16) == 0);
+ return (u16_t)ret;
}
/* Initialize WLAN hardware and software, resource will be allocated */
/* for WLAN operation, must be called first before other function. */
-extern u16_t zfiWlanOpen(zdev_t* dev, struct zsCbFuncTbl* cbFuncTbl)
+extern u16_t zfiWlanOpen(zdev_t *dev, struct zsCbFuncTbl *cbFuncTbl)
{
- //u16_t ret;
- //u32_t i;
- //u8_t* ch;
- //u8_t bPassive;
- u32_t devSize;
- struct zfCbUsbFuncTbl cbUsbFuncTbl;
- zmw_get_wlan_dev(dev);
+ /* u16_t ret;
+ u32_t i;
+ u8_t* ch;
+ u8_t bPassive;
+ */
+ u32_t devSize;
+ struct zfCbUsbFuncTbl cbUsbFuncTbl;
+ zmw_get_wlan_dev(dev);
- zm_debug_msg0("start");
+ zm_debug_msg0("start");
- devSize = sizeof(struct zsWlanDev);
- /* Zeroize zsWlanDev struct */
- zfZeroMemory((u8_t*)wd, (u16_t)devSize);
+ devSize = sizeof(struct zsWlanDev);
+ /* Zeroize zsWlanDev struct */
+ zfZeroMemory((u8_t *)wd, (u16_t)devSize);
#ifdef ZM_ENABLE_AGGREGATION
- zfAggInit(dev);
+ zfAggInit(dev);
#endif
- zfCwmInit(dev);
-
- wd->commTally.RateCtrlTxMPDU = 0;
- wd->commTally.RateCtrlBAFail = 0;
- wd->preambleTypeInUsed = ZM_PREAMBLE_TYPE_SHORT;
-
- if (cbFuncTbl == NULL)
- {
- /* zfcbRecvEth() is mandatory */
- zm_assert(0);
- }
- else
- {
- if (cbFuncTbl->zfcbRecvEth == NULL)
- {
- /* zfcbRecvEth() is mandatory */
- zm_assert(0);
- }
- wd->zfcbAuthNotify = cbFuncTbl->zfcbAuthNotify;
- wd->zfcbAuthNotify = cbFuncTbl->zfcbAuthNotify;
- wd->zfcbAsocNotify = cbFuncTbl->zfcbAsocNotify;
- wd->zfcbDisAsocNotify = cbFuncTbl->zfcbDisAsocNotify;
- wd->zfcbApConnectNotify = cbFuncTbl->zfcbApConnectNotify;
- wd->zfcbConnectNotify = cbFuncTbl->zfcbConnectNotify;
- wd->zfcbScanNotify = cbFuncTbl->zfcbScanNotify;
- wd->zfcbMicFailureNotify = cbFuncTbl->zfcbMicFailureNotify;
- wd->zfcbApMicFailureNotify = cbFuncTbl->zfcbApMicFailureNotify;
- wd->zfcbIbssPartnerNotify = cbFuncTbl->zfcbIbssPartnerNotify;
- wd->zfcbMacAddressNotify = cbFuncTbl->zfcbMacAddressNotify;
- wd->zfcbSendCompleteIndication = cbFuncTbl->zfcbSendCompleteIndication;
- wd->zfcbRecvEth = cbFuncTbl->zfcbRecvEth;
- wd->zfcbRestoreBufData = cbFuncTbl->zfcbRestoreBufData;
- wd->zfcbRecv80211 = cbFuncTbl->zfcbRecv80211;
+ zfCwmInit(dev);
+
+ wd->commTally.RateCtrlTxMPDU = 0;
+ wd->commTally.RateCtrlBAFail = 0;
+ wd->preambleTypeInUsed = ZM_PREAMBLE_TYPE_SHORT;
+
+ if (cbFuncTbl == NULL) {
+ /* zfcbRecvEth() is mandatory */
+ zm_assert(0);
+ } else {
+ if (cbFuncTbl->zfcbRecvEth == NULL) {
+ /* zfcbRecvEth() is mandatory */
+ zm_assert(0);
+ }
+ wd->zfcbAuthNotify = cbFuncTbl->zfcbAuthNotify;
+ wd->zfcbAuthNotify = cbFuncTbl->zfcbAuthNotify;
+ wd->zfcbAsocNotify = cbFuncTbl->zfcbAsocNotify;
+ wd->zfcbDisAsocNotify = cbFuncTbl->zfcbDisAsocNotify;
+ wd->zfcbApConnectNotify = cbFuncTbl->zfcbApConnectNotify;
+ wd->zfcbConnectNotify = cbFuncTbl->zfcbConnectNotify;
+ wd->zfcbScanNotify = cbFuncTbl->zfcbScanNotify;
+ wd->zfcbMicFailureNotify = cbFuncTbl->zfcbMicFailureNotify;
+ wd->zfcbApMicFailureNotify = cbFuncTbl->zfcbApMicFailureNotify;
+ wd->zfcbIbssPartnerNotify = cbFuncTbl->zfcbIbssPartnerNotify;
+ wd->zfcbMacAddressNotify = cbFuncTbl->zfcbMacAddressNotify;
+ wd->zfcbSendCompleteIndication =
+ cbFuncTbl->zfcbSendCompleteIndication;
+ wd->zfcbRecvEth = cbFuncTbl->zfcbRecvEth;
+ wd->zfcbRestoreBufData = cbFuncTbl->zfcbRestoreBufData;
+ wd->zfcbRecv80211 = cbFuncTbl->zfcbRecv80211;
#ifdef ZM_ENABLE_CENC
- wd->zfcbCencAsocNotify = cbFuncTbl->zfcbCencAsocNotify;
-#endif //ZM_ENABLE_CENC
- wd->zfcbClassifyTxPacket = cbFuncTbl->zfcbClassifyTxPacket;
- wd->zfcbHwWatchDogNotify = cbFuncTbl->zfcbHwWatchDogNotify;
- }
-
- //add by honda 0330
- cbUsbFuncTbl.zfcbUsbRecv = zfiUsbRecv;
- cbUsbFuncTbl.zfcbUsbRegIn = zfiUsbRegIn;
- cbUsbFuncTbl.zfcbUsbOutComplete = zfiUsbOutComplete;
- cbUsbFuncTbl.zfcbUsbRegOutComplete = zfiUsbRegOutComplete;
- zfwUsbRegisterCallBack(dev, &cbUsbFuncTbl);
- /* Init OWN MAC address */
- wd->macAddr[0] = 0x8000;
- wd->macAddr[1] = 0x0000;
- wd->macAddr[2] = 0x0000;
-
- wd->regulationTable.regionCode = 0xffff;
-
- zfHpInit(dev, wd->frequency);
-
- /* init region code */
- //wd->regulationTable.regionCode = NULL1_WORLD; //Only 2.4g RegCode
- //zfHpGetRegulationTablefromRegionCode(dev, NULL1_WORLD);
- //zfiWlanSetDot11DMode(dev , 1); // Enable 802.11d
- /* Get the first channel */
- //wd->frequency = zfChGetFirstChannel(dev, &bPassive);
+ wd->zfcbCencAsocNotify = cbFuncTbl->zfcbCencAsocNotify;
+#endif /* ZM_ENABLE_CENC */
+ wd->zfcbClassifyTxPacket = cbFuncTbl->zfcbClassifyTxPacket;
+ wd->zfcbHwWatchDogNotify = cbFuncTbl->zfcbHwWatchDogNotify;
+ }
+
+ /* add by honda 0330 */
+ cbUsbFuncTbl.zfcbUsbRecv = zfiUsbRecv;
+ cbUsbFuncTbl.zfcbUsbRegIn = zfiUsbRegIn;
+ cbUsbFuncTbl.zfcbUsbOutComplete = zfiUsbOutComplete;
+ cbUsbFuncTbl.zfcbUsbRegOutComplete = zfiUsbRegOutComplete;
+ zfwUsbRegisterCallBack(dev, &cbUsbFuncTbl);
+ /* Init OWN MAC address */
+ wd->macAddr[0] = 0x8000;
+ wd->macAddr[1] = 0x0000;
+ wd->macAddr[2] = 0x0000;
+
+ wd->regulationTable.regionCode = 0xffff;
+
+ zfHpInit(dev, wd->frequency);
+
+ /* init region code */
+ /* wd->regulationTable.regionCode = NULL1_WORLD; //Only 2.4g RegCode */
+ /* zfHpGetRegulationTablefromRegionCode(dev, NULL1_WORLD); */
+ /* zfiWlanSetDot11DMode(dev , 1); //Enable 802.11d */
+ /* Get the first channel */
+ /* wd->frequency = zfChGetFirstChannel(dev, &bPassive); */
#ifdef ZM_AP_DEBUG
- //wd->frequency = 2437;
+ /* wd->frequency = 2437; */
#endif
- //STA mode
- wd->sta.mTxRate = 0x0;
- wd->sta.uTxRate = 0x3;
- wd->sta.mmTxRate = 0x0;
- wd->sta.adapterState = ZM_STA_STATE_DISCONNECT;
- wd->sta.capability[0] = 0x01;
- wd->sta.capability[1] = 0x00;
-
- wd->sta.preambleTypeHT = 0;
- wd->sta.htCtrlBandwidth = 0;
- wd->sta.htCtrlSTBC = 0;
- wd->sta.htCtrlSG = 0;
- wd->sta.defaultTA = 0;
- //wd->sta.activescanTickPerChannel = ZM_TIME_ACTIVE_SCAN/ZM_MS_PER_TICK;
+ /* STA mode */
+ wd->sta.mTxRate = 0x0;
+ wd->sta.uTxRate = 0x3;
+ wd->sta.mmTxRate = 0x0;
+ wd->sta.adapterState = ZM_STA_STATE_DISCONNECT;
+ wd->sta.capability[0] = 0x01;
+ wd->sta.capability[1] = 0x00;
+
+ wd->sta.preambleTypeHT = 0;
+ wd->sta.htCtrlBandwidth = 0;
+ wd->sta.htCtrlSTBC = 0;
+ wd->sta.htCtrlSG = 0;
+ wd->sta.defaultTA = 0;
+ /*wd->sta.activescanTickPerChannel =
+ *ZM_TIME_ACTIVE_SCAN/ZM_MS_PER_TICK;
+ */
{
u8_t Dur = ZM_TIME_ACTIVE_SCAN;
zfwGetActiveScanDur(dev, &Dur);
- wd->sta.activescanTickPerChannel = Dur/ZM_MS_PER_TICK;
+ wd->sta.activescanTickPerChannel = Dur / ZM_MS_PER_TICK;
}
- wd->sta.passiveScanTickPerChannel = ZM_TIME_PASSIVE_SCAN/ZM_MS_PER_TICK;
- wd->sta.bAutoReconnect = TRUE;
- wd->sta.dropUnencryptedPkts = FALSE;
+ wd->sta.passiveScanTickPerChannel = ZM_TIME_PASSIVE_SCAN/ZM_MS_PER_TICK;
+ wd->sta.bAutoReconnect = TRUE;
+ wd->sta.dropUnencryptedPkts = FALSE;
- /* set default to bypass all multicast packet for linux, window XP would set 0 by wrapper initialization */
+ /* set default to bypass all multicast packet for linux,
+ * window XP would set 0 by wrapper initialization
+ */
wd->sta.bAllMulticast = 1;
- /* Initial the RIFS Status / RIFS-like frame count / RIFS count */
- wd->sta.rifsState = ZM_RIFS_STATE_DETECTING;
- wd->sta.rifsLikeFrameCnt = 0;
- wd->sta.rifsCount = 0;
-
- wd->sta.osRxFilter = 0;
- wd->sta.bSafeMode = 0;
-
- //Common
- zfResetSupportRate(dev, ZM_DEFAULT_SUPPORT_RATE_DISCONNECT);
- wd->beaconInterval = 100;
- wd->rtsThreshold = 2346;
- wd->fragThreshold = 32767;
- wd->wlanMode = ZM_MODE_INFRASTRUCTURE;
- wd->txMCS = 0xff; //AUTO
- wd->dtim = 1;
- //wd->txMT = 1; //OFDM
- wd->tick = 1;
- wd->maxTxPower2 = 0xff;
- wd->maxTxPower5 = 0xff;
- wd->supportMode = 0xffffffff;
- wd->ws.adhocMode = ZM_ADHOCBAND_G;
- wd->ws.autoSetFrequency = 0xff;
-
- //AP mode
- //wd->bgMode = wd->ws.bgMode;
- wd->ap.ssidLen[0] = 6;
- wd->ap.ssid[0][0] = 'Z';
- wd->ap.ssid[0][1] = 'D';
- wd->ap.ssid[0][2] = '1';
- wd->ap.ssid[0][3] = '2';
- wd->ap.ssid[0][4] = '2';
- wd->ap.ssid[0][5] = '1';
-
- // Init the country iso name as NA
- wd->ws.countryIsoName[0] = 0;
- wd->ws.countryIsoName[1] = 0;
- wd->ws.countryIsoName[2] = '\0';
+ /* Initial the RIFS Status / RIFS-like frame count / RIFS count */
+ wd->sta.rifsState = ZM_RIFS_STATE_DETECTING;
+ wd->sta.rifsLikeFrameCnt = 0;
+ wd->sta.rifsCount = 0;
+
+ wd->sta.osRxFilter = 0;
+ wd->sta.bSafeMode = 0;
+
+ /* Common */
+ zfResetSupportRate(dev, ZM_DEFAULT_SUPPORT_RATE_DISCONNECT);
+ wd->beaconInterval = 100;
+ wd->rtsThreshold = 2346;
+ wd->fragThreshold = 32767;
+ wd->wlanMode = ZM_MODE_INFRASTRUCTURE;
+ wd->txMCS = 0xff; /* AUTO */
+ wd->dtim = 1;
+ /* wd->txMT = 1; *//*OFDM */
+ wd->tick = 1;
+ wd->maxTxPower2 = 0xff;
+ wd->maxTxPower5 = 0xff;
+ wd->supportMode = 0xffffffff;
+ wd->ws.adhocMode = ZM_ADHOCBAND_G;
+ wd->ws.autoSetFrequency = 0xff;
+
+ /* AP mode */
+ /* wd->bgMode = wd->ws.bgMode; */
+ wd->ap.ssidLen[0] = 6;
+ wd->ap.ssid[0][0] = 'Z';
+ wd->ap.ssid[0][1] = 'D';
+ wd->ap.ssid[0][2] = '1';
+ wd->ap.ssid[0][3] = '2';
+ wd->ap.ssid[0][4] = '2';
+ wd->ap.ssid[0][5] = '1';
+
+ /* Init the country iso name as NA */
+ wd->ws.countryIsoName[0] = 0;
+ wd->ws.countryIsoName[1] = 0;
+ wd->ws.countryIsoName[2] = '\0';
/* init fragmentation is disabled */
- //zfiWlanSetFragThreshold(dev, 0);
+ /* zfiWlanSetFragThreshold(dev, 0); */
/* airopeek : swSniffer 1=>on 0=>off */
wd->swSniffer = 0;
- wd->XLinkMode = 0;
+ wd->XLinkMode = 0;
-// jhlee HT 0
+ /* jhlee HT 0 */
#if 1
- /* AP Mode*/
- /* Init HT Capability Info */
- wd->ap.HTCap.Data.ElementID = ZM_WLAN_EID_HT_CAPABILITY;
- wd->ap.HTCap.Data.Length = 26;
- //wd->ap.HTCap.Data.SupChannelWidthSet = 0;
- //wd->ap.HTCap.Data.MIMOPowerSave = 3;
- //wd->ap.HTCap.Data.ShortGIfor40MHz = 0;
- //wd->ap.HTCap.Data.ShortGIfor20MHz = 0;
- //wd->ap.HTCap.Data.DSSSandCCKin40MHz = 0;
- wd->ap.HTCap.Data.AMPDUParam |= HTCAP_MaxRxAMPDU3;
- wd->ap.HTCap.Data.MCSSet[0] = 0xFF; // MCS 0 ~ 7
- wd->ap.HTCap.Data.MCSSet[1] = 0xFF; // MCS 8 ~ 15
-
- /* Init Extended HT Capability Info */
- wd->ap.ExtHTCap.Data.ElementID = ZM_WLAN_EID_EXTENDED_HT_CAPABILITY;
- wd->ap.ExtHTCap.Data.Length = 22;
- wd->ap.ExtHTCap.Data.ControlChannel = 6;
- //wd->ap.ExtHTCap.Data.ExtChannelOffset = 3;
- wd->ap.ExtHTCap.Data.ChannelInfo |= ExtHtCap_RecomTxWidthSet;
- //wd->ap.ExtHTCap.Data.RIFSMode = 1;
- wd->ap.ExtHTCap.Data.OperatingInfo |= 1;
-
- /* STA Mode*/
- /* Init HT Capability Info */
- wd->sta.HTCap.Data.ElementID = ZM_WLAN_EID_HT_CAPABILITY;
- wd->sta.HTCap.Data.Length = 26;
-
- /* Test with 5G-AP : 7603 */
- //wd->sta.HTCap.Data.SupChannelWidthSet = 1;
- wd->sta.HTCap.Data.HtCapInfo |= HTCAP_SMEnabled;
- wd->sta.HTCap.Data.HtCapInfo |= HTCAP_SupChannelWidthSet;
- wd->sta.HTCap.Data.HtCapInfo |= HTCAP_ShortGIfor40MHz;
- wd->sta.HTCap.Data.HtCapInfo |= HTCAP_DSSSandCCKin40MHz;
+ /* AP Mode*/
+ /* Init HT Capability Info */
+ wd->ap.HTCap.Data.ElementID = ZM_WLAN_EID_HT_CAPABILITY;
+ wd->ap.HTCap.Data.Length = 26;
+ /*wd->ap.HTCap.Data.SupChannelWidthSet = 0;
+ wd->ap.HTCap.Data.MIMOPowerSave = 3;
+ wd->ap.HTCap.Data.ShortGIfor40MHz = 0;
+ wd->ap.HTCap.Data.ShortGIfor20MHz = 0;
+ wd->ap.HTCap.Data.DSSSandCCKin40MHz = 0;
+ */
+ wd->ap.HTCap.Data.AMPDUParam |= HTCAP_MaxRxAMPDU3;
+ wd->ap.HTCap.Data.MCSSet[0] = 0xFF; /* MCS 0 ~ 7 */
+ wd->ap.HTCap.Data.MCSSet[1] = 0xFF; /* MCS 8 ~ 15 */
+
+ /* Init Extended HT Capability Info */
+ wd->ap.ExtHTCap.Data.ElementID = ZM_WLAN_EID_EXTENDED_HT_CAPABILITY;
+ wd->ap.ExtHTCap.Data.Length = 22;
+ wd->ap.ExtHTCap.Data.ControlChannel = 6;
+ /* wd->ap.ExtHTCap.Data.ExtChannelOffset = 3; */
+ wd->ap.ExtHTCap.Data.ChannelInfo |= ExtHtCap_RecomTxWidthSet;
+ /* wd->ap.ExtHTCap.Data.RIFSMode = 1; */
+ wd->ap.ExtHTCap.Data.OperatingInfo |= 1;
+
+ /* STA Mode*/
+ /* Init HT Capability Info */
+ wd->sta.HTCap.Data.ElementID = ZM_WLAN_EID_HT_CAPABILITY;
+ wd->sta.HTCap.Data.Length = 26;
+
+ /* Test with 5G-AP : 7603 */
+ /* wd->sta.HTCap.Data.SupChannelWidthSet = 1; */
+ wd->sta.HTCap.Data.HtCapInfo |= HTCAP_SMEnabled;
+ wd->sta.HTCap.Data.HtCapInfo |= HTCAP_SupChannelWidthSet;
+ wd->sta.HTCap.Data.HtCapInfo |= HTCAP_ShortGIfor40MHz;
+ wd->sta.HTCap.Data.HtCapInfo |= HTCAP_DSSSandCCKin40MHz;
#ifndef ZM_DISABLE_AMSDU8K_SUPPORT
- wd->sta.HTCap.Data.HtCapInfo |= HTCAP_MaxAMSDULength;
+ wd->sta.HTCap.Data.HtCapInfo |= HTCAP_MaxAMSDULength;
#endif
- //wd->sta.HTCap.Data.MIMOPowerSave = 0;
- //wd->sta.HTCap.Data.ShortGIfor40MHz = 0;
- //wd->sta.HTCap.Data.ShortGIfor20MHz = 0;
- //wd->sta.HTCap.Data.DSSSandCCKin40MHz = 0;
- wd->sta.HTCap.Data.AMPDUParam |= HTCAP_MaxRxAMPDU3;
- wd->sta.HTCap.Data.MCSSet[0] = 0xFF; // MCS 0 ~ 7
- wd->sta.HTCap.Data.MCSSet[1] = 0xFF; // MCS 8 ~ 15
- wd->sta.HTCap.Data.PCO |= HTCAP_TransmissionTime3;
- //wd->sta.HTCap.Data.TransmissionTime = 0;
- /* Init Extended HT Capability Info */
- wd->sta.ExtHTCap.Data.ElementID = ZM_WLAN_EID_EXTENDED_HT_CAPABILITY;
- wd->sta.ExtHTCap.Data.Length = 22;
- wd->sta.ExtHTCap.Data.ControlChannel = 6;
-
- //wd->sta.ExtHTCap.Data.ExtChannelOffset |= 3;
- wd->sta.ExtHTCap.Data.ChannelInfo |= ExtHtCap_ExtChannelOffsetBelow;
-
- //wd->sta.ExtHTCap.Data.RecomTxWidthSet = 1;
- //wd->sta.ExtHTCap.Data.RIFSMode = 1;
- wd->sta.ExtHTCap.Data.OperatingInfo |= 1;
+ /*wd->sta.HTCap.Data.MIMOPowerSave = 0;
+ wd->sta.HTCap.Data.ShortGIfor40MHz = 0;
+ wd->sta.HTCap.Data.ShortGIfor20MHz = 0;
+ wd->sta.HTCap.Data.DSSSandCCKin40MHz = 0;
+ */
+ wd->sta.HTCap.Data.AMPDUParam |= HTCAP_MaxRxAMPDU3;
+ wd->sta.HTCap.Data.MCSSet[0] = 0xFF; /* MCS 0 ~ 7 */
+ wd->sta.HTCap.Data.MCSSet[1] = 0xFF; /* MCS 8 ~ 15 */
+ wd->sta.HTCap.Data.PCO |= HTCAP_TransmissionTime3;
+ /* wd->sta.HTCap.Data.TransmissionTime = 0; */
+ /* Init Extended HT Capability Info */
+ wd->sta.ExtHTCap.Data.ElementID = ZM_WLAN_EID_EXTENDED_HT_CAPABILITY;
+ wd->sta.ExtHTCap.Data.Length = 22;
+ wd->sta.ExtHTCap.Data.ControlChannel = 6;
+
+ /* wd->sta.ExtHTCap.Data.ExtChannelOffset |= 3; */
+ wd->sta.ExtHTCap.Data.ChannelInfo |= ExtHtCap_ExtChannelOffsetBelow;
+
+ /* wd->sta.ExtHTCap.Data.RecomTxWidthSet = 1; */
+ /* wd->sta.ExtHTCap.Data.RIFSMode = 1; */
+ wd->sta.ExtHTCap.Data.OperatingInfo |= 1;
#endif
#if 0
- /* WME test code */
- wd->ap.qosMode[0] = 1;
+ /* WME test code */
+ wd->ap.qosMode[0] = 1;
#endif
- wd->ledStruct.ledMode[0] = 0x2221;
- wd->ledStruct.ledMode[1] = 0x2221;
+ wd->ledStruct.ledMode[0] = 0x2221;
+ wd->ledStruct.ledMode[1] = 0x2221;
- zfTimerInit(dev);
+ zfTimerInit(dev);
- ZM_PERFORMANCE_INIT(dev);
+ ZM_PERFORMANCE_INIT(dev);
- zfBssInfoCreate(dev);
- zfScanMgrInit(dev);
- zfPowerSavingMgrInit(dev);
+ zfBssInfoCreate(dev);
+ zfScanMgrInit(dev);
+ zfPowerSavingMgrInit(dev);
#if 0
- /* Test code */
- {
- u32_t key[4] = {0xffffffff, 0xff, 0, 0};
- u16_t addr[3] = {0x8000, 0x01ab, 0x0000};
- //zfSetKey(dev, 0, 0, ZM_WEP64, addr, key);
- //zfSetKey(dev, 0, 0, ZM_AES, addr, key);
- //zfSetKey(dev, 64, 0, 1, wd->macAddr, key);
- }
+ /* Test code */
+ {
+ u32_t key[4] = {0xffffffff, 0xff, 0, 0};
+ u16_t addr[3] = {0x8000, 0x01ab, 0x0000};
+ /*zfSetKey(dev, 0, 0, ZM_WEP64, addr, key);
+ zfSetKey(dev, 0, 0, ZM_AES, addr, key);
+ zfSetKey(dev, 64, 0, 1, wd->macAddr, key);
+ */
+ }
#endif
- // WME settings
- wd->ws.staWmeEnabled = 1; // Enable WME by default
- #define ZM_UAPSD_Q_SIZE 32 //2^N
- wd->ap.uapsdQ = zfQueueCreate(dev, ZM_UAPSD_Q_SIZE);
- zm_assert(wd->ap.uapsdQ != NULL);
- wd->sta.uapsdQ = zfQueueCreate(dev, ZM_UAPSD_Q_SIZE);
- zm_assert(wd->sta.uapsdQ != NULL);
+ /* WME settings */
+ wd->ws.staWmeEnabled = 1; /* Enable WME by default */
+#define ZM_UAPSD_Q_SIZE 32 /* 2^N */
+ wd->ap.uapsdQ = zfQueueCreate(dev, ZM_UAPSD_Q_SIZE);
+ zm_assert(wd->ap.uapsdQ != NULL);
+ wd->sta.uapsdQ = zfQueueCreate(dev, ZM_UAPSD_Q_SIZE);
+ zm_assert(wd->sta.uapsdQ != NULL);
- //zfHpInit(dev, wd->frequency);
+ /* zfHpInit(dev, wd->frequency); */
- /* MAC address */
- //zfHpSetMacAddress(dev, wd->macAddr, 0);
- zfHpGetMacAddress(dev);
+ /* MAC address */
+ /* zfHpSetMacAddress(dev, wd->macAddr, 0); */
+ zfHpGetMacAddress(dev);
- zfCoreSetFrequency(dev, wd->frequency);
+ zfCoreSetFrequency(dev, wd->frequency);
#if ZM_PCI_LOOP_BACK == 1
- zfwWriteReg(dev, ZM_REG_PCI_CONTROL, 6);
+ zfwWriteReg(dev, ZM_REG_PCI_CONTROL, 6);
#endif /* #if ZM_PCI_LOOP_BACK == 1 */
- //zfiWlanSetDot11DMode(dev , 1); // Enable 802.11d
- //zfiWlanSetDot11HDFSMode(dev , 1); // Enable 802.11h DFS
- wd->sta.DFSEnable = 1;
- wd->sta.capability[1] |= ZM_BIT_0;
+ /* zfiWlanSetDot11DMode(dev , 1); // Enable 802.11d */
+ /* zfiWlanSetDot11HDFSMode(dev , 1); // Enable 802.11h DFS */
+ wd->sta.DFSEnable = 1;
+ wd->sta.capability[1] |= ZM_BIT_0;
- //zfiWlanSetFrequency(dev, 5260000, TRUE);
- //zfiWlanSetAniMode(dev , 1); // Enable ANI
+ /* zfiWlanSetFrequency(dev, 5260000, TRUE); */
+ /* zfiWlanSetAniMode(dev , 1); // Enable ANI */
- /* Trgger Rx DMA */
- zfHpStartRecv(dev);
+ /* Trgger Rx DMA */
+ zfHpStartRecv(dev);
- zm_debug_msg0("end");
+ zm_debug_msg0("end");
- return 0;
+ return 0;
}
/* WLAN hardware will be shutdown and all resource will be release */
-u16_t zfiWlanClose(zdev_t* dev)
+u16_t zfiWlanClose(zdev_t *dev)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- zm_msg0_init(ZM_LV_0, "enter");
+ zm_msg0_init(ZM_LV_0, "enter");
- wd->state = ZM_WLAN_STATE_CLOSEDED;
+ wd->state = ZM_WLAN_STATE_CLOSEDED;
- //zfiWlanDisable(dev, 1);
- zfWlanReset(dev);
+ /* zfiWlanDisable(dev, 1); */
+ zfWlanReset(dev);
- zfHpStopRecv(dev);
+ zfHpStopRecv(dev);
- /* Disable MAC */
- /* Disable PHY */
- /* Disable RF */
+ /* Disable MAC */
+ /* Disable PHY */
+ /* Disable RF */
- zfHpRelease(dev);
+ zfHpRelease(dev);
- zfQueueDestroy(dev, wd->ap.uapsdQ);
- zfQueueDestroy(dev, wd->sta.uapsdQ);
+ zfQueueDestroy(dev, wd->ap.uapsdQ);
+ zfQueueDestroy(dev, wd->sta.uapsdQ);
- zfBssInfoDestroy(dev);
+ zfBssInfoDestroy(dev);
#ifdef ZM_ENABLE_AGGREGATION
- /* add by honda */
- zfAggRxFreeBuf(dev, 1); //1 for release structure memory
- /* end of add by honda */
+ /* add by honda */
+ zfAggRxFreeBuf(dev, 1); /* 1 for release structure memory */
+ /* end of add by honda */
#endif
- zm_msg0_init(ZM_LV_0, "exit");
+ zm_msg0_init(ZM_LV_0, "exit");
- return 0;
+ return 0;
}
-void zfGetWrapperSetting(zdev_t* dev)
+void zfGetWrapperSetting(zdev_t *dev)
{
- u8_t bPassive;
- u16_t vapId = 0;
+ u8_t bPassive;
+ u16_t vapId = 0;
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- zmw_declare_for_critical_section();
+ zmw_declare_for_critical_section();
#if 0
- if ( (wd->ws.countryIsoName[0] != 0)
- || (wd->ws.countryIsoName[1] != 0)
- || (wd->ws.countryIsoName[2] != '\0') )
- {
- zfHpGetRegulationTablefromRegionCode(
- dev,
- zfHpGetRegionCodeFromIsoName(dev, wd->ws.countryIsoName) );
- }
+ if ((wd->ws.countryIsoName[0] != 0)
+ || (wd->ws.countryIsoName[1] != 0)
+ || (wd->ws.countryIsoName[2] != '\0')) {
+ zfHpGetRegulationTablefromRegionCode(dev,
+ zfHpGetRegionCodeFromIsoName(dev, wd->ws.countryIsoName));
+ }
#endif
- zmw_enter_critical_section(dev);
-
- wd->wlanMode = wd->ws.wlanMode;
-
- /* set channel */
- if ( wd->ws.frequency )
- {
- wd->frequency = wd->ws.frequency;
- wd->ws.frequency = 0;
- }
- else
- {
- wd->frequency = zfChGetFirstChannel(dev, &bPassive);
-
- if ( wd->wlanMode == ZM_MODE_IBSS )
- {
- if (wd->ws.adhocMode == ZM_ADHOCBAND_A)
- {
- wd->frequency = ZM_CH_A_36;
- }
- else
- {
- wd->frequency = ZM_CH_G_6;
- }
- }
- }
+ zmw_enter_critical_section(dev);
+
+ wd->wlanMode = wd->ws.wlanMode;
+
+ /* set channel */
+ if (wd->ws.frequency) {
+ wd->frequency = wd->ws.frequency;
+ wd->ws.frequency = 0;
+ } else {
+ wd->frequency = zfChGetFirstChannel(dev, &bPassive);
+
+ if (wd->wlanMode == ZM_MODE_IBSS) {
+ if (wd->ws.adhocMode == ZM_ADHOCBAND_A)
+ wd->frequency = ZM_CH_A_36;
+ else
+ wd->frequency = ZM_CH_G_6;
+ }
+ }
#ifdef ZM_AP_DEBUG
- /* honda add for debug, 2437 channel 6, 2452 channel 9 */
- wd->frequency = 2437;
- /* end of add by honda */
+ /* honda add for debug, 2437 channel 6, 2452 channel 9 */
+ wd->frequency = 2437;
+ /* end of add by honda */
#endif
- /* set preamble type */
- switch (wd->ws.preambleType)
- {
- case ZM_PREAMBLE_TYPE_AUTO:
- case ZM_PREAMBLE_TYPE_SHORT:
- case ZM_PREAMBLE_TYPE_LONG:
- wd->preambleType = wd->ws.preambleType;
- break;
- default:
- wd->preambleType = ZM_PREAMBLE_TYPE_SHORT;
- break;
- }
- wd->ws.preambleType = 0;
-
- if ( wd->wlanMode == ZM_MODE_AP )
- {
- vapId = zfwGetVapId(dev);
-
- if (vapId == 0xffff)
- {
- wd->ap.authAlgo[0] = wd->ws.authMode;
- wd->ap.encryMode[0] = wd->ws.encryMode;
- }
- else
- {
- wd->ap.authAlgo[vapId + 1] = wd->ws.authMode;
- wd->ap.encryMode[vapId + 1] = wd->ws.encryMode;
- }
- wd->ws.authMode = 0;
- wd->ws.encryMode = ZM_NO_WEP;
-
- /* Get beaconInterval from WrapperSetting */
- if ((wd->ws.beaconInterval >= 20) && (wd->ws.beaconInterval <= 1000))
- {
- wd->beaconInterval = wd->ws.beaconInterval;
- }
- else
- {
- wd->beaconInterval = 100; //100ms
- }
-
- if (wd->ws.dtim > 0)
- {
- wd->dtim = wd->ws.dtim;
- }
- else
- {
- wd->dtim = 1;
- }
-
- wd->ap.qosMode = wd->ws.apWmeEnabled & 0x1;
- wd->ap.uapsdEnabled = (wd->ws.apWmeEnabled & 0x2) >> 1;
- }
- else
- {
- wd->sta.authMode = wd->ws.authMode;
- wd->sta.currentAuthMode = wd->ws.authMode;
- wd->sta.wepStatus = wd->ws.wepStatus;
-
- if ( wd->ws.beaconInterval )
- {
- wd->beaconInterval = wd->ws.beaconInterval;
- }
- else
- {
- wd->beaconInterval = 0x64;
- }
-
- if ( wd->wlanMode == ZM_MODE_IBSS )
- {
- /* 1. Set default channel 6 (2437MHz) */
-// wd->frequency = 2437;
-
- /* 2. Otus support 802.11g Mode */
- if ((wd->ws.adhocMode == ZM_ADHOCBAND_G) ||
- (wd->ws.adhocMode == ZM_ADHOCBAND_BG) ||
- (wd->ws.adhocMode == ZM_ADHOCBAND_ABG) ) {
- wd->wfc.bIbssGMode = 1;
- } else {
- wd->wfc.bIbssGMode = 0;
- }
-
- /* 3. set short preamble */
- //wd->sta.preambleType = ZM_PREAMBLE_TYPE_SHORT ;
- }
-
- /* set ATIM window */
- if ( wd->ws.atimWindow )
- {
- wd->sta.atimWindow = wd->ws.atimWindow;
- }
- else
- {
- //wd->sta.atimWindow = 0x0a;
- wd->sta.atimWindow = 0;
- }
-
- //wd->sta.connectingHiddenAP = 1;//wd->ws.connectingHiddenAP;
- wd->sta.dropUnencryptedPkts = wd->ws.dropUnencryptedPkts;
- wd->sta.ibssJoinOnly = wd->ws.ibssJoinOnly;
-
- if ( wd->ws.bDesiredBssid )
- {
- zfMemoryCopy(wd->sta.desiredBssid, wd->ws.desiredBssid, 6);
- wd->sta.bDesiredBssid = TRUE;
- wd->ws.bDesiredBssid = FALSE;
- }
- else
- {
- wd->sta.bDesiredBssid = FALSE;
- }
-
- /* check ssid */
- if ( wd->ws.ssidLen != 0 )
- {
- if ( (!zfMemoryIsEqual(wd->ws.ssid, wd->sta.ssid,
- wd->sta.ssidLen))||
- (wd->ws.ssidLen != wd->sta.ssidLen)||
- (wd->sta.authMode == ZM_AUTH_MODE_WPA)||
- (wd->sta.authMode == ZM_AUTH_MODE_WPAPSK) ||
- (wd->ws.staWmeQosInfo!= 0) )
- {
- /*if u-APSD test(set QosInfo), clear connectByReasso to do association (not reassociation)*/
- wd->sta.connectByReasso = FALSE;
- wd->sta.failCntOfReasso = 0;
- wd->sta.pmkidInfo.bssidCount = 0;
-
- wd->sta.ssidLen = wd->ws.ssidLen;
- zfMemoryCopy(wd->sta.ssid, wd->ws.ssid, wd->sta.ssidLen);
-
- if ( wd->sta.ssidLen < 32 )
- {
- wd->sta.ssid[wd->sta.ssidLen] = 0;
- }
- }
- }
- else
- { /* ANY BSS */
- wd->sta.ssid[0] = 0;
- wd->sta.ssidLen = 0;
- }
-
- wd->sta.wmeEnabled = wd->ws.staWmeEnabled;
- wd->sta.wmeQosInfo = wd->ws.staWmeQosInfo;
-
- }
-
- zmw_leave_critical_section(dev);
+ /* set preamble type */
+ switch (wd->ws.preambleType) {
+ case ZM_PREAMBLE_TYPE_AUTO:
+ case ZM_PREAMBLE_TYPE_SHORT:
+ case ZM_PREAMBLE_TYPE_LONG:
+ wd->preambleType = wd->ws.preambleType;
+ break;
+ default:
+ wd->preambleType = ZM_PREAMBLE_TYPE_SHORT;
+ break;
+ }
+ wd->ws.preambleType = 0;
+
+ if (wd->wlanMode == ZM_MODE_AP) {
+ vapId = zfwGetVapId(dev);
+
+ if (vapId == 0xffff) {
+ wd->ap.authAlgo[0] = wd->ws.authMode;
+ wd->ap.encryMode[0] = wd->ws.encryMode;
+ } else {
+ wd->ap.authAlgo[vapId + 1] = wd->ws.authMode;
+ wd->ap.encryMode[vapId + 1] = wd->ws.encryMode;
+ }
+ wd->ws.authMode = 0;
+ wd->ws.encryMode = ZM_NO_WEP;
+
+ /* Get beaconInterval from WrapperSetting */
+ if ((wd->ws.beaconInterval >= 20) &&
+ (wd->ws.beaconInterval <= 1000))
+ wd->beaconInterval = wd->ws.beaconInterval;
+ else
+ wd->beaconInterval = 100; /* 100ms */
+
+ if (wd->ws.dtim > 0)
+ wd->dtim = wd->ws.dtim;
+ else
+ wd->dtim = 1;
+
+
+ wd->ap.qosMode = wd->ws.apWmeEnabled & 0x1;
+ wd->ap.uapsdEnabled = (wd->ws.apWmeEnabled & 0x2) >> 1;
+ } else {
+ wd->sta.authMode = wd->ws.authMode;
+ wd->sta.currentAuthMode = wd->ws.authMode;
+ wd->sta.wepStatus = wd->ws.wepStatus;
+
+ if (wd->ws.beaconInterval)
+ wd->beaconInterval = wd->ws.beaconInterval;
+ else
+ wd->beaconInterval = 0x64;
+
+ if (wd->wlanMode == ZM_MODE_IBSS) {
+ /* 1. Set default channel 6 (2437MHz) */
+ /* wd->frequency = 2437; */
+
+ /* 2. Otus support 802.11g Mode */
+ if ((wd->ws.adhocMode == ZM_ADHOCBAND_G) ||
+ (wd->ws.adhocMode == ZM_ADHOCBAND_BG) ||
+ (wd->ws.adhocMode == ZM_ADHOCBAND_ABG))
+ wd->wfc.bIbssGMode = 1;
+ else
+ wd->wfc.bIbssGMode = 0;
+
+ /* 3. set short preamble */
+ /* wd->sta.preambleType = ZM_PREAMBLE_TYPE_SHORT; */
+ }
+
+ /* set ATIM window */
+ if (wd->ws.atimWindow)
+ wd->sta.atimWindow = wd->ws.atimWindow;
+ else {
+ /* wd->sta.atimWindow = 0x0a; */
+ wd->sta.atimWindow = 0;
+ }
+
+ /* wd->sta.connectingHiddenAP = 1;
+ wd->ws.connectingHiddenAP;
+ */
+ wd->sta.dropUnencryptedPkts = wd->ws.dropUnencryptedPkts;
+ wd->sta.ibssJoinOnly = wd->ws.ibssJoinOnly;
+
+ if (wd->ws.bDesiredBssid) {
+ zfMemoryCopy(wd->sta.desiredBssid,
+ wd->ws.desiredBssid, 6);
+ wd->sta.bDesiredBssid = TRUE;
+ wd->ws.bDesiredBssid = FALSE;
+ } else
+ wd->sta.bDesiredBssid = FALSE;
+
+ /* check ssid */
+ if (wd->ws.ssidLen != 0) {
+ if ((!zfMemoryIsEqual(wd->ws.ssid, wd->sta.ssid,
+ wd->sta.ssidLen)) ||
+ (wd->ws.ssidLen != wd->sta.ssidLen) ||
+ (wd->sta.authMode == ZM_AUTH_MODE_WPA) ||
+ (wd->sta.authMode == ZM_AUTH_MODE_WPAPSK) ||
+ (wd->ws.staWmeQosInfo != 0)) {
+ /* if u-APSD test(set QosInfo), clear
+ connectByReasso to do association
+ (not reassociation)
+ */
+ wd->sta.connectByReasso = FALSE;
+ wd->sta.failCntOfReasso = 0;
+ wd->sta.pmkidInfo.bssidCount = 0;
+
+ wd->sta.ssidLen = wd->ws.ssidLen;
+ zfMemoryCopy(wd->sta.ssid, wd->ws.ssid,
+ wd->sta.ssidLen);
+
+ if (wd->sta.ssidLen < 32)
+ wd->sta.ssid[wd->sta.ssidLen] = 0;
+ }
+ } else {
+ /* ANY BSS */
+ wd->sta.ssid[0] = 0;
+ wd->sta.ssidLen = 0;
+ }
+
+ wd->sta.wmeEnabled = wd->ws.staWmeEnabled;
+ wd->sta.wmeQosInfo = wd->ws.staWmeQosInfo;
+
+ }
+
+ zmw_leave_critical_section(dev);
}
-u16_t zfWlanEnable(zdev_t* dev)
+u16_t zfWlanEnable(zdev_t *dev)
{
- u8_t bssid[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
- u16_t i;
-
- zmw_get_wlan_dev(dev);
-
- zmw_declare_for_critical_section();
-
- if ( wd->wlanMode == ZM_MODE_UNKNOWN )
- {
- zm_debug_msg0("Unknown Mode...Skip...");
- return 0;
- }
-
- if (wd->wlanMode == ZM_MODE_AP)
- {
- u16_t vapId;
-
- vapId = zfwGetVapId(dev);
-
- if (vapId == 0xffff)
- {
- /* AP mode */
- zfApInitStaTbl(dev);
-
- /* AP default parameters */
- wd->bRate = 0xf;
- wd->gRate = 0xff;
- wd->bRateBasic = 0xf;
- wd->gRateBasic = 0x0;
- //wd->beaconInterval = 100;
- wd->ap.apBitmap = 1;
- wd->ap.beaconCounter = 0;
- //wd->ap.vapNumber = 1; //mark by ygwei for Vap
-
- wd->ap.hideSsid[0] = 0;
- wd->ap.staAgingTimeSec = 10*60;
- wd->ap.staProbingTimeSec = 60;
-
- for (i=0; i<ZM_MAX_AP_SUPPORT; i++)
- {
- wd->ap.bcmcHead[i] = wd->ap.bcmcTail[i] = 0;
- }
-
- //wd->ap.uniHead = wd->ap.uniTail = 0;
-
- /* load AP parameters */
- wd->bRateBasic = wd->ws.bRateBasic;
- wd->gRateBasic = wd->ws.gRateBasic;
- wd->bgMode = wd->ws.bgMode;
- if ((wd->ws.ssidLen <= 32) && (wd->ws.ssidLen != 0))
- {
- wd->ap.ssidLen[0] = wd->ws.ssidLen;
- for(i=0; i<wd->ws.ssidLen; i++)
- {
- wd->ap.ssid[0][i] = wd->ws.ssid[i];
- }
- wd->ws.ssidLen = 0; // Reset Wrapper Variable
- }
-
- if (wd->ap.encryMode[0] == 0)
- {
- wd->ap.capab[0] = 0x001;
- }
- else
- {
- wd->ap.capab[0] = 0x011;
- }
- /* set Short Slot Time bit if not 11b */
- if (wd->ap.wlanType[0] != ZM_WLAN_TYPE_PURE_B)
- {
- wd->ap.capab[0] |= 0x400;
- }
-
- // wd->ap.vapNumber = 1; // mark by ygwei for Vap Test
- }
- else
- {
+ u8_t bssid[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
+ u16_t i;
+
+ zmw_get_wlan_dev(dev);
+
+ zmw_declare_for_critical_section();
+
+ if (wd->wlanMode == ZM_MODE_UNKNOWN) {
+ zm_debug_msg0("Unknown Mode...Skip...");
+ return 0;
+ }
+
+ if (wd->wlanMode == ZM_MODE_AP) {
+ u16_t vapId;
+
+ vapId = zfwGetVapId(dev);
+
+ if (vapId == 0xffff) {
+ /* AP mode */
+ zfApInitStaTbl(dev);
+
+ /* AP default parameters */
+ wd->bRate = 0xf;
+ wd->gRate = 0xff;
+ wd->bRateBasic = 0xf;
+ wd->gRateBasic = 0x0;
+ /* wd->beaconInterval = 100; */
+ wd->ap.apBitmap = 1;
+ wd->ap.beaconCounter = 0;
+ /* wd->ap.vapNumber = 1; //mark by ygwei for Vap */
+
+ wd->ap.hideSsid[0] = 0;
+ wd->ap.staAgingTimeSec = 10*60;
+ wd->ap.staProbingTimeSec = 60;
+
+ for (i = 0; i < ZM_MAX_AP_SUPPORT; i++)
+ wd->ap.bcmcHead[i] = wd->ap.bcmcTail[i] = 0;
+
+ /* wd->ap.uniHead = wd->ap.uniTail = 0; */
+
+ /* load AP parameters */
+ wd->bRateBasic = wd->ws.bRateBasic;
+ wd->gRateBasic = wd->ws.gRateBasic;
+ wd->bgMode = wd->ws.bgMode;
+ if ((wd->ws.ssidLen <= 32) && (wd->ws.ssidLen != 0)) {
+ wd->ap.ssidLen[0] = wd->ws.ssidLen;
+ for (i = 0; i < wd->ws.ssidLen; i++)
+ wd->ap.ssid[0][i] = wd->ws.ssid[i];
+ wd->ws.ssidLen = 0; /* Reset Wrapper Variable */
+ }
+
+ if (wd->ap.encryMode[0] == 0)
+ wd->ap.capab[0] = 0x001;
+ else
+ wd->ap.capab[0] = 0x011;
+ /* set Short Slot Time bit if not 11b */
+ if (wd->ap.wlanType[0] != ZM_WLAN_TYPE_PURE_B)
+ wd->ap.capab[0] |= 0x400;
+
+ /* wd->ap.vapNumber = 1; //mark by ygwei for Vap Test */
+ } else {
#if 0
- /* VAP Test Code */
- wd->ap.apBitmap = 0x3;
- wd->ap.capab[1] = 0x401;
- wd->ap.ssidLen[1] = 4;
- wd->ap.ssid[1][0] = 'v';
- wd->ap.ssid[1][1] = 'a';
- wd->ap.ssid[1][2] = 'p';
- wd->ap.ssid[1][3] = '1';
- wd->ap.authAlgo[1] = wd->ws.authMode;
- wd->ap.encryMode[1] = wd->ws.encryMode;
- wd->ap.vapNumber = 2;
+ /* VAP Test Code */
+ wd->ap.apBitmap = 0x3;
+ wd->ap.capab[1] = 0x401;
+ wd->ap.ssidLen[1] = 4;
+ wd->ap.ssid[1][0] = 'v';
+ wd->ap.ssid[1][1] = 'a';
+ wd->ap.ssid[1][2] = 'p';
+ wd->ap.ssid[1][3] = '1';
+ wd->ap.authAlgo[1] = wd->ws.authMode;
+ wd->ap.encryMode[1] = wd->ws.encryMode;
+ wd->ap.vapNumber = 2;
#else
- /* VAP Test Code */
- wd->ap.apBitmap = 0x1 | (0x01 << (vapId+1));
-
- if ((wd->ws.ssidLen <= 32) && (wd->ws.ssidLen != 0))
- {
- wd->ap.ssidLen[vapId+1] = wd->ws.ssidLen;
- for(i=0; i<wd->ws.ssidLen; i++)
- {
- wd->ap.ssid[vapId+1][i] = wd->ws.ssid[i];
- }
- wd->ws.ssidLen = 0; // Reset Wrapper Variable
- }
-
- if (wd->ap.encryMode[vapId+1] == 0)
- {
- wd->ap.capab[vapId+1] = 0x401;
- }
- else
- {
- wd->ap.capab[vapId+1] = 0x411;
- }
-
- wd->ap.authAlgo[vapId+1] = wd->ws.authMode;
- wd->ap.encryMode[vapId+1] = wd->ws.encryMode;
-
- /* Need to be modified when VAP is used */
- //wd->ap.vapNumber = 2;
+ /* VAP Test Code */
+ wd->ap.apBitmap = 0x1 | (0x01 << (vapId+1));
+
+ if ((wd->ws.ssidLen <= 32) && (wd->ws.ssidLen != 0)) {
+ wd->ap.ssidLen[vapId+1] = wd->ws.ssidLen;
+ for (i = 0; i < wd->ws.ssidLen; i++)
+ wd->ap.ssid[vapId+1][i] =
+ wd->ws.ssid[i];
+ wd->ws.ssidLen = 0; /* Reset Wrapper Variable */
+ }
+
+ if (wd->ap.encryMode[vapId+1] == 0)
+ wd->ap.capab[vapId+1] = 0x401;
+ else
+ wd->ap.capab[vapId+1] = 0x411;
+
+ wd->ap.authAlgo[vapId+1] = wd->ws.authMode;
+ wd->ap.encryMode[vapId+1] = wd->ws.encryMode;
+
+ /* Need to be modified when VAP is used */
+ /* wd->ap.vapNumber = 2; */
#endif
- }
-
- wd->ap.vapNumber++;
-
- zfCoreSetFrequency(dev, wd->frequency);
-
- zfInitMacApMode(dev);
-
- /* Disable protection mode */
- zfApSetProtectionMode(dev, 0);
-
- zfApSendBeacon(dev);
- } /*if (wd->wlanMode == ZM_MODE_AP) */
- else
- {
- zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_INTERNAL);
- zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_EXTERNAL);
-
- zmw_enter_critical_section(dev);
- wd->sta.oppositeCount = 0; /* reset opposite count */
- //wd->sta.bAutoReconnect = wd->sta.bAutoReconnectEnabled;
- //wd->sta.scanWithSSID = 0;
- zfStaInitOppositeInfo(dev);
- zmw_leave_critical_section(dev);
-
- zfStaResetStatus(dev, 0);
-
- if ( (wd->sta.cmDisallowSsidLength != 0)&&
- (wd->sta.ssidLen == wd->sta.cmDisallowSsidLength)&&
- (zfMemoryIsEqual(wd->sta.ssid, wd->sta.cmDisallowSsid,
- wd->sta.ssidLen)) &&
- (wd->sta.wepStatus == ZM_ENCRYPTION_TKIP))
- { /* countermeasures */
- zm_debug_msg0("countermeasures disallow association");
-
- }
- else
- {
- switch( wd->wlanMode )
- {
- case ZM_MODE_IBSS:
- /* some registers may be set here */
- if ( wd->sta.authMode == ZM_AUTH_MODE_WPA2PSK )
- {
- zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_IBSS_WPA2PSK);
- }
- else
- {
- zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_IBSS_GENERAL);
- }
-
- zm_msg0_mm(ZM_LV_0, "ZM_MODE_IBSS");
- zfIbssConnectNetwork(dev);
- break;
-
- case ZM_MODE_INFRASTRUCTURE:
- /* some registers may be set here */
- zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_STA);
-
- zfInfraConnectNetwork(dev);
- break;
-
- case ZM_MODE_PSEUDO:
- /* some registers may be set here */
- zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_STA);
-
- zfUpdateBssid(dev, bssid);
- zfCoreSetFrequency(dev, wd->frequency);
- break;
-
- default:
- break;
- }
- }
-
- }
-
-
- //if ( (wd->wlanMode != ZM_MODE_INFRASTRUCTURE)&&
- // (wd->wlanMode != ZM_MODE_AP) )
- if ( wd->wlanMode == ZM_MODE_PSEUDO )
- {
- /* Reset Wlan status */
- zfWlanReset(dev);
-
- if (wd->zfcbConnectNotify != NULL)
- {
- wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECT, wd->sta.bssid);
- }
- zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED);
- }
-
-
- if(wd->wlanMode == ZM_MODE_AP)
- {
- if (wd->zfcbConnectNotify != NULL)
- {
- wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECT, wd->sta.bssid);
- }
- //zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED);
- }
-
- // Assign default Tx Rate
- if ( wd->sta.EnableHT )
- {
+ }
+
+ wd->ap.vapNumber++;
+
+ zfCoreSetFrequency(dev, wd->frequency);
+
+ zfInitMacApMode(dev);
+
+ /* Disable protection mode */
+ zfApSetProtectionMode(dev, 0);
+
+ zfApSendBeacon(dev);
+ } else { /*if (wd->wlanMode == ZM_MODE_AP) */
+
+ zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_INTERNAL);
+ zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_EXTERNAL);
+
+ zmw_enter_critical_section(dev);
+ wd->sta.oppositeCount = 0; /* reset opposite count */
+ /* wd->sta.bAutoReconnect = wd->sta.bAutoReconnectEnabled; */
+ /* wd->sta.scanWithSSID = 0; */
+ zfStaInitOppositeInfo(dev);
+ zmw_leave_critical_section(dev);
+
+ zfStaResetStatus(dev, 0);
+
+ if ((wd->sta.cmDisallowSsidLength != 0) &&
+ (wd->sta.ssidLen == wd->sta.cmDisallowSsidLength) &&
+ (zfMemoryIsEqual(wd->sta.ssid, wd->sta.cmDisallowSsid,
+ wd->sta.ssidLen)) &&
+ (wd->sta.wepStatus == ZM_ENCRYPTION_TKIP)) {/*countermeasures*/
+ zm_debug_msg0("countermeasures disallow association");
+ } else {
+ switch (wd->wlanMode) {
+ case ZM_MODE_IBSS:
+ /* some registers may be set here */
+ if (wd->sta.authMode == ZM_AUTH_MODE_WPA2PSK)
+ zfHpSetApStaMode(dev,
+ ZM_HAL_80211_MODE_IBSS_WPA2PSK);
+ else
+ zfHpSetApStaMode(dev,
+ ZM_HAL_80211_MODE_IBSS_GENERAL);
+
+ zm_msg0_mm(ZM_LV_0, "ZM_MODE_IBSS");
+ zfIbssConnectNetwork(dev);
+ break;
+
+ case ZM_MODE_INFRASTRUCTURE:
+ /* some registers may be set here */
+ zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_STA);
+
+ zfInfraConnectNetwork(dev);
+ break;
+
+ case ZM_MODE_PSEUDO:
+ /* some registers may be set here */
+ zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_STA);
+
+ zfUpdateBssid(dev, bssid);
+ zfCoreSetFrequency(dev, wd->frequency);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+
+ /* if ((wd->wlanMode != ZM_MODE_INFRASTRUCTURE) &&
+ (wd->wlanMode != ZM_MODE_AP))
+ */
+ if (wd->wlanMode == ZM_MODE_PSEUDO) {
+ /* Reset Wlan status */
+ zfWlanReset(dev);
+
+ if (wd->zfcbConnectNotify != NULL)
+ wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECT,
+ wd->sta.bssid);
+ zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED);
+ }
+
+
+ if (wd->wlanMode == ZM_MODE_AP) {
+ if (wd->zfcbConnectNotify != NULL)
+ wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECT,
+ wd->sta.bssid);
+ /* zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED); */
+ }
+
+ /* Assign default Tx Rate */
+ if (wd->sta.EnableHT) {
u32_t oneTxStreamCap;
- oneTxStreamCap = (zfHpCapability(dev) & ZM_HP_CAP_11N_ONE_TX_STREAM);
- if(oneTxStreamCap)
+ oneTxStreamCap = (zfHpCapability(dev) &
+ ZM_HP_CAP_11N_ONE_TX_STREAM);
+ if (oneTxStreamCap)
wd->CurrentTxRateKbps = 135000;
else
wd->CurrentTxRateKbps = 270000;
- wd->CurrentRxRateKbps = 270000;
- }
- else
- {
- wd->CurrentTxRateKbps = 54000;
- wd->CurrentRxRateKbps = 54000;
- }
+ wd->CurrentRxRateKbps = 270000;
+ } else {
+ wd->CurrentTxRateKbps = 54000;
+ wd->CurrentRxRateKbps = 54000;
+ }
- wd->state = ZM_WLAN_STATE_ENABLED;
+ wd->state = ZM_WLAN_STATE_ENABLED;
- return 0;
+ return 0;
}
/* Enable/disable Wlan operation */
-u16_t zfiWlanEnable(zdev_t* dev)
+u16_t zfiWlanEnable(zdev_t *dev)
{
- u16_t ret;
+ u16_t ret;
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- zm_msg0_mm(ZM_LV_1, "Enable Wlan");
+ zm_msg0_mm(ZM_LV_1, "Enable Wlan");
- zfGetWrapperSetting(dev);
+ zfGetWrapperSetting(dev);
- zfZeroMemory((u8_t*) &wd->trafTally, sizeof(struct zsTrafTally));
+ zfZeroMemory((u8_t *) &wd->trafTally, sizeof(struct zsTrafTally));
+
+ /* Reset cmMicFailureCount to 0 for new association request */
+ if (wd->sta.cmMicFailureCount == 1) {
+ zfTimerCancel(dev, ZM_EVENT_CM_TIMER);
+ wd->sta.cmMicFailureCount = 0;
+ }
- // Reset cmMicFailureCount to 0 for new association request
- if ( wd->sta.cmMicFailureCount == 1 )
- {
- zfTimerCancel(dev, ZM_EVENT_CM_TIMER);
- wd->sta.cmMicFailureCount = 0;
- }
+ zfFlushVtxq(dev);
+ if ((wd->queueFlushed & 0x10) != 0)
+ zfHpUsbReset(dev);
- zfFlushVtxq(dev);
- if ((wd->queueFlushed & 0x10) != 0)
- {
- zfHpUsbReset(dev);
- }
- ret = zfWlanEnable(dev);
+ ret = zfWlanEnable(dev);
- return ret;
+ return ret;
}
/* Add a flag named ResetKeyCache to show if KeyCache should be cleared.
for hostapd in AP mode, if driver receives iwconfig ioctl
- after setting group key, it shouldn't clear KeyCache. */
-u16_t zfiWlanDisable(zdev_t* dev, u8_t ResetKeyCache)
+ after setting group key, it shouldn't clear KeyCache.
+*/
+u16_t zfiWlanDisable(zdev_t *dev, u8_t ResetKeyCache)
{
- u16_t i;
- u8_t isConnected;
+ u16_t i;
+ u8_t isConnected;
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
#ifdef ZM_ENABLE_IBSS_WPA2PSK
- zmw_declare_for_critical_section();
+ zmw_declare_for_critical_section();
#endif
- wd->state = ZM_WLAN_STATE_DISABLED;
-
- zm_msg0_mm(ZM_LV_1, "Disable Wlan");
-
- if ( wd->wlanMode != ZM_MODE_AP )
- {
- isConnected = zfStaIsConnected(dev);
-
- if ( (wd->wlanMode == ZM_MODE_INFRASTRUCTURE)&&
- (wd->sta.currentAuthMode != ZM_AUTH_MODE_WPA2) )
- {
- /* send deauthentication frame */
- if (isConnected)
- {
- //zfiWlanDeauth(dev, NULL, 0);
- zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, wd->sta.bssid, 3, 0, 0);
- //zmw_debug_msg0("send a Deauth frame!");
- }
- }
-
- // Remove all the connected peer stations
- if ( wd->wlanMode == ZM_MODE_IBSS )
- {
- wd->sta.ibssBssIsCreator = 0;
- zfTimerCancel(dev, ZM_EVENT_IBSS_MONITOR);
- zfStaIbssMonitoring(dev, 1);
- }
+ wd->state = ZM_WLAN_STATE_DISABLED;
+
+ zm_msg0_mm(ZM_LV_1, "Disable Wlan");
+
+ if (wd->wlanMode != ZM_MODE_AP) {
+ isConnected = zfStaIsConnected(dev);
+
+ if ((wd->wlanMode == ZM_MODE_INFRASTRUCTURE) &&
+ (wd->sta.currentAuthMode != ZM_AUTH_MODE_WPA2)) {
+ /* send deauthentication frame */
+ if (isConnected) {
+ /* zfiWlanDeauth(dev, NULL, 0); */
+ zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH,
+ wd->sta.bssid, 3, 0, 0);
+ /* zmw_debug_msg0("send a Deauth frame!"); */
+ }
+ }
+
+ /* Remove all the connected peer stations */
+ if (wd->wlanMode == ZM_MODE_IBSS) {
+ wd->sta.ibssBssIsCreator = 0;
+ zfTimerCancel(dev, ZM_EVENT_IBSS_MONITOR);
+ zfStaIbssMonitoring(dev, 1);
+ }
#ifdef ZM_ENABLE_IBSS_WPA2PSK
- zmw_enter_critical_section(dev);
- wd->sta.ibssWpa2Psk = 0;
- zmw_leave_critical_section(dev);
+ zmw_enter_critical_section(dev);
+ wd->sta.ibssWpa2Psk = 0;
+ zmw_leave_critical_section(dev);
#endif
- wd->sta.wpaState = ZM_STA_WPA_STATE_INIT;
-
- /* reset connect timeout counter */
- wd->sta.connectTimeoutCount = 0;
-
- /* reset connectState to None */
- wd->sta.connectState = ZM_STA_CONN_STATE_NONE;
-
- /* reset leap enable variable */
- wd->sta.leapEnabled = 0;
-
- /* Disable the RIFS Status / RIFS-like frame count / RIFS count */
- if( wd->sta.rifsState == ZM_RIFS_STATE_DETECTED )
- zfHpDisableRifs(dev);
- wd->sta.rifsState = ZM_RIFS_STATE_DETECTING;
- wd->sta.rifsLikeFrameCnt = 0;
- wd->sta.rifsCount = 0;
-
- wd->sta.osRxFilter = 0;
- wd->sta.bSafeMode = 0;
-
- zfChangeAdapterState(dev, ZM_STA_STATE_DISCONNECT);
- if (ResetKeyCache)
- zfHpResetKeyCache(dev);
-
- if (isConnected)
- {
- if (wd->zfcbConnectNotify != NULL)
- {
- wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECTION_DISABLED, wd->sta.bssid);
- }
- }
- else
- {
- if (wd->zfcbConnectNotify != NULL)
- {
- wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_DISABLED, wd->sta.bssid);
- }
- }
- }
- else //if (wd->wlanMode == ZM_MODE_AP)
- {
- for (i=0; i<ZM_MAX_STA_SUPPORT; i++)
- {
- /* send deauthentication frame */
- if (wd->ap.staTable[i].valid == 1)
- {
- /* Reason : Sending station is leaving */
- zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH,
- wd->ap.staTable[i].addr, 3, 0, 0);
- }
- }
-
- if (ResetKeyCache)
- zfHpResetKeyCache(dev);
-
- wd->ap.vapNumber--;
- }
-
- /* stop beacon */
- zfHpDisableBeacon(dev);
-
- /* Flush VTxQ and MmQ */
- zfFlushVtxq(dev);
- /* Flush AP PS queues */
- zfApFlushBufferedPsFrame(dev);
- /* Free buffer in defragment list*/
- zfAgingDefragList(dev, 1);
-
- #ifdef ZM_ENABLE_AGGREGATION
- /* add by honda */
- zfAggRxFreeBuf(dev, 0); //1 for release structure memory
- /* end of add by honda */
- #endif
-
- // Clear the information for the peer stations of IBSS or AP of Station mode
- zfZeroMemory((u8_t*)wd->sta.oppositeInfo, sizeof(struct zsOppositeInfo) * ZM_MAX_OPPOSITE_COUNT);
-
- /* Turn off Software WEP/TKIP */
- if (wd->sta.SWEncryptEnable != 0)
- {
- zm_debug_msg0("Disable software encryption");
- zfStaDisableSWEncryption(dev);
- }
-
- /* Improve WEP/TKIP performace with HT AP, detail information please look bug#32495 */
- //zfHpSetTTSIFSTime(dev, 0x8);
-
- return 0;
-}
+ wd->sta.wpaState = ZM_STA_WPA_STATE_INIT;
+
+ /* reset connect timeout counter */
+ wd->sta.connectTimeoutCount = 0;
+
+ /* reset connectState to None */
+ wd->sta.connectState = ZM_STA_CONN_STATE_NONE;
+
+ /* reset leap enable variable */
+ wd->sta.leapEnabled = 0;
+
+ /* Disable the RIFS Status/RIFS-like frame count/RIFS count */
+ if (wd->sta.rifsState == ZM_RIFS_STATE_DETECTED)
+ zfHpDisableRifs(dev);
+ wd->sta.rifsState = ZM_RIFS_STATE_DETECTING;
+ wd->sta.rifsLikeFrameCnt = 0;
+ wd->sta.rifsCount = 0;
+
+ wd->sta.osRxFilter = 0;
+ wd->sta.bSafeMode = 0;
+
+ zfChangeAdapterState(dev, ZM_STA_STATE_DISCONNECT);
+ if (ResetKeyCache)
+ zfHpResetKeyCache(dev);
+
+ if (isConnected) {
+ if (wd->zfcbConnectNotify != NULL)
+ wd->zfcbConnectNotify(dev,
+ ZM_STATUS_MEDIA_CONNECTION_DISABLED,
+ wd->sta.bssid);
+ } else {
+ if (wd->zfcbConnectNotify != NULL)
+ wd->zfcbConnectNotify(dev,
+ ZM_STATUS_MEDIA_DISABLED, wd->sta.bssid);
+ }
+ } else { /* if (wd->wlanMode == ZM_MODE_AP) */
+ for (i = 0; i < ZM_MAX_STA_SUPPORT; i++) {
+ /* send deauthentication frame */
+ if (wd->ap.staTable[i].valid == 1) {
+ /* Reason : Sending station is leaving */
+ zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH,
+ wd->ap.staTable[i].addr, 3, 0, 0);
+ }
+ }
+
+ if (ResetKeyCache)
+ zfHpResetKeyCache(dev);
+
+ wd->ap.vapNumber--;
+ }
-u16_t zfiWlanSuspend(zdev_t* dev)
-{
- zmw_get_wlan_dev(dev);
- zmw_declare_for_critical_section();
+ /* stop beacon */
+ zfHpDisableBeacon(dev);
+
+ /* Flush VTxQ and MmQ */
+ zfFlushVtxq(dev);
+ /* Flush AP PS queues */
+ zfApFlushBufferedPsFrame(dev);
+ /* Free buffer in defragment list*/
+ zfAgingDefragList(dev, 1);
+
+#ifdef ZM_ENABLE_AGGREGATION
+ /* add by honda */
+ zfAggRxFreeBuf(dev, 0); /* 1 for release structure memory */
+ /* end of add by honda */
+#endif
+
+ /* Clear the information for the peer stations
+ of IBSS or AP of Station mode
+ */
+ zfZeroMemory((u8_t *)wd->sta.oppositeInfo,
+ sizeof(struct zsOppositeInfo) * ZM_MAX_OPPOSITE_COUNT);
- // Change the HAL state to init so that any packet can't be transmitted between
- // resume & HAL reinit. This would cause the chip hang issue in OTUS.
- zmw_enter_critical_section(dev);
- wd->halState = ZM_HAL_STATE_INIT;
- zmw_leave_critical_section(dev);
+ /* Turn off Software WEP/TKIP */
+ if (wd->sta.SWEncryptEnable != 0) {
+ zm_debug_msg0("Disable software encryption");
+ zfStaDisableSWEncryption(dev);
+ }
+
+ /* Improve WEP/TKIP performace with HT AP,
+ detail information please look bug#32495 */
+ /* zfHpSetTTSIFSTime(dev, 0x8); */
+
+ return 0;
+}
- return 0;
+u16_t zfiWlanSuspend(zdev_t *dev)
+{
+ zmw_get_wlan_dev(dev);
+ zmw_declare_for_critical_section();
+
+ /* Change the HAL state to init so that any packet
+ can't be transmitted between resume & HAL reinit.
+ This would cause the chip hang issue in OTUS.
+ */
+ zmw_enter_critical_section(dev);
+ wd->halState = ZM_HAL_STATE_INIT;
+ zmw_leave_critical_section(dev);
+
+ return 0;
}
-u16_t zfiWlanResume(zdev_t* dev, u8_t doReconn)
+u16_t zfiWlanResume(zdev_t *dev, u8_t doReconn)
{
- u16_t ret;
- zmw_get_wlan_dev(dev);
- zmw_declare_for_critical_section();
-
- /* Redownload firmware, Reinit MAC,PHY,RF */
- zfHpReinit(dev, wd->frequency);
-
- //Set channel according to AP's configuration
- zfCoreSetFrequencyExV2(dev, wd->frequency, wd->BandWidth40,
- wd->ExtOffset, NULL, 1);
-
- zfHpSetMacAddress(dev, wd->macAddr, 0);
-
- /* Start Rx */
- zfHpStartRecv(dev);
-
- zfFlushVtxq(dev);
-
- if ( wd->wlanMode != ZM_MODE_INFRASTRUCTURE &&
- wd->wlanMode != ZM_MODE_IBSS )
- {
- return 1;
- }
-
- zm_msg0_mm(ZM_LV_1, "Resume Wlan");
- if ( (zfStaIsConnected(dev)) || (zfStaIsConnecting(dev)) )
- {
- if (doReconn == 1)
- {
- zm_msg0_mm(ZM_LV_1, "Re-connect...");
- zmw_enter_critical_section(dev);
- wd->sta.connectByReasso = FALSE;
- zmw_leave_critical_section(dev);
-
- zfWlanEnable(dev);
- }
- else if (doReconn == 0)
- {
- zfHpSetRollCallTable(dev);
- }
- }
-
- ret = 0;
-
- return ret;
+ u16_t ret;
+ zmw_get_wlan_dev(dev);
+ zmw_declare_for_critical_section();
+
+ /* Redownload firmware, Reinit MAC,PHY,RF */
+ zfHpReinit(dev, wd->frequency);
+
+ /* Set channel according to AP's configuration */
+ zfCoreSetFrequencyExV2(dev, wd->frequency, wd->BandWidth40,
+ wd->ExtOffset, NULL, 1);
+
+ zfHpSetMacAddress(dev, wd->macAddr, 0);
+
+ /* Start Rx */
+ zfHpStartRecv(dev);
+
+ zfFlushVtxq(dev);
+
+ if (wd->wlanMode != ZM_MODE_INFRASTRUCTURE &&
+ wd->wlanMode != ZM_MODE_IBSS)
+ return 1;
+
+ zm_msg0_mm(ZM_LV_1, "Resume Wlan");
+ if ((zfStaIsConnected(dev)) || (zfStaIsConnecting(dev))) {
+ if (doReconn == 1) {
+ zm_msg0_mm(ZM_LV_1, "Re-connect...");
+ zmw_enter_critical_section(dev);
+ wd->sta.connectByReasso = FALSE;
+ zmw_leave_critical_section(dev);
+
+ zfWlanEnable(dev);
+ } else if (doReconn == 0)
+ zfHpSetRollCallTable(dev);
+ }
+
+ ret = 0;
+
+ return ret;
}
/************************************************************************/
@@ -1057,235 +979,227 @@ u16_t zfiWlanResume(zdev_t* dev, u8_t doReconn)
/* Stephen Chen Atheros Communications, INC. 2007.1 */
/* */
/************************************************************************/
-void zfiWlanFlushAllQueuedBuffers(zdev_t* dev)
+void zfiWlanFlushAllQueuedBuffers(zdev_t *dev)
{
- /* Flush VTxQ and MmQ */
- zfFlushVtxq(dev);
- /* Flush AP PS queues */
- zfApFlushBufferedPsFrame(dev);
- /* Free buffer in defragment list*/
- zfAgingDefragList(dev, 1);
+ /* Flush VTxQ and MmQ */
+ zfFlushVtxq(dev);
+ /* Flush AP PS queues */
+ zfApFlushBufferedPsFrame(dev);
+ /* Free buffer in defragment list*/
+ zfAgingDefragList(dev, 1);
}
/* Do WLAN site survey */
-u16_t zfiWlanScan(zdev_t* dev)
+u16_t zfiWlanScan(zdev_t *dev)
{
- u16_t ret = 1;
- zmw_get_wlan_dev(dev);
-
- zm_debug_msg0("");
-
- zmw_declare_for_critical_section();
-
- zmw_enter_critical_section(dev);
-
- if (wd->wlanMode == ZM_MODE_AP)
- {
- wd->heartBeatNotification |= ZM_BSSID_LIST_SCAN;
- wd->sta.scanFrequency = 0;
- //wd->sta.pUpdateBssList->bssCount = 0;
- ret = 0;
- }
- else
- {
- #if 0
- if ( !zfStaBlockWlanScan(dev) )
- {
- zm_debug_msg0("scan request");
- //zfTimerSchedule(dev, ZM_EVENT_SCAN, ZM_TICK_ZERO);
- ret = 0;
- goto start_scan;
- }
- #else
- goto start_scan;
- #endif
- }
-
- zmw_leave_critical_section(dev);
-
- return ret;
+ u16_t ret = 1;
+ zmw_get_wlan_dev(dev);
+
+ zm_debug_msg0("");
+
+ zmw_declare_for_critical_section();
+
+ zmw_enter_critical_section(dev);
+
+ if (wd->wlanMode == ZM_MODE_AP) {
+ wd->heartBeatNotification |= ZM_BSSID_LIST_SCAN;
+ wd->sta.scanFrequency = 0;
+ /* wd->sta.pUpdateBssList->bssCount = 0; */
+ ret = 0;
+ } else {
+#if 0
+ if (!zfStaBlockWlanScan(dev)) {
+ zm_debug_msg0("scan request");
+ /*zfTimerSchedule(dev, ZM_EVENT_SCAN, ZM_TICK_ZERO);*/
+ ret = 0;
+ goto start_scan;
+ }
+#else
+ goto start_scan;
+#endif
+ }
+
+ zmw_leave_critical_section(dev);
+
+ return ret;
start_scan:
- zmw_leave_critical_section(dev);
+ zmw_leave_critical_section(dev);
- if(wd->ledStruct.LEDCtrlFlagFromReg & ZM_LED_CTRL_FLAG_ALPHA) // flag for Alpha
- wd->ledStruct.LEDCtrlFlag |= ZM_LED_CTRL_FLAG_ALPHA;
+ if (wd->ledStruct.LEDCtrlFlagFromReg & ZM_LED_CTRL_FLAG_ALPHA) {
+ /* flag for Alpha */
+ wd->ledStruct.LEDCtrlFlag |= ZM_LED_CTRL_FLAG_ALPHA;
+ }
- ret = zfScanMgrScanStart(dev, ZM_SCAN_MGR_SCAN_EXTERNAL);
+ ret = zfScanMgrScanStart(dev, ZM_SCAN_MGR_SCAN_EXTERNAL);
- zm_debug_msg1("ret = ", ret);
+ zm_debug_msg1("ret = ", ret);
- return ret;
+ return ret;
}
-/* rate */
-/* 0 : AUTO */
-/* 1 : CCK 1M */
-/* 2 : CCK 2M */
-/* 3 : CCK 5.5M */
-/* 4 : CCK 11M */
-/* 5 : OFDM 6M */
-/* 6 : OFDM 9M */
-/* 7 : OFDM 12M */
-/* 8 : OFDM 18M */
-/* 9 : OFDM 24M */
-/* 10 : OFDM 36M */
-/* 11 : OFDM 48M */
-/* 12 : OFDM 54M */
-/* 13 : MCS 0 */
-/* 28 : MCS 15 */
+/* rate */
+/* 0 : AUTO */
+/* 1 : CCK 1M */
+/* 2 : CCK 2M */
+/* 3 : CCK 5.5M */
+/* 4 : CCK 11M */
+/* 5 : OFDM 6M */
+/* 6 : OFDM 9M */
+/* 7 : OFDM 12M */
+/* 8 : OFDM 18M */
+/* 9 : OFDM 24M */
+/* 10 : OFDM 36M */
+/* 11 : OFDM 48M */
+/* 12 : OFDM 54M */
+/* 13 : MCS 0 */
+/* 28 : MCS 15 */
u16_t zcRateToMCS[] =
{0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd, 0x8, 0xc};
u16_t zcRateToMT[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
-u16_t zfiWlanSetTxRate(zdev_t* dev, u16_t rate)
-{ // jhlee HT 0
- zmw_get_wlan_dev(dev);
-
- if (rate <=12)
- {
- wd->txMCS = zcRateToMCS[rate];
- wd->txMT = zcRateToMT[rate];
- return ZM_SUCCESS;
- }
- else if ((rate<=28)||(rate==13+32))
- {
- wd->txMCS = rate - 12 - 1;
- wd->txMT = 2;
- return ZM_SUCCESS;
- }
-
- return ZM_ERR_INVALID_TX_RATE;
+u16_t zfiWlanSetTxRate(zdev_t *dev, u16_t rate)
+{
+ /* jhlee HT 0 */
+ zmw_get_wlan_dev(dev);
+
+ if (rate <= 12) {
+ wd->txMCS = zcRateToMCS[rate];
+ wd->txMT = zcRateToMT[rate];
+ return ZM_SUCCESS;
+ } else if ((rate <= 28) || (rate == 13 + 32)) {
+ wd->txMCS = rate - 12 - 1;
+ wd->txMT = 2;
+ return ZM_SUCCESS;
+ }
+
+ return ZM_ERR_INVALID_TX_RATE;
}
const u32_t zcRateIdToKbps40M[] =
- {
- 1000, 2000, 5500, 11000, /* 1M, 2M, 5M, 11M , 0 1 2 3*/
- 6000, 9000, 12000, 18000, /* 6M 9M 12M 18M , 4 5 6 7*/
- 24000, 36000, 48000, 54000, /* 24M 36M 48M 54M , 8 9 10 11*/
- 13500, 27000, 40500, 54000, /* MCS0 MCS1 MCS2 MCS3 , 12 13 14 15*/
- 81000, 108000, 121500, 135000, /* MCS4 MCS5 MCS6 MCS7 , 16 17 18 19*/
- 27000, 54000, 81000, 108000, /* MCS8 MCS9 MCS10 MCS11 , 20 21 22 23*/
- 162000, 216000, 243000, 270000, /* MCS12 MCS13 MCS14 MCS15 , 24 25 26 27*/
- 270000, 300000, 150000 /* MCS14SG, MCS15SG, MCS7SG , 28 29 30*/
- };
+{
+ 1000, 2000, 5500, 11000, /* 1M, 2M, 5M, 11M , 0 1 2 3 */
+ 6000, 9000, 12000, 18000, /* 6M 9M 12M 18M , 4 5 6 7 */
+ 24000, 36000, 48000, 54000, /* 24M 36M 48M 54M , 8 9 10 11 */
+ 13500, 27000, 40500, 54000, /* MCS0 MCS1 MCS2 MCS3 , 12 13 14 15 */
+ 81000, 108000, 121500, 135000, /* MCS4 MCS5 MCS6 MCS7 , 16 17 18 19 */
+ 27000, 54000, 81000, 108000, /* MCS8 MCS9 MCS10 MCS11 , 20 21 22 23 */
+ 162000, 216000, 243000, 270000, /*MCS12 MCS13 MCS14 MCS15, 24 25 26 27*/
+ 270000, 300000, 150000 /* MCS14SG, MCS15SG, MCS7SG , 28 29 30 */
+};
const u32_t zcRateIdToKbps20M[] =
- {
- 1000, 2000, 5500, 11000, /* 1M, 2M, 5M, 11M , 0 1 2 3*/
- 6000, 9000, 12000, 18000, /* 6M 9M 12M 18M , 4 5 6 7*/
- 24000, 36000, 48000, 54000, /* 24M 36M 48M 54M , 8 9 10 11*/
- 6500, 13000, 19500, 26000, /* MCS0 MCS1 MCS2 MCS3 , 12 13 14 15*/
- 39000, 52000, 58500, 65000, /* MCS4 MCS5 MCS6 MCS7 , 16 17 18 19*/
- 13000, 26000, 39000, 52000, /* MCS8 MCS9 MCS10 MCS11 , 20 21 22 23*/
- 78000, 104000, 117000, 130000, /* MCS12 MCS13 MCS14 MCS15 , 24 25 26 27*/
- 130000, 144400, 72200 /* MCS14SG, MCS15SG, MSG7SG , 28 29 30*/
- };
-
-u32_t zfiWlanQueryTxRate(zdev_t* dev)
{
- u8_t rateId = 0xff;
- zmw_get_wlan_dev(dev);
- zmw_declare_for_critical_section();
-
- /* If Tx rate had not been trained, return maximum Tx rate instead */
- if ((wd->wlanMode == ZM_MODE_INFRASTRUCTURE) && (zfStaIsConnected(dev)))
- {
- zmw_enter_critical_section(dev);
- //Not in fixed rate mode
- if (wd->txMCS == 0xff)
- {
- if ((wd->sta.oppositeInfo[0].rcCell.flag & ZM_RC_TRAINED_BIT) == 0)
- {
- rateId = wd->sta.oppositeInfo[0].rcCell.operationRateSet[wd->sta.oppositeInfo[0].rcCell.operationRateCount-1];
- }
- else
- {
- rateId = wd->sta.oppositeInfo[0].rcCell.operationRateSet[wd->sta.oppositeInfo[0].rcCell.currentRateIndex];
- }
- }
- zmw_leave_critical_section(dev);
- }
- if (rateId != 0xff)
- {
- if (wd->sta.htCtrlBandwidth)
- {
- return zcRateIdToKbps40M[rateId];
- }
- else
- {
- return zcRateIdToKbps20M[rateId];
- }
- }
- else
- {
- return wd->CurrentTxRateKbps;
- }
+ 1000, 2000, 5500, 11000, /* 1M, 2M, 5M, 11M , 0 1 2 3 */
+ 6000, 9000, 12000, 18000, /* 6M 9M 12M 18M , 4 5 6 7 */
+ 24000, 36000, 48000, 54000, /* 24M 36M 48M 54M , 8 9 10 11 */
+ 6500, 13000, 19500, 26000, /* MCS0 MCS1 MCS2 MCS3 , 12 13 14 15 */
+ 39000, 52000, 58500, 65000, /* MCS4 MCS5 MCS6 MCS7 , 16 17 18 19 */
+ 13000, 26000, 39000, 52000, /* MCS8 MCS9 MCS10 MCS11 , 20 21 22 23 */
+ 78000, 104000, 117000, 130000, /* MCS12 MCS13 MCS14 MCS15, 24 25 26 27*/
+ 130000, 144400, 72200 /* MCS14SG, MCS15SG, MSG7SG , 28 29 30 */
+};
+
+u32_t zfiWlanQueryTxRate(zdev_t *dev)
+{
+ u8_t rateId = 0xff;
+ zmw_get_wlan_dev(dev);
+ zmw_declare_for_critical_section();
+
+ /* If Tx rate had not been trained, return maximum Tx rate instead */
+ if ((wd->wlanMode == ZM_MODE_INFRASTRUCTURE) &&
+ (zfStaIsConnected(dev))) {
+ zmw_enter_critical_section(dev);
+ /* Not in fixed rate mode */
+ if (wd->txMCS == 0xff) {
+ if ((wd->sta.oppositeInfo[0].rcCell.flag &
+ ZM_RC_TRAINED_BIT) == 0)
+ rateId = wd->sta.oppositeInfo[0].rcCell. \
+ operationRateSet[wd->sta.oppositeInfo[0]. \
+ rcCell.operationRateCount-1];
+ else
+ rateId = wd->sta.oppositeInfo[0].rcCell. \
+ operationRateSet[wd->sta.oppositeInfo[0]. \
+ rcCell.currentRateIndex];
+ }
+ zmw_leave_critical_section(dev);
+ }
+
+ if (rateId != 0xff) {
+ if (wd->sta.htCtrlBandwidth)
+ return zcRateIdToKbps40M[rateId];
+ else
+ return zcRateIdToKbps20M[rateId];
+ } else
+ return wd->CurrentTxRateKbps;
}
-void zfWlanUpdateRxRate(zdev_t* dev, struct zsAdditionInfo* addInfo)
+void zfWlanUpdateRxRate(zdev_t *dev, struct zsAdditionInfo *addInfo)
{
- u32_t rxRateKbps;
- zmw_get_wlan_dev(dev);
- //zm_msg1_mm(ZM_LV_0, "addInfo->Tail.Data.RxMacStatus =", addInfo->Tail.Data.RxMacStatus & 0x03);
-
- /* b5~b4: MPDU indication. */
- /* 00: Single MPDU. */
- /* 10: First MPDU of A-MPDU. */
- /* 11: Middle MPDU of A-MPDU. */
- /* 01: Last MPDU of A-MPDU. */
- /* Only First MPDU and Single MPDU have PLCP header */
- /* First MPDU : (mpduInd & 0x30) == 0x00 */
- /* Single MPDU : (mpduInd & 0x30) == 0x20 */
- if ((addInfo->Tail.Data.RxMacStatus & 0x10) == 0)
- {
- /* Modulation type */
- wd->modulationType = addInfo->Tail.Data.RxMacStatus & 0x03;
- switch(wd->modulationType)
- {
- case 0x0: wd->rateField = addInfo->PlcpHeader[0] & 0xff; //CCK mode
- wd->rxInfo = 0;
- break;
- case 0x1: wd->rateField = addInfo->PlcpHeader[0] & 0x0f; //Legacy-OFDM mode
- wd->rxInfo = 0;
- break;
- case 0x2: wd->rateField = addInfo->PlcpHeader[3]; //HT-OFDM mode
- wd->rxInfo = addInfo->PlcpHeader[6];
- break;
- default: break;
- }
-
- rxRateKbps = zfUpdateRxRate(dev);
- if (wd->CurrentRxRateUpdated == 1)
- {
- if (rxRateKbps > wd->CurrentRxRateKbps)
- {
- wd->CurrentRxRateKbps = rxRateKbps;
- }
- }
- else
- {
- wd->CurrentRxRateKbps = rxRateKbps;
- wd->CurrentRxRateUpdated = 1;
- }
- }
+ u32_t rxRateKbps;
+ zmw_get_wlan_dev(dev);
+ /* zm_msg1_mm(ZM_LV_0, "addInfo->Tail.Data.RxMacStatus =",
+ * addInfo->Tail.Data.RxMacStatus & 0x03);
+ */
+
+ /* b5~b4: MPDU indication. */
+ /* 00: Single MPDU. */
+ /* 10: First MPDU of A-MPDU. */
+ /* 11: Middle MPDU of A-MPDU. */
+ /* 01: Last MPDU of A-MPDU. */
+ /* Only First MPDU and Single MPDU have PLCP header */
+ /* First MPDU : (mpduInd & 0x30) == 0x00 */
+ /* Single MPDU : (mpduInd & 0x30) == 0x20 */
+ if ((addInfo->Tail.Data.RxMacStatus & 0x10) == 0) {
+ /* Modulation type */
+ wd->modulationType = addInfo->Tail.Data.RxMacStatus & 0x03;
+ switch (wd->modulationType) {
+ /* CCK mode */
+ case 0x0:
+ wd->rateField = addInfo->PlcpHeader[0] & 0xff;
+ wd->rxInfo = 0;
+ break;
+ /* Legacy-OFDM mode */
+ case 0x1:
+ wd->rateField = addInfo->PlcpHeader[0] & 0x0f;
+ wd->rxInfo = 0;
+ break;
+ /* HT-OFDM mode */
+ case 0x2:
+ wd->rateField = addInfo->PlcpHeader[3];
+ wd->rxInfo = addInfo->PlcpHeader[6];
+ break;
+ default:
+ break;
+ }
+
+ rxRateKbps = zfUpdateRxRate(dev);
+ if (wd->CurrentRxRateUpdated == 1) {
+ if (rxRateKbps > wd->CurrentRxRateKbps)
+ wd->CurrentRxRateKbps = rxRateKbps;
+ } else {
+ wd->CurrentRxRateKbps = rxRateKbps;
+ wd->CurrentRxRateUpdated = 1;
+ }
+ }
}
+
#if 0
u16_t zcIndextoRateBG[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0, 48000,
- 24000, 12000, 6000, 54000, 36000, 18000, 9000};
+ 24000, 12000, 6000, 54000, 36000, 18000, 9000};
u32_t zcIndextoRateN20L[16] = {6500, 13000, 19500, 26000, 39000, 52000, 58500,
- 65000, 13000, 26000, 39000, 52000, 78000, 104000,
- 117000, 130000};
+ 65000, 13000, 26000, 39000, 52000, 78000, 104000,
+ 117000, 130000};
u32_t zcIndextoRateN20S[16] = {7200, 14400, 21700, 28900, 43300, 57800, 65000,
- 72200, 14400, 28900, 43300, 57800, 86700, 115600,
- 130000, 144400};
-u32_t zcIndextoRateN40L[16] = {13500, 27000, 40500, 54000, 81000, 108000, 121500,
- 135000, 27000, 54000, 81000, 108000, 162000, 216000,
- 243000, 270000};
-u32_t zcIndextoRateN40S[16] = {15000, 30000, 45000, 60000, 90000, 120000, 135000,
- 150000, 30000, 60000, 90000, 120000, 180000, 240000,
- 270000, 300000};
+ 72200, 14400, 28900, 43300, 57800, 86700, 115600,
+ 130000, 144400};
+u32_t zcIndextoRateN40L[16] = {13500, 27000, 40500, 54000, 81000, 108000,
+ 121500, 135000, 27000, 54000, 81000, 108000,
+ 162000, 216000, 243000, 270000};
+u32_t zcIndextoRateN40S[16] = {15000, 30000, 45000, 60000, 90000, 120000,
+ 135000, 150000, 30000, 60000, 90000, 120000,
+ 180000, 240000, 270000, 300000};
#endif
extern u16_t zcIndextoRateBG[16];
@@ -1294,568 +1208,558 @@ extern u32_t zcIndextoRateN20S[16];
extern u32_t zcIndextoRateN40L[16];
extern u32_t zcIndextoRateN40S[16];
-u32_t zfiWlanQueryRxRate(zdev_t* dev)
+u32_t zfiWlanQueryRxRate(zdev_t *dev)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- wd->CurrentRxRateUpdated = 0;
- return wd->CurrentRxRateKbps;
+ wd->CurrentRxRateUpdated = 0;
+ return wd->CurrentRxRateKbps;
}
-u32_t zfUpdateRxRate(zdev_t* dev)
+u32_t zfUpdateRxRate(zdev_t *dev)
{
- u8_t mcs, bandwidth;
- u32_t rxRateKbps = 130000;
- zmw_get_wlan_dev(dev);
-
- switch (wd->modulationType)
- {
- case 0x0: //CCK mode
- switch (wd->rateField)
- {
- case 0x0a: rxRateKbps = 1000;
- break;
- case 0x14: rxRateKbps = 2000;
-
- case 0x37: rxRateKbps = 5500;
- break;
- case 0x6e: rxRateKbps = 11000;
- break;
- default:
- break;
- }
- break;
- case 0x1: //Legacy-OFDM mode
- if (wd->rateField <= 15)
- {
- rxRateKbps = zcIndextoRateBG[wd->rateField];
- }
- break;
- case 0x2: //HT-OFDM mode
- mcs = wd->rateField & 0x7F;
- bandwidth = wd->rateField & 0x80;
- if (mcs <= 15)
- {
- if (bandwidth != 0)
- {
- if((wd->rxInfo & 0x80) != 0)
- {
- /* Short GI 40 MHz MIMO Rate */
- rxRateKbps = zcIndextoRateN40S[mcs];
- }
- else
- {
- /* Long GI 40 MHz MIMO Rate */
- rxRateKbps = zcIndextoRateN40L[mcs];
- }
- }
- else
- {
- if((wd->rxInfo & 0x80) != 0)
- {
- /* Short GI 20 MHz MIMO Rate */
- rxRateKbps = zcIndextoRateN20S[mcs];
- }
- else
- {
- /* Long GI 20 MHz MIMO Rate */
- rxRateKbps = zcIndextoRateN20L[mcs];
- }
- }
- }
- break;
- default:
- break;
- }
- //zm_msg1_mm(ZM_LV_0, "wd->CurrentRxRateKbps=", wd->CurrentRxRateKbps);
-
- // ToDo: use bandwith field to define 40MB
- return rxRateKbps;
+ u8_t mcs, bandwidth;
+ u32_t rxRateKbps = 130000;
+ zmw_get_wlan_dev(dev);
+
+ switch (wd->modulationType) {
+ /* CCK mode */
+ case 0x0:
+ switch (wd->rateField) {
+ case 0x0a:
+ rxRateKbps = 1000;
+ break;
+ case 0x14:
+ rxRateKbps = 2000;
+
+ case 0x37:
+ rxRateKbps = 5500;
+ break;
+ case 0x6e:
+ rxRateKbps = 11000;
+ break;
+ default:
+ break;
+ }
+ break;
+ /* Legacy-OFDM mode */
+ case 0x1:
+ if (wd->rateField <= 15)
+ rxRateKbps = zcIndextoRateBG[wd->rateField];
+ break;
+ /* HT-OFDM mode */
+ case 0x2:
+ mcs = wd->rateField & 0x7F;
+ bandwidth = wd->rateField & 0x80;
+ if (mcs <= 15) {
+ if (bandwidth != 0) {
+ if ((wd->rxInfo & 0x80) != 0) {
+ /* Short GI 40 MHz MIMO Rate */
+ rxRateKbps = zcIndextoRateN40S[mcs];
+ } else {
+ /* Long GI 40 MHz MIMO Rate */
+ rxRateKbps = zcIndextoRateN40L[mcs];
+ }
+ } else {
+ if ((wd->rxInfo & 0x80) != 0) {
+ /* Short GI 20 MHz MIMO Rate */
+ rxRateKbps = zcIndextoRateN20S[mcs];
+ } else {
+ /* Long GI 20 MHz MIMO Rate */
+ rxRateKbps = zcIndextoRateN20L[mcs];
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ /* zm_msg1_mm(ZM_LV_0, "wd->CurrentRxRateKbps=",
+ wd->CurrentRxRateKbps);
+ */
+
+ /* ToDo: use bandwith field to define 40MB */
+ return rxRateKbps;
}
/* Get WLAN stastics */
-u16_t zfiWlanGetStatistics(zdev_t* dev)
+u16_t zfiWlanGetStatistics(zdev_t *dev)
{
- /* Return link statistics */
- return 0;
+ /* Return link statistics */
+ return 0;
}
-u16_t zfiWlanReset(zdev_t* dev)
+u16_t zfiWlanReset(zdev_t *dev)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- wd->state = ZM_WLAN_STATE_DISABLED;
+ wd->state = ZM_WLAN_STATE_DISABLED;
- return zfWlanReset(dev);
+ return zfWlanReset(dev);
}
/* Reset WLAN */
-u16_t zfWlanReset(zdev_t* dev)
+u16_t zfWlanReset(zdev_t *dev)
{
- u8_t isConnected;
- zmw_get_wlan_dev(dev);
-
- zmw_declare_for_critical_section();
-
- zm_debug_msg0("zfWlanReset");
-
- isConnected = zfStaIsConnected(dev);
-
- //if ( wd->wlanMode != ZM_MODE_AP )
- {
- if ( (wd->wlanMode == ZM_MODE_INFRASTRUCTURE)&&
- (wd->sta.currentAuthMode != ZM_AUTH_MODE_WPA2) )
- {
- /* send deauthentication frame */
- if (isConnected)
- {
- //zfiWlanDeauth(dev, NULL, 0);
- zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, wd->sta.bssid, 3, 0, 0);
- //zmw_debug_msg0("send a Deauth frame!");
- }
- }
- }
-
- zfChangeAdapterState(dev, ZM_STA_STATE_DISCONNECT);
- zfHpResetKeyCache(dev);
-
- if (isConnected)
- {
- //zfiWlanDisable(dev);
- if (wd->zfcbConnectNotify != NULL)
- {
- wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECTION_RESET, wd->sta.bssid);
- }
- }
- else
- {
- if (wd->zfcbConnectNotify != NULL)
- {
- wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_RESET, wd->sta.bssid);
- }
- }
-
- /* stop beacon */
- zfHpDisableBeacon(dev);
-
- /* Free buffer in defragment list*/
- zfAgingDefragList(dev, 1);
-
- /* Flush VTxQ and MmQ */
- zfFlushVtxq(dev);
-
- #ifdef ZM_ENABLE_AGGREGATION
- /* add by honda */
- zfAggRxFreeBuf(dev, 0); //1 for release structure memory
- /* end of add by honda */
- #endif
-
- zfStaRefreshBlockList(dev, 1);
-
- zmw_enter_critical_section(dev);
-
- zfTimerCancel(dev, ZM_EVENT_IBSS_MONITOR);
- zfTimerCancel(dev, ZM_EVENT_CM_BLOCK_TIMER);
- zfTimerCancel(dev, ZM_EVENT_CM_DISCONNECT);
-
- wd->sta.connectState = ZM_STA_CONN_STATE_NONE;
- wd->sta.connectByReasso = FALSE;
- wd->sta.cmDisallowSsidLength = 0;
- wd->sta.bAutoReconnect = 0;
- wd->sta.InternalScanReq = 0;
- wd->sta.encryMode = ZM_NO_WEP;
- wd->sta.wepStatus = ZM_ENCRYPTION_WEP_DISABLED;
- wd->sta.wpaState = ZM_STA_WPA_STATE_INIT;
- wd->sta.cmMicFailureCount = 0;
- wd->sta.ibssBssIsCreator = 0;
+ u8_t isConnected;
+ zmw_get_wlan_dev(dev);
+
+ zmw_declare_for_critical_section();
+
+ zm_debug_msg0("zfWlanReset");
+
+ isConnected = zfStaIsConnected(dev);
+
+ /* if ( wd->wlanMode != ZM_MODE_AP ) */
+ {
+ if ((wd->wlanMode == ZM_MODE_INFRASTRUCTURE) &&
+ (wd->sta.currentAuthMode != ZM_AUTH_MODE_WPA2)) {
+ /* send deauthentication frame */
+ if (isConnected) {
+ /* zfiWlanDeauth(dev, NULL, 0); */
+ zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH,
+ wd->sta.bssid, 3, 0, 0);
+ /* zmw_debug_msg0("send a Deauth frame!"); */
+ }
+ }
+ }
+
+ zfChangeAdapterState(dev, ZM_STA_STATE_DISCONNECT);
+ zfHpResetKeyCache(dev);
+
+ if (isConnected) {
+ /* zfiWlanDisable(dev); */
+ if (wd->zfcbConnectNotify != NULL)
+ wd->zfcbConnectNotify(dev,
+ ZM_STATUS_MEDIA_CONNECTION_RESET, wd->sta.bssid);
+ } else {
+ if (wd->zfcbConnectNotify != NULL)
+ wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_RESET,
+ wd->sta.bssid);
+ }
+
+ /* stop beacon */
+ zfHpDisableBeacon(dev);
+
+ /* Free buffer in defragment list*/
+ zfAgingDefragList(dev, 1);
+
+ /* Flush VTxQ and MmQ */
+ zfFlushVtxq(dev);
+
+#ifdef ZM_ENABLE_AGGREGATION
+ /* add by honda */
+ zfAggRxFreeBuf(dev, 0); /* 1 for release structure memory */
+ /* end of add by honda */
+#endif
+
+ zfStaRefreshBlockList(dev, 1);
+
+ zmw_enter_critical_section(dev);
+
+ zfTimerCancel(dev, ZM_EVENT_IBSS_MONITOR);
+ zfTimerCancel(dev, ZM_EVENT_CM_BLOCK_TIMER);
+ zfTimerCancel(dev, ZM_EVENT_CM_DISCONNECT);
+
+ wd->sta.connectState = ZM_STA_CONN_STATE_NONE;
+ wd->sta.connectByReasso = FALSE;
+ wd->sta.cmDisallowSsidLength = 0;
+ wd->sta.bAutoReconnect = 0;
+ wd->sta.InternalScanReq = 0;
+ wd->sta.encryMode = ZM_NO_WEP;
+ wd->sta.wepStatus = ZM_ENCRYPTION_WEP_DISABLED;
+ wd->sta.wpaState = ZM_STA_WPA_STATE_INIT;
+ wd->sta.cmMicFailureCount = 0;
+ wd->sta.ibssBssIsCreator = 0;
#ifdef ZM_ENABLE_IBSS_WPA2PSK
- wd->sta.ibssWpa2Psk = 0;
+ wd->sta.ibssWpa2Psk = 0;
#endif
- /* reset connect timeout counter */
- wd->sta.connectTimeoutCount = 0;
-
- /* reset leap enable variable */
- wd->sta.leapEnabled = 0;
-
- /* Reset the RIFS Status / RIFS-like frame count / RIFS count */
- if( wd->sta.rifsState == ZM_RIFS_STATE_DETECTED )
- zfHpDisableRifs(dev);
- wd->sta.rifsState = ZM_RIFS_STATE_DETECTING;
- wd->sta.rifsLikeFrameCnt = 0;
- wd->sta.rifsCount = 0;
-
- wd->sta.osRxFilter = 0;
- wd->sta.bSafeMode = 0;
-
- // Clear the information for the peer stations of IBSS or AP of Station mode
- zfZeroMemory((u8_t*)wd->sta.oppositeInfo, sizeof(struct zsOppositeInfo) * ZM_MAX_OPPOSITE_COUNT);
-
- zmw_leave_critical_section(dev);
-
- zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_INTERNAL);
- zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_EXTERNAL);
-
- /* Turn off Software WEP/TKIP */
- if (wd->sta.SWEncryptEnable != 0)
- {
- zm_debug_msg0("Disable software encryption");
- zfStaDisableSWEncryption(dev);
- }
-
- /* Improve WEP/TKIP performace with HT AP, detail information please look bug#32495 */
- //zfHpSetTTSIFSTime(dev, 0x8);
-
- /* Keep Pseudo mode */
- if ( wd->wlanMode != ZM_MODE_PSEUDO )
- {
- wd->wlanMode = ZM_MODE_INFRASTRUCTURE;
- }
- return 0;
+ /* reset connect timeout counter */
+ wd->sta.connectTimeoutCount = 0;
+
+ /* reset leap enable variable */
+ wd->sta.leapEnabled = 0;
+
+ /* Reset the RIFS Status / RIFS-like frame count / RIFS count */
+ if (wd->sta.rifsState == ZM_RIFS_STATE_DETECTED)
+ zfHpDisableRifs(dev);
+ wd->sta.rifsState = ZM_RIFS_STATE_DETECTING;
+ wd->sta.rifsLikeFrameCnt = 0;
+ wd->sta.rifsCount = 0;
+
+ wd->sta.osRxFilter = 0;
+ wd->sta.bSafeMode = 0;
+
+ /* Clear the information for the peer
+ stations of IBSS or AP of Station mode
+ */
+ zfZeroMemory((u8_t *)wd->sta.oppositeInfo,
+ sizeof(struct zsOppositeInfo) * ZM_MAX_OPPOSITE_COUNT);
+
+ zmw_leave_critical_section(dev);
+
+ zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_INTERNAL);
+ zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_EXTERNAL);
+
+ /* Turn off Software WEP/TKIP */
+ if (wd->sta.SWEncryptEnable != 0) {
+ zm_debug_msg0("Disable software encryption");
+ zfStaDisableSWEncryption(dev);
+ }
+
+ /* Improve WEP/TKIP performace with HT AP,
+ detail information please look bug#32495
+ */
+ /* zfHpSetTTSIFSTime(dev, 0x8); */
+
+ /* Keep Pseudo mode */
+ if (wd->wlanMode != ZM_MODE_PSEUDO)
+ wd->wlanMode = ZM_MODE_INFRASTRUCTURE;
+
+ return 0;
}
/* Deauthenticate a STA */
-u16_t zfiWlanDeauth(zdev_t* dev, u16_t* macAddr, u16_t reason)
+u16_t zfiWlanDeauth(zdev_t *dev, u16_t *macAddr, u16_t reason)
{
- zmw_get_wlan_dev(dev);
-
- if ( wd->wlanMode == ZM_MODE_AP )
- {
- //u16_t id;
-
- /*
- * we will reset all key in zfHpResetKeyCache() when call
- * zfiWlanDisable(), if we want to reset PairwiseKey for each sta,
- * need to use a nullAddr to let keyindex not match.
- * otherwise hardware will still find PairwiseKey when AP change
- * encryption mode from WPA to WEP
- */
-
- /*
- if ((id = zfApFindSta(dev, macAddr)) != 0xffff)
- {
- u32_t key[8];
- u16_t nullAddr[3] = { 0x0, 0x0, 0x0 };
-
- if (wd->ap.staTable[i].encryMode != ZM_NO_WEP)
- {
- zfHpSetApPairwiseKey(dev, nullAddr,
- ZM_NO_WEP, &key[0], &key[4], i+1);
- }
- //zfHpSetApPairwiseKey(dev, (u16_t *)macAddr,
- // ZM_NO_WEP, &key[0], &key[4], id+1);
- wd->ap.staTable[id].encryMode = ZM_NO_WEP;
- wd->ap.staTable[id].keyIdx = 0xff;
- }
- */
-
- zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, macAddr, reason, 0, 0);
- }
- else
- {
- zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, wd->sta.bssid, 3, 0, 0);
- }
-
- /* Issue DEAUTH command to FW */
- return 0;
+ zmw_get_wlan_dev(dev);
+
+ if (wd->wlanMode == ZM_MODE_AP) {
+ /* u16_t id; */
+
+ /*
+ * we will reset all key in zfHpResetKeyCache() when call
+ * zfiWlanDisable(), if we want to reset PairwiseKey for each
+ * sta, need to use a nullAddr to let keyindex not match.
+ * otherwise hardware will still find PairwiseKey when AP change
+ * encryption mode from WPA to WEP
+ */
+
+ /*
+ if ((id = zfApFindSta(dev, macAddr)) != 0xffff)
+ {
+ u32_t key[8];
+ u16_t nullAddr[3] = { 0x0, 0x0, 0x0 };
+
+ if (wd->ap.staTable[i].encryMode != ZM_NO_WEP)
+ {
+ zfHpSetApPairwiseKey(dev, nullAddr,
+ ZM_NO_WEP, &key[0], &key[4], i+1);
+ }
+ //zfHpSetApPairwiseKey(dev, (u16_t *)macAddr,
+ // ZM_NO_WEP, &key[0], &key[4], id+1);
+ wd->ap.staTable[id].encryMode = ZM_NO_WEP;
+ wd->ap.staTable[id].keyIdx = 0xff;
+ }
+ */
+
+ zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, macAddr,
+ reason, 0, 0);
+ } else
+ zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH,
+ wd->sta.bssid, 3, 0, 0);
+
+ /* Issue DEAUTH command to FW */
+ return 0;
}
/* XP packet filter feature : */
-/* 1=>enable: All multicast address packets, not just the ones enumerated in the multicast address list. */
+/* 1=>enable: All multicast address packets, not just the ones */
+/* enumerated in the multicast address list. */
/* 0=>disable */
-void zfiWlanSetAllMulticast(zdev_t* dev, u32_t setting)
+void zfiWlanSetAllMulticast(zdev_t *dev, u32_t setting)
{
- zmw_get_wlan_dev(dev);
- zm_msg1_mm(ZM_LV_0, "sta.bAllMulticast = ", setting);
- wd->sta.bAllMulticast = (u8_t)setting;
+ zmw_get_wlan_dev(dev);
+ zm_msg1_mm(ZM_LV_0, "sta.bAllMulticast = ", setting);
+ wd->sta.bAllMulticast = (u8_t)setting;
}
/* HT configure API */
-void zfiWlanSetHTCtrl(zdev_t* dev, u32_t *setting, u32_t forceTxTPC)
+void zfiWlanSetHTCtrl(zdev_t *dev, u32_t *setting, u32_t forceTxTPC)
{
- zmw_get_wlan_dev(dev);
-
- wd->preambleType = (u8_t)setting[0];
- wd->sta.preambleTypeHT = (u8_t)setting[1];
- wd->sta.htCtrlBandwidth = (u8_t)setting[2];
- wd->sta.htCtrlSTBC = (u8_t)setting[3];
- wd->sta.htCtrlSG = (u8_t)setting[4];
- wd->sta.defaultTA = (u8_t)setting[5];
- wd->enableAggregation = (u8_t)setting[6];
- wd->enableWDS = (u8_t)setting[7];
-
- wd->forceTxTPC = forceTxTPC;
+ zmw_get_wlan_dev(dev);
+
+ wd->preambleType = (u8_t)setting[0];
+ wd->sta.preambleTypeHT = (u8_t)setting[1];
+ wd->sta.htCtrlBandwidth = (u8_t)setting[2];
+ wd->sta.htCtrlSTBC = (u8_t)setting[3];
+ wd->sta.htCtrlSG = (u8_t)setting[4];
+ wd->sta.defaultTA = (u8_t)setting[5];
+ wd->enableAggregation = (u8_t)setting[6];
+ wd->enableWDS = (u8_t)setting[7];
+
+ wd->forceTxTPC = forceTxTPC;
}
/* FB50 in OS XP, RD private test code */
-void zfiWlanQueryHTCtrl(zdev_t* dev, u32_t *setting, u32_t *forceTxTPC)
+void zfiWlanQueryHTCtrl(zdev_t *dev, u32_t *setting, u32_t *forceTxTPC)
{
- zmw_get_wlan_dev(dev);
-
- setting[0] = wd->preambleType;
- setting[1] = wd->sta.preambleTypeHT;
- setting[2] = wd->sta.htCtrlBandwidth;
- setting[3] = wd->sta.htCtrlSTBC;
- setting[4] = wd->sta.htCtrlSG;
- setting[5] = wd->sta.defaultTA;
- setting[6] = wd->enableAggregation;
- setting[7] = wd->enableWDS;
-
- *forceTxTPC = wd->forceTxTPC;
+ zmw_get_wlan_dev(dev);
+
+ setting[0] = wd->preambleType;
+ setting[1] = wd->sta.preambleTypeHT;
+ setting[2] = wd->sta.htCtrlBandwidth;
+ setting[3] = wd->sta.htCtrlSTBC;
+ setting[4] = wd->sta.htCtrlSG;
+ setting[5] = wd->sta.defaultTA;
+ setting[6] = wd->enableAggregation;
+ setting[7] = wd->enableWDS;
+
+ *forceTxTPC = wd->forceTxTPC;
}
-void zfiWlanDbg(zdev_t* dev, u8_t setting)
+void zfiWlanDbg(zdev_t *dev, u8_t setting)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- wd->enableHALDbgInfo = setting;
+ wd->enableHALDbgInfo = setting;
}
/* FB50 in OS XP, RD private test code */
-void zfiWlanSetRxPacketDump(zdev_t* dev, u32_t setting)
+void zfiWlanSetRxPacketDump(zdev_t *dev, u32_t setting)
{
- zmw_get_wlan_dev(dev);
- if (setting)
- {
- wd->rxPacketDump = 1; /* enable */
- }
- else
- {
- wd->rxPacketDump = 0; /* disable */
- }
+ zmw_get_wlan_dev(dev);
+ if (setting)
+ wd->rxPacketDump = 1; /* enable */
+ else
+ wd->rxPacketDump = 0; /* disable */
}
/* FB50 in OS XP, RD private test code */
/* Tally */
-void zfiWlanResetTally(zdev_t* dev)
+void zfiWlanResetTally(zdev_t *dev)
{
- zmw_get_wlan_dev(dev);
-
- zmw_declare_for_critical_section();
-
- zmw_enter_critical_section(dev);
-
- wd->commTally.txUnicastFrm = 0; //txUnicastFrames
- wd->commTally.txMulticastFrm = 0; //txMulticastFrames
- wd->commTally.txUnicastOctets = 0; //txUniOctets byte size
- wd->commTally.txMulticastOctets = 0; //txMultiOctets byte size
- wd->commTally.txFrmUpperNDIS = 0;
- wd->commTally.txFrmDrvMgt = 0;
- wd->commTally.RetryFailCnt = 0;
- wd->commTally.Hw_TotalTxFrm = 0; //Hardware total Tx Frame
- wd->commTally.Hw_RetryCnt = 0; //txMultipleRetriesFrames
- wd->commTally.Hw_UnderrunCnt = 0;//
- wd->commTally.DriverRxFrmCnt = 0;//
- wd->commTally.rxUnicastFrm = 0; //rxUnicastFrames
- wd->commTally.rxMulticastFrm = 0; //rxMulticastFrames
- wd->commTally.NotifyNDISRxFrmCnt = 0;//
- wd->commTally.rxUnicastOctets = 0; //rxUniOctets byte size
- wd->commTally.rxMulticastOctets = 0; //rxMultiOctets byte size
- wd->commTally.DriverDiscardedFrm = 0;// Discard by ValidateFrame
- wd->commTally.LessThanDataMinLen = 0;//
- wd->commTally.GreaterThanMaxLen = 0;//
- wd->commTally.DriverDiscardedFrmCauseByMulticastList = 0;
- wd->commTally.DriverDiscardedFrmCauseByFrmCtrl = 0;
- wd->commTally.rxNeedFrgFrm = 0; // need more frg frm
- wd->commTally.DriverRxMgtFrmCnt = 0;
- wd->commTally.rxBroadcastFrm = 0; //Receive broadcast frame count
- wd->commTally.rxBroadcastOctets = 0; //Receive broadcast frame byte size
- wd->commTally.Hw_TotalRxFrm = 0;//
- wd->commTally.Hw_CRC16Cnt = 0; //rxPLCPCRCErrCnt
- wd->commTally.Hw_CRC32Cnt = 0; //rxCRC32ErrCnt
- wd->commTally.Hw_DecrypErr_UNI = 0;//
- wd->commTally.Hw_DecrypErr_Mul = 0;//
- wd->commTally.Hw_RxFIFOOverrun = 0;//
- wd->commTally.Hw_RxTimeOut = 0;
- wd->commTally.LossAP = 0;//
-
- wd->commTally.Tx_MPDU = 0;
- wd->commTally.BA_Fail = 0;
- wd->commTally.Hw_Tx_AMPDU = 0;
- wd->commTally.Hw_Tx_MPDU = 0;
-
- wd->commTally.txQosDropCount[0] = 0;
- wd->commTally.txQosDropCount[1] = 0;
- wd->commTally.txQosDropCount[2] = 0;
- wd->commTally.txQosDropCount[3] = 0;
- wd->commTally.txQosDropCount[4] = 0;
-
- wd->commTally.Hw_RxMPDU = 0;
- wd->commTally.Hw_RxDropMPDU = 0;
- wd->commTally.Hw_RxDelMPDU = 0;
-
- wd->commTally.Hw_RxPhyMiscError = 0;
- wd->commTally.Hw_RxPhyXRError = 0;
- wd->commTally.Hw_RxPhyOFDMError = 0;
- wd->commTally.Hw_RxPhyCCKError = 0;
- wd->commTally.Hw_RxPhyHTError = 0;
- wd->commTally.Hw_RxPhyTotalCount = 0;
-
-#if (defined(GCCK) && defined(OFDM))
- wd->commTally.rx11bDataFrame = 0;
- wd->commTally.rxOFDMDataFrame = 0;
+ zmw_get_wlan_dev(dev);
+
+ zmw_declare_for_critical_section();
+
+ zmw_enter_critical_section(dev);
+
+ wd->commTally.txUnicastFrm = 0; /* txUnicastFrames */
+ wd->commTally.txMulticastFrm = 0; /* txMulticastFrames */
+ wd->commTally.txUnicastOctets = 0; /* txUniOctets byte size */
+ wd->commTally.txMulticastOctets = 0; /* txMultiOctets byte size */
+ wd->commTally.txFrmUpperNDIS = 0;
+ wd->commTally.txFrmDrvMgt = 0;
+ wd->commTally.RetryFailCnt = 0;
+ wd->commTally.Hw_TotalTxFrm = 0; /* Hardware total Tx Frame */
+ wd->commTally.Hw_RetryCnt = 0; /* txMultipleRetriesFrames */
+ wd->commTally.Hw_UnderrunCnt = 0;
+ wd->commTally.DriverRxFrmCnt = 0;
+ wd->commTally.rxUnicastFrm = 0; /* rxUnicastFrames */
+ wd->commTally.rxMulticastFrm = 0; /* rxMulticastFrames */
+ wd->commTally.NotifyNDISRxFrmCnt = 0;
+ wd->commTally.rxUnicastOctets = 0; /* rxUniOctets byte size */
+ wd->commTally.rxMulticastOctets = 0; /* rxMultiOctets byte size */
+ wd->commTally.DriverDiscardedFrm = 0; /* Discard by ValidateFrame */
+ wd->commTally.LessThanDataMinLen = 0;
+ wd->commTally.GreaterThanMaxLen = 0;
+ wd->commTally.DriverDiscardedFrmCauseByMulticastList = 0;
+ wd->commTally.DriverDiscardedFrmCauseByFrmCtrl = 0;
+ wd->commTally.rxNeedFrgFrm = 0; /* need more frg frm */
+ wd->commTally.DriverRxMgtFrmCnt = 0;
+ wd->commTally.rxBroadcastFrm = 0;/* Receive broadcast frame count */
+ wd->commTally.rxBroadcastOctets = 0;/*Receive broadcast framebyte size*/
+ wd->commTally.Hw_TotalRxFrm = 0;
+ wd->commTally.Hw_CRC16Cnt = 0; /* rxPLCPCRCErrCnt */
+ wd->commTally.Hw_CRC32Cnt = 0; /* rxCRC32ErrCnt */
+ wd->commTally.Hw_DecrypErr_UNI = 0;
+ wd->commTally.Hw_DecrypErr_Mul = 0;
+ wd->commTally.Hw_RxFIFOOverrun = 0;
+ wd->commTally.Hw_RxTimeOut = 0;
+ wd->commTally.LossAP = 0;
+
+ wd->commTally.Tx_MPDU = 0;
+ wd->commTally.BA_Fail = 0;
+ wd->commTally.Hw_Tx_AMPDU = 0;
+ wd->commTally.Hw_Tx_MPDU = 0;
+
+ wd->commTally.txQosDropCount[0] = 0;
+ wd->commTally.txQosDropCount[1] = 0;
+ wd->commTally.txQosDropCount[2] = 0;
+ wd->commTally.txQosDropCount[3] = 0;
+ wd->commTally.txQosDropCount[4] = 0;
+
+ wd->commTally.Hw_RxMPDU = 0;
+ wd->commTally.Hw_RxDropMPDU = 0;
+ wd->commTally.Hw_RxDelMPDU = 0;
+
+ wd->commTally.Hw_RxPhyMiscError = 0;
+ wd->commTally.Hw_RxPhyXRError = 0;
+ wd->commTally.Hw_RxPhyOFDMError = 0;
+ wd->commTally.Hw_RxPhyCCKError = 0;
+ wd->commTally.Hw_RxPhyHTError = 0;
+ wd->commTally.Hw_RxPhyTotalCount = 0;
+
+#if (defined(GCCK) && defined(OFDM))
+ wd->commTally.rx11bDataFrame = 0;
+ wd->commTally.rxOFDMDataFrame = 0;
#endif
- zmw_leave_critical_section(dev);
+ zmw_leave_critical_section(dev);
}
/* FB50 in OS XP, RD private test code */
-void zfiWlanQueryTally(zdev_t* dev, struct zsCommTally *tally)
+void zfiWlanQueryTally(zdev_t *dev, struct zsCommTally *tally)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- zmw_declare_for_critical_section();
+ zmw_declare_for_critical_section();
- zmw_enter_critical_section(dev);
- zfMemoryCopy((u8_t*)tally, (u8_t*)&wd->commTally, sizeof(struct zsCommTally));
- zmw_leave_critical_section(dev);
+ zmw_enter_critical_section(dev);
+ zfMemoryCopy((u8_t *)tally, (u8_t *)&wd->commTally,
+ sizeof(struct zsCommTally));
+ zmw_leave_critical_section(dev);
}
-void zfiWlanQueryTrafTally(zdev_t* dev, struct zsTrafTally *tally)
+
+void zfiWlanQueryTrafTally(zdev_t *dev, struct zsTrafTally *tally)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- zmw_declare_for_critical_section();
+ zmw_declare_for_critical_section();
- zmw_enter_critical_section(dev);
- zfMemoryCopy((u8_t*)tally, (u8_t*)&wd->trafTally, sizeof(struct zsTrafTally));
- zmw_leave_critical_section(dev);
+ zmw_enter_critical_section(dev);
+ zfMemoryCopy((u8_t *)tally, (u8_t *)&wd->trafTally,
+ sizeof(struct zsTrafTally));
+ zmw_leave_critical_section(dev);
}
-void zfiWlanQueryMonHalRxInfo(zdev_t* dev, struct zsMonHalRxInfo *monHalRxInfo)
+void zfiWlanQueryMonHalRxInfo(zdev_t *dev, struct zsMonHalRxInfo *monHalRxInfo)
{
- zfHpQueryMonHalRxInfo(dev, (u8_t *)monHalRxInfo);
+ zfHpQueryMonHalRxInfo(dev, (u8_t *)monHalRxInfo);
}
/* parse the modeMDKEnable to DrvCore */
-void zfiDKEnable(zdev_t* dev, u32_t enable)
+void zfiDKEnable(zdev_t *dev, u32_t enable)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- wd->modeMDKEnable = enable;
- zm_debug_msg1("modeMDKEnable = ", wd->modeMDKEnable);
+ wd->modeMDKEnable = enable;
+ zm_debug_msg1("modeMDKEnable = ", wd->modeMDKEnable);
}
/* airoPeek */
-u32_t zfiWlanQueryPacketTypePromiscuous(zdev_t* dev)
+u32_t zfiWlanQueryPacketTypePromiscuous(zdev_t *dev)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- return wd->swSniffer;
+ return wd->swSniffer;
}
/* airoPeek */
-void zfiWlanSetPacketTypePromiscuous(zdev_t* dev, u32_t setValue)
+void zfiWlanSetPacketTypePromiscuous(zdev_t *dev, u32_t setValue)
{
- zmw_get_wlan_dev(dev);
-
- wd->swSniffer = setValue;
- zm_msg1_mm(ZM_LV_0, "wd->swSniffer ", wd->swSniffer);
- if (setValue)
- {
- /* write register for sniffer mode */
- zfHpSetSnifferMode(dev, 1);
- zm_msg0_mm(ZM_LV_1, "enalbe sniffer mode");
- }
- else
- {
- zfHpSetSnifferMode(dev, 0);
- zm_msg0_mm(ZM_LV_0, "disalbe sniffer mode");
- }
+ zmw_get_wlan_dev(dev);
+
+ wd->swSniffer = setValue;
+ zm_msg1_mm(ZM_LV_0, "wd->swSniffer ", wd->swSniffer);
+ if (setValue) {
+ /* write register for sniffer mode */
+ zfHpSetSnifferMode(dev, 1);
+ zm_msg0_mm(ZM_LV_1, "enalbe sniffer mode");
+ } else {
+ zfHpSetSnifferMode(dev, 0);
+ zm_msg0_mm(ZM_LV_0, "disalbe sniffer mode");
+ }
}
-void zfiWlanSetXLinkMode(zdev_t* dev, u32_t setValue)
+void zfiWlanSetXLinkMode(zdev_t *dev, u32_t setValue)
{
- zmw_get_wlan_dev(dev);
-
- wd->XLinkMode = setValue;
- if (setValue)
- {
- /* write register for sniffer mode */
- zfHpSetSnifferMode(dev, 1);
- }
- else
- {
- zfHpSetSnifferMode(dev, 0);
- }
+ zmw_get_wlan_dev(dev);
+
+ wd->XLinkMode = setValue;
+ if (setValue) {
+ /* write register for sniffer mode */
+ zfHpSetSnifferMode(dev, 1);
+ } else
+ zfHpSetSnifferMode(dev, 0);
}
-extern void zfStaChannelManagement(zdev_t* dev, u8_t scan);
-void zfiSetChannelManagement(zdev_t* dev, u32_t setting)
+extern void zfStaChannelManagement(zdev_t *dev, u8_t scan);
+
+void zfiSetChannelManagement(zdev_t *dev, u32_t setting)
{
- zmw_get_wlan_dev(dev);
-
- switch (setting)
- {
- case 1:
- wd->sta.EnableHT = 1;
- wd->BandWidth40 = 1;
- wd->ExtOffset = 1;
- break;
- case 3:
- wd->sta.EnableHT = 1;
- wd->BandWidth40 = 1;
- wd->ExtOffset = 3;
- break;
- case 0:
- wd->sta.EnableHT = 1;
- wd->BandWidth40 = 0;
- wd->ExtOffset = 0;
- break;
- default:
- wd->BandWidth40 = 0;
- wd->ExtOffset = 0;
- break;
-
- }
- zfCoreSetFrequencyEx(dev, wd->frequency, wd->BandWidth40,
- wd->ExtOffset, NULL);
+ zmw_get_wlan_dev(dev);
+
+ switch (setting) {
+ case 1:
+ wd->sta.EnableHT = 1;
+ wd->BandWidth40 = 1;
+ wd->ExtOffset = 1;
+ break;
+ case 3:
+ wd->sta.EnableHT = 1;
+ wd->BandWidth40 = 1;
+ wd->ExtOffset = 3;
+ break;
+ case 0:
+ wd->sta.EnableHT = 1;
+ wd->BandWidth40 = 0;
+ wd->ExtOffset = 0;
+ break;
+ default:
+ wd->BandWidth40 = 0;
+ wd->ExtOffset = 0;
+ break;
+ }
+
+ zfCoreSetFrequencyEx(dev, wd->frequency, wd->BandWidth40,
+ wd->ExtOffset, NULL);
}
-void zfiSetRifs(zdev_t* dev, u16_t setting)
+void zfiSetRifs(zdev_t *dev, u16_t setting)
{
- zmw_get_wlan_dev(dev);
-
- wd->sta.ie.HtInfo.ChannelInfo |= ExtHtCap_RIFSMode;
- wd->sta.EnableHT = 1;
- switch (setting)
- {
- case 0:
- wd->sta.HT2040 = 0;
-// zfHpSetRifs(dev, 1, 0, (wd->sta.currentFrequency < 3000)? 1:0);
- break;
- case 1:
- wd->sta.HT2040 = 1;
-// zfHpSetRifs(dev, 1, 1, (wd->sta.currentFrequency < 3000)? 1:0);
- break;
- default:
- wd->sta.HT2040 = 0;
-// zfHpSetRifs(dev, 1, 0, (wd->sta.currentFrequency < 3000)? 1:0);
- break;
- }
+ zmw_get_wlan_dev(dev);
+
+ wd->sta.ie.HtInfo.ChannelInfo |= ExtHtCap_RIFSMode;
+ wd->sta.EnableHT = 1;
+
+ switch (setting) {
+ case 0:
+ wd->sta.HT2040 = 0;
+ /* zfHpSetRifs(dev, 1, 0,
+ * (wd->sta.currentFrequency < 3000)? 1:0);
+ */
+ break;
+ case 1:
+ wd->sta.HT2040 = 1;
+ /* zfHpSetRifs(dev, 1, 1,
+ * (wd->sta.currentFrequency < 3000)? 1:0);
+ */
+ break;
+ default:
+ wd->sta.HT2040 = 0;
+ /* zfHpSetRifs(dev, 1, 0,
+ * (wd->sta.currentFrequency < 3000)? 1:0);
+ */
+ break;
+ }
}
-void zfiCheckRifs(zdev_t* dev)
+void zfiCheckRifs(zdev_t *dev)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- if(wd->sta.ie.HtInfo.ChannelInfo & ExtHtCap_RIFSMode)
- {
-// zfHpSetRifs(dev, wd->sta.EnableHT, wd->sta.HT2040, (wd->sta.currentFrequency < 3000)? 1:0);
- }
+ if (wd->sta.ie.HtInfo.ChannelInfo & ExtHtCap_RIFSMode)
+ ;
+ /* zfHpSetRifs(dev, wd->sta.EnableHT, wd->sta.HT2040,
+ * (wd->sta.currentFrequency < 3000)? 1:0);
+ */
}
-void zfiSetReorder(zdev_t* dev, u16_t value)
+void zfiSetReorder(zdev_t *dev, u16_t value)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- wd->reorder = value;
+ wd->reorder = value;
}
-void zfiSetSeqDebug(zdev_t* dev, u16_t value)
+void zfiSetSeqDebug(zdev_t *dev, u16_t value)
{
- zmw_get_wlan_dev(dev);
+ zmw_get_wlan_dev(dev);
- wd->seq_debug = value;
+ wd->seq_debug = value;
}
diff --git a/drivers/staging/panel/lcd-panel-cgram.txt b/drivers/staging/panel/lcd-panel-cgram.txt
index f9ceef4322a3..7f82c905763d 100644
--- a/drivers/staging/panel/lcd-panel-cgram.txt
+++ b/drivers/staging/panel/lcd-panel-cgram.txt
@@ -3,7 +3,7 @@ characters 0 to 7. The escape code to define a new character is
'\e[LG' followed by one digit from 0 to 7, representing the character
number, and up to 8 couples of hex digits terminated by a semi-colon
(';'). Each couple of digits represents a line, with 1-bits for each
-illuminated pixel with LSB on the right. Lines are numberred from the
+illuminated pixel with LSB on the right. Lines are numbered from the
top of the character to the bottom. On a 5x7 matrix, only the 5 lower
bits of the 7 first bytes are used for each character. If the string
is incomplete, only complete lines will be redefined. Here are some
diff --git a/drivers/staging/pohmelfs/crypto.c b/drivers/staging/pohmelfs/crypto.c
index 31d765de92ce..19781ad782fb 100644
--- a/drivers/staging/pohmelfs/crypto.c
+++ b/drivers/staging/pohmelfs/crypto.c
@@ -832,8 +832,7 @@ int pohmelfs_trans_crypt(struct netfs_trans *trans, struct pohmelfs_sb *psb)
return pohmelfs_crypto_thread_get(psb, pohmelfs_trans_crypt_action, trans);
}
-struct pohmelfs_crypto_input_action_data
-{
+struct pohmelfs_crypto_input_action_data {
struct page *page;
struct pohmelfs_crypto_engine *e;
u64 iv;
diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c
index b5799842fb84..4c58e22c1fbe 100644
--- a/drivers/staging/pohmelfs/dir.c
+++ b/drivers/staging/pohmelfs/dir.c
@@ -562,7 +562,7 @@ struct dentry *pohmelfs_lookup(struct inode *dir, struct dentry *dentry, struct
if (!inode) {
dprintk("%s: No inode for ino: %lu, name: '%s', hash: %x.\n",
__func__, ino, str.name, str.hash);
- //return NULL;
+ /* return NULL; */
return ERR_PTR(-EACCES);
}
} else {
@@ -692,9 +692,9 @@ static int pohmelfs_remove_entry(struct inode *dir, struct dentry *dentry)
n = pohmelfs_search_hash(parent, str.hash);
if (n) {
pohmelfs_fix_offset(parent, n);
- if (test_bit(NETFS_INODE_REMOTE_SYNCED, &pi->state)) {
+ if (test_bit(NETFS_INODE_REMOTE_SYNCED, &pi->state))
pohmelfs_remove_child(pi, n);
- }
+
pohmelfs_name_free(parent, n);
err = 0;
}
@@ -1006,9 +1006,8 @@ static int pohmelfs_rename(struct inode *old_dir, struct dentry *old_dentry,
pi = POHMELFS_I(inode);
old_parent = POHMELFS_I(old_dir);
- if (new_dir) {
+ if (new_dir)
new_dir->i_sb->s_op->write_inode(new_dir, 0);
- }
old_hash = jhash(old_dentry->d_name.name, old_dentry->d_name.len, 0);
str.hash = jhash(new_dentry->d_name.name, new_dentry->d_name.len, 0);
diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c
index b2eaf9047266..7b605795b770 100644
--- a/drivers/staging/pohmelfs/inode.c
+++ b/drivers/staging/pohmelfs/inode.c
@@ -386,7 +386,7 @@ static int pohmelfs_write_inode_create_children(struct inode *inode)
if (inode && (inode->i_state & I_DIRTY)) {
struct pohmelfs_inode *pi = POHMELFS_I(inode);
pohmelfs_write_create_inode(pi);
- //pohmelfs_meta_command(pi, NETFS_INODE_INFO, 0, NULL, NULL, 0);
+ /* pohmelfs_meta_command(pi, NETFS_INODE_INFO, 0, NULL, NULL, 0); */
iput(inode);
}
}
@@ -845,7 +845,7 @@ static void pohmelfs_destroy_inode(struct inode *inode)
struct pohmelfs_sb *psb = POHMELFS_SB(sb);
struct pohmelfs_inode *pi = POHMELFS_I(inode);
- //pohmelfs_data_unlock(pi, 0, inode->i_size, POHMELFS_READ_LOCK);
+ /* pohmelfs_data_unlock(pi, 0, inode->i_size, POHMELFS_READ_LOCK); */
pohmelfs_inode_del_inode(psb, pi);
@@ -943,7 +943,7 @@ err_out_unlock:
return ret;
}
-const static struct file_operations pohmelfs_file_ops = {
+static const struct file_operations pohmelfs_file_ops = {
.open = generic_file_open,
.fsync = pohmelfs_fsync,
@@ -1529,9 +1529,9 @@ static void pohmelfs_drop_scan(struct work_struct *work)
struct pohmelfs_inode *pi;
unsigned int count = 0;
- while ((pi = pohmelfs_get_inode_from_list(psb, &psb->drop_list, &count))) {
+ while ((pi = pohmelfs_get_inode_from_list(psb, &psb->drop_list, &count)))
pohmelfs_put_inode_count(pi, count);
- }
+
pohmelfs_check_states(psb);
if (psb->drop_scan_timeout)
@@ -1568,9 +1568,8 @@ static void pohmelfs_trans_scan_state(struct netfs_state *st)
rb_node = rb_next(rb_node);
err = -ETIMEDOUT;
- if (timeout && (++dst->retries < psb->trans_retries)) {
+ if (timeout && (++dst->retries < psb->trans_retries))
err = netfs_trans_resend(t, psb);
- }
if (err || (t->flags & NETFS_TRANS_SINGLE_DST)) {
if (netfs_trans_remove_nolock(dst, st))
@@ -1777,7 +1776,7 @@ static int pohmelfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
seq_printf(m, "%u ", ctl->idx);
if (ctl->addr.sa_family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *)&st->ctl.addr;
- //seq_printf(m, "%pi4:%u", &sin->sin_addr.s_addr, ntohs(sin->sin_port));
+ /* seq_printf(m, "%pi4:%u", &sin->sin_addr.s_addr, ntohs(sin->sin_port)); */
seq_printf(m, "%u.%u.%u.%u:%u", NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port));
} else if (ctl->addr.sa_family == AF_INET6) {
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)&st->ctl.addr;
diff --git a/drivers/staging/pohmelfs/net.c b/drivers/staging/pohmelfs/net.c
index 11ecac026ca7..5f312c91aab6 100644
--- a/drivers/staging/pohmelfs/net.c
+++ b/drivers/staging/pohmelfs/net.c
@@ -168,8 +168,7 @@ int pohmelfs_data_recv_and_check(struct netfs_state *st, void *data, unsigned in
* Polling machinery.
*/
-struct netfs_poll_helper
-{
+struct netfs_poll_helper {
poll_table pt;
struct netfs_state *st;
};
@@ -915,9 +914,9 @@ static int pohmelfs_recv(void *data)
unsigned char *hash = e->data;
dprintk("%s: received hash: ", __func__);
- for (i=0; i<cmd->csize; ++i) {
+ for (i=0; i<cmd->csize; ++i)
printk("%02x ", hash[i]);
- }
+
printk("\n");
}
#endif
diff --git a/drivers/staging/pohmelfs/netfs.h b/drivers/staging/pohmelfs/netfs.h
index c78cfcb042fb..3b60c611ba80 100644
--- a/drivers/staging/pohmelfs/netfs.h
+++ b/drivers/staging/pohmelfs/netfs.h
@@ -30,8 +30,7 @@
* Network command structure.
* Will be extended.
*/
-struct netfs_cmd
-{
+struct netfs_cmd {
__u16 cmd; /* Command number */
__u16 csize; /* Attached crypto information size */
__u16 cpad; /* Attached padding size */
@@ -96,8 +95,7 @@ enum {
*/
#define _K_SS_MAXSIZE 128
-struct saddr
-{
+struct saddr {
unsigned short sa_family;
char addr[_K_SS_MAXSIZE];
};
@@ -107,8 +105,7 @@ enum {
POHMELFS_CRYPTO_CIPHER,
};
-struct pohmelfs_crypto
-{
+struct pohmelfs_crypto {
unsigned int idx; /* Config index */
unsigned short strlen; /* Size of the attached crypto string including 0-byte
* "cbc(aes)" for example */
@@ -123,8 +120,7 @@ struct pohmelfs_crypto
/*
* Configuration command used to create table of different remote servers.
*/
-struct pohmelfs_ctl
-{
+struct pohmelfs_ctl {
__u32 idx; /* Config index */
__u32 type; /* Socket type */
__u32 proto; /* Socket protocol */
@@ -137,8 +133,7 @@ struct pohmelfs_ctl
/*
* Ack for userspace about requested command.
*/
-struct pohmelfs_cn_ack
-{
+struct pohmelfs_cn_ack {
struct cn_msg msg;
int error;
int msg_num;
@@ -150,8 +145,7 @@ struct pohmelfs_cn_ack
* Inode info structure used to sync with server.
* Check what stat() returns.
*/
-struct netfs_inode_info
-{
+struct netfs_inode_info {
unsigned int mode;
unsigned int nlink;
unsigned int uid;
@@ -205,8 +199,7 @@ enum pohmelfs_capabilities {
/* Extended attributes support on/off */
#define POHMELFS_FLAGS_XATTR (1<<1)
-struct netfs_root_capabilities
-{
+struct netfs_root_capabilities {
__u64 nr_files;
__u64 used, avail;
__u64 flags;
@@ -220,8 +213,7 @@ static inline void netfs_convert_root_capabilities(struct netfs_root_capabilitie
cap->flags = __cpu_to_be64(cap->flags);
}
-struct netfs_crypto_capabilities
-{
+struct netfs_crypto_capabilities {
unsigned short hash_strlen; /* Hash string length, like "hmac(sha1) including 0 byte "*/
unsigned short cipher_strlen; /* Cipher string length with the same format */
unsigned int cipher_keysize; /* Cipher key size */
@@ -241,8 +233,7 @@ enum pohmelfs_lock_type {
POHMELFS_WRITE_LOCK,
};
-struct netfs_lock
-{
+struct netfs_lock {
__u64 start;
__u64 ino;
__u32 size;
@@ -268,8 +259,7 @@ static inline void netfs_convert_lock(struct netfs_lock *lock)
/*
* Private POHMELFS cache of objects in directory.
*/
-struct pohmelfs_name
-{
+struct pohmelfs_name {
struct rb_node hash_node;
struct list_head sync_create_entry;
@@ -286,8 +276,7 @@ struct pohmelfs_name
/*
* POHMELFS inode. Main object.
*/
-struct pohmelfs_inode
-{
+struct pohmelfs_inode {
struct list_head inode_entry; /* Entry in superblock list.
* Objects which are not bound to dentry require to be dropped
* in ->put_super()
@@ -318,8 +307,7 @@ typedef int (* netfs_trans_complete_t)(struct page **pages, unsigned int page_nu
struct netfs_state;
struct pohmelfs_sb;
-struct netfs_trans
-{
+struct netfs_trans {
/*
* Transaction header and attached contiguous data live here.
*/
@@ -426,8 +414,7 @@ static inline void netfs_trans_reset(struct netfs_trans *t)
t->complete = NULL;
}
-struct netfs_trans_dst
-{
+struct netfs_trans_dst {
struct list_head trans_entry;
struct rb_node state_entry;
@@ -456,8 +443,7 @@ int netfs_trans_remove_nolock(struct netfs_trans_dst *dst, struct netfs_state *s
int netfs_trans_init(void);
void netfs_trans_exit(void);
-struct pohmelfs_crypto_engine
-{
+struct pohmelfs_crypto_engine {
u64 iv; /* Crypto IV for current operation */
unsigned long timeout; /* Crypto waiting timeout */
unsigned int size; /* Size of crypto scratchpad */
@@ -474,8 +460,7 @@ struct pohmelfs_crypto_engine
unsigned int page_num;
};
-struct pohmelfs_crypto_thread
-{
+struct pohmelfs_crypto_thread {
struct list_head thread_entry;
struct task_struct *thread;
@@ -497,8 +482,7 @@ void pohmelfs_crypto_thread_make_ready(struct pohmelfs_crypto_thread *th);
/*
* Network state, attached to one server.
*/
-struct netfs_state
-{
+struct netfs_state {
struct mutex __state_lock; /* Can not allow to use the same socket simultaneously */
struct mutex __state_send_lock;
struct netfs_cmd cmd; /* Cached command */
@@ -580,8 +564,7 @@ static inline unsigned int netfs_state_poll(struct netfs_state *st)
struct pohmelfs_config;
-struct pohmelfs_sb
-{
+struct pohmelfs_sb {
struct rb_root mcache_root;
struct mutex mcache_lock;
atomic_long_t mcache_gen;
@@ -718,15 +701,13 @@ static inline void pohmelfs_put_inode(struct pohmelfs_inode *pi)
spin_unlock(&psb->ino_lock);
}
-struct pohmelfs_config
-{
+struct pohmelfs_config {
struct list_head config_entry;
struct netfs_state state;
};
-struct pohmelfs_config_group
-{
+struct pohmelfs_config_group {
/*
* Entry in the global config group list.
*/
@@ -814,8 +795,7 @@ void pohmelfs_switch_active(struct pohmelfs_sb *psb);
int pohmelfs_construct_path_string(struct pohmelfs_inode *pi, void *data, int len);
int pohmelfs_path_length(struct pohmelfs_inode *pi);
-struct pohmelfs_crypto_completion
-{
+struct pohmelfs_crypto_completion {
struct completion complete;
int error;
};
@@ -864,7 +844,7 @@ static inline int pohmelfs_need_lock(struct pohmelfs_inode *pi, int type)
int __init pohmelfs_mcache_init(void);
void pohmelfs_mcache_exit(void);
-//#define CONFIG_POHMELFS_DEBUG
+/* #define CONFIG_POHMELFS_DEBUG */
#ifdef CONFIG_POHMELFS_DEBUG
#define dprintka(f, a...) printk(f, ##a)
@@ -891,8 +871,7 @@ static inline void netfs_trans_put(struct netfs_trans *t)
}
}
-struct pohmelfs_mcache
-{
+struct pohmelfs_mcache {
struct rb_node mcache_entry;
struct completion complete;
diff --git a/drivers/staging/pohmelfs/trans.c b/drivers/staging/pohmelfs/trans.c
index fef5f9bd6920..4587f6d546aa 100644
--- a/drivers/staging/pohmelfs/trans.c
+++ b/drivers/staging/pohmelfs/trans.c
@@ -101,7 +101,8 @@ static int netfs_trans_send_pages(struct netfs_trans *t, struct netfs_state *st)
goto err_out;
}
- msg.msg_flags = MSG_WAITALL|(attached_pages == 1)?0:MSG_MORE;
+ msg.msg_flags = MSG_WAITALL | (attached_pages == 1 ? 0 :
+ MSG_MORE);
err = kernel_sendpage(st->socket, page, 0, size, msg.msg_flags);
if (err <= 0) {
@@ -177,9 +178,9 @@ int netfs_trans_send(struct netfs_trans *t, struct netfs_state *st)
err_out_unlock_return:
- if (st->need_reset) {
+ if (st->need_reset)
netfs_state_exit(st);
- }
+
netfs_state_unlock_send(st);
dprintk("%s: t: %p, gen: %u, err: %d.\n",
diff --git a/drivers/staging/rspiusb/rspiusb.c b/drivers/staging/rspiusb/rspiusb.c
index ecaffb503111..b2339724a315 100644
--- a/drivers/staging/rspiusb/rspiusb.c
+++ b/drivers/staging/rspiusb/rspiusb.c
@@ -217,7 +217,7 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case PIUSB_GETVNDCMD:
if (copy_from_user
(&ctrl, (void __user *)arg, sizeof(struct ioctl_struct)))
- info("copy_from_user failed\n");
+ dev_err(&pdx->udev->dev, "copy_from_user failed\n");
dbg("%s %x\n", "Get Vendor Command = ", ctrl.cmd);
retval =
usb_control_msg(pdx->udev, usb_rcvctrlpipe(pdx->udev, 0),
@@ -231,7 +231,7 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case PIUSB_SETVNDCMD:
if (copy_from_user
(&ctrl, (void __user *)arg, sizeof(struct ioctl_struct)))
- info("copy_from_user failed\n");
+ dev_err(&pdx->udev->dev, "copy_from_user failed\n");
// dbg( "%s %x", "Set Vendor Command = ",ctrl.cmd );
controlData = ctrl.pData[0];
controlData |= (ctrl.pData[1] << 8);
@@ -247,7 +247,7 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break;
case PIUSB_WRITEPIPE:
if (copy_from_user(&ctrl, (void __user *)arg, _IOC_SIZE(cmd)))
- info("copy_from_user WRITE_DUMMY failed\n");
+ dev_err(&pdx->udev->dev, "copy_from_user WRITE_DUMMY failed\n");
if (!access_ok(VERIFY_READ, ctrl.pData, ctrl.numbytes)) {
dbg("can't access pData");
return 0;
@@ -258,7 +258,7 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case PIUSB_USERBUFFER:
if (copy_from_user
(&ctrl, (void __user *)arg, sizeof(struct ioctl_struct)))
- info("copy_from_user failed\n");
+ dev_err(&pdx->udev->dev, "copy_from_user failed\n");
return MapUserBuffer((struct ioctl_struct *) & ctrl, pdx);
break;
case PIUSB_UNMAP_USERBUFFER:
@@ -268,7 +268,7 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case PIUSB_READPIPE:
if (copy_from_user
(&ctrl, (void __user *)arg, sizeof(struct ioctl_struct)))
- info("copy_from_user failed\n");
+ dev_err(&pdx->udev->dev, "copy_from_user failed\n");
switch (ctrl.endpoint) {
case 0: //ST133 Pixel Data or PIXIS IO
if (pdx->iama == PIXIS_PID) {
@@ -387,7 +387,7 @@ static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
dbg("PIUSB_SETFRAMESIZE");
if (copy_from_user
(&ctrl, (void __user *)arg, sizeof(struct ioctl_struct)))
- info("copy_from_user failed\n");
+ dev_err(&pdx->udev->dev, "copy_from_user failed\n");
pdx->frameSize = ctrl.numbytes;
pdx->num_frames = ctrl.numFrames;
if (!pdx->sgl)
@@ -449,7 +449,7 @@ int piusb_output(struct ioctl_struct * io, unsigned char *uBuf, int len,
usb_buffer_alloc(pdx->udev, len, GFP_KERNEL,
&urb->transfer_dma);
if (!kbuf) {
- info("buffer_alloc failed\n");
+ dev_err(&pdx->udev->dev, "buffer_alloc failed\n");
return -ENOMEM;
}
memcpy(kbuf, uBuf, len);
diff --git a/drivers/staging/rt2860/2860_main_dev.c b/drivers/staging/rt2860/2860_main_dev.c
index ff7f83380736..c7038e03a4dc 100644
--- a/drivers/staging/rt2860/2860_main_dev.c
+++ b/drivers/staging/rt2860/2860_main_dev.c
@@ -37,13 +37,6 @@
#include "rt_config.h"
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// record whether the card in the card list is used in the card file
-extern UINT8 MC_CardUsed[];
-#endif // MULTIPLE_CARD_SUPPORT //
-
-
extern INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
@@ -110,13 +103,10 @@ static struct pci_device_id rt2860_pci_tbl[] __devinitdata =
};
MODULE_DEVICE_TABLE(pci, rt2860_pci_tbl);
-#ifdef CONFIG_STA_SUPPORT
MODULE_LICENSE("GPL");
#ifdef MODULE_VERSION
MODULE_VERSION(STA_DRIVER_VERSION);
#endif
-#endif // CONFIG_STA_SUPPORT //
-
//
// Our PCI driver structure
@@ -328,14 +318,6 @@ static VOID __devexit rt2860_remove_one(
if (pAd != NULL)
{
-#ifdef MULTIPLE_CARD_SUPPORT
- if ((pAd->MC_RowID >= 0) && (pAd->MC_RowID <= MAX_NUM_OF_MULTIPLE_CARD))
- MC_CardUsed[pAd->MC_RowID] = 0; // not clear MAC address
-#endif // MULTIPLE_CARD_SUPPORT //
-
-
-
-
// Unregister network device
unregister_netdev(net_dev);
@@ -494,10 +476,8 @@ static void rx_done_tasklet(unsigned long data)
pObj = (POS_COOKIE) pAd->OS_Cookie;
pAd->int_pending &= ~(INT_RX);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- bReschedule = STARxDoneInterruptHandle(pAd, 0);
-#endif // CONFIG_STA_SUPPORT //
+
+ bReschedule = STARxDoneInterruptHandle(pAd, 0);
RTMP_INT_LOCK(&pAd->irq_lock, flags);
/*
@@ -933,15 +913,8 @@ rt2860_interrupt(int irq, void *dev_instance)
RTMPHandleTBTTInterrupt(pAd);
}
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (IntSource.word & AutoWakeupInt)
- RTMPHandleTwakeupInterrupt(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
+ if (IntSource.word & AutoWakeupInt)
+ RTMPHandleTwakeupInterrupt(pAd);
return IRQ_HANDLED;
}
@@ -1182,9 +1155,7 @@ VOID RT28xx_UpdateBeaconToAsic(
else
{
ptr = (PUCHAR)&pAd->BeaconTxWI;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(ptr, TYPE_TXWI);
-#endif
+
for (i=0; i<TXWI_SIZE; i+=4) // 16-byte TXWI field
{
UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
@@ -1212,7 +1183,6 @@ VOID RT28xx_UpdateBeaconToAsic(
}
-#ifdef CONFIG_STA_SUPPORT
VOID RTMPInitPCIeLinkCtrlValue(
IN PRTMP_ADAPTER pAd)
{
@@ -1256,7 +1226,6 @@ VOID RTMPPCIeLinkCtrlSetting(
IN USHORT Max)
{
}
-#endif // CONFIG_STA_SUPPORT //
VOID rt2860_stop(struct net_device *net_dev)
{
diff --git a/drivers/staging/rt2860/Makefile b/drivers/staging/rt2860/Makefile
index b95636478464..c9fe92583d7e 100644
--- a/drivers/staging/rt2860/Makefile
+++ b/drivers/staging/rt2860/Makefile
@@ -2,11 +2,8 @@ obj-$(CONFIG_RT2860) += rt2860sta.o
# TODO: all of these should be removed
EXTRA_CFLAGS += -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
-EXTRA_CFLAGS += -DCONFIG_STA_SUPPORT
+EXTRA_CFLAGS += -DRT2860
EXTRA_CFLAGS += -DDBG
-EXTRA_CFLAGS += -DDOT11_N_SUPPORT
-EXTRA_CFLAGS += -DWPA_SUPPLICANT_SUPPORT
-EXTRA_CFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT
rt2860sta-objs := \
common/md5.o \
diff --git a/drivers/staging/rt2860/ap.h b/drivers/staging/rt2860/ap.h
index df6db2813121..a814d55abeff 100644
--- a/drivers/staging/rt2860/ap.h
+++ b/drivers/staging/rt2860/ap.h
@@ -159,9 +159,6 @@ USHORT APBuildAssociation(
IN UCHAR *pRSNLen,
IN BOOLEAN bWmmCapable,
IN ULONG RalinkIe,
-#ifdef DOT11N_DRAFT3
- IN EXT_CAP_INFO_ELEMENT ExtCapInfo,
-#endif // DOT11N_DRAFT3 //
IN HT_CAPABILITY_IE *pHtCapability,
IN UCHAR HtCapabilityLen,
OUT USHORT *pAid);
@@ -282,11 +279,6 @@ VOID SupportRate(
BOOLEAN ApScanRunning(
IN PRTMP_ADAPTER pAd);
-#ifdef DOT11N_DRAFT3
-VOID APOverlappingBSSScan(
- IN RTMP_ADAPTER *pAd);
-#endif // DOT11N_DRAFT3 //
-
// ap_wpa.c
VOID APWpaStateMachineInit(
@@ -332,6 +324,13 @@ VOID APQuickResponeForRateUpExec(
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
+#ifdef RT2870
+VOID BeaconUpdateExec(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3);
+#endif // RT2870 //
VOID RTMPSetPiggyBack(
IN PRTMP_ADAPTER pAd,
@@ -408,10 +407,8 @@ VOID ApLogEvent(
IN PUCHAR pAddr,
IN USHORT Event);
-#ifdef DOT11_N_SUPPORT
VOID APUpdateOperationMode(
IN PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
VOID APUpdateCapabilityAndErpIe(
IN PRTMP_ADAPTER pAd);
@@ -472,9 +469,6 @@ BOOLEAN PeerAssocReqCmmSanity(
OUT UCHAR *pRSNLen,
OUT BOOLEAN *pbWmmCapable,
OUT ULONG *pRalinkIe,
-#ifdef DOT11N_DRAFT3
- OUT EXT_CAP_INFO_ELEMENT *pExtCapInfo,
-#endif // DOT11N_DRAFT3 //
OUT UCHAR *pHtCapabilityLen,
OUT HT_CAPABILITY_IE *pHtCapability);
@@ -529,26 +523,6 @@ BOOLEAN APPeerBeaconAndProbeRspSanity(
OUT BOOLEAN *ExtendedRateIeExist,
OUT UCHAR *Erp);
-// ap_info.c
-
-#ifdef WIN_NDIS
-NDIS_STATUS APQueryInformation(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN NDIS_OID Oid,
- IN PVOID pInformationBuffer,
- IN ULONG InformationBufferLength,
- OUT PULONG pBytesWritten,
- OUT PULONG pBytesNeeded);
-
-NDIS_STATUS APSetInformation(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN NDIS_OID Oid,
- IN PVOID pInformationBuffer,
- IN ULONG InformationBufferLength,
- OUT PULONG pBytesRead,
- OUT PULONG pBytesNeeded);
-#endif
-
// ================== end of AP RTMP.h ========================
diff --git a/drivers/staging/rt2860/chlist.h b/drivers/staging/rt2860/chlist.h
index 9e15b9daeb80..1ad26b574083 100644
--- a/drivers/staging/rt2860/chlist.h
+++ b/drivers/staging/rt2860/chlist.h
@@ -524,7 +524,12 @@ static CH_REGION ChRegion[] =
JAP,
{
{ 1, 14, 20, BOTH, FALSE}, // 2.4 G, ch 1~14
+#ifndef RT30xx
{ 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
+#endif
+#ifdef RT30xx
+ { 34, 4, 23, IDOR, FALSE}, // 5G, ch 34~46
+#endif
{ 0}, // end
}
},
@@ -957,16 +962,12 @@ static inline VOID ChBandCheck(
switch(PhyMode)
{
case PHY_11A:
-#ifdef DOT11_N_SUPPORT
case PHY_11AN_MIXED:
-#endif // DOT11_N_SUPPORT //
*pChType = BAND_5G;
break;
case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
case PHY_11AGN_MIXED:
case PHY_11ABGN_MIXED:
-#endif // DOT11_N_SUPPORT //
*pChType = BAND_BOTH;
break;
@@ -1114,8 +1115,6 @@ static inline VOID BuildBeaconChList(
}
}
-
-#ifdef DOT11_N_SUPPORT
static inline BOOLEAN IsValidChannel(
IN PRTMP_ADAPTER pAd,
IN UCHAR channel)
@@ -1201,49 +1200,6 @@ static inline VOID N_ChannelCheck(
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
//pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT()
}
-#if 0
- switch (pAd->CommonCfg.CountryRegion & 0x7f)
- {
- case REGION_0_BG_BAND: // 1 -11
- case REGION_1_BG_BAND: // 1 - 13
- case REGION_5_BG_BAND: // 1 - 14
- if (Channel <= 4)
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- }
- else if (Channel >= 8)
- {
- if ((ChannelNum - Channel) < 4)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- }
- break;
-
- case REGION_2_BG_BAND: // 10 - 11
- case REGION_3_BG_BAND: // 10 - 13
- case REGION_4_BG_BAND: // 14
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- break;
-
- case REGION_6_BG_BAND: // 3 - 9
- if (Channel <= 5)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- else if (Channel == 6)
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- else if (Channel >= 7)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- break;
-
- case REGION_7_BG_BAND: // 5 - 13
- if (Channel <= 8)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- else if (Channel >= 10)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- break;
-
- default: // Error. should never happen
- break;
- }
-#endif
}
}
@@ -1273,8 +1229,6 @@ static inline VOID N_SetCenCh(
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
}
}
-#endif // DOT11_N_SUPPORT //
-
static inline UINT8 GetCuntryMaxTxPwr(
IN PRTMP_ADAPTER pAd,
diff --git a/drivers/staging/rt2860/common/2860_rtmp_init.c b/drivers/staging/rt2860/common/2860_rtmp_init.c
index 546f304ec330..0bc0fb99d2e4 100644
--- a/drivers/staging/rt2860/common/2860_rtmp_init.c
+++ b/drivers/staging/rt2860/common/2860_rtmp_init.c
@@ -173,9 +173,6 @@ NDIS_STATUS RTMPAllocTxRxRingMemory(
pTxD->SDPtr0 = BufBasePaLow;
// advance to next ring descriptor address
pTxD->DMADONE = 1;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
RingBasePaLow += TXD_SIZE;
RingBaseVa = (PUCHAR) RingBaseVa + TXD_SIZE;
@@ -236,9 +233,6 @@ NDIS_STATUS RTMPAllocTxRxRingMemory(
pTxD = (PTXD_STRUC) pAd->MgmtRing.Cell[index].AllocVa;
pTxD->DMADONE = 1;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
// no pre-allocated buffer required in MgmtRing for scatter-gather case
}
DBGPRINT(RT_DEBUG_TRACE, ("MGMT Ring: total %d entry allocated\n", index));
@@ -318,10 +312,6 @@ NDIS_STATUS RTMPAllocTxRxRingMemory(
pRxD = (PRXD_STRUC) pAd->RxRing.Cell[index].AllocVa;
pRxD->SDP0 = RTMP_GetPhysicalAddressLow(pDmaBuf->AllocPa);
pRxD->DDONE = 0;
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);
-#endif
}
DBGPRINT(RT_DEBUG_TRACE, ("Rx Ring: total %d entry allocated\n", index));
@@ -821,10 +811,6 @@ PNDIS_PACKET GetPacketFromRxRing(
IN OUT UINT32 *pRxPending)
{
PRXD_STRUC pRxD;
-#ifdef RT_BIG_ENDIAN
- PRXD_STRUC pDestRxD;
- RXD_STRUC RxD;
-#endif
PNDIS_PACKET pRxPacket = NULL;
PNDIS_PACKET pNewPacket;
PVOID AllocVa;
@@ -853,15 +839,8 @@ PNDIS_PACKET GetPacketFromRxRing(
}
-#ifdef RT_BIG_ENDIAN
- pDestRxD = (PRXD_STRUC) pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].AllocVa;
- RxD = *pDestRxD;
- pRxD = &RxD;
- RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);
-#else
// Point to Rx indexed rx ring descriptor
pRxD = (PRXD_STRUC) pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].AllocVa;
-#endif
if (pRxD->DDONE == 0)
{
@@ -904,10 +883,6 @@ PNDIS_PACKET GetPacketFromRxRing(
*pRxPending = *pRxPending - 1;
// update rx descriptor and kick rx
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);
- WriteBackToDescriptor((PUCHAR)pDestRxD, (PUCHAR)pRxD, FALSE, TYPE_RXD);
-#endif
INC_RING_INDEX(pAd->RxRing.RxSwReadIdx, RX_RING_SIZE);
pAd->RxRing.RxCpuIdx = (pAd->RxRing.RxSwReadIdx == 0) ? (RX_RING_SIZE-1) : (pAd->RxRing.RxSwReadIdx-1);
diff --git a/drivers/staging/rt2860/common/action.c b/drivers/staging/rt2860/common/action.c
index d6f530fb857f..a4d9fdc0736e 100644
--- a/drivers/staging/rt2860/common/action.c
+++ b/drivers/staging/rt2860/common/action.c
@@ -72,17 +72,12 @@ VOID ActionStateMachineInit(
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction);
-#ifdef QOS_DLS_SUPPORT
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)PeerDLSAction);
-#endif // QOS_DLS_SUPPORT //
-#ifdef DOT11_N_SUPPORT
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE, (STATE_MACHINE_FUNC)PeerHTAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE, (STATE_MACHINE_FUNC)MlmeADDBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
-#endif // DOT11_N_SUPPORT //
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE, (STATE_MACHINE_FUNC)PeerPublicAction);
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE, (STATE_MACHINE_FUNC)PeerRMAction);
@@ -92,7 +87,6 @@ VOID ActionStateMachineInit(
StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID, (STATE_MACHINE_FUNC)MlmeInvalidAction);
}
-#ifdef DOT11_N_SUPPORT
VOID MlmeADDBAAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
@@ -131,21 +125,12 @@ VOID MlmeADDBAAction(
pBAEntry =&pAd->BATable.BAOriEntry[Idx];
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
else
-#ifdef QOS_DLS_SUPPORT
- if (pAd->MacTab.Content[pInfo->Wcid].ValidAsDls)
- ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#endif // QOS_DLS_SUPPORT //
ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pInfo->pAddr);
-
}
-#endif // CONFIG_STA_SUPPORT //
Frame.Category = CATEGORY_BA;
Frame.Action = ADDBA_REQ;
@@ -220,10 +205,8 @@ VOID MlmeDELBAAction(
// SEND BAR (Send BAR to refresh peer reordering buffer.)
Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
+
+ BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress);
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL funciton.
FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; // make sure sequence not clear in DEL funciton.
@@ -241,20 +224,14 @@ VOID MlmeDELBAAction(
// SEND DELBA FRAME
FrameLen = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
else
-#ifdef QOS_DLS_SUPPORT
- if (pAd->MacTab.Content[pInfo->Wcid].ValidAsDls)
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#endif // QOS_DLS_SUPPORT //
ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[pInfo->Wcid].Addr);
}
-#endif // CONFIG_STA_SUPPORT //
+
Frame.Category = CATEGORY_BA;
Frame.Action = DELBA;
Frame.DelbaParm.Initiator = pInfo->Initiator;
@@ -271,7 +248,6 @@ VOID MlmeDELBAAction(
DBGPRINT(RT_DEBUG_TRACE, ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n", pInfo->Initiator));
}
}
-#endif // DOT11_N_SUPPORT //
VOID MlmeQOSAction(
IN PRTMP_ADAPTER pAd,
@@ -299,40 +275,6 @@ VOID PeerQOSAction(
{
}
-#ifdef QOS_DLS_SUPPORT
-VOID PeerDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- switch(Action)
- {
- case ACTION_DLS_REQUEST:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsReqAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
-
- case ACTION_DLS_RESPONSE:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsRspAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
-
- case ACTION_DLS_TEARDOWN:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsTearDownAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
- }
-}
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
VOID PeerBAAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
@@ -353,320 +295,12 @@ VOID PeerBAAction(
}
}
-
-#ifdef DOT11N_DRAFT3
-
-#ifdef CONFIG_STA_SUPPORT
-VOID StaPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Bss2040Coexist)
-{
- BSS_2040_COEXIST_IE BssCoexist;
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- BssCoexist.word = Bss2040Coexist;
- // AP asks Station to return a 20/40 BSS Coexistence mgmt frame. So we first starts a scan, then send back 20/40 BSS Coexistence mgmt frame
- if ((BssCoexist.field.InfoReq == 1) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)))
- {
- // Clear record first. After scan , will update those bit and send back to transmiter.
- pAd->CommonCfg.BSSCoexist2040.field.InfoReq = 1;
- pAd->CommonCfg.BSSCoexist2040.field.Intolerant40 = 0;
- pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 0;
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_2040_BSS_COEXIST);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- }
-}
-
-
-/*
-Description : Build Intolerant Channel Rerpot from Trigger event table.
-return : how many bytes copied.
-*/
-ULONG BuildIntolerantChannelRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest)
-{
- ULONG FrameLen = 0;
- ULONG ReadOffset = 0;
- UCHAR i;
- UCHAR LastRegClass = 0xff;
- PUCHAR pLen;
-
- for ( i = 0;i < MAX_TRIGGER_EVENT;i++)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid == TRUE)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass == LastRegClass)
- {
- *(pDest + ReadOffset) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
- *pLen++;
- ReadOffset++;
- FrameLen++;
- }
- else
- {
- *(pDest + ReadOffset) = IE_2040_BSS_INTOLERANT_REPORT; // IE
- *(pDest + ReadOffset + 1) = 2; // Len = RegClass byte + channel byte.
- pLen = pDest + ReadOffset + 1;
- LastRegClass = pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass;
- *(pDest + ReadOffset + 2) = LastRegClass; // Len = RegClass byte + channel byte.
- *(pDest + ReadOffset + 3) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
- FrameLen += 4;
- ReadOffset += 4;
- }
-
- }
- }
- return FrameLen;
-}
-
-
-/*
-Description : Send 20/40 BSS Coexistence Action frame If one trigger event is triggered.
-*/
-VOID Send2040CoexistAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- FRAME_ACTION_HDR Frame;
- ULONG FrameLen;
- ULONG IntolerantChaRepLen;
-
- IntolerantChaRepLen = 0;
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction() allocate memory failed \n"));
- return;
- }
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[Wcid].Addr, pAd->CommonCfg.Bssid);
- Frame.Category = CATEGORY_PUBLIC;
- Frame.Action = ACTION_BSS_2040_COEXIST;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ACTION_HDR), &Frame,
- END_OF_ARGS);
-
- *(pOutBuffer + FrameLen) = pAd->CommonCfg.BSSCoexist2040.word;
- FrameLen++;
-
- if (bAddIntolerantCha == TRUE)
- IntolerantChaRepLen = BuildIntolerantChannelRep(pAd, pOutBuffer + FrameLen);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen + IntolerantChaRepLen);
- DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction( BSSCoexist2040 = 0x%x ) \n", pAd->CommonCfg.BSSCoexist2040.word));
-
-}
-
-
-/*
- ==========================================================================
- Description:
- After scan, Update 20/40 BSS Coexistence IE and send out.
- According to 802.11n D3.03 11.14.10
-
- Parameters:
- ==========================================================================
- */
-VOID Update2040CoexistFrameAndNotify(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha)
-{
- BSS_2040_COEXIST_IE OldValue;
-
- OldValue.word = pAd->CommonCfg.BSSCoexist2040.word;
- if ((pAd->CommonCfg.TriggerEventTab.EventANo > 0) || (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0))
- pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 1;
-
- // Need to check !!!!
- // How STA will set Intolerant40 if implementation dependent. Now we don't set this bit first.!!!!!
- // So Only check BSS20WidthReq change.
- if (OldValue.field.BSS20WidthReq != pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq)
- {
- Send2040CoexistAction(pAd, Wcid, bAddIntolerantCha);
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-BOOLEAN ChannelSwitchSanityCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary)
-{
- UCHAR i;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- if ((NewChannel > 7) && (Secondary == 1))
- return FALSE;
-
- if ((NewChannel < 5) && (Secondary == 3))
- return FALSE;
-
- // 0. Check if new channel is in the channellist.
- for (i = 0;i < pAd->ChannelListNum;i++)
- {
- if (pAd->ChannelList[i].Channel == NewChannel)
- {
- break;
- }
- }
-
- if (i == pAd->ChannelListNum)
- return FALSE;
-
- return TRUE;
-}
-
-
-VOID ChannelSwitchAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary)
-{
- UCHAR BBPValue = 0;
- ULONG MACValue;
-
- DBGPRINT(RT_DEBUG_TRACE,("SPECTRUM - ChannelSwitchAction(NewChannel = %d , Secondary = %d) \n", NewChannel, Secondary));
-
- if (ChannelSwitchSanityCheck(pAd, Wcid, NewChannel, Secondary) == FALSE)
- return;
-
- // 1. Switches to BW = 20.
- if (Secondary == 0)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- pAd->CommonCfg.Channel = NewChannel;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel,FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("!!!20MHz !!! \n" ));
- }
- // 1. Switches to BW = 40 And Station supports BW = 40.
- else if (((Secondary == 1) || (Secondary == 3)) && (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == 1))
- {
- pAd->CommonCfg.Channel = NewChannel;
-
- if (Secondary == 1)
- {
- // Secondary above.
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
- MACValue &= 0xfe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
- BBPValue&= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else
- {
- // Secondary below.
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
- MACValue &= 0xfe;
- MACValue |= 0x1;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
- BBPValue&= (~0x20);
- BBPValue|= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 1;
- }
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
VOID PeerPublicAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
{
-#ifdef DOT11N_DRAFT3
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-#endif // DOT11N_DRAFT3 //
-
if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
return;
-
-#ifdef DOT11N_DRAFT3
- switch(Action)
- {
- case ACTION_BSS_2040_COEXIST: // Format defined in IEEE 7.4.7a.1 in 11n Draf3.03
- {
- //UCHAR BssCoexist;
- BSS_2040_COEXIST_ELEMENT *pCoexistInfo;
- BSS_2040_COEXIST_IE *pBssCoexistIe;
- BSS_2040_INTOLERANT_CH_REPORT *pIntolerantReport = NULL;
-
- if (Elem->MsgLen <= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT)) )
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ACTION - 20/40 BSS Coexistence Management Frame length too short! len = %ld!\n", Elem->MsgLen));
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("ACTION - 20/40 BSS Coexistence Management action----> \n"));
- hex_dump("CoexistenceMgmtFrame", Elem->Msg, Elem->MsgLen);
-
-
- pCoexistInfo = (BSS_2040_COEXIST_ELEMENT *) &Elem->Msg[LENGTH_802_11+2];
- //hex_dump("CoexistInfo", (PUCHAR)pCoexistInfo, sizeof(BSS_2040_COEXIST_ELEMENT));
- if (Elem->MsgLen >= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT) + sizeof(BSS_2040_INTOLERANT_CH_REPORT)))
- {
- pIntolerantReport = (BSS_2040_INTOLERANT_CH_REPORT *)((PUCHAR)pCoexistInfo + sizeof(BSS_2040_COEXIST_ELEMENT));
- }
- //hex_dump("IntolerantReport ", (PUCHAR)pIntolerantReport, sizeof(BSS_2040_INTOLERANT_CH_REPORT));
-
- pBssCoexistIe = (BSS_2040_COEXIST_IE *)(&pCoexistInfo->BssCoexistIe);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (INFRA_ON(pAd))
- {
- StaPublicAction(pAd, pCoexistInfo);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- }
- break;
- }
-
-#endif // DOT11N_DRAFT3 //
-
}
@@ -694,7 +328,6 @@ VOID PeerRMAction(
return;
}
-#ifdef DOT11_N_SUPPORT
static VOID respond_ht_information_exchange_action(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
@@ -721,15 +354,12 @@ static VOID respond_ht_information_exchange_action(
NdisZeroMemory(&HTINFOframe, sizeof(FRAME_HT_INFO));
// 2-1. Prepare ADDBA Response frame.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
else
ActHeaderInit(pAd, &HTINFOframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
}
-#endif // CONFIG_STA_SUPPORT //
HTINFOframe.Category = CATEGORY_HT;
HTINFOframe.Action = HT_INFO_EXCHANGE;
@@ -745,51 +375,6 @@ static VOID respond_ht_information_exchange_action(
MlmeFreeMemory(pAd, pOutBuffer);
}
-
-#ifdef DOT11N_DRAFT3
-VOID SendNotifyBWActionFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- FRAME_ACTION_HDR Frame;
- ULONG FrameLen;
- PUCHAR pAddr1;
-
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ACT - SendNotifyBWAction() allocate memory failed \n"));
- return;
- }
-
- if (Wcid == MCAST_WCID)
- pAddr1 = &BROADCAST_ADDR[0];
- else
- pAddr1 = pAd->MacTab.Content[Wcid].Addr;
- ActHeaderInit(pAd, &Frame.Hdr, pAddr1, pAd->ApCfg.MBSSID[apidx].Bssid, pAd->ApCfg.MBSSID[apidx].Bssid);
-
- Frame.Category = CATEGORY_HT;
- Frame.Action = NOTIFY_BW_ACTION;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ACTION_HDR), &Frame,
- END_OF_ARGS);
-
- *(pOutBuffer + FrameLen) = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
- FrameLen++;
-
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- DBGPRINT(RT_DEBUG_TRACE,("ACT - SendNotifyBWAction(NotifyBW= %d)!\n", pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth));
-
-}
-#endif // DOT11N_DRAFT3 //
-
-
VOID PeerHTAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
@@ -803,7 +388,7 @@ VOID PeerHTAction(
{
case NOTIFY_BW_ACTION:
DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Notify Channel bandwidth action----> \n"));
-#ifdef CONFIG_STA_SUPPORT
+
if(pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
{
// Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
@@ -813,7 +398,6 @@ VOID PeerHTAction(
Elem->Msg[LENGTH_802_11+2] ));
break;
}
-#endif // CONFIG_STA_SUPPORT //
if (Elem->Msg[LENGTH_802_11+2] == 0) // 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
@@ -881,11 +465,6 @@ VOID ORIBATimerTimeout(
INT i, total;
UCHAR TID;
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
total = pAd->MacTab.Size * NUM_OF_TID;
for (i = 1; ((i <MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)) ; i++)
@@ -938,10 +517,8 @@ VOID SendRefreshBAR(
}
Sequence = pEntry->TxSeq[TID];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pEntry->Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
+
+ BarHeaderInit(pAd, &FrameBar, pEntry->Addr, pAd->CurrentAddress);
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
FrameBar.StartingSeq.field.StartSeq = Sequence; // make sure sequence not clear in DEL funciton.
@@ -950,15 +527,20 @@ VOID SendRefreshBAR(
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(FRAME_BAR), &FrameBar,
END_OF_ARGS);
+
if (1) // Now we always send BAR.
{
+#ifndef RT30xx
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
+#endif
+#ifdef RT30xx
+ MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
+#endif
}
MlmeFreeMemory(pAd, pOutBuffer);
}
}
}
-#endif // DOT11_N_SUPPORT //
VOID ActHeaderInit(
IN PRTMP_ADAPTER pAd,
diff --git a/drivers/staging/rt2860/common/action.h b/drivers/staging/rt2860/common/action.h
index ce3877dce81b..cfc2a5f8d1aa 100644
--- a/drivers/staging/rt2860/common/action.h
+++ b/drivers/staging/rt2860/common/action.h
@@ -41,17 +41,10 @@
typedef struct PACKED __HT_INFO_OCTET
{
-#ifdef RT_BIG_ENDIAN
- UCHAR Reserved:5;
- UCHAR STA_Channel_Width:1;
- UCHAR Forty_MHz_Intolerant:1;
- UCHAR Request:1;
-#else
UCHAR Request:1;
UCHAR Forty_MHz_Intolerant:1;
UCHAR STA_Channel_Width:1;
UCHAR Reserved:5;
-#endif
} HT_INFORMATION_OCTET;
diff --git a/drivers/staging/rt2860/common/ba_action.c b/drivers/staging/rt2860/common/ba_action.c
index 591d1e2158da..b95a341caacd 100644
--- a/drivers/staging/rt2860/common/ba_action.c
+++ b/drivers/staging/rt2860/common/ba_action.c
@@ -25,8 +25,6 @@
*************************************************************************
*/
-#ifdef DOT11_N_SUPPORT
-
#include "../rt_config.h"
@@ -132,10 +130,7 @@ void Announce_Reordering_Packet(IN PRTMP_ADAPTER pAd,
// pass this 802.3 packet to upper layer or forward this packet to WM directly
//
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket, RTMP_GET_PACKET_IF(pPacket));
-#endif // CONFIG_STA_SUPPORT //
+ ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket, RTMP_GET_PACKET_IF(pPacket));
}
}
@@ -449,9 +444,6 @@ void ba_flush_reordering_timeout_mpdus(
&& (pBAEntry->list.qlen > 0)
)
{
-// printk("timeout[%d] (%lx-%lx = %d > %d): %x, ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
-// (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), REORDERING_PACKET_TIMEOUT,
-// pBAEntry->LastIndSeq);
//
// force LastIndSeq to shift to LastIndSeq+1
//
@@ -468,22 +460,7 @@ void ba_flush_reordering_timeout_mpdus(
pBAEntry->LastIndSeq = Sequence;
}
- //printk("%x, flush one!\n", pBAEntry->LastIndSeq);
-
}
-#if 0
- else if (
- (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(MAX_REORDERING_PACKET_TIMEOUT))) &&
- (pBAEntry->list.qlen > 1))
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%lx-%lx = %d > %d): %x\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
- (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), MAX_REORDERING_PACKET_TIMEOUT,
- pBAEntry->LastIndSeq));
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- pBAEntry->LastIndSeqAtTimer = Now32;
- }
-#endif
}
@@ -554,6 +531,13 @@ VOID BAOriSessionSetUp(
pBAEntry->TimeOutValue = TimeOut;
pBAEntry->pAdapter = pAd;
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_TRACE,("Send AddBA to %02x:%02x:%02x:%02x:%02x:%02x Tid:%d isForced:%d Wcid:%d\n"
+ ,pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2]
+ ,pEntry->Addr[3],pEntry->Addr[4],pEntry->Addr[5]
+ ,TID,isForced,pEntry->Aid));
+#endif
+
if (!(pEntry->TXBAbitmap & (1<<TID)))
{
RTMPInitTimer(pAd, &pBAEntry->ORIBATimer, GET_TIMER_FUNCTION(BAOriSessionSetupTimeout), pBAEntry, FALSE);
@@ -610,11 +594,7 @@ VOID BAOriSessionAdd(
return;
}
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pBAEntry->Wcid].Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
+ BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pBAEntry->Wcid].Addr, pAd->CurrentAddress);
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
FrameBar.StartingSeq.field.StartSeq = pBAEntry->Sequence; // make sure sequence not clear in DEL funciton.
@@ -701,10 +681,6 @@ BOOLEAN BARecSessionAdd(
RTMPInitTimer(pAd, &pBAEntry->RECBATimer, GET_TIMER_FUNCTION(BARecSessionIdleTimeout), pBAEntry, TRUE);
}
-#if 0 // for debugging
- RTMPSetTimer(&pBAEntry->RECBATimer, REC_BA_SESSION_IDLE_TIMEOUT);
-#endif
-
// Set Bitmap flag.
pEntry->RXBAbitmap |= (1<<TID);
pEntry->BARecWcidArray[TID] = Idx;
@@ -1083,20 +1059,9 @@ VOID BAOriSessionSetupTimeout(
pAd = pBAEntry->pAdapter;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
+ // Do nothing if monitor mode is on
+ if (MONITOR_ON(pAd))
return;
-#endif // RALINK_ATE //
pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
@@ -1113,8 +1078,16 @@ VOID BAOriSessionSetupTimeout(
AddbaReq.Token = pBAEntry->Token;
MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ADD_BA_CATE, sizeof(MLME_ADDBA_REQ_STRUCT), (PVOID)&AddbaReq);
RT28XX_MLME_HANDLER(pAd);
+#ifndef RT30xx
DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) : Send ADD BA again\n", pBAEntry->Token));
-
+#endif
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) to %02x:%02x:%02x:%02x:%02x:%02x Tid:%d Wcid:%d\n"
+ ,pBAEntry->Token
+ ,pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2]
+ ,pEntry->Addr[3],pEntry->Addr[4],pEntry->Addr[5]
+ ,pBAEntry->TID,pEntry->Aid));
+#endif
pBAEntry->Token++;
RTMPSetTimer(&pBAEntry->ORIBATimer, ORI_BA_SESSION_TIMEOUT);
}
@@ -1229,21 +1202,15 @@ VOID PeerAddBAReqAction(
}
NdisZeroMemory(&ADDframe, sizeof(FRAME_ADDBA_RSP));
+
// 2-1. Prepare ADDBA Response frame.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (ADHOC_ON(pAd))
ActHeaderInit(pAd, &ADDframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
else
-#ifdef QOS_DLS_SUPPORT
- if (pAd->MacTab.Content[Elem->Wcid].ValidAsDls)
- ActHeaderInit(pAd, &ADDframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#endif // QOS_DLS_SUPPORT //
ActHeaderInit(pAd, &ADDframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
}
-#endif // CONFIG_STA_SUPPORT //
+
ADDframe.Category = CATEGORY_BA;
ADDframe.Action = ADDBA_RESP;
ADDframe.Token = pAddreqFrame->Token;
@@ -1310,9 +1277,7 @@ VOID PeerAddBARspAction(
}
// Rcv Decline StatusCode
if ((pFrame->StatusCode == 37)
-#ifdef CONFIG_STA_SUPPORT
|| ((pAd->OpMode == OPMODE_STA) && STA_TGN_WIFI_ON(pAd) && (pFrame->StatusCode != 0))
-#endif // CONFIG_STA_SUPPORT //
)
{
pAd->MacTab.Content[Elem->Wcid].BADeclineBitmap |= 1<<pFrame->BaParm.TID;
@@ -1426,6 +1391,10 @@ VOID SendPSMPAction(
//ULONG Idx;
FRAME_PSMP_ACTION Frame;
ULONG FrameLen;
+#ifdef RT30xx
+ UCHAR bbpdata=0;
+ UINT32 macdata;
+#endif // RT30xx //
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
@@ -1433,22 +1402,62 @@ VOID SendPSMPAction(
DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
return;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[Wcid].Addr);
-#endif // CONFIG_STA_SUPPORT //
+
+ ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[Wcid].Addr);
Frame.Category = CATEGORY_HT;
Frame.Action = SMPS_ACTION;
switch (Psmp)
{
case MMPS_ENABLE:
+#ifdef RT30xx
+ if (IS_RT3090(pAd))
+ {
+ // disable MMPS BBP control register
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata);
+ bbpdata &= ~(0x04); //bit 2
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata);
+
+ // disable MMPS MAC control register
+ RTMP_IO_READ32(pAd, 0x1210, &macdata);
+ macdata &= ~(0x09); //bit 0, 3
+ RTMP_IO_WRITE32(pAd, 0x1210, macdata);
+ }
+#endif // RT30xx //
Frame.Psmp = 0;
break;
case MMPS_DYNAMIC:
+#ifdef RT30xx
+ if (IS_RT3090(pAd))
+ {
+ // enable MMPS BBP control register
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata);
+ bbpdata |= 0x04; //bit 2
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata);
+
+ // enable MMPS MAC control register
+ RTMP_IO_READ32(pAd, 0x1210, &macdata);
+ macdata |= 0x09; //bit 0, 3
+ RTMP_IO_WRITE32(pAd, 0x1210, macdata);
+ }
+#endif // RT30xx //
Frame.Psmp = 3;
break;
case MMPS_STATIC:
+#ifdef RT30xx
+ if (IS_RT3090(pAd))
+ {
+ // enable MMPS BBP control register
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata);
+ bbpdata |= 0x04; //bit 2
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata);
+
+ // enable MMPS MAC control register
+ RTMP_IO_READ32(pAd, 0x1210, &macdata);
+ macdata |= 0x09; //bit 0, 3
+ RTMP_IO_WRITE32(pAd, 0x1210, macdata);
+ }
+#endif // RT30xx //
Frame.Psmp = 1;
break;
}
@@ -1501,10 +1510,7 @@ void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
// a. pointer pRxBlk->pData to payload
// b. modify pRxBlk->DataSize
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
+ RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
ASSERT(pRxBlk->pRxPacket);
pRxPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
@@ -1519,18 +1525,9 @@ void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
//
if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
#ifdef LINUX
- NdisMoveMemory(skb_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
-#endif
-#ifdef UCOS
- NdisMoveMemory(net_pkt_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
+ NdisMoveMemory(skb_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
#endif
- }
-#endif // CONFIG_STA_SUPPORT //
}
}
@@ -1598,13 +1595,9 @@ static VOID ba_enqueue_reordering_packet(
}
else
{
-#if 0
- DBGPRINT(RT_DEBUG_ERROR, ("!!! (%d:%d) Can't allocate reordering mpdu blk\n",
- blk_count, pBAEntry->list.qlen));
-#else
DBGPRINT(RT_DEBUG_ERROR, ("!!! (%d) Can't allocate reordering mpdu blk\n",
pBAEntry->list.qlen));
-#endif
+
/*
* flush all pending reordering mpdus
* and receving mpdu to upper layer
@@ -1652,29 +1645,11 @@ VOID Indicate_AMPDU_Packet(
if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU) && (pRxBlk->DataSize > MAX_RX_PKT_LEN))
{
-#if 0 // sample take off, no use
- static int err_size;
-
- err_size++;
- if (err_size > 20) {
- printk("AMPDU DataSize = %d\n", pRxBlk->DataSize);
- hex_dump("802.11 Header", (UCHAR *)pRxBlk->pHeader, 24);
- hex_dump("Payload", pRxBlk->pData, 64);
- err_size = 0;
- }
-#endif
// release packet
RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
return;
}
-
-#if 0 // test
- /* Rec BA Session had been torn down */
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- return;
-#endif
-
if (Wcid < MAX_LEN_OF_MAC_TABLE)
{
Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
@@ -1769,10 +1744,6 @@ VOID Indicate_AMPDU_Packet(
//
else
{
-#if 0
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
-#else
LONG WinStartSeq, TmpSeq;
@@ -1794,9 +1765,5 @@ VOID Indicate_AMPDU_Packet(
{
pBAEntry->LastIndSeq = TmpSeq;
}
-#endif
}
}
-
-#endif // DOT11_N_SUPPORT //
-
diff --git a/drivers/staging/rt2860/common/cmm_data.c b/drivers/staging/rt2860/common/cmm_data.c
index b3f88f52af7c..66eca202eae4 100644
--- a/drivers/staging/rt2860/common/cmm_data.c
+++ b/drivers/staging/rt2860/common/cmm_data.c
@@ -105,7 +105,9 @@ NDIS_STATUS MiniportMMRequest(
PNDIS_PACKET pPacket;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
ULONG FreeNum;
+#ifdef RT2860
unsigned long IrqFlags = 0;
+#endif
UCHAR IrqState;
UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
@@ -117,9 +119,10 @@ NDIS_STATUS MiniportMMRequest(
IrqState = pAd->irq_disabled;
+#ifdef RT2860
if ((pAd->MACVersion == 0x28600100) && (!IrqState))
RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-
+#endif
do
{
// Reset is in progress, stop immediately
@@ -172,14 +175,15 @@ NDIS_STATUS MiniportMMRequest(
} while (FALSE);
+#ifdef RT2860
// 2860C use Tx Ring
if ((pAd->MACVersion == 0x28600100) && (!IrqState))
RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
+#endif
return Status;
}
-
+#ifdef RT2860
NDIS_STATUS MiniportMMRequestUnlock(
IN PRTMP_ADAPTER pAd,
IN UCHAR QueIdx,
@@ -247,7 +251,115 @@ NDIS_STATUS MiniportMMRequestUnlock(
return Status;
}
+#endif
+#ifdef RT30xx
+NDIS_STATUS MlmeDataHardTransmit(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket);
+
+#define MAX_DATAMM_RETRY 3
+/*
+ ========================================================================
+
+ Routine Description:
+ API for MLME to transmit management frame to AP (BSS Mode)
+ or station (IBSS Mode)
+
+ Arguments:
+ pAd Pointer to our adapter
+ pData Pointer to the outgoing 802.11 frame
+ Length Size of outgoing management frame
+
+ Return Value:
+ NDIS_STATUS_FAILURE
+ NDIS_STATUS_PENDING
+ NDIS_STATUS_SUCCESS
+
+ IRQL = PASSIVE_LEVEL
+ IRQL = DISPATCH_LEVEL
+
+ Note:
+
+ ========================================================================
+*/
+NDIS_STATUS MiniportDataMMRequest(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PUCHAR pData,
+ IN UINT Length)
+{
+ PNDIS_PACKET pPacket;
+ NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
+ ULONG FreeNum;
+ int retry = 0;
+ UCHAR IrqState;
+ UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
+
+ ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
+
+ // 2860C use Tx Ring
+ IrqState = pAd->irq_disabled;
+
+ do
+ {
+ // Reset is in progress, stop immediately
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
+ RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)||
+ !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
+ {
+ Status = NDIS_STATUS_FAILURE;
+ break;
+ }
+
+ // Check Free priority queue
+ // Since we use PBF Queue2 for management frame. Its corresponding DMA ring should be using TxRing.
+
+ // 2860C use Tx Ring
+
+ // free Tx(QueIdx) resources
+ FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
+
+ if ((FreeNum > 0))
+ {
+ // We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870
+ NdisZeroMemory(&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE));
+ Status = RTMPAllocateNdisPacket(pAd, &pPacket, (PUCHAR)&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE), pData, Length);
+ if (Status != NDIS_STATUS_SUCCESS)
+ {
+ DBGPRINT(RT_DEBUG_WARN, ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n"));
+ break;
+ }
+
+ //pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
+ //pAd->CommonCfg.MlmeRate = RATE_2;
+
+
+ Status = MlmeDataHardTransmit(pAd, QueIdx, pPacket);
+ if (Status != NDIS_STATUS_SUCCESS)
+ RTMPFreeNdisPacket(pAd, pPacket);
+ retry = MAX_DATAMM_RETRY;
+ }
+ else
+ {
+ retry ++;
+
+ printk("retry %d\n", retry);
+ pAd->RalinkCounters.MgmtRingFullCount++;
+ if (retry >= MAX_DATAMM_RETRY)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in DataRing, MgmtRingFullCount=%ld!\n",
+ QueIdx, pAd->RalinkCounters.MgmtRingFullCount));
+ }
+ }
+
+ } while (retry < MAX_DATAMM_RETRY);
+
+
+ return Status;
+}
+#endif /* RT30xx */
/*
========================================================================
@@ -283,14 +395,16 @@ NDIS_STATUS MlmeHardTransmit(
return NDIS_STATUS_FAILURE;
}
+#ifdef RT2860
if ( pAd->MACVersion == 0x28600100 )
return MlmeHardTransmitTxRing(pAd,QueIdx,pPacket);
else
+#endif
return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket);
}
-
+#ifdef RT2860
NDIS_STATUS MlmeHardTransmitTxRing(
IN PRTMP_ADAPTER pAd,
IN UCHAR QueIdx,
@@ -300,10 +414,6 @@ NDIS_STATUS MlmeHardTransmitTxRing(
PUCHAR pSrcBufVA;
UINT SrcBufLen;
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
PHEADER_802_11 pHeader_802_11;
BOOLEAN bAckRequired, bInsertTimestamp;
ULONG SrcBufPA;
@@ -335,14 +445,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
SwIdx = pAd->TxRing[QueIdx].TxCpuIdx;
-#ifndef RT_BIG_ENDIAN
pTxD = (PTXD_STRUC) pAd->TxRing[QueIdx].Cell[SwIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pAd->TxRing[QueIdx].Cell[SwIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
if (pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket)
{
@@ -350,15 +453,10 @@ NDIS_STATUS MlmeHardTransmitTxRing(
return NDIS_STATUS_FAILURE;
}
+ // outgoing frame always wakeup PHY to prevent frame lost
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ AsicForceWakeup(pAd, FROM_TX);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // outgoing frame always wakeup PHY to prevent frame lost
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- AsicForceWakeup(pAd, FROM_TX);
- }
-#endif // CONFIG_STA_SUPPORT //
pFirstTxWI =(PTXWI_STRUC)pSrcBufVA;
pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXWI_SIZE);
@@ -388,7 +486,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
//
//
// In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
-#ifdef CONFIG_STA_SUPPORT
+
// Data-Null packets alse pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD
if (pHeader_802_11->FC.Type != BTYPE_DATA)
{
@@ -401,7 +499,6 @@ NDIS_STATUS MlmeHardTransmitTxRing(
pHeader_802_11->FC.PwrMgmt = pAd->CommonCfg.bAPSDForcePowerSave;
}
}
-#endif // CONFIG_STA_SUPPORT //
bInsertTimestamp = FALSE;
if (pHeader_802_11->FC.Type == BTYPE_CNTL) // must be PS-POLL
@@ -438,9 +535,6 @@ NDIS_STATUS MlmeHardTransmitTxRing(
return (NDIS_STATUS_FAILURE);
}
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader_802_11, DIR_WRITE, FALSE);
-#endif
//
// fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET
// should always has only one ohysical buffer, and the whole frame size equals
@@ -470,9 +564,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket = pPacket;
pAd->TxRing[QueIdx].Cell[SwIdx].pNextNdisPacket = NULL;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pFirstTxWI, TYPE_TXWI);
-#endif
+
SrcBufPA = PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE);
@@ -484,11 +576,6 @@ NDIS_STATUS MlmeHardTransmitTxRing(
pTxD->SDPtr0 = SrcBufPA;
pTxD->DMADONE = 0;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
-
pAd->RalinkCounters.KickTxCount++;
pAd->RalinkCounters.OneSecTxDoneCount++;
@@ -499,7 +586,25 @@ NDIS_STATUS MlmeHardTransmitTxRing(
return NDIS_STATUS_SUCCESS;
}
+#endif /* RT2860 */
+#ifdef RT30xx
+NDIS_STATUS MlmeDataHardTransmit(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket)
+{
+ if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
+ )
+ {
+ return NDIS_STATUS_FAILURE;
+ }
+
+#ifdef RT2870
+ return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket);
+#endif // RT2870 //
+}
+#endif /* RT30xx */
NDIS_STATUS MlmeHardTransmitMgmtRing(
IN PRTMP_ADAPTER pAd,
@@ -525,14 +630,14 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
return NDIS_STATUS_FAILURE;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // outgoing frame always wakeup PHY to prevent frame lost
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- AsicForceWakeup(pAd, FROM_TX);
- }
-#endif // CONFIG_STA_SUPPORT //
+ // outgoing frame always wakeup PHY to prevent frame lost
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+#ifdef RT2860
+ AsicForceWakeup(pAd, FROM_TX);
+#endif
+#ifdef RT2870
+ AsicForceWakeup(pAd, TRUE);
+#endif
pFirstTxWI = (PTXWI_STRUC)(pSrcBufVA + TXINFO_SIZE);
pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE); //TXWI_SIZE);
@@ -556,14 +661,10 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Fixed W52 with Activity scan issue in ABG_MIXED and ABGN_MIXED mode.
if (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED
-#ifdef DOT11_N_SUPPORT
|| pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED
-#endif // DOT11_N_SUPPORT //
)
{
if (pAd->LatchRfRegs.Channel > 14)
@@ -572,7 +673,6 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
pAd->CommonCfg.MlmeTransmit.field.MODE = 0;
}
}
-#endif // CONFIG_STA_SUPPORT //
//
// Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE)
@@ -582,7 +682,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
// pHeader_802_11->FC.PwrMgmt = 0; // (pAd->StaCfg.Psm == PWR_SAVE);
//
// In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
-#ifdef CONFIG_STA_SUPPORT
+
// Data-Null packets alse pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD
if ((pHeader_802_11->FC.Type != BTYPE_DATA) && (pHeader_802_11->FC.Type != BTYPE_CNTL))
{
@@ -592,18 +692,15 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
else
pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;
}
-#endif // CONFIG_STA_SUPPORT //
bInsertTimestamp = FALSE;
if (pHeader_802_11->FC.Type == BTYPE_CNTL) // must be PS-POLL
{
-#ifdef CONFIG_STA_SUPPORT
//Set PM bit in ps-poll, to fix WLK 1.2 PowerSaveMode_ext failure issue.
if ((pAd->OpMode == OPMODE_STA) && (pHeader_802_11->FC.SubType == SUBTYPE_PS_POLL))
{
pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
}
-#endif // CONFIG_STA_SUPPORT //
bAckRequired = FALSE;
}
else // BTYPE_MGMT or BTYPE_DATA(must be NULL frame)
@@ -639,10 +736,6 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
return (NDIS_STATUS_FAILURE);
}
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader_802_11, DIR_WRITE, FALSE);
-#endif
-
//
// fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET
// should always has only one ohysical buffer, and the whole frame size equals
@@ -669,10 +762,6 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode);
}
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pFirstTxWI, TYPE_TXWI);
-#endif
-
// Now do hardware-depened kick out.
HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen);
@@ -752,9 +841,7 @@ static UCHAR TxPktClassification(
UCHAR TxFrameType = TX_UNKOWN_FRAME;
UCHAR Wcid;
MAC_TABLE_ENTRY *pMacEntry = NULL;
-#ifdef DOT11_N_SUPPORT
BOOLEAN bHTRate = FALSE;
-#endif // DOT11_N_SUPPORT //
Wcid = RTMP_GET_PACKET_WCID(pPacket);
if (Wcid == MCAST_WCID)
@@ -768,7 +855,6 @@ static UCHAR TxPktClassification(
{ // It's a specific packet need to force low rate, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame
TxFrameType = TX_LEGACY_FRAME;
}
-#ifdef DOT11_N_SUPPORT
else if (IS_HT_RATE(pMacEntry))
{ // it's a 11n capable packet
@@ -788,7 +874,6 @@ static UCHAR TxPktClassification(
else
TxFrameType = TX_LEGACY_FRAME;
}
-#endif // DOT11_N_SUPPORT //
else
{ // it's a legacy b/g packet.
if ((CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE) && pAd->CommonCfg.bAggregationCapable) &&
@@ -874,16 +959,15 @@ BOOLEAN RTMP_FillTxBlkInfo(
TX_BLK_SET_FLAG(pTxBlk, fTX_bAckRequired);
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- // If support WMM, enable it.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM);
- }
-#endif // CONFIG_STA_SUPPORT //
+ // If support WMM, enable it.
+#ifdef RT2860
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
+#endif
+#ifdef RT2870
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
+ CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))
+#endif
+ TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM);
}
if (pTxBlk->TxFrameType == TX_LEGACY_FRAME)
@@ -892,7 +976,7 @@ BOOLEAN RTMP_FillTxBlkInfo(
((pAd->OpMode == OPMODE_AP) && (pMacEntry->MaxHTPhyMode.field.MODE == MODE_CCK) && (pMacEntry->MaxHTPhyMode.field.MCS == RATE_1)))
{ // Specific packet, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame, need force low rate.
pTxBlk->pTransmit = &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
-#ifdef DOT11_N_SUPPORT
+
// Modify the WMM bit for ICV issue. If we have a packet with EOSP field need to set as 1, how to handle it???
if (IS_HT_STA(pTxBlk->pMacEntry) &&
(CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RALINK_CHIPSET)) &&
@@ -901,16 +985,13 @@ BOOLEAN RTMP_FillTxBlkInfo(
TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
TX_BLK_SET_FLAG(pTxBlk, fTX_bForceNonQoS);
}
-#endif // DOT11_N_SUPPORT //
}
-#ifdef DOT11_N_SUPPORT
if ( (IS_HT_RATE(pMacEntry) == FALSE) &&
(CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE)))
{ // Currently piggy-back only support when peer is operate in b/g mode.
TX_BLK_SET_FLAG(pTxBlk, fTX_bPiggyBack);
}
-#endif // DOT11_N_SUPPORT //
if (RTMP_GET_PACKET_MOREDATA(pPacket))
{
@@ -932,6 +1013,11 @@ BOOLEAN RTMP_FillTxBlkInfo(
}
return TRUE;
+
+#ifdef RT30xx
+FillTxBlkErr:
+ return FALSE;
+#endif
}
@@ -963,13 +1049,10 @@ BOOLEAN CanDoAggregateTransmit(
return FALSE;
}
-#ifdef CONFIG_STA_SUPPORT
if ((INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA)) // must be unicast to AP
return TRUE;
else
-#endif // CONFIG_STA_SUPPORT //
return FALSE;
-
}
@@ -1022,6 +1105,7 @@ VOID RTMPDeQueuePacket(
if (QIdx == NUM_OF_TX_RING)
{
sQIdx = 0;
+//PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
eQIdx = 3; // 4 ACs, start from 0.
}
else
@@ -1064,7 +1148,7 @@ VOID RTMPDeQueuePacket(
DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
break;
}
-
+#ifdef RT2860
FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
#ifdef DBG_DIAGNOSE
@@ -1089,7 +1173,7 @@ VOID RTMPDeQueuePacket(
RTMPFreeTXDUponTxDmaDone(pAd, QueIdx);
FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
}
-
+#endif /* RT2860 */
// probe the Queue Head
pQueue = &pAd->TxSwQueue[QueIdx];
if ((pEntry = pQueue->Head) == NULL)
@@ -1158,32 +1242,29 @@ VOID RTMPDeQueuePacket(
pTxBlk->TxFrameType = TX_LEGACY_FRAME;
}
+#ifdef RT2870
+ DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
+#endif // RT2870 //
Count += pTxBlk->TxPacketList.Number;
- // Do HardTransmit now.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- Status = STAHardTransmit(pAd, pTxBlk, QueIdx);
-#endif // CONFIG_STA_SUPPORT //
+ // Do HardTransmit now.
+ Status = STAHardTransmit(pAd, pTxBlk, QueIdx);
+#ifdef RT2860
DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
// static rate also need NICUpdateFifoStaCounters() function.
//if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))
NICUpdateFifoStaCounters(pAd);
+#endif
}
RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-#ifdef BLOCK_NET_IF
- if ((pAd->blockQueueTab[QueIdx].SwTxQueueBlockFlag == TRUE)
- && (pAd->TxSwQueue[QueIdx].Number < 1))
- {
- releaseNetIf(&pAd->blockQueueTab[QueIdx]);
- }
-#endif // BLOCK_NET_IF //
-
+#ifdef RT2870
+ if (!hasTxDesc)
+ RTUSBKickBulkOut(pAd);
+#endif // RT2870 //
}
}
@@ -1318,7 +1399,6 @@ VOID RTMPWriteTxWI(
pTxWI->NSEQ = NSeq;
// John tune the performace with Intel Client in 20 MHz performance
-#ifdef DOT11_N_SUPPORT
BASize = pAd->CommonCfg.TxBASize;
if( BASize >7 )
@@ -1326,7 +1406,6 @@ VOID RTMPWriteTxWI(
pTxWI->BAWinSize = BASize;
pTxWI->ShortGI = pTransmit->field.ShortGI;
pTxWI->STBC = pTransmit->field.STBC;
-#endif // DOT11_N_SUPPORT //
pTxWI->WirelessCliID = WCID;
pTxWI->MPDUtotalByteCount = Length;
@@ -1334,16 +1413,11 @@ VOID RTMPWriteTxWI(
// If CCK or OFDM, BW must be 20
pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
pTxWI->MCS = pTransmit->field.MCS;
pTxWI->PHYMODE = pTransmit->field.MODE;
pTxWI->CFACK = CfAck;
-#ifdef DOT11_N_SUPPORT
if (pMac)
{
if (pAd->CommonCfg.bMIMOPSEnable)
@@ -1373,7 +1447,6 @@ VOID RTMPWriteTxWI(
pTxWI->MpduDensity = pMac->MpduDensity;
}
}
-#endif // DOT11_N_SUPPORT //
pTxWI->PacketId = pTxWI->MCS;
NdisMoveMemory(pOutTxWI, &TxWI, sizeof(TXWI_STRUC));
@@ -1387,10 +1460,7 @@ VOID RTMPWriteTxWI_Data(
{
HTTRANSMIT_SETTING *pTransmit;
PMAC_TABLE_ENTRY pMacEntry;
-#ifdef DOT11_N_SUPPORT
UCHAR BASize;
-#endif // DOT11_N_SUPPORT //
-
ASSERT(pTxWI);
@@ -1409,15 +1479,6 @@ VOID RTMPWriteTxWI_Data(
pTxWI->ACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired);
pTxWI->txop = pTxBlk->FrameGap;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (pMacEntry &&
- (pAd->StaCfg.BssType == BSS_INFRA) &&
- (pMacEntry->ValidAsDls == TRUE))
- pTxWI->WirelessCliID = BSSID_WCID;
- else
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
pTxWI->WirelessCliID = pTxBlk->Wcid;
pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
@@ -1425,11 +1486,6 @@ VOID RTMPWriteTxWI_Data(
// If CCK or OFDM, BW must be 20
pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
pTxWI->AMPDU = ((pTxBlk->TxFrameType == TX_AMPDU_FRAME) ? TRUE : FALSE);
// John tune the performace with Intel Client in 20 MHz performance
@@ -1446,12 +1502,10 @@ VOID RTMPWriteTxWI_Data(
pTxWI->BAWinSize = BASize;
pTxWI->ShortGI = pTransmit->field.ShortGI;
pTxWI->STBC = pTransmit->field.STBC;
-#endif // DOT11_N_SUPPORT //
pTxWI->MCS = pTransmit->field.MCS;
pTxWI->PHYMODE = pTransmit->field.MODE;
-#ifdef DOT11_N_SUPPORT
if (pMacEntry)
{
if ((pMacEntry->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
@@ -1478,7 +1532,6 @@ VOID RTMPWriteTxWI_Data(
pTxWI->MpduDensity = pMacEntry->MpduDensity;
}
}
-#endif // DOT11_N_SUPPORT //
#ifdef DBG_DIAGNOSE
if (pTxBlk->QueIdx== 0)
@@ -1523,15 +1576,9 @@ VOID RTMPWriteTxWI_Cache(
pTxWI->PacketId = pTransmit->field.MCS;
}
-#ifdef DOT11_N_SUPPORT
pTxWI->AMPDU = ((pMacEntry->NoBADataCountDown == 0) ? TRUE: FALSE);
pTxWI->MIMOps = 0;
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
-
if (pAd->CommonCfg.bMIMOPSEnable)
{
// MIMO Power Save Mode
@@ -1550,7 +1597,6 @@ VOID RTMPWriteTxWI_Cache(
}
}
}
-#endif // DOT11_N_SUPPORT //
#ifdef DBG_DIAGNOSE
if (pTxBlk->QueIdx== 0)
@@ -1665,12 +1711,10 @@ BOOLEAN PeerIsAggreOn(
if (pMacEntry != NULL && CLIENT_STATUS_TEST_FLAG(pMacEntry, AFlags))
{
-#ifdef DOT11_N_SUPPORT
if (pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
{
return TRUE;
}
-#endif // DOT11_N_SUPPORT //
#ifdef AGGREGATION_SUPPORT
if (TxRate >= RATE_6 && pAd->CommonCfg.bAggregationCapable && (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))))
@@ -1748,16 +1792,13 @@ PQUEUE_HEADER RTMPCheckTxSwQueue(
return (NULL);
}
-
+#ifdef RT2860
BOOLEAN RTMPFreeTXDUponTxDmaDone(
IN PRTMP_ADAPTER pAd,
IN UCHAR QueIdx)
{
PRTMP_TX_RING pTxRing;
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
-#endif
PNDIS_PACKET pPacket;
UCHAR FREE = 0;
TXD_STRUC TxD, *pOriTxD;
@@ -1771,111 +1812,19 @@ BOOLEAN RTMPFreeTXDUponTxDmaDone(
RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF, &pTxRing->TxDmaIdx);
while (pTxRing->TxSwFreeIdx != pTxRing->TxDmaIdx)
{
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
- PHEADER_802_11 pHeader80211;
-
- if ((ATE_ON(pAd)) && (pAd->ate.bQATxStart == TRUE))
- {
- if (pAd->ate.QID == QueIdx)
- {
- pAd->ate.TxDoneCount++;
- //pAd->ate.Repeat++;
- pAd->RalinkCounters.KickTxCount++;
-
- /* always use QID_AC_BE and FIFO_EDCA */
- ASSERT(pAd->ate.QID == 0);
- pAd->ate.TxAc0++;
-
- FREE++;
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
- pOriTxD = pTxD;
- NdisMoveMemory(&TxD, pTxD, sizeof(TXD_STRUC));
- pTxD = &TxD;
-#else
- pDestTxD = (PTXD_STRUC) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
- pOriTxD = pDestTxD ;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- pTxD->DMADONE = 0;
-
- pHeader80211 = pTxRing->Cell[pTxRing->TxSwFreeIdx].DmaBuf.AllocVa + sizeof(TXWI_STRUC);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader80211, DIR_READ, FALSE);
-#endif
- pHeader80211->Sequence = ++pAd->ate.seq;
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader80211, DIR_WRITE, FALSE);
-#endif
-
- if ((pAd->ate.bQATxStart == TRUE) && (pAd->ate.Mode & ATE_TXFRAME) && (pAd->ate.TxDoneCount < pAd->ate.TxCount))
- {
- pAd->RalinkCounters.TransmittedByteCount += (pTxD->SDLen1 + pTxD->SDLen0);
- pAd->RalinkCounters.OneSecDmaDoneCount[QueIdx] ++;
- INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
- /* get tx_tdx_idx again */
- RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF , &pTxRing->TxDmaIdx);
- goto kick_out;
- }
- else if ((pAd->ate.TxStatus == 1)/* or (pAd->ate.bQATxStart == TRUE) ??? */ && (pAd->ate.TxDoneCount == pAd->ate.TxCount))//<========================PETER
- {
- DBGPRINT(RT_DEBUG_TRACE,("all Tx is done\n"));
- // Tx status enters idle mode.
- pAd->ate.TxStatus = 0;
- }
- else if (!(pAd->ate.Mode & ATE_TXFRAME))
- {
- /* not complete sending yet, but someone press the Stop TX botton. */
- DBGPRINT(RT_DEBUG_ERROR,("not complete sending yet, but someone pressed the Stop TX bottom\n"));
- DBGPRINT(RT_DEBUG_ERROR,("pAd->ate.Mode = 0x%02x\n", pAd->ate.Mode));
- }
- else
- {
- DBGPRINT(RT_DEBUG_OFF,("pTxRing->TxSwFreeIdx = %d\n", pTxRing->TxSwFreeIdx));
- }
-#ifndef RT_BIG_ENDIAN
- NdisMoveMemory(pOriTxD, pTxD, sizeof(TXD_STRUC));
-#else
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- *pDestTxD = TxD;
-#endif // RT_BIG_ENDIAN //
-
- INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
- continue;
- }
- }
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
// static rate also need NICUpdateFifoStaCounters() function.
//if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))
NICUpdateFifoStaCounters(pAd);
/* Note : If (pAd->ate.bQATxStart == TRUE), we will never reach here. */
FREE++;
-#ifndef RT_BIG_ENDIAN
pTxD = (PTXD_STRUC) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
pOriTxD = pTxD;
NdisMoveMemory(&TxD, pTxD, sizeof(TXD_STRUC));
pTxD = &TxD;
-#else
- pDestTxD = (PTXD_STRUC) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
- pOriTxD = pDestTxD ;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
pTxD->DMADONE = 0;
-
-#ifdef RALINK_ATE
- /* Execution of this block is not allowed when ATE is running. */
- if (!(ATE_ON(pAd)))
-#endif // RALINK_ATE //
/*====================================================================*/
{
pPacket = pTxRing->Cell[pTxRing->TxSwFreeIdx].pNdisPacket;
@@ -1915,59 +1864,8 @@ BOOLEAN RTMPFreeTXDUponTxDmaDone(
INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
/* get tx_tdx_idx again */
RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF , &pTxRing->TxDmaIdx);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- *pDestTxD = TxD;
-#else
- NdisMoveMemory(pOriTxD, pTxD, sizeof(TXD_STRUC));
-#endif
-
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-kick_out:
-#endif // RALINK_28xx_QA //
- //
- // ATE_TXCONT mode also need to send some normal frames, so let it in.
- // ATE_STOP must be changed not to be 0xff
- // to prevent it from running into this block.
- //
- if ((pAd->ate.Mode & ATE_TXFRAME) && (pAd->ate.QID == QueIdx))
- {
- // TxDoneCount++ has been done if QA is used.
- if (pAd->ate.bQATxStart == FALSE)
- {
- pAd->ate.TxDoneCount++;
- }
- if (((pAd->ate.TxCount - pAd->ate.TxDoneCount + 1) >= TX_RING_SIZE))
- {
- /* Note : We increase TxCpuIdx here, not TxSwFreeIdx ! */
- INC_RING_INDEX(pAd->TxRing[QueIdx].TxCpuIdx, TX_RING_SIZE);
-#ifndef RT_BIG_ENDIAN//<==========================PETER
- pTxD = (PTXD_STRUC) (pTxRing->Cell[pAd->TxRing[QueIdx].TxCpuIdx].AllocVa);
- pOriTxD = pTxD;
- NdisMoveMemory(&TxD, pTxD, sizeof(TXD_STRUC));
- pTxD = &TxD;
-#else
- pDestTxD = (PTXD_STRUC) (pTxRing->Cell[pAd->TxRing[QueIdx].TxCpuIdx].AllocVa);
- pOriTxD = pDestTxD ;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- pTxD->DMADONE = 0;
-#ifndef RT_BIG_ENDIAN//<==========================PETER
- NdisMoveMemory(pOriTxD, pTxD, sizeof(TXD_STRUC));
-#else
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- *pDestTxD = TxD;
-#endif
- // kick Tx-Ring.
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QueIdx * RINGREG_DIFF, pAd->TxRing[QueIdx].TxCpuIdx);
- pAd->RalinkCounters.KickTxCount++;
- }
- }
-#endif // RALINK_ATE //
+ NdisMoveMemory(pOriTxD, pTxD, sizeof(TXD_STRUC));
}
@@ -2050,10 +1948,6 @@ VOID RTMPHandleMgmtRingDmaDoneInterrupt(
IN PRTMP_ADAPTER pAd)
{
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
PNDIS_PACKET pPacket;
UCHAR FREE = 0;
PRTMP_MGMT_RING pMgmtRing = &pAd->MgmtRing;
@@ -2064,14 +1958,7 @@ VOID RTMPHandleMgmtRingDmaDoneInterrupt(
while (pMgmtRing->TxSwFreeIdx!= pMgmtRing->TxDmaIdx)
{
FREE++;
-#ifdef RT_BIG_ENDIAN
- pDestTxD = (PTXD_STRUC) (pMgmtRing->Cell[pAd->MgmtRing.TxSwFreeIdx].AllocVa);
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#else
pTxD = (PTXD_STRUC) (pMgmtRing->Cell[pAd->MgmtRing.TxSwFreeIdx].AllocVa);
-#endif
pTxD->DMADONE = 0;
pPacket = pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNdisPacket;
@@ -2091,11 +1978,6 @@ VOID RTMPHandleMgmtRingDmaDoneInterrupt(
}
pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNextNdisPacket = NULL;
INC_RING_INDEX(pMgmtRing->TxSwFreeIdx, MGMT_RING_SIZE);
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, TRUE, TYPE_TXD);
-#endif
}
NdisReleaseSpinLock(&pAd->MgmtRingLock);
@@ -2293,6 +2175,7 @@ VOID DBGPRINT_RX_RING(
DBGPRINT_RAW(RT_DEBUG_TRACE,(" RxSwReadIdx [%d]=", AC0freeIdx));
DBGPRINT_RAW(RT_DEBUG_TRACE,(" pending-NDIS=%ld\n", pAd->RalinkCounters.PendingNdisPacketCount));
}
+#endif /* RT2860 */
/*
========================================================================
@@ -2352,7 +2235,15 @@ VOID RTMPResumeMsduTransmission(
{
DBGPRINT(RT_DEBUG_TRACE,("SCAN done, resume MSDU transmission ...\n"));
-
+#ifdef RT30xx
+ // After finish BSS_SCAN_IN_PROGRESS, we need to restore Current R66 value
+ // R66 should not be 0
+ if (pAd->BbpTuning.R66CurrentValue == 0)
+ {
+ pAd->BbpTuning.R66CurrentValue = 0x38;
+ DBGPRINT_ERR(("RTMPResumeMsduTransmission, R66CurrentValue=0...\n"));
+ }
+#endif
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, pAd->BbpTuning.R66CurrentValue);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
@@ -2401,7 +2292,6 @@ UINT deaggregate_AMSDU_announce(
// convert to 802.3 header
CONVERT_TO_802_3(Header802_3, pDA, pSA, pPayload, PayloadSize, pRemovedLLCSNAP);
-#ifdef CONFIG_STA_SUPPORT
if ((Header802_3[12] == 0x88) && (Header802_3[13] == 0x8E) )
{
// avoid local heap overflow, use dyanamic allocation
@@ -2411,10 +2301,7 @@ UINT deaggregate_AMSDU_announce(
WpaEAPOLKeyAction(pAd, Elem);
kfree(Elem);
}
-#endif // CONFIG_STA_SUPPORT //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (pRemovedLLCSNAP)
{
@@ -2423,15 +2310,11 @@ UINT deaggregate_AMSDU_announce(
NdisMoveMemory(pPayload, &Header802_3[0], LENGTH_802_3);
}
}
-#endif // CONFIG_STA_SUPPORT //
pClonePacket = ClonePacket(pAd, pPacket, pPayload, PayloadSize);
if (pClonePacket)
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pClonePacket, RTMP_GET_PACKET_IF(pPacket));
-#endif // CONFIG_STA_SUPPORT //
+ ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pClonePacket, RTMP_GET_PACKET_IF(pPacket));
}
@@ -2527,11 +2410,9 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
return NULL;
FirstWcid = 1;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
if (pAd->StaCfg.BssType == BSS_INFRA)
FirstWcid = 2;
-#endif // CONFIG_STA_SUPPORT //
// allocate one MAC entry
NdisAcquireSpinLock(&pAd->MacTabLock);
@@ -2542,11 +2423,6 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
(pAd->MacTab.Content[i].ValidAsWDS == FALSE) &&
(pAd->MacTab.Content[i].ValidAsApCli== FALSE) &&
(pAd->MacTab.Content[i].ValidAsMesh == FALSE)
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- && (pAd->MacTab.Content[i].ValidAsDls == FALSE)
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
)
{
pEntry = &pAd->MacTab.Content[i];
@@ -2558,24 +2434,7 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
pEntry->PairwiseKey.KeyLen = 0;
pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
}
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (apidx >= MIN_NET_DEVICE_FOR_DLS)
- {
- pEntry->ValidAsCLI = FALSE;
- pEntry->ValidAsWDS = FALSE;
- pEntry->ValidAsApCli = FALSE;
- pEntry->ValidAsMesh = FALSE;
- pEntry->ValidAsDls = TRUE;
- pEntry->isCached = FALSE;
- }
- else
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pEntry->ValidAsCLI = TRUE;
pEntry->ValidAsWDS = FALSE;
@@ -2583,7 +2442,6 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
pEntry->ValidAsMesh = FALSE;
pEntry->ValidAsDls = FALSE;
}
-#endif // CONFIG_STA_SUPPORT //
}
pEntry->bIAmBadAtheros = FALSE;
@@ -2600,43 +2458,32 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_APCLI);
else if (pEntry->ValidAsWDS)
pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_WDS);
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- else if (pEntry->ValidAsDls)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_DLS);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
else
pEntry->apidx = apidx;
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pEntry->AuthMode = pAd->StaCfg.AuthMode;
pEntry->WepStatus = pAd->StaCfg.WepStatus;
pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
+#ifdef RT2860
AsicRemovePairwiseKeyEntry(pAd, pEntry->apidx, (UCHAR)i);
+#endif
}
-#endif // CONFIG_STA_SUPPORT //
}
pEntry->GTKState = REKEY_NEGOTIATING;
pEntry->PairwiseKey.KeyLen = 0;
pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
-#ifdef CONFIG_STA_SUPPORT
+
+#ifdef RT2860
if ((pAd->OpMode == OPMODE_STA) &&
(pAd->StaCfg.BssType == BSS_ADHOC))
pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
else
-#ifdef QOS_DLS_SUPPORT
- if (pEntry->ValidAsDls == TRUE)
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
- else
-#endif //QOS_DLS_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
+#endif
pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
+
pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND;
COPY_MAC_ADDR(pEntry->Addr, pAddr);
pEntry->Sst = SST_NOT_AUTH;
@@ -2706,11 +2553,6 @@ BOOLEAN MacTableDeleteEntry(
pEntry = &pAd->MacTab.Content[wcid];
if (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsApCli || pEntry->ValidAsWDS || pEntry->ValidAsMesh
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- || pEntry->ValidAsDls
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
))
{
if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
@@ -2719,11 +2561,8 @@ BOOLEAN MacTableDeleteEntry(
// Delete this entry from ASIC on-chip WCID Table
RT28XX_STA_ENTRY_MAC_RESET(pAd, wcid);
-#ifdef DOT11_N_SUPPORT
// free resources of BA
BASessionTearDownALL(pAd, pEntry->Aid);
-#endif // DOT11_N_SUPPORT //
-
pPrevEntry = NULL;
pProbeEntry = pAd->MacTab.Hash[HashIdx];
@@ -2777,10 +2616,13 @@ BOOLEAN MacTableDeleteEntry(
//Reset operating mode when no Sta.
if (pAd->MacTab.Size == 0)
{
-#ifdef DOT11_N_SUPPORT
pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode = 0;
-#endif // DOT11_N_SUPPORT //
+#ifndef RT30xx
AsicUpdateProtect(pAd, 0 /*pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode*/, (ALLN_SETPROTECT), TRUE, 0 /*pAd->MacTab.fAnyStationNonGF*/);
+#endif
+#ifdef RT30xx
+ RT28XX_UPDATE_PROTECT(pAd); // edit by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
+#endif
}
return TRUE;
@@ -2804,19 +2646,22 @@ VOID MacTableReset(
for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
{
+#ifdef RT2860
RT28XX_STA_ENTRY_MAC_RESET(pAd, i);
+#endif
if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
{
-
-#ifdef DOT11_N_SUPPORT
// free resources of BA
BASessionTearDownALL(pAd, i);
-#endif // DOT11_N_SUPPORT //
pAd->MacTab.Content[i].ValidAsCLI = FALSE;
+#ifdef RT2870
+ NdisZeroMemory(pAd->MacTab.Content[i].Addr, 6);
+ RT28XX_STA_ENTRY_MAC_RESET(pAd, i);
+#endif // RT2870 //
//AsicDelWcidTab(pAd, i);
}
@@ -3116,10 +2961,7 @@ VOID Indicate_Legacy_Packet(
// 2. remove LLC
// a. pointer pRxBlk->pData to payload
// b. modify pRxBlk->DataSize
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
+ RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
if (pRxBlk->DataSize > MAX_RX_PKT_LEN)
{
@@ -3132,17 +2974,44 @@ VOID Indicate_Legacy_Packet(
STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
+#ifdef RT2870
+ if (pAd->CommonCfg.bDisableReordering == 0)
+ {
+ PBA_REC_ENTRY pBAEntry;
+ ULONG Now32;
+ UCHAR Wcid = pRxBlk->pRxWI->WirelessCliID;
+ UCHAR TID = pRxBlk->pRxWI->TID;
+ USHORT Idx;
+
+#define REORDERING_PACKET_TIMEOUT ((100 * HZ)/1000) // system ticks -- 100 ms
+
+ if (Wcid < MAX_LEN_OF_MAC_TABLE)
+ {
+ Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
+ if (Idx != 0)
+ {
+ pBAEntry = &pAd->BATable.BARecEntry[Idx];
+ // update last rx time
+ NdisGetSystemUpTime(&Now32);
+ if ((pBAEntry->list.qlen > 0) &&
+ RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(REORDERING_PACKET_TIMEOUT)))
+ )
+ {
+ printk("Indicate_Legacy_Packet():flush reordering_timeout_mpdus! RxWI->Flags=%d, pRxWI.TID=%d, RxD->AMPDU=%d!\n", pRxBlk->Flags, pRxBlk->pRxWI->TID, pRxBlk->RxD.AMPDU);
+ hex_dump("Dump the legacy Packet:", GET_OS_PKT_DATAPTR(pRxBlk->pRxPacket), 64);
+ ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32);
+ }
+ }
+ }
+ }
+#endif // RT2870 //
wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
//
// pass this 802.3 packet to upper layer or forward this packet to WM directly
//
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxPacket, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
+ ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxPacket, FromWhichBSSID);
}
@@ -3152,22 +3021,18 @@ VOID CmmRxnonRalinkFrameIndicate(
IN RX_BLK *pRxBlk,
IN UCHAR FromWhichBSSID)
{
-#ifdef DOT11_N_SUPPORT
if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
{
Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
}
else
-#endif // DOT11_N_SUPPORT //
{
-#ifdef DOT11_N_SUPPORT
if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
{
// handle A-MSDU
Indicate_AMSDU_Packet(pAd, pRxBlk, FromWhichBSSID);
}
else
-#endif // DOT11_N_SUPPORT //
{
Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
}
@@ -3205,11 +3070,7 @@ VOID CmmRxRalinkFrameIndicate(
}
// get 802.3 Header and remove LLC
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
+ RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
ASSERT(pRxBlk->pRxPacket);
@@ -3219,10 +3080,8 @@ VOID CmmRxRalinkFrameIndicate(
Payload2Size = Msdu2Size - LENGTH_802_3;
pData2 = pRxBlk->pData + Payload1Size + LENGTH_802_3;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pPacket2 = duplicate_pkt(pAd, (pData2-LENGTH_802_3), LENGTH_802_3, pData2, Payload2Size, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
+
+ pPacket2 = duplicate_pkt(pAd, (pData2-LENGTH_802_3), LENGTH_802_3, pData2, Payload2Size, FromWhichBSSID);
if (!pPacket2)
{
@@ -3235,17 +3094,11 @@ VOID CmmRxRalinkFrameIndicate(
pRxBlk->DataSize = Payload1Size;
wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxBlk->pRxPacket, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
+ ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxBlk->pRxPacket, FromWhichBSSID);
if (pPacket2)
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket2, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
+ ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket2, FromWhichBSSID);
}
}
@@ -3388,15 +3241,11 @@ VOID Indicate_EAPOL_Packet(
{
MAC_TABLE_ENTRY *pEntry = NULL;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pEntry = &pAd->MacTab.Content[BSSID_WCID];
STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
return;
}
-#endif // CONFIG_STA_SUPPORT //
if (pEntry == NULL)
{
diff --git a/drivers/staging/rt2860/common/cmm_data_2860.c b/drivers/staging/rt2860/common/cmm_data_2860.c
index fae741e4beeb..fb1735533b74 100644
--- a/drivers/staging/rt2860/common/cmm_data_2860.c
+++ b/drivers/staging/rt2860/common/cmm_data_2860.c
@@ -110,10 +110,6 @@ USHORT RtmpPCI_WriteSingleTxResource(
UCHAR *pDMAHeaderBufVA;
USHORT TxIdx, RetTxIdx;
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
UINT32 BufBasePaLow;
PRTMP_TX_RING pTxRing;
USHORT hwHeaderLen;
@@ -137,13 +133,8 @@ USHORT RtmpPCI_WriteSingleTxResource(
//
// build Tx Descriptor
//
-#ifndef RT_BIG_ENDIAN
pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
-#endif
+
NdisZeroMemory(pTxD, TXD_SIZE);
pTxD->SDPtr0 = BufBasePaLow;
@@ -154,12 +145,6 @@ USHORT RtmpPCI_WriteSingleTxResource(
pTxD->LastSec1 = (bIsLast) ? 1 : 0;
RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE), TYPE_TXWI);
- RTMPFrameEndianChange(pAd, (PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif // RT_BIG_ENDIAN //
RetTxIdx = TxIdx;
//
@@ -184,10 +169,6 @@ USHORT RtmpPCI_WriteMultiTxResource(
UCHAR *pDMAHeaderBufVA;
USHORT TxIdx, RetTxIdx;
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
UINT32 BufBasePaLow;
PRTMP_TX_RING pTxRing;
USHORT hwHdrLen;
@@ -231,13 +212,8 @@ USHORT RtmpPCI_WriteMultiTxResource(
//
// build Tx Descriptor
//
-#ifndef RT_BIG_ENDIAN
pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
-#endif
+
NdisZeroMemory(pTxD, TXD_SIZE);
pTxD->SDPtr0 = BufBasePaLow;
@@ -249,17 +225,6 @@ USHORT RtmpPCI_WriteMultiTxResource(
RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-#ifdef RT_BIG_ENDIAN
- if (frameNum == 0)
- RTMPFrameEndianChange(pAd, (PUCHAR)(pDMAHeaderBufVA+ TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-
- if (frameNum != 0)
- RTMPWIEndianChange((PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE), TYPE_TXWI);
-
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif // RT_BIG_ENDIAN //
-
RetTxIdx = TxIdx;
//
// Update Tx index
@@ -290,10 +255,6 @@ VOID RtmpPCI_FinalWriteTxResource(
pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
pTxWI = (PTXWI_STRUC) pTxRing->Cell[FirstTxIdx].DmaBuf.AllocVa;
pTxWI->MPDUtotalByteCount = totalMPDUSize;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
}
@@ -303,10 +264,6 @@ VOID RtmpPCIDataLastTxIdx(
IN USHORT LastTxIdx)
{
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
PRTMP_TX_RING pTxRing;
//
@@ -317,21 +274,9 @@ VOID RtmpPCIDataLastTxIdx(
//
// build Tx Descriptor
//
-#ifndef RT_BIG_ENDIAN
pTxD = (PTXD_STRUC) pTxRing->Cell[LastTxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC) pTxRing->Cell[LastTxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
-#endif
pTxD->LastSec1 = 1;
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif // RT_BIG_ENDIAN //
-
}
@@ -344,10 +289,6 @@ USHORT RtmpPCI_WriteFragTxResource(
UCHAR *pDMAHeaderBufVA;
USHORT TxIdx, RetTxIdx;
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
UINT32 BufBasePaLow;
PRTMP_TX_RING pTxRing;
USHORT hwHeaderLen;
@@ -373,13 +314,8 @@ USHORT RtmpPCI_WriteFragTxResource(
//
// Build Tx Descriptor
//
-#ifndef RT_BIG_ENDIAN
pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
-#endif
+
NdisZeroMemory(pTxD, TXD_SIZE);
if (fragNum == pTxBlk->TotalFragNum)
@@ -397,13 +333,6 @@ USHORT RtmpPCI_WriteFragTxResource(
RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE), TYPE_TXWI);
- RTMPFrameEndianChange(pAd, (PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif // RT_BIG_ENDIAN //
-
RetTxIdx = TxIdx;
pTxBlk->Priv += pTxBlk->SrcBufLen;
@@ -431,20 +360,9 @@ int RtmpPCIMgmtKickOut(
IN UINT SrcBufLen)
{
PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
ULONG SwIdx = pAd->MgmtRing.TxCpuIdx;
-#ifdef RT_BIG_ENDIAN
- pDestTxD = (PTXD_STRUC)pAd->MgmtRing.Cell[SwIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#else
pTxD = (PTXD_STRUC) pAd->MgmtRing.Cell[SwIdx].AllocVa;
-#endif
pAd->MgmtRing.Cell[SwIdx].pNdisPacket = pPacket;
pAd->MgmtRing.Cell[SwIdx].pNextNdisPacket = NULL;
@@ -457,11 +375,6 @@ int RtmpPCIMgmtKickOut(
pTxD->SDPtr0 = PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE);;
pTxD->SDLen0 = SrcBufLen;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
-
pAd->RalinkCounters.KickTxCount++;
pAd->RalinkCounters.OneSecTxDoneCount++;
@@ -473,8 +386,6 @@ int RtmpPCIMgmtKickOut(
return 0;
}
-
-#ifdef CONFIG_STA_SUPPORT
/*
========================================================================
@@ -570,12 +481,11 @@ NDIS_STATUS RTMPCheckRxError(
if (pRxD->CipherErr == 2)
{
pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex];
-#ifdef WPA_SUPPLICANT_SUPPORT
+
if (pAd->StaCfg.WpaSupplicantUP)
WpaSendMicFailureToWpaSupplicant(pAd,
(pWpaKey->Type == PAIRWISEKEY) ? TRUE:FALSE);
else
-#endif // WPA_SUPPLICANT_SUPPORT //
RTMPReportMicError(pAd, pWpaKey);
if (((pRxD->CipherErr & 2) == 2) && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
@@ -1128,8 +1038,6 @@ VOID RadioOnExec(
}
}
-#endif // CONFIG_STA_SUPPORT //
-
VOID RT28xxPciMlmeRadioOn(
IN PRTMP_ADAPTER pAd)
{
@@ -1163,7 +1071,6 @@ VOID RT28xxPciMlmeRadioOn(
RTMPSetLED(pAd, LED_RADIO_ON);
}
-#ifdef CONFIG_STA_SUPPORT
if ((pAd->OpMode == OPMODE_STA) &&
(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)))
{
@@ -1176,7 +1083,6 @@ VOID RT28xxPciMlmeRadioOn(
RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
}
-#endif // CONFIG_STA_SUPPORT //
}
VOID RT28xxPciMlmeRadioOFF(
@@ -1199,8 +1105,6 @@ VOID RT28xxPciMlmeRadioOFF(
// Set LED
RTMPSetLED(pAd, LED_RADIO_OFF);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
BOOLEAN Cancelled;
@@ -1249,7 +1153,6 @@ VOID RT28xxPciMlmeRadioOFF(
return;
}
}
-#endif // CONFIG_STA_SUPPORT //
// Set Radio off flag
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
diff --git a/drivers/staging/rt2860/common/cmm_info.c b/drivers/staging/rt2860/common/cmm_info.c
index c3e13195e121..306c3a21f905 100644
--- a/drivers/staging/rt2860/common/cmm_info.c
+++ b/drivers/staging/rt2860/common/cmm_info.c
@@ -63,7 +63,6 @@ INT Show_FragThreshold_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf);
-#ifdef DOT11_N_SUPPORT
INT Show_HtBw_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf);
@@ -103,7 +102,6 @@ INT Show_HtAmsdu_Proc(
INT Show_HtAutoBa_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf);
-#endif // DOT11_N_SUPPORT //
INT Show_CountryRegion_Proc(
IN PRTMP_ADAPTER pAd,
@@ -133,11 +131,9 @@ INT Show_IEEE80211H_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf);
-#ifdef CONFIG_STA_SUPPORT
INT Show_NetworkType_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf);
-#endif // CONFIG_STA_SUPPORT //
INT Show_AuthMode_Proc(
IN PRTMP_ADAPTER pAd,
@@ -184,7 +180,6 @@ static struct {
{"BGProtection", Show_BGProtection_Proc},
{"RTSThreshold", Show_RTSThreshold_Proc},
{"FragThreshold", Show_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
{"HtBw", Show_HtBw_Proc},
{"HtMcs", Show_HtMcs_Proc},
{"HtGi", Show_HtGi_Proc},
@@ -195,7 +190,6 @@ static struct {
{"HtRdg", Show_HtRdg_Proc},
{"HtAmsdu", Show_HtAmsdu_Proc},
{"HtAutoBa", Show_HtAutoBa_Proc},
-#endif // DOT11_N_SUPPORT //
{"CountryRegion", Show_CountryRegion_Proc},
{"CountryRegionABand", Show_CountryRegionABand_Proc},
{"CountryCode", Show_CountryCode_Proc},
@@ -207,9 +201,7 @@ static struct {
{"WmmCapable", Show_WmmCapable_Proc},
#endif
{"IEEE80211H", Show_IEEE80211H_Proc},
-#ifdef CONFIG_STA_SUPPORT
{"NetworkType", Show_NetworkType_Proc},
-#endif // CONFIG_STA_SUPPORT //
{"AuthMode", Show_AuthMode_Proc},
{"EncrypType", Show_EncrypType_Proc},
{"DefaultKeyID", Show_DefaultKeyID_Proc},
@@ -233,11 +225,7 @@ INT Set_DriverVersion_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg)
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
-#endif // CONFIG_STA_SUPPORT //
+ DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
return TRUE;
}
@@ -259,10 +247,6 @@ INT Set_CountryRegion_Proc(
region = simple_strtol(arg, 0, 10);
-#ifdef EXT_BUILD_CHANNEL_LIST
- return -EOPNOTSUPP;
-#endif // EXT_BUILD_CHANNEL_LIST //
-
// Country can be set only when EEPROM not programmed
if (pAd->CommonCfg.CountryRegion & 0x80)
{
@@ -309,10 +293,6 @@ INT Set_CountryRegionABand_Proc(
region = simple_strtol(arg, 0, 10);
-#ifdef EXT_BUILD_CHANNEL_LIST
- return -EOPNOTSUPP;
-#endif // EXT_BUILD_CHANNEL_LIST //
-
// Country can be set only when EEPROM not programmed
if (pAd->CommonCfg.CountryRegionForABand & 0x80)
{
@@ -355,20 +335,15 @@ INT Set_WirelessMode_Proc(
WirelessMode = simple_strtol(arg, 0, 10);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
INT MaxPhyMode = PHY_11G;
-#ifdef DOT11_N_SUPPORT
MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
if (WirelessMode <= MaxPhyMode)
{
RTMPSetPhyMode(pAd, WirelessMode);
-#ifdef DOT11_N_SUPPORT
+
if (WirelessMode >= PHY_11ABGN_MIXED)
{
pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
@@ -379,7 +354,7 @@ INT Set_WirelessMode_Proc(
pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
}
-#endif // DOT11_N_SUPPORT //
+
// Set AdhocMode rates
if (pAd->StaCfg.BssType == BSS_ADHOC)
{
@@ -393,14 +368,11 @@ INT Set_WirelessMode_Proc(
success = FALSE;
}
}
-#endif // CONFIG_STA_SUPPORT //
// it is needed to set SSID to take effect
if (success == TRUE)
{
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%ld)\n", WirelessMode));
}
else
@@ -431,14 +403,11 @@ INT Set_Channel_Proc(
// check if this channel is valid
if (ChannelSanity(pAd, Channel) == TRUE)
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pAd->CommonCfg.Channel = Channel;
if (MONITOR_ON(pAd))
{
-#ifdef DOT11_N_SUPPORT
N_ChannelCheck(pAd);
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
@@ -450,7 +419,6 @@ INT Set_Channel_Proc(
pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
}
else
-#endif // DOT11_N_SUPPORT //
{
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.Channel);
@@ -458,16 +426,11 @@ INT Set_Channel_Proc(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
success = TRUE;
}
else
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- success = FALSE;
-#endif // CONFIG_STA_SUPPORT //
+ success = FALSE;
}
@@ -523,14 +486,10 @@ INT Set_TxPower_Proc(
TxPower = (ULONG) simple_strtol(arg, 0, 10);
if (TxPower <= 100)
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pAd->CommonCfg.TxPowerDefault = TxPower;
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
}
-#endif // CONFIG_STA_SUPPORT //
success = TRUE;
}
else
@@ -595,22 +554,16 @@ INT Set_TxPreamble_Proc(
{
case Rt802_11PreambleShort:
pAd->CommonCfg.TxPreamble = Preamble;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
-#endif // CONFIG_STA_SUPPORT //
+
+ MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
break;
case Rt802_11PreambleLong:
-#ifdef CONFIG_STA_SUPPORT
case Rt802_11PreambleAuto:
// if user wants AUTO, initialize to LONG here, then change according to AP's
// capability upon association.
-#endif // CONFIG_STA_SUPPORT //
pAd->CommonCfg.TxPreamble = Preamble;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
-#endif // CONFIG_STA_SUPPORT //
+
+ MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
break;
default: //Invalid argument
return FALSE;
@@ -639,10 +592,8 @@ INT Set_RTSThreshold_Proc(
if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
-#ifdef CONFIG_STA_SUPPORT
else if (RtsThresh == 0)
pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-#endif // CONFIG_STA_SUPPORT //
else
return FALSE; //Invalid argument
@@ -683,15 +634,12 @@ INT Set_FragThreshold_Proc(
pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
else
pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
}
-#endif // CONFIG_STA_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
@@ -814,6 +762,7 @@ INT Show_DescInfo_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg)
{
+#ifdef RT2860
INT i, QueIdx=0;
PRT28XX_RXD_STRUC pRxD;
PTXD_STRUC pTxD;
@@ -844,7 +793,7 @@ INT Show_DescInfo_Proc(
hex_dump("Rx Descriptor", (char *)pRxD, 16);
printk("pRxD->DDONE = %x\n", pRxD->DDONE);
}
-
+#endif /* RT2860 */
return TRUE;
}
@@ -912,7 +861,6 @@ BOOLEAN RTMPCheckStrPrintAble(
========================================================================
*/
-#ifdef CONFIG_STA_SUPPORT
VOID RTMPSetDesiredRates(
IN PRTMP_ADAPTER pAdapter,
IN LONG Rates)
@@ -1125,10 +1073,7 @@ NDIS_STATUS RTMPWPARemoveKeyProc(
return (Status);
}
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
/*
========================================================================
@@ -1178,7 +1123,6 @@ VOID RTMPWPARemoveAllKeys(
}
}
-#endif // CONFIG_STA_SUPPORT //
/*
========================================================================
@@ -1202,19 +1146,11 @@ VOID RTMPSetPhyMode(
INT i;
// the selected phymode must be supported by the RF IC encoded in E2PROM
- // if no change, do nothing
- /* bug fix
- if (pAd->CommonCfg.PhyMode == phymode)
- return;
- */
pAd->CommonCfg.PhyMode = (UCHAR)phymode;
DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
-#ifdef EXT_BUILD_CHANNEL_LIST
- BuildChannelListEx(pAd);
-#else
+
BuildChannelList(pAd);
-#endif // EXT_BUILD_CHANNEL_LIST //
// sanity check user setting
for (i = 0; i < pAd->ChannelListNum; i++)
@@ -1225,10 +1161,7 @@ VOID RTMPSetPhyMode(
if (i == pAd->ChannelListNum)
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->CommonCfg.Channel = FirstChannel(pAd);
-#endif // CONFIG_STA_SUPPORT //
+ pAd->CommonCfg.Channel = FirstChannel(pAd);
DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
}
@@ -1253,12 +1186,10 @@ VOID RTMPSetPhyMode(
case PHY_11G:
case PHY_11BG_MIXED:
case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
case PHY_11N_2_4G:
case PHY_11ABGN_MIXED:
case PHY_11BGN_MIXED:
case PHY_11GN_MIXED:
-#endif // DOT11_N_SUPPORT //
pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
@@ -1288,11 +1219,9 @@ VOID RTMPSetPhyMode(
break;
case PHY_11A:
-#ifdef DOT11_N_SUPPORT
case PHY_11AN_MIXED:
case PHY_11AGN_MIXED:
case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
@@ -1322,8 +1251,6 @@ VOID RTMPSetPhyMode(
pAd->CommonCfg.BandState = UNKNOWN_BAND;
}
-
-#ifdef DOT11_N_SUPPORT
/*
========================================================================
Routine Description:
@@ -1492,6 +1419,16 @@ VOID RTMPSetHT(
pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
}
+#ifndef RT30xx
+#ifdef RT2870
+ /* Frank recommend ,If not, Tx maybe block in high power. Rx has no problem*/
+ if(IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
+ {
+ pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 0;
+ pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
+ }
+#endif // RT2870 //
+#endif
if(pHTPhyMode->SHORTGI == GI_400)
{
@@ -1539,14 +1476,7 @@ VOID RTMPSetHT(
}
AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- RTMPSetIndividualHT(pAd, 0);
- }
-#endif // CONFIG_STA_SUPPORT //
-
+ RTMPSetIndividualHT(pAd, 0);
}
/*
@@ -1571,16 +1501,12 @@ VOID RTMPSetIndividualHT(
do
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
//pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
break;
}
-#endif // CONFIG_STA_SUPPORT //
} while (FALSE);
if (pDesired_ht_phy == NULL)
@@ -1710,7 +1636,6 @@ VOID RTMPUpdateHTIE(
DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
}
-#endif // DOT11_N_SUPPORT //
/*
========================================================================
@@ -1732,8 +1657,6 @@ VOID RTMPAddWcidAttributeEntry(
USHORT Wcid = 0;
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (BssIdx > BSS0)
{
@@ -1748,39 +1671,22 @@ VOID RTMPAddWcidAttributeEntry(
Wcid = pEntry->Aid;
else if (pEntry && INFRA_ON(pAd))
{
-#ifdef QOS_DLS_SUPPORT
- if (pEntry->ValidAsDls == TRUE)
- Wcid = pEntry->Aid;
- else
-#endif // QOS_DLS_SUPPORT //
Wcid = BSSID_WCID;
}
else
Wcid = MCAST_WCID;
}
-#endif // CONFIG_STA_SUPPORT //
}
// Update WCID attribute table
offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (pEntry && pEntry->ValidAsMesh)
WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
-#ifdef QOS_DLS_SUPPORT
- else if ((pEntry) && (pEntry->ValidAsDls) &&
- ((CipherAlg == CIPHER_TKIP) ||
- (CipherAlg == CIPHER_TKIP_NO_MIC) ||
- (CipherAlg == CIPHER_AES) ||
- (CipherAlg == CIPHER_NONE)))
- WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
-#endif // QOS_DLS_SUPPORT //
else
WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
}
-#endif // CONFIG_STA_SUPPORT //
RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
@@ -1801,7 +1707,12 @@ VOID RTMPAddWcidAttributeEntry(
}
// For key index and ext IV bit, so only need to update the position(offset+3).
+#ifdef RT2860
RTMP_IO_WRITE8(pAd, offset+3, IVEIV);
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
+#endif // RT2870 //
DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
@@ -1864,7 +1775,6 @@ CHAR *GetAuthMode(CHAR auth)
return "UNKNOW";
}
-#if 1 //#ifndef UCOS
/*
==========================================================================
Description:
@@ -1912,11 +1822,10 @@ VOID RTMPIoctlGetSiteSurvey(
"Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
WaitCnt = 0;
-#ifdef CONFIG_STA_SUPPORT
pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
+
while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
OS_WAIT(500);
-#endif // CONFIG_STA_SUPPORT //
for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
{
@@ -1982,9 +1891,7 @@ VOID RTMPIoctlGetSiteSurvey(
sprintf(msg+strlen(msg),"\n");
}
-#ifdef CONFIG_STA_SUPPORT
pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-#endif // CONFIG_STA_SUPPORT //
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
@@ -2010,9 +1917,7 @@ VOID RTMPIoctlGetMacTable(
COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
-#ifdef DOT11_N_SUPPORT
MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
-#endif // DOT11_N_SUPPORT //
// Fill in RSSI per entry
MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
@@ -2072,9 +1977,7 @@ VOID RTMPIoctlGetMacTable(
kfree(msg);
}
-#endif // UCOS //
-#ifdef DOT11_N_SUPPORT
INT Set_BASetup_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg)
@@ -2089,7 +1992,6 @@ INT Set_BASetup_Proc(
=>The six 2 digit hex-decimal number previous are the Mac address,
=>The seventh decimal number is the tid value.
*/
- //printk("\n%s\n", arg);
if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
return FALSE;
@@ -2283,9 +2185,7 @@ INT Set_HtMcs_Proc(
IN PUCHAR arg)
{
ULONG HtMcs, Mcs_tmp;
-#ifdef CONFIG_STA_SUPPORT
BOOLEAN bAutoRate = FALSE;
-#endif // CONFIG_STA_SUPPORT //
Mcs_tmp = simple_strtol(arg, 0, 10);
@@ -2294,8 +2194,6 @@ INT Set_HtMcs_Proc(
else
HtMcs = MCS_AUTO;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
@@ -2330,7 +2228,6 @@ INT Set_HtMcs_Proc(
if (ADHOC_ON(pAd))
return TRUE;
}
-#endif // CONFIG_STA_SUPPORT //
SetCommonHT(pAd);
@@ -2592,13 +2489,26 @@ INT Set_HtAutoBa_Proc(
Value = simple_strtol(arg, 0, 10);
if (Value == 0)
+ {
pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
+#ifdef RT30xx
+ pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
+#endif
+ }
else if (Value == 1)
+ {
pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
+#ifdef RT30xx
+ pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
+#endif
+ }
else
return FALSE; //Invalid argument
pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
+#ifdef RT30xx
+ pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
+#endif
SetCommonHT(pAd);
DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
@@ -2762,10 +2672,7 @@ INT Set_HtMimoPs_Proc(
return TRUE;
}
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
INT SetCommonHT(
IN PRTMP_ADAPTER pAd)
{
@@ -2787,7 +2694,6 @@ INT SetCommonHT(
return TRUE;
}
-#endif // DOT11_N_SUPPORT //
INT Set_FixedTxMode_Proc(
IN PRTMP_ADAPTER pAd,
@@ -2804,45 +2710,13 @@ INT Set_FixedTxMode_Proc(
fix_tx_mode = FIXED_TXMODE_CCK;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
-#endif // CONFIG_STA_SUPPORT //
+ pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
return TRUE;
}
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-INT Set_OpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Can not switch operate mode on interface up !! \n"));
- return FALSE;
- }
-
- if (Value == 0)
- pAd->OpMode = OPMODE_STA;
- else if (Value == 1)
- pAd->OpMode = OPMODE_AP;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_OpMode_Proc::(OpMode=%s)\n", pAd->OpMode == 1 ? "AP Mode" : "STA Mode"));
-
- return TRUE;
-}
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-
/////////////////////////////////////////////////////////////////////////
PCHAR RTMPGetRalinkAuthModeStr(
IN NDIS_802_11_AUTHENTICATION_MODE authMode)
@@ -2851,7 +2725,9 @@ PCHAR RTMPGetRalinkAuthModeStr(
{
case Ndis802_11AuthModeOpen:
return "OPEN";
+#if defined(RT2860) || defined(RT30xx)
default:
+#endif
case Ndis802_11AuthModeWPAPSK:
return "WPAPSK";
case Ndis802_11AuthModeShared:
@@ -2866,8 +2742,14 @@ PCHAR RTMPGetRalinkAuthModeStr(
return "WPAPSKWPA2PSK";
case Ndis802_11AuthModeWPA1WPA2:
return "WPA1WPA2";
+#ifndef RT30xx
case Ndis802_11AuthModeWPANone:
return "WPANONE";
+#ifdef RT2870
+ default:
+ return "UNKNOW";
+#endif
+#endif
}
}
@@ -2876,7 +2758,9 @@ PCHAR RTMPGetRalinkEncryModeStr(
{
switch(encryMode)
{
+#if defined(RT2860) || defined(RT30xx)
default:
+#endif
case Ndis802_11WEPDisabled:
return "NONE";
case Ndis802_11WEPEnabled:
@@ -2887,6 +2771,10 @@ PCHAR RTMPGetRalinkEncryModeStr(
return "AES";
case Ndis802_11Encryption4Enabled:
return "TKIPAES";
+#if !defined(RT2860) && !defined(RT30xx)
+ default:
+ return "UNKNOW";
+#endif
}
}
@@ -2911,7 +2799,7 @@ INT RTMPShowCfgValue(
{
sprintf(pBuf, "\n");
for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
- sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
+ sprintf(pBuf + strlen(pBuf), "%s\n", PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
}
return Status;
@@ -2921,11 +2809,7 @@ INT Show_SSID_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf)
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
-#endif // CONFIG_STA_SUPPORT //
+ sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
return 0;
}
@@ -2950,7 +2834,6 @@ INT Show_WirelessMode_Proc(
case PHY_11G:
sprintf(pBuf, "\t11G");
break;
-#ifdef DOT11_N_SUPPORT
case PHY_11ABGN_MIXED:
sprintf(pBuf, "\t11A/B/G/N");
break;
@@ -2972,7 +2855,6 @@ INT Show_WirelessMode_Proc(
case PHY_11N_5G:
sprintf(pBuf, "\t11N only with 5G");
break;
-#endif // DOT11_N_SUPPORT //
default:
sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
break;
@@ -3066,7 +2948,6 @@ INT Show_FragThreshold_Proc(
return 0;
}
-#ifdef DOT11_N_SUPPORT
INT Show_HtBw_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf)
@@ -3086,11 +2967,7 @@ INT Show_HtMcs_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf)
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
-#endif // CONFIG_STA_SUPPORT //
+ sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
return 0;
}
@@ -3191,7 +3068,6 @@ INT Show_HtAutoBa_Proc(
sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
return 0;
}
-#endif // DOT11_N_SUPPORT //
INT Show_CountryRegion_Proc(
IN PRTMP_ADAPTER pAd,
@@ -3232,11 +3108,7 @@ INT Show_WmmCapable_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf)
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
-#endif // CONFIG_STA_SUPPORT //
+ sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
return 0;
}
@@ -3250,7 +3122,6 @@ INT Show_IEEE80211H_Proc(
return 0;
}
-#ifdef CONFIG_STA_SUPPORT
INT Show_NetworkType_Proc(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pBuf)
@@ -3275,7 +3146,6 @@ INT Show_NetworkType_Proc(
}
return 0;
}
-#endif // CONFIG_STA_SUPPORT //
INT Show_AuthMode_Proc(
IN PRTMP_ADAPTER pAd,
@@ -3283,10 +3153,7 @@ INT Show_AuthMode_Proc(
{
NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AuthMode = pAd->StaCfg.AuthMode;
-#endif // CONFIG_STA_SUPPORT //
+ AuthMode = pAd->StaCfg.AuthMode;
if ((AuthMode >= Ndis802_11AuthModeOpen) &&
(AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
@@ -3303,10 +3170,7 @@ INT Show_EncrypType_Proc(
{
NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- WepStatus = pAd->StaCfg.WepStatus;
-#endif // CONFIG_STA_SUPPORT //
+ WepStatus = pAd->StaCfg.WepStatus;
if ((WepStatus >= Ndis802_11WEPEnabled) &&
(WepStatus <= Ndis802_11Encryption4KeyAbsent))
@@ -3323,10 +3187,7 @@ INT Show_DefaultKeyID_Proc(
{
UCHAR DefaultKeyId = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- DefaultKeyId = pAd->StaCfg.DefaultKeyId;
-#endif // CONFIG_STA_SUPPORT //
+ DefaultKeyId = pAd->StaCfg.DefaultKeyId;
sprintf(pBuf, "\t%d", DefaultKeyId);
@@ -3396,11 +3257,7 @@ INT Show_WPAPSK_Proc(
INT idx;
UCHAR PMK[32] = {0};
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
-#endif // CONFIG_STA_SUPPORT //
+ NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
sprintf(pBuf, "\tPMK = ");
for (idx = 0; idx < 32; idx++)
diff --git a/drivers/staging/rt2860/common/cmm_sanity.c b/drivers/staging/rt2860/common/cmm_sanity.c
index b0f070d43135..843e44e41abe 100644
--- a/drivers/staging/rt2860/common/cmm_sanity.c
+++ b/drivers/staging/rt2860/common/cmm_sanity.c
@@ -275,9 +275,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
OUT PQOS_CAPABILITY_PARM pQosCapability,
OUT ULONG *pRalinkIe,
OUT UCHAR *pHtCapabilityLen,
-#ifdef CONFIG_STA_SUPPORT
OUT UCHAR *pPreNHtCapabilityLen,
-#endif // CONFIG_STA_SUPPORT //
OUT HT_CAPABILITY_IE *pHtCapability,
OUT UCHAR *AddHtInfoLen,
OUT ADD_HT_INFO_IE *AddHtInfo,
@@ -286,9 +284,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
OUT PNDIS_802_11_VARIABLE_IEs pVIE)
{
CHAR *Ptr;
-#ifdef CONFIG_STA_SUPPORT
CHAR TimLen;
-#endif // CONFIG_STA_SUPPORT //
PFRAME_802_11 pFrame;
PEID_STRUCT pEid;
UCHAR SubType;
@@ -316,10 +312,8 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
*pAironetCellPowerLimit = 0xFF; // Default of AironetCellPowerLimit is 0xFF
*LengthVIE = 0; // Set the length of VIE to init value 0
*pHtCapabilityLen = 0; // Set the length of VIE to init value 0
-#ifdef CONFIG_STA_SUPPORT
if (pAd->OpMode == OPMODE_STA)
*pPreNHtCapabilityLen = 0; // Set the length of VIE to init value 0
-#endif // CONFIG_STA_SUPPORT //
*AddHtInfoLen = 0; // Set the length of VIE to init value 0
*pRalinkIe = 0;
*pNewChannel = 0;
@@ -428,8 +422,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
*(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
*(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
*pPreNHtCapabilityLen = 0; // Nnow we only support 26 bytes.
@@ -437,7 +429,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
*LengthVIE += (pEid->Len + 2);
}
-#endif // CONFIG_STA_SUPPORT //
}
else
{
@@ -458,14 +449,11 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
*(USHORT *)(&AddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo2));
*(USHORT *)(&AddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo3));
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
Ptr = (PUCHAR) pVIE;
NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
*LengthVIE += (pEid->Len + 2);
}
-#endif // CONFIG_STA_SUPPORT //
}
else
{
@@ -492,8 +480,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
if(pEid->Len == 1)
{
*pChannel = *pEid->Octet;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
{
if (ChannelSanity(pAd, *pChannel) == 0)
{
@@ -501,7 +488,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
return FALSE;
}
}
-#endif // CONFIG_STA_SUPPORT //
+
Sanity |= 0x4;
}
else
@@ -539,14 +526,13 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
}
break;
-#ifdef CONFIG_STA_SUPPORT
case IE_TIM:
if(INFRA_ON(pAd) && SubType == SUBTYPE_BEACON)
{
GetTimBit((PUCHAR)pEid, pAd->StaActive.Aid, &TimLen, pBcastFlag, pDtimCount, pDtimPeriod, pMessageToMe);
}
break;
-#endif // CONFIG_STA_SUPPORT //
+
case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
if(pEid->Len == 3)
{
@@ -568,8 +554,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
else
*pRalinkIe = 0xf0000000; // Set to non-zero value (can't set bit0-2) to represent this is Ralink Chip. So at linkup, we will set ralinkchip flag.
}
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
// This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
// Other vendors had production before IE_HT_CAP value is assigned. To backward support those old-firmware AP,
@@ -588,8 +572,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
*AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
}
}
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
{
// Copy to pVIE which will report to microsoft bssid list.
@@ -712,15 +694,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
*LengthVIE += (pEid->Len + 2);
}
break;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- case IE_COUNTRY:
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- break;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
default:
break;
@@ -731,8 +704,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
}
// For some 11a AP. it did not have the channel EID, patch here
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
UCHAR LatchRfChannel = MsgChannel;
if ((pAd->LatchRfRegs.Channel > 14) && ((Sanity & 0x4) == 0))
@@ -744,7 +715,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
Sanity |= 0x4;
}
}
-#endif // CONFIG_STA_SUPPORT //
if (Sanity != 0x7)
{
@@ -758,76 +728,6 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
}
-#ifdef DOT11N_DRAFT3
-/*
- ==========================================================================
- Description:
- MLME message sanity check for some IE addressed in 802.11n d3.03.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerBeaconAndProbeRspSanity2(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *RegClass)
-{
- CHAR *Ptr;
- PFRAME_802_11 pFrame;
- PEID_STRUCT pEid;
- ULONG Length = 0;
-
- pFrame = (PFRAME_802_11)Msg;
-
- *RegClass = 0;
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- // get timestamp from payload and advance the pointer
- Ptr += TIMESTAMP_LEN;
- Length += TIMESTAMP_LEN;
-
- // get beacon interval from payload and advance the pointer
- Ptr += 2;
- Length += 2;
-
- // get capability info from payload and advance the pointer
- Ptr += 2;
- Length += 2;
-
- pEid = (PEID_STRUCT) Ptr;
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- switch(pEid->Eid)
- {
- case IE_SUPP_REG_CLASS:
- if(pEid->Len > 0)
- {
- *RegClass = *pEid->Octet;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
- }
-
- Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- return TRUE;
-
-}
-#endif // DOT11N_DRAFT3 //
-
/*
==========================================================================
Description:
@@ -855,10 +755,8 @@ BOOLEAN MlmeScanReqSanity(
if ((*pBssType == BSS_INFRA || *pBssType == BSS_ADHOC || *pBssType == BSS_ANY)
&& (*pScanType == SCAN_ACTIVE || *pScanType == SCAN_PASSIVE
-#ifdef CONFIG_STA_SUPPORT
|| *pScanType == SCAN_CISCO_PASSIVE || *pScanType == SCAN_CISCO_ACTIVE
|| *pScanType == SCAN_CISCO_CHANNEL_LOAD || *pScanType == SCAN_CISCO_NOISE
-#endif // CONFIG_STA_SUPPORT //
))
{
return TRUE;
@@ -940,9 +838,6 @@ BOOLEAN PeerAuthSanity(
NdisMoveMemory(pStatus, &pFrame->Octet[4], 2);
if ((*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
)
{
if (*pSeq == 1 || *pSeq == 2)
@@ -1003,9 +898,6 @@ BOOLEAN MlmeAuthReqSanity(
*pAlg = pInfo->Alg;
if (((*pAlg == Ndis802_11AuthModeShared) ||(*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
) &&
((*pAddr & 0x01) == 0))
{
@@ -1344,290 +1236,3 @@ BOOLEAN PeerWpaMessageSanity(
return TRUE;
}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN MlmeDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PRT_802_11_DLS *pDLS,
- OUT PUSHORT pReason)
-{
- MLME_DLS_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_DLS_REQ_STRUCT *)Msg;
-
- *pDLS = pInfo->pDLS;
- *pReason = pInfo->Reason;
-
- return TRUE;
-}
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN PeerDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pDlsTimeout,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
- PEID_STRUCT eid_ptr;
-
- // to prevent caller from using garbage output value
- *pCapabilityInfo = 0;
- *pDlsTimeout = 0;
- *pHtCapabilityLen = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pDlsTimeout, Ptr, 2);
- Ptr += 2;
-
- // Category and Action field + DA + SA + capability + Timeout
- eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
-
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_SUPP_RATES:
- if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
- {
- NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
- DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
- *pRatesLen = eid_ptr->Len;
- }
- else
- {
- *pRatesLen = 8;
- Rates[0] = 0x82;
- Rates[1] = 0x84;
- Rates[2] = 0x8b;
- Rates[3] = 0x96;
- Rates[4] = 0x12;
- Rates[5] = 0x24;
- Rates[6] = 0x48;
- Rates[7] = 0x6c;
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
- *pRatesLen = (*pRatesLen) + eid_ptr->Len;
- }
- else
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
- *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
- }
- break;
-
- case IE_HT_CAP:
- if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
- {
- NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
- *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_HT_CAP\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
- }
- break;
-
- default:
- break;
- }
-
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerDlsRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
- PEID_STRUCT eid_ptr;
-
- // to prevent caller from using garbage output value
- *pStatus = 0;
- *pCapabilityInfo = 0;
- *pHtCapabilityLen = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get status code from payload and advance the pointer
- NdisMoveMemory(pStatus, Ptr, 2);
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- if (pStatus == 0)
- {
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
- }
-
- // Category and Action field + status code + DA + SA + capability
- eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
-
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_SUPP_RATES:
- if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
- {
- NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
- DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
- *pRatesLen = eid_ptr->Len;
- }
- else
- {
- *pRatesLen = 8;
- Rates[0] = 0x82;
- Rates[1] = 0x84;
- Rates[2] = 0x8b;
- Rates[3] = 0x96;
- Rates[4] = 0x12;
- Rates[5] = 0x24;
- Rates[6] = 0x48;
- Rates[7] = 0x6c;
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
- *pRatesLen = (*pRatesLen) + eid_ptr->Len;
- }
- else
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
- *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
- }
- break;
-
- case IE_HT_CAP:
- if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
- {
- NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
- *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_HT_CAP\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
- }
- break;
-
- default:
- break;
- }
-
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerDlsTearDownSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pReason)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
-
- // to prevent caller from using garbage output value
- *pReason = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get reason code from payload and advance the pointer
- NdisMoveMemory(pReason, Ptr, 2);
- Ptr += 2;
-
- return TRUE;
-}
-#endif // QOS_DLS_SUPPORT //
-
diff --git a/drivers/staging/rt2860/common/cmm_sync.c b/drivers/staging/rt2860/common/cmm_sync.c
index d29e0b630e2e..a6e1b6ddfe57 100644
--- a/drivers/staging/rt2860/common/cmm_sync.c
+++ b/drivers/staging/rt2860/common/cmm_sync.c
@@ -95,9 +95,7 @@ VOID BuildChannelList(
// if not 11a-only mode, channel list starts from 2.4Ghz band
if ((pAd->CommonCfg.PhyMode != PHY_11A)
-#ifdef DOT11_N_SUPPORT
&& (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED) && (pAd->CommonCfg.PhyMode != PHY_11N_5G)
-#endif // DOT11_N_SUPPORT //
)
{
switch (pAd->CommonCfg.CountryRegion & 0x7f)
@@ -146,10 +144,8 @@ VOID BuildChannelList(
}
if ((pAd->CommonCfg.PhyMode == PHY_11A) || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-#ifdef DOT11_N_SUPPORT
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)
-#endif // DOT11_N_SUPPORT //
)
{
switch (pAd->CommonCfg.CountryRegionForABand & 0x7f)
@@ -383,33 +379,18 @@ VOID ScanNextChannel(
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
UCHAR SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
-#ifdef CONFIG_STA_SUPPORT
USHORT Status;
PHEADER_802_11 pHdr80211;
-#endif // CONFIG_STA_SUPPORT //
UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (MONITOR_ON(pAd))
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
+ if (MONITOR_ON(pAd))
return;
-#endif // RALINK_ATE //
if (pAd->MlmeAux.Channel == 0)
{
if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
-#ifdef CONFIG_STA_SUPPORT
&& (INFRA_ON(pAd)
|| (pAd->OpMode == OPMODE_AP))
-#endif // CONFIG_STA_SUPPORT //
)
{
AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
@@ -427,8 +408,6 @@ VOID ScanNextChannel(
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
//
// To prevent data lost.
@@ -458,31 +437,35 @@ VOID ScanNextChannel(
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
}
-#endif // CONFIG_STA_SUPPORT //
-
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
}
+#ifdef RT2870
+ else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->OpMode == OPMODE_STA))
+ {
+ pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
+ MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
+ }
+#endif // RT2870 //
else
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// BBP and RF are not accessible in PS mode, we has to wake them up first
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+#ifdef RT2860
AsicForceWakeup(pAd, FROM_TX);
-
+#endif
+#ifdef RT2870
+ AsicForceWakeup(pAd, TRUE);
+#endif
// leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON
if (pAd->StaCfg.Psm == PWR_SAVE)
MlmeSetPsmBit(pAd, PWR_ACTIVE);
}
-#endif // CONFIG_STA_SUPPORT //
AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, TRUE);
AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (pAd->MlmeAux.Channel > 14)
{
@@ -492,19 +475,8 @@ VOID ScanNextChannel(
ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
}
}
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // carrier detection
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- ScanType = SCAN_PASSIVE;
- ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
- }
-#endif // CARRIER_DETECTION_SUPPORT //
}
-#endif // CONFIG_STA_SUPPORT //
-
//Global country domain(ch1-11:active scan, ch12-14 passive scan)
if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12) && ((pAd->CommonCfg.CountryRegion & 0x7f) == REGION_31_BG_BAND))
{
@@ -515,7 +487,6 @@ VOID ScanNextChannel(
// Chnage the channel scan time for CISCO stuff based on its IAPP announcement
if (ScanType == FAST_SCAN_ACTIVE)
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, FAST_ACTIVE_SCAN_TIME);
-#ifdef CONFIG_STA_SUPPORT
else if (((ScanType == SCAN_CISCO_ACTIVE) ||
(ScanType == SCAN_CISCO_PASSIVE) ||
(ScanType == SCAN_CISCO_CHANNEL_LOAD) ||
@@ -526,13 +497,10 @@ VOID ScanNextChannel(
else
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime);
}
-#endif // CONFIG_STA_SUPPORT //
else // must be SCAN_PASSIVE or SCAN_ACTIVE
{
if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-#ifdef DOT11_N_SUPPORT
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
-#endif // DOT11_N_SUPPORT //
)
{
if (pAd->MlmeAux.Channel > 14)
@@ -551,14 +519,12 @@ VOID ScanNextChannel(
if (NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - ScanNextChannel() allocate memory fail\n"));
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
{
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
}
-#endif // CONFIG_STA_SUPPORT //
return;
}
@@ -592,78 +558,35 @@ VOID ScanNextChannel(
FrameLen += Tmp;
}
-#ifdef DOT11_N_SUPPORT
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
ULONG Tmp;
UCHAR HtLen;
UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
+
if (pAd->bBroadComHT == TRUE)
{
HtLen = pAd->MlmeAux.HtCapabilityLen + 4;
-#ifdef RT_BIG_ENDIAN
- NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
1, &WpaIe,
1, &HtLen,
4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#else
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
-#endif // RT_BIG_ENDIAN //
}
else
{
HtLen = pAd->MlmeAux.HtCapabilityLen;
-#ifdef RT_BIG_ENDIAN
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, SIZE_HT_CAP_IE);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
1, &HtCapIe,
1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#else
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &HtCapIe,
- 1, &HtLen,
HtLen, &pAd->CommonCfg.HtCapability,
END_OF_ARGS);
-#endif // RT_BIG_ENDIAN //
}
FrameLen += Tmp;
-
-#ifdef DOT11N_DRAFT3
- if (pAd->CommonCfg.BACapability.field.b2040CoexistScanSup == 1)
- {
- ULONG Tmp;
- HtLen = 1;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtHtCapIe,
- 1, &HtLen,
- 1, &pAd->CommonCfg.BSSCoexist2040.word,
- END_OF_ARGS);
-
- FrameLen += Tmp;
- }
-#endif // DOT11N_DRAFT3 //
}
-#endif // DOT11_N_SUPPORT //
-
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
@@ -671,11 +594,7 @@ VOID ScanNextChannel(
// For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe reponse
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
-#endif // CONFIG_STA_SUPPORT //
-
+ pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
}
}
diff --git a/drivers/staging/rt2860/common/cmm_wpa.c b/drivers/staging/rt2860/common/cmm_wpa.c
index 69baf522fa01..bda69e76867e 100644
--- a/drivers/staging/rt2860/common/cmm_wpa.c
+++ b/drivers/staging/rt2860/common/cmm_wpa.c
@@ -39,10 +39,14 @@
// WPA OUI
UCHAR OUI_WPA_NONE_AKM[4] = {0x00, 0x50, 0xF2, 0x00};
UCHAR OUI_WPA_VERSION[4] = {0x00, 0x50, 0xF2, 0x01};
+#ifndef RT30xx
UCHAR OUI_WPA_WEP40[4] = {0x00, 0x50, 0xF2, 0x01};
+#endif
UCHAR OUI_WPA_TKIP[4] = {0x00, 0x50, 0xF2, 0x02};
UCHAR OUI_WPA_CCMP[4] = {0x00, 0x50, 0xF2, 0x04};
+#ifndef RT30xx
UCHAR OUI_WPA_WEP104[4] = {0x00, 0x50, 0xF2, 0x05};
+#endif
UCHAR OUI_WPA_8021X_AKM[4] = {0x00, 0x50, 0xF2, 0x01};
UCHAR OUI_WPA_PSK_AKM[4] = {0x00, 0x50, 0xF2, 0x02};
// WPA2 OUI
@@ -51,7 +55,9 @@ UCHAR OUI_WPA2_TKIP[4] = {0x00, 0x0F, 0xAC, 0x02};
UCHAR OUI_WPA2_CCMP[4] = {0x00, 0x0F, 0xAC, 0x04};
UCHAR OUI_WPA2_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x01};
UCHAR OUI_WPA2_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x02};
+#ifndef RT30xx
UCHAR OUI_WPA2_WEP104[4] = {0x00, 0x0F, 0xAC, 0x05};
+#endif
// MSA OUI
UCHAR OUI_MSA_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x05}; // Not yet final - IEEE 802.11s-D1.06
UCHAR OUI_MSA_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x06}; // Not yet final - IEEE 802.11s-D1.06
@@ -370,7 +376,7 @@ static VOID RTMPInsertRsnIeCipher(
break;
}
-#ifdef CONFIG_STA_SUPPORT
+#ifndef RT30xx
if ((pAd->OpMode == OPMODE_STA) &&
(pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
(pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled))
@@ -386,8 +392,7 @@ static VOID RTMPInsertRsnIeCipher(
break;
}
}
-#endif // CONFIG_STA_SUPPORT //
-
+#endif
// swap for big-endian platform
pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
@@ -448,7 +453,7 @@ static VOID RTMPInsertRsnIeCipher(
break;
}
-#ifdef CONFIG_STA_SUPPORT
+#ifndef RT30xx
if ((pAd->OpMode == OPMODE_STA) &&
(pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
(pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled))
@@ -464,8 +469,7 @@ static VOID RTMPInsertRsnIeCipher(
break;
}
}
-#endif // CONFIG_STA_SUPPORT //
-
+#endif
// swap for big-endian platform
pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
@@ -621,23 +625,19 @@ VOID RTMPMakeRSNIE(
UCHAR PrimaryRsnie;
BOOLEAN bMixCipher = FALSE; // indicate the pairwise and group cipher are different
UCHAR p_offset;
- WPA_MIX_PAIR_CIPHER FlexibleCipher = MIX_CIPHER_NOTUSE; // it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode
+ WPA_MIX_PAIR_CIPHER FlexibleCipher = WPA_TKIPAES_WPA2_TKIPAES; // it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode
rsnielen_cur_p = NULL;
rsnielen_ex_cur_p = NULL;
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
-#ifdef WPA_SUPPLICANT_SUPPORT
if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
{
if (AuthMode < Ndis802_11AuthModeWPA)
return;
}
else
-#endif // WPA_SUPPLICANT_SUPPORT //
{
// Support WPAPSK or WPA2PSK in STA-Infra mode
// Support WPANone in STA-Adhoc mode
@@ -660,7 +660,6 @@ VOID RTMPMakeRSNIE(
bMixCipher = pAd->StaCfg.bMixCipher;
}
-#endif // CONFIG_STA_SUPPORT //
}
// indicate primary RSNIE as WPA or WPA2
@@ -1131,11 +1130,6 @@ BOOLEAN RTMPParseEapolKeyData(
return FALSE;
}
-
-#ifdef CONFIG_STA_SUPPORT
- // Todo
-#endif // CONFIG_STA_SUPPORT //
-
return TRUE;
}
diff --git a/drivers/staging/rt2860/common/dfs.c b/drivers/staging/rt2860/common/dfs.c
index b09bba5cb206..23330f2661d9 100644
--- a/drivers/staging/rt2860/common/dfs.c
+++ b/drivers/staging/rt2860/common/dfs.c
@@ -80,18 +80,6 @@ VOID BbpRadarDetectionStart(
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 124, 0x28);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 125, 0xff);
-#if 0
- // toggle Rx enable bit for radar detection.
- // it's Andy's recommand.
- {
- UINT32 Value;
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (0x1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- Value &= ~(0x1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
-#endif
RadarPeriod = ((UINT)RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + (UINT)pAd->CommonCfg.RadarDetect.DfsSessionTime) < 250 ?
(RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + pAd->CommonCfg.RadarDetect.DfsSessionTime) : 250;
@@ -314,15 +302,6 @@ ULONG RTMPReadRadarDuration(
{
ULONG result = 0;
-#ifdef DFS_SUPPORT
- UINT8 duration1 = 0, duration2 = 0, duration3 = 0;
-
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R116, &duration1);
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R117, &duration2);
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R118, &duration3);
- result = (duration1 << 16) + (duration2 << 8) + duration3;
-#endif // DFS_SUPPORT //
-
return result;
}
diff --git a/drivers/staging/rt2860/common/eeprom.c b/drivers/staging/rt2860/common/eeprom.c
index bed2d666629c..9729323baca5 100644
--- a/drivers/staging/rt2860/common/eeprom.c
+++ b/drivers/staging/rt2860/common/eeprom.c
@@ -73,12 +73,16 @@ USHORT ShiftInBits(
RaiseClock(pAd, &x);
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
+#ifdef RT30xx
+ LowerClock(pAd, &x); //prevent read failed
+#endif
x &= ~(EEDI);
if(x & EEDO)
data |= 1;
+#ifndef RT30xx
LowerClock(pAd, &x);
+#endif
}
return data;
@@ -181,6 +185,15 @@ USHORT RTMP_EEPROM_READ16(
UINT32 x;
USHORT data;
+#ifdef RT30xx
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ pAd->EepromAccess = TRUE;
+ }
+//2008/09/11:KH add to support efuse<--
+//2008/09/11:KH add to support efuse-->
+{
+#endif
Offset /= 2;
// reset bits and set EECS
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
@@ -188,9 +201,17 @@ USHORT RTMP_EEPROM_READ16(
x |= EECS;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
+#ifdef RT30xx
+ // patch can not access e-Fuse issue
+ if (!IS_RT3090(pAd))
+ {
+#endif
// kick a pulse
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
+#ifdef RT30xx
+ }
+#endif
// output the read_opcode and register number in that order
ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
@@ -201,6 +222,17 @@ USHORT RTMP_EEPROM_READ16(
EEpromCleanup(pAd);
+#ifdef RT30xx
+ // Antenna and EEPROM access are both using EESK pin,
+ // Therefor we should avoid accessing EESK at the same time
+ // Then restore antenna after EEPROM access
+ if ((pAd->NicConfig2.field.AntDiversity) || (pAd->RfIcType == RFIC_3020))
+ {
+ pAd->EepromAccess = FALSE;
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+ }
+}
+#endif
return data;
} //ReadEEprom
@@ -211,6 +243,15 @@ VOID RTMP_EEPROM_WRITE16(
{
UINT32 x;
+#ifdef RT30xx
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ pAd->EepromAccess = TRUE;
+ }
+ //2008/09/11:KH add to support efuse<--
+//2008/09/11:KH add to support efuse-->
+ {
+#endif
Offset /= 2;
EWEN(pAd);
@@ -221,9 +262,17 @@ VOID RTMP_EEPROM_WRITE16(
x |= EECS;
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
+#ifdef RT30xx
+ // patch can not access e-Fuse issue
+ if (!IS_RT3090(pAd))
+ {
+#endif
// kick a pulse
RaiseClock(pAd, &x);
LowerClock(pAd, &x);
+#ifdef RT30xx
+ }
+#endif
// output the read_opcode ,register number and data in that order
ShiftOutBits(pAd, EEPROM_WRITE_OPCODE, 3);
@@ -240,5 +289,1222 @@ VOID RTMP_EEPROM_WRITE16(
EWDS(pAd);
EEpromCleanup(pAd);
+
+#ifdef RT30xx
+ // Antenna and EEPROM access are both using EESK pin,
+ // Therefor we should avoid accessing EESK at the same time
+ // Then restore antenna after EEPROM access
+ if ((pAd->NicConfig2.field.AntDiversity) || (pAd->RfIcType == RFIC_3020))
+ {
+ pAd->EepromAccess = FALSE;
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+ }
+}
+#endif
+}
+
+//2008/09/11:KH add to support efuse<--
+#ifdef RT30xx
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+UCHAR eFuseReadRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData)
+{
+ EFUSE_CTRL_STRUC eFuseCtrlStruc;
+ int i;
+ USHORT efuseDataOffset;
+ UINT32 data;
+
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
+ //Use the eeprom logical address and covert to address to block number
+ eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
+
+ //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 0.
+ eFuseCtrlStruc.field.EFSROM_MODE = 0;
+
+ //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
+ eFuseCtrlStruc.field.EFSROM_KICK = 1;
+
+ NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
+ RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
+
+ //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
+ i = 0;
+ while(i < 100)
+ {
+ //rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4);
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ {
+ break;
+ }
+ RTMPusecDelay(2);
+ i++;
+ }
+
+ //if EFSROM_AOUT is not found in physical address, write 0xffff
+ if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f)
+ {
+ for(i=0; i<Length/2; i++)
+ *(pData+2*i) = 0xffff;
+ }
+ else
+ {
+ //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x590-0x59C)
+ efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ;
+ //data hold 4 bytes data.
+ //In RTMP_IO_READ32 will automatically execute 32-bytes swapping
+ RTMP_IO_READ32(pAd, efuseDataOffset, &data);
+ //Decide the upper 2 bytes or the bottom 2 bytes.
+ // Little-endian S | S Big-endian
+ // addr 3 2 1 0 | 0 1 2 3
+ // Ori-V D C B A | A B C D
+ //After swapping
+ // D C B A | D C B A
+ //Return 2-bytes
+ //The return byte statrs from S. Therefore, the little-endian will return BA, the Big-endian will return DC.
+ //For returning the bottom 2 bytes, the Big-endian should shift right 2-bytes.
+ data = data >> (8*(Offset & 0x3));
+
+ NdisMoveMemory(pData, &data, Length);
+ }
+
+ return (UCHAR) eFuseCtrlStruc.field.EFSROM_AOUT;
+
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+VOID eFusePhysicalReadRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData)
+{
+ EFUSE_CTRL_STRUC eFuseCtrlStruc;
+ int i;
+ USHORT efuseDataOffset;
+ UINT32 data;
+
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
+ eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
+
+ //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1.
+ //Read in physical view
+ eFuseCtrlStruc.field.EFSROM_MODE = 1;
+
+ //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
+ eFuseCtrlStruc.field.EFSROM_KICK = 1;
+
+ NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
+ RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
+
+ //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
+ i = 0;
+ while(i < 100)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ break;
+ RTMPusecDelay(2);
+ i++;
+ }
+
+ //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590)
+ //Because the size of each EFUSE_DATA is 4 Bytes, the size of address of each is 2 bits.
+ //The previous 2 bits is the EFUSE_DATA number, the last 2 bits is used to decide which bytes
+ //Decide which EFUSE_DATA to read
+ //590:F E D C
+ //594:B A 9 8
+ //598:7 6 5 4
+ //59C:3 2 1 0
+ efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ;
+
+ RTMP_IO_READ32(pAd, efuseDataOffset, &data);
+
+ data = data >> (8*(Offset & 0x3));
+
+ NdisMoveMemory(pData, &data, Length);
+
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+VOID eFuseReadPhysical(
+ IN PRTMP_ADAPTER pAd,
+ IN PUSHORT lpInBuffer,
+ IN ULONG nInBufferSize,
+ OUT PUSHORT lpOutBuffer,
+ IN ULONG nOutBufferSize
+)
+{
+ USHORT* pInBuf = (USHORT*)lpInBuffer;
+ USHORT* pOutBuf = (USHORT*)lpOutBuffer;
+
+ USHORT Offset = pInBuf[0]; //addr
+ USHORT Length = pInBuf[1]; //length
+ int i;
+
+ for(i=0; i<Length; i+=2)
+ {
+ eFusePhysicalReadRegisters(pAd,Offset+i, 2, &pOutBuf[i/2]);
+ }
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NTSTATUS eFuseRead(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT PUCHAR pData,
+ IN USHORT Length)
+{
+ USHORT* pOutBuf = (USHORT*)pData;
+ NTSTATUS Status = STATUS_SUCCESS;
+ UCHAR EFSROM_AOUT;
+ int i;
+
+ for(i=0; i<Length; i+=2)
+ {
+ EFSROM_AOUT = eFuseReadRegisters(pAd, Offset+i, 2, &pOutBuf[i/2]);
+ }
+ return Status;
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+VOID eFusePhysicalWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData)
+{
+ EFUSE_CTRL_STRUC eFuseCtrlStruc;
+ int i;
+ USHORT efuseDataOffset;
+ UINT32 data, eFuseDataBuffer[4];
+
+ //Step0. Write 16-byte of data to EFUSE_DATA0-3 (0x590-0x59C), where EFUSE_DATA0 is the LSB DW, EFUSE_DATA3 is the MSB DW.
+
+ /////////////////////////////////////////////////////////////////
+ //read current values of 16-byte block
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
+ eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
+
+ //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1.
+ eFuseCtrlStruc.field.EFSROM_MODE = 1;
+
+ //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
+ eFuseCtrlStruc.field.EFSROM_KICK = 1;
+
+ NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
+ RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
+
+ //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
+ i = 0;
+ while(i < 100)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ break;
+ RTMPusecDelay(2);
+ i++;
+ }
+
+ //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590)
+ efuseDataOffset = EFUSE_DATA3;
+ for(i=0; i< 4; i++)
+ {
+ RTMP_IO_READ32(pAd, efuseDataOffset, (PUINT32) &eFuseDataBuffer[i]);
+ efuseDataOffset -= 4;
+ }
+
+ //Update the value, the offset is multiple of 2, length is 2
+ efuseDataOffset = (Offset & 0xc) >> 2;
+ data = pData[0] & 0xffff;
+ //The offset should be 0x***10 or 0x***00
+ if((Offset % 4) != 0)
+ {
+ eFuseDataBuffer[efuseDataOffset] = (eFuseDataBuffer[efuseDataOffset] & 0xffff) | (data << 16);
+ }
+ else
+ {
+ eFuseDataBuffer[efuseDataOffset] = (eFuseDataBuffer[efuseDataOffset] & 0xffff0000) | data;
+ }
+
+ efuseDataOffset = EFUSE_DATA3;
+ for(i=0; i< 4; i++)
+ {
+ RTMP_IO_WRITE32(pAd, efuseDataOffset, eFuseDataBuffer[i]);
+ efuseDataOffset -= 4;
+ }
+ /////////////////////////////////////////////////////////////////
+
+ //Step1. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
+ eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
+
+ //Step2. Write EFSROM_MODE (0x580, bit7:bit6) to 3.
+ eFuseCtrlStruc.field.EFSROM_MODE = 3;
+
+ //Step3. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical write procedure.
+ eFuseCtrlStruc.field.EFSROM_KICK = 1;
+
+ NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
+ RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
+
+ //Step4. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. It��s done.
+ i = 0;
+ while(i < 100)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ break;
+
+ RTMPusecDelay(2);
+ i++;
+ }
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NTSTATUS eFuseWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData)
+{
+ USHORT i;
+ USHORT eFuseData;
+ USHORT LogicalAddress, BlkNum = 0xffff;
+ UCHAR EFSROM_AOUT;
+
+ USHORT addr,tmpaddr, InBuf[3], tmpOffset;
+ USHORT buffer[8];
+ BOOLEAN bWriteSuccess = TRUE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters Offset=%x, pData=%x\n", Offset, *pData));
+
+ //Step 0. find the entry in the mapping table
+ //The address of EEPROM is 2-bytes alignment.
+ //The last bit is used for alignment, so it must be 0.
+ tmpOffset = Offset & 0xfffe;
+ EFSROM_AOUT = eFuseReadRegisters(pAd, tmpOffset, 2, &eFuseData);
+
+ if( EFSROM_AOUT == 0x3f)
+ { //find available logical address pointer
+ //the logical address does not exist, find an empty one
+ //from the first address of block 45=16*45=0x2d0 to the last address of block 47
+ //==>48*16-3(reserved)=2FC
+ for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
+ {
+ //Retrive the logical block nubmer form each logical address pointer
+ //It will access two logical address pointer each time.
+ eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
+ if( (LogicalAddress & 0xff) == 0)
+ {//Not used logical address pointer
+ BlkNum = i-EFUSE_USAGE_MAP_START;
+ break;
+ }
+ else if(( (LogicalAddress >> 8) & 0xff) == 0)
+ {//Not used logical address pointer
+ if (i != EFUSE_USAGE_MAP_END)
+ {
+ BlkNum = i-EFUSE_USAGE_MAP_START+1;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ BlkNum = EFSROM_AOUT;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters BlkNum = %d \n", BlkNum));
+
+ if(BlkNum == 0xffff)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n"));
+ return FALSE;
+ }
+
+ //Step 1. Save data of this block which is pointed by the avaible logical address pointer
+ // read and save the original block data
+ for(i =0; i<8; i++)
+ {
+ addr = BlkNum * 0x10 ;
+
+ InBuf[0] = addr+2*i;
+ InBuf[1] = 2;
+ InBuf[2] = 0x0;
+
+ eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
+
+ buffer[i] = InBuf[2];
+ }
+
+ //Step 2. Update the data in buffer, and write the data to Efuse
+ buffer[ (Offset >> 1) % 8] = pData[0];
+
+ do
+ {
+ //Step 3. Write the data to Efuse
+ if(!bWriteSuccess)
+ {
+ for(i =0; i<8; i++)
+ {
+ addr = BlkNum * 0x10 ;
+
+ InBuf[0] = addr+2*i;
+ InBuf[1] = 2;
+ InBuf[2] = buffer[i];
+
+ eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2);
+ }
+ }
+ else
+ {
+ addr = BlkNum * 0x10 ;
+
+ InBuf[0] = addr+(Offset % 16);
+ InBuf[1] = 2;
+ InBuf[2] = pData[0];
+
+ eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2);
+ }
+
+ //Step 4. Write mapping table
+ addr = EFUSE_USAGE_MAP_START+BlkNum;
+
+ tmpaddr = addr;
+
+ if(addr % 2 != 0)
+ addr = addr -1;
+ InBuf[0] = addr;
+ InBuf[1] = 2;
+
+ //convert the address from 10 to 8 bit ( bit7, 6 = parity and bit5 ~ 0 = bit9~4), and write to logical map entry
+ tmpOffset = Offset;
+ tmpOffset >>= 4;
+ tmpOffset |= ((~((tmpOffset & 0x01) ^ ( tmpOffset >> 1 & 0x01) ^ (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01))) << 6) & 0x40;
+ tmpOffset |= ((~( (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01) ^ (tmpOffset >> 4 & 0x01) ^ ( tmpOffset >> 5 & 0x01))) << 7) & 0x80;
+
+ // write the logical address
+ if(tmpaddr%2 != 0)
+ InBuf[2] = tmpOffset<<8;
+ else
+ InBuf[2] = tmpOffset;
+
+ eFuseWritePhysical(pAd,&InBuf[0], 6, NULL, 0);
+
+ //Step 5. Compare data if not the same, invalidate the mapping entry, then re-write the data until E-fuse is exhausted
+ bWriteSuccess = TRUE;
+ for(i =0; i<8; i++)
+ {
+ addr = BlkNum * 0x10 ;
+
+ InBuf[0] = addr+2*i;
+ InBuf[1] = 2;
+ InBuf[2] = 0x0;
+
+ eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
+
+ if(buffer[i] != InBuf[2])
+ {
+ bWriteSuccess = FALSE;
+ break;
+ }
+ }
+
+ //Step 6. invlidate mapping entry and find a free mapping entry if not succeed
+ if (!bWriteSuccess)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Not bWriteSuccess BlkNum = %d\n", BlkNum));
+
+ // the offset of current mapping entry
+ addr = EFUSE_USAGE_MAP_START+BlkNum;
+
+ //find a new mapping entry
+ BlkNum = 0xffff;
+ for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
+ {
+ eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
+ if( (LogicalAddress & 0xff) == 0)
+ {
+ BlkNum = i-EFUSE_USAGE_MAP_START;
+ break;
+ }
+ else if(( (LogicalAddress >> 8) & 0xff) == 0)
+ {
+ if (i != EFUSE_USAGE_MAP_END)
+ {
+ BlkNum = i+1-EFUSE_USAGE_MAP_START;
+ }
+ break;
+ }
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("Not bWriteSuccess new BlkNum = %d\n", BlkNum));
+ if(BlkNum == 0xffff)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n"));
+ return FALSE;
+ }
+
+ //invalidate the original mapping entry if new entry is not found
+ tmpaddr = addr;
+
+ if(addr % 2 != 0)
+ addr = addr -1;
+ InBuf[0] = addr;
+ InBuf[1] = 2;
+
+ eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
+
+ // write the logical address
+ if(tmpaddr%2 != 0)
+ {
+ // Invalidate the high byte
+ for (i=8; i<15; i++)
+ {
+ if( ( (InBuf[2] >> i) & 0x01) == 0)
+ {
+ InBuf[2] |= (0x1 <<i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ // invalidate the low byte
+ for (i=0; i<8; i++)
+ {
+ if( ( (InBuf[2] >> i) & 0x01) == 0)
+ {
+ InBuf[2] |= (0x1 <<i);
+ break;
+ }
+ }
+ }
+ eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 0);
+ }
+ }
+ while(!bWriteSuccess);
+
+ return TRUE;
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+VOID eFuseWritePhysical(
+ IN PRTMP_ADAPTER pAd,
+ PUSHORT lpInBuffer,
+ ULONG nInBufferSize,
+ PUCHAR lpOutBuffer,
+ ULONG nOutBufferSize
+)
+{
+ USHORT* pInBuf = (USHORT*)lpInBuffer;
+ int i;
+ //USHORT* pOutBuf = (USHORT*)ioBuffer;
+
+ USHORT Offset = pInBuf[0]; //addr
+ USHORT Length = pInBuf[1]; //length
+ USHORT* pValueX = &pInBuf[2]; //value ...
+ // Little-endian S | S Big-endian
+ // addr 3 2 1 0 | 0 1 2 3
+ // Ori-V D C B A | A B C D
+ //After swapping
+ // D C B A | D C B A
+ //Both the little and big-endian use the same sequence to write data.
+ //Therefore, we only need swap data when read the data.
+ for(i=0; i<Length; i+=2)
+ {
+ eFusePhysicalWriteRegisters(pAd, Offset+i, 2, &pValueX[i/2]);
+ }
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NTSTATUS eFuseWrite(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN PUCHAR pData,
+ IN USHORT length)
+{
+ int i;
+
+ USHORT* pValueX = (PUSHORT) pData; //value ...
+ //The input value=3070 will be stored as following
+ // Little-endian S | S Big-endian
+ // addr 1 0 | 0 1
+ // Ori-V 30 70 | 30 70
+ //After swapping
+ // 30 70 | 70 30
+ //Casting
+ // 3070 | 7030 (x)
+ //The swapping should be removed for big-endian
+ for(i=0; i<length; i+=2)
+ {
+ eFuseWriteRegisters(pAd, Offset+i, 2, &pValueX[i/2]);
+ }
+
+ return TRUE;
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+INT set_eFuseGetFreeBlockCount_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg)
+{
+ USHORT i;
+ USHORT LogicalAddress;
+ USHORT efusefreenum=0;
+ if(!pAd->bUseEfuse)
+ return FALSE;
+ for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i+=2)
+ {
+ eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
+ if( (LogicalAddress & 0xff) == 0)
+ {
+ efusefreenum= (UCHAR) (EFUSE_USAGE_MAP_END-i+1);
+ break;
+ }
+ else if(( (LogicalAddress >> 8) & 0xff) == 0)
+ {
+ efusefreenum = (UCHAR) (EFUSE_USAGE_MAP_END-i);
+ break;
+ }
+
+ if(i == EFUSE_USAGE_MAP_END)
+ efusefreenum = 0;
+ }
+ printk("efuseFreeNumber is %d\n",efusefreenum);
+ return TRUE;
+}
+INT set_eFusedump_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg)
+{
+USHORT InBuf[3];
+ INT i=0;
+ if(!pAd->bUseEfuse)
+ return FALSE;
+ for(i =0; i<EFUSE_USAGE_MAP_END/2; i++)
+ {
+ InBuf[0] = 2*i;
+ InBuf[1] = 2;
+ InBuf[2] = 0x0;
+
+ eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
+ if(i%4==0)
+ printk("\nBlock %x:",i/8);
+ printk("%04x ",InBuf[2]);
+ }
+ return TRUE;
+}
+INT set_eFuseLoadFromBin_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg)
+{
+ CHAR *src;
+ struct file *srcf;
+ INT retval, orgfsuid, orgfsgid;
+ mm_segment_t orgfs;
+ UCHAR *buffer;
+ UCHAR BinFileSize=0;
+ INT i = 0,j=0,k=1;
+ USHORT *PDATA;
+ USHORT DATA;
+ BinFileSize=strlen("RT30xxEEPROM.bin");
+ src = kmalloc(128, MEM_ALLOC_FLAG);
+ NdisZeroMemory(src, 128);
+
+ if(strlen(arg)>0)
+ {
+
+ NdisMoveMemory(src, arg, strlen(arg));
+ }
+
+ else
+ {
+
+ NdisMoveMemory(src, "RT30xxEEPROM.bin", BinFileSize);
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("FileName=%s\n",src));
+ buffer = kmalloc(MAX_EEPROM_BIN_FILE_SIZE, MEM_ALLOC_FLAG);
+
+ if(buffer == NULL)
+ {
+ kfree(src);
+ return FALSE;
+}
+ PDATA=kmalloc(sizeof(USHORT)*8,MEM_ALLOC_FLAG);
+
+ if(PDATA==NULL)
+ {
+ kfree(src);
+
+ kfree(buffer);
+ return FALSE;
+ }
+ /* Don't change to uid 0, let the file be opened as the "normal" user */
+#if 0
+ orgfsuid = current->fsuid;
+ orgfsgid = current->fsgid;
+ current->fsuid=current->fsgid = 0;
+#endif
+ orgfs = get_fs();
+ set_fs(KERNEL_DS);
+
+ if (src && *src)
+ {
+ srcf = filp_open(src, O_RDONLY, 0);
+ if (IS_ERR(srcf))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
+ return FALSE;
+ }
+ else
+ {
+ // The object must have a read method
+ if (srcf->f_op && srcf->f_op->read)
+ {
+ memset(buffer, 0x00, MAX_EEPROM_BIN_FILE_SIZE);
+ while(srcf->f_op->read(srcf, &buffer[i], 1, &srcf->f_pos)==1)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[i]));
+ if((i+1)%8==0)
+ DBGPRINT(RT_DEBUG_TRACE, ("\n"));
+ i++;
+ if(i>=MAX_EEPROM_BIN_FILE_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld reading %s, The file is too large[1024]\n", -PTR_ERR(srcf),src));
+ kfree(PDATA);
+ kfree(buffer);
+ kfree(src);
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error!! System doest not support read function\n"));
+ kfree(PDATA);
+ kfree(buffer);
+ kfree(src);
+ return FALSE;
+ }
+ }
+
+
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error src or srcf is null\n"));
+ kfree(PDATA);
+ kfree(buffer);
+ return FALSE;
+
+ }
+
+
+ retval=filp_close(srcf,NULL);
+
+ if (retval)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
+ }
+ set_fs(orgfs);
+#if 0
+ current->fsuid = orgfsuid;
+ current->fsgid = orgfsgid;
+#endif
+ for(j=0;j<i;j++)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[j]));
+ if((j+1)%2==0)
+ PDATA[j/2%8]=((buffer[j]<<8)&0xff00)|(buffer[j-1]&0xff);
+ if(j%16==0)
+ {
+ k=buffer[j];
+ }
+ else
+ {
+ k&=buffer[j];
+ if((j+1)%16==0)
+ {
+
+ DBGPRINT(RT_DEBUG_TRACE, (" result=%02X,blk=%02x\n",k,j/16));
+
+ if(k!=0xff)
+ eFuseWriteRegistersFromBin(pAd,(USHORT)j-15, 16, PDATA);
+ else
+ {
+ if(eFuseReadRegisters(pAd,j, 2,(PUSHORT)&DATA)!=0x3f)
+ eFuseWriteRegistersFromBin(pAd,(USHORT)j-15, 16, PDATA);
+ }
+ /*
+ for(l=0;l<8;l++)
+ printk("%04x ",PDATA[l]);
+ printk("\n");
+ */
+ NdisZeroMemory(PDATA,16);
+
+
+ }
+ }
+
+
+ }
+
+
+ kfree(PDATA);
+ kfree(buffer);
+ kfree(src);
+ return TRUE;
+}
+NTSTATUS eFuseWriteRegistersFromBin(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData)
+{
+ USHORT i;
+ USHORT eFuseData;
+ USHORT LogicalAddress, BlkNum = 0xffff;
+ UCHAR EFSROM_AOUT,Loop=0;
+ EFUSE_CTRL_STRUC eFuseCtrlStruc;
+ USHORT efuseDataOffset;
+ UINT32 data,tempbuffer;
+ USHORT addr,tmpaddr, InBuf[3], tmpOffset;
+ UINT32 buffer[4];
+ BOOLEAN bWriteSuccess = TRUE;
+ BOOLEAN bNotWrite=TRUE;
+ BOOLEAN bAllocateNewBlk=TRUE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin Offset=%x, pData=%04x:%04x:%04x:%04x\n", Offset, *pData,*(pData+1),*(pData+2),*(pData+3)));
+
+ do
+ {
+ //Step 0. find the entry in the mapping table
+ //The address of EEPROM is 2-bytes alignment.
+ //The last bit is used for alignment, so it must be 0.
+ Loop++;
+ tmpOffset = Offset & 0xfffe;
+ EFSROM_AOUT = eFuseReadRegisters(pAd, tmpOffset, 2, &eFuseData);
+
+ if( EFSROM_AOUT == 0x3f)
+ { //find available logical address pointer
+ //the logical address does not exist, find an empty one
+ //from the first address of block 45=16*45=0x2d0 to the last address of block 47
+ //==>48*16-3(reserved)=2FC
+ bAllocateNewBlk=TRUE;
+ for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
+ {
+ //Retrive the logical block nubmer form each logical address pointer
+ //It will access two logical address pointer each time.
+ eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
+ if( (LogicalAddress & 0xff) == 0)
+ {//Not used logical address pointer
+ BlkNum = i-EFUSE_USAGE_MAP_START;
+ break;
+ }
+ else if(( (LogicalAddress >> 8) & 0xff) == 0)
+ {//Not used logical address pointer
+ if (i != EFUSE_USAGE_MAP_END)
+ {
+ BlkNum = i-EFUSE_USAGE_MAP_START+1;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ bAllocateNewBlk=FALSE;
+ BlkNum = EFSROM_AOUT;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters BlkNum = %d \n", BlkNum));
+
+ if(BlkNum == 0xffff)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n"));
+ return FALSE;
+ }
+ //Step 1.1.0
+ //If the block is not existing in mapping table, create one
+ //and write down the 16-bytes data to the new block
+ if(bAllocateNewBlk)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Allocate New Blk\n"));
+ efuseDataOffset = EFUSE_DATA3;
+ for(i=0; i< 4; i++)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Allocate New Blk, Data%d=%04x%04x\n",3-i,pData[2*i+1],pData[2*i]));
+ tempbuffer=((pData[2*i+1]<<16)&0xffff0000)|pData[2*i];
+
+
+ RTMP_IO_WRITE32(pAd, efuseDataOffset,tempbuffer);
+ efuseDataOffset -= 4;
+
+ }
+ /////////////////////////////////////////////////////////////////
+
+ //Step1.1.1. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
+ eFuseCtrlStruc.field.EFSROM_AIN = BlkNum* 0x10 ;
+
+ //Step1.1.2. Write EFSROM_MODE (0x580, bit7:bit6) to 3.
+ eFuseCtrlStruc.field.EFSROM_MODE = 3;
+
+ //Step1.1.3. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical write procedure.
+ eFuseCtrlStruc.field.EFSROM_KICK = 1;
+
+ NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
+
+ RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
+
+ //Step1.1.4. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. It��s done.
+ i = 0;
+ while(i < 100)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ break;
+
+ RTMPusecDelay(2);
+ i++;
+ }
+
+ }
+ else
+ { //Step1.2.
+ //If the same logical number is existing, check if the writting data and the data
+ //saving in this block are the same.
+ /////////////////////////////////////////////////////////////////
+ //read current values of 16-byte block
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ //Step1.2.0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
+ eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
+
+ //Step1.2.1. Write EFSROM_MODE (0x580, bit7:bit6) to 1.
+ eFuseCtrlStruc.field.EFSROM_MODE = 0;
+
+ //Step1.2.2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
+ eFuseCtrlStruc.field.EFSROM_KICK = 1;
+
+ NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
+ RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
+
+ //Step1.2.3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
+ i = 0;
+ while(i < 100)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
+
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ break;
+ RTMPusecDelay(2);
+ i++;
+ }
+
+ //Step1.2.4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590)
+ efuseDataOffset = EFUSE_DATA3;
+ for(i=0; i< 4; i++)
+ {
+ RTMP_IO_READ32(pAd, efuseDataOffset, (PUINT32) &buffer[i]);
+ efuseDataOffset -= 4;
+ }
+ //Step1.2.5. Check if the data of efuse and the writing data are the same.
+ for(i =0; i<4; i++)
+ {
+ tempbuffer=((pData[2*i+1]<<16)&0xffff0000)|pData[2*i];
+ DBGPRINT(RT_DEBUG_TRACE, ("buffer[%d]=%x,pData[%d]=%x,pData[%d]=%x,tempbuffer=%x\n",i,buffer[i],2*i,pData[2*i],2*i+1,pData[2*i+1],tempbuffer));
+
+ if(((buffer[i]&0xffff0000)==(pData[2*i+1]<<16))&&((buffer[i]&0xffff)==pData[2*i]))
+ bNotWrite&=TRUE;
+ else
+ {
+ bNotWrite&=FALSE;
+ break;
+ }
+ }
+ if(!bNotWrite)
+ {
+ printk("The data is not the same\n");
+
+ for(i =0; i<8; i++)
+ {
+ addr = BlkNum * 0x10 ;
+
+ InBuf[0] = addr+2*i;
+ InBuf[1] = 2;
+ InBuf[2] = pData[i];
+
+ eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2);
+ }
+
+ }
+ else
+ return TRUE;
+ }
+
+
+
+ //Step 2. Write mapping table
+ addr = EFUSE_USAGE_MAP_START+BlkNum;
+
+ tmpaddr = addr;
+
+ if(addr % 2 != 0)
+ addr = addr -1;
+ InBuf[0] = addr;
+ InBuf[1] = 2;
+
+ //convert the address from 10 to 8 bit ( bit7, 6 = parity and bit5 ~ 0 = bit9~4), and write to logical map entry
+ tmpOffset = Offset;
+ tmpOffset >>= 4;
+ tmpOffset |= ((~((tmpOffset & 0x01) ^ ( tmpOffset >> 1 & 0x01) ^ (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01))) << 6) & 0x40;
+ tmpOffset |= ((~( (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01) ^ (tmpOffset >> 4 & 0x01) ^ ( tmpOffset >> 5 & 0x01))) << 7) & 0x80;
+
+ // write the logical address
+ if(tmpaddr%2 != 0)
+ InBuf[2] = tmpOffset<<8;
+ else
+ InBuf[2] = tmpOffset;
+
+ eFuseWritePhysical(pAd,&InBuf[0], 6, NULL, 0);
+
+ //Step 3. Compare data if not the same, invalidate the mapping entry, then re-write the data until E-fuse is exhausted
+ bWriteSuccess = TRUE;
+ for(i =0; i<8; i++)
+ {
+ addr = BlkNum * 0x10 ;
+
+ InBuf[0] = addr+2*i;
+ InBuf[1] = 2;
+ InBuf[2] = 0x0;
+
+ eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
+ DBGPRINT(RT_DEBUG_TRACE, ("addr=%x, buffer[i]=%x,InBuf[2]=%x\n",InBuf[0],pData[i],InBuf[2]));
+ if(pData[i] != InBuf[2])
+ {
+ bWriteSuccess = FALSE;
+ break;
+ }
+ }
+
+ //Step 4. invlidate mapping entry and find a free mapping entry if not succeed
+
+ if (!bWriteSuccess&&Loop<2)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin::Not bWriteSuccess BlkNum = %d\n", BlkNum));
+
+ // the offset of current mapping entry
+ addr = EFUSE_USAGE_MAP_START+BlkNum;
+
+ //find a new mapping entry
+ BlkNum = 0xffff;
+ for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
+ {
+ eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
+ if( (LogicalAddress & 0xff) == 0)
+ {
+ BlkNum = i-EFUSE_USAGE_MAP_START;
+ break;
+ }
+ else if(( (LogicalAddress >> 8) & 0xff) == 0)
+ {
+ if (i != EFUSE_USAGE_MAP_END)
+ {
+ BlkNum = i+1-EFUSE_USAGE_MAP_START;
+ }
+ break;
+ }
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin::Not bWriteSuccess new BlkNum = %d\n", BlkNum));
+ if(BlkNum == 0xffff)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin: out of free E-fuse space!!!\n"));
+ return FALSE;
+ }
+
+ //invalidate the original mapping entry if new entry is not found
+ tmpaddr = addr;
+
+ if(addr % 2 != 0)
+ addr = addr -1;
+ InBuf[0] = addr;
+ InBuf[1] = 2;
+
+ eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
+
+ // write the logical address
+ if(tmpaddr%2 != 0)
+ {
+ // Invalidate the high byte
+ for (i=8; i<15; i++)
+ {
+ if( ( (InBuf[2] >> i) & 0x01) == 0)
+ {
+ InBuf[2] |= (0x1 <<i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ // invalidate the low byte
+ for (i=0; i<8; i++)
+ {
+ if( ( (InBuf[2] >> i) & 0x01) == 0)
+ {
+ InBuf[2] |= (0x1 <<i);
+ break;
+ }
+ }
+ }
+ eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 0);
+ }
+
+ }
+ while(!bWriteSuccess&&Loop<2);
+
+ return TRUE;
}
+#endif // RT30xx //
+//2008/09/11:KH add to support efuse-->
diff --git a/drivers/staging/rt2860/common/md5.c b/drivers/staging/rt2860/common/md5.c
index 774776b4b8c3..ad883ca2ffc8 100644
--- a/drivers/staging/rt2860/common/md5.c
+++ b/drivers/staging/rt2860/common/md5.c
@@ -131,19 +131,7 @@ void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
MD5Final(mac, &context); /* finish up 2nd pass */
}
-#ifndef RT_BIG_ENDIAN
#define byteReverse(buf, len) /* Nothing */
-#else
-void byteReverse(unsigned char *buf, unsigned longs);
-void byteReverse(unsigned char *buf, unsigned longs)
-{
- do {
- *(UINT32 *)buf = SWAP32(*(UINT32 *)buf);
- buf += 4;
- } while (--longs);
-}
-#endif
-
/* ========================== MD5 implementation =========================== */
// four base functions for MD5
diff --git a/drivers/staging/rt2860/common/mlme.c b/drivers/staging/rt2860/common/mlme.c
index c00f9ab9c46c..e9e69c539e6f 100644
--- a/drivers/staging/rt2860/common/mlme.c
+++ b/drivers/staging/rt2860/common/mlme.c
@@ -50,11 +50,7 @@ UCHAR Ccx2QosInfo[] = {0x00, 0x40, 0x96, 0x04};
UCHAR RALINK_OUI[] = {0x00, 0x0c, 0x43};
UCHAR BROADCOM_OUI[] = {0x00, 0x90, 0x4c};
UCHAR WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04};
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
UCHAR PRE_N_HT_OUI[] = {0x00, 0x90, 0x4c};
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
UCHAR RateSwitchTable[] = {
// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
@@ -130,7 +126,6 @@ UCHAR RateSwitchTable11G[] = {
0x07, 0x10, 7, 10, 13,
};
-#ifdef DOT11_N_SUPPORT
UCHAR RateSwitchTable11N1S[] = {
// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
0x09, 0x00, 0, 0, 0, // Initial used item after association
@@ -287,7 +282,6 @@ UCHAR RateSwitchTable11BGN3SForABand[] = { // 3*3
0x0a, 0x20, 23, 8, 25,
0x0b, 0x22, 23, 8, 25,
};
-#endif // DOT11_N_SUPPORT //
PUCHAR ReasonString[] = {
/* 0 */ "Reserved",
@@ -334,14 +328,9 @@ USHORT RateIdTo500Kbps[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144,
UCHAR SsidIe = IE_SSID;
UCHAR SupRateIe = IE_SUPP_RATES;
UCHAR ExtRateIe = IE_EXT_SUPP_RATES;
-#ifdef DOT11_N_SUPPORT
UCHAR HtCapIe = IE_HT_CAP;
UCHAR AddHtInfoIe = IE_ADD_HT;
UCHAR NewExtChanIe = IE_SECONDARY_CH_OFFSET;
-#ifdef DOT11N_DRAFT3
-UCHAR ExtHtCapIe = IE_EXT_CAPABILITY;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
UCHAR ErpIe = IE_ERP;
UCHAR DsIe = IE_DS_PARM;
UCHAR TimIe = IE_TIM;
@@ -349,6 +338,9 @@ UCHAR WpaIe = IE_WPA;
UCHAR Wpa2Ie = IE_WPA2;
UCHAR IbssIe = IE_IBSS_PARM;
UCHAR Ccx2Ie = IE_CCX_V2;
+#ifdef RT2870
+UCHAR WapiIe = IE_WAPI;
+#endif
extern UCHAR WPA_OUI[];
@@ -457,7 +449,13 @@ FREQUENCY_ITEM FreqItems3020[] =
{13, 247, 2, 2},
{14, 248, 2, 4},
};
+#ifndef RT30xx
#define NUM_OF_3020_CHNL (sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM))
+#endif
+#ifdef RT30xx
+//2008/07/10:KH Modified to share this variable
+UCHAR NUM_OF_3020_CHNL=(sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM));
+#endif
/*
==========================================================================
@@ -488,8 +486,6 @@ NDIS_STATUS MlmeInit(
pAd->Mlme.bRunning = FALSE;
NdisAllocateSpinLock(&pAd->Mlme.TaskLock);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
BssTableInit(&pAd->ScanTab);
@@ -501,18 +497,10 @@ NDIS_STATUS MlmeInit(
WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc);
AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);
-#ifdef QOS_DLS_SUPPORT
- DlsStateMachineInit(pAd, &pAd->Mlme.DlsMachine, pAd->Mlme.DlsFunc);
-#endif // QOS_DLS_SUPPORT //
-
-
// Since we are using switch/case to implement it, the init is different from the above
// state machine init
MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
}
-#endif // CONFIG_STA_SUPPORT //
-
-
ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine, pAd->Mlme.ActFunc);
@@ -525,9 +513,7 @@ NDIS_STATUS MlmeInit(
// software-based RX Antenna diversity
RTMPInitTimer(pAd, &pAd->Mlme.RxAntEvalTimer, GET_TIMER_FUNCTION(AsicRxAntEvalTimeout), pAd, FALSE);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+#ifdef RT2860
{
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
@@ -536,8 +522,7 @@ NDIS_STATUS MlmeInit(
RTMPInitTimer(pAd, &pAd->Mlme.RadioOnOffTimer, GET_TIMER_FUNCTION(RadioOnExec), pAd, FALSE);
}
}
-#endif // CONFIG_STA_SUPPORT //
-
+#endif
} while (FALSE);
DBGPRINT(RT_DEBUG_TRACE, ("<-- MLME Initialize\n"));
@@ -563,9 +548,6 @@ VOID MlmeHandler(
IN PRTMP_ADAPTER pAd)
{
MLME_QUEUE_ELEM *Elem = NULL;
-#ifdef APCLI_SUPPORT
- SHORT apcliIfIndex;
-#endif
// Only accept MLME and Frame from peer side, no other (control/data) frame should
// get into this state machine
@@ -592,23 +574,24 @@ VOID MlmeHandler(
break;
}
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now in MlmeHandler\n"));
- break;
- }
-#endif // RALINK_ATE //
-
//From message type, determine which state machine I should drive
if (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
{
+#ifdef RT2870
+ if (Elem->MsgType == MT2_RESET_CONF)
+ {
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! reset MLME state machine !!!\n"));
+ MlmeRestartStateMachine(pAd);
+ Elem->Occupied = FALSE;
+ Elem->MsgLen = 0;
+ continue;
+ }
+#endif // RT2870 //
// if dequeue success
switch (Elem->Machine)
{
// STA state machines
-#ifdef CONFIG_STA_SUPPORT
case ASSOC_STATE_MACHINE:
StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem);
break;
@@ -627,22 +610,9 @@ VOID MlmeHandler(
case WPA_PSK_STATE_MACHINE:
StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);
break;
-#ifdef LEAP_SUPPORT
- case LEAP_STATE_MACHINE:
- LeapMachinePerformAction(pAd, &pAd->Mlme.LeapMachine, Elem);
- break;
-#endif
case AIRONET_STATE_MACHINE:
StateMachinePerformAction(pAd, &pAd->Mlme.AironetMachine, Elem);
break;
-
-#ifdef QOS_DLS_SUPPORT
- case DLS_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.DlsMachine, Elem);
- break;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
case ACTION_STATE_MACHINE:
StateMachinePerformAction(pAd, &pAd->Mlme.ActMachine, Elem);
break;
@@ -687,6 +657,9 @@ VOID MlmeHalt(
IN PRTMP_ADAPTER pAd)
{
BOOLEAN Cancelled;
+#ifdef RT3070
+ UINT32 TxPinCfg = 0x00050F0F;
+#endif // RT3070 //
DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeHalt\n"));
@@ -696,12 +669,7 @@ VOID MlmeHalt(
AsicDisableSync(pAd);
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
-#ifdef QOS_DLS_SUPPORT
- UCHAR i;
-#endif // QOS_DLS_SUPPORT //
// Cancel pending timers
RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
@@ -709,20 +677,14 @@ VOID MlmeHalt(
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
}
-
-#ifdef QOS_DLS_SUPPORT
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
- }
-#endif // QOS_DLS_SUPPORT //
+#endif
}
-#endif // CONFIG_STA_SUPPORT //
RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
RTMPCancelTimer(&pAd->Mlme.RxAntEvalTimer, &Cancelled);
@@ -734,6 +696,27 @@ VOID MlmeHalt(
// Set LED
RTMPSetLED(pAd, LED_HALT);
RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
+#ifdef RT2870
+ {
+ LED_CFG_STRUC LedCfg;
+ RTMP_IO_READ32(pAd, LED_CFG, &LedCfg.word);
+ LedCfg.field.LedPolar = 0;
+ LedCfg.field.RLedMode = 0;
+ LedCfg.field.GLedMode = 0;
+ LedCfg.field.YLedMode = 0;
+ RTMP_IO_WRITE32(pAd, LED_CFG, LedCfg.word);
+ }
+#endif // RT2870 //
+#ifdef RT3070
+ //
+ // Turn off LNA_PE
+ //
+ if (IS_RT3070(pAd) || IS_RT3071(pAd))
+ {
+ TxPinCfg &= 0xFFFFF0F0;
+ RTUSBWriteMACRegister(pAd, TX_PIN_CFG, TxPinCfg);
+ }
+#endif // RT3070 //
}
RTMPusecDelay(5000); // 5 msec to gurantee Ant Diversity timer canceled
@@ -804,6 +787,7 @@ VOID MlmePeriodicExec(
ULONG TxTotalCnt;
PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
+#ifdef RT2860
//Baron 2008/07/10
//printk("Baron_Test:\t%s", RTMPGetRalinkEncryModeStr(pAd->StaCfg.WepStatus));
//If the STA security setting is OPEN or WEP, pAd->StaCfg.WpaSupplicantUP = 0.
@@ -817,8 +801,6 @@ VOID MlmePeriodicExec(
pAd->StaCfg.WpaSupplicantUP = 1;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// If Hardware controlled Radio enabled, we have to check GPIO pin2 every 2 second.
// Move code to here, because following code will return when radio is off
@@ -858,7 +840,7 @@ VOID MlmePeriodicExec(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
+#endif /* RT2860 */
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
@@ -868,7 +850,7 @@ VOID MlmePeriodicExec(
fRTMP_ADAPTER_RESET_IN_PROGRESS))))
return;
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+#ifdef RT2860
{
if ((pAd->RalinkCounters.LastReceivedByteCount == pAd->RalinkCounters.ReceivedByteCount) && (pAd->StaCfg.bRadio == TRUE))
{
@@ -906,23 +888,9 @@ VOID MlmePeriodicExec(
AsicResetFromDMABusy(pAd);
}
}
-
+#endif /* RT2860 */
RT28XX_MLME_PRE_SANITY_CHECK(pAd);
-#ifdef RALINK_ATE
- /* Do not show RSSI until "Normal 1 second Mlme PeriodicExec". */
- if (ATE_ON(pAd))
- {
- if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE != (MLME_TASK_EXEC_MULTIPLE - 1))
- {
- pAd->Mlme.PeriodicRound ++;
- return;
- }
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Do nothing if monitor mode is on
if (MONITOR_ON(pAd))
@@ -947,26 +915,26 @@ VOID MlmePeriodicExec(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
pAd->bUpdateBcnCntDone = FALSE;
// RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3);
pAd->Mlme.PeriodicRound ++;
+#ifdef RT3070
+ // execute every 100ms, update the Tx FIFO Cnt for update Tx Rate.
+ NICUpdateFifoStaCounters(pAd);
+#endif // RT3070 //
// execute every 500ms
if ((pAd->Mlme.PeriodicRound % 5 == 0) && RTMPAutoRateSwitchCheck(pAd)/*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))*/)
{
-#ifdef CONFIG_STA_SUPPORT
// perform dynamic tx rate switching based on past TX history
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
)
&& (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)))
MlmeDynamicTxRateSwitching(pAd);
}
-#endif // CONFIG_STA_SUPPORT //
}
// Normal 1 second Mlme PeriodicExec.
@@ -974,30 +942,6 @@ VOID MlmePeriodicExec(
{
pAd->Mlme.OneSecPeriodicRound ++;
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- /* request from Baron : move this routine from later to here */
- /* for showing Rx error count in ATE RXFRAME */
- NICUpdateRawCounters(pAd);
- if (pAd->ate.bRxFer == 1)
- {
- pAd->ate.RxTotalCnt += pAd->ate.RxCntPerSec;
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx packet cnt = %d/%d\n", pAd->ate.RxCntPerSec, pAd->ate.RxTotalCnt);
- pAd->ate.RxCntPerSec = 0;
-
- if (pAd->ate.RxAntennaSel == 0)
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx AvgRssi0=%d, AvgRssi1=%d, AvgRssi2=%d\n\n",
- pAd->ate.AvgRssi0, pAd->ate.AvgRssi1, pAd->ate.AvgRssi2);
- else
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx AvgRssi=%d\n\n", pAd->ate.AvgRssi0);
- }
- MlmeResetRalinkCounters(pAd);
- return;
- }
-#endif // RALINK_ATE //
-
-
if (rx_Total)
{
@@ -1029,12 +973,12 @@ VOID MlmePeriodicExec(
// the dynamic tuning mechanism below are based on most up-to-date information
NICUpdateRawCounters(pAd);
+#ifdef RT2870
+ RT2870_WatchDog(pAd);
+#endif // RT2870 //
-#ifdef DOT11_N_SUPPORT
// Need statistics after read counter. So put after NICUpdateRawCounters
ORIBATimerTimeout(pAd);
-#endif // DOT11_N_SUPPORT //
-
// The time period for checking antenna is according to traffic
if (pAd->Mlme.bEnableAutoAntennaCheck)
@@ -1043,6 +987,7 @@ VOID MlmePeriodicExec(
pAd->RalinkCounters.OneSecTxRetryOkCount +
pAd->RalinkCounters.OneSecTxFailCount;
+ // dynamic adjust antenna evaluation period according to the traffic
if (TxTotalCnt > 50)
{
if (pAd->Mlme.OneSecPeriodicRound % 10 == 0)
@@ -1059,17 +1004,14 @@ VOID MlmePeriodicExec(
}
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- STAMlmePeriodicExec(pAd);
-#endif // CONFIG_STA_SUPPORT //
+ STAMlmePeriodicExec(pAd);
MlmeResetRalinkCounters(pAd);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
+#ifdef RT2860
if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->bPCIclkOff == FALSE))
+#endif
{
// When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock
// and sending CTS-to-self over and over.
@@ -1091,41 +1033,32 @@ VOID MlmePeriodicExec(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
RT28XX_MLME_HANDLER(pAd);
}
-
pAd->bUpdateBcnCntDone = FALSE;
}
-#ifdef CONFIG_STA_SUPPORT
VOID STAMlmePeriodicExec(
PRTMP_ADAPTER pAd)
{
+#ifdef RT2860
ULONG TxTotalCnt;
+#endif
+#ifdef RT2870
+ ULONG TxTotalCnt;
+ int i;
+#endif
-//
-// We return here in ATE mode, because the statistics
-// that ATE needs are not collected via this routine.
-//
-#ifdef RALINK_ATE
- // It is supposed that we will never reach here in ATE mode.
- ASSERT(!(ATE_ON(pAd)));
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)
-#endif // WPA_SUPPLICANT_SUPPORT //
{
// WPA MIC error should block association attempt for 60 seconds
if (pAd->StaCfg.bBlockAssoc && (pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ) < pAd->Mlme.Now32))
pAd->StaCfg.bBlockAssoc = FALSE;
}
+#ifdef RT2860
//Baron 2008/07/10
//printk("Baron_Test:\t%s", RTMPGetRalinkEncryModeStr(pAd->StaCfg.WepStatus));
//If the STA security setting is OPEN or WEP, pAd->StaCfg.WpaSupplicantUP = 0.
@@ -1138,6 +1071,7 @@ VOID STAMlmePeriodicExec(
{
pAd->StaCfg.WpaSupplicantUP = 1;
}
+#endif
if ((pAd->PreMediaState != pAd->IndicateMediaState) && (pAd->CommonCfg.bWirelessEvent))
{
@@ -1148,6 +1082,7 @@ VOID STAMlmePeriodicExec(
pAd->PreMediaState = pAd->IndicateMediaState;
}
+#ifdef RT2860
if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd)) &&
(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
(pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE) &&
@@ -1157,6 +1092,7 @@ VOID STAMlmePeriodicExec(
{
RT28xxPciAsicRadioOff(pAd, GUI_IDLE_POWER_SAVE, 0);
}
+#endif
@@ -1179,11 +1115,6 @@ VOID STAMlmePeriodicExec(
if (INFRA_ON(pAd))
{
-#ifdef QOS_DLS_SUPPORT
- // Check DLS time out, then tear down those session
- RTMPCheckDLSTimeOut(pAd);
-#endif // QOS_DLS_SUPPORT //
-
// Is PSM bit consistent with user power management policy?
// This is the only place that will set PSM bit ON.
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
@@ -1228,26 +1159,11 @@ VOID STAMlmePeriodicExec(
// Lost AP, send disconnect & link down event
LinkDown(pAd, FALSE);
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
MlmeAutoReconnectLastSSID(pAd);
}
@@ -1273,6 +1189,7 @@ VOID STAMlmePeriodicExec(
}
else if (ADHOC_ON(pAd))
{
+#ifdef RT2860
// 2003-04-17 john. this is a patch that driver forces a BEACON out if ASIC fails
// the "TX BEACON competition" for the entire past 1 sec.
// So that even when ASIC's BEACONgen engine been blocked
@@ -1297,7 +1214,6 @@ VOID STAMlmePeriodicExec(
pAd->StaCfg.AdhocBOnlyJoined = FALSE;
}
-#ifdef DOT11_N_SUPPORT
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
if ((pAd->StaCfg.AdhocBGJoined) &&
@@ -1314,7 +1230,7 @@ VOID STAMlmePeriodicExec(
pAd->StaCfg.Adhoc20NJoined = FALSE;
}
}
-#endif // DOT11_N_SUPPORT //
+#endif /* RT2860 */
//radar detect
if ((pAd->CommonCfg.Channel > 14)
@@ -1339,6 +1255,19 @@ VOID STAMlmePeriodicExec(
MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
}
+
+#ifdef RT2870
+ for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
+ {
+ MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i];
+
+ if (pEntry->ValidAsCLI == FALSE)
+ continue;
+
+ if (pEntry->LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < pAd->Mlme.Now32)
+ MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
+ }
+#endif
}
else // no INFRA nor ADHOC connection
{
@@ -1378,14 +1307,6 @@ VOID STAMlmePeriodicExec(
}
else
{
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- if ((pAd->Mlme.OneSecPeriodicRound % 5) == 1)
- MlmeAutoReconnectLastSSID(pAd);
- }
- else
-#endif // CARRIER_DETECTION_SUPPORT //
MlmeAutoReconnectLastSSID(pAd);
}
}
@@ -1394,7 +1315,6 @@ VOID STAMlmePeriodicExec(
SKIP_AUTO_SCAN_CONN:
-#ifdef DOT11_N_SUPPORT
if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap !=0) && (pAd->MacTab.fAnyBASession == FALSE))
{
pAd->MacTab.fAnyBASession = TRUE;
@@ -1405,15 +1325,6 @@ SKIP_AUTO_SCAN_CONN:
pAd->MacTab.fAnyBASession = FALSE;
AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
}
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040))
- TriEventCounterMaintenance(pAd);
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
return;
}
@@ -1473,7 +1384,6 @@ VOID MlmeAutoReconnectLastSSID(
RT28XX_MLME_HANDLER(pAd);
}
}
-#endif // CONFIG_STA_SUPPORT //
/*
==========================================================================
@@ -1522,15 +1432,19 @@ VOID MlmeSelectTxRateTable(
break;
}
-#ifdef CONFIG_STA_SUPPORT
if ((pAd->OpMode == OPMODE_STA) && ADHOC_ON(pAd))
{
-#ifdef DOT11_N_SUPPORT
if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
+#ifdef RT2860
!pAd->StaCfg.AdhocBOnlyJoined &&
!pAd->StaCfg.AdhocBGJoined &&
(pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
+#endif
+#ifdef RT2870
+ (pEntry->HTCapability.MCSSet[0] == 0xff) &&
+ ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
+#endif
{// 11N 1S Adhoc
*ppTable = RateSwitchTable11N1S;
*pTableSize = RateSwitchTable11N1S[0];
@@ -1538,10 +1452,16 @@ VOID MlmeSelectTxRateTable(
}
else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
+#ifdef RT2860
!pAd->StaCfg.AdhocBOnlyJoined &&
!pAd->StaCfg.AdhocBGJoined &&
(pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
(pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) &&
+#endif
+#ifdef RT2870
+ (pEntry->HTCapability.MCSSet[0] == 0xff) &&
+ (pEntry->HTCapability.MCSSet[1] == 0xff) &&
+#endif
(pAd->Antenna.field.TxPath == 2))
{// 11N 2S Adhoc
if (pAd->LatchRfRegs.Channel <= 14)
@@ -1559,7 +1479,7 @@ VOID MlmeSelectTxRateTable(
}
else
-#endif // DOT11_N_SUPPORT //
+#ifdef RT2860
if (pAd->CommonCfg.PhyMode == PHY_11B)
{
*ppTable = RateSwitchTable11B;
@@ -1568,6 +1488,12 @@ VOID MlmeSelectTxRateTable(
}
else if((pAd->LatchRfRegs.Channel <= 14) && (pAd->StaCfg.AdhocBOnlyJoined == TRUE))
+#endif
+#ifdef RT2870
+ if ((pEntry->RateLen == 4)
+ && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
+ )
+#endif
{
// USe B Table when Only b-only Station in my IBSS .
*ppTable = RateSwitchTable11B;
@@ -1591,9 +1517,7 @@ VOID MlmeSelectTxRateTable(
}
break;
}
-#endif // CONFIG_STA_SUPPORT //
-#ifdef DOT11_N_SUPPORT
if ((pEntry->RateLen == 12) && (pEntry->HTCapability.MCSSet[0] == 0xff) &&
((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1)))
{// 11BGN 1S AP
@@ -1650,12 +1574,13 @@ VOID MlmeSelectTxRateTable(
break;
}
-#endif // DOT11_N_SUPPORT //
+
//else if ((pAd->StaActive.SupRateLen == 4) && (pAd->StaActive.ExtRateLen == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
if ((pEntry->RateLen == 4)
-#ifdef DOT11_N_SUPPORT
+#ifndef RT30xx
+//Iverson mark for Adhoc b mode,sta will use rate 54 Mbps when connect with sta b/g/n mode
&& (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
+#endif
)
{// B only AP
*ppTable = RateSwitchTable11B;
@@ -1667,9 +1592,7 @@ VOID MlmeSelectTxRateTable(
//else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen > 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
if ((pEntry->RateLen > 8)
-#ifdef DOT11_N_SUPPORT
&& (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
)
{// B/G mixed AP
*ppTable = RateSwitchTable11BG;
@@ -1681,9 +1604,7 @@ VOID MlmeSelectTxRateTable(
//else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
if ((pEntry->RateLen == 8)
-#ifdef DOT11_N_SUPPORT
&& (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
)
{// G only AP
*ppTable = RateSwitchTable11G;
@@ -1692,16 +1613,10 @@ VOID MlmeSelectTxRateTable(
break;
}
-#ifdef DOT11_N_SUPPORT
-#endif // DOT11_N_SUPPORT //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
-#ifdef DOT11_N_SUPPORT
//else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
if ((pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0))
-#endif // DOT11_N_SUPPORT //
{ // Legacy mode
if (pAd->CommonCfg.MaxTxRate <= RATE_11)
{
@@ -1724,7 +1639,7 @@ VOID MlmeSelectTxRateTable(
}
break;
}
-#ifdef DOT11_N_SUPPORT
+
if (pAd->LatchRfRegs.Channel <= 14)
{
if (pAd->CommonCfg.TxStream == 1)
@@ -1759,15 +1674,13 @@ VOID MlmeSelectTxRateTable(
DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
}
}
-#endif // DOT11_N_SUPPORT //
+
DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode (SupRateLen=%d, ExtRateLen=%d, MCSSet[0]=0x%x, MCSSet[1]=0x%x)\n",
pAd->StaActive.SupRateLen, pAd->StaActive.ExtRateLen, pAd->StaActive.SupportedPhyInfo.MCSSet[0], pAd->StaActive.SupportedPhyInfo.MCSSet[1]));
}
-#endif // CONFIG_STA_SUPPORT //
} while(FALSE);
}
-#ifdef CONFIG_STA_SUPPORT
/*
==========================================================================
Description:
@@ -1921,14 +1834,6 @@ VOID MlmeCalculateChannelQuality(
CHAR MaxRssi;
ULONG BeaconLostTime = BEACON_LOST_TIME;
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // longer beacon lost time when carrier detection enabled
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- BeaconLostTime = BEACON_LOST_TIME + BEACON_LOST_TIME/2;
- }
-#endif // CARRIER_DETECTION_SUPPORT //
-
MaxRssi = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
//
@@ -1993,13 +1898,11 @@ VOID MlmeSetTxRate(
{
UCHAR MaxMode = MODE_OFDM;
-#ifdef DOT11_N_SUPPORT
MaxMode = MODE_HTGREENFIELD;
if (pTxRate->STBC && (pAd->StaCfg.MaxHTPhyMode.field.STBC) && (pAd->Antenna.field.TxPath == 2))
pAd->StaCfg.HTPhyMode.field.STBC = STBC_USE;
else
-#endif // DOT11_N_SUPPORT //
pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
if (pTxRate->CurrMCS < MCS_AUTO)
@@ -2029,14 +1932,11 @@ VOID MlmeSetTxRate(
if (pTxRate->Mode <= MaxMode)
pAd->StaCfg.HTPhyMode.field.MODE = pTxRate->Mode;
-#ifdef DOT11_N_SUPPORT
if (pTxRate->ShortGI && (pAd->StaCfg.MaxHTPhyMode.field.ShortGI))
pAd->StaCfg.HTPhyMode.field.ShortGI = GI_400;
else
-#endif // DOT11_N_SUPPORT //
pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-#ifdef DOT11_N_SUPPORT
// Reexam each bandwidth's SGI support.
if (pAd->StaCfg.HTPhyMode.field.ShortGI == GI_400)
{
@@ -2080,17 +1980,15 @@ VOID MlmeSetTxRate(
{
AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
}
-#endif // DOT11_N_SUPPORT //
pEntry->HTPhyMode.field.STBC = pAd->StaCfg.HTPhyMode.field.STBC;
pEntry->HTPhyMode.field.ShortGI = pAd->StaCfg.HTPhyMode.field.ShortGI;
pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
-#ifdef DOT11_N_SUPPORT
+
if ((pAd->StaCfg.MaxHTPhyMode.field.MODE == MODE_HTGREENFIELD) &&
pAd->WIFItestbed.bGreenField)
pEntry->HTPhyMode.field.MODE = MODE_HTGREENFIELD;
-#endif // DOT11_N_SUPPORT //
}
pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
@@ -2130,18 +2028,6 @@ VOID MlmeDynamicTxRateSwitching(
ULONG TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
MAC_TABLE_ENTRY *pEntry;
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- /*if (pAd->Antenna.field.RxPath > 1)
- Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
- else
- Rssi = pAd->StaCfg.RssiSample.AvgRssi0;*/
-
//
// walk through MAC table, see if need to change AP's TX rate toward each entry
//
@@ -2155,7 +2041,15 @@ VOID MlmeDynamicTxRateSwitching(
if ((pAd->MacTab.Size == 1) || (pEntry->ValidAsDls))
{
+#ifdef RT2860
Rssi = RTMPMaxRssi(pAd, (CHAR)pAd->StaCfg.RssiSample.AvgRssi0, (CHAR)pAd->StaCfg.RssiSample.AvgRssi1, (CHAR)pAd->StaCfg.RssiSample.AvgRssi2);
+#endif
+#ifdef RT2870
+ Rssi = RTMPMaxRssi(pAd,
+ pAd->StaCfg.RssiSample.AvgRssi0,
+ pAd->StaCfg.RssiSample.AvgRssi1,
+ pAd->StaCfg.RssiSample.AvgRssi2);
+#endif
// Update statistic counter
RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
@@ -2185,7 +2079,21 @@ VOID MlmeDynamicTxRateSwitching(
}
else
{
+#ifdef RT2860
Rssi = RTMPMaxRssi(pAd, (CHAR)pEntry->RssiSample.AvgRssi0, (CHAR)pEntry->RssiSample.AvgRssi1, (CHAR)pEntry->RssiSample.AvgRssi2);
+#endif
+#ifdef RT2870
+ if (INFRA_ON(pAd) && (i == 1))
+ Rssi = RTMPMaxRssi(pAd,
+ pAd->StaCfg.RssiSample.AvgRssi0,
+ pAd->StaCfg.RssiSample.AvgRssi1,
+ pAd->StaCfg.RssiSample.AvgRssi2);
+ else
+ Rssi = RTMPMaxRssi(pAd,
+ pEntry->RssiSample.AvgRssi0,
+ pEntry->RssiSample.AvgRssi1,
+ pEntry->RssiSample.AvgRssi2);
+#endif
TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
pEntry->OneSecTxRetryOkCount +
@@ -2242,14 +2150,12 @@ VOID MlmeDynamicTxRateSwitching(
pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-#ifdef DOT11_N_SUPPORT
if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX))
{
TrainUp = (pCurrTxRate->TrainUp + (pCurrTxRate->TrainUp >> 1));
TrainDown = (pCurrTxRate->TrainDown + (pCurrTxRate->TrainDown >> 1));
}
else
-#endif // DOT11_N_SUPPORT //
{
TrainUp = pCurrTxRate->TrainUp;
TrainDown = pCurrTxRate->TrainDown;
@@ -2327,7 +2233,6 @@ VOID MlmeDynamicTxRateSwitching(
{
MCS14 = idx;
}
- //else if ((pCurrTxRate->CurrMCS == MCS_15)/* && (pCurrTxRate->ShortGI == GI_800)*/) //we hope to use ShortGI as initial rate
else if ((pCurrTxRate->CurrMCS == MCS_15) && (pCurrTxRate->ShortGI == GI_800)) //we hope to use ShortGI as initial rate, however Atheros's chip has bugs when short GI
{
MCS15 = idx;
@@ -2373,7 +2278,7 @@ VOID MlmeDynamicTxRateSwitching(
RssiOffset = 8;
}
}
-#ifdef DOT11_N_SUPPORT
+
/*if (MCS15)*/
if ((pTable == RateSwitchTable11BGN3S) ||
(pTable == RateSwitchTable11N3S) ||
@@ -2439,7 +2344,6 @@ VOID MlmeDynamicTxRateSwitching(
TxRateIdx = MCS0;
}
else
-#endif // DOT11_N_SUPPORT //
{// Legacy mode
if (MCS7 && (Rssi > -70))
TxRateIdx = MCS7;
@@ -2613,7 +2517,12 @@ VOID StaQuickResponeForRateUpExec(
UCHAR UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx = 0;
ULONG TxTotalCnt;
ULONG TxErrorRatio = 0;
+#ifdef RT2860
BOOLEAN bTxRateChanged = TRUE; //, bUpgradeQuality = FALSE;
+#endif
+#ifdef RT2870
+ BOOLEAN bTxRateChanged; //, bUpgradeQuality = FALSE;
+#endif
PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate = NULL;
PUCHAR pTable;
UCHAR TableSize = 0;
@@ -2638,11 +2547,25 @@ VOID StaQuickResponeForRateUpExec(
if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
continue;
+#ifdef RT2860
//Rssi = RTMPMaxRssi(pAd, (CHAR)pAd->StaCfg.AvgRssi0, (CHAR)pAd->StaCfg.AvgRssi1, (CHAR)pAd->StaCfg.AvgRssi2);
if (pAd->Antenna.field.TxPath > 1)
Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
else
Rssi = pAd->StaCfg.RssiSample.AvgRssi0;
+#endif
+#ifdef RT2870
+ if (INFRA_ON(pAd) && (i == 1))
+ Rssi = RTMPMaxRssi(pAd,
+ pAd->StaCfg.RssiSample.AvgRssi0,
+ pAd->StaCfg.RssiSample.AvgRssi1,
+ pAd->StaCfg.RssiSample.AvgRssi2);
+ else
+ Rssi = RTMPMaxRssi(pAd,
+ pEntry->RssiSample.AvgRssi0,
+ pEntry->RssiSample.AvgRssi1,
+ pEntry->RssiSample.AvgRssi2);
+#endif
CurrRateIdx = pAd->CommonCfg.TxRateIndex;
@@ -2667,14 +2590,12 @@ VOID StaQuickResponeForRateUpExec(
pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-#ifdef DOT11_N_SUPPORT
if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX))
{
TrainUp = (pCurrTxRate->TrainUp + (pCurrTxRate->TrainUp >> 1));
TrainDown = (pCurrTxRate->TrainDown + (pCurrTxRate->TrainDown >> 1));
}
else
-#endif // DOT11_N_SUPPORT //
{
TrainUp = pCurrTxRate->TrainUp;
TrainDown = pCurrTxRate->TrainDown;
@@ -2784,6 +2705,9 @@ VOID StaQuickResponeForRateUpExec(
pAd->DrsCounters.TxRateUpPenalty = 0;
NdisZeroMemory(pAd->DrsCounters.TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
NdisZeroMemory(pAd->DrsCounters.PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
+#ifdef RT2870
+ bTxRateChanged = TRUE;
+#endif
}
// if rate-down happen, only clear DownRate's bad history
else if (pAd->CommonCfg.TxRateIndex < CurrRateIdx)
@@ -2793,6 +2717,9 @@ VOID StaQuickResponeForRateUpExec(
pAd->DrsCounters.TxRateUpPenalty = 0; // no penalty
pAd->DrsCounters.TxQuality[pAd->CommonCfg.TxRateIndex] = 0;
pAd->DrsCounters.PER[pAd->CommonCfg.TxRateIndex] = 0;
+#ifdef RT2870
+ bTxRateChanged = TRUE;
+#endif
}
else
{
@@ -2848,7 +2775,13 @@ VOID MlmeCheckPsmChange(
if (INFRA_ON(pAd) &&
(PowerMode != Ndis802_11PowerModeCAM) &&
(pAd->StaCfg.Psm == PWR_ACTIVE) &&
+#ifdef RT2860
RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP))
+#endif
+#if !defined(RT2860) && !defined(RT30xx)
+ (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
+#endif
+#ifndef RT30xx
{
NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
pAd->RalinkCounters.RxCountSinceLastNULL = 0;
@@ -2862,6 +2795,42 @@ VOID MlmeCheckPsmChange(
RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
}
}
+#endif
+#ifdef RT30xx
+// (! RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+ (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) /*&&
+ (pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
+ (pAd->RalinkCounters.OneSecTxRetryOkCount == 0)*/)
+ {
+ // add by johnli, use Rx OK data count per second to calculate throughput
+ // If Ttraffic is too high ( > 400 Rx per second), don't go to sleep mode. If tx rate is low, use low criteria
+ // Mode=CCK/MCS=3 => 11 Mbps, Mode=OFDM/MCS=3 => 18 Mbps
+ if (((pAd->StaCfg.HTPhyMode.field.MCS <= 3) &&
+/* Iverson mark
+ (pAd->StaCfg.HTPhyMode.field.MODE <= MODE_OFDM) &&
+*/
+ (pAd->RalinkCounters.OneSecRxOkDataCnt < (ULONG)100)) ||
+ ((pAd->StaCfg.HTPhyMode.field.MCS > 3) &&
+/* Iverson mark
+ (pAd->StaCfg.HTPhyMode.field.MODE > MODE_OFDM) &&
+*/
+ (pAd->RalinkCounters.OneSecRxOkDataCnt < (ULONG)400)))
+ {
+ // Get this time
+ NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
+ pAd->RalinkCounters.RxCountSinceLastNULL = 0;
+ MlmeSetPsmBit(pAd, PWR_SAVE);
+ if (!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable))
+ {
+ RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE);
+ }
+ else
+ {
+ RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
+ }
+ }
+ }
+#endif
}
// IRQL = PASSIVE_LEVEL
@@ -2876,10 +2845,10 @@ VOID MlmeSetPsmBit(
RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
csr4.field.AckCtsPsmBit = (psm == PWR_SAVE)? 1:0;
RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
+#ifndef RT30xx
DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetPsmBit = %d\n", psm));
+#endif
}
-#endif // CONFIG_STA_SUPPORT //
-
// IRQL = DISPATCH_LEVEL
VOID MlmeSetTxPreamble(
@@ -3018,9 +2987,6 @@ VOID MlmeUpdateTxRates(
//===========================================================================
//===========================================================================
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pHtPhy = &pAd->StaCfg.HTPhyMode;
pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
@@ -3036,7 +3002,6 @@ VOID MlmeUpdateTxRates(
MaxDesire = RATE_11;
}
}
-#endif // CONFIG_STA_SUPPORT //
pAd->CommonCfg.MaxDesiredRate = MaxDesire;
pMinHtPhy->word = 0;
@@ -3065,7 +3030,6 @@ VOID MlmeUpdateTxRates(
}
#endif
-#ifdef CONFIG_STA_SUPPORT
if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
{
pSupRate = &pAd->StaActive.SupRate[0];
@@ -3074,7 +3038,6 @@ VOID MlmeUpdateTxRates(
ExtRateLen = pAd->StaActive.ExtRateLen;
}
else
-#endif // CONFIG_STA_SUPPORT //
{
pSupRate = &pAd->CommonCfg.SupRate[0];
pExtRate = &pAd->CommonCfg.ExtRate[0];
@@ -3151,10 +3114,9 @@ VOID MlmeUpdateTxRates(
if (*auto_rate_cur_p)
{
short dbm = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- dbm = pAd->StaCfg.RssiSample.AvgRssi0 - pAd->BbpRssiToDbmDelta;
-#endif // CONFIG_STA_SUPPORT //
+
+ dbm = pAd->StaCfg.RssiSample.AvgRssi0 - pAd->BbpRssiToDbmDelta;
+
if (bLinkUp == TRUE)
pAd->CommonCfg.TxRate = RATE_24;
else
@@ -3212,9 +3174,7 @@ VOID MlmeUpdateTxRates(
{
case PHY_11BG_MIXED:
case PHY_11B:
-#ifdef DOT11_N_SUPPORT
case PHY_11BGN_MIXED:
-#endif // DOT11_N_SUPPORT //
pAd->CommonCfg.MlmeRate = RATE_1;
pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
@@ -3222,22 +3182,18 @@ VOID MlmeUpdateTxRates(
break;
case PHY_11G:
case PHY_11A:
-#ifdef DOT11_N_SUPPORT
case PHY_11AGN_MIXED:
case PHY_11GN_MIXED:
case PHY_11N_2_4G:
case PHY_11AN_MIXED:
case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
pAd->CommonCfg.MlmeRate = RATE_6;
pAd->CommonCfg.RtsRate = RATE_6;
pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
break;
case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
case PHY_11ABGN_MIXED:
-#endif // DOT11_N_SUPPORT //
if (pAd->CommonCfg.Channel <= 14)
{
pAd->CommonCfg.MlmeRate = RATE_1;
@@ -3280,7 +3236,6 @@ VOID MlmeUpdateTxRates(
pAd->CommonCfg.MlmeTransmit.word, pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word ));
}
-#ifdef DOT11_N_SUPPORT
/*
==========================================================================
Description:
@@ -3313,8 +3268,6 @@ VOID MlmeUpdateHtTxRates(
auto_rate_cur_p = NULL;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pDesireHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
pActiveHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
@@ -3324,9 +3277,7 @@ VOID MlmeUpdateHtTxRates(
auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
}
-#endif // CONFIG_STA_SUPPORT //
-#ifdef CONFIG_STA_SUPPORT
if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
{
if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
@@ -3342,7 +3293,6 @@ VOID MlmeUpdateHtTxRates(
pMaxHtPhy->field.STBC = STBC_NONE;
}
else
-#endif // CONFIG_STA_SUPPORT //
{
if (pDesireHtPhy->bHtEnable == FALSE)
return;
@@ -3393,7 +3343,6 @@ VOID MlmeUpdateHtTxRates(
pMinHtPhy->field.STBC = 0;
pMinHtPhy->field.ShortGI = 0;
//If STA assigns fixed rate. update to fixed here.
-#ifdef CONFIG_STA_SUPPORT
if ( (pAd->OpMode == OPMODE_STA) && (pDesireHtPhy->MCSSet[0] != 0xff))
{
if (pDesireHtPhy->MCSSet[4] != 0)
@@ -3417,8 +3366,6 @@ VOID MlmeUpdateHtTxRates(
break;
}
}
-#endif // CONFIG_STA_SUPPORT //
-
// Decide ht rate
pHtPhy->field.STBC = pMaxHtPhy->field.STBC;
@@ -3438,7 +3385,6 @@ VOID MlmeUpdateHtTxRates(
pHtPhy->field.BW, pHtPhy->field.ShortGI, pHtPhy->field.MODE));
DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates<=== \n"));
}
-#endif // DOT11_N_SUPPORT //
// IRQL = DISPATCH_LEVEL
VOID MlmeRadioOff(
@@ -3483,7 +3429,6 @@ VOID BssTableInit(
}
}
-#ifdef DOT11_N_SUPPORT
VOID BATableInit(
IN PRTMP_ADAPTER pAd,
IN BA_TABLE *Tab)
@@ -3503,7 +3448,6 @@ VOID BATableInit(
Tab->BAOriEntry[i].ORI_BA_Status = Originator_NONE;
}
}
-#endif // DOT11_N_SUPPORT //
/*! \brief search the BSS table by SSID
* \param p_tab pointer to the bss table
@@ -3613,7 +3557,6 @@ VOID BssTableDeleteEntry(
}
}
-#ifdef DOT11_N_SUPPORT
/*
========================================================================
Routine Description:
@@ -3645,7 +3588,6 @@ VOID BATableDeleteORIEntry(
NdisReleaseSpinLock(&pAd->BATabLock);
}
}
-#endif // DOT11_N_SUPPORT //
/*! \brief
* \param
@@ -3762,7 +3704,7 @@ VOID BssEntrySet(
pBss->AddHtInfoLen = 0;
pBss->HtCapabilityLen = 0;
-#ifdef DOT11_N_SUPPORT
+
if (HtCapabilityLen> 0)
{
pBss->HtCapabilityLen = HtCapabilityLen;
@@ -3782,7 +3724,6 @@ VOID BssEntrySet(
}
}
}
-#endif // DOT11_N_SUPPORT //
BssCipherParse(pBss);
@@ -3800,8 +3741,6 @@ VOID BssEntrySet(
else
pBss->QbssLoad.bValid = FALSE;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
PEID_STRUCT pEid;
USHORT Length = 0;
@@ -3809,11 +3748,9 @@ VOID BssEntrySet(
NdisZeroMemory(&pBss->WpaIE.IE[0], MAX_CUSTOM_LEN);
NdisZeroMemory(&pBss->RsnIE.IE[0], MAX_CUSTOM_LEN);
-#ifdef EXT_BUILD_CHANNEL_LIST
- NdisZeroMemory(&pBss->CountryString[0], 3);
- pBss->bHasCountryIE = FALSE;
-#endif // EXT_BUILD_CHANNEL_LIST //
+
pEid = (PEID_STRUCT) pVIE;
+
while ((Length + 2 + (USHORT)pEid->Len) <= LengthVIE)
{
switch(pEid->Eid)
@@ -3842,18 +3779,11 @@ VOID BssEntrySet(
NdisMoveMemory(pBss->RsnIE.IE, pEid, pBss->RsnIE.IELen);
}
break;
-#ifdef EXT_BUILD_CHANNEL_LIST
- case IE_COUNTRY:
- NdisMoveMemory(&pBss->CountryString[0], pEid->Octet, 3);
- pBss->bHasCountryIE = TRUE;
- break;
-#endif // EXT_BUILD_CHANNEL_LIST //
}
Length = Length + 2 + (USHORT)pEid->Len; // Eid[1] + Len[1]+ content[Len]
pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
}
}
-#endif // CONFIG_STA_SUPPORT //
}
/*!
@@ -3947,119 +3877,22 @@ ULONG BssTableSetEntry(
}
else
{
+#ifdef RT30xx
+ /* avoid Hidden SSID form beacon to overwirite correct SSID from probe response */
+ if ((SSID_EQUAL(Ssid, SsidLen, Tab->BssEntry[Idx].Ssid, Tab->BssEntry[Idx].SsidLen)) ||
+ (NdisEqualMemory(Tab->BssEntry[Idx].Ssid, ZeroSsid, Tab->BssEntry[Idx].SsidLen)))
+ {
+#endif
BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod,CfParm, AtimWin,
CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- }
-
- return Idx;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
-VOID TriEventInit(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
-
- for (i = 0;i < MAX_TRIGGER_EVENT;i++)
- pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
-
- pAd->CommonCfg.TriggerEventTab.EventANo = 0;
- pAd->CommonCfg.TriggerEventTab.EventBCountDown = 0;
-}
-
-ULONG TriEventTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT TRIGGER_EVENT_TAB *Tab,
- IN PUCHAR pBssid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN UCHAR RegClass,
- IN UCHAR ChannelNo)
-{
- // Event A
- if (HtCapabilityLen == 0)
- {
- if (Tab->EventANo < MAX_TRIGGER_EVENT)
- {
- RTMPMoveMemory(Tab->EventA[Tab->EventANo].BSSID, pBssid, 6);
- Tab->EventA[Tab->EventANo].bValid = TRUE;
- Tab->EventA[Tab->EventANo].Channel = ChannelNo;
- Tab->EventA[Tab->EventANo].CDCounter = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
- if (RegClass != 0)
- {
- // Beacon has Regulatory class IE. So use beacon's
- Tab->EventA[Tab->EventANo].RegClass = RegClass;
- }
- else
- {
- // Use Station's Regulatory class instead.
- if (pAd->StaActive.SupportedHtPhy.bHtEnable == TRUE)
- {
- if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
- {
- Tab->EventA[Tab->EventANo].RegClass = 32;
- }
- else if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
- Tab->EventA[Tab->EventANo].RegClass = 33;
- }
- else
- Tab->EventA[Tab->EventANo].RegClass = ??;
-
- }
-
- Tab->EventANo ++;
- }
- }
- else if (pHtCapability->HtCapInfo.Intolerant40)
- {
- Tab->EventBCountDown = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
- }
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Trigger Event table Maintainence called once every second.
-
- Arguments:
- // IRQL = DISPATCH_LEVEL
- ========================================================================
-*/
-VOID TriEventCounterMaintenance(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
- BOOLEAN bNotify = FALSE;
- for (i = 0;i < MAX_TRIGGER_EVENT;i++)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid && (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter > 0))
- {
- pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter--;
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter == 0)
- {
- pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
- pAd->CommonCfg.TriggerEventTab.EventANo --;
- // Need to send 20/40 Coexistence Notify frame if has status change.
- bNotify = TRUE;
- }
+#ifdef RT30xx
}
- }
- if (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0)
- {
- pAd->CommonCfg.TriggerEventTab.EventBCountDown--;
- if (pAd->CommonCfg.TriggerEventTab.EventBCountDown == 0)
- bNotify = TRUE;
+#endif
}
- if (bNotify == TRUE)
- Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE);
+ return Idx;
}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
// IRQL = DISPATCH_LEVEL
VOID BssTableSsidSort(
@@ -4079,9 +3912,6 @@ VOID BssTableSsidSort(
if (((pAd->CommonCfg.bIEEE80211H == 1) &&
(pAd->MlmeAux.Channel > 14) &&
RadarChannelCheck(pAd, pInBss->Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
-#endif // CARRIER_DETECTION_SUPPORT //
)
{
if (pInBss->Hidden)
@@ -4093,18 +3923,6 @@ VOID BssTableSsidSort(
{
BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // If no Country IE exists no Connection will be established when IEEE80211dClientMode is strict.
- if ((pAd->StaCfg.IEEE80211dClientMode == Rt802_11_D_Strict) &&
- (pInBss->bHasCountryIE == FALSE))
- {
- DBGPRINT(RT_DEBUG_TRACE,("StaCfg.IEEE80211dClientMode == Rt802_11_D_Strict, but this AP doesn't have country IE.\n"));
- continue;
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef DOT11_N_SUPPORT
// 2.4G/5G N only mode
if ((pInBss->HtCapabilityLen == 0) &&
((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)))
@@ -4112,7 +3930,6 @@ VOID BssTableSsidSort(
DBGPRINT(RT_DEBUG_TRACE,("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
continue;
}
-#endif // DOT11_N_SUPPORT //
// New for WPA2
// Check the Authmode first
@@ -4132,9 +3949,14 @@ VOID BssTableSsidSort(
continue;
// check group cipher
+#ifndef RT30xx
if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) &&
(pInBss->WPA.GroupCipher != Ndis802_11GroupWEP40Enabled) &&
(pInBss->WPA.GroupCipher != Ndis802_11GroupWEP104Enabled))
+#endif
+#ifdef RT30xx
+ if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
+#endif
continue;
// check pairwise cipher, skip if none matched
@@ -4153,9 +3975,14 @@ VOID BssTableSsidSort(
continue;
// check group cipher
+#ifndef RT30xx
if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) &&
(pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP40Enabled) &&
(pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP104Enabled))
+#endif
+#ifdef RT30xx
+ if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
+#endif
continue;
// check pairwise cipher, skip if none matched
@@ -4185,7 +4012,6 @@ VOID BssTableSsidSort(
if (SsidLen == 0)
continue;
-#ifdef DOT11_N_SUPPORT
// If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
// If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
if ((pInBss->CentralChannel != pInBss->Channel) &&
@@ -4205,7 +4031,6 @@ VOID BssTableSsidSort(
}
}
}
-#endif // DOT11_N_SUPPORT //
// copy matching BSS from InTab to OutTab
NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
@@ -4216,8 +4041,6 @@ VOID BssTableSsidSort(
{
BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-#ifdef DOT11_N_SUPPORT
// 2.4G/5G N only mode
if ((pInBss->HtCapabilityLen == 0) &&
((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)))
@@ -4225,7 +4048,6 @@ VOID BssTableSsidSort(
DBGPRINT(RT_DEBUG_TRACE,("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
continue;
}
-#endif // DOT11_N_SUPPORT //
// New for WPA2
// Check the Authmode first
@@ -4281,7 +4103,6 @@ VOID BssTableSsidSort(
else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
continue;
-#ifdef DOT11_N_SUPPORT
// If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
// If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
if ((pInBss->CentralChannel != pInBss->Channel) &&
@@ -4294,7 +4115,6 @@ VOID BssTableSsidSort(
pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
}
}
-#endif // DOT11_N_SUPPORT //
// copy matching BSS from InTab to OutTab
NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
@@ -4330,8 +4150,6 @@ VOID BssTableSortByRssi(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
-
VOID BssCipherParse(
IN OUT PBSS_ENTRY pBss)
@@ -4442,10 +4260,16 @@ VOID BssCipherParse(
switch (*pTmp)
{
case 1:
+#ifndef RT30xx
pBss->WPA.GroupCipher = Ndis802_11GroupWEP40Enabled;
break;
case 5:
pBss->WPA.GroupCipher = Ndis802_11GroupWEP104Enabled;
+#endif
+#ifdef RT30xx
+ case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
+ pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
+#endif
break;
case 2:
pBss->WPA.GroupCipher = Ndis802_11Encryption2Enabled;
@@ -4532,7 +4356,6 @@ VOID BssCipherParse(
pBss->AuthMode = Ndis802_11AuthModeWPANone;
pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
pBss->WepStatus = pBss->WPA.GroupCipher;
- // Patched bugs for old driver
if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
}
@@ -4562,10 +4385,16 @@ VOID BssCipherParse(
switch (pCipher->Type)
{
case 1:
+#ifndef RT30xx
pBss->WPA2.GroupCipher = Ndis802_11GroupWEP40Enabled;
break;
case 5:
pBss->WPA2.GroupCipher = Ndis802_11GroupWEP104Enabled;
+#endif
+#ifdef RT30xx
+ case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
+ pBss->WPA2.GroupCipher = Ndis802_11Encryption1Enabled;
+#endif
break;
case 2:
pBss->WPA2.GroupCipher = Ndis802_11Encryption2Enabled;
@@ -4659,7 +4488,6 @@ VOID BssCipherParse(
pBss->WPA.PairCipherAux = pBss->WPA2.PairCipherAux;
pBss->WPA.GroupCipher = pBss->WPA2.GroupCipher;
pBss->WepStatus = pBss->WPA.GroupCipher;
- // Patched bugs for old driver
if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
}
@@ -4735,10 +4563,9 @@ VOID MgtMacHeaderInit(
pHdr80211->FC.SubType = SubType;
pHdr80211->FC.ToDs = ToDs;
COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
+
+ COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
+
COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
}
@@ -4925,12 +4752,6 @@ BOOLEAN MlmeEnqueueForRecv(
INT MsgType;
MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
-#ifdef RALINK_ATE
- /* Nothing to do in ATE mode */
- if(ATE_ON(pAd))
- return FALSE;
-#endif // RALINK_ATE //
-
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
@@ -4951,8 +4772,6 @@ BOOLEAN MlmeEnqueueForRecv(
return FALSE;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (!MsgTypeSubst(pAd, pFrame, &Machine, &MsgType))
{
@@ -4960,7 +4779,6 @@ BOOLEAN MlmeEnqueueForRecv(
return FALSE;
}
}
-#endif // CONFIG_STA_SUPPORT //
// OK, we got all the informations, it is time to put things into queue
NdisAcquireSpinLock(&(Queue->Lock));
@@ -5028,13 +4846,14 @@ BOOLEAN MlmeDequeue(
VOID MlmeRestartStateMachine(
IN PRTMP_ADAPTER pAd)
{
+#ifdef RT2860
MLME_QUEUE_ELEM *Elem = NULL;
-#ifdef CONFIG_STA_SUPPORT
+#endif
BOOLEAN Cancelled;
-#endif // CONFIG_STA_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
+#ifdef RT2860
NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
if(pAd->Mlme.bRunning)
{
@@ -5062,13 +4881,9 @@ VOID MlmeRestartStateMachine(
DBGPRINT_ERR(("MlmeRestartStateMachine: MlmeQueue empty\n"));
}
}
+#endif /* RT2860 */
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
-#ifdef QOS_DLS_SUPPORT
- UCHAR i;
-#endif // QOS_DLS_SUPPORT //
// Cancel all timer events
// Be careful to cancel new added timer
RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
@@ -5077,15 +4892,7 @@ VOID MlmeRestartStateMachine(
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-#ifdef QOS_DLS_SUPPORT
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
- }
-#endif // QOS_DLS_SUPPORT //
}
-#endif // CONFIG_STA_SUPPORT //
// Change back to original channel in case of doing scan
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
@@ -5094,8 +4901,6 @@ VOID MlmeRestartStateMachine(
// Resume MSDU which is turned off durning scan
RTMPResumeMsduTransmission(pAd);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Set all state machines back IDLE
pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
@@ -5104,16 +4909,14 @@ VOID MlmeRestartStateMachine(
pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
-#ifdef QOS_DLS_SUPPORT
- pAd->Mlme.DlsMachine.CurrState = DLS_IDLE;
-#endif // QOS_DLS_SUPPORT //
}
-#endif // CONFIG_STA_SUPPORT //
+#ifdef RT2860
// Remove running state
NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
pAd->Mlme.bRunning = FALSE;
NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
+#endif
}
/*! \brief test if the MLME Queue is empty
@@ -5191,7 +4994,6 @@ VOID MlmeQueueDestroy(
IRQL = DISPATCH_LEVEL
*/
-#ifdef CONFIG_STA_SUPPORT
BOOLEAN MsgTypeSubst(
IN PRTMP_ADAPTER pAd,
IN PFRAME_802_11 pFrame,
@@ -5215,16 +5017,6 @@ BOOLEAN MsgTypeSubst(
*MsgType = MT2_AIRONET_MSG;
return (TRUE);
}
-#ifdef LEAP_SUPPORT
- if ( pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP ) //LEAP
- {
- // LEAP frames
- *Machine = LEAP_STATE_MACHINE;
- EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
- return (LeapMsgTypeSubst(EAPType, MsgType));
- }
- else
-#endif // LEAP_SUPPORT //
{
*Machine = WPA_PSK_STATE_MACHINE;
EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
@@ -5311,7 +5103,6 @@ BOOLEAN MsgTypeSubst(
return TRUE;
}
-#endif // CONFIG_STA_SUPPORT //
// ===========================================================================================
// state_machine.c
@@ -5533,7 +5324,6 @@ VOID AsicUpdateAutoFallBackTable(
}
}
break;
-#ifdef DOT11_N_SUPPORT
case 2: //HT-MIX
case 3: //HT-GF
{
@@ -5595,7 +5385,6 @@ VOID AsicUpdateAutoFallBackTable(
}
}
break;
-#endif // DOT11_N_SUPPORT //
}
pNextTxRate = pCurrTxRate;
@@ -5637,12 +5426,6 @@ VOID AsicUpdateProtect(
UCHAR i;
UINT32 MacReg = 0;
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
if (!(pAd->CommonCfg.bHTProtect) && (OperationMode != 8))
{
return;
@@ -5656,19 +5439,14 @@ VOID AsicUpdateProtect(
SetMask = ALLN_SETPROTECT;
OperationMode = 8;
}
-#endif // DOT11_N_SUPPORT //
// Config ASIC RTS threshold register
RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
MacReg &= 0xFF0000FF;
-#if 0
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
-#else
- // If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
+
+ // If the user want disable RtsThreshold and enable Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
if ((
-#ifdef DOT11_N_SUPPORT
(pAd->CommonCfg.BACapability.field.AmsduEnable) ||
-#endif // DOT11_N_SUPPORT //
(pAd->CommonCfg.bAggregationCapable == TRUE))
&& pAd->CommonCfg.RtsThreshold == MAX_RTS_THRESHOLD)
{
@@ -5678,7 +5456,6 @@ VOID AsicUpdateProtect(
{
MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
}
-#endif
RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
@@ -5717,7 +5494,6 @@ VOID AsicUpdateProtect(
Protect[1] = ProtCfg.word;
}
-#ifdef DOT11_N_SUPPORT
// Decide HT frame protection.
if ((SetMask & ALLN_SETPROTECT) != 0)
{
@@ -5848,7 +5624,6 @@ VOID AsicUpdateProtect(
break;
}
}
-#endif // DOT11_N_SUPPORT //
offset = CCK_PROT_CFG;
for (i = 0;i < 6;i++)
@@ -5860,6 +5635,276 @@ VOID AsicUpdateProtect(
}
}
+#ifdef RT30xx
+/*
+ ========================================================================
+
+ Routine Description: Write RT30xx RF register through MAC
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NTSTATUS RT30xxWriteRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RegID,
+ IN UCHAR Value)
+{
+ RF_CSR_CFG_STRUC rfcsr;
+ UINT i = 0;
+
+ do
+ {
+ RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
+
+ if (!rfcsr.field.RF_CSR_KICK)
+ break;
+ i++;
+ }
+ while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
+
+ if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
+ {
+ DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ rfcsr.field.RF_CSR_WR = 1;
+ rfcsr.field.RF_CSR_KICK = 1;
+ rfcsr.field.TESTCSR_RFACC_REGNUM = RegID;
+ rfcsr.field.RF_CSR_DATA = Value;
+
+ RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
+
+ return STATUS_SUCCESS;
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description: Read RT30xx RF register through MAC
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NTSTATUS RT30xxReadRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RegID,
+ IN PUCHAR pValue)
+{
+ RF_CSR_CFG_STRUC rfcsr;
+ UINT i=0, k=0;
+
+ for (i=0; i<MAX_BUSY_COUNT; i++)
+ {
+ RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
+
+ if (rfcsr.field.RF_CSR_KICK == BUSY)
+ {
+ continue;
+ }
+ rfcsr.word = 0;
+ rfcsr.field.RF_CSR_WR = 0;
+ rfcsr.field.RF_CSR_KICK = 1;
+ rfcsr.field.TESTCSR_RFACC_REGNUM = RegID;
+ RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
+ for (k=0; k<MAX_BUSY_COUNT; k++)
+ {
+ RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
+
+ if (rfcsr.field.RF_CSR_KICK == IDLE)
+ break;
+ }
+ if ((rfcsr.field.RF_CSR_KICK == IDLE) &&
+ (rfcsr.field.TESTCSR_RFACC_REGNUM == RegID))
+ {
+ *pValue = (UCHAR)rfcsr.field.RF_CSR_DATA;
+ break;
+ }
+ }
+ if (rfcsr.field.RF_CSR_KICK == BUSY)
+ {
+ DBGPRINT_ERR(("RF read R%d=0x%x fail, i[%d], k[%d]\n", RegID, rfcsr.word,i,k));
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ return STATUS_SUCCESS;
+}
+#endif // RT30xx //
+
+#ifdef RT30xx
+// add by johnli, RF power sequence setup
+/*
+ ==========================================================================
+ Description:
+
+ Load RF normal operation-mode setup
+
+ ==========================================================================
+ */
+VOID RT30xxLoadRFNormalModeSetup(
+ IN PRTMP_ADAPTER pAd)
+{
+ UCHAR RFValue;
+
+ // RX0_PD & TX0_PD, RF R1 register Bit 2 & Bit 3 to 0 and RF_BLOCK_en,RX1_PD & TX1_PD, Bit0, Bit 4 & Bit5 to 1
+ RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
+ RFValue = (RFValue & (~0x0C)) | 0x31;
+ RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
+
+ // TX_LO2_en, RF R15 register Bit 3 to 0
+ RT30xxReadRFRegister(pAd, RF_R15, &RFValue);
+ RFValue &= (~0x08);
+ RT30xxWriteRFRegister(pAd, RF_R15, RFValue);
+
+ // TX_LO1_en, RF R17 register Bit 3 to 0
+ RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
+ RFValue &= (~0x08);
+ // to fix rx long range issue
+ if (((pAd->MACVersion & 0xffff) >= 0x0211) && (pAd->NicConfig2.field.ExternalLNAForG == 0))
+ {
+ RFValue |= 0x20;
+ }
+ RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
+
+ // RX_LO1_en, RF R20 register Bit 3 to 0
+ RT30xxReadRFRegister(pAd, RF_R20, &RFValue);
+ RFValue &= (~0x08);
+ RT30xxWriteRFRegister(pAd, RF_R20, RFValue);
+
+ // RX_LO2_en, RF R21 register Bit 3 to 0
+ RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
+ RFValue &= (~0x08);
+ RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
+
+ // LDORF_VC, RF R27 register Bit 2 to 0
+ RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
+ if ((pAd->MACVersion & 0xffff) < 0x0211)
+ RFValue = (RFValue & (~0x77)) | 0x3;
+ else
+ RFValue = (RFValue & (~0x77));
+ RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
+ /* end johnli */
+}
+
+/*
+ ==========================================================================
+ Description:
+
+ Load RF sleep-mode setup
+
+ ==========================================================================
+ */
+VOID RT30xxLoadRFSleepModeSetup(
+ IN PRTMP_ADAPTER pAd)
+{
+ UCHAR RFValue;
+ UINT32 MACValue;
+
+ // RF_BLOCK_en. RF R1 register Bit 0 to 0
+ RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
+ RFValue &= (~0x01);
+ RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
+
+ // VCO_IC, RF R7 register Bit 4 & Bit 5 to 0
+ RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
+ RFValue &= (~0x30);
+ RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
+
+ // Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 0
+ RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
+ RFValue &= (~0x0E);
+ RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
+
+ // RX_CTB_en, RF R21 register Bit 7 to 0
+ RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
+ RFValue &= (~0x80);
+ RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
+
+ // LDORF_VC, RF R27 register Bit 0, Bit 1 & Bit 2 to 1
+ RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
+ RFValue |= 0x77;
+ RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
+
+ RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
+ MACValue |= 0x1D000000;
+ RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
+}
+
+/*
+ ==========================================================================
+ Description:
+
+ Reverse RF sleep-mode setup
+
+ ==========================================================================
+ */
+VOID RT30xxReverseRFSleepModeSetup(
+ IN PRTMP_ADAPTER pAd)
+{
+ UCHAR RFValue;
+ UINT32 MACValue;
+
+ // RF_BLOCK_en, RF R1 register Bit 0 to 1
+ RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
+ RFValue |= 0x01;
+ RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
+
+ // VCO_IC, RF R7 register Bit 4 & Bit 5 to 1
+ RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
+ RFValue |= 0x30;
+ RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
+
+ // Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 1
+ RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
+ RFValue |= 0x0E;
+ RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
+
+ // RX_CTB_en, RF R21 register Bit 7 to 1
+ RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
+ RFValue |= 0x80;
+ RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
+
+ // LDORF_VC, RF R27 register Bit 2 to 0
+ RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
+ if ((pAd->MACVersion & 0xffff) < 0x0211)
+ RFValue = (RFValue & (~0x77)) | 0x3;
+ else
+ RFValue = (RFValue & (~0x77));
+ RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
+
+ // RT3071 version E has fixed this issue
+ if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211))
+ {
+ // patch tx EVM issue temporarily
+ RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
+ MACValue = ((MACValue & 0xE0FFFFFF) | 0x0D000000);
+ RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
+ }
+ else
+ {
+ RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
+ MACValue = ((MACValue & 0xE0FFFFFF) | 0x01000000);
+ RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
+ }
+}
+// end johnli
+#endif // RT30xx //
+
/*
==========================================================================
Description:
@@ -5881,6 +5926,21 @@ VOID AsicSwitchChannel(
RTMP_RF_REGS *RFRegTable;
// Search Tx power value
+#ifdef RT30xx
+ // We can't use ChannelList to search channel, since some central channl's txpowr doesn't list
+ // in ChannelList, so use TxPower array instead.
+ //
+ for (index = 0; index < MAX_NUM_OF_CHANNELS; index++)
+ {
+ if (Channel == pAd->TxPower[index].Channel)
+ {
+ TxPwer = pAd->TxPower[index].Power;
+ TxPwer2 = pAd->TxPower[index].Power2;
+ break;
+ }
+ }
+#endif
+#ifndef RT30xx
for (index = 0; index < pAd->ChannelListNum; index++)
{
if (Channel == pAd->ChannelList[index].Channel)
@@ -5890,12 +5950,152 @@ VOID AsicSwitchChannel(
break;
}
}
+#endif
if (index == MAX_NUM_OF_CHANNELS)
{
+#ifndef RT30xx
DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Cant find the Channel#%d \n", Channel));
+#endif
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Can't find the Channel#%d \n", Channel));
+#endif
}
+#ifdef RT2870
+ // The RF programming sequence is difference between 3xxx and 2xxx
+#ifdef RT30xx
+ if ((IS_RT3070(pAd) || IS_RT3090(pAd)) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020) ||
+ (pAd->RfIcType == RFIC_3021) || (pAd->RfIcType == RFIC_3022)))
+#endif
+#ifndef RT30xx
+ if (IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
+#endif
+ {
+ /* modify by WY for Read RF Reg. error */
+ UCHAR RFValue;
+
+ for (index = 0; index < NUM_OF_3020_CHNL; index++)
+ {
+ if (Channel == FreqItems3020[index].Channel)
+ {
+ // Programming channel parameters
+ RT30xxWriteRFRegister(pAd, RF_R02, FreqItems3020[index].N);
+ RT30xxWriteRFRegister(pAd, RF_R03, FreqItems3020[index].K);
+
+#ifndef RT30xx
+ RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RFValue);
+ RFValue = (RFValue & 0xFC) | FreqItems3020[index].R;
+ RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RFValue);
+
+ // Set Tx Power
+ RT30xxReadRFRegister(pAd, RF_R12, (PUCHAR)&RFValue);
+ RFValue = (RFValue & 0xE0) | TxPwer;
+ RT30xxWriteRFRegister(pAd, RF_R12, (UCHAR)RFValue);
+
+ // Set RF offset
+ RT30xxReadRFRegister(pAd, RF_R23, (PUCHAR)&RFValue);
+ RFValue = (RFValue & 0x80) | pAd->RfFreqOffset;
+ RT30xxWriteRFRegister(pAd, RF_R23, (UCHAR)RFValue);
+#endif
+#ifdef RT30xx
+ RT30xxReadRFRegister(pAd, RF_R06, &RFValue);
+ RFValue = (RFValue & 0xFC) | FreqItems3020[index].R;
+ RT30xxWriteRFRegister(pAd, RF_R06, RFValue);
+
+ // Set Tx0 Power
+ RT30xxReadRFRegister(pAd, RF_R12, &RFValue);
+ RFValue = (RFValue & 0xE0) | TxPwer;
+ RT30xxWriteRFRegister(pAd, RF_R12, RFValue);
+
+ // Set Tx1 Power
+ RT30xxReadRFRegister(pAd, RF_R13, &RFValue);
+ RFValue = (RFValue & 0xE0) | TxPwer2;
+ RT30xxWriteRFRegister(pAd, RF_R13, RFValue);
+
+ // Tx/Rx Stream setting
+ RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
+ //if (IS_RT3090(pAd))
+ // RFValue |= 0x01; // Enable RF block.
+ RFValue &= 0x03; //clear bit[7~2]
+ if (pAd->Antenna.field.TxPath == 1)
+ RFValue |= 0xA0;
+ else if (pAd->Antenna.field.TxPath == 2)
+ RFValue |= 0x80;
+ if (pAd->Antenna.field.RxPath == 1)
+ RFValue |= 0x50;
+ else if (pAd->Antenna.field.RxPath == 2)
+ RFValue |= 0x40;
+ RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
+
+ // Set RF offset
+ RT30xxReadRFRegister(pAd, RF_R23, &RFValue);
+ RFValue = (RFValue & 0x80) | pAd->RfFreqOffset;
+ RT30xxWriteRFRegister(pAd, RF_R23, RFValue);
+#endif
+
+ // Set BW
+ if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40))
+ {
+ RFValue = pAd->Mlme.CaliBW40RfR24;
+ //DISABLE_11N_CHECK(pAd);
+ }
+ else
+ {
+ RFValue = pAd->Mlme.CaliBW20RfR24;
+ }
+#ifndef RT30xx
+ RT30xxWriteRFRegister(pAd, RF_R24, (UCHAR)RFValue);
+
+ // Enable RF tuning
+ RT30xxReadRFRegister(pAd, RF_R07, (PUCHAR)&RFValue);
+ RFValue = RFValue | 0x1;
+ RT30xxWriteRFRegister(pAd, RF_R07, (UCHAR)RFValue);
+
+ // latch channel for future usage.
+ pAd->LatchRfRegs.Channel = Channel;
+#endif
+#ifdef RT30xx
+ RT30xxWriteRFRegister(pAd, RF_R24, RFValue);
+ RT30xxWriteRFRegister(pAd, RF_R31, RFValue);
+
+ // Enable RF tuning
+ RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
+ RFValue = RFValue | 0x1;
+ RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
+
+ // latch channel for future usage.
+ pAd->LatchRfRegs.Channel = Channel;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
+ Channel,
+ pAd->RfIcType,
+ TxPwer,
+ TxPwer2,
+ pAd->Antenna.field.TxPath,
+ FreqItems3020[index].N,
+ FreqItems3020[index].K,
+ FreqItems3020[index].R));
+#endif
+
+ break;
+ }
+ }
+
+#ifndef RT30xx
+ DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
+ Channel,
+ pAd->RfIcType,
+ TxPwer,
+ TxPwer2,
+ pAd->Antenna.field.TxPath,
+ FreqItems3020[index].N,
+ FreqItems3020[index].K,
+ FreqItems3020[index].R));
+#endif
+ }
+ else
+#endif // RT2870 //
{
RFRegTable = RF2850RegTable;
@@ -6149,6 +6349,53 @@ VOID AsicAntennaSelect(
IN PRTMP_ADAPTER pAd,
IN UCHAR Channel)
{
+#ifdef RT30xx
+ if (pAd->Mlme.OneSecPeriodicRound % 2 == 1)
+ {
+ // patch for AsicSetRxAnt failed
+ pAd->RxAnt.EvaluatePeriod = 0;
+
+ // check every 2 second. If rcv-beacon less than 5 in the past 2 second, then AvgRSSI is no longer a
+ // valid indication of the distance between this AP and its clients.
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
+ {
+ SHORT realavgrssi1;
+
+ // if no traffic then reset average rssi to trigger evaluation
+ if (pAd->StaCfg.NumOfAvgRssiSample < 5)
+ {
+ pAd->RxAnt.Pair1LastAvgRssi = (-99);
+ pAd->RxAnt.Pair2LastAvgRssi = (-99);
+ DBGPRINT(RT_DEBUG_TRACE, ("MlmePeriodicExec: no traffic/beacon, reset RSSI\n"));
+ }
+
+ pAd->StaCfg.NumOfAvgRssiSample = 0;
+ realavgrssi1 = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt] >> 3);
+
+ DBGPRINT(RT_DEBUG_TRACE,("Ant-realrssi0(%d), Lastrssi0(%d), EvaluateStableCnt=%d\n", realavgrssi1, pAd->RxAnt.Pair1LastAvgRssi, pAd->RxAnt.EvaluateStableCnt));
+
+ // if the difference between two rssi is larger or less than 5, then evaluate the other antenna
+ if ((pAd->RxAnt.EvaluateStableCnt < 2) || (realavgrssi1 > (pAd->RxAnt.Pair1LastAvgRssi + 5)) || (realavgrssi1 < (pAd->RxAnt.Pair1LastAvgRssi - 5)))
+ {
+ pAd->RxAnt.Pair1LastAvgRssi = realavgrssi1;
+ AsicEvaluateRxAnt(pAd);
+ }
+ }
+ else
+ {
+ // if not connected, always switch antenna to try to connect
+ UCHAR temp;
+
+ temp = pAd->RxAnt.Pair1PrimaryRxAnt;
+ pAd->RxAnt.Pair1PrimaryRxAnt = pAd->RxAnt.Pair1SecondaryRxAnt;
+ pAd->RxAnt.Pair1SecondaryRxAnt = temp;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("MlmePeriodicExec: no connect, switch to another one to try connection\n"));
+
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+ }
+ }
+#endif /* RT30xx */
}
/*
@@ -6218,11 +6465,13 @@ VOID AsicAdjustTxPower(
ULONG TxPwr[5];
CHAR Value;
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
|| (pAd->bPCIclkOff == TRUE)
|| RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)
|| RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
return;
+#endif
if (pAd->CommonCfg.BBPCurrentBW == BW_40)
{
@@ -6364,95 +6613,6 @@ VOID AsicAdjustTxPower(
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpR1);
BbpR1 &= 0xFC;
-#ifdef SINGLE_SKU
- // Handle regulatory max tx power constrain
- do
- {
- UCHAR TxPwrInEEPROM = 0xFF, CountryTxPwr = 0xFF, criterion;
- UCHAR AdjustMaxTxPwr[40];
-
- if (pAd->CommonCfg.Channel > 14) // 5G band
- TxPwrInEEPROM = ((pAd->CommonCfg.DefineMaxTxPwr & 0xFF00) >> 8);
- else // 2.4G band
- TxPwrInEEPROM = (pAd->CommonCfg.DefineMaxTxPwr & 0x00FF);
- CountryTxPwr = GetCuntryMaxTxPwr(pAd, pAd->CommonCfg.Channel);
-
- // error handling, range check
- if ((TxPwrInEEPROM > 0x50) || (CountryTxPwr > 0x50))
- {
- DBGPRINT(RT_DEBUG_ERROR,("AsicAdjustTxPower - Invalid max tx power (=0x%02x), CountryTxPwr=%d\n", TxPwrInEEPROM, CountryTxPwr));
- break;
- }
-
- criterion = *((PUCHAR)TxPwr + 2) & 0xF; // FAE use OFDM 6M as criterion
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (criterion=%d, TxPwrInEEPROM=%d, CountryTxPwr=%d)\n", criterion, TxPwrInEEPROM, CountryTxPwr));
-
- // Adjust max tx power according to the relationship of tx power in E2PROM
- for (i=0; i<5; i++)
- {
- // CCK will have 4dBm larger than OFDM
- // Therefore, we should separate to parse the tx power field
- if (i == 0)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- if (j < 4)
- {
- // CCK will have 4dBm larger than OFDM
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion) + 4;
- }
- else
- {
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- }
- else
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- }
- }
-
- // Adjust tx power according to the relationship
- for (i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- // The system tx power is larger than the regulatory, the power should be restrain
- if (AdjustMaxTxPwr[i*8+j] > CountryTxPwr)
- {
- // decrease to zero and don't need to take care BBPR1
- if ((Value - (AdjustMaxTxPwr[i*8+j] - CountryTxPwr)) > 0)
- Value -= (AdjustMaxTxPwr[i*8+j] - CountryTxPwr);
- else
- Value = 0;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- else
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d, no change)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
-
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
- }
- }
- } while (FALSE);
-#endif // SINGLE_SKU //
-
/* calculate delta power based on the percentage specified from UI */
// E2PROM setting is calibrated for maximum TX power (i.e. 100%)
// We lower TX power here according to the percentage specified from UI
@@ -6522,7 +6682,6 @@ VOID AsicAdjustTxPower(
}
-#ifdef CONFIG_STA_SUPPORT
/*
==========================================================================
Description:
@@ -6568,12 +6727,22 @@ VOID AsicForceSleep(
*/
VOID AsicForceWakeup(
IN PRTMP_ADAPTER pAd,
+#ifdef RT2860
IN UCHAR Level)
+#endif
+#ifdef RT2870
+ IN BOOLEAN bFromTx)
+#endif
{
DBGPRINT(RT_DEBUG_TRACE, ("--> AsicForceWakeup \n"));
+#ifdef RT2860
RT28XX_STA_FORCE_WAKEUP(pAd, Level);
+#endif
+#ifdef RT2870
+ RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx);
+#endif
}
-#endif // CONFIG_STA_SUPPORT //
+
/*
==========================================================================
Description:
@@ -6688,9 +6857,7 @@ VOID AsicDisableRDG(
Data &= 0xFFFFFF00;
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE)
-#ifdef DOT11_N_SUPPORT
&& (pAd->MacTab.fAnyStationMIMOPSDynamic == FALSE)
-#endif // DOT11_N_SUPPORT //
)
{
// For CWC test, change txop from 0x30 to 0x20 in TxBurst mode
@@ -6745,8 +6912,7 @@ VOID AsicEnableBssSync(
DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableBssSync(INFRA mode)\n"));
RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
{
csr.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
csr.field.bTsfTicking = 1;
@@ -6754,7 +6920,7 @@ VOID AsicEnableBssSync(
csr.field.bBeaconGen = 0; // do NOT generate BEACON
csr.field.bTBTTEnable = 1;
}
-#endif // CONFIG_STA_SUPPORT //
+
RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
}
@@ -6785,6 +6951,7 @@ VOID AsicEnableIbssSync(
csr9.field.bTsfTicking = 0;
RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
+#ifdef RT2860
// move BEACON TXD and frame content to on-chip memory
ptr = (PUCHAR)&pAd->BeaconTxWI;
for (i=0; i<TXWI_SIZE; i+=4) // 16-byte TXWI field
@@ -6802,6 +6969,24 @@ VOID AsicEnableIbssSync(
RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr);
ptr +=4;
}
+#endif
+#ifdef RT2870
+ // move BEACON TXD and frame content to on-chip memory
+ ptr = (PUCHAR)&pAd->BeaconTxWI;
+ for (i=0; i<TXWI_SIZE; i+=2) // 16-byte TXWI field
+ {
+ RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + i, ptr, 2);
+ ptr += 2;
+ }
+
+ // start right after the 16-byte TXWI field
+ ptr = pAd->BeaconBuf;
+ for (i=0; i< pAd->BeaconTxWI.MPDUtotalByteCount; i+=2)
+ {
+ RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, ptr, 2);
+ ptr +=2;
+ }
+#endif // RT2870 //
// start sending BEACON
csr9.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
@@ -6949,8 +7134,7 @@ VOID AsicSetEdcaParm(
Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI];
Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI];
Ac2Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
{
// Tuning for Wi-Fi WMM S06
if (pAd->CommonCfg.bWiFiTest &&
@@ -6958,15 +7142,22 @@ VOID AsicSetEdcaParm(
Ac2Cfg.field.Aifsn -= 1;
// Tuning for TGn Wi-Fi 5.2.32
- // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
+ // STA TestBed changes in this item: connexant legacy sta ==> broadcom 11n sta
if (STA_TGN_WIFI_ON(pAd) &&
pEdcaParm->Aifsn[QID_AC_VI] == 10)
{
Ac0Cfg.field.Aifsn = 3;
Ac2Cfg.field.AcTxop = 5;
}
+
+#ifdef RT30xx
+ if (pAd->RfIcType == RFIC_3020 || pAd->RfIcType == RFIC_2020)
+ {
+ // Tuning for WiFi WMM S3-T07: connexant legacy sta ==> broadcom 11n sta.
+ Ac2Cfg.field.Aifsn = 5;
+ }
+#endif // RT30xx //
}
-#endif // CONFIG_STA_SUPPORT //
Ac3Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VO];
Ac3Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VO];
@@ -7008,10 +7199,9 @@ VOID AsicSetEdcaParm(
CwminCsr.field.Cwmin0 = pEdcaParm->Cwmin[QID_AC_BE];
CwminCsr.field.Cwmin1 = pEdcaParm->Cwmin[QID_AC_BK];
CwminCsr.field.Cwmin2 = pEdcaParm->Cwmin[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- CwminCsr.field.Cwmin3 = pEdcaParm->Cwmin[QID_AC_VO] - 1; //for TGn wifi test
-#endif // CONFIG_STA_SUPPORT //
+
+ CwminCsr.field.Cwmin3 = pEdcaParm->Cwmin[QID_AC_VO] - 1; //for TGn wifi test
+
RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
CwmaxCsr.word = 0;
@@ -7025,8 +7215,7 @@ VOID AsicSetEdcaParm(
AifsnCsr.field.Aifsn0 = Ac0Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_BE];
AifsnCsr.field.Aifsn1 = Ac1Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_BK];
AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
{
// Tuning for Wi-Fi WMM S06
if (pAd->CommonCfg.bWiFiTest &&
@@ -7034,20 +7223,25 @@ VOID AsicSetEdcaParm(
AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn - 4;
// Tuning for TGn Wi-Fi 5.2.32
- // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
+ // STA TestBed changes in this item: connexant legacy sta ==> broadcom 11n sta
if (STA_TGN_WIFI_ON(pAd) &&
pEdcaParm->Aifsn[QID_AC_VI] == 10)
{
AifsnCsr.field.Aifsn0 = 3;
AifsnCsr.field.Aifsn2 = 7;
}
+#ifdef RT2870
+ if (INFRA_ON(pAd))
+ CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_WMM_CAPABLE);
+#endif
}
-#endif // CONFIG_STA_SUPPORT //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AifsnCsr.field.Aifsn3 = Ac3Cfg.field.Aifsn - 1; //pEdcaParm->Aifsn[QID_AC_VO]; //for TGn wifi test
-#endif // CONFIG_STA_SUPPORT //
+ AifsnCsr.field.Aifsn3 = Ac3Cfg.field.Aifsn - 1; //pEdcaParm->Aifsn[QID_AC_VO]; //for TGn wifi test
+#ifdef RT30xx
+ if (pAd->RfIcType == RFIC_3020 || pAd->RfIcType == RFIC_2020)
+ AifsnCsr.field.Aifsn2 = 0x2; //pEdcaParm->Aifsn[QID_AC_VI]; //for WiFi WMM S4-T04.
+#endif // RT30xx //
+
RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, AifsnCsr.word);
NdisMoveMemory(&pAd->CommonCfg.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
@@ -7098,10 +7292,8 @@ VOID AsicSetSlotTime(
ULONG SlotTime;
UINT32 RegValue = 0;
-#ifdef CONFIG_STA_SUPPORT
if (pAd->CommonCfg.Channel > 14)
bUseShortSlotTime = TRUE;
-#endif // CONFIG_STA_SUPPORT //
if (bUseShortSlotTime)
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
@@ -7110,36 +7302,31 @@ VOID AsicSetSlotTime(
SlotTime = (bUseShortSlotTime)? 9 : 20;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
+#ifndef RT30xx
// force using short SLOT time for FAE to demo performance when TxBurst is ON
if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)))
-#ifdef DOT11_N_SUPPORT
|| ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE))
-#endif // DOT11_N_SUPPORT //
)
{
// In this case, we will think it is doing Wi-Fi test
// And we will not set to short slot when bEnableTxBurst is TRUE.
}
else if (pAd->CommonCfg.bEnableTxBurst)
+#endif
+#ifdef RT30xx
+ if (pAd->CommonCfg.bEnableTxBurst)
+#endif
SlotTime = 9;
}
-#endif // CONFIG_STA_SUPPORT //
//
// For some reasons, always set it to short slot time.
//
// ToDo: Should consider capability with 11B
//
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.BssType == BSS_ADHOC)
- SlotTime = 20;
- }
-#endif // CONFIG_STA_SUPPORT //
+ if (pAd->StaCfg.BssType == BSS_ADHOC)
+ SlotTime = 20;
RTMP_IO_READ32(pAd, BKOFF_SLOT_CFG, &RegValue);
RegValue = RegValue & 0xFFFFFF00;
@@ -7170,7 +7357,9 @@ VOID AsicAddSharedKeyEntry(
{
ULONG offset; //, csr0;
SHAREDKEY_MODE_STRUC csr1;
+#ifdef RT2860
INT i;
+#endif
DBGPRINT(RT_DEBUG_TRACE, ("AsicAddSharedKeyEntry BssIndex=%d, KeyIdx=%d\n", BssIndex,KeyIdx));
//============================================================================================
@@ -7192,28 +7381,43 @@ VOID AsicAddSharedKeyEntry(
//
// fill key material - key + TX MIC + RX MIC
//
+
offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE;
+#ifdef RT2860
for (i=0; i<MAX_LEN_OF_SHARE_KEY; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
}
-
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_SHARE_KEY);
+#endif
offset += MAX_LEN_OF_SHARE_KEY;
if (pTxMic)
{
+#ifdef RT2860
for (i=0; i<8; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, pTxMic, 8);
+#endif
}
offset += 8;
if (pRxMic)
{
+#ifdef RT2860
for (i=0; i<8; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, pRxMic, 8);
+#endif
}
@@ -7389,7 +7593,9 @@ VOID AsicAddKeyEntry(
PUCHAR pTxtsc = pCipherKey->TxTsc;
UCHAR CipherAlg = pCipherKey->CipherAlg;
SHAREDKEY_MODE_STRUC csr1;
+#ifdef RT2860
UCHAR i;
+#endif
DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n"));
//
@@ -7404,10 +7610,15 @@ VOID AsicAddKeyEntry(
// 2.) Set Key to Asic
//
//for (i = 0; i < KeyLen; i++)
+#ifdef RT2860
for (i = 0; i < MAX_LEN_OF_PEER_KEY; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_PEER_KEY);
+#endif
offset += MAX_LEN_OF_PEER_KEY;
//
@@ -7415,19 +7626,29 @@ VOID AsicAddKeyEntry(
//
if (pTxMic)
{
+#ifdef RT2860
for (i = 0; i < 8; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, pTxMic, 8);
+#endif
}
offset += LEN_TKIP_TXMICK;
if (pRxMic)
{
+#ifdef RT2860
for (i = 0; i < 8; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, pRxMic, 8);
+#endif
}
@@ -7437,6 +7658,7 @@ VOID AsicAddKeyEntry(
//
if (bTxKey)
{
+#ifdef RT2860
offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
//
// Write IV
@@ -7460,6 +7682,26 @@ VOID AsicAddKeyEntry(
RTMP_IO_WRITE8(pAd, offset + i, pTxtsc[i + 2]);
}
+#endif
+#ifdef RT2870
+ UINT32 tmpVal;
+
+ //
+ // Write IV
+ //
+ IV4 = (KeyIdx << 6);
+ if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) ||(CipherAlg == CIPHER_AES))
+ IV4 |= 0x20; // turn on extension bit means EIV existence
+
+ tmpVal = pTxtsc[1] + (((pTxtsc[1] | 0x20) & 0x7f) << 8) + (pTxtsc[0] << 16) + (IV4 << 24);
+ RTMP_IO_WRITE32(pAd, offset, tmpVal);
+
+ //
+ // Write EIV
+ //
+ offset += 4;
+ RTMP_IO_WRITE32(pAd, offset, *(PUINT32)&pCipherKey->TxTsc[2]);
+#endif // RT2870 //
AsicUpdateWCIDAttribute(pAd, WCID, BssIndex, CipherAlg, bUsePairewiseKeyTable);
}
@@ -7524,10 +7766,15 @@ VOID AsicAddPairwiseKeyEntry(
// EKEY
offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
+#ifdef RT2860
for (i=0; i<MAX_LEN_OF_PEER_KEY; i++)
{
RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, &pCipherKey->Key[0], MAX_LEN_OF_PEER_KEY);
+#endif // RT2870 //
for (i=0; i<MAX_LEN_OF_PEER_KEY; i+=4)
{
UINT32 Value;
@@ -7539,18 +7786,28 @@ VOID AsicAddPairwiseKeyEntry(
// MIC KEY
if (pTxMic)
{
+#ifdef RT2860
for (i=0; i<8; i++)
{
RTMP_IO_WRITE8(pAd, offset+i, pTxMic[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, &pCipherKey->TxMic[0], 8);
+#endif // RT2870 //
}
offset += 8;
if (pRxMic)
{
+#ifdef RT2860
for (i=0; i<8; i++)
{
RTMP_IO_WRITE8(pAd, offset+i, pRxMic[i]);
}
+#endif
+#ifdef RT2870
+ RTUSBMultiWrite(pAd, offset, &pCipherKey->RxMic[0], 8);
+#endif // RT2870 //
}
DBGPRINT(RT_DEBUG_TRACE,("AsicAddPairwiseKeyEntry: WCID #%d Alg=%s\n",WCID, CipherName[CipherAlg]));
@@ -7599,9 +7856,7 @@ BOOLEAN AsicSendCommandToMcu(
HOST_CMD_CSR_STRUC H2MCmd;
H2M_MAILBOX_STRUC H2MMailbox;
ULONG i = 0;
-#ifdef RALINK_ATE
- static UINT32 j = 0;
-#endif // RALINK_ATE //
+
do
{
RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
@@ -7613,31 +7868,8 @@ BOOLEAN AsicSendCommandToMcu(
if (i >= 100)
{
-#ifdef RALINK_ATE
- if (pAd->ate.bFWLoading == TRUE)
- {
- /* reloading firmware when received iwpriv cmd "ATE=ATESTOP" */
- if (j > 0)
- {
- if (j % 64 != 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("#"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("\n"));
- }
- ++j;
- }
- else if (j == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Loading firmware. Please wait for a moment...\n"));
- ++j;
- }
- }
- else
-#endif // RALINK_ATE //
{
+#ifdef RT2860
UINT32 Data;
// Reset DMA
@@ -7659,21 +7891,15 @@ BOOLEAN AsicSendCommandToMcu(
RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
Data &= 0xfffffffd;
RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
+#endif /* RT2860 */
DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
}
//return FALSE;
+#ifdef RT2870
+ return FALSE;
+#endif
}
-#ifdef RALINK_ATE
- else if (pAd->ate.bFWLoading == TRUE)
- {
- /* reloading of firmware is completed */
- pAd->ate.bFWLoading = FALSE;
- DBGPRINT(RT_DEBUG_ERROR, ("\n"));
- j = 0;
- }
-#endif // RALINK_ATE //
-
H2MMailbox.field.Owner = 1; // pass ownership to MCU
H2MMailbox.field.CmdToken = Token;
H2MMailbox.field.HighByte = Arg1;
@@ -7691,6 +7917,7 @@ BOOLEAN AsicSendCommandToMcu(
return TRUE;
}
+#ifdef RT2860
BOOLEAN AsicCheckCommanOk(
IN PRTMP_ADAPTER pAd,
IN UCHAR Command)
@@ -7755,6 +7982,7 @@ BOOLEAN AsicCheckCommanOk(
return FALSE;
}
+#endif /* RT8260 */
/*
========================================================================
@@ -7797,8 +8025,6 @@ VOID RTMPCheckRates(
NdisMoveMemory(SupRate, NewRate, NewRateLen);
}
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
BOOLEAN RTMPCheckChannel(
IN PRTMP_ADAPTER pAd,
IN UCHAR CentralChannel,
@@ -7944,8 +8170,6 @@ BOOLEAN RTMPCheckHt(
COPY_AP_HTSETTINGS_FROM_BEACON(pAd, pHtCapability);
return TRUE;
}
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
/*
========================================================================
@@ -7978,10 +8202,8 @@ VOID RTMPUpdateMlmeRate(
MinimumRate = RATE_1;
break;
case PHY_11BG_MIXED:
-#ifdef DOT11_N_SUPPORT
case PHY_11ABGN_MIXED:
case PHY_11BGN_MIXED:
-#endif // DOT11_N_SUPPORT //
if ((pAd->MlmeAux.SupRateLen == 4) &&
(pAd->MlmeAux.ExtRateLen == 0))
// B only AP
@@ -7995,13 +8217,11 @@ VOID RTMPUpdateMlmeRate(
MinimumRate = RATE_6;
break;
case PHY_11A:
-#ifdef DOT11_N_SUPPORT
case PHY_11N_2_4G: // rt2860 need to check mlmerate for 802.11n
case PHY_11GN_MIXED:
case PHY_11AGN_MIXED:
case PHY_11AN_MIXED:
case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
ProperMlmeRate = RATE_24;
MinimumRate = RATE_6;
break;
@@ -8111,6 +8331,58 @@ CHAR RTMPMaxRssi(
return larger;
}
+#ifdef RT30xx
+// Antenna divesity use GPIO3 and EESK pin for control
+// Antenna and EEPROM access are both using EESK pin,
+// Therefor we should avoid accessing EESK at the same time
+// Then restore antenna after EEPROM access
+VOID AsicSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant)
+{
+#ifdef RT30xx
+ UINT32 Value;
+ UINT32 x;
+
+ if ((pAd->EepromAccess) ||
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) ||
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
+ {
+ return;
+ }
+
+ // the antenna selection is through firmware and MAC register(GPIO3)
+ if (Ant == 0)
+ {
+ // Main antenna
+ RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
+ x |= (EESK);
+ RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
+
+ RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
+ Value &= ~(0x0808);
+ RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to main antenna\n"));
+ }
+ else
+ {
+ // Aux antenna
+ RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
+ x &= ~(EESK);
+ RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
+
+ RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
+ Value &= ~(0x0808);
+ Value |= 0x08;
+ RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to aux antenna\n"));
+ }
+#endif // RT30xx //
+}
+#endif /* RT30xx */
+
/*
========================================================================
Routine Description:
@@ -8129,14 +8401,7 @@ VOID AsicEvaluateRxAnt(
{
UCHAR BBPR3 = 0;
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+#ifndef RT30xx
{
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
fRTMP_ADAPTER_HALT_IN_PROGRESS |
@@ -8148,7 +8413,6 @@ VOID AsicEvaluateRxAnt(
if (pAd->StaCfg.Psm == PWR_SAVE)
return;
}
-#endif // CONFIG_STA_SUPPORT //
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
BBPR3 &= (~0x18);
@@ -8165,10 +8429,11 @@ VOID AsicEvaluateRxAnt(
BBPR3 |= (0x0);
}
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+
+#ifdef RT2860
pAd->StaCfg.BBPR3 = BBPR3;
-#endif // CONFIG_STA_SUPPORT //
+#endif
+#ifdef RT2870
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
)
{
@@ -8187,6 +8452,90 @@ VOID AsicEvaluateRxAnt(
pAd->Mlme.bLowThroughput = TRUE;
}
}
+#endif
+#endif /* RT30xx */
+#ifdef RT30xx
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
+ fRTMP_ADAPTER_HALT_IN_PROGRESS |
+ fRTMP_ADAPTER_RADIO_OFF |
+ fRTMP_ADAPTER_NIC_NOT_EXIST |
+ fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS) ||
+ OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
+#ifdef RT30xx
+ || (pAd->EepromAccess)
+#endif // RT30xx //
+ )
+ return;
+
+
+ {
+ //if (pAd->StaCfg.Psm == PWR_SAVE)
+ // return;
+ }
+
+ // two antenna selection mechanism- one is antenna diversity, the other is failed antenna remove
+ // one is antenna diversity:there is only one antenna can rx and tx
+ // the other is failed antenna remove:two physical antenna can rx and tx
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("AntDiv - before evaluate Pair1-Ant (%d,%d)\n",
+ pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
+
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1SecondaryRxAnt);
+
+ pAd->RxAnt.EvaluatePeriod = 1; // 1:Means switch to SecondaryRxAnt, 0:Means switch to Pair1PrimaryRxAnt
+ pAd->RxAnt.FirstPktArrivedWhenEvaluate = FALSE;
+ pAd->RxAnt.RcvPktNumWhenEvaluate = 0;
+
+ // a one-shot timer to end the evalution
+ // dynamic adjust antenna evaluation period according to the traffic
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
+ RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 100);
+ else
+ RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300);
+ }
+ else
+ {
+ if (pAd->StaCfg.Psm == PWR_SAVE)
+ return;
+
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
+ BBPR3 &= (~0x18);
+ if(pAd->Antenna.field.RxPath == 3)
+ {
+ BBPR3 |= (0x10);
+ }
+ else if(pAd->Antenna.field.RxPath == 2)
+ {
+ BBPR3 |= (0x8);
+ }
+ else if(pAd->Antenna.field.RxPath == 1)
+ {
+ BBPR3 |= (0x0);
+ }
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
+ }
+#endif /* RT30xx */
+
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
+ )
+ {
+ ULONG TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
+ pAd->RalinkCounters.OneSecTxRetryOkCount +
+ pAd->RalinkCounters.OneSecTxFailCount;
+
+ // dynamic adjust antenna evaluation period according to the traffic
+ if (TxTotalCnt > 50)
+ {
+ RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 20);
+ pAd->Mlme.bLowThroughput = FALSE;
+ }
+ else
+ {
+ RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300);
+ pAd->Mlme.bLowThroughput = TRUE;
+ }
+ }
}
/*
@@ -8209,19 +8558,10 @@ VOID AsicRxAntEvalTimeout(
IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-#ifdef CONFIG_STA_SUPPORT
UCHAR BBPR3 = 0;
CHAR larger = -127, rssi0, rssi1, rssi2;
-#endif // CONFIG_STA_SUPPORT //
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+#ifndef RT30xx
{
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
@@ -8279,11 +8619,111 @@ VOID AsicRxAntEvalTimeout(
BBPR3 |= (0x0);
}
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
+#ifdef RT2860
pAd->StaCfg.BBPR3 = BBPR3;
+#endif
}
+#endif /* RT30xx */
+#ifdef RT30xx
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
+ fRTMP_ADAPTER_HALT_IN_PROGRESS |
+ fRTMP_ADAPTER_RADIO_OFF |
+ fRTMP_ADAPTER_NIC_NOT_EXIST) ||
+ OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
+#ifdef RT30xx
+ || (pAd->EepromAccess)
+#endif // RT30xx //
+ )
+ return;
-#endif // CONFIG_STA_SUPPORT //
+ {
+ //if (pAd->StaCfg.Psm == PWR_SAVE)
+ // return;
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ if ((pAd->RxAnt.RcvPktNumWhenEvaluate != 0) && (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >= pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt]))
+ {
+ UCHAR temp;
+
+ //
+ // select PrimaryRxAntPair
+ // Role change, Used Pair1SecondaryRxAnt as PrimaryRxAntPair.
+ // Since Pair1SecondaryRxAnt Quality good than Pair1PrimaryRxAnt
+ //
+ temp = pAd->RxAnt.Pair1PrimaryRxAnt;
+ pAd->RxAnt.Pair1PrimaryRxAnt = pAd->RxAnt.Pair1SecondaryRxAnt;
+ pAd->RxAnt.Pair1SecondaryRxAnt = temp;
+
+ pAd->RxAnt.Pair1LastAvgRssi = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >> 3);
+ pAd->RxAnt.EvaluateStableCnt = 0;
+ }
+ else
+ {
+ // if the evaluated antenna is not better than original, switch back to original antenna
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+ pAd->RxAnt.EvaluateStableCnt ++;
+ }
+
+ pAd->RxAnt.EvaluatePeriod = 0; // 1:Means switch to SecondaryRxAnt, 0:Means switch to Pair1PrimaryRxAnt
+
+ DBGPRINT(RT_DEBUG_TRACE,("AsicRxAntEvalAction::After Eval(fix in #%d), <%d, %d>, RcvPktNumWhenEvaluate=%ld\n",
+ pAd->RxAnt.Pair1PrimaryRxAnt, (pAd->RxAnt.Pair1AvgRssi[0] >> 3), (pAd->RxAnt.Pair1AvgRssi[1] >> 3), pAd->RxAnt.RcvPktNumWhenEvaluate));
+ }
+ else
+ {
+ if (pAd->StaCfg.Psm == PWR_SAVE)
+ return;
+
+ // if the traffic is low, use average rssi as the criteria
+ if (pAd->Mlme.bLowThroughput == TRUE)
+ {
+ rssi0 = pAd->StaCfg.RssiSample.LastRssi0;
+ rssi1 = pAd->StaCfg.RssiSample.LastRssi1;
+ rssi2 = pAd->StaCfg.RssiSample.LastRssi2;
+ }
+ else
+ {
+ rssi0 = pAd->StaCfg.RssiSample.AvgRssi0;
+ rssi1 = pAd->StaCfg.RssiSample.AvgRssi1;
+ rssi2 = pAd->StaCfg.RssiSample.AvgRssi2;
+ }
+
+ if(pAd->Antenna.field.RxPath == 3)
+ {
+ larger = max(rssi0, rssi1);
+
+ if (larger > (rssi2 + 20))
+ pAd->Mlme.RealRxPath = 2;
+ else
+ pAd->Mlme.RealRxPath = 3;
+ }
+ else if(pAd->Antenna.field.RxPath == 2)
+ {
+ if (rssi0 > (rssi1 + 20))
+ pAd->Mlme.RealRxPath = 1;
+ else
+ pAd->Mlme.RealRxPath = 2;
+ }
+
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
+ BBPR3 &= (~0x18);
+ if(pAd->Mlme.RealRxPath == 3)
+ {
+ BBPR3 |= (0x10);
+ }
+ else if(pAd->Mlme.RealRxPath == 2)
+ {
+ BBPR3 |= (0x8);
+ }
+ else if(pAd->Mlme.RealRxPath == 1)
+ {
+ BBPR3 |= (0x0);
+ }
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
+ }
+ }
+#endif /* RT30xx */
}
@@ -8350,9 +8790,6 @@ BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
{
BOOLEAN result = TRUE;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// only associated STA counts
if (pEntry && (pEntry->ValidAsCLI) && (pEntry->Sst == SST_ASSOC))
@@ -8361,15 +8798,7 @@ BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
}
else
result = FALSE;
-
-#ifdef QOS_DLS_SUPPORT
- if (pEntry && (pEntry->ValidAsDls))
- result = pAd->StaCfg.bAutoTxRateSwitch;
-#endif // QOS_DLS_SUPPORT //
}
-#endif // CONFIG_STA_SUPPORT //
-
-
return result;
}
@@ -8378,14 +8807,9 @@ BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
BOOLEAN RTMPAutoRateSwitchCheck(
IN PRTMP_ADAPTER pAd)
{
+ if (pAd->StaCfg.bAutoTxRateSwitch)
+ return TRUE;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.bAutoTxRateSwitch)
- return TRUE;
- }
-#endif // CONFIG_STA_SUPPORT //
return FALSE;
}
@@ -8411,13 +8835,7 @@ UCHAR RTMPStaFixedTxMode(
{
UCHAR tx_mode = FIXED_TXMODE_HT;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- tx_mode = (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode;
- }
-#endif // CONFIG_STA_SUPPORT //
+ tx_mode = (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode;
return tx_mode;
}
@@ -8474,7 +8892,6 @@ VOID RTMPUpdateLegacyTxSetting(
}
}
-#ifdef CONFIG_STA_SUPPORT
/*
==========================================================================
Description:
@@ -8505,7 +8922,12 @@ VOID AsicStaBbpTuning(
&& (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
)
&& !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+#ifdef RT2860
&& (pAd->bPCIclkOff == FALSE))
+#endif
+#ifdef RT2870
+ )
+#endif
{
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value);
R66 = OrigR66Value;
@@ -8517,6 +8939,45 @@ VOID AsicStaBbpTuning(
if (pAd->LatchRfRegs.Channel <= 14)
{ //BG band
+#ifdef RT2870
+ // RT3070 is a no LNA solution, it should have different control regarding to AGC gain control
+ // Otherwise, it will have some throughput side effect when low RSSI
+#ifndef RT30xx
+ if (IS_RT3070(pAd))
+#endif
+#ifdef RT30xx
+ if (IS_RT30xx(pAd))
+#endif
+ {
+ if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
+ {
+ R66 = 0x1C + 2*GET_LNA_GAIN(pAd) + 0x20;
+ if (OrigR66Value != R66)
+ {
+#ifndef RT30xx
+ RTUSBWriteBBPRegister(pAd, BBP_R66, R66);
+#endif
+#ifdef RT30xx
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
+#endif
+ }
+ }
+ else
+ {
+ R66 = 0x1C + 2*GET_LNA_GAIN(pAd);
+ if (OrigR66Value != R66)
+ {
+#ifndef RT30xx
+ RTUSBWriteBBPRegister(pAd, BBP_R66, R66);
+#endif
+#ifdef RT30xx
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
+#endif
+ }
+ }
+ }
+ else
+#endif // RT2870 //
{
if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
{
@@ -8582,6 +9043,7 @@ VOID AsicStaBbpTuning(
}
}
+#ifdef RT2860
VOID AsicResetFromDMABusy(
IN PRTMP_ADAPTER pAd)
{
@@ -8681,7 +9143,7 @@ VOID AsicResetPBF(
DBGPRINT(RT_DEBUG_TRACE, ("<--- Asic HardReset PBF !!!! \n"));
}
}
-#endif // CONFIG_STA_SUPPORT //
+#endif /* RT2860 */
VOID RTMPSetAGCInitValue(
IN PRTMP_ADAPTER pAd,
@@ -8701,13 +9163,11 @@ VOID RTMPSetAGCInitValue(
R66 = (UCHAR)(0x32 + (GET_LNA_GAIN(pAd)*5)/3);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
}
-#ifdef DOT11_N_SUPPORT
else
{
R66 = (UCHAR)(0x3A + (GET_LNA_GAIN(pAd)*5)/3);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
}
-#endif // DOT11_N_SUPPORT //
}
}
@@ -8722,6 +9182,15 @@ VOID AsicTurnOffRFClk(
UCHAR index;
RTMP_RF_REGS *RFRegTable;
+#ifdef RT30xx
+ // The RF programming sequence is difference between 3xxx and 2xxx
+ if (IS_RT3090(pAd))
+ {
+ RT30xxLoadRFSleepModeSetup(pAd); // add by johnli, RF power sequence setup, load RF sleep-mode setup
+ }
+ else
+ {
+#endif // RT30xx //
RFRegTable = RF2850RegTable;
switch (pAd->RfIcType)
@@ -8763,6 +9232,10 @@ VOID AsicTurnOffRFClk(
default:
break;
}
+#ifdef RT30xx
+ }
+#endif // RT30xx //
+
}
@@ -8776,6 +9249,14 @@ VOID AsicTurnOnRFClk(
UCHAR index;
RTMP_RF_REGS *RFRegTable;
+#ifdef RT30xx
+ // The RF programming sequence is difference between 3xxx and 2xxx
+ if (IS_RT3090(pAd))
+ {
+ }
+ else
+ {
+#endif // RT30xx //
RFRegTable = RF2850RegTable;
switch (pAd->RfIcType)
@@ -8822,9 +9303,14 @@ VOID AsicTurnOnRFClk(
break;
}
+#ifndef RT30xx
DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOnRFClk#%d(RF=%d, ) , R2=0x%08x\n",
Channel,
pAd->RfIcType,
R2));
+#endif
+#ifdef RT30xx
+ }
+#endif // RT30xx //
}
diff --git a/drivers/staging/rt2860/common/netif_block.c b/drivers/staging/rt2860/common/netif_block.c
deleted file mode 100644
index d3f7d087e7f0..000000000000
--- a/drivers/staging/rt2860/common/netif_block.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "../rt_config.h"
-#include "netif_block.h"
-
-static NETIF_ENTRY freeNetIfEntryPool[FREE_NETIF_POOL_SIZE];
-static LIST_HEADER freeNetIfEntryList;
-
-void initblockQueueTab(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
-
- initList(&freeNetIfEntryList);
- for (i = 0; i < FREE_NETIF_POOL_SIZE; i++)
- insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)&freeNetIfEntryPool[i]);
-
- for (i=0; i < NUM_OF_TX_RING; i++)
- initList(&pAd->blockQueueTab[i].NetIfList);
-
- return;
-}
-
-BOOLEAN blockNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
- IN PNET_DEV pNetDev)
-{
- PNETIF_ENTRY pNetIfEntry = NULL;
-
- if ((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(&freeNetIfEntryList)) != NULL)
- {
- netif_stop_queue(pNetDev);
- pNetIfEntry->pNetDev = pNetDev;
- insertTailList(&pBlockQueueEntry->NetIfList, (PLIST_ENTRY)pNetIfEntry);
-
- pBlockQueueEntry->SwTxQueueBlockFlag = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("netif_stop_queue(%s)\n", pNetDev->name));
- }
- else
- return FALSE;
-
- return TRUE;
-}
-
-VOID releaseNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry)
-{
- PNETIF_ENTRY pNetIfEntry = NULL;
- PLIST_HEADER pNetIfList = &pBlockQueueEntry->NetIfList;
-
- while((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(pNetIfList)) != NULL)
- {
- PNET_DEV pNetDev = pNetIfEntry->pNetDev;
- netif_wake_queue(pNetDev);
- insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)pNetIfEntry);
-
- DBGPRINT(RT_DEBUG_TRACE, ("netif_wake_queue(%s)\n", pNetDev->name));
- }
- pBlockQueueEntry->SwTxQueueBlockFlag = FALSE;
- return;
-}
-
-
-VOID StopNetIfQueue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- PNET_DEV NetDev = NULL;
- UCHAR IfIdx = 0;
- BOOLEAN valid = FALSE;
-
-#ifdef APCLI_SUPPORT
- if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_APCLI)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_APCLI) % MAX_APCLI_NUM;
- NetDev = pAd->ApCfg.ApCliTab[IfIdx].dev;
- }
- else
-#endif // APCLI_SUPPORT //
-#ifdef WDS_SUPPORT
- if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_WDS)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_WDS) % MAX_WDS_ENTRY;
- NetDev = pAd->WdsTab.WdsEntry[IfIdx].dev;
- }
- else
-#endif // WDS_SUPPORT //
- {
-#ifdef MBSS_SUPPORT
- if (pAd->OpMode == OPMODE_AP)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_MBSSID) % MAX_MBSSID_NUM;
- NetDev = pAd->ApCfg.MBSSID[IfIdx].MSSIDDev;
- }
- else
- {
- IfIdx = MAIN_MBSSID;
- NetDev = pAd->net_dev;
- }
-#else
- IfIdx = MAIN_MBSSID;
- NetDev = pAd->net_dev;
-#endif
- }
-
- // WMM support 4 software queues.
- // One software queue full doesn't mean device have no capbility to transmit packet.
- // So disable block Net-If queue function while WMM enable.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- valid = (pAd->CommonCfg.bWmmCapable == TRUE) ? FALSE : TRUE;
-#endif // CONFIG_STA_SUPPORT //
-
- if (valid)
- blockNetIf(&pAd->blockQueueTab[QueIdx], NetDev);
- return;
-}
-
diff --git a/drivers/staging/rt2860/common/netif_block.h b/drivers/staging/rt2860/common/netif_block.h
deleted file mode 100644
index 6e5151c41095..000000000000
--- a/drivers/staging/rt2860/common/netif_block.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __NET_IF_BLOCK_H__
-#define __NET_IF_BLOCK_H__
-
-//#include <linux/device.h>
-#include "link_list.h"
-#include "rtmp.h"
-
-#define FREE_NETIF_POOL_SIZE 32
-
-typedef struct _NETIF_ENTRY
-{
- struct _NETIF_ENTRY *pNext;
- PNET_DEV pNetDev;
-} NETIF_ENTRY, *PNETIF_ENTRY;
-
-void initblockQueueTab(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN blockNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
- IN PNET_DEV pNetDev);
-
-VOID releaseNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry);
-
-VOID StopNetIfQueue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-#endif // __NET_IF_BLOCK_H__
-
diff --git a/drivers/staging/rt2860/common/rtmp_init.c b/drivers/staging/rt2860/common/rtmp_init.c
index 8a00cee3ee91..c2facac5cf88 100644
--- a/drivers/staging/rt2860/common/rtmp_init.c
+++ b/drivers/staging/rt2860/common/rtmp_init.c
@@ -38,8 +38,18 @@
Jan Lee 2006-09-15 RT2860. Change for 802.11n , EEPROM, Led, BA, HT.
*/
#include "../rt_config.h"
-#include "firmware.h"
+#ifndef RT30xx
+#ifdef RT2860
+#include "firmware.h"
#include <linux/bitrev.h>
+#endif
+#ifdef RT2870
+#include "../../rt2870/common/firmware.h"
+#endif
+#endif
+#ifdef RT30xx
+#include "../../rt3070/firmware.h"
+#endif
UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008,
@@ -90,6 +100,22 @@ const unsigned short ccitt_16Table[] = {
#define ByteCRC16(v, crc) \
(unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])
+#ifdef RT2870
+unsigned char BitReverse(unsigned char x)
+{
+ int i;
+ unsigned char Temp=0;
+ for(i=0; ; i++)
+ {
+ if(x & 0x80) Temp |= 0x80;
+ if(i==7) break;
+ x <<= 1;
+ Temp >>= 1;
+ }
+ return Temp;
+}
+#endif
+
//
// BBP register initialization set
//
@@ -114,6 +140,38 @@ REG_PAIR BBPRegTable[] = {
//
// RF register initialization set
//
+#ifdef RT2870
+REG_PAIR RT30xx_RFRegTable[] = {
+ {RF_R04, 0x40},
+ {RF_R05, 0x03},
+ {RF_R06, 0x02},
+ {RF_R07, 0x70},
+ {RF_R09, 0x0F},
+#ifndef RT30xx
+ {RF_R10, 0x71},
+#endif
+#ifdef RT30xx
+ {RF_R10, 0x41},
+#endif
+ {RF_R11, 0x21},
+ {RF_R12, 0x7B},
+ {RF_R14, 0x90},
+ {RF_R15, 0x58},
+ {RF_R16, 0xB3},
+ {RF_R17, 0x92},
+ {RF_R18, 0x2C},
+ {RF_R19, 0x02},
+ {RF_R20, 0xBA},
+ {RF_R21, 0xDB},
+ {RF_R24, 0x16},
+ {RF_R25, 0x01},
+#ifndef RT30xx
+ {RF_R27, 0x03},
+#endif
+ {RF_R29, 0x1F},
+};
+#define NUM_RF_REG_PARMS (sizeof(RT30xx_RFRegTable) / sizeof(REG_PAIR))
+#endif // RT2870 //
//
// ASIC register initialization sets
@@ -146,10 +204,18 @@ RTMP_REG_PAIR MACRegTable[] = {
{AUTO_RSP_CFG, 0x00000013}, // Initial Auto_Responder, because QA will turn off Auto-Responder
{CCK_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
{OFDM_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
+//PS packets use Tx1Q (for HCCA) when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
+#ifdef RT2870
+ {PBF_CFG, 0xf40006}, // Only enable Queue 2
+ {MM40_PROT_CFG, 0x3F44084}, // Initial Auto_Responder, because QA will turn off Auto-Responder
+ {WPDMA_GLO_CFG, 0x00000030},
+#endif // RT2870 //
{GF20_PROT_CFG, 0x01744004}, // set 19:18 --> Short NAV for MIMO PS
{GF40_PROT_CFG, 0x03F44084},
{MM20_PROT_CFG, 0x01744004},
+#ifdef RT2860
{MM40_PROT_CFG, 0x03F54084},
+#endif
{TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f*/ /*0x000024bf*/}, //Extension channel backoff.
{TX_RTS_CFG, 0x00092b20},
{EXP_ACK_TIME, 0x002400ca}, // default value
@@ -163,20 +229,22 @@ RTMP_REG_PAIR MACRegTable[] = {
{PWR_PIN_CFG, 0x00000003}, // patch for 2880-E
};
-
-#ifdef CONFIG_STA_SUPPORT
RTMP_REG_PAIR STAMACRegTable[] = {
{WMM_AIFSN_CFG, 0x00002273},
{WMM_CWMIN_CFG, 0x00002344},
{WMM_CWMAX_CFG, 0x000034aa},
};
-#endif // CONFIG_STA_SUPPORT //
#define NUM_MAC_REG_PARMS (sizeof(MACRegTable) / sizeof(RTMP_REG_PAIR))
-#ifdef CONFIG_STA_SUPPORT
#define NUM_STA_MAC_REG_PARMS (sizeof(STAMACRegTable) / sizeof(RTMP_REG_PAIR))
-#endif // CONFIG_STA_SUPPORT //
+#ifdef RT2870
+//
+// RT2870 Firmware Spec only used 1 oct for version expression
+//
+#define FIRMWARE_MINOR_VERSION 7
+
+#endif // RT2870 //
// New 8k byte firmware size for RT3071/RT3072
#define FIRMWAREIMAGE_MAX_LENGTH 0x2000
@@ -186,7 +254,9 @@ RTMP_REG_PAIR STAMACRegTable[] = {
#define FIRMWAREIMAGEV1_LENGTH 0x1000
#define FIRMWAREIMAGEV2_LENGTH 0x1000
+#ifdef RT2860
#define FIRMWARE_MINOR_VERSION 2
+#endif
/*
@@ -244,7 +314,9 @@ NDIS_STATUS RTMPAllocAdapterBlock(
// Init spin locks
NdisAllocateSpinLock(&pAd->MgmtRingLock);
+#ifdef RT2860
NdisAllocateSpinLock(&pAd->RxRingLock);
+#endif
for (index =0 ; index < NUM_OF_TX_RING; index++)
{
@@ -974,67 +1046,6 @@ VOID RTMPReadChannelPwr(
// 4. Print and Debug
choffset = 14 + 12 + 16 + 7;
-
-
-#if 0
- // Init the 802.11j channel number for TX channel power
- // 0. 20MHz
- for (i = 0; i < 3; i++)
- {
- pAd->TxPower11J[i].Channel = 8 + i * 4;
- pAd->TxPower11J[i].BW = BW_20;
- }
-
- for (i = 0; i < 4; i++)
- {
- pAd->TxPower11J[i + 3].Channel = 34 + i * 4;
- pAd->TxPower11J[i + 3].BW = BW_20;
- }
-
- for (i = 0; i < 4; i++)
- {
- pAd->TxPower11J[i + 7].Channel = 184 + i * 4;
- pAd->TxPower11J[i + 7].BW = BW_20;
- }
-
- // 0. 10MHz
- for (i = 0; i < 2; i++)
- {
- pAd->TxPower11J[i + 11].Channel = 7 + i;
- pAd->TxPower11J[i + 11].BW = BW_10;
- }
- pAd->TxPower11J[13].Channel = 11;
- pAd->TxPower11J[13].BW = BW_10;
-
- for (i = 0; i < 3; i++)
- {
- pAd->TxPower11J[i + 14].Channel = 183 + i;
- pAd->TxPower11J[i + 14].BW= BW_10;
- }
-
- for (i = 0; i < 3; i++)
- {
- pAd->TxPower11J[i + 17].Channel = 187 + i;
- pAd->TxPower11J[i + 17].BW = BW_10;
- }
- for (i = 0; i < 10; i++)
- {
- Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_Japan_TX_PWR_OFFSET + i * 2);
- Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_Japan_TX2_PWR_OFFSET + i * 2);
-
- if ((Power.field.Byte0 < 36) && (Power.field.Byte0 > -6))
- pAd->TxPower11J[i * 2].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 36) && (Power.field.Byte1 > -6))
- pAd->TxPower11J[i * 2 + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 36) && (Power2.field.Byte0 > -6))
- pAd->TxPower11J[i * 2].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 36) && (Power2.field.Byte1 > -6))
- pAd->TxPower11J[i * 2 + 1].Power2 = Power2.field.Byte1;
- }
-#endif
}
/*
@@ -1071,6 +1082,425 @@ NDIS_STATUS NICReadRegParameters(
}
+#ifdef RT2870
+/*
+ ========================================================================
+
+ Routine Description:
+ For RF filter calibration purpose
+
+ Arguments:
+ pAd Pointer to our adapter
+
+ Return Value:
+ None
+
+ IRQL = PASSIVE_LEVEL
+
+ ========================================================================
+*/
+#ifndef RT30xx
+VOID RTUSBFilterCalibration(
+ IN PRTMP_ADAPTER pAd)
+{
+ UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue;
+ UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0;
+ UCHAR RF_R24_Value = 0;
+
+ // Give bbp filter initial value
+ pAd->Mlme.CaliBW20RfR24 = 0x16;
+ pAd->Mlme.CaliBW40RfR24 = 0x36; //Bit[5] must be 1 for BW 40
+
+ do
+ {
+ if (loop == 1) //BandWidth = 40 MHz
+ {
+ // Write 0x27 to RF_R24 to program filter
+ RF_R24_Value = 0x27;
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+ FilterTarget = 0x19;
+
+ // when calibrate BW40, BBP mask must set to BW40.
+ RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue);
+ BBPValue&= (~0x18);
+ BBPValue|= (0x10);
+ RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue);
+ }
+ else //BandWidth = 20 MHz
+ {
+ // Write 0x07 to RF_R24 to program filter
+ RF_R24_Value = 0x07;
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+ FilterTarget = 0x16;
+ }
+
+ // Write 0x01 to RF_R22 to enable baseband loopback mode
+ RT30xxReadRFRegister(pAd, RF_R22, &value);
+ value |= 0x01;
+ RT30xxWriteRFRegister(pAd, RF_R22, value);
+
+ // Write 0x00 to BBP_R24 to set power & frequency of passband test tone
+ RTUSBWriteBBPRegister(pAd, BBP_R24, 0);
+
+ do
+ {
+ // Write 0x90 to BBP_R25 to transmit test tone
+ RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90);
+
+ RTMPusecDelay(1000);
+ // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0]
+ RTUSBReadBBPRegister(pAd, BBP_R55, &value);
+ R55x = value & 0xFF;
+
+ } while ((ReTry++ < 100) && (R55x == 0));
+
+ // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone
+ RTUSBWriteBBPRegister(pAd, BBP_R24, 0x06);
+
+ while(TRUE)
+ {
+ // Write 0x90 to BBP_R25 to transmit test tone
+ RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90);
+
+ //We need to wait for calibration
+ RTMPusecDelay(1000);
+ RTUSBReadBBPRegister(pAd, BBP_R55, &value);
+ value &= 0xFF;
+ if ((R55x - value) < FilterTarget)
+ {
+ RF_R24_Value ++;
+ }
+ else if ((R55x - value) == FilterTarget)
+ {
+ RF_R24_Value ++;
+ count ++;
+ }
+ else
+ {
+ break;
+ }
+
+ // prevent infinite loop cause driver hang.
+ if (loopcnt++ > 100)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("RTUSBFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt));
+ break;
+ }
+
+ // Write RF_R24 to program filter
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+ }
+
+ if (count > 0)
+ {
+ RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
+ }
+
+ // Store for future usage
+ if (loopcnt < 100)
+ {
+ if (loop++ == 0)
+ {
+ //BandWidth = 20 MHz
+ pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value;
+ }
+ else
+ {
+ //BandWidth = 40 MHz
+ pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value;
+ break;
+ }
+ }
+ else
+ break;
+
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+
+ // reset count
+ count = 0;
+ } while(TRUE);
+
+ //
+ // Set back to initial state
+ //
+ RTUSBWriteBBPRegister(pAd, BBP_R24, 0);
+
+ RT30xxReadRFRegister(pAd, RF_R22, &value);
+ value &= ~(0x01);
+ RT30xxWriteRFRegister(pAd, RF_R22, value);
+
+ // set BBP back to BW20
+ RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue);
+ BBPValue&= (~0x18);
+ RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("RTUSBFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
+}
+#endif /* RT30xx */
+#ifdef RT30xx
+VOID RTMPFilterCalibration(
+ IN PRTMP_ADAPTER pAd)
+{
+ UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue=0;
+ UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0;
+ UCHAR RF_R24_Value = 0;
+
+ // Give bbp filter initial value
+ pAd->Mlme.CaliBW20RfR24 = 0x1F;
+ pAd->Mlme.CaliBW40RfR24 = 0x2F; //Bit[5] must be 1 for BW 40
+
+ do
+ {
+ if (loop == 1) //BandWidth = 40 MHz
+ {
+ // Write 0x27 to RF_R24 to program filter
+ RF_R24_Value = 0x27;
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+ if (IS_RT3090(pAd))
+ FilterTarget = 0x15;
+ else
+ FilterTarget = 0x19;
+
+ // when calibrate BW40, BBP mask must set to BW40.
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
+ BBPValue&= (~0x18);
+ BBPValue|= (0x10);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
+
+ // set to BW40
+ RT30xxReadRFRegister(pAd, RF_R31, &value);
+ value |= 0x20;
+ RT30xxWriteRFRegister(pAd, RF_R31, value);
+ }
+ else //BandWidth = 20 MHz
+ {
+ // Write 0x07 to RF_R24 to program filter
+ RF_R24_Value = 0x07;
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+ if (IS_RT3090(pAd))
+ FilterTarget = 0x13;
+ else
+ FilterTarget = 0x16;
+
+ // set to BW20
+ RT30xxReadRFRegister(pAd, RF_R31, &value);
+ value &= (~0x20);
+ RT30xxWriteRFRegister(pAd, RF_R31, value);
+ }
+
+ // Write 0x01 to RF_R22 to enable baseband loopback mode
+ RT30xxReadRFRegister(pAd, RF_R22, &value);
+ value |= 0x01;
+ RT30xxWriteRFRegister(pAd, RF_R22, value);
+
+ // Write 0x00 to BBP_R24 to set power & frequency of passband test tone
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
+
+ do
+ {
+ // Write 0x90 to BBP_R25 to transmit test tone
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
+
+ RTMPusecDelay(1000);
+ // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0]
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
+ R55x = value & 0xFF;
+
+ } while ((ReTry++ < 100) && (R55x == 0));
+
+ // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0x06);
+
+ while(TRUE)
+ {
+ // Write 0x90 to BBP_R25 to transmit test tone
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
+
+ //We need to wait for calibration
+ RTMPusecDelay(1000);
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
+ value &= 0xFF;
+ if ((R55x - value) < FilterTarget)
+ {
+ RF_R24_Value ++;
+ }
+ else if ((R55x - value) == FilterTarget)
+ {
+ RF_R24_Value ++;
+ count ++;
+ }
+ else
+ {
+ break;
+ }
+
+ // prevent infinite loop cause driver hang.
+ if (loopcnt++ > 100)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("RTMPFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt));
+ break;
+ }
+
+ // Write RF_R24 to program filter
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+ }
+
+ if (count > 0)
+ {
+ RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
+ }
+
+ // Store for future usage
+ if (loopcnt < 100)
+ {
+ if (loop++ == 0)
+ {
+ //BandWidth = 20 MHz
+ pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value;
+ }
+ else
+ {
+ //BandWidth = 40 MHz
+ pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value;
+ break;
+ }
+ }
+ else
+ break;
+
+ RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
+
+ // reset count
+ count = 0;
+ } while(TRUE);
+
+ //
+ // Set back to initial state
+ //
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
+
+ RT30xxReadRFRegister(pAd, RF_R22, &value);
+ value &= ~(0x01);
+ RT30xxWriteRFRegister(pAd, RF_R22, value);
+
+ // set BBP back to BW20
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
+ BBPValue&= (~0x18);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
+}
+#endif /* RT30xx */
+
+VOID NICInitRT30xxRFRegisters(IN PRTMP_ADAPTER pAd)
+{
+ INT i;
+ // Driver must read EEPROM to get RfIcType before initial RF registers
+ // Initialize RF register to default value
+#ifndef RT30xx
+ if (IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) ||(pAd->RfIcType == RFIC_2020)))
+ {
+ // Init RF calibration
+ // Driver should toggle RF R30 bit7 before init RF registers
+ ULONG RfReg = 0;
+ RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg);
+ RfReg |= 0x80;
+ RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
+ RTMPusecDelay(1000);
+ RfReg &= 0x7F;
+ RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
+
+ // Initialize RF register to default value
+ for (i = 0; i < NUM_RF_REG_PARMS; i++)
+ {
+ RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value);
+ }
+
+ //For RF filter Calibration
+ RTUSBFilterCalibration(pAd);
+ }
+#endif
+#ifdef RT30xx
+ if (IS_RT3070(pAd) || IS_RT3071(pAd))
+ {
+ // Init RF calibration
+ // Driver should toggle RF R30 bit7 before init RF registers
+ UINT32 RfReg = 0;
+ UINT32 data;
+
+ RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg);
+ RfReg |= 0x80;
+ RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
+ RTMPusecDelay(1000);
+ RfReg &= 0x7F;
+ RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
+
+ // Initialize RF register to default value
+ for (i = 0; i < NUM_RF_REG_PARMS; i++)
+ {
+ RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value);
+ }
+
+ // add by johnli
+ if (IS_RT3070(pAd))
+ {
+ // Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate
+ RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
+ data = ((data & 0xF0FFFFFF) | 0x0D000000);
+ RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
+ }
+ else if (IS_RT3071(pAd))
+ {
+ // Driver should set RF R6 bit6 on before init RF registers
+ RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg);
+ RfReg |= 0x40;
+ RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg);
+
+ // init R31
+ RT30xxWriteRFRegister(pAd, RF_R31, 0x14);
+
+ // RT3071 version E has fixed this issue
+ if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211))
+ {
+ // patch tx EVM issue temporarily
+ RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
+ data = ((data & 0xE0FFFFFF) | 0x0D000000);
+ RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
+ }
+ else
+ {
+ RTMP_IO_READ32(pAd, LDO_CFG0, &data);
+ data = ((data & 0xE0FFFFFF) | 0x01000000);
+ RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
+ }
+
+ // patch LNA_PE_G1 failed issue
+ RTUSBReadMACRegister(pAd, GPIO_SWITCH, &data);
+ data &= ~(0x20);
+ RTUSBWriteMACRegister(pAd, GPIO_SWITCH, data);
+ }
+
+ //For RF filter Calibration
+ RTMPFilterCalibration(pAd);
+
+ // Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration()
+ if ((pAd->MACVersion & 0xffff) < 0x0211)
+ RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
+
+ // set led open drain enable
+ RTUSBReadMACRegister(pAd, OPT_14, &data);
+ data |= 0x01;
+ RTUSBWriteMACRegister(pAd, OPT_14, data);
+
+ if (IS_RT3071(pAd))
+ {
+ // add by johnli, RF power sequence setup, load RF normal operation-mode setup
+ RT30xxLoadRFNormalModeSetup(pAd);
+ }
+ }
+#endif
+}
+#endif // RT2870 //
/*
@@ -1245,11 +1675,25 @@ VOID NICReadEEPROMParameters(
Antenna.word = pAd->EEPROMDefaultValue[0];
if (Antenna.word == 0xFFFF)
{
+#ifdef RT30xx
+ if(IS_RT3090(pAd))
+ {
+ Antenna.word = 0;
+ Antenna.field.RfIcType = RFIC_3020;
+ Antenna.field.TxPath = 1;
+ Antenna.field.RxPath = 1;
+ }
+ else
+ {
+#endif // RT30xx //
Antenna.word = 0;
Antenna.field.RfIcType = RFIC_2820;
Antenna.field.TxPath = 1;
Antenna.field.RxPath = 2;
DBGPRINT(RT_DEBUG_WARN, ("E2PROM error, hard code as 0x%04x\n", Antenna.word));
+#ifdef RT30xx
+ }
+#endif // RT30xx //
}
// Choose the desired Tx&Rx stream.
@@ -1277,12 +1721,10 @@ VOID NICReadEEPROMParameters(
NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
+#ifndef RT30xx
NicConfig2.word = 0;
+#endif
if ((NicConfig2.word & 0x00ff) == 0xff)
{
NicConfig2.word &= 0xff00;
@@ -1293,7 +1735,6 @@ VOID NICReadEEPROMParameters(
NicConfig2.word &= 0x00ff;
}
}
-#endif // CONFIG_STA_SUPPORT //
if (NicConfig2.field.DynamicTxAgcControl == 1)
pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
@@ -1314,13 +1755,11 @@ VOID NICReadEEPROMParameters(
if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) ||
(pAd->CommonCfg.PhyMode == PHY_11A))
pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;
-#ifdef DOT11_N_SUPPORT
else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) ||
(pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) ||
(pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) ||
(pAd->CommonCfg.PhyMode == PHY_11N_5G))
pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED;
-#endif // DOT11_N_SUPPORT //
}
// Read TSSI reference and TSSI boundary for temperature compensation. This is ugly
@@ -1411,9 +1850,7 @@ VOID NICReadEEPROMParameters(
TmpPhy = pAd->CommonCfg.PhyMode;
pAd->CommonCfg.PhyMode = 0xff;
RTMPSetPhyMode(pAd, TmpPhy);
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
}
//
@@ -1480,10 +1917,13 @@ VOID NICReadEEPROMParameters(
RTMPReadTxPwrPerRate(pAd);
-#ifdef SINGLE_SKU
- //pAd->CommonCfg.DefineMaxTxPwr = RTMP_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR);
- RT28xx_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR, pAd->CommonCfg.DefineMaxTxPwr);
-#endif // SINGLE_SKU //
+#ifdef RT30xx
+ if (IS_RT30xx(pAd))
+ {
+ eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value);
+ pAd->EFuseTag = (value & 0xff);
+ }
+#endif // RT30xx //
DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n"));
}
@@ -1509,10 +1949,8 @@ VOID NICReadEEPROMParameters(
VOID NICInitAsicFromEEPROM(
IN PRTMP_ADAPTER pAd)
{
-#ifdef CONFIG_STA_SUPPORT
UINT32 data = 0;
UCHAR BBPR1 = 0;
-#endif // CONFIG_STA_SUPPORT //
USHORT i;
EEPROM_ANTENNA_STRUC Antenna;
EEPROM_NIC_CONFIG2_STRUC NicConfig2;
@@ -1531,16 +1969,49 @@ VOID NICInitAsicFromEEPROM(
}
}
+#ifndef RT30xx
Antenna.word = pAd->Antenna.word;
+#endif
+#ifdef RT30xx
+ Antenna.word = pAd->EEPROMDefaultValue[0];
+ if (Antenna.word == 0xFFFF)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("E2PROM error, hard code as 0x%04x\n", Antenna.word));
+ BUG_ON(Antenna.word == 0xFFFF);
+ }
+#endif
pAd->Mlme.RealRxPath = (UCHAR) Antenna.field.RxPath;
pAd->RfIcType = (UCHAR) Antenna.field.RfIcType;
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_WARN, ("pAd->RfIcType = %d, RealRxPath=%d, TxPath = %d\n", pAd->RfIcType, pAd->Mlme.RealRxPath,Antenna.field.TxPath));
+
+ // Save the antenna for future use
+ pAd->Antenna.word = Antenna.word;
+#endif
NicConfig2.word = pAd->EEPROMDefaultValue[1];
+#ifdef RT30xx
+ {
+ if ((NicConfig2.word & 0x00ff) == 0xff)
+ {
+ NicConfig2.word &= 0xff00;
+ }
+ if ((NicConfig2.word >> 8) == 0xff)
+ {
+ NicConfig2.word &= 0x00ff;
+ }
+ }
+#endif
// Save the antenna for future use
pAd->NicConfig2.word = NicConfig2.word;
+#ifdef RT30xx
+ // set default antenna as main
+ if (pAd->RfIcType == RFIC_3020)
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+#endif
//
// Send LED Setting to MCU.
//
@@ -1549,7 +2020,13 @@ VOID NICInitAsicFromEEPROM(
pAd->LedCntl.word = 0x01;
pAd->Led1 = 0x5555;
pAd->Led2 = 0x2221;
+#ifdef RT2860
pAd->Led3 = 0xA9F8;
+#endif
+
+#ifdef RT2870
+ pAd->Led3 = 0x5627;
+#endif // RT2870 //
}
AsicSendCommandToMcu(pAd, 0x52, 0xff, (UCHAR)pAd->Led1, (UCHAR)(pAd->Led1 >> 8));
@@ -1558,8 +2035,6 @@ VOID NICInitAsicFromEEPROM(
pAd->LedIndicatorStregth = 0xFF;
RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, before link up
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Read Hardware controlled Radio state enable bit
if (NicConfig2.field.HardwareRadioControl == 1)
@@ -1585,13 +2060,14 @@ VOID NICInitAsicFromEEPROM(
else
{
RTMPSetLED(pAd, LED_RADIO_ON);
+#ifdef RT2860
AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00);
// 2-1. wait command ok.
AsicCheckCommanOk(pAd, PowerWakeCID);
+#endif
}
}
-#endif // CONFIG_STA_SUPPORT //
// Turn off patching for cardbus controller
if (NicConfig2.field.CardbusAcceleration == 1)
@@ -1624,8 +2100,6 @@ VOID NICInitAsicFromEEPROM(
}
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Handle the difference when 1T
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BBPR1);
@@ -1637,7 +2111,7 @@ VOID NICInitAsicFromEEPROM(
DBGPRINT(RT_DEBUG_TRACE, ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n", pAd->CommonCfg.bHardwareRadio, pAd->CommonCfg.bHardwareRadio));
}
-#endif // CONFIG_STA_SUPPORT //
+
DBGPRINT(RT_DEBUG_TRACE, ("TxPath = %d, RxPath = %d, RFIC=%d, Polar+LED mode=%x\n", pAd->Antenna.field.TxPath, pAd->Antenna.field.RxPath, pAd->RfIcType, pAd->LedCntl.word));
DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitAsicFromEEPROM\n"));
}
@@ -1666,8 +2140,10 @@ NDIS_STATUS NICInitializeAdapter(
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
WPDMA_GLO_CFG_STRUC GloCfg;
+#ifdef RT2860
UINT32 Value;
DELAY_INT_CFG_STRUC IntCfg;
+#endif
ULONG i =0, j=0;
AC_TXOP_CSR0_STRUC csr0;
@@ -1706,9 +2182,11 @@ retry:
// asic simulation sequence put this ahead before loading firmware.
// pbf hardware reset
+#ifdef RT2860
RTMP_IO_WRITE32(pAd, WPDMA_RST_IDX, 0x1003f); // 0x10000 for reset rx, 0x3f resets all 6 tx rings.
RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe1f);
RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe00);
+#endif
// Initialze ASIC for TX & Rx operation
if (NICInitializeAsic(pAd , bHardReset) != NDIS_STATUS_SUCCESS)
@@ -1722,6 +2200,7 @@ retry:
}
+#ifdef RT2860
// Write AC_BK base address register
Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BK].Cell[0].AllocPa);
RTMP_IO_WRITE32(pAd, TX_BASE_PTR1, Value);
@@ -1794,6 +2273,7 @@ retry:
// Write RX_RING_CSR register
Value = RX_RING_SIZE;
RTMP_IO_WRITE32(pAd, RX_MAX_CNT, Value);
+#endif /* RT2860 */
// WMM parameter
@@ -1812,6 +2292,7 @@ retry:
RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word);
+#ifdef RT2860
// 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits:
i = 0;
do
@@ -1830,6 +2311,7 @@ retry:
IntCfg.word = 0;
RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word);
+#endif
// reset action
@@ -1865,36 +2347,133 @@ NDIS_STATUS NICInitializeAsic(
ULONG Index = 0;
UCHAR R0 = 0xff;
UINT32 MacCsr12 = 0, Counter = 0;
+#ifdef RT2870
+ UINT32 MacCsr0 = 0;
+ NTSTATUS Status;
+ UCHAR Value = 0xff;
+#endif // RT2870 //
+#ifdef RT30xx
+ UINT32 eFuseCtrl;
+#endif // RT30xx //
USHORT KeyIdx;
INT i,apidx;
DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n"));
+#ifdef RT2860
if (bHardReset == TRUE)
{
RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
}
else
RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
+#endif
+#ifdef RT2870
+ //
+ // Make sure MAC gets ready after NICLoadFirmware().
+ //
+ Index = 0;
+
+ //To avoid hang-on issue when interface up in kernel 2.4,
+ //we use a local variable "MacCsr0" instead of using "pAd->MACVersion" directly.
+ do
+ {
+ RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
+
+ if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF))
+ break;
+
+ RTMPusecDelay(10);
+ } while (Index++ < 100);
+
+ pAd->MACVersion = MacCsr0;
+ DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
+ // turn on bit13 (set to zero) after rt2860D. This is to solve high-current issue.
+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacCsr12);
+ MacCsr12 &= (~0x2000);
+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, MacCsr12);
+
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
+ RTMP_IO_WRITE32(pAd, USB_DMA_CFG, 0x0);
+ Status = RTUSBVenderReset(pAd);
+#endif
RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
+
// Initialize MAC register to default value
+#ifdef RT2860
for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++)
{
RTMP_IO_WRITE32(pAd, MACRegTable[Index].Register, MACRegTable[Index].Value);
}
+#endif
+#ifdef RT2870
+ for(Index=0; Index<NUM_MAC_REG_PARMS; Index++)
+ {
+#ifdef RT3070
+ if ((MACRegTable[Index].Register == TX_SW_CFG0) && (IS_RT3070(pAd) || IS_RT3071(pAd)))
+ {
+ MACRegTable[Index].Value = 0x00000400;
+ }
+#endif // RT3070 //
+ RTMP_IO_WRITE32(pAd, (USHORT)MACRegTable[Index].Register, MACRegTable[Index].Value);
+ }
+
+#ifndef RT30xx
+ if(IS_RT3070(pAd))
+ {
+ // According to Frank Hsu (from Gary Tsao)
+ RTMP_IO_WRITE32(pAd, (USHORT)TX_SW_CFG0, 0x00000400);
+
+ // Initialize RT3070 serial MAC registers which is different from RT2870 serial
+ RTUSBWriteMACRegister(pAd, TX_SW_CFG1, 0);
+ RTUSBWriteMACRegister(pAd, TX_SW_CFG2, 0);
+ }
+#endif
+#endif // RT2870 //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++)
{
+#ifdef RT2860
RTMP_IO_WRITE32(pAd, STAMACRegTable[Index].Register, STAMACRegTable[Index].Value);
+#endif
+#ifdef RT2870
+ RTMP_IO_WRITE32(pAd, (USHORT)STAMACRegTable[Index].Register, STAMACRegTable[Index].Value);
+#endif
}
}
-#endif // CONFIG_STA_SUPPORT //
+#ifdef RT30xx
+ // Initialize RT3070 serial MAc registers which is different from RT2870 serial
+ if (IS_RT3090(pAd))
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
+
+ // RT3071 version E has fixed this issue
+ if ((pAd->MACVersion & 0xffff) < 0x0211)
+ {
+ if (pAd->NicConfig2.field.DACTestBit == 1)
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x1F); // To fix throughput drop drastically
+ }
+ else
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0F); // To fix throughput drop drastically
+ }
+ }
+ else
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0);
+ }
+ }
+ else if (IS_RT3070(pAd))
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x1F); // To fix throughput drop drastically
+ }
+#endif // RT30xx //
//
// Before program BBP, we need to wait BBP/RF get wake up.
@@ -1935,11 +2514,69 @@ NDIS_STATUS NICInitializeAsic(
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, BBPRegTable[Index].Value);
}
+#ifndef RT30xx
// for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT.
if ((pAd->MACVersion&0xffff) != 0x0101)
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
+#ifdef RT2870
+ //write RT3070 BBP wchich different with 2870 after write RT2870 BBP
+ if (IS_RT3070(pAd))
+ {
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0a);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x99);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R105, 0x05);
+ }
+#endif // RT2870 //
+#endif
+#ifdef RT30xx
+ // for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT.
+ // RT3090 should not program BBP R84 to 0x19, otherwise TX will block.
+ if (((pAd->MACVersion&0xffff) != 0x0101) && (!IS_RT30xx(pAd)))
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
+
+// add by johnli, RF power sequence setup
+ if (IS_RT30xx(pAd))
+ { //update for RT3070/71/72/90/91/92.
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R79, 0x13);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R80, 0x05);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R81, 0x33);
+ }
+
+ if (IS_RT3090(pAd))
+ {
+ UCHAR bbpreg=0;
+
+ // enable DC filter
+ if ((pAd->MACVersion & 0xffff) >= 0x0211)
+ {
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0);
+ }
+ // improve power consumption
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R138, &bbpreg);
+ if (pAd->Antenna.field.TxPath == 1)
+ {
+ // turn off tx DAC_1
+ bbpreg = (bbpreg | 0x20);
+ }
+
+ if (pAd->Antenna.field.RxPath == 1)
+ {
+ // turn off tx ADC_1
+ bbpreg &= (~0x2);
+ }
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R138, bbpreg);
+
+ // improve power consumption in RT3071 Ver.E
+ if ((pAd->MACVersion & 0xffff) >= 0x0211)
+ {
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg);
+ bbpreg &= (~0x3);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg);
+ }
+ }
+#endif
if (pAd->MACVersion == 0x28600100)
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
@@ -1956,10 +2593,20 @@ NDIS_STATUS NICInitializeAsic(
RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, csr);
}
+#ifdef RT2870
+{
+ UCHAR MAC_Value[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0,0};
+
+ //Initialize WCID table
+ Value = 0xff;
+ for(Index =0 ;Index < 254;Index++)
+ {
+ RTUSBMultiWrite(pAd, (USHORT)(MAC_WCID_BASE + Index * 8), MAC_Value, 8);
+ }
+}
+#endif // RT2870 //
// Add radio off control
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (pAd->StaCfg.bRadio == FALSE)
{
@@ -1968,7 +2615,6 @@ NDIS_STATUS NICInitializeAsic(
DBGPRINT(RT_DEBUG_TRACE, ("Set Radio Off\n"));
}
}
-#endif // CONFIG_STA_SUPPORT //
// Clear raw counters
RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
@@ -2006,21 +2652,48 @@ NDIS_STATUS NICInitializeAsic(
RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[apidx] + i, 0x00);
}
}
+#ifdef RT2870
+ AsicDisableSync(pAd);
+ // Clear raw counters
+ RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
+ RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
+ RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
+ RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
+ RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
+ RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
+ // Default PCI clock cycle per ms is different as default setting, which is based on PCI.
+ RTMP_IO_READ32(pAd, USB_CYC_CFG, &Counter);
+ Counter&=0xffffff00;
+ Counter|=0x000001e;
+ RTMP_IO_WRITE32(pAd, USB_CYC_CFG, Counter);
+#endif // RT2870 //
+#ifdef RT30xx
+ pAd->bUseEfuse=FALSE;
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl);
+ pAd->bUseEfuse = ( (eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
+ if(pAd->bUseEfuse)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("NVM is Efuse\n"));
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n"));
+
+ }
+#endif // RT30xx //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// for rt2860E and after, init TXOP_CTRL_CFG with 0x583f. This is for extension channel overlapping IOT.
if ((pAd->MACVersion&0xffff) != 0x0101)
RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x583f);
}
-#endif // CONFIG_STA_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAsic\n"));
return NDIS_STATUS_SUCCESS;
}
+#ifdef RT2860
VOID NICRestoreBBPValue(
IN PRTMP_ADAPTER pAd)
{
@@ -2144,6 +2817,7 @@ VOID NICRestoreBBPValue(
DBGPRINT(RT_DEBUG_TRACE, ("<--- NICRestoreBBPValue !!!!!!!!!!!!!!!!!!!!!!! \n"));
}
+#endif /* RT2860 */
/*
========================================================================
@@ -2214,12 +2888,6 @@ VOID NICUpdateFifoStaCounters(
CHAR reTry;
UCHAR succMCS;
-#ifdef RALINK_ATE
- /* Nothing to do in ATE mode */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
do
{
RTMP_IO_READ32(pAd, TX_STA_FIFO, &StaFifo.word);
@@ -2244,10 +2912,8 @@ VOID NICUpdateFifoStaCounters(
pEntry->DebugFIFOCount++;
-#ifdef DOT11_N_SUPPORT
if (StaFifo.field.TxBF) // 3*3
pEntry->TxBFCount++;
-#endif // DOT11_N_SUPPORT //
#ifdef UAPSD_AP_SUPPORT
UAPSD_SP_AUE_Handle(pAd, pEntry, StaFifo.field.TxSuccess);
@@ -2261,23 +2927,15 @@ VOID NICUpdateFifoStaCounters(
if (pEntry->FIFOCount >= 1)
{
DBGPRINT(RT_DEBUG_TRACE, ("#"));
-#if 0
- SendRefreshBAR(pAd, pEntry);
pEntry->NoBADataCountDown = 64;
-#else
-#ifdef DOT11_N_SUPPORT
- pEntry->NoBADataCountDown = 64;
-#endif // DOT11_N_SUPPORT //
if(pEntry->PsMode == PWR_ACTIVE)
{
-#ifdef DOT11_N_SUPPORT
int tid;
for (tid=0; tid<NUM_OF_TID; tid++)
{
BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, FALSE);
}
-#endif // DOT11_N_SUPPORT //
// Update the continuous transmission counter except PS mode
pEntry->ContinueTxFailCnt++;
@@ -2289,14 +2947,10 @@ VOID NICUpdateFifoStaCounters(
pEntry->FIFOCount = 0;
pEntry->ContinueTxFailCnt = 0;
}
-#endif
- //pEntry->FIFOCount = 0;
}
- //pEntry->bSendBAR = TRUE;
}
else
{
-#ifdef DOT11_N_SUPPORT
if ((pEntry->PsMode != PWR_SAVE) && (pEntry->NoBADataCountDown > 0))
{
pEntry->NoBADataCountDown--;
@@ -2305,7 +2959,7 @@ VOID NICUpdateFifoStaCounters(
DBGPRINT(RT_DEBUG_TRACE, ("@\n"));
}
}
-#endif // DOT11_N_SUPPORT //
+
pEntry->FIFOCount = 0;
pEntry->OneSecTxNoRetryOkCount++;
// update NoDataIdleCount when sucessful send packet to STA.
@@ -2416,6 +3070,22 @@ VOID NICUpdateRawCounters(
// Update RX Overflow counter
pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount);
+#ifdef RT2870
+ if (pAd->RalinkCounters.RxCount != pAd->watchDogRxCnt)
+ {
+ pAd->watchDogRxCnt = pAd->RalinkCounters.RxCount;
+ pAd->watchDogRxOverFlowCnt = 0;
+ }
+ else
+ {
+ if (RxStaCnt2.field.RxFifoOverflowCount)
+ pAd->watchDogRxOverFlowCnt++;
+ else
+ pAd->watchDogRxOverFlowCnt = 0;
+ }
+#endif // RT2870 //
+
+
if (!pAd->bUpdateBcnCntDone)
{
// Update BEACON sent count
@@ -2643,217 +3313,46 @@ VOID NICEraseFirmware(
NDIS_STATUS NICLoadFirmware(
IN PRTMP_ADAPTER pAd)
{
-#ifdef BIN_IN_FILE
-#define NICLF_DEFAULT_USE() \
- flg_default_firm_use = TRUE; \
- printk("%s - Use default firmware!\n", __func__);
-
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR src;
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid, i;
- mm_segment_t orgfs;
PUCHAR pFirmwareImage;
- UINT FileLength = 0;
- UINT32 MacReg;
- ULONG Index;
- ULONG firm;
- BOOLEAN flg_default_firm_use = FALSE;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __func__));
-
- /* init */
- pFirmwareImage = NULL;
- src = RTMP_FIRMWARE_FILE_NAME;
-
- /* save uid and gid used for filesystem access.
- set user and group to 0 (root) */
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- pAd->FirmwareVersion = (FIRMWARE_MAJOR_VERSION << 8) + \
- FIRMWARE_MINOR_VERSION;
-
-
- /* allocate firmware buffer */
- pFirmwareImage = kmalloc(MAX_FIRMWARE_IMAGE_SIZE, MEM_ALLOC_FLAG);
- if (pFirmwareImage == NULL)
- {
- /* allocate fail, use default firmware array in firmware.h */
- printk("%s - Allocate memory fail!\n", __func__);
- NICLF_DEFAULT_USE();
- }
- else
- {
- /* allocate ok! zero the firmware buffer */
- memset(pFirmwareImage, 0x00, MAX_FIRMWARE_IMAGE_SIZE);
- } /* End of if */
-
+ ULONG FileLength, Index;
+ //ULONG firm;
+ UINT32 MacReg = 0;
+#ifdef RT2870
+ UINT32 Version = (pAd->MACVersion >> 16);
+#endif // RT2870 //
- /* if ok, read firmware file from *.bin file */
- if (flg_default_firm_use == FALSE)
+ pFirmwareImage = FirmwareImage;
+ FileLength = sizeof(FirmwareImage);
+#ifdef RT2870
+ // New 8k byte firmware size for RT3071/RT3072
+ //printk("Usb Chip\n");
+ if (FIRMWAREIMAGE_LENGTH == FIRMWAREIMAGE_MAX_LENGTH)
+ //The firmware image consists of two parts. One is the origianl and the other is the new.
+ //Use Second Part
{
- do
- {
- /* open the bin file */
- srcf = filp_open(src, O_RDONLY, 0);
-
- if (IS_ERR(srcf))
- {
- printk("%s - Error %ld opening %s\n",
- __func__, -PTR_ERR(srcf), src);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
-
- /* the object must have a read method */
- if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
- {
- printk("%s - %s does not have a write method\n", __func__, src);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
-
- /* read the firmware from the file *.bin */
- FileLength = srcf->f_op->read(srcf,
- pFirmwareImage,
- MAX_FIRMWARE_IMAGE_SIZE,
- &srcf->f_pos);
-
- if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
- {
- printk("%s: error file length (=%d) in RT2860AP.BIN\n",
- __func__, FileLength);
- NICLF_DEFAULT_USE();
- break;
- }
- else
- {
- PUCHAR ptr = pFirmwareImage;
- USHORT crc = 0xffff;
-
-
- /* calculate firmware CRC */
- for(i=0; i<(MAX_FIRMWARE_IMAGE_SIZE-2); i++, ptr++)
- crc = ByteCRC16(bitrev8(*ptr), crc);
- /* End of for */
-
- if ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2] != \
- (UCHAR)bitrev8((UCHAR)(crc>>8))) ||
- (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1] != \
- (UCHAR)bitrev8((UCHAR)crc)))
- {
- /* CRC fail */
- printk("%s: CRC = 0x%02x 0x%02x "
- "error, should be 0x%02x 0x%02x\n",
- __func__,
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
- (UCHAR)(crc>>8), (UCHAR)(crc));
- NICLF_DEFAULT_USE();
- break;
- }
- else
- {
- /* firmware is ok */
- pAd->FirmwareVersion = \
- (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4] << 8) +
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3];
-
- /* check if firmware version of the file is too old */
- if ((pAd->FirmwareVersion) < \
- ((FIRMWARE_MAJOR_VERSION << 8) +
- FIRMWARE_MINOR_VERSION))
- {
- printk("%s: firmware version too old!\n", __func__);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
- } /* End of if */
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("NICLoadFirmware: CRC ok, ver=%d.%d\n",
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4],
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3]));
- } /* End of if (FileLength == MAX_FIRMWARE_IMAGE_SIZE) */
- break;
- } while(TRUE);
-
- /* close firmware file */
- if (IS_ERR(srcf))
- ;
+ if ((Version != 0x2860) && (Version != 0x2872) && (Version != 0x3070))
+ { // Use Firmware V2.
+ //printk("KH:Use New Version,part2\n");
+ pFirmwareImage = (PUCHAR)&FirmwareImage[FIRMWAREIMAGEV1_LENGTH];
+ FileLength = FIRMWAREIMAGEV2_LENGTH;
+ }
else
{
- retval = filp_close(srcf, NULL);
- if (retval)
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("--> Error %d closing %s\n", -retval, src));
- } /* End of if */
- } /* End of if */
- } /* End of if */
-
-
- /* write firmware to ASIC */
- if (flg_default_firm_use == TRUE)
- {
- /* use default fimeware, free allocated buffer */
- if (pFirmwareImage != NULL)
- kfree(pFirmwareImage);
- /* End of if */
-
- /* use default *.bin array */
- pFirmwareImage = FirmwareImage;
- FileLength = sizeof(FirmwareImage);
- } /* End of if */
-
- /* enable Host program ram write selection */
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x10000);
-
- for(i=0; i<FileLength; i+=4)
- {
- firm = pFirmwareImage[i] +
- (pFirmwareImage[i+3] << 24) +
- (pFirmwareImage[i+2] << 16) +
- (pFirmwareImage[i+1] << 8);
-
- RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, firm);
- } /* End of for */
-
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00000);
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00001);
-
- /* initialize BBP R/W access agent */
- RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0);
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
-
- if (flg_default_firm_use == FALSE)
+ //printk("KH:Use New Version,part1\n");
+ pFirmwareImage = FirmwareImage;
+ FileLength = FIRMWAREIMAGEV1_LENGTH;
+ }
+ }
+ else
{
- /* use file firmware, free allocated buffer */
- if (pFirmwareImage != NULL)
- kfree(pFirmwareImage);
- /* End of if */
- } /* End of if */
+ DBGPRINT(RT_DEBUG_ERROR, ("KH: bin file should be 8KB.\n"));
+ Status = NDIS_STATUS_FAILURE;
+ }
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
-#else
+#endif // RT2870 //
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR pFirmwareImage;
- ULONG FileLength, Index;
- //ULONG firm;
- UINT32 MacReg = 0;
-
- pFirmwareImage = FirmwareImage;
- FileLength = sizeof(FirmwareImage);
RT28XX_WRITE_FIRMWARE(pAd, pFirmwareImage, FileLength);
-#endif
/* check if MCU is ready */
Index = 0;
@@ -3118,6 +3617,31 @@ VOID UserCfgInit(
//
// part I. intialize common configuration
//
+#ifdef RT2870
+ pAd->BulkOutReq = 0;
+
+ pAd->BulkOutComplete = 0;
+ pAd->BulkOutCompleteOther = 0;
+ pAd->BulkOutCompleteCancel = 0;
+ pAd->BulkInReq = 0;
+ pAd->BulkInComplete = 0;
+ pAd->BulkInCompleteFail = 0;
+
+ //pAd->QuickTimerP = 100;
+ //pAd->TurnAggrBulkInCount = 0;
+ pAd->bUsbTxBulkAggre = 0;
+
+ // init as unsed value to ensure driver will set to MCU once.
+ pAd->LedIndicatorStregth = 0xFF;
+
+ pAd->CommonCfg.MaxPktOneTxBulk = 2;
+ pAd->CommonCfg.TxBulkFactor = 1;
+ pAd->CommonCfg.RxBulkFactor =1;
+
+ pAd->CommonCfg.TxPower = 100; //mW
+
+ NdisZeroMemory(&pAd->CommonCfg.IOTestParm, sizeof(pAd->CommonCfg.IOTestParm));
+#endif // RT2870 //
for(key_index=0; key_index<SHARE_KEY_NUM; key_index++)
{
@@ -3128,14 +3652,19 @@ VOID UserCfgInit(
}
}
+#ifdef RT30xx
+ pAd->EepromAccess = FALSE;
+#endif
pAd->Antenna.word = 0;
pAd->CommonCfg.BBPCurrentBW = BW_20;
pAd->LedCntl.word = 0;
+#ifdef RT2860
pAd->LedIndicatorStregth = 0;
pAd->RLnkCtrlOffset = 0;
pAd->HostLnkCtrlOffset = 0;
pAd->CheckDmaBusyCount = 0;
+#endif
pAd->bAutoTxAgcA = FALSE; // Default is OFF
pAd->bAutoTxAgcG = FALSE; // Default is OFF
@@ -3176,23 +3705,11 @@ VOID UserCfgInit(
NdisZeroMemory(&pAd->BeaconTxWI, sizeof(pAd->BeaconTxWI));
-#ifdef DOT11_N_SUPPORT
NdisZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
pAd->HTCEnable = FALSE;
pAd->bBroadComHT = FALSE;
pAd->CommonCfg.bRdg = FALSE;
-#ifdef DOT11N_DRAFT3
- pAd->CommonCfg.Dot11OBssScanPassiveDwell = dot11OBSSScanPassiveDwell; // Unit : TU. 5~1000
- pAd->CommonCfg.Dot11OBssScanActiveDwell = dot11OBSSScanActiveDwell; // Unit : TU. 10~1000
- pAd->CommonCfg.Dot11BssWidthTriggerScanInt = dot11BSSWidthTriggerScanInterval; // Unit : Second
- pAd->CommonCfg.Dot11OBssScanPassiveTotalPerChannel = dot11OBSSScanPassiveTotalPerChannel; // Unit : TU. 200~10000
- pAd->CommonCfg.Dot11OBssScanActiveTotalPerChannel = dot11OBSSScanActiveTotalPerChannel; // Unit : TU. 20~10000
- pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor = dot11BSSWidthChannelTransactionDelayFactor;
- pAd->CommonCfg.Dot11OBssScanActivityThre = dot11BSSScanActivityThreshold; // Unit : percentage
- pAd->CommonCfg.Dot11BssWidthChanTranDelay = (pAd->CommonCfg.Dot11BssWidthTriggerScanInt * pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor);
-#endif // DOT11N_DRAFT3 //
-
NdisZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
pAd->CommonCfg.BACapability.field.MpduDensity = 0;
@@ -3213,7 +3730,6 @@ VOID UserCfgInit(
pAd->CommonCfg.TxBASize = 7;
pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word;
-#endif // DOT11_N_SUPPORT //
//pAd->CommonCfg.HTPhyMode.field.BW = BW_20;
//pAd->CommonCfg.HTPhyMode.field.MCS = MCS_AUTO;
@@ -3230,8 +3746,6 @@ VOID UserCfgInit(
//
// part II. intialize STA specific configuration
//
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_DIRECT);
RX_FILTER_CLEAR_FLAG(pAd, fRX_FILTER_ACCEPT_MULTICAST);
@@ -3270,11 +3784,6 @@ VOID UserCfgInit(
pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
}
-#ifdef EXT_BUILD_CHANNEL_LIST
- pAd->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
-
// global variables mXXXX used in MAC protocol state machines
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
@@ -3284,21 +3793,12 @@ VOID UserCfgInit(
pAd->CommonCfg.PhyMode = PHY_11BG_MIXED; // default PHY mode
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED); // CCK use LONG preamble
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// user desired power mode
pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
pAd->StaCfg.bWindowsACCAMEnable = FALSE;
-#ifdef LEAP_SUPPORT
- // CCX v1.0 releated init value
- RTMPInitTimer(pAd, &pAd->StaCfg.LeapAuthTimer, GET_TIMER_FUNCTION(LeapAuthTimeout), pAd, FALSE);
- pAd->StaCfg.LeapAuthMode = CISCO_AuthModeLEAPNone;
- pAd->StaCfg.bCkipOn = FALSE;
-#endif // LEAP_SUPPORT //
-
RTMPInitTimer(pAd, &pAd->StaCfg.StaQuickResponeForRateUpTimer, GET_TIMER_FUNCTION(StaQuickResponeForRateUpExec), pAd, FALSE);
pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
@@ -3326,17 +3826,11 @@ VOID UserCfgInit(
NdisZeroMemory(pAd->nickname, IW_ESSID_MAX_SIZE+1);
sprintf(pAd->nickname, "%s", STA_NIC_DEVICE_NAME);
RTMPInitTimer(pAd, &pAd->StaCfg.WpaDisassocAndBlockAssocTimer, GET_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc), pAd, FALSE);
-#ifdef WPA_SUPPLICANT_SUPPORT
pAd->StaCfg.IEEE8021X = FALSE;
pAd->StaCfg.IEEE8021x_required_keys = FALSE;
pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
}
-#endif // CONFIG_STA_SUPPORT //
// Default for extra information is not valid
pAd->ExtraInfo = EXTRA_INFO_CLEAR;
@@ -3373,41 +3867,12 @@ VOID UserCfgInit(
InitializeQueueHeader(&pAd->MacTab.McastPsQueue);
NdisAllocateSpinLock(&pAd->MacTabLock);
-#ifdef RALINK_ATE
- NdisZeroMemory(&pAd->ate, sizeof(ATE_INFO));
- pAd->ate.Mode = ATE_STOP;
- pAd->ate.TxCount = 200;/* to exceed TX_RING_SIZE ... */
- pAd->ate.TxLength = 1024;
- pAd->ate.TxWI.ShortGI = 0;// LONG GI : 800 ns
- pAd->ate.TxWI.PHYMODE = MODE_CCK;
- pAd->ate.TxWI.MCS = 3;
- pAd->ate.TxWI.BW = BW_20;
- pAd->ate.Channel = 1;
- pAd->ate.QID = QID_AC_BE;
- pAd->ate.Addr1[0] = 0x00;
- pAd->ate.Addr1[1] = 0x11;
- pAd->ate.Addr1[2] = 0x22;
- pAd->ate.Addr1[3] = 0xAA;
- pAd->ate.Addr1[4] = 0xBB;
- pAd->ate.Addr1[5] = 0xCC;
- NdisMoveMemory(pAd->ate.Addr2, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- NdisMoveMemory(pAd->ate.Addr3, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- pAd->ate.bRxFer = 0;
- pAd->ate.bQATxStart = FALSE;
- pAd->ate.bQARxStart = FALSE;
- pAd->ate.bFWLoading = FALSE;
-#ifdef RALINK_28xx_QA
- //pAd->ate.Repeat = 0;
- pAd->ate.TxStatus = 0;
- pAd->ate.AtePid = THREAD_PID_INIT_VALUE;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-
pAd->CommonCfg.bWiFiTest = FALSE;
+#ifdef RT2860
pAd->bPCIclkOff = FALSE;
RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+#endif
DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n"));
}
@@ -3509,6 +3974,9 @@ VOID RTMPInitTimer(
pTimer->State = FALSE;
pTimer->cookie = (ULONG) pData;
+#ifdef RT2870
+ pTimer->pAd = pAd;
+#endif // RT2870 //
RTMP_OS_Init_Timer(pAd, &pTimer->TimerObj, pTimerFunc, (PVOID) pTimer);
}
@@ -3635,6 +4103,12 @@ VOID RTMPCancelTimer(
if (*pCancelled == TRUE)
pTimer->State = TRUE;
+#ifdef RT2870
+ // We need to go-through the TimerQ to findout this timer handler and remove it if
+ // it's still waiting for execution.
+
+ RT2870_TimerQ_Remove(pTimer->pAd, pTimer);
+#endif // RT2870 //
}
else
{
@@ -3674,13 +4148,6 @@ VOID RTMPSetLED(
UCHAR HighByte = 0;
UCHAR LowByte;
-// In ATE mode of RT2860 AP/STA, we have erased 8051 firmware.
-// So LED mode is not supported when ATE is running.
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
LowByte = pAd->LedCntl.field.LedMode&0x7f;
switch (Status)
{
diff --git a/drivers/staging/rt2860/common/rtmp_tkip.c b/drivers/staging/rt2860/common/rtmp_tkip.c
index a87ea3a5d3ea..4a7fda69f9b4 100644
--- a/drivers/staging/rt2860/common/rtmp_tkip.c
+++ b/drivers/staging/rt2860/common/rtmp_tkip.c
@@ -199,15 +199,9 @@ typedef struct PACKED _IV_CONTROL_
{
struct PACKED
{
-#ifdef RT_BIG_ENDIAN
- UCHAR KeyID:2;
- UCHAR ExtIV:1;
- UCHAR Rsvd:5;
-#else
UCHAR Rsvd:5;
UCHAR ExtIV:1;
UCHAR KeyID:2;
-#endif
} field;
UCHAR Byte;
} CONTROL;
@@ -1114,10 +1108,6 @@ BOOLEAN RTMPSoftDecryptTKIP(
UCHAR MIC[8];
UCHAR TrailMIC[8];
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
fc0 = *pData;
fc1 = *(pData + 1);
@@ -1224,9 +1214,6 @@ BOOLEAN RTMPSoftDecryptTKIP(
return (FALSE);
}
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
return TRUE;
}
@@ -1266,10 +1253,6 @@ BOOLEAN RTMPSoftDecryptAES(
UCHAR MIC[8];
UCHAR TrailMIC[8];
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
fc0 = *pData;
fc1 = *(pData + 1);
@@ -1437,10 +1420,6 @@ BOOLEAN RTMPSoftDecryptAES(
return FALSE;
}
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
return TRUE;
}
diff --git a/drivers/staging/rt2860/common/rtmp_wep.c b/drivers/staging/rt2860/common/rtmp_wep.c
index ffe26c237950..8e833e7011bd 100644
--- a/drivers/staging/rt2860/common/rtmp_wep.c
+++ b/drivers/staging/rt2860/common/rtmp_wep.c
@@ -144,14 +144,12 @@ VOID RTMPInitWepEngine(
pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
-#ifdef CONFIG_STA_SUPPORT
if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10) && (pAd->OpMode == OPMODE_STA))
{
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, pKey, KeyLen); //INIT SBOX, KEYLEN+3(IV)
NdisMoveMemory(pDest, pKey, 3); //Append Init Vector
}
else
-#endif // CONFIG_STA_SUPPORT //
{
NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c
index b3650ec46563..101c2923ca37 100644
--- a/drivers/staging/rt2860/common/spectrum.c
+++ b/drivers/staging/rt2860/common/spectrum.c
@@ -1060,27 +1060,6 @@ VOID NotifyChSwAnnToPeerAPs(
IN UINT8 ChSwMode,
IN UINT8 Channel)
{
-#ifdef WDS_SUPPORT
- if (!((pRA[0] & 0xff) == 0xff)) // is pRA a broadcase address.
- {
- INT i;
- // info neighbor APs that Radar signal found throgh WDS link.
- for (i = 0; i < MAX_WDS_ENTRY; i++)
- {
- if (ValidWdsEntry(pAd, i))
- {
- PUCHAR pDA = pAd->WdsTab.WdsEntry[i].PeerWdsAddr;
-
- // DA equal to SA. have no necessary orignal AP which found Radar signal.
- if (MAC_ADDR_EQUAL(pTA, pDA))
- continue;
-
- // send Channel Switch Action frame to info Neighbro APs.
- EnqueueChSwAnn(pAd, pDA, ChSwMode, Channel);
- }
- }
- }
-#endif // WDS_SUPPORT //
}
static VOID StartDFSProcedure(
@@ -1090,9 +1069,9 @@ static VOID StartDFSProcedure(
{
// start DFS procedure
pAd->CommonCfg.Channel = Channel;
-#ifdef DOT11_N_SUPPORT
+
N_ChannelCheck(pAd);
-#endif // DOT11_N_SUPPORT //
+
pAd->CommonCfg.RadarDetect.RDMode = RD_SWITCHING_MODE;
pAd->CommonCfg.RadarDetect.CSCount = 0;
}
@@ -1475,10 +1454,8 @@ static VOID PeerChSwAnnAction(
{
CH_SW_ANN_INFO ChSwAnnInfo;
PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
-#ifdef CONFIG_STA_SUPPORT
UCHAR index = 0, Channel = 0, NewChannel = 0;
ULONG Bssidx = 0;
-#endif // CONFIG_STA_SUPPORT //
NdisZeroMemory(&ChSwAnnInfo, sizeof(CH_SW_ANN_INFO));
if (! PeerChSwAnnSanity(pAd, Elem->Msg, Elem->MsgLen, &ChSwAnnInfo))
@@ -1487,8 +1464,6 @@ static VOID PeerChSwAnnAction(
return;
}
-
-#ifdef CONFIG_STA_SUPPORT
if (pAd->OpMode == OPMODE_STA)
{
Bssidx = BssTableSearch(&pAd->ScanTab, pFr->Hdr.Addr3, pAd->CommonCfg.Channel);
@@ -1535,7 +1510,6 @@ static VOID PeerChSwAnnAction(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
return;
}
@@ -1596,7 +1570,12 @@ static VOID PeerMeasureReportAction(
if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL)
{
+#ifndef RT30xx
DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%zu).\n", __func__, sizeof(MEASURE_RPI_REPORT)));
+#endif
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __func__, sizeof(MEASURE_RPI_REPORT)));
+#endif
return;
}
@@ -1756,28 +1735,6 @@ VOID PeerSpectrumAction(
case SPEC_CHANNEL_SWITCH:
{
-#ifdef DOT11N_DRAFT3
- SEC_CHA_OFFSET_IE Secondary;
- CHA_SWITCH_ANNOUNCE_IE ChannelSwitch;
-
- // 802.11h only has Channel Switch Announcement IE.
- RTMPMoveMemory(&ChannelSwitch, &Elem->Msg[LENGTH_802_11+4], sizeof (CHA_SWITCH_ANNOUNCE_IE));
-
- // 802.11n D3.03 adds secondary channel offset element in the end.
- if (Elem->MsgLen == (LENGTH_802_11 + 2 + sizeof (CHA_SWITCH_ANNOUNCE_IE) + sizeof (SEC_CHA_OFFSET_IE)))
- {
- RTMPMoveMemory(&Secondary, &Elem->Msg[LENGTH_802_11+9], sizeof (SEC_CHA_OFFSET_IE));
- }
- else
- {
- Secondary.SecondaryChannelOffset = 0;
- }
-
- if ((Elem->Msg[LENGTH_802_11+2] == IE_CHANNEL_SWITCH_ANNOUNCEMENT) && (Elem->Msg[LENGTH_802_11+3] == 3))
- {
- ChannelSwitchAction(pAd, Elem->Wcid, ChannelSwitch.NewChannel, Secondary.SecondaryChannelOffset);
- }
-#endif // DOT11N_DRAFT3 //
}
PeerChSwAnnAction(pAd, Elem);
break;
diff --git a/drivers/staging/rt2860/leap.h b/drivers/staging/rt2860/leap.h
deleted file mode 100644
index 6818c1ff4d73..000000000000
--- a/drivers/staging/rt2860/leap.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- leap.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef __LEAP_H__
-#define __LEAP_H__
-
-// Messages for Associate state machine
-#define LEAP_MACHINE_BASE 30
-
-#define LEAP_MSG_REQUEST_IDENTITY 31
-#define LEAP_MSG_REQUEST_LEAP 32
-#define LEAP_MSG_SUCCESS 33
-#define LEAP_MSG_FAILED 34
-#define LEAP_MSG_RESPONSE_LEAP 35
-#define LEAP_MSG_EAPOLKEY 36
-#define LEAP_MSG_UNKNOWN 37
-#define LEAP_MSG 38
-//! assoc state-machine states
-#define LEAP_IDLE 0
-#define LEAP_WAIT_IDENTITY_REQUEST 1
-#define LEAP_WAIT_CHANLLENGE_REQUEST 2
-#define LEAP_WAIT_SUCCESS 3
-#define LEAP_WAIT_CHANLLENGE_RESPONSE 4
-#define LEAP_WAIT_EAPOLKEY 5
-
-#define LEAP_REASON_INVALID_AUTH 0x01
-#define LEAP_REASON_AUTH_TIMEOUT 0x02
-#define LEAP_REASON_CHALLENGE_FROM_AP_FAILED 0x03
-#define LEAP_REASON_CHALLENGE_TO_AP_FAILED 0x04
-
-#define CISCO_AuthModeLEAP 0x80
-#define CISCO_AuthModeLEAPNone 0x00
-#define LEAP_AUTH_TIMEOUT 30000
-#define LEAP_CHALLENGE_RESPONSE_LENGTH 24
-#define LEAP_CHALLENGE_REQUEST_LENGTH 8
-
-typedef struct _LEAP_EAPOL_HEADER_ {
- UCHAR Version;
- UCHAR Type;
- UCHAR Length[2];
-} LEAP_EAPOL_HEADER, *PLEAP_EAPOL_HEADER;
-
-typedef struct _LEAP_EAPOL_PACKET_ {
- UCHAR Code;
- UCHAR Identifier;
- UCHAR Length[2];
- UCHAR Type;
-} LEAP_EAPOL_PACKET, *PLEAP_EAPOL_PACKET;
-
-typedef struct _LEAP_EAP_CONTENTS_ {
- UCHAR Version;
- UCHAR Reserved;
- UCHAR Length;
-} LEAP_EAP_CONTENTS, *PLEAP_EAP_CONTENTS;
-
-/*** EAPOL key ***/
-typedef struct _EAPOL_KEY_HEADER_ {
- UCHAR Type;
- UCHAR Length[2];
- UCHAR Counter[8];
- UCHAR IV[16];
- UCHAR Index;
- UCHAR Signature[16];
-} EAPOL_KEY_HEADER, *PEAPOL_KEY_HEADER;
-
-BOOLEAN LeapMsgTypeSubst(
- IN UCHAR EAPType,
- OUT ULONG *MsgType);
-
-VOID LeapMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr3);
-
-VOID LeapStartAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapIdentityAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapPeerChallengeAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HashPwd(
- IN PUCHAR pwd,
- IN INT pwdlen,
- OUT PUCHAR hash);
-
-VOID PeerChallengeResponse(
- IN PUCHAR szChallenge,
- IN PUCHAR smbPasswd,
- OUT PUCHAR szResponse);
-
-VOID ParityKey(
- OUT PUCHAR szOut,
- IN PUCHAR szIn);
-
-VOID DesKey(
- OUT ULONG k[16][2],
- IN PUCHAR key,
- IN INT decrypt);
-
-VOID Des(
- IN ULONG ks[16][2],
- OUT UCHAR block[8]);
-
-VOID DesEncrypt(
- IN PUCHAR szClear,
- IN PUCHAR szKey,
- OUT PUCHAR szOut);
-
-VOID LeapNetworkChallengeAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapNetworkChallengeResponse(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HashpwdHash(
- IN PUCHAR hash,
- IN PUCHAR hashhash);
-
-VOID ProcessSessionKey(
- OUT PUCHAR SessionKey,
- IN PUCHAR hash2,
- IN PUCHAR ChallengeToRadius,
- IN PUCHAR ChallengeResponseFromRadius,
- IN PUCHAR ChallengeFromRadius,
- IN PUCHAR ChallengeResponseToRadius);
-
-VOID LeapEapolKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID RogueApTableInit(
- IN ROGUEAP_TABLE *Tab);
-
-ULONG RogueApTableSearch(
- IN ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr);
-
-VOID RogueApEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT ROGUEAP_ENTRY *pRogueAp,
- IN PUCHAR pAddr,
- IN UCHAR FaileCode);
-
-ULONG RogueApTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr,
- IN UCHAR FaileCode);
-
-VOID RogueApTableDeleteEntry(
- IN OUT ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr);
-
-VOID LeapAuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LeapSendRogueAPReport(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN CCKMAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen);
-
-#endif // __LEAP_H__
diff --git a/drivers/staging/rt2860/mlme.h b/drivers/staging/rt2860/mlme.h
index 5cb61652b668..3d1a8284fbd4 100644
--- a/drivers/staging/rt2860/mlme.h
+++ b/drivers/staging/rt2860/mlme.h
@@ -73,17 +73,7 @@
#define MAX_CHANNEL_TIME 140 // unit: msec, for single band scan
#define FAST_ACTIVE_SCAN_TIME 30 // Active scan waiting for probe response time
#define CW_MIN_IN_BITS 4 // actual CwMin = 2^CW_MIN_IN_BITS - 1
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifndef CONFIG_AP_SUPPORT
#define CW_MAX_IN_BITS 10 // actual CwMax = 2^CW_MAX_IN_BITS - 1
-#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-extern UINT32 CW_MAX_IN_BITS;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
// Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
// SHould not refer to this constant anymore
@@ -115,10 +105,7 @@ extern UINT32 CW_MAX_IN_BITS;
#define BSS_NOT_FOUND 0xFFFFFFFF
-
-#ifdef CONFIG_STA_SUPPORT
#define MAX_LEN_OF_MLME_QUEUE 40 //10
-#endif // CONFIG_STA_SUPPORT //
#define SCAN_PASSIVE 18 // scan with no probe request, only wait beacon and probe response
#define SCAN_ACTIVE 19 // scan with probe request, and wait beacon and probe response
@@ -128,10 +115,6 @@ extern UINT32 CW_MAX_IN_BITS;
#define SCAN_CISCO_CHANNEL_LOAD 23 // Single channel passive scan for channel load collection
#define FAST_SCAN_ACTIVE 24 // scan with probe request, and wait beacon and probe response
-#ifdef DOT11N_DRAFT3
-#define SCAN_2040_BSS_COEXIST 26
-#endif // DOT11N_DRAFT3 //
-
#define MAC_ADDR_IS_GROUP(Addr) (((Addr[0]) & 0x01))
#define MAC_ADDR_HASH(Addr) (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
@@ -204,22 +187,6 @@ if (((__pEntry)) != NULL) \
//
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT LSIGTxopProSup:1;
- USHORT Forty_Mhz_Intolerant:1;
- USHORT PSMP:1;
- USHORT CCKmodein40:1;
- USHORT AMsduSize:1;
- USHORT DelayedBA:1; //rt2860c not support
- USHORT RxSTBC:2;
- USHORT TxSTBC:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT ShortGIfor20:1;
- USHORT GF:1; //green field
- USHORT MimoPs:2;//momi power safe
- USHORT ChannelWidth:1;
- USHORT AdvCoding:1;
-#else
USHORT AdvCoding:1;
USHORT ChannelWidth:1;
USHORT MimoPs:2;//momi power safe
@@ -234,53 +201,29 @@ typedef struct PACKED {
USHORT PSMP:1;
USHORT Forty_Mhz_Intolerant:1;
USHORT LSIGTxopProSup:1;
-#endif /* !RT_BIG_ENDIAN */
} HT_CAP_INFO, *PHT_CAP_INFO;
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:3;//momi power safe
- UCHAR MpduDensity:3;
- UCHAR MaxRAmpduFactor:2;
-#else
UCHAR MaxRAmpduFactor:2;
UCHAR MpduDensity:3;
UCHAR rsv:3;//momi power safe
-#endif /* !RT_BIG_ENDIAN */
} HT_CAP_PARM, *PHT_CAP_PARM;
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
UCHAR MCSSet[10];
UCHAR SupRate[2]; // unit : 1Mbps
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:3;
- UCHAR MpduDensity:1;
- UCHAR TxStream:2;
- UCHAR TxRxNotEqual:1;
- UCHAR TxMCSSetDefined:1;
-#else
UCHAR TxMCSSetDefined:1;
UCHAR TxRxNotEqual:1;
UCHAR TxStream:2;
UCHAR MpduDensity:1;
UCHAR rsv:3;
-#endif // RT_BIG_ENDIAN //
UCHAR rsv3[3];
} HT_MCS_SET, *PHT_MCS_SET;
// HT Capability INFO field in HT Cap IE .
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:4;
- USHORT RDGSupport:1; //reverse Direction Grant support
- USHORT PlusHTC:1; //+HTC control field support
- USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
- USHORT rsv:5;//momi power safe
- USHORT TranTime:2;
- USHORT Pco:1;
-#else
USHORT Pco:1;
USHORT TranTime:2;
USHORT rsv:5;//momi power safe
@@ -288,33 +231,10 @@ typedef struct PACKED {
USHORT PlusHTC:1; //+HTC control field support
USHORT RDGSupport:1; //reverse Direction Grant support
USHORT rsv2:4;
-#endif /* RT_BIG_ENDIAN */
} EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
// HT Beamforming field in HT Cap IE .
typedef struct PACKED _HT_BF_CAP{
-#ifdef RT_BIG_ENDIAN
- ULONG rsv:3;
- ULONG ChanEstimation:2;
- ULONG CSIRowBFSup:2;
- ULONG ComSteerBFAntSup:2;
- ULONG NoComSteerBFAntSup:2;
- ULONG CSIBFAntSup:2;
- ULONG MinGrouping:2;
- ULONG ExpComBF:2;
- ULONG ExpNoComBF:2;
- ULONG ExpCSIFbk:2;
- ULONG ExpComSteerCapable:1;
- ULONG ExpNoComSteerCapable:1;
- ULONG ExpCSICapable:1;
- ULONG Calibration:2;
- ULONG ImpTxBFCapable:1;
- ULONG TxNDPCapable:1;
- ULONG RxNDPCapable:1;
- ULONG TxSoundCapable:1;
- ULONG RxSoundCapable:1;
- ULONG TxBFRecCapable:1;
-#else
ULONG TxBFRecCapable:1;
ULONG RxSoundCapable:1;
ULONG TxSoundCapable:1;
@@ -335,21 +255,10 @@ typedef struct PACKED _HT_BF_CAP{
ULONG CSIRowBFSup:2;
ULONG ChanEstimation:2;
ULONG rsv:3;
-#endif // RT_BIG_ENDIAN //
} HT_BF_CAP, *PHT_BF_CAP;
// HT antenna selection field in HT Cap IE .
typedef struct PACKED _HT_AS_CAP{
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:1;
- UCHAR TxSoundPPDU:1;
- UCHAR RxASel:1;
- UCHAR AntIndFbk:1;
- UCHAR ExpCSIFbk:1;
- UCHAR AntIndFbkTxASEL:1;
- UCHAR ExpCSIFbkTxASEL:1;
- UCHAR AntSelect:1;
-#else
UCHAR AntSelect:1;
UCHAR ExpCSIFbkTxASEL:1;
UCHAR AntIndFbkTxASEL:1;
@@ -358,7 +267,6 @@ typedef struct PACKED _HT_AS_CAP{
UCHAR RxASel:1;
UCHAR TxSoundPPDU:1;
UCHAR rsv:1;
-#endif // RT_BIG_ENDIAN //
} HT_AS_CAP, *PHT_AS_CAP;
// Draft 1.0 set IE length 26, but is extensible..
@@ -402,17 +310,10 @@ typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
// 7.3.2.56. 20/40 Coexistence element used in Element ID = 72 = IE_2040_BSS_COEXIST
typedef union PACKED _BSS_2040_COEXIST_IE{
struct PACKED {
- #ifdef RT_BIG_ENDIAN
- UCHAR rsv:5;
- UCHAR BSS20WidthReq:1;
- UCHAR Intolerant40:1;
- UCHAR InfoReq:1;
- #else
UCHAR InfoReq:1;
UCHAR Intolerant40:1; // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
UCHAR BSS20WidthReq:1; // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
UCHAR rsv:5;
-#endif // RT_BIG_ENDIAN //
} field;
UCHAR word;
} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
@@ -438,17 +339,10 @@ typedef struct _TRIGGER_EVENT_TAB{
// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
// This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv2:5;
- UCHAR ExtendChannelSwitch:1;
- UCHAR rsv:1;
- UCHAR BssCoexistMgmtSupport:1;
-#else
UCHAR BssCoexistMgmtSupport:1;
UCHAR rsv:1;
UCHAR ExtendChannelSwitch:1;
UCHAR rsv2:5;
-#endif // RT_BIG_ENDIAN //
}EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
@@ -494,18 +388,6 @@ typedef struct {
//This structure substracts ralink supports from all 802.11n-related features.
//Features not listed here but contained in 802.11n spec are not supported in rt2860.
typedef struct {
-#ifdef RT_BIG_ENDIAN
- USHORT rsv:5;
- USHORT AmsduSize:1; // Max receiving A-MSDU size
- USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
- USHORT RxSTBC:2; // 2 bits
- USHORT TxSTBC:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT ShortGIfor20:1;
- USHORT GF:1; //green field
- USHORT MimoPs:2;//mimo power safe MMPS_
- USHORT ChannelWidth:1;
-#else
USHORT ChannelWidth:1;
USHORT MimoPs:2;//mimo power safe MMPS_
USHORT GF:1; //green field
@@ -516,34 +398,18 @@ typedef struct {
USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
USHORT AmsduSize:1; // Max receiving A-MSDU size
USHORT rsv:5;
-#endif
//Substract from Addiont HT INFO IE
-#ifdef RT_BIG_ENDIAN
- UCHAR RecomWidth:1;
- UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
- UCHAR MpduDensity:3;
- UCHAR MaxRAmpduFactor:2;
-#else
UCHAR MaxRAmpduFactor:2;
UCHAR MpduDensity:3;
UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
UCHAR RecomWidth:1;
-#endif
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:11;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv3:1;
- USHORT NonGfPresent:1;
- USHORT OperaionMode:2;
-#else
USHORT OperaionMode:2;
USHORT NonGfPresent:1;
USHORT rsv3:1;
USHORT OBSS_NonHTExist:1;
USHORT rsv2:11;
-#endif
// New Extension Channel Offset IE
UCHAR NewExtChannelOffset;
@@ -553,50 +419,24 @@ typedef struct {
// field in Addtional HT Information IE .
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR SerInterGranu:3;
- UCHAR S_PSMPSup:1;
- UCHAR RifsMode:1;
- UCHAR RecomWidth:1;
- UCHAR ExtChanOffset:2;
-#else
UCHAR ExtChanOffset:2;
UCHAR RecomWidth:1;
UCHAR RifsMode:1;
UCHAR S_PSMPSup:1; //Indicate support for scheduled PSMP
UCHAR SerInterGranu:3; //service interval granularity
-#endif
} ADD_HTINFO, *PADD_HTINFO;
typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:11;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv:1;
- USHORT NonGfPresent:1;
- USHORT OperaionMode:2;
-#else
USHORT OperaionMode:2;
USHORT NonGfPresent:1;
USHORT rsv:1;
USHORT OBSS_NonHTExist:1;
USHORT rsv2:11;
-#endif
} ADD_HTINFO2, *PADD_HTINFO2;
// TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT rsv:4;
- USHORT PcoPhase:1;
- USHORT PcoActive:1;
- USHORT LsigTxopProt:1;
- USHORT STBCBeacon:1;
- USHORT DualCTSProtect:1;
- USHORT DualBeacon:1;
- USHORT StbcMcs:6;
-#else
USHORT StbcMcs:6;
USHORT DualBeacon:1;
USHORT DualCTSProtect:1;
@@ -605,7 +445,6 @@ typedef struct PACKED{
USHORT PcoActive:1;
USHORT PcoPhase:1;
USHORT rsv:4;
-#endif // RT_BIG_ENDIAN //
} ADD_HTINFO3, *PADD_HTINFO3;
#define SIZE_ADD_HT_INFO_IE 22
@@ -624,22 +463,6 @@ typedef struct PACKED{
// 4-byte HTC field. maybe included in any frame except non-QOS data frame. The Order bit must set 1.
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UINT32 RDG:1; //RDG / More PPDU
- UINT32 ACConstraint:1; //feedback request
- UINT32 rsv:5; //calibration sequence
- UINT32 ZLFAnnouce:1; // ZLF announcement
- UINT32 CSISTEERING:2; //CSI/ STEERING
- UINT32 FBKReq:2; //feedback request
- UINT32 CalSeq:2; //calibration sequence
- UINT32 CalPos:2; // calibration position
- UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
- UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
- UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
- UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
- UINT32 TRQ:1; //sounding request
- UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
-#else
UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
UINT32 TRQ:1; //sounding request
UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
@@ -654,41 +477,19 @@ typedef struct PACKED {
UINT32 rsv:5; //calibration sequence
UINT32 ACConstraint:1; //feedback request
UINT32 RDG:1; //RDG / More PPDU
-#endif /* !RT_BIG_ENDIAN */
} HT_CONTROL, *PHT_CONTROL;
// 2-byte QOS CONTROL field
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Txop_QueueSize:8;
- USHORT AMsduPresent:1;
- USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
- USHORT EOSP:1;
- USHORT TID:4;
-#else
USHORT TID:4;
USHORT EOSP:1;
USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
USHORT AMsduPresent:1;
USHORT Txop_QueueSize:8;
-#endif /* !RT_BIG_ENDIAN */
} QOS_CONTROL, *PQOS_CONTROL;
// 2-byte Frame control field
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Order:1; // Strict order expected
- USHORT Wep:1; // Wep data
- USHORT MoreData:1; // More data bit
- USHORT PwrMgmt:1; // Power management bit
- USHORT Retry:1; // Retry status bit
- USHORT MoreFrag:1; // More fragment bit
- USHORT FrDs:1; // From DS indication
- USHORT ToDs:1; // To DS indication
- USHORT SubType:4; // MSDU subtype
- USHORT Type:2; // MSDU type
- USHORT Ver:2; // Protocol version
-#else
USHORT Ver:2; // Protocol version
USHORT Type:2; // MSDU type
USHORT SubType:4; // MSDU subtype
@@ -700,7 +501,6 @@ typedef struct PACKED {
USHORT MoreData:1; // More data bit
USHORT Wep:1; // Wep data
USHORT Order:1; // Strict order expected
-#endif /* !RT_BIG_ENDIAN */
} FRAME_CONTROL, *PFRAME_CONTROL;
typedef struct PACKED _HEADER_802_11 {
@@ -709,13 +509,8 @@ typedef struct PACKED _HEADER_802_11 {
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR Addr3[MAC_ADDR_LEN];
-#ifdef RT_BIG_ENDIAN
- USHORT Sequence:12;
- USHORT Frag:4;
-#else
USHORT Frag:4;
USHORT Sequence:12;
-#endif /* !RT_BIG_ENDIAN */
UCHAR Octet[0];
} HEADER_802_11, *PHEADER_802_11;
@@ -739,42 +534,24 @@ typedef struct PACKED _HEADER_802_3 {
////Block ACK related format
// 2-byte BA Parameter field in DELBA frames to terminate an already set up bA
typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4; // value of TC os TS
- USHORT Initiator:1; // 1: originator 0:recipient
- USHORT Rsv:11; // always set to 0
-#else
USHORT Rsv:11; // always set to 0
USHORT Initiator:1; // 1: originator 0:recipient
USHORT TID:4; // value of TC os TS
-#endif /* !RT_BIG_ENDIAN */
} DELBA_PARM, *PDELBA_PARM;
// 2-byte BA Parameter Set field in ADDBA frames to signal parm for setting up a BA
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT BufSize:10; // number of buffe of size 2304 octetsr
- USHORT TID:4; // value of TC os TS
- USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
- USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
-#else
USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
USHORT TID:4; // value of TC os TS
USHORT BufSize:10; // number of buffe of size 2304 octetsr
-#endif /* !RT_BIG_ENDIAN */
} BA_PARM, *PBA_PARM;
// 2-byte BA Starting Seq CONTROL field
typedef union PACKED {
struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
- USHORT FragNum:4; // always set to 0
-#else
USHORT FragNum:4; // always set to 0
USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
-#endif /* RT_BIG_ENDIAN */
} field;
USHORT word;
} BASEQ_CONTROL, *PBASEQ_CONTROL;
@@ -782,63 +559,34 @@ typedef union PACKED {
//BAControl and BARControl are the same
// 2-byte BA CONTROL field in BA frame
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv:9;
- USHORT Compressed:1;
- USHORT MTID:1; //EWC V1.24
- USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
-#else
USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
USHORT MTID:1; //EWC V1.24
USHORT Compressed:1;
USHORT Rsv:9;
USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
} BA_CONTROL, *PBA_CONTROL;
// 2-byte BAR CONTROL field in BAR frame
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv1:9;
- USHORT Compressed:1;
- USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
- USHORT ACKPolicy:1;
-#else
USHORT ACKPolicy:1; // 0:normal ack, 1:no ack.
USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
USHORT Compressed:1;
USHORT Rsv1:9;
USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
} BAR_CONTROL, *PBAR_CONTROL;
// BARControl in MTBAR frame
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT NumTID:4;
- USHORT Rsv1:9;
- USHORT Compressed:1;
- USHORT MTID:1;
- USHORT ACKPolicy:1;
-#else
USHORT ACKPolicy:1;
USHORT MTID:1;
USHORT Compressed:1;
USHORT Rsv1:9;
USHORT NumTID:4;
-#endif /* !RT_BIG_ENDIAN */
} MTBAR_CONTROL, *PMTBAR_CONTROL;
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv1:12;
-#else
USHORT Rsv1:12;
USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
} PER_TID_INFO, *PPER_TID_INFO;
typedef struct {
@@ -1058,15 +806,6 @@ typedef struct {
// QBSS Info field in QSTA's assoc req
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR Rsv2:1;
- UCHAR MaxSPLength:2;
- UCHAR Rsv1:1;
- UCHAR UAPSD_AC_BE:1;
- UCHAR UAPSD_AC_BK:1;
- UCHAR UAPSD_AC_VI:1;
- UCHAR UAPSD_AC_VO:1;
-#else
UCHAR UAPSD_AC_VO:1;
UCHAR UAPSD_AC_VI:1;
UCHAR UAPSD_AC_BK:1;
@@ -1074,20 +813,13 @@ typedef struct PACKED {
UCHAR Rsv1:1;
UCHAR MaxSPLength:2;
UCHAR Rsv2:1;
-#endif /* !RT_BIG_ENDIAN */
} QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
// QBSS Info field in QAP's Beacon/ProbeRsp
typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR UAPSD:1;
- UCHAR Rsv:3;
- UCHAR ParamSetCount:4;
-#else
UCHAR ParamSetCount:4;
UCHAR Rsv:3;
UCHAR UAPSD:1;
-#endif /* !RT_BIG_ENDIAN */
} QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
// QOS Capability reported in QAP's BEACON/ProbeRsp
@@ -1101,13 +833,10 @@ typedef struct {
UCHAR EdcaUpdateCount;
} QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
-#ifdef CONFIG_STA_SUPPORT
typedef struct {
UCHAR IELen;
UCHAR IE[MAX_CUSTOM_LEN];
} WPA_IE_;
-#endif // CONFIG_STA_SUPPORT //
-
typedef struct {
UCHAR Bssid[MAC_ADDR_LEN];
@@ -1167,14 +896,8 @@ typedef struct {
EDCA_PARM EdcaParm;
QOS_CAPABILITY_PARM QosCapability;
QBSS_LOAD_PARM QbssLoad;
-#ifdef CONFIG_STA_SUPPORT
WPA_IE_ WpaIE;
WPA_IE_ RsnIE;
-#ifdef EXT_BUILD_CHANNEL_LIST
- UCHAR CountryString[3];
- BOOLEAN bHasCountryIE;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
} BSS_ENTRY, *PBSS_ENTRY;
typedef struct {
@@ -1333,29 +1056,6 @@ typedef struct _MLME_START_REQ_STRUCT {
UCHAR SsidLen;
} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-// structure for DLS
-typedef struct _RT_802_11_DLS {
- USHORT TimeOut; // Use to time out while slience, unit: second , set by UI
- USHORT CountDownTimer; // Use to time out while slience,unit: second , used by driver only
- NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
- UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
- BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
- RALINK_TIMER_STRUCT Timer; // Use to time out while handshake
- USHORT Sequence;
- USHORT MacTabMatchWCID; // ASIC
- BOOLEAN bHTCap;
- PVOID pAd;
-} RT_802_11_DLS, *PRT_802_11_DLS;
-
-typedef struct _MLME_DLS_REQ_STRUCT {
- PRT_802_11_DLS pDLS;
- USHORT Reason;
-} MLME_DLS_REQ_STRUCT, *PMLME_DLS_REQ_STRUCT;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
typedef struct PACKED {
UCHAR Eid;
UCHAR Len;
@@ -1365,21 +1065,12 @@ typedef struct PACKED {
typedef struct PACKED _RTMP_TX_RATE_SWITCH
{
UCHAR ItemNo;
-#ifdef RT_BIG_ENDIAN
- UCHAR Rsv2:2;
- UCHAR Mode:2;
- UCHAR Rsv1:1;
- UCHAR BW:1;
- UCHAR ShortGI:1;
- UCHAR STBC:1;
-#else
UCHAR STBC:1;
UCHAR ShortGI:1;
UCHAR BW:1;
UCHAR Rsv1:1;
UCHAR Mode:2;
UCHAR Rsv2:2;
-#endif
UCHAR CurrMCS;
UCHAR TrainUp;
UCHAR TrainDown;
diff --git a/drivers/staging/rt2860/oid.h b/drivers/staging/rt2860/oid.h
index 5e6ed9f62f9d..8519afccd979 100644
--- a/drivers/staging/rt2860/oid.h
+++ b/drivers/staging/rt2860/oid.h
@@ -80,13 +80,8 @@
#define MAX_LENGTH_OF_SUPPORT_RATES 12 // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
#define MAX_NUMBER_OF_DLS_ENTRY 4
-#ifndef UNDER_CE
-
#define OID_GEN_MACHINE_NAME 0x0001021A
-#ifdef RALINK_ATE
-#define RT_QUERY_ATE_TXDONE_COUNT 0x0401
-#endif // RALINK_ATE //
#define RT_QUERY_SIGNAL_CONTEXT 0x0402
#define RT_SET_IAPP_PID 0x0404
#define RT_SET_APD_PID 0x0405
@@ -163,7 +158,7 @@
#define RT_OID_802_11_QUERY_LAST_RX_RATE 0x0613
#define RT_OID_802_11_TX_POWER_LEVEL_1 0x0614
#define RT_OID_802_11_QUERY_PIDVID 0x0615
-//for WPA_SUPPLICANT_SUPPORT
+
#define OID_SET_COUNTERMEASURES 0x0616
#define OID_802_11_SET_IEEE8021X 0x0617
#define OID_802_11_SET_IEEE8021X_REQUIRE_KEY 0x0618
@@ -388,9 +383,6 @@ typedef struct PACKED _RADIUS_CONF
RADIUS_KEY_INFO RadiusInfo[8/*MAX_MBSSID_NUM*/];
} RADIUS_CONF, *PRADIUS_CONF;
-
-
-#ifdef CONFIG_STA_SUPPORT
// Key mapping keys require a BSSID
typedef struct _NDIS_802_11_KEY
{
@@ -401,7 +393,6 @@ typedef struct _NDIS_802_11_KEY
NDIS_802_11_KEY_RSC KeyRSC;
UCHAR KeyMaterial[1]; // variable length depending on above field
} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
-#endif // CONFIG_STA_SUPPORT //
typedef struct _NDIS_802_11_REMOVE_KEY
{
@@ -544,8 +535,10 @@ typedef enum _NDIS_802_11_WEP_STATUS
Ndis802_11Encryption3KeyAbsent,
Ndis802_11Encryption4Enabled, // TKIP or AES mix
Ndis802_11Encryption4KeyAbsent,
+#ifndef RT30xx
Ndis802_11GroupWEP40Enabled,
Ndis802_11GroupWEP104Enabled,
+#endif
} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
@@ -605,7 +598,6 @@ typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
// PMKID Structures
typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
-#ifdef CONFIG_STA_SUPPORT
typedef struct _BSSID_INFO
{
NDIS_802_11_MAC_ADDRESS BSSID;
@@ -618,8 +610,6 @@ typedef struct _NDIS_802_11_PMKID
UINT BSSIDInfoCount;
BSSID_INFO BSSIDInfo[1];
} NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
-#endif // CONFIG_STA_SUPPORT //
-
typedef struct _NDIS_802_11_AUTHENTICATION_ENCRYPTION
{
@@ -636,9 +626,6 @@ typedef struct _NDIS_802_11_CAPABILITY
NDIS_802_11_AUTHENTICATION_ENCRYPTION AuthenticationEncryptionSupported[1];
} NDIS_802_11_CAPABILITY, *PNDIS_802_11_CAPABILITY;
-//#endif //of WIN 2k
-#endif //UNDER_CE
-
#if WIRELESS_EXT <= 11
#ifndef SIOCDEVPRIVATE
#define SIOCDEVPRIVATE 0x8BE0
@@ -646,21 +633,20 @@ typedef struct _NDIS_802_11_CAPABILITY
#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
#endif
-#ifdef CONFIG_STA_SUPPORT
+#ifdef RT30xx
+#define RT_PRIV_IOCTL_EXT (SIOCIWFIRSTPRIV + 0x01) // Sync. with AP for wsc upnp daemon
+#endif
#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
#ifdef DBG
#define RTPRIV_IOCTL_BBP (SIOCIWFIRSTPRIV + 0x03)
#define RTPRIV_IOCTL_MAC (SIOCIWFIRSTPRIV + 0x05)
+#ifdef RT30xx
+#define RTPRIV_IOCTL_RF (SIOCIWFIRSTPRIV + 0x13)
+#endif
#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
#endif
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-#define RTPRIV_IOCTL_ATE (SIOCIWFIRSTPRIV + 0x08)
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
@@ -674,67 +660,61 @@ enum {
SHOW_DRVIER_VERION = 5,
SHOW_BA_INFO = 6,
SHOW_DESC_INFO = 7,
+#ifdef RT2870
+ SHOW_RXBULK_INFO = 8,
+ SHOW_TXBULK_INFO = 9,
+#endif // RT2870 //
RAIO_OFF = 10,
RAIO_ON = 11,
-#ifdef QOS_DLS_SUPPORT
- SHOW_DLS_ENTRY_INFO = 19,
-#endif // QOS_DLS_SUPPORT //
SHOW_CFG_VALUE = 20,
+#if !defined(RT2860) && !defined(RT30xx)
+ SHOW_ADHOC_ENTRY_INFO = 21,
+#endif
};
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef SNMP_SUPPORT
-//SNMP ieee 802dot11, kathy , 2008_0220
-// dot11res(3)
-#define RT_OID_802_11_MANUFACTUREROUI 0x0700
-#define RT_OID_802_11_MANUFACTURERNAME 0x0701
-#define RT_OID_802_11_RESOURCETYPEIDNAME 0x0702
-
-// dot11smt(1)
-#define RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED 0x0703
-#define RT_OID_802_11_POWERMANAGEMENTMODE 0x0704
-#define OID_802_11_WEPDEFAULTKEYVALUE 0x0705 // read , write
-#define OID_802_11_WEPDEFAULTKEYID 0x0706
-#define RT_OID_802_11_WEPKEYMAPPINGLENGTH 0x0707
-#define OID_802_11_SHORTRETRYLIMIT 0x0708
-#define OID_802_11_LONGRETRYLIMIT 0x0709
-#define RT_OID_802_11_PRODUCTID 0x0710
-#define RT_OID_802_11_MANUFACTUREID 0x0711
-
-// //dot11Phy(4)
-#define OID_802_11_CURRENTCHANNEL 0x0712
-
-//dot11mac
-#define RT_OID_802_11_MAC_ADDRESS 0x0713
-#endif // SNMP_SUPPORT //
-
#define OID_802_11_BUILD_CHANNEL_EX 0x0714
#define OID_802_11_GET_CH_LIST 0x0715
#define OID_802_11_GET_COUNTRY_CODE 0x0716
#define OID_802_11_GET_CHANNEL_GEOGRAPHY 0x0717
+#ifdef RT30xx
+#define RT_OID_WSC_SET_PASSPHRASE 0x0740 // passphrase for wpa(2)-psk
+#define RT_OID_WSC_DRIVER_AUTO_CONNECT 0x0741
+#define RT_OID_WSC_QUERY_DEFAULT_PROFILE 0x0742
+#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX 0x0743
+#define RT_OID_WSC_SET_ACTION 0x0744
+#define RT_OID_WSC_SET_SSID 0x0745
+#define RT_OID_WSC_SET_PIN_CODE 0x0746
+#define RT_OID_WSC_SET_MODE 0x0747 // PIN or PBC
+#define RT_OID_WSC_SET_CONF_MODE 0x0748 // Enrollee or Registrar
+#define RT_OID_WSC_SET_PROFILE 0x0749
+
+#define RT_OID_802_11_WSC_QUERY_PROFILE 0x0750
+// for consistency with RT61
+#define RT_OID_WSC_QUERY_STATUS 0x0751
+#define RT_OID_WSC_PIN_CODE 0x0752
+#define RT_OID_WSC_UUID 0x0753
+#define RT_OID_WSC_SET_SELECTED_REGISTRAR 0x0754
+#define RT_OID_WSC_EAPMSG 0x0755
+#define RT_OID_WSC_MANUFACTURER 0x0756
+#define RT_OID_WSC_MODEL_NAME 0x0757
+#define RT_OID_WSC_MODEL_NO 0x0758
+#define RT_OID_WSC_SERIAL_NO 0x0759
+#define RT_OID_WSC_MAC_ADDRESS 0x0760
+#endif
+
#ifdef LLTD_SUPPORT
// for consistency with RT61
#define RT_OID_GET_PHY_MODE 0x761
#endif // LLTD_SUPPORT //
+#if defined(RT2860) || defined(RT30xx)
// New for MeetingHouse Api support
#define OID_MH_802_1X_SUPPORTED 0xFFEDC100
+#endif
// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
typedef union _HTTRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT MODE:2; // Use definition MODE_xxx.
- USHORT TxBF:1;
- USHORT rsv:2;
- USHORT STBC:2; //SPACE
- USHORT ShortGI:1;
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT MCS:7; // MCS
- } field;
-#else
struct {
USHORT MCS:7; // MCS
USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
@@ -744,7 +724,6 @@ typedef union _HTTRANSMIT_SETTING {
USHORT TxBF:1;
USHORT MODE:2; // Use definition MODE_xxx.
} field;
-#endif
USHORT word;
} HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
@@ -755,14 +734,12 @@ typedef enum _RT_802_11_PREAMBLE {
} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
// Only for STA, need to sync with AP
-// 2005-03-08 match current RaConfig.
typedef enum _RT_802_11_PHY_MODE {
PHY_11BG_MIXED = 0,
PHY_11B,
PHY_11A,
PHY_11ABG_MIXED,
PHY_11G,
-#ifdef DOT11_N_SUPPORT
PHY_11ABGN_MIXED, // both band 5
PHY_11N_2_4G, // 11n-only with 2.4G band 6
PHY_11GN_MIXED, // 2.4G band 7
@@ -770,7 +747,6 @@ typedef enum _RT_802_11_PHY_MODE {
PHY_11BGN_MIXED, // if check 802.11b. 9
PHY_11AGN_MIXED, // if check 802.11b. 10
PHY_11N_5G, // 11n-only with 5G band 11
-#endif // DOT11_N_SUPPORT //
} RT_802_11_PHY_MODE;
// put all proprietery for-query objects here to reduce # of Query_OID
@@ -937,54 +913,14 @@ typedef struct _RT_LLTD_ASSOICATION_TABLE {
} RT_LLTD_ASSOICATION_TABLE, *PRT_LLTD_ASSOICATION_TABLE;
#endif // LLTD_SUPPORT //
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-//rt2860, kathy 2007-0118
-// structure for DLS
-typedef struct _RT_802_11_DLS_UI {
- USHORT TimeOut; // unit: second , set by UI
- USHORT CountDownTimer; // unit: second , used by driver only
- NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
- UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
- BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
-} RT_802_11_DLS_UI, *PRT_802_11_DLS_UI;
-
-typedef struct _RT_802_11_DLS_INFO {
- RT_802_11_DLS_UI Entry[MAX_NUMBER_OF_DLS_ENTRY];
- UCHAR num;
-} RT_802_11_DLS_INFO, *PRT_802_11_DLS_INFO;
-
-typedef enum _RT_802_11_DLS_MODE {
- DLS_NONE,
- DLS_WAIT_KEY,
- DLS_FINISH
-} RT_802_11_DLS_MODE;
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-#define RT_ASSOC_EVENT_FLAG 0x0101
-#define RT_DISASSOC_EVENT_FLAG 0x0102
-#define RT_REQIE_EVENT_FLAG 0x0103
-#define RT_RESPIE_EVENT_FLAG 0x0104
-#define RT_ASSOCINFO_EVENT_FLAG 0x0105
-#define RT_PMKIDCAND_FLAG 0x0106
-#define RT_INTERFACE_DOWN 0x0107
-#define RT_INTERFACE_UP 0x0108
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
#define MAX_CUSTOM_LEN 128
-#ifdef CONFIG_STA_SUPPORT
typedef enum _RT_802_11_D_CLIENT_MODE
{
Rt802_11_D_None,
Rt802_11_D_Flexible,
Rt802_11_D_Strict,
} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
-#endif // CONFIG_STA_SUPPORT //
typedef struct _RT_CHANNEL_LIST_INFO
{
@@ -992,6 +928,27 @@ typedef struct _RT_CHANNEL_LIST_INFO
UCHAR ChannelListNum; // number of channel in ChannelList[]
} RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO;
+#ifdef RT2870
+// WSC configured credential
+typedef struct _WSC_CREDENTIAL
+{
+ NDIS_802_11_SSID SSID; // mandatory
+ USHORT AuthType; // mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk
+ USHORT EncrType; // mandatory, 1: none, 2: wep, 4: tkip, 8: aes
+ UCHAR Key[64]; // mandatory, Maximum 64 byte
+ USHORT KeyLength;
+ UCHAR MacAddr[6]; // mandatory, AP MAC address
+ UCHAR KeyIndex; // optional, default is 1
+ UCHAR Rsvd[3]; // Make alignment
+} WSC_CREDENTIAL, *PWSC_CREDENTIAL;
+
+// WSC configured profiles
+typedef struct _WSC_PROFILE
+{
+ UINT ProfileCnt;
+ WSC_CREDENTIAL Profile[8]; // Support up to 8 profiles
+} WSC_PROFILE, *PWSC_PROFILE;
+#endif
#endif // _OID_H_
diff --git a/drivers/staging/rt2860/rt28xx.h b/drivers/staging/rt2860/rt28xx.h
index e5e6f0a8de63..6e71acb16dc3 100644
--- a/drivers/staging/rt2860/rt28xx.h
+++ b/drivers/staging/rt2860/rt28xx.h
@@ -47,6 +47,15 @@
#define PCI_EECTRL 0x0004
#define PCI_MCUCTRL 0x0008
+#ifdef RT30xx
+#define OPT_14 0x114
+
+typedef int NTSTATUS;
+#define RETRY_LIMIT 10
+#define STATUS_SUCCESS 0x00
+#define STATUS_UNSUCCESSFUL 0x01
+#endif
+
//
// SCH/DMA registers - base address 0x0200
//
@@ -54,32 +63,6 @@
//
#define DMA_CSR0 0x200
#define INT_SOURCE_CSR 0x200
-#ifdef RT_BIG_ENDIAN
-typedef union _INT_SOURCE_CSR_STRUC {
- struct {
- UINT32 :14;
- UINT32 TxCoherent:1;
- UINT32 RxCoherent:1;
- UINT32 GPTimer:1;
- UINT32 AutoWakeup:1;//bit14
- UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
- UINT32 PreTBTT:1;
- UINT32 TBTTInt:1;
- UINT32 RxTxCoherent:1;
- UINT32 MCUCommandINT:1;
- UINT32 MgmtDmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 RxDone:1;
- UINT32 TxDelayINT:1; //delayed interrupt, not interrupt until several int or time limit hit
- UINT32 RxDelayINT:1; //dealyed interrupt
- } field;
- UINT32 word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-#else
typedef union _INT_SOURCE_CSR_STRUC {
struct {
UINT32 RxDelayINT:1;
@@ -104,32 +87,11 @@ typedef union _INT_SOURCE_CSR_STRUC {
} field;
UINT32 word;
} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-#endif
//
// INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF
//
#define INT_MASK_CSR 0x204
-#ifdef RT_BIG_ENDIAN
-typedef union _INT_MASK_CSR_STRUC {
- struct {
- UINT32 TxCoherent:1;
- UINT32 RxCoherent:1;
- UINT32 :20;
- UINT32 MCUCommandINT:1;
- UINT32 MgmtDmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 RxDone:1;
- UINT32 TxDelay:1;
- UINT32 RXDelay_INT_MSK:1;
- } field;
- UINT32 word;
-}INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-#else
typedef union _INT_MASK_CSR_STRUC {
struct {
UINT32 RXDelay_INT_MSK:1;
@@ -148,24 +110,8 @@ typedef union _INT_MASK_CSR_STRUC {
} field;
UINT32 word;
} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-#endif
+
#define WPDMA_GLO_CFG 0x208
-#ifdef RT_BIG_ENDIAN
-typedef union _WPDMA_GLO_CFG_STRUC {
- struct {
- UINT32 HDR_SEG_LEN:16;
- UINT32 RXHdrScater:8;
- UINT32 BigEndian:1;
- UINT32 EnTXWriteBackDDONE:1;
- UINT32 WPDMABurstSIZE:2;
- UINT32 RxDMABusy:1;
- UINT32 EnableRxDMA:1;
- UINT32 TxDMABusy:1;
- UINT32 EnableTxDMA:1;
- } field;
- UINT32 word;
-}WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-#else
typedef union _WPDMA_GLO_CFG_STRUC {
struct {
UINT32 EnableTxDMA:1;
@@ -180,24 +126,8 @@ typedef union _WPDMA_GLO_CFG_STRUC {
} field;
UINT32 word;
} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-#endif
+
#define WPDMA_RST_IDX 0x20c
-#ifdef RT_BIG_ENDIAN
-typedef union _WPDMA_RST_IDX_STRUC {
- struct {
- UINT32 :15;
- UINT32 RST_DRX_IDX0:1;
- UINT32 rsv:10;
- UINT32 RST_DTX_IDX5:1;
- UINT32 RST_DTX_IDX4:1;
- UINT32 RST_DTX_IDX3:1;
- UINT32 RST_DTX_IDX2:1;
- UINT32 RST_DTX_IDX1:1;
- UINT32 RST_DTX_IDX0:1;
- } field;
- UINT32 word;
-}WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#else
typedef union _WPDMA_RST_IDX_STRUC {
struct {
UINT32 RST_DTX_IDX0:1;
@@ -212,21 +142,8 @@ typedef union _WPDMA_RST_IDX_STRUC {
} field;
UINT32 word;
} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#endif
+
#define DELAY_INT_CFG 0x0210
-#ifdef RT_BIG_ENDIAN
-typedef union _DELAY_INT_CFG_STRUC {
- struct {
- UINT32 TXDLY_INT_EN:1;
- UINT32 TXMAX_PINT:7;
- UINT32 TXMAX_PTIME:8;
- UINT32 RXDLY_INT_EN:1;
- UINT32 RXMAX_PINT:7;
- UINT32 RXMAX_PTIME:8;
- } field;
- UINT32 word;
-}DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#else
typedef union _DELAY_INT_CFG_STRUC {
struct {
UINT32 RXMAX_PTIME:8;
@@ -238,20 +155,8 @@ typedef union _DELAY_INT_CFG_STRUC {
} field;
UINT32 word;
} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#endif
+
#define WMM_AIFSN_CFG 0x0214
-#ifdef RT_BIG_ENDIAN
-typedef union _AIFSN_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Aifsn3:4; // for AC_VO
- UINT32 Aifsn2:4; // for AC_VI
- UINT32 Aifsn1:4; // for AC_BK
- UINT32 Aifsn0:4; // for AC_BE
- } field;
- UINT32 word;
-} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-#else
typedef union _AIFSN_CSR_STRUC {
struct {
UINT32 Aifsn0:4; // for AC_BE
@@ -262,23 +167,11 @@ typedef union _AIFSN_CSR_STRUC {
} field;
UINT32 word;
} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-#endif
+
//
// CWMIN_CSR: CWmin for each EDCA AC
//
#define WMM_CWMIN_CFG 0x0218
-#ifdef RT_BIG_ENDIAN
-typedef union _CWMIN_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Cwmin3:4; // for AC_VO
- UINT32 Cwmin2:4; // for AC_VI
- UINT32 Cwmin1:4; // for AC_BK
- UINT32 Cwmin0:4; // for AC_BE
- } field;
- UINT32 word;
-} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-#else
typedef union _CWMIN_CSR_STRUC {
struct {
UINT32 Cwmin0:4; // for AC_BE
@@ -289,24 +182,11 @@ typedef union _CWMIN_CSR_STRUC {
} field;
UINT32 word;
} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-#endif
//
// CWMAX_CSR: CWmin for each EDCA AC
//
#define WMM_CWMAX_CFG 0x021c
-#ifdef RT_BIG_ENDIAN
-typedef union _CWMAX_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Cwmax3:4; // for AC_VO
- UINT32 Cwmax2:4; // for AC_VI
- UINT32 Cwmax1:4; // for AC_BK
- UINT32 Cwmax0:4; // for AC_BE
- } field;
- UINT32 word;
-} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-#else
typedef union _CWMAX_CSR_STRUC {
struct {
UINT32 Cwmax0:4; // for AC_BE
@@ -317,22 +197,11 @@ typedef union _CWMAX_CSR_STRUC {
} field;
UINT32 word;
} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-#endif
-
//
// AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
//
#define WMM_TXOP0_CFG 0x0220
-#ifdef RT_BIG_ENDIAN
-typedef union _AC_TXOP_CSR0_STRUC {
- struct {
- USHORT Ac1Txop; // for AC_BE, in unit of 32us
- USHORT Ac0Txop; // for AC_BK, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-#else
typedef union _AC_TXOP_CSR0_STRUC {
struct {
USHORT Ac0Txop; // for AC_BK, in unit of 32us
@@ -340,21 +209,11 @@ typedef union _AC_TXOP_CSR0_STRUC {
} field;
UINT32 word;
} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-#endif
//
// AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
//
#define WMM_TXOP1_CFG 0x0224
-#ifdef RT_BIG_ENDIAN
-typedef union _AC_TXOP_CSR1_STRUC {
- struct {
- USHORT Ac3Txop; // for AC_VO, in unit of 32us
- USHORT Ac2Txop; // for AC_VI, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-#else
typedef union _AC_TXOP_CSR1_STRUC {
struct {
USHORT Ac2Txop; // for AC_VI, in unit of 32us
@@ -362,7 +221,7 @@ typedef union _AC_TXOP_CSR1_STRUC {
} field;
UINT32 word;
} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-#endif
+
#define RINGREG_DIFF 0x10
#define GPIO_CTRL_CFG 0x0228 //MAC_CSR13
#define MCU_CMD_CFG 0x022c
@@ -398,25 +257,7 @@ typedef union _AC_TXOP_CSR1_STRUC {
#define RX_CRX_IDX 0x0298
#define RX_DRX_IDX 0x029c
#define USB_DMA_CFG 0x02a0
-#ifdef RT_BIG_ENDIAN
-typedef union _USB_DMA_CFG_STRUC {
- struct {
- UINT32 TxBusy:1; //USB DMA TX FSM busy . debug only
- UINT32 RxBusy:1; //USB DMA RX FSM busy . debug only
- UINT32 EpoutValid:6; //OUT endpoint data valid. debug only
- UINT32 TxBulkEn:1; //Enable USB DMA Tx
- UINT32 RxBulkEn:1; //Enable USB DMA Rx
- UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
- UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
- UINT32 TxClear:1; //Clear USB DMA TX path
- UINT32 rsv:2;
- UINT32 phyclear:1; //phy watch dog enable. write 1
- UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 1024 bytes
- UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
- } field;
- UINT32 word;
-} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-#else
+
typedef union _USB_DMA_CFG_STRUC {
struct {
UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
@@ -434,7 +275,6 @@ typedef union _USB_DMA_CFG_STRUC {
} field;
UINT32 word;
} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-#endif
//
// 3 PBF registers
@@ -451,6 +291,36 @@ typedef union _USB_DMA_CFG_STRUC {
#define PBF_DBG 0x043c
#define PBF_CAP_CTRL 0x0440
+#ifdef RT30xx
+// eFuse registers
+#define EFUSE_CTRL 0x0580
+#define EFUSE_DATA0 0x0590
+#define EFUSE_DATA1 0x0594
+#define EFUSE_DATA2 0x0598
+#define EFUSE_DATA3 0x059c
+#define EFUSE_USAGE_MAP_START 0x2d0
+#define EFUSE_USAGE_MAP_END 0x2fc
+#define EFUSE_TAG 0x2fe
+#define EFUSE_USAGE_MAP_SIZE 45
+
+typedef union _EFUSE_CTRL_STRUC {
+ struct {
+ UINT32 EFSROM_AOUT:6;
+ UINT32 EFSROM_MODE:2;
+ UINT32 EFSROM_LDO_OFF_TIME:6;
+ UINT32 EFSROM_LDO_ON_TIME:2;
+ UINT32 EFSROM_AIN:10;
+ UINT32 RESERVED:4;
+ UINT32 EFSROM_KICK:1;
+ UINT32 SEL_EFUSE:1;
+ } field;
+ UINT32 word;
+} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
+
+#define LDO_CFG0 0x05d4
+#define GPIO_SWITCH 0x05dc
+#endif /* RT30xx */
+
//
// 4 MAC registers
//
@@ -458,15 +328,6 @@ typedef union _USB_DMA_CFG_STRUC {
// 4.1 MAC SYSTEM configuration registers (offset:0x1000)
//
#define MAC_CSR0 0x1000
-#ifdef RT_BIG_ENDIAN
-typedef union _ASIC_VER_ID_STRUC {
- struct {
- USHORT ASICVer; // version : 2860
- USHORT ASICRev; // reversion : 0
- } field;
- UINT32 word;
-} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#else
typedef union _ASIC_VER_ID_STRUC {
struct {
USHORT ASICRev; // reversion : 0
@@ -474,24 +335,13 @@ typedef union _ASIC_VER_ID_STRUC {
} field;
UINT32 word;
} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#endif
+
#define MAC_SYS_CTRL 0x1004 //MAC_CSR1
#define MAC_ADDR_DW0 0x1008 // MAC ADDR DW0
#define MAC_ADDR_DW1 0x100c // MAC ADDR DW1
//
// MAC_CSR2: STA MAC register 0
//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_DW0_STRUC {
- struct {
- UCHAR Byte3; // MAC address byte 3
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte0; // MAC address byte 0
- } field;
- UINT32 word;
-} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-#else
typedef union _MAC_DW0_STRUC {
struct {
UCHAR Byte0; // MAC address byte 0
@@ -501,22 +351,10 @@ typedef union _MAC_DW0_STRUC {
} field;
UINT32 word;
} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-#endif
//
// MAC_CSR3: STA MAC register 1
//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_DW1_STRUC {
- struct {
- UCHAR Rsvd1;
- UCHAR U2MeMask;
- UCHAR Byte5; // MAC address byte 5
- UCHAR Byte4; // MAC address byte 4
- } field;
- UINT32 word;
-} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-#else
typedef union _MAC_DW1_STRUC {
struct {
UCHAR Byte4; // MAC address byte 4
@@ -526,7 +364,6 @@ typedef union _MAC_DW1_STRUC {
} field;
UINT32 word;
} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-#endif
#define MAC_BSSID_DW0 0x1010 // MAC BSSID DW0
#define MAC_BSSID_DW1 0x1014 // MAC BSSID DW1
@@ -534,18 +371,6 @@ typedef union _MAC_DW1_STRUC {
//
// MAC_CSR5: BSSID register 1
//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_CSR5_STRUC {
- struct {
- USHORT Rsvd:11;
- USHORT MBssBcnNum:3;
- USHORT BssIdMode:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
- UCHAR Byte5; // BSSID byte 5
- UCHAR Byte4; // BSSID byte 4
- } field;
- UINT32 word;
-} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-#else
typedef union _MAC_CSR5_STRUC {
struct {
UCHAR Byte4; // BSSID byte 4
@@ -556,27 +381,12 @@ typedef union _MAC_CSR5_STRUC {
} field;
UINT32 word;
} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-#endif
#define MAX_LEN_CFG 0x1018 // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
#define BBP_CSR_CFG 0x101c //
//
// BBP_CSR_CFG: BBP serial control register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _BBP_CSR_CFG_STRUC {
- struct {
- UINT32 :12;
- UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
- UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
- UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
- UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
- UINT32 RegNum:8; // Selected BBP register
- UINT32 Value:8; // Register value to program into BBP
- } field;
- UINT32 word;
-} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#else
typedef union _BBP_CSR_CFG_STRUC {
struct {
UINT32 Value:8; // Register value to program into BBP
@@ -589,23 +399,11 @@ typedef union _BBP_CSR_CFG_STRUC {
} field;
UINT32 word;
} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#endif
+
#define RF_CSR_CFG0 0x1020
//
// RF_CSR_CFG: RF control register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG0_STRUC {
- struct {
- UINT32 Busy:1; // 0: idle 1: 8busy
- UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
- UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
- UINT32 bitwidth:5; // Selected BBP register
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#else
typedef union _RF_CSR_CFG0_STRUC {
struct {
UINT32 RegIdAndContent:24; // Register value to program into BBP
@@ -616,18 +414,8 @@ typedef union _RF_CSR_CFG0_STRUC {
} field;
UINT32 word;
} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#endif
+
#define RF_CSR_CFG1 0x1024
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG1_STRUC {
- struct {
- UINT32 rsv:7; // 0: idle 1: 8busy
- UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#else
typedef union _RF_CSR_CFG1_STRUC {
struct {
UINT32 RegIdAndContent:24; // Register value to program into BBP
@@ -636,17 +424,8 @@ typedef union _RF_CSR_CFG1_STRUC {
} field;
UINT32 word;
} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#endif
+
#define RF_CSR_CFG2 0x1028 //
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG2_STRUC {
- struct {
- UINT32 rsv:8; // 0: idle 1: 8busy
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#else
typedef union _RF_CSR_CFG2_STRUC {
struct {
UINT32 RegIdAndContent:24; // Register value to program into BBP
@@ -654,24 +433,8 @@ typedef union _RF_CSR_CFG2_STRUC {
} field;
UINT32 word;
} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#endif
+
#define LED_CFG 0x102c // MAC_CSR14
-#ifdef RT_BIG_ENDIAN
-typedef union _LED_CFG_STRUC {
- struct {
- UINT32 :1;
- UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
- UINT32 YLedMode:2; // yellow Led Mode
- UINT32 GLedMode:2; // green Led Mode
- UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
- UINT32 rsv:2;
- UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
- UINT32 OffPeriod:8; // blinking off period unit 1ms
- UINT32 OnPeriod:8; // blinking on period unit 1ms
- } field;
- UINT32 word;
-} LED_CFG_STRUC, *PLED_CFG_STRUC;
-#else
typedef union _LED_CFG_STRUC {
struct {
UINT32 OnPeriod:8; // blinking on period unit 1ms
@@ -686,24 +449,11 @@ typedef union _LED_CFG_STRUC {
} field;
UINT32 word;
} LED_CFG_STRUC, *PLED_CFG_STRUC;
-#endif
+
//
// 4.2 MAC TIMING configuration registers (offset:0x1100)
//
#define XIFS_TIME_CFG 0x1100 // MAC_CSR8 MAC_CSR9
-#ifdef RT_BIG_ENDIAN
-typedef union _IFS_SLOT_CFG_STRUC {
- struct {
- UINT32 rsv:2;
- UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
- UINT32 EIFS:9; // unit 1us
- UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
- UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
- UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
- } field;
- UINT32 word;
-} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-#else
typedef union _IFS_SLOT_CFG_STRUC {
struct {
UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
@@ -715,7 +465,6 @@ typedef union _IFS_SLOT_CFG_STRUC {
} field;
UINT32 word;
} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-#endif
#define BKOFF_SLOT_CFG 0x1104 // mac_csr9 last 8 bits
#define NAV_TIME_CFG 0x1108 // NAV (MAC_CSR15)
@@ -729,20 +478,6 @@ typedef union _IFS_SLOT_CFG_STRUC {
//
// BCN_TIME_CFG : Synchronization control register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _BCN_TIME_CFG_STRUC {
- struct {
- UINT32 TxTimestampCompensate:8;
- UINT32 :3;
- UINT32 bBeaconGen:1; // Enable beacon generator
- UINT32 bTBTTEnable:1;
- UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
- UINT32 bTsfTicking:1; // Enable TSF auto counting
- UINT32 BeaconInterval:16; // in unit of 1/16 TU
- } field;
- UINT32 word;
-} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#else
typedef union _BCN_TIME_CFG_STRUC {
struct {
UINT32 BeaconInterval:16; // in unit of 1/16 TU
@@ -755,7 +490,7 @@ typedef union _BCN_TIME_CFG_STRUC {
} field;
UINT32 word;
} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#endif
+
#define TBTT_SYNC_CFG 0x1118 // txrx_csr10
#define TSF_TIMER_DW0 0x111C // Local TSF timer lsb 32 bits. Read-only
#define TSF_TIMER_DW1 0x1120 // msb 32 bits. Read-only.
@@ -773,17 +508,6 @@ typedef union _BCN_TIME_CFG_STRUC {
//
// AUTO_WAKEUP_CFG: Manual power control / status register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _AUTO_WAKEUP_STRUC {
- struct {
- UINT32 :16;
- UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
- UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
- UINT32 AutoLeadTime:8;
- } field;
- UINT32 word;
-} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-#else
typedef union _AUTO_WAKEUP_STRUC {
struct {
UINT32 AutoLeadTime:8;
@@ -793,7 +517,7 @@ typedef union _AUTO_WAKEUP_STRUC {
} field;
UINT32 word;
} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-#endif
+
//
// 4.3 MAC TX configuration registers (offset:0x1300)
//
@@ -802,18 +526,6 @@ typedef union _AUTO_WAKEUP_STRUC {
#define EDCA_AC1_CFG 0x1304
#define EDCA_AC2_CFG 0x1308
#define EDCA_AC3_CFG 0x130c
-#ifdef RT_BIG_ENDIAN
-typedef union _EDCA_AC_CFG_STRUC {
- struct {
- UINT32 :12; //
- UINT32 Cwmax:4; //unit power of 2
- UINT32 Cwmin:4; //
- UINT32 Aifsn:4; // # of slot time
- UINT32 AcTxop:8; // in unit of 32us
- } field;
- UINT32 word;
-} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-#else
typedef union _EDCA_AC_CFG_STRUC {
struct {
UINT32 AcTxop:8; // in unit of 32us
@@ -824,7 +536,6 @@ typedef union _EDCA_AC_CFG_STRUC {
} field;
UINT32 word;
} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-#endif
#define EDCA_TID_AC_MAP 0x1310
#define TX_PWR_CFG_0 0x1314
@@ -841,17 +552,6 @@ typedef union _EDCA_AC_CFG_STRUC {
#define TXOP_CTRL_CFG 0x1340
#define TX_RTS_CFG 0x1344
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_RTS_CFG_STRUC {
- struct {
- UINT32 rsv:7;
- UINT32 RtsFbkEn:1; // enable rts rate fallback
- UINT32 RtsThres:16; // unit:byte
- UINT32 AutoRtsRetryLimit:8;
- } field;
- UINT32 word;
-} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#else
typedef union _TX_RTS_CFG_STRUC {
struct {
UINT32 AutoRtsRetryLimit:8;
@@ -861,20 +561,8 @@ typedef union _TX_RTS_CFG_STRUC {
} field;
UINT32 word;
} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#endif
+
#define TX_TIMEOUT_CFG 0x1348
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_TIMEOUT_CFG_STRUC {
- struct {
- UINT32 rsv2:8;
- UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
- UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
- UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
- UINT32 rsv:4;
- } field;
- UINT32 word;
-} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#else
typedef union _TX_TIMEOUT_CFG_STRUC {
struct {
UINT32 rsv:4;
@@ -885,23 +573,8 @@ typedef union _TX_TIMEOUT_CFG_STRUC {
} field;
UINT32 word;
} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#endif
-#define TX_RTY_CFG 0x134c
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_RTY_CFG_STRUC {
- struct {
- UINT32 rsv:1;
- UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
- UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 LongRtyThre:12; // Long retry threshoold
- UINT32 LongRtyLimit:8; //long retry limit
- UINT32 ShortRtyLimit:8; // short retry limit
- } field;
- UINT32 word;
-} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#else
+#define TX_RTY_CFG 0x134c
typedef union PACKED _TX_RTY_CFG_STRUC {
struct {
UINT32 ShortRtyLimit:8; // short retry limit
@@ -914,24 +587,8 @@ typedef union PACKED _TX_RTY_CFG_STRUC {
} field;
UINT32 word;
} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#endif
+
#define TX_LINK_CFG 0x1350
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_LINK_CFG_STRUC {
- struct PACKED {
- UINT32 RemotMFS:8; //remote MCS feedback sequence number
- UINT32 RemotMFB:8; // remote MCS feedback
- UINT32 rsv:3; //
- UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
- UINT32 TxRDGEn:1; // RDG TX enable
- UINT32 TxMRQEn:1; // MCS request TX enable
- UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
- UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
- UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
- } field;
- UINT32 word;
-} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#else
typedef union PACKED _TX_LINK_CFG_STRUC {
struct PACKED {
UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
@@ -946,23 +603,8 @@ typedef union PACKED _TX_LINK_CFG_STRUC {
} field;
UINT32 word;
} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#endif
+
#define HT_FBK_CFG0 0x1354
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _HT_FBK_CFG0_STRUC {
- struct {
- UINT32 HTMCS7FBK:4;
- UINT32 HTMCS6FBK:4;
- UINT32 HTMCS5FBK:4;
- UINT32 HTMCS4FBK:4;
- UINT32 HTMCS3FBK:4;
- UINT32 HTMCS2FBK:4;
- UINT32 HTMCS1FBK:4;
- UINT32 HTMCS0FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#else
typedef union PACKED _HT_FBK_CFG0_STRUC {
struct {
UINT32 HTMCS0FBK:4;
@@ -976,23 +618,8 @@ typedef union PACKED _HT_FBK_CFG0_STRUC {
} field;
UINT32 word;
} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#endif
+
#define HT_FBK_CFG1 0x1358
-#ifdef RT_BIG_ENDIAN
-typedef union _HT_FBK_CFG1_STRUC {
- struct {
- UINT32 HTMCS15FBK:4;
- UINT32 HTMCS14FBK:4;
- UINT32 HTMCS13FBK:4;
- UINT32 HTMCS12FBK:4;
- UINT32 HTMCS11FBK:4;
- UINT32 HTMCS10FBK:4;
- UINT32 HTMCS9FBK:4;
- UINT32 HTMCS8FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#else
typedef union _HT_FBK_CFG1_STRUC {
struct {
UINT32 HTMCS8FBK:4;
@@ -1006,23 +633,8 @@ typedef union _HT_FBK_CFG1_STRUC {
} field;
UINT32 word;
} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#endif
+
#define LG_FBK_CFG0 0x135c
-#ifdef RT_BIG_ENDIAN
-typedef union _LG_FBK_CFG0_STRUC {
- struct {
- UINT32 OFDMMCS7FBK:4; //initial value is 6
- UINT32 OFDMMCS6FBK:4; //initial value is 5
- UINT32 OFDMMCS5FBK:4; //initial value is 4
- UINT32 OFDMMCS4FBK:4; //initial value is 3
- UINT32 OFDMMCS3FBK:4; //initial value is 2
- UINT32 OFDMMCS2FBK:4; //initial value is 1
- UINT32 OFDMMCS1FBK:4; //initial value is 0
- UINT32 OFDMMCS0FBK:4; //initial value is 0
- } field;
- UINT32 word;
-} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#else
typedef union _LG_FBK_CFG0_STRUC {
struct {
UINT32 OFDMMCS0FBK:4; //initial value is 0
@@ -1036,20 +648,8 @@ typedef union _LG_FBK_CFG0_STRUC {
} field;
UINT32 word;
} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#endif
+
#define LG_FBK_CFG1 0x1360
-#ifdef RT_BIG_ENDIAN
-typedef union _LG_FBK_CFG1_STRUC {
- struct {
- UINT32 rsv:16;
- UINT32 CCKMCS3FBK:4; //initial value is 2
- UINT32 CCKMCS2FBK:4; //initial value is 1
- UINT32 CCKMCS1FBK:4; //initial value is 0
- UINT32 CCKMCS0FBK:4; //initial value is 0
- } field;
- UINT32 word;
-} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-#else
typedef union _LG_FBK_CFG1_STRUC {
struct {
UINT32 CCKMCS0FBK:4; //initial value is 0
@@ -1060,7 +660,6 @@ typedef union _LG_FBK_CFG1_STRUC {
} field;
UINT32 word;
} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-#endif
//=======================================================
//================ Protection Paramater================================
@@ -1070,24 +669,6 @@ typedef union _LG_FBK_CFG1_STRUC {
#define ASIC_LONGNAV 2
#define ASIC_RTS 1
#define ASIC_CTS 2
-#ifdef RT_BIG_ENDIAN
-typedef union _PROT_CFG_STRUC {
- struct {
- UINT32 rsv:5;
- UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
- UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
- UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
- UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
- UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
- UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
- } field;
- UINT32 word;
-} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-#else
typedef union _PROT_CFG_STRUC {
struct {
UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
@@ -1104,7 +685,6 @@ typedef union _PROT_CFG_STRUC {
} field;
UINT32 word;
} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-#endif
#define OFDM_PROT_CFG 0x1368 //OFDM Protection
#define MM20_PROT_CFG 0x136C //MM20 Protection
@@ -1122,22 +702,6 @@ typedef union _PROT_CFG_STRUC {
//
// TXRX_CSR4: Auto-Responder/
//
-#ifdef RT_BIG_ENDIAN
-typedef union _AUTO_RSP_CFG_STRUC {
- struct {
- UINT32 :24;
- UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
- UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
- UINT32 rsv:1; // Power bit value in conrtrol frame
- UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
- UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
- UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
- UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
- UINT32 AutoResponderEnable:1;
- } field;
- UINT32 word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-#else
typedef union _AUTO_RSP_CFG_STRUC {
struct {
UINT32 AutoResponderEnable:1;
@@ -1152,7 +716,6 @@ typedef union _AUTO_RSP_CFG_STRUC {
} field;
UINT32 word;
} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-#endif
#define LEGACY_BASIC_RATE 0x1408 // TXRX_CSR5 0x3054
#define HT_BASIC_RATE 0x140c
@@ -1185,15 +748,6 @@ typedef union _AUTO_RSP_CFG_STRUC {
//
// RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT0_STRUC {
- struct {
- USHORT PhyErr;
- USHORT CrcErr;
- } field;
- UINT32 word;
-} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-#else
typedef union _RX_STA_CNT0_STRUC {
struct {
USHORT CrcErr;
@@ -1201,20 +755,10 @@ typedef union _RX_STA_CNT0_STRUC {
} field;
UINT32 word;
} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-#endif
//
// RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT1_STRUC {
- struct {
- USHORT PlcpErr;
- USHORT FalseCca;
- } field;
- UINT32 word;
-} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-#else
typedef union _RX_STA_CNT1_STRUC {
struct {
USHORT FalseCca;
@@ -1222,20 +766,10 @@ typedef union _RX_STA_CNT1_STRUC {
} field;
UINT32 word;
} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-#endif
//
// RX_STA_CNT2_STRUC:
//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT2_STRUC {
- struct {
- USHORT RxFifoOverflowCount;
- USHORT RxDupliCount;
- } field;
- UINT32 word;
-} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#else
typedef union _RX_STA_CNT2_STRUC {
struct {
USHORT RxDupliCount;
@@ -1243,20 +777,11 @@ typedef union _RX_STA_CNT2_STRUC {
} field;
UINT32 word;
} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#endif
+
#define TX_STA_CNT0 0x170C //
//
// STA_CSR3: TX Beacon count
//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT0_STRUC {
- struct {
- USHORT TxBeaconCount;
- USHORT TxFailCount;
- } field;
- UINT32 word;
-} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#else
typedef union _TX_STA_CNT0_STRUC {
struct {
USHORT TxFailCount;
@@ -1264,20 +789,11 @@ typedef union _TX_STA_CNT0_STRUC {
} field;
UINT32 word;
} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#endif
+
#define TX_STA_CNT1 0x1710 //
//
// TX_STA_CNT1: TX tx count
//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT1_STRUC {
- struct {
- USHORT TxRetransmit;
- USHORT TxSuccess;
- } field;
- UINT32 word;
-} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#else
typedef union _TX_STA_CNT1_STRUC {
struct {
USHORT TxSuccess;
@@ -1285,20 +801,11 @@ typedef union _TX_STA_CNT1_STRUC {
} field;
UINT32 word;
} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#endif
+
#define TX_STA_CNT2 0x1714 //
//
// TX_STA_CNT2: TX tx count
//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT2_STRUC {
- struct {
- USHORT TxUnderFlowCount;
- USHORT TxZeroLenCount;
- } field;
- UINT32 word;
-} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#else
typedef union _TX_STA_CNT2_STRUC {
struct {
USHORT TxZeroLenCount;
@@ -1306,28 +813,11 @@ typedef union _TX_STA_CNT2_STRUC {
} field;
UINT32 word;
} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#endif
+
#define TX_STA_FIFO 0x1718 //
//
// TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
//
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_STA_FIFO_STRUC {
- struct {
- UINT32 Reserve:2;
- UINT32 TxBF:1; // 3*3
- UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
-// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 wcid:8; //wireless client index
- UINT32 TxAckRequired:1; // ack required
- UINT32 TxAggre:1; // Tx is aggregated
- UINT32 TxSuccess:1; // Tx success. whether success or not
- UINT32 PidType:4;
- UINT32 bValid:1; // 1:This register contains a valid TX result
- } field;
- UINT32 word;
-} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-#else
typedef union PACKED _TX_STA_FIFO_STRUC {
struct {
UINT32 bValid:1; // 1:This register contains a valid TX result
@@ -1343,18 +833,9 @@ typedef union PACKED _TX_STA_FIFO_STRUC {
} field;
UINT32 word;
} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-#endif
+
// Debug counter
#define TX_AGG_CNT 0x171c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT_STRUC {
- struct {
- USHORT AggTxCount;
- USHORT NonAggTxCount;
- } field;
- UINT32 word;
-} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-#else
typedef union _TX_AGG_CNT_STRUC {
struct {
USHORT NonAggTxCount;
@@ -1362,18 +843,9 @@ typedef union _TX_AGG_CNT_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-#endif
+
// Debug counter
#define TX_AGG_CNT0 0x1720
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT0_STRUC {
- struct {
- USHORT AggSize2Count;
- USHORT AggSize1Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-#else
typedef union _TX_AGG_CNT0_STRUC {
struct {
USHORT AggSize1Count;
@@ -1381,18 +853,9 @@ typedef union _TX_AGG_CNT0_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-#endif
+
// Debug counter
#define TX_AGG_CNT1 0x1724
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT1_STRUC {
- struct {
- USHORT AggSize4Count;
- USHORT AggSize3Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#else
typedef union _TX_AGG_CNT1_STRUC {
struct {
USHORT AggSize3Count;
@@ -1400,17 +863,8 @@ typedef union _TX_AGG_CNT1_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#endif
+
#define TX_AGG_CNT2 0x1728
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT2_STRUC {
- struct {
- USHORT AggSize6Count;
- USHORT AggSize5Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-#else
typedef union _TX_AGG_CNT2_STRUC {
struct {
USHORT AggSize5Count;
@@ -1418,18 +872,9 @@ typedef union _TX_AGG_CNT2_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-#endif
+
// Debug counter
#define TX_AGG_CNT3 0x172c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT3_STRUC {
- struct {
- USHORT AggSize8Count;
- USHORT AggSize7Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-#else
typedef union _TX_AGG_CNT3_STRUC {
struct {
USHORT AggSize7Count;
@@ -1437,18 +882,9 @@ typedef union _TX_AGG_CNT3_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-#endif
+
// Debug counter
#define TX_AGG_CNT4 0x1730
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT4_STRUC {
- struct {
- USHORT AggSize10Count;
- USHORT AggSize9Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#else
typedef union _TX_AGG_CNT4_STRUC {
struct {
USHORT AggSize9Count;
@@ -1456,17 +892,8 @@ typedef union _TX_AGG_CNT4_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#endif
+
#define TX_AGG_CNT5 0x1734
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT5_STRUC {
- struct {
- USHORT AggSize12Count;
- USHORT AggSize11Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#else
typedef union _TX_AGG_CNT5_STRUC {
struct {
USHORT AggSize11Count;
@@ -1474,17 +901,8 @@ typedef union _TX_AGG_CNT5_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#endif
+
#define TX_AGG_CNT6 0x1738
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT6_STRUC {
- struct {
- USHORT AggSize14Count;
- USHORT AggSize13Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#else
typedef union _TX_AGG_CNT6_STRUC {
struct {
USHORT AggSize13Count;
@@ -1492,17 +910,8 @@ typedef union _TX_AGG_CNT6_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#endif
+
#define TX_AGG_CNT7 0x173c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT7_STRUC {
- struct {
- USHORT AggSize16Count;
- USHORT AggSize15Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#else
typedef union _TX_AGG_CNT7_STRUC {
struct {
USHORT AggSize15Count;
@@ -1510,17 +919,8 @@ typedef union _TX_AGG_CNT7_STRUC {
} field;
UINT32 word;
} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#endif
+
#define MPDU_DENSITY_CNT 0x1740
-#ifdef RT_BIG_ENDIAN
-typedef union _MPDU_DEN_CNT_STRUC {
- struct {
- USHORT RXZeroDelCount; //RX zero length delimiter count
- USHORT TXZeroDelCount; //TX zero length delimiter count
- } field;
- UINT32 word;
-} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-#else
typedef union _MPDU_DEN_CNT_STRUC {
struct {
USHORT TXZeroDelCount; //TX zero length delimiter count
@@ -1528,7 +928,7 @@ typedef union _MPDU_DEN_CNT_STRUC {
} field;
UINT32 word;
} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-#endif
+
//
// TXRX control registers - base address 0x3000
//
@@ -1554,30 +954,6 @@ typedef union _MPDU_DEN_CNT_STRUC {
#define SHAREDKEYTABLE 0
#define PAIRWISEKEYTABLE 1
-
-#ifdef RT_BIG_ENDIAN
-typedef union _SHAREDKEY_MODE_STRUC {
- struct {
- UINT32 :1;
- UINT32 Bss1Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key0CipherAlg:3;
- } field;
- UINT32 word;
-} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-#else
typedef union _SHAREDKEY_MODE_STRUC {
struct {
UINT32 Bss0Key0CipherAlg:3;
@@ -1599,7 +975,7 @@ typedef union _SHAREDKEY_MODE_STRUC {
} field;
UINT32 word;
} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-#endif
+
// 64-entry for pairwise key table
typedef struct _HW_WCID_ENTRY { // 8-byte per entry
UCHAR Address[6];
@@ -1670,10 +1046,16 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry
#define E2PROM_CSR 0x0004
#define IO_CNTL_CSR 0x77d0
+#ifdef RT2860
// 8051 firmware image for RT2860 - base address = 0x4000
#define FIRMWARE_IMAGE_BASE 0x2000
#define MAX_FIRMWARE_IMAGE_SIZE 0x2000 // 8kbyte
-
+#endif
+#ifdef RT2870
+// 8051 firmware image for usb - use last-half base address = 0x3000
+#define FIRMWARE_IMAGE_BASE 0x3000
+#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 // 4kbyte
+#endif // RT2870 //
// ================================================================
// Tx / Rx / Mgmt ring descriptor definition
@@ -1754,6 +1136,9 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry
#define BBP_R22 22
#define BBP_R24 24
#define BBP_R25 25
+#ifdef RT30xx
+#define BBP_R31 31
+#endif
#define BBP_R49 49 //TSSI
#define BBP_R50 50
#define BBP_R51 51
@@ -1771,6 +1156,10 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry
#define BBP_R73 73
#define BBP_R75 75
#define BBP_R77 77
+#ifdef RT30xx
+#define BBP_R79 79
+#define BBP_R80 80
+#endif
#define BBP_R81 81
#define BBP_R82 82
#define BBP_R83 83
@@ -1792,6 +1181,9 @@ typedef struct _HW_WCID_ENTRY { // 8-byte per entry
#define BBP_R121 121
#define BBP_R122 122
#define BBP_R123 123
+#ifdef RT30xx
+#define BBP_R138 138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
+#endif // RT30xx //
#define BBPR94_DEFAULT 0x06 // Add 1 value will gain 1db
@@ -1872,15 +1264,6 @@ typedef struct _HW_KEY_ENTRY { // 32-byte per entry
//8.1.2 IV/EIV format : 2DW
//8.1.3 RX attribute entry format : 1DW
-#ifdef RT_BIG_ENDIAN
-typedef struct _MAC_ATTRIBUTE_STRUC {
- UINT32 rsv:22;
- UINT32 RXWIUDF:3;
- UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
- UINT32 PairKeyMode:3;
- UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
-} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-#else
typedef struct _MAC_ATTRIBUTE_STRUC {
UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
UINT32 PairKeyMode:3;
@@ -1888,8 +1271,6 @@ typedef struct _MAC_ATTRIBUTE_STRUC {
UINT32 RXWIUDF:3;
UINT32 rsv:22;
} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-#endif
-
// =================================================================================
// TX / RX ring descriptor format
@@ -1904,29 +1285,6 @@ typedef struct _MAC_ATTRIBUTE_STRUC {
//
// TX descriptor format, Tx ring, Mgmt Ring
//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _TXD_STRUC {
- // Word 0
- UINT32 SDPtr0;
- // Word 1
- UINT32 DMADONE:1;
- UINT32 LastSec0:1;
- UINT32 SDLen0:14;
- UINT32 Burst:1;
- UINT32 LastSec1:1;
- UINT32 SDLen1:14;
- // Word 2
- UINT32 SDPtr1;
- // Word 3
- UINT32 ICO:1;
- UINT32 UCO:1;
- UINT32 TCO:1;
- UINT32 rsv:2;
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 rsv2:24;
-} TXD_STRUC, *PTXD_STRUC;
-#else
typedef struct PACKED _TXD_STRUC {
// Word 0
UINT32 SDPtr0;
@@ -1948,8 +1306,6 @@ typedef struct PACKED _TXD_STRUC {
UINT32 UCO:1; //
UINT32 ICO:1; //
} TXD_STRUC, *PTXD_STRUC;
-#endif
-
//
// TXD Wireless Information format for Tx ring and Mgmt Ring
@@ -1957,40 +1313,6 @@ typedef struct PACKED _TXD_STRUC {
//txop : for txop mode
// 0:txop for the MPDU frame will be handles by ASIC by register
// 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _TXWI_STRUC {
- // Word 0
- UINT32 PHYMODE:2;
- UINT32 TxBF:1; // 3*3
- UINT32 rsv2:1;
- UINT32 Ifs:1; //
- UINT32 STBC:2; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 MCS:7;
-
- UINT32 rsv:6;
- UINT32 txop:2; //tx back off mode 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
- UINT32 MpduDensity:3;
- UINT32 AMPDU:1;
-
- UINT32 TS:1;
- UINT32 CFACK:1;
- UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
- UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
- // Word 1
- UINT32 PacketId:4;
- UINT32 MPDUtotalByteCount:12;
- UINT32 WirelessCliID:8;
- UINT32 BAWinSize:6;
- UINT32 NSEQ:1;
- UINT32 ACK:1;
- // Word 2
- UINT32 IV;
- // Word 3
- UINT32 EIV;
-} TXWI_STRUC, *PTXWI_STRUC;
-#else
typedef struct PACKED _TXWI_STRUC {
// Word 0
UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
@@ -2023,45 +1345,11 @@ typedef struct PACKED _TXWI_STRUC {
//Word3
UINT32 EIV;
} TXWI_STRUC, *PTXWI_STRUC;
-#endif
+
//
// Rx descriptor format, Rx Ring
//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _RXD_STRUC {
- // Word 0
- UINT32 SDP0;
- // Word 1
- UINT32 DDONE:1;
- UINT32 LS0:1;
- UINT32 SDL0:14;
- UINT32 Rsv:2;
- UINT32 SDL1:14;
- // Word 2
- UINT32 SDP1;
- // Word 3
- UINT32 Rsv1:13;
- UINT32 PlcpRssil:1;// To be moved
- UINT32 PlcpSignal:1; // To be moved
- UINT32 Decrypted:1; // this frame is being decrypted.
- UINT32 AMPDU:1;
- UINT32 L2PAD:1;
- UINT32 RSSI:1;
- UINT32 HTC:1;
- UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header. obsolete.
- UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
- UINT32 Crc:1; // 1: CRC error
- UINT32 MyBss:1; // 1: this frame belongs to the same BSSID
- UINT32 Bcast:1; // 1: this is a broadcast frame
- UINT32 Mcast:1; // 1: this is a multicast frame
- UINT32 U2M:1; // 1: this RX frame is unicast to me
- UINT32 FRAG:1;
- UINT32 NULLDATA:1;
- UINT32 DATA:1;
- UINT32 BA:1;
-
-} RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#else
+#ifdef RT2860
typedef struct PACKED _RXD_STRUC {
// Word 0
UINT32 SDP0;
@@ -2094,39 +1382,11 @@ typedef struct PACKED _RXD_STRUC {
UINT32 PlcpRssil:1;// To be moved
UINT32 Rsv1:13;
} RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#endif
+#endif /* RT2860 */
+
//
// RXWI wireless information format, in PBF. invisible in driver.
//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _RXWI_STRUC {
- // Word 0
- UINT32 TID:4;
- UINT32 MPDUtotalByteCount:12;
- UINT32 UDF:3;
- UINT32 BSSID:3;
- UINT32 KeyIndex:2;
- UINT32 WirelessCliID:8;
- // Word 1
- UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
- UINT32 rsv:3;
- UINT32 STBC:2;
- UINT32 ShortGI:1;
- UINT32 BW:1;
- UINT32 MCS:7;
- UINT32 SEQUENCE:12;
- UINT32 FRAG:4;
- // Word 2
- UINT32 rsv1:8;
- UINT32 RSSI2:8;
- UINT32 RSSI1:8;
- UINT32 RSSI0:8;
- // Word 3
- UINT32 rsv2:16;
- UINT32 SNR1:8;
- UINT32 SNR0:8;
-} RXWI_STRUC, *PRXWI_STRUC;
-#else
typedef struct PACKED _RXWI_STRUC {
// Word 0
UINT32 WirelessCliID:8;
@@ -2154,8 +1414,6 @@ typedef struct PACKED _RXWI_STRUC {
UINT32 SNR1:8;
UINT32 rsv2:16;
} RXWI_STRUC, *PRXWI_STRUC;
-#endif
-
// =================================================================================
// HOST-MCU communication data structure
@@ -2164,17 +1422,6 @@ typedef struct PACKED _RXWI_STRUC {
//
// H2M_MAILBOX_CSR: Host-to-MCU Mailbox
//
-#ifdef RT_BIG_ENDIAN
-typedef union _H2M_MAILBOX_STRUC {
- struct {
- UINT32 Owner:8;
- UINT32 CmdToken:8; // 0xff tells MCU not to report CmdDoneInt after excuting the command
- UINT32 HighByte:8;
- UINT32 LowByte:8;
- } field;
- UINT32 word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-#else
typedef union _H2M_MAILBOX_STRUC {
struct {
UINT32 LowByte:8;
@@ -2184,22 +1431,10 @@ typedef union _H2M_MAILBOX_STRUC {
} field;
UINT32 word;
} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-#endif
//
// M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
//
-#ifdef RT_BIG_ENDIAN
-typedef union _M2H_CMD_DONE_STRUC {
- struct {
- UINT32 CmdToken3;
- UINT32 CmdToken2;
- UINT32 CmdToken1;
- UINT32 CmdToken0;
- } field;
- UINT32 word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-#else
typedef union _M2H_CMD_DONE_STRUC {
struct {
UINT32 CmdToken0;
@@ -2209,22 +1444,10 @@ typedef union _M2H_CMD_DONE_STRUC {
} field;
UINT32 word;
} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-#endif
-
-
//
// MCU_LEDCS: MCU LED Control Setting.
//
-#ifdef RT_BIG_ENDIAN
-typedef union _MCU_LEDCS_STRUC {
- struct {
- UCHAR Polarity:1;
- UCHAR LedMode:7;
- } field;
- UCHAR word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-#else
typedef union _MCU_LEDCS_STRUC {
struct {
UCHAR LedMode:7;
@@ -2232,7 +1455,7 @@ typedef union _MCU_LEDCS_STRUC {
} field;
UCHAR word;
} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-#endif
+
// =================================================================================
// Register format
// =================================================================================
@@ -2240,18 +1463,6 @@ typedef union _MCU_LEDCS_STRUC {
//NAV_TIME_CFG :NAV
-#ifdef RT_BIG_ENDIAN
-typedef union _NAV_TIME_CFG_STRUC {
- struct {
- USHORT rsv:6;
- USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
- USHORT Eifs:9; // in unit of 1-us
- UCHAR SlotTime; // in unit of 1-us
- UCHAR Sifs; // in unit of 1-us
- } field;
- UINT32 word;
-} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-#else
typedef union _NAV_TIME_CFG_STRUC {
struct {
UCHAR Sifs; // in unit of 1-us
@@ -2262,44 +1473,10 @@ typedef union _NAV_TIME_CFG_STRUC {
} field;
UINT32 word;
} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-#endif
-
-
-
-
//
// RX_FILTR_CFG: /RX configuration register
//
-#ifdef RT_BIG_ENDIAN
-typedef union RX_FILTR_CFG_STRUC {
- struct {
- UINT32 :15;
- UINT32 DropRsvCntlType:1;
-
- UINT32 DropBAR:1; //
- UINT32 DropBA:1; //
- UINT32 DropPsPoll:1; // Drop Ps-Poll
- UINT32 DropRts:1; // Drop Ps-Poll
-
- UINT32 DropCts:1; // Drop Ps-Poll
- UINT32 DropAck:1; // Drop Ps-Poll
- UINT32 DropCFEnd:1; // Drop Ps-Poll
- UINT32 DropCFEndAck:1; // Drop Ps-Poll
-
- UINT32 DropDuplicate:1; // Drop duplicate frame
- UINT32 DropBcast:1; // Drop broadcast frames
- UINT32 DropMcast:1; // Drop multicast frames
- UINT32 DropVerErr:1; // Drop version error frame
-
- UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
- UINT32 DropNotToMe:1; // Drop not to me unicast frame
- UINT32 DropPhyErr:1; // Drop physical error
- UINT32 DropCRCErr:1; // Drop CRC error
- } field;
- UINT32 word;
-} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-#else
typedef union _RX_FILTR_CFG_STRUC {
struct {
UINT32 DropCRCErr:1; // Drop CRC error
@@ -2327,26 +1504,10 @@ typedef union _RX_FILTR_CFG_STRUC {
} field;
UINT32 word;
} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-#endif
-
-
-
//
// PHY_CSR4: RF serial control register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _PHY_CSR4_STRUC {
- struct {
- UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
- UINT32 PLL_LD:1; // RF PLL_LD status
- UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
- UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
- UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
- } field;
- UINT32 word;
-} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-#else
typedef union _PHY_CSR4_STRUC {
struct {
UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
@@ -2357,35 +1518,10 @@ typedef union _PHY_CSR4_STRUC {
} field;
UINT32 word;
} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-#endif
-
//
// SEC_CSR5: shared key table security mode register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _SEC_CSR5_STRUC {
- struct {
- UINT32 :1;
- UINT32 Bss3Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key0CipherAlg:3;
- } field;
- UINT32 word;
-} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-#else
typedef union _SEC_CSR5_STRUC {
struct {
UINT32 Bss2Key0CipherAlg:3;
@@ -2407,21 +1543,10 @@ typedef union _SEC_CSR5_STRUC {
} field;
UINT32 word;
} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-#endif
-
//
// HOST_CMD_CSR: For HOST to interrupt embedded processor
//
-#ifdef RT_BIG_ENDIAN
-typedef union _HOST_CMD_CSR_STRUC {
- struct {
- UINT32 Rsv:24;
- UINT32 HostCommand:8;
- } field;
- UINT32 word;
-} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-#else
typedef union _HOST_CMD_CSR_STRUC {
struct {
UINT32 HostCommand:8;
@@ -2429,8 +1554,6 @@ typedef union _HOST_CMD_CSR_STRUC {
} field;
UINT32 word;
} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-#endif
-
//
// AIFSN_CSR: AIFSN for each EDCA AC
@@ -2441,21 +1564,6 @@ typedef union _HOST_CMD_CSR_STRUC {
//
// E2PROM_CSR: EEPROM control register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _E2PROM_CSR_STRUC {
- struct {
- UINT32 Rsvd:25;
- UINT32 LoadStatus:1; // 1:loading, 0:done
- UINT32 Type:1; // 1: 93C46, 0:93C66
- UINT32 EepromDO:1;
- UINT32 EepromDI:1;
- UINT32 EepromCS:1;
- UINT32 EepromSK:1;
- UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
- } field;
- UINT32 word;
-} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-#else
typedef union _E2PROM_CSR_STRUC {
struct {
UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
@@ -2469,8 +1577,6 @@ typedef union _E2PROM_CSR_STRUC {
} field;
UINT32 word;
} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-#endif
-
// -------------------------------------------------------------------
// E2PROM data layout
@@ -2479,17 +1585,6 @@ typedef union _E2PROM_CSR_STRUC {
//
// EEPROM antenna select format
//
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_ANTENNA_STRUC {
- struct {
- USHORT Rsv:4;
- USHORT RfIcType:4; // see E2PROM document
- USHORT TxPath:4; // 1: 1T, 2: 2T
- USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
- } field;
- USHORT word;
-} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-#else
typedef union _EEPROM_ANTENNA_STRUC {
struct {
USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
@@ -2499,26 +1594,7 @@ typedef union _EEPROM_ANTENNA_STRUC {
} field;
USHORT word;
} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-#endif
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_NIC_CINFIG2_STRUC {
- struct {
- USHORT Rsv2:6; // must be 0
- USHORT BW40MAvailForA:1; // 0:enable, 1:disable
- USHORT BW40MAvailForG:1; // 0:enable, 1:disable
- USHORT EnableWPSPBC:1; // WPS PBC Control bit
- USHORT BW40MSidebandForA:1;
- USHORT BW40MSidebandForG:1;
- USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
- USHORT ExternalLNAForA:1; // external LNA enable for 5G
- USHORT ExternalLNAForG:1; // external LNA enable for 2.4G
- USHORT DynamicTxAgcControl:1; //
- USHORT HardwareRadioControl:1; // Whether RF is controlled by driver or HW. 1:enable hw control, 0:disable
- } field;
- USHORT word;
-} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-#else
typedef union _EEPROM_NIC_CINFIG2_STRUC {
struct {
USHORT HardwareRadioControl:1; // 1:enable, 0:disable
@@ -2531,24 +1607,22 @@ typedef union _EEPROM_NIC_CINFIG2_STRUC {
USHORT EnableWPSPBC:1; // WPS PBC Control bit
USHORT BW40MAvailForG:1; // 0:enable, 1:disable
USHORT BW40MAvailForA:1; // 0:enable, 1:disable
+#ifndef RT30xx
USHORT Rsv2:6; // must be 0
+#endif
+#ifdef RT30xx
+ USHORT Rsv1:1; // must be 0
+ USHORT AntDiversity:1; // Antenna diversity
+ USHORT Rsv2:3; // must be 0
+ USHORT DACTestBit:1; // control if driver should patch the DAC issue
+#endif
} field;
USHORT word;
} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-#endif
//
// TX_PWR Value valid range 0xFA(-6) ~ 0x24(36)
//
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_TX_PWR_STRUC {
- struct {
- CHAR Byte1; // High Byte
- CHAR Byte0; // Low Byte
- } field;
- USHORT word;
-} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-#else
typedef union _EEPROM_TX_PWR_STRUC {
struct {
CHAR Byte0; // Low Byte
@@ -2556,17 +1630,7 @@ typedef union _EEPROM_TX_PWR_STRUC {
} field;
USHORT word;
} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-#endif
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_VERSION_STRUC {
- struct {
- UCHAR Version; // High Byte
- UCHAR FaeReleaseNumber; // Low Byte
- } field;
- USHORT word;
-} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-#else
typedef union _EEPROM_VERSION_STRUC {
struct {
UCHAR FaeReleaseNumber; // Low Byte
@@ -2574,25 +1638,7 @@ typedef union _EEPROM_VERSION_STRUC {
} field;
USHORT word;
} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-#endif
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_LED_STRUC {
- struct {
- USHORT Rsvd:3; // Reserved
- USHORT LedMode:5; // Led mode.
- USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
- USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
- USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
- USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
- USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
- USHORT PolarityACT:1; // Polarity ACT setting.
- USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
- USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
- } field;
- USHORT word;
-} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-#else
typedef union _EEPROM_LED_STRUC {
struct {
USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
@@ -2608,18 +1654,7 @@ typedef union _EEPROM_LED_STRUC {
} field;
USHORT word;
} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-#endif
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_TXPOWER_DELTA_STRUC {
- struct {
- UCHAR TxPowerEnable:1;// Enable
- UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
- UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
- } field;
- UCHAR value;
-} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-#else
typedef union _EEPROM_TXPOWER_DELTA_STRUC {
struct {
UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
@@ -2628,22 +1663,10 @@ typedef union _EEPROM_TXPOWER_DELTA_STRUC {
} field;
UCHAR value;
} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-#endif
//
// QOS_CSR0: TXOP holder address0 register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _QOS_CSR0_STRUC {
- struct {
- UCHAR Byte3; // MAC address byte 3
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte0; // MAC address byte 0
- } field;
- UINT32 word;
-} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-#else
typedef union _QOS_CSR0_STRUC {
struct {
UCHAR Byte0; // MAC address byte 0
@@ -2653,22 +1676,10 @@ typedef union _QOS_CSR0_STRUC {
} field;
UINT32 word;
} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-#endif
//
// QOS_CSR1: TXOP holder address1 register
//
-#ifdef RT_BIG_ENDIAN
-typedef union _QOS_CSR1_STRUC {
- struct {
- UCHAR Rsvd1;
- UCHAR Rsvd0;
- UCHAR Byte5; // MAC address byte 5
- UCHAR Byte4; // MAC address byte 4
- } field;
- UINT32 word;
-} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-#else
typedef union _QOS_CSR1_STRUC {
struct {
UCHAR Byte4; // MAC address byte 4
@@ -2678,22 +1689,8 @@ typedef union _QOS_CSR1_STRUC {
} field;
UINT32 word;
} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-#endif
#define RF_CSR_CFG 0x500
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG_STRUC {
- struct {
- UINT Rsvd1:14; // Reserved
- UINT RF_CSR_KICK:1; // kick RF register read/write
- UINT RF_CSR_WR:1; // 0: read 1: write
- UINT Rsvd2:3; // Reserved
- UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
- UINT RF_CSR_DATA:8; // DATA
- } field;
- UINT word;
-} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-#else
typedef union _RF_CSR_CFG_STRUC {
struct {
UINT RF_CSR_DATA:8; // DATA
@@ -2705,6 +1702,5 @@ typedef union _RF_CSR_CFG_STRUC {
} field;
UINT word;
} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-#endif
#endif // __RT28XX_H__
diff --git a/drivers/staging/rt2860/rt_ate.c b/drivers/staging/rt2860/rt_ate.c
deleted file mode 100644
index 1ed73c9e6b60..000000000000
--- a/drivers/staging/rt2860/rt_ate.c
+++ /dev/null
@@ -1,6009 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-#ifdef RALINK_ATE
-UCHAR TemplateFrame[24] = {0x08/* Data type */,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
-extern RTMP_RF_REGS RF2850RegTable[];
-extern UCHAR NUM_OF_2850_CHNL;
-
-static CHAR CCKRateTable[] = {0, 1, 2, 3, 8, 9, 10, 11, -1}; /* CCK Mode. */
-static CHAR OFDMRateTable[] = {0, 1, 2, 3, 4, 5, 6, 7, -1}; /* OFDM Mode. */
-static CHAR HTMIXRateTable[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}; /* HT Mix Mode. */
-
-static INT TxDmaBusy(
- IN PRTMP_ADAPTER pAd);
-
-static INT RxDmaBusy(
- IN PRTMP_ADAPTER pAd);
-
-static VOID RtmpDmaEnable(
- IN PRTMP_ADAPTER pAd,
- IN INT Enable);
-
-static VOID BbpSoftReset(
- IN PRTMP_ADAPTER pAd);
-
-static VOID RtmpRfIoWrite(
- IN PRTMP_ADAPTER pAd);
-
-static INT ATESetUpFrame(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TxIdx);
-
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index);
-
-static INT ATECmdHandler(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-static int CheckMCSValid(
- IN UCHAR Mode,
- IN UCHAR Mcs);
-
-static VOID ATEWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pOutTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN CFACK,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR TID,
- IN UCHAR TxRate,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING *pTransmit);
-
-
-static VOID SetJapanFilter(
- IN PRTMP_ADAPTER pAd);
-
-/*=========================end of prototype=========================*/
-
-static INT TxDmaBusy(
- IN PRTMP_ADAPTER pAd)
-{
- INT result;
- WPDMA_GLO_CFG_STRUC GloCfg;
-
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
- if (GloCfg.field.TxDMABusy)
- result = 1;
- else
- result = 0;
-
- return result;
-}
-
-static INT RxDmaBusy(
- IN PRTMP_ADAPTER pAd)
-{
- INT result;
- WPDMA_GLO_CFG_STRUC GloCfg;
-
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
- if (GloCfg.field.RxDMABusy)
- result = 1;
- else
- result = 0;
-
- return result;
-}
-
-static VOID RtmpDmaEnable(
- IN PRTMP_ADAPTER pAd,
- IN INT Enable)
-{
- BOOLEAN value;
- ULONG WaitCnt;
- WPDMA_GLO_CFG_STRUC GloCfg;
-
- value = Enable > 0 ? 1 : 0;
-
- // check DMA is in busy mode.
- WaitCnt = 0;
- while (TxDmaBusy(pAd) || RxDmaBusy(pAd))
- {
- RTMPusecDelay(10);
- if (WaitCnt++ > 100)
- break;
- }
-
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
- GloCfg.field.EnableTxDMA = value;
- GloCfg.field.EnableRxDMA = value;
- RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word); // abort all TX rings
- RTMPusecDelay(5000);
-
- return;
-}
-
-
-static VOID BbpSoftReset(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BbpData = 0;
-
- // Soft reset, set BBP R21 bit0=1->0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R21, &BbpData);
- BbpData |= 0x00000001; //set bit0=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R21, BbpData);
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R21, &BbpData);
- BbpData &= ~(0x00000001); //set bit0=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R21, BbpData);
-
- return;
-}
-
-static VOID RtmpRfIoWrite(
- IN PRTMP_ADAPTER pAd)
-{
- // Set RF value 1's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 2's set R3[bit2] = [1]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 | 0x04));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 3's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- return;
-}
-
-static int CheckMCSValid(
- UCHAR Mode,
- UCHAR Mcs)
-{
- int i;
- PCHAR pRateTab;
-
- switch(Mode)
- {
- case 0:
- pRateTab = CCKRateTable;
- break;
- case 1:
- pRateTab = OFDMRateTable;
- break;
- case 2:
- case 3:
- pRateTab = HTMIXRateTable;
- break;
- default:
- ATEDBGPRINT(RT_DEBUG_ERROR, ("unrecognizable Tx Mode %d\n", Mode));
- return -1;
- break;
- }
-
- i = 0;
- while(pRateTab[i] != -1)
- {
- if (pRateTab[i] == Mcs)
- return 0;
- i++;
- }
-
- return -1;
-}
-
-#if 1
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index)
-{
- ULONG R;
- CHAR TxPower;
- UCHAR Bbp94 = 0;
- BOOLEAN bPowerReduce = FALSE;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
- ** are not synchronized.
- */
-/*
- pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
- pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
-*/
- return 0;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- TxPower = index == 0 ? pAd->ate.TxPower0 : pAd->ate.TxPower1;
-
- if (pAd->ate.Channel <= 14)
- {
- if (TxPower > 31)
- {
- //
- // R3, R4 can't large than 31 (0x24), 31 ~ 36 used by BBP 94
- //
- R = 31;
- if (TxPower <= 36)
- Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
- //
- R = 0;
- if (TxPower >= -6)
- Bbp94 = BBPR94_DEFAULT + TxPower;
- }
- else
- {
- // 0 ~ 31
- R = (ULONG) TxPower;
- Bbp94 = BBPR94_DEFAULT;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
- }
- else// 5.5 GHz
- {
- if (TxPower > 15)
- {
- //
- // R3, R4 can't large than 15 (0x0F)
- //
- R = 15;
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0
- //
- // -1 ~ -7
- ASSERT((TxPower >= -7));
- R = (ULONG)(TxPower + 7);
- bPowerReduce = TRUE;
- }
- else
- {
- // 0 ~ 15
- R = (ULONG) TxPower;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __func__, TxPower, R));
- }
-
- if (pAd->ate.Channel <= 14)
- {
- if (index == 0)
- {
- R = R << 9; // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = R << 6; // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else// 5.5GHz
- {
- if (bPowerReduce == FALSE)
- {
- if (index == 0)
- {
- R = (R << 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = (R << 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else
- {
- if (index == 0)
- {
- R = (R << 10); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
-
- /* Clear bit 9 of R3 to reduce 7dB. */
- pAd->LatchRfRegs.R3 = (R & (~(1 << 9)));
- }
- else
- {
- R = (R << 7); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
-
- /* Clear bit 6 of R4 to reduce 7dB. */
- pAd->LatchRfRegs.R4 = (R & (~(1 << 6)));
- }
- }
- }
-
- RtmpRfIoWrite(pAd);
-
- return 0;
- }
-}
-#else// 1 //
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index)
-{
- ULONG R;
- CHAR TxPower;
- UCHAR Bbp94 = 0;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- // TODO: how to get current TxPower0/1 from pAd->LatchRfRegs ?
- /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
- ** are not synchronized.
- */
-/*
- pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
- pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
-*/
- return 0;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- TxPower = index == 0 ? pAd->ate.TxPower0 : pAd->ate.TxPower1;
-
- if (TxPower > 31)
- {
- //
- // R3, R4 can't large than 36 (0x24), 31 ~ 36 used by BBP 94
- //
- R = 31;
- if (TxPower <= 36)
- Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
- //
- R = 0;
- if (TxPower >= -6)
- Bbp94 = BBPR94_DEFAULT + TxPower;
- }
- else
- {
- // 0 ~ 31
- R = (ULONG) TxPower;
- Bbp94 = BBPR94_DEFAULT;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
-
- if (pAd->ate.Channel <= 14)
- {
- if (index == 0)
- {
- R = R << 9; // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = R << 6; // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else
- {
- if (index == 0)
- {
- R = (R << 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = (R << 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
-
- RtmpRfIoWrite(pAd);
-
- return 0;
- }
-}
-#endif // 1 //
-/*
- ==========================================================================
- Description:
- Set ATE operation mode to
- 0. ATESTART = Start ATE Mode
- 1. ATESTOP = Stop ATE Mode
- 2. TXCONT = Continuous Transmit
- 3. TXCARR = Transmit Carrier
- 4. TXFRAME = Transmit Frames
- 5. RXFRAME = Receive Frames
-#ifdef RALINK_28xx_QA
- 6. TXSTOP = Stop Any Type of Transmition
- 7. RXSTOP = Stop Receiving Frames
-#endif // RALINK_28xx_QA //
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-static INT ATECmdHandler(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 Value = 0;
- UCHAR BbpData;
- UINT32 MacData = 0;
- PTXD_STRUC pTxD;
- INT index;
- UINT i=0, atemode;
- PRXD_STRUC pRxD;
- PRTMP_TX_RING pTxRing = &pAd->TxRing[QID_AC_BE];
-#ifndef UCOS
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
-#endif // UCOS //
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> ATECmdHandler()\n"));
-
- ATEAsicSwitchChannel(pAd);
- AsicLockChannel(pAd, pAd->ate.Channel);
-
- RTMPusecDelay(5000);
-
- // read MAC_SYS_CTRL and backup MAC_SYS_CTRL value.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- // clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
-
- if (!strcmp(arg, "ATESTART")) //Enter ATE mode and set Tx/Rx Idle
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: ATESTART\n"));
-
-#ifndef UCOS
- // check if we have removed the firmware
- if (!(ATE_ON(pAd)))
- {
- NICEraseFirmware(pAd);
- }
-#endif // !UCOS //
- atemode = pAd->ate.Mode;
- pAd->ate.Mode = ATE_START;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- if (atemode & ATE_TXCARR)
- {
- // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // No Carrier Suppression set BBP R24 bit0=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
- BbpData &= 0xFFFFFFFE; //clear bit0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
- }
- // We should free some resource which was allocated when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
- PRTMP_TX_RING pTxRing = &pAd->TxRing[QID_AC_BE];
-
- if (atemode & ATE_TXCONT)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- // Abort Tx, Rx DMA.
- RtmpDmaEnable(pAd, 0);
- for (i=0; i<TX_RING_SIZE; i++)
- {
- PNDIS_PACKET pPacket;
-
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC)pAd->TxRing[QID_AC_BE].Cell[i].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pAd->TxRing[QID_AC_BE].Cell[i].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- pTxD->DMADONE = 0;
- pPacket = pTxRing->Cell[i].pNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNdisPacket as NULL after clear
- pTxRing->Cell[i].pNdisPacket = NULL;
-
- pPacket = pTxRing->Cell[i].pNextNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNextNdisPacket as NULL after clear
- pTxRing->Cell[i].pNextNdisPacket = NULL;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
- }
- // Start Tx, RX DMA
- RtmpDmaEnable(pAd, 1);
- }
- // reset Rx statistics.
- pAd->ate.LastSNR0 = 0;
- pAd->ate.LastSNR1 = 0;
- pAd->ate.LastRssi0 = 0;
- pAd->ate.LastRssi1 = 0;
- pAd->ate.LastRssi2 = 0;
- pAd->ate.AvgRssi0 = 0;
- pAd->ate.AvgRssi1 = 0;
- pAd->ate.AvgRssi2 = 0;
- pAd->ate.AvgRssi0X8 = 0;
- pAd->ate.AvgRssi1X8 = 0;
- pAd->ate.AvgRssi2X8 = 0;
- pAd->ate.NumOfAvgRssiSample = 0;
-
-#ifdef RALINK_28xx_QA
- // Tx frame
- pAd->ate.bQATxStart = FALSE;
- pAd->ate.bQARxStart = FALSE;
- pAd->ate.seq = 0;
-
- // counters
- pAd->ate.U2M = 0;
- pAd->ate.OtherData = 0;
- pAd->ate.Beacon = 0;
- pAd->ate.OtherCount = 0;
- pAd->ate.TxAc0 = 0;
- pAd->ate.TxAc1 = 0;
- pAd->ate.TxAc2 = 0;
- pAd->ate.TxAc3 = 0;
- pAd->ate.TxHCCA = 0;
- pAd->ate.TxMgmt = 0;
- pAd->ate.RSSI0 = 0;
- pAd->ate.RSSI1 = 0;
- pAd->ate.RSSI2 = 0;
- pAd->ate.SNR0 = 0;
- pAd->ate.SNR1 = 0;
-
- // control
- pAd->ate.TxDoneCount = 0;
- pAd->ate.TxStatus = 0; // task Tx status // 0 --> task is idle, 1 --> task is running
-#endif // RALINK_28xx_QA //
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
-
-#ifdef CONFIG_STA_SUPPORT
- //
- // LinkDown() has "AsicDisableSync();" and "RTMP_BBP_IO_R/W8_BY_REG_ID();" inside.
- //
-// LinkDown(pAd, FALSE);
-// AsicEnableBssSync(pAd);
-#ifndef UCOS
- netif_stop_queue(pAd->net_dev);
-#endif // !UCOS //
- //
- // If we skip "LinkDown()", we should disable protection
- // to prevent from sending out RTS or CTS-to-self.
- //
- ATEDisableAsicProtect(pAd);
- RTMPStationStop(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- /* Disable Tx */
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- /* Disable Rx */
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
- else if (!strcmp(arg, "ATESTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: ATESTOP\n"));
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData); // recover the MAC_SYS_CTRL register back.
-
- // Disable Tx, Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= (0xfffffff3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
-#ifndef UCOS
- pAd->ate.bFWLoading = TRUE;
- Status = NICLoadFirmware(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
- return FALSE;
- }
-#endif // !UCOS //
- pAd->ate.Mode = ATE_STOP;
-
-
-#ifdef CONFIG_STA_SUPPORT
- //
- // Even the firmware has been loaded,
- // we still could use ATE_BBP_IO_READ8_BY_REG_ID().
- // But this is not suggested.
- //
- BbpSoftReset(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- NICDisableInterrupt(pAd);
-
- NICInitializeAdapter(pAd, TRUE);
-
-
- // Reinitialize Rx Ring before Rx DMA is enabled.
- // The nightmare of >>>RxCoherent<<< was gone !
- for (index = 0; index < RX_RING_SIZE; index++)
- {
- pRxD = (PRXD_STRUC) pAd->RxRing.Cell[index].AllocVa;
- pRxD->DDONE = 0;
- }
-
- // We should read EEPROM for all cases.
- NICReadEEPROMParameters(pAd, NULL);
- NICInitAsicFromEEPROM(pAd);
-
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- //
- // Enable Interrupt
- //
-
- //
- // These steps are only for APAutoSelectChannel().
- //
-#if 0
- //pAd->bStaFifoTest = TRUE;
- pAd->int_enable_reg = ((DELAYINTMASK) | (RxINT|TxDataInt|TxMgmtInt)) & ~(0x03);
- pAd->int_disable_mask = 0;
- pAd->int_pending = 0;
-#endif
- RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff); // clear garbage interrupts
- NICEnableInterrupt(pAd);
-
-
-/*=========================================================================*/
- /* restore RX_FILTR_CFG */
-#ifdef CONFIG_STA_SUPPORT
- /* restore RX_FILTR_CFG due to that QA maybe set it to 0x3 */
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL);
-#endif // CONFIG_STA_SUPPORT //
-/*=========================================================================*/
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Enable Tx, Rx DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-
-#ifdef CONFIG_STA_SUPPORT
- RTMPStationStart(pAd);
-#endif // CONFIG_STA_SUPPORT //
-#ifndef UCOS
- netif_start_queue(pAd->net_dev);
-#endif // !UCOS //
- }
- else if (!strcmp(arg, "TXCARR")) // Tx Carrier
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXCARR\n"));
- pAd->ate.Mode |= ATE_TXCARR;
-
- // QA has done the following steps if it is used.
- if (pAd->ate.bQATxStart == FALSE)
- {
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Carrier Test set BBP R22 bit7=1, bit6=1, bit[5~0]=0x01
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- BbpData |= 0x000000C1; //set bit7=1, bit6=1, bit[5~0]=0x01
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value = Value | 0x00000010;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
- }
- else if (!strcmp(arg, "TXCONT")) // Tx Continue
- {
- if (pAd->ate.bQATxStart == TRUE)
- {
- /* set MAC_SYS_CTRL(0x1004) bit4(Continuous Tx Production Test)
- and bit2(MAC TX enable) back to zero. */
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData &= 0xFFFFFFEB;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- // set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF7F; //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
-
- /* for TxCont mode.
- ** Step 1: Send 50 packets first then wait for a moment.
- ** Step 2: Send more 50 packet then start continue mode.
- */
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXCONT\n"));
- // Step 1: send 50 packets first.
- pAd->ate.Mode |= ATE_TXCONT;
- pAd->ate.TxCount = 50;
- /* Do it after Tx/Rx DMA is aborted. */
-// pAd->ate.TxDoneCount = 0;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Fix can't smooth kick
- {
- RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QID_AC_BE * 0x10, &pTxRing->TxDmaIdx);
- pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
- pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);
- }
-
- pAd->ate.TxDoneCount = 0;
-
- /* Only needed if we have to send some normal frames. */
- SetJapanFilter(pAd);
-
- for (i = 0; (i < TX_RING_SIZE-1) && (i < pAd->ate.TxCount); i++)
- {
- PNDIS_PACKET pPacket;
- UINT32 TxIdx = pTxRing->TxCpuIdx;
-
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- // Clean current cell.
- pPacket = pTxRing->Cell[TxIdx].pNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNdisPacket as NULL after clear
- pTxRing->Cell[TxIdx].pNdisPacket = NULL;
-
- pPacket = pTxRing->Cell[TxIdx].pNextNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNextNdisPacket as NULL after clear
- pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
-
- if (ATESetUpFrame(pAd, TxIdx) != 0)
- break;
-
- INC_RING_INDEX(pTxRing->TxCpuIdx, TX_RING_SIZE);
- }
-
- // Setup frame format.
- ATESetUpFrame(pAd, pTxRing->TxCpuIdx);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#endif // RALINK_28xx_QA //
-
- // kick Tx-Ring.
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * RINGREG_DIFF, pAd->TxRing[QID_AC_BE].TxCpuIdx);
-
- RTMPusecDelay(5000);
-
-
- // Step 2: send more 50 packets then start continue mode.
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Cont. TX set BBP R22 bit7=1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData |= 0x00000080; //set bit7=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- pAd->ate.TxCount = 50;
-
- // Fix can't smooth kick
- {
- RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QID_AC_BE * 0x10, &pTxRing->TxDmaIdx);
- pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
- pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);
- }
-
- pAd->ate.TxDoneCount = 0;
-
- SetJapanFilter(pAd);
-
- for (i = 0; (i < TX_RING_SIZE-1) && (i < pAd->ate.TxCount); i++)
- {
- PNDIS_PACKET pPacket;
- UINT32 TxIdx = pTxRing->TxCpuIdx;
-
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- // clean current cell.
- pPacket = pTxRing->Cell[TxIdx].pNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNdisPacket as NULL after clear
- pTxRing->Cell[TxIdx].pNdisPacket = NULL;
-
- pPacket = pTxRing->Cell[TxIdx].pNextNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNextNdisPacket as NULL after clear
- pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
-
- if (ATESetUpFrame(pAd, TxIdx) != 0)
- break;
-
- INC_RING_INDEX(pTxRing->TxCpuIdx, TX_RING_SIZE);
- }
-
- ATESetUpFrame(pAd, pTxRing->TxCpuIdx);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#endif // RALINK_28xx_QA //
-
- // kick Tx-Ring.
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * RINGREG_DIFF, pAd->TxRing[QID_AC_BE].TxCpuIdx);
-
- RTMPusecDelay(500);
-
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData |= 0x00000010;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
- }
- else if (!strcmp(arg, "TXFRAME")) // Tx Frames
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXFRAME(Count=%d)\n", pAd->ate.TxCount));
- pAd->ate.Mode |= ATE_TXFRAME;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Fix can't smooth kick
- {
- RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QID_AC_BE * 0x10, &pTxRing->TxDmaIdx);
- pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
- pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);
- }
-
- pAd->ate.TxDoneCount = 0;
-
- SetJapanFilter(pAd);
-
- for (i = 0; (i < TX_RING_SIZE-1) && (i < pAd->ate.TxCount); i++)
- {
- PNDIS_PACKET pPacket;
- UINT32 TxIdx = pTxRing->TxCpuIdx;
-
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- // Clean current cell.
- pPacket = pTxRing->Cell[TxIdx].pNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNdisPacket as NULL after clear
- pTxRing->Cell[TxIdx].pNdisPacket = NULL;
-
- pPacket = pTxRing->Cell[TxIdx].pNextNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNextNdisPacket as NULL after clear
- pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
-
- if (ATESetUpFrame(pAd, TxIdx) != 0)
- break;
-
- INC_RING_INDEX(pTxRing->TxCpuIdx, TX_RING_SIZE);
-
- }
-
- ATESetUpFrame(pAd, pTxRing->TxCpuIdx);
-
- // Start Tx, Rx DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-#ifdef RALINK_28xx_QA
- // add this for LoopBack mode
- if (pAd->ate.bQARxStart == FALSE)
- {
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
-
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#else
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-#endif // RALINK_28xx_QA //
-
- RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QID_AC_BE * RINGREG_DIFF, &pAd->TxRing[QID_AC_BE].TxDmaIdx);
- // kick Tx-Ring.
- RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * RINGREG_DIFF, pAd->TxRing[QID_AC_BE].TxCpuIdx);
-
- pAd->RalinkCounters.KickTxCount++;
- }
-#ifdef RALINK_28xx_QA
- else if (!strcmp(arg, "TXSTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXSTOP\n"));
- atemode = pAd->ate.Mode;
- pAd->ate.Mode &= ATE_TXSTOP;
- pAd->ate.bQATxStart = FALSE;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
-
- if (atemode & ATE_TXCARR)
- {
- // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // No Carrier Suppression set BBP R24 bit0=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
- BbpData &= 0xFFFFFFFE; //clear bit0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
- }
- // We should free some resource which allocate when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
-
- PRTMP_TX_RING pTxRing = &pAd->TxRing[QID_AC_BE];
-
- if (atemode & ATE_TXCONT)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
-
- // Abort Tx, Rx DMA.
- RtmpDmaEnable(pAd, 0);
- for (i=0; i<TX_RING_SIZE; i++)
- {
- PNDIS_PACKET pPacket;
-
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC)pAd->TxRing[QID_AC_BE].Cell[i].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pAd->TxRing[QID_AC_BE].Cell[i].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-#endif
- pTxD->DMADONE = 0;
- pPacket = pTxRing->Cell[i].pNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNdisPacket as NULL after clear
- pTxRing->Cell[i].pNdisPacket = NULL;
-
- pPacket = pTxRing->Cell[i].pNextNdisPacket;
- if (pPacket)
- {
- PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
- }
- //Always assign pNextNdisPacket as NULL after clear
- pTxRing->Cell[i].pNextNdisPacket = NULL;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif
- }
- // Enable Tx, Rx DMA
- RtmpDmaEnable(pAd, 1);
-
- }
-
- // control
-// pAd->ate.TxDoneCount = 0;
- pAd->ate.TxStatus = 0; // task Tx status // 0 --> task is idle, 1 --> task is running
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
- else if (!strcmp(arg, "RXSTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: RXSTOP\n"));
- atemode = pAd->ate.Mode;
- pAd->ate.Mode &= ATE_RXSTOP;
- pAd->ate.bQARxStart = FALSE;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
-
- if (atemode & ATE_TXCARR)
- {
- ;
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
- ;
- }
-
- // We should free some resource which was allocated when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
- if (atemode & ATE_TXCONT)
- {
- ;
- }
- }
-
- // control
-// pAd->ate.TxDoneCount = 0;
-// pAd->ate.TxStatus = 0; // task Tx status // 0 --> task is idle, 1 --> task is running
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
-#endif // RALINK_28xx_QA //
- else if (!strcmp(arg, "RXFRAME")) // Rx Frames
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: RXFRAME\n"));
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- pAd->ate.Mode |= ATE_RXFRAME;
-
- // Disable Tx of MAC block.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Enable Rx of MAC block.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: Invalid arg!\n"));
- return FALSE;
- }
- RTMPusecDelay(5000);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== ATECmdHandler()\n"));
-
- return TRUE;
-}
-/* */
-/* */
-/*=======================End of RT2860=======================*/
-
-
-/*======================Start of RT2870======================*/
-/* */
-/* */
-
-
-INT Set_ATE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (ATECmdHandler(pAd, arg))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_Proc Success\n"));
-
-
- return TRUE;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_Proc Failed\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR1=DA for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_DA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr3[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_DA_Proc (DA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr3[0],
- pAd->ate.Addr3[1], pAd->ate.Addr3[2], pAd->ate.Addr3[3], pAd->ate.Addr3[4], pAd->ate.Addr3[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_DA_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR3=SA for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR2=SA for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_SA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr2[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_SA_Proc (SA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr2[0],
- pAd->ate.Addr2[1], pAd->ate.Addr2[2], pAd->ate.Addr2[3], pAd->ate.Addr2[4], pAd->ate.Addr2[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_SA_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR2=BSSID for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR1=BSSID for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_BSSID_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr1[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_BSSID_Proc (BSSID = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr1[0],
- pAd->ate.Addr1[1], pAd->ate.Addr1[2], pAd->ate.Addr1[3], pAd->ate.Addr1[4], pAd->ate.Addr1[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_BSSID_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Channel
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_CHANNEL_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR channel;
-
- channel = simple_strtol(arg, 0, 10);
-
- if ((channel < 1) || (channel > 216))// to allow A band channel : ((channel < 1) || (channel > 14))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_CHANNEL_Proc::Out of range, it should be in range of 1~14.\n"));
- return FALSE;
- }
- pAd->ate.Channel = channel;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAd->ate.Channel));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_CHANNEL_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Power0
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_POWER0_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR TxPower;
-
- TxPower = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.Channel <= 14)
- {
- if ((TxPower > 31) || (TxPower < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
- else// 5.5GHz
- {
- if ((TxPower > 15) || (TxPower < -7))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
-
- pAd->ate.TxPower0 = TxPower;
- ATETxPwrHandler(pAd, 0);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER0_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Power1
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_POWER1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR TxPower;
-
- TxPower = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.Channel <= 14)
- {
- if ((TxPower > 31) || (TxPower < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
- else
- {
- if ((TxPower > 15) || (TxPower < -7))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
-
- pAd->ate.TxPower1 = TxPower;
- ATETxPwrHandler(pAd, 1);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER1_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Antenna
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR value;
-
- value = simple_strtol(arg, 0, 10);
-
- if ((value > 2) || (value < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_Antenna_Proc::Out of range (Value=%d)\n", value));
- return FALSE;
- }
-
- pAd->ate.TxAntennaSel = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_Antenna_Proc (Antenna = %d)\n", pAd->ate.TxAntennaSel));
- ATEDBGPRINT(RT_DEBUG_TRACE,("Ralink: Set_ATE_TX_Antenna_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Rx Antenna
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_RX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR value;
-
- value = simple_strtol(arg, 0, 10);
-
- if ((value > 3) || (value < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_RX_Antenna_Proc::Out of range (Value=%d)\n", value));
- return FALSE;
- }
-
- pAd->ate.RxAntennaSel = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_Antenna_Proc (Antenna = %d)\n", pAd->ate.RxAntennaSel));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_Antenna_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE RF frequence offset
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_FREQOFFSET_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR RFFreqOffset;
- ULONG R4;
-
- RFFreqOffset = simple_strtol(arg, 0, 10);
-
- if(RFFreqOffset >= 64)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_FREQOFFSET_Proc::Out of range, it should be in range of 0~63.\n"));
- return FALSE;
- }
-
- pAd->ate.RFFreqOffset = RFFreqOffset;
- R4 = pAd->ate.RFFreqOffset << 15; // shift TX power control to correct RF register bit position
- R4 |= (pAd->LatchRfRegs.R4 & ((~0x001f8000)));
- pAd->LatchRfRegs.R4 = R4;
-
- RtmpRfIoWrite(pAd);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_FREQOFFSET_Proc (RFFreqOffset = %d)\n", pAd->ate.RFFreqOffset));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_FREQOFFSET_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE RF BW
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_BW_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- int i;
- UCHAR value = 0;
- UCHAR BBPCurrentBW;
-
- BBPCurrentBW = simple_strtol(arg, 0, 10);
-
- if(BBPCurrentBW == 0)
- pAd->ate.TxWI.BW = BW_20;
- else
- pAd->ate.TxWI.BW = BW_40;
-
- if(pAd->ate.TxWI.BW == BW_20)
- {
- if(pAd->ate.Channel <= 14)
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx20MPwrCfgGBand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgGBand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
- else
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx20MPwrCfgABand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgABand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
-
- //Set BBP R4 bit[4:3]=0:0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value &= (~0x18);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
-
- //Set BBP R66=0x3C
- value = 0x3C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
- //Set BBP R68=0x0B
- //to improve Rx sensitivity.
- value = 0x0B;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R68, value);
- //Set BBP R69=0x16
- value = 0x16;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, value);
- //Set BBP R70=0x08
- value = 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, value);
- //Set BBP R73=0x11
- value = 0x11;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, value);
-
- // If Channel=14, Bandwidth=20M and Mode=CCK, Set BBP R4 bit5=1
- // (Japan filter coefficients)
- // This segment of code will only works when ATETXMODE and ATECHANNEL
- // were set to MODE_CCK and 14 respectively before ATETXBW is set to 0.
- //=====================================================================
- if (pAd->ate.Channel == 14)
- {
- int TxMode = pAd->ate.TxWI.PHYMODE;
- if (TxMode == MODE_CCK)
- {
- // when Channel==14 && Mode==CCK && BandWidth==20M, BBP R4 bit5=1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value |= 0x20; //set bit5=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
- }
- }
-
- //=====================================================================
- // If bandwidth != 40M, RF Reg4 bit 21 = 0.
- pAd->LatchRfRegs.R4 &= ~0x00200000;
- RtmpRfIoWrite(pAd);
- }
- else if(pAd->ate.TxWI.BW == BW_40)
- {
- if(pAd->ate.Channel <= 14)
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx40MPwrCfgGBand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgGBand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
- else
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx40MPwrCfgABand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgABand[i]);
- RTMPusecDelay(5000);
- }
- }
-#ifdef DOT11_N_SUPPORT
- if ((pAd->ate.TxWI.PHYMODE >= MODE_HTMIX) && (pAd->ate.TxWI.MCS == 7))
- {
- value = 0x28;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R67, value);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
- //Set BBP R4 bit[4:3]=1:0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value &= (~0x18);
- value |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
-
- //Set BBP R66=0x3C
- value = 0x3C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
- //Set BBP R68=0x0C
- //to improve Rx sensitivity.
- value = 0x0C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R68, value);
- //Set BBP R69=0x1A
- value = 0x1A;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, value);
- //Set BBP R70=0x0A
- value = 0x0A;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, value);
- //Set BBP R73=0x16
- value = 0x16;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, value);
-
- // If bandwidth = 40M, set RF Reg4 bit 21 = 1.
- pAd->LatchRfRegs.R4 |= 0x00200000;
- RtmpRfIoWrite(pAd);
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_BW_Proc (BBPCurrentBW = %d)\n", pAd->ate.TxWI.BW));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_BW_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame length
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_LENGTH_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxLength = simple_strtol(arg, 0, 10);
-
- if((pAd->ate.TxLength < 24) || (pAd->ate.TxLength > (MAX_FRAME_SIZE - 34/* == 2312 */)))
- {
- pAd->ate.TxLength = (MAX_FRAME_SIZE - 34/* == 2312 */);
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_LENGTH_Proc::Out of range, it should be in range of 24~%d.\n", (MAX_FRAME_SIZE - 34/* == 2312 */)));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_LENGTH_Proc (TxLength = %d)\n", pAd->ate.TxLength));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_LENGTH_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame count
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_COUNT_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxCount = simple_strtol(arg, 0, 10);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAd->ate.TxCount));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame MCS
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_MCS_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR MCS;
- int result;
-
- MCS = simple_strtol(arg, 0, 10);
- result = CheckMCSValid(pAd->ate.TxWI.PHYMODE, MCS);
-
- if (result != -1)
- {
- pAd->ate.TxWI.MCS = (UCHAR)MCS;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MCS_Proc::Out of range, refer to rate table.\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MCS_Proc (MCS = %d)\n", pAd->ate.TxWI.MCS));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MCS_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame Mode
- 0: MODE_CCK
- 1: MODE_OFDM
- 2: MODE_HTMIX
- 3: MODE_HTGREENFIELD
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_MODE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxWI.PHYMODE = simple_strtol(arg, 0, 10);
-
- if(pAd->ate.TxWI.PHYMODE > 3)
- {
- pAd->ate.TxWI.PHYMODE = 0;
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MODE_Proc::Out of range. it should be in range of 0~3\n"));
- ATEDBGPRINT(RT_DEBUG_ERROR, ("0: CCK, 1: OFDM, 2: HT_MIX, 3: HT_GREEN_FIELD.\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MODE_Proc (TxMode = %d)\n", pAd->ate.TxWI.PHYMODE));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MODE_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame GI
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_GI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxWI.ShortGI = simple_strtol(arg, 0, 10);
-
- if(pAd->ate.TxWI.ShortGI > 1)
- {
- pAd->ate.TxWI.ShortGI = 0;
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_GI_Proc::Out of range\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_GI_Proc (GI = %d)\n", pAd->ate.TxWI.ShortGI));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_GI_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-INT Set_ATE_RX_FER_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.bRxFer = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.bRxFer == 1)
- {
- pAd->ate.RxCntPerSec = 0;
- pAd->ate.RxTotalCnt = 0;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_FER_Proc (bRxFer = %d)\n", pAd->ate.bRxFer));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_FER_Proc Success\n"));
-
-
- return TRUE;
-}
-
-INT Set_ATE_Read_RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print(KERN_EMERG "R1 = %lx\n", pAd->LatchRfRegs.R1);
- ate_print(KERN_EMERG "R2 = %lx\n", pAd->LatchRfRegs.R2);
- ate_print(KERN_EMERG "R3 = %lx\n", pAd->LatchRfRegs.R3);
- ate_print(KERN_EMERG "R4 = %lx\n", pAd->LatchRfRegs.R4);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R1 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF2_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R2 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF3_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R3 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF4_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R4 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Load and Write EEPROM from a binary file prepared in advance.
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-#ifndef UCOS
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN ret = FALSE;
- PUCHAR src = EEPROM_BIN_FILE_NAME;
- struct file *srcf;
- INT32 retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- USHORT WriteEEPROM[(EEPROM_SIZE/2)];
- UINT32 FileLength = 0;
- UINT32 value = simple_strtol(arg, 0, 10);
-
- ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __func__, value));
-
- if (value > 0)
- {
- /* zero the e2p buffer */
- NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
-
- /* save uid and gid used for filesystem access.
- ** set user and group to 0 (root)
- */
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- /* as root */
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- do
- {
- /* open the bin file */
- srcf = filp_open(src, O_RDONLY, 0);
-
- if (IS_ERR(srcf))
- {
- ate_print("%s - Error %ld opening %s\n", __func__, -PTR_ERR(srcf), src);
- break;
- }
-
- /* the object must have a read method */
- if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
- {
- ate_print("%s - %s does not have a read method\n", __func__, src);
- break;
- }
-
- /* read the firmware from the file *.bin */
- FileLength = srcf->f_op->read(srcf,
- (PUCHAR)WriteEEPROM,
- EEPROM_SIZE,
- &srcf->f_pos);
-
- if (FileLength != EEPROM_SIZE)
- {
- ate_print("%s: error file length (=%d) in e2p.bin\n",
- __func__, FileLength);
- break;
- }
- else
- {
- /* write the content of .bin file to EEPROM */
- rt_ee_write_all(pAd, WriteEEPROM);
- ret = TRUE;
- }
- break;
- } while(TRUE);
-
- /* close firmware file */
- if (IS_ERR(srcf))
- {
- ;
- }
- else
- {
- retval = filp_close(srcf, NULL);
- if (retval)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("--> Error %d closing %s\n", -retval, src));
-
- }
- }
-
- /* restore */
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
- }
- ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __func__, ret));
-
- return ret;
-
-}
-#else
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT WriteEEPROM[(EEPROM_SIZE/2)];
- struct iwreq *wrq = (struct iwreq *)arg;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __func__, wrq->u.data.length));
-
- if (wrq->u.data.length != EEPROM_SIZE)
- {
- ate_print("%s: error length (=%d) from host\n",
- __func__, wrq->u.data.length);
- return FALSE;
- }
- else/* (wrq->u.data.length == EEPROM_SIZE) */
- {
- /* zero the e2p buffer */
- NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
-
- /* fill the local buffer */
- NdisMoveMemory((PUCHAR)WriteEEPROM, wrq->u.data.pointer, wrq->u.data.length);
-
- do
- {
- /* write the content of .bin file to EEPROM */
- rt_ee_write_all(pAd, WriteEEPROM);
-
- } while(FALSE);
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __func__));
-
- return TRUE;
-
-}
-#endif // !UCOS //
-
-INT Set_ATE_Read_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT buffer[EEPROM_SIZE/2];
- USHORT *p;
- int i;
-
- rt_ee_read_all(pAd, (USHORT *)buffer);
- p = buffer;
- for (i = 0; i < (EEPROM_SIZE/2); i++)
- {
- ate_print("%4.4x ", *p);
- if (((i+1) % 16) == 0)
- ate_print("\n");
- p++;
- }
- return TRUE;
-}
-
-INT Set_ATE_Show_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print("Mode=%d\n", pAd->ate.Mode);
- ate_print("TxPower0=%d\n", pAd->ate.TxPower0);
- ate_print("TxPower1=%d\n", pAd->ate.TxPower1);
- ate_print("TxAntennaSel=%d\n", pAd->ate.TxAntennaSel);
- ate_print("RxAntennaSel=%d\n", pAd->ate.RxAntennaSel);
- ate_print("BBPCurrentBW=%d\n", pAd->ate.TxWI.BW);
- ate_print("GI=%d\n", pAd->ate.TxWI.ShortGI);
- ate_print("MCS=%d\n", pAd->ate.TxWI.MCS);
- ate_print("TxMode=%d\n", pAd->ate.TxWI.PHYMODE);
- ate_print("Addr1=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr1[0], pAd->ate.Addr1[1], pAd->ate.Addr1[2], pAd->ate.Addr1[3], pAd->ate.Addr1[4], pAd->ate.Addr1[5]);
- ate_print("Addr2=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr2[0], pAd->ate.Addr2[1], pAd->ate.Addr2[2], pAd->ate.Addr2[3], pAd->ate.Addr2[4], pAd->ate.Addr2[5]);
- ate_print("Addr3=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr3[0], pAd->ate.Addr3[1], pAd->ate.Addr3[2], pAd->ate.Addr3[3], pAd->ate.Addr3[4], pAd->ate.Addr3[5]);
- ate_print("Channel=%d\n", pAd->ate.Channel);
- ate_print("TxLength=%d\n", pAd->ate.TxLength);
- ate_print("TxCount=%u\n", pAd->ate.TxCount);
- ate_print("RFFreqOffset=%d\n", pAd->ate.RFFreqOffset);
- ate_print(KERN_EMERG "Set_ATE_Show_Proc Success\n");
- return TRUE;
-}
-
-INT Set_ATE_Help_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print("ATE=ATESTART, ATESTOP, TXCONT, TXCARR, TXFRAME, RXFRAME\n");
- ate_print("ATEDA\n");
- ate_print("ATESA\n");
- ate_print("ATEBSSID\n");
- ate_print("ATECHANNEL, range:0~14(unless A band !)\n");
- ate_print("ATETXPOW0, set power level of antenna 1.\n");
- ate_print("ATETXPOW1, set power level of antenna 2.\n");
- ate_print("ATETXANT, set TX antenna. 0:all, 1:antenna one, 2:antenna two.\n");
- ate_print("ATERXANT, set RX antenna.0:all, 1:antenna one, 2:antenna two, 3:antenna three.\n");
- ate_print("ATETXFREQOFFSET, set frequency offset, range 0~63\n");
- ate_print("ATETXBW, set BandWidth, 0:20MHz, 1:40MHz.\n");
- ate_print("ATETXLEN, set Frame length, range 24~%d\n", (MAX_FRAME_SIZE - 34/* == 2312 */));
- ate_print("ATETXCNT, set how many frame going to transmit.\n");
- ate_print("ATETXMCS, set MCS, reference to rate table.\n");
- ate_print("ATETXMODE, set Mode 0:CCK, 1:OFDM, 2:HT-Mix, 3:GreenField, reference to rate table.\n");
- ate_print("ATETXGI, set GI interval, 0:Long, 1:Short\n");
- ate_print("ATERXFER, 0:disable Rx Frame error rate. 1:enable Rx Frame error rate.\n");
- ate_print("ATERRF, show all RF registers.\n");
- ate_print("ATEWRF1, set RF1 register.\n");
- ate_print("ATEWRF2, set RF2 register.\n");
- ate_print("ATEWRF3, set RF3 register.\n");
- ate_print("ATEWRF4, set RF4 register.\n");
- ate_print("ATELDE2P, load EEPROM from .bin file.\n");
- ate_print("ATERE2P, display all EEPROM content.\n");
- ate_print("ATESHOW, display all parameters of ATE.\n");
- ate_print("ATEHELP, online help.\n");
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
-
- AsicSwitchChannel() dedicated for ATE.
-
- ==========================================================================
-*/
-VOID ATEAsicSwitchChannel(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0, Value = 0;
- CHAR TxPwer = 0, TxPwer2 = 0;
- UCHAR index, BbpValue = 0, R66 = 0x30;
- RTMP_RF_REGS *RFRegTable;
- UCHAR Channel;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- if (pAd->ate.Channel != pAd->LatchRfRegs.Channel)
- {
- pAd->ate.Channel = pAd->LatchRfRegs.Channel;
- }
- return;
- }
- else
-#endif // RALINK_28xx_QA //
- Channel = pAd->ate.Channel;
-
- // Select antenna
- AsicAntennaSelect(pAd, Channel);
-
- // fill Tx power value
- TxPwer = pAd->ate.TxPower0;
- TxPwer2 = pAd->ate.TxPower1;
-
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- /* But only 2850 and 2750 support 5.5GHz band... */
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- switch (pAd->ate.RxAntennaSel)
- {
- case 1:
- R2 |= 0x20040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x00;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 2:
- R2 |= 0x10040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x01;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- default:
- R2 |= 0x40;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- /* Only enable two Antenna to receive. */
- BbpValue |= 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- }
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
-
- if (pAd->Antenna.field.TxPath == 2)
- {
- if (pAd->ate.TxAntennaSel == 1)
- {
- R2 |= 0x4000; // If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7; //11100111B
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- else if (pAd->ate.TxAntennaSel == 2)
- {
- R2 |= 0x8000; // If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7;
- BbpValue |= 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- else
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7;
- BbpValue |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- }
- if (pAd->Antenna.field.RxPath == 3)
- {
- switch (pAd->ate.RxAntennaSel)
- {
- case 1:
- R2 |= 0x20040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x00;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 2:
- R2 |= 0x10040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x01;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 3:
- R2 |= 0x30000;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x02;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- default:
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- }
- }
-
- if (Channel > 14)
- {
- // initialize R3, R4
- R3 = (RFRegTable[index].R3 & 0xffffc1ff);
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15);
-
- // According the Rory's suggestion to solve the middle range issue.
- // 5.5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB
- // R3
- if ((TxPwer >= -7) && (TxPwer < 0))
- {
- TxPwer = (7+TxPwer);
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer=%d \n", TxPwer));
- }
- else
- {
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10) | (1 << 9);
- }
-
- // R4
- if ((TxPwer2 >= -7) && (TxPwer2 < 0))
- {
- TxPwer2 = (7+TxPwer2);
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer2=%d \n", TxPwer2));
- }
- else
- {
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7) | (1 << 6);
- }
- }
- else
- {
- R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); // set TX power0
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15) | (TxPwer2 <<6);// Set freq offset & TxPwr1
- }
-
- // Based on BBP current mode before changing RF channel.
- if (pAd->ate.TxWI.BW == BW_40)
- {
- R4 |=0x200000;
- }
-
- // Update variables
- pAd->LatchRfRegs.Channel = Channel;
- pAd->LatchRfRegs.R1 = RFRegTable[index].R1;
- pAd->LatchRfRegs.R2 = R2;
- pAd->LatchRfRegs.R3 = R3;
- pAd->LatchRfRegs.R4 = R4;
-
- RtmpRfIoWrite(pAd);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
- // Change BBP setting during switch from a->g, g->a
- if (Channel <= 14)
- {
- ULONG TxPinCfg = 0x00050F0A;// 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
-
- /* For 1T/2R chip only... */
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
- }
- else
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);
- }
-
- // According the Rory's suggestion to solve the middle range issue.
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R86, &BbpValue);
- ASSERT((BbpValue == 0x00));
- if ((BbpValue != 0x00))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
- }
-
- // 5.5GHz band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x04);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R.
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
- else
- {
- ULONG TxPinCfg = 0x00050F05;//2007.10.09 by Brian : 0x00050505 ==> 0x00050F05
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
-
- // According the Rory's suggestion to solve the middle range issue.
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R86, &BbpValue);
- ASSERT((BbpValue == 0x00));
- if ((BbpValue != 0x00))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
- }
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R91, &BbpValue);
- ASSERT((BbpValue == 0x04));
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R92, &BbpValue);
- ASSERT((BbpValue == 0x00));
-
- // 5.5GHz band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x02);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R.
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
-
- // R66 should be set according to Channel and use 20MHz when scanning
- if (Channel <= 14)
- {
- // BG band
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- {
- // 5.5 GHz band
- if (pAd->ate.TxWI.BW == BW_20)
- {
- R66 = (UCHAR)(0x32 + (GET_LNA_GAIN(pAd)*5)/3);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- {
- R66 = (UCHAR)(0x3A + (GET_LNA_GAIN(pAd)*5)/3);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
-
- //
- // On 11A, We should delay and wait RF/BBP to be stable
- // and the appropriate time should be 1000 micro seconds
- // 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
- //
- RTMPusecDelay(1000);
-
- if (Channel > 14)
- {
- // When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not.
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%u, Pwr1=%u, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- (R3 & 0x00003e00) >> 9,
- (R4 & 0x000007c0) >> 6,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
- }
-}
-
-//
-// In fact, no one will call this routine so far !
-//
-/*
- ==========================================================================
- Description:
- Gives CCK TX rate 2 more dB TX power.
- This routine works only in ATE mode.
-
- calculate desired Tx power in RF R3.Tx0~5, should consider -
- 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
- 1. TxPowerPercentage
- 2. auto calibration based on TSSI feedback
- 3. extra 2 db for CCK
- 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
-
- NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
- it should be called AFTER MlmeDynamicTxRateSwitching()
- ==========================================================================
- */
-VOID ATEAsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd)
-{
- INT i, j;
- CHAR DeltaPwr = 0;
- BOOLEAN bAutoTxAgc = FALSE;
- UCHAR TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;
- UCHAR BbpR49 = 0, idx;
- PCHAR pTxAgcCompensate;
- ULONG TxPwr[5];
- CHAR Value;
-
- /* no one calls this procedure so far */
- if (pAd->ate.TxWI.BW == BW_40)
- {
- if (pAd->ate.Channel > 14)
- {
- TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
- }
- }
- else
- {
- if (pAd->ate.Channel > 14)
- {
- TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
- }
- }
-
- // TX power compensation for temperature variation based on TSSI.
- // Do it per 4 seconds.
- if (pAd->Mlme.OneSecPeriodicRound % 4 == 0)
- {
- if (pAd->ate.Channel <= 14)
- {
- /* bg channel */
- bAutoTxAgc = pAd->bAutoTxAgcG;
- TssiRef = pAd->TssiRefG;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryG[0];
- TxAgcStep = pAd->TxAgcStepG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- /* a channel */
- bAutoTxAgc = pAd->bAutoTxAgcA;
- TssiRef = pAd->TssiRefA;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryA[0];
- TxAgcStep = pAd->TxAgcStepA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- {
- /* BbpR49 is unsigned char */
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);
-
- /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
- /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
- /* step value is defined in pAd->TxAgcStepG for tx power value */
-
- /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
- /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- above value are examined in mass factory production */
- /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
-
- /* plus is 0x10 ~ 0x40, minus is 0x60 ~ 0x90 */
- /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
- /* if value is 0x65, tx power will be -= TxAgcStep*(2-1) */
-
- if (BbpR49 > pTssiMinusBoundary[1])
- {
- // Reading is larger than the reference value.
- // Check for how large we need to decrease the Tx power.
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 <= pTssiMinusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should decrease, idx = 0 means there is nothing to compensate
-// if (R3 > (ULONG) (TxAgcStep * (idx-1)))
- *pTxAgcCompensate = -(TxAgcStep * (idx-1));
-// else
-// *pTxAgcCompensate = -((UCHAR)R3);
-
- DeltaPwr += (*pTxAgcCompensate);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else if (BbpR49 < pTssiPlusBoundary[1])
- {
- // Reading is smaller than the reference value
- // check for how large we need to increase the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 >= pTssiPlusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should increase, idx = 0 means there is nothing to compensate
- *pTxAgcCompensate = TxAgcStep * (idx-1);
- DeltaPwr += (*pTxAgcCompensate);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else
- {
- *pTxAgcCompensate = 0;
- ATEDBGPRINT(RT_DEBUG_TRACE, (" Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, 0));
- }
- }
- }
- else
- {
- if (pAd->ate.Channel <= 14)
- {
- bAutoTxAgc = pAd->bAutoTxAgcG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- bAutoTxAgc = pAd->bAutoTxAgcA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- DeltaPwr += (*pTxAgcCompensate);
- }
-
- /* calculate delta power based on the percentage specified from UI */
- // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
- // We lower TX power here according to the percentage specified from UI
- if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff) // AUTO TX POWER control
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW
- {
- DeltaPwr -= 1;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW
- {
- DeltaPwr -= 3;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW
- {
- DeltaPwr -= 6;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW
- {
- DeltaPwr -= 9;
- }
- else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW
- {
- DeltaPwr -= 12;
- }
-
- /* reset different new tx power for different TX rate */
- for(i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F); /* 0 ~ 15 */
-
- if ((Value + DeltaPwr) < 0)
- {
- Value = 0; /* min */
- }
- else if ((Value + DeltaPwr) > 0xF)
- {
- Value = 0xF; /* max */
- }
- else
- {
- Value += DeltaPwr; /* temperature compensation */
- }
-
- /* fill new value to CSR offset */
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
-
- /* write tx power value to CSR */
- /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
- TX power for OFDM 6M/9M
- TX power for CCK5.5M/11M
- TX power for CCK1M/2M */
- /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);
-
-
- }
- }
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Write TxWI for ATE mode.
-
- Return Value:
- None
- ========================================================================
-*/
-static VOID ATEWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pOutTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN CFACK,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR TID,
- IN UCHAR TxRate,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING *pTransmit)
-{
- TXWI_STRUC TxWI;
- PTXWI_STRUC pTxWI;
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- NdisZeroMemory(&TxWI, TXWI_SIZE);
- pTxWI = &TxWI;
-
- pTxWI->FRAG= FRAG;
-
- pTxWI->CFACK = CFACK;
- pTxWI->TS= InsTimestamp;
- pTxWI->AMPDU = AMPDU;
- pTxWI->ACK = Ack;
- pTxWI->txop= Txopmode;
-
- pTxWI->NSEQ = NSeq;
- // John tune the performace with Intel Client in 20 MHz performance
- if( BASize >7 )
- BASize =7;
-
- pTxWI->BAWinSize = BASize;
- pTxWI->WirelessCliID = WCID;
- pTxWI->MPDUtotalByteCount = Length;
- pTxWI->PacketId = PID;
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
- pTxWI->CFACK = CfAck;
- pTxWI->MIMOps = 0;
- pTxWI->MpduDensity = 0;
-
- pTxWI->PacketId = pTxWI->MCS;
- NdisMoveMemory(pOutTxWI, &TxWI, sizeof(TXWI_STRUC));
-
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Disable protection for ATE.
- ========================================================================
-*/
-VOID ATEDisableAsicProtect(
- IN PRTMP_ADAPTER pAd)
-{
- PROT_CFG_STRUC ProtCfg, ProtCfg4;
- UINT32 Protect[6];
- USHORT offset;
- UCHAR i;
- UINT32 MacReg = 0;
-
- // Config ASIC RTS threshold register
- RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
- MacReg &= 0xFF0000FF;
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
- RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
-
- // Initial common protection settings
- RTMPZeroMemory(Protect, sizeof(Protect));
- ProtCfg4.word = 0;
- ProtCfg.word = 0;
- ProtCfg.field.TxopAllowGF40 = 1;
- ProtCfg.field.TxopAllowGF20 = 1;
- ProtCfg.field.TxopAllowMM40 = 1;
- ProtCfg.field.TxopAllowMM20 = 1;
- ProtCfg.field.TxopAllowOfdm = 1;
- ProtCfg.field.TxopAllowCck = 1;
- ProtCfg.field.RTSThEn = 1;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-
- // Handle legacy(B/G) protection
- ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0;
- Protect[0] = ProtCfg.word;
- Protect[1] = ProtCfg.word;
-
- // NO PROTECT
- // 1.All STAs in the BSS are 20/40 MHz HT
- // 2. in ai 20/40MHz BSS
- // 3. all STAs are 20MHz in a 20MHz BSS
- // Pure HT. no protection.
-
- // MM20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[2] = 0x01744004;
-
- // MM40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[3] = 0x03f44084;
-
- // CF20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[4] = 0x01744004;
-
- // CF40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[5] = 0x03f44084;
-
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
-
- offset = CCK_PROT_CFG;
- for (i = 0;i < 6;i++)
- RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);
-
-}
-
-
-/* There are two ways to convert Rssi */
-#if 1
-//
-// The way used with GET_LNA_GAIN().
-//
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- LNAGain = GET_LNA_GAIN(pAd);
- if (pAd->LatchRfRegs.Channel > 14)
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-12 - RssiOffset - LNAGain - Rssi);
-}
-#else
-//
-// The way originally used in ATE of rt2860ap.
-//
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- if (pAd->LatchRfRegs.Channel > 14)
- {
- LNAGain = pAd->ALNAGain;
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- LNAGain = pAd->BLNAGain;
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-32 - RssiOffset + LNAGain - Rssi);
-}
-#endif /* end of #if 1 */
-
-/*
- ========================================================================
-
- Routine Description:
- Set Japan filter coefficients if needed.
- Note:
- This routine should only be called when
- entering TXFRAME mode or TXCONT mode.
-
- ========================================================================
-*/
-static VOID SetJapanFilter(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BbpData = 0;
-
- //
- // If Channel=14 and Bandwidth=20M and Mode=CCK, set BBP R4 bit5=1
- // (Japan Tx filter coefficients)when (TXFRAME or TXCONT).
- //
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BbpData);
-
- if ((pAd->ate.TxWI.PHYMODE == MODE_CCK) && (pAd->ate.Channel == 14) && (pAd->ate.TxWI.BW == BW_20))
- {
- BbpData |= 0x20; // turn on
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SetJapanFilter!!!\n"));
- }
- else
- {
- BbpData &= 0xdf; // turn off
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ClearJapanFilter!!!\n"));
- }
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BbpData);
-}
-
-VOID ATESampleRssi(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI)
-{
- /* There are two ways to collect RSSI. */
-#if 1
- //pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
- if (pRxWI->RSSI0 != 0)
- {
- pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
- pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
- pAd->ate.AvgRssi0 = pAd->ate.AvgRssi0X8 >> 3;
- }
- if (pRxWI->RSSI1 != 0)
- {
- pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
- pAd->ate.AvgRssi1X8 = (pAd->ate.AvgRssi1X8 - pAd->ate.AvgRssi1) + pAd->ate.LastRssi1;
- pAd->ate.AvgRssi1 = pAd->ate.AvgRssi1X8 >> 3;
- }
- if (pRxWI->RSSI2 != 0)
- {
- pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
- pAd->ate.AvgRssi2X8 = (pAd->ate.AvgRssi2X8 - pAd->ate.AvgRssi2) + pAd->ate.LastRssi2;
- pAd->ate.AvgRssi2 = pAd->ate.AvgRssi2X8 >> 3;
- }
-
- pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);// CHAR ==> UCHAR ?
- pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);// CHAR ==> UCHAR ?
-
- pAd->ate.NumOfAvgRssiSample ++;
-#else
- pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);
- pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);
- pAd->ate.RxCntPerSec++;
- pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
- pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
- pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
- pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
- pAd->ate.AvgRssi0 = pAd->ate.AvgRssi0X8 >> 3;
- pAd->ate.AvgRssi1X8 = (pAd->ate.AvgRssi1X8 - pAd->ate.AvgRssi1) + pAd->ate.LastRssi1;
- pAd->ate.AvgRssi1 = pAd->ate.AvgRssi1X8 >> 3;
- pAd->ate.AvgRssi2X8 = (pAd->ate.AvgRssi2X8 - pAd->ate.AvgRssi2) + pAd->ate.LastRssi2;
- pAd->ate.AvgRssi2 = pAd->ate.AvgRssi2X8 >> 3;
- pAd->ate.NumOfAvgRssiSample ++;
-#endif
-}
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPStationStop(
- IN PRTMP_ADAPTER pAd)
-{
-// BOOLEAN Cancelled;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStop\n"));
-
-#if 0
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-#endif
- // For rx statistics, we need to keep this timer running.
-// RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStop\n"));
-}
-
-VOID RTMPStationStart(
- IN PRTMP_ADAPTER pAd)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStart\n"));
-epAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- //
- // We did not cancel this timer when entering ATE mode.
- //
-// RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStart\n"));
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Setup Frame format.
- NOTE:
- This routine should only be used in ATE mode.
- ==========================================================================
- */
-static INT ATESetUpFrame(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TxIdx)
-{
- UINT j;
- PTXD_STRUC pTxD;
-#ifdef RT_BIG_ENDIAN
- PTXD_STRUC pDestTxD;
- TXD_STRUC TxD;
-#endif
- PNDIS_PACKET pPacket;
- PUCHAR pDest;
- PVOID AllocVa;
- NDIS_PHYSICAL_ADDRESS AllocPa;
- HTTRANSMIT_SETTING TxHTPhyMode;
-
- PRTMP_TX_RING pTxRing = &pAd->TxRing[QID_AC_BE];
- PTXWI_STRUC pTxWI = (PTXWI_STRUC) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
- PUCHAR pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
-
-#ifdef RALINK_28xx_QA
- PHEADER_802_11 pHeader80211;
-#endif // RALINK_28xx_QA //
-
- if (pAd->ate.bQATxStart == TRUE)
- {
- // always use QID_AC_BE and FIFO_EDCA
-
- // fill TxWI
- TxHTPhyMode.field.BW = pAd->ate.TxWI.BW;
- TxHTPhyMode.field.ShortGI = pAd->ate.TxWI.ShortGI;
- TxHTPhyMode.field.STBC = 0;
- TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
- TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
- ATEWriteTxWI(pAd, pTxWI, pAd->ate.TxWI.FRAG, pAd->ate.TxWI.CFACK, pAd->ate.TxWI.TS, pAd->ate.TxWI.AMPDU, pAd->ate.TxWI.ACK, pAd->ate.TxWI.NSEQ,
- pAd->ate.TxWI.BAWinSize, 0, pAd->ate.TxWI.MPDUtotalByteCount, pAd->ate.TxWI.PacketId, 0, 0, pAd->ate.TxWI.txop/*IFS_HTTXOP*/, pAd->ate.TxWI.CFACK/*FALSE*/, &TxHTPhyMode);
- }
- else
- {
- TxHTPhyMode.field.BW = pAd->ate.TxWI.BW;
- TxHTPhyMode.field.ShortGI = pAd->ate.TxWI.ShortGI;
- TxHTPhyMode.field.STBC = 0;
- TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
- TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
- ATEWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
- 4, 0, pAd->ate.TxLength, 0, 0, 0, IFS_HTTXOP, FALSE, &TxHTPhyMode);
- }
-
- // fill 802.11 header.
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- NdisMoveMemory(pDMAHeaderBufVA+TXWI_SIZE, pAd->ate.Header, pAd->ate.HLen);
- }
- else
-#endif // RALINK_28xx_QA //
- {
- NdisMoveMemory(pDMAHeaderBufVA+TXWI_SIZE, TemplateFrame, LENGTH_802_11);
- NdisMoveMemory(pDMAHeaderBufVA+TXWI_SIZE+4, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- NdisMoveMemory(pDMAHeaderBufVA+TXWI_SIZE+10, pAd->ate.Addr2, ETH_LENGTH_OF_ADDRESS);
- NdisMoveMemory(pDMAHeaderBufVA+TXWI_SIZE+16, pAd->ate.Addr3, ETH_LENGTH_OF_ADDRESS);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (((PUCHAR)pDMAHeaderBufVA)+TXWI_SIZE), DIR_READ, FALSE);
-#endif // RT_BIG_ENDIAN //
-
- /* alloc buffer for payload */
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- /* Why not use RTMP_AllocateTxPacketBuffer() instead of RTMP_AllocateRxPacketBuffer()? */
- pPacket = RTMP_AllocateRxPacketBuffer(pAd, pAd->ate.DLen + 0x100, FALSE, &AllocVa, &AllocPa);
- }
- else
-#endif // RALINK_28xx_QA //
- {
- /* Why not use RTMP_AllocateTxPacketBuffer() instead of RTMP_AllocateRxPacketBuffer()? */
- pPacket = RTMP_AllocateRxPacketBuffer(pAd, pAd->ate.TxLength, FALSE, &AllocVa, &AllocPa);
- }
-
- if (pPacket == NULL)
- {
- pAd->ate.TxCount = 0;
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s fail to alloc packet space.\n", __func__));
- return -1;
- }
- pTxRing->Cell[TxIdx].pNextNdisPacket = pPacket;
-
- pDest = (PUCHAR) AllocVa;
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- RTPKT_TO_OSPKT(pPacket)->len = pAd->ate.DLen;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- RTPKT_TO_OSPKT(pPacket)->len = pAd->ate.TxLength - LENGTH_802_11;
- }
-
- // Prepare frame payload
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- // copy pattern
- if ((pAd->ate.PLen != 0))
- {
- int j;
-
- for (j = 0; j < pAd->ate.DLen; j+=pAd->ate.PLen)
- {
- memcpy(RTPKT_TO_OSPKT(pPacket)->data + j, pAd->ate.Pattern, pAd->ate.PLen);
- }
- }
- }
- else
-#endif // RALINK_28xx_QA //
- {
- for(j = 0; j < RTPKT_TO_OSPKT(pPacket)->len; j++)
- pDest[j] = 0xA5;
- }
-
- //
- // build Tx Descriptor
- //
-#ifndef RT_BIG_ENDIAN
- pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
-#else
- pDestTxD = (PTXD_STRUC)pTxRing->Cell[TxIdx].AllocVa;
- TxD = *pDestTxD;
- pTxD = &TxD;
-#endif // !RT_BIG_ENDIAN //
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- // prepare TxD
- NdisZeroMemory(pTxD, TXD_SIZE);
- RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
- // build TX DESC
- pTxD->SDPtr0 = RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
- pTxD->SDLen0 = TXWI_SIZE + pAd->ate.HLen;
- pTxD->LastSec0 = 0;
- pTxD->SDPtr1 = AllocPa;
- pTxD->SDLen1 = RTPKT_TO_OSPKT(pPacket)->len;
- pTxD->LastSec1 = 1;
-
- pDest = (PUCHAR)pTxWI;
- pDest += TXWI_SIZE;
- pHeader80211 = (PHEADER_802_11)pDest;
-
- // modify sequence number....
- if (pAd->ate.TxDoneCount == 0)
- {
- pAd->ate.seq = pHeader80211->Sequence;
- }
- else
- pHeader80211->Sequence = ++pAd->ate.seq;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- NdisZeroMemory(pTxD, TXD_SIZE);
- RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
- // build TX DESC
- pTxD->SDPtr0 = RTMP_GetPhysicalAddressLow (pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
- pTxD->SDLen0 = TXWI_SIZE + LENGTH_802_11;
- pTxD->LastSec0 = 0;
- pTxD->SDPtr1 = AllocPa;
- pTxD->SDLen1 = RTPKT_TO_OSPKT(pPacket)->len;
- pTxD->LastSec1 = 1;
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
- RTMPFrameEndianChange(pAd, (((PUCHAR)pDMAHeaderBufVA)+TXWI_SIZE), DIR_WRITE, FALSE);
- RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
- WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
-#endif // RT_BIG_ENDIAN //
- return 0;
-}
-/* */
-/* */
-/*=======================End of RT2860=======================*/
-
-
-VOID rt_ee_read_all(PRTMP_ADAPTER pAd, USHORT *Data)
-{
- USHORT i;
- USHORT value;
-
- for (i = 0 ; i < EEPROM_SIZE/2 ; )
- {
- /* "value" is expecially for some compilers... */
- RT28xx_EEPROM_READ16(pAd, i*2, value);
- Data[i] = value;
- i++;
- }
-}
-
-VOID rt_ee_write_all(PRTMP_ADAPTER pAd, USHORT *Data)
-{
- USHORT i;
- USHORT value;
-
- for (i = 0 ; i < EEPROM_SIZE/2 ; )
- {
- /* "value" is expecially for some compilers... */
- value = Data[i];
- RT28xx_EEPROM_WRITE16(pAd, i*2, value);
- i ++;
- }
-}
-#ifdef RALINK_28xx_QA
-VOID ATE_QA_Statistics(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC pRxD,
- IN PHEADER_802_11 pHeader)
-{
- // update counter first
- if (pHeader != NULL)
- {
- if (pHeader->FC.Type == BTYPE_DATA)
- {
- if (pRxD->U2M)
- pAd->ate.U2M++;
- else
- pAd->ate.OtherData++;
- }
- else if (pHeader->FC.Type == BTYPE_MGMT)
- {
- if (pHeader->FC.SubType == SUBTYPE_BEACON)
- pAd->ate.Beacon++;
- else
- pAd->ate.OtherCount++;
- }
- else if (pHeader->FC.Type == BTYPE_CNTL)
- {
- pAd->ate.OtherCount++;
- }
- }
- pAd->ate.RSSI0 = pRxWI->RSSI0;
- pAd->ate.RSSI1 = pRxWI->RSSI1;
- pAd->ate.RSSI2 = pRxWI->RSSI2;
- pAd->ate.SNR0 = pRxWI->SNR0;
- pAd->ate.SNR1 = pRxWI->SNR1;
-}
-
-/* command id with Cmd Type == 0x0008(for 28xx)/0x0005(for iNIC) */
-#define RACFG_CMD_RF_WRITE_ALL 0x0000
-#define RACFG_CMD_E2PROM_READ16 0x0001
-#define RACFG_CMD_E2PROM_WRITE16 0x0002
-#define RACFG_CMD_E2PROM_READ_ALL 0x0003
-#define RACFG_CMD_E2PROM_WRITE_ALL 0x0004
-#define RACFG_CMD_IO_READ 0x0005
-#define RACFG_CMD_IO_WRITE 0x0006
-#define RACFG_CMD_IO_READ_BULK 0x0007
-#define RACFG_CMD_BBP_READ8 0x0008
-#define RACFG_CMD_BBP_WRITE8 0x0009
-#define RACFG_CMD_BBP_READ_ALL 0x000a
-#define RACFG_CMD_GET_COUNTER 0x000b
-#define RACFG_CMD_CLEAR_COUNTER 0x000c
-
-#define RACFG_CMD_RSV1 0x000d
-#define RACFG_CMD_RSV2 0x000e
-#define RACFG_CMD_RSV3 0x000f
-
-#define RACFG_CMD_TX_START 0x0010
-#define RACFG_CMD_GET_TX_STATUS 0x0011
-#define RACFG_CMD_TX_STOP 0x0012
-#define RACFG_CMD_RX_START 0x0013
-#define RACFG_CMD_RX_STOP 0x0014
-#define RACFG_CMD_GET_NOISE_LEVEL 0x0015
-
-#define RACFG_CMD_ATE_START 0x0080
-#define RACFG_CMD_ATE_STOP 0x0081
-
-#define RACFG_CMD_ATE_START_TX_CARRIER 0x0100
-#define RACFG_CMD_ATE_START_TX_CONT 0x0101
-#define RACFG_CMD_ATE_START_TX_FRAME 0x0102
-#define RACFG_CMD_ATE_SET_BW 0x0103
-#define RACFG_CMD_ATE_SET_TX_POWER0 0x0104
-#define RACFG_CMD_ATE_SET_TX_POWER1 0x0105
-#define RACFG_CMD_ATE_SET_FREQ_OFFSET 0x0106
-#define RACFG_CMD_ATE_GET_STATISTICS 0x0107
-#define RACFG_CMD_ATE_RESET_COUNTER 0x0108
-#define RACFG_CMD_ATE_SEL_TX_ANTENNA 0x0109
-#define RACFG_CMD_ATE_SEL_RX_ANTENNA 0x010a
-#define RACFG_CMD_ATE_SET_PREAMBLE 0x010b
-#define RACFG_CMD_ATE_SET_CHANNEL 0x010c
-#define RACFG_CMD_ATE_SET_ADDR1 0x010d
-#define RACFG_CMD_ATE_SET_ADDR2 0x010e
-#define RACFG_CMD_ATE_SET_ADDR3 0x010f
-#define RACFG_CMD_ATE_SET_RATE 0x0110
-#define RACFG_CMD_ATE_SET_TX_FRAME_LEN 0x0111
-#define RACFG_CMD_ATE_SET_TX_FRAME_COUNT 0x0112
-#define RACFG_CMD_ATE_START_RX_FRAME 0x0113
-#define RACFG_CMD_ATE_E2PROM_READ_BULK 0x0114
-#define RACFG_CMD_ATE_E2PROM_WRITE_BULK 0x0115
-#define RACFG_CMD_ATE_IO_WRITE_BULK 0x0116
-#define RACFG_CMD_ATE_BBP_READ_BULK 0x0117
-#define RACFG_CMD_ATE_BBP_WRITE_BULK 0x0118
-#define RACFG_CMD_ATE_RF_READ_BULK 0x0119
-#define RACFG_CMD_ATE_RF_WRITE_BULK 0x011a
-
-
-
-#define A2Hex(_X, _p) \
-{ \
- UCHAR *p; \
- _X = 0; \
- p = _p; \
- while (((*p >= 'a') && (*p <= 'f')) || ((*p >= 'A') && (*p <= 'F')) || ((*p >= '0') && (*p <= '9'))) \
- { \
- if ((*p >= 'a') && (*p <= 'f')) \
- _X = _X * 16 + *p - 87; \
- else if ((*p >= 'A') && (*p <= 'F')) \
- _X = _X * 16 + *p - 55; \
- else if ((*p >= '0') && (*p <= '9')) \
- _X = _X * 16 + *p - 48; \
- p++; \
- } \
-}
-
-
-static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len);
-static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len);
-static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32 len);
-
-#ifdef UCOS
-int ate_copy_to_user(
- IN PUCHAR payload,
- IN PUCHAR msg,
- IN INT len)
-{
- memmove(payload, msg, len);
- return 0;
-}
-
-#undef copy_to_user
-#define copy_to_user(x,y,z) ate_copy_to_user((PUCHAR)x, (PUCHAR)y, z)
-#endif // UCOS //
-
-#define LEN_OF_ARG 16
-
-VOID RtmpDoAte(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- unsigned short Command_Id;
- struct ate_racfghdr *pRaCfg;
- INT Status = NDIS_STATUS_SUCCESS;
-
-
-
- if((pRaCfg = kmalloc(sizeof(struct ate_racfghdr), GFP_KERNEL)) == NULL)
- {
- Status = -EINVAL;
- return;
- }
-
- NdisZeroMemory(pRaCfg, sizeof(struct ate_racfghdr));
-
- if (copy_from_user((PUCHAR)pRaCfg, wrq->u.data.pointer, wrq->u.data.length))
- {
- Status = -EFAULT;
- kfree(pRaCfg);
- return;
- }
-
-
- Command_Id = ntohs(pRaCfg->command_id);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __func__, Command_Id));
-
- switch (Command_Id)
- {
- // We will get this command when QA starts.
- case RACFG_CMD_ATE_START:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START\n"));
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_ATE_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START is done !\n"));
- }
- Set_ATE_Proc(pAdapter, "ATESTART");
- }
- break;
-
- // We will get this command either QA is closed or ated is killed by user.
- case RACFG_CMD_ATE_STOP:
- {
-#ifndef UCOS
- INT32 ret;
-#endif // !UCOS //
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_STOP\n"));
-
- // Distinguish this command came from QA(via ated)
- // or ate daemon according to the existence of pid in payload.
- // No need to prepare feedback if this cmd came directly from ate daemon.
- pRaCfg->length = ntohs(pRaCfg->length);
-
- if (pRaCfg->length == sizeof(pAdapter->ate.AtePid))
- {
- // This command came from QA.
- // Get the pid of ATE daemon.
- memcpy((UCHAR *)&pAdapter->ate.AtePid,
- (&pRaCfg->data[0]) - 2/* == &(pRaCfg->status) */,
- sizeof(pAdapter->ate.AtePid));
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_STOP\n"));
- Status = -EFAULT;
- }
-
- //
- // kill ATE daemon when leaving ATE mode.
- // We must kill ATE daemon first before setting ATESTOP,
- // or Microsoft will report sth. wrong.
-#ifndef UCOS
- ret = KILL_THREAD_PID(pAdapter->ate.AtePid, SIGTERM, 1);
- if (ret)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("%s: unable to signal thread\n", pAdapter->net_dev->name));
- }
-#endif // !UCOS //
- }
-
- // AP might have in ATE_STOP mode due to cmd from QA.
- if (ATE_ON(pAdapter))
- {
- // Someone has killed ate daemon while QA GUI is still open.
- Set_ATE_Proc(pAdapter, "ATESTOP");
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_AP_START is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RF_WRITE_ALL:
- {
- UINT32 R1, R2, R3, R4;
- USHORT channel;
-
- memcpy(&R1, pRaCfg->data-2, 4);
- memcpy(&R2, pRaCfg->data+2, 4);
- memcpy(&R3, pRaCfg->data+6, 4);
- memcpy(&R4, pRaCfg->data+10, 4);
- memcpy(&channel, pRaCfg->data+14, 2);
-
- pAdapter->LatchRfRegs.R1 = ntohl(R1);
- pAdapter->LatchRfRegs.R2 = ntohl(R2);
- pAdapter->LatchRfRegs.R3 = ntohl(R3);
- pAdapter->LatchRfRegs.R4 = ntohl(R4);
- pAdapter->LatchRfRegs.Channel = ntohs(channel);
-
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R3);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R4);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RF_WRITE_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RF_WRITE_ALL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_READ16:
- {
- USHORT offset, value, tmp;
-
- offset = ntohs(pRaCfg->status);
- /* "tmp" is expecially for some compilers... */
- RT28xx_EEPROM_READ16(pAdapter, offset, tmp);
- value = tmp;
- value = htons(value);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("EEPROM Read offset = 0x%04x, value = 0x%04x\n", offset, value));
-
- // prepare feedback
- pRaCfg->length = htons(4);
- pRaCfg->status = htons(0);
- memcpy(pRaCfg->data, &value, 2);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("sizeof(struct ate_racfghdr) = %d\n", sizeof(struct ate_racfghdr)));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ16\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_READ16 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_WRITE16:
- {
- USHORT offset, value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&value, pRaCfg->data, 2);
- value = ntohs(value);
- RT28xx_EEPROM_WRITE16(pAdapter, offset, value);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE16\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_WRITE16 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_READ_ALL:
- {
- USHORT buffer[EEPROM_SIZE/2];
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer, EEPROM_SIZE);
-
- // prepare feedback
- pRaCfg->length = htons(2+EEPROM_SIZE);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_READ_ALL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_WRITE_ALL:
- {
- USHORT buffer[EEPROM_SIZE/2];
-
- NdisZeroMemory((UCHAR *)buffer, EEPROM_SIZE);
- memcpy_exs(pAdapter, (UCHAR *)buffer, (UCHAR *)&pRaCfg->status, EEPROM_SIZE);
- rt_ee_write_all(pAdapter,(USHORT *)buffer);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_E2PROM_WRITE_ALL is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_IO_READ:
- {
- UINT32 offset;
- UINT32 value;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract the offset out.
- offset &= 0x0000FFFF;
- RTMP_IO_READ32(pAdapter, offset, &value);
- value = htonl(value);
-
- // prepare feedback
- pRaCfg->length = htons(6);
- pRaCfg->status = htons(0);
- memcpy(pRaCfg->data, &value, 4);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_READ\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_READ is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_IO_WRITE:
- {
- UINT32 offset, value;
-
- memcpy(&offset, pRaCfg->data-2, 4);
- memcpy(&value, pRaCfg->data+2, 4);
-
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract out the offset.
- offset &= 0x0000FFFF;
- value = ntohl(value);
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_IO_WRITE: offset = %x, value = %x\n", offset, value));
- RTMP_IO_WRITE32(pAdapter, offset, value);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_WRITE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_WRITE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_IO_READ_BULK:
- {
- UINT32 offset;
- USHORT len;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract the offset.
- offset &= 0x0000FFFF;
- memcpy(&len, pRaCfg->data+2, 2);
- len = ntohs(len);
-
- if (len > 371)
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("len is too large, make it smaller\n"));
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(1);
- break;
- }
-
- RTMP_IO_READ_BULK(pAdapter, pRaCfg->data, (UCHAR *)offset, len*4);// unit in four bytes
-
- // prepare feedback
- pRaCfg->length = htons(2+len*4);// unit in four bytes
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_READ_BULK is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_BBP_READ8:
- {
- USHORT offset;
- UCHAR value;
-
- value = 0;
- offset = ntohs(pRaCfg->status);
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, offset, &value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, offset, &value);
- }
- // prepare feedback
- pRaCfg->length = htons(3);
- pRaCfg->status = htons(0);
- pRaCfg->data[0] = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("BBP value = %x\n", value));
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_READ8\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_READ8 is done !\n"));
- }
- }
- break;
- case RACFG_CMD_BBP_WRITE8:
- {
- USHORT offset;
- UCHAR value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&value, pRaCfg->data, 1);
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, offset, value);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, offset, value);
- }
-
- if ((offset == BBP_R1) || (offset == BBP_R3))
- {
- SyncTxRxConfig(pAdapter, offset, value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_WRITE8\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_WRITE8 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_BBP_READ_ALL:
- {
- USHORT j;
-
- for (j = 0; j < 137; j++)
- {
- pRaCfg->data[j] = 0;
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j]);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j]);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+137);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_READ_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_READ_ALL is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_ATE_E2PROM_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT buffer[EEPROM_SIZE/2];
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- if (offset + len <= EEPROM_SIZE)
- memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer+offset, len);
- else
- ATEDBGPRINT(RT_DEBUG_ERROR, ("exceed EEPROM size\n"));
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_E2PROM_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_E2PROM_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT buffer[EEPROM_SIZE/2];
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- memcpy_exs(pAdapter, (UCHAR *)buffer + offset, (UCHAR *)pRaCfg->data + 2, len);
- rt_ee_write_all(pAdapter,(USHORT *)buffer);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_ATE_E2PROM_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_IO_WRITE_BULK:
- {
- UINT32 offset, i, value;
- USHORT len;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
- memcpy(&len, pRaCfg->data+2, 2);
- len = ntohs(len);
-
- for (i = 0; i < len; i += 4)
- {
- memcpy_exl(pAdapter, (UCHAR *)&value, pRaCfg->data+4+i, 4);
- printk("Write %x %x\n", offset + i, value);
- RTMP_IO_WRITE32(pAdapter, (offset +i) & 0xffff, value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_IO_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_ATE_IO_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_BBP_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
-
- for (j = offset; j < (offset+len); j++)
- {
- pRaCfg->data[j - offset] = 0;
-
- if (pAdapter->ate.Mode == ATE_STOP)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j - offset]);
- }
- else
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j - offset]);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_BBP_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_BBP_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
- UCHAR *value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- value = pRaCfg->data + 2 + (j - offset);
- if (pAdapter->ate.Mode == ATE_STOP)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, j, *value);
- }
- else
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, j, *value);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_BBP_WRITE_BULK is done !\n"));
- }
- }
- break;
-
-#ifdef CONFIG_RALINK_RT3052
- case RACFG_CMD_ATE_RF_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- pRaCfg->data[j - offset] = 0;
- RT30xxReadRFRegister(pAdapter, j, &pRaCfg->data[j - offset]);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RF_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_RF_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
- UCHAR *value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- value = pRaCfg->data + 2 + (j - offset);
- RT30xxWriteRFRegister(pAdapter, j, *value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RF_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-#endif
-
-
- case RACFG_CMD_GET_NOISE_LEVEL:
- {
- UCHAR channel;
- INT32 buffer[3][10];/* 3 : RxPath ; 10 : no. of per rssi samples */
-
- channel = (ntohs(pRaCfg->status) & 0x00FF);
- CalNoiseLevel(pAdapter, channel, buffer);
- memcpy_exl(pAdapter, (UCHAR *)pRaCfg->data, (UCHAR *)&(buffer[0][0]), (sizeof(INT32)*3*10));
-
- // prepare feedback
- pRaCfg->length = htons(2 + (sizeof(INT32)*3*10));
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_NOISE_LEVEL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_NOISE_LEVEL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_GET_COUNTER:
- {
- memcpy_exl(pAdapter, &pRaCfg->data[0], (UCHAR *)&pAdapter->ate.U2M, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[4], (UCHAR *)&pAdapter->ate.OtherData, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[8], (UCHAR *)&pAdapter->ate.Beacon, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[12], (UCHAR *)&pAdapter->ate.OtherCount, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[16], (UCHAR *)&pAdapter->ate.TxAc0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[20], (UCHAR *)&pAdapter->ate.TxAc1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[24], (UCHAR *)&pAdapter->ate.TxAc2, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->ate.TxAc3, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->ate.TxHCCA, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->ate.TxMgmt, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&pAdapter->ate.RSSI0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[44], (UCHAR *)&pAdapter->ate.RSSI1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&pAdapter->ate.RSSI2, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[52], (UCHAR *)&pAdapter->ate.SNR0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[56], (UCHAR *)&pAdapter->ate.SNR1, 4);
-
- pRaCfg->length = htons(2+60);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_COUNTER is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_CLEAR_COUNTER:
- {
- pAdapter->ate.U2M = 0;
- pAdapter->ate.OtherData = 0;
- pAdapter->ate.Beacon = 0;
- pAdapter->ate.OtherCount = 0;
- pAdapter->ate.TxAc0 = 0;
- pAdapter->ate.TxAc1 = 0;
- pAdapter->ate.TxAc2 = 0;
- pAdapter->ate.TxAc3 = 0;
- pAdapter->ate.TxHCCA = 0;
- pAdapter->ate.TxMgmt = 0;
- pAdapter->ate.TxDoneCount = 0;
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_CLEAR_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_CLEAR_COUNTER is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_TX_START:
- {
- USHORT *p;
- USHORT err = 1;
- UCHAR Bbp22Value = 0, Bbp24Value = 0;
-
- if ((pAdapter->ate.TxStatus != 0) && (pAdapter->ate.Mode & ATE_TXFRAME))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("Ate Tx is already running, to run next Tx, you must stop it first\n"));
- err = 2;
- goto TX_START_ERROR;
- }
- else if ((pAdapter->ate.TxStatus != 0) && !(pAdapter->ate.Mode & ATE_TXFRAME))
- {
- int i = 0;
-
- while ((i++ < 10) && (pAdapter->ate.TxStatus != 0))
- {
- RTMPusecDelay(5000);
- }
-
- // force it to stop
- pAdapter->ate.TxStatus = 0;
- pAdapter->ate.TxDoneCount = 0;
- //pAdapter->ate.Repeat = 0;
- pAdapter->ate.bQATxStart = FALSE;
- }
-
- // If pRaCfg->length == 0, this "RACFG_CMD_TX_START" is for Carrier test or Carrier Suppression.
- if (ntohs(pRaCfg->length) != 0)
- {
- // Get frame info
-
- NdisMoveMemory(&pAdapter->ate.TxWI, pRaCfg->data + 2, 16);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)&pAdapter->ate.TxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
- NdisMoveMemory(&pAdapter->ate.TxCount, pRaCfg->data + 18, 4);
- pAdapter->ate.TxCount = ntohl(pAdapter->ate.TxCount);
-
- p = (USHORT *)(&pRaCfg->data[22]);
- //p = pRaCfg->data + 22;
- // always use QID_AC_BE
- pAdapter->ate.QID = 0;
- p = (USHORT *)(&pRaCfg->data[24]);
- //p = pRaCfg->data + 24;
- pAdapter->ate.HLen = ntohs(*p);
-
- if (pAdapter->ate.HLen > 32)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("pAdapter->ate.HLen > 32\n"));
- err = 3;
- goto TX_START_ERROR;
- }
-
- NdisMoveMemory(&pAdapter->ate.Header, pRaCfg->data + 26, pAdapter->ate.HLen);
-
-
- pAdapter->ate.PLen = ntohs(pRaCfg->length) - (pAdapter->ate.HLen + 28);
-
- if (pAdapter->ate.PLen > 32)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("pAdapter->ate.PLen > 32\n"));
- err = 4;
- goto TX_START_ERROR;
- }
-
- NdisMoveMemory(&pAdapter->ate.Pattern, pRaCfg->data + 26 + pAdapter->ate.HLen, pAdapter->ate.PLen);
- pAdapter->ate.DLen = pAdapter->ate.TxWI.MPDUtotalByteCount - pAdapter->ate.HLen;
- }
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R22, &Bbp22Value);
-
- switch (Bbp22Value)
- {
- case BBP22_TXFRAME:
- {
- if (pAdapter->ate.TxCount == 0)
- {
- pAdapter->ate.TxCount = 0xFFFFFFFF;
- }
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXFRAME\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXFRAME");
- }
- break;
-
- case BBP22_TXCONT_OR_CARRSUPP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("BBP22_TXCONT_OR_CARRSUPP\n"));
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, 24, &Bbp24Value);
-
- switch (Bbp24Value)
- {
- case BBP24_TXCONT:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCONT\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXCONT");
- }
- break;
-
- case BBP24_CARRSUPP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCARRSUPP\n"));
- pAdapter->ate.bQATxStart = TRUE;
- pAdapter->ate.Mode |= ATE_TXCARRSUPP;
- }
- break;
-
- default:
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("Unknown Start TX subtype !"));
- }
- break;
- }
- }
- break;
-
- case BBP22_TXCARR:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCARR\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXCARR");
- }
- break;
-
- default:
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("Unknown Start TX subtype !"));
- }
- break;
- }
-
- if (pAdapter->ate.bQATxStart == TRUE)
- {
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() was failed in case RACFG_CMD_TX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_TX_START is done !\n"));
- }
- break;
- }
-
-TX_START_ERROR:
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(err);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_TX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("feedback of TX_START_ERROR is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_GET_TX_STATUS:
- {
- UINT32 count;
-
- // prepare feedback
- pRaCfg->length = htons(6);
- pRaCfg->status = htons(0);
- count = htonl(pAdapter->ate.TxDoneCount);
- NdisMoveMemory(pRaCfg->data, &count, 4);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_TX_STATUS\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_TX_STATUS is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_TX_STOP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_TX_STOP\n"));
-
- Set_ATE_Proc(pAdapter, "TXSTOP");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_TX_STOP\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_TX_STOP is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RX_START:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
-
- pAdapter->ate.bQARxStart = TRUE;
- Set_ATE_Proc(pAdapter, "RXFRAME");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_START is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RX_STOP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_STOP\n"));
-
- Set_ATE_Proc(pAdapter, "RXSTOP");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_STOP\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_STOP is done !\n"));
- }
- }
- break;
-
- /* The following cases are for new ATE GUI(not QA). */
- /*==================================================*/
- case RACFG_CMD_ATE_START_TX_CARRIER:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CARRIER\n"));
-
- Set_ATE_Proc(pAdapter, "TXCARR");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CARRIER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_CARRIER is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_TX_CONT:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CONT\n"));
-
- Set_ATE_Proc(pAdapter, "TXCONT");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CONT\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_CONT is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_TX_FRAME:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_FRAME\n"));
-
- Set_ATE_Proc(pAdapter, "TXFRAME");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_FRAME\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_FRAME is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_BW:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_BW\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
-
- Set_ATE_TX_BW_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_BW\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_BW is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_POWER0:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER0\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_POWER0_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER0\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_POWER0 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_POWER1:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER1\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_POWER1_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER1\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_POWER1 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_FREQ_OFFSET:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_FREQOFFSET_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_FREQ_OFFSET is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_GET_STATISTICS:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_GET_STATISTICS\n"));
-
- memcpy_exl(pAdapter, &pRaCfg->data[0], (UCHAR *)&pAdapter->ate.TxDoneCount, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[4], (UCHAR *)&pAdapter->WlanCounters.RetryCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[8], (UCHAR *)&pAdapter->WlanCounters.FailedCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[12], (UCHAR *)&pAdapter->WlanCounters.RTSSuccessCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[16], (UCHAR *)&pAdapter->WlanCounters.RTSFailureCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[20], (UCHAR *)&pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[24], (UCHAR *)&pAdapter->WlanCounters.FCSErrorCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->Counters8023.RxNoBuffer, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->RalinkCounters.OneSecFalseCCACnt, 4);
-
- if (pAdapter->ate.RxAntennaSel == 0)
- {
- INT32 RSSI0 = 0;
- INT32 RSSI1 = 0;
- INT32 RSSI2 = 0;
-
- RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
- RSSI1 = (INT32)(pAdapter->ate.LastRssi1 - pAdapter->BbpRssiToDbmDelta);
- RSSI2 = (INT32)(pAdapter->ate.LastRssi2 - pAdapter->BbpRssiToDbmDelta);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[44], (UCHAR *)&RSSI1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&RSSI2, 4);
- pRaCfg->length = htons(2+52);
- }
- else
- {
- INT32 RSSI0 = 0;
-
- RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
- pRaCfg->length = htons(2+44);
- }
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_GET_STATISTICS\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_GET_STATISTICS is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_RESET_COUNTER:
- {
- SHORT value = 1;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_RESET_COUNTER\n"));
-
- sprintf((PCHAR)str, "%d", value);
- Set_ResetStatCounter_Proc(pAdapter, str);
-
- pAdapter->ate.TxDoneCount = 0;
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RESET_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RESET_COUNTER is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_ATE_SEL_TX_ANTENNA:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_Antenna_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SEL_TX_ANTENNA is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SEL_RX_ANTENNA:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_RX_Antenna_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SEL_RX_ANTENNA is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_PREAMBLE:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_PREAMBLE\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_MODE_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_PREAMBLE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_PREAMBLE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_CHANNEL:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_CHANNEL\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_CHANNEL_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_CHANNEL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_CHANNEL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR1:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR1\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr1, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR1\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR1 is done !\n (ADDR1 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr1[0],
- pAdapter->ate.Addr1[1], pAdapter->ate.Addr1[2], pAdapter->ate.Addr1[3], pAdapter->ate.Addr1[4], pAdapter->ate.Addr1[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR2:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR2\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr2, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR2\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR2 is done !\n (ADDR2 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr2[0],
- pAdapter->ate.Addr2[1], pAdapter->ate.Addr2[2], pAdapter->ate.Addr2[3], pAdapter->ate.Addr2[4], pAdapter->ate.Addr2[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR3:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR3\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr3, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR3\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR3 is done !\n (ADDR3 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr3[0],
- pAdapter->ate.Addr3[1], pAdapter->ate.Addr3[2], pAdapter->ate.Addr3[3], pAdapter->ate.Addr3[4], pAdapter->ate.Addr3[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_RATE:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_RATE\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_MCS_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_RATE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_RATE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_FRAME_LEN:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_LENGTH_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_FRAME_LEN is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_FRAME_COUNT:
- {
- USHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- /* TX_FRAME_COUNT == 0 means tx infinitely */
- if (value == 0)
- {
- /* Use TxCount = 0xFFFFFFFF to approximate the infinity. */
- pAdapter->ate.TxCount = 0xFFFFFFFF;
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAdapter->ate.TxCount));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
-
-
- }
- else
- {
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_COUNT_Proc(pAdapter, str);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_FRAME_COUNT is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_RX_FRAME:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
-
- Set_ATE_Proc(pAdapter, "RXFRAME");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_START is done !\n"));
- }
- }
- break;
- default:
- break;
- }
- ASSERT(pRaCfg != NULL);
- if (pRaCfg != NULL)
- {
- kfree(pRaCfg);
- }
- return;
-}
-
-VOID BubbleSort(INT32 n, INT32 a[])
-{
- INT32 k, j, temp;
-
- for (k = n-1; k>0; k--)
- {
- for (j = 0; j<k; j++)
- {
- if(a[j] > a[j+1])
- {
- temp = a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- }
- }
- }
-}
-
-VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
-{
- INT32 RSSI0, RSSI1, RSSI2;
- CHAR Rssi0Offset, Rssi1Offset, Rssi2Offset;
- UCHAR BbpR50Rssi0 = 0, BbpR51Rssi1 = 0, BbpR52Rssi2 = 0;
- UCHAR Org_BBP66value = 0, Org_BBP69value = 0, Org_BBP70value = 0, data = 0;
- USHORT LNA_Gain = 0;
- INT32 j = 0;
- UCHAR Org_Channel = pAd->ate.Channel;
- USHORT GainValue = 0, OffsetValue = 0;
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &Org_BBP66value);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R69, &Org_BBP69value);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R70, &Org_BBP70value);
-
- //**********************************************************************
- // Read the value of LNA gain and Rssi offset
- //**********************************************************************
- RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, GainValue);
-
- // for Noise Level
- if (channel <= 14)
- {
- LNA_Gain = GainValue & 0x00FF;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, OffsetValue);
- Rssi0Offset = OffsetValue & 0x00FF;
- Rssi1Offset = (OffsetValue & 0xFF00) >> 8;
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_BG_OFFSET + 2)/* 0x48 */, OffsetValue);
- Rssi2Offset = OffsetValue & 0x00FF;
- }
- else
- {
- LNA_Gain = (GainValue & 0xFF00) >> 8;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, OffsetValue);
- Rssi0Offset = OffsetValue & 0x00FF;
- Rssi1Offset = (OffsetValue & 0xFF00) >> 8;
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET + 2)/* 0x4C */, OffsetValue);
- Rssi2Offset = OffsetValue & 0x00FF;
- }
- //**********************************************************************
- {
- pAd->ate.Channel = channel;
- ATEAsicSwitchChannel(pAd);
- mdelay(5);
-
- data = 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, data);
- data = 0x40;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, data);
- data = 0x40;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, data);
- mdelay(5);
-
- // Start Rx
- pAd->ate.bQARxStart = TRUE;
- Set_ATE_Proc(pAd, "RXFRAME");
-
- mdelay(5);
-
- for (j = 0; j < 10; j++)
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R50, &BbpR50Rssi0);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R51, &BbpR51Rssi1);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R52, &BbpR52Rssi2);
-
- mdelay(10);
-
- // Calculate RSSI 0
- if (BbpR50Rssi0 == 0)
- {
- RSSI0 = -100;
- }
- else
- {
- RSSI0 = (INT32)(-12 - BbpR50Rssi0 - LNA_Gain - Rssi0Offset);
- }
- RSSI[0][j] = RSSI0;
-
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- // Calculate RSSI 1
- if (BbpR51Rssi1 == 0)
- {
- RSSI1 = -100;
- }
- else
- {
- RSSI1 = (INT32)(-12 - BbpR51Rssi1 - LNA_Gain - Rssi1Offset);
- }
- RSSI[1][j] = RSSI1;
- }
-
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- // Calculate RSSI 2
- if (BbpR52Rssi2 == 0)
- RSSI2 = -100;
- else
- RSSI2 = (INT32)(-12 - BbpR52Rssi2 - LNA_Gain - Rssi2Offset);
-
- RSSI[2][j] = RSSI2;
- }
- }
-
- // Stop Rx
- Set_ATE_Proc(pAd, "RXSTOP");
-
- mdelay(5);
-
-#if 0// Debug Message................
- ate_print("\n**********************************************************\n");
- ate_print("Noise Level: Channel %d\n", channel);
- ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[0][0], RSSI[0][1], RSSI[0][2],
- RSSI[0][3], RSSI[0][4], RSSI[0][5],
- RSSI[0][6], RSSI[0][7], RSSI[0][8],
- RSSI[0][9]);
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[1][0], RSSI[1][1], RSSI[1][2],
- RSSI[1][3], RSSI[1][4], RSSI[1][5],
- RSSI[1][6], RSSI[1][7], RSSI[1][8],
- RSSI[1][9]);
- }
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[2][0], RSSI[2][1], RSSI[2][2],
- RSSI[2][3], RSSI[2][4], RSSI[2][5],
- RSSI[2][6], RSSI[2][7], RSSI[2][8],
- RSSI[2][9]);
- }
-#endif // 0 //
- BubbleSort(10, RSSI[0]); // 1R
-
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- BubbleSort(10, RSSI[1]);
- }
-
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- BubbleSort(10, RSSI[2]);
- }
-
-#if 0// Debug Message................
- ate_print("\nAfter Sorting....Channel %d\n", channel);
- ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[0][0], RSSI[0][1], RSSI[0][2],
- RSSI[0][3], RSSI[0][4], RSSI[0][5],
- RSSI[0][6], RSSI[0][7], RSSI[0][8],
- RSSI[0][9]);
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[1][0], RSSI[1][1], RSSI[1][2],
- RSSI[1][3], RSSI[1][4], RSSI[1][5],
- RSSI[1][6], RSSI[1][7], RSSI[1][8],
- RSSI[1][9]);
- }
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[2][0], RSSI[2][1], RSSI[2][2],
- RSSI[2][3], RSSI[2][4], RSSI[2][5],
- RSSI[2][6], RSSI[2][7], RSSI[2][8],
- RSSI[2][9]);
- }
- ate_print("**********************************************************\n");
-#endif // 0 //
- }
-
- pAd->ate.Channel = Org_Channel;
- ATEAsicSwitchChannel(pAd);
-
- // Restore original value
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, Org_BBP66value);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, Org_BBP69value);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, Org_BBP70value);
-
- return;
-}
-
-BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
-{
- UCHAR tmp = 0, bbp_data = 0;
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, offset, &bbp_data);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, offset, &bbp_data);
- }
-
- /* confirm again */
- ASSERT(bbp_data == value);
-
- switch(offset)
- {
- case BBP_R1:
- /* Need to sync. tx configuration with legacy ATE. */
- tmp = (bbp_data & ((1 << 4) | (1 << 3))/* 0x18 */) >> 3;
- switch(tmp)
- {
- /* The BBP R1 bit[4:3] = 2 :: Both DACs will be used by QA. */
- case 2:
- /* All */
- pAd->ate.TxAntennaSel = 0;
- break;
- /* The BBP R1 bit[4:3] = 0 :: DAC 0 will be used by QA. */
- case 0:
- /* Antenna one */
- pAd->ate.TxAntennaSel = 1;
- break;
- /* The BBP R1 bit[4:3] = 1 :: DAC 1 will be used by QA. */
- case 1:
- /* Antenna two */
- pAd->ate.TxAntennaSel = 2;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
- return FALSE;
- }
- break;/* case BBP_R1 */
-
- case BBP_R3:
- /* Need to sync. rx configuration with legacy ATE. */
- tmp = (bbp_data & ((1 << 1) | (1 << 0))/* 0x03 */);
- switch(tmp)
- {
- /* The BBP R3 bit[1:0] = 3 :: All ADCs will be used by QA. */
- case 3:
- /* All */
- pAd->ate.RxAntennaSel = 0;
- break;
- /* The BBP R3 bit[1:0] = 0 :: ADC 0 will be used by QA, */
- /* unless the BBP R3 bit[4:3] = 2 */
- case 0:
- /* Antenna one */
- pAd->ate.RxAntennaSel = 1;
- tmp = ((bbp_data & ((1 << 4) | (1 << 3))/* 0x03 */) >> 3);
- if (tmp == 2)// 3R
- {
- /* Default : All ADCs will be used by QA */
- pAd->ate.RxAntennaSel = 0;
- }
- break;
- /* The BBP R3 bit[1:0] = 1 :: ADC 1 will be used by QA. */
- case 1:
- /* Antenna two */
- pAd->ate.RxAntennaSel = 2;
- break;
- /* The BBP R3 bit[1:0] = 2 :: ADC 2 will be used by QA. */
- case 2:
- /* Antenna three */
- pAd->ate.RxAntennaSel = 3;
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __func__));
- return FALSE;
- }
- break;/* case BBP_R3 */
-
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
- return FALSE;
-
- }
- return TRUE;
-}
-
-static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
-{
- ULONG i, Value = 0;
- ULONG *pDst, *pSrc;
- UCHAR *p8;
-
- p8 = src;
- pDst = (ULONG *) dst;
- pSrc = (ULONG *) src;
-
- for (i = 0 ; i < (len/4); i++)
- {
- /* For alignment issue, we need a variable "Value". */
- memmove(&Value, pSrc, 4);
- Value = htonl(Value);
- memmove(pDst, &Value, 4);
- pDst++;
- pSrc++;
- }
- if ((len % 4) != 0)
- {
- /* wish that it will never reach here */
- memmove(&Value, pSrc, (len % 4));
- Value = htonl(Value);
- memmove(pDst, &Value, (len % 4));
- }
-}
-
-static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
-{
- ULONG i;
- UCHAR *pDst, *pSrc;
-
- pDst = dst;
- pSrc = src;
-
- for (i = 0; i < (len/2); i++)
- {
- memmove(pDst, pSrc, 2);
- *((USHORT *)pDst) = htons(*((USHORT *)pDst));
- pDst+=2;
- pSrc+=2;
- }
-
- if ((len % 2) != 0)
- {
- memmove(pDst, pSrc, 1);
- }
-}
-
-static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32 len)
-{
- UINT32 i, Value;
- UINT32 *pDst, *pSrc;
-
- pDst = (UINT32 *) dst;
- pSrc = (UINT32 *) src;
-
- for (i = 0 ; i < (len/4); i++)
- {
- RTMP_IO_READ32(pAd, (ULONG)pSrc, &Value);
- Value = htonl(Value);
- memmove(pDst, &Value, 4);
- pDst++;
- pSrc++;
- }
- return;
-}
-
-// TODO:
-#if 0
-/* These work only when RALINK_ATE is defined */
-INT Set_TxStart_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG value = simple_strtol(arg, 0, 10);
- UCHAR buffer[26] = {0x88, 0x02, 0x2c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x55, 0x44, 0x33, 0x22, 0x11, 0xc0, 0x22, 0x00, 0x00};
- POS_COOKIE pObj;
-
- if (pAd->ate.TxStatus != 0)
- return FALSE;
-
- pAd->ate.TxInfo = 0x04000000;
- bzero(&pAd->ate.TxWI, sizeof(TXWI_STRUC));
- pAd->ate.TxWI.PHYMODE = 0;// MODE_CCK
- pAd->ate.TxWI.MPDUtotalByteCount = 1226;
- pAd->ate.TxWI.MCS = 3;
- //pAd->ate.Mode = ATE_START;
- pAd->ate.Mode |= ATE_TXFRAME;
- pAd->ate.TxCount = value;
- pAd->ate.QID = 0;
- pAd->ate.HLen = 26;
- pAd->ate.PLen = 0;
- pAd->ate.DLen = 1200;
- memcpy(pAd->ate.Header, buffer, 26);
- pAd->ate.bQATxStart = TRUE;
- //pObj = (POS_COOKIE) pAd->OS_Cookie;
- //tasklet_hi_schedule(&pObj->AteTxTask);
- return TRUE;
-}
-#endif /* end of #if 0 */
-
-INT Set_TxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE,("Set_TxStop_Proc\n"));
-
- if (Set_ATE_Proc(pAd, "TXSTOP"))
- {
- return TRUE;
-}
- else
- {
- return FALSE;
- }
-}
-
-INT Set_RxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE,("Set_RxStop_Proc\n"));
-
- if (Set_ATE_Proc(pAd, "RXSTOP"))
- {
- return TRUE;
-}
- else
- {
- return FALSE;
- }
-}
-
-#if 0
-INT Set_EEWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT offset = 0, value;
- PUCHAR p2 = arg;
-
- while((*p2 != ':') && (*p2 != '\0'))
- {
- p2++;
- }
-
- if (*p2 == ':')
- {
- A2Hex(offset, arg);
- A2Hex(value, p2+ 1);
- }
- else
- {
- A2Hex(value, arg);
- }
-
- if (offset >= EEPROM_SIZE)
- {
- ate_print("Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE);
- return FALSE;
- }
-
- RTMP_EEPROM_WRITE16(pAd, offset, value);
-
- return TRUE;
-}
-
-INT Set_BBPRead_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR value = 0, offset;
-
- A2Hex(offset, arg);
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, offset, &value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, offset, &value);
- }
-
- ate_print("%x\n", value);
-
- return TRUE;
-}
-
-
-INT Set_BBPWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT offset = 0;
- PUCHAR p2 = arg;
- UCHAR value;
-
- while((*p2 != ':') && (*p2 != '\0'))
- {
- p2++;
- }
-
- if (*p2 == ':')
- {
- A2Hex(offset, arg);
- A2Hex(value, p2+ 1);
- }
- else
- {
- A2Hex(value, arg);
- }
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, offset, value);
- }
- else
- {
- RTNP_BBP_IO_WRITE8_BY_REG_ID(pAd, offset, value);
- }
-
- return TRUE;
-}
-
-INT Set_RFWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- PUCHAR p2, p3, p4;
- ULONG R1, R2, R3, R4;
-
- p2 = arg;
-
- while((*p2 != ':') && (*p2 != '\0'))
- {
- p2++;
- }
-
- if (*p2 != ':')
- return FALSE;
-
- p3 = p2 + 1;
-
- while((*p3 != ':') && (*p3 != '\0'))
- {
- p3++;
- }
-
- if (*p3 != ':')
- return FALSE;
-
- p4 = p3 + 1;
-
- while((*p4 != ':') && (*p4 != '\0'))
- {
- p4++;
- }
-
- if (*p4 != ':')
- return FALSE;
-
-
- A2Hex(R1, arg);
- A2Hex(R2, p2 + 1);
- A2Hex(R3, p3 + 1);
- A2Hex(R4, p4 + 1);
-
- RTMP_RF_IO_WRITE32(pAd, R1);
- RTMP_RF_IO_WRITE32(pAd, R2);
- RTMP_RF_IO_WRITE32(pAd, R3);
- RTMP_RF_IO_WRITE32(pAd, R4);
-
- return TRUE;
-}
-#endif // end of #if 0 //
-#endif // RALINK_28xx_QA //
-
-#endif // RALINK_ATE //
-
diff --git a/drivers/staging/rt2860/rt_ate.h b/drivers/staging/rt2860/rt_ate.h
deleted file mode 100644
index 38f5c4af5462..000000000000
--- a/drivers/staging/rt2860/rt_ate.h
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __ATE_H__
-#define __ATE_H__
-
-#ifndef UCOS
-#define ate_print printk
-#define ATEDBGPRINT DBGPRINT
-#define EEPROM_SIZE 0x200
-#ifdef CONFIG_STA_SUPPORT
-#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2860STA/e2p.bin"
-#endif // CONFIG_STA_SUPPORT //
-
-#else // !UCOS //
-#define fATE_LOAD_EEPROM 0x0C43
-#ifdef CONFIG_PRINTK
-extern INT ConsoleResponse(IN PUCHAR buff);
-extern int (*remote_display)(char *);
-extern void puts (const char *s);
-
-/* specificly defined to redirect and show ate-related messages to host. */
-/* Try to define ate_print as a macro. */
-#define ate_print(fmt, args...) \
-do{ int (*org_remote_display)(char *) = NULL; \
- org_remote_display = remote_display;\
- /* Save original "remote_display" */\
- remote_display = (int (*)(char *))ConsoleResponse; \
- printk(fmt, ## args); \
- /* Restore the remote_display function pointer */ \
- remote_display = org_remote_display; }while(0)
-
-#define ATEDBGPRINT(Level, Fmt) \
-{ \
- if ((Level) <= RTDebugLevel) \
- { \
- ate_print Fmt; \
- } \
-}
-#endif // CONFIG_PRINTK //
-#endif // !UCOS //
-
-#define ATE_ON(_p) (((_p)->ate.Mode) != ATE_STOP)
-
-/* RT2880_iNIC will define "RT2860". */
-#define ATE_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
-{ \
- BBP_CSR_CFG_STRUC BbpCsr; \
- int i, k; \
- for (i=0; i<MAX_BUSY_COUNT; i++) \
- { \
- RTMP_IO_READ32(_A, BBP_CSR_CFG, &BbpCsr.word); \
- if (BbpCsr.field.Busy == BUSY) \
- { \
- continue; \
- } \
- BbpCsr.word = 0; \
- BbpCsr.field.fRead = 1; \
- BbpCsr.field.BBP_RW_MODE = 1; \
- BbpCsr.field.Busy = 1; \
- BbpCsr.field.RegNum = _I; \
- RTMP_IO_WRITE32(_A, BBP_CSR_CFG, BbpCsr.word); \
- for (k=0; k<MAX_BUSY_COUNT; k++) \
- { \
- RTMP_IO_READ32(_A, BBP_CSR_CFG, &BbpCsr.word); \
- if (BbpCsr.field.Busy == IDLE) \
- break; \
- } \
- if ((BbpCsr.field.Busy == IDLE) && \
- (BbpCsr.field.RegNum == _I)) \
- { \
- *(_pV) = (UCHAR)BbpCsr.field.Value; \
- break; \
- } \
- } \
- if (BbpCsr.field.Busy == BUSY) \
- { \
- ATEDBGPRINT(RT_DEBUG_ERROR, ("BBP read R%d fail\n", _I)); \
- *(_pV) = (_A)->BbpWriteLatch[_I]; \
- } \
-}
-
-#define ATE_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) \
-{ \
- BBP_CSR_CFG_STRUC BbpCsr; \
- int BusyCnt; \
- for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++) \
- { \
- RTMP_IO_READ32(_A, BBP_CSR_CFG, &BbpCsr.word); \
- if (BbpCsr.field.Busy == BUSY) \
- continue; \
- BbpCsr.word = 0; \
- BbpCsr.field.fRead = 0; \
- BbpCsr.field.BBP_RW_MODE = 1; \
- BbpCsr.field.Busy = 1; \
- BbpCsr.field.Value = _V; \
- BbpCsr.field.RegNum = _I; \
- RTMP_IO_WRITE32(_A, BBP_CSR_CFG, BbpCsr.word); \
- (_A)->BbpWriteLatch[_I] = _V; \
- break; \
- } \
- if (BusyCnt == MAX_BUSY_COUNT) \
- { \
- ATEDBGPRINT(RT_DEBUG_ERROR, ("BBP write R%d fail\n", _I)); \
- } \
-}
-
-/* RT2880_iNIC will define RT2860. */
-#define EEPROM_SIZE 0x200
-/* iNIC has its own EEPROM_BIN_FILE_NAME */
-#ifndef UCOS
-#ifdef CONFIG_STA_SUPPORT
-#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2860STA/e2p.bin"
-#endif // CONFIG_STA_SUPPORT //
-#endif // !UCOS //
-
-
-
-VOID rt_ee_read_all(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Data);
-
-
-VOID rt_ee_write_all(
- IN PRTMP_ADAPTER pAd,
- IN USHORT *Data);
-
-INT Set_ATE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_DA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_SA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_BSSID_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_CHANNEL_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_POWER0_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_POWER1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_RX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_FREQOFFSET_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_BW_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_LENGTH_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_COUNT_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_MCS_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_MODE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_GI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_ATE_RX_FER_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Read_RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF2_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF3_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF4_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Read_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Show_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Help_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-VOID ATE_QA_Statistics(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC p28xxRxD,
- IN PHEADER_802_11 pHeader);
-
-VOID RtmpDoAte(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID BubbleSort(
- IN INT32 n,
- IN INT32 a[]);
-
-VOID CalNoiseLevel(
- IN PRTMP_ADAPTER pAdapter,
- IN UCHAR channel,
- OUT INT32 buffer[3][10]);
-
-BOOLEAN SyncTxRxConfig(
- IN PRTMP_ADAPTER pAdapter,
- IN USHORT offset,
- IN UCHAR value);
-
-#if 0
-INT Set_TxStart_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // 0 //
-
-INT Set_TxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#if 0
-INT Set_EERead_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_EEWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BBPRead_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BBPWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RFWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // end of #if 0 //
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-VOID ATEAsicSwitchChannel(
- IN PRTMP_ADAPTER pAd);
-
-VOID ATEAsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd);
-
-VOID ATEDisableAsicProtect(
- IN PRTMP_ADAPTER pAd);
-
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber);
-
-VOID ATESampleRssi(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI);
-
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPStationStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPStationStart(
- IN PRTMP_ADAPTER pAd);
-#endif // CONFIG_STA_SUPPORT //
-#endif // __ATE_H__ //
diff --git a/drivers/staging/rt2860/rt_config.h b/drivers/staging/rt2860/rt_config.h
index a67024fb4373..a19cbe1dedeb 100644
--- a/drivers/staging/rt2860/rt_config.h
+++ b/drivers/staging/rt2860/rt_config.h
@@ -41,20 +41,18 @@
#define __RT_CONFIG_H__
#include "rtmp_type.h"
-#ifdef UCOS
-#include "includes.h"
-#include <stdio.h>
-#include "rt_ucos.h"
-#endif
-
#ifdef LINUX
#include "rt_linux.h"
#endif
#include "rtmp_def.h"
#include "rt28xx.h"
+#ifdef RT2860
#include "rt2860.h"
-
+#endif
+#ifdef RT2870
+#include "../rt2870/rt2870.h"
+#endif // RT2870 //
#include "oid.h"
#include "mlme.h"
@@ -66,31 +64,10 @@
#include "chlist.h"
#include "spectrum.h"
-#ifdef LEAP_SUPPORT
-#include "leap.h"
-#endif // LEAP_SUPPORT //
-
-#ifdef BLOCK_NET_IF
-#include "netif_block.h"
-#endif // BLOCK_NET_IF //
-
#ifdef IGMP_SNOOP_SUPPORT
#include "igmp_snoop.h"
#endif // IGMP_SNOOP_SUPPORT //
-#ifdef RALINK_ATE
-#include "rt_ate.h"
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifndef WPA_SUPPLICANT_SUPPORT
-#error "Build for being controlled by NetworkManager or wext, please set HAS_WPA_SUPPLICANT=y and HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y"
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#endif // CONFIG_STA_SUPPORT //
-
#ifdef IKANOS_VX_1X0
#include "vr_ikans.h"
#endif // IKANOS_VX_1X0 //
diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c
index f3c128c72a21..80176b20db07 100644
--- a/drivers/staging/rt2860/rt_linux.c
+++ b/drivers/staging/rt2860/rt_linux.c
@@ -33,9 +33,10 @@ BUILD_TIMER_FUNCTION(MlmePeriodicExec);
BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
BUILD_TIMER_FUNCTION(APSDPeriodicExec);
BUILD_TIMER_FUNCTION(AsicRfTuningExec);
+#ifdef RT2870
+BUILD_TIMER_FUNCTION(BeaconUpdateExec);
+#endif // RT2870 //
-
-#ifdef CONFIG_STA_SUPPORT
BUILD_TIMER_FUNCTION(BeaconTimeout);
BUILD_TIMER_FUNCTION(ScanTimeout);
BUILD_TIMER_FUNCTION(AuthTimeout);
@@ -43,17 +44,12 @@ BUILD_TIMER_FUNCTION(AssocTimeout);
BUILD_TIMER_FUNCTION(ReassocTimeout);
BUILD_TIMER_FUNCTION(DisassocTimeout);
BUILD_TIMER_FUNCTION(LinkDownExec);
-#ifdef LEAP_SUPPORT
-BUILD_TIMER_FUNCTION(LeapAuthTimeout);
-#endif
BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
+#ifdef RT2860
BUILD_TIMER_FUNCTION(PsPollWakeExec);
BUILD_TIMER_FUNCTION(RadioOnExec);
-#ifdef QOS_DLS_SUPPORT
-BUILD_TIMER_FUNCTION(DlsTimeoutAction);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
+#endif
// for wireless system event message
char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
@@ -290,9 +286,9 @@ VOID RTMPFreeAdapter(
NdisFreeSpinLock(&pAd->MgmtRingLock);
-
+#ifdef RT2860
NdisFreeSpinLock(&pAd->RxRingLock);
-
+#endif
for (index =0 ; index < NUM_OF_TX_RING; index++)
{
NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
@@ -495,12 +491,7 @@ PNET_DEV get_netdev_from_bssid(
{
PNET_DEV dev_p = NULL;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- dev_p = pAd->net_dev;
- }
-#endif // CONFIG_STA_SUPPORT //
+ dev_p = pAd->net_dev;
ASSERT(dev_p);
return dev_p; /* return one of MBSS */
@@ -656,13 +647,8 @@ void wlan_802_11_to_802_3_packet(
//
//
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
+ NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
+}
void announce_802_3_packet(
IN PRTMP_ADAPTER pAd,
@@ -824,8 +810,6 @@ VOID RTMPSendWirelessEvent(
#endif /* WIRELESS_EXT >= 15 */
}
-
-#ifdef CONFIG_STA_SUPPORT
void send_monitor_packets(
IN PRTMP_ADAPTER pAd,
IN RX_BLK *pRxBlk)
@@ -850,7 +834,12 @@ void send_monitor_packets(
if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
{
+#ifndef RT30xx
DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%zu)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
+#endif
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
+#endif
goto err_free_sk_buff;
}
@@ -957,13 +946,11 @@ void send_monitor_packets(
ph->noise.len = 4;
ph->noise.data = 0;
-#ifdef DOT11_N_SUPPORT
if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX)
{
rate_index = 16 + ((UCHAR)pRxBlk->pRxWI->BW *16) + ((UCHAR)pRxBlk->pRxWI->ShortGI *32) + ((UCHAR)pRxBlk->pRxWI->MCS);
}
else
-#endif // DOT11_N_SUPPORT //
if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
else
@@ -996,8 +983,6 @@ err_free_sk_buff:
return;
}
-#endif // CONFIG_STA_SUPPORT //
-
void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
{
diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h
index 708923cecaa2..85175c182432 100644
--- a/drivers/staging/rt2860/rt_linux.h
+++ b/drivers/staging/rt2860/rt_linux.h
@@ -42,8 +42,10 @@
#include "rtmp_type.h"
#include <linux/module.h>
-#include <linux/version.h>
#include <linux/kernel.h>
+#if !defined(RT2860) && !defined(RT30xx)
+#include <linux/kthread.h>
+#endif
#include <linux/spinlock.h>
#include <linux/init.h>
@@ -65,6 +67,9 @@
#include <linux/vmalloc.h>
+#ifdef RT30xx
+#include <linux/wireless.h>
+#endif
#include <net/iw_handler.h>
// load firmware
@@ -88,23 +93,31 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
// add by kathy
-#ifdef CONFIG_STA_SUPPORT
+#ifdef RT2860
#define STA_PROFILE_PATH "/etc/Wireless/RT2860STA/RT2860STA.dat"
#define STA_RTMP_FIRMWARE_FILE_NAME "/etc/Wireless/RT2860STA/RT2860STA.bin"
#define STA_NIC_DEVICE_NAME "RT2860STA"
#define STA_DRIVER_VERSION "1.8.1.1"
-#ifdef MULTIPLE_CARD_SUPPORT
-#define CARD_INFO_PATH "/etc/Wireless/RT2860STA/RT2860STACard.dat"
-#endif // MULTIPLE_CARD_SUPPORT //
-
-
-#endif // CONFIG_STA_SUPPORT //
+#endif
+#ifdef RT2870
+#define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
+#define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
+#define STA_NIC_DEVICE_NAME "RT2870STA"
+#ifndef RT30xx
+#define STA_DRIVER_VERSION "1.4.0.0"
+#endif
+#ifdef RT30xx
+#define STA_DRIVER_VERSION "2.0.1.0"
+#endif
+#endif
+#ifdef RT2860
#ifndef PCI_DEVICE
#define PCI_DEVICE(vend,dev) \
.vendor = (vend), .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
#endif // PCI_DEVICE //
+#endif
#define RTMP_TIME_AFTER(a,b) \
(typecheck(unsigned long, (unsigned long)a) && \
@@ -144,24 +157,23 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
#define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
#define MIN_NET_DEVICE_FOR_APCLI 0x20
#define MIN_NET_DEVICE_FOR_MESH 0x30
-#ifdef CONFIG_STA_SUPPORT
#define MIN_NET_DEVICE_FOR_DLS 0x40
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
#define NDIS_PACKET_TYPE_DIRECTED 0
#define NDIS_PACKET_TYPE_MULTICAST 1
#define NDIS_PACKET_TYPE_BROADCAST 2
#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
-#endif // CONFIG_STA_SUPPORT //
+#ifndef RT30xx
typedef struct pid * THREAD_PID;
+#ifdef RT2860
#define THREAD_PID_INIT_VALUE NULL
+#endif
#define GET_PID(_v) find_get_pid(_v)
#define GET_PID_NUMBER(_v) pid_nr(_v)
#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
#define KILL_THREAD_PID(_A, _B, _C) kill_pid(_A, _B, _C)
+#endif
struct os_lock {
spinlock_t lock;
@@ -170,10 +182,25 @@ struct os_lock {
struct os_cookie {
+#ifdef RT2860
struct pci_dev *pci_dev;
struct pci_dev *parent_pci_dev;
dma_addr_t pAd_pa;
+#endif
+#ifdef RT2870
+ struct usb_device *pUsb_Dev;
+#ifndef RT30xx
+ struct task_struct *MLMEThr_task;
+ struct task_struct *RTUSBCmdThr_task;
+ struct task_struct *TimerQThr_task;
+#endif
+#ifdef RT30xx
+ struct pid *MLMEThr_pid;
+ struct pid *RTUSBCmdThr_pid;
+ struct pid *TimerQThr_pid;
+#endif
+#endif // RT2870 //
struct tasklet_struct rx_done_task;
struct tasklet_struct mgmt_dma_done_task;
@@ -183,8 +210,14 @@ struct os_cookie {
struct tasklet_struct ac3_dma_done_task;
struct tasklet_struct hcca_dma_done_task;
struct tasklet_struct tbtt_task;
+#ifdef RT2860
struct tasklet_struct fifo_statistic_full_task;
-
+#endif
+#ifdef RT2870
+ struct tasklet_struct null_frame_complete_task;
+ struct tasklet_struct rts_frame_complete_task;
+ struct tasklet_struct pspoll_frame_complete_task;
+#endif // RT2870 //
unsigned long apd_pid; //802.1x daemon pid
INT ioctl_if_type;
@@ -198,13 +231,7 @@ typedef struct _VIRTUAL_ADAPTER
} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
#undef ASSERT
-#define ASSERT(x) \
-{ \
- if (!(x)) \
- { \
- printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
- } \
-}
+#define ASSERT(x)
typedef struct os_cookie * POS_COOKIE;
typedef struct pci_dev * PPCI_DEV;
@@ -238,6 +265,7 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int
#define RT2860_PCI_DEVICE_ID 0x0601
+#ifdef RT2860
#define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \
linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
@@ -252,7 +280,12 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int
#define DEV_ALLOC_SKB(_length) \
dev_alloc_skb(_length)
+#endif
+#ifdef RT2870
+#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
+#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
+#endif // RT2870 //
#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
@@ -266,9 +299,20 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int
#define NdisMIndicateStatus(_w, _x, _y, _z)
-
typedef struct timer_list RTMP_OS_TIMER;
+#ifdef RT2870
+/* ----------------- Timer Related MARCO ---------------*/
+// In RT2870, we have a lot of timer functions and will read/write register, it's
+// not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
+// to ctrl pipe). So we need a wrapper function to take care it.
+
+typedef VOID (*RT2870_TIMER_HANDLE)(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3);
+#endif // RT2870 //
typedef struct _RALINK_TIMER_STRUCT {
@@ -279,9 +323,42 @@ typedef struct _RALINK_TIMER_STRUCT {
BOOLEAN Repeat; // True if periodic timer
ULONG TimerValue; // Timer value in milliseconds
ULONG cookie; // os specific object
+#ifdef RT2870
+ RT2870_TIMER_HANDLE handle;
+ void *pAd;
+#endif // RT2870 //
} RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
+#ifdef RT2870
+
+typedef enum _RT2870_KERNEL_THREAD_STATUS_
+{
+ RT2870_THREAD_UNKNOWN = 0,
+ RT2870_THREAD_INITED = 1,
+ RT2870_THREAD_RUNNING = 2,
+ RT2870_THREAD_STOPED = 4,
+}RT2870_KERNEL_THREAD_STATUS;
+
+#define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
+
+typedef struct _RT2870_TIMER_ENTRY_
+{
+ RALINK_TIMER_STRUCT *pRaTimer;
+ struct _RT2870_TIMER_ENTRY_ *pNext;
+}RT2870_TIMER_ENTRY;
+
+
+#define TIMER_QUEUE_SIZE_MAX 128
+typedef struct _RT2870_TIMER_QUEUE_
+{
+ unsigned int status;
+ UCHAR *pTimerQPoll;
+ RT2870_TIMER_ENTRY *pQPollFreeList;
+ RT2870_TIMER_ENTRY *pQHead;
+ RT2870_TIMER_ENTRY *pQTail;
+}RT2870_TIMER_QUEUE;
+#endif // RT2870 //
//#define DBG 1
@@ -371,6 +448,7 @@ extern ULONG RTDebugLevel;
spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
}
+#ifdef RT2860
#if defined(INF_TWINPASS) || defined(INF_DANUBE) || defined(IKANOS_VX_1X0)
//Patch for ASIC turst read/write bug, needs to remove after metel fix
#define RTMP_IO_READ32(_A, _R, _pV) \
@@ -472,7 +550,32 @@ extern ULONG RTDebugLevel;
writew((_V), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \
}
#endif
+#endif /* RT2860 */
+#ifdef RT2870
+//Patch for ASIC turst read/write bug, needs to remove after metel fix
+#define RTMP_IO_READ32(_A, _R, _pV) \
+ RTUSBReadMACRegister(_A, _R, _pV)
+
+#define RTMP_IO_READ8(_A, _R, _pV) \
+{ \
+}
+
+#define RTMP_IO_WRITE32(_A, _R, _V) \
+ RTUSBWriteMACRegister(_A, _R, _V)
+
+
+#define RTMP_IO_WRITE8(_A, _R, _V) \
+{ \
+ USHORT _Val = _V; \
+ RTUSBSingleWrite(_A, _R, _Val); \
+}
+
+#define RTMP_IO_WRITE16(_A, _R, _V) \
+{ \
+ RTUSBSingleWrite(_A, _R, _V); \
+}
+#endif // RT2870 //
#ifndef wait_event_interruptible_timeout
#define __wait_event_interruptible_timeout(wq, condition, ret) \
@@ -515,7 +618,6 @@ do { \
wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
-/* Modified by Wu Xi-Kun 4/21/2006 */
typedef void (*TIMER_FUNCTION)(unsigned long);
#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
@@ -523,6 +625,7 @@ typedef void (*TIMER_FUNCTION)(unsigned long);
#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
+#ifdef RT2860
#define BUILD_TIMER_FUNCTION(_func) \
void linux_##_func(unsigned long data) \
{ \
@@ -532,7 +635,22 @@ void linux_##_func(unsigned long data) \
if (pTimer->Repeat) \
RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \
}
-
+#endif
+#ifdef RT2870
+#define BUILD_TIMER_FUNCTION(_func) \
+void linux_##_func(unsigned long data) \
+{ \
+ PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
+ RT2870_TIMER_ENTRY *_pQNode; \
+ RTMP_ADAPTER *_pAd; \
+ \
+ _pTimer->handle = _func; \
+ _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
+ _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
+ if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
+ RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
+}
+#endif // RT2870 //
#define DECLARE_TIMER_FUNCTION(_func) \
@@ -546,9 +664,10 @@ DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
+#ifdef RT2870
+DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
+#endif // RT2870 //
-
-#ifdef CONFIG_STA_SUPPORT
DECLARE_TIMER_FUNCTION(BeaconTimeout);
DECLARE_TIMER_FUNCTION(ScanTimeout);
DECLARE_TIMER_FUNCTION(AuthTimeout);
@@ -556,19 +675,11 @@ DECLARE_TIMER_FUNCTION(AssocTimeout);
DECLARE_TIMER_FUNCTION(ReassocTimeout);
DECLARE_TIMER_FUNCTION(DisassocTimeout);
DECLARE_TIMER_FUNCTION(LinkDownExec);
-#ifdef LEAP_SUPPORT
-DECLARE_TIMER_FUNCTION(LeapAuthTimeout);
-#endif
DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
DECLARE_TIMER_FUNCTION(PsPollWakeExec);
DECLARE_TIMER_FUNCTION(RadioOnExec);
-#ifdef QOS_DLS_SUPPORT
-DECLARE_TIMER_FUNCTION(DlsTimeoutAction);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
@@ -676,10 +787,6 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
-#if 0
-//#define RTMP_SET_PACKET_DHCP(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
-//#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11])
-#else
//
// Sepcific Pakcet Type definition
//
@@ -759,8 +866,6 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
-#endif
-
// If this flag is set, it indicates that this EAPoL frame MUST be clear.
#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
@@ -884,6 +989,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb);
void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
+#ifdef RT2860
#if !defined(PCI_CAP_ID_EXP)
#define PCI_CAP_ID_EXP 0x10
#endif
@@ -897,5 +1003,5 @@ void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
#endif
#define PCIBUS_INTEL_VENDOR 0x8086
-
+#endif
diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c
index 6c4396f0903b..f298b9bcec39 100644
--- a/drivers/staging/rt2860/rt_main_dev.c
+++ b/drivers/staging/rt2860/rt_main_dev.c
@@ -40,17 +40,6 @@
#define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min
-#ifdef MULTIPLE_CARD_SUPPORT
-// record whether the card in the card list is used in the card file
-UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD];
-// record used card mac address in the card list
-static UINT8 MC_CardMac[MAX_NUM_OF_MULTIPLE_CARD][6];
-#endif // MULTIPLE_CARD_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-UINT32 CW_MAX_IN_BITS;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
/*---------------------------------------------------------------------*/
/* Private Variables Used */
/*---------------------------------------------------------------------*/
@@ -65,13 +54,13 @@ MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
/*---------------------------------------------------------------------*/
/* Prototypes of Functions Used */
/*---------------------------------------------------------------------*/
-#ifdef DOT11_N_SUPPORT
extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
+#ifdef RT2860
extern void init_thread_task(PRTMP_ADAPTER pAd);
+#endif
// public function prototype
INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
@@ -83,13 +72,7 @@ INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev)
static void CfgInitHook(PRTMP_ADAPTER pAd);
-#ifdef CONFIG_STA_SUPPORT
extern const struct iw_handler_def rt28xx_iw_handler_def;
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-extern const struct iw_handler_def rt28xx_ap_iw_handler_def;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
#if WIRELESS_EXT >= 12
// This function will be called when query /proc
@@ -206,6 +189,12 @@ int rt28xx_close(IN PNET_DEV dev)
RTMP_ADAPTER *pAd = net_dev->ml_priv;
BOOLEAN Cancelled = FALSE;
UINT32 i = 0;
+#ifdef RT2870
+ DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
+ DECLARE_WAITQUEUE(wait, current);
+
+ //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
+#endif // RT2870 //
DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
@@ -214,54 +203,26 @@ int rt28xx_close(IN PNET_DEV dev)
if (pAd == NULL)
return 0; // close ok
-
-#ifdef WDS_SUPPORT
- WdsDown(pAd);
-#endif // WDS_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// If dirver doesn't wake up firmware here,
// NICLoadFirmware will hang forever when interface is up again.
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
RTMP_SET_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) ||
RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
+#endif
+#ifdef RT2870
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+#endif
{
+#ifdef RT2860
AsicForceWakeup(pAd, RTMP_HALT);
+#endif
+#ifdef RT2870
+ AsicForceWakeup(pAd, TRUE);
+#endif
}
-#ifdef QOS_DLS_SUPPORT
- // send DLS-TEAR_DOWN message,
- if (pAd->CommonCfg.bDLSCapable)
- {
- UCHAR i;
-
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
- RT28XX_MLME_HANDLER(pAd);
- }
-#endif // QOS_DLS_SUPPORT //
-
if (INFRA_ON(pAd) &&
(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
{
@@ -287,6 +248,9 @@ int rt28xx_close(IN PNET_DEV dev)
RTMPusecDelay(1000);
}
+#ifdef RT2870
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
+#endif // RT2870 //
#ifdef CCX_SUPPORT
RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
@@ -295,22 +259,11 @@ int rt28xx_close(IN PNET_DEV dev)
RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- // send wireless event to wpa_supplicant for infroming interface down.
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_INTERFACE_DOWN;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
MlmeRadioOff(pAd);
+#ifdef RT2860
pAd->bPCIclkOff = FALSE;
+#endif
}
-#endif // CONFIG_STA_SUPPORT //
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
@@ -323,25 +276,52 @@ int rt28xx_close(IN PNET_DEV dev)
}
}
+#ifdef RT2870
+ // ensure there are no more active urbs.
+ add_wait_queue (&unlink_wakeup, &wait);
+ pAd->wait = &unlink_wakeup;
+
+ // maybe wait for deletions to finish.
+ i = 0;
+ //while((i < 25) && atomic_read(&pAd->PendingRx) > 0)
+ while(i < 25)
+ {
+ unsigned long IrqFlags;
+
+ RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
+ if (pAd->PendingRx == 0)
+ {
+ RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
+ break;
+ }
+ RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
+
+ msleep(UNLINK_TIMEOUT_MS); //Time in millisecond
+ i++;
+ }
+ pAd->wait = NULL;
+ remove_wait_queue (&unlink_wakeup, &wait);
+#endif // RT2870 //
+
+#ifdef RT2870
+ // We need clear timerQ related structure before exits of the timer thread.
+ RT2870_TimerQ_Exit(pAd);
+ // Close kernel threads or tasklets
+ RT28xxThreadTerminate(pAd);
+#endif // RT2870 //
+
// Stop Mlme state machine
MlmeHalt(pAd);
// Close kernel threads or tasklets
kill_thread_task(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- MacTableReset(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
+ MacTableReset(pAd);
MeasureReqTabExit(pAd);
TpcReqTabExit(pAd);
-
+#ifdef RT2860
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
{
NICDisableInterrupt(pAd);
@@ -357,18 +337,15 @@ int rt28xx_close(IN PNET_DEV dev)
RT28XX_IRQ_RELEASE(net_dev)
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
}
-
+#endif
// Free Ring or USB buffers
RTMPFreeTxRxRingMemory(pAd);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-#ifdef DOT11_N_SUPPORT
// Free BA reorder resource
ba_reordering_resource_release(pAd);
-#endif // DOT11_N_SUPPORT //
-
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
@@ -377,17 +354,19 @@ int rt28xx_close(IN PNET_DEV dev)
static int rt28xx_init(IN struct net_device *net_dev)
{
+#ifdef RT2860
PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv;
+#endif
+#ifdef RT2870
+ PRTMP_ADAPTER pAd = net_dev->ml_priv;
+#endif
UINT index;
UCHAR TmpPhy;
NDIS_STATUS Status;
UINT32 MacCsr0 = 0;
-
-#ifdef DOT11_N_SUPPORT
// Allocate BA Reordering memory
ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
-#endif // DOT11_N_SUPPORT //
// Make sure MAC gets ready.
index = 0;
@@ -403,11 +382,11 @@ static int rt28xx_init(IN struct net_device *net_dev)
} while (index++ < 100);
DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
+/*Iverson patch PCIE L1 issue */
// Disable DMA
RT28XXDMADisable(pAd);
-
// Load 8051 firmware
Status = NICLoadFirmware(pAd);
if (Status != NDIS_STATUS_SUCCESS)
@@ -420,10 +399,12 @@ static int rt28xx_init(IN struct net_device *net_dev)
// Disable interrupts here which is as soon as possible
// This statement should never be true. We might consider to remove it later
+#ifdef RT2860
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
{
NICDisableInterrupt(pAd);
}
+#endif
Status = RTMPAllocTxRxRingMemory(pAd);
if (Status != NDIS_STATUS_SUCCESS)
@@ -448,6 +429,10 @@ static int rt28xx_init(IN struct net_device *net_dev)
//
UserCfgInit(pAd);
+#ifdef RT2870
+ // We need init timerQ related structure before create the timer thread.
+ RT2870_TimerQ_Init(pAd);
+#endif // RT2870 //
RT28XX_TASK_THREAD_INIT(pAd, Status);
if (Status != NDIS_STATUS_SUCCESS)
@@ -455,15 +440,7 @@ static int rt28xx_init(IN struct net_device *net_dev)
CfgInitHook(pAd);
-
-#ifdef BLOCK_NET_IF
- initblockQueueTab(pAd);
-#endif // BLOCK_NET_IF //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisAllocateSpinLock(&pAd->MacTabLock);
-#endif // CONFIG_STA_SUPPORT //
+ NdisAllocateSpinLock(&pAd->MacTabLock);
MeasureReqTabInit(pAd);
TpcReqTabInit(pAd);
@@ -489,10 +466,17 @@ static int rt28xx_init(IN struct net_device *net_dev)
goto err4;
}
+#ifdef RT2870
+ pAd->CommonCfg.bMultipleIRP = FALSE;
+
+ if (pAd->CommonCfg.bMultipleIRP)
+ pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
+ else
+ pAd->CommonCfg.NumOfBulkInIRP = 1;
+#endif // RT2870 //
//Init Ba Capability parameters.
-#ifdef DOT11_N_SUPPORT
pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
@@ -501,7 +485,6 @@ static int rt28xx_init(IN struct net_device *net_dev)
pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-#endif // DOT11_N_SUPPORT //
printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
@@ -516,9 +499,7 @@ static int rt28xx_init(IN struct net_device *net_dev)
TmpPhy = pAd->CommonCfg.PhyMode;
pAd->CommonCfg.PhyMode = 0xff;
RTMPSetPhyMode(pAd, TmpPhy);
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
// No valid channels.
if (pAd->ChannelListNum == 0)
@@ -527,11 +508,14 @@ static int rt28xx_init(IN struct net_device *net_dev)
goto err4;
}
-#ifdef DOT11_N_SUPPORT
printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
-#endif // DOT11_N_SUPPORT //
+
+#ifdef RT2870
+ //Init RT30xx RFRegisters after read RFIC type from EEPROM
+ NICInitRT30xxRFRegisters(pAd);
+#endif // RT2870 //
#ifdef IKANOS_VX_1X0
VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
@@ -543,8 +527,10 @@ static int rt28xx_init(IN struct net_device *net_dev)
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+#ifndef RT30xx
// 8051 firmware require the signal during booting time.
AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
+#endif
if (pAd && (Status != NDIS_STATUS_SUCCESS))
{
@@ -561,9 +547,24 @@ static int rt28xx_init(IN struct net_device *net_dev)
// Microsoft HCT require driver send a disconnect event after driver initialization.
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
+
DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
+#ifdef RT2870
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
+
+ //
+ // Support multiple BulkIn IRP,
+ // the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.
+ //
+ for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++)
+ {
+ RTUSBBulkReceive(pAd);
+ DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" ));
+ }
+#endif // RT2870 //
}// end of else
@@ -578,17 +579,12 @@ err3:
err2:
RTMPFreeTxRxRingMemory(pAd);
err1:
-
-#ifdef DOT11_N_SUPPORT
os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
-#endif // DOT11_N_SUPPORT //
RT28XX_IRQ_RELEASE(net_dev);
// shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
//net_dev->ml_priv = 0;
-#ifdef INF_AMAZON_SE
-err0:
-#endif // INF_AMAZON_SE //
+
printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
return FALSE;
} /* End of rt28xx_init */
@@ -625,27 +621,6 @@ int rt28xx_open(IN PNET_DEV dev)
return -1;
}
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (pAd->OpMode == OPMODE_AP)
- {
- CW_MAX_IN_BITS = 6;
- }
- else if (pAd->OpMode == OPMODE_STA)
- {
- CW_MAX_IN_BITS = 10;
- }
-
-#if WIRELESS_EXT >= 12
- if (net_dev->priv_flags == INT_MAIN)
- {
- if (pAd->OpMode == OPMODE_AP)
- net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
- else if (pAd->OpMode == OPMODE_STA)
- net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
- }
-#endif // WIRELESS_EXT >= 12 //
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
// Init
pObj = (POS_COOKIE)pAd->OS_Cookie;
@@ -664,13 +639,8 @@ int rt28xx_open(IN PNET_DEV dev)
if (rt28xx_init(net_dev) == FALSE)
goto err;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NdisZeroMemory(pAd->StaCfg.dev_name, 16);
- NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
- }
-#endif // CONFIG_STA_SUPPORT //
+ NdisZeroMemory(pAd->StaCfg.dev_name, 16);
+ NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
// Set up the Mac address
NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
@@ -680,24 +650,6 @@ int rt28xx_open(IN PNET_DEV dev)
// Various AP function init
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- // send wireless event to wpa_supplicant for infroming interface down.
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_INTERFACE_UP;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
// Enable Interrupt
RT28XX_IRQ_ENABLE(pAd);
@@ -711,11 +663,9 @@ int rt28xx_open(IN PNET_DEV dev)
printk("0x1300 = %08x\n", reg);
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+#ifdef RT2860
RTMPInitPCIeLinkCtrlValue(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
+#endif
return (retval);
err:
@@ -745,26 +695,12 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
CHAR slot_name[IFNAMSIZ];
struct net_device *device;
-
- //ether_setup(dev);
-
-#ifdef CONFIG_STA_SUPPORT
#if WIRELESS_EXT >= 12
if (pAd->OpMode == OPMODE_STA)
{
dev->wireless_handlers = &rt28xx_iw_handler_def;
}
#endif //WIRELESS_EXT >= 12
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-#if WIRELESS_EXT >= 12
- if (pAd->OpMode == OPMODE_AP)
- {
- dev->wireless_handlers = &rt28xx_ap_iw_handler_def;
- }
-#endif //WIRELESS_EXT >= 12
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
#if WIRELESS_EXT < 21
dev->get_wireless_stats = rt28xx_get_wireless_stats;
@@ -774,11 +710,6 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
// find available device name
for (i = 0; i < 8; i++)
{
-#ifdef MULTIPLE_CARD_SUPPORT
- if (pAd->MC_RowID >= 0)
- sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i);
- else
-#endif // MULTIPLE_CARD_SUPPORT //
sprintf(slot_name, "ra%d", i);
device = dev_get_by_name(dev_net(dev), slot_name);
@@ -796,11 +727,6 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
}
else
{
-#ifdef MULTIPLE_CARD_SUPPORT
- if (pAd->MC_RowID >= 0)
- sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i);
- else
-#endif // MULTIPLE_CARD_SUPPORT //
sprintf(dev->name, "ra%d", i);
Status = NDIS_STATUS_SUCCESS;
}
@@ -809,369 +735,6 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
}
-
-#ifdef MULTIPLE_CARD_SUPPORT
-/*
-========================================================================
-Routine Description:
- Get card profile path.
-
-Arguments:
- pAd
-
-Return Value:
- TRUE - Find a card profile
- FALSE - use default profile
-
-Note:
-========================================================================
-*/
-extern INT RTMPGetKeyParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer);
-
-BOOLEAN RTMP_CardInfoRead(
- IN PRTMP_ADAPTER pAd)
-{
-#define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
-#define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
-#define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
-
-#define LETTER_CASE_TRANSLATE(txt_p, card_id) \
- { UINT32 _len; char _char; \
- for(_len=0; _len<strlen(card_id); _len++) { \
- _char = *(txt_p + _len); \
- if (('A' <= _char) && (_char <= 'Z')) \
- *(txt_p+_len) = 'a'+(_char-'A'); \
- } }
-
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30];
- BOOLEAN flg_match_ok = FALSE;
- INT32 card_select_method;
- INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
- EEPROM_ANTENNA_STRUC antenna;
- USHORT addr01, addr23, addr45;
- UINT8 mac[6];
- UINT32 data, card_index;
- UCHAR *start_ptr;
-
-
- // init
- buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if (buffer == NULL)
- return FALSE;
-
- tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(tmpbuf == NULL)
- {
- kfree(buffer);
- return NDIS_STATUS_FAILURE;
- }
-
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- // get RF IC type
- RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
-
- if ((data & 0x30) == 0)
- pAd->EEPROMAddressNum = 6; // 93C46
- else if ((data & 0x30) == 0x10)
- pAd->EEPROMAddressNum = 8; // 93C66
- else
- pAd->EEPROMAddressNum = 8; // 93C86
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
-
- if ((antenna.field.RfIcType == RFIC_2850) ||
- (antenna.field.RfIcType == RFIC_2750))
- {
- /* ABGN card */
- strcpy(RFIC_word, "abgn");
- }
- else
- {
- /* BGN card */
- strcpy(RFIC_word, "bgn");
- }
-
- // get MAC address
- RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
- RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
- RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
-
- mac[0] = (UCHAR)(addr01 & 0xff);
- mac[1] = (UCHAR)(addr01 >> 8);
- mac[2] = (UCHAR)(addr23 & 0xff);
- mac[3] = (UCHAR)(addr23 >> 8);
- mac[4] = (UCHAR)(addr45 & 0xff);
- mac[5] = (UCHAR)(addr45 >> 8);
-
- // open card information file
- srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
- if (IS_ERR(srcf))
- {
- /* card information file does not exist */
- DBGPRINT(RT_DEBUG_TRACE,
- ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH));
- return FALSE;
- }
-
- if (srcf->f_op && srcf->f_op->read)
- {
- /* card information file exists so reading the card information */
- memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
- retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
- if (retval < 0)
- {
- /* read fail */
- DBGPRINT(RT_DEBUG_TRACE,
- ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
- }
- else
- {
- /* get card selection method */
- memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
- card_select_method = MC_SELECT_CARDTYPE; // default
-
- if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer))
- {
- if (strcmp(tmpbuf, "CARDID") == 0)
- card_select_method = MC_SELECT_CARDID;
- else if (strcmp(tmpbuf, "MAC") == 0)
- card_select_method = MC_SELECT_MAC;
- else if (strcmp(tmpbuf, "CARDTYPE") == 0)
- card_select_method = MC_SELECT_CARDTYPE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> Card Selection = %d\n", card_select_method));
-
- // init
- card_free_id = -1;
- card_nouse_id = -1;
- card_same_mac_id = -1;
- card_match_id = -1;
-
- // search current card information records
- for(card_index=0;
- card_index<MAX_NUM_OF_MULTIPLE_CARD;
- card_index++)
- {
- if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
- (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
- {
- // MAC is all-0 so the entry is available
- MC_CardUsed[card_index] = 0;
-
- if (card_free_id < 0)
- card_free_id = card_index; // 1st free entry
- }
- else
- {
- if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
- {
- // we find the entry with same MAC
- if (card_same_mac_id < 0)
- card_same_mac_id = card_index; // 1st same entry
- }
- else
- {
- // MAC is not all-0 but used flag == 0
- if ((MC_CardUsed[card_index] == 0) &&
- (card_nouse_id < 0))
- {
- card_nouse_id = card_index; // 1st available entry
- }
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> Free = %d, Same = %d, NOUSE = %d\n",
- card_free_id, card_same_mac_id, card_nouse_id));
-
- if ((card_same_mac_id >= 0) &&
- ((card_select_method == MC_SELECT_CARDID) ||
- (card_select_method == MC_SELECT_CARDTYPE)))
- {
- // same MAC entry is found
- card_match_id = card_same_mac_id;
-
- if (card_select_method == MC_SELECT_CARDTYPE)
- {
- // for CARDTYPE
- sprintf(card_id_buf, "%02dCARDTYPE%s",
- card_match_id, RFIC_word);
-
- if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
- {
- // we found the card ID
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
- }
- }
- }
- else
- {
- // the card is 1st plug-in, try to find the match card profile
- switch(card_select_method)
- {
- case MC_SELECT_CARDID: // CARDID
- default:
- if (card_free_id >= 0)
- card_match_id = card_free_id;
- else
- card_match_id = card_nouse_id;
- break;
-
- case MC_SELECT_MAC: // MAC
- sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
-
- /* try to find the key word in the card file */
- if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
- {
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
-
- /* get the row ID (2 ASCII characters) */
- start_ptr -= 2;
- card_id_buf[0] = *(start_ptr);
- card_id_buf[1] = *(start_ptr+1);
- card_id_buf[2] = 0x00;
-
- card_match_id = simple_strtol(card_id_buf, 0, 10);
- }
- break;
-
- case MC_SELECT_CARDTYPE: // CARDTYPE
- card_nouse_id = -1;
-
- for(card_index=0;
- card_index<MAX_NUM_OF_MULTIPLE_CARD;
- card_index++)
- {
- sprintf(card_id_buf, "%02dCARDTYPE%s",
- card_index, RFIC_word);
-
- if ((start_ptr=rtstrstruncasecmp(buffer,
- card_id_buf)) != NULL)
- {
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
-
- if (MC_CardUsed[card_index] == 0)
- {
- /* current the card profile is not used */
- if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
- (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
- {
- // find it and no previous card use it
- card_match_id = card_index;
- break;
- }
- else
- {
- // ever a card use it
- if (card_nouse_id < 0)
- card_nouse_id = card_index;
- }
- }
- }
- }
-
- // if not find a free one, use the available one
- if (card_match_id < 0)
- card_match_id = card_nouse_id;
- break;
- }
- }
-
- if (card_match_id >= 0)
- {
- // make up search keyword
- switch(card_select_method)
- {
- case MC_SELECT_CARDID: // CARDID
- sprintf(card_id_buf, "%02dCARDID", card_match_id);
- break;
-
- case MC_SELECT_MAC: // MAC
- sprintf(card_id_buf,
- "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
- card_match_id,
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
- break;
-
- case MC_SELECT_CARDTYPE: // CARDTYPE
- default:
- sprintf(card_id_buf, "%02dcardtype%s",
- card_match_id, RFIC_word);
- break;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
-
- // read card file path
- if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer))
- {
- if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
- {
- // backup card information
- pAd->MC_RowID = card_match_id; /* base 0 */
- MC_CardUsed[card_match_id] = 1;
- memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
-
- // backup card file path
- NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
- pAd->MC_FileName[strlen(tmpbuf)] = '\0';
- flg_match_ok = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("Card Profile Name = %s\n", pAd->MC_FileName));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("Card Profile Name length too large!\n"));
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("Can not find search key word in card.dat!\n"));
- }
-
- if ((flg_match_ok != TRUE) &&
- (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
- {
- MC_CardUsed[card_match_id] = 0;
- memset(MC_CardMac[card_match_id], 0, sizeof(mac));
- }
- } // if (card_match_id >= 0)
- }
- }
-
- // close file
- retval = filp_close(srcf, NULL);
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
- kfree(buffer);
- kfree(tmpbuf);
- return flg_match_ok;
-}
-#endif // MULTIPLE_CARD_SUPPORT //
-
-
/*
========================================================================
Routine Description:
@@ -1198,12 +761,17 @@ INT __devinit rt28xx_probe(
PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
INT status;
PVOID handle;
+#ifdef RT2860
struct pci_dev *dev_p = (struct pci_dev *)_dev_p;
+#endif
+#ifdef RT2870
+ struct usb_interface *intf = (struct usb_interface *)_dev_p;
+ struct usb_device *dev_p = interface_to_usbdev(intf);
+ dev_p = usb_get_dev(dev_p);
+#endif // RT2870 //
-#ifdef CONFIG_STA_SUPPORT
DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
-#endif // CONFIG_STA_SUPPORT //
net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
if (net_dev == NULL)
@@ -1214,13 +782,12 @@ INT __devinit rt28xx_probe(
}
netif_stop_queue(net_dev);
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+
/* for supporting Network Manager */
/* Set the sysfs physical device reference for the network logical device
* if set prior to registration will cause a symlink during initialization.
*/
SET_NETDEV_DEV(net_dev, &(dev_p->dev));
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
// Allocate RTMP_ADAPTER miniport adapter structure
handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
@@ -1235,32 +802,13 @@ INT __devinit rt28xx_probe(
RT28XXNetDevInit(_dev_p, net_dev, pAd);
-#ifdef CONFIG_STA_SUPPORT
pAd->StaCfg.OriDevType = net_dev->type;
-#endif // CONFIG_STA_SUPPORT //
// Post config
if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
goto err_out_unmap;
-#ifdef CONFIG_STA_SUPPORT
pAd->OpMode = OPMODE_STA;
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
- // find its profile path
- pAd->MC_RowID = -1; // use default profile path
- RTMP_CardInfoRead(pAd);
-
- if (pAd->MC_RowID == -1)
-#ifdef CONFIG_STA_SUPPORT
- strcpy(pAd->MC_FileName, STA_PROFILE_PATH);
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName));
-#endif // MULTIPLE_CARD_SUPPORT //
// sample move
if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
@@ -1317,17 +865,6 @@ int rt28xx_packet_xmit(struct sk_buff *skb)
int status = 0;
PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
- /* RT2870STA does this in RTMPSendPackets() */
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES);
- return 0;
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Drop send request since we are in monitor mode
if (MONITOR_ON(pAd))
@@ -1336,7 +873,6 @@ int rt28xx_packet_xmit(struct sk_buff *skb)
goto done;
}
}
-#endif // CONFIG_STA_SUPPORT //
// EapolStart size is 18
if (skb->len < 14)
@@ -1354,16 +890,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb)
}
#endif
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
- }
-
-#endif // CONFIG_STA_SUPPORT //
+ STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
status = 0;
done:
@@ -1432,10 +959,8 @@ struct iw_statistics *rt28xx_get_wireless_stats(
if(pAd->iw_stats.qual.qual > 100)
pAd->iw_stats.qual.qual = 100;
-#ifdef CONFIG_STA_SUPPORT
if (pAd->OpMode == OPMODE_STA)
pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
-#endif // CONFIG_STA_SUPPORT //
pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
@@ -1487,13 +1012,7 @@ INT rt28xx_ioctl(
return -ENETDOWN;
}
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
- }
-#endif // CONFIG_STA_SUPPORT //
+ ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
return ret;
}
diff --git a/drivers/staging/rt2860/rt_profile.c b/drivers/staging/rt2860/rt_profile.c
index 62141f376972..d92b14328d40 100644
--- a/drivers/staging/rt2860/rt_profile.c
+++ b/drivers/staging/rt2860/rt_profile.c
@@ -27,12 +27,10 @@
#include "rt_config.h"
-#ifdef DOT11_N_SUPPORT
static void HTParametersHook(
IN PRTMP_ADAPTER pAd,
IN CHAR *pValueStr,
IN CHAR *pInput);
-#endif // DOT11_N_SUPPORT //
#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
@@ -756,9 +754,6 @@ static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, c
//DefaultKeyID
if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
KeyIdx = simple_strtol(tmpbuf, 0, 10);
if((KeyIdx >= 1 ) && (KeyIdx <= 4))
@@ -768,7 +763,6 @@ static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, c
DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
}
-#endif // CONFIG_STA_SUPPORT //
}
@@ -783,8 +777,6 @@ static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, c
KeyType[i] = simple_strtol(macptr, 0, 10);
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
sprintf(tok_str, "Key%dStr", idx + 1);
if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
@@ -792,13 +784,10 @@ static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, c
rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
}
}
-#endif // CONFIG_STA_SUPPORT //
}
}
}
-
-#ifdef CONFIG_STA_SUPPORT
static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
{
PUCHAR macptr;
@@ -821,23 +810,6 @@ static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbu
DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
}
-#ifdef QOS_DLS_SUPPORT
- //DLSCapable
- if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- {
- pAd->CommonCfg.bDLSCapable = TRUE;
- }
- else //Disable
- {
- pAd->CommonCfg.bDLSCapable = FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
- }
-#endif // QOS_DLS_SUPPORT //
-
//AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
{
@@ -882,8 +854,6 @@ static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbu
}
}
-#endif // CONFIG_STA_SUPPORT //
-
NDIS_STATUS RTMPReadParametersHook(
IN PRTMP_ADAPTER pAd)
@@ -896,10 +866,7 @@ NDIS_STATUS RTMPReadParametersHook(
CHAR *tmpbuf;
ULONG RtsThresh;
ULONG FragThresh;
-#ifdef CONFIG_STA_SUPPORT
UCHAR keyMaterial[40];
-#endif // CONFIG_STA_SUPPORT //
-
PUCHAR macptr;
INT i = 0;
@@ -915,21 +882,17 @@ NDIS_STATUS RTMPReadParametersHook(
return NDIS_STATUS_FAILURE;
}
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- src = STA_PROFILE_PATH;
-#endif // CONFIG_STA_SUPPORT //
-#ifdef MULTIPLE_CARD_SUPPORT
- src = pAd->MC_FileName;
-#endif // MULTIPLE_CARD_SUPPORT //
+ src = STA_PROFILE_PATH;
// Save uid and gid used for filesystem access.
// Set user and group to 0 (root)
+#ifndef RT30xx
orgfsuid = current_fsuid();
orgfsgid = current_fsgid();
/* Hm, can't really do this nicely anymore, so rely on these files
* being set to the proper permission to read them... */
/* current->cred->fsuid = current->cred->fsgid = 0; */
+#endif
orgfs = get_fs();
set_fs(KERNEL_DS);
@@ -970,12 +933,7 @@ NDIS_STATUS RTMPReadParametersHook(
if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
{
NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(pAd->StaCfg.StaOriCountryCode, tmpbuf , 2);
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
+
if (strlen(pAd->CommonCfg.CountryCode) != 0)
{
pAd->CommonCfg.bCountryFlag = TRUE;
@@ -991,12 +949,6 @@ NDIS_STATUS RTMPReadParametersHook(
pAd->CommonCfg.Geography = Geography;
pAd->CommonCfg.CountryCode[2] =
(pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
}
}
@@ -1006,9 +958,6 @@ NDIS_STATUS RTMPReadParametersHook(
pAd->CommonCfg.CountryCode[2] = ' ';
}
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
//SSID
if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
@@ -1028,10 +977,7 @@ NDIS_STATUS RTMPReadParametersHook(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
//NetworkType
if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
@@ -1046,7 +992,7 @@ NDIS_STATUS RTMPReadParametersHook(
DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
}
}
-#endif // CONFIG_STA_SUPPORT //
+
//Channel
if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
{
@@ -1058,9 +1004,7 @@ NDIS_STATUS RTMPReadParametersHook(
{
int value = 0, maxPhyMode = PHY_11G;
-#ifdef DOT11_N_SUPPORT
maxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
value = simple_strtol(tmpbuf, 0, 10);
@@ -1086,10 +1030,9 @@ NDIS_STATUS RTMPReadParametersHook(
if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
{
pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
-#endif // CONFIG_STA_SUPPORT //
+
+ pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
+
DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
}
//BGProtection
@@ -1206,11 +1149,7 @@ NDIS_STATUS RTMPReadParametersHook(
#endif // AGGREGATION_SUPPORT //
// WmmCapable
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
-#endif // CONFIG_STA_SUPPORT //
+ rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
//ShortSlot
if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
@@ -1313,8 +1252,6 @@ NDIS_STATUS RTMPReadParametersHook(
//AuthMode
if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
{
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
@@ -1326,12 +1263,10 @@ NDIS_STATUS RTMPReadParametersHook(
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
else
pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
@@ -1339,14 +1274,10 @@ NDIS_STATUS RTMPReadParametersHook(
DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
}
-#endif // CONFIG_STA_SUPPORT //
}
//EncrypType
if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
@@ -1365,13 +1296,8 @@ NDIS_STATUS RTMPReadParametersHook(
DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
}
-#endif // CONFIG_STA_SUPPORT //
}
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
{
@@ -1420,38 +1346,20 @@ NDIS_STATUS RTMPReadParametersHook(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
//DefaultKeyID, KeyType, KeyStr
rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
-#ifdef DOT11_N_SUPPORT
HTParametersHook(pAd, tmpbuf, buffer);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef CARRIER_DETECTION_SUPPORT
- //CarrierDetect
- if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, buffer))
- {
- if ((strncmp(tmpbuf, "0", 1) == 0))
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else if ((strncmp(tmpbuf, "1", 1) == 0))
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CarrierDetect.Enable=%d\n", pAd->CommonCfg.CarrierDetect.Enable));
- }
- else
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
//PSMode
+#ifdef RT2860
if (RTMPGetKeyParameter("PSMode", tmpbuf, 32, buffer))
+#endif
+#ifdef RT2870
+ if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
+#endif
{
if (pAd->StaCfg.BssType == BSS_INFRA)
{
@@ -1534,8 +1442,23 @@ NDIS_STATUS RTMPReadParametersHook(
DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
}
}
-#endif // CONFIG_STA_SUPPORT //
+#ifdef RT30xx
+ {
+ if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, buffer))
+ {
+ for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
+ {
+ if(simple_strtol(macptr, 0, 10) != 0) //Enable
+ pAd->CommonCfg.bRxAntDiversity = TRUE;
+ else //Disable
+ pAd->CommonCfg.bRxAntDiversity = FALSE;
+
+ DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
+ }
+ }
+ }
+#endif // RT30xx //
}
}
else
@@ -1554,18 +1477,12 @@ NDIS_STATUS RTMPReadParametersHook(
set_fs(orgfs);
-#if 0
- current->cred->fsuid = orgfsuid;
- current->cred->fsgid = orgfsgid;
-#endif
-
kfree(buffer);
kfree(tmpbuf);
return (NDIS_STATUS_SUCCESS);
}
-#ifdef DOT11_N_SUPPORT
static void HTParametersHook(
IN PRTMP_ADAPTER pAd,
IN CHAR *pValueStr,
@@ -1654,12 +1571,21 @@ static void HTParametersHook(
if (Value == 0)
{
pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
+#ifdef RT30xx
+ pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
+#endif
}
else
{
pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
+#ifdef RT30xx
+ pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
+#endif
}
pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
+#ifdef RT30xx
+ pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
+#endif
DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
}
@@ -1804,8 +1730,6 @@ static void HTParametersHook(
{
UCHAR fix_tx_mode;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
fix_tx_mode = FIXED_TXMODE_HT;
@@ -1837,7 +1761,6 @@ static void HTParametersHook(
DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
}
-#endif // CONFIG_STA_SUPPORT //
}
@@ -1882,9 +1805,6 @@ static void HTParametersHook(
// MSC
if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
Value = simple_strtol(pValueStr, 0, 10);
@@ -1901,7 +1821,6 @@ static void HTParametersHook(
DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
}
}
-#endif // CONFIG_STA_SUPPORT //
}
// STBC
@@ -1977,5 +1896,3 @@ static void HTParametersHook(
}
}
-#endif // DOT11_N_SUPPORT //
-
diff --git a/drivers/staging/rt2860/rtmp.h b/drivers/staging/rt2860/rtmp.h
index b904b7886c28..25c31998d071 100644
--- a/drivers/staging/rt2860/rtmp.h
+++ b/drivers/staging/rt2860/rtmp.h
@@ -43,25 +43,112 @@
#include "link_list.h"
#include "spectrum_def.h"
-
-#ifdef CONFIG_STA_SUPPORT
#include "aironet.h"
-#endif // CONFIG_STA_SUPPORT //
//#define DBG_DIAGNOSE 1
-#if defined(CONFIG_AP_SUPPORT) && defined(CONFIG_STA_SUPPORT)
-#define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd) if(_pAd->OpMode == OPMODE_AP)
-#define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd) if(_pAd->OpMode == OPMODE_STA)
-#else
-#define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd)
-#define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd)
-#endif
-
#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
+#ifdef RT2870
+////////////////////////////////////////////////////////////////////////////
+// The TX_BUFFER structure forms the transmitted USB packet to the device
+////////////////////////////////////////////////////////////////////////////
+typedef struct __TX_BUFFER{
+ union {
+ UCHAR WirelessPacket[TX_BUFFER_NORMSIZE];
+ HEADER_802_11 NullFrame;
+ PSPOLL_FRAME PsPollPacket;
+ RTS_FRAME RTSFrame;
+ }field;
+ UCHAR Aggregation[4]; //Buffer for save Aggregation size.
+} TX_BUFFER, *PTX_BUFFER;
+
+typedef struct __HTTX_BUFFER{
+ union {
+ UCHAR WirelessPacket[MAX_TXBULK_SIZE];
+ HEADER_802_11 NullFrame;
+ PSPOLL_FRAME PsPollPacket;
+ RTS_FRAME RTSFrame;
+ }field;
+ UCHAR Aggregation[4]; //Buffer for save Aggregation size.
+} HTTX_BUFFER, *PHTTX_BUFFER;
+
+
+// used to track driver-generated write irps
+typedef struct _TX_CONTEXT
+{
+ PVOID pAd; //Initialized in MiniportInitialize
+ PURB pUrb; //Initialized in MiniportInitialize
+ PIRP pIrp; //used to cancel pending bulk out.
+ //Initialized in MiniportInitialize
+ PTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
+ ULONG BulkOutSize;
+ UCHAR BulkOutPipeId;
+ UCHAR SelfIdx;
+ BOOLEAN InUse;
+ BOOLEAN bWaitingBulkOut; // at least one packet is in this TxContext, ready for making IRP anytime.
+ BOOLEAN bFullForBulkOut; // all tx buffer are full , so waiting for tx bulkout.
+ BOOLEAN IRPPending;
+ BOOLEAN LastOne;
+ BOOLEAN bAggregatible;
+ UCHAR Header_802_3[LENGTH_802_3];
+ UCHAR Rsv[2];
+ ULONG DataOffset;
+ UINT TxRate;
+ dma_addr_t data_dma; // urb dma on linux
+
+} TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT;
+
+
+// used to track driver-generated write irps
+typedef struct _HT_TX_CONTEXT
+{
+ PVOID pAd; //Initialized in MiniportInitialize
+ PURB pUrb; //Initialized in MiniportInitialize
+ PIRP pIrp; //used to cancel pending bulk out.
+ //Initialized in MiniportInitialize
+ PHTTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
+ ULONG BulkOutSize; // Indicate the total bulk-out size in bytes in one bulk-transmission
+ UCHAR BulkOutPipeId;
+ BOOLEAN IRPPending;
+ BOOLEAN LastOne;
+ BOOLEAN bCurWriting;
+ BOOLEAN bRingEmpty;
+ BOOLEAN bCopySavePad;
+ UCHAR SavedPad[8];
+ UCHAR Header_802_3[LENGTH_802_3];
+ ULONG CurWritePosition; // Indicate the buffer offset which packet will be inserted start from.
+ ULONG CurWriteRealPos; // Indicate the buffer offset which packet now are writing to.
+ ULONG NextBulkOutPosition; // Indicate the buffer start offset of a bulk-transmission
+ ULONG ENextBulkOutPosition; // Indicate the buffer end offset of a bulk-transmission
+ UINT TxRate;
+ dma_addr_t data_dma; // urb dma on linux
+} HT_TX_CONTEXT, *PHT_TX_CONTEXT, **PPHT_TX_CONTEXT;
+
+
+//
+// Structure to keep track of receive packets and buffers to indicate
+// receive data to the protocol.
+//
+typedef struct _RX_CONTEXT
+{
+ PUCHAR TransferBuffer;
+ PVOID pAd;
+ PIRP pIrp;//used to cancel pending bulk in.
+ PURB pUrb;
+ //These 2 Boolean shouldn't both be 1 at the same time.
+ ULONG BulkInOffset; // number of packets waiting for reordering .
+ BOOLEAN bRxHandling; // Notify this packet is being process now.
+ BOOLEAN InUse; // USB Hardware Occupied. Wait for USB HW to put packet.
+ BOOLEAN Readable; // Receive Complete back. OK for driver to indicate receiving packet.
+ BOOLEAN IRPPending; // TODO: To be removed
+ atomic_t IrpLock;
+ NDIS_SPIN_LOCK RxContextLock;
+ dma_addr_t data_dma; // urb dma on linux
+} RX_CONTEXT, *PRX_CONTEXT;
+#endif // RT2870 //
//
@@ -136,14 +223,9 @@ extern UCHAR SsidIe;
extern UCHAR SupRateIe;
extern UCHAR ExtRateIe;
-#ifdef DOT11_N_SUPPORT
extern UCHAR HtCapIe;
extern UCHAR AddHtInfoIe;
extern UCHAR NewExtChanIe;
-#ifdef DOT11N_DRAFT3
-extern UCHAR ExtHtCapIe;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
extern UCHAR ErpIe;
extern UCHAR DsIe;
@@ -152,9 +234,15 @@ extern UCHAR WpaIe;
extern UCHAR Wpa2Ie;
extern UCHAR IbssIe;
extern UCHAR Ccx2Ie;
+#ifdef RT30xx
+extern UCHAR WapiIe;
+#endif
extern UCHAR WPA_OUI[];
extern UCHAR RSN_OUI[];
+#ifdef RT30xx
+extern UCHAR WAPI_OUI[];
+#endif
extern UCHAR WME_INFO_ELEM[];
extern UCHAR WME_PARM_ELEM[];
extern UCHAR Ccx2QosInfo[];
@@ -168,7 +256,6 @@ extern UCHAR RateSwitchTable11B[];
extern UCHAR RateSwitchTable11G[];
extern UCHAR RateSwitchTable11BG[];
-#ifdef DOT11_N_SUPPORT
extern UCHAR RateSwitchTable11BGN1S[];
extern UCHAR RateSwitchTable11BGN2S[];
extern UCHAR RateSwitchTable11BGN2SForABand[];
@@ -176,97 +263,10 @@ extern UCHAR RateSwitchTable11N1S[];
extern UCHAR RateSwitchTable11N2S[];
extern UCHAR RateSwitchTable11N2SForABand[];
-#ifdef CONFIG_STA_SUPPORT
extern UCHAR PRE_N_HT_OUI[];
-#endif // CONFIG_STA_SUPPORT //
-#endif // DOT11_N_SUPPORT //
#define MAXSEQ (0xFFF)
-#ifdef RALINK_ATE
-typedef struct _ATE_INFO {
- UCHAR Mode;
- CHAR TxPower0;
- CHAR TxPower1;
- CHAR TxAntennaSel;
- CHAR RxAntennaSel;
- TXWI_STRUC TxWI; // TXWI
- USHORT QID;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR Addr3[MAC_ADDR_LEN];
- UCHAR Channel;
- UINT32 TxLength;
- UINT32 TxCount;
- UINT32 TxDoneCount; // Tx DMA Done
- UINT32 RFFreqOffset;
- BOOLEAN bRxFer;
- BOOLEAN bQATxStart; // Have compiled QA in and use it to ATE tx.
- BOOLEAN bQARxStart; // Have compiled QA in and use it to ATE rx.
- BOOLEAN bFWLoading; // Reload firmware when ATE is done.
- UINT32 RxTotalCnt;
- UINT32 RxCntPerSec;
-
- CHAR LastSNR0; // last received SNR
- CHAR LastSNR1; // last received SNR for 2nd antenna
- CHAR LastRssi0; // last received RSSI
- CHAR LastRssi1; // last received RSSI for 2nd antenna
- CHAR LastRssi2; // last received RSSI for 3rd antenna
- CHAR AvgRssi0; // last 8 frames' average RSSI
- CHAR AvgRssi1; // last 8 frames' average RSSI
- CHAR AvgRssi2; // last 8 frames' average RSSI
- SHORT AvgRssi0X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi1X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi2X8; // sum of last 8 frames' RSSI
-
- UINT32 NumOfAvgRssiSample;
-
-#ifdef RALINK_28xx_QA
- // Tx frame
- USHORT HLen; // Header Length
- USHORT PLen; // Pattern Length
- UCHAR Header[32]; // Header buffer
- UCHAR Pattern[32]; // Pattern buffer
- USHORT DLen; // Data Length
- USHORT seq;
- UINT32 CID;
- THREAD_PID AtePid;
- // counters
- UINT32 U2M;
- UINT32 OtherData;
- UINT32 Beacon;
- UINT32 OtherCount;
- UINT32 TxAc0;
- UINT32 TxAc1;
- UINT32 TxAc2;
- UINT32 TxAc3;
- UINT32 TxHCCA;
- UINT32 TxMgmt;
- UINT32 RSSI0;
- UINT32 RSSI1;
- UINT32 RSSI2;
- UINT32 SNR0;
- UINT32 SNR1;
- // control
- //UINT32 Repeat; // Tx Cpu count
- UCHAR TxStatus; // task Tx status // 0 --> task is idle, 1 --> task is running
-#endif // RALINK_28xx_QA //
-} ATE_INFO, *PATE_INFO;
-
-#ifdef RALINK_28xx_QA
-struct ate_racfghdr {
- UINT32 magic_no;
- USHORT command_type;
- USHORT command_id;
- USHORT length;
- USHORT sequence;
- USHORT status;
- UCHAR data[2046];
-} __attribute__((packed));
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
struct reordering_mpdu
{
struct reordering_mpdu *next;
@@ -287,7 +287,6 @@ struct reordering_mpdu_pool
NDIS_SPIN_LOCK lock;
struct reordering_list freelist;
};
-#endif // DOT11_N_SUPPORT //
typedef struct _RSSI_SAMPLE {
CHAR LastRssi0; // last received RSSI
@@ -364,12 +363,14 @@ typedef struct _QUEUE_HEADER {
#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
+#ifdef RT2860
// Macro for power save flag.
#define RTMP_SET_PSFLAG(_M, _F) ((_M)->PSFlags |= (_F))
#define RTMP_CLEAR_PSFLAG(_M, _F) ((_M)->PSFlags &= ~(_F))
#define RTMP_CLEAR_PSFLAGS(_M) ((_M)->PSFlags = 0)
#define RTMP_TEST_PSFLAG(_M, _F) (((_M)->PSFlags & (_F)) != 0)
#define RTMP_TEST_PSFLAGS(_M, _F) (((_M)->PSFlags & (_F)) == (_F))
+#endif
#define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
#define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
@@ -383,14 +384,12 @@ typedef struct _QUEUE_HEADER {
#define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
#define RX_FILTER_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
-#ifdef CONFIG_STA_SUPPORT
#define STA_NO_SECURITY_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
#define STA_WEP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
#define STA_TKIP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
#define STA_AES_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
#define STA_TGN_WIFI_ON(_p) (_p->StaCfg.bTGnWifiTest == TRUE)
-#endif // CONFIG_STA_SUPPORT //
#define CKIP_KP_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
#define CKIP_CMIC_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
@@ -401,7 +400,17 @@ typedef struct _QUEUE_HEADER {
(_idx) = (_idx+1) % (_RingSize); \
}
+#ifdef RT30xx
+// We will have a cost down version which mac version is 0x3090xxxx
+#define IS_RT3090(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
+#endif
#define IS_RT3070(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
+#ifdef RT30xx
+#define IS_RT3071(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30710000)
+#define IS_RT2070(_pAd) (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27))
+
+#define IS_RT30xx(_pAd) (((_pAd)->MACVersion & 0xfff00000) == 0x30700000)
+#endif
#define RING_PACKET_INIT(_TxRing, _idx) \
{ \
@@ -437,7 +446,6 @@ typedef struct _QUEUE_HEADER {
} \
}
-#ifdef DOT11_N_SUPPORT
// StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here.
#define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
{ \
@@ -461,7 +469,6 @@ typedef struct _QUEUE_HEADER {
_pAd->MacTab.Content[BSSID_WCID].MmpsMode= (UCHAR)(_pHtCapability->HtCapInfo.MimoPs); \
_pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (UCHAR)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
}
-#endif // DOT11_N_SUPPORT //
//
// MACRO for 32-bit PCI register read / write
@@ -483,6 +490,7 @@ typedef struct _QUEUE_HEADER {
//
#define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register
//
+#ifdef RT2860
#define RTMP_RF_IO_WRITE32(_A, _V) \
{ \
PHY_CSR4_STRUC Value; \
@@ -646,7 +654,20 @@ typedef struct _QUEUE_HEADER {
} \
} \
}
+#endif /* RT2860 */
+#ifdef RT2870
+#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V)
+#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
+#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
+#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
+#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
+#endif // RT2870 //
+
+#ifdef RT30xx
+#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV) RT30xxReadRFRegister(_A, _I, _pV)
+#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V) RT30xxWriteRFRegister(_A, _I, _V)
+#endif // RT30xx //
#define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \
switch (ch) \
@@ -897,6 +918,7 @@ typedef struct _RTMP_SCATTER_GATHER_LIST {
// Enqueue this frame to MLME engine
// We need to enqueue the whole frame because MLME need to pass data type
// information from 802.11 header
+#ifdef RT2860
#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
{ \
UINT32 High32TSF, Low32TSF; \
@@ -904,6 +926,49 @@ typedef struct _RTMP_SCATTER_GATHER_LIST {
RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \
MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
}
+#endif
+#ifdef RT2870
+#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
+{ \
+ UINT32 High32TSF=0, Low32TSF=0; \
+ MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
+}
+#endif // RT2870 //
+
+#ifdef RT30xx
+//Need to collect each ant's rssi concurrently
+//rssi1 is report to pair2 Ant and rss2 is reprot to pair1 Ant when 4 Ant
+#define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _rssi1, _rssi2) \
+{ \
+ SHORT AvgRssi; \
+ UCHAR UsedAnt; \
+ if (_pAd->RxAnt.EvaluatePeriod == 0) \
+ { \
+ UsedAnt = _pAd->RxAnt.Pair1PrimaryRxAnt; \
+ AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \
+ if (AvgRssi < 0) \
+ AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \
+ else \
+ AvgRssi = _rssi1 << 3; \
+ _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \
+ } \
+ else \
+ { \
+ UsedAnt = _pAd->RxAnt.Pair1SecondaryRxAnt; \
+ AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \
+ if ((AvgRssi < 0) && (_pAd->RxAnt.FirstPktArrivedWhenEvaluate)) \
+ AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \
+ else \
+ { \
+ _pAd->RxAnt.FirstPktArrivedWhenEvaluate = TRUE; \
+ AvgRssi = _rssi1 << 3; \
+ } \
+ _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \
+ _pAd->RxAnt.RcvPktNumWhenEvaluate++; \
+ } \
+}
+#endif // RT30xx //
+
#define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \
NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen)
@@ -916,7 +981,7 @@ typedef struct _RTMP_SCATTER_GATHER_LIST {
//
#define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
-#ifdef CONFIG_STA_SUPPORT
+#ifdef RT2860
#define STA_PORT_SECURED(_pAd) \
{ \
_pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
@@ -925,8 +990,16 @@ typedef struct _RTMP_SCATTER_GATHER_LIST {
_pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
}
-#endif // CONFIG_STA_SUPPORT //
-
+#endif
+#ifdef RT2870
+#define STA_PORT_SECURED(_pAd) \
+{ \
+ _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
+ NdisAcquireSpinLock(&_pAd->MacTabLock); \
+ _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
+ NdisReleaseSpinLock(&_pAd->MacTabLock); \
+}
+#endif
//
// Register set pair for initialzation register set definition
@@ -975,17 +1048,10 @@ typedef struct _RTMP_DMABUF
typedef union _HEADER_802_11_SEQ{
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT Sequence:12;
- USHORT Frag:4;
- } field;
-#else
struct {
USHORT Frag:4;
USHORT Sequence:12;
} field;
-#endif
USHORT value;
} HEADER_802_11_SEQ, *PHEADER_802_11_SEQ;
@@ -1002,7 +1068,12 @@ typedef struct _RTMP_REORDERBUF
UCHAR DataOffset;
USHORT Datasize;
ULONG AllocSize;
+#ifdef RT2860
NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address
+#endif
+#ifdef RT2870
+ PUCHAR AllocPa;
+#endif // RT2870 //
} RTMP_REORDERBUF, *PRTMP_REORDERBUF;
//
@@ -1101,7 +1172,9 @@ typedef struct _COUNTER_802_11 {
typedef struct _COUNTER_RALINK {
ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput
+#ifdef RT2860
ULONG LastReceivedByteCount;
+#endif
ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput
ULONG BeenDisassociatedCount;
ULONG BadCQIAutoRecoveryCount;
@@ -1124,6 +1197,9 @@ typedef struct _COUNTER_RALINK {
UINT32 OneSecFrameDuplicateCount;
+#ifdef RT2870
+ ULONG OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput
+#endif // RT2870 //
UINT32 OneSecTxNoRetryOkCount;
UINT32 OneSecTxRetryOkCount;
@@ -1197,15 +1273,6 @@ typedef struct _ARCFOUR
// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI too. just copy to TXWI.
typedef struct _RECEIVE_SETTING {
-#ifdef RT_BIG_ENDIAN
- USHORT MIMO:1;
- USHORT OFDM:1;
- USHORT rsv:3;
- USHORT STBC:2; //SPACE
- USHORT ShortGI:1;
- USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
- USHORT NumOfRX:2; // MIMO. WE HAVE 3R
-#else
USHORT NumOfRX:2; // MIMO. WE HAVE 3R
USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
USHORT ShortGI:1;
@@ -1213,7 +1280,6 @@ typedef struct _RECEIVE_SETTING {
USHORT rsv:3;
USHORT OFDM:1;
USHORT MIMO:1;
-#endif
} RECEIVE_SETTING, *PRECEIVE_SETTING;
// Shared key data structure
@@ -1230,9 +1296,7 @@ typedef struct _CIPHER_KEY {
UCHAR RxTsc[6]; // 48bit TSC value
UCHAR CipherAlg; // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
UCHAR KeyLen;
-#ifdef CONFIG_STA_SUPPORT
UCHAR BssId[6];
-#endif // CONFIG_STA_SUPPORT //
// Key length for each key, 0: entry is invalid
UCHAR Type; // Indicate Pairwise/Group when reporting MIC error
} CIPHER_KEY, *PCIPHER_KEY;
@@ -1248,6 +1312,9 @@ typedef struct _BBP_TUNING_STRUCT {
typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
UCHAR EvaluatePeriod; // 0:not evalute status, 1: evaluate status, 2: switching status
+#ifdef RT30xx
+ UCHAR EvaluateStableCnt;
+#endif
UCHAR Pair1PrimaryRxAnt; // 0:Ant-E1, 1:Ant-E2
UCHAR Pair1SecondaryRxAnt; // 0:Ant-E1, 1:Ant-E2
UCHAR Pair2PrimaryRxAnt; // 0:Ant-E3, 1:Ant-E4
@@ -1368,9 +1435,6 @@ typedef struct _BBP_R66_TUNING {
typedef struct _CHANNEL_TX_POWER {
USHORT RemainingTimeForUse; //unit: sec
UCHAR Channel;
-#ifdef DOT11N_DRAFT3
- BOOLEAN bEffectedChannel; // For BW 40 operating in 2.4GHz , the "effected channel" is the channel that is covered in 40Mhz.
-#endif // DOT11N_DRAFT3 //
CHAR Power;
CHAR Power2;
UCHAR MaxTxPwr;
@@ -1393,7 +1457,6 @@ typedef enum _ABGBAND_STATE_ {
} ABGBAND_STATE;
typedef struct _MLME_STRUCT {
-#ifdef CONFIG_STA_SUPPORT
// STA state machines
STATE_MACHINE CntlMachine;
STATE_MACHINE AssocMachine;
@@ -1409,20 +1472,10 @@ typedef struct _MLME_STRUCT {
STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
STATE_MACHINE_FUNC WpaPskFunc[WPA_PSK_FUNC_SIZE];
STATE_MACHINE_FUNC AironetFunc[AIRONET_FUNC_SIZE];
-#endif // CONFIG_STA_SUPPORT //
STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
// Action
STATE_MACHINE ActMachine;
-
-#ifdef QOS_DLS_SUPPORT
- STATE_MACHINE DlsMachine;
- STATE_MACHINE_FUNC DlsFunc[DLS_FUNC_SIZE];
-#endif // QOS_DLS_SUPPORT //
-
-
-
-
ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
ULONG Now32; // latch the value of NdisGetSystemUpTime()
ULONG LastSendNULLpsmTime;
@@ -1437,9 +1490,11 @@ typedef struct _MLME_STRUCT {
RALINK_TIMER_STRUCT APSDPeriodicTimer;
RALINK_TIMER_STRUCT LinkDownTimer;
RALINK_TIMER_STRUCT LinkUpTimer;
+#ifdef RT2860
UCHAR bPsPollTimerRunning;
RALINK_TIMER_STRUCT PsPollTimer;
RALINK_TIMER_STRUCT RadioOnOffTimer;
+#endif
ULONG PeriodicRound;
ULONG OneSecPeriodicRound;
@@ -1448,7 +1503,10 @@ typedef struct _MLME_STRUCT {
BOOLEAN bEnableAutoAntennaCheck;
RALINK_TIMER_STRUCT RxAntEvalTimer;
-
+#ifdef RT2870
+ UCHAR CaliBW40RfR24;
+ UCHAR CaliBW20RfR24;
+#endif // RT2870 //
} MLME_STRUCT, *PMLME_STRUCT;
// structure for radar detection and channel switch
@@ -1471,23 +1529,6 @@ typedef struct _RADAR_DETECT_STRUCT {
UINT8 LongPulseRadarTh;
} RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
-#ifdef CARRIER_DETECTION_SUPPORT
-typedef enum CD_STATE_n
-{
- CD_NORMAL,
- CD_SILENCE,
- CD_MAX_STATE
-} CD_STATE;
-
-typedef struct CARRIER_DETECTION_s
-{
- BOOLEAN Enable;
- UINT8 CDSessionTime;
- UINT8 CDPeriod;
- CD_STATE CD_State;
-} CARRIER_DETECTION, *PCARRIER_DETECTION;
-#endif // CARRIER_DETECTION_SUPPORT //
-
typedef enum _REC_BLOCKACK_STATUS
{
Recipient_NONE=0,
@@ -1504,7 +1545,6 @@ typedef enum _ORI_BLOCKACK_STATUS
Originator_Done
} ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
-#ifdef DOT11_N_SUPPORT
typedef struct _BA_ORI_ENTRY{
UCHAR Wcid;
UCHAR TID;
@@ -1568,21 +1608,6 @@ typedef struct _QUERYBA_TABLE{
} QUERYBA_TABLE, *PQUERYBA_TABLE;
typedef union _BACAP_STRUC {
-#ifdef RT_BIG_ENDIAN
- struct {
- UINT32 :4;
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 MpduDensity:3;
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 AutoBA:1; // automatically BA
- UINT32 TxBAWinLimit:8;
- UINT32 RxBAWinLimit:8;
- } field;
-#else
struct {
UINT32 RxBAWinLimit:8;
UINT32 TxBAWinLimit:8;
@@ -1596,10 +1621,8 @@ typedef union _BACAP_STRUC {
UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
UINT32 :4;
} field;
-#endif
UINT32 word;
} BACAP_STRUC, *PBACAP_STRUC;
-#endif // DOT11_N_SUPPORT //
//This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic)
typedef struct _IOT_STRUC {
@@ -1614,30 +1637,15 @@ typedef struct _IOT_STRUC {
UCHAR RTSShortProt;
UCHAR RTSLongProt;
BOOLEAN bRTSLongProtOn;
-#ifdef CONFIG_STA_SUPPORT
BOOLEAN bLastAtheros;
BOOLEAN bCurrentAtheros;
BOOLEAN bNowAtherosBurstOn;
BOOLEAN bNextDisableRxBA;
BOOLEAN bToggle;
-#endif // CONFIG_STA_SUPPORT //
} IOT_STRUC, *PIOT_STRUC;
// This is the registry setting for 802.11n transmit setting. Used in advanced page.
typedef union _REG_TRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- UINT32 rsv:13;
- UINT32 EXTCHA:2;
- UINT32 HTMODE:1;
- UINT32 TRANSNO:2;
- UINT32 STBC:1; //SPACE
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 TxBF:1; // 3*3
- UINT32 rsv0:10;
- } field;
-#else
struct {
UINT32 rsv0:10;
UINT32 TxBF:1;
@@ -1649,26 +1657,16 @@ typedef union _REG_TRANSMIT_SETTING {
UINT32 EXTCHA:2;
UINT32 rsv:13;
} field;
-#endif
UINT32 word;
} REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
typedef union _DESIRED_TRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT rsv:3;
- USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
- USHORT PhyMode:4;
- USHORT MCS:7; // MCS
- } field;
-#else
struct {
USHORT MCS:7; // MCS
USHORT PhyMode:4;
USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
USHORT rsv:3;
} field;
-#endif
USHORT word;
} DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
@@ -1707,6 +1705,19 @@ typedef struct {
UCHAR bit_offset = wcid & 0x7; \
ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
+#ifdef RT2870
+#define BEACON_BITMAP_MASK 0xff
+typedef struct _BEACON_SYNC_STRUCT_
+{
+ UCHAR BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
+ UCHAR BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
+ ULONG TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
+ ULONG CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
+ BOOLEAN EnableBeacon; // trigger to enable beacon transmission.
+ UCHAR BeaconBitMap; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
+ UCHAR DtimBitOn; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
+}BEACON_SYNC_STRUCT;
+#endif // RT2870 //
typedef struct _MULTISSID_STRUCT {
UCHAR Bssid[MAC_ADDR_LEN];
@@ -1813,17 +1824,6 @@ typedef struct _MULTISSID_STRUCT {
UCHAR BcnBufIdx;
} MULTISSID_STRUCT, *PMULTISSID_STRUCT;
-
-
-#ifdef DOT11N_DRAFT3
-typedef enum _BSS2040COEXIST_FLAG{
- BSS_2040_COEXIST_DISABLE = 0,
- BSS_2040_COEXIST_TIMER_FIRED = 1,
- BSS_2040_COEXIST_INFO_SYNC = 2,
- BSS_2040_COEXIST_INFO_NOTIFY = 4,
-}BSS2040COEXIST_FLAG;
-#endif // DOT11N_DRAFT3 //
-
// configuration common to OPMODE_AP as well as OPMODE_STA
typedef struct _COMMON_CONFIG {
@@ -1886,10 +1886,9 @@ typedef struct _COMMON_CONFIG {
ULONG TxPowerPercentage; // 0~100 %
ULONG TxPowerDefault; // keep for TxPowerPercentage
-#ifdef DOT11_N_SUPPORT
BACAP_STRUC BACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
BACAP_STRUC REGBACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
-#endif // DOT11_N_SUPPORT //
+
IOT_STRUC IOTestParm; // 802.11n InterOpbility Test Parameter;
ULONG TxPreamble; // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto
BOOLEAN bUseZeroToDisableFragment; // Microsoft use 0 as disable
@@ -1901,17 +1900,14 @@ typedef struct _COMMON_CONFIG {
BOOLEAN bIEEE80211H; // 1: enable IEEE802.11h spec.
ULONG DisableOLBCDetect; // 0: enable OLBC detect; 1 disable OLBC detect
-#ifdef DOT11_N_SUPPORT
BOOLEAN bRdg;
-#endif // DOT11_N_SUPPORT //
+
BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
UCHAR AckPolicy[4]; // ACK policy of the specified AC. see ACK_xxx
-#ifdef CONFIG_STA_SUPPORT
BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
-#endif // CONFIG_STA_SUPPORT //
// a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
// BOOLEAN control, either ON or OFF. These flags should always be accessed via
// OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros.
@@ -1920,15 +1916,13 @@ typedef struct _COMMON_CONFIG {
BOOLEAN NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.
ABGBAND_STATE BandState; // For setting BBP used on B/G or A mode.
+#ifdef RT30xx
+ BOOLEAN bRxAntDiversity; // 0:disable, 1:enable Software Rx Antenna Diversity.
+#endif
// IEEE802.11H--DFS.
RADAR_DETECT_STRUCT RadarDetect;
-#ifdef CARRIER_DETECTION_SUPPORT
- CARRIER_DETECTION CarrierDetect;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
// HT
UCHAR BASize; // USer desired BAWindowSize. Should not exceed our max capability
//RT_HT_CAPABILITY SupportedHtPhy;
@@ -1939,33 +1933,6 @@ typedef struct _COMMON_CONFIG {
//This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp.
NEW_EXT_CHAN_IE NewExtChanOffset; //7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present
-#ifdef DOT11N_DRAFT3
- UCHAR Bss2040CoexistFlag; // bit 0: bBssCoexistTimerRunning, bit 1: NeedSyncAddHtInfo.
- RALINK_TIMER_STRUCT Bss2040CoexistTimer;
-
- //This IE is used for 20/40 BSS Coexistence.
- BSS_2040_COEXIST_IE BSS2040CoexistInfo;
- // ====== 11n D3.0 =======================>
- USHORT Dot11OBssScanPassiveDwell; // Unit : TU. 5~1000
- USHORT Dot11OBssScanActiveDwell; // Unit : TU. 10~1000
- USHORT Dot11BssWidthTriggerScanInt; // Unit : Second
- USHORT Dot11OBssScanPassiveTotalPerChannel; // Unit : TU. 200~10000
- USHORT Dot11OBssScanActiveTotalPerChannel; // Unit : TU. 20~10000
- USHORT Dot11BssWidthChanTranDelayFactor;
- USHORT Dot11OBssScanActivityThre; // Unit : percentage
-
- ULONG Dot11BssWidthChanTranDelay; // multiple of (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
- ULONG CountDownCtr; // CountDown Counter from (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
-
- NDIS_SPIN_LOCK TriggerEventTabLock;
- BSS_2040_COEXIST_IE LastBSSCoexist2040;
- BSS_2040_COEXIST_IE BSSCoexist2040;
- TRIGGER_EVENT_TAB TriggerEventTab;
- UCHAR ChannelListIdx;
- // <====== 11n D3.0 =======================
- BOOLEAN bOverlapScanning;
-#endif // DOT11N_DRAFT3 //
-
BOOLEAN bHTProtect;
BOOLEAN bMIMOPSEnable;
BOOLEAN bBADecline;
@@ -1976,7 +1943,6 @@ typedef struct _COMMON_CONFIG {
ULONG LastRcvBSSWidthTriggerEventsTime;
UCHAR TxBASize;
-#endif // DOT11_N_SUPPORT //
// Enable wireless event
BOOLEAN bWirelessEvent;
@@ -1994,6 +1960,20 @@ typedef struct _COMMON_CONFIG {
BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
+#ifdef RT2870
+ BOOLEAN bMultipleIRP; // Multiple Bulk IN flag
+ UCHAR NumOfBulkInIRP; // if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1
+ RT_HT_CAPABILITY SupportedHtPhy;
+ ULONG MaxPktOneTxBulk;
+ UCHAR TxBulkFactor;
+ UCHAR RxBulkFactor;
+
+ BEACON_SYNC_STRUCT *pBeaconSync;
+ RALINK_TIMER_STRUCT BeaconUpdateTimer;
+ UINT32 BeaconAdjust;
+ UINT32 BeaconFactor;
+ UINT32 BeaconRemain;
+#endif // RT2870 //
NDIS_SPIN_LOCK MeasureReqTabLock;
@@ -2006,16 +1986,8 @@ typedef struct _COMMON_CONFIG {
#ifdef MCAST_RATE_SPECIFIC
HTTRANSMIT_SETTING MCastPhyMode;
#endif // MCAST_RATE_SPECIFIC //
-
-#ifdef SINGLE_SKU
- UINT16 DefineMaxTxPwr;
-#endif // SINGLE_SKU //
-
-
} COMMON_CONFIG, *PCOMMON_CONFIG;
-
-#ifdef CONFIG_STA_SUPPORT
/* Modified by Wu Xi-Kun 4/21/2006 */
// STA configuration and status
typedef struct _STA_ADMIN_CONFIG {
@@ -2103,11 +2075,11 @@ typedef struct _STA_ADMIN_CONFIG {
BOOLEAN bRadio; // Radio state, And of Sw & Hw radio state
BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
BOOLEAN bShowHiddenSSID; // Show all known SSID in SSID list get operation
-
+#ifdef RT2860
BOOLEAN AdhocBOnlyJoined; // Indicate Adhoc B Join.
BOOLEAN AdhocBGJoined; // Indicate Adhoc B/G Join.
BOOLEAN Adhoc20NJoined; // Indicate Adhoc 20MHz N Join.
-
+#endif
// New for WPA, windows want us to to keep association information and
// Fixed IEs from last association response
NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
@@ -2189,10 +2161,6 @@ typedef struct _STA_ADMIN_CONFIG {
UCHAR DtimCount; // 0.. DtimPeriod-1
UCHAR DtimPeriod; // default = 3
-#ifdef QOS_DLS_SUPPORT
- RT_802_11_DLS DLSEntry[MAX_NUM_OF_DLS_ENTRY];
- UCHAR DlsReplayCounter[8];
-#endif // QOS_DLS_SUPPORT //
////////////////////////////////////////////////////////////////////////////////////////
// This is only for WHQL test.
BOOLEAN WhqlTest;
@@ -2203,7 +2171,6 @@ typedef struct _STA_ADMIN_CONFIG {
BOOLEAN bFastRoaming; // 0:disable fast roaming, 1:enable fast roaming
CHAR dBmToRoam; // the condition to roam when receiving Rssi less than this value. It's negative value.
-#ifdef WPA_SUPPLICANT_SUPPORT
BOOLEAN IEEE8021X;
BOOLEAN IEEE8021x_required_keys;
CIPHER_KEY DesireSharedKey[4]; // Record user desired WEP keys
@@ -2214,7 +2181,6 @@ typedef struct _STA_ADMIN_CONFIG {
// 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters
UCHAR WpaSupplicantUP;
UCHAR WpaSupplicantScanCount;
-#endif // WPA_SUPPLICANT_SUPPORT //
CHAR dev_name[16];
USHORT OriDevType;
@@ -2227,13 +2193,9 @@ typedef struct _STA_ADMIN_CONFIG {
RT_HT_PHY_INFO DesiredHtPhyInfo;
BOOLEAN bAutoTxRateSwitch;
+#ifdef RT2860
UCHAR BBPR3;
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- UCHAR IEEE80211dClientMode;
- UCHAR StaOriCountryCode[3];
- UCHAR StaOriGeography;
-#endif // EXT_BUILD_CHANNEL_LIST //
+#endif
} STA_ADMIN_CONFIG, *PSTA_ADMIN_CONFIG;
// This data structure keep the current active BSS/IBSS's configuration that this STA
@@ -2259,7 +2221,15 @@ typedef struct _STA_ACTIVE_CONFIG {
RT_HT_PHY_INFO SupportedPhyInfo;
RT_HT_CAPABILITY SupportedHtPhy;
} STA_ACTIVE_CONFIG, *PSTA_ACTIVE_CONFIG;
-#endif // CONFIG_STA_SUPPORT //
+
+#ifdef RT2870
+// for USB interface, avoid in interrupt when write key
+typedef struct RT_ADD_PAIRWISE_KEY_ENTRY {
+ NDIS_802_11_MAC_ADDRESS MacAddr;
+ USHORT MacTabMatchWCID; // ASIC
+ CIPHER_KEY CipherKey;
+} RT_ADD_PAIRWISE_KEY_ENTRY,*PRT_ADD_PAIRWISE_KEY_ENTRY;
+#endif // RT2870 //
// ----------- start of AP --------------------------
// AUTH-RSP State Machine Aux data structure
@@ -2325,14 +2295,11 @@ typedef struct _MAC_TABLE_ENTRY {
UINT32 StaConnectTime; // the live time of this station since associated with AP
-
-#ifdef DOT11_N_SUPPORT
BOOLEAN bSendBAR;
USHORT NoBADataCountDown;
UINT32 CachedBuf[16]; // UINT (4 bytes) for alignment
UINT TxBFCount; // 3*3
-#endif // DOT11_N_SUPPORT //
UINT FIFOCount;
UINT DebugFIFOCount;
UINT DebugTxCount;
@@ -2356,14 +2323,6 @@ typedef struct _MAC_TABLE_ENTRY {
UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
//====================================================
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- UINT MatchDlsEntryIdx; // indicate the index in pAd->StaCfg.DLSEntry
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
BOOLEAN fNoisyEnvironment;
BOOLEAN fLastSecAccordingRSSI;
UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
@@ -2377,10 +2336,8 @@ typedef struct _MAC_TABLE_ENTRY {
// see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED
ULONG ClientStatusFlags;
- // TODO: Shall we move that to DOT11_N_SUPPORT???
HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-#ifdef DOT11_N_SUPPORT
// HT EWC MIMO-N used parameters
USHORT RXBAbitmap; // fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format
USHORT TXBAbitmap; // This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI
@@ -2398,11 +2355,6 @@ typedef struct _MAC_TABLE_ENTRY {
HT_CAPABILITY_IE HTCapability;
-#ifdef DOT11N_DRAFT3
- UCHAR BSS2040CoexistenceMgmtSupport;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
BOOLEAN bAutoTxRateSwitch;
UCHAR RateLen;
@@ -2416,6 +2368,9 @@ typedef struct _MAC_TABLE_ENTRY {
UINT32 TXMCSSuccessful[16];
UINT32 TXMCSFailed[16];
UINT32 TXMCSAutoFallBack[16][16];
+#ifdef RT2870
+ ULONG LastBeaconRxTime;
+#endif
} MAC_TABLE_ENTRY, *PMAC_TABLE_ENTRY;
typedef struct _MAC_TABLE {
@@ -2427,16 +2382,16 @@ typedef struct _MAC_TABLE {
BOOLEAN fAnyStationInPsm;
BOOLEAN fAnyStationBadAtheros; // Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip.
BOOLEAN fAnyTxOPForceDisable; // Check if it is necessary to disable BE TxOP
-#ifdef DOT11_N_SUPPORT
+#ifdef RT2870
+ BOOLEAN fAllStationAsRalink; // Check if all stations are ralink-chipset
+#endif
BOOLEAN fAnyStationIsLegacy; // Check if I use legacy rate to transmit to my BSS Station/
BOOLEAN fAnyStationNonGF; // Check if any Station can't support GF.
BOOLEAN fAnyStation20Only; // Check if any Station can't support GF.
BOOLEAN fAnyStationMIMOPSDynamic; // Check if any Station is MIMO Dynamic
BOOLEAN fAnyBASession; // Check if there is BA session. Force turn on RTS/CTS
-#endif // DOT11_N_SUPPORT //
} MAC_TABLE, *PMAC_TABLE;
-#ifdef DOT11_N_SUPPORT
#define IS_HT_STA(_pMacEntry) \
(_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
@@ -2445,7 +2400,6 @@ typedef struct _MAC_TABLE {
#define PEER_IS_HT_RATE(_pMacEntry) \
(_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-#endif // DOT11_N_SUPPORT //
typedef struct _WDS_ENTRY {
BOOLEAN Valid;
@@ -2549,10 +2503,6 @@ typedef struct _APCLI_STRUCT {
UCHAR SNonce[32]; // SNonce for WPA-PSK
UCHAR GNonce[32]; // GNonce for WPA-PSK from authenticator
-#ifdef WSC_AP_SUPPORT
- WSC_CTRL WscControl;
-#endif // WSC_AP_SUPPORT //
-
HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
RT_HT_PHY_INFO DesiredHtPhyInfo;
BOOLEAN bAutoTxRateSwitch;
@@ -2561,14 +2511,6 @@ typedef struct _APCLI_STRUCT {
// ----------- end of AP ----------------------------
-#ifdef BLOCK_NET_IF
-typedef struct _BLOCK_QUEUE_ENTRY
-{
- BOOLEAN SwTxQueueBlockFlag;
- LIST_HEADER NetIfList;
-} BLOCK_QUEUE_ENTRY, *PBLOCK_QUEUE_ENTRY;
-#endif // BLOCK_NET_IF //
-
struct wificonf
{
BOOLEAN bShortGI;
@@ -2600,28 +2542,6 @@ typedef struct _INF_USB_CONFIG
};
#endif // IKANOS_VX_1X0 //
-#ifdef NINTENDO_AP
-typedef struct _NINDO_CTRL_BLOCK {
-
- RT_NINTENDO_TABLE DS_TABLE;
-
-#ifdef CHIP25XX
- spinlock_t NINTENDO_TABLE_Lock;
-#else
- NDIS_SPIN_LOCK NINTENDO_TABLE_Lock;
-#endif // CHIP25XX //
-
- UCHAR NINTENDO_UP_BUFFER[512];
- UCHAR Local_KeyIdx;
- CIPHER_KEY Local_SharedKey;
- UCHAR Local_bHideSsid;
- UCHAR Local_AuthMode;
- UCHAR Local_WepStatus;
- USHORT Local_CapabilityInfo;
-} NINDO_CTRL_BLOCK;
-#endif // NINTENDO_AP //
-
-
#ifdef DBG_DIAGNOSE
#define DIAGNOSE_TIME 10 // 10 sec
typedef struct _RtmpDiagStrcut_
@@ -2660,6 +2580,7 @@ typedef struct _RTMP_ADAPTER
PNET_DEV net_dev;
ULONG VirtualIfCnt;
+#ifdef RT2860
USHORT LnkCtrlBitMask;
USHORT RLnkCtrlConfiguration;
USHORT RLnkCtrlOffset;
@@ -2686,11 +2607,51 @@ typedef struct _RTMP_ADAPTER
RTMP_DMABUF RxDescRing; // Shared memory for RX descriptors
RTMP_DMABUF TxDescRing[NUM_OF_TX_RING]; // Shared memory for Tx descriptors
RTMP_TX_RING TxRing[NUM_OF_TX_RING]; // AC0~4 + HCCA
-
+#endif
NDIS_SPIN_LOCK irq_lock;
UCHAR irq_disabled;
+#ifdef RT2870
+/*****************************************************************************************/
+/* USB related parameters */
+/*****************************************************************************************/
+ struct usb_config_descriptor *config;
+ UINT BulkInEpAddr; // bulk-in endpoint address
+ UINT BulkOutEpAddr[6]; // bulk-out endpoint address
+
+ UINT NumberOfPipes;
+ USHORT BulkOutMaxPacketSize;
+ USHORT BulkInMaxPacketSize;
+
+ //======Control Flags
+ LONG PendingIoCount;
+ ULONG BulkFlags;
+ BOOLEAN bUsbTxBulkAggre; // Flags for bulk out data priority
+
+
+ //======Timer Thread
+ RT2870_TIMER_QUEUE TimerQ;
+ NDIS_SPIN_LOCK TimerQLock;
+
+
+ //======Cmd Thread
+ CmdQ CmdQ;
+ NDIS_SPIN_LOCK CmdQLock; // CmdQLock spinlock
+
+ BOOLEAN TimerFunc_kill;
+ BOOLEAN mlme_kill;
+
+
+ //======Semaphores (event)
+ struct semaphore mlme_semaphore; /* to sleep thread on */
+ struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */
+ struct semaphore RTUSBTimer_semaphore;
+ struct completion TimerQComplete;
+ struct completion mlmeComplete;
+ struct completion CmdQComplete;
+ wait_queue_head_t *wait;
+#endif // RT2870 //
/*****************************************************************************************/
@@ -2704,6 +2665,22 @@ typedef struct _RTMP_ADAPTER
BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; // for ensuring RTUSBDeQueuePacket get call once
NDIS_SPIN_LOCK DeQueueLock[NUM_OF_TX_RING];
+#ifdef RT2870
+ // Data related context and AC specified, 4 AC supported
+ NDIS_SPIN_LOCK BulkOutLock[6]; // BulkOut spinlock for 4 ACs
+ NDIS_SPIN_LOCK MLMEBulkOutLock; // MLME BulkOut lock
+
+ HT_TX_CONTEXT TxContext[NUM_OF_TX_RING];
+ NDIS_SPIN_LOCK TxContextQueueLock[NUM_OF_TX_RING]; // TxContextQueue spinlock
+
+ // 4 sets of Bulk Out index and pending flag
+ UCHAR NextBulkOutIndex[4]; // only used for 4 EDCA bulkout pipe
+
+ BOOLEAN BulkOutPending[6]; // used for total 6 bulkout pipe
+ UCHAR bulkResetPipeid;
+ BOOLEAN MgmtBulkPending;
+ ULONG bulkResetReq[6];
+#endif // RT2870 //
// resource for software backlog queues
QUEUE_HEADER TxSwQueue[NUM_OF_TX_RING]; // 4 AC + 1 HCCA
@@ -2717,10 +2694,20 @@ typedef struct _RTMP_ADAPTER
/*****************************************************************************************/
/* Rx related parameters */
/*****************************************************************************************/
-
+#ifdef RT2860
RTMP_RX_RING RxRing;
NDIS_SPIN_LOCK RxRingLock; // Rx Ring spinlock
-
+#endif
+#ifdef RT2870
+ RX_CONTEXT RxContext[RX_RING_SIZE]; // 1 for redundant multiple IRP bulk in.
+ NDIS_SPIN_LOCK BulkInLock; // BulkIn spinlock for 4 ACs
+ UCHAR PendingRx; // The Maxima pending Rx value should be RX_RING_SIZE.
+ UCHAR NextRxBulkInIndex; // Indicate the current RxContext Index which hold by Host controller.
+ UCHAR NextRxBulkInReadIndex; // Indicate the current RxContext Index which driver can read & process it.
+ ULONG NextRxBulkInPosition; // Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength.
+ ULONG TransferBufferLength; // current length of the packet buffer
+ ULONG ReadPosition; // current read position in a packet buffer
+#endif // RT2870 //
/*****************************************************************************************/
@@ -2734,6 +2721,10 @@ typedef struct _RTMP_ADAPTER
ULONG EepromVersion; // byte 0: version, byte 1: revision, byte 2~3: unused
UCHAR EEPROMAddressNum; // 93c46=6 93c66=8
USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
+#ifdef RT30xx
+ BOOLEAN EepromAccess;
+ UCHAR EFuseTag;
+#endif
ULONG FirmwareVersion; // byte 0: Minor version, byte 1: Major version, otherwise unused.
// ---------------------------
@@ -2826,11 +2817,19 @@ typedef struct _RTMP_ADAPTER
PSPOLL_FRAME PsPollFrame;
HEADER_802_11 NullFrame;
+#ifdef RT2870
+ TX_CONTEXT BeaconContext[BEACON_RING_SIZE];
+ TX_CONTEXT NullContext;
+ TX_CONTEXT PsPollContext;
+ TX_CONTEXT RTSContext;
+#endif // RT2870 //
+
+
+
//=========AP===========
//=======STA===========
-#ifdef CONFIG_STA_SUPPORT
/* Modified by Wu Xi-Kun 4/21/2006 */
// -----------------------------------------------
// STA specific configuration & operation status
@@ -2840,7 +2839,6 @@ typedef struct _RTMP_ADAPTER
STA_ACTIVE_CONFIG StaActive; // valid only when ADHOC_ON(pAd) || INFRA_ON(pAd)
CHAR nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
NDIS_MEDIA_STATE PreMediaState;
-#endif // CONFIG_STA_SUPPORT //
//=======Common===========
// OP mode: either AP or STA
@@ -2848,7 +2846,6 @@ typedef struct _RTMP_ADAPTER
NDIS_MEDIA_STATE IndicateMediaState; // Base on Indication state, default is NdisMediaStateDisConnected
- // MAT related parameters
// configuration: read from Registry & E2PROM
BOOLEAN bLocalAdminMAC; // Use user changed MAC
@@ -2869,9 +2866,8 @@ typedef struct _RTMP_ADAPTER
MAC_TABLE MacTab; // ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table.
NDIS_SPIN_LOCK MacTabLock;
-#ifdef DOT11_N_SUPPORT
BA_TABLE BATable;
-#endif // DOT11_N_SUPPORT //
+
NDIS_SPIN_LOCK BATabLock;
RALINK_TIMER_STRUCT RECBATimer;
@@ -2890,16 +2886,13 @@ typedef struct _RTMP_ADAPTER
// flags, see fRTMP_ADAPTER_xxx flags
ULONG Flags; // Represent current device status
+#ifdef RT2860
ULONG PSFlags; // Power Save operation flag.
+#endif
// current TX sequence #
USHORT Sequence;
-#ifdef UNDER_CE
- NDIS_HANDLE hGiISR;
-#endif
-
-
// Control disconnect / connect event generation
//+++Didn't used anymore
ULONG LinkDownTime;
@@ -2928,6 +2921,14 @@ typedef struct _RTMP_ADAPTER
/*****************************************************************************************/
/* Statistic related parameters */
/*****************************************************************************************/
+#ifdef RT2870
+ ULONG BulkOutDataOneSecCount;
+ ULONG BulkInDataOneSecCount;
+ ULONG BulkLastOneSecCount; // BulkOutDataOneSecCount + BulkInDataOneSecCount
+ ULONG watchDogRxCnt;
+ ULONG watchDogRxOverFlowCnt;
+ ULONG watchDogTxPendingCnt[NUM_OF_TX_RING];
+#endif // RT2870 //
BOOLEAN bUpdateBcnCntDone;
ULONG watchDogMacDeadlock; // prevent MAC/BBP into deadlock condition
@@ -2967,13 +2968,7 @@ typedef struct _RTMP_ADAPTER
struct wificonf WIFItestbed;
-#ifdef RALINK_ATE
- ATE_INFO ate;
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
struct reordering_mpdu_pool mpdu_blk_pool;
-#endif // DOT11_N_SUPPORT //
ULONG OneSecondnonBEpackets; // record non BE packets per second
@@ -2983,17 +2978,6 @@ typedef struct _RTMP_ADAPTER
struct net_device_stats stats;
-#ifdef BLOCK_NET_IF
- BLOCK_QUEUE_ENTRY blockQueueTab[NUM_OF_TX_RING];
-#endif // BLOCK_NET_IF //
-
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
- INT32 MC_RowID;
- UCHAR MC_FileName[256];
-#endif // MULTIPLE_CARD_SUPPORT //
-
ULONG TbttTickCount;
#ifdef PCI_MSI_SUPPORT
BOOLEAN HaveMsi;
@@ -3007,11 +2991,6 @@ typedef struct _RTMP_ADAPTER
UCHAR flg_be_adjust;
ULONG be_adjust_last_time;
-#ifdef NINTENDO_AP
- NINDO_CTRL_BLOCK nindo_ctrl_block;
-#endif // NINTENDO_AP //
-
-
#ifdef IKANOS_VX_1X0
struct IKANOS_TX_INFO IkanosTxInfo;
struct IKANOS_TX_INFO IkanosRxInfo[MAX_MBSSID_NUM + MAX_WDS_ENTRY + MAX_APCLI_NUM + MAX_MESH_NUM];
@@ -3024,6 +3003,13 @@ typedef struct _RTMP_ADAPTER
UINT8 PM_FlgSuspend;
+
+#ifdef RT30xx
+//======efuse
+ BOOLEAN bUseEfuse;
+ BOOLEAN bEEPROMFile;
+#endif // RT30xx //
+
} RTMP_ADAPTER, *PRTMP_ADAPTER;
//
@@ -3176,7 +3162,7 @@ typedef struct _TX_BLK_
//------------------------------------------------------------------------------------------
-
+#ifdef RT2860
//
// Enable & Disable NIC interrupt via writing interrupt mask register
// Since it use ADAPTER structure, it have to be put after structure definition.
@@ -3210,243 +3196,6 @@ __inline VOID NICEnableInterrupt(
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
}
-#ifdef RT_BIG_ENDIAN
-static inline VOID WriteBackToDescriptor(
- IN PUCHAR Dest,
- IN PUCHAR Src,
- IN BOOLEAN DoEncrypt,
- IN ULONG DescriptorType)
-{
- UINT32 *p1, *p2;
-
- p1 = ((UINT32 *)Dest);
- p2 = ((UINT32 *)Src);
-
- *p1 = *p2;
- *(p1+2) = *(p2+2);
- *(p1+3) = *(p2+3);
- *(p1+1) = *(p2+1); // Word 1; this must be written back last
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of Tx/Rx descriptor .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to Tx/Rx descriptor
- DescriptorType Direction of the frame
-
- Return Value:
- None
-
- Note:
- Call this function when read or update descriptor
- ========================================================================
-*/
-static inline VOID RTMPWIEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType)
-{
- int size;
- int i;
-
- size = ((DescriptorType == TYPE_TXWI) ? TXWI_SIZE : RXWI_SIZE);
-
- if(DescriptorType == TYPE_TXWI)
- {
- *((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData))); // Byte 0~3
- *((UINT32 *)(pData + 4)) = SWAP32(*((UINT32 *)(pData+4))); // Byte 4~7
- }
- else
- {
- for(i=0; i < size/4 ; i++)
- *(((UINT32 *)pData) +i) = SWAP32(*(((UINT32 *)pData)+i));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of Tx/Rx descriptor .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to Tx/Rx descriptor
- DescriptorType Direction of the frame
-
- Return Value:
- None
-
- Note:
- Call this function when read or update descriptor
- ========================================================================
-*/
-static inline VOID RTMPDescriptorEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType)
-{
- *((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData))); // Byte 0~3
- *((UINT32 *)(pData + 8)) = SWAP32(*((UINT32 *)(pData+8))); // Byte 8~11
- *((UINT32 *)(pData +12)) = SWAP32(*((UINT32 *)(pData + 12))); // Byte 12~15
- *((UINT32 *)(pData + 4)) = SWAP32(*((UINT32 *)(pData + 4))); // Byte 4~7, this must be swapped last
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of all kinds of 802.11 frames .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to the 802.11 frame structure
- Dir Direction of the frame
- FromRxDoneInt Caller is from RxDone interrupt
-
- Return Value:
- None
-
- Note:
- Call this function when read or update buffer data
- ========================================================================
-*/
-static inline VOID RTMPFrameEndianChange(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG Dir,
- IN BOOLEAN FromRxDoneInt)
-{
- PHEADER_802_11 pFrame;
- PUCHAR pMacHdr;
-
- // swab 16 bit fields - Frame Control field
- if(Dir == DIR_READ)
- {
- *(USHORT *)pData = SWAP16(*(USHORT *)pData);
- }
-
- pFrame = (PHEADER_802_11) pData;
- pMacHdr = (PUCHAR) pFrame;
-
- // swab 16 bit fields - Duration/ID field
- *(USHORT *)(pMacHdr + 2) = SWAP16(*(USHORT *)(pMacHdr + 2));
-
- // swab 16 bit fields - Sequence Control field
- *(USHORT *)(pMacHdr + 22) = SWAP16(*(USHORT *)(pMacHdr + 22));
-
- if(pFrame->FC.Type == BTYPE_MGMT)
- {
- switch(pFrame->FC.SubType)
- {
- case SUBTYPE_ASSOC_REQ:
- case SUBTYPE_REASSOC_REQ:
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Listen Interval field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_ASSOC_RSP:
- case SUBTYPE_REASSOC_RSP:
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Status Code field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - AID field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_AUTH:
- // If from APHandleRxDoneInterrupt routine, it is still a encrypt format.
- // The convertion is delayed to RTMPHandleDecryptionDoneInterrupt.
- if(!FromRxDoneInt && pFrame->FC.Wep == 1)
- break;
- else
- {
- // swab 16 bit fields - Auth Alg No. field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Auth Seq No. field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Status Code field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- }
- break;
-
- case SUBTYPE_BEACON:
- case SUBTYPE_PROBE_RSP:
- // swab 16 bit fields - BeaconInterval field
- pMacHdr += (sizeof(HEADER_802_11) + TIMESTAMP_LEN);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(USHORT);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_DEAUTH:
- case SUBTYPE_DISASSOC:
- // swab 16 bit fields - Reason code field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
- }
- }
- else if( pFrame->FC.Type == BTYPE_DATA )
- {
- }
- else if(pFrame->FC.Type == BTYPE_CNTL)
- {
- switch(pFrame->FC.SubType)
- {
- case SUBTYPE_BLOCK_ACK_REQ:
- {
- PFRAME_BA_REQ pBAReq = (PFRAME_BA_REQ)pFrame;
- *(USHORT *)(&pBAReq->BARControl) = SWAP16(*(USHORT *)(&pBAReq->BARControl));
- pBAReq->BAStartingSeq.word = SWAP16(pBAReq->BAStartingSeq.word);
- }
- break;
- case SUBTYPE_BLOCK_ACK:
- // For Block Ack packet, the HT_CONTROL field is in the same offset with Addr3
- *(UINT32 *)(&pFrame->Addr3[0]) = SWAP32(*(UINT32 *)(&pFrame->Addr3[0]));
- break;
-
- case SUBTYPE_ACK:
- //For ACK packet, the HT_CONTROL field is in the same offset with Addr2
- *(UINT32 *)(&pFrame->Addr2[0])= SWAP32(*(UINT32 *)(&pFrame->Addr2[0]));
- break;
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,("Invalid Frame Type!!!\n"));
- }
-
- // swab 16 bit fields - Frame Control
- if(Dir == DIR_WRITE)
- {
- *(USHORT *)pData = SWAP16(*(USHORT *)pData);
- }
-}
-#endif // RT_BIG_ENDIAN //
-
-
static inline VOID ConvertMulticastIP2MAC(
IN PUCHAR pIpAddr,
IN PUCHAR *ppMacAddr,
@@ -3484,6 +3233,7 @@ static inline VOID ConvertMulticastIP2MAC(
return;
}
+#endif /* RT2860 */
BOOLEAN RTMPCheckForHang(
IN NDIS_HANDLE MiniportAdapterContext
@@ -3523,6 +3273,10 @@ NDIS_STATUS NICReadRegParameters(
IN NDIS_HANDLE WrapperConfigurationContext
);
+#ifdef RT2870
+VOID NICInitRT30xxRFRegisters(
+ IN PRTMP_ADAPTER pAd);
+#endif // RT2870 //
VOID NICReadEEPROMParameters(
IN PRTMP_ADAPTER pAd,
@@ -3541,10 +3295,10 @@ NDIS_STATUS NICInitializeAdapter(
NDIS_STATUS NICInitializeAsic(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN bHardReset);
-
+#ifdef RT2860
VOID NICRestoreBBPValue(
IN PRTMP_ADAPTER pAd);
-
+#endif
VOID NICIssueReset(
IN PRTMP_ADAPTER pAd);
@@ -3691,7 +3445,6 @@ VOID MlmeQOSAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#ifdef DOT11_N_SUPPORT
VOID PeerAddBAReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
@@ -3707,53 +3460,12 @@ VOID PeerDelBAAction(
VOID PeerBAAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#endif // DOT11_N_SUPPORT //
VOID SendPSMPAction(
IN PRTMP_ADAPTER pAd,
IN UCHAR Wcid,
IN UCHAR Psmp);
-
-#ifdef DOT11N_DRAFT3
-VOID SendBSS2040CoexistMgmtAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx,
- IN UCHAR InfoReq);
-
-VOID SendNotifyBWActionFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx);
-
-BOOLEAN ChannelSwitchSanityCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary);
-
-VOID ChannelSwitchAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Channel,
- IN UCHAR Secondary);
-
-ULONG BuildIntolerantChannelRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest);
-
-VOID Update2040CoexistFrameAndNotify(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha);
-
-VOID Send2040CoexistAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha);
-#endif // DOT11N_DRAFT3 //
-
VOID PeerRMAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
@@ -3762,44 +3474,22 @@ VOID PeerPublicAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#ifdef CONFIG_STA_SUPPORT
VOID StaPublicAction(
IN PRTMP_ADAPTER pAd,
IN UCHAR Bss2040Coexist);
-#endif // CONFIG_STA_SUPPORT //
-
VOID PeerBSSTranAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#ifdef DOT11_N_SUPPORT
VOID PeerHTAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#endif // DOT11_N_SUPPORT //
VOID PeerQOSAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#ifdef QOS_DLS_SUPPORT
-VOID PeerDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-VOID DlsParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
- IN PRT_802_11_DLS pDls,
- IN USHORT reason);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
VOID RECBATimerTimeout(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
@@ -3812,7 +3502,6 @@ VOID ORIBATimerTimeout(
VOID SendRefreshBAR(
IN PRTMP_ADAPTER pAd,
IN MAC_TABLE_ENTRY *pEntry);
-#endif // DOT11_N_SUPPORT //
VOID ActHeaderInit(
IN PRTMP_ADAPTER pAd,
@@ -3845,7 +3534,6 @@ BOOLEAN QosBADataParse(
IN USHORT Datasize,
IN UINT CurRxIndex);
-#ifdef DOT11_N_SUPPORT
BOOLEAN CntlEnqueueForRecv(
IN PRTMP_ADAPTER pAd,
IN ULONG Wcid,
@@ -3854,7 +3542,6 @@ BOOLEAN CntlEnqueueForRecv(
VOID BaAutoManSwitch(
IN PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
VOID HTIOTCheck(
IN PRTMP_ADAPTER pAd,
@@ -4010,7 +3697,13 @@ NDIS_STATUS MiniportMMRequest(
IN UCHAR QueIdx,
IN PUCHAR pData,
IN UINT Length);
-
+#ifdef RT2870
+NDIS_STATUS MiniportDataMMRequest(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PUCHAR pData,
+ IN UINT Length);
+#endif
VOID RTMPSendNullFrame(
IN PRTMP_ADAPTER pAd,
IN UCHAR TxRate,
@@ -4039,7 +3732,6 @@ PQUEUE_HEADER RTMPCheckTxSwQueue(
IN PRTMP_ADAPTER pAd,
OUT UCHAR *QueIdx);
-#ifdef CONFIG_STA_SUPPORT
VOID RTMPReportMicError(
IN PRTMP_ADAPTER pAd,
IN PCIPHER_KEY pWpaKey);
@@ -4053,7 +3745,6 @@ VOID WpaDisassocApAndBlockAssoc(
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
-#endif // CONFIG_STA_SUPPORT //
NDIS_STATUS RTMPCloneNdisPacket(
IN PRTMP_ADAPTER pAd,
@@ -4193,7 +3884,6 @@ VOID AsicRfTuningExec(
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
-#ifdef CONFIG_STA_SUPPORT
VOID AsicSleepThenAutoWakeup(
IN PRTMP_ADAPTER pAd,
IN USHORT TbttNumToNextWakeUp);
@@ -4203,8 +3893,12 @@ VOID AsicForceSleep(
VOID AsicForceWakeup(
IN PRTMP_ADAPTER pAd,
+#ifdef RT2860
IN UCHAR Level);
-#endif // CONFIG_STA_SUPPORT //
+#endif
+#ifdef RT2870
+ IN BOOLEAN bFromTx);
+#endif
VOID AsicSetBssid(
IN PRTMP_ADAPTER pAd,
@@ -4298,11 +3992,11 @@ BOOLEAN AsicSendCommandToMcu(
IN UCHAR Token,
IN UCHAR Arg0,
IN UCHAR Arg1);
-
+#ifdef RT2860
BOOLEAN AsicCheckCommanOk(
IN PRTMP_ADAPTER pAd,
IN UCHAR Command);
-
+#endif
VOID MacAddrRandomBssid(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pAddr);
@@ -4325,11 +4019,9 @@ VOID MlmeRadioOn(
VOID BssTableInit(
IN BSS_TABLE *Tab);
-#ifdef DOT11_N_SUPPORT
VOID BATableInit(
IN PRTMP_ADAPTER pAd,
IN BA_TABLE *Tab);
-#endif // DOT11_N_SUPPORT //
ULONG BssTableSearch(
IN BSS_TABLE *Tab,
@@ -4355,7 +4047,6 @@ VOID BssTableDeleteEntry(
IN PUCHAR pBssid,
IN UCHAR Channel);
-#ifdef DOT11_N_SUPPORT
VOID BATableDeleteORIEntry(
IN OUT PRTMP_ADAPTER pAd,
IN BA_ORI_ENTRY *pBAORIEntry);
@@ -4376,7 +4067,6 @@ VOID BATableTearRECEntry(
IN UCHAR TID,
IN UCHAR WCID,
IN BOOLEAN ALL);
-#endif // DOT11_N_SUPPORT //
VOID BssEntrySet(
IN PRTMP_ADAPTER pAd,
@@ -4438,7 +4128,6 @@ ULONG BssTableSetEntry(
IN USHORT LengthVIE,
IN PNDIS_802_11_VARIABLE_IEs pVIE);
-#ifdef DOT11_N_SUPPORT
VOID BATableInsertEntry(
IN PRTMP_ADAPTER pAd,
IN USHORT Aid,
@@ -4449,31 +4138,6 @@ VOID BATableInsertEntry(
IN UCHAR OriginatorStatus,
IN BOOLEAN IsRecipient);
-#ifdef DOT11N_DRAFT3
-VOID Bss2040CoexistTimeOut(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-
-VOID TriEventInit(
- IN PRTMP_ADAPTER pAd);
-
-ULONG TriEventTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT TRIGGER_EVENT_TAB *Tab,
- IN PUCHAR pBssid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN UCHAR RegClass,
- IN UCHAR ChannelNo);
-
-VOID TriEventCounterMaintenance(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
VOID BssTableSsidSort(
IN PRTMP_ADAPTER pAd,
OUT BSS_TABLE *OutTab,
@@ -4638,6 +4302,12 @@ VOID InvalidStateWhenDisassociate(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
+#ifdef RT2870
+VOID MlmeCntlConfirm(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG MsgType,
+ IN USHORT Msg);
+#endif // RT2870 //
VOID ComposePsPoll(
IN PRTMP_ADAPTER pAd);
@@ -4721,142 +4391,6 @@ VOID PeerAuthSimpleRspGenAndSend(
// Private routines in dls.c
//
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-void DlsStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID RTMPCheckDLSTimeOut(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPRcvFrameDLSCheck(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN ULONG Len,
- IN PRT28XX_RXD_STRUC pRxD);
-
-INT RTMPCheckDLSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-NDIS_STATUS RTMPSendSTAKeyRequest(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-NDIS_STATUS RTMPSendSTAKeyHandShake(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-VOID DlsTimeoutAction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN MlmeDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PRT_802_11_DLS *pDLS,
- OUT PUSHORT pReason);
-
-INT Set_DlsEntryInfo_Display_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UINT DlsEntryIdx);
-
-BOOLEAN MacTableDeleteDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr);
-
-MAC_TABLE_ENTRY *DlsEntryTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount);
-
-MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR wcid,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount);
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_DlsTearDownEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN PeerDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pDlsTimeout,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDlsRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDlsTearDownSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pReason);
-#endif // QOS_DLS_SUPPORT //
-
//========================================
VOID SyncStateMachineInit(
@@ -4961,12 +4495,6 @@ VOID CntlWaitAssocProc(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem);
-#ifdef QOS_DLS_SUPPORT
-VOID CntlOidDLSSetupProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // QOS_DLS_SUPPORT //
-
VOID LinkUp(
IN PRTMP_ADAPTER pAd,
IN UCHAR BssType);
@@ -5113,9 +4641,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
OUT PQOS_CAPABILITY_PARM pQosCapability,
OUT ULONG *pRalinkIe,
OUT UCHAR *pHtCapabilityLen,
-#ifdef CONFIG_STA_SUPPORT
OUT UCHAR *pPreNHtCapabilityLen,
-#endif // CONFIG_STA_SUPPORT //
OUT HT_CAPABILITY_IE *pHtCapability,
OUT UCHAR *AddHtInfoLen,
OUT ADD_HT_INFO_IE *AddHtInfo,
@@ -5343,23 +4869,19 @@ VOID MlmeUpdateTxRates(
IN BOOLEAN bLinkUp,
IN UCHAR apidx);
-#ifdef DOT11_N_SUPPORT
VOID MlmeUpdateHtTxRates(
IN PRTMP_ADAPTER pAd,
IN UCHAR apidx);
-#endif // DOT11_N_SUPPORT //
VOID RTMPCheckRates(
IN PRTMP_ADAPTER pAd,
IN OUT UCHAR SupRate[],
IN OUT UCHAR *SupRateLen);
-#ifdef CONFIG_STA_SUPPORT
BOOLEAN RTMPCheckChannel(
IN PRTMP_ADAPTER pAd,
IN UCHAR CentralChannel,
IN UCHAR Channel);
-#endif // CONFIG_STA_SUPPORT //
BOOLEAN RTMPCheckHt(
IN PRTMP_ADAPTER pAd,
@@ -5388,6 +4910,12 @@ CHAR RTMPMaxRssi(
IN CHAR Rssi1,
IN CHAR Rssi2);
+#ifdef RT30xx
+VOID AsicSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant);
+#endif
+
VOID AsicEvaluateRxAnt(
IN PRTMP_ADAPTER pAd);
@@ -5600,15 +5128,12 @@ VOID RTMPIndicateWPA2Status(
VOID RTMPOPModeSwitching(
IN PRTMP_ADAPTER pAd);
-#ifdef CONFIG_STA_SUPPORT
VOID RTMPAddBSSIDCipher(
IN PRTMP_ADAPTER pAd,
IN UCHAR Aid,
IN PNDIS_802_11_KEY pKey,
IN UCHAR CipherAlg);
-#endif // CONFIG_STA_SUPPORT //
-#ifdef DOT11_N_SUPPORT
VOID RTMPSetHT(
IN PRTMP_ADAPTER pAd,
IN OID_SET_HT_PHYMODE *pHTPhyMode);
@@ -5616,7 +5141,6 @@ VOID RTMPSetHT(
VOID RTMPSetIndividualHT(
IN PRTMP_ADAPTER pAd,
IN UCHAR apidx);
-#endif // DOT11_N_SUPPORT //
VOID RTMPSendWirelessEvent(
IN PRTMP_ADAPTER pAd,
@@ -5793,13 +5317,6 @@ CHAR ConvertToRssi(
IN CHAR Rssi,
IN UCHAR RssiNumber);
-
-#ifdef DOT11N_DRAFT3
-VOID BuildEffectedChannelList(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11N_DRAFT3 //
-
-
VOID APAsicEvaluateRxAnt(
IN PRTMP_ADAPTER pAd);
@@ -6072,6 +5589,10 @@ VOID RTMPSendTriggerFrame(
IN UCHAR TxRate,
IN BOOLEAN bQosNull);
+#ifdef RT30xx
+VOID RTMPFilterCalibration(
+ IN PRTMP_ADAPTER pAd);
+#endif // RT30xx //
/* timeout -- ms */
VOID RTMP_SetPeriodicTimer(
@@ -6263,7 +5784,6 @@ UCHAR VLAN_8023_Header_Copy(
OUT PUCHAR pData,
IN UCHAR FromWhichBSSID);
-#ifdef DOT11_N_SUPPORT
void ba_flush_reordering_timeout_mpdus(
IN PRTMP_ADAPTER pAd,
IN PBA_REC_ENTRY pBAEntry,
@@ -6281,7 +5801,6 @@ VOID BAOriSessionSetUp(
VOID BASessionTearDownALL(
IN OUT PRTMP_ADAPTER pAd,
IN UCHAR Wcid);
-#endif // DOT11_N_SUPPORT //
BOOLEAN OS_Need_Clone_Packet(void);
@@ -6429,7 +5948,6 @@ INT Set_ResetStatCounter_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
-#ifdef DOT11_N_SUPPORT
INT Set_BASetup_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
@@ -6530,24 +6048,17 @@ INT Set_HtMIMOPSmode_Proc(
INT Set_HtTxBASize_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef CONFIG_STA_SUPPORT
//Dls , kathy
VOID RTMPSendDLSTearDownFrame(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pDA);
-#ifdef DOT11_N_SUPPORT
//Block ACK
VOID QueryBATABLE(
IN PRTMP_ADAPTER pAd,
OUT PQUERYBA_TABLE pBAT);
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
INT WpaCheckEapCode(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pFrame,
@@ -6560,26 +6071,16 @@ VOID WpaSendMicFailureToWpaSupplicant(
VOID SendAssocIEsToWpaSupplicant(
IN PRTMP_ADAPTER pAd);
-#endif // WPA_SUPPLICANT_SUPPORT //
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
int wext_notify_event_assoc(
IN RTMP_ADAPTER *pAd);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
VOID Handle_BSS_Width_Trigger_Events(
IN PRTMP_ADAPTER pAd);
void build_ext_channel_switch_ie(
IN PRTMP_ADAPTER pAd,
IN HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE *pIE);
-#endif // DOT11_N_SUPPORT //
-
BOOLEAN APRxDoneInterruptHandle(
IN PRTMP_ADAPTER pAd);
@@ -6588,7 +6089,6 @@ BOOLEAN STARxDoneInterruptHandle(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN argc);
-#ifdef DOT11_N_SUPPORT
// AMPDU packet indication
VOID Indicate_AMPDU_Packet(
IN PRTMP_ADAPTER pAd,
@@ -6600,7 +6100,6 @@ VOID Indicate_AMSDU_Packet(
IN PRTMP_ADAPTER pAd,
IN RX_BLK *pRxBlk,
IN UCHAR FromWhichBSSID);
-#endif // DOT11_N_SUPPORT //
// Normal legacy Rx packet indication
VOID Indicate_Legacy_Packet(
@@ -6630,8 +6129,6 @@ UINT deaggregate_AMSDU_announce(
IN PUCHAR pData,
IN ULONG DataSize);
-
-#ifdef CONFIG_STA_SUPPORT
// remove LLC and get 802_3 Header
#define RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3) \
{ \
@@ -6662,8 +6159,6 @@ UINT deaggregate_AMSDU_announce(
CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData, \
_pRxBlk->DataSize, _pRemovedLLCSNAP); \
}
-#endif // CONFIG_STA_SUPPORT //
-
BOOLEAN APFowardWirelessStaToWirelessSta(
IN PRTMP_ADAPTER pAd,
@@ -6680,13 +6175,9 @@ VOID Sta_Announce_or_Forward_802_3_Packet(
IN PNDIS_PACKET pPacket,
IN UCHAR FromWhichBSSID);
-
-#ifdef CONFIG_STA_SUPPORT
#define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
//announce_802_3_packet(_pAd, _pPacket);
-#endif // CONFIG_STA_SUPPORT //
-
PNDIS_PACKET DuplicatePacket(
IN PRTMP_ADAPTER pAd,
@@ -6729,22 +6220,6 @@ PNDIS_PACKET RTMPDeFragmentDataFrame(
IN RX_BLK *pRxBlk);
////////////////////////////////////////
-
-
-
-
-
-#ifdef SNMP_SUPPORT
-//for snmp , kathy
-typedef struct _DefaultKeyIdxValue
-{
- UCHAR KeyIdx;
- UCHAR Value[16];
-} DefaultKeyIdxValue, *PDefaultKeyIdxValue;
-#endif
-
-
-#ifdef CONFIG_STA_SUPPORT
enum {
DIDmsg_lnxind_wlansniffrm = 0x00000044,
DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
@@ -6857,18 +6332,11 @@ struct iw_statistics *rt28xx_get_wireless_stats(
VOID RTMPSetDesiredRates(
IN PRTMP_ADAPTER pAdapter,
IN LONG Rates);
-#endif // CONFIG_STA_SUPPORT //
INT Set_FixedTxMode_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-INT Set_OpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
static inline char* GetPhyMode(
int Mode)
{
@@ -6879,13 +6347,11 @@ static inline char* GetPhyMode(
case MODE_OFDM:
return "OFDM";
-#ifdef DOT11_N_SUPPORT
case MODE_HTMIX:
return "HTMIX";
case MODE_HTGREENFIELD:
return "GREEN";
-#endif // DOT11_N_SUPPORT //
default:
return "N/A";
}
@@ -6902,10 +6368,8 @@ static inline char* GetBW(
case BW_20:
return "20M";
-#ifdef DOT11_N_SUPPORT
case BW_40:
return "40M";
-#endif // DOT11_N_SUPPORT //
default:
return "N/A";
}
@@ -6945,13 +6409,10 @@ INT rt28xx_ioctl(
IN OUT struct ifreq *rq,
IN INT cmd);
-
-#ifdef CONFIG_STA_SUPPORT
INT rt28xx_sta_ioctl(
IN struct net_device *net_dev,
IN OUT struct ifreq *rq,
IN INT cmd);
-#endif // CONFIG_STA_SUPPORT //
BOOLEAN RT28XXSecurityKeyAdd(
IN PRTMP_ADAPTER pAd,
@@ -6971,6 +6432,7 @@ void kill_thread_task(PRTMP_ADAPTER pAd);
void tbtt_tasklet(unsigned long data);
+#ifdef RT2860
//
// Function Prototype in cmm_data_2860.c
//
@@ -7035,7 +6497,6 @@ NDIS_STATUS RTMPCheckRxError(
IN PRXWI_STRUC pRxWI,
IN PRT28XX_RXD_STRUC pRxD);
-#ifdef CONFIG_STA_SUPPORT
VOID RTMPInitPCIeLinkCtrlValue(
IN PRTMP_ADAPTER pAd);
@@ -7078,13 +6539,13 @@ VOID RadioOnExec(
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3);
-#endif // CONFIG_STA_SUPPORT //
VOID RT28xxPciMlmeRadioOn(
IN PRTMP_ADAPTER pAd);
VOID RT28xxPciMlmeRadioOFF(
IN PRTMP_ADAPTER pAd);
+#endif /* RT2860 */
VOID AsicTurnOffRFClk(
IN PRTMP_ADAPTER pAd,
@@ -7094,6 +6555,493 @@ VOID AsicTurnOnRFClk(
IN PRTMP_ADAPTER pAd,
IN UCHAR Channel);
+#ifdef RT30xx
+NTSTATUS RT30xxWriteRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RegID,
+ IN UCHAR Value);
+
+NTSTATUS RT30xxReadRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RegID,
+ IN PUCHAR pValue);
+
+//2008/09/11:KH add to support efuse<--
+UCHAR eFuseReadRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData);
+
+VOID eFuseReadPhysical(
+ IN PRTMP_ADAPTER pAd,
+ IN PUSHORT lpInBuffer,
+ IN ULONG nInBufferSize,
+ OUT PUSHORT lpOutBuffer,
+ IN ULONG nOutBufferSize
+);
+
+NTSTATUS eFuseRead(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT PUCHAR pData,
+ IN USHORT Length);
+
+VOID eFusePhysicalWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData);
+
+NTSTATUS eFuseWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData);
+
+VOID eFuseWritePhysical(
+ IN PRTMP_ADAPTER pAd,
+ PUSHORT lpInBuffer,
+ ULONG nInBufferSize,
+ PUCHAR lpOutBuffer,
+ ULONG nOutBufferSize
+);
+
+NTSTATUS eFuseWrite(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN PUCHAR pData,
+ IN USHORT length);
+
+INT set_eFuseGetFreeBlockCount_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg);
+
+INT set_eFusedump_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg);
+
+INT set_eFuseLoadFromBin_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg);
+
+NTSTATUS eFuseWriteRegistersFromBin(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData);
+
+VOID eFusePhysicalReadRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData);
+
+NDIS_STATUS NICLoadEEPROM(
+ IN PRTMP_ADAPTER pAd);
+
+BOOLEAN bNeedLoadEEPROM(
+ IN PRTMP_ADAPTER pAd);
+//2008/09/11:KH add to support efuse-->
+#endif // RT30xx //
+
+#ifdef RT30xx
+// add by johnli, RF power sequence setup
+VOID RT30xxLoadRFNormalModeSetup(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT30xxLoadRFSleepModeSetup(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT30xxReverseRFSleepModeSetup(
+ IN PRTMP_ADAPTER pAd);
+// end johnli
+#endif // RT30xx //
+
+#ifdef RT2870
+//
+// Function Prototype in rtusb_bulk.c
+//
+VOID RTUSBInitTxDesc(
+ IN PRTMP_ADAPTER pAd,
+ IN PTX_CONTEXT pTxContext,
+ IN UCHAR BulkOutPipeId,
+ IN usb_complete_t Func);
+
+VOID RTUSBInitHTTxDesc(
+ IN PRTMP_ADAPTER pAd,
+ IN PHT_TX_CONTEXT pTxContext,
+ IN UCHAR BulkOutPipeId,
+ IN ULONG BulkOutSize,
+ IN usb_complete_t Func);
+
+VOID RTUSBInitRxDesc(
+ IN PRTMP_ADAPTER pAd,
+ IN PRX_CONTEXT pRxContext);
+
+VOID RTUSBCleanUpDataBulkOutQueue(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBCancelPendingBulkOutIRP(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBBulkOutDataPacket(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR BulkOutPipeId,
+ IN UCHAR Index);
+
+VOID RTUSBBulkOutNullFrame(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBBulkOutRTSFrame(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBCancelPendingBulkInIRP(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBCancelPendingIRPs(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBBulkOutMLMEPacket(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Index);
+
+VOID RTUSBBulkOutPsPoll(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBCleanUpMLMEBulkOutQueue(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBKickBulkOut(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBBulkReceive(
+ IN PRTMP_ADAPTER pAd);
+
+VOID DoBulkIn(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RTUSBInitRxDesc(
+ IN PRTMP_ADAPTER pAd,
+ IN PRX_CONTEXT pRxContext);
+
+VOID RTUSBBulkRxHandle(
+ IN unsigned long data);
+
+//
+// Function Prototype in rtusb_io.c
+//
+NTSTATUS RTUSBMultiRead(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT PUCHAR pData,
+ IN USHORT length);
+
+NTSTATUS RTUSBMultiWrite(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN PUCHAR pData,
+ IN USHORT length);
+
+NTSTATUS RTUSBMultiWrite_OneByte(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN PUCHAR pData);
+
+NTSTATUS RTUSBReadBBPRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Id,
+ IN PUCHAR pValue);
+
+NTSTATUS RTUSBWriteBBPRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Id,
+ IN UCHAR Value);
+
+NTSTATUS RTUSBWriteRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT32 Value);
+
+#ifndef RT30xx
+NTSTATUS RT30xxWriteRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RegID,
+ IN UCHAR Value);
+
+NTSTATUS RT30xxReadRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RegID,
+ IN PUCHAR pValue);
+#endif
+
+NTSTATUS RTUSB_VendorRequest(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT32 TransferFlags,
+ IN UCHAR ReservedBits,
+ IN UCHAR Request,
+ IN USHORT Value,
+ IN USHORT Index,
+ IN PVOID TransferBuffer,
+ IN UINT32 TransferBufferLength);
+
+NTSTATUS RTUSBReadEEPROM(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT PUCHAR pData,
+ IN USHORT length);
+
+NTSTATUS RTUSBWriteEEPROM(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN PUCHAR pData,
+ IN USHORT length);
+
+VOID RTUSBPutToSleep(
+ IN PRTMP_ADAPTER pAd);
+
+NTSTATUS RTUSBWakeUp(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTUSBInitializeCmdQ(
+ IN PCmdQ cmdq);
+
+NDIS_STATUS RTUSBEnqueueCmdFromNdis(
+ IN PRTMP_ADAPTER pAd,
+ IN NDIS_OID Oid,
+ IN BOOLEAN SetInformation,
+ IN PVOID pInformationBuffer,
+ IN UINT32 InformationBufferLength);
+
+NDIS_STATUS RTUSBEnqueueInternalCmd(
+ IN PRTMP_ADAPTER pAd,
+ IN NDIS_OID Oid,
+ IN PVOID pInformationBuffer,
+ IN UINT32 InformationBufferLength);
+
+VOID RTUSBDequeueCmd(
+ IN PCmdQ cmdq,
+ OUT PCmdQElmt *pcmdqelmt);
+
+INT RTUSBCmdThread(
+ IN OUT PVOID Context);
+
+INT TimerQThread(
+ IN OUT PVOID Context);
+
+RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
+ IN RTMP_ADAPTER *pAd,
+ IN RALINK_TIMER_STRUCT *pTimer);
+
+BOOLEAN RT2870_TimerQ_Remove(
+ IN RTMP_ADAPTER *pAd,
+ IN RALINK_TIMER_STRUCT *pTimer);
+
+void RT2870_TimerQ_Exit(
+ IN RTMP_ADAPTER *pAd);
+
+void RT2870_TimerQ_Init(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RT2870_BssBeaconExit(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RT2870_BssBeaconStop(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RT2870_BssBeaconStart(
+ IN RTMP_ADAPTER * pAd);
+
+VOID RT2870_BssBeaconInit(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RT2870_WatchDog(
+ IN RTMP_ADAPTER *pAd);
+
+NTSTATUS RTUSBWriteMACRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN UINT32 Value);
+
+NTSTATUS RTUSBReadMACRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT PUINT32 pValue);
+
+NTSTATUS RTUSBSingleWrite(
+ IN RTMP_ADAPTER *pAd,
+ IN USHORT Offset,
+ IN USHORT Value);
+
+NTSTATUS RTUSBFirmwareRun(
+ IN PRTMP_ADAPTER pAd);
+
+NTSTATUS RTUSBFirmwareWrite(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pFwImage,
+ IN ULONG FwLen);
+
+NTSTATUS RTUSBFirmwareOpmode(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUINT32 pValue);
+
+NTSTATUS RTUSBVenderReset(
+ IN PRTMP_ADAPTER pAd);
+
+NDIS_STATUS RTUSBSetHardWareRegister(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PVOID pBuf);
+
+NDIS_STATUS RTUSBQueryHardWareRegister(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PVOID pBuf);
+
+VOID CMDHandler(
+ IN PRTMP_ADAPTER pAd);
+
+
+NDIS_STATUS CreateThreads(
+ IN struct net_device *net_dev );
+
+
+VOID MacTableInitialize(
+ IN PRTMP_ADAPTER pAd);
+
+VOID MlmeSetPsm(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT psm);
+
+NDIS_STATUS RTMPWPAAddKeyProc(
+ IN PRTMP_ADAPTER pAd,
+ IN PVOID pBuf);
+
+VOID AsicRxAntEvalAction(
+ IN PRTMP_ADAPTER pAd);
+
+void append_pkt(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pHeader802_3,
+ IN UINT HdrLen,
+ IN PUCHAR pData,
+ IN ULONG DataSize,
+ OUT PNDIS_PACKET *ppPacket);
+
+UINT deaggregate_AMSDU_announce(
+ IN PRTMP_ADAPTER pAd,
+ PNDIS_PACKET pPacket,
+ IN PUCHAR pData,
+ IN ULONG DataSize);
+
+NDIS_STATUS RTMPCheckRxError(
+ IN PRTMP_ADAPTER pAd,
+ IN PHEADER_802_11 pHeader,
+ IN PRXWI_STRUC pRxWI,
+ IN PRT28XX_RXD_STRUC pRxINFO);
+
+
+VOID RTUSBMlmeHardTransmit(
+ IN PRTMP_ADAPTER pAd,
+ IN PMGMT_STRUC pMgmt);
+
+INT MlmeThread(
+ IN PVOID Context);
+
+//
+// Function Prototype in rtusb_data.c
+//
+NDIS_STATUS RTUSBFreeDescriptorRequest(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR BulkOutPipeId,
+ IN UINT32 NumberRequired);
+
+
+BOOLEAN RTUSBNeedQueueBackForAgg(
+ IN RTMP_ADAPTER *pAd,
+ IN UCHAR BulkOutPipeId);
+
+
+VOID RTMPWriteTxInfo(
+ IN PRTMP_ADAPTER pAd,
+ IN PTXINFO_STRUC pTxInfo,
+ IN USHORT USBDMApktLen,
+ IN BOOLEAN bWiv,
+ IN UCHAR QueueSel,
+ IN UCHAR NextValid,
+ IN UCHAR TxBurst);
+
+//
+// Function Prototype in cmm_data_2870.c
+//
+USHORT RtmpUSB_WriteSubTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpUSB_WriteSingleTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpUSB_WriteFragTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR fragNum,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpUSB_WriteMultiTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR frameNum,
+ OUT USHORT *FreeNumber);
+
+VOID RtmpUSB_FinalWriteTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN USHORT totalMPDUSize,
+#ifdef RT2860
+ IN USHORT FirstTxIdx);
+#endif
+ IN USHORT TxIdx);
+
+VOID RtmpUSBDataLastTxIdx(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN USHORT TxIdx);
+
+VOID RtmpUSBDataKickOut(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR QueIdx);
+
+
+int RtmpUSBMgmtKickOut(
+ IN RTMP_ADAPTER *pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket,
+ IN PUCHAR pSrcBufVA,
+ IN UINT SrcBufLen);
+
+VOID RtmpUSBNullFrameKickOut(
+ IN RTMP_ADAPTER *pAd,
+ IN UCHAR QueIdx,
+ IN UCHAR *pNullFrame,
+ IN UINT32 frameLen);
+
+VOID RT28xxUsbStaAsicForceWakeup(
+ IN PRTMP_ADAPTER pAd,
+ IN BOOLEAN bFromTx);
+
+VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT TbttNumToNextWakeUp);
+
+VOID RT28xxUsbMlmeRadioOn(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT28xxUsbMlmeRadioOFF(
+ IN PRTMP_ADAPTER pAd);
+#endif // RT2870 //
////////////////////////////////////////
@@ -7120,10 +7068,10 @@ PCHAR RTMPGetRalinkEncryModeStr(
IN USHORT encryMode);
//////////////////////////////////////
-#ifdef CONFIG_STA_SUPPORT
VOID AsicStaBbpTuning(
IN PRTMP_ADAPTER pAd);
+#ifdef RT2860
VOID AsicResetFromDMABusy(
IN PRTMP_ADAPTER pAd);
@@ -7135,7 +7083,16 @@ VOID AsicResetMAC(
VOID AsicResetPBF(
IN PRTMP_ADAPTER pAd);
-#endif // CONFIG_STA_SUPPORT //
+#endif
+#ifdef RT2870
+BOOLEAN StaAddMacTableEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PMAC_TABLE_ENTRY pEntry,
+ IN UCHAR MaxSupportedRateIn500Kbps,
+ IN HT_CAPABILITY_IE *pHtCapability,
+ IN UCHAR HtCapabilityLen,
+ IN USHORT CapabilityInfo);
+#endif
void RTMP_IndicateMediaState(
IN PRTMP_ADAPTER pAd);
diff --git a/drivers/staging/rt2860/rtmp_def.h b/drivers/staging/rt2860/rtmp_def.h
index 25a53d83a0d7..5dde860cbbd4 100644
--- a/drivers/staging/rt2860/rtmp_def.h
+++ b/drivers/staging/rt2860/rtmp_def.h
@@ -54,15 +54,6 @@
#define NIC_TAG ((ULONG)'0682')
#define NIC_DBG_STRING ("**RT28xx**")
-#ifdef SNMP_SUPPORT
-// for snmp
-// to get manufacturer OUI, kathy, 2008_0220
-#define ManufacturerOUI_LEN 3
-#define ManufacturerNAME ("Ralink Technology Company.")
-#define ResourceTypeIdName ("Ralink_ID")
-#endif
-
-
#define RALINK_2883_VERSION ((UINT32)0x28830300)
#define RALINK_2880E_VERSION ((UINT32)0x28720200)
#define RALINK_3070_VERSION ((UINT32)0x30700200)
@@ -111,6 +102,7 @@
// Entry number for each DMA descriptor ring
//
+#ifdef RT2860
#define TX_RING_SIZE 64 //64
#define MGMT_RING_SIZE 128
#define RX_RING_SIZE 128 //64
@@ -118,12 +110,15 @@
#define MAX_DMA_DONE_PROCESS TX_RING_SIZE
#define MAX_TX_DONE_PROCESS TX_RING_SIZE //8
#define LOCAL_TXBUF_SIZE 2
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// MC: Multple Cards
-#define MAX_NUM_OF_MULTIPLE_CARD 32
-#endif // MULTIPLE_CARD_SUPPORT //
+#endif
+#ifdef RT2870
+#define TX_RING_SIZE 8 // 1
+#define PRIO_RING_SIZE 8
+#define MGMT_RING_SIZE 32 // PRIO_RING_SIZE
+#define RX_RING_SIZE 8
+#define MAX_TX_PROCESS 4
+#define LOCAL_TXBUF_SIZE 2048
+#endif // RT2870 //
#define MAX_RX_PROCESS 128 //64 //32
#define NUM_OF_LOCAL_TXBUF 2
@@ -153,7 +148,11 @@
#define MAX_PACKETS_IN_PS_QUEUE 128 //32
#define WMM_NUM_OF_AC 4 /* AC0, AC1, AC2, and AC3 */
-
+#ifdef RT30xx
+//2008/09/11:KH add to support efuse<--
+#define MAX_EEPROM_BIN_FILE_SIZE 1024
+//2008/09/11:KH add to support efuse-->
+#endif
// RxFilter
#define STANORMAL 0x17f97
@@ -210,6 +209,7 @@
#define fOP_STATUS_WAKEUP_NOW 0x00008000
#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000
+#ifdef RT2860
//
// RTMP_ADAPTER PSFlags : related to advanced power save.
//
@@ -222,10 +222,7 @@
// Indicate driver should IMMEDIATELY fo to sleep after receiving AP's beacon in which doesn't indicate unicate nor multicast packets for me
//. This flag is used ONLY in RTMPHandleRxDoneInterrupt routine.
#define fRTMP_PS_GO_TO_SLEEP_NOW 0x00000008
-
-#ifdef DOT11N_DRAFT3
-#define fOP_STATUS_SCAN_2040 0x00040000
-#endif // DOT11N_DRAFT3 //
+#endif
#define CCKSETPROTECT 0x1
#define OFDMSETPROTECT 0x2
@@ -251,10 +248,6 @@
#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE 0x00000400
#define fCLIENT_STATUS_APSD_CAPABLE 0x00000800 /* UAPSD STATION */
-#ifdef DOT11N_DRAFT3
-#define fCLIENT_STATUS_BSSCOEXIST_CAPABLE 0x00001000
-#endif // DOT11N_DRAFT3 //
-
#define fCLIENT_STATUS_RALINK_CHIPSET 0x00100000
//
// STA configuration flags
@@ -330,16 +323,14 @@
#define MAX_MESH_NUM 0
#define MAX_APCLI_NUM 0
-#ifdef APCLI_SUPPORT
-#undef MAX_APCLI_NUM
-#define MAX_APCLI_NUM 1
-#endif // APCLI_SUPPORT //
#define MAX_MBSSID_NUM 1
+#if defined(RT2860) || defined(RT30xx)
#ifdef MBSS_SUPPORT
#undef MAX_MBSSID_NUM
#define MAX_MBSSID_NUM (8 - MAX_MESH_NUM - MAX_APCLI_NUM)
#endif // MBSS_SUPPORT //
+#endif
/* sanity check for apidx */
#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
@@ -582,6 +573,9 @@
// For 802.11n D3.03
//#define IE_NEW_EXT_CHA_OFFSET 62 // 802.11n d1. New extension channel offset elemet
#define IE_SECONDARY_CH_OFFSET 62 // 802.11n D3.03 Secondary Channel Offset element
+#ifdef RT2870
+#define IE_WAPI 68 // WAPI information element
+#endif
#define IE_2040_BSS_COEXIST 72 // 802.11n D3.0.3
#define IE_2040_BSS_INTOLERANT_REPORT 73 // 802.11n D3.03
#define IE_OVERLAPBSS_SCAN_PARM 74 // 802.11n D3.03
@@ -630,9 +624,10 @@
#define AP_CNTL_STATE_MACHINE 15
#define AP_WPA_STATE_MACHINE 16
-#ifdef QOS_DLS_SUPPORT
-#define DLS_STATE_MACHINE 26
-#endif // QOS_DLS_SUPPORT //
+#ifdef RT30xx
+#define WSC_STATE_MACHINE 17
+#define WSC_UPNP_STATE_MACHINE 18
+#endif
//
// STA's CONTROL/CONNECT state machine: states, events, total function #
@@ -647,6 +642,9 @@
#define CNTL_WAIT_AUTH2 7
#define CNTL_WAIT_OID_LIST_SCAN 8
#define CNTL_WAIT_OID_DISASSOC 9
+#ifdef RT2870
+#define CNTL_WAIT_SCAN_FOR_CONNECT 10
+#endif // RT2870 //
#define MT2_ASSOC_CONF 34
#define MT2_AUTH_CONF 35
@@ -948,79 +946,6 @@
#define AP_WPA_FUNC_SIZE (AP_MAX_WPA_PTK_STATE * AP_MAX_WPA_MSG)
-#ifdef APCLI_SUPPORT
-//ApCli authentication state machine
-#define APCLI_AUTH_REQ_IDLE 0
-#define APCLI_AUTH_WAIT_SEQ2 1
-#define APCLI_AUTH_WAIT_SEQ4 2
-#define APCLI_MAX_AUTH_STATE 3
-
-#define APCLI_AUTH_MACHINE_BASE 0
-#define APCLI_MT2_MLME_AUTH_REQ 0
-#define APCLI_MT2_MLME_DEAUTH_REQ 1
-#define APCLI_MT2_PEER_AUTH_EVEN 2
-#define APCLI_MT2_PEER_DEAUTH 3
-#define APCLI_MT2_AUTH_TIMEOUT 4
-#define APCLI_MAX_AUTH_MSG 5
-
-#define APCLI_AUTH_FUNC_SIZE (APCLI_MAX_AUTH_STATE * APCLI_MAX_AUTH_MSG)
-
-//ApCli association state machine
-#define APCLI_ASSOC_IDLE 0
-#define APCLI_ASSOC_WAIT_RSP 1
-#define APCLI_MAX_ASSOC_STATE 2
-
-#define APCLI_ASSOC_MACHINE_BASE 0
-#define APCLI_MT2_MLME_ASSOC_REQ 0
-#define APCLI_MT2_MLME_DISASSOC_REQ 1
-#define APCLI_MT2_PEER_DISASSOC_REQ 2
-#define APCLI_MT2_PEER_ASSOC_RSP 3
-#define APCLI_MT2_ASSOC_TIMEOUT 4
-#define APCLI_MAX_ASSOC_MSG 5
-
-#define APCLI_ASSOC_FUNC_SIZE (APCLI_MAX_ASSOC_STATE * APCLI_MAX_ASSOC_MSG)
-
-//ApCli sync state machine
-#define APCLI_SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define APCLI_JOIN_WAIT_PROBE_RSP 1
-#define APCLI_MAX_SYNC_STATE 2
-
-#define APCLI_SYNC_MACHINE_BASE 0
-#define APCLI_MT2_MLME_PROBE_REQ 0
-#define APCLI_MT2_PEER_PROBE_RSP 1
-#define APCLI_MT2_PROBE_TIMEOUT 2
-#define APCLI_MAX_SYNC_MSG 3
-
-#define APCLI_SYNC_FUNC_SIZE (APCLI_MAX_SYNC_STATE * APCLI_MAX_SYNC_MSG)
-
-//ApCli ctrl state machine
-#define APCLI_CTRL_DISCONNECTED 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define APCLI_CTRL_PROBE 1
-#define APCLI_CTRL_AUTH 2
-#define APCLI_CTRL_AUTH_2 3
-#define APCLI_CTRL_ASSOC 4
-#define APCLI_CTRL_DEASSOC 5
-#define APCLI_CTRL_CONNECTED 6
-#define APCLI_MAX_CTRL_STATE 7
-
-#define APCLI_CTRL_MACHINE_BASE 0
-#define APCLI_CTRL_JOIN_REQ 0
-#define APCLI_CTRL_PROBE_RSP 1
-#define APCLI_CTRL_AUTH_RSP 2
-#define APCLI_CTRL_DISCONNECT_REQ 3
-#define APCLI_CTRL_PEER_DISCONNECT_REQ 4
-#define APCLI_CTRL_ASSOC_RSP 5
-#define APCLI_CTRL_DEASSOC_RSP 6
-#define APCLI_CTRL_JOIN_REQ_TIMEOUT 7
-#define APCLI_CTRL_AUTH_REQ_TIMEOUT 8
-#define APCLI_CTRL_ASSOC_REQ_TIMEOUT 9
-#define APCLI_MAX_CTRL_MSG 10
-
-#define APCLI_CTRL_FUNC_SIZE (APCLI_MAX_CTRL_STATE * APCLI_MAX_CTRL_MSG)
-
-#endif // APCLI_SUPPORT //
-
-
// =============================================================================
// value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header
@@ -1107,10 +1032,9 @@
// Preamble MODE in TxD
#define MODE_CCK 0
#define MODE_OFDM 1
-#ifdef DOT11_N_SUPPORT
#define MODE_HTMIX 2
#define MODE_HTGREENFIELD 3
-#endif // DOT11_N_SUPPORT //
+
// MCS for CCK. BW.SGI.STBC are reserved
#define MCS_LONGP_RATE_1 0 // long preamble CCK 1Mbps
#define MCS_LONGP_RATE_2 1 // long preamble CCK 1Mbps
@@ -1157,12 +1081,10 @@
#define MCS_32 32
#define MCS_AUTO 33
-#ifdef DOT11_N_SUPPORT
// OID_HTPHYMODE
// MODE
#define HTMODE_MM 0
#define HTMODE_GF 1
-#endif // DOT11_N_SUPPORT //
// Fixed Tx MODE - HT, CCK or OFDM
#define FIXED_TXMODE_HT 0
@@ -1174,15 +1096,12 @@
#define BW_BOTH BAND_WIDTH_BOTH
#define BW_10 BAND_WIDTH_10 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-#ifdef DOT11_N_SUPPORT
// SHORTGI
#define GI_400 GAP_INTERVAL_400 // only support in HT mode
#define GI_BOTH GAP_INTERVAL_BOTH
-#endif // DOT11_N_SUPPORT //
#define GI_800 GAP_INTERVAL_800
// STBC
#define STBC_NONE 0
-#ifdef DOT11_N_SUPPORT
#define STBC_USE 1 // limited use in rt2860b phy
#define RXSTBC_ONE 1 // rx support of one spatial stream
#define RXSTBC_TWO 2 // rx support of 1 and 2 spatial stream
@@ -1204,8 +1123,6 @@
#define AMSDU_0 0
#define AMSDU_1 1
-#endif // DOT11_N_SUPPORT //
-
// MCS use 7 bits
#define TXRATEMIMO 0x80
#define TXRATEMCS 0x7F
@@ -1298,6 +1215,10 @@
#define RFIC_2750 4 // 2.4G/5G 1T2R
#define RFIC_3020 5 // 2.4G 1T1R
#define RFIC_2020 6 // 2.4G B/G
+#ifdef RT30xx
+#define RFIC_3021 7 // 2.4G 1T2R
+#define RFIC_3022 8 // 2.4G 2T2R
+#endif
// LED Status.
#define LED_LINK_DOWN 0
@@ -1353,17 +1274,6 @@
#define OPMODE_AP 1
//#define OPMODE_L3_BRG 2 // as AP and STA at the same time
-#ifdef RT_BIG_ENDIAN
-#define DIR_READ 0
-#define DIR_WRITE 1
-#define TYPE_TXD 0
-#define TYPE_RXD 1
-#define TYPE_TXINFO 0
-#define TYPE_RXINFO 1
-#define TYPE_TXWI 0
-#define TYPE_RXWI 1
-#endif
-
// ========================= AP rtmp_def.h ===========================
// value domain for pAd->EventTab.Log[].Event
#define EVENT_RESET_ACCESS_POINT 0 // Log = "hh:mm:ss Restart Access Point"
@@ -1410,24 +1320,6 @@
#define INT_MESH 0x0500
// Use bitmap to allow coexist of ATE_TXFRAME and ATE_RXFRAME(i.e.,to support LoopBack mode)
-#ifdef RALINK_ATE
-#define ATE_START 0x00 // Start ATE
-#define ATE_STOP 0x80 // Stop ATE
-#define ATE_TXCONT 0x05 // Continuous Transmit
-#define ATE_TXCARR 0x09 // Transmit Carrier
-#define ATE_TXCARRSUPP 0x11 // Transmit Carrier Suppression
-#define ATE_TXFRAME 0x01 // Transmit Frames
-#define ATE_RXFRAME 0x02 // Receive Frames
-#ifdef RALINK_28xx_QA
-#define ATE_TXSTOP 0xe2 // Stop Transmition(i.e., TXCONT, TXCARR, TXCARRSUPP, and TXFRAME)
-#define ATE_RXSTOP 0xfd // Stop receiving Frames
-#define BBP22_TXFRAME 0x00 // Transmit Frames
-#define BBP22_TXCONT_OR_CARRSUPP 0x80 // Continuous Transmit or Carrier Suppression
-#define BBP22_TXCARR 0xc1 // Transmit Carrier
-#define BBP24_TXCONT 0x00 // Continuous Transmit
-#define BBP24_CARRSUPP 0x01 // Carrier Suppression
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
// WEP Key TYPE
#define WEP_HEXADECIMAL_TYPE 0
@@ -1498,7 +1390,6 @@
// End - WIRELESS EVENTS definition
-#ifdef CONFIG_STA_SUPPORT
// definition for DLS, kathy
#define MAX_NUM_OF_INIT_DLS_ENTRY 1
#define MAX_NUM_OF_DLS_ENTRY MAX_NUMBER_OF_DLS_ENTRY
@@ -1508,15 +1399,12 @@
#define MAX_RX_REORDERBUF 64
#define DEFAULT_TX_TIMEOUT 30
#define DEFAULT_RX_TIMEOUT 30
-#ifndef CONFIG_AP_SUPPORT
#define MAX_BARECI_SESSION 8
-#endif
#ifndef IW_ESSID_MAX_SIZE
/* Maximum size of the ESSID and pAd->nickname strings */
#define IW_ESSID_MAX_SIZE 32
#endif
-#endif // CONFIG_STA_SUPPORT //
#ifdef MCAST_RATE_SPECIFIC
#define MCAST_DISABLE 0
@@ -1525,6 +1413,7 @@
#define MCAST_HTMIX 3
#endif // MCAST_RATE_SPECIFIC //
+#ifdef RT2860
// For AsicRadioOff/AsicRadioOn/AsicForceWakeup function
// This is to indicate from where to call this function.
#define DOT11POWERSAVE 0 // TO do .11 power save sleep
@@ -1532,8 +1421,14 @@
#define RTMP_HALT 2 // Called from Halt handler.
#define GUI_IDLE_POWER_SAVE 3 // Call to sleep before link up with AP
#define FROM_TX 4 // Force wake up from Tx packet.
-
-
+#endif
+#ifdef RT2870
+// For AsicRadioOff/AsicRadioOn function
+#define DOT11POWERSAVE 0
+#define GUIRADIO_OFF 1
+#define RTMP_HALT 2
+#define GUI_IDLE_POWER_SAVE 3
+#endif
// definition for WpaSupport flag
#define WPA_SUPPLICANT_DISABLE 0
@@ -1564,23 +1459,6 @@
(UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
(UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
-#ifdef RT_BIG_ENDIAN
-
-#define cpu2le64(x) SWAP64((x))
-#define le2cpu64(x) SWAP64((x))
-#define cpu2le32(x) SWAP32((x))
-#define le2cpu32(x) SWAP32((x))
-#define cpu2le16(x) SWAP16((x))
-#define le2cpu16(x) SWAP16((x))
-#define cpu2be64(x) ((UINT64)(x))
-#define be2cpu64(x) ((UINT64)(x))
-#define cpu2be32(x) ((UINT32)(x))
-#define be2cpu32(x) ((UINT32)(x))
-#define cpu2be16(x) ((UINT16)(x))
-#define be2cpu16(x) ((UINT16)(x))
-
-#else // Little_Endian
-
#define cpu2le64(x) ((UINT64)(x))
#define le2cpu64(x) ((UINT64)(x))
#define cpu2le32(x) ((UINT32)(x))
@@ -1594,8 +1472,6 @@
#define cpu2be16(x) SWAP16((x))
#define be2cpu16(x) SWAP16((x))
-#endif // RT_BIG_ENDIAN
-
#endif // __RTMP_DEF_H__
diff --git a/drivers/staging/rt2860/spectrum.h b/drivers/staging/rt2860/spectrum.h
index 60f25dbdba9f..0a878ba81b48 100644
--- a/drivers/staging/rt2860/spectrum.h
+++ b/drivers/staging/rt2860/spectrum.h
@@ -46,16 +46,6 @@ typedef struct PACKED _CH_SW_ANN_INFO
typedef union PACKED _MEASURE_REQ_MODE
{
-#ifdef RT_BIG_ENDIAN
- struct PACKED
- {
- UINT8 Rev1:4;
- UINT8 Report:1;
- UINT8 Request:1;
- UINT8 Enable:1;
- UINT8 Rev0:1;
- } field;
-#else
struct PACKED
{
UINT8 Rev0:1;
@@ -64,7 +54,6 @@ typedef union PACKED _MEASURE_REQ_MODE
UINT8 Report:1;
UINT8 Rev1:4;
} field;
-#endif // RT_BIG_ENDIAN //
UINT8 word;
} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
@@ -85,17 +74,6 @@ typedef struct PACKED _MEASURE_REQ_INFO
typedef union PACKED _MEASURE_BASIC_REPORT_MAP
{
-#ifdef RT_BIG_ENDIAN
- struct PACKED
- {
- UINT8 Rev:3;
- UINT8 Unmeasure:1;
- UINT8 Radar:1;
- UINT8 UnidentifiedSignal:1;
- UINT8 OfdmPreamble:1;
- UINT8 BSS:1;
- } field;
-#else
struct PACKED
{
UINT8 BSS:1;
@@ -105,7 +83,6 @@ typedef union PACKED _MEASURE_BASIC_REPORT_MAP
UINT8 Unmeasure:1;
UINT8 Rev:3;
} field;
-#endif // RT_BIG_ENDIAN //
UINT8 word;
} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
@@ -137,17 +114,10 @@ typedef union PACKED _MEASURE_REPORT_MODE
{
struct PACKED
{
-#ifdef RT_BIG_ENDIAN
- UINT8 Rev:5;
- UINT8 Refused:1;
- UINT8 Incapable:1;
- UINT8 Late:1;
-#else
UINT8 Late:1;
UINT8 Incapable:1;
UINT8 Refused:1;
UINT8 Rev:5;
-#endif // RT_BIG_ENDIAN //
} field;
UINT8 word;
} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
diff --git a/drivers/staging/rt2860/sta/assoc.c b/drivers/staging/rt2860/sta/assoc.c
index 34f1c1490f44..a0734c65bc2f 100644
--- a/drivers/staging/rt2860/sta/assoc.c
+++ b/drivers/staging/rt2860/sta/assoc.c
@@ -341,7 +341,6 @@ VOID MlmeAssocReqAction(
FrameLen += tmp;
}
-#ifdef DOT11_N_SUPPORT
// HT
if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
@@ -360,32 +359,14 @@ VOID MlmeAssocReqAction(
}
else
{
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
-#ifndef RT_BIG_ENDIAN
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &HtCapIe,
1, &pAd->MlmeAux.HtCapabilityLen,
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
-#else
- NdisZeroMemory(&HtCapabilityTmp, sizeof(HT_CAPABILITY_IE));
- NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, pAd->MlmeAux.HtCapabilityLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen,&HtCapabilityTmp,
- END_OF_ARGS);
-#endif
}
FrameLen += TmpLen;
}
-#endif // DOT11_N_SUPPORT //
// add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
// Case I: (Aggregation + Piggy-Back)
@@ -473,6 +454,11 @@ VOID MlmeAssocReqAction(
RSNIe = IE_WPA2;
}
+#ifdef RT30xx
+#ifdef SIOCSIWGENIE
+ if (pAd->StaCfg.WpaSupplicantUP != 1)
+#endif // SIOCSIWGENIE //
+#endif
RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
// Check for WPA PMK cache list
@@ -499,6 +485,17 @@ VOID MlmeAssocReqAction(
}
}
+#ifdef RT30xx
+#ifdef SIOCSIWGENIE
+ if (pAd->StaCfg.WpaSupplicantUP == 1)
+ {
+ MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
+ pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
+ END_OF_ARGS);
+ }
+ else
+#endif
+#endif
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &RSNIe,
@@ -509,6 +506,11 @@ VOID MlmeAssocReqAction(
FrameLen += tmp;
+#ifdef RT30xx
+#ifdef SIOCSIWGENIE
+ if (pAd->StaCfg.WpaSupplicantUP != 1)
+#endif
+#endif
{
// Append Variable IE
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1);
@@ -560,34 +562,6 @@ VOID MlmeAssocReqAction(
END_OF_ARGS);
FrameLen += tmp;
- //
- // Add CipherSuite CCKM or LeapTkip if setting.
- //
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCiscoCCKMLen, CipherSuiteCiscoCCKM,
- END_OF_ARGS);
- FrameLen += tmp;
-
- // Third add RSN
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen); //Save CipherSuite
- VarIesOffset += CipherSuiteCiscoCCKMLen;
- }
- else if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCCXTkipLen, CipherSuiteCCXTkip,
- END_OF_ARGS);
- FrameLen += tmp;
-
- // Third add RSN
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCCXTkip, CipherSuiteCCXTkipLen);
- VarIesOffset += CipherSuiteCCXTkipLen;
- }
-#endif // LEAP_SUPPORT //
-
// Add by James 03/06/27
// Set Variable IEs Length
pAd->StaCfg.ReqVarIELen = VarIesOffset;
@@ -647,23 +621,6 @@ VOID MlmeReassocReqAction(
NDIS_STATUS NStatus;
ULONG tmp;
PUCHAR pOutBuffer = NULL;
-//CCX 2.X
-#ifdef LEAP_SUPPORT
- UCHAR CkipFlag;
- UCHAR CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH];
- UCHAR AironetCkipIe = IE_AIRONET_CKIP;
- UCHAR AironetCkipLen = CKIP_NEGOTIATION_LENGTH;
- UCHAR AironetIPAddressIE = IE_AIRONET_IPADDRESS;
- UCHAR AironetIPAddressLen = AIRONET_IPADDRESS_LENGTH;
- UCHAR AironetIPAddressBuffer[AIRONET_IPADDRESS_LENGTH] = {0x00, 0x40, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00};
- UCHAR AironetCCKMReassocIE = IE_AIRONET_CCKMREASSOC;
- UCHAR AironetCCKMReassocLen = AIRONET_CCKMREASSOC_LENGTH;
- UCHAR AironetCCKMReassocBuffer[AIRONET_CCKMREASSOC_LENGTH];
- UCHAR AironetOUI[] = {0x00, 0x40, 0x96, 0x00};
- UCHAR MICMN[16];
- UCHAR CalcMicBuffer[80];
- ULONG CalcMicBufferLen = 0;
-#endif // LEAP_SUPPORT //
USHORT Status;
// Block all authentication request durning WPA block period
@@ -738,7 +695,6 @@ VOID MlmeReassocReqAction(
FrameLen += tmp;
}
-#ifdef DOT11_N_SUPPORT
// HT
if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
@@ -765,7 +721,6 @@ VOID MlmeReassocReqAction(
}
FrameLen += TmpLen;
}
-#endif // DOT11_N_SUPPORT //
// add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
// Case I: (Aggregation + Piggy-Back)
@@ -805,73 +760,6 @@ VOID MlmeReassocReqAction(
END_OF_ARGS);
FrameLen += TmpLen;
}
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- CkipFlag = pAd->StaCfg.CkipFlag; // We have update that at PeerBeaconAtJoinRequest()
- if (CkipFlag != 0)
- {
- NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH);
- CkipNegotiationBuffer[2] = 0x66;
- // Make it try KP & MIC, since we have to follow the result from AssocRsp
- CkipNegotiationBuffer[8] = 0x18;
- CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCkipIe,
- 1, &AironetCkipLen,
- AironetCkipLen, CkipNegotiationBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetIPAddressIE,
- 1, &AironetIPAddressLen,
- AironetIPAddressLen, AironetIPAddressBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
-
- //
- // The RN is incremented before each reassociation request.
- //
- pAd->StaCfg.CCKMRN++;
- //
- // Calculate MIC = hmac-md5(krk, STA-ID|BSSID|RSNIE|TSF|RN);
- //
- COPY_MAC_ADDR(CalcMicBuffer, pAd->CurrentAddress);
- CalcMicBufferLen = MAC_ADDR_LEN;
- COPY_MAC_ADDR(CalcMicBuffer + CalcMicBufferLen, pAd->MlmeAux.Bssid);
- CalcMicBufferLen += MAC_ADDR_LEN;
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen);
- CalcMicBufferLen += CipherSuiteCiscoCCKMLen;
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR) &pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp));
- CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp);
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR)&pAd->StaCfg.CCKMRN, sizeof(pAd->StaCfg.CCKMRN));
- CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMRN);
- hmac_md5(pAd->StaCfg.KRK, LEN_EAP_MICK, CalcMicBuffer, CalcMicBufferLen, MICMN);
-
- //
- // fill up CCKM reassociation request element
- //
- NdisMoveMemory(AironetCCKMReassocBuffer, AironetOUI, 4);
- NdisMoveMemory(AironetCCKMReassocBuffer + 4, (PUCHAR)&pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, 8);
- NdisMoveMemory(AironetCCKMReassocBuffer + 12, (PUCHAR) &pAd->StaCfg.CCKMRN, 4);
- NdisMoveMemory(AironetCCKMReassocBuffer +16, MICMN, 8);
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCCKMReassocIE,
- 1, &AironetCCKMReassocLen,
- AironetCCKMReassocLen, AironetCCKMReassocBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCiscoCCKMLen,CipherSuiteCiscoCCKM,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-#endif // LEAP_SUPPORT //
// Add CCX v2 request if CCX2 admin state is on
if (pAd->StaCfg.CCXControl.field.Enable == 1)
@@ -927,36 +815,6 @@ VOID MlmeDisassocReqAction(
ULONG Timeout = 0;
USHORT Status;
-#ifdef QOS_DLS_SUPPORT
- // send DLS-TEAR_DOWN message,
- if (pAd->CommonCfg.bDLSCapable)
- {
- UCHAR i;
-
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
- }
-#endif // QOS_DLS_SUPPORT //
-
// skip sanity check
pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);
@@ -999,27 +857,11 @@ VOID MlmeDisassocReqAction(
RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */
pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
}
/*
@@ -1057,31 +899,15 @@ VOID PeerAssocRspAction(
if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))
{
DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status));
-#ifdef DOT11_N_SUPPORT
DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem->Wcid, pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-#endif // DOT11_N_SUPPORT //
RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
if(Status == MLME_SUCCESS)
{
+#ifdef RT2860
// go to procedure listed on page 376
AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
&EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
wext_notify_event_assoc(pAd);
@@ -1091,9 +917,29 @@ VOID PeerAssocRspAction(
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif
+#ifdef RT2870
+ UCHAR MaxSupportedRateIn500Kbps = 0;
+ UCHAR idx;
+ // supported rates array may not be sorted. sort it and find the maximum rate
+ for (idx=0; idx<SupRateLen; idx++)
+ {
+ if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
+ MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
+ }
+
+ for (idx=0; idx<ExtRateLen; idx++)
+ {
+ if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
+ MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
+ }
+ // go to procedure listed on page 376
+ AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
+ &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
+ StaAddMacTableEntry(pAd, &pAd->MacTab.Content[BSSID_WCID], MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo);
+#endif
pAd->StaCfg.CkipFlag = CkipFlag;
if (CkipFlag & 0x18)
{
@@ -1109,14 +955,6 @@ VOID PeerAssocRspAction(
}
else
{
- // Faile on Association, we need to check the status code
- // Is that a Rogue AP?
-#ifdef LEAP_SUPPORT
- if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (Status == MLME_ALG_NOT_SUPPORT))
- { //Possibly Rogue AP
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, pAd->MlmeAux.Bssid, LEAP_REASON_INVALID_AUTH);
- }
-#endif // LEAP_SUPPORT //
}
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
@@ -1172,21 +1010,6 @@ VOID PeerReassocRspAction(
AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
&EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
wext_notify_event_assoc(pAd);
@@ -1196,41 +1019,9 @@ VOID PeerReassocRspAction(
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
}
- //
- // Cisco Leap CCKM supported Re-association.
- //
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- if (CCKMAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen) == TRUE)
- {
- pAd->StaCfg.CkipFlag = CkipFlag;
- if (CkipFlag & 0x18)
- {
- NdisZeroMemory(pAd->StaCfg.TxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.RxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.CKIPMIC, 4);
- pAd->StaCfg.GIV[0] = RandomByte(pAd);
- pAd->StaCfg.GIV[1] = RandomByte(pAd);
- pAd->StaCfg.GIV[2] = RandomByte(pAd);
- pAd->StaCfg.bCkipOn = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag));
- }
-
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - CCKMAssocRspSanity() sanity check fail\n"));
- }
- }
- else
-#endif // LEAP_SUPPORT //
{
// CkipFlag is no use for reassociate
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
@@ -1275,7 +1066,7 @@ VOID AssocPostProc(
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2);
pAd->MlmeAux.Aid = Aid;
pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
-#ifdef DOT11_N_SUPPORT
+
// Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on.
if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE))
{
@@ -1301,7 +1092,6 @@ VOID AssocPostProc(
pEdcaParm->Txop[3] = 48;
}
-#endif // DOT11_N_SUPPORT //
NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
@@ -1315,7 +1105,6 @@ VOID AssocPostProc(
NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-#ifdef DOT11_N_SUPPORT
if (HtCapabilityLen > 0)
{
RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
@@ -1324,7 +1113,6 @@ VOID AssocPostProc(
DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n",
pAd->MacTab.Content[BSSID_WCID].MmpsMode, pAd->MacTab.Content[BSSID_WCID].AMsduSize));
-#endif // DOT11_N_SUPPORT //
// Set New WPA information
Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
@@ -1414,21 +1202,6 @@ VOID PeerDisassocAction(
RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
}
-
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- // Cisco_LEAP has start a timer
- // We should cancel it if using LEAP
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
- //Check is it mach the LEAP Authentication failed as possible a Rogue AP
- //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Association.
- if ((pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
- }
- }
-#endif // LEAP_SUPPORT //
//
// Get Current System time and Turn on AdjacentAPReport
//
@@ -1437,26 +1210,11 @@ VOID PeerDisassocAction(
LinkDown(pAd, TRUE);
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
}
}
else
@@ -1739,36 +1497,6 @@ VOID SwitchBetweenWepAndCkip(
}
}
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-VOID SendAssocIEsToWpaSupplicant(
- IN PRTMP_ADAPTER pAd)
-{
- union iwreq_data wrqu;
- unsigned char custom[IW_CUSTOM_MAX] = {0};
-
- if ((pAd->StaCfg.ReqVarIELen + 17) <= IW_CUSTOM_MAX)
- {
- sprintf(custom, "ASSOCINFO_ReqIEs=");
- NdisMoveMemory(custom+17, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.length = pAd->StaCfg.ReqVarIELen + 17;
- wrqu.data.flags = RT_REQIE_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
-
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOCINFO_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen + 17 > MAX_CUSTOM_LEN\n"));
-
- return;
-}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
int wext_notify_event_assoc(
IN RTMP_ADAPTER *pAd)
{
@@ -1791,7 +1519,7 @@ int wext_notify_event_assoc(
wrqu.data.length = (pAd->StaCfg.ReqVarIELen*2) + 17;
sprintf(custom, "ASSOCINFO(ReqIEs=");
for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++)
- sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]);
+ sprintf(custom + strlen(custom), "%02x", pAd->StaCfg.ReqVarIEs[idx]);
wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
}
else
@@ -1801,5 +1529,227 @@ int wext_notify_event_assoc(
return 0;
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#ifdef RT2870
+BOOLEAN StaAddMacTableEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PMAC_TABLE_ENTRY pEntry,
+ IN UCHAR MaxSupportedRateIn500Kbps,
+ IN HT_CAPABILITY_IE *pHtCapability,
+ IN UCHAR HtCapabilityLen,
+ IN USHORT CapabilityInfo)
+{
+ UCHAR MaxSupportedRate = RATE_11;
+
+ if (ADHOC_ON(pAd))
+ CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
+
+ switch (MaxSupportedRateIn500Kbps)
+ {
+ case 108: MaxSupportedRate = RATE_54; break;
+ case 96: MaxSupportedRate = RATE_48; break;
+ case 72: MaxSupportedRate = RATE_36; break;
+ case 48: MaxSupportedRate = RATE_24; break;
+ case 36: MaxSupportedRate = RATE_18; break;
+ case 24: MaxSupportedRate = RATE_12; break;
+ case 18: MaxSupportedRate = RATE_9; break;
+ case 12: MaxSupportedRate = RATE_6; break;
+ case 22: MaxSupportedRate = RATE_11; break;
+ case 11: MaxSupportedRate = RATE_5_5; break;
+ case 4: MaxSupportedRate = RATE_2; break;
+ case 2: MaxSupportedRate = RATE_1; break;
+ default: MaxSupportedRate = RATE_11; break;
+ }
+
+ if ((pAd->CommonCfg.PhyMode == PHY_11G) && (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
+ return FALSE;
+
+ // 11n only
+ if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G))&& (HtCapabilityLen == 0))
+ return FALSE;
+
+ if (!pEntry)
+ return FALSE;
+
+ NdisAcquireSpinLock(&pAd->MacTabLock);
+ if (pEntry)
+ {
+ pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
+ if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) ||
+ (pAd->CommonCfg.PhyMode == PHY_11B))
+ {
+ pEntry->RateLen = 4;
+ if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE)
+ MaxSupportedRate = RATE_11;
+ }
+ else
+ pEntry->RateLen = 12;
+
+ pEntry->MaxHTPhyMode.word = 0;
+ pEntry->MinHTPhyMode.word = 0;
+ pEntry->HTPhyMode.word = 0;
+ pEntry->MaxSupportedRate = MaxSupportedRate;
+ if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
+ {
+ pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
+ pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
+ pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
+ pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
+ pEntry->HTPhyMode.field.MODE = MODE_CCK;
+ pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
+ }
+ else
+ {
+ pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
+ pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
+ pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
+ pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
+ pEntry->HTPhyMode.field.MODE = MODE_OFDM;
+ pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
+ }
+ pEntry->CapabilityInfo = CapabilityInfo;
+ CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
+ CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE);
+ }
+
+ // If this Entry supports 802.11n, upgrade to HT rate.
+ if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
+ {
+ UCHAR j, bitmask; //k,bitmask;
+ CHAR i;
+
+ if (ADHOC_ON(pAd))
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
+ if ((pHtCapability->HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
+ {
+ pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
+ }
+ else
+ {
+ pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
+ pAd->MacTab.fAnyStationNonGF = TRUE;
+ pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
+ }
+
+ if ((pHtCapability->HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
+ {
+ pEntry->MaxHTPhyMode.field.BW= BW_40;
+ pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(pHtCapability->HtCapInfo.ShortGIfor40));
+ }
+ else
+ {
+ pEntry->MaxHTPhyMode.field.BW = BW_20;
+ pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(pHtCapability->HtCapInfo.ShortGIfor20));
+ pAd->MacTab.fAnyStation20Only = TRUE;
+ }
+
+ // 3*3
+ if (pAd->MACVersion >= RALINK_2883_VERSION && pAd->MACVersion < RALINK_3070_VERSION)
+ pEntry->MaxHTPhyMode.field.TxBF = pAd->CommonCfg.RegTransmitSetting.field.TxBF;
+
+ // find max fixed rate
+ for (i=23; i>=0; i--) // 3*3
+ {
+ j = i/8;
+ bitmask = (1<<(i-(j*8)));
+ if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask) && (pHtCapability->MCSSet[j] & bitmask))
+ {
+ pEntry->MaxHTPhyMode.field.MCS = i;
+ break;
+ }
+ if (i==0)
+ break;
+ }
+
+
+ if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
+ {
+ if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
+ {
+ // Fix MCS as HT Duplicated Mode
+ pEntry->MaxHTPhyMode.field.BW = 1;
+ pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
+ pEntry->MaxHTPhyMode.field.STBC = 0;
+ pEntry->MaxHTPhyMode.field.ShortGI = 0;
+ pEntry->MaxHTPhyMode.field.MCS = 32;
+ }
+ else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
+ {
+ // STA supports fixed MCS
+ pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
+ }
+ }
+
+ pEntry->MaxHTPhyMode.field.STBC = (pHtCapability->HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
+ pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity;
+ pEntry->MaxRAmpduFactor = pHtCapability->HtCapParm.MaxRAmpduFactor;
+ pEntry->MmpsMode = (UCHAR)pHtCapability->HtCapInfo.MimoPs;
+ pEntry->AMsduSize = (UCHAR)pHtCapability->HtCapInfo.AMsduSize;
+ pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
+
+ if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED);
+ if (pHtCapability->HtCapInfo.ShortGIfor20)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
+ if (pHtCapability->HtCapInfo.ShortGIfor40)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
+ if (pHtCapability->HtCapInfo.TxSTBC)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
+ if (pHtCapability->HtCapInfo.RxSTBC)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
+ if (pHtCapability->ExtHtCapInfo.PlusHTC)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
+ if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
+ if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03)
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
+ }
+ else
+ {
+ pAd->MacTab.fAnyStationIsLegacy = TRUE;
+ }
+
+ NdisMoveMemory(&pEntry->HTCapability, pHtCapability, sizeof(HT_CAPABILITY_IE));
+
+ pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
+ pEntry->CurrTxRate = pEntry->MaxSupportedRate;
+
+ // Set asic auto fall back
+ if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
+ {
+ PUCHAR pTable;
+ UCHAR TableSize = 0;
+
+ MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
+ pEntry->bAutoTxRateSwitch = TRUE;
+ }
+ else
+ {
+ pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
+ pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
+ pEntry->bAutoTxRateSwitch = FALSE;
+
+ // If the legacy mode is set, overwrite the transmit setting of this entry.
+ RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
+ }
+
+ pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
+ pEntry->Sst = SST_ASSOC;
+ pEntry->AuthState = AS_AUTH_OPEN;
+ pEntry->AuthMode = pAd->StaCfg.AuthMode;
+ pEntry->WepStatus = pAd->StaCfg.WepStatus;
+
+ NdisReleaseSpinLock(&pAd->MacTabLock);
+
+ {
+ union iwreq_data wrqu;
+ wext_notify_event_assoc(pAd);
+
+ memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
+ memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
+ wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
+
+ }
+ return TRUE;
+}
+#endif /* RT2870 */
diff --git a/drivers/staging/rt2860/sta/auth.c b/drivers/staging/rt2860/sta/auth.c
index 73fb8d6ea76f..d8414eac42f8 100644
--- a/drivers/staging/rt2860/sta/auth.c
+++ b/drivers/staging/rt2860/sta/auth.c
@@ -218,15 +218,9 @@ VOID PeerAuthRspAtSeq2Action(
{
// Authentication Mode "LEAP" has allow for CCX 1.X
if ((pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
)
{
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-#ifdef LEAP_SUPPORT
- pAd->Mlme.LeapMachine.CurrState = LEAP_IDLE;
-#endif // LEAP_SUPPORT //
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
else
@@ -282,14 +276,6 @@ VOID PeerAuthRspAtSeq2Action(
}
else
{
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- //Invalid Authentication possible rogue AP
- //Add this Ap to Rogue AP.
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_INVALID_AUTH);
- }
-#endif // LEAP_SUPPORT //
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
diff --git a/drivers/staging/rt2860/sta/auth_rsp.c b/drivers/staging/rt2860/sta/auth_rsp.c
index f7aa4b99cf56..cc639b1c6c13 100644
--- a/drivers/staging/rt2860/sta/auth_rsp.c
+++ b/drivers/staging/rt2860/sta/auth_rsp.c
@@ -127,36 +127,17 @@ VOID PeerDeauthAction(
{
DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason));
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
// send wireless event - for deauthentication
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
LinkDown(pAd, TRUE);
-
- // Authentication Mode Cisco_LEAP has start a timer
- // We should cancel it if using LEAP
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
- //Check is it mach the LEAP Authentication failed as possible a Rogue AP
- //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Authenticaton.
- if ((pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED) && (pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE))
- {
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
- }
- }
-#endif // LEAP_SUPPORT //
}
}
else
diff --git a/drivers/staging/rt2860/sta/connect.c b/drivers/staging/rt2860/sta/connect.c
index d8bcc76688a6..ac7135186665 100644
--- a/drivers/staging/rt2860/sta/connect.c
+++ b/drivers/staging/rt2860/sta/connect.c
@@ -178,13 +178,6 @@ VOID MlmeCntlMachinePerformAction(
pAd->bLedOnScanning = FALSE;
RTMPSetLED(pAd, pAd->LedStatus);
}
-#ifdef DOT11N_DRAFT3
- // AP sent a 2040Coexistence mgmt frame, then station perform a scan, and then send back the respone.
- if (pAd->CommonCfg.BSSCoexist2040.field.InfoReq == 1)
- {
- Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE);
- }
-#endif // DOT11N_DRAFT3 //
}
break;
@@ -195,6 +188,38 @@ VOID MlmeCntlMachinePerformAction(
pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
}
break;
+#ifdef RT2870
+ //
+ // This state is for that we want to connect to an AP but
+ // it didn't find on BSS List table. So we need to scan the air first,
+ // after that we can try to connect to the desired AP if available.
+ //
+ case CNTL_WAIT_SCAN_FOR_CONNECT:
+ if(Elem->MsgType == MT2_SCAN_CONF)
+ {
+ // Resume TxRing after SCANING complete. We hope the out-of-service time
+ // won't be too long to let upper layer time-out the waiting frames
+ RTMPResumeMsduTransmission(pAd);
+#ifdef CCX_SUPPORT
+ if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED)
+ {
+ // Cisco scan request is finished, prepare beacon report
+ MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
+ }
+#endif // CCX_SUPPORT //
+ pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
+
+ //
+ // Check if we can connect to.
+ //
+ BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
+ if (pAd->MlmeAux.SsidBssTab.BssNr > 0)
+ {
+ MlmeAutoReconnectLastSSID(pAd);
+ }
+ }
+ break;
+#endif // RT2870 //
default:
DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem->MsgType));
break;
@@ -234,19 +259,11 @@ VOID CntlIdleProc(
break;
case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-#ifdef WPA_SUPPLICANT_SUPPORT
+
if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE_WITH_WEB_UI)
-#endif // WPA_SUPPLICANT_SUPPORT //
{
// Set the AutoReconnectSsid to prevent it reconnect to old SSID
// Since calling this indicate user don't want to connect to that SSID anymore.
@@ -263,12 +280,6 @@ VOID CntlIdleProc(
WpaMicFailureReportFrame(pAd, Elem);
break;
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS_PARAM:
- CntlOidDLSSetupProc(pAd, Elem);
- break;
-#endif // QOS_DLS_SUPPORT //
-
default:
DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem->MsgType));
break;
@@ -283,13 +294,6 @@ VOID CntlOidScanProc(
ULONG BssIdx = BSS_NOT_FOUND;
BSS_ENTRY CurrBss;
-#ifdef RALINK_ATE
-/* Disable scanning when ATE is running. */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
// record current BSS if network is connected.
// 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
@@ -337,9 +341,11 @@ VOID CntlOidSsidProc(
MLME_DISASSOC_REQ_STRUCT DisassocReq;
ULONG Now;
+#ifdef RT2860
// BBP and RF are not accessible in PS mode, we has to wake them up first
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
AsicForceWakeup(pAd, RTMP_HALT);
+#endif
// Step 1. record the desired user settings to MlmeAux
NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
@@ -377,9 +383,6 @@ VOID CntlOidSsidProc(
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
) &&
(pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
{
@@ -420,7 +423,7 @@ VOID CntlOidSsidProc(
}
pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+
{
union iwreq_data wrqu;
@@ -429,7 +432,6 @@ VOID CntlOidSsidProc(
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
}
}
else if (INFRA_ON(pAd))
@@ -513,12 +515,6 @@ VOID CntlOidRTBssidProc(
MLME_DISASSOC_REQ_STRUCT DisassocReq;
MLME_JOIN_REQ_STRUCT JoinReq;
-#ifdef RALINK_ATE
-/* No need to perform this routine when ATE is running. */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
// record user desired settings
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pOidBssid);
pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
@@ -558,7 +554,7 @@ VOID CntlOidRTBssidProc(
// already connected to the same BSSID, go back to idle state directly
DBGPRINT(RT_DEBUG_TRACE, ("CNTL - already in this BSSID. ignore this SET_BSSID request\n"));
pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+
{
union iwreq_data wrqu;
@@ -567,7 +563,6 @@ VOID CntlOidRTBssidProc(
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
}
else
{
@@ -672,113 +667,6 @@ VOID CntlMlmeRoamingProc(
IterateOnBssTab(pAd);
}
-#ifdef QOS_DLS_SUPPORT
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidDLSSetupProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRT_802_11_DLS pDLS = (PRT_802_11_DLS)Elem->Msg;
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- INT i;
- USHORT reason = REASON_UNSPECIFY;
-
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - (OID set %02x:%02x:%02x:%02x:%02x:%02x with Valid=%d, Status=%d, TimeOut=%d, CountDownTimer=%d)\n",
- pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5],
- pDLS->Valid, pDLS->Status, pDLS->TimeOut, pDLS->CountDownTimer));
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- // DLS will not be supported when Adhoc mode
- if (INFRA_ON(pAd))
- {
- for (i = 0; i < MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- (pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 1. Same setting, just drop it
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - setting unchanged\n"));
- break;
- }
- else if (!pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 2. Disable DLS link case, just tear down DLS link
- reason = REASON_QOS_UNWANTED_MECHANISM;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - start tear down procedure\n"));
- break;
- }
- else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid)
- {
- // 3. Enable case, start DLS setup procedure
- NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
-
- //Update countdown timer
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS setup case\n"));
- break;
- }
- else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 4. update mac case, tear down old DLS and setup new DLS
- reason = REASON_QOS_UNWANTED_MECHANISM;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS tear down and restart case\n"));
- break;
- }
- else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut))
- {
- // 5. update timeout case, start DLS setup procedure (no tear down)
- pAd->StaCfg.DLSEntry[i].TimeOut = pDLS->TimeOut;
- //Update countdown timer
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS update timeout case\n"));
- break;
- }
- else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- (pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 6. re-setup case, start DLS setup procedure (no tear down)
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS retry setup procedure\n"));
- break;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN,("CNTL - DLS not changed in entry - %d - Valid=%d, Status=%d, TimeOut=%d\n",
- i, pAd->StaCfg.DLSEntry[i].Valid, pAd->StaCfg.DLSEntry[i].Status, pAd->StaCfg.DLSEntry[i].TimeOut));
- }
- }
- }
-}
-#endif // QOS_DLS_SUPPORT //
-
/*
==========================================================================
Description:
@@ -870,14 +758,6 @@ VOID CntlWaitJoinProc(
// 2. joined a new INFRA network, start from authentication
else
{
-#ifdef LEAP_SUPPORT
- // Add AuthMode "LEAP" for CCX 1.X
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
- }
- else
-#endif // LEAP_SUPPORT //
{
// either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
@@ -937,7 +817,7 @@ VOID CntlWaitStartProc(
DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
return;
}
-#ifdef DOT11_N_SUPPORT
+
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
N_ChannelCheck(pAd);
@@ -961,7 +841,6 @@ VOID CntlWaitStartProc(
}
}
else
-#endif // DOT11_N_SUPPORT //
{
pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
}
@@ -974,9 +853,6 @@ VOID CntlWaitStartProc(
{
pAd->CommonCfg.RadarDetect.RDMode = RD_SILENCE_MODE;
pAd->CommonCfg.RadarDetect.RDCount = 0;
-#ifdef DFS_SUPPORT
- BbpRadarDetectionStart(pAd);
-#endif // DFS_SUPPORT //
}
DBGPRINT(RT_DEBUG_TRACE, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
@@ -1016,21 +892,6 @@ VOID CntlWaitAuthProc(
AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
-#ifdef LEAP_SUPPORT
- //
- // Cisco Leap CCKM supported Re-association.
- //
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- //if CCKM is turn on , that's mean Fast Reauthentication
- //Use CCKM Reassociation instead of normal association for Fast Roaming.
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
- }
- else
-#endif // LEAP_SUPPORT //
{
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
@@ -1044,14 +905,7 @@ VOID CntlWaitAuthProc(
// ageing-out. The previous authentication attempt must have let it remove us.
// so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try again...\n"));
-#ifdef LEAP_SUPPORT
- //Add AuthMode "LEAP" for CCX 1.X
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
- }
- else
-#endif // LEAP_SUPPORT //
+
{
if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
@@ -1103,20 +957,6 @@ VOID CntlWaitAuthProc2(
}
else
{
-#ifdef LEAP_SUPPORT
- // Process LEAP first, since it use different control variable
- // We don't want to affect other poven operation
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- // LEAP Auth not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - *LEAP* AUTH FAIL, give up; try next BSS\n"));
- DBGPRINT(RT_DEBUG_TRACE, ("Total match BSSID [=%d]\n", pAd->MlmeAux.SsidBssTab.BssNr));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- else
-#endif // LEAP_SUPPORT //
if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) &&
(pAd->MlmeAux.Alg == Ndis802_11AuthModeShared))
{
@@ -1205,14 +1045,6 @@ VOID CntlWaitReassocProc(
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd))
- {
- STA_PORT_SECURED(pAd);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
-#endif // LEAP_SUPPORT //
pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
}
@@ -1226,6 +1058,44 @@ VOID CntlWaitReassocProc(
}
}
+
+#ifdef RT2870
+VOID AdhocTurnOnQos(
+ IN PRTMP_ADAPTER pAd)
+{
+#define AC0_DEF_TXOP 0
+#define AC1_DEF_TXOP 0
+#define AC2_DEF_TXOP 94
+#define AC3_DEF_TXOP 47
+
+ // Turn on QOs if use HT rate.
+ if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
+ {
+ pAd->CommonCfg.APEdcaParm.bValid = TRUE;
+ pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
+ pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
+ pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
+ pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
+
+ pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
+ pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
+ pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
+ pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
+
+ pAd->CommonCfg.APEdcaParm.Cwmax[0] = 10;
+ pAd->CommonCfg.APEdcaParm.Cwmax[1] = 6;
+ pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
+ pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
+
+ pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
+ pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
+ pAd->CommonCfg.APEdcaParm.Txop[2] = AC2_DEF_TXOP;
+ pAd->CommonCfg.APEdcaParm.Txop[3] = AC3_DEF_TXOP;
+ }
+ AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
+}
+#endif /* RT2870 */
+
/*
==========================================================================
Description:
@@ -1244,12 +1114,14 @@ VOID LinkUp(
UCHAR Value = 0, idx;
MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
+#ifdef RT2860
if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
{
RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
RTMPusecDelay(6000);
pAd->bPCIclkOff = FALSE;
}
+#endif
pEntry = &pAd->MacTab.Content[BSSID_WCID];
@@ -1266,15 +1138,15 @@ VOID LinkUp(
COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-#ifdef DOT11_N_SUPPORT
COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-#endif // DOT11_N_SUPPORT //
+
// It's quite difficult to tell if a newly added KEY is WEP or CKIP until a new BSS
// is formed (either ASSOC/RE-ASSOC done or IBSS started. LinkUP should be a safe place
// to examine if cipher algorithm switching is required.
//rt2860b. Don't know why need this
SwitchBetweenWepAndCkip(pAd);
+#ifdef RT2860
// Before power save before link up function, We will force use 1R.
// So after link up, check Rx antenna # again.
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
@@ -1292,17 +1164,30 @@ VOID LinkUp(
}
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
pAd->StaCfg.BBPR3 = Value;
+#endif /* RT2860 */
if (BssType == BSS_ADHOC)
{
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON);
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // No carrier detection when adhoc
- // CarrierDetectionStop(pAd);
- pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL;
-#endif // CARRIER_DETECTION_SUPPORT //
+#ifdef RT30xx
+ if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
+ (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE))
+ {
+ pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
+ }
+ else if ((pAd->CommonCfg.Channel > 2) &&
+ (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
+ (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW))
+ {
+ pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
+ }
+#endif
+#ifdef RT2870
+ if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
+ AdhocTurnOnQos(pAd);
+#endif
DBGPRINT(RT_DEBUG_TRACE, ("!!!Adhoc LINK UP !!! \n" ));
}
@@ -1321,7 +1206,6 @@ VOID LinkUp(
Value |= pAd->CommonCfg.RegTransmitSetting.field.TxBF;
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-#ifdef DOT11_N_SUPPORT
// Change to AP channel
if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
{
@@ -1339,7 +1223,9 @@ VOID LinkUp(
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
Value &= (~0x20);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
+#ifdef RT2860
pAd->StaCfg.BBPR3 = Value;
+#endif
RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
Data &= 0xfffffffe;
@@ -1374,7 +1260,9 @@ VOID LinkUp(
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
Value |= (0x20);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
+#ifdef RT2860
pAd->StaCfg.BBPR3 = Value;
+#endif
if (pAd->MACVersion == 0x28600100)
{
@@ -1387,7 +1275,6 @@ VOID LinkUp(
DBGPRINT(RT_DEBUG_TRACE, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
}
else
-#endif // DOT11_N_SUPPORT //
{
pAd->CommonCfg.BBPCurrentBW = BW_20;
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
@@ -1405,7 +1292,9 @@ VOID LinkUp(
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
Value &= (~0x20);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
+#ifdef RT2860
pAd->StaCfg.BBPR3 = Value;
+#endif
if (pAd->MACVersion == 0x28600100)
{
@@ -1427,9 +1316,7 @@ VOID LinkUp(
DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
-#ifdef DOT11_N_SUPPORT
DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Density =%d, )\n", pAd->MacTab.Content[BSSID_WCID].MpduDensity));
-#endif // DOT11_N_SUPPORT //
AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
@@ -1439,7 +1326,6 @@ VOID LinkUp(
// Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit
AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE, FALSE);
-#ifdef DOT11_N_SUPPORT
if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))
{
// Update HT protectionfor based on AP's operating mode.
@@ -1450,7 +1336,6 @@ VOID LinkUp(
else
AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
}
-#endif // DOT11_N_SUPPORT //
NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS));
@@ -1467,9 +1352,6 @@ VOID LinkUp(
if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE)
{
-#ifdef DFS_SUPPORT
- RadarDetectionStop(pAd);
-#endif // DFS_SUPPORT //
}
pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
@@ -1602,7 +1484,9 @@ VOID LinkUp(
IV |= (pAd->StaCfg.DefaultKeyId << 30);
AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
+#ifdef RT2860
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+#endif
}
// NOTE:
// the decision of using "short slot time" or not may change dynamically due to
@@ -1643,15 +1527,11 @@ VOID LinkUp(
// If WEP is enabled, add paiewise and shared key
-#ifdef WPA_SUPPLICANT_SUPPORT
if (((pAd->StaCfg.WpaSupplicantUP)&&
(pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)&&
(pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) ||
((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)&&
(pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)))
-#else
- if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
-#endif // WPA_SUPPLICANT_SUPPORT //
{
PUCHAR Key;
UCHAR CipherAlg;
@@ -1687,9 +1567,14 @@ VOID LinkUp(
{
pAd->IndicateMediaState = NdisMediaStateConnected;
pAd->ExtraInfo = GENERAL_LINK_UP;
+#ifdef RT2870
+ RTMP_IndicateMediaState(pAd);
+#endif
}
// --
+#ifdef RT2860
RTMP_IndicateMediaState(pAd);
+#endif
// Add BSSID in my MAC Table.
NdisAcquireSpinLock(&pAd->MacTabLock);
@@ -1700,6 +1585,9 @@ VOID LinkUp(
pAd->MacTab.Size = 1; // infra mode always set MACtab size =1.
pAd->MacTab.Content[BSSID_WCID].Sst = SST_ASSOC;
pAd->MacTab.Content[BSSID_WCID].AuthState = SST_ASSOC;
+#ifdef RT30xx
+ pAd->MacTab.Content[BSSID_WCID].AuthMode = pAd->StaCfg.AuthMode;
+#endif
pAd->MacTab.Content[BSSID_WCID].WepStatus = pAd->StaCfg.WepStatus;
NdisReleaseSpinLock(&pAd->MacTabLock);
@@ -1707,17 +1595,8 @@ VOID LinkUp(
pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
MlmeUpdateTxRates(pAd, TRUE, BSS0);
-#ifdef DOT11_N_SUPPORT
MlmeUpdateHtTxRates(pAd, BSS0);
DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd->StaActive.SupportedPhyInfo.bHtEnable));
-#endif // DOT11_N_SUPPORT //
-
- //
- // Report Adjacent AP report.
- //
-#ifdef LEAP_SUPPORT
- CCXAdjacentAPReport(pAd);
-#endif // LEAP_SUPPORT //
if (pAd->CommonCfg.bAggregationCapable)
{
@@ -1737,12 +1616,11 @@ VOID LinkUp(
if (pAd->MlmeAux.APRalinkIe != 0x0)
{
-#ifdef DOT11_N_SUPPORT
if (CLIENT_STATUS_TEST_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RDG_CAPABLE))
{
AsicEnableRDG(pAd);
}
-#endif // DOT11_N_SUPPORT //
+
OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);
}
@@ -1753,9 +1631,7 @@ VOID LinkUp(
}
}
-#ifdef DOT11_N_SUPPORT
DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n", pAd->CommonCfg.BACapability.word, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-#endif // DOT11_N_SUPPORT //
// Set LED
RTMPSetLED(pAd, LED_LINK_UP);
@@ -1780,13 +1656,13 @@ VOID LinkUp(
if (pAd->StaCfg.bAutoTxRateSwitch == FALSE)
{
pEntry->bAutoTxRateSwitch = FALSE;
-#ifdef DOT11_N_SUPPORT
+
if (pEntry->HTPhyMode.field.MCS == 32)
pEntry->HTPhyMode.field.ShortGI = GI_800;
if ((pEntry->HTPhyMode.field.MCS > MCS_7) || (pEntry->HTPhyMode.field.MCS == 32))
pEntry->HTPhyMode.field.STBC = STBC_NONE;
-#endif // DOT11_N_SUPPORT //
+
// If the legacy mode is set, overwrite the transmit setting of this entry.
if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM)
RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
@@ -1815,7 +1691,6 @@ VOID LinkUp(
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
}
-#ifdef DOT11_N_SUPPORT
if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
{
}
@@ -1825,7 +1700,6 @@ VOID LinkUp(
// Because our Init value is 1 at MACRegTable.
RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff);
}
-#endif // DOT11_N_SUPPORT //
// Patch for Marvel AP to gain high throughput
// Need to set as following,
@@ -1837,9 +1711,15 @@ VOID LinkUp(
// Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable
//
// if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is.
-#ifdef DOT11_N_SUPPORT
+#ifdef RT30xx
+ if (!((pAd->CommonCfg.RxStream == 1)&&(pAd->CommonCfg.TxStream == 1)) &&
+ (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
+ || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE))))
+#endif
+#ifndef RT30xx
if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)))
|| ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)))
+#endif
{
RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
Data &= 0xFFFFFF00;
@@ -1849,7 +1729,6 @@ VOID LinkUp(
DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n"));
}
else
-#endif // DOT11_N_SUPPORT //
if (pAd->CommonCfg.bEnableTxBurst)
{
RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
@@ -1871,7 +1750,6 @@ VOID LinkUp(
DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n"));
}
-#ifdef DOT11_N_SUPPORT
// Re-check to turn on TX burst or not.
if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) && ((STA_WEP_ON(pAd))||(STA_TKIP_ON(pAd))))
{
@@ -1891,7 +1769,6 @@ VOID LinkUp(
{
pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE;
}
-#endif // DOT11_N_SUPPORT //
pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE;
COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
@@ -1924,17 +1801,9 @@ VOID LinkUp(
}
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
+#ifdef RT2860
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if ((pAd->CommonCfg.BACapability.field.b2040CoexistScanSup) && (pAd->CommonCfg.Channel <= 11))
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SCAN_2040);
- BuildEffectedChannelList(pAd);
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
+#endif
}
/*
@@ -1967,23 +1836,21 @@ VOID LinkDown(
IN BOOLEAN IsReqFromAP)
{
UCHAR i, ByteValue = 0;
+#ifdef RT2860
BOOLEAN Cancelled;
+#endif
// Do nothing if monitor mode is on
if (MONITOR_ON(pAd))
return;
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
+#ifdef RT2860
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
// Not allow go to sleep within linkdown function.
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+#endif
if (pAd->CommonCfg.bWirelessEvent)
{
@@ -1993,6 +1860,7 @@ VOID LinkDown(
DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n"));
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
BOOLEAN Cancelled;
@@ -2009,6 +1877,7 @@ VOID LinkDown(
}
pAd->bPCIclkOff = FALSE;
+#endif
if (ADHOC_ON(pAd)) // Adhoc mode link down
{
DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n"));
@@ -2025,33 +1894,6 @@ VOID LinkDown(
{
DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n"));
-#ifdef QOS_DLS_SUPPORT
- // DLS tear down frame must be sent before link down
- // send DLS-TEAR_DOWN message
- if (pAd->CommonCfg.bDLSCapable)
- {
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-#endif // QOS_DLS_SUPPORT //
-
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
@@ -2095,17 +1937,6 @@ VOID LinkDown(
NdisMoveMemory(pAd->StaCfg.CCXAdjacentAPSsid, pAd->CommonCfg.Ssid, pAd->StaCfg.CCXAdjacentAPSsidLen);
COPY_MAC_ADDR(pAd->StaCfg.CCXAdjacentAPBssid, pAd->CommonCfg.Bssid);
}
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // Country IE of the AP will be evaluated and will be used.
- if (pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None)
- {
- NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pAd->StaCfg.StaOriCountryCode[0], 2);
- pAd->CommonCfg.Geography = pAd->StaCfg.StaOriGeography;
- BuildChannelListEx(pAd);
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
}
for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
@@ -2137,12 +1968,11 @@ VOID LinkDown(
NdisZeroMemory(pAd->CommonCfg.Ssid, MAX_LEN_OF_SSID);
pAd->CommonCfg.SsidLen = 0;
}
-#ifdef DOT11_N_SUPPORT
+
NdisZeroMemory(&pAd->MlmeAux.HtCapability, sizeof(HT_CAPABILITY_IE));
NdisZeroMemory(&pAd->MlmeAux.AddHtInfo, sizeof(ADD_HT_INFO_IE));
pAd->MlmeAux.HtCapabilityLen = 0;
pAd->MlmeAux.NewExtChannelOffset = 0xff;
-#endif // DOT11_N_SUPPORT //
// Reset WPA-PSK state. Only reset when supplicant enabled
if (pAd->StaCfg.WpaState != SS_NOTUSE)
@@ -2150,11 +1980,6 @@ VOID LinkDown(
pAd->StaCfg.WpaState = SS_START;
// Clear Replay counter
NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
-
-#ifdef QOS_DLS_SUPPORT
- if (pAd->CommonCfg.bDLSCapable)
- NdisZeroMemory(pAd->StaCfg.DlsReplayCounter, 8);
-#endif // QOS_DLS_SUPPORT //
}
@@ -2169,7 +1994,7 @@ VOID LinkDown(
}
// 802.1x port control
-#ifdef WPA_SUPPLICANT_SUPPORT
+
// Prevent clear PortSecured here with static WEP
// NetworkManger set security policy first then set SSID to connect AP.
if (pAd->StaCfg.WpaSupplicantUP &&
@@ -2179,7 +2004,6 @@ VOID LinkDown(
pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
}
else
-#endif // WPA_SUPPLICANT_SUPPORT //
{
pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
@@ -2199,13 +2023,18 @@ VOID LinkDown(
// Update extra information to link is up
pAd->ExtraInfo = GENERAL_LINK_DOWN;
+#ifdef RT2860
pAd->StaCfg.AdhocBOnlyJoined = FALSE;
pAd->StaCfg.AdhocBGJoined = FALSE;
pAd->StaCfg.Adhoc20NJoined = FALSE;
+#endif
pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
// Reset the Current AP's IP address
NdisZeroMemory(pAd->StaCfg.AironetIPAddress, 4);
+#ifdef RT2870
+ pAd->bUsbTxBulkAggre = FALSE;
+#endif // RT2870 //
// Clean association information
NdisZeroMemory(&pAd->StaCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));
@@ -2227,7 +2056,6 @@ VOID LinkDown(
pAd->CommonCfg.MlmeRate = pAd->CommonCfg.BasicMlmeRate;
pAd->CommonCfg.RtsRate = pAd->CommonCfg.BasicMlmeRate;
-#ifdef DOT11_N_SUPPORT
//
// After Link down, reset piggy-back setting in ASIC. Disable RDG.
//
@@ -2238,7 +2066,7 @@ VOID LinkDown(
ByteValue &= (~0x18);
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, ByteValue);
}
-#endif // DOT11_N_SUPPORT //
+
// Reset DAC
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &ByteValue);
ByteValue &= (~0x18);
@@ -2251,9 +2079,7 @@ VOID LinkDown(
RTMPSetPiggyBack(pAd,FALSE);
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
-#ifdef DOT11_N_SUPPORT
pAd->CommonCfg.BACapability.word = pAd->CommonCfg.REGBACapability.word;
-#endif // DOT11_N_SUPPORT //
// Restore all settings in the following.
AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT|CCKSETPROTECT|OFDMSETPROTECT), TRUE, FALSE);
@@ -2261,43 +2087,35 @@ VOID LinkDown(
pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE;
pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SCAN_2040);
- pAd->CommonCfg.BSSCoexist2040.word = 0;
- TriEventInit(pAd);
- for (i = 0; i < (pAd->ChannelListNum - 1); i++)
- {
- pAd->ChannelList[i].bEffectedChannel = FALSE;
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
+#ifdef RT2860
// Allow go to sleep after linkdown steps.
RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+#endif
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP) {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+
+#ifdef RT30xx
+ if (IS_RT3090(pAd))
+ {
+ UINT32 macdata;
+ // disable MMPS BBP control register
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &ByteValue);
+ ByteValue &= ~(0x04); //bit 2
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, ByteValue);
+
+ // disable MMPS MAC control register
+ RTMP_IO_READ32(pAd, 0x1210, &macdata);
+ macdata &= ~(0x09); //bit 0, 3
+ RTMP_IO_WRITE32(pAd, 0x1210, macdata);
+ }
+#endif // RT30xx //
}
/*
@@ -2457,26 +2275,6 @@ VOID ScanParmFill(
ScanReq->ScanType = ScanType;
}
-#ifdef QOS_DLS_SUPPORT
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID DlsParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
- IN PRT_802_11_DLS pDls,
- IN USHORT reason)
-{
- pDlsReq->pDLS = pDls;
- pDlsReq->Reason = reason;
-}
-#endif // QOS_DLS_SUPPORT //
-
/*
==========================================================================
Description:
@@ -2523,21 +2321,61 @@ VOID AuthParmFill(
==========================================================================
*/
+
+
+#ifdef RT2870
+
+VOID MlmeCntlConfirm(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG MsgType,
+ IN USHORT Msg)
+{
+ MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg);
+}
+#endif
+
VOID ComposePsPoll(
IN PRTMP_ADAPTER pAd)
{
+#ifdef RT2870
+ PTXINFO_STRUC pTxInfo;
+ PTXWI_STRUC pTxWI;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("ComposePsPoll\n"));
+#endif
NdisZeroMemory(&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
+
+#ifdef RT2870
+ pAd->PsPollFrame.FC.PwrMgmt = 0;
+#endif
pAd->PsPollFrame.FC.Type = BTYPE_CNTL;
pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL;
pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000;
COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid);
COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress);
+
+#ifdef RT2870
+ RTMPZeroMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0], 100);
+ pTxInfo = (PTXINFO_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0];
+ RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(PSPOLL_FRAME)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
+ pTxWI = (PTXWI_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
+ RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(PSPOLL_FRAME)),
+ 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
+ RTMPMoveMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
+ // Append 4 extra zero bytes.
+ pAd->PsPollContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(PSPOLL_FRAME) + 4;
+#endif
}
// IRQL = DISPATCH_LEVEL
VOID ComposeNullFrame(
IN PRTMP_ADAPTER pAd)
{
+#ifdef RT2870
+ PTXINFO_STRUC pTxInfo;
+ PTXWI_STRUC pTxWI;
+#endif
+
NdisZeroMemory(&pAd->NullFrame, sizeof(HEADER_802_11));
pAd->NullFrame.FC.Type = BTYPE_DATA;
pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC;
@@ -2545,6 +2383,16 @@ VOID ComposeNullFrame(
COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid);
COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress);
COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid);
+#ifdef RT2870
+ RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[0], 100);
+ pTxInfo = (PTXINFO_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[0];
+ RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(HEADER_802_11)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
+ pTxWI = (PTXWI_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
+ RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(HEADER_802_11)),
+ 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
+ RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
+ pAd->NullContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
+#endif
}
@@ -2688,22 +2536,15 @@ ULONG MakeIbssBeacon(
FrameLen += tmp;
}
-#ifdef DOT11_N_SUPPORT
if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
ULONG TmpLen;
UCHAR HtLen, HtLen1;
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
- ADD_HT_INFO_IE addHTInfoTmp;
- USHORT b2lTmp, b2lTmp2;
-#endif
-
// add HT Capability IE
HtLen = sizeof(pAd->CommonCfg.HtCapability);
HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo);
-#ifndef RT_BIG_ENDIAN
+
MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen,
1, &HtCapIe,
1, &HtLen,
@@ -2712,27 +2553,9 @@ ULONG MakeIbssBeacon(
1, &HtLen1,
HtLen1, &pAd->CommonCfg.AddHTInfo,
END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- NdisMoveMemory(&addHTInfoTmp, &pAd->CommonCfg.AddHTInfo, HtLen1);
- *(USHORT *)(&addHTInfoTmp.AddHtInfo2) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo2));
- *(USHORT *)(&addHTInfoTmp.AddHtInfo3) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo3));
- MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- 1, &AddHtInfoIe,
- 1, &HtLen1,
- HtLen1, &addHTInfoTmp,
- END_OF_ARGS);
-#endif
FrameLen += TmpLen;
}
-#endif // DOT11_N_SUPPORT //
//beacon use reserved WCID 0xff
if (pAd->CommonCfg.Channel > 14)
@@ -2749,11 +2572,6 @@ ULONG MakeIbssBeacon(
PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &Transmit);
}
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, pBeaconFrame, DIR_WRITE, FALSE);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif
-
DBGPRINT(RT_DEBUG_TRACE, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel, pAd->CommonCfg.PhyMode));
return FrameLen;
diff --git a/drivers/staging/rt2860/sta/dls.c b/drivers/staging/rt2860/sta/dls.c
deleted file mode 100644
index 873cf7f1de93..000000000000
--- a/drivers/staging/rt2860/sta/dls.c
+++ /dev/null
@@ -1,2197 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- dls.c
-
- Abstract:
- Handle WMM-DLS state machine
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 02-14-2006
- Arvin Tai 06-03-2008 Modified for RT28xx
- */
-
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- dls state machine init, including state transition and timer init
- Parameters:
- Sm - pointer to the dls state machine
- Note:
- The state machine looks like this
-
- DLS_IDLE
- MT2_MLME_DLS_REQUEST MlmeDlsReqAction
- MT2_PEER_DLS_REQUEST PeerDlsReqAction
- MT2_PEER_DLS_RESPONSE PeerDlsRspAction
- MT2_MLME_DLS_TEARDOWN MlmeTearDownAction
- MT2_PEER_DLS_TEARDOWN PeerTearDownAction
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-void DlsStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- UCHAR i;
-
- StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_DLS_STATE, MAX_DLS_MSG, (STATE_MACHINE_FUNC)Drop, DLS_IDLE, DLS_MACHINE_BASE);
-
- // the first column
- StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_REQ, (STATE_MACHINE_FUNC)MlmeDlsReqAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_REQ, (STATE_MACHINE_FUNC)PeerDlsReqAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_RSP, (STATE_MACHINE_FUNC)PeerDlsRspAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)MlmeDlsTearDownAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)PeerDlsTearDownAction);
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- pAd->StaCfg.DLSEntry[i].pAd = pAd;
- RTMPInitTimer(pAd, &pAd->StaCfg.DLSEntry[i].Timer, GET_TIMER_FUNCTION(DlsTimeoutAction), pAd, FALSE);
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- HEADER_802_11 DlsReqHdr;
- PRT_802_11_DLS pDLS = NULL;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_REQUEST;
- ULONG tmp;
- USHORT reason;
- ULONG Timeout;
- BOOLEAN TimerCancelled;
-
- if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &reason))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsReqAction() \n"));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsReqAction() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsReqHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsReqHdr,
- 1, &Category,
- 1, &Action,
- 6, &pDLS->MacAddr,
- 6, pAd->CurrentAddress,
- 2, &pAd->StaActive.CapabilityInfo,
- 2, &pDLS->TimeOut,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR HtLen;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(HT_CAPABILITY_IE);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- FrameLen = FrameLen + tmp;
- }
-#endif // DOT11_N_SUPPORT //
-
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
- Timeout = DLS_TIMEOUT;
- RTMPSetTimer(&pDLS->Timer, Timeout);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT StatusCode = MLME_SUCCESS;
- HEADER_802_11 DlsRspHdr;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_RESPONSE;
- ULONG tmp;
- USHORT CapabilityInfo;
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT DLSTimeOut;
- SHORT i;
- ULONG Timeout;
- BOOLEAN TimerCancelled;
- PRT_802_11_DLS pDLS = NULL;
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR SupportedRatesLen;
- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR HtCapabilityLen;
- HT_CAPABILITY_IE HtCapability;
-
- if (!PeerDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &DLSTimeOut,
- &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
- return;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (i = 0; i < SupportedRatesLen; i++)
- {
- if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
- MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() from %02x:%02x:%02x:%02x:%02x:%02x\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() allocate memory failed \n"));
- return;
- }
-
- if (!INFRA_ON(pAd))
- {
- StatusCode = MLME_REQUEST_DECLINED;
- }
- else if (!pAd->CommonCfg.bWmmCapable)
- {
- StatusCode = MLME_DEST_STA_IS_NOT_A_QSTA;
- }
- else if (!pAd->CommonCfg.bDLSCapable)
- {
- StatusCode = MLME_REQUEST_DECLINED;
- }
- else
- {
- // find table to update parameters
- for (i = (MAX_NUM_OF_DLS_ENTRY-1); i >= 0; i--)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- }
-
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
- pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- pDLS = &pAd->StaCfg.DLSEntry[i];
- break;
- }
- }
-
- // can not find in table, create a new one
- if (i < 0)
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() can not find same entry \n"));
- for (i=(MAX_NUM_OF_DLS_ENTRY - 1); i >= MAX_NUM_OF_INIT_DLS_ENTRY; i--)
- {
- if (!pAd->StaCfg.DLSEntry[i].Valid)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- }
-
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- pAd->StaCfg.DLSEntry[i].Valid = TRUE;
- pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
- pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
- NdisMoveMemory(pAd->StaCfg.DLSEntry[i].MacAddr, SA, MAC_ADDR_LEN);
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- pDLS = &pAd->StaCfg.DLSEntry[i];
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsReqAction() Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
-
- printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS);
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- break;
- }
- }
- }
- StatusCode = MLME_SUCCESS;
-
- // can not find in table, create a new one
- if (i < 0)
- {
- StatusCode = MLME_QOS_UNSPECIFY;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() DLSEntry table full(only can support %d DLS session) \n", MAX_NUM_OF_DLS_ENTRY - MAX_NUM_OF_INIT_DLS_ENTRY));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() use entry(%d) %02x:%02x:%02x:%02x:%02x:%02x\n",
- i, SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
- }
-
- ActHeaderInit(pAd, &DlsRspHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- if (StatusCode == MLME_SUCCESS)
- {
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsRspHdr,
- 1, &Category,
- 1, &Action,
- 2, &StatusCode,
- 6, SA,
- 6, pAd->CurrentAddress,
- 2, &pAd->StaActive.CapabilityInfo,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR HtLen;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(HT_CAPABILITY_IE);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- FrameLen = FrameLen + tmp;
- }
-#endif // DOT11_N_SUPPORT //
-
- if (pDLS && (pDLS->Status != DLS_FINISH))
- {
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
- Timeout = DLS_TIMEOUT;
- RTMPSetTimer(&pDLS->Timer, Timeout);
- }
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsRspHdr,
- 1, &Category,
- 1, &Action,
- 2, &StatusCode,
- 6, SA,
- 6, pAd->CurrentAddress,
- END_OF_ARGS);
- }
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo;
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT StatusCode;
- SHORT i;
- BOOLEAN TimerCancelled;
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR SupportedRatesLen;
- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR HtCapabilityLen;
- HT_CAPABILITY_IE HtCapability;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- if (!INFRA_ON(pAd))
- return;
-
- if (!PeerDlsRspSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &StatusCode,
- &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
- return;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (i=0; i<SupportedRatesLen; i++)
- {
- if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
- MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x with StatusCode=%d, CapabilityInfo=0x%x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], StatusCode, CapabilityInfo));
-
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (StatusCode == MLME_SUCCESS)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsRspAction Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
- }
- else
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
- }
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
-
- //initialize seq no for DLS frames.
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- }
- else
- {
- // DLS setup procedure failed.
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
- }
- }
- }
-
- if (i >= MAX_NUM_OF_INIT_DLS_ENTRY)
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() update timeout value \n"));
- for (i=(MAX_NUM_OF_DLS_ENTRY-1); i>=MAX_NUM_OF_INIT_DLS_ENTRY; i--)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (StatusCode == MLME_SUCCESS)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsRspAction Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS);
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
- }
- else
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
- }
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- }
- else
- {
- // DLS setup procedure failed.
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
- }
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_TEARDOWN;
- USHORT ReasonCode = REASON_QOS_UNSPECIFY;
- HEADER_802_11 DlsTearDownHdr;
- PRT_802_11_DLS pDLS;
- BOOLEAN TimerCancelled;
- UCHAR i;
-
- if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &ReasonCode))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsTearDownAction() with ReasonCode=%d \n", ReasonCode));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsTearDownAction() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsTearDownHdr,
- 1, &Category,
- 1, &Action,
- 6, &pDLS->MacAddr,
- 6, pAd->CurrentAddress,
- 2, &ReasonCode,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
-
- // Remove key in local dls table entry
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // clear peer dls table entry
- for (i = MAX_NUM_OF_INIT_DLS_ENTRY; i < MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT ReasonCode;
- UINT i;
- BOOLEAN TimerCancelled;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- if (!INFRA_ON(pAd))
- return;
-
- if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsTearDownAction() from %02x:%02x:%02x:%02x:%02x:%02x with ReasonCode=%d\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], ReasonCode));
-
- // clear local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // clear peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID RTMPCheckDLSTimeOut(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_UNSPECIFY;
-
- if (! pAd->CommonCfg.bDLSCapable)
- return;
-
- if (! INFRA_ON(pAd))
- return;
-
- // If timeout value is equaled to zero, it means always not be timeout.
-
- // update local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer --;
-
- if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- }
- }
-
- // update peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer --;
-
- if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN RTMPRcvFrameDLSCheck(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN ULONG Len,
- IN PRT28XX_RXD_STRUC pRxD)
-{
- ULONG i;
- BOOLEAN bFindEntry = FALSE;
- BOOLEAN bSTAKeyFrame = FALSE;
- PEAPOL_PACKET pEap;
- PUCHAR pProto, pAddr = NULL;
- PUCHAR pSTAKey = NULL;
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
- UCHAR Mic[16], OldMic[16];
- UCHAR digest[80];
- UCHAR DlsPTK[80];
- UCHAR temp[64];
- BOOLEAN TimerCancelled;
- CIPHER_KEY PairwiseKey;
-
-
- if (! pAd->CommonCfg.bDLSCapable)
- return bSTAKeyFrame;
-
- if (! INFRA_ON(pAd))
- return bSTAKeyFrame;
-
- if (! (pHeader->FC.SubType & 0x08))
- return bSTAKeyFrame;
-
- if (Len < LENGTH_802_11 + 6 + 2 + 2)
- return bSTAKeyFrame;
-
- pProto = (PUCHAR)pHeader + LENGTH_802_11 + 2 + 6; // QOS Control field , 0xAA 0xAA 0xAA 0x00 0x00 0x00
- pAddr = pHeader->Addr2;
-
- // L2PAD bit on will pad 2 bytes at LLC
- if (pRxD->L2PAD)
- {
- pProto += 2;
- }
-
- if (RTMPEqualMemory(EAPOL, pProto, 2) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- pEap = (PEAPOL_PACKET) (pProto + 2);
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff Len=%ld, DataLen=%d, KeyMic=%d, Install=%d, KeyAck=%d, Secure=%d, EKD_DL=%d, Error=%d, Request=%d\n", Len,
- (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16),
- pEap->KeyDesc.KeyInfo.KeyMic,
- pEap->KeyDesc.KeyInfo.Install,
- pEap->KeyDesc.KeyInfo.KeyAck,
- pEap->KeyDesc.KeyInfo.Secure,
- pEap->KeyDesc.KeyInfo.EKD_DL,
- pEap->KeyDesc.KeyInfo.Error,
- pEap->KeyDesc.KeyInfo.Request));
-
- if ((Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16)) && pEap->KeyDesc.KeyInfo.KeyMic
- && pEap->KeyDesc.KeyInfo.Install && pEap->KeyDesc.KeyInfo.KeyAck && pEap->KeyDesc.KeyInfo.Secure
- && pEap->KeyDesc.KeyInfo.EKD_DL && !pEap->KeyDesc.KeyInfo.Error && !pEap->KeyDesc.KeyInfo.Request)
- {
- // First validate replay counter, only accept message with larger replay counter
- // Let equal pass, some AP start with all zero replay counter
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
- if ((RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- return bSTAKeyFrame;
-
- //RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter (%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
- pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
- pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
- pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
-
- // put these code segment to get the replay counter
- if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
- return bSTAKeyFrame;
-
- // Check MIC value
- // Save the MIC and replace with zero
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- NdisMoveMemory(OldMic, pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1((PUCHAR) pEap, pEap->Body_Len[1] + 4, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic);
- }
-
- if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in Msg1 of STAKey handshake! \n"));
- return bSTAKeyFrame;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("MIC VALID in Msg1 of STAKey handshake! \n"));
-#if 1
- if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0C)
- && (pEap->KeyDesc.KeyData[4] == 0x43) && (pEap->KeyDesc.KeyData[5] == 0x02))
- {
- pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
- pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%ld, KeyDataLen=%d\n",
- pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
-
- bSTAKeyFrame = TRUE;
- }
-#else
- if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0F)
- && (pEap->KeyDesc.KeyData[4] == 0xAC) && (pEap->KeyDesc.KeyData[5] == 0x02))
- {
- pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
- pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%d, KeyDataLen=%d\n",
- pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
-
- bSTAKeyFrame = TRUE;
- }
-#endif
-
- }
- else if (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE))
- {
-#if 0
- RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
-#endif
- RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter 2(%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
- pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
- pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
- pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
-
- }
- }
-
- // If timeout value is equaled to zero, it means always not be timeout.
- // update local dls table entry
- for (i= 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (bSTAKeyFrame)
- {
- PMAC_TABLE_ENTRY pEntry;
-
- // STAKey frame, add pairwise key table
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-
- PairwiseKey.KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
- NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
-
- PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
-
- pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- // Add Pair-wise key to Asic
- AsicAddPairwiseKeyEntry(pAd,
- pAd->StaCfg.DLSEntry[i].MacAddr,
- (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
- &PairwiseKey);
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- PairwiseKey.CipherAlg,
- pEntry);
-
- NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n"));
-
- RTMPSendSTAKeyHandShake(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Initiator side)\n"));
- }
- else
- {
- // Data frame, update timeout value
- if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- }
- }
-
- bFindEntry = TRUE;
- }
- }
-
- // update peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (bSTAKeyFrame)
- {
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- // STAKey frame, add pairwise key table, and send STAkey Msg-2
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-
- PairwiseKey.KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
- NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
-
- PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
-
- pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- // Add Pair-wise key to Asic
- AsicAddPairwiseKeyEntry(pAd,
- pAd->StaCfg.DLSEntry[i].MacAddr,
- (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
- &PairwiseKey);
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- PairwiseKey.CipherAlg,
- pEntry);
- NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Initiator STA MAC Address STAKey)\n"));
-
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyHandShake(pAd, pAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Peer side)\n"));
- }
- }
- else
- {
- // Data frame, update timeout value
- if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- }
- }
-
- bFindEntry = TRUE;
- }
- }
-
-
- return bSTAKeyFrame;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check if the frame can be sent through DLS direct link interface
-
- Arguments:
- pAd Pointer to adapter
-
- Return Value:
- DLS entry index
-
- Note:
-
- ========================================================================
-*/
-INT RTMPCheckDLSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- INT rval = -1;
- INT i;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return rval;
-
- if (!INFRA_ON(pAd))
- return rval;
-
- do{
- // check local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- rval = i;
- break;
- }
- }
-
- // check peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- rval = i;
- break;
- }
- }
- } while (FALSE);
-
- return rval;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- HEADER_802_11 DlsTearDownHdr;
- ULONG FrameLen = 0;
- USHORT Reason = REASON_QOS_QSTA_LEAVING_QBSS;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_TEARDOWN;
- UCHAR i = 0;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame \n"));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ASSOC - RTMPSendDLSTearDownFrame() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsTearDownHdr,
- 1, &Category,
- 1, &Action,
- 6, pDA,
- 6, pAd->CurrentAddress,
- 2, &Reason,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- // Remove key in local dls table entry
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // Remove key in peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame and remove key in (i=%d) \n", i));
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-NDIS_STATUS RTMPSendSTAKeyRequest(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- UCHAR Header802_3[14];
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- UCHAR digest[80];
- PUCHAR pOutBuffer = NULL;
- PNDIS_PACKET pNdisPacket;
- UCHAR temp[64];
- UCHAR DlsPTK[80];
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyRequest() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-
- pAd->Sequence ++;
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE andPeer MAC address
-
- // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
-
- // Key descriptor version
- Packet.KeyDesc.KeyInfo.KeyDescVer =
- (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
- Packet.KeyDesc.KeyInfo.Request = 1;
-
- Packet.KeyDesc.KeyDataLen[1] = 12;
-
- // use our own OUI to distinguish proprietary with standard.
- Packet.KeyDesc.KeyData[0] = 0xDD;
- Packet.KeyDesc.KeyData[1] = 0x0A;
- Packet.KeyDesc.KeyData[2] = 0x00;
- Packet.KeyDesc.KeyData[3] = 0x0C;
- Packet.KeyDesc.KeyData[4] = 0x43;
- Packet.KeyDesc.KeyData[5] = 0x03;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Allocate buffer for transmitting message
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return NStatus;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- // calculate MIC
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- NdisZeroMemory(digest, sizeof(digest));
- HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
- }
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(Header802_3), Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
- STASendPacket(pAd, pNdisPacket);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyRequest- Send STAKey request (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
-
- return NStatus;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-NDIS_STATUS RTMPSendSTAKeyHandShake(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- UCHAR Header802_3[14];
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- UCHAR digest[80];
- PUCHAR pOutBuffer = NULL;
- PNDIS_PACKET pNdisPacket;
- UCHAR temp[64];
- UCHAR DlsPTK[80]; // Due to dirver can not get PTK, use proprietary PTK
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyHandShake() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-
- pAd->Sequence ++;
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE and Peer MAC address
-
- // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
-
- // Key descriptor version
- Packet.KeyDesc.KeyInfo.KeyDescVer =
- (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- Packet.KeyDesc.KeyDataLen[1] = 12;
-
- // use our own OUI to distinguish proprietary with standard.
- Packet.KeyDesc.KeyData[0] = 0xDD;
- Packet.KeyDesc.KeyData[1] = 0x0A;
- Packet.KeyDesc.KeyData[2] = 0x00;
- Packet.KeyDesc.KeyData[3] = 0x0C;
- Packet.KeyDesc.KeyData[4] = 0x43;
- Packet.KeyDesc.KeyData[5] = 0x03;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Allocate buffer for transmitting message
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return NStatus;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- // calculate MIC
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- NdisZeroMemory(digest, sizeof(digest));
- HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
- }
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(Header802_3), Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
- STASendPacket(pAd, pNdisPacket);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyHandShake- Send STAKey Message-2 (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
-
- return NStatus;
-}
-
-VOID DlsTimeoutAction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason;
- PRT_802_11_DLS pDLS = (PRT_802_11_DLS)FunctionContext;
- PRTMP_ADAPTER pAd = pDLS->pAd;
-
- DBGPRINT(RT_DEBUG_TRACE, ("DlsTimeout - Tear down DLS links (%02x:%02x:%02x:%02x:%02x:%02x)\n",
- pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5]));
-
- if ((pDLS) && (pDLS->Valid))
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pDLS->Valid = FALSE;
- pDLS->Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, pDLS, reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-
-/*
-================================================================
-Description : because DLS and CLI share the same WCID table in ASIC.
-Mesh entry also insert to pAd->MacTab.content[]. Such is marked as ValidAsDls = TRUE.
-Also fills the pairwise key.
-Because front MAX_AID_BA entries have direct mapping to BAEntry, which is only used as CLI. So we insert Dls
-from index MAX_AID_BA.
-================================================================
-*/
-MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UINT DlsEntryIdx)
-{
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableInsertDlsEntry\n"));
- // if FULL, return
- if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
- return NULL;
-
- do
- {
- if((pEntry = DlsEntryTableLookup(pAd, pAddr, TRUE)) != NULL)
- break;
-
- // allocate one MAC entry
- pEntry = MacTableInsertEntry(pAd, pAddr, DlsEntryIdx + MIN_NET_DEVICE_FOR_DLS, TRUE);
- if (pEntry)
- {
- pAd->StaCfg.DLSEntry[DlsEntryIdx].MacTabMatchWCID = pEntry->Aid;
- pEntry->MatchDlsEntryIdx = DlsEntryIdx;
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertDlsEntry - allocate entry #%d, Total= %d\n",pEntry->Aid, pAd->MacTab.Size));
-
- // If legacy WEP is used, set pair-wise cipherAlg into WCID attribute table for this entry
- if ((pEntry->ValidAsDls) && (pEntry->WepStatus == Ndis802_11WEPEnabled))
- {
- UCHAR KeyIdx = 0;
- UCHAR CipherAlg = 0;
-
- KeyIdx = pAd->StaCfg.DefaultKeyId;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pEntry);
- }
-
- break;
- }
- } while(FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableInsertDlsEntry\n"));
-
- return pEntry;
-}
-
-
-/*
- ==========================================================================
- Description:
- Delete all Mesh Entry in pAd->MacTab
- ==========================================================================
- */
-BOOLEAN MacTableDeleteDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableDeleteDlsEntry\n"));
-
- if (!VALID_WCID(wcid))
- return FALSE;
-
- MacTableDeleteEntry(pAd, wcid, pAddr);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableDeleteDlsEntry\n"));
-
- return TRUE;
-}
-
-MAC_TABLE_ENTRY *DlsEntryTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount)
-{
- ULONG HashIdx;
- MAC_TABLE_ENTRY *pEntry = NULL;
-
- RTMP_SEM_LOCK(&pAd->MacTabLock);
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- pEntry = pAd->MacTab.Hash[HashIdx];
-
- while (pEntry)
- {
- if ((pEntry->ValidAsDls == TRUE)
- && MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
- if(bResetIdelCount)
- pEntry->NoDataIdleCount = 0;
- break;
- }
- else
- pEntry = pEntry->pNext;
- }
-
- RTMP_SEM_UNLOCK(&pAd->MacTabLock);
- return pEntry;
-}
-
-MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR wcid,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount)
-{
- ULONG DLsIndex;
- PMAC_TABLE_ENTRY pCurEntry = NULL;
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- if (!VALID_WCID(wcid))
- return NULL;
-
- RTMP_SEM_LOCK(&pAd->MacTabLock);
-
- do
- {
- pCurEntry = &pAd->MacTab.Content[wcid];
-
- DLsIndex = 0xff;
- if ((pCurEntry) && (pCurEntry->ValidAsDls== TRUE))
- {
- DLsIndex = pCurEntry->MatchDlsEntryIdx;
- }
-
- if (DLsIndex == 0xff)
- break;
-
- if (MAC_ADDR_EQUAL(pCurEntry->Addr, pAddr))
- {
- if(bResetIdelCount)
- pCurEntry->NoDataIdleCount = 0;
- pEntry = pCurEntry;
- break;
- }
- } while(FALSE);
-
- RTMP_SEM_UNLOCK(&pAd->MacTabLock);
-
- return pEntry;
-}
-
-INT Set_DlsEntryInfo_Display_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- INT i;
-
- printk("\n%-19s%-8s\n", "MAC", "TIMEOUT\n");
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[pAd->StaCfg.DLSEntry[i].MacTabMatchWCID];
-
- printk("%02x:%02x:%02x:%02x:%02x:%02x ",
- pAd->StaCfg.DLSEntry[i].MacAddr[0], pAd->StaCfg.DLSEntry[i].MacAddr[1], pAd->StaCfg.DLSEntry[i].MacAddr[2],
- pAd->StaCfg.DLSEntry[i].MacAddr[3], pAd->StaCfg.DLSEntry[i].MacAddr[4], pAd->StaCfg.DLSEntry[i].MacAddr[5]);
- printk("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut);
-
- printk("\n");
- printk("\n%-19s%-4s%-4s%-4s%-4s%-8s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
- "MAC", "AID", "BSS", "PSM", "WMM", "MIMOPS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
- printk("%02X:%02X:%02X:%02X:%02X:%02X ",
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- printk("%-4d", (int)pEntry->Aid);
- printk("%-4d", (int)pEntry->apidx);
- printk("%-4d", (int)pEntry->PsMode);
- printk("%-4d", (int)CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE));
- printk("%-8d", (int)pEntry->MmpsMode);
- printk("%-7d", pEntry->RssiSample.AvgRssi0);
- printk("%-7d", pEntry->RssiSample.AvgRssi1);
- printk("%-7d", pEntry->RssiSample.AvgRssi2);
- printk("%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
- printk("%-6s", GetBW(pEntry->HTPhyMode.field.BW));
- printk("%-6d", pEntry->HTPhyMode.field.MCS);
- printk("%-6d", pEntry->HTPhyMode.field.ShortGI);
- printk("%-6d", pEntry->HTPhyMode.field.STBC);
- printk("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
- (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
- printk("\n");
-
- }
- }
-
- return TRUE;
-}
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[MAC_ADDR_LEN];
- USHORT Timeout;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- RT_802_11_DLS Dls;
-
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and timeout value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- Timeout = simple_strtol((token+1), 0, 10);
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%d", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], (int)Timeout);
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- Dls.TimeOut = Timeout;
- COPY_MAC_ADDR(Dls.MacAddr, mac);
- Dls.Valid = 1;
-
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_DlsTearDownEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR macAddr[MAC_ADDR_LEN];
- CHAR *value;
- INT i;
- RT_802_11_DLS Dls;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
- AtoH(value, &macAddr[i++], 2);
- }
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x", macAddr[0], macAddr[1],
- macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- COPY_MAC_ADDR(Dls.MacAddr, macAddr);
- Dls.Valid = 0;
-
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
-
- return TRUE;
-}
-
diff --git a/drivers/staging/rt2860/sta/rtmp_data.c b/drivers/staging/rt2860/sta/rtmp_data.c
index c5e76a2da56d..b41ce230c501 100644
--- a/drivers/staging/rt2860/sta/rtmp_data.c
+++ b/drivers/staging/rt2860/sta/rtmp_data.c
@@ -50,7 +50,6 @@ VOID STARxEAPOLFrameIndicate(
PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
UCHAR *pTmpBuf;
-#ifdef WPA_SUPPLICANT_SUPPORT
if (pAd->StaCfg.WpaSupplicantUP)
{
// All EAPoL frames have to pass to upper layer (ex. WPA_SUPPLICANT daemon)
@@ -75,6 +74,7 @@ VOID STARxEAPOLFrameIndicate(
if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
{
+#ifdef RT2860
MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[BSSID_WCID];
// Set key material and cipherAlg to Asic
@@ -88,6 +88,32 @@ VOID STARxEAPOLFrameIndicate(
pAd->IndicateMediaState = NdisMediaStateConnected;
pAd->ExtraInfo = GENERAL_LINK_UP;
+#endif
+#ifdef RT2870
+ union
+ {
+ char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1];
+ NDIS_802_11_WEP keyinfo;
+ } WepKey;
+ int len;
+
+
+ NdisZeroMemory(&WepKey, sizeof(WepKey));
+ len =pAd->StaCfg.DesireSharedKey[idx].KeyLen;
+
+ NdisMoveMemory(WepKey.keyinfo.KeyMaterial,
+ pAd->StaCfg.DesireSharedKey[idx].Key,
+ pAd->StaCfg.DesireSharedKey[idx].KeyLen);
+
+ WepKey.keyinfo.KeyIndex = 0x80000000 + idx;
+ WepKey.keyinfo.KeyLength = len;
+ pAd->SharedKey[BSS0][idx].KeyLen =(UCHAR) (len <= 5 ? 5 : 13);
+
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+ pAd->ExtraInfo = GENERAL_LINK_UP;
+ // need to enqueue cmd to thread
+ RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1);
+#endif // RT2870 //
// For Preventing ShardKey Table is cleared by remove key procedure.
pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg;
pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen;
@@ -103,7 +129,6 @@ VOID STARxEAPOLFrameIndicate(
}
}
else
-#endif // WPA_SUPPLICANT_SUPPORT //
{
// Special DATA frame that has to pass to MLME
// 1. Cisco Aironet frames for CCX2. We need pass it to MLME for special process
@@ -168,20 +193,16 @@ VOID STARxDataFrameAnnounce(
// ARALINK
CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
}
-#ifdef QOS_DLS_SUPPORT
- RX_BLK_CLEAR_FLAG(pRxBlk, fRX_DLS);
-#endif // QOS_DLS_SUPPORT //
}
else
{
RX_BLK_SET_FLAG(pRxBlk, fRX_EAP);
-#ifdef DOT11_N_SUPPORT
+
if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
{
Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
}
else
-#endif // DOT11_N_SUPPORT //
{
// Determin the destination of the EAP frame
// to WPA state machine or upper layer
@@ -226,13 +247,11 @@ BOOLEAN STACheckTkipMICValue(
{
DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error 2\n"));
-#ifdef WPA_SUPPLICANT_SUPPORT
if (pAd->StaCfg.WpaSupplicantUP)
{
WpaSendMicFailureToWpaSupplicant(pAd, (pWpaKey->Type == PAIRWISEKEY) ? TRUE : FALSE);
}
else
-#endif // WPA_SUPPLICANT_SUPPORT //
{
RTMPReportMicError(pAd, pWpaKey);
}
@@ -276,14 +295,6 @@ VOID STAHandleRxDataFrame(
return;
}
-#ifdef QOS_DLS_SUPPORT
- //if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
- if (RTMPRcvFrameDLSCheck(pAd, pHeader, pRxWI->MPDUtotalByteCount, pRxD))
- {
- return;
- }
-#endif // QOS_DLS_SUPPORT //
-
// Drop not my BSS frames
if (pRxD->MyBss == 0)
{
@@ -342,10 +353,7 @@ VOID STAHandleRxDataFrame(
}
// Drop not my BSS frame (we can not only check the MyBss bit in RxD)
-#ifdef QOS_DLS_SUPPORT
- if (!pAd->CommonCfg.bDLSCapable)
- {
-#endif // QOS_DLS_SUPPORT //
+
if (INFRA_ON(pAd))
{
// Infrastructure mode, check address 2 for BSSID
@@ -368,9 +376,6 @@ VOID STAHandleRxDataFrame(
return;
}
}
-#ifdef QOS_DLS_SUPPORT
- }
-#endif // QOS_DLS_SUPPORT //
//
// find pEntry
@@ -391,11 +396,6 @@ VOID STAHandleRxDataFrame(
if (INFRA_ON(pAd))
{
RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA);
-#ifdef QOS_DLS_SUPPORT
- if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
- RX_BLK_SET_FLAG(pRxBlk, fRX_DLS);
- else
-#endif // QOS_DLS_SUPPORT //
ASSERT(pRxWI->WirelessCliID == BSSID_WCID);
}
@@ -453,12 +453,10 @@ VOID STAHandleRxDataFrame(
else
#endif
{
-#ifdef DOT11_N_SUPPORT
RX_BLK_SET_FLAG(pRxBlk, fRX_HTC);
// skip HTC contorl field
pRxBlk->pData += 4;
pRxBlk->DataSize -= 4;
-#endif // DOT11_N_SUPPORT //
}
}
@@ -471,13 +469,10 @@ VOID STAHandleRxDataFrame(
pRxBlk->pData += 2;
}
-#ifdef DOT11_N_SUPPORT
if (pRxD->BA)
{
RX_BLK_SET_FLAG(pRxBlk, fRX_AMPDU);
}
-#endif // DOT11_N_SUPPORT //
-
//
// Case I Process Broadcast & Multicast data frame
@@ -509,18 +504,6 @@ VOID STAHandleRxDataFrame(
{
pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
-
-#ifdef QOS_DLS_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_DLS))
- {
- MAC_TABLE_ENTRY *pDlsEntry = NULL;
-
- pDlsEntry = DlsEntryTableLookupByWcid(pAd, pRxWI->WirelessCliID, pHeader->Addr2, TRUE);
- if(pDlsEntry)
- Update_Rssi_Sample(pAd, &pDlsEntry->RssiSample, pRxWI);
- }
- else
-#endif // QOS_DLS_SUPPORT //
if (ADHOC_ON(pAd))
{
pEntry = MacTableLookup(pAd, pHeader->Addr2);
@@ -592,7 +575,13 @@ VOID STAHandleRxMgmtFrame(
{
// We should collect RSSI not only U2M data but also my beacon
+#ifdef RT30xx
+ if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))
+ && (pAd->RxAnt.EvaluatePeriod == 0))
+#endif
+#ifndef RT30xx
if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2)))
+#endif
{
Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
@@ -600,6 +589,18 @@ VOID STAHandleRxMgmtFrame(
pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
}
+#ifdef RT30xx
+ // collect rssi information for antenna diversity
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ if ((pRxD->U2M) || ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))))
+ {
+ COLLECT_RX_ANTENNA_AVERAGE_RSSI(pAd, ConvertToRssi(pAd, (UCHAR)pRxWI->RSSI0, RSSI_0), 0); //Note: RSSI2 not used on RT73
+ pAd->StaCfg.NumOfAvgRssiSample ++;
+ }
+ }
+#endif // RT30xx //
+
// First check the size, it MUST not exceed the mlme queue size
if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE)
{
@@ -618,21 +619,17 @@ VOID STAHandleRxControlFrame(
IN PRTMP_ADAPTER pAd,
IN RX_BLK *pRxBlk)
{
-#ifdef DOT11_N_SUPPORT
PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
-#endif // DOT11_N_SUPPORT //
PHEADER_802_11 pHeader = pRxBlk->pHeader;
PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
switch (pHeader->FC.SubType)
{
case SUBTYPE_BLOCK_ACK_REQ:
-#ifdef DOT11_N_SUPPORT
{
CntlEnqueueForRecv(pAd, pRxWI->WirelessCliID, (pRxWI->MPDUtotalByteCount), (PFRAME_BA_REQ)pHeader);
}
break;
-#endif // DOT11_N_SUPPORT //
case SUBTYPE_BLOCK_ACK:
case SUBTYPE_ACK:
default:
@@ -691,12 +688,14 @@ BOOLEAN STARxDoneInterruptHandle(
break;
}
+#ifdef RT2860
if (RxProcessed++ > MAX_RX_PROCESS_CNT)
{
// need to reschedule rx handle
bReschedule = TRUE;
break;
}
+#endif
RxProcessed ++; // test
@@ -721,11 +720,6 @@ BOOLEAN STARxDoneInterruptHandle(
pRxWI = (PRXWI_STRUC) pData;
pHeader = (PHEADER_802_11) (pData+RXWI_SIZE) ;
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader, DIR_READ, TRUE);
- RTMPWIEndianChange((PUCHAR)pRxWI, TYPE_RXWI);
-#endif
-
// build RxCell
RxCell.pRxWI = pRxWI;
RxCell.pHeader = pHeader;
@@ -749,22 +743,6 @@ BOOLEAN STARxDoneInterruptHandle(
break;
}
/* RT2870 invokes STARxDoneInterruptHandle() in rtusb_bulk.c */
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- pAd->ate.RxCntPerSec++;
- ATESampleRssi(pAd, pRxWI);
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQARxStart == TRUE)
- {
- /* (*pRxD) has been swapped in GetPacketFromRxRing() */
- ATE_QA_Statistics(pAd, pRxWI, pRxD, pHeader);
- }
-#endif // RALINK_28xx_QA //
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
- continue;
- }
-#endif // RALINK_ATE //
// Check for all RxD errors
Status = RTMPCheckRxError(pAd, pHeader, pRxWI, pRxD);
@@ -807,6 +785,7 @@ BOOLEAN STARxDoneInterruptHandle(
}
}
+#ifdef RT2860
// fRTMP_PS_GO_TO_SLEEP_NOW is set if receiving beacon.
if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW) && (INFRA_ON(pAd)))
{
@@ -814,6 +793,7 @@ BOOLEAN STARxDoneInterruptHandle(
AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp);
bReschedule = FALSE;
}
+#endif
return bReschedule;
}
@@ -831,7 +811,12 @@ BOOLEAN STARxDoneInterruptHandle(
VOID RTMPHandleTwakeupInterrupt(
IN PRTMP_ADAPTER pAd)
{
+#ifdef RT2860
AsicForceWakeup(pAd, DOT11POWERSAVE);
+#endif
+#ifdef RT2870
+ AsicForceWakeup(pAd, FALSE);
+#endif
}
/*
@@ -885,17 +870,6 @@ VOID STASendPackets(
{
// Record that orignal packet source is from NDIS layer,so that
// later on driver knows how to release this NDIS PACKET
-#ifdef QOS_DLS_SUPPORT
- MAC_TABLE_ENTRY *pEntry;
- PUCHAR pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-
- pEntry = MacTableLookup(pAd, pSrcBufVA);
- if (pEntry && (pEntry->ValidAsDls == TRUE))
- {
- RTMP_SET_PACKET_WCID(pPacket, pEntry->Aid);
- }
- else
-#endif // QOS_DLS_SUPPORT //
RTMP_SET_PACKET_WCID(pPacket, 0); // this field is useless when in STA mode
RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_PENDING);
@@ -977,18 +951,6 @@ NDIS_STATUS STASendPacket(
{
if(INFRA_ON(pAd))
{
-#ifdef QOS_DLS_SUPPORT
- USHORT tmpWcid;
-
- tmpWcid = RTMP_GET_PACKET_WCID(pPacket);
- if (VALID_WCID(tmpWcid) &&
- (pAd->MacTab.Content[tmpWcid].ValidAsDls== TRUE))
- {
- pEntry = &pAd->MacTab.Content[tmpWcid];
- Rate = pAd->MacTab.Content[tmpWcid].CurrTxRate;
- }
- else
-#endif // QOS_DLS_SUPPORT //
{
pEntry = &pAd->MacTab.Content[BSSID_WCID];
RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID);
@@ -1039,12 +1001,7 @@ NDIS_STATUS STASendPacket(
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef WPA_SUPPLICANT_SUPPORT
|| (pAd->StaCfg.IEEE8021X == TRUE)
-#endif // WPA_SUPPLICANT_SUPPORT //
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
)
&& ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAd->StaCfg.MicErrCnt >= 2))
&& (RTMP_GET_PACKET_EAPOL(pPacket)== FALSE)
@@ -1070,10 +1027,8 @@ NDIS_STATUS STASendPacket(
NumberOfFrag = 1; // Aggregation overwhelms fragmentation
else if (CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED))
NumberOfFrag = 1; // Aggregation overwhelms fragmentation
-#ifdef DOT11_N_SUPPORT
else if ((pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTMIX) || (pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTGREENFIELD))
NumberOfFrag = 1; // MIMO RATE overwhelms fragmentation
-#endif // DOT11_N_SUPPORT //
else
{
// The calculated "NumberOfFrag" is a rough estimation because of various
@@ -1110,7 +1065,13 @@ NDIS_STATUS STASendPacket(
//
UserPriority = 0;
QueIdx = QID_AC_BE;
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
+#endif
+#ifdef RT2870
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
+ CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE))
+#endif
{
USHORT Protocol;
UCHAR LlcSnapLen = 0, Byte0, Byte1;
@@ -1163,9 +1124,6 @@ NDIS_STATUS STASendPacket(
if (pAd->TxSwQueue[QueIdx].Number >= MAX_PACKETS_IN_QUEUE)
{
RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-#ifdef BLOCK_NET_IF
- StopNetIfQueue(pAd, QueIdx, pPacket);
-#endif // BLOCK_NET_IF //
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
return NDIS_STATUS_FAILURE;
@@ -1176,9 +1134,13 @@ NDIS_STATUS STASendPacket(
}
RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-#ifdef DOT11_N_SUPPORT
if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&&
+#ifdef RT2860
(pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))
+#endif
+#ifdef RT2870
+ IS_HT_STA(pEntry))
+#endif
{
if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) &&
((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) &&
@@ -1194,7 +1156,6 @@ NDIS_STATUS STASendPacket(
BAOriSessionSetUp(pAd, pEntry, 0, 0, 10, FALSE);
}
}
-#endif // DOT11_N_SUPPORT //
pAd->RalinkCounters.OneSecOsTxCount[QueIdx]++; // TODO: for debug only. to be removed
return NDIS_STATUS_SUCCESS;
@@ -1223,14 +1184,27 @@ NDIS_STATUS STASendPacket(
========================================================================
*/
+
+#ifdef RT2870
+/*
+ Actually, this function used to check if the TxHardware Queue still has frame need to send.
+ If no frame need to send, go to sleep, else, still wake up.
+*/
+#endif
NDIS_STATUS RTMPFreeTXDRequest(
IN PRTMP_ADAPTER pAd,
IN UCHAR QueIdx,
IN UCHAR NumberRequired,
IN PUCHAR FreeNumberIs)
{
+#ifdef RT2860
ULONG FreeNumber = 0;
+#endif
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
+#ifdef RT2870
+ unsigned long IrqFlags;
+ HT_TX_CONTEXT *pHTTXContext;
+#endif
switch (QueIdx)
{
@@ -1239,6 +1213,7 @@ NDIS_STATUS RTMPFreeTXDRequest(
case QID_AC_VI:
case QID_AC_VO:
case QID_HCCA:
+#ifdef RT2860
if (pAd->TxRing[QueIdx].TxSwFreeIdx > pAd->TxRing[QueIdx].TxCpuIdx)
FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx - pAd->TxRing[QueIdx].TxCpuIdx - 1;
else
@@ -1246,9 +1221,27 @@ NDIS_STATUS RTMPFreeTXDRequest(
if (FreeNumber >= NumberRequired)
Status = NDIS_STATUS_SUCCESS;
+#endif
+#ifdef RT2870
+ {
+ pHTTXContext = &pAd->TxContext[QueIdx];
+ RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
+ if ((pHTTXContext->CurWritePosition != pHTTXContext->ENextBulkOutPosition) ||
+ (pHTTXContext->IRPPending == TRUE))
+ {
+ Status = NDIS_STATUS_FAILURE;
+ }
+ else
+ {
+ Status = NDIS_STATUS_SUCCESS;
+ }
+ RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
+ }
+#endif
break;
case QID_MGMT:
+#ifdef RT2860
if (pAd->MgmtRing.TxSwFreeIdx > pAd->MgmtRing.TxCpuIdx)
FreeNumber = pAd->MgmtRing.TxSwFreeIdx - pAd->MgmtRing.TxCpuIdx - 1;
else
@@ -1256,13 +1249,22 @@ NDIS_STATUS RTMPFreeTXDRequest(
if (FreeNumber >= NumberRequired)
Status = NDIS_STATUS_SUCCESS;
+#endif
+#ifdef RT2870
+ if (pAd->MgmtRing.TxSwFreeIdx != MGMT_RING_SIZE)
+ Status = NDIS_STATUS_FAILURE;
+ else
+ Status = NDIS_STATUS_SUCCESS;
+#endif
break;
default:
DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
break;
}
+#ifdef RT2860
*FreeNumberIs = (UCHAR)FreeNumber;
+#endif
return (Status);
}
@@ -1283,22 +1285,12 @@ VOID RTMPSendNullFrame(
ULONG Length;
PHEADER_802_11 pHeader_802_11;
-
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
// WPA 802.1x secured port control
if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef WPA_SUPPLICANT_SUPPORT
|| (pAd->StaCfg.IEEE8021X == TRUE)
-#endif
) &&
(pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
{
@@ -1402,30 +1394,6 @@ VOID STAFindCipherAlgorithm(
}
else if (Cipher == Ndis802_11Encryption1Enabled)
{
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.CkipFlag & 0x10) // Cisco CKIP KP is on
- {
- if (LEAP_CCKM_ON(pAd))
- {
- if (((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))))
- KeyIdx = 1;
- else
- KeyIdx = 0;
- }
- else
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
- else if (pAd->StaCfg.CkipFlag & 0x08) // only CKIP CMIC
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- else if (LEAP_CCKM_ON(pAd))
- {
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
- KeyIdx = 1;
- else
- KeyIdx = 0;
- }
- else // standard WEP64 or WEP128
-#endif // LEAP_SUPPORT //
KeyIdx = pAd->StaCfg.DefaultKeyId;
}
else if ((Cipher == Ndis802_11Encryption2Enabled) ||
@@ -1443,13 +1411,11 @@ VOID STAFindCipherAlgorithm(
CipherAlg = CIPHER_NONE;
else if ((Cipher == Ndis802_11EncryptionDisabled) || (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 0))
CipherAlg = CIPHER_NONE;
-#ifdef WPA_SUPPLICANT_SUPPORT
else if ( pAd->StaCfg.WpaSupplicantUP &&
(Cipher == Ndis802_11Encryption1Enabled) &&
(pAd->StaCfg.IEEE8021X == TRUE) &&
(pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
CipherAlg = CIPHER_NONE;
-#endif // WPA_SUPPLICANT_SUPPORT //
else
{
//Header_802_11.FC.Wep = 1;
@@ -1467,12 +1433,7 @@ VOID STABuildCommon802_11Header(
IN PRTMP_ADAPTER pAd,
IN TX_BLK *pTxBlk)
{
-
HEADER_802_11 *pHeader_802_11;
-#ifdef QOS_DLS_SUPPORT
- BOOLEAN bDLSFrame = FALSE;
- INT DlsEntryIndex = 0;
-#endif // QOS_DLS_SUPPORT //
//
// MAKE A COMMON 802.11 HEADER
@@ -1489,19 +1450,6 @@ VOID STABuildCommon802_11Header(
pHeader_802_11->FC.Type = BTYPE_DATA;
pHeader_802_11->FC.SubType = ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA : SUBTYPE_DATA);
-#ifdef QOS_DLS_SUPPORT
- if (INFRA_ON(pAd))
- {
- // Check if the frame can be sent through DLS direct link interface
- // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
- DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
- if (DlsEntryIndex >= 0)
- bDLSFrame = TRUE;
- else
- bDLSFrame = FALSE;
- }
-#endif // QOS_DLS_SUPPORT //
-
if (pTxBlk->pMacEntry)
{
if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS))
@@ -1511,14 +1459,6 @@ VOID STABuildCommon802_11Header(
}
else
{
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- pHeader_802_11->Sequence = pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence;
- pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence = (pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence+1) & MAXSEQ;
- }
- else
-#endif // QOS_DLS_SUPPORT //
{
pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority];
pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
@@ -1538,16 +1478,6 @@ VOID STABuildCommon802_11Header(
{
if (INFRA_ON(pAd))
{
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
- pHeader_802_11->FC.ToDs = 0;
- }
- else
-#endif // QOS_DLS_SUPPORT //
{
COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
@@ -1576,7 +1506,6 @@ VOID STABuildCommon802_11Header(
pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
}
-#ifdef DOT11_N_SUPPORT
VOID STABuildCache802_11Header(
IN RTMP_ADAPTER *pAd,
IN TX_BLK *pTxBlk,
@@ -1603,29 +1532,7 @@ VOID STABuildCache802_11Header(
pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
{
- // Check if the frame can be sent through DLS direct link interface
- // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
-#ifdef QOS_DLS_SUPPORT
- BOOLEAN bDLSFrame = FALSE;
- INT DlsEntryIndex = 0;
-
- DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
- if (DlsEntryIndex >= 0)
- bDLSFrame = TRUE;
- else
- bDLSFrame = FALSE;
-#endif // QOS_DLS_SUPPORT //
-
// The addr3 of normal packet send from DS is Dest Mac address.
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- COPY_MAC_ADDR(pHeader80211->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
- pHeader80211->FC.ToDs = 0;
- }
- else
-#endif // QOS_DLS_SUPPORT //
if (ADHOC_ON(pAd))
COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
else
@@ -1640,7 +1547,6 @@ VOID STABuildCache802_11Header(
else
pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
}
-#endif // DOT11_N_SUPPORT //
static inline PUCHAR STA_Build_ARalink_Frame_Header(
IN RTMP_ADAPTER *pAd,
@@ -1700,7 +1606,6 @@ static inline PUCHAR STA_Build_ARalink_Frame_Header(
}
-#ifdef DOT11_N_SUPPORT
static inline PUCHAR STA_Build_AMSDU_Frame_Header(
IN RTMP_ADAPTER *pAd,
IN TX_BLK *pTxBlk)
@@ -1890,7 +1795,9 @@ VOID STA_AMPDU_Frame_Tx(
//
// Kick out Tx
//
+#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
+#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
pAd->RalinkCounters.KickTxCount++;
@@ -2021,10 +1928,11 @@ VOID STA_AMSDU_Frame_Tx(
//
// Kick out Tx
//
+#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
+#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
}
-#endif // DOT11_N_SUPPORT //
VOID STA_Legacy_Frame_Tx(
IN PRTMP_ADAPTER pAd,
@@ -2142,7 +2050,9 @@ VOID STA_Legacy_Frame_Tx(
//
// Kick out Tx
//
+#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
+#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
}
@@ -2253,7 +2163,9 @@ VOID STA_ARalink_Frame_Tx(
//
// Kick out Tx
//
+#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
+#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
}
@@ -2513,15 +2425,6 @@ NDIS_STATUS STAHardTransmit(
pPacket = QUEUE_ENTRY_TO_PACKET(pTxBlk->TxPacketList.Head);
-#if 0 //def CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- if ((pAd->CommonCfg.CarrierDetect.Enable == TRUE) && (isCarrierDetectExist(pAd) == TRUE))
- {
- DBGPRINT(RT_DEBUG_INFO,("STAHardTransmit --> radar detect not in normal mode !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return (NDIS_STATUS_FAILURE);
- }
-#endif // CARRIER_DETECTION_SUPPORT //
-
// ------------------------------------------------------------------
// STEP 1. WAKE UP PHY
// outgoing frame always wakeup PHY to prevent frame lost and
@@ -2531,7 +2434,12 @@ NDIS_STATUS STAHardTransmit(
if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
{
DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n"));
+#ifdef RT2860
AsicForceWakeup(pAd, FROM_TX);
+#endif
+#ifdef RT2870
+ AsicForceWakeup(pAd, TRUE);
+#endif
}
// It should not change PSM bit, when APSD turn on.
@@ -2546,14 +2454,12 @@ NDIS_STATUS STAHardTransmit(
switch (pTxBlk->TxFrameType)
{
-#ifdef DOT11_N_SUPPORT
case TX_AMPDU_FRAME:
STA_AMPDU_Frame_Tx(pAd, pTxBlk);
break;
case TX_AMSDU_FRAME:
STA_AMSDU_Frame_Tx(pAd, pTxBlk);
break;
-#endif // DOT11_N_SUPPORT //
case TX_LEGACY_FRAME:
STA_Legacy_Frame_Tx(pAd, pTxBlk);
break;
diff --git a/drivers/staging/rt2860/sta/sanity.c b/drivers/staging/rt2860/sta/sanity.c
index 239872464bed..7d530f601602 100644
--- a/drivers/staging/rt2860/sta/sanity.c
+++ b/drivers/staging/rt2860/sta/sanity.c
@@ -184,7 +184,6 @@ BOOLEAN PeerAssocRspSanity(
}
break;
-#ifdef DOT11_N_SUPPORT
case IE_ADD_HT:
case IE_ADD_HT2:
if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
@@ -213,7 +212,6 @@ BOOLEAN PeerAssocRspSanity(
{
DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
}
-#endif // DOT11_N_SUPPORT //
break;
case IE_AIRONET_CKIP:
// 0. Check Aironet IE length, it must be larger or equal to 28
diff --git a/drivers/staging/rt2860/sta/sync.c b/drivers/staging/rt2860/sta/sync.c
index 148037a79d51..87b5e49cec54 100644
--- a/drivers/staging/rt2860/sta/sync.c
+++ b/drivers/staging/rt2860/sta/sync.c
@@ -37,6 +37,7 @@
*/
#include "../rt_config.h"
+#ifdef RT2860
#define AC0_DEF_TXOP 0
#define AC1_DEF_TXOP 0
#define AC2_DEF_TXOP 94
@@ -71,6 +72,10 @@ VOID AdhocTurnOnQos(
}
AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
}
+#endif /* RT2860 */
+#ifdef RT2870
+#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec
+#endif
/*
==========================================================================
@@ -141,7 +146,6 @@ VOID BeaconTimeout(
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
return;
-#ifdef DOT11_N_SUPPORT
if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
)
{
@@ -154,7 +158,6 @@ VOID BeaconTimeout(
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
}
-#endif // DOT11_N_SUPPORT //
MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL);
RT28XX_MLME_HANDLER(pAd);
@@ -228,6 +231,7 @@ VOID MlmeScanReqAction(
// Increase the scan retry counters.
pAd->StaCfg.ScanCnt++;
+#ifdef RT2860
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
@@ -235,6 +239,7 @@ VOID MlmeScanReqAction(
{
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
+#endif
// first check the parameter sanity
if (MlmeScanReqSanity(pAd,
@@ -347,6 +352,7 @@ VOID MlmeJoinReqAction(
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
+#ifdef RT2860
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
@@ -354,6 +360,7 @@ VOID MlmeJoinReqAction(
{
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
+#endif
// reset all the timers
RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
@@ -375,22 +382,6 @@ VOID MlmeJoinReqAction(
pAd->MlmeAux.Channel = pBss->Channel;
pAd->MlmeAux.CentralChannel = pBss->CentralChannel;
-#ifdef EXT_BUILD_CHANNEL_LIST
- // Country IE of the AP will be evaluated and will be used.
- if ((pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None) &&
- (pBss->bHasCountryIE == TRUE))
- {
- NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pBss->CountryString[0], 2);
- if (pBss->CountryString[2] == 'I')
- pAd->CommonCfg.Geography = IDOR;
- else if (pBss->CountryString[2] == 'O')
- pAd->CommonCfg.Geography = ODOR;
- else
- pAd->CommonCfg.Geography = BOTH;
- BuildChannelListEx(pAd);
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
// Let BBP register at 20MHz to do scan
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
@@ -407,9 +398,6 @@ VOID MlmeJoinReqAction(
if (((pAd->CommonCfg.bIEEE80211H == 1) &&
(pAd->MlmeAux.Channel > 14) &&
RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
-#endif // CARRIER_DETECTION_SUPPORT //
)
{
//
@@ -541,7 +529,7 @@ VOID MlmeStartReqAction(
pAd->MlmeAux.ExtRateLen = pAd->CommonCfg.ExtRateLen;
NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-#ifdef DOT11_N_SUPPORT
+
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy, &pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0], &pAd->MlmeAux.HtCapability, &pAd->MlmeAux.AddHtInfo);
@@ -550,7 +538,6 @@ VOID MlmeStartReqAction(
DBGPRINT(RT_DEBUG_TRACE, ("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n"));
}
else
-#endif // DOT11_N_SUPPORT //
{
pAd->MlmeAux.HtCapabilityLen = 0;
pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
@@ -618,10 +605,9 @@ VOID PeerBeaconAtScanAction(
// Init Variable IE structure
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
pVIE->Length = 0;
-#ifdef DOT11_N_SUPPORT
+
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-#endif // DOT11_N_SUPPORT //
if (PeerBeaconAndProbeRspSanity(pAd,
Elem->Msg,
@@ -672,11 +658,9 @@ VOID PeerBeaconAtScanAction(
Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
-#ifdef DOT11_N_SUPPORT
if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
HtCapabilityLen = SIZE_HT_CAP_IE;
-#endif // DOT11_N_SUPPORT //
+
if ((pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) && (Channel == pAd->StaCfg.CCXScanChannel))
{
Idx = BssTableSetEntry(pAd, &pAd->StaCfg.CCXBssTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
@@ -698,16 +682,7 @@ VOID PeerBeaconAtScanAction(
&CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
&EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (pAd->ChannelList[pAd->CommonCfg.ChannelListIdx].bEffectedChannel == TRUE)
- {
- UCHAR RegClass;
- PeerBeaconAndProbeRspSanity2(pAd, Elem->Msg, Elem->MsgLen, &RegClass);
- TriEventTableSetEntry(pAd, &pAd->CommonCfg.TriggerEventTab, Bssid, &HtCapability, HtCapabilityLen, RegClass, Channel);
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
+
if (Idx != BSS_NOT_FOUND)
{
NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
@@ -755,9 +730,7 @@ VOID PeerBeaconAtJoinAction(
UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
-#ifdef DOT11_N_SUPPORT
UCHAR CentralChannel;
-#endif // DOT11_N_SUPPORT //
// Init Variable IE structure
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
@@ -873,7 +846,7 @@ VOID PeerBeaconAtJoinAction(
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, 16);
-#ifdef DOT11_N_SUPPORT
+
pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
@@ -918,7 +891,6 @@ VOID PeerBeaconAtJoinAction(
}
else
-#endif // DOT11_N_SUPPORT //
{
// To prevent error, let legacy AP must have same CentralChannel and Channel.
if ((HtCapabilityLen == 0) && (PreNHtCapabilityLen == 0))
@@ -933,9 +905,7 @@ VOID PeerBeaconAtJoinAction(
// copy QOS related information
if ((pAd->CommonCfg.bWmmCapable)
-#ifdef DOT11_N_SUPPORT
|| (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-#endif // DOT11_N_SUPPORT //
)
{
NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, &EdcaParm, sizeof(EDCA_PARM));
@@ -952,15 +922,6 @@ VOID PeerBeaconAtJoinAction(
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-#ifdef LEAP_SUPPORT
- // Update CkipFlag
- pAd->StaCfg.CkipFlag = CkipFlag;
-
- // Keep TimeStamp for Re-Association used.
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- pAd->StaCfg.CCKMBeaconAtJoinTimeStamp = TimeStamp;
-#endif // LEAP_SUPPORT //
-
if (AironetCellPowerLimit != 0xFF)
{
//We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power
@@ -1018,14 +979,6 @@ VOID PeerBeacon(
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
if (!(INFRA_ON(pAd) || ADHOC_ON(pAd)
))
return;
@@ -1093,14 +1046,12 @@ VOID PeerBeacon(
if (pAd->Mlme.CntlMachine.CurrState == CNTL_WAIT_DISASSOC)
return;
-#ifdef DOT11_N_SUPPORT
// Copy Control channel for this BSSID.
if (AddHtInfoLen != 0)
Channel = AddHtInfo.ControlChan;
if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
HtCapabilityLen = SIZE_HT_CAP_IE;
-#endif // DOT11_N_SUPPORT //
//
// Housekeeping "SsidBssTab" table for later-on ROAMing usage.
@@ -1165,6 +1116,10 @@ VOID PeerBeacon(
// Add the safeguard against the mismatch of adhoc wep status
if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus)
{
+#ifdef RT30xx
+ DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Not matched wep status %d %d\n", pAd->StaCfg.WepStatus, pAd->ScanTab.BssEntry[Bssidx].WepStatus));
+ DBGPRINT(RT_DEBUG_TRACE, ("bssid=%s\n", pAd->ScanTab.BssEntry[Bssidx].Bssid));
+#endif
return;
}
@@ -1228,11 +1183,14 @@ VOID PeerBeacon(
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
}
+#ifdef RT2860
// at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps
// after last 11b peer left for several seconds, we'll auto switch back to 11G rate
// in MlmePeriodicExec()
+#endif
if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
{
+#ifdef RT2860
BOOLEAN bRestart;
BOOLEAN bnRestart;
@@ -1260,7 +1218,7 @@ VOID PeerBeacon(
pAd->StaCfg.Last11bBeaconRxTime = Now;
break;
}
-#ifdef DOT11_N_SUPPORT
+
// Update Ht Phy.
if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
@@ -1316,7 +1274,6 @@ VOID PeerBeacon(
}
else
-#endif // DOT11_N_SUPPORT //
{
RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo, SIZE_ADD_HT_INFO_IE);
@@ -1330,7 +1287,6 @@ VOID PeerBeacon(
MakeIbssBeacon(pAd); // re-build BEACON frame
AsicEnableIbssSync(pAd); // copy to on-chip memory
}
-#ifdef DOT11_N_SUPPORT
else if ((bRestart == TRUE) && (bnRestart == TRUE))
{
MlmeUpdateTxRates(pAd, FALSE, BSS0);
@@ -1338,7 +1294,6 @@ VOID PeerBeacon(
MakeIbssBeacon(pAd); // re-build BEACON frame
AsicEnableIbssSync(pAd); // copy to on-chip memory
}
-#endif // DOT11_N_SUPPORT //
// At least another peer in this IBSS, declare MediaState as CONNECTED
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
@@ -1402,29 +1357,12 @@ VOID PeerBeacon(
}
MlmeUpdateTxRates(pAd, FALSE, 0);
}
-#ifdef DOT11_N_SUPPORT
else
{
MlmeUpdateTxRates(pAd, FALSE, 0);
MlmeUpdateHtTxRates(pAd, BSS0);
}
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
{
union iwreq_data wrqu;
wext_notify_event_assoc(pAd);
@@ -1434,10 +1372,82 @@ VOID PeerBeacon(
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
}
}
}
+#endif /* RT2860 */
+#ifdef RT2870
+ UCHAR MaxSupportedRateIn500Kbps = 0;
+ UCHAR idx;
+ MAC_TABLE_ENTRY *pEntry;
+
+ // supported rates array may not be sorted. sort it and find the maximum rate
+ for (idx=0; idx<SupRateLen; idx++)
+ {
+ if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
+ MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
+ }
+
+ for (idx=0; idx<ExtRateLen; idx++)
+ {
+ if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
+ MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
+ }
+
+ // look up the existing table
+ pEntry = MacTableLookup(pAd, Addr2);
+
+ // Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon.
+ // To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station.
+ if ((ADHOC_ON(pAd) && (Elem->Wcid == RESERVED_WCID)) ||
+ (pEntry && ((pEntry->LastBeaconRxTime + ADHOC_ENTRY_BEACON_LOST_TIME) < Now)))
+ {
+ if (pEntry == NULL)
+ // Another adhoc joining, add to our MAC table.
+ pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);
+
+ if (StaAddMacTableEntry(pAd, pEntry, MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo) == FALSE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
+ return;
+ }
+
+ if (pEntry &&
+ (Elem->Wcid == RESERVED_WCID))
+ {
+ idx = pAd->StaCfg.DefaultKeyId;
+ RT28XX_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry);
+ }
+ }
+
+ if (pEntry && pEntry->ValidAsCLI)
+ pEntry->LastBeaconRxTime = Now;
+
+ // At least another peer in this IBSS, declare MediaState as CONNECTED
+ if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
+ {
+ OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
+
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+ RTMP_IndicateMediaState(pAd);
+ pAd->ExtraInfo = GENERAL_LINK_UP;
+ AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
+
+ // 2003/03/12 - john
+ // Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that
+ // "site survey" result should always include the current connected network.
+ //
+ Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
+ if (Bssidx == BSS_NOT_FOUND)
+ {
+ Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
+ &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
+ &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0,
+ &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
+ }
+#endif /* RT2870 */
}
if (INFRA_ON(pAd))
@@ -1476,7 +1486,6 @@ VOID PeerBeacon(
DBGPRINT(RT_DEBUG_WARN, ("SYNC - AP changed B/G protection to %d\n", bUseBGProtection));
}
-#ifdef DOT11_N_SUPPORT
// check Ht protection mode. and adhere to the Non-GF device indication by AP.
if ((AddHtInfoLen != 0) &&
((AddHtInfo.AddHtInfo2.OperaionMode != pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode) ||
@@ -1493,7 +1502,6 @@ VOID PeerBeacon(
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP changed N OperaionMode to %d\n", pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode));
}
-#endif // DOT11_N_SUPPORT //
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) &&
ERP_IS_USE_BARKER_PREAMBLE(Erp))
@@ -1528,10 +1536,12 @@ VOID PeerBeacon(
// 5. otherwise, put PHY back to sleep to save battery.
if (MessageToMe)
{
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
}
+#endif
if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
{
@@ -1542,10 +1552,12 @@ VOID PeerBeacon(
}
else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
{
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
}
+#endif
}
else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
(pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
@@ -1559,10 +1571,12 @@ VOID PeerBeacon(
{
// TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
// can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
+#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
}
+#endif
}
else
{
@@ -1577,10 +1591,14 @@ VOID PeerBeacon(
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
{
+#ifdef RT2860
// Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
RTMP_SET_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp;
- //AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
+#endif
+#ifdef RT2870
+ AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
+#endif
}
}
}
@@ -1603,9 +1621,7 @@ VOID PeerProbeReqAction(
UCHAR Addr2[MAC_ADDR_LEN];
CHAR Ssid[MAX_LEN_OF_SSID];
UCHAR SsidLen;
-#ifdef DOT11_N_SUPPORT
UCHAR HtLen, AddHtLen, NewExtLen;
-#endif // DOT11_N_SUPPORT //
HEADER_802_11 ProbeRspHdr;
NDIS_STATUS NStatus;
PUCHAR pOutBuffer = NULL;
@@ -1678,7 +1694,7 @@ VOID PeerProbeReqAction(
END_OF_ARGS);
FrameLen += tmp;
}
-#ifdef DOT11_N_SUPPORT
+
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
ULONG TmpLen;
@@ -1711,7 +1727,7 @@ VOID PeerProbeReqAction(
}
FrameLen += TmpLen;
}
-#endif // DOT11_N_SUPPORT //
+
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
@@ -1811,14 +1827,6 @@ VOID InvalidStateWhenStart(
VOID EnqueuePsPoll(
IN PRTMP_ADAPTER pAd)
{
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
-
if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP)
pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
MiniportMMRequest(pAd, 0, (PUCHAR)&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
@@ -1861,88 +1869,6 @@ VOID EnqueueProbeRequest(
}
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
-VOID BuildEffectedChannelList(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR EChannel[11];
- UCHAR i, j, k;
- UCHAR UpperChannel = 0, LowerChannel = 0;
-
- RTMPZeroMemory(EChannel, 11);
- i = 0;
- // Find upper channel and lower channel.
- if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
- {
- UpperChannel = pAd->CommonCfg.Channel;
- LowerChannel = pAd->CommonCfg.CentralChannel;
- }
- else if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
- {
- UpperChannel = pAd->CommonCfg.CentralChannel;
- LowerChannel = pAd->CommonCfg.Channel;
- }
- else
- {
- return;
- }
-
- // Record channels that is below lower channel..
- if (LowerChannel > 1)
- {
- EChannel[0] = LowerChannel - 1;
- i = 1;
- if (LowerChannel > 2)
- {
- EChannel[1] = LowerChannel - 2;
- i = 2;
- if (LowerChannel > 3)
- {
- EChannel[2] = LowerChannel - 3;
- i = 3;
- }
- }
- }
- // Record channels that is between lower channel and upper channel.
- for (k = LowerChannel;k < UpperChannel;k++)
- {
- EChannel[i] = k;
- i++;
- }
- // Record channels that is above upper channel..
- if (LowerChannel < 11)
- {
- EChannel[i] = UpperChannel + 1;
- i++;
- if (LowerChannel < 10)
- {
- EChannel[i] = LowerChannel + 2;
- i++;
- if (LowerChannel < 9)
- {
- EChannel[i] = LowerChannel + 3;
- i++;
- }
- }
- }
- //
- for (j = 0;j < i;j++)
- {
- for (k = 0;k < pAd->ChannelListNum;k++)
- {
- if (pAd->ChannelList[k].Channel == EChannel[j])
- {
- pAd->ChannelList[k].bEffectedChannel = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,(" EffectedChannel( =%d)\n", EChannel[j]));
- break;
- }
- }
- }
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
BOOLEAN ScanRunning(
IN PRTMP_ADAPTER pAd)
{
diff --git a/drivers/staging/rt2860/sta/wpa.c b/drivers/staging/rt2860/sta/wpa.c
index 2609d845fd5c..58274364d78c 100644
--- a/drivers/staging/rt2860/sta/wpa.c
+++ b/drivers/staging/rt2860/sta/wpa.c
@@ -1384,10 +1384,12 @@ VOID WpaGroupMsg1Action(
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
+#ifndef RT30xx
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
+#endif
//hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK);
}
@@ -1764,7 +1766,12 @@ BOOLEAN ParseKeyData(
// Get GTK length - refer to IEEE 802.11i-2004 p.82
GTKLEN = pKDE->Len -6;
+#ifdef RT30xx
+ if (GTKLEN < LEN_AES_KEY)
+#endif
+#ifndef RT30xx
if (GTKLEN < MIN_LEN_OF_GTK)
+#endif
{
DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
return FALSE;
@@ -1790,10 +1797,12 @@ BOOLEAN ParseKeyData(
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
+#ifndef RT30xx
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
+#endif
return TRUE;
@@ -1915,8 +1924,6 @@ VOID RTMPReportMicError(
}
}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
#define LENGTH_EAP_H 4
// If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)).
INT WpaCheckEapCode(
@@ -1957,7 +1964,6 @@ VOID WpaSendMicFailureToWpaSupplicant(
return;
}
-#endif // WPA_SUPPLICANT_SUPPORT //
VOID WpaMicFailureReportFrame(
IN PRTMP_ADAPTER pAd,
diff --git a/drivers/staging/rt2860/sta_ioctl.c b/drivers/staging/rt2860/sta_ioctl.c
index c5452f152a21..eb0109ad2fc0 100644
--- a/drivers/staging/rt2860/sta_ioctl.c
+++ b/drivers/staging/rt2860/sta_ioctl.c
@@ -49,10 +49,6 @@ extern ULONG RTDebugLevel;
#define GROUP_KEY_NO 4
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
-
extern UCHAR CipherWpa2Template[];
extern UCHAR CipherWpaPskTkip[];
extern UCHAR CipherWpaPskTkipLen;
@@ -89,12 +85,12 @@ struct iw_priv_args privtab[] = {
0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
{ RAIO_ON,
0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
-#ifdef QOS_DLS_SUPPORT
- { SHOW_DLS_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
-#endif // QOS_DLS_SUPPORT //
{ SHOW_CFG_VALUE,
IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
+#if !defined(RT2860) && !defined(RT30xx)
+ { SHOW_ADHOC_ENTRY_INFO,
+ 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
+#endif
/* --- sub-ioctls relations --- */
#ifdef DBG
@@ -104,6 +100,11 @@ struct iw_priv_args privtab[] = {
{ RTPRIV_IOCTL_MAC,
IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
"mac"},
+#ifdef RT30xx
+{ RTPRIV_IOCTL_RF,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
+ "rf"},
+#endif // RT30xx //
{ RTPRIV_IOCTL_E2P,
IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
"e2p"},
@@ -168,16 +169,16 @@ INT Set_PSMode_Proc(
IN PRTMP_ADAPTER pAdapter,
IN PUCHAR arg);
-#ifdef WPA_SUPPLICANT_SUPPORT
INT Set_Wpa_Support(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
-#endif // WPA_SUPPLICANT_SUPPORT //
#ifdef DBG
+#if !defined(RT2860) && !defined(RT30xx)
VOID RTMPIoctlBBP(
IN PRTMP_ADAPTER pAdapter,
IN struct iwreq *wrq);
+#endif
VOID RTMPIoctlMAC(
IN PRTMP_ADAPTER pAdapter,
@@ -186,6 +187,12 @@ VOID RTMPIoctlMAC(
VOID RTMPIoctlE2PROM(
IN PRTMP_ADAPTER pAdapter,
IN struct iwreq *wrq);
+
+#ifdef RT30xx
+VOID RTMPIoctlRF(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+#endif // RT30xx //
#endif // DBG //
@@ -197,11 +204,9 @@ INT Set_FragTest_Proc(
IN PRTMP_ADAPTER pAdapter,
IN PUCHAR arg);
-#ifdef DOT11_N_SUPPORT
INT Set_TGnWifiTest_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
INT Set_LongRetryLimit_Proc(
IN PRTMP_ADAPTER pAdapter,
@@ -211,17 +216,11 @@ INT Set_ShortRetryLimit_Proc(
IN PRTMP_ADAPTER pAdapter,
IN PUCHAR arg);
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CARRIER_DETECTION_SUPPORT //
+#if !defined(RT2860) && !defined(RT30xx)
+INT Show_Adhoc_MacTable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PCHAR extra);
+#endif
static struct {
CHAR *name;
@@ -239,7 +238,6 @@ static struct {
{"BGProtection", Set_BGProtection_Proc},
{"RTSThreshold", Set_RTSThreshold_Proc},
{"FragThreshold", Set_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
{"HtBw", Set_HtBw_Proc},
{"HtMcs", Set_HtMcs_Proc},
{"HtGi", Set_HtGi_Proc},
@@ -253,8 +251,6 @@ static struct {
{"HtBaDecline", Set_BADecline_Proc},
{"HtProtect", Set_HtProtect_Proc},
{"HtMimoPs", Set_HtMimoPs_Proc},
-#endif // DOT11_N_SUPPORT //
-
#ifdef AGGREGATION_SUPPORT
{"PktAggregate", Set_PktAggregate_Proc},
#endif
@@ -277,68 +273,19 @@ static struct {
#ifdef DBG
{"Debug", Set_Debug_Proc},
#endif
-
-#ifdef RALINK_ATE
- {"ATE", Set_ATE_Proc},
- {"ATEDA", Set_ATE_DA_Proc},
- {"ATESA", Set_ATE_SA_Proc},
- {"ATEBSSID", Set_ATE_BSSID_Proc},
- {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
- {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
- {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
- {"ATETXANT", Set_ATE_TX_Antenna_Proc},
- {"ATERXANT", Set_ATE_RX_Antenna_Proc},
- {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
- {"ATETXBW", Set_ATE_TX_BW_Proc},
- {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
- {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
- {"ATETXMCS", Set_ATE_TX_MCS_Proc},
- {"ATETXMODE", Set_ATE_TX_MODE_Proc},
- {"ATETXGI", Set_ATE_TX_GI_Proc},
- {"ATERXFER", Set_ATE_RX_FER_Proc},
- {"ATERRF", Set_ATE_Read_RF_Proc},
- {"ATEWRF1", Set_ATE_Write_RF1_Proc},
- {"ATEWRF2", Set_ATE_Write_RF2_Proc},
- {"ATEWRF3", Set_ATE_Write_RF3_Proc},
- {"ATEWRF4", Set_ATE_Write_RF4_Proc},
- {"ATELDE2P", Set_ATE_Load_E2P_Proc},
- {"ATERE2P", Set_ATE_Read_E2P_Proc},
- {"ATESHOW", Set_ATE_Show_Proc},
- {"ATEHELP", Set_ATE_Help_Proc},
-
-#ifdef RALINK_28xx_QA
- {"TxStop", Set_TxStop_Proc},
- {"RxStop", Set_RxStop_Proc},
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
{"WpaSupport", Set_Wpa_Support},
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
{"FixedTxMode", Set_FixedTxMode_Proc},
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- {"OpMode", Set_OpMode_Proc},
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-#ifdef DOT11_N_SUPPORT
{"TGnWifiTest", Set_TGnWifiTest_Proc},
{"ForceGF", Set_ForceGF_Proc},
-#endif // DOT11_N_SUPPORT //
-#ifdef QOS_DLS_SUPPORT
- {"DlsAddEntry", Set_DlsAddEntry_Proc},
- {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
-#endif // QOS_DLS_SUPPORT //
{"LongRetry", Set_LongRetryLimit_Proc},
{"ShortRetry", Set_ShortRetryLimit_Proc},
-#ifdef EXT_BUILD_CHANNEL_LIST
- {"11dClientMode", Set_Ieee80211dClientMode_Proc},
-#endif // EXT_BUILD_CHANNEL_LIST //
-#ifdef CARRIER_DETECTION_SUPPORT
- {"CarrierDetect", Set_CarrierDetect_Proc},
-#endif // CARRIER_DETECTION_SUPPORT //
-
+//2008/09/11:KH add to support efuse<--
+#ifdef RT30xx
+ {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
+ {"efuseDump", set_eFusedump_Proc},
+ {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
+#endif // RT30xx //
+//2008/09/11:KH add to support efuse-->
{NULL,}
};
@@ -352,6 +299,7 @@ VOID RTMPAddKey(
DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
+#ifdef RT2860
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
{
@@ -365,6 +313,7 @@ VOID RTMPAddKey(
RTMPusecDelay(6000);
pAd->bPCIclkOff = FALSE;
}
+#endif
if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
{
@@ -380,14 +329,13 @@ VOID RTMPAddKey(
NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
+
if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
{
NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
}
else
-#endif // WPA_SUPPLICANT_SUPPORT //
{
NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
@@ -440,14 +388,13 @@ VOID RTMPAddKey(
NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
+
if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
{
NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
}
else
-#endif // WPA_SUPPLICANT_SUPPORT //
{
NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
@@ -559,8 +506,10 @@ VOID RTMPAddKey(
}
}
end:
+#ifdef RT2860
RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
+#endif
return;
}
@@ -582,8 +531,12 @@ rt_ioctl_giwname(struct net_device *dev,
char *name, char *extra)
{
// PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
+#ifdef RT2860
strncpy(name, "RT2860 Wireless", IFNAMSIZ);
+#endif
+#ifdef RT2870
+ strncpy(name, "RT2870 Wireless", IFNAMSIZ);
+#endif // RT2870 //
return 0;
}
@@ -625,7 +578,12 @@ int rt_ioctl_giwfreq(struct net_device *dev,
struct iw_freq *freq, char *extra)
{
VIRTUAL_ADAPTER *pVirtualAd = NULL;
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter;
+#endif
UCHAR ch;
ULONG m;
@@ -636,7 +594,9 @@ int rt_ioctl_giwfreq(struct net_device *dev,
else
{
pVirtualAd = dev->ml_priv;
+#ifndef RT30xx
if (pVirtualAd && pVirtualAd->RtmpDev)
+#endif
pAdapter = pVirtualAd->RtmpDev->ml_priv;
}
@@ -696,6 +656,7 @@ int rt_ioctl_giwmode(struct net_device *dev,
struct iw_request_info *info,
__u32 *mode, char *extra)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -716,6 +677,10 @@ int rt_ioctl_giwmode(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
if (ADHOC_ON(pAdapter))
*mode = IW_MODE_ADHOC;
@@ -759,12 +724,18 @@ int rt_ioctl_giwrange(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *extra)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
struct iw_range *range = (struct iw_range *) extra;
u16 val;
int i;
+#ifndef RT30xx
if (dev->priv_flags == INT_MAIN)
{
pAdapter = dev->ml_priv;
@@ -782,6 +753,7 @@ int rt_ioctl_giwrange(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
data->length = sizeof(struct iw_range);
@@ -901,6 +873,7 @@ int rt_ioctl_giwap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *ap_addr, char *extra)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -921,20 +894,22 @@ int rt_ioctl_giwap(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
{
ap_addr->sa_family = ARPHRD_ETHER;
memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
}
-#ifdef WPA_SUPPLICANT_SUPPORT
// Add for RT2870
else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
{
ap_addr->sa_family = ARPHRD_ETHER;
memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
}
-#endif // WPA_SUPPLICANT_SUPPORT //
else
{
DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
@@ -1041,7 +1016,7 @@ int rt_ioctl_siwscan(struct net_device *dev,
DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
return -EINVAL;
}
-
+#ifdef RT2860
if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
&& (pAdapter->StaCfg.bRadio == TRUE)
&& (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
@@ -1051,13 +1026,11 @@ int rt_ioctl_siwscan(struct net_device *dev,
// Check if still radio off.
else if (pAdapter->bPCIclkOff == TRUE)
return 0;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
+#endif
if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
{
pAdapter->StaCfg.WpaSupplicantScanCount++;
}
-#endif // WPA_SUPPLICANT_SUPPORT //
pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
@@ -1065,7 +1038,6 @@ int rt_ioctl_siwscan(struct net_device *dev,
do{
Now = jiffies;
-#ifdef WPA_SUPPLICANT_SUPPORT
if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
(pAdapter->StaCfg.WpaSupplicantScanCount > 3))
{
@@ -1073,7 +1045,6 @@ int rt_ioctl_siwscan(struct net_device *dev,
Status = NDIS_STATUS_SUCCESS;
break;
}
-#endif // WPA_SUPPLICANT_SUPPORT //
if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
@@ -1133,13 +1104,10 @@ int rt_ioctl_giwscan(struct net_device *dev,
return -EAGAIN;
}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
{
pAdapter->StaCfg.WpaSupplicantScanCount = 0;
}
-#endif // WPA_SUPPLICANT_SUPPORT //
if (pAdapter->ScanTab.BssNr == 0)
{
@@ -1175,7 +1143,88 @@ int rt_ioctl_giwscan(struct net_device *dev,
memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
+#ifdef RT30xx
+ if (current_ev == previous_ev)
+#if WIRELESS_EXT >= 17
+ return -E2BIG;
+#else
+ break;
+#endif
+
+ /*
+ Protocol:
+ it will show scanned AP's WirelessMode .
+ it might be
+ 802.11a
+ 802.11a/n
+ 802.11g/n
+ 802.11b/g/n
+ 802.11g
+ 802.11b/g
+ */
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWNAME;
+
+
+ {
+ PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
+ BOOLEAN isGonly=FALSE;
+ int rateCnt=0;
+
+ if (pBssEntry->Channel>14)
+ {
+ if (pBssEntry->HtCapabilityLen!=0)
+ strcpy(iwe.u.name,"802.11a/n");
+ else
+ strcpy(iwe.u.name,"802.11a");
+ }
+ else
+ {
+ /*
+ if one of non B mode rate is set supported rate . it mean G only.
+ */
+ for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
+ {
+ /*
+ 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
+ */
+ if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
+ isGonly=TRUE;
+ }
+
+ for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
+ {
+ if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
+ isGonly=TRUE;
+ }
+
+
+ if (pBssEntry->HtCapabilityLen!=0)
+ {
+ if (isGonly==TRUE)
+ strcpy(iwe.u.name,"802.11g/n");
+ else
+ strcpy(iwe.u.name,"802.11b/g/n");
+ }
+ else
+ {
+ if (isGonly==TRUE)
+ strcpy(iwe.u.name,"802.11g");
+ else
+ {
+ if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
+ strcpy(iwe.u.name,"802.11b");
+ else
+ strcpy(iwe.u.name,"802.11b/g");
+ }
+ }
+ }
+ }
+
+ previous_ev = current_ev;
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
+#endif /* RT30xx */
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1191,7 +1240,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.data.flags = 1;
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
+ current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1218,7 +1267,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.len = IW_EV_UINT_LEN;
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1238,7 +1287,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.freq.i = 0;
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1253,7 +1302,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.qual.level = 0;
iwe.u.qual.noise = 0;
set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1271,7 +1320,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.data.flags = IW_ENCODE_DISABLED;
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1299,7 +1348,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.bitrate.value = (tmpRate/2) * 1000000;
iwe.u.bitrate.disabled = 0;
- current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
+ current_val = iwe_stream_add_value(info, current_ev,
current_val, end_buf, &iwe,
IW_EV_PARAM_LEN);
@@ -1323,7 +1372,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
iwe.cmd = IWEVGENIE;
iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1341,7 +1390,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
iwe.cmd = IWEVGENIE;
iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1360,9 +1409,9 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
NdisMoveMemory(custom, "wpa_ie=", 7);
for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
+ sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1380,9 +1429,9 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
NdisMoveMemory(custom, "rsn_ie=", 7);
for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
+ sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
if (current_ev == previous_ev)
#if WIRELESS_EXT >= 17
return -E2BIG;
@@ -1445,6 +1494,7 @@ int rt_ioctl_giwessid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *essid)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -1465,6 +1515,10 @@ int rt_ioctl_giwessid(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
data->flags = 1;
if (MONITOR_ON(pAdapter))
@@ -1479,6 +1533,14 @@ int rt_ioctl_giwessid(struct net_device *dev,
data->length = pAdapter->CommonCfg.SsidLen;
memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
}
+#ifdef RT2870
+ // Add for RT2870
+ else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
+ {
+ data->length = pAdapter->CommonCfg.SsidLen;
+ memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
+ }
+#endif // RT2870 //
else
{//the ANY ssid was specified
data->length = 0;
@@ -1516,6 +1578,7 @@ int rt_ioctl_giwnickn(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *nickname)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -1536,6 +1599,10 @@ int rt_ioctl_giwnickn(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
if (data->length > strlen(pAdapter->nickname) + 1)
data->length = strlen(pAdapter->nickname) + 1;
@@ -1579,6 +1646,7 @@ int rt_ioctl_giwrts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -1599,6 +1667,10 @@ int rt_ioctl_giwrts(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
//check if the interface is down
if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
@@ -1645,6 +1717,7 @@ int rt_ioctl_giwfrag(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -1665,6 +1738,10 @@ int rt_ioctl_giwfrag(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
//check if the interface is down
if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
@@ -1705,8 +1782,13 @@ int rt_ioctl_siwencode(struct net_device *dev,
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
goto done;
}
+#ifndef RT30xx
else if ((erq->length == 0) &&
(erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
+#endif
+#ifdef RT30xx
+ else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
+#endif
{
STA_PORT_SECURED(pAdapter);
pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
@@ -1717,7 +1799,9 @@ int rt_ioctl_siwencode(struct net_device *dev,
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
else
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
+#ifndef RT30xx
goto done;
+#endif
}
if (erq->length > 0)
@@ -1736,6 +1820,12 @@ int rt_ioctl_siwencode(struct net_device *dev,
//Using default key
keyIdx = pAdapter->StaCfg.DefaultKeyId;
}
+#ifdef RT30xx
+ else
+ {
+ pAdapter->StaCfg.DefaultKeyId=keyIdx;
+ }
+#endif
NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
@@ -1787,7 +1877,11 @@ rt_ioctl_giwencode(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *erq, char *key)
{
+#ifdef RT30xx
+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
+#endif
int kid;
+#ifndef RT30xx
PRTMP_ADAPTER pAdapter = NULL;
VIRTUAL_ADAPTER *pVirtualAd = NULL;
@@ -1808,6 +1902,7 @@ rt_ioctl_giwencode(struct net_device *dev,
So the net_dev->ml_priv will be NULL in 2rd open */
return -ENETDOWN;
}
+#endif
//check if the interface is down
if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
@@ -1952,14 +2047,6 @@ rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
memset(extra, 0x00, IW_PRIV_SIZE_MASK);
sprintf(extra, "\n\n");
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- }
- else
-#endif // RALINK_ATE //
{
sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
@@ -1975,31 +2062,12 @@ rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if (pAd->ate.RxAntennaSel == 0)
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
- else
- {
- sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- }
- }
- else
-#endif // RALINK_ATE //
{
sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
}
-#ifdef WPA_SUPPLICANT_SUPPORT
sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
wrq->length = strlen(extra) + 1; // 1: size of '\0'
DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
@@ -2007,7 +2075,6 @@ rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
return Status;
}
-#ifdef DOT11_N_SUPPORT
void getBaInfo(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pOutBuf)
@@ -2022,8 +2089,7 @@ void getBaInfo(
if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
|| (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
{
- sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
- pOutBuf,
+ sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
@@ -2033,7 +2099,7 @@ void getBaInfo(
if (pEntry->BARecWcidArray[j] != 0)
{
pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
+ sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
}
}
sprintf(pOutBuf, "%s\n", pOutBuf);
@@ -2044,7 +2110,7 @@ void getBaInfo(
if (pEntry->BAOriWcidArray[j] != 0)
{
pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
+ sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
}
}
sprintf(pOutBuf, "%s\n\n", pOutBuf);
@@ -2055,7 +2121,6 @@ void getBaInfo(
return;
}
-#endif // DOT11_N_SUPPORT //
static int
rt_private_show(struct net_device *dev, struct iw_request_info *info,
@@ -2101,12 +2166,10 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
case SHOW_CONN_STATUS:
if (MONITOR_ON(pAd))
{
-#ifdef DOT11_N_SUPPORT
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
pAd->CommonCfg.RegTransmitSetting.field.BW)
sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
else
-#endif // DOT11_N_SUPPORT //
sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
}
else
@@ -2140,12 +2203,10 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
wrq->length = strlen(extra) + 1; // 1: size of '\0'
break;
-#ifdef DOT11_N_SUPPORT
case SHOW_BA_INFO:
getBaInfo(pAd, extra);
wrq->length = strlen(extra) + 1; // 1: size of '\0'
break;
-#endif // DOT11_N_SUPPORT //
case SHOW_DESC_INFO:
{
Show_DescInfo_Proc(pAd, NULL);
@@ -2174,6 +2235,14 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
wrq->length = strlen(extra) + 1; // 1: size of '\0'
break;
case RAIO_ON:
+#ifdef RT2870
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+ {
+ sprintf(extra, "Scanning\n");
+ wrq->length = strlen(extra) + 1; // 1: size of '\0'
+ break;
+ }
+#endif
pAd->StaCfg.bSwRadio = TRUE;
//if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
{
@@ -2189,16 +2258,6 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
wrq->length = strlen(extra) + 1; // 1: size of '\0'
break;
-
-#ifdef QOS_DLS_SUPPORT
- case SHOW_DLS_ENTRY_INFO:
- {
- Set_DlsEntryInfo_Display_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
-#endif // QOS_DLS_SUPPORT //
-
case SHOW_CFG_VALUE:
{
Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
@@ -2206,6 +2265,12 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
wrq->length = strlen(extra) + 1; // 1: size of '\0'
}
break;
+#if !defined(RT2860) && !defined(RT30xx)
+ case SHOW_ADHOC_ENTRY_INFO:
+ Show_Adhoc_MacTable_Proc(pAd, extra);
+ wrq->length = strlen(extra) + 1; // 1: size of '\0'
+ break;
+#endif
default:
DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
break;
@@ -2312,9 +2377,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-#ifdef WPA_SUPPLICANT_SUPPORT
pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
}
else if (param->value == IW_AUTH_CIPHER_TKIP)
{
@@ -2356,22 +2419,16 @@ int rt_ioctl_siwauth(struct net_device *dev,
if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
{
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-#ifdef WPA_SUPPLICANT_SUPPORT
pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
}
else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
{
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#ifdef WPA_SUPPLICANT_SUPPORT
pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
}
-#ifdef WPA_SUPPLICANT_SUPPORT
else
// WEP 1x
pAdapter->StaCfg.IEEE8021X = TRUE;
-#endif // WPA_SUPPLICANT_SUPPORT //
}
else if (param->value == 0)
{
@@ -2457,6 +2514,7 @@ void fnSetCipherKey(
IN BOOLEAN bGTK,
IN struct iw_encode_ext *ext)
{
+#ifdef RT2860
RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
{
@@ -2470,7 +2528,7 @@ void fnSetCipherKey(
RTMPusecDelay(6000);
pAdapter->bPCIclkOff = FALSE;
}
-
+#endif
NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
@@ -2501,8 +2559,9 @@ void fnSetCipherKey(
keyIdx,
pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
&pAdapter->MacTab.Content[BSSID_WCID]);
-
+#ifdef RT2860
RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
+#endif
}
int rt_ioctl_siwencodeext(struct net_device *dev,
@@ -2567,7 +2626,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
-
+#ifndef RT30xx
if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
{
@@ -2582,6 +2641,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
// Indicate Connected for GUI
pAdapter->IndicateMediaState = NdisMediaStateConnected;
}
+#endif
break;
case IW_ENCODE_ALG_TKIP:
DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
@@ -2752,7 +2812,6 @@ int rt_ioctl_giwgenie(struct net_device *dev,
return 0;
}
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
#ifdef SIOCSIWGENIE
if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
{
@@ -2764,7 +2823,6 @@ int rt_ioctl_giwgenie(struct net_device *dev,
}
else
#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
{
UCHAR RSNIe = IE_WPA;
@@ -2895,15 +2953,13 @@ rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
if (sscanf(this_char, "%d", &(bbpId)) == 1)
{
+#ifndef RT30xx
if (bbpId <= 136)
+#endif // RT30xx //
+#ifdef RT30xx
+ if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
+#endif // RT30xx //
{
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
{
RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
}
@@ -2927,17 +2983,13 @@ rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
{ //Write
if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
{
+#ifndef RT30xx
if (bbpId <= 136)
+#endif // RT30xx //
+#ifdef RT30xx
+ if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
+#endif // RT30xx //
{
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
//Read it back for showing
@@ -2968,21 +3020,24 @@ next:
{
memset(extra, 0x00, IW_PRIV_SIZE_MASK);
sprintf(extra, "\n");
+#ifndef RT30xx
for (bbpId = 0; bbpId <= 136; bbpId++)
+#endif // RT30xx //
+#ifdef RT30xx
+ for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
+#endif // RT30xx //
{
if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
break;
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
+#ifndef RT30xx
sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
if (bbpId%5 == 4)
sprintf(extra+strlen(extra), "\n");
+#endif
+#ifdef RT30xx
+ sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
+#endif
}
wrq->length = strlen(extra) + 1; // 1: size of '\0'
@@ -3022,9 +3077,7 @@ int rt_ioctl_siwrate(struct net_device *dev,
(pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
RTMPSetDesiredRates(pAd, -1);
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
}
else
{
@@ -3037,9 +3090,7 @@ int rt_ioctl_siwrate(struct net_device *dev,
else
{
pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
}
DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
}
@@ -3087,13 +3138,11 @@ int rt_ioctl_giwrate(struct net_device *dev,
else
ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-#ifdef DOT11_N_SUPPORT
if (ht_setting.field.MODE >= MODE_HTMIX)
{
rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
}
else
-#endif // DOT11_N_SUPPORT //
if (ht_setting.field.MODE == MODE_OFDM)
rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
else if (ht_setting.field.MODE == MODE_CCK)
@@ -3184,11 +3233,7 @@ static const iw_handler rt_handler[] =
static const iw_handler rt_priv_handlers[] = {
(iw_handler) NULL, /* + 0x00 */
(iw_handler) NULL, /* + 0x01 */
-#ifndef CONFIG_AP_SUPPORT
(iw_handler) rt_ioctl_setparam, /* + 0x02 */
-#else
- (iw_handler) NULL, /* + 0x02 */
-#endif // CONFIG_AP_SUPPORT //
#ifdef DBG
(iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
#else
@@ -3258,27 +3303,13 @@ INT RTMPSetInformation(
ULONG PowerTemp;
BOOLEAN RadioState;
BOOLEAN StateMachineTouched = FALSE;
-#ifdef DOT11_N_SUPPORT
OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
PNDIS_802_11_PMKID pPmkId = NULL;
BOOLEAN IEEE8021xState = FALSE;
BOOLEAN IEEE8021x_required_keys = FALSE;
UCHAR wpa_supplicant_enable = 0;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef SNMP_SUPPORT
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR ctmp;
-#endif // SNMP_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
switch(cmd & 0x7FFF) {
@@ -3298,21 +3329,12 @@ INT RTMPSetInformation(
pAdapter->CommonCfg.PhyMode = 0xff;
// Build all corresponding channel information
RTMPSetPhyMode(pAdapter, TmpPhy);
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
pAdapter->CommonCfg.CountryRegion));
}
break;
case OID_802_11_BSSID_LIST_SCAN:
- #ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
Now = jiffies;
DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
@@ -3414,13 +3436,6 @@ INT RTMPSetInformation(
}
break;
case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
Status = -EINVAL;
else
@@ -3492,9 +3507,7 @@ INT RTMPSetInformation(
if (PhyMode <= MaxPhyMode)
{
RTMPSetPhyMode(pAdapter, PhyMode);
-#ifdef DOT11_N_SUPPORT
SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
}
DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
}
@@ -3513,9 +3526,14 @@ INT RTMPSetInformation(
{
// allow dynamic change of "USE OFDM rate or not" in ADHOC mode
// if setting changed, need to reset current TX rate as well as BEACON frame format
+#ifdef RT30xx
+ pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
+#endif
if (pAdapter->StaCfg.BssType == BSS_ADHOC)
{
+#ifndef RT30xx
pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
+#endif
RTMPSetPhyMode(pAdapter, PhyMode);
MlmeUpdateTxRates(pAdapter, FALSE, 0);
MakeIbssBeacon(pAdapter); // re-build BEACON frame
@@ -3679,6 +3697,15 @@ INT RTMPSetInformation(
pAdapter->Counters8023.RxNoBuffer = 0;
pAdapter->Counters8023.GoodReceives = 0;
pAdapter->Counters8023.RxNoBuffer = 0;
+#ifdef RT2870
+ pAdapter->BulkOutComplete = 0;
+ pAdapter->BulkOutCompleteOther= 0;
+ pAdapter->BulkOutCompleteCancel = 0;
+ pAdapter->BulkOutReq = 0;
+ pAdapter->BulkInReq= 0;
+ pAdapter->BulkInComplete = 0;
+ pAdapter->BulkInCompleteFail = 0;
+#endif // RT2870 //
DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
break;
case OID_802_11_RTS_THRESHOLD:
@@ -3763,10 +3790,10 @@ INT RTMPSetInformation(
RTMPSetPhyMode(pAdapter, PHY_11A);
else
Status = -EINVAL;
-#ifdef DOT11_N_SUPPORT
+
if (Status == NDIS_STATUS_SUCCESS)
SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
+
DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
}
break;
@@ -3910,7 +3937,6 @@ INT RTMPSetInformation(
pAdapter->bConfigChanged = TRUE;
}
break;
-#ifdef DOT11_N_SUPPORT
case RT_OID_802_11_SET_HT_PHYMODE:
if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
Status = -EINVAL;
@@ -3929,7 +3955,6 @@ INT RTMPSetInformation(
pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
pAdapter->StaCfg.HTPhyMode.field.STBC));
break;
-#endif // DOT11_N_SUPPORT //
case RT_OID_802_11_SET_APSD_SETTING:
if (wrq->u.data.length != sizeof(ULONG))
Status = -EINVAL;
@@ -3970,62 +3995,7 @@ INT RTMPSetInformation(
DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
}
break;
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
- Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
- if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
- {
- int i;
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- }
- break;
-
- case RT_OID_802_11_SET_DLS_PARAM:
- if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
- Status = -EINVAL;
- else
- {
- RT_802_11_DLS Dls;
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
- }
- break;
-#endif // QOS_DLS_SUPPORT //
case RT_OID_802_11_SET_WMM:
if (wrq->u.data.length != sizeof(BOOLEAN))
Status = -EINVAL;
@@ -4037,13 +4007,6 @@ INT RTMPSetInformation(
break;
case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
//
// Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
// Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
@@ -4074,8 +4037,6 @@ INT RTMPSetInformation(
StateMachineTouched = TRUE;
}
break;
-
-#ifdef DOT11_N_SUPPORT
case RT_OID_802_11_SET_IMME_BA_CAP:
if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
Status = -EINVAL;
@@ -4230,8 +4191,6 @@ INT RTMPSetInformation(
}
}
break;
-#endif // DOT11_N_SUPPORT //
-
// For WPA_SUPPLICANT to set static wep key
case OID_802_11_ADD_WEP:
pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
@@ -4285,19 +4244,21 @@ INT RTMPSetInformation(
// Default key for tx (shared key)
if (pWepKey->KeyIndex & 0x80000000)
{
-#ifdef WPA_SUPPLICANT_SUPPORT
// set key material and key length
NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-#endif // WPA_SUPPLICANT_SUPPORT //
pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
+#ifndef RT30xx
+#ifdef RT2860
if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
+#endif
+#ifdef RT2870
+ if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
+#endif
(pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
{
Key = pWepKey->KeyMaterial;
@@ -4314,7 +4275,10 @@ INT RTMPSetInformation(
pAdapter->IndicateMediaState = NdisMediaStateConnected;
}
else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
-#endif // WPA_SUPPLICANT_SUPPORT
+#endif
+#ifdef RT30xx
+ if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
+#endif
{
Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
@@ -4335,7 +4299,6 @@ INT RTMPSetInformation(
}
kfree(pWepKey);
break;
-#ifdef WPA_SUPPLICANT_SUPPORT
case OID_SET_COUNTERMEASURES:
if (wrq->u.data.length != sizeof(int))
Status = -EINVAL;
@@ -4469,95 +4432,6 @@ INT RTMPSetInformation(
if(pPmkId)
kfree(pPmkId);
break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
-#ifdef SNMP_SUPPORT
- case OID_802_11_SHORTRETRYLIMIT:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
- }
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
- }
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
- pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- //pKey = &WepKey;
-
- if ( pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
- }
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
- DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
-
- // it is a shared key
- if (KeyIdx > 4)
- Status = -EINVAL;
- else
- {
- pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
- if (pKey->KeyIndex & 0x80000000)
- {
- // Default key for tx (shared key)
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
- //RestartAPIsRequired = TRUE;
- }
- break;
-
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
-
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
-
- break;
-
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
- sprintf(&ctmp,"%d", ctmp);
- Set_Channel_Proc(pAdapter, &ctmp);
- }
- break;
-#endif
-
-
-
default:
DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
Status = -EOPNOTSUPP;
@@ -4599,16 +4473,6 @@ INT RTMPQueryInformation(
UCHAR driverVersion[8];
OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
-
-#ifdef SNMP_SUPPORT
- //for snmp, kathy
- DefaultKeyIdxValue *pKeyIdxValue;
- INT valueLen;
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR tmp[64];
-#endif //SNMP
-
switch(cmd)
{
case RT_OID_DEVICE_NAME:
@@ -4625,16 +4489,6 @@ INT RTMPQueryInformation(
Status = -EFAULT;
}
break;
-#ifdef RALINK_ATE
- case RT_QUERY_ATE_TXDONE_COUNT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
- wrq->u.data.length = sizeof(UINT32);
- if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#endif // RALINK_ATE //
case OID_802_11_BSSID_LIST:
if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
{
@@ -4776,14 +4630,6 @@ INT RTMPQueryInformation(
Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
break;
case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-#endif // RALINK_ATE //
if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
{
Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
@@ -5121,7 +4967,6 @@ INT RTMPQueryInformation(
Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
break;
-#ifdef WPA_SUPPLICANT_SUPPORT
case RT_OID_NEW_DRIVER:
{
UCHAR enabled = 1;
@@ -5135,8 +4980,6 @@ INT RTMPQueryInformation(
Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
case RT_OID_DRIVER_DEVICE_NAME:
DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
wrq->u.data.length = 16;
@@ -5211,154 +5054,20 @@ INT RTMPQueryInformation(
case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
wrq->u.data.length = sizeof(UCHAR);
i = 0;
-#ifdef MULTIPLE_CARD_SUPPORT
- i = 1;
-#endif // MULTIPLE_CARD_SUPPORT //
if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
{
Status = -EFAULT;
}
DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
break;
-#ifdef SNMP_SUPPORT
- case RT_OID_802_11_MAC_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREROUI:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
- wrq->u.data.length = ManufacturerOUI_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTURERNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_RESOURCETYPEIDNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
- wrq->u.data.length = strlen(ResourceTypeIdName);
- Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
- ulInfo = 1; // 1 is support wep else 2 is not support.
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_POWERMANAGEMENTMODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
- if (pAdapter->StaCfg.Psm == PSMP_ACTION)
- ulInfo = 1; // 1 is power active else 2 is power save.
- else
- ulInfo = 2;
-
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
- //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
- pKeyIdxValue = wrq->u.data.pointer;
- DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
- valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- NdisMoveMemory(pKeyIdxValue->Value,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
- valueLen);
- pKeyIdxValue->Value[valueLen]='\0';
-
- wrq->u.data.length = sizeof(DefaultKeyIdxValue);
-
- Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- pAdapter->SharedKey[BSS0][0].Key[0],
- pAdapter->SharedKey[BSS0][1].Key[0],
- pAdapter->SharedKey[BSS0][2].Key[0],
- pAdapter->SharedKey[BSS0][3].Key[0]));
- break;
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
- break;
-
- case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- wrq->u.data.length);
- break;
-
- case OID_802_11_SHORTRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRODUCTID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
-
- {
-
- USHORT device_id;
- if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
- pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
- else
- DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
- sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
- }
- wrq->u.data.length = strlen(tmp);
- Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
- wrq->u.data.length = sizeof(UCHAR);
- DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-#endif //SNMP_SUPPORT
case OID_802_11_BUILD_CHANNEL_EX:
{
UCHAR value;
DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
wrq->u.data.length = sizeof(UCHAR);
-#ifdef EXT_BUILD_CHANNEL_LIST
- DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 1;
-#else
DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
value = 0;
-#endif // EXT_BUILD_CHANNEL_LIST //
Status = copy_to_user(wrq->u.data.pointer, &value, 1);
DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
}
@@ -5409,35 +5118,6 @@ INT RTMPQueryInformation(
DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
break;
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_QUERY_DLS:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- break;
-
- case RT_OID_802_11_QUERY_DLS_PARAM:
- {
- PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
- if (pDlsInfo == NULL)
- break;
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
- }
-
- pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
- wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
-
- if (pDlsInfo)
- kfree(pDlsInfo);
- }
- break;
-#endif // QOS_DLS_SUPPORT //
default:
DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
Status = -EOPNOTSUPP;
@@ -5480,14 +5160,6 @@ INT rt28xx_sta_ioctl(
//check if the interface is down
if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
{
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (wrq->u.data.pointer == NULL)
- {
- return Status;
- }
-
- if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
{
DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
return -ENETDOWN;
@@ -5501,15 +5173,6 @@ INT rt28xx_sta_ioctl(
switch(cmd)
{
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
- case RTPRIV_IOCTL_ATE:
- {
- RtmpDoAte(pAd, wrq);
- }
- break;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
case SIOCGIFHWADDR:
DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
@@ -5640,6 +5303,9 @@ INT rt28xx_sta_ioctl(
Status = -EOPNOTSUPP;
break;
case RT_PRIV_IOCTL:
+#ifdef RT30xx
+ case RT_PRIV_IOCTL_EXT:
+#endif
subcmd = wrq->u.data.flags;
if( subcmd & OID_GET_SET_TOGGLE)
Status = RTMPSetInformation(pAd, rq, subcmd);
@@ -5671,6 +5337,11 @@ INT rt28xx_sta_ioctl(
case RTPRIV_IOCTL_E2P:
RTMPIoctlE2PROM(pAd, wrq);
break;
+#ifdef RT30xx
+ case RTPRIV_IOCTL_RF:
+ RTMPIoctlRF(pAd, wrq);
+ break;
+#endif // RT30xx //
#endif // DBG //
case SIOCETHTOOL:
break;
@@ -5766,6 +5437,9 @@ INT Set_WmmCapable_Proc(
bWmmCapable = simple_strtol(arg, 0, 10);
if ((bWmmCapable == 1)
+#ifdef RT2870
+ && (pAd->NumberOfPipes >= 5)
+#endif // RT2870 //
)
pAd->CommonCfg.bWmmCapable = TRUE;
else if (bWmmCapable == 0)
@@ -5873,19 +5547,14 @@ INT Set_NetworkType_Proc(
DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
if (pAdapter->CommonCfg.CentralChannel == 0)
{
-#ifdef DOT11_N_SUPPORT
if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
pAdapter->CommonCfg.CentralChannel = 36;
else
-#endif // DOT11_N_SUPPORT //
pAdapter->CommonCfg.CentralChannel = 6;
}
-#ifdef DOT11_N_SUPPORT
else
N_ChannelCheck(pAdapter);
-#endif // DOT11_N_SUPPORT //
-#ifdef DOT11_N_SUPPORT
if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
@@ -5936,7 +5605,6 @@ INT Set_NetworkType_Proc(
pAdapter->CommonCfg.CentralChannel));
}
else
-#endif // DOT11_N_SUPPORT //
{
// 20MHz
RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
@@ -5997,12 +5665,10 @@ INT Set_AuthMode_Proc(
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
else
return FALSE;
@@ -6544,7 +6210,6 @@ INT Set_PSMode_Proc(
return TRUE;
}
-#ifdef WPA_SUPPLICANT_SUPPORT
/*
==========================================================================
Description:
@@ -6575,7 +6240,6 @@ INT Set_Wpa_Support(
return TRUE;
}
-#endif // WPA_SUPPLICANT_SUPPORT //
#ifdef DBG
/*
@@ -6608,7 +6272,9 @@ VOID RTMPIoctlMAC(
UCHAR temp[16], temp2[16];
UINT32 macValue = 0;
INT Status;
-
+#ifdef RT30xx
+ BOOLEAN bIsPrintAllMAC = FALSE;
+#endif
memset(msg, 0x00, 1024);
if (wrq->u.data.length > 1) //No parameters.
@@ -6659,7 +6325,13 @@ VOID RTMPIoctlMAC(
sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
}
else
+#ifndef RT30xx
{//Invalid parametes, so default printk all bbp
+#endif
+#ifdef RT30xx
+ {//Invalid parametes, so default printk all mac
+ bIsPrintAllMAC = TRUE;
+#endif
goto next;
}
}
@@ -6730,13 +6402,6 @@ VOID RTMPIoctlMAC(
UCHAR R66;
pAdapter->BbpTuning.bEnable = FALSE;
R66 = 0x26 + GET_LNA_GAIN(pAdapter);
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- }
- else
-#endif // RALINK_ATE //
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
}
@@ -6750,7 +6415,52 @@ VOID RTMPIoctlMAC(
}
}
}
+#ifdef RT30xx
+ else
+ bIsPrintAllMAC = TRUE;
+#endif
next:
+#ifdef RT30xx
+ if (bIsPrintAllMAC)
+ {
+ struct file *file_w;
+ PCHAR fileName = "MacDump.txt";
+ mm_segment_t orig_fs;
+
+ orig_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ // open file
+ file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
+ if (IS_ERR(file_w))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
+ }
+ else
+ {
+ if (file_w->f_op && file_w->f_op->write)
+ {
+ file_w->f_pos = 0;
+ macAddr = 0x1000;
+
+ while (macAddr <= 0x1800)
+ {
+ RTMP_IO_READ32(pAdapter, macAddr, &macValue);
+ sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
+
+ // write data to file
+ file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
+
+ printk("%s", msg);
+ macAddr += 4;
+ }
+ sprintf(msg, "\nDump all MAC values to %s\n", fileName);
+ }
+ filp_close(file_w, NULL);
+ }
+ set_fs(orig_fs);
+ }
+#endif /* RT30xx */
if(strlen(msg) == 1)
sprintf(msg+strlen(msg), "===>Error command format!");
@@ -6791,7 +6501,9 @@ VOID RTMPIoctlE2PROM(
UCHAR temp[16], temp2[16];
USHORT eepValue;
int Status;
-
+#ifdef RT30xx
+ BOOLEAN bIsPrintAllE2P = FALSE;
+#endif
memset(msg, 0x00, 1024);
if (wrq->u.data.length > 1) //No parameters.
@@ -6845,6 +6557,9 @@ VOID RTMPIoctlE2PROM(
}
else
{//Invalid parametes, so default printk all bbp
+#ifdef RT30xx
+ bIsPrintAllE2P = TRUE;
+#endif
goto next;
}
}
@@ -6903,7 +6618,52 @@ VOID RTMPIoctlE2PROM(
sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
}
}
+#ifdef RT30xx
+ else
+ bIsPrintAllE2P = TRUE;
+#endif
next:
+#ifdef RT30xx
+ if (bIsPrintAllE2P)
+ {
+ struct file *file_w;
+ PCHAR fileName = "EEPROMDump.txt";
+ mm_segment_t orig_fs;
+
+ orig_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ // open file
+ file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
+ if (IS_ERR(file_w))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
+ }
+ else
+ {
+ if (file_w->f_op && file_w->f_op->write)
+ {
+ file_w->f_pos = 0;
+ eepAddr = 0x00;
+
+ while (eepAddr <= 0xFE)
+ {
+ RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
+ sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
+
+ // write data to file
+ file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
+
+ printk("%s", msg);
+ eepAddr += 2;
+ }
+ sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
+ }
+ filp_close(file_w, NULL);
+ }
+ set_fs(orig_fs);
+ }
+#endif /* RT30xx */
if(strlen(msg) == 1)
sprintf(msg+strlen(msg), "===>Error command format!");
@@ -6914,6 +6674,154 @@ next:
DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
}
+#ifdef RT30xx
+/*
+ ==========================================================================
+ Description:
+ Read / Write RF register
+Arguments:
+ pAdapter Pointer to our adapter
+ wrq Pointer to the ioctl argument
+
+ Return Value:
+ None
+
+ Note:
+ Usage:
+ 1.) iwpriv ra0 rf ==> read all RF registers
+ 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
+ 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
+ ==========================================================================
+*/
+VOID RTMPIoctlRF(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq)
+{
+ CHAR *this_char;
+ CHAR *value;
+ UCHAR regRF = 0;
+ CHAR msg[2048];
+ CHAR arg[255];
+ INT rfId;
+ LONG rfValue;
+ int Status;
+ BOOLEAN bIsPrintAllRF = FALSE;
+
+
+ memset(msg, 0x00, 2048);
+ if (wrq->u.data.length > 1) //No parameters.
+ {
+ Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
+ sprintf(msg, "\n");
+
+ //Parsing Read or Write
+ this_char = arg;
+ if (!*this_char)
+ goto next;
+
+ if ((value = strchr(this_char, '=')) != NULL)
+ *value++ = 0;
+
+ if (!value || !*value)
+ { //Read
+ if (sscanf(this_char, "%d", &(rfId)) == 1)
+ {
+ if (rfId <= 31)
+ {
+ // In RT2860 ATE mode, we do not load 8051 firmware.
+ //We must access RF directly.
+ // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
+ // according to Andy, Gary, David require.
+ // the command rf shall read rf register directly for dubug.
+ // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
+ RT30xxReadRFRegister(pAdapter, rfId, &regRF);
+
+ sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
+ }
+ else
+ {//Invalid parametes, so default printk all RF
+ bIsPrintAllRF = TRUE;
+ goto next;
+ }
+ }
+ else
+ { //Invalid parametes, so default printk all RF
+ bIsPrintAllRF = TRUE;
+ goto next;
+ }
+ }
+ else
+ { //Write
+ if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
+ {
+ if (rfId <= 31)
+ {
+ // In RT2860 ATE mode, we do not load 8051 firmware.
+ // We should access RF registers directly.
+ // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
+ {
+ // according to Andy, Gary, David require.
+ // the command RF shall read/write RF register directly for dubug.
+ //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
+ //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
+ RT30xxReadRFRegister(pAdapter, rfId, &regRF);
+ RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
+ //Read it back for showing
+ //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
+ RT30xxReadRFRegister(pAdapter, rfId, &regRF);
+ sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
+ }
+ }
+ else
+ {//Invalid parametes, so default printk all RF
+ bIsPrintAllRF = TRUE;
+ }
+ }
+ else
+ { //Invalid parametes, so default printk all RF
+ bIsPrintAllRF = TRUE;
+ }
+ }
+ }
+ else
+ bIsPrintAllRF = TRUE;
+next:
+ if (bIsPrintAllRF)
+ {
+ memset(msg, 0x00, 2048);
+ sprintf(msg, "\n");
+ for (rfId = 0; rfId <= 31; rfId++)
+ {
+ // according to Andy, Gary, David require.
+ // the command RF shall read/write RF register directly for dubug.
+ RT30xxReadRFRegister(pAdapter, rfId, &regRF);
+ sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
+ }
+ // Copy the information into the user buffer
+ DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
+ wrq->u.data.length = strlen(msg);
+ if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
+ }
+ }
+ else
+ {
+ if(strlen(msg) == 1)
+ sprintf(msg+strlen(msg), "===>Error command format!");
+
+ DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
+ // Copy the information into the user buffer
+ DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
+
+ // Copy the information into the user buffer
+ wrq->u.data.length = strlen(msg);
+ Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
+}
+#endif // RT30xx //
#endif // DBG //
@@ -6960,37 +6868,47 @@ INT Set_ShortRetryLimit_Proc(
return TRUE;
}
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
+#if !defined(RT2860) && !defined(RT30xx)
+INT Show_Adhoc_MacTable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PCHAR extra)
{
- if (simple_strtol(arg, 0, 10) == 0)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
- else if (simple_strtol(arg, 0, 10) == 1)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
- else if (simple_strtol(arg, 0, 10) == 2)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
- else
- return FALSE;
+ INT i;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
- return TRUE;
-}
-#endif // EXT_BUILD_CHANNEL_LIST //
+ sprintf(extra, "\n");
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
+ sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
+
+ sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
+ "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
+
+ for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
+ {
+ PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
+
+ if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
+ break;
+ if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
+ {
+ sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
+ pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
+ pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
+ sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
+ sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
+ sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
+ sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
+ sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
+ sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
+ sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
+ sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
+ sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
+ sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
+ sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
+ (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
+ sprintf(extra, "%s\n", extra);
+ }
+ }
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
return TRUE;
}
-#endif // CARRIER_DETECTION_SUPPORT //
-
+#endif /* RT2870 */
diff --git a/drivers/staging/rt2860/wpa.h b/drivers/staging/rt2860/wpa.h
index 0134ae6097cf..e6716748adfa 100644
--- a/drivers/staging/rt2860/wpa.h
+++ b/drivers/staging/rt2860/wpa.h
@@ -90,7 +90,9 @@
#define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
#define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
#define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
+#ifndef RT30xx
#define MIN_LEN_OF_GTK 5
+#endif
// RSN IE Length definition
#define MAX_LEN_OF_RSNIE 90
@@ -150,19 +152,6 @@
// EAPOL Key Information definition within Key descriptor format
typedef struct PACKED _KEY_INFO
{
-#ifdef RT_BIG_ENDIAN
- UCHAR KeyAck:1;
- UCHAR Install:1;
- UCHAR KeyIndex:2;
- UCHAR KeyType:1;
- UCHAR KeyDescVer:3;
- UCHAR Rsvd:3;
- UCHAR EKD_DL:1; // EKD for AP; DL for STA
- UCHAR Request:1;
- UCHAR Error:1;
- UCHAR Secure:1;
- UCHAR KeyMic:1;
-#else
UCHAR KeyMic:1;
UCHAR Secure:1;
UCHAR Error:1;
@@ -174,7 +163,6 @@ typedef struct PACKED _KEY_INFO
UCHAR KeyIndex:2;
UCHAR Install:1;
UCHAR KeyAck:1;
-#endif
} KEY_INFO, *PKEY_INFO;
// EAPOL Key descriptor format
@@ -204,17 +192,10 @@ typedef struct PACKED _EAPOL_PACKET
//802.11i D10 page 83
typedef struct PACKED _GTK_ENCAP
{
-#ifndef RT_BIG_ENDIAN
UCHAR Kid:2;
UCHAR tx:1;
UCHAR rsv:5;
UCHAR rsv1;
-#else
- UCHAR rsv:5;
- UCHAR tx:1;
- UCHAR Kid:2;
- UCHAR rsv1;
-#endif
UCHAR GTK[TKIP_GTK_LENGTH];
} GTK_ENCAP, *PGTK_ENCAP;
@@ -258,19 +239,11 @@ typedef struct PACKED _RSNIE_AUTH {
typedef union PACKED _RSN_CAPABILITIES {
struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Rsvd:10;
- USHORT GTKSA_R_Counter:2;
- USHORT PTKSA_R_Counter:2;
- USHORT No_Pairwise:1;
- USHORT PreAuth:1;
-#else
USHORT PreAuth:1;
USHORT No_Pairwise:1;
USHORT PTKSA_R_Counter:2;
USHORT GTKSA_R_Counter:2;
USHORT Rsvd:10;
-#endif
} field;
USHORT word;
} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
diff --git a/drivers/staging/rt2870/2870_main_dev.c b/drivers/staging/rt2870/2870_main_dev.c
index 9d59e3167fe4..dd01c64fbf61 100644
--- a/drivers/staging/rt2870/2870_main_dev.c
+++ b/drivers/staging/rt2870/2870_main_dev.c
@@ -46,17 +46,10 @@
// Otherwise post to forum in ralinktech's web site(www.ralinktech.com) and let all users help you. ***
MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>");
MODULE_DESCRIPTION("RT2870 Wireless Lan Linux Driver");
-#ifdef CONFIG_STA_SUPPORT
MODULE_LICENSE("GPL");
#ifdef MODULE_VERSION
MODULE_VERSION(STA_DRIVER_VERSION);
#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// record whether the card in the card list is used in the card file
-extern UINT8 MC_CardUsed[];
-#endif // MULTIPLE_CARD_SUPPORT //
/* Kernel thread and vars, which handles packets that are completed. Only
* packets that have a "complete" function are sent here. This way, the
@@ -77,26 +70,6 @@ MODULE_DEVICE_TABLE(usb, rtusb_usb_id);
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-
-/**************************************************************************/
-/**************************************************************************/
-//tested for kernel 2.4 series
-/**************************************************************************/
-/**************************************************************************/
-static void *rtusb_probe(struct usb_device *dev, UINT interface,
- const struct usb_device_id *id_table);
-static void rtusb_disconnect(struct usb_device *dev, void *ptr);
-
-struct usb_driver rtusb_driver = {
- name:"rt2870",
- probe:rtusb_probe,
- disconnect:rtusb_disconnect,
- id_table:rtusb_usb_id,
- };
-
-#else
-
#ifdef CONFIG_PM
static int rt2870_suspend(struct usb_interface *intf, pm_message_t state);
static int rt2870_resume(struct usb_interface *intf);
@@ -112,9 +85,6 @@ static int rtusb_probe (struct usb_interface *intf,
static void rtusb_disconnect(struct usb_interface *intf);
struct usb_driver rtusb_driver = {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
- .owner = THIS_MODULE,
-#endif
.name="rt2870",
.probe=rtusb_probe,
.disconnect=rtusb_disconnect,
@@ -176,7 +146,6 @@ static int rt2870_resume(
return 0;
}
#endif // CONFIG_PM //
-#endif // LINUX_VERSION_CODE //
// Init driver module
@@ -265,7 +234,12 @@ INT MlmeThread(
*/
DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
+#ifndef RT30xx
pObj->MLMEThr_task = NULL;
+#endif
+#ifdef RT30xx
+ pObj->MLMEThr_pid = NULL;
+#endif
complete_and_exit (&pAd->mlmeComplete, 0);
return 0;
@@ -373,7 +347,12 @@ INT RTUSBCmdThread(
*/
DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n"));
+#ifndef RT30xx
pObj->RTUSBCmdThr_task = NULL;
+#endif
+#ifdef RT30xx
+ pObj->RTUSBCmdThr_pid = NULL;
+#endif
complete_and_exit (&pAd->CmdQComplete, 0);
return 0;
@@ -467,8 +446,12 @@ INT TimerQThread(
*/
DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
+#ifndef RT30xx
pObj->TimerQThr_task = NULL;
-
+#endif
+#ifdef RT30xx
+ pObj->TimerQThr_pid = NULL;
+#endif
complete_and_exit(&pAd->TimerQComplete, 0);
return 0;
@@ -636,6 +619,7 @@ VOID RT2870_WatchDog(IN RTMP_ADAPTER *pAd)
RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
}
+//PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
idx = 0;
if ((MACValue & 0xff00) !=0 )
{
@@ -649,7 +633,6 @@ VOID RT2870_WatchDog(IN RTMP_ADAPTER *pAd)
RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
}
-
if (pAd->watchDogRxOverFlowCnt >= 2)
{
DBGPRINT(RT_DEBUG_TRACE, ("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n"));
@@ -740,7 +723,6 @@ VOID RT2870_WatchDog(IN RTMP_ADAPTER *pAd)
}
}
-#ifdef DOT11_N_SUPPORT
// For Sigma debug, dump the ba_reordering sequence.
if((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0))
{
@@ -768,7 +750,6 @@ VOID RT2870_WatchDog(IN RTMP_ADAPTER *pAd)
NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
}
}
-#endif // DOT11_N_SUPPORT //
}
/*
@@ -795,19 +776,7 @@ static void _rtusb_disconnect(struct usb_device *dev, PRTMP_ADAPTER pAd)
dev->bus->bus_name, dev->devpath));
if (!pAd)
{
-#ifdef MULTIPLE_CARD_SUPPORT
- if ((pAd->MC_RowID >= 0) && (pAd->MC_RowID <= MAX_NUM_OF_MULTIPLE_CARD))
- MC_CardUsed[pAd->MC_RowID] = 0; // not clear MAC address
-#endif // MULTIPLE_CARD_SUPPORT //
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- while(MOD_IN_USE > 0)
- {
- MOD_DEC_USE_COUNT;
- }
-#else
usb_put_dev(dev);
-#endif // LINUX_VERSION_CODE //
printk("rtusb_disconnect: pAd == NULL!\n");
return;
@@ -829,31 +798,17 @@ static void _rtusb_disconnect(struct usb_device *dev, PRTMP_ADAPTER pAd)
unregister_netdev (pAd->net_dev);
}
udelay(1);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
-#else
flush_scheduled_work();
-#endif // LINUX_VERSION_CODE //
udelay(1);
// free net_device memory
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- kfree(net_dev);
-#else
free_netdev(net_dev);
-#endif // LINUX_VERSION_CODE //
// free adapter memory
RTMPFreeAdapter(pAd);
// release a use of the usb device structure
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- while(MOD_IN_USE > 0)
- {
- MOD_DEC_USE_COUNT;
- }
-#else
usb_put_dev(dev);
-#endif // LINUX_VERSION_CODE //
udelay(1);
DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n"));
@@ -876,22 +831,6 @@ Return Value:
Note:
========================================================================
*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
-static void *rtusb_probe(struct usb_device *dev, UINT interface,
- const struct usb_device_id *id)
-{
- PRTMP_ADAPTER pAd;
- rt28xx_probe((void *)dev, (void *)id, interface, &pAd);
- return (void *)pAd;
-}
-
-//Disconnect function is called within exit routine
-static void rtusb_disconnect(struct usb_device *dev, void *ptr)
-{
- _rtusb_disconnect(dev, ((PRTMP_ADAPTER)ptr));
-}
-
-#else /* kernel 2.6 series */
static int rtusb_probe (struct usb_interface *intf,
const struct usb_device_id *id)
{
@@ -911,7 +850,6 @@ static void rtusb_disconnect(struct usb_interface *intf)
_rtusb_disconnect(dev, pAd);
}
-#endif // LINUX_VERSION_CODE //
/*
@@ -944,6 +882,7 @@ VOID RT28xxThreadTerminate(
RTUSBCancelPendingIRPs(pAd);
// Terminate Threads
+#ifndef RT30xx
BUG_ON(pObj->TimerQThr_task == NULL);
CHECK_PID_LEGALITY(task_pid(pObj->TimerQThr_task))
{
@@ -985,7 +924,72 @@ VOID RT28xxThreadTerminate(
kthread_stop(pObj->RTUSBCmdThr_task);
pObj->RTUSBCmdThr_task = NULL;
}
+#endif
+#ifdef RT30xx
+ if (pObj->MLMEThr_pid)
+ {
+ printk("Terminate the MLMEThr_pid=%d!\n", pid_nr(pObj->MLMEThr_pid));
+ mb();
+ pAd->mlme_kill = 1;
+ //RT28XX_MLME_HANDLER(pAd);
+ mb();
+ ret = kill_pid(pObj->MLMEThr_pid, SIGTERM, 1);
+ if (ret)
+ {
+ printk (KERN_WARNING "%s: unable to Mlme thread, pid=%d, ret=%d!\n",
+ pAd->net_dev->name, pid_nr(pObj->MLMEThr_pid), ret);
+ }
+ else
+ {
+ //wait_for_completion (&pAd->notify);
+ wait_for_completion (&pAd->mlmeComplete);
+ pObj->MLMEThr_pid = NULL;
+ }
+ }
+ if (pObj->RTUSBCmdThr_pid >= 0)
+ {
+ printk("Terminate the RTUSBCmdThr_pid=%d!\n", pid_nr(pObj->RTUSBCmdThr_pid));
+ mb();
+ NdisAcquireSpinLock(&pAd->CmdQLock);
+ pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
+ NdisReleaseSpinLock(&pAd->CmdQLock);
+ mb();
+ //RTUSBCMDUp(pAd);
+ ret = kill_pid(pObj->RTUSBCmdThr_pid, SIGTERM, 1);
+ if (ret)
+ {
+ printk(KERN_WARNING "%s: unable to RTUSBCmd thread, pid=%d, ret=%d!\n",
+ pAd->net_dev->name, pid_nr(pObj->RTUSBCmdThr_pid), ret);
+ }
+ else
+ {
+ //wait_for_completion (&pAd->notify);
+ wait_for_completion (&pAd->CmdQComplete);
+ pObj->RTUSBCmdThr_pid = NULL;
+ }
+ }
+ if (pObj->TimerQThr_pid >= 0)
+ {
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+ printk("Terminate the TimerQThr_pid=%d!\n", pid_nr(pObj->TimerQThr_pid));
+ mb();
+ pAd->TimerFunc_kill = 1;
+ mb();
+ ret = kill_pid(pObj->TimerQThr_pid, SIGTERM, 1);
+ if (ret)
+ {
+ printk(KERN_WARNING "%s: unable to stop TimerQThread, pid=%d, ret=%d!\n",
+ pAd->net_dev->name, pid_nr(pObj->TimerQThr_pid), ret);
+ }
+ else
+ {
+ printk("wait_for_completion TimerQThr\n");
+ wait_for_completion(&pAd->TimerQComplete);
+ pObj->TimerQThr_pid = NULL;
+ }
+ }
+#endif
// Kill tasklets
pAd->mlme_kill = 0;
@@ -1030,12 +1034,8 @@ Note:
BOOLEAN RT28XXChipsetCheck(
IN void *_dev_p)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
-#else
struct usb_interface *intf = (struct usb_interface *)_dev_p;
struct usb_device *dev_p = interface_to_usbdev(intf);
-#endif // LINUX_VERSION_CODE //
UINT32 i;
@@ -1044,7 +1044,12 @@ BOOLEAN RT28XXChipsetCheck(
if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor &&
dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct)
{
+#ifndef RT30xx
printk(KERN_DEBUG "rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
+#endif
+#ifdef RT30xx
+ printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
+#endif
dev_p->descriptor.idVendor, dev_p->descriptor.idProduct);
break;
}
@@ -1082,19 +1087,11 @@ BOOLEAN RT28XXNetDevInit(
IN struct net_device *net_dev,
IN RTMP_ADAPTER *pAd)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
-#else
struct usb_interface *intf = (struct usb_interface *)_dev_p;
struct usb_device *dev_p = interface_to_usbdev(intf);
-#endif // LINUX_VERSION_CODE //
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- pAd->config = dev_p->config;
-#else
pAd->config = &dev_p->config->desc;
-#endif // LINUX_VERSION_CODE //
return TRUE;
}
@@ -1115,70 +1112,6 @@ Return Value:
Note:
========================================================================
*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-BOOLEAN RT28XXProbePostConfig(
- IN void *_dev_p,
- IN RTMP_ADAPTER *pAd,
- IN INT32 interface)
-{
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
- struct usb_interface *intf;
- struct usb_interface_descriptor *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
- ULONG BulkOutIdx;
- UINT32 i;
-
-
- /* get the active interface descriptor */
- intf = &dev_p->actconfig->interface[interface];
- iface_desc = &intf->altsetting[0];
-
- /* get # of enpoints */
- pAd->NumberOfPipes = iface_desc->bNumEndpoints;
- DBGPRINT(RT_DEBUG_TRACE, ("NumEndpoints=%d\n", iface_desc->bNumEndpoints));
-
- /* Configure Pipes */
- endpoint = &iface_desc->endpoint[0];
- BulkOutIdx = 0;
-
- for(i=0; i<pAd->NumberOfPipes; i++)
- {
- if ((endpoint[i].bmAttributes == USB_ENDPOINT_XFER_BULK) &&
- ((endpoint[i].bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN))
- {
- pAd->BulkInEpAddr = endpoint[i].bEndpointAddress;
- pAd->BulkInMaxPacketSize = endpoint[i].wMaxPacketSize;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("BULK IN MaximumPacketSize = %d\n", pAd->BulkInMaxPacketSize));
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("EP address = 0x%2x \n", endpoint[i].bEndpointAddress));
- }
- else if ((endpoint[i].bmAttributes == USB_ENDPOINT_XFER_BULK) &&
- ((endpoint[i].bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT))
- {
- // There are 6 bulk out EP. EP6 highest priority.
- // EP1-4 is EDCA. EP5 is HCCA.
- pAd->BulkOutEpAddr[BulkOutIdx++] = endpoint[i].bEndpointAddress;
- pAd->BulkOutMaxPacketSize = endpoint[i].wMaxPacketSize;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("BULK OUT MaximumPacketSize = %d\n", pAd->BulkOutMaxPacketSize));
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("EP address = 0x%2x \n", endpoint[i].bEndpointAddress));
- }
- }
-
- if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0]))
- {
- printk("Could not find both bulk-in and bulk-out endpoints\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-#else
BOOLEAN RT28XXProbePostConfig(
IN void *_dev_p,
IN RTMP_ADAPTER *pAd,
@@ -1241,7 +1174,6 @@ BOOLEAN RT28XXProbePostConfig(
return TRUE;
}
-#endif // LINUX_VERSION_CODE //
/*
@@ -1380,9 +1312,7 @@ VOID RT28xx_UpdateBeaconToAsic(
else
{
ptr = (PUCHAR)&pAd->BeaconTxWI;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(ptr, TYPE_TXWI);
-#endif
+
if (NdisEqualMemory(pBeaconSync->BeaconTxWI[bcn_idx], &pAd->BeaconTxWI, TXWI_SIZE) == FALSE)
{ // If BeaconTxWI changed, we need to rewrite the TxWI for the Beacon frames.
pBeaconSync->BeaconBitMap &= (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
@@ -1417,6 +1347,8 @@ VOID RT28xx_UpdateBeaconToAsic(
}
pBeaconSync->BeaconBitMap |= (1 << bcn_idx);
+
+ // For AP interface, set the DtimBitOn so that we can send Bcast/Mcast frame out after this beacon frame.
}
}
@@ -1434,13 +1366,7 @@ VOID RT2870_BssBeaconStop(
{
INT NumOfBcn;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NumOfBcn = MAX_MESH_NUM;
- }
-#endif // CONFIG_STA_SUPPORT //
+ NumOfBcn = MAX_MESH_NUM;
RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
@@ -1473,13 +1399,7 @@ VOID RT2870_BssBeaconStart(
{
INT NumOfBcn;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NumOfBcn = MAX_MESH_NUM;
- }
-#endif // CONFIG_STA_SUPPORT //
+ NumOfBcn = MAX_MESH_NUM;
for(apidx=0; apidx<NumOfBcn; apidx++)
{
diff --git a/drivers/staging/rt2870/Makefile b/drivers/staging/rt2870/Makefile
index 1a015f408e69..3c17921b74aa 100644
--- a/drivers/staging/rt2870/Makefile
+++ b/drivers/staging/rt2870/Makefile
@@ -3,11 +3,7 @@ obj-$(CONFIG_RT2870) += rt2870sta.o
# TODO: all of these should be removed
EXTRA_CFLAGS += -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
EXTRA_CFLAGS += -DRT2870
-EXTRA_CFLAGS += -DCONFIG_STA_SUPPORT
EXTRA_CFLAGS += -DDBG
-EXTRA_CFLAGS += -DDOT11_N_SUPPORT
-EXTRA_CFLAGS += -DWPA_SUPPLICANT_SUPPORT
-EXTRA_CFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT
rt2870sta-objs := \
common/md5.o \
diff --git a/drivers/staging/rt2870/aironet.h b/drivers/staging/rt2870/aironet.h
index 1e07b19b8cdc..ae6259710a4f 100644
--- a/drivers/staging/rt2870/aironet.h
+++ b/drivers/staging/rt2870/aironet.h
@@ -1,210 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- aironet.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 04-06-15 Initial
-*/
-
-#ifndef __AIRONET_H__
-#define __AIRONET_H__
-
-// Measurement Type definition
-#define MSRN_TYPE_UNUSED 0
-#define MSRN_TYPE_CHANNEL_LOAD_REQ 1
-#define MSRN_TYPE_NOISE_HIST_REQ 2
-#define MSRN_TYPE_BEACON_REQ 3
-#define MSRN_TYPE_FRAME_REQ 4
-
-// Scan Mode in Beacon Request
-#define MSRN_SCAN_MODE_PASSIVE 0
-#define MSRN_SCAN_MODE_ACTIVE 1
-#define MSRN_SCAN_MODE_BEACON_TABLE 2
-
-// PHY type definition for Aironet beacon report, CCX 2 table 36-9
-#define PHY_FH 1
-#define PHY_DSS 2
-#define PHY_UNUSED 3
-#define PHY_OFDM 4
-#define PHY_HR_DSS 5
-#define PHY_ERP 6
-
-// RPI table in dBm
-#define RPI_0 0 // Power <= -87
-#define RPI_1 1 // -87 < Power <= -82
-#define RPI_2 2 // -82 < Power <= -77
-#define RPI_3 3 // -77 < Power <= -72
-#define RPI_4 4 // -72 < Power <= -67
-#define RPI_5 5 // -67 < Power <= -62
-#define RPI_6 6 // -62 < Power <= -57
-#define RPI_7 7 // -57 < Power
-
-// Cisco Aironet IAPP definetions
-#define AIRONET_IAPP_TYPE 0x32
-#define AIRONET_IAPP_SUBTYPE_REQUEST 0x01
-#define AIRONET_IAPP_SUBTYPE_REPORT 0x81
-
-// Measurement Request detail format
-typedef struct _MEASUREMENT_REQUEST {
- UCHAR Channel;
- UCHAR ScanMode; // Use only in beacon request, other requests did not use this field
- USHORT Duration;
-} MEASUREMENT_REQUEST, *PMEASUREMENT_REQUEST;
-
-// Beacon Measurement Report
-// All these field might change to UCHAR, because we didn't do anything to these report.
-// We copy all these beacons and report to CCX 2 AP.
-typedef struct _BEACON_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR PhyType; // Definiation is listed above table 36-9
- UCHAR RxPower;
- UCHAR BSSID[6];
- UCHAR ParentTSF[4];
- UCHAR TargetTSF[8];
- USHORT BeaconInterval;
- USHORT CapabilityInfo;
-} BEACON_REPORT, *PBEACON_REPORT;
-
-// Frame Measurement Report (Optional)
-typedef struct _FRAME_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR TA;
- UCHAR BSSID[6];
- UCHAR RSSI;
- UCHAR Count;
-} FRAME_REPORT, *PFRAME_REPORT;
-
-#pragma pack(1)
-// Channel Load Report
-typedef struct _CHANNEL_LOAD_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR CCABusy;
-} CHANNEL_LOAD_REPORT, *PCHANNEL_LOAD_REPORT;
-#pragma pack()
-
-// Nosie Histogram Report
-typedef struct _NOISE_HIST_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR Density[8];
-} NOISE_HIST_REPORT, *PNOISE_HIST_REPORT;
-
-// Radio Management Capability element
-typedef struct _RADIO_MANAGEMENT_CAPABILITY {
- UCHAR Eid; // TODO: Why the Eid is 1 byte, not normal 2 bytes???
- UCHAR Length;
- UCHAR AironetOui[3]; // AIronet OUI (00 40 96)
- UCHAR Type; // Type / Version
- USHORT Status; // swap16 required
-} RADIO_MANAGEMENT_CAPABILITY, *PRADIO_MANAGEMENT_CAPABILITY;
-
-// Measurement Mode Bit definition
-typedef struct _MEASUREMENT_MODE {
- UCHAR Rsvd:4;
- UCHAR Report:1;
- UCHAR NotUsed:1;
- UCHAR Enable:1;
- UCHAR Parallel:1;
-} MEASUREMENT_MODE, *PMEASUREMENT_MODE;
-
-// Measurement Request element, This is little endian mode
-typedef struct _MEASUREMENT_REQUEST_ELEMENT {
- USHORT Eid;
- USHORT Length; // swap16 required
- USHORT Token; // non-zero unique token
- UCHAR Mode; // Measurement Mode
- UCHAR Type; // Measurement type
-} MEASUREMENT_REQUEST_ELEMENT, *PMEASUREMENT_REQUEST_ELEMENT;
-
-// Measurement Report element, This is little endian mode
-typedef struct _MEASUREMENT_REPORT_ELEMENT {
- USHORT Eid;
- USHORT Length; // swap16 required
- USHORT Token; // non-zero unique token
- UCHAR Mode; // Measurement Mode
- UCHAR Type; // Measurement type
-} MEASUREMENT_REPORT_ELEMENT, *PMEASUREMENT_REPORT_ELEMENT;
-
-// Cisco Aironet IAPP Frame Header, Network byte order used
-typedef struct _AIRONET_IAPP_HEADER {
- UCHAR CiscoSnapHeader[8]; // 8 bytes Cisco snap header
- USHORT Length; // IAPP ID & length, remember to swap16 in LE system
- UCHAR Type; // IAPP type
- UCHAR SubType; // IAPP subtype
- UCHAR DA[6]; // Destination MAC address
- UCHAR SA[6]; // Source MAC address
- USHORT Token; // Dialog token, no need to swap16 since it is for yoken usage only
-} AIRONET_IAPP_HEADER, *PAIRONET_IAPP_HEADER;
-
-// Radio Measurement Request frame
-typedef struct _AIRONET_RM_REQUEST_FRAME {
- AIRONET_IAPP_HEADER IAPP; // Common header
- UCHAR Delay; // Activation Delay
- UCHAR Offset; // Measurement offset
-} AIRONET_RM_REQUEST_FRAME, *PAIRONET_RM_REQUEST_FRAME;
-
-// Radio Measurement Report frame
-typedef struct _AIRONET_RM_REPORT_FRAME {
- AIRONET_IAPP_HEADER IAPP; // Common header
-} AIRONET_RM_REPORT_FRAME, *PAIRONET_RM_REPORT_FRAME;
-
-// Saved element request actions which will saved in StaCfg.
-typedef struct _RM_REQUEST_ACTION {
- MEASUREMENT_REQUEST_ELEMENT ReqElem; // Saved request element
- MEASUREMENT_REQUEST Measurement; // Saved measurement within the request element
-} RM_REQUEST_ACTION, *PRM_REQUEST_ACTION;
-
-// CCX administration control
-typedef union _CCX_CONTROL {
- struct {
- UINT32 Enable:1; // Enable CCX2
- UINT32 LeapEnable:1; // Enable LEAP at CCX2
- UINT32 RMEnable:1; // Radio Measurement Enable
- UINT32 DCRMEnable:1; // Non serving channel Radio Measurement enable
- UINT32 QOSEnable:1; // Enable QOS for CCX 2.0 support
- UINT32 FastRoamEnable:1; // Enable fast roaming
- UINT32 Rsvd:2; // Not used
- UINT32 dBmToRoam:8; // the condition to roam when receiving Rssi less than this value. It's negative value.
- UINT32 TuLimit:16; // Limit for different channel scan
- } field;
- UINT32 word;
-} CCX_CONTROL, *PCCX_CONTROL;
-
-#endif // __AIRONET_H__
+#include "../rt2860/aironet.h"
diff --git a/drivers/staging/rt2870/ap.h b/drivers/staging/rt2870/ap.h
index 0dc557516790..fe04b5f45f20 100644
--- a/drivers/staging/rt2870/ap.h
+++ b/drivers/staging/rt2870/ap.h
@@ -1,562 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- ap.h
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
- James Tan 09-06-2002 modified (Revise NTCRegTable)
- John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
-*/
-#ifndef __AP_H__
-#define __AP_H__
-
-
-
-// ========================= AP RTMP.h ================================
-
-
-
-// =============================================================
-// Function Prototypes
-// =============================================================
-
-// ap_data.c
-
-BOOLEAN APBridgeToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN ULONG fromwdsidx);
-
-BOOLEAN APHandleRxDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID APSendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets);
-
-NDIS_STATUS APSendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-NDIS_STATUS APHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx);
-
-VOID APRxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-NDIS_STATUS APCheckRxError(
- IN PRTMP_ADAPTER pAd,
- IN PRT28XX_RXD_STRUC pRxD,
- IN UCHAR Wcid);
-
-BOOLEAN APCheckClass2Class3Error(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN PHEADER_802_11 pHeader);
-
-VOID APHandleRxPsPoll(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN USHORT Aid,
- IN BOOLEAN isActive);
-
-VOID RTMPDescriptorEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType);
-
-VOID RTMPFrameEndianChange(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG Dir,
- IN BOOLEAN FromRxDoneInt);
-
-// ap_assoc.c
-
-VOID APAssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APPeerAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MbssKickOutStas(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN USHORT Reason);
-
-VOID APMlmeKickOutSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pStaAddr,
- IN UCHAR Wcid,
- IN USHORT Reason);
-
-VOID APMlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APCls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN PHEADER_802_11 pHeader);
-
-
-USHORT APBuildAssociation(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN USHORT CapabilityInfo,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN UCHAR *RSN,
- IN UCHAR *pRSNLen,
- IN BOOLEAN bWmmCapable,
- IN ULONG RalinkIe,
-#ifdef DOT11N_DRAFT3
- IN EXT_CAP_INFO_ELEMENT ExtCapInfo,
-#endif // DOT11N_DRAFT3 //
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- OUT USHORT *pAid);
-
-/*
-VOID RTMPAddClientSec(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN PUCHAR pKey,
- IN PUCHAR pTxMic,
- IN PUCHAR pRxMic,
- IN MAC_TABLE_ENTRY *pEntry);
-*/
-
-// ap_auth.c
-
-void APAuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APMlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APCls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN PHEADER_802_11 pHeader);
-
-// ap_authrsp.c
-
-VOID APAuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[]);
-
-VOID APPeerAuthAtAuthRspIdleAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT StatusCode);
-
-// ap_connect.c
-
-BOOLEAN BeaconTransmitRequired(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx);
-
-VOID APMakeBssBeacon(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx);
-
-VOID APUpdateBeaconFrame(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx);
-
-VOID APMakeAllBssBeacon(
- IN PRTMP_ADAPTER pAd);
-
-VOID APUpdateAllBeaconFrame(
- IN PRTMP_ADAPTER pAd);
-
-
-// ap_sync.c
-
-VOID APSyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID APInvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerBeaconAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APMlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APScanCnclAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ApSiteSurvey(
- IN PRTMP_ADAPTER pAd);
-
-VOID SupportRate(
- IN PUCHAR SupRate,
- IN UCHAR SupRateLen,
- IN PUCHAR ExtRate,
- IN UCHAR ExtRateLen,
- OUT PUCHAR *Rates,
- OUT PUCHAR RatesLen,
- OUT PUCHAR pMaxSupportRate);
-
-
-BOOLEAN ApScanRunning(
- IN PRTMP_ADAPTER pAd);
-
-#ifdef DOT11N_DRAFT3
-VOID APOverlappingBSSScan(
- IN RTMP_ADAPTER *pAd);
-#endif // DOT11N_DRAFT3 //
-
-// ap_wpa.c
-
-VOID APWpaStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-// ap_mlme.c
-
-VOID APMlmePeriodicExec(
- IN PRTMP_ADAPTER pAd);
-
-VOID APMlmeSelectTxRateTable(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR *ppTable,
- IN PUCHAR pTableSize,
- IN PUCHAR pInitTxRateIdx);
-
-VOID APMlmeSetTxRate(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PRTMP_TX_RATE_SWITCH pTxRate);
-
-VOID APMlmeDynamicTxRateSwitching(
- IN PRTMP_ADAPTER pAd);
-
-VOID APQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN APMsgTypeSubst(
- IN PRTMP_ADAPTER pAd,
- IN PFRAME_802_11 pFrame,
- OUT INT *Machine,
- OUT INT *MsgType);
-
-VOID APQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-#ifdef RT2870
-VOID BeaconUpdateExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-#endif // RT2870 //
-
-VOID RTMPSetPiggyBack(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bPiggyBack);
-
-VOID APAsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd);
-
-VOID APAsicRxAntEvalTimeout(
- IN PRTMP_ADAPTER pAd);
-
-// ap.c
-
-VOID APSwitchChannel(
- IN PRTMP_ADAPTER pAd,
- IN INT Channel);
-
-NDIS_STATUS APInitialize(
- IN PRTMP_ADAPTER pAd);
-
-VOID APShutdown(
- IN PRTMP_ADAPTER pAd);
-
-VOID APStartUp(
- IN PRTMP_ADAPTER pAd);
-
-VOID APStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID APCleanupPsQueue(
- IN PRTMP_ADAPTER pAd,
- IN PQUEUE_HEADER pQueue);
-
-VOID MacTableReset(
- IN PRTMP_ADAPTER pAd);
-
-MAC_TABLE_ENTRY *MacTableInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR apidx,
- IN BOOLEAN CleanAll);
-
-BOOLEAN MacTableDeleteEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr);
-
-MAC_TABLE_ENTRY *MacTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr);
-
-VOID MacTableMaintenance(
- IN PRTMP_ADAPTER pAd);
-
-UINT32 MacTableAssocStaNumGet(
- IN PRTMP_ADAPTER pAd);
-
-MAC_TABLE_ENTRY *APSsPsInquiry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- OUT SST *Sst,
- OUT USHORT *Aid,
- OUT UCHAR *PsMode,
- OUT UCHAR *Rate);
-
-BOOLEAN APPsIndicate(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN ULONG Wcid,
- IN UCHAR Psm);
-
-VOID ApLogEvent(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN USHORT Event);
-
-#ifdef DOT11_N_SUPPORT
-VOID APUpdateOperationMode(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
-
-VOID APUpdateCapabilityAndErpIe(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN ApCheckAccessControlList(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR Apidx);
-
-VOID ApUpdateAccessControlList(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Apidx);
-
-VOID ApEnqueueNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR TxRate,
- IN UCHAR PID,
- IN UCHAR apidx,
- IN BOOLEAN bQosNull,
- IN BOOLEAN bEOSP,
- IN UCHAR OldUP);
-
-VOID ApSendFrame(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuffer,
- IN ULONG Length,
- IN UCHAR TxRate,
- IN UCHAR PID);
-
-VOID ApEnqueueAckFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR TxRate,
- IN UCHAR apidx);
-
-UCHAR APAutoSelectChannel(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN Optimal);
-
-// ap_sanity.c
-
-
-BOOLEAN PeerAssocReqCmmSanity(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN isRessoc,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pListenInterval,
- OUT PUCHAR pApAddr,
- OUT UCHAR *pSsidLen,
- OUT char *Ssid,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *RSN,
- OUT UCHAR *pRSNLen,
- OUT BOOLEAN *pbWmmCapable,
-#ifdef WSC_AP_SUPPORT
- OUT BOOLEAN *pWscCapable,
-#endif // WSC_AP_SUPPORT //
- OUT ULONG *pRalinkIe,
-#ifdef DOT11N_DRAFT3
- OUT EXT_CAP_INFO_ELEMENT *pExtCapInfo,
-#endif // DOT11N_DRAFT3 //
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDisassocReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN PeerDeauthReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN APPeerAuthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr1,
- OUT PUCHAR pAddr2,
- OUT USHORT *Alg,
- OUT USHORT *Seq,
- OUT USHORT *Status,
- CHAR *ChlgText);
-
-BOOLEAN APPeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *SsidLen);
-
-BOOLEAN APPeerBeaconAndProbeRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT PUCHAR pBssid,
- OUT CHAR Ssid[],
- OUT UCHAR *SsidLen,
- OUT UCHAR *BssType,
- OUT USHORT *BeaconPeriod,
- OUT UCHAR *Channel,
- OUT LARGE_INTEGER *Timestamp,
- OUT USHORT *CapabilityInfo,
- OUT UCHAR Rate[],
- OUT UCHAR *RateLen,
- OUT BOOLEAN *ExtendedRateIeExist,
- OUT UCHAR *Erp);
-
-// ap_info.c
-
-
-
-// ================== end of AP RTMP.h ========================
-
-
-#endif // __AP_H__
-
+#include "../rt2860/ap.h"
diff --git a/drivers/staging/rt2870/chlist.h b/drivers/staging/rt2870/chlist.h
index 9e15b9daeb80..31999583b379 100644
--- a/drivers/staging/rt2870/chlist.h
+++ b/drivers/staging/rt2870/chlist.h
@@ -1,1296 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- chlist.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Fonchi Wu 2007-12-19 created
-*/
-
-#ifndef __CHLIST_H__
-#define __CHLIST_H__
-
-#include "rtmp_type.h"
-#include "rtmp_def.h"
-
-
-#define ODOR 0
-#define IDOR 1
-#define BOTH 2
-
-#define BAND_5G 0
-#define BAND_24G 1
-#define BAND_BOTH 2
-
-typedef struct _CH_DESP {
- UCHAR FirstChannel;
- UCHAR NumOfCh;
- CHAR MaxTxPwr; // dBm
- UCHAR Geography; // 0:out door, 1:in door, 2:both
- BOOLEAN DfsReq; // Dfs require, 0: No, 1: yes.
-} CH_DESP, *PCH_DESP;
-
-typedef struct _CH_REGION {
- UCHAR CountReg[3];
- UCHAR DfsType; // 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56
- CH_DESP ChDesp[10];
-} CH_REGION, *PCH_REGION;
-
-static CH_REGION ChRegion[] =
-{
- { // Antigua and Berbuda
- "AG",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Argentina
- "AR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Aruba
- "AW",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Australia
- "AU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Austria
- "AT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Bahamas
- "BS",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Barbados
- "BB",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Bermuda
- "BM",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Brazil
- "BR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 24, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Belgium
- "BE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 18, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 18, IDOR, FALSE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Bulgaria
- "BG",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Canada
- "CA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Cayman IsLands
- "KY",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Chile
- "CL",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // China
- "CN",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Colombia
- "CO",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Costa Rica
- "CR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Cyprus
- "CY",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Czech_Republic
- "CZ",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Denmark
- "DK",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Dominican Republic
- "DO",
- CE,
- {
- { 1, 0, 20, BOTH, FALSE}, // 2.4 G, ch 0
- { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Equador
- "EC",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 100, 11, 27, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // El Salvador
- "SV",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 30, BOTH, TRUE}, // 5G, ch 52~64
- { 149, 4, 36, BOTH, TRUE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Finland
- "FI",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // France
- "FR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Germany
- "DE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Greece
- "GR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Guam
- "GU",
- CE,
- {
- { 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Guatemala
- "GT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Haiti
- "HT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Honduras
- "HN",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Hong Kong
- "HK",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Hungary
- "HU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Iceland
- "IS",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // India
- "IN",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 24, IDOR, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Indonesia
- "ID",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Ireland
- "IE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Israel
- "IL",
- CE,
- {
- { 1, 3, 20, IDOR, FALSE}, // 2.4 G, ch 1~3
- { 4, 6, 20, BOTH, FALSE}, // 2.4 G, ch 4~9
- { 10, 4, 20, IDOR, FALSE}, // 2.4 G, ch 10~13
- { 0}, // end
- }
- },
-
- { // Italy
- "IT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Japan
- "JP",
- JAP,
- {
- { 1, 14, 20, BOTH, FALSE}, // 2.4 G, ch 1~14
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 0}, // end
- }
- },
-
- { // Jordan
- "JO",
- CE,
- {
- { 1, 13, 20, IDOR, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 149, 4, 23, IDOR, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Latvia
- "LV",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Liechtenstein
- "LI",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Lithuania
- "LT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Luxemburg
- "LU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Malaysia
- "MY",
- CE,
- {
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Malta
- "MT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Marocco
- "MA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
- { 0}, // end
- }
- },
-
- { // Mexico
- "MX",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, IDOR, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Netherlands
- "NL",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // New Zealand
- "NZ",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 24, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Norway
- "NO",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Peru
- "PE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Portugal
- "PT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Poland
- "PL",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Romania
- "RO",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Russia
- "RU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 20, IDOR, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Saudi Arabia
- "SA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 23, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Serbia_and_Montenegro
- "CS",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 0}, // end
- }
- },
-
- { // Singapore
- "SG",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Slovakia
- "SK",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Slovenia
- "SI",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // South Africa
- "ZA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // South Korea
- "KR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 8, 20, BOTH, FALSE}, // 5G, ch 100~128
- { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Spain
- "ES",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Sweden
- "SE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Switzerland
- "CH",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Taiwan
- "TW",
- CE,
- {
- { 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Turkey
- "TR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // UK
- "GB",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Ukraine
- "UA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 0}, // end
- }
- },
-
- { // United_Arab_Emirates
- "AE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 0}, // end
- }
- },
-
- { // United_States
- "US",
- CE,
- {
- { 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 17, IDOR, FALSE}, // 5G, ch 52~64
- { 52, 4, 24, BOTH, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Venezuela
- "VE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Default
- "",
- CE,
- {
- { 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 20, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-};
-
-static inline PCH_REGION GetChRegion(
- IN PUCHAR CntryCode)
-{
- INT loop = 0;
- PCH_REGION pChRegion = NULL;
-
- while (strcmp(ChRegion[loop].CountReg, "") != 0)
- {
- if (strncmp(ChRegion[loop].CountReg, CntryCode, 2) == 0)
- {
- pChRegion = &ChRegion[loop];
- break;
- }
- loop++;
- }
-
- if (pChRegion == NULL)
- pChRegion = &ChRegion[loop];
- return pChRegion;
-}
-
-static inline VOID ChBandCheck(
- IN UCHAR PhyMode,
- OUT PUCHAR pChType)
-{
- switch(PhyMode)
- {
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AN_MIXED:
-#endif // DOT11_N_SUPPORT //
- *pChType = BAND_5G;
- break;
- case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AGN_MIXED:
- case PHY_11ABGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- *pChType = BAND_BOTH;
- break;
-
- default:
- *pChType = BAND_24G;
- break;
- }
-}
-
-static inline UCHAR FillChList(
- IN PRTMP_ADAPTER pAd,
- IN PCH_DESP pChDesp,
- IN UCHAR Offset,
- IN UCHAR increment)
-{
- INT i, j, l;
- UCHAR channel;
-
- j = Offset;
- for (i = 0; i < pChDesp->NumOfCh; i++)
- {
- channel = pChDesp->FirstChannel + i * increment;
- for (l=0; l<MAX_NUM_OF_CHANNELS; l++)
- {
- if (channel == pAd->TxPower[l].Channel)
- {
- pAd->ChannelList[j].Power = pAd->TxPower[l].Power;
- pAd->ChannelList[j].Power2 = pAd->TxPower[l].Power2;
- break;
- }
- }
- if (l == MAX_NUM_OF_CHANNELS)
- continue;
-
- pAd->ChannelList[j].Channel = pChDesp->FirstChannel + i * increment;
- pAd->ChannelList[j].MaxTxPwr = pChDesp->MaxTxPwr;
- pAd->ChannelList[j].DfsReq = pChDesp->DfsReq;
- j++;
- }
- pAd->ChannelListNum = j;
-
- return j;
-}
-
-static inline VOID CreateChList(
- IN PRTMP_ADAPTER pAd,
- IN PCH_REGION pChRegion,
- IN UCHAR Geography)
-{
- INT i;
- UCHAR offset = 0;
- PCH_DESP pChDesp;
- UCHAR ChType;
- UCHAR increment;
-
- if (pChRegion == NULL)
- return;
-
- ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
-
- for (i=0; i<10; i++)
- {
- pChDesp = &pChRegion->ChDesp[i];
- if (pChDesp->FirstChannel == 0)
- break;
-
- if (ChType == BAND_5G)
- {
- if (pChDesp->FirstChannel <= 14)
- continue;
- }
- else if (ChType == BAND_24G)
- {
- if (pChDesp->FirstChannel > 14)
- continue;
- }
-
- if ((pChDesp->Geography == BOTH)
- || (pChDesp->Geography == Geography))
- {
- if (pChDesp->FirstChannel > 14)
- increment = 4;
- else
- increment = 1;
- offset = FillChList(pAd, pChDesp, offset, increment);
- }
- }
-}
-
-static inline VOID BuildChannelListEx(
- IN PRTMP_ADAPTER pAd)
-{
- PCH_REGION pChReg;
-
- pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
- CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
-}
-
-static inline VOID BuildBeaconChList(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf,
- OUT PULONG pBufLen)
-{
- INT i;
- ULONG TmpLen;
- PCH_REGION pChRegion;
- PCH_DESP pChDesp;
- UCHAR ChType;
-
- pChRegion = GetChRegion(pAd->CommonCfg.CountryCode);
-
- if (pChRegion == NULL)
- return;
-
- ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
- *pBufLen = 0;
-
- for (i=0; i<10; i++)
- {
- pChDesp = &pChRegion->ChDesp[i];
- if (pChDesp->FirstChannel == 0)
- break;
-
- if (ChType == BAND_5G)
- {
- if (pChDesp->FirstChannel <= 14)
- continue;
- }
- else if (ChType == BAND_24G)
- {
- if (pChDesp->FirstChannel > 14)
- continue;
- }
-
- if ((pChDesp->Geography == BOTH)
- || (pChDesp->Geography == pAd->CommonCfg.Geography))
- {
- MakeOutgoingFrame(pBuf + *pBufLen, &TmpLen,
- 1, &pChDesp->FirstChannel,
- 1, &pChDesp->NumOfCh,
- 1, &pChDesp->MaxTxPwr,
- END_OF_ARGS);
- *pBufLen += TmpLen;
- }
- }
-}
-
-
-#ifdef DOT11_N_SUPPORT
-static inline BOOLEAN IsValidChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel)
-
-{
- INT i;
-
- for (i = 0; i < pAd->ChannelListNum; i++)
- {
- if (pAd->ChannelList[i].Channel == channel)
- break;
- }
-
- if (i == pAd->ChannelListNum)
- return FALSE;
- else
- return TRUE;
-}
-
-
-static inline UCHAR GetExtCh(
- IN UCHAR Channel,
- IN UCHAR Direction)
-{
- CHAR ExtCh;
-
- if (Direction == EXTCHA_ABOVE)
- ExtCh = Channel + 4;
- else
- ExtCh = (Channel - 4) > 0 ? (Channel - 4) : 0;
-
- return ExtCh;
-}
-
-
-static inline VOID N_ChannelCheck(
- IN PRTMP_ADAPTER pAd)
-{
- //UCHAR ChannelNum = pAd->ChannelListNum;
- UCHAR Channel = pAd->CommonCfg.Channel;
-
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
- {
- if (Channel > 14)
- {
- if ((Channel == 36) || (Channel == 44) || (Channel == 52) || (Channel == 60) || (Channel == 100) || (Channel == 108) ||
- (Channel == 116) || (Channel == 124) || (Channel == 132) || (Channel == 149) || (Channel == 157))
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- }
- else if ((Channel == 40) || (Channel == 48) || (Channel == 56) || (Channel == 64) || (Channel == 104) || (Channel == 112) ||
- (Channel == 120) || (Channel == 128) || (Channel == 136) || (Channel == 153) || (Channel == 161))
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- }
- }
- else
- {
- do
- {
- UCHAR ExtCh;
- UCHAR Dir = pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
- ExtCh = GetExtCh(Channel, Dir);
- if (IsValidChannel(pAd, ExtCh))
- break;
-
- Dir = (Dir == EXTCHA_ABOVE) ? EXTCHA_BELOW : EXTCHA_ABOVE;
- ExtCh = GetExtCh(Channel, Dir);
- if (IsValidChannel(pAd, ExtCh))
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = Dir;
- break;
- }
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- } while(FALSE);
-
- if (Channel == 14)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- //pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT()
- }
-#if 0
- switch (pAd->CommonCfg.CountryRegion & 0x7f)
- {
- case REGION_0_BG_BAND: // 1 -11
- case REGION_1_BG_BAND: // 1 - 13
- case REGION_5_BG_BAND: // 1 - 14
- if (Channel <= 4)
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- }
- else if (Channel >= 8)
- {
- if ((ChannelNum - Channel) < 4)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- }
- break;
-
- case REGION_2_BG_BAND: // 10 - 11
- case REGION_3_BG_BAND: // 10 - 13
- case REGION_4_BG_BAND: // 14
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- break;
-
- case REGION_6_BG_BAND: // 3 - 9
- if (Channel <= 5)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- else if (Channel == 6)
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- else if (Channel >= 7)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- break;
-
- case REGION_7_BG_BAND: // 5 - 13
- if (Channel <= 8)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- else if (Channel >= 10)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- break;
-
- default: // Error. should never happen
- break;
- }
-#endif
- }
- }
-
-
-}
-
-
-static inline VOID N_SetCenCh(
- IN PRTMP_ADAPTER pAd)
-{
- if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
- {
- if (pAd->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
- {
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
- }
- else
- {
- if (pAd->CommonCfg.Channel == 14)
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 1;
- else
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
- }
- }
- else
- {
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-
-static inline UINT8 GetCuntryMaxTxPwr(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 channel)
-{
- int i;
- for (i = 0; i < pAd->ChannelListNum; i++)
- {
- if (pAd->ChannelList[i].Channel == channel)
- break;
- }
-
- if (i == pAd->ChannelListNum)
- return 0xff;
- else
- return pAd->ChannelList[i].MaxTxPwr;
-}
-#endif // __CHLIST_H__
-
+#include "../rt2860/chlist.h"
diff --git a/drivers/staging/rt2870/common/2870_rtmp_init.c b/drivers/staging/rt2870/common/2870_rtmp_init.c
index cb16d2fcf60a..9ed818d442ff 100644
--- a/drivers/staging/rt2870/common/2870_rtmp_init.c
+++ b/drivers/staging/rt2870/common/2870_rtmp_init.c
@@ -266,27 +266,6 @@ NDIS_STATUS NICInitTransmit(
//
// MGMT_RING_SIZE
//
-#if 0
- for(i=0; i<MGMT_RING_SIZE; i++) // 8
- {
- PTX_CONTEXT pMLMEContext = &(pAd->MLMEContext[i]);
-
-
- NdisZeroMemory(pMLMEContext, sizeof(TX_CONTEXT));
-
- //Allocate URB
- LM_USB_ALLOC(pObj, pMLMEContext, PTX_BUFFER, sizeof(TX_BUFFER), Status,
- ("<-- ERROR in Alloc TX MLMEContext[%d] urb!! \n", i),
- out2,
- ("<-- ERROR in Alloc TX MLMEContext[%d] TX_BUFFER !! \n", i),
- out2);
-
- pMLMEContext->pAd = pAd;
- pMLMEContext->pIrp = NULL;
- pMLMEContext->InUse = FALSE;
- pMLMEContext->IRPPending = FALSE;
- }
-#else
// Allocate MGMT ring descriptor's memory
pAd->MgmtDescRing.AllocSize = MGMT_RING_SIZE * sizeof(TX_CONTEXT);
RTMPAllocateMemory(&pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocSize);
@@ -336,7 +315,6 @@ NDIS_STATUS NICInitTransmit(
pAd->MgmtRing.TxSwFreeIdx = MGMT_RING_SIZE;
pAd->MgmtRing.TxCpuIdx = 0;
pAd->MgmtRing.TxDmaIdx = 0;
-#endif
//
// BEACON_RING_SIZE
@@ -518,10 +496,6 @@ NDIS_STATUS RTMPAllocTxRxRingMemory(
NdisAllocateSpinLock(&pAd->TxContextQueueLock[num]);
}
-#ifdef RALINK_ATE
- NdisAllocateSpinLock(&pAd->GenericLock);
-#endif // RALINK_ATE //
-
// NdisAllocateSpinLock(&pAd->MemLock); // Not used in RT28XX
// NdisAllocateSpinLock(&pAd->MacTabLock); // init it in UserCfgInit()
@@ -665,7 +639,7 @@ VOID RTMPFreeTxRxRingMemory(
// Free Tx frame resource
- for (acidx = 0; acidx < 4; acidx++)
+ for(acidx=0; acidx<4; acidx++)
{
PHT_TX_CONTEXT pHTTXContext = &(pAd->TxContext[acidx]);
if (pHTTXContext)
@@ -684,9 +658,7 @@ VOID RTMPFreeTxRxRingMemory(
NdisFreeSpinLock(&pAd->MLMEBulkOutLock);
NdisFreeSpinLock(&pAd->CmdQLock);
-#ifdef RALINK_ATE
- NdisFreeSpinLock(&pAd->GenericLock);
-#endif // RALINK_ATE //
+
// Clear all pending bulk-out request flags.
RTUSB_CLEAR_BULK_FLAG(pAd, 0xffffffff);
@@ -727,9 +699,14 @@ NDIS_STATUS AdapterBlockAllocateMemory(
usb_dev = pObj->pUsb_Dev;
+#ifndef RT30xx
pObj->MLMEThr_task = NULL;
pObj->RTUSBCmdThr_task = NULL;
-
+#endif
+#ifdef RT30xx
+ pObj->MLMEThr_pid = NULL;
+ pObj->RTUSBCmdThr_pid = NULL;
+#endif
*ppAd = (PVOID)vmalloc(sizeof(RTMP_ADAPTER));
if (*ppAd)
@@ -765,7 +742,12 @@ NDIS_STATUS CreateThreads(
{
PRTMP_ADAPTER pAd = net_dev->ml_priv;
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
+#ifndef RT30xx
struct task_struct *tsk;
+#endif
+#ifdef RT30xx
+ pid_t pid_number;
+#endif
//init_MUTEX(&(pAd->usbdev_semaphore));
@@ -779,39 +761,76 @@ NDIS_STATUS CreateThreads(
init_completion (&pAd->TimerQComplete);
// Creat MLME Thread
+#ifndef RT30xx
pObj->MLMEThr_task = NULL;
tsk = kthread_run(MlmeThread, pAd, pAd->net_dev->name);
if (IS_ERR(tsk)) {
+#endif
+#ifdef RT30xx
+ pObj->MLMEThr_pid = NULL;
+ pid_number = kernel_thread(MlmeThread, pAd, CLONE_VM);
+ if (pid_number < 0)
+ {
+#endif
printk (KERN_WARNING "%s: unable to start Mlme thread\n",pAd->net_dev->name);
return NDIS_STATUS_FAILURE;
}
+#ifndef RT30xx
pObj->MLMEThr_task = tsk;
+#endif
+#ifdef RT30xx
+ pObj->MLMEThr_pid = find_get_pid(pid_number);
+#endif
// Wait for the thread to start
wait_for_completion(&(pAd->mlmeComplete));
// Creat Command Thread
+#ifndef RT30xx
pObj->RTUSBCmdThr_task = NULL;
tsk = kthread_run(RTUSBCmdThread, pAd, pAd->net_dev->name);
if (IS_ERR(tsk) < 0)
+#endif
+#ifdef RT30xx
+ pObj->RTUSBCmdThr_pid = NULL;
+ pid_number = kernel_thread(RTUSBCmdThread, pAd, CLONE_VM);
+ if (pid_number < 0)
+#endif
{
printk (KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAd->net_dev->name);
return NDIS_STATUS_FAILURE;
}
+#ifndef RT30xx
pObj->RTUSBCmdThr_task = tsk;
+#endif
+#ifdef RT30xx
+ pObj->RTUSBCmdThr_pid = find_get_pid(pid_number);
+#endif
wait_for_completion(&(pAd->CmdQComplete));
+#ifndef RT30xx
pObj->TimerQThr_task = NULL;
tsk = kthread_run(TimerQThread, pAd, pAd->net_dev->name);
if (IS_ERR(tsk) < 0)
+#endif
+#ifdef RT30xx
+ pObj->TimerQThr_pid = NULL;
+ pid_number = kernel_thread(TimerQThread, pAd, CLONE_VM);
+ if (pid_number < 0)
+#endif
{
printk (KERN_WARNING "%s: unable to start TimerQThread\n",pAd->net_dev->name);
return NDIS_STATUS_FAILURE;
}
+#ifndef RT30xx
pObj->TimerQThr_task = tsk;
+#endif
+#ifdef RT30xx
+ pObj->TimerQThr_pid = find_get_pid(pid_number);
+#endif
// Wait for the thread to start
wait_for_completion(&(pAd->TimerQComplete));
@@ -831,8 +850,6 @@ NDIS_STATUS CreateThreads(
return NDIS_STATUS_SUCCESS;
}
-
-#ifdef CONFIG_STA_SUPPORT
/*
========================================================================
Routine Description:
@@ -1013,7 +1030,6 @@ VOID RTMPAddBSSIDCipher(
DBGPRINT_RAW(RT_DEBUG_TRACE,(" %x:", pKey->KeyMaterial[i]));
DBGPRINT(RT_DEBUG_TRACE,(" \n"));
}
-#endif // CONFIG_STA_SUPPORT //
/*
========================================================================
@@ -1084,18 +1100,13 @@ PNDIS_PACKET GetPacketFromRxRing(
// skip USB frame length field
pData += RT2870_RXDMALEN_FIELD_SIZE;
pRxWI = (PRXWI_STRUC)pData;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(pData, TYPE_RXWI);
-#endif // RT_BIG_ENDIAN //
+
if (pRxWI->MPDUtotalByteCount > ThisFrameLen)
{
DBGPRINT(RT_DEBUG_ERROR, ("%s():pRxWIMPDUtotalByteCount(%d) large than RxDMALen(%ld)\n",
__func__, pRxWI->MPDUtotalByteCount, ThisFrameLen));
goto label_null;
}
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(pData, TYPE_RXWI);
-#endif // RT_BIG_ENDIAN //
// allocate a rx packet
pSkb = dev_alloc_skb(ThisFrameLen);
@@ -1112,9 +1123,6 @@ PNDIS_PACKET GetPacketFromRxRing(
// copy RxD
*pSaveRxD = *(PRXINFO_STRUC)(pData + ThisFrameLen);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pSaveRxD, TYPE_RXINFO);
-#endif // RT_BIG_ENDIAN //
// update next packet read position.
pAd->ReadPosition += (ThisFrameLen + RT2870_RXDMALEN_FIELD_SIZE + RXINFO_SIZE); // 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(RXINFO_STRUC))
@@ -1197,17 +1205,6 @@ static void rx_done_tasklet(unsigned long data)
ASSERT((pRxContext->InUse == pRxContext->IRPPending));
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- // If the driver is in ATE mode and Rx frame is set into here.
- if (pAd->ContinBulkIn == TRUE)
- {
- RTUSBBulkReceive(pAd);
- }
- }
- else
-#endif // RALINK_ATE //
RTUSBBulkReceive(pAd);
return;
@@ -1310,9 +1307,9 @@ static void rt2870_hcca_dma_done_tasklet(unsigned long data)
UCHAR BulkOutPipeId = 4;
purbb_t pUrb;
-
+#ifndef RT30xx
DBGPRINT_RAW(RT_DEBUG_ERROR, ("--->hcca_dma_done_tasklet\n"));
-
+#endif
pUrb = (purbb_t)data;
pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
@@ -1342,13 +1339,19 @@ static void rt2870_hcca_dma_done_tasklet(unsigned long data)
RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId, MAX_TX_PROCESS);
}
+#ifndef RT30xx
RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL);
+#endif
+#ifdef RT30xx
+ RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL<<4);
+#endif
RTUSBKickBulkOut(pAd);
}
}
+#ifndef RT30xx
DBGPRINT_RAW(RT_DEBUG_ERROR, ("<---hcca_dma_done_tasklet\n"));
-
+#endif
return;
}
diff --git a/drivers/staging/rt2870/common/action.c b/drivers/staging/rt2870/common/action.c
index 3a48a7f5e2bc..fd806c3871aa 100644
--- a/drivers/staging/rt2870/common/action.c
+++ b/drivers/staging/rt2870/common/action.c
@@ -1,1046 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- action.c
-
- Abstract:
- Handle association related requests either from WSTA or from local MLME
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 2006 created for rt2860
- */
-
-#include "../rt_config.h"
-#include "action.h"
-
-
-static VOID ReservedAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
- Note:
- The state machine looks like the following
-
- ASSOC_IDLE
- MT2_MLME_DISASSOC_REQ mlme_disassoc_req_action
- MT2_PEER_DISASSOC_REQ peer_disassoc_action
- MT2_PEER_ASSOC_REQ drop
- MT2_PEER_REASSOC_REQ drop
- MT2_CLS3ERR cls3err_action
- ==========================================================================
- */
-VOID ActionStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, (STATE_MACHINE_FUNC *)Trans, MAX_ACT_STATE, MAX_ACT_MSG, (STATE_MACHINE_FUNC)Drop, ACT_IDLE, ACT_MACHINE_BASE);
-
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE, (STATE_MACHINE_FUNC)PeerSpectrumAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction);
-
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction);
-#ifdef QOS_DLS_SUPPORT
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)PeerDLSAction);
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE, (STATE_MACHINE_FUNC)PeerHTAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE, (STATE_MACHINE_FUNC)MlmeADDBAAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
-#endif // DOT11_N_SUPPORT //
-
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE, (STATE_MACHINE_FUNC)PeerPublicAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE, (STATE_MACHINE_FUNC)PeerRMAction);
-
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE, (STATE_MACHINE_FUNC)MlmeQOSAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE, (STATE_MACHINE_FUNC)MlmeDLSAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID, (STATE_MACHINE_FUNC)MlmeInvalidAction);
-}
-
-#ifdef DOT11_N_SUPPORT
-VOID MlmeADDBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- MLME_ADDBA_REQ_STRUCT *pInfo;
- UCHAR Addr[6];
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG Idx;
- FRAME_ADDBA_REQ Frame;
- ULONG FrameLen;
- BA_ORI_ENTRY *pBAEntry = NULL;
-
- pInfo = (MLME_ADDBA_REQ_STRUCT *)Elem->Msg;
- NdisZeroMemory(&Frame, sizeof(FRAME_ADDBA_REQ));
-
- if(MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr))
- {
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeADDBAAction() allocate memory failed \n"));
- return;
- }
- // 1. find entry
- Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
- if (Idx == 0)
- {
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
- return;
- }
- else
- {
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#ifdef QOS_DLS_SUPPORT
- if (pAd->MacTab.Content[pInfo->Wcid].ValidAsDls)
- ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#endif // QOS_DLS_SUPPORT //
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pInfo->pAddr);
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
- Frame.Category = CATEGORY_BA;
- Frame.Action = ADDBA_REQ;
- Frame.BaParm.AMSDUSupported = 0;
- Frame.BaParm.BAPolicy = IMMED_BA;
- Frame.BaParm.TID = pInfo->TID;
- Frame.BaParm.BufSize = pInfo->BaBufSize;
- Frame.Token = pInfo->Token;
- Frame.TimeOutValue = pInfo->TimeOutValue;
- Frame.BaStartSeq.field.FragNum = 0;
- Frame.BaStartSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
-
- *(USHORT *)(&Frame.BaParm) = cpu2le16(*(USHORT *)(&Frame.BaParm));
- Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
- Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ADDBA_REQ), &Frame,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n", Frame.BaStartSeq.field.StartSeq, FrameLen, Frame.BaParm.BufSize));
- }
-}
-
-/*
- ==========================================================================
- Description:
- send DELBA and delete BaEntry if any
- Parametrs:
- Elem - MLME message MLME_DELBA_REQ_STRUCT
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDELBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DELBA_REQ_STRUCT *pInfo;
- PUCHAR pOutBuffer = NULL;
- PUCHAR pOutBuffer2 = NULL;
- NDIS_STATUS NStatus;
- ULONG Idx;
- FRAME_DELBA_REQ Frame;
- ULONG FrameLen;
- FRAME_BAR FrameBar;
-
- pInfo = (MLME_DELBA_REQ_STRUCT *)Elem->Msg;
- // must send back DELBA
- NdisZeroMemory(&Frame, sizeof(FRAME_DELBA_REQ));
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
-
- if(MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen))
- {
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
- return;
- }
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_ERROR, ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
- return;
- }
-
- // SEND BAR (Send BAR to refresh peer reordering buffer.)
- Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
-
- FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL funciton.
- FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.TID = pInfo->TID; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.ACKPolicy = IMMED_BA; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.Compressed = 1; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.MTID = 0; // make sure sequence not clear in DEL funciton.
-
- MakeOutgoingFrame(pOutBuffer2, &FrameLen,
- sizeof(FRAME_BAR), &FrameBar,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer2);
- DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
-
- // SEND DELBA FRAME
- FrameLen = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#ifdef QOS_DLS_SUPPORT
- if (pAd->MacTab.Content[pInfo->Wcid].ValidAsDls)
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#endif // QOS_DLS_SUPPORT //
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[pInfo->Wcid].Addr);
- }
-#endif // CONFIG_STA_SUPPORT //
- Frame.Category = CATEGORY_BA;
- Frame.Action = DELBA;
- Frame.DelbaParm.Initiator = pInfo->Initiator;
- Frame.DelbaParm.TID = pInfo->TID;
- Frame.ReasonCode = 39; // Time Out
- *(USHORT *)(&Frame.DelbaParm) = cpu2le16(*(USHORT *)(&Frame.DelbaParm));
- Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_DELBA_REQ), &Frame,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n", pInfo->Initiator));
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID MlmeQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-VOID MlmeDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-VOID MlmeInvalidAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- //PUCHAR pOutBuffer = NULL;
- //Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11
-}
-
-VOID PeerQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-#ifdef QOS_DLS_SUPPORT
-VOID PeerDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- switch(Action)
- {
- case ACTION_DLS_REQUEST:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsReqAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
-
- case ACTION_DLS_RESPONSE:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsRspAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
-
- case ACTION_DLS_TEARDOWN:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsTearDownAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
- }
-}
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
-VOID PeerBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- switch(Action)
- {
- case ADDBA_REQ:
- PeerAddBAReqAction(pAd,Elem);
- break;
- case ADDBA_RESP:
- PeerAddBARspAction(pAd,Elem);
- break;
- case DELBA:
- PeerDelBAAction(pAd,Elem);
- break;
- }
-}
-
-
-#ifdef DOT11N_DRAFT3
-
-#ifdef CONFIG_STA_SUPPORT
-VOID StaPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Bss2040Coexist)
-{
- BSS_2040_COEXIST_IE BssCoexist;
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- BssCoexist.word = Bss2040Coexist;
- // AP asks Station to return a 20/40 BSS Coexistence mgmt frame. So we first starts a scan, then send back 20/40 BSS Coexistence mgmt frame
- if ((BssCoexist.field.InfoReq == 1) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)))
- {
- // Clear record first. After scan , will update those bit and send back to transmiter.
- pAd->CommonCfg.BSSCoexist2040.field.InfoReq = 1;
- pAd->CommonCfg.BSSCoexist2040.field.Intolerant40 = 0;
- pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 0;
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_2040_BSS_COEXIST);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- }
-}
-
-
-/*
-Description : Build Intolerant Channel Rerpot from Trigger event table.
-return : how many bytes copied.
-*/
-ULONG BuildIntolerantChannelRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest)
-{
- ULONG FrameLen = 0;
- ULONG ReadOffset = 0;
- UCHAR i;
- UCHAR LastRegClass = 0xff;
- PUCHAR pLen;
-
- for ( i = 0;i < MAX_TRIGGER_EVENT;i++)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid == TRUE)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass == LastRegClass)
- {
- *(pDest + ReadOffset) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
- *pLen++;
- ReadOffset++;
- FrameLen++;
- }
- else
- {
- *(pDest + ReadOffset) = IE_2040_BSS_INTOLERANT_REPORT; // IE
- *(pDest + ReadOffset + 1) = 2; // Len = RegClass byte + channel byte.
- pLen = pDest + ReadOffset + 1;
- LastRegClass = pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass;
- *(pDest + ReadOffset + 2) = LastRegClass; // Len = RegClass byte + channel byte.
- *(pDest + ReadOffset + 3) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
- FrameLen += 4;
- ReadOffset += 4;
- }
-
- }
- }
- return FrameLen;
-}
-
-
-/*
-Description : Send 20/40 BSS Coexistence Action frame If one trigger event is triggered.
-*/
-VOID Send2040CoexistAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- FRAME_ACTION_HDR Frame;
- ULONG FrameLen;
- ULONG IntolerantChaRepLen;
-
- IntolerantChaRepLen = 0;
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction() allocate memory failed \n"));
- return;
- }
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[Wcid].Addr, pAd->CommonCfg.Bssid);
- Frame.Category = CATEGORY_PUBLIC;
- Frame.Action = ACTION_BSS_2040_COEXIST;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ACTION_HDR), &Frame,
- END_OF_ARGS);
-
- *(pOutBuffer + FrameLen) = pAd->CommonCfg.BSSCoexist2040.word;
- FrameLen++;
-
- if (bAddIntolerantCha == TRUE)
- IntolerantChaRepLen = BuildIntolerantChannelRep(pAd, pOutBuffer + FrameLen);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen + IntolerantChaRepLen);
- DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction( BSSCoexist2040 = 0x%x ) \n", pAd->CommonCfg.BSSCoexist2040.word));
-
-}
-
-
-/*
- ==========================================================================
- Description:
- After scan, Update 20/40 BSS Coexistence IE and send out.
- According to 802.11n D3.03 11.14.10
-
- Parameters:
- ==========================================================================
- */
-VOID Update2040CoexistFrameAndNotify(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha)
-{
- BSS_2040_COEXIST_IE OldValue;
-
- OldValue.word = pAd->CommonCfg.BSSCoexist2040.word;
- if ((pAd->CommonCfg.TriggerEventTab.EventANo > 0) || (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0))
- pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 1;
-
- // Need to check !!!!
- // How STA will set Intolerant40 if implementation dependent. Now we don't set this bit first.!!!!!
- // So Only check BSS20WidthReq change.
- if (OldValue.field.BSS20WidthReq != pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq)
- {
- Send2040CoexistAction(pAd, Wcid, bAddIntolerantCha);
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-BOOLEAN ChannelSwitchSanityCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary)
-{
- UCHAR i;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- if ((NewChannel > 7) && (Secondary == 1))
- return FALSE;
-
- if ((NewChannel < 5) && (Secondary == 3))
- return FALSE;
-
- // 0. Check if new channel is in the channellist.
- for (i = 0;i < pAd->ChannelListNum;i++)
- {
- if (pAd->ChannelList[i].Channel == NewChannel)
- {
- break;
- }
- }
-
- if (i == pAd->ChannelListNum)
- return FALSE;
-
- return TRUE;
-}
-
-
-VOID ChannelSwitchAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary)
-{
- UCHAR BBPValue = 0;
- ULONG MACValue;
-
- DBGPRINT(RT_DEBUG_TRACE,("SPECTRUM - ChannelSwitchAction(NewChannel = %d , Secondary = %d) \n", NewChannel, Secondary));
-
- if (ChannelSwitchSanityCheck(pAd, Wcid, NewChannel, Secondary) == FALSE)
- return;
-
- // 1. Switches to BW = 20.
- if (Secondary == 0)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- pAd->CommonCfg.Channel = NewChannel;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel,FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("!!!20MHz !!! \n" ));
- }
- // 1. Switches to BW = 40 And Station supports BW = 40.
- else if (((Secondary == 1) || (Secondary == 3)) && (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == 1))
- {
- pAd->CommonCfg.Channel = NewChannel;
-
- if (Secondary == 1)
- {
- // Secondary above.
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
- MACValue &= 0xfe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
- BBPValue&= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else
- {
- // Secondary below.
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
- MACValue &= 0xfe;
- MACValue |= 0x1;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
- BBPValue&= (~0x20);
- BBPValue|= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 1;
- }
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-VOID PeerPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-#ifdef DOT11N_DRAFT3
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-#endif // DOT11N_DRAFT3 //
-
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
-#ifdef DOT11N_DRAFT3
- switch(Action)
- {
- case ACTION_BSS_2040_COEXIST: // Format defined in IEEE 7.4.7a.1 in 11n Draf3.03
- {
- //UCHAR BssCoexist;
- BSS_2040_COEXIST_ELEMENT *pCoexistInfo;
- BSS_2040_COEXIST_IE *pBssCoexistIe;
- BSS_2040_INTOLERANT_CH_REPORT *pIntolerantReport = NULL;
-
- if (Elem->MsgLen <= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT)) )
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ACTION - 20/40 BSS Coexistence Management Frame length too short! len = %ld!\n", Elem->MsgLen));
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("ACTION - 20/40 BSS Coexistence Management action----> \n"));
- hex_dump("CoexistenceMgmtFrame", Elem->Msg, Elem->MsgLen);
-
-
- pCoexistInfo = (BSS_2040_COEXIST_ELEMENT *) &Elem->Msg[LENGTH_802_11+2];
- //hex_dump("CoexistInfo", (PUCHAR)pCoexistInfo, sizeof(BSS_2040_COEXIST_ELEMENT));
- if (Elem->MsgLen >= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT) + sizeof(BSS_2040_INTOLERANT_CH_REPORT)))
- {
- pIntolerantReport = (BSS_2040_INTOLERANT_CH_REPORT *)((PUCHAR)pCoexistInfo + sizeof(BSS_2040_COEXIST_ELEMENT));
- }
- //hex_dump("IntolerantReport ", (PUCHAR)pIntolerantReport, sizeof(BSS_2040_INTOLERANT_CH_REPORT));
-
- pBssCoexistIe = (BSS_2040_COEXIST_IE *)(&pCoexistInfo->BssCoexistIe);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (INFRA_ON(pAd))
- {
- StaPublicAction(pAd, pCoexistInfo);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- }
- break;
- }
-
-#endif // DOT11N_DRAFT3 //
-
-}
-
-
-static VOID ReservedAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Category;
-
- if (Elem->MsgLen <= LENGTH_802_11)
- {
- return;
- }
-
- Category = Elem->Msg[LENGTH_802_11];
- DBGPRINT(RT_DEBUG_TRACE,("Rcv reserved category(%d) Action Frame\n", Category));
- hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
-}
-
-VOID PeerRMAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- return;
-}
-
-#ifdef DOT11_N_SUPPORT
-static VOID respond_ht_information_exchange_action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- FRAME_HT_INFO HTINFOframe, *pFrame;
- UCHAR *pAddr;
-
-
- // 2. Always send back ADDBA Response
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
-
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
- return;
- }
-
- // get RA
- pFrame = (FRAME_HT_INFO *) &Elem->Msg[0];
- pAddr = pFrame->Hdr.Addr2;
-
- NdisZeroMemory(&HTINFOframe, sizeof(FRAME_HT_INFO));
- // 2-1. Prepare ADDBA Response frame.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
- ActHeaderInit(pAd, &HTINFOframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- HTINFOframe.Category = CATEGORY_HT;
- HTINFOframe.Action = HT_INFO_EXCHANGE;
- HTINFOframe.HT_Info.Request = 0;
- HTINFOframe.HT_Info.Forty_MHz_Intolerant = pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
- HTINFOframe.HT_Info.STA_Channel_Width = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_HT_INFO), &HTINFOframe,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-
-#ifdef DOT11N_DRAFT3
-VOID SendNotifyBWActionFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- FRAME_ACTION_HDR Frame;
- ULONG FrameLen;
- PUCHAR pAddr1;
-
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ACT - SendNotifyBWAction() allocate memory failed \n"));
- return;
- }
-
- if (Wcid == MCAST_WCID)
- pAddr1 = &BROADCAST_ADDR[0];
- else
- pAddr1 = pAd->MacTab.Content[Wcid].Addr;
- ActHeaderInit(pAd, &Frame.Hdr, pAddr1, pAd->ApCfg.MBSSID[apidx].Bssid, pAd->ApCfg.MBSSID[apidx].Bssid);
-
- Frame.Category = CATEGORY_HT;
- Frame.Action = NOTIFY_BW_ACTION;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ACTION_HDR), &Frame,
- END_OF_ARGS);
-
- *(pOutBuffer + FrameLen) = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
- FrameLen++;
-
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- DBGPRINT(RT_DEBUG_TRACE,("ACT - SendNotifyBWAction(NotifyBW= %d)!\n", pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth));
-
-}
-#endif // DOT11N_DRAFT3 //
-
-
-VOID PeerHTAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- switch(Action)
- {
- case NOTIFY_BW_ACTION:
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Notify Channel bandwidth action----> \n"));
-#ifdef CONFIG_STA_SUPPORT
- if(pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- {
- // Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
- // sending BW_Notify Action frame, and cause us to linkup and linkdown.
- // In legacy mode, don't need to parse HT action frame.
- DBGPRINT(RT_DEBUG_TRACE,("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
- Elem->Msg[LENGTH_802_11+2] ));
- break;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (Elem->Msg[LENGTH_802_11+2] == 0) // 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
- pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
-
- break;
-
- case SMPS_ACTION:
- // 7.3.1.25
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - SMPS action----> \n"));
- if (((Elem->Msg[LENGTH_802_11+2]&0x1) == 0))
- {
- pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
- }
- else if (((Elem->Msg[LENGTH_802_11+2]&0x2) == 0))
- {
- pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
- }
- else
- {
- pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Aid(%d) MIMO PS = %d\n", Elem->Wcid, pAd->MacTab.Content[Elem->Wcid].MmpsMode));
- // rt2860c : add something for smps change.
- break;
-
- case SETPCO_ACTION:
- break;
-
- case MIMO_CHA_MEASURE_ACTION:
- break;
-
- case HT_INFO_EXCHANGE:
- {
- HT_INFORMATION_OCTET *pHT_info;
-
- pHT_info = (HT_INFORMATION_OCTET *) &Elem->Msg[LENGTH_802_11+2];
- // 7.4.8.10
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Information Exchange action----> \n"));
- if (pHT_info->Request)
- {
- respond_ht_information_exchange_action(pAd, Elem);
- }
- }
- break;
- }
-}
-
-
-/*
- ==========================================================================
- Description:
- Retry sending ADDBA Reqest.
-
- IRQL = DISPATCH_LEVEL
-
- Parametrs:
- p8023Header: if this is already 802.3 format, p8023Header is NULL
-
- Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
- FALSE , then continue indicaterx at this moment.
- ==========================================================================
- */
-VOID ORIBATimerTimeout(
- IN PRTMP_ADAPTER pAd)
-{
- MAC_TABLE_ENTRY *pEntry;
- INT i, total;
-// FRAME_BAR FrameBar;
-// ULONG FrameLen;
-// NDIS_STATUS NStatus;
-// PUCHAR pOutBuffer = NULL;
-// USHORT Sequence;
- UCHAR TID;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- total = pAd->MacTab.Size * NUM_OF_TID;
-
- for (i = 1; ((i <MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)) ; i++)
- {
- if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done)
- {
- pEntry = &pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].Wcid];
- TID = pAd->BATable.BAOriEntry[i].TID;
-
- ASSERT(pAd->BATable.BAOriEntry[i].Wcid < MAX_LEN_OF_MAC_TABLE);
- }
- total --;
- }
-}
-
-
-VOID SendRefreshBAR(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- FRAME_BAR FrameBar;
- ULONG FrameLen;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- USHORT Sequence;
- UCHAR i, TID;
- USHORT idx;
- BA_ORI_ENTRY *pBAEntry;
-
- for (i = 0; i <NUM_OF_TID; i++)
- {
- idx = pEntry->BAOriWcidArray[i];
- if (idx == 0)
- {
- continue;
- }
- pBAEntry = &pAd->BATable.BAOriEntry[idx];
-
- if (pBAEntry->ORI_BA_Status == Originator_Done)
- {
- TID = pBAEntry->TID;
-
- ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
- return;
- }
-
- Sequence = pEntry->TxSeq[TID];
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pEntry->Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
-
- FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
- FrameBar.StartingSeq.field.StartSeq = Sequence; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.TID = TID; // make sure sequence not clear in DEL funciton.
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_BAR), &FrameBar,
- END_OF_ARGS);
- //if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET)))
- if (1) // Now we always send BAR.
- {
- //MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- }
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID ActHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN PUCHAR Addr1,
- IN PUCHAR Addr2,
- IN PUCHAR Addr3)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
- pHdr80211->FC.Type = BTYPE_MGMT;
- pHdr80211->FC.SubType = SUBTYPE_ACTION;
-
- COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
- COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
- COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
-}
-
-VOID BarHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PFRAME_BAR pCntlBar,
- IN PUCHAR pDA,
- IN PUCHAR pSA)
-{
-// USHORT Duration;
-
- NdisZeroMemory(pCntlBar, sizeof(FRAME_BAR));
- pCntlBar->FC.Type = BTYPE_CNTL;
- pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
- pCntlBar->BarControl.MTID = 0;
- pCntlBar->BarControl.Compressed = 1;
- pCntlBar->BarControl.ACKPolicy = 0;
-
-
- pCntlBar->Duration = 16 + RTMPCalcDuration(pAd, RATE_1, sizeof(FRAME_BA));
-
- COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
- COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
-}
-
-
-/*
- ==========================================================================
- Description:
- Insert Category and action code into the action frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. category code of the frame.
- 4. action code of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID InsertActField(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 Category,
- IN UINT8 ActCode)
-{
- ULONG TempLen;
-
- MakeOutgoingFrame( pFrameBuf, &TempLen,
- 1, &Category,
- 1, &ActCode,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
+#include "../../rt2860/common/action.c"
diff --git a/drivers/staging/rt2870/common/action.h b/drivers/staging/rt2870/common/action.h
index ce3877dce81b..9a1895525f30 100644
--- a/drivers/staging/rt2870/common/action.h
+++ b/drivers/staging/rt2870/common/action.h
@@ -1,68 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- aironet.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 04-06-15 Initial
-*/
-
-#ifndef __ACTION_H__
-#define __ACTION_H__
-
-typedef struct PACKED __HT_INFO_OCTET
-{
-#ifdef RT_BIG_ENDIAN
- UCHAR Reserved:5;
- UCHAR STA_Channel_Width:1;
- UCHAR Forty_MHz_Intolerant:1;
- UCHAR Request:1;
-#else
- UCHAR Request:1;
- UCHAR Forty_MHz_Intolerant:1;
- UCHAR STA_Channel_Width:1;
- UCHAR Reserved:5;
-#endif
-} HT_INFORMATION_OCTET;
-
-
-typedef struct PACKED __FRAME_HT_INFO
-{
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- HT_INFORMATION_OCTET HT_Info;
-} FRAME_HT_INFO, *PFRAME_HT_INFO;
-
-#endif /* __ACTION_H__ */
-
-
+#include "../../rt2860/common/action.h"
diff --git a/drivers/staging/rt2870/common/ba_action.c b/drivers/staging/rt2870/common/ba_action.c
index d9f738177e2b..a9e6a09d994f 100644
--- a/drivers/staging/rt2870/common/ba_action.c
+++ b/drivers/staging/rt2870/common/ba_action.c
@@ -1,1798 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-
-#ifdef DOT11_N_SUPPORT
-
-#include "../rt_config.h"
-
-
-
-#define BA_ORI_INIT_SEQ (pEntry->TxSeq[TID]) //1 // inital sequence number of BA session
-
-#define ORI_SESSION_MAX_RETRY 8
-#define ORI_BA_SESSION_TIMEOUT (2000) // ms
-#define REC_BA_SESSION_IDLE_TIMEOUT (1000) // ms
-
-#define REORDERING_PACKET_TIMEOUT ((100 * HZ)/1000) // system ticks -- 100 ms
-#define MAX_REORDERING_PACKET_TIMEOUT ((3000 * HZ)/1000) // system ticks -- 100 ms
-
-#define RESET_RCV_SEQ (0xFFFF)
-
-static void ba_mpdu_blk_free(PRTMP_ADAPTER pAd, struct reordering_mpdu *mpdu_blk);
-
-
-BA_ORI_ENTRY *BATableAllocOriEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx);
-
-BA_REC_ENTRY *BATableAllocRecEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx);
-
-VOID BAOriSessionSetupTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID BARecSessionIdleTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-
-BUILD_TIMER_FUNCTION(BAOriSessionSetupTimeout);
-BUILD_TIMER_FUNCTION(BARecSessionIdleTimeout);
-
-#define ANNOUNCE_REORDERING_PACKET(_pAd, _mpdu_blk) \
- Announce_Reordering_Packet(_pAd, _mpdu_blk);
-
-VOID BA_MaxWinSizeReasign(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntryPeer,
- OUT UCHAR *pWinSize)
-{
- UCHAR MaxSize;
-
-
- if (pAd->MACVersion >= RALINK_2883_VERSION) // 3*3
- {
- if (pAd->MACVersion >= RALINK_3070_VERSION)
- {
- if (pEntryPeer->WepStatus != Ndis802_11EncryptionDisabled)
- MaxSize = 7; // for non-open mode
- else
- MaxSize = 13;
- }
- else
- MaxSize = 31;
- }
- else if (pAd->MACVersion >= RALINK_2880E_VERSION) // 2880 e
- {
- if (pEntryPeer->WepStatus != Ndis802_11EncryptionDisabled)
- MaxSize = 7; // for non-open mode
- else
- MaxSize = 13;
- }
- else
- MaxSize = 7;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ba> Win Size = %d, Max Size = %d\n",
- *pWinSize, MaxSize));
-
- if ((*pWinSize) > MaxSize)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ba> reassign max win size from %d to %d\n",
- *pWinSize, MaxSize));
-
- *pWinSize = MaxSize;
- }
-}
-
-void Announce_Reordering_Packet(IN PRTMP_ADAPTER pAd,
- IN struct reordering_mpdu *mpdu)
-{
- PNDIS_PACKET pPacket;
-
- pPacket = mpdu->pPacket;
-
- if (mpdu->bAMSDU)
- {
- ASSERT(0);
- BA_Reorder_AMSDU_Annnounce(pAd, pPacket);
- }
- else
- {
- //
- // pass this 802.3 packet to upper layer or forward this packet to WM directly
- //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket, RTMP_GET_PACKET_IF(pPacket));
-#endif // CONFIG_STA_SUPPORT //
- }
-}
-
-/*
- * Insert a reordering mpdu into sorted linked list by sequence no.
- */
-BOOLEAN ba_reordering_mpdu_insertsorted(struct reordering_list *list, struct reordering_mpdu *mpdu)
-{
-
- struct reordering_mpdu **ppScan = &list->next;
-
- while (*ppScan != NULL)
- {
- if (SEQ_SMALLER((*ppScan)->Sequence, mpdu->Sequence, MAXSEQ))
- {
- ppScan = &(*ppScan)->next;
- }
- else if ((*ppScan)->Sequence == mpdu->Sequence)
- {
- /* give up this duplicated frame */
- return(FALSE);
- }
- else
- {
- /* find position */
- break;
- }
- }
-
- mpdu->next = *ppScan;
- *ppScan = mpdu;
- list->qlen++;
- return TRUE;
-}
-
-
-/*
- * caller lock critical section if necessary
- */
-static inline void ba_enqueue(struct reordering_list *list, struct reordering_mpdu *mpdu_blk)
-{
- list->qlen++;
- mpdu_blk->next = list->next;
- list->next = mpdu_blk;
-}
-
-/*
- * caller lock critical section if necessary
- */
-static inline struct reordering_mpdu * ba_dequeue(struct reordering_list *list)
-{
- struct reordering_mpdu *mpdu_blk = NULL;
-
- ASSERT(list);
-
- if (list->qlen)
- {
- list->qlen--;
- mpdu_blk = list->next;
- if (mpdu_blk)
- {
- list->next = mpdu_blk->next;
- mpdu_blk->next = NULL;
- }
- }
- return mpdu_blk;
-}
-
-
-static inline struct reordering_mpdu *ba_reordering_mpdu_dequeue(struct reordering_list *list)
-{
- return(ba_dequeue(list));
-}
-
-
-static inline struct reordering_mpdu *ba_reordering_mpdu_probe(struct reordering_list *list)
- {
- ASSERT(list);
-
- return(list->next);
- }
-
-
-/*
- * free all resource for reordering mechanism
- */
-void ba_reordering_resource_release(PRTMP_ADAPTER pAd)
-{
- BA_TABLE *Tab;
- PBA_REC_ENTRY pBAEntry;
- struct reordering_mpdu *mpdu_blk;
- int i;
-
- Tab = &pAd->BATable;
-
- /* I. release all pending reordering packet */
- NdisAcquireSpinLock(&pAd->BATabLock);
- for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++)
- {
- pBAEntry = &Tab->BARecEntry[i];
- if (pBAEntry->REC_BA_Status != Recipient_NONE)
- {
- while ((mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list)))
- {
- ASSERT(mpdu_blk->pPacket);
- RELEASE_NDIS_PACKET(pAd, mpdu_blk->pPacket, NDIS_STATUS_FAILURE);
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
- }
- }
- NdisReleaseSpinLock(&pAd->BATabLock);
-
- ASSERT(pBAEntry->list.qlen == 0);
- /* II. free memory of reordering mpdu table */
- NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
- os_free_mem(pAd, pAd->mpdu_blk_pool.mem);
- NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-}
-
-
-
-/*
- * Allocate all resource for reordering mechanism
- */
-BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num)
-{
- int i;
- PUCHAR mem;
- struct reordering_mpdu *mpdu_blk;
- struct reordering_list *freelist;
-
- /* allocate spinlock */
- NdisAllocateSpinLock(&pAd->mpdu_blk_pool.lock);
-
- /* initialize freelist */
- freelist = &pAd->mpdu_blk_pool.freelist;
- freelist->next = NULL;
- freelist->qlen = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Allocate %d memory for BA reordering\n", (UINT32)(num*sizeof(struct reordering_mpdu))));
-
- /* allocate number of mpdu_blk memory */
- os_alloc_mem(pAd, (PUCHAR *)&mem, (num*sizeof(struct reordering_mpdu)));
-
- pAd->mpdu_blk_pool.mem = mem;
-
- if (mem == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Can't Allocate Memory for BA Reordering\n"));
- return(FALSE);
- }
-
- /* build mpdu_blk free list */
- for (i=0; i<num; i++)
- {
- /* get mpdu_blk */
- mpdu_blk = (struct reordering_mpdu *) mem;
- /* initial mpdu_blk */
- NdisZeroMemory(mpdu_blk, sizeof(struct reordering_mpdu));
- /* next mpdu_blk */
- mem += sizeof(struct reordering_mpdu);
- /* insert mpdu_blk into freelist */
- ba_enqueue(freelist, mpdu_blk);
- }
-
- return(TRUE);
-}
-
-//static int blk_count=0; // sample take off, no use
-
-static struct reordering_mpdu *ba_mpdu_blk_alloc(PRTMP_ADAPTER pAd)
-{
- struct reordering_mpdu *mpdu_blk;
-
- NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
- mpdu_blk = ba_dequeue(&pAd->mpdu_blk_pool.freelist);
- if (mpdu_blk)
- {
-// blk_count++;
- /* reset mpdu_blk */
- NdisZeroMemory(mpdu_blk, sizeof(struct reordering_mpdu));
- }
- NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
- return mpdu_blk;
-}
-
-static void ba_mpdu_blk_free(PRTMP_ADAPTER pAd, struct reordering_mpdu *mpdu_blk)
-{
- ASSERT(mpdu_blk);
-
- NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
-// blk_count--;
- ba_enqueue(&pAd->mpdu_blk_pool.freelist, mpdu_blk);
- NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-}
-
-
-static USHORT ba_indicate_reordering_mpdus_in_order(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN USHORT StartSeq)
-{
- struct reordering_mpdu *mpdu_blk;
- USHORT LastIndSeq = RESET_RCV_SEQ;
-
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
- while ((mpdu_blk = ba_reordering_mpdu_probe(&pBAEntry->list)))
- {
- /* find in-order frame */
- if (!SEQ_STEPONE(mpdu_blk->Sequence, StartSeq, MAXSEQ))
- {
- break;
- }
- /* dequeue in-order frame from reodering list */
- mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list);
- /* pass this frame up */
- ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
- /* move to next sequence */
- StartSeq = mpdu_blk->Sequence;
- LastIndSeq = StartSeq;
- /* free mpdu_blk */
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
-
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-
- /* update last indicated sequence */
- return LastIndSeq;
-}
-
-static void ba_indicate_reordering_mpdus_le_seq(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN USHORT Sequence)
-{
- struct reordering_mpdu *mpdu_blk;
-
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
- while ((mpdu_blk = ba_reordering_mpdu_probe(&pBAEntry->list)))
- {
- /* find in-order frame */
- if ((mpdu_blk->Sequence == Sequence) || SEQ_SMALLER(mpdu_blk->Sequence, Sequence, MAXSEQ))
- {
- /* dequeue in-order frame from reodering list */
- mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list);
- /* pass this frame up */
- ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
- /* free mpdu_blk */
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
- else
- {
- break;
- }
- }
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-}
-
-
-static void ba_refresh_reordering_mpdus(
- IN PRTMP_ADAPTER pAd,
- PBA_REC_ENTRY pBAEntry)
-{
- struct reordering_mpdu *mpdu_blk;
-
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
- /* dequeue in-order frame from reodering list */
- while ((mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list)))
- {
- /* pass this frame up */
- ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
-
- pBAEntry->LastIndSeq = mpdu_blk->Sequence;
- ba_mpdu_blk_free(pAd, mpdu_blk);
-
- /* update last indicated sequence */
- }
- ASSERT(pBAEntry->list.qlen == 0);
- pBAEntry->LastIndSeq = RESET_RCV_SEQ;
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-}
-
-
-//static
-void ba_flush_reordering_timeout_mpdus(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN ULONG Now32)
-
-{
- USHORT Sequence;
-
-// if ((RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+REORDERING_PACKET_TIMEOUT)) &&
-// (pBAEntry->list.qlen > ((pBAEntry->BAWinSize*7)/8))) //||
-// (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(10*REORDERING_PACKET_TIMEOUT))) &&
-// (pBAEntry->list.qlen > (pBAEntry->BAWinSize/8)))
- if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(MAX_REORDERING_PACKET_TIMEOUT/6)))
- &&(pBAEntry->list.qlen > 1)
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%08lx-%08lx = %d > %d): %x, flush all!\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
- (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), MAX_REORDERING_PACKET_TIMEOUT,
- pBAEntry->LastIndSeq));
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- pBAEntry->LastIndSeqAtTimer = Now32;
- }
- else
- if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(REORDERING_PACKET_TIMEOUT)))
- && (pBAEntry->list.qlen > 0)
- )
- {
- //
- // force LastIndSeq to shift to LastIndSeq+1
- //
- Sequence = (pBAEntry->LastIndSeq+1) & MAXSEQ;
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
- pBAEntry->LastIndSeqAtTimer = Now32;
- pBAEntry->LastIndSeq = Sequence;
- //
- // indicate in-order mpdus
- //
- Sequence = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, Sequence);
- if (Sequence != RESET_RCV_SEQ)
- {
- pBAEntry->LastIndSeq = Sequence;
- }
-
- }
-#if 0
- else if (
- (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(MAX_REORDERING_PACKET_TIMEOUT))) &&
- (pBAEntry->list.qlen > 1))
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%lx-%lx = %d > %d): %x\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
- (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), MAX_REORDERING_PACKET_TIMEOUT,
- pBAEntry->LastIndSeq));
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- pBAEntry->LastIndSeqAtTimer = Now32;
- }
-#endif
-}
-
-
-/*
- * generate ADDBA request to
- * set up BA agreement
- */
-VOID BAOriSessionSetUp(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN UCHAR TID,
- IN USHORT TimeOut,
- IN ULONG DelayTime,
- IN BOOLEAN isForced)
-
-{
- //MLME_ADDBA_REQ_STRUCT AddbaReq;
- BA_ORI_ENTRY *pBAEntry = NULL;
- USHORT Idx;
- BOOLEAN Cancelled;
-
- if ((pAd->CommonCfg.BACapability.field.AutoBA != TRUE) && (isForced == FALSE))
- return;
-
- // if this entry is limited to use legacy tx mode, it doesn't generate BA.
- if (RTMPStaFixedTxMode(pAd, pEntry) != FIXED_TXMODE_HT)
- return;
-
- if ((pEntry->BADeclineBitmap & (1<<TID)) && (isForced == FALSE))
- {
- // try again after 3 secs
- DelayTime = 3000;
-// printk("DeCline BA from Peer\n");
-// return;
- }
-
-
- Idx = pEntry->BAOriWcidArray[TID];
- if (Idx == 0)
- {
- // allocate a BA session
- pBAEntry = BATableAllocOriEntry(pAd, &Idx);
- if (pBAEntry == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ADDBA - MlmeADDBAAction() allocate BA session failed \n"));
- return;
- }
- }
- else
- {
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
- }
-
- if (pBAEntry->ORI_BA_Status >= Originator_WaitRes)
- {
- return;
- }
-
- pEntry->BAOriWcidArray[TID] = Idx;
-
- // Initialize BA session
- pBAEntry->ORI_BA_Status = Originator_WaitRes;
- pBAEntry->Wcid = pEntry->Aid;
- pBAEntry->BAWinSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
- pBAEntry->Sequence = BA_ORI_INIT_SEQ;
- pBAEntry->Token = 1; // (2008-01-21) Jan Lee recommends it - this token can't be 0
- pBAEntry->TID = TID;
- pBAEntry->TimeOutValue = TimeOut;
- pBAEntry->pAdapter = pAd;
-
- if (!(pEntry->TXBAbitmap & (1<<TID)))
- {
- RTMPInitTimer(pAd, &pBAEntry->ORIBATimer, GET_TIMER_FUNCTION(BAOriSessionSetupTimeout), pBAEntry, FALSE);
- }
- else
- RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-
- // set timer to send ADDBA request
- RTMPSetTimer(&pBAEntry->ORIBATimer, DelayTime);
-}
-
-VOID BAOriSessionAdd(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN PFRAME_ADDBA_RSP pFrame)
-{
- BA_ORI_ENTRY *pBAEntry = NULL;
- BOOLEAN Cancelled;
- UCHAR TID;
- USHORT Idx;
- PUCHAR pOutBuffer2 = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- FRAME_BAR FrameBar;
-
- TID = pFrame->BaParm.TID;
- Idx = pEntry->BAOriWcidArray[TID];
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
-
- // Start fill in parameters.
- if ((Idx !=0) && (pBAEntry->TID == TID) && (pBAEntry->ORI_BA_Status == Originator_WaitRes))
- {
- pBAEntry->BAWinSize = min(pBAEntry->BAWinSize, ((UCHAR)pFrame->BaParm.BufSize));
- BA_MaxWinSizeReasign(pAd, pEntry, &pBAEntry->BAWinSize);
-
- pBAEntry->TimeOutValue = pFrame->TimeOutValue;
- pBAEntry->ORI_BA_Status = Originator_Done;
- // reset sequence number
- pBAEntry->Sequence = BA_ORI_INIT_SEQ;
- // Set Bitmap flag.
- pEntry->TXBAbitmap |= (1<<TID);
- RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-
- pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue;
-
- DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __func__, pEntry->TXBAbitmap,
- pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue));
-
- // SEND BAR ;
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - BAOriSessionAdd() allocate memory failed \n"));
- return;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pBAEntry->Wcid].Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
-
- FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
- FrameBar.StartingSeq.field.StartSeq = pBAEntry->Sequence; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.TID = pBAEntry->TID; // make sure sequence not clear in DEL funciton.
- MakeOutgoingFrame(pOutBuffer2, &FrameLen,
- sizeof(FRAME_BAR), &FrameBar,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer2);
-
-
- if (pBAEntry->ORIBATimer.TimerValue)
- RTMPSetTimer(&pBAEntry->ORIBATimer, pBAEntry->ORIBATimer.TimerValue); // in mSec
- }
-}
-
-BOOLEAN BARecSessionAdd(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN PFRAME_ADDBA_REQ pFrame)
-{
- BA_REC_ENTRY *pBAEntry = NULL;
- BOOLEAN Status = TRUE;
- BOOLEAN Cancelled;
- USHORT Idx;
- UCHAR TID;
- UCHAR BAWinSize;
- //UINT32 Value;
- //UINT offset;
-
-
- ASSERT(pEntry);
-
- // find TID
- TID = pFrame->BaParm.TID;
-
- BAWinSize = min(((UCHAR)pFrame->BaParm.BufSize), (UCHAR)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
-
- // Intel patch
- if (BAWinSize == 0)
- {
- BAWinSize = 64;
- }
-
- Idx = pEntry->BARecWcidArray[TID];
-
-
- if (Idx == 0)
- {
- pBAEntry = BATableAllocRecEntry(pAd, &Idx);
- }
- else
- {
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- // flush all pending reordering mpdus
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __func__, pAd->BATable.numAsRecipient, Idx,
- pFrame->BaParm.BufSize, BAWinSize));
-
- // Start fill in parameters.
- if (pBAEntry != NULL)
- {
- ASSERT(pBAEntry->list.qlen == 0);
-
- pBAEntry->REC_BA_Status = Recipient_HandleRes;
- pBAEntry->BAWinSize = BAWinSize;
- pBAEntry->Wcid = pEntry->Aid;
- pBAEntry->TID = TID;
- pBAEntry->TimeOutValue = pFrame->TimeOutValue;
- pBAEntry->REC_BA_Status = Recipient_Accept;
- // initial sequence number
- pBAEntry->LastIndSeq = RESET_RCV_SEQ; //pFrame->BaStartSeq.field.StartSeq;
-
- printk("Start Seq = %08x\n", pFrame->BaStartSeq.field.StartSeq);
-
- if (pEntry->RXBAbitmap & (1<<TID))
- {
- RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
- }
- else
- {
- RTMPInitTimer(pAd, &pBAEntry->RECBATimer, GET_TIMER_FUNCTION(BARecSessionIdleTimeout), pBAEntry, TRUE);
- }
-
-#if 0 // for debugging
- RTMPSetTimer(&pBAEntry->RECBATimer, REC_BA_SESSION_IDLE_TIMEOUT);
-#endif
-
- // Set Bitmap flag.
- pEntry->RXBAbitmap |= (1<<TID);
- pEntry->BARecWcidArray[TID] = Idx;
-
- pEntry->BADeclineBitmap &= ~(1<<TID);
-
- // Set BA session mask in WCID table.
- RT28XX_ADD_BA_SESSION_TO_ASIC(pAd, pEntry->Aid, TID);
-
- DBGPRINT(RT_DEBUG_TRACE,("MACEntry[%d]RXBAbitmap = 0x%x. BARecWcidArray=%d\n",
- pEntry->Aid, pEntry->RXBAbitmap, pEntry->BARecWcidArray[TID]));
- }
- else
- {
- Status = FALSE;
- DBGPRINT(RT_DEBUG_TRACE,("Can't Accept ADDBA for %02x:%02x:%02x:%02x:%02x:%02x TID = %d\n",
- PRINT_MAC(pEntry->Addr), TID));
- }
- return(Status);
-}
-
-
-BA_REC_ENTRY *BATableAllocRecEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx)
-{
- int i;
- BA_REC_ENTRY *pBAEntry = NULL;
-
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- if (pAd->BATable.numAsRecipient >= MAX_BARECI_SESSION)
- {
- printk("BA Recipeint Session (%ld) > %d\n", pAd->BATable.numAsRecipient,
- MAX_BARECI_SESSION);
- goto done;
- }
-
- // reserve idx 0 to identify BAWcidArray[TID] as empty
- for (i=1; i < MAX_LEN_OF_BA_REC_TABLE; i++)
- {
- pBAEntry =&pAd->BATable.BARecEntry[i];
- if ((pBAEntry->REC_BA_Status == Recipient_NONE))
- {
- // get one
- pAd->BATable.numAsRecipient++;
- pBAEntry->REC_BA_Status = Recipient_USED;
- *Idx = i;
- break;
- }
- }
-
-done:
- NdisReleaseSpinLock(&pAd->BATabLock);
- return pBAEntry;
-}
-
-BA_ORI_ENTRY *BATableAllocOriEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx)
-{
- int i;
- BA_ORI_ENTRY *pBAEntry = NULL;
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- if (pAd->BATable.numAsOriginator >= (MAX_LEN_OF_BA_ORI_TABLE))
- {
- goto done;
- }
-
- // reserve idx 0 to identify BAWcidArray[TID] as empty
- for (i=1; i<MAX_LEN_OF_BA_ORI_TABLE; i++)
- {
- pBAEntry =&pAd->BATable.BAOriEntry[i];
- if ((pBAEntry->ORI_BA_Status == Originator_NONE))
- {
- // get one
- pAd->BATable.numAsOriginator++;
- pBAEntry->ORI_BA_Status = Originator_USED;
- pBAEntry->pAdapter = pAd;
- *Idx = i;
- break;
- }
- }
-
-done:
- NdisReleaseSpinLock(&pAd->BATabLock);
- return pBAEntry;
-}
-
-
-VOID BATableFreeOriEntry(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Idx)
-{
- BA_ORI_ENTRY *pBAEntry = NULL;
- MAC_TABLE_ENTRY *pEntry;
-
-
- if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_ORI_TABLE))
- return;
-
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
-
- if (pBAEntry->ORI_BA_Status != Originator_NONE)
- {
- pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
- pEntry->BAOriWcidArray[pBAEntry->TID] = 0;
-
-
- NdisAcquireSpinLock(&pAd->BATabLock);
- if (pBAEntry->ORI_BA_Status == Originator_Done)
- {
- pEntry->TXBAbitmap &= (~(1<<(pBAEntry->TID) ));
- DBGPRINT(RT_DEBUG_TRACE, ("BATableFreeOriEntry numAsOriginator= %ld\n", pAd->BATable.numAsRecipient));
- // Erase Bitmap flag.
- }
-
- ASSERT(pAd->BATable.numAsOriginator != 0);
-
- pAd->BATable.numAsOriginator -= 1;
-
- pBAEntry->ORI_BA_Status = Originator_NONE;
- pBAEntry->Token = 0;
- NdisReleaseSpinLock(&pAd->BATabLock);
- }
-}
-
-
-VOID BATableFreeRecEntry(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Idx)
-{
- BA_REC_ENTRY *pBAEntry = NULL;
- MAC_TABLE_ENTRY *pEntry;
-
-
- if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_REC_TABLE))
- return;
-
- pBAEntry =&pAd->BATable.BARecEntry[Idx];
-
- if (pBAEntry->REC_BA_Status != Recipient_NONE)
- {
- pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
- pEntry->BARecWcidArray[pBAEntry->TID] = 0;
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- ASSERT(pAd->BATable.numAsRecipient != 0);
-
- pAd->BATable.numAsRecipient -= 1;
-
- pBAEntry->REC_BA_Status = Recipient_NONE;
- NdisReleaseSpinLock(&pAd->BATabLock);
- }
-}
-
-
-VOID BAOriSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive,
- IN BOOLEAN bForceSend)
-{
- ULONG Idx = 0;
- BA_ORI_ENTRY *pBAEntry;
- BOOLEAN Cancelled;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- {
- return;
- }
-
- //
- // Locate corresponding BA Originator Entry in BA Table with the (pAddr,TID).
- //
- Idx = pAd->MacTab.Content[Wcid].BAOriWcidArray[TID];
- if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_ORI_TABLE))
- {
- if (bForceSend == TRUE)
- {
- // force send specified TID DelBA
- MLME_DELBA_REQ_STRUCT DelbaReq;
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
- NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-
- COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
- DelbaReq.Wcid = Wcid;
- DelbaReq.TID = TID;
- DelbaReq.Initiator = ORIGINATOR;
-#if 1
- Elem->MsgLen = sizeof(DelbaReq);
- NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
- MlmeDELBAAction(pAd, Elem);
- kfree(Elem);
-#else
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
- RT28XX_MLME_HANDLER(pAd);
-#endif
- }
-
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
-
- pBAEntry = &pAd->BATable.BAOriEntry[Idx];
- DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status));
- //
- // Prepare DelBA action frame and send to the peer.
- //
- if ((bPassive == FALSE) && (TID == pBAEntry->TID) && (pBAEntry->ORI_BA_Status == Originator_Done))
- {
- MLME_DELBA_REQ_STRUCT DelbaReq;
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
- NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-
- COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
- DelbaReq.Wcid = Wcid;
- DelbaReq.TID = pBAEntry->TID;
- DelbaReq.Initiator = ORIGINATOR;
-#if 1
- Elem->MsgLen = sizeof(DelbaReq);
- NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
- MlmeDELBAAction(pAd, Elem);
- kfree(Elem);
-#else
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
- RT28XX_MLME_HANDLER(pAd);
-#endif
- }
- RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
- BATableFreeOriEntry(pAd, Idx);
-
- if (bPassive)
- {
- //BAOriSessionSetUp(pAd, &pAd->MacTab.Content[Wcid], TID, 0, 10000, TRUE);
- }
-}
-
-VOID BARecSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive)
-{
- ULONG Idx = 0;
- BA_REC_ENTRY *pBAEntry;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- {
- return;
- }
-
- //
- // Locate corresponding BA Originator Entry in BA Table with the (pAddr,TID).
- //
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- if (Idx == 0)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
-
-
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, REC_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->REC_BA_Status));
- //
- // Prepare DelBA action frame and send to the peer.
- //
- if ((TID == pBAEntry->TID) && (pBAEntry->REC_BA_Status == Recipient_Accept))
- {
- MLME_DELBA_REQ_STRUCT DelbaReq;
- BOOLEAN Cancelled;
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
- //ULONG offset;
- //UINT32 VALUE;
-
- RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
-
- //
- // 1. Send DELBA Action Frame
- //
- if (bPassive == FALSE)
- {
- NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
- NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-
- COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
- DelbaReq.Wcid = Wcid;
- DelbaReq.TID = TID;
- DelbaReq.Initiator = RECIPIENT;
-#if 1
- Elem->MsgLen = sizeof(DelbaReq);
- NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
- MlmeDELBAAction(pAd, Elem);
- kfree(Elem);
-#else
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
- RT28XX_MLME_HANDLER(pAd);
-#endif
- }
-
-
- //
- // 2. Free resource of BA session
- //
- // flush all pending reordering mpdus
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- // Erase Bitmap flag.
- pBAEntry->LastIndSeq = RESET_RCV_SEQ;
- pBAEntry->BAWinSize = 0;
- // Erase Bitmap flag at software mactable
- pAd->MacTab.Content[Wcid].RXBAbitmap &= (~(1<<(pBAEntry->TID)));
- pAd->MacTab.Content[Wcid].BARecWcidArray[TID] = 0;
-
- RT28XX_DEL_BA_SESSION_FROM_ASIC(pAd, Wcid, TID);
-
- NdisReleaseSpinLock(&pAd->BATabLock);
-
- }
-
- BATableFreeRecEntry(pAd, Idx);
-}
-
-VOID BASessionTearDownALL(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid)
-{
- int i;
-
- for (i=0; i<NUM_OF_TID; i++)
- {
- BAOriSessionTearDown(pAd, Wcid, i, FALSE, FALSE);
- BARecSessionTearDown(pAd, Wcid, i, FALSE);
- }
-}
-
-
-/*
- ==========================================================================
- Description:
- Retry sending ADDBA Reqest.
-
- IRQL = DISPATCH_LEVEL
-
- Parametrs:
- p8023Header: if this is already 802.3 format, p8023Header is NULL
-
- Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
- FALSE , then continue indicaterx at this moment.
- ==========================================================================
- */
-VOID BAOriSessionSetupTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- BA_ORI_ENTRY *pBAEntry = (BA_ORI_ENTRY *)FunctionContext;
- MAC_TABLE_ENTRY *pEntry;
- PRTMP_ADAPTER pAd;
-
- if (pBAEntry == NULL)
- return;
-
- pAd = pBAEntry->pAdapter;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
-
- if ((pBAEntry->ORI_BA_Status == Originator_WaitRes) && (pBAEntry->Token < ORI_SESSION_MAX_RETRY))
- {
- MLME_ADDBA_REQ_STRUCT AddbaReq;
-
- NdisZeroMemory(&AddbaReq, sizeof(AddbaReq));
- COPY_MAC_ADDR(AddbaReq.pAddr, pEntry->Addr);
- AddbaReq.Wcid = (UCHAR)(pEntry->Aid);
- AddbaReq.TID = pBAEntry->TID;
- AddbaReq.BaBufSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
- AddbaReq.TimeOutValue = 0;
- AddbaReq.Token = pBAEntry->Token;
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ADD_BA_CATE, sizeof(MLME_ADDBA_REQ_STRUCT), (PVOID)&AddbaReq);
- RT28XX_MLME_HANDLER(pAd);
- DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) : Send ADD BA again\n", pBAEntry->Token));
-
- pBAEntry->Token++;
- RTMPSetTimer(&pBAEntry->ORIBATimer, ORI_BA_SESSION_TIMEOUT);
- }
- else
- {
- BATableFreeOriEntry(pAd, pEntry->BAOriWcidArray[pBAEntry->TID]);
- }
-}
-
-/*
- ==========================================================================
- Description:
- Retry sending ADDBA Reqest.
-
- IRQL = DISPATCH_LEVEL
-
- Parametrs:
- p8023Header: if this is already 802.3 format, p8023Header is NULL
-
- Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
- FALSE , then continue indicaterx at this moment.
- ==========================================================================
- */
-VOID BARecSessionIdleTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
-
- BA_REC_ENTRY *pBAEntry = (BA_REC_ENTRY *)FunctionContext;
- PRTMP_ADAPTER pAd;
- ULONG Now32;
-
- if (pBAEntry == NULL)
- return;
-
- if ((pBAEntry->REC_BA_Status == Recipient_Accept))
- {
- NdisGetSystemUpTime(&Now32);
-
- if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer + REC_BA_SESSION_IDLE_TIMEOUT)))
- {
- pAd = pBAEntry->pAdapter;
- // flush all pending reordering mpdus
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- printk("%ld: REC BA session Timeout\n", Now32);
- }
- }
-}
-
-
-VOID PeerAddBAReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- // 7.4.4.1
- //ULONG Idx;
- UCHAR Status = 1;
- UCHAR pAddr[6];
- FRAME_ADDBA_RSP ADDframe;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- PFRAME_ADDBA_REQ pAddreqFrame = NULL;
- //UCHAR BufSize;
- ULONG FrameLen;
- PULONG ptemp;
- PMAC_TABLE_ENTRY pMacEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __func__, Elem->Wcid));
-
- //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen);
-
- //ADDBA Request from unknown peer, ignore this.
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- pMacEntry = &pAd->MacTab.Content[Elem->Wcid];
- DBGPRINT(RT_DEBUG_TRACE,("BA - PeerAddBAReqAction----> \n"));
- ptemp = (PULONG)Elem->Msg;
- //DBGPRINT_RAW(RT_DEBUG_EMU, ("%08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x\n", *(ptemp), *(ptemp+1), *(ptemp+2), *(ptemp+3), *(ptemp+4), *(ptemp+5), *(ptemp+6), *(ptemp+7), *(ptemp+8)));
-
- if (PeerAddBAReqActionSanity(pAd, Elem->Msg, Elem->MsgLen, pAddr))
- {
-
- if ((pAd->CommonCfg.bBADecline == FALSE) && IS_HT_STA(pMacEntry))
- {
- pAddreqFrame = (PFRAME_ADDBA_REQ)(&Elem->Msg[0]);
- printk("Rcv Wcid(%d) AddBAReq\n", Elem->Wcid);
- if (BARecSessionAdd(pAd, &pAd->MacTab.Content[Elem->Wcid], pAddreqFrame))
- Status = 0;
- else
- Status = 38; // more parameters have invalid values
- }
- else
- {
- Status = 37; // the request has been declined.
- }
- }
-
- if (pAd->MacTab.Content[Elem->Wcid].ValidAsCLI)
- ASSERT(pAd->MacTab.Content[Elem->Wcid].Sst == SST_ASSOC);
-
- pAddreqFrame = (PFRAME_ADDBA_REQ)(&Elem->Msg[0]);
- // 2. Always send back ADDBA Response
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - PeerBAAction() allocate memory failed \n"));
- return;
- }
-
- NdisZeroMemory(&ADDframe, sizeof(FRAME_ADDBA_RSP));
- // 2-1. Prepare ADDBA Response frame.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &ADDframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#ifdef QOS_DLS_SUPPORT
- if (pAd->MacTab.Content[Elem->Wcid].ValidAsDls)
- ActHeaderInit(pAd, &ADDframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
-#endif // QOS_DLS_SUPPORT //
- ActHeaderInit(pAd, &ADDframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
- }
-#endif // CONFIG_STA_SUPPORT //
- ADDframe.Category = CATEGORY_BA;
- ADDframe.Action = ADDBA_RESP;
- ADDframe.Token = pAddreqFrame->Token;
- // What is the Status code?? need to check.
- ADDframe.StatusCode = Status;
- ADDframe.BaParm.BAPolicy = IMMED_BA;
- ADDframe.BaParm.AMSDUSupported = 0;
- ADDframe.BaParm.TID = pAddreqFrame->BaParm.TID;
- ADDframe.BaParm.BufSize = min(((UCHAR)pAddreqFrame->BaParm.BufSize), (UCHAR)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
- if (ADDframe.BaParm.BufSize == 0)
- {
- ADDframe.BaParm.BufSize = 64;
- }
- ADDframe.TimeOutValue = 0; //pAddreqFrame->TimeOutValue;
-
- *(USHORT *)(&ADDframe.BaParm) = cpu2le16(*(USHORT *)(&ADDframe.BaParm));
- ADDframe.StatusCode = cpu2le16(ADDframe.StatusCode);
- ADDframe.TimeOutValue = cpu2le16(ADDframe.TimeOutValue);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ADDBA_RSP), &ADDframe,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __func__, Elem->Wcid, ADDframe.BaParm.TID,
- ADDframe.BaParm.BufSize));
-}
-
-
-VOID PeerAddBARspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- //UCHAR Idx, i;
- //PUCHAR pOutBuffer = NULL;
- PFRAME_ADDBA_RSP pFrame = NULL;
- //PBA_ORI_ENTRY pBAEntry;
-
- //ADDBA Response from unknown peer, ignore this.
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __func__, Elem->Wcid));
-
- //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen);
-
- if (PeerAddBARspActionSanity(pAd, Elem->Msg, Elem->MsgLen))
- {
- pFrame = (PFRAME_ADDBA_RSP)(&Elem->Msg[0]);
-
- DBGPRINT(RT_DEBUG_TRACE, ("\t\t StatusCode = %d\n", pFrame->StatusCode));
- switch (pFrame->StatusCode)
- {
- case 0:
- // I want a BAsession with this peer as an originator.
- BAOriSessionAdd(pAd, &pAd->MacTab.Content[Elem->Wcid], pFrame);
- break;
- default:
- // check status == USED ???
- BAOriSessionTearDown(pAd, Elem->Wcid, pFrame->BaParm.TID, TRUE, FALSE);
- break;
- }
- // Rcv Decline StatusCode
- if ((pFrame->StatusCode == 37)
-#ifdef CONFIG_STA_SUPPORT
- || ((pAd->OpMode == OPMODE_STA) && STA_TGN_WIFI_ON(pAd) && (pFrame->StatusCode != 0))
-#endif // CONFIG_STA_SUPPORT //
- )
- {
- pAd->MacTab.Content[Elem->Wcid].BADeclineBitmap |= 1<<pFrame->BaParm.TID;
- }
- }
-}
-
-VOID PeerDelBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- //UCHAR Idx;
- //PUCHAR pOutBuffer = NULL;
- PFRAME_DELBA_REQ pDelFrame = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __func__));
- //DELBA Request from unknown peer, ignore this.
- if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen))
- {
- pDelFrame = (PFRAME_DELBA_REQ)(&Elem->Msg[0]);
- if (pDelFrame->DelbaParm.Initiator == ORIGINATOR)
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - PeerDelBAAction----> ORIGINATOR\n"));
- BARecSessionTearDown(pAd, Elem->Wcid, pDelFrame->DelbaParm.TID, TRUE);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - PeerDelBAAction----> RECIPIENT, Reason = %d\n", pDelFrame->ReasonCode));
- //hex_dump("DelBA Frame", pDelFrame, Elem->MsgLen);
- BAOriSessionTearDown(pAd, Elem->Wcid, pDelFrame->DelbaParm.TID, TRUE, FALSE);
- }
- }
-}
-
-
-BOOLEAN CntlEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG MsgLen,
- IN PFRAME_BA_REQ pMsg)
-{
- PFRAME_BA_REQ pFrame = pMsg;
- //PRTMP_REORDERBUF pBuffer;
- //PRTMP_REORDERBUF pDmaBuf;
- PBA_REC_ENTRY pBAEntry;
- //BOOLEAN Result;
- ULONG Idx;
- //UCHAR NumRxPkt;
- UCHAR TID;//, i;
-
- TID = (UCHAR)pFrame->BARControl.TID;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __func__, Wcid, TID));
- //hex_dump("BAR", (PCHAR) pFrame, MsgLen);
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return FALSE;
-
- // First check the size, it MUST not exceed the mlme queue size
- if (MsgLen > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("CntlEnqueueForRecv: frame too large, size = %ld \n", MsgLen));
- return FALSE;
- }
- else if (MsgLen != sizeof(FRAME_BA_REQ))
- {
- DBGPRINT_ERR(("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
- else if (MsgLen != sizeof(FRAME_BA_REQ))
- {
- DBGPRINT_ERR(("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
-
- if ((Wcid < MAX_LEN_OF_MAC_TABLE) && (TID < 8))
- {
- // if this receiving packet is from SA that is in our OriEntry. Since WCID <9 has direct mapping. no need search.
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- }
- else
- {
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("BAR(%ld) : Tid (%d) - %04x:%04x\n", Wcid, TID, pFrame->BAStartingSeq.field.StartSeq, pBAEntry->LastIndSeq ));
-
- if (SEQ_SMALLER(pBAEntry->LastIndSeq, pFrame->BAStartingSeq.field.StartSeq, MAXSEQ))
- {
- //printk("BAR Seq = %x, LastIndSeq = %x\n", pFrame->BAStartingSeq.field.StartSeq, pBAEntry->LastIndSeq);
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, pFrame->BAStartingSeq.field.StartSeq);
- pBAEntry->LastIndSeq = (pFrame->BAStartingSeq.field.StartSeq == 0) ? MAXSEQ :(pFrame->BAStartingSeq.field.StartSeq -1);
- }
- //ba_refresh_reordering_mpdus(pAd, pBAEntry);
- return TRUE;
-}
-
-/*
-Description : Send PSMP Action frame If PSMP mode switches.
-*/
-VOID SendPSMPAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Psmp)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- //ULONG Idx;
- FRAME_PSMP_ACTION Frame;
- ULONG FrameLen;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
- return;
- }
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[Wcid].Addr);
-#endif // CONFIG_STA_SUPPORT //
-
- Frame.Category = CATEGORY_HT;
- Frame.Action = SMPS_ACTION;
- switch (Psmp)
- {
- case MMPS_ENABLE:
- Frame.Psmp = 0;
- break;
- case MMPS_DYNAMIC:
- Frame.Psmp = 3;
- break;
- case MMPS_STATIC:
- Frame.Psmp = 1;
- break;
- }
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_PSMP_ACTION), &Frame,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_ERROR,("HT - SendPSMPAction( %d ) \n", Frame.Psmp));
-}
-
-
-#define RADIO_MEASUREMENT_REQUEST_ACTION 0
-
-typedef struct PACKED
-{
- UCHAR RegulatoryClass;
- UCHAR ChannelNumber;
- USHORT RandomInterval;
- USHORT MeasurementDuration;
- UCHAR MeasurementMode;
- UCHAR BSSID[MAC_ADDR_LEN];
- UCHAR ReportingCondition;
- UCHAR Threshold;
- UCHAR SSIDIE[2]; // 2 byte
-} BEACON_REQUEST;
-
-typedef struct PACKED
-{
- UCHAR ID;
- UCHAR Length;
- UCHAR Token;
- UCHAR RequestMode;
- UCHAR Type;
-} MEASUREMENT_REQ;
-
-
-
-
-void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PNDIS_PACKET pRxPkt;
- UCHAR Header802_3[LENGTH_802_3];
-
- // 1. get 802.3 Header
- // 2. remove LLC
- // a. pointer pRxBlk->pData to payload
- // b. modify pRxBlk->DataSize
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
- ASSERT(pRxBlk->pRxPacket);
- pRxPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
- RTPKT_TO_OSPKT(pRxPkt)->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- RTPKT_TO_OSPKT(pRxPkt)->data = pRxBlk->pData;
- RTPKT_TO_OSPKT(pRxPkt)->len = pRxBlk->DataSize;
- RTPKT_TO_OSPKT(pRxPkt)->tail = RTPKT_TO_OSPKT(pRxPkt)->data + RTPKT_TO_OSPKT(pRxPkt)->len;
-
- //
- // copy 802.3 header, if necessary
- //
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef LINUX
- NdisMoveMemory(skb_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
-#endif
-#ifdef UCOS
- NdisMoveMemory(net_pkt_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
-#endif
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-}
-
-
-#define INDICATE_LEGACY_OR_AMSDU(_pAd, _pRxBlk, _fromWhichBSSID) \
- do \
- { \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_AMSDU)) \
- { \
- Indicate_AMSDU_Packet(_pAd, _pRxBlk, _fromWhichBSSID); \
- } \
- else if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_EAP)) \
- { \
- Indicate_EAPOL_Packet(_pAd, _pRxBlk, _fromWhichBSSID); \
- } \
- else \
- { \
- Indicate_Legacy_Packet(_pAd, _pRxBlk, _fromWhichBSSID); \
- } \
- } while (0);
-
-
-
-static VOID ba_enqueue_reordering_packet(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- struct reordering_mpdu *mpdu_blk;
- UINT16 Sequence = (UINT16) pRxBlk->pHeader->Sequence;
-
- mpdu_blk = ba_mpdu_blk_alloc(pAd);
- if (mpdu_blk != NULL)
- {
- // Write RxD buffer address & allocated buffer length
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
- mpdu_blk->Sequence = Sequence;
-
- mpdu_blk->bAMSDU = RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU);
-
- convert_reordering_packet_to_preAMSDU_or_802_3_packet(pAd, pRxBlk, FromWhichBSSID);
-
- STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
-
- //
- // it is necessary for reordering packet to record
- // which BSS it come from
- //
- RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
-
- mpdu_blk->pPacket = pRxBlk->pRxPacket;
-
- if (ba_reordering_mpdu_insertsorted(&pBAEntry->list, mpdu_blk) == FALSE)
- {
- // had been already within reordering list
- // don't indicate
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_SUCCESS);
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
-
- ASSERT((0<= pBAEntry->list.qlen) && (pBAEntry->list.qlen <= pBAEntry->BAWinSize));
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
- }
- else
- {
-#if 0
- DBGPRINT(RT_DEBUG_ERROR, ("!!! (%d:%d) Can't allocate reordering mpdu blk\n",
- blk_count, pBAEntry->list.qlen));
-#else
- DBGPRINT(RT_DEBUG_ERROR, ("!!! (%d) Can't allocate reordering mpdu blk\n",
- pBAEntry->list.qlen));
-#endif
- /*
- * flush all pending reordering mpdus
- * and receving mpdu to upper layer
- * make tcp/ip to take care reordering mechanism
- */
- //ba_refresh_reordering_mpdus(pAd, pBAEntry);
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
-
- pBAEntry->LastIndSeq = Sequence;
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- }
-}
-
-
-/*
- ==========================================================================
- Description:
- Indicate this packet to upper layer or put it into reordering buffer
-
- Parametrs:
- pRxBlk : carry necessary packet info 802.11 format
- FromWhichBSSID : the packet received from which BSS
-
- Return :
- none
-
- Note :
- the packet queued into reordering buffer need to cover to 802.3 format
- or pre_AMSDU format
- ==========================================================================
- */
-
-VOID Indicate_AMPDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- USHORT Idx;
- PBA_REC_ENTRY pBAEntry = NULL;
- UINT16 Sequence = pRxBlk->pHeader->Sequence;
- ULONG Now32;
- UCHAR Wcid = pRxBlk->pRxWI->WirelessCliID;
- UCHAR TID = pRxBlk->pRxWI->TID;
-
-
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU) && (pRxBlk->DataSize > MAX_RX_PKT_LEN))
- {
-#if 0 // sample take off, no use
- static int err_size;
-
- err_size++;
- if (err_size > 20) {
- printk("AMPDU DataSize = %d\n", pRxBlk->DataSize);
- hex_dump("802.11 Header", (UCHAR *)pRxBlk->pHeader, 24);
- hex_dump("Payload", pRxBlk->pData, 64);
- err_size = 0;
- }
-#endif
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
-
-#if 0 // test
- /* Rec BA Session had been torn down */
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- return;
-#endif
-
- if (Wcid < MAX_LEN_OF_MAC_TABLE)
- {
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- if (Idx == 0)
- {
- /* Rec BA Session had been torn down */
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- }
- else
- {
- // impossible !!!
- ASSERT(0);
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- ASSERT(pBAEntry);
-
- // update last rx time
- NdisGetSystemUpTime(&Now32);
-
- pBAEntry->rcvSeq = Sequence;
-
-
- ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32);
- pBAEntry->LastIndSeqAtTimer = Now32;
-
- //
- // Reset Last Indicate Sequence
- //
- if (pBAEntry->LastIndSeq == RESET_RCV_SEQ)
- {
- ASSERT((pBAEntry->list.qlen == 0) && (pBAEntry->list.next == NULL));
-
- // reset rcv sequence of BA session
- pBAEntry->LastIndSeq = Sequence;
- pBAEntry->LastIndSeqAtTimer = Now32;
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
-
-
- //
- // I. Check if in order.
- //
- if (SEQ_STEPONE(Sequence, pBAEntry->LastIndSeq, MAXSEQ))
- {
- USHORT LastIndSeq;
-
- pBAEntry->LastIndSeq = Sequence;
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- LastIndSeq = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, pBAEntry->LastIndSeq);
- if (LastIndSeq != RESET_RCV_SEQ)
- {
- pBAEntry->LastIndSeq = LastIndSeq;
- }
- pBAEntry->LastIndSeqAtTimer = Now32;
- }
- //
- // II. Drop Duplicated Packet
- //
- else if (Sequence == pBAEntry->LastIndSeq)
- {
-
- // drop and release packet
- pBAEntry->nDropPacket++;
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- }
- //
- // III. Drop Old Received Packet
- //
- else if (SEQ_SMALLER(Sequence, pBAEntry->LastIndSeq, MAXSEQ))
- {
-
- // drop and release packet
- pBAEntry->nDropPacket++;
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- }
- //
- // IV. Receive Sequence within Window Size
- //
- else if (SEQ_SMALLER(Sequence, (((pBAEntry->LastIndSeq+pBAEntry->BAWinSize+1)) & MAXSEQ), MAXSEQ))
- {
- ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk, FromWhichBSSID);
- }
- //
- // V. Receive seq surpasses Win(lastseq + nMSDU). So refresh all reorder buffer
- //
- else
- {
-#if 0
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
-#else
- LONG WinStartSeq, TmpSeq;
-
-
- TmpSeq = Sequence - (pBAEntry->BAWinSize) -1;
- if (TmpSeq < 0)
- {
- TmpSeq = (MAXSEQ+1) + TmpSeq;
- }
- WinStartSeq = (TmpSeq+1) & MAXSEQ;
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, WinStartSeq);
- pBAEntry->LastIndSeq = WinStartSeq; //TmpSeq;
-
- pBAEntry->LastIndSeqAtTimer = Now32;
-
- ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk, FromWhichBSSID);
-
- TmpSeq = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, pBAEntry->LastIndSeq);
- if (TmpSeq != RESET_RCV_SEQ)
- {
- pBAEntry->LastIndSeq = TmpSeq;
- }
-#endif
- }
-}
-
-#endif // DOT11_N_SUPPORT //
-
+#include "../../rt2860/common/ba_action.c"
diff --git a/drivers/staging/rt2870/common/cmm_data.c b/drivers/staging/rt2870/common/cmm_data.c
index f8e0ebd7bca9..df775c3cf691 100644
--- a/drivers/staging/rt2870/common/cmm_data.c
+++ b/drivers/staging/rt2870/common/cmm_data.c
@@ -1,2731 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-*/
-
-#include "../rt_config.h"
-
-#define MAX_TX_IN_TBTT (16)
-
-
-UCHAR SNAP_802_1H[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
-UCHAR SNAP_BRIDGE_TUNNEL[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
-// Add Cisco Aironet SNAP heade for CCX2 support
-UCHAR SNAP_AIRONET[] = {0xaa, 0xaa, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00};
-UCHAR CKIP_LLC_SNAP[] = {0xaa, 0xaa, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02};
-UCHAR EAPOL_LLC_SNAP[]= {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e};
-UCHAR EAPOL[] = {0x88, 0x8e};
-UCHAR TPID[] = {0x81, 0x00}; /* VLAN related */
-
-UCHAR IPX[] = {0x81, 0x37};
-UCHAR APPLE_TALK[] = {0x80, 0xf3};
-UCHAR RateIdToPlcpSignal[12] = {
- 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec
- 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14
- 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14
-
-UCHAR OfdmSignalToRateId[16] = {
- RATE_54, RATE_54, RATE_54, RATE_54, // OFDM PLCP Signal = 0, 1, 2, 3 respectively
- RATE_54, RATE_54, RATE_54, RATE_54, // OFDM PLCP Signal = 4, 5, 6, 7 respectively
- RATE_48, RATE_24, RATE_12, RATE_6, // OFDM PLCP Signal = 8, 9, 10, 11 respectively
- RATE_54, RATE_36, RATE_18, RATE_9, // OFDM PLCP Signal = 12, 13, 14, 15 respectively
-};
-
-UCHAR OfdmRateToRxwiMCS[12] = {
- 0, 0, 0, 0,
- 0, 1, 2, 3, // OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3
- 4, 5, 6, 7, // OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7
-};
-UCHAR RxwiMCSToOfdmRate[12] = {
- RATE_6, RATE_9, RATE_12, RATE_18,
- RATE_24, RATE_36, RATE_48, RATE_54, // OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3
- 4, 5, 6, 7, // OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7
-};
-
-char* MCSToMbps[] = {"1Mbps","2Mbps","5.5Mbps","11Mbps","06Mbps","09Mbps","12Mbps","18Mbps","24Mbps","36Mbps","48Mbps","54Mbps","MM-0","MM-1","MM-2","MM-3","MM-4","MM-5","MM-6","MM-7","MM-8","MM-9","MM-10","MM-11","MM-12","MM-13","MM-14","MM-15","MM-32","ee1","ee2","ee3"};
-
-UCHAR default_cwmin[]={CW_MIN_IN_BITS, CW_MIN_IN_BITS, CW_MIN_IN_BITS-1, CW_MIN_IN_BITS-2};
-//UCHAR default_cwmax[]={CW_MAX_IN_BITS, CW_MAX_IN_BITS, CW_MIN_IN_BITS, CW_MIN_IN_BITS-1};
-UCHAR default_sta_aifsn[]={3,7,2,2};
-
-UCHAR MapUserPriorityToAccessCategory[8] = {QID_AC_BE, QID_AC_BK, QID_AC_BK, QID_AC_BE, QID_AC_VI, QID_AC_VI, QID_AC_VO, QID_AC_VO};
-
-
-/*
- ========================================================================
-
- Routine Description:
- API for MLME to transmit management frame to AP (BSS Mode)
- or station (IBSS Mode)
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to the outgoing 802.11 frame
- Length Size of outgoing management frame
-
- Return Value:
- NDIS_STATUS_FAILURE
- NDIS_STATUS_PENDING
- NDIS_STATUS_SUCCESS
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS MiniportMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length)
-{
- PNDIS_PACKET pPacket;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- ULONG FreeNum;
- UCHAR IrqState;
- UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
-
- ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
-
- QueIdx=3;
-
- // 2860C use Tx Ring
-
- IrqState = pAd->irq_disabled;
-
- do
- {
- // Reset is in progress, stop immediately
- if ( RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)||
- !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
- {
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- // Check Free priority queue
- // Since we use PBF Queue2 for management frame. Its corresponding DMA ring should be using TxRing.
-
- // 2860C use Tx Ring
- if (pAd->MACVersion == 0x28600100)
- {
- FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
- }
- else
- {
- FreeNum = GET_MGMTRING_FREENO(pAd);
- }
-
- if ((FreeNum > 0))
- {
- // We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870
- NdisZeroMemory(&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE));
- Status = RTMPAllocateNdisPacket(pAd, &pPacket, (PUCHAR)&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE), pData, Length);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_WARN, ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n"));
- break;
- }
-
- //pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- //pAd->CommonCfg.MlmeRate = RATE_2;
-
-
- Status = MlmeHardTransmit(pAd, QueIdx, pPacket);
- if (Status != NDIS_STATUS_SUCCESS)
- RTMPFreeNdisPacket(pAd, pPacket);
- }
- else
- {
- pAd->RalinkCounters.MgmtRingFullCount++;
- DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in MgmtRing, MgmtRingFullCount=%ld!\n",
- QueIdx, pAd->RalinkCounters.MgmtRingFullCount));
- }
-
- } while (FALSE);
-
-
- return Status;
-}
-
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware transmit function
-
- Arguments:
- pAd Pointer to our adapter
- pBuffer Pointer to memory of outgoing frame
- Length Size of outgoing management frame
-
- Return Value:
- NDIS_STATUS_FAILURE
- NDIS_STATUS_PENDING
- NDIS_STATUS_SUCCESS
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS MlmeHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
-#ifdef CARRIER_DETECTION_SUPPORT
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- return NDIS_STATUS_FAILURE;
- }
-
- return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket);
-
-}
-
-
-
-NDIS_STATUS MlmeHardTransmitMgmtRing(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- PHEADER_802_11 pHeader_802_11;
- BOOLEAN bAckRequired, bInsertTimestamp;
- UCHAR MlmeRate;
- PTXWI_STRUC pFirstTxWI;
- MAC_TABLE_ENTRY *pMacEntry = NULL;
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- // Make sure MGMT ring resource won't be used by other threads
-// sample, for IRQ LOCK -> SEM LOCK
-// IrqState = pAd->irq_disabled;
-// if (!IrqState)
- RTMP_SEM_LOCK(&pAd->MgmtRingLock);
-
-
- if (pSrcBufVA == NULL)
- {
- // The buffer shouldn't be NULL
-// if (!IrqState)
- RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
- return NDIS_STATUS_FAILURE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // outgoing frame always wakeup PHY to prevent frame lost
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- AsicForceWakeup(pAd, TRUE);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pFirstTxWI = (PTXWI_STRUC)(pSrcBufVA + TXINFO_SIZE);
- pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE); //TXWI_SIZE);
-
- if (pHeader_802_11->Addr1[0] & 0x01)
- {
- MlmeRate = pAd->CommonCfg.BasicMlmeRate;
- }
- else
- {
- MlmeRate = pAd->CommonCfg.MlmeRate;
- }
-
- // Verify Mlme rate for a / g bands.
- if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6)) // 11A band
- MlmeRate = RATE_6;
-
- if ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
- (pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL))
- {
- pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Fixed W52 with Activity scan issue in ABG_MIXED and ABGN_MIXED mode.
- if (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED
-#ifdef DOT11_N_SUPPORT
- || pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED
-#endif // DOT11_N_SUPPORT //
- )
- {
- if (pAd->LatchRfRegs.Channel > 14)
- pAd->CommonCfg.MlmeTransmit.field.MODE = 1;
- else
- pAd->CommonCfg.MlmeTransmit.field.MODE = 0;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- //
- // Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE)
- // Snice it's been set to 0 while on MgtMacHeaderInit
- // By the way this will cause frame to be send on PWR_SAVE failed.
- //
- // pHeader_802_11->FC.PwrMgmt = 0; // (pAd->StaCfg.Psm == PWR_SAVE);
- //
- // In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
-#ifdef CONFIG_STA_SUPPORT
- // Data-Null packets alse pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD
- if ((pHeader_802_11->FC.Type != BTYPE_DATA) && (pHeader_802_11->FC.Type != BTYPE_CNTL))
- {
- if ((pAd->StaCfg.Psm == PWR_SAVE) &&
- (pHeader_802_11->FC.SubType == SUBTYPE_ACTION))
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- else
- pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- bInsertTimestamp = FALSE;
- if (pHeader_802_11->FC.Type == BTYPE_CNTL) // must be PS-POLL
- {
-#ifdef CONFIG_STA_SUPPORT
- //Set PM bit in ps-poll, to fix WLK 1.2 PowerSaveMode_ext failure issue.
- if ((pAd->OpMode == OPMODE_STA) && (pHeader_802_11->FC.SubType == SUBTYPE_PS_POLL))
- {
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- }
-#endif // CONFIG_STA_SUPPORT //
- bAckRequired = FALSE;
- }
- else // BTYPE_MGMT or BTYPE_DATA(must be NULL frame)
- {
- //pAd->Sequence++;
- //pHeader_802_11->Sequence = pAd->Sequence;
-
- if (pHeader_802_11->Addr1[0] & 0x01) // MULTICAST, BROADCAST
- {
- bAckRequired = FALSE;
- pHeader_802_11->Duration = 0;
- }
- else
- {
- bAckRequired = TRUE;
- pHeader_802_11->Duration = RTMPCalcDuration(pAd, MlmeRate, 14);
- if (pHeader_802_11->FC.SubType == SUBTYPE_PROBE_RSP)
- {
- bInsertTimestamp = TRUE;
- }
- }
- }
-
- pHeader_802_11->Sequence = pAd->Sequence++;
- if (pAd->Sequence >0xfff)
- pAd->Sequence = 0;
-
- // Before radar detection done, mgmt frame can not be sent but probe req
- // Because we need to use probe req to trigger driver to send probe req in passive scan
- if ((pHeader_802_11->FC.SubType != SUBTYPE_PROBE_REQ)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE))
- {
- DBGPRINT(RT_DEBUG_ERROR,("MlmeHardTransmit --> radar detect not in normal mode !!!\n"));
-// if (!IrqState)
- RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
- return (NDIS_STATUS_FAILURE);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader_802_11, DIR_WRITE, FALSE);
-#endif
-
- //
- // fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET
- // should always has only one ohysical buffer, and the whole frame size equals
- // to the first scatter buffer size
- //
-
- // Initialize TX Descriptor
- // For inter-frame gap, the number is for this frame and next frame
- // For MLME rate, we will fix as 2Mb to match other vendor's implement
-// pAd->CommonCfg.MlmeTransmit.field.MODE = 1;
-
-// management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not.
- if (pMacEntry == NULL)
- {
- RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE,
- 0, RESERVED_WCID, (SrcBufLen - TXINFO_SIZE - TXWI_SIZE), PID_MGMT, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
- }
- else
- {
- RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE,
- bInsertTimestamp, FALSE, bAckRequired, FALSE,
- 0, pMacEntry->Aid, (SrcBufLen - TXINFO_SIZE - TXWI_SIZE),
- pMacEntry->MaxHTPhyMode.field.MCS, 0,
- (UCHAR)pMacEntry->MaxHTPhyMode.field.MCS,
- IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pFirstTxWI, TYPE_TXWI);
-#endif
-
- // Now do hardware-depened kick out.
- HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen);
-
- // Make sure to release MGMT ring resource
-// if (!IrqState)
- RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
- return NDIS_STATUS_SUCCESS;
-}
-
-
-/********************************************************************************
-
- New DeQueue Procedures.
-
- ********************************************************************************/
-
-#define DEQUEUE_LOCK(lock, bIntContext, IrqFlags) \
- do{ \
- if (bIntContext == FALSE) \
- RTMP_IRQ_LOCK((lock), IrqFlags); \
- }while(0)
-
-#define DEQUEUE_UNLOCK(lock, bIntContext, IrqFlags) \
- do{ \
- if (bIntContext == FALSE) \
- RTMP_IRQ_UNLOCK((lock), IrqFlags); \
- }while(0)
-
-
-#if 0
-static VOID dumpTxBlk(TX_BLK *pTxBlk)
-{
- NDIS_PACKET *pPacket;
- int i, frameNum;
- PQUEUE_ENTRY pQEntry;
-
- printk("Dump TX_BLK Structure:\n");
- printk("\tTxFrameType=%d!\n", pTxBlk->TxFrameType);
- printk("\tTotalFrameLen=%d\n", pTxBlk->TotalFrameLen);
- printk("\tTotalFrameNum=%ld!\n", pTxBlk->TxPacketList.Number);
- printk("\tTotalFragNum=%d!\n", pTxBlk->TotalFragNum);
- printk("\tpPacketList=\n");
-
- frameNum = pTxBlk->TxPacketList.Number;
-
- for(i=0; i < frameNum; i++)
- { int j;
- UCHAR *pBuf;
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (pPacket)
- {
- pBuf = GET_OS_PKT_DATAPTR(pPacket);
- printk("\t\t[%d]:ptr=0x%x, Len=%d!\n", i, (UINT32)(GET_OS_PKT_DATAPTR(pPacket)), GET_OS_PKT_LEN(pPacket));
- printk("\t\t");
- for (j =0 ; j < GET_OS_PKT_LEN(pPacket); j++)
- {
- printk("%02x ", (pBuf[j] & 0xff));
- if (j == 16)
- break;
- }
- InsertTailQueue(&pTxBlk->TxPacketList, PACKET_TO_QUEUE_ENTRY(pPacket));
- }
- }
- printk("\tWcid=%d!\n", pTxBlk->Wcid);
- printk("\tapidx=%d!\n", pTxBlk->apidx);
- printk("----EndOfDump\n");
-
-}
-#endif
-
-
-/*
- ========================================================================
- Tx Path design algorithm:
- Basically, we divide the packets into four types, Broadcast/Multicast, 11N Rate(AMPDU, AMSDU, Normal), B/G Rate(ARALINK, Normal),
- Specific Packet Type. Following show the classification rule and policy for each kinds of packets.
- Classification Rule=>
- Multicast: (*addr1 & 0x01) == 0x01
- Specific : bDHCPFrame, bARPFrame, bEAPOLFrame, etc.
- 11N Rate : If peer support HT
- (1).AMPDU -- If TXBA is negotiated.
- (2).AMSDU -- If AMSDU is capable for both peer and ourself.
- *). AMSDU can embedded in a AMPDU, but now we didn't support it.
- (3).Normal -- Other packets which send as 11n rate.
-
- B/G Rate : If peer is b/g only.
- (1).ARALINK-- If both of peer/us supprot Ralink proprietary Aggregation and the TxRate is large than RATE_6
- (2).Normal -- Other packets which send as b/g rate.
- Fragment:
- The packet must be unicast, NOT A-RALINK, NOT A-MSDU, NOT 11n, then can consider about fragment.
-
- Classified Packet Handle Rule=>
- Multicast:
- No ACK, //pTxBlk->bAckRequired = FALSE;
- No WMM, //pTxBlk->bWMM = FALSE;
- No piggyback, //pTxBlk->bPiggyBack = FALSE;
- Force LowRate, //pTxBlk->bForceLowRate = TRUE;
- Specific : Basically, for specific packet, we should handle it specifically, but now all specific packets are use
- the same policy to handle it.
- Force LowRate, //pTxBlk->bForceLowRate = TRUE;
-
- 11N Rate :
- No piggyback, //pTxBlk->bPiggyBack = FALSE;
-
- (1).AMSDU
- pTxBlk->bWMM = TRUE;
- (2).AMPDU
- pTxBlk->bWMM = TRUE;
- (3).Normal
-
- B/G Rate :
- (1).ARALINK
-
- (2).Normal
- ========================================================================
-*/
-static UCHAR TxPktClassification(
- IN RTMP_ADAPTER *pAd,
- IN PNDIS_PACKET pPacket)
-{
- UCHAR TxFrameType = TX_UNKOWN_FRAME;
- UCHAR Wcid;
- MAC_TABLE_ENTRY *pMacEntry = NULL;
-#ifdef DOT11_N_SUPPORT
- BOOLEAN bHTRate = FALSE;
-#endif // DOT11_N_SUPPORT //
-
- Wcid = RTMP_GET_PACKET_WCID(pPacket);
- if (Wcid == MCAST_WCID)
- { // Handle for RA is Broadcast/Multicast Address.
- return TX_MCAST_FRAME;
- }
-
- // Handle for unicast packets
- pMacEntry = &pAd->MacTab.Content[Wcid];
- if (RTMP_GET_PACKET_LOWRATE(pPacket))
- { // It's a specific packet need to force low rate, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame
- TxFrameType = TX_LEGACY_FRAME;
- }
-#ifdef DOT11_N_SUPPORT
- else if (IS_HT_RATE(pMacEntry))
- { // it's a 11n capable packet
-
- // Depends on HTPhyMode to check if the peer support the HTRate transmission.
- // Currently didn't support A-MSDU embedded in A-MPDU
- bHTRate = TRUE;
- if (RTMP_GET_PACKET_MOREDATA(pPacket) || (pMacEntry->PsMode == PWR_SAVE))
- TxFrameType = TX_LEGACY_FRAME;
-#ifdef UAPSD_AP_SUPPORT
- else if (RTMP_GET_PACKET_EOSP(pPacket))
- TxFrameType = TX_LEGACY_FRAME;
-#endif // UAPSD_AP_SUPPORT //
- else if((pMacEntry->TXBAbitmap & (1<<(RTMP_GET_PACKET_UP(pPacket)))) != 0)
- return TX_AMPDU_FRAME;
- else if(CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AMSDU_INUSED))
- return TX_AMSDU_FRAME;
- else
- TxFrameType = TX_LEGACY_FRAME;
- }
-#endif // DOT11_N_SUPPORT //
- else
- { // it's a legacy b/g packet.
- if ((CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE) && pAd->CommonCfg.bAggregationCapable) &&
- (RTMP_GET_PACKET_TXRATE(pPacket) >= RATE_6) &&
- (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))))
- { // if peer support Ralink Aggregation, we use it.
- TxFrameType = TX_RALINK_FRAME;
- }
- else
- {
- TxFrameType = TX_LEGACY_FRAME;
- }
- }
-
- // Currently, our fragment only support when a unicast packet send as NOT-ARALINK, NOT-AMSDU and NOT-AMPDU.
- if ((RTMP_GET_PACKET_FRAGMENTS(pPacket) > 1) && (TxFrameType == TX_LEGACY_FRAME))
- TxFrameType = TX_FRAG_FRAME;
-
- return TxFrameType;
-}
-
-
-BOOLEAN RTMP_FillTxBlkInfo(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PACKET_INFO PacketInfo;
- PNDIS_PACKET pPacket;
- PMAC_TABLE_ENTRY pMacEntry = NULL;
-
- pPacket = pTxBlk->pPacket;
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pTxBlk->pSrcBufHeader, &pTxBlk->SrcBufLen);
-
- pTxBlk->Wcid = RTMP_GET_PACKET_WCID(pPacket);
- pTxBlk->apidx = RTMP_GET_PACKET_IF(pPacket);
- pTxBlk->UserPriority = RTMP_GET_PACKET_UP(pPacket);
- pTxBlk->FrameGap = IFS_HTTXOP; // ASIC determine Frame Gap
-
- if (RTMP_GET_PACKET_CLEAR_EAP_FRAME(pTxBlk->pPacket))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bClearEAPFrame);
- else
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bClearEAPFrame);
-
- // Default to clear this flag
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bForceNonQoS);
-
-
- if (pTxBlk->Wcid == MCAST_WCID)
- {
- pTxBlk->pMacEntry = NULL;
- {
-#ifdef MCAST_RATE_SPECIFIC
- PUCHAR pDA = GET_OS_PKT_DATAPTR(pPacket);
- if (((*pDA & 0x01) == 0x01) && (*pDA != 0xff))
- pTxBlk->pTransmit = &pAd->CommonCfg.MCastPhyMode;
- else
-#endif // MCAST_RATE_SPECIFIC //
- pTxBlk->pTransmit = &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
- }
-
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired); // AckRequired = FALSE, when broadcast packet in Adhoc mode.
- //TX_BLK_SET_FLAG(pTxBlk, fTX_bForceLowRate);
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAllowFrag);
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
- if (RTMP_GET_PACKET_MOREDATA(pPacket))
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
- }
-
- }
- else
- {
- pTxBlk->pMacEntry = &pAd->MacTab.Content[pTxBlk->Wcid];
- pTxBlk->pTransmit = &pTxBlk->pMacEntry->HTPhyMode;
-
- pMacEntry = pTxBlk->pMacEntry;
-
-
- // For all unicast packets, need Ack unless the Ack Policy is not set as NORMAL_ACK.
- if (pAd->CommonCfg.AckPolicy[pTxBlk->QueIdx] != NORMAL_ACK)
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);
- else
- TX_BLK_SET_FLAG(pTxBlk, fTX_bAckRequired);
-
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- // If support WMM, enable it.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if (pTxBlk->TxFrameType == TX_LEGACY_FRAME)
- {
- if ( (RTMP_GET_PACKET_LOWRATE(pPacket)) ||
- ((pAd->OpMode == OPMODE_AP) && (pMacEntry->MaxHTPhyMode.field.MODE == MODE_CCK) && (pMacEntry->MaxHTPhyMode.field.MCS == RATE_1)))
- { // Specific packet, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame, need force low rate.
- pTxBlk->pTransmit = &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
-#ifdef DOT11_N_SUPPORT
- // Modify the WMM bit for ICV issue. If we have a packet with EOSP field need to set as 1, how to handle it???
- if (IS_HT_STA(pTxBlk->pMacEntry) &&
- (CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RALINK_CHIPSET)) &&
- ((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RDG_CAPABLE)))
- {
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
- TX_BLK_SET_FLAG(pTxBlk, fTX_bForceNonQoS);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
-#ifdef DOT11_N_SUPPORT
- if ( (IS_HT_RATE(pMacEntry) == FALSE) &&
- (CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE)))
- { // Currently piggy-back only support when peer is operate in b/g mode.
- TX_BLK_SET_FLAG(pTxBlk, fTX_bPiggyBack);
- }
-#endif // DOT11_N_SUPPORT //
-
- if (RTMP_GET_PACKET_MOREDATA(pPacket))
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
- }
-#ifdef UAPSD_AP_SUPPORT
- if (RTMP_GET_PACKET_EOSP(pPacket))
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM_UAPSD_EOSP);
- }
-#endif // UAPSD_AP_SUPPORT //
- }
- else if (pTxBlk->TxFrameType == TX_FRAG_FRAME)
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bAllowFrag);
- }
-
- pMacEntry->DebugTxCount++;
- }
-
- return TRUE;
-}
-
-
-BOOLEAN CanDoAggregateTransmit(
- IN RTMP_ADAPTER *pAd,
- IN NDIS_PACKET *pPacket,
- IN TX_BLK *pTxBlk)
-{
-
- //printk("Check if can do aggregation! TxFrameType=%d!\n", pTxBlk->TxFrameType);
-
- if (RTMP_GET_PACKET_WCID(pPacket) == MCAST_WCID)
- return FALSE;
-
- if (RTMP_GET_PACKET_DHCP(pPacket) ||
- RTMP_GET_PACKET_EAPOL(pPacket) ||
- RTMP_GET_PACKET_WAI(pPacket))
- return FALSE;
-
- if ((pTxBlk->TxFrameType == TX_AMSDU_FRAME) &&
- ((pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))> (RX_BUFFER_AGGRESIZE - 100)))
- { // For AMSDU, allow the packets with total length < max-amsdu size
- return FALSE;
- }
-
- if ((pTxBlk->TxFrameType == TX_RALINK_FRAME) &&
- (pTxBlk->TxPacketList.Number == 2))
- { // For RALINK-Aggregation, allow two frames in one batch.
- return FALSE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- if ((INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA)) // must be unicast to AP
- return TRUE;
- else
-#endif // CONFIG_STA_SUPPORT //
- return FALSE;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- To do the enqueue operation and extract the first item of waiting
- list. If a number of available shared memory segments could meet
- the request of extracted item, the extracted item will be fragmented
- into shared memory segments.
-
- Arguments:
- pAd Pointer to our adapter
- pQueue Pointer to Waiting Queue
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPDeQueuePacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bIntContext,
- IN UCHAR QIdx, /* BulkOutPipeId */
- IN UCHAR Max_Tx_Packets)
-{
- PQUEUE_ENTRY pEntry = NULL;
- PNDIS_PACKET pPacket;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- UCHAR Count=0;
- PQUEUE_HEADER pQueue;
- ULONG FreeNumber[NUM_OF_TX_RING];
- UCHAR QueIdx, sQIdx, eQIdx;
- unsigned long IrqFlags = 0;
- BOOLEAN hasTxDesc = FALSE;
- TX_BLK TxBlk;
- TX_BLK *pTxBlk;
-
-#ifdef DBG_DIAGNOSE
- BOOLEAN firstRound;
- RtmpDiagStruct *pDiagStruct = &pAd->DiagStruct;
-#endif
-
-
- if (QIdx == NUM_OF_TX_RING)
- {
- sQIdx = 0;
- eQIdx = 3; // 4 ACs, start from 0.
- }
- else
- {
- sQIdx = eQIdx = QIdx;
- }
-
- for (QueIdx=sQIdx; QueIdx <= eQIdx; QueIdx++)
- {
- Count=0;
-
- RT28XX_START_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-#ifdef DBG_DIAGNOSE
- firstRound = ((QueIdx == 0) ? TRUE : FALSE);
-#endif // DBG_DIAGNOSE //
-
- while (1)
- {
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
- return;
- }
-
- if (Count >= Max_Tx_Packets)
- break;
-
- DEQUEUE_LOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- if (&pAd->TxSwQueue[QueIdx] == NULL)
- {
-#ifdef DBG_DIAGNOSE
- if (firstRound == TRUE)
- pDiagStruct->TxSWQueCnt[pDiagStruct->ArrayCurIdx][0]++;
-#endif // DBG_DIAGNOSE //
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- break;
- }
-
-
- // probe the Queue Head
- pQueue = &pAd->TxSwQueue[QueIdx];
- if ((pEntry = pQueue->Head) == NULL)
- {
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- break;
- }
-
- pTxBlk = &TxBlk;
- NdisZeroMemory((PUCHAR)pTxBlk, sizeof(TX_BLK));
- //InitializeQueueHeader(&pTxBlk->TxPacketList); // Didn't need it because we already memzero it.
- pTxBlk->QueIdx = QueIdx;
-
- pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
-
- // Early check to make sure we have enoguh Tx Resource.
- hasTxDesc = RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, FreeNumber[QueIdx], pPacket);
- if (!hasTxDesc)
- {
- pAd->PrivateInfo.TxRingFullCnt++;
-
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-
- break;
- }
-
- pTxBlk->TxFrameType = TxPktClassification(pAd, pPacket);
- pEntry = RemoveHeadQueue(pQueue);
- pTxBlk->TotalFrameNum++;
- pTxBlk->TotalFragNum += RTMP_GET_PACKET_FRAGMENTS(pPacket); // The real fragment number maybe vary
- pTxBlk->TotalFrameLen += GET_OS_PKT_LEN(pPacket);
- pTxBlk->pPacket = pPacket;
- InsertTailQueue(&pTxBlk->TxPacketList, PACKET_TO_QUEUE_ENTRY(pPacket));
-
- if (pTxBlk->TxFrameType == TX_RALINK_FRAME || pTxBlk->TxFrameType == TX_AMSDU_FRAME)
- {
- // Enhance SW Aggregation Mechanism
- if (NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, FreeNumber[QueIdx], pTxBlk->TxFrameType))
- {
- InsertHeadQueue(pQueue, PACKET_TO_QUEUE_ENTRY(pPacket));
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- break;
- }
-
- do{
- if((pEntry = pQueue->Head) == NULL)
- break;
-
- // For TX_AMSDU_FRAME/TX_RALINK_FRAME, Need to check if next pakcet can do aggregation.
- pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
- FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
- hasTxDesc = RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, FreeNumber[QueIdx], pPacket);
- if ((hasTxDesc == FALSE) || (CanDoAggregateTransmit(pAd, pPacket, pTxBlk) == FALSE))
- break;
-
- //Remove the packet from the TxSwQueue and insert into pTxBlk
- pEntry = RemoveHeadQueue(pQueue);
- ASSERT(pEntry);
- pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
- pTxBlk->TotalFrameNum++;
- pTxBlk->TotalFragNum += RTMP_GET_PACKET_FRAGMENTS(pPacket); // The real fragment number maybe vary
- pTxBlk->TotalFrameLen += GET_OS_PKT_LEN(pPacket);
- InsertTailQueue(&pTxBlk->TxPacketList, PACKET_TO_QUEUE_ENTRY(pPacket));
- }while(1);
-
- if (pTxBlk->TxPacketList.Number == 1)
- pTxBlk->TxFrameType = TX_LEGACY_FRAME;
- }
-
-#ifdef RT2870
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-#endif // RT2870 //
-
- Count += pTxBlk->TxPacketList.Number;
-
- // Do HardTransmit now.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- Status = STAHardTransmit(pAd, pTxBlk, QueIdx);
-#endif // CONFIG_STA_SUPPORT //
-
-
-#if 0 // We should not break if HardTransmit failed. Well, at least now we should not!
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE /*RT_DEBUG_INFO*/,("RTMPHardTransmit return failed!!!\n"));
- break;
- }
-#endif
- }
-
- RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-#ifdef RT2870
- if (!hasTxDesc)
- RTUSBKickBulkOut(pAd);
-#endif // RT2870 //
-
-#ifdef BLOCK_NET_IF
- if ((pAd->blockQueueTab[QueIdx].SwTxQueueBlockFlag == TRUE)
- && (pAd->TxSwQueue[QueIdx].Number < 1))
- {
- releaseNetIf(&pAd->blockQueueTab[QueIdx]);
- }
-#endif // BLOCK_NET_IF //
-
- }
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculates the duration which is required to transmit out frames
- with given size and specified rate.
-
- Arguments:
- pAd Pointer to our adapter
- Rate Transmit rate
- Size Frame size in units of byte
-
- Return Value:
- Duration number in units of usec
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-USHORT RTMPCalcDuration(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Rate,
- IN ULONG Size)
-{
- ULONG Duration = 0;
-
- if (Rate < RATE_FIRST_OFDM_RATE) // CCK
- {
- if ((Rate > RATE_1) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED))
- Duration = 96; // 72+24 preamble+plcp
- else
- Duration = 192; // 144+48 preamble+plcp
-
- Duration += (USHORT)((Size << 4) / RateIdTo500Kbps[Rate]);
- if ((Size << 4) % RateIdTo500Kbps[Rate])
- Duration ++;
- }
- else if (Rate <= RATE_LAST_OFDM_RATE)// OFDM rates
- {
- Duration = 20 + 6; // 16+4 preamble+plcp + Signal Extension
- Duration += 4 * (USHORT)((11 + Size * 4) / RateIdTo500Kbps[Rate]);
- if ((11 + Size * 4) % RateIdTo500Kbps[Rate])
- Duration += 4;
- }
- else //mimo rate
- {
- Duration = 20 + 6; // 16+4 preamble+plcp + Signal Extension
- }
-
- return (USHORT)Duration;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculates the duration which is required to transmit out frames
- with given size and specified rate.
-
- Arguments:
- pTxWI Pointer to head of each MPDU to HW.
- Ack Setting for Ack requirement bit
- Fragment Setting for Fragment bit
- RetryMode Setting for retry mode
- Ifs Setting for IFS gap
- Rate Setting for transmit rate
- Service Setting for service
- Length Frame length
- TxPreamble Short or Long preamble when using CCK rates
- QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- See also : BASmartHardTransmit() !!!
-
- ========================================================================
-*/
-VOID RTMPWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pOutTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN CFACK,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR TID,
- IN UCHAR TxRate,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING *pTransmit)
-{
- PMAC_TABLE_ENTRY pMac = NULL;
- TXWI_STRUC TxWI;
- PTXWI_STRUC pTxWI;
-
- if (WCID < MAX_LEN_OF_MAC_TABLE)
- pMac = &pAd->MacTab.Content[WCID];
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- NdisZeroMemory(&TxWI, TXWI_SIZE);
- pTxWI = &TxWI;
-
- pTxWI->FRAG= FRAG;
-
- pTxWI->CFACK = CFACK;
- pTxWI->TS= InsTimestamp;
- pTxWI->AMPDU = AMPDU;
- pTxWI->ACK = Ack;
- pTxWI->txop= Txopmode;
-
- pTxWI->NSEQ = NSeq;
- // John tune the performace with Intel Client in 20 MHz performance
-#ifdef DOT11_N_SUPPORT
- BASize = pAd->CommonCfg.TxBASize;
-
- if( BASize >7 )
- BASize =7;
- pTxWI->BAWinSize = BASize;
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->WirelessCliID = WCID;
- pTxWI->MPDUtotalByteCount = Length;
- pTxWI->PacketId = PID;
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
- pTxWI->CFACK = CfAck;
-
-#ifdef DOT11_N_SUPPORT
- if (pMac)
- {
- if (pAd->CommonCfg.bMIMOPSEnable)
- {
- if ((pMac->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
- {
- // Dynamic MIMO Power Save Mode
- pTxWI->MIMOps = 1;
- }
- else if (pMac->MmpsMode == MMPS_STATIC)
- {
- // Static MIMO Power Save Mode
- if (pTransmit->field.MODE >= MODE_HTMIX && pTransmit->field.MCS > 7)
- {
- pTxWI->MCS = 7;
- pTxWI->MIMOps = 0;
- }
- }
- }
- //pTxWI->MIMOps = (pMac->PsMode == PWR_MMPS)? 1:0;
- if (pMac->bIAmBadAtheros && (pMac->WepStatus != Ndis802_11WEPDisabled))
- {
- pTxWI->MpduDensity = 7;
- }
- else
- {
- pTxWI->MpduDensity = pMac->MpduDensity;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->PacketId = pTxWI->MCS;
- NdisMoveMemory(pOutTxWI, &TxWI, sizeof(TXWI_STRUC));
-}
-
-
-VOID RTMPWriteTxWI_Data(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk)
-{
- HTTRANSMIT_SETTING *pTransmit;
- PMAC_TABLE_ENTRY pMacEntry;
-#ifdef DOT11_N_SUPPORT
- UCHAR BASize;
-#endif // DOT11_N_SUPPORT //
-
-
- ASSERT(pTxWI);
-
- pTransmit = pTxBlk->pTransmit;
- pMacEntry = pTxBlk->pMacEntry;
-
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- NdisZeroMemory(pTxWI, TXWI_SIZE);
-
- pTxWI->FRAG = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag);
- pTxWI->ACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired);
- pTxWI->txop = pTxBlk->FrameGap;
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (pMacEntry &&
- (pAd->StaCfg.BssType == BSS_INFRA) &&
- (pMacEntry->ValidAsDls == TRUE))
- pTxWI->WirelessCliID = BSSID_WCID;
- else
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- pTxWI->WirelessCliID = pTxBlk->Wcid;
-
- pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
- pTxWI->CFACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bPiggyBack);
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
- pTxWI->AMPDU = ((pTxBlk->TxFrameType == TX_AMPDU_FRAME) ? TRUE : FALSE);
-
- // John tune the performace with Intel Client in 20 MHz performance
- BASize = pAd->CommonCfg.TxBASize;
- if((pTxBlk->TxFrameType == TX_AMPDU_FRAME) && (pMacEntry))
- {
- UCHAR RABAOriIdx = 0; //The RA's BA Originator table index.
-
- RABAOriIdx = pTxBlk->pMacEntry->BAOriWcidArray[pTxBlk->UserPriority];
- BASize = pAd->BATable.BAOriEntry[RABAOriIdx].BAWinSize;
- }
-
-#if 0 // 3*3
- if (BASize > 7)
- BASize = 7;
-#endif
-
- pTxWI->TxBF = pTransmit->field.TxBF;
- pTxWI->BAWinSize = BASize;
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
-
-#ifdef DOT11_N_SUPPORT
- if (pMacEntry)
- {
- if ((pMacEntry->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
- {
- // Dynamic MIMO Power Save Mode
- pTxWI->MIMOps = 1;
- }
- else if (pMacEntry->MmpsMode == MMPS_STATIC)
- {
- // Static MIMO Power Save Mode
- if (pTransmit->field.MODE >= MODE_HTMIX && pTransmit->field.MCS > 7)
- {
- pTxWI->MCS = 7;
- pTxWI->MIMOps = 0;
- }
- }
-
- if (pMacEntry->bIAmBadAtheros && (pMacEntry->WepStatus != Ndis802_11WEPDisabled))
- {
- pTxWI->MpduDensity = 7;
- }
- else
- {
- pTxWI->MpduDensity = pMacEntry->MpduDensity;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DBG_DIAGNOSE
- if (pTxBlk->QueIdx== 0)
- {
- pAd->DiagStruct.TxDataCnt[pAd->DiagStruct.ArrayCurIdx]++;
- pAd->DiagStruct.TxMcsCnt[pAd->DiagStruct.ArrayCurIdx][pTxWI->MCS]++;
- }
-#endif // DBG_DIAGNOSE //
-
- // for rate adapation
- pTxWI->PacketId = pTxWI->MCS;
-}
-
-
-VOID RTMPWriteTxWI_Cache(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk)
-{
- PHTTRANSMIT_SETTING /*pTxHTPhyMode,*/ pTransmit;
- PMAC_TABLE_ENTRY pMacEntry;
-
- //
- // update TXWI
- //
- pMacEntry = pTxBlk->pMacEntry;
- pTransmit = pTxBlk->pTransmit;
-
- if (pMacEntry->bAutoTxRateSwitch)
- {
- pTxWI->txop = IFS_HTTXOP;
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
-
- // set PID for TxRateSwitching
- pTxWI->PacketId = pTransmit->field.MCS;
- }
-
-#ifdef DOT11_N_SUPPORT
- pTxWI->AMPDU = ((pMacEntry->NoBADataCountDown == 0) ? TRUE: FALSE);
- pTxWI->MIMOps = 0;
-
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
-
- if (pAd->CommonCfg.bMIMOPSEnable)
- {
- // MIMO Power Save Mode
- if ((pMacEntry->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
- {
- // Dynamic MIMO Power Save Mode
- pTxWI->MIMOps = 1;
- }
- else if (pMacEntry->MmpsMode == MMPS_STATIC)
- {
- // Static MIMO Power Save Mode
- if ((pTransmit->field.MODE >= MODE_HTMIX) && (pTransmit->field.MCS > 7))
- {
- pTxWI->MCS = 7;
- pTxWI->MIMOps = 0;
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DBG_DIAGNOSE
- if (pTxBlk->QueIdx== 0)
- {
- pAd->DiagStruct.TxDataCnt[pAd->DiagStruct.ArrayCurIdx]++;
- pAd->DiagStruct.TxMcsCnt[pAd->DiagStruct.ArrayCurIdx][pTxWI->MCS]++;
- }
-#endif // DBG_DIAGNOSE //
-
- pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculates the duration which is required to transmit out frames
- with given size and specified rate.
-
- Arguments:
- pTxD Pointer to transmit descriptor
- Ack Setting for Ack requirement bit
- Fragment Setting for Fragment bit
- RetryMode Setting for retry mode
- Ifs Setting for IFS gap
- Rate Setting for transmit rate
- Service Setting for service
- Length Frame length
- TxPreamble Short or Long preamble when using CCK rates
- QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPWriteTxDescriptor(
- IN PRTMP_ADAPTER pAd,
- IN PTXD_STRUC pTxD,
- IN BOOLEAN bWIV,
- IN UCHAR QueueSEL)
-{
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-
- pTxD->WIV = (bWIV) ? 1: 0;
- pTxD->QSEL= (QueueSEL);
- //RT2860c?? fixed using EDCA queue for test... We doubt Queue1 has problem. 2006-09-26 Jan
- //pTxD->QSEL= FIFO_EDCA;
- if (pAd->bGenOneHCCA == TRUE)
- pTxD->QSEL= FIFO_HCCA;
- pTxD->DMADONE = 0;
-}
-
-
-// should be called only when -
-// 1. MEADIA_CONNECTED
-// 2. AGGREGATION_IN_USED
-// 3. Fragmentation not in used
-// 4. either no previous frame (pPrevAddr1=NULL) .OR. previoud frame is aggregatible
-BOOLEAN TxFrameIsAggregatible(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pPrevAddr1,
- IN PUCHAR p8023hdr)
-{
-
- // can't aggregate EAPOL (802.1x) frame
- if ((p8023hdr[12] == 0x88) && (p8023hdr[13] == 0x8e))
- return FALSE;
-
- // can't aggregate multicast/broadcast frame
- if (p8023hdr[0] & 0x01)
- return FALSE;
-
- if (INFRA_ON(pAd)) // must be unicast to AP
- return TRUE;
- else if ((pPrevAddr1 == NULL) || MAC_ADDR_EQUAL(pPrevAddr1, p8023hdr)) // unicast to same STA
- return TRUE;
- else
- return FALSE;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check the MSDU Aggregation policy
- 1.HT aggregation is A-MSDU
- 2.legaacy rate aggregation is software aggregation by Ralink.
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN PeerIsAggreOn(
- IN PRTMP_ADAPTER pAd,
- IN ULONG TxRate,
- IN PMAC_TABLE_ENTRY pMacEntry)
-{
- ULONG AFlags = (fCLIENT_STATUS_AMSDU_INUSED | fCLIENT_STATUS_AGGREGATION_CAPABLE);
-
- if (pMacEntry != NULL && CLIENT_STATUS_TEST_FLAG(pMacEntry, AFlags))
- {
-#ifdef DOT11_N_SUPPORT
- if (pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
- {
- return TRUE;
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef AGGREGATION_SUPPORT
- if (TxRate >= RATE_6 && pAd->CommonCfg.bAggregationCapable && (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))))
- { // legacy Ralink Aggregation support
- return TRUE;
- }
-#endif // AGGREGATION_SUPPORT //
- }
-
- return FALSE;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check and fine the packet waiting in SW queue with highest priority
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- pQueue Pointer to Waiting Queue
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-PQUEUE_HEADER RTMPCheckTxSwQueue(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pQueIdx)
-{
-
- ULONG Number;
- // 2004-11-15 to be removed. test aggregation only
-// if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)) && (*pNumber < 2))
-// return NULL;
-
- Number = pAd->TxSwQueue[QID_AC_BK].Number
- + pAd->TxSwQueue[QID_AC_BE].Number
- + pAd->TxSwQueue[QID_AC_VI].Number
- + pAd->TxSwQueue[QID_AC_VO].Number
- + pAd->TxSwQueue[QID_HCCA].Number;
-
- if (pAd->TxSwQueue[QID_AC_VO].Head != NULL)
- {
- *pQueIdx = QID_AC_VO;
- return (&pAd->TxSwQueue[QID_AC_VO]);
- }
- else if (pAd->TxSwQueue[QID_AC_VI].Head != NULL)
- {
- *pQueIdx = QID_AC_VI;
- return (&pAd->TxSwQueue[QID_AC_VI]);
- }
- else if (pAd->TxSwQueue[QID_AC_BE].Head != NULL)
- {
- *pQueIdx = QID_AC_BE;
- return (&pAd->TxSwQueue[QID_AC_BE]);
- }
- else if (pAd->TxSwQueue[QID_AC_BK].Head != NULL)
- {
- *pQueIdx = QID_AC_BK;
- return (&pAd->TxSwQueue[QID_AC_BK]);
- }
- else if (pAd->TxSwQueue[QID_HCCA].Head != NULL)
- {
- *pQueIdx = QID_HCCA;
- return (&pAd->TxSwQueue[QID_HCCA]);
- }
-
- // No packet pending in Tx Sw queue
- *pQueIdx = QID_AC_BK;
-
- return (NULL);
-}
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- Suspend MSDU transmission
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPSuspendMsduTransmission(
- IN PRTMP_ADAPTER pAd)
-{
- DBGPRINT(RT_DEBUG_TRACE,("SCANNING, suspend MSDU transmission ...\n"));
-
-
- //
- // Before BSS_SCAN_IN_PROGRESS, we need to keep Current R66 value and
- // use Lowbound as R66 value on ScanNextChannel(...)
- //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
-
- // set BBP_R66 to 0x30/0x40 when scanning (AsicSwitchChannel will set R66 according to channel when scanning)
- //RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x26 + GET_LNA_GAIN(pAd)));
- RTMPSetAGCInitValue(pAd, BW_20);
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- //RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x000f0000); // abort all TX rings
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Resume MSDU transmission
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPResumeMsduTransmission(
- IN PRTMP_ADAPTER pAd)
-{
-// UCHAR IrqState;
-
- DBGPRINT(RT_DEBUG_TRACE,("SCAN done, resume MSDU transmission ...\n"));
-
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, pAd->BbpTuning.R66CurrentValue);
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-// sample, for IRQ LOCK to SEM LOCK
-// IrqState = pAd->irq_disabled;
-// if (IrqState)
-// RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-// else
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-}
-
-
-UINT deaggregate_AMSDU_announce(
- IN PRTMP_ADAPTER pAd,
- PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize)
-{
- USHORT PayloadSize;
- USHORT SubFrameSize;
- PHEADER_802_3 pAMSDUsubheader;
- UINT nMSDU;
- UCHAR Header802_3[14];
-
- PUCHAR pPayload, pDA, pSA, pRemovedLLCSNAP;
- PNDIS_PACKET pClonePacket;
-
-
-
- nMSDU = 0;
-
- while (DataSize > LENGTH_802_3)
- {
-
- nMSDU++;
-
- //hex_dump("subheader", pData, 64);
- pAMSDUsubheader = (PHEADER_802_3)pData;
- //pData += LENGTH_802_3;
- PayloadSize = pAMSDUsubheader->Octet[1] + (pAMSDUsubheader->Octet[0]<<8);
- SubFrameSize = PayloadSize + LENGTH_802_3;
-
-
- if ((DataSize < SubFrameSize) || (PayloadSize > 1518 ))
- {
- break;
- }
-
- //printk("%d subframe: Size = %d\n", nMSDU, PayloadSize);
-
- pPayload = pData + LENGTH_802_3;
- pDA = pData;
- pSA = pData + MAC_ADDR_LEN;
-
- // convert to 802.3 header
- CONVERT_TO_802_3(Header802_3, pDA, pSA, pPayload, PayloadSize, pRemovedLLCSNAP);
-
-#ifdef CONFIG_STA_SUPPORT
- if ((Header802_3[12] == 0x88) && (Header802_3[13] == 0x8E) )
- {
- // avoid local heap overflow, use dyanamic allocation
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
- memmove(Elem->Msg+(LENGTH_802_11 + LENGTH_802_1_H), pPayload, PayloadSize);
- Elem->MsgLen = LENGTH_802_11 + LENGTH_802_1_H + PayloadSize;
- WpaEAPOLKeyAction(pAd, Elem);
- kfree(Elem);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pRemovedLLCSNAP)
- {
- pPayload -= LENGTH_802_3;
- PayloadSize += LENGTH_802_3;
- NdisMoveMemory(pPayload, &Header802_3[0], LENGTH_802_3);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pClonePacket = ClonePacket(pAd, pPacket, pPayload, PayloadSize);
- if (pClonePacket)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pClonePacket, RTMP_GET_PACKET_IF(pPacket));
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- // A-MSDU has padding to multiple of 4 including subframe header.
- // align SubFrameSize up to multiple of 4
- SubFrameSize = (SubFrameSize+3)&(~0x3);
-
-
- if (SubFrameSize > 1528 || SubFrameSize < 32)
- {
- break;
- }
-
- if (DataSize > SubFrameSize)
- {
- pData += SubFrameSize;
- DataSize -= SubFrameSize;
- }
- else
- {
- // end of A-MSDU
- DataSize = 0;
- }
- }
-
- // finally release original rx packet
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
-
- return nMSDU;
-}
-
-
-UINT BA_Reorder_AMSDU_Annnounce(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PUCHAR pData;
- USHORT DataSize;
- UINT nMSDU = 0;
-
- pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
- DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
-
- nMSDU = deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
-
- return nMSDU;
-}
-
-
-/*
- ==========================================================================
- Description:
- Look up the MAC address in the MAC table. Return NULL if not found.
- Return:
- pEntry - pointer to the MAC entry; NULL is not found
- ==========================================================================
-*/
-MAC_TABLE_ENTRY *MacTableLookup(
- IN PRTMP_ADAPTER pAd,
- PUCHAR pAddr)
-{
- ULONG HashIdx;
- MAC_TABLE_ENTRY *pEntry = NULL;
-
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- pEntry = pAd->MacTab.Hash[HashIdx];
-
- while (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsWDS || pEntry->ValidAsApCli || pEntry->ValidAsMesh))
- {
- if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
- break;
- }
- else
- pEntry = pEntry->pNext;
- }
-
- return pEntry;
-}
-
-MAC_TABLE_ENTRY *MacTableInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR apidx,
- IN BOOLEAN CleanAll)
-{
- UCHAR HashIdx;
- int i, FirstWcid;
- MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
-
- // if FULL, return
- if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
- return NULL;
-
- FirstWcid = 1;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- if (pAd->StaCfg.BssType == BSS_INFRA)
- FirstWcid = 2;
-#endif // CONFIG_STA_SUPPORT //
-
- // allocate one MAC entry
- NdisAcquireSpinLock(&pAd->MacTabLock);
- for (i = FirstWcid; i< MAX_LEN_OF_MAC_TABLE; i++) // skip entry#0 so that "entry index == AID" for fast lookup
- {
- // pick up the first available vacancy
- if ((pAd->MacTab.Content[i].ValidAsCLI == FALSE) &&
- (pAd->MacTab.Content[i].ValidAsWDS == FALSE) &&
- (pAd->MacTab.Content[i].ValidAsApCli== FALSE) &&
- (pAd->MacTab.Content[i].ValidAsMesh == FALSE)
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- && (pAd->MacTab.Content[i].ValidAsDls == FALSE)
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- )
- {
- pEntry = &pAd->MacTab.Content[i];
- if (CleanAll == TRUE)
- {
- pEntry->MaxSupportedRate = RATE_11;
- pEntry->CurrTxRate = RATE_11;
- NdisZeroMemory(pEntry, sizeof(MAC_TABLE_ENTRY));
- pEntry->PairwiseKey.KeyLen = 0;
- pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
- }
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (apidx >= MIN_NET_DEVICE_FOR_DLS)
- {
- pEntry->ValidAsCLI = FALSE;
- pEntry->ValidAsWDS = FALSE;
- pEntry->ValidAsApCli = FALSE;
- pEntry->ValidAsMesh = FALSE;
- pEntry->ValidAsDls = TRUE;
- pEntry->isCached = FALSE;
- }
- else
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pEntry->ValidAsCLI = TRUE;
- pEntry->ValidAsWDS = FALSE;
- pEntry->ValidAsApCli = FALSE;
- pEntry->ValidAsMesh = FALSE;
- pEntry->ValidAsDls = FALSE;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- pEntry->bIAmBadAtheros = FALSE;
- pEntry->pAd = pAd;
- pEntry->CMTimerRunning = FALSE;
- pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
- pEntry->RSNIE_Len = 0;
- NdisZeroMemory(pEntry->R_Counter, sizeof(pEntry->R_Counter));
- pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
-
- if (pEntry->ValidAsMesh)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_MESH);
- else if (pEntry->ValidAsApCli)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_APCLI);
- else if (pEntry->ValidAsWDS)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_WDS);
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- else if (pEntry->ValidAsDls)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_DLS);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- else
- pEntry->apidx = apidx;
-
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
- pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- pEntry->GTKState = REKEY_NEGOTIATING;
- pEntry->PairwiseKey.KeyLen = 0;
- pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (pEntry->ValidAsDls == TRUE)
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-#endif //QOS_DLS_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND;
- COPY_MAC_ADDR(pEntry->Addr, pAddr);
- pEntry->Sst = SST_NOT_AUTH;
- pEntry->AuthState = AS_NOT_AUTH;
- pEntry->Aid = (USHORT)i; //0;
- pEntry->CapabilityInfo = 0;
- pEntry->PsMode = PWR_ACTIVE;
- pEntry->PsQIdleCount = 0;
- pEntry->NoDataIdleCount = 0;
- pEntry->ContinueTxFailCnt = 0;
- InitializeQueueHeader(&pEntry->PsQueue);
-
-
- pAd->MacTab.Size ++;
- // Add this entry into ASIC RX WCID search table
- RT28XX_STA_ENTRY_ADD(pAd, pEntry);
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertEntry - allocate entry #%d, Total= %d\n",i, pAd->MacTab.Size));
- break;
- }
- }
-
- // add this MAC entry into HASH table
- if (pEntry)
- {
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- if (pAd->MacTab.Hash[HashIdx] == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pAd->MacTab.Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
-
- NdisReleaseSpinLock(&pAd->MacTabLock);
- return pEntry;
-}
-
-/*
- ==========================================================================
- Description:
- Delete a specified client from MAC table
- ==========================================================================
- */
-BOOLEAN MacTableDeleteEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr)
-{
- USHORT HashIdx;
- MAC_TABLE_ENTRY *pEntry, *pPrevEntry, *pProbeEntry;
- BOOLEAN Cancelled;
- //USHORT offset; // unused variable
- //UCHAR j; // unused variable
-
- if (wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
-
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- //pEntry = pAd->MacTab.Hash[HashIdx];
- pEntry = &pAd->MacTab.Content[wcid];
-
- if (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsApCli || pEntry->ValidAsWDS || pEntry->ValidAsMesh
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- || pEntry->ValidAsDls
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- ))
- {
- if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
-
- // Delete this entry from ASIC on-chip WCID Table
- RT28XX_STA_ENTRY_MAC_RESET(pAd, wcid);
-
-#ifdef DOT11_N_SUPPORT
- // free resources of BA
- BASessionTearDownALL(pAd, pEntry->Aid);
-#endif // DOT11_N_SUPPORT //
-
-
- pPrevEntry = NULL;
- pProbeEntry = pAd->MacTab.Hash[HashIdx];
- ASSERT(pProbeEntry);
-
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- // not found !!!
- ASSERT(pProbeEntry != NULL);
-
- RT28XX_STA_ENTRY_KEY_DEL(pAd, BSS0, wcid);
-
-
- if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
- {
- RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
- pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
- }
-
-
- NdisZeroMemory(pEntry, sizeof(MAC_TABLE_ENTRY));
- pAd->MacTab.Size --;
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableDeleteEntry1 - Total= %d\n", pAd->MacTab.Size));
- }
- else
- {
- printk("\n%s: Impossible Wcid = %d !!!!!\n", __func__, wcid);
- }
- }
-
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- //Reset operating mode when no Sta.
- if (pAd->MacTab.Size == 0)
- {
-#ifdef DOT11_N_SUPPORT
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode = 0;
-#endif // DOT11_N_SUPPORT //
- AsicUpdateProtect(pAd, 0 /*pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode*/, (ALLN_SETPROTECT), TRUE, 0 /*pAd->MacTab.fAnyStationNonGF*/);
- }
-
- return TRUE;
-}
-
-
-/*
- ==========================================================================
- Description:
- This routine reset the entire MAC table. All packets pending in
- the power-saving queues are freed here.
- ==========================================================================
- */
-VOID MacTableReset(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableReset\n"));
- //NdisAcquireSpinLock(&pAd->MacTabLock);
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
- {
-
-#ifdef DOT11_N_SUPPORT
- // free resources of BA
- BASessionTearDownALL(pAd, i);
-#endif // DOT11_N_SUPPORT //
-
- pAd->MacTab.Content[i].ValidAsCLI = FALSE;
-
-
-
-#ifdef RT2870
- NdisZeroMemory(pAd->MacTab.Content[i].Addr, 6);
- RT28XX_STA_ENTRY_MAC_RESET(pAd, i);
-#endif // RT2870 //
-
- //AsicDelWcidTab(pAd, i);
- }
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID AssocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
- IN PUCHAR pAddr,
- IN USHORT CapabilityInfo,
- IN ULONG Timeout,
- IN USHORT ListenIntv)
-{
- COPY_MAC_ADDR(AssocReq->Addr, pAddr);
- // Add mask to support 802.11b mode only
- AssocReq->CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO; // not cf-pollable, not cf-poll-request
- AssocReq->Timeout = Timeout;
- AssocReq->ListenIntv = ListenIntv;
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID DisassocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
- IN PUCHAR pAddr,
- IN USHORT Reason)
-{
- COPY_MAC_ADDR(DisassocReq->Addr, pAddr);
- DisassocReq->Reason = Reason;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check the out going frame, if this is an DHCP or ARP datagram
- will be duplicate another frame at low data rate transmit.
-
- Arguments:
- pAd Pointer to our adapter
- pPacket Pointer to outgoing Ndis frame
-
- Return Value:
- TRUE To be duplicate at Low data rate transmit. (1mb)
- FALSE Do nothing.
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- MAC header + IP Header + UDP Header
- 14 Bytes 20 Bytes
-
- UDP Header
- 00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|
- Source Port
- 16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
- Destination Port
-
- port 0x43 means Bootstrap Protocol, server.
- Port 0x44 means Bootstrap Protocol, client.
-
- ========================================================================
-*/
-
-BOOLEAN RTMPCheckDHCPFrame(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- ULONG NumberOfBytesRead = 0;
- ULONG CurrentOffset = 0;
- PVOID pVirtualAddress = NULL;
- UINT NdisBufferLength;
- PUCHAR pSrc;
- USHORT Protocol;
- UCHAR ByteOffset36 = 0;
- UCHAR ByteOffset38 = 0;
- BOOLEAN ReadFirstParm = TRUE;
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, (PUCHAR *)&pVirtualAddress, &NdisBufferLength);
-
- NumberOfBytesRead += NdisBufferLength;
- pSrc = (PUCHAR) pVirtualAddress;
- Protocol = *(pSrc + 12) * 256 + *(pSrc + 13);
-
- //
- // Check DHCP & BOOTP protocol
- //
- while (NumberOfBytesRead <= PacketInfo.TotalPacketLength)
- {
- if ((NumberOfBytesRead >= 35) && (ReadFirstParm == TRUE))
- {
- CurrentOffset = 35 - (NumberOfBytesRead - NdisBufferLength);
- ByteOffset36 = *(pSrc + CurrentOffset);
- ReadFirstParm = FALSE;
- }
-
- if (NumberOfBytesRead >= 37)
- {
- CurrentOffset = 37 - (NumberOfBytesRead - NdisBufferLength);
- ByteOffset38 = *(pSrc + CurrentOffset);
- //End of Read
- break;
- }
- return FALSE;
- }
-
- // Check for DHCP & BOOTP protocol
- if ((ByteOffset36 != 0x44) || (ByteOffset38 != 0x43))
- {
- //
- // 2054 (hex 0806) for ARP datagrams
- // if this packet is not ARP datagrams, then do nothing
- // ARP datagrams will also be duplicate at 1mb broadcast frames
- //
- if (Protocol != 0x0806 )
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-BOOLEAN RTMPCheckEtherType(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- USHORT TypeLen;
- UCHAR Byte0, Byte1;
- PUCHAR pSrcBuf;
- UINT32 pktLen;
- UINT16 srcPort, dstPort;
- BOOLEAN status = TRUE;
-
-
- pSrcBuf = GET_OS_PKT_DATAPTR(pPacket);
- pktLen = GET_OS_PKT_LEN(pPacket);
-
- ASSERT(pSrcBuf);
-
- RTMP_SET_PACKET_SPECIFIC(pPacket, 0);
-
- // get Ethernet protocol field
- TypeLen = (pSrcBuf[12] << 8) + pSrcBuf[13];
-
- pSrcBuf += LENGTH_802_3; // Skip the Ethernet Header.
-
- if (TypeLen <= 1500)
- { // 802.3, 802.3 LLC
- /*
- DestMAC(6) + SrcMAC(6) + Lenght(2) +
- DSAP(1) + SSAP(1) + Control(1) +
- if the DSAP = 0xAA, SSAP=0xAA, Contorl = 0x03, it has a 5-bytes SNAP header.
- => + SNAP (5, OriginationID(3) + etherType(2))
- */
- if (pSrcBuf[0] == 0xAA && pSrcBuf[1] == 0xAA && pSrcBuf[2] == 0x03)
- {
- Sniff2BytesFromNdisBuffer(pSrcBuf, 6, &Byte0, &Byte1);
- RTMP_SET_PACKET_LLCSNAP(pPacket, 1);
- TypeLen = (USHORT)((Byte0 << 8) + Byte1);
- pSrcBuf += 8; // Skip this LLC/SNAP header
- }
- else
- {
- //It just has 3-byte LLC header, maybe a legacy ether type frame. we didn't handle it.
- }
- }
-
- // If it's a VLAN packet, get the real Type/Length field.
- if (TypeLen == 0x8100)
- {
- /* 0x8100 means VLAN packets */
-
- /* Dest. MAC Address (6-bytes) +
- Source MAC Address (6-bytes) +
- Length/Type = 802.1Q Tag Type (2-byte) +
- Tag Control Information (2-bytes) +
- Length / Type (2-bytes) +
- data payload (0-n bytes) +
- Pad (0-p bytes) +
- Frame Check Sequence (4-bytes) */
-
- RTMP_SET_PACKET_VLAN(pPacket, 1);
- Sniff2BytesFromNdisBuffer(pSrcBuf, 2, &Byte0, &Byte1);
- TypeLen = (USHORT)((Byte0 << 8) + Byte1);
-
- pSrcBuf += 4; // Skip the VLAN Header.
- }
-
- switch (TypeLen)
- {
- case 0x0800:
- {
- ASSERT((pktLen > 34));
- if (*(pSrcBuf + 9) == 0x11)
- { // udp packet
- ASSERT((pktLen > 34)); // 14 for ethernet header, 20 for IP header
-
- pSrcBuf += 20; // Skip the IP header
- srcPort = OS_NTOHS(*((UINT16 *)pSrcBuf));
- dstPort = OS_NTOHS(*((UINT16 *)(pSrcBuf +2)));
-
- if ((srcPort==0x44 && dstPort==0x43) || (srcPort==0x43 && dstPort==0x44))
- { //It's a BOOTP/DHCP packet
- RTMP_SET_PACKET_DHCP(pPacket, 1);
- }
- }
- }
- break;
- case 0x0806:
- {
- //ARP Packet.
- RTMP_SET_PACKET_DHCP(pPacket, 1);
- }
- break;
- case 0x888e:
- {
- // EAPOL Packet.
- RTMP_SET_PACKET_EAPOL(pPacket, 1);
- }
- break;
- default:
- status = FALSE;
- break;
- }
-
- return status;
-
-}
-
-
-
-VOID Update_Rssi_Sample(
- IN PRTMP_ADAPTER pAd,
- IN RSSI_SAMPLE *pRssi,
- IN PRXWI_STRUC pRxWI)
- {
- CHAR rssi0 = pRxWI->RSSI0;
- CHAR rssi1 = pRxWI->RSSI1;
- CHAR rssi2 = pRxWI->RSSI2;
-
- if (rssi0 != 0)
- {
- pRssi->LastRssi0 = ConvertToRssi(pAd, (CHAR)rssi0, RSSI_0);
- pRssi->AvgRssi0X8 = (pRssi->AvgRssi0X8 - pRssi->AvgRssi0) + pRssi->LastRssi0;
- pRssi->AvgRssi0 = pRssi->AvgRssi0X8 >> 3;
- }
-
- if (rssi1 != 0)
- {
- pRssi->LastRssi1 = ConvertToRssi(pAd, (CHAR)rssi1, RSSI_1);
- pRssi->AvgRssi1X8 = (pRssi->AvgRssi1X8 - pRssi->AvgRssi1) + pRssi->LastRssi1;
- pRssi->AvgRssi1 = pRssi->AvgRssi1X8 >> 3;
- }
-
- if (rssi2 != 0)
- {
- pRssi->LastRssi2 = ConvertToRssi(pAd, (CHAR)rssi2, RSSI_2);
- pRssi->AvgRssi2X8 = (pRssi->AvgRssi2X8 - pRssi->AvgRssi2) + pRssi->LastRssi2;
- pRssi->AvgRssi2 = pRssi->AvgRssi2X8 >> 3;
- }
-}
-
-
-
-// Normal legacy Rx packet indication
-VOID Indicate_Legacy_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- UCHAR Header802_3[LENGTH_802_3];
-
- // 1. get 802.3 Header
- // 2. remove LLC
- // a. pointer pRxBlk->pData to payload
- // b. modify pRxBlk->DataSize
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
- if (pRxBlk->DataSize > MAX_RX_PKT_LEN)
- {
-#if 0 // sample take off, for multiple card design
- static int err_size;
-
- err_size++;
- if (err_size > 20)
- {
- printk("Legacy DataSize = %d\n", pRxBlk->DataSize);
- hex_dump("802.3 Header", Header802_3, LENGTH_802_3);
- hex_dump("Payload", pRxBlk->pData, 64);
- err_size = 0;
- }
-#endif
-
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
-
- STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
-
-#ifdef RT2870
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.bDisableReordering == 0)
- {
- PBA_REC_ENTRY pBAEntry;
- ULONG Now32;
- UCHAR Wcid = pRxBlk->pRxWI->WirelessCliID;
- UCHAR TID = pRxBlk->pRxWI->TID;
- USHORT Idx;
-
-#define REORDERING_PACKET_TIMEOUT ((100 * HZ)/1000) // system ticks -- 100 ms
-
- if (Wcid < MAX_LEN_OF_MAC_TABLE)
- {
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- if (Idx != 0)
- {
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- // update last rx time
- NdisGetSystemUpTime(&Now32);
- if ((pBAEntry->list.qlen > 0) &&
- RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(REORDERING_PACKET_TIMEOUT)))
- )
- {
- printk("Indicate_Legacy_Packet():flush reordering_timeout_mpdus! RxWI->Flags=%d, pRxWI.TID=%d, RxD->AMPDU=%d!\n", pRxBlk->Flags, pRxBlk->pRxWI->TID, pRxBlk->RxD.AMPDU);
- hex_dump("Dump the legacy Packet:", GET_OS_PKT_DATAPTR(pRxBlk->pRxPacket), 64);
- ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32);
- }
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-#endif // RT2870 //
-
- wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-
- //
- // pass this 802.3 packet to upper layer or forward this packet to WM directly
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxPacket, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-
-// Normal, AMPDU or AMSDU
-VOID CmmRxnonRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
-#ifdef DOT11_N_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
- {
- Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
-#ifdef DOT11_N_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
- {
- // handle A-MSDU
- Indicate_AMSDU_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- }
-}
-
-
-VOID CmmRxRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- UCHAR Header802_3[LENGTH_802_3];
- UINT16 Msdu2Size;
- UINT16 Payload1Size, Payload2Size;
- PUCHAR pData2;
- PNDIS_PACKET pPacket2 = NULL;
-
-
-
- Msdu2Size = *(pRxBlk->pData) + (*(pRxBlk->pData+1) << 8);
-
- if ((Msdu2Size <= 1536) && (Msdu2Size < pRxBlk->DataSize))
- {
- /* skip two byte MSDU2 len */
- pRxBlk->pData += 2;
- pRxBlk->DataSize -= 2;
- }
- else
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // get 802.3 Header and remove LLC
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
-
- ASSERT(pRxBlk->pRxPacket);
-
- // Ralink Aggregation frame
- pAd->RalinkCounters.OneSecRxAggregationCount ++;
- Payload1Size = pRxBlk->DataSize - Msdu2Size;
- Payload2Size = Msdu2Size - LENGTH_802_3;
-
- pData2 = pRxBlk->pData + Payload1Size + LENGTH_802_3;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pPacket2 = duplicate_pkt(pAd, (pData2-LENGTH_802_3), LENGTH_802_3, pData2, Payload2Size, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
- if (!pPacket2)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // update payload size of 1st packet
- pRxBlk->DataSize = Payload1Size;
- wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxBlk->pRxPacket, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
- if (pPacket2)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket2, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
- }
-}
-
-
-#define RESET_FRAGFRAME(_fragFrame) \
- { \
- _fragFrame.RxSize = 0; \
- _fragFrame.Sequence = 0; \
- _fragFrame.LastFrag = 0; \
- _fragFrame.Flags = 0; \
- }
-
-
-PNDIS_PACKET RTMPDeFragmentDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- UCHAR *pData = pRxBlk->pData;
- USHORT DataSize = pRxBlk->DataSize;
- PNDIS_PACKET pRetPacket = NULL;
- UCHAR *pFragBuffer = NULL;
- BOOLEAN bReassDone = FALSE;
- UCHAR HeaderRoom = 0;
-
-
- ASSERT(pHeader);
-
- HeaderRoom = pData - (UCHAR *)pHeader;
-
- // Re-assemble the fragmented packets
- if (pHeader->Frag == 0) // Frag. Number is 0 : First frag or only one pkt
- {
- // the first pkt of fragment, record it.
- if (pHeader->FC.MoreFrag)
- {
- ASSERT(pAd->FragFrame.pFragPacket);
- pFragBuffer = GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
- pAd->FragFrame.RxSize = DataSize + HeaderRoom;
- NdisMoveMemory(pFragBuffer, pHeader, pAd->FragFrame.RxSize);
- pAd->FragFrame.Sequence = pHeader->Sequence;
- pAd->FragFrame.LastFrag = pHeader->Frag; // Should be 0
- ASSERT(pAd->FragFrame.LastFrag == 0);
- goto done; // end of processing this frame
- }
- }
- else //Middle & End of fragment
- {
- if ((pHeader->Sequence != pAd->FragFrame.Sequence) ||
- (pHeader->Frag != (pAd->FragFrame.LastFrag + 1)))
- {
- // Fragment is not the same sequence or out of fragment number order
- // Reset Fragment control blk
- RESET_FRAGFRAME(pAd->FragFrame);
- DBGPRINT(RT_DEBUG_ERROR, ("Fragment is not the same sequence or out of fragment number order.\n"));
- goto done; // give up this frame
- }
- else if ((pAd->FragFrame.RxSize + DataSize) > MAX_FRAME_SIZE)
- {
- // Fragment frame is too large, it exeeds the maximum frame size.
- // Reset Fragment control blk
- RESET_FRAGFRAME(pAd->FragFrame);
- DBGPRINT(RT_DEBUG_ERROR, ("Fragment frame is too large, it exeeds the maximum frame size.\n"));
- goto done; // give up this frame
- }
-
- //
- // Broadcom AP(BCM94704AGR) will send out LLC in fragment's packet, LLC only can accpet at first fragment.
- // In this case, we will dropt it.
- //
- if (NdisEqualMemory(pData, SNAP_802_1H, sizeof(SNAP_802_1H)))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Find another LLC at Middle or End fragment(SN=%d, Frag=%d)\n", pHeader->Sequence, pHeader->Frag));
- goto done; // give up this frame
- }
-
- pFragBuffer = GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
-
- // concatenate this fragment into the re-assembly buffer
- NdisMoveMemory((pFragBuffer + pAd->FragFrame.RxSize), pData, DataSize);
- pAd->FragFrame.RxSize += DataSize;
- pAd->FragFrame.LastFrag = pHeader->Frag; // Update fragment number
-
- // Last fragment
- if (pHeader->FC.MoreFrag == FALSE)
- {
- bReassDone = TRUE;
- }
- }
-
-done:
- // always release rx fragmented packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-
- // return defragmented packet if packet is reassembled completely
- // otherwise return NULL
- if (bReassDone)
- {
- PNDIS_PACKET pNewFragPacket;
-
- // allocate a new packet buffer for fragment
- pNewFragPacket = RTMP_AllocateFragPacketBuffer(pAd, RX_BUFFER_NORMSIZE);
- if (pNewFragPacket)
- {
- // update RxBlk
- pRetPacket = pAd->FragFrame.pFragPacket;
- pAd->FragFrame.pFragPacket = pNewFragPacket;
- pRxBlk->pHeader = (PHEADER_802_11) GET_OS_PKT_DATAPTR(pRetPacket);
- pRxBlk->pData = (UCHAR *)pRxBlk->pHeader + HeaderRoom;
- pRxBlk->DataSize = pAd->FragFrame.RxSize - HeaderRoom;
- pRxBlk->pRxPacket = pRetPacket;
- }
- else
- {
- RESET_FRAGFRAME(pAd->FragFrame);
- }
- }
-
- return pRetPacket;
-}
-
-
-VOID Indicate_AMSDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- UINT nMSDU;
-
- update_os_packet_info(pAd, pRxBlk, FromWhichBSSID);
- RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
- nMSDU = deaggregate_AMSDU_announce(pAd, pRxBlk->pRxPacket, pRxBlk->pData, pRxBlk->DataSize);
-}
-
-VOID Indicate_EAPOL_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- MAC_TABLE_ENTRY *pEntry = NULL;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (pEntry == NULL)
- {
- DBGPRINT(RT_DEBUG_WARN, ("Indicate_EAPOL_Packet: drop and release the invalid packet.\n"));
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-}
-
-#define BCN_TBTT_OFFSET 64 //defer 64 us
-VOID ReSyncBeaconTime(
- IN PRTMP_ADAPTER pAd)
-{
-
- UINT32 Offset;
-
-
- Offset = (pAd->TbttTickCount) % (BCN_TBTT_OFFSET);
-
- pAd->TbttTickCount++;
-
- //
- // The updated BeaconInterval Value will affect Beacon Interval after two TBTT
- // beacasue the original BeaconInterval had been loaded into next TBTT_TIMER
- //
- if (Offset == (BCN_TBTT_OFFSET-2))
- {
- BCN_TIME_CFG_STRUC csr;
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
- csr.field.BeaconInterval = (pAd->CommonCfg.BeaconPeriod << 4) - 1 ; // ASIC register in units of 1/16 TU = 64us
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
- }
- else
- {
- if (Offset == (BCN_TBTT_OFFSET-1))
- {
- BCN_TIME_CFG_STRUC csr;
-
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
- csr.field.BeaconInterval = (pAd->CommonCfg.BeaconPeriod) << 4; // ASIC register in units of 1/16 TU
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
- }
- }
-}
-
+#include "../../rt2860/common/cmm_data.c"
diff --git a/drivers/staging/rt2870/common/cmm_data_2870.c b/drivers/staging/rt2870/common/cmm_data_2870.c
index f77000f336a9..d6fc056f81d9 100644
--- a/drivers/staging/rt2870/common/cmm_data_2870.c
+++ b/drivers/staging/rt2870/common/cmm_data_2870.c
@@ -189,9 +189,6 @@ USHORT RtmpUSB_WriteFragTxResource(
}
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)(pWirelessPacket + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
pHTTXContext->CurWriteRealPos += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
@@ -295,6 +292,7 @@ USHORT RtmpUSB_WriteSingleTxResource(
pTxBlk->Priv = (TXINFO_SIZE + USBDMApktLen);
// For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload
+ //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(USBDMApktLen), FALSE, FIFO_EDCA, FALSE /*NextValid*/, FALSE);
if ((pHTTXContext->CurWritePosition + 3906 + pTxBlk->Priv) > MAX_TXBULK_LIMIT)
@@ -303,9 +301,6 @@ USHORT RtmpUSB_WriteSingleTxResource(
bTxQLastRound = TRUE;
}
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)(pWirelessPacket + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
// We unlock it here to prevent the first 8 bytes maybe over-writed issue.
@@ -417,9 +412,6 @@ USHORT RtmpUSB_WriteMultiTxResource(
// Copy it.
NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, pTxBlk->Priv);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)(pWirelessPacket+ TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
pHTTXContext->CurWriteRealPos += pTxBlk->Priv;
pWirelessPacket += pTxBlk->Priv;
}
@@ -687,14 +679,7 @@ VOID RtmpUSBNullFrameKickOut(
pTxWI = (PTXWI_STRUC)&pWirelessPkt[TXINFO_SIZE];
RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(HEADER_802_11)),
0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
RTMPMoveMemory(&pWirelessPkt[TXWI_SIZE+TXINFO_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)&pWirelessPkt[TXINFO_SIZE + TXWI_SIZE], DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
pAd->NullContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
// Fill out frame length information for global Bulk out arbitor
@@ -708,7 +693,6 @@ VOID RtmpUSBNullFrameKickOut(
}
-#ifdef CONFIG_STA_SUPPORT
/*
========================================================================
@@ -826,7 +810,12 @@ VOID RT28xxUsbStaAsicForceWakeup(
AutoWakeupCfg.word = 0;
RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+#ifndef RT30xx
AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x00);
+#endif
+#ifdef RT30xx
+ AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
+#endif
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
}
@@ -854,7 +843,6 @@ VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
}
-#endif // CONFIG_STA_SUPPORT //
VOID RT28xxUsbMlmeRadioOn(
IN PRTMP_ADAPTER pAd)
@@ -864,25 +852,30 @@ VOID RT28xxUsbMlmeRadioOn(
if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
return;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
+#ifndef RT30xx
AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x00);
+#endif
+#ifdef RT30xx
+ AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
+#endif
RTMPusecDelay(10000);
- }
-#endif // CONFIG_STA_SUPPORT //
+
NICResetFromError(pAd);
// Enable Tx/Rx
RTMPEnableRxTx(pAd);
+#ifdef RT3070
+ if (IS_RT3071(pAd))
+ {
+ RT30xxReverseRFSleepModeSetup(pAd);
+ }
+#endif // RT3070 //
+
// Clear Radio off flag
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTUSBBulkReceive(pAd);
-#endif // CONFIG_STA_SUPPORT //
+ RTUSBBulkReceive(pAd);
// Set LED
RTMPSetLED(pAd, LED_RADIO_ON);
@@ -904,8 +897,6 @@ VOID RT28xxUsbMlmeRadioOFF(
// Set Radio off flag
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Link down first if any association exists
if (INFRA_ON(pAd) || ADHOC_ON(pAd))
@@ -916,9 +907,8 @@ VOID RT28xxUsbMlmeRadioOFF(
// Clean up old bss table
BssTableInit(&pAd->ScanTab);
}
-#endif // CONFIG_STA_SUPPORT //
-
+#ifndef RT30xx
// Disable MAC Tx/Rx
RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
Value &= (0xfffffff3);
@@ -932,6 +922,7 @@ VOID RT28xxUsbMlmeRadioOFF(
// TX_PIN_CFG => value = 0x0 => 20mA
RTMP_IO_WRITE32(pAd, TX_PIN_CFG, 0);
+#endif
if (pAd->CommonCfg.BBPCurrentBW == BW_40)
{
@@ -944,6 +935,14 @@ VOID RT28xxUsbMlmeRadioOFF(
AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
}
+#ifdef RT30xx
+ // Disable Tx/Rx DMA
+ RTUSBReadMACRegister(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
+ GloCfg.field.EnableTxDMA = 0;
+ GloCfg.field.EnableRxDMA = 0;
+ RTUSBWriteMACRegister(pAd, WPDMA_GLO_CFG, GloCfg.word); // abort all TX rings
+#endif
+
// Waiting for DMA idle
i = 0;
do
@@ -955,9 +954,13 @@ VOID RT28xxUsbMlmeRadioOFF(
RTMPusecDelay(1000);
}while (i++ < 100);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
-#endif // CONFIG_STA_SUPPORT //
+#ifdef RT30xx
+ // Disable MAC Tx/Rx
+ RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
+ Value &= (0xfffffff3);
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
+#endif
+
+ AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
}
diff --git a/drivers/staging/rt2870/common/cmm_info.c b/drivers/staging/rt2870/common/cmm_info.c
index 47a1b1a73f09..226187ee5561 100644
--- a/drivers/staging/rt2870/common/cmm_info.c
+++ b/drivers/staging/rt2870/common/cmm_info.c
@@ -1,3712 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-*/
-
-#include "../rt_config.h"
-
-INT Show_SSID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-#ifdef DOT11_N_SUPPORT
-INT Show_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // DOT11_N_SUPPORT //
-
-INT Show_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_CountryCode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-#ifdef AGGREGATION_SUPPORT
-INT Show_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // AGGREGATION_SUPPORT //
-
-#ifdef WMM_SUPPORT
-INT Show_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // WMM_SUPPORT //
-
-INT Show_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-#ifdef CONFIG_STA_SUPPORT
-INT Show_NetworkType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // CONFIG_STA_SUPPORT //
-
-INT Show_AuthMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_EncrypType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key1_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key2_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key3_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key4_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-static struct {
- CHAR *name;
- INT (*show_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
- {"SSID", Show_SSID_Proc},
- {"WirelessMode", Show_WirelessMode_Proc},
- {"TxBurst", Show_TxBurst_Proc},
- {"TxPreamble", Show_TxPreamble_Proc},
- {"TxPower", Show_TxPower_Proc},
- {"Channel", Show_Channel_Proc},
- {"BGProtection", Show_BGProtection_Proc},
- {"RTSThreshold", Show_RTSThreshold_Proc},
- {"FragThreshold", Show_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
- {"HtBw", Show_HtBw_Proc},
- {"HtMcs", Show_HtMcs_Proc},
- {"HtGi", Show_HtGi_Proc},
- {"HtOpMode", Show_HtOpMode_Proc},
- {"HtExtcha", Show_HtExtcha_Proc},
- {"HtMpduDensity", Show_HtMpduDensity_Proc},
- {"HtBaWinSize", Show_HtBaWinSize_Proc},
- {"HtRdg", Show_HtRdg_Proc},
- {"HtAmsdu", Show_HtAmsdu_Proc},
- {"HtAutoBa", Show_HtAutoBa_Proc},
-#endif // DOT11_N_SUPPORT //
- {"CountryRegion", Show_CountryRegion_Proc},
- {"CountryRegionABand", Show_CountryRegionABand_Proc},
- {"CountryCode", Show_CountryCode_Proc},
-#ifdef AGGREGATION_SUPPORT
- {"PktAggregate", Show_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
- {"WmmCapable", Show_WmmCapable_Proc},
-#endif
- {"IEEE80211H", Show_IEEE80211H_Proc},
-#ifdef CONFIG_STA_SUPPORT
- {"NetworkType", Show_NetworkType_Proc},
-#endif // CONFIG_STA_SUPPORT //
- {"AuthMode", Show_AuthMode_Proc},
- {"EncrypType", Show_EncrypType_Proc},
- {"DefaultKeyID", Show_DefaultKeyID_Proc},
- {"Key1", Show_Key1_Proc},
- {"Key2", Show_Key2_Proc},
- {"Key3", Show_Key3_Proc},
- {"Key4", Show_Key4_Proc},
- {"WPAPSK", Show_WPAPSK_Proc},
- {NULL, NULL}
-};
-
-/*
- ==========================================================================
- Description:
- Get Driver version.
-
- Return:
- ==========================================================================
-*/
-INT Set_DriverVersion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
-#endif // CONFIG_STA_SUPPORT //
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Country Region.
- This command will not work, if the field of CountryRegion in eeprom is programmed.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG region;
-
- region = simple_strtol(arg, 0, 10);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- return -EOPNOTSUPP;
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // Country can be set only when EEPROM not programmed
- if (pAd->CommonCfg.CountryRegion & 0x80)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n"));
- return FALSE;
- }
-
- if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
- {
- pAd->CommonCfg.CountryRegion = (UCHAR) region;
- }
- else if (region == REGION_31_BG_BAND)
- {
- pAd->CommonCfg.CountryRegion = (UCHAR) region;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameters out of range\n"));
- return FALSE;
- }
-
- // if set country region, driver needs to be reset
- BuildChannelList(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Country Region for A band.
- This command will not work, if the field of CountryRegion in eeprom is programmed.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG region;
-
- region = simple_strtol(arg, 0, 10);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- return -EOPNOTSUPP;
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // Country can be set only when EEPROM not programmed
- if (pAd->CommonCfg.CountryRegionForABand & 0x80)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n"));
- return FALSE;
- }
-
- if((region >= 0) && (region <= REGION_MAXIMUM_A_BAND))
- {
- pAd->CommonCfg.CountryRegionForABand = (UCHAR) region;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameters out of range\n"));
- return FALSE;
- }
-
- // if set country region, driver needs to be reset
- BuildChannelList(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Wireless Mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG WirelessMode;
- INT success = TRUE;
-
- WirelessMode = simple_strtol(arg, 0, 10);
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- INT MaxPhyMode = PHY_11G;
-
-#ifdef DOT11_N_SUPPORT
- MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
- if (WirelessMode <= MaxPhyMode)
- {
- RTMPSetPhyMode(pAd, WirelessMode);
-#ifdef DOT11_N_SUPPORT
- if (WirelessMode >= PHY_11ABGN_MIXED)
- {
- pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
- pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
- }
- else
- {
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
- }
-#endif // DOT11_N_SUPPORT //
- // Set AdhocMode rates
- if (pAd->StaCfg.BssType == BSS_ADHOC)
- {
- MlmeUpdateTxRates(pAd, FALSE, 0);
- MakeIbssBeacon(pAd); // re-build BEACON frame
- AsicEnableIbssSync(pAd); // copy to on-chip memory
- }
- }
- else
- {
- success = FALSE;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // it is needed to set SSID to take effect
- if (success == TRUE)
- {
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%ld)\n", WirelessMode));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
- }
-
- return success;
-}
-
-/*
- ==========================================================================
- Description:
- Set Channel
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- INT success = TRUE;
- UCHAR Channel;
-
- Channel = (UCHAR) simple_strtol(arg, 0, 10);
-
- // check if this channel is valid
- if (ChannelSanity(pAd, Channel) == TRUE)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->CommonCfg.Channel = Channel;
-
- if (MONITOR_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- N_ChannelCheck(pAd);
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
- {
- N_SetCenCh(pAd);
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
- pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- success = TRUE;
- }
- else
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- success = FALSE;
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- if (success == TRUE)
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
-
- return success;
-}
-
-/*
- ==========================================================================
- Description:
- Set Short Slot Time Enable or Disable
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ShortSlot_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG ShortSlot;
-
- ShortSlot = simple_strtol(arg, 0, 10);
-
- if (ShortSlot == 1)
- pAd->CommonCfg.bUseShortSlotTime = TRUE;
- else if (ShortSlot == 0)
- pAd->CommonCfg.bUseShortSlotTime = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Tx power
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG TxPower;
- INT success = FALSE;
-
- TxPower = (ULONG) simple_strtol(arg, 0, 10);
- if (TxPower <= 100)
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->CommonCfg.TxPowerDefault = TxPower;
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
- }
-#endif // CONFIG_STA_SUPPORT //
- success = TRUE;
- }
- else
- success = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
-
- return success;
-}
-
-/*
- ==========================================================================
- Description:
- Set 11B/11G Protection
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- switch (simple_strtol(arg, 0, 10))
- {
- case 0: //AUTO
- pAd->CommonCfg.UseBGProtection = 0;
- break;
- case 1: //Always On
- pAd->CommonCfg.UseBGProtection = 1;
- break;
- case 2: //Always OFF
- pAd->CommonCfg.UseBGProtection = 2;
- break;
- default: //Invalid argument
- return FALSE;
- }
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set TxPreamble
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- RT_802_11_PREAMBLE Preamble;
-
- Preamble = simple_strtol(arg, 0, 10);
-
-
- switch (Preamble)
- {
- case Rt802_11PreambleShort:
- pAd->CommonCfg.TxPreamble = Preamble;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
-#endif // CONFIG_STA_SUPPORT //
- break;
- case Rt802_11PreambleLong:
-#ifdef CONFIG_STA_SUPPORT
- case Rt802_11PreambleAuto:
- // if user wants AUTO, initialize to LONG here, then change according to AP's
- // capability upon association.
-#endif // CONFIG_STA_SUPPORT //
- pAd->CommonCfg.TxPreamble = Preamble;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
-#endif // CONFIG_STA_SUPPORT //
- break;
- default: //Invalid argument
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set RTS Threshold
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
-
- RtsThresh = simple_strtol(arg, 0, 10);
-
- if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
- pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
-#ifdef CONFIG_STA_SUPPORT
- else if (RtsThresh == 0)
- pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-#endif // CONFIG_STA_SUPPORT //
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Fragment Threshold
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
-
- FragThresh = simple_strtol(arg, 0, 10);
-
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- {
- //Illegal FragThresh so we set it to default
- pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- }
- else if (FragThresh % 2 == 1)
- {
- // The length of each fragment shall always be an even number of octets, except for the last fragment
- // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
- pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
- }
- else
- {
- pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
- pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
- else
- pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set TxBurst
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG TxBurst;
-
- TxBurst = simple_strtol(arg, 0, 10);
- if (TxBurst == 1)
- pAd->CommonCfg.bEnableTxBurst = TRUE;
- else if (TxBurst == 0)
- pAd->CommonCfg.bEnableTxBurst = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
-
- return TRUE;
-}
-
-#ifdef AGGREGATION_SUPPORT
-/*
- ==========================================================================
- Description:
- Set TxBurst
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG aggre;
-
- aggre = simple_strtol(arg, 0, 10);
-
- if (aggre == 1)
- pAd->CommonCfg.bAggregationCapable = TRUE;
- else if (aggre == 0)
- pAd->CommonCfg.bAggregationCapable = FALSE;
- else
- return FALSE; //Invalid argument
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
-
- return TRUE;
-}
-#endif
-
-/*
- ==========================================================================
- Description:
- Set IEEE80211H.
- This parameter is 1 when needs radar detection, otherwise 0
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG ieee80211h;
-
- ieee80211h = simple_strtol(arg, 0, 10);
-
- if (ieee80211h == 1)
- pAd->CommonCfg.bIEEE80211H = TRUE;
- else if (ieee80211h == 0)
- pAd->CommonCfg.bIEEE80211H = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
-
- return TRUE;
-}
-
-
-#ifdef DBG
-/*
- ==========================================================================
- Description:
- For Debug information
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Debug_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
-
- if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
- RTDebugLevel = simple_strtol(arg, 0, 10);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
-
- return TRUE;
-}
-#endif
-
-INT Show_DescInfo_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Reset statistics counter
-
- Arguments:
- pAdapter Pointer to our adapter
- arg
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ResetStatCounter_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- //UCHAR i;
- //MAC_TABLE_ENTRY *pEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
-
- // add the most up-to-date h/w raw counters into software counters
- NICUpdateRawCounters(pAd);
-
- NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
- NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
- NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
-
- // Reset HotSpot counter
-#if 0 // ToDo.
- for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- pEntry = &pAd->MacTab.Content[i];
-
- if ((pEntry->Valid == FALSE) || (pEntry->Sst != SST_ASSOC))
- continue;
-
- pEntry->HSCounter.LastDataPacketTime = 0;
- pEntry->HSCounter.TotalRxByteCount= 0;
- pEntry->HSCounter.TotalTxByteCount= 0;
- }
-#endif
-
-
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Add WPA key process.
- In Adhoc WPANONE, bPairwise = 0; KeyIdx = 0;
-
- Arguments:
- pAd Pointer to our adapter
- pBuf Pointer to the where the key stored
-
- Return Value:
- NDIS_SUCCESS Add key successfully
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-#if 0 // remove by AlbertY
-NDIS_STATUS RTMPWPAAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf)
-{
- PNDIS_802_11_KEY pKey;
- ULONG KeyIdx;
-// NDIS_STATUS Status;
-// ULONG offset; // unused variable, snowpin 2006.07.13
-
- PUCHAR pTxMic, pRxMic;
- BOOLEAN bTxKey; // Set the key as transmit key
- BOOLEAN bPairwise; // Indicate the key is pairwise key
- BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
- // Otherwise, it will set by the NIC.
- BOOLEAN bAuthenticator; // indicate key is set by authenticator.
- UCHAR apidx = BSS0;
-
- pKey = (PNDIS_802_11_KEY) pBuf;
- KeyIdx = pKey->KeyIndex & 0xff;
- // Bit 31 of Add-key, Tx Key
- bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
- // Bit 30 of Add-key PairwiseKey
- bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
- // Bit 29 of Add-key KeyRSC
- bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
- // Bit 28 of Add-key Authenticator
- bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc==>pKey->KeyIndex = %x. bPairwise= %d\n", pKey->KeyIndex, bPairwise));
- // 1. Check Group / Pairwise Key
- if (bPairwise) // Pairwise Key
- {
- // 1. KeyIdx must be 0, otherwise, return NDIS_STATUS_INVALID_DATA
- if (KeyIdx != 0)
- return(NDIS_STATUS_INVALID_DATA);
-
- // 2. Check bTx, it must be true, otherwise, return NDIS_STATUS_INVALID_DATA
- if (bTxKey == FALSE)
- return(NDIS_STATUS_INVALID_DATA);
-
- // 3. If BSSID is all 0xff, return NDIS_STATUS_INVALID_DATA
- if (MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR))
- return(NDIS_STATUS_INVALID_DATA);
-
- // 3.1 Check Pairwise key length for TKIP key. For AES, it's always 128 bits
- //if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
- if ((pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
- return(NDIS_STATUS_INVALID_DATA);
-
- pAd->SharedKey[apidx][KeyIdx].Type = PAIRWISE_KEY;
-
- if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2)
- {
- // Send media specific event to start PMKID caching
- RTMPIndicateWPA2Status(pAd);
- }
- }
- else
- {
- // 1. Check BSSID, if not current BSSID or Bcast, return NDIS_STATUS_INVALID_DATA
- if ((! MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR)) &&
- (! MAC_ADDR_EQUAL(pKey->BSSID, pAd->ApCfg.MBSSID[apidx].Bssid)))
- return(NDIS_STATUS_INVALID_DATA);
-
- // 2. Check Key index for supported Group Key
- if (KeyIdx >= GROUP_KEY_NUM)
- return(NDIS_STATUS_INVALID_DATA);
-
- // 3. Set as default Tx Key if bTxKey is TRUE
- if (bTxKey == TRUE)
- pAd->ApCfg.MBSSID[apidx].DefaultKeyId = (UCHAR) KeyIdx;
-
- pAd->SharedKey[apidx][KeyIdx].Type = GROUP_KEY;
- }
-
- // 4. Select RxMic / TxMic based on Supp / Authenticator
- if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPANone)
- {
- // for WPA-None Tx, Rx MIC is the same
- pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
- pRxMic = pTxMic;
- }
- else if (bAuthenticator == TRUE)
- {
- pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
- pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
- }
- else
- {
- pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
- pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
- }
-
- // 6. Check RxTsc
- if (bKeyRSC == TRUE)
- {
- NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, &pKey->KeyRSC, 6);
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxTsc, &pKey->KeyRSC, 6);
- }
- else
- {
- NdisZeroMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, 6);
- }
-
- // 7. Copy information into Pairwise Key structure.
- // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
- pAd->SharedKey[apidx][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
- NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, 16);
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.Key, &pKey->KeyMaterial, 16);
- if (pKey->KeyLength == LEN_TKIP_KEY)
- {
- // Only Key lenth equal to TKIP key have these
- NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxMic, pRxMic, 8);
- NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].TxMic, pTxMic, 8);
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxMic, pRxMic, 8);
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxMic, pTxMic, 8);
- }
-
- COPY_MAC_ADDR(pAd->SharedKey[BSS0][KeyIdx].BssId, pKey->BSSID);
-
- // Init TxTsc to one based on WiFi WPA specs
- pAd->SharedKey[apidx][KeyIdx].TxTsc[0] = 1;
- pAd->SharedKey[apidx][KeyIdx].TxTsc[1] = 0;
- pAd->SharedKey[apidx][KeyIdx].TxTsc[2] = 0;
- pAd->SharedKey[apidx][KeyIdx].TxTsc[3] = 0;
- pAd->SharedKey[apidx][KeyIdx].TxTsc[4] = 0;
- pAd->SharedKey[apidx][KeyIdx].TxTsc[5] = 0;
- // 4. Init TxTsc to one based on WiFi WPA specs
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[0] = 1;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[1] = 0;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[2] = 0;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[3] = 0;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[4] = 0;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[5] = 0;
-
- if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption3Enabled)
- {
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_AES;
- }
- else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption2Enabled)
- {
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_TKIP;
- }
- else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption1Enabled)
- {
- if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 5)
- {
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP64;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP64;
- }
- else if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 13)
- {
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP128;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP128;
- }
- else
- {
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
- }
- }
- else
- {
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
- }
-
- if ((pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
- {
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = pAd->SharedKey[BSS0][KeyIdx].KeyLen;
- }
-
- if ((pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- //
- // On WPA2, Update Group Key Cipher.
- //
- if (!bPairwise)
- {
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->SharedKey[%d][%d].CipherAlg = %d\n", apidx, KeyIdx, pAd->SharedKey[apidx][KeyIdx].CipherAlg));
-
-#if 0
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("%s Key #%d", CipherName[pAd->SharedKey[apidx][KeyIdx].CipherAlg],KeyIdx));
- for (i = 0; i < 16; i++)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].Key[i]));
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Rx MIC Key = "));
- for (i = 0; i < 8; i++)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxMic[i]));
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Tx MIC Key = "));
- for (i = 0; i < 8; i++)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].TxMic[i]));
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n RxTSC = "));
- for (i = 0; i < 6; i++)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxTsc[i]));
- }
-#endif
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n pKey-> BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
- pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]));
-
- if ((bTxKey) && (pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
- RTMPAddBSSIDCipher(pAd, BSSID_WCID, pKey, pAd->SharedKey[BSS0][KeyIdx].CipherAlg);
-
-
- // No matter pairwise key or what leyidx is, always has a copy at on-chip SharedKeytable.
- AsicAddSharedKeyEntry(pAd,
- apidx,
- (UCHAR)KeyIdx,
- pAd->SharedKey[apidx][KeyIdx].CipherAlg,
- pAd->SharedKey[apidx][KeyIdx].Key,
- pAd->SharedKey[apidx][KeyIdx].TxMic,
- pAd->SharedKey[apidx][KeyIdx].RxMic);
-
- // The WCID key specified in used at Tx. For STA, always use pairwise key.
-
- // ad-hoc mode need to specify WAP Group key with WCID index=BSS0Mcast_WCID. Let's always set this key here.
-/* if (bPairwise == FALSE)
- {
- offset = MAC_IVEIV_TABLE_BASE + (BSS0Mcast_WCID * HW_IVEIV_ENTRY_SIZE);
- NdisZeroMemory(IVEIV, 8);
- // 1. IV/EIV
- // Specify key index to find shared key.
- if ((pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_TKIP) ||
- (pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_AES))
- IVEIV[3] = 0x20; // Eiv bit on. keyid always 0 for pairwise key
- IVEIV[3] |= (KeyIdx<< 6); // groupkey index is not 0
- for (i=0; i<8; i++)
- {
- RTMP_IO_WRITE8(pAd, offset+i, IVEIV[i]);
- }
-
- // 2. WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:use share key, BSSIdx is 0
- WCIDAttri = (pAd->SharedKey[BSS0][KeyIdx].CipherAlg<<1)|PAIRWISEKEYTABLE;
- offset = MAC_WCID_ATTRIBUTE_BASE + (BSS0Mcast_WCID* HW_WCID_ATTRI_SIZE);
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-
- }
-
-*/
-
- if (pAd->SharedKey[apidx][KeyIdx].Type == GROUP_KEY)
- {
- // 802.1x port control
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- DBGPRINT(RT_DEBUG_TRACE,("!!WPA_802_1X_PORT_SECURED!!\n"));
-
- }
-
- return (NDIS_STATUS_SUCCESS);
-}
-#endif
-
-BOOLEAN RTMPCheckStrPrintAble(
- IN CHAR *pInPutStr,
- IN UCHAR strLen)
-{
- UCHAR i=0;
-
- for (i=0; i<strLen; i++)
- {
- if ((pInPutStr[i] < 0x21) ||
- (pInPutStr[i] > 0x7E))
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Remove WPA Key process
-
- Arguments:
- pAd Pointer to our adapter
- pBuf Pointer to the where the key stored
-
- Return Value:
- NDIS_SUCCESS Add key successfully
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPSetDesiredRates(
- IN PRTMP_ADAPTER pAdapter,
- IN LONG Rates)
-{
- NDIS_802_11_RATES aryRates;
-
- memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
- switch (pAdapter->CommonCfg.PhyMode)
- {
- case PHY_11A: // A only
- switch (Rates)
- {
- case 6000000: //6M
- aryRates[0] = 0x0c; // 6M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
- break;
- case 9000000: //9M
- aryRates[0] = 0x12; // 9M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
- break;
- case 12000000: //12M
- aryRates[0] = 0x18; // 12M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
- break;
- case 18000000: //18M
- aryRates[0] = 0x24; // 18M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
- break;
- case 24000000: //24M
- aryRates[0] = 0x30; // 24M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
- break;
- case 36000000: //36M
- aryRates[0] = 0x48; // 36M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
- break;
- case 48000000: //48M
- aryRates[0] = 0x60; // 48M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
- break;
- case 54000000: //54M
- aryRates[0] = 0x6c; // 54M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
- break;
- case -1: //Auto
- default:
- aryRates[0] = 0x6c; // 54Mbps
- aryRates[1] = 0x60; // 48Mbps
- aryRates[2] = 0x48; // 36Mbps
- aryRates[3] = 0x30; // 24Mbps
- aryRates[4] = 0x24; // 18M
- aryRates[5] = 0x18; // 12M
- aryRates[6] = 0x12; // 9M
- aryRates[7] = 0x0c; // 6M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- break;
- }
- break;
- case PHY_11BG_MIXED: // B/G Mixed
- case PHY_11B: // B only
- case PHY_11ABG_MIXED: // A/B/G Mixed
- default:
- switch (Rates)
- {
- case 1000000: //1M
- aryRates[0] = 0x02;
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
- break;
- case 2000000: //2M
- aryRates[0] = 0x04;
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
- break;
- case 5000000: //5.5M
- aryRates[0] = 0x0b; // 5.5M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
- break;
- case 11000000: //11M
- aryRates[0] = 0x16; // 11M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
- break;
- case 6000000: //6M
- aryRates[0] = 0x0c; // 6M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
- break;
- case 9000000: //9M
- aryRates[0] = 0x12; // 9M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
- break;
- case 12000000: //12M
- aryRates[0] = 0x18; // 12M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
- break;
- case 18000000: //18M
- aryRates[0] = 0x24; // 18M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
- break;
- case 24000000: //24M
- aryRates[0] = 0x30; // 24M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
- break;
- case 36000000: //36M
- aryRates[0] = 0x48; // 36M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
- break;
- case 48000000: //48M
- aryRates[0] = 0x60; // 48M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
- break;
- case 54000000: //54M
- aryRates[0] = 0x6c; // 54M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
- break;
- case -1: //Auto
- default:
- if (pAdapter->CommonCfg.PhyMode == PHY_11B)
- { //B Only
- aryRates[0] = 0x16; // 11Mbps
- aryRates[1] = 0x0b; // 5.5Mbps
- aryRates[2] = 0x04; // 2Mbps
- aryRates[3] = 0x02; // 1Mbps
- }
- else
- { //(B/G) Mixed or (A/B/G) Mixed
- aryRates[0] = 0x6c; // 54Mbps
- aryRates[1] = 0x60; // 48Mbps
- aryRates[2] = 0x48; // 36Mbps
- aryRates[3] = 0x30; // 24Mbps
- aryRates[4] = 0x16; // 11Mbps
- aryRates[5] = 0x0b; // 5.5Mbps
- aryRates[6] = 0x04; // 2Mbps
- aryRates[7] = 0x02; // 1Mbps
- }
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- break;
- }
- break;
- }
-
- NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
- DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
- pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
- pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
- pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
- pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
- // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
-}
-
-NDIS_STATUS RTMPWPARemoveKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf)
-{
- PNDIS_802_11_REMOVE_KEY pKey;
- ULONG KeyIdx;
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- BOOLEAN bTxKey; // Set the key as transmit key
- BOOLEAN bPairwise; // Indicate the key is pairwise key
- BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
- // Otherwise, it will set by the NIC.
- BOOLEAN bAuthenticator; // indicate key is set by authenticator.
- INT i;
-
- DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
-
- pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
- KeyIdx = pKey->KeyIndex & 0xff;
- // Bit 31 of Add-key, Tx Key
- bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
- // Bit 30 of Add-key PairwiseKey
- bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
- // Bit 29 of Add-key KeyRSC
- bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
- // Bit 28 of Add-key Authenticator
- bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
-
- // 1. If bTx is TRUE, return failure information
- if (bTxKey == TRUE)
- return(NDIS_STATUS_INVALID_DATA);
-
- // 2. Check Pairwise Key
- if (bPairwise)
- {
- // a. If BSSID is broadcast, remove all pairwise keys.
- // b. If not broadcast, remove the pairwise specified by BSSID
- for (i = 0; i < SHARE_KEY_NUM; i++)
- {
- if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
- {
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
- pAd->SharedKey[BSS0][i].KeyLen = 0;
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
- }
- }
- // 3. Group Key
- else
- {
- // a. If BSSID is broadcast, remove all group keys indexed
- // b. If BSSID matched, delete the group key indexed.
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
- Status = NDIS_STATUS_SUCCESS;
- }
-
- return (Status);
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ========================================================================
-
- Routine Description:
- Remove All WPA Keys
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPWPARemoveAllKeys(
- IN PRTMP_ADAPTER pAd)
-{
-
- UCHAR i;
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
-
- // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
- // Link up. And it will be replaced if user changed it.
- if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return;
-
- // For WPA-None, there is no need to remove it, since WinXP won't set it again after
- // Link up. And it will be replaced if user changed it.
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- return;
-
- // set BSSID wcid entry of the Pair-wise Key table as no-security mode
- AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
-
- // set all shared key mode as no-security.
- for (i = 0; i < SHARE_KEY_NUM; i++)
- {
- DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
- NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
-
- AsicRemoveSharedKeyEntry(pAd, BSS0, i);
- }
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ========================================================================
- Routine Description:
- Change NIC PHY mode. Re-association may be necessary. possible settings
- include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
-
- Arguments:
- pAd - Pointer to our adapter
- phymode -
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPSetPhyMode(
- IN PRTMP_ADAPTER pAd,
- IN ULONG phymode)
-{
- INT i;
- // the selected phymode must be supported by the RF IC encoded in E2PROM
-
- // if no change, do nothing
- /* bug fix
- if (pAd->CommonCfg.PhyMode == phymode)
- return;
- */
- pAd->CommonCfg.PhyMode = (UCHAR)phymode;
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
-#ifdef EXT_BUILD_CHANNEL_LIST
- BuildChannelListEx(pAd);
-#else
- BuildChannelList(pAd);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // sanity check user setting
- for (i = 0; i < pAd->ChannelListNum; i++)
- {
- if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
- break;
- }
-
- if (i == pAd->ChannelListNum)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->CommonCfg.Channel = FirstChannel(pAd);
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
- }
-
- NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- switch (phymode) {
- case PHY_11B:
- pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRateLen = 4;
- pAd->CommonCfg.ExtRateLen = 0;
- pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
- //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
- break;
-
- case PHY_11G:
- case PHY_11BG_MIXED:
- case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11N_2_4G:
- case PHY_11ABGN_MIXED:
- case PHY_11BGN_MIXED:
- case PHY_11GN_MIXED:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRateLen = 8;
- pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRateLen = 4;
- pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
- break;
-
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AN_MIXED:
- case PHY_11AGN_MIXED:
- case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRateLen = 8;
- pAd->CommonCfg.ExtRateLen = 0;
- pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
- //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
- break;
-
- default:
- break;
- }
-
-
- pAd->CommonCfg.BandState = UNKNOWN_BAND;
-}
-
-
-#ifdef DOT11_N_SUPPORT
-/*
- ========================================================================
- Routine Description:
- Caller ensures we has 802.11n support.
- Calls at setting HT from AP/STASetinformation
-
- Arguments:
- pAd - Pointer to our adapter
- phymode -
-
- ========================================================================
-*/
-VOID RTMPSetHT(
- IN PRTMP_ADAPTER pAd,
- IN OID_SET_HT_PHYMODE *pHTPhyMode)
-{
- //ULONG *pmcs;
- UINT32 Value = 0;
- UCHAR BBPValue = 0;
- UCHAR BBP3Value = 0;
- UCHAR RxStream = pAd->CommonCfg.RxStream;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
- pHTPhyMode->MCS, pHTPhyMode->BW,
- pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
-
- // Don't zero supportedHyPhy structure.
- RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
- RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
- RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
- RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
-
- if (pAd->CommonCfg.bRdg)
- {
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
- }
- else
- {
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
- }
-
- pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
- pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
-
- // Mimo power save, A-MSDU size,
- pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
- pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
- pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-
- pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
- pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
- pAd->CommonCfg.DesiredHtPhy.AmsduSize,
- pAd->CommonCfg.DesiredHtPhy.MimoPs,
- pAd->CommonCfg.DesiredHtPhy.MpduDensity,
- pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
-
- if(pHTPhyMode->HtMode == HTMODE_GF)
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
- pAd->CommonCfg.DesiredHtPhy.GF = 1;
- }
- else
- pAd->CommonCfg.DesiredHtPhy.GF = 0;
-
- // Decide Rx MCSSet
- switch (RxStream)
- {
- case 1:
- pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
- break;
-
- case 2:
- pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
- break;
-
- case 3: // 3*3
- pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
- break;
- }
-
- if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
- {
- pHTPhyMode->BW = BW_20;
- pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
- }
-
- if(pHTPhyMode->BW == BW_40)
- {
- pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
- pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
- if (pAd->CommonCfg.Channel <= 14)
- pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
-
- pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
- // Set Regsiter for extension channel position.
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
- if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
- {
- Value |= 0x1;
- BBP3Value |= (0x20);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
- }
- else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
- {
- Value &= 0xfe;
- BBP3Value &= (~0x20);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
- }
-
- // Turn on BBP 40MHz mode now only as AP .
- // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
- if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
- )
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- }
- }
- else
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
- pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- // Turn on BBP 20MHz mode by request here.
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- }
- }
-
- if(pHTPhyMode->STBC == STBC_USE)
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
- pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
- pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
- pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
- }
- else
- {
- pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
- pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
- }
-
-#ifdef RT2870
- /* Frank recommend ,If not, Tx maybe block in high power. Rx has no problem*/
- if(IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 0;
- pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
- }
-#endif // RT2870 //
-
- if(pHTPhyMode->SHORTGI == GI_400)
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
- }
- else
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
- }
-
- // We support link adaptation for unsolicit MCS feedback, set to 2.
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
- pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
- // 1, the extension channel above the control channel.
-
- // EDCA parameters used for AP's own transmission
- if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
- {
- pAd->CommonCfg.APEdcaParm.bValid = TRUE;
- pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
- pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
- pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
- pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-
- pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
- pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
-
- pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
- pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
- pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
-
- pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
- pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
- }
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- RTMPSetIndividualHT(pAd, 0);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Caller ensures we has 802.11n support.
- Calls at setting HT from AP/STASetinformation
-
- Arguments:
- pAd - Pointer to our adapter
- phymode -
-
- ========================================================================
-*/
-VOID RTMPSetIndividualHT(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx)
-{
- PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
- UCHAR TxStream = pAd->CommonCfg.TxStream;
- UCHAR DesiredMcs = MCS_AUTO;
-
- do
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
- DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
- //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
- break;
- }
-#endif // CONFIG_STA_SUPPORT //
- } while (FALSE);
-
- if (pDesired_ht_phy == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
- return;
- }
- RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
- // Check the validity of MCS
- if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
- {
- DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
- DesiredMcs = MCS_7;
- }
-
- if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
- {
- DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
- DesiredMcs = MCS_0;
- }
-
- pDesired_ht_phy->bHtEnable = TRUE;
-
- // Decide desired Tx MCS
- switch (TxStream)
- {
- case 1:
- if (DesiredMcs == MCS_AUTO)
- {
- pDesired_ht_phy->MCSSet[0]= 0xff;
- pDesired_ht_phy->MCSSet[1]= 0x00;
- }
- else if (DesiredMcs <= MCS_7)
- {
- pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
- pDesired_ht_phy->MCSSet[1]= 0x00;
- }
- break;
-
- case 2:
- if (DesiredMcs == MCS_AUTO)
- {
- pDesired_ht_phy->MCSSet[0]= 0xff;
- pDesired_ht_phy->MCSSet[1]= 0xff;
- }
- else if (DesiredMcs <= MCS_15)
- {
- ULONG mode;
-
- mode = DesiredMcs / 8;
- if (mode < 2)
- pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
- }
- break;
-
- case 3: // 3*3
- if (DesiredMcs == MCS_AUTO)
- {
- /* MCS0 ~ MCS23, 3 bytes */
- pDesired_ht_phy->MCSSet[0]= 0xff;
- pDesired_ht_phy->MCSSet[1]= 0xff;
- pDesired_ht_phy->MCSSet[2]= 0xff;
- }
- else if (DesiredMcs <= MCS_23)
- {
- ULONG mode;
-
- mode = DesiredMcs / 8;
- if (mode < 3)
- pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
- }
- break;
- }
-
- if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
- {
- if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
- pDesired_ht_phy->MCSSet[4] = 0x1;
- }
-
- // update HT Rate setting
- if (pAd->OpMode == OPMODE_STA)
- MlmeUpdateHtTxRates(pAd, BSS0);
- else
- MlmeUpdateHtTxRates(pAd, apidx);
-}
-
-
-/*
- ========================================================================
- Routine Description:
- Update HT IE from our capability.
-
- Arguments:
- Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
-
-
- ========================================================================
-*/
-VOID RTMPUpdateHTIE(
- IN RT_HT_CAPABILITY *pRtHt,
- IN UCHAR *pMcsSet,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo)
-{
- RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
- RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
-
- pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
- pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
- pHtCapability->HtCapInfo.GF = pRtHt->GF;
- pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
- pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
- pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
- pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
- pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
- pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
- pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
-
- pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
- pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
- pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
- pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
- RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
-}
-#endif // DOT11_N_SUPPORT //
-
-/*
- ========================================================================
- Description:
- Add Client security information into ASIC WCID table and IVEIV table.
- Return:
- ========================================================================
-*/
-VOID RTMPAddWcidAttributeEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- UINT32 WCIDAttri = 0;
- USHORT offset;
- UCHAR IVEIV = 0;
- USHORT Wcid = 0;
-
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (BssIdx > BSS0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
- return;
- }
-
- // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
- // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
- // the AID:2~ assign to mesh link entry.
- if (pEntry && ADHOC_ON(pAd))
- Wcid = pEntry->Aid;
- else if (pEntry && INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- if (pEntry->ValidAsDls == TRUE)
- Wcid = pEntry->Aid;
- else
-#endif // QOS_DLS_SUPPORT //
- Wcid = BSSID_WCID;
- }
- else
- Wcid = MCAST_WCID;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // Update WCID attribute table
- offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pEntry && pEntry->ValidAsMesh)
- WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
-#ifdef QOS_DLS_SUPPORT
- else if ((pEntry) && (pEntry->ValidAsDls) &&
- ((CipherAlg == CIPHER_TKIP) ||
- (CipherAlg == CIPHER_TKIP_NO_MIC) ||
- (CipherAlg == CIPHER_AES) ||
- (CipherAlg == CIPHER_NONE)))
- WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
-#endif // QOS_DLS_SUPPORT //
- else
- WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-
-
- // Update IV/EIV table
- offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
-
- // WPA mode
- if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
- {
- // Eiv bit on. keyid always is 0 for pairwise key
- IVEIV = (KeyIdx <<6) | 0x20;
- }
- else
- {
- // WEP KeyIdx is default tx key.
- IVEIV = (KeyIdx << 6);
- }
-
- // For key index and ext IV bit, so only need to update the position(offset+3).
-#ifdef RT2870
- RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
-#endif // RT2870 //
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
- DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
-
-}
-
-/*
- ==========================================================================
- Description:
- Parse encryption type
-Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- ==========================================================================
-*/
-CHAR *GetEncryptType(CHAR enc)
-{
- if(enc == Ndis802_11WEPDisabled)
- return "NONE";
- if(enc == Ndis802_11WEPEnabled)
- return "WEP";
- if(enc == Ndis802_11Encryption2Enabled)
- return "TKIP";
- if(enc == Ndis802_11Encryption3Enabled)
- return "AES";
- if(enc == Ndis802_11Encryption4Enabled)
- return "TKIPAES";
- else
- return "UNKNOW";
-}
-
-CHAR *GetAuthMode(CHAR auth)
-{
- if(auth == Ndis802_11AuthModeOpen)
- return "OPEN";
- if(auth == Ndis802_11AuthModeShared)
- return "SHARED";
- if(auth == Ndis802_11AuthModeAutoSwitch)
- return "AUTOWEP";
- if(auth == Ndis802_11AuthModeWPA)
- return "WPA";
- if(auth == Ndis802_11AuthModeWPAPSK)
- return "WPAPSK";
- if(auth == Ndis802_11AuthModeWPANone)
- return "WPANONE";
- if(auth == Ndis802_11AuthModeWPA2)
- return "WPA2";
- if(auth == Ndis802_11AuthModeWPA2PSK)
- return "WPA2PSK";
- if(auth == Ndis802_11AuthModeWPA1WPA2)
- return "WPA1WPA2";
- if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
- return "WPA1PSKWPA2PSK";
-
- return "UNKNOW";
-}
-
-#if 1 //#ifndef UCOS
-/*
- ==========================================================================
- Description:
- Get site survey results
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) UI needs to wait 4 seconds after issue a site survey command
- 2.) iwpriv ra0 get_site_survey
- 3.) UI needs to prepare at least 4096bytes to get the results
- ==========================================================================
-*/
-#define LINE_LEN (4+33+20+8+10+9+7+3) // Channel+SSID+Bssid+WepStatus+AuthMode+Signal+WiressMode+NetworkType
-VOID RTMPIoctlGetSiteSurvey(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *msg;
- INT i=0;
- INT WaitCnt;
- INT Status=0;
- CHAR Ssid[MAX_LEN_OF_SSID +1];
- INT Rssi = 0, max_len = LINE_LEN;
- UINT Rssi_Quality = 0;
- NDIS_802_11_NETWORK_TYPE wireless_mode;
-
- os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
-
- if (msg == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
- return;
- }
-
- memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
- memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
- sprintf(msg,"%s","\n");
- sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-8s%-10s%-9s%-7s%-3s\n",
- "Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
-
-
- WaitCnt = 0;
-#ifdef CONFIG_STA_SUPPORT
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
- OS_WAIT(500);
-#endif // CONFIG_STA_SUPPORT //
-
- for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
- {
- if( pAdapter->ScanTab.BssEntry[i].Channel==0)
- break;
-
- if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
- break;
-
- //Channel
- sprintf(msg+strlen(msg),"%-4d", pAdapter->ScanTab.BssEntry[i].Channel);
- //SSID
- memcpy(Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- Ssid[pAdapter->ScanTab.BssEntry[i].SsidLen] = '\0';
- sprintf(msg+strlen(msg),"%-33s", Ssid);
- //BSSID
- sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
- pAdapter->ScanTab.BssEntry[i].Bssid[0],
- pAdapter->ScanTab.BssEntry[i].Bssid[1],
- pAdapter->ScanTab.BssEntry[i].Bssid[2],
- pAdapter->ScanTab.BssEntry[i].Bssid[3],
- pAdapter->ScanTab.BssEntry[i].Bssid[4],
- pAdapter->ScanTab.BssEntry[i].Bssid[5]);
- //Encryption Type
- sprintf(msg+strlen(msg),"%-8s",GetEncryptType(pAdapter->ScanTab.BssEntry[i].WepStatus));
- //Authentication Mode
- if (pAdapter->ScanTab.BssEntry[i].WepStatus == Ndis802_11WEPEnabled)
- sprintf(msg+strlen(msg),"%-10s", "UNKNOW");
- else
- sprintf(msg+strlen(msg),"%-10s",GetAuthMode(pAdapter->ScanTab.BssEntry[i].AuthMode));
- // Rssi
- Rssi = (INT)pAdapter->ScanTab.BssEntry[i].Rssi;
- if (Rssi >= -50)
- Rssi_Quality = 100;
- else if (Rssi >= -80) // between -50 ~ -80dbm
- Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
- else if (Rssi >= -90) // between -80 ~ -90dbm
- Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
- else // < -84 dbm
- Rssi_Quality = 0;
- sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
- // Wireless Mode
- wireless_mode = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
- if (wireless_mode == Ndis802_11FH ||
- wireless_mode == Ndis802_11DS)
- sprintf(msg+strlen(msg),"%-7s", "11b");
- else if (wireless_mode == Ndis802_11OFDM5)
- sprintf(msg+strlen(msg),"%-7s", "11a");
- else if (wireless_mode == Ndis802_11OFDM5_N)
- sprintf(msg+strlen(msg),"%-7s", "11a/n");
- else if (wireless_mode == Ndis802_11OFDM24)
- sprintf(msg+strlen(msg),"%-7s", "11b/g");
- else if (wireless_mode == Ndis802_11OFDM24_N)
- sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
- else
- sprintf(msg+strlen(msg),"%-7s", "unknow");
- //Network Type
- if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_ADHOC)
- sprintf(msg+strlen(msg),"%-3s", " Ad");
- else
- sprintf(msg+strlen(msg),"%-3s", " In");
-
- sprintf(msg+strlen(msg),"\n");
- }
-
-#ifdef CONFIG_STA_SUPPORT
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-#endif // CONFIG_STA_SUPPORT //
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
- os_free_mem(NULL, (PUCHAR)msg);
-}
-
-
-#define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
-VOID RTMPIoctlGetMacTable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq)
-{
- INT i;
- RT_802_11_MAC_TABLE MacTab;
- char *msg;
-
- MacTab.Num = 0;
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
- {
- COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
- MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
- MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
-#ifdef DOT11_N_SUPPORT
- MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
-#endif // DOT11_N_SUPPORT //
-
- // Fill in RSSI per entry
- MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
- MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
- MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
-
- // the connected time per entry
- MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
-#if 0 // ToDo
- MacTab.Entry[MacTab.Num].HSCounter.LastDataPacketTime = pAd->MacTab.Content[i].HSCounter.LastDataPacketTime;
- MacTab.Entry[MacTab.Num].HSCounter.TotalRxByteCount = pAd->MacTab.Content[i].HSCounter.TotalRxByteCount;
- MacTab.Entry[MacTab.Num].HSCounter.TotalTxByteCount = pAd->MacTab.Content[i].HSCounter.TotalTxByteCount;
-#endif
- MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
- MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
- MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
- MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
- MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
- MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
- MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
-
- MacTab.Num += 1;
- }
- }
- wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
- if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
- }
-
- msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
- memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
- sprintf(msg,"%s","\n");
- sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
- "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
-
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
- if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
- {
- if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
- break;
- sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
- sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
- sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
- sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
- sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
- sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
- sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
- }
- }
- // for compatible with old API just do the printk to console
- //wrq->u.data.length = strlen(msg);
- //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
- }
-
- kfree(msg);
-}
-#endif // UCOS //
-
-#ifdef DOT11_N_SUPPORT
-INT Set_BASetup_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], tid;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
-/*
- The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the tid value.
-*/
- //printk("\n%s\n", arg);
-
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- tid = simple_strtol((token+1), 0, 10);
- if (tid > 15)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], tid);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nSetup BA Session: Tid = %d\n", tid);
- BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_BADecline_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG bBADecline;
-
- bBADecline = simple_strtol(arg, 0, 10);
-
- if (bBADecline == 0)
- {
- pAd->CommonCfg.bBADecline = FALSE;
- }
- else if (bBADecline == 1)
- {
- pAd->CommonCfg.bBADecline = TRUE;
- }
- else
- {
- return FALSE; //Invalid argument
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
-
- return TRUE;
-}
-
-INT Set_BAOriTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], tid;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
- //printk("\n%s\n", arg);
-/*
- The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the tid value.
-*/
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- tid = simple_strtol((token+1), 0, 10);
- if (tid > NUM_OF_TID)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], tid);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nTear down Ori BA Session: Tid = %d\n", tid);
- BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_BARecTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], tid;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
- //printk("\n%s\n", arg);
-/*
- The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the tid value.
-*/
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- tid = simple_strtol((token+1), 0, 10);
- if (tid > NUM_OF_TID)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], tid);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nTear down Rec BA Session: Tid = %d\n", tid);
- BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG HtBw;
-
- HtBw = simple_strtol(arg, 0, 10);
- if (HtBw == BW_40)
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- else if (HtBw == BW_20)
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
-
- return TRUE;
-}
-
-INT Set_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG HtMcs, Mcs_tmp;
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN bAutoRate = FALSE;
-#endif // CONFIG_STA_SUPPORT //
-
- Mcs_tmp = simple_strtol(arg, 0, 10);
-
- if (Mcs_tmp <= 15 || Mcs_tmp == 32)
- HtMcs = Mcs_tmp;
- else
- HtMcs = MCS_AUTO;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
- pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
-
- if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
- {
- if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
- (HtMcs >= 0 && HtMcs <= 3) &&
- (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
- {
- RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
- }
- else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
- (HtMcs >= 0 && HtMcs <= 7) &&
- (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
- {
- RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
- }
- else
- bAutoRate = TRUE;
-
- if (bAutoRate)
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- RTMPSetDesiredRates(pAd, -1);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
- }
- if (ADHOC_ON(pAd))
- return TRUE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- SetCommonHT(pAd);
-
- return TRUE;
-}
-
-INT Set_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG HtGi;
-
- HtGi = simple_strtol(arg, 0, 10);
-
- if ( HtGi == GI_400)
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
- else if ( HtGi == GI_800 )
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
-
- return TRUE;
-}
-
-
-INT Set_HtTxBASize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR Size;
-
- Size = simple_strtol(arg, 0, 10);
-
- if (Size <=0 || Size >=64)
- {
- Size = 8;
- }
- pAd->CommonCfg.TxBASize = Size-1;
- DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
-
- return TRUE;
-}
-
-
-INT Set_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == HTMODE_GF)
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
- else if ( Value == HTMODE_MM )
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
-
- return TRUE;
-
-}
-
-INT Set_HtStbc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == STBC_USE)
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
- else if ( Value == STBC_NONE )
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
-
- return TRUE;
-}
-
-INT Set_HtHtc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->HTCEnable = FALSE;
- else if ( Value ==1 )
- pAd->HTCEnable = TRUE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
-
- return TRUE;
-}
-
-INT Set_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == 0)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- else if ( Value ==1 )
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
-
- return TRUE;
-}
-
-INT Set_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value <=7 && Value >= 0)
- pAd->CommonCfg.BACapability.field.MpduDensity = Value;
- else
- pAd->CommonCfg.BACapability.field.MpduDensity = 4;
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
-
- return TRUE;
-}
-
-INT Set_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
-
- if (Value >=1 && Value <= 64)
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
- }
- else
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
- }
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
-
- return TRUE;
-}
-
-INT Set_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == 0)
- pAd->CommonCfg.bRdg = FALSE;
- else if ( Value ==1 )
- {
- pAd->HTCEnable = TRUE;
- pAd->CommonCfg.bRdg = TRUE;
- }
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
-
- return TRUE;
-}
-
-INT Set_HtLinkAdapt_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->bLinkAdapt = FALSE;
- else if ( Value ==1 )
- {
- pAd->HTCEnable = TRUE;
- pAd->bLinkAdapt = TRUE;
- }
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
-
- return TRUE;
-}
-
-INT Set_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
- else if ( Value == 1 )
- pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
-
- return TRUE;
-}
-
-INT Set_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- else if (Value == 1)
- pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
- else
- return FALSE; //Invalid argument
-
- pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
-
- return TRUE;
-
-}
-
-INT Set_HtProtect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.bHTProtect = FALSE;
- else if (Value == 1)
- pAd->CommonCfg.bHTProtect = TRUE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
-
- return TRUE;
-}
-
-INT Set_SendPSMPAction_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], mode;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
- //printk("\n%s\n", arg);
-/*
- The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the mode value.
-*/
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- mode = simple_strtol((token+1), 0, 10);
- if (mode > MMPS_ENABLE)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], mode);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nSendPSMPAction MIPS mode = %d\n", mode);
- SendPSMPAction(pAd, pEntry->Aid, mode);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-
-}
-
-INT Set_HtMIMOPSmode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value <=3 && Value >= 0)
- pAd->CommonCfg.BACapability.field.MMPSmode = Value;
- else
- pAd->CommonCfg.BACapability.field.MMPSmode = 3;
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
-
- return TRUE;
-}
-
-
-INT Set_ForceShortGI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->WIFItestbed.bShortGI = FALSE;
- else if (Value == 1)
- pAd->WIFItestbed.bShortGI = TRUE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
-
- return TRUE;
-}
-
-
-
-INT Set_ForceGF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->WIFItestbed.bGreenField = FALSE;
- else if (Value == 1)
- pAd->WIFItestbed.bGreenField = TRUE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
-
- return TRUE;
-}
-
-INT Set_HtMimoPs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.bMIMOPSEnable = FALSE;
- else if (Value == 1)
- pAd->CommonCfg.bMIMOPSEnable = TRUE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
-
- return TRUE;
-}
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
-INT SetCommonHT(
- IN PRTMP_ADAPTER pAd)
-{
- OID_SET_HT_PHYMODE SetHT;
-
- if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
- return FALSE;
-
- SetHT.PhyMode = pAd->CommonCfg.PhyMode;
- SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
- SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
- SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
- SetHT.MCS = MCS_AUTO;
- SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
- SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
- SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
-
- RTMPSetHT(pAd, &SetHT);
-
- return TRUE;
-}
-#endif // DOT11_N_SUPPORT //
-
-INT Set_FixedTxMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR fix_tx_mode = FIXED_TXMODE_HT;
-
- if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_OFDM;
- }
- else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_CCK;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
-
- return TRUE;
-}
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-INT Set_OpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
-#ifdef RT2870
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
-#endif // RT2870 //
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Can not switch operate mode on interface up !! \n"));
- return FALSE;
- }
-
- if (Value == 0)
- pAd->OpMode = OPMODE_STA;
- else if (Value == 1)
- pAd->OpMode = OPMODE_AP;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_OpMode_Proc::(OpMode=%s)\n", pAd->OpMode == 1 ? "AP Mode" : "STA Mode"));
-
- return TRUE;
-}
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-
-/////////////////////////////////////////////////////////////////////////
-PCHAR RTMPGetRalinkAuthModeStr(
- IN NDIS_802_11_AUTHENTICATION_MODE authMode)
-{
- switch(authMode)
- {
- case Ndis802_11AuthModeOpen:
- return "OPEN";
- case Ndis802_11AuthModeWPAPSK:
- return "WPAPSK";
- case Ndis802_11AuthModeShared:
- return "SHARED";
- case Ndis802_11AuthModeWPA:
- return "WPA";
- case Ndis802_11AuthModeWPA2:
- return "WPA2";
- case Ndis802_11AuthModeWPA2PSK:
- return "WPA2PSK";
- case Ndis802_11AuthModeWPA1PSKWPA2PSK:
- return "WPAPSKWPA2PSK";
- case Ndis802_11AuthModeWPA1WPA2:
- return "WPA1WPA2";
- case Ndis802_11AuthModeWPANone:
- return "WPANONE";
- default:
- return "UNKNOW";
- }
-}
-
-PCHAR RTMPGetRalinkEncryModeStr(
- IN USHORT encryMode)
-{
- switch(encryMode)
- {
- case Ndis802_11WEPDisabled:
- return "NONE";
- case Ndis802_11WEPEnabled:
- return "WEP";
- case Ndis802_11Encryption2Enabled:
- return "TKIP";
- case Ndis802_11Encryption3Enabled:
- return "AES";
- case Ndis802_11Encryption4Enabled:
- return "TKIPAES";
- default:
- return "UNKNOW";
- }
-}
-
-INT RTMPShowCfgValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pName,
- IN PUCHAR pBuf)
-{
- INT Status = 0;
-
- for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
- {
- if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
- {
- if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
- Status = -EINVAL;
- break; //Exit for loop.
- }
- }
-
- if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
- {
- sprintf(pBuf, "\n");
- for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
- sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
- }
-
- return Status;
-}
-
-INT Show_SSID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
-#endif // CONFIG_STA_SUPPORT //
- return 0;
-}
-
-INT Show_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.PhyMode)
- {
- case PHY_11BG_MIXED:
- sprintf(pBuf, "\t11B/G");
- break;
- case PHY_11B:
- sprintf(pBuf, "\t11B");
- break;
- case PHY_11A:
- sprintf(pBuf, "\t11A");
- break;
- case PHY_11ABG_MIXED:
- sprintf(pBuf, "\t11A/B/G");
- break;
- case PHY_11G:
- sprintf(pBuf, "\t11G");
- break;
-#ifdef DOT11_N_SUPPORT
- case PHY_11ABGN_MIXED:
- sprintf(pBuf, "\t11A/B/G/N");
- break;
- case PHY_11N_2_4G:
- sprintf(pBuf, "\t11N only with 2.4G");
- break;
- case PHY_11GN_MIXED:
- sprintf(pBuf, "\t11G/N");
- break;
- case PHY_11AN_MIXED:
- sprintf(pBuf, "\t11A/N");
- break;
- case PHY_11BGN_MIXED:
- sprintf(pBuf, "\t11B/G/N");
- break;
- case PHY_11AGN_MIXED:
- sprintf(pBuf, "\t11A/G/N");
- break;
- case PHY_11N_5G:
- sprintf(pBuf, "\t11N only with 5G");
- break;
-#endif // DOT11_N_SUPPORT //
- default:
- sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
- break;
- }
- return 0;
-}
-
-
-INT Show_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
- return 0;
-}
-
-INT Show_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.TxPreamble)
- {
- case Rt802_11PreambleShort:
- sprintf(pBuf, "\tShort");
- break;
- case Rt802_11PreambleLong:
- sprintf(pBuf, "\tLong");
- break;
- case Rt802_11PreambleAuto:
- sprintf(pBuf, "\tAuto");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
- break;
- }
-
- return 0;
-}
-
-INT Show_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
- return 0;
-}
-
-INT Show_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
- return 0;
-}
-
-INT Show_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.UseBGProtection)
- {
- case 1: //Always On
- sprintf(pBuf, "\tON");
- break;
- case 2: //Always OFF
- sprintf(pBuf, "\tOFF");
- break;
- case 0: //AUTO
- sprintf(pBuf, "\tAuto");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
- break;
- }
- return 0;
-}
-
-INT Show_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
- return 0;
-}
-
-INT Show_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
- return 0;
-}
-
-#ifdef DOT11_N_SUPPORT
-INT Show_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
- {
- sprintf(pBuf, "\t40 MHz");
- }
- else
- {
- sprintf(pBuf, "\t20 MHz");
- }
- return 0;
-}
-
-INT Show_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
-#endif // CONFIG_STA_SUPPORT //
- return 0;
-}
-
-INT Show_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
- {
- case GI_400:
- sprintf(pBuf, "\tGI_400");
- break;
- case GI_800:
- sprintf(pBuf, "\tGI_800");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
- break;
- }
- return 0;
-}
-
-INT Show_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
- {
- case HTMODE_GF:
- sprintf(pBuf, "\tGF");
- break;
- case HTMODE_MM:
- sprintf(pBuf, "\tMM");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
- break;
- }
- return 0;
-}
-
-INT Show_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
- {
- case EXTCHA_BELOW:
- sprintf(pBuf, "\tBelow");
- break;
- case EXTCHA_ABOVE:
- sprintf(pBuf, "\tAbove");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
- break;
- }
- return 0;
-}
-
-
-INT Show_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
- return 0;
-}
-
-INT Show_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
- return 0;
-}
-
-INT Show_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
- return 0;
-}
-
-INT Show_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
- return 0;
-}
-
-INT Show_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
- return 0;
-}
-#endif // DOT11_N_SUPPORT //
-
-INT Show_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
- return 0;
-}
-
-INT Show_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
- return 0;
-}
-
-INT Show_CountryCode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
- return 0;
-}
-
-#ifdef AGGREGATION_SUPPORT
-INT Show_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
- return 0;
-}
-#endif // AGGREGATION_SUPPORT //
-
-#ifdef WMM_SUPPORT
-INT Show_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
-#endif // CONFIG_STA_SUPPORT //
-
- return 0;
-}
-#endif // WMM_SUPPORT //
-
-INT Show_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
- return 0;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-INT Show_NetworkType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->StaCfg.BssType)
- {
- case BSS_ADHOC:
- sprintf(pBuf, "\tAdhoc");
- break;
- case BSS_INFRA:
- sprintf(pBuf, "\tInfra");
- break;
- case BSS_ANY:
- sprintf(pBuf, "\tAny");
- break;
- case BSS_MONITOR:
- sprintf(pBuf, "\tMonitor");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
- break;
- }
- return 0;
-}
-#endif // CONFIG_STA_SUPPORT //
-
-INT Show_AuthMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AuthMode = pAd->StaCfg.AuthMode;
-#endif // CONFIG_STA_SUPPORT //
-
- if ((AuthMode >= Ndis802_11AuthModeOpen) &&
- (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
- sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
- else
- sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
-
- return 0;
-}
-
-INT Show_EncrypType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- WepStatus = pAd->StaCfg.WepStatus;
-#endif // CONFIG_STA_SUPPORT //
-
- if ((WepStatus >= Ndis802_11WEPEnabled) &&
- (WepStatus <= Ndis802_11Encryption4KeyAbsent))
- sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
- else
- sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
-
- return 0;
-}
-
-INT Show_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- UCHAR DefaultKeyId = 0;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- DefaultKeyId = pAd->StaCfg.DefaultKeyId;
-#endif // CONFIG_STA_SUPPORT //
-
- sprintf(pBuf, "\t%d", DefaultKeyId);
-
- return 0;
-}
-
-INT Show_WepKey_Proc(
- IN PRTMP_ADAPTER pAd,
- IN INT KeyIdx,
- OUT PUCHAR pBuf)
-{
- UCHAR Key[16] = {0}, KeyLength = 0;
- INT index = BSS0;
-
- KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
- NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
-
- //check key string is ASCII or not
- if (RTMPCheckStrPrintAble(Key, KeyLength))
- sprintf(pBuf, "\t%s", Key);
- else
- {
- int idx;
- sprintf(pBuf, "\t");
- for (idx = 0; idx < KeyLength; idx++)
- sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
- }
- return 0;
-}
-
-INT Show_Key1_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 0, pBuf);
- return 0;
-}
-
-INT Show_Key2_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 1, pBuf);
- return 0;
-}
-
-INT Show_Key3_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 2, pBuf);
- return 0;
-}
-
-INT Show_Key4_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 3, pBuf);
- return 0;
-}
-
-INT Show_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- INT idx;
- UCHAR PMK[32] = {0};
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
-#endif // CONFIG_STA_SUPPORT //
-
- sprintf(pBuf, "\tPMK = ");
- for (idx = 0; idx < 32; idx++)
- sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);
-
- return 0;
-}
-
+#include "../../rt2860/common/cmm_info.c"
diff --git a/drivers/staging/rt2870/common/cmm_sanity.c b/drivers/staging/rt2870/common/cmm_sanity.c
index 1e24320177bc..cb3352118c57 100644
--- a/drivers/staging/rt2870/common/cmm_sanity.c
+++ b/drivers/staging/rt2870/common/cmm_sanity.c
@@ -1,1663 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sanity.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 add WMM support
-*/
-#include "../rt_config.h"
-
-
-extern UCHAR CISCO_OUI[];
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR BROADCOM_OUI[];
-extern UCHAR WPS_OUI[];
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN MlmeAddBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2)
-{
- PMLME_ADDBA_REQ_STRUCT pInfo;
-
- pInfo = (MLME_ADDBA_REQ_STRUCT *)Msg;
-
- if ((MsgLen != sizeof(MLME_ADDBA_REQ_STRUCT)))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - message lenght not correct.\n"));
- return FALSE;
- }
-
- if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - The peer Mac is not associated yet.\n"));
- return FALSE;
- }
-
- /*
- if ((pInfo->BaBufSize > MAX_RX_REORDERBUF) || (pInfo->BaBufSize < 2))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - Rx Reordering buffer too big or too small\n"));
- return FALSE;
- }
- */
-
- if ((pInfo->pAddr[0]&0x01) == 0x01)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - broadcast address not support BA\n"));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN MlmeDelBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen)
-{
- MLME_DELBA_REQ_STRUCT *pInfo;
- pInfo = (MLME_DELBA_REQ_STRUCT *)Msg;
-
- if ((MsgLen != sizeof(MLME_DELBA_REQ_STRUCT)))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - message lenght not correct.\n"));
- return FALSE;
- }
-
- if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer Mac is not associated yet.\n"));
- return FALSE;
- }
-
- if ((pInfo->TID & 0xf0))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer TID is incorrect.\n"));
- return FALSE;
- }
-
- if (NdisEqualMemory(pAd->MacTab.Content[pInfo->Wcid].Addr, pInfo->Addr, MAC_ADDR_LEN) == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - the peer addr dosen't exist.\n"));
- return FALSE;
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerAddBAReqActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PFRAME_ADDBA_REQ pAddFrame;
- pAddFrame = (PFRAME_ADDBA_REQ)(pMsg);
- if (MsgLen < (sizeof(FRAME_ADDBA_REQ)))
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
- // we support immediate BA.
- *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
- pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
- pAddFrame->BaStartSeq.word = cpu2le16(pAddFrame->BaStartSeq.word);
-
- if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request Ba Policy[%d] not support\n", pAddFrame->BaParm.BAPolicy));
- DBGPRINT(RT_DEBUG_ERROR,("ADDBA Request. tid=%x, Bufsize=%x, AMSDUSupported=%x \n", pAddFrame->BaParm.TID, pAddFrame->BaParm.BufSize, pAddFrame->BaParm.AMSDUSupported));
- return FALSE;
- }
-
- // we support immediate BA.
- if (pAddFrame->BaParm.TID &0xfff0)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request incorrect TID = %d\n", pAddFrame->BaParm.TID));
- return FALSE;
- }
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- return TRUE;
-}
-
-BOOLEAN PeerAddBARspActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen)
-{
- //PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PFRAME_ADDBA_RSP pAddFrame;
-
- pAddFrame = (PFRAME_ADDBA_RSP)(pMsg);
- if (MsgLen < (sizeof(FRAME_ADDBA_RSP)))
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBARspActionSanity: ADDBA Response frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
- // we support immediate BA.
- *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
- pAddFrame->StatusCode = cpu2le16(pAddFrame->StatusCode);
- pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
-
- if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Response Ba Policy[%d] not support\n", pAddFrame->BaParm.BAPolicy));
- return FALSE;
- }
-
- // we support immediate BA.
- if (pAddFrame->BaParm.TID &0xfff0)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBARspActionSanity: ADDBA Response incorrect TID = %d\n", pAddFrame->BaParm.TID));
- return FALSE;
- }
- return TRUE;
-
-}
-
-BOOLEAN PeerDelBAActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN VOID *pMsg,
- IN ULONG MsgLen )
-{
- //PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PFRAME_DELBA_REQ pDelFrame;
- if (MsgLen != (sizeof(FRAME_DELBA_REQ)))
- return FALSE;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- pDelFrame = (PFRAME_DELBA_REQ)(pMsg);
-
- *(USHORT *)(&pDelFrame->DelbaParm) = cpu2le16(*(USHORT *)(&pDelFrame->DelbaParm));
- pDelFrame->ReasonCode = cpu2le16(pDelFrame->ReasonCode);
-
- if (pDelFrame->DelbaParm.TID &0xfff0)
- return FALSE;
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerBeaconAndProbeRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- IN UCHAR MsgChannel,
- OUT PUCHAR pAddr2,
- OUT PUCHAR pBssid,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen,
- OUT UCHAR *pBssType,
- OUT USHORT *pBeaconPeriod,
- OUT UCHAR *pChannel,
- OUT UCHAR *pNewChannel,
- OUT LARGE_INTEGER *pTimestamp,
- OUT CF_PARM *pCfParm,
- OUT USHORT *pAtimWin,
- OUT USHORT *pCapabilityInfo,
- OUT UCHAR *pErp,
- OUT UCHAR *pDtimCount,
- OUT UCHAR *pDtimPeriod,
- OUT UCHAR *pBcastFlag,
- OUT UCHAR *pMessageToMe,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT UCHAR *pCkipFlag,
- OUT UCHAR *pAironetCellPowerLimit,
- OUT PEDCA_PARM pEdcaParm,
- OUT PQBSS_LOAD_PARM pQbssLoad,
- OUT PQOS_CAPABILITY_PARM pQosCapability,
- OUT ULONG *pRalinkIe,
- OUT UCHAR *pHtCapabilityLen,
-#ifdef CONFIG_STA_SUPPORT
- OUT UCHAR *pPreNHtCapabilityLen,
-#endif // CONFIG_STA_SUPPORT //
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT UCHAR *AddHtInfoLen,
- OUT ADD_HT_INFO_IE *AddHtInfo,
- OUT UCHAR *NewExtChannelOffset, // Ht extension channel offset(above or below)
- OUT USHORT *LengthVIE,
- OUT PNDIS_802_11_VARIABLE_IEs pVIE)
-{
- CHAR *Ptr;
-#ifdef CONFIG_STA_SUPPORT
- CHAR TimLen;
-#endif // CONFIG_STA_SUPPORT //
- PFRAME_802_11 pFrame;
- PEID_STRUCT pEid;
- UCHAR SubType;
- UCHAR Sanity;
- //UCHAR ECWMin, ECWMax;
- //MAC_CSR9_STRUC Csr9;
- ULONG Length = 0;
-
- // For some 11a AP which didn't have DS_IE, we use two conditions to decide the channel
- // 1. If the AP is 11n enabled, then check the control channel.
- // 2. If the AP didn't have any info about channel, use the channel we received this frame as the channel. (May inaccuracy!!)
- UCHAR CtrlChannel = 0;
-
- // Add for 3 necessary EID field check
- Sanity = 0;
-
- *pAtimWin = 0;
- *pErp = 0;
- *pDtimCount = 0;
- *pDtimPeriod = 0;
- *pBcastFlag = 0;
- *pMessageToMe = 0;
- *pExtRateLen = 0;
- *pCkipFlag = 0; // Default of CkipFlag is 0
- *pAironetCellPowerLimit = 0xFF; // Default of AironetCellPowerLimit is 0xFF
- *LengthVIE = 0; // Set the length of VIE to init value 0
- *pHtCapabilityLen = 0; // Set the length of VIE to init value 0
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->OpMode == OPMODE_STA)
- *pPreNHtCapabilityLen = 0; // Set the length of VIE to init value 0
-#endif // CONFIG_STA_SUPPORT //
- *AddHtInfoLen = 0; // Set the length of VIE to init value 0
- *pRalinkIe = 0;
- *pNewChannel = 0;
- *NewExtChannelOffset = 0xff; //Default 0xff means no such IE
- pCfParm->bValid = FALSE; // default: no IE_CF found
- pQbssLoad->bValid = FALSE; // default: no IE_QBSS_LOAD found
- pEdcaParm->bValid = FALSE; // default: no IE_EDCA_PARAMETER found
- pQosCapability->bValid = FALSE; // default: no IE_QOS_CAPABILITY found
-
- pFrame = (PFRAME_802_11)Msg;
-
- // get subtype from header
- SubType = (UCHAR)pFrame->Hdr.FC.SubType;
-
- // get Addr2 and BSSID from header
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- COPY_MAC_ADDR(pBssid, pFrame->Hdr.Addr3);
-
-// hex_dump("Beacon", Msg, MsgLen);
-
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- // get timestamp from payload and advance the pointer
- NdisMoveMemory(pTimestamp, Ptr, TIMESTAMP_LEN);
-
- pTimestamp->u.LowPart = cpu2le32(pTimestamp->u.LowPart);
- pTimestamp->u.HighPart = cpu2le32(pTimestamp->u.HighPart);
-
- Ptr += TIMESTAMP_LEN;
- Length += TIMESTAMP_LEN;
-
- // get beacon interval from payload and advance the pointer
- NdisMoveMemory(pBeaconPeriod, Ptr, 2);
- Ptr += 2;
- Length += 2;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
- Length += 2;
-
- if (CAP_IS_ESS_ON(*pCapabilityInfo))
- *pBssType = BSS_INFRA;
- else
- *pBssType = BSS_ADHOC;
-
- pEid = (PEID_STRUCT) Ptr;
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- //
- // Secure copy VIE to VarIE[MAX_VIE_LEN] didn't overflow.
- //
- if ((*LengthVIE + pEid->Len + 2) >= MAX_VIE_LEN)
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - Variable IEs out of resource [len(=%d) > MAX_VIE_LEN(=%d)]\n",
- (*LengthVIE + pEid->Len + 2), MAX_VIE_LEN));
- break;
- }
-
- switch(pEid->Eid)
- {
- case IE_SSID:
- // Already has one SSID EID in this beacon, ignore the second one
- if (Sanity & 0x1)
- break;
- if(pEid->Len <= MAX_LEN_OF_SSID)
- {
- NdisMoveMemory(Ssid, pEid->Octet, pEid->Len);
- *pSsidLen = pEid->Len;
- Sanity |= 0x1;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
-
- case IE_SUPP_RATES:
- if(pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- Sanity |= 0x2;
- NdisMoveMemory(SupRate, pEid->Octet, pEid->Len);
- *pSupRateLen = pEid->Len;
-
- // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
- // from ScanTab. We should report as is. And filter out unsupported
- // rates in MlmeAux.
- // Check against the supported rates
- // RTMPCheckRates(pAd, SupRate, pSupRateLen);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SUPP_RATES (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
-
- case IE_HT_CAP:
- if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
- {
- NdisMoveMemory(pHtCapability, pEid->Octet, sizeof(HT_CAPABILITY_IE));
- *pHtCapabilityLen = SIZE_HT_CAP_IE; // Nnow we only support 26 bytes.
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- *pPreNHtCapabilityLen = 0; // Nnow we only support 26 bytes.
-
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_HT_CAP. pEid->Len = %d\n", pEid->Len));
- }
-
- break;
- case IE_ADD_HT:
- if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
- {
- // This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
- // copy first sizeof(ADD_HT_INFO_IE)
- NdisMoveMemory(AddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
- *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
-
- CtrlChannel = AddHtInfo->ControlChan;
-
- *(USHORT *)(&AddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo2));
- *(USHORT *)(&AddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo3));
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_ADD_HT. \n"));
- }
-
- break;
- case IE_SECONDARY_CH_OFFSET:
- if (pEid->Len == 1)
- {
- *NewExtChannelOffset = pEid->Octet[0];
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
- }
-
- break;
- case IE_FH_PARM:
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n"));
- break;
-
- case IE_DS_PARM:
- if(pEid->Len == 1)
- {
- *pChannel = *pEid->Octet;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ChannelSanity(pAd, *pChannel) == 0)
- {
-
- return FALSE;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- Sanity |= 0x4;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
-
- case IE_CF_PARM:
- if(pEid->Len == 6)
- {
- pCfParm->bValid = TRUE;
- pCfParm->CfpCount = pEid->Octet[0];
- pCfParm->CfpPeriod = pEid->Octet[1];
- pCfParm->CfpMaxDuration = pEid->Octet[2] + 256 * pEid->Octet[3];
- pCfParm->CfpDurRemaining = pEid->Octet[4] + 256 * pEid->Octet[5];
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_CF_PARM\n"));
- return FALSE;
- }
- break;
-
- case IE_IBSS_PARM:
- if(pEid->Len == 2)
- {
- NdisMoveMemory(pAtimWin, pEid->Octet, pEid->Len);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_IBSS_PARM\n"));
- return FALSE;
- }
- break;
-
-#ifdef CONFIG_STA_SUPPORT
- case IE_TIM:
- if(INFRA_ON(pAd) && SubType == SUBTYPE_BEACON)
- {
- GetTimBit((PUCHAR)pEid, pAd->StaActive.Aid, &TimLen, pBcastFlag, pDtimCount, pDtimPeriod, pMessageToMe);
- }
- break;
-#endif // CONFIG_STA_SUPPORT //
- case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
- if(pEid->Len == 3)
- {
- *pNewChannel = pEid->Octet[1]; //extract new channel number
- }
- break;
-
- // New for WPA
- // CCX v2 has the same IE, we need to parse that too
- // Wifi WMM use the same IE vale, need to parse that too
- // case IE_WPA:
- case IE_VENDOR_SPECIFIC:
- // Check Broadcom/Atheros 802.11n OUI version, for HT Capability IE.
- // This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
- /*if (NdisEqualMemory(pEid->Octet, BROADCOM_OUI, 3) && (pEid->Len >= 4))
- {
- if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 30))
- {
- {
- NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(HT_CAPABILITY_IE));
- *pHtCapabilityLen = SIZE_HT_CAP_IE; // Nnow we only support 26 bytes.
- }
- }
- if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 26))
- {
- {
- NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(ADD_HT_INFO_IE));
- *AddHtInfoLen = SIZE_ADD_HT_INFO_IE; // Nnow we only support 26 bytes.
- }
- }
- }
- */
- // Check the OUI version, filter out non-standard usage
- if (NdisEqualMemory(pEid->Octet, RALINK_OUI, 3) && (pEid->Len == 7))
- {
- //*pRalinkIe = pEid->Octet[3];
- if (pEid->Octet[3] != 0)
- *pRalinkIe = pEid->Octet[3];
- else
- *pRalinkIe = 0xf0000000; // Set to non-zero value (can't set bit0-2) to represent this is Ralink Chip. So at linkup, we will set ralinkchip flag.
- }
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
- // This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
-
- // Other vendors had production before IE_HT_CAP value is assigned. To backward support those old-firmware AP,
- // Check broadcom-defiend pre-802.11nD1.0 OUI for HT related IE, including HT Capatilities IE and HT Information IE
- else if ((*pHtCapabilityLen == 0) && NdisEqualMemory(pEid->Octet, PRE_N_HT_OUI, 3) && (pEid->Len >= 4) && (pAd->OpMode == OPMODE_STA))
- {
- if ((pEid->Octet[3] == OUI_PREN_HT_CAP) && (pEid->Len >= 30) && (*pHtCapabilityLen == 0))
- {
- NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(HT_CAPABILITY_IE));
- *pPreNHtCapabilityLen = SIZE_HT_CAP_IE;
- }
-
- if ((pEid->Octet[3] == OUI_PREN_ADD_HT) && (pEid->Len >= 26))
- {
- NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(ADD_HT_INFO_IE));
- *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
- }
- }
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- {
- // Copy to pVIE which will report to microsoft bssid list.
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
- else if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
- {
- PUCHAR ptr;
- int i;
-
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
- ptr = &pEid->Octet[8];
- for (i=0; i<4; i++)
- {
- UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
- pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
- pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
- pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
- pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
- pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
- ptr += 4; // point to next AC
- }
- }
- else if (NdisEqualMemory(pEid->Octet, WME_INFO_ELEM, 6) && (pEid->Len == 7))
- {
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
-
- // use default EDCA parameter
- pEdcaParm->bACM[QID_AC_BE] = 0;
- pEdcaParm->Aifsn[QID_AC_BE] = 3;
- pEdcaParm->Cwmin[QID_AC_BE] = CW_MIN_IN_BITS;
- pEdcaParm->Cwmax[QID_AC_BE] = CW_MAX_IN_BITS;
- pEdcaParm->Txop[QID_AC_BE] = 0;
-
- pEdcaParm->bACM[QID_AC_BK] = 0;
- pEdcaParm->Aifsn[QID_AC_BK] = 7;
- pEdcaParm->Cwmin[QID_AC_BK] = CW_MIN_IN_BITS;
- pEdcaParm->Cwmax[QID_AC_BK] = CW_MAX_IN_BITS;
- pEdcaParm->Txop[QID_AC_BK] = 0;
-
- pEdcaParm->bACM[QID_AC_VI] = 0;
- pEdcaParm->Aifsn[QID_AC_VI] = 2;
- pEdcaParm->Cwmin[QID_AC_VI] = CW_MIN_IN_BITS-1;
- pEdcaParm->Cwmax[QID_AC_VI] = CW_MAX_IN_BITS;
- pEdcaParm->Txop[QID_AC_VI] = 96; // AC_VI: 96*32us ~= 3ms
-
- pEdcaParm->bACM[QID_AC_VO] = 0;
- pEdcaParm->Aifsn[QID_AC_VO] = 2;
- pEdcaParm->Cwmin[QID_AC_VO] = CW_MIN_IN_BITS-2;
- pEdcaParm->Cwmax[QID_AC_VO] = CW_MAX_IN_BITS-1;
- pEdcaParm->Txop[QID_AC_VO] = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
- *pExtRateLen = pEid->Len;
-
- // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
- // from ScanTab. We should report as is. And filter out unsupported
- // rates in MlmeAux.
- // Check against the supported rates
- // RTMPCheckRates(pAd, ExtRate, pExtRateLen);
- }
- break;
-
- case IE_ERP:
- if (pEid->Len == 1)
- {
- *pErp = (UCHAR)pEid->Octet[0];
- }
- break;
-
- case IE_AIRONET_CKIP:
- // 0. Check Aironet IE length, it must be larger or equal to 28
- // Cisco AP350 used length as 28
- // Cisco AP12XX used length as 30
- if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
- break;
-
- // 1. Copy CKIP flag byte to buffer for process
- *pCkipFlag = *(pEid->Octet + 8);
- break;
-
- case IE_AP_TX_POWER:
- // AP Control of Client Transmit Power
- //0. Check Aironet IE length, it must be 6
- if (pEid->Len != 0x06)
- break;
-
- // Get cell power limit in dBm
- if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
- *pAironetCellPowerLimit = *(pEid->Octet + 4);
- break;
-
- // WPA2 & 802.11i RSN
- case IE_RSN:
- // There is no OUI for version anymore, check the group cipher OUI before copying
- if (RTMPEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- {
- // Copy to pVIE which will report to microsoft bssid list.
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
- break;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- case IE_COUNTRY:
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- break;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
- default:
- break;
- }
-
- Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- // For some 11a AP. it did not have the channel EID, patch here
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- UCHAR LatchRfChannel = MsgChannel;
- if ((pAd->LatchRfRegs.Channel > 14) && ((Sanity & 0x4) == 0))
- {
- if (CtrlChannel != 0)
- *pChannel = CtrlChannel;
- else
- *pChannel = LatchRfChannel;
- Sanity |= 0x4;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (Sanity != 0x7)
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - missing field, Sanity=0x%02x\n", Sanity));
- return FALSE;
- }
- else
- {
- return TRUE;
- }
-
-}
-
-#ifdef DOT11N_DRAFT3
-/*
- ==========================================================================
- Description:
- MLME message sanity check for some IE addressed in 802.11n d3.03.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerBeaconAndProbeRspSanity2(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *RegClass)
-{
- CHAR *Ptr;
- PFRAME_802_11 pFrame;
- PEID_STRUCT pEid;
- ULONG Length = 0;
-
- pFrame = (PFRAME_802_11)Msg;
-
- *RegClass = 0;
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- // get timestamp from payload and advance the pointer
- Ptr += TIMESTAMP_LEN;
- Length += TIMESTAMP_LEN;
-
- // get beacon interval from payload and advance the pointer
- Ptr += 2;
- Length += 2;
-
- // get capability info from payload and advance the pointer
- Ptr += 2;
- Length += 2;
-
- pEid = (PEID_STRUCT) Ptr;
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- switch(pEid->Eid)
- {
- case IE_SUPP_REG_CLASS:
- if(pEid->Len > 0)
- {
- *RegClass = *pEid->Octet;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
- }
-
- Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- return TRUE;
-
-}
-#endif // DOT11N_DRAFT3 //
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeScanReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *pBssType,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen,
- OUT UCHAR *pScanType)
-{
- MLME_SCAN_REQ_STRUCT *Info;
-
- Info = (MLME_SCAN_REQ_STRUCT *)(Msg);
- *pBssType = Info->BssType;
- *pSsidLen = Info->SsidLen;
- NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
- *pScanType = Info->ScanType;
-
- if ((*pBssType == BSS_INFRA || *pBssType == BSS_ADHOC || *pBssType == BSS_ANY)
- && (*pScanType == SCAN_ACTIVE || *pScanType == SCAN_PASSIVE
-#ifdef CONFIG_STA_SUPPORT
- || *pScanType == SCAN_CISCO_PASSIVE || *pScanType == SCAN_CISCO_ACTIVE
- || *pScanType == SCAN_CISCO_CHANNEL_LOAD || *pScanType == SCAN_CISCO_NOISE
-#endif // CONFIG_STA_SUPPORT //
- ))
- {
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqSanity fail - wrong BssType or ScanType\n"));
- return FALSE;
- }
-}
-
-// IRQL = DISPATCH_LEVEL
-UCHAR ChannelSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel)
-{
- int i;
-
- for (i = 0; i < pAd->ChannelListNum; i ++)
- {
- if (channel == pAd->ChannelList[i].Channel)
- return 1;
- }
- return 0;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerDeauthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pReason)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerAuthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT USHORT *pAlg,
- OUT USHORT *pSeq,
- OUT USHORT *pStatus,
- CHAR *pChlgText)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr, pFrame->Hdr.Addr2);
- NdisMoveMemory(pAlg, &pFrame->Octet[0], 2);
- NdisMoveMemory(pSeq, &pFrame->Octet[2], 2);
- NdisMoveMemory(pStatus, &pFrame->Octet[4], 2);
-
- if ((*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- )
- {
- if (*pSeq == 1 || *pSeq == 2)
- {
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
- return FALSE;
- }
- }
- else if (*pAlg == Ndis802_11AuthModeShared)
- {
- if (*pSeq == 1 || *pSeq == 4)
- {
- return TRUE;
- }
- else if (*pSeq == 2 || *pSeq == 3)
- {
- NdisMoveMemory(pChlgText, &pFrame->Octet[8], CIPHER_TEXT_LEN);
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
- return FALSE;
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong algorithm\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeAuthReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT ULONG *pTimeout,
- OUT USHORT *pAlg)
-{
- MLME_AUTH_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_AUTH_REQ_STRUCT *)Msg;
- COPY_MAC_ADDR(pAddr, pInfo->Addr);
- *pTimeout = pInfo->Timeout;
- *pAlg = pInfo->Alg;
-
- if (((*pAlg == Ndis802_11AuthModeShared) ||(*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- ) &&
- ((*pAddr & 0x01) == 0))
- {
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAuthReqSanity fail - wrong algorithm\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN MlmeAssocReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pApAddr,
- OUT USHORT *pCapabilityInfo,
- OUT ULONG *pTimeout,
- OUT USHORT *pListenIntv)
-{
- MLME_ASSOC_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_ASSOC_REQ_STRUCT *)Msg;
- *pTimeout = pInfo->Timeout; // timeout
- COPY_MAC_ADDR(pApAddr, pInfo->Addr); // AP address
- *pCapabilityInfo = pInfo->CapabilityInfo; // capability info
- *pListenIntv = pInfo->ListenIntv;
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerDisassocSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pReason)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
-
- return TRUE;
-}
-
-/*
- ========================================================================
- Routine Description:
- Sanity check NetworkType (11b, 11g or 11a)
-
- Arguments:
- pBss - Pointer to BSS table.
-
- Return Value:
- Ndis802_11DS .......(11b)
- Ndis802_11OFDM24....(11g)
- Ndis802_11OFDM5.....(11a)
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
- IN PBSS_ENTRY pBss)
-{
- NDIS_802_11_NETWORK_TYPE NetWorkType;
- UCHAR rate, i;
-
- NetWorkType = Ndis802_11DS;
-
- if (pBss->Channel <= 14)
- {
- //
- // First check support Rate.
- //
- for (i = 0; i < pBss->SupRateLen; i++)
- {
- rate = pBss->SupRate[i] & 0x7f; // Mask out basic rate set bit
- if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
- {
- continue;
- }
- else
- {
- //
- // Otherwise (even rate > 108) means Ndis802_11OFDM24
- //
- NetWorkType = Ndis802_11OFDM24;
- break;
- }
- }
-
- //
- // Second check Extend Rate.
- //
- if (NetWorkType != Ndis802_11OFDM24)
- {
- for (i = 0; i < pBss->ExtRateLen; i++)
- {
- rate = pBss->SupRate[i] & 0x7f; // Mask out basic rate set bit
- if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
- {
- continue;
- }
- else
- {
- //
- // Otherwise (even rate > 108) means Ndis802_11OFDM24
- //
- NetWorkType = Ndis802_11OFDM24;
- break;
- }
- }
- }
- }
- else
- {
- NetWorkType = Ndis802_11OFDM5;
- }
-
- if (pBss->HtCapabilityLen != 0)
- {
- if (NetWorkType == Ndis802_11OFDM5)
- NetWorkType = Ndis802_11OFDM5_N;
- else
- NetWorkType = Ndis802_11OFDM24_N;
- }
-
- return NetWorkType;
-}
-
-/*
- ==========================================================================
- Description:
- WPA message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN PeerWpaMessageSanity(
- IN PRTMP_ADAPTER pAd,
- IN PEAPOL_PACKET pMsg,
- IN ULONG MsgLen,
- IN UCHAR MsgType,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- UCHAR mic[LEN_KEY_DESC_MIC], digest[80], KEYDATA[MAX_LEN_OF_RSNIE];
- BOOLEAN bReplayDiff = FALSE;
- BOOLEAN bWPA2 = FALSE;
- KEY_INFO EapolKeyInfo;
- UCHAR GroupKeyIndex = 0;
-
-
- NdisZeroMemory(mic, sizeof(mic));
- NdisZeroMemory(digest, sizeof(digest));
- NdisZeroMemory(KEYDATA, sizeof(KEYDATA));
- NdisZeroMemory((PUCHAR)&EapolKeyInfo, sizeof(EapolKeyInfo));
-
- NdisMoveMemory((PUCHAR)&EapolKeyInfo, (PUCHAR)&pMsg->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT *)&EapolKeyInfo) = cpu2le16(*((USHORT *)&EapolKeyInfo));
-
- // Choose WPA2 or not
- if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
- bWPA2 = TRUE;
-
- // 0. Check MsgType
- if ((MsgType > EAPOL_GROUP_MSG_2) || (MsgType < EAPOL_PAIR_MSG_1))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("The message type is invalid(%d)! \n", MsgType));
- return FALSE;
- }
-
- // 1. Replay counter check
- if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1) // For supplicant
- {
- // First validate replay counter, only accept message with larger replay counter.
- // Let equal pass, some AP start with all zero replay counter
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
-
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
- if ((RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- {
- bReplayDiff = TRUE;
- }
- }
- else if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2) // For authenticator
- {
- // check Replay Counter coresponds to MSG from authenticator, otherwise discard
- if (!NdisEqualMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY))
- {
- bReplayDiff = TRUE;
- }
- }
-
- // Replay Counter different condition
- if (bReplayDiff)
- {
- // send wireless event - for replay counter different
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_REPLAY_COUNTER_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
-
- if (MsgType < EAPOL_GROUP_MSG_1)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in pairwise msg %d of 4-way handshake!\n", MsgType));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
- }
-
- hex_dump("Receive replay counter ", pMsg->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- hex_dump("Current replay counter ", pEntry->R_Counter, LEN_KEY_DESC_REPLAY);
- return FALSE;
- }
-
- // 2. Verify MIC except Pairwise Msg1
- if (MsgType != EAPOL_PAIR_MSG_1)
- {
- UCHAR rcvd_mic[LEN_KEY_DESC_MIC];
-
- // Record the received MIC for check later
- NdisMoveMemory(rcvd_mic, pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
- if (pEntry->WepStatus == Ndis802_11Encryption2Enabled) // TKIP
- {
- hmac_md5(pEntry->PTK, LEN_EAP_MICK, (PUCHAR)pMsg, MsgLen, mic);
- }
- else if (pEntry->WepStatus == Ndis802_11Encryption3Enabled) // AES
- {
- HMAC_SHA1((PUCHAR)pMsg, MsgLen, pEntry->PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
- }
-
- if (!NdisEqualMemory(rcvd_mic, mic, LEN_KEY_DESC_MIC))
- {
- // send wireless event - for MIC different
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_MIC_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
-
- if (MsgType < EAPOL_GROUP_MSG_1)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in pairwise msg %d of 4-way handshake!\n", MsgType));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
- }
-
- hex_dump("Received MIC", rcvd_mic, LEN_KEY_DESC_MIC);
- hex_dump("Desired MIC", mic, LEN_KEY_DESC_MIC);
-
- return FALSE;
- }
- }
-
- // Extract the context of the Key Data field if it exist
- // The field in pairwise_msg_2_WPA1(WPA2) & pairwise_msg_3_WPA1 is un-encrypted.
- // The field in group_msg_1_WPA1(WPA2) & pairwise_msg_3_WPA2 is encrypted.
- if (pMsg->KeyDesc.KeyDataLen[1] > 0)
- {
- // Decrypt this field
- if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
- {
- if(pEntry->WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA, pMsg->KeyDesc.KeyDataLen[1],pMsg->KeyDesc.KeyData);
- }
- else
- {
- INT i;
- UCHAR Key[32];
- // Decrypt TKIP GTK
- // Construct 32 bytes RC4 Key
- NdisMoveMemory(Key, pMsg->KeyDesc.KeyIv, 16);
- NdisMoveMemory(&Key[16], &pEntry->PTK[16], 16);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
- //discard first 256 bytes
- for(i = 0; i < 256; i++)
- ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
- // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
- }
-
- if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
- GroupKeyIndex = EapolKeyInfo.KeyIndex;
-
- }
- else if ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3 && !bWPA2))
- {
- NdisMoveMemory(KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
- }
- else
- {
-
- return TRUE;
- }
-
- // Parse Key Data field to
- // 1. verify RSN IE for pairwise_msg_2_WPA1(WPA2) ,pairwise_msg_3_WPA1(WPA2)
- // 2. verify KDE format for pairwise_msg_3_WPA2, group_msg_1_WPA2
- // 3. update shared key for pairwise_msg_3_WPA2, group_msg_1_WPA1(WPA2)
- if (!RTMPParseEapolKeyData(pAd, KEYDATA, pMsg->KeyDesc.KeyDataLen[1], GroupKeyIndex, MsgType, bWPA2, pEntry))
- {
- return FALSE;
- }
- }
-
- return TRUE;
-
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN MlmeDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PRT_802_11_DLS *pDLS,
- OUT PUSHORT pReason)
-{
- MLME_DLS_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_DLS_REQ_STRUCT *)Msg;
-
- *pDLS = pInfo->pDLS;
- *pReason = pInfo->Reason;
-
- return TRUE;
-}
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN PeerDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pDlsTimeout,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
- PEID_STRUCT eid_ptr;
-
- // to prevent caller from using garbage output value
- *pCapabilityInfo = 0;
- *pDlsTimeout = 0;
- *pHtCapabilityLen = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pDlsTimeout, Ptr, 2);
- Ptr += 2;
-
- // Category and Action field + DA + SA + capability + Timeout
- eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
-
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_SUPP_RATES:
- if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
- {
- NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
- DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
- *pRatesLen = eid_ptr->Len;
- }
- else
- {
- *pRatesLen = 8;
- Rates[0] = 0x82;
- Rates[1] = 0x84;
- Rates[2] = 0x8b;
- Rates[3] = 0x96;
- Rates[4] = 0x12;
- Rates[5] = 0x24;
- Rates[6] = 0x48;
- Rates[7] = 0x6c;
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
- *pRatesLen = (*pRatesLen) + eid_ptr->Len;
- }
- else
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
- *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
- }
- break;
-
- case IE_HT_CAP:
- if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
- {
- NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
- *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_HT_CAP\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
- }
- break;
-
- default:
- break;
- }
-
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerDlsRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
- PEID_STRUCT eid_ptr;
-
- // to prevent caller from using garbage output value
- *pStatus = 0;
- *pCapabilityInfo = 0;
- *pHtCapabilityLen = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get status code from payload and advance the pointer
- NdisMoveMemory(pStatus, Ptr, 2);
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- if (pStatus == 0)
- {
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
- }
-
- // Category and Action field + status code + DA + SA + capability
- eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
-
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_SUPP_RATES:
- if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
- {
- NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
- DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
- *pRatesLen = eid_ptr->Len;
- }
- else
- {
- *pRatesLen = 8;
- Rates[0] = 0x82;
- Rates[1] = 0x84;
- Rates[2] = 0x8b;
- Rates[3] = 0x96;
- Rates[4] = 0x12;
- Rates[5] = 0x24;
- Rates[6] = 0x48;
- Rates[7] = 0x6c;
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
- *pRatesLen = (*pRatesLen) + eid_ptr->Len;
- }
- else
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
- *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
- }
- break;
-
- case IE_HT_CAP:
- if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
- {
- NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
- *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_HT_CAP\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
- }
- break;
-
- default:
- break;
- }
-
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerDlsTearDownSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pReason)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
-
- // to prevent caller from using garbage output value
- *pReason = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get reason code from payload and advance the pointer
- NdisMoveMemory(pReason, Ptr, 2);
- Ptr += 2;
-
- return TRUE;
-}
-#endif // QOS_DLS_SUPPORT //
-
+#include "../../rt2860/common/cmm_sanity.c"
diff --git a/drivers/staging/rt2870/common/cmm_sync.c b/drivers/staging/rt2870/common/cmm_sync.c
index 2be7c77a384e..5e7221d7cb27 100644
--- a/drivers/staging/rt2870/common/cmm_sync.c
+++ b/drivers/staging/rt2870/common/cmm_sync.c
@@ -1,711 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sync.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 modified for rt2561/2661
-*/
-#include "../rt_config.h"
-
-// 2.4 Ghz channel plan index in the TxPower arrays.
-#define BG_BAND_REGION_0_START 0 // 1,2,3,4,5,6,7,8,9,10,11
-#define BG_BAND_REGION_0_SIZE 11
-#define BG_BAND_REGION_1_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13
-#define BG_BAND_REGION_1_SIZE 13
-#define BG_BAND_REGION_2_START 9 // 10,11
-#define BG_BAND_REGION_2_SIZE 2
-#define BG_BAND_REGION_3_START 9 // 10,11,12,13
-#define BG_BAND_REGION_3_SIZE 4
-#define BG_BAND_REGION_4_START 13 // 14
-#define BG_BAND_REGION_4_SIZE 1
-#define BG_BAND_REGION_5_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
-#define BG_BAND_REGION_5_SIZE 14
-#define BG_BAND_REGION_6_START 2 // 3,4,5,6,7,8,9
-#define BG_BAND_REGION_6_SIZE 7
-#define BG_BAND_REGION_7_START 4 // 5,6,7,8,9,10,11,12,13
-#define BG_BAND_REGION_7_SIZE 9
-#define BG_BAND_REGION_31_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
-#define BG_BAND_REGION_31_SIZE 14
-
-// 5 Ghz channel plan index in the TxPower arrays.
-UCHAR A_BAND_REGION_0_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_1_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
-UCHAR A_BAND_REGION_2_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64};
-UCHAR A_BAND_REGION_3_CHANNEL_LIST[]={52, 56, 60, 64, 149, 153, 157, 161};
-UCHAR A_BAND_REGION_4_CHANNEL_LIST[]={149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_5_CHANNEL_LIST[]={149, 153, 157, 161};
-UCHAR A_BAND_REGION_6_CHANNEL_LIST[]={36, 40, 44, 48};
-UCHAR A_BAND_REGION_7_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_8_CHANNEL_LIST[]={52, 56, 60, 64};
-UCHAR A_BAND_REGION_9_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_10_CHANNEL_LIST[]={36, 40, 44, 48, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_11_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161};
-
-//BaSizeArray follows the 802.11n definition as MaxRxFactor. 2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8.
-UCHAR BaSizeArray[4] = {8,16,32,64};
-
-/*
- ==========================================================================
- Description:
- Update StaCfg->ChannelList[] according to 1) Country Region 2) RF IC type,
- and 3) PHY-mode user selected.
- The outcome is used by driver when doing site survey.
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID BuildChannelList(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i, j, index=0, num=0;
- PUCHAR pChannelList = NULL;
-
- NdisZeroMemory(pAd->ChannelList, MAX_NUM_OF_CHANNELS * sizeof(CHANNEL_TX_POWER));
-
- // if not 11a-only mode, channel list starts from 2.4Ghz band
- if ((pAd->CommonCfg.PhyMode != PHY_11A)
-#ifdef DOT11_N_SUPPORT
- && (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED) && (pAd->CommonCfg.PhyMode != PHY_11N_5G)
-#endif // DOT11_N_SUPPORT //
- )
- {
- switch (pAd->CommonCfg.CountryRegion & 0x7f)
- {
- case REGION_0_BG_BAND: // 1 -11
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_0_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_0_SIZE);
- index += BG_BAND_REGION_0_SIZE;
- break;
- case REGION_1_BG_BAND: // 1 - 13
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_1_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_1_SIZE);
- index += BG_BAND_REGION_1_SIZE;
- break;
- case REGION_2_BG_BAND: // 10 - 11
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_2_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_2_SIZE);
- index += BG_BAND_REGION_2_SIZE;
- break;
- case REGION_3_BG_BAND: // 10 - 13
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_3_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_3_SIZE);
- index += BG_BAND_REGION_3_SIZE;
- break;
- case REGION_4_BG_BAND: // 14
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_4_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_4_SIZE);
- index += BG_BAND_REGION_4_SIZE;
- break;
- case REGION_5_BG_BAND: // 1 - 14
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_5_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_5_SIZE);
- index += BG_BAND_REGION_5_SIZE;
- break;
- case REGION_6_BG_BAND: // 3 - 9
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_6_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_6_SIZE);
- index += BG_BAND_REGION_6_SIZE;
- break;
- case REGION_7_BG_BAND: // 5 - 13
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_7_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_7_SIZE);
- index += BG_BAND_REGION_7_SIZE;
- break;
- case REGION_31_BG_BAND: // 1 - 14
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_31_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_31_SIZE);
- index += BG_BAND_REGION_31_SIZE;
- break;
- default: // Error. should never happen
- break;
- }
- for (i=0; i<index; i++)
- pAd->ChannelList[i].MaxTxPwr = 20;
- }
-
- if ((pAd->CommonCfg.PhyMode == PHY_11A) || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-#ifdef DOT11_N_SUPPORT
- || (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
- || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)
-#endif // DOT11_N_SUPPORT //
- )
- {
- switch (pAd->CommonCfg.CountryRegionForABand & 0x7f)
- {
- case REGION_0_A_BAND:
- num = sizeof(A_BAND_REGION_0_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_0_CHANNEL_LIST;
- break;
- case REGION_1_A_BAND:
- num = sizeof(A_BAND_REGION_1_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_1_CHANNEL_LIST;
- break;
- case REGION_2_A_BAND:
- num = sizeof(A_BAND_REGION_2_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_2_CHANNEL_LIST;
- break;
- case REGION_3_A_BAND:
- num = sizeof(A_BAND_REGION_3_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_3_CHANNEL_LIST;
- break;
- case REGION_4_A_BAND:
- num = sizeof(A_BAND_REGION_4_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_4_CHANNEL_LIST;
- break;
- case REGION_5_A_BAND:
- num = sizeof(A_BAND_REGION_5_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_5_CHANNEL_LIST;
- break;
- case REGION_6_A_BAND:
- num = sizeof(A_BAND_REGION_6_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_6_CHANNEL_LIST;
- break;
- case REGION_7_A_BAND:
- num = sizeof(A_BAND_REGION_7_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_7_CHANNEL_LIST;
- break;
- case REGION_8_A_BAND:
- num = sizeof(A_BAND_REGION_8_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_8_CHANNEL_LIST;
- break;
- case REGION_9_A_BAND:
- num = sizeof(A_BAND_REGION_9_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_9_CHANNEL_LIST;
- break;
-
- case REGION_10_A_BAND:
- num = sizeof(A_BAND_REGION_10_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_10_CHANNEL_LIST;
- break;
-
- case REGION_11_A_BAND:
- num = sizeof(A_BAND_REGION_11_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
- break;
-
- default: // Error. should never happen
- DBGPRINT(RT_DEBUG_WARN,("countryregion=%d not support", pAd->CommonCfg.CountryRegionForABand));
- break;
- }
-
- if (num != 0)
- {
- UCHAR RadarCh[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
- for (i=0; i<num; i++)
- {
- for (j=0; j<MAX_NUM_OF_CHANNELS; j++)
- {
- if (pChannelList[i] == pAd->TxPower[j].Channel)
- NdisMoveMemory(&pAd->ChannelList[index+i], &pAd->TxPower[j], sizeof(CHANNEL_TX_POWER));
- }
- for (j=0; j<15; j++)
- {
- if (pChannelList[i] == RadarCh[j])
- pAd->ChannelList[index+i].DfsReq = TRUE;
- }
- pAd->ChannelList[index+i].MaxTxPwr = 20;
- }
- index += num;
- }
- }
-
- pAd->ChannelListNum = index;
- DBGPRINT(RT_DEBUG_TRACE,("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
- pAd->CommonCfg.CountryRegion, pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType, pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
-#ifdef DBG
- for (i=0;i<pAd->ChannelListNum;i++)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE,("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ", pAd->ChannelList[i].Channel, pAd->ChannelList[i].Power, pAd->ChannelList[i].Power2));
- }
-#endif
-}
-
-/*
- ==========================================================================
- Description:
- This routine return the first channel number according to the country
- code selection and RF IC selection (signal band or dual band). It is called
- whenever driver need to start a site survey of all supported channels.
- Return:
- ch - the first channel number of current country code setting
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-UCHAR FirstChannel(
- IN PRTMP_ADAPTER pAd)
-{
- return pAd->ChannelList[0].Channel;
-}
-
-/*
- ==========================================================================
- Description:
- This routine returns the next channel number. This routine is called
- during driver need to start a site survey of all supported channels.
- Return:
- next_channel - the next channel number valid in current country code setting.
- Note:
- return 0 if no more next channel
- ==========================================================================
- */
-UCHAR NextChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel)
-{
- int i;
- UCHAR next_channel = 0;
-
- for (i = 0; i < (pAd->ChannelListNum - 1); i++)
- if (channel == pAd->ChannelList[i].Channel)
- {
- next_channel = pAd->ChannelList[i+1].Channel;
- break;
- }
- return next_channel;
-}
-
-/*
- ==========================================================================
- Description:
- This routine is for Cisco Compatible Extensions 2.X
- Spec31. AP Control of Client Transmit Power
- Return:
- None
- Note:
- Required by Aironet dBm(mW)
- 0dBm(1mW), 1dBm(5mW), 13dBm(20mW), 15dBm(30mW),
- 17dBm(50mw), 20dBm(100mW)
-
- We supported
- 3dBm(Lowest), 6dBm(10%), 9dBm(25%), 12dBm(50%),
- 14dBm(75%), 15dBm(100%)
-
- The client station's actual transmit power shall be within +/- 5dB of
- the minimum value or next lower value.
- ==========================================================================
- */
-VOID ChangeToCellPowerLimit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AironetCellPowerLimit)
-{
- //valud 0xFF means that hasn't found power limit information
- //from the AP's Beacon/Probe response.
- if (AironetCellPowerLimit == 0xFF)
- return;
-
- if (AironetCellPowerLimit < 6) //Used Lowest Power Percentage.
- pAd->CommonCfg.TxPowerPercentage = 6;
- else if (AironetCellPowerLimit < 9)
- pAd->CommonCfg.TxPowerPercentage = 10;
- else if (AironetCellPowerLimit < 12)
- pAd->CommonCfg.TxPowerPercentage = 25;
- else if (AironetCellPowerLimit < 14)
- pAd->CommonCfg.TxPowerPercentage = 50;
- else if (AironetCellPowerLimit < 15)
- pAd->CommonCfg.TxPowerPercentage = 75;
- else
- pAd->CommonCfg.TxPowerPercentage = 100; //else used maximum
-
- if (pAd->CommonCfg.TxPowerPercentage > pAd->CommonCfg.TxPowerDefault)
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
-
-}
-
-CHAR ConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- LNAGain = GET_LNA_GAIN(pAd);
- if (pAd->LatchRfRegs.Channel > 14)
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-12 - RssiOffset - LNAGain - Rssi);
-}
-
-/*
- ==========================================================================
- Description:
- Scan next channel
- ==========================================================================
- */
-VOID ScanNextChannel(
- IN PRTMP_ADAPTER pAd)
-{
- HEADER_802_11 Hdr80211;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- UCHAR SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
-#ifdef CONFIG_STA_SUPPORT
- USHORT Status;
- PHEADER_802_11 pHdr80211;
-#endif // CONFIG_STA_SUPPORT //
- UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (MONITOR_ON(pAd))
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- if (pAd->MlmeAux.Channel == 0)
- {
- if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
-#ifdef CONFIG_STA_SUPPORT
- && (INFRA_ON(pAd)
- || (pAd->OpMode == OPMODE_AP))
-#endif // CONFIG_STA_SUPPORT //
- )
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
- }
- else
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //
- // To prevent data lost.
- // Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
- // Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done
- //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
- {
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- pHdr80211 = (PHEADER_802_11) pOutBuffer;
- MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pHdr80211->Duration = 0;
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame\n"));
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPusecDelay(5000);
- }
- }
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- }
-#ifdef RT2870
-#ifdef CONFIG_STA_SUPPORT
- else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->OpMode == OPMODE_STA))
- {
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
- }
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
- else
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // BBP and RF are not accessible in PS mode, we has to wake them up first
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- AsicForceWakeup(pAd, TRUE);
-
- // leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON
- if (pAd->StaCfg.Psm == PWR_SAVE)
- MlmeSetPsmBit(pAd, PWR_ACTIVE);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, TRUE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->MlmeAux.Channel > 14)
- {
- if ((pAd->CommonCfg.bIEEE80211H == 1) && RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
- {
- ScanType = SCAN_PASSIVE;
- ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
- }
- }
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // carrier detection
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- ScanType = SCAN_PASSIVE;
- ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
- }
-#endif // CARRIER_DETECTION_SUPPORT //
- }
-
-#endif // CONFIG_STA_SUPPORT //
-
- //Global country domain(ch1-11:active scan, ch12-14 passive scan)
- if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12) && ((pAd->CommonCfg.CountryRegion & 0x7f) == REGION_31_BG_BAND))
- {
- ScanType = SCAN_PASSIVE;
- }
-
- // We need to shorten active scan time in order for WZC connect issue
- // Chnage the channel scan time for CISCO stuff based on its IAPP announcement
- if (ScanType == FAST_SCAN_ACTIVE)
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, FAST_ACTIVE_SCAN_TIME);
-#ifdef CONFIG_STA_SUPPORT
- else if (((ScanType == SCAN_CISCO_ACTIVE) ||
- (ScanType == SCAN_CISCO_PASSIVE) ||
- (ScanType == SCAN_CISCO_CHANNEL_LOAD) ||
- (ScanType == SCAN_CISCO_NOISE)) && (pAd->OpMode == OPMODE_STA))
- {
- if (pAd->StaCfg.CCXScanTime < 25)
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime * 2);
- else
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime);
- }
-#endif // CONFIG_STA_SUPPORT //
- else // must be SCAN_PASSIVE or SCAN_ACTIVE
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-#ifdef DOT11_N_SUPPORT
- || (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
-#endif // DOT11_N_SUPPORT //
- )
- {
- if (pAd->MlmeAux.Channel > 14)
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, ScanTimeIn5gChannel);
- else
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MIN_CHANNEL_TIME);
- }
- else
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MAX_CHANNEL_TIME);
- }
-
- if ((ScanType == SCAN_ACTIVE) || (ScanType == FAST_SCAN_ACTIVE) ||
- (ScanType == SCAN_CISCO_ACTIVE))
- {
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - ScanNextChannel() allocate memory fail\n"));
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return;
- }
-
- // There is no need to send broadcast probe request if active scan is in effect.
- if ((ScanType == SCAN_ACTIVE) || (ScanType == FAST_SCAN_ACTIVE)
- )
- SsidLen = pAd->MlmeAux.SsidLen;
- else
- SsidLen = 0;
-
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &SsidLen,
- SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &pAd->CommonCfg.SupRateLen,
- pAd->CommonCfg.SupRateLen, pAd->CommonCfg.SupRate,
- END_OF_ARGS);
-
- if (pAd->CommonCfg.ExtRateLen)
- {
- ULONG Tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtRateIe,
- 1, &pAd->CommonCfg.ExtRateLen,
- pAd->CommonCfg.ExtRateLen, pAd->CommonCfg.ExtRate,
- END_OF_ARGS);
- FrameLen += Tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- ULONG Tmp;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
- if (pAd->bBroadComHT == TRUE)
- {
- HtLen = pAd->MlmeAux.HtCapabilityLen + 4;
-#ifdef RT_BIG_ENDIAN
- NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#else
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
-#endif // RT_BIG_ENDIAN //
- }
- else
- {
- HtLen = pAd->MlmeAux.HtCapabilityLen;
-#ifdef RT_BIG_ENDIAN
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, SIZE_HT_CAP_IE);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#else
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#endif // RT_BIG_ENDIAN //
- }
- FrameLen += Tmp;
-
-#ifdef DOT11N_DRAFT3
- if (pAd->CommonCfg.BACapability.field.b2040CoexistScanSup == 1)
- {
- ULONG Tmp;
- HtLen = 1;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtHtCapIe,
- 1, &HtLen,
- 1, &pAd->CommonCfg.BSSCoexist2040.word,
- END_OF_ARGS);
-
- FrameLen += Tmp;
- }
-#endif // DOT11N_DRAFT3 //
- }
-#endif // DOT11_N_SUPPORT //
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
-
- // For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe reponse
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
-#endif // CONFIG_STA_SUPPORT //
-
- }
-}
-
-VOID MgtProbReqMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR SubType,
- IN UCHAR ToDs,
- IN PUCHAR pDA,
- IN PUCHAR pBssid)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-
- pHdr80211->FC.Type = BTYPE_MGMT;
- pHdr80211->FC.SubType = SubType;
- if (SubType == SUBTYPE_ACK)
- pHdr80211->FC.Type = BTYPE_CNTL;
- pHdr80211->FC.ToDs = ToDs;
- COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
-}
-
-
+#include "../../rt2860/common/cmm_sync.c"
diff --git a/drivers/staging/rt2870/common/cmm_wpa.c b/drivers/staging/rt2870/common/cmm_wpa.c
index d2c24bd49e75..04a54bb21853 100644
--- a/drivers/staging/rt2870/common/cmm_wpa.c
+++ b/drivers/staging/rt2870/common/cmm_wpa.c
@@ -1,1654 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- wpa.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 03-07-22 Initial
- Paul Lin 03-11-28 Modify for supplicant
-*/
-#include "../rt_config.h"
-// WPA OUI
-UCHAR OUI_WPA_NONE_AKM[4] = {0x00, 0x50, 0xF2, 0x00};
-UCHAR OUI_WPA_VERSION[4] = {0x00, 0x50, 0xF2, 0x01};
-UCHAR OUI_WPA_WEP40[4] = {0x00, 0x50, 0xF2, 0x01};
-UCHAR OUI_WPA_TKIP[4] = {0x00, 0x50, 0xF2, 0x02};
-UCHAR OUI_WPA_CCMP[4] = {0x00, 0x50, 0xF2, 0x04};
-UCHAR OUI_WPA_WEP104[4] = {0x00, 0x50, 0xF2, 0x05};
-UCHAR OUI_WPA_8021X_AKM[4] = {0x00, 0x50, 0xF2, 0x01};
-UCHAR OUI_WPA_PSK_AKM[4] = {0x00, 0x50, 0xF2, 0x02};
-// WPA2 OUI
-UCHAR OUI_WPA2_WEP40[4] = {0x00, 0x0F, 0xAC, 0x01};
-UCHAR OUI_WPA2_TKIP[4] = {0x00, 0x0F, 0xAC, 0x02};
-UCHAR OUI_WPA2_CCMP[4] = {0x00, 0x0F, 0xAC, 0x04};
-UCHAR OUI_WPA2_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x01};
-UCHAR OUI_WPA2_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x02};
-UCHAR OUI_WPA2_WEP104[4] = {0x00, 0x0F, 0xAC, 0x05};
-// MSA OUI
-UCHAR OUI_MSA_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x05}; // Not yet final - IEEE 802.11s-D1.06
-UCHAR OUI_MSA_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x06}; // Not yet final - IEEE 802.11s-D1.06
-
-/*
- ========================================================================
-
- Routine Description:
- The pseudo-random function(PRF) that hashes various inputs to
- derive a pseudo-random value. To add liveness to the pseudo-random
- value, a nonce should be one of the inputs.
-
- It is used to generate PTK, GTK or some specific random value.
-
- Arguments:
- UCHAR *key, - the key material for HMAC_SHA1 use
- INT key_len - the length of key
- UCHAR *prefix - a prefix label
- INT prefix_len - the length of the label
- UCHAR *data - a specific data with variable length
- INT data_len - the length of a specific data
- INT len - the output lenght
-
- Return Value:
- UCHAR *output - the calculated result
-
- Note:
- 802.11i-2004 Annex H.3
-
- ========================================================================
-*/
-VOID PRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *prefix,
- IN INT prefix_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len)
-{
- INT i;
- UCHAR *input;
- INT currentindex = 0;
- INT total_len;
-
- // Allocate memory for input
- os_alloc_mem(NULL, (PUCHAR *)&input, 1024);
-
- if (input == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!!PRF: no memory!!!\n"));
- return;
- }
-
- // Generate concatenation input
- NdisMoveMemory(input, prefix, prefix_len);
-
- // Concatenate a single octet containing 0
- input[prefix_len] = 0;
-
- // Concatenate specific data
- NdisMoveMemory(&input[prefix_len + 1], data, data_len);
- total_len = prefix_len + 1 + data_len;
-
- // Concatenate a single octet containing 0
- // This octet shall be update later
- input[total_len] = 0;
- total_len++;
-
- // Iterate to calculate the result by hmac-sha-1
- // Then concatenate to last result
- for (i = 0; i < (len + 19) / 20; i++)
- {
- HMAC_SHA1(input, total_len, key, key_len, &output[currentindex]);
- currentindex += 20;
-
- // update the last octet
- input[total_len - 1]++;
- }
- os_free_mem(NULL, input);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- It utilizes PRF-384 or PRF-512 to derive session-specific keys from a PMK.
- It shall be called by 4-way handshake processing.
-
- Arguments:
- pAd - pointer to our pAdapter context
- PMK - pointer to PMK
- ANonce - pointer to ANonce
- AA - pointer to Authenticator Address
- SNonce - pointer to SNonce
- SA - pointer to Supplicant Address
- len - indicate the length of PTK (octet)
-
- Return Value:
- Output pointer to the PTK
-
- Note:
- Refer to IEEE 802.11i-2004 8.5.1.2
-
- ========================================================================
-*/
-VOID WpaCountPTK(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *PMK,
- IN UCHAR *ANonce,
- IN UCHAR *AA,
- IN UCHAR *SNonce,
- IN UCHAR *SA,
- OUT UCHAR *output,
- IN UINT len)
-{
- UCHAR concatenation[76];
- UINT CurrPos = 0;
- UCHAR temp[32];
- UCHAR Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
- 'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n'};
-
- // initiate the concatenation input
- NdisZeroMemory(temp, sizeof(temp));
- NdisZeroMemory(concatenation, 76);
-
- // Get smaller address
- if (RTMPCompareMemory(SA, AA, 6) == 1)
- NdisMoveMemory(concatenation, AA, 6);
- else
- NdisMoveMemory(concatenation, SA, 6);
- CurrPos += 6;
-
- // Get larger address
- if (RTMPCompareMemory(SA, AA, 6) == 1)
- NdisMoveMemory(&concatenation[CurrPos], SA, 6);
- else
- NdisMoveMemory(&concatenation[CurrPos], AA, 6);
-
- // store the larger mac address for backward compatible of
- // ralink proprietary STA-key issue
- NdisMoveMemory(temp, &concatenation[CurrPos], MAC_ADDR_LEN);
- CurrPos += 6;
-
- // Get smaller Nonce
- if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
- NdisMoveMemory(&concatenation[CurrPos], temp, 32); // patch for ralink proprietary STA-key issue
- else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
- NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
- else
- NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
- CurrPos += 32;
-
- // Get larger Nonce
- if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
- NdisMoveMemory(&concatenation[CurrPos], temp, 32); // patch for ralink proprietary STA-key issue
- else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
- NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
- else
- NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
- CurrPos += 32;
-
- hex_dump("concatenation=", concatenation, 76);
-
- // Use PRF to generate PTK
- PRF(PMK, LEN_MASTER_KEY, Prefix, 22, concatenation, 76, output, len);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Generate random number by software.
-
- Arguments:
- pAd - pointer to our pAdapter context
- macAddr - pointer to local MAC address
-
- Return Value:
-
- Note:
- 802.1ii-2004 Annex H.5
-
- ========================================================================
-*/
-VOID GenRandom(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *macAddr,
- OUT UCHAR *random)
-{
- INT i, curr;
- UCHAR local[80], KeyCounter[32];
- UCHAR result[80];
- ULONG CurrentTime;
- UCHAR prefix[] = {'I', 'n', 'i', 't', ' ', 'C', 'o', 'u', 'n', 't', 'e', 'r'};
-
- // Zero the related information
- NdisZeroMemory(result, 80);
- NdisZeroMemory(local, 80);
- NdisZeroMemory(KeyCounter, 32);
-
- for (i = 0; i < 32; i++)
- {
- // copy the local MAC address
- COPY_MAC_ADDR(local, macAddr);
- curr = MAC_ADDR_LEN;
-
- // concatenate the current time
- NdisGetSystemUpTime(&CurrentTime);
- NdisMoveMemory(&local[curr], &CurrentTime, sizeof(CurrentTime));
- curr += sizeof(CurrentTime);
-
- // concatenate the last result
- NdisMoveMemory(&local[curr], result, 32);
- curr += 32;
-
- // concatenate a variable
- NdisMoveMemory(&local[curr], &i, 2);
- curr += 2;
-
- // calculate the result
- PRF(KeyCounter, 32, prefix,12, local, curr, result, 32);
- }
-
- NdisMoveMemory(random, result, 32);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Build cipher suite in RSN-IE.
- It only shall be called by RTMPMakeRSNIE.
-
- Arguments:
- pAd - pointer to our pAdapter context
- ElementID - indicate the WPA1 or WPA2
- WepStatus - indicate the encryption type
- bMixCipher - a boolean to indicate the pairwise cipher and group
- cipher are the same or not
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-static VOID RTMPInsertRsnIeCipher(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR ElementID,
- IN UINT WepStatus,
- IN BOOLEAN bMixCipher,
- IN UCHAR FlexibleCipher,
- OUT PUCHAR pRsnIe,
- OUT UCHAR *rsn_len)
-{
- UCHAR PairwiseCnt;
-
- *rsn_len = 0;
-
- // decide WPA2 or WPA1
- if (ElementID == Wpa2Ie)
- {
- RSNIE2 *pRsnie_cipher = (RSNIE2*)pRsnIe;
-
- // Assign the verson as 1
- pRsnie_cipher->version = 1;
-
- switch (WepStatus)
- {
- // TKIP mode
- case Ndis802_11Encryption2Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
- *rsn_len = sizeof(RSNIE2);
- break;
-
- // AES mode
- case Ndis802_11Encryption3Enabled:
- if (bMixCipher)
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
- else
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_CCMP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
- *rsn_len = sizeof(RSNIE2);
- break;
-
- // TKIP-AES mix mode
- case Ndis802_11Encryption4Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
-
- PairwiseCnt = 1;
- // Insert WPA2 TKIP as the first pairwise cipher
- if (MIX_CIPHER_WPA2_TKIP_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
- // Insert WPA2 AES as the secondary pairwise cipher
- if (MIX_CIPHER_WPA2_AES_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA2_CCMP, 4);
- PairwiseCnt = 2;
- }
- }
- else
- {
- // Insert WPA2 AES as the first pairwise cipher
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
- }
-
- pRsnie_cipher->ucount = PairwiseCnt;
- *rsn_len = sizeof(RSNIE2) + (4 * (PairwiseCnt - 1));
- break;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- if ((pAd->OpMode == OPMODE_STA) &&
- (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled))
- {
- UINT GroupCipher = pAd->StaCfg.GroupCipher;
- switch(GroupCipher)
- {
- case Ndis802_11GroupWEP40Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_WEP40, 4);
- break;
- case Ndis802_11GroupWEP104Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_WEP104, 4);
- break;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // swap for big-endian platform
- pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
- pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
- }
- else
- {
- RSNIE *pRsnie_cipher = (RSNIE*)pRsnIe;
-
- // Assign OUI and version
- NdisMoveMemory(pRsnie_cipher->oui, OUI_WPA_VERSION, 4);
- pRsnie_cipher->version = 1;
-
- switch (WepStatus)
- {
- // TKIP mode
- case Ndis802_11Encryption2Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
- *rsn_len = sizeof(RSNIE);
- break;
-
- // AES mode
- case Ndis802_11Encryption3Enabled:
- if (bMixCipher)
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
- else
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_CCMP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
- *rsn_len = sizeof(RSNIE);
- break;
-
- // TKIP-AES mix mode
- case Ndis802_11Encryption4Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
-
- PairwiseCnt = 1;
- // Insert WPA TKIP as the first pairwise cipher
- if (MIX_CIPHER_WPA_TKIP_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
- // Insert WPA AES as the secondary pairwise cipher
- if (MIX_CIPHER_WPA_AES_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA_CCMP, 4);
- PairwiseCnt = 2;
- }
- }
- else
- {
- // Insert WPA AES as the first pairwise cipher
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
- }
-
- pRsnie_cipher->ucount = PairwiseCnt;
- *rsn_len = sizeof(RSNIE) + (4 * (PairwiseCnt - 1));
- break;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- if ((pAd->OpMode == OPMODE_STA) &&
- (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled))
- {
- UINT GroupCipher = pAd->StaCfg.GroupCipher;
- switch(GroupCipher)
- {
- case Ndis802_11GroupWEP40Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_WEP40, 4);
- break;
- case Ndis802_11GroupWEP104Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_WEP104, 4);
- break;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // swap for big-endian platform
- pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
- pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Build AKM suite in RSN-IE.
- It only shall be called by RTMPMakeRSNIE.
-
- Arguments:
- pAd - pointer to our pAdapter context
- ElementID - indicate the WPA1 or WPA2
- AuthMode - indicate the authentication mode
- apidx - indicate the interface index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-static VOID RTMPInsertRsnIeAKM(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR ElementID,
- IN UINT AuthMode,
- IN UCHAR apidx,
- OUT PUCHAR pRsnIe,
- OUT UCHAR *rsn_len)
-{
- RSNIE_AUTH *pRsnie_auth;
-
- pRsnie_auth = (RSNIE_AUTH*)(pRsnIe + (*rsn_len));
-
- // decide WPA2 or WPA1
- if (ElementID == Wpa2Ie)
- {
- switch (AuthMode)
- {
- case Ndis802_11AuthModeWPA2:
- case Ndis802_11AuthModeWPA1WPA2:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_8021X_AKM, 4);
- break;
-
- case Ndis802_11AuthModeWPA2PSK:
- case Ndis802_11AuthModeWPA1PSKWPA2PSK:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_PSK_AKM, 4);
- break;
- }
- }
- else
- {
- switch (AuthMode)
- {
- case Ndis802_11AuthModeWPA:
- case Ndis802_11AuthModeWPA1WPA2:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_8021X_AKM, 4);
- break;
-
- case Ndis802_11AuthModeWPAPSK:
- case Ndis802_11AuthModeWPA1PSKWPA2PSK:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_PSK_AKM, 4);
- break;
-
- case Ndis802_11AuthModeWPANone:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_NONE_AKM, 4);
- break;
- }
- }
-
- pRsnie_auth->acount = cpu2le16(pRsnie_auth->acount);
-
- (*rsn_len) += sizeof(RSNIE_AUTH); // update current RSNIE length
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Build capability in RSN-IE.
- It only shall be called by RTMPMakeRSNIE.
-
- Arguments:
- pAd - pointer to our pAdapter context
- ElementID - indicate the WPA1 or WPA2
- apidx - indicate the interface index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-static VOID RTMPInsertRsnIeCap(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR ElementID,
- IN UCHAR apidx,
- OUT PUCHAR pRsnIe,
- OUT UCHAR *rsn_len)
-{
- RSN_CAPABILITIES *pRSN_Cap;
-
- // it could be ignored in WPA1 mode
- if (ElementID == WpaIe)
- return;
-
- pRSN_Cap = (RSN_CAPABILITIES*)(pRsnIe + (*rsn_len));
-
-
- pRSN_Cap->word = cpu2le16(pRSN_Cap->word);
-
- (*rsn_len) += sizeof(RSN_CAPABILITIES); // update current RSNIE length
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Build RSN IE context. It is not included element-ID and length.
-
- Arguments:
- pAd - pointer to our pAdapter context
- AuthMode - indicate the authentication mode
- WepStatus - indicate the encryption type
- apidx - indicate the interface index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPMakeRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN UINT AuthMode,
- IN UINT WepStatus,
- IN UCHAR apidx)
-{
- PUCHAR pRsnIe = NULL; // primary RSNIE
- UCHAR *rsnielen_cur_p = 0; // the length of the primary RSNIE
- UCHAR *rsnielen_ex_cur_p = 0; // the length of the secondary RSNIE
- UCHAR PrimaryRsnie;
- BOOLEAN bMixCipher = FALSE; // indicate the pairwise and group cipher are different
- UCHAR p_offset;
- WPA_MIX_PAIR_CIPHER FlexibleCipher = MIX_CIPHER_NOTUSE; // it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode
-
- rsnielen_cur_p = NULL;
- rsnielen_ex_cur_p = NULL;
-
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- if (AuthMode < Ndis802_11AuthModeWPA)
- return;
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // Support WPAPSK or WPA2PSK in STA-Infra mode
- // Support WPANone in STA-Adhoc mode
- if ((AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (AuthMode != Ndis802_11AuthModeWPANone)
- )
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("==> RTMPMakeRSNIE(STA)\n"));
-
- // Zero RSNIE context
- pAd->StaCfg.RSNIE_Len = 0;
- NdisZeroMemory(pAd->StaCfg.RSN_IE, MAX_LEN_OF_RSNIE);
-
- // Pointer to RSNIE
- rsnielen_cur_p = &pAd->StaCfg.RSNIE_Len;
- pRsnIe = pAd->StaCfg.RSN_IE;
-
- bMixCipher = pAd->StaCfg.bMixCipher;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // indicate primary RSNIE as WPA or WPA2
- if ((AuthMode == Ndis802_11AuthModeWPA) ||
- (AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (AuthMode == Ndis802_11AuthModeWPANone) ||
- (AuthMode == Ndis802_11AuthModeWPA1WPA2) ||
- (AuthMode == Ndis802_11AuthModeWPA1PSKWPA2PSK))
- PrimaryRsnie = WpaIe;
- else
- PrimaryRsnie = Wpa2Ie;
-
- {
- // Build the primary RSNIE
- // 1. insert cipher suite
- RTMPInsertRsnIeCipher(pAd, PrimaryRsnie, WepStatus, bMixCipher, FlexibleCipher, pRsnIe, &p_offset);
-
- // 2. insert AKM
- RTMPInsertRsnIeAKM(pAd, PrimaryRsnie, AuthMode, apidx, pRsnIe, &p_offset);
-
- // 3. insert capability
- RTMPInsertRsnIeCap(pAd, PrimaryRsnie, apidx, pRsnIe, &p_offset);
- }
-
- // 4. update the RSNIE length
- *rsnielen_cur_p = p_offset;
-
- hex_dump("The primary RSNIE", pRsnIe, (*rsnielen_cur_p));
-
-
-}
-
-/*
- ==========================================================================
- Description:
- Check whether the received frame is EAP frame.
-
- Arguments:
- pAd - pointer to our pAdapter context
- pEntry - pointer to active entry
- pData - the received frame
- DataByteCount - the received frame's length
- FromWhichBSSID - indicate the interface index
-
- Return:
- TRUE - This frame is EAP frame
- FALSE - otherwise
- ==========================================================================
-*/
-BOOLEAN RTMPCheckWPAframe(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR pData,
- IN ULONG DataByteCount,
- IN UCHAR FromWhichBSSID)
-{
- ULONG Body_len;
- BOOLEAN Cancelled;
-
-
- if(DataByteCount < (LENGTH_802_1_H + LENGTH_EAPOL_H))
- return FALSE;
-
-
- // Skip LLC header
- if (NdisEqualMemory(SNAP_802_1H, pData, 6) ||
- // Cisco 1200 AP may send packet with SNAP_BRIDGE_TUNNEL
- NdisEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6))
- {
- pData += 6;
- }
- // Skip 2-bytes EAPoL type
- if (NdisEqualMemory(EAPOL, pData, 2))
- {
- pData += 2;
- }
- else
- return FALSE;
-
- switch (*(pData+1))
- {
- case EAPPacket:
- Body_len = (*(pData+2)<<8) | (*(pData+3));
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAP-Packet frame, TYPE = 0, Length = %ld\n", Body_len));
- break;
- case EAPOLStart:
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Start frame, TYPE = 1 \n"));
- if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Cancel the EnqueueEapolStartTimerRunning \n"));
- RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
- pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
- }
- break;
- case EAPOLLogoff:
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLLogoff frame, TYPE = 2 \n"));
- break;
- case EAPOLKey:
- Body_len = (*(pData+2)<<8) | (*(pData+3));
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Key frame, TYPE = 3, Length = %ld\n", Body_len));
- break;
- case EAPOLASFAlert:
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLASFAlert frame, TYPE = 4 \n"));
- break;
- default:
- return FALSE;
-
- }
- return TRUE;
-}
-
-
-/*
- ==========================================================================
- Description:
- ENCRYPT AES GTK before sending in EAPOL frame.
- AES GTK length = 128 bit, so fix blocks for aes-key-wrap as 2 in this function.
- This function references to RFC 3394 for aes key wrap algorithm.
- Return:
- ==========================================================================
-*/
-VOID AES_GTK_KEY_WRAP(
- IN UCHAR *key,
- IN UCHAR *plaintext,
- IN UCHAR p_len,
- OUT UCHAR *ciphertext)
-{
- UCHAR A[8], BIN[16], BOUT[16];
- UCHAR R[512];
- INT num_blocks = p_len/8; // unit:64bits
- INT i, j;
- aes_context aesctx;
- UCHAR xor;
-
- rtmp_aes_set_key(&aesctx, key, 128);
-
- // Init IA
- for (i = 0; i < 8; i++)
- A[i] = 0xa6;
-
- //Input plaintext
- for (i = 0; i < num_blocks; i++)
- {
- for (j = 0 ; j < 8; j++)
- R[8 * (i + 1) + j] = plaintext[8 * i + j];
- }
-
- // Key Mix
- for (j = 0; j < 6; j++)
- {
- for(i = 1; i <= num_blocks; i++)
- {
- //phase 1
- NdisMoveMemory(BIN, A, 8);
- NdisMoveMemory(&BIN[8], &R[8 * i], 8);
- rtmp_aes_encrypt(&aesctx, BIN, BOUT);
-
- NdisMoveMemory(A, &BOUT[0], 8);
- xor = num_blocks * j + i;
- A[7] = BOUT[7] ^ xor;
- NdisMoveMemory(&R[8 * i], &BOUT[8], 8);
- }
- }
-
- // Output ciphertext
- NdisMoveMemory(ciphertext, A, 8);
-
- for (i = 1; i <= num_blocks; i++)
- {
- for (j = 0 ; j < 8; j++)
- ciphertext[8 * i + j] = R[8 * i + j];
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Misc function to decrypt AES body
-
- Arguments:
-
- Return Value:
-
- Note:
- This function references to RFC 3394 for aes key unwrap algorithm.
-
- ========================================================================
-*/
-VOID AES_GTK_KEY_UNWRAP(
- IN UCHAR *key,
- OUT UCHAR *plaintext,
- IN UCHAR c_len,
- IN UCHAR *ciphertext)
-
-{
- UCHAR A[8], BIN[16], BOUT[16];
- UCHAR xor;
- INT i, j;
- aes_context aesctx;
- UCHAR *R;
- INT num_blocks = c_len/8; // unit:64bits
-
-
- os_alloc_mem(NULL, (PUCHAR *)&R, 512);
-
- if (R == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!!AES_GTK_KEY_UNWRAP: no memory!!!\n"));
- return;
- } /* End of if */
-
- // Initialize
- NdisMoveMemory(A, ciphertext, 8);
- //Input plaintext
- for(i = 0; i < (c_len-8); i++)
- {
- R[ i] = ciphertext[i + 8];
- }
-
- rtmp_aes_set_key(&aesctx, key, 128);
-
- for(j = 5; j >= 0; j--)
- {
- for(i = (num_blocks-1); i > 0; i--)
- {
- xor = (num_blocks -1 )* j + i;
- NdisMoveMemory(BIN, A, 8);
- BIN[7] = A[7] ^ xor;
- NdisMoveMemory(&BIN[8], &R[(i-1)*8], 8);
- rtmp_aes_decrypt(&aesctx, BIN, BOUT);
- NdisMoveMemory(A, &BOUT[0], 8);
- NdisMoveMemory(&R[(i-1)*8], &BOUT[8], 8);
- }
- }
-
- // OUTPUT
- for(i = 0; i < c_len; i++)
- {
- plaintext[i] = R[i];
- }
-
-
- os_free_mem(NULL, R);
-}
-
-/*
- ==========================================================================
- Description:
- Report the EAP message type
-
- Arguments:
- msg - EAPOL_PAIR_MSG_1
- EAPOL_PAIR_MSG_2
- EAPOL_PAIR_MSG_3
- EAPOL_PAIR_MSG_4
- EAPOL_GROUP_MSG_1
- EAPOL_GROUP_MSG_2
-
- Return:
- message type string
-
- ==========================================================================
-*/
-CHAR *GetEapolMsgType(CHAR msg)
-{
- if(msg == EAPOL_PAIR_MSG_1)
- return "Pairwise Message 1";
- else if(msg == EAPOL_PAIR_MSG_2)
- return "Pairwise Message 2";
- else if(msg == EAPOL_PAIR_MSG_3)
- return "Pairwise Message 3";
- else if(msg == EAPOL_PAIR_MSG_4)
- return "Pairwise Message 4";
- else if(msg == EAPOL_GROUP_MSG_1)
- return "Group Message 1";
- else if(msg == EAPOL_GROUP_MSG_2)
- return "Group Message 2";
- else
- return "Invalid Message";
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check Sanity RSN IE of EAPoL message
-
- Arguments:
-
- Return Value:
-
-
- ========================================================================
-*/
-BOOLEAN RTMPCheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- IN MAC_TABLE_ENTRY *pEntry,
- OUT UCHAR *Offset)
-{
- PUCHAR pVIE;
- UCHAR len;
- PEID_STRUCT pEid;
- BOOLEAN result = FALSE;
-
- pVIE = pData;
- len = DataLen;
- *Offset = 0;
-
- while (len > sizeof(RSNIE2))
- {
- pEid = (PEID_STRUCT) pVIE;
- // WPA RSN IE
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
- {
- if ((pEntry->AuthMode == Ndis802_11AuthModeWPA || pEntry->AuthMode == Ndis802_11AuthModeWPAPSK) &&
- (NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
- (pEntry->RSNIE_Len == (pEid->Len + 2)))
- {
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- // WPA2 RSN IE
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
- {
- if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2 || pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK) &&
- (NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
- (pEntry->RSNIE_Len == (pEid->Len + 2))/* ToDo-AlbertY for mesh*/)
- {
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- else
- {
- break;
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
-
-
- return result;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Parse KEYDATA field. KEYDATA[] May contain 2 RSN IE and optionally GTK.
- GTK is encaptulated in KDE format at p.83 802.11i D10
-
- Arguments:
-
- Return Value:
-
- Note:
- 802.11i D10
-
- ========================================================================
-*/
-BOOLEAN RTMPParseEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR GroupKeyIndex,
- IN UCHAR MsgType,
- IN BOOLEAN bWPA2,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- PKDE_ENCAP pKDE = NULL;
- PUCHAR pMyKeyData = pKeyData;
- UCHAR KeyDataLength = KeyDataLen;
- UCHAR GTKLEN = 0;
- UCHAR DefaultIdx = 0;
- UCHAR skip_offset;
-
- // Verify The RSN IE contained in pairewise_msg_2 && pairewise_msg_3 and skip it
- if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_3)
- {
- // Check RSN IE whether it is WPA2/WPA2PSK
- if (!RTMPCheckRSNIE(pAd, pKeyData, KeyDataLen, pEntry, &skip_offset))
- {
- // send wireless event - for RSN IE different
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_RSNIE_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
-
- DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in msg %d of 4-way handshake!\n", MsgType));
- hex_dump("Receive RSN_IE ", pKeyData, KeyDataLen);
- hex_dump("Desired RSN_IE ", pEntry->RSN_IE, pEntry->RSNIE_Len);
-
- return FALSE;
- }
- else
- {
- if (bWPA2 && MsgType == EAPOL_PAIR_MSG_3)
- {
- // skip RSN IE
- pMyKeyData += skip_offset;
- KeyDataLength -= skip_offset;
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPParseEapolKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", skip_offset));
- }
- else
- return TRUE;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPParseEapolKeyData ==> KeyDataLength %d without RSN_IE \n", KeyDataLength));
-
- // Parse EKD format in pairwise_msg_3_WPA2 && group_msg_1_WPA2
- if (bWPA2 && (MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1))
- {
- if (KeyDataLength >= 8) // KDE format exclude GTK length
- {
- pKDE = (PKDE_ENCAP) pMyKeyData;
-
-
- DefaultIdx = pKDE->GTKEncap.Kid;
-
- // Sanity check - KED length
- if (KeyDataLength < (pKDE->Len + 2))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
- return FALSE;
- }
-
- // Get GTK length - refer to IEEE 802.11i-2004 p.82
- GTKLEN = pKDE->Len -6;
- if (GTKLEN < LEN_AES_KEY)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
- return FALSE;
- }
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: KDE format length is too short \n"));
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("GTK in KDE format ,DefaultKeyID=%d, KeyLen=%d \n", DefaultIdx, GTKLEN));
- // skip it
- pMyKeyData += 8;
- KeyDataLength -= 8;
-
- }
- else if (!bWPA2 && MsgType == EAPOL_GROUP_MSG_1)
- {
- DefaultIdx = GroupKeyIndex;
- DBGPRINT(RT_DEBUG_TRACE, ("GTK DefaultKeyID=%d \n", DefaultIdx));
- }
-
- // Sanity check - shared key index must be 1 ~ 3
- if (DefaultIdx < 1 || DefaultIdx > 3)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index(%d) is invalid in %s %s \n", DefaultIdx, ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
- return FALSE;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- // Todo
-#endif // CONFIG_STA_SUPPORT //
-
- return TRUE;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Construct EAPoL message for WPA handshaking
- Its format is below,
-
- +--------------------+
- | Protocol Version | 1 octet
- +--------------------+
- | Protocol Type | 1 octet
- +--------------------+
- | Body Length | 2 octets
- +--------------------+
- | Descriptor Type | 1 octet
- +--------------------+
- | Key Information | 2 octets
- +--------------------+
- | Key Length | 1 octet
- +--------------------+
- | Key Repaly Counter | 8 octets
- +--------------------+
- | Key Nonce | 32 octets
- +--------------------+
- | Key IV | 16 octets
- +--------------------+
- | Key RSC | 8 octets
- +--------------------+
- | Key ID or Reserved | 8 octets
- +--------------------+
- | Key MIC | 16 octets
- +--------------------+
- | Key Data Length | 2 octets
- +--------------------+
- | Key Data | n octets
- +--------------------+
-
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ConstructEapolMsg(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AuthMode,
- IN UCHAR WepStatus,
- IN UCHAR GroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN UCHAR *ReplayCounter,
- IN UCHAR *KeyNonce,
- IN UCHAR *TxRSC,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_Len,
- OUT PEAPOL_PACKET pMsg)
-{
- BOOLEAN bWPA2 = FALSE;
-
- // Choose WPA2 or not
- if ((AuthMode == Ndis802_11AuthModeWPA2) || (AuthMode == Ndis802_11AuthModeWPA2PSK))
- bWPA2 = TRUE;
-
- // Init Packet and Fill header
- pMsg->ProVer = EAPOL_VER;
- pMsg->ProType = EAPOLKey;
-
- // Default 95 bytes, the EAPoL-Key descriptor exclude Key-data field
- pMsg->Body_Len[1] = LEN_EAPOL_KEY_MSG;
-
- // Fill in EAPoL descriptor
- if (bWPA2)
- pMsg->KeyDesc.Type = WPA2_KEY_DESC;
- else
- pMsg->KeyDesc.Type = WPA1_KEY_DESC;
-
- // Fill in Key information, refer to IEEE Std 802.11i-2004 page 78
- // When either the pairwise or the group cipher is AES, the DESC_TYPE_AES(2) shall be used.
- pMsg->KeyDesc.KeyInfo.KeyDescVer =
- (((WepStatus == Ndis802_11Encryption3Enabled) || (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- // Specify Key Type as Group(0) or Pairwise(1)
- if (MsgType >= EAPOL_GROUP_MSG_1)
- pMsg->KeyDesc.KeyInfo.KeyType = GROUPKEY;
- else
- pMsg->KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // Specify Key Index, only group_msg1_WPA1
- if (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1))
- pMsg->KeyDesc.KeyInfo.KeyIndex = DefaultKeyIdx;
-
- if (MsgType == EAPOL_PAIR_MSG_3)
- pMsg->KeyDesc.KeyInfo.Install = 1;
-
- if ((MsgType == EAPOL_PAIR_MSG_1) || (MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1))
- pMsg->KeyDesc.KeyInfo.KeyAck = 1;
-
- if (MsgType != EAPOL_PAIR_MSG_1)
- pMsg->KeyDesc.KeyInfo.KeyMic = 1;
-
- if ((bWPA2 && (MsgType >= EAPOL_PAIR_MSG_3)) || (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1)))
- {
- pMsg->KeyDesc.KeyInfo.Secure = 1;
- }
-
- if (bWPA2 && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
- {
- pMsg->KeyDesc.KeyInfo.EKD_DL = 1;
- }
-
- // key Information element has done.
- *(USHORT *)(&pMsg->KeyDesc.KeyInfo) = cpu2le16(*(USHORT *)(&pMsg->KeyDesc.KeyInfo));
-
- // Fill in Key Length
-#if 0
- if (bWPA2)
- {
- // In WPA2 mode, the field indicates the length of pairwise key cipher,
- // so only pairwise_msg_1 and pairwise_msg_3 need to fill.
- if ((MsgType == EAPOL_PAIR_MSG_1) || (MsgType == EAPOL_PAIR_MSG_3))
- pMsg->KeyDesc.KeyLength[1] = ((WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);
- }
- else if (!bWPA2)
-#endif
- {
- if (MsgType >= EAPOL_GROUP_MSG_1)
- {
- // the length of group key cipher
- pMsg->KeyDesc.KeyLength[1] = ((GroupKeyWepStatus == Ndis802_11Encryption2Enabled) ? TKIP_GTK_LENGTH : LEN_AES_KEY);
- }
- else
- {
- // the length of pairwise key cipher
- pMsg->KeyDesc.KeyLength[1] = ((WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);
- }
- }
-
- // Fill in replay counter
- NdisMoveMemory(pMsg->KeyDesc.ReplayCounter, ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Fill Key Nonce field
- // ANonce : pairwise_msg1 & pairwise_msg3
- // SNonce : pairwise_msg2
- // GNonce : group_msg1_wpa1
- if ((MsgType <= EAPOL_PAIR_MSG_3) || ((!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))))
- NdisMoveMemory(pMsg->KeyDesc.KeyNonce, KeyNonce, LEN_KEY_DESC_NONCE);
-
- // Fill key IV - WPA2 as 0, WPA1 as random
- if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
- {
- // Suggest IV be random number plus some number,
- NdisMoveMemory(pMsg->KeyDesc.KeyIv, &KeyNonce[16], LEN_KEY_DESC_IV);
- pMsg->KeyDesc.KeyIv[15] += 2;
- }
-
- // Fill Key RSC field
- // It contains the RSC for the GTK being installed.
- if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
- {
- NdisMoveMemory(pMsg->KeyDesc.KeyRsc, TxRSC, 6);
- }
-
- // Clear Key MIC field for MIC calculation later
- NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
- ConstructEapolKeyData(pAd,
- AuthMode,
- WepStatus,
- GroupKeyWepStatus,
- MsgType,
- DefaultKeyIdx,
- bWPA2,
- PTK,
- GTK,
- RSNIE,
- RSNIE_Len,
- pMsg);
-
- // Calculate MIC and fill in KeyMic Field except Pairwise Msg 1.
- if (MsgType != EAPOL_PAIR_MSG_1)
- {
- CalculateMIC(pAd, WepStatus, PTK, pMsg);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> ConstructEapolMsg for %s %s\n", ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
- DBGPRINT(RT_DEBUG_TRACE, (" Body length = %d \n", pMsg->Body_Len[1]));
- DBGPRINT(RT_DEBUG_TRACE, (" Key length = %d \n", pMsg->KeyDesc.KeyLength[1]));
-
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Construct the Key Data field of EAPoL message
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ConstructEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AuthMode,
- IN UCHAR WepStatus,
- IN UCHAR GroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN BOOLEAN bWPA2Capable,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_LEN,
- OUT PEAPOL_PACKET pMsg)
-{
- UCHAR *mpool, *Key_Data, *Rc4GTK;
- UCHAR ekey[(LEN_KEY_DESC_IV+LEN_EAP_EK)];
- UCHAR data_offset;
-
-
- if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)
- return;
-
- // allocate memory pool
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 1500);
-
- if (mpool == NULL)
- return;
-
- /* Rc4GTK Len = 512 */
- Rc4GTK = (UCHAR *) ROUND_UP(mpool, 4);
- /* Key_Data Len = 512 */
- Key_Data = (UCHAR *) ROUND_UP(Rc4GTK + 512, 4);
-
- NdisZeroMemory(Key_Data, 512);
- pMsg->KeyDesc.KeyDataLen[1] = 0;
- data_offset = 0;
-
- // Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3
- if (RSNIE_LEN && ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3)))
- {
- if (bWPA2Capable)
- Key_Data[data_offset + 0] = IE_WPA2;
- else
- Key_Data[data_offset + 0] = IE_WPA;
-
- Key_Data[data_offset + 1] = RSNIE_LEN;
- NdisMoveMemory(&Key_Data[data_offset + 2], RSNIE, RSNIE_LEN);
- data_offset += (2 + RSNIE_LEN);
- }
-
- // Encapsulate KDE format in pairwise_msg3_WPA2 & group_msg1_WPA2
- if (bWPA2Capable && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
- {
- // Key Data Encapsulation (KDE) format - 802.11i-2004 Figure-43w and Table-20h
- Key_Data[data_offset + 0] = 0xDD;
-
- if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
- {
- Key_Data[data_offset + 1] = 0x16;// 4+2+16(OUI+DataType+DataField)
- }
- else
- {
- Key_Data[data_offset + 1] = 0x26;// 4+2+32(OUI+DataType+DataField)
- }
-
- Key_Data[data_offset + 2] = 0x00;
- Key_Data[data_offset + 3] = 0x0F;
- Key_Data[data_offset + 4] = 0xAC;
- Key_Data[data_offset + 5] = 0x01;
-
- // GTK KDE format - 802.11i-2004 Figure-43x
- Key_Data[data_offset + 6] = (DefaultKeyIdx & 0x03);
- Key_Data[data_offset + 7] = 0x00; // Reserved Byte
-
- data_offset += 8;
- }
-
-
- // Encapsulate GTK and encrypt the key-data field with KEK.
- // Only for pairwise_msg3_WPA2 and group_msg1
- if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable) || (MsgType == EAPOL_GROUP_MSG_1))
- {
- // Fill in GTK
- if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
- {
- NdisMoveMemory(&Key_Data[data_offset], GTK, LEN_AES_KEY);
- data_offset += LEN_AES_KEY;
- }
- else
- {
- NdisMoveMemory(&Key_Data[data_offset], GTK, TKIP_GTK_LENGTH);
- data_offset += TKIP_GTK_LENGTH;
- }
-
- // Still dont know why, but if not append will occur "GTK not include in MSG3"
- // Patch for compatibility between zero config and funk
- if (MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable)
- {
- if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
- {
- Key_Data[data_offset + 0] = 0xDD;
- Key_Data[data_offset + 1] = 0;
- data_offset += 2;
- }
- else
- {
- Key_Data[data_offset + 0] = 0xDD;
- Key_Data[data_offset + 1] = 0;
- Key_Data[data_offset + 2] = 0;
- Key_Data[data_offset + 3] = 0;
- Key_Data[data_offset + 4] = 0;
- Key_Data[data_offset + 5] = 0;
- data_offset += 6;
- }
- }
-
- // Encrypt the data material in key data field
- if (WepStatus == Ndis802_11Encryption3Enabled)
- {
- AES_GTK_KEY_WRAP(&PTK[16], Key_Data, data_offset, Rc4GTK);
- // AES wrap function will grow 8 bytes in length
- data_offset += 8;
- }
- else
- {
- // PREPARE Encrypted "Key DATA" field. (Encrypt GTK with RC4, usinf PTK[16]->[31] as Key, IV-field as IV)
- // put TxTsc in Key RSC field
- pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
-
- // ekey is the contanetion of IV-field, and PTK[16]->PTK[31]
- NdisMoveMemory(ekey, pMsg->KeyDesc.KeyIv, LEN_KEY_DESC_IV);
- NdisMoveMemory(&ekey[LEN_KEY_DESC_IV], &PTK[16], LEN_EAP_EK);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, ekey, sizeof(ekey)); //INIT SBOX, KEYLEN+3(IV)
- pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, Key_Data, data_offset);
- WPAARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, Rc4GTK, Key_Data, data_offset);
- }
-
- NdisMoveMemory(pMsg->KeyDesc.KeyData, Rc4GTK, data_offset);
- }
- else
- {
- NdisMoveMemory(pMsg->KeyDesc.KeyData, Key_Data, data_offset);
- }
-
- // set key data length field and total length
- pMsg->KeyDesc.KeyDataLen[1] = data_offset;
- pMsg->Body_Len[1] += data_offset;
-
- os_free_mem(pAd, mpool);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Calcaulate MIC. It is used during 4-ways handsharking.
-
- Arguments:
- pAd - pointer to our pAdapter context
- PeerWepStatus - indicate the encryption type
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID CalculateMIC(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerWepStatus,
- IN UCHAR *PTK,
- OUT PEAPOL_PACKET pMsg)
-{
- UCHAR *OutBuffer;
- ULONG FrameLen = 0;
- UCHAR mic[LEN_KEY_DESC_MIC];
- UCHAR digest[80];
-
- // allocate memory for MIC calculation
- os_alloc_mem(pAd, (PUCHAR *)&OutBuffer, 512);
-
- if (OutBuffer == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!!CalculateMIC: no memory!!!\n"));
- return;
- }
-
- // make a frame for calculating MIC.
- MakeOutgoingFrame(OutBuffer, &FrameLen,
- pMsg->Body_Len[1] + 4, pMsg,
- END_OF_ARGS);
-
- NdisZeroMemory(mic, sizeof(mic));
-
- // Calculate MIC
- if (PeerWepStatus == Ndis802_11Encryption3Enabled)
- {
- HMAC_SHA1(OutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, mic);
- }
-
- // store the calculated MIC
- NdisMoveMemory(pMsg->KeyDesc.KeyMic, mic, LEN_KEY_DESC_MIC);
-
- os_free_mem(pAd, OutBuffer);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Some received frames can't decrypt by Asic, so decrypt them by software.
-
- Arguments:
- pAd - pointer to our pAdapter context
- PeerWepStatus - indicate the encryption type
-
- Return Value:
- NDIS_STATUS_SUCCESS - decryption successful
- NDIS_STATUS_FAILURE - decryption failure
-
- ========================================================================
-*/
-NDIS_STATUS RTMPSoftDecryptBroadCastData(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN NDIS_802_11_ENCRYPTION_STATUS GroupCipher,
- IN PCIPHER_KEY pShard_key)
-{
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
-
-
-
- // handle WEP decryption
- if (GroupCipher == Ndis802_11Encryption1Enabled)
- {
- if (RTMPSoftDecryptWEP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, pShard_key))
- {
-
- //Minus IV[4] & ICV[4]
- pRxWI->MPDUtotalByteCount -= 8;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR : Software decrypt WEP data fails.\n"));
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
- }
- // handle TKIP decryption
- else if (GroupCipher == Ndis802_11Encryption2Enabled)
- {
- if (RTMPSoftDecryptTKIP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, 0, pShard_key))
- {
-
- //Minus 8 bytes MIC, 8 bytes IV/EIV, 4 bytes ICV
- pRxWI->MPDUtotalByteCount -= 20;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptTKIP Failed\n"));
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
- }
- // handle AES decryption
- else if (GroupCipher == Ndis802_11Encryption3Enabled)
- {
- if (RTMPSoftDecryptAES(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount , pShard_key))
- {
-
- //8 bytes MIC, 8 bytes IV/EIV (CCMP Header)
- pRxWI->MPDUtotalByteCount -= 16;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptAES Failed\n"));
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
- }
- else
- {
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
-
- return NDIS_STATUS_SUCCESS;
-
-}
-
+#include "../../rt2860/common/cmm_wpa.c"
diff --git a/drivers/staging/rt2870/common/dfs.c b/drivers/staging/rt2870/common/dfs.c
index b09bba5cb206..ac2da4c0e2ca 100644
--- a/drivers/staging/rt2870/common/dfs.c
+++ b/drivers/staging/rt2870/common/dfs.c
@@ -1,453 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- ap_dfs.c
-
- Abstract:
- Support DFS function.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Fonchi 03-12-2007 created
-*/
-
-#include "../rt_config.h"
-
-typedef struct _RADAR_DURATION_TABLE
-{
- ULONG RDDurRegion;
- ULONG RadarSignalDuration;
- ULONG Tolerance;
-} RADAR_DURATION_TABLE, *PRADAR_DURATION_TABLE;
-
-
-static UCHAR RdIdleTimeTable[MAX_RD_REGION][4] =
-{
- {9, 250, 250, 250}, // CE
- {4, 250, 250, 250}, // FCC
- {4, 250, 250, 250}, // JAP
- {15, 250, 250, 250}, // JAP_W53
- {4, 250, 250, 250} // JAP_W56
-};
-
-/*
- ========================================================================
-
- Routine Description:
- Bbp Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
-
- ========================================================================
-*/
-VOID BbpRadarDetectionStart(
- IN PRTMP_ADAPTER pAd)
-{
- UINT8 RadarPeriod;
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 114, 0x02);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 121, 0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 122, 0x00);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 123, 0x08/*0x80*/);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 124, 0x28);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 125, 0xff);
-
-#if 0
- // toggle Rx enable bit for radar detection.
- // it's Andy's recommand.
- {
- UINT32 Value;
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (0x1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- Value &= ~(0x1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
-#endif
- RadarPeriod = ((UINT)RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + (UINT)pAd->CommonCfg.RadarDetect.DfsSessionTime) < 250 ?
- (RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + pAd->CommonCfg.RadarDetect.DfsSessionTime) : 250;
-
- RTMP_IO_WRITE8(pAd, 0x7020, 0x1d);
- RTMP_IO_WRITE8(pAd, 0x7021, 0x40);
-
- RadarDetectionStart(pAd, 0, RadarPeriod);
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Bbp Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
-
- ========================================================================
-*/
-VOID BbpRadarDetectionStop(
- IN PRTMP_ADAPTER pAd)
-{
- RTMP_IO_WRITE8(pAd, 0x7020, 0x1d);
- RTMP_IO_WRITE8(pAd, 0x7021, 0x60);
-
- RadarDetectionStop(pAd);
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
-
- ========================================================================
-*/
-VOID RadarDetectionStart(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN CTSProtect,
- IN UINT8 CTSPeriod)
-{
- UINT8 DfsActiveTime = (pAd->CommonCfg.RadarDetect.DfsSessionTime & 0x1f);
- UINT8 CtsProtect = (CTSProtect == 1) ? 0x02 : 0x01; // CTS protect.
-
- if (CTSProtect != 0)
- {
- switch(pAd->CommonCfg.RadarDetect.RDDurRegion)
- {
- case FCC:
- case JAP_W56:
- CtsProtect = 0x03;
- break;
-
- case CE:
- case JAP_W53:
- default:
- CtsProtect = 0x02;
- break;
- }
- }
- else
- CtsProtect = 0x01;
-
-
- // send start-RD with CTS protection command to MCU
- // highbyte [7] reserve
- // highbyte [6:5] 0x: stop Carrier/Radar detection
- // highbyte [10]: Start Carrier/Radar detection without CTS protection, 11: Start Carrier/Radar detection with CTS protection
- // highbyte [4:0] Radar/carrier detection duration. In 1ms.
-
- // lowbyte [7:0] Radar/carrier detection period, in 1ms.
- AsicSendCommandToMcu(pAd, 0x60, 0xff, CTSPeriod, DfsActiveTime | (CtsProtect << 5));
- //AsicSendCommandToMcu(pAd, 0x63, 0xff, 10, 0);
-
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- TRUE Found radar signal
- FALSE Not found radar signal
-
- ========================================================================
-*/
-VOID RadarDetectionStop(
- IN PRTMP_ADAPTER pAd)
-{
- DBGPRINT(RT_DEBUG_TRACE,("RadarDetectionStop.\n"));
- AsicSendCommandToMcu(pAd, 0x60, 0xff, 0x00, 0x00); // send start-RD with CTS protection command to MCU
-
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Radar channel check routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- TRUE need to do radar detect
- FALSE need not to do radar detect
-
- ========================================================================
-*/
-BOOLEAN RadarChannelCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Ch)
-{
-#if 1
- INT i;
- BOOLEAN result = FALSE;
-
- for (i=0; i<pAd->ChannelListNum; i++)
- {
- if (Ch == pAd->ChannelList[i].Channel)
- {
- result = pAd->ChannelList[i].DfsReq;
- break;
- }
- }
-
- return result;
-#else
- INT i;
- UCHAR Channel[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
-
- for (i=0; i<15; i++)
- {
- if (Ch == Channel[i])
- {
- break;
- }
- }
-
- if (i != 15)
- return TRUE;
- else
- return FALSE;
-#endif
-}
-
-ULONG JapRadarType(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- const UCHAR Channel[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
-
- if (pAd->CommonCfg.RadarDetect.RDDurRegion != JAP)
- {
- return pAd->CommonCfg.RadarDetect.RDDurRegion;
- }
-
- for (i=0; i<15; i++)
- {
- if (pAd->CommonCfg.Channel == Channel[i])
- {
- break;
- }
- }
-
- if (i < 4)
- return JAP_W53;
- else if (i < 15)
- return JAP_W56;
- else
- return JAP; // W52
-
-}
-
-ULONG RTMPBbpReadRadarDuration(
- IN PRTMP_ADAPTER pAd)
-{
- UINT8 byteValue = 0;
- ULONG result;
-
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R115, &byteValue);
-
- result = 0;
- switch (byteValue)
- {
- case 1: // radar signal detected by pulse mode.
- case 2: // radar signal detected by width mode.
- result = RTMPReadRadarDuration(pAd);
- break;
-
- case 0: // No radar signal.
- default:
-
- result = 0;
- break;
- }
-
- return result;
-}
-
-ULONG RTMPReadRadarDuration(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG result = 0;
-
-#ifdef DFS_SUPPORT
- UINT8 duration1 = 0, duration2 = 0, duration3 = 0;
-
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R116, &duration1);
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R117, &duration2);
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R118, &duration3);
- result = (duration1 << 16) + (duration2 << 8) + duration3;
-#endif // DFS_SUPPORT //
-
- return result;
-
-}
-
-VOID RTMPCleanRadarDuration(
- IN PRTMP_ADAPTER pAd)
-{
- return;
-}
-
-/*
- ========================================================================
- Routine Description:
- Radar wave detection. The API should be invoke each second.
-
- Arguments:
- pAd - Adapter pointer
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID ApRadarDetectPeriodic(
- IN PRTMP_ADAPTER pAd)
-{
- INT i;
-
- pAd->CommonCfg.RadarDetect.InServiceMonitorCount++;
-
- for (i=0; i<pAd->ChannelListNum; i++)
- {
- if (pAd->ChannelList[i].RemainingTimeForUse > 0)
- {
- pAd->ChannelList[i].RemainingTimeForUse --;
- if ((pAd->Mlme.PeriodicRound%5) == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RadarDetectPeriodic - ch=%d, RemainingTimeForUse=%d\n", pAd->ChannelList[i].Channel, pAd->ChannelList[i].RemainingTimeForUse));
- }
- }
- }
-
- //radar detect
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- RadarDetectPeriodic(pAd);
- }
-
- return;
-}
-
-// Periodic Radar detection, switch channel will occur in RTMPHandleTBTTInterrupt()
-// Before switch channel, driver needs doing channel switch announcement.
-VOID RadarDetectPeriodic(
- IN PRTMP_ADAPTER pAd)
-{
- // need to check channel availability, after switch channel
- if (pAd->CommonCfg.RadarDetect.RDMode != RD_SILENCE_MODE)
- return;
-
- // channel availability check time is 60sec, use 65 for assurance
- if (pAd->CommonCfg.RadarDetect.RDCount++ > pAd->CommonCfg.RadarDetect.ChMovingTime)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n"));
- BbpRadarDetectionStop(pAd);
- AsicEnableBssSync(pAd);
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
-
- return;
- }
-
- return;
-}
-
-
-/*
- ==========================================================================
- Description:
- change channel moving time for DFS testing.
-
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 set ChMovTime=[value]
- ==========================================================================
-*/
-INT Set_ChMovingTime_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT8 Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- pAd->CommonCfg.RadarDetect.ChMovingTime = Value;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
- pAd->CommonCfg.RadarDetect.ChMovingTime));
-
- return TRUE;
-}
-
-INT Set_LongPulseRadarTh_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT8 Value;
-
- Value = simple_strtol(arg, 0, 10) > 10 ? 10 : simple_strtol(arg, 0, 10);
-
- pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
- pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
-
- return TRUE;
-}
-
-
+#include "../../rt2860/common/dfs.c"
diff --git a/drivers/staging/rt2870/common/eeprom.c b/drivers/staging/rt2870/common/eeprom.c
index 33f16ed9c491..def09658fd81 100644
--- a/drivers/staging/rt2870/common/eeprom.c
+++ b/drivers/staging/rt2870/common/eeprom.c
@@ -1,254 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- eeprom.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#include "../rt_config.h"
-
-#if 0
-#define EEPROM_SIZE 0x200
-#define NVRAM_OFFSET 0x30000
-#define RF_OFFSET 0x40000
-
-static UCHAR init_flag = 0;
-static PUCHAR nv_ee_start = 0;
-
-static UCHAR EeBuffer[EEPROM_SIZE];
-#endif
-// IRQL = PASSIVE_LEVEL
-VOID RaiseClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x)
-{
- *x = *x | EESK;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
- RTMPusecDelay(1); // Max frequency = 1MHz in Spec. definition
-}
-
-// IRQL = PASSIVE_LEVEL
-VOID LowerClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x)
-{
- *x = *x & ~EESK;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
- RTMPusecDelay(1);
-}
-
-// IRQL = PASSIVE_LEVEL
-USHORT ShiftInBits(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x,i;
- USHORT data=0;
-
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~( EEDO | EEDI);
-
- for(i=0; i<16; i++)
- {
- data = data << 1;
- RaiseClock(pAd, &x);
-
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~(EEDI);
- if(x & EEDO)
- data |= 1;
-
- LowerClock(pAd, &x);
- }
-
- return data;
-}
-
-// IRQL = PASSIVE_LEVEL
-VOID ShiftOutBits(
- IN PRTMP_ADAPTER pAd,
- IN USHORT data,
- IN USHORT count)
-{
- UINT32 x,mask;
-
- mask = 0x01 << (count - 1);
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~(EEDO | EEDI);
-
- do
- {
- x &= ~EEDI;
- if(data & mask) x |= EEDI;
-
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- mask = mask >> 1;
- } while(mask);
-
- x &= ~EEDI;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-}
-
-// IRQL = PASSIVE_LEVEL
-VOID EEpromCleanup(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x;
-
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~(EECS | EEDI);
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-}
-
-VOID EWEN(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x;
-
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- // output the read_opcode and six pulse in that order
- ShiftOutBits(pAd, EEPROM_EWEN_OPCODE, 5);
- ShiftOutBits(pAd, 0, 6);
-
- EEpromCleanup(pAd);
-}
-
-VOID EWDS(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x;
-
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- // output the read_opcode and six pulse in that order
- ShiftOutBits(pAd, EEPROM_EWDS_OPCODE, 5);
- ShiftOutBits(pAd, 0, 6);
-
- EEpromCleanup(pAd);
-}
-
-// IRQL = PASSIVE_LEVEL
-USHORT RTMP_EEPROM_READ16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset)
-{
- UINT32 x;
- USHORT data;
-
- Offset /= 2;
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- // output the read_opcode and register number in that order
- ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
- ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
-
- // Now read the data (16 bits) in from the selected EEPROM word
- data = ShiftInBits(pAd);
-
- EEpromCleanup(pAd);
-
- return data;
-} //ReadEEprom
-
-VOID RTMP_EEPROM_WRITE16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Data)
-{
- UINT32 x;
-
- Offset /= 2;
-
- EWEN(pAd);
-
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- // output the read_opcode ,register number and data in that order
- ShiftOutBits(pAd, EEPROM_WRITE_OPCODE, 3);
- ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
- ShiftOutBits(pAd, Data, 16); // 16-bit access
-
- // read DO status
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- EEpromCleanup(pAd);
-
- RTMPusecDelay(10000); //delay for twp(MAX)=10ms
-
- EWDS(pAd);
-
- EEpromCleanup(pAd);
-}
-
+#include "../../rt2860/common/eeprom.c"
diff --git a/drivers/staging/rt2870/common/md5.c b/drivers/staging/rt2870/common/md5.c
index 774776b4b8c3..195645c0e1a8 100644
--- a/drivers/staging/rt2870/common/md5.c
+++ b/drivers/staging/rt2870/common/md5.c
@@ -1,1427 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- md5.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- jan 10-28-03 Initial
- Rita 11-23-04 Modify MD5 and SHA-1
- Rita 10-14-05 Modify SHA-1 in big-endian platform
- */
-#include "../rt_config.h"
-
-/**
- * md5_mac:
- * @key: pointer to the key used for MAC generation
- * @key_len: length of the key in bytes
- * @data: pointer to the data area for which the MAC is generated
- * @data_len: length of the data in bytes
- * @mac: pointer to the buffer holding space for the MAC; the buffer should
- * have space for 128-bit (16 bytes) MD5 hash value
- *
- * md5_mac() determines the message authentication code by using secure hash
- * MD5(key | data | key).
- */
-void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
-{
- MD5_CTX context;
-
- MD5Init(&context);
- MD5Update(&context, key, key_len);
- MD5Update(&context, data, data_len);
- MD5Update(&context, key, key_len);
- MD5Final(mac, &context);
-}
-
-/**
- * hmac_md5:
- * @key: pointer to the key used for MAC generation
- * @key_len: length of the key in bytes
- * @data: pointer to the data area for which the MAC is generated
- * @data_len: length of the data in bytes
- * @mac: pointer to the buffer holding space for the MAC; the buffer should
- * have space for 128-bit (16 bytes) MD5 hash value
- *
- * hmac_md5() determines the message authentication code using HMAC-MD5.
- * This implementation is based on the sample code presented in RFC 2104.
- */
-void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
-{
- MD5_CTX context;
- u8 k_ipad[65]; /* inner padding - key XORd with ipad */
- u8 k_opad[65]; /* outer padding - key XORd with opad */
- u8 tk[16];
- int i;
-
- //assert(key != NULL && data != NULL && mac != NULL);
-
- /* if key is longer than 64 bytes reset it to key = MD5(key) */
- if (key_len > 64) {
- MD5_CTX ttcontext;
-
- MD5Init(&ttcontext);
- MD5Update(&ttcontext, key, key_len);
- MD5Final(tk, &ttcontext);
- //key=(PUCHAR)ttcontext.buf;
- key = tk;
- key_len = 16;
- }
-
- /* the HMAC_MD5 transform looks like:
- *
- * MD5(K XOR opad, MD5(K XOR ipad, text))
- *
- * where K is an n byte key
- * ipad is the byte 0x36 repeated 64 times
- * opad is the byte 0x5c repeated 64 times
- * and text is the data being protected */
-
- /* start out by storing key in pads */
- NdisZeroMemory(k_ipad, sizeof(k_ipad));
- NdisZeroMemory(k_opad, sizeof(k_opad));
- //assert(key_len < sizeof(k_ipad));
- NdisMoveMemory(k_ipad, key, key_len);
- NdisMoveMemory(k_opad, key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i = 0; i < 64; i++) {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- /* perform inner MD5 */
- MD5Init(&context); /* init context for 1st pass */
- MD5Update(&context, k_ipad, 64); /* start with inner pad */
- MD5Update(&context, data, data_len); /* then text of datagram */
- MD5Final(mac, &context); /* finish up 1st pass */
-
- /* perform outer MD5 */
- MD5Init(&context); /* init context for 2nd pass */
- MD5Update(&context, k_opad, 64); /* start with outer pad */
- MD5Update(&context, mac, 16); /* then results of 1st hash */
- MD5Final(mac, &context); /* finish up 2nd pass */
-}
-
-#ifndef RT_BIG_ENDIAN
-#define byteReverse(buf, len) /* Nothing */
-#else
-void byteReverse(unsigned char *buf, unsigned longs);
-void byteReverse(unsigned char *buf, unsigned longs)
-{
- do {
- *(UINT32 *)buf = SWAP32(*(UINT32 *)buf);
- buf += 4;
- } while (--longs);
-}
-#endif
-
-
-/* ========================== MD5 implementation =========================== */
-// four base functions for MD5
-#define MD5_F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define MD5_F2(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define MD5_F3(x, y, z) ((x) ^ (y) ^ (z))
-#define MD5_F4(x, y, z) ((y) ^ ((x) | (~z)))
-#define CYCLIC_LEFT_SHIFT(w, s) (((w) << (s)) | ((w) >> (32-(s))))
-
-#define MD5Step(f, w, x, y, z, data, t, s) \
- ( w += f(x, y, z) + data + t, w = (CYCLIC_LEFT_SHIFT(w, s)) & 0xffffffff, w += x )
-
-
-/*
- * Function Description:
- * Initiate MD5 Context satisfied in RFC 1321
- *
- * Arguments:
- * pCtx Pointer to MD5 context
- *
- * Return Value:
- * None
- */
-VOID MD5Init(MD5_CTX *pCtx)
-{
- pCtx->Buf[0]=0x67452301;
- pCtx->Buf[1]=0xefcdab89;
- pCtx->Buf[2]=0x98badcfe;
- pCtx->Buf[3]=0x10325476;
-
- pCtx->LenInBitCount[0]=0;
- pCtx->LenInBitCount[1]=0;
-}
-
-
-/*
- * Function Description:
- * Update MD5 Context, allow of an arrary of octets as the next portion
- * of the message
- *
- * Arguments:
- * pCtx Pointer to MD5 context
- * pData Pointer to input data
- * LenInBytes The length of input data (unit: byte)
- *
- * Return Value:
- * None
- *
- * Note:
- * Called after MD5Init or MD5Update(itself)
- */
-VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
-{
-
- UINT32 TfTimes;
- UINT32 temp;
- unsigned int i;
-
- temp = pCtx->LenInBitCount[0];
-
- pCtx->LenInBitCount[0] = (UINT32) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
-
- if (pCtx->LenInBitCount[0] < temp)
- pCtx->LenInBitCount[1]++; //carry in
-
- pCtx->LenInBitCount[1] += LenInBytes >> 29;
-
- // mod 64 bytes
- temp = (temp >> 3) & 0x3f;
-
- // process lacks of 64-byte data
- if (temp)
- {
- UCHAR *pAds = (UCHAR *) pCtx->Input + temp;
-
- if ((temp+LenInBytes) < 64)
- {
- NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);
- return;
- }
-
- NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp);
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
- pData += 64-temp;
- LenInBytes -= 64-temp;
- } // end of if (temp)
-
-
- TfTimes = (LenInBytes >> 6);
-
- for (i=TfTimes; i>0; i--)
- {
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64);
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
- pData += 64;
- LenInBytes -= 64;
- } // end of for
-
- // buffering lacks of 64-byte data
- if(LenInBytes)
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes);
-
-}
-
-
-/*
- * Function Description:
- * Append padding bits and length of original message in the tail
- * The message digest has to be completed in the end
- *
- * Arguments:
- * Digest Output of Digest-Message for MD5
- * pCtx Pointer to MD5 context
- *
- * Return Value:
- * None
- *
- * Note:
- * Called after MD5Update
- */
-VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
-{
- UCHAR Remainder;
- UCHAR PadLenInBytes;
- UCHAR *pAppend=0;
- unsigned int i;
-
- Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f);
-
- PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder);
-
- pAppend = (UCHAR *)pCtx->Input + Remainder;
-
- // padding bits without crossing block(64-byte based) boundary
- if (Remainder < 56)
- {
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes);
-
- // add data-length field, from low to high
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff);
- }
-
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of if
-
- // padding bits with crossing block(64-byte based) boundary
- else
- {
- // the first block ===
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1));
- PadLenInBytes -= (64 - Remainder - 1);
-
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
-
- // the second block ===
- NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes);
-
- // add data-length field
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff);
- }
-
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of else
-
-
- NdisMoveMemory((UCHAR *)Digest, (UINT32 *)pCtx->Buf, 16); // output
- byteReverse((UCHAR *)Digest, 4);
- NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free
-}
-
-
-/*
- * Function Description:
- * The central algorithm of MD5, consists of four rounds and sixteen
- * steps per round
- *
- * Arguments:
- * Buf Buffers of four states (output: 16 bytes)
- * Mes Input data (input: 64 bytes)
- *
- * Return Value:
- * None
- *
- * Note:
- * Called by MD5Update or MD5Final
- */
-VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16])
-{
- UINT32 Reg[4], Temp;
- unsigned int i;
-
- static UCHAR LShiftVal[16] =
- {
- 7, 12, 17, 22,
- 5, 9 , 14, 20,
- 4, 11, 16, 23,
- 6, 10, 15, 21,
- };
-
-
- // [equal to 4294967296*abs(sin(index))]
- static UINT32 MD5Table[64] =
- {
- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
-
- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
- 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
-
- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
-
- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
- };
-
-
- for (i=0; i<4; i++)
- Reg[i]=Buf[i];
-
-
- // 64 steps in MD5 algorithm
- for (i=0; i<16; i++)
- {
- MD5Step(MD5_F1, Reg[0], Reg[1], Reg[2], Reg[3], Mes[i],
- MD5Table[i], LShiftVal[i & 0x3]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
- for (i=16; i<32; i++)
- {
- MD5Step(MD5_F2, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(5*(i & 0xf)+1) & 0xf],
- MD5Table[i], LShiftVal[(0x1 << 2)+(i & 0x3)]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
- for (i=32; i<48; i++)
- {
- MD5Step(MD5_F3, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(3*(i & 0xf)+5) & 0xf],
- MD5Table[i], LShiftVal[(0x1 << 3)+(i & 0x3)]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
- for (i=48; i<64; i++)
- {
- MD5Step(MD5_F4, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(7*(i & 0xf)) & 0xf],
- MD5Table[i], LShiftVal[(0x3 << 2)+(i & 0x3)]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
-
-
- // (temporary)output
- for (i=0; i<4; i++)
- Buf[i] += Reg[i];
-
-}
-
-
-
-/* ========================= SHA-1 implementation ========================== */
-// four base functions for SHA-1
-#define SHA1_F1(b, c, d) (((b) & (c)) | ((~b) & (d)))
-#define SHA1_F2(b, c, d) ((b) ^ (c) ^ (d))
-#define SHA1_F3(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
-
-
-#define SHA1Step(f, a, b, c, d, e, w, k) \
- ( e += ( f(b, c, d) + w + k + CYCLIC_LEFT_SHIFT(a, 5)) & 0xffffffff, \
- b = CYCLIC_LEFT_SHIFT(b, 30) )
-
-//Initiate SHA-1 Context satisfied in RFC 3174
-VOID SHAInit(SHA_CTX *pCtx)
-{
- pCtx->Buf[0]=0x67452301;
- pCtx->Buf[1]=0xefcdab89;
- pCtx->Buf[2]=0x98badcfe;
- pCtx->Buf[3]=0x10325476;
- pCtx->Buf[4]=0xc3d2e1f0;
-
- pCtx->LenInBitCount[0]=0;
- pCtx->LenInBitCount[1]=0;
-}
-
-/*
- * Function Description:
- * Update SHA-1 Context, allow of an arrary of octets as the next
- * portion of the message
- *
- * Arguments:
- * pCtx Pointer to SHA-1 context
- * pData Pointer to input data
- * LenInBytes The length of input data (unit: byte)
- *
- * Return Value:
- * error indicate more than pow(2,64) bits of data
- *
- * Note:
- * Called after SHAInit or SHAUpdate(itself)
- */
-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
-{
- UINT32 TfTimes;
- UINT32 temp1,temp2;
- unsigned int i;
- UCHAR err=1;
-
- temp1 = pCtx->LenInBitCount[0];
- temp2 = pCtx->LenInBitCount[1];
-
- pCtx->LenInBitCount[0] = (UINT32) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
- if (pCtx->LenInBitCount[0] < temp1)
- pCtx->LenInBitCount[1]++; //carry in
-
-
- pCtx->LenInBitCount[1] = (UINT32) (pCtx->LenInBitCount[1] +(LenInBytes >> 29));
- if (pCtx->LenInBitCount[1] < temp2)
- return (err); //check total length of original data
-
-
- // mod 64 bytes
- temp1 = (temp1 >> 3) & 0x3f;
-
- // process lacks of 64-byte data
- if (temp1)
- {
- UCHAR *pAds = (UCHAR *) pCtx->Input + temp1;
-
- if ((temp1+LenInBytes) < 64)
- {
- NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);
- return (0);
- }
-
- NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp1);
- byteReverse((UCHAR *)pCtx->Input, 16);
-
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
- pData += 64-temp1;
- LenInBytes -= 64-temp1;
- } // end of if (temp1)
-
-
- TfTimes = (LenInBytes >> 6);
-
- for (i=TfTimes; i>0; i--)
- {
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64);
- byteReverse((UCHAR *)pCtx->Input, 16);
-
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
- pData += 64;
- LenInBytes -= 64;
- } // end of for
-
- // buffering lacks of 64-byte data
- if(LenInBytes)
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes);
-
- return (0);
-
-}
-
-// Append padding bits and length of original message in the tail
-// The message digest has to be completed in the end
-VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20])
-{
- UCHAR Remainder;
- UCHAR PadLenInBytes;
- UCHAR *pAppend=0;
- unsigned int i;
-
- Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f);
-
- pAppend = (UCHAR *)pCtx->Input + Remainder;
-
- PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder);
-
- // padding bits without crossing block(64-byte based) boundary
- if (Remainder < 56)
- {
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes);
-
- // add data-length field, from high to low
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff);
- }
-
- byteReverse((UCHAR *)pCtx->Input, 16);
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 14);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of if
-
- // padding bits with crossing block(64-byte based) boundary
- else
- {
- // the first block ===
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1));
- PadLenInBytes -= (64 - Remainder - 1);
-
- byteReverse((UCHAR *)pCtx->Input, 16);
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
-
- // the second block ===
- NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes);
-
- // add data-length field
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff);
- }
-
- byteReverse((UCHAR *)pCtx->Input, 16);
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of else
-
-
- //Output, bytereverse
- for (i=0; i<20; i++)
- {
- Digest [i] = (UCHAR)(pCtx->Buf[i>>2] >> 8*(3-(i & 0x3)));
- }
-
- NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free
-}
-
-
-// The central algorithm of SHA-1, consists of four rounds and
-// twenty steps per round
-VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20])
-{
- UINT32 Reg[5],Temp;
- unsigned int i;
- UINT32 W[80];
-
- static UINT32 SHA1Table[4] = { 0x5a827999, 0x6ed9eba1,
- 0x8f1bbcdc, 0xca62c1d6 };
-
- Reg[0]=Buf[0];
- Reg[1]=Buf[1];
- Reg[2]=Buf[2];
- Reg[3]=Buf[3];
- Reg[4]=Buf[4];
-
- //the first octet of a word is stored in the 0th element, bytereverse
- for(i = 0; i < 16; i++)
- {
- W[i] = (Mes[i] >> 24) & 0xff;
- W[i] |= (Mes[i] >> 8 ) & 0xff00;
- W[i] |= (Mes[i] << 8 ) & 0xff0000;
- W[i] |= (Mes[i] << 24) & 0xff000000;
- }
-
-
- for (i = 0; i < 64; i++)
- W[16+i] = CYCLIC_LEFT_SHIFT(W[i] ^ W[2+i] ^ W[8+i] ^ W[13+i], 1);
-
-
- // 80 steps in SHA-1 algorithm
- for (i=0; i<80; i++)
- {
- if (i<20)
- SHA1Step(SHA1_F1, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[0]);
-
- else if (i>=20 && i<40)
- SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[1]);
-
- else if (i>=40 && i<60)
- SHA1Step(SHA1_F3, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[2]);
-
- else
- SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[3]);
-
-
- // one-word right shift
- Temp = Reg[4];
- Reg[4] = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
-
- } // end of for-loop
-
-
- // (temporary)output
- for (i=0; i<5; i++)
- Buf[i] += Reg[i];
-
-}
-
-
-/* ========================= AES En/Decryption ========================== */
-
-/* forward S-box */
-static uint32 FSb[256] =
-{
- 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
- 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
- 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
- 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
- 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC,
- 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
- 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A,
- 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
- 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
- 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
- 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B,
- 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
- 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85,
- 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
- 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
- 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
- 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17,
- 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
- 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88,
- 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
- 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
- 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
- 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9,
- 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
- 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6,
- 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
- 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
- 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
- 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94,
- 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
- 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68,
- 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
-};
-
-/* forward table */
-#define FT \
-\
- V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \
- V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \
- V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \
- V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \
- V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \
- V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \
- V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \
- V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \
- V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \
- V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \
- V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \
- V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \
- V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \
- V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \
- V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \
- V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \
- V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \
- V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \
- V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \
- V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \
- V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \
- V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \
- V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \
- V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \
- V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \
- V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \
- V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \
- V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \
- V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \
- V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \
- V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \
- V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \
- V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \
- V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \
- V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \
- V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \
- V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \
- V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \
- V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \
- V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \
- V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \
- V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \
- V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \
- V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \
- V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \
- V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \
- V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \
- V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \
- V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \
- V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \
- V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \
- V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \
- V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \
- V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \
- V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \
- V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \
- V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \
- V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \
- V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \
- V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \
- V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \
- V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \
- V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \
- V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A)
-
-#define V(a,b,c,d) 0x##a##b##c##d
-static uint32 FT0[256] = { FT };
-#undef V
-
-#define V(a,b,c,d) 0x##d##a##b##c
-static uint32 FT1[256] = { FT };
-#undef V
-
-#define V(a,b,c,d) 0x##c##d##a##b
-static uint32 FT2[256] = { FT };
-#undef V
-
-#define V(a,b,c,d) 0x##b##c##d##a
-static uint32 FT3[256] = { FT };
-#undef V
-
-#undef FT
-
-/* reverse S-box */
-
-static uint32 RSb[256] =
-{
- 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38,
- 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
- 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
- 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
- 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D,
- 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
- 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2,
- 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
- 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
- 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
- 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA,
- 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
- 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A,
- 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
- 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
- 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
- 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA,
- 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
- 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85,
- 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
- 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
- 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
- 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20,
- 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
- 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31,
- 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
- 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
- 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
- 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0,
- 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
- 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26,
- 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
-};
-
-/* reverse table */
-
-#define RT \
-\
- V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \
- V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \
- V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \
- V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \
- V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \
- V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \
- V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \
- V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \
- V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \
- V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \
- V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \
- V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \
- V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \
- V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \
- V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \
- V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \
- V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \
- V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \
- V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \
- V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \
- V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \
- V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \
- V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \
- V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \
- V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \
- V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \
- V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \
- V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \
- V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \
- V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \
- V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \
- V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \
- V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \
- V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \
- V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \
- V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \
- V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \
- V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \
- V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \
- V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \
- V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \
- V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \
- V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \
- V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \
- V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \
- V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \
- V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \
- V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \
- V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \
- V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \
- V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \
- V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \
- V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \
- V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \
- V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \
- V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \
- V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \
- V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \
- V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \
- V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \
- V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \
- V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \
- V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \
- V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42)
-
-#define V(a,b,c,d) 0x##a##b##c##d
-static uint32 RT0[256] = { RT };
-#undef V
-
-#define V(a,b,c,d) 0x##d##a##b##c
-static uint32 RT1[256] = { RT };
-#undef V
-
-#define V(a,b,c,d) 0x##c##d##a##b
-static uint32 RT2[256] = { RT };
-#undef V
-
-#define V(a,b,c,d) 0x##b##c##d##a
-static uint32 RT3[256] = { RT };
-#undef V
-
-#undef RT
-
-/* round constants */
-
-static uint32 RCON[10] =
-{
- 0x01000000, 0x02000000, 0x04000000, 0x08000000,
- 0x10000000, 0x20000000, 0x40000000, 0x80000000,
- 0x1B000000, 0x36000000
-};
-
-/* key schedule tables */
-
-static int KT_init = 1;
-
-static uint32 KT0[256];
-static uint32 KT1[256];
-static uint32 KT2[256];
-static uint32 KT3[256];
-
-/* platform-independant 32-bit integer manipulation macros */
-
-#define GET_UINT32(n,b,i) \
-{ \
- (n) = ( (uint32) (b)[(i) ] << 24 ) \
- | ( (uint32) (b)[(i) + 1] << 16 ) \
- | ( (uint32) (b)[(i) + 2] << 8 ) \
- | ( (uint32) (b)[(i) + 3] ); \
-}
-
-#define PUT_UINT32(n,b,i) \
-{ \
- (b)[(i) ] = (uint8) ( (n) >> 24 ); \
- (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \
- (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \
- (b)[(i) + 3] = (uint8) ( (n) ); \
-}
-
-/* AES key scheduling routine */
-
-int rtmp_aes_set_key( aes_context *ctx, uint8 *key, int nbits )
-{
- int i;
- uint32 *RK, *SK;
-
- switch( nbits )
- {
- case 128: ctx->nr = 10; break;
- case 192: ctx->nr = 12; break;
- case 256: ctx->nr = 14; break;
- default : return( 1 );
- }
-
- RK = ctx->erk;
-
- for( i = 0; i < (nbits >> 5); i++ )
- {
- GET_UINT32( RK[i], key, i * 4 );
- }
-
- /* setup encryption round keys */
-
- switch( nbits )
- {
- case 128:
-
- for( i = 0; i < 10; i++, RK += 4 )
- {
- RK[4] = RK[0] ^ RCON[i] ^
- ( FSb[ (uint8) ( RK[3] >> 16 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[3] >> 8 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[3] ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[3] >> 24 ) ] );
-
- RK[5] = RK[1] ^ RK[4];
- RK[6] = RK[2] ^ RK[5];
- RK[7] = RK[3] ^ RK[6];
- }
- break;
-
- case 192:
-
- for( i = 0; i < 8; i++, RK += 6 )
- {
- RK[6] = RK[0] ^ RCON[i] ^
- ( FSb[ (uint8) ( RK[5] >> 16 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[5] >> 8 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[5] ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[5] >> 24 ) ] );
-
- RK[7] = RK[1] ^ RK[6];
- RK[8] = RK[2] ^ RK[7];
- RK[9] = RK[3] ^ RK[8];
- RK[10] = RK[4] ^ RK[9];
- RK[11] = RK[5] ^ RK[10];
- }
- break;
-
- case 256:
-
- for( i = 0; i < 7; i++, RK += 8 )
- {
- RK[8] = RK[0] ^ RCON[i] ^
- ( FSb[ (uint8) ( RK[7] >> 16 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[7] >> 8 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[7] ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[7] >> 24 ) ] );
-
- RK[9] = RK[1] ^ RK[8];
- RK[10] = RK[2] ^ RK[9];
- RK[11] = RK[3] ^ RK[10];
-
- RK[12] = RK[4] ^
- ( FSb[ (uint8) ( RK[11] >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[11] >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[11] >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[11] ) ] );
-
- RK[13] = RK[5] ^ RK[12];
- RK[14] = RK[6] ^ RK[13];
- RK[15] = RK[7] ^ RK[14];
- }
- break;
- }
-
- /* setup decryption round keys */
-
- if( KT_init )
- {
- for( i = 0; i < 256; i++ )
- {
- KT0[i] = RT0[ FSb[i] ];
- KT1[i] = RT1[ FSb[i] ];
- KT2[i] = RT2[ FSb[i] ];
- KT3[i] = RT3[ FSb[i] ];
- }
-
- KT_init = 0;
- }
-
- SK = ctx->drk;
-
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
-
- for( i = 1; i < ctx->nr; i++ )
- {
- RK -= 8;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
- }
-
- RK -= 8;
-
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
-
- return( 0 );
-}
-
-/* AES 128-bit block encryption routine */
-
-void rtmp_aes_encrypt(aes_context *ctx, uint8 input[16], uint8 output[16] )
-{
- uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
-
- RK = ctx->erk;
- GET_UINT32( X0, input, 0 ); X0 ^= RK[0];
- GET_UINT32( X1, input, 4 ); X1 ^= RK[1];
- GET_UINT32( X2, input, 8 ); X2 ^= RK[2];
- GET_UINT32( X3, input, 12 ); X3 ^= RK[3];
-
-#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
-{ \
- RK += 4; \
- \
- X0 = RK[0] ^ FT0[ (uint8) ( Y0 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y1 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y2 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y3 ) ]; \
- \
- X1 = RK[1] ^ FT0[ (uint8) ( Y1 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y2 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y3 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y0 ) ]; \
- \
- X2 = RK[2] ^ FT0[ (uint8) ( Y2 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y3 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y0 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y1 ) ]; \
- \
- X3 = RK[3] ^ FT0[ (uint8) ( Y3 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y0 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y1 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y2 ) ]; \
-}
-
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */
-
- if( ctx->nr > 10 )
- {
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */
- }
-
- if( ctx->nr > 12 )
- {
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */
- }
-
- /* last round */
-
- RK += 4;
-
- X0 = RK[0] ^ ( FSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y3 ) ] );
-
- X1 = RK[1] ^ ( FSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y0 ) ] );
-
- X2 = RK[2] ^ ( FSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y1 ) ] );
-
- X3 = RK[3] ^ ( FSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y2 ) ] );
-
- PUT_UINT32( X0, output, 0 );
- PUT_UINT32( X1, output, 4 );
- PUT_UINT32( X2, output, 8 );
- PUT_UINT32( X3, output, 12 );
-}
-
-/* AES 128-bit block decryption routine */
-
-void rtmp_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] )
-{
- uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
-
- RK = ctx->drk;
-
- GET_UINT32( X0, input, 0 ); X0 ^= RK[0];
- GET_UINT32( X1, input, 4 ); X1 ^= RK[1];
- GET_UINT32( X2, input, 8 ); X2 ^= RK[2];
- GET_UINT32( X3, input, 12 ); X3 ^= RK[3];
-
-#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
-{ \
- RK += 4; \
- \
- X0 = RK[0] ^ RT0[ (uint8) ( Y0 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y3 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y2 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y1 ) ]; \
- \
- X1 = RK[1] ^ RT0[ (uint8) ( Y1 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y0 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y3 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y2 ) ]; \
- \
- X2 = RK[2] ^ RT0[ (uint8) ( Y2 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y1 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y0 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y3 ) ]; \
- \
- X3 = RK[3] ^ RT0[ (uint8) ( Y3 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y2 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y1 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y0 ) ]; \
-}
-
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */
-
- if( ctx->nr > 10 )
- {
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */
- }
-
- if( ctx->nr > 12 )
- {
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */
- }
-
- /* last round */
-
- RK += 4;
-
- X0 = RK[0] ^ ( RSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y1 ) ] );
-
- X1 = RK[1] ^ ( RSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y2 ) ] );
-
- X2 = RK[2] ^ ( RSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y3 ) ] );
-
- X3 = RK[3] ^ ( RSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y0 ) ] );
-
- PUT_UINT32( X0, output, 0 );
- PUT_UINT32( X1, output, 4 );
- PUT_UINT32( X2, output, 8 );
- PUT_UINT32( X3, output, 12 );
-}
-
-/*
- ========================================================================
-
- Routine Description:
- SHA1 function
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID HMAC_SHA1(
- IN UCHAR *text,
- IN UINT text_len,
- IN UCHAR *key,
- IN UINT key_len,
- IN UCHAR *digest)
-{
- SHA_CTX context;
- UCHAR k_ipad[65]; /* inner padding - key XORd with ipad */
- UCHAR k_opad[65]; /* outer padding - key XORd with opad */
- INT i;
-
- // if key is longer than 64 bytes reset it to key=SHA1(key)
- if (key_len > 64)
- {
- SHA_CTX tctx;
- SHAInit(&tctx);
- SHAUpdate(&tctx, key, key_len);
- SHAFinal(&tctx, key);
- key_len = 20;
- }
- NdisZeroMemory(k_ipad, sizeof(k_ipad));
- NdisZeroMemory(k_opad, sizeof(k_opad));
- NdisMoveMemory(k_ipad, key, key_len);
- NdisMoveMemory(k_opad, key, key_len);
-
- // XOR key with ipad and opad values
- for (i = 0; i < 64; i++)
- {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- // perform inner SHA1
- SHAInit(&context); /* init context for 1st pass */
- SHAUpdate(&context, k_ipad, 64); /* start with inner pad */
- SHAUpdate(&context, text, text_len); /* then text of datagram */
- SHAFinal(&context, digest); /* finish up 1st pass */
-
- //perform outer SHA1
- SHAInit(&context); /* init context for 2nd pass */
- SHAUpdate(&context, k_opad, 64); /* start with outer pad */
- SHAUpdate(&context, digest, 20); /* then results of 1st hash */
- SHAFinal(&context, digest); /* finish up 2nd pass */
-
-}
-
-/*
-* F(P, S, c, i) = U1 xor U2 xor ... Uc
-* U1 = PRF(P, S || Int(i))
-* U2 = PRF(P, U1)
-* Uc = PRF(P, Uc-1)
-*/
-
-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output)
-{
- unsigned char digest[36], digest1[SHA_DIGEST_LEN];
- int i, j;
-
- /* U1 = PRF(P, S || int(i)) */
- memcpy(digest, ssid, ssidlength);
- digest[ssidlength] = (unsigned char)((count>>24) & 0xff);
- digest[ssidlength+1] = (unsigned char)((count>>16) & 0xff);
- digest[ssidlength+2] = (unsigned char)((count>>8) & 0xff);
- digest[ssidlength+3] = (unsigned char)(count & 0xff);
- HMAC_SHA1(digest, ssidlength+4, (unsigned char*) password, (int) strlen(password), digest1); // for WPA update
-
- /* output = U1 */
- memcpy(output, digest1, SHA_DIGEST_LEN);
-
- for (i = 1; i < iterations; i++)
- {
- /* Un = PRF(P, Un-1) */
- HMAC_SHA1(digest1, SHA_DIGEST_LEN, (unsigned char*) password, (int) strlen(password), digest); // for WPA update
- memcpy(digest1, digest, SHA_DIGEST_LEN);
-
- /* output = output xor Un */
- for (j = 0; j < SHA_DIGEST_LEN; j++)
- {
- output[j] ^= digest[j];
- }
- }
-}
-/*
-* password - ascii string up to 63 characters in length
-* ssid - octet string up to 32 octets
-* ssidlength - length of ssid in octets
-* output must be 40 octets in length and outputs 256 bits of key
-*/
-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output)
-{
- if ((strlen(password) > 63) || (ssidlength > 32))
- return 0;
-
- F(password, ssid, ssidlength, 4096, 1, output);
- F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]);
- return 1;
-}
-
-
+#include "../../rt2860/common/md5.c"
diff --git a/drivers/staging/rt2870/common/mlme.c b/drivers/staging/rt2870/common/mlme.c
index 8a82cee8bf26..f88040abd26b 100644
--- a/drivers/staging/rt2870/common/mlme.c
+++ b/drivers/staging/rt2870/common/mlme.c
@@ -1,8609 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- mlme.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-08-25 Modify from RT2500 code base
- John Chang 2004-09-06 modified for RT2600
-*/
-
-#include "../rt_config.h"
-#include <stdarg.h>
-
-UCHAR CISCO_OUI[] = {0x00, 0x40, 0x96};
-
-UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
-UCHAR RSN_OUI[] = {0x00, 0x0f, 0xac};
-UCHAR WAPI_OUI[] = {0x00, 0x14, 0x72};
-UCHAR WME_INFO_ELEM[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
-UCHAR WME_PARM_ELEM[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
-UCHAR Ccx2QosInfo[] = {0x00, 0x40, 0x96, 0x04};
-UCHAR RALINK_OUI[] = {0x00, 0x0c, 0x43};
-UCHAR BROADCOM_OUI[] = {0x00, 0x90, 0x4c};
-UCHAR WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04};
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-UCHAR PRE_N_HT_OUI[] = {0x00, 0x90, 0x4c};
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-UCHAR RateSwitchTable[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x11, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
- 0x04, 0x21, 0, 30, 50,
- 0x05, 0x21, 1, 20, 50,
- 0x06, 0x21, 2, 20, 50,
- 0x07, 0x21, 3, 15, 50,
- 0x08, 0x21, 4, 15, 30,
- 0x09, 0x21, 5, 10, 25,
- 0x0a, 0x21, 6, 8, 25,
- 0x0b, 0x21, 7, 8, 25,
- 0x0c, 0x20, 12, 15, 30,
- 0x0d, 0x20, 13, 8, 20,
- 0x0e, 0x20, 14, 8, 20,
- 0x0f, 0x20, 15, 8, 25,
- 0x10, 0x22, 15, 8, 25,
- 0x11, 0x00, 0, 0, 0,
- 0x12, 0x00, 0, 0, 0,
- 0x13, 0x00, 0, 0, 0,
- 0x14, 0x00, 0, 0, 0,
- 0x15, 0x00, 0, 0, 0,
- 0x16, 0x00, 0, 0, 0,
- 0x17, 0x00, 0, 0, 0,
- 0x18, 0x00, 0, 0, 0,
- 0x19, 0x00, 0, 0, 0,
- 0x1a, 0x00, 0, 0, 0,
- 0x1b, 0x00, 0, 0, 0,
- 0x1c, 0x00, 0, 0, 0,
- 0x1d, 0x00, 0, 0, 0,
- 0x1e, 0x00, 0, 0, 0,
- 0x1f, 0x00, 0, 0, 0,
-};
-
-UCHAR RateSwitchTable11B[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x04, 0x03, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
-};
-
-UCHAR RateSwitchTable11BG[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
- 0x04, 0x10, 2, 20, 35,
- 0x05, 0x10, 3, 16, 35,
- 0x06, 0x10, 4, 10, 25,
- 0x07, 0x10, 5, 16, 25,
- 0x08, 0x10, 6, 10, 25,
- 0x09, 0x10, 7, 10, 13,
-};
-
-UCHAR RateSwitchTable11G[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x08, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x10, 0, 20, 101,
- 0x01, 0x10, 1, 20, 35,
- 0x02, 0x10, 2, 20, 35,
- 0x03, 0x10, 3, 16, 35,
- 0x04, 0x10, 4, 10, 25,
- 0x05, 0x10, 5, 16, 25,
- 0x06, 0x10, 6, 10, 25,
- 0x07, 0x10, 7, 10, 13,
-};
-
-#ifdef DOT11_N_SUPPORT
-UCHAR RateSwitchTable11N1S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x09, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 10, 25,
- 0x06, 0x21, 6, 8, 14,
- 0x07, 0x21, 7, 8, 14,
- 0x08, 0x23, 7, 8, 14,
-};
-
-UCHAR RateSwitchTable11N2S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11N3S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11N2SForABand[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0b, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x20, 12, 15, 30,
- 0x07, 0x20, 13, 8, 20,
- 0x08, 0x20, 14, 8, 20,
- 0x09, 0x20, 15, 8, 25,
- 0x0a, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11N3SForABand[] = { // 3*3
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0b, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x20, 12, 15, 30,
- 0x07, 0x20, 13, 8, 20,
- 0x08, 0x20, 14, 8, 20,
- 0x09, 0x20, 15, 8, 25,
- 0x0a, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11BGN1S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0d, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
- 0x04, 0x21, 0, 30,101, //50
- 0x05, 0x21, 1, 20, 50,
- 0x06, 0x21, 2, 20, 50,
- 0x07, 0x21, 3, 15, 50,
- 0x08, 0x21, 4, 15, 30,
- 0x09, 0x21, 5, 10, 25,
- 0x0a, 0x21, 6, 8, 14,
- 0x0b, 0x21, 7, 8, 14,
- 0x0c, 0x23, 7, 8, 14,
-};
-
-UCHAR RateSwitchTable11BGN2S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11BGN3S[] = { // 3*3
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 20, 50,
- 0x04, 0x21, 4, 15, 50,
-#if 1
- 0x05, 0x20, 20, 15, 30,
- 0x06, 0x20, 21, 8, 20,
- 0x07, 0x20, 22, 8, 20,
- 0x08, 0x20, 23, 8, 25,
- 0x09, 0x22, 23, 8, 25,
-#else // for RT2860 2*3 test
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-#endif
-};
-
-UCHAR RateSwitchTable11BGN2SForABand[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0b, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x20, 12, 15, 30,
- 0x07, 0x20, 13, 8, 20,
- 0x08, 0x20, 14, 8, 20,
- 0x09, 0x20, 15, 8, 25,
- 0x0a, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11BGN3SForABand[] = { // 3*3
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0c, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x21, 12, 15, 30,
- 0x07, 0x20, 20, 15, 30,
- 0x08, 0x20, 21, 8, 20,
- 0x09, 0x20, 22, 8, 20,
- 0x0a, 0x20, 23, 8, 25,
- 0x0b, 0x22, 23, 8, 25,
-};
-#endif // DOT11_N_SUPPORT //
-
-PUCHAR ReasonString[] = {
- /* 0 */ "Reserved",
- /* 1 */ "Unspecified Reason",
- /* 2 */ "Previous Auth no longer valid",
- /* 3 */ "STA is leaving / has left",
- /* 4 */ "DIS-ASSOC due to inactivity",
- /* 5 */ "AP unable to hanle all associations",
- /* 6 */ "class 2 error",
- /* 7 */ "class 3 error",
- /* 8 */ "STA is leaving / has left",
- /* 9 */ "require auth before assoc/re-assoc",
- /* 10 */ "Reserved",
- /* 11 */ "Reserved",
- /* 12 */ "Reserved",
- /* 13 */ "invalid IE",
- /* 14 */ "MIC error",
- /* 15 */ "4-way handshake timeout",
- /* 16 */ "2-way (group key) handshake timeout",
- /* 17 */ "4-way handshake IE diff among AssosReq/Rsp/Beacon",
- /* 18 */
-};
-
-extern UCHAR OfdmRateToRxwiMCS[];
-// since RT61 has better RX sensibility, we have to limit TX ACK rate not to exceed our normal data TX rate.
-// otherwise the WLAN peer may not be able to receive the ACK thus downgrade its data TX rate
-ULONG BasicRateMask[12] = {0xfffff001 /* 1-Mbps */, 0xfffff003 /* 2 Mbps */, 0xfffff007 /* 5.5 */, 0xfffff00f /* 11 */,
- 0xfffff01f /* 6 */ , 0xfffff03f /* 9 */ , 0xfffff07f /* 12 */ , 0xfffff0ff /* 18 */,
- 0xfffff1ff /* 24 */ , 0xfffff3ff /* 36 */ , 0xfffff7ff /* 48 */ , 0xffffffff /* 54 */};
-
-UCHAR MULTICAST_ADDR[MAC_ADDR_LEN] = {0x1, 0x00, 0x00, 0x00, 0x00, 0x00};
-UCHAR BROADCAST_ADDR[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than
-// this value, then it's quaranteed capable of operating in 36 mbps TX rate in
-// clean environment.
-// TxRate: 1 2 5.5 11 6 9 12 18 24 36 48 54 72 100
-CHAR RssiSafeLevelForTxRate[] ={ -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 };
-
-UCHAR RateIdToMbps[] = { 1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 72, 100};
-USHORT RateIdTo500Kbps[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144, 200};
-
-UCHAR SsidIe = IE_SSID;
-UCHAR SupRateIe = IE_SUPP_RATES;
-UCHAR ExtRateIe = IE_EXT_SUPP_RATES;
-#ifdef DOT11_N_SUPPORT
-UCHAR HtCapIe = IE_HT_CAP;
-UCHAR AddHtInfoIe = IE_ADD_HT;
-UCHAR NewExtChanIe = IE_SECONDARY_CH_OFFSET;
-#ifdef DOT11N_DRAFT3
-UCHAR ExtHtCapIe = IE_EXT_CAPABILITY;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-UCHAR ErpIe = IE_ERP;
-UCHAR DsIe = IE_DS_PARM;
-UCHAR TimIe = IE_TIM;
-UCHAR WpaIe = IE_WPA;
-UCHAR Wpa2Ie = IE_WPA2;
-UCHAR IbssIe = IE_IBSS_PARM;
-UCHAR Ccx2Ie = IE_CCX_V2;
-UCHAR WapiIe = IE_WAPI;
-
-extern UCHAR WPA_OUI[];
-
-UCHAR SES_OUI[] = {0x00, 0x90, 0x4c};
-
-UCHAR ZeroSsid[32] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-
-// Reset the RFIC setting to new series
-RTMP_RF_REGS RF2850RegTable[] = {
-// ch R1 R2 R3(TX0~4=0) R4
- {1, 0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b},
- {2, 0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f},
- {3, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b},
- {4, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f},
- {5, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b},
- {6, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f},
- {7, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b},
- {8, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f},
- {9, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b},
- {10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f},
- {11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b},
- {12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f},
- {13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b},
- {14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193},
-
- // 802.11 UNI / HyperLan 2
- {36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3},
- {38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193},
- {40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183},
- {44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3},
- {46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b},
- {48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b},
- {52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193},
- {54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3},
- {56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b},
- {60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183},
- {62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193},
- {64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3}, // Plugfest#4, Day4, change RFR3 left4th 9->5.
-
- // 802.11 HyperLan 2
- {100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783},
-
- // 2008.04.30 modified
- // The system team has AN to improve the EVM value
- // for channel 102 to 108 for the RT2850/RT2750 dual band solution.
- {102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793},
- {104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3},
- {108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193},
-
- {110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183},
- {112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b},
- {116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3},
- {118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193},
- {120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183},
- {124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193},
- {126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b}, // 0x980ed1bb->0x980ed15b required by Rory 20070927
- {128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3},
- {132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b},
- {134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193},
- {136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b},
- {140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183},
-
- // 802.11 UNII
- {149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7},
- {151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187},
- {153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f},
- {157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f},
- {159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7},
- {161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187},
- {165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197},
-
- // Japan
- {184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b},
- {188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13},
- {192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b},
- {196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23},
- {208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13},
- {212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b},
- {216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23},
-
- // still lack of MMAC(Japan) ch 34,38,42,46
-};
-UCHAR NUM_OF_2850_CHNL = (sizeof(RF2850RegTable) / sizeof(RTMP_RF_REGS));
-
-FREQUENCY_ITEM FreqItems3020[] =
-{
- /**************************************************/
- // ISM : 2.4 to 2.483 GHz //
- /**************************************************/
- // 11g
- /**************************************************/
- //-CH---N-------R---K-----------
- {1, 241, 2, 2},
- {2, 241, 2, 7},
- {3, 242, 2, 2},
- {4, 242, 2, 7},
- {5, 243, 2, 2},
- {6, 243, 2, 7},
- {7, 244, 2, 2},
- {8, 244, 2, 7},
- {9, 245, 2, 2},
- {10, 245, 2, 7},
- {11, 246, 2, 2},
- {12, 246, 2, 7},
- {13, 247, 2, 2},
- {14, 248, 2, 4},
-};
-#define NUM_OF_3020_CHNL (sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM))
-
-/*
- ==========================================================================
- Description:
- initialize the MLME task and its data structure (queue, spinlock,
- timer, state machines).
-
- IRQL = PASSIVE_LEVEL
-
- Return:
- always return NDIS_STATUS_SUCCESS
-
- ==========================================================================
-*/
-NDIS_STATUS MlmeInit(
- IN PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> MLME Initialize\n"));
-
- do
- {
- Status = MlmeQueueInit(&pAd->Mlme.Queue);
- if(Status != NDIS_STATUS_SUCCESS)
- break;
-
- pAd->Mlme.bRunning = FALSE;
- NdisAllocateSpinLock(&pAd->Mlme.TaskLock);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- BssTableInit(&pAd->ScanTab);
-
- // init STA state machines
- AssocStateMachineInit(pAd, &pAd->Mlme.AssocMachine, pAd->Mlme.AssocFunc);
- AuthStateMachineInit(pAd, &pAd->Mlme.AuthMachine, pAd->Mlme.AuthFunc);
- AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine, pAd->Mlme.AuthRspFunc);
- SyncStateMachineInit(pAd, &pAd->Mlme.SyncMachine, pAd->Mlme.SyncFunc);
- WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc);
- AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);
-
-#ifdef QOS_DLS_SUPPORT
- DlsStateMachineInit(pAd, &pAd->Mlme.DlsMachine, pAd->Mlme.DlsFunc);
-#endif // QOS_DLS_SUPPORT //
-
-
- // Since we are using switch/case to implement it, the init is different from the above
- // state machine init
- MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
-
- ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine, pAd->Mlme.ActFunc);
-
- // Init mlme periodic timer
- RTMPInitTimer(pAd, &pAd->Mlme.PeriodicTimer, GET_TIMER_FUNCTION(MlmePeriodicExec), pAd, TRUE);
-
- // Set mlme periodic timer
- RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
-
- // software-based RX Antenna diversity
- RTMPInitTimer(pAd, &pAd->Mlme.RxAntEvalTimer, GET_TIMER_FUNCTION(AsicRxAntEvalTimeout), pAd, FALSE);
-
- } while (FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- MLME Initialize\n"));
-
- return Status;
-}
-
-/*
- ==========================================================================
- Description:
- main loop of the MLME
- Pre:
- Mlme has to be initialized, and there are something inside the queue
- Note:
- This function is invoked from MPSetInformation and MPReceive;
- This task guarantee only one MlmeHandler will run.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeHandler(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_QUEUE_ELEM *Elem = NULL;
-#ifdef APCLI_SUPPORT
- SHORT apcliIfIndex;
-#endif
-
- // Only accept MLME and Frame from peer side, no other (control/data) frame should
- // get into this state machine
-
- NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
- if(pAd->Mlme.bRunning)
- {
- NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
- return;
- }
- else
- {
- pAd->Mlme.bRunning = TRUE;
- }
- NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-
- while (!MlmeQueueEmpty(&pAd->Mlme.Queue))
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Device Halted or Removed or MlmeRest, exit MlmeHandler! (queue num = %ld)\n", pAd->Mlme.Queue.Num));
- break;
- }
-
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now in MlmeHandler\n"));
- break;
- }
-#endif // RALINK_ATE //
-
- //From message type, determine which state machine I should drive
- if (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
- {
-#ifdef RT2870
- if (Elem->MsgType == MT2_RESET_CONF)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! reset MLME state machine !!!\n"));
- MlmeRestartStateMachine(pAd);
- Elem->Occupied = FALSE;
- Elem->MsgLen = 0;
- continue;
- }
-#endif // RT2870 //
-
- // if dequeue success
- switch (Elem->Machine)
- {
- // STA state machines
-#ifdef CONFIG_STA_SUPPORT
- case ASSOC_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem);
- break;
- case AUTH_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AuthMachine, Elem);
- break;
- case AUTH_RSP_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AuthRspMachine, Elem);
- break;
- case SYNC_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.SyncMachine, Elem);
- break;
- case MLME_CNTL_STATE_MACHINE:
- MlmeCntlMachinePerformAction(pAd, &pAd->Mlme.CntlMachine, Elem);
- break;
- case WPA_PSK_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);
- break;
-#ifdef LEAP_SUPPORT
- case LEAP_STATE_MACHINE:
- LeapMachinePerformAction(pAd, &pAd->Mlme.LeapMachine, Elem);
- break;
-#endif
- case AIRONET_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AironetMachine, Elem);
- break;
-
-#ifdef QOS_DLS_SUPPORT
- case DLS_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.DlsMachine, Elem);
- break;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
- case ACTION_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.ActMachine, Elem);
- break;
-
-
-
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("ERROR: Illegal machine %ld in MlmeHandler()\n", Elem->Machine));
- break;
- } // end of switch
-
- // free MLME element
- Elem->Occupied = FALSE;
- Elem->MsgLen = 0;
-
- }
- else {
- DBGPRINT_ERR(("MlmeHandler: MlmeQueue empty\n"));
- }
- }
-
- NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
- pAd->Mlme.bRunning = FALSE;
- NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-}
-
-/*
- ==========================================================================
- Description:
- Destructor of MLME (Destroy queue, state machine, spin lock and timer)
- Parameters:
- Adapter - NIC Adapter pointer
- Post:
- The MLME task will no longer work properly
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID MlmeHalt(
- IN PRTMP_ADAPTER pAd)
-{
- BOOLEAN Cancelled;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeHalt\n"));
-
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- // disable BEACON generation and other BEACON related hardware timers
- AsicDisableSync(pAd);
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef QOS_DLS_SUPPORT
- UCHAR i;
-#endif // QOS_DLS_SUPPORT //
- // Cancel pending timers
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-#ifdef QOS_DLS_SUPPORT
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
- }
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
- RTMPCancelTimer(&pAd->Mlme.RxAntEvalTimer, &Cancelled);
-
-
-
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- // Set LED
- RTMPSetLED(pAd, LED_HALT);
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
-#ifdef RT2870
- {
- LED_CFG_STRUC LedCfg;
- RTMP_IO_READ32(pAd, LED_CFG, &LedCfg.word);
- LedCfg.field.LedPolar = 0;
- LedCfg.field.RLedMode = 0;
- LedCfg.field.GLedMode = 0;
- LedCfg.field.YLedMode = 0;
- RTMP_IO_WRITE32(pAd, LED_CFG, LedCfg.word);
- }
-#endif // RT2870 //
- }
-
- RTMPusecDelay(5000); // 5 msec to gurantee Ant Diversity timer canceled
-
- MlmeQueueDestroy(&pAd->Mlme.Queue);
- NdisFreeSpinLock(&pAd->Mlme.TaskLock);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeHalt\n"));
-}
-
-VOID MlmeResetRalinkCounters(
- IN PRTMP_ADAPTER pAd)
-{
- pAd->RalinkCounters.LastOneSecRxOkDataCnt = pAd->RalinkCounters.OneSecRxOkDataCnt;
- // clear all OneSecxxx counters.
- pAd->RalinkCounters.OneSecBeaconSentCnt = 0;
- pAd->RalinkCounters.OneSecFalseCCACnt = 0;
- pAd->RalinkCounters.OneSecRxFcsErrCnt = 0;
- pAd->RalinkCounters.OneSecRxOkCnt = 0;
- pAd->RalinkCounters.OneSecTxFailCount = 0;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount = 0;
- pAd->RalinkCounters.OneSecTxRetryOkCount = 0;
- pAd->RalinkCounters.OneSecRxOkDataCnt = 0;
-
- // TODO: for debug only. to be removed
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] = 0;
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] = 0;
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] = 0;
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BE] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BK] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VI] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VO] = 0;
- pAd->RalinkCounters.OneSecTxDoneCount = 0;
- pAd->RalinkCounters.OneSecRxCount = 0;
- pAd->RalinkCounters.OneSecTxAggregationCount = 0;
- pAd->RalinkCounters.OneSecRxAggregationCount = 0;
-
- return;
-}
-
-unsigned long rx_AMSDU;
-unsigned long rx_Total;
-
-/*
- ==========================================================================
- Description:
- This routine is executed periodically to -
- 1. Decide if it's a right time to turn on PwrMgmt bit of all
- outgoiing frames
- 2. Calculate ChannelQuality based on statistics of the last
- period, so that TX rate won't toggling very frequently between a
- successful TX and a failed TX.
- 3. If the calculated ChannelQuality indicated current connection not
- healthy, then a ROAMing attempt is tried here.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-#define ADHOC_BEACON_LOST_TIME (8*OS_HZ) // 8 sec
-VOID MlmePeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- ULONG TxTotalCnt;
- PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RADIO_MEASUREMENT |
- fRTMP_ADAPTER_RESET_IN_PROGRESS))))
- return;
-
- RT28XX_MLME_PRE_SANITY_CHECK(pAd);
-
-#ifdef RALINK_ATE
- /* Do not show RSSI until "Normal 1 second Mlme PeriodicExec". */
- if (ATE_ON(pAd))
- {
- if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE != (MLME_TASK_EXEC_MULTIPLE - 1))
- {
- pAd->Mlme.PeriodicRound ++;
- return;
- }
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
-
- if (pAd->Mlme.PeriodicRound & 0x1)
- {
- // This is the fix for wifi 11n extension channel overlapping test case. for 2860D
- if (((pAd->MACVersion & 0xffff) == 0x0101) &&
- (STA_TGN_WIFI_ON(pAd)) &&
- (pAd->CommonCfg.IOTestParm.bToggle == FALSE))
-
- {
- RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x24Bf);
- pAd->CommonCfg.IOTestParm.bToggle = TRUE;
- }
- else if ((STA_TGN_WIFI_ON(pAd)) &&
- ((pAd->MACVersion & 0xffff) == 0x0101))
- {
- RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x243f);
- pAd->CommonCfg.IOTestParm.bToggle = FALSE;
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pAd->bUpdateBcnCntDone = FALSE;
-
-// RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3);
- pAd->Mlme.PeriodicRound ++;
-
- // execute every 500ms
- if ((pAd->Mlme.PeriodicRound % 5 == 0) && RTMPAutoRateSwitchCheck(pAd)/*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))*/)
- {
-#ifdef CONFIG_STA_SUPPORT
- // perform dynamic tx rate switching based on past TX history
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)))
- MlmeDynamicTxRateSwitching(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // Normal 1 second Mlme PeriodicExec.
- if (pAd->Mlme.PeriodicRound %MLME_TASK_EXEC_MULTIPLE == 0)
- {
- pAd->Mlme.OneSecPeriodicRound ++;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- /* request from Baron : move this routine from later to here */
- /* for showing Rx error count in ATE RXFRAME */
- NICUpdateRawCounters(pAd);
- if (pAd->ate.bRxFer == 1)
- {
- pAd->ate.RxTotalCnt += pAd->ate.RxCntPerSec;
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx packet cnt = %d/%d\n", pAd->ate.RxCntPerSec, pAd->ate.RxTotalCnt);
- pAd->ate.RxCntPerSec = 0;
-
- if (pAd->ate.RxAntennaSel == 0)
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx AvgRssi0=%d, AvgRssi1=%d, AvgRssi2=%d\n\n",
- pAd->ate.AvgRssi0, pAd->ate.AvgRssi1, pAd->ate.AvgRssi2);
- else
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx AvgRssi=%d\n\n", pAd->ate.AvgRssi0);
- }
- MlmeResetRalinkCounters(pAd);
- return;
- }
-#endif // RALINK_ATE //
-
-
- if (rx_Total)
- {
-
- // reset counters
- rx_AMSDU = 0;
- rx_Total = 0;
- }
-
- //ORIBATimerTimeout(pAd);
-
- // Media status changed, report to NDIS
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE))
- {
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
-
- }
- else
- {
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- }
- }
-
- NdisGetSystemUpTime(&pAd->Mlme.Now32);
-
- // add the most up-to-date h/w raw counters into software variable, so that
- // the dynamic tuning mechanism below are based on most up-to-date information
- NICUpdateRawCounters(pAd);
-
-#ifdef RT2870
- RT2870_WatchDog(pAd);
-#endif // RT2870 //
-
-#ifdef DOT11_N_SUPPORT
- // Need statistics after read counter. So put after NICUpdateRawCounters
- ORIBATimerTimeout(pAd);
-#endif // DOT11_N_SUPPORT //
-
- // if MGMT RING is full more than twice within 1 second, we consider there's
- // a hardware problem stucking the TX path. In this case, try a hardware reset
- // to recover the system
- // if (pAd->RalinkCounters.MgmtRingFullCount >= 2)
- // RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HARDWARE_ERROR);
- // else
- // pAd->RalinkCounters.MgmtRingFullCount = 0;
-
- // The time period for checking antenna is according to traffic
- if (pAd->Mlme.bEnableAutoAntennaCheck)
- {
- TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- if (TxTotalCnt > 50)
- {
- if (pAd->Mlme.OneSecPeriodicRound % 10 == 0)
- {
- AsicEvaluateRxAnt(pAd);
- }
- }
- else
- {
- if (pAd->Mlme.OneSecPeriodicRound % 3 == 0)
- {
- AsicEvaluateRxAnt(pAd);
- }
- }
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- STAMlmePeriodicExec(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- MlmeResetRalinkCounters(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- {
- // When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock
- // and sending CTS-to-self over and over.
- // Software Patch Solution:
- // 1. Polling debug state register 0x10F4 every one second.
- // 2. If in 0x10F4 the ((bit29==1) && (bit7==1)) OR ((bit29==1) && (bit5==1)), it means the deadlock has occurred.
- // 3. If the deadlock occurred, reset MAC/BBP by setting 0x1004 to 0x0001 for a while then setting it back to 0x000C again.
-
- UINT32 MacReg = 0;
-
- RTMP_IO_READ32(pAd, 0x10F4, &MacReg);
- if (((MacReg & 0x20000000) && (MacReg & 0x80)) || ((MacReg & 0x20000000) && (MacReg & 0x20)))
- {
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
- RTMPusecDelay(1);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xC);
-
- DBGPRINT(RT_DEBUG_WARN,("Warning, MAC specific condition occurs \n"));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RT28XX_MLME_HANDLER(pAd);
- }
-
-
- pAd->bUpdateBcnCntDone = FALSE;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-VOID STAMlmePeriodicExec(
- PRTMP_ADAPTER pAd)
-{
- ULONG TxTotalCnt;
- int i;
-
-//
-// We return here in ATE mode, because the statistics
-// that ATE needs are not collected via this routine.
-//
-#ifdef RALINK_ATE
- // It is supposed that we will never reach here in ATE mode.
- ASSERT(!(ATE_ON(pAd)));
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // WPA MIC error should block association attempt for 60 seconds
- if (pAd->StaCfg.bBlockAssoc && (pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ) < pAd->Mlme.Now32))
- pAd->StaCfg.bBlockAssoc = FALSE;
- }
-
- if ((pAd->PreMediaState != pAd->IndicateMediaState) && (pAd->CommonCfg.bWirelessEvent))
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- pAd->PreMediaState = pAd->IndicateMediaState;
- }
-
-
-
-
- AsicStaBbpTuning(pAd);
-
- TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- // update channel quality for Roaming and UI LinkQuality display
- MlmeCalculateChannelQuality(pAd, pAd->Mlme.Now32);
- }
-
- // must be AFTER MlmeDynamicTxRateSwitching() because it needs to know if
- // Radio is currently in noisy environment
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- AsicAdjustTxPower(pAd);
-
- if (INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- // Check DLS time out, then tear down those session
- RTMPCheckDLSTimeOut(pAd);
-#endif // QOS_DLS_SUPPORT //
-
- // Is PSM bit consistent with user power management policy?
- // This is the only place that will set PSM bit ON.
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- MlmeCheckPsmChange(pAd, pAd->Mlme.Now32);
-
- pAd->RalinkCounters.LastOneSecTotalTxCount = TxTotalCnt;
-
- if ((pAd->StaCfg.LastBeaconRxTime + 1*OS_HZ < pAd->Mlme.Now32) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
- ((TxTotalCnt + pAd->RalinkCounters.OneSecRxOkCnt < 600)))
- {
- RTMPSetAGCInitValue(pAd, BW_20);
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - No BEACON. restore R66 to the low bound(%d) \n", (0x2E + GET_LNA_GAIN(pAd))));
- }
-
- //if ((pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
- // (pAd->RalinkCounters.OneSecTxRetryOkCount == 0))
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable)
- {
- // When APSD is enabled, the period changes as 20 sec
- if ((pAd->Mlme.OneSecPeriodicRound % 20) == 8)
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- }
- else
- {
- // Send out a NULL frame every 10 sec to inform AP that STA is still alive (Avoid being age out)
- if ((pAd->Mlme.OneSecPeriodicRound % 10) == 8)
- {
- if (pAd->CommonCfg.bWmmCapable)
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- else
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE);
- }
- }
- }
-
- if (CQI_IS_DEAD(pAd->Mlme.ChannelQuality))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - No BEACON. Dead CQI. Auto Recovery attempt #%ld\n", pAd->RalinkCounters.BadCQIAutoRecoveryCount));
- pAd->StaCfg.CCXAdjacentAPReportFlag = TRUE;
- pAd->StaCfg.CCXAdjacentAPLinkDownTime = pAd->StaCfg.LastBeaconRxTime;
-
- // Lost AP, send disconnect & link down event
- LinkDown(pAd, FALSE);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- // RTMPPatchMacBbpBug(pAd);
- MlmeAutoReconnectLastSSID(pAd);
- }
- else if (CQI_IS_BAD(pAd->Mlme.ChannelQuality))
- {
- pAd->RalinkCounters.BadCQIAutoRecoveryCount ++;
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Bad CQI. Auto Recovery attempt #%ld\n", pAd->RalinkCounters.BadCQIAutoRecoveryCount));
- MlmeAutoReconnectLastSSID(pAd);
- }
-
- // Add auto seamless roaming
- if (pAd->StaCfg.bFastRoaming)
- {
- SHORT dBmToRoam = (SHORT)pAd->StaCfg.dBmToRoam;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Rssi=%d, dBmToRoam=%d\n", RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2), (CHAR)dBmToRoam));
-
- if (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) <= (CHAR)dBmToRoam)
- {
- MlmeCheckForFastRoaming(pAd, pAd->Mlme.Now32);
- }
- }
- }
- else if (ADHOC_ON(pAd))
- {
- //radar detect
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- RadarDetectPeriodic(pAd);
- }
-
- // If all peers leave, and this STA becomes the last one in this IBSS, then change MediaState
- // to DISCONNECTED. But still holding this IBSS (i.e. sending BEACON) so that other STAs can
- // join later.
- if ((pAd->StaCfg.LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < pAd->Mlme.Now32) &&
- OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- MLME_START_REQ_STRUCT StartReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n"));
- LinkDown(pAd, FALSE);
-
- StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
-
- for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i];
-
- if (pEntry->ValidAsCLI == FALSE)
- continue;
-
- if (pEntry->LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < pAd->Mlme.Now32)
- MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
- }
- }
- else // no INFRA nor ADHOC connection
- {
-
- if (pAd->StaCfg.bScanReqIsFromWebUI &&
- ((pAd->StaCfg.LastScanTime + 30 * OS_HZ) > pAd->Mlme.Now32))
- goto SKIP_AUTO_SCAN_CONN;
- else
- pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
-
- if ((pAd->StaCfg.bAutoReconnect == TRUE)
- && RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)
- && (MlmeValidateSSID(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen) == TRUE))
- {
- if ((pAd->ScanTab.BssNr==0) && (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
- {
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- if ((pAd->StaCfg.LastScanTime + 10 * OS_HZ) < pAd->Mlme.Now32)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("STAMlmePeriodicExec():CNTL - ScanTab.BssNr==0, start a new ACTIVE scan SSID[%s]\n", pAd->MlmeAux.AutoReconnectSsid));
- ScanParmFill(pAd, &ScanReq, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- // Reset Missed scan number
- pAd->StaCfg.LastScanTime = pAd->Mlme.Now32;
- }
- else if (pAd->StaCfg.BssType == BSS_ADHOC) // Quit the forever scan when in a very clean room
- MlmeAutoReconnectLastSSID(pAd);
- }
- else if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- if ((pAd->Mlme.OneSecPeriodicRound % 7) == 0)
- {
- MlmeAutoScan(pAd);
- pAd->StaCfg.LastScanTime = pAd->Mlme.Now32;
- }
- else
- {
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- if ((pAd->Mlme.OneSecPeriodicRound % 5) == 1)
- MlmeAutoReconnectLastSSID(pAd);
- }
- else
-#endif // CARRIER_DETECTION_SUPPORT //
- MlmeAutoReconnectLastSSID(pAd);
- }
- }
- }
- }
-
-SKIP_AUTO_SCAN_CONN:
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap !=0) && (pAd->MacTab.fAnyBASession == FALSE))
- {
- pAd->MacTab.fAnyBASession = TRUE;
- AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, FALSE, FALSE);
- }
- else if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap ==0) && (pAd->MacTab.fAnyBASession == TRUE))
- {
- pAd->MacTab.fAnyBASession = FALSE;
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040))
- TriEventCounterMaintenance(pAd);
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
- return;
-}
-
-// Link down report
-VOID LinkDownExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
-
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeAutoScan(
- IN PRTMP_ADAPTER pAd)
-{
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Driver auto scan\n"));
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeAutoReconnectLastSSID(
- IN PRTMP_ADAPTER pAd)
-{
-
-
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) &&
- (MlmeValidateSSID(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen) == TRUE))
- {
- NDIS_802_11_SSID OidSsid;
- OidSsid.SsidLength = pAd->MlmeAux.AutoReconnectSsidLen;
- NdisMoveMemory(OidSsid.Ssid, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Driver auto reconnect to last OID_802_11_SSID setting - %s, len - %d\n", pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen));
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_SSID,
- sizeof(NDIS_802_11_SSID),
- &OidSsid);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ==========================================================================
- Validate SSID for connection try and rescan purpose
- Valid SSID will have visible chars only.
- The valid length is from 0 to 32.
- IRQL = DISPATCH_LEVEL
- ==========================================================================
- */
-BOOLEAN MlmeValidateSSID(
- IN PUCHAR pSsid,
- IN UCHAR SsidLen)
-{
- int index;
-
- if (SsidLen > MAX_LEN_OF_SSID)
- return (FALSE);
-
- // Check each character value
- for (index = 0; index < SsidLen; index++)
- {
- if (pSsid[index] < 0x20)
- return (FALSE);
- }
-
- // All checked
- return (TRUE);
-}
-
-VOID MlmeSelectTxRateTable(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR *ppTable,
- IN PUCHAR pTableSize,
- IN PUCHAR pInitTxRateIdx)
-{
- do
- {
- // decide the rate table for tuning
- if (pAd->CommonCfg.TxRateTableSize > 0)
- {
- *ppTable = RateSwitchTable;
- *pTableSize = RateSwitchTable[0];
- *pInitTxRateIdx = RateSwitchTable[1];
-
- break;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- if ((pAd->OpMode == OPMODE_STA) && ADHOC_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
- (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
- {// 11N 1S Adhoc
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
-
- }
- else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
- (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- (pEntry->HTCapability.MCSSet[1] == 0xff) &&
- (pAd->Antenna.field.TxPath == 2))
- {// 11N 2S Adhoc
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11N2S;
- *pTableSize = RateSwitchTable11N2S[0];
- *pInitTxRateIdx = RateSwitchTable11N2S[1];
- }
- else
- {
- *ppTable = RateSwitchTable11N2SForABand;
- *pTableSize = RateSwitchTable11N2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
- }
-
- }
- else
-#endif // DOT11_N_SUPPORT //
- if ((pEntry->RateLen == 4)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {
- *ppTable = RateSwitchTable11B;
- *pTableSize = RateSwitchTable11B[0];
- *pInitTxRateIdx = RateSwitchTable11B[1];
-
- }
- else if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11BG;
- *pTableSize = RateSwitchTable11BG[0];
- *pInitTxRateIdx = RateSwitchTable11BG[1];
-
- }
- else
- {
- *ppTable = RateSwitchTable11G;
- *pTableSize = RateSwitchTable11G[0];
- *pInitTxRateIdx = RateSwitchTable11G[1];
-
- }
- break;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- //if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 12) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
- // ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
- if ((pEntry->RateLen == 12) && (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1)))
- {// 11BGN 1S AP
- *ppTable = RateSwitchTable11BGN1S;
- *pTableSize = RateSwitchTable11BGN1S[0];
- *pInitTxRateIdx = RateSwitchTable11BGN1S[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 12) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
- // (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2))
- if ((pEntry->RateLen == 12) && (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->CommonCfg.TxStream == 2))
- {// 11BGN 2S AP
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11BGN2S;
- *pTableSize = RateSwitchTable11BGN2S[0];
- *pInitTxRateIdx = RateSwitchTable11BGN2S[1];
-
- }
- else
- {
- *ppTable = RateSwitchTable11BGN2SForABand;
- *pTableSize = RateSwitchTable11BGN2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11BGN2SForABand[1];
-
- }
- break;
- }
-
- //else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
- if ((pEntry->HTCapability.MCSSet[0] == 0xff) && ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1)))
- {// 11N 1S AP
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2))
- if ((pEntry->HTCapability.MCSSet[0] == 0xff) && (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->CommonCfg.TxStream == 2))
- {// 11N 2S AP
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11N2S;
- *pTableSize = RateSwitchTable11N2S[0];
- *pInitTxRateIdx = RateSwitchTable11N2S[1];
- }
- else
- {
- *ppTable = RateSwitchTable11N2SForABand;
- *pTableSize = RateSwitchTable11N2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
- }
-
- break;
- }
-#endif // DOT11_N_SUPPORT //
- //else if ((pAd->StaActive.SupRateLen == 4) && (pAd->StaActive.ExtRateLen == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->RateLen == 4)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {// B only AP
- *ppTable = RateSwitchTable11B;
- *pTableSize = RateSwitchTable11B[0];
- *pInitTxRateIdx = RateSwitchTable11B[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen > 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->RateLen > 8)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {// B/G mixed AP
- *ppTable = RateSwitchTable11BG;
- *pTableSize = RateSwitchTable11BG[0];
- *pInitTxRateIdx = RateSwitchTable11BG[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->RateLen == 8)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {// G only AP
- *ppTable = RateSwitchTable11G;
- *pTableSize = RateSwitchTable11G[0];
- *pInitTxRateIdx = RateSwitchTable11G[1];
-
- break;
- }
-#ifdef DOT11_N_SUPPORT
-#endif // DOT11_N_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef DOT11_N_SUPPORT
- //else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0))
-#endif // DOT11_N_SUPPORT //
- { // Legacy mode
- if (pAd->CommonCfg.MaxTxRate <= RATE_11)
- {
- *ppTable = RateSwitchTable11B;
- *pTableSize = RateSwitchTable11B[0];
- *pInitTxRateIdx = RateSwitchTable11B[1];
- }
- else if ((pAd->CommonCfg.MaxTxRate > RATE_11) && (pAd->CommonCfg.MinTxRate > RATE_11))
- {
- *ppTable = RateSwitchTable11G;
- *pTableSize = RateSwitchTable11G[0];
- *pInitTxRateIdx = RateSwitchTable11G[1];
-
- }
- else
- {
- *ppTable = RateSwitchTable11BG;
- *pTableSize = RateSwitchTable11BG[0];
- *pInitTxRateIdx = RateSwitchTable11BG[1];
- }
- break;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- if (pAd->CommonCfg.TxStream == 1)
- {
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 1S AP \n"));
- }
- else
- {
- *ppTable = RateSwitchTable11N2S;
- *pTableSize = RateSwitchTable11N2S[0];
- *pInitTxRateIdx = RateSwitchTable11N2S[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
- }
- }
- else
- {
- if (pAd->CommonCfg.TxStream == 1)
- {
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 1S AP \n"));
- }
- else
- {
- *ppTable = RateSwitchTable11N2SForABand;
- *pTableSize = RateSwitchTable11N2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
- }
- }
-#endif // DOT11_N_SUPPORT //
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode (SupRateLen=%d, ExtRateLen=%d, MCSSet[0]=0x%x, MCSSet[1]=0x%x)\n",
- pAd->StaActive.SupRateLen, pAd->StaActive.ExtRateLen, pAd->StaActive.SupportedPhyInfo.MCSSet[0], pAd->StaActive.SupportedPhyInfo.MCSSet[1]));
- }
-#endif // CONFIG_STA_SUPPORT //
- } while(FALSE);
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ==========================================================================
- Description:
- This routine checks if there're other APs out there capable for
- roaming. Caller should call this routine only when Link up in INFRA mode
- and channel quality is below CQI_GOOD_THRESHOLD.
-
- IRQL = DISPATCH_LEVEL
-
- Output:
- ==========================================================================
- */
-VOID MlmeCheckForRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32)
-{
- USHORT i;
- BSS_TABLE *pRoamTab = &pAd->MlmeAux.RoamTab;
- BSS_ENTRY *pBss;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeCheckForRoaming\n"));
- // put all roaming candidates into RoamTab, and sort in RSSI order
- BssTableInit(pRoamTab);
- for (i = 0; i < pAd->ScanTab.BssNr; i++)
- {
- pBss = &pAd->ScanTab.BssEntry[i];
-
- if ((pBss->LastBeaconRxTime + BEACON_LOST_TIME) < Now32)
- continue; // AP disappear
- if (pBss->Rssi <= RSSI_THRESHOLD_FOR_ROAMING)
- continue; // RSSI too weak. forget it.
- if (MAC_ADDR_EQUAL(pBss->Bssid, pAd->CommonCfg.Bssid))
- continue; // skip current AP
- if (pBss->Rssi < (pAd->StaCfg.RssiSample.LastRssi0 + RSSI_DELTA))
- continue; // only AP with stronger RSSI is eligible for roaming
-
- // AP passing all above rules is put into roaming candidate table
- NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
- pRoamTab->BssNr += 1;
- }
-
- if (pRoamTab->BssNr > 0)
- {
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- pAd->RalinkCounters.PoorCQIRoamingCount ++;
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming attempt #%ld\n", pAd->RalinkCounters.PoorCQIRoamingCount));
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_MLME_ROAMING_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForRoaming(# of candidate= %d)\n",pRoamTab->BssNr));
-}
-
-/*
- ==========================================================================
- Description:
- This routine checks if there're other APs out there capable for
- roaming. Caller should call this routine only when link up in INFRA mode
- and channel quality is below CQI_GOOD_THRESHOLD.
-
- IRQL = DISPATCH_LEVEL
-
- Output:
- ==========================================================================
- */
-VOID MlmeCheckForFastRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now)
-{
- USHORT i;
- BSS_TABLE *pRoamTab = &pAd->MlmeAux.RoamTab;
- BSS_ENTRY *pBss;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeCheckForFastRoaming\n"));
- // put all roaming candidates into RoamTab, and sort in RSSI order
- BssTableInit(pRoamTab);
- for (i = 0; i < pAd->ScanTab.BssNr; i++)
- {
- pBss = &pAd->ScanTab.BssEntry[i];
-
- if ((pBss->Rssi <= -50) && (pBss->Channel == pAd->CommonCfg.Channel))
- continue; // RSSI too weak. forget it.
- if (MAC_ADDR_EQUAL(pBss->Bssid, pAd->CommonCfg.Bssid))
- continue; // skip current AP
- if (!SSID_EQUAL(pBss->Ssid, pBss->SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
- continue; // skip different SSID
- if (pBss->Rssi < (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) + RSSI_DELTA))
- continue; // skip AP without better RSSI
-
- DBGPRINT(RT_DEBUG_TRACE, ("LastRssi0 = %d, pBss->Rssi = %d\n", RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2), pBss->Rssi));
- // AP passing all above rules is put into roaming candidate table
- NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
- pRoamTab->BssNr += 1;
- }
-
- if (pRoamTab->BssNr > 0)
- {
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- pAd->RalinkCounters.PoorCQIRoamingCount ++;
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming attempt #%ld\n", pAd->RalinkCounters.PoorCQIRoamingCount));
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_MLME_ROAMING_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
- }
- // Maybe site survey required
- else
- {
- if ((pAd->StaCfg.LastScanTime + 10 * 1000) < Now)
- {
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming, No eligable entry, try new scan!\n"));
- pAd->StaCfg.ScanCnt = 2;
- pAd->StaCfg.LastScanTime = Now;
- MlmeAutoScan(pAd);
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForFastRoaming (BssNr=%d)\n", pRoamTab->BssNr));
-}
-
-/*
- ==========================================================================
- Description:
- This routine calculates TxPER, RxPER of the past N-sec period. And
- according to the calculation result, ChannelQuality is calculated here
- to decide if current AP is still doing the job.
-
- If ChannelQuality is not good, a ROAMing attempt may be tried later.
- Output:
- StaCfg.ChannelQuality - 0..100
-
- IRQL = DISPATCH_LEVEL
-
- NOTE: This routine decide channle quality based on RX CRC error ratio.
- Caller should make sure a function call to NICUpdateRawCounters(pAd)
- is performed right before this routine, so that this routine can decide
- channel quality based on the most up-to-date information
- ==========================================================================
- */
-VOID MlmeCalculateChannelQuality(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32)
-{
- ULONG TxOkCnt, TxCnt, TxPER, TxPRR;
- ULONG RxCnt, RxPER;
- UCHAR NorRssi;
- CHAR MaxRssi;
- ULONG BeaconLostTime = BEACON_LOST_TIME;
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // longer beacon lost time when carrier detection enabled
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- BeaconLostTime = BEACON_LOST_TIME + BEACON_LOST_TIME/2;
- }
-#endif // CARRIER_DETECTION_SUPPORT //
-
- MaxRssi = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
-
- //
- // calculate TX packet error ratio and TX retry ratio - if too few TX samples, skip TX related statistics
- //
- TxOkCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + pAd->RalinkCounters.OneSecTxRetryOkCount;
- TxCnt = TxOkCnt + pAd->RalinkCounters.OneSecTxFailCount;
- if (TxCnt < 5)
- {
- TxPER = 0;
- TxPRR = 0;
- }
- else
- {
- TxPER = (pAd->RalinkCounters.OneSecTxFailCount * 100) / TxCnt;
- TxPRR = ((TxCnt - pAd->RalinkCounters.OneSecTxNoRetryOkCount) * 100) / TxCnt;
- }
-
- //
- // calculate RX PER - don't take RxPER into consideration if too few sample
- //
- RxCnt = pAd->RalinkCounters.OneSecRxOkCnt + pAd->RalinkCounters.OneSecRxFcsErrCnt;
- if (RxCnt < 5)
- RxPER = 0;
- else
- RxPER = (pAd->RalinkCounters.OneSecRxFcsErrCnt * 100) / RxCnt;
-
- //
- // decide ChannelQuality based on: 1)last BEACON received time, 2)last RSSI, 3)TxPER, and 4)RxPER
- //
- if (INFRA_ON(pAd) &&
- (pAd->RalinkCounters.OneSecTxNoRetryOkCount < 2) && // no heavy traffic
- (pAd->StaCfg.LastBeaconRxTime + BeaconLostTime < Now32))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("BEACON lost > %ld msec with TxOkCnt=%ld -> CQI=0\n", BeaconLostTime, TxOkCnt));
- pAd->Mlme.ChannelQuality = 0;
- }
- else
- {
- // Normalize Rssi
- if (MaxRssi > -40)
- NorRssi = 100;
- else if (MaxRssi < -90)
- NorRssi = 0;
- else
- NorRssi = (MaxRssi + 90) * 2;
-
- // ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER (RSSI 0..100), (TxPER 100..0), (RxPER 100..0)
- pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * NorRssi +
- TX_WEIGHTING * (100 - TxPRR) +
- RX_WEIGHTING* (100 - RxPER)) / 100;
- if (pAd->Mlme.ChannelQuality >= 100)
- pAd->Mlme.ChannelQuality = 100;
- }
-
-}
-
-VOID MlmeSetTxRate(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PRTMP_TX_RATE_SWITCH pTxRate)
-{
- UCHAR MaxMode = MODE_OFDM;
-
-#ifdef DOT11_N_SUPPORT
- MaxMode = MODE_HTGREENFIELD;
-
- if (pTxRate->STBC && (pAd->StaCfg.MaxHTPhyMode.field.STBC) && (pAd->Antenna.field.TxPath == 2))
- pAd->StaCfg.HTPhyMode.field.STBC = STBC_USE;
- else
-#endif // DOT11_N_SUPPORT //
- pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
-
- if (pTxRate->CurrMCS < MCS_AUTO)
- pAd->StaCfg.HTPhyMode.field.MCS = pTxRate->CurrMCS;
-
- if (pAd->StaCfg.HTPhyMode.field.MCS > 7)
- pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
-
- if (ADHOC_ON(pAd))
- {
- // If peer adhoc is b-only mode, we can't send 11g rate.
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
- pEntry->HTPhyMode.field.STBC = STBC_NONE;
-
- //
- // For Adhoc MODE_CCK, driver will use AdhocBOnlyJoined flag to roll back to B only if necessary
- //
- pEntry->HTPhyMode.field.MODE = pTxRate->Mode;
- pEntry->HTPhyMode.field.ShortGI = pAd->StaCfg.HTPhyMode.field.ShortGI;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
-
- // Patch speed error in status page
- pAd->StaCfg.HTPhyMode.field.MODE = pEntry->HTPhyMode.field.MODE;
- }
- else
- {
- if (pTxRate->Mode <= MaxMode)
- pAd->StaCfg.HTPhyMode.field.MODE = pTxRate->Mode;
-
-#ifdef DOT11_N_SUPPORT
- if (pTxRate->ShortGI && (pAd->StaCfg.MaxHTPhyMode.field.ShortGI))
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_400;
- else
-#endif // DOT11_N_SUPPORT //
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-
-#ifdef DOT11_N_SUPPORT
- // Reexam each bandwidth's SGI support.
- if (pAd->StaCfg.HTPhyMode.field.ShortGI == GI_400)
- {
- if ((pEntry->HTPhyMode.field.BW == BW_20) && (!CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE)))
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
- if ((pEntry->HTPhyMode.field.BW == BW_40) && (!CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE)))
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
- }
-
- // Turn RTS/CTS rate to 6Mbps.
- if ((pEntry->HTPhyMode.field.MCS == 0) && (pAd->StaCfg.HTPhyMode.field.MCS != 0))
- {
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- if (pAd->MacTab.fAnyBASession)
- {
- AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- else
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- }
- else if ((pEntry->HTPhyMode.field.MCS == 8) && (pAd->StaCfg.HTPhyMode.field.MCS != 8))
- {
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- if (pAd->MacTab.fAnyBASession)
- {
- AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- else
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- }
- else if ((pEntry->HTPhyMode.field.MCS != 0) && (pAd->StaCfg.HTPhyMode.field.MCS == 0))
- {
- AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
-
- }
- else if ((pEntry->HTPhyMode.field.MCS != 8) && (pAd->StaCfg.HTPhyMode.field.MCS == 8))
- {
- AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.field.STBC = pAd->StaCfg.HTPhyMode.field.STBC;
- pEntry->HTPhyMode.field.ShortGI = pAd->StaCfg.HTPhyMode.field.ShortGI;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
-#ifdef DOT11_N_SUPPORT
- if ((pAd->StaCfg.MaxHTPhyMode.field.MODE == MODE_HTGREENFIELD) &&
- pAd->WIFItestbed.bGreenField)
- pEntry->HTPhyMode.field.MODE = MODE_HTGREENFIELD;
-#endif // DOT11_N_SUPPORT //
- }
-
- pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
-}
-
-/*
- ==========================================================================
- Description:
- This routine calculates the acumulated TxPER of eaxh TxRate. And
- according to the calculation result, change CommonCfg.TxRate which
- is the stable TX Rate we expect the Radio situation could sustained.
-
- CommonCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate}
- Output:
- CommonCfg.TxRate -
-
- IRQL = DISPATCH_LEVEL
-
- NOTE:
- call this routine every second
- ==========================================================================
- */
-VOID MlmeDynamicTxRateSwitching(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx;
- ULONG i, AccuTxTotalCnt = 0, TxTotalCnt;
- ULONG TxErrorRatio = 0;
- BOOLEAN bTxRateChanged, bUpgradeQuality = FALSE;
- PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate = NULL;
- PUCHAR pTable;
- UCHAR TableSize = 0;
- UCHAR InitTxRateIdx = 0, TrainUp, TrainDown;
- CHAR Rssi, RssiOffset = 0;
- TX_STA_CNT1_STRUC StaTx1;
- TX_STA_CNT0_STRUC TxStaCnt0;
- ULONG TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
- MAC_TABLE_ENTRY *pEntry;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- //
- // walk through MAC table, see if need to change AP's TX rate toward each entry
- //
- for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- pEntry = &pAd->MacTab.Content[i];
-
- // check if this entry need to switch rate automatically
- if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
- continue;
-
- if ((pAd->MacTab.Size == 1) || (pEntry->ValidAsDls))
- {
- Rssi = RTMPMaxRssi(pAd,
- pAd->StaCfg.RssiSample.AvgRssi0,
- pAd->StaCfg.RssiSample.AvgRssi1,
- pAd->StaCfg.RssiSample.AvgRssi2);
-
- // Update statistic counter
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
- pAd->bUpdateBcnCntDone = TRUE;
- TxRetransmit = StaTx1.field.TxRetransmit;
- TxSuccess = StaTx1.field.TxSuccess;
- TxFailCount = TxStaCnt0.field.TxFailCount;
- TxTotalCnt = TxRetransmit + TxSuccess + TxFailCount;
-
- pAd->RalinkCounters.OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
- pAd->RalinkCounters.OneSecTxFailCount += TxStaCnt0.field.TxFailCount;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
- pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
- pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
-
- // if no traffic in the past 1-sec period, don't change TX rate,
- // but clear all bad history. because the bad history may affect the next
- // Chariot throughput test
- AccuTxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((TxRetransmit + TxFailCount) * 100) / TxTotalCnt;
- }
- else
- {
- if (INFRA_ON(pAd) && (i == 1))
- Rssi = RTMPMaxRssi(pAd,
- pAd->StaCfg.RssiSample.AvgRssi0,
- pAd->StaCfg.RssiSample.AvgRssi1,
- pAd->StaCfg.RssiSample.AvgRssi2);
- else
- Rssi = RTMPMaxRssi(pAd,
- pEntry->RssiSample.AvgRssi0,
- pEntry->RssiSample.AvgRssi1,
- pEntry->RssiSample.AvgRssi2);
-
- TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
- pEntry->OneSecTxRetryOkCount +
- pEntry->OneSecTxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((pEntry->OneSecTxRetryOkCount + pEntry->OneSecTxFailCount) * 100) / TxTotalCnt;
- }
-
- CurrRateIdx = pEntry->CurrTxRateIndex;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &InitTxRateIdx);
-
- if (CurrRateIdx >= TableSize)
- {
- CurrRateIdx = TableSize - 1;
- }
-
- // When switch from Fixed rate -> auto rate, the REAL TX rate might be different from pAd->CommonCfg.TxRateIndex.
- // So need to sync here.
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
- if ((pEntry->HTPhyMode.field.MCS != pCurrTxRate->CurrMCS)
- //&& (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- )
- {
-
- // Need to sync Real Tx rate and our record.
- // Then return for next DRS.
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(InitTxRateIdx+1)*5];
- pEntry->CurrTxRateIndex = InitTxRateIdx;
- MlmeSetTxRate(pAd, pEntry, pCurrTxRate);
-
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
- continue;
- }
-
- // decide the next upgrade rate and downgrade rate, if any
- if ((CurrRateIdx > 0) && (CurrRateIdx < (TableSize - 1)))
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx -1;
- }
- else if (CurrRateIdx == 0)
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx;
- }
- else if (CurrRateIdx == (TableSize - 1))
- {
- UpRateIdx = CurrRateIdx;
- DownRateIdx = CurrRateIdx - 1;
- }
-
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-
-#ifdef DOT11_N_SUPPORT
- if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX))
- {
- TrainUp = (pCurrTxRate->TrainUp + (pCurrTxRate->TrainUp >> 1));
- TrainDown = (pCurrTxRate->TrainDown + (pCurrTxRate->TrainDown >> 1));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- TrainUp = pCurrTxRate->TrainUp;
- TrainDown = pCurrTxRate->TrainDown;
- }
-
- //pAd->DrsCounters.LastTimeTxRateChangeAction = pAd->DrsCounters.LastSecTxRateChangeAction;
-
- //
- // Keep the last time TxRateChangeAction status.
- //
- pEntry->LastTimeTxRateChangeAction = pEntry->LastSecTxRateChangeAction;
-
-
-
- //
- // CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI
- // (criteria copied from RT2500 for Netopia case)
- //
- if (TxTotalCnt <= 15)
- {
- CHAR idx = 0;
- UCHAR TxRateIdx;
- //UCHAR MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0, MCS7 = 0, MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
- UCHAR MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0, MCS5 =0, MCS6 = 0, MCS7 = 0;
- UCHAR MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
- UCHAR MCS20 = 0, MCS21 = 0, MCS22 = 0, MCS23 = 0; // 3*3
-
- // check the existence and index of each needed MCS
- while (idx < pTable[0])
- {
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(idx+1)*5];
-
- if (pCurrTxRate->CurrMCS == MCS_0)
- {
- MCS0 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_1)
- {
- MCS1 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_2)
- {
- MCS2 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_3)
- {
- MCS3 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_4)
- {
- MCS4 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_5)
- {
- MCS5 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_6)
- {
- MCS6 = idx;
- }
- //else if (pCurrTxRate->CurrMCS == MCS_7)
- else if ((pCurrTxRate->CurrMCS == MCS_7) && (pCurrTxRate->ShortGI == GI_800)) // prevent the highest MCS using short GI when 1T and low throughput
- {
- MCS7 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_12)
- {
- MCS12 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_13)
- {
- MCS13 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_14)
- {
- MCS14 = idx;
- }
- //else if ((pCurrTxRate->CurrMCS == MCS_15)/* && (pCurrTxRate->ShortGI == GI_800)*/) //we hope to use ShortGI as initial rate
- else if ((pCurrTxRate->CurrMCS == MCS_15) && (pCurrTxRate->ShortGI == GI_800)) //we hope to use ShortGI as initial rate, however Atheros's chip has bugs when short GI
- {
- MCS15 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_20) // 3*3
- {
- MCS20 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_21)
- {
- MCS21 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_22)
- {
- MCS22 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_23)
- {
- MCS23 = idx;
- }
- idx ++;
- }
-
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- RssiOffset = 2;
- }
- else
- {
- RssiOffset = 5;
- }
- }
- else
- {
- if (pAd->NicConfig2.field.ExternalLNAForA)
- {
- RssiOffset = 5;
- }
- else
- {
- RssiOffset = 8;
- }
- }
-#ifdef DOT11_N_SUPPORT
- /*if (MCS15)*/
- if ((pTable == RateSwitchTable11BGN3S) ||
- (pTable == RateSwitchTable11N3S) ||
- (pTable == RateSwitchTable))
- {// N mode with 3 stream // 3*3
- if (MCS23 && (Rssi >= -70))
- TxRateIdx = MCS15;
- else if (MCS22 && (Rssi >= -72))
- TxRateIdx = MCS14;
- else if (MCS21 && (Rssi >= -76))
- TxRateIdx = MCS13;
- else if (MCS20 && (Rssi >= -78))
- TxRateIdx = MCS12;
- else if (MCS4 && (Rssi >= -82))
- TxRateIdx = MCS4;
- else if (MCS3 && (Rssi >= -84))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi >= -86))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi >= -88))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
-// else if ((pTable == RateSwitchTable11BGN2S) || (pTable == RateSwitchTable11BGN2SForABand) ||(pTable == RateSwitchTable11N2S) ||(pTable == RateSwitchTable11N2SForABand) || (pTable == RateSwitchTable))
- else if ((pTable == RateSwitchTable11BGN2S) || (pTable == RateSwitchTable11BGN2SForABand) ||(pTable == RateSwitchTable11N2S) ||(pTable == RateSwitchTable11N2SForABand)) // 3*3
- {// N mode with 2 stream
- if (MCS15 && (Rssi >= (-70+RssiOffset)))
- TxRateIdx = MCS15;
- else if (MCS14 && (Rssi >= (-72+RssiOffset)))
- TxRateIdx = MCS14;
- else if (MCS13 && (Rssi >= (-76+RssiOffset)))
- TxRateIdx = MCS13;
- else if (MCS12 && (Rssi >= (-78+RssiOffset)))
- TxRateIdx = MCS12;
- else if (MCS4 && (Rssi >= (-82+RssiOffset)))
- TxRateIdx = MCS4;
- else if (MCS3 && (Rssi >= (-84+RssiOffset)))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi >= (-86+RssiOffset)))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi >= (-88+RssiOffset)))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
- else if ((pTable == RateSwitchTable11BGN1S) || (pTable == RateSwitchTable11N1S))
- {// N mode with 1 stream
- if (MCS7 && (Rssi > (-72+RssiOffset)))
- TxRateIdx = MCS7;
- else if (MCS6 && (Rssi > (-74+RssiOffset)))
- TxRateIdx = MCS6;
- else if (MCS5 && (Rssi > (-77+RssiOffset)))
- TxRateIdx = MCS5;
- else if (MCS4 && (Rssi > (-79+RssiOffset)))
- TxRateIdx = MCS4;
- else if (MCS3 && (Rssi > (-81+RssiOffset)))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi > (-83+RssiOffset)))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi > (-86+RssiOffset)))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
- else
-#endif // DOT11_N_SUPPORT //
- {// Legacy mode
- if (MCS7 && (Rssi > -70))
- TxRateIdx = MCS7;
- else if (MCS6 && (Rssi > -74))
- TxRateIdx = MCS6;
- else if (MCS5 && (Rssi > -78))
- TxRateIdx = MCS5;
- else if (MCS4 && (Rssi > -82))
- TxRateIdx = MCS4;
- else if (MCS4 == 0) // for B-only mode
- TxRateIdx = MCS3;
- else if (MCS3 && (Rssi > -85))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi > -87))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi > -90))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
-
- // if (TxRateIdx != pAd->CommonCfg.TxRateIndex)
- {
- pEntry->CurrTxRateIndex = TxRateIdx;
- pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(pEntry->CurrTxRateIndex+1)*5];
- MlmeSetTxRate(pAd, pEntry, pNextTxRate);
- }
-
- NdisZeroMemory(pEntry->TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pEntry->PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
- pEntry->fLastSecAccordingRSSI = TRUE;
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
-
- continue;
- }
-
- if (pEntry->fLastSecAccordingRSSI == TRUE)
- {
- pEntry->fLastSecAccordingRSSI = FALSE;
- pEntry->LastSecTxRateChangeAction = 0;
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
-
- continue;
- }
-
- do
- {
- BOOLEAN bTrainUpDown = FALSE;
-
- pEntry->CurrTxRateStableTime ++;
-
- // downgrade TX quality if PER >= Rate-Down threshold
- if (TxErrorRatio >= TrainDown)
- {
- bTrainUpDown = TRUE;
- pEntry->TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
- }
- // upgrade TX quality if PER <= Rate-Up threshold
- else if (TxErrorRatio <= TrainUp)
- {
- bTrainUpDown = TRUE;
- bUpgradeQuality = TRUE;
- if (pEntry->TxQuality[CurrRateIdx])
- pEntry->TxQuality[CurrRateIdx] --; // quality very good in CurrRate
-
- if (pEntry->TxRateUpPenalty)
- pEntry->TxRateUpPenalty --;
- else if (pEntry->TxQuality[UpRateIdx])
- pEntry->TxQuality[UpRateIdx] --; // may improve next UP rate's quality
- }
-
- pEntry->PER[CurrRateIdx] = (UCHAR)TxErrorRatio;
-
- if (bTrainUpDown)
- {
- // perform DRS - consider TxRate Down first, then rate up.
- if ((CurrRateIdx != DownRateIdx) && (pEntry->TxQuality[CurrRateIdx] >= DRS_TX_QUALITY_WORST_BOUND))
- {
- pEntry->CurrTxRateIndex = DownRateIdx;
- }
- else if ((CurrRateIdx != UpRateIdx) && (pEntry->TxQuality[UpRateIdx] <= 0))
- {
- pEntry->CurrTxRateIndex = UpRateIdx;
- }
- }
- } while (FALSE);
-
- // if rate-up happen, clear all bad history of all TX rates
- if (pEntry->CurrTxRateIndex > CurrRateIdx)
- {
- pEntry->CurrTxRateStableTime = 0;
- pEntry->TxRateUpPenalty = 0;
- pEntry->LastSecTxRateChangeAction = 1; // rate UP
- NdisZeroMemory(pEntry->TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pEntry->PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
-
- //
- // For TxRate fast train up
- //
- if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning)
- {
- RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
-
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = TRUE;
- }
- bTxRateChanged = TRUE;
- }
- // if rate-down happen, only clear DownRate's bad history
- else if (pEntry->CurrTxRateIndex < CurrRateIdx)
- {
- pEntry->CurrTxRateStableTime = 0;
- pEntry->TxRateUpPenalty = 0; // no penalty
- pEntry->LastSecTxRateChangeAction = 2; // rate DOWN
- pEntry->TxQuality[pEntry->CurrTxRateIndex] = 0;
- pEntry->PER[pEntry->CurrTxRateIndex] = 0;
-
- //
- // For TxRate fast train down
- //
- if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning)
- {
- RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
-
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = TRUE;
- }
- bTxRateChanged = TRUE;
- }
- else
- {
- pEntry->LastSecTxRateChangeAction = 0; // rate no change
- bTxRateChanged = FALSE;
- }
-
- pEntry->LastTxOkCount = TxSuccess;
-
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
-
- pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(pEntry->CurrTxRateIndex+1)*5];
- if (bTxRateChanged && pNextTxRate)
- {
- MlmeSetTxRate(pAd, pEntry, pNextTxRate);
- }
- }
-}
-
-/*
- ========================================================================
- Routine Description:
- Station side, Auto TxRate faster train up timer call back function.
-
- Arguments:
- SystemSpecific1 - Not used.
- FunctionContext - Pointer to our Adapter context.
- SystemSpecific2 - Not used.
- SystemSpecific3 - Not used.
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID StaQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)FunctionContext;
- UCHAR UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx = 0;
- ULONG TxTotalCnt;
- ULONG TxErrorRatio = 0;
- BOOLEAN bTxRateChanged; //, bUpgradeQuality = FALSE;
- PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate = NULL;
- PUCHAR pTable;
- UCHAR TableSize = 0;
- UCHAR InitTxRateIdx = 0, TrainUp, TrainDown;
- TX_STA_CNT1_STRUC StaTx1;
- TX_STA_CNT0_STRUC TxStaCnt0;
- CHAR Rssi, ratio;
- ULONG TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
- MAC_TABLE_ENTRY *pEntry;
- ULONG i;
-
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
-
- //
- // walk through MAC table, see if need to change AP's TX rate toward each entry
- //
- for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- pEntry = &pAd->MacTab.Content[i];
-
- // check if this entry need to switch rate automatically
- if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
- continue;
-
- if (INFRA_ON(pAd) && (i == 1))
- Rssi = RTMPMaxRssi(pAd,
- pAd->StaCfg.RssiSample.AvgRssi0,
- pAd->StaCfg.RssiSample.AvgRssi1,
- pAd->StaCfg.RssiSample.AvgRssi2);
- else
- Rssi = RTMPMaxRssi(pAd,
- pEntry->RssiSample.AvgRssi0,
- pEntry->RssiSample.AvgRssi1,
- pEntry->RssiSample.AvgRssi2);
-
- CurrRateIdx = pAd->CommonCfg.TxRateIndex;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &InitTxRateIdx);
-
- // decide the next upgrade rate and downgrade rate, if any
- if ((CurrRateIdx > 0) && (CurrRateIdx < (TableSize - 1)))
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx -1;
- }
- else if (CurrRateIdx == 0)
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx;
- }
- else if (CurrRateIdx == (TableSize - 1))
- {
- UpRateIdx = CurrRateIdx;
- DownRateIdx = CurrRateIdx - 1;
- }
-
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-
-#ifdef DOT11_N_SUPPORT
- if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX))
- {
- TrainUp = (pCurrTxRate->TrainUp + (pCurrTxRate->TrainUp >> 1));
- TrainDown = (pCurrTxRate->TrainDown + (pCurrTxRate->TrainDown >> 1));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- TrainUp = pCurrTxRate->TrainUp;
- TrainDown = pCurrTxRate->TrainDown;
- }
-
- if (pAd->MacTab.Size == 1)
- {
- // Update statistic counter
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
-
- TxRetransmit = StaTx1.field.TxRetransmit;
- TxSuccess = StaTx1.field.TxSuccess;
- TxFailCount = TxStaCnt0.field.TxFailCount;
- TxTotalCnt = TxRetransmit + TxSuccess + TxFailCount;
-
- pAd->RalinkCounters.OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
- pAd->RalinkCounters.OneSecTxFailCount += TxStaCnt0.field.TxFailCount;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
- pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
- pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
-
-#if 0 // test by Gary.
- // if no traffic in the past 1-sec period, don't change TX rate,
- // but clear all bad history. because the bad history may affect the next
- // Chariot throughput test
- TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-#endif
- if (TxTotalCnt)
- TxErrorRatio = ((TxRetransmit + TxFailCount) * 100) / TxTotalCnt;
- }
- else
- {
- TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
- pEntry->OneSecTxRetryOkCount +
- pEntry->OneSecTxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((pEntry->OneSecTxRetryOkCount + pEntry->OneSecTxFailCount) * 100) / TxTotalCnt;
- }
-
-
- //
- // CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI
- // (criteria copied from RT2500 for Netopia case)
- //
- if (TxTotalCnt <= 12)
- {
- NdisZeroMemory(pAd->DrsCounters.TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pAd->DrsCounters.PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
-
- if ((pAd->DrsCounters.LastSecTxRateChangeAction == 1) && (CurrRateIdx != DownRateIdx))
- {
- pAd->CommonCfg.TxRateIndex = DownRateIdx;
- pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
- }
- else if ((pAd->DrsCounters.LastSecTxRateChangeAction == 2) && (CurrRateIdx != UpRateIdx))
- {
- pAd->CommonCfg.TxRateIndex = UpRateIdx;
- }
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("QuickDRS: TxTotalCnt <= 15, train back to original rate \n"));
- return;
- }
-
- do
- {
- ULONG OneSecTxNoRetryOKRationCount;
-
- if (pAd->DrsCounters.LastTimeTxRateChangeAction == 0)
- ratio = 5;
- else
- ratio = 4;
-
- // downgrade TX quality if PER >= Rate-Down threshold
- if (TxErrorRatio >= TrainDown)
- {
- pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
- }
-
- pAd->DrsCounters.PER[CurrRateIdx] = (UCHAR)TxErrorRatio;
-
- OneSecTxNoRetryOKRationCount = (TxSuccess * ratio);
-
- // perform DRS - consider TxRate Down first, then rate up.
- if ((pAd->DrsCounters.LastSecTxRateChangeAction == 1) && (CurrRateIdx != DownRateIdx))
- {
- if ((pAd->DrsCounters.LastTxOkCount + 2) >= OneSecTxNoRetryOKRationCount)
- {
- pAd->CommonCfg.TxRateIndex = DownRateIdx;
- pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
-
- }
-
- }
- else if ((pAd->DrsCounters.LastSecTxRateChangeAction == 2) && (CurrRateIdx != UpRateIdx))
- {
- if ((TxErrorRatio >= 50) || (TxErrorRatio >= TrainDown))
- {
-
- }
- else if ((pAd->DrsCounters.LastTxOkCount + 2) >= OneSecTxNoRetryOKRationCount)
- {
- pAd->CommonCfg.TxRateIndex = UpRateIdx;
- }
- }
- }while (FALSE);
-
- // if rate-up happen, clear all bad history of all TX rates
- if (pAd->CommonCfg.TxRateIndex > CurrRateIdx)
- {
- pAd->DrsCounters.TxRateUpPenalty = 0;
- NdisZeroMemory(pAd->DrsCounters.TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pAd->DrsCounters.PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
- bTxRateChanged = TRUE;
- }
- // if rate-down happen, only clear DownRate's bad history
- else if (pAd->CommonCfg.TxRateIndex < CurrRateIdx)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE,("QuickDRS: --TX rate from %d to %d \n", CurrRateIdx, pAd->CommonCfg.TxRateIndex));
-
- pAd->DrsCounters.TxRateUpPenalty = 0; // no penalty
- pAd->DrsCounters.TxQuality[pAd->CommonCfg.TxRateIndex] = 0;
- pAd->DrsCounters.PER[pAd->CommonCfg.TxRateIndex] = 0;
- bTxRateChanged = TRUE;
- }
- else
- {
- bTxRateChanged = FALSE;
- }
-
- pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(pAd->CommonCfg.TxRateIndex+1)*5];
- if (bTxRateChanged && pNextTxRate)
- {
- MlmeSetTxRate(pAd, pEntry, pNextTxRate);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- This routine is executed periodically inside MlmePeriodicExec() after
- association with an AP.
- It checks if StaCfg.Psm is consistent with user policy (recorded in
- StaCfg.WindowsPowerMode). If not, enforce user policy. However,
- there're some conditions to consider:
- 1. we don't support power-saving in ADHOC mode, so Psm=PWR_ACTIVE all
- the time when Mibss==TRUE
- 2. When link up in INFRA mode, Psm should not be switch to PWR_SAVE
- if outgoing traffic available in TxRing or MgmtRing.
- Output:
- 1. change pAd->StaCfg.Psm to PWR_SAVE or leave it untouched
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeCheckPsmChange(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32)
-{
- ULONG PowerMode;
-
- // condition -
- // 1. Psm maybe ON only happen in INFRASTRUCTURE mode
- // 2. user wants either MAX_PSP or FAST_PSP
- // 3. but current psm is not in PWR_SAVE
- // 4. CNTL state machine is not doing SCANning
- // 5. no TX SUCCESS event for the past 1-sec period
-#ifdef NDIS51_MINIPORT
- if (pAd->StaCfg.WindowsPowerProfile == NdisPowerProfileBattery)
- PowerMode = pAd->StaCfg.WindowsBatteryPowerMode;
- else
-#endif
- PowerMode = pAd->StaCfg.WindowsPowerMode;
-
- if (INFRA_ON(pAd) &&
- (PowerMode != Ndis802_11PowerModeCAM) &&
- (pAd->StaCfg.Psm == PWR_ACTIVE) &&
-// (! RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) /*&&
- (pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
- (pAd->RalinkCounters.OneSecTxRetryOkCount == 0)*/)
- {
- NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
- pAd->RalinkCounters.RxCountSinceLastNULL = 0;
- MlmeSetPsmBit(pAd, PWR_SAVE);
- if (!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable))
- {
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE);
- }
- else
- {
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- }
- }
-}
-
-// IRQL = PASSIVE_LEVEL
-// IRQL = DISPATCH_LEVEL
-VOID MlmeSetPsmBit(
- IN PRTMP_ADAPTER pAd,
- IN USHORT psm)
-{
- AUTO_RSP_CFG_STRUC csr4;
-
- pAd->StaCfg.Psm = psm;
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
- csr4.field.AckCtsPsmBit = (psm == PWR_SAVE)? 1:0;
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetPsmBit = %d\n", psm));
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeSetTxPreamble(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TxPreamble)
-{
- AUTO_RSP_CFG_STRUC csr4;
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- //TxPreamble = Rt802_11PreambleLong;
-
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
- if (TxPreamble == Rt802_11PreambleLong)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetTxPreamble (= LONG PREAMBLE)\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- csr4.field.AutoResponderPreamble = 0;
- }
- else
- {
- // NOTE: 1Mbps should always use long preamble
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetTxPreamble (= SHORT PREAMBLE)\n"));
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- csr4.field.AutoResponderPreamble = 1;
- }
-
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
-}
-
-/*
- ==========================================================================
- Description:
- Update basic rate bitmap
- ==========================================================================
- */
-
-VOID UpdateBasicRateBitmap(
- IN PRTMP_ADAPTER pAdapter)
-{
- INT i, j;
- /* 1 2 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 */
- UCHAR rate[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
- UCHAR *sup_p = pAdapter->CommonCfg.SupRate;
- UCHAR *ext_p = pAdapter->CommonCfg.ExtRate;
- ULONG bitmap = pAdapter->CommonCfg.BasicRateBitmap;
-
-
- /* if A mode, always use fix BasicRateBitMap */
- //if (pAdapter->CommonCfg.Channel == PHY_11A)
- if (pAdapter->CommonCfg.Channel > 14)
- pAdapter->CommonCfg.BasicRateBitmap = 0x150; /* 6, 12, 24M */
- /* End of if */
-
- if (pAdapter->CommonCfg.BasicRateBitmap > 4095)
- {
- /* (2 ^ MAX_LEN_OF_SUPPORTED_RATES) -1 */
- return;
- } /* End of if */
-
- for(i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- sup_p[i] &= 0x7f;
- ext_p[i] &= 0x7f;
- } /* End of for */
-
- for(i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- if (bitmap & (1 << i))
- {
- for(j=0; j<MAX_LEN_OF_SUPPORTED_RATES; j++)
- {
- if (sup_p[j] == rate[i])
- sup_p[j] |= 0x80;
- /* End of if */
- } /* End of for */
-
- for(j=0; j<MAX_LEN_OF_SUPPORTED_RATES; j++)
- {
- if (ext_p[j] == rate[i])
- ext_p[j] |= 0x80;
- /* End of if */
- } /* End of for */
- } /* End of if */
- } /* End of for */
-} /* End of UpdateBasicRateBitmap */
-
-// IRQL = PASSIVE_LEVEL
-// IRQL = DISPATCH_LEVEL
-// bLinkUp is to identify the inital link speed.
-// TRUE indicates the rate update at linkup, we should not try to set the rate at 54Mbps.
-VOID MlmeUpdateTxRates(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bLinkUp,
- IN UCHAR apidx)
-{
- int i, num;
- UCHAR Rate = RATE_6, MaxDesire = RATE_1, MaxSupport = RATE_1;
- UCHAR MinSupport = RATE_54;
- ULONG BasicRateBitmap = 0;
- UCHAR CurrBasicRate = RATE_1;
- UCHAR *pSupRate, SupRateLen, *pExtRate, ExtRateLen;
- PHTTRANSMIT_SETTING pHtPhy = NULL;
- PHTTRANSMIT_SETTING pMaxHtPhy = NULL;
- PHTTRANSMIT_SETTING pMinHtPhy = NULL;
- BOOLEAN *auto_rate_cur_p;
- UCHAR HtMcs = MCS_AUTO;
-
- // find max desired rate
- UpdateBasicRateBitmap(pAd);
-
- num = 0;
- auto_rate_cur_p = NULL;
- for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- switch (pAd->CommonCfg.DesireRate[i] & 0x7f)
- {
- case 2: Rate = RATE_1; num++; break;
- case 4: Rate = RATE_2; num++; break;
- case 11: Rate = RATE_5_5; num++; break;
- case 22: Rate = RATE_11; num++; break;
- case 12: Rate = RATE_6; num++; break;
- case 18: Rate = RATE_9; num++; break;
- case 24: Rate = RATE_12; num++; break;
- case 36: Rate = RATE_18; num++; break;
- case 48: Rate = RATE_24; num++; break;
- case 72: Rate = RATE_36; num++; break;
- case 96: Rate = RATE_48; num++; break;
- case 108: Rate = RATE_54; num++; break;
- //default: Rate = RATE_1; break;
- }
- if (MaxDesire < Rate) MaxDesire = Rate;
- }
-
-//===========================================================================
-//===========================================================================
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pHtPhy = &pAd->StaCfg.HTPhyMode;
- pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
- pMinHtPhy = &pAd->StaCfg.MinHTPhyMode;
-
- auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
- HtMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
-
- if ((pAd->StaCfg.BssType == BSS_ADHOC) &&
- (pAd->CommonCfg.PhyMode == PHY_11B) &&
- (MaxDesire > RATE_11))
- {
- MaxDesire = RATE_11;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pAd->CommonCfg.MaxDesiredRate = MaxDesire;
- pMinHtPhy->word = 0;
- pMaxHtPhy->word = 0;
- pHtPhy->word = 0;
-
- // Auto rate switching is enabled only if more than one DESIRED RATES are
- // specified; otherwise disabled
- if (num <= 1)
- {
- //OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = FALSE;
- *auto_rate_cur_p = FALSE;
- }
- else
- {
- //OPSTATUS_SET_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = TRUE;
- *auto_rate_cur_p = TRUE;
- }
-
-#if 1
- if (HtMcs != MCS_AUTO)
- {
- //OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = FALSE;
- *auto_rate_cur_p = FALSE;
- }
- else
- {
- //OPSTATUS_SET_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = TRUE;
- *auto_rate_cur_p = TRUE;
- }
-#endif
-
-#ifdef CONFIG_STA_SUPPORT
- if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
- {
- pSupRate = &pAd->StaActive.SupRate[0];
- pExtRate = &pAd->StaActive.ExtRate[0];
- SupRateLen = pAd->StaActive.SupRateLen;
- ExtRateLen = pAd->StaActive.ExtRateLen;
- }
- else
-#endif // CONFIG_STA_SUPPORT //
- {
- pSupRate = &pAd->CommonCfg.SupRate[0];
- pExtRate = &pAd->CommonCfg.ExtRate[0];
- SupRateLen = pAd->CommonCfg.SupRateLen;
- ExtRateLen = pAd->CommonCfg.ExtRateLen;
- }
-
- // find max supported rate
- for (i=0; i<SupRateLen; i++)
- {
- switch (pSupRate[i] & 0x7f)
- {
- case 2: Rate = RATE_1; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0001; break;
- case 4: Rate = RATE_2; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0002; break;
- case 11: Rate = RATE_5_5; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0004; break;
- case 22: Rate = RATE_11; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0008; break;
- case 12: Rate = RATE_6; /*if (pSupRate[i] & 0x80)*/ BasicRateBitmap |= 0x0010; break;
- case 18: Rate = RATE_9; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0020; break;
- case 24: Rate = RATE_12; /*if (pSupRate[i] & 0x80)*/ BasicRateBitmap |= 0x0040; break;
- case 36: Rate = RATE_18; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0080; break;
- case 48: Rate = RATE_24; /*if (pSupRate[i] & 0x80)*/ BasicRateBitmap |= 0x0100; break;
- case 72: Rate = RATE_36; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0200; break;
- case 96: Rate = RATE_48; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0400; break;
- case 108: Rate = RATE_54; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0800; break;
- default: Rate = RATE_1; break;
- }
- if (MaxSupport < Rate) MaxSupport = Rate;
-
- if (MinSupport > Rate) MinSupport = Rate;
- }
-
- for (i=0; i<ExtRateLen; i++)
- {
- switch (pExtRate[i] & 0x7f)
- {
- case 2: Rate = RATE_1; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0001; break;
- case 4: Rate = RATE_2; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0002; break;
- case 11: Rate = RATE_5_5; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0004; break;
- case 22: Rate = RATE_11; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0008; break;
- case 12: Rate = RATE_6; /*if (pExtRate[i] & 0x80)*/ BasicRateBitmap |= 0x0010; break;
- case 18: Rate = RATE_9; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0020; break;
- case 24: Rate = RATE_12; /*if (pExtRate[i] & 0x80)*/ BasicRateBitmap |= 0x0040; break;
- case 36: Rate = RATE_18; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0080; break;
- case 48: Rate = RATE_24; /*if (pExtRate[i] & 0x80)*/ BasicRateBitmap |= 0x0100; break;
- case 72: Rate = RATE_36; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0200; break;
- case 96: Rate = RATE_48; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0400; break;
- case 108: Rate = RATE_54; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0800; break;
- default: Rate = RATE_1; break;
- }
- if (MaxSupport < Rate) MaxSupport = Rate;
-
- if (MinSupport > Rate) MinSupport = Rate;
- }
-
- RTMP_IO_WRITE32(pAd, LEGACY_BASIC_RATE, BasicRateBitmap);
-
- // bug fix
- // pAd->CommonCfg.BasicRateBitmap = BasicRateBitmap;
-
- // calculate the exptected ACK rate for each TX rate. This info is used to caculate
- // the DURATION field of outgoing uniicast DATA/MGMT frame
- for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- if (BasicRateBitmap & (0x01 << i))
- CurrBasicRate = (UCHAR)i;
- pAd->CommonCfg.ExpectedACKRate[i] = CurrBasicRate;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateTxRates[MaxSupport = %d] = MaxDesire %d Mbps\n", RateIdToMbps[MaxSupport], RateIdToMbps[MaxDesire]));
- // max tx rate = min {max desire rate, max supported rate}
- if (MaxSupport < MaxDesire)
- pAd->CommonCfg.MaxTxRate = MaxSupport;
- else
- pAd->CommonCfg.MaxTxRate = MaxDesire;
-
- pAd->CommonCfg.MinTxRate = MinSupport;
- // 2003-07-31 john - 2500 doesn't have good sensitivity at high OFDM rates. to increase the success
- // ratio of initial DHCP packet exchange, TX rate starts from a lower rate depending
- // on average RSSI
- // 1. RSSI >= -70db, start at 54 Mbps (short distance)
- // 2. -70 > RSSI >= -75, start at 24 Mbps (mid distance)
- // 3. -75 > RSSI, start at 11 Mbps (long distance)
- //if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)/* &&
- // OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)*/)
- if (*auto_rate_cur_p)
- {
- short dbm = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- dbm = pAd->StaCfg.RssiSample.AvgRssi0 - pAd->BbpRssiToDbmDelta;
-#endif // CONFIG_STA_SUPPORT //
- if (bLinkUp == TRUE)
- pAd->CommonCfg.TxRate = RATE_24;
- else
- pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-
- if (dbm < -75)
- pAd->CommonCfg.TxRate = RATE_11;
- else if (dbm < -70)
- pAd->CommonCfg.TxRate = RATE_24;
-
- // should never exceed MaxTxRate (consider 11B-only mode)
- if (pAd->CommonCfg.TxRate > pAd->CommonCfg.MaxTxRate)
- pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-
- pAd->CommonCfg.TxRateIndex = 0;
- }
- else
- {
- pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
- pHtPhy->field.MCS = (pAd->CommonCfg.MaxTxRate > 3) ? (pAd->CommonCfg.MaxTxRate - 4) : pAd->CommonCfg.MaxTxRate;
- pHtPhy->field.MODE = (pAd->CommonCfg.MaxTxRate > 3) ? MODE_OFDM : MODE_CCK;
-
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC = pHtPhy->field.STBC;
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI = pHtPhy->field.ShortGI;
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS = pHtPhy->field.MCS;
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE = pHtPhy->field.MODE;
- }
-
- if (pAd->CommonCfg.TxRate <= RATE_11)
- {
- pMaxHtPhy->field.MODE = MODE_CCK;
- pMaxHtPhy->field.MCS = pAd->CommonCfg.TxRate;
- pMinHtPhy->field.MCS = pAd->CommonCfg.MinTxRate;
- }
- else
- {
- pMaxHtPhy->field.MODE = MODE_OFDM;
- pMaxHtPhy->field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.TxRate];
- if (pAd->CommonCfg.MinTxRate >= RATE_6 && (pAd->CommonCfg.MinTxRate <= RATE_54))
- {pMinHtPhy->field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MinTxRate];}
- else
- {pMinHtPhy->field.MCS = pAd->CommonCfg.MinTxRate;}
- }
-
- pHtPhy->word = (pMaxHtPhy->word);
- if (bLinkUp && (pAd->OpMode == OPMODE_STA))
- {
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word = pHtPhy->word;
- pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word = pMaxHtPhy->word;
- pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word = pMinHtPhy->word;
- }
- else
- {
- switch (pAd->CommonCfg.PhyMode)
- {
- case PHY_11BG_MIXED:
- case PHY_11B:
-#ifdef DOT11_N_SUPPORT
- case PHY_11BGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.MlmeRate = RATE_1;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
-
-//#ifdef WIFI_TEST
- pAd->CommonCfg.RtsRate = RATE_11;
-//#else
-// pAd->CommonCfg.RtsRate = RATE_1;
-//#endif
- break;
- case PHY_11G:
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AGN_MIXED:
- case PHY_11GN_MIXED:
- case PHY_11N_2_4G:
- case PHY_11AN_MIXED:
- case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- break;
- case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11ABGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- if (pAd->CommonCfg.Channel <= 14)
- {
- pAd->CommonCfg.MlmeRate = RATE_1;
- pAd->CommonCfg.RtsRate = RATE_1;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
- }
- else
- {
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- break;
- default: // error
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->CommonCfg.RtsRate = RATE_1;
- break;
- }
- //
- // Keep Basic Mlme Rate.
- //
- pAd->MacTab.Content[MCAST_WCID].HTPhyMode.word = pAd->CommonCfg.MlmeTransmit.word;
- if (pAd->CommonCfg.MlmeTransmit.field.MODE == MODE_OFDM)
- pAd->MacTab.Content[MCAST_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[RATE_24];
- else
- pAd->MacTab.Content[MCAST_WCID].HTPhyMode.field.MCS = RATE_1;
- pAd->CommonCfg.BasicMlmeRate = pAd->CommonCfg.MlmeRate;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, MinRate=%d, Rate Switching =%d)\n",
- RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport], RateIdToMbps[pAd->CommonCfg.MaxTxRate], RateIdToMbps[pAd->CommonCfg.MinTxRate],
- /*OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)*/*auto_rate_cur_p));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04lx)\n",
- RateIdToMbps[pAd->CommonCfg.TxRate], RateIdToMbps[pAd->CommonCfg.RtsRate], BasicRateBitmap));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeUpdateTxRates (MlmeTransmit=0x%x, MinHTPhyMode=%x, MaxHTPhyMode=0x%x, HTPhyMode=0x%x)\n",
- pAd->CommonCfg.MlmeTransmit.word, pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word ));
-}
-
-#ifdef DOT11_N_SUPPORT
-/*
- ==========================================================================
- Description:
- This function update HT Rate setting.
- Input Wcid value is valid for 2 case :
- 1. it's used for Station in infra mode that copy AP rate to Mactable.
- 2. OR Station in adhoc mode to copy peer's HT rate to Mactable.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeUpdateHtTxRates(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx)
-{
- UCHAR StbcMcs; //j, StbcMcs, bitmask;
- CHAR i; // 3*3
- RT_HT_CAPABILITY *pRtHtCap = NULL;
- RT_HT_PHY_INFO *pActiveHtPhy = NULL;
- ULONG BasicMCS;
- UCHAR j, bitmask;
- PRT_HT_PHY_INFO pDesireHtPhy = NULL;
- PHTTRANSMIT_SETTING pHtPhy = NULL;
- PHTTRANSMIT_SETTING pMaxHtPhy = NULL;
- PHTTRANSMIT_SETTING pMinHtPhy = NULL;
- BOOLEAN *auto_rate_cur_p;
-
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates===> \n"));
-
- auto_rate_cur_p = NULL;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pDesireHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
- pActiveHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
- pHtPhy = &pAd->StaCfg.HTPhyMode;
- pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
- pMinHtPhy = &pAd->StaCfg.MinHTPhyMode;
-
- auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
- {
- if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- return;
-
- pRtHtCap = &pAd->StaActive.SupportedHtPhy;
- pActiveHtPhy = &pAd->StaActive.SupportedPhyInfo;
- StbcMcs = (UCHAR)pAd->MlmeAux.AddHtInfo.AddHtInfo3.StbcMcs;
- BasicMCS =pAd->MlmeAux.AddHtInfo.MCSSet[0]+(pAd->MlmeAux.AddHtInfo.MCSSet[1]<<8)+(StbcMcs<<16);
- if ((pAd->CommonCfg.DesiredHtPhy.TxSTBC) && (pRtHtCap->RxSTBC) && (pAd->Antenna.field.TxPath == 2))
- pMaxHtPhy->field.STBC = STBC_USE;
- else
- pMaxHtPhy->field.STBC = STBC_NONE;
- }
- else
-#endif // CONFIG_STA_SUPPORT //
- {
- if (pDesireHtPhy->bHtEnable == FALSE)
- return;
-
- pRtHtCap = &pAd->CommonCfg.DesiredHtPhy;
- StbcMcs = (UCHAR)pAd->CommonCfg.AddHTInfo.AddHtInfo3.StbcMcs;
- BasicMCS = pAd->CommonCfg.AddHTInfo.MCSSet[0]+(pAd->CommonCfg.AddHTInfo.MCSSet[1]<<8)+(StbcMcs<<16);
- if ((pAd->CommonCfg.DesiredHtPhy.TxSTBC) && (pRtHtCap->RxSTBC) && (pAd->Antenna.field.TxPath == 2))
- pMaxHtPhy->field.STBC = STBC_USE;
- else
- pMaxHtPhy->field.STBC = STBC_NONE;
- }
-
- // Decide MAX ht rate.
- if ((pRtHtCap->GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- pMaxHtPhy->field.MODE = MODE_HTGREENFIELD;
- else
- pMaxHtPhy->field.MODE = MODE_HTMIX;
-
- if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth) && (pRtHtCap->ChannelWidth))
- pMaxHtPhy->field.BW = BW_40;
- else
- pMaxHtPhy->field.BW = BW_20;
-
- if (pMaxHtPhy->field.BW == BW_20)
- pMaxHtPhy->field.ShortGI = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 & pRtHtCap->ShortGIfor20);
- else
- pMaxHtPhy->field.ShortGI = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 & pRtHtCap->ShortGIfor40);
-
- for (i=23; i>=0; i--) // 3*3
- {
- j = i/8;
- bitmask = (1<<(i-(j*8)));
-
- if ((pActiveHtPhy->MCSSet[j] & bitmask) && (pDesireHtPhy->MCSSet[j] & bitmask))
- {
- pMaxHtPhy->field.MCS = i;
- break;
- }
-
- if (i==0)
- break;
- }
-
- // Copy MIN ht rate. rt2860???
- pMinHtPhy->field.BW = BW_20;
- pMinHtPhy->field.MCS = 0;
- pMinHtPhy->field.STBC = 0;
- pMinHtPhy->field.ShortGI = 0;
- //If STA assigns fixed rate. update to fixed here.
-#ifdef CONFIG_STA_SUPPORT
- if ( (pAd->OpMode == OPMODE_STA) && (pDesireHtPhy->MCSSet[0] != 0xff))
- {
- if (pDesireHtPhy->MCSSet[4] != 0)
- {
- pMaxHtPhy->field.MCS = 32;
- pMinHtPhy->field.MCS = 32;
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates<=== Use Fixed MCS = %d\n",pMinHtPhy->field.MCS));
- }
-
- for (i=23; (CHAR)i >= 0; i--) // 3*3
- {
- j = i/8;
- bitmask = (1<<(i-(j*8)));
- if ( (pDesireHtPhy->MCSSet[j] & bitmask) && (pActiveHtPhy->MCSSet[j] & bitmask))
- {
- pMaxHtPhy->field.MCS = i;
- pMinHtPhy->field.MCS = i;
- break;
- }
- if (i==0)
- break;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- // Decide ht rate
- pHtPhy->field.STBC = pMaxHtPhy->field.STBC;
- pHtPhy->field.BW = pMaxHtPhy->field.BW;
- pHtPhy->field.MODE = pMaxHtPhy->field.MODE;
- pHtPhy->field.MCS = pMaxHtPhy->field.MCS;
- pHtPhy->field.ShortGI = pMaxHtPhy->field.ShortGI;
-
- // use default now. rt2860
- if (pDesireHtPhy->MCSSet[0] != 0xff)
- *auto_rate_cur_p = FALSE;
- else
- *auto_rate_cur_p = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateHtTxRates<---.AMsduSize = %d \n", pAd->CommonCfg.DesiredHtPhy.AmsduSize ));
- DBGPRINT(RT_DEBUG_TRACE,("TX: MCS[0] = %x (choose %d), BW = %d, ShortGI = %d, MODE = %d, \n", pActiveHtPhy->MCSSet[0],pHtPhy->field.MCS,
- pHtPhy->field.BW, pHtPhy->field.ShortGI, pHtPhy->field.MODE));
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates<=== \n"));
-}
-#endif // DOT11_N_SUPPORT //
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeRadioOff(
- IN PRTMP_ADAPTER pAd)
-{
- RT28XX_MLME_RADIO_OFF(pAd);
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeRadioOn(
- IN PRTMP_ADAPTER pAd)
-{
- RT28XX_MLME_RADIO_ON(pAd);
-}
-
-// ===========================================================================================
-// bss_table.c
-// ===========================================================================================
-
-
-/*! \brief initialize BSS table
- * \param p_tab pointer to the table
- * \return none
- * \pre
- * \post
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-VOID BssTableInit(
- IN BSS_TABLE *Tab)
-{
- int i;
-
- Tab->BssNr = 0;
- Tab->BssOverlapNr = 0;
- for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++)
- {
- NdisZeroMemory(&Tab->BssEntry[i], sizeof(BSS_ENTRY));
- Tab->BssEntry[i].Rssi = -127; // initial the rssi as a minimum value
- }
-}
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableInit(
- IN PRTMP_ADAPTER pAd,
- IN BA_TABLE *Tab)
-{
- int i;
-
- Tab->numAsOriginator = 0;
- Tab->numAsRecipient = 0;
- NdisAllocateSpinLock(&pAd->BATabLock);
- for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++)
- {
- Tab->BARecEntry[i].REC_BA_Status = Recipient_NONE;
- NdisAllocateSpinLock(&(Tab->BARecEntry[i].RxReRingLock));
- }
- for (i = 0; i < MAX_LEN_OF_BA_ORI_TABLE; i++)
- {
- Tab->BAOriEntry[i].ORI_BA_Status = Originator_NONE;
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-/*! \brief search the BSS table by SSID
- * \param p_tab pointer to the bss table
- * \param ssid SSID string
- * \return index of the table, BSS_NOT_FOUND if not in the table
- * \pre
- * \post
- * \note search by sequential search
-
- IRQL = DISPATCH_LEVEL
-
- */
-ULONG BssTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN UCHAR Channel)
-{
- UCHAR i;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- //
- // Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G.
- // We should distinguish this case.
- //
- if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
- ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
- MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid))
- {
- return i;
- }
- }
- return (ULONG)BSS_NOT_FOUND;
-}
-
-ULONG BssSsidTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel)
-{
- UCHAR i;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- //
- // Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G.
- // We should distinguish this case.
- //
- if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
- ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
- MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid) &&
- SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen))
- {
- return i;
- }
- }
- return (ULONG)BSS_NOT_FOUND;
-}
-
-ULONG BssTableSearchWithSSID(
- IN BSS_TABLE *Tab,
- IN PUCHAR Bssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel)
-{
- UCHAR i;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
- ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
- MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid) &&
- (SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen) ||
- (NdisEqualMemory(pSsid, ZeroSsid, SsidLen)) ||
- (NdisEqualMemory(Tab->BssEntry[i].Ssid, ZeroSsid, Tab->BssEntry[i].SsidLen))))
- {
- return i;
- }
- }
- return (ULONG)BSS_NOT_FOUND;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID BssTableDeleteEntry(
- IN OUT BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN UCHAR Channel)
-{
- UCHAR i, j;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- if ((Tab->BssEntry[i].Channel == Channel) &&
- (MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid)))
- {
- for (j = i; j < Tab->BssNr - 1; j++)
- {
- NdisMoveMemory(&(Tab->BssEntry[j]), &(Tab->BssEntry[j + 1]), sizeof(BSS_ENTRY));
- }
- NdisZeroMemory(&(Tab->BssEntry[Tab->BssNr - 1]), sizeof(BSS_ENTRY));
- Tab->BssNr -= 1;
- return;
- }
- }
-}
-
-#ifdef DOT11_N_SUPPORT
-/*
- ========================================================================
- Routine Description:
- Delete the Originator Entry in BAtable. Or decrease numAs Originator by 1 if needed.
-
- Arguments:
- // IRQL = DISPATCH_LEVEL
- ========================================================================
-*/
-VOID BATableDeleteORIEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN BA_ORI_ENTRY *pBAORIEntry)
-{
-
- if (pBAORIEntry->ORI_BA_Status != Originator_NONE)
- {
- NdisAcquireSpinLock(&pAd->BATabLock);
- if (pBAORIEntry->ORI_BA_Status == Originator_Done)
- {
- pAd->BATable.numAsOriginator -= 1;
- DBGPRINT(RT_DEBUG_TRACE, ("BATableDeleteORIEntry numAsOriginator= %ld\n", pAd->BATable.numAsRecipient));
- // Erase Bitmap flag.
- }
- pAd->MacTab.Content[pBAORIEntry->Wcid].TXBAbitmap &= (~(1<<(pBAORIEntry->TID) )); // If STA mode, erase flag here
- pAd->MacTab.Content[pBAORIEntry->Wcid].BAOriWcidArray[pBAORIEntry->TID] = 0; // If STA mode, erase flag here
- pBAORIEntry->ORI_BA_Status = Originator_NONE;
- pBAORIEntry->Token = 1;
- // Not clear Sequence here.
- NdisReleaseSpinLock(&pAd->BATabLock);
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-/*! \brief
- * \param
- * \return
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-VOID BssEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_ENTRY *pBss,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN PCF_PARM pCfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR Channel,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE)
-{
- COPY_MAC_ADDR(pBss->Bssid, pBssid);
- // Default Hidden SSID to be TRUE, it will be turned to FALSE after coping SSID
- pBss->Hidden = 1;
- if (SsidLen > 0)
- {
- // For hidden SSID AP, it might send beacon with SSID len equal to 0
- // Or send beacon /probe response with SSID len matching real SSID length,
- // but SSID is all zero. such as "00-00-00-00" with length 4.
- // We have to prevent this case overwrite correct table
- if (NdisEqualMemory(Ssid, ZeroSsid, SsidLen) == 0)
- {
- NdisZeroMemory(pBss->Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pBss->Ssid, Ssid, SsidLen);
- pBss->SsidLen = SsidLen;
- pBss->Hidden = 0;
- }
- }
- else
- pBss->SsidLen = 0;
- pBss->BssType = BssType;
- pBss->BeaconPeriod = BeaconPeriod;
- if (BssType == BSS_INFRA)
- {
- if (pCfParm->bValid)
- {
- pBss->CfpCount = pCfParm->CfpCount;
- pBss->CfpPeriod = pCfParm->CfpPeriod;
- pBss->CfpMaxDuration = pCfParm->CfpMaxDuration;
- pBss->CfpDurRemaining = pCfParm->CfpDurRemaining;
- }
- }
- else
- {
- pBss->AtimWin = AtimWin;
- }
-
- pBss->CapabilityInfo = CapabilityInfo;
- // The privacy bit indicate security is ON, it maight be WEP, TKIP or AES
- // Combine with AuthMode, they will decide the connection methods.
- pBss->Privacy = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo);
- ASSERT(SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
- if (SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES)
- NdisMoveMemory(pBss->SupRate, SupRate, SupRateLen);
- else
- NdisMoveMemory(pBss->SupRate, SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- pBss->SupRateLen = SupRateLen;
- ASSERT(ExtRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pBss->ExtRate, ExtRate, ExtRateLen);
- NdisMoveMemory(&pBss->HtCapability, pHtCapability, HtCapabilityLen);
- NdisMoveMemory(&pBss->AddHtInfo, pAddHtInfo, AddHtInfoLen);
- pBss->NewExtChanOffset = NewExtChanOffset;
- pBss->ExtRateLen = ExtRateLen;
- pBss->Channel = Channel;
- pBss->CentralChannel = Channel;
- pBss->Rssi = Rssi;
- // Update CkipFlag. if not exists, the value is 0x0
- pBss->CkipFlag = CkipFlag;
-
- // New for microsoft Fixed IEs
- NdisMoveMemory(pBss->FixIEs.Timestamp, &TimeStamp, 8);
- pBss->FixIEs.BeaconInterval = BeaconPeriod;
- pBss->FixIEs.Capabilities = CapabilityInfo;
-
- // New for microsoft Variable IEs
- if (LengthVIE != 0)
- {
- pBss->VarIELen = LengthVIE;
- NdisMoveMemory(pBss->VarIEs, pVIE, pBss->VarIELen);
- }
- else
- {
- pBss->VarIELen = 0;
- }
-
- pBss->AddHtInfoLen = 0;
- pBss->HtCapabilityLen = 0;
-#ifdef DOT11_N_SUPPORT
- if (HtCapabilityLen> 0)
- {
- pBss->HtCapabilityLen = HtCapabilityLen;
- NdisMoveMemory(&pBss->HtCapability, pHtCapability, HtCapabilityLen);
- if (AddHtInfoLen > 0)
- {
- pBss->AddHtInfoLen = AddHtInfoLen;
- NdisMoveMemory(&pBss->AddHtInfo, pAddHtInfo, AddHtInfoLen);
-
- if ((pAddHtInfo->ControlChan > 2)&& (pAddHtInfo->AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (pHtCapability->HtCapInfo.ChannelWidth == BW_40))
- {
- pBss->CentralChannel = pAddHtInfo->ControlChan - 2;
- }
- else if ((pAddHtInfo->AddHtInfo.ExtChanOffset == EXTCHA_ABOVE) && (pHtCapability->HtCapInfo.ChannelWidth == BW_40))
- {
- pBss->CentralChannel = pAddHtInfo->ControlChan + 2;
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- BssCipherParse(pBss);
-
- // new for QOS
- if (pEdcaParm)
- NdisMoveMemory(&pBss->EdcaParm, pEdcaParm, sizeof(EDCA_PARM));
- else
- pBss->EdcaParm.bValid = FALSE;
- if (pQosCapability)
- NdisMoveMemory(&pBss->QosCapability, pQosCapability, sizeof(QOS_CAPABILITY_PARM));
- else
- pBss->QosCapability.bValid = FALSE;
- if (pQbssLoad)
- NdisMoveMemory(&pBss->QbssLoad, pQbssLoad, sizeof(QBSS_LOAD_PARM));
- else
- pBss->QbssLoad.bValid = FALSE;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- PEID_STRUCT pEid;
- USHORT Length = 0;
-
-
- NdisZeroMemory(&pBss->WpaIE.IE[0], MAX_CUSTOM_LEN);
- NdisZeroMemory(&pBss->RsnIE.IE[0], MAX_CUSTOM_LEN);
-#ifdef EXT_BUILD_CHANNEL_LIST
- NdisZeroMemory(&pBss->CountryString[0], 3);
- pBss->bHasCountryIE = FALSE;
-#endif // EXT_BUILD_CHANNEL_LIST //
- pEid = (PEID_STRUCT) pVIE;
- while ((Length + 2 + (USHORT)pEid->Len) <= LengthVIE)
- {
- switch(pEid->Eid)
- {
- case IE_WPA:
- if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- {
- if ((pEid->Len + 2) > MAX_CUSTOM_LEN)
- {
- pBss->WpaIE.IELen = 0;
- break;
- }
- pBss->WpaIE.IELen = pEid->Len + 2;
- NdisMoveMemory(pBss->WpaIE.IE, pEid, pBss->WpaIE.IELen);
- }
- break;
- case IE_RSN:
- if (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- {
- if ((pEid->Len + 2) > MAX_CUSTOM_LEN)
- {
- pBss->RsnIE.IELen = 0;
- break;
- }
- pBss->RsnIE.IELen = pEid->Len + 2;
- NdisMoveMemory(pBss->RsnIE.IE, pEid, pBss->RsnIE.IELen);
- }
- break;
-#ifdef EXT_BUILD_CHANNEL_LIST
- case IE_COUNTRY:
- NdisMoveMemory(&pBss->CountryString[0], pEid->Octet, 3);
- pBss->bHasCountryIE = TRUE;
- break;
-#endif // EXT_BUILD_CHANNEL_LIST //
- }
- Length = Length + 2 + (USHORT)pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-}
-
-/*!
- * \brief insert an entry into the bss table
- * \param p_tab The BSS table
- * \param Bssid BSSID
- * \param ssid SSID
- * \param ssid_len Length of SSID
- * \param bss_type
- * \param beacon_period
- * \param timestamp
- * \param p_cf
- * \param atim_win
- * \param cap
- * \param rates
- * \param rates_len
- * \param channel_idx
- * \return none
- * \pre
- * \post
- * \note If SSID is identical, the old entry will be replaced by the new one
-
- IRQL = DISPATCH_LEVEL
-
- */
-ULONG BssTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN CF_PARM *CfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR ChannelNo,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE)
-{
- ULONG Idx;
-
- Idx = BssTableSearchWithSSID(Tab, pBssid, Ssid, SsidLen, ChannelNo);
- if (Idx == BSS_NOT_FOUND)
- {
- if (Tab->BssNr >= MAX_LEN_OF_BSS_TABLE)
- {
- //
- // It may happen when BSS Table was full.
- // The desired AP will not be added into BSS Table
- // In this case, if we found the desired AP then overwrite BSS Table.
- //
- if(!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, pBssid) ||
- SSID_EQUAL(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Ssid, SsidLen))
- {
- Idx = Tab->BssOverlapNr;
- BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin,
- CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
- NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- Tab->BssOverlapNr = (Tab->BssOverlapNr++) % MAX_LEN_OF_BSS_TABLE;
- }
- return Idx;
- }
- else
- {
- return BSS_NOT_FOUND;
- }
- }
- Idx = Tab->BssNr;
- BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin,
- CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
- NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- Tab->BssNr++;
- }
- else
- {
- BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod,CfParm, AtimWin,
- CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
- NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- }
-
- return Idx;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
-VOID TriEventInit(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
-
- for (i = 0;i < MAX_TRIGGER_EVENT;i++)
- pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
-
- pAd->CommonCfg.TriggerEventTab.EventANo = 0;
- pAd->CommonCfg.TriggerEventTab.EventBCountDown = 0;
-}
-
-ULONG TriEventTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT TRIGGER_EVENT_TAB *Tab,
- IN PUCHAR pBssid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN UCHAR RegClass,
- IN UCHAR ChannelNo)
-{
- // Event A
- if (HtCapabilityLen == 0)
- {
- if (Tab->EventANo < MAX_TRIGGER_EVENT)
- {
- RTMPMoveMemory(Tab->EventA[Tab->EventANo].BSSID, pBssid, 6);
- Tab->EventA[Tab->EventANo].bValid = TRUE;
- Tab->EventA[Tab->EventANo].Channel = ChannelNo;
- Tab->EventA[Tab->EventANo].CDCounter = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
- if (RegClass != 0)
- {
- // Beacon has Regulatory class IE. So use beacon's
- Tab->EventA[Tab->EventANo].RegClass = RegClass;
- }
- else
- {
- // Use Station's Regulatory class instead.
- if (pAd->StaActive.SupportedHtPhy.bHtEnable == TRUE)
- {
- if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
- {
- Tab->EventA[Tab->EventANo].RegClass = 32;
- }
- else if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
- Tab->EventA[Tab->EventANo].RegClass = 33;
- }
- else
- Tab->EventA[Tab->EventANo].RegClass = ??;
-
- }
-
- Tab->EventANo ++;
- }
- }
- else if (pHtCapability->HtCapInfo.Intolerant40)
- {
- Tab->EventBCountDown = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
- }
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Trigger Event table Maintainence called once every second.
-
- Arguments:
- // IRQL = DISPATCH_LEVEL
- ========================================================================
-*/
-VOID TriEventCounterMaintenance(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
- BOOLEAN bNotify = FALSE;
- for (i = 0;i < MAX_TRIGGER_EVENT;i++)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid && (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter > 0))
- {
- pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter--;
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter == 0)
- {
- pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
- pAd->CommonCfg.TriggerEventTab.EventANo --;
- // Need to send 20/40 Coexistence Notify frame if has status change.
- bNotify = TRUE;
- }
- }
- }
- if (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0)
- {
- pAd->CommonCfg.TriggerEventTab.EventBCountDown--;
- if (pAd->CommonCfg.TriggerEventTab.EventBCountDown == 0)
- bNotify = TRUE;
- }
-
- if (bNotify == TRUE)
- Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE);
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-// IRQL = DISPATCH_LEVEL
-VOID BssTableSsidSort(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_TABLE *OutTab,
- IN CHAR Ssid[],
- IN UCHAR SsidLen)
-{
- INT i;
- BssTableInit(OutTab);
-
- for (i = 0; i < pAd->ScanTab.BssNr; i++)
- {
- BSS_ENTRY *pInBss = &pAd->ScanTab.BssEntry[i];
- BOOLEAN bIsHiddenApIncluded = FALSE;
-
- if (((pAd->CommonCfg.bIEEE80211H == 1) &&
- (pAd->MlmeAux.Channel > 14) &&
- RadarChannelCheck(pAd, pInBss->Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- if (pInBss->Hidden)
- bIsHiddenApIncluded = TRUE;
- }
-
- if ((pInBss->BssType == pAd->StaCfg.BssType) &&
- (SSID_EQUAL(Ssid, SsidLen, pInBss->Ssid, pInBss->SsidLen) || bIsHiddenApIncluded))
- {
- BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // If no Country IE exists no Connection will be established when IEEE80211dClientMode is strict.
- if ((pAd->StaCfg.IEEE80211dClientMode == Rt802_11_D_Strict) &&
- (pInBss->bHasCountryIE == FALSE))
- {
- DBGPRINT(RT_DEBUG_TRACE,("StaCfg.IEEE80211dClientMode == Rt802_11_D_Strict, but this AP doesn't have country IE.\n"));
- continue;
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef DOT11_N_SUPPORT
- // 2.4G/5G N only mode
- if ((pInBss->HtCapabilityLen == 0) &&
- ((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)))
- {
- DBGPRINT(RT_DEBUG_TRACE,("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
- continue;
- }
-#endif // DOT11_N_SUPPORT //
-
- // New for WPA2
- // Check the Authmode first
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // Check AuthMode and AuthModeAux for matching, in case AP support dual-mode
- if ((pAd->StaCfg.AuthMode != pInBss->AuthMode) && (pAd->StaCfg.AuthMode != pInBss->AuthModeAux))
- // None matched
- continue;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA.GroupCipher)
- continue;
-
- // check group cipher
- if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) &&
- (pInBss->WPA.GroupCipher != Ndis802_11GroupWEP40Enabled) &&
- (pInBss->WPA.GroupCipher != Ndis802_11GroupWEP104Enabled))
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipherAux))
- continue;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA2.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA2.GroupCipher)
- continue;
-
- // check group cipher
- if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) &&
- (pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP40Enabled) &&
- (pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP104Enabled))
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipherAux))
- continue;
- }
- }
- // Bss Type matched, SSID matched.
- // We will check wepstatus for qualification Bss
- else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
- {
- DBGPRINT(RT_DEBUG_TRACE,("StaCfg.WepStatus=%d, while pInBss->WepStatus=%d\n", pAd->StaCfg.WepStatus, pInBss->WepStatus));
- //
- // For the SESv2 case, we will not qualify WepStatus.
- //
- if (!pInBss->bSES)
- continue;
- }
-
- // Since the AP is using hidden SSID, and we are trying to connect to ANY
- // It definitely will fail. So, skip it.
- // CCX also require not even try to connect it!!
- if (SsidLen == 0)
- continue;
-
-#ifdef DOT11_N_SUPPORT
- // If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
- // If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
- if ((pInBss->CentralChannel != pInBss->Channel) &&
- (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
- {
- if (RTMPCheckChannel(pAd, pInBss->CentralChannel, pInBss->Channel) == FALSE)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- SetCommonHT(pAd);
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- }
- else
- {
- if (pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BAND_WIDTH_20)
- {
- SetCommonHT(pAd);
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- // copy matching BSS from InTab to OutTab
- NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
-
- OutTab->BssNr++;
- }
- else if ((pInBss->BssType == pAd->StaCfg.BssType) && (SsidLen == 0))
- {
- BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-
-#ifdef DOT11_N_SUPPORT
- // 2.4G/5G N only mode
- if ((pInBss->HtCapabilityLen == 0) &&
- ((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)))
- {
- DBGPRINT(RT_DEBUG_TRACE,("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
- continue;
- }
-#endif // DOT11_N_SUPPORT //
-
- // New for WPA2
- // Check the Authmode first
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // Check AuthMode and AuthModeAux for matching, in case AP support dual-mode
- if ((pAd->StaCfg.AuthMode != pInBss->AuthMode) && (pAd->StaCfg.AuthMode != pInBss->AuthModeAux))
- // None matched
- continue;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA.GroupCipher)
- continue;
-
- // check group cipher
- if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipherAux))
- continue;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA2.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA2.GroupCipher)
- continue;
-
- // check group cipher
- if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipherAux))
- continue;
- }
- }
- // Bss Type matched, SSID matched.
- // We will check wepstatus for qualification Bss
- else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
- continue;
-
-#ifdef DOT11_N_SUPPORT
- // If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
- // If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
- if ((pInBss->CentralChannel != pInBss->Channel) &&
- (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
- {
- if (RTMPCheckChannel(pAd, pInBss->CentralChannel, pInBss->Channel) == FALSE)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- SetCommonHT(pAd);
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- // copy matching BSS from InTab to OutTab
- NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
-
- OutTab->BssNr++;
- }
-
- if (OutTab->BssNr >= MAX_LEN_OF_BSS_TABLE)
- break;
- }
-
- BssTableSortByRssi(OutTab);
-}
-
-
-// IRQL = DISPATCH_LEVEL
-VOID BssTableSortByRssi(
- IN OUT BSS_TABLE *OutTab)
-{
- INT i, j;
- BSS_ENTRY TmpBss;
-
- for (i = 0; i < OutTab->BssNr - 1; i++)
- {
- for (j = i+1; j < OutTab->BssNr; j++)
- {
- if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi)
- {
- NdisMoveMemory(&TmpBss, &OutTab->BssEntry[j], sizeof(BSS_ENTRY));
- NdisMoveMemory(&OutTab->BssEntry[j], &OutTab->BssEntry[i], sizeof(BSS_ENTRY));
- NdisMoveMemory(&OutTab->BssEntry[i], &TmpBss, sizeof(BSS_ENTRY));
- }
- }
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-VOID BssCipherParse(
- IN OUT PBSS_ENTRY pBss)
-{
- PEID_STRUCT pEid;
- PUCHAR pTmp;
- PRSN_IE_HEADER_STRUCT pRsnHeader;
- PCIPHER_SUITE_STRUCT pCipher;
- PAKM_SUITE_STRUCT pAKM;
- USHORT Count;
- INT Length;
- NDIS_802_11_ENCRYPTION_STATUS TmpCipher;
-
- //
- // WepStatus will be reset later, if AP announce TKIP or AES on the beacon frame.
- //
- if (pBss->Privacy)
- {
- pBss->WepStatus = Ndis802_11WEPEnabled;
- }
- else
- {
- pBss->WepStatus = Ndis802_11WEPDisabled;
- }
- // Set default to disable & open authentication before parsing variable IE
- pBss->AuthMode = Ndis802_11AuthModeOpen;
- pBss->AuthModeAux = Ndis802_11AuthModeOpen;
-
- // Init WPA setting
- pBss->WPA.PairCipher = Ndis802_11WEPDisabled;
- pBss->WPA.PairCipherAux = Ndis802_11WEPDisabled;
- pBss->WPA.GroupCipher = Ndis802_11WEPDisabled;
- pBss->WPA.RsnCapability = 0;
- pBss->WPA.bMixMode = FALSE;
-
- // Init WPA2 setting
- pBss->WPA2.PairCipher = Ndis802_11WEPDisabled;
- pBss->WPA2.PairCipherAux = Ndis802_11WEPDisabled;
- pBss->WPA2.GroupCipher = Ndis802_11WEPDisabled;
- pBss->WPA2.RsnCapability = 0;
- pBss->WPA2.bMixMode = FALSE;
-
-
- Length = (INT) pBss->VarIELen;
-
- while (Length > 0)
- {
- // Parse cipher suite base on WPA1 & WPA2, they should be parsed differently
- pTmp = ((PUCHAR) pBss->VarIEs) + pBss->VarIELen - Length;
- pEid = (PEID_STRUCT) pTmp;
- switch (pEid->Eid)
- {
- case IE_WPA:
- //Parse Cisco IE_WPA (LEAP, CCKM, etc.)
- if ( NdisEqualMemory((pTmp+8), CISCO_OUI, 3))
- {
- pTmp += 11;
- switch (*pTmp)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- pBss->WepStatus = Ndis802_11Encryption1Enabled;
- pBss->WPA.PairCipher = Ndis802_11Encryption1Enabled;
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- pBss->WepStatus = Ndis802_11Encryption2Enabled;
- pBss->WPA.PairCipher = Ndis802_11Encryption1Enabled;
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- case 4:
- pBss->WepStatus = Ndis802_11Encryption3Enabled;
- pBss->WPA.PairCipher = Ndis802_11Encryption1Enabled;
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- default:
- break;
- }
-
- // if Cisco IE_WPA, break
- break;
- }
- else if (NdisEqualMemory(pEid->Octet, SES_OUI, 3) && (pEid->Len == 7))
- {
- pBss->bSES = TRUE;
- break;
- }
- else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4) != 1)
- {
- // if unsupported vendor specific IE
- break;
- }
- // Skip OUI, version, and multicast suite
- // This part should be improved in the future when AP supported multiple cipher suite.
- // For now, it's OK since almost all APs have fixed cipher suite supported.
- // pTmp = (PUCHAR) pEid->Octet;
- pTmp += 11;
-
- // Cipher Suite Selectors from Spec P802.11i/D3.2 P26.
- // Value Meaning
- // 0 None
- // 1 WEP-40
- // 2 Tkip
- // 3 WRAP
- // 4 AES
- // 5 WEP-104
- // Parse group cipher
- switch (*pTmp)
- {
- case 1:
- pBss->WPA.GroupCipher = Ndis802_11GroupWEP40Enabled;
- break;
- case 5:
- pBss->WPA.GroupCipher = Ndis802_11GroupWEP104Enabled;
- break;
- case 2:
- pBss->WPA.GroupCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- pBss->WPA.GroupCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- // number of unicast suite
- pTmp += 1;
-
- // skip all unicast cipher suites
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // Parsing all unicast cipher suite
- while (Count > 0)
- {
- // Skip OUI
- pTmp += 3;
- TmpCipher = Ndis802_11WEPDisabled;
- switch (*pTmp)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- TmpCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- TmpCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- TmpCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- if (TmpCipher > pBss->WPA.PairCipher)
- {
- // Move the lower cipher suite to PairCipherAux
- pBss->WPA.PairCipherAux = pBss->WPA.PairCipher;
- pBss->WPA.PairCipher = TmpCipher;
- }
- else
- {
- pBss->WPA.PairCipherAux = TmpCipher;
- }
- pTmp++;
- Count--;
- }
-
- // 4. get AKM suite counts
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
- pTmp += 3;
-
- switch (*pTmp)
- {
- case 1:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPA;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPA;
- break;
- case 2:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPAPSK;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPAPSK;
- break;
- default:
- break;
- }
- pTmp += 1;
-
- // Fixed for WPA-None
- if (pBss->BssType == BSS_ADHOC)
- {
- pBss->AuthMode = Ndis802_11AuthModeWPANone;
- pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
- pBss->WepStatus = pBss->WPA.GroupCipher;
- // Patched bugs for old driver
- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
- pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
- }
- else
- pBss->WepStatus = pBss->WPA.PairCipher;
-
- // Check the Pair & Group, if different, turn on mixed mode flag
- if (pBss->WPA.GroupCipher != pBss->WPA.PairCipher)
- pBss->WPA.bMixMode = TRUE;
-
- break;
-
- case IE_RSN:
- pRsnHeader = (PRSN_IE_HEADER_STRUCT) pTmp;
-
- // 0. Version must be 1
- if (le2cpu16(pRsnHeader->Version) != 1)
- break;
- pTmp += sizeof(RSN_IE_HEADER_STRUCT);
-
- // 1. Check group cipher
- pCipher = (PCIPHER_SUITE_STRUCT) pTmp;
- if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
- break;
-
- // Parse group cipher
- switch (pCipher->Type)
- {
- case 1:
- pBss->WPA2.GroupCipher = Ndis802_11GroupWEP40Enabled;
- break;
- case 5:
- pBss->WPA2.GroupCipher = Ndis802_11GroupWEP104Enabled;
- break;
- case 2:
- pBss->WPA2.GroupCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- pBss->WPA2.GroupCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- // set to correct offset for next parsing
- pTmp += sizeof(CIPHER_SUITE_STRUCT);
-
- // 2. Get pairwise cipher counts
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // 3. Get pairwise cipher
- // Parsing all unicast cipher suite
- while (Count > 0)
- {
- // Skip OUI
- pCipher = (PCIPHER_SUITE_STRUCT) pTmp;
- TmpCipher = Ndis802_11WEPDisabled;
- switch (pCipher->Type)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- TmpCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- TmpCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- TmpCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- if (TmpCipher > pBss->WPA2.PairCipher)
- {
- // Move the lower cipher suite to PairCipherAux
- pBss->WPA2.PairCipherAux = pBss->WPA2.PairCipher;
- pBss->WPA2.PairCipher = TmpCipher;
- }
- else
- {
- pBss->WPA2.PairCipherAux = TmpCipher;
- }
- pTmp += sizeof(CIPHER_SUITE_STRUCT);
- Count--;
- }
-
- // 4. get AKM suite counts
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // 5. Get AKM ciphers
- pAKM = (PAKM_SUITE_STRUCT) pTmp;
- if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
- break;
-
- switch (pAKM->Type)
- {
- case 1:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPA2;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPA2;
- break;
- case 2:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPA2PSK;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPA2PSK;
- break;
- default:
- break;
- }
- pTmp += (Count * sizeof(AKM_SUITE_STRUCT));
-
- // Fixed for WPA-None
- if (pBss->BssType == BSS_ADHOC)
- {
- pBss->AuthMode = Ndis802_11AuthModeWPANone;
- pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
- pBss->WPA.PairCipherAux = pBss->WPA2.PairCipherAux;
- pBss->WPA.GroupCipher = pBss->WPA2.GroupCipher;
- pBss->WepStatus = pBss->WPA.GroupCipher;
- // Patched bugs for old driver
- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
- pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
- }
- pBss->WepStatus = pBss->WPA2.PairCipher;
-
- // 6. Get RSN capability
- //pBss->WPA2.RsnCapability = *(PUSHORT) pTmp;
- pBss->WPA2.RsnCapability = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // Check the Pair & Group, if different, turn on mixed mode flag
- if (pBss->WPA2.GroupCipher != pBss->WPA2.PairCipher)
- pBss->WPA2.bMixMode = TRUE;
-
- break;
- default:
- break;
- }
- Length -= (pEid->Len + 2);
- }
-}
-
-// ===========================================================================================
-// mac_table.c
-// ===========================================================================================
-
-/*! \brief generates a random mac address value for IBSS BSSID
- * \param Addr the bssid location
- * \return none
- * \pre
- * \post
- */
-VOID MacAddrRandomBssid(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pAddr)
-{
- INT i;
-
- for (i = 0; i < MAC_ADDR_LEN; i++)
- {
- pAddr[i] = RandomByte(pAd);
- }
-
- pAddr[0] = (pAddr[0] & 0xfe) | 0x02; // the first 2 bits must be 01xxxxxxxx
-}
-
-/*! \brief init the management mac frame header
- * \param p_hdr mac header
- * \param subtype subtype of the frame
- * \param p_ds destination address, don't care if it is a broadcast address
- * \return none
- * \pre the station has the following information in the pAd->StaCfg
- * - bssid
- * - station address
- * \post
- * \note this function initializes the following field
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-VOID MgtMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR SubType,
- IN UCHAR ToDs,
- IN PUCHAR pDA,
- IN PUCHAR pBssid)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-
- pHdr80211->FC.Type = BTYPE_MGMT;
- pHdr80211->FC.SubType = SubType;
-// if (SubType == SUBTYPE_ACK) // sample, no use, it will conflict with ACTION frame sub type
-// pHdr80211->FC.Type = BTYPE_CNTL;
- pHdr80211->FC.ToDs = ToDs;
- COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
- COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
-}
-
-// ===========================================================================================
-// mem_mgmt.c
-// ===========================================================================================
-
-/*!***************************************************************************
- * This routine build an outgoing frame, and fill all information specified
- * in argument list to the frame body. The actual frame size is the summation
- * of all arguments.
- * input params:
- * Buffer - pointer to a pre-allocated memory segment
- * args - a list of <int arg_size, arg> pairs.
- * NOTE NOTE NOTE!!!! the last argument must be NULL, otherwise this
- * function will FAIL!!!
- * return:
- * Size of the buffer
- * usage:
- * MakeOutgoingFrame(Buffer, output_length, 2, &fc, 2, &dur, 6, p_addr1, 6,p_addr2, END_OF_ARGS);
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ****************************************************************************/
-ULONG MakeOutgoingFrame(
- OUT CHAR *Buffer,
- OUT ULONG *FrameLen, ...)
-{
- CHAR *p;
- int leng;
- ULONG TotLeng;
- va_list Args;
-
- // calculates the total length
- TotLeng = 0;
- va_start(Args, FrameLen);
- do
- {
- leng = va_arg(Args, int);
- if (leng == END_OF_ARGS)
- {
- break;
- }
- p = va_arg(Args, PVOID);
- NdisMoveMemory(&Buffer[TotLeng], p, leng);
- TotLeng = TotLeng + leng;
- } while(TRUE);
-
- va_end(Args); /* clean up */
- *FrameLen = TotLeng;
- return TotLeng;
-}
-
-// ===========================================================================================
-// mlme_queue.c
-// ===========================================================================================
-
-/*! \brief Initialize The MLME Queue, used by MLME Functions
- * \param *Queue The MLME Queue
- * \return Always Return NDIS_STATE_SUCCESS in this implementation
- * \pre
- * \post
- * \note Because this is done only once (at the init stage), no need to be locked
-
- IRQL = PASSIVE_LEVEL
-
- */
-NDIS_STATUS MlmeQueueInit(
- IN MLME_QUEUE *Queue)
-{
- INT i;
-
- NdisAllocateSpinLock(&Queue->Lock);
-
- Queue->Num = 0;
- Queue->Head = 0;
- Queue->Tail = 0;
-
- for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++)
- {
- Queue->Entry[i].Occupied = FALSE;
- Queue->Entry[i].MsgLen = 0;
- NdisZeroMemory(Queue->Entry[i].Msg, MGMT_DMA_BUFFER_SIZE);
- }
-
- return NDIS_STATUS_SUCCESS;
-}
-
-/*! \brief Enqueue a message for other threads, if they want to send messages to MLME thread
- * \param *Queue The MLME Queue
- * \param Machine The State Machine Id
- * \param MsgType The Message Type
- * \param MsgLen The Message length
- * \param *Msg The message pointer
- * \return TRUE if enqueue is successful, FALSE if the queue is full
- * \pre
- * \post
- * \note The message has to be initialized
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeEnqueue(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Machine,
- IN ULONG MsgType,
- IN ULONG MsgLen,
- IN VOID *Msg)
-{
- INT Tail;
- MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return FALSE;
-
- // First check the size, it MUST not exceed the mlme queue size
- if (MsgLen > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("MlmeEnqueue: msg too large, size = %ld \n", MsgLen));
- return FALSE;
- }
-
- if (MlmeQueueFull(Queue))
- {
- return FALSE;
- }
-
- NdisAcquireSpinLock(&(Queue->Lock));
- Tail = Queue->Tail;
- Queue->Tail++;
- Queue->Num++;
- if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
- {
- Queue->Tail = 0;
- }
-
- Queue->Entry[Tail].Wcid = RESERVED_WCID;
- Queue->Entry[Tail].Occupied = TRUE;
- Queue->Entry[Tail].Machine = Machine;
- Queue->Entry[Tail].MsgType = MsgType;
- Queue->Entry[Tail].MsgLen = MsgLen;
-
- if (Msg != NULL)
- {
- NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
- }
-
- NdisReleaseSpinLock(&(Queue->Lock));
- return TRUE;
-}
-
-/*! \brief This function is used when Recv gets a MLME message
- * \param *Queue The MLME Queue
- * \param TimeStampHigh The upper 32 bit of timestamp
- * \param TimeStampLow The lower 32 bit of timestamp
- * \param Rssi The receiving RSSI strength
- * \param MsgLen The length of the message
- * \param *Msg The message pointer
- * \return TRUE if everything ok, FALSE otherwise (like Queue Full)
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG TimeStampHigh,
- IN ULONG TimeStampLow,
- IN UCHAR Rssi0,
- IN UCHAR Rssi1,
- IN UCHAR Rssi2,
- IN ULONG MsgLen,
- IN VOID *Msg,
- IN UCHAR Signal)
-{
- INT Tail, Machine;
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
- INT MsgType;
- MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
-
-#ifdef RALINK_ATE
- /* Nothing to do in ATE mode */
- if(ATE_ON(pAd))
- return FALSE;
-#endif // RALINK_ATE //
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- DBGPRINT_ERR(("MlmeEnqueueForRecv: fRTMP_ADAPTER_HALT_IN_PROGRESS\n"));
- return FALSE;
- }
-
- // First check the size, it MUST not exceed the mlme queue size
- if (MsgLen > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("MlmeEnqueueForRecv: frame too large, size = %ld \n", MsgLen));
- return FALSE;
- }
-
- if (MlmeQueueFull(Queue))
- {
- return FALSE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (!MsgTypeSubst(pAd, pFrame, &Machine, &MsgType))
- {
- DBGPRINT_ERR(("MlmeEnqueueForRecv: un-recongnized mgmt->subtype=%d\n",pFrame->Hdr.FC.SubType));
- return FALSE;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // OK, we got all the informations, it is time to put things into queue
- NdisAcquireSpinLock(&(Queue->Lock));
- Tail = Queue->Tail;
- Queue->Tail++;
- Queue->Num++;
- if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
- {
- Queue->Tail = 0;
- }
- Queue->Entry[Tail].Occupied = TRUE;
- Queue->Entry[Tail].Machine = Machine;
- Queue->Entry[Tail].MsgType = MsgType;
- Queue->Entry[Tail].MsgLen = MsgLen;
- Queue->Entry[Tail].TimeStamp.u.LowPart = TimeStampLow;
- Queue->Entry[Tail].TimeStamp.u.HighPart = TimeStampHigh;
- Queue->Entry[Tail].Rssi0 = Rssi0;
- Queue->Entry[Tail].Rssi1 = Rssi1;
- Queue->Entry[Tail].Rssi2 = Rssi2;
- Queue->Entry[Tail].Signal = Signal;
- Queue->Entry[Tail].Wcid = (UCHAR)Wcid;
-
- Queue->Entry[Tail].Channel = pAd->LatchRfRegs.Channel;
-
- if (Msg != NULL)
- {
- NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
- }
-
- NdisReleaseSpinLock(&(Queue->Lock));
-
- RT28XX_MLME_HANDLER(pAd);
-
- return TRUE;
-}
-
-
-/*! \brief Dequeue a message from the MLME Queue
- * \param *Queue The MLME Queue
- * \param *Elem The message dequeued from MLME Queue
- * \return TRUE if the Elem contains something, FALSE otherwise
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeDequeue(
- IN MLME_QUEUE *Queue,
- OUT MLME_QUEUE_ELEM **Elem)
-{
- NdisAcquireSpinLock(&(Queue->Lock));
- *Elem = &(Queue->Entry[Queue->Head]);
- Queue->Num--;
- Queue->Head++;
- if (Queue->Head == MAX_LEN_OF_MLME_QUEUE)
- {
- Queue->Head = 0;
- }
- NdisReleaseSpinLock(&(Queue->Lock));
- return TRUE;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeRestartStateMachine(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN Cancelled;
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef QOS_DLS_SUPPORT
- UCHAR i;
-#endif // QOS_DLS_SUPPORT //
- // Cancel all timer events
- // Be careful to cancel new added timer
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-#ifdef QOS_DLS_SUPPORT
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
- }
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Change back to original channel in case of doing scan
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- // Resume MSDU which is turned off durning scan
- RTMPResumeMsduTransmission(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Set all state machines back IDLE
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
-#ifdef QOS_DLS_SUPPORT
- pAd->Mlme.DlsMachine.CurrState = DLS_IDLE;
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-/*! \brief test if the MLME Queue is empty
- * \param *Queue The MLME Queue
- * \return TRUE if the Queue is empty, FALSE otherwise
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeQueueEmpty(
- IN MLME_QUEUE *Queue)
-{
- BOOLEAN Ans;
-
- NdisAcquireSpinLock(&(Queue->Lock));
- Ans = (Queue->Num == 0);
- NdisReleaseSpinLock(&(Queue->Lock));
-
- return Ans;
-}
-
-/*! \brief test if the MLME Queue is full
- * \param *Queue The MLME Queue
- * \return TRUE if the Queue is empty, FALSE otherwise
- * \pre
- * \post
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeQueueFull(
- IN MLME_QUEUE *Queue)
-{
- BOOLEAN Ans;
-
- NdisAcquireSpinLock(&(Queue->Lock));
- Ans = (Queue->Num == MAX_LEN_OF_MLME_QUEUE || Queue->Entry[Queue->Tail].Occupied);
- NdisReleaseSpinLock(&(Queue->Lock));
-
- return Ans;
-}
-
-/*! \brief The destructor of MLME Queue
- * \param
- * \return
- * \pre
- * \post
- * \note Clear Mlme Queue, Set Queue->Num to Zero.
-
- IRQL = PASSIVE_LEVEL
-
- */
-VOID MlmeQueueDestroy(
- IN MLME_QUEUE *pQueue)
-{
- NdisAcquireSpinLock(&(pQueue->Lock));
- pQueue->Num = 0;
- pQueue->Head = 0;
- pQueue->Tail = 0;
- NdisReleaseSpinLock(&(pQueue->Lock));
- NdisFreeSpinLock(&(pQueue->Lock));
-}
-
-/*! \brief To substitute the message type if the message is coming from external
- * \param pFrame The frame received
- * \param *Machine The state machine
- * \param *MsgType the message type for the state machine
- * \return TRUE if the substitution is successful, FALSE otherwise
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-#ifdef CONFIG_STA_SUPPORT
-BOOLEAN MsgTypeSubst(
- IN PRTMP_ADAPTER pAd,
- IN PFRAME_802_11 pFrame,
- OUT INT *Machine,
- OUT INT *MsgType)
-{
- USHORT Seq;
- UCHAR EAPType;
- PUCHAR pData;
-
- // Pointer to start of data frames including SNAP header
- pData = (PUCHAR) pFrame + LENGTH_802_11;
-
- // The only data type will pass to this function is EAPOL frame
- if (pFrame->Hdr.FC.Type == BTYPE_DATA)
- {
- if (NdisEqualMemory(SNAP_AIRONET, pData, LENGTH_802_1_H))
- {
- // Cisco Aironet SNAP header
- *Machine = AIRONET_STATE_MACHINE;
- *MsgType = MT2_AIRONET_MSG;
- return (TRUE);
- }
-#ifdef LEAP_SUPPORT
- if ( pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP ) //LEAP
- {
- // LEAP frames
- *Machine = LEAP_STATE_MACHINE;
- EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
- return (LeapMsgTypeSubst(EAPType, MsgType));
- }
- else
-#endif // LEAP_SUPPORT //
- {
- *Machine = WPA_PSK_STATE_MACHINE;
- EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
- return(WpaMsgTypeSubst(EAPType, MsgType));
- }
- }
-
- switch (pFrame->Hdr.FC.SubType)
- {
- case SUBTYPE_ASSOC_REQ:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_ASSOC_REQ;
- break;
- case SUBTYPE_ASSOC_RSP:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_ASSOC_RSP;
- break;
- case SUBTYPE_REASSOC_REQ:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_REASSOC_REQ;
- break;
- case SUBTYPE_REASSOC_RSP:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_REASSOC_RSP;
- break;
- case SUBTYPE_PROBE_REQ:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_PROBE_REQ;
- break;
- case SUBTYPE_PROBE_RSP:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_PROBE_RSP;
- break;
- case SUBTYPE_BEACON:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_BEACON;
- break;
- case SUBTYPE_ATIM:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_ATIM;
- break;
- case SUBTYPE_DISASSOC:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_DISASSOC_REQ;
- break;
- case SUBTYPE_AUTH:
- // get the sequence number from payload 24 Mac Header + 2 bytes algorithm
- NdisMoveMemory(&Seq, &pFrame->Octet[2], sizeof(USHORT));
- if (Seq == 1 || Seq == 3)
- {
- *Machine = AUTH_RSP_STATE_MACHINE;
- *MsgType = MT2_PEER_AUTH_ODD;
- }
- else if (Seq == 2 || Seq == 4)
- {
- *Machine = AUTH_STATE_MACHINE;
- *MsgType = MT2_PEER_AUTH_EVEN;
- }
- else
- {
- return FALSE;
- }
- break;
- case SUBTYPE_DEAUTH:
- *Machine = AUTH_RSP_STATE_MACHINE;
- *MsgType = MT2_PEER_DEAUTH;
- break;
- case SUBTYPE_ACTION:
- *Machine = ACTION_STATE_MACHINE;
- // Sometimes Sta will return with category bytes with MSB = 1, if they receive catogory out of their support
- if ((pFrame->Octet[0]&0x7F) > MAX_PEER_CATE_MSG)
- {
- *MsgType = MT2_ACT_INVALID;
- }
- else
- {
- *MsgType = (pFrame->Octet[0]&0x7F);
- }
- break;
- default:
- return FALSE;
- break;
- }
-
- return TRUE;
-}
-#endif // CONFIG_STA_SUPPORT //
-
-// ===========================================================================================
-// state_machine.c
-// ===========================================================================================
-
-/*! \brief Initialize the state machine.
- * \param *S pointer to the state machine
- * \param Trans State machine transition function
- * \param StNr number of states
- * \param MsgNr number of messages
- * \param DefFunc default function, when there is invalid state/message combination
- * \param InitState initial state of the state machine
- * \param Base StateMachine base, internal use only
- * \pre p_sm should be a legal pointer
- * \post
-
- IRQL = PASSIVE_LEVEL
-
- */
-VOID StateMachineInit(
- IN STATE_MACHINE *S,
- IN STATE_MACHINE_FUNC Trans[],
- IN ULONG StNr,
- IN ULONG MsgNr,
- IN STATE_MACHINE_FUNC DefFunc,
- IN ULONG InitState,
- IN ULONG Base)
-{
- ULONG i, j;
-
- // set number of states and messages
- S->NrState = StNr;
- S->NrMsg = MsgNr;
- S->Base = Base;
-
- S->TransFunc = Trans;
-
- // init all state transition to default function
- for (i = 0; i < StNr; i++)
- {
- for (j = 0; j < MsgNr; j++)
- {
- S->TransFunc[i * MsgNr + j] = DefFunc;
- }
- }
-
- // set the starting state
- S->CurrState = InitState;
-}
-
-/*! \brief This function fills in the function pointer into the cell in the state machine
- * \param *S pointer to the state machine
- * \param St state
- * \param Msg incoming message
- * \param f the function to be executed when (state, message) combination occurs at the state machine
- * \pre *S should be a legal pointer to the state machine, st, msg, should be all within the range, Base should be set in the initial state
- * \post
-
- IRQL = PASSIVE_LEVEL
-
- */
-VOID StateMachineSetAction(
- IN STATE_MACHINE *S,
- IN ULONG St,
- IN ULONG Msg,
- IN STATE_MACHINE_FUNC Func)
-{
- ULONG MsgIdx;
-
- MsgIdx = Msg - S->Base;
-
- if (St < S->NrState && MsgIdx < S->NrMsg)
- {
- // boundary checking before setting the action
- S->TransFunc[St * S->NrMsg + MsgIdx] = Func;
- }
-}
-
-/*! \brief This function does the state transition
- * \param *Adapter the NIC adapter pointer
- * \param *S the state machine
- * \param *Elem the message to be executed
- * \return None
-
- IRQL = DISPATCH_LEVEL
-
- */
-VOID StateMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem)
-{
- (*(S->TransFunc[S->CurrState * S->NrMsg + Elem->MsgType - S->Base]))(pAd, Elem);
-}
-
-/*
- ==========================================================================
- Description:
- The drop function, when machine executes this, the message is simply
- ignored. This function does nothing, the message is freed in
- StateMachinePerformAction()
- ==========================================================================
- */
-VOID Drop(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-// ===========================================================================================
-// lfsr.c
-// ===========================================================================================
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID LfsrInit(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Seed)
-{
- if (Seed == 0)
- pAd->Mlme.ShiftReg = 1;
- else
- pAd->Mlme.ShiftReg = Seed;
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-UCHAR RandomByte(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- UCHAR R, Result;
-
- R = 0;
-
- if (pAd->Mlme.ShiftReg == 0)
- NdisGetSystemUpTime((ULONG *)&pAd->Mlme.ShiftReg);
-
- for (i = 0; i < 8; i++)
- {
- if (pAd->Mlme.ShiftReg & 0x00000001)
- {
- pAd->Mlme.ShiftReg = ((pAd->Mlme.ShiftReg ^ LFSR_MASK) >> 1) | 0x80000000;
- Result = 1;
- }
- else
- {
- pAd->Mlme.ShiftReg = pAd->Mlme.ShiftReg >> 1;
- Result = 0;
- }
- R = (R << 1) | Result;
- }
-
- return R;
-}
-
-VOID AsicUpdateAutoFallBackTable(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pRateTable)
-{
- UCHAR i;
- HT_FBK_CFG0_STRUC HtCfg0;
- HT_FBK_CFG1_STRUC HtCfg1;
- LG_FBK_CFG0_STRUC LgCfg0;
- LG_FBK_CFG1_STRUC LgCfg1;
- PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate;
-
- // set to initial value
- HtCfg0.word = 0x65432100;
- HtCfg1.word = 0xedcba988;
- LgCfg0.word = 0xedcba988;
- LgCfg1.word = 0x00002100;
-
- pNextTxRate = (PRTMP_TX_RATE_SWITCH)pRateTable+1;
- for (i = 1; i < *((PUCHAR) pRateTable); i++)
- {
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH)pRateTable+1+i;
- switch (pCurrTxRate->Mode)
- {
- case 0: //CCK
- break;
- case 1: //OFDM
- {
- switch(pCurrTxRate->CurrMCS)
- {
- case 0:
- LgCfg0.field.OFDMMCS0FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 1:
- LgCfg0.field.OFDMMCS1FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 2:
- LgCfg0.field.OFDMMCS2FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 3:
- LgCfg0.field.OFDMMCS3FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 4:
- LgCfg0.field.OFDMMCS4FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 5:
- LgCfg0.field.OFDMMCS5FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 6:
- LgCfg0.field.OFDMMCS6FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 7:
- LgCfg0.field.OFDMMCS7FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- }
- }
- break;
-#ifdef DOT11_N_SUPPORT
- case 2: //HT-MIX
- case 3: //HT-GF
- {
- if ((pNextTxRate->Mode >= MODE_HTMIX) && (pCurrTxRate->CurrMCS != pNextTxRate->CurrMCS))
- {
- switch(pCurrTxRate->CurrMCS)
- {
- case 0:
- HtCfg0.field.HTMCS0FBK = pNextTxRate->CurrMCS;
- break;
- case 1:
- HtCfg0.field.HTMCS1FBK = pNextTxRate->CurrMCS;
- break;
- case 2:
- HtCfg0.field.HTMCS2FBK = pNextTxRate->CurrMCS;
- break;
- case 3:
- HtCfg0.field.HTMCS3FBK = pNextTxRate->CurrMCS;
- break;
- case 4:
- HtCfg0.field.HTMCS4FBK = pNextTxRate->CurrMCS;
- break;
- case 5:
- HtCfg0.field.HTMCS5FBK = pNextTxRate->CurrMCS;
- break;
- case 6:
- HtCfg0.field.HTMCS6FBK = pNextTxRate->CurrMCS;
- break;
- case 7:
- HtCfg0.field.HTMCS7FBK = pNextTxRate->CurrMCS;
- break;
- case 8:
- HtCfg1.field.HTMCS8FBK = pNextTxRate->CurrMCS;
- break;
- case 9:
- HtCfg1.field.HTMCS9FBK = pNextTxRate->CurrMCS;
- break;
- case 10:
- HtCfg1.field.HTMCS10FBK = pNextTxRate->CurrMCS;
- break;
- case 11:
- HtCfg1.field.HTMCS11FBK = pNextTxRate->CurrMCS;
- break;
- case 12:
- HtCfg1.field.HTMCS12FBK = pNextTxRate->CurrMCS;
- break;
- case 13:
- HtCfg1.field.HTMCS13FBK = pNextTxRate->CurrMCS;
- break;
- case 14:
- HtCfg1.field.HTMCS14FBK = pNextTxRate->CurrMCS;
- break;
- case 15:
- HtCfg1.field.HTMCS15FBK = pNextTxRate->CurrMCS;
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("AsicUpdateAutoFallBackTable: not support CurrMCS=%d\n", pCurrTxRate->CurrMCS));
- }
- }
- }
- break;
-#endif // DOT11_N_SUPPORT //
- }
-
- pNextTxRate = pCurrTxRate;
- }
-
- RTMP_IO_WRITE32(pAd, HT_FBK_CFG0, HtCfg0.word);
- RTMP_IO_WRITE32(pAd, HT_FBK_CFG1, HtCfg1.word);
- RTMP_IO_WRITE32(pAd, LG_FBK_CFG0, LgCfg0.word);
- RTMP_IO_WRITE32(pAd, LG_FBK_CFG1, LgCfg1.word);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set MAC register value according operation mode.
- OperationMode AND bNonGFExist are for MM and GF Proteciton.
- If MM or GF mask is not set, those passing argument doesn't not take effect.
-
- Operation mode meaning:
- = 0 : Pure HT, no preotection.
- = 0x01; there may be non-HT devices in both the control and extension channel, protection is optional in BSS.
- = 0x10: No Transmission in 40M is protected.
- = 0x11: Transmission in both 40M and 20M shall be protected
- if (bNonGFExist)
- we should choose not to use GF. But still set correct ASIC registers.
- ========================================================================
-*/
-VOID AsicUpdateProtect(
- IN PRTMP_ADAPTER pAd,
- IN USHORT OperationMode,
- IN UCHAR SetMask,
- IN BOOLEAN bDisableBGProtect,
- IN BOOLEAN bNonGFExist)
-{
- PROT_CFG_STRUC ProtCfg, ProtCfg4;
- UINT32 Protect[6];
- USHORT offset;
- UCHAR i;
- UINT32 MacReg = 0;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
- if (!(pAd->CommonCfg.bHTProtect) && (OperationMode != 8))
- {
- return;
- }
-
- if (pAd->BATable.numAsOriginator)
- {
- //
- // enable the RTS/CTS to avoid channel collision
- //
- SetMask = ALLN_SETPROTECT;
- OperationMode = 8;
- }
-#endif // DOT11_N_SUPPORT //
-
- // Config ASIC RTS threshold register
- RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
- MacReg &= 0xFF0000FF;
-#if 0
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
-#else
- // If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
- if ((
-#ifdef DOT11_N_SUPPORT
- (pAd->CommonCfg.BACapability.field.AmsduEnable) ||
-#endif // DOT11_N_SUPPORT //
- (pAd->CommonCfg.bAggregationCapable == TRUE))
- && pAd->CommonCfg.RtsThreshold == MAX_RTS_THRESHOLD)
- {
- MacReg |= (0x1000 << 8);
- }
- else
- {
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
- }
-#endif
-
- RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
-
- // Initial common protection settings
- RTMPZeroMemory(Protect, sizeof(Protect));
- ProtCfg4.word = 0;
- ProtCfg.word = 0;
- ProtCfg.field.TxopAllowGF40 = 1;
- ProtCfg.field.TxopAllowGF20 = 1;
- ProtCfg.field.TxopAllowMM40 = 1;
- ProtCfg.field.TxopAllowMM20 = 1;
- ProtCfg.field.TxopAllowOfdm = 1;
- ProtCfg.field.TxopAllowCck = 1;
- ProtCfg.field.RTSThEn = 1;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-
- // update PHY mode and rate
- if (pAd->CommonCfg.Channel > 14)
- ProtCfg.field.ProtectRate = 0x4000;
- ProtCfg.field.ProtectRate |= pAd->CommonCfg.RtsRate;
-
- // Handle legacy(B/G) protection
- if (bDisableBGProtect)
- {
- //ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0;
- Protect[0] = ProtCfg.word;
- Protect[1] = ProtCfg.word;
- }
- else
- {
- //ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0; // CCK do not need to be protected
- Protect[0] = ProtCfg.word;
- ProtCfg.field.ProtectCtrl = ASIC_CTS; // OFDM needs using CCK to protect
- Protect[1] = ProtCfg.word;
- }
-
-#ifdef DOT11_N_SUPPORT
- // Decide HT frame protection.
- if ((SetMask & ALLN_SETPROTECT) != 0)
- {
- switch(OperationMode)
- {
- case 0x0:
- // NO PROTECT
- // 1.All STAs in the BSS are 20/40 MHz HT
- // 2. in ai 20/40MHz BSS
- // 3. all STAs are 20MHz in a 20MHz BSS
- // Pure HT. no protection.
-
- // MM20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[2] = 0x01744004;
-
- // MM40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[3] = 0x03f44084;
-
- // CF20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[4] = 0x01744004;
-
- // CF40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[5] = 0x03f44084;
-
- if (bNonGFExist)
- {
- // PROT_NAV(19:18) -- 01 (Short NAV protectiion)
- // PROT_CTRL(17:16) -- 01 (RTS/CTS)
- Protect[4] = 0x01754004;
- Protect[5] = 0x03f54084;
- }
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
- break;
-
- case 1:
- // This is "HT non-member protection mode."
- // If there may be non-HT STAs my BSS
- ProtCfg.word = 0x01744004; // PROT_CTRL(17:16) : 0 (None)
- ProtCfg4.word = 0x03f44084; // duplicaet legacy 24M. BW set 1.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- ProtCfg.word = 0x01740003; //ERP use Protection bit is set, use protection rate at Clause 18..
- ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083;
- }
- //Assign Protection method for 20&40 MHz packets
- ProtCfg.field.ProtectCtrl = ASIC_RTS;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
- ProtCfg4.field.ProtectCtrl = ASIC_RTS;
- ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
- Protect[2] = ProtCfg.word;
- Protect[3] = ProtCfg4.word;
- Protect[4] = ProtCfg.word;
- Protect[5] = ProtCfg4.word;
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
- break;
-
- case 2:
- // If only HT STAs are in BSS. at least one is 20MHz. Only protect 40MHz packets
- ProtCfg.word = 0x01744004; // PROT_CTRL(17:16) : 0 (None)
- ProtCfg4.word = 0x03f44084; // duplicaet legacy 24M. BW set 1.
-
- //Assign Protection method for 40MHz packets
- ProtCfg4.field.ProtectCtrl = ASIC_RTS;
- ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
- Protect[2] = ProtCfg.word;
- Protect[3] = ProtCfg4.word;
- if (bNonGFExist)
- {
- ProtCfg.field.ProtectCtrl = ASIC_RTS;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
- }
- Protect[4] = ProtCfg.word;
- Protect[5] = ProtCfg4.word;
-
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
- break;
-
- case 3:
- // HT mixed mode. PROTECT ALL!
- // Assign Rate
- ProtCfg.word = 0x01744004; //duplicaet legacy 24M. BW set 1.
- ProtCfg4.word = 0x03f44084;
- // both 20MHz and 40MHz are protected. Whether use RTS or CTS-to-self depends on the
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- ProtCfg.word = 0x01740003; //ERP use Protection bit is set, use protection rate at Clause 18..
- ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083
- }
- //Assign Protection method for 20&40 MHz packets
- ProtCfg.field.ProtectCtrl = ASIC_RTS;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
- ProtCfg4.field.ProtectCtrl = ASIC_RTS;
- ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
- Protect[2] = ProtCfg.word;
- Protect[3] = ProtCfg4.word;
- Protect[4] = ProtCfg.word;
- Protect[5] = ProtCfg4.word;
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
- break;
-
- case 8:
- // Special on for Atheros problem n chip.
- Protect[2] = 0x01754004;
- Protect[3] = 0x03f54084;
- Protect[4] = 0x01754004;
- Protect[5] = 0x03f54084;
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
- break;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- offset = CCK_PROT_CFG;
- for (i = 0;i < 6;i++)
- {
- if ((SetMask & (1<< i)))
- {
- RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSwitchChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel,
- IN BOOLEAN bScan)
-{
- ULONG R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0;
- CHAR TxPwer = 0, TxPwer2 = DEFAULT_RF_TX_POWER; //Bbp94 = BBPR94_DEFAULT, TxPwer2 = DEFAULT_RF_TX_POWER;
- UCHAR index;
- UINT32 Value = 0; //BbpReg, Value;
- RTMP_RF_REGS *RFRegTable;
-
- // Search Tx power value
- for (index = 0; index < pAd->ChannelListNum; index++)
- {
- if (Channel == pAd->ChannelList[index].Channel)
- {
- TxPwer = pAd->ChannelList[index].Power;
- TxPwer2 = pAd->ChannelList[index].Power2;
- break;
- }
- }
-
- if (index == MAX_NUM_OF_CHANNELS)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Cant find the Channel#%d \n", Channel));
- }
-
-#ifdef RT2870
- // The RF programming sequence is difference between 3xxx and 2xxx
- if (IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
- {
- /* modify by WY for Read RF Reg. error */
- UCHAR RFValue;
-
- for (index = 0; index < NUM_OF_3020_CHNL; index++)
- {
- if (Channel == FreqItems3020[index].Channel)
- {
- // Programming channel parameters
- RT30xxWriteRFRegister(pAd, RF_R02, FreqItems3020[index].N);
- RT30xxWriteRFRegister(pAd, RF_R03, FreqItems3020[index].K);
-
- RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RFValue);
- RFValue = (RFValue & 0xFC) | FreqItems3020[index].R;
- RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RFValue);
-
- // Set Tx Power
- RT30xxReadRFRegister(pAd, RF_R12, (PUCHAR)&RFValue);
- RFValue = (RFValue & 0xE0) | TxPwer;
- RT30xxWriteRFRegister(pAd, RF_R12, (UCHAR)RFValue);
-
- // Set RF offset
- RT30xxReadRFRegister(pAd, RF_R23, (PUCHAR)&RFValue);
- RFValue = (RFValue & 0x80) | pAd->RfFreqOffset;
- RT30xxWriteRFRegister(pAd, RF_R23, (UCHAR)RFValue);
-
- // Set BW
- if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40))
- {
- RFValue = pAd->Mlme.CaliBW40RfR24;
- //DISABLE_11N_CHECK(pAd);
- }
- else
- {
- RFValue = pAd->Mlme.CaliBW20RfR24;
- }
- RT30xxWriteRFRegister(pAd, RF_R24, (UCHAR)RFValue);
-
- // Enable RF tuning
- RT30xxReadRFRegister(pAd, RF_R07, (PUCHAR)&RFValue);
- RFValue = RFValue | 0x1;
- RT30xxWriteRFRegister(pAd, RF_R07, (UCHAR)RFValue);
-
- // latch channel for future usage.
- pAd->LatchRfRegs.Channel = Channel;
-
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
- Channel,
- pAd->RfIcType,
- TxPwer,
- TxPwer2,
- pAd->Antenna.field.TxPath,
- FreqItems3020[index].N,
- FreqItems3020[index].K,
- FreqItems3020[index].R));
- }
- else
-#endif // RT2870 //
- {
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- R2 |= 0x40; // write 1 to off Rxpath.
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
-
- if (Channel > 14)
- {
- // initialize R3, R4
- R3 = (RFRegTable[index].R3 & 0xffffc1ff);
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15);
-
- // 5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB
- // R3
- if ((TxPwer >= -7) && (TxPwer < 0))
- {
- TxPwer = (7+TxPwer);
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10);
- DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: TxPwer=%d \n", TxPwer));
- }
- else
- {
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10) | (1 << 9);
- }
-
- // R4
- if ((TxPwer2 >= -7) && (TxPwer2 < 0))
- {
- TxPwer2 = (7+TxPwer2);
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7);
- DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: TxPwer2=%d \n", TxPwer2));
- }
- else
- {
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7) | (1 << 6);
- }
- }
- else
- {
- R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); // set TX power0
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15) | (TxPwer2 <<6);// Set freq Offset & TxPwr1
- }
-
- // Based on BBP current mode before changing RF channel.
- if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40))
- {
- R4 |=0x200000;
- }
-
- // Update variables
- pAd->LatchRfRegs.Channel = Channel;
- pAd->LatchRfRegs.R1 = RFRegTable[index].R1;
- pAd->LatchRfRegs.R2 = R2;
- pAd->LatchRfRegs.R3 = R3;
- pAd->LatchRfRegs.R4 = R4;
-
- // Set RF value 1's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 2's set R3[bit2] = [1]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 | 0x04));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 3's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
- }
-
- // Change BBP setting during siwtch from a->g, g->a
- if (Channel <= 14)
- {
- ULONG TxPinCfg = 0x00050F0A;//Gary 2007/08/09 0x050A0A
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd))); // According the Rory's suggestion to solve the middle range issue.
- //RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
-
- // Rx High power VGA offset for LNA select
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);
- }
-
- // 5G band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x04);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
- else
- {
- ULONG TxPinCfg = 0x00050F05;//Gary 2007/8/9 0x050505
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd))); // According the Rory's suggestion to solve the middle range issue.
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
-
- // Rx High power VGA offset for LNA select
- if (pAd->NicConfig2.field.ExternalLNAForA)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);
- }
-
- // 5G band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x02);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
-
- // R66 should be set according to Channel and use 20MHz when scanning
- //RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x2E + GET_LNA_GAIN(pAd)));
- if (bScan)
- RTMPSetAGCInitValue(pAd, BW_20);
- else
- RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
-
- //
- // On 11A, We should delay and wait RF/BBP to be stable
- // and the appropriate time should be 1000 micro seconds
- // 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
- //
- RTMPusecDelay(1000);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%lu, Pwr1=%lu, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- (R3 & 0x00003e00) >> 9,
- (R4 & 0x000007c0) >> 6,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
-}
-
-/*
- ==========================================================================
- Description:
- This function is required for 2421 only, and should not be used during
- site survey. It's only required after NIC decided to stay at a channel
- for a longer period.
- When this function is called, it's always after AsicSwitchChannel().
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicLockChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicAntennaSelect(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Antenna miscellaneous setting.
-
- Arguments:
- pAd Pointer to our adapter
- BandState Indicate current Band State.
-
- Return Value:
- None
-
- IRQL <= DISPATCH_LEVEL
-
- Note:
- 1.) Frame End type control
- only valid for G only (RF_2527 & RF_2529)
- 0: means DPDT, set BBP R4 bit 5 to 1
- 1: means SPDT, set BBP R4 bit 5 to 0
-
-
- ========================================================================
-*/
-VOID AsicAntennaSetting(
- IN PRTMP_ADAPTER pAd,
- IN ABGBAND_STATE BandState)
-{
-}
-
-VOID AsicRfTuningExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
-}
-
-/*
- ==========================================================================
- Description:
- Gives CCK TX rate 2 more dB TX power.
- This routine works only in LINK UP in INFRASTRUCTURE mode.
-
- calculate desired Tx power in RF R3.Tx0~5, should consider -
- 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
- 1. TxPowerPercentage
- 2. auto calibration based on TSSI feedback
- 3. extra 2 db for CCK
- 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
-
- NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
- it should be called AFTER MlmeDynamicTxRatSwitching()
- ==========================================================================
- */
-VOID AsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd)
-{
- INT i, j;
- CHAR DeltaPwr = 0;
- BOOLEAN bAutoTxAgc = FALSE;
- UCHAR TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;
- UCHAR BbpR1 = 0, BbpR49 = 0, idx;
- PCHAR pTxAgcCompensate;
- ULONG TxPwr[5];
- CHAR Value;
-
- if (pAd->CommonCfg.BBPCurrentBW == BW_40)
- {
- if (pAd->CommonCfg.CentralChannel > 14)
- {
- TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
- }
- }
- else
- {
- if (pAd->CommonCfg.Channel > 14)
- {
- TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
- }
- }
-
- // TX power compensation for temperature variation based on TSSI. try every 4 second
- if (pAd->Mlme.OneSecPeriodicRound % 4 == 0)
- {
- if (pAd->CommonCfg.Channel <= 14)
- {
- /* bg channel */
- bAutoTxAgc = pAd->bAutoTxAgcG;
- TssiRef = pAd->TssiRefG;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryG[0];
- TxAgcStep = pAd->TxAgcStepG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- /* a channel */
- bAutoTxAgc = pAd->bAutoTxAgcA;
- TssiRef = pAd->TssiRefA;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryA[0];
- TxAgcStep = pAd->TxAgcStepA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- {
- /* BbpR1 is unsigned char */
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);
-
- /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
- /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
- /* step value is defined in pAd->TxAgcStepG for tx power value */
-
- /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
- /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- above value are examined in mass factory production */
- /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
-
- /* plus (+) is 0x00 ~ 0x45, minus (-) is 0xa0 ~ 0xf0 */
- /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
- /* if value is 0xa5, tx power will be -= TxAgcStep*(2-1) */
-
- if (BbpR49 > pTssiMinusBoundary[1])
- {
- // Reading is larger than the reference value
- // check for how large we need to decrease the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 <= pTssiMinusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should decrease, idx = 0 means there is nothing to compensate
-// if (R3 > (ULONG) (TxAgcStep * (idx-1)))
- *pTxAgcCompensate = -(TxAgcStep * (idx-1));
-// else
-// *pTxAgcCompensate = -((UCHAR)R3);
-
- DeltaPwr += (*pTxAgcCompensate);
- DBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else if (BbpR49 < pTssiPlusBoundary[1])
- {
- // Reading is smaller than the reference value
- // check for how large we need to increase the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 >= pTssiPlusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should increase, idx = 0 means there is nothing to compensate
- *pTxAgcCompensate = TxAgcStep * (idx-1);
- DeltaPwr += (*pTxAgcCompensate);
- DBGPRINT(RT_DEBUG_TRACE, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else
- {
- *pTxAgcCompensate = 0;
- DBGPRINT(RT_DEBUG_TRACE, (" Tx Power, BBP R49=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, 0));
- }
- }
- }
- else
- {
- if (pAd->CommonCfg.Channel <= 14)
- {
- bAutoTxAgc = pAd->bAutoTxAgcG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- bAutoTxAgc = pAd->bAutoTxAgcA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- DeltaPwr += (*pTxAgcCompensate);
- }
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpR1);
- BbpR1 &= 0xFC;
-
-#ifdef SINGLE_SKU
- // Handle regulatory max tx power constrain
- do
- {
- UCHAR TxPwrInEEPROM = 0xFF, CountryTxPwr = 0xFF, criterion;
- UCHAR AdjustMaxTxPwr[40];
-
- if (pAd->CommonCfg.Channel > 14) // 5G band
- TxPwrInEEPROM = ((pAd->CommonCfg.DefineMaxTxPwr & 0xFF00) >> 8);
- else // 2.4G band
- TxPwrInEEPROM = (pAd->CommonCfg.DefineMaxTxPwr & 0x00FF);
- CountryTxPwr = GetCuntryMaxTxPwr(pAd, pAd->CommonCfg.Channel);
-
- // error handling, range check
- if ((TxPwrInEEPROM > 0x50) || (CountryTxPwr > 0x50))
- {
- DBGPRINT(RT_DEBUG_ERROR,("AsicAdjustTxPower - Invalid max tx power (=0x%02x), CountryTxPwr=%d\n", TxPwrInEEPROM, CountryTxPwr));
- break;
- }
-
- criterion = *((PUCHAR)TxPwr + 2) & 0xF; // FAE use OFDM 6M as criterion
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (criterion=%d, TxPwrInEEPROM=%d, CountryTxPwr=%d)\n", criterion, TxPwrInEEPROM, CountryTxPwr));
-
- // Adjust max tx power according to the relationship of tx power in E2PROM
- for (i=0; i<5; i++)
- {
- // CCK will have 4dBm larger than OFDM
- // Therefore, we should separate to parse the tx power field
- if (i == 0)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- if (j < 4)
- {
- // CCK will have 4dBm larger than OFDM
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion) + 4;
- }
- else
- {
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- }
- else
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- }
- }
-
- // Adjust tx power according to the relationship
- for (i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- // The system tx power is larger than the regulatory, the power should be restrain
- if (AdjustMaxTxPwr[i*8+j] > CountryTxPwr)
- {
- // decrease to zero and don't need to take care BBPR1
- if ((Value - (AdjustMaxTxPwr[i*8+j] - CountryTxPwr)) > 0)
- Value -= (AdjustMaxTxPwr[i*8+j] - CountryTxPwr);
- else
- Value = 0;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- else
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d, no change)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
-
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
- }
- }
- } while (FALSE);
-#endif // SINGLE_SKU //
-
- /* calculate delta power based on the percentage specified from UI */
- // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
- // We lower TX power here according to the percentage specified from UI
- if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff) // AUTO TX POWER control
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW // DeltaPwr -= 1;
- {
- DeltaPwr -= 1;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW // DeltaPwr -= 3;
- {
- DeltaPwr -= 3;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW // DeltaPwr -= 6;
- {
- BbpR1 |= 0x01;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW // DeltaPwr -= 9;
- {
- BbpR1 |= 0x01;
- DeltaPwr -= 3;
- }
- else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW // DeltaPwr -= 12;
- {
- BbpR1 |= 0x02;
- }
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpR1);
-
- /* reset different new tx power for different TX rate */
- for(i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F); /* 0 ~ 15 */
-
- if ((Value + DeltaPwr) < 0)
- {
- Value = 0; /* min */
- }
- else if ((Value + DeltaPwr) > 0xF)
- {
- Value = 0xF; /* max */
- }
- else
- {
- Value += DeltaPwr; /* temperature compensation */
- }
-
- /* fill new value to CSR offset */
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
-
- /* write tx power value to CSR */
- /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
- TX power for OFDM 6M/9M
- TX power for CCK5.5M/11M
- TX power for CCK1M/2M */
- /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);
- }
- }
-
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ==========================================================================
- Description:
- put PHY to sleep here, and set next wakeup timer. PHY doesn't not wakeup
- automatically. Instead, MCU will issue a TwakeUpInterrupt to host after
- the wakeup timer timeout. Driver has to issue a separate command to wake
- PHY up.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp)
-{
- RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp);
-}
-
-/*
- ==========================================================================
- Description:
- AsicForceWakeup() is used whenever manual wakeup is required
- AsicForceSleep() should only be used when not in INFRA BSS. When
- in INFRA BSS, we should use AsicSleepThenAutoWakeup() instead.
- ==========================================================================
- */
-VOID AsicForceSleep(
- IN PRTMP_ADAPTER pAd)
-{
-
-}
-
-/*
- ==========================================================================
- Description:
- AsicForceWakeup() is used whenever Twakeup timer (set via AsicSleepThenAutoWakeup)
- expired.
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
- ==========================================================================
- */
-VOID AsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("--> AsicForceWakeup \n"));
- RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx);
-}
-#endif // CONFIG_STA_SUPPORT //
-/*
- ==========================================================================
- Description:
- Set My BSSID
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSetBssid(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid)
-{
- ULONG Addr4;
- DBGPRINT(RT_DEBUG_TRACE, ("==============> AsicSetBssid %x:%x:%x:%x:%x:%x\n",
- pBssid[0],pBssid[1],pBssid[2],pBssid[3], pBssid[4],pBssid[5]));
-
- Addr4 = (ULONG)(pBssid[0]) |
- (ULONG)(pBssid[1] << 8) |
- (ULONG)(pBssid[2] << 16) |
- (ULONG)(pBssid[3] << 24);
- RTMP_IO_WRITE32(pAd, MAC_BSSID_DW0, Addr4);
-
- Addr4 = 0;
- // always one BSSID in STA mode
- Addr4 = (ULONG)(pBssid[4]) | (ULONG)(pBssid[5] << 8);
-
- RTMP_IO_WRITE32(pAd, MAC_BSSID_DW1, Addr4);
-}
-
-VOID AsicSetMcastWC(
- IN PRTMP_ADAPTER pAd)
-{
- MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[MCAST_WCID];
- USHORT offset;
-
- pEntry->Sst = SST_ASSOC;
- pEntry->Aid = MCAST_WCID; // Softap supports 1 BSSID and use WCID=0 as multicast Wcid index
- pEntry->PsMode = PWR_ACTIVE;
- pEntry->CurrTxRate = pAd->CommonCfg.MlmeRate;
- offset = MAC_WCID_BASE + BSS0Mcast_WCID * HW_WCID_ENTRY_SIZE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicDelWcidTab(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid)
-{
- ULONG Addr0 = 0x0, Addr1 = 0x0;
- ULONG offset;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicDelWcidTab==>Wcid = 0x%x\n",Wcid));
- offset = MAC_WCID_BASE + Wcid * HW_WCID_ENTRY_SIZE;
- RTMP_IO_WRITE32(pAd, offset, Addr0);
- offset += 4;
- RTMP_IO_WRITE32(pAd, offset, Addr1);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicEnableRDG(
- IN PRTMP_ADAPTER pAd)
-{
- TX_LINK_CFG_STRUC TxLinkCfg;
- UINT32 Data = 0;
-
- RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
- TxLinkCfg.field.TxRDGEn = 1;
- RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- Data |= 0x80;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- //OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicDisableRDG(
- IN PRTMP_ADAPTER pAd)
-{
- TX_LINK_CFG_STRUC TxLinkCfg;
- UINT32 Data = 0;
-
-
- RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
- TxLinkCfg.field.TxRDGEn = 0;
- RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-
- Data &= 0xFFFFFF00;
- //Data |= 0x20;
-#ifndef WIFI_TEST
- //if ( pAd->CommonCfg.bEnableTxBurst )
- // Data |= 0x60; // for performance issue not set the TXOP to 0
-#endif
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE)
-#ifdef DOT11_N_SUPPORT
- && (pAd->MacTab.fAnyStationMIMOPSDynamic == FALSE)
-#endif // DOT11_N_SUPPORT //
- )
- {
- // For CWC test, change txop from 0x30 to 0x20 in TxBurst mode
- if (pAd->CommonCfg.bEnableTxBurst)
- Data |= 0x20;
- }
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicDisableSync(
- IN PRTMP_ADAPTER pAd)
-{
- BCN_TIME_CFG_STRUC csr;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->Disable TSF synchronization\n"));
-
- // 2003-12-20 disable TSF and TBTT while NIC in power-saving have side effect
- // that NIC will never wakes up because TSF stops and no more
- // TBTT interrupts
- pAd->TbttTickCount = 0;
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
- csr.field.bBeaconGen = 0;
- csr.field.bTBTTEnable = 0;
- csr.field.TsfSyncMode = 0;
- csr.field.bTsfTicking = 0;
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicEnableBssSync(
- IN PRTMP_ADAPTER pAd)
-{
- BCN_TIME_CFG_STRUC csr;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableBssSync(INFRA mode)\n"));
-
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-// RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, 0x00000000);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- csr.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
- csr.field.bTsfTicking = 1;
- csr.field.TsfSyncMode = 1; // sync TSF in INFRASTRUCTURE mode
- csr.field.bBeaconGen = 0; // do NOT generate BEACON
- csr.field.bTBTTEnable = 1;
- }
-#endif // CONFIG_STA_SUPPORT //
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-}
-
-/*
- ==========================================================================
- Description:
- Note:
- BEACON frame in shared memory should be built ok before this routine
- can be called. Otherwise, a garbage frame maybe transmitted out every
- Beacon period.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicEnableIbssSync(
- IN PRTMP_ADAPTER pAd)
-{
- BCN_TIME_CFG_STRUC csr9;
- PUCHAR ptr;
- UINT i;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableIbssSync(ADHOC mode. MPDUtotalByteCount = %d)\n", pAd->BeaconTxWI.MPDUtotalByteCount));
-
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr9.word);
- csr9.field.bBeaconGen = 0;
- csr9.field.bTBTTEnable = 0;
- csr9.field.bTsfTicking = 0;
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
-
-
-#ifdef RT2870
- // move BEACON TXD and frame content to on-chip memory
- ptr = (PUCHAR)&pAd->BeaconTxWI;
- for (i=0; i<TXWI_SIZE; i+=2) // 16-byte TXWI field
- {
- //UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
- //RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + i, longptr);
- RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + i, ptr, 2);
- ptr += 2;
- }
-
- // start right after the 16-byte TXWI field
- ptr = pAd->BeaconBuf;
- for (i=0; i< pAd->BeaconTxWI.MPDUtotalByteCount; i+=2)
- {
- //UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
- //RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr);
- RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, ptr, 2);
- ptr +=2;
- }
-#endif // RT2870 //
-
- //
- // For Wi-Fi faily generated beacons between participating stations.
- // Set TBTT phase adaptive adjustment step to 8us (default 16us)
- // don't change settings 2006-5- by Jerry
- //RTMP_IO_WRITE32(pAd, TBTT_SYNC_CFG, 0x00001010);
-
- // start sending BEACON
- csr9.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
- csr9.field.bTsfTicking = 1;
- csr9.field.TsfSyncMode = 2; // sync TSF in IBSS mode
- csr9.field.bTBTTEnable = 1;
- csr9.field.bBeaconGen = 1;
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSetEdcaParm(
- IN PRTMP_ADAPTER pAd,
- IN PEDCA_PARM pEdcaParm)
-{
- EDCA_AC_CFG_STRUC Ac0Cfg, Ac1Cfg, Ac2Cfg, Ac3Cfg;
- AC_TXOP_CSR0_STRUC csr0;
- AC_TXOP_CSR1_STRUC csr1;
- AIFSN_CSR_STRUC AifsnCsr;
- CWMIN_CSR_STRUC CwminCsr;
- CWMAX_CSR_STRUC CwmaxCsr;
- int i;
-
- Ac0Cfg.word = 0;
- Ac1Cfg.word = 0;
- Ac2Cfg.word = 0;
- Ac3Cfg.word = 0;
- if ((pEdcaParm == NULL) || (pEdcaParm->bValid == FALSE))
- {
- DBGPRINT(RT_DEBUG_TRACE,("AsicSetEdcaParm\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WMM_INUSED);
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI || pAd->MacTab.Content[i].ValidAsApCli)
- CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.Content[i], fCLIENT_STATUS_WMM_CAPABLE);
- }
-
- //========================================================
- // MAC Register has a copy .
- //========================================================
-//#ifndef WIFI_TEST
- if( pAd->CommonCfg.bEnableTxBurst )
- {
- // For CWC test, change txop from 0x30 to 0x20 in TxBurst mode
- Ac0Cfg.field.AcTxop = 0x20; // Suggest by John for TxBurst in HT Mode
- }
- else
- Ac0Cfg.field.AcTxop = 0; // QID_AC_BE
-//#else
-// Ac0Cfg.field.AcTxop = 0; // QID_AC_BE
-//#endif
- Ac0Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac0Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac0Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Ac0Cfg.word);
-
- Ac1Cfg.field.AcTxop = 0; // QID_AC_BK
- Ac1Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac1Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac1Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word);
-
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- {
- Ac2Cfg.field.AcTxop = 192; // AC_VI: 192*32us ~= 6ms
- Ac3Cfg.field.AcTxop = 96; // AC_VO: 96*32us ~= 3ms
- }
- else
- {
- Ac2Cfg.field.AcTxop = 96; // AC_VI: 96*32us ~= 3ms
- Ac3Cfg.field.AcTxop = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- Ac2Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac2Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac2Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC2_CFG, Ac2Cfg.word);
- Ac3Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac3Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac3Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC3_CFG, Ac3Cfg.word);
-
- //========================================================
- // DMA Register has a copy too.
- //========================================================
- csr0.field.Ac0Txop = 0; // QID_AC_BE
- csr0.field.Ac1Txop = 0; // QID_AC_BK
- RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- {
- csr1.field.Ac2Txop = 192; // AC_VI: 192*32us ~= 6ms
- csr1.field.Ac3Txop = 96; // AC_VO: 96*32us ~= 3ms
- }
- else
- {
- csr1.field.Ac2Txop = 96; // AC_VI: 96*32us ~= 3ms
- csr1.field.Ac3Txop = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr1.word);
-
- CwminCsr.word = 0;
- CwminCsr.field.Cwmin0 = CW_MIN_IN_BITS;
- CwminCsr.field.Cwmin1 = CW_MIN_IN_BITS;
- CwminCsr.field.Cwmin2 = CW_MIN_IN_BITS;
- CwminCsr.field.Cwmin3 = CW_MIN_IN_BITS;
- RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
-
- CwmaxCsr.word = 0;
- CwmaxCsr.field.Cwmax0 = CW_MAX_IN_BITS;
- CwmaxCsr.field.Cwmax1 = CW_MAX_IN_BITS;
- CwmaxCsr.field.Cwmax2 = CW_MAX_IN_BITS;
- CwmaxCsr.field.Cwmax3 = CW_MAX_IN_BITS;
- RTMP_IO_WRITE32(pAd, WMM_CWMAX_CFG, CwmaxCsr.word);
-
- RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, 0x00002222);
-
- NdisZeroMemory(&pAd->CommonCfg.APEdcaParm, sizeof(EDCA_PARM));
- }
- else
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WMM_INUSED);
- //========================================================
- // MAC Register has a copy.
- //========================================================
- //
- // Modify Cwmin/Cwmax/Txop on queue[QID_AC_VI], Recommend by Jerry 2005/07/27
- // To degrade our VIDO Queue's throughput for WiFi WMM S3T07 Issue.
- //
- //pEdcaParm->Txop[QID_AC_VI] = pEdcaParm->Txop[QID_AC_VI] * 7 / 10; // rt2860c need this
-
- Ac0Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BE];
- Ac0Cfg.field.Cwmin= pEdcaParm->Cwmin[QID_AC_BE];
- Ac0Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BE];
- Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE]; //+1;
-
- Ac1Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BK];
- Ac1Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_BK]; //+2;
- Ac1Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BK];
- Ac1Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BK]; //+1;
-
- Ac2Cfg.field.AcTxop = (pEdcaParm->Txop[QID_AC_VI] * 6) / 10;
- Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI];
- Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI];
- Ac2Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Tuning for Wi-Fi WMM S06
- if (pAd->CommonCfg.bWiFiTest &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- Ac2Cfg.field.Aifsn -= 1;
-
- // Tuning for TGn Wi-Fi 5.2.32
- // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
- if (STA_TGN_WIFI_ON(pAd) &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- {
- Ac0Cfg.field.Aifsn = 3;
- Ac2Cfg.field.AcTxop = 5;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- Ac3Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VO];
- Ac3Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VO];
- Ac3Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VO];
- Ac3Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VO];
-
-//#ifdef WIFI_TEST
- if (pAd->CommonCfg.bWiFiTest)
- {
- if (Ac3Cfg.field.AcTxop == 102)
- {
- Ac0Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BE] ? pEdcaParm->Txop[QID_AC_BE] : 10;
- Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE]-1; /* AIFSN must >= 1 */
- Ac1Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BK];
- Ac1Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BK];
- Ac2Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VI];
- } /* End of if */
- }
-//#endif // WIFI_TEST //
-
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Ac0Cfg.word);
- RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word);
- RTMP_IO_WRITE32(pAd, EDCA_AC2_CFG, Ac2Cfg.word);
- RTMP_IO_WRITE32(pAd, EDCA_AC3_CFG, Ac3Cfg.word);
-
-
- //========================================================
- // DMA Register has a copy too.
- //========================================================
- csr0.field.Ac0Txop = Ac0Cfg.field.AcTxop;
- csr0.field.Ac1Txop = Ac1Cfg.field.AcTxop;
- RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
-
- csr1.field.Ac2Txop = Ac2Cfg.field.AcTxop;
- csr1.field.Ac3Txop = Ac3Cfg.field.AcTxop;
- RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr1.word);
-
- CwminCsr.word = 0;
- CwminCsr.field.Cwmin0 = pEdcaParm->Cwmin[QID_AC_BE];
- CwminCsr.field.Cwmin1 = pEdcaParm->Cwmin[QID_AC_BK];
- CwminCsr.field.Cwmin2 = pEdcaParm->Cwmin[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- CwminCsr.field.Cwmin3 = pEdcaParm->Cwmin[QID_AC_VO] - 1; //for TGn wifi test
-#endif // CONFIG_STA_SUPPORT //
- RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
-
- CwmaxCsr.word = 0;
- CwmaxCsr.field.Cwmax0 = pEdcaParm->Cwmax[QID_AC_BE];
- CwmaxCsr.field.Cwmax1 = pEdcaParm->Cwmax[QID_AC_BK];
- CwmaxCsr.field.Cwmax2 = pEdcaParm->Cwmax[QID_AC_VI];
- CwmaxCsr.field.Cwmax3 = pEdcaParm->Cwmax[QID_AC_VO];
- RTMP_IO_WRITE32(pAd, WMM_CWMAX_CFG, CwmaxCsr.word);
-
- AifsnCsr.word = 0;
- AifsnCsr.field.Aifsn0 = Ac0Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_BE];
- AifsnCsr.field.Aifsn1 = Ac1Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_BK];
- AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Tuning for Wi-Fi WMM S06
- if (pAd->CommonCfg.bWiFiTest &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn - 4;
-
- // Tuning for TGn Wi-Fi 5.2.32
- // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
- if (STA_TGN_WIFI_ON(pAd) &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- {
- AifsnCsr.field.Aifsn0 = 3;
- AifsnCsr.field.Aifsn2 = 7;
- }
-
- if (INFRA_ON(pAd))
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_WMM_CAPABLE);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AifsnCsr.field.Aifsn3 = Ac3Cfg.field.Aifsn - 1; //pEdcaParm->Aifsn[QID_AC_VO]; //for TGn wifi test
-#endif // CONFIG_STA_SUPPORT //
- RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, AifsnCsr.word);
-
- NdisMoveMemory(&pAd->CommonCfg.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
- if (!ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE,("EDCA [#%d]: AIFSN CWmin CWmax TXOP(us) ACM\n", pEdcaParm->EdcaUpdateCount));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_BE %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[0],
- pEdcaParm->Cwmin[0],
- pEdcaParm->Cwmax[0],
- pEdcaParm->Txop[0]<<5,
- pEdcaParm->bACM[0]));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_BK %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[1],
- pEdcaParm->Cwmin[1],
- pEdcaParm->Cwmax[1],
- pEdcaParm->Txop[1]<<5,
- pEdcaParm->bACM[1]));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_VI %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[2],
- pEdcaParm->Cwmin[2],
- pEdcaParm->Cwmax[2],
- pEdcaParm->Txop[2]<<5,
- pEdcaParm->bACM[2]));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_VO %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[3],
- pEdcaParm->Cwmin[3],
- pEdcaParm->Cwmax[3],
- pEdcaParm->Txop[3]<<5,
- pEdcaParm->bACM[3]));
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSetSlotTime(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUseShortSlotTime)
-{
- ULONG SlotTime;
- UINT32 RegValue = 0;
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->CommonCfg.Channel > 14)
- bUseShortSlotTime = TRUE;
-#endif // CONFIG_STA_SUPPORT //
-
- if (bUseShortSlotTime)
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
- else
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
-
- SlotTime = (bUseShortSlotTime)? 9 : 20;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // force using short SLOT time for FAE to demo performance when TxBurst is ON
- if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)))
-#ifdef DOT11_N_SUPPORT
- || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE))
-#endif // DOT11_N_SUPPORT //
- )
- {
- // In this case, we will think it is doing Wi-Fi test
- // And we will not set to short slot when bEnableTxBurst is TRUE.
- }
- else if (pAd->CommonCfg.bEnableTxBurst)
- SlotTime = 9;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- //
- // For some reasons, always set it to short slot time.
- //
- // ToDo: Should consider capability with 11B
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.BssType == BSS_ADHOC)
- SlotTime = 20;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_IO_READ32(pAd, BKOFF_SLOT_CFG, &RegValue);
- RegValue = RegValue & 0xFFFFFF00;
-
- RegValue |= SlotTime;
-
- RTMP_IO_WRITE32(pAd, BKOFF_SLOT_CFG, RegValue);
-}
-
-/*
- ========================================================================
- Description:
- Add Shared key information into ASIC.
- Update shared key, TxMic and RxMic to Asic Shared key table
- Update its cipherAlg to Asic Shared key Mode.
-
- Return:
- ========================================================================
-*/
-VOID AsicAddSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN PUCHAR pKey,
- IN PUCHAR pTxMic,
- IN PUCHAR pRxMic)
-{
- ULONG offset; //, csr0;
- SHAREDKEY_MODE_STRUC csr1;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicAddSharedKeyEntry BssIndex=%d, KeyIdx=%d\n", BssIndex,KeyIdx));
-//============================================================================================
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicAddSharedKeyEntry: %s key #%d\n", CipherName[CipherAlg], BssIndex*4 + KeyIdx));
- DBGPRINT_RAW(RT_DEBUG_TRACE, (" Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pKey[0],pKey[1],pKey[2],pKey[3],pKey[4],pKey[5],pKey[6],pKey[7],pKey[8],pKey[9],pKey[10],pKey[11],pKey[12],pKey[13],pKey[14],pKey[15]));
- if (pRxMic)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, (" Rx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pRxMic[0],pRxMic[1],pRxMic[2],pRxMic[3],pRxMic[4],pRxMic[5],pRxMic[6],pRxMic[7]));
- }
- if (pTxMic)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, (" Tx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pTxMic[0],pTxMic[1],pTxMic[2],pTxMic[3],pTxMic[4],pTxMic[5],pTxMic[6],pTxMic[7]));
- }
-//============================================================================================
- //
- // fill key material - key + TX MIC + RX MIC
- //
-
-#ifdef RT2870
-{
- offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE;
- RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_SHARE_KEY);
-
- offset += MAX_LEN_OF_SHARE_KEY;
- if (pTxMic)
- {
- RTUSBMultiWrite(pAd, offset, pTxMic, 8);
- }
-
- offset += 8;
- if (pRxMic)
- {
- RTUSBMultiWrite(pAd, offset, pRxMic, 8);
- }
-}
-#endif // RT2870 //
-
- //
- // Update cipher algorithm. WSTA always use BSS0
- //
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), &csr1.word);
- DBGPRINT(RT_DEBUG_TRACE,("Read: SHARED_KEY_MODE_BASE at this Bss[%d] KeyIdx[%d]= 0x%x \n", BssIndex,KeyIdx, csr1.word));
- if ((BssIndex%2) == 0)
- {
- if (KeyIdx == 0)
- csr1.field.Bss0Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss0Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss0Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss0Key3CipherAlg = CipherAlg;
- }
- else
- {
- if (KeyIdx == 0)
- csr1.field.Bss1Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss1Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss1Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss1Key3CipherAlg = CipherAlg;
- }
- DBGPRINT(RT_DEBUG_TRACE,("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n", BssIndex, csr1.word));
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), csr1.word);
-
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID AsicRemoveSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx)
-{
- //ULONG SecCsr0;
- SHAREDKEY_MODE_STRUC csr1;
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicRemoveSharedKeyEntry: #%d \n", BssIndex*4 + KeyIdx));
-
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), &csr1.word);
- if ((BssIndex%2) == 0)
- {
- if (KeyIdx == 0)
- csr1.field.Bss0Key0CipherAlg = 0;
- else if (KeyIdx == 1)
- csr1.field.Bss0Key1CipherAlg = 0;
- else if (KeyIdx == 2)
- csr1.field.Bss0Key2CipherAlg = 0;
- else
- csr1.field.Bss0Key3CipherAlg = 0;
- }
- else
- {
- if (KeyIdx == 0)
- csr1.field.Bss1Key0CipherAlg = 0;
- else if (KeyIdx == 1)
- csr1.field.Bss1Key1CipherAlg = 0;
- else if (KeyIdx == 2)
- csr1.field.Bss1Key2CipherAlg = 0;
- else
- csr1.field.Bss1Key3CipherAlg = 0;
- }
- DBGPRINT(RT_DEBUG_TRACE,("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n", BssIndex, csr1.word));
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), csr1.word);
- ASSERT(BssIndex < 4);
- ASSERT(KeyIdx < 4);
-
-}
-
-
-VOID AsicUpdateWCIDAttribute(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR CipherAlg,
- IN BOOLEAN bUsePairewiseKeyTable)
-{
- ULONG WCIDAttri = 0, offset;
-
- //
- // Update WCID attribute.
- // Only TxKey could update WCID attribute.
- //
- offset = MAC_WCID_ATTRIBUTE_BASE + (WCID * HW_WCID_ATTRI_SIZE);
- WCIDAttri = (BssIndex << 4) | (CipherAlg << 1) | (bUsePairewiseKeyTable);
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-}
-
-VOID AsicUpdateWCIDIVEIV(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN ULONG uIV,
- IN ULONG uEIV)
-{
- ULONG offset;
-
- offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
-
- RTMP_IO_WRITE32(pAd, offset, uIV);
- RTMP_IO_WRITE32(pAd, offset + 4, uEIV);
-}
-
-VOID AsicUpdateRxWCIDTable(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN PUCHAR pAddr)
-{
- ULONG offset;
- ULONG Addr;
-
- offset = MAC_WCID_BASE + (WCID * HW_WCID_ENTRY_SIZE);
- Addr = pAddr[0] + (pAddr[1] << 8) +(pAddr[2] << 16) +(pAddr[3] << 24);
- RTMP_IO_WRITE32(pAd, offset, Addr);
- Addr = pAddr[4] + (pAddr[5] << 8);
- RTMP_IO_WRITE32(pAd, offset + 4, Addr);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Set Cipher Key, Cipher algorithm, IV/EIV to Asic
-
- Arguments:
- pAd Pointer to our adapter
- WCID WCID Entry number.
- BssIndex BSSID index, station or none multiple BSSID support
- this value should be 0.
- KeyIdx This KeyIdx will set to IV's KeyID if bTxKey enabled
- pCipherKey Pointer to Cipher Key.
- bUsePairewiseKeyTable TRUE means saved the key in SharedKey table,
- otherwise PairewiseKey table
- bTxKey This is the transmit key if enabled.
-
- Return Value:
- None
-
- Note:
- This routine will set the relative key stuff to Asic including WCID attribute,
- Cipher Key, Cipher algorithm and IV/EIV.
-
- IV/EIV will be update if this CipherKey is the transmission key because
- ASIC will base on IV's KeyID value to select Cipher Key.
-
- If bTxKey sets to FALSE, this is not the TX key, but it could be
- RX key
-
- For AP mode bTxKey must be always set to TRUE.
- ========================================================================
-*/
-VOID AsicAddKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN PCIPHER_KEY pCipherKey,
- IN BOOLEAN bUsePairewiseKeyTable,
- IN BOOLEAN bTxKey)
-{
- ULONG offset;
-// ULONG WCIDAttri = 0;
- UCHAR IV4 = 0;
- PUCHAR pKey = pCipherKey->Key;
-// ULONG KeyLen = pCipherKey->KeyLen;
- PUCHAR pTxMic = pCipherKey->TxMic;
- PUCHAR pRxMic = pCipherKey->RxMic;
- PUCHAR pTxtsc = pCipherKey->TxTsc;
- UCHAR CipherAlg = pCipherKey->CipherAlg;
- SHAREDKEY_MODE_STRUC csr1;
-
-// ASSERT(KeyLen <= MAX_LEN_OF_PEER_KEY);
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n"));
- //
- // 1.) decide key table offset
- //
- if (bUsePairewiseKeyTable)
- offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
- else
- offset = SHARED_KEY_TABLE_BASE + (4 * BssIndex + KeyIdx) * HW_KEY_ENTRY_SIZE;
-
- //
- // 2.) Set Key to Asic
- //
- //for (i = 0; i < KeyLen; i++)
-
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_PEER_KEY);
- offset += MAX_LEN_OF_PEER_KEY;
-
- //
- // 3.) Set MIC key if available
- //
- if (pTxMic)
- {
- RTUSBMultiWrite(pAd, offset, pTxMic, 8);
- }
- offset += LEN_TKIP_TXMICK;
-
- if (pRxMic)
- {
- RTUSBMultiWrite(pAd, offset, pRxMic, 8);
- }
-#endif // RT2870 //
-
- //
- // 4.) Modify IV/EIV if needs
- // This will force Asic to use this key ID by setting IV.
- //
- if (bTxKey)
- {
-
-#ifdef RT2870
- UINT32 tmpVal;
-
- //
- // Write IV
- //
- IV4 = (KeyIdx << 6);
- if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) ||(CipherAlg == CIPHER_AES))
- IV4 |= 0x20; // turn on extension bit means EIV existence
-
- tmpVal = pTxtsc[1] + (((pTxtsc[1] | 0x20) & 0x7f) << 8) + (pTxtsc[0] << 16) + (IV4 << 24);
- RTMP_IO_WRITE32(pAd, offset, tmpVal);
-
- //
- // Write EIV
- //
- offset += 4;
- RTMP_IO_WRITE32(pAd, offset, *(PUINT32)&pCipherKey->TxTsc[2]);
-#endif // RT2870 //
- AsicUpdateWCIDAttribute(pAd, WCID, BssIndex, CipherAlg, bUsePairewiseKeyTable);
- }
-
- if (!bUsePairewiseKeyTable)
- {
- //
- // Only update the shared key security mode
- //
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2), &csr1.word);
- if ((BssIndex % 2) == 0)
- {
- if (KeyIdx == 0)
- csr1.field.Bss0Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss0Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss0Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss0Key3CipherAlg = CipherAlg;
- }
- else
- {
- if (KeyIdx == 0)
- csr1.field.Bss1Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss1Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss1Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss1Key3CipherAlg = CipherAlg;
- }
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2), csr1.word);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== AsicAddKeyEntry\n"));
-}
-
-
-/*
- ========================================================================
- Description:
- Add Pair-wise key material into ASIC.
- Update pairwise key, TxMic and RxMic to Asic Pair-wise key table
-
- Return:
- ========================================================================
-*/
-VOID AsicAddPairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR WCID,
- IN CIPHER_KEY *pCipherKey)
-{
- INT i;
- ULONG offset;
- PUCHAR pKey = pCipherKey->Key;
- PUCHAR pTxMic = pCipherKey->TxMic;
- PUCHAR pRxMic = pCipherKey->RxMic;
-#ifdef DBG
- UCHAR CipherAlg = pCipherKey->CipherAlg;
-#endif // DBG //
-
- // EKEY
- offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, &pCipherKey->Key[0], MAX_LEN_OF_PEER_KEY);
-#endif // RT2870 //
- for (i=0; i<MAX_LEN_OF_PEER_KEY; i+=4)
- {
- UINT32 Value;
- RTMP_IO_READ32(pAd, offset + i, &Value);
- }
-
- offset += MAX_LEN_OF_PEER_KEY;
-
- // MIC KEY
- if (pTxMic)
- {
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, &pCipherKey->TxMic[0], 8);
-#endif // RT2870 //
- }
- offset += 8;
- if (pRxMic)
- {
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, &pCipherKey->RxMic[0], 8);
-#endif // RT2870 //
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicAddPairwiseKeyEntry: WCID #%d Alg=%s\n",WCID, CipherName[CipherAlg]));
- DBGPRINT(RT_DEBUG_TRACE,(" Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pKey[0],pKey[1],pKey[2],pKey[3],pKey[4],pKey[5],pKey[6],pKey[7],pKey[8],pKey[9],pKey[10],pKey[11],pKey[12],pKey[13],pKey[14],pKey[15]));
- if (pRxMic)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" Rx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pRxMic[0],pRxMic[1],pRxMic[2],pRxMic[3],pRxMic[4],pRxMic[5],pRxMic[6],pRxMic[7]));
- }
- if (pTxMic)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" Tx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pTxMic[0],pTxMic[1],pTxMic[2],pTxMic[3],pTxMic[4],pTxMic[5],pTxMic[6],pTxMic[7]));
- }
-}
-/*
- ========================================================================
- Description:
- Remove Pair-wise key material from ASIC.
-
- Return:
- ========================================================================
-*/
-VOID AsicRemovePairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR Wcid)
-{
- ULONG WCIDAttri;
- USHORT offset;
-
- // re-set the entry's WCID attribute as OPEN-NONE.
- offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
- WCIDAttri = (BssIdx<<4) | PAIRWISEKEYTABLE;
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-}
-
-BOOLEAN AsicSendCommandToMcu(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Command,
- IN UCHAR Token,
- IN UCHAR Arg0,
- IN UCHAR Arg1)
-{
- HOST_CMD_CSR_STRUC H2MCmd;
- H2M_MAILBOX_STRUC H2MMailbox;
- ULONG i = 0;
- do
- {
- RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
- if (H2MMailbox.field.Owner == 0)
- break;
-
- RTMPusecDelay(2);
- } while(i++ < 100);
-
- if (i >= 100)
- {
- {
- DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
- }
- return FALSE;
- }
-
-
- H2MMailbox.field.Owner = 1; // pass ownership to MCU
- H2MMailbox.field.CmdToken = Token;
- H2MMailbox.field.HighByte = Arg1;
- H2MMailbox.field.LowByte = Arg0;
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
-
- H2MCmd.word = 0;
- H2MCmd.field.HostCommand = Command;
- RTMP_IO_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
-
- if (Command != 0x80)
- {
- }
-
- return TRUE;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Verify the support rate for different PHY type
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID RTMPCheckRates(
- IN PRTMP_ADAPTER pAd,
- IN OUT UCHAR SupRate[],
- IN OUT UCHAR *SupRateLen)
-{
- UCHAR RateIdx, i, j;
- UCHAR NewRate[12], NewRateLen;
-
- NewRateLen = 0;
-
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- RateIdx = 4;
- else
- RateIdx = 12;
-
- // Check for support rates exclude basic rate bit
- for (i = 0; i < *SupRateLen; i++)
- for (j = 0; j < RateIdx; j++)
- if ((SupRate[i] & 0x7f) == RateIdTo500Kbps[j])
- NewRate[NewRateLen++] = SupRate[i];
-
- *SupRateLen = NewRateLen;
- NdisMoveMemory(SupRate, NewRate, NewRateLen);
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-BOOLEAN RTMPCheckChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR CentralChannel,
- IN UCHAR Channel)
-{
- UCHAR k;
- UCHAR UpperChannel = 0, LowerChannel = 0;
- UCHAR NoEffectChannelinList = 0;
-
- // Find upper and lower channel according to 40MHz current operation.
- if (CentralChannel < Channel)
- {
- UpperChannel = Channel;
- if (CentralChannel > 2)
- LowerChannel = CentralChannel - 2;
- else
- return FALSE;
- }
- else if (CentralChannel > Channel)
- {
- UpperChannel = CentralChannel + 2;
- LowerChannel = Channel;
- }
-
- for (k = 0;k < pAd->ChannelListNum;k++)
- {
- if (pAd->ChannelList[k].Channel == UpperChannel)
- {
- NoEffectChannelinList ++;
- }
- if (pAd->ChannelList[k].Channel == LowerChannel)
- {
- NoEffectChannelinList ++;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Total Channel in Channel List = [%d]\n", NoEffectChannelinList));
- if (NoEffectChannelinList == 2)
- return TRUE;
- else
- return FALSE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Verify the support rate for HT phy type
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- FALSE if pAd->CommonCfg.SupportedHtPhy doesn't accept the pHtCapability. (AP Mode)
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-BOOLEAN RTMPCheckHt(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo)
-{
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- // If use AMSDU, set flag.
- if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_AMSDU_INUSED);
- // Save Peer Capability
- if (pHtCapability->HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_SGI20_CAPABLE);
- if (pHtCapability->HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_SGI40_CAPABLE);
- if (pHtCapability->HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (pHtCapability->HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport)
- {
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_RDG_CAPABLE);
- }
-
- if (Wcid < MAX_LEN_OF_MAC_TABLE)
- {
- pAd->MacTab.Content[Wcid].MpduDensity = pHtCapability->HtCapParm.MpduDensity;
- }
-
- // Will check ChannelWidth for MCSSet[4] below
- pAd->MlmeAux.HtCapability.MCSSet[4] = 0x1;
- switch (pAd->CommonCfg.RxStream)
- {
- case 1:
- pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[1] = 0x00;
- pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
- pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
- break;
- case 2:
- pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
- pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
- break;
- case 3:
- pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[2] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
- break;
- }
-
- pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth = pAddHtInfo->AddHtInfo.RecomWidth & pAd->CommonCfg.DesiredHtPhy.ChannelWidth;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPCheckHt:: HtCapInfo.ChannelWidth=%d, RecomWidth=%d, DesiredHtPhy.ChannelWidth=%d, BW40MAvailForA/G=%d/%d, PhyMode=%d \n",
- pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth, pAddHtInfo->AddHtInfo.RecomWidth, pAd->CommonCfg.DesiredHtPhy.ChannelWidth,
- pAd->NicConfig2.field.BW40MAvailForA, pAd->NicConfig2.field.BW40MAvailForG, pAd->CommonCfg.PhyMode));
-
- pAd->MlmeAux.HtCapability.HtCapInfo.GF = pHtCapability->HtCapInfo.GF &pAd->CommonCfg.DesiredHtPhy.GF;
-
- // Send Assoc Req with my HT capability.
- pAd->MlmeAux.HtCapability.HtCapInfo.AMsduSize = pAd->CommonCfg.DesiredHtPhy.AmsduSize;
- pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs = pAd->CommonCfg.DesiredHtPhy.MimoPs;
- pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20 = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor20) & (pHtCapability->HtCapInfo.ShortGIfor20);
- pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40 = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40) & (pHtCapability->HtCapInfo.ShortGIfor40);
- pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC = (pAd->CommonCfg.DesiredHtPhy.TxSTBC)&(pHtCapability->HtCapInfo.RxSTBC);
- pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC = (pAd->CommonCfg.DesiredHtPhy.RxSTBC)&(pHtCapability->HtCapInfo.TxSTBC);
- pAd->MlmeAux.HtCapability.HtCapParm.MaxRAmpduFactor = pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor;
- pAd->MlmeAux.HtCapability.HtCapParm.MpduDensity = pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity;
- pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC = pHtCapability->ExtHtCapInfo.PlusHTC;
- pAd->MacTab.Content[Wcid].HTCapability.ExtHtCapInfo.PlusHTC = pHtCapability->ExtHtCapInfo.PlusHTC;
- if (pAd->CommonCfg.bRdg)
- {
- pAd->MlmeAux.HtCapability.ExtHtCapInfo.RDGSupport = pHtCapability->ExtHtCapInfo.RDGSupport;
- pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC = 1;
- }
-
- if (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_20)
- pAd->MlmeAux.HtCapability.MCSSet[4] = 0x0; // BW20 can't transmit MCS32
-
- COPY_AP_HTSETTINGS_FROM_BEACON(pAd, pHtCapability);
- return TRUE;
-}
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ========================================================================
-
- Routine Description:
- Verify the support rate for different PHY type
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID RTMPUpdateMlmeRate(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR MinimumRate;
- UCHAR ProperMlmeRate; //= RATE_54;
- UCHAR i, j, RateIdx = 12; //1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
- BOOLEAN bMatch = FALSE;
-
- switch (pAd->CommonCfg.PhyMode)
- {
- case PHY_11B:
- ProperMlmeRate = RATE_11;
- MinimumRate = RATE_1;
- break;
- case PHY_11BG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11ABGN_MIXED:
- case PHY_11BGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- if ((pAd->MlmeAux.SupRateLen == 4) &&
- (pAd->MlmeAux.ExtRateLen == 0))
- // B only AP
- ProperMlmeRate = RATE_11;
- else
- ProperMlmeRate = RATE_24;
-
- if (pAd->MlmeAux.Channel <= 14)
- MinimumRate = RATE_1;
- else
- MinimumRate = RATE_6;
- break;
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11N_2_4G: // rt2860 need to check mlmerate for 802.11n
- case PHY_11GN_MIXED:
- case PHY_11AGN_MIXED:
- case PHY_11AN_MIXED:
- case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
- ProperMlmeRate = RATE_24;
- MinimumRate = RATE_6;
- break;
- case PHY_11ABG_MIXED:
- ProperMlmeRate = RATE_24;
- if (pAd->MlmeAux.Channel <= 14)
- MinimumRate = RATE_1;
- else
- MinimumRate = RATE_6;
- break;
- default: // error
- ProperMlmeRate = RATE_1;
- MinimumRate = RATE_1;
- break;
- }
-
- for (i = 0; i < pAd->MlmeAux.SupRateLen; i++)
- {
- for (j = 0; j < RateIdx; j++)
- {
- if ((pAd->MlmeAux.SupRate[i] & 0x7f) == RateIdTo500Kbps[j])
- {
- if (j == ProperMlmeRate)
- {
- bMatch = TRUE;
- break;
- }
- }
- }
-
- if (bMatch)
- break;
- }
-
- if (bMatch == FALSE)
- {
- for (i = 0; i < pAd->MlmeAux.ExtRateLen; i++)
- {
- for (j = 0; j < RateIdx; j++)
- {
- if ((pAd->MlmeAux.ExtRate[i] & 0x7f) == RateIdTo500Kbps[j])
- {
- if (j == ProperMlmeRate)
- {
- bMatch = TRUE;
- break;
- }
- }
- }
-
- if (bMatch)
- break;
- }
- }
-
- if (bMatch == FALSE)
- {
- ProperMlmeRate = MinimumRate;
- }
-
- pAd->CommonCfg.MlmeRate = MinimumRate;
- pAd->CommonCfg.RtsRate = ProperMlmeRate;
- if (pAd->CommonCfg.MlmeRate >= RATE_6)
- {
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_OFDM;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- else
- {
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- pAd->CommonCfg.MlmeTransmit.field.MCS = pAd->CommonCfg.MlmeRate;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_CCK;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = pAd->CommonCfg.MlmeRate;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateMlmeRate ==> MlmeTransmit = 0x%x \n" , pAd->CommonCfg.MlmeTransmit.word));
-}
-
-CHAR RTMPMaxRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi0,
- IN CHAR Rssi1,
- IN CHAR Rssi2)
-{
- CHAR larger = -127;
-
- if ((pAd->Antenna.field.RxPath == 1) && (Rssi0 != 0))
- {
- larger = Rssi0;
- }
-
- if ((pAd->Antenna.field.RxPath >= 2) && (Rssi1 != 0))
- {
- larger = max(Rssi0, Rssi1);
- }
-
- if ((pAd->Antenna.field.RxPath == 3) && (Rssi2 != 0))
- {
- larger = max(larger, Rssi2);
- }
-
- if (larger == -127)
- larger = 0;
-
- return larger;
-}
-
-/*
- ========================================================================
- Routine Description:
- Periodic evaluate antenna link status
-
- Arguments:
- pAd - Adapter pointer
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID AsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BBPR3 = 0;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_NIC_NOT_EXIST |
- fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- return;
-
- if (pAd->StaCfg.Psm == PWR_SAVE)
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
- BBPR3 &= (~0x18);
- if(pAd->Antenna.field.RxPath == 3)
- {
- BBPR3 |= (0x10);
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- BBPR3 |= (0x8);
- }
- else if(pAd->Antenna.field.RxPath == 1)
- {
- BBPR3 |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- {
- ULONG TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- if (TxTotalCnt > 50)
- {
- RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 20);
- pAd->Mlme.bLowThroughput = FALSE;
- }
- else
- {
- RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300);
- pAd->Mlme.bLowThroughput = TRUE;
- }
- }
-}
-
-/*
- ========================================================================
- Routine Description:
- After evaluation, check antenna link status
-
- Arguments:
- pAd - Adapter pointer
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID AsicRxAntEvalTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR BBPR3 = 0;
- CHAR larger = -127, rssi0, rssi1, rssi2;
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- if (pAd->StaCfg.Psm == PWR_SAVE)
- return;
-
-
- // if the traffic is low, use average rssi as the criteria
- if (pAd->Mlme.bLowThroughput == TRUE)
- {
- rssi0 = pAd->StaCfg.RssiSample.LastRssi0;
- rssi1 = pAd->StaCfg.RssiSample.LastRssi1;
- rssi2 = pAd->StaCfg.RssiSample.LastRssi2;
- }
- else
- {
- rssi0 = pAd->StaCfg.RssiSample.AvgRssi0;
- rssi1 = pAd->StaCfg.RssiSample.AvgRssi1;
- rssi2 = pAd->StaCfg.RssiSample.AvgRssi2;
- }
-
- if(pAd->Antenna.field.RxPath == 3)
- {
- larger = max(rssi0, rssi1);
-
- if (larger > (rssi2 + 20))
- pAd->Mlme.RealRxPath = 2;
- else
- pAd->Mlme.RealRxPath = 3;
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- if (rssi0 > (rssi1 + 20))
- pAd->Mlme.RealRxPath = 1;
- else
- pAd->Mlme.RealRxPath = 2;
- }
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
- BBPR3 &= (~0x18);
- if(pAd->Mlme.RealRxPath == 3)
- {
- BBPR3 |= (0x10);
- }
- else if(pAd->Mlme.RealRxPath == 2)
- {
- BBPR3 |= (0x8);
- }
- else if(pAd->Mlme.RealRxPath == 1)
- {
- BBPR3 |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
- }
-
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-
-
-VOID APSDPeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- return;
-
- pAd->CommonCfg.TriggerTimerCount++;
-
-// Driver should not send trigger frame, it should be send by application layer
-/*
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable
- && (pAd->CommonCfg.bNeedSendTriggerFrame ||
- (((pAd->CommonCfg.TriggerTimerCount%20) == 19) && (!pAd->CommonCfg.bAPSDAC_BE || !pAd->CommonCfg.bAPSDAC_BK || !pAd->CommonCfg.bAPSDAC_VI || !pAd->CommonCfg.bAPSDAC_VO))))
- {
- DBGPRINT(RT_DEBUG_TRACE,("Sending trigger frame and enter service period when support APSD\n"));
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- pAd->CommonCfg.bNeedSendTriggerFrame = FALSE;
- pAd->CommonCfg.TriggerTimerCount = 0;
- pAd->CommonCfg.bInServicePeriod = TRUE;
- }*/
-}
-
-/*
- ========================================================================
- Routine Description:
- Set/reset MAC registers according to bPiggyBack parameter
-
- Arguments:
- pAd - Adapter pointer
- bPiggyBack - Enable / Disable Piggy-Back
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID RTMPSetPiggyBack(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bPiggyBack)
-{
- TX_LINK_CFG_STRUC TxLinkCfg;
-
- RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
-
- TxLinkCfg.field.TxCFAckEn = bPiggyBack;
- RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-}
-
-/*
- ========================================================================
- Routine Description:
- check if this entry need to switch rate automatically
-
- Arguments:
- pAd
- pEntry
-
- Return Value:
- TURE
- FALSE
-
- ========================================================================
-*/
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry)
-{
- BOOLEAN result = TRUE;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // only associated STA counts
- if (pEntry && (pEntry->ValidAsCLI) && (pEntry->Sst == SST_ASSOC))
- {
- result = pAd->StaCfg.bAutoTxRateSwitch;
- }
- else
- result = FALSE;
-
-#ifdef QOS_DLS_SUPPORT
- if (pEntry && (pEntry->ValidAsDls))
- result = pAd->StaCfg.bAutoTxRateSwitch;
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
-
- return result;
-}
-
-
-BOOLEAN RTMPAutoRateSwitchCheck(
- IN PRTMP_ADAPTER pAd)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.bAutoTxRateSwitch)
- return TRUE;
- }
-#endif // CONFIG_STA_SUPPORT //
- return FALSE;
-}
-
-
-/*
- ========================================================================
- Routine Description:
- check if this entry need to fix tx legacy rate
-
- Arguments:
- pAd
- pEntry
-
- Return Value:
- TURE
- FALSE
-
- ========================================================================
-*/
-UCHAR RTMPStaFixedTxMode(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry)
-{
- UCHAR tx_mode = FIXED_TXMODE_HT;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- tx_mode = (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return tx_mode;
-}
-
-/*
- ========================================================================
- Routine Description:
- Overwrite HT Tx Mode by Fixed Legency Tx Mode, if specified.
-
- Arguments:
- pAd
- pEntry
-
- Return Value:
- TURE
- FALSE
-
- ========================================================================
-*/
-VOID RTMPUpdateLegacyTxSetting(
- UCHAR fixed_tx_mode,
- PMAC_TABLE_ENTRY pEntry)
-{
- HTTRANSMIT_SETTING TransmitSetting;
-
- if (fixed_tx_mode == FIXED_TXMODE_HT)
- return;
-
- TransmitSetting.word = 0;
-
- TransmitSetting.field.MODE = pEntry->HTPhyMode.field.MODE;
- TransmitSetting.field.MCS = pEntry->HTPhyMode.field.MCS;
-
- if (fixed_tx_mode == FIXED_TXMODE_CCK)
- {
- TransmitSetting.field.MODE = MODE_CCK;
- // CCK mode allow MCS 0~3
- if (TransmitSetting.field.MCS > MCS_3)
- TransmitSetting.field.MCS = MCS_3;
- }
- else
- {
- TransmitSetting.field.MODE = MODE_OFDM;
- // OFDM mode allow MCS 0~7
- if (TransmitSetting.field.MCS > MCS_7)
- TransmitSetting.field.MCS = MCS_7;
- }
-
- if (pEntry->HTPhyMode.field.MODE >= TransmitSetting.field.MODE)
- {
- pEntry->HTPhyMode.word = TransmitSetting.word;
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateLegacyTxSetting : wcid-%d, MODE=%s, MCS=%d \n",
- pEntry->Aid, GetPhyMode(pEntry->HTPhyMode.field.MODE), pEntry->HTPhyMode.field.MCS));
- }
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ==========================================================================
- Description:
- dynamic tune BBP R66 to find a balance between sensibility and
- noise isolation
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicStaBbpTuning(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR OrigR66Value = 0, R66;//, R66UpperBound = 0x30, R66LowerBound = 0x30;
- CHAR Rssi;
-
- // 2860C did not support Fase CCA, therefore can't tune
- if (pAd->MACVersion == 0x28600100)
- return;
-
- //
- // work as a STA
- //
- if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) // no R66 tuning when SCANNING
- return;
-
- if ((pAd->OpMode == OPMODE_STA)
- && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- && !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- )
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value);
- R66 = OrigR66Value;
-
- if (pAd->Antenna.field.RxPath > 1)
- Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
- else
- Rssi = pAd->StaCfg.RssiSample.AvgRssi0;
-
- if (pAd->LatchRfRegs.Channel <= 14)
- { //BG band
-#ifdef RT2870
- // RT3070 is a no LNA solution, it should have different control regarding to AGC gain control
- // Otherwise, it will have some throughput side effect when low RSSI
- if (IS_RT3070(pAd))
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = 0x1C + 2*GET_LNA_GAIN(pAd) + 0x20;
- if (OrigR66Value != R66)
- {
- RTUSBWriteBBPRegister(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x1C + 2*GET_LNA_GAIN(pAd);
- if (OrigR66Value != R66)
- {
- RTUSBWriteBBPRegister(pAd, BBP_R66, R66);
- }
- }
- }
- else
-#endif // RT2870 //
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = (0x2E + GET_LNA_GAIN(pAd)) + 0x10;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
- }
- else
- { //A band
- if (pAd->CommonCfg.BBPCurrentBW == BW_20)
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = 0x32 + (GET_LNA_GAIN(pAd)*5)/3 + 0x10;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x32 + (GET_LNA_GAIN(pAd)*5)/3;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
- else
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = 0x3A + (GET_LNA_GAIN(pAd)*5)/3 + 0x10;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x3A + (GET_LNA_GAIN(pAd)*5)/3;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
- }
-
-
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-VOID RTMPSetAGCInitValue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BandWidth)
-{
- UCHAR R66 = 0x30;
-
- if (pAd->LatchRfRegs.Channel <= 14)
- { // BG band
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- { //A band
- if (BandWidth == BW_20)
- {
- R66 = (UCHAR)(0x32 + (GET_LNA_GAIN(pAd)*5)/3);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
-#ifdef DOT11_N_SUPPORT
- else
- {
- R66 = (UCHAR)(0x3A + (GET_LNA_GAIN(pAd)*5)/3);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
-}
-
-VOID AsicTurnOffRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
-
- // RF R2 bit 18 = 0
- UINT32 R1 = 0, R2 = 0, R3 = 0;
- UCHAR index;
- RTMP_RF_REGS *RFRegTable;
-
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R1 = RFRegTable[index].R1 & 0xffffdfff;
- R2 = RFRegTable[index].R2 & 0xfffbffff;
- R3 = RFRegTable[index].R3 & 0xfff3ffff;
-
- RTMP_RF_IO_WRITE32(pAd, R1);
- RTMP_RF_IO_WRITE32(pAd, R2);
-
- // Program R1b13 to 1, R3/b18,19 to 0, R2b18 to 0.
- // Set RF R2 bit18=0, R3 bit[18:19]=0
- //if (pAd->StaCfg.bRadio == FALSE)
- if (1)
- {
- RTMP_RF_IO_WRITE32(pAd, R3);
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOffRFClk#%d(RF=%d, ) , R2=0x%08x, R3 = 0x%08x \n",
- Channel, pAd->RfIcType, R2, R3));
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOffRFClk#%d(RF=%d, ) , R2=0x%08x \n",
- Channel, pAd->RfIcType, R2));
- break;
- }
- }
- break;
-
- default:
- break;
- }
-}
-
-
-VOID AsicTurnOnRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
-
- // RF R2 bit 18 = 0
- UINT32 R1 = 0, R2 = 0, R3 = 0;
- UCHAR index;
- RTMP_RF_REGS *RFRegTable;
-
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R3 = pAd->LatchRfRegs.R3;
- R3 &= 0xfff3ffff;
- R3 |= 0x00080000;
- RTMP_RF_IO_WRITE32(pAd, R3);
-
- R1 = RFRegTable[index].R1;
- RTMP_RF_IO_WRITE32(pAd, R1);
-
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- R2 |= 0x40; // write 1 to off Rxpath.
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
- RTMP_RF_IO_WRITE32(pAd, R2);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOnRFClk#%d(RF=%d, ) , R2=0x%08x\n",
- Channel,
- pAd->RfIcType,
- R2));
-}
-
+#include "../../rt2860/common/mlme.c"
diff --git a/drivers/staging/rt2870/common/netif_block.c b/drivers/staging/rt2870/common/netif_block.c
deleted file mode 100644
index d3f7d087e7f0..000000000000
--- a/drivers/staging/rt2870/common/netif_block.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "../rt_config.h"
-#include "netif_block.h"
-
-static NETIF_ENTRY freeNetIfEntryPool[FREE_NETIF_POOL_SIZE];
-static LIST_HEADER freeNetIfEntryList;
-
-void initblockQueueTab(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
-
- initList(&freeNetIfEntryList);
- for (i = 0; i < FREE_NETIF_POOL_SIZE; i++)
- insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)&freeNetIfEntryPool[i]);
-
- for (i=0; i < NUM_OF_TX_RING; i++)
- initList(&pAd->blockQueueTab[i].NetIfList);
-
- return;
-}
-
-BOOLEAN blockNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
- IN PNET_DEV pNetDev)
-{
- PNETIF_ENTRY pNetIfEntry = NULL;
-
- if ((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(&freeNetIfEntryList)) != NULL)
- {
- netif_stop_queue(pNetDev);
- pNetIfEntry->pNetDev = pNetDev;
- insertTailList(&pBlockQueueEntry->NetIfList, (PLIST_ENTRY)pNetIfEntry);
-
- pBlockQueueEntry->SwTxQueueBlockFlag = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("netif_stop_queue(%s)\n", pNetDev->name));
- }
- else
- return FALSE;
-
- return TRUE;
-}
-
-VOID releaseNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry)
-{
- PNETIF_ENTRY pNetIfEntry = NULL;
- PLIST_HEADER pNetIfList = &pBlockQueueEntry->NetIfList;
-
- while((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(pNetIfList)) != NULL)
- {
- PNET_DEV pNetDev = pNetIfEntry->pNetDev;
- netif_wake_queue(pNetDev);
- insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)pNetIfEntry);
-
- DBGPRINT(RT_DEBUG_TRACE, ("netif_wake_queue(%s)\n", pNetDev->name));
- }
- pBlockQueueEntry->SwTxQueueBlockFlag = FALSE;
- return;
-}
-
-
-VOID StopNetIfQueue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- PNET_DEV NetDev = NULL;
- UCHAR IfIdx = 0;
- BOOLEAN valid = FALSE;
-
-#ifdef APCLI_SUPPORT
- if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_APCLI)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_APCLI) % MAX_APCLI_NUM;
- NetDev = pAd->ApCfg.ApCliTab[IfIdx].dev;
- }
- else
-#endif // APCLI_SUPPORT //
-#ifdef WDS_SUPPORT
- if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_WDS)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_WDS) % MAX_WDS_ENTRY;
- NetDev = pAd->WdsTab.WdsEntry[IfIdx].dev;
- }
- else
-#endif // WDS_SUPPORT //
- {
-#ifdef MBSS_SUPPORT
- if (pAd->OpMode == OPMODE_AP)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_MBSSID) % MAX_MBSSID_NUM;
- NetDev = pAd->ApCfg.MBSSID[IfIdx].MSSIDDev;
- }
- else
- {
- IfIdx = MAIN_MBSSID;
- NetDev = pAd->net_dev;
- }
-#else
- IfIdx = MAIN_MBSSID;
- NetDev = pAd->net_dev;
-#endif
- }
-
- // WMM support 4 software queues.
- // One software queue full doesn't mean device have no capbility to transmit packet.
- // So disable block Net-If queue function while WMM enable.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- valid = (pAd->CommonCfg.bWmmCapable == TRUE) ? FALSE : TRUE;
-#endif // CONFIG_STA_SUPPORT //
-
- if (valid)
- blockNetIf(&pAd->blockQueueTab[QueIdx], NetDev);
- return;
-}
-
diff --git a/drivers/staging/rt2870/common/rtmp_init.c b/drivers/staging/rt2870/common/rtmp_init.c
index 099b6a806f86..eef10efda196 100644
--- a/drivers/staging/rt2870/common/rtmp_init.c
+++ b/drivers/staging/rt2870/common/rtmp_init.c
@@ -1,4132 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_init.c
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 2002-08-01 created
- John Chang 2004-08-20 RT2561/2661 use scatter-gather scheme
- Jan Lee 2006-09-15 RT2860. Change for 802.11n , EEPROM, Led, BA, HT.
-*/
-#include "../rt_config.h"
-#include "firmware.h"
-
-//#define BIN_IN_FILE /* use *.bin firmware */
-
-UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
-ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008,
- 0x00000010, 0x00000020, 0x00000040, 0x00000080,
- 0x00000100, 0x00000200, 0x00000400, 0x00000800,
- 0x00001000, 0x00002000, 0x00004000, 0x00008000,
- 0x00010000, 0x00020000, 0x00040000, 0x00080000,
- 0x00100000, 0x00200000, 0x00400000, 0x00800000,
- 0x01000000, 0x02000000, 0x04000000, 0x08000000,
- 0x10000000, 0x20000000, 0x40000000, 0x80000000};
-
-char* CipherName[] = {"none","wep64","wep128","TKIP","AES","CKIP64","CKIP128"};
-
-const unsigned short ccitt_16Table[] = {
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
- 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
- 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
- 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
- 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
- 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
- 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
- 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
- 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
- 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
- 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
- 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
- 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
- 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
- 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
- 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
- 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
- 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
- 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
- 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
- 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
- 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
- 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
-};
-#define ByteCRC16(v, crc) \
- (unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])
-
-unsigned char BitReverse(unsigned char x)
-{
- int i;
- unsigned char Temp=0;
- for(i=0; ; i++)
- {
- if(x & 0x80) Temp |= 0x80;
- if(i==7) break;
- x <<= 1;
- Temp >>= 1;
- }
- return Temp;
-}
-
-//
-// BBP register initialization set
-//
-REG_PAIR BBPRegTable[] = {
- {BBP_R65, 0x2C}, // fix rssi issue
- {BBP_R66, 0x38}, // Also set this default value to pAd->BbpTuning.R66CurrentValue at initial
- {BBP_R69, 0x12},
- {BBP_R70, 0xa}, // BBP_R70 will change to 0x8 in ApStartUp and LinkUp for rt2860C, otherwise value is 0xa
- {BBP_R73, 0x10},
- {BBP_R81, 0x37},
- {BBP_R82, 0x62},
- {BBP_R83, 0x6A},
- {BBP_R84, 0x99}, // 0x19 is for rt2860E and after. This is for extension channel overlapping IOT. 0x99 is for rt2860D and before
- {BBP_R86, 0x00}, // middle range issue, Rory @2008-01-28
- {BBP_R91, 0x04}, // middle range issue, Rory @2008-01-28
- {BBP_R92, 0x00}, // middle range issue, Rory @2008-01-28
- {BBP_R103, 0x00}, // near range high-power issue, requested from Gary @2008-0528
- {BBP_R105, 0x05}, // 0x05 is for rt2860E to turn on FEQ control. It is safe for rt2860D and before, because Bit 7:2 are reserved in rt2860D and before.
-};
-#define NUM_BBP_REG_PARMS (sizeof(BBPRegTable) / sizeof(REG_PAIR))
-
-//
-// RF register initialization set
-//
-#ifdef RT2870
-REG_PAIR RT30xx_RFRegTable[] = {
- {RF_R04, 0x40},
- {RF_R05, 0x03},
- {RF_R06, 0x02},
- {RF_R07, 0x70},
- {RF_R09, 0x0F},
- {RF_R10, 0x71},
- {RF_R11, 0x21},
- {RF_R12, 0x7B},
- {RF_R14, 0x90},
- {RF_R15, 0x58},
- {RF_R16, 0xB3},
- {RF_R17, 0x92},
- {RF_R18, 0x2C},
- {RF_R19, 0x02},
- {RF_R20, 0xBA},
- {RF_R21, 0xDB},
- {RF_R24, 0x16},
- {RF_R25, 0x01},
- {RF_R27, 0x03},
- {RF_R29, 0x1F},
-};
-#define NUM_RF_REG_PARMS (sizeof(RT30xx_RFRegTable) / sizeof(REG_PAIR))
-#endif // RT2870 //
-
-//
-// ASIC register initialization sets
-//
-
-RTMP_REG_PAIR MACRegTable[] = {
-#if defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x200)
- {BCN_OFFSET0, 0xf8f0e8e0}, /* 0x3800(e0), 0x3A00(e8), 0x3C00(f0), 0x3E00(f8), 512B for each beacon */
- {BCN_OFFSET1, 0x6f77d0c8}, /* 0x3200(c8), 0x3400(d0), 0x1DC0(77), 0x1BC0(6f), 512B for each beacon */
-#elif defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x100)
- {BCN_OFFSET0, 0xece8e4e0}, /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */
- {BCN_OFFSET1, 0xfcf8f4f0}, /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */
-#else
- #error You must re-calculate new value for BCN_OFFSET0 & BCN_OFFSET1 in MACRegTable[]!!!
-#endif // HW_BEACON_OFFSET //
-
- {LEGACY_BASIC_RATE, 0x0000013f}, // Basic rate set bitmap
- {HT_BASIC_RATE, 0x00008003}, // Basic HT rate set , 20M, MCS=3, MM. Format is the same as in TXWI.
- {MAC_SYS_CTRL, 0x00}, // 0x1004, , default Disable RX
- {RX_FILTR_CFG, 0x17f97}, //0x1400 , RX filter control,
- {BKOFF_SLOT_CFG, 0x209}, // default set short slot time, CC_DELAY_TIME should be 2
- {TX_SW_CFG0, 0x0}, // Gary,2008-05-21 for CWC test
- {TX_SW_CFG1, 0x80606}, // Gary,2006-08-23
- {TX_LINK_CFG, 0x1020}, // Gary,2006-08-23
- //{TX_TIMEOUT_CFG, 0x00182090}, // CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT
- {TX_TIMEOUT_CFG, 0x000a2090}, // CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT , Modify for 2860E ,2007-08-01
- {MAX_LEN_CFG, MAX_AGGREGATION_SIZE | 0x00001000}, // 0x3018, MAX frame length. Max PSDU = 16kbytes.
- {LED_CFG, 0x7f031e46}, // Gary, 2006-08-23
- {PBF_MAX_PCNT, 0x1F3FBF9F}, //0x1F3f7f9f}, //Jan, 2006/04/20
- //{TX_RTY_CFG, 0x6bb80408}, // Jan, 2006/11/16
- {TX_RTY_CFG, 0x47d01f0f}, // Jan, 2006/11/16, Set TxWI->ACK =0 in Probe Rsp Modify for 2860E ,2007-08-03
- {AUTO_RSP_CFG, 0x00000013}, // Initial Auto_Responder, because QA will turn off Auto-Responder
- {CCK_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
- {OFDM_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
-#ifdef RT2870
- {PBF_CFG, 0xf40006}, // Only enable Queue 2
- {MM40_PROT_CFG, 0x3F44084}, // Initial Auto_Responder, because QA will turn off Auto-Responder
- {WPDMA_GLO_CFG, 0x00000030},
-#endif // RT2870 //
- {GF20_PROT_CFG, 0x01744004}, // set 19:18 --> Short NAV for MIMO PS
- {GF40_PROT_CFG, 0x03F44084},
- {MM20_PROT_CFG, 0x01744004},
- {TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f*/ /*0x000024bf*/}, //Extension channel backoff.
- {TX_RTS_CFG, 0x00092b20},
-//#ifdef WIFI_TEST
- {EXP_ACK_TIME, 0x002400ca}, // default value
-//#else
-// {EXP_ACK_TIME, 0x005400ca}, // suggested by Gray @ 20070323 for 11n intel-sta throughput
-//#endif // end - WIFI_TEST //
- {TXOP_HLDR_ET, 0x00000002},
-
- /* Jerry comments 2008/01/16: we use SIFS = 10us in CCK defaultly, but it seems that 10us
- is too small for INTEL 2200bg card, so in MBSS mode, the delta time between beacon0
- and beacon1 is SIFS (10us), so if INTEL 2200bg card connects to BSS0, the ping
- will always lost. So we change the SIFS of CCK from 10us to 16us. */
- {XIFS_TIME_CFG, 0x33a41010},
- {PWR_PIN_CFG, 0x00000003}, // patch for 2880-E
-};
-
-
-#ifdef CONFIG_STA_SUPPORT
-RTMP_REG_PAIR STAMACRegTable[] = {
- {WMM_AIFSN_CFG, 0x00002273},
- {WMM_CWMIN_CFG, 0x00002344},
- {WMM_CWMAX_CFG, 0x000034aa},
-};
-#endif // CONFIG_STA_SUPPORT //
-
-#define NUM_MAC_REG_PARMS (sizeof(MACRegTable) / sizeof(RTMP_REG_PAIR))
-#ifdef CONFIG_STA_SUPPORT
-#define NUM_STA_MAC_REG_PARMS (sizeof(STAMACRegTable) / sizeof(RTMP_REG_PAIR))
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RT2870
-//
-// RT2870 Firmware Spec only used 1 oct for version expression
-//
-#define FIRMWARE_MINOR_VERSION 7
-
-#endif // RT2870 //
-
-// New 8k byte firmware size for RT3071/RT3072
-#define FIRMWAREIMAGE_MAX_LENGTH 0x2000
-#define FIRMWAREIMAGE_LENGTH (sizeof (FirmwareImage) / sizeof(UCHAR))
-#define FIRMWARE_MAJOR_VERSION 0
-
-#define FIRMWAREIMAGEV1_LENGTH 0x1000
-#define FIRMWAREIMAGEV2_LENGTH 0x1000
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- Allocate RTMP_ADAPTER data block and do some initialization
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTMPAllocAdapterBlock(
- IN PVOID handle,
- OUT PRTMP_ADAPTER *ppAdapter)
-{
- PRTMP_ADAPTER pAd;
- NDIS_STATUS Status;
- INT index;
- UCHAR *pBeaconBuf = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocAdapterBlock\n"));
-
- *ppAdapter = NULL;
-
- do
- {
- // Allocate RTMP_ADAPTER memory block
- pBeaconBuf = kmalloc(MAX_BEACON_SIZE, MEM_ALLOC_FLAG);
- if (pBeaconBuf == NULL)
- {
- Status = NDIS_STATUS_FAILURE;
- DBGPRINT_ERR(("Failed to allocate memory - BeaconBuf!\n"));
- break;
- }
-
- Status = AdapterBlockAllocateMemory(handle, (PVOID *)&pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("Failed to allocate memory - ADAPTER\n"));
- break;
- }
- pAd->BeaconBuf = pBeaconBuf;
- printk("\n\n=== pAd = %p, size = %d ===\n\n", pAd, (UINT32)sizeof(RTMP_ADAPTER));
-
-
- // Init spin locks
- NdisAllocateSpinLock(&pAd->MgmtRingLock);
-
- for (index =0 ; index < NUM_OF_TX_RING; index++)
- {
- NdisAllocateSpinLock(&pAd->TxSwQueueLock[index]);
- NdisAllocateSpinLock(&pAd->DeQueueLock[index]);
- pAd->DeQueueRunning[index] = FALSE;
- }
-
- NdisAllocateSpinLock(&pAd->irq_lock);
-
- } while (FALSE);
-
- if ((Status != NDIS_STATUS_SUCCESS) && (pBeaconBuf))
- kfree(pBeaconBuf);
-
- *ppAdapter = pAd;
-
- DBGPRINT_S(Status, ("<-- RTMPAllocAdapterBlock, Status=%x\n", Status));
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Read initial Tx power per MCS and BW from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReadTxPwrPerRate(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG data, Adata, Gdata;
- USHORT i, value, value2;
- INT Apwrdelta, Gpwrdelta;
- UCHAR t1,t2,t3,t4;
- BOOLEAN bValid, bApwrdeltaMinus = TRUE, bGpwrdeltaMinus = TRUE;
-
- //
- // Get power delta for 20MHz and 40MHz.
- //
- DBGPRINT(RT_DEBUG_TRACE, ("Txpower per Rate\n"));
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_DELTA, value2);
- Apwrdelta = 0;
- Gpwrdelta = 0;
-
- if ((value2 & 0xff) != 0xff)
- {
- if ((value2 & 0x80))
- Gpwrdelta = (value2&0xf);
-
- if ((value2 & 0x40))
- bGpwrdeltaMinus = FALSE;
- else
- bGpwrdeltaMinus = TRUE;
- }
- if ((value2 & 0xff00) != 0xff00)
- {
- if ((value2 & 0x8000))
- Apwrdelta = ((value2&0xf00)>>8);
-
- if ((value2 & 0x4000))
- bApwrdeltaMinus = FALSE;
- else
- bApwrdeltaMinus = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Gpwrdelta = %x, Apwrdelta = %x .\n", Gpwrdelta, Apwrdelta));
-
- //
- // Get Txpower per MCS for 20MHz in 2.4G.
- //
- for (i=0; i<5; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i*4, value);
- data = value;
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i*4 + 2, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
- data |= (value<<16);
-
- pAd->Tx20MPwrCfgABand[i] = pAd->Tx40MPwrCfgABand[i] = Adata;
- pAd->Tx20MPwrCfgGBand[i] = pAd->Tx40MPwrCfgGBand[i] = Gdata;
-
- if (data != 0xffffffff)
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, data);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("20MHz BW, 2.4G band-%lx, Adata = %lx, Gdata = %lx \n", data, Adata, Gdata));
- }
-
- //
- // Check this block is valid for 40MHz in 2.4G. If invalid, use parameter for 20MHz in 2.4G
- //
- bValid = TRUE;
- for (i=0; i<6; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + 2 + i*2, value);
- if (((value & 0x00FF) == 0x00FF) || ((value & 0xFF00) == 0xFF00))
- {
- bValid = FALSE;
- break;
- }
- }
-
- //
- // Get Txpower per MCS for 40MHz in 2.4G.
- //
- if (bValid)
- {
- for (i=0; i<4; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + i*4, value);
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + i*4 + 2, value);
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
-
- if (i == 0)
- pAd->Tx40MPwrCfgGBand[i+1] = (pAd->Tx40MPwrCfgGBand[i+1] & 0x0000FFFF) | (Gdata & 0xFFFF0000);
- else
- pAd->Tx40MPwrCfgGBand[i+1] = Gdata;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("40MHz BW, 2.4G band, Gdata = %lx \n", Gdata));
- }
- }
-
- //
- // Check this block is valid for 20MHz in 5G. If invalid, use parameter for 20MHz in 2.4G
- //
- bValid = TRUE;
- for (i=0; i<8; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + 2 + i*2, value);
- if (((value & 0x00FF) == 0x00FF) || ((value & 0xFF00) == 0xFF00))
- {
- bValid = FALSE;
- break;
- }
- }
-
- //
- // Get Txpower per MCS for 20MHz in 5G.
- //
- if (bValid)
- {
- for (i=0; i<5; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + i*4, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + i*4 + 2, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
-
- if (i == 0)
- pAd->Tx20MPwrCfgABand[i] = (pAd->Tx20MPwrCfgABand[i] & 0x0000FFFF) | (Adata & 0xFFFF0000);
- else
- pAd->Tx20MPwrCfgABand[i] = Adata;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("20MHz BW, 5GHz band, Adata = %lx \n", Adata));
- }
- }
-
- //
- // Check this block is valid for 40MHz in 5G. If invalid, use parameter for 20MHz in 2.4G
- //
- bValid = TRUE;
- for (i=0; i<6; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + 2 + i*2, value);
- if (((value & 0x00FF) == 0x00FF) || ((value & 0xFF00) == 0xFF00))
- {
- bValid = FALSE;
- break;
- }
- }
-
- //
- // Get Txpower per MCS for 40MHz in 5G.
- //
- if (bValid)
- {
- for (i=0; i<4; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + i*4, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + i*4 + 2, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
-
- if (i == 0)
- pAd->Tx40MPwrCfgABand[i+1] = (pAd->Tx40MPwrCfgABand[i+1] & 0x0000FFFF) | (Adata & 0xFFFF0000);
- else
- pAd->Tx40MPwrCfgABand[i+1] = Adata;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("40MHz BW, 5GHz band, Adata = %lx \n", Adata));
- }
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Read initial channel power parameters from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReadChannelPwr(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i, choffset;
- EEPROM_TX_PWR_STRUC Power;
- EEPROM_TX_PWR_STRUC Power2;
-
- // Read Tx power value for all channels
- // Value from 1 - 0x7f. Default value is 24.
- // Power value : 2.4G 0x00 (0) ~ 0x1F (31)
- // : 5.5G 0xF9 (-7) ~ 0x0F (15)
-
- // 0. 11b/g, ch1 - ch 14
- for (i = 0; i < 7; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2, Power2.word);
- pAd->TxPower[i * 2].Channel = i * 2 + 1;
- pAd->TxPower[i * 2 + 1].Channel = i * 2 + 2;
-
- if ((Power.field.Byte0 > 31) || (Power.field.Byte0 < 0))
- pAd->TxPower[i * 2].Power = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 > 31) || (Power.field.Byte1 < 0))
- pAd->TxPower[i * 2 + 1].Power = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2 + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 > 31) || (Power2.field.Byte0 < 0))
- pAd->TxPower[i * 2].Power2 = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 > 31) || (Power2.field.Byte1 < 0))
- pAd->TxPower[i * 2 + 1].Power2 = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2 + 1].Power2 = Power2.field.Byte1;
- }
-
- // 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz)
- // 1.1 Fill up channel
- choffset = 14;
- for (i = 0; i < 4; i++)
- {
- pAd->TxPower[3 * i + choffset + 0].Channel = 36 + i * 8 + 0;
- pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 1].Channel = 36 + i * 8 + 2;
- pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 2].Channel = 36 + i * 8 + 4;
- pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
- }
-
- // 1.2 Fill up power
- for (i = 0; i < 6; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2, Power2.word);
-
- if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
- }
-
- // 2. HipperLAN 2 100, 102 ,104; 108, 110, 112; 116, 118, 120; 124, 126, 128; 132, 134, 136; 140 (including central frequency in BW 40MHz)
- // 2.1 Fill up channel
- choffset = 14 + 12;
- for (i = 0; i < 5; i++)
- {
- pAd->TxPower[3 * i + choffset + 0].Channel = 100 + i * 8 + 0;
- pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 1].Channel = 100 + i * 8 + 2;
- pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 2].Channel = 100 + i * 8 + 4;
- pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
- }
- pAd->TxPower[3 * 5 + choffset + 0].Channel = 140;
- pAd->TxPower[3 * 5 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * 5 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- // 2.2 Fill up power
- for (i = 0; i < 8; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2, Power2.word);
-
- if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
- }
-
- // 3. U-NII upper band: 149, 151, 153; 157, 159, 161; 165 (including central frequency in BW 40MHz)
- // 3.1 Fill up channel
- choffset = 14 + 12 + 16;
- for (i = 0; i < 2; i++)
- {
- pAd->TxPower[3 * i + choffset + 0].Channel = 149 + i * 8 + 0;
- pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 1].Channel = 149 + i * 8 + 2;
- pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 2].Channel = 149 + i * 8 + 4;
- pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
- }
- pAd->TxPower[3 * 2 + choffset + 0].Channel = 165;
- pAd->TxPower[3 * 2 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * 2 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- // 3.2 Fill up power
- for (i = 0; i < 4; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2, Power2.word);
-
- if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
- }
-
- // 4. Print and Debug
- choffset = 14 + 12 + 16 + 7;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Read the following from the registry
- 1. All the parameters
- 2. NetworkAddres
-
- Arguments:
- Adapter Pointer to our adapter
- WrapperConfigurationContext For use by NdisOpenConfiguration
-
- Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
- NDIS_STATUS_RESOURCES
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS NICReadRegParameters(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_HANDLE WrapperConfigurationContext
- )
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- DBGPRINT_S(Status, ("<-- NICReadRegParameters, Status=%x\n", Status));
- return Status;
-}
-
-
-#ifdef RT2870
-/*
- ========================================================================
-
- Routine Description:
- For RF filter calibration purpose
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID RTUSBFilterCalibration(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue;
- UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0;
- UCHAR RF_R24_Value = 0;
-
- // Give bbp filter initial value
- pAd->Mlme.CaliBW20RfR24 = 0x16;
- pAd->Mlme.CaliBW40RfR24 = 0x36; //Bit[5] must be 1 for BW 40
-
- do
- {
- if (loop == 1) //BandWidth = 40 MHz
- {
- // Write 0x27 to RF_R24 to program filter
- RF_R24_Value = 0x27;
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
- FilterTarget = 0x19;
-
- // when calibrate BW40, BBP mask must set to BW40.
- RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue);
- }
- else //BandWidth = 20 MHz
- {
- // Write 0x07 to RF_R24 to program filter
- RF_R24_Value = 0x07;
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
- FilterTarget = 0x16;
- }
-
- // Write 0x01 to RF_R22 to enable baseband loopback mode
- RT30xxReadRFRegister(pAd, RF_R22, &value);
- value |= 0x01;
- RT30xxWriteRFRegister(pAd, RF_R22, value);
-
- // Write 0x00 to BBP_R24 to set power & frequency of passband test tone
- RTUSBWriteBBPRegister(pAd, BBP_R24, 0);
-
- do
- {
- // Write 0x90 to BBP_R25 to transmit test tone
- RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90);
-
- RTMPusecDelay(1000);
- // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0]
- RTUSBReadBBPRegister(pAd, BBP_R55, &value);
- R55x = value & 0xFF;
-
- } while ((ReTry++ < 100) && (R55x == 0));
-
- // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone
- RTUSBWriteBBPRegister(pAd, BBP_R24, 0x06);
-
- while(TRUE)
- {
- // Write 0x90 to BBP_R25 to transmit test tone
- RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90);
-
- //We need to wait for calibration
- RTMPusecDelay(1000);
- RTUSBReadBBPRegister(pAd, BBP_R55, &value);
- value &= 0xFF;
- if ((R55x - value) < FilterTarget)
- {
- RF_R24_Value ++;
- }
- else if ((R55x - value) == FilterTarget)
- {
- RF_R24_Value ++;
- count ++;
- }
- else
- {
- break;
- }
-
- // prevent infinite loop cause driver hang.
- if (loopcnt++ > 100)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt));
- break;
- }
-
- // Write RF_R24 to program filter
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
- }
-
- if (count > 0)
- {
- RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
- }
-
- // Store for future usage
- if (loopcnt < 100)
- {
- if (loop++ == 0)
- {
- //BandWidth = 20 MHz
- pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value;
- }
- else
- {
- //BandWidth = 40 MHz
- pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value;
- break;
- }
- }
- else
- break;
-
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
-
- // reset count
- count = 0;
- } while(TRUE);
-
- //
- // Set back to initial state
- //
- RTUSBWriteBBPRegister(pAd, BBP_R24, 0);
-
- RT30xxReadRFRegister(pAd, RF_R22, &value);
- value &= ~(0x01);
- RT30xxWriteRFRegister(pAd, RF_R22, value);
-
- // set BBP back to BW20
- RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTUSBFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
-}
-
-
-VOID NICInitRT30xxRFRegisters(IN PRTMP_ADAPTER pAd)
-{
- INT i;
- // Driver must read EEPROM to get RfIcType before initial RF registers
- // Initialize RF register to default value
- if (IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) ||(pAd->RfIcType == RFIC_2020)))
- {
- // Init RF calibration
- // Driver should toggle RF R30 bit7 before init RF registers
- ULONG RfReg = 0;
- RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg);
- RfReg |= 0x80;
- RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
- RTMPusecDelay(1000);
- RfReg &= 0x7F;
- RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
-
- // Initialize RF register to default value
- for (i = 0; i < NUM_RF_REG_PARMS; i++)
- {
- RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value);
- }
-
- //For RF filter Calibration
- RTUSBFilterCalibration(pAd);
- }
-
-}
-#endif // RT2870 //
-
-
-/*
- ========================================================================
-
- Routine Description:
- Read initial parameters from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID NICReadEEPROMParameters(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mac_addr)
-{
- UINT32 data = 0;
- USHORT i, value, value2;
- UCHAR TmpPhy;
- EEPROM_TX_PWR_STRUC Power;
- EEPROM_VERSION_STRUC Version;
- EEPROM_ANTENNA_STRUC Antenna;
- EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n"));
-
- // Init EEPROM Address Number, before access EEPROM; if 93c46, EEPROMAddressNum=6, else if 93c66, EEPROMAddressNum=8
- RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
- DBGPRINT(RT_DEBUG_TRACE, ("--> E2PROM_CSR = 0x%x\n", data));
-
- if((data & 0x30) == 0)
- pAd->EEPROMAddressNum = 6; // 93C46
- else if((data & 0x30) == 0x10)
- pAd->EEPROMAddressNum = 8; // 93C66
- else
- pAd->EEPROMAddressNum = 8; // 93C86
- DBGPRINT(RT_DEBUG_TRACE, ("--> EEPROMAddressNum = %d\n", pAd->EEPROMAddressNum ));
-
- // RT2860 MAC no longer auto load MAC address from E2PROM. Driver has to intialize
- // MAC address registers according to E2PROM setting
- if (mac_addr == NULL ||
- strlen(mac_addr) != 17 ||
- mac_addr[2] != ':' || mac_addr[5] != ':' || mac_addr[8] != ':' ||
- mac_addr[11] != ':' || mac_addr[14] != ':')
- {
- USHORT Addr01,Addr23,Addr45 ;
-
- RT28xx_EEPROM_READ16(pAd, 0x04, Addr01);
- RT28xx_EEPROM_READ16(pAd, 0x06, Addr23);
- RT28xx_EEPROM_READ16(pAd, 0x08, Addr45);
-
- pAd->PermanentAddress[0] = (UCHAR)(Addr01 & 0xff);
- pAd->PermanentAddress[1] = (UCHAR)(Addr01 >> 8);
- pAd->PermanentAddress[2] = (UCHAR)(Addr23 & 0xff);
- pAd->PermanentAddress[3] = (UCHAR)(Addr23 >> 8);
- pAd->PermanentAddress[4] = (UCHAR)(Addr45 & 0xff);
- pAd->PermanentAddress[5] = (UCHAR)(Addr45 >> 8);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from E2PROM \n"));
- }
- else
- {
- INT j;
- PUCHAR macptr;
-
- macptr = mac_addr;
-
- for (j=0; j<MAC_ADDR_LEN; j++)
- {
- AtoH(macptr, &pAd->PermanentAddress[j], 1);
- macptr=macptr+3;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from module parameter \n"));
- }
-
-
- {
-#if 0
- USHORT Addr01,Addr23,Addr45 ;
-
- Addr01=RTMP_EEPROM_READ16(pAd, 0x04);
- Addr23=RTMP_EEPROM_READ16(pAd, 0x06);
- Addr45=RTMP_EEPROM_READ16(pAd, 0x08);
-
- pAd->PermanentAddress[0] = (UCHAR)(Addr01 & 0xff);
- pAd->PermanentAddress[1] = (UCHAR)(Addr01 >> 8);
- pAd->PermanentAddress[2] = (UCHAR)(Addr23 & 0xff);
- pAd->PermanentAddress[3] = (UCHAR)(Addr23 >> 8);
- pAd->PermanentAddress[4] = (UCHAR)(Addr45 & 0xff);
- pAd->PermanentAddress[5] = (UCHAR)(Addr45 >> 8);
-#endif
- //more conveninet to test mbssid, so ap's bssid &0xf1
- if (pAd->PermanentAddress[0] == 0xff)
- pAd->PermanentAddress[0] = RandomByte(pAd)&0xf8;
-
- //if (pAd->PermanentAddress[5] == 0xff)
- // pAd->PermanentAddress[5] = RandomByte(pAd)&0xf8;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->PermanentAddress[0], pAd->PermanentAddress[1],
- pAd->PermanentAddress[2], pAd->PermanentAddress[3],
- pAd->PermanentAddress[4], pAd->PermanentAddress[5]));
- if (pAd->bLocalAdminMAC == FALSE)
- {
- MAC_DW0_STRUC csr2;
- MAC_DW1_STRUC csr3;
- COPY_MAC_ADDR(pAd->CurrentAddress, pAd->PermanentAddress);
- csr2.field.Byte0 = pAd->CurrentAddress[0];
- csr2.field.Byte1 = pAd->CurrentAddress[1];
- csr2.field.Byte2 = pAd->CurrentAddress[2];
- csr2.field.Byte3 = pAd->CurrentAddress[3];
- RTMP_IO_WRITE32(pAd, MAC_ADDR_DW0, csr2.word);
- csr3.word = 0;
- csr3.field.Byte4 = pAd->CurrentAddress[4];
- csr3.field.Byte5 = pAd->CurrentAddress[5];
- csr3.field.U2MeMask = 0xff;
- RTMP_IO_WRITE32(pAd, MAC_ADDR_DW1, csr3.word);
- DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->PermanentAddress[0], pAd->PermanentAddress[1],
- pAd->PermanentAddress[2], pAd->PermanentAddress[3],
- pAd->PermanentAddress[4], pAd->PermanentAddress[5]));
- }
- }
-
- // if not return early. cause fail at emulation.
- // Init the channel number for TX channel power
- RTMPReadChannelPwr(pAd);
-
- // if E2PROM version mismatch with driver's expectation, then skip
- // all subsequent E2RPOM retieval and set a system error bit to notify GUI
- RT28xx_EEPROM_READ16(pAd, EEPROM_VERSION_OFFSET, Version.word);
- pAd->EepromVersion = Version.field.Version + Version.field.FaeReleaseNumber * 256;
- DBGPRINT(RT_DEBUG_TRACE, ("E2PROM: Version = %d, FAE release #%d\n", Version.field.Version, Version.field.FaeReleaseNumber));
-
- if (Version.field.Version > VALID_EEPROM_VERSION)
- {
- DBGPRINT_ERR(("E2PROM: WRONG VERSION 0x%x, should be %d\n",Version.field.Version, VALID_EEPROM_VERSION));
- /*pAd->SystemErrorBitmap |= 0x00000001;
-
- // hard-code default value when no proper E2PROM installed
- pAd->bAutoTxAgcA = FALSE;
- pAd->bAutoTxAgcG = FALSE;
-
- // Default the channel power
- for (i = 0; i < MAX_NUM_OF_CHANNELS; i++)
- pAd->TxPower[i].Power = DEFAULT_RF_TX_POWER;
-
- // Default the channel power
- for (i = 0; i < MAX_NUM_OF_11JCHANNELS; i++)
- pAd->TxPower11J[i].Power = DEFAULT_RF_TX_POWER;
-
- for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++)
- pAd->EEPROMDefaultValue[i] = 0xffff;
- return; */
- }
-
- // Read BBP default value from EEPROM and store to array(EEPROMDefaultValue) in pAd
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, value);
- pAd->EEPROMDefaultValue[0] = value;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC2_OFFSET, value);
- pAd->EEPROMDefaultValue[1] = value;
-
- RT28xx_EEPROM_READ16(pAd, 0x38, value); // Country Region
- pAd->EEPROMDefaultValue[2] = value;
-
- for(i = 0; i < 8; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_BBP_BASE_OFFSET + i*2, value);
- pAd->EEPROMDefaultValue[i+3] = value;
- }
-
- // We have to parse NIC configuration 0 at here.
- // If TSSI did not have preloaded value, it should reset the TxAutoAgc to false
- // Therefore, we have to read TxAutoAgc control beforehand.
- // Read Tx AGC control bit
- Antenna.word = pAd->EEPROMDefaultValue[0];
- if (Antenna.word == 0xFFFF)
- {
- Antenna.word = 0;
- Antenna.field.RfIcType = RFIC_2820;
- Antenna.field.TxPath = 1;
- Antenna.field.RxPath = 2;
- DBGPRINT(RT_DEBUG_WARN, ("E2PROM error, hard code as 0x%04x\n", Antenna.word));
- }
-
- // Choose the desired Tx&Rx stream.
- if ((pAd->CommonCfg.TxStream == 0) || (pAd->CommonCfg.TxStream > Antenna.field.TxPath))
- pAd->CommonCfg.TxStream = Antenna.field.TxPath;
-
- if ((pAd->CommonCfg.RxStream == 0) || (pAd->CommonCfg.RxStream > Antenna.field.RxPath))
- {
- pAd->CommonCfg.RxStream = Antenna.field.RxPath;
-
- if ((pAd->MACVersion < RALINK_2883_VERSION) &&
- (pAd->CommonCfg.RxStream > 2))
- {
- // only 2 Rx streams for RT2860 series
- pAd->CommonCfg.RxStream = 2;
- }
- }
-
- // 3*3
- // read value from EEPROM and set them to CSR174 ~ 177 in chain0 ~ chain2
- // yet implement
- for(i=0; i<3; i++)
- {
- }
-
- NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NicConfig2.word = 0;
- if ((NicConfig2.word & 0x00ff) == 0xff)
- {
- NicConfig2.word &= 0xff00;
- }
-
- if ((NicConfig2.word >> 8) == 0xff)
- {
- NicConfig2.word &= 0x00ff;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (NicConfig2.field.DynamicTxAgcControl == 1)
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
- else
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("NICReadEEPROMParameters: RxPath = %d, TxPath = %d\n", Antenna.field.RxPath, Antenna.field.TxPath));
-
- // Save the antenna for future use
- pAd->Antenna.word = Antenna.word;
-
- //
- // Reset PhyMode if we don't support 802.11a
- // Only RFIC_2850 & RFIC_2750 support 802.11a
- //
- if ((Antenna.field.RfIcType != RFIC_2850) && (Antenna.field.RfIcType != RFIC_2750))
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11A))
- pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;
-#ifdef DOT11_N_SUPPORT
- else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11N_5G))
- pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED;
-#endif // DOT11_N_SUPPORT //
- }
-
- // Read TSSI reference and TSSI boundary for temperature compensation. This is ugly
- // 0. 11b/g
- {
- /* these are tempature reference value (0x00 ~ 0xFE)
- ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- TssiPlusBoundaryG [4] [3] [2] [1] [0] (smaller) +
- TssiMinusBoundaryG[0] [1] [2] [3] [4] (larger) */
- RT28xx_EEPROM_READ16(pAd, 0x6E, Power.word);
- pAd->TssiMinusBoundaryG[4] = Power.field.Byte0;
- pAd->TssiMinusBoundaryG[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x70, Power.word);
- pAd->TssiMinusBoundaryG[2] = Power.field.Byte0;
- pAd->TssiMinusBoundaryG[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x72, Power.word);
- pAd->TssiRefG = Power.field.Byte0; /* reference value [0] */
- pAd->TssiPlusBoundaryG[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x74, Power.word);
- pAd->TssiPlusBoundaryG[2] = Power.field.Byte0;
- pAd->TssiPlusBoundaryG[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x76, Power.word);
- pAd->TssiPlusBoundaryG[4] = Power.field.Byte0;
- pAd->TxAgcStepG = Power.field.Byte1;
- pAd->TxAgcCompensateG = 0;
- pAd->TssiMinusBoundaryG[0] = pAd->TssiRefG;
- pAd->TssiPlusBoundaryG[0] = pAd->TssiRefG;
-
- // Disable TxAgc if the based value is not right
- if (pAd->TssiRefG == 0xff)
- pAd->bAutoTxAgcG = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE,("E2PROM: G Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n",
- pAd->TssiMinusBoundaryG[4], pAd->TssiMinusBoundaryG[3], pAd->TssiMinusBoundaryG[2], pAd->TssiMinusBoundaryG[1],
- pAd->TssiRefG,
- pAd->TssiPlusBoundaryG[1], pAd->TssiPlusBoundaryG[2], pAd->TssiPlusBoundaryG[3], pAd->TssiPlusBoundaryG[4],
- pAd->TxAgcStepG, pAd->bAutoTxAgcG));
- }
- // 1. 11a
- {
- RT28xx_EEPROM_READ16(pAd, 0xD4, Power.word);
- pAd->TssiMinusBoundaryA[4] = Power.field.Byte0;
- pAd->TssiMinusBoundaryA[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xD6, Power.word);
- pAd->TssiMinusBoundaryA[2] = Power.field.Byte0;
- pAd->TssiMinusBoundaryA[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xD8, Power.word);
- pAd->TssiRefA = Power.field.Byte0;
- pAd->TssiPlusBoundaryA[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xDA, Power.word);
- pAd->TssiPlusBoundaryA[2] = Power.field.Byte0;
- pAd->TssiPlusBoundaryA[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xDC, Power.word);
- pAd->TssiPlusBoundaryA[4] = Power.field.Byte0;
- pAd->TxAgcStepA = Power.field.Byte1;
- pAd->TxAgcCompensateA = 0;
- pAd->TssiMinusBoundaryA[0] = pAd->TssiRefA;
- pAd->TssiPlusBoundaryA[0] = pAd->TssiRefA;
-
- // Disable TxAgc if the based value is not right
- if (pAd->TssiRefA == 0xff)
- pAd->bAutoTxAgcA = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE,("E2PROM: A Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n",
- pAd->TssiMinusBoundaryA[4], pAd->TssiMinusBoundaryA[3], pAd->TssiMinusBoundaryA[2], pAd->TssiMinusBoundaryA[1],
- pAd->TssiRefA,
- pAd->TssiPlusBoundaryA[1], pAd->TssiPlusBoundaryA[2], pAd->TssiPlusBoundaryA[3], pAd->TssiPlusBoundaryA[4],
- pAd->TxAgcStepA, pAd->bAutoTxAgcA));
- }
- pAd->BbpRssiToDbmDelta = 0x0;
-
- // Read frequency offset setting for RF
- RT28xx_EEPROM_READ16(pAd, EEPROM_FREQ_OFFSET, value);
- if ((value & 0x00FF) != 0x00FF)
- pAd->RfFreqOffset = (ULONG) (value & 0x00FF);
- else
- pAd->RfFreqOffset = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("E2PROM: RF FreqOffset=0x%lx \n", pAd->RfFreqOffset));
-
- //CountryRegion byte offset (38h)
- value = pAd->EEPROMDefaultValue[2] >> 8; // 2.4G band
- value2 = pAd->EEPROMDefaultValue[2] & 0x00FF; // 5G band
-
- if ((value <= REGION_MAXIMUM_BG_BAND) && (value2 <= REGION_MAXIMUM_A_BAND))
- {
- pAd->CommonCfg.CountryRegion = ((UCHAR) value) | 0x80;
- pAd->CommonCfg.CountryRegionForABand = ((UCHAR) value2) | 0x80;
- TmpPhy = pAd->CommonCfg.PhyMode;
- pAd->CommonCfg.PhyMode = 0xff;
- RTMPSetPhyMode(pAd, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
-
- //
- // Get RSSI Offset on EEPROM 0x9Ah & 0x9Ch.
- // The valid value are (-10 ~ 10)
- //
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, value);
- pAd->BGRssiOffset0 = value & 0x00ff;
- pAd->BGRssiOffset1 = (value >> 8);
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET+2, value);
- pAd->BGRssiOffset2 = value & 0x00ff;
- pAd->ALNAGain1 = (value >> 8);
- RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, value);
- pAd->BLNAGain = value & 0x00ff;
- pAd->ALNAGain0 = (value >> 8);
-
- // Validate 11b/g RSSI_0 offset.
- if ((pAd->BGRssiOffset0 < -10) || (pAd->BGRssiOffset0 > 10))
- pAd->BGRssiOffset0 = 0;
-
- // Validate 11b/g RSSI_1 offset.
- if ((pAd->BGRssiOffset1 < -10) || (pAd->BGRssiOffset1 > 10))
- pAd->BGRssiOffset1 = 0;
-
- // Validate 11b/g RSSI_2 offset.
- if ((pAd->BGRssiOffset2 < -10) || (pAd->BGRssiOffset2 > 10))
- pAd->BGRssiOffset2 = 0;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, value);
- pAd->ARssiOffset0 = value & 0x00ff;
- pAd->ARssiOffset1 = (value >> 8);
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET+2), value);
- pAd->ARssiOffset2 = value & 0x00ff;
- pAd->ALNAGain2 = (value >> 8);
-
- if (((UCHAR)pAd->ALNAGain1 == 0xFF) || (pAd->ALNAGain1 == 0x00))
- pAd->ALNAGain1 = pAd->ALNAGain0;
- if (((UCHAR)pAd->ALNAGain2 == 0xFF) || (pAd->ALNAGain2 == 0x00))
- pAd->ALNAGain2 = pAd->ALNAGain0;
-
- // Validate 11a RSSI_0 offset.
- if ((pAd->ARssiOffset0 < -10) || (pAd->ARssiOffset0 > 10))
- pAd->ARssiOffset0 = 0;
-
- // Validate 11a RSSI_1 offset.
- if ((pAd->ARssiOffset1 < -10) || (pAd->ARssiOffset1 > 10))
- pAd->ARssiOffset1 = 0;
-
- //Validate 11a RSSI_2 offset.
- if ((pAd->ARssiOffset2 < -10) || (pAd->ARssiOffset2 > 10))
- pAd->ARssiOffset2 = 0;
-
- //
- // Get LED Setting.
- //
- RT28xx_EEPROM_READ16(pAd, 0x3a, value);
- pAd->LedCntl.word = (value&0xff00) >> 8;
- RT28xx_EEPROM_READ16(pAd, EEPROM_LED1_OFFSET, value);
- pAd->Led1 = value;
- RT28xx_EEPROM_READ16(pAd, EEPROM_LED2_OFFSET, value);
- pAd->Led2 = value;
- RT28xx_EEPROM_READ16(pAd, EEPROM_LED3_OFFSET, value);
- pAd->Led3 = value;
-
- RTMPReadTxPwrPerRate(pAd);
-
-#ifdef SINGLE_SKU
- //pAd->CommonCfg.DefineMaxTxPwr = RTMP_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR);
- RT28xx_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR, pAd->CommonCfg.DefineMaxTxPwr);
-#endif // SINGLE_SKU //
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set default value from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID NICInitAsicFromEEPROM(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef CONFIG_STA_SUPPORT
- UINT32 data = 0;
- UCHAR BBPR1 = 0;
-#endif // CONFIG_STA_SUPPORT //
- USHORT i;
- EEPROM_ANTENNA_STRUC Antenna;
- EEPROM_NIC_CONFIG2_STRUC NicConfig2;
- UCHAR BBPR3 = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitAsicFromEEPROM\n"));
- for(i = 3; i < NUM_EEPROM_BBP_PARMS; i++)
- {
- UCHAR BbpRegIdx, BbpValue;
-
- if ((pAd->EEPROMDefaultValue[i] != 0xFFFF) && (pAd->EEPROMDefaultValue[i] != 0))
- {
- BbpRegIdx = (UCHAR)(pAd->EEPROMDefaultValue[i] >> 8);
- BbpValue = (UCHAR)(pAd->EEPROMDefaultValue[i] & 0xff);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BbpRegIdx, BbpValue);
- }
- }
-
- Antenna.word = pAd->Antenna.word;
- pAd->Mlme.RealRxPath = (UCHAR) Antenna.field.RxPath;
- pAd->RfIcType = (UCHAR) Antenna.field.RfIcType;
-
- NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-
- // Save the antenna for future use
- pAd->NicConfig2.word = NicConfig2.word;
-
- //
- // Send LED Setting to MCU.
- //
- if (pAd->LedCntl.word == 0xFF)
- {
- pAd->LedCntl.word = 0x01;
- pAd->Led1 = 0x5555;
- pAd->Led2 = 0x2221;
-
-#ifdef RT2870
- pAd->Led3 = 0x5627;
-#endif // RT2870 //
- }
-
- AsicSendCommandToMcu(pAd, 0x52, 0xff, (UCHAR)pAd->Led1, (UCHAR)(pAd->Led1 >> 8));
- AsicSendCommandToMcu(pAd, 0x53, 0xff, (UCHAR)pAd->Led2, (UCHAR)(pAd->Led2 >> 8));
- AsicSendCommandToMcu(pAd, 0x54, 0xff, (UCHAR)pAd->Led3, (UCHAR)(pAd->Led3 >> 8));
- pAd->LedIndicatorStregth = 0xFF;
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, before link up
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Read Hardware controlled Radio state enable bit
- if (NicConfig2.field.HardwareRadioControl == 1)
- {
- pAd->StaCfg.bHardwareRadio = TRUE;
-
- // Read GPIO pin2 as Hardware controlled radio state
- RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data);
- if ((data & 0x04) == 0)
- {
- pAd->StaCfg.bHwRadio = FALSE;
- pAd->StaCfg.bRadio = FALSE;
-// RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818);
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
- }
- }
- else
- pAd->StaCfg.bHardwareRadio = FALSE;
-
- if (pAd->StaCfg.bRadio == FALSE)
- {
- RTMPSetLED(pAd, LED_RADIO_OFF);
- }
- else
- {
- RTMPSetLED(pAd, LED_RADIO_ON);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Turn off patching for cardbus controller
- if (NicConfig2.field.CardbusAcceleration == 1)
- {
-// pAd->bTest1 = TRUE;
- }
-
- if (NicConfig2.field.DynamicTxAgcControl == 1)
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
- else
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
- //
- // Since BBP has been progamed, to make sure BBP setting will be
- // upate inside of AsicAntennaSelect, so reset to UNKNOWN_BAND!!
- //
- pAd->CommonCfg.BandState = UNKNOWN_BAND;
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
- BBPR3 &= (~0x18);
- if(pAd->Antenna.field.RxPath == 3)
- {
- BBPR3 |= (0x10);
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- BBPR3 |= (0x8);
- }
- else if(pAd->Antenna.field.RxPath == 1)
- {
- BBPR3 |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Handle the difference when 1T
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BBPR1);
- if(pAd->Antenna.field.TxPath == 1)
- {
- BBPR1 &= (~0x18);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BBPR1);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n", pAd->CommonCfg.bHardwareRadio, pAd->CommonCfg.bHardwareRadio));
- }
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("TxPath = %d, RxPath = %d, RFIC=%d, Polar+LED mode=%x\n", pAd->Antenna.field.TxPath, pAd->Antenna.field.RxPath, pAd->RfIcType, pAd->LedCntl.word));
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitAsicFromEEPROM\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Initialize NIC hardware
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS NICInitializeAdapter(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset)
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- WPDMA_GLO_CFG_STRUC GloCfg;
-// INT_MASK_CSR_STRUC IntMask;
- ULONG i =0, j=0;
- AC_TXOP_CSR0_STRUC csr0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAdapter\n"));
-
- // 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits:
-retry:
- i = 0;
- do
- {
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
- if ((GloCfg.field.TxDMABusy == 0) && (GloCfg.field.RxDMABusy == 0))
- break;
-
- RTMPusecDelay(1000);
- i++;
- }while ( i<100);
- DBGPRINT(RT_DEBUG_TRACE, ("<== DMA offset 0x208 = 0x%x\n", GloCfg.word));
- GloCfg.word &= 0xff0;
- GloCfg.field.EnTXWriteBackDDONE =1;
- RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
- // Record HW Beacon offset
- pAd->BeaconOffset[0] = HW_BEACON_BASE0;
- pAd->BeaconOffset[1] = HW_BEACON_BASE1;
- pAd->BeaconOffset[2] = HW_BEACON_BASE2;
- pAd->BeaconOffset[3] = HW_BEACON_BASE3;
- pAd->BeaconOffset[4] = HW_BEACON_BASE4;
- pAd->BeaconOffset[5] = HW_BEACON_BASE5;
- pAd->BeaconOffset[6] = HW_BEACON_BASE6;
- pAd->BeaconOffset[7] = HW_BEACON_BASE7;
-
- //
- // write all shared Ring's base address into ASIC
- //
-
- // asic simulation sequence put this ahead before loading firmware.
- // pbf hardware reset
-
- // Initialze ASIC for TX & Rx operation
- if (NICInitializeAsic(pAd , bHardReset) != NDIS_STATUS_SUCCESS)
- {
- if (j++ == 0)
- {
- NICLoadFirmware(pAd);
- goto retry;
- }
- return NDIS_STATUS_FAILURE;
- }
-
-
-
-
- // WMM parameter
- csr0.word = 0;
- RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- {
- csr0.field.Ac0Txop = 192; // AC_VI: 192*32us ~= 6ms
- csr0.field.Ac1Txop = 96; // AC_VO: 96*32us ~= 3ms
- }
- else
- {
- csr0.field.Ac0Txop = 96; // AC_VI: 96*32us ~= 3ms
- csr0.field.Ac1Txop = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word);
-
-
-
-
- // reset action
- // Load firmware
- // Status = NICLoadFirmware(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAdapter\n"));
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Initialize ASIC
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS NICInitializeAsic(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset)
-{
- ULONG Index = 0;
- UCHAR R0 = 0xff;
- UINT32 MacCsr12 = 0, Counter = 0;
-#ifdef RT2870
- UINT32 MacCsr0 = 0;
- NTSTATUS Status;
- UCHAR Value = 0xff;
-#endif // RT2870 //
- USHORT KeyIdx;
- INT i,apidx;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n"));
-
-
-#ifdef RT2870
- //
- // Make sure MAC gets ready after NICLoadFirmware().
- //
- Index = 0;
-
- //To avoid hang-on issue when interface up in kernel 2.4,
- //we use a local variable "MacCsr0" instead of using "pAd->MACVersion" directly.
- do
- {
- RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-
- if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF))
- break;
-
- RTMPusecDelay(10);
- } while (Index++ < 100);
-
- pAd->MACVersion = MacCsr0;
- DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
- // turn on bit13 (set to zero) after rt2860D. This is to solve high-current issue.
- RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacCsr12);
- MacCsr12 &= (~0x2000);
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, MacCsr12);
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
- RTMP_IO_WRITE32(pAd, USB_DMA_CFG, 0x0);
- Status = RTUSBVenderReset(pAd);
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-
- // Initialize MAC register to default value
- for(Index=0; Index<NUM_MAC_REG_PARMS; Index++)
- {
- RTMP_IO_WRITE32(pAd, (USHORT)MACRegTable[Index].Register, MACRegTable[Index].Value);
- }
-
- if(IS_RT3070(pAd))
- {
- // According to Frank Hsu (from Gary Tsao)
- RTMP_IO_WRITE32(pAd, (USHORT)TX_SW_CFG0, 0x00000400);
-
- // Initialize RT3070 serial MAC registers which is different from RT2870 serial
- RTUSBWriteMACRegister(pAd, TX_SW_CFG1, 0);
- RTUSBWriteMACRegister(pAd, TX_SW_CFG2, 0);
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++)
- {
- RTMP_IO_WRITE32(pAd, (USHORT)STAMACRegTable[Index].Register, STAMACRegTable[Index].Value);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
-
- //
- // Before program BBP, we need to wait BBP/RF get wake up.
- //
- Index = 0;
- do
- {
- RTMP_IO_READ32(pAd, MAC_STATUS_CFG, &MacCsr12);
-
- if ((MacCsr12 & 0x03) == 0) // if BB.RF is stable
- break;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Check MAC_STATUS_CFG = Busy = %x\n", MacCsr12));
- RTMPusecDelay(1000);
- } while (Index++ < 100);
-
- // The commands to firmware should be after these commands, these commands will init firmware
- // PCI and USB are not the same because PCI driver needs to wait for PCI bus ready
- RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0); // initialize BBP R/W access agent
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
- RTMPusecDelay(1000);
-
- // Read BBP register, make sure BBP is up and running before write new data
- Index = 0;
- do
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R0, &R0);
- DBGPRINT(RT_DEBUG_TRACE, ("BBP version = %x\n", R0));
- } while ((++Index < 20) && ((R0 == 0xff) || (R0 == 0x00)));
- //ASSERT(Index < 20); //this will cause BSOD on Check-build driver
-
- if ((R0 == 0xff) || (R0 == 0x00))
- return NDIS_STATUS_FAILURE;
-
- // Initialize BBP register to default value
- for (Index = 0; Index < NUM_BBP_REG_PARMS; Index++)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, BBPRegTable[Index].Value);
- }
-
- // for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT.
- if ((pAd->MACVersion&0xffff) != 0x0101)
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
-
-#ifdef RT2870
- //write RT3070 BBP wchich different with 2870 after write RT2870 BBP
- if (IS_RT3070(pAd))
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0a);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x99);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R105, 0x05);
- }
-#endif // RT2870 //
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x12);
- }
-
- if (pAd->MACVersion >= RALINK_2880E_VERSION && pAd->MACVersion < RALINK_3070_VERSION) // 3*3
- {
- // enlarge MAX_LEN_CFG
- UINT32 csr;
- RTMP_IO_READ32(pAd, MAX_LEN_CFG, &csr);
- csr &= 0xFFF;
- csr |= 0x2000;
- RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, csr);
- }
-
-#ifdef RT2870
-{
- UCHAR MAC_Value[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0,0};
-
- //Initialize WCID table
- Value = 0xff;
- for(Index =0 ;Index < 254;Index++)
- {
- RTUSBMultiWrite(pAd, (USHORT)(MAC_WCID_BASE + Index * 8), MAC_Value, 8);
- }
-}
-#endif // RT2870 //
-
- // Add radio off control
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.bRadio == FALSE)
- {
-// RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818);
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
- DBGPRINT(RT_DEBUG_TRACE, ("Set Radio Off\n"));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Clear raw counters
- RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
-
- // ASIC will keep garbage value after boot
- // Clear all seared key table when initial
- // This routine can be ignored in radio-ON/OFF operation.
- if (bHardReset)
- {
- for (KeyIdx = 0; KeyIdx < 4; KeyIdx++)
- {
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4*KeyIdx, 0);
- }
-
- // Clear all pairwise key table when initial
- for (KeyIdx = 0; KeyIdx < 256; KeyIdx++)
- {
- RTMP_IO_WRITE32(pAd, MAC_WCID_ATTRIBUTE_BASE + (KeyIdx * HW_WCID_ATTRI_SIZE), 1);
- }
- }
-
- // assert HOST ready bit
-// RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x0); // 2004-09-14 asked by Mark
-// RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x4);
-
- // It isn't necessary to clear this space when not hard reset.
- if (bHardReset == TRUE)
- {
- // clear all on-chip BEACON frame space
- for (apidx = 0; apidx < HW_BEACON_MAX_COUNT; apidx++)
- {
- for (i = 0; i < HW_BEACON_OFFSET>>2; i+=4)
- RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[apidx] + i, 0x00);
- }
- }
-#ifdef RT2870
- AsicDisableSync(pAd);
- // Clear raw counters
- RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
- // Default PCI clock cycle per ms is different as default setting, which is based on PCI.
- RTMP_IO_READ32(pAd, USB_CYC_CFG, &Counter);
- Counter&=0xffffff00;
- Counter|=0x000001e;
- RTMP_IO_WRITE32(pAd, USB_CYC_CFG, Counter);
-#endif // RT2870 //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // for rt2860E and after, init TXOP_CTRL_CFG with 0x583f. This is for extension channel overlapping IOT.
- if ((pAd->MACVersion&0xffff) != 0x0101)
- RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x583f);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAsic\n"));
- return NDIS_STATUS_SUCCESS;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Reset NIC Asics
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
- Reset NIC to initial state AS IS system boot up time.
-
- ========================================================================
-*/
-VOID NICIssueReset(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 Value = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICIssueReset\n"));
-
- // Abort Tx, prevent ASIC from writing to Host memory
- //RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x001f0000);
-
- // Disable Rx, register value supposed will remain after reset
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= (0xfffffff3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Issue reset and clear from reset state
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x03); // 2004-09-17 change from 0x01
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x00);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICIssueReset\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check ASIC registers and find any reason the system might hang
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-BOOLEAN NICCheckForHang(
- IN PRTMP_ADAPTER pAd)
-{
- return (FALSE);
-}
-
-VOID NICUpdateFifoStaCounters(
- IN PRTMP_ADAPTER pAd)
-{
- TX_STA_FIFO_STRUC StaFifo;
- MAC_TABLE_ENTRY *pEntry;
- UCHAR i = 0;
- UCHAR pid = 0, wcid = 0;
- CHAR reTry;
- UCHAR succMCS;
-
-#ifdef RALINK_ATE
- /* Nothing to do in ATE mode */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- do
- {
- RTMP_IO_READ32(pAd, TX_STA_FIFO, &StaFifo.word);
-
- if (StaFifo.field.bValid == 0)
- break;
-
- wcid = (UCHAR)StaFifo.field.wcid;
-
-
- /* ignore NoACK and MGMT frame use 0xFF as WCID */
- if ((StaFifo.field.TxAckRequired == 0) || (wcid >= MAX_LEN_OF_MAC_TABLE))
- {
- i++;
- continue;
- }
-
- /* PID store Tx MCS Rate */
- pid = (UCHAR)StaFifo.field.PidType;
-
- pEntry = &pAd->MacTab.Content[wcid];
-
- pEntry->DebugFIFOCount++;
-
-#ifdef DOT11_N_SUPPORT
- if (StaFifo.field.TxBF) // 3*3
- pEntry->TxBFCount++;
-#endif // DOT11_N_SUPPORT //
-
-#ifdef UAPSD_AP_SUPPORT
- UAPSD_SP_AUE_Handle(pAd, pEntry, StaFifo.field.TxSuccess);
-#endif // UAPSD_AP_SUPPORT //
-
- if (!StaFifo.field.TxSuccess)
- {
- pEntry->FIFOCount++;
- pEntry->OneSecTxFailCount++;
-
- if (pEntry->FIFOCount >= 1)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("#"));
-#if 0
- SendRefreshBAR(pAd, pEntry);
- pEntry->NoBADataCountDown = 64;
-#else
-#ifdef DOT11_N_SUPPORT
- pEntry->NoBADataCountDown = 64;
-#endif // DOT11_N_SUPPORT //
-
- if(pEntry->PsMode == PWR_ACTIVE)
- {
-#ifdef DOT11_N_SUPPORT
- int tid;
- for (tid=0; tid<NUM_OF_TID; tid++)
- {
- BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
- // Update the continuous transmission counter except PS mode
- pEntry->ContinueTxFailCnt++;
- }
- else
- {
- // Clear the FIFOCount when sta in Power Save mode. Basically we assume
- // this tx error happened due to sta just go to sleep.
- pEntry->FIFOCount = 0;
- pEntry->ContinueTxFailCnt = 0;
- }
-#endif
- //pEntry->FIFOCount = 0;
- }
- //pEntry->bSendBAR = TRUE;
- }
- else
- {
-#ifdef DOT11_N_SUPPORT
- if ((pEntry->PsMode != PWR_SAVE) && (pEntry->NoBADataCountDown > 0))
- {
- pEntry->NoBADataCountDown--;
- if (pEntry->NoBADataCountDown==0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("@\n"));
- }
- }
-#endif // DOT11_N_SUPPORT //
- pEntry->FIFOCount = 0;
- pEntry->OneSecTxNoRetryOkCount++;
- // update NoDataIdleCount when sucessful send packet to STA.
- pEntry->NoDataIdleCount = 0;
- pEntry->ContinueTxFailCnt = 0;
- }
-
- succMCS = StaFifo.field.SuccessRate & 0x7F;
-
- reTry = pid - succMCS;
-
- if (StaFifo.field.TxSuccess)
- {
- pEntry->TXMCSExpected[pid]++;
- if (pid == succMCS)
- {
- pEntry->TXMCSSuccessful[pid]++;
- }
- else
- {
- pEntry->TXMCSAutoFallBack[pid][succMCS]++;
- }
- }
- else
- {
- pEntry->TXMCSFailed[pid]++;
- }
-
- if (reTry > 0)
- {
- if ((pid >= 12) && succMCS <=7)
- {
- reTry -= 4;
- }
- pEntry->OneSecTxRetryOkCount += reTry;
- }
-
- i++;
- // ASIC store 16 stack
- } while ( i < (2*TX_RING_SIZE) );
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Read statistical counters from hardware registers and record them
- in software variables for later on query
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID NICUpdateRawCounters(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 OldValue;
- RX_STA_CNT0_STRUC RxStaCnt0;
- RX_STA_CNT1_STRUC RxStaCnt1;
- RX_STA_CNT2_STRUC RxStaCnt2;
- TX_STA_CNT0_STRUC TxStaCnt0;
- TX_STA_CNT1_STRUC StaTx1;
- TX_STA_CNT2_STRUC StaTx2;
- TX_AGG_CNT_STRUC TxAggCnt;
- TX_AGG_CNT0_STRUC TxAggCnt0;
- TX_AGG_CNT1_STRUC TxAggCnt1;
- TX_AGG_CNT2_STRUC TxAggCnt2;
- TX_AGG_CNT3_STRUC TxAggCnt3;
- TX_AGG_CNT4_STRUC TxAggCnt4;
- TX_AGG_CNT5_STRUC TxAggCnt5;
- TX_AGG_CNT6_STRUC TxAggCnt6;
- TX_AGG_CNT7_STRUC TxAggCnt7;
-
-
- RTMP_IO_READ32(pAd, RX_STA_CNT0, &RxStaCnt0.word);
- RTMP_IO_READ32(pAd, RX_STA_CNT2, &RxStaCnt2.word);
-
- {
- RTMP_IO_READ32(pAd, RX_STA_CNT1, &RxStaCnt1.word);
- // Update RX PLCP error counter
- pAd->PrivateInfo.PhyRxErrCnt += RxStaCnt1.field.PlcpErr;
- // Update False CCA counter
- pAd->RalinkCounters.OneSecFalseCCACnt += RxStaCnt1.field.FalseCca;
- }
-
- // Update FCS counters
- OldValue= pAd->WlanCounters.FCSErrorCount.u.LowPart;
- pAd->WlanCounters.FCSErrorCount.u.LowPart += (RxStaCnt0.field.CrcErr); // >> 7);
- if (pAd->WlanCounters.FCSErrorCount.u.LowPart < OldValue)
- pAd->WlanCounters.FCSErrorCount.u.HighPart++;
-
- // Add FCS error count to private counters
- pAd->RalinkCounters.OneSecRxFcsErrCnt += RxStaCnt0.field.CrcErr;
- OldValue = pAd->RalinkCounters.RealFcsErrCount.u.LowPart;
- pAd->RalinkCounters.RealFcsErrCount.u.LowPart += RxStaCnt0.field.CrcErr;
- if (pAd->RalinkCounters.RealFcsErrCount.u.LowPart < OldValue)
- pAd->RalinkCounters.RealFcsErrCount.u.HighPart++;
-
- // Update Duplicate Rcv check
- pAd->RalinkCounters.DuplicateRcv += RxStaCnt2.field.RxDupliCount;
- pAd->WlanCounters.FrameDuplicateCount.u.LowPart += RxStaCnt2.field.RxDupliCount;
- // Update RX Overflow counter
- pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount);
-
- //pAd->RalinkCounters.RxCount = 0;
-#ifdef RT2870
- if (pAd->RalinkCounters.RxCount != pAd->watchDogRxCnt)
- {
- pAd->watchDogRxCnt = pAd->RalinkCounters.RxCount;
- pAd->watchDogRxOverFlowCnt = 0;
- }
- else
- {
- if (RxStaCnt2.field.RxFifoOverflowCount)
- pAd->watchDogRxOverFlowCnt++;
- else
- pAd->watchDogRxOverFlowCnt = 0;
- }
-#endif // RT2870 //
-
-
- //if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) ||
- // (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) && (pAd->MacTab.Size != 1)))
- if (!pAd->bUpdateBcnCntDone)
- {
- // Update BEACON sent count
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT2, &StaTx2.word);
- pAd->RalinkCounters.OneSecBeaconSentCnt += TxStaCnt0.field.TxBeaconCount;
- pAd->RalinkCounters.OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
- pAd->RalinkCounters.OneSecTxFailCount += TxStaCnt0.field.TxFailCount;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
- pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
- pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
- }
-
-#if 0
- Retry = StaTx1.field.TxRetransmit;
- Fail = TxStaCnt0.field.TxFailCount;
- TxErrorRatio = 0;
- OneSecTransmitCount = pAd->WlanCounters.TransmittedFragmentCount.u.LowPart- pAd->WlanCounters.LastTransmittedFragmentCount.u.LowPart;
- if ((OneSecTransmitCount+Retry + Fail) > 0)
- TxErrorRatio = (( Retry + Fail) *100) / (OneSecTransmitCount+Retry + Fail);
-
- if ((OneSecTransmitCount+Retry + Fail) > 0)
- TxErrorRatio = (( Retry + Fail) *100) / (OneSecTransmitCount+Retry + Fail);
- DBGPRINT(RT_DEBUG_INFO, ("TX ERROR Rate = %ld %%, Retry = %ld, Fail = %ld, Total = %ld \n",TxErrorRatio, Retry, Fail, (OneSecTransmitCount+Retry + Fail)));
- pAd->WlanCounters.LastTransmittedFragmentCount.u.LowPart = pAd->WlanCounters.TransmittedFragmentCount.u.LowPart;
-#endif
-
- //if (pAd->bStaFifoTest == TRUE)
- {
- RTMP_IO_READ32(pAd, TX_AGG_CNT, &TxAggCnt.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT0, &TxAggCnt0.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT1, &TxAggCnt1.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT2, &TxAggCnt2.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT3, &TxAggCnt3.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT4, &TxAggCnt4.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT5, &TxAggCnt5.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT6, &TxAggCnt6.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT7, &TxAggCnt7.word);
- pAd->RalinkCounters.TxAggCount += TxAggCnt.field.AggTxCount;
- pAd->RalinkCounters.TxNonAggCount += TxAggCnt.field.NonAggTxCount;
- pAd->RalinkCounters.TxAgg1MPDUCount += TxAggCnt0.field.AggSize1Count;
- pAd->RalinkCounters.TxAgg2MPDUCount += TxAggCnt0.field.AggSize2Count;
-
- pAd->RalinkCounters.TxAgg3MPDUCount += TxAggCnt1.field.AggSize3Count;
- pAd->RalinkCounters.TxAgg4MPDUCount += TxAggCnt1.field.AggSize4Count;
- pAd->RalinkCounters.TxAgg5MPDUCount += TxAggCnt2.field.AggSize5Count;
- pAd->RalinkCounters.TxAgg6MPDUCount += TxAggCnt2.field.AggSize6Count;
-
- pAd->RalinkCounters.TxAgg7MPDUCount += TxAggCnt3.field.AggSize7Count;
- pAd->RalinkCounters.TxAgg8MPDUCount += TxAggCnt3.field.AggSize8Count;
- pAd->RalinkCounters.TxAgg9MPDUCount += TxAggCnt4.field.AggSize9Count;
- pAd->RalinkCounters.TxAgg10MPDUCount += TxAggCnt4.field.AggSize10Count;
-
- pAd->RalinkCounters.TxAgg11MPDUCount += TxAggCnt5.field.AggSize11Count;
- pAd->RalinkCounters.TxAgg12MPDUCount += TxAggCnt5.field.AggSize12Count;
- pAd->RalinkCounters.TxAgg13MPDUCount += TxAggCnt6.field.AggSize13Count;
- pAd->RalinkCounters.TxAgg14MPDUCount += TxAggCnt6.field.AggSize14Count;
-
- pAd->RalinkCounters.TxAgg15MPDUCount += TxAggCnt7.field.AggSize15Count;
- pAd->RalinkCounters.TxAgg16MPDUCount += TxAggCnt7.field.AggSize16Count;
-
- // Calculate the transmitted A-MPDU count
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += TxAggCnt0.field.AggSize1Count;
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt0.field.AggSize2Count / 2);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt1.field.AggSize3Count / 3);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt1.field.AggSize4Count / 4);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt2.field.AggSize5Count / 5);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt2.field.AggSize6Count / 6);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt3.field.AggSize7Count / 7);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt3.field.AggSize8Count / 8);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt4.field.AggSize9Count / 9);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt4.field.AggSize10Count / 10);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt5.field.AggSize11Count / 11);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt5.field.AggSize12Count / 12);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize13Count / 13);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize14Count / 14);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize15Count / 15);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize16Count / 16);
- }
-
-#ifdef DBG_DIAGNOSE
- {
- RtmpDiagStruct *pDiag;
- COUNTER_RALINK *pRalinkCounters;
- UCHAR ArrayCurIdx, i;
-
- pDiag = &pAd->DiagStruct;
- pRalinkCounters = &pAd->RalinkCounters;
- ArrayCurIdx = pDiag->ArrayCurIdx;
-
- if (pDiag->inited == 0)
- {
- NdisZeroMemory(pDiag, sizeof(struct _RtmpDiagStrcut_));
- pDiag->ArrayStartIdx = pDiag->ArrayCurIdx = 0;
- pDiag->inited = 1;
- }
- else
- {
- // Tx
- pDiag->TxFailCnt[ArrayCurIdx] = TxStaCnt0.field.TxFailCount;
- pDiag->TxAggCnt[ArrayCurIdx] = TxAggCnt.field.AggTxCount;
- pDiag->TxNonAggCnt[ArrayCurIdx] = TxAggCnt.field.NonAggTxCount;
- pDiag->TxAMPDUCnt[ArrayCurIdx][0] = TxAggCnt0.field.AggSize1Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][1] = TxAggCnt0.field.AggSize2Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][2] = TxAggCnt1.field.AggSize3Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][3] = TxAggCnt1.field.AggSize4Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][4] = TxAggCnt2.field.AggSize5Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][5] = TxAggCnt2.field.AggSize6Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][6] = TxAggCnt3.field.AggSize7Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][7] = TxAggCnt3.field.AggSize8Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][8] = TxAggCnt4.field.AggSize9Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][9] = TxAggCnt4.field.AggSize10Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][10] = TxAggCnt5.field.AggSize11Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][11] = TxAggCnt5.field.AggSize12Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][12] = TxAggCnt6.field.AggSize13Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][13] = TxAggCnt6.field.AggSize14Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][14] = TxAggCnt7.field.AggSize15Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][15] = TxAggCnt7.field.AggSize16Count;
-
- pDiag->RxCrcErrCnt[ArrayCurIdx] = RxStaCnt0.field.CrcErr;
-
- INC_RING_INDEX(pDiag->ArrayCurIdx, DIAGNOSE_TIME);
- ArrayCurIdx = pDiag->ArrayCurIdx;
- for (i =0; i < 9; i++)
- {
- pDiag->TxDescCnt[ArrayCurIdx][i]= 0;
- pDiag->TxSWQueCnt[ArrayCurIdx][i] =0;
- pDiag->TxMcsCnt[ArrayCurIdx][i] = 0;
- pDiag->RxMcsCnt[ArrayCurIdx][i] = 0;
- }
- pDiag->TxDataCnt[ArrayCurIdx] = 0;
- pDiag->TxFailCnt[ArrayCurIdx] = 0;
- pDiag->RxDataCnt[ArrayCurIdx] = 0;
- pDiag->RxCrcErrCnt[ArrayCurIdx] = 0;
-// for (i = 9; i < 16; i++)
- for (i = 9; i < 24; i++) // 3*3
- {
- pDiag->TxDescCnt[ArrayCurIdx][i] = 0;
- pDiag->TxMcsCnt[ArrayCurIdx][i] = 0;
- pDiag->RxMcsCnt[ArrayCurIdx][i] = 0;
-}
-
- if (pDiag->ArrayCurIdx == pDiag->ArrayStartIdx)
- INC_RING_INDEX(pDiag->ArrayStartIdx, DIAGNOSE_TIME);
- }
-
- }
-#endif // DBG_DIAGNOSE //
-
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Reset NIC from error
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
- Reset NIC from error state
-
- ========================================================================
-*/
-VOID NICResetFromError(
- IN PRTMP_ADAPTER pAd)
-{
- // Reset BBP (according to alex, reset ASIC will force reset BBP
- // Therefore, skip the reset BBP
- // RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x2);
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
- // Remove ASIC from reset state
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-
- NICInitializeAdapter(pAd, FALSE);
- NICInitAsicFromEEPROM(pAd);
-
- // Switch to current channel, since during reset process, the connection should remains on.
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- erase 8051 firmware image in MAC ASIC
-
- Arguments:
- Adapter Pointer to our adapter
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID NICEraseFirmware(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
-
- for(i=0; i<MAX_FIRMWARE_IMAGE_SIZE; i+=4)
- RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, 0);
-
-}/* End of NICEraseFirmware */
-
-/*
- ========================================================================
-
- Routine Description:
- Load 8051 firmware RT2561.BIN file into MAC ASIC
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- NDIS_STATUS_SUCCESS firmware image load ok
- NDIS_STATUS_FAILURE image not found
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-NDIS_STATUS NICLoadFirmware(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef BIN_IN_FILE
-#define NICLF_DEFAULT_USE() \
- flg_default_firm_use = TRUE; \
- printk("%s - Use default firmware!\n", __func__);
-
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR src;
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid, i;
- mm_segment_t orgfs;
- PUCHAR pFirmwareImage;
- UINT FileLength = 0;
- UINT32 MacReg;
- ULONG Index;
- ULONG firm;
- BOOLEAN flg_default_firm_use = FALSE;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __func__));
-
- /* init */
- pFirmwareImage = NULL;
- src = RTMP_FIRMWARE_FILE_NAME;
-
- /* save uid and gid used for filesystem access.
- set user and group to 0 (root) */
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- pAd->FirmwareVersion = (FIRMWARE_MAJOR_VERSION << 8) + \
- FIRMWARE_MINOR_VERSION;
-
-
- /* allocate firmware buffer */
- pFirmwareImage = kmalloc(MAX_FIRMWARE_IMAGE_SIZE, MEM_ALLOC_FLAG);
- if (pFirmwareImage == NULL)
- {
- /* allocate fail, use default firmware array in firmware.h */
- printk("%s - Allocate memory fail!\n", __func__);
- NICLF_DEFAULT_USE();
- }
- else
- {
- /* allocate ok! zero the firmware buffer */
- memset(pFirmwareImage, 0x00, MAX_FIRMWARE_IMAGE_SIZE);
- } /* End of if */
-
-
- /* if ok, read firmware file from *.bin file */
- if (flg_default_firm_use == FALSE)
- {
- do
- {
- /* open the bin file */
- srcf = filp_open(src, O_RDONLY, 0);
-
- if (IS_ERR(srcf))
- {
- printk("%s - Error %ld opening %s\n",
- __func__, -PTR_ERR(srcf), src);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
-
- /* the object must have a read method */
- if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
- {
- printk("%s - %s does not have a write method\n", __func__, src);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
-
- /* read the firmware from the file *.bin */
- FileLength = srcf->f_op->read(srcf,
- pFirmwareImage,
- MAX_FIRMWARE_IMAGE_SIZE,
- &srcf->f_pos);
-
- if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
- {
- printk("%s: error file length (=%d) in RT2860AP.BIN\n",
- __func__, FileLength);
- NICLF_DEFAULT_USE();
- break;
- }
- else
- {
- PUCHAR ptr = pFirmwareImage;
- USHORT crc = 0xffff;
-
-
- /* calculate firmware CRC */
- for(i=0; i<(MAX_FIRMWARE_IMAGE_SIZE-2); i++, ptr++)
- crc = ByteCRC16(BitReverse(*ptr), crc);
- /* End of for */
-
- if ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2] != \
- (UCHAR)BitReverse((UCHAR)(crc>>8))) ||
- (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1] != \
- (UCHAR)BitReverse((UCHAR)crc)))
- {
- /* CRC fail */
- printk("%s: CRC = 0x%02x 0x%02x "
- "error, should be 0x%02x 0x%02x\n",
- __func__,
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
- (UCHAR)(crc>>8), (UCHAR)(crc));
- NICLF_DEFAULT_USE();
- break;
- }
- else
- {
- /* firmware is ok */
- pAd->FirmwareVersion = \
- (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4] << 8) +
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3];
-
- /* check if firmware version of the file is too old */
- if ((pAd->FirmwareVersion) < \
- ((FIRMWARE_MAJOR_VERSION << 8) +
- FIRMWARE_MINOR_VERSION))
- {
- printk("%s: firmware version too old!\n", __func__);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
- } /* End of if */
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("NICLoadFirmware: CRC ok, ver=%d.%d\n",
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4],
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3]));
- } /* End of if (FileLength == MAX_FIRMWARE_IMAGE_SIZE) */
- break;
- } while(TRUE);
-
- /* close firmware file */
- if (IS_ERR(srcf))
- ;
- else
- {
- retval = filp_close(srcf, NULL);
- if (retval)
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("--> Error %d closing %s\n", -retval, src));
- } /* End of if */
- } /* End of if */
- } /* End of if */
-
-
- /* write firmware to ASIC */
- if (flg_default_firm_use == TRUE)
- {
- /* use default fimeware, free allocated buffer */
- if (pFirmwareImage != NULL)
- kfree(pFirmwareImage);
- /* End of if */
-
- /* use default *.bin array */
- pFirmwareImage = FirmwareImage;
- FileLength = sizeof(FirmwareImage);
- } /* End of if */
-
- /* enable Host program ram write selection */
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x10000);
-
- for(i=0; i<FileLength; i+=4)
- {
- firm = pFirmwareImage[i] +
- (pFirmwareImage[i+3] << 24) +
- (pFirmwareImage[i+2] << 16) +
- (pFirmwareImage[i+1] << 8);
-
- RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, firm);
- } /* End of for */
-
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00000);
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00001);
-
- /* initialize BBP R/W access agent */
- RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0);
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
-
- if (flg_default_firm_use == FALSE)
- {
- /* use file firmware, free allocated buffer */
- if (pFirmwareImage != NULL)
- kfree(pFirmwareImage);
- /* End of if */
- } /* End of if */
-
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
-#else
-
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR pFirmwareImage;
- ULONG FileLength, Index;
- //ULONG firm;
- UINT32 MacReg = 0;
-#ifdef RT2870
- UINT32 Version = (pAd->MACVersion >> 16);
-#endif // RT2870 //
-
- pFirmwareImage = FirmwareImage;
- FileLength = sizeof(FirmwareImage);
-#ifdef RT2870
- // New 8k byte firmware size for RT3071/RT3072
- //printk("Usb Chip\n");
- if (FIRMWAREIMAGE_LENGTH == FIRMWAREIMAGE_MAX_LENGTH)
- //The firmware image consists of two parts. One is the origianl and the other is the new.
- //Use Second Part
- {
- if ((Version != 0x2860) && (Version != 0x2872) && (Version != 0x3070))
- { // Use Firmware V2.
- //printk("KH:Use New Version,part2\n");
- pFirmwareImage = (PUCHAR)&FirmwareImage[FIRMWAREIMAGEV1_LENGTH];
- FileLength = FIRMWAREIMAGEV2_LENGTH;
- }
- else
- {
- //printk("KH:Use New Version,part1\n");
- pFirmwareImage = FirmwareImage;
- FileLength = FIRMWAREIMAGEV1_LENGTH;
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("KH: bin file should be 8KB.\n"));
- Status = NDIS_STATUS_FAILURE;
- }
-
-#endif // RT2870 //
-
-#if 0
- /* enable Host program ram write selection */
- RT28XX_FIRMUD_INIT(pAd);
-
- for(i=0; i<FileLength; i+=4)
- {
- firm = pFirmwareImage[i] +
- (pFirmwareImage[i+3] << 24) +
- (pFirmwareImage[i+2] << 16) +
- (pFirmwareImage[i+1] << 8);
-
- RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, firm);
- } /* End of for */
-
- RT28XX_FIRMUD_END(pAd);
-#else
- RT28XX_WRITE_FIRMWARE(pAd, pFirmwareImage, FileLength);
-#endif
-
-#endif
-
- /* check if MCU is ready */
- Index = 0;
- do
- {
- RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacReg);
-
- if (MacReg & 0x80)
- break;
-
- RTMPusecDelay(1000);
- } while (Index++ < 1000);
-
- if (Index >= 1000)
- {
- Status = NDIS_STATUS_FAILURE;
- DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
- } /* End of if */
-
-#if 0
- DBGPRINT(RT_DEBUG_TRACE,
- ("<=== %s (src=%s, status=%d)\n", __func__, src, Status));
-#else
- DBGPRINT(RT_DEBUG_TRACE,
- ("<=== %s (status=%d)\n", __func__, Status));
-#endif
- return Status;
-} /* End of NICLoadFirmware */
-
-
-/*
- ========================================================================
-
- Routine Description:
- Load Tx rate switching parameters
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- NDIS_STATUS_SUCCESS firmware image load ok
- NDIS_STATUS_FAILURE image not found
-
- IRQL = PASSIVE_LEVEL
-
- Rate Table Format:
- 1. (B0: Valid Item number) (B1:Initial item from zero)
- 2. Item Number(Dec) Mode(Hex) Current MCS(Dec) TrainUp(Dec) TrainDown(Dec)
-
- ========================================================================
-*/
-NDIS_STATUS NICLoadRateSwitchingParams(
- IN PRTMP_ADAPTER pAd)
-{
-#if 0
- NDIS_STATUS Status;
-
- NDIS_HANDLE FileHandle;
- UINT FileLength = 0, i, j;
- PUCHAR pFirmwareImage;
- NDIS_STRING FileName;
- NDIS_PHYSICAL_ADDRESS HighestAcceptableMax = NDIS_PHYSICAL_ADDRESS_CONST(-1, -1);
-
- DBGPRINT(RT_DEBUG_TRACE,("===> NICLoadRateSwitchingParams \n"));
- pAd->CommonCfg.TxRateTableSize = 0;
-
- if ((pAd->DeviceID == NIC2860_PCI_DEVICE_ID) || (pAd->DeviceID == NIC2860_PCIe_DEVICE_ID))
- {
- NdisInitializeString(&FileName,"rate.bin");
- DBGPRINT(RT_DEBUG_TRACE, ("NICLoadRateSwitchingParams: load file - rate.bin for tx rate switch \n"));
- }
- else
- {
- DBGPRINT_ERR(("NICLoadRateSwitchingParams: wrong DeviceID = 0x%04x, can't find Tx rate switch parameters file\n", pAd->DeviceID));
- return NDIS_STATUS_SUCCESS;
- }
- NdisOpenFile(&Status, &FileHandle, &FileLength, &FileName, HighestAcceptableMax);
- NdisFreeString(FileName);
-
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("NICLoadRateSwitchingParams: NdisOpenFile() failed, used RateSwitchTable instead\n"));
- return NDIS_STATUS_SUCCESS;
- }
-
- if ((FileLength == 0) || (FileLength > (MAX_STEP_OF_TX_RATE_SWITCH+1)*16))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("NICLoadRateSwitchingParams: file size is not reasonable, used RateSwitchTable instead\n"));
-
- NdisCloseFile(FileHandle);
- return NDIS_STATUS_SUCCESS;
- }
- else
- {
- //
- // NDIS_STATUS_SUCCESS means
- // The handle at FileHandle is valid for a subsequent call to NdisMapFile.
- //
- NdisMapFile(&Status, &pFirmwareImage, FileHandle);
- DBGPRINT(RT_DEBUG_TRACE, ("NdisMapFile FileLength=%d\n", FileLength));
- }
-
- for (i=0, j=0; i<FileLength; i++)
- {
- if ((i%16) <= 4) // trim reserved field
- {
- if (i%16 == 1) // deal with DEC and HEX, only row0 is Hex, others are Dec
- {
- RateSwitchTable[j] = *(pFirmwareImage + i);
- }
- else
- {
- RateSwitchTable[j] = (*(pFirmwareImage + i)>>4) * 10 + (*(pFirmwareImage + i) & 0x0F);
- }
-
- j++;
- }
- }
-
- pAd->CommonCfg.TxRateTableSize = RateSwitchTable[0]; // backup table size
-
- if (Status == NDIS_STATUS_SUCCESS)
- {
- NdisUnmapFile(FileHandle);
- NdisCloseFile(FileHandle);
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("<=== NICLoadRateSwitchingParams(Valid TxRateTable item number=%d)\n", pAd->CommonCfg.TxRateTableSize));
-#endif
- return NDIS_STATUS_SUCCESS;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- if pSrc1 all zero with length Length, return 0.
- If not all zero, return 1
-
- Arguments:
- pSrc1
-
- Return Value:
- 1: not all zero
- 0: all zero
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-ULONG RTMPNotAllZero(
- IN PVOID pSrc1,
- IN ULONG Length)
-{
- PUCHAR pMem1;
- ULONG Index = 0;
-
- pMem1 = (PUCHAR) pSrc1;
-
- for (Index = 0; Index < Length; Index++)
- {
- if (pMem1[Index] != 0x0)
- {
- break;
- }
- }
-
- if (Index == Length)
- {
- return (0);
- }
- else
- {
- return (1);
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Compare two memory block
-
- Arguments:
- pSrc1 Pointer to first memory address
- pSrc2 Pointer to second memory address
-
- Return Value:
- 0: memory is equal
- 1: pSrc1 memory is larger
- 2: pSrc2 memory is larger
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-ULONG RTMPCompareMemory(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- IN ULONG Length)
-{
- PUCHAR pMem1;
- PUCHAR pMem2;
- ULONG Index = 0;
-
- pMem1 = (PUCHAR) pSrc1;
- pMem2 = (PUCHAR) pSrc2;
-
- for (Index = 0; Index < Length; Index++)
- {
- if (pMem1[Index] > pMem2[Index])
- return (1);
- else if (pMem1[Index] < pMem2[Index])
- return (2);
- }
-
- // Equal
- return (0);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Zero out memory block
-
- Arguments:
- pSrc1 Pointer to memory address
- Length Size
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPZeroMemory(
- IN PVOID pSrc,
- IN ULONG Length)
-{
- PUCHAR pMem;
- ULONG Index = 0;
-
- pMem = (PUCHAR) pSrc;
-
- for (Index = 0; Index < Length; Index++)
- {
- pMem[Index] = 0x00;
- }
-}
-
-VOID RTMPFillMemory(
- IN PVOID pSrc,
- IN ULONG Length,
- IN UCHAR Fill)
-{
- PUCHAR pMem;
- ULONG Index = 0;
-
- pMem = (PUCHAR) pSrc;
-
- for (Index = 0; Index < Length; Index++)
- {
- pMem[Index] = Fill;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Copy data from memory block 1 to memory block 2
-
- Arguments:
- pDest Pointer to destination memory address
- pSrc Pointer to source memory address
- Length Copy size
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPMoveMemory(
- OUT PVOID pDest,
- IN PVOID pSrc,
- IN ULONG Length)
-{
- PUCHAR pMem1;
- PUCHAR pMem2;
- UINT Index;
-
- ASSERT((Length==0) || (pDest && pSrc));
-
- pMem1 = (PUCHAR) pDest;
- pMem2 = (PUCHAR) pSrc;
-
- for (Index = 0; Index < Length; Index++)
- {
- pMem1[Index] = pMem2[Index];
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Initialize port configuration structure
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID UserCfgInit(
- IN PRTMP_ADAPTER pAd)
-{
-// EDCA_PARM DefaultEdcaParm;
- UINT key_index, bss_index;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit\n"));
-
- //
- // part I. intialize common configuration
- //
-#ifdef RT2870
- pAd->BulkOutReq = 0;
-
- pAd->BulkOutComplete = 0;
- pAd->BulkOutCompleteOther = 0;
- pAd->BulkOutCompleteCancel = 0;
- pAd->BulkInReq = 0;
- pAd->BulkInComplete = 0;
- pAd->BulkInCompleteFail = 0;
-
- //pAd->QuickTimerP = 100;
- //pAd->TurnAggrBulkInCount = 0;
- pAd->bUsbTxBulkAggre = 0;
-
- // init as unsed value to ensure driver will set to MCU once.
- pAd->LedIndicatorStregth = 0xFF;
-
- pAd->CommonCfg.MaxPktOneTxBulk = 2;
- pAd->CommonCfg.TxBulkFactor = 1;
- pAd->CommonCfg.RxBulkFactor =1;
-
- pAd->CommonCfg.TxPower = 100; //mW
-
- NdisZeroMemory(&pAd->CommonCfg.IOTestParm, sizeof(pAd->CommonCfg.IOTestParm));
-#endif // RT2870 //
-
- for(key_index=0; key_index<SHARE_KEY_NUM; key_index++)
- {
- for(bss_index = 0; bss_index < MAX_MBSSID_NUM; bss_index++)
- {
- pAd->SharedKey[bss_index][key_index].KeyLen = 0;
- pAd->SharedKey[bss_index][key_index].CipherAlg = CIPHER_NONE;
- }
- }
-
- pAd->Antenna.word = 0;
- pAd->CommonCfg.BBPCurrentBW = BW_20;
-
- pAd->LedCntl.word = 0;
-
- pAd->bAutoTxAgcA = FALSE; // Default is OFF
- pAd->bAutoTxAgcG = FALSE; // Default is OFF
- pAd->RfIcType = RFIC_2820;
-
- // Init timer for reset complete event
- pAd->CommonCfg.CentralChannel = 1;
- pAd->bForcePrintTX = FALSE;
- pAd->bForcePrintRX = FALSE;
- pAd->bStaFifoTest = FALSE;
- pAd->bProtectionTest = FALSE;
- pAd->bHCCATest = FALSE;
- pAd->bGenOneHCCA = FALSE;
- pAd->CommonCfg.Dsifs = 10; // in units of usec
- pAd->CommonCfg.TxPower = 100; //mW
- pAd->CommonCfg.TxPowerPercentage = 0xffffffff; // AUTO
- pAd->CommonCfg.TxPowerDefault = 0xffffffff; // AUTO
- pAd->CommonCfg.TxPreamble = Rt802_11PreambleAuto; // use Long preamble on TX by defaut
- pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
- pAd->CommonCfg.RtsThreshold = 2347;
- pAd->CommonCfg.FragmentThreshold = 2346;
- pAd->CommonCfg.UseBGProtection = 0; // 0: AUTO
- pAd->CommonCfg.bEnableTxBurst = TRUE; //0;
- pAd->CommonCfg.PhyMode = 0xff; // unknown
- pAd->CommonCfg.BandState = UNKNOWN_BAND;
- pAd->CommonCfg.RadarDetect.CSPeriod = 10;
- pAd->CommonCfg.RadarDetect.CSCount = 0;
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
- pAd->CommonCfg.RadarDetect.ChMovingTime = 65;
- pAd->CommonCfg.RadarDetect.LongPulseRadarTh = 3;
- pAd->CommonCfg.bAPSDCapable = FALSE;
- pAd->CommonCfg.bNeedSendTriggerFrame = FALSE;
- pAd->CommonCfg.TriggerTimerCount = 0;
- pAd->CommonCfg.bAPSDForcePowerSave = FALSE;
- pAd->CommonCfg.bCountryFlag = FALSE;
- pAd->CommonCfg.TxStream = 0;
- pAd->CommonCfg.RxStream = 0;
-
- NdisZeroMemory(&pAd->BeaconTxWI, sizeof(pAd->BeaconTxWI));
-
-#ifdef DOT11_N_SUPPORT
- NdisZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
- pAd->HTCEnable = FALSE;
- pAd->bBroadComHT = FALSE;
- pAd->CommonCfg.bRdg = FALSE;
-
-#ifdef DOT11N_DRAFT3
- pAd->CommonCfg.Dot11OBssScanPassiveDwell = dot11OBSSScanPassiveDwell; // Unit : TU. 5~1000
- pAd->CommonCfg.Dot11OBssScanActiveDwell = dot11OBSSScanActiveDwell; // Unit : TU. 10~1000
- pAd->CommonCfg.Dot11BssWidthTriggerScanInt = dot11BSSWidthTriggerScanInterval; // Unit : Second
- pAd->CommonCfg.Dot11OBssScanPassiveTotalPerChannel = dot11OBSSScanPassiveTotalPerChannel; // Unit : TU. 200~10000
- pAd->CommonCfg.Dot11OBssScanActiveTotalPerChannel = dot11OBSSScanActiveTotalPerChannel; // Unit : TU. 20~10000
- pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor = dot11BSSWidthChannelTransactionDelayFactor;
- pAd->CommonCfg.Dot11OBssScanActivityThre = dot11BSSScanActivityThreshold; // Unit : percentage
- pAd->CommonCfg.Dot11BssWidthChanTranDelay = (pAd->CommonCfg.Dot11BssWidthTriggerScanInt * pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor);
-#endif // DOT11N_DRAFT3 //
-
- NdisZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
- pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
- pAd->CommonCfg.BACapability.field.MpduDensity = 0;
- pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64; //32;
- pAd->CommonCfg.BACapability.field.TxBAWinLimit = 64; //32;
- DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit. BACapability = 0x%x\n", pAd->CommonCfg.BACapability.word));
-
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- BATableInit(pAd, &pAd->BATable);
-
- pAd->CommonCfg.bExtChannelSwitchAnnouncement = 1;
- pAd->CommonCfg.bHTProtect = 1;
- pAd->CommonCfg.bMIMOPSEnable = TRUE;
- pAd->CommonCfg.bBADecline = FALSE;
- pAd->CommonCfg.bDisableReordering = FALSE;
-
- pAd->CommonCfg.TxBASize = 7;
-
- pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word;
-#endif // DOT11_N_SUPPORT //
-
- //pAd->CommonCfg.HTPhyMode.field.BW = BW_20;
- //pAd->CommonCfg.HTPhyMode.field.MCS = MCS_AUTO;
- //pAd->CommonCfg.HTPhyMode.field.ShortGI = GI_800;
- //pAd->CommonCfg.HTPhyMode.field.STBC = STBC_NONE;
- pAd->CommonCfg.TxRate = RATE_6;
-
- pAd->CommonCfg.MlmeTransmit.field.MCS = MCS_RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.BW = BW_20;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-
- pAd->CommonCfg.BeaconPeriod = 100; // in mSec
-
- //
- // part II. intialize STA specific configuration
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_DIRECT);
- RX_FILTER_CLEAR_FLAG(pAd, fRX_FILTER_ACCEPT_MULTICAST);
- RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_BROADCAST);
- RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_ALL_MULTICAST);
-
- pAd->StaCfg.Psm = PWR_ACTIVE;
-
- pAd->StaCfg.OrigWepStatus = Ndis802_11EncryptionDisabled;
- pAd->StaCfg.PairCipher = Ndis802_11EncryptionDisabled;
- pAd->StaCfg.GroupCipher = Ndis802_11EncryptionDisabled;
- pAd->StaCfg.bMixCipher = FALSE;
- pAd->StaCfg.DefaultKeyId = 0;
-
- // 802.1x port control
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.LastMicErrorTime = 0;
- pAd->StaCfg.MicErrCnt = 0;
- pAd->StaCfg.bBlockAssoc = FALSE;
- pAd->StaCfg.WpaState = SS_NOTUSE;
-
- pAd->CommonCfg.NdisRadioStateOff = FALSE; // New to support microsoft disable radio with OID command
-
- pAd->StaCfg.RssiTrigger = 0;
- NdisZeroMemory(&pAd->StaCfg.RssiSample, sizeof(RSSI_SAMPLE));
- pAd->StaCfg.RssiTriggerMode = RSSI_TRIGGERED_UPON_BELOW_THRESHOLD;
- pAd->StaCfg.AtimWin = 0;
- pAd->StaCfg.DefaultListenCount = 3;//default listen count;
- pAd->StaCfg.BssType = BSS_INFRA; // BSS_INFRA or BSS_ADHOC or BSS_MONITOR
- pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
-
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- }
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- pAd->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
-
- // global variables mXXXX used in MAC protocol state machines
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-
- // PHY specification
- pAd->CommonCfg.PhyMode = PHY_11BG_MIXED; // default PHY mode
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED); // CCK use LONG preamble
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // user desired power mode
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- pAd->StaCfg.bWindowsACCAMEnable = FALSE;
-
-#ifdef LEAP_SUPPORT
- // CCX v1.0 releated init value
- RTMPInitTimer(pAd, &pAd->StaCfg.LeapAuthTimer, GET_TIMER_FUNCTION(LeapAuthTimeout), pAd, FALSE);
- pAd->StaCfg.LeapAuthMode = CISCO_AuthModeLEAPNone;
- pAd->StaCfg.bCkipOn = FALSE;
-#endif // LEAP_SUPPORT //
-
- RTMPInitTimer(pAd, &pAd->StaCfg.StaQuickResponeForRateUpTimer, GET_TIMER_FUNCTION(StaQuickResponeForRateUpExec), pAd, FALSE);
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
-
- // Patch for Ndtest
- pAd->StaCfg.ScanCnt = 0;
-
- // CCX 2.0 control flag init
- pAd->StaCfg.CCXEnable = FALSE;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_UNUSED;
- pAd->StaCfg.CCXQosECWMin = 4;
- pAd->StaCfg.CCXQosECWMax = 10;
-
- pAd->StaCfg.bHwRadio = TRUE; // Default Hardware Radio status is On
- pAd->StaCfg.bSwRadio = TRUE; // Default Software Radio status is On
- pAd->StaCfg.bRadio = TRUE; // bHwRadio && bSwRadio
- pAd->StaCfg.bHardwareRadio = FALSE; // Default is OFF
- pAd->StaCfg.bShowHiddenSSID = FALSE; // Default no show
-
- // Nitro mode control
- pAd->StaCfg.bAutoReconnect = TRUE;
-
- // Save the init time as last scan time, the system should do scan after 2 seconds.
- // This patch is for driver wake up from standby mode, system will do scan right away.
- pAd->StaCfg.LastScanTime = 0;
- NdisZeroMemory(pAd->nickname, IW_ESSID_MAX_SIZE+1);
- sprintf(pAd->nickname, "%s", STA_NIC_DEVICE_NAME);
- RTMPInitTimer(pAd, &pAd->StaCfg.WpaDisassocAndBlockAssocTimer, GET_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc), pAd, FALSE);
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAd->StaCfg.IEEE8021X = FALSE;
- pAd->StaCfg.IEEE8021x_required_keys = FALSE;
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Default for extra information is not valid
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
-
- // Default Config change flag
- pAd->bConfigChanged = FALSE;
-
- //
- // part III. AP configurations
- //
-
-
- //
- // part IV. others
- //
- // dynamic BBP R66:sensibity tuning to overcome background noise
- pAd->BbpTuning.bEnable = TRUE;
- pAd->BbpTuning.FalseCcaLowerThreshold = 100;
- pAd->BbpTuning.FalseCcaUpperThreshold = 512;
- pAd->BbpTuning.R66Delta = 4;
- pAd->Mlme.bEnableAutoAntennaCheck = TRUE;
-
- //
- // Also initial R66CurrentValue, RTUSBResumeMsduTransmission might use this value.
- // if not initial this value, the default value will be 0.
- //
- pAd->BbpTuning.R66CurrentValue = 0x38;
-
- pAd->Bbp94 = BBPR94_DEFAULT;
- pAd->BbpForCCK = FALSE;
-
- // Default is FALSE for test bit 1
- //pAd->bTest1 = FALSE;
-
- // initialize MAC table and allocate spin lock
- NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE));
- InitializeQueueHeader(&pAd->MacTab.McastPsQueue);
- NdisAllocateSpinLock(&pAd->MacTabLock);
-
- //RTMPInitTimer(pAd, &pAd->RECBATimer, RECBATimerTimeout, pAd, TRUE);
- //RTMPSetTimer(&pAd->RECBATimer, REORDER_EXEC_INTV);
-
-#ifdef RALINK_ATE
- NdisZeroMemory(&pAd->ate, sizeof(ATE_INFO));
- pAd->ate.Mode = ATE_STOP;
- pAd->ate.TxCount = 200;/* to exceed TX_RING_SIZE ... */
- pAd->ate.TxLength = 1024;
- pAd->ate.TxWI.ShortGI = 0;// LONG GI : 800 ns
- pAd->ate.TxWI.PHYMODE = MODE_CCK;
- pAd->ate.TxWI.MCS = 3;
- pAd->ate.TxWI.BW = BW_20;
- pAd->ate.Channel = 1;
- pAd->ate.QID = QID_AC_BE;
- pAd->ate.Addr1[0] = 0x00;
- pAd->ate.Addr1[1] = 0x11;
- pAd->ate.Addr1[2] = 0x22;
- pAd->ate.Addr1[3] = 0xAA;
- pAd->ate.Addr1[4] = 0xBB;
- pAd->ate.Addr1[5] = 0xCC;
- NdisMoveMemory(pAd->ate.Addr2, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- NdisMoveMemory(pAd->ate.Addr3, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- pAd->ate.bRxFer = 0;
- pAd->ate.bQATxStart = FALSE;
- pAd->ate.bQARxStart = FALSE;
-#ifdef RALINK_28xx_QA
- //pAd->ate.Repeat = 0;
- pAd->ate.TxStatus = 0;
- pAd->ate.AtePid = NULL;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-
- pAd->CommonCfg.bWiFiTest = FALSE;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n"));
-}
-
-// IRQL = PASSIVE_LEVEL
-UCHAR BtoH(char ch)
-{
- if (ch >= '0' && ch <= '9') return (ch - '0'); // Handle numerals
- if (ch >= 'A' && ch <= 'F') return (ch - 'A' + 0xA); // Handle capitol hex digits
- if (ch >= 'a' && ch <= 'f') return (ch - 'a' + 0xA); // Handle small hex digits
- return(255);
-}
-
-//
-// FUNCTION: AtoH(char *, UCHAR *, int)
-//
-// PURPOSE: Converts ascii string to network order hex
-//
-// PARAMETERS:
-// src - pointer to input ascii string
-// dest - pointer to output hex
-// destlen - size of dest
-//
-// COMMENTS:
-//
-// 2 ascii bytes make a hex byte so must put 1st ascii byte of pair
-// into upper nibble and 2nd ascii byte of pair into lower nibble.
-//
-// IRQL = PASSIVE_LEVEL
-
-void AtoH(char * src, UCHAR * dest, int destlen)
-{
- char * srcptr;
- PUCHAR destTemp;
-
- srcptr = src;
- destTemp = (PUCHAR) dest;
-
- while(destlen--)
- {
- *destTemp = BtoH(*srcptr++) << 4; // Put 1st ascii byte in upper nibble.
- *destTemp += BtoH(*srcptr++); // Add 2nd ascii byte to above.
- destTemp++;
- }
-}
-
-VOID RTMPPatchMacBbpBug(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG Index;
-
- // Initialize BBP register to default value
- for (Index = 0; Index < NUM_BBP_REG_PARMS; Index++)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, (UCHAR)BBPRegTable[Index].Value);
- }
-
- // Initialize RF register to default value
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- // Re-init BBP register from EEPROM value
- NICInitAsicFromEEPROM(pAd);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init timer objects
-
- Arguments:
- pAd Pointer to our adapter
- pTimer Timer structure
- pTimerFunc Function to execute when timer expired
- Repeat Ture for period timer
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitTimer(
- IN PRTMP_ADAPTER pAd,
- IN PRALINK_TIMER_STRUCT pTimer,
- IN PVOID pTimerFunc,
- IN PVOID pData,
- IN BOOLEAN Repeat)
-{
- //
- // Set Valid to TRUE for later used.
- // It will crash if we cancel a timer or set a timer
- // that we haven't initialize before.
- //
- pTimer->Valid = TRUE;
-
- pTimer->PeriodicType = Repeat;
- pTimer->State = FALSE;
- pTimer->cookie = (ULONG) pData;
-
-#ifdef RT2870
- pTimer->pAd = pAd;
-#endif // RT2870 //
-
- RTMP_OS_Init_Timer(pAd, &pTimer->TimerObj, pTimerFunc, (PVOID) pTimer);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init timer objects
-
- Arguments:
- pTimer Timer structure
- Value Timer value in milliseconds
-
- Return Value:
- None
-
- Note:
- To use this routine, must call RTMPInitTimer before.
-
- ========================================================================
-*/
-VOID RTMPSetTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value)
-{
- if (pTimer->Valid)
- {
- pTimer->TimerValue = Value;
- pTimer->State = FALSE;
- if (pTimer->PeriodicType == TRUE)
- {
- pTimer->Repeat = TRUE;
- RTMP_SetPeriodicTimer(&pTimer->TimerObj, Value);
- }
- else
- {
- pTimer->Repeat = FALSE;
- RTMP_OS_Add_Timer(&pTimer->TimerObj, Value);
- }
- }
- else
- {
- DBGPRINT_ERR(("RTMPSetTimer failed, Timer hasn't been initialize!\n"));
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Init timer objects
-
- Arguments:
- pTimer Timer structure
- Value Timer value in milliseconds
-
- Return Value:
- None
-
- Note:
- To use this routine, must call RTMPInitTimer before.
-
- ========================================================================
-*/
-VOID RTMPModTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value)
-{
- BOOLEAN Cancel;
-
- if (pTimer->Valid)
- {
- pTimer->TimerValue = Value;
- pTimer->State = FALSE;
- if (pTimer->PeriodicType == TRUE)
- {
- RTMPCancelTimer(pTimer, &Cancel);
- RTMPSetTimer(pTimer, Value);
- }
- else
- {
- RTMP_OS_Mod_Timer(&pTimer->TimerObj, Value);
- }
- }
- else
- {
- DBGPRINT_ERR(("RTMPModTimer failed, Timer hasn't been initialize!\n"));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Cancel timer objects
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
- 1.) To use this routine, must call RTMPInitTimer before.
- 2.) Reset NIC to initial state AS IS system boot up time.
-
- ========================================================================
-*/
-VOID RTMPCancelTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- OUT BOOLEAN *pCancelled)
-{
- if (pTimer->Valid)
- {
- if (pTimer->State == FALSE)
- pTimer->Repeat = FALSE;
- RTMP_OS_Del_Timer(&pTimer->TimerObj, pCancelled);
-
- if (*pCancelled == TRUE)
- pTimer->State = TRUE;
-
-#ifdef RT2870
- // We need to go-through the TimerQ to findout this timer handler and remove it if
- // it's still waiting for execution.
-
- RT2870_TimerQ_Remove(pTimer->pAd, pTimer);
-#endif // RT2870 //
- }
- else
- {
- //
- // NdisMCancelTimer just canced the timer and not mean release the timer.
- // And don't set the "Valid" to False. So that we can use this timer again.
- //
- DBGPRINT_ERR(("RTMPCancelTimer failed, Timer hasn't been initialize!\n"));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set LED Status
-
- Arguments:
- pAd Pointer to our adapter
- Status LED Status
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPSetLED(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Status)
-{
- //ULONG data;
- UCHAR HighByte = 0;
- UCHAR LowByte;
-
-// In ATE mode of RT2860 AP/STA, we have erased 8051 firmware.
-// So LED mode is not supported when ATE is running.
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- LowByte = pAd->LedCntl.field.LedMode&0x7f;
- switch (Status)
- {
- case LED_LINK_DOWN:
- HighByte = 0x20;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- pAd->LedIndicatorStregth = 0;
- break;
- case LED_LINK_UP:
- if (pAd->CommonCfg.Channel > 14)
- HighByte = 0xa0;
- else
- HighByte = 0x60;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_RADIO_ON:
- HighByte = 0x20;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_HALT:
- LowByte = 0; // Driver sets MAC register and MAC controls LED
- case LED_RADIO_OFF:
- HighByte = 0;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_WPS:
- HighByte = 0x10;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_ON_SITE_SURVEY:
- HighByte = 0x08;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_POWER_UP:
- HighByte = 0x04;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- default:
- DBGPRINT(RT_DEBUG_WARN, ("RTMPSetLED::Unknown Status %d\n", Status));
- break;
- }
-
- //
- // Keep LED status for LED SiteSurvey mode.
- // After SiteSurvey, we will set the LED mode to previous status.
- //
- if ((Status != LED_ON_SITE_SURVEY) && (Status != LED_POWER_UP))
- pAd->LedStatus = Status;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetLED::Mode=%d,HighByte=0x%02x,LowByte=0x%02x\n", pAd->LedCntl.field.LedMode, HighByte, LowByte));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set LED Signal Stregth
-
- Arguments:
- pAd Pointer to our adapter
- Dbm Signal Stregth
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
- Can be run on any IRQL level.
-
- According to Microsoft Zero Config Wireless Signal Stregth definition as belows.
- <= -90 No Signal
- <= -81 Very Low
- <= -71 Low
- <= -67 Good
- <= -57 Very Good
- > -57 Excellent
- ========================================================================
-*/
-VOID RTMPSetSignalLED(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_802_11_RSSI Dbm)
-{
- UCHAR nLed = 0;
-
- //
- // if not Signal Stregth, then do nothing.
- //
- if (pAd->LedCntl.field.LedMode != LED_MODE_SIGNAL_STREGTH)
- {
- return;
- }
-
- if (Dbm <= -90)
- nLed = 0;
- else if (Dbm <= -81)
- nLed = 1;
- else if (Dbm <= -71)
- nLed = 3;
- else if (Dbm <= -67)
- nLed = 7;
- else if (Dbm <= -57)
- nLed = 15;
- else
- nLed = 31;
-
- //
- // Update Signal Stregth to firmware if changed.
- //
- if (pAd->LedIndicatorStregth != nLed)
- {
- AsicSendCommandToMcu(pAd, 0x51, 0xff, nLed, pAd->LedCntl.field.Polarity);
- pAd->LedIndicatorStregth = nLed;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Enable RX
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL <= DISPATCH_LEVEL
-
- Note:
- Before Enable RX, make sure you have enabled Interrupt.
- ========================================================================
-*/
-VOID RTMPEnableRxTx(
- IN PRTMP_ADAPTER pAd)
-{
-// WPDMA_GLO_CFG_STRUC GloCfg;
-// ULONG i = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPEnableRxTx\n"));
-
-#if 0
- // Enable Rx DMA.
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x4);
- do
- {
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
- if ((GloCfg.field.TxDMABusy == 0) && (GloCfg.field.RxDMABusy == 0))
- break;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> DMABusy\n"));
- RTMPusecDelay(1000);
- i++;
- }while ( i <200);
-
- RTMPusecDelay(50);
- RT28XX_DMA_WRITE_INIT(GloCfg);
- DBGPRINT(RT_DEBUG_TRACE, ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));
- RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
- RT28XX_DMA_POST_WRITE(pAd);
-#else
- // Enable Rx DMA.
- RT28XXDMAEnable(pAd);
-#endif
-
- // enable RX of MAC block
- if (pAd->OpMode == OPMODE_AP)
- {
- UINT32 rx_filter_flag = APNORMAL;
-
-
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag); // enable RX of DMA block
- }
- else
- {
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
- }
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc);
- DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n"));
-}
-
-
+#include "../../rt2860/common/rtmp_init.c"
diff --git a/drivers/staging/rt2870/common/rtmp_tkip.c b/drivers/staging/rt2870/common/rtmp_tkip.c
index 2847409ff081..240bf67f521f 100644
--- a/drivers/staging/rt2870/common/rtmp_tkip.c
+++ b/drivers/staging/rt2870/common/rtmp_tkip.c
@@ -1,1613 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_tkip.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Wu 02-25-02 Initial
-*/
-
-#include "../rt_config.h"
-
-// Rotation functions on 32 bit values
-#define ROL32( A, n ) \
- ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
-#define ROR32( A, n ) ROL32( (A), 32-(n) )
-
-UINT Tkip_Sbox_Lower[256] =
-{
- 0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54,
- 0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A,
- 0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B,
- 0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B,
- 0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F,
- 0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F,
- 0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5,
- 0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F,
- 0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB,
- 0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97,
- 0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED,
- 0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A,
- 0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94,
- 0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3,
- 0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04,
- 0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D,
- 0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39,
- 0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95,
- 0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83,
- 0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76,
- 0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4,
- 0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B,
- 0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0,
- 0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18,
- 0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51,
- 0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85,
- 0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12,
- 0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9,
- 0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7,
- 0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A,
- 0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8,
- 0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A
-};
-
-UINT Tkip_Sbox_Upper[256] =
-{
- 0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91,
- 0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC,
- 0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB,
- 0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B,
- 0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83,
- 0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A,
- 0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F,
- 0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA,
- 0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B,
- 0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13,
- 0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6,
- 0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85,
- 0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11,
- 0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B,
- 0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1,
- 0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF,
- 0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E,
- 0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6,
- 0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B,
- 0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD,
- 0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8,
- 0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2,
- 0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49,
- 0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10,
- 0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97,
- 0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F,
- 0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C,
- 0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27,
- 0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33,
- 0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5,
- 0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0,
- 0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C
-};
-
-/*****************************/
-/******** SBOX Table *********/
-/*****************************/
-
-UCHAR SboxTable[256] =
-{
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
- 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
- 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
- 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
- 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
- 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
- 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
- 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
- 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
- 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
- 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
- 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
- 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
- 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
- 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
- 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
- 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round);
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a);
-//
-// Expanded IV for TKIP function.
-//
-typedef struct PACKED _IV_CONTROL_
-{
- union PACKED
- {
- struct PACKED
- {
- UCHAR rc0;
- UCHAR rc1;
- UCHAR rc2;
-
- union PACKED
- {
- struct PACKED
- {
-#ifdef RT_BIG_ENDIAN
- UCHAR KeyID:2;
- UCHAR ExtIV:1;
- UCHAR Rsvd:5;
-#else
- UCHAR Rsvd:5;
- UCHAR ExtIV:1;
- UCHAR KeyID:2;
-#endif
- } field;
- UCHAR Byte;
- } CONTROL;
- } field;
-
- ULONG word;
- } IV16;
-
- ULONG IV32;
-} TKIP_IV, *PTKIP_IV;
-
-
-/*
- ========================================================================
-
- Routine Description:
- Convert from UCHAR[] to ULONG in a portable way
-
- Arguments:
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-ULONG RTMPTkipGetUInt32(
- IN PUCHAR pMICKey)
-{
- ULONG res = 0;
- INT i;
-
- for (i = 0; i < 4; i++)
- {
- res |= (*pMICKey++) << (8 * i);
- }
-
- return res;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Convert from ULONG to UCHAR[] in a portable way
-
- Arguments:
- pDst pointer to destination for convert ULONG to UCHAR[]
- val the value for convert
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipPutUInt32(
- IN OUT PUCHAR pDst,
- IN ULONG val)
-{
- INT i;
-
- for(i = 0; i < 4; i++)
- {
- *pDst++ = (UCHAR) (val & 0xff);
- val >>= 8;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set the MIC Key.
-
- Arguments:
- pAd Pointer to our adapter
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipSetMICKey(
- IN PTKIP_KEY_INFO pTkip,
- IN PUCHAR pMICKey)
-{
- // Set the key
- pTkip->K0 = RTMPTkipGetUInt32(pMICKey);
- pTkip->K1 = RTMPTkipGetUInt32(pMICKey + 4);
- // and reset the message
- pTkip->L = pTkip->K0;
- pTkip->R = pTkip->K1;
- pTkip->nBytesInM = 0;
- pTkip->M = 0;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Calculate the MIC Value.
-
- Arguments:
- pAd Pointer to our adapter
- uChar Append this uChar
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipAppendByte(
- IN PTKIP_KEY_INFO pTkip,
- IN UCHAR uChar)
-{
- // Append the byte to our word-sized buffer
- pTkip->M |= (uChar << (8* pTkip->nBytesInM));
- pTkip->nBytesInM++;
- // Process the word if it is full.
- if( pTkip->nBytesInM >= 4 )
- {
- pTkip->L ^= pTkip->M;
- pTkip->R ^= ROL32( pTkip->L, 17 );
- pTkip->L += pTkip->R;
- pTkip->R ^= ((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->L & 0x00ff00ff) << 8);
- pTkip->L += pTkip->R;
- pTkip->R ^= ROL32( pTkip->L, 3 );
- pTkip->L += pTkip->R;
- pTkip->R ^= ROR32( pTkip->L, 2 );
- pTkip->L += pTkip->R;
- // Clear the buffer
- pTkip->M = 0;
- pTkip->nBytesInM = 0;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Calculate the MIC Value.
-
- Arguments:
- pAd Pointer to our adapter
- pSrc Pointer to source data for Calculate MIC Value
- Len Indicate the length of the source data
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipAppend(
- IN PTKIP_KEY_INFO pTkip,
- IN PUCHAR pSrc,
- IN UINT nBytes)
-{
- // This is simple
- while(nBytes > 0)
- {
- RTMPTkipAppendByte(pTkip, *pSrc++);
- nBytes--;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get the MIC Value.
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- the MIC Value is store in pAd->PrivateInfo.MIC
- ========================================================================
-*/
-VOID RTMPTkipGetMIC(
- IN PTKIP_KEY_INFO pTkip)
-{
- // Append the minimum padding
- RTMPTkipAppendByte(pTkip, 0x5a );
- RTMPTkipAppendByte(pTkip, 0 );
- RTMPTkipAppendByte(pTkip, 0 );
- RTMPTkipAppendByte(pTkip, 0 );
- RTMPTkipAppendByte(pTkip, 0 );
- // and then zeroes until the length is a multiple of 4
- while( pTkip->nBytesInM != 0 )
- {
- RTMPTkipAppendByte(pTkip, 0 );
- }
- // The appendByte function has already computed the result.
- RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
- RTMPTkipPutUInt32(pTkip->MIC + 4, pTkip->R);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init Tkip function.
-
- Arguments:
- pAd Pointer to our adapter
- pTKey Pointer to the Temporal Key (TK), TK shall be 128bits.
- KeyId TK Key ID
- pTA Pointer to transmitter address
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitTkipEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN UCHAR KeyId,
- IN PUCHAR pTA,
- IN PUCHAR pMICKey,
- IN PUCHAR pTSC,
- OUT PULONG pIV16,
- OUT PULONG pIV32)
-{
- TKIP_IV tkipIv;
-
- // Prepare 8 bytes TKIP encapsulation for MPDU
- NdisZeroMemory(&tkipIv, sizeof(TKIP_IV));
- tkipIv.IV16.field.rc0 = *(pTSC + 1);
- tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;
- tkipIv.IV16.field.rc2 = *pTSC;
- tkipIv.IV16.field.CONTROL.field.ExtIV = 1; // 0: non-extended IV, 1: an extended IV
- tkipIv.IV16.field.CONTROL.field.KeyID = KeyId;
-// tkipIv.IV32 = *(PULONG)(pTSC + 2);
- NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4); // Copy IV
-
- *pIV16 = tkipIv.IV16.word;
- *pIV32 = tkipIv.IV32;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init MIC Value calculation function which include set MIC key &
- calculate first 16 bytes (DA + SA + priority + 0)
-
- Arguments:
- pAd Pointer to our adapter
- pTKey Pointer to the Temporal Key (TK), TK shall be 128bits.
- pDA Pointer to DA address
- pSA Pointer to SA address
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitMICEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN UCHAR UserPriority,
- IN PUCHAR pMICKey)
-{
- ULONG Priority = UserPriority;
-
- // Init MIC value calculation
- RTMPTkipSetMICKey(&pAd->PrivateInfo.Tx, pMICKey);
- // DA
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pDA, MAC_ADDR_LEN);
- // SA
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSA, MAC_ADDR_LEN);
- // Priority + 3 bytes of 0
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, (PUCHAR)&Priority, 4);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Compare MIC value of received MSDU
-
- Arguments:
- pAd Pointer to our adapter
- pSrc Pointer to the received Plain text data
- pDA Pointer to DA address
- pSA Pointer to SA address
- pMICKey pointer to MIC Key
- Len the length of the received plain text data exclude MIC value
-
- Return Value:
- TRUE MIC value matched
- FALSE MIC value mismatched
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN RTMPTkipCompareMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UCHAR UserPriority,
- IN UINT Len)
-{
- UCHAR OldMic[8];
- ULONG Priority = UserPriority;
-
- // Init MIC value calculation
- RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
- // DA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pDA, MAC_ADDR_LEN);
- // SA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
- // Priority + 3 bytes of 0
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
-
- // Calculate MIC value from plain text data
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
-
- // Get MIC valude from received frame
- NdisMoveMemory(OldMic, pSrc + Len, 8);
-
- // Get MIC value from decrypted plain data
- RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-
- // Move MIC value from MSDU, this steps should move to data path.
- // Since the MIC value might cross MPDUs.
- if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n")); //MIC error.
-
-
- return (FALSE);
- }
- return (TRUE);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Compare MIC value of received MSDU
-
- Arguments:
- pAd Pointer to our adapter
- pLLC LLC header
- pSrc Pointer to the received Plain text data
- pDA Pointer to DA address
- pSA Pointer to SA address
- pMICKey pointer to MIC Key
- Len the length of the received plain text data exclude MIC value
-
- Return Value:
- TRUE MIC value matched
- FALSE MIC value mismatched
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN RTMPTkipCompareMICValueWithLLC(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pLLC,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UINT Len)
-{
- UCHAR OldMic[8];
- ULONG Priority = 0;
-
- // Init MIC value calculation
- RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
- // DA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pDA, MAC_ADDR_LEN);
- // SA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
- // Priority + 3 bytes of 0
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
-
- // Start with LLC header
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pLLC, 8);
-
- // Calculate MIC value from plain text data
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
-
- // Get MIC valude from received frame
- NdisMoveMemory(OldMic, pSrc + Len, 8);
-
- // Get MIC value from decrypted plain data
- RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-
- // Move MIC value from MSDU, this steps should move to data path.
- // Since the MIC value might cross MPDUs.
- if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValueWithLLC(): TKIP MIC Error !\n")); //MIC error.
-
-
- return (FALSE);
- }
- return (TRUE);
-}
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware transmit function
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to Ndis Packet for MIC calculation
- pEncap Pointer to LLC encap data
- LenEncap Total encap length, might be 0 which indicates no encap
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPCalculateMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pEncap,
- IN PCIPHER_KEY pKey,
- IN UCHAR apidx)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- PUCHAR pSrc;
- UCHAR UserPriority;
- UCHAR vlan_offset = 0;
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- UserPriority = RTMP_GET_PACKET_UP(pPacket);
- pSrc = pSrcBufVA;
-
- // determine if this is a vlan packet
- if (((*(pSrc + 12) << 8) + *(pSrc + 13)) == 0x8100)
- vlan_offset = 4;
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- {
- RTMPInitMICEngine(
- pAd,
- pKey->Key,
- pSrc,
- pSrc + 6,
- UserPriority,
- pKey->TxMic);
- }
-
-
- if (pEncap != NULL)
- {
- // LLC encapsulation
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pEncap, 6);
- // Protocol Type
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset, 2);
- }
- SrcBufLen -= (14 + vlan_offset);
- pSrc += (14 + vlan_offset);
- do
- {
- if (SrcBufLen > 0)
- {
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc, SrcBufLen);
- }
-
- break; // No need handle next packet
-
- } while (TRUE); // End of copying payload
-
- // Compute the final MIC Value
- RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
-}
-
-
-/************************************************************/
-/* tkip_sbox() */
-/* Returns a 16 bit value from a 64K entry table. The Table */
-/* is synthesized from two 256 entry byte wide tables. */
-/************************************************************/
-
-UINT tkip_sbox(UINT index)
-{
- UINT index_low;
- UINT index_high;
- UINT left, right;
-
- index_low = (index % 256);
- index_high = ((index >> 8) % 256);
-
- left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256);
- right = Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
-
- return (left ^ right);
-}
-
-UINT rotr1(UINT a)
-{
- unsigned int b;
-
- if ((a & 0x01) == 0x01)
- {
- b = (a >> 1) | 0x8000;
- }
- else
- {
- b = (a >> 1) & 0x7fff;
- }
- b = b % 65536;
- return b;
-}
-
-VOID RTMPTkipMixKey(
- UCHAR *key,
- UCHAR *ta,
- ULONG pnl, /* Least significant 16 bits of PN */
- ULONG pnh, /* Most significant 32 bits of PN */
- UCHAR *rc4key,
- UINT *p1k)
-{
-
- UINT tsc0;
- UINT tsc1;
- UINT tsc2;
-
- UINT ppk0;
- UINT ppk1;
- UINT ppk2;
- UINT ppk3;
- UINT ppk4;
- UINT ppk5;
-
- INT i;
- INT j;
-
- tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
- tsc1 = (unsigned int)(pnh % 65536);
- tsc2 = (unsigned int)(pnl % 65536); /* lsb */
-
- /* Phase 1, step 1 */
- p1k[0] = tsc1;
- p1k[1] = tsc0;
- p1k[2] = (UINT)(ta[0] + (ta[1]*256));
- p1k[3] = (UINT)(ta[2] + (ta[3]*256));
- p1k[4] = (UINT)(ta[4] + (ta[5]*256));
-
- /* Phase 1, step 2 */
- for (i=0; i<8; i++)
- {
- j = 2*(i & 1);
- p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*key[1+j]) + key[j])) % 65536 )) % 65536;
- p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*key[5+j]) + key[4+j])) % 65536 )) % 65536;
- p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*key[9+j]) + key[8+j])) % 65536 )) % 65536;
- p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*key[13+j]) + key[12+j])) % 65536 )) % 65536;
- p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*key[1+j]) + key[j]))) % 65536 )) % 65536;
- p1k[4] = (p1k[4] + i) % 65536;
- }
-
- /* Phase 2, Step 1 */
- ppk0 = p1k[0];
- ppk1 = p1k[1];
- ppk2 = p1k[2];
- ppk3 = p1k[3];
- ppk4 = p1k[4];
- ppk5 = (p1k[4] + tsc2) % 65536;
-
- /* Phase2, Step 2 */
- ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*key[1]) + key[0])) % 65536);
- ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*key[3]) + key[2])) % 65536);
- ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*key[5]) + key[4])) % 65536);
- ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*key[7]) + key[6])) % 65536);
- ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*key[9]) + key[8])) % 65536);
- ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*key[11]) + key[10])) % 65536);
-
- ppk0 = ppk0 + rotr1(ppk5 ^ ((256*key[13]) + key[12]));
- ppk1 = ppk1 + rotr1(ppk0 ^ ((256*key[15]) + key[14]));
- ppk2 = ppk2 + rotr1(ppk1);
- ppk3 = ppk3 + rotr1(ppk2);
- ppk4 = ppk4 + rotr1(ppk3);
- ppk5 = ppk5 + rotr1(ppk4);
-
- /* Phase 2, Step 3 */
- /* Phase 2, Step 3 */
-
- tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
- tsc1 = (unsigned int)(pnh % 65536);
- tsc2 = (unsigned int)(pnl % 65536); /* lsb */
-
- rc4key[0] = (tsc2 >> 8) % 256;
- rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
- rc4key[2] = tsc2 % 256;
- rc4key[3] = ((ppk5 ^ ((256*key[1]) + key[0])) >> 1) % 256;
-
- rc4key[4] = ppk0 % 256;
- rc4key[5] = (ppk0 >> 8) % 256;
-
- rc4key[6] = ppk1 % 256;
- rc4key[7] = (ppk1 >> 8) % 256;
-
- rc4key[8] = ppk2 % 256;
- rc4key[9] = (ppk2 >> 8) % 256;
-
- rc4key[10] = ppk3 % 256;
- rc4key[11] = (ppk3 >> 8) % 256;
-
- rc4key[12] = ppk4 % 256;
- rc4key[13] = (ppk4 >> 8) % 256;
-
- rc4key[14] = ppk5 % 256;
- rc4key[15] = (ppk5 >> 8) % 256;
-}
-
-
-/************************************************/
-/* construct_mic_header1() */
-/* Builds the first MIC header block from */
-/* header fields. */
-/************************************************/
-
-void construct_mic_header1(
- unsigned char *mic_header1,
- int header_length,
- unsigned char *mpdu)
-{
- mic_header1[0] = (unsigned char)((header_length - 2) / 256);
- mic_header1[1] = (unsigned char)((header_length - 2) % 256);
- mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */
- mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */
- mic_header1[4] = mpdu[4]; /* A1 */
- mic_header1[5] = mpdu[5];
- mic_header1[6] = mpdu[6];
- mic_header1[7] = mpdu[7];
- mic_header1[8] = mpdu[8];
- mic_header1[9] = mpdu[9];
- mic_header1[10] = mpdu[10]; /* A2 */
- mic_header1[11] = mpdu[11];
- mic_header1[12] = mpdu[12];
- mic_header1[13] = mpdu[13];
- mic_header1[14] = mpdu[14];
- mic_header1[15] = mpdu[15];
-}
-
-/************************************************/
-/* construct_mic_header2() */
-/* Builds the last MIC header block from */
-/* header fields. */
-/************************************************/
-
-void construct_mic_header2(
- unsigned char *mic_header2,
- unsigned char *mpdu,
- int a4_exists,
- int qc_exists)
-{
- int i;
-
- for (i = 0; i<16; i++) mic_header2[i]=0x00;
-
- mic_header2[0] = mpdu[16]; /* A3 */
- mic_header2[1] = mpdu[17];
- mic_header2[2] = mpdu[18];
- mic_header2[3] = mpdu[19];
- mic_header2[4] = mpdu[20];
- mic_header2[5] = mpdu[21];
-
- // In Sequence Control field, mute sequence numer bits (12-bit)
- mic_header2[6] = mpdu[22] & 0x0f; /* SC */
- mic_header2[7] = 0x00; /* mpdu[23]; */
-
- if ((!qc_exists) & a4_exists)
- {
- for (i=0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */
-
- }
-
- if (qc_exists && (!a4_exists))
- {
- mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */
- mic_header2[9] = mpdu[25] & 0x00;
- }
-
- if (qc_exists && a4_exists)
- {
- for (i=0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */
-
- mic_header2[14] = mpdu[30] & 0x0f;
- mic_header2[15] = mpdu[31] & 0x00;
- }
-}
-
-
-/************************************************/
-/* construct_mic_iv() */
-/* Builds the MIC IV from header fields and PN */
-/************************************************/
-
-void construct_mic_iv(
- unsigned char *mic_iv,
- int qc_exists,
- int a4_exists,
- unsigned char *mpdu,
- unsigned int payload_length,
- unsigned char *pn_vector)
-{
- int i;
-
- mic_iv[0] = 0x59;
- if (qc_exists && a4_exists)
- mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */
- if (qc_exists && !a4_exists)
- mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */
- if (!qc_exists)
- mic_iv[1] = 0x00;
- for (i = 2; i < 8; i++)
- mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */
-#ifdef CONSISTENT_PN_ORDER
- for (i = 8; i < 14; i++)
- mic_iv[i] = pn_vector[i - 8]; /* mic_iv[8:13] = PN[0:5] */
-#else
- for (i = 8; i < 14; i++)
- mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */
-#endif
- i = (payload_length / 256);
- i = (payload_length % 256);
- mic_iv[14] = (unsigned char) (payload_length / 256);
- mic_iv[15] = (unsigned char) (payload_length % 256);
-
-}
-
-
-
-/************************************/
-/* bitwise_xor() */
-/* A 128 bit, bitwise exclusive or */
-/************************************/
-
-void bitwise_xor(unsigned char *ina, unsigned char *inb, unsigned char *out)
-{
- int i;
- for (i=0; i<16; i++)
- {
- out[i] = ina[i] ^ inb[i];
- }
-}
-
-
-void aes128k128d(unsigned char *key, unsigned char *data, unsigned char *ciphertext)
-{
- int round;
- int i;
- unsigned char intermediatea[16];
- unsigned char intermediateb[16];
- unsigned char round_key[16];
-
- for(i=0; i<16; i++) round_key[i] = key[i];
-
- for (round = 0; round < 11; round++)
- {
- if (round == 0)
- {
- xor_128(round_key, data, ciphertext);
- next_key(round_key, round);
- }
- else if (round == 10)
- {
- byte_sub(ciphertext, intermediatea);
- shift_row(intermediatea, intermediateb);
- xor_128(intermediateb, round_key, ciphertext);
- }
- else /* 1 - 9 */
- {
- byte_sub(ciphertext, intermediatea);
- shift_row(intermediatea, intermediateb);
- mix_column(&intermediateb[0], &intermediatea[0]);
- mix_column(&intermediateb[4], &intermediatea[4]);
- mix_column(&intermediateb[8], &intermediatea[8]);
- mix_column(&intermediateb[12], &intermediatea[12]);
- xor_128(intermediatea, round_key, ciphertext);
- next_key(round_key, round);
- }
- }
-
-}
-
-void construct_ctr_preload(
- unsigned char *ctr_preload,
- int a4_exists,
- int qc_exists,
- unsigned char *mpdu,
- unsigned char *pn_vector,
- int c)
-{
-
- int i = 0;
- for (i=0; i<16; i++) ctr_preload[i] = 0x00;
- i = 0;
-
- ctr_preload[0] = 0x01; /* flag */
- if (qc_exists && a4_exists) ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */
- if (qc_exists && !a4_exists) ctr_preload[1] = mpdu[24] & 0x0f;
-
- for (i = 2; i < 8; i++)
- ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
-#ifdef CONSISTENT_PN_ORDER
- for (i = 8; i < 14; i++)
- ctr_preload[i] = pn_vector[i - 8]; /* ctr_preload[8:13] = PN[0:5] */
-#else
- for (i = 8; i < 14; i++)
- ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */
-#endif
- ctr_preload[14] = (unsigned char) (c / 256); // Ctr
- ctr_preload[15] = (unsigned char) (c % 256);
-
-}
-
-
-//
-// TRUE: Success!
-// FALSE: Decrypt Error!
-//
-BOOLEAN RTMPSoftDecryptTKIP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN UCHAR UserPriority,
- IN PCIPHER_KEY pWpaKey)
-{
- UCHAR KeyID;
- UINT HeaderLen;
- UCHAR fc0;
- UCHAR fc1;
- USHORT fc;
- UINT frame_type;
- UINT frame_subtype;
- UINT from_ds;
- UINT to_ds;
- INT a4_exists;
- INT qc_exists;
- USHORT duration;
- USHORT seq_control;
- USHORT qos_control;
- UCHAR TA[MAC_ADDR_LEN];
- UCHAR DA[MAC_ADDR_LEN];
- UCHAR SA[MAC_ADDR_LEN];
- UCHAR RC4Key[16];
- UINT p1k[5]; //for mix_key;
- ULONG pnl;/* Least significant 16 bits of PN */
- ULONG pnh;/* Most significant 32 bits of PN */
- UINT num_blocks;
- UINT payload_remainder;
- ARCFOURCONTEXT ArcFourContext;
- UINT crc32 = 0;
- UINT trailfcs = 0;
- UCHAR MIC[8];
- UCHAR TrailMIC[8];
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
- fc0 = *pData;
- fc1 = *(pData + 1);
-
- fc = *((PUSHORT)pData);
-
- frame_type = ((fc0 >> 2) & 0x03);
- frame_subtype = ((fc0 >> 4) & 0x0f);
-
- from_ds = (fc1 & 0x2) >> 1;
- to_ds = (fc1 & 0x1);
-
- a4_exists = (from_ds & to_ds);
- qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
- (frame_subtype == 0x09) || /* Likely to change. */
- (frame_subtype == 0x0a) ||
- (frame_subtype == 0x0b)
- );
-
- HeaderLen = 24;
- if (a4_exists)
- HeaderLen += 6;
-
- KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
- KeyID = KeyID >> 6;
-
- if (pWpaKey[KeyID].KeyLen == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP failed!(KeyID[%d] Length can not be 0)\n", KeyID));
- return FALSE;
- }
-
- duration = *((PUSHORT)(pData+2));
-
- seq_control = *((PUSHORT)(pData+22));
-
- if (qc_exists)
- {
- if (a4_exists)
- {
- qos_control = *((PUSHORT)(pData+30));
- }
- else
- {
- qos_control = *((PUSHORT)(pData+24));
- }
- }
-
- if (to_ds == 0 && from_ds == 1)
- {
- NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
- NdisMoveMemory(SA, pData+16, MAC_ADDR_LEN);
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN); //BSSID
- }
- else if (to_ds == 0 && from_ds == 0 )
- {
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
- NdisMoveMemory(SA, pData+10, MAC_ADDR_LEN);
- }
- else if (to_ds == 1 && from_ds == 0)
- {
- NdisMoveMemory(SA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(DA, pData+16, MAC_ADDR_LEN);
- }
- else if (to_ds == 1 && from_ds == 1)
- {
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(DA, pData+16, MAC_ADDR_LEN);
- NdisMoveMemory(SA, pData+22, MAC_ADDR_LEN);
- }
-
- num_blocks = (DataByteCnt - 16) / 16;
- payload_remainder = (DataByteCnt - 16) % 16;
-
- pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);
- pnh = *((PULONG)(pData + HeaderLen + 4));
- pnh = cpu2le32(pnh);
- RTMPTkipMixKey(pWpaKey[KeyID].Key, TA, pnl, pnh, RC4Key, p1k);
-
- ARCFOUR_INIT(&ArcFourContext, RC4Key, 16);
-
- ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen, pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
- NdisMoveMemory(&trailfcs, pData + DataByteCnt - 8 - 4, 4);
- crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 4); //Skip IV+EIV 8 bytes & Skip last 4 bytes(FCS).
- crc32 ^= 0xffffffff; /* complement */
-
- if(crc32 != cpu2le32(trailfcs))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP, WEP Data ICV Error !\n")); //ICV error.
-
- return (FALSE);
- }
-
- NdisMoveMemory(TrailMIC, pData + DataByteCnt - 8 - 8 - 4, 8);
- RTMPInitMICEngine(pAd, pWpaKey[KeyID].Key, DA, SA, UserPriority, pWpaKey[KeyID].RxMic);
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 12);
- RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
- NdisMoveMemory(MIC, pAd->PrivateInfo.Tx.MIC, 8);
-
- if (!NdisEqualMemory(MIC, TrailMIC, 8))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n")); //MIC error.
- //RTMPReportMicError(pAd, &pWpaKey[KeyID]); // marked by AlbertY @ 20060630
- return (FALSE);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
- //DBGPRINT(RT_DEBUG_TRACE, "RTMPSoftDecryptTKIP Decript done!!\n");
- return TRUE;
-}
-
-
-
-
-BOOLEAN RTMPSoftDecryptAES(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pWpaKey)
-{
- UCHAR KeyID;
- UINT HeaderLen;
- UCHAR PN[6];
- UINT payload_len;
- UINT num_blocks;
- UINT payload_remainder;
- USHORT fc;
- UCHAR fc0;
- UCHAR fc1;
- UINT frame_type;
- UINT frame_subtype;
- UINT from_ds;
- UINT to_ds;
- INT a4_exists;
- INT qc_exists;
- UCHAR aes_out[16];
- int payload_index;
- UINT i;
- UCHAR ctr_preload[16];
- UCHAR chain_buffer[16];
- UCHAR padded_buffer[16];
- UCHAR mic_iv[16];
- UCHAR mic_header1[16];
- UCHAR mic_header2[16];
- UCHAR MIC[8];
- UCHAR TrailMIC[8];
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
- fc0 = *pData;
- fc1 = *(pData + 1);
-
- fc = *((PUSHORT)pData);
-
- frame_type = ((fc0 >> 2) & 0x03);
- frame_subtype = ((fc0 >> 4) & 0x0f);
-
- from_ds = (fc1 & 0x2) >> 1;
- to_ds = (fc1 & 0x1);
-
- a4_exists = (from_ds & to_ds);
- qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
- (frame_subtype == 0x09) || /* Likely to change. */
- (frame_subtype == 0x0a) ||
- (frame_subtype == 0x0b)
- );
-
- HeaderLen = 24;
- if (a4_exists)
- HeaderLen += 6;
-
- KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
- KeyID = KeyID >> 6;
-
- if (pWpaKey[KeyID].KeyLen == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptAES failed!(KeyID[%d] Length can not be 0)\n", KeyID));
- return FALSE;
- }
-
- PN[0] = *(pData+ HeaderLen);
- PN[1] = *(pData+ HeaderLen + 1);
- PN[2] = *(pData+ HeaderLen + 4);
- PN[3] = *(pData+ HeaderLen + 5);
- PN[4] = *(pData+ HeaderLen + 6);
- PN[5] = *(pData+ HeaderLen + 7);
-
- payload_len = DataByteCnt - HeaderLen - 8 - 8; // 8 bytes for CCMP header , 8 bytes for MIC
- payload_remainder = (payload_len) % 16;
- num_blocks = (payload_len) / 16;
-
-
-
- // Find start of payload
- payload_index = HeaderLen + 8; //IV+EIV
-
- for (i=0; i< num_blocks; i++)
- {
- construct_ctr_preload(ctr_preload,
- a4_exists,
- qc_exists,
- pData,
- PN,
- i+1 );
-
- aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
- bitwise_xor(aes_out, pData + payload_index, chain_buffer);
- NdisMoveMemory(pData + payload_index - 8, chain_buffer, 16);
- payload_index += 16;
- }
-
- //
- // If there is a short final block, then pad it
- // encrypt it and copy the unpadded part back
- //
- if (payload_remainder > 0)
- {
- construct_ctr_preload(ctr_preload,
- a4_exists,
- qc_exists,
- pData,
- PN,
- num_blocks + 1);
-
- NdisZeroMemory(padded_buffer, 16);
- NdisMoveMemory(padded_buffer, pData + payload_index, payload_remainder);
-
- aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
- bitwise_xor(aes_out, padded_buffer, chain_buffer);
- NdisMoveMemory(pData + payload_index - 8, chain_buffer, payload_remainder);
- payload_index += payload_remainder;
- }
-
- //
- // Descrypt the MIC
- //
- construct_ctr_preload(ctr_preload,
- a4_exists,
- qc_exists,
- pData,
- PN,
- 0);
- NdisZeroMemory(padded_buffer, 16);
- NdisMoveMemory(padded_buffer, pData + payload_index, 8);
-
- aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
- bitwise_xor(aes_out, padded_buffer, chain_buffer);
-
- NdisMoveMemory(TrailMIC, chain_buffer, 8);
-
- //
- // Calculate MIC
- //
-
- //Force the protected frame bit on
- *(pData + 1) = *(pData + 1) | 0x40;
-
- // Find start of payload
- // Because the CCMP header has been removed
- payload_index = HeaderLen;
-
- construct_mic_iv(
- mic_iv,
- qc_exists,
- a4_exists,
- pData,
- payload_len,
- PN);
-
- construct_mic_header1(
- mic_header1,
- HeaderLen,
- pData);
-
- construct_mic_header2(
- mic_header2,
- pData,
- a4_exists,
- qc_exists);
-
- aes128k128d(pWpaKey[KeyID].Key, mic_iv, aes_out);
- bitwise_xor(aes_out, mic_header1, chain_buffer);
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
- bitwise_xor(aes_out, mic_header2, chain_buffer);
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
-
- // iterate through each 16 byte payload block
- for (i = 0; i < num_blocks; i++)
- {
- bitwise_xor(aes_out, pData + payload_index, chain_buffer);
- payload_index += 16;
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
- }
-
- // Add on the final payload block if it needs padding
- if (payload_remainder > 0)
- {
- NdisZeroMemory(padded_buffer, 16);
- NdisMoveMemory(padded_buffer, pData + payload_index, payload_remainder);
-
- bitwise_xor(aes_out, padded_buffer, chain_buffer);
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
- }
-
- // aes_out contains padded mic, discard most significant
- // 8 bytes to generate 64 bit MIC
- for (i = 0 ; i < 8; i++) MIC[i] = aes_out[i];
-
- if (!NdisEqualMemory(MIC, TrailMIC, 8))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptAES, MIC Error !\n")); //MIC error.
- return FALSE;
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
- return TRUE;
-}
-
-/****************************************/
-/* aes128k128d() */
-/* Performs a 128 bit AES encrypt with */
-/* 128 bit data. */
-/****************************************/
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0;i<16; i++)
- {
- out[i] = a[i] ^ b[i];
- }
-}
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round)
-{
- UCHAR rcon;
- UCHAR sbox_key[4];
- UCHAR rcon_table[12] =
- {
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
- 0x1b, 0x36, 0x36, 0x36
- };
-
- sbox_key[0] = RTMPCkipSbox(key[13]);
- sbox_key[1] = RTMPCkipSbox(key[14]);
- sbox_key[2] = RTMPCkipSbox(key[15]);
- sbox_key[3] = RTMPCkipSbox(key[12]);
-
- rcon = rcon_table[round];
-
- xor_32(&key[0], sbox_key, &key[0]);
- key[0] = key[0] ^ rcon;
-
- xor_32(&key[4], &key[0], &key[4]);
- xor_32(&key[8], &key[4], &key[8]);
- xor_32(&key[12], &key[8], &key[12]);
-}
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0;i<4; i++)
- {
- out[i] = a[i] ^ b[i];
- }
-}
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0; i< 16; i++)
- {
- out[i] = RTMPCkipSbox(in[i]);
- }
-}
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a)
-{
- return SboxTable[(int)a];
-}
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- out[0] = in[0];
- out[1] = in[5];
- out[2] = in[10];
- out[3] = in[15];
- out[4] = in[4];
- out[5] = in[9];
- out[6] = in[14];
- out[7] = in[3];
- out[8] = in[8];
- out[9] = in[13];
- out[10] = in[2];
- out[11] = in[7];
- out[12] = in[12];
- out[13] = in[1];
- out[14] = in[6];
- out[15] = in[11];
-}
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- INT i;
- UCHAR add1b[4];
- UCHAR add1bf7[4];
- UCHAR rotl[4];
- UCHAR swap_halfs[4];
- UCHAR andf7[4];
- UCHAR rotr[4];
- UCHAR temp[4];
- UCHAR tempb[4];
-
- for (i=0 ; i<4; i++)
- {
- if ((in[i] & 0x80)== 0x80)
- add1b[i] = 0x1b;
- else
- add1b[i] = 0x00;
- }
-
- swap_halfs[0] = in[2]; /* Swap halfs */
- swap_halfs[1] = in[3];
- swap_halfs[2] = in[0];
- swap_halfs[3] = in[1];
-
- rotl[0] = in[3]; /* Rotate left 8 bits */
- rotl[1] = in[0];
- rotl[2] = in[1];
- rotl[3] = in[2];
-
- andf7[0] = in[0] & 0x7f;
- andf7[1] = in[1] & 0x7f;
- andf7[2] = in[2] & 0x7f;
- andf7[3] = in[3] & 0x7f;
-
- for (i = 3; i>0; i--) /* logical shift left 1 bit */
- {
- andf7[i] = andf7[i] << 1;
- if ((andf7[i-1] & 0x80) == 0x80)
- {
- andf7[i] = (andf7[i] | 0x01);
- }
- }
- andf7[0] = andf7[0] << 1;
- andf7[0] = andf7[0] & 0xfe;
-
- xor_32(add1b, andf7, add1bf7);
-
- xor_32(in, add1bf7, rotr);
-
- temp[0] = rotr[0]; /* Rotate right 8 bits */
- rotr[0] = rotr[1];
- rotr[1] = rotr[2];
- rotr[2] = rotr[3];
- rotr[3] = temp[0];
-
- xor_32(add1bf7, rotr, temp);
- xor_32(swap_halfs, rotl,tempb);
- xor_32(temp, tempb, out);
-}
-
+#include "../../rt2860/common/rtmp_tkip.c"
diff --git a/drivers/staging/rt2870/common/rtmp_wep.c b/drivers/staging/rt2870/common/rtmp_wep.c
index 62f9e58729d7..ae255adc9f7f 100644
--- a/drivers/staging/rt2870/common/rtmp_wep.c
+++ b/drivers/staging/rt2870/common/rtmp_wep.c
@@ -1,508 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_wep.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Wu 10-28-02 Initial
-*/
-
-#include "../rt_config.h"
-
-UINT FCSTAB_32[256] =
-{
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
- 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
- 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
- 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
- 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
- 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
- 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
- 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
- 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
- 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
- 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
- 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
- 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
- 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
- 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
- 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
- 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
- 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
- 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
- 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
- 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
- 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
- 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
- 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
- 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
- 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
- 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
- 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
- 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
- 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
- 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
- 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
- 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
- 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
- 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
- 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
- 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
- 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
- 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
- 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
- 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
- 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
- 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-/*
-UCHAR WEPKEY[] = {
- //IV
- 0x00, 0x11, 0x22,
- //WEP KEY
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
- };
- */
-
-/*
- ========================================================================
-
- Routine Description:
- Init WEP function.
-
- Arguments:
- pAd Pointer to our adapter
- pKey Pointer to the WEP KEY
- KeyId WEP Key ID
- KeyLen the length of WEP KEY
- pDest Pointer to the destination which Encryption data will store in.
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitWepEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN UCHAR KeyId,
- IN UCHAR KeyLen,
- IN OUT PUCHAR pDest)
-{
- UINT i;
- UCHAR WEPKEY[] = {
- //IV
- 0x00, 0x11, 0x22,
- //WEP KEY
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
- };
-
- pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10) && (pAd->OpMode == OPMODE_STA))
- {
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, pKey, KeyLen); //INIT SBOX, KEYLEN+3(IV)
- NdisMoveMemory(pDest, pKey, 3); //Append Init Vector
- }
- else
-#endif // CONFIG_STA_SUPPORT //
- {
- NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
-
- for(i = 0; i < 3; i++)
- WEPKEY[i] = RandomByte(pAd); //Call mlme RandomByte() function.
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); //INIT SBOX, KEYLEN+3(IV)
-
- NdisMoveMemory(pDest, WEPKEY, 3); //Append Init Vector
- }
- *(pDest+3) = (KeyId << 6); //Append KEYID
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Encrypt transimitted data
-
- Arguments:
- pAd Pointer to our adapter
- pSrc Pointer to the transimitted source data that will be encrypt
- pDest Pointer to the destination where entryption data will be store in.
- Len Indicate the length of the source data
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPEncryptData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDest,
- IN UINT Len)
-{
- pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, pSrc, Len);
- ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, pSrc, Len);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Decrypt received WEP data
-
- Arguments:
- pAdapter Pointer to our adapter
- pSrc Pointer to the received data
- Len the length of the received data
-
- Return Value:
- TRUE Decrypt WEP data success
- FALSE Decrypt WEP data failed
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN RTMPSoftDecryptWEP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pGroupKey)
-{
- UINT trailfcs;
- UINT crc32;
- UCHAR KeyIdx;
- UCHAR WEPKEY[] = {
- //IV
- 0x00, 0x11, 0x22,
- //WEP KEY
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
- };
- UCHAR *pPayload = (UCHAR *)pData + LENGTH_802_11;
- ULONG payload_len = DataByteCnt - LENGTH_802_11;
-
- NdisMoveMemory(WEPKEY, pPayload, 3); //Get WEP IV
-
- KeyIdx = (*(pPayload + 3) & 0xc0) >> 6;
- if (pGroupKey[KeyIdx].KeyLen == 0)
- return (FALSE);
-
- NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key, pGroupKey[KeyIdx].KeyLen);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, pGroupKey[KeyIdx].KeyLen + 3);
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4, payload_len - 4);
- NdisMoveMemory(&trailfcs, pPayload + payload_len - 8, 4);
- crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pPayload, payload_len - 8); //Skip last 4 bytes(FCS).
- crc32 ^= 0xffffffff; /* complement */
-
- if(crc32 != cpu2le32(trailfcs))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("! WEP Data CRC Error !\n")); //CRC error.
- return (FALSE);
- }
- return (TRUE);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Encryption Algorithm "ARCFOUR" initialize
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pKey Pointer to the WEP KEY
- KeyLen Indicate the length fo the WEP KEY
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID ARCFOUR_INIT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pKey,
- IN UINT KeyLen)
-{
- UCHAR t, u;
- UINT keyindex;
- UINT stateindex;
- PUCHAR state;
- UINT counter;
-
- state = Ctx->STATE;
- Ctx->X = 0;
- Ctx->Y = 0;
- for (counter = 0; counter < 256; counter++)
- state[counter] = (UCHAR)counter;
- keyindex = 0;
- stateindex = 0;
- for (counter = 0; counter < 256; counter++)
- {
- t = state[counter];
- stateindex = (stateindex + pKey[keyindex] + t) & 0xff;
- u = state[stateindex];
- state[stateindex] = t;
- state[counter] = u;
- if (++keyindex >= KeyLen)
- keyindex = 0;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get bytes from ARCFOUR CONTEXT (S-BOX)
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
-
- Return Value:
- UCHAR - the value of the ARCFOUR CONTEXT (S-BOX)
-
- Note:
-
- ========================================================================
-*/
-UCHAR ARCFOUR_BYTE(
- IN PARCFOURCONTEXT Ctx)
-{
- UINT x;
- UINT y;
- UCHAR sx, sy;
- PUCHAR state;
-
- state = Ctx->STATE;
- x = (Ctx->X + 1) & 0xff;
- sx = state[x];
- y = (sx + Ctx->Y) & 0xff;
- sy = state[y];
- Ctx->X = x;
- Ctx->Y = y;
- state[y] = sx;
- state[x] = sy;
-
- return(state[(sx + sy) & 0xff]);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Decryption Algorithm
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pDest Pointer to the Destination
- pSrc Pointer to the Source data
- Len Indicate the length of the Source data
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ARCFOUR_DECRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len)
-{
- UINT i;
-
- for (i = 0; i < Len; i++)
- pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Encryption Algorithm
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pDest Pointer to the Destination
- pSrc Pointer to the Source data
- Len Indicate the length of the Source dta
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID ARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len)
-{
- UINT i;
-
- for (i = 0; i < Len; i++)
- pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Encryption Algorithm which conform to the special requirement to encrypt GTK.
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pDest Pointer to the Destination
- pSrc Pointer to the Source data
- Len Indicate the length of the Source dta
-
-
- ========================================================================
-*/
-
-VOID WPAARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len)
-{
- UINT i;
- //discard first 256 bytes
- for (i = 0; i < 256; i++)
- ARCFOUR_BYTE(Ctx);
-
- for (i = 0; i < Len; i++)
- pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculate a new FCS given the current FCS and the new data.
-
- Arguments:
- Fcs the original FCS value
- Cp pointer to the data which will be calculate the FCS
- Len the length of the data
-
- Return Value:
- UINT - FCS 32 bits
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-UINT RTMP_CALC_FCS32(
- IN UINT Fcs,
- IN PUCHAR Cp,
- IN INT Len)
-{
- while (Len--)
- Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
-
- return (Fcs);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Get last FCS and encrypt it to the destination
-
- Arguments:
- pDest Pointer to the Destination
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPSetICV(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest)
-{
- pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff; /* complement */
- pAd->PrivateInfo.FCSCRC32 = cpu2le32(pAd->PrivateInfo.FCSCRC32);
-
- ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, (PUCHAR) &pAd->PrivateInfo.FCSCRC32, 4);
-}
-
+#include "../../rt2860/common/rtmp_wep.c"
diff --git a/drivers/staging/rt2870/common/rtusb_bulk.c b/drivers/staging/rt2870/common/rtusb_bulk.c
index c46d9166ccf4..7ae3e9596133 100644
--- a/drivers/staging/rt2870/common/rtusb_bulk.c
+++ b/drivers/staging/rt2870/common/rtusb_bulk.c
@@ -52,11 +52,7 @@ void RTUSB_FILL_BULK_URB (struct urb *pUrb,
void *pContext)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
usb_fill_bulk_urb(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize, (usb_complete_t)Complete, pContext);
-#else
- FILL_BULK_URB(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize, Complete, pContext);
-#endif
}
@@ -95,14 +91,12 @@ VOID RTUSBInitTxDesc(
Func,
pTxContext);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
if (pTxContext->bAggregatible)
pUrb->transfer_dma = (pTxContext->data_dma + TX_BUFFER_NORMSIZE + 2);
else
pUrb->transfer_dma = pTxContext->data_dma;
pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-#endif
}
@@ -135,10 +129,8 @@ VOID RTUSBInitHTTxDesc(
Func,
pTxContext);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
pUrb->transfer_dma = (pTxContext->data_dma + pTxContext->NextBulkOutPosition);
pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-#endif
}
@@ -168,10 +160,8 @@ VOID RTUSBInitRxDesc(
(usb_complete_t)RTUSBBulkRxComplete,
(void *)pRxContext);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
pUrb->transfer_dma = pRxContext->data_dma + pAd->NextRxBulkInPosition;
pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-#endif
}
@@ -327,6 +317,7 @@ VOID RTUSBBulkOutDataPacket(
break;
}
+ //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
if (pTxInfo->QSEL != FIFO_EDCA)
{
printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __func__, pTxInfo->QSEL);
@@ -359,7 +350,7 @@ VOID RTUSBBulkOutDataPacket(
pLastTxInfo = pTxInfo;
// Make sure we use EDCA QUEUE.
- pTxInfo->QSEL = FIFO_EDCA;
+ pTxInfo->QSEL = FIFO_EDCA; //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
ThisBulkSize += (pTxInfo->USBDMATxPktLen+4);
TmpBulkEndPos += (pTxInfo->USBDMATxPktLen+4);
@@ -375,31 +366,14 @@ VOID RTUSBBulkOutDataPacket(
bTxQLastRound = TRUE;
pHTTXContext->ENextBulkOutPosition = 8;
- #ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
- #endif // RT_BIG_ENDIAN //
-
break;
}
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
}while (TRUE);
// adjust the pTxInfo->USBDMANextVLD value of last pTxInfo.
if (pLastTxInfo)
{
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
pLastTxInfo->USBDMANextVLD = 0;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
}
/*
@@ -475,115 +449,6 @@ VOID RTUSBBulkOutDataPacket(
VOID RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
{
-#if 0 // sample, IRQ LOCK
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId;
- NTSTATUS Status;
- unsigned long IrqFlags;
-
- DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutDataPacketComplete\n"));
-
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
- Status = pUrb->status;
-
- // Store BulkOut PipeId
- BulkOutPipeId = pHTTXContext->BulkOutPipeId;
- pAd->BulkOutDataOneSecCount++;
-
- //DBGPRINT(RT_DEBUG_LOUD, ("Done-B(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", BulkOutPipeId, in_interrupt(), pHTTXContext->CurWritePosition,
- // pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad));
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- pHTTXContext->IRPPending = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- if (Status == USB_ST_NOERROR)
- {
- pAd->BulkOutComplete++;
-
- pAd->Counters8023.GoodTransmits++;
- //RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- FREE_HTTX_RING(pAd, BulkOutPipeId, pHTTXContext);
- //RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
-
- }
- else // STATUS_OTHER
- {
- PUCHAR pBuf;
-
- pAd->BulkOutCompleteOther++;
-
- pBuf = &pHTTXContext->TransferBuffer->WirelessPacket[pHTTXContext->NextBulkOutPosition];
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("BulkOutDataPacket failed: ReasonCode=%d!\n", Status));
- DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n", pAd->BulkOutReq, pAd->BulkOutComplete, pAd->BulkOutCompleteOther));
- DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOut Header:%x %x %x %x %x %x %x %x\n", pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7]));
- //DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOutCompleteCancel=0x%x, BulkOutCompleteOther=0x%x\n", pAd->BulkOutCompleteCancel, pAd->BulkOutCompleteOther));
-
- if (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST |
- fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = BulkOutPipeId;
- }
- }
-
- //
- // bInUse = TRUE, means some process are filling TX data, after that must turn on bWaitingBulkOut
- // bWaitingBulkOut = TRUE, means the TX data are waiting for bulk out.
- //
- //RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- if ((pHTTXContext->ENextBulkOutPosition != pHTTXContext->CurWritePosition) &&
- (pHTTXContext->ENextBulkOutPosition != (pHTTXContext->CurWritePosition+8)) &&
- !RTUSB_TEST_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId)))
- {
- // Indicate There is data avaliable
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
- }
- //RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protection of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-
-
- //DBGPRINT(RT_DEBUG_LOUD,("Done-A(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d\n", BulkOutPipeId, in_interrupt(),
- // pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad));
-
- switch (BulkOutPipeId)
- {
- case 0:
- pObj->ac0_dma_done_task.data = (unsigned long)pAd;
- tasklet_hi_schedule(&pObj->ac0_dma_done_task);
- break;
- case 1:
- pObj->ac1_dma_done_task.data = (unsigned long)pAd;
- tasklet_hi_schedule(&pObj->ac1_dma_done_task);
- break;
- case 2:
- pObj->ac2_dma_done_task.data = (unsigned long)pAd;
- tasklet_hi_schedule(&pObj->ac2_dma_done_task);
- break;
- case 3:
- pObj->ac3_dma_done_task.data = (unsigned long)pAd;
- tasklet_hi_schedule(&pObj->ac3_dma_done_task);
- break;
- case 4:
- pObj->hcca_dma_done_task.data = (unsigned long)pAd;
- tasklet_hi_schedule(&pObj->hcca_dma_done_task);
- break;
- }
-#else
-
-{
PHT_TX_CONTEXT pHTTXContext;
PRTMP_ADAPTER pAd;
POS_COOKIE pObj;
@@ -622,10 +487,6 @@ VOID RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
break;
}
}
-#endif
-
-
-}
/*
@@ -667,10 +528,6 @@ VOID RTUSBBulkOutNullFrame(
// Clear Null frame bulk flag
RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pNullContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
// Init Tx context descriptor
RTUSBInitTxDesc(pAd, pNullContext, 0, (usb_complete_t)RTUSBBulkOutNullFrameComplete);
@@ -695,9 +552,6 @@ VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs)
PRTMP_ADAPTER pAd;
PTX_CONTEXT pNullContext;
NTSTATUS Status;
-#if 0 // sample, IRQ LOCK
- unsigned long IrqFlags;
-#endif
POS_COOKIE pObj;
@@ -705,173 +559,10 @@ VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs)
pAd = pNullContext->pAd;
Status = pUrb->status;
-#if 0 // sample, IRQ LOCK
- // Reset Null frame context flags
- pNullContext->IRPPending = FALSE;
- pNullContext->InUse = FALSE;
-
- if (Status == USB_ST_NOERROR)
- {
- // Don't worry about the queue is empty or not, this function will check itself
- //RTMPUSBDeQueuePacket(pAd, 0);
- RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
- else // STATUS_OTHER
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out Null Frame Failed\n"));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- }
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- pAd->BulkOutPending[0] = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-#else
-
pObj = (POS_COOKIE) pAd->OS_Cookie;
pObj->null_frame_complete_task.data = (unsigned long)pUrb;
tasklet_hi_schedule(&pObj->null_frame_complete_task);
-#endif
-
-}
-
-#if 0 // For RT2870, RTS frame not used now, but maybe will use it latter.
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note: RTS frame use BulkOutPipeId = 0
-
- ========================================================================
-*/
-VOID RTUSBBulkOutRTSFrame(
- IN PRTMP_ADAPTER pAd)
-{
- PTX_CONTEXT pRTSContext = &(pAd->RTSContext);
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
- UCHAR PipeID=0;
-
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_4))
- PipeID= 3;
- else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_3))
- PipeID= 2;
- else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_2))
- PipeID= 1;
- else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL))
- PipeID= 0;
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[PipeID], IrqFlags);
- if ((pAd->BulkOutPending[PipeID] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX))
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[PipeID], IrqFlags);
- return;
- }
- pAd->BulkOutPending[PipeID] = TRUE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[PipeID], IrqFlags);
-
- // Increase Total transmit byte counter
- pAd->RalinkCounters.TransmittedByteCount += pRTSContext->BulkOutSize;
-
- DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutRTSFrame \n"));
-
- // Clear RTS frame bulk flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_RTS);
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pRTSContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
- // Init Tx context descriptor
- RTUSBInitTxDesc(pAd, pRTSContext, PipeID, (usb_complete_t)RTUSBBulkOutRTSFrameComplete);
- pRTSContext->IRPPending = TRUE;
-
- pUrb = pRTSContext->pUrb;
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutRTSFrame: Submit Tx URB failed %d\n", ret));
- return;
- }
-
- DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutRTSFrame \n"));
-
-}
-
-// RTS frame use BulkOutPipeId = 0
-VOID RTUSBBulkOutRTSFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pRTSContext;
- NTSTATUS Status;
-#if 0 // sample, IRQ LOCK
- unsigned long IrqFlags;
-#endif
- POS_COOKIE pObj;
-
- DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutRTSFrameComplete\n"));
-
- pRTSContext = (PTX_CONTEXT)pUrb->context;
- pAd = pRTSContext->pAd;
- Status = pUrb->status;
-
-#if 0 // sample, IRQ LOCK
- // Reset RTS frame context flags
- pRTSContext->IRPPending = FALSE;
- pRTSContext->InUse = FALSE;
-
- if (Status == USB_ST_NOERROR)
- {
- // Don't worry about the queue is empty or not, this function will check itself
- //RTMPUSBDeQueuePacket(pAd, pRTSContext->BulkOutPipeId);
- RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
- else // STATUS_OTHER
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out RTS Frame Failed\n"));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- }
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[pRTSContext->BulkOutPipeId] = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-#else
-
- pObj = (POS_COOKIE) pAd->OS_Cookie;
- pObj->rts_frame_complete_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->rts_frame_complete_task);
-#endif
-
- DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutRTSFrameComplete\n"));
-
}
-#endif
/*
========================================================================
@@ -930,37 +621,12 @@ VOID RTUSBBulkOutMLMEPacket(
// Clear MLME bulk flag
RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-
- //DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutMLMEPacket\n"));
-#if 0 // for debug
-{
- printk("MLME-Out, C=%d!, D=%d, F=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx);
-
- //TODO: Need to remove it when formal release
- PTXINFO_STRUC pTxInfo;
-
- pTxInfo = (PTXINFO_STRUC)pMLMEContext->TransferBuffer;
- if (pTxInfo->QSEL != FIFO_EDCA)
- {
- printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __func__, pTxInfo->QSEL);
- printk("\tMLME_Index=%d!\n", Index);
- hex_dump("Wrong QSel Pkt:", (PUCHAR)pMLMEContext->TransferBuffer, pTxInfo->USBDMATxPktLen);
- }
-}
-#endif
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pMLMEContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
// Init Tx context descriptor
RTUSBInitTxDesc(pAd, pMLMEContext, MGMTPIPEIDX, (usb_complete_t)RTUSBBulkOutMLMEPacketComplete);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
//For mgmt urb buffer, because we use sk_buff, so we need to notify the USB controller do dma mapping.
pUrb->transfer_dma = 0;
pUrb->transfer_flags &= (~URB_NO_TRANSFER_DMA_MAP);
-#endif
pUrb = pMLMEContext->pUrb;
if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
@@ -988,11 +654,6 @@ VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
NTSTATUS Status;
POS_COOKIE pObj;
int index;
-#if 0 // sample, IRQ LOCK
- unsigned long IrqFlags;
- PNDIS_PACKET pPacket;
-#endif
-
//DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutMLMEPacketComplete\n"));
pMLMEContext = (PTX_CONTEXT)pUrb->context;
@@ -1001,82 +662,8 @@ VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
Status = pUrb->status;
index = pMLMEContext->SelfIdx;
-
-#if 0 // sample, IRQ LOCK
- ASSERT((pAd->MgmtRing.TxDmaIdx == index));
- //printk("MLME-Done-B: C=%d, D=%d, F=%d, Self=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx, pMLMEContext->SelfIdx);
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
-
- if (Status != USB_ST_NOERROR)
- {
- //Bulk-Out fail status handle
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out MLME Failed, Status=%d!\n", Status));
- // TODO: How to handle about the MLMEBulkOut failed issue. Need to resend the mgmt pkt?
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
- }
- }
- pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
- RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
- // Reset MLME context flags
- pMLMEContext->IRPPending = FALSE;
- pMLMEContext->InUse = FALSE;
- pMLMEContext->bWaitingBulkOut = FALSE;
- pMLMEContext->BulkOutSize = 0;
-
- pPacket = pAd->MgmtRing.Cell[index].pNdisPacket;
- pAd->MgmtRing.Cell[index].pNdisPacket = NULL;
-
- // Increase MgmtRing Index
- INC_RING_INDEX(pAd->MgmtRing.TxDmaIdx, MGMT_RING_SIZE);
- pAd->MgmtRing.TxSwFreeIdx++;
-
- RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
- // No-matter success or fail, we free the mgmt packet.
- if (pPacket)
- RTMPFreeNdisPacket(pAd, pPacket);
-
-#if 0
- //Bulk-Out fail status handle
- if (Status != USB_ST_NOERROR)
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out MLME Failed, Status=%d!\n", Status));
- // TODO: How to handle about the MLMEBulkOut failed issue. Need to reset the endpoint?
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
- }
- }
-#endif
-
- //printk("MLME-Done-A: C=%d, D=%d, F=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx);
-
- pObj->mgmt_dma_done_task.data = (unsigned long)pAd;
- tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-
- //DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutMLMEPacketComplete\n"));
-// printk("<---RTUSBBulkOutMLMEPacketComplete, Cpu=%d, Dma=%d, SwIdx=%d!\n",
-// pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx);
-
-#else
-
pObj->mgmt_dma_done_task.data = (unsigned long)pUrb;
tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-#endif
}
@@ -1116,10 +703,6 @@ VOID RTUSBBulkOutPsPoll(
// Clear PS-Poll bulk flag
RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pPsPollContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
// Init Tx context descriptor
RTUSBInitTxDesc(pAd, pPsPollContext, MGMTPIPEIDX, (usb_complete_t)RTUSBBulkOutPsPollComplete);
@@ -1144,9 +727,6 @@ VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb,struct pt_regs *pt_regs)
PRTMP_ADAPTER pAd;
PTX_CONTEXT pPsPollContext;
NTSTATUS Status;
-#if 0 // sample, IRQ LOCK
- unsigned long IrqFlags;
-#endif
POS_COOKIE pObj;
@@ -1154,255 +734,11 @@ VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb,struct pt_regs *pt_regs)
pAd = pPsPollContext->pAd;
Status = pUrb->status;
-#if 0 // sample, IRQ LOCK
- // Reset PsPoll context flags
- pPsPollContext->IRPPending = FALSE;
- pPsPollContext->InUse = FALSE;
-
- if (Status == USB_ST_NOERROR)
- {
- // Don't worry about the queue is empty or not, this function will check itself
- RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
- else // STATUS_OTHER
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out PSPoll Failed\n"));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- }
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- pAd->BulkOutPending[0] = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-#else
-
pObj = (POS_COOKIE) pAd->OS_Cookie;
pObj->pspoll_frame_complete_task.data = (unsigned long)pUrb;
tasklet_hi_schedule(&pObj->pspoll_frame_complete_task);
-#endif
-}
-
-
-#if 0
-/*
- ========================================================================
-
- Routine Description:
- USB_RxPacket initializes a URB and uses the Rx IRP to submit it
- to USB. It checks if an Rx Descriptor is available and passes the
- the coresponding buffer to be filled. If no descriptor is available
- fails the request. When setting the completion routine we pass our
- Adapter Object as Context.
-
- Arguments:
-
- Return Value:
- TRUE found matched tuple cache
- FALSE no matched found
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBBulkReceive(
- IN PRTMP_ADAPTER pAd)
-{
- PRX_CONTEXT pRxContext;
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
-
- /* device had been closed */
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))
- return;
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-
- // Last is time point between 2 separate URB.
- if (pAd->NextRxBulkInPosition == 0)
- {
- //pAd->NextRxBulkInIndex = (pAd->NextRxBulkInIndex + 1) % (RX_RING_SIZE);
- INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE);
- }
- else if ((pAd->NextRxBulkInPosition&0x1ff) != 0)
- {
- //pAd->NextRxBulkInIndex = (pAd->NextRxBulkInIndex + 1) % (RX_RING_SIZE);
- INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("pAd->NextRxBulkInPosition = 0x%lx. End of URB.\n", pAd->NextRxBulkInPosition ));
- pAd->NextRxBulkInPosition = 0;
- }
-
- if (pAd->NextRxBulkInPosition == MAX_RXBULK_SIZE)
- pAd->NextRxBulkInPosition = 0;
-
- pRxContext = &(pAd->RxContext[pAd->NextRxBulkInIndex]);
-
- // TODO: Why need to check if pRxContext->InUsed == TRUE?
- //if ((pRxContext->InUse == TRUE) || (pRxContext->Readable == TRUE))
- if ((pRxContext->InUse == FALSE) && (pRxContext->Readable == TRUE))
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("pRxContext[%d] InUse = %d.pRxContext->Readable = %d. Return.\n", pAd->NextRxBulkInIndex,pRxContext->InUse, pRxContext->Readable ));
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- // read RxContext, Since not
-#ifdef CONFIG_STA_SUPPORT
- STARxDoneInterruptHandle(pAd, TRUE);
-#endif // CONFIG_STA_SUPPORT //
-
- //return;
- }
- pRxContext->InUse = TRUE;
- pRxContext->IRPPending= TRUE;
-
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- // Init Rx context descriptor
- NdisZeroMemory(pRxContext->TransferBuffer, BUFFER_SIZE);
- RTUSBInitRxDesc(pAd, pRxContext);
-
- pUrb = pRxContext->pUrb;
- if ((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkReceive: Submit Rx URB failed %d\n", ret));
- return;
- }
- else // success
- {
- NdisInterlockedIncrement(&pAd->PendingRx);
- pAd->BulkInReq++;
- }
-
- // read RxContext, Since not
-#ifdef CONFIG_STA_SUPPORT
- STARxDoneInterruptHandle(pAd, FALSE);
-#endif // CONFIG_STA_SUPPORT //
-}
-
-/*
- ========================================================================
-
- Routine Description:
- This routine process Rx Irp and call rx complete function.
-
- Arguments:
- DeviceObject Pointer to the device object for next lower
- device. DeviceObject passed in here belongs to
- the next lower driver in the stack because we
- were invoked via IoCallDriver in USB_RxPacket
- AND it is not OUR device object
- Irp Ptr to completed IRP
- Context Ptr to our Adapter object (context specified
- in IoSetCompletionRoutine
-
- Return Value:
- Always returns STATUS_MORE_PROCESSING_REQUIRED
-
- Note:
- Always returns STATUS_MORE_PROCESSING_REQUIRED
- ========================================================================
-*/
-VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
-#if 0
- PRX_CONTEXT pRxContext;
- PRTMP_ADAPTER pAd;
- NTSTATUS Status;
-// POS_COOKIE pObj;
-
- pRxContext = (PRX_CONTEXT)pUrb->context;
- pAd = pRxContext->pAd;
-// pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-
- Status = pUrb->status;
- //pRxContext->pIrp = NULL;
-
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
-
- if (Status == USB_ST_NOERROR)
- {
- pAd->BulkInComplete++;
- pRxContext->Readable = TRUE;
- pAd->NextRxBulkInPosition = 0;
-
- }
- else // STATUS_OTHER
- {
- pAd->BulkInCompleteFail++;
- // Still read this packet although it may comtain wrong bytes.
- pRxContext->Readable = FALSE;
- // Parsing all packets. because after reset, the index will reset to all zero.
-
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk In Failed. Status = %d\n", Status));
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("==>NextRxBulkInIndex=0x%x, NextRxBulkInReadIndex=0x%x, TransferBufferLength= 0x%x\n",
- pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex, pRxContext->pUrb->actual_length));
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, NULL, 0);
- }
- //pUrb = NULL;
- }
-
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET)) &&
-// (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- RTUSBBulkReceive(pAd);
-#if 0
-#if 1
- STARxDoneInterruptHandle(pAd, FALSE);
-#else
- pObj->rx_bh.data = (unsigned long)pUrb;
- tasklet_schedule(&pObj->rx_bh);
-#endif
-#endif
- }
-
- // Call RxPacket to process packet and return the status
- NdisInterlockedDecrement(&pAd->PendingRx);
-#else
-
-
- // use a receive tasklet to handle received packets;
- // or sometimes hardware IRQ will be disabled here, so we can not
- // use spin_lock_bh()/spin_unlock_bh() after IRQ is disabled. :<
- PRX_CONTEXT pRxContext;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
-
-
- pRxContext = (PRX_CONTEXT)pUrb->context;
- pAd = pRxContext->pAd;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- pObj->rx_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->rx_done_task);
-#endif
}
-#else
-
VOID DoBulkIn(IN RTMP_ADAPTER *pAd)
{
PRX_CONTEXT pRxContext;
@@ -1441,14 +777,6 @@ VOID DoBulkIn(IN RTMP_ADAPTER *pAd)
}
else
{ // success
-#if 0
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext->IRPPending = TRUE;
- //NdisInterlockedIncrement(&pAd->PendingRx);
- pAd->PendingRx++;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- pAd->BulkInReq++;
-#endif
ASSERT((pRxContext->InUse == pRxContext->IRPPending));
//printk("BIDone, Pend=%d,BIIdx=%d,BIRIdx=%d!\n", pAd->PendingRx, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex);
}
@@ -1508,10 +836,7 @@ VOID RTUSBBulkReceive(
RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
// read RxContext, Since not
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- STARxDoneInterruptHandle(pAd, TRUE);
-#endif // CONFIG_STA_SUPPORT //
+ STARxDoneInterruptHandle(pAd, TRUE);
// Finish to handle this bulkIn buffer.
RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
@@ -1579,8 +904,6 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs)
}
-#endif
-
/*
@@ -1601,51 +924,8 @@ VOID RTUSBKickBulkOut(
{
// BulkIn Reset will reset whole USB PHY. So we need to make sure fRTMP_ADAPTER_BULKIN_RESET not flaged.
if (!RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX)
-#ifdef RALINK_ATE
- && !(ATE_ON(pAd))
-#endif // RALINK_ATE //
)
{
-#if 0 // not used now in RT28xx, but may used latter.
- // 1. Data Fragment has highest priority
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 0, pAd->NextBulkOutIndex[0]);
- }
- }
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG_2))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 1, pAd->NextBulkOutIndex[1]);
- }
- }
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG_3))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 2, pAd->NextBulkOutIndex[2]);
- }
- }
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_FRAG_4))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 3, pAd->NextBulkOutIndex[3]);
- }
- }
-#endif
-
// 2. PS-Poll frame is next
if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL))
{
@@ -1696,6 +976,17 @@ VOID RTUSBKickBulkOut(
RTUSBBulkOutDataPacket(pAd, 3, pAd->NextBulkOutIndex[3]);
}
}
+#ifdef RT30xx
+ //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
+ if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_5))
+ {
+ if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
+ (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
+ ))
+ {
+ }
+ }
+#endif
// 7. Null frame is the last
else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL))
@@ -1712,18 +1003,6 @@ VOID RTUSBKickBulkOut(
}
}
-#ifdef RALINK_ATE
- /* If the mode is in ATE mode. */
- else if((ATE_ON(pAd)) &&
- !RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX))// PETER : watch out !
- {
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE))
- {
- ATE_RTUSBBulkOutDataPacket(pAd, 0);
- }
- }
-#endif // RALINK_ATE //
-
}
/*
@@ -1778,24 +1057,6 @@ VOID RTUSBCleanUpMLMEBulkOutQueue(
IN PRTMP_ADAPTER pAd)
{
DBGPRINT(RT_DEBUG_TRACE, ("--->CleanUpMLMEBulkOutQueue\n"));
-
-#if 0 // Do nothing!
- NdisAcquireSpinLock(&pAd->MLMEBulkOutLock);
- while (pAd->PrioRingTxCnt > 0)
- {
- pAd->MLMEContext[pAd->PrioRingFirstIndex].InUse = FALSE;
-
- pAd->PrioRingFirstIndex++;
- if (pAd->PrioRingFirstIndex >= MGMT_RING_SIZE)
- {
- pAd->PrioRingFirstIndex = 0;
- }
-
- pAd->PrioRingTxCnt--;
- }
- NdisReleaseSpinLock(&pAd->MLMEBulkOutLock);
-#endif
-
DBGPRINT(RT_DEBUG_TRACE, ("<---CleanUpMLMEBulkOutQueue\n"));
}
@@ -1906,14 +1167,6 @@ VOID RTUSBCancelPendingBulkOutIRP(
RTMPusecDelay(200);
}
-#ifdef RALINK_ATE
- pHTTXContext->bCopySavePad = 0;
- pHTTXContext->CurWritePosition = 0;
- pHTTXContext->CurWriteRealPos = 0;
- pHTTXContext->bCurWriting = FALSE;
- pHTTXContext->NextBulkOutPosition = 0;
- pHTTXContext->ENextBulkOutPosition = 0;
-#endif // RALINK_ATE //
pAd->BulkOutPending[Idx] = FALSE;
}
diff --git a/drivers/staging/rt2870/common/rtusb_data.c b/drivers/staging/rt2870/common/rtusb_data.c
index 5a0d78389f41..6b003f63372e 100644
--- a/drivers/staging/rt2870/common/rtusb_data.c
+++ b/drivers/staging/rt2870/common/rtusb_data.c
@@ -135,24 +135,11 @@ BOOLEAN RTUSBNeedQueueBackForAgg(
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
if ((pHTTXContext->IRPPending == TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */)
{
-#if 0
- if ((pHTTXContext->CurWritePosition <= 8) &&
- (pHTTXContext->NextBulkOutPosition > 8 && (pHTTXContext->NextBulkOutPosition+MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT))
- {
- needQueBack = TRUE;
- }
- else if ((pHTTXContext->CurWritePosition < pHTTXContext->NextBulkOutPosition) &&
- ((pHTTXContext->NextBulkOutPosition + MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT))
- {
- needQueBack = TRUE;
- }
-#else
if ((pHTTXContext->CurWritePosition < pHTTXContext->ENextBulkOutPosition) &&
(((pHTTXContext->ENextBulkOutPosition+MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT) || (pHTTXContext->CurWritePosition > MAX_AGGREGATION_SIZE)))
{
needQueBack = TRUE;
}
-#endif
else if ((pHTTXContext->CurWritePosition > pHTTXContext->ENextBulkOutPosition) &&
((pHTTXContext->ENextBulkOutPosition + MAX_AGGREGATION_SIZE) < pHTTXContext->CurWritePosition))
{
diff --git a/drivers/staging/rt2870/common/rtusb_io.c b/drivers/staging/rt2870/common/rtusb_io.c
index afde136a9a0c..fd1b0c18f2a0 100644
--- a/drivers/staging/rt2870/common/rtusb_io.c
+++ b/drivers/staging/rt2870/common/rtusb_io.c
@@ -110,6 +110,12 @@ NTSTATUS RTUSBFirmwareWrite(
Status = RTUSBWriteMACRegister(pAd, 0x701c, 0xffffffff);
Status = RTUSBFirmwareRun(pAd);
+#ifdef RT30xx
+ RTMPusecDelay(10000);
+ RTUSBWriteMACRegister(pAd,H2M_MAILBOX_CSR,0);
+ AsicSendCommandToMcu(pAd, 0x72, 0x00, 0x00, 0x00);//reset rf by MCU supported by new firmware
+#endif
+
return Status;
}
@@ -665,6 +671,7 @@ NTSTATUS RTUSBWriteRFRegister(
return STATUS_SUCCESS;
}
+#ifndef RT30xx
/*
========================================================================
@@ -772,6 +779,7 @@ NTSTATUS RT30xxReadRFRegister(
return STATUS_SUCCESS;
}
+#endif /* RT30xx */
/*
========================================================================
@@ -796,6 +804,14 @@ NTSTATUS RTUSBReadEEPROM(
{
NTSTATUS Status = STATUS_SUCCESS;
+#ifdef RT30xx
+ if(pAd->bUseEfuse)
+ {
+ Status =eFuseRead(pAd, Offset, pData, length);
+ }
+ else
+#endif // RT30xx //
+ {
Status = RTUSB_VendorRequest(
pAd,
(USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK),
@@ -805,6 +821,7 @@ NTSTATUS RTUSBReadEEPROM(
Offset,
pData,
length);
+ }
return Status;
}
@@ -832,6 +849,14 @@ NTSTATUS RTUSBWriteEEPROM(
{
NTSTATUS Status = STATUS_SUCCESS;
+#ifdef RT30xx
+ if(pAd->bUseEfuse)
+ {
+ Status = eFuseWrite(pAd, Offset, pData, length);
+ }
+ else
+#endif // RT30xx //
+ {
Status = RTUSB_VendorRequest(
pAd,
USBD_TRANSFER_DIRECTION_OUT,
@@ -841,6 +866,7 @@ NTSTATUS RTUSBWriteEEPROM(
Offset,
pData,
length);
+ }
return Status;
}
@@ -957,9 +983,13 @@ NDIS_STATUS RTUSBEnqueueCmdFromNdis(
PCmdQElmt cmdqelmt = NULL;
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-
+#ifndef RT30xx
BUG_ON(pObj->RTUSBCmdThr_task == NULL);
CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task))
+#endif
+#ifdef RT30xx
+ if (pObj->RTUSBCmdThr_pid < 0)
+#endif
return (NDIS_STATUS_RESOURCES);
status = RTMPAllocateMemory((PVOID *)&cmdqelmt, sizeof(CmdQElmt));
@@ -1194,21 +1224,6 @@ NTSTATUS RTUSB_VendorRequest(
void *tmpBuf = TransferBuffer;
// Acquire Control token
-#ifdef INF_AMAZON_SE
- //Semaphore fix INF_AMAZON_SE hang
- //pAd->UsbVendorReqBuf is the swap for DEVICE_VENDOR_REQUEST_IN to fix dma bug.
- ret = down_interruptible(&(pAd->UsbVendorReq_semaphore));
- if (pAd->UsbVendorReqBuf)
- {
- ASSERT(TransferBufferLength <MAX_PARAM_BUFFER_SIZE);
-
- tmpBuf = (void *)pAd->UsbVendorReqBuf;
- NdisZeroMemory(pAd->UsbVendorReqBuf, TransferBufferLength);
-
- if (RequestType == DEVICE_VENDOR_REQUEST_OUT)
- NdisMoveMemory(tmpBuf, TransferBuffer, TransferBufferLength);
- }
-#endif // INF_AMAZON_SE //
do {
if( RequestType == DEVICE_VENDOR_REQUEST_OUT)
ret=usb_control_msg(pObj->pUsb_Dev, usb_sndctrlpipe( pObj->pUsb_Dev, 0 ), Request, RequestType, Value,Index, tmpBuf, TransferBufferLength, CONTROL_TIMEOUT_JIFFIES);
@@ -1227,12 +1242,6 @@ NTSTATUS RTUSB_VendorRequest(
}
} while((ret < 0) && (retryCount < MAX_RETRY_COUNT));
-#ifdef INF_AMAZON_SE
- if ((pAd->UsbVendorReqBuf) && (RequestType == DEVICE_VENDOR_REQUEST_IN))
- NdisMoveMemory(TransferBuffer, tmpBuf, TransferBufferLength);
- up(&(pAd->UsbVendorReq_semaphore));
-#endif // INF_AMAZON_SE //
-
if (ret < 0) {
// DBGPRINT(RT_DEBUG_ERROR, ("USBVendorRequest failed ret=%d \n",ret));
DBGPRINT(RT_DEBUG_ERROR, ("RTUSB_VendorRequest failed(%d),TxFlags=0x%x, ReqType=%s, Req=0x%x, Index=0x%x\n",
@@ -1243,28 +1252,6 @@ NTSTATUS RTUSB_VendorRequest(
if ((TransferBuffer!= NULL) && (TransferBufferLength > 0))
hex_dump("Failed TransferBuffer value", TransferBuffer, TransferBufferLength);
}
-
-#if 0
- // retry
- if (ret < 0) {
- int temp_i=0;
- DBGPRINT(RT_DEBUG_ERROR, ("USBVendorRequest failed ret=%d, \n",ret));
- ret = 0;
- do
- {
- if( RequestType == DEVICE_VENDOR_REQUEST_OUT)
- ret=usb_control_msg(pObj->pUsb_Dev, usb_sndctrlpipe( pObj->pUsb_Dev, 0 ), Request, RequestType, Value,Index, TransferBuffer, TransferBufferLength, CONTROL_TIMEOUT_JIFFIES);
- else if(RequestType == DEVICE_VENDOR_REQUEST_IN)
- ret=usb_control_msg(pObj->pUsb_Dev, usb_rcvctrlpipe( pObj->pUsb_Dev, 0 ), Request, RequestType, Value,Index, TransferBuffer, TransferBufferLength, CONTROL_TIMEOUT_JIFFIES);
- temp_i++;
- } while( (ret < 0) && (temp_i <= 1) );
-
- if( ret >= 0)
- return ret;
-
- }
-#endif
-
}
return ret;
}
@@ -1324,21 +1311,8 @@ VOID CMDHandler(
{
case CMDTHREAD_CHECK_GPIO:
{
-#ifdef CONFIG_STA_SUPPORT
UINT32 data;
-#endif // CONFIG_STA_SUPPORT //
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
-
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Read GPIO pin2 as Hardware controlled radio state
@@ -1374,17 +1348,14 @@ VOID CMDHandler(
}
}
}
-#endif // CONFIG_STA_SUPPORT //
}
break;
-#ifdef CONFIG_STA_SUPPORT
case CMDTHREAD_QKERIODIC_EXECUT:
{
StaQuickResponeForRateUpExec(NULL, pAd, NULL, NULL);
}
break;
-#endif // CONFIG_STA_SUPPORT //
case CMDTHREAD_RESET_BULK_OUT:
{
@@ -1394,9 +1365,7 @@ VOID CMDHandler(
PHT_TX_CONTEXT pHTTXContext;
// RTMP_TX_RING *pTxRing;
unsigned long IrqFlags;
-#ifdef RALINK_ATE
- PTX_CONTEXT pNullContext = &(pAd->NullContext);
-#endif // RALINK_ATE //
+
DBGPRINT_RAW(RT_DEBUG_TRACE, ("CmdThread : CMDTHREAD_RESET_BULK_OUT(ResetPipeid=0x%0x)===>\n", pAd->bulkResetPipeid));
// All transfers must be aborted or cancelled before attempting to reset the pipe.
//RTUSBCancelPendingBulkOutIRP(pAd);
@@ -1459,32 +1428,6 @@ VOID CMDHandler(
//NdisReleaseSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]);
RTMP_INT_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
/*-----------------------------------------------------------------------------------------------*/
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- pNullContext->IRPPending = TRUE;
- //
- // If driver is still in ATE TXFRAME mode,
- // keep on transmitting ATE frames.
- //
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("pAd->ate.Mode == %d\npAd->ContinBulkOut == %d\npAd->BulkOutRemained == %d\n", pAd->ate.Mode, pAd->ContinBulkOut, atomic_read(&pAd->BulkOutRemained)));
- if((pAd->ate.Mode == ATE_TXFRAME) && ((pAd->ContinBulkOut == TRUE) || (atomic_read(&pAd->BulkOutRemained) > 0)))
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("After CMDTHREAD_RESET_BULK_OUT, continue to bulk out frames !\n"));
-
- // Init Tx context descriptor
- RTUSBInitTxDesc(pAd, pNullContext, 0/* pAd->bulkResetPipeid */, (usb_complete_t)ATE_RTUSBBulkOutDataPacketComplete);
-
- if((ret = RTUSB_SUBMIT_URB(pNullContext->pUrb))!=0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ATE_RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret));
- }
-
- pAd->BulkOutReq++;
- }
- }
- else
-#endif // RALINK_ATE //
/*-----------------------------------------------------------------------------------------------*/
{
RTUSBInitHTTxDesc(pAd, pHTTXContext, pAd->bulkResetPipeid, pHTTXContext->BulkOutSize, (usb_complete_t)RTUSBBulkOutDataPacketComplete);
@@ -1597,19 +1540,6 @@ VOID CMDHandler(
{
UINT32 MACValue;
/*-----------------------------------------------------------------------------------------------*/
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if((pAd->PendingRx > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("ATE : BulkIn IRP Pending!!!\n"));
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
- RTMPusecDelay(100000);
- pAd->PendingRx = 0;
- }
- }
- else
-#endif // RALINK_ATE //
/*-----------------------------------------------------------------------------------------------*/
{
//while ((atomic_read(&pAd->PendingRx) > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
@@ -1699,15 +1629,6 @@ VOID CMDHandler(
}
else
{ // success
-#if 0
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext->IRPPending = TRUE;
- //NdisInterlockedIncrement(&pAd->PendingRx);
- pAd->PendingRx++;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- pAd->BulkInReq++;
-#endif
- //printk("BIDone, Pend=%d,BIIdx=%d,BIRIdx=%d!\n", pAd->PendingRx, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex);
DBGPRINT_RAW(RT_DEBUG_TRACE, ("CMDTHREAD_RESET_BULK_IN: Submit Rx URB Done, status=%d!\n", pUrb->status));
ASSERT((pRxContext->InUse == pRxContext->IRPPending));
}
@@ -1765,7 +1686,6 @@ VOID CMDHandler(
case CMDTHREAD_SET_ASIC_WCID_CIPHER:
{
-#ifdef CONFIG_STA_SUPPORT
RT_SET_ASIC_WCID_ATTRI SetAsicWcidAttri;
USHORT offset;
UINT32 MACRValue = 0;
@@ -1817,46 +1737,46 @@ VOID CMDHandler(
RTUSBWriteMACRegister(pAd, SHARED_KEY_MODE_BASE+4*(0/2), csr1.word);
}
-#endif // CONFIG_STA_SUPPORT //
}
break;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- // avoid in interrupt when write key
+#ifdef RT30xx
+//Benson modified for USB interface, avoid in interrupt when write key, 20080724 -->
case RT_CMD_SET_KEY_TABLE: //General call for AsicAddPairwiseKeyEntry()
- {
- RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
- KeyInfo = *((PRT_ADD_PAIRWISE_KEY_ENTRY)(pData));
- AsicAddPairwiseKeyEntry(pAd,
- KeyInfo.MacAddr,
- (UCHAR)KeyInfo.MacTabMatchWCID,
- &KeyInfo.CipherKey);
- }
+ {
+ RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
+ KeyInfo = *((PRT_ADD_PAIRWISE_KEY_ENTRY)(pData));
+ AsicAddPairwiseKeyEntry(pAd,
+ KeyInfo.MacAddr,
+ (UCHAR)KeyInfo.MacTabMatchWCID,
+ &KeyInfo.CipherKey);
+ }
break;
-
case RT_CMD_SET_RX_WCID_TABLE: //General call for RTMPAddWcidAttributeEntry()
- {
- PMAC_TABLE_ENTRY pEntry ;
- pEntry = (PMAC_TABLE_ENTRY)(pData);
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pEntry->PairwiseKey.CipherAlg,
- pEntry);
+ {
+ PMAC_TABLE_ENTRY pEntry;
+ UCHAR KeyIdx;
+ UCHAR CipherAlg;
+ UCHAR ApIdx;
+
+ pEntry = (PMAC_TABLE_ENTRY)(pData);
+
+ RTMPAddWcidAttributeEntry(
+ pAd,
+ ApIdx,
+ KeyIdx,
+ CipherAlg,
+ pEntry);
}
- break;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
+ break;
+//Benson modified for USB interface, avoid in interrupt when write key, 20080724 <--
+#endif
case CMDTHREAD_SET_CLIENT_MAC_ENTRY:
{
MAC_TABLE_ENTRY *pEntry;
pEntry = (MAC_TABLE_ENTRY *)pData;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
AsicRemovePairwiseKeyEntry(pAd, pEntry->apidx, (UCHAR)pEntry->Aid);
if ((pEntry->AuthMode <= Ndis802_11AuthModeAutoSwitch) && (pEntry->WepStatus == Ndis802_11Encryption1Enabled))
@@ -1891,7 +1811,6 @@ VOID CMDHandler(
RTUSBWriteMACRegister(pAd, offset, 0);
}
}
-#endif // CONFIG_STA_SUPPORT //
AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
printk("UpdateRxWCIDTable(): Aid=%d, Addr=%02x:%02x:%02x:%02x:%02x:%02x!\n", pEntry->Aid,
@@ -1899,9 +1818,18 @@ VOID CMDHandler(
}
break;
+#ifdef RT30xx
+// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
+ case CMDTHREAD_UPDATE_PROTECT:
+ {
+ AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
+ }
+ break;
+// end johnli
+#endif
+
case OID_802_11_ADD_WEP:
{
-#ifdef CONFIG_STA_SUPPORT
UINT i;
UINT32 KeyIdx;
PNDIS_802_11_WEP pWepKey;
@@ -1975,7 +1903,6 @@ VOID CMDHandler(
AsicAddSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx, CipherAlg, pWepKey->KeyMaterial, NULL, NULL);
DBGPRINT(RT_DEBUG_TRACE, ("CmdThread::OID_802_11_ADD_WEP (KeyIdx=%d, Len=%d-byte)\n", KeyIdx, pWepKey->KeyLength));
}
-#endif // CONFIG_STA_SUPPORT //
}
break;
diff --git a/drivers/staging/rt2870/common/spectrum.c b/drivers/staging/rt2870/common/spectrum.c
index 74380958eb70..1cf2c263f452 100644
--- a/drivers/staging/rt2870/common/spectrum.c
+++ b/drivers/staging/rt2870/common/spectrum.c
@@ -1,1876 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- action.c
-
- Abstract:
- Handle association related requests either from WSTA or from local MLME
-
- Revision History:
- Who When What
- --------- ---------- ----------------------------------------------
- Fonchi Wu 2008 created for 802.11h
- */
-
-#include "../rt_config.h"
-#include "action.h"
-
-VOID MeasureReqTabInit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisAllocateSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
-
- pAd->CommonCfg.pMeasureReqTab = kmalloc(sizeof(MEASURE_REQ_TAB), GFP_ATOMIC);
- if (pAd->CommonCfg.pMeasureReqTab)
- NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB));
- else
- DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __func__));
-
- return;
-}
-
-VOID MeasureReqTabExit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisFreeSpinLock(pAd->CommonCfg.MeasureReqTabLock);
-
- if (pAd->CommonCfg.pMeasureReqTab)
- kfree(pAd->CommonCfg.pMeasureReqTab);
- pAd->CommonCfg.pMeasureReqTab = NULL;
-
- return;
-}
-
-static PMEASURE_REQ_ENTRY MeasureReqLookUp(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- UINT HashIdx;
- PMEASURE_REQ_TAB pTab = pAd->CommonCfg.pMeasureReqTab;
- PMEASURE_REQ_ENTRY pEntry = NULL;
- PMEASURE_REQ_ENTRY pPrevEntry = NULL;
-
- if (pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
- return NULL;
- }
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
-
- HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(DialogToken);
- pEntry = pTab->Hash[HashIdx];
-
- while (pEntry)
- {
- if (pEntry->DialogToken == DialogToken)
- break;
- else
- {
- pPrevEntry = pEntry;
- pEntry = pEntry->pNext;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-
- return pEntry;
-}
-
-static PMEASURE_REQ_ENTRY MeasureReqInsert(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- INT i;
- ULONG HashIdx;
- PMEASURE_REQ_TAB pTab = pAd->CommonCfg.pMeasureReqTab;
- PMEASURE_REQ_ENTRY pEntry = NULL, pCurrEntry;
- ULONG Now;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
- return NULL;
- }
-
- pEntry = MeasureReqLookUp(pAd, DialogToken);
- if (pEntry == NULL)
- {
- RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
- for (i = 0; i < MAX_MEASURE_REQ_TAB_SIZE; i++)
- {
- NdisGetSystemUpTime(&Now);
- pEntry = &pTab->Content[i];
-
- if ((pEntry->Valid == TRUE)
- && RTMP_TIME_AFTER((unsigned long)Now, (unsigned long)(pEntry->lastTime + MQ_REQ_AGE_OUT)))
- {
- PMEASURE_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PMEASURE_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(MEASURE_REQ_ENTRY));
- pTab->Size--;
-
- break;
- }
-
- if (pEntry->Valid == FALSE)
- break;
- }
-
- if (i < MAX_MEASURE_REQ_TAB_SIZE)
- {
- NdisGetSystemUpTime(&Now);
- pEntry->lastTime = Now;
- pEntry->Valid = TRUE;
- pEntry->DialogToken = DialogToken;
- pTab->Size++;
- }
- else
- {
- pEntry = NULL;
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __func__));
- }
-
- // add this Neighbor entry into HASH table
- if (pEntry)
- {
- HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(DialogToken);
- if (pTab->Hash[HashIdx] == NULL)
- {
- pTab->Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pTab->Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
- }
-
- return pEntry;
-}
-
-static VOID MeasureReqDelete(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- PMEASURE_REQ_TAB pTab = pAd->CommonCfg.pMeasureReqTab;
- PMEASURE_REQ_ENTRY pEntry = NULL;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
- return;
- }
-
- // if empty, return
- if (pTab->Size == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pMeasureReqTab empty.\n"));
- return;
- }
-
- pEntry = MeasureReqLookUp(pAd, DialogToken);
- if (pEntry != NULL)
- {
- PMEASURE_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PMEASURE_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(MEASURE_REQ_ENTRY));
- pTab->Size--;
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
- }
-
- return;
-}
-
-VOID TpcReqTabInit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisAllocateSpinLock(&pAd->CommonCfg.TpcReqTabLock);
-
- pAd->CommonCfg.pTpcReqTab = kmalloc(sizeof(TPC_REQ_TAB), GFP_ATOMIC);
- if (pAd->CommonCfg.pTpcReqTab)
- NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB));
- else
- DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __func__));
-
- return;
-}
-
-VOID TpcReqTabExit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisFreeSpinLock(pAd->CommonCfg.TpcReqTabLock);
-
- if (pAd->CommonCfg.pTpcReqTab)
- kfree(pAd->CommonCfg.pTpcReqTab);
- pAd->CommonCfg.pTpcReqTab = NULL;
-
- return;
-}
-
-static PTPC_REQ_ENTRY TpcReqLookUp(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- UINT HashIdx;
- PTPC_REQ_TAB pTab = pAd->CommonCfg.pTpcReqTab;
- PTPC_REQ_ENTRY pEntry = NULL;
- PTPC_REQ_ENTRY pPrevEntry = NULL;
-
- if (pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
- return NULL;
- }
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
-
- HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(DialogToken);
- pEntry = pTab->Hash[HashIdx];
-
- while (pEntry)
- {
- if (pEntry->DialogToken == DialogToken)
- break;
- else
- {
- pPrevEntry = pEntry;
- pEntry = pEntry->pNext;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-
- return pEntry;
-}
-
-
-static PTPC_REQ_ENTRY TpcReqInsert(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- INT i;
- ULONG HashIdx;
- PTPC_REQ_TAB pTab = pAd->CommonCfg.pTpcReqTab;
- PTPC_REQ_ENTRY pEntry = NULL, pCurrEntry;
- ULONG Now;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
- return NULL;
- }
-
- pEntry = TpcReqLookUp(pAd, DialogToken);
- if (pEntry == NULL)
- {
- RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
- for (i = 0; i < MAX_TPC_REQ_TAB_SIZE; i++)
- {
- NdisGetSystemUpTime(&Now);
- pEntry = &pTab->Content[i];
-
- if ((pEntry->Valid == TRUE)
- && RTMP_TIME_AFTER((unsigned long)Now, (unsigned long)(pEntry->lastTime + TPC_REQ_AGE_OUT)))
- {
- PTPC_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PTPC_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(TPC_REQ_ENTRY));
- pTab->Size--;
-
- break;
- }
-
- if (pEntry->Valid == FALSE)
- break;
- }
-
- if (i < MAX_TPC_REQ_TAB_SIZE)
- {
- NdisGetSystemUpTime(&Now);
- pEntry->lastTime = Now;
- pEntry->Valid = TRUE;
- pEntry->DialogToken = DialogToken;
- pTab->Size++;
- }
- else
- {
- pEntry = NULL;
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __func__));
- }
-
- // add this Neighbor entry into HASH table
- if (pEntry)
- {
- HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(DialogToken);
- if (pTab->Hash[HashIdx] == NULL)
- {
- pTab->Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pTab->Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
- }
-
- return pEntry;
-}
-
-static VOID TpcReqDelete(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- PTPC_REQ_TAB pTab = pAd->CommonCfg.pTpcReqTab;
- PTPC_REQ_ENTRY pEntry = NULL;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
- return;
- }
-
- // if empty, return
- if (pTab->Size == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pTpcReqTab empty.\n"));
- return;
- }
-
- pEntry = TpcReqLookUp(pAd, DialogToken);
- if (pEntry != NULL)
- {
- PTPC_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PTPC_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(TPC_REQ_ENTRY));
- pTab->Size--;
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Get Current TimeS tamp.
-
- Parametrs:
-
- Return : Current Time Stamp.
- ==========================================================================
- */
-static UINT64 GetCurrentTimeStamp(
- IN PRTMP_ADAPTER pAd)
-{
- // get current time stamp.
- return 0;
-}
-
-/*
- ==========================================================================
- Description:
- Get Current Transmit Power.
-
- Parametrs:
-
- Return : Current Time Stamp.
- ==========================================================================
- */
-static UINT8 GetCurTxPwr(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 Wcid)
-{
- return 16; /* 16 dBm */
-}
-
-/*
- ==========================================================================
- Description:
- Insert Dialog Token into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Dialog token.
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertDialogToken(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 DialogToken)
-{
- ULONG TempLen;
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &DialogToken,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert TPC Request IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
-
- Return : None.
- ==========================================================================
- */
- static VOID InsertTpcReqIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen)
-{
- ULONG TempLen;
- ULONG Len = 0;
- UINT8 ElementID = IE_TPC_REQUEST;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert TPC Report IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Transmit Power.
- 4. Link Margin.
-
- Return : None.
- ==========================================================================
- */
- static VOID InsertTpcReportIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 TxPwr,
- IN UINT8 LinkMargin)
-{
- ULONG TempLen;
- ULONG Len = sizeof(TPC_REPORT_INFO);
- UINT8 ElementID = IE_TPC_REPORT;
- TPC_REPORT_INFO TpcReportIE;
-
- TpcReportIE.TxPwr = TxPwr;
- TpcReportIE.LinkMargin = LinkMargin;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, &TpcReportIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert Channel Switch Announcement IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. channel switch announcement mode.
- 4. new selected channel.
- 5. channel switch announcement count.
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertChSwAnnIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 ChSwMode,
- IN UINT8 NewChannel,
- IN UINT8 ChSwCnt)
-{
- ULONG TempLen;
- ULONG Len = sizeof(CH_SW_ANN_INFO);
- UINT8 ElementID = IE_CHANNEL_SWITCH_ANNOUNCEMENT;
- CH_SW_ANN_INFO ChSwAnnIE;
-
- ChSwAnnIE.ChSwMode = ChSwMode;
- ChSwAnnIE.Channel = NewChannel;
- ChSwAnnIE.ChSwCnt = ChSwCnt;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, &ChSwAnnIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert Measure Request IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Measure Token.
- 4. Measure Request Mode.
- 5. Measure Request Type.
- 6. Measure Channel.
- 7. Measure Start time.
- 8. Measure Duration.
-
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertMeasureReqIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN PMEASURE_REQ_INFO pMeasureReqIE)
-{
- ULONG TempLen;
- UINT8 Len = sizeof(MEASURE_REQ_INFO);
- UINT8 ElementID = IE_MEASUREMENT_REQUEST;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, pMeasureReqIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert Measure Report IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Measure Token.
- 4. Measure Request Mode.
- 5. Measure Request Type.
- 6. Length of Report Infomation
- 7. Pointer of Report Infomation Buffer.
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertMeasureReportIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN PMEASURE_REPORT_INFO pMeasureReportIE,
- IN UINT8 ReportLnfoLen,
- IN PUINT8 pReportInfo)
-{
- ULONG TempLen;
- ULONG Len;
- UINT8 ElementID = IE_MEASUREMENT_REPORT;
-
- Len = sizeof(MEASURE_REPORT_INFO) + ReportLnfoLen;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, pMeasureReportIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- if ((ReportLnfoLen > 0) && (pReportInfo != NULL))
- {
- MakeOutgoingFrame(pFrameBuf + *pFrameLen, &TempLen,
- ReportLnfoLen, pReportInfo,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
- }
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 MeasureCh,
- IN UINT16 MeasureDuration)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- HEADER_802_11 ActHdr;
- MEASURE_REQ_INFO MeasureReqIE;
- UINT8 RmReqDailogToken = RandomByte(pAd);
- UINT64 MeasureStartTime = GetCurrentTimeStamp(pAd);
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_MRQ);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, MeasureToken);
-
- // prepare Measurement IE.
- NdisZeroMemory(&MeasureReqIE, sizeof(MEASURE_REQ_INFO));
- MeasureReqIE.Token = RmReqDailogToken;
- MeasureReqIE.ReqMode.word = MeasureReqMode;
- MeasureReqIE.ReqType = MeasureReqType;
- MeasureReqIE.MeasureReq.ChNum = MeasureCh;
- MeasureReqIE.MeasureReq.MeasureStartTime = cpu2le64(MeasureStartTime);
- MeasureReqIE.MeasureReq.MeasureDuration = cpu2le16(MeasureDuration);
- InsertMeasureReqIE(pAd, (pOutBuffer + FrameLen), &FrameLen, &MeasureReqIE);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 ReportInfoLen,
- IN PUINT8 pReportInfo)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- HEADER_802_11 ActHdr;
- MEASURE_REPORT_INFO MeasureRepIE;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_MRP);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
- // prepare Measurement IE.
- NdisZeroMemory(&MeasureRepIE, sizeof(MEASURE_REPORT_INFO));
- MeasureRepIE.Token = MeasureToken;
- MeasureRepIE.ReportMode.word = MeasureReqMode;
- MeasureRepIE.ReportType = MeasureReqType;
- InsertMeasureReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen, &MeasureRepIE, ReportInfoLen, pReportInfo);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UCHAR DialogToken)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
-
- HEADER_802_11 ActHdr;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_TPCRQ);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
- // Insert TPC Request IE.
- InsertTpcReqIE(pAd, (pOutBuffer + FrameLen), &FrameLen);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 TxPwr,
- IN UINT8 LinkMargin)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
-
- HEADER_802_11 ActHdr;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_TPCRP);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
- // Insert TPC Request IE.
- InsertTpcReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen, TxPwr, LinkMargin);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare Channel Switch Announcement action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
- 2. Channel switch announcement mode.
- 2. a New selected channel.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueChSwAnn(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 ChSwMode,
- IN UINT8 NewCh)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
-
- HEADER_802_11 ActHdr;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_CHANNEL_SWITCH);
-
- InsertChSwAnnIE(pAd, (pOutBuffer + FrameLen), &FrameLen, ChSwMode, NewCh, 0);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-static BOOLEAN DfsRequirementCheck(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 Channel)
-{
- BOOLEAN Result = FALSE;
- INT i;
-
- do
- {
- // check DFS procedure is running.
- // make sure DFS procedure won't start twice.
- if (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
- {
- Result = FALSE;
- break;
- }
-
- // check the new channel carried from Channel Switch Announcemnet is valid.
- for (i=0; i<pAd->ChannelListNum; i++)
- {
- if ((Channel == pAd->ChannelList[i].Channel)
- &&(pAd->ChannelList[i].RemainingTimeForUse == 0))
- {
- // found radar signal in the channel. the channel can't use at least for 30 minutes.
- pAd->ChannelList[i].RemainingTimeForUse = 1800;//30 min = 1800 sec
- Result = TRUE;
- break;
- }
- }
- } while(FALSE);
-
- return Result;
-}
-
-VOID NotifyChSwAnnToPeerAPs(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pRA,
- IN PUCHAR pTA,
- IN UINT8 ChSwMode,
- IN UINT8 Channel)
-{
-#ifdef WDS_SUPPORT
- if (!((pRA[0] & 0xff) == 0xff)) // is pRA a broadcase address.
- {
- INT i;
- // info neighbor APs that Radar signal found throgh WDS link.
- for (i = 0; i < MAX_WDS_ENTRY; i++)
- {
- if (ValidWdsEntry(pAd, i))
- {
- PUCHAR pDA = pAd->WdsTab.WdsEntry[i].PeerWdsAddr;
-
- // DA equal to SA. have no necessary orignal AP which found Radar signal.
- if (MAC_ADDR_EQUAL(pTA, pDA))
- continue;
-
- // send Channel Switch Action frame to info Neighbro APs.
- EnqueueChSwAnn(pAd, pDA, ChSwMode, Channel);
- }
- }
- }
-#endif // WDS_SUPPORT //
-}
-
-static VOID StartDFSProcedure(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel,
- IN UINT8 ChSwMode)
-{
- // start DFS procedure
- pAd->CommonCfg.Channel = Channel;
-#ifdef DOT11_N_SUPPORT
- N_ChannelCheck(pAd);
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.RadarDetect.RDMode = RD_SWITCHING_MODE;
- pAd->CommonCfg.RadarDetect.CSCount = 0;
-}
-
-/*
- ==========================================================================
- Description:
- Channel Switch Announcement action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Channel switch announcement infomation buffer.
-
-
- Return : None.
- ==========================================================================
- */
-
-/*
- Channel Switch Announcement IE.
- +----+-----+-----------+------------+-----------+
- | ID | Len |Ch Sw Mode | New Ch Num | Ch Sw Cnt |
- +----+-----+-----------+------------+-----------+
- 1 1 1 1 1
-*/
-static BOOLEAN PeerChSwAnnSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PCH_SW_ANN_INFO pChSwAnnInfo)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
-
- // skip 802.11 header.
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pChSwAnnInfo == NULL)
- return result;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
- NdisMoveMemory(&pChSwAnnInfo->ChSwMode, eid_ptr->Octet, 1);
- NdisMoveMemory(&pChSwAnnInfo->Channel, eid_ptr->Octet + 1, 1);
- NdisMoveMemory(&pChSwAnnInfo->ChSwCnt, eid_ptr->Octet + 2, 1);
-
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- Measurement request action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Measurement request infomation buffer.
-
- Return : None.
- ==========================================================================
- */
-static BOOLEAN PeerMeasureReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken,
- OUT PMEASURE_REQ_INFO pMeasureReqInfo)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
- PUCHAR ptr;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
-
- // skip 802.11 header.
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pMeasureReqInfo == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_MEASUREMENT_REQUEST:
- NdisMoveMemory(&pMeasureReqInfo->Token, eid_ptr->Octet, 1);
- NdisMoveMemory(&pMeasureReqInfo->ReqMode.word, eid_ptr->Octet + 1, 1);
- NdisMoveMemory(&pMeasureReqInfo->ReqType, eid_ptr->Octet + 2, 1);
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pMeasureReqInfo->MeasureReq.ChNum, ptr, 1);
- NdisMoveMemory(&MeasureStartTime, ptr + 1, 8);
- pMeasureReqInfo->MeasureReq.MeasureStartTime = SWAP64(MeasureStartTime);
- NdisMoveMemory(&MeasureDuration, ptr + 9, 2);
- pMeasureReqInfo->MeasureReq.MeasureDuration = SWAP16(MeasureDuration);
-
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- Measurement report action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Measurement report infomation buffer.
- 4. basic report infomation buffer.
-
- Return : None.
- ==========================================================================
- */
-
-/*
- Measurement Report IE.
- +----+-----+-------+-------------+--------------+----------------+
- | ID | Len | Token | Report Mode | Measure Type | Measure Report |
- +----+-----+-------+-------------+--------------+----------------+
- 1 1 1 1 1 variable
-
- Basic Report.
- +--------+------------+----------+-----+
- | Ch Num | Start Time | Duration | Map |
- +--------+------------+----------+-----+
- 1 8 2 1
-
- Map Field Bit Format.
- +-----+---------------+---------------------+-------+------------+----------+
- | Bss | OFDM Preamble | Unidentified signal | Radar | Unmeasured | Reserved |
- +-----+---------------+---------------------+-------+------------+----------+
- 0 1 2 3 4 5-7
-*/
-static BOOLEAN PeerMeasureReportSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken,
- OUT PMEASURE_REPORT_INFO pMeasureReportInfo,
- OUT PUINT8 pReportBuf)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
- PUCHAR ptr;
-
- // skip 802.11 header.
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pMeasureReportInfo == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_MEASUREMENT_REPORT:
- NdisMoveMemory(&pMeasureReportInfo->Token, eid_ptr->Octet, 1);
- NdisMoveMemory(&pMeasureReportInfo->ReportMode, eid_ptr->Octet + 1, 1);
- NdisMoveMemory(&pMeasureReportInfo->ReportType, eid_ptr->Octet + 2, 1);
- if (pMeasureReportInfo->ReportType == RM_BASIC)
- {
- PMEASURE_BASIC_REPORT pReport = (PMEASURE_BASIC_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pReport->ChNum, ptr, 1);
- NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
- NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
- NdisMoveMemory(&pReport->Map, ptr + 11, 1);
-
- }
- else if (pMeasureReportInfo->ReportType == RM_CCA)
- {
- PMEASURE_CCA_REPORT pReport = (PMEASURE_CCA_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pReport->ChNum, ptr, 1);
- NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
- NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
- NdisMoveMemory(&pReport->CCA_Busy_Fraction, ptr + 11, 1);
-
- }
- else if (pMeasureReportInfo->ReportType == RM_RPI_HISTOGRAM)
- {
- PMEASURE_RPI_REPORT pReport = (PMEASURE_RPI_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pReport->ChNum, ptr, 1);
- NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
- NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
- NdisMoveMemory(&pReport->RPI_Density, ptr + 11, 8);
- }
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Request action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Dialog Token.
-
- Return : None.
- ==========================================================================
- */
-static BOOLEAN PeerTpcReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
-
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pDialogToken == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_TPC_REQUEST:
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Report action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Dialog Token.
- 4. TPC Report IE.
-
- Return : None.
- ==========================================================================
- */
-static BOOLEAN PeerTpcRepSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken,
- OUT PTPC_REPORT_INFO pTpcRepInfo)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
-
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pDialogToken == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_TPC_REPORT:
- NdisMoveMemory(&pTpcRepInfo->TxPwr, eid_ptr->Octet, 1);
- NdisMoveMemory(&pTpcRepInfo->LinkMargin, eid_ptr->Octet + 1, 1);
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- Channel Switch Announcement action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerChSwAnnAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- CH_SW_ANN_INFO ChSwAnnInfo;
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR index = 0, Channel = 0, NewChannel = 0;
- ULONG Bssidx = 0;
-#endif // CONFIG_STA_SUPPORT //
-
- NdisZeroMemory(&ChSwAnnInfo, sizeof(CH_SW_ANN_INFO));
- if (! PeerChSwAnnSanity(pAd, Elem->Msg, Elem->MsgLen, &ChSwAnnInfo))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Invalid Channel Switch Action Frame.\n"));
- return;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->OpMode == OPMODE_STA)
- {
- Bssidx = BssTableSearch(&pAd->ScanTab, pFr->Hdr.Addr3, pAd->CommonCfg.Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerChSwAnnAction - Bssidx is not found\n"));
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("\n****Bssidx is %d, Channel = %d\n", index, pAd->ScanTab.BssEntry[Bssidx].Channel));
- hex_dump("SSID",pAd->ScanTab.BssEntry[Bssidx].Bssid ,6);
-
- Channel = pAd->CommonCfg.Channel;
- NewChannel = ChSwAnnInfo.Channel;
-
- if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
- {
- // Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection).
- // In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results.
- AsicSwitchChannel(pAd, 1, FALSE);
- AsicLockChannel(pAd, 1);
- LinkDown(pAd, FALSE);
- MlmeQueueInit(&pAd->Mlme.Queue);
- BssTableInit(&pAd->ScanTab);
- RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
-
- // channel sanity check
- for (index = 0 ; index < pAd->ChannelListNum; index++)
- {
- if (pAd->ChannelList[index].Channel == NewChannel)
- {
- pAd->ScanTab.BssEntry[Bssidx].Channel = NewChannel;
- pAd->CommonCfg.Channel = NewChannel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("&&&&&&&&&&&&&&&&PeerChSwAnnAction - STA receive channel switch announcement IE (New Channel =%d)\n", NewChannel));
- break;
- }
- }
-
- if (index >= pAd->ChannelListNum)
- {
- DBGPRINT_ERR(("&&&&&&&&&&&&&&&&&&&&&&&&&&PeerChSwAnnAction(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return;
-}
-
-
-/*
- ==========================================================================
- Description:
- Measurement Request action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerMeasureReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
- UINT8 DialogToken;
- MEASURE_REQ_INFO MeasureReqInfo;
- MEASURE_REPORT_MODE ReportMode;
-
- if(PeerMeasureReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReqInfo))
- {
- ReportMode.word = 0;
- ReportMode.field.Incapable = 1;
- EnqueueMeasurementRep(pAd, pFr->Hdr.Addr2, DialogToken, MeasureReqInfo.Token, ReportMode.word, MeasureReqInfo.ReqType, 0, NULL);
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Measurement Report action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerMeasureReportAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MEASURE_REPORT_INFO MeasureReportInfo;
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
- UINT8 DialogToken;
- PUINT8 pMeasureReportInfo;
-
-// if (pAd->CommonCfg.bIEEE80211H != TRUE)
-// return;
-
- if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%zu).\n", __func__, sizeof(MEASURE_RPI_REPORT)));
- return;
- }
-
- NdisZeroMemory(&MeasureReportInfo, sizeof(MEASURE_REPORT_INFO));
- NdisZeroMemory(pMeasureReportInfo, sizeof(MEASURE_RPI_REPORT));
- if (PeerMeasureReportSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReportInfo, pMeasureReportInfo))
- {
- do {
- PMEASURE_REQ_ENTRY pEntry = NULL;
-
- // Not a autonomous measure report.
- // check the dialog token field. drop it if the dialog token doesn't match.
- if ((DialogToken != 0)
- && ((pEntry = MeasureReqLookUp(pAd, DialogToken)) == NULL))
- break;
-
- if (pEntry != NULL)
- MeasureReqDelete(pAd, pEntry->DialogToken);
-
- if (MeasureReportInfo.ReportType == RM_BASIC)
- {
- PMEASURE_BASIC_REPORT pBasicReport = (PMEASURE_BASIC_REPORT)pMeasureReportInfo;
- if ((pBasicReport->Map.field.Radar)
- && (DfsRequirementCheck(pAd, pBasicReport->ChNum) == TRUE))
- {
- NotifyChSwAnnToPeerAPs(pAd, pFr->Hdr.Addr1, pFr->Hdr.Addr2, 1, pBasicReport->ChNum);
- StartDFSProcedure(pAd, pBasicReport->ChNum, 1);
- }
- }
- } while (FALSE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Invalid Measurement Report Frame.\n"));
-
- kfree(pMeasureReportInfo);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Request action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerTpcReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
- PUCHAR pFramePtr = pFr->Octet;
- UINT8 DialogToken;
- UINT8 TxPwr = GetCurTxPwr(pAd, Elem->Wcid);
- UINT8 LinkMargin = 0;
- CHAR RealRssi;
-
- // link margin: Ratio of the received signal power to the minimum desired by the station (STA). The
- // STA may incorporate rate information and channel conditions, including interference, into its computation
- // of link margin.
-
- RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
- ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
- ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
- // skip Category and action code.
- pFramePtr += 2;
-
- // Dialog token.
- NdisMoveMemory(&DialogToken, pFramePtr, 1);
-
- LinkMargin = (RealRssi / MIN_RCV_PWR);
- if (PeerTpcReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken))
- EnqueueTPCRep(pAd, pFr->Hdr.Addr2, DialogToken, TxPwr, LinkMargin);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Report action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerTpcRepAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UINT8 DialogToken;
- TPC_REPORT_INFO TpcRepInfo;
- PTPC_REQ_ENTRY pEntry = NULL;
-
- NdisZeroMemory(&TpcRepInfo, sizeof(TPC_REPORT_INFO));
- if (PeerTpcRepSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &TpcRepInfo))
- {
- if ((pEntry = TpcReqLookUp(pAd, DialogToken)) != NULL)
- {
- TpcReqDelete(pAd, pEntry->DialogToken);
- DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n",
- __func__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin));
- }
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Spectrun action frames Handler such as channel switch annoucement,
- measurement report, measurement request actions frames.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-VOID PeerSpectrumAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- if (pAd->CommonCfg.bIEEE80211H != TRUE)
- return;
-
- switch(Action)
- {
- case SPEC_MRQ:
- // current rt2860 unable do such measure specified in Measurement Request.
- // reject all measurement request.
- PeerMeasureReqAction(pAd, Elem);
- break;
-
- case SPEC_MRP:
- PeerMeasureReportAction(pAd, Elem);
- break;
-
- case SPEC_TPCRQ:
- PeerTpcReqAction(pAd, Elem);
- break;
-
- case SPEC_TPCRP:
- PeerTpcRepAction(pAd, Elem);
- break;
-
- case SPEC_CHANNEL_SWITCH:
-{
-#ifdef DOT11N_DRAFT3
- SEC_CHA_OFFSET_IE Secondary;
- CHA_SWITCH_ANNOUNCE_IE ChannelSwitch;
-
- // 802.11h only has Channel Switch Announcement IE.
- RTMPMoveMemory(&ChannelSwitch, &Elem->Msg[LENGTH_802_11+4], sizeof (CHA_SWITCH_ANNOUNCE_IE));
-
- // 802.11n D3.03 adds secondary channel offset element in the end.
- if (Elem->MsgLen == (LENGTH_802_11 + 2 + sizeof (CHA_SWITCH_ANNOUNCE_IE) + sizeof (SEC_CHA_OFFSET_IE)))
- {
- RTMPMoveMemory(&Secondary, &Elem->Msg[LENGTH_802_11+9], sizeof (SEC_CHA_OFFSET_IE));
- }
- else
- {
- Secondary.SecondaryChannelOffset = 0;
- }
-
- if ((Elem->Msg[LENGTH_802_11+2] == IE_CHANNEL_SWITCH_ANNOUNCEMENT) && (Elem->Msg[LENGTH_802_11+3] == 3))
- {
- ChannelSwitchAction(pAd, Elem->Wcid, ChannelSwitch.NewChannel, Secondary.SecondaryChannelOffset);
- }
-#endif // DOT11N_DRAFT3 //
-}
- PeerChSwAnnAction(pAd, Elem);
- break;
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
-
- Parametrs:
-
- Return : None.
- ==========================================================================
- */
-INT Set_MeasureReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT Aid = 1;
- UINT ArgIdx;
- PUCHAR thisChar;
-
- MEASURE_REQ_MODE MeasureReqMode;
- UINT8 MeasureReqToken = RandomByte(pAd);
- UINT8 MeasureReqType = RM_BASIC;
- UINT8 MeasureCh = 1;
-
- ArgIdx = 1;
- while ((thisChar = strsep((char **)&arg, "-")) != NULL)
- {
- switch(ArgIdx)
- {
- case 1: // Aid.
- Aid = simple_strtol(thisChar, 0, 16);
- break;
-
- case 2: // Measurement Request Type.
- MeasureReqType = simple_strtol(thisChar, 0, 16);
- if (MeasureReqType > 3)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __func__, MeasureReqType));
- return TRUE;
- }
- break;
-
- case 3: // Measurement channel.
- MeasureCh = simple_strtol(thisChar, 0, 16);
- break;
- }
- ArgIdx++;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __func__, Aid, MeasureReqType, MeasureCh));
- if (!VALID_WCID(Aid))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
- return TRUE;
- }
-
- MeasureReqMode.word = 0;
- MeasureReqMode.field.Enable = 1;
-
- MeasureReqInsert(pAd, MeasureReqToken);
-
- EnqueueMeasurementReq(pAd, pAd->MacTab.Content[Aid].Addr,
- MeasureReqToken, MeasureReqMode.word, MeasureReqType, MeasureCh, 2000);
-
- return TRUE;
-}
-
-INT Set_TpcReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT Aid;
-
- UINT8 TpcReqToken = RandomByte(pAd);
-
- Aid = simple_strtol(arg, 0, 16);
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __func__, Aid));
- if (!VALID_WCID(Aid))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
- return TRUE;
- }
-
- TpcReqInsert(pAd, TpcReqToken);
-
- EnqueueTPCReq(pAd, pAd->MacTab.Content[Aid].Addr, TpcReqToken);
-
- return TRUE;
-}
-
+#include "../../rt2860/common/spectrum.c"
diff --git a/drivers/staging/rt2870/dfs.h b/drivers/staging/rt2870/dfs.h
index 752a6352d9dd..1fdbd7bc5de5 100644
--- a/drivers/staging/rt2870/dfs.h
+++ b/drivers/staging/rt2870/dfs.h
@@ -1,100 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- dfs.h
-
- Abstract:
- Support DFS function.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Fonchi 03-12-2007 created
-*/
-
-#define RADAR_PULSE 1
-#define RADAR_WIDTH 2
-
-#define WIDTH_RD_IDLE 0
-#define WIDTH_RD_CHECK 1
-
-
-VOID BbpRadarDetectionStart(
- IN PRTMP_ADAPTER pAd);
-
-VOID BbpRadarDetectionStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RadarDetectionStart(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN CTS_Protect,
- IN UINT8 CTSPeriod);
-
-VOID RadarDetectionStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RadarDetectPeriodic(
- IN PRTMP_ADAPTER pAd);
-
-
-BOOLEAN RadarChannelCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Ch);
-
-ULONG JapRadarType(
- IN PRTMP_ADAPTER pAd);
-
-ULONG RTMPBbpReadRadarDuration(
- IN PRTMP_ADAPTER pAd);
-
-ULONG RTMPReadRadarDuration(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPCleanRadarDuration(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPPrepareRDCTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN ULONG Duration,
- IN UCHAR RTSRate,
- IN ULONG CTSBaseAddr,
- IN UCHAR FrameGap);
-
-VOID RTMPPrepareRadarDetectParams(
- IN PRTMP_ADAPTER pAd);
-
-
-INT Set_ChMovingTime_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_LongPulseRadarTh_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
+#include "../rt2860/dfs.h"
diff --git a/drivers/staging/rt2870/leap.h b/drivers/staging/rt2870/leap.h
deleted file mode 100644
index 6818c1ff4d73..000000000000
--- a/drivers/staging/rt2870/leap.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- leap.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef __LEAP_H__
-#define __LEAP_H__
-
-// Messages for Associate state machine
-#define LEAP_MACHINE_BASE 30
-
-#define LEAP_MSG_REQUEST_IDENTITY 31
-#define LEAP_MSG_REQUEST_LEAP 32
-#define LEAP_MSG_SUCCESS 33
-#define LEAP_MSG_FAILED 34
-#define LEAP_MSG_RESPONSE_LEAP 35
-#define LEAP_MSG_EAPOLKEY 36
-#define LEAP_MSG_UNKNOWN 37
-#define LEAP_MSG 38
-//! assoc state-machine states
-#define LEAP_IDLE 0
-#define LEAP_WAIT_IDENTITY_REQUEST 1
-#define LEAP_WAIT_CHANLLENGE_REQUEST 2
-#define LEAP_WAIT_SUCCESS 3
-#define LEAP_WAIT_CHANLLENGE_RESPONSE 4
-#define LEAP_WAIT_EAPOLKEY 5
-
-#define LEAP_REASON_INVALID_AUTH 0x01
-#define LEAP_REASON_AUTH_TIMEOUT 0x02
-#define LEAP_REASON_CHALLENGE_FROM_AP_FAILED 0x03
-#define LEAP_REASON_CHALLENGE_TO_AP_FAILED 0x04
-
-#define CISCO_AuthModeLEAP 0x80
-#define CISCO_AuthModeLEAPNone 0x00
-#define LEAP_AUTH_TIMEOUT 30000
-#define LEAP_CHALLENGE_RESPONSE_LENGTH 24
-#define LEAP_CHALLENGE_REQUEST_LENGTH 8
-
-typedef struct _LEAP_EAPOL_HEADER_ {
- UCHAR Version;
- UCHAR Type;
- UCHAR Length[2];
-} LEAP_EAPOL_HEADER, *PLEAP_EAPOL_HEADER;
-
-typedef struct _LEAP_EAPOL_PACKET_ {
- UCHAR Code;
- UCHAR Identifier;
- UCHAR Length[2];
- UCHAR Type;
-} LEAP_EAPOL_PACKET, *PLEAP_EAPOL_PACKET;
-
-typedef struct _LEAP_EAP_CONTENTS_ {
- UCHAR Version;
- UCHAR Reserved;
- UCHAR Length;
-} LEAP_EAP_CONTENTS, *PLEAP_EAP_CONTENTS;
-
-/*** EAPOL key ***/
-typedef struct _EAPOL_KEY_HEADER_ {
- UCHAR Type;
- UCHAR Length[2];
- UCHAR Counter[8];
- UCHAR IV[16];
- UCHAR Index;
- UCHAR Signature[16];
-} EAPOL_KEY_HEADER, *PEAPOL_KEY_HEADER;
-
-BOOLEAN LeapMsgTypeSubst(
- IN UCHAR EAPType,
- OUT ULONG *MsgType);
-
-VOID LeapMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr3);
-
-VOID LeapStartAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapIdentityAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapPeerChallengeAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HashPwd(
- IN PUCHAR pwd,
- IN INT pwdlen,
- OUT PUCHAR hash);
-
-VOID PeerChallengeResponse(
- IN PUCHAR szChallenge,
- IN PUCHAR smbPasswd,
- OUT PUCHAR szResponse);
-
-VOID ParityKey(
- OUT PUCHAR szOut,
- IN PUCHAR szIn);
-
-VOID DesKey(
- OUT ULONG k[16][2],
- IN PUCHAR key,
- IN INT decrypt);
-
-VOID Des(
- IN ULONG ks[16][2],
- OUT UCHAR block[8]);
-
-VOID DesEncrypt(
- IN PUCHAR szClear,
- IN PUCHAR szKey,
- OUT PUCHAR szOut);
-
-VOID LeapNetworkChallengeAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapNetworkChallengeResponse(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HashpwdHash(
- IN PUCHAR hash,
- IN PUCHAR hashhash);
-
-VOID ProcessSessionKey(
- OUT PUCHAR SessionKey,
- IN PUCHAR hash2,
- IN PUCHAR ChallengeToRadius,
- IN PUCHAR ChallengeResponseFromRadius,
- IN PUCHAR ChallengeFromRadius,
- IN PUCHAR ChallengeResponseToRadius);
-
-VOID LeapEapolKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID RogueApTableInit(
- IN ROGUEAP_TABLE *Tab);
-
-ULONG RogueApTableSearch(
- IN ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr);
-
-VOID RogueApEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT ROGUEAP_ENTRY *pRogueAp,
- IN PUCHAR pAddr,
- IN UCHAR FaileCode);
-
-ULONG RogueApTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr,
- IN UCHAR FaileCode);
-
-VOID RogueApTableDeleteEntry(
- IN OUT ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr);
-
-VOID LeapAuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LeapSendRogueAPReport(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN CCKMAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen);
-
-#endif // __LEAP_H__
diff --git a/drivers/staging/rt2870/link_list.h b/drivers/staging/rt2870/link_list.h
index f6521133fd5e..2589f3470390 100644
--- a/drivers/staging/rt2870/link_list.h
+++ b/drivers/staging/rt2870/link_list.h
@@ -1,134 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __LINK_LIST_H__
-#define __LINK_LIST_H__
-
-typedef struct _LIST_ENTRY
-{
- struct _LIST_ENTRY *pNext;
-} LIST_ENTRY, *PLIST_ENTRY;
-
-typedef struct _LIST_HEADR
-{
- PLIST_ENTRY pHead;
- PLIST_ENTRY pTail;
- UCHAR size;
-} LIST_HEADER, *PLIST_HEADER;
-
-static inline VOID initList(
- IN PLIST_HEADER pList)
-{
- pList->pHead = pList->pTail = NULL;
- pList->size = 0;
- return;
-}
-
-static inline VOID insertTailList(
- IN PLIST_HEADER pList,
- IN PLIST_ENTRY pEntry)
-{
- pEntry->pNext = NULL;
- if (pList->pTail)
- pList->pTail->pNext = pEntry;
- else
- pList->pHead = pEntry;
- pList->pTail = pEntry;
- pList->size++;
-
- return;
-}
-
-static inline PLIST_ENTRY removeHeadList(
- IN PLIST_HEADER pList)
-{
- PLIST_ENTRY pNext;
- PLIST_ENTRY pEntry;
-
- pEntry = pList->pHead;
- if (pList->pHead != NULL)
- {
- pNext = pList->pHead->pNext;
- pList->pHead = pNext;
- if (pNext == NULL)
- pList->pTail = NULL;
- pList->size--;
- }
- return pEntry;
-}
-
-static inline int getListSize(
- IN PLIST_HEADER pList)
-{
- return pList->size;
-}
-
-static inline PLIST_ENTRY delEntryList(
- IN PLIST_HEADER pList,
- IN PLIST_ENTRY pEntry)
-{
- PLIST_ENTRY pCurEntry;
- PLIST_ENTRY pPrvEntry;
-
- if(pList->pHead == NULL)
- return NULL;
-
- if(pEntry == pList->pHead)
- {
- pCurEntry = pList->pHead;
- pList->pHead = pCurEntry->pNext;
-
- if(pList->pHead == NULL)
- pList->pTail = NULL;
-
- pList->size--;
- return pCurEntry;
- }
-
- pPrvEntry = pList->pHead;
- pCurEntry = pPrvEntry->pNext;
- while(pCurEntry != NULL)
- {
- if (pEntry == pCurEntry)
- {
- pPrvEntry->pNext = pCurEntry->pNext;
-
- if(pEntry == pList->pTail)
- pList->pTail = pPrvEntry;
-
- pList->size--;
- break;
- }
- pPrvEntry = pCurEntry;
- pCurEntry = pPrvEntry->pNext;
- }
-
- return pCurEntry;
-}
-
-#endif // ___LINK_LIST_H__ //
-
+#include "../rt2860/link_list.h"
diff --git a/drivers/staging/rt2870/md5.h b/drivers/staging/rt2870/md5.h
index d85db12170d5..d60cd05b54f7 100644
--- a/drivers/staging/rt2870/md5.h
+++ b/drivers/staging/rt2870/md5.h
@@ -1,107 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- md5.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- jan 10-28-03 Initial
- Rita 11-23-04 Modify MD5 and SHA-1
-*/
-
-#ifndef uint8
-#define uint8 unsigned char
-#endif
-
-#ifndef uint32
-#define uint32 unsigned long int
-#endif
-
-
-#ifndef __MD5_H__
-#define __MD5_H__
-
-#define MD5_MAC_LEN 16
-
-typedef struct _MD5_CTX {
- UINT32 Buf[4]; // buffers of four states
- UCHAR Input[64]; // input message
- UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
-} MD5_CTX;
-
-VOID MD5Init(MD5_CTX *pCtx);
-VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
-VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx);
-VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16]);
-
-void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
-void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
-
-//
-// SHA context
-//
-typedef struct _SHA_CTX
-{
- UINT32 Buf[5]; // buffers of five states
- UCHAR Input[80]; // input message
- UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
-
-} SHA_CTX;
-
-VOID SHAInit(SHA_CTX *pCtx);
-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
-VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]);
-VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20]);
-
-#define SHA_DIGEST_LEN 20
-#endif // __MD5_H__
-
-/******************************************************************************/
-#ifndef _AES_H
-#define _AES_H
-
-typedef struct
-{
- uint32 erk[64]; /* encryption round keys */
- uint32 drk[64]; /* decryption round keys */
- int nr; /* number of rounds */
-}
-aes_context;
-
-int rtmp_aes_set_key( aes_context *ctx, uint8 *key, int nbits );
-void rtmp_aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
-void rtmp_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
-
-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);
-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);
-
-#endif /* aes.h */
-
+#include "../rt2860/md5.h"
diff --git a/drivers/staging/rt2870/mlme.h b/drivers/staging/rt2870/mlme.h
index 52fb8e1c2906..58753ac441de 100644
--- a/drivers/staging/rt2870/mlme.h
+++ b/drivers/staging/rt2870/mlme.h
@@ -1,1471 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- mlme.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2003-08-28 Created
- John Chang 2004-09-06 modified for RT2600
-
-*/
-#ifndef __MLME_H__
-#define __MLME_H__
-
-//extern UCHAR BROADCAST_ADDR[];
-
-// maximum supported capability information -
-// ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
-#define SUPPORTED_CAPABILITY_INFO 0x0533
-
-#define END_OF_ARGS -1
-#define LFSR_MASK 0x80000057
-#define MLME_TASK_EXEC_INTV 100/*200*/ //
-#define LEAD_TIME 5
-#define MLME_TASK_EXEC_MULTIPLE 10 /*5*/ // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
-#define REORDER_EXEC_INTV 100 // 0.1 sec
-//#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps
-
-// The definition of Radar detection duration region
-#define CE 0
-#define FCC 1
-#define JAP 2
-#define JAP_W53 3
-#define JAP_W56 4
-#define MAX_RD_REGION 5
-
-#ifdef NDIS51_MINIPORT
-#define BEACON_LOST_TIME 4000 // 2048 msec = 2 sec
-#else
-#define BEACON_LOST_TIME 4 * OS_HZ // 2048 msec = 2 sec
-#endif
-
-#define DLS_TIMEOUT 1200 // unit: msec
-#define AUTH_TIMEOUT 300 // unit: msec
-#define ASSOC_TIMEOUT 300 // unit: msec
-#define JOIN_TIMEOUT 2 * OS_HZ // unit: msec
-#define SHORT_CHANNEL_TIME 90 // unit: msec
-#define MIN_CHANNEL_TIME 110 // unit: msec, for dual band scan
-#define MAX_CHANNEL_TIME 140 // unit: msec, for single band scan
-#define FAST_ACTIVE_SCAN_TIME 30 // Active scan waiting for probe response time
-#define CW_MIN_IN_BITS 4 // actual CwMin = 2^CW_MIN_IN_BITS - 1
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifndef CONFIG_AP_SUPPORT
-#define CW_MAX_IN_BITS 10 // actual CwMax = 2^CW_MAX_IN_BITS - 1
-#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-extern UINT32 CW_MAX_IN_BITS;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-// Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
-// SHould not refer to this constant anymore
-//#define RSSI_TO_DBM_OFFSET 120 // for RT2530 RSSI-115 = dBm
-#define RSSI_FOR_MID_TX_POWER -55 // -55 db is considered mid-distance
-#define RSSI_FOR_LOW_TX_POWER -45 // -45 db is considered very short distance and
- // eligible to use a lower TX power
-#define RSSI_FOR_LOWEST_TX_POWER -30
-//#define MID_TX_POWER_DELTA 0 // 0 db from full TX power upon mid-distance to AP
-#define LOW_TX_POWER_DELTA 6 // -3 db from full TX power upon very short distance. 1 grade is 0.5 db
-#define LOWEST_TX_POWER_DELTA 16 // -8 db from full TX power upon shortest distance. 1 grade is 0.5 db
-
-#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD 0
-#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD 1
-#define RSSI_THRESHOLD_FOR_ROAMING 25
-#define RSSI_DELTA 5
-
-// Channel Quality Indication
-#define CQI_IS_GOOD(cqi) ((cqi) >= 50)
-//#define CQI_IS_FAIR(cqi) (((cqi) >= 20) && ((cqi) < 50))
-#define CQI_IS_POOR(cqi) (cqi < 50) //(((cqi) >= 5) && ((cqi) < 20))
-#define CQI_IS_BAD(cqi) (cqi < 5)
-#define CQI_IS_DEAD(cqi) (cqi == 0)
-
-// weighting factor to calculate Channel quality, total should be 100%
-#define RSSI_WEIGHTING 50
-#define TX_WEIGHTING 30
-#define RX_WEIGHTING 20
-
-//#define PEER_KEY_NOT_USED 0
-//#define PEER_KEY_64_BIT 64
-//#define PEER_KEY_128_BIT 128
-
-//#define PEER_KEY_64BIT_LEN 8
-//#define PEER_KEY_128BIT_LEN 16
-
-#define BSS_NOT_FOUND 0xFFFFFFFF
-
-
-#ifdef CONFIG_STA_SUPPORT
-#define MAX_LEN_OF_MLME_QUEUE 40 //10
-#endif // CONFIG_STA_SUPPORT //
-
-#define SCAN_PASSIVE 18 // scan with no probe request, only wait beacon and probe response
-#define SCAN_ACTIVE 19 // scan with probe request, and wait beacon and probe response
-#define SCAN_CISCO_PASSIVE 20 // Single channel passive scan
-#define SCAN_CISCO_ACTIVE 21 // Single channel active scan
-#define SCAN_CISCO_NOISE 22 // Single channel passive scan for noise histogram collection
-#define SCAN_CISCO_CHANNEL_LOAD 23 // Single channel passive scan for channel load collection
-#define FAST_SCAN_ACTIVE 24 // scan with probe request, and wait beacon and probe response
-
-#ifdef DOT11N_DRAFT3
-#define SCAN_2040_BSS_COEXIST 26
-#endif // DOT11N_DRAFT3 //
-
-//#define BSS_TABLE_EMPTY(x) ((x).BssNr == 0)
-#define MAC_ADDR_IS_GROUP(Addr) (((Addr[0]) & 0x01))
-#define MAC_ADDR_HASH(Addr) (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
-#define TID_MAC_HASH(Addr,TID) (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define TID_MAC_HASH_INDEX(Addr,TID) (TID_MAC_HASH(Addr,TID) % HASH_TABLE_SIZE)
-
-// LED Control
-// assoiation ON. one LED ON. another blinking when TX, OFF when idle
-// no association, both LED off
-#define ASIC_LED_ACT_ON(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
-#define ASIC_LED_ACT_OFF(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
-
-// bit definition of the 2-byte pBEACON->Capability field
-#define CAP_IS_ESS_ON(x) (((x) & 0x0001) != 0)
-#define CAP_IS_IBSS_ON(x) (((x) & 0x0002) != 0)
-#define CAP_IS_CF_POLLABLE_ON(x) (((x) & 0x0004) != 0)
-#define CAP_IS_CF_POLL_REQ_ON(x) (((x) & 0x0008) != 0)
-#define CAP_IS_PRIVACY_ON(x) (((x) & 0x0010) != 0)
-#define CAP_IS_SHORT_PREAMBLE_ON(x) (((x) & 0x0020) != 0)
-#define CAP_IS_PBCC_ON(x) (((x) & 0x0040) != 0)
-#define CAP_IS_AGILITY_ON(x) (((x) & 0x0080) != 0)
-#define CAP_IS_SPECTRUM_MGMT(x) (((x) & 0x0100) != 0) // 802.11e d9
-#define CAP_IS_QOS(x) (((x) & 0x0200) != 0) // 802.11e d9
-#define CAP_IS_SHORT_SLOT(x) (((x) & 0x0400) != 0)
-#define CAP_IS_APSD(x) (((x) & 0x0800) != 0) // 802.11e d9
-#define CAP_IS_IMMED_BA(x) (((x) & 0x1000) != 0) // 802.11e d9
-#define CAP_IS_DSSS_OFDM(x) (((x) & 0x2000) != 0)
-#define CAP_IS_DELAY_BA(x) (((x) & 0x4000) != 0) // 802.11e d9
-
-#define CAP_GENERATE(ess,ibss,priv,s_pre,s_slot,spectrum) (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
-
-//#define STA_QOS_CAPABILITY 0 // 1-byte. see 802.11e d9.0 for bit definition
-
-#define ERP_IS_NON_ERP_PRESENT(x) (((x) & 0x01) != 0) // 802.11g
-#define ERP_IS_USE_PROTECTION(x) (((x) & 0x02) != 0) // 802.11g
-#define ERP_IS_USE_BARKER_PREAMBLE(x) (((x) & 0x04) != 0) // 802.11g
-
-#define DRS_TX_QUALITY_WORST_BOUND 8// 3 // just test by gary
-#define DRS_PENALTY 8
-
-#define BA_NOTUSE 2
-//BA Policy subfiled value in ADDBA frame
-#define IMMED_BA 1
-#define DELAY_BA 0
-
-// BA Initiator subfield in DELBA frame
-#define ORIGINATOR 1
-#define RECIPIENT 0
-
-// ADDBA Status Code
-#define ADDBA_RESULTCODE_SUCCESS 0
-#define ADDBA_RESULTCODE_REFUSED 37
-#define ADDBA_RESULTCODE_INVALID_PARAMETERS 38
-
-// DELBA Reason Code
-#define DELBA_REASONCODE_QSTA_LEAVING 36
-#define DELBA_REASONCODE_END_BA 37
-#define DELBA_REASONCODE_UNKNOWN_BA 38
-#define DELBA_REASONCODE_TIMEOUT 39
-
-// reset all OneSecTx counters
-#define RESET_ONE_SEC_TX_CNT(__pEntry) \
-if (((__pEntry)) != NULL) \
-{ \
- (__pEntry)->OneSecTxRetryOkCount = 0; \
- (__pEntry)->OneSecTxFailCount = 0; \
- (__pEntry)->OneSecTxNoRetryOkCount = 0; \
-}
-
-//
-// 802.11 frame formats
-//
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT LSIGTxopProSup:1;
- USHORT Forty_Mhz_Intolerant:1;
- USHORT PSMP:1;
- USHORT CCKmodein40:1;
- USHORT AMsduSize:1;
- USHORT DelayedBA:1; //rt2860c not support
- USHORT RxSTBC:2;
- USHORT TxSTBC:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT ShortGIfor20:1;
- USHORT GF:1; //green field
- USHORT MimoPs:2;//momi power safe
- USHORT ChannelWidth:1;
- USHORT AdvCoding:1;
-#else
- USHORT AdvCoding:1;
- USHORT ChannelWidth:1;
- USHORT MimoPs:2;//momi power safe
- USHORT GF:1; //green field
- USHORT ShortGIfor20:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT TxSTBC:1;
- USHORT RxSTBC:2;
- USHORT DelayedBA:1; //rt2860c not support
- USHORT AMsduSize:1; // only support as zero
- USHORT CCKmodein40:1;
- USHORT PSMP:1;
- USHORT Forty_Mhz_Intolerant:1;
- USHORT LSIGTxopProSup:1;
-#endif /* !RT_BIG_ENDIAN */
-} HT_CAP_INFO, *PHT_CAP_INFO;
-
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:3;//momi power safe
- UCHAR MpduDensity:3;
- UCHAR MaxRAmpduFactor:2;
-#else
- UCHAR MaxRAmpduFactor:2;
- UCHAR MpduDensity:3;
- UCHAR rsv:3;//momi power safe
-#endif /* !RT_BIG_ENDIAN */
-} HT_CAP_PARM, *PHT_CAP_PARM;
-
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
- UCHAR MCSSet[10];
- UCHAR SupRate[2]; // unit : 1Mbps
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:3;
- UCHAR MpduDensity:1;
- UCHAR TxStream:2;
- UCHAR TxRxNotEqual:1;
- UCHAR TxMCSSetDefined:1;
-#else
- UCHAR TxMCSSetDefined:1;
- UCHAR TxRxNotEqual:1;
- UCHAR TxStream:2;
- UCHAR MpduDensity:1;
- UCHAR rsv:3;
-#endif // RT_BIG_ENDIAN //
- UCHAR rsv3[3];
-} HT_MCS_SET, *PHT_MCS_SET;
-
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:4;
- USHORT RDGSupport:1; //reverse Direction Grant support
- USHORT PlusHTC:1; //+HTC control field support
- USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
- USHORT rsv:5;//momi power safe
- USHORT TranTime:2;
- USHORT Pco:1;
-#else
- USHORT Pco:1;
- USHORT TranTime:2;
- USHORT rsv:5;//momi power safe
- USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
- USHORT PlusHTC:1; //+HTC control field support
- USHORT RDGSupport:1; //reverse Direction Grant support
- USHORT rsv2:4;
-#endif /* RT_BIG_ENDIAN */
-} EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
-
-// HT Beamforming field in HT Cap IE .
-typedef struct PACKED _HT_BF_CAP{
-#ifdef RT_BIG_ENDIAN
- ULONG rsv:3;
- ULONG ChanEstimation:2;
- ULONG CSIRowBFSup:2;
- ULONG ComSteerBFAntSup:2;
- ULONG NoComSteerBFAntSup:2;
- ULONG CSIBFAntSup:2;
- ULONG MinGrouping:2;
- ULONG ExpComBF:2;
- ULONG ExpNoComBF:2;
- ULONG ExpCSIFbk:2;
- ULONG ExpComSteerCapable:1;
- ULONG ExpNoComSteerCapable:1;
- ULONG ExpCSICapable:1;
- ULONG Calibration:2;
- ULONG ImpTxBFCapable:1;
- ULONG TxNDPCapable:1;
- ULONG RxNDPCapable:1;
- ULONG TxSoundCapable:1;
- ULONG RxSoundCapable:1;
- ULONG TxBFRecCapable:1;
-#else
- ULONG TxBFRecCapable:1;
- ULONG RxSoundCapable:1;
- ULONG TxSoundCapable:1;
- ULONG RxNDPCapable:1;
- ULONG TxNDPCapable:1;
- ULONG ImpTxBFCapable:1;
- ULONG Calibration:2;
- ULONG ExpCSICapable:1;
- ULONG ExpNoComSteerCapable:1;
- ULONG ExpComSteerCapable:1;
- ULONG ExpCSIFbk:2;
- ULONG ExpNoComBF:2;
- ULONG ExpComBF:2;
- ULONG MinGrouping:2;
- ULONG CSIBFAntSup:2;
- ULONG NoComSteerBFAntSup:2;
- ULONG ComSteerBFAntSup:2;
- ULONG CSIRowBFSup:2;
- ULONG ChanEstimation:2;
- ULONG rsv:3;
-#endif // RT_BIG_ENDIAN //
-} HT_BF_CAP, *PHT_BF_CAP;
-
-// HT antenna selection field in HT Cap IE .
-typedef struct PACKED _HT_AS_CAP{
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:1;
- UCHAR TxSoundPPDU:1;
- UCHAR RxASel:1;
- UCHAR AntIndFbk:1;
- UCHAR ExpCSIFbk:1;
- UCHAR AntIndFbkTxASEL:1;
- UCHAR ExpCSIFbkTxASEL:1;
- UCHAR AntSelect:1;
-#else
- UCHAR AntSelect:1;
- UCHAR ExpCSIFbkTxASEL:1;
- UCHAR AntIndFbkTxASEL:1;
- UCHAR ExpCSIFbk:1;
- UCHAR AntIndFbk:1;
- UCHAR RxASel:1;
- UCHAR TxSoundPPDU:1;
- UCHAR rsv:1;
-#endif // RT_BIG_ENDIAN //
-} HT_AS_CAP, *PHT_AS_CAP;
-
-// Draft 1.0 set IE length 26, but is extensible..
-#define SIZE_HT_CAP_IE 26
-// The structure for HT Capability IE.
-typedef struct PACKED _HT_CAPABILITY_IE{
- HT_CAP_INFO HtCapInfo;
- HT_CAP_PARM HtCapParm;
-// HT_MCS_SET HtMCSSet;
- UCHAR MCSSet[16];
- EXT_HT_CAP_INFO ExtHtCapInfo;
- HT_BF_CAP TxBFCap; // beamforming cap. rt2860c not support beamforming.
- HT_AS_CAP ASCap; //antenna selection.
-} HT_CAPABILITY_IE, *PHT_CAPABILITY_IE;
-
-
-// 802.11n draft3 related structure definitions.
-// 7.3.2.60
-#define dot11OBSSScanPassiveDwell 20 // in TU. min amount of time that the STA continously scans each channel when performing an active OBSS scan.
-#define dot11OBSSScanActiveDwell 10 // in TU.min amount of time that the STA continously scans each channel when performing an passive OBSS scan.
-#define dot11BSSWidthTriggerScanInterval 300 // in sec. max interval between scan operations to be performed to detect BSS channel width trigger events.
-#define dot11OBSSScanPassiveTotalPerChannel 200 // in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan.
-#define dot11OBSSScanActiveTotalPerChannel 20 //in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
-#define dot11BSSWidthChannelTransactionDelayFactor 5 // min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
- // interval between overlapping BSS scan operations.
-#define dot11BSSScanActivityThreshold 25 // in %%, max total time that a STA may be active on the medium during a period of
- // (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
- // being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
-
-typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
- USHORT ScanPassiveDwell;
- USHORT ScanActiveDwell;
- USHORT TriggerScanInt; // Trigger scan interval
- USHORT PassiveTalPerChannel; // passive total per channel
- USHORT ActiveTalPerChannel; // active total per channel
- USHORT DelayFactor; // BSS width channel transition delay factor
- USHORT ScanActThre; // Scan Activity threshold
-}OVERLAP_BSS_SCAN_IE, *POVERLAP_BSS_SCAN_IE;
-
-
-// 7.3.2.56. 20/40 Coexistence element used in Element ID = 72 = IE_2040_BSS_COEXIST
-typedef union PACKED _BSS_2040_COEXIST_IE{
- struct PACKED {
- #ifdef RT_BIG_ENDIAN
- UCHAR rsv:5;
- UCHAR BSS20WidthReq:1;
- UCHAR Intolerant40:1;
- UCHAR InfoReq:1;
- #else
- UCHAR InfoReq:1;
- UCHAR Intolerant40:1; // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
- UCHAR BSS20WidthReq:1; // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
- UCHAR rsv:5;
-#endif // RT_BIG_ENDIAN //
- } field;
- UCHAR word;
-} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
-
-
-typedef struct _TRIGGER_EVENTA{
- BOOLEAN bValid;
- UCHAR BSSID[6];
- UCHAR RegClass; // Regulatory Class
- USHORT Channel;
- ULONG CDCounter; // Maintain a seperate count down counter for each Event A.
-} TRIGGER_EVENTA, *PTRIGGER_EVENTA;
-
-// 20/40 trigger event table
-// If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
-#define MAX_TRIGGER_EVENT 64
-typedef struct _TRIGGER_EVENT_TAB{
- UCHAR EventANo;
- TRIGGER_EVENTA EventA[MAX_TRIGGER_EVENT];
- ULONG EventBCountDown; // Count down counter for Event B.
-} TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
-
-// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
-// This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
-typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv2:5;
- UCHAR ExtendChannelSwitch:1;
- UCHAR rsv:1;
- UCHAR BssCoexistMgmtSupport:1;
-#else
- UCHAR BssCoexistMgmtSupport:1;
- UCHAR rsv:1;
- UCHAR ExtendChannelSwitch:1;
- UCHAR rsv2:5;
-#endif // RT_BIG_ENDIAN //
-}EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
-
-
-// 802.11n 7.3.2.61
-typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
- UCHAR ElementID; // ID = IE_2040_BSS_COEXIST = 72
- UCHAR Len;
- BSS_2040_COEXIST_IE BssCoexistIe;
-}BSS_2040_COEXIST_ELEMENT, *PBSS_2040_COEXIST_ELEMENT;
-
-
-//802.11n 7.3.2.59
-typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
- UCHAR ElementID; // ID = IE_2040_BSS_INTOLERANT_REPORT = 73
- UCHAR Len;
- UCHAR RegulatoryClass;
- UCHAR ChList[0];
-}BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
-
-
-// The structure for channel switch annoucement IE. This is in 802.11n D3.03
-typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
- UCHAR SwitchMode; //channel switch mode
- UCHAR NewChannel; //
- UCHAR SwitchCount; //
-} CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
-
-
-// The structure for channel switch annoucement IE. This is in 802.11n D3.03
-typedef struct PACKED _SEC_CHA_OFFSET_IE{
- UCHAR SecondaryChannelOffset; // 1: Secondary above, 3: Secondary below, 0: no Secondary
-} SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
-
-
-// This structure is extracted from struct RT_HT_CAPABILITY
-typedef struct {
- BOOLEAN bHtEnable; // If we should use ht rate.
- BOOLEAN bPreNHt; // If we should use ht rate.
- //Substract from HT Capability IE
- UCHAR MCSSet[16]; //only supoort MCS=0-15,32 ,
-} RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
-
-//This structure substracts ralink supports from all 802.11n-related features.
-//Features not listed here but contained in 802.11n spec are not supported in rt2860.
-typedef struct {
-#if 0 // move to
- BOOLEAN bHtEnable; // If we should use ht rate.
- BOOLEAN bPreNHt; // If we should use ht rate.
- //Substract from HT Capability IE
- UCHAR MCSSet[16]; //only supoort MCS=0-15,32 ,
-#endif
-#ifdef RT_BIG_ENDIAN
- USHORT rsv:5;
- USHORT AmsduSize:1; // Max receiving A-MSDU size
- USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
- USHORT RxSTBC:2; // 2 bits
- USHORT TxSTBC:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT ShortGIfor20:1;
- USHORT GF:1; //green field
- USHORT MimoPs:2;//mimo power safe MMPS_
- USHORT ChannelWidth:1;
-#else
- USHORT ChannelWidth:1;
- USHORT MimoPs:2;//mimo power safe MMPS_
- USHORT GF:1; //green field
- USHORT ShortGIfor20:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT TxSTBC:1;
- USHORT RxSTBC:2; // 2 bits
- USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
- USHORT AmsduSize:1; // Max receiving A-MSDU size
- USHORT rsv:5;
-#endif
-
- //Substract from Addiont HT INFO IE
-#ifdef RT_BIG_ENDIAN
- UCHAR RecomWidth:1;
- UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
- UCHAR MpduDensity:3;
- UCHAR MaxRAmpduFactor:2;
-#else
- UCHAR MaxRAmpduFactor:2;
- UCHAR MpduDensity:3;
- UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
- UCHAR RecomWidth:1;
-#endif
-
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:11;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv3:1;
- USHORT NonGfPresent:1;
- USHORT OperaionMode:2;
-#else
- USHORT OperaionMode:2;
- USHORT NonGfPresent:1;
- USHORT rsv3:1;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv2:11;
-#endif
-
- // New Extension Channel Offset IE
- UCHAR NewExtChannelOffset;
- // Extension Capability IE = 127
- UCHAR BSSCoexist2040;
-} RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
-
-// field in Addtional HT Information IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR SerInterGranu:3;
- UCHAR S_PSMPSup:1;
- UCHAR RifsMode:1;
- UCHAR RecomWidth:1;
- UCHAR ExtChanOffset:2;
-#else
- UCHAR ExtChanOffset:2;
- UCHAR RecomWidth:1;
- UCHAR RifsMode:1;
- UCHAR S_PSMPSup:1; //Indicate support for scheduled PSMP
- UCHAR SerInterGranu:3; //service interval granularity
-#endif
-} ADD_HTINFO, *PADD_HTINFO;
-
-typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:11;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv:1;
- USHORT NonGfPresent:1;
- USHORT OperaionMode:2;
-#else
- USHORT OperaionMode:2;
- USHORT NonGfPresent:1;
- USHORT rsv:1;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv2:11;
-#endif
-} ADD_HTINFO2, *PADD_HTINFO2;
-
-
-// TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
-typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT rsv:4;
- USHORT PcoPhase:1;
- USHORT PcoActive:1;
- USHORT LsigTxopProt:1;
- USHORT STBCBeacon:1;
- USHORT DualCTSProtect:1;
- USHORT DualBeacon:1;
- USHORT StbcMcs:6;
-#else
- USHORT StbcMcs:6;
- USHORT DualBeacon:1;
- USHORT DualCTSProtect:1;
- USHORT STBCBeacon:1;
- USHORT LsigTxopProt:1; // L-SIG TXOP protection full support
- USHORT PcoActive:1;
- USHORT PcoPhase:1;
- USHORT rsv:4;
-#endif // RT_BIG_ENDIAN //
-} ADD_HTINFO3, *PADD_HTINFO3;
-
-#define SIZE_ADD_HT_INFO_IE 22
-typedef struct PACKED{
- UCHAR ControlChan;
- ADD_HTINFO AddHtInfo;
- ADD_HTINFO2 AddHtInfo2;
- ADD_HTINFO3 AddHtInfo3;
- UCHAR MCSSet[16]; // Basic MCS set
-} ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
-
-typedef struct PACKED{
- UCHAR NewExtChanOffset;
-} NEW_EXT_CHAN_IE, *PNEW_EXT_CHAN_IE;
-
-
-// 4-byte HTC field. maybe included in any frame except non-QOS data frame. The Order bit must set 1.
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UINT32 RDG:1; //RDG / More PPDU
- UINT32 ACConstraint:1; //feedback request
- UINT32 rsv:5; //calibration sequence
- UINT32 ZLFAnnouce:1; // ZLF announcement
- UINT32 CSISTEERING:2; //CSI/ STEERING
- UINT32 FBKReq:2; //feedback request
- UINT32 CalSeq:2; //calibration sequence
- UINT32 CalPos:2; // calibration position
- UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
- UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
- UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
- UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
- UINT32 TRQ:1; //sounding request
- UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
-#else
- UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
- UINT32 TRQ:1; //sounding request
- UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
- UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
- UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
- UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
- UINT32 CalPos:2; // calibration position
- UINT32 CalSeq:2; //calibration sequence
- UINT32 FBKReq:2; //feedback request
- UINT32 CSISTEERING:2; //CSI/ STEERING
- UINT32 ZLFAnnouce:1; // ZLF announcement
- UINT32 rsv:5; //calibration sequence
- UINT32 ACConstraint:1; //feedback request
- UINT32 RDG:1; //RDG / More PPDU
-#endif /* !RT_BIG_ENDIAN */
-} HT_CONTROL, *PHT_CONTROL;
-
-// 2-byte QOS CONTROL field
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Txop_QueueSize:8;
- USHORT AMsduPresent:1;
- USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
- USHORT EOSP:1;
- USHORT TID:4;
-#else
- USHORT TID:4;
- USHORT EOSP:1;
- USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
- USHORT AMsduPresent:1;
- USHORT Txop_QueueSize:8;
-#endif /* !RT_BIG_ENDIAN */
-} QOS_CONTROL, *PQOS_CONTROL;
-
-// 2-byte Frame control field
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Order:1; // Strict order expected
- USHORT Wep:1; // Wep data
- USHORT MoreData:1; // More data bit
- USHORT PwrMgmt:1; // Power management bit
- USHORT Retry:1; // Retry status bit
- USHORT MoreFrag:1; // More fragment bit
- USHORT FrDs:1; // From DS indication
- USHORT ToDs:1; // To DS indication
- USHORT SubType:4; // MSDU subtype
- USHORT Type:2; // MSDU type
- USHORT Ver:2; // Protocol version
-#else
- USHORT Ver:2; // Protocol version
- USHORT Type:2; // MSDU type
- USHORT SubType:4; // MSDU subtype
- USHORT ToDs:1; // To DS indication
- USHORT FrDs:1; // From DS indication
- USHORT MoreFrag:1; // More fragment bit
- USHORT Retry:1; // Retry status bit
- USHORT PwrMgmt:1; // Power management bit
- USHORT MoreData:1; // More data bit
- USHORT Wep:1; // Wep data
- USHORT Order:1; // Strict order expected
-#endif /* !RT_BIG_ENDIAN */
-} FRAME_CONTROL, *PFRAME_CONTROL;
-
-typedef struct PACKED _HEADER_802_11 {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR Addr3[MAC_ADDR_LEN];
-#ifdef RT_BIG_ENDIAN
- USHORT Sequence:12;
- USHORT Frag:4;
-#else
- USHORT Frag:4;
- USHORT Sequence:12;
-#endif /* !RT_BIG_ENDIAN */
- UCHAR Octet[0];
-} HEADER_802_11, *PHEADER_802_11;
-
-typedef struct PACKED _FRAME_802_11 {
- HEADER_802_11 Hdr;
- UCHAR Octet[1];
-} FRAME_802_11, *PFRAME_802_11;
-
-// QoSNull embedding of management action. When HT Control MA field set to 1.
-typedef struct PACKED _MA_BODY {
- UCHAR Category;
- UCHAR Action;
- UCHAR Octet[1];
-} MA_BODY, *PMA_BODY;
-
-typedef struct PACKED _HEADER_802_3 {
- UCHAR DAAddr1[MAC_ADDR_LEN];
- UCHAR SAAddr2[MAC_ADDR_LEN];
- UCHAR Octet[2];
-} HEADER_802_3, *PHEADER_802_3;
-////Block ACK related format
-// 2-byte BA Parameter field in DELBA frames to terminate an already set up bA
-typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4; // value of TC os TS
- USHORT Initiator:1; // 1: originator 0:recipient
- USHORT Rsv:11; // always set to 0
-#else
- USHORT Rsv:11; // always set to 0
- USHORT Initiator:1; // 1: originator 0:recipient
- USHORT TID:4; // value of TC os TS
-#endif /* !RT_BIG_ENDIAN */
-} DELBA_PARM, *PDELBA_PARM;
-
-// 2-byte BA Parameter Set field in ADDBA frames to signal parm for setting up a BA
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT BufSize:10; // number of buffe of size 2304 octetsr
- USHORT TID:4; // value of TC os TS
- USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
- USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
-#else
- USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
- USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
- USHORT TID:4; // value of TC os TS
- USHORT BufSize:10; // number of buffe of size 2304 octetsr
-#endif /* !RT_BIG_ENDIAN */
-} BA_PARM, *PBA_PARM;
-
-// 2-byte BA Starting Seq CONTROL field
-typedef union PACKED {
- struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
- USHORT FragNum:4; // always set to 0
-#else
- USHORT FragNum:4; // always set to 0
- USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
-#endif /* RT_BIG_ENDIAN */
- } field;
- USHORT word;
-} BASEQ_CONTROL, *PBASEQ_CONTROL;
-
-//BAControl and BARControl are the same
-// 2-byte BA CONTROL field in BA frame
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv:9;
- USHORT Compressed:1;
- USHORT MTID:1; //EWC V1.24
- USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
-#else
- USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
- USHORT MTID:1; //EWC V1.24
- USHORT Compressed:1;
- USHORT Rsv:9;
- USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
-} BA_CONTROL, *PBA_CONTROL;
-
-// 2-byte BAR CONTROL field in BAR frame
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv1:9;
- USHORT Compressed:1;
- USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
- USHORT ACKPolicy:1;
-#else
- USHORT ACKPolicy:1; // 0:normal ack, 1:no ack.
- USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
- USHORT Compressed:1;
- USHORT Rsv1:9;
- USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
-} BAR_CONTROL, *PBAR_CONTROL;
-
-// BARControl in MTBAR frame
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT NumTID:4;
- USHORT Rsv1:9;
- USHORT Compressed:1;
- USHORT MTID:1;
- USHORT ACKPolicy:1;
-#else
- USHORT ACKPolicy:1;
- USHORT MTID:1;
- USHORT Compressed:1;
- USHORT Rsv1:9;
- USHORT NumTID:4;
-#endif /* !RT_BIG_ENDIAN */
-} MTBAR_CONTROL, *PMTBAR_CONTROL;
-
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv1:12;
-#else
- USHORT Rsv1:12;
- USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
-} PER_TID_INFO, *PPER_TID_INFO;
-
-typedef struct {
- PER_TID_INFO PerTID;
- BASEQ_CONTROL BAStartingSeq;
-} EACH_TID, *PEACH_TID;
-
-
-typedef struct PACKED _PSPOLL_FRAME {
- FRAME_CONTROL FC;
- USHORT Aid;
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR Ta[MAC_ADDR_LEN];
-} PSPOLL_FRAME, *PPSPOLL_FRAME;
-
-typedef struct PACKED _RTS_FRAME {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
-}RTS_FRAME, *PRTS_FRAME;
-
-// BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap.
-typedef struct PACKED _FRAME_BA_REQ {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BAR_CONTROL BARControl;
- BASEQ_CONTROL BAStartingSeq;
-} FRAME_BA_REQ, *PFRAME_BA_REQ;
-
-typedef struct PACKED _FRAME_MTBA_REQ {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- MTBAR_CONTROL MTBARControl;
- PER_TID_INFO PerTIDInfo;
- BASEQ_CONTROL BAStartingSeq;
-} FRAME_MTBA_REQ, *PFRAME_MTBA_REQ;
-
-// Compressed format is mandantory in HT STA
-typedef struct PACKED _FRAME_MTBA {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BA_CONTROL BAControl;
- BASEQ_CONTROL BAStartingSeq;
- UCHAR BitMap[8];
-} FRAME_MTBA, *PFRAME_MTBA;
-
-typedef struct PACKED _FRAME_PSMP_ACTION {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Psmp; // 7.3.1.25
-} FRAME_PSMP_ACTION, *PFRAME_PSMP_ACTION;
-
-typedef struct PACKED _FRAME_ACTION_HDR {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
-} FRAME_ACTION_HDR, *PFRAME_ACTION_HDR;
-
-//Action Frame
-//Action Frame Category:Spectrum, Action:Channel Switch. 7.3.2.20
-typedef struct PACKED _CHAN_SWITCH_ANNOUNCE {
- UCHAR ElementID; // ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37
- UCHAR Len;
- CHA_SWITCH_ANNOUNCE_IE CSAnnounceIe;
-} CHAN_SWITCH_ANNOUNCE, *PCHAN_SWITCH_ANNOUNCE;
-
-
-//802.11n : 7.3.2.20a
-typedef struct PACKED _SECOND_CHAN_OFFSET {
- UCHAR ElementID; // ID = IE_SECONDARY_CH_OFFSET = 62
- UCHAR Len;
- SEC_CHA_OFFSET_IE SecChOffsetIe;
-} SECOND_CHAN_OFFSET, *PSECOND_CHAN_OFFSET;
-
-
-typedef struct PACKED _FRAME_SPETRUM_CS {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- CHAN_SWITCH_ANNOUNCE CSAnnounce;
- SECOND_CHAN_OFFSET SecondChannel;
-} FRAME_SPETRUM_CS, *PFRAME_SPETRUM_CS;
-
-
-typedef struct PACKED _FRAME_ADDBA_REQ {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Token; // 1
- BA_PARM BaParm; // 2 - 10
- USHORT TimeOutValue; // 0 - 0
- BASEQ_CONTROL BaStartSeq; // 0-0
-} FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
-
-typedef struct PACKED _FRAME_ADDBA_RSP {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Token;
- USHORT StatusCode;
- BA_PARM BaParm; //0 - 2
- USHORT TimeOutValue;
-} FRAME_ADDBA_RSP, *PFRAME_ADDBA_RSP;
-
-typedef struct PACKED _FRAME_DELBA_REQ {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- DELBA_PARM DelbaParm;
- USHORT ReasonCode;
-} FRAME_DELBA_REQ, *PFRAME_DELBA_REQ;
-
-
-//7.2.1.7
-typedef struct PACKED _FRAME_BAR {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BAR_CONTROL BarControl;
- BASEQ_CONTROL StartingSeq;
-} FRAME_BAR, *PFRAME_BAR;
-
-//7.2.1.7
-typedef struct PACKED _FRAME_BA {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BAR_CONTROL BarControl;
- BASEQ_CONTROL StartingSeq;
- UCHAR bitmask[8];
-} FRAME_BA, *PFRAME_BA;
-
-
-// Radio Measuement Request Frame Format
-typedef struct PACKED _FRAME_RM_REQ_ACTION {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Token;
- USHORT Repetition;
- UCHAR data[0];
-} FRAME_RM_REQ_ACTION, *PFRAME_RM_REQ_ACTION;
-
-typedef struct PACKED {
- UCHAR ID;
- UCHAR Length;
- UCHAR ChannelSwitchMode;
- UCHAR NewRegClass;
- UCHAR NewChannelNum;
- UCHAR ChannelSwitchCount;
-} HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE, *PHT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE;
-
-
-//
-// _Limit must be the 2**n - 1
-// _SEQ1 , _SEQ2 must be within 0 ~ _Limit
-//
-#define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit) ((_SEQ1 == ((_SEQ2+1) & _Limit)))
-#define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit) (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
-#define SEQ_LARGER(_SEQ1, _SEQ2, _Limit) ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
-#define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) && \
- SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
-
-//
-// Contention-free parameter (without ID and Length)
-//
-typedef struct PACKED {
- BOOLEAN bValid; // 1: variable contains valid value
- UCHAR CfpCount;
- UCHAR CfpPeriod;
- USHORT CfpMaxDuration;
- USHORT CfpDurRemaining;
-} CF_PARM, *PCF_PARM;
-
-typedef struct _CIPHER_SUITE {
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher 1, this one has more secured cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipherAux; // Unicast cipher 2 if AP announce two unicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Group cipher
- USHORT RsnCapability; // RSN capability from beacon
- BOOLEAN bMixMode; // Indicate Pair & Group cipher might be different
-} CIPHER_SUITE, *PCIPHER_SUITE;
-
-// EDCA configuration from AP's BEACON/ProbeRsp
-typedef struct {
- BOOLEAN bValid; // 1: variable contains valid value
- BOOLEAN bAdd; // 1: variable contains valid value
- BOOLEAN bQAck;
- BOOLEAN bQueueRequest;
- BOOLEAN bTxopRequest;
- BOOLEAN bAPSDCapable;
-// BOOLEAN bMoreDataAck;
- UCHAR EdcaUpdateCount;
- UCHAR Aifsn[4]; // 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO
- UCHAR Cwmin[4];
- UCHAR Cwmax[4];
- USHORT Txop[4]; // in unit of 32-us
- BOOLEAN bACM[4]; // 1: Admission Control of AC_BK is mandattory
-} EDCA_PARM, *PEDCA_PARM;
-
-// QBSS LOAD information from QAP's BEACON/ProbeRsp
-typedef struct {
- BOOLEAN bValid; // 1: variable contains valid value
- USHORT StaNum;
- UCHAR ChannelUtilization;
- USHORT RemainingAdmissionControl; // in unit of 32-us
-} QBSS_LOAD_PARM, *PQBSS_LOAD_PARM;
-
-// QBSS Info field in QSTA's assoc req
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR Rsv2:1;
- UCHAR MaxSPLength:2;
- UCHAR Rsv1:1;
- UCHAR UAPSD_AC_BE:1;
- UCHAR UAPSD_AC_BK:1;
- UCHAR UAPSD_AC_VI:1;
- UCHAR UAPSD_AC_VO:1;
-#else
- UCHAR UAPSD_AC_VO:1;
- UCHAR UAPSD_AC_VI:1;
- UCHAR UAPSD_AC_BK:1;
- UCHAR UAPSD_AC_BE:1;
- UCHAR Rsv1:1;
- UCHAR MaxSPLength:2;
- UCHAR Rsv2:1;
-#endif /* !RT_BIG_ENDIAN */
-} QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
-
-// QBSS Info field in QAP's Beacon/ProbeRsp
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR UAPSD:1;
- UCHAR Rsv:3;
- UCHAR ParamSetCount:4;
-#else
- UCHAR ParamSetCount:4;
- UCHAR Rsv:3;
- UCHAR UAPSD:1;
-#endif /* !RT_BIG_ENDIAN */
-} QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
-
-// QOS Capability reported in QAP's BEACON/ProbeRsp
-// QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq
-typedef struct {
- BOOLEAN bValid; // 1: variable contains valid value
- BOOLEAN bQAck;
- BOOLEAN bQueueRequest;
- BOOLEAN bTxopRequest;
-// BOOLEAN bMoreDataAck;
- UCHAR EdcaUpdateCount;
-} QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
-
-#ifdef CONFIG_STA_SUPPORT
-typedef struct {
- UCHAR IELen;
- UCHAR IE[MAX_CUSTOM_LEN];
-} WPA_IE_;
-#endif // CONFIG_STA_SUPPORT //
-
-
-typedef struct {
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR Channel;
- UCHAR CentralChannel; //Store the wide-band central channel for 40MHz. .used in 40MHz AP. Or this is the same as Channel.
- UCHAR BssType;
- USHORT AtimWin;
- USHORT BeaconPeriod;
-
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen;
- HT_CAPABILITY_IE HtCapability;
- UCHAR HtCapabilityLen;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR AddHtInfoLen;
- UCHAR NewExtChanOffset;
- CHAR Rssi;
- UCHAR Privacy; // Indicate security function ON/OFF. Don't mess up with auth mode.
- UCHAR Hidden;
-
- USHORT DtimPeriod;
- USHORT CapabilityInfo;
-
- USHORT CfpCount;
- USHORT CfpPeriod;
- USHORT CfpMaxDuration;
- USHORT CfpDurRemaining;
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
-
- ULONG LastBeaconRxTime; // OS's timestamp
-
- BOOLEAN bSES;
-
- // New for WPA2
- CIPHER_SUITE WPA; // AP announced WPA cipher suite
- CIPHER_SUITE WPA2; // AP announced WPA2 cipher suite
-
- // New for microsoft WPA support
- NDIS_802_11_FIXED_IEs FixIEs;
- NDIS_802_11_AUTHENTICATION_MODE AuthModeAux; // Addition mode for WPA2 / WPA capable AP
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus; // Unicast Encryption Algorithm extract from VAR_IE
- USHORT VarIELen; // Length of next VIE include EID & Length
- UCHAR VarIEs[MAX_VIE_LEN];
-
- // CCX Ckip information
- UCHAR CkipFlag;
-
- // CCX 2 TSF
- UCHAR PTSF[4]; // Parent TSF
- UCHAR TTSF[8]; // Target TSF
-
- // 802.11e d9, and WMM
- EDCA_PARM EdcaParm;
- QOS_CAPABILITY_PARM QosCapability;
- QBSS_LOAD_PARM QbssLoad;
-#ifdef CONFIG_STA_SUPPORT
- WPA_IE_ WpaIE;
- WPA_IE_ RsnIE;
-#ifdef EXT_BUILD_CHANNEL_LIST
- UCHAR CountryString[3];
- BOOLEAN bHasCountryIE;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
-} BSS_ENTRY, *PBSS_ENTRY;
-
-typedef struct {
- UCHAR BssNr;
- UCHAR BssOverlapNr;
- BSS_ENTRY BssEntry[MAX_LEN_OF_BSS_TABLE];
-} BSS_TABLE, *PBSS_TABLE;
-
-
-typedef struct _MLME_QUEUE_ELEM {
- ULONG Machine;
- ULONG MsgType;
- ULONG MsgLen;
- UCHAR Msg[MGMT_DMA_BUFFER_SIZE];
- LARGE_INTEGER TimeStamp;
- UCHAR Rssi0;
- UCHAR Rssi1;
- UCHAR Rssi2;
- UCHAR Signal;
- UCHAR Channel;
- UCHAR Wcid;
- BOOLEAN Occupied;
-} MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM;
-
-typedef struct _MLME_QUEUE {
- ULONG Num;
- ULONG Head;
- ULONG Tail;
- NDIS_SPIN_LOCK Lock;
- MLME_QUEUE_ELEM Entry[MAX_LEN_OF_MLME_QUEUE];
-} MLME_QUEUE, *PMLME_QUEUE;
-
-typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem);
-
-typedef struct _STATE_MACHINE {
- ULONG Base;
- ULONG NrState;
- ULONG NrMsg;
- ULONG CurrState;
- STATE_MACHINE_FUNC *TransFunc;
-} STATE_MACHINE, *PSTATE_MACHINE;
-
-
-// MLME AUX data structure that hold temporarliy settings during a connection attempt.
-// Once this attemp succeeds, all settings will be copy to pAd->StaActive.
-// A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of
-// several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely
-// separate this under-trial settings away from pAd->StaActive so that once
-// this new attempt failed, driver can auto-recover back to the active settings.
-typedef struct _MLME_AUX {
- UCHAR BssType;
- UCHAR Ssid[MAX_LEN_OF_SSID];
- UCHAR SsidLen;
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR AutoReconnectSsid[MAX_LEN_OF_SSID];
- UCHAR AutoReconnectSsidLen;
- USHORT Alg;
- UCHAR ScanType;
- UCHAR Channel;
- UCHAR CentralChannel;
- USHORT Aid;
- USHORT CapabilityInfo;
- USHORT BeaconPeriod;
- USHORT CfpMaxDuration;
- USHORT CfpPeriod;
- USHORT AtimWin;
-
- // Copy supported rate from desired AP's beacon. We are trying to match
- // AP's supported and extended rate settings.
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRateLen;
- HT_CAPABILITY_IE HtCapability;
- UCHAR HtCapabilityLen;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR NewExtChannelOffset;
- //RT_HT_CAPABILITY SupportedHtPhy;
-
- // new for QOS
- QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
- EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
- QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
-
- // new to keep Ralink specific feature
- ULONG APRalinkIe;
-
- BSS_TABLE SsidBssTab; // AP list for the same SSID
- BSS_TABLE RoamTab; // AP list eligible for roaming
- ULONG BssIdx;
- ULONG RoamIdx;
-
- BOOLEAN CurrReqIsFromNdis;
-
- RALINK_TIMER_STRUCT BeaconTimer, ScanTimer;
- RALINK_TIMER_STRUCT AuthTimer;
- RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
-} MLME_AUX, *PMLME_AUX;
-
-typedef struct _MLME_ADDBA_REQ_STRUCT{
- UCHAR Wcid; //
- UCHAR pAddr[MAC_ADDR_LEN];
- UCHAR BaBufSize;
- USHORT TimeOutValue;
- UCHAR TID;
- UCHAR Token;
- USHORT BaStartSeq;
-} MLME_ADDBA_REQ_STRUCT, *PMLME_ADDBA_REQ_STRUCT;
-
-
-typedef struct _MLME_DELBA_REQ_STRUCT{
- UCHAR Wcid; //
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR TID;
- UCHAR Initiator;
-} MLME_DELBA_REQ_STRUCT, *PMLME_DELBA_REQ_STRUCT;
-
-// assoc struct is equal to reassoc
-typedef struct _MLME_ASSOC_REQ_STRUCT{
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT CapabilityInfo;
- USHORT ListenIntv;
- ULONG Timeout;
-} MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT;
-
-typedef struct _MLME_DISASSOC_REQ_STRUCT{
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Reason;
-} MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT;
-
-typedef struct _MLME_AUTH_REQ_STRUCT {
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Alg;
- ULONG Timeout;
-} MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT;
-
-typedef struct _MLME_DEAUTH_REQ_STRUCT {
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Reason;
-} MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
-
-typedef struct {
- ULONG BssIdx;
-} MLME_JOIN_REQ_STRUCT;
-
-typedef struct _MLME_SCAN_REQ_STRUCT {
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR BssType;
- UCHAR ScanType;
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
-} MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT;
-
-typedef struct _MLME_START_REQ_STRUCT {
- CHAR Ssid[MAX_LEN_OF_SSID];
- UCHAR SsidLen;
-} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-// structure for DLS
-typedef struct _RT_802_11_DLS {
- USHORT TimeOut; // Use to time out while slience, unit: second , set by UI
- USHORT CountDownTimer; // Use to time out while slience,unit: second , used by driver only
- NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
- UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
- BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
- RALINK_TIMER_STRUCT Timer; // Use to time out while handshake
- USHORT Sequence;
- USHORT MacTabMatchWCID; // ASIC
- BOOLEAN bHTCap;
- PVOID pAd;
-} RT_802_11_DLS, *PRT_802_11_DLS;
-
-typedef struct _MLME_DLS_REQ_STRUCT {
- PRT_802_11_DLS pDLS;
- USHORT Reason;
-} MLME_DLS_REQ_STRUCT, *PMLME_DLS_REQ_STRUCT;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-typedef struct PACKED {
- UCHAR Eid;
- UCHAR Len;
- CHAR Octet[1];
-} EID_STRUCT,*PEID_STRUCT, BEACON_EID_STRUCT, *PBEACON_EID_STRUCT;
-
-typedef struct PACKED _RTMP_TX_RATE_SWITCH
-{
- UCHAR ItemNo;
-#ifdef RT_BIG_ENDIAN
- UCHAR Rsv2:2;
- UCHAR Mode:2;
- UCHAR Rsv1:1;
- UCHAR BW:1;
- UCHAR ShortGI:1;
- UCHAR STBC:1;
-#else
- UCHAR STBC:1;
- UCHAR ShortGI:1;
- UCHAR BW:1;
- UCHAR Rsv1:1;
- UCHAR Mode:2;
- UCHAR Rsv2:2;
-#endif
- UCHAR CurrMCS;
- UCHAR TrainUp;
- UCHAR TrainDown;
-} RRTMP_TX_RATE_SWITCH, *PRTMP_TX_RATE_SWITCH;
-
-// ========================== AP mlme.h ===============================
-#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps
-#define DEFAULT_DTIM_PERIOD 1
-
-// weighting factor to calculate Channel quality, total should be 100%
-//#define RSSI_WEIGHTING 0
-//#define TX_WEIGHTING 40
-//#define RX_WEIGHTING 60
-
-#define MAC_TABLE_AGEOUT_TIME 300 // unit: sec
-#define MAC_TABLE_ASSOC_TIMEOUT 5 // unit: sec
-#define MAC_TABLE_FULL(Tab) ((Tab).size == MAX_LEN_OF_MAC_TABLE)
-
-// AP shall drop the sta if contine Tx fail count reach it.
-#define MAC_ENTRY_LIFE_CHECK_CNT 20 // packet cnt.
-
-// Value domain of pMacEntry->Sst
-typedef enum _Sst {
- SST_NOT_AUTH, // 0: equivalent to IEEE 802.11/1999 state 1
- SST_AUTH, // 1: equivalent to IEEE 802.11/1999 state 2
- SST_ASSOC // 2: equivalent to IEEE 802.11/1999 state 3
-} SST;
-
-// value domain of pMacEntry->AuthState
-typedef enum _AuthState {
- AS_NOT_AUTH,
- AS_AUTH_OPEN, // STA has been authenticated using OPEN SYSTEM
- AS_AUTH_KEY, // STA has been authenticated using SHARED KEY
- AS_AUTHENTICATING // STA is waiting for AUTH seq#3 using SHARED KEY
-} AUTH_STATE;
-
-//for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
-typedef enum _ApWpaState {
- AS_NOTUSE, // 0
- AS_DISCONNECT, // 1
- AS_DISCONNECTED, // 2
- AS_INITIALIZE, // 3
- AS_AUTHENTICATION, // 4
- AS_AUTHENTICATION2, // 5
- AS_INITPMK, // 6
- AS_INITPSK, // 7
- AS_PTKSTART, // 8
- AS_PTKINIT_NEGOTIATING, // 9
- AS_PTKINITDONE, // 10
- AS_UPDATEKEYS, // 11
- AS_INTEGRITY_FAILURE, // 12
- AS_KEYUPDATE, // 13
-} AP_WPA_STATE;
-
-// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
-typedef enum _GTKState {
- REKEY_NEGOTIATING,
- REKEY_ESTABLISHED,
- KEYERROR,
-} GTK_STATE;
-
-// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
-typedef enum _WpaGTKState {
- SETKEYS,
- SETKEYS_DONE,
-} WPA_GTK_STATE;
-// ====================== end of AP mlme.h ============================
-
-
-#endif // MLME_H__
+#include "../rt2860/mlme.h"
diff --git a/drivers/staging/rt2870/netif_block.h b/drivers/staging/rt2870/netif_block.h
deleted file mode 100644
index 6e5151c41095..000000000000
--- a/drivers/staging/rt2870/netif_block.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __NET_IF_BLOCK_H__
-#define __NET_IF_BLOCK_H__
-
-//#include <linux/device.h>
-#include "link_list.h"
-#include "rtmp.h"
-
-#define FREE_NETIF_POOL_SIZE 32
-
-typedef struct _NETIF_ENTRY
-{
- struct _NETIF_ENTRY *pNext;
- PNET_DEV pNetDev;
-} NETIF_ENTRY, *PNETIF_ENTRY;
-
-void initblockQueueTab(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN blockNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
- IN PNET_DEV pNetDev);
-
-VOID releaseNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry);
-
-VOID StopNetIfQueue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-#endif // __NET_IF_BLOCK_H__
-
diff --git a/drivers/staging/rt2870/oid.h b/drivers/staging/rt2870/oid.h
index d788db6b6264..1223d81bfc62 100644
--- a/drivers/staging/rt2870/oid.h
+++ b/drivers/staging/rt2870/oid.h
@@ -1,1091 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- oid.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef _OID_H_
-#define _OID_H_
-
-#define TRUE 1
-#define FALSE 0
-//
-// IEEE 802.11 Structures and definitions
-//
-#define MAX_TX_POWER_LEVEL 100 /* mW */
-#define MAX_RSSI_TRIGGER -10 /* dBm */
-#define MIN_RSSI_TRIGGER -200 /* dBm */
-#define MAX_FRAG_THRESHOLD 2346 /* byte count */
-#define MIN_FRAG_THRESHOLD 256 /* byte count */
-#define MAX_RTS_THRESHOLD 2347 /* byte count */
-
-// new types for Media Specific Indications
-// Extension channel offset
-#define EXTCHA_NONE 0
-#define EXTCHA_ABOVE 0x1
-#define EXTCHA_BELOW 0x3
-
-// BW
-#define BAND_WIDTH_20 0
-#define BAND_WIDTH_40 1
-#define BAND_WIDTH_BOTH 2
-#define BAND_WIDTH_10 3 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-// SHORTGI
-#define GAP_INTERVAL_400 1 // only support in HT mode
-#define GAP_INTERVAL_800 0
-#define GAP_INTERVAL_BOTH 2
-
-#define NdisMediaStateConnected 1
-#define NdisMediaStateDisconnected 0
-
-#define NDIS_802_11_LENGTH_SSID 32
-#define NDIS_802_11_LENGTH_RATES 8
-#define NDIS_802_11_LENGTH_RATES_EX 16
-#define MAC_ADDR_LENGTH 6
-#define MAX_NUM_OF_CHS 49 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL terminationc
-#define MAX_NUMBER_OF_EVENT 10 // entry # in EVENT table
-#define MAX_NUMBER_OF_MAC 32 // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
-#define MAX_NUMBER_OF_ACL 64
-#define MAX_LENGTH_OF_SUPPORT_RATES 12 // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
-#define MAX_NUMBER_OF_DLS_ENTRY 4
-
-#ifndef UNDER_CE
-// OID definition, since NDIS 5.0 didn't define these, we need to define for our own
-//#if _WIN32_WINNT<=0x0500
-
-#define OID_GEN_MACHINE_NAME 0x0001021A
-
-#ifdef RALINK_ATE
-#define RT_QUERY_ATE_TXDONE_COUNT 0x0401
-#endif // RALINK_ATE //
-#define RT_QUERY_SIGNAL_CONTEXT 0x0402
-#define RT_SET_IAPP_PID 0x0404
-#define RT_SET_APD_PID 0x0405
-#define RT_SET_DEL_MAC_ENTRY 0x0406
-
-//
-// IEEE 802.11 OIDs
-//
-#define OID_GET_SET_TOGGLE 0x8000
-
-#define OID_802_11_NETWORK_TYPES_SUPPORTED 0x0103
-#define OID_802_11_NETWORK_TYPE_IN_USE 0x0104
-#define OID_802_11_RSSI_TRIGGER 0x0107
-#define RT_OID_802_11_RSSI 0x0108 //rt2860 only , kathy
-#define RT_OID_802_11_RSSI_1 0x0109 //rt2860 only , kathy
-#define RT_OID_802_11_RSSI_2 0x010A //rt2860 only , kathy
-#define OID_802_11_NUMBER_OF_ANTENNAS 0x010B
-#define OID_802_11_RX_ANTENNA_SELECTED 0x010C
-#define OID_802_11_TX_ANTENNA_SELECTED 0x010D
-#define OID_802_11_SUPPORTED_RATES 0x010E
-#define OID_802_11_ADD_WEP 0x0112
-#define OID_802_11_REMOVE_WEP 0x0113
-#define OID_802_11_DISASSOCIATE 0x0114
-#define OID_802_11_PRIVACY_FILTER 0x0118
-#define OID_802_11_ASSOCIATION_INFORMATION 0x011E
-#define OID_802_11_TEST 0x011F
-#define RT_OID_802_11_COUNTRY_REGION 0x0507
-#define OID_802_11_BSSID_LIST_SCAN 0x0508
-#define OID_802_11_SSID 0x0509
-#define OID_802_11_BSSID 0x050A
-#define RT_OID_802_11_RADIO 0x050B
-#define RT_OID_802_11_PHY_MODE 0x050C
-#define RT_OID_802_11_STA_CONFIG 0x050D
-#define OID_802_11_DESIRED_RATES 0x050E
-#define RT_OID_802_11_PREAMBLE 0x050F
-#define OID_802_11_WEP_STATUS 0x0510
-#define OID_802_11_AUTHENTICATION_MODE 0x0511
-#define OID_802_11_INFRASTRUCTURE_MODE 0x0512
-#define RT_OID_802_11_RESET_COUNTERS 0x0513
-#define OID_802_11_RTS_THRESHOLD 0x0514
-#define OID_802_11_FRAGMENTATION_THRESHOLD 0x0515
-#define OID_802_11_POWER_MODE 0x0516
-#define OID_802_11_TX_POWER_LEVEL 0x0517
-#define RT_OID_802_11_ADD_WPA 0x0518
-#define OID_802_11_REMOVE_KEY 0x0519
-#define OID_802_11_ADD_KEY 0x0520
-#define OID_802_11_CONFIGURATION 0x0521
-#define OID_802_11_TX_PACKET_BURST 0x0522
-#define RT_OID_802_11_QUERY_NOISE_LEVEL 0x0523
-#define RT_OID_802_11_EXTRA_INFO 0x0524
-#ifdef DBG
-#define RT_OID_802_11_HARDWARE_REGISTER 0x0525
-#endif
-#define OID_802_11_ENCRYPTION_STATUS OID_802_11_WEP_STATUS
-#define OID_802_11_DEAUTHENTICATION 0x0526
-#define OID_802_11_DROP_UNENCRYPTED 0x0527
-#define OID_802_11_MIC_FAILURE_REPORT_FRAME 0x0528
-
-// For 802.1x daemin using to require current driver configuration
-#define OID_802_11_RADIUS_QUERY_SETTING 0x0540
-
-#define RT_OID_DEVICE_NAME 0x0607
-#define RT_OID_VERSION_INFO 0x0608
-#define OID_802_11_BSSID_LIST 0x0609
-#define OID_802_3_CURRENT_ADDRESS 0x060A
-#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B
-#define RT_OID_802_11_QUERY_LINK_STATUS 0x060C
-#define OID_802_11_RSSI 0x060D
-#define OID_802_11_STATISTICS 0x060E
-#define OID_GEN_RCV_OK 0x060F
-#define OID_GEN_RCV_NO_BUFFER 0x0610
-#define RT_OID_802_11_QUERY_EEPROM_VERSION 0x0611
-#define RT_OID_802_11_QUERY_FIRMWARE_VERSION 0x0612
-#define RT_OID_802_11_QUERY_LAST_RX_RATE 0x0613
-#define RT_OID_802_11_TX_POWER_LEVEL_1 0x0614
-#define RT_OID_802_11_QUERY_PIDVID 0x0615
-//for WPA_SUPPLICANT_SUPPORT
-#define OID_SET_COUNTERMEASURES 0x0616
-#define OID_802_11_SET_IEEE8021X 0x0617
-#define OID_802_11_SET_IEEE8021X_REQUIRE_KEY 0x0618
-#define OID_802_11_PMKID 0x0620
-#define RT_OID_WPA_SUPPLICANT_SUPPORT 0x0621
-#define RT_OID_WE_VERSION_COMPILED 0x0622
-#define RT_OID_NEW_DRIVER 0x0623
-
-
-//rt2860 , kathy
-#define RT_OID_802_11_SNR_0 0x0630
-#define RT_OID_802_11_SNR_1 0x0631
-#define RT_OID_802_11_QUERY_LAST_TX_RATE 0x0632
-#define RT_OID_802_11_QUERY_HT_PHYMODE 0x0633
-#define RT_OID_802_11_SET_HT_PHYMODE 0x0634
-#define OID_802_11_RELOAD_DEFAULTS 0x0635
-#define RT_OID_802_11_QUERY_APSD_SETTING 0x0636
-#define RT_OID_802_11_SET_APSD_SETTING 0x0637
-#define RT_OID_802_11_QUERY_APSD_PSM 0x0638
-#define RT_OID_802_11_SET_APSD_PSM 0x0639
-#define RT_OID_802_11_QUERY_DLS 0x063A
-#define RT_OID_802_11_SET_DLS 0x063B
-#define RT_OID_802_11_QUERY_DLS_PARAM 0x063C
-#define RT_OID_802_11_SET_DLS_PARAM 0x063D
-#define RT_OID_802_11_QUERY_WMM 0x063E
-#define RT_OID_802_11_SET_WMM 0x063F
-#define RT_OID_802_11_QUERY_IMME_BA_CAP 0x0640
-#define RT_OID_802_11_SET_IMME_BA_CAP 0x0641
-#define RT_OID_802_11_QUERY_BATABLE 0x0642
-#define RT_OID_802_11_ADD_IMME_BA 0x0643
-#define RT_OID_802_11_TEAR_IMME_BA 0x0644
-#define RT_OID_DRIVER_DEVICE_NAME 0x0645
-#define RT_OID_802_11_QUERY_DAT_HT_PHYMODE 0x0646
-#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT 0x0647
-
-// Ralink defined OIDs
-// Dennis Lee move to platform specific
-
-#define RT_OID_802_11_BSSID (OID_GET_SET_TOGGLE | OID_802_11_BSSID)
-#define RT_OID_802_11_SSID (OID_GET_SET_TOGGLE | OID_802_11_SSID)
-#define RT_OID_802_11_INFRASTRUCTURE_MODE (OID_GET_SET_TOGGLE | OID_802_11_INFRASTRUCTURE_MODE)
-#define RT_OID_802_11_ADD_WEP (OID_GET_SET_TOGGLE | OID_802_11_ADD_WEP)
-#define RT_OID_802_11_ADD_KEY (OID_GET_SET_TOGGLE | OID_802_11_ADD_KEY)
-#define RT_OID_802_11_REMOVE_WEP (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_WEP)
-#define RT_OID_802_11_REMOVE_KEY (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_KEY)
-#define RT_OID_802_11_DISASSOCIATE (OID_GET_SET_TOGGLE | OID_802_11_DISASSOCIATE)
-#define RT_OID_802_11_AUTHENTICATION_MODE (OID_GET_SET_TOGGLE | OID_802_11_AUTHENTICATION_MODE)
-#define RT_OID_802_11_PRIVACY_FILTER (OID_GET_SET_TOGGLE | OID_802_11_PRIVACY_FILTER)
-#define RT_OID_802_11_BSSID_LIST_SCAN (OID_GET_SET_TOGGLE | OID_802_11_BSSID_LIST_SCAN)
-#define RT_OID_802_11_WEP_STATUS (OID_GET_SET_TOGGLE | OID_802_11_WEP_STATUS)
-#define RT_OID_802_11_RELOAD_DEFAULTS (OID_GET_SET_TOGGLE | OID_802_11_RELOAD_DEFAULTS)
-#define RT_OID_802_11_NETWORK_TYPE_IN_USE (OID_GET_SET_TOGGLE | OID_802_11_NETWORK_TYPE_IN_USE)
-#define RT_OID_802_11_TX_POWER_LEVEL (OID_GET_SET_TOGGLE | OID_802_11_TX_POWER_LEVEL)
-#define RT_OID_802_11_RSSI_TRIGGER (OID_GET_SET_TOGGLE | OID_802_11_RSSI_TRIGGER)
-#define RT_OID_802_11_FRAGMENTATION_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_FRAGMENTATION_THRESHOLD)
-#define RT_OID_802_11_RTS_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_RTS_THRESHOLD)
-#define RT_OID_802_11_RX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_RX_ANTENNA_SELECTED)
-#define RT_OID_802_11_TX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_TX_ANTENNA_SELECTED)
-#define RT_OID_802_11_SUPPORTED_RATES (OID_GET_SET_TOGGLE | OID_802_11_SUPPORTED_RATES)
-#define RT_OID_802_11_DESIRED_RATES (OID_GET_SET_TOGGLE | OID_802_11_DESIRED_RATES)
-#define RT_OID_802_11_CONFIGURATION (OID_GET_SET_TOGGLE | OID_802_11_CONFIGURATION)
-#define RT_OID_802_11_POWER_MODE (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE)
-
-typedef enum _NDIS_802_11_STATUS_TYPE
-{
- Ndis802_11StatusType_Authentication,
- Ndis802_11StatusType_MediaStreamMode,
- Ndis802_11StatusType_PMKID_CandidateList,
- Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
-} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
-
-typedef UCHAR NDIS_802_11_MAC_ADDRESS[6];
-
-typedef struct _NDIS_802_11_STATUS_INDICATION
-{
- NDIS_802_11_STATUS_TYPE StatusType;
-} NDIS_802_11_STATUS_INDICATION, *PNDIS_802_11_STATUS_INDICATION;
-
-// mask for authentication/integrity fields
-#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
-
-#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
-#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
-#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
-#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
-
-typedef struct _NDIS_802_11_AUTHENTICATION_REQUEST
-{
- ULONG Length; // Length of structure
- NDIS_802_11_MAC_ADDRESS Bssid;
- ULONG Flags;
-} NDIS_802_11_AUTHENTICATION_REQUEST, *PNDIS_802_11_AUTHENTICATION_REQUEST;
-
-//Added new types for PMKID Candidate lists.
-typedef struct _PMKID_CANDIDATE {
- NDIS_802_11_MAC_ADDRESS BSSID;
- ULONG Flags;
-} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
-
-typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
-{
- ULONG Version; // Version of the structure
- ULONG NumCandidates; // No. of pmkid candidates
- PMKID_CANDIDATE CandidateList[1];
-} NDIS_802_11_PMKID_CANDIDATE_LIST, *PNDIS_802_11_PMKID_CANDIDATE_LIST;
-
-//Flags for PMKID Candidate list structure
-#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
-
-// Added new types for OFDM 5G and 2.4G
-typedef enum _NDIS_802_11_NETWORK_TYPE
-{
- Ndis802_11FH,
- Ndis802_11DS,
- Ndis802_11OFDM5,
- Ndis802_11OFDM5_N,
- Ndis802_11OFDM24,
- Ndis802_11OFDM24_N,
- Ndis802_11Automode,
- Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
-} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
-
-typedef struct _NDIS_802_11_NETWORK_TYPE_LIST
-{
- UINT NumberOfItems; // in list below, at least 1
- NDIS_802_11_NETWORK_TYPE NetworkType [1];
-} NDIS_802_11_NETWORK_TYPE_LIST, *PNDIS_802_11_NETWORK_TYPE_LIST;
-
-typedef enum _NDIS_802_11_POWER_MODE
-{
- Ndis802_11PowerModeCAM,
- Ndis802_11PowerModeMAX_PSP,
- Ndis802_11PowerModeFast_PSP,
- Ndis802_11PowerModeLegacy_PSP,
- Ndis802_11PowerModeMax // not a real mode, defined as an upper bound
-} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
-
-typedef ULONG NDIS_802_11_TX_POWER_LEVEL; // in milliwatts
-
-//
-// Received Signal Strength Indication
-//
-typedef LONG NDIS_802_11_RSSI; // in dBm
-
-typedef struct _NDIS_802_11_CONFIGURATION_FH
-{
- ULONG Length; // Length of structure
- ULONG HopPattern; // As defined by 802.11, MSB set
- ULONG HopSet; // to one if non-802.11
- ULONG DwellTime; // units are Kusec
-} NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
-
-typedef struct _NDIS_802_11_CONFIGURATION
-{
- ULONG Length; // Length of structure
- ULONG BeaconPeriod; // units are Kusec
- ULONG ATIMWindow; // units are Kusec
- ULONG DSConfig; // Frequency, units are kHz
- NDIS_802_11_CONFIGURATION_FH FHConfig;
-} NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
-
-typedef struct _NDIS_802_11_STATISTICS
-{
- ULONG Length; // Length of structure
- LARGE_INTEGER TransmittedFragmentCount;
- LARGE_INTEGER MulticastTransmittedFrameCount;
- LARGE_INTEGER FailedCount;
- LARGE_INTEGER RetryCount;
- LARGE_INTEGER MultipleRetryCount;
- LARGE_INTEGER RTSSuccessCount;
- LARGE_INTEGER RTSFailureCount;
- LARGE_INTEGER ACKFailureCount;
- LARGE_INTEGER FrameDuplicateCount;
- LARGE_INTEGER ReceivedFragmentCount;
- LARGE_INTEGER MulticastReceivedFrameCount;
- LARGE_INTEGER FCSErrorCount;
- LARGE_INTEGER TKIPLocalMICFailures;
- LARGE_INTEGER TKIPRemoteMICErrors;
- LARGE_INTEGER TKIPICVErrors;
- LARGE_INTEGER TKIPCounterMeasuresInvoked;
- LARGE_INTEGER TKIPReplays;
- LARGE_INTEGER CCMPFormatErrors;
- LARGE_INTEGER CCMPReplays;
- LARGE_INTEGER CCMPDecryptErrors;
- LARGE_INTEGER FourWayHandshakeFailures;
-} NDIS_802_11_STATISTICS, *PNDIS_802_11_STATISTICS;
-
-typedef ULONG NDIS_802_11_KEY_INDEX;
-typedef ULONGLONG NDIS_802_11_KEY_RSC;
-
-#define MAX_RADIUS_SRV_NUM 2 // 802.1x failover number
-
-typedef struct PACKED _RADIUS_SRV_INFO {
- UINT32 radius_ip;
- UINT32 radius_port;
- UCHAR radius_key[64];
- UCHAR radius_key_len;
-} RADIUS_SRV_INFO, *PRADIUS_SRV_INFO;
-
-typedef struct PACKED _RADIUS_KEY_INFO
-{
- UCHAR radius_srv_num;
- RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
- UCHAR ieee8021xWEP; // dynamic WEP
- UCHAR key_index;
- UCHAR key_length; // length of key in bytes
- UCHAR key_material[13];
-} RADIUS_KEY_INFO, *PRADIUS_KEY_INFO;
-
-// It's used by 802.1x daemon to require relative configuration
-typedef struct PACKED _RADIUS_CONF
-{
- UINT32 Length; // Length of this structure
- UCHAR mbss_num; // indicate multiple BSS number
- UINT32 own_ip_addr;
- UINT32 retry_interval;
- UINT32 session_timeout_interval;
- UCHAR EAPifname[IFNAMSIZ];
- UCHAR EAPifname_len;
- UCHAR PreAuthifname[IFNAMSIZ];
- UCHAR PreAuthifname_len;
- RADIUS_KEY_INFO RadiusInfo[8/*MAX_MBSSID_NUM*/];
-} RADIUS_CONF, *PRADIUS_CONF;
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-// Key mapping keys require a BSSID
-typedef struct _NDIS_802_11_KEY
-{
- UINT Length; // Length of this structure
- UINT KeyIndex;
- UINT KeyLength; // length of key in bytes
- NDIS_802_11_MAC_ADDRESS BSSID;
- NDIS_802_11_KEY_RSC KeyRSC;
- UCHAR KeyMaterial[1]; // variable length depending on above field
-} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
-#endif // CONFIG_STA_SUPPORT //
-
-typedef struct _NDIS_802_11_REMOVE_KEY
-{
- UINT Length; // Length of this structure
- UINT KeyIndex;
- NDIS_802_11_MAC_ADDRESS BSSID;
-} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
-
-typedef struct _NDIS_802_11_WEP
-{
- UINT Length; // Length of this structure
- UINT KeyIndex; // 0 is the per-client key, 1-N are the
- // global keys
- UINT KeyLength; // length of key in bytes
- UCHAR KeyMaterial[1];// variable length depending on above field
-} NDIS_802_11_WEP, *PNDIS_802_11_WEP;
-
-
-typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
-{
- Ndis802_11IBSS,
- Ndis802_11Infrastructure,
- Ndis802_11AutoUnknown,
- Ndis802_11Monitor,
- Ndis802_11InfrastructureMax // Not a real value, defined as upper bound
-} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
-
-// Add new authentication modes
-typedef enum _NDIS_802_11_AUTHENTICATION_MODE
-{
- Ndis802_11AuthModeOpen,
- Ndis802_11AuthModeShared,
- Ndis802_11AuthModeAutoSwitch,
- Ndis802_11AuthModeWPA,
- Ndis802_11AuthModeWPAPSK,
- Ndis802_11AuthModeWPANone,
- Ndis802_11AuthModeWPA2,
- Ndis802_11AuthModeWPA2PSK,
- Ndis802_11AuthModeWPA1WPA2,
- Ndis802_11AuthModeWPA1PSKWPA2PSK,
- Ndis802_11AuthModeMax // Not a real mode, defined as upper bound
-} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
-
-typedef UCHAR NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; // Set of 8 data rates
-typedef UCHAR NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; // Set of 16 data rates
-
-typedef struct PACKED _NDIS_802_11_SSID
-{
- UINT SsidLength; // length of SSID field below, in bytes;
- // this can be zero.
- UCHAR Ssid[NDIS_802_11_LENGTH_SSID]; // SSID information field
-} NDIS_802_11_SSID, *PNDIS_802_11_SSID;
-
-
-typedef struct PACKED _NDIS_WLAN_BSSID
-{
- ULONG Length; // Length of this structure
- NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
- UCHAR Reserved[2];
- NDIS_802_11_SSID Ssid; // SSID
- ULONG Privacy; // WEP encryption requirement
- NDIS_802_11_RSSI Rssi; // receive signal strength in dBm
- NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
- NDIS_802_11_CONFIGURATION Configuration;
- NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
- NDIS_802_11_RATES SupportedRates;
-} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;
-
-typedef struct PACKED _NDIS_802_11_BSSID_LIST
-{
- UINT NumberOfItems; // in list below, at least 1
- NDIS_WLAN_BSSID Bssid[1];
-} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
-
-// Added Capabilities, IELength and IEs for each BSSID
-typedef struct PACKED _NDIS_WLAN_BSSID_EX
-{
- ULONG Length; // Length of this structure
- NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
- UCHAR Reserved[2];
- NDIS_802_11_SSID Ssid; // SSID
- UINT Privacy; // WEP encryption requirement
- NDIS_802_11_RSSI Rssi; // receive signal
- // strength in dBm
- NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
- NDIS_802_11_CONFIGURATION Configuration;
- NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
- NDIS_802_11_RATES_EX SupportedRates;
- ULONG IELength;
- UCHAR IEs[1];
-} NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
-
-typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
-{
- UINT NumberOfItems; // in list below, at least 1
- NDIS_WLAN_BSSID_EX Bssid[1];
-} NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
-
-typedef struct PACKED _NDIS_802_11_FIXED_IEs
-{
- UCHAR Timestamp[8];
- USHORT BeaconInterval;
- USHORT Capabilities;
-} NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
-
-typedef struct _NDIS_802_11_VARIABLE_IEs
-{
- UCHAR ElementID;
- UCHAR Length; // Number of bytes in data field
- UCHAR data[1];
-} NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
-
-typedef ULONG NDIS_802_11_FRAGMENTATION_THRESHOLD;
-
-typedef ULONG NDIS_802_11_RTS_THRESHOLD;
-
-typedef ULONG NDIS_802_11_ANTENNA;
-
-typedef enum _NDIS_802_11_PRIVACY_FILTER
-{
- Ndis802_11PrivFilterAcceptAll,
- Ndis802_11PrivFilter8021xWEP
-} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
-
-// Added new encryption types
-// Also aliased typedef to new name
-typedef enum _NDIS_802_11_WEP_STATUS
-{
- Ndis802_11WEPEnabled,
- Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
- Ndis802_11WEPDisabled,
- Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
- Ndis802_11WEPKeyAbsent,
- Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
- Ndis802_11WEPNotSupported,
- Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
- Ndis802_11Encryption2Enabled,
- Ndis802_11Encryption2KeyAbsent,
- Ndis802_11Encryption3Enabled,
- Ndis802_11Encryption3KeyAbsent,
- Ndis802_11Encryption4Enabled, // TKIP or AES mix
- Ndis802_11Encryption4KeyAbsent,
- Ndis802_11GroupWEP40Enabled,
- Ndis802_11GroupWEP104Enabled,
-} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
- NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
-
-typedef enum _NDIS_802_11_RELOAD_DEFAULTS
-{
- Ndis802_11ReloadWEPKeys
-} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
-
-#define NDIS_802_11_AI_REQFI_CAPABILITIES 1
-#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
-#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
-
-#define NDIS_802_11_AI_RESFI_CAPABILITIES 1
-#define NDIS_802_11_AI_RESFI_STATUSCODE 2
-#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
-
-typedef struct _NDIS_802_11_AI_REQFI
-{
- USHORT Capabilities;
- USHORT ListenInterval;
- NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
-} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
-
-typedef struct _NDIS_802_11_AI_RESFI
-{
- USHORT Capabilities;
- USHORT StatusCode;
- USHORT AssociationId;
-} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
-
-typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
-{
- ULONG Length;
- USHORT AvailableRequestFixedIEs;
- NDIS_802_11_AI_REQFI RequestFixedIEs;
- ULONG RequestIELength;
- ULONG OffsetRequestIEs;
- USHORT AvailableResponseFixedIEs;
- NDIS_802_11_AI_RESFI ResponseFixedIEs;
- ULONG ResponseIELength;
- ULONG OffsetResponseIEs;
-} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
-
-typedef struct _NDIS_802_11_AUTHENTICATION_EVENT
-{
- NDIS_802_11_STATUS_INDICATION Status;
- NDIS_802_11_AUTHENTICATION_REQUEST Request[1];
-} NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
-
-/*
-typedef struct _NDIS_802_11_TEST
-{
- ULONG Length;
- ULONG Type;
- union
- {
- NDIS_802_11_AUTHENTICATION_EVENT AuthenticationEvent;
- NDIS_802_11_RSSI RssiTrigger;
- };
-} NDIS_802_11_TEST, *PNDIS_802_11_TEST;
- */
-
-// 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE
-typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
-{
- Ndis802_11MediaStreamOff,
- Ndis802_11MediaStreamOn,
-} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
-
-// PMKID Structures
-typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
-
-#ifdef CONFIG_STA_SUPPORT
-typedef struct _BSSID_INFO
-{
- NDIS_802_11_MAC_ADDRESS BSSID;
- NDIS_802_11_PMKID_VALUE PMKID;
-} BSSID_INFO, *PBSSID_INFO;
-
-typedef struct _NDIS_802_11_PMKID
-{
- UINT Length;
- UINT BSSIDInfoCount;
- BSSID_INFO BSSIDInfo[1];
-} NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
-#endif // CONFIG_STA_SUPPORT //
-
-
-typedef struct _NDIS_802_11_AUTHENTICATION_ENCRYPTION
-{
- NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
- NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
-} NDIS_802_11_AUTHENTICATION_ENCRYPTION, *PNDIS_802_11_AUTHENTICATION_ENCRYPTION;
-
-typedef struct _NDIS_802_11_CAPABILITY
-{
- ULONG Length;
- ULONG Version;
- ULONG NoOfPMKIDs;
- ULONG NoOfAuthEncryptPairsSupported;
- NDIS_802_11_AUTHENTICATION_ENCRYPTION AuthenticationEncryptionSupported[1];
-} NDIS_802_11_CAPABILITY, *PNDIS_802_11_CAPABILITY;
-
-//#endif //of WIN 2k
-#endif //UNDER_CE
-
-#if WIRELESS_EXT <= 11
-#ifndef SIOCDEVPRIVATE
-#define SIOCDEVPRIVATE 0x8BE0
-#endif
-#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
-#endif
-
-#ifdef CONFIG_STA_SUPPORT
-#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
-
-#ifdef DBG
-#define RTPRIV_IOCTL_BBP (SIOCIWFIRSTPRIV + 0x03)
-#define RTPRIV_IOCTL_MAC (SIOCIWFIRSTPRIV + 0x05)
-#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
-#endif
-
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-#define RTPRIV_IOCTL_ATE (SIOCIWFIRSTPRIV + 0x08)
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
-#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
-#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
-#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
-#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E) // Sync. with RT61 (for wpa_supplicant)
-#define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
-
-#define RTPRIV_IOCTL_SHOW (SIOCIWFIRSTPRIV + 0x11)
-enum {
- SHOW_CONN_STATUS = 4,
- SHOW_DRVIER_VERION = 5,
- SHOW_BA_INFO = 6,
- SHOW_DESC_INFO = 7,
-#ifdef RT2870
- SHOW_RXBULK_INFO = 8,
- SHOW_TXBULK_INFO = 9,
-#endif // RT2870 //
- RAIO_OFF = 10,
- RAIO_ON = 11,
-#ifdef QOS_DLS_SUPPORT
- SHOW_DLS_ENTRY_INFO = 19,
-#endif // QOS_DLS_SUPPORT //
- SHOW_CFG_VALUE = 20,
- SHOW_ADHOC_ENTRY_INFO = 21,
-};
-
-
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef SNMP_SUPPORT
-//SNMP ieee 802dot11, kathy , 2008_0220
-// dot11res(3)
-#define RT_OID_802_11_MANUFACTUREROUI 0x0700
-#define RT_OID_802_11_MANUFACTURERNAME 0x0701
-#define RT_OID_802_11_RESOURCETYPEIDNAME 0x0702
-
-// dot11smt(1)
-#define RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED 0x0703
-#define RT_OID_802_11_POWERMANAGEMENTMODE 0x0704
-#define OID_802_11_WEPDEFAULTKEYVALUE 0x0705 // read , write
-#define OID_802_11_WEPDEFAULTKEYID 0x0706
-#define RT_OID_802_11_WEPKEYMAPPINGLENGTH 0x0707
-#define OID_802_11_SHORTRETRYLIMIT 0x0708
-#define OID_802_11_LONGRETRYLIMIT 0x0709
-#define RT_OID_802_11_PRODUCTID 0x0710
-#define RT_OID_802_11_MANUFACTUREID 0x0711
-
-// //dot11Phy(4)
-#define OID_802_11_CURRENTCHANNEL 0x0712
-
-//dot11mac
-#define RT_OID_802_11_MAC_ADDRESS 0x0713
-#endif // SNMP_SUPPORT //
-
-#define OID_802_11_BUILD_CHANNEL_EX 0x0714
-#define OID_802_11_GET_CH_LIST 0x0715
-#define OID_802_11_GET_COUNTRY_CODE 0x0716
-#define OID_802_11_GET_CHANNEL_GEOGRAPHY 0x0717
-
-#ifdef LLTD_SUPPORT
-// for consistency with RT61
-#define RT_OID_GET_PHY_MODE 0x761
-#endif // LLTD_SUPPORT //
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
-typedef union _HTTRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT MODE:2; // Use definition MODE_xxx.
-// USHORT rsv:3;
- USHORT TxBF:1;
- USHORT rsv:2;
- USHORT STBC:2; //SPACE
- USHORT ShortGI:1;
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT MCS:7; // MCS
- } field;
-#else
- struct {
- USHORT MCS:7; // MCS
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT ShortGI:1;
- USHORT STBC:2; //SPACE
-// USHORT rsv:3;
- USHORT rsv:2;
- USHORT TxBF:1;
- USHORT MODE:2; // Use definition MODE_xxx.
- } field;
-#endif
- USHORT word;
- } HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
-
-typedef enum _RT_802_11_PREAMBLE {
- Rt802_11PreambleLong,
- Rt802_11PreambleShort,
- Rt802_11PreambleAuto
-} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
-
-// Only for STA, need to sync with AP
-typedef enum _RT_802_11_PHY_MODE {
- PHY_11BG_MIXED = 0,
- PHY_11B,
- PHY_11A,
- PHY_11ABG_MIXED,
- PHY_11G,
-#ifdef DOT11_N_SUPPORT
- PHY_11ABGN_MIXED, // both band 5
- PHY_11N_2_4G, // 11n-only with 2.4G band 6
- PHY_11GN_MIXED, // 2.4G band 7
- PHY_11AN_MIXED, // 5G band 8
- PHY_11BGN_MIXED, // if check 802.11b. 9
- PHY_11AGN_MIXED, // if check 802.11b. 10
- PHY_11N_5G, // 11n-only with 5G band 11
-#endif // DOT11_N_SUPPORT //
-} RT_802_11_PHY_MODE;
-
-// put all proprietery for-query objects here to reduce # of Query_OID
-typedef struct _RT_802_11_LINK_STATUS {
- ULONG CurrTxRate; // in units of 0.5Mbps
- ULONG ChannelQuality; // 0..100 %
- ULONG TxByteCount; // both ok and fail
- ULONG RxByteCount; // both ok and fail
- ULONG CentralChannel; // 40MHz central channel number
-} RT_802_11_LINK_STATUS, *PRT_802_11_LINK_STATUS;
-
-typedef struct _RT_802_11_EVENT_LOG {
- LARGE_INTEGER SystemTime; // timestammp via NdisGetCurrentSystemTime()
- UCHAR Addr[MAC_ADDR_LENGTH];
- USHORT Event; // EVENT_xxx
-} RT_802_11_EVENT_LOG, *PRT_802_11_EVENT_LOG;
-
-typedef struct _RT_802_11_EVENT_TABLE {
- ULONG Num;
- ULONG Rsv; // to align Log[] at LARGE_INEGER boundary
- RT_802_11_EVENT_LOG Log[MAX_NUMBER_OF_EVENT];
-} RT_802_11_EVENT_TABLE, PRT_802_11_EVENT_TABLE;
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
-typedef union _MACHTTRANSMIT_SETTING {
- struct {
- USHORT MCS:7; // MCS
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT ShortGI:1;
- USHORT STBC:2; //SPACE
- USHORT rsv:3;
- USHORT MODE:2; // Use definition MODE_xxx.
- } field;
- USHORT word;
- } MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
-
-typedef struct _RT_802_11_MAC_ENTRY {
- UCHAR Addr[MAC_ADDR_LENGTH];
- UCHAR Aid;
- UCHAR Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
- UCHAR MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
- CHAR AvgRssi0;
- CHAR AvgRssi1;
- CHAR AvgRssi2;
- UINT32 ConnectedTime;
- MACHTTRANSMIT_SETTING TxRate;
-} RT_802_11_MAC_ENTRY, *PRT_802_11_MAC_ENTRY;
-
-typedef struct _RT_802_11_MAC_TABLE {
- ULONG Num;
- RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
-} RT_802_11_MAC_TABLE, *PRT_802_11_MAC_TABLE;
-
-// structure for query/set hardware register - MAC, BBP, RF register
-typedef struct _RT_802_11_HARDWARE_REGISTER {
- ULONG HardwareType; // 0:MAC, 1:BBP, 2:RF register, 3:EEPROM
- ULONG Offset; // Q/S register offset addr
- ULONG Data; // R/W data buffer
-} RT_802_11_HARDWARE_REGISTER, *PRT_802_11_HARDWARE_REGISTER;
-
-// structure to tune BBP R17 "RX AGC VGC init"
-//typedef struct _RT_802_11_RX_AGC_VGC_TUNING {
-// UCHAR FalseCcaLowerThreshold; // 0-255, def 10
-// UCHAR FalseCcaUpperThreshold; // 0-255, def 100
-// UCHAR VgcDelta; // R17 +-= VgcDelta whenever flase CCA over UpprThreshold
-// // or lower than LowerThresholdupper threshold
-// UCHAR VgcUpperBound; // max value of R17
-//} RT_802_11_RX_AGC_VGC_TUNING, *PRT_802_11_RX_AGC_VGC_TUNING;
-
-typedef struct _RT_802_11_AP_CONFIG {
- ULONG EnableTxBurst; // 0-disable, 1-enable
- ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
- ULONG IsolateInterStaTraffic; // 0-disable, 1-enable isolation
- ULONG HideSsid; // 0-disable, 1-enable hiding
- ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
- ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time
- ULONG Rsv1; // must be 0
- ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
-} RT_802_11_AP_CONFIG, *PRT_802_11_AP_CONFIG;
-
-// structure to query/set STA_CONFIG
-typedef struct _RT_802_11_STA_CONFIG {
- ULONG EnableTxBurst; // 0-disable, 1-enable
- ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
- ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
- ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time when applicable
- ULONG AdhocMode; // 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only
- ULONG HwRadioStatus; // 0-OFF, 1-ON, default is 1, Read-Only
- ULONG Rsv1; // must be 0
- ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
-} RT_802_11_STA_CONFIG, *PRT_802_11_STA_CONFIG;
-
-//
-// For OID Query or Set about BA structure
-//
-typedef struct _OID_BACAP_STRUC {
- UCHAR RxBAWinLimit;
- UCHAR TxBAWinLimit;
- UCHAR Policy; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
- UCHAR MpduDensity; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
- UCHAR AmsduEnable; //Enable AMSDU transmisstion
- UCHAR AmsduSize; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UCHAR MMPSmode; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- BOOLEAN AutoBA; // Auto BA will automatically
-} OID_BACAP_STRUC, *POID_BACAP_STRUC;
-
-typedef struct _RT_802_11_ACL_ENTRY {
- UCHAR Addr[MAC_ADDR_LENGTH];
- USHORT Rsv;
-} RT_802_11_ACL_ENTRY, *PRT_802_11_ACL_ENTRY;
-
-typedef struct PACKED _RT_802_11_ACL {
- ULONG Policy; // 0-disable, 1-positive list, 2-negative list
- ULONG Num;
- RT_802_11_ACL_ENTRY Entry[MAX_NUMBER_OF_ACL];
-} RT_802_11_ACL, *PRT_802_11_ACL;
-
-typedef struct _RT_802_11_WDS {
- ULONG Num;
- NDIS_802_11_MAC_ADDRESS Entry[24/*MAX_NUM_OF_WDS_LINK*/];
- ULONG KeyLength;
- UCHAR KeyMaterial[32];
-} RT_802_11_WDS, *PRT_802_11_WDS;
-
-typedef struct _RT_802_11_TX_RATES_ {
- UCHAR SupRateLen;
- UCHAR SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
- UCHAR ExtRateLen;
- UCHAR ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
-} RT_802_11_TX_RATES, *PRT_802_11_TX_RATES;
-
-
-// Definition of extra information code
-#define GENERAL_LINK_UP 0x0 // Link is Up
-#define GENERAL_LINK_DOWN 0x1 // Link is Down
-#define HW_RADIO_OFF 0x2 // Hardware radio off
-#define SW_RADIO_OFF 0x3 // Software radio off
-#define AUTH_FAIL 0x4 // Open authentication fail
-#define AUTH_FAIL_KEYS 0x5 // Shared authentication fail
-#define ASSOC_FAIL 0x6 // Association failed
-#define EAP_MIC_FAILURE 0x7 // Deauthencation because MIC failure
-#define EAP_4WAY_TIMEOUT 0x8 // Deauthencation on 4-way handshake timeout
-#define EAP_GROUP_KEY_TIMEOUT 0x9 // Deauthencation on group key handshake timeout
-#define EAP_SUCCESS 0xa // EAP succeed
-#define DETECT_RADAR_SIGNAL 0xb // Radar signal occur in current channel
-#define EXTRA_INFO_MAX 0xb // Indicate Last OID
-
-#define EXTRA_INFO_CLEAR 0xffffffff
-
-// This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use.
-typedef struct {
- RT_802_11_PHY_MODE PhyMode; //
- UCHAR TransmitNo;
- UCHAR HtMode; //HTMODE_GF or HTMODE_MM
- UCHAR ExtOffset; //extension channel above or below
- UCHAR MCS;
- UCHAR BW;
- UCHAR STBC;
- UCHAR SHORTGI;
- UCHAR rsv;
-} OID_SET_HT_PHYMODE, *POID_SET_HT_PHYMODE;
-
-#ifdef NINTENDO_AP
-#define NINTENDO_MAX_ENTRY 16
-#define NINTENDO_SSID_NAME_LN 8
-#define NINTENDO_SSID_NAME "NWCUSBAP"
-#define NINTENDO_PROBE_REQ_FLAG_MASK 0x03
-#define NINTENDO_PROBE_REQ_ON 0x01
-#define NINTENDO_PROBE_REQ_SIGNAL 0x02
-#define NINTENDO_PROBE_RSP_ON 0x01
-#define NINTENDO_SSID_NICKNAME_LN 20
-
-#define NINTENDO_WEPKEY_LN 13
-
-typedef struct _NINTENDO_SSID
-{
- UCHAR NINTENDOFixChar[NINTENDO_SSID_NAME_LN];
- UCHAR zero1;
- UCHAR registe;
- UCHAR ID;
- UCHAR zero2;
- UCHAR NICKname[NINTENDO_SSID_NICKNAME_LN];
-} RT_NINTENDO_SSID, *PRT_NINTENDO_SSID;
-
-typedef struct _NINTENDO_ENTRY
-{
- UCHAR NICKname[NINTENDO_SSID_NICKNAME_LN];
- UCHAR DS_Addr[ETH_LENGTH_OF_ADDRESS];
- UCHAR registe;
- UCHAR UserSpaceAck;
-} RT_NINTENDO_ENTRY, *PRT_NINTENDO_ENTRY;
-
-//RTPRIV_IOCTL_NINTENDO_GET_TABLE
-//RTPRIV_IOCTL_NINTENDO_SET_TABLE
-typedef struct _NINTENDO_TABLE
-{
- UINT number;
- RT_NINTENDO_ENTRY entry[NINTENDO_MAX_ENTRY];
-} RT_NINTENDO_TABLE, *PRT_NINTENDO_TABLE;
-
-//RTPRIV_IOCTL_NINTENDO_SEED_WEPKEY
-typedef struct _NINTENDO_SEED_WEPKEY
-{
- UCHAR seed[NINTENDO_SSID_NICKNAME_LN];
- UCHAR wepkey[16];//use 13 for 104 bits wep key
-} RT_NINTENDO_SEED_WEPKEY, *PRT_NINTENDO_SEED_WEPKEY;
-#endif // NINTENDO_AP //
-
-#ifdef LLTD_SUPPORT
-typedef struct _RT_LLTD_ASSOICATION_ENTRY {
- UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
- unsigned short MOR; // maximum operational rate
- UCHAR phyMode;
-} RT_LLTD_ASSOICATION_ENTRY, *PRT_LLTD_ASSOICATION_ENTRY;
-
-typedef struct _RT_LLTD_ASSOICATION_TABLE {
- unsigned int Num;
- RT_LLTD_ASSOICATION_ENTRY Entry[MAX_NUMBER_OF_MAC];
-} RT_LLTD_ASSOICATION_TABLE, *PRT_LLTD_ASSOICATION_TABLE;
-#endif // LLTD_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-//rt2860, kathy 2007-0118
-// structure for DLS
-typedef struct _RT_802_11_DLS_UI {
- USHORT TimeOut; // unit: second , set by UI
- USHORT CountDownTimer; // unit: second , used by driver only
- NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
- UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
- BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
-} RT_802_11_DLS_UI, *PRT_802_11_DLS_UI;
-
-typedef struct _RT_802_11_DLS_INFO {
- RT_802_11_DLS_UI Entry[MAX_NUMBER_OF_DLS_ENTRY];
- UCHAR num;
-} RT_802_11_DLS_INFO, *PRT_802_11_DLS_INFO;
-
-typedef enum _RT_802_11_DLS_MODE {
- DLS_NONE,
- DLS_WAIT_KEY,
- DLS_FINISH
-} RT_802_11_DLS_MODE;
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-#define RT_ASSOC_EVENT_FLAG 0x0101
-#define RT_DISASSOC_EVENT_FLAG 0x0102
-#define RT_REQIE_EVENT_FLAG 0x0103
-#define RT_RESPIE_EVENT_FLAG 0x0104
-#define RT_ASSOCINFO_EVENT_FLAG 0x0105
-#define RT_PMKIDCAND_FLAG 0x0106
-#define RT_INTERFACE_DOWN 0x0107
-#define RT_INTERFACE_UP 0x0108
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-
-#define MAX_CUSTOM_LEN 128
-
-#ifdef CONFIG_STA_SUPPORT
-typedef enum _RT_802_11_D_CLIENT_MODE
-{
- Rt802_11_D_None,
- Rt802_11_D_Flexible,
- Rt802_11_D_Strict,
-} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
-#endif // CONFIG_STA_SUPPORT //
-
-typedef struct _RT_CHANNEL_LIST_INFO
-{
- UCHAR ChannelList[MAX_NUM_OF_CHS]; // list all supported channels for site survey
- UCHAR ChannelListNum; // number of channel in ChannelList[]
-} RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO;
-
-// WSC configured credential
-typedef struct _WSC_CREDENTIAL
-{
- NDIS_802_11_SSID SSID; // mandatory
- USHORT AuthType; // mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk
- USHORT EncrType; // mandatory, 1: none, 2: wep, 4: tkip, 8: aes
- UCHAR Key[64]; // mandatory, Maximum 64 byte
- USHORT KeyLength;
- UCHAR MacAddr[6]; // mandatory, AP MAC address
- UCHAR KeyIndex; // optional, default is 1
- UCHAR Rsvd[3]; // Make alignment
-} WSC_CREDENTIAL, *PWSC_CREDENTIAL;
-
-// WSC configured profiles
-typedef struct _WSC_PROFILE
-{
- UINT ProfileCnt;
- WSC_CREDENTIAL Profile[8]; // Support up to 8 profiles
-} WSC_PROFILE, *PWSC_PROFILE;
-
-
-#endif // _OID_H_
-
+#include "../rt2860/oid.h"
diff --git a/drivers/staging/rt2870/rt2870.h b/drivers/staging/rt2870/rt2870.h
index a69cf338e498..5e5b3f2b7eb1 100644
--- a/drivers/staging/rt2870/rt2870.h
+++ b/drivers/staging/rt2870/rt2870.h
@@ -33,7 +33,6 @@
/* rtmp_def.h */
//
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#define BULKAGGRE_ZISE 100
#define RT28XX_DRVDATA_SET(_a) usb_set_intfdata(_a, pAd);
#define RT28XX_PUT_DEVICE usb_put_dev
@@ -41,22 +40,15 @@
#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, GFP_ATOMIC)
#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_buffer_alloc(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_buffer_free(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)
-#else
-#define BULKAGGRE_ZISE 60
-#define RT28XX_DRVDATA_SET(_a)
-#define RT28XX_PUT_DEVICE(dev_p)
-#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso)
-#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb)
-#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) kmalloc(BufSize, GFP_ATOMIC)
-#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) kfree(pTransferBuf)
-#endif
#define RXBULKAGGRE_ZISE 12
#define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
#define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
#define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
#define MAX_MLME_HANDLER_MEMORY 20
+#ifndef RT30xx
#define RETRY_LIMIT 10
+#endif
#define BUFFER_SIZE 2400 //2048
#define TX_RING 0xa
#define PRIO_RING 0xc
@@ -72,6 +64,9 @@
#define fRTUSB_BULK_OUT_DATA_NORMAL_2 0x00020000
#define fRTUSB_BULK_OUT_DATA_NORMAL_3 0x00040000
#define fRTUSB_BULK_OUT_DATA_NORMAL_4 0x00080000
+#ifdef RT30xx
+#define fRTUSB_BULK_OUT_DATA_NORMAL_5 0x00100000
+#endif
#define fRTUSB_BULK_OUT_PSPOLL 0x00000020
#define fRTUSB_BULK_OUT_DATA_FRAG 0x00000040
@@ -79,10 +74,7 @@
#define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000100
#define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000200
-#ifdef RALINK_ATE
-#define fRTUSB_BULK_OUT_DATA_ATE 0x00100000
-#endif // RALINK_ATE //
-
+#ifndef RT30xx
#define RT2870_USB_DEVICES \
{ \
{USB_DEVICE(0x148F,0x2770)}, /* Ralink */ \
@@ -148,6 +140,84 @@
{USB_DEVICE(0x7392,0x7717)}, /* Edimax */ \
{ }/* Terminating entry */ \
}
+#endif
+#ifdef RT30xx
+#define RT2870_USB_DEVICES \
+{ \
+ {USB_DEVICE(0x148F,0x2770)}, /* Ralink */ \
+ {USB_DEVICE(0x148F,0x2870)}, /* Ralink */ \
+ {USB_DEVICE(0x148F,0x3070)}, /* Ralink 3070 */ \
+ {USB_DEVICE(0x148F,0x3071)}, /* Ralink 3071 */ \
+ {USB_DEVICE(0x148F,0x3072)}, /* Ralink 3072 */ \
+ {USB_DEVICE(0x0B05,0x1731)}, /* Asus */ \
+ {USB_DEVICE(0x0B05,0x1732)}, /* Asus */ \
+ {USB_DEVICE(0x0B05,0x1742)}, /* Asus */ \
+ {USB_DEVICE(0x0DF6,0x0017)}, /* Sitecom */ \
+ {USB_DEVICE(0x0DF6,0x002B)}, /* Sitecom */ \
+ {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */ \
+ {USB_DEVICE(0x0DF6,0x003E)}, /* Sitecom 3070 */ \
+ {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */ \
+ {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom 2770 */ \
+ {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \
+ {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \
+ {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \
+ {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */ \
+ {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */ \
+ {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */ \
+ {USB_DEVICE(0x2001,0x3C09)}, /* D-Link */ \
+ {USB_DEVICE(0x2001,0x3C0A)}, /* D-Link 3072*/ \
+ {USB_DEVICE(0x14B2,0x3C07)}, /* AL */ \
+ {USB_DEVICE(0x14B2,0x3C12)}, /* AL 3070 */ \
+ {USB_DEVICE(0x050D,0x8053)}, /* Belkin */ \
+ {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */ \
+ {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */ \
+ {USB_DEVICE(0x07AA,0x002F)}, /* Corega */ \
+ {USB_DEVICE(0x07AA,0x003C)}, /* Corega */ \
+ {USB_DEVICE(0x07AA,0x003F)}, /* Corega */ \
+ {USB_DEVICE(0x18C5,0x0012)}, /* Corega 3070 */ \
+ {USB_DEVICE(0x1044,0x800B)}, /* Gigabyte */ \
+ {USB_DEVICE(0x1044,0x800D)}, /* Gigabyte GN-WB32L 3070 */ \
+ {USB_DEVICE(0x15A9,0x0006)}, /* Sparklan */ \
+ {USB_DEVICE(0x083A,0xB522)}, /* SMC */ \
+ {USB_DEVICE(0x083A,0xA618)}, /* SMC */ \
+ {USB_DEVICE(0x083A,0x8522)}, /* Arcadyan */ \
+ {USB_DEVICE(0x083A,0x7512)}, /* Arcadyan 2770 */ \
+ {USB_DEVICE(0x083A,0x7522)}, /* Arcadyan */ \
+ {USB_DEVICE(0x083A,0x7511)}, /* Arcadyan 3070 */ \
+ {USB_DEVICE(0x0CDE,0x0022)}, /* ZCOM */ \
+ {USB_DEVICE(0x0586,0x3416)}, /* Zyxel */ \
+ {USB_DEVICE(0x0CDE,0x0025)}, /* Zyxel */ \
+ {USB_DEVICE(0x1740,0x9701)}, /* EnGenius */ \
+ {USB_DEVICE(0x1740,0x9702)}, /* EnGenius */ \
+ {USB_DEVICE(0x1740,0x9703)}, /* EnGenius 3070 */ \
+ {USB_DEVICE(0x0471,0x200f)}, /* Philips */ \
+ {USB_DEVICE(0x14B2,0x3C25)}, /* Draytek */ \
+ {USB_DEVICE(0x13D3,0x3247)}, /* AzureWave */ \
+ {USB_DEVICE(0x13D3,0x3273)}, /* AzureWave 3070*/ \
+ {USB_DEVICE(0x083A,0x6618)}, /* Accton */ \
+ {USB_DEVICE(0x15c5,0x0008)}, /* Amit */ \
+ {USB_DEVICE(0x0E66,0x0001)}, /* Hawking */ \
+ {USB_DEVICE(0x0E66,0x0003)}, /* Hawking */ \
+ {USB_DEVICE(0x129B,0x1828)}, /* Siemens */ \
+ {USB_DEVICE(0x157E,0x300E)}, /* U-Media */ \
+ {USB_DEVICE(0x050d,0x805c)}, \
+ {USB_DEVICE(0x1482,0x3C09)}, /* Abocom*/ \
+ {USB_DEVICE(0x14B2,0x3C09)}, /* Alpha */ \
+ {USB_DEVICE(0x04E8,0x2018)}, /* samsung */ \
+ {USB_DEVICE(0x07B8,0x3070)}, /* AboCom 3070 */ \
+ {USB_DEVICE(0x07B8,0x3071)}, /* AboCom 3071 */ \
+ {USB_DEVICE(0x07B8,0x3072)}, /* Abocom 3072 */ \
+ {USB_DEVICE(0x7392,0x7711)}, /* Edimax 3070 */ \
+ {USB_DEVICE(0x5A57,0x0280)}, /* Zinwell */ \
+ {USB_DEVICE(0x5A57,0x0282)}, /* Zinwell */ \
+ {USB_DEVICE(0x1A32,0x0304)}, /* Quanta 3070 */ \
+ {USB_DEVICE(0x0789,0x0162)}, /* Logitec 2870 */ \
+ {USB_DEVICE(0x0789,0x0163)}, /* Logitec 2870 */ \
+ {USB_DEVICE(0x0789,0x0164)}, /* Logitec 2870 */ \
+ {USB_DEVICE(0x1EDA,0x2310)}, /* AirTies 3070 */ \
+ { }/* Terminating entry */ \
+}
+#endif
#define FREE_HTTX_RING(_p, _b, _t) \
{ \
@@ -161,30 +231,6 @@
//
// RXINFO appends at the end of each rx packet.
//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _RXINFO_STRUC {
- UINT32 PlcpSignal:12;
- UINT32 LastAMSDU:1;
- UINT32 CipherAlg:1;
- UINT32 PlcpRssil:1;
- UINT32 Decrypted:1;
- UINT32 AMPDU:1; // To be moved
- UINT32 L2PAD:1;
- UINT32 RSSI:1;
- UINT32 HTC:1;
- UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header.
- UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
- UINT32 Crc:1; // 1: CRC error
- UINT32 MyBss:1; // 1: this frame belongs to the same BSSID
- UINT32 Bcast:1; // 1: this is a broadcast frame
- UINT32 Mcast:1; // 1: this is a multicast frame
- UINT32 U2M:1; // 1: this RX frame is unicast to me
- UINT32 FRAG:1;
- UINT32 NULLDATA:1;
- UINT32 DATA:1;
- UINT32 BA:1;
-} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#else
typedef struct PACKED _RXINFO_STRUC {
UINT32 BA:1;
UINT32 DATA:1;
@@ -207,25 +253,10 @@ typedef struct PACKED _RXINFO_STRUC {
UINT32 LastAMSDU:1;
UINT32 PlcpSignal:12;
} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#endif
-
//
// TXINFO
//
-#ifdef RT_BIG_ENDIAN
-typedef struct _TXINFO_STRUC {
- // Word 0
- UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
- UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid
- UINT32 rsv2:2; // Software use.
- UINT32 SwUseLastRound:1; // Software use.
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 rsv:8;
- UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame.
-} TXINFO_STRUC, *PTXINFO_STRUC;
-#else
typedef struct _TXINFO_STRUC {
// Word 0
UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame.
@@ -237,7 +268,6 @@ typedef struct _TXINFO_STRUC {
UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid
UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
} TXINFO_STRUC, *PTXINFO_STRUC;
-#endif
#define TXINFO_SIZE 4
#define RXINFO_SIZE 4
@@ -254,6 +284,23 @@ typedef struct _MGMT_STRUC {
/* ----------------- EEPROM Related MACRO ----------------- */
+#ifdef RT30xx
+#define RT28xx_EEPROM_READ16(pAd, offset, var) \
+ do { \
+ RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2); \
+ if(!pAd->bUseEfuse) \
+ var = le2cpu16(var); \
+ }while(0)
+
+#define RT28xx_EEPROM_WRITE16(pAd, offset, var) \
+ do{ \
+ USHORT _tmpVar=var; \
+ if(!pAd->bUseEfuse) \
+ _tmpVar = cpu2le16(var); \
+ RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2); \
+ }while(0)
+#endif // RT30xx //
+#ifndef RT30xx
#define RT28xx_EEPROM_READ16(pAd, offset, var) \
do { \
RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2); \
@@ -266,6 +313,7 @@ typedef struct _MGMT_STRUC {
_tmpVar = cpu2le16(var); \
RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2); \
}while(0)
+#endif // RT30xx //
/* ----------------- TASK/THREAD Related MACRO ----------------- */
#define RT28XX_TASK_THREAD_INIT(pAd, Status) \
@@ -273,19 +321,8 @@ typedef struct _MGMT_STRUC {
/* ----------------- Frimware Related MACRO ----------------- */
-#if 0
-#define RT28XX_FIRMUD_INIT(pAd) \
- { UINT32 MacReg; \
- RTUSBReadMACRegister(pAd, MAC_CSR0, &MacReg); }
-
-#define RT28XX_FIRMUD_END(pAd) \
- RTUSBWriteMACRegister(pAd, 0x7014, 0xffffffff); \
- RTUSBWriteMACRegister(pAd, 0x701c, 0xffffffff); \
- RTUSBFirmwareRun(pAd);
-#else
#define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
-#endif
/* ----------------- TX Related MACRO ----------------- */
#define RT28XX_START_DEQUEUE(pAd, QueIdx, irqFlags) \
@@ -370,13 +407,6 @@ extern UCHAR EpToQueue[6];
/* ----------------- RX Related MACRO ----------------- */
//#define RT28XX_RX_ERROR_CHECK RTMPCheckRxWI
-#if 0
-#define RT28XX_RCV_INIT(pAd) \
- pAd->TransferBufferLength = 0; \
- pAd->ReadPosition = 0; \
- pAd->pCurrRxContext = NULL;
-#endif
-
#define RT28XX_RV_ALL_BUF_END(bBulkReceive) \
/* We return STATUS_MORE_PROCESSING_REQUIRED so that the completion */ \
/* routine (IofCompleteRequest) will stop working on the irp. */ \
@@ -384,27 +414,6 @@ extern UCHAR EpToQueue[6];
/* ----------------- ASIC Related MACRO ----------------- */
-#if 0
-#define RT28XX_DMA_WRITE_INIT(GloCfg) \
- { GloCfg.field.EnTXWriteBackDDONE = 1; \
- GloCfg.field.EnableRxDMA = 1; \
- GloCfg.field.EnableTxDMA = 1; }
-
-#define RT28XX_DMA_POST_WRITE(_pAd) \
- do{ USB_DMA_CFG_STRUC UsbCfg; \
- UsbCfg.word = 0; \
- /* for last packet, PBF might use more than limited, so minus 2 to prevent from error */ \
- UsbCfg.field.RxBulkAggLmt = (MAX_RXBULK_SIZE /1024)-3; \
- UsbCfg.field.phyclear = 0; \
- /* usb version is 1.1,do not use bulk in aggregation */ \
- if (_pAd->BulkInMaxPacketSize == 512) \
- UsbCfg.field.RxBulkAggEn = 1; \
- UsbCfg.field.RxBulkEn = 1; \
- UsbCfg.field.TxBulkEn = 1; \
- UsbCfg.field.RxBulkAggTOut = 0x80; /* 2006-10-18 */ \
- RTUSBWriteMACRegister(_pAd, USB_DMA_CFG, UsbCfg.word); \
- }while(0)
-#endif
// reset MAC of a station entry to 0xFFFFFFFFFFFF
#define RT28XX_STA_ENTRY_MAC_RESET(pAd, Wcid) \
@@ -420,6 +429,14 @@ extern UCHAR EpToQueue[6];
RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_CLIENT_MAC_ENTRY, \
pEntry, sizeof(MAC_TABLE_ENTRY));
+#ifdef RT30xx
+// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
+// Set MAC register value according operation mode
+#define RT28XX_UPDATE_PROTECT(pAd) \
+ RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_UPDATE_PROTECT, NULL, 0);
+// end johnli
+#endif
+
// remove Pair-wise key material from ASIC
// yet implement
#define RT28XX_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)
@@ -507,8 +524,10 @@ extern UCHAR EpToQueue[6];
#define RT28xx_CHIP_NAME "RT2870"
#define USB_CYC_CFG 0x02a4
+#ifndef RT30xx
#define STATUS_SUCCESS 0x00
#define STATUS_UNSUCCESSFUL 0x01
+#endif
#define NT_SUCCESS(status) (((status) > 0) ? (1):(0))
#define InterlockedIncrement atomic_inc
#define NdisInterlockedIncrement atomic_inc
@@ -533,7 +552,9 @@ extern UCHAR EpToQueue[6];
//#undef MlmeAllocateMemory
//#undef MlmeFreeMemory
+#ifndef RT30xx
typedef int NTSTATUS;
+#endif
typedef struct usb_device * PUSB_DEV;
/* MACRO for linux usb */
@@ -551,23 +572,9 @@ typedef struct usb_ctrlrequest devctrlrequest;
#define UNLINK_TIMEOUT_MS 3
/* unlink urb */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
#define RTUSB_UNLINK_URB(pUrb) usb_kill_urb(pUrb)
-#else
-#define RTUSB_UNLINK_URB(pUrb) usb_unlink_urb(pUrb)
-#endif
// Prototypes of completion funuc.
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define RTUSBBulkOutDataPacketComplete(purb, pt_regs) RTUSBBulkOutDataPacketComplete(purb)
-#define RTUSBBulkOutMLMEPacketComplete(pUrb, pt_regs) RTUSBBulkOutMLMEPacketComplete(pUrb)
-#define RTUSBBulkOutNullFrameComplete(pUrb, pt_regs) RTUSBBulkOutNullFrameComplete(pUrb)
-#define RTUSBBulkOutRTSFrameComplete(pUrb, pt_regs) RTUSBBulkOutRTSFrameComplete(pUrb)
-#define RTUSBBulkOutPsPollComplete(pUrb, pt_regs) RTUSBBulkOutPsPollComplete(pUrb)
-#define RTUSBBulkRxComplete(pUrb, pt_regs) RTUSBBulkRxComplete(pUrb)
-#endif
-
-
VOID RTUSBBulkOutDataPacketComplete(purbb_t purb, struct pt_regs *pt_regs);
VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs);
VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
@@ -575,7 +582,7 @@ VOID RTUSBBulkOutRTSFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb, struct pt_regs *pt_regs);
VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-
+#ifndef RT30xx
#define RTUSBMlmeUp(pAd) \
{ \
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
@@ -591,7 +598,22 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task)) \
up(&(pAd->RTUSBCmd_semaphore)); \
}
+#endif
+#ifdef RT30xx
+#define RTUSBMlmeUp(pAd) \
+{ \
+ POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
+ if(pObj->MLMEThr_pid>0) \
+ up(&(pAd->mlme_semaphore)); \
+}
+#define RTUSBCMDUp(pAd) \
+{ \
+ POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
+ if(pObj->RTUSBCmdThr_pid>0) \
+ up(&(pAd->RTUSBCmd_semaphore)); \
+}
+#endif
static inline NDIS_STATUS RTMPAllocateMemory(
OUT PVOID *ptr,
@@ -633,7 +655,9 @@ typedef struct _RT_SET_ASIC_WCID {
ULONG WCID; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
ULONG SetTid; // time-based: seconds, packet-based: kilo-packets
ULONG DeleteTid; // time-based: seconds, packet-based: kilo-packets
+#ifndef RT30xx
UCHAR Addr[MAC_ADDR_LEN]; // avoid in interrupt when write key
+#endif
} RT_SET_ASIC_WCID,*PRT_SET_ASIC_WCID;
typedef struct _RT_SET_ASIC_WCID_ATTRI {
@@ -676,13 +700,6 @@ typedef struct _CmdQ {
UINT32 CmdQState;
}CmdQ, *PCmdQ;
-//
-// For WPA SUPPLICANT: WIRELESS EXT support wireless events: v14 or newer
-//
-#if WIRELESS_EXT >= 14
-//#define WPA_SUPPLICANT_SUPPORT 1
-#endif
-
/* oid.h */
// Cipher suite type for mixed mode group cipher, P802.11i-2004
typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
@@ -742,6 +759,11 @@ typedef struct _CMDHandler_TLV {
#define CMDTHREAD_802_11_SET_PREAMBLE 0x0D790101 // cmd
#define CMDTHREAD_802_11_COUNTER_MEASURE 0x0D790102 // cmd
+#ifdef RT30xx
+// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
+#define CMDTHREAD_UPDATE_PROTECT 0x0D790103 // cmd
+// end johnli
+#endif
#define WPA1AKMBIT 0x01
#define WPA2AKMBIT 0x02
diff --git a/drivers/staging/rt2870/rt28xx.h b/drivers/staging/rt2870/rt28xx.h
index 3927d22f78fb..29bad957de48 100644
--- a/drivers/staging/rt2870/rt28xx.h
+++ b/drivers/staging/rt2870/rt28xx.h
@@ -1,2689 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rt28xx.h
-
- Abstract:
- RT28xx ASIC related definition & structures
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee Jan-3-2006 created for RT2860c
-*/
-
-#ifndef __RT28XX_H__
-#define __RT28XX_H__
-
-
-//
-// PCI registers - base address 0x0000
-//
-#define PCI_CFG 0x0000
-#define PCI_EECTRL 0x0004
-#define PCI_MCUCTRL 0x0008
-
-//
-// SCH/DMA registers - base address 0x0200
-//
-// INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit
-//
-#define DMA_CSR0 0x200
-#define INT_SOURCE_CSR 0x200
-#ifdef RT_BIG_ENDIAN
-typedef union _INT_SOURCE_CSR_STRUC {
- struct {
- UINT32 :14;
- UINT32 TxCoherent:1;
- UINT32 RxCoherent:1;
- UINT32 GPTimer:1;
- UINT32 AutoWakeup:1;//bit14
- UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
- UINT32 PreTBTT:1;
- UINT32 TBTTInt:1;
- UINT32 RxTxCoherent:1;
- UINT32 MCUCommandINT:1;
- UINT32 MgmtDmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 RxDone:1;
- UINT32 TxDelayINT:1; //delayed interrupt, not interrupt until several int or time limit hit
- UINT32 RxDelayINT:1; //dealyed interrupt
- } field;
- UINT32 word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-#else
-typedef union _INT_SOURCE_CSR_STRUC {
- struct {
- UINT32 RxDelayINT:1;
- UINT32 TxDelayINT:1;
- UINT32 RxDone:1;
- UINT32 Ac0DmaDone:1;//4
- UINT32 Ac1DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 HccaDmaDone:1; // bit7
- UINT32 MgmtDmaDone:1;
- UINT32 MCUCommandINT:1;//bit 9
- UINT32 RxTxCoherent:1;
- UINT32 TBTTInt:1;
- UINT32 PreTBTT:1;
- UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
- UINT32 AutoWakeup:1;//bit14
- UINT32 GPTimer:1;
- UINT32 RxCoherent:1;//bit16
- UINT32 TxCoherent:1;
- UINT32 :14;
- } field;
- UINT32 word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-#endif
-
-//
-// INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF
-//
-#define INT_MASK_CSR 0x204
-#ifdef RT_BIG_ENDIAN
-typedef union _INT_MASK_CSR_STRUC {
- struct {
- UINT32 TxCoherent:1;
- UINT32 RxCoherent:1;
- UINT32 :20;
- UINT32 MCUCommandINT:1;
- UINT32 MgmtDmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 RxDone:1;
- UINT32 TxDelay:1;
- UINT32 RXDelay_INT_MSK:1;
- } field;
- UINT32 word;
-}INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-#else
-typedef union _INT_MASK_CSR_STRUC {
- struct {
- UINT32 RXDelay_INT_MSK:1;
- UINT32 TxDelay:1;
- UINT32 RxDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 MgmtDmaDone:1;
- UINT32 MCUCommandINT:1;
- UINT32 :20;
- UINT32 RxCoherent:1;
- UINT32 TxCoherent:1;
- } field;
- UINT32 word;
-} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-#endif
-#define WPDMA_GLO_CFG 0x208
-#ifdef RT_BIG_ENDIAN
-typedef union _WPDMA_GLO_CFG_STRUC {
- struct {
- UINT32 HDR_SEG_LEN:16;
- UINT32 RXHdrScater:8;
- UINT32 BigEndian:1;
- UINT32 EnTXWriteBackDDONE:1;
- UINT32 WPDMABurstSIZE:2;
- UINT32 RxDMABusy:1;
- UINT32 EnableRxDMA:1;
- UINT32 TxDMABusy:1;
- UINT32 EnableTxDMA:1;
- } field;
- UINT32 word;
-}WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-#else
-typedef union _WPDMA_GLO_CFG_STRUC {
- struct {
- UINT32 EnableTxDMA:1;
- UINT32 TxDMABusy:1;
- UINT32 EnableRxDMA:1;
- UINT32 RxDMABusy:1;
- UINT32 WPDMABurstSIZE:2;
- UINT32 EnTXWriteBackDDONE:1;
- UINT32 BigEndian:1;
- UINT32 RXHdrScater:8;
- UINT32 HDR_SEG_LEN:16;
- } field;
- UINT32 word;
-} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-#endif
-#define WPDMA_RST_IDX 0x20c
-#ifdef RT_BIG_ENDIAN
-typedef union _WPDMA_RST_IDX_STRUC {
- struct {
- UINT32 :15;
- UINT32 RST_DRX_IDX0:1;
- UINT32 rsv:10;
- UINT32 RST_DTX_IDX5:1;
- UINT32 RST_DTX_IDX4:1;
- UINT32 RST_DTX_IDX3:1;
- UINT32 RST_DTX_IDX2:1;
- UINT32 RST_DTX_IDX1:1;
- UINT32 RST_DTX_IDX0:1;
- } field;
- UINT32 word;
-}WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#else
-typedef union _WPDMA_RST_IDX_STRUC {
- struct {
- UINT32 RST_DTX_IDX0:1;
- UINT32 RST_DTX_IDX1:1;
- UINT32 RST_DTX_IDX2:1;
- UINT32 RST_DTX_IDX3:1;
- UINT32 RST_DTX_IDX4:1;
- UINT32 RST_DTX_IDX5:1;
- UINT32 rsv:10;
- UINT32 RST_DRX_IDX0:1;
- UINT32 :15;
- } field;
- UINT32 word;
-} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#endif
-#define DELAY_INT_CFG 0x0210
-#ifdef RT_BIG_ENDIAN
-typedef union _DELAY_INT_CFG_STRUC {
- struct {
- UINT32 TXDLY_INT_EN:1;
- UINT32 TXMAX_PINT:7;
- UINT32 TXMAX_PTIME:8;
- UINT32 RXDLY_INT_EN:1;
- UINT32 RXMAX_PINT:7;
- UINT32 RXMAX_PTIME:8;
- } field;
- UINT32 word;
-}DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#else
-typedef union _DELAY_INT_CFG_STRUC {
- struct {
- UINT32 RXMAX_PTIME:8;
- UINT32 RXMAX_PINT:7;
- UINT32 RXDLY_INT_EN:1;
- UINT32 TXMAX_PTIME:8;
- UINT32 TXMAX_PINT:7;
- UINT32 TXDLY_INT_EN:1;
- } field;
- UINT32 word;
-} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#endif
-#define WMM_AIFSN_CFG 0x0214
-#ifdef RT_BIG_ENDIAN
-typedef union _AIFSN_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Aifsn3:4; // for AC_VO
- UINT32 Aifsn2:4; // for AC_VI
- UINT32 Aifsn1:4; // for AC_BK
- UINT32 Aifsn0:4; // for AC_BE
- } field;
- UINT32 word;
-} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-#else
-typedef union _AIFSN_CSR_STRUC {
- struct {
- UINT32 Aifsn0:4; // for AC_BE
- UINT32 Aifsn1:4; // for AC_BK
- UINT32 Aifsn2:4; // for AC_VI
- UINT32 Aifsn3:4; // for AC_VO
- UINT32 Rsv:16;
- } field;
- UINT32 word;
-} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-#endif
-//
-// CWMIN_CSR: CWmin for each EDCA AC
-//
-#define WMM_CWMIN_CFG 0x0218
-#ifdef RT_BIG_ENDIAN
-typedef union _CWMIN_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Cwmin3:4; // for AC_VO
- UINT32 Cwmin2:4; // for AC_VI
- UINT32 Cwmin1:4; // for AC_BK
- UINT32 Cwmin0:4; // for AC_BE
- } field;
- UINT32 word;
-} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-#else
-typedef union _CWMIN_CSR_STRUC {
- struct {
- UINT32 Cwmin0:4; // for AC_BE
- UINT32 Cwmin1:4; // for AC_BK
- UINT32 Cwmin2:4; // for AC_VI
- UINT32 Cwmin3:4; // for AC_VO
- UINT32 Rsv:16;
- } field;
- UINT32 word;
-} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-#endif
-
-//
-// CWMAX_CSR: CWmin for each EDCA AC
-//
-#define WMM_CWMAX_CFG 0x021c
-#ifdef RT_BIG_ENDIAN
-typedef union _CWMAX_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Cwmax3:4; // for AC_VO
- UINT32 Cwmax2:4; // for AC_VI
- UINT32 Cwmax1:4; // for AC_BK
- UINT32 Cwmax0:4; // for AC_BE
- } field;
- UINT32 word;
-} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-#else
-typedef union _CWMAX_CSR_STRUC {
- struct {
- UINT32 Cwmax0:4; // for AC_BE
- UINT32 Cwmax1:4; // for AC_BK
- UINT32 Cwmax2:4; // for AC_VI
- UINT32 Cwmax3:4; // for AC_VO
- UINT32 Rsv:16;
- } field;
- UINT32 word;
-} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-#endif
-
-
-//
-// AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
-//
-#define WMM_TXOP0_CFG 0x0220
-#ifdef RT_BIG_ENDIAN
-typedef union _AC_TXOP_CSR0_STRUC {
- struct {
- USHORT Ac1Txop; // for AC_BE, in unit of 32us
- USHORT Ac0Txop; // for AC_BK, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-#else
-typedef union _AC_TXOP_CSR0_STRUC {
- struct {
- USHORT Ac0Txop; // for AC_BK, in unit of 32us
- USHORT Ac1Txop; // for AC_BE, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-#endif
-
-//
-// AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
-//
-#define WMM_TXOP1_CFG 0x0224
-#ifdef RT_BIG_ENDIAN
-typedef union _AC_TXOP_CSR1_STRUC {
- struct {
- USHORT Ac3Txop; // for AC_VO, in unit of 32us
- USHORT Ac2Txop; // for AC_VI, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-#else
-typedef union _AC_TXOP_CSR1_STRUC {
- struct {
- USHORT Ac2Txop; // for AC_VI, in unit of 32us
- USHORT Ac3Txop; // for AC_VO, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-#endif
-#define RINGREG_DIFF 0x10
-#define GPIO_CTRL_CFG 0x0228 //MAC_CSR13
-#define MCU_CMD_CFG 0x022c
-#define TX_BASE_PTR0 0x0230 //AC_BK base address
-#define TX_MAX_CNT0 0x0234
-#define TX_CTX_IDX0 0x0238
-#define TX_DTX_IDX0 0x023c
-#define TX_BASE_PTR1 0x0240 //AC_BE base address
-#define TX_MAX_CNT1 0x0244
-#define TX_CTX_IDX1 0x0248
-#define TX_DTX_IDX1 0x024c
-#define TX_BASE_PTR2 0x0250 //AC_VI base address
-#define TX_MAX_CNT2 0x0254
-#define TX_CTX_IDX2 0x0258
-#define TX_DTX_IDX2 0x025c
-#define TX_BASE_PTR3 0x0260 //AC_VO base address
-#define TX_MAX_CNT3 0x0264
-#define TX_CTX_IDX3 0x0268
-#define TX_DTX_IDX3 0x026c
-#define TX_BASE_PTR4 0x0270 //HCCA base address
-#define TX_MAX_CNT4 0x0274
-#define TX_CTX_IDX4 0x0278
-#define TX_DTX_IDX4 0x027c
-#define TX_BASE_PTR5 0x0280 //MGMT base address
-#define TX_MAX_CNT5 0x0284
-#define TX_CTX_IDX5 0x0288
-#define TX_DTX_IDX5 0x028c
-#define TX_MGMTMAX_CNT TX_MAX_CNT5
-#define TX_MGMTCTX_IDX TX_CTX_IDX5
-#define TX_MGMTDTX_IDX TX_DTX_IDX5
-#define RX_BASE_PTR 0x0290 //RX base address
-#define RX_MAX_CNT 0x0294
-#define RX_CRX_IDX 0x0298
-#define RX_DRX_IDX 0x029c
-#define USB_DMA_CFG 0x02a0
-#ifdef RT_BIG_ENDIAN
-typedef union _USB_DMA_CFG_STRUC {
- struct {
- UINT32 TxBusy:1; //USB DMA TX FSM busy . debug only
- UINT32 RxBusy:1; //USB DMA RX FSM busy . debug only
- UINT32 EpoutValid:6; //OUT endpoint data valid. debug only
- UINT32 TxBulkEn:1; //Enable USB DMA Tx
- UINT32 RxBulkEn:1; //Enable USB DMA Rx
- UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
- UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
- UINT32 TxClear:1; //Clear USB DMA TX path
- UINT32 rsv:2;
- UINT32 phyclear:1; //phy watch dog enable. write 1
- UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 1024 bytes
- UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
- } field;
- UINT32 word;
-} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-#else
-typedef union _USB_DMA_CFG_STRUC {
- struct {
- UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
- UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 256 bytes
- UINT32 phyclear:1; //phy watch dog enable. write 1
- UINT32 rsv:2;
- UINT32 TxClear:1; //Clear USB DMA TX path
- UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
- UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
- UINT32 RxBulkEn:1; //Enable USB DMA Rx
- UINT32 TxBulkEn:1; //Enable USB DMA Tx
- UINT32 EpoutValid:6; //OUT endpoint data valid
- UINT32 RxBusy:1; //USB DMA RX FSM busy
- UINT32 TxBusy:1; //USB DMA TX FSM busy
- } field;
- UINT32 word;
-} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-#endif
-
-//
-// 3 PBF registers
-//
-//
-// Most are for debug. Driver doesn't touch PBF register.
-#define PBF_SYS_CTRL 0x0400
-#define PBF_CFG 0x0408
-#define PBF_MAX_PCNT 0x040C
-#define PBF_CTRL 0x0410
-#define PBF_INT_STA 0x0414
-#define PBF_INT_ENA 0x0418
-#define TXRXQ_PCNT 0x0438
-#define PBF_DBG 0x043c
-#define PBF_CAP_CTRL 0x0440
-
-//
-// 4 MAC registers
-//
-//
-// 4.1 MAC SYSTEM configuration registers (offset:0x1000)
-//
-#define MAC_CSR0 0x1000
-#ifdef RT_BIG_ENDIAN
-typedef union _ASIC_VER_ID_STRUC {
- struct {
- USHORT ASICVer; // version : 2860
- USHORT ASICRev; // reversion : 0
- } field;
- UINT32 word;
-} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#else
-typedef union _ASIC_VER_ID_STRUC {
- struct {
- USHORT ASICRev; // reversion : 0
- USHORT ASICVer; // version : 2860
- } field;
- UINT32 word;
-} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#endif
-#define MAC_SYS_CTRL 0x1004 //MAC_CSR1
-#define MAC_ADDR_DW0 0x1008 // MAC ADDR DW0
-#define MAC_ADDR_DW1 0x100c // MAC ADDR DW1
-//
-// MAC_CSR2: STA MAC register 0
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_DW0_STRUC {
- struct {
- UCHAR Byte3; // MAC address byte 3
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte0; // MAC address byte 0
- } field;
- UINT32 word;
-} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-#else
-typedef union _MAC_DW0_STRUC {
- struct {
- UCHAR Byte0; // MAC address byte 0
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte3; // MAC address byte 3
- } field;
- UINT32 word;
-} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-#endif
-
-//
-// MAC_CSR3: STA MAC register 1
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_DW1_STRUC {
- struct {
- UCHAR Rsvd1;
- UCHAR U2MeMask;
- UCHAR Byte5; // MAC address byte 5
- UCHAR Byte4; // MAC address byte 4
- } field;
- UINT32 word;
-} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-#else
-typedef union _MAC_DW1_STRUC {
- struct {
- UCHAR Byte4; // MAC address byte 4
- UCHAR Byte5; // MAC address byte 5
- UCHAR U2MeMask;
- UCHAR Rsvd1;
- } field;
- UINT32 word;
-} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-#endif
-
-#define MAC_BSSID_DW0 0x1010 // MAC BSSID DW0
-#define MAC_BSSID_DW1 0x1014 // MAC BSSID DW1
-
-//
-// MAC_CSR5: BSSID register 1
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_CSR5_STRUC {
- struct {
- USHORT Rsvd:11;
- USHORT MBssBcnNum:3;
- USHORT BssIdMode:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
- UCHAR Byte5; // BSSID byte 5
- UCHAR Byte4; // BSSID byte 4
- } field;
- UINT32 word;
-} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-#else
-typedef union _MAC_CSR5_STRUC {
- struct {
- UCHAR Byte4; // BSSID byte 4
- UCHAR Byte5; // BSSID byte 5
- USHORT BssIdMask:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
- USHORT MBssBcnNum:3;
- USHORT Rsvd:11;
- } field;
- UINT32 word;
-} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-#endif
-
-#define MAX_LEN_CFG 0x1018 // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
-#define BBP_CSR_CFG 0x101c //
-//
-// BBP_CSR_CFG: BBP serial control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _BBP_CSR_CFG_STRUC {
- struct {
- UINT32 :12;
- UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
- UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
- UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
- UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
- UINT32 RegNum:8; // Selected BBP register
- UINT32 Value:8; // Register value to program into BBP
- } field;
- UINT32 word;
-} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#else
-typedef union _BBP_CSR_CFG_STRUC {
- struct {
- UINT32 Value:8; // Register value to program into BBP
- UINT32 RegNum:8; // Selected BBP register
- UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
- UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
- UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
- UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
- UINT32 :12;
- } field;
- UINT32 word;
-} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#endif
-#define RF_CSR_CFG0 0x1020
-//
-// RF_CSR_CFG: RF control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG0_STRUC {
- struct {
- UINT32 Busy:1; // 0: idle 1: 8busy
- UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
- UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
- UINT32 bitwidth:5; // Selected BBP register
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#else
-typedef union _RF_CSR_CFG0_STRUC {
- struct {
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- UINT32 bitwidth:5; // Selected BBP register
- UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
- UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
- UINT32 Busy:1; // 0: idle 1: 8busy
- } field;
- UINT32 word;
-} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#endif
-#define RF_CSR_CFG1 0x1024
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG1_STRUC {
- struct {
- UINT32 rsv:7; // 0: idle 1: 8busy
- UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#else
-typedef union _RF_CSR_CFG1_STRUC {
- struct {
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
- UINT32 rsv:7; // 0: idle 1: 8busy
- } field;
- UINT32 word;
-} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#endif
-#define RF_CSR_CFG2 0x1028 //
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG2_STRUC {
- struct {
- UINT32 rsv:8; // 0: idle 1: 8busy
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#else
-typedef union _RF_CSR_CFG2_STRUC {
- struct {
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- UINT32 rsv:8; // 0: idle 1: 8busy
- } field;
- UINT32 word;
-} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#endif
-#define LED_CFG 0x102c // MAC_CSR14
-#ifdef RT_BIG_ENDIAN
-typedef union _LED_CFG_STRUC {
- struct {
- UINT32 :1;
- UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
- UINT32 YLedMode:2; // yellow Led Mode
- UINT32 GLedMode:2; // green Led Mode
- UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
- UINT32 rsv:2;
- UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
- UINT32 OffPeriod:8; // blinking off period unit 1ms
- UINT32 OnPeriod:8; // blinking on period unit 1ms
- } field;
- UINT32 word;
-} LED_CFG_STRUC, *PLED_CFG_STRUC;
-#else
-typedef union _LED_CFG_STRUC {
- struct {
- UINT32 OnPeriod:8; // blinking on period unit 1ms
- UINT32 OffPeriod:8; // blinking off period unit 1ms
- UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
- UINT32 rsv:2;
- UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
- UINT32 GLedMode:2; // green Led Mode
- UINT32 YLedMode:2; // yellow Led Mode
- UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
- UINT32 :1;
- } field;
- UINT32 word;
-} LED_CFG_STRUC, *PLED_CFG_STRUC;
-#endif
-//
-// 4.2 MAC TIMING configuration registers (offset:0x1100)
-//
-#define XIFS_TIME_CFG 0x1100 // MAC_CSR8 MAC_CSR9
-#ifdef RT_BIG_ENDIAN
-typedef union _IFS_SLOT_CFG_STRUC {
- struct {
- UINT32 rsv:2;
- UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
- UINT32 EIFS:9; // unit 1us
- UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
- UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
- UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
- } field;
- UINT32 word;
-} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-#else
-typedef union _IFS_SLOT_CFG_STRUC {
- struct {
- UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
- UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
- UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
- UINT32 EIFS:9; // unit 1us
- UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
- UINT32 rsv:2;
- } field;
- UINT32 word;
-} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-#endif
-
-#define BKOFF_SLOT_CFG 0x1104 // mac_csr9 last 8 bits
-#define NAV_TIME_CFG 0x1108 // NAV (MAC_CSR15)
-#define CH_TIME_CFG 0x110C // Count as channel busy
-#define PBF_LIFE_TIMER 0x1110 //TX/RX MPDU timestamp timer (free run)Unit: 1us
-#define BCN_TIME_CFG 0x1114 // TXRX_CSR9
-
-#define BCN_OFFSET0 0x042C
-#define BCN_OFFSET1 0x0430
-
-//
-// BCN_TIME_CFG : Synchronization control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _BCN_TIME_CFG_STRUC {
- struct {
- UINT32 TxTimestampCompensate:8;
- UINT32 :3;
- UINT32 bBeaconGen:1; // Enable beacon generator
- UINT32 bTBTTEnable:1;
- UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
- UINT32 bTsfTicking:1; // Enable TSF auto counting
- UINT32 BeaconInterval:16; // in unit of 1/16 TU
- } field;
- UINT32 word;
-} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#else
-typedef union _BCN_TIME_CFG_STRUC {
- struct {
- UINT32 BeaconInterval:16; // in unit of 1/16 TU
- UINT32 bTsfTicking:1; // Enable TSF auto counting
- UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
- UINT32 bTBTTEnable:1;
- UINT32 bBeaconGen:1; // Enable beacon generator
- UINT32 :3;
- UINT32 TxTimestampCompensate:8;
- } field;
- UINT32 word;
-} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#endif
-#define TBTT_SYNC_CFG 0x1118 // txrx_csr10
-#define TSF_TIMER_DW0 0x111C // Local TSF timer lsb 32 bits. Read-only
-#define TSF_TIMER_DW1 0x1120 // msb 32 bits. Read-only.
-#define TBTT_TIMER 0x1124 // TImer remains till next TBTT. Read-only. TXRX_CSR14
-#define INT_TIMER_CFG 0x1128 //
-#define INT_TIMER_EN 0x112c // GP-timer and pre-tbtt Int enable
-#define CH_IDLE_STA 0x1130 // channel idle time
-#define CH_BUSY_STA 0x1134 // channle busy time
-//
-// 4.2 MAC POWER configuration registers (offset:0x1200)
-//
-#define MAC_STATUS_CFG 0x1200 // old MAC_CSR12
-#define PWR_PIN_CFG 0x1204 // old MAC_CSR12
-#define AUTO_WAKEUP_CFG 0x1208 // old MAC_CSR10
-//
-// AUTO_WAKEUP_CFG: Manual power control / status register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _AUTO_WAKEUP_STRUC {
- struct {
- UINT32 :16;
- UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
- UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
- UINT32 AutoLeadTime:8;
- } field;
- UINT32 word;
-} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-#else
-typedef union _AUTO_WAKEUP_STRUC {
- struct {
- UINT32 AutoLeadTime:8;
- UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
- UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
- UINT32 :16;
- } field;
- UINT32 word;
-} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-#endif
-//
-// 4.3 MAC TX configuration registers (offset:0x1300)
-//
-
-#define EDCA_AC0_CFG 0x1300 //AC_TXOP_CSR0 0x3474
-#define EDCA_AC1_CFG 0x1304
-#define EDCA_AC2_CFG 0x1308
-#define EDCA_AC3_CFG 0x130c
-#ifdef RT_BIG_ENDIAN
-typedef union _EDCA_AC_CFG_STRUC {
- struct {
- UINT32 :12; //
- UINT32 Cwmax:4; //unit power of 2
- UINT32 Cwmin:4; //
- UINT32 Aifsn:4; // # of slot time
- UINT32 AcTxop:8; // in unit of 32us
- } field;
- UINT32 word;
-} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-#else
-typedef union _EDCA_AC_CFG_STRUC {
- struct {
- UINT32 AcTxop:8; // in unit of 32us
- UINT32 Aifsn:4; // # of slot time
- UINT32 Cwmin:4; //
- UINT32 Cwmax:4; //unit power of 2
- UINT32 :12; //
- } field;
- UINT32 word;
-} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-#endif
-
-#define EDCA_TID_AC_MAP 0x1310
-#define TX_PWR_CFG_0 0x1314
-#define TX_PWR_CFG_1 0x1318
-#define TX_PWR_CFG_2 0x131C
-#define TX_PWR_CFG_3 0x1320
-#define TX_PWR_CFG_4 0x1324
-#define TX_PIN_CFG 0x1328
-#define TX_BAND_CFG 0x132c // 0x1 use upper 20MHz. 0 juse lower 20MHz
-#define TX_SW_CFG0 0x1330
-#define TX_SW_CFG1 0x1334
-#define TX_SW_CFG2 0x1338
-#define TXOP_THRES_CFG 0x133c
-#define TXOP_CTRL_CFG 0x1340
-#define TX_RTS_CFG 0x1344
-
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_RTS_CFG_STRUC {
- struct {
- UINT32 rsv:7;
- UINT32 RtsFbkEn:1; // enable rts rate fallback
- UINT32 RtsThres:16; // unit:byte
- UINT32 AutoRtsRetryLimit:8;
- } field;
- UINT32 word;
-} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#else
-typedef union _TX_RTS_CFG_STRUC {
- struct {
- UINT32 AutoRtsRetryLimit:8;
- UINT32 RtsThres:16; // unit:byte
- UINT32 RtsFbkEn:1; // enable rts rate fallback
- UINT32 rsv:7; // 1: HT non-STBC control frame enable
- } field;
- UINT32 word;
-} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#endif
-#define TX_TIMEOUT_CFG 0x1348
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_TIMEOUT_CFG_STRUC {
- struct {
- UINT32 rsv2:8;
- UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
- UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
- UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
- UINT32 rsv:4;
- } field;
- UINT32 word;
-} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#else
-typedef union _TX_TIMEOUT_CFG_STRUC {
- struct {
- UINT32 rsv:4;
- UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
- UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
- UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
- UINT32 rsv2:8; // 1: HT non-STBC control frame enable
- } field;
- UINT32 word;
-} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#endif
-#define TX_RTY_CFG 0x134c
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_RTY_CFG_STRUC {
- struct {
- UINT32 rsv:1;
- UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
- UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 LongRtyThre:12; // Long retry threshoold
- UINT32 LongRtyLimit:8; //long retry limit
- UINT32 ShortRtyLimit:8; // short retry limit
-
- } field;
- UINT32 word;
-} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#else
-typedef union PACKED _TX_RTY_CFG_STRUC {
- struct {
- UINT32 ShortRtyLimit:8; // short retry limit
- UINT32 LongRtyLimit:8; //long retry limit
- UINT32 LongRtyThre:12; // Long retry threshoold
- UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
- UINT32 rsv:1; // 1: HT non-STBC control frame enable
- } field;
- UINT32 word;
-} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#endif
-#define TX_LINK_CFG 0x1350
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_LINK_CFG_STRUC {
- struct PACKED {
- UINT32 RemotMFS:8; //remote MCS feedback sequence number
- UINT32 RemotMFB:8; // remote MCS feedback
- UINT32 rsv:3; //
- UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
- UINT32 TxRDGEn:1; // RDG TX enable
- UINT32 TxMRQEn:1; // MCS request TX enable
- UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
- UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
- UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
- } field;
- UINT32 word;
-} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#else
-typedef union PACKED _TX_LINK_CFG_STRUC {
- struct PACKED {
- UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
- UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
- UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
- UINT32 TxMRQEn:1; // MCS request TX enable
- UINT32 TxRDGEn:1; // RDG TX enable
- UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
- UINT32 rsv:3; //
- UINT32 RemotMFB:8; // remote MCS feedback
- UINT32 RemotMFS:8; //remote MCS feedback sequence number
- } field;
- UINT32 word;
-} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#endif
-#define HT_FBK_CFG0 0x1354
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _HT_FBK_CFG0_STRUC {
- struct {
- UINT32 HTMCS7FBK:4;
- UINT32 HTMCS6FBK:4;
- UINT32 HTMCS5FBK:4;
- UINT32 HTMCS4FBK:4;
- UINT32 HTMCS3FBK:4;
- UINT32 HTMCS2FBK:4;
- UINT32 HTMCS1FBK:4;
- UINT32 HTMCS0FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#else
-typedef union PACKED _HT_FBK_CFG0_STRUC {
- struct {
- UINT32 HTMCS0FBK:4;
- UINT32 HTMCS1FBK:4;
- UINT32 HTMCS2FBK:4;
- UINT32 HTMCS3FBK:4;
- UINT32 HTMCS4FBK:4;
- UINT32 HTMCS5FBK:4;
- UINT32 HTMCS6FBK:4;
- UINT32 HTMCS7FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#endif
-#define HT_FBK_CFG1 0x1358
-#ifdef RT_BIG_ENDIAN
-typedef union _HT_FBK_CFG1_STRUC {
- struct {
- UINT32 HTMCS15FBK:4;
- UINT32 HTMCS14FBK:4;
- UINT32 HTMCS13FBK:4;
- UINT32 HTMCS12FBK:4;
- UINT32 HTMCS11FBK:4;
- UINT32 HTMCS10FBK:4;
- UINT32 HTMCS9FBK:4;
- UINT32 HTMCS8FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#else
-typedef union _HT_FBK_CFG1_STRUC {
- struct {
- UINT32 HTMCS8FBK:4;
- UINT32 HTMCS9FBK:4;
- UINT32 HTMCS10FBK:4;
- UINT32 HTMCS11FBK:4;
- UINT32 HTMCS12FBK:4;
- UINT32 HTMCS13FBK:4;
- UINT32 HTMCS14FBK:4;
- UINT32 HTMCS15FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#endif
-#define LG_FBK_CFG0 0x135c
-#ifdef RT_BIG_ENDIAN
-typedef union _LG_FBK_CFG0_STRUC {
- struct {
- UINT32 OFDMMCS7FBK:4; //initial value is 6
- UINT32 OFDMMCS6FBK:4; //initial value is 5
- UINT32 OFDMMCS5FBK:4; //initial value is 4
- UINT32 OFDMMCS4FBK:4; //initial value is 3
- UINT32 OFDMMCS3FBK:4; //initial value is 2
- UINT32 OFDMMCS2FBK:4; //initial value is 1
- UINT32 OFDMMCS1FBK:4; //initial value is 0
- UINT32 OFDMMCS0FBK:4; //initial value is 0
- } field;
- UINT32 word;
-} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#else
-typedef union _LG_FBK_CFG0_STRUC {
- struct {
- UINT32 OFDMMCS0FBK:4; //initial value is 0
- UINT32 OFDMMCS1FBK:4; //initial value is 0
- UINT32 OFDMMCS2FBK:4; //initial value is 1
- UINT32 OFDMMCS3FBK:4; //initial value is 2
- UINT32 OFDMMCS4FBK:4; //initial value is 3
- UINT32 OFDMMCS5FBK:4; //initial value is 4
- UINT32 OFDMMCS6FBK:4; //initial value is 5
- UINT32 OFDMMCS7FBK:4; //initial value is 6
- } field;
- UINT32 word;
-} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#endif
-#define LG_FBK_CFG1 0x1360
-#ifdef RT_BIG_ENDIAN
-typedef union _LG_FBK_CFG1_STRUC {
- struct {
- UINT32 rsv:16;
- UINT32 CCKMCS3FBK:4; //initial value is 2
- UINT32 CCKMCS2FBK:4; //initial value is 1
- UINT32 CCKMCS1FBK:4; //initial value is 0
- UINT32 CCKMCS0FBK:4; //initial value is 0
- } field;
- UINT32 word;
-} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-#else
-typedef union _LG_FBK_CFG1_STRUC {
- struct {
- UINT32 CCKMCS0FBK:4; //initial value is 0
- UINT32 CCKMCS1FBK:4; //initial value is 0
- UINT32 CCKMCS2FBK:4; //initial value is 1
- UINT32 CCKMCS3FBK:4; //initial value is 2
- UINT32 rsv:16;
- } field;
- UINT32 word;
-} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-#endif
-
-//=======================================================
-//================ Protection Paramater================================
-//=======================================================
-#define CCK_PROT_CFG 0x1364 //CCK Protection
-#define ASIC_SHORTNAV 1
-#define ASIC_LONGNAV 2
-#define ASIC_RTS 1
-#define ASIC_CTS 2
-#ifdef RT_BIG_ENDIAN
-typedef union _PROT_CFG_STRUC {
- struct {
- UINT32 rsv:5;
- UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
- UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
- UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
- UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
- UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
- UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
- } field;
- UINT32 word;
-} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-#else
-typedef union _PROT_CFG_STRUC {
- struct {
- UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
- UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
- UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
- UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
- UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
- UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
- UINT32 rsv:5;
- } field;
- UINT32 word;
-} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-#endif
-
-#define OFDM_PROT_CFG 0x1368 //OFDM Protection
-#define MM20_PROT_CFG 0x136C //MM20 Protection
-#define MM40_PROT_CFG 0x1370 //MM40 Protection
-#define GF20_PROT_CFG 0x1374 //GF20 Protection
-#define GF40_PROT_CFG 0x1378 //GR40 Protection
-#define EXP_CTS_TIME 0x137C //
-#define EXP_ACK_TIME 0x1380 //
-
-//
-// 4.4 MAC RX configuration registers (offset:0x1400)
-//
-#define RX_FILTR_CFG 0x1400 //TXRX_CSR0
-#define AUTO_RSP_CFG 0x1404 //TXRX_CSR4
-//
-// TXRX_CSR4: Auto-Responder/
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _AUTO_RSP_CFG_STRUC {
- struct {
- UINT32 :24;
- UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
- UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
- UINT32 rsv:1; // Power bit value in conrtrol frame
- UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
- UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
- UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
- UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
- UINT32 AutoResponderEnable:1;
- } field;
- UINT32 word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-#else
-typedef union _AUTO_RSP_CFG_STRUC {
- struct {
- UINT32 AutoResponderEnable:1;
- UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
- UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
- UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
- UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
- UINT32 rsv:1; // Power bit value in conrtrol frame
- UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
- UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
- UINT32 :24;
- } field;
- UINT32 word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-#endif
-
-#define LEGACY_BASIC_RATE 0x1408 // TXRX_CSR5 0x3054
-#define HT_BASIC_RATE 0x140c
-#define HT_CTRL_CFG 0x1410
-#define SIFS_COST_CFG 0x1414
-#define RX_PARSER_CFG 0x1418 //Set NAV for all received frames
-
-//
-// 4.5 MAC Security configuration (offset:0x1500)
-//
-#define TX_SEC_CNT0 0x1500 //
-#define RX_SEC_CNT0 0x1504 //
-#define CCMP_FC_MUTE 0x1508 //
-//
-// 4.6 HCCA/PSMP (offset:0x1600)
-//
-#define TXOP_HLDR_ADDR0 0x1600
-#define TXOP_HLDR_ADDR1 0x1604
-#define TXOP_HLDR_ET 0x1608
-#define QOS_CFPOLL_RA_DW0 0x160c
-#define QOS_CFPOLL_A1_DW1 0x1610
-#define QOS_CFPOLL_QC 0x1614
-//
-// 4.7 MAC Statistis registers (offset:0x1700)
-//
-#define RX_STA_CNT0 0x1700 //
-#define RX_STA_CNT1 0x1704 //
-#define RX_STA_CNT2 0x1708 //
-
-//
-// RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT0_STRUC {
- struct {
- USHORT PhyErr;
- USHORT CrcErr;
- } field;
- UINT32 word;
-} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-#else
-typedef union _RX_STA_CNT0_STRUC {
- struct {
- USHORT CrcErr;
- USHORT PhyErr;
- } field;
- UINT32 word;
-} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-#endif
-
-//
-// RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT1_STRUC {
- struct {
- USHORT PlcpErr;
- USHORT FalseCca;
- } field;
- UINT32 word;
-} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-#else
-typedef union _RX_STA_CNT1_STRUC {
- struct {
- USHORT FalseCca;
- USHORT PlcpErr;
- } field;
- UINT32 word;
-} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-#endif
-
-//
-// RX_STA_CNT2_STRUC:
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT2_STRUC {
- struct {
- USHORT RxFifoOverflowCount;
- USHORT RxDupliCount;
- } field;
- UINT32 word;
-} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#else
-typedef union _RX_STA_CNT2_STRUC {
- struct {
- USHORT RxDupliCount;
- USHORT RxFifoOverflowCount;
- } field;
- UINT32 word;
-} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#endif
-#define TX_STA_CNT0 0x170C //
-//
-// STA_CSR3: TX Beacon count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT0_STRUC {
- struct {
- USHORT TxBeaconCount;
- USHORT TxFailCount;
- } field;
- UINT32 word;
-} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#else
-typedef union _TX_STA_CNT0_STRUC {
- struct {
- USHORT TxFailCount;
- USHORT TxBeaconCount;
- } field;
- UINT32 word;
-} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#endif
-#define TX_STA_CNT1 0x1710 //
-//
-// TX_STA_CNT1: TX tx count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT1_STRUC {
- struct {
- USHORT TxRetransmit;
- USHORT TxSuccess;
- } field;
- UINT32 word;
-} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#else
-typedef union _TX_STA_CNT1_STRUC {
- struct {
- USHORT TxSuccess;
- USHORT TxRetransmit;
- } field;
- UINT32 word;
-} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#endif
-#define TX_STA_CNT2 0x1714 //
-//
-// TX_STA_CNT2: TX tx count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT2_STRUC {
- struct {
- USHORT TxUnderFlowCount;
- USHORT TxZeroLenCount;
- } field;
- UINT32 word;
-} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#else
-typedef union _TX_STA_CNT2_STRUC {
- struct {
- USHORT TxZeroLenCount;
- USHORT TxUnderFlowCount;
- } field;
- UINT32 word;
-} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#endif
-#define TX_STA_FIFO 0x1718 //
-//
-// TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_STA_FIFO_STRUC {
- struct {
- UINT32 Reserve:2;
- UINT32 TxBF:1; // 3*3
- UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
-// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 wcid:8; //wireless client index
- UINT32 TxAckRequired:1; // ack required
- UINT32 TxAggre:1; // Tx is aggregated
- UINT32 TxSuccess:1; // Tx success. whether success or not
- UINT32 PidType:4;
- UINT32 bValid:1; // 1:This register contains a valid TX result
- } field;
- UINT32 word;
-} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-#else
-typedef union PACKED _TX_STA_FIFO_STRUC {
- struct {
- UINT32 bValid:1; // 1:This register contains a valid TX result
- UINT32 PidType:4;
- UINT32 TxSuccess:1; // Tx No retry success
- UINT32 TxAggre:1; // Tx Retry Success
- UINT32 TxAckRequired:1; // Tx fail
- UINT32 wcid:8; //wireless client index
-// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 TxBF:1;
- UINT32 Reserve:2;
- } field;
- UINT32 word;
-} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT 0x171c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT_STRUC {
- struct {
- USHORT AggTxCount;
- USHORT NonAggTxCount;
- } field;
- UINT32 word;
-} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-#else
-typedef union _TX_AGG_CNT_STRUC {
- struct {
- USHORT NonAggTxCount;
- USHORT AggTxCount;
- } field;
- UINT32 word;
-} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT0 0x1720
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT0_STRUC {
- struct {
- USHORT AggSize2Count;
- USHORT AggSize1Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-#else
-typedef union _TX_AGG_CNT0_STRUC {
- struct {
- USHORT AggSize1Count;
- USHORT AggSize2Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT1 0x1724
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT1_STRUC {
- struct {
- USHORT AggSize4Count;
- USHORT AggSize3Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#else
-typedef union _TX_AGG_CNT1_STRUC {
- struct {
- USHORT AggSize3Count;
- USHORT AggSize4Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#endif
-#define TX_AGG_CNT2 0x1728
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT2_STRUC {
- struct {
- USHORT AggSize6Count;
- USHORT AggSize5Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-#else
-typedef union _TX_AGG_CNT2_STRUC {
- struct {
- USHORT AggSize5Count;
- USHORT AggSize6Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT3 0x172c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT3_STRUC {
- struct {
- USHORT AggSize8Count;
- USHORT AggSize7Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-#else
-typedef union _TX_AGG_CNT3_STRUC {
- struct {
- USHORT AggSize7Count;
- USHORT AggSize8Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT4 0x1730
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT4_STRUC {
- struct {
- USHORT AggSize10Count;
- USHORT AggSize9Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#else
-typedef union _TX_AGG_CNT4_STRUC {
- struct {
- USHORT AggSize9Count;
- USHORT AggSize10Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#endif
-#define TX_AGG_CNT5 0x1734
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT5_STRUC {
- struct {
- USHORT AggSize12Count;
- USHORT AggSize11Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#else
-typedef union _TX_AGG_CNT5_STRUC {
- struct {
- USHORT AggSize11Count;
- USHORT AggSize12Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#endif
-#define TX_AGG_CNT6 0x1738
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT6_STRUC {
- struct {
- USHORT AggSize14Count;
- USHORT AggSize13Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#else
-typedef union _TX_AGG_CNT6_STRUC {
- struct {
- USHORT AggSize13Count;
- USHORT AggSize14Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#endif
-#define TX_AGG_CNT7 0x173c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT7_STRUC {
- struct {
- USHORT AggSize16Count;
- USHORT AggSize15Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#else
-typedef union _TX_AGG_CNT7_STRUC {
- struct {
- USHORT AggSize15Count;
- USHORT AggSize16Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#endif
-#define MPDU_DENSITY_CNT 0x1740
-#ifdef RT_BIG_ENDIAN
-typedef union _MPDU_DEN_CNT_STRUC {
- struct {
- USHORT RXZeroDelCount; //RX zero length delimiter count
- USHORT TXZeroDelCount; //TX zero length delimiter count
- } field;
- UINT32 word;
-} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-#else
-typedef union _MPDU_DEN_CNT_STRUC {
- struct {
- USHORT TXZeroDelCount; //TX zero length delimiter count
- USHORT RXZeroDelCount; //RX zero length delimiter count
- } field;
- UINT32 word;
-} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-#endif
-//
-// TXRX control registers - base address 0x3000
-//
-// rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
-#define TXRX_CSR1 0x77d0
-
-//
-// Security key table memory, base address = 0x1000
-//
-#define MAC_WCID_BASE 0x1800 //8-bytes(use only 6-bytes) * 256 entry =
-#define HW_WCID_ENTRY_SIZE 8
-#define PAIRWISE_KEY_TABLE_BASE 0x4000 // 32-byte * 256-entry = -byte
-#define HW_KEY_ENTRY_SIZE 0x20
-#define PAIRWISE_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
-#define MAC_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
-#define HW_IVEIV_ENTRY_SIZE 8
-#define MAC_WCID_ATTRIBUTE_BASE 0x6800 // 4-byte * 256-entry = -byte
-#define HW_WCID_ATTRI_SIZE 4
-#define WCID_RESERVED 0x6bfc
-#define SHARED_KEY_TABLE_BASE 0x6c00 // 32-byte * 16-entry = 512-byte
-#define SHARED_KEY_MODE_BASE 0x7000 // 32-byte * 16-entry = 512-byte
-#define HW_SHARED_KEY_MODE_SIZE 4
-#define SHAREDKEYTABLE 0
-#define PAIRWISEKEYTABLE 1
-
-
-#ifdef RT_BIG_ENDIAN
-typedef union _SHAREDKEY_MODE_STRUC {
- struct {
- UINT32 :1;
- UINT32 Bss1Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key0CipherAlg:3;
- } field;
- UINT32 word;
-} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-#else
-typedef union _SHAREDKEY_MODE_STRUC {
- struct {
- UINT32 Bss0Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key3CipherAlg:3;
- UINT32 :1;
- } field;
- UINT32 word;
-} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-#endif
-// 64-entry for pairwise key table
-typedef struct _HW_WCID_ENTRY { // 8-byte per entry
- UCHAR Address[6];
- UCHAR Rsv[2];
-} HW_WCID_ENTRY, PHW_WCID_ENTRY;
-
-
-
-//
-// Other on-chip shared memory space, base = 0x2000
-//
-
-// CIS space - base address = 0x2000
-#define HW_CIS_BASE 0x2000
-
-// Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function.
-#define HW_CS_CTS_BASE 0x7700
-// DFS CTS frame base address. It's where mac stores CTS frame for DFS.
-#define HW_DFS_CTS_BASE 0x7780
-#define HW_CTS_FRAME_SIZE 0x80
-
-// 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes
-// to save debugging settings
-#define HW_DEBUG_SETTING_BASE 0x77f0 // 0x77f0~0x77ff total 16 bytes
-#define HW_DEBUG_SETTING_BASE2 0x7770 // 0x77f0~0x77ff total 16 bytes
-
-#if 0
-// on-chip BEACON frame space - base address = 0x7800
-#define HW_BEACON_MAX_SIZE 0x0800 /* unit: byte */
-#define HW_BEACON_BASE0 0x7800
-#define HW_BEACON_BASE1 0x7900
-#define HW_BEACON_BASE2 0x7a00
-#define HW_BEACON_BASE3 0x7b00
-#define HW_BEACON_BASE4 0x7c00
-#define HW_BEACON_BASE5 0x7d00
-#define HW_BEACON_BASE6 0x7e00
-#define HW_BEACON_BASE7 0x7f00
-/* 1. HW_BEACON_OFFSET/64B must be 0;
- 2. BCN_OFFSET0 must also be changed in NICInitializeAsic();
- 3. max 0x0800 for 8 beacon frames; */
-#else
-// In order to support maximum 8 MBSS and its maximum length is 512 for each beacon
-// Three section discontinue memory segments will be used.
-// 1. The original region for BCN 0~3
-// 2. Extract memory from FCE table for BCN 4~5
-// 3. Extract memory from Pair-wise key table for BCN 6~7
-// It occupied those memory of wcid 238~253 for BCN 6
-// and wcid 222~237 for BCN 7
-#define HW_BEACON_MAX_SIZE 0x1000 /* unit: byte */
-#define HW_BEACON_BASE0 0x7800
-#define HW_BEACON_BASE1 0x7A00
-#define HW_BEACON_BASE2 0x7C00
-#define HW_BEACON_BASE3 0x7E00
-#define HW_BEACON_BASE4 0x7200
-#define HW_BEACON_BASE5 0x7400
-#define HW_BEACON_BASE6 0x5DC0
-#define HW_BEACON_BASE7 0x5BC0
-#endif
-
-#define HW_BEACON_MAX_COUNT 8
-#define HW_BEACON_OFFSET 0x0200
-#define HW_BEACON_CONTENT_LEN (HW_BEACON_OFFSET - TXWI_SIZE)
-
-// HOST-MCU shared memory - base address = 0x2100
-#define HOST_CMD_CSR 0x404
-#define H2M_MAILBOX_CSR 0x7010
-#define H2M_MAILBOX_CID 0x7014
-#define H2M_MAILBOX_STATUS 0x701c
-#define H2M_INT_SRC 0x7024
-#define H2M_BBP_AGENT 0x7028
-#define M2H_CMD_DONE_CSR 0x000c
-#define MCU_TXOP_ARRAY_BASE 0x000c // TODO: to be provided by Albert
-#define MCU_TXOP_ENTRY_SIZE 32 // TODO: to be provided by Albert
-#define MAX_NUM_OF_TXOP_ENTRY 16 // TODO: must be same with 8051 firmware
-#define MCU_MBOX_VERSION 0x01 // TODO: to be confirmed by Albert
-#define MCU_MBOX_VERSION_OFFSET 5 // TODO: to be provided by Albert
-
-//
-// Host DMA registers - base address 0x200 . TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT,
-//
-//
-// DMA RING DESCRIPTOR
-//
-#define E2PROM_CSR 0x0004
-#define IO_CNTL_CSR 0x77d0
-
-#ifdef RT2870
-// 8051 firmware image for usb - use last-half base address = 0x3000
-#define FIRMWARE_IMAGE_BASE 0x3000
-#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 // 4kbyte
-#endif // RT2870 //
-
-// TODO: ????? old RT2560 registers. to keep them or remove them?
-//#define MCAST0 0x0178 // multicast filter register 0
-//#define MCAST1 0x017c // multicast filter register 1
-
-
-// ================================================================
-// Tx / Rx / Mgmt ring descriptor definition
-// ================================================================
-
-// the following PID values are used to mark outgoing frame type in TXD->PID so that
-// proper TX statistics can be collected based on these categories
-// b3-2 of PID field -
-#define PID_MGMT 0x05
-#define PID_BEACON 0x0c
-#define PID_DATA_NORMALUCAST 0x02
-#define PID_DATA_AMPDU 0x04
-#define PID_DATA_NO_ACK 0x08
-#define PID_DATA_NOT_NORM_ACK 0x03
-#if 0
-#define PTYPE_DATA_REQUIRE_ACK 0x00 // b7-6:00, b5-0: 0~59 is MAC table index (AID?), 60~63 is WDS index
-#define PTYPE_NULL_AT_HIGH_RATE 0x04 // b7-6:01, b5-0: 0~59 is MAC table index (AID?), 60~63 is WDS index
-#define PTYPE_RESERVED 0x08 // b7-6:10
-#define PTYPE_SPECIAL 0x0c // b7-6:11
-
-// when b3-2=11 (PTYPE_SPECIAL), b1-0 coube be ...
-#define PSUBTYPE_DATA_NO_ACK 0x00
-#define PSUBTYPE_MGMT 0x01
-#define PSUBTYPE_OTHER_CNTL 0x02
-#define PSUBTYPE_RTS 0x03
-#endif
-// value domain of pTxD->HostQId (4-bit: 0~15)
-#define QID_AC_BK 1 // meet ACI definition in 802.11e
-#define QID_AC_BE 0 // meet ACI definition in 802.11e
-#define QID_AC_VI 2
-#define QID_AC_VO 3
-#define QID_HCCA 4
-#define NUM_OF_TX_RING 5
-#define QID_MGMT 13
-#define QID_RX 14
-#define QID_OTHER 15
-
-
-// ------------------------------------------------------
-// BBP & RF definition
-// ------------------------------------------------------
-#define BUSY 1
-#define IDLE 0
-
-#define RF_R00 0
-#define RF_R01 1
-#define RF_R02 2
-#define RF_R03 3
-#define RF_R04 4
-#define RF_R05 5
-#define RF_R06 6
-#define RF_R07 7
-#define RF_R08 8
-#define RF_R09 9
-#define RF_R10 10
-#define RF_R11 11
-#define RF_R12 12
-#define RF_R13 13
-#define RF_R14 14
-#define RF_R15 15
-#define RF_R16 16
-#define RF_R17 17
-#define RF_R18 18
-#define RF_R19 19
-#define RF_R20 20
-#define RF_R21 21
-#define RF_R22 22
-#define RF_R23 23
-#define RF_R24 24
-#define RF_R25 25
-#define RF_R26 26
-#define RF_R27 27
-#define RF_R28 28
-#define RF_R29 29
-#define RF_R30 30
-#define RF_R31 31
-
-#define BBP_R0 0 // version
-#define BBP_R1 1 // TSSI
-#define BBP_R2 2 // TX configure
-#define BBP_R3 3
-#define BBP_R4 4
-#define BBP_R5 5
-#define BBP_R6 6
-#define BBP_R14 14 // RX configure
-#define BBP_R16 16
-#define BBP_R17 17 // RX sensibility
-#define BBP_R18 18
-#define BBP_R21 21
-#define BBP_R22 22
-#define BBP_R24 24
-#define BBP_R25 25
-#define BBP_R49 49 //TSSI
-#define BBP_R50 50
-#define BBP_R51 51
-#define BBP_R52 52
-#define BBP_R55 55
-#define BBP_R62 62 // Rx SQ0 Threshold HIGH
-#define BBP_R63 63
-#define BBP_R64 64
-#define BBP_R65 65
-#define BBP_R66 66
-#define BBP_R67 67
-#define BBP_R68 68
-#define BBP_R69 69
-#define BBP_R70 70 // Rx AGC SQ CCK Xcorr threshold
-#define BBP_R73 73
-#define BBP_R75 75
-#define BBP_R77 77
-#define BBP_R81 81
-#define BBP_R82 82
-#define BBP_R83 83
-#define BBP_R84 84
-#define BBP_R86 86
-#define BBP_R91 91
-#define BBP_R92 92
-#define BBP_R94 94 // Tx Gain Control
-#define BBP_R103 103
-#define BBP_R105 105
-#define BBP_R113 113
-#define BBP_R114 114
-#define BBP_R115 115
-#define BBP_R116 116
-#define BBP_R117 117
-#define BBP_R118 118
-#define BBP_R119 119
-#define BBP_R120 120
-#define BBP_R121 121
-#define BBP_R122 122
-#define BBP_R123 123
-
-
-#define BBPR94_DEFAULT 0x06 // Add 1 value will gain 1db
-
-//#define PHY_TR_SWITCH_TIME 5 // usec
-
-//#define BBP_R17_LOW_SENSIBILITY 0x50
-//#define BBP_R17_MID_SENSIBILITY 0x41
-//#define BBP_R17_DYNAMIC_UP_BOUND 0x40
-#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
-#define RSSI_FOR_LOW_SENSIBILITY -58
-#define RSSI_FOR_MID_LOW_SENSIBILITY -80
-#define RSSI_FOR_MID_SENSIBILITY -90
-
-//-------------------------------------------------------------------------
-// EEPROM definition
-//-------------------------------------------------------------------------
-#define EEDO 0x08
-#define EEDI 0x04
-#define EECS 0x02
-#define EESK 0x01
-#define EERL 0x80
-
-#define EEPROM_WRITE_OPCODE 0x05
-#define EEPROM_READ_OPCODE 0x06
-#define EEPROM_EWDS_OPCODE 0x10
-#define EEPROM_EWEN_OPCODE 0x13
-
-#define NUM_EEPROM_BBP_PARMS 19 // Include NIC Config 0, 1, CR, TX ALC step, BBPs
-#define NUM_EEPROM_TX_G_PARMS 7
-#define EEPROM_NIC1_OFFSET 0x34 // The address is from NIC config 0, not BBP register ID
-#define EEPROM_NIC2_OFFSET 0x36 // The address is from NIC config 0, not BBP register ID
-#define EEPROM_BBP_BASE_OFFSET 0xf0 // The address is from NIC config 0, not BBP register ID
-#define EEPROM_G_TX_PWR_OFFSET 0x52
-#define EEPROM_G_TX2_PWR_OFFSET 0x60
-#define EEPROM_LED1_OFFSET 0x3c
-#define EEPROM_LED2_OFFSET 0x3e
-#define EEPROM_LED3_OFFSET 0x40
-#define EEPROM_LNA_OFFSET 0x44
-#define EEPROM_RSSI_BG_OFFSET 0x46
-#define EEPROM_RSSI_A_OFFSET 0x4a
-#define EEPROM_DEFINE_MAX_TXPWR 0x4e
-#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G 0xde // 20MHZ 2.4G tx power.
-#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G 0xee // 40MHZ 2.4G tx power.
-#define EEPROM_TXPOWER_BYRATE_20MHZ_5G 0xfa // 20MHZ 5G tx power.
-#define EEPROM_TXPOWER_BYRATE_40MHZ_5G 0x10a // 40MHZ 5G tx power.
-#define EEPROM_A_TX_PWR_OFFSET 0x78
-#define EEPROM_A_TX2_PWR_OFFSET 0xa6
-//#define EEPROM_Japan_TX_PWR_OFFSET 0x90 // 802.11j
-//#define EEPROM_Japan_TX2_PWR_OFFSET 0xbe
-//#define EEPROM_TSSI_REF_OFFSET 0x54
-//#define EEPROM_TSSI_DELTA_OFFSET 0x24
-//#define EEPROM_CCK_TX_PWR_OFFSET 0x62
-//#define EEPROM_CALIBRATE_OFFSET 0x7c
-#define EEPROM_VERSION_OFFSET 0x02
-#define EEPROM_FREQ_OFFSET 0x3a
-#define EEPROM_TXPOWER_BYRATE 0xde // 20MHZ power.
-#define EEPROM_TXPOWER_DELTA 0x50 // 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ.
-#define VALID_EEPROM_VERSION 1
-
-// PairKeyMode definition
-#define PKMODE_NONE 0
-#define PKMODE_WEP64 1
-#define PKMODE_WEP128 2
-#define PKMODE_TKIP 3
-#define PKMODE_AES 4
-#define PKMODE_CKIP64 5
-#define PKMODE_CKIP128 6
-#define PKMODE_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
-
-// =================================================================================
-// WCID format
-// =================================================================================
-//7.1 WCID ENTRY format : 8bytes
-typedef struct _WCID_ENTRY_STRUC {
- UCHAR RXBABitmap7; // bit0 for TID8, bit7 for TID 15
- UCHAR RXBABitmap0; // bit0 for TID0, bit7 for TID 7
- UCHAR MAC[6]; // 0 for shared key table. 1 for pairwise key table
-} WCID_ENTRY_STRUC, *PWCID_ENTRY_STRUC;
-
-//8.1.1 SECURITY KEY format : 8DW
-// 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table
-typedef struct _HW_KEY_ENTRY { // 32-byte per entry
- UCHAR Key[16];
- UCHAR TxMic[8];
- UCHAR RxMic[8];
-} HW_KEY_ENTRY, *PHW_KEY_ENTRY;
-
-//8.1.2 IV/EIV format : 2DW
-
-//8.1.3 RX attribute entry format : 1DW
-#ifdef RT_BIG_ENDIAN
-typedef struct _MAC_ATTRIBUTE_STRUC {
- UINT32 rsv:22;
- UINT32 RXWIUDF:3;
- UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
- UINT32 PairKeyMode:3;
- UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
-} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-#else
-typedef struct _MAC_ATTRIBUTE_STRUC {
- UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
- UINT32 PairKeyMode:3;
- UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
- UINT32 RXWIUDF:3;
- UINT32 rsv:22;
-} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-#endif
-
-
-// =================================================================================
-// TX / RX ring descriptor format
-// =================================================================================
-
-// the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO.
-// MAC block use this TXINFO to control the transmission behavior of this frame.
-#define FIFO_MGMT 0
-#define FIFO_HCCA 1
-#define FIFO_EDCA 2
-
-//
-// TX descriptor format, Tx ring, Mgmt Ring
-//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _TXD_STRUC {
- // Word 0
- UINT32 SDPtr0;
- // Word 1
- UINT32 DMADONE:1;
- UINT32 LastSec0:1;
- UINT32 SDLen0:14;
- UINT32 Burst:1;
- UINT32 LastSec1:1;
- UINT32 SDLen1:14;
- // Word 2
- UINT32 SDPtr1;
- // Word 3
- UINT32 ICO:1;
- UINT32 UCO:1;
- UINT32 TCO:1;
- UINT32 rsv:2;
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 rsv2:24;
-} TXD_STRUC, *PTXD_STRUC;
-#else
-typedef struct PACKED _TXD_STRUC {
- // Word 0
- UINT32 SDPtr0;
- // Word 1
- UINT32 SDLen1:14;
- UINT32 LastSec1:1;
- UINT32 Burst:1;
- UINT32 SDLen0:14;
- UINT32 LastSec0:1;
- UINT32 DMADONE:1;
- //Word2
- UINT32 SDPtr1;
- //Word3
- UINT32 rsv2:24;
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 rsv:2;
- UINT32 TCO:1; //
- UINT32 UCO:1; //
- UINT32 ICO:1; //
-} TXD_STRUC, *PTXD_STRUC;
-#endif
-
-
-//
-// TXD Wireless Information format for Tx ring and Mgmt Ring
-//
-//txop : for txop mode
-// 0:txop for the MPDU frame will be handles by ASIC by register
-// 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _TXWI_STRUC {
- // Word 0
- UINT32 PHYMODE:2;
- UINT32 TxBF:1; // 3*3
- UINT32 rsv2:1;
-// UINT32 rsv2:2;
- UINT32 Ifs:1; //
- UINT32 STBC:2; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 MCS:7;
-
- UINT32 rsv:6;
- UINT32 txop:2; //tx back off mode 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
- UINT32 MpduDensity:3;
- UINT32 AMPDU:1;
-
- UINT32 TS:1;
- UINT32 CFACK:1;
- UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
- UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
- // Word 1
- UINT32 PacketId:4;
- UINT32 MPDUtotalByteCount:12;
- UINT32 WirelessCliID:8;
- UINT32 BAWinSize:6;
- UINT32 NSEQ:1;
- UINT32 ACK:1;
- // Word 2
- UINT32 IV;
- // Word 3
- UINT32 EIV;
-} TXWI_STRUC, *PTXWI_STRUC;
-#else
-typedef struct PACKED _TXWI_STRUC {
- // Word 0
- UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
- UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
- UINT32 CFACK:1;
- UINT32 TS:1;
-
- UINT32 AMPDU:1;
- UINT32 MpduDensity:3;
- UINT32 txop:2; //FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
- UINT32 rsv:6;
-
- UINT32 MCS:7;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 STBC:2; // 1: STBC support MCS =0-7, 2,3 : RESERVE
- UINT32 Ifs:1; //
-// UINT32 rsv2:2; //channel bandwidth 20MHz or 40 MHz
- UINT32 rsv2:1;
- UINT32 TxBF:1; // 3*3
- UINT32 PHYMODE:2;
- // Word 1
- UINT32 ACK:1;
- UINT32 NSEQ:1;
- UINT32 BAWinSize:6;
- UINT32 WirelessCliID:8;
- UINT32 MPDUtotalByteCount:12;
- UINT32 PacketId:4;
- //Word2
- UINT32 IV;
- //Word3
- UINT32 EIV;
-} TXWI_STRUC, *PTXWI_STRUC;
-#endif
-//
-// Rx descriptor format, Rx Ring
-//
-//
-// RXWI wireless information format, in PBF. invisible in driver.
-//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _RXWI_STRUC {
- // Word 0
- UINT32 TID:4;
- UINT32 MPDUtotalByteCount:12;
- UINT32 UDF:3;
- UINT32 BSSID:3;
- UINT32 KeyIndex:2;
- UINT32 WirelessCliID:8;
- // Word 1
- UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
- UINT32 rsv:3;
- UINT32 STBC:2;
- UINT32 ShortGI:1;
- UINT32 BW:1;
- UINT32 MCS:7;
- UINT32 SEQUENCE:12;
- UINT32 FRAG:4;
- // Word 2
- UINT32 rsv1:8;
- UINT32 RSSI2:8;
- UINT32 RSSI1:8;
- UINT32 RSSI0:8;
- // Word 3
- UINT32 rsv2:16;
- UINT32 SNR1:8;
- UINT32 SNR0:8;
-} RXWI_STRUC, *PRXWI_STRUC;
-#else
-typedef struct PACKED _RXWI_STRUC {
- // Word 0
- UINT32 WirelessCliID:8;
- UINT32 KeyIndex:2;
- UINT32 BSSID:3;
- UINT32 UDF:3;
- UINT32 MPDUtotalByteCount:12;
- UINT32 TID:4;
- // Word 1
- UINT32 FRAG:4;
- UINT32 SEQUENCE:12;
- UINT32 MCS:7;
- UINT32 BW:1;
- UINT32 ShortGI:1;
- UINT32 STBC:2;
- UINT32 rsv:3;
- UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
- //Word2
- UINT32 RSSI0:8;
- UINT32 RSSI1:8;
- UINT32 RSSI2:8;
- UINT32 rsv1:8;
- //Word3
- UINT32 SNR0:8;
- UINT32 SNR1:8;
- UINT32 rsv2:16;
-} RXWI_STRUC, *PRXWI_STRUC;
-#endif
-
-
-// =================================================================================
-// HOST-MCU communication data structure
-// =================================================================================
-
-//
-// H2M_MAILBOX_CSR: Host-to-MCU Mailbox
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _H2M_MAILBOX_STRUC {
- struct {
- UINT32 Owner:8;
- UINT32 CmdToken:8; // 0xff tells MCU not to report CmdDoneInt after excuting the command
- UINT32 HighByte:8;
- UINT32 LowByte:8;
- } field;
- UINT32 word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-#else
-typedef union _H2M_MAILBOX_STRUC {
- struct {
- UINT32 LowByte:8;
- UINT32 HighByte:8;
- UINT32 CmdToken:8;
- UINT32 Owner:8;
- } field;
- UINT32 word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-#endif
-
-//
-// M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _M2H_CMD_DONE_STRUC {
- struct {
- UINT32 CmdToken3;
- UINT32 CmdToken2;
- UINT32 CmdToken1;
- UINT32 CmdToken0;
- } field;
- UINT32 word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-#else
-typedef union _M2H_CMD_DONE_STRUC {
- struct {
- UINT32 CmdToken0;
- UINT32 CmdToken1;
- UINT32 CmdToken2;
- UINT32 CmdToken3;
- } field;
- UINT32 word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-#endif
-
-
-
-//
-// MCU_LEDCS: MCU LED Control Setting.
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MCU_LEDCS_STRUC {
- struct {
- UCHAR Polarity:1;
- UCHAR LedMode:7;
- } field;
- UCHAR word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-#else
-typedef union _MCU_LEDCS_STRUC {
- struct {
- UCHAR LedMode:7;
- UCHAR Polarity:1;
- } field;
- UCHAR word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-#endif
-// =================================================================================
-// Register format
-// =================================================================================
-
-
-
-//NAV_TIME_CFG :NAV
-#ifdef RT_BIG_ENDIAN
-typedef union _NAV_TIME_CFG_STRUC {
- struct {
- USHORT rsv:6;
- USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
- USHORT Eifs:9; // in unit of 1-us
- UCHAR SlotTime; // in unit of 1-us
- UCHAR Sifs; // in unit of 1-us
- } field;
- UINT32 word;
-} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-#else
-typedef union _NAV_TIME_CFG_STRUC {
- struct {
- UCHAR Sifs; // in unit of 1-us
- UCHAR SlotTime; // in unit of 1-us
- USHORT Eifs:9; // in unit of 1-us
- USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
- USHORT rsv:6;
- } field;
- UINT32 word;
-} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-#endif
-
-
-
-
-
-//
-// RX_FILTR_CFG: /RX configuration register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union RX_FILTR_CFG_STRUC {
- struct {
- UINT32 :15;
- UINT32 DropRsvCntlType:1;
-
- UINT32 DropBAR:1; //
- UINT32 DropBA:1; //
- UINT32 DropPsPoll:1; // Drop Ps-Poll
- UINT32 DropRts:1; // Drop Ps-Poll
-
- UINT32 DropCts:1; // Drop Ps-Poll
- UINT32 DropAck:1; // Drop Ps-Poll
- UINT32 DropCFEnd:1; // Drop Ps-Poll
- UINT32 DropCFEndAck:1; // Drop Ps-Poll
-
- UINT32 DropDuplicate:1; // Drop duplicate frame
- UINT32 DropBcast:1; // Drop broadcast frames
- UINT32 DropMcast:1; // Drop multicast frames
- UINT32 DropVerErr:1; // Drop version error frame
-
- UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
- UINT32 DropNotToMe:1; // Drop not to me unicast frame
- UINT32 DropPhyErr:1; // Drop physical error
- UINT32 DropCRCErr:1; // Drop CRC error
- } field;
- UINT32 word;
-} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-#else
-typedef union _RX_FILTR_CFG_STRUC {
- struct {
- UINT32 DropCRCErr:1; // Drop CRC error
- UINT32 DropPhyErr:1; // Drop physical error
- UINT32 DropNotToMe:1; // Drop not to me unicast frame
- UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
-
- UINT32 DropVerErr:1; // Drop version error frame
- UINT32 DropMcast:1; // Drop multicast frames
- UINT32 DropBcast:1; // Drop broadcast frames
- UINT32 DropDuplicate:1; // Drop duplicate frame
-
- UINT32 DropCFEndAck:1; // Drop Ps-Poll
- UINT32 DropCFEnd:1; // Drop Ps-Poll
- UINT32 DropAck:1; // Drop Ps-Poll
- UINT32 DropCts:1; // Drop Ps-Poll
-
- UINT32 DropRts:1; // Drop Ps-Poll
- UINT32 DropPsPoll:1; // Drop Ps-Poll
- UINT32 DropBA:1; //
- UINT32 DropBAR:1; //
-
- UINT32 DropRsvCntlType:1;
- UINT32 :15;
- } field;
- UINT32 word;
-} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-#endif
-
-
-
-
-//
-// PHY_CSR4: RF serial control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _PHY_CSR4_STRUC {
- struct {
- UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
- UINT32 PLL_LD:1; // RF PLL_LD status
- UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
- UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
- UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
- } field;
- UINT32 word;
-} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-#else
-typedef union _PHY_CSR4_STRUC {
- struct {
- UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
- UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
- UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
- UINT32 PLL_LD:1; // RF PLL_LD status
- UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
- } field;
- UINT32 word;
-} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-#endif
-
-
-//
-// SEC_CSR5: shared key table security mode register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _SEC_CSR5_STRUC {
- struct {
- UINT32 :1;
- UINT32 Bss3Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key0CipherAlg:3;
- } field;
- UINT32 word;
-} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-#else
-typedef union _SEC_CSR5_STRUC {
- struct {
- UINT32 Bss2Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key3CipherAlg:3;
- UINT32 :1;
- } field;
- UINT32 word;
-} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-#endif
-
-
-//
-// HOST_CMD_CSR: For HOST to interrupt embedded processor
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _HOST_CMD_CSR_STRUC {
- struct {
- UINT32 Rsv:24;
- UINT32 HostCommand:8;
- } field;
- UINT32 word;
-} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-#else
-typedef union _HOST_CMD_CSR_STRUC {
- struct {
- UINT32 HostCommand:8;
- UINT32 Rsv:24;
- } field;
- UINT32 word;
-} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-#endif
-
-
-//
-// AIFSN_CSR: AIFSN for each EDCA AC
-//
-
-
-
-//
-// E2PROM_CSR: EEPROM control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _E2PROM_CSR_STRUC {
- struct {
- UINT32 Rsvd:25;
- UINT32 LoadStatus:1; // 1:loading, 0:done
- UINT32 Type:1; // 1: 93C46, 0:93C66
- UINT32 EepromDO:1;
- UINT32 EepromDI:1;
- UINT32 EepromCS:1;
- UINT32 EepromSK:1;
- UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
- } field;
- UINT32 word;
-} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-#else
-typedef union _E2PROM_CSR_STRUC {
- struct {
- UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
- UINT32 EepromSK:1;
- UINT32 EepromCS:1;
- UINT32 EepromDI:1;
- UINT32 EepromDO:1;
- UINT32 Type:1; // 1: 93C46, 0:93C66
- UINT32 LoadStatus:1; // 1:loading, 0:done
- UINT32 Rsvd:25;
- } field;
- UINT32 word;
-} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-#endif
-
-
-// -------------------------------------------------------------------
-// E2PROM data layout
-// -------------------------------------------------------------------
-
-//
-// EEPROM antenna select format
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_ANTENNA_STRUC {
- struct {
- USHORT Rsv:4;
- USHORT RfIcType:4; // see E2PROM document
- USHORT TxPath:4; // 1: 1T, 2: 2T
- USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
- } field;
- USHORT word;
-} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-#else
-typedef union _EEPROM_ANTENNA_STRUC {
- struct {
- USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
- USHORT TxPath:4; // 1: 1T, 2: 2T
- USHORT RfIcType:4; // see E2PROM document
- USHORT Rsv:4;
- } field;
- USHORT word;
-} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_NIC_CINFIG2_STRUC {
- struct {
- USHORT Rsv2:6; // must be 0
- USHORT BW40MAvailForA:1; // 0:enable, 1:disable
- USHORT BW40MAvailForG:1; // 0:enable, 1:disable
- USHORT EnableWPSPBC:1; // WPS PBC Control bit
- USHORT BW40MSidebandForA:1;
- USHORT BW40MSidebandForG:1;
- USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
- USHORT ExternalLNAForA:1; // external LNA enable for 5G
- USHORT ExternalLNAForG:1; // external LNA enable for 2.4G
- USHORT DynamicTxAgcControl:1; //
- USHORT HardwareRadioControl:1; // Whether RF is controlled by driver or HW. 1:enable hw control, 0:disable
- } field;
- USHORT word;
-} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-#else
-typedef union _EEPROM_NIC_CINFIG2_STRUC {
- struct {
- USHORT HardwareRadioControl:1; // 1:enable, 0:disable
- USHORT DynamicTxAgcControl:1; //
- USHORT ExternalLNAForG:1; //
- USHORT ExternalLNAForA:1; // external LNA enable for 2.4G
- USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
- USHORT BW40MSidebandForG:1;
- USHORT BW40MSidebandForA:1;
- USHORT EnableWPSPBC:1; // WPS PBC Control bit
- USHORT BW40MAvailForG:1; // 0:enable, 1:disable
- USHORT BW40MAvailForA:1; // 0:enable, 1:disable
- USHORT Rsv2:6; // must be 0
- } field;
- USHORT word;
-} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-#endif
-
-//
-// TX_PWR Value valid range 0xFA(-6) ~ 0x24(36)
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_TX_PWR_STRUC {
- struct {
- CHAR Byte1; // High Byte
- CHAR Byte0; // Low Byte
- } field;
- USHORT word;
-} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-#else
-typedef union _EEPROM_TX_PWR_STRUC {
- struct {
- CHAR Byte0; // Low Byte
- CHAR Byte1; // High Byte
- } field;
- USHORT word;
-} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_VERSION_STRUC {
- struct {
- UCHAR Version; // High Byte
- UCHAR FaeReleaseNumber; // Low Byte
- } field;
- USHORT word;
-} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-#else
-typedef union _EEPROM_VERSION_STRUC {
- struct {
- UCHAR FaeReleaseNumber; // Low Byte
- UCHAR Version; // High Byte
- } field;
- USHORT word;
-} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_LED_STRUC {
- struct {
- USHORT Rsvd:3; // Reserved
- USHORT LedMode:5; // Led mode.
- USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
- USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
- USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
- USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
- USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
- USHORT PolarityACT:1; // Polarity ACT setting.
- USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
- USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
- } field;
- USHORT word;
-} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-#else
-typedef union _EEPROM_LED_STRUC {
- struct {
- USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
- USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
- USHORT PolarityACT:1; // Polarity ACT setting.
- USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
- USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
- USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
- USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
- USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
- USHORT LedMode:5; // Led mode.
- USHORT Rsvd:3; // Reserved
- } field;
- USHORT word;
-} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_TXPOWER_DELTA_STRUC {
- struct {
- UCHAR TxPowerEnable:1;// Enable
- UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
- UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
- } field;
- UCHAR value;
-} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-#else
-typedef union _EEPROM_TXPOWER_DELTA_STRUC {
- struct {
- UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
- UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
- UCHAR TxPowerEnable:1;// Enable
- } field;
- UCHAR value;
-} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-#endif
-
-//
-// QOS_CSR0: TXOP holder address0 register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _QOS_CSR0_STRUC {
- struct {
- UCHAR Byte3; // MAC address byte 3
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte0; // MAC address byte 0
- } field;
- UINT32 word;
-} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-#else
-typedef union _QOS_CSR0_STRUC {
- struct {
- UCHAR Byte0; // MAC address byte 0
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte3; // MAC address byte 3
- } field;
- UINT32 word;
-} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-#endif
-
-//
-// QOS_CSR1: TXOP holder address1 register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _QOS_CSR1_STRUC {
- struct {
- UCHAR Rsvd1;
- UCHAR Rsvd0;
- UCHAR Byte5; // MAC address byte 5
- UCHAR Byte4; // MAC address byte 4
- } field;
- UINT32 word;
-} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-#else
-typedef union _QOS_CSR1_STRUC {
- struct {
- UCHAR Byte4; // MAC address byte 4
- UCHAR Byte5; // MAC address byte 5
- UCHAR Rsvd0;
- UCHAR Rsvd1;
- } field;
- UINT32 word;
-} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-#endif
-
-#define RF_CSR_CFG 0x500
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG_STRUC {
- struct {
- UINT Rsvd1:14; // Reserved
- UINT RF_CSR_KICK:1; // kick RF register read/write
- UINT RF_CSR_WR:1; // 0: read 1: write
- UINT Rsvd2:3; // Reserved
- UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
- UINT RF_CSR_DATA:8; // DATA
- } field;
- UINT word;
-} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-#else
-typedef union _RF_CSR_CFG_STRUC {
- struct {
- UINT RF_CSR_DATA:8; // DATA
- UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
- UINT Rsvd2:3; // Reserved
- UINT RF_CSR_WR:1; // 0: read 1: write
- UINT RF_CSR_KICK:1; // kick RF register read/write
- UINT Rsvd1:14; // Reserved
- } field;
- UINT word;
-} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-#endif
-
-#endif // __RT28XX_H__
+#include "../rt2860/rt28xx.h"
diff --git a/drivers/staging/rt2870/rt_ate.c b/drivers/staging/rt2870/rt_ate.c
deleted file mode 100644
index 27c763ee9276..000000000000
--- a/drivers/staging/rt2870/rt_ate.c
+++ /dev/null
@@ -1,6452 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-#ifdef UCOS
-INT IoctlResponse(PUCHAR payload, PUCHAR msg, INT len);
-#endif // UCOS //
-
-#ifdef RALINK_ATE
-UCHAR TemplateFrame[24] = {0x08/* Data type */,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
-extern RTMP_RF_REGS RF2850RegTable[];
-extern UCHAR NUM_OF_2850_CHNL;
-
-#ifdef RT2870
-extern UCHAR EpToQueue[];
-extern VOID RTUSBRejectPendingPackets( IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-#ifdef UCOS
-extern INT ConsoleResponse(IN PUCHAR buff);
-extern int (*remote_display)(char *);
-#endif // UCOS //
-
-static CHAR CCKRateTable[] = {0, 1, 2, 3, 8, 9, 10, 11, -1}; /* CCK Mode. */
-static CHAR OFDMRateTable[] = {0, 1, 2, 3, 4, 5, 6, 7, -1}; /* OFDM Mode. */
-static CHAR HTMIXRateTable[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}; /* HT Mix Mode. */
-
-static INT TxDmaBusy(
- IN PRTMP_ADAPTER pAd);
-
-static INT RxDmaBusy(
- IN PRTMP_ADAPTER pAd);
-
-static VOID RtmpDmaEnable(
- IN PRTMP_ADAPTER pAd,
- IN INT Enable);
-
-static VOID BbpSoftReset(
- IN PRTMP_ADAPTER pAd);
-
-static VOID RtmpRfIoWrite(
- IN PRTMP_ADAPTER pAd);
-
-static INT ATESetUpFrame(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TxIdx);
-
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index);
-
-static INT ATECmdHandler(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-static int CheckMCSValid(
- IN UCHAR Mode,
- IN UCHAR Mcs);
-
-
-#ifdef RT2870
-static VOID ATEWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst);
-
-static VOID ATEWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR MIMOps,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING Transmit);
-
-#endif // RT2870 //
-
-static VOID SetJapanFilter(
- IN PRTMP_ADAPTER pAd);
-
-/*=========================end of prototype=========================*/
-
-
-#ifdef RT2870
-static INT TxDmaBusy(
- IN PRTMP_ADAPTER pAd)
-{
- INT result;
- USB_DMA_CFG_STRUC UsbCfg;
-
- RTMP_IO_READ32(pAd, USB_DMA_CFG, &UsbCfg.word); // disable DMA
- if (UsbCfg.field.TxBusy)
- result = 1;
- else
- result = 0;
-
- return result;
-}
-
-static INT RxDmaBusy(
- IN PRTMP_ADAPTER pAd)
-{
- INT result;
- USB_DMA_CFG_STRUC UsbCfg;
-
- RTMP_IO_READ32(pAd, USB_DMA_CFG, &UsbCfg.word); // disable DMA
- if (UsbCfg.field.RxBusy)
- result = 1;
- else
- result = 0;
-
- return result;
-}
-
-static VOID RtmpDmaEnable(
- IN PRTMP_ADAPTER pAd,
- IN INT Enable)
-{
- BOOLEAN value;
- ULONG WaitCnt;
- USB_DMA_CFG_STRUC UsbCfg;
-
- value = Enable > 0 ? 1 : 0;
-
- // check DMA is in busy mode.
- WaitCnt = 0;
- while (TxDmaBusy(pAd) || RxDmaBusy(pAd))
- {
- RTMPusecDelay(10);
- if (WaitCnt++ > 100)
- break;
- }
-
- //Why not to clear USB DMA TX path first ???
- RTMP_IO_READ32(pAd, USB_DMA_CFG, &UsbCfg.word); // disable DMA
- UsbCfg.field.TxBulkEn = value;
- UsbCfg.field.RxBulkEn = value;
- RTMP_IO_WRITE32(pAd, USB_DMA_CFG, UsbCfg.word); // abort all TX rings
- RTMPusecDelay(5000);
-
- return;
-}
-#endif // RT2870 //
-
-static VOID BbpSoftReset(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BbpData = 0;
-
- // Soft reset, set BBP R21 bit0=1->0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R21, &BbpData);
- BbpData |= 0x00000001; //set bit0=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R21, BbpData);
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R21, &BbpData);
- BbpData &= ~(0x00000001); //set bit0=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R21, BbpData);
-
- return;
-}
-
-static VOID RtmpRfIoWrite(
- IN PRTMP_ADAPTER pAd)
-{
- // Set RF value 1's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 2's set R3[bit2] = [1]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 | 0x04));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 3's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- return;
-}
-
-static int CheckMCSValid(
- UCHAR Mode,
- UCHAR Mcs)
-{
- int i;
- PCHAR pRateTab;
-
- switch(Mode)
- {
- case 0:
- pRateTab = CCKRateTable;
- break;
- case 1:
- pRateTab = OFDMRateTable;
- break;
- case 2:
- case 3:
- pRateTab = HTMIXRateTable;
- break;
- default:
- ATEDBGPRINT(RT_DEBUG_ERROR, ("unrecognizable Tx Mode %d\n", Mode));
- return -1;
- break;
- }
-
- i = 0;
- while(pRateTab[i] != -1)
- {
- if (pRateTab[i] == Mcs)
- return 0;
- i++;
- }
-
- return -1;
-}
-
-#if 1
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index)
-{
- ULONG R;
- CHAR TxPower;
- UCHAR Bbp94 = 0;
- BOOLEAN bPowerReduce = FALSE;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
- ** are not synchronized.
- */
-/*
- pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
- pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
-*/
- return 0;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- TxPower = index == 0 ? pAd->ate.TxPower0 : pAd->ate.TxPower1;
-
- if (pAd->ate.Channel <= 14)
- {
- if (TxPower > 31)
- {
- //
- // R3, R4 can't large than 31 (0x24), 31 ~ 36 used by BBP 94
- //
- R = 31;
- if (TxPower <= 36)
- Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
- //
- R = 0;
- if (TxPower >= -6)
- Bbp94 = BBPR94_DEFAULT + TxPower;
- }
- else
- {
- // 0 ~ 31
- R = (ULONG) TxPower;
- Bbp94 = BBPR94_DEFAULT;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
- }
- else// 5.5 GHz
- {
- if (TxPower > 15)
- {
- //
- // R3, R4 can't large than 15 (0x0F)
- //
- R = 15;
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0
- //
- // -1 ~ -7
- ASSERT((TxPower >= -7));
- R = (ULONG)(TxPower + 7);
- bPowerReduce = TRUE;
- }
- else
- {
- // 0 ~ 15
- R = (ULONG) TxPower;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __func__, TxPower, R));
- }
-
- if (pAd->ate.Channel <= 14)
- {
- if (index == 0)
- {
- R = R << 9; // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = R << 6; // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else// 5.5GHz
- {
- if (bPowerReduce == FALSE)
- {
- if (index == 0)
- {
- R = (R << 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = (R << 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else
- {
- if (index == 0)
- {
- R = (R << 10); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
-
- /* Clear bit 9 of R3 to reduce 7dB. */
- pAd->LatchRfRegs.R3 = (R & (~(1 << 9)));
- }
- else
- {
- R = (R << 7); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
-
- /* Clear bit 6 of R4 to reduce 7dB. */
- pAd->LatchRfRegs.R4 = (R & (~(1 << 6)));
- }
- }
- }
-
- RtmpRfIoWrite(pAd);
-
- return 0;
- }
-}
-#else// 1 //
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index)
-{
- ULONG R;
- CHAR TxPower;
- UCHAR Bbp94 = 0;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- // TODO: how to get current TxPower0/1 from pAd->LatchRfRegs ?
- /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
- ** are not synchronized.
- */
-/*
- pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
- pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
-*/
- return 0;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- TxPower = index == 0 ? pAd->ate.TxPower0 : pAd->ate.TxPower1;
-
- if (TxPower > 31)
- {
- //
- // R3, R4 can't large than 36 (0x24), 31 ~ 36 used by BBP 94
- //
- R = 31;
- if (TxPower <= 36)
- Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
- //
- R = 0;
- if (TxPower >= -6)
- Bbp94 = BBPR94_DEFAULT + TxPower;
- }
- else
- {
- // 0 ~ 31
- R = (ULONG) TxPower;
- Bbp94 = BBPR94_DEFAULT;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
-
- if (pAd->ate.Channel <= 14)
- {
- if (index == 0)
- {
- R = R << 9; // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = R << 6; // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else
- {
- if (index == 0)
- {
- R = (R << 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = (R << 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
-
- RtmpRfIoWrite(pAd);
-
- return 0;
- }
-}
-#endif // 1 //
-/*
- ==========================================================================
- Description:
- Set ATE operation mode to
- 0. ATESTART = Start ATE Mode
- 1. ATESTOP = Stop ATE Mode
- 2. TXCONT = Continuous Transmit
- 3. TXCARR = Transmit Carrier
- 4. TXFRAME = Transmit Frames
- 5. RXFRAME = Receive Frames
-#ifdef RALINK_28xx_QA
- 6. TXSTOP = Stop Any Type of Transmition
- 7. RXSTOP = Stop Receiving Frames
-#endif // RALINK_28xx_QA //
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-/* */
-/* */
-/*=======================End of RT2860=======================*/
-
-
-/*======================Start of RT2870======================*/
-/* */
-/* */
-
-#ifdef RT2870
-static INT ATECmdHandler(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 Value;
- UCHAR BbpData;
- UINT32 MacData;
- UINT i=0, atemode;
- //NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- //PUCHAR pDest;
- UINT32 temp;
- ULONG IrqFlags;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> ATECmdHandler()\n"));
- ATEAsicSwitchChannel(pAd);
- /* AsicLockChannel() is empty function so far in fact */
- AsicLockChannel(pAd, pAd->ate.Channel);
-
- RTMPusecDelay(5000);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- /* Enter ATE mode and set Tx/Rx Idle */
- if (!strcmp(arg, "ATESTART"))
- {
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN Cancelled;
-#endif // CONFIG_STA_SUPPORT //
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: ATESTART\n"));
-
- netif_stop_queue(pAd->net_dev);
-
- atemode = pAd->ate.Mode;
- pAd->ate.Mode = ATE_START;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable auto responder
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &temp);
- temp = temp & 0xFFFFFFFE;
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, temp);
-
- // read MAC_SYS_CTRL and backup MAC_SYS_CTRL value.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- // clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
- // Stop continuous TX production test.
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);//disable or cancel pending irp first ???
-
- if (atemode & ATE_TXCARR)
- {
- // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // No Carrier Suppression set BBP R24 bit0=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
- BbpData &= 0xFFFFFFFE; //clear bit0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
- }
- // We should free some resource which allocate when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
- // TODO:Should we free some resource which was allocated when LoopBack and ATE_STOP ?
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
- if (atemode & ATE_TXCONT)
- {
- // Not Cont. TX anymore, so set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- // Abort Tx, Rx DMA.
- RtmpDmaEnable(pAd, 0);
-
- {
- // It seems nothing to free,
- // because we didn't allocate any resource when we entered ATE_TXFRAME mode latestly.
- }
-
- // Start Tx, RX DMA
- RtmpDmaEnable(pAd, 1);
- }
-
- RTUSBRejectPendingPackets(pAd);
- RTUSBCleanUpDataBulkOutQueue(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- //
- // It will be called in MlmeSuspend().
- //
- // Cancel pending timers
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-#endif // CONFIG_STA_SUPPORT //
-
- //RTUSBCleanUpMLMEWaitQueue(pAd); /* not used in RT28xx */
- RTUSBCleanUpMLMEBulkOutQueue(pAd);
-
- // Sometimes kernel will hang on, so we avoid calling MlmeSuspend().
-// MlmeSuspend(pAd, TRUE);
- //RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Make sure there are no pending bulk in/out IRPs before we go on.
-/*=========================================================================*/
- /* pAd->PendingRx is not of type atomic_t anymore in 28xx */
-// while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- while ((pAd->PendingRx > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
- NdisInterlockedDecrement(&pAd->PendingRx);
-#endif
- /* delay 0.5 seconds */
- RTMPusecDelay(500000);
- pAd->PendingRx = 0;
- }
- /* peter : why don't we have to get BulkOutLock first ? */
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- /* pAd->BulkOutPending[y] will be set to FALSE in RTUSBCancelPendingBulkOutIRP(pAd) */
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- /* we have enough time delay in RTUSBCancelPendingBulkOutIRP(pAd)
- ** so this is not necessary
- */
-// RTMPusecDelay(500000);
- }
-
- /* pAd->PendingRx is not of type atomic_t anymore in 28xx */
-// ASSERT(atomic_read(&pAd->PendingRx) == 0);
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
-
- // reset Rx statistics.
- pAd->ate.LastSNR0 = 0;
- pAd->ate.LastSNR1 = 0;
- pAd->ate.LastRssi0 = 0;
- pAd->ate.LastRssi1 = 0;
- pAd->ate.LastRssi2 = 0;
- pAd->ate.AvgRssi0 = 0;
- pAd->ate.AvgRssi1 = 0;
- pAd->ate.AvgRssi2 = 0;
- pAd->ate.AvgRssi0X8 = 0;
- pAd->ate.AvgRssi1X8 = 0;
- pAd->ate.AvgRssi2X8 = 0;
- pAd->ate.NumOfAvgRssiSample = 0;
-
-#ifdef RALINK_28xx_QA
- // Tx frame
- pAd->ate.bQATxStart = FALSE;
- pAd->ate.bQARxStart = FALSE;
- pAd->ate.seq = 0;
-
- // counters
- pAd->ate.U2M = 0;
- pAd->ate.OtherData = 0;
- pAd->ate.Beacon = 0;
- pAd->ate.OtherCount = 0;
- pAd->ate.TxAc0 = 0;
- pAd->ate.TxAc1 = 0;
- pAd->ate.TxAc2 = 0;
- pAd->ate.TxAc3 = 0;
- pAd->ate.TxHCCA = 0;
- pAd->ate.TxMgmt = 0;
- pAd->ate.RSSI0 = 0;
- pAd->ate.RSSI1 = 0;
- pAd->ate.RSSI2 = 0;
- pAd->ate.SNR0 = 0;
- pAd->ate.SNR1 = 0;
-
- // control
- pAd->ate.TxDoneCount = 0;
- pAd->ate.TxStatus = 0; // task Tx status // 0 --> task is idle, 1 --> task is running
-#endif // RALINK_28xx_QA //
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
-
-#ifdef CONFIG_STA_SUPPORT
- AsicDisableSync(pAd);
-
- /*
- ** If we skip "LinkDown()", we should disable protection
- ** to prevent from sending out RTS or CTS-to-self.
- */
- ATEDisableAsicProtect(pAd);
- RTMPStationStop(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
-
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
- //Clean ATE Bulk in/out counter and continue setup
- InterlockedExchange(&pAd->BulkOutRemained, 0);
-
- /* NdisAcquireSpinLock()/NdisReleaseSpinLock() need only one argument in RT28xx */
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = FALSE;
- pAd->ContinBulkIn = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
- }
- else if (!strcmp(arg, "ATESTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE : ATESTOP ===>\n"));
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);//0820
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData); // recover the MAC_SYS_CTRL register back.
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- /*
- ** Abort Tx, RX DMA.
- ** Q : How to do the following I/O if Tx, Rx DMA is aborted ?
- ** Ans : Bulk endpoints are aborted, while the control endpoint is not.
- */
- RtmpDmaEnable(pAd, 0);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- /* Make sure there are no pending bulk in/out IRPs before we go on. */
-/*=========================================================================*/
-// while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- while (pAd->PendingRx > 0)
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
-// NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-#endif
- RTMPusecDelay(500000);
- }
-
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- RTMPusecDelay(500000);
- }
-
-// ASSERT(atomic_read(&pAd->PendingRx) == 0);
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
-/* Reset Rx RING */
-/*=========================================================================*/
-// InterlockedExchange(&pAd->PendingRx, 0);
- pAd->PendingRx = 0;
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = RX_RING_SIZE - 1; // Rx Bulk pointer
- pAd->NextRxBulkInPosition = 0;
- for (i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
- NdisZeroMemory(pRxContext->TransferBuffer, MAX_RXBULK_SIZE);
- /* peter : why don't we have to get BulkInLock first ? */
- pRxContext->pAd = pAd;
- pRxContext->pIrp = NULL;
- /* peter debug ++ */
- pRxContext->BulkInOffset = 0;
- pRxContext->bRxHandling = FALSE;
- /* peter debug -- */
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
-// pRxContext->ReorderInUse = FALSE;
-// pRxContext->ReadPosOffset = 0;
- }
-
-/*=========================================================================*/
-/* Reset Tx RING */
-/*=========================================================================*/
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
-/*=========================================================================*/
- // Enable auto responder.
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &temp);
- temp = temp | (0x01);
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, temp);
-
-/*================================================*/
- AsicEnableBssSync(pAd);
-
- /* Soft reset BBP.*/
- /* In 2870 chipset, ATE_BBP_IO_READ8_BY_REG_ID() == RTMP_BBP_IO_READ8_BY_REG_ID() */
- /* Both rt2870ap and rt2870sta use BbpSoftReset(pAd) to do BBP soft reset */
- BbpSoftReset(pAd);
-/*================================================*/
- {
-#ifdef CONFIG_STA_SUPPORT
- // Set all state machines back IDLE
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
-#endif // CONFIG_STA_SUPPORT //
-
- //
- // ===> refer to MlmeRestartStateMachine().
- // When we entered ATE_START mode, PeriodicTimer was not cancelled.
- // So we don't have to set it here.
- //
- //RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
-
- ASSERT(pAd->CommonCfg.Channel != 0);
-
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
-
-#ifdef CONFIG_STA_SUPPORT
- RTMPStationStart(pAd);
-#endif // CONFIG_STA_SUPPORT //
- }
-//
-// These two steps have been done when entering ATE_STOP mode.
-//
-#if 0
- RTUSBWriteBBPRegister(pAd, BBP_R22, BbpData);
- RTUSBWriteMACRegister(pAd, MAC_SYS_CTRL, MacData);
-#endif
- // Clean ATE Bulk in/out counter and continue setup.
- InterlockedExchange(&pAd->BulkOutRemained, 0);
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = FALSE;
- pAd->ContinBulkIn = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- /* Wait 50ms to prevent next URB to bulkout during HW reset. */
- /* todo : remove this if not necessary */
- NdisMSleep(50000);
-
- pAd->ate.Mode = ATE_STOP;
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-/*=========================================================================*/
- /* restore RX_FILTR_CFG */
-#ifdef CONFIG_STA_SUPPORT
- /* restore RX_FILTR_CFG in order that QA maybe set it to 0x3 */
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL);
-#endif // CONFIG_STA_SUPPORT //
-/*=========================================================================*/
-
- // Enable Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Wait 10ms to wait all of the bulk-in URBs to complete.
- /* todo : remove this if not necessary */
- NdisMSleep(10000);
-
- // Everything is ready to start normal Tx/Rx.
- RTUSBBulkReceive(pAd);
- netif_start_queue(pAd->net_dev);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== ATE : ATESTOP \n"));
- }
- else if (!strcmp(arg, "TXCARR")) // Tx Carrier
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXCARR\n"));
- pAd->ate.Mode |= ATE_TXCARR;
-
- // Disable Rx
- // May be we need not to do this, because these have been done in ATE_START mode ???
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // QA has done the following steps if it is used.
- if (pAd->ate.bQATxStart == FALSE)
- {
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Carrier Test set BBP R22 bit7=1, bit6=1, bit[5~0]=0x01
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- BbpData |= 0x000000C1; //set bit7=1, bit6=1, bit[5~0]=0x01
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value = Value | 0x00000010;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
- }
- else if (!strcmp(arg, "TXCONT")) // Tx Continue
- {
- if (pAd->ate.bQATxStart == TRUE)
- {
- /* set MAC_SYS_CTRL(0x1004) bit4(Continuous Tx Production Test)
- and bit2(MAC TX enable) back to zero. */
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData &= 0xFFFFFFEB;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- // set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF7F; //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
-
- /* for TxCont mode.
- ** Step 1: Send 50 packets first then wait for a moment.
- ** Step 2: Send more 50 packet then start continue mode.
- */
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXCONT\n"));
- // Step 1: send 50 packets first.
- pAd->ate.Mode |= ATE_TXCONT;
- pAd->ate.TxCount = 50;
- pAd->ate.TxDoneCount = 0;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
-
- /* Only needed if we have to send some normal frames. */
- SetJapanFilter(pAd);
-
- // Setup frame format.
- ATESetUpFrame(pAd, 0);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- InterlockedExchange(&pAd->BulkOutRemained, pAd->ate.TxCount);
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#endif // RALINK_28xx_QA //
-
- NdisAcquireSpinLock(&pAd->GenericLock);//0820
- pAd->ContinBulkOut = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
-
- /* To make sure all the 50 frames have been bulk out before executing step 2 */
- while (atomic_read(&pAd->BulkOutRemained) > 0)
- {
- RTMPusecDelay(5000);
- }
-
- // Step 2: send more 50 packets then start continue mode.
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Cont. TX set BBP R22 bit7=1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData |= 0x00000080; //set bit7=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- pAd->ate.TxCount = 50;
- pAd->ate.TxDoneCount = 0;
-
- SetJapanFilter(pAd);
-
- // Setup frame format.
- ATESetUpFrame(pAd, 0);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- InterlockedExchange(&pAd->BulkOutRemained, pAd->ate.TxCount);
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#endif // RALINK_28xx_QA //
-
- NdisAcquireSpinLock(&pAd->GenericLock);//0820
- pAd->ContinBulkOut = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
-
-#if 1
- RTMPusecDelay(500);
-#else
- while (atomic_read(&pAd->BulkOutRemained) > 0)
- {
- RTMPusecDelay(5000);
- }
-#endif // 1 //
-
- // Set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData |= 0x00000010;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
- }
- else if (!strcmp(arg, "TXFRAME")) // Tx Frames
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXFRAME(Count=0x%08x)\n", pAd->ate.TxCount));
- pAd->ate.Mode |= ATE_TXFRAME;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
-
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
-#ifdef RALINK_28xx_QA
- // add this for LoopBack mode
- if (pAd->ate.bQARxStart == FALSE)
- {
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
-
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#else
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-#endif // RALINK_28xx_QA //
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- SetJapanFilter(pAd);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- pAd->ate.TxDoneCount = 0;
-
- // Setup frame format
- ATESetUpFrame(pAd, 0);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Check count is continuous or not yet.
- //
- // Due to the type mismatch between "pAd->BulkOutRemained"(atomic_t) and "pAd->ate.TxCount"(UINT32)
- //
- if (pAd->ate.TxCount == 0)
- {
- InterlockedExchange(&pAd->BulkOutRemained, 0);
- }
- else
- {
- InterlockedExchange(&pAd->BulkOutRemained, pAd->ate.TxCount);
- }
- ATEDBGPRINT(RT_DEBUG_TRACE, ("bulk out count = %d\n", atomic_read(&pAd->BulkOutRemained)));
- ASSERT((atomic_read(&pAd->BulkOutRemained) >= 0));
-
- if (atomic_read(&pAd->BulkOutRemained) == 0)
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Send packet countinuously\n"));
-
- /* In 28xx, NdisAcquireSpinLock() == spin_lock_bh() */
- /* NdisAcquireSpinLock only need one argument in 28xx. */
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = TRUE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- /* In 28xx, BULK_OUT_LOCK() == spin_lock_irqsave() */
- BULK_OUT_LOCK(&pAd->BulkOutLock[0], IrqFlags);// peter : NdisAcquireSpinLock ==> BULK_OUT_LOCK
- pAd->BulkOutPending[0] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);// peter : NdisAcquireSpinLock ==> BULK_OUT_LOCK
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Send packets depend on counter\n"));
-
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- pAd->BulkOutPending[0] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
- }
-#ifdef RALINK_28xx_QA
- else if (!strcmp(arg, "TXSTOP")) //Enter ATE mode and set Tx/Rx Idle
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXSTOP\n"));
-
- atemode = pAd->ate.Mode;
- pAd->ate.Mode &= ATE_TXSTOP;
- pAd->ate.bQATxStart = FALSE;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
-
-/*=========================================================================*/
- if (atemode & ATE_TXCARR)
- {
- // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // No Carrier Suppression set BBP R24 bit0=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
- BbpData &= 0xFFFFFFFE; //clear bit0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
- }
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
- if (atemode & ATE_TXCONT)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- }
-
-/*=========================================================================*/
- RTUSBRejectPendingPackets(pAd);
- RTUSBCleanUpDataBulkOutQueue(pAd);
-
- /* not used in RT28xx */
- //RTUSBCleanUpMLMEWaitQueue(pAd);
- /* empty function so far */
- RTUSBCleanUpMLMEBulkOutQueue(pAd);
-/*=========================================================================*/
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-/*=========================================================================*/
-
- /* In 28xx, pAd->PendingRx is not of type atomic_t anymore */
-// while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- /* peter todo : BulkInLock */
- while (pAd->PendingRx > 0)
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
-// NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-#endif
- RTMPusecDelay(500000);
- }
-
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- RTMPusecDelay(500000);
- }
-
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
- // Enable Tx, Rx DMA.
- RtmpDmaEnable(pAd, 1);
-
- /* task Tx status : 0 --> task is idle, 1 --> task is running */
- pAd->ate.TxStatus = 0;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData &= (0xfffffffb);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- //Clean ATE Bulk in/out counter and continue setup
- InterlockedExchange(&pAd->BulkOutRemained, 0);
-
- pAd->ContinBulkOut = FALSE;
- }
- else if (!strcmp(arg, "RXSTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: RXSTOP\n"));
- atemode = pAd->ate.Mode;
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- pAd->ate.Mode &= ATE_RXSTOP;
- pAd->ate.bQARxStart = FALSE;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
-
-/*=========================================================================*/
- RTUSBRejectPendingPackets(pAd);
- RTUSBCleanUpDataBulkOutQueue(pAd);
-
- /* not used in RT28xx */
- //RTUSBCleanUpMLMEWaitQueue(pAd);
- RTUSBCleanUpMLMEBulkOutQueue(pAd);
-/*=========================================================================*/
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-/*=========================================================================*/
-// while ((atomic_read(&pAd->PendingRx) > 0))
- while (pAd->PendingRx > 0)
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
-// NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-#endif
- RTMPusecDelay(500000);
- }
-
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- RTMPusecDelay(500000);
- }
-
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
- pAd->ContinBulkIn = FALSE;
- }
-#endif // RALINK_28xx_QA //
- else if (!strcmp(arg, "RXFRAME")) // Rx Frames
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: RXFRAME\n"));
-
- // Disable Rx of MAC block
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- pAd->ate.Mode |= ATE_RXFRAME;
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Disable TX of MAC block
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Reset Rx RING.
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
-
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
-
- //
- // Get the urb from kernel back to driver.
- //
- RTUSB_UNLINK_URB(pRxContext->pUrb);
-
- /* Sleep 200 microsecs to give cancellation time to work. */
- NdisMSleep(200);
- pAd->BulkInReq = 0;
-
-// InterlockedExchange(&pAd->PendingRx, 0);
- pAd->PendingRx = 0;
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = RX_RING_SIZE - 1; // Rx Bulk pointer
- pAd->NextRxBulkInPosition = 0;
- }
-
- // read to clear counters
- RTUSBReadMACRegister(pAd, RX_STA_CNT0, &temp); //RX PHY & RX CRC count
- RTUSBReadMACRegister(pAd, RX_STA_CNT1, &temp); //RX PLCP error count & CCA false alarm count
- RTUSBReadMACRegister(pAd, RX_STA_CNT2, &temp); //RX FIFO overflow frame count & RX duplicated filtered frame count
-
- pAd->ContinBulkIn = TRUE;
-
- // Enable Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable RX of MAC block
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Kick bulk in
- RTUSBBulkReceive(pAd);
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: Invalid arg!\n"));
- return FALSE;
- }
- RTMPusecDelay(5000);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== ATECmdHandler()\n"));
-
- return TRUE;
-}
-#endif // RT2870 //
-
-INT Set_ATE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (ATECmdHandler(pAd, arg))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_Proc Success\n"));
-
-
- return TRUE;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_Proc Failed\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR1=DA for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_DA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr3[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_DA_Proc (DA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr3[0],
- pAd->ate.Addr3[1], pAd->ate.Addr3[2], pAd->ate.Addr3[3], pAd->ate.Addr3[4], pAd->ate.Addr3[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_DA_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR3=SA for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR2=SA for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_SA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr2[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_SA_Proc (SA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr2[0],
- pAd->ate.Addr2[1], pAd->ate.Addr2[2], pAd->ate.Addr2[3], pAd->ate.Addr2[4], pAd->ate.Addr2[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_SA_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR2=BSSID for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR1=BSSID for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_BSSID_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr1[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_BSSID_Proc (BSSID = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr1[0],
- pAd->ate.Addr1[1], pAd->ate.Addr1[2], pAd->ate.Addr1[3], pAd->ate.Addr1[4], pAd->ate.Addr1[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_BSSID_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Channel
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_CHANNEL_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR channel;
-
- channel = simple_strtol(arg, 0, 10);
-
- if ((channel < 1) || (channel > 216))// to allow A band channel : ((channel < 1) || (channel > 14))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_CHANNEL_Proc::Out of range, it should be in range of 1~14.\n"));
- return FALSE;
- }
- pAd->ate.Channel = channel;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAd->ate.Channel));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_CHANNEL_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Power0
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_POWER0_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR TxPower;
-
- TxPower = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.Channel <= 14)
- {
- if ((TxPower > 31) || (TxPower < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
- else// 5.5GHz
- {
- if ((TxPower > 15) || (TxPower < -7))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
-
- pAd->ate.TxPower0 = TxPower;
- ATETxPwrHandler(pAd, 0);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER0_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Power1
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_POWER1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR TxPower;
-
- TxPower = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.Channel <= 14)
- {
- if ((TxPower > 31) || (TxPower < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
- else
- {
- if ((TxPower > 15) || (TxPower < -7))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
-
- pAd->ate.TxPower1 = TxPower;
- ATETxPwrHandler(pAd, 1);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER1_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Antenna
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR value;
-
- value = simple_strtol(arg, 0, 10);
-
- if ((value > 2) || (value < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_Antenna_Proc::Out of range (Value=%d)\n", value));
- return FALSE;
- }
-
- pAd->ate.TxAntennaSel = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_Antenna_Proc (Antenna = %d)\n", pAd->ate.TxAntennaSel));
- ATEDBGPRINT(RT_DEBUG_TRACE,("Ralink: Set_ATE_TX_Antenna_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Rx Antenna
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_RX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR value;
-
- value = simple_strtol(arg, 0, 10);
-
- if ((value > 3) || (value < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_RX_Antenna_Proc::Out of range (Value=%d)\n", value));
- return FALSE;
- }
-
- pAd->ate.RxAntennaSel = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_Antenna_Proc (Antenna = %d)\n", pAd->ate.RxAntennaSel));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_Antenna_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE RF frequence offset
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_FREQOFFSET_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR RFFreqOffset;
- ULONG R4;
-
- RFFreqOffset = simple_strtol(arg, 0, 10);
-
- if(RFFreqOffset >= 64)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_FREQOFFSET_Proc::Out of range, it should be in range of 0~63.\n"));
- return FALSE;
- }
-
- pAd->ate.RFFreqOffset = RFFreqOffset;
- R4 = pAd->ate.RFFreqOffset << 15; // shift TX power control to correct RF register bit position
- R4 |= (pAd->LatchRfRegs.R4 & ((~0x001f8000)));
- pAd->LatchRfRegs.R4 = R4;
-
- RtmpRfIoWrite(pAd);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_FREQOFFSET_Proc (RFFreqOffset = %d)\n", pAd->ate.RFFreqOffset));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_FREQOFFSET_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE RF BW
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_BW_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- int i;
- UCHAR value = 0;
- UCHAR BBPCurrentBW;
-
- BBPCurrentBW = simple_strtol(arg, 0, 10);
-
- if(BBPCurrentBW == 0)
- pAd->ate.TxWI.BW = BW_20;
- else
- pAd->ate.TxWI.BW = BW_40;
-
- if(pAd->ate.TxWI.BW == BW_20)
- {
- if(pAd->ate.Channel <= 14)
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx20MPwrCfgGBand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgGBand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
- else
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx20MPwrCfgABand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgABand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
-
- //Set BBP R4 bit[4:3]=0:0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value &= (~0x18);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
-
- //Set BBP R66=0x3C
- value = 0x3C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
- //Set BBP R68=0x0B
- //to improve Rx sensitivity.
- value = 0x0B;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R68, value);
- //Set BBP R69=0x16
- value = 0x16;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, value);
- //Set BBP R70=0x08
- value = 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, value);
- //Set BBP R73=0x11
- value = 0x11;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, value);
-
- // If Channel=14, Bandwidth=20M and Mode=CCK, Set BBP R4 bit5=1
- // (Japan filter coefficients)
- // This segment of code will only works when ATETXMODE and ATECHANNEL
- // were set to MODE_CCK and 14 respectively before ATETXBW is set to 0.
- //=====================================================================
- if (pAd->ate.Channel == 14)
- {
- int TxMode = pAd->ate.TxWI.PHYMODE;
- if (TxMode == MODE_CCK)
- {
- // when Channel==14 && Mode==CCK && BandWidth==20M, BBP R4 bit5=1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value |= 0x20; //set bit5=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
- }
- }
-
- //=====================================================================
- // If bandwidth != 40M, RF Reg4 bit 21 = 0.
- pAd->LatchRfRegs.R4 &= ~0x00200000;
- RtmpRfIoWrite(pAd);
- }
- else if(pAd->ate.TxWI.BW == BW_40)
- {
- if(pAd->ate.Channel <= 14)
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx40MPwrCfgGBand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgGBand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
- else
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx40MPwrCfgABand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgABand[i]);
- RTMPusecDelay(5000);
- }
- }
-#ifdef DOT11_N_SUPPORT
- if ((pAd->ate.TxWI.PHYMODE >= MODE_HTMIX) && (pAd->ate.TxWI.MCS == 7))
- {
- value = 0x28;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R67, value);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
- //Set BBP R4 bit[4:3]=1:0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value &= (~0x18);
- value |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
-
- //Set BBP R66=0x3C
- value = 0x3C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
- //Set BBP R68=0x0C
- //to improve Rx sensitivity.
- value = 0x0C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R68, value);
- //Set BBP R69=0x1A
- value = 0x1A;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, value);
- //Set BBP R70=0x0A
- value = 0x0A;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, value);
- //Set BBP R73=0x16
- value = 0x16;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, value);
-
- // If bandwidth = 40M, set RF Reg4 bit 21 = 1.
- pAd->LatchRfRegs.R4 |= 0x00200000;
- RtmpRfIoWrite(pAd);
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_BW_Proc (BBPCurrentBW = %d)\n", pAd->ate.TxWI.BW));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_BW_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame length
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_LENGTH_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxLength = simple_strtol(arg, 0, 10);
-
- if((pAd->ate.TxLength < 24) || (pAd->ate.TxLength > (MAX_FRAME_SIZE - 34/* == 2312 */)))
- {
- pAd->ate.TxLength = (MAX_FRAME_SIZE - 34/* == 2312 */);
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_LENGTH_Proc::Out of range, it should be in range of 24~%d.\n", (MAX_FRAME_SIZE - 34/* == 2312 */)));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_LENGTH_Proc (TxLength = %d)\n", pAd->ate.TxLength));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_LENGTH_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame count
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_COUNT_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxCount = simple_strtol(arg, 0, 10);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAd->ate.TxCount));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame MCS
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_MCS_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR MCS;
- int result;
-
- MCS = simple_strtol(arg, 0, 10);
- result = CheckMCSValid(pAd->ate.TxWI.PHYMODE, MCS);
-
- if (result != -1)
- {
- pAd->ate.TxWI.MCS = (UCHAR)MCS;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MCS_Proc::Out of range, refer to rate table.\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MCS_Proc (MCS = %d)\n", pAd->ate.TxWI.MCS));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MCS_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame Mode
- 0: MODE_CCK
- 1: MODE_OFDM
- 2: MODE_HTMIX
- 3: MODE_HTGREENFIELD
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_MODE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxWI.PHYMODE = simple_strtol(arg, 0, 10);
-
- if(pAd->ate.TxWI.PHYMODE > 3)
- {
- pAd->ate.TxWI.PHYMODE = 0;
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MODE_Proc::Out of range. it should be in range of 0~3\n"));
- ATEDBGPRINT(RT_DEBUG_ERROR, ("0: CCK, 1: OFDM, 2: HT_MIX, 3: HT_GREEN_FIELD.\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MODE_Proc (TxMode = %d)\n", pAd->ate.TxWI.PHYMODE));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MODE_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame GI
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_GI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxWI.ShortGI = simple_strtol(arg, 0, 10);
-
- if(pAd->ate.TxWI.ShortGI > 1)
- {
- pAd->ate.TxWI.ShortGI = 0;
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_GI_Proc::Out of range\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_GI_Proc (GI = %d)\n", pAd->ate.TxWI.ShortGI));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_GI_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-INT Set_ATE_RX_FER_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.bRxFer = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.bRxFer == 1)
- {
- pAd->ate.RxCntPerSec = 0;
- pAd->ate.RxTotalCnt = 0;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_FER_Proc (bRxFer = %d)\n", pAd->ate.bRxFer));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_FER_Proc Success\n"));
-
-
- return TRUE;
-}
-
-INT Set_ATE_Read_RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print(KERN_EMERG "R1 = %lx\n", pAd->LatchRfRegs.R1);
- ate_print(KERN_EMERG "R2 = %lx\n", pAd->LatchRfRegs.R2);
- ate_print(KERN_EMERG "R3 = %lx\n", pAd->LatchRfRegs.R3);
- ate_print(KERN_EMERG "R4 = %lx\n", pAd->LatchRfRegs.R4);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R1 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF2_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R2 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF3_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R3 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-INT Set_ATE_Write_RF4_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R4 = value;
- RtmpRfIoWrite(pAd);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Load and Write EEPROM from a binary file prepared in advance.
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-#ifndef UCOS
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN ret = FALSE;
- PUCHAR src = EEPROM_BIN_FILE_NAME;
- struct file *srcf;
- INT32 retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- USHORT WriteEEPROM[(EEPROM_SIZE/2)];
- UINT32 FileLength = 0;
- UINT32 value = simple_strtol(arg, 0, 10);
-
- ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __func__, value));
-
- if (value > 0)
- {
- /* zero the e2p buffer */
- NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
-
- /* save uid and gid used for filesystem access.
- ** set user and group to 0 (root)
- */
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- /* as root */
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- do
- {
- /* open the bin file */
- srcf = filp_open(src, O_RDONLY, 0);
-
- if (IS_ERR(srcf))
- {
- ate_print("%s - Error %ld opening %s\n", __func__, -PTR_ERR(srcf), src);
- break;
- }
-
- /* the object must have a read method */
- if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
- {
- ate_print("%s - %s does not have a read method\n", __func__, src);
- break;
- }
-
- /* read the firmware from the file *.bin */
- FileLength = srcf->f_op->read(srcf,
- (PUCHAR)WriteEEPROM,
- EEPROM_SIZE,
- &srcf->f_pos);
-
- if (FileLength != EEPROM_SIZE)
- {
- ate_print("%s: error file length (=%d) in e2p.bin\n",
- __func__, FileLength);
- break;
- }
- else
- {
- /* write the content of .bin file to EEPROM */
- rt_ee_write_all(pAd, WriteEEPROM);
- ret = TRUE;
- }
- break;
- } while(TRUE);
-
- /* close firmware file */
- if (IS_ERR(srcf))
- {
- ;
- }
- else
- {
- retval = filp_close(srcf, NULL);
- if (retval)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("--> Error %d closing %s\n", -retval, src));
-
- }
- }
-
- /* restore */
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
- }
- ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __func__, ret));
-
- return ret;
-
-}
-#else
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT WriteEEPROM[(EEPROM_SIZE/2)];
- struct iwreq *wrq = (struct iwreq *)arg;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __func__, wrq->u.data.length));
-
- if (wrq->u.data.length != EEPROM_SIZE)
- {
- ate_print("%s: error length (=%d) from host\n",
- __func__, wrq->u.data.length);
- return FALSE;
- }
- else/* (wrq->u.data.length == EEPROM_SIZE) */
- {
- /* zero the e2p buffer */
- NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
-
- /* fill the local buffer */
- NdisMoveMemory((PUCHAR)WriteEEPROM, wrq->u.data.pointer, wrq->u.data.length);
-
- do
- {
- /* write the content of .bin file to EEPROM */
- rt_ee_write_all(pAd, WriteEEPROM);
-
- } while(FALSE);
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __func__));
-
- return TRUE;
-
-}
-#endif // !UCOS //
-
-INT Set_ATE_Read_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT buffer[EEPROM_SIZE/2];
- USHORT *p;
- int i;
-
- rt_ee_read_all(pAd, (USHORT *)buffer);
- p = buffer;
- for (i = 0; i < (EEPROM_SIZE/2); i++)
- {
- ate_print("%4.4x ", *p);
- if (((i+1) % 16) == 0)
- ate_print("\n");
- p++;
- }
- return TRUE;
-}
-
-INT Set_ATE_Show_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print("Mode=%d\n", pAd->ate.Mode);
- ate_print("TxPower0=%d\n", pAd->ate.TxPower0);
- ate_print("TxPower1=%d\n", pAd->ate.TxPower1);
- ate_print("TxAntennaSel=%d\n", pAd->ate.TxAntennaSel);
- ate_print("RxAntennaSel=%d\n", pAd->ate.RxAntennaSel);
- ate_print("BBPCurrentBW=%d\n", pAd->ate.TxWI.BW);
- ate_print("GI=%d\n", pAd->ate.TxWI.ShortGI);
- ate_print("MCS=%d\n", pAd->ate.TxWI.MCS);
- ate_print("TxMode=%d\n", pAd->ate.TxWI.PHYMODE);
- ate_print("Addr1=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr1[0], pAd->ate.Addr1[1], pAd->ate.Addr1[2], pAd->ate.Addr1[3], pAd->ate.Addr1[4], pAd->ate.Addr1[5]);
- ate_print("Addr2=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr2[0], pAd->ate.Addr2[1], pAd->ate.Addr2[2], pAd->ate.Addr2[3], pAd->ate.Addr2[4], pAd->ate.Addr2[5]);
- ate_print("Addr3=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr3[0], pAd->ate.Addr3[1], pAd->ate.Addr3[2], pAd->ate.Addr3[3], pAd->ate.Addr3[4], pAd->ate.Addr3[5]);
- ate_print("Channel=%d\n", pAd->ate.Channel);
- ate_print("TxLength=%d\n", pAd->ate.TxLength);
- ate_print("TxCount=%u\n", pAd->ate.TxCount);
- ate_print("RFFreqOffset=%d\n", pAd->ate.RFFreqOffset);
- ate_print(KERN_EMERG "Set_ATE_Show_Proc Success\n");
- return TRUE;
-}
-
-INT Set_ATE_Help_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print("ATE=ATESTART, ATESTOP, TXCONT, TXCARR, TXFRAME, RXFRAME\n");
- ate_print("ATEDA\n");
- ate_print("ATESA\n");
- ate_print("ATEBSSID\n");
- ate_print("ATECHANNEL, range:0~14(unless A band !)\n");
- ate_print("ATETXPOW0, set power level of antenna 1.\n");
- ate_print("ATETXPOW1, set power level of antenna 2.\n");
- ate_print("ATETXANT, set TX antenna. 0:all, 1:antenna one, 2:antenna two.\n");
- ate_print("ATERXANT, set RX antenna.0:all, 1:antenna one, 2:antenna two, 3:antenna three.\n");
- ate_print("ATETXFREQOFFSET, set frequency offset, range 0~63\n");
- ate_print("ATETXBW, set BandWidth, 0:20MHz, 1:40MHz.\n");
- ate_print("ATETXLEN, set Frame length, range 24~%d\n", (MAX_FRAME_SIZE - 34/* == 2312 */));
- ate_print("ATETXCNT, set how many frame going to transmit.\n");
- ate_print("ATETXMCS, set MCS, reference to rate table.\n");
- ate_print("ATETXMODE, set Mode 0:CCK, 1:OFDM, 2:HT-Mix, 3:GreenField, reference to rate table.\n");
- ate_print("ATETXGI, set GI interval, 0:Long, 1:Short\n");
- ate_print("ATERXFER, 0:disable Rx Frame error rate. 1:enable Rx Frame error rate.\n");
- ate_print("ATERRF, show all RF registers.\n");
- ate_print("ATEWRF1, set RF1 register.\n");
- ate_print("ATEWRF2, set RF2 register.\n");
- ate_print("ATEWRF3, set RF3 register.\n");
- ate_print("ATEWRF4, set RF4 register.\n");
- ate_print("ATELDE2P, load EEPROM from .bin file.\n");
- ate_print("ATERE2P, display all EEPROM content.\n");
- ate_print("ATESHOW, display all parameters of ATE.\n");
- ate_print("ATEHELP, online help.\n");
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
-
- AsicSwitchChannel() dedicated for ATE.
-
- ==========================================================================
-*/
-VOID ATEAsicSwitchChannel(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0, Value = 0;
- CHAR TxPwer = 0, TxPwer2 = 0;
- UCHAR index, BbpValue = 0, R66 = 0x30;
- RTMP_RF_REGS *RFRegTable;
- UCHAR Channel;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- if (pAd->ate.Channel != pAd->LatchRfRegs.Channel)
- {
- pAd->ate.Channel = pAd->LatchRfRegs.Channel;
- }
- return;
- }
- else
-#endif // RALINK_28xx_QA //
- Channel = pAd->ate.Channel;
-
- // Select antenna
- AsicAntennaSelect(pAd, Channel);
-
- // fill Tx power value
- TxPwer = pAd->ate.TxPower0;
- TxPwer2 = pAd->ate.TxPower1;
-
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- /* But only 2850 and 2750 support 5.5GHz band... */
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- switch (pAd->ate.RxAntennaSel)
- {
- case 1:
- R2 |= 0x20040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x00;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 2:
- R2 |= 0x10040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x01;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- default:
- R2 |= 0x40;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- /* Only enable two Antenna to receive. */
- BbpValue |= 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- }
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
-
- if (pAd->Antenna.field.TxPath == 2)
- {
- if (pAd->ate.TxAntennaSel == 1)
- {
- R2 |= 0x4000; // If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7; //11100111B
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- else if (pAd->ate.TxAntennaSel == 2)
- {
- R2 |= 0x8000; // If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7;
- BbpValue |= 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- else
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7;
- BbpValue |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- }
- if (pAd->Antenna.field.RxPath == 3)
- {
- switch (pAd->ate.RxAntennaSel)
- {
- case 1:
- R2 |= 0x20040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x00;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 2:
- R2 |= 0x10040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x01;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 3:
- R2 |= 0x30000;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x02;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- default:
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- }
- }
-
- if (Channel > 14)
- {
- // initialize R3, R4
- R3 = (RFRegTable[index].R3 & 0xffffc1ff);
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15);
-
- // According the Rory's suggestion to solve the middle range issue.
- // 5.5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB
- // R3
- if ((TxPwer >= -7) && (TxPwer < 0))
- {
- TxPwer = (7+TxPwer);
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer=%d \n", TxPwer));
- }
- else
- {
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10) | (1 << 9);
- }
-
- // R4
- if ((TxPwer2 >= -7) && (TxPwer2 < 0))
- {
- TxPwer2 = (7+TxPwer2);
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer2=%d \n", TxPwer2));
- }
- else
- {
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7) | (1 << 6);
- }
- }
- else
- {
- R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); // set TX power0
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15) | (TxPwer2 <<6);// Set freq offset & TxPwr1
- }
-
- // Based on BBP current mode before changing RF channel.
- if (pAd->ate.TxWI.BW == BW_40)
- {
- R4 |=0x200000;
- }
-
- // Update variables
- pAd->LatchRfRegs.Channel = Channel;
- pAd->LatchRfRegs.R1 = RFRegTable[index].R1;
- pAd->LatchRfRegs.R2 = R2;
- pAd->LatchRfRegs.R3 = R3;
- pAd->LatchRfRegs.R4 = R4;
-
- RtmpRfIoWrite(pAd);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
- // Change BBP setting during switch from a->g, g->a
- if (Channel <= 14)
- {
- ULONG TxPinCfg = 0x00050F0A;// 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
-
- /* For 1T/2R chip only... */
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
- }
- else
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);
- }
-
- // According the Rory's suggestion to solve the middle range issue.
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R86, &BbpValue);
- ASSERT((BbpValue == 0x00));
- if ((BbpValue != 0x00))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
- }
-
- // 5.5GHz band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x04);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R.
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
- else
- {
- ULONG TxPinCfg = 0x00050F05;//2007.10.09 by Brian : 0x00050505 ==> 0x00050F05
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
-
- // According the Rory's suggestion to solve the middle range issue.
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R86, &BbpValue);
- ASSERT((BbpValue == 0x00));
- if ((BbpValue != 0x00))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
- }
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R91, &BbpValue);
- ASSERT((BbpValue == 0x04));
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R92, &BbpValue);
- ASSERT((BbpValue == 0x00));
-
- // 5.5GHz band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x02);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R.
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
-
- // R66 should be set according to Channel and use 20MHz when scanning
- if (Channel <= 14)
- {
- // BG band
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- {
- // 5.5 GHz band
- if (pAd->ate.TxWI.BW == BW_20)
- {
- R66 = (UCHAR)(0x32 + (GET_LNA_GAIN(pAd)*5)/3);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- {
- R66 = (UCHAR)(0x3A + (GET_LNA_GAIN(pAd)*5)/3);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
-
- //
- // On 11A, We should delay and wait RF/BBP to be stable
- // and the appropriate time should be 1000 micro seconds
- // 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
- //
- RTMPusecDelay(1000);
-
- if (Channel > 14)
- {
- // When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not.
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%u, Pwr1=%u, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- (R3 & 0x00003e00) >> 9,
- (R4 & 0x000007c0) >> 6,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
- }
-}
-
-//
-// In fact, no one will call this routine so far !
-//
-/*
- ==========================================================================
- Description:
- Gives CCK TX rate 2 more dB TX power.
- This routine works only in ATE mode.
-
- calculate desired Tx power in RF R3.Tx0~5, should consider -
- 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
- 1. TxPowerPercentage
- 2. auto calibration based on TSSI feedback
- 3. extra 2 db for CCK
- 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
-
- NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
- it should be called AFTER MlmeDynamicTxRateSwitching()
- ==========================================================================
- */
-VOID ATEAsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd)
-{
- INT i, j;
- CHAR DeltaPwr = 0;
- BOOLEAN bAutoTxAgc = FALSE;
- UCHAR TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;
- UCHAR BbpR49 = 0, idx;
- PCHAR pTxAgcCompensate;
- ULONG TxPwr[5];
- CHAR Value;
-
- /* no one calls this procedure so far */
- if (pAd->ate.TxWI.BW == BW_40)
- {
- if (pAd->ate.Channel > 14)
- {
- TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
- }
- }
- else
- {
- if (pAd->ate.Channel > 14)
- {
- TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
- }
- }
-
- // TX power compensation for temperature variation based on TSSI.
- // Do it per 4 seconds.
- if (pAd->Mlme.OneSecPeriodicRound % 4 == 0)
- {
- if (pAd->ate.Channel <= 14)
- {
- /* bg channel */
- bAutoTxAgc = pAd->bAutoTxAgcG;
- TssiRef = pAd->TssiRefG;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryG[0];
- TxAgcStep = pAd->TxAgcStepG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- /* a channel */
- bAutoTxAgc = pAd->bAutoTxAgcA;
- TssiRef = pAd->TssiRefA;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryA[0];
- TxAgcStep = pAd->TxAgcStepA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- {
- /* BbpR49 is unsigned char */
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);
-
- /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
- /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
- /* step value is defined in pAd->TxAgcStepG for tx power value */
-
- /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
- /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- above value are examined in mass factory production */
- /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
-
- /* plus is 0x10 ~ 0x40, minus is 0x60 ~ 0x90 */
- /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
- /* if value is 0x65, tx power will be -= TxAgcStep*(2-1) */
-
- if (BbpR49 > pTssiMinusBoundary[1])
- {
- // Reading is larger than the reference value.
- // Check for how large we need to decrease the Tx power.
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 <= pTssiMinusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should decrease, idx = 0 means there is nothing to compensate
-// if (R3 > (ULONG) (TxAgcStep * (idx-1)))
- *pTxAgcCompensate = -(TxAgcStep * (idx-1));
-// else
-// *pTxAgcCompensate = -((UCHAR)R3);
-
- DeltaPwr += (*pTxAgcCompensate);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else if (BbpR49 < pTssiPlusBoundary[1])
- {
- // Reading is smaller than the reference value
- // check for how large we need to increase the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 >= pTssiPlusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should increase, idx = 0 means there is nothing to compensate
- *pTxAgcCompensate = TxAgcStep * (idx-1);
- DeltaPwr += (*pTxAgcCompensate);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else
- {
- *pTxAgcCompensate = 0;
- ATEDBGPRINT(RT_DEBUG_TRACE, (" Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, 0));
- }
- }
- }
- else
- {
- if (pAd->ate.Channel <= 14)
- {
- bAutoTxAgc = pAd->bAutoTxAgcG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- bAutoTxAgc = pAd->bAutoTxAgcA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- DeltaPwr += (*pTxAgcCompensate);
- }
-
- /* calculate delta power based on the percentage specified from UI */
- // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
- // We lower TX power here according to the percentage specified from UI
- if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff) // AUTO TX POWER control
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW
- {
- DeltaPwr -= 1;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW
- {
- DeltaPwr -= 3;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW
- {
- DeltaPwr -= 6;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW
- {
- DeltaPwr -= 9;
- }
- else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW
- {
- DeltaPwr -= 12;
- }
-
- /* reset different new tx power for different TX rate */
- for(i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F); /* 0 ~ 15 */
-
- if ((Value + DeltaPwr) < 0)
- {
- Value = 0; /* min */
- }
- else if ((Value + DeltaPwr) > 0xF)
- {
- Value = 0xF; /* max */
- }
- else
- {
- Value += DeltaPwr; /* temperature compensation */
- }
-
- /* fill new value to CSR offset */
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
-
- /* write tx power value to CSR */
- /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
- TX power for OFDM 6M/9M
- TX power for CCK5.5M/11M
- TX power for CCK1M/2M */
- /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);
-
-
- }
- }
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Write TxWI for ATE mode.
-
- Return Value:
- None
- ========================================================================
-*/
-
-#ifdef RT2870
-static VOID ATEWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR MIMOps,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING Transmit)
-{
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- pTxWI->FRAG= FRAG;
- pTxWI->TS= InsTimestamp;
- pTxWI->AMPDU = AMPDU;
-
- pTxWI->MIMOps = PWR_ACTIVE;
- pTxWI->MpduDensity = 4;
- pTxWI->ACK = Ack;
- pTxWI->txop = Txopmode;
- pTxWI->NSEQ = NSeq;
- pTxWI->BAWinSize = BASize;
-
- pTxWI->WirelessCliID = WCID;
- pTxWI->MPDUtotalByteCount = Length;
- pTxWI->PacketId = PID;
-
- pTxWI->BW = Transmit.field.BW;
- pTxWI->ShortGI = Transmit.field.ShortGI;
- pTxWI->STBC= Transmit.field.STBC;
-
- pTxWI->MCS = Transmit.field.MCS;
- pTxWI->PHYMODE= Transmit.field.MODE;
-
-#ifdef DOT11_N_SUPPORT
- //
- // MMPS is 802.11n features. Because TxWI->MCS > 7 must be HT mode,
- // so need not check if it's HT rate.
- //
- if ((MIMOps == MMPS_STATIC) && (pTxWI->MCS > 7))
- pTxWI->MCS = 7;
-
- if ((MIMOps == MMPS_DYNAMIC) && (pTxWI->MCS > 7)) // SMPS protect 2 spatial.
- pTxWI->MIMOps = 1;
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->CFACK = CfAck;
-
- return;
-}
-#endif // RT2870 //
-/*
- ========================================================================
-
- Routine Description:
- Disable protection for ATE.
- ========================================================================
-*/
-VOID ATEDisableAsicProtect(
- IN PRTMP_ADAPTER pAd)
-{
- PROT_CFG_STRUC ProtCfg, ProtCfg4;
- UINT32 Protect[6];
- USHORT offset;
- UCHAR i;
- UINT32 MacReg = 0;
-
- // Config ASIC RTS threshold register
- RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
- MacReg &= 0xFF0000FF;
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
- RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
-
- // Initial common protection settings
- RTMPZeroMemory(Protect, sizeof(Protect));
- ProtCfg4.word = 0;
- ProtCfg.word = 0;
- ProtCfg.field.TxopAllowGF40 = 1;
- ProtCfg.field.TxopAllowGF20 = 1;
- ProtCfg.field.TxopAllowMM40 = 1;
- ProtCfg.field.TxopAllowMM20 = 1;
- ProtCfg.field.TxopAllowOfdm = 1;
- ProtCfg.field.TxopAllowCck = 1;
- ProtCfg.field.RTSThEn = 1;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-
- // Handle legacy(B/G) protection
- ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0;
- Protect[0] = ProtCfg.word;
- Protect[1] = ProtCfg.word;
-
- // NO PROTECT
- // 1.All STAs in the BSS are 20/40 MHz HT
- // 2. in ai 20/40MHz BSS
- // 3. all STAs are 20MHz in a 20MHz BSS
- // Pure HT. no protection.
-
- // MM20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[2] = 0x01744004;
-
- // MM40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[3] = 0x03f44084;
-
- // CF20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[4] = 0x01744004;
-
- // CF40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[5] = 0x03f44084;
-
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
-
- offset = CCK_PROT_CFG;
- for (i = 0;i < 6;i++)
- RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);
-
-}
-
-#ifdef RT2870
-/*
- ========================================================================
- Routine Description:
- Write TxInfo for ATE mode.
-
- Return Value:
- None
- ========================================================================
-*/
-static VOID ATEWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst)
-{
- pTxInfo->USBDMATxPktLen = USBDMApktLen;
- pTxInfo->QSEL = QueueSel;
-
- if (QueueSel != FIFO_EDCA)
- ATEDBGPRINT(RT_DEBUG_TRACE, ("=======> QueueSel != FIFO_EDCA<=======\n"));
-
- pTxInfo->USBDMANextVLD = NextValid;
- pTxInfo->USBDMATxburst = TxBurst;
- pTxInfo->WIV = bWiv;
- pTxInfo->SwUseLastRound = 0;
- pTxInfo->rsv = 0;
- pTxInfo->rsv2 = 0;
-
- return;
-}
-#endif // RT2870 //
-
-/* There are two ways to convert Rssi */
-#if 1
-//
-// The way used with GET_LNA_GAIN().
-//
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- LNAGain = GET_LNA_GAIN(pAd);
- if (pAd->LatchRfRegs.Channel > 14)
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-12 - RssiOffset - LNAGain - Rssi);
-}
-#else
-//
-// The way originally used in ATE of rt2860ap.
-//
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- if (pAd->LatchRfRegs.Channel > 14)
- {
- LNAGain = pAd->ALNAGain;
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- LNAGain = pAd->BLNAGain;
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-32 - RssiOffset + LNAGain - Rssi);
-}
-#endif /* end of #if 1 */
-
-/*
- ========================================================================
-
- Routine Description:
- Set Japan filter coefficients if needed.
- Note:
- This routine should only be called when
- entering TXFRAME mode or TXCONT mode.
-
- ========================================================================
-*/
-static VOID SetJapanFilter(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BbpData = 0;
-
- //
- // If Channel=14 and Bandwidth=20M and Mode=CCK, set BBP R4 bit5=1
- // (Japan Tx filter coefficients)when (TXFRAME or TXCONT).
- //
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BbpData);
-
- if ((pAd->ate.TxWI.PHYMODE == MODE_CCK) && (pAd->ate.Channel == 14) && (pAd->ate.TxWI.BW == BW_20))
- {
- BbpData |= 0x20; // turn on
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SetJapanFilter!!!\n"));
- }
- else
- {
- BbpData &= 0xdf; // turn off
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ClearJapanFilter!!!\n"));
- }
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BbpData);
-}
-
-VOID ATESampleRssi(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI)
-{
- /* There are two ways to collect RSSI. */
-#if 1
- //pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
- if (pRxWI->RSSI0 != 0)
- {
- pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
- pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
- pAd->ate.AvgRssi0 = pAd->ate.AvgRssi0X8 >> 3;
- }
- if (pRxWI->RSSI1 != 0)
- {
- pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
- pAd->ate.AvgRssi1X8 = (pAd->ate.AvgRssi1X8 - pAd->ate.AvgRssi1) + pAd->ate.LastRssi1;
- pAd->ate.AvgRssi1 = pAd->ate.AvgRssi1X8 >> 3;
- }
- if (pRxWI->RSSI2 != 0)
- {
- pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
- pAd->ate.AvgRssi2X8 = (pAd->ate.AvgRssi2X8 - pAd->ate.AvgRssi2) + pAd->ate.LastRssi2;
- pAd->ate.AvgRssi2 = pAd->ate.AvgRssi2X8 >> 3;
- }
-
- pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);// CHAR ==> UCHAR ?
- pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);// CHAR ==> UCHAR ?
-
- pAd->ate.NumOfAvgRssiSample ++;
-#else
- pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);
- pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);
- pAd->ate.RxCntPerSec++;
- pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
- pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
- pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
- pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
- pAd->ate.AvgRssi0 = pAd->ate.AvgRssi0X8 >> 3;
- pAd->ate.AvgRssi1X8 = (pAd->ate.AvgRssi1X8 - pAd->ate.AvgRssi1) + pAd->ate.LastRssi1;
- pAd->ate.AvgRssi1 = pAd->ate.AvgRssi1X8 >> 3;
- pAd->ate.AvgRssi2X8 = (pAd->ate.AvgRssi2X8 - pAd->ate.AvgRssi2) + pAd->ate.LastRssi2;
- pAd->ate.AvgRssi2 = pAd->ate.AvgRssi2X8 >> 3;
- pAd->ate.NumOfAvgRssiSample ++;
-#endif
-}
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPStationStop(
- IN PRTMP_ADAPTER pAd)
-{
-// BOOLEAN Cancelled;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStop\n"));
-
-#if 0
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-#endif
- // For rx statistics, we need to keep this timer running.
-// RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStop\n"));
-}
-
-VOID RTMPStationStart(
- IN PRTMP_ADAPTER pAd)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStart\n"));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStart\n"));
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Setup Frame format.
- NOTE:
- This routine should only be used in ATE mode.
- ==========================================================================
- */
-
-#ifdef RT2870
-/*======================Start of RT2870======================*/
-/* */
-/* */
-static INT ATESetUpFrame(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TxIdx)
-{
- UINT j;
- PTX_CONTEXT pNullContext;
- PUCHAR pDest;
- HTTRANSMIT_SETTING TxHTPhyMode;
- PTXWI_STRUC pTxWI;
- PTXINFO_STRUC pTxInfo;
- UINT32 TransferBufferLength, OrgBufferLength = 0;
- UCHAR padLen = 0;
-#ifdef RALINK_28xx_QA
- PHEADER_802_11 pHeader80211 = NULL;
-#endif // RALINK_28xx_QA //
-
- if ((RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- return -1;
- }
-
- /* We always use QID_AC_BE and FIFO_EDCA in ATE mode. */
-
- pNullContext = &(pAd->NullContext);
- ASSERT(pNullContext != NULL);
-
- if (pNullContext->InUse == FALSE)
- {
- // Set the in use bit
- pNullContext->InUse = TRUE;
- NdisZeroMemory(&(pAd->NullFrame), sizeof(HEADER_802_11));
-
- // Fill 802.11 header.
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pHeader80211 = NdisMoveMemory(&(pAd->NullFrame), pAd->ate.Header, pAd->ate.HLen);
-// pDest = NdisMoveMemory(&(pAd->NullFrame), pAd->ate.Header, pAd->ate.HLen);
-// pHeader80211 = (PHEADER_802_11)pDest;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- // Fill 802.11 header.
- NdisMoveMemory(&(pAd->NullFrame), TemplateFrame, sizeof(HEADER_802_11));
- }
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)&(pAd->NullFrame), DIR_READ, FALSE);
-#endif // RT_BIG_ENDIAN //
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- /* modify sequence number.... */
- if (pAd->ate.TxDoneCount == 0)
- {
- pAd->ate.seq = pHeader80211->Sequence;
- }
- else
- {
- pHeader80211->Sequence = ++pAd->ate.seq;
- }
- /* We already got all the addr. fields from QA GUI. */
- }
- else
-#endif // RALINK_28xx_QA //
- {
- COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->ate.Addr1);
- COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->ate.Addr2);
- COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->ate.Addr3);
- }
-
- RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[0], TX_BUFFER_NORMSIZE);//???
- pTxInfo = (PTXINFO_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[0];
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- // Avoid to exceed the range of WirelessPacket[].
- ASSERT(pAd->ate.TxInfo.USBDMATxPktLen <= (MAX_FRAME_SIZE - 34/* == 2312 */));
- NdisMoveMemory(pTxInfo, &(pAd->ate.TxInfo), sizeof(pAd->ate.TxInfo));
- }
- else
-#endif // RALINK_28xx_QA //
- {
- // Avoid to exceed the range of WirelessPacket[].
- ASSERT(pAd->ate.TxLength <= (MAX_FRAME_SIZE - 34/* == 2312 */));
-
- // pTxInfo->USBDMATxPktLen will be updated to include padding later.
- ATEWriteTxInfo(pAd, pTxInfo, (USHORT)(TXWI_SIZE + pAd->ate.TxLength), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxInfo->QSEL = FIFO_EDCA;
- }
-
- pTxWI = (PTXWI_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
-
- // Fill TxWI.
- if (pAd->ate.bQATxStart == TRUE)
- {
- TxHTPhyMode.field.BW = pAd->ate.TxWI.BW;
- TxHTPhyMode.field.ShortGI = pAd->ate.TxWI.ShortGI;
- TxHTPhyMode.field.STBC = pAd->ate.TxWI.STBC;
- TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
- TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
- ATEWriteTxWI(pAd, pTxWI, pAd->ate.TxWI.FRAG, pAd->ate.TxWI.TS, pAd->ate.TxWI.AMPDU, pAd->ate.TxWI.ACK, pAd->ate.TxWI.NSEQ,
- pAd->ate.TxWI.BAWinSize, BSSID_WCID, pAd->ate.TxWI.MPDUtotalByteCount/* include 802.11 header */, pAd->ate.TxWI.PacketId, 0, pAd->ate.TxWI.txop/*IFS_HTTXOP*/, pAd->ate.TxWI.CFACK/*FALSE*/, TxHTPhyMode);
- }
- else
- {
- TxHTPhyMode.field.BW = pAd->ate.TxWI.BW;
- TxHTPhyMode.field.ShortGI = pAd->ate.TxWI.ShortGI;
- TxHTPhyMode.field.STBC = 0;
- TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
- TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
-
- ATEWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE/* No ack required. */, FALSE, 0, BSSID_WCID, pAd->ate.TxLength,
- 0, 0, IFS_HTTXOP, FALSE, TxHTPhyMode);// "MMPS_STATIC" instead of "MMPS_DYNAMIC" ???
- }
-
- RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE+TXWI_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
-
- pDest = &(pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE+TXWI_SIZE+sizeof(HEADER_802_11)]);
-
- // Prepare frame payload
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- // copy pattern
- if ((pAd->ate.PLen != 0))
- {
- for (j = 0; j < pAd->ate.DLen; j+=pAd->ate.PLen)
- {
- RTMPMoveMemory(pDest, pAd->ate.Pattern, pAd->ate.PLen);
- pDest += pAd->ate.PLen;
- }
- }
- TransferBufferLength = TXINFO_SIZE + TXWI_SIZE + pAd->ate.TxWI.MPDUtotalByteCount;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- for (j = 0; j < (pAd->ate.TxLength - sizeof(HEADER_802_11)); j++)
- {
- *pDest = 0xA5;
- pDest += 1;
- }
- TransferBufferLength = TXINFO_SIZE + TXWI_SIZE + pAd->ate.TxLength;
- }
-
-#if 1
- OrgBufferLength = TransferBufferLength;
- TransferBufferLength = (TransferBufferLength + 3) & (~3);
-
- // Always add 4 extra bytes at every packet.
- padLen = TransferBufferLength - OrgBufferLength + 4;/* 4 == last packet padding */
- ASSERT((padLen <= (RTMP_PKT_TAIL_PADDING - 4/* 4 == MaxBulkOutsize alignment padding */)));
-
- /* Now memzero all extra padding bytes. */
- NdisZeroMemory(pDest, padLen);
- pDest += padLen;
-#else
- if ((TransferBufferLength % 4) == 1)
- {
- NdisZeroMemory(pDest, 7);
- pDest += 7;
- TransferBufferLength += 3;
- }
- else if ((TransferBufferLength % 4) == 2)
- {
- NdisZeroMemory(pDest, 6);
- pDest += 6;
- TransferBufferLength += 2;
- }
- else if ((TransferBufferLength % 4) == 3)
- {
- NdisZeroMemory(pDest, 5);
- pDest += 5;
- TransferBufferLength += 1;
- }
-#endif // 1 //
-
- // Update pTxInfo->USBDMATxPktLen to include padding.
- pTxInfo->USBDMATxPktLen = TransferBufferLength - TXINFO_SIZE;
-
- TransferBufferLength += 4;
-
- // If TransferBufferLength is multiple of 64, add extra 4 bytes again.
- if ((TransferBufferLength % pAd->BulkOutMaxPacketSize) == 0)
- {
- NdisZeroMemory(pDest, 4);
- TransferBufferLength += 4;
- }
-
- // Fill out frame length information for global Bulk out arbitor
- pAd->NullContext.BulkOutSize = TransferBufferLength;
- }
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
- RTMPFrameEndianChange(pAd, (((PUCHAR)pTxInfo)+TXWI_SIZE+TXINFO_SIZE), DIR_WRITE, FALSE);
- RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
- return 0;
-}
-
-VOID ATE_RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pNullContext;
- UCHAR BulkOutPipeId;
- NTSTATUS Status;
- unsigned long IrqFlags;
- ULONG OldValue;
-
- pNullContext = (PTX_CONTEXT)pUrb->context;
- pAd = pNullContext->pAd;
-
-
- // Reset Null frame context flags
- pNullContext->IRPPending = FALSE;
- pNullContext->InUse = FALSE;
- Status = pUrb->status;
-
- // Store BulkOut PipeId
- BulkOutPipeId = pNullContext->BulkOutPipeId;
- pAd->BulkOutDataOneSecCount++;
-
- if (Status == USB_ST_NOERROR)
- {
-#ifdef RALINK_28xx_QA
- if ((ATE_ON(pAd)) && (pAd->ate.bQATxStart == TRUE))
- {
- if (pAd->ate.QID == BulkOutPipeId)
- {
- // Let Rx can have a chance to break in during Tx process,
- // especially for loopback mode in QA ATE.
- // To trade off between tx performance and loopback mode integrity.
- /* Q : Now Rx is handled by tasklet, do we still need this delay ? */
- /* Ans : Even tasklet is used, Rx/Tx < 1 if we do not delay for a while right here. */
- RTMPusecDelay(500);
- pAd->ate.TxDoneCount++;
- pAd->RalinkCounters.KickTxCount++;
- ASSERT(pAd->ate.QID == 0);
- pAd->ate.TxAc0++;
- }
- }
-#endif // RALINK_28xx_QA //
- pAd->BulkOutComplete++;
-
- pAd->Counters8023.GoodTransmits++;
-
- /* Don't worry about the queue is empty or not. This function will check itself. */
- RTMPDeQueuePacket(pAd, TRUE, BulkOutPipeId, MAX_TX_PROCESS);
-
- /* In 28xx, SendTxWaitQueue ==> TxSwQueue */
-/*
- if (pAd->SendTxWaitQueue[BulkOutPipeId].Number > 0)
- {
- RTMPDeQueuePacket(pAd, BulkOutPipeId);
- }
-*/
- }
- else // STATUS_OTHER
- {
- pAd->BulkOutCompleteOther++;
-
- ATEDBGPRINT(RT_DEBUG_ERROR, ("BulkOutDataPacket Failed STATUS_OTHER = 0x%x . \n", Status));
- ATEDBGPRINT(RT_DEBUG_ERROR, (">>BulkOutReq=0x%lx, BulkOutComplete=0x%lx\n", pAd->BulkOutReq, pAd->BulkOutComplete));
-
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- /* In 28xx, RT_OID_USB_RESET_BULK_OUT ==> CMDTHREAD_RESET_BULK_OUT */
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- // Check
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- pAd->bulkResetPipeid = BulkOutPipeId;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
- }
-
-
-
- if (atomic_read(&pAd->BulkOutRemained) > 0)
- {
- atomic_dec(&pAd->BulkOutRemained);
- }
-
- // 1st - Transmit Success
- OldValue = pAd->WlanCounters.TransmittedFragmentCount.u.LowPart;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart++;
-
- if (pAd->WlanCounters.TransmittedFragmentCount.u.LowPart < OldValue)
- {
- pAd->WlanCounters.TransmittedFragmentCount.u.HighPart++;
- }
-
- if(((pAd->ContinBulkOut == TRUE ) ||(atomic_read(&pAd->BulkOutRemained) > 0)) && (pAd->ate.Mode & ATE_TXFRAME))
- {
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
- }
- else
- {
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-#ifdef RALINK_28xx_QA
- pAd->ate.TxStatus = 0;
-#endif // RALINK_28xx_QA //
- }
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protection of rest bulk should be in BulkOut routine.
- RTUSBKickBulkOut(pAd);
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID ATE_RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId)
-{
- PTX_CONTEXT pNullContext = &(pAd->NullContext);
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
-
- ASSERT(BulkOutPipeId == 0);
-
- /* Build up the frame first. */
-// ATESetUpFrame(pAd, 0);
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- if (pAd->BulkOutPending[BulkOutPipeId] == TRUE)
- {
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
-
- pAd->BulkOutPending[BulkOutPipeId] = TRUE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- // Increase Total transmit byte counter
- pAd->RalinkCounters.OneSecTransmittedByteCount += pNullContext->BulkOutSize;
- pAd->RalinkCounters.TransmittedByteCount += pNullContext->BulkOutSize;
-
- // Clear ATE frame bulk out flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-
- // Init Tx context descriptor
- pNullContext->IRPPending = TRUE;
- RTUSBInitTxDesc(pAd, pNullContext, BulkOutPipeId, (usb_complete_t)ATE_RTUSBBulkOutDataPacketComplete);
- pUrb = pNullContext->pUrb;
-
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("ATE_RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret));
- return;
- }
-
- pAd->BulkOutReq++;
- return;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID ATE_RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd)
-{
- PRX_CONTEXT pRxContext;
- UINT i;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("--->ATE_RTUSBCancelPendingBulkInIRP\n"));
-#if 1
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- pRxContext = &(pAd->RxContext[i]);
- if(pRxContext->IRPPending == TRUE)
- {
- RTUSB_UNLINK_URB(pRxContext->pUrb);
- pRxContext->IRPPending = FALSE;
- pRxContext->InUse = FALSE;
- //NdisInterlockedDecrement(&pAd->PendingRx);
- //pAd->PendingRx--;
- }
- }
-#else
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- pRxContext = &(pAd->RxContext[i]);
- if(atomic_read(&pRxContext->IrpLock) == IRPLOCK_CANCELABLE)
- {
- RTUSB_UNLINK_URB(pRxContext->pUrb);
- }
- InterlockedExchange(&pRxContext->IrpLock, IRPLOCK_CANCE_START);
- }
-#endif // 1 //
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<---ATE_RTUSBCancelPendingBulkInIRP\n"));
- return;
-}
-#endif // RT2870 //
-
-VOID rt_ee_read_all(PRTMP_ADAPTER pAd, USHORT *Data)
-{
- USHORT i;
- USHORT value;
-
- for (i = 0 ; i < EEPROM_SIZE/2 ; )
- {
- /* "value" is expecially for some compilers... */
- RT28xx_EEPROM_READ16(pAd, i*2, value);
- Data[i] = value;
- i++;
- }
-}
-
-VOID rt_ee_write_all(PRTMP_ADAPTER pAd, USHORT *Data)
-{
- USHORT i;
- USHORT value;
-
- for (i = 0 ; i < EEPROM_SIZE/2 ; )
- {
- /* "value" is expecially for some compilers... */
- value = Data[i];
- RT28xx_EEPROM_WRITE16(pAd, i*2, value);
- i ++;
- }
-}
-#ifdef RALINK_28xx_QA
-VOID ATE_QA_Statistics(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC pRxD,
- IN PHEADER_802_11 pHeader)
-{
- // update counter first
- if (pHeader != NULL)
- {
- if (pHeader->FC.Type == BTYPE_DATA)
- {
- if (pRxD->U2M)
- pAd->ate.U2M++;
- else
- pAd->ate.OtherData++;
- }
- else if (pHeader->FC.Type == BTYPE_MGMT)
- {
- if (pHeader->FC.SubType == SUBTYPE_BEACON)
- pAd->ate.Beacon++;
- else
- pAd->ate.OtherCount++;
- }
- else if (pHeader->FC.Type == BTYPE_CNTL)
- {
- pAd->ate.OtherCount++;
- }
- }
- pAd->ate.RSSI0 = pRxWI->RSSI0;
- pAd->ate.RSSI1 = pRxWI->RSSI1;
- pAd->ate.RSSI2 = pRxWI->RSSI2;
- pAd->ate.SNR0 = pRxWI->SNR0;
- pAd->ate.SNR1 = pRxWI->SNR1;
-}
-
-/* command id with Cmd Type == 0x0008(for 28xx)/0x0005(for iNIC) */
-#define RACFG_CMD_RF_WRITE_ALL 0x0000
-#define RACFG_CMD_E2PROM_READ16 0x0001
-#define RACFG_CMD_E2PROM_WRITE16 0x0002
-#define RACFG_CMD_E2PROM_READ_ALL 0x0003
-#define RACFG_CMD_E2PROM_WRITE_ALL 0x0004
-#define RACFG_CMD_IO_READ 0x0005
-#define RACFG_CMD_IO_WRITE 0x0006
-#define RACFG_CMD_IO_READ_BULK 0x0007
-#define RACFG_CMD_BBP_READ8 0x0008
-#define RACFG_CMD_BBP_WRITE8 0x0009
-#define RACFG_CMD_BBP_READ_ALL 0x000a
-#define RACFG_CMD_GET_COUNTER 0x000b
-#define RACFG_CMD_CLEAR_COUNTER 0x000c
-
-#define RACFG_CMD_RSV1 0x000d
-#define RACFG_CMD_RSV2 0x000e
-#define RACFG_CMD_RSV3 0x000f
-
-#define RACFG_CMD_TX_START 0x0010
-#define RACFG_CMD_GET_TX_STATUS 0x0011
-#define RACFG_CMD_TX_STOP 0x0012
-#define RACFG_CMD_RX_START 0x0013
-#define RACFG_CMD_RX_STOP 0x0014
-#define RACFG_CMD_GET_NOISE_LEVEL 0x0015
-
-#define RACFG_CMD_ATE_START 0x0080
-#define RACFG_CMD_ATE_STOP 0x0081
-
-#define RACFG_CMD_ATE_START_TX_CARRIER 0x0100
-#define RACFG_CMD_ATE_START_TX_CONT 0x0101
-#define RACFG_CMD_ATE_START_TX_FRAME 0x0102
-#define RACFG_CMD_ATE_SET_BW 0x0103
-#define RACFG_CMD_ATE_SET_TX_POWER0 0x0104
-#define RACFG_CMD_ATE_SET_TX_POWER1 0x0105
-#define RACFG_CMD_ATE_SET_FREQ_OFFSET 0x0106
-#define RACFG_CMD_ATE_GET_STATISTICS 0x0107
-#define RACFG_CMD_ATE_RESET_COUNTER 0x0108
-#define RACFG_CMD_ATE_SEL_TX_ANTENNA 0x0109
-#define RACFG_CMD_ATE_SEL_RX_ANTENNA 0x010a
-#define RACFG_CMD_ATE_SET_PREAMBLE 0x010b
-#define RACFG_CMD_ATE_SET_CHANNEL 0x010c
-#define RACFG_CMD_ATE_SET_ADDR1 0x010d
-#define RACFG_CMD_ATE_SET_ADDR2 0x010e
-#define RACFG_CMD_ATE_SET_ADDR3 0x010f
-#define RACFG_CMD_ATE_SET_RATE 0x0110
-#define RACFG_CMD_ATE_SET_TX_FRAME_LEN 0x0111
-#define RACFG_CMD_ATE_SET_TX_FRAME_COUNT 0x0112
-#define RACFG_CMD_ATE_START_RX_FRAME 0x0113
-#define RACFG_CMD_ATE_E2PROM_READ_BULK 0x0114
-#define RACFG_CMD_ATE_E2PROM_WRITE_BULK 0x0115
-#define RACFG_CMD_ATE_IO_WRITE_BULK 0x0116
-#define RACFG_CMD_ATE_BBP_READ_BULK 0x0117
-#define RACFG_CMD_ATE_BBP_WRITE_BULK 0x0118
-#define RACFG_CMD_ATE_RF_READ_BULK 0x0119
-#define RACFG_CMD_ATE_RF_WRITE_BULK 0x011a
-
-
-
-#define A2Hex(_X, _p) \
-{ \
- UCHAR *p; \
- _X = 0; \
- p = _p; \
- while (((*p >= 'a') && (*p <= 'f')) || ((*p >= 'A') && (*p <= 'F')) || ((*p >= '0') && (*p <= '9'))) \
- { \
- if ((*p >= 'a') && (*p <= 'f')) \
- _X = _X * 16 + *p - 87; \
- else if ((*p >= 'A') && (*p <= 'F')) \
- _X = _X * 16 + *p - 55; \
- else if ((*p >= '0') && (*p <= '9')) \
- _X = _X * 16 + *p - 48; \
- p++; \
- } \
-}
-
-
-static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len);
-static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len);
-static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32 len);
-
-#ifdef UCOS
-int ate_copy_to_user(
- IN PUCHAR payload,
- IN PUCHAR msg,
- IN INT len)
-{
- memmove(payload, msg, len);
- return 0;
-}
-
-#undef copy_to_user
-#define copy_to_user(x,y,z) ate_copy_to_user((PUCHAR)x, (PUCHAR)y, z)
-#endif // UCOS //
-
-#define LEN_OF_ARG 16
-
-VOID RtmpDoAte(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- unsigned short Command_Id;
- struct ate_racfghdr *pRaCfg;
- INT Status = NDIS_STATUS_SUCCESS;
-
-
-
- if((pRaCfg = kmalloc(sizeof(struct ate_racfghdr), GFP_KERNEL)) == NULL)
- {
- Status = -EINVAL;
- return;
- }
-
- NdisZeroMemory(pRaCfg, sizeof(struct ate_racfghdr));
-
- if (copy_from_user((PUCHAR)pRaCfg, wrq->u.data.pointer, wrq->u.data.length))
- {
- Status = -EFAULT;
- kfree(pRaCfg);
- return;
- }
-
-
- Command_Id = ntohs(pRaCfg->command_id);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __func__, Command_Id));
-
- switch (Command_Id)
- {
- // We will get this command when QA starts.
- case RACFG_CMD_ATE_START:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START\n"));
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_ATE_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START is done !\n"));
- }
- Set_ATE_Proc(pAdapter, "ATESTART");
- }
- break;
-
- // We will get this command either QA is closed or ated is killed by user.
- case RACFG_CMD_ATE_STOP:
- {
-#ifndef UCOS
- INT32 ret;
-#endif // !UCOS //
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_STOP\n"));
-
- // Distinguish this command came from QA(via ated)
- // or ate daemon according to the existence of pid in payload.
- // No need to prepare feedback if this cmd came directly from ate daemon.
- pRaCfg->length = ntohs(pRaCfg->length);
-
- if (pRaCfg->length == sizeof(pAdapter->ate.AtePid))
- {
- // This command came from QA.
- // Get the pid of ATE daemon.
- memcpy((UCHAR *)&pAdapter->ate.AtePid,
- (&pRaCfg->data[0]) - 2/* == &(pRaCfg->status) */,
- sizeof(pAdapter->ate.AtePid));
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_STOP\n"));
- Status = -EFAULT;
- }
-
- //
- // kill ATE daemon when leaving ATE mode.
- // We must kill ATE daemon first before setting ATESTOP,
- // or Microsoft will report sth. wrong.
-#ifndef UCOS
- ret = KILL_THREAD_PID(pAdapter->ate.AtePid, SIGTERM, 1);
- if (ret)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("%s: unable to signal thread\n", pAdapter->net_dev->name));
- }
-#endif // !UCOS //
- }
-
- // AP might have in ATE_STOP mode due to cmd from QA.
- if (ATE_ON(pAdapter))
- {
- // Someone has killed ate daemon while QA GUI is still open.
- Set_ATE_Proc(pAdapter, "ATESTOP");
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_AP_START is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RF_WRITE_ALL:
- {
- UINT32 R1, R2, R3, R4;
- USHORT channel;
-
- memcpy(&R1, pRaCfg->data-2, 4);
- memcpy(&R2, pRaCfg->data+2, 4);
- memcpy(&R3, pRaCfg->data+6, 4);
- memcpy(&R4, pRaCfg->data+10, 4);
- memcpy(&channel, pRaCfg->data+14, 2);
-
- pAdapter->LatchRfRegs.R1 = ntohl(R1);
- pAdapter->LatchRfRegs.R2 = ntohl(R2);
- pAdapter->LatchRfRegs.R3 = ntohl(R3);
- pAdapter->LatchRfRegs.R4 = ntohl(R4);
- pAdapter->LatchRfRegs.Channel = ntohs(channel);
-
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R3);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R4);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RF_WRITE_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RF_WRITE_ALL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_READ16:
- {
- USHORT offset, value, tmp;
-
- offset = ntohs(pRaCfg->status);
- /* "tmp" is expecially for some compilers... */
- RT28xx_EEPROM_READ16(pAdapter, offset, tmp);
- value = tmp;
- value = htons(value);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("EEPROM Read offset = 0x%04x, value = 0x%04x\n", offset, value));
-
- // prepare feedback
- pRaCfg->length = htons(4);
- pRaCfg->status = htons(0);
- memcpy(pRaCfg->data, &value, 2);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("sizeof(struct ate_racfghdr) = %d\n", sizeof(struct ate_racfghdr)));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ16\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_READ16 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_WRITE16:
- {
- USHORT offset, value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&value, pRaCfg->data, 2);
- value = ntohs(value);
- RT28xx_EEPROM_WRITE16(pAdapter, offset, value);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE16\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_WRITE16 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_READ_ALL:
- {
- USHORT buffer[EEPROM_SIZE/2];
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer, EEPROM_SIZE);
-
- // prepare feedback
- pRaCfg->length = htons(2+EEPROM_SIZE);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_READ_ALL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_WRITE_ALL:
- {
- USHORT buffer[EEPROM_SIZE/2];
-
- NdisZeroMemory((UCHAR *)buffer, EEPROM_SIZE);
- memcpy_exs(pAdapter, (UCHAR *)buffer, (UCHAR *)&pRaCfg->status, EEPROM_SIZE);
- rt_ee_write_all(pAdapter,(USHORT *)buffer);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_E2PROM_WRITE_ALL is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_IO_READ:
- {
- UINT32 offset;
- UINT32 value;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract the offset out.
- offset &= 0x0000FFFF;
- RTMP_IO_READ32(pAdapter, offset, &value);
- value = htonl(value);
-
- // prepare feedback
- pRaCfg->length = htons(6);
- pRaCfg->status = htons(0);
- memcpy(pRaCfg->data, &value, 4);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_READ\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_READ is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_IO_WRITE:
- {
- UINT32 offset, value;
-
- memcpy(&offset, pRaCfg->data-2, 4);
- memcpy(&value, pRaCfg->data+2, 4);
-
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract out the offset.
- offset &= 0x0000FFFF;
- value = ntohl(value);
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_IO_WRITE: offset = %x, value = %x\n", offset, value));
- RTMP_IO_WRITE32(pAdapter, offset, value);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_WRITE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_WRITE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_IO_READ_BULK:
- {
- UINT32 offset;
- USHORT len;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract the offset.
- offset &= 0x0000FFFF;
- memcpy(&len, pRaCfg->data+2, 2);
- len = ntohs(len);
-
- if (len > 371)
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("len is too large, make it smaller\n"));
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(1);
- break;
- }
-
- RTMP_IO_READ_BULK(pAdapter, pRaCfg->data, (UCHAR *)offset, len*4);// unit in four bytes
-
- // prepare feedback
- pRaCfg->length = htons(2+len*4);// unit in four bytes
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_READ_BULK is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_BBP_READ8:
- {
- USHORT offset;
- UCHAR value;
-
- value = 0;
- offset = ntohs(pRaCfg->status);
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, offset, &value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, offset, &value);
- }
- // prepare feedback
- pRaCfg->length = htons(3);
- pRaCfg->status = htons(0);
- pRaCfg->data[0] = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("BBP value = %x\n", value));
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_READ8\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_READ8 is done !\n"));
- }
- }
- break;
- case RACFG_CMD_BBP_WRITE8:
- {
- USHORT offset;
- UCHAR value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&value, pRaCfg->data, 1);
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, offset, value);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, offset, value);
- }
-
- if ((offset == BBP_R1) || (offset == BBP_R3))
- {
- SyncTxRxConfig(pAdapter, offset, value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_WRITE8\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_WRITE8 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_BBP_READ_ALL:
- {
- USHORT j;
-
- for (j = 0; j < 137; j++)
- {
- pRaCfg->data[j] = 0;
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j]);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j]);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+137);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_READ_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_READ_ALL is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_ATE_E2PROM_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT buffer[EEPROM_SIZE/2];
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- if (offset + len <= EEPROM_SIZE)
- memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer+offset, len);
- else
- ATEDBGPRINT(RT_DEBUG_ERROR, ("exceed EEPROM size\n"));
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_E2PROM_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_E2PROM_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT buffer[EEPROM_SIZE/2];
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- memcpy_exs(pAdapter, (UCHAR *)buffer + offset, (UCHAR *)pRaCfg->data + 2, len);
- rt_ee_write_all(pAdapter,(USHORT *)buffer);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_ATE_E2PROM_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_IO_WRITE_BULK:
- {
- UINT32 offset, i, value;
- USHORT len;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
- memcpy(&len, pRaCfg->data+2, 2);
- len = ntohs(len);
-
- for (i = 0; i < len; i += 4)
- {
- memcpy_exl(pAdapter, (UCHAR *)&value, pRaCfg->data+4+i, 4);
- printk("Write %x %x\n", offset + i, value);
- RTMP_IO_WRITE32(pAdapter, (offset +i) & 0xffff, value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_IO_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_ATE_IO_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_BBP_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
-
- for (j = offset; j < (offset+len); j++)
- {
- pRaCfg->data[j - offset] = 0;
-
- if (pAdapter->ate.Mode == ATE_STOP)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j - offset]);
- }
- else
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j - offset]);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_BBP_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_BBP_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
- UCHAR *value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- value = pRaCfg->data + 2 + (j - offset);
- if (pAdapter->ate.Mode == ATE_STOP)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, j, *value);
- }
- else
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, j, *value);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_BBP_WRITE_BULK is done !\n"));
- }
- }
- break;
-
-#ifdef CONFIG_RALINK_RT3052
- case RACFG_CMD_ATE_RF_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- pRaCfg->data[j - offset] = 0;
- RT30xxReadRFRegister(pAdapter, j, &pRaCfg->data[j - offset]);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RF_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_RF_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
- UCHAR *value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- value = pRaCfg->data + 2 + (j - offset);
- RT30xxWriteRFRegister(pAdapter, j, *value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RF_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-#endif
-
-
- case RACFG_CMD_GET_NOISE_LEVEL:
- {
- UCHAR channel;
- INT32 buffer[3][10];/* 3 : RxPath ; 10 : no. of per rssi samples */
-
- channel = (ntohs(pRaCfg->status) & 0x00FF);
- CalNoiseLevel(pAdapter, channel, buffer);
- memcpy_exl(pAdapter, (UCHAR *)pRaCfg->data, (UCHAR *)&(buffer[0][0]), (sizeof(INT32)*3*10));
-
- // prepare feedback
- pRaCfg->length = htons(2 + (sizeof(INT32)*3*10));
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_NOISE_LEVEL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_NOISE_LEVEL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_GET_COUNTER:
- {
- memcpy_exl(pAdapter, &pRaCfg->data[0], (UCHAR *)&pAdapter->ate.U2M, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[4], (UCHAR *)&pAdapter->ate.OtherData, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[8], (UCHAR *)&pAdapter->ate.Beacon, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[12], (UCHAR *)&pAdapter->ate.OtherCount, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[16], (UCHAR *)&pAdapter->ate.TxAc0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[20], (UCHAR *)&pAdapter->ate.TxAc1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[24], (UCHAR *)&pAdapter->ate.TxAc2, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->ate.TxAc3, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->ate.TxHCCA, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->ate.TxMgmt, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&pAdapter->ate.RSSI0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[44], (UCHAR *)&pAdapter->ate.RSSI1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&pAdapter->ate.RSSI2, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[52], (UCHAR *)&pAdapter->ate.SNR0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[56], (UCHAR *)&pAdapter->ate.SNR1, 4);
-
- pRaCfg->length = htons(2+60);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_COUNTER is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_CLEAR_COUNTER:
- {
- pAdapter->ate.U2M = 0;
- pAdapter->ate.OtherData = 0;
- pAdapter->ate.Beacon = 0;
- pAdapter->ate.OtherCount = 0;
- pAdapter->ate.TxAc0 = 0;
- pAdapter->ate.TxAc1 = 0;
- pAdapter->ate.TxAc2 = 0;
- pAdapter->ate.TxAc3 = 0;
- pAdapter->ate.TxHCCA = 0;
- pAdapter->ate.TxMgmt = 0;
- pAdapter->ate.TxDoneCount = 0;
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_CLEAR_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_CLEAR_COUNTER is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_TX_START:
- {
- USHORT *p;
- USHORT err = 1;
- UCHAR Bbp22Value = 0, Bbp24Value = 0;
-
- if ((pAdapter->ate.TxStatus != 0) && (pAdapter->ate.Mode & ATE_TXFRAME))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("Ate Tx is already running, to run next Tx, you must stop it first\n"));
- err = 2;
- goto TX_START_ERROR;
- }
- else if ((pAdapter->ate.TxStatus != 0) && !(pAdapter->ate.Mode & ATE_TXFRAME))
- {
- int i = 0;
-
- while ((i++ < 10) && (pAdapter->ate.TxStatus != 0))
- {
- RTMPusecDelay(5000);
- }
-
- // force it to stop
- pAdapter->ate.TxStatus = 0;
- pAdapter->ate.TxDoneCount = 0;
- //pAdapter->ate.Repeat = 0;
- pAdapter->ate.bQATxStart = FALSE;
- }
-
- // If pRaCfg->length == 0, this "RACFG_CMD_TX_START" is for Carrier test or Carrier Suppression.
- if (ntohs(pRaCfg->length) != 0)
- {
- // Get frame info
-#ifdef RT2870
- NdisMoveMemory(&pAdapter->ate.TxInfo, pRaCfg->data - 2, 4);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR) &pAdapter->ate.TxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-#endif // RT2870 //
-
- NdisMoveMemory(&pAdapter->ate.TxWI, pRaCfg->data + 2, 16);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)&pAdapter->ate.TxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
- NdisMoveMemory(&pAdapter->ate.TxCount, pRaCfg->data + 18, 4);
- pAdapter->ate.TxCount = ntohl(pAdapter->ate.TxCount);
-
- p = (USHORT *)(&pRaCfg->data[22]);
- //p = pRaCfg->data + 22;
- // always use QID_AC_BE
- pAdapter->ate.QID = 0;
- p = (USHORT *)(&pRaCfg->data[24]);
- //p = pRaCfg->data + 24;
- pAdapter->ate.HLen = ntohs(*p);
-
- if (pAdapter->ate.HLen > 32)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("pAdapter->ate.HLen > 32\n"));
- err = 3;
- goto TX_START_ERROR;
- }
-
- NdisMoveMemory(&pAdapter->ate.Header, pRaCfg->data + 26, pAdapter->ate.HLen);
-
-
- pAdapter->ate.PLen = ntohs(pRaCfg->length) - (pAdapter->ate.HLen + 28);
-
- if (pAdapter->ate.PLen > 32)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("pAdapter->ate.PLen > 32\n"));
- err = 4;
- goto TX_START_ERROR;
- }
-
- NdisMoveMemory(&pAdapter->ate.Pattern, pRaCfg->data + 26 + pAdapter->ate.HLen, pAdapter->ate.PLen);
- pAdapter->ate.DLen = pAdapter->ate.TxWI.MPDUtotalByteCount - pAdapter->ate.HLen;
- }
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R22, &Bbp22Value);
-
- switch (Bbp22Value)
- {
- case BBP22_TXFRAME:
- {
- if (pAdapter->ate.TxCount == 0)
- {
- }
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXFRAME\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXFRAME");
- }
- break;
-
- case BBP22_TXCONT_OR_CARRSUPP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("BBP22_TXCONT_OR_CARRSUPP\n"));
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, 24, &Bbp24Value);
-
- switch (Bbp24Value)
- {
- case BBP24_TXCONT:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCONT\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXCONT");
- }
- break;
-
- case BBP24_CARRSUPP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCARRSUPP\n"));
- pAdapter->ate.bQATxStart = TRUE;
- pAdapter->ate.Mode |= ATE_TXCARRSUPP;
- }
- break;
-
- default:
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("Unknown Start TX subtype !"));
- }
- break;
- }
- }
- break;
-
- case BBP22_TXCARR:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCARR\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXCARR");
- }
- break;
-
- default:
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("Unknown Start TX subtype !"));
- }
- break;
- }
-
- if (pAdapter->ate.bQATxStart == TRUE)
- {
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() was failed in case RACFG_CMD_TX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_TX_START is done !\n"));
- }
- break;
- }
-
-TX_START_ERROR:
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(err);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_TX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("feedback of TX_START_ERROR is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_GET_TX_STATUS:
- {
- UINT32 count;
-
- // prepare feedback
- pRaCfg->length = htons(6);
- pRaCfg->status = htons(0);
- count = htonl(pAdapter->ate.TxDoneCount);
- NdisMoveMemory(pRaCfg->data, &count, 4);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_TX_STATUS\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_TX_STATUS is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_TX_STOP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_TX_STOP\n"));
-
- Set_ATE_Proc(pAdapter, "TXSTOP");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_TX_STOP\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_TX_STOP is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RX_START:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
-
- pAdapter->ate.bQARxStart = TRUE;
- Set_ATE_Proc(pAdapter, "RXFRAME");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_START is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RX_STOP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_STOP\n"));
-
- Set_ATE_Proc(pAdapter, "RXSTOP");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_STOP\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_STOP is done !\n"));
- }
- }
- break;
-
- /* The following cases are for new ATE GUI(not QA). */
- /*==================================================*/
- case RACFG_CMD_ATE_START_TX_CARRIER:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CARRIER\n"));
-
- Set_ATE_Proc(pAdapter, "TXCARR");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CARRIER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_CARRIER is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_TX_CONT:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CONT\n"));
-
- Set_ATE_Proc(pAdapter, "TXCONT");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CONT\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_CONT is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_TX_FRAME:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_FRAME\n"));
-
- Set_ATE_Proc(pAdapter, "TXFRAME");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_FRAME\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_FRAME is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_BW:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_BW\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
-
- Set_ATE_TX_BW_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_BW\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_BW is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_POWER0:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER0\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_POWER0_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER0\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_POWER0 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_POWER1:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER1\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_POWER1_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER1\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_POWER1 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_FREQ_OFFSET:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_FREQOFFSET_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_FREQ_OFFSET is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_GET_STATISTICS:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_GET_STATISTICS\n"));
-
- memcpy_exl(pAdapter, &pRaCfg->data[0], (UCHAR *)&pAdapter->ate.TxDoneCount, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[4], (UCHAR *)&pAdapter->WlanCounters.RetryCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[8], (UCHAR *)&pAdapter->WlanCounters.FailedCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[12], (UCHAR *)&pAdapter->WlanCounters.RTSSuccessCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[16], (UCHAR *)&pAdapter->WlanCounters.RTSFailureCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[20], (UCHAR *)&pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[24], (UCHAR *)&pAdapter->WlanCounters.FCSErrorCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->Counters8023.RxNoBuffer, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->RalinkCounters.OneSecFalseCCACnt, 4);
-
- if (pAdapter->ate.RxAntennaSel == 0)
- {
- INT32 RSSI0 = 0;
- INT32 RSSI1 = 0;
- INT32 RSSI2 = 0;
-
- RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
- RSSI1 = (INT32)(pAdapter->ate.LastRssi1 - pAdapter->BbpRssiToDbmDelta);
- RSSI2 = (INT32)(pAdapter->ate.LastRssi2 - pAdapter->BbpRssiToDbmDelta);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[44], (UCHAR *)&RSSI1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&RSSI2, 4);
- pRaCfg->length = htons(2+52);
- }
- else
- {
- INT32 RSSI0 = 0;
-
- RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
- pRaCfg->length = htons(2+44);
- }
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_GET_STATISTICS\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_GET_STATISTICS is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_RESET_COUNTER:
- {
- SHORT value = 1;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_RESET_COUNTER\n"));
-
- sprintf((PCHAR)str, "%d", value);
- Set_ResetStatCounter_Proc(pAdapter, str);
-
- pAdapter->ate.TxDoneCount = 0;
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RESET_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RESET_COUNTER is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_ATE_SEL_TX_ANTENNA:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_Antenna_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SEL_TX_ANTENNA is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SEL_RX_ANTENNA:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_RX_Antenna_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SEL_RX_ANTENNA is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_PREAMBLE:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_PREAMBLE\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_MODE_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_PREAMBLE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_PREAMBLE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_CHANNEL:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_CHANNEL\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_CHANNEL_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_CHANNEL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_CHANNEL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR1:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR1\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr1, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR1\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR1 is done !\n (ADDR1 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr1[0],
- pAdapter->ate.Addr1[1], pAdapter->ate.Addr1[2], pAdapter->ate.Addr1[3], pAdapter->ate.Addr1[4], pAdapter->ate.Addr1[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR2:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR2\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr2, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR2\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR2 is done !\n (ADDR2 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr2[0],
- pAdapter->ate.Addr2[1], pAdapter->ate.Addr2[2], pAdapter->ate.Addr2[3], pAdapter->ate.Addr2[4], pAdapter->ate.Addr2[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR3:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR3\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr3, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR3\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR3 is done !\n (ADDR3 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr3[0],
- pAdapter->ate.Addr3[1], pAdapter->ate.Addr3[2], pAdapter->ate.Addr3[3], pAdapter->ate.Addr3[4], pAdapter->ate.Addr3[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_RATE:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_RATE\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_MCS_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_RATE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_RATE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_FRAME_LEN:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_LENGTH_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_FRAME_LEN is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_FRAME_COUNT:
- {
- USHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- {
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_COUNT_Proc(pAdapter, str);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_FRAME_COUNT is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_RX_FRAME:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
-
- Set_ATE_Proc(pAdapter, "RXFRAME");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_START is done !\n"));
- }
- }
- break;
- default:
- break;
- }
- ASSERT(pRaCfg != NULL);
- if (pRaCfg != NULL)
- {
- kfree(pRaCfg);
- }
- return;
-}
-
-VOID BubbleSort(INT32 n, INT32 a[])
-{
- INT32 k, j, temp;
-
- for (k = n-1; k>0; k--)
- {
- for (j = 0; j<k; j++)
- {
- if(a[j] > a[j+1])
- {
- temp = a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- }
- }
- }
-}
-
-VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
-{
- INT32 RSSI0, RSSI1, RSSI2;
- CHAR Rssi0Offset, Rssi1Offset, Rssi2Offset;
- UCHAR BbpR50Rssi0 = 0, BbpR51Rssi1 = 0, BbpR52Rssi2 = 0;
- UCHAR Org_BBP66value = 0, Org_BBP69value = 0, Org_BBP70value = 0, data = 0;
- USHORT LNA_Gain = 0;
- INT32 j = 0;
- UCHAR Org_Channel = pAd->ate.Channel;
- USHORT GainValue = 0, OffsetValue = 0;
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &Org_BBP66value);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R69, &Org_BBP69value);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R70, &Org_BBP70value);
-
- //**********************************************************************
- // Read the value of LNA gain and Rssi offset
- //**********************************************************************
- RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, GainValue);
-
- // for Noise Level
- if (channel <= 14)
- {
- LNA_Gain = GainValue & 0x00FF;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, OffsetValue);
- Rssi0Offset = OffsetValue & 0x00FF;
- Rssi1Offset = (OffsetValue & 0xFF00) >> 8;
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_BG_OFFSET + 2)/* 0x48 */, OffsetValue);
- Rssi2Offset = OffsetValue & 0x00FF;
- }
- else
- {
- LNA_Gain = (GainValue & 0xFF00) >> 8;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, OffsetValue);
- Rssi0Offset = OffsetValue & 0x00FF;
- Rssi1Offset = (OffsetValue & 0xFF00) >> 8;
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET + 2)/* 0x4C */, OffsetValue);
- Rssi2Offset = OffsetValue & 0x00FF;
- }
- //**********************************************************************
- {
- pAd->ate.Channel = channel;
- ATEAsicSwitchChannel(pAd);
- mdelay(5);
-
- data = 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, data);
- data = 0x40;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, data);
- data = 0x40;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, data);
- mdelay(5);
-
- // Start Rx
- pAd->ate.bQARxStart = TRUE;
- Set_ATE_Proc(pAd, "RXFRAME");
-
- mdelay(5);
-
- for (j = 0; j < 10; j++)
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R50, &BbpR50Rssi0);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R51, &BbpR51Rssi1);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R52, &BbpR52Rssi2);
-
- mdelay(10);
-
- // Calculate RSSI 0
- if (BbpR50Rssi0 == 0)
- {
- RSSI0 = -100;
- }
- else
- {
- RSSI0 = (INT32)(-12 - BbpR50Rssi0 - LNA_Gain - Rssi0Offset);
- }
- RSSI[0][j] = RSSI0;
-
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- // Calculate RSSI 1
- if (BbpR51Rssi1 == 0)
- {
- RSSI1 = -100;
- }
- else
- {
- RSSI1 = (INT32)(-12 - BbpR51Rssi1 - LNA_Gain - Rssi1Offset);
- }
- RSSI[1][j] = RSSI1;
- }
-
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- // Calculate RSSI 2
- if (BbpR52Rssi2 == 0)
- RSSI2 = -100;
- else
- RSSI2 = (INT32)(-12 - BbpR52Rssi2 - LNA_Gain - Rssi2Offset);
-
- RSSI[2][j] = RSSI2;
- }
- }
-
- // Stop Rx
- Set_ATE_Proc(pAd, "RXSTOP");
-
- mdelay(5);
-
-#if 0// Debug Message................
- ate_print("\n**********************************************************\n");
- ate_print("Noise Level: Channel %d\n", channel);
- ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[0][0], RSSI[0][1], RSSI[0][2],
- RSSI[0][3], RSSI[0][4], RSSI[0][5],
- RSSI[0][6], RSSI[0][7], RSSI[0][8],
- RSSI[0][9]);
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[1][0], RSSI[1][1], RSSI[1][2],
- RSSI[1][3], RSSI[1][4], RSSI[1][5],
- RSSI[1][6], RSSI[1][7], RSSI[1][8],
- RSSI[1][9]);
- }
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[2][0], RSSI[2][1], RSSI[2][2],
- RSSI[2][3], RSSI[2][4], RSSI[2][5],
- RSSI[2][6], RSSI[2][7], RSSI[2][8],
- RSSI[2][9]);
- }
-#endif // 0 //
- BubbleSort(10, RSSI[0]); // 1R
-
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- BubbleSort(10, RSSI[1]);
- }
-
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- BubbleSort(10, RSSI[2]);
- }
-
-#if 0// Debug Message................
- ate_print("\nAfter Sorting....Channel %d\n", channel);
- ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[0][0], RSSI[0][1], RSSI[0][2],
- RSSI[0][3], RSSI[0][4], RSSI[0][5],
- RSSI[0][6], RSSI[0][7], RSSI[0][8],
- RSSI[0][9]);
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[1][0], RSSI[1][1], RSSI[1][2],
- RSSI[1][3], RSSI[1][4], RSSI[1][5],
- RSSI[1][6], RSSI[1][7], RSSI[1][8],
- RSSI[1][9]);
- }
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
- RSSI[2][0], RSSI[2][1], RSSI[2][2],
- RSSI[2][3], RSSI[2][4], RSSI[2][5],
- RSSI[2][6], RSSI[2][7], RSSI[2][8],
- RSSI[2][9]);
- }
- ate_print("**********************************************************\n");
-#endif // 0 //
- }
-
- pAd->ate.Channel = Org_Channel;
- ATEAsicSwitchChannel(pAd);
-
- // Restore original value
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, Org_BBP66value);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, Org_BBP69value);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, Org_BBP70value);
-
- return;
-}
-
-BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
-{
- UCHAR tmp = 0, bbp_data = 0;
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, offset, &bbp_data);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, offset, &bbp_data);
- }
-
- /* confirm again */
- ASSERT(bbp_data == value);
-
- switch(offset)
- {
- case BBP_R1:
- /* Need to sync. tx configuration with legacy ATE. */
- tmp = (bbp_data & ((1 << 4) | (1 << 3))/* 0x18 */) >> 3;
- switch(tmp)
- {
- /* The BBP R1 bit[4:3] = 2 :: Both DACs will be used by QA. */
- case 2:
- /* All */
- pAd->ate.TxAntennaSel = 0;
- break;
- /* The BBP R1 bit[4:3] = 0 :: DAC 0 will be used by QA. */
- case 0:
- /* Antenna one */
- pAd->ate.TxAntennaSel = 1;
- break;
- /* The BBP R1 bit[4:3] = 1 :: DAC 1 will be used by QA. */
- case 1:
- /* Antenna two */
- pAd->ate.TxAntennaSel = 2;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
- return FALSE;
- }
- break;/* case BBP_R1 */
-
- case BBP_R3:
- /* Need to sync. rx configuration with legacy ATE. */
- tmp = (bbp_data & ((1 << 1) | (1 << 0))/* 0x03 */);
- switch(tmp)
- {
- /* The BBP R3 bit[1:0] = 3 :: All ADCs will be used by QA. */
- case 3:
- /* All */
- pAd->ate.RxAntennaSel = 0;
- break;
- /* The BBP R3 bit[1:0] = 0 :: ADC 0 will be used by QA, */
- /* unless the BBP R3 bit[4:3] = 2 */
- case 0:
- /* Antenna one */
- pAd->ate.RxAntennaSel = 1;
- tmp = ((bbp_data & ((1 << 4) | (1 << 3))/* 0x03 */) >> 3);
- if (tmp == 2)// 3R
- {
- /* Default : All ADCs will be used by QA */
- pAd->ate.RxAntennaSel = 0;
- }
- break;
- /* The BBP R3 bit[1:0] = 1 :: ADC 1 will be used by QA. */
- case 1:
- /* Antenna two */
- pAd->ate.RxAntennaSel = 2;
- break;
- /* The BBP R3 bit[1:0] = 2 :: ADC 2 will be used by QA. */
- case 2:
- /* Antenna three */
- pAd->ate.RxAntennaSel = 3;
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __func__));
- return FALSE;
- }
- break;/* case BBP_R3 */
-
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
- return FALSE;
-
- }
- return TRUE;
-}
-
-static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
-{
- ULONG i, Value = 0;
- ULONG *pDst, *pSrc;
- UCHAR *p8;
-
- p8 = src;
- pDst = (ULONG *) dst;
- pSrc = (ULONG *) src;
-
- for (i = 0 ; i < (len/4); i++)
- {
- /* For alignment issue, we need a variable "Value". */
- memmove(&Value, pSrc, 4);
- Value = htonl(Value);
- memmove(pDst, &Value, 4);
- pDst++;
- pSrc++;
- }
- if ((len % 4) != 0)
- {
- /* wish that it will never reach here */
- memmove(&Value, pSrc, (len % 4));
- Value = htonl(Value);
- memmove(pDst, &Value, (len % 4));
- }
-}
-
-static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
-{
- ULONG i;
- UCHAR *pDst, *pSrc;
-
- pDst = dst;
- pSrc = src;
-
- for (i = 0; i < (len/2); i++)
- {
- memmove(pDst, pSrc, 2);
- *((USHORT *)pDst) = htons(*((USHORT *)pDst));
- pDst+=2;
- pSrc+=2;
- }
-
- if ((len % 2) != 0)
- {
- memmove(pDst, pSrc, 1);
- }
-}
-
-static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32 len)
-{
- UINT32 i, Value;
- UINT32 *pDst, *pSrc;
-
- pDst = (UINT32 *) dst;
- pSrc = (UINT32 *) src;
-
- for (i = 0 ; i < (len/4); i++)
- {
- RTMP_IO_READ32(pAd, (ULONG)pSrc, &Value);
- Value = htonl(Value);
- memmove(pDst, &Value, 4);
- pDst++;
- pSrc++;
- }
- return;
-}
-
-// TODO:
-#if 0
-/* These work only when RALINK_ATE is defined */
-INT Set_TxStart_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG value = simple_strtol(arg, 0, 10);
- UCHAR buffer[26] = {0x88, 0x02, 0x2c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x55, 0x44, 0x33, 0x22, 0x11, 0xc0, 0x22, 0x00, 0x00};
- POS_COOKIE pObj;
-
- if (pAd->ate.TxStatus != 0)
- return FALSE;
-
- pAd->ate.TxInfo = 0x04000000;
- bzero(&pAd->ate.TxWI, sizeof(TXWI_STRUC));
- pAd->ate.TxWI.PHYMODE = 0;// MODE_CCK
- pAd->ate.TxWI.MPDUtotalByteCount = 1226;
- pAd->ate.TxWI.MCS = 3;
- //pAd->ate.Mode = ATE_START;
- pAd->ate.Mode |= ATE_TXFRAME;
- pAd->ate.TxCount = value;
- pAd->ate.QID = 0;
- pAd->ate.HLen = 26;
- pAd->ate.PLen = 0;
- pAd->ate.DLen = 1200;
- memcpy(pAd->ate.Header, buffer, 26);
- pAd->ate.bQATxStart = TRUE;
- //pObj = (POS_COOKIE) pAd->OS_Cookie;
- //tasklet_hi_schedule(&pObj->AteTxTask);
- return TRUE;
-}
-#endif /* end of #if 0 */
-
-INT Set_TxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE,("Set_TxStop_Proc\n"));
-
- if (Set_ATE_Proc(pAd, "TXSTOP"))
- {
- return TRUE;
-}
- else
- {
- return FALSE;
- }
-}
-
-INT Set_RxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE,("Set_RxStop_Proc\n"));
-
- if (Set_ATE_Proc(pAd, "RXSTOP"))
- {
- return TRUE;
-}
- else
- {
- return FALSE;
- }
-}
-
-#if 0
-INT Set_EEWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT offset = 0, value;
- PUCHAR p2 = arg;
-
- while((*p2 != ':') && (*p2 != '\0'))
- {
- p2++;
- }
-
- if (*p2 == ':')
- {
- A2Hex(offset, arg);
- A2Hex(value, p2+ 1);
- }
- else
- {
- A2Hex(value, arg);
- }
-
- if (offset >= EEPROM_SIZE)
- {
- ate_print("Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE);
- return FALSE;
- }
-
- RTMP_EEPROM_WRITE16(pAd, offset, value);
-
- return TRUE;
-}
-
-INT Set_BBPRead_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR value = 0, offset;
-
- A2Hex(offset, arg);
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, offset, &value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, offset, &value);
- }
-
- ate_print("%x\n", value);
-
- return TRUE;
-}
-
-
-INT Set_BBPWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT offset = 0;
- PUCHAR p2 = arg;
- UCHAR value;
-
- while((*p2 != ':') && (*p2 != '\0'))
- {
- p2++;
- }
-
- if (*p2 == ':')
- {
- A2Hex(offset, arg);
- A2Hex(value, p2+ 1);
- }
- else
- {
- A2Hex(value, arg);
- }
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, offset, value);
- }
- else
- {
- RTNP_BBP_IO_WRITE8_BY_REG_ID(pAd, offset, value);
- }
-
- return TRUE;
-}
-
-INT Set_RFWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- PUCHAR p2, p3, p4;
- ULONG R1, R2, R3, R4;
-
- p2 = arg;
-
- while((*p2 != ':') && (*p2 != '\0'))
- {
- p2++;
- }
-
- if (*p2 != ':')
- return FALSE;
-
- p3 = p2 + 1;
-
- while((*p3 != ':') && (*p3 != '\0'))
- {
- p3++;
- }
-
- if (*p3 != ':')
- return FALSE;
-
- p4 = p3 + 1;
-
- while((*p4 != ':') && (*p4 != '\0'))
- {
- p4++;
- }
-
- if (*p4 != ':')
- return FALSE;
-
-
- A2Hex(R1, arg);
- A2Hex(R2, p2 + 1);
- A2Hex(R3, p3 + 1);
- A2Hex(R4, p4 + 1);
-
- RTMP_RF_IO_WRITE32(pAd, R1);
- RTMP_RF_IO_WRITE32(pAd, R2);
- RTMP_RF_IO_WRITE32(pAd, R3);
- RTMP_RF_IO_WRITE32(pAd, R4);
-
- return TRUE;
-}
-#endif // end of #if 0 //
-#endif // RALINK_28xx_QA //
-
-#endif // RALINK_ATE //
-
diff --git a/drivers/staging/rt2870/rt_ate.h b/drivers/staging/rt2870/rt_ate.h
deleted file mode 100644
index b618ce3599ac..000000000000
--- a/drivers/staging/rt2870/rt_ate.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __ATE_H__
-#define __ATE_H__
-
-#ifndef UCOS
-#define ate_print printk
-#define ATEDBGPRINT DBGPRINT
-
-#ifdef RT2870
-#define EEPROM_SIZE 0x400
-#ifdef CONFIG_STA_SUPPORT
-#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2870STA/e2p.bin"
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
-#else // !UCOS //
-#define fATE_LOAD_EEPROM 0x0C43
-#ifdef CONFIG_PRINTK
-extern INT ConsoleResponse(IN PUCHAR buff);
-extern int (*remote_display)(char *);
-extern void puts (const char *s);
-
-/* specificly defined to redirect and show ate-related messages to host. */
-/* Try to define ate_print as a macro. */
-#define ate_print(fmt, args...) \
-do{ int (*org_remote_display)(char *) = NULL; \
- org_remote_display = remote_display;\
- /* Save original "remote_display" */\
- remote_display = (int (*)(char *))ConsoleResponse; \
- printk(fmt, ## args); \
- /* Restore the remote_display function pointer */ \
- remote_display = org_remote_display; }while(0)
-
-#define ATEDBGPRINT(Level, Fmt) \
-{ \
- if ((Level) <= RTDebugLevel) \
- { \
- ate_print Fmt; \
- } \
-}
-#endif // CONFIG_PRINTK //
-#endif // !UCOS //
-
-#define ATE_ON(_p) (((_p)->ate.Mode) != ATE_STOP)
-
-/* RT2880_iNIC will define "RT2860". */
-
-/* RT2880_iNIC will define RT2860. */
-
-#ifdef RT2870
-#define EEPROM_SIZE 0x400
-#ifdef CONFIG_STA_SUPPORT
-#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2870STA/e2p.bin"
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
-
-#ifdef RT2870
-#define ATE_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)
-#define ATE_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)
-
-#define BULK_OUT_LOCK(pLock, IrqFlags) \
- if(1 /*!(in_interrupt() & 0xffff0000)*/) \
- RTMP_IRQ_LOCK((pLock), IrqFlags);
-
-#define BULK_OUT_UNLOCK(pLock, IrqFlags) \
- if(1 /*!(in_interrupt() & 0xffff0000)*/) \
- RTMP_IRQ_UNLOCK((pLock), IrqFlags);
-
-// Prototypes of completion funuc.
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define ATE_RTUSBBulkOutDataPacketComplete(purb, pt_regs) ATE_RTUSBBulkOutDataPacketComplete(purb)
-#endif
-
-VOID ATE_RTUSBBulkOutDataPacketComplete(
- IN purbb_t purb,
- OUT struct pt_regs *pt_regs);
-
-VOID ATE_RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId);
-
-VOID ATE_RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-VOID rt_ee_read_all(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Data);
-
-
-VOID rt_ee_write_all(
- IN PRTMP_ADAPTER pAd,
- IN USHORT *Data);
-
-INT Set_ATE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_DA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_SA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_BSSID_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_CHANNEL_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_POWER0_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_POWER1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_RX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_FREQOFFSET_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_BW_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_LENGTH_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_COUNT_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_MCS_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_MODE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_GI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_ATE_RX_FER_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Read_RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF2_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF3_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF4_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Read_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Show_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Help_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-VOID ATE_QA_Statistics(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC p28xxRxD,
- IN PHEADER_802_11 pHeader);
-
-VOID RtmpDoAte(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID BubbleSort(
- IN INT32 n,
- IN INT32 a[]);
-
-VOID CalNoiseLevel(
- IN PRTMP_ADAPTER pAdapter,
- IN UCHAR channel,
- OUT INT32 buffer[3][10]);
-
-BOOLEAN SyncTxRxConfig(
- IN PRTMP_ADAPTER pAdapter,
- IN USHORT offset,
- IN UCHAR value);
-
-#if 0
-INT Set_TxStart_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // 0 //
-
-INT Set_TxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#if 0
-INT Set_EERead_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_EEWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BBPRead_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BBPWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RFWrite_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // end of #if 0 //
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-VOID ATEAsicSwitchChannel(
- IN PRTMP_ADAPTER pAd);
-
-VOID ATEAsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd);
-
-VOID ATEDisableAsicProtect(
- IN PRTMP_ADAPTER pAd);
-
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber);
-
-VOID ATESampleRssi(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI);
-
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPStationStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPStationStart(
- IN PRTMP_ADAPTER pAd);
-#endif // CONFIG_STA_SUPPORT //
-#endif // __ATE_H__ //
diff --git a/drivers/staging/rt2870/rt_config.h b/drivers/staging/rt2870/rt_config.h
index e3fe2642633a..1f6d6ed5630c 100644
--- a/drivers/staging/rt2870/rt_config.h
+++ b/drivers/staging/rt2870/rt_config.h
@@ -1,104 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rt_config.h
-
- Abstract:
- Central header file to maintain all include files for all NDIS
- miniport driver routines.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
-
-*/
-#ifndef __RT_CONFIG_H__
-#define __RT_CONFIG_H__
-
-#include "rtmp_type.h"
-#ifdef UCOS
-#include "includes.h"
-#include <stdio.h>
-#include "rt_ucos.h"
-#endif
-
-#ifdef LINUX
-#include "rt_linux.h"
-#endif
-#include "rtmp_def.h"
-#include "rt28xx.h"
-
-
-#ifdef RT2870
-#include "rt2870.h"
-#endif // RT2870 //
-
-#include "oid.h"
-#include "mlme.h"
-#include "wpa.h"
-#include "md5.h"
-#include "rtmp.h"
-#include "ap.h"
-#include "dfs.h"
-#include "chlist.h"
-#include "spectrum.h"
-
-
-#ifdef LEAP_SUPPORT
-#include "leap.h"
-#endif // LEAP_SUPPORT //
-
-#ifdef BLOCK_NET_IF
-#include "netif_block.h"
-#endif // BLOCK_NET_IF //
-
-#ifdef IGMP_SNOOP_SUPPORT
-#include "igmp_snoop.h"
-#endif // IGMP_SNOOP_SUPPORT //
-
-#ifdef RALINK_ATE
-#include "rt_ate.h"
-#endif // RALINK_ATE //
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifndef WPA_SUPPLICANT_SUPPORT
-#error "Build for being controlled by NetworkManager or wext, please set HAS_WPA_SUPPLICANT=y and HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y"
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef IKANOS_VX_1X0
-#include "vr_ikans.h"
-#endif // IKANOS_VX_1X0 //
-
-#endif // __RT_CONFIG_H__
-
+#include "../rt2860/rt_config.h"
diff --git a/drivers/staging/rt2870/rt_linux.c b/drivers/staging/rt2870/rt_linux.c
index e38552c5ccb1..88c697bf90eb 100644
--- a/drivers/staging/rt2870/rt_linux.c
+++ b/drivers/staging/rt2870/rt_linux.c
@@ -1,1095 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-ULONG RTDebugLevel = RT_DEBUG_ERROR;
-
-BUILD_TIMER_FUNCTION(MlmePeriodicExec);
-//BUILD_TIMER_FUNCTION(MlmeRssiReportExec);
-BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-BUILD_TIMER_FUNCTION(APSDPeriodicExec);
-BUILD_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RT2870
-BUILD_TIMER_FUNCTION(BeaconUpdateExec);
-#endif // RT2870 //
-
-
-#ifdef CONFIG_STA_SUPPORT
-BUILD_TIMER_FUNCTION(BeaconTimeout);
-BUILD_TIMER_FUNCTION(ScanTimeout);
-BUILD_TIMER_FUNCTION(AuthTimeout);
-BUILD_TIMER_FUNCTION(AssocTimeout);
-BUILD_TIMER_FUNCTION(ReassocTimeout);
-BUILD_TIMER_FUNCTION(DisassocTimeout);
-BUILD_TIMER_FUNCTION(LinkDownExec);
-#ifdef LEAP_SUPPORT
-BUILD_TIMER_FUNCTION(LeapAuthTimeout);
-#endif
-BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-#ifdef QOS_DLS_SUPPORT
-BUILD_TIMER_FUNCTION(DlsTimeoutAction);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-// for wireless system event message
-char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
- // system status event
- "had associated successfully", /* IW_ASSOC_EVENT_FLAG */
- "had disassociated", /* IW_DISASSOC_EVENT_FLAG */
- "had deauthenticated", /* IW_DEAUTH_EVENT_FLAG */
- "had been aged-out and disassociated", /* IW_AGEOUT_EVENT_FLAG */
- "occurred CounterMeasures attack", /* IW_COUNTER_MEASURES_EVENT_FLAG */
- "occurred replay counter different in Key Handshaking", /* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
- "occurred RSNIE different in Key Handshaking", /* IW_RSNIE_DIFF_EVENT_FLAG */
- "occurred MIC different in Key Handshaking", /* IW_MIC_DIFF_EVENT_FLAG */
- "occurred ICV error in RX", /* IW_ICV_ERROR_EVENT_FLAG */
- "occurred MIC error in RX", /* IW_MIC_ERROR_EVENT_FLAG */
- "Group Key Handshaking timeout", /* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
- "Pairwise Key Handshaking timeout", /* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
- "RSN IE sanity check failure", /* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
- "set key done in WPA/WPAPSK", /* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
- "set key done in WPA2/WPA2PSK", /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
- "connects with our wireless client", /* IW_STA_LINKUP_EVENT_FLAG */
- "disconnects with our wireless client", /* IW_STA_LINKDOWN_EVENT_FLAG */
- "scan completed" /* IW_SCAN_COMPLETED_EVENT_FLAG */
- "scan terminate!! Busy!! Enqueue fail!!" /* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
- };
-
-// for wireless IDS_spoof_attack event message
-char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
- "detected conflict SSID", /* IW_CONFLICT_SSID_EVENT_FLAG */
- "detected spoofed association response", /* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
- "detected spoofed reassociation responses", /* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
- "detected spoofed probe response", /* IW_SPOOF_PROBE_RESP_EVENT_FLAG */
- "detected spoofed beacon", /* IW_SPOOF_BEACON_EVENT_FLAG */
- "detected spoofed disassociation", /* IW_SPOOF_DISASSOC_EVENT_FLAG */
- "detected spoofed authentication", /* IW_SPOOF_AUTH_EVENT_FLAG */
- "detected spoofed deauthentication", /* IW_SPOOF_DEAUTH_EVENT_FLAG */
- "detected spoofed unknown management frame", /* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
- "detected replay attack" /* IW_REPLAY_ATTACK_EVENT_FLAG */
- };
-
-// for wireless IDS_flooding_attack event message
-char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
- "detected authentication flooding", /* IW_FLOOD_AUTH_EVENT_FLAG */
- "detected association request flooding", /* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
- "detected reassociation request flooding", /* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
- "detected probe request flooding", /* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
- "detected disassociation flooding", /* IW_FLOOD_DISASSOC_EVENT_FLAG */
- "detected deauthentication flooding", /* IW_FLOOD_DEAUTH_EVENT_FLAG */
- "detected 802.1x eap-request flooding" /* IW_FLOOD_EAP_REQ_EVENT_FLAG */
- };
-
-/* timeout -- ms */
-VOID RTMP_SetPeriodicTimer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout)
-{
- timeout = ((timeout*HZ) / 1000);
- pTimer->expires = jiffies + timeout;
- add_timer(pTimer);
-}
-
-/* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
-VOID RTMP_OS_Init_Timer(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN TIMER_FUNCTION function,
- IN PVOID data)
-{
- init_timer(pTimer);
- pTimer->data = (unsigned long)data;
- pTimer->function = function;
-}
-
-
-VOID RTMP_OS_Add_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout)
-{
- if (timer_pending(pTimer))
- return;
-
- timeout = ((timeout*HZ) / 1000);
- pTimer->expires = jiffies + timeout;
- add_timer(pTimer);
-}
-
-VOID RTMP_OS_Mod_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout)
-{
- timeout = ((timeout*HZ) / 1000);
- mod_timer(pTimer, jiffies + timeout);
-}
-
-VOID RTMP_OS_Del_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- OUT BOOLEAN *pCancelled)
-{
- if (timer_pending(pTimer))
- {
- *pCancelled = del_timer_sync(pTimer);
- }
- else
- {
- *pCancelled = TRUE;
- }
-
-}
-
-VOID RTMP_OS_Release_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PQUEUE_ENTRY pEntry)
-{
- //RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry);
-}
-
-// Unify all delay routine by using udelay
-VOID RTMPusecDelay(
- IN ULONG usec)
-{
- ULONG i;
-
- for (i = 0; i < (usec / 50); i++)
- udelay(50);
-
- if (usec % 50)
- udelay(usec % 50);
-}
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time)
-{
- time->u.LowPart = jiffies;
-}
-
-// pAd MUST allow to be NULL
-NDIS_STATUS os_alloc_mem(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR *mem,
- IN ULONG size)
-{
- *mem = (PUCHAR) kmalloc(size, GFP_ATOMIC);
- if (*mem)
- return (NDIS_STATUS_SUCCESS);
- else
- return (NDIS_STATUS_FAILURE);
-}
-
-// pAd MUST allow to be NULL
-NDIS_STATUS os_free_mem(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mem)
-{
-
- ASSERT(mem);
- kfree(mem);
- return (NDIS_STATUS_SUCCESS);
-}
-
-
-PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length)
-{
- struct sk_buff *pkt;
-
- pkt = dev_alloc_skb(Length);
-
- if (pkt == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("can't allocate frag rx %ld size packet\n",Length));
- }
-
- if (pkt)
- {
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
- }
-
- return (PNDIS_PACKET) pkt;
-}
-
-
-PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress)
-{
- struct sk_buff *pkt;
-
- pkt = dev_alloc_skb(Length);
-
- if (pkt == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("can't allocate tx %ld size packet\n",Length));
- }
-
- if (pkt)
- {
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
- *VirtualAddress = (PVOID) pkt->data;
- }
- else
- {
- *VirtualAddress = (PVOID) NULL;
- }
-
- return (PNDIS_PACKET) pkt;
-}
-
-
-VOID build_tx_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pFrame,
- IN ULONG FrameLen)
-{
-
- struct sk_buff *pTxPkt;
-
- ASSERT(pPacket);
- pTxPkt = RTPKT_TO_OSPKT(pPacket);
-
- NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
-}
-
-VOID RTMPFreeAdapter(
- IN PRTMP_ADAPTER pAd)
-{
- POS_COOKIE os_cookie;
- int index;
-
- os_cookie=(POS_COOKIE)pAd->OS_Cookie;
-
- kfree(pAd->BeaconBuf);
-
-
- NdisFreeSpinLock(&pAd->MgmtRingLock);
-
-
- for (index =0 ; index < NUM_OF_TX_RING; index++)
- {
- NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
- NdisFreeSpinLock(&pAd->DeQueueLock[index]);
- pAd->DeQueueRunning[index] = FALSE;
- }
-
- NdisFreeSpinLock(&pAd->irq_lock);
-
-
- vfree(pAd); // pci_free_consistent(os_cookie->pci_dev,sizeof(RTMP_ADAPTER),pAd,os_cookie->pAd_pa);
- kfree(os_cookie);
-}
-
-BOOLEAN OS_Need_Clone_Packet(void)
-{
- return (FALSE);
-}
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- clone an input NDIS PACKET to another one. The new internally created NDIS PACKET
- must have only one NDIS BUFFER
- return - byte copied. 0 means can't create NDIS PACKET
- NOTE: internally created NDIS_PACKET should be destroyed by RTMPFreeNdisPacket
-
- Arguments:
- pAd Pointer to our adapter
- pInsAMSDUHdr EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
- *pSrcTotalLen return total packet length. This lenght is calculated with 802.3 format packet.
-
- Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTMPCloneNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN pInsAMSDUHdr,
- IN PNDIS_PACKET pInPacket,
- OUT PNDIS_PACKET *ppOutPacket)
-{
-
- struct sk_buff *pkt;
-
- ASSERT(pInPacket);
- ASSERT(ppOutPacket);
-
- // 1. Allocate a packet
- pkt = dev_alloc_skb(2048);
-
- if (pkt == NULL)
- {
- return NDIS_STATUS_FAILURE;
- }
-
- skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
- NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));
- *ppOutPacket = OSPKT_TO_RTPKT(pkt);
-
-
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-
- printk("###Clone###\n");
-
- return NDIS_STATUS_SUCCESS;
-}
-
-
-// the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket()
-NDIS_STATUS RTMPAllocateNdisPacket(
- IN PRTMP_ADAPTER pAd,
- OUT PNDIS_PACKET *ppPacket,
- IN PUCHAR pHeader,
- IN UINT HeaderLen,
- IN PUCHAR pData,
- IN UINT DataLen)
-{
- PNDIS_PACKET pPacket;
- ASSERT(pData);
- ASSERT(DataLen);
-
- // 1. Allocate a packet
- pPacket = (PNDIS_PACKET *) dev_alloc_skb(HeaderLen + DataLen + TXPADDING_SIZE);
- if (pPacket == NULL)
- {
- *ppPacket = NULL;
-#ifdef DEBUG
- printk("RTMPAllocateNdisPacket Fail\n\n");
-#endif
- return NDIS_STATUS_FAILURE;
- }
-
- // 2. clone the frame content
- if (HeaderLen > 0)
- NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket), pHeader, HeaderLen);
- if (DataLen > 0)
- NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket) + HeaderLen, pData, DataLen);
-
- // 3. update length of packet
- skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
-
- RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-// printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
- *ppPacket = pPacket;
- return NDIS_STATUS_SUCCESS;
-}
-
-/*
- ========================================================================
- Description:
- This routine frees a miniport internally allocated NDIS_PACKET and its
- corresponding NDIS_BUFFER and allocated memory.
- ========================================================================
-*/
-VOID RTMPFreeNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- dev_kfree_skb_any(RTPKT_TO_OSPKT(pPacket));
-}
-
-
-// IRQL = DISPATCH_LEVEL
-// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same
-// scatter gather buffer
-NDIS_STATUS Sniff2BytesFromNdisBuffer(
- IN PNDIS_BUFFER pFirstBuffer,
- IN UCHAR DesiredOffset,
- OUT PUCHAR pByte0,
- OUT PUCHAR pByte1)
-{
- *pByte0 = *(PUCHAR)(pFirstBuffer + DesiredOffset);
- *pByte1 = *(PUCHAR)(pFirstBuffer + DesiredOffset + 1);
-
- return NDIS_STATUS_SUCCESS;
-}
-
-
-void RTMP_QueryPacketInfo(
- IN PNDIS_PACKET pPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen)
-{
- pPacketInfo->BufferCount = 1;
- pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
- pPacketInfo->PhysicalBufferCount = 1;
- pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
- *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
- *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
-}
-
-void RTMP_QueryNextPacketInfo(
- IN PNDIS_PACKET *ppPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen)
-{
- PNDIS_PACKET pPacket = NULL;
-
- if (*ppPacket)
- pPacket = GET_OS_PKT_NEXT(*ppPacket);
-
- if (pPacket)
- {
- pPacketInfo->BufferCount = 1;
- pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
- pPacketInfo->PhysicalBufferCount = 1;
- pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
- *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
- *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
- *ppPacket = GET_OS_PKT_NEXT(pPacket);
- }
- else
- {
- pPacketInfo->BufferCount = 0;
- pPacketInfo->pFirstBuffer = NULL;
- pPacketInfo->PhysicalBufferCount = 0;
- pPacketInfo->TotalPacketLength = 0;
-
- *pSrcBufVA = NULL;
- *pSrcBufLen = 0;
- *ppPacket = NULL;
- }
-}
-
-// not yet support MBSS
-PNET_DEV get_netdev_from_bssid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR FromWhichBSSID)
-{
- PNET_DEV dev_p = NULL;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- dev_p = pAd->net_dev;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- ASSERT(dev_p);
- return dev_p; /* return one of MBSS */
-}
-
-PNDIS_PACKET DuplicatePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *skb;
- PNDIS_PACKET pRetPacket = NULL;
- USHORT DataSize;
- UCHAR *pData;
-
- DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
- pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
-
-
- skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
- if (skb)
- {
- skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pRetPacket = OSPKT_TO_RTPKT(skb);
- }
-
-#if 0
- if ((skb = __dev_alloc_skb(DataSize + 2+32, MEM_ALLOC_FLAG)) != NULL)
- {
- skb_reserve(skb, 2+32);
- NdisMoveMemory(skb->tail, pData, DataSize);
- skb_put(skb, DataSize);
- skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pRetPacket = OSPKT_TO_RTPKT(skb);
- }
-#endif
-
- return pRetPacket;
-
-}
-
-PNDIS_PACKET duplicate_pkt(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *skb;
- PNDIS_PACKET pPacket = NULL;
-
-
- if ((skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL)
- {
- skb_reserve(skb, 2);
- NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
- skb_put(skb, HdrLen);
- NdisMoveMemory(skb->tail, pData, DataSize);
- skb_put(skb, DataSize);
- skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pPacket = OSPKT_TO_RTPKT(skb);
- }
-
- return pPacket;
-}
-
-
-#define TKIP_TX_MIC_SIZE 8
-PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- struct sk_buff *skb, *newskb;
-
-
- skb = RTPKT_TO_OSPKT(pPacket);
- if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE)
- {
- // alloc a new skb and copy the packet
- newskb = skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE, GFP_ATOMIC);
- dev_kfree_skb_any(skb);
- if (newskb == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Extend Tx.MIC for packet failed!, dropping packet!\n"));
- return NULL;
- }
- skb = newskb;
- }
-
- return OSPKT_TO_RTPKT(skb);
-
-#if 0
- if ((data = skb_put(skb, TKIP_TX_MIC_SIZE)) != NULL)
- { // If we can extend it, well, copy it first.
- NdisMoveMemory(data, pAd->PrivateInfo.Tx.MIC, TKIP_TX_MIC_SIZE);
- }
- else
- {
- // Otherwise, copy the packet.
- newskb = skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE, GFP_ATOMIC);
- dev_kfree_skb_any(skb);
- if (newskb == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Extend Tx.MIC to packet failed!, dropping packet\n"));
- return NULL;
- }
- skb = newskb;
-
- NdisMoveMemory(skb->tail, pAd->PrivateInfo.Tx.MIC, TKIP_TX_MIC_SIZE);
- skb_put(skb, TKIP_TX_MIC_SIZE);
- }
-
- return OSPKT_TO_RTPKT(skb);
-#endif
-
-}
-
-
-
-
-PNDIS_PACKET ClonePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize)
-{
- struct sk_buff *pRxPkt;
- struct sk_buff *pClonedPkt;
-
- ASSERT(pPacket);
- pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
- // clone the packet
- pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
-
- if (pClonedPkt)
- {
- // set the correct dataptr and data len
- pClonedPkt->dev = pRxPkt->dev;
- pClonedPkt->data = pData;
- pClonedPkt->len = DataSize;
- pClonedPkt->tail = pClonedPkt->data + pClonedPkt->len;
- ASSERT(DataSize < 1530);
- }
- return pClonedPkt;
-}
-
-//
-// change OS packet DataPtr and DataLen
-//
-void update_os_packet_info(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *pOSPkt;
-
- ASSERT(pRxBlk->pRxPacket);
- pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
- pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pOSPkt->data = pRxBlk->pData;
- pOSPkt->len = pRxBlk->DataSize;
- pOSPkt->tail = pOSPkt->data + pOSPkt->len;
-}
-
-
-void wlan_802_11_to_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN PUCHAR pHeader802_3,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *pOSPkt;
-
- ASSERT(pRxBlk->pRxPacket);
- ASSERT(pHeader802_3);
-
- pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
- pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pOSPkt->data = pRxBlk->pData;
- pOSPkt->len = pRxBlk->DataSize;
- pOSPkt->tail = pOSPkt->data + pOSPkt->len;
-
- //
- // copy 802.3 header
- //
- //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
-
-void announce_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
-
- struct sk_buff *pRxPkt;
-
- ASSERT(pPacket);
-
- pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- /* Push up the protocol stack */
-#ifdef IKANOS_VX_1X0
- IKANOS_DataFrameRx(pAd, pRxPkt->dev, pRxPkt, pRxPkt->len);
-#else
- pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
-
-//#ifdef CONFIG_5VT_ENHANCE
-// *(int*)(pRxPkt->cb) = BRIDGE_TAG;
-//#endif
- netif_rx(pRxPkt);
-#endif // IKANOS_VX_1X0 //
-}
-
-
-PRTMP_SCATTER_GATHER_LIST
-rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg)
-{
- sg->NumberOfElements = 1;
- sg->Elements[0].Address = GET_OS_PKT_DATAPTR(pPacket);
- sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
- return (sg);
-}
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
-{
- unsigned char *pt;
- int x;
-
- if (RTDebugLevel < RT_DEBUG_TRACE)
- return;
-
- pt = pSrcBufVA;
- printk("%s: %p, len = %d\n",str, pSrcBufVA, SrcBufLen);
- for (x=0; x<SrcBufLen; x++)
- {
- if (x % 16 == 0)
- printk("0x%04x : ", x);
- printk("%02x ", ((unsigned char)pt[x]));
- if (x%16 == 15) printk("\n");
- }
- printk("\n");
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Send log message through wireless event
-
- Support standard iw_event with IWEVCUSTOM. It is used below.
-
- iwreq_data.data.flags is used to store event_flag that is defined by user.
- iwreq_data.data.length is the length of the event log.
-
- The format of the event log is composed of the entry's MAC address and
- the desired log message (refer to pWirelessEventText).
-
- ex: 11:22:33:44:55:66 has associated successfully
-
- p.s. The requirement of Wireless Extension is v15 or newer.
-
- ========================================================================
-*/
-VOID RTMPSendWirelessEvent(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Event_flag,
- IN PUCHAR pAddr,
- IN UCHAR BssIdx,
- IN CHAR Rssi)
-{
-#if WIRELESS_EXT >= 15
-
- union iwreq_data wrqu;
- PUCHAR pBuf = NULL, pBufPtr = NULL;
- USHORT event, type, BufLen;
- UCHAR event_table_len = 0;
-
- type = Event_flag & 0xFF00;
- event = Event_flag & 0x00FF;
-
- switch (type)
- {
- case IW_SYS_EVENT_FLAG_START:
- event_table_len = IW_SYS_EVENT_TYPE_NUM;
- break;
-
- case IW_SPOOF_EVENT_FLAG_START:
- event_table_len = IW_SPOOF_EVENT_TYPE_NUM;
- break;
-
- case IW_FLOOD_EVENT_FLAG_START:
- event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
- break;
- }
-
- if (event_table_len == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
- return;
- }
-
- if (event >= event_table_len)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
- return;
- }
-
- //Allocate memory and copy the msg.
- if((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL)
- {
- //Prepare the payload
- memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
-
- pBufPtr = pBuf;
-
- if (pAddr)
- pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));
- else if (BssIdx < MAX_MBSSID_NUM)
- pBufPtr += sprintf(pBufPtr, "(RT2860) BSS(ra%d) ", BssIdx);
- else
- pBufPtr += sprintf(pBufPtr, "(RT2860) ");
-
- if (type == IW_SYS_EVENT_FLAG_START)
- pBufPtr += sprintf(pBufPtr, "%s", pWirelessSysEventText[event]);
- else if (type == IW_SPOOF_EVENT_FLAG_START)
- pBufPtr += sprintf(pBufPtr, "%s (RSSI=%d)", pWirelessSpoofEventText[event], Rssi);
- else if (type == IW_FLOOD_EVENT_FLAG_START)
- pBufPtr += sprintf(pBufPtr, "%s", pWirelessFloodEventText[event]);
- else
- pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
-
- pBufPtr[pBufPtr - pBuf] = '\0';
- BufLen = pBufPtr - pBuf;
-
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = Event_flag;
- wrqu.data.length = BufLen;
-
- //send wireless event
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
-
- //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
-
- kfree(pBuf);
- }
- else
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
-#else
- DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
-#endif /* WIRELESS_EXT >= 15 */
-}
-
-
-#ifdef CONFIG_STA_SUPPORT
-void send_monitor_packets(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- struct sk_buff *pOSPkt;
- wlan_ng_prism2_header *ph;
- int rate_index = 0;
- USHORT header_len = 0;
- UCHAR temp_header[40] = {0};
-
- u_int32_t ralinkrate[256] = {2,4,11,22, 12,18,24,36,48,72,96, 108, 109, 110, 111, 112, 13, 26, 39, 52,78,104, 117, 130, 26, 52, 78,104, 156, 208, 234, 260, 27, 54,81,108,162, 216, 243, 270, // Last 38
- 54, 108, 162, 216, 324, 432, 486, 540, 14, 29, 43, 57, 87, 115, 130, 144, 29, 59,87,115, 173, 230,260, 288, 30, 60,90,120,180,240,270,300,60,120,180,240,360,480,540,600, 0,1,2,3,4,5,6,7,8,9,10,
- 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};
-
-
- ASSERT(pRxBlk->pRxPacket);
- if (pRxBlk->DataSize < 10)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
- goto err_free_sk_buff;
- }
-
- if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%zu)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
- goto err_free_sk_buff;
- }
-
- pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
- pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
- if (pRxBlk->pHeader->FC.Type == BTYPE_DATA)
- {
- pRxBlk->DataSize -= LENGTH_802_11;
- if ((pRxBlk->pHeader->FC.ToDs == 1) &&
- (pRxBlk->pHeader->FC.FrDs == 1))
- header_len = LENGTH_802_11_WITH_ADDR4;
- else
- header_len = LENGTH_802_11;
-
- // QOS
- if (pRxBlk->pHeader->FC.SubType & 0x08)
- {
- header_len += 2;
- // Data skip QOS contorl field
- pRxBlk->DataSize -=2;
- }
-
- // Order bit: A-Ralink or HTC+
- if (pRxBlk->pHeader->FC.Order)
- {
- header_len += 4;
- // Data skip HTC contorl field
- pRxBlk->DataSize -= 4;
- }
-
- // Copy Header
- if (header_len <= 40)
- NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
-
- // skip HW padding
- if (pRxBlk->RxD.L2PAD)
- pRxBlk->pData += (header_len + 2);
- else
- pRxBlk->pData += header_len;
- } //end if
-
-
- if (pRxBlk->DataSize < pOSPkt->len) {
- skb_trim(pOSPkt,pRxBlk->DataSize);
- } else {
- skb_put(pOSPkt,(pRxBlk->DataSize - pOSPkt->len));
- } //end if
-
- if ((pRxBlk->pData - pOSPkt->data) > 0) {
- skb_put(pOSPkt,(pRxBlk->pData - pOSPkt->data));
- skb_pull(pOSPkt,(pRxBlk->pData - pOSPkt->data));
- } //end if
-
- if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
- if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
- goto err_free_sk_buff;
- } //end if
- } //end if
-
- if (header_len > 0)
- NdisMoveMemory(skb_push(pOSPkt, header_len), temp_header, header_len);
-
- ph = (wlan_ng_prism2_header *) skb_push(pOSPkt, sizeof(wlan_ng_prism2_header));
- NdisZeroMemory(ph, sizeof(wlan_ng_prism2_header));
-
- ph->msgcode = DIDmsg_lnxind_wlansniffrm;
- ph->msglen = sizeof(wlan_ng_prism2_header);
- strcpy(ph->devname, pAd->net_dev->name);
-
- ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
- ph->hosttime.status = 0;
- ph->hosttime.len = 4;
- ph->hosttime.data = jiffies;
-
- ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
- ph->mactime.status = 0;
- ph->mactime.len = 0;
- ph->mactime.data = 0;
-
- ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
- ph->istx.status = 0;
- ph->istx.len = 0;
- ph->istx.data = 0;
-
- ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
- ph->channel.status = 0;
- ph->channel.len = 4;
-
- ph->channel.data = (u_int32_t)pAd->CommonCfg.Channel;
-
- ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
- ph->rssi.status = 0;
- ph->rssi.len = 4;
- ph->rssi.data = (u_int32_t)RTMPMaxRssi(pAd, ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0, RSSI_0), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI1, RSSI_1), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2, RSSI_2));;
-
- ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
- ph->signal.status = 0;
- ph->signal.len = 4;
- ph->signal.data = 0; //rssi + noise;
-
- ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
- ph->noise.status = 0;
- ph->noise.len = 4;
- ph->noise.data = 0;
-
-#ifdef DOT11_N_SUPPORT
- if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX)
- {
- rate_index = 16 + ((UCHAR)pRxBlk->pRxWI->BW *16) + ((UCHAR)pRxBlk->pRxWI->ShortGI *32) + ((UCHAR)pRxBlk->pRxWI->MCS);
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
- rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
- else
- rate_index = (UCHAR)(pRxBlk->pRxWI->MCS);
- if (rate_index < 0)
- rate_index = 0;
- if (rate_index > 255)
- rate_index = 255;
-
- ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
- ph->rate.status = 0;
- ph->rate.len = 4;
- ph->rate.data = ralinkrate[rate_index];
-
- ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
- ph->frmlen.status = 0;
- ph->frmlen.len = 4;
- ph->frmlen.data = (u_int32_t)pRxBlk->DataSize;
-
-
- pOSPkt->pkt_type = PACKET_OTHERHOST;
- pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
- pOSPkt->ip_summed = CHECKSUM_NONE;
- netif_rx(pOSPkt);
-
- return;
-
-err_free_sk_buff:
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
-{
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- daemonize(pThreadName /*"%s",pAd->net_dev->name*/);
-
- allow_signal(SIGTERM);
- allow_signal(SIGKILL);
- current->flags |= PF_NOFREEZE;
-#else
- unsigned long flags;
-
- daemonize();
- reparent_to_init();
- strcpy(current->comm, pThreadName);
-
- siginitsetinv(&current->blocked, sigmask(SIGTERM) | sigmask(SIGKILL));
-
- /* Allow interception of SIGKILL only
- * Don't allow other signals to interrupt the transmission */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,22)
- spin_lock_irqsave(&current->sigmask_lock, flags);
- flush_signals(current);
- recalc_sigpending(current);
- spin_unlock_irqrestore(&current->sigmask_lock, flags);
-#endif
-#endif
-
- /* signal that we've started the thread */
- complete(pNotify);
-
-}
-
-void RTMP_IndicateMediaState(
- IN PRTMP_ADAPTER pAd)
-{
- if (pAd->CommonCfg.bWirelessEvent)
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- else
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
-}
-
+#include "../rt2860/rt_linux.c"
diff --git a/drivers/staging/rt2870/rt_linux.h b/drivers/staging/rt2870/rt_linux.h
index 5a6ee6ad0e52..b2aeafbd5189 100644
--- a/drivers/staging/rt2870/rt_linux.h
+++ b/drivers/staging/rt2870/rt_linux.h
@@ -1,906 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-/***********************************************************************/
-/* */
-/* Program: rt_linux.c */
-/* Created: 4/21/2006 1:17:38 PM */
-/* Author: Wu Xi-Kun */
-/* Comments: `description` */
-/* */
-/*---------------------------------------------------------------------*/
-/* */
-/* History: */
-/* Revision 1.1 4/21/2006 1:17:38 PM xsikun */
-/* Initial revision */
-/* */
-/***********************************************************************/
-
-#include "rtmp_type.h"
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/kthread.h>
-
-#include <linux/spinlock.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
-#include <linux/proc_fs.h>
-#include <linux/delay.h>
-#include <linux/if_arp.h>
-#include <linux/ctype.h>
-#include <linux/vmalloc.h>
-
-
-#include <net/iw_handler.h>
-
-// load firmware
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-#include <asm/uaccess.h>
-
-
-#define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
-
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
-//#define CONFIG_CKIP_SUPPORT
-
-#undef __inline
-#define __inline static inline
-
-typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
-
-// add by kathy
-
-#ifdef CONFIG_STA_SUPPORT
-
-#ifdef RT2870
-#define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
-#define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
-#define STA_NIC_DEVICE_NAME "RT2870STA"
-#define STA_DRIVER_VERSION "1.4.0.0"
-#ifdef MULTIPLE_CARD_SUPPORT
-#define CARD_INFO_PATH "/etc/Wireless/RT2870STA/RT2870STACard.dat"
-#endif // MULTIPLE_CARD_SUPPORT //
-#endif // RT2870 //
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-
-#define RTMP_TIME_AFTER(a,b) \
- (typecheck(unsigned long, (unsigned long)a) && \
- typecheck(unsigned long, (unsigned long)b) && \
- ((long)(b) - (long)(a) < 0))
-
-#define RTMP_TIME_AFTER_EQ(a,b) \
- (typecheck(unsigned long, (unsigned long)a) && \
- typecheck(unsigned long, (unsigned long)b) && \
- ((long)(a) - (long)(b) >= 0))
-#define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
-#else
-#define RTMP_TIME_AFTER(a,b) time_after(a, b)
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#define RT_MOD_INC_USE_COUNT() \
- if (!try_module_get(THIS_MODULE)) \
- { \
- DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
- return -1; \
- }
-
-#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
-#else
-#define RT_MOD_INC_USE_COUNT() MOD_INC_USE_COUNT;
-#define RT_MOD_DEC_USE_COUNT() MOD_DEC_USE_COUNT;
-#endif
-
-#define OS_HZ HZ
-
-#define ETH_LENGTH_OF_ADDRESS 6
-
-#define IN
-#define OUT
-
-#define NDIS_STATUS INT
-#define NDIS_STATUS_SUCCESS 0x00
-#define NDIS_STATUS_FAILURE 0x01
-#define NDIS_STATUS_INVALID_DATA 0x02
-#define NDIS_STATUS_RESOURCES 0x03
-
-#define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f
-#define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30
-#define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
-#define MIN_NET_DEVICE_FOR_APCLI 0x20
-#define MIN_NET_DEVICE_FOR_MESH 0x30
-#ifdef CONFIG_STA_SUPPORT
-#define MIN_NET_DEVICE_FOR_DLS 0x40
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef CONFIG_STA_SUPPORT
-#define NDIS_PACKET_TYPE_DIRECTED 0
-#define NDIS_PACKET_TYPE_MULTICAST 1
-#define NDIS_PACKET_TYPE_BROADCAST 2
-#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
-#endif // CONFIG_STA_SUPPORT //
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
-typedef struct pid * THREAD_PID;
-#define GET_PID(_v) find_get_pid(_v)
-#define GET_PID_NUMBER(_v) pid_nr(_v)
-#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
-#define KILL_THREAD_PID(_A, _B, _C) kill_pid(_A, _B, _C)
-#else
-typedef pid_t THREAD_PID;
-#define GET_PID(_v) _v
-#define GET_PID_NUMBER(_v) _v
-#define CHECK_PID_LEGALITY(_pid) if (_pid >= 0)
-#define KILL_THREAD_PID(_A, _B, _C) kill_proc(_A, _B, _C)
-#endif
-
-struct os_lock {
- spinlock_t lock;
- unsigned long flags;
-};
-
-
-struct os_cookie {
-
-#ifdef RT2870
- struct usb_device *pUsb_Dev;
-
- struct task_struct *MLMEThr_task;
- struct task_struct *RTUSBCmdThr_task;
- struct task_struct *TimerQThr_task;
-#endif // RT2870 //
-
- struct tasklet_struct rx_done_task;
- struct tasklet_struct mgmt_dma_done_task;
- struct tasklet_struct ac0_dma_done_task;
- struct tasklet_struct ac1_dma_done_task;
- struct tasklet_struct ac2_dma_done_task;
- struct tasklet_struct ac3_dma_done_task;
- struct tasklet_struct hcca_dma_done_task;
- struct tasklet_struct tbtt_task;
-#ifdef RT2870
- struct tasklet_struct null_frame_complete_task;
- struct tasklet_struct rts_frame_complete_task;
- struct tasklet_struct pspoll_frame_complete_task;
-#endif // RT2870 //
-
-
- unsigned long apd_pid; //802.1x daemon pid
- INT ioctl_if_type;
- INT ioctl_if;
-};
-
-typedef struct _VIRTUAL_ADAPTER
-{
- struct net_device *RtmpDev;
- struct net_device *VirtualDev;
-} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
-
-#undef ASSERT
-#define ASSERT(x) \
-{ \
- if (!(x)) \
- { \
- printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
- } \
-}
-
-typedef struct os_cookie * POS_COOKIE;
-typedef struct pci_dev * PPCI_DEV;
-typedef struct net_device * PNET_DEV;
-typedef void * PNDIS_PACKET;
-typedef char NDIS_PACKET;
-typedef PNDIS_PACKET * PPNDIS_PACKET;
-typedef dma_addr_t NDIS_PHYSICAL_ADDRESS;
-typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
-//typedef struct timer_list RALINK_TIMER_STRUCT;
-//typedef struct timer_list * PRALINK_TIMER_STRUCT;
-//typedef struct os_lock NDIS_SPIN_LOCK;
-typedef spinlock_t NDIS_SPIN_LOCK;
-typedef struct timer_list NDIS_MINIPORT_TIMER;
-typedef void * NDIS_HANDLE;
-typedef char * PNDIS_BUFFER;
-
-
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
-
-dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
-void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
-
-
-////////////////////////////////////////
-// MOVE TO rtmp.h ?
-/////////////////////////////////////////
-#define PKTSRC_NDIS 0x7f
-#define PKTSRC_DRIVER 0x0f
-#define PRINT_MAC(addr) \
- addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
-
-
-#define RT2860_PCI_DEVICE_ID 0x0601
-
-
-#ifdef RT2870
-#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
-
-#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
-#endif // RT2870 //
-
-
-#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
- dma_cache_wback(_ptr, _size)
-
-
-//////////////////////////////////////////
-//
-//////////////////////////////////////////
-
-
-#define NdisMIndicateStatus(_w, _x, _y, _z)
-
-typedef struct timer_list RTMP_OS_TIMER;
-
-#ifdef RT2870
-/* ----------------- Timer Related MARCO ---------------*/
-// In RT2870, we have a lot of timer functions and will read/write register, it's
-// not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
-// to ctrl pipe). So we need a wrapper function to take care it.
-
-typedef VOID (*RT2870_TIMER_HANDLE)(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-#endif // RT2870 //
-
-
-typedef struct _RALINK_TIMER_STRUCT {
- RTMP_OS_TIMER TimerObj; // Ndis Timer object
- BOOLEAN Valid; // Set to True when call RTMPInitTimer
- BOOLEAN State; // True if timer cancelled
- BOOLEAN PeriodicType; // True if timer is periodic timer
- BOOLEAN Repeat; // True if periodic timer
- ULONG TimerValue; // Timer value in milliseconds
- ULONG cookie; // os specific object
-#ifdef RT2870
- RT2870_TIMER_HANDLE handle;
- void *pAd;
-#endif // RT2870 //
-} RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
-
-
-#ifdef RT2870
-
-typedef enum _RT2870_KERNEL_THREAD_STATUS_
-{
- RT2870_THREAD_UNKNOWN = 0,
- RT2870_THREAD_INITED = 1,
- RT2870_THREAD_RUNNING = 2,
- RT2870_THREAD_STOPED = 4,
-}RT2870_KERNEL_THREAD_STATUS;
-
-#define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
-
-typedef struct _RT2870_TIMER_ENTRY_
-{
- RALINK_TIMER_STRUCT *pRaTimer;
- struct _RT2870_TIMER_ENTRY_ *pNext;
-}RT2870_TIMER_ENTRY;
-
-
-#define TIMER_QUEUE_SIZE_MAX 128
-typedef struct _RT2870_TIMER_QUEUE_
-{
- unsigned int status;
- //wait_queue_head_t timerWaitQ;
- //atomic_t count;
- UCHAR *pTimerQPoll;
- RT2870_TIMER_ENTRY *pQPollFreeList;
- RT2870_TIMER_ENTRY *pQHead;
- RT2870_TIMER_ENTRY *pQTail;
-}RT2870_TIMER_QUEUE;
-#endif // RT2870 //
-
-
-//#define DBG 1
-
-//
-// MACRO for debugging information
-//
-
-#ifdef DBG
-extern ULONG RTDebugLevel;
-
-#define DBGPRINT_RAW(Level, Fmt) \
-{ \
- if (Level <= RTDebugLevel) \
- { \
- printk Fmt; \
- } \
-}
-
-#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
-
-
-#define DBGPRINT_ERR(Fmt) \
-{ \
- printk("ERROR!!! "); \
- printk Fmt; \
-}
-
-#define DBGPRINT_S(Status, Fmt) \
-{ \
- printk Fmt; \
-}
-
-
-#else
-#define DBGPRINT(Level, Fmt)
-#define DBGPRINT_RAW(Level, Fmt)
-#define DBGPRINT_S(Status, Fmt)
-#define DBGPRINT_ERR(Fmt)
-#endif
-
-
-//
-// spin_lock enhanced for Nested spin lock
-//
-#define NdisAllocateSpinLock(__lock) \
-{ \
- spin_lock_init((spinlock_t *)(__lock)); \
-}
-
-#define NdisFreeSpinLock(lock) \
-{ \
-}
-
-
-#define RTMP_SEM_LOCK(__lock) \
-{ \
- spin_lock_bh((spinlock_t *)(__lock)); \
-}
-
-#define RTMP_SEM_UNLOCK(__lock) \
-{ \
- spin_unlock_bh((spinlock_t *)(__lock)); \
-}
-
-#if 0 // sample, IRQ LOCK
-#define RTMP_IRQ_LOCK(__lock, __irqflags) \
-{ \
- spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
- pAd->irq_disabled |= 1; \
-}
-
-#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
-{ \
- pAd->irq_disabled &= 0; \
- spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
-}
-#else
-
-// sample, use semaphore lock to replace IRQ lock, 2007/11/15
-#define RTMP_IRQ_LOCK(__lock, __irqflags) \
-{ \
- __irqflags = 0; \
- spin_lock_bh((spinlock_t *)(__lock)); \
- pAd->irq_disabled |= 1; \
-}
-
-#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
-{ \
- pAd->irq_disabled &= 0; \
- spin_unlock_bh((spinlock_t *)(__lock)); \
-}
-
-#define RTMP_INT_LOCK(__lock, __irqflags) \
-{ \
- spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
-}
-
-#define RTMP_INT_UNLOCK(__lock, __irqflag) \
-{ \
- spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
-}
-#endif
-
-
-
-#ifdef RT2870
-//Patch for ASIC turst read/write bug, needs to remove after metel fix
-#define RTMP_IO_READ32(_A, _R, _pV) \
- RTUSBReadMACRegister(_A, _R, _pV)
-
-#define RTMP_IO_READ8(_A, _R, _pV) \
-{ \
-}
-
-#define RTMP_IO_WRITE32(_A, _R, _V) \
- RTUSBWriteMACRegister(_A, _R, _V)
-
-
-#define RTMP_IO_WRITE8(_A, _R, _V) \
-{ \
- USHORT _Val = _V; \
- RTUSBSingleWrite(_A, _R, _Val); \
-}
-
-
-#define RTMP_IO_WRITE16(_A, _R, _V) \
-{ \
- RTUSBSingleWrite(_A, _R, _V); \
-}
-#endif // RT2870 //
-
-#ifndef wait_event_interruptible_timeout
-#define __wait_event_interruptible_timeout(wq, condition, ret) \
-do { \
- wait_queue_t __wait; \
- init_waitqueue_entry(&__wait, current); \
- add_wait_queue(&wq, &__wait); \
- for (;;) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- if (condition) \
- break; \
- if (!signal_pending(current)) { \
- ret = schedule_timeout(ret); \
- if (!ret) \
- break; \
- continue; \
- } \
- ret = -ERESTARTSYS; \
- break; \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event_interruptible_timeout(wq, condition, timeout) \
-({ \
- long __ret = timeout; \
- if (!(condition)) \
- __wait_event_interruptible_timeout(wq, condition, __ret); \
- __ret; \
-})
-#endif
-#define ONE_TICK 1
-#define OS_WAIT(_time) \
-{ int _i; \
- long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
- wait_queue_head_t _wait; \
- init_waitqueue_head(&_wait); \
- for (_i=0; _i<(_loop); _i++) \
- wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
-
-
-typedef void (*TIMER_FUNCTION)(unsigned long);
-
-#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
-
-#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
-#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
-
-
-#ifdef RT2870
-#define BUILD_TIMER_FUNCTION(_func) \
-void linux_##_func(unsigned long data) \
-{ \
- PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
- RT2870_TIMER_ENTRY *_pQNode; \
- RTMP_ADAPTER *_pAd; \
- \
- _pTimer->handle = _func; \
- _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
- _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
- if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
- RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
-}
-#endif // RT2870 //
-
-
-#define DECLARE_TIMER_FUNCTION(_func) \
-void linux_##_func(unsigned long data)
-
-#define GET_TIMER_FUNCTION(_func) \
- linux_##_func
-
-DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
-DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
-DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
-DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RT2870
-DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
-#endif // RT2870 //
-
-
-#ifdef CONFIG_STA_SUPPORT
-DECLARE_TIMER_FUNCTION(BeaconTimeout);
-DECLARE_TIMER_FUNCTION(ScanTimeout);
-DECLARE_TIMER_FUNCTION(AuthTimeout);
-DECLARE_TIMER_FUNCTION(AssocTimeout);
-DECLARE_TIMER_FUNCTION(ReassocTimeout);
-DECLARE_TIMER_FUNCTION(DisassocTimeout);
-DECLARE_TIMER_FUNCTION(LinkDownExec);
-#ifdef LEAP_SUPPORT
-DECLARE_TIMER_FUNCTION(LeapAuthTimeout);
-#endif
-DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-DECLARE_TIMER_FUNCTION(PsPollWakeExec);
-DECLARE_TIMER_FUNCTION(RadioOnExec);
-
-#ifdef QOS_DLS_SUPPORT
-DECLARE_TIMER_FUNCTION(DlsTimeoutAction);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
-
-
-/*
- * packet helper
- * - convert internal rt packet to os packet or
- * os packet to rt packet
- */
-#define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
-#define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
-
-#define GET_OS_PKT_DATAPTR(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->data)
-
-#define GET_OS_PKT_LEN(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->len)
-
-#define GET_OS_PKT_DATATAIL(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->tail)
-
-#define GET_OS_PKT_HEAD(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->head)
-
-#define GET_OS_PKT_END(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->end)
-
-#define GET_OS_PKT_NETDEV(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->dev)
-
-#define GET_OS_PKT_TYPE(_pkt) \
- (RTPKT_TO_OSPKT(_pkt))
-
-#define GET_OS_PKT_NEXT(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->next)
-
-
-#define OS_NTOHS(_Val) \
- (ntohs(_Val))
-#define OS_HTONS(_Val) \
- (htons(_Val))
-#define OS_NTOHL(_Val) \
- (ntohl(_Val))
-#define OS_HTONL(_Val) \
- (htonl(_Val))
-
-/* statistics counter */
-#define STATS_INC_RX_PACKETS(_pAd, _dev)
-#define STATS_INC_TX_PACKETS(_pAd, _dev)
-
-#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
-#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
-
-#define STATS_INC_RX_ERRORS(_pAd, _dev)
-#define STATS_INC_TX_ERRORS(_pAd, _dev)
-
-#define STATS_INC_RX_DROPPED(_pAd, _dev)
-#define STATS_INC_TX_DROPPED(_pAd, _dev)
-
-
-#define CB_OFF 10
-
-
-// check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
-// ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
-//
-//#define RTMP_GET_PACKET_MR(_p) (RTPKT_TO_OSPKT(_p))
-
-// User Priority
-#define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
-#define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
-
-// Fragment #
-#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
-#define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
-
-// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too.
-//(this value also as MAC(on-chip WCID) table index)
-// 0x80~0xff: TX to a WDS link. b0~6: WDS index
-#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
-#define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
-
-// 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
-#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
-#define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
-
-// RTS/CTS-to-self protection method
-#define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
-#define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
-// see RTMP_S(G)ET_PACKET_EMACTAB
-
-// TX rate index
-#define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
-#define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
-
-// From which Interface
-#define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
-#define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
-#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
-#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
-#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
-#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
-#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
-#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
-
-#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
-#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
-
-//#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) (RTPKT_TO_OSPKT(_p)->cb[8] = _bss)
-//#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) (RTPKT_TO_OSPKT(_p)->cb[8])
-
-
-
-
-#if 0
-//#define RTMP_SET_PACKET_DHCP(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
-//#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11])
-#else
-//
-// Sepcific Pakcet Type definition
-//
-#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
-
-#define RTMP_PACKET_SPECIFIC_DHCP 0x01
-#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
-#define RTMP_PACKET_SPECIFIC_IPV4 0x04
-#define RTMP_PACKET_SPECIFIC_WAI 0x08
-#define RTMP_PACKET_SPECIFIC_VLAN 0x10
-#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
-
-//Specific
-#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
-
-//DHCP
-#define RTMP_SET_PACKET_DHCP(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
- }while(0)
-#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
-
-//EAPOL
-#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
- }while(0)
-#define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
-
-//WAI
-#define RTMP_SET_PACKET_WAI(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
- }while(0)
-#define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
-
-#define RTMP_GET_PACKET_LOWRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
-
-//VLAN
-#define RTMP_SET_PACKET_VLAN(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
- }while(0)
-#define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
-
-//LLC/SNAP
-#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
- }while(0)
-
-#define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
-
-// IP
-#define RTMP_SET_PACKET_IPV4(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
- }while(0)
-
-#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
-
-#endif
-
-
-// If this flag is set, it indicates that this EAPoL frame MUST be clear.
-#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
-#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
-
-#define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
-#define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
-
-
-#ifdef CONFIG_5VT_ENHANCE
-#define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
-#endif
-
-
-#define NDIS_SET_PACKET_STATUS(_p, _status)
-
-
-#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
- rt_get_sg_list_from_packet(_p, _sc)
-
-
-#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
-#define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
-#define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
-#define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
-#define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
-
-
-#define RTMP_INC_REF(_A) 0
-#define RTMP_DEC_REF(_A) 0
-#define RTMP_GET_REF(_A) 0
-
-
-
-/*
- * ULONG
- * RTMP_GetPhysicalAddressLow(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
-
-/*
- * ULONG
- * RTMP_GetPhysicalAddressHigh(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
-
-/*
- * VOID
- * RTMP_SetPhysicalAddressLow(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
- * IN ULONG Value);
- */
-#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
- PhysicalAddress = Value;
-
-/*
- * VOID
- * RTMP_SetPhysicalAddressHigh(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
- * IN ULONG Value);
- */
-#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
-
-
-//CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
-#define QUEUE_ENTRY_TO_PACKET(pEntry) \
- (PNDIS_PACKET)(pEntry)
-
-#define PACKET_TO_QUEUE_ENTRY(pPacket) \
- (PQUEUE_ENTRY)(pPacket)
-
-
-#ifndef CONTAINING_RECORD
-#define CONTAINING_RECORD(address, type, field) \
-((type *)((PCHAR)(address) - offsetof(type, field)))
-#endif
-
-
-#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
-{ \
- RTMPFreeNdisPacket(_pAd, _pPacket); \
-}
-
-
-#define SWITCH_PhyAB(_pAA, _pBB) \
-{ \
- ULONG AABasePaHigh; \
- ULONG AABasePaLow; \
- ULONG BBBasePaHigh; \
- ULONG BBBasePaLow; \
- BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \
- BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \
- AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \
- AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \
- RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \
- RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \
- RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \
- RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \
-}
-
-
-#define NdisWriteErrorLogEntry(_a, _b, _c, _d)
-#define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS
-
-
-#define NdisAcquireSpinLock RTMP_SEM_LOCK
-#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
-
-static inline void NdisGetSystemUpTime(ULONG *time)
-{
- *time = jiffies;
-}
-
-//pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
-#define QUEUE_ENTRY_TO_PKT(pEntry) \
- ((PNDIS_PACKET) (pEntry))
-
-int rt28xx_packet_xmit(struct sk_buff *skb);
-
-
-
-void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
-
-
+#include "../rt2860/rt_linux.h"
diff --git a/drivers/staging/rt2870/rt_main_dev.c b/drivers/staging/rt2870/rt_main_dev.c
index 48ad41136d0f..121e1636017a 100644
--- a/drivers/staging/rt2870/rt_main_dev.c
+++ b/drivers/staging/rt2870/rt_main_dev.c
@@ -1,1865 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rt_main_dev.c
-
- Abstract:
- Create and register network interface.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Sample Mar/21/07 Merge RT2870 and RT2860 drivers.
-*/
-
-#include "rt_config.h"
-
-#define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// record whether the card in the card list is used in the card file
-UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD];
-// record used card mac address in the card list
-static UINT8 MC_CardMac[MAX_NUM_OF_MULTIPLE_CARD][6];
-#endif // MULTIPLE_CARD_SUPPORT //
-
-/*---------------------------------------------------------------------*/
-/* Private Variables Used */
-/*---------------------------------------------------------------------*/
-//static RALINK_TIMER_STRUCT PeriodicTimer;
-
-char *mac = ""; // default 00:00:00:00:00:00
-char *hostname = "";
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)
-MODULE_PARM (mac, "s");
-#else
-module_param (mac, charp, 0);
-#endif
-MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
-
-
-/*---------------------------------------------------------------------*/
-/* Prototypes of Functions Used */
-/*---------------------------------------------------------------------*/
-#ifdef DOT11_N_SUPPORT
-extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
-extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
-extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
-
-
-// public function prototype
-INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
- IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
-
-// private function prototype
-static int rt28xx_init(IN struct net_device *net_dev);
-INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
-
-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
-struct net_device *alloc_netdev(
- int sizeof_priv,
- const char *mask,
- void (*setup)(struct net_device *));
-#endif // LINUX_VERSION_CODE //
-
-static void CfgInitHook(PRTMP_ADAPTER pAd);
-//static BOOLEAN RT28XXAvailRANameAssign(IN CHAR *name_p);
-
-#ifdef CONFIG_STA_SUPPORT
-extern const struct iw_handler_def rt28xx_iw_handler_def;
-#endif // CONFIG_STA_SUPPORT //
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
- IN struct net_device *net_dev);
-#endif
-
-struct net_device_stats *RT28xx_get_ether_stats(
- IN struct net_device *net_dev);
-
-/*
-========================================================================
-Routine Description:
- Close raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
- 1. if open fail, kernel will not call the close function.
- 2. Free memory for
- (1) Mlme Memory Handler: MlmeHalt()
- (2) TX & RX: RTMPFreeTxRxRingMemory()
- (3) BA Reordering: ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_close(IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
- // Sanity check for pAd
- if (pAd == NULL)
- return 0; // close ok
-
- netif_carrier_off(pAd->net_dev);
- netif_stop_queue(pAd->net_dev);
-
-
-
- VIRTUAL_IF_DOWN(pAd);
-
- RT_MOD_DEC_USE_COUNT();
-
- return 0; // close ok
-}
-
-/*
-========================================================================
-Routine Description:
- Open raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
- 1. if open fail, kernel will not call the close function.
- 2. Free memory for
- (1) Mlme Memory Handler: MlmeHalt()
- (2) TX & RX: RTMPFreeTxRxRingMemory()
- (3) BA Reordering: ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_open(IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
- // Sanity check for pAd
- if (pAd == NULL)
- return 0; // close ok
-
- if (VIRTUAL_IF_UP(pAd) != 0)
- return -1;
-
- // increase MODULE use count
- RT_MOD_INC_USE_COUNT();
-
- netif_start_queue(net_dev);
- netif_carrier_on(net_dev);
- netif_wake_queue(net_dev);
-
- return 0;
-}
-
-/*
-========================================================================
-Routine Description:
- Close raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
- 1. if open fail, kernel will not call the close function.
- 2. Free memory for
- (1) Mlme Memory Handler: MlmeHalt()
- (2) TX & RX: RTMPFreeTxRxRingMemory()
- (3) BA Reordering: ba_reordering_resource_release()
-========================================================================
-*/
-int rt28xx_close(IN PNET_DEV dev)
-{
- struct net_device * net_dev = (struct net_device *)dev;
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
- BOOLEAN Cancelled = FALSE;
- UINT32 i = 0;
-#ifdef RT2870
- DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
- DECLARE_WAITQUEUE(wait, current);
-
- //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif // RT2870 //
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
-
- // Sanity check for pAd
- if (pAd == NULL)
- return 0; // close ok
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- // If dirver doesn't wake up firmware here,
- // NICLoadFirmware will hang forever when interface is up again.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- AsicForceWakeup(pAd, TRUE);
- }
-
-#ifdef QOS_DLS_SUPPORT
- // send DLS-TEAR_DOWN message,
- if (pAd->CommonCfg.bDLSCapable)
- {
- UCHAR i;
-
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
- RT28XX_MLME_HANDLER(pAd);
- }
-#endif // QOS_DLS_SUPPORT //
-
- if (INFRA_ON(pAd) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- MLME_DISASSOC_REQ_STRUCT DisReq;
- MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
- DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
-
- MsgElem->Machine = ASSOC_STATE_MACHINE;
- MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
- MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
- NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAd->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
- MlmeDisassocReqAction(pAd, MsgElem);
- kfree(MsgElem);
-
- RTMPusecDelay(1000);
- }
-
-#ifdef RT2870
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif // RT2870 //
-
-#ifdef CCX_SUPPORT
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
-#endif
-
- RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
- RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- // send wireless event to wpa_supplicant for infroming interface down.
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_INTERFACE_DOWN;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- MlmeRadioOff(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
- for (i = 0 ; i < NUM_OF_TX_RING; i++)
- {
- while (pAd->DeQueueRunning[i] == TRUE)
- {
- printk("Waiting for TxQueue[%d] done..........\n", i);
- RTMPusecDelay(1000);
- }
- }
-
-#ifdef RT2870
- // ensure there are no more active urbs.
- add_wait_queue (&unlink_wakeup, &wait);
- pAd->wait = &unlink_wakeup;
-
- // maybe wait for deletions to finish.
- i = 0;
- //while((i < 25) && atomic_read(&pAd->PendingRx) > 0)
- while(i < 25)
- {
- unsigned long IrqFlags;
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- if (pAd->PendingRx == 0)
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- break;
- }
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
- msleep(UNLINK_TIMEOUT_MS); //Time in millisecond
-#else
- RTMPusecDelay(UNLINK_TIMEOUT_MS*1000); //Time in microsecond
-#endif
- i++;
- }
- pAd->wait = NULL;
- remove_wait_queue (&unlink_wakeup, &wait);
-#endif // RT2870 //
-
- //RTUSBCleanUpMLMEWaitQueue(pAd); /*not used in RT28xx*/
-
-
-#ifdef RT2870
- // We need clear timerQ related structure before exits of the timer thread.
- RT2870_TimerQ_Exit(pAd);
- // Close kernel threads or tasklets
- RT28xxThreadTerminate(pAd);
-#endif // RT2870 //
-
- // Stop Mlme state machine
- MlmeHalt(pAd);
-
- // Close kernel threads or tasklets
- kill_thread_task(pAd);
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- MacTableReset(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- MeasureReqTabExit(pAd);
- TpcReqTabExit(pAd);
-
-
-
-
- // Free Ring or USB buffers
- RTMPFreeTxRxRingMemory(pAd);
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
-#ifdef DOT11_N_SUPPORT
- // Free BA reorder resource
- ba_reordering_resource_release(pAd);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef RT2870
-#ifdef INF_AMAZON_SE
- if (pAd->UsbVendorReqBuf)
- os_free_mem(pAd, pAd->UsbVendorReqBuf);
-#endif // INF_AMAZON_SE //
-#endif // RT2870 //
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
- return 0; // close ok
-} /* End of rt28xx_close */
-
-static int rt28xx_init(IN struct net_device *net_dev)
-{
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- UINT index;
- UCHAR TmpPhy;
- NDIS_STATUS Status;
- UINT32 MacCsr0 = 0;
-
-#ifdef RT2870
-#ifdef INF_AMAZON_SE
- init_MUTEX(&(pAd->UsbVendorReq_semaphore));
- os_alloc_mem(pAd, (PUCHAR)&pAd->UsbVendorReqBuf, MAX_PARAM_BUFFER_SIZE - 1);
- if (pAd->UsbVendorReqBuf == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Allocate vendor request temp buffer failed!\n"));
- goto err0;
- }
-#endif // INF_AMAZON_SE //
-#endif // RT2870 //
-
-#ifdef DOT11_N_SUPPORT
- // Allocate BA Reordering memory
- ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
-#endif // DOT11_N_SUPPORT //
-
- // Make sure MAC gets ready.
- index = 0;
- do
- {
- RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
- pAd->MACVersion = MacCsr0;
-
- if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
- break;
-
- RTMPusecDelay(10);
- } while (index++ < 100);
-
- DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
-
- // Disable DMA
- RT28XXDMADisable(pAd);
-
-
- // Load 8051 firmware
- Status = NICLoadFirmware(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
- goto err1;
- }
-
- NICLoadRateSwitchingParams(pAd);
-
- // Disable interrupts here which is as soon as possible
- // This statement should never be true. We might consider to remove it later
-
- Status = RTMPAllocTxRxRingMemory(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
- goto err1;
- }
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-
- // initialize MLME
- //
-
- Status = MlmeInit(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
- goto err2;
- }
-
- // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
- //
- UserCfgInit(pAd);
-
-#ifdef RT2870
- // We need init timerQ related structure before create the timer thread.
- RT2870_TimerQ_Init(pAd);
-#endif // RT2870 //
-
- RT28XX_TASK_THREAD_INIT(pAd, Status);
- if (Status != NDIS_STATUS_SUCCESS)
- goto err1;
-
-// COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].Bssid, netif->hwaddr);
-// pAd->bForcePrintTX = TRUE;
-
- CfgInitHook(pAd);
-
-
-#ifdef BLOCK_NET_IF
- initblockQueueTab(pAd);
-#endif // BLOCK_NET_IF //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisAllocateSpinLock(&pAd->MacTabLock);
-#endif // CONFIG_STA_SUPPORT //
-
- MeasureReqTabInit(pAd);
- TpcReqTabInit(pAd);
-
- //
- // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
- //
- Status = NICInitializeAdapter(pAd, TRUE);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
- if (Status != NDIS_STATUS_SUCCESS)
- goto err3;
- }
-
- // Read parameters from Config File
- Status = RTMPReadParametersHook(pAd);
-
- printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
- goto err4;
- }
-
-#ifdef RT2870
- pAd->CommonCfg.bMultipleIRP = FALSE;
-
- if (pAd->CommonCfg.bMultipleIRP)
- pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
- else
- pAd->CommonCfg.NumOfBulkInIRP = 1;
-#endif // RT2870 //
-
-
- //Init Ba Capability parameters.
-// RT28XX_BA_INIT(pAd);
-#ifdef DOT11_N_SUPPORT
- pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
- pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
- pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
- // UPdata to HT IE
- pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
- pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-#endif // DOT11_N_SUPPORT //
-
- // after reading Registry, we now know if in AP mode or STA mode
-
- // Load 8051 firmware; crash when FW image not existent
- // Status = NICLoadFirmware(pAd);
- // if (Status != NDIS_STATUS_SUCCESS)
- // break;
-
- printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-
- // We should read EEPROM for all cases. rt2860b
- NICReadEEPROMParameters(pAd, mac);
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-
- NICInitAsicFromEEPROM(pAd); //rt2860b
-
- // Set PHY to appropriate mode
- TmpPhy = pAd->CommonCfg.PhyMode;
- pAd->CommonCfg.PhyMode = 0xff;
- RTMPSetPhyMode(pAd, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
-
- // No valid channels.
- if (pAd->ChannelListNum == 0)
- {
- printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
- goto err4;
- }
-
-#ifdef DOT11_N_SUPPORT
- printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
- pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
- pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef RT2870
- //Init RT30xx RFRegisters after read RFIC type from EEPROM
- NICInitRT30xxRFRegisters(pAd);
-#endif // RT2870 //
-
-#if 0
- // Patch cardbus controller if EEPROM said so.
- if (pAd->bTest1 == FALSE)
- RTMPPatchCardBus(pAd);
-#endif
-
-
-// APInitialize(pAd);
-
-#ifdef IKANOS_VX_1X0
- VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
-#endif // IKANOS_VX_1X0 //
-
- //
- // Initialize RF register to default value
- //
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- // 8051 firmware require the signal during booting time.
- AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
-
- if (pAd && (Status != NDIS_STATUS_SUCCESS))
- {
- //
- // Undo everything if it failed
- //
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
-// NdisMDeregisterInterrupt(&pAd->Interrupt);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
- }
-// RTMPFreeAdapter(pAd); // we will free it in disconnect()
- }
- else if (pAd)
- {
- // Microsoft HCT require driver send a disconnect event after driver initialization.
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-// pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
-
-
-#ifdef RT2870
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-
- //
- // Support multiple BulkIn IRP,
- // the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.
- //
- for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++)
- {
- RTUSBBulkReceive(pAd);
- DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" ));
- }
-#endif // RT2870 //
- }// end of else
-
-
- DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
-
- return TRUE;
-
-
-err4:
-err3:
- MlmeHalt(pAd);
-err2:
- RTMPFreeTxRxRingMemory(pAd);
-// RTMPFreeAdapter(pAd);
-err1:
-
-#ifdef DOT11_N_SUPPORT
- os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
-#endif // DOT11_N_SUPPORT //
- RT28XX_IRQ_RELEASE(net_dev);
-
- // shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
- //net_dev->ml_priv = 0;
-#ifdef INF_AMAZON_SE
-err0:
-#endif // INF_AMAZON_SE //
- printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
- return FALSE;
-} /* End of rt28xx_init */
-
-
-/*
-========================================================================
-Routine Description:
- Open raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
-========================================================================
-*/
-int rt28xx_open(IN PNET_DEV dev)
-{
- struct net_device * net_dev = (struct net_device *)dev;
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- int retval = 0;
- POS_COOKIE pObj;
-
-
- // Sanity check for pAd
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -1;
- }
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (pAd->OpMode == OPMODE_AP)
- {
- CW_MAX_IN_BITS = 6;
- }
- else if (pAd->OpMode == OPMODE_STA)
- {
- CW_MAX_IN_BITS = 10;
- }
-
-#if WIRELESS_EXT >= 12
- if (net_dev->priv_flags == INT_MAIN)
- {
- if (pAd->OpMode == OPMODE_AP)
- net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
- else if (pAd->OpMode == OPMODE_STA)
- net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
- }
-#endif // WIRELESS_EXT >= 12 //
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- // Init
- pObj = (POS_COOKIE)pAd->OS_Cookie;
-
- // reset Adapter flags
- RTMP_CLEAR_FLAGS(pAd);
-
- // Request interrupt service routine for PCI device
- // register the interrupt routine with the os
- RT28XX_IRQ_REQUEST(net_dev);
-
-
- // Init BssTab & ChannelInfo tabbles for auto channel select.
-
-
- // Chip & other init
- if (rt28xx_init(net_dev) == FALSE)
- goto err;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NdisZeroMemory(pAd->StaCfg.dev_name, 16);
- NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Set up the Mac address
- NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
-
- // Init IRQ parameters
- RT28XX_IRQ_INIT(pAd);
-
- // Various AP function init
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- // send wireless event to wpa_supplicant for infroming interface down.
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_INTERFACE_UP;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Enable Interrupt
- RT28XX_IRQ_ENABLE(pAd);
-
- // Now Enable RxTx
- RTMPEnableRxTx(pAd);
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
- {
- UINT32 reg = 0;
- RTMP_IO_READ32(pAd, 0x1300, &reg); // clear garbage interrupts
- printk("0x1300 = %08x\n", reg);
- }
-
- {
-// u32 reg;
-// u8 byte;
-// u16 tmp;
-
-// RTMP_IO_READ32(pAd, XIFS_TIME_CFG, &reg);
-
-// tmp = 0x0805;
-// reg = (reg & 0xffff0000) | tmp;
-// RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg);
-
- }
-
-#if 0
- /*
- * debugging helper
- * show the size of main table in Adapter structure
- * MacTab -- 185K
- * BATable -- 137K
- * Total -- 385K !!!!! (5/26/2006)
- */
- printk("sizeof(pAd->MacTab) = %ld\n", sizeof(pAd->MacTab));
- printk("sizeof(pAd->AccessControlList) = %ld\n", sizeof(pAd->AccessControlList));
- printk("sizeof(pAd->ApCfg) = %ld\n", sizeof(pAd->ApCfg));
- printk("sizeof(pAd->BATable) = %ld\n", sizeof(pAd->BATable));
- BUG();
-#endif
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- return (retval);
-
-err:
- return (-1);
-} /* End of rt28xx_open */
-
-static const struct net_device_ops rt2870_netdev_ops = {
- .ndo_open = MainVirtualIF_open,
- .ndo_stop = MainVirtualIF_close,
- .ndo_do_ioctl = rt28xx_ioctl,
- .ndo_get_stats = RT28xx_get_ether_stats,
- .ndo_validate_addr = NULL,
- .ndo_set_mac_address = eth_mac_addr,
- .ndo_change_mtu = eth_change_mtu,
-#ifdef IKANOS_VX_1X0
- .ndo_start_xmit = IKANOS_DataFramesTx,
-#else
- .ndo_start_xmit = rt28xx_send_packets,
-#endif
-};
-
-/* Must not be called for mdev and apdev */
-static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS Status;
- INT i=0;
- CHAR slot_name[IFNAMSIZ];
- struct net_device *device;
-
-
- //ether_setup(dev);
-// dev->set_multicast_list = ieee80211_set_multicast_list;
-// dev->change_mtu = ieee80211_change_mtu;
-#ifdef CONFIG_STA_SUPPORT
-#if WIRELESS_EXT >= 12
- if (pAd->OpMode == OPMODE_STA)
- {
- dev->wireless_handlers = &rt28xx_iw_handler_def;
- }
-#endif //WIRELESS_EXT >= 12
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-#if WIRELESS_EXT >= 12
- if (pAd->OpMode == OPMODE_AP)
- {
- dev->wireless_handlers = &rt28xx_ap_iw_handler_def;
- }
-#endif //WIRELESS_EXT >= 12
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-#if WIRELESS_EXT < 21
- dev->get_wireless_stats = rt28xx_get_wireless_stats;
-#endif
-// dev->uninit = ieee80211_if_reinit;
-// dev->destructor = ieee80211_if_free;
- dev->priv_flags = INT_MAIN;
- dev->netdev_ops = &rt2870_netdev_ops;
- // find available device name
- for (i = 0; i < 8; i++)
- {
-#ifdef MULTIPLE_CARD_SUPPORT
- if (pAd->MC_RowID >= 0)
- sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i);
- else
-#endif // MULTIPLE_CARD_SUPPORT //
- sprintf(slot_name, "ra%d", i);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
- device = dev_get_by_name(dev_net(dev), slot_name);
-#else
- device = dev_get_by_name(dev->nd_net, slot_name);
-#endif
-#else
- device = dev_get_by_name(slot_name);
-#endif
- if (device != NULL) dev_put(device);
-#else
- for (device = dev_base; device != NULL; device = device->next)
- {
- if (strncmp(device->name, slot_name, 4) == 0)
- break;
- }
-#endif
- if(device == NULL)
- break;
- }
-
- if(i == 8)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
-#ifdef MULTIPLE_CARD_SUPPORT
- if (pAd->MC_RowID >= 0)
- sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i);
- else
-#endif // MULTIPLE_CARD_SUPPORT //
- sprintf(dev->name, "ra%d", i);
- Status = NDIS_STATUS_SUCCESS;
- }
-
- return Status;
-
-}
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
-/*
-========================================================================
-Routine Description:
- Get card profile path.
-
-Arguments:
- pAd
-
-Return Value:
- TRUE - Find a card profile
- FALSE - use default profile
-
-Note:
-========================================================================
-*/
-extern INT RTMPGetKeyParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer);
-
-BOOLEAN RTMP_CardInfoRead(
- IN PRTMP_ADAPTER pAd)
-{
-#define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
-#define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
-#define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
-
-#define LETTER_CASE_TRANSLATE(txt_p, card_id) \
- { UINT32 _len; char _char; \
- for(_len=0; _len<strlen(card_id); _len++) { \
- _char = *(txt_p + _len); \
- if (('A' <= _char) && (_char <= 'Z')) \
- *(txt_p+_len) = 'a'+(_char-'A'); \
- } }
-
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30];
- BOOLEAN flg_match_ok = FALSE;
- INT32 card_select_method;
- INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
- EEPROM_ANTENNA_STRUC antenna;
- USHORT addr01, addr23, addr45;
- UINT8 mac[6];
- UINT32 data, card_index;
- UCHAR *start_ptr;
-
-
- // init
- buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if (buffer == NULL)
- return FALSE;
-
- tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(tmpbuf == NULL)
- {
- kfree(buffer);
- return NDIS_STATUS_FAILURE;
- }
-
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- // get RF IC type
- RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
-
- if ((data & 0x30) == 0)
- pAd->EEPROMAddressNum = 6; // 93C46
- else if ((data & 0x30) == 0x10)
- pAd->EEPROMAddressNum = 8; // 93C66
- else
- pAd->EEPROMAddressNum = 8; // 93C86
-
- //antenna.word = RTMP_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET);
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
-
- if ((antenna.field.RfIcType == RFIC_2850) ||
- (antenna.field.RfIcType == RFIC_2750))
- {
- /* ABGN card */
- strcpy(RFIC_word, "abgn");
- }
- else
- {
- /* BGN card */
- strcpy(RFIC_word, "bgn");
- }
-
- // get MAC address
- //addr01 = RTMP_EEPROM_READ16(pAd, 0x04);
- //addr23 = RTMP_EEPROM_READ16(pAd, 0x06);
- //addr45 = RTMP_EEPROM_READ16(pAd, 0x08);
- RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
- RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
- RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
-
- mac[0] = (UCHAR)(addr01 & 0xff);
- mac[1] = (UCHAR)(addr01 >> 8);
- mac[2] = (UCHAR)(addr23 & 0xff);
- mac[3] = (UCHAR)(addr23 >> 8);
- mac[4] = (UCHAR)(addr45 & 0xff);
- mac[5] = (UCHAR)(addr45 >> 8);
-
- // open card information file
- srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
- if (IS_ERR(srcf))
- {
- /* card information file does not exist */
- DBGPRINT(RT_DEBUG_TRACE,
- ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH));
- return FALSE;
- }
-
- if (srcf->f_op && srcf->f_op->read)
- {
- /* card information file exists so reading the card information */
- memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
- retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
- if (retval < 0)
- {
- /* read fail */
- DBGPRINT(RT_DEBUG_TRACE,
- ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
- }
- else
- {
- /* get card selection method */
- memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
- card_select_method = MC_SELECT_CARDTYPE; // default
-
- if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer))
- {
- if (strcmp(tmpbuf, "CARDID") == 0)
- card_select_method = MC_SELECT_CARDID;
- else if (strcmp(tmpbuf, "MAC") == 0)
- card_select_method = MC_SELECT_MAC;
- else if (strcmp(tmpbuf, "CARDTYPE") == 0)
- card_select_method = MC_SELECT_CARDTYPE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> Card Selection = %d\n", card_select_method));
-
- // init
- card_free_id = -1;
- card_nouse_id = -1;
- card_same_mac_id = -1;
- card_match_id = -1;
-
- // search current card information records
- for(card_index=0;
- card_index<MAX_NUM_OF_MULTIPLE_CARD;
- card_index++)
- {
- if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
- (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
- {
- // MAC is all-0 so the entry is available
- MC_CardUsed[card_index] = 0;
-
- if (card_free_id < 0)
- card_free_id = card_index; // 1st free entry
- }
- else
- {
- if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
- {
- // we find the entry with same MAC
- if (card_same_mac_id < 0)
- card_same_mac_id = card_index; // 1st same entry
- }
- else
- {
- // MAC is not all-0 but used flag == 0
- if ((MC_CardUsed[card_index] == 0) &&
- (card_nouse_id < 0))
- {
- card_nouse_id = card_index; // 1st available entry
- }
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> Free = %d, Same = %d, NOUSE = %d\n",
- card_free_id, card_same_mac_id, card_nouse_id));
-
- if ((card_same_mac_id >= 0) &&
- ((card_select_method == MC_SELECT_CARDID) ||
- (card_select_method == MC_SELECT_CARDTYPE)))
- {
- // same MAC entry is found
- card_match_id = card_same_mac_id;
-
- if (card_select_method == MC_SELECT_CARDTYPE)
- {
- // for CARDTYPE
- sprintf(card_id_buf, "%02dCARDTYPE%s",
- card_match_id, RFIC_word);
-
- if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
- {
- // we found the card ID
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
- }
- }
- }
- else
- {
- // the card is 1st plug-in, try to find the match card profile
- switch(card_select_method)
- {
- case MC_SELECT_CARDID: // CARDID
- default:
- if (card_free_id >= 0)
- card_match_id = card_free_id;
- else
- card_match_id = card_nouse_id;
- break;
-
- case MC_SELECT_MAC: // MAC
- sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
-
- /* try to find the key word in the card file */
- if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
- {
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
-
- /* get the row ID (2 ASCII characters) */
- start_ptr -= 2;
- card_id_buf[0] = *(start_ptr);
- card_id_buf[1] = *(start_ptr+1);
- card_id_buf[2] = 0x00;
-
- card_match_id = simple_strtol(card_id_buf, 0, 10);
- }
- break;
-
- case MC_SELECT_CARDTYPE: // CARDTYPE
- card_nouse_id = -1;
-
- for(card_index=0;
- card_index<MAX_NUM_OF_MULTIPLE_CARD;
- card_index++)
- {
- sprintf(card_id_buf, "%02dCARDTYPE%s",
- card_index, RFIC_word);
-
- if ((start_ptr=rtstrstruncasecmp(buffer,
- card_id_buf)) != NULL)
- {
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
-
- if (MC_CardUsed[card_index] == 0)
- {
- /* current the card profile is not used */
- if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
- (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
- {
- // find it and no previous card use it
- card_match_id = card_index;
- break;
- }
- else
- {
- // ever a card use it
- if (card_nouse_id < 0)
- card_nouse_id = card_index;
- }
- }
- }
- }
-
- // if not find a free one, use the available one
- if (card_match_id < 0)
- card_match_id = card_nouse_id;
- break;
- }
- }
-
- if (card_match_id >= 0)
- {
- // make up search keyword
- switch(card_select_method)
- {
- case MC_SELECT_CARDID: // CARDID
- sprintf(card_id_buf, "%02dCARDID", card_match_id);
- break;
-
- case MC_SELECT_MAC: // MAC
- sprintf(card_id_buf,
- "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
- card_match_id,
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
- break;
-
- case MC_SELECT_CARDTYPE: // CARDTYPE
- default:
- sprintf(card_id_buf, "%02dcardtype%s",
- card_match_id, RFIC_word);
- break;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
-
- // read card file path
- if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer))
- {
- if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
- {
- // backup card information
- pAd->MC_RowID = card_match_id; /* base 0 */
- MC_CardUsed[card_match_id] = 1;
- memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
-
- // backup card file path
- NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
- pAd->MC_FileName[strlen(tmpbuf)] = '\0';
- flg_match_ok = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("Card Profile Name = %s\n", pAd->MC_FileName));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("Card Profile Name length too large!\n"));
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("Can not find search key word in card.dat!\n"));
- }
-
- if ((flg_match_ok != TRUE) &&
- (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
- {
- MC_CardUsed[card_match_id] = 0;
- memset(MC_CardMac[card_match_id], 0, sizeof(mac));
- }
- } // if (card_match_id >= 0)
- }
- }
-
- // close file
- retval = filp_close(srcf, NULL);
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
- kfree(buffer);
- kfree(tmpbuf);
- return flg_match_ok;
-}
-#endif // MULTIPLE_CARD_SUPPORT //
-
-
-/*
-========================================================================
-Routine Description:
- Probe RT28XX chipset.
-
-Arguments:
- _dev_p Point to the PCI or USB device
- _dev_id_p Point to the PCI or USB device ID
-
-Return Value:
- 0 Probe OK
- -ENODEV Probe Fail
-
-Note:
-========================================================================
-*/
-INT __devinit rt28xx_probe(
- IN void *_dev_p,
- IN void *_dev_id_p,
- IN UINT argc,
- OUT PRTMP_ADAPTER *ppAd)
-{
- struct net_device *net_dev;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
- INT status;
- PVOID handle;
-#ifdef RT2870
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
-#else
- struct usb_interface *intf = (struct usb_interface *)_dev_p;
- struct usb_device *dev_p = interface_to_usbdev(intf);
-
- dev_p = usb_get_dev(dev_p);
-#endif // LINUX_VERSION_CODE //
-#endif // RT2870 //
-
-
-#ifdef CONFIG_STA_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
-#endif // CONFIG_STA_SUPPORT //
-
- // Check chipset vendor/product ID
-// if (RT28XXChipsetCheck(_dev_p) == FALSE)
-// goto err_out;
-
-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
- net_dev = alloc_netdev(sizeof(PRTMP_ADAPTER), "eth%d", ether_setup);
-#else
- net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
-#endif
- if (net_dev == NULL)
- {
- printk("alloc_netdev failed\n");
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
- module_put(THIS_MODULE);
-#endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
-#else
- MOD_DEC_USE_COUNT;
-#endif
- goto err_out;
- }
-
-// sample
-// if (rt_ieee80211_if_setup(net_dev) != NDIS_STATUS_SUCCESS)
-// goto err_out;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- SET_MODULE_OWNER(net_dev);
-#endif
-
- netif_stop_queue(net_dev);
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-/* for supporting Network Manager */
-/* Set the sysfs physical device reference for the network logical device
- * if set prior to registration will cause a symlink during initialization.
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
- SET_NETDEV_DEV(net_dev, &(dev_p->dev));
-#endif
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- // Allocate RTMP_ADAPTER miniport adapter structure
- handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
- RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
-
- status = RTMPAllocAdapterBlock(handle, &pAd);
- if (status != NDIS_STATUS_SUCCESS)
- goto err_out_free_netdev;
-
- net_dev->ml_priv = (PVOID)pAd;
- pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
-
- RT28XXNetDevInit(_dev_p, net_dev, pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- pAd->StaCfg.OriDevType = net_dev->type;
-#endif // CONFIG_STA_SUPPORT //
-
- // Find and assign a free interface name, raxx
-// RT28XXAvailRANameAssign(net_dev->name);
-
- // Post config
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- if (RT28XXProbePostConfig(_dev_p, pAd, argc) == FALSE)
- goto err_out_unmap;
-#else
- if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
- goto err_out_unmap;
-#endif // LINUX_VERSION_CODE //
-
-#ifdef CONFIG_STA_SUPPORT
- pAd->OpMode = OPMODE_STA;
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
- // find its profile path
- pAd->MC_RowID = -1; // use default profile path
- RTMP_CardInfoRead(pAd);
-
- if (pAd->MC_RowID == -1)
-#ifdef CONFIG_STA_SUPPORT
- strcpy(pAd->MC_FileName, STA_PROFILE_PATH);
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName));
-#endif // MULTIPLE_CARD_SUPPORT //
-
- // sample move
- if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
- goto err_out_unmap;
-
- // Register this device
- status = register_netdev(net_dev);
- if (status)
- goto err_out_unmap;
-
- // Set driver data
- RT28XX_DRVDATA_SET(_dev_p);
-
-
-
- *ppAd = pAd;
- return 0; // probe ok
-
-
- /* --------------------------- ERROR HANDLE --------------------------- */
-err_out_unmap:
- RTMPFreeAdapter(pAd);
- RT28XX_UNMAP();
-
-err_out_free_netdev:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- free_netdev(net_dev);
-#else
- kfree(net_dev);
-#endif
-
-err_out:
- RT28XX_PUT_DEVICE(dev_p);
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- return (LONG)NULL;
-#else
- return -ENODEV; /* probe fail */
-#endif // LINUX_VERSION_CODE //
-} /* End of rt28xx_probe */
-
-
-/*
-========================================================================
-Routine Description:
- The entry point for Linux kernel sent packet to our driver.
-
-Arguments:
- sk_buff *skb the pointer refer to a sk_buffer.
-
-Return Value:
- 0
-
-Note:
- This function is the entry point of Tx Path for Os delivery packet to
- our driver. You only can put OS-depened & STA/AP common handle procedures
- in here.
-========================================================================
-*/
-int rt28xx_packet_xmit(struct sk_buff *skb)
-{
- struct net_device *net_dev = skb->dev;
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- int status = 0;
- PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
-
- /* RT2870STA does this in RTMPSendPackets() */
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES);
- return 0;
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Drop send request since we are in monitor mode
- if (MONITOR_ON(pAd))
- {
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- goto done;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // EapolStart size is 18
- if (skb->len < 14)
- {
- //printk("bad packet size: %d\n", pkt->len);
- hex_dump("bad packet", skb->data, skb->len);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- goto done;
- }
-
-#if 0
-// if ((pkt->data[0] & 0x1) == 0)
- {
- //hex_dump(__func__, pkt->data, pkt->len);
- printk("pPacket = %x\n", pPacket);
- }
-#endif
-
- RTMP_SET_PACKET_5VT(pPacket, 0);
-// MiniportMMRequest(pAd, pkt->data, pkt->len);
-#ifdef CONFIG_5VT_ENHANCE
- if (*(int*)(skb->cb) == BRIDGE_TAG) {
- RTMP_SET_PACKET_5VT(pPacket, 1);
- }
-#endif
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
- }
-
-#endif // CONFIG_STA_SUPPORT //
-
- status = 0;
-done:
-
- return status;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Send a packet to WLAN.
-
-Arguments:
- skb_p points to our adapter
- dev_p which WLAN network interface
-
-Return Value:
- 0: transmit successfully
- otherwise: transmit fail
-
-Note:
-========================================================================
-*/
-INT rt28xx_send_packets(
- IN struct sk_buff *skb_p,
- IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
- if (!(net_dev->flags & IFF_UP))
- {
- RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
- return 0;
- }
-
- NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
- RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
-
- return rt28xx_packet_xmit(skb_p);
-} /* End of MBSS_VirtualIF_PacketSend */
-
-
-
-
-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
-//static struct net_device *alloc_netdev(int sizeof_priv, const char *mask, void (*setup)(struct net_device *)) //sample
-struct net_device *alloc_netdev(
- int sizeof_priv,
- const char *mask,
- void (*setup)(struct net_device *))
-{
- struct net_device *dev;
- INT alloc_size;
-
-
- /* ensure 32-byte alignment of the private area */
- alloc_size = sizeof (*dev) + sizeof_priv + 31;
-
- dev = (struct net_device *) kmalloc(alloc_size, GFP_KERNEL);
- if (dev == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("alloc_netdev: Unable to allocate device memory.\n"));
- return NULL;
- }
-
- memset(dev, 0, alloc_size);
-
- if (sizeof_priv)
- dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
-
- setup(dev);
- strcpy(dev->name, mask);
-
- return dev;
-}
-#endif // LINUX_VERSION_CODE //
-
-
-void CfgInitHook(PRTMP_ADAPTER pAd)
-{
- pAd->bBroadComHT = TRUE;
-} /* End of CfgInitHook */
-
-
-#if 0 // Not used now, should keep it in our source tree??
-/*
-========================================================================
-Routine Description:
- Find and assign a free interface name (raxx).
-
-Arguments:
- *name_p the interface name pointer
-
-Return Value:
- TRUE OK
- FALSE FAIL
-
-Note:
-========================================================================
-*/
-static BOOLEAN RT28XXAvailRANameAssign(
- IN CHAR *name_p)
-{
- CHAR slot_name[IFNAMSIZ];
- struct net_device *device;
- UINT32 if_id;
-
-
- for(if_id=0; if_id<8; if_id++)
- {
- sprintf(slot_name, "ra%d", if_id);
-
- for(device=dev_base; device!=NULL; device=device->next)
- {
- if (strncmp(device->name, slot_name, 4) == 0)
- break;
- }
-
- if (device == NULL)
- break;
- }
-
- if (if_id == 8)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
- return FALSE;
- }
-
- sprintf(name_p, "ra%d", if_id);
- return TRUE;
-} /* End of RT28XXAvailRANameAssign */
-#endif
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
- IN struct net_device *net_dev)
-{
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
-
- pAd->iw_stats.status = 0; // Status - device dependent for now
-
- // link quality
- pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
- if(pAd->iw_stats.qual.qual > 100)
- pAd->iw_stats.qual.qual = 100;
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->OpMode == OPMODE_STA)
- pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
-#endif // CONFIG_STA_SUPPORT //
-
- pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
-
- pAd->iw_stats.qual.noise += 256 - 143;
- pAd->iw_stats.qual.updated = 1; // Flags to know if updated
-#ifdef IW_QUAL_DBM
- pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
-#endif // IW_QUAL_DBM //
-
- pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
- pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
-
- DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
- return &pAd->iw_stats;
-} /* End of rt28xx_get_wireless_stats */
-#endif // WIRELESS_EXT //
-
-
-
-void tbtt_tasklet(unsigned long data)
-{
-#define MAX_TX_IN_TBTT (16)
-
-}
-
-INT rt28xx_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- RTMP_ADAPTER *pAd = NULL;
- INT ret = 0;
-
- if (net_dev->priv_flags == INT_MAIN)
- {
- pAd = net_dev->ml_priv;
- }
- else
- {
- pVirtualAd = net_dev->ml_priv;
- pAd = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return ret;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- return ethernet statistics counter
-
- Arguments:
- net_dev Pointer to net_device
-
- Return Value:
- net_device_stats*
-
- Note:
-
- ========================================================================
-*/
-struct net_device_stats *RT28xx_get_ether_stats(
- IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = NULL;
-
- if (net_dev)
- pAd = net_dev->ml_priv;
-
- if (pAd)
- {
-
- pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
- pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
-
- pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
- pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
-
- pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
- pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
-
- pAd->stats.rx_dropped = 0;
- pAd->stats.tx_dropped = 0;
-
- pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
- pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
-
- pAd->stats.rx_length_errors = 0;
- pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
- pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
- pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
- pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
- pAd->stats.rx_missed_errors = 0; // receiver missed packet
-
- // detailed tx_errors
- pAd->stats.tx_aborted_errors = 0;
- pAd->stats.tx_carrier_errors = 0;
- pAd->stats.tx_fifo_errors = 0;
- pAd->stats.tx_heartbeat_errors = 0;
- pAd->stats.tx_window_errors = 0;
-
- // for cslip etc
- pAd->stats.rx_compressed = 0;
- pAd->stats.tx_compressed = 0;
-
- return &pAd->stats;
- }
- else
- return NULL;
-}
-
+#include "../rt2860/rt_main_dev.c"
diff --git a/drivers/staging/rt2870/rt_profile.c b/drivers/staging/rt2870/rt_profile.c
index 467fea35e4a9..15988c5d9df7 100644
--- a/drivers/staging/rt2870/rt_profile.c
+++ b/drivers/staging/rt2870/rt_profile.c
@@ -1,2020 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-#ifdef DOT11_N_SUPPORT
-static void HTParametersHook(
- IN PRTMP_ADAPTER pAd,
- IN CHAR *pValueStr,
- IN CHAR *pInput);
-#endif // DOT11_N_SUPPORT //
-
-#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
-
-// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
-BOOLEAN rtstrmactohex(char *s1, char *s2)
-{
- int i = 0;
- char *ptokS = s1, *ptokE = s1;
-
- if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
- return FALSE;
-
- while((*ptokS) != '\0')
- {
- if((ptokE = strchr(ptokS, ':')) != NULL)
- *ptokE++ = '\0';
- if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
- break; // fail
- AtoH(ptokS, &s2[i++], 1);
- ptokS = ptokE;
- if (i == 6)
- break; // parsing finished
- }
-
- return ( i == 6 ? TRUE : FALSE);
-
-}
-
-
-// we assume the s1 and s2 both are strings.
-BOOLEAN rtstrcasecmp(char *s1, char *s2)
-{
- char *p1 = s1, *p2 = s2;
-
- if (strlen(s1) != strlen(s2))
- return FALSE;
-
- while(*p1 != '\0')
- {
- if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
- return FALSE;
- p1++;
- p2++;
- }
-
- return TRUE;
-}
-
-// we assume the s1 (buffer) and s2 (key) both are strings.
-char * rtstrstruncasecmp(char * s1, char * s2)
-{
- INT l1, l2, i;
- char temp1, temp2;
-
- l2 = strlen(s2);
- if (!l2)
- return (char *) s1;
-
- l1 = strlen(s1);
-
- while (l1 >= l2)
- {
- l1--;
-
- for(i=0; i<l2; i++)
- {
- temp1 = *(s1+i);
- temp2 = *(s2+i);
-
- if (('a' <= temp1) && (temp1 <= 'z'))
- temp1 = 'A'+(temp1-'a');
- if (('a' <= temp2) && (temp2 <= 'z'))
- temp2 = 'A'+(temp2-'a');
-
- if (temp1 != temp2)
- break;
- }
-
- if (i == l2)
- return (char *) s1;
-
- s1++;
- }
-
- return NULL; // not found
-}
-
-//add by kathy
-
- /**
- * strstr - Find the first substring in a %NUL terminated string
- * @s1: The string to be searched
- * @s2: The string to search for
- */
-char * rtstrstr(const char * s1,const char * s2)
-{
- INT l1, l2;
-
- l2 = strlen(s2);
- if (!l2)
- return (char *) s1;
-
- l1 = strlen(s1);
-
- while (l1 >= l2)
- {
- l1--;
- if (!memcmp(s1,s2,l2))
- return (char *) s1;
- s1++;
- }
-
- return NULL;
-}
-
-/**
- * rstrtok - Split a string into tokens
- * @s: The string to be searched
- * @ct: The characters to search for
- * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
- */
-char * __rstrtok;
-char * rstrtok(char * s,const char * ct)
-{
- char *sbegin, *send;
-
- sbegin = s ? s : __rstrtok;
- if (!sbegin)
- {
- return NULL;
- }
-
- sbegin += strspn(sbegin,ct);
- if (*sbegin == '\0')
- {
- __rstrtok = NULL;
- return( NULL );
- }
-
- send = strpbrk( sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
-
- __rstrtok = send;
-
- return (sbegin);
-}
-
-/**
- * delimitcnt - return the count of a given delimiter in a given string.
- * @s: The string to be searched.
- * @ct: The delimiter to search for.
- * Notice : We suppose the delimiter is a single-char string(for example : ";").
- */
-INT delimitcnt(char * s,const char * ct)
-{
- INT count = 0;
- /* point to the beginning of the line */
- const char *token = s;
-
- for ( ;; )
- {
- token = strpbrk(token, ct); /* search for delimiters */
-
- if ( token == NULL )
- {
- /* advanced to the terminating null character */
- break;
- }
- /* skip the delimiter */
- ++token;
-
- /*
- * Print the found text: use len with %.*s to specify field width.
- */
-
- /* accumulate delimiter count */
- ++count;
- }
- return count;
-}
-
-/*
- * converts the Internet host address from the standard numbers-and-dots notation
- * into binary data.
- * returns nonzero if the address is valid, zero if not.
- */
-int rtinet_aton(const char *cp, unsigned int *addr)
-{
- unsigned int val;
- int base, n;
- char c;
- unsigned int parts[4];
- unsigned int *pp = parts;
-
- for (;;)
- {
- /*
- * Collect number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, other=decimal.
- */
- val = 0;
- base = 10;
- if (*cp == '0')
- {
- if (*++cp == 'x' || *cp == 'X')
- base = 16, cp++;
- else
- base = 8;
- }
- while ((c = *cp) != '\0')
- {
- if (isdigit((unsigned char) c))
- {
- val = (val * base) + (c - '0');
- cp++;
- continue;
- }
- if (base == 16 && isxdigit((unsigned char) c))
- {
- val = (val << 4) +
- (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
- cp++;
- continue;
- }
- break;
- }
- if (*cp == '.')
- {
- /*
- * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
- * a.b (with b treated as 24 bits)
- */
- if (pp >= parts + 3 || val > 0xff)
- return 0;
- *pp++ = val, cp++;
- }
- else
- break;
- }
-
- /*
- * Check for trailing junk.
- */
- while (*cp)
- if (!isspace((unsigned char) *cp++))
- return 0;
-
- /*
- * Concoct the address according to the number of parts specified.
- */
- n = pp - parts + 1;
- switch (n)
- {
-
- case 1: /* a -- 32 bits */
- break;
-
- case 2: /* a.b -- 8.24 bits */
- if (val > 0xffffff)
- return 0;
- val |= parts[0] << 24;
- break;
-
- case 3: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff)
- return 0;
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
- if (val > 0xff)
- return 0;
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- }
-
- *addr = htonl(val);
- return 1;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Find key section for Get key parameter.
-
- Arguments:
- buffer Pointer to the buffer to start find the key section
- section the key of the secion to be find
-
- Return Value:
- NULL Fail
- Others Success
- ========================================================================
-*/
-PUCHAR RTMPFindSection(
- IN PCHAR buffer)
-{
- CHAR temp_buf[32];
- PUCHAR ptr;
-
- strcpy(temp_buf, "Default");
-
- if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
- return (ptr+strlen("\n"));
- else
- return NULL;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get key parameter.
-
- Arguments:
- key Pointer to key string
- dest Pointer to destination
- destsize The datasize of the destination
- buffer Pointer to the buffer to start find the key
-
- Return Value:
- TRUE Success
- FALSE Fail
-
- Note:
- This routine get the value with the matched key (case case-sensitive)
- ========================================================================
-*/
-INT RTMPGetKeyParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer)
-{
- UCHAR *temp_buf1 = NULL;
- UCHAR *temp_buf2 = NULL;
- CHAR *start_ptr;
- CHAR *end_ptr;
- CHAR *ptr;
- CHAR *offset = 0;
- INT len;
-
- //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
- if(temp_buf1 == NULL)
- return (FALSE);
-
- //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
- if(temp_buf2 == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- return (FALSE);
- }
-
- //find section
- if((offset = RTMPFindSection(buffer)) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf1, "\n");
- strcat(temp_buf1, key);
- strcat(temp_buf1, "=");
-
- //search key
- if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- start_ptr+=strlen("\n");
- if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
- end_ptr=start_ptr+strlen(start_ptr);
-
- if (end_ptr<start_ptr)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
- temp_buf2[end_ptr-start_ptr]='\0';
- len = strlen(temp_buf2);
- strcpy(temp_buf1, temp_buf2);
- if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf2, start_ptr+1);
- ptr = temp_buf2;
- //trim space or tab
- while(*ptr != 0x00)
- {
- if( (*ptr == ' ') || (*ptr == '\t') )
- ptr++;
- else
- break;
- }
-
- len = strlen(ptr);
- memset(dest, 0x00, destsize);
- strncpy(dest, ptr, len >= destsize ? destsize: len);
-
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get key parameter.
-
- Arguments:
- key Pointer to key string
- dest Pointer to destination
- destsize The datasize of the destination
- buffer Pointer to the buffer to start find the key
-
- Return Value:
- TRUE Success
- FALSE Fail
-
- Note:
- This routine get the value with the matched key (case case-sensitive).
- It is called for parsing SSID and any key string.
- ========================================================================
-*/
-INT RTMPGetCriticalParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer)
-{
- UCHAR *temp_buf1 = NULL;
- UCHAR *temp_buf2 = NULL;
- CHAR *start_ptr;
- CHAR *end_ptr;
- CHAR *ptr;
- CHAR *offset = 0;
- INT len;
-
- //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
- if(temp_buf1 == NULL)
- return (FALSE);
-
- //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
- if(temp_buf2 == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- return (FALSE);
- }
-
- //find section
- if((offset = RTMPFindSection(buffer)) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf1, "\n");
- strcat(temp_buf1, key);
- strcat(temp_buf1, "=");
-
- //search key
- if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- start_ptr+=strlen("\n");
- if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
- end_ptr=start_ptr+strlen(start_ptr);
-
- if (end_ptr<start_ptr)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
- temp_buf2[end_ptr-start_ptr]='\0';
- len = strlen(temp_buf2);
- strcpy(temp_buf1, temp_buf2);
- if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf2, start_ptr+1);
- ptr = temp_buf2;
-
- //trim tab
- /* We cannot trim space(' ') for SSID and key string. */
- while(*ptr != 0x00)
- {
- //if( (*ptr == ' ') || (*ptr == '\t') )
- if( (*ptr == '\t') )
- ptr++;
- else
- break;
- }
-
- len = strlen(ptr);
- memset(dest, 0x00, destsize);
- strncpy(dest, ptr, len >= destsize ? destsize: len);
-
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get multiple key parameter.
-
- Arguments:
- key Pointer to key string
- dest Pointer to destination
- destsize The datasize of the destination
- buffer Pointer to the buffer to start find the key
-
- Return Value:
- TRUE Success
- FALSE Fail
-
- Note:
- This routine get the value with the matched key (case case-sensitive)
- ========================================================================
-*/
-INT RTMPGetKeyParameterWithOffset(
- IN PCHAR key,
- OUT PCHAR dest,
- OUT USHORT *end_offset,
- IN INT destsize,
- IN PCHAR buffer,
- IN BOOLEAN bTrimSpace)
-{
- UCHAR *temp_buf1 = NULL;
- UCHAR *temp_buf2 = NULL;
- CHAR *start_ptr;
- CHAR *end_ptr;
- CHAR *ptr;
- CHAR *offset = 0;
- INT len;
-
- if (*end_offset >= MAX_INI_BUFFER_SIZE)
- return (FALSE);
-
- os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
- if(temp_buf1 == NULL)
- return (FALSE);
-
- os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
- if(temp_buf2 == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- return (FALSE);
- }
-
- //find section
- if(*end_offset == 0)
- {
- if ((offset = RTMPFindSection(buffer)) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
- }
- else
- offset = buffer + (*end_offset);
-
- strcpy(temp_buf1, "\n");
- strcat(temp_buf1, key);
- strcat(temp_buf1, "=");
-
- //search key
- if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- start_ptr+=strlen("\n");
- if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
- end_ptr=start_ptr+strlen(start_ptr);
-
- if (end_ptr<start_ptr)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- *end_offset = end_ptr - buffer;
-
- NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
- temp_buf2[end_ptr-start_ptr]='\0';
- len = strlen(temp_buf2);
- strcpy(temp_buf1, temp_buf2);
- if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf2, start_ptr+1);
- ptr = temp_buf2;
- //trim space or tab
- while(*ptr != 0x00)
- {
- if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
- ptr++;
- else
- break;
- }
-
- len = strlen(ptr);
- memset(dest, 0x00, destsize);
- strncpy(dest, ptr, len >= destsize ? destsize: len);
-
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return TRUE;
-}
-
-
-static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
-{
- PUCHAR keybuff;
- INT i = BSSIdx, idx = KeyIdx;
- ULONG KeyLen;
- UCHAR CipherAlg = CIPHER_WEP64;
-
- keybuff = buffer;
- KeyLen = strlen(keybuff);
-
- if (KeyType == 1)
- {//Ascii
- if( (KeyLen == 5) || (KeyLen == 13))
- {
- pAd->SharedKey[i][idx].KeyLen = KeyLen;
- NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
- if (KeyLen == 5)
- CipherAlg = CIPHER_WEP64;
- else
- CipherAlg = CIPHER_WEP128;
- pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-
- DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
- return 1;
- }
- else
- {//Invalid key length
- DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
- return 0;
- }
- }
- else
- {//Hex type
- if( (KeyLen == 10) || (KeyLen == 26))
- {
- pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
- AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
- if (KeyLen == 10)
- CipherAlg = CIPHER_WEP64;
- else
- CipherAlg = CIPHER_WEP128;
- pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-
- DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
- return 1;
- }
- else
- {//Invalid key length
- DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
- return 0;
- }
- }
-}
-static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
-{
- char tok_str[16];
- PUCHAR macptr;
- INT i = 0, idx;
- ULONG KeyType[MAX_MBSSID_NUM];
- ULONG KeyIdx;
-
- NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
-
- //DefaultKeyID
- if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- KeyIdx = simple_strtol(tmpbuf, 0, 10);
- if((KeyIdx >= 1 ) && (KeyIdx <= 4))
- pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
- else
- pAd->StaCfg.DefaultKeyId = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- for (idx = 0; idx < 4; idx++)
- {
- sprintf(tok_str, "Key%dType", idx + 1);
- //Key1Type
- if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- KeyType[i] = simple_strtol(macptr, 0, 10);
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- sprintf(tok_str, "Key%dStr", idx + 1);
- if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
- {
- rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- }
-}
-
-
-#ifdef CONFIG_STA_SUPPORT
-static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
-{
- PUCHAR macptr;
- INT i=0;
- BOOLEAN bWmmEnable = FALSE;
-
- //WmmCapable
- if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- {
- pAd->CommonCfg.bWmmCapable = TRUE;
- bWmmEnable = TRUE;
- }
- else //Disable
- {
- pAd->CommonCfg.bWmmCapable = FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
- }
-
-#ifdef QOS_DLS_SUPPORT
- //DLSCapable
- if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- {
- pAd->CommonCfg.bDLSCapable = TRUE;
- }
- else //Disable
- {
- pAd->CommonCfg.bDLSCapable = FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
- }
-#endif // QOS_DLS_SUPPORT //
-
- //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
- if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
-
- DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
- }
- }
-
- if (bWmmEnable)
- {
- //APSDCapable
- if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bAPSDCapable = TRUE;
- else
- pAd->CommonCfg.bAPSDCapable = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
- }
-
- //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
- if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
- {
- BOOLEAN apsd_ac[4];
-
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
-
- DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
- }
-
- pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
- pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
- pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
- pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
- }
- }
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-NDIS_STATUS RTMPReadParametersHook(
- IN PRTMP_ADAPTER pAd)
-{
- PUCHAR src = NULL;
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- CHAR *buffer;
- CHAR *tmpbuf;
- ULONG RtsThresh;
- ULONG FragThresh;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR keyMaterial[40];
-#endif // CONFIG_STA_SUPPORT //
-
-
- PUCHAR macptr;
- INT i = 0;
-
- buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(buffer == NULL)
- return NDIS_STATUS_FAILURE;
-
- tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(tmpbuf == NULL)
- {
- kfree(buffer);
- return NDIS_STATUS_FAILURE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- src = STA_PROFILE_PATH;
-#endif // CONFIG_STA_SUPPORT //
-#ifdef MULTIPLE_CARD_SUPPORT
- src = pAd->MC_FileName;
-#endif // MULTIPLE_CARD_SUPPORT //
-
- // Save uid and gid used for filesystem access.
- // Set user and group to 0 (root)
- orgfsuid = current_fsuid();
- orgfsgid = current_fsgid();
- /* Hm, can't really do this nicely anymore, so rely on these files
- * being set to the proper permission to read them... */
- /* current->cred->fsuid = current->cred->fsgid = 0; */
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- if (src && *src)
- {
- srcf = filp_open(src, O_RDONLY, 0);
- if (IS_ERR(srcf))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
- }
- else
- {
- // The object must have a read method
- if (srcf->f_op && srcf->f_op->read)
- {
- memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
- retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
- if (retval < 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
- }
- else
- {
- // set file parameter to portcfg
- //CountryRegion
- if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
- {
- pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
- }
- //CountryRegionABand
- if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
- {
- pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
- }
- //CountryCode
- if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
- {
- NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(pAd->StaCfg.StaOriCountryCode, tmpbuf , 2);
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
- if (strlen(pAd->CommonCfg.CountryCode) != 0)
- {
- pAd->CommonCfg.bCountryFlag = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
- }
- //ChannelGeography
- if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
- {
- UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
- if (Geography <= BOTH)
- {
- pAd->CommonCfg.Geography = Geography;
- pAd->CommonCfg.CountryCode[2] =
- (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
- }
- }
- else
- {
- pAd->CommonCfg.Geography = BOTH;
- pAd->CommonCfg.CountryCode[2] = ' ';
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //SSID
- if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
- {
- if (strlen(tmpbuf) <= 32)
- {
- pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
- NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
- NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
- pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
- NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //NetworkType
- if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
- {
- pAd->bConfigChanged = TRUE;
- if (strcmp(tmpbuf, "Adhoc") == 0)
- pAd->StaCfg.BssType = BSS_ADHOC;
- else //Default Infrastructure mode
- pAd->StaCfg.BssType = BSS_INFRA;
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAd->StaCfg.WpaState = SS_NOTUSE;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- //Channel
- if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
- }
- //WirelessMode
- if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
- {
- int value = 0, maxPhyMode = PHY_11G;
-
-#ifdef DOT11_N_SUPPORT
- maxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
- value = simple_strtol(tmpbuf, 0, 10);
-
- if (value <= maxPhyMode)
- {
- pAd->CommonCfg.PhyMode = value;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
- }
- //BasicRate
- if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
- }
- //BeaconPeriod
- if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
- }
- //TxPower
- if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
- }
- //BGProtection
- if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case 1: //Always On
- pAd->CommonCfg.UseBGProtection = 1;
- break;
- case 2: //Always OFF
- pAd->CommonCfg.UseBGProtection = 2;
- break;
- case 0: //AUTO
- default:
- pAd->CommonCfg.UseBGProtection = 0;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
- }
- //OLBCDetection
- if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case 1: //disable OLBC Detection
- pAd->CommonCfg.DisableOLBCDetect = 1;
- break;
- case 0: //enable OLBC Detection
- pAd->CommonCfg.DisableOLBCDetect = 0;
- break;
- default:
- pAd->CommonCfg.DisableOLBCDetect= 0;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
- }
- //TxPreamble
- if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case Rt802_11PreambleShort:
- pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
- break;
- case Rt802_11PreambleLong:
- default:
- pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
- }
- //RTSThreshold
- if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
- {
- RtsThresh = simple_strtol(tmpbuf, 0, 10);
- if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
- pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
- else
- pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
- }
- //FragThreshold
- if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
- {
- FragThresh = simple_strtol(tmpbuf, 0, 10);
- pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
-
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- { //illegal FragThresh so we set it to default
- pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
- }
- else if (FragThresh % 2 == 1)
- {
- // The length of each fragment shall always be an even number of octets, except for the last fragment
- // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
- pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
- }
- else
- {
- pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
- //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
- DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
- }
- //TxBurst
- if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
- {
-//#ifdef WIFI_TEST
-// pAd->CommonCfg.bEnableTxBurst = FALSE;
-//#else
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bEnableTxBurst = TRUE;
- else //Disable
- pAd->CommonCfg.bEnableTxBurst = FALSE;
-//#endif
- DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
- }
-
-#ifdef AGGREGATION_SUPPORT
- //PktAggregate
- if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bAggregationCapable = TRUE;
- else //Disable
- pAd->CommonCfg.bAggregationCapable = FALSE;
-#ifdef PIGGYBACK_SUPPORT
- pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
-#endif // PIGGYBACK_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
- }
-#else
- pAd->CommonCfg.bAggregationCapable = FALSE;
- pAd->CommonCfg.bPiggyBackCapable = FALSE;
-#endif // AGGREGATION_SUPPORT //
-
- // WmmCapable
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
-#endif // CONFIG_STA_SUPPORT //
-
- //ShortSlot
- if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bUseShortSlotTime = TRUE;
- else //Disable
- pAd->CommonCfg.bUseShortSlotTime = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
- }
- //IEEE80211H
- if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- if(simple_strtol(macptr, 0, 10) != 0) //Enable
- pAd->CommonCfg.bIEEE80211H = TRUE;
- else //Disable
- pAd->CommonCfg.bIEEE80211H = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
- }
- }
- //CSPeriod
- if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0)
- pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
- else
- pAd->CommonCfg.RadarDetect.CSPeriod = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
- }
-
- //RDRegion
- if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
- {
- if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
- }
- else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
- else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
- }
- else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
- }
- else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
- else
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
- }
- else
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
-
- //WirelessEvent
- if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
- {
-#if WIRELESS_EXT >= 15
- if(simple_strtol(tmpbuf, 0, 10) != 0)
- pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
- else
- pAd->CommonCfg.bWirelessEvent = 0; // disable
-#else
- pAd->CommonCfg.bWirelessEvent = 0; // disable
-#endif
- DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
- }
- if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0)
- pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
- else
- pAd->CommonCfg.bWiFiTest = 0; // disable
-
- DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
- }
- //AuthMode
- if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
- else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
- else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- //EncrypType
- if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
- pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
- pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
- pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- else
- pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-
- // Update all wepstatus related
- pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
- pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
- pAd->StaCfg.bMixCipher = FALSE;
-
- //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
- {
- int err=0;
-
- tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
-
- if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- )
- {
- err = 1;
- }
- else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
- {
- PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
- NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
-
- }
- else if (strlen(tmpbuf) == 64)
- {
- AtoH(tmpbuf, keyMaterial, 32);
- NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
- }
- else
- {
- err = 1;
- DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
- }
-
- if (err == 0)
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- // Start STA supplicant state machine
- pAd->StaCfg.WpaState = SS_START;
- }
- else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- /*
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
- */
- pAd->StaCfg.WpaState = SS_NOTUSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- //DefaultKeyID, KeyType, KeyStr
- rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
-
-
- //HSCounter
- /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case 1: //Enable
- pAd->CommonCfg.bEnableHSCounter = TRUE;
- break;
- case 0: //Disable
- default:
- pAd->CommonCfg.bEnableHSCounter = FALSE;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
- }*/
-
-#ifdef DOT11_N_SUPPORT
- HTParametersHook(pAd, tmpbuf, buffer);
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef CARRIER_DETECTION_SUPPORT
- //CarrierDetect
- if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, buffer))
- {
- if ((strncmp(tmpbuf, "0", 1) == 0))
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else if ((strncmp(tmpbuf, "1", 1) == 0))
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CarrierDetect.Enable=%d\n", pAd->CommonCfg.CarrierDetect.Enable));
- }
- else
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //PSMode
- if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
- {
- if (pAd->StaCfg.BssType == BSS_INFRA)
- {
- if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- // MlmeSetPsm(pAd, PWR_SAVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAd->StaCfg.DefaultListenCount = 5;
- }
- else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
- || (strcmp(tmpbuf, "FAST_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- // MlmeSetPsmBit(pAd, PWR_SAVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
- pAd->StaCfg.DefaultListenCount = 3;
- }
- else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
- || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- // MlmeSetPsmBit(pAd, PWR_SAVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAd->StaCfg.DefaultListenCount = 3;
- }
- else
- { //Default Ndis802_11PowerModeCAM
- // clear PSM bit immediately
- MlmeSetPsmBit(pAd, PWR_ACTIVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
- }
- }
- // FastRoaming
- if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
- {
- if (simple_strtol(tmpbuf, 0, 10) == 0)
- pAd->StaCfg.bFastRoaming = FALSE;
- else
- pAd->StaCfg.bFastRoaming = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
- }
- // RoamThreshold
- if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
- {
- long lInfo = simple_strtol(tmpbuf, 0, 10);
-
- if (lInfo > 90 || lInfo < 60)
- pAd->StaCfg.dBmToRoam = -70;
- else
- pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
- }
-
- if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) == 0)
- pAd->StaCfg.bTGnWifiTest = FALSE;
- else
- pAd->StaCfg.bTGnWifiTest = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
-
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
- }
-
- retval=filp_close(srcf,NULL);
-
- if (retval)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
- }
- }
- }
-
- set_fs(orgfs);
-#if 0
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
-#endif
-
- kfree(buffer);
- kfree(tmpbuf);
-
- return (NDIS_STATUS_SUCCESS);
-}
-
-#ifdef DOT11_N_SUPPORT
-static void HTParametersHook(
- IN PRTMP_ADAPTER pAd,
- IN CHAR *pValueStr,
- IN CHAR *pInput)
-{
-
- INT Value;
-
- if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bHTProtect = FALSE;
- }
- else
- {
- pAd->CommonCfg.bHTProtect = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bMIMOPSEnable = FALSE;
- }
- else
- {
- pAd->CommonCfg.bMIMOPSEnable = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
-
- if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value > MMPS_ENABLE)
- {
- pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
- }
- else
- {
- //TODO: add mimo power saving mechanism
- pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
- //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
- }
-
- if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bBADecline = FALSE;
- }
- else
- {
- pAd->CommonCfg.bBADecline = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
-
- if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bDisableReordering = FALSE;
- }
- else
- {
- pAd->CommonCfg.bDisableReordering = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- }
- else
- {
- pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
- }
- pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- // Tx_+HTC frame
- if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->HTCEnable = FALSE;
- }
- else
- {
- pAd->HTCEnable = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- // Enable HT Link Adaptation Control
- if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->bLinkAdapt = FALSE;
- }
- else
- {
- pAd->HTCEnable = TRUE;
- pAd->bLinkAdapt = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
- }
-
- // Reverse Direction Mechanism
- if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bRdg = FALSE;
- }
- else
- {
- pAd->HTCEnable = TRUE;
- pAd->CommonCfg.bRdg = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
- }
-
-
-
-
- // Tx A-MSUD ?
- if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
- }
- else
- {
- pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- // MPDU Density
- if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value <=7 && Value >= 0)
- {
- pAd->CommonCfg.BACapability.field.MpduDensity = Value;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
- }
- else
- {
- pAd->CommonCfg.BACapability.field.MpduDensity = 4;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
- }
- }
-
- // Max Rx BA Window Size
- if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value >=1 && Value <= 64)
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
- }
- else
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
- }
-
- }
-
- // Guard Interval
- if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == GI_400)
- {
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
- }
-
- // HT Operation Mode : Mixed Mode , Green Field
- if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == HTMODE_GF)
- {
-
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
- }
-
- // Fixed Tx mode : CCK, OFDM
- if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
- {
- UCHAR fix_tx_mode;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- fix_tx_mode = FIXED_TXMODE_HT;
-
- if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_OFDM;
- }
- else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_CCK;
- }
- else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_HT;
- }
- else
- {
- Value = simple_strtol(pValueStr, 0, 10);
- // 1 : CCK
- // 2 : OFDM
- // otherwise : HT
- if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
- fix_tx_mode = Value;
- else
- fix_tx_mode = FIXED_TXMODE_HT;
- }
-
- pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
- DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
-
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- // Channel Width
- if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == BW_40)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- }
-
-#ifdef MCAST_RATE_SPECIFIC
- pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
-#endif // MCAST_RATE_SPECIFIC //
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
- }
-
- if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == 0)
- {
-
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
- }
-
- // MSC
- if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
-// if ((Value >= 0 && Value <= 15) || (Value == 32))
- if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
- pAd->StaCfg.bAutoTxRateSwitch = FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
- }
- else
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // STBC
- if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == STBC_USE)
- {
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
- }
-
- // 40_Mhz_Intolerant
- if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
- }
- else
- {
- pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
- }
- //HT_TxStream
- if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
- {
- switch (simple_strtol(pValueStr, 0, 10))
- {
- case 1:
- pAd->CommonCfg.TxStream = 1;
- break;
- case 2:
- pAd->CommonCfg.TxStream = 2;
- break;
- case 3: // 3*3
- default:
- pAd->CommonCfg.TxStream = 3;
-
- if (pAd->MACVersion < RALINK_2883_VERSION)
- pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
- }
- //HT_RxStream
- if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
- {
- switch (simple_strtol(pValueStr, 0, 10))
- {
- case 1:
- pAd->CommonCfg.RxStream = 1;
- break;
- case 2:
- pAd->CommonCfg.RxStream = 2;
- break;
- case 3:
- default:
- pAd->CommonCfg.RxStream = 3;
-
- if (pAd->MACVersion < RALINK_2883_VERSION)
- pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
- }
-
-}
-#endif // DOT11_N_SUPPORT //
-
+#include "../rt2860/rt_profile.c"
diff --git a/drivers/staging/rt2870/rtmp.h b/drivers/staging/rt2870/rtmp.h
index c2a4784ec338..e5ef89f8bef1 100644
--- a/drivers/staging/rt2870/rtmp.h
+++ b/drivers/staging/rt2870/rtmp.h
@@ -1,7586 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp.h
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 2002-08-01 created
- James Tan 2002-09-06 modified (Revise NTCRegTable)
- John Chang 2004-09-06 modified for RT2600
-*/
-#ifndef __RTMP_H__
-#define __RTMP_H__
-
-#include "link_list.h"
-#include "spectrum_def.h"
-
-
-#ifdef CONFIG_STA_SUPPORT
-#include "aironet.h"
-#endif // CONFIG_STA_SUPPORT //
-
-//#define DBG 1
-
-//#define DBG_DIAGNOSE 1
-
-#if defined(CONFIG_AP_SUPPORT) && defined(CONFIG_STA_SUPPORT)
-#define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd) if(_pAd->OpMode == OPMODE_AP)
-#define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd) if(_pAd->OpMode == OPMODE_STA)
-#else
-#define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd)
-#define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd)
-#endif
-
-#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
-#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
-#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
-
-#ifdef RT2870
-////////////////////////////////////////////////////////////////////////////
-// The TX_BUFFER structure forms the transmitted USB packet to the device
-////////////////////////////////////////////////////////////////////////////
-typedef struct __TX_BUFFER{
- union {
- UCHAR WirelessPacket[TX_BUFFER_NORMSIZE];
- HEADER_802_11 NullFrame;
- PSPOLL_FRAME PsPollPacket;
- RTS_FRAME RTSFrame;
- }field;
- UCHAR Aggregation[4]; //Buffer for save Aggregation size.
-} TX_BUFFER, *PTX_BUFFER;
-
-typedef struct __HTTX_BUFFER{
- union {
- UCHAR WirelessPacket[MAX_TXBULK_SIZE];
- HEADER_802_11 NullFrame;
- PSPOLL_FRAME PsPollPacket;
- RTS_FRAME RTSFrame;
- }field;
- UCHAR Aggregation[4]; //Buffer for save Aggregation size.
-} HTTX_BUFFER, *PHTTX_BUFFER;
-
-
-// used to track driver-generated write irps
-typedef struct _TX_CONTEXT
-{
- PVOID pAd; //Initialized in MiniportInitialize
- PURB pUrb; //Initialized in MiniportInitialize
- PIRP pIrp; //used to cancel pending bulk out.
- //Initialized in MiniportInitialize
- PTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
- ULONG BulkOutSize;
- UCHAR BulkOutPipeId;
- UCHAR SelfIdx;
- BOOLEAN InUse;
- BOOLEAN bWaitingBulkOut; // at least one packet is in this TxContext, ready for making IRP anytime.
- BOOLEAN bFullForBulkOut; // all tx buffer are full , so waiting for tx bulkout.
- BOOLEAN IRPPending;
- BOOLEAN LastOne;
- BOOLEAN bAggregatible;
- UCHAR Header_802_3[LENGTH_802_3];
- UCHAR Rsv[2];
- ULONG DataOffset;
- UINT TxRate;
- dma_addr_t data_dma; // urb dma on linux
-
-} TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT;
-
-
-// used to track driver-generated write irps
-typedef struct _HT_TX_CONTEXT
-{
- PVOID pAd; //Initialized in MiniportInitialize
- PURB pUrb; //Initialized in MiniportInitialize
- PIRP pIrp; //used to cancel pending bulk out.
- //Initialized in MiniportInitialize
- PHTTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
- ULONG BulkOutSize; // Indicate the total bulk-out size in bytes in one bulk-transmission
- UCHAR BulkOutPipeId;
- BOOLEAN IRPPending;
- BOOLEAN LastOne;
- BOOLEAN bCurWriting;
- BOOLEAN bRingEmpty;
- BOOLEAN bCopySavePad;
- UCHAR SavedPad[8];
- UCHAR Header_802_3[LENGTH_802_3];
- ULONG CurWritePosition; // Indicate the buffer offset which packet will be inserted start from.
- ULONG CurWriteRealPos; // Indicate the buffer offset which packet now are writing to.
- ULONG NextBulkOutPosition; // Indicate the buffer start offset of a bulk-transmission
- ULONG ENextBulkOutPosition; // Indicate the buffer end offset of a bulk-transmission
- UINT TxRate;
- dma_addr_t data_dma; // urb dma on linux
-} HT_TX_CONTEXT, *PHT_TX_CONTEXT, **PPHT_TX_CONTEXT;
-
-
-//
-// Structure to keep track of receive packets and buffers to indicate
-// receive data to the protocol.
-//
-typedef struct _RX_CONTEXT
-{
- PUCHAR TransferBuffer;
- PVOID pAd;
- PIRP pIrp;//used to cancel pending bulk in.
- PURB pUrb;
- //These 2 Boolean shouldn't both be 1 at the same time.
- ULONG BulkInOffset; // number of packets waiting for reordering .
-// BOOLEAN ReorderInUse; // At least one packet in this buffer are in reordering buffer and wait for receive indication
- BOOLEAN bRxHandling; // Notify this packet is being process now.
- BOOLEAN InUse; // USB Hardware Occupied. Wait for USB HW to put packet.
- BOOLEAN Readable; // Receive Complete back. OK for driver to indicate receiving packet.
- BOOLEAN IRPPending; // TODO: To be removed
- atomic_t IrpLock;
- NDIS_SPIN_LOCK RxContextLock;
- dma_addr_t data_dma; // urb dma on linux
-} RX_CONTEXT, *PRX_CONTEXT;
-#endif // RT2870 //
-
-
-//
-// NDIS Version definitions
-//
-#ifdef NDIS50_MINIPORT
-#define RTMP_NDIS_MAJOR_VERSION 5
-#define RTMP_NDIS_MINOR_VERSION 0
-#endif
-
-#ifdef NDIS51_MINIPORT
-#define RTMP_NDIS_MAJOR_VERSION 5
-#define RTMP_NDIS_MINOR_VERSION 1
-#endif
-
-extern char NIC_VENDOR_DESC[];
-extern int NIC_VENDOR_DESC_LEN;
-
-extern unsigned char SNAP_AIRONET[];
-extern unsigned char CipherSuiteCiscoCCKM[];
-extern unsigned char CipherSuiteCiscoCCKMLen;
-extern unsigned char CipherSuiteCiscoCCKM24[];
-extern unsigned char CipherSuiteCiscoCCKM24Len;
-extern unsigned char CipherSuiteCCXTkip[];
-extern unsigned char CipherSuiteCCXTkipLen;
-extern unsigned char CISCO_OUI[];
-extern UCHAR BaSizeArray[4];
-
-extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];
-extern UCHAR MULTICAST_ADDR[MAC_ADDR_LEN];
-extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];
-extern ULONG BIT32[32];
-extern UCHAR BIT8[8];
-extern char* CipherName[];
-extern char* MCSToMbps[];
-extern UCHAR RxwiMCSToOfdmRate[12];
-extern UCHAR SNAP_802_1H[6];
-extern UCHAR SNAP_BRIDGE_TUNNEL[6];
-extern UCHAR SNAP_AIRONET[8];
-extern UCHAR CKIP_LLC_SNAP[8];
-extern UCHAR EAPOL_LLC_SNAP[8];
-extern UCHAR EAPOL[2];
-extern UCHAR IPX[2];
-extern UCHAR APPLE_TALK[2];
-extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14
-extern UCHAR OfdmRateToRxwiMCS[];
-extern UCHAR OfdmSignalToRateId[16] ;
-extern UCHAR default_cwmin[4];
-extern UCHAR default_cwmax[4];
-extern UCHAR default_sta_aifsn[4];
-extern UCHAR MapUserPriorityToAccessCategory[8];
-
-extern USHORT RateUpPER[];
-extern USHORT RateDownPER[];
-extern UCHAR Phy11BNextRateDownward[];
-extern UCHAR Phy11BNextRateUpward[];
-extern UCHAR Phy11BGNextRateDownward[];
-extern UCHAR Phy11BGNextRateUpward[];
-extern UCHAR Phy11ANextRateDownward[];
-extern UCHAR Phy11ANextRateUpward[];
-extern CHAR RssiSafeLevelForTxRate[];
-extern UCHAR RateIdToMbps[];
-extern USHORT RateIdTo500Kbps[];
-
-extern UCHAR CipherSuiteWpaNoneTkip[];
-extern UCHAR CipherSuiteWpaNoneTkipLen;
-
-extern UCHAR CipherSuiteWpaNoneAes[];
-extern UCHAR CipherSuiteWpaNoneAesLen;
-
-extern UCHAR SsidIe;
-extern UCHAR SupRateIe;
-extern UCHAR ExtRateIe;
-
-#ifdef DOT11_N_SUPPORT
-extern UCHAR HtCapIe;
-extern UCHAR AddHtInfoIe;
-extern UCHAR NewExtChanIe;
-#ifdef DOT11N_DRAFT3
-extern UCHAR ExtHtCapIe;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-extern UCHAR ErpIe;
-extern UCHAR DsIe;
-extern UCHAR TimIe;
-extern UCHAR WpaIe;
-extern UCHAR Wpa2Ie;
-extern UCHAR IbssIe;
-extern UCHAR Ccx2Ie;
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR Ccx2IeInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR PowerConstraintIE[];
-
-
-extern UCHAR RateSwitchTable[];
-extern UCHAR RateSwitchTable11B[];
-extern UCHAR RateSwitchTable11G[];
-extern UCHAR RateSwitchTable11BG[];
-
-#ifdef DOT11_N_SUPPORT
-extern UCHAR RateSwitchTable11BGN1S[];
-extern UCHAR RateSwitchTable11BGN2S[];
-extern UCHAR RateSwitchTable11BGN2SForABand[];
-extern UCHAR RateSwitchTable11N1S[];
-extern UCHAR RateSwitchTable11N2S[];
-extern UCHAR RateSwitchTable11N2SForABand[];
-
-#ifdef CONFIG_STA_SUPPORT
-extern UCHAR PRE_N_HT_OUI[];
-#endif // CONFIG_STA_SUPPORT //
-#endif // DOT11_N_SUPPORT //
-
-#define MAXSEQ (0xFFF)
-
-#ifdef RALINK_ATE
-typedef struct _ATE_INFO {
- UCHAR Mode;
- CHAR TxPower0;
- CHAR TxPower1;
- CHAR TxAntennaSel;
- CHAR RxAntennaSel;
- TXWI_STRUC TxWI; // TXWI
- USHORT QID;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR Addr3[MAC_ADDR_LEN];
- UCHAR Channel;
- UINT32 TxLength;
- UINT32 TxCount;
- UINT32 TxDoneCount; // Tx DMA Done
- UINT32 RFFreqOffset;
- BOOLEAN bRxFer;
- BOOLEAN bQATxStart; // Have compiled QA in and use it to ATE tx.
- BOOLEAN bQARxStart; // Have compiled QA in and use it to ATE rx.
- UINT32 RxTotalCnt;
- UINT32 RxCntPerSec;
-
- CHAR LastSNR0; // last received SNR
- CHAR LastSNR1; // last received SNR for 2nd antenna
- CHAR LastRssi0; // last received RSSI
- CHAR LastRssi1; // last received RSSI for 2nd antenna
- CHAR LastRssi2; // last received RSSI for 3rd antenna
- CHAR AvgRssi0; // last 8 frames' average RSSI
- CHAR AvgRssi1; // last 8 frames' average RSSI
- CHAR AvgRssi2; // last 8 frames' average RSSI
- SHORT AvgRssi0X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi1X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi2X8; // sum of last 8 frames' RSSI
-
- UINT32 NumOfAvgRssiSample;
-
-#ifdef RALINK_28xx_QA
- // Tx frame
-#ifdef RT2870
- /* not used in RT2860 */
- TXINFO_STRUC TxInfo; // TxInfo
-#endif // RT2870 //
- USHORT HLen; // Header Length
- USHORT PLen; // Pattern Length
- UCHAR Header[32]; // Header buffer
- UCHAR Pattern[32]; // Pattern buffer
- USHORT DLen; // Data Length
- USHORT seq;
- UINT32 CID;
- THREAD_PID AtePid;
- // counters
- UINT32 U2M;
- UINT32 OtherData;
- UINT32 Beacon;
- UINT32 OtherCount;
- UINT32 TxAc0;
- UINT32 TxAc1;
- UINT32 TxAc2;
- UINT32 TxAc3;
- UINT32 TxHCCA;
- UINT32 TxMgmt;
- UINT32 RSSI0;
- UINT32 RSSI1;
- UINT32 RSSI2;
- UINT32 SNR0;
- UINT32 SNR1;
- // control
- //UINT32 Repeat; // Tx Cpu count
- UCHAR TxStatus; // task Tx status // 0 --> task is idle, 1 --> task is running
-#endif // RALINK_28xx_QA //
-} ATE_INFO, *PATE_INFO;
-
-#ifdef RALINK_28xx_QA
-struct ate_racfghdr {
- UINT32 magic_no;
- USHORT command_type;
- USHORT command_id;
- USHORT length;
- USHORT sequence;
- USHORT status;
- UCHAR data[2046];
-} __attribute__((packed));
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
-struct reordering_mpdu
-{
- struct reordering_mpdu *next;
- PNDIS_PACKET pPacket; /* coverted to 802.3 frame */
- int Sequence; /* sequence number of MPDU */
- BOOLEAN bAMSDU;
-};
-
-struct reordering_list
-{
- struct reordering_mpdu *next;
- int qlen;
-};
-
-struct reordering_mpdu_pool
-{
- PVOID mem;
- NDIS_SPIN_LOCK lock;
- struct reordering_list freelist;
-};
-#endif // DOT11_N_SUPPORT //
-
-typedef struct _RSSI_SAMPLE {
- CHAR LastRssi0; // last received RSSI
- CHAR LastRssi1; // last received RSSI
- CHAR LastRssi2; // last received RSSI
- CHAR AvgRssi0;
- CHAR AvgRssi1;
- CHAR AvgRssi2;
- SHORT AvgRssi0X8;
- SHORT AvgRssi1X8;
- SHORT AvgRssi2X8;
-} RSSI_SAMPLE;
-
-//
-// Queue structure and macros
-//
-typedef struct _QUEUE_ENTRY {
- struct _QUEUE_ENTRY *Next;
-} QUEUE_ENTRY, *PQUEUE_ENTRY;
-
-// Queue structure
-typedef struct _QUEUE_HEADER {
- PQUEUE_ENTRY Head;
- PQUEUE_ENTRY Tail;
- ULONG Number;
-} QUEUE_HEADER, *PQUEUE_HEADER;
-
-#define InitializeQueueHeader(QueueHeader) \
-{ \
- (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
- (QueueHeader)->Number = 0; \
-}
-
-#define RemoveHeadQueue(QueueHeader) \
-(QueueHeader)->Head; \
-{ \
- PQUEUE_ENTRY pNext; \
- if ((QueueHeader)->Head != NULL) \
- { \
- pNext = (QueueHeader)->Head->Next; \
- (QueueHeader)->Head = pNext; \
- if (pNext == NULL) \
- (QueueHeader)->Tail = NULL; \
- (QueueHeader)->Number--; \
- } \
-}
-
-#define InsertHeadQueue(QueueHeader, QueueEntry) \
-{ \
- ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- if ((QueueHeader)->Tail == NULL) \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
-}
-
-#define InsertTailQueue(QueueHeader, QueueEntry) \
-{ \
- ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \
- if ((QueueHeader)->Tail) \
- (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
- else \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
-}
-
-//
-// Macros for flag and ref count operations
-//
-#define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
-#define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
-#define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
-#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
-#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
-
-#define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
-#define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
-#define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
-
-#define CLIENT_STATUS_SET_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags |= (_F))
-#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags &= ~(_F))
-#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F) (((_pEntry)->ClientStatusFlags & (_F)) != 0)
-
-#define RX_FILTER_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter |= (_F))
-#define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
-#define RX_FILTER_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
-
-#ifdef CONFIG_STA_SUPPORT
-#define STA_NO_SECURITY_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
-#define STA_WEP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
-#define STA_TKIP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-#define STA_AES_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
-
-#define STA_TGN_WIFI_ON(_p) (_p->StaCfg.bTGnWifiTest == TRUE)
-#endif // CONFIG_STA_SUPPORT //
-
-#define CKIP_KP_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-#define CKIP_CMIC_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-
-
-#define INC_RING_INDEX(_idx, _RingSize) \
-{ \
- (_idx) = (_idx+1) % (_RingSize); \
-}
-
-#define IS_RT3070(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
-
-#define RING_PACKET_INIT(_TxRing, _idx) \
-{ \
- _TxRing->Cell[_idx].pNdisPacket = NULL; \
- _TxRing->Cell[_idx].pNextNdisPacket = NULL; \
-}
-
-#define TXDT_INIT(_TxD) \
-{ \
- NdisZeroMemory(_TxD, TXD_SIZE); \
- _TxD->DMADONE = 1; \
-}
-
-//Set last data segment
-#define RING_SET_LASTDS(_TxD, _IsSD0) \
-{ \
- if (_IsSD0) {_TxD->LastSec0 = 1;} \
- else {_TxD->LastSec1 = 1;} \
-}
-
-// Increase TxTsc value for next transmission
-// TODO:
-// When i==6, means TSC has done one full cycle, do re-keying stuff follow specs
-// Should send a special event microsoft defined to request re-key
-#define INC_TX_TSC(_tsc) \
-{ \
- int i=0; \
- while (++_tsc[i] == 0x0) \
- { \
- i++; \
- if (i == 6) \
- break; \
- } \
-}
-
-#ifdef DOT11_N_SUPPORT
-// StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here.
-#define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
-{ \
- _pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth; \
- _pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs; \
- _pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF; \
- _pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20; \
- _pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40; \
- _pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC; \
- _pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC; \
- _pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset; \
- _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth; \
- _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode; \
- _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent; \
- NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(UCHAR) * 16);\
-}
-
-#define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \
-{ \
- _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (UCHAR)(_pHtCapability->HtCapInfo.AMsduSize); \
- _pAd->MacTab.Content[BSSID_WCID].MmpsMode= (UCHAR)(_pHtCapability->HtCapInfo.MimoPs); \
- _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (UCHAR)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
-}
-#endif // DOT11_N_SUPPORT //
-
-//
-// BBP & RF are using indirect access. Before write any value into it.
-// We have to make sure there is no outstanding command pending via checking busy bit.
-//
-#define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register
-//
-
-#ifdef RT2870
-#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V)
-#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
-#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
-
-#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
-#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
-#endif // RT2870 //
-
-#define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \
- switch (ch) \
- { \
- case 1: khz = 2412000; break; \
- case 2: khz = 2417000; break; \
- case 3: khz = 2422000; break; \
- case 4: khz = 2427000; break; \
- case 5: khz = 2432000; break; \
- case 6: khz = 2437000; break; \
- case 7: khz = 2442000; break; \
- case 8: khz = 2447000; break; \
- case 9: khz = 2452000; break; \
- case 10: khz = 2457000; break; \
- case 11: khz = 2462000; break; \
- case 12: khz = 2467000; break; \
- case 13: khz = 2472000; break; \
- case 14: khz = 2484000; break; \
- case 36: /* UNII */ khz = 5180000; break; \
- case 40: /* UNII */ khz = 5200000; break; \
- case 44: /* UNII */ khz = 5220000; break; \
- case 48: /* UNII */ khz = 5240000; break; \
- case 52: /* UNII */ khz = 5260000; break; \
- case 56: /* UNII */ khz = 5280000; break; \
- case 60: /* UNII */ khz = 5300000; break; \
- case 64: /* UNII */ khz = 5320000; break; \
- case 149: /* UNII */ khz = 5745000; break; \
- case 153: /* UNII */ khz = 5765000; break; \
- case 157: /* UNII */ khz = 5785000; break; \
- case 161: /* UNII */ khz = 5805000; break; \
- case 165: /* UNII */ khz = 5825000; break; \
- case 100: /* HiperLAN2 */ khz = 5500000; break; \
- case 104: /* HiperLAN2 */ khz = 5520000; break; \
- case 108: /* HiperLAN2 */ khz = 5540000; break; \
- case 112: /* HiperLAN2 */ khz = 5560000; break; \
- case 116: /* HiperLAN2 */ khz = 5580000; break; \
- case 120: /* HiperLAN2 */ khz = 5600000; break; \
- case 124: /* HiperLAN2 */ khz = 5620000; break; \
- case 128: /* HiperLAN2 */ khz = 5640000; break; \
- case 132: /* HiperLAN2 */ khz = 5660000; break; \
- case 136: /* HiperLAN2 */ khz = 5680000; break; \
- case 140: /* HiperLAN2 */ khz = 5700000; break; \
- case 34: /* Japan MMAC */ khz = 5170000; break; \
- case 38: /* Japan MMAC */ khz = 5190000; break; \
- case 42: /* Japan MMAC */ khz = 5210000; break; \
- case 46: /* Japan MMAC */ khz = 5230000; break; \
- case 184: /* Japan */ khz = 4920000; break; \
- case 188: /* Japan */ khz = 4940000; break; \
- case 192: /* Japan */ khz = 4960000; break; \
- case 196: /* Japan */ khz = 4980000; break; \
- case 208: /* Japan, means J08 */ khz = 5040000; break; \
- case 212: /* Japan, means J12 */ khz = 5060000; break; \
- case 216: /* Japan, means J16 */ khz = 5080000; break; \
- default: khz = 2412000; break; \
- } \
- }
-
-#define MAP_KHZ_TO_CHANNEL_ID(khz, ch) { \
- switch (khz) \
- { \
- case 2412000: ch = 1; break; \
- case 2417000: ch = 2; break; \
- case 2422000: ch = 3; break; \
- case 2427000: ch = 4; break; \
- case 2432000: ch = 5; break; \
- case 2437000: ch = 6; break; \
- case 2442000: ch = 7; break; \
- case 2447000: ch = 8; break; \
- case 2452000: ch = 9; break; \
- case 2457000: ch = 10; break; \
- case 2462000: ch = 11; break; \
- case 2467000: ch = 12; break; \
- case 2472000: ch = 13; break; \
- case 2484000: ch = 14; break; \
- case 5180000: ch = 36; /* UNII */ break; \
- case 5200000: ch = 40; /* UNII */ break; \
- case 5220000: ch = 44; /* UNII */ break; \
- case 5240000: ch = 48; /* UNII */ break; \
- case 5260000: ch = 52; /* UNII */ break; \
- case 5280000: ch = 56; /* UNII */ break; \
- case 5300000: ch = 60; /* UNII */ break; \
- case 5320000: ch = 64; /* UNII */ break; \
- case 5745000: ch = 149; /* UNII */ break; \
- case 5765000: ch = 153; /* UNII */ break; \
- case 5785000: ch = 157; /* UNII */ break; \
- case 5805000: ch = 161; /* UNII */ break; \
- case 5825000: ch = 165; /* UNII */ break; \
- case 5500000: ch = 100; /* HiperLAN2 */ break; \
- case 5520000: ch = 104; /* HiperLAN2 */ break; \
- case 5540000: ch = 108; /* HiperLAN2 */ break; \
- case 5560000: ch = 112; /* HiperLAN2 */ break; \
- case 5580000: ch = 116; /* HiperLAN2 */ break; \
- case 5600000: ch = 120; /* HiperLAN2 */ break; \
- case 5620000: ch = 124; /* HiperLAN2 */ break; \
- case 5640000: ch = 128; /* HiperLAN2 */ break; \
- case 5660000: ch = 132; /* HiperLAN2 */ break; \
- case 5680000: ch = 136; /* HiperLAN2 */ break; \
- case 5700000: ch = 140; /* HiperLAN2 */ break; \
- case 5170000: ch = 34; /* Japan MMAC */ break; \
- case 5190000: ch = 38; /* Japan MMAC */ break; \
- case 5210000: ch = 42; /* Japan MMAC */ break; \
- case 5230000: ch = 46; /* Japan MMAC */ break; \
- case 4920000: ch = 184; /* Japan */ break; \
- case 4940000: ch = 188; /* Japan */ break; \
- case 4960000: ch = 192; /* Japan */ break; \
- case 4980000: ch = 196; /* Japan */ break; \
- case 5040000: ch = 208; /* Japan, means J08 */ break; \
- case 5060000: ch = 212; /* Japan, means J12 */ break; \
- case 5080000: ch = 216; /* Japan, means J16 */ break; \
- default: ch = 1; break; \
- } \
- }
-
-//
-// Common fragment list structure - Identical to the scatter gather frag list structure
-//
-//#define RTMP_SCATTER_GATHER_ELEMENT SCATTER_GATHER_ELEMENT
-//#define PRTMP_SCATTER_GATHER_ELEMENT PSCATTER_GATHER_ELEMENT
-#define NIC_MAX_PHYS_BUF_COUNT 8
-
-typedef struct _RTMP_SCATTER_GATHER_ELEMENT {
- PVOID Address;
- ULONG Length;
- PULONG Reserved;
-} RTMP_SCATTER_GATHER_ELEMENT, *PRTMP_SCATTER_GATHER_ELEMENT;
-
-
-typedef struct _RTMP_SCATTER_GATHER_LIST {
- ULONG NumberOfElements;
- PULONG Reserved;
- RTMP_SCATTER_GATHER_ELEMENT Elements[NIC_MAX_PHYS_BUF_COUNT];
-} RTMP_SCATTER_GATHER_LIST, *PRTMP_SCATTER_GATHER_LIST;
-
-//
-// Some utility macros
-//
-#ifndef min
-#define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
-#endif
-
-#ifndef max
-#define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
-#endif
-
-#define GET_LNA_GAIN(_pAd) ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
-
-#define INC_COUNTER64(Val) (Val.QuadPart++)
-
-#define INFRA_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
-#define ADHOC_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
-#define MONITOR_ON(_p) (((_p)->StaCfg.BssType) == BSS_MONITOR)
-#define IDLE_ON(_p) (!INFRA_ON(_p) && !ADHOC_ON(_p))
-
-// Check LEAP & CCKM flags
-#define LEAP_ON(_p) (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
-#define LEAP_CCKM_ON(_p) ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
-
-// if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \
-{ \
- if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) \
- { \
- _pExtraLlcSnapEncap = SNAP_802_1H; \
- if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \
- NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) \
- { \
- _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
- } \
- } \
- else \
- { \
- _pExtraLlcSnapEncap = NULL; \
- } \
-}
-
-// New Define for new Tx Path.
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \
-{ \
- if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) \
- { \
- _pExtraLlcSnapEncap = SNAP_802_1H; \
- if (NdisEqualMemory(IPX, _pBufVA, 2) || \
- NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) \
- { \
- _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
- } \
- } \
- else \
- { \
- _pExtraLlcSnapEncap = NULL; \
- } \
-}
-
-
-#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \
-{ \
- NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN); \
- NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN); \
- NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
-}
-
-// if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way.
-// else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field
-// else remove the LLC/SNAP field from the result Ethernet frame
-// Patch for WHQL only, which did not turn on Netbios but use IPX within its payload
-// Note:
-// _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO
-// _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed
-#define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \
-{ \
- char LLC_Len[2]; \
- \
- _pRemovedLLCSNAP = NULL; \
- if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \
- NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) \
- { \
- PUCHAR pProto = _pData + 6; \
- \
- if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
- NdisEqualMemory(SNAP_802_1H, _pData, 6)) \
- { \
- LLC_Len[0] = (UCHAR)(_DataSize / 256); \
- LLC_Len[1] = (UCHAR)(_DataSize % 256); \
- MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
- } \
- else \
- { \
- MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \
- _pRemovedLLCSNAP = _pData; \
- _DataSize -= LENGTH_802_1_H; \
- _pData += LENGTH_802_1_H; \
- } \
- } \
- else \
- { \
- LLC_Len[0] = (UCHAR)(_DataSize / 256); \
- LLC_Len[1] = (UCHAR)(_DataSize % 256); \
- MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
- } \
-}
-
-#define SWITCH_AB( _pAA, _pBB) \
-{ \
- PVOID pCC; \
- pCC = _pBB; \
- _pBB = _pAA; \
- _pAA = pCC; \
-}
-
-// Enqueue this frame to MLME engine
-// We need to enqueue the whole frame because MLME need to pass data type
-// information from 802.11 header
-#ifdef RT2870
-#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
-{ \
- UINT32 High32TSF=0, Low32TSF=0; \
- MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
-}
-#endif // RT2870 //
-
-#define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \
- NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen)
-
-#define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN)
-#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
-
-//
-// Check if it is Japan W53(ch52,56,60,64) channel.
-//
-#define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
-
-#ifdef CONFIG_STA_SUPPORT
-#define STA_PORT_SECURED(_pAd) \
-{ \
- _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
- NdisAcquireSpinLock(&_pAd->MacTabLock); \
- _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
- NdisReleaseSpinLock(&_pAd->MacTabLock); \
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-//
-// Register set pair for initialzation register set definition
-//
-typedef struct _RTMP_REG_PAIR
-{
- ULONG Register;
- ULONG Value;
-} RTMP_REG_PAIR, *PRTMP_REG_PAIR;
-
-typedef struct _REG_PAIR
-{
- UCHAR Register;
- UCHAR Value;
-} REG_PAIR, *PREG_PAIR;
-
-//
-// Register set pair for initialzation register set definition
-//
-typedef struct _RTMP_RF_REGS
-{
- UCHAR Channel;
- ULONG R1;
- ULONG R2;
- ULONG R3;
- ULONG R4;
-} RTMP_RF_REGS, *PRTMP_RF_REGS;
-
-typedef struct _FREQUENCY_ITEM {
- UCHAR Channel;
- UCHAR N;
- UCHAR R;
- UCHAR K;
-} FREQUENCY_ITEM, *PFREQUENCY_ITEM;
-
-//
-// Data buffer for DMA operation, the buffer must be contiguous physical memory
-// Both DMA to / from CPU use the same structure.
-//
-typedef struct _RTMP_DMABUF
-{
- ULONG AllocSize;
- PVOID AllocVa; // TxBuf virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address
-} RTMP_DMABUF, *PRTMP_DMABUF;
-
-
-typedef union _HEADER_802_11_SEQ{
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT Sequence:12;
- USHORT Frag:4;
- } field;
-#else
- struct {
- USHORT Frag:4;
- USHORT Sequence:12;
- } field;
-#endif
- USHORT value;
-} HEADER_802_11_SEQ, *PHEADER_802_11_SEQ;
-
-//
-// Data buffer for DMA operation, the buffer must be contiguous physical memory
-// Both DMA to / from CPU use the same structure.
-//
-typedef struct _RTMP_REORDERBUF
-{
- BOOLEAN IsFull;
- PVOID AllocVa; // TxBuf virtual address
- UCHAR Header802_3[14];
- HEADER_802_11_SEQ Sequence; //support compressed bitmap BA, so no consider fragment in BA
- UCHAR DataOffset;
- USHORT Datasize;
- ULONG AllocSize;
-#ifdef RT2870
- PUCHAR AllocPa;
-#endif // RT2870 //
-} RTMP_REORDERBUF, *PRTMP_REORDERBUF;
-
-//
-// Control block (Descriptor) for all ring descriptor DMA operation, buffer must be
-// contiguous physical memory. NDIS_PACKET stored the binding Rx packet descriptor
-// which won't be released, driver has to wait until upper layer return the packet
-// before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair
-// to describe the packet buffer. For Tx, NDIS_PACKET stored the tx packet descriptor
-// which driver should ACK upper layer when the tx is physically done or failed.
-//
-typedef struct _RTMP_DMACB
-{
- ULONG AllocSize; // Control block size
- PVOID AllocVa; // Control block virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
- PNDIS_PACKET pNdisPacket;
- PNDIS_PACKET pNextNdisPacket;
-
- RTMP_DMABUF DmaBuf; // Associated DMA buffer structure
-} RTMP_DMACB, *PRTMP_DMACB;
-
-typedef struct _RTMP_TX_BUF
-{
- PQUEUE_ENTRY Next;
- UCHAR Index;
- ULONG AllocSize; // Control block size
- PVOID AllocVa; // Control block virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
-} RTMP_TXBUF, *PRTMP_TXBUF;
-
-typedef struct _RTMP_RX_BUF
-{
- BOOLEAN InUse;
- ULONG ByBaRecIndex;
- RTMP_REORDERBUF MAP_RXBuf[MAX_RX_REORDERBUF];
-} RTMP_RXBUF, *PRTMP_RXBUF;
-typedef struct _RTMP_TX_RING
-{
- RTMP_DMACB Cell[TX_RING_SIZE];
- UINT32 TxCpuIdx;
- UINT32 TxDmaIdx;
- UINT32 TxSwFreeIdx; // software next free tx index
-} RTMP_TX_RING, *PRTMP_TX_RING;
-
-typedef struct _RTMP_RX_RING
-{
- RTMP_DMACB Cell[RX_RING_SIZE];
- UINT32 RxCpuIdx;
- UINT32 RxDmaIdx;
- INT32 RxSwReadIdx; // software next read index
-} RTMP_RX_RING, *PRTMP_RX_RING;
-
-typedef struct _RTMP_MGMT_RING
-{
- RTMP_DMACB Cell[MGMT_RING_SIZE];
- UINT32 TxCpuIdx;
- UINT32 TxDmaIdx;
- UINT32 TxSwFreeIdx; // software next free tx index
-} RTMP_MGMT_RING, *PRTMP_MGMT_RING;
-
-//
-// Statistic counter structure
-//
-typedef struct _COUNTER_802_3
-{
- // General Stats
- ULONG GoodTransmits;
- ULONG GoodReceives;
- ULONG TxErrors;
- ULONG RxErrors;
- ULONG RxNoBuffer;
-
- // Ethernet Stats
- ULONG RcvAlignmentErrors;
- ULONG OneCollision;
- ULONG MoreCollisions;
-
-} COUNTER_802_3, *PCOUNTER_802_3;
-
-typedef struct _COUNTER_802_11 {
- ULONG Length;
- LARGE_INTEGER LastTransmittedFragmentCount;
- LARGE_INTEGER TransmittedFragmentCount;
- LARGE_INTEGER MulticastTransmittedFrameCount;
- LARGE_INTEGER FailedCount;
- LARGE_INTEGER RetryCount;
- LARGE_INTEGER MultipleRetryCount;
- LARGE_INTEGER RTSSuccessCount;
- LARGE_INTEGER RTSFailureCount;
- LARGE_INTEGER ACKFailureCount;
- LARGE_INTEGER FrameDuplicateCount;
- LARGE_INTEGER ReceivedFragmentCount;
- LARGE_INTEGER MulticastReceivedFrameCount;
- LARGE_INTEGER FCSErrorCount;
-} COUNTER_802_11, *PCOUNTER_802_11;
-
-typedef struct _COUNTER_RALINK {
- ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput
- ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput
- ULONG BeenDisassociatedCount;
- ULONG BadCQIAutoRecoveryCount;
- ULONG PoorCQIRoamingCount;
- ULONG MgmtRingFullCount;
- ULONG RxCountSinceLastNULL;
- ULONG RxCount;
- ULONG RxRingErrCount;
- ULONG KickTxCount;
- ULONG TxRingErrCount;
- LARGE_INTEGER RealFcsErrCount;
- ULONG PendingNdisPacketCount;
-
- ULONG OneSecOsTxCount[NUM_OF_TX_RING];
- ULONG OneSecDmaDoneCount[NUM_OF_TX_RING];
- UINT32 OneSecTxDoneCount;
- ULONG OneSecRxCount;
- UINT32 OneSecTxAggregationCount;
- UINT32 OneSecRxAggregationCount;
-
- UINT32 OneSecFrameDuplicateCount;
-
-#ifdef RT2870
- ULONG OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput
-#endif // RT2870 //
-
- UINT32 OneSecTxNoRetryOkCount;
- UINT32 OneSecTxRetryOkCount;
- UINT32 OneSecTxFailCount;
- UINT32 OneSecFalseCCACnt; // CCA error count, for debug purpose, might move to global counter
- UINT32 OneSecRxOkCnt; // RX without error
- UINT32 OneSecRxOkDataCnt; // unicast-to-me DATA frame count
- UINT32 OneSecRxFcsErrCnt; // CRC error
- UINT32 OneSecBeaconSentCnt;
- UINT32 LastOneSecTotalTxCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
- UINT32 LastOneSecRxOkDataCnt; // OneSecRxOkDataCnt
- ULONG DuplicateRcv;
- ULONG TxAggCount;
- ULONG TxNonAggCount;
- ULONG TxAgg1MPDUCount;
- ULONG TxAgg2MPDUCount;
- ULONG TxAgg3MPDUCount;
- ULONG TxAgg4MPDUCount;
- ULONG TxAgg5MPDUCount;
- ULONG TxAgg6MPDUCount;
- ULONG TxAgg7MPDUCount;
- ULONG TxAgg8MPDUCount;
- ULONG TxAgg9MPDUCount;
- ULONG TxAgg10MPDUCount;
- ULONG TxAgg11MPDUCount;
- ULONG TxAgg12MPDUCount;
- ULONG TxAgg13MPDUCount;
- ULONG TxAgg14MPDUCount;
- ULONG TxAgg15MPDUCount;
- ULONG TxAgg16MPDUCount;
-
- LARGE_INTEGER TransmittedOctetsInAMSDU;
- LARGE_INTEGER TransmittedAMSDUCount;
- LARGE_INTEGER ReceivedOctesInAMSDUCount;
- LARGE_INTEGER ReceivedAMSDUCount;
- LARGE_INTEGER TransmittedAMPDUCount;
- LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
- LARGE_INTEGER TransmittedOctetsInAMPDUCount;
- LARGE_INTEGER MPDUInReceivedAMPDUCount;
-} COUNTER_RALINK, *PCOUNTER_RALINK;
-
-typedef struct _PID_COUNTER {
- ULONG TxAckRequiredCount; // CRC error
- ULONG TxAggreCount;
- ULONG TxSuccessCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
- ULONG LastSuccessRate;
-} PID_COUNTER, *PPID_COUNTER;
-
-typedef struct _COUNTER_DRS {
- // to record the each TX rate's quality. 0 is best, the bigger the worse.
- USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
- UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
- ULONG CurrTxRateStableTime; // # of second in current TX rate
- BOOLEAN fNoisyEnvironment;
- BOOLEAN fLastSecAccordingRSSI;
- UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
- UCHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
- ULONG LastTxOkCount;
-} COUNTER_DRS, *PCOUNTER_DRS;
-
-//
-// Arcfour Structure Added by PaulWu
-//
-typedef struct _ARCFOUR
-{
- UINT X;
- UINT Y;
- UCHAR STATE[256];
-} ARCFOURCONTEXT, *PARCFOURCONTEXT;
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI too. just copy to TXWI.
-typedef struct _RECEIVE_SETTING {
-#ifdef RT_BIG_ENDIAN
- USHORT MIMO:1;
- USHORT OFDM:1;
- USHORT rsv:3;
- USHORT STBC:2; //SPACE
- USHORT ShortGI:1;
- USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
- USHORT NumOfRX:2; // MIMO. WE HAVE 3R
-#else
- USHORT NumOfRX:2; // MIMO. WE HAVE 3R
- USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
- USHORT ShortGI:1;
- USHORT STBC:2; //SPACE
- USHORT rsv:3;
- USHORT OFDM:1;
- USHORT MIMO:1;
-#endif
- } RECEIVE_SETTING, *PRECEIVE_SETTING;
-
-// Shared key data structure
-typedef struct _WEP_KEY {
- UCHAR KeyLen; // Key length for each key, 0: entry is invalid
- UCHAR Key[MAX_LEN_OF_KEY]; // right now we implement 4 keys, 128 bits max
-} WEP_KEY, *PWEP_KEY;
-
-typedef struct _CIPHER_KEY {
- UCHAR Key[16]; // right now we implement 4 keys, 128 bits max
- UCHAR RxMic[8]; // make alignment
- UCHAR TxMic[8];
- UCHAR TxTsc[6]; // 48bit TSC value
- UCHAR RxTsc[6]; // 48bit TSC value
- UCHAR CipherAlg; // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
- UCHAR KeyLen;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR BssId[6];
-#endif // CONFIG_STA_SUPPORT //
- // Key length for each key, 0: entry is invalid
- UCHAR Type; // Indicate Pairwise/Group when reporting MIC error
-} CIPHER_KEY, *PCIPHER_KEY;
-
-typedef struct _BBP_TUNING_STRUCT {
- BOOLEAN Enable;
- UCHAR FalseCcaCountUpperBound; // 100 per sec
- UCHAR FalseCcaCountLowerBound; // 10 per sec
- UCHAR R17LowerBound; // specified in E2PROM
- UCHAR R17UpperBound; // 0x68 according to David Tung
- UCHAR CurrentR17Value;
-} BBP_TUNING, *PBBP_TUNING;
-
-typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
- UCHAR EvaluatePeriod; // 0:not evalute status, 1: evaluate status, 2: switching status
- UCHAR Pair1PrimaryRxAnt; // 0:Ant-E1, 1:Ant-E2
- UCHAR Pair1SecondaryRxAnt; // 0:Ant-E1, 1:Ant-E2
- UCHAR Pair2PrimaryRxAnt; // 0:Ant-E3, 1:Ant-E4
- UCHAR Pair2SecondaryRxAnt; // 0:Ant-E3, 1:Ant-E4
- SHORT Pair1AvgRssi[2]; // AvgRssi[0]:E1, AvgRssi[1]:E2
- SHORT Pair2AvgRssi[2]; // AvgRssi[0]:E3, AvgRssi[1]:E4
- SHORT Pair1LastAvgRssi; //
- SHORT Pair2LastAvgRssi; //
- ULONG RcvPktNumWhenEvaluate;
- BOOLEAN FirstPktArrivedWhenEvaluate;
- RALINK_TIMER_STRUCT RxAntDiversityTimer;
-} SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY;
-
-typedef struct _LEAP_AUTH_INFO {
- BOOLEAN Enabled; //Ture: Enable LEAP Authentication
- BOOLEAN CCKM; //Ture: Use Fast Reauthentication with CCKM
- UCHAR Reserve[2];
- UCHAR UserName[256]; //LEAP, User name
- ULONG UserNameLen;
- UCHAR Password[256]; //LEAP, User Password
- ULONG PasswordLen;
-} LEAP_AUTH_INFO, *PLEAP_AUTH_INFO;
-
-typedef struct {
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR ErrorCode[2]; //00 01-Invalid authentication type
- //00 02-Authentication timeout
- //00 03-Challenge from AP failed
- //00 04-Challenge to AP failed
- BOOLEAN Reported;
-} ROGUEAP_ENTRY, *PROGUEAP_ENTRY;
-
-typedef struct {
- UCHAR RogueApNr;
- ROGUEAP_ENTRY RogueApEntry[MAX_LEN_OF_BSS_TABLE];
-} ROGUEAP_TABLE, *PROGUEAP_TABLE;
-
-typedef struct {
- BOOLEAN Enable;
- UCHAR Delta;
- BOOLEAN PlusSign;
-} CCK_TX_POWER_CALIBRATE, *PCCK_TX_POWER_CALIBRATE;
-
-//
-// Receive Tuple Cache Format
-//
-typedef struct _TUPLE_CACHE {
- BOOLEAN Valid;
- UCHAR MacAddress[MAC_ADDR_LEN];
- USHORT Sequence;
- USHORT Frag;
-} TUPLE_CACHE, *PTUPLE_CACHE;
-
-//
-// Fragment Frame structure
-//
-typedef struct _FRAGMENT_FRAME {
- PNDIS_PACKET pFragPacket;
- ULONG RxSize;
- USHORT Sequence;
- USHORT LastFrag;
- ULONG Flags; // Some extra frame information. bit 0: LLC presented
-} FRAGMENT_FRAME, *PFRAGMENT_FRAME;
-
-
-//
-// Packet information for NdisQueryPacket
-//
-typedef struct _PACKET_INFO {
- UINT PhysicalBufferCount; // Physical breaks of buffer descripor chained
- UINT BufferCount ; // Number of Buffer descriptor chained
- UINT TotalPacketLength ; // Self explained
- PNDIS_BUFFER pFirstBuffer; // Pointer to first buffer descriptor
-} PACKET_INFO, *PPACKET_INFO;
-
-//
-// Tkip Key structure which RC4 key & MIC calculation
-//
-typedef struct _TKIP_KEY_INFO {
- UINT nBytesInM; // # bytes in M for MICKEY
- ULONG IV16;
- ULONG IV32;
- ULONG K0; // for MICKEY Low
- ULONG K1; // for MICKEY Hig
- ULONG L; // Current state for MICKEY
- ULONG R; // Current state for MICKEY
- ULONG M; // Message accumulator for MICKEY
- UCHAR RC4KEY[16];
- UCHAR MIC[8];
-} TKIP_KEY_INFO, *PTKIP_KEY_INFO;
-
-//
-// Private / Misc data, counters for driver internal use
-//
-typedef struct __PRIVATE_STRUC {
- UINT SystemResetCnt; // System reset counter
- UINT TxRingFullCnt; // Tx ring full occurrance number
- UINT PhyRxErrCnt; // PHY Rx error count, for debug purpose, might move to global counter
- // Variables for WEP encryption / decryption in rtmp_wep.c
- UINT FCSCRC32;
- ARCFOURCONTEXT WEPCONTEXT;
- // Tkip stuff
- TKIP_KEY_INFO Tx;
- TKIP_KEY_INFO Rx;
-} PRIVATE_STRUC, *PPRIVATE_STRUC;
-
-// structure to tune BBP R66 (BBP TUNING)
-typedef struct _BBP_R66_TUNING {
- BOOLEAN bEnable;
- USHORT FalseCcaLowerThreshold; // default 100
- USHORT FalseCcaUpperThreshold; // default 512
- UCHAR R66Delta;
- UCHAR R66CurrentValue;
- BOOLEAN R66LowerUpperSelect; //Before LinkUp, Used LowerBound or UpperBound as R66 value.
-} BBP_R66_TUNING, *PBBP_R66_TUNING;
-
-// structure to store channel TX power
-typedef struct _CHANNEL_TX_POWER {
- USHORT RemainingTimeForUse; //unit: sec
- UCHAR Channel;
-#ifdef DOT11N_DRAFT3
- BOOLEAN bEffectedChannel; // For BW 40 operating in 2.4GHz , the "effected channel" is the channel that is covered in 40Mhz.
-#endif // DOT11N_DRAFT3 //
- CHAR Power;
- CHAR Power2;
- UCHAR MaxTxPwr;
- UCHAR DfsReq;
-} CHANNEL_TX_POWER, *PCHANNEL_TX_POWER;
-
-// structure to store 802.11j channel TX power
-typedef struct _CHANNEL_11J_TX_POWER {
- UCHAR Channel;
- UCHAR BW; // BW_10 or BW_20
- CHAR Power;
- CHAR Power2;
- USHORT RemainingTimeForUse; //unit: sec
-} CHANNEL_11J_TX_POWER, *PCHANNEL_11J_TX_POWER;
-
-typedef enum _ABGBAND_STATE_ {
- UNKNOWN_BAND,
- BG_BAND,
- A_BAND,
-} ABGBAND_STATE;
-
-typedef struct _MLME_STRUCT {
-#ifdef CONFIG_STA_SUPPORT
- // STA state machines
- STATE_MACHINE CntlMachine;
- STATE_MACHINE AssocMachine;
- STATE_MACHINE AuthMachine;
- STATE_MACHINE AuthRspMachine;
- STATE_MACHINE SyncMachine;
- STATE_MACHINE WpaPskMachine;
- STATE_MACHINE LeapMachine;
- STATE_MACHINE AironetMachine;
- STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
- STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
- STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
- STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
- STATE_MACHINE_FUNC WpaPskFunc[WPA_PSK_FUNC_SIZE];
- STATE_MACHINE_FUNC AironetFunc[AIRONET_FUNC_SIZE];
-#endif // CONFIG_STA_SUPPORT //
- STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
- // Action
- STATE_MACHINE ActMachine;
-
-
-#ifdef QOS_DLS_SUPPORT
- STATE_MACHINE DlsMachine;
- STATE_MACHINE_FUNC DlsFunc[DLS_FUNC_SIZE];
-#endif // QOS_DLS_SUPPORT //
-
-
-
-
- ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
- ULONG Now32; // latch the value of NdisGetSystemUpTime()
- ULONG LastSendNULLpsmTime;
-
- BOOLEAN bRunning;
- NDIS_SPIN_LOCK TaskLock;
- MLME_QUEUE Queue;
-
- UINT ShiftReg;
-
- RALINK_TIMER_STRUCT PeriodicTimer;
- RALINK_TIMER_STRUCT APSDPeriodicTimer;
- RALINK_TIMER_STRUCT LinkDownTimer;
- RALINK_TIMER_STRUCT LinkUpTimer;
- ULONG PeriodicRound;
- ULONG OneSecPeriodicRound;
-
- UCHAR RealRxPath;
- BOOLEAN bLowThroughput;
- BOOLEAN bEnableAutoAntennaCheck;
- RALINK_TIMER_STRUCT RxAntEvalTimer;
-
-#ifdef RT2870
- UCHAR CaliBW40RfR24;
- UCHAR CaliBW20RfR24;
-#endif // RT2870 //
-
-} MLME_STRUCT, *PMLME_STRUCT;
-
-// structure for radar detection and channel switch
-typedef struct _RADAR_DETECT_STRUCT {
- //BOOLEAN IEEE80211H; // 0: disable, 1: enable IEEE802.11h
- UCHAR CSCount; //Channel switch counter
- UCHAR CSPeriod; //Channel switch period (beacon count)
- UCHAR RDCount; //Radar detection counter
- UCHAR RDMode; //Radar Detection mode
- UCHAR RDDurRegion; //Radar detection duration region
- UCHAR BBPR16;
- UCHAR BBPR17;
- UCHAR BBPR18;
- UCHAR BBPR21;
- UCHAR BBPR22;
- UCHAR BBPR64;
- ULONG InServiceMonitorCount; // unit: sec
- UINT8 DfsSessionTime;
- BOOLEAN bFastDfs;
- UINT8 ChMovingTime;
- UINT8 LongPulseRadarTh;
-} RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
-
-#ifdef CARRIER_DETECTION_SUPPORT
-typedef enum CD_STATE_n
-{
- CD_NORMAL,
- CD_SILENCE,
- CD_MAX_STATE
-} CD_STATE;
-
-typedef struct CARRIER_DETECTION_s
-{
- BOOLEAN Enable;
- UINT8 CDSessionTime;
- UINT8 CDPeriod;
- CD_STATE CD_State;
-} CARRIER_DETECTION, *PCARRIER_DETECTION;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-typedef enum _REC_BLOCKACK_STATUS
-{
- Recipient_NONE=0,
- Recipient_USED,
- Recipient_HandleRes,
- Recipient_Accept
-} REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
-
-typedef enum _ORI_BLOCKACK_STATUS
-{
- Originator_NONE=0,
- Originator_USED,
- Originator_WaitRes,
- Originator_Done
-} ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
-
-#ifdef DOT11_N_SUPPORT
-typedef struct _BA_ORI_ENTRY{
- UCHAR Wcid;
- UCHAR TID;
- UCHAR BAWinSize;
- UCHAR Token;
-// Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header.
- USHORT Sequence;
- USHORT TimeOutValue;
- ORI_BLOCKACK_STATUS ORI_BA_Status;
- RALINK_TIMER_STRUCT ORIBATimer;
- PVOID pAdapter;
-} BA_ORI_ENTRY, *PBA_ORI_ENTRY;
-
-typedef struct _BA_REC_ENTRY {
- UCHAR Wcid;
- UCHAR TID;
- UCHAR BAWinSize; // 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU.
- //UCHAR NumOfRxPkt;
- //UCHAR Curindidx; // the head in the RX reordering buffer
- USHORT LastIndSeq;
-// USHORT LastIndSeqAtTimer;
- USHORT TimeOutValue;
- RALINK_TIMER_STRUCT RECBATimer;
- ULONG LastIndSeqAtTimer;
- ULONG nDropPacket;
- ULONG rcvSeq;
- REC_BLOCKACK_STATUS REC_BA_Status;
-// UCHAR RxBufIdxUsed;
- // corresponding virtual address for RX reordering packet storage.
- //RTMP_REORDERDMABUF MAP_RXBuf[MAX_RX_REORDERBUF];
- NDIS_SPIN_LOCK RxReRingLock; // Rx Ring spinlock
-// struct _BA_REC_ENTRY *pNext;
- PVOID pAdapter;
- struct reordering_list list;
-} BA_REC_ENTRY, *PBA_REC_ENTRY;
-
-
-typedef struct {
- ULONG numAsRecipient; // I am recipient of numAsRecipient clients. These client are in the BARecEntry[]
- ULONG numAsOriginator; // I am originator of numAsOriginator clients. These clients are in the BAOriEntry[]
- BA_ORI_ENTRY BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
- BA_REC_ENTRY BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
-} BA_TABLE, *PBA_TABLE;
-
-//For QureyBATableOID use;
-typedef struct PACKED _OID_BA_REC_ENTRY{
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize
- UCHAR rsv;
- UCHAR BufSize[8];
- REC_BLOCKACK_STATUS REC_BA_Status[8];
-} OID_BA_REC_ENTRY, *POID_BA_REC_ENTRY;
-
-//For QureyBATableOID use;
-typedef struct PACKED _OID_BA_ORI_ENTRY{
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status
- UCHAR rsv;
- UCHAR BufSize[8];
- ORI_BLOCKACK_STATUS ORI_BA_Status[8];
-} OID_BA_ORI_ENTRY, *POID_BA_ORI_ENTRY;
-
-typedef struct _QUERYBA_TABLE{
- OID_BA_ORI_ENTRY BAOriEntry[32];
- OID_BA_REC_ENTRY BARecEntry[32];
- UCHAR OriNum;// Number of below BAOriEntry
- UCHAR RecNum;// Number of below BARecEntry
-} QUERYBA_TABLE, *PQUERYBA_TABLE;
-
-typedef union _BACAP_STRUC {
-#ifdef RT_BIG_ENDIAN
- struct {
- UINT32 :4;
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 MpduDensity:3;
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 AutoBA:1; // automatically BA
- UINT32 TxBAWinLimit:8;
- UINT32 RxBAWinLimit:8;
- } field;
-#else
- struct {
- UINT32 RxBAWinLimit:8;
- UINT32 TxBAWinLimit:8;
- UINT32 AutoBA:1; // automatically BA
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 MpduDensity:3;
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 :4;
- } field;
-#endif
- UINT32 word;
-} BACAP_STRUC, *PBACAP_STRUC;
-#endif // DOT11_N_SUPPORT //
-
-//This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic)
-typedef struct _IOT_STRUC {
- UCHAR Threshold[2];
- UCHAR ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[0]
- UCHAR RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[1]
- ULONG OneSecInWindowCount;
- ULONG OneSecFrameDuplicateCount;
- ULONG OneSecOutWindowCount;
- UCHAR DelOriAct;
- UCHAR DelRecAct;
- UCHAR RTSShortProt;
- UCHAR RTSLongProt;
- BOOLEAN bRTSLongProtOn;
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN bLastAtheros;
- BOOLEAN bCurrentAtheros;
- BOOLEAN bNowAtherosBurstOn;
- BOOLEAN bNextDisableRxBA;
- BOOLEAN bToggle;
-#endif // CONFIG_STA_SUPPORT //
-} IOT_STRUC, *PIOT_STRUC;
-
-// This is the registry setting for 802.11n transmit setting. Used in advanced page.
-typedef union _REG_TRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- UINT32 rsv:13;
- UINT32 EXTCHA:2;
- UINT32 HTMODE:1;
- UINT32 TRANSNO:2;
- UINT32 STBC:1; //SPACE
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 TxBF:1; // 3*3
- UINT32 rsv0:10;
- //UINT32 MCS:7; // MCS
- //UINT32 PhyMode:4;
- } field;
-#else
- struct {
- //UINT32 PhyMode:4;
- //UINT32 MCS:7; // MCS
- UINT32 rsv0:10;
- UINT32 TxBF:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 STBC:1; //SPACE
- UINT32 TRANSNO:2;
- UINT32 HTMODE:1;
- UINT32 EXTCHA:2;
- UINT32 rsv:13;
- } field;
-#endif
- UINT32 word;
-} REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
-
-typedef union _DESIRED_TRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT rsv:3;
- USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
- USHORT PhyMode:4;
- USHORT MCS:7; // MCS
- } field;
-#else
- struct {
- USHORT MCS:7; // MCS
- USHORT PhyMode:4;
- USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
- USHORT rsv:3;
- } field;
-#endif
- USHORT word;
- } DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
-
-typedef struct {
- BOOLEAN IsRecipient;
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR TID;
- UCHAR nMSDU;
- USHORT TimeOut;
- BOOLEAN bAllTid; // If True, delete all TID for BA sessions with this MACaddr.
-} OID_ADD_BA_ENTRY, *POID_ADD_BA_ENTRY;
-
-//
-// Multiple SSID structure
-//
-#define WLAN_MAX_NUM_OF_TIM ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
-#define WLAN_CT_TIM_BCMC_OFFSET 0 /* unit: 32B */
-
-/* clear bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
- pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
-
-/* set bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_SET(apidx) \
- pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
-
-/* clear a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
- { UCHAR tim_offset = wcid >> 3; \
- UCHAR bit_offset = wcid & 0x7; \
- ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
-
-/* set a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
- { UCHAR tim_offset = wcid >> 3; \
- UCHAR bit_offset = wcid & 0x7; \
- ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
-
-#ifdef RT2870
-#define BEACON_BITMAP_MASK 0xff
-typedef struct _BEACON_SYNC_STRUCT_
-{
- UCHAR BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
- UCHAR BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
- ULONG TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
- ULONG CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
- BOOLEAN EnableBeacon; // trigger to enable beacon transmission.
- UCHAR BeaconBitMap; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
- UCHAR DtimBitOn; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
-}BEACON_SYNC_STRUCT;
-#endif // RT2870 //
-
-typedef struct _MULTISSID_STRUCT {
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
- USHORT CapabilityInfo;
-
- PNET_DEV MSSIDDev;
-
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
- WPA_MIX_PAIR_CIPHER WpaMixPairCipher;
-
- ULONG TxCount;
- ULONG RxCount;
- ULONG ReceivedByteCount;
- ULONG TransmittedByteCount;
- ULONG RxErrorCount;
- ULONG RxDropCount;
-
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting. this is for reading registry setting only. not useful.
- BOOLEAN bAutoTxRateSwitch;
-
- //CIPHER_KEY SharedKey[SHARE_KEY_NUM]; // ref pAd->SharedKey[BSS][4]
- UCHAR DefaultKeyId;
-
- UCHAR TxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11, ...
- UCHAR DesiredRates[MAX_LEN_OF_SUPPORTED_RATES];// OID_802_11_DESIRED_RATES
- UCHAR DesiredRatesIndex;
- UCHAR MaxTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
-
-// ULONG TimBitmap; // bit0 for broadcast, 1 for AID1, 2 for AID2, ...so on
-// ULONG TimBitmap2; // b0 for AID32, b1 for AID33, ... and so on
- UCHAR TimBitmaps[WLAN_MAX_NUM_OF_TIM];
-
- // WPA
- UCHAR GMK[32];
- UCHAR PMK[32];
- UCHAR GTK[32];
- BOOLEAN IEEE8021X;
- BOOLEAN PreAuth;
- UCHAR GNonce[32];
- UCHAR PortSecured;
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter;
- UCHAR BANClass3Data;
- ULONG IsolateInterStaTraffic;
-
- UCHAR RSNIE_Len[2];
- UCHAR RSN_IE[2][MAX_LEN_OF_RSNIE];
-
-
- UCHAR TimIELocationInBeacon;
- UCHAR CapabilityInfoLocationInBeacon;
- // outgoing BEACON frame buffer and corresponding TXWI
- // PTXWI_STRUC BeaconTxWI; //
- CHAR BeaconBuf[MAX_BEACON_SIZE]; // NOTE: BeaconBuf should be 4-byte aligned
-
- BOOLEAN bHideSsid;
- UINT16 StationKeepAliveTime; // unit: second
-
- USHORT VLAN_VID;
- USHORT VLAN_Priority;
-
- RT_802_11_ACL AccessControlList;
-
- // EDCA Qos
- BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
- BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
-
- UCHAR DlsPTK[64]; // Due to windows dirver count on meetinghouse to handle 4-way shake
-
- // For 802.1x daemon setting per BSS
- UCHAR radius_srv_num;
- RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
-
-#ifdef RTL865X_SOC
- unsigned int mylinkid;
-#endif
-
-
- UINT32 RcvdConflictSsidCount;
- UINT32 RcvdSpoofedAssocRespCount;
- UINT32 RcvdSpoofedReassocRespCount;
- UINT32 RcvdSpoofedProbeRespCount;
- UINT32 RcvdSpoofedBeaconCount;
- UINT32 RcvdSpoofedDisassocCount;
- UINT32 RcvdSpoofedAuthCount;
- UINT32 RcvdSpoofedDeauthCount;
- UINT32 RcvdSpoofedUnknownMgmtCount;
- UINT32 RcvdReplayAttackCount;
-
- CHAR RssiOfRcvdConflictSsid;
- CHAR RssiOfRcvdSpoofedAssocResp;
- CHAR RssiOfRcvdSpoofedReassocResp;
- CHAR RssiOfRcvdSpoofedProbeResp;
- CHAR RssiOfRcvdSpoofedBeacon;
- CHAR RssiOfRcvdSpoofedDisassoc;
- CHAR RssiOfRcvdSpoofedAuth;
- CHAR RssiOfRcvdSpoofedDeauth;
- CHAR RssiOfRcvdSpoofedUnknownMgmt;
- CHAR RssiOfRcvdReplayAttack;
-
- BOOLEAN bBcnSntReq;
- UCHAR BcnBufIdx;
-} MULTISSID_STRUCT, *PMULTISSID_STRUCT;
-
-
-
-#ifdef DOT11N_DRAFT3
-typedef enum _BSS2040COEXIST_FLAG{
- BSS_2040_COEXIST_DISABLE = 0,
- BSS_2040_COEXIST_TIMER_FIRED = 1,
- BSS_2040_COEXIST_INFO_SYNC = 2,
- BSS_2040_COEXIST_INFO_NOTIFY = 4,
-}BSS2040COEXIST_FLAG;
-#endif // DOT11N_DRAFT3 //
-
-// configuration common to OPMODE_AP as well as OPMODE_STA
-typedef struct _COMMON_CONFIG {
-
- BOOLEAN bCountryFlag;
- UCHAR CountryCode[3];
- UCHAR Geography;
- UCHAR CountryRegion; // Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel
- UCHAR CountryRegionForABand; // Enum of country region for A band
- UCHAR PhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED
- USHORT Dsifs; // in units of usec
- ULONG PacketFilter; // Packet filter for receiving
-
- CHAR Ssid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
- UCHAR SsidLen; // the actual ssid length in used
- UCHAR LastSsidLen; // the actual ssid length in used
- CHAR LastSsid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
- UCHAR LastBssid[MAC_ADDR_LEN];
-
- UCHAR Bssid[MAC_ADDR_LEN];
- USHORT BeaconPeriod;
- UCHAR Channel;
- UCHAR CentralChannel; // Central Channel when using 40MHz is indicating. not real channel.
-
-#if 0 // move to STA_ADMIN_CONFIG
- UCHAR DefaultKeyId;
-
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_WEP_STATUS OrigWepStatus; // Original wep status set from OID
-
- // Add to support different cipher suite for WPA2/WPA mode
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
- BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
- USHORT RsnCapability;
-
- NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
-#endif
-
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen;
- UCHAR DesireRate[MAX_LEN_OF_SUPPORTED_RATES]; // OID_802_11_DESIRED_RATES
- UCHAR MaxDesiredRate;
- UCHAR ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
-
- ULONG BasicRateBitmap; // backup basic ratebitmap
-
- BOOLEAN bAPSDCapable;
- BOOLEAN bInServicePeriod;
- BOOLEAN bAPSDAC_BE;
- BOOLEAN bAPSDAC_BK;
- BOOLEAN bAPSDAC_VI;
- BOOLEAN bAPSDAC_VO;
- BOOLEAN bNeedSendTriggerFrame;
- BOOLEAN bAPSDForcePowerSave; // Force power save mode, should only use in APSD-STAUT
- ULONG TriggerTimerCount;
- UCHAR MaxSPLength;
- UCHAR BBPCurrentBW; // BW_10, BW_20, BW_40
- // move to MULTISSID_STRUCT for MBSS
- //HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
- REG_TRANSMIT_SETTING RegTransmitSetting; //registry transmit setting. this is for reading registry setting only. not useful.
- //UCHAR FixedTxMode; // Fixed Tx Mode (CCK, OFDM), for HT fixed tx mode (GF, MIX) , refer to RegTransmitSetting.field.HTMode
- UCHAR TxRate; // Same value to fill in TXD. TxRate is 6-bit
- UCHAR MaxTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
- UCHAR TxRateIndex; // Tx rate index in RateSwitchTable
- UCHAR TxRateTableSize; // Valid Tx rate table size in RateSwitchTable
- //BOOLEAN bAutoTxRateSwitch;
- UCHAR MinTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
- UCHAR RtsRate; // RATE_xxx
- HTTRANSMIT_SETTING MlmeTransmit; // MGMT frame PHY rate setting when operatin at Ht rate.
- UCHAR MlmeRate; // RATE_xxx, used to send MLME frames
- UCHAR BasicMlmeRate; // Default Rate for sending MLME frames
-
- USHORT RtsThreshold; // in unit of BYTE
- USHORT FragmentThreshold; // in unit of BYTE
-
- UCHAR TxPower; // in unit of mW
- ULONG TxPowerPercentage; // 0~100 %
- ULONG TxPowerDefault; // keep for TxPowerPercentage
-
-#ifdef DOT11_N_SUPPORT
- BACAP_STRUC BACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
- BACAP_STRUC REGBACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
-#endif // DOT11_N_SUPPORT //
- IOT_STRUC IOTestParm; // 802.11n InterOpbility Test Parameter;
- ULONG TxPreamble; // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto
- BOOLEAN bUseZeroToDisableFragment; // Microsoft use 0 as disable
- ULONG UseBGProtection; // 0: auto, 1: always use, 2: always not use
- BOOLEAN bUseShortSlotTime; // 0: disable, 1 - use short slot (9us)
- BOOLEAN bEnableTxBurst; // 1: enble TX PACKET BURST, 0: disable TX PACKET BURST
- BOOLEAN bAggregationCapable; // 1: enable TX aggregation when the peer supports it
- BOOLEAN bPiggyBackCapable; // 1: enable TX piggy-back according MAC's version
- BOOLEAN bIEEE80211H; // 1: enable IEEE802.11h spec.
- ULONG DisableOLBCDetect; // 0: enable OLBC detect; 1 disable OLBC detect
-
-#ifdef DOT11_N_SUPPORT
- BOOLEAN bRdg;
-#endif // DOT11_N_SUPPORT //
- BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
- QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
- EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
- QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
- UCHAR AckPolicy[4]; // ACK policy of the specified AC. see ACK_xxx
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
-#endif // CONFIG_STA_SUPPORT //
- // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
- // BOOLEAN control, either ON or OFF. These flags should always be accessed via
- // OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros.
- // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition
- ULONG OpStatusFlags;
-
- BOOLEAN NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.
- ABGBAND_STATE BandState; // For setting BBP used on B/G or A mode.
-
- // IEEE802.11H--DFS.
- RADAR_DETECT_STRUCT RadarDetect;
-
-#ifdef CARRIER_DETECTION_SUPPORT
- CARRIER_DETECTION CarrierDetect;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- // HT
- UCHAR BASize; // USer desired BAWindowSize. Should not exceed our max capability
- //RT_HT_CAPABILITY SupportedHtPhy;
- RT_HT_CAPABILITY DesiredHtPhy;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHTInfo; // Useful as AP.
- //This IE is used with channel switch announcement element when changing to a new 40MHz.
- //This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp.
- NEW_EXT_CHAN_IE NewExtChanOffset; //7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present
-
-#ifdef DOT11N_DRAFT3
- UCHAR Bss2040CoexistFlag; // bit 0: bBssCoexistTimerRunning, bit 1: NeedSyncAddHtInfo.
- RALINK_TIMER_STRUCT Bss2040CoexistTimer;
-
- //This IE is used for 20/40 BSS Coexistence.
- BSS_2040_COEXIST_IE BSS2040CoexistInfo;
- // ====== 11n D3.0 =======================>
- USHORT Dot11OBssScanPassiveDwell; // Unit : TU. 5~1000
- USHORT Dot11OBssScanActiveDwell; // Unit : TU. 10~1000
- USHORT Dot11BssWidthTriggerScanInt; // Unit : Second
- USHORT Dot11OBssScanPassiveTotalPerChannel; // Unit : TU. 200~10000
- USHORT Dot11OBssScanActiveTotalPerChannel; // Unit : TU. 20~10000
- USHORT Dot11BssWidthChanTranDelayFactor;
- USHORT Dot11OBssScanActivityThre; // Unit : percentage
-
- ULONG Dot11BssWidthChanTranDelay; // multiple of (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
- ULONG CountDownCtr; // CountDown Counter from (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
-
- NDIS_SPIN_LOCK TriggerEventTabLock;
- BSS_2040_COEXIST_IE LastBSSCoexist2040;
- BSS_2040_COEXIST_IE BSSCoexist2040;
- TRIGGER_EVENT_TAB TriggerEventTab;
- UCHAR ChannelListIdx;
- // <====== 11n D3.0 =======================
- BOOLEAN bOverlapScanning;
-#endif // DOT11N_DRAFT3 //
-
- BOOLEAN bHTProtect;
- BOOLEAN bMIMOPSEnable;
- BOOLEAN bBADecline;
- BOOLEAN bDisableReordering;
- BOOLEAN bForty_Mhz_Intolerant;
- BOOLEAN bExtChannelSwitchAnnouncement;
- BOOLEAN bRcvBSSWidthTriggerEvents;
- ULONG LastRcvBSSWidthTriggerEventsTime;
-
- UCHAR TxBASize;
-#endif // DOT11_N_SUPPORT //
-
- // Enable wireless event
- BOOLEAN bWirelessEvent;
- BOOLEAN bWiFiTest; // Enable this parameter for WiFi test
-
- // Tx & Rx Stream number selection
- UCHAR TxStream;
- UCHAR RxStream;
-
- // transmit phy mode, trasmit rate for Multicast.
-#ifdef MCAST_RATE_SPECIFIC
- UCHAR McastTransmitMcs;
- UCHAR McastTransmitPhyMode;
-#endif // MCAST_RATE_SPECIFIC //
-
- BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
-
-#ifdef RT2870
- BOOLEAN bMultipleIRP; // Multiple Bulk IN flag
- UCHAR NumOfBulkInIRP; // if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1
- RT_HT_CAPABILITY SupportedHtPhy;
- ULONG MaxPktOneTxBulk;
- UCHAR TxBulkFactor;
- UCHAR RxBulkFactor;
-
- BEACON_SYNC_STRUCT *pBeaconSync;
- RALINK_TIMER_STRUCT BeaconUpdateTimer;
- UINT32 BeaconAdjust;
- UINT32 BeaconFactor;
- UINT32 BeaconRemain;
-#endif // RT2870 //
-
-
- NDIS_SPIN_LOCK MeasureReqTabLock;
- PMEASURE_REQ_TAB pMeasureReqTab;
-
- NDIS_SPIN_LOCK TpcReqTabLock;
- PTPC_REQ_TAB pTpcReqTab;
-
- // transmit phy mode, trasmit rate for Multicast.
-#ifdef MCAST_RATE_SPECIFIC
- HTTRANSMIT_SETTING MCastPhyMode;
-#endif // MCAST_RATE_SPECIFIC //
-
-#ifdef SINGLE_SKU
- UINT16 DefineMaxTxPwr;
-#endif // SINGLE_SKU //
-
-
-} COMMON_CONFIG, *PCOMMON_CONFIG;
-
-
-#ifdef CONFIG_STA_SUPPORT
-/* Modified by Wu Xi-Kun 4/21/2006 */
-// STA configuration and status
-typedef struct _STA_ADMIN_CONFIG {
- // GROUP 1 -
- // User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
- // the user intended configuration, but not necessary fully equal to the final
- // settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either
- // AP or IBSS holder).
- // Once initialized, user configuration can only be changed via OID_xxx
- UCHAR BssType; // BSS_INFRA or BSS_ADHOC
- USHORT AtimWin; // used when starting a new IBSS
-
- // GROUP 2 -
- // User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
- // the user intended configuration, and should be always applied to the final
- // settings in ACTIVE BSS without compromising with the BSS holder.
- // Once initialized, user configuration can only be changed via OID_xxx
- UCHAR RssiTrigger;
- UCHAR RssiTriggerMode; // RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD
- USHORT DefaultListenCount; // default listen count;
- ULONG WindowsPowerMode; // Power mode for AC power
- ULONG WindowsBatteryPowerMode; // Power mode for battery if exists
- BOOLEAN bWindowsACCAMEnable; // Enable CAM power mode when AC on
- BOOLEAN bAutoReconnect; // Set to TRUE when setting OID_802_11_SSID with no matching BSSID
- ULONG WindowsPowerProfile; // Windows power profile, for NDIS5.1 PnP
-
- // MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1)
- USHORT Psm; // power management mode (PWR_ACTIVE|PWR_SAVE)
- USHORT DisassocReason;
- UCHAR DisassocSta[MAC_ADDR_LEN];
- USHORT DeauthReason;
- UCHAR DeauthSta[MAC_ADDR_LEN];
- USHORT AuthFailReason;
- UCHAR AuthFailSta[MAC_ADDR_LEN];
-
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_WEP_STATUS OrigWepStatus; // Original wep status set from OID
-
- // Add to support different cipher suite for WPA2/WPA mode
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
- BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
- USHORT RsnCapability;
-
- NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
-
- UCHAR PMK[32]; // WPA PSK mode PMK
- UCHAR PTK[64]; // WPA PSK mode PTK
- UCHAR GTK[32]; // GTK from authenticator
- BSSID_INFO SavedPMK[PMKID_NO];
- UINT SavedPMKNum; // Saved PMKID number
-
- UCHAR DefaultKeyId;
-
-
- // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
- UCHAR PortSecured;
-
- // For WPA countermeasures
- ULONG LastMicErrorTime; // record last MIC error time
- ULONG MicErrCnt; // Should be 0, 1, 2, then reset to zero (after disassoiciation).
- BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
- // For WPA-PSK supplicant state
- WPA_STATE WpaState; // Default is SS_NOTUSE and handled by microsoft 802.1x
- UCHAR ReplayCounter[8];
- UCHAR ANonce[32]; // ANonce for WPA-PSK from aurhenticator
- UCHAR SNonce[32]; // SNonce for WPA-PSK
-
- UCHAR LastSNR0; // last received BEACON's SNR
- UCHAR LastSNR1; // last received BEACON's SNR for 2nd antenna
- RSSI_SAMPLE RssiSample;
- ULONG NumOfAvgRssiSample;
-
- ULONG LastBeaconRxTime; // OS's timestamp of the last BEACON RX time
- ULONG Last11bBeaconRxTime; // OS's timestamp of the last 11B BEACON RX time
- ULONG Last11gBeaconRxTime; // OS's timestamp of the last 11G BEACON RX time
- ULONG Last20NBeaconRxTime; // OS's timestamp of the last 20MHz N BEACON RX time
-
- ULONG LastScanTime; // Record last scan time for issue BSSID_SCAN_LIST
- ULONG ScanCnt; // Scan counts since most recent SSID, BSSID, SCAN OID request
- BOOLEAN bSwRadio; // Software controlled Radio On/Off, TRUE: On
- BOOLEAN bHwRadio; // Hardware controlled Radio On/Off, TRUE: On
- BOOLEAN bRadio; // Radio state, And of Sw & Hw radio state
- BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
- BOOLEAN bShowHiddenSSID; // Show all known SSID in SSID list get operation
-
-
- // New for WPA, windows want us to to keep association information and
- // Fixed IEs from last association response
- NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
- USHORT ReqVarIELen; // Length of next VIE include EID & Length
- UCHAR ReqVarIEs[MAX_VIE_LEN]; // The content saved here should be little-endian format.
- USHORT ResVarIELen; // Length of next VIE include EID & Length
- UCHAR ResVarIEs[MAX_VIE_LEN];
-
- UCHAR RSNIE_Len;
- UCHAR RSN_IE[MAX_LEN_OF_RSNIE]; // The content saved here should be little-endian format.
-
- // New variables used for CCX 1.0
- BOOLEAN bCkipOn;
- BOOLEAN bCkipCmicOn;
- UCHAR CkipFlag;
- UCHAR GIV[3]; //for CCX iv
- UCHAR RxSEQ[4];
- UCHAR TxSEQ[4];
- UCHAR CKIPMIC[4];
- UCHAR LeapAuthMode;
- LEAP_AUTH_INFO LeapAuthInfo;
- UCHAR HashPwd[16];
- UCHAR NetworkChallenge[8];
- UCHAR NetworkChallengeResponse[24];
- UCHAR PeerChallenge[8];
-
- UCHAR PeerChallengeResponse[24];
- UCHAR SessionKey[16]; //Network session keys (NSK)
- RALINK_TIMER_STRUCT LeapAuthTimer;
- ROGUEAP_TABLE RogueApTab; //Cisco CCX1 Rogue AP Detection
-
- // New control flags for CCX
- CCX_CONTROL CCXControl; // Master administration state
- BOOLEAN CCXEnable; // Actual CCX state
- UCHAR CCXScanChannel; // Selected channel for CCX beacon request
- USHORT CCXScanTime; // Time out to wait for beacon and probe response
- UCHAR CCXReqType; // Current processing CCX request type
- BSS_TABLE CCXBssTab; // BSS Table
- UCHAR FrameReportBuf[2048]; // Buffer for creating frame report
- USHORT FrameReportLen; // Current Frame report length
- ULONG CLBusyBytes; // Save the total bytes received durning channel load scan time
- USHORT RPIDensity[8]; // Array for RPI density collection
- // Start address of each BSS table within FrameReportBuf
- // It's important to update the RxPower of the corresponding Bss
- USHORT BssReportOffset[MAX_LEN_OF_BSS_TABLE];
- USHORT BeaconToken; // Token for beacon report
- ULONG LastBssIndex; // Most current reported Bss index
- RM_REQUEST_ACTION MeasurementRequest[16]; // Saved measurement request
- UCHAR RMReqCnt; // Number of measurement request saved.
- UCHAR CurrentRMReqIdx; // Number of measurement request saved.
- BOOLEAN ParallelReq; // Parallel measurement, only one request performed,
- // It must be the same channel with maximum duration
- USHORT ParallelDuration; // Maximum duration for parallel measurement
- UCHAR ParallelChannel; // Only one channel with parallel measurement
- USHORT IAPPToken; // IAPP dialog token
- UCHAR CCXQosECWMin; // Cisco QOS ECWMin for AC 0
- UCHAR CCXQosECWMax; // Cisco QOS ECWMax for AC 0
- // Hack for channel load and noise histogram parameters
- UCHAR NHFactor; // Parameter for Noise histogram
- UCHAR CLFactor; // Parameter for channel load
-
- UCHAR KRK[16]; //Key Refresh Key.
- UCHAR BTK[32]; //Base Transient Key
- BOOLEAN CCKMLinkUpFlag;
- ULONG CCKMRN; //(Re)Association request number.
- LARGE_INTEGER CCKMBeaconAtJoinTimeStamp; //TSF timer for Re-assocaite to the new AP
- UCHAR AironetCellPowerLimit; //in dBm
- UCHAR AironetIPAddress[4]; //eg. 192.168.1.1
- BOOLEAN CCXAdjacentAPReportFlag; //flag for determining report Assoc Lost time
- CHAR CCXAdjacentAPSsid[MAX_LEN_OF_SSID]; //Adjacent AP's SSID report
- UCHAR CCXAdjacentAPSsidLen; // the actual ssid length in used
- UCHAR CCXAdjacentAPBssid[MAC_ADDR_LEN]; //Adjacent AP's BSSID report
- USHORT CCXAdjacentAPChannel;
- ULONG CCXAdjacentAPLinkDownTime; //for Spec S32.
-
- RALINK_TIMER_STRUCT StaQuickResponeForRateUpTimer;
- BOOLEAN StaQuickResponeForRateUpTimerRunning;
-
- UCHAR DtimCount; // 0.. DtimPeriod-1
- UCHAR DtimPeriod; // default = 3
-
-#ifdef QOS_DLS_SUPPORT
- RT_802_11_DLS DLSEntry[MAX_NUM_OF_DLS_ENTRY];
- UCHAR DlsReplayCounter[8];
-#endif // QOS_DLS_SUPPORT //
- ////////////////////////////////////////////////////////////////////////////////////////
- // This is only for WHQL test.
- BOOLEAN WhqlTest;
- ////////////////////////////////////////////////////////////////////////////////////////
-
- RALINK_TIMER_STRUCT WpaDisassocAndBlockAssocTimer;
- // Fast Roaming
- BOOLEAN bFastRoaming; // 0:disable fast roaming, 1:enable fast roaming
- CHAR dBmToRoam; // the condition to roam when receiving Rssi less than this value. It's negative value.
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- BOOLEAN IEEE8021X;
- BOOLEAN IEEE8021x_required_keys;
- CIPHER_KEY DesireSharedKey[4]; // Record user desired WEP keys
- UCHAR DesireSharedKeyId;
-
- // 0: driver ignores wpa_supplicant
- // 1: wpa_supplicant initiates scanning and AP selection
- // 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters
- UCHAR WpaSupplicantUP;
- UCHAR WpaSupplicantScanCount;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- CHAR dev_name[16];
- USHORT OriDevType;
-
- BOOLEAN bTGnWifiTest;
- BOOLEAN bScanReqIsFromWebUI;
-
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting;
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- BOOLEAN bAutoTxRateSwitch;
-
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- UCHAR IEEE80211dClientMode;
- UCHAR StaOriCountryCode[3];
- UCHAR StaOriGeography;
-#endif // EXT_BUILD_CHANNEL_LIST //
-} STA_ADMIN_CONFIG, *PSTA_ADMIN_CONFIG;
-
-// This data structure keep the current active BSS/IBSS's configuration that this STA
-// had agreed upon joining the network. Which means these parameters are usually decided
-// by the BSS/IBSS creator instead of user configuration. Data in this data structurre
-// is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE.
-// Normally, after SCAN or failed roaming attempts, we need to recover back to
-// the current active settings.
-typedef struct _STA_ACTIVE_CONFIG {
- USHORT Aid;
- USHORT AtimWin; // in kusec; IBSS parameter set element
- USHORT CapabilityInfo;
- USHORT CfpMaxDuration;
- USHORT CfpPeriod;
-
- // Copy supported rate from desired AP's beacon. We are trying to match
- // AP's supported and extended rate settings.
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRateLen;
- // Copy supported ht from desired AP's beacon. We are trying to match
- RT_HT_PHY_INFO SupportedPhyInfo;
- RT_HT_CAPABILITY SupportedHtPhy;
-} STA_ACTIVE_CONFIG, *PSTA_ACTIVE_CONFIG;
-
-#ifdef RT2870
-// for USB interface, avoid in interrupt when write key
-typedef struct RT_ADD_PAIRWISE_KEY_ENTRY {
- NDIS_802_11_MAC_ADDRESS MacAddr;
- USHORT MacTabMatchWCID; // ASIC
- CIPHER_KEY CipherKey;
-} RT_ADD_PAIRWISE_KEY_ENTRY,*PRT_ADD_PAIRWISE_KEY_ENTRY;
-#endif // RT2870 //
-#endif // CONFIG_STA_SUPPORT //
-
-// ----------- start of AP --------------------------
-// AUTH-RSP State Machine Aux data structure
-typedef struct _AP_MLME_AUX {
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Alg;
- CHAR Challenge[CIPHER_TEXT_LEN];
-} AP_MLME_AUX, *PAP_MLME_AUX;
-
-// structure to define WPA Group Key Rekey Interval
-typedef struct PACKED _RT_802_11_WPA_REKEY {
- ULONG ReKeyMethod; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
- ULONG ReKeyInterval; // time-based: seconds, packet-based: kilo-packets
-} RT_WPA_REKEY,*PRT_WPA_REKEY, RT_802_11_WPA_REKEY, *PRT_802_11_WPA_REKEY;
-
-typedef struct _MAC_TABLE_ENTRY {
- //Choose 1 from ValidAsWDS and ValidAsCLI to validize.
- BOOLEAN ValidAsCLI; // Sta mode, set this TRUE after Linkup,too.
- BOOLEAN ValidAsWDS; // This is WDS Entry. only for AP mode.
- BOOLEAN ValidAsApCli; //This is a AP-Client entry, only for AP mode which enable AP-Client functions.
- BOOLEAN ValidAsMesh;
- BOOLEAN ValidAsDls; // This is DLS Entry. only for STA mode.
- BOOLEAN isCached;
- BOOLEAN bIAmBadAtheros; // Flag if this is Atheros chip that has IOT problem. We need to turn on RTS/CTS protection.
-
- UCHAR EnqueueEapolStartTimerRunning; // Enqueue EAPoL-Start for triggering EAP SM
- //jan for wpa
- // record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB
- UCHAR CMTimerRunning;
- UCHAR apidx; // MBSS number
- UCHAR RSNIE_Len;
- UCHAR RSN_IE[MAX_LEN_OF_RSNIE];
- UCHAR ANonce[LEN_KEY_DESC_NONCE];
- UCHAR R_Counter[LEN_KEY_DESC_REPLAY];
- UCHAR PTK[64];
- UCHAR ReTryCounter;
- RALINK_TIMER_STRUCT RetryTimer;
- RALINK_TIMER_STRUCT EnqueueStartForPSKTimer; // A timer which enqueue EAPoL-Start for triggering PSK SM
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
- AP_WPA_STATE WpaState;
- GTK_STATE GTKState;
- USHORT PortSecured;
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
- CIPHER_KEY PairwiseKey;
- PVOID pAd;
- INT PMKID_CacheIdx;
- UCHAR PMKID[LEN_PMKID];
-
-
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR PsMode;
- SST Sst;
- AUTH_STATE AuthState; // for SHARED KEY authentication state machine used only
- BOOLEAN IsReassocSta; // Indicate whether this is a reassociation procedure
- USHORT Aid;
- USHORT CapabilityInfo;
- UCHAR LastRssi;
- ULONG NoDataIdleCount;
- UINT16 StationKeepAliveCount; // unit: second
- ULONG PsQIdleCount;
- QUEUE_HEADER PsQueue;
-
- UINT32 StaConnectTime; // the live time of this station since associated with AP
-
-
-#ifdef DOT11_N_SUPPORT
- BOOLEAN bSendBAR;
- USHORT NoBADataCountDown;
-
- UINT32 CachedBuf[16]; // UINT (4 bytes) for alignment
- UINT TxBFCount; // 3*3
-#endif // DOT11_N_SUPPORT //
- UINT FIFOCount;
- UINT DebugFIFOCount;
- UINT DebugTxCount;
- BOOLEAN bDlsInit;
-
-
-//====================================================
-//WDS entry needs these
-// rt2860 add this. if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab
- UINT MatchWDSTabIdx;
- UCHAR MaxSupportedRate;
- UCHAR CurrTxRate;
- UCHAR CurrTxRateIndex;
- // to record the each TX rate's quality. 0 is best, the bigger the worse.
- USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
-// USHORT OneSecTxOkCount;
- UINT32 OneSecTxNoRetryOkCount;
- UINT32 OneSecTxRetryOkCount;
- UINT32 OneSecTxFailCount;
- UINT32 ContinueTxFailCnt;
- UINT32 CurrTxRateStableTime; // # of second in current TX rate
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
-//====================================================
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- UINT MatchDlsEntryIdx; // indicate the index in pAd->StaCfg.DLSEntry
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
- BOOLEAN fNoisyEnvironment;
- BOOLEAN fLastSecAccordingRSSI;
- UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
- CHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
- ULONG LastTxOkCount;
- UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
-
- // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
- // BOOLEAN control, either ON or OFF. These flags should always be accessed via
- // CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros.
- // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED
- ULONG ClientStatusFlags;
-
- // TODO: Shall we move that to DOT11_N_SUPPORT???
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-
-#ifdef DOT11_N_SUPPORT
- // HT EWC MIMO-N used parameters
- USHORT RXBAbitmap; // fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format
- USHORT TXBAbitmap; // This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI
- USHORT TXAutoBAbitmap;
- USHORT BADeclineBitmap;
- USHORT BARecWcidArray[NUM_OF_TID]; // The mapping wcid of recipient session. if RXBAbitmap bit is masked
- USHORT BAOriWcidArray[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
- USHORT BAOriSequence[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
-
- // 802.11n features.
- UCHAR MpduDensity;
- UCHAR MaxRAmpduFactor;
- UCHAR AMsduSize;
- UCHAR MmpsMode; // MIMO power save more.
-
- HT_CAPABILITY_IE HTCapability;
-
-#ifdef DOT11N_DRAFT3
- UCHAR BSS2040CoexistenceMgmtSupport;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
- BOOLEAN bAutoTxRateSwitch;
-
- UCHAR RateLen;
- struct _MAC_TABLE_ENTRY *pNext;
- USHORT TxSeq[NUM_OF_TID];
- USHORT NonQosDataSeq;
-
- RSSI_SAMPLE RssiSample;
-
- UINT32 TXMCSExpected[16];
- UINT32 TXMCSSuccessful[16];
- UINT32 TXMCSFailed[16];
- UINT32 TXMCSAutoFallBack[16][16];
-
-#ifdef CONFIG_STA_SUPPORT
- ULONG LastBeaconRxTime;
-#endif // CONFIG_STA_SUPPORT //
-} MAC_TABLE_ENTRY, *PMAC_TABLE_ENTRY;
-
-typedef struct _MAC_TABLE {
- USHORT Size;
- MAC_TABLE_ENTRY *Hash[HASH_TABLE_SIZE];
- MAC_TABLE_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
- QUEUE_HEADER McastPsQueue;
- ULONG PsQIdleCount;
- BOOLEAN fAnyStationInPsm;
- BOOLEAN fAnyStationBadAtheros; // Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip.
- BOOLEAN fAnyTxOPForceDisable; // Check if it is necessary to disable BE TxOP
- BOOLEAN fAllStationAsRalink; // Check if all stations are ralink-chipset
-#ifdef DOT11_N_SUPPORT
- BOOLEAN fAnyStationIsLegacy; // Check if I use legacy rate to transmit to my BSS Station/
- BOOLEAN fAnyStationNonGF; // Check if any Station can't support GF.
- BOOLEAN fAnyStation20Only; // Check if any Station can't support GF.
- BOOLEAN fAnyStationMIMOPSDynamic; // Check if any Station is MIMO Dynamic
- BOOLEAN fAnyBASession; // Check if there is BA session. Force turn on RTS/CTS
-#endif // DOT11_N_SUPPORT //
-} MAC_TABLE, *PMAC_TABLE;
-
-#ifdef DOT11_N_SUPPORT
-#define IS_HT_STA(_pMacEntry) \
- (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define IS_HT_RATE(_pMacEntry) \
- (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define PEER_IS_HT_RATE(_pMacEntry) \
- (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-#endif // DOT11_N_SUPPORT //
-
-typedef struct _WDS_ENTRY {
- BOOLEAN Valid;
- UCHAR Addr[MAC_ADDR_LEN];
- ULONG NoDataIdleCount;
- struct _WDS_ENTRY *pNext;
-} WDS_ENTRY, *PWDS_ENTRY;
-
-typedef struct _WDS_TABLE_ENTRY {
- USHORT Size;
- UCHAR WdsAddr[MAC_ADDR_LEN];
- WDS_ENTRY *Hash[HASH_TABLE_SIZE];
- WDS_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
- UCHAR MaxSupportedRate;
- UCHAR CurrTxRate;
- USHORT TxQuality[MAX_LEN_OF_SUPPORTED_RATES];
- USHORT OneSecTxOkCount;
- USHORT OneSecTxRetryOkCount;
- USHORT OneSecTxFailCount;
- ULONG CurrTxRateStableTime; // # of second in current TX rate
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
-} WDS_TABLE_ENTRY, *PWDS_TABLE_ENTRY;
-
-typedef struct _RT_802_11_WDS_ENTRY {
- PNET_DEV dev;
- UCHAR Valid;
- UCHAR PhyMode;
- UCHAR PeerWdsAddr[MAC_ADDR_LEN];
- UCHAR MacTabMatchWCID; // ASIC
- NDIS_802_11_WEP_STATUS WepStatus;
- UCHAR KeyIdx;
- CIPHER_KEY WdsKey;
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- BOOLEAN bAutoTxRateSwitch;
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting.
-} RT_802_11_WDS_ENTRY, *PRT_802_11_WDS_ENTRY;
-
-typedef struct _WDS_TABLE {
- UCHAR Mode;
- ULONG Size;
- RT_802_11_WDS_ENTRY WdsEntry[MAX_WDS_ENTRY];
-} WDS_TABLE, *PWDS_TABLE;
-
-typedef struct _APCLI_STRUCT {
- PNET_DEV dev;
-#ifdef RTL865X_SOC
- unsigned int mylinkid;
-#endif
- BOOLEAN Enable; // Set it as 1 if the apcli interface was configured to "1" or by iwpriv cmd "ApCliEnable"
- BOOLEAN Valid; // Set it as 1 if the apcli interface associated success to remote AP.
- UCHAR MacTabWCID; //WCID value, which point to the entry of ASIC Mac table.
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
-
- UCHAR CfgSsidLen;
- CHAR CfgSsid[MAX_LEN_OF_SSID];
- UCHAR CfgApCliBssid[ETH_LENGTH_OF_ADDRESS];
- UCHAR CurrentAddress[ETH_LENGTH_OF_ADDRESS];
-
- ULONG ApCliRcvBeaconTime;
-
- ULONG CtrlCurrState;
- ULONG SyncCurrState;
- ULONG AuthCurrState;
- ULONG AssocCurrState;
- ULONG WpaPskCurrState;
-
- USHORT AuthReqCnt;
- USHORT AssocReqCnt;
-
- ULONG ClientStatusFlags;
- UCHAR MpduDensity;
-
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
-
- // Add to support different cipher suite for WPA2/WPA mode
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
- BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
- USHORT RsnCapability;
-
- UCHAR PSK[100]; // reserve PSK key material
- UCHAR PSKLen;
- UCHAR PMK[32]; // WPA PSK mode PMK
- //UCHAR PTK[64]; // WPA PSK mode PTK
- UCHAR GTK[32]; // GTK from authenticator
-
- //CIPHER_KEY PairwiseKey;
- CIPHER_KEY SharedKey[SHARE_KEY_NUM];
- UCHAR DefaultKeyId;
-
- // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
- //UCHAR PortSecured;
-
- // store RSN_IE built by driver
- UCHAR RSN_IE[MAX_LEN_OF_RSNIE]; // The content saved here should be convert to little-endian format.
- UCHAR RSNIE_Len;
-
- // For WPA countermeasures
- ULONG LastMicErrorTime; // record last MIC error time
- //ULONG MicErrCnt; // Should be 0, 1, 2, then reset to zero (after disassoiciation).
- BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
-
- // For WPA-PSK supplicant state
- //WPA_STATE WpaState; // Default is SS_NOTUSE
- //UCHAR ReplayCounter[8];
- //UCHAR ANonce[32]; // ANonce for WPA-PSK from authenticator
- UCHAR SNonce[32]; // SNonce for WPA-PSK
- UCHAR GNonce[32]; // GNonce for WPA-PSK from authenticator
-
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- BOOLEAN bAutoTxRateSwitch;
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting.
-} APCLI_STRUCT, *PAPCLI_STRUCT;
-
-// ----------- end of AP ----------------------------
-
-#ifdef BLOCK_NET_IF
-typedef struct _BLOCK_QUEUE_ENTRY
-{
- BOOLEAN SwTxQueueBlockFlag;
- LIST_HEADER NetIfList;
-} BLOCK_QUEUE_ENTRY, *PBLOCK_QUEUE_ENTRY;
-#endif // BLOCK_NET_IF //
-
-struct wificonf
-{
- BOOLEAN bShortGI;
- BOOLEAN bGreenField;
-};
-
-
-
-typedef struct _INF_PCI_CONFIG
-{
- PUCHAR CSRBaseAddress; // PCI MMIO Base Address, all access will use
-}INF_PCI_CONFIG;
-
-typedef struct _INF_USB_CONFIG
-{
- UINT BulkInEpAddr; // bulk-in endpoint address
- UINT BulkOutEpAddr[6]; // bulk-out endpoint address
-
-}INF_USB_CONFIG;
-
-#ifdef IKANOS_VX_1X0
- typedef void (*IkanosWlanTxCbFuncP)(void *, void *);
-
- struct IKANOS_TX_INFO
- {
- struct net_device *netdev;
- IkanosWlanTxCbFuncP *fp;
- };
-#endif // IKANOS_VX_1X0 //
-
-#ifdef NINTENDO_AP
-typedef struct _NINDO_CTRL_BLOCK {
-
- RT_NINTENDO_TABLE DS_TABLE;
-
-#ifdef CHIP25XX
- spinlock_t NINTENDO_TABLE_Lock;
-#else
- NDIS_SPIN_LOCK NINTENDO_TABLE_Lock;
-#endif // CHIP25XX //
-
- UCHAR NINTENDO_UP_BUFFER[512];
- UCHAR Local_KeyIdx;
- CIPHER_KEY Local_SharedKey;
- UCHAR Local_bHideSsid;
- UCHAR Local_AuthMode;
- UCHAR Local_WepStatus;
- USHORT Local_CapabilityInfo;
-} NINDO_CTRL_BLOCK;
-#endif // NINTENDO_AP //
-
-
-#ifdef DBG_DIAGNOSE
-#define DIAGNOSE_TIME 10 // 10 sec
-typedef struct _RtmpDiagStrcut_
-{ // Diagnosis Related element
- unsigned char inited;
- unsigned char qIdx;
- unsigned char ArrayStartIdx;
- unsigned char ArrayCurIdx;
- // Tx Related Count
- USHORT TxDataCnt[DIAGNOSE_TIME];
- USHORT TxFailCnt[DIAGNOSE_TIME];
-// USHORT TxDescCnt[DIAGNOSE_TIME][16]; // TxDesc queue length in scale of 0~14, >=15
- USHORT TxDescCnt[DIAGNOSE_TIME][24]; // 3*3 // TxDesc queue length in scale of 0~14, >=15
-// USHORT TxMcsCnt[DIAGNOSE_TIME][16]; // TxDate MCS Count in range from 0 to 15, step in 1.
- USHORT TxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
- USHORT TxSWQueCnt[DIAGNOSE_TIME][9]; // TxSwQueue length in scale of 0, 1, 2, 3, 4, 5, 6, 7, >=8
-
- USHORT TxAggCnt[DIAGNOSE_TIME];
- USHORT TxNonAggCnt[DIAGNOSE_TIME];
-// USHORT TxAMPDUCnt[DIAGNOSE_TIME][16]; // 10 sec, TxDMA APMDU Aggregation count in range from 0 to 15, in setp of 1.
- USHORT TxAMPDUCnt[DIAGNOSE_TIME][24]; // 3*3 // 10 sec, TxDMA APMDU Aggregation count in range from 0 to 15, in setp of 1.
- USHORT TxRalinkCnt[DIAGNOSE_TIME]; // TxRalink Aggregation Count in 1 sec scale.
- USHORT TxAMSDUCnt[DIAGNOSE_TIME]; // TxAMSUD Aggregation Count in 1 sec scale.
-
- // Rx Related Count
- USHORT RxDataCnt[DIAGNOSE_TIME]; // Rx Total Data count.
- USHORT RxCrcErrCnt[DIAGNOSE_TIME];
-// USHORT RxMcsCnt[DIAGNOSE_TIME][16]; // Rx MCS Count in range from 0 to 15, step in 1.
- USHORT RxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
-}RtmpDiagStruct;
-#endif // DBG_DIAGNOSE //
-
-
-//
-// The miniport adapter structure
-//
-typedef struct _RTMP_ADAPTER
-{
- PVOID OS_Cookie; // save specific structure relative to OS
- PNET_DEV net_dev;
- ULONG VirtualIfCnt;
-
-
-
- NDIS_SPIN_LOCK irq_lock;
- UCHAR irq_disabled;
-
-#ifdef RT2870
-/*****************************************************************************************/
-/* USB related parameters */
-/*****************************************************************************************/
- struct usb_config_descriptor *config;
- UINT BulkInEpAddr; // bulk-in endpoint address
- UINT BulkOutEpAddr[6]; // bulk-out endpoint address
-
- UINT NumberOfPipes;
- USHORT BulkOutMaxPacketSize;
- USHORT BulkInMaxPacketSize;
-
- //======Control Flags
- LONG PendingIoCount;
- ULONG BulkFlags;
- BOOLEAN bUsbTxBulkAggre; // Flags for bulk out data priority
-
-
- //======Timer Thread
- RT2870_TIMER_QUEUE TimerQ;
- NDIS_SPIN_LOCK TimerQLock;
-
-
- //======Cmd Thread
- CmdQ CmdQ;
- NDIS_SPIN_LOCK CmdQLock; // CmdQLock spinlock
-
- BOOLEAN TimerFunc_kill;
- BOOLEAN mlme_kill;
-
-
- //======Semaphores (event)
- struct semaphore mlme_semaphore; /* to sleep thread on */
- struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */
- struct semaphore RTUSBTimer_semaphore;
-#ifdef INF_AMAZON_SE
- struct semaphore UsbVendorReq_semaphore;
- PVOID UsbVendorReqBuf;
-#endif // INF_AMAZON_SE //
- struct completion TimerQComplete;
- struct completion mlmeComplete;
- struct completion CmdQComplete;
- wait_queue_head_t *wait;
-
- //======Lock for 2870 ATE
-#ifdef RALINK_ATE
- NDIS_SPIN_LOCK GenericLock; // ATE Tx/Rx generic spinlock
-#endif // RALINK_ATE //
-
-#endif // RT2870 //
-
-
-/*****************************************************************************************/
- /* Both PCI/USB related parameters */
-/*****************************************************************************************/
-
-
-/*****************************************************************************************/
-/* Tx related parameters */
-/*****************************************************************************************/
- BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; // for ensuring RTUSBDeQueuePacket get call once
- NDIS_SPIN_LOCK DeQueueLock[NUM_OF_TX_RING];
-
-#ifdef RT2870
- // Data related context and AC specified, 4 AC supported
- NDIS_SPIN_LOCK BulkOutLock[6]; // BulkOut spinlock for 4 ACs
- NDIS_SPIN_LOCK MLMEBulkOutLock; // MLME BulkOut lock
-
- HT_TX_CONTEXT TxContext[NUM_OF_TX_RING];
- NDIS_SPIN_LOCK TxContextQueueLock[NUM_OF_TX_RING]; // TxContextQueue spinlock
-
- // 4 sets of Bulk Out index and pending flag
- UCHAR NextBulkOutIndex[4]; // only used for 4 EDCA bulkout pipe
-
- BOOLEAN BulkOutPending[6]; // used for total 6 bulkout pipe
- UCHAR bulkResetPipeid;
- BOOLEAN MgmtBulkPending;
- ULONG bulkResetReq[6];
-#endif // RT2870 //
-
- // resource for software backlog queues
- QUEUE_HEADER TxSwQueue[NUM_OF_TX_RING]; // 4 AC + 1 HCCA
- NDIS_SPIN_LOCK TxSwQueueLock[NUM_OF_TX_RING]; // TxSwQueue spinlock
-
- RTMP_DMABUF MgmtDescRing; // Shared memory for MGMT descriptors
- RTMP_MGMT_RING MgmtRing;
- NDIS_SPIN_LOCK MgmtRingLock; // Prio Ring spinlock
-
-
-/*****************************************************************************************/
-/* Rx related parameters */
-/*****************************************************************************************/
-
-
-#ifdef RT2870
- RX_CONTEXT RxContext[RX_RING_SIZE]; // 1 for redundant multiple IRP bulk in.
- NDIS_SPIN_LOCK BulkInLock; // BulkIn spinlock for 4 ACs
- UCHAR PendingRx; // The Maxima pending Rx value should be RX_RING_SIZE.
- UCHAR NextRxBulkInIndex; // Indicate the current RxContext Index which hold by Host controller.
- UCHAR NextRxBulkInReadIndex; // Indicate the current RxContext Index which driver can read & process it.
- ULONG NextRxBulkInPosition; // Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength.
- ULONG TransferBufferLength; // current length of the packet buffer
- ULONG ReadPosition; // current read position in a packet buffer
-#endif // RT2870 //
-
-
-/*****************************************************************************************/
-/* ASIC related parameters */
-/*****************************************************************************************/
- UINT32 MACVersion; // MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101)..
-
- // ---------------------------
- // E2PROM
- // ---------------------------
- ULONG EepromVersion; // byte 0: version, byte 1: revision, byte 2~3: unused
- UCHAR EEPROMAddressNum; // 93c46=6 93c66=8
- USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
- ULONG FirmwareVersion; // byte 0: Minor version, byte 1: Major version, otherwise unused.
-
- // ---------------------------
- // BBP Control
- // ---------------------------
- UCHAR BbpWriteLatch[140]; // record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID
- UCHAR BbpRssiToDbmDelta;
- BBP_R66_TUNING BbpTuning;
-
- // ----------------------------
- // RFIC control
- // ----------------------------
- UCHAR RfIcType; // RFIC_xxx
- ULONG RfFreqOffset; // Frequency offset for channel switching
- RTMP_RF_REGS LatchRfRegs; // latch th latest RF programming value since RF IC doesn't support READ
-
- EEPROM_ANTENNA_STRUC Antenna; // Since ANtenna definition is different for a & g. We need to save it for future reference.
- EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-
- // This soft Rx Antenna Diversity mechanism is used only when user set
- // RX Antenna = DIVERSITY ON
- SOFT_RX_ANT_DIVERSITY RxAnt;
-
- UCHAR RFProgSeq;
- CHANNEL_TX_POWER TxPower[MAX_NUM_OF_CHANNELS]; // Store Tx power value for all channels.
- CHANNEL_TX_POWER ChannelList[MAX_NUM_OF_CHANNELS]; // list all supported channels for site survey
- CHANNEL_11J_TX_POWER TxPower11J[MAX_NUM_OF_11JCHANNELS]; // 802.11j channel and bw
- CHANNEL_11J_TX_POWER ChannelList11J[MAX_NUM_OF_11JCHANNELS]; // list all supported channels for site survey
-
- UCHAR ChannelListNum; // number of channel in ChannelList[]
- UCHAR Bbp94;
- BOOLEAN BbpForCCK;
- ULONG Tx20MPwrCfgABand[5];
- ULONG Tx20MPwrCfgGBand[5];
- ULONG Tx40MPwrCfgABand[5];
- ULONG Tx40MPwrCfgGBand[5];
-
- BOOLEAN bAutoTxAgcA; // Enable driver auto Tx Agc control
- UCHAR TssiRefA; // Store Tssi reference value as 25 temperature.
- UCHAR TssiPlusBoundaryA[5]; // Tssi boundary for increase Tx power to compensate.
- UCHAR TssiMinusBoundaryA[5]; // Tssi boundary for decrease Tx power to compensate.
- UCHAR TxAgcStepA; // Store Tx TSSI delta increment / decrement value
- CHAR TxAgcCompensateA; // Store the compensation (TxAgcStep * (idx-1))
-
- BOOLEAN bAutoTxAgcG; // Enable driver auto Tx Agc control
- UCHAR TssiRefG; // Store Tssi reference value as 25 temperature.
- UCHAR TssiPlusBoundaryG[5]; // Tssi boundary for increase Tx power to compensate.
- UCHAR TssiMinusBoundaryG[5]; // Tssi boundary for decrease Tx power to compensate.
- UCHAR TxAgcStepG; // Store Tx TSSI delta increment / decrement value
- CHAR TxAgcCompensateG; // Store the compensation (TxAgcStep * (idx-1))
-
- //+++For RT2870, the parameteres is start from BGRssiOffset1 ~ BGRssiOffset3
- CHAR BGRssiOffset0; // Store B/G RSSI#0 Offset value on EEPROM 0x46h
- CHAR BGRssiOffset1; // Store B/G RSSI#1 Offset value
- CHAR BGRssiOffset2; // Store B/G RSSI#2 Offset value
- //---
-
- //+++For RT2870, the parameteres is start from ARssiOffset1 ~ ARssiOffset3
- CHAR ARssiOffset0; // Store A RSSI#0 Offset value on EEPROM 0x4Ah
- CHAR ARssiOffset1; // Store A RSSI#1 Offset value
- CHAR ARssiOffset2; // Store A RSSI#2 Offset value
- //---
-
- CHAR BLNAGain; // Store B/G external LNA#0 value on EEPROM 0x44h
- CHAR ALNAGain0; // Store A external LNA#0 value for ch36~64
- CHAR ALNAGain1; // Store A external LNA#1 value for ch100~128
- CHAR ALNAGain2; // Store A external LNA#2 value for ch132~165
-
- // ----------------------------
- // LED control
- // ----------------------------
- MCU_LEDCS_STRUC LedCntl;
- USHORT Led1; // read from EEPROM 0x3c
- USHORT Led2; // EEPROM 0x3e
- USHORT Led3; // EEPROM 0x40
- UCHAR LedIndicatorStregth;
- UCHAR RssiSingalstrengthOffet;
- BOOLEAN bLedOnScanning;
- UCHAR LedStatus;
-
-/*****************************************************************************************/
-/* 802.11 related parameters */
-/*****************************************************************************************/
- // outgoing BEACON frame buffer and corresponding TXD
- TXWI_STRUC BeaconTxWI;
- PUCHAR BeaconBuf;
- USHORT BeaconOffset[HW_BEACON_MAX_COUNT];
-
- // pre-build PS-POLL and NULL frame upon link up. for efficiency purpose.
- PSPOLL_FRAME PsPollFrame;
- HEADER_802_11 NullFrame;
-
-#ifdef RT2870
- TX_CONTEXT BeaconContext[BEACON_RING_SIZE];
- TX_CONTEXT NullContext;
- TX_CONTEXT PsPollContext;
- TX_CONTEXT RTSContext;
-#endif // RT2870 //
-
-
-
-//=========AP===========
-
-
-//=======STA===========
-#ifdef CONFIG_STA_SUPPORT
-/* Modified by Wu Xi-Kun 4/21/2006 */
- // -----------------------------------------------
- // STA specific configuration & operation status
- // used only when pAd->OpMode == OPMODE_STA
- // -----------------------------------------------
- STA_ADMIN_CONFIG StaCfg; // user desired settings
- STA_ACTIVE_CONFIG StaActive; // valid only when ADHOC_ON(pAd) || INFRA_ON(pAd)
- CHAR nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
- NDIS_MEDIA_STATE PreMediaState;
-#endif // CONFIG_STA_SUPPORT //
-
-//=======Common===========
- // OP mode: either AP or STA
- UCHAR OpMode; // OPMODE_STA, OPMODE_AP
-
- NDIS_MEDIA_STATE IndicateMediaState; // Base on Indication state, default is NdisMediaStateDisConnected
-
-
- // configuration: read from Registry & E2PROM
- BOOLEAN bLocalAdminMAC; // Use user changed MAC
- UCHAR PermanentAddress[MAC_ADDR_LEN]; // Factory default MAC address
- UCHAR CurrentAddress[MAC_ADDR_LEN]; // User changed MAC address
-
- // ------------------------------------------------------
- // common configuration to both OPMODE_STA and OPMODE_AP
- // ------------------------------------------------------
- COMMON_CONFIG CommonCfg;
- MLME_STRUCT Mlme;
-
- // AP needs those vaiables for site survey feature.
- MLME_AUX MlmeAux; // temporary settings used during MLME state machine
- BSS_TABLE ScanTab; // store the latest SCAN result
-
- //About MacTab, the sta driver will use #0 and #1 for multicast and AP.
- MAC_TABLE MacTab; // ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table.
- NDIS_SPIN_LOCK MacTabLock;
-
-#ifdef DOT11_N_SUPPORT
- BA_TABLE BATable;
-#endif // DOT11_N_SUPPORT //
- NDIS_SPIN_LOCK BATabLock;
- RALINK_TIMER_STRUCT RECBATimer;
-
- // encryption/decryption KEY tables
- CIPHER_KEY SharedKey[MAX_MBSSID_NUM][4]; // STA always use SharedKey[BSS0][0..3]
-
- // RX re-assembly buffer for fragmentation
- FRAGMENT_FRAME FragFrame; // Frame storage for fragment frame
-
- // various Counters
- COUNTER_802_3 Counters8023; // 802.3 counters
- COUNTER_802_11 WlanCounters; // 802.11 MIB counters
- COUNTER_RALINK RalinkCounters; // Ralink propriety counters
- COUNTER_DRS DrsCounters; // counters for Dynamic TX Rate Switching
- PRIVATE_STRUC PrivateInfo; // Private information & counters
-
- // flags, see fRTMP_ADAPTER_xxx flags
- ULONG Flags; // Represent current device status
-
- // current TX sequence #
- USHORT Sequence;
-
- // Control disconnect / connect event generation
- //+++Didn't used anymore
- ULONG LinkDownTime;
- //---
- ULONG LastRxRate;
- ULONG LastTxRate;
- //+++Used only for Station
- BOOLEAN bConfigChanged; // Config Change flag for the same SSID setting
- //---
-
- ULONG ExtraInfo; // Extra information for displaying status
- ULONG SystemErrorBitmap; // b0: E2PROM version error
-
- //+++Didn't used anymore
- ULONG MacIcVersion; // MAC/BBP serial interface issue solved after ver.D
- //---
-
- // ---------------------------
- // System event log
- // ---------------------------
- RT_802_11_EVENT_TABLE EventTab;
-
-
- BOOLEAN HTCEnable;
-
- /*****************************************************************************************/
- /* Statistic related parameters */
- /*****************************************************************************************/
-#ifdef RT2870
- ULONG BulkOutDataOneSecCount;
- ULONG BulkInDataOneSecCount;
- ULONG BulkLastOneSecCount; // BulkOutDataOneSecCount + BulkInDataOneSecCount
- ULONG watchDogRxCnt;
- ULONG watchDogRxOverFlowCnt;
- ULONG watchDogTxPendingCnt[NUM_OF_TX_RING];
-#endif // RT2870 //
-
- BOOLEAN bUpdateBcnCntDone;
- ULONG watchDogMacDeadlock; // prevent MAC/BBP into deadlock condition
- // ----------------------------
- // DEBUG paramerts
- // ----------------------------
- //ULONG DebugSetting[4];
- BOOLEAN bBanAllBaSetup;
- BOOLEAN bPromiscuous;
-
- // ----------------------------
- // rt2860c emulation-use Parameters
- // ----------------------------
- ULONG rtsaccu[30];
- ULONG ctsaccu[30];
- ULONG cfendaccu[30];
- ULONG bacontent[16];
- ULONG rxint[RX_RING_SIZE+1];
- UCHAR rcvba[60];
- BOOLEAN bLinkAdapt;
- BOOLEAN bForcePrintTX;
- BOOLEAN bForcePrintRX;
- BOOLEAN bDisablescanning; //defined in RT2870 USB
- BOOLEAN bStaFifoTest;
- BOOLEAN bProtectionTest;
- BOOLEAN bHCCATest;
- BOOLEAN bGenOneHCCA;
- BOOLEAN bBroadComHT;
- //+++Following add from RT2870 USB.
- ULONG BulkOutReq;
- ULONG BulkOutComplete;
- ULONG BulkOutCompleteOther;
- ULONG BulkOutCompleteCancel; // seems not use now?
- ULONG BulkInReq;
- ULONG BulkInComplete;
- ULONG BulkInCompleteFail;
- //---
-
- struct wificonf WIFItestbed;
-
-#ifdef RALINK_ATE
- ATE_INFO ate;
-#ifdef RT2870
- BOOLEAN ContinBulkOut; //ATE bulk out control
- BOOLEAN ContinBulkIn; //ATE bulk in control
- atomic_t BulkOutRemained;
- atomic_t BulkInRemained;
-#endif // RT2870 //
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
- struct reordering_mpdu_pool mpdu_blk_pool;
-#endif // DOT11_N_SUPPORT //
-
- ULONG OneSecondnonBEpackets; // record non BE packets per second
-
-#if WIRELESS_EXT >= 12
- struct iw_statistics iw_stats;
-#endif
-
- struct net_device_stats stats;
-
-#ifdef BLOCK_NET_IF
- BLOCK_QUEUE_ENTRY blockQueueTab[NUM_OF_TX_RING];
-#endif // BLOCK_NET_IF //
-
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
- INT32 MC_RowID;
- UCHAR MC_FileName[256];
-#endif // MULTIPLE_CARD_SUPPORT //
-
- ULONG TbttTickCount;
-#ifdef PCI_MSI_SUPPORT
- BOOLEAN HaveMsi;
-#endif // PCI_MSI_SUPPORT //
-
-
- UCHAR is_on;
-
-#define TIME_BASE (1000000/OS_HZ)
-#define TIME_ONE_SECOND (1000000/TIME_BASE)
- UCHAR flg_be_adjust;
- ULONG be_adjust_last_time;
-
-
-#ifdef IKANOS_VX_1X0
- struct IKANOS_TX_INFO IkanosTxInfo;
- struct IKANOS_TX_INFO IkanosRxInfo[MAX_MBSSID_NUM + MAX_WDS_ENTRY + MAX_APCLI_NUM + MAX_MESH_NUM];
-#endif // IKANOS_VX_1X0 //
-
-
-#ifdef DBG_DIAGNOSE
- RtmpDiagStruct DiagStruct;
-#endif // DBG_DIAGNOSE //
-
-
- UINT8 PM_FlgSuspend;
-} RTMP_ADAPTER, *PRTMP_ADAPTER;
-
-//
-// Cisco IAPP format
-//
-typedef struct _CISCO_IAPP_CONTENT_
-{
- USHORT Length; //IAPP Length
- UCHAR MessageType; //IAPP type
- UCHAR FunctionCode; //IAPP function type
- UCHAR DestinaionMAC[MAC_ADDR_LEN];
- UCHAR SourceMAC[MAC_ADDR_LEN];
- USHORT Tag; //Tag(element IE) - Adjacent AP report
- USHORT TagLength; //Length of element not including 4 byte header
- UCHAR OUI[4]; //0x00, 0x40, 0x96, 0x00
- UCHAR PreviousAP[MAC_ADDR_LEN]; //MAC Address of access point
- USHORT Channel;
- USHORT SsidLen;
- UCHAR Ssid[MAX_LEN_OF_SSID];
- USHORT Seconds; //Seconds that the client has been disassociated.
-} CISCO_IAPP_CONTENT, *PCISCO_IAPP_CONTENT;
-
-#define DELAYINTMASK 0x0003fffb
-#define INTMASK 0x0003fffb
-#define IndMask 0x0003fffc
-#define RxINT 0x00000005 // Delayed Rx or indivi rx
-#define TxDataInt 0x000000fa // Delayed Tx or indivi tx
-#define TxMgmtInt 0x00000102 // Delayed Tx or indivi tx
-#define TxCoherent 0x00020000 // tx coherent
-#define RxCoherent 0x00010000 // rx coherent
-#define McuCommand 0x00000200 // mcu
-#define PreTBTTInt 0x00001000 // Pre-TBTT interrupt
-#define TBTTInt 0x00000800 // TBTT interrupt
-#define GPTimeOutInt 0x00008000 // GPtimeout interrupt
-#define AutoWakeupInt 0x00004000 // AutoWakeupInt interrupt
-#define FifoStaFullInt 0x00002000 // fifo statistics full interrupt
-
-
-typedef struct _RX_BLK_
-{
-// RXD_STRUC RxD; // sample
- RT28XX_RXD_STRUC RxD;
- PRXWI_STRUC pRxWI;
- PHEADER_802_11 pHeader;
- PNDIS_PACKET pRxPacket;
- UCHAR *pData;
- USHORT DataSize;
- USHORT Flags;
- UCHAR UserPriority; // for calculate TKIP MIC using
-} RX_BLK;
-
-
-#define RX_BLK_SET_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags |= _flag)
-#define RX_BLK_TEST_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags & _flag)
-#define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags &= ~(_flag))
-
-
-#define fRX_WDS 0x0001
-#define fRX_AMSDU 0x0002
-#define fRX_ARALINK 0x0004
-#define fRX_HTC 0x0008
-#define fRX_PAD 0x0010
-#define fRX_AMPDU 0x0020
-#define fRX_QOS 0x0040
-#define fRX_INFRA 0x0080
-#define fRX_EAP 0x0100
-#define fRX_MESH 0x0200
-#define fRX_APCLI 0x0400
-#define fRX_DLS 0x0800
-#define fRX_WPI 0x1000
-
-#define LENGTH_AMSDU_SUBFRAMEHEAD 14
-#define LENGTH_ARALINK_SUBFRAMEHEAD 14
-#define LENGTH_ARALINK_HEADER_FIELD 2
-
-#define TX_UNKOWN_FRAME 0x00
-#define TX_MCAST_FRAME 0x01
-#define TX_LEGACY_FRAME 0x02
-#define TX_AMPDU_FRAME 0x04
-#define TX_AMSDU_FRAME 0x08
-#define TX_RALINK_FRAME 0x10
-#define TX_FRAG_FRAME 0x20
-
-
-// Currently the sizeof(TX_BLK) is 148 bytes.
-typedef struct _TX_BLK_
-{
- UCHAR QueIdx;
- UCHAR TxFrameType; // Indicate the Transmission type of the all frames in one batch
- UCHAR TotalFrameNum; // Total frame number want to send-out in one batch
- USHORT TotalFragNum; // Total frame fragments required in one batch
- USHORT TotalFrameLen; // Total length of all frames want to send-out in one batch
-
- QUEUE_HEADER TxPacketList;
- MAC_TABLE_ENTRY *pMacEntry; // NULL: packet with 802.11 RA field is multicast/broadcast address
- HTTRANSMIT_SETTING *pTransmit;
-
- // Following structure used for the characteristics of a specific packet.
- PNDIS_PACKET pPacket;
- PUCHAR pSrcBufHeader; // Reference to the head of sk_buff->data
- PUCHAR pSrcBufData; // Reference to the sk_buff->data, will changed depends on hanlding progresss
- UINT SrcBufLen; // Length of packet payload which not including Layer 2 header
- PUCHAR pExtraLlcSnapEncap; // NULL means no extra LLC/SNAP is required
- UCHAR HeaderBuf[80]; // TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP
- UCHAR MpduHeaderLen; // 802.11 header length NOT including the padding
- UCHAR HdrPadLen; // recording Header Padding Length;
- UCHAR apidx; // The interface associated to this packet
- UCHAR Wcid; // The MAC entry associated to this packet
- UCHAR UserPriority; // priority class of packet
- UCHAR FrameGap; // what kind of IFS this packet use
- UCHAR MpduReqNum; // number of fragments of this frame
- UCHAR TxRate; // TODO: Obsoleted? Should change to MCS?
- UCHAR CipherAlg; // cipher alogrithm
- PCIPHER_KEY pKey;
-
-
-
- USHORT Flags; //See following definitions for detail.
-
- //YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer.
- ULONG Priv; // Hardware specific value saved in here.
-} TX_BLK, *PTX_BLK;
-
-
-#define fTX_bRtsRequired 0x0001 // Indicate if need send RTS frame for protection. Not used in RT2860/RT2870.
-#define fTX_bAckRequired 0x0002 // the packet need ack response
-#define fTX_bPiggyBack 0x0004 // Legacy device use Piggback or not
-#define fTX_bHTRate 0x0008 // allow to use HT rate
-//#define fTX_bForceLowRate 0x0010 // force to use Low Rate
-#define fTX_bForceNonQoS 0x0010 // force to transmit frame without WMM-QoS in HT mode
-#define fTX_bAllowFrag 0x0020 // allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment
-#define fTX_bMoreData 0x0040 // there are more data packets in PowerSave Queue
-#define fTX_bWMM 0x0080 // QOS Data
-
-#define fTX_bClearEAPFrame 0x0100
-
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
-
-
-#define TX_BLK_ASSIGN_FLAG(_pTxBlk, _flag, value) \
- do { \
- if (value) \
- (_pTxBlk->Flags |= _flag) \
- else \
- (_pTxBlk->Flags &= ~(_flag)) \
- }while(0)
-
-#define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
-#define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
-#define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags &= ~(_flag))
-
-
-
-
-
-//------------------------------------------------------------------------------------------
-
-
-
-#ifdef RT_BIG_ENDIAN
-static inline VOID WriteBackToDescriptor(
- IN PUCHAR Dest,
- IN PUCHAR Src,
- IN BOOLEAN DoEncrypt,
- IN ULONG DescriptorType)
-{
- UINT32 *p1, *p2;
-
- p1 = ((UINT32 *)Dest);
- p2 = ((UINT32 *)Src);
-
- *p1 = *p2;
- *(p1+2) = *(p2+2);
- *(p1+3) = *(p2+3);
- *(p1+1) = *(p2+1); // Word 1; this must be written back last
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of Tx/Rx descriptor .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to Tx/Rx descriptor
- DescriptorType Direction of the frame
-
- Return Value:
- None
-
- Note:
- Call this function when read or update descriptor
- ========================================================================
-*/
-static inline VOID RTMPWIEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType)
-{
- int size;
- int i;
-
- size = ((DescriptorType == TYPE_TXWI) ? TXWI_SIZE : RXWI_SIZE);
-
- if(DescriptorType == TYPE_TXWI)
- {
- *((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData))); // Byte 0~3
- *((UINT32 *)(pData + 4)) = SWAP32(*((UINT32 *)(pData+4))); // Byte 4~7
- }
- else
- {
- for(i=0; i < size/4 ; i++)
- *(((UINT32 *)pData) +i) = SWAP32(*(((UINT32 *)pData)+i));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of Tx/Rx descriptor .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to Tx/Rx descriptor
- DescriptorType Direction of the frame
-
- Return Value:
- None
-
- Note:
- Call this function when read or update descriptor
- ========================================================================
-*/
-
-#ifdef RT2870
-static inline VOID RTMPDescriptorEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType)
-{
- *((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData)));
-}
-#endif // RT2870 //
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of all kinds of 802.11 frames .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to the 802.11 frame structure
- Dir Direction of the frame
- FromRxDoneInt Caller is from RxDone interrupt
-
- Return Value:
- None
-
- Note:
- Call this function when read or update buffer data
- ========================================================================
-*/
-static inline VOID RTMPFrameEndianChange(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG Dir,
- IN BOOLEAN FromRxDoneInt)
-{
- PHEADER_802_11 pFrame;
- PUCHAR pMacHdr;
-
- // swab 16 bit fields - Frame Control field
- if(Dir == DIR_READ)
- {
- *(USHORT *)pData = SWAP16(*(USHORT *)pData);
- }
-
- pFrame = (PHEADER_802_11) pData;
- pMacHdr = (PUCHAR) pFrame;
-
- // swab 16 bit fields - Duration/ID field
- *(USHORT *)(pMacHdr + 2) = SWAP16(*(USHORT *)(pMacHdr + 2));
-
- // swab 16 bit fields - Sequence Control field
- *(USHORT *)(pMacHdr + 22) = SWAP16(*(USHORT *)(pMacHdr + 22));
-
- if(pFrame->FC.Type == BTYPE_MGMT)
- {
- switch(pFrame->FC.SubType)
- {
- case SUBTYPE_ASSOC_REQ:
- case SUBTYPE_REASSOC_REQ:
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Listen Interval field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_ASSOC_RSP:
- case SUBTYPE_REASSOC_RSP:
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Status Code field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - AID field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_AUTH:
- // If from APHandleRxDoneInterrupt routine, it is still a encrypt format.
- // The convertion is delayed to RTMPHandleDecryptionDoneInterrupt.
- if(!FromRxDoneInt && pFrame->FC.Wep == 1)
- break;
- else
- {
- // swab 16 bit fields - Auth Alg No. field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Auth Seq No. field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Status Code field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- }
- break;
-
- case SUBTYPE_BEACON:
- case SUBTYPE_PROBE_RSP:
- // swab 16 bit fields - BeaconInterval field
- pMacHdr += (sizeof(HEADER_802_11) + TIMESTAMP_LEN);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(USHORT);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_DEAUTH:
- case SUBTYPE_DISASSOC:
- // swab 16 bit fields - Reason code field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
- }
- }
- else if( pFrame->FC.Type == BTYPE_DATA )
- {
- }
- else if(pFrame->FC.Type == BTYPE_CNTL)
- {
- switch(pFrame->FC.SubType)
- {
- case SUBTYPE_BLOCK_ACK_REQ:
- {
- PFRAME_BA_REQ pBAReq = (PFRAME_BA_REQ)pFrame;
- *(USHORT *)(&pBAReq->BARControl) = SWAP16(*(USHORT *)(&pBAReq->BARControl));
- pBAReq->BAStartingSeq.word = SWAP16(pBAReq->BAStartingSeq.word);
- }
- break;
- case SUBTYPE_BLOCK_ACK:
- // For Block Ack packet, the HT_CONTROL field is in the same offset with Addr3
- *(UINT32 *)(&pFrame->Addr3[0]) = SWAP32(*(UINT32 *)(&pFrame->Addr3[0]));
- break;
-
- case SUBTYPE_ACK:
- //For ACK packet, the HT_CONTROL field is in the same offset with Addr2
- *(UINT32 *)(&pFrame->Addr2[0])= SWAP32(*(UINT32 *)(&pFrame->Addr2[0]));
- break;
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,("Invalid Frame Type!!!\n"));
- }
-
- // swab 16 bit fields - Frame Control
- if(Dir == DIR_WRITE)
- {
- *(USHORT *)pData = SWAP16(*(USHORT *)pData);
- }
-}
-#endif // RT_BIG_ENDIAN //
-
-
-static inline VOID ConvertMulticastIP2MAC(
- IN PUCHAR pIpAddr,
- IN PUCHAR *ppMacAddr,
- IN UINT16 ProtoType)
-{
- if (pIpAddr == NULL)
- return;
-
- if (ppMacAddr == NULL || *ppMacAddr == NULL)
- return;
-
- switch (ProtoType)
- {
- case ETH_P_IPV6:
-// memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
- *(*ppMacAddr) = 0x33;
- *(*ppMacAddr + 1) = 0x33;
- *(*ppMacAddr + 2) = pIpAddr[12];
- *(*ppMacAddr + 3) = pIpAddr[13];
- *(*ppMacAddr + 4) = pIpAddr[14];
- *(*ppMacAddr + 5) = pIpAddr[15];
- break;
-
- case ETH_P_IP:
- default:
-// memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
- *(*ppMacAddr) = 0x01;
- *(*ppMacAddr + 1) = 0x00;
- *(*ppMacAddr + 2) = 0x5e;
- *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
- *(*ppMacAddr + 4) = pIpAddr[2];
- *(*ppMacAddr + 5) = pIpAddr[3];
- break;
- }
-
- return;
-}
-
-BOOLEAN RTMPCheckForHang(
- IN NDIS_HANDLE MiniportAdapterContext
- );
-
-VOID RTMPHalt(
- IN NDIS_HANDLE MiniportAdapterContext
- );
-
-//
-// Private routines in rtmp_init.c
-//
-NDIS_STATUS RTMPAllocAdapterBlock(
- IN PVOID handle,
- OUT PRTMP_ADAPTER *ppAdapter
- );
-
-NDIS_STATUS RTMPAllocTxRxRingMemory(
- IN PRTMP_ADAPTER pAd
- );
-
-NDIS_STATUS RTMPFindAdapter(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_HANDLE WrapperConfigurationContext
- );
-
-NDIS_STATUS RTMPReadParametersHook(
- IN PRTMP_ADAPTER pAd
- );
-
-VOID RTMPFreeAdapter(
- IN PRTMP_ADAPTER pAd
- );
-
-NDIS_STATUS NICReadRegParameters(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_HANDLE WrapperConfigurationContext
- );
-
-#ifdef RT2870
-VOID NICInitRT30xxRFRegisters(
- IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-VOID NICReadEEPROMParameters(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mac_addr);
-
-VOID NICInitAsicFromEEPROM(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICInitTxRxRingAndBacklogQueue(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICInitializeAdapter(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset);
-
-NDIS_STATUS NICInitializeAsic(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset);
-
-VOID NICIssueReset(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPRingCleanUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RingType);
-
-VOID RxTest(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS DbgSendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-VOID UserCfgInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICResetFromError(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICEraseFirmware(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICLoadFirmware(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICLoadRateSwitchingParams(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN NICCheckForHang(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICUpdateFifoStaCounters(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICUpdateRawCounters(
- IN PRTMP_ADAPTER pAd);
-
-#if 0
-ULONG RTMPEqualMemory(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- IN ULONG Length);
-#endif
-
-ULONG RTMPNotAllZero(
- IN PVOID pSrc1,
- IN ULONG Length);
-
-VOID RTMPZeroMemory(
- IN PVOID pSrc,
- IN ULONG Length);
-
-ULONG RTMPCompareMemory(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- IN ULONG Length);
-
-VOID RTMPMoveMemory(
- OUT PVOID pDest,
- IN PVOID pSrc,
- IN ULONG Length);
-
-VOID AtoH(
- char *src,
- UCHAR *dest,
- int destlen);
-
-UCHAR BtoH(
- char ch);
-
-VOID RTMPPatchMacBbpBug(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPPatchCardBus(
- IN PRTMP_ADAPTER pAdapter);
-
-VOID RTMPPatchRalinkCardBus(
- IN PRTMP_ADAPTER pAdapter,
- IN ULONG Bus);
-
-ULONG RTMPReadCBConfig(
- IN ULONG Bus,
- IN ULONG Slot,
- IN ULONG Func,
- IN ULONG Offset);
-
-VOID RTMPWriteCBConfig(
- IN ULONG Bus,
- IN ULONG Slot,
- IN ULONG Func,
- IN ULONG Offset,
- IN ULONG Value);
-
-VOID RTMPInitTimer(
- IN PRTMP_ADAPTER pAd,
- IN PRALINK_TIMER_STRUCT pTimer,
- IN PVOID pTimerFunc,
- IN PVOID pData,
- IN BOOLEAN Repeat);
-
-VOID RTMPSetTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value);
-
-
-VOID RTMPModTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value);
-
-VOID RTMPCancelTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- OUT BOOLEAN *pCancelled);
-
-VOID RTMPSetLED(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Status);
-
-VOID RTMPSetSignalLED(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_802_11_RSSI Dbm);
-
-VOID RTMPEnableRxTx(
- IN PRTMP_ADAPTER pAd);
-
-//
-// prototype in action.c
-//
-VOID ActionStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeADDBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDELBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeInvalidAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef DOT11_N_SUPPORT
-VOID PeerAddBAReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAddBARspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDelBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // DOT11_N_SUPPORT //
-
-VOID SendPSMPAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Psmp);
-
-
-#ifdef DOT11N_DRAFT3
-VOID SendBSS2040CoexistMgmtAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx,
- IN UCHAR InfoReq);
-
-VOID SendNotifyBWActionFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx);
-
-BOOLEAN ChannelSwitchSanityCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary);
-
-VOID ChannelSwitchAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Channel,
- IN UCHAR Secondary);
-
-ULONG BuildIntolerantChannelRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest);
-
-VOID Update2040CoexistFrameAndNotify(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha);
-
-VOID Send2040CoexistAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha);
-#endif // DOT11N_DRAFT3 //
-
-VOID PeerRMAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID StaPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Bss2040Coexist);
-#endif // CONFIG_STA_SUPPORT //
-
-
-VOID PeerBSSTranAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef DOT11_N_SUPPORT
-VOID PeerHTAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // DOT11_N_SUPPORT //
-
-VOID PeerQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef QOS_DLS_SUPPORT
-VOID PeerDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-VOID DlsParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
- IN PRT_802_11_DLS pDls,
- IN USHORT reason);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
-VOID RECBATimerTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID ORIBATimerTimeout(
- IN PRTMP_ADAPTER pAd);
-
-VOID SendRefreshBAR(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry);
-#endif // DOT11_N_SUPPORT //
-
-VOID ActHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN PUCHAR Addr1,
- IN PUCHAR Addr2,
- IN PUCHAR Addr3);
-
-VOID BarHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PFRAME_BAR pCntlBar,
- IN PUCHAR pDA,
- IN PUCHAR pSA);
-
-VOID InsertActField(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 Category,
- IN UINT8 ActCode);
-
-BOOLEAN QosBADataParse(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bAMSDU,
- IN PUCHAR p8023Header,
- IN UCHAR WCID,
- IN UCHAR TID,
- IN USHORT Sequence,
- IN UCHAR DataOffset,
- IN USHORT Datasize,
- IN UINT CurRxIndex);
-
-#ifdef DOT11_N_SUPPORT
-BOOLEAN CntlEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG MsgLen,
- IN PFRAME_BA_REQ pMsg);
-
-VOID BaAutoManSwitch(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
-
-VOID HTIOTCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BatRecIdx);
-
-//
-// Private routines in rtmp_data.c
-//
-BOOLEAN RTMPHandleRxDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandleTxDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(
- IN PRTMP_ADAPTER pAd,
- IN INT_SOURCE_CSR_STRUC TxRingBitmap);
-
-VOID RTMPHandleMgmtRingDmaDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandleTBTTInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandlePreTBTTInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-void RTMPHandleTwakeupInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandleRxCoherentInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN TxFrameIsAggregatible(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pPrevAddr1,
- IN PUCHAR p8023hdr);
-
-BOOLEAN PeerIsAggreOn(
- IN PRTMP_ADAPTER pAd,
- IN ULONG TxRate,
- IN PMAC_TABLE_ENTRY pMacEntry);
-
-#if 0 // It's not be used
-HTTRANSMIT_SETTING *GetTxMode(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk);
-#endif
-
-NDIS_STATUS Sniff2BytesFromNdisBuffer(
- IN PNDIS_BUFFER pFirstBuffer,
- IN UCHAR DesiredOffset,
- OUT PUCHAR pByte0,
- OUT PUCHAR pByte1);
-
-NDIS_STATUS STASendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-VOID STASendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets);
-
-VOID RTMPDeQueuePacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bIntContext,
- IN UCHAR QueIdx,
- IN UCHAR Max_Tx_Packets);
-
-NDIS_STATUS RTMPHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR QueIdx,
- OUT PULONG pFreeTXDLeft);
-
-NDIS_STATUS STAHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx);
-
-VOID STARxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-NDIS_STATUS RTMPFreeTXDRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RingType,
- IN UCHAR NumberRequired,
- IN PUCHAR FreeNumberIs);
-
-NDIS_STATUS MlmeHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-NDIS_STATUS MlmeHardTransmitMgmtRing(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-NDIS_STATUS MlmeHardTransmitTxRing(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-USHORT RTMPCalcDuration(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Rate,
- IN ULONG Size);
-
-VOID RTMPWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN CFACK,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR TID,
- IN UCHAR TxRate,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING *pTransmit);
-
-
-VOID RTMPWriteTxWI_Data(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk);
-
-
-VOID RTMPWriteTxWI_Cache(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk);
-
-VOID RTMPWriteTxDescriptor(
- IN PRTMP_ADAPTER pAd,
- IN PTXD_STRUC pTxD,
- IN BOOLEAN bWIV,
- IN UCHAR QSEL);
-
-VOID RTMPSuspendMsduTransmission(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPResumeMsduTransmission(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS MiniportMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length);
-
-NDIS_STATUS MiniportDataMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length);
-
-VOID RTMPSendNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull);
-
-VOID RTMPSendDisassociationFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPSendRTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN unsigned int NextMpduSize,
- IN UCHAR TxRate,
- IN UCHAR RTSRate,
- IN USHORT AckDuration,
- IN UCHAR QueIdx,
- IN UCHAR FrameGap);
-
-
-NDIS_STATUS RTMPApplyPacketFilter(
- IN PRTMP_ADAPTER pAd,
- IN PRT28XX_RXD_STRUC pRxD,
- IN PHEADER_802_11 pHeader);
-
-PQUEUE_HEADER RTMPCheckTxSwQueue(
- IN PRTMP_ADAPTER pAd,
- OUT UCHAR *QueIdx);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPReportMicError(
- IN PRTMP_ADAPTER pAd,
- IN PCIPHER_KEY pWpaKey);
-
-VOID WpaMicFailureReportFrame(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaDisassocApAndBlockAssoc(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-#endif // CONFIG_STA_SUPPORT //
-
-NDIS_STATUS RTMPCloneNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN pInsAMSDUHdr,
- IN PNDIS_PACKET pInPacket,
- OUT PNDIS_PACKET *ppOutPacket);
-
-NDIS_STATUS RTMPAllocateNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET *pPacket,
- IN PUCHAR pHeader,
- IN UINT HeaderLen,
- IN PUCHAR pData,
- IN UINT DataLen);
-
-VOID RTMPFreeNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-BOOLEAN RTMPFreeTXDUponTxDmaDone(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx);
-
-BOOLEAN RTMPCheckDHCPFrame(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-BOOLEAN RTMPCheckEtherType(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-VOID RTMPCckBbpTuning(
- IN PRTMP_ADAPTER pAd,
- IN UINT TxRate);
-
-//
-// Private routines in rtmp_wep.c
-//
-VOID RTMPInitWepEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN UCHAR KeyId,
- IN UCHAR KeyLen,
- IN PUCHAR pDest);
-
-VOID RTMPEncryptData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDest,
- IN UINT Len);
-
-BOOLEAN RTMPDecryptData(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR pSrc,
- IN UINT Len,
- IN UINT idx);
-
-BOOLEAN RTMPSoftDecryptWEP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pGroupKey);
-
-VOID RTMPSetICV(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest);
-
-VOID ARCFOUR_INIT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pKey,
- IN UINT KeyLen);
-
-UCHAR ARCFOUR_BYTE(
- IN PARCFOURCONTEXT Ctx);
-
-VOID ARCFOUR_DECRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len);
-
-VOID ARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len);
-
-VOID WPAARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len);
-
-UINT RTMP_CALC_FCS32(
- IN UINT Fcs,
- IN PUCHAR Cp,
- IN INT Len);
-
-//
-// MLME routines
-//
-
-// Asic/RF/BBP related functions
-
-VOID AsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicUpdateProtect(
- IN PRTMP_ADAPTER pAd,
- IN USHORT OperaionMode,
- IN UCHAR SetMask,
- IN BOOLEAN bDisableBGProtect,
- IN BOOLEAN bNonGFExist);
-
-VOID AsicSwitchChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel,
- IN BOOLEAN bScan);
-
-VOID AsicLockChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel) ;
-
-VOID AsicAntennaSelect(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel);
-
-VOID AsicAntennaSetting(
- IN PRTMP_ADAPTER pAd,
- IN ABGBAND_STATE BandState);
-
-VOID AsicRfTuningExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID AsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp);
-
-VOID AsicForceSleep(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx);
-#endif // CONFIG_STA_SUPPORT //
-
-VOID AsicSetBssid(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid);
-
-VOID AsicSetMcastWC(
- IN PRTMP_ADAPTER pAd);
-
-#if 0 // removed by AlbertY
-VOID AsicSetBssidWC(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid);
-#endif
-
-VOID AsicDelWcidTab(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid);
-
-VOID AsicEnableRDG(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicDisableRDG(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicDisableSync(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicEnableBssSync(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicEnableIbssSync(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicSetEdcaParm(
- IN PRTMP_ADAPTER pAd,
- IN PEDCA_PARM pEdcaParm);
-
-VOID AsicSetSlotTime(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUseShortSlotTime);
-
-#if 0
-VOID AsicAddWcidCipherEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR WCID,
- IN UCHAR BssIndex,
- IN UCHAR KeyTable,
- IN UCHAR CipherAlg,
- IN PUCHAR pAddr,
- IN CIPHER_KEY *pCipherKey);
-#endif
-
-VOID AsicAddSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN PUCHAR pKey,
- IN PUCHAR pTxMic,
- IN PUCHAR pRxMic);
-
-VOID AsicRemoveSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx);
-
-VOID AsicUpdateWCIDAttribute(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR CipherAlg,
- IN BOOLEAN bUsePairewiseKeyTable);
-
-VOID AsicUpdateWCIDIVEIV(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN ULONG uIV,
- IN ULONG uEIV);
-
-VOID AsicUpdateRxWCIDTable(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN PUCHAR pAddr);
-
-VOID AsicAddKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN PCIPHER_KEY pCipherKey,
- IN BOOLEAN bUsePairewiseKeyTable,
- IN BOOLEAN bTxKey);
-
-VOID AsicAddPairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR WCID,
- IN CIPHER_KEY *pCipherKey);
-
-VOID AsicRemovePairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR Wcid);
-
-BOOLEAN AsicSendCommandToMcu(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Command,
- IN UCHAR Token,
- IN UCHAR Arg0,
- IN UCHAR Arg1);
-
-
-VOID MacAddrRandomBssid(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pAddr);
-
-VOID MgtMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR SubType,
- IN UCHAR ToDs,
- IN PUCHAR pDA,
- IN PUCHAR pBssid);
-
-VOID MlmeRadioOff(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeRadioOn(
- IN PRTMP_ADAPTER pAd);
-
-
-VOID BssTableInit(
- IN BSS_TABLE *Tab);
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableInit(
- IN PRTMP_ADAPTER pAd,
- IN BA_TABLE *Tab);
-#endif // DOT11_N_SUPPORT //
-
-ULONG BssTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN UCHAR Channel);
-
-ULONG BssSsidTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel);
-
-ULONG BssTableSearchWithSSID(
- IN BSS_TABLE *Tab,
- IN PUCHAR Bssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel);
-
-VOID BssTableDeleteEntry(
- IN OUT PBSS_TABLE pTab,
- IN PUCHAR pBssid,
- IN UCHAR Channel);
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableDeleteORIEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN BA_ORI_ENTRY *pBAORIEntry);
-
-VOID BATableDeleteRECEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN BA_REC_ENTRY *pBARECEntry);
-
-VOID BATableTearORIEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR TID,
- IN UCHAR Wcid,
- IN BOOLEAN bForceDelete,
- IN BOOLEAN ALL);
-
-VOID BATableTearRECEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR TID,
- IN UCHAR WCID,
- IN BOOLEAN ALL);
-#endif // DOT11_N_SUPPORT //
-
-VOID BssEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT PBSS_ENTRY pBss,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN PCF_PARM CfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR Channel,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE);
-
-ULONG BssTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT PBSS_TABLE pTab,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN CF_PARM *CfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR Channel,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE);
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Aid,
- IN USHORT TimeOutValue,
- IN USHORT StartingSeq,
- IN UCHAR TID,
- IN UCHAR BAWinSize,
- IN UCHAR OriginatorStatus,
- IN BOOLEAN IsRecipient);
-
-#ifdef DOT11N_DRAFT3
-VOID Bss2040CoexistTimeOut(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-
-VOID TriEventInit(
- IN PRTMP_ADAPTER pAd);
-
-ULONG TriEventTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT TRIGGER_EVENT_TAB *Tab,
- IN PUCHAR pBssid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN UCHAR RegClass,
- IN UCHAR ChannelNo);
-
-VOID TriEventCounterMaintenance(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-VOID BssTableSsidSort(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_TABLE *OutTab,
- IN CHAR Ssid[],
- IN UCHAR SsidLen);
-
-VOID BssTableSortByRssi(
- IN OUT BSS_TABLE *OutTab);
-
-VOID BssCipherParse(
- IN OUT PBSS_ENTRY pBss);
-
-NDIS_STATUS MlmeQueueInit(
- IN MLME_QUEUE *Queue);
-
-VOID MlmeQueueDestroy(
- IN MLME_QUEUE *Queue);
-
-BOOLEAN MlmeEnqueue(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Machine,
- IN ULONG MsgType,
- IN ULONG MsgLen,
- IN VOID *Msg);
-
-BOOLEAN MlmeEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG TimeStampHigh,
- IN ULONG TimeStampLow,
- IN UCHAR Rssi0,
- IN UCHAR Rssi1,
- IN UCHAR Rssi2,
- IN ULONG MsgLen,
- IN PVOID Msg,
- IN UCHAR Signal);
-
-
-BOOLEAN MlmeDequeue(
- IN MLME_QUEUE *Queue,
- OUT MLME_QUEUE_ELEM **Elem);
-
-VOID MlmeRestartStateMachine(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeQueueEmpty(
- IN MLME_QUEUE *Queue);
-
-BOOLEAN MlmeQueueFull(
- IN MLME_QUEUE *Queue);
-
-BOOLEAN MsgTypeSubst(
- IN PRTMP_ADAPTER pAd,
- IN PFRAME_802_11 pFrame,
- OUT INT *Machine,
- OUT INT *MsgType);
-
-VOID StateMachineInit(
- IN STATE_MACHINE *Sm,
- IN STATE_MACHINE_FUNC Trans[],
- IN ULONG StNr,
- IN ULONG MsgNr,
- IN STATE_MACHINE_FUNC DefFunc,
- IN ULONG InitState,
- IN ULONG Base);
-
-VOID StateMachineSetAction(
- IN STATE_MACHINE *S,
- IN ULONG St,
- ULONG Msg,
- IN STATE_MACHINE_FUNC F);
-
-VOID StateMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Drop(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID ReassocTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID AssocTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID DisassocTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-//----------------------------------------------
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAssocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerReassocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDisassocAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID DisassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AssocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ReassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Cls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr);
-
-VOID SwitchBetweenWepAndCkip(
- IN PRTMP_ADAPTER pAd);
-
-VOID InvalidStateWhenAssoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenReassoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenDisassociate(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef RT2870
-VOID MlmeCntlConfirm(
- IN PRTMP_ADAPTER pAd,
- IN ULONG MsgType,
- IN USHORT Msg);
-#endif // RT2870 //
-
-VOID ComposePsPoll(
- IN PRTMP_ADAPTER pAd);
-
-VOID ComposeNullFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID AssocPostProc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr2,
- IN USHORT CapabilityInfo,
- IN USHORT Aid,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN PEDCA_PARM pEdcaParm,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN ADD_HT_INFO_IE *pAddHtInfo);
-
-VOID AuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID AuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID MlmeAuthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthRspAtSeq2Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthRspAtSeq4Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AuthTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Cls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr);
-
-VOID MlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenAuth(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-//=============================================
-
-VOID AuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[]);
-
-VOID PeerDeauthAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT Reason,
- IN USHORT Status);
-
-//
-// Private routines in dls.c
-//
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-void DlsStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID RTMPCheckDLSTimeOut(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPRcvFrameDLSCheck(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN ULONG Len,
- IN PRT28XX_RXD_STRUC pRxD);
-
-INT RTMPCheckDLSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-NDIS_STATUS RTMPSendSTAKeyRequest(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-NDIS_STATUS RTMPSendSTAKeyHandShake(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-VOID DlsTimeoutAction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN MlmeDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PRT_802_11_DLS *pDLS,
- OUT PUSHORT pReason);
-
-INT Set_DlsEntryInfo_Display_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UINT DlsEntryIdx);
-
-BOOLEAN MacTableDeleteDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr);
-
-MAC_TABLE_ENTRY *DlsEntryTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount);
-
-MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR wcid,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount);
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_DlsTearDownEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN PeerDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pDlsTimeout,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDlsRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDlsTearDownSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pReason);
-#endif // QOS_DLS_SUPPORT //
-
-//========================================
-
-VOID SyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID BeaconTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID ScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenJoin(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenStart(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID EnqueueProbeRequest(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN ScanRunning(
- IN PRTMP_ADAPTER pAd);
-//=========================================
-
-VOID MlmeCntlInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeCntlMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlIdleProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlOidScanProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlOidSsidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem);
-
-VOID CntlOidRTBssidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem);
-
-VOID CntlMlmeRoamingProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem);
-
-VOID CntlWaitDisassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitJoinProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitReassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitStartProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAuthProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAuthProc2(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAssocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef QOS_DLS_SUPPORT
-VOID CntlOidDLSSetupProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // QOS_DLS_SUPPORT //
-
-VOID LinkUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssType);
-
-VOID LinkDown(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN IsReqFromAP);
-
-VOID IterateOnBssTab(
- IN PRTMP_ADAPTER pAd);
-
-VOID IterateOnBssTab2(
- IN PRTMP_ADAPTER pAd);;
-
-VOID JoinParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
- IN ULONG BssIdx);
-
-VOID AssocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
- IN PUCHAR pAddr,
- IN USHORT CapabilityInfo,
- IN ULONG Timeout,
- IN USHORT ListenIntv);
-
-VOID ScanParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN UCHAR ScanType);
-
-VOID DisassocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
- IN PUCHAR pAddr,
- IN USHORT Reason);
-
-VOID StartParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_START_REQ_STRUCT *StartReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen);
-
-VOID AuthParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
- IN PUCHAR pAddr,
- IN USHORT Alg);
-
-VOID EnqueuePsPoll(
- IN PRTMP_ADAPTER pAd);
-
-VOID EnqueueBeaconFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeJoinReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeStartReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID BeaconTimeoutAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeaconAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ScanNextChannel(
- IN PRTMP_ADAPTER pAd);
-
-ULONG MakeIbssBeacon(
- IN PRTMP_ADAPTER pAd);
-
-VOID CCXAdjacentAPReport(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeScanReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *BssType,
- OUT CHAR ssid[],
- OUT UCHAR *SsidLen,
- OUT UCHAR *ScanType);
-
-BOOLEAN PeerBeaconAndProbeRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- IN UCHAR MsgChannel,
- OUT PUCHAR pAddr2,
- OUT PUCHAR pBssid,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen,
- OUT UCHAR *pBssType,
- OUT USHORT *pBeaconPeriod,
- OUT UCHAR *pChannel,
- OUT UCHAR *pNewChannel,
- OUT LARGE_INTEGER *pTimestamp,
- OUT CF_PARM *pCfParm,
- OUT USHORT *pAtimWin,
- OUT USHORT *pCapabilityInfo,
- OUT UCHAR *pErp,
- OUT UCHAR *pDtimCount,
- OUT UCHAR *pDtimPeriod,
- OUT UCHAR *pBcastFlag,
- OUT UCHAR *pMessageToMe,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT UCHAR *pCkipFlag,
- OUT UCHAR *pAironetCellPowerLimit,
- OUT PEDCA_PARM pEdcaParm,
- OUT PQBSS_LOAD_PARM pQbssLoad,
- OUT PQOS_CAPABILITY_PARM pQosCapability,
- OUT ULONG *pRalinkIe,
- OUT UCHAR *pHtCapabilityLen,
-#ifdef CONFIG_STA_SUPPORT
- OUT UCHAR *pPreNHtCapabilityLen,
-#endif // CONFIG_STA_SUPPORT //
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT UCHAR *AddHtInfoLen,
- OUT ADD_HT_INFO_IE *AddHtInfo,
- OUT UCHAR *NewExtChannel,
- OUT USHORT *LengthVIE,
- OUT PNDIS_802_11_VARIABLE_IEs pVIE);
-
-BOOLEAN PeerAddBAReqActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2);
-
-BOOLEAN PeerAddBARspActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen);
-
-BOOLEAN PeerDelBAActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN VOID *pMsg,
- IN ULONG MsgLen);
-
-BOOLEAN MlmeAssocReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pApAddr,
- OUT USHORT *CapabilityInfo,
- OUT ULONG *Timeout,
- OUT USHORT *ListenIntv);
-
-BOOLEAN MlmeAuthReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT ULONG *Timeout,
- OUT USHORT *Alg);
-
-BOOLEAN MlmeStartReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT CHAR Ssid[],
- OUT UCHAR *Ssidlen);
-
-BOOLEAN PeerAuthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT USHORT *Alg,
- OUT USHORT *Seq,
- OUT USHORT *Status,
- OUT CHAR ChlgText[]);
-
-BOOLEAN PeerAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT USHORT *pAid,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- OUT UCHAR *pHtCapabilityLen,
- OUT UCHAR *pAddHtInfoLen,
- OUT UCHAR *pNewExtChannelOffset,
- OUT PEDCA_PARM pEdcaParm,
- OUT UCHAR *pCkipFlag);
-
-BOOLEAN PeerDisassocSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN PeerWpaMessageSanity(
- IN PRTMP_ADAPTER pAd,
- IN PEAPOL_PACKET pMsg,
- IN ULONG MsgLen,
- IN UCHAR MsgType,
- IN MAC_TABLE_ENTRY *pEntry);
-
-BOOLEAN PeerDeauthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN PeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen);
-
-BOOLEAN GetTimBit(
- IN CHAR *Ptr,
- IN USHORT Aid,
- OUT UCHAR *TimLen,
- OUT UCHAR *BcastFlag,
- OUT UCHAR *DtimCount,
- OUT UCHAR *DtimPeriod,
- OUT UCHAR *MessageToMe);
-
-UCHAR ChannelSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel);
-
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
- IN PBSS_ENTRY pBss);
-
-#if 0 // It's omitted
-NDIS_STATUS RTMPWepKeySanity(
- IN PRTMP_ADAPTER pAdapter,
- IN PVOID pBuf);
-#endif
-
-BOOLEAN MlmeDelBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen);
-
-BOOLEAN MlmeAddBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2);
-
-ULONG MakeOutgoingFrame(
- OUT CHAR *Buffer,
- OUT ULONG *Length, ...);
-
-VOID LfsrInit(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Seed);
-
-UCHAR RandomByte(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicUpdateAutoFallBackTable(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pTxRate);
-
-VOID MlmePeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LinkDownExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LinkUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID STAMlmePeriodicExec(
- PRTMP_ADAPTER pAd);
-
-VOID MlmeAutoScan(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeAutoReconnectLastSSID(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeValidateSSID(
- IN PUCHAR pSsid,
- IN UCHAR SsidLen);
-
-VOID MlmeCheckForRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32);
-
-VOID MlmeCheckForFastRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now);
-
-VOID MlmeDynamicTxRateSwitching(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeSetTxRate(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PRTMP_TX_RATE_SWITCH pTxRate);
-
-VOID MlmeSelectTxRateTable(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR *ppTable,
- IN PUCHAR pTableSize,
- IN PUCHAR pInitTxRateIdx);
-
-VOID MlmeCalculateChannelQuality(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now);
-
-VOID MlmeCheckPsmChange(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32);
-
-VOID MlmeSetPsmBit(
- IN PRTMP_ADAPTER pAd,
- IN USHORT psm);
-
-VOID MlmeSetTxPreamble(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TxPreamble);
-
-VOID UpdateBasicRateBitmap(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeUpdateTxRates(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bLinkUp,
- IN UCHAR apidx);
-
-#ifdef DOT11_N_SUPPORT
-VOID MlmeUpdateHtTxRates(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx);
-#endif // DOT11_N_SUPPORT //
-
-VOID RTMPCheckRates(
- IN PRTMP_ADAPTER pAd,
- IN OUT UCHAR SupRate[],
- IN OUT UCHAR *SupRateLen);
-
-#ifdef CONFIG_STA_SUPPORT
-BOOLEAN RTMPCheckChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR CentralChannel,
- IN UCHAR Channel);
-#endif // CONFIG_STA_SUPPORT //
-
-BOOLEAN RTMPCheckHt(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN OUT HT_CAPABILITY_IE *pHtCapability,
- IN OUT ADD_HT_INFO_IE *pAddHtInfo);
-
-VOID StaQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID AsicBbpTuning1(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicBbpTuning2(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPUpdateMlmeRate(
- IN PRTMP_ADAPTER pAd);
-
-CHAR RTMPMaxRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi0,
- IN CHAR Rssi1,
- IN CHAR Rssi2);
-
-VOID AsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicRxAntEvalTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID APSDPeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry);
-
-UCHAR RTMPStaFixedTxMode(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry);
-
-VOID RTMPUpdateLegacyTxSetting(
- UCHAR fixed_tx_mode,
- PMAC_TABLE_ENTRY pEntry);
-
-BOOLEAN RTMPAutoRateSwitchCheck(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS MlmeInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeHandler(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeHalt(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeResetRalinkCounters(
- IN PRTMP_ADAPTER pAd);
-
-VOID BuildChannelList(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR FirstChannel(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR NextChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel);
-
-VOID ChangeToCellPowerLimit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AironetCellPowerLimit);
-
-VOID RaiseClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x);
-
-VOID LowerClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x);
-
-USHORT ShiftInBits(
- IN PRTMP_ADAPTER pAd);
-
-VOID ShiftOutBits(
- IN PRTMP_ADAPTER pAd,
- IN USHORT data,
- IN USHORT count);
-
-VOID EEpromCleanup(
- IN PRTMP_ADAPTER pAd);
-
-VOID EWDS(
- IN PRTMP_ADAPTER pAd);
-
-VOID EWEN(
- IN PRTMP_ADAPTER pAd);
-
-USHORT RTMP_EEPROM_READ16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset);
-
-VOID RTMP_EEPROM_WRITE16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Data);
-
-//
-// Prototypes of function definition in rtmp_tkip.c
-//
-VOID RTMPInitTkipEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pTKey,
- IN UCHAR KeyId,
- IN PUCHAR pTA,
- IN PUCHAR pMICKey,
- IN PUCHAR pTSC,
- OUT PULONG pIV16,
- OUT PULONG pIV32);
-
-VOID RTMPInitMICEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN UCHAR UserPriority,
- IN PUCHAR pMICKey);
-
-BOOLEAN RTMPTkipCompareMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UCHAR UserPriority,
- IN UINT Len);
-
-VOID RTMPCalculateMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pEncap,
- IN PCIPHER_KEY pKey,
- IN UCHAR apidx);
-
-BOOLEAN RTMPTkipCompareMICValueWithLLC(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pLLC,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UINT Len);
-
-VOID RTMPTkipAppendByte(
- IN PTKIP_KEY_INFO pTkip,
- IN UCHAR uChar);
-
-VOID RTMPTkipAppend(
- IN PTKIP_KEY_INFO pTkip,
- IN PUCHAR pSrc,
- IN UINT nBytes);
-
-VOID RTMPTkipGetMIC(
- IN PTKIP_KEY_INFO pTkip);
-
-BOOLEAN RTMPSoftDecryptTKIP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN UCHAR UserPriority,
- IN PCIPHER_KEY pWpaKey);
-
-BOOLEAN RTMPSoftDecryptAES(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pWpaKey);
-
-#if 0 // removed by AlbertY
-NDIS_STATUS RTMPWPAAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-#endif
-
-//
-// Prototypes of function definition in cmm_info.c
-//
-NDIS_STATUS RTMPWPARemoveKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-VOID RTMPWPARemoveAllKeys(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPCheckStrPrintAble(
- IN CHAR *pInPutStr,
- IN UCHAR strLen);
-
-VOID RTMPSetPhyMode(
- IN PRTMP_ADAPTER pAd,
- IN ULONG phymode);
-
-VOID RTMPUpdateHTIE(
- IN RT_HT_CAPABILITY *pRtHt,
- IN UCHAR *pMcsSet,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo);
-
-VOID RTMPAddWcidAttributeEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN MAC_TABLE_ENTRY *pEntry);
-
-CHAR *GetEncryptType(
- CHAR enc);
-
-CHAR *GetAuthMode(
- CHAR auth);
-
-VOID RTMPIoctlGetSiteSurvey(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlGetMacTable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq);
-
-VOID RTMPIndicateWPA2Status(
- IN PRTMP_ADAPTER pAdapter);
-
-VOID RTMPOPModeSwitching(
- IN PRTMP_ADAPTER pAd);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPAddBSSIDCipher(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Aid,
- IN PNDIS_802_11_KEY pKey,
- IN UCHAR CipherAlg);
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
-VOID RTMPSetHT(
- IN PRTMP_ADAPTER pAd,
- IN OID_SET_HT_PHYMODE *pHTPhyMode);
-
-VOID RTMPSetIndividualHT(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx);
-#endif // DOT11_N_SUPPORT //
-
-VOID RTMPSendWirelessEvent(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Event_flag,
- IN PUCHAR pAddr,
- IN UCHAR BssIdx,
- IN CHAR Rssi);
-
-VOID NICUpdateCntlCounters(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN UCHAR SubType,
- IN PRXWI_STRUC pRxWI);
-//
-// prototype in wpa.c
-//
-BOOLEAN WpaMsgTypeSubst(
- IN UCHAR EAPType,
- OUT INT *MsgType);
-
-VOID WpaPskStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID WpaEAPOLKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaPairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaPairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaGroupMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr1);
-
-VOID Wpa2PairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Wpa2PairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-BOOLEAN ParseKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR bPairewise);
-
-VOID RTMPToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN BOOLEAN is4wayFrame);
-
-VOID HMAC_SHA1(
- IN UCHAR *text,
- IN UINT text_len,
- IN UCHAR *key,
- IN UINT key_len,
- IN UCHAR *digest);
-
-VOID PRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *prefix,
- IN INT prefix_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len);
-
-VOID CCKMPRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len);
-
-VOID WpaCountPTK(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *PMK,
- IN UCHAR *ANonce,
- IN UCHAR *AA,
- IN UCHAR *SNonce,
- IN UCHAR *SA,
- OUT UCHAR *output,
- IN UINT len);
-
-VOID GenRandom(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *macAddr,
- OUT UCHAR *random);
-
-//
-// prototype in aironet.c
-//
-VOID AironetStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID AironetMsgAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AironetRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ChannelLoadRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID NoiseHistRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID BeaconRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID AironetReportAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ChannelLoadReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID NoiseHistReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID AironetFinalReportAction(
- IN PRTMP_ADAPTER pAd);
-
-VOID BeaconReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID AironetAddBeaconReport(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Index,
- IN PMLME_QUEUE_ELEM pElem);
-
-VOID AironetCreateBeaconReportFromBssTable(
- IN PRTMP_ADAPTER pAd);
-
-VOID DBGPRINT_TX_RING(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx);
-
-VOID DBGPRINT_RX_RING(
- IN PRTMP_ADAPTER pAd);
-
-CHAR ConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber);
-
-
-#ifdef DOT11N_DRAFT3
-VOID BuildEffectedChannelList(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11N_DRAFT3 //
-
-
-VOID APAsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd);
-
-
-VOID APAsicRxAntEvalTimeout(
- IN PRTMP_ADAPTER pAd);
-
-//
-// function prototype in cmm_wpa.c
-//
-BOOLEAN RTMPCheckWPAframe(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR pData,
- IN ULONG DataByteCount,
- IN UCHAR FromWhichBSSID);
-
-VOID AES_GTK_KEY_UNWRAP(
- IN UCHAR *key,
- OUT UCHAR *plaintext,
- IN UCHAR c_len,
- IN UCHAR *ciphertext);
-
-BOOLEAN RTMPCheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- IN MAC_TABLE_ENTRY *pEntry,
- OUT UCHAR *Offset);
-
-BOOLEAN RTMPParseEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR GroupKeyIndex,
- IN UCHAR MsgType,
- IN BOOLEAN bWPA2,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID ConstructEapolMsg(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerAuthMode,
- IN UCHAR PeerWepStatus,
- IN UCHAR MyGroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN UCHAR *ReplayCounter,
- IN UCHAR *KeyNonce,
- IN UCHAR *TxRSC,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_Len,
- OUT PEAPOL_PACKET pMsg);
-
-VOID CalculateMIC(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerWepStatus,
- IN UCHAR *PTK,
- OUT PEAPOL_PACKET pMsg);
-
-NDIS_STATUS RTMPSoftDecryptBroadCastData(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN NDIS_802_11_ENCRYPTION_STATUS GroupCipher,
- IN PCIPHER_KEY pShard_key);
-
-VOID ConstructEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerAuthMode,
- IN UCHAR PeerWepStatus,
- IN UCHAR GroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN BOOLEAN bWPA2Capable,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_LEN,
- OUT PEAPOL_PACKET pMsg);
-
-VOID RTMPMakeRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN UINT AuthMode,
- IN UINT WepStatus,
- IN UCHAR apidx);
-
-//
-// function prototype in ap_wpa.c
-//
-
-BOOLEAN APWpaMsgTypeSubst(
- IN UCHAR EAPType,
- OUT INT *MsgType) ;
-
-MAC_TABLE_ENTRY *PACInquiry(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid);
-
-BOOLEAN RTMPCheckMcast(
- IN PRTMP_ADAPTER pAd,
- IN PEID_STRUCT eid_ptr,
- IN MAC_TABLE_ENTRY *pEntry);
-
-BOOLEAN RTMPCheckUcast(
- IN PRTMP_ADAPTER pAd,
- IN PEID_STRUCT eid_ptr,
- IN MAC_TABLE_ENTRY *pEntry);
-
-BOOLEAN RTMPCheckAUTH(
- IN PRTMP_ADAPTER pAd,
- IN PEID_STRUCT eid_ptr,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID WPAStart4WayHS(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN ULONG TimeInterval);
-
-VOID WPAStart2WayGroupHS(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID APWpaEAPPacketAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLStartAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLLogoffAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLASFAlertAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HandleCounterMeasure(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID PeerPairMsg2Action(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerPairMsg4Action(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CMTimerExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID WPARetryExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID EnqueueStartForPSKExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID RTMPHandleSTAKey(
- IN PRTMP_ADAPTER pAdapter,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-#if 0 // merge into PeerPairMsg4Action
-VOID Wpa1PeerPairMsg4Action(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Wpa2PeerPairMsg4Action(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // 0 //
-
-VOID PeerGroupMsg2Action(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN VOID *Msg,
- IN UINT MsgLen);
-
-#if 0 // replaced by WPAStart2WayGroupHS
-NDIS_STATUS APWpaHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry);
-#endif // 0 //
-
-VOID PairDisAssocAction(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN USHORT Reason);
-
-VOID MlmeDeAuthAction(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN USHORT Reason);
-
-VOID GREKEYPeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID CountGTK(
- IN UCHAR *PMK,
- IN UCHAR *GNonce,
- IN UCHAR *AA,
- OUT UCHAR *output,
- IN UINT len);
-
-VOID GetSmall(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- OUT PUCHAR out,
- IN ULONG Length);
-
-VOID GetLarge(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- OUT PUCHAR out,
- IN ULONG Length);
-
-VOID APGenRandom(
- IN PRTMP_ADAPTER pAd,
- OUT UCHAR *random);
-
-VOID AES_GTK_KEY_WRAP(
- IN UCHAR *key,
- IN UCHAR *plaintext,
- IN UCHAR p_len,
- OUT UCHAR *ciphertext);
-
-VOID WpaSend(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR pPacket,
- IN ULONG Len);
-
-VOID APToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN BOOLEAN bClearFrame);
-
-VOID RTMPAddPMKIDCache(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN PUCHAR pAddr,
- IN UCHAR *PMKID,
- IN UCHAR *PMK);
-
-INT RTMPSearchPMKIDCache(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN PUCHAR pAddr);
-
-VOID RTMPDeletePMKIDCache(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN INT idx);
-
-VOID RTMPMaintainPMKIDCache(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPSendTriggerFrame(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuffer,
- IN ULONG Length,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull);
-
-
-//typedef void (*TIMER_FUNCTION)(unsigned long);
-
-
-/* timeout -- ms */
-VOID RTMP_SetPeriodicTimer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout);
-
-VOID RTMP_OS_Init_Timer(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN TIMER_FUNCTION function,
- IN PVOID data);
-
-VOID RTMP_OS_Add_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout);
-
-VOID RTMP_OS_Mod_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout);
-
-
-VOID RTMP_OS_Del_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- OUT BOOLEAN *pCancelled);
-
-
-VOID RTMP_OS_Release_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PQUEUE_ENTRY pEntry);
-
-VOID RTMPusecDelay(
- IN ULONG usec);
-
-NDIS_STATUS os_alloc_mem(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR *mem,
- IN ULONG size);
-
-NDIS_STATUS os_free_mem(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mem);
-
-
-void RTMP_AllocateSharedMemory(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-VOID RTMPFreeTxRxRingMemory(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS AdapterBlockAllocateMemory(
- IN PVOID handle,
- OUT PVOID *ppAd);
-
-void RTMP_AllocateTxDescMemory(
- IN PRTMP_ADAPTER pAd,
- IN UINT Index,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateFirstTxBuffer(
- IN PRTMP_ADAPTER pAd,
- IN UINT Index,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateMgmtDescMemory(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateRxDescMemory(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-PNDIS_PACKET RTMP_AllocateRxPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress);
-
-PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length);
-
-void RTMP_QueryPacketInfo(
- IN PNDIS_PACKET pPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen);
-
-void RTMP_QueryNextPacketInfo(
- IN PNDIS_PACKET *ppPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen);
-
-
-BOOLEAN RTMP_FillTxBlkInfo(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk);
-
-
-PRTMP_SCATTER_GATHER_LIST
-rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg);
-
-
- void announce_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-UINT BA_Reorder_AMSDU_Annnounce(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-UINT Handle_AMSDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-
-void convert_802_11_to_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR p8023hdr,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-
-PNET_DEV get_netdev_from_bssid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR FromWhichBSSID);
-
-
-PNDIS_PACKET duplicate_pkt(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-
-PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pOldPkt);
-
-PNDIS_PACKET duplicate_pkt_with_VLAN(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-PNDIS_PACKET duplicate_pkt_with_WPI(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UINT32 ext_head_len,
- IN UINT32 ext_tail_len);
-
-UCHAR VLAN_8023_Header_Copy(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- OUT PUCHAR pData,
- IN UCHAR FromWhichBSSID);
-
-#ifdef DOT11_N_SUPPORT
-void ba_flush_reordering_timeout_mpdus(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN ULONG Now32);
-
-
-VOID BAOriSessionSetUp(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN UCHAR TID,
- IN USHORT TimeOut,
- IN ULONG DelayTime,
- IN BOOLEAN isForced);
-
-VOID BASessionTearDownALL(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid);
-#endif // DOT11_N_SUPPORT //
-
-BOOLEAN OS_Need_Clone_Packet(void);
-
-
-VOID build_tx_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pFrame,
- IN ULONG FrameLen);
-
-
-VOID BAOriSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive,
- IN BOOLEAN bForceSend);
-
-VOID BARecSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive);
-
-BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
-void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-
-ULONG AutoChBssInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR ChannelNo,
- IN CHAR Rssi);
-
-void AutoChBssTableInit(
- IN PRTMP_ADAPTER pAd);
-
-void ChannelInfoInit(
- IN PRTMP_ADAPTER pAd);
-
-void AutoChBssTableDestroy(
- IN PRTMP_ADAPTER pAd);
-
-void ChannelInfoDestroy(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR New_ApAutoSelectChannel(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN rtstrmactohex(
- IN char *s1,
- IN char *s2);
-
-BOOLEAN rtstrcasecmp(
- IN char *s1,
- IN char *s2);
-
-char *rtstrstruncasecmp(
- IN char *s1,
- IN char *s2);
-
-char *rtstrstr(
- IN const char * s1,
- IN const char * s2);
-
-char *rstrtok(
- IN char * s,
- IN const char * ct);
-
-int rtinet_aton(
- const char *cp,
- unsigned int *addr);
-
-////////// common ioctl functions //////////
-INT Set_DriverVersion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ShortSlot_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef AGGREGATION_SUPPORT
-INT Set_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Set_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef DBG
-INT Set_Debug_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Show_DescInfo_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ResetStatCounter_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef DOT11_N_SUPPORT
-INT Set_BASetup_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BADecline_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BAOriTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BARecTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtStbc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtHtc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtLinkAdapt_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtProtect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMimoPs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_ForceShortGI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ForceGF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT SetCommonHT(
- IN PRTMP_ADAPTER pAd);
-
-INT Set_SendPSMPAction_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMIMOPSmode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_HtTxBASize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-//Dls , kathy
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-#ifdef DOT11_N_SUPPORT
-//Block ACK
-VOID QueryBATABLE(
- IN PRTMP_ADAPTER pAd,
- OUT PQUERYBA_TABLE pBAT);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-INT WpaCheckEapCode(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFrame,
- IN USHORT FrameLen,
- IN USHORT OffSet);
-
-VOID WpaSendMicFailureToWpaSupplicant(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUnicast);
-
-VOID SendAssocIEsToWpaSupplicant(
- IN PRTMP_ADAPTER pAd);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-int wext_notify_event_assoc(
- IN RTMP_ADAPTER *pAd);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-
-#ifdef DOT11_N_SUPPORT
-VOID Handle_BSS_Width_Trigger_Events(
- IN PRTMP_ADAPTER pAd);
-
-void build_ext_channel_switch_ie(
- IN PRTMP_ADAPTER pAd,
- IN HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE *pIE);
-#endif // DOT11_N_SUPPORT //
-
-
-BOOLEAN APRxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN STARxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN argc);
-
-#ifdef DOT11_N_SUPPORT
-// AMPDU packet indication
-VOID Indicate_AMPDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-// AMSDU packet indication
-VOID Indicate_AMSDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-#endif // DOT11_N_SUPPORT //
-
-// Normal legacy Rx packet indication
-VOID Indicate_Legacy_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-VOID Indicate_EAPOL_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-void update_os_packet_info(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-void wlan_802_11_to_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN PUCHAR pHeader802_3,
- IN UCHAR FromWhichBSSID);
-
-UINT deaggregate_AMSDU_announce(
- IN PRTMP_ADAPTER pAd,
- PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize);
-
-
-#ifdef CONFIG_STA_SUPPORT
-// remove LLC and get 802_3 Header
-#define RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3) \
-{ \
- PUCHAR _pRemovedLLCSNAP = NULL, _pDA, _pSA; \
- \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) \
- { \
- _pDA = _pRxBlk->pHeader->Addr3; \
- _pSA = (PUCHAR)_pRxBlk->pHeader + sizeof(HEADER_802_11); \
- } \
- else \
- { \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) \
- { \
- _pDA = _pRxBlk->pHeader->Addr1; \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS)) \
- _pSA = _pRxBlk->pHeader->Addr2; \
- else \
- _pSA = _pRxBlk->pHeader->Addr3; \
- } \
- else \
- { \
- _pDA = _pRxBlk->pHeader->Addr1; \
- _pSA = _pRxBlk->pHeader->Addr2; \
- } \
- } \
- \
- CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData, \
- _pRxBlk->DataSize, _pRemovedLLCSNAP); \
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-BOOLEAN APFowardWirelessStaToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN ULONG FromWhichBSSID);
-
-VOID Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID);
-
-VOID Sta_Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID);
-
-
-#ifdef CONFIG_STA_SUPPORT
-#define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
- Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
- //announce_802_3_packet(_pAd, _pPacket);
-#endif // CONFIG_STA_SUPPORT //
-
-
-PNDIS_PACKET DuplicatePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID);
-
-
-PNDIS_PACKET ClonePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize);
-
-
-// Normal, AMPDU or AMSDU
-VOID CmmRxnonRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-VOID CmmRxRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-VOID Update_Rssi_Sample(
- IN PRTMP_ADAPTER pAd,
- IN RSSI_SAMPLE *pRssi,
- IN PRXWI_STRUC pRxWI);
-
-PNDIS_PACKET GetPacketFromRxRing(
- IN PRTMP_ADAPTER pAd,
- OUT PRT28XX_RXD_STRUC pSaveRxD,
- OUT BOOLEAN *pbReschedule,
- IN OUT UINT32 *pRxPending);
-
-PNDIS_PACKET RTMPDeFragmentDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk);
-
-////////////////////////////////////////
-
-
-
-
-
-#ifdef SNMP_SUPPORT
-//for snmp , kathy
-typedef struct _DefaultKeyIdxValue
-{
- UCHAR KeyIdx;
- UCHAR Value[16];
-} DefaultKeyIdxValue, *PDefaultKeyIdxValue;
-#endif
-
-
-#ifdef CONFIG_STA_SUPPORT
-enum {
- DIDmsg_lnxind_wlansniffrm = 0x00000044,
- DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
- DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
- DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
- DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
- DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
- DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
- DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
- DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
- DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
- DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
-};
-enum {
- P80211ENUM_msgitem_status_no_value = 0x00
-};
-enum {
- P80211ENUM_truth_false = 0x00,
- P80211ENUM_truth_true = 0x01
-};
-
-/* Definition from madwifi */
-typedef struct {
- UINT32 did;
- UINT16 status;
- UINT16 len;
- UINT32 data;
-} p80211item_uint32_t;
-
-typedef struct {
- UINT32 msgcode;
- UINT32 msglen;
-#define WLAN_DEVNAMELEN_MAX 16
- UINT8 devname[WLAN_DEVNAMELEN_MAX];
- p80211item_uint32_t hosttime;
- p80211item_uint32_t mactime;
- p80211item_uint32_t channel;
- p80211item_uint32_t rssi;
- p80211item_uint32_t sq;
- p80211item_uint32_t signal;
- p80211item_uint32_t noise;
- p80211item_uint32_t rate;
- p80211item_uint32_t istx;
- p80211item_uint32_t frmlen;
-} wlan_ng_prism2_header;
-
-/* The radio capture header precedes the 802.11 header. */
-typedef struct PACKED _ieee80211_radiotap_header {
- UINT8 it_version; /* Version 0. Only increases
- * for drastic changes,
- * introduction of compatible
- * new fields does not count.
- */
- UINT8 it_pad;
- UINT16 it_len; /* length of the whole
- * header in bytes, including
- * it_version, it_pad,
- * it_len, and data fields.
- */
- UINT32 it_present; /* A bitmap telling which
- * fields are present. Set bit 31
- * (0x80000000) to extend the
- * bitmap by another 32 bits.
- * Additional extensions are made
- * by setting bit 31.
- */
-}ieee80211_radiotap_header ;
-
-enum ieee80211_radiotap_type {
- IEEE80211_RADIOTAP_TSFT = 0,
- IEEE80211_RADIOTAP_FLAGS = 1,
- IEEE80211_RADIOTAP_RATE = 2,
- IEEE80211_RADIOTAP_CHANNEL = 3,
- IEEE80211_RADIOTAP_FHSS = 4,
- IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
- IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
- IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
- IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
- IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
- IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
- IEEE80211_RADIOTAP_ANTENNA = 11,
- IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
- IEEE80211_RADIOTAP_DB_ANTNOISE = 13
-};
-
-#define WLAN_RADIOTAP_PRESENT ( \
- (1 << IEEE80211_RADIOTAP_TSFT) | \
- (1 << IEEE80211_RADIOTAP_FLAGS) | \
- (1 << IEEE80211_RADIOTAP_RATE) | \
- 0)
-
-typedef struct _wlan_radiotap_header {
- ieee80211_radiotap_header wt_ihdr;
- INT64 wt_tsft;
- UINT8 wt_flags;
- UINT8 wt_rate;
-} wlan_radiotap_header;
-/* Definition from madwifi */
-
-void send_monitor_packets(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk);
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
- IN struct net_device *net_dev);
-#endif
-
-VOID RTMPSetDesiredRates(
- IN PRTMP_ADAPTER pAdapter,
- IN LONG Rates);
-#endif // CONFIG_STA_SUPPORT //
-
-INT Set_FixedTxMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-INT Set_OpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-static inline char* GetPhyMode(
- int Mode)
-{
- switch(Mode)
- {
- case MODE_CCK:
- return "CCK";
-
- case MODE_OFDM:
- return "OFDM";
-#ifdef DOT11_N_SUPPORT
- case MODE_HTMIX:
- return "HTMIX";
-
- case MODE_HTGREENFIELD:
- return "GREEN";
-#endif // DOT11_N_SUPPORT //
- default:
- return "N/A";
- }
-}
-
-
-static inline char* GetBW(
- int BW)
-{
- switch(BW)
- {
- case BW_10:
- return "10M";
-
- case BW_20:
- return "20M";
-#ifdef DOT11_N_SUPPORT
- case BW_40:
- return "40M";
-#endif // DOT11_N_SUPPORT //
- default:
- return "N/A";
- }
-}
-
-
-VOID RT28xxThreadTerminate(
- IN RTMP_ADAPTER *pAd);
-
-BOOLEAN RT28XXChipsetCheck(
- IN void *_dev_p);
-
-BOOLEAN RT28XXNetDevInit(
- IN void *_dev_p,
- IN struct net_device *net_dev,
- IN RTMP_ADAPTER *pAd);
-
-BOOLEAN RT28XXProbePostConfig(
- IN void *_dev_p,
- IN RTMP_ADAPTER *pAd,
- IN INT32 argc);
-
-VOID RT28XXDMADisable(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT28XXDMAEnable(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT28xx_UpdateBeaconToAsic(
- IN RTMP_ADAPTER * pAd,
- IN INT apidx,
- IN ULONG BeaconLen,
- IN ULONG UpdatePos);
-
-INT rt28xx_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd);
-
-
-#ifdef CONFIG_STA_SUPPORT
-INT rt28xx_sta_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd);
-#endif // CONFIG_STA_SUPPORT //
-
-BOOLEAN RT28XXSecurityKeyAdd(
- IN PRTMP_ADAPTER pAd,
- IN ULONG apidx,
- IN ULONG KeyIdx,
- IN MAC_TABLE_ENTRY *pEntry);
-
-////////////////////////////////////////
-PNDIS_PACKET GetPacketFromRxRing(
- IN PRTMP_ADAPTER pAd,
- OUT PRT28XX_RXD_STRUC pSaveRxD,
- OUT BOOLEAN *pbReschedule,
- IN OUT UINT32 *pRxPending);
-
-
-void kill_thread_task(PRTMP_ADAPTER pAd);
-
-void tbtt_tasklet(unsigned long data);
-
-
-VOID AsicTurnOffRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel);
-
-VOID AsicTurnOnRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel);
-
-#ifdef RT2870
-//
-// Function Prototype in rtusb_bulk.c
-//
-VOID RTUSBInitTxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PTX_CONTEXT pTxContext,
- IN UCHAR BulkOutPipeId,
- IN usb_complete_t Func);
-
-VOID RTUSBInitHTTxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PHT_TX_CONTEXT pTxContext,
- IN UCHAR BulkOutPipeId,
- IN ULONG BulkOutSize,
- IN usb_complete_t Func);
-
-VOID RTUSBInitRxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PRX_CONTEXT pRxContext);
-
-VOID RTUSBCleanUpDataBulkOutQueue(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCancelPendingBulkOutIRP(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId,
- IN UCHAR Index);
-
-VOID RTUSBBulkOutNullFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkOutRTSFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCancelPendingIRPs(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkOutMLMEPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID RTUSBBulkOutPsPoll(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCleanUpMLMEBulkOutQueue(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBKickBulkOut(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkReceive(
- IN PRTMP_ADAPTER pAd);
-
-VOID DoBulkIn(
- IN RTMP_ADAPTER *pAd);
-
-VOID RTUSBInitRxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PRX_CONTEXT pRxContext);
-
-VOID RTUSBBulkRxHandle(
- IN unsigned long data);
-
-//
-// Function Prototype in rtusb_io.c
-//
-NTSTATUS RTUSBMultiRead(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT length);
-
-NTSTATUS RTUSBMultiWrite(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length);
-
-NTSTATUS RTUSBMultiWrite_OneByte(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData);
-
-NTSTATUS RTUSBReadBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN PUCHAR pValue);
-
-NTSTATUS RTUSBWriteBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN UCHAR Value);
-
-NTSTATUS RTUSBWriteRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 Value);
-
-NTSTATUS RT30xxWriteRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RegID,
- IN UCHAR Value);
-
-NTSTATUS RT30xxReadRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RegID,
- IN PUCHAR pValue);
-
-NTSTATUS RTUSB_VendorRequest(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TransferFlags,
- IN UCHAR ReservedBits,
- IN UCHAR Request,
- IN USHORT Value,
- IN USHORT Index,
- IN PVOID TransferBuffer,
- IN UINT32 TransferBufferLength);
-
-NTSTATUS RTUSBReadEEPROM(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT length);
-
-NTSTATUS RTUSBWriteEEPROM(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length);
-
-VOID RTUSBPutToSleep(
- IN PRTMP_ADAPTER pAd);
-
-NTSTATUS RTUSBWakeUp(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBInitializeCmdQ(
- IN PCmdQ cmdq);
-
-NDIS_STATUS RTUSBEnqueueCmdFromNdis(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_OID Oid,
- IN BOOLEAN SetInformation,
- IN PVOID pInformationBuffer,
- IN UINT32 InformationBufferLength);
-
-NDIS_STATUS RTUSBEnqueueInternalCmd(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_OID Oid,
- IN PVOID pInformationBuffer,
- IN UINT32 InformationBufferLength);
-
-VOID RTUSBDequeueCmd(
- IN PCmdQ cmdq,
- OUT PCmdQElmt *pcmdqelmt);
-
-INT RTUSBCmdThread(
- IN OUT PVOID Context);
-
-INT TimerQThread(
- IN OUT PVOID Context);
-
-RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
- IN RTMP_ADAPTER *pAd,
- IN RALINK_TIMER_STRUCT *pTimer);
-
-BOOLEAN RT2870_TimerQ_Remove(
- IN RTMP_ADAPTER *pAd,
- IN RALINK_TIMER_STRUCT *pTimer);
-
-void RT2870_TimerQ_Exit(
- IN RTMP_ADAPTER *pAd);
-
-void RT2870_TimerQ_Init(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconExit(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconStop(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconStart(
- IN RTMP_ADAPTER * pAd);
-
-VOID RT2870_BssBeaconInit(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_WatchDog(
- IN RTMP_ADAPTER *pAd);
-
-NTSTATUS RTUSBWriteMACRegister(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN UINT32 Value);
-
-NTSTATUS RTUSBReadMACRegister(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUINT32 pValue);
-
-NTSTATUS RTUSBSingleWrite(
- IN RTMP_ADAPTER *pAd,
- IN USHORT Offset,
- IN USHORT Value);
-
-NTSTATUS RTUSBFirmwareRun(
- IN PRTMP_ADAPTER pAd);
-
-NTSTATUS RTUSBFirmwareWrite(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFwImage,
- IN ULONG FwLen);
-
-NTSTATUS RTUSBFirmwareOpmode(
- IN PRTMP_ADAPTER pAd,
- OUT PUINT32 pValue);
-
-NTSTATUS RTUSBVenderReset(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS RTUSBSetHardWareRegister(
- IN PRTMP_ADAPTER pAdapter,
- IN PVOID pBuf);
-
-NDIS_STATUS RTUSBQueryHardWareRegister(
- IN PRTMP_ADAPTER pAdapter,
- IN PVOID pBuf);
-
-VOID CMDHandler(
- IN PRTMP_ADAPTER pAd);
-
-
-NDIS_STATUS CreateThreads(
- IN struct net_device *net_dev );
-
-
-VOID MacTableInitialize(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeSetPsm(
- IN PRTMP_ADAPTER pAd,
- IN USHORT psm);
-
-NDIS_STATUS RTMPWPAAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-VOID AsicRxAntEvalAction(
- IN PRTMP_ADAPTER pAd);
-
-#if 0 // Mark because not used in RT28xx.
-NTSTATUS RTUSBRxPacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bBulkReceive);
-
-VOID RTUSBDequeueMLMEPacket(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCleanUpMLMEWaitQueue(
- IN PRTMP_ADAPTER pAd);
-#endif
-
-void append_pkt(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- OUT PNDIS_PACKET *ppPacket);
-
-UINT deaggregate_AMSDU_announce(
- IN PRTMP_ADAPTER pAd,
- PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize);
-
-NDIS_STATUS RTMPCheckRxError(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC pRxINFO);
-
-
-VOID RTUSBMlmeHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN PMGMT_STRUC pMgmt);
-
-INT MlmeThread(
- IN PVOID Context);
-
-#if 0
-VOID RTUSBResumeMsduTransmission(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBSuspendMsduTransmission(
- IN PRTMP_ADAPTER pAd);
-#endif
-
-//
-// Function Prototype in rtusb_data.c
-//
-NDIS_STATUS RTUSBFreeDescriptorRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId,
- IN UINT32 NumberRequired);
-
-
-BOOLEAN RTUSBNeedQueueBackForAgg(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR BulkOutPipeId);
-
-
-VOID RTMPWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst);
-
-//
-// Function Prototype in cmm_data_2870.c
-//
-USHORT RtmpUSB_WriteSubTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN BOOLEAN bIsLast,
- OUT USHORT *FreeNumber);
-
-USHORT RtmpUSB_WriteSingleTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN BOOLEAN bIsLast,
- OUT USHORT *FreeNumber);
-
-USHORT RtmpUSB_WriteFragTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR fragNum,
- OUT USHORT *FreeNumber);
-
-USHORT RtmpUSB_WriteMultiTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR frameNum,
- OUT USHORT *FreeNumber);
-
-VOID RtmpUSB_FinalWriteTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN USHORT totalMPDUSize,
- IN USHORT TxIdx);
-
-VOID RtmpUSBDataLastTxIdx(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN USHORT TxIdx);
-
-VOID RtmpUSBDataKickOut(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx);
-
-
-int RtmpUSBMgmtKickOut(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pSrcBufVA,
- IN UINT SrcBufLen);
-
-VOID RtmpUSBNullFrameKickOut(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN UCHAR *pNullFrame,
- IN UINT32 frameLen);
-
-VOID RT28xxUsbStaAsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx);
-
-VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp);
-
-VOID RT28xxUsbMlmeRadioOn(
- IN PRTMP_ADAPTER pAd);
-
-VOID RT28xxUsbMlmeRadioOFF(
- IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-////////////////////////////////////////
-
-VOID QBSS_LoadInit(
- IN RTMP_ADAPTER *pAd);
-
-UINT32 QBSS_LoadElementAppend(
- IN RTMP_ADAPTER *pAd,
- OUT UINT8 *buf_p);
-
-VOID QBSS_LoadUpdate(
- IN RTMP_ADAPTER *pAd);
-
-///////////////////////////////////////
-INT RTMPShowCfgValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pName,
- IN PUCHAR pBuf);
-
-PCHAR RTMPGetRalinkAuthModeStr(
- IN NDIS_802_11_AUTHENTICATION_MODE authMode);
-
-PCHAR RTMPGetRalinkEncryModeStr(
- IN USHORT encryMode);
-//////////////////////////////////////
-
-#ifdef CONFIG_STA_SUPPORT
-VOID AsicStaBbpTuning(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN StaAddMacTableEntry(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN USHORT CapabilityInfo);
-#endif // CONFIG_STA_SUPPORT //
-
-void RTMP_IndicateMediaState(
- IN PRTMP_ADAPTER pAd);
-
-VOID ReSyncBeaconTime(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPSetAGCInitValue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BandWidth);
-
-int rt28xx_close(IN PNET_DEV dev);
-int rt28xx_open(IN PNET_DEV dev);
-
-__inline INT VIRTUAL_IF_UP(PRTMP_ADAPTER pAd)
-{
-extern VOID MeshMakeBeacon(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
-extern VOID MeshUpdateBeaconFrame(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
-
- if (VIRTUAL_IF_NUM(pAd) == 0)
- {
- if (rt28xx_open(pAd->net_dev) != 0)
- return -1;
- }
- else
- {
- }
- VIRTUAL_IF_INC(pAd);
- return 0;
-}
-
-__inline VOID VIRTUAL_IF_DOWN(PRTMP_ADAPTER pAd)
-{
- VIRTUAL_IF_DEC(pAd);
- if (VIRTUAL_IF_NUM(pAd) == 0)
- rt28xx_close(pAd->net_dev);
- return;
-}
-
-
-#endif // __RTMP_H__
-
+#include "../rt2860/rtmp.h"
diff --git a/drivers/staging/rt2870/rtmp_ckipmic.h b/drivers/staging/rt2870/rtmp_ckipmic.h
index a3d949a39d39..0e7f1dfd4547 100644
--- a/drivers/staging/rt2870/rtmp_ckipmic.h
+++ b/drivers/staging/rt2870/rtmp_ckipmic.h
@@ -1,113 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_ckipmic.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef __RTMP_CKIPMIC_H__
-#define __RTMP_CKIPMIC_H__
-
-typedef struct _MIC_CONTEXT {
- /* --- MMH context */
- UCHAR CK[16]; /* the key */
- UCHAR coefficient[16]; /* current aes counter mode coefficients */
- ULONGLONG accum; /* accumulated mic, reduced to u32 in final() */
- UINT position; /* current position (byte offset) in message */
- UCHAR part[4]; /* for conversion of message to u32 for mmh */
-} MIC_CONTEXT, *PMIC_CONTEXT;
-
-VOID CKIP_key_permute(
- OUT UCHAR *PK, /* output permuted key */
- IN UCHAR *CK, /* input CKIP key */
- IN UCHAR toDsFromDs, /* input toDs/FromDs bits */
- IN UCHAR *piv); /* input pointer to IV */
-
-VOID RTMPCkipMicInit(
- IN PMIC_CONTEXT pContext,
- IN PUCHAR CK);
-
-VOID RTMPMicUpdate(
- IN PMIC_CONTEXT pContext,
- IN PUCHAR pOctets,
- IN INT len);
-
-ULONG RTMPMicGetCoefficient(
- IN PMIC_CONTEXT pContext);
-
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a);
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round);
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID RTMPAesEncrypt(
- IN PUCHAR key,
- IN PUCHAR data,
- IN PUCHAR ciphertext);
-
-VOID RTMPMicFinal(
- IN PMIC_CONTEXT pContext,
- OUT UCHAR digest[4]);
-
-VOID RTMPCkipInsertCMIC(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pMIC,
- IN PUCHAR p80211hdr,
- IN PNDIS_PACKET pPacket,
- IN PCIPHER_KEY pKey,
- IN PUCHAR mic_snap);
-
-#endif //__RTMP_CKIPMIC_H__
+#include "../rt2860/rtmp_ckipmic.h"
diff --git a/drivers/staging/rt2870/rtmp_def.h b/drivers/staging/rt2870/rtmp_def.h
index c0f7561a9d9d..839d791b4f62 100644
--- a/drivers/staging/rt2870/rtmp_def.h
+++ b/drivers/staging/rt2870/rtmp_def.h
@@ -1,1622 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_def.h
-
- Abstract:
- Miniport related definition header
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
- John Chang 08-05-2003 add definition for 11g & other drafts
-*/
-#ifndef __RTMP_DEF_H__
-#define __RTMP_DEF_H__
-
-#include "oid.h"
-
-//
-// Debug information verbosity: lower values indicate higher urgency
-//
-#define RT_DEBUG_OFF 0
-#define RT_DEBUG_ERROR 1
-#define RT_DEBUG_WARN 2
-#define RT_DEBUG_TRACE 3
-#define RT_DEBUG_INFO 4
-#define RT_DEBUG_LOUD 5
-
-#define NIC_TAG ((ULONG)'0682')
-#define NIC_DBG_STRING ("**RT28xx**")
-
-#ifdef SNMP_SUPPORT
-// for snmp
-// to get manufacturer OUI, kathy, 2008_0220
-#define ManufacturerOUI_LEN 3
-#define ManufacturerNAME ("Ralink Technology Company.")
-#define ResourceTypeIdName ("Ralink_ID")
-#endif
-
-
-//#define PACKED
-
-#define RALINK_2883_VERSION ((UINT32)0x28830300)
-#define RALINK_2880E_VERSION ((UINT32)0x28720200)
-#define RALINK_3070_VERSION ((UINT32)0x30700200)
-
-//
-// NDIS version in use by the NIC driver.
-// The high byte is the major version. The low byte is the minor version.
-//
-#ifdef NDIS51_MINIPORT
-#define NIC_DRIVER_VERSION 0x0501
-#else
-#define NIC_DRIVER_VERSION 0x0500
-#endif
-
-//
-// NDIS media type, current is ethernet, change if native wireless supported
-//
-#define NIC_MEDIA_TYPE NdisMedium802_3
-#define NIC_PCI_HDR_LENGTH 0xe2
-#define NIC_MAX_PACKET_SIZE 2304
-#define NIC_HEADER_SIZE 14
-#define MAX_MAP_REGISTERS_NEEDED 32
-#define MIN_MAP_REGISTERS_NEEDED 2 //Todo: should consider fragment issue.
-
-//
-// interface type, we use PCI
-//
-#define NIC_INTERFACE_TYPE NdisInterfacePci
-#define NIC_INTERRUPT_MODE NdisInterruptLevelSensitive
-
-//
-// buffer size passed in NdisMQueryAdapterResources
-// We should only need three adapter resources (IO, interrupt and memory),
-// Some devices get extra resources, so have room for 10 resources
-// UF_SIZE (sizeof(NDIS_RESOURCE_LIST) + (10*sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)))
-
-
-#define NIC_RESOURCE_B//
-// IO space length
-//
-#define NIC_MAP_IOSPACE_LENGTH sizeof(CSR_STRUC)
-
-#define MAX_RX_PKT_LEN 1520
-
-//
-// Entry number for each DMA descriptor ring
-//
-
-
-#ifdef RT2870
-#define TX_RING_SIZE 8 // 1
-#define PRIO_RING_SIZE 8
-#define MGMT_RING_SIZE 32 // PRIO_RING_SIZE
-#define RX_RING_SIZE 8
-#define MAX_TX_PROCESS 4
-#define LOCAL_TXBUF_SIZE 2048
-#endif // RT2870 //
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// MC: Multple Cards
-#define MAX_NUM_OF_MULTIPLE_CARD 32
-#endif // MULTIPLE_CARD_SUPPORT //
-
-#define MAX_RX_PROCESS 128 //64 //32
-#define NUM_OF_LOCAL_TXBUF 2
-#define TXD_SIZE 16
-#define TXWI_SIZE 16
-#define RXD_SIZE 16
-#define RXWI_SIZE 16
-// TXINFO_SIZE + TXWI_SIZE + 802.11 Header Size + AMSDU sub frame header
-#define TX_DMA_1ST_BUFFER_SIZE 96 // only the 1st physical buffer is pre-allocated
-#define MGMT_DMA_BUFFER_SIZE 1536 //2048
-#define RX_BUFFER_AGGRESIZE 3840 //3904 //3968 //4096 //2048 //4096
-#define RX_BUFFER_NORMSIZE 3840 //3904 //3968 //4096 //2048 //4096
-#define TX_BUFFER_NORMSIZE RX_BUFFER_NORMSIZE
-#define MAX_FRAME_SIZE 2346 // Maximum 802.11 frame size
-#define MAX_AGGREGATION_SIZE 3840 //3904 //3968 //4096
-#define MAX_NUM_OF_TUPLE_CACHE 2
-#define MAX_MCAST_LIST_SIZE 32
-#define MAX_LEN_OF_VENDOR_DESC 64
-//#define MAX_SIZE_OF_MCAST_PSQ (NUM_OF_LOCAL_TXBUF >> 2) // AP won't spend more than 1/4 of total buffers on M/BCAST PSQ
-#define MAX_SIZE_OF_MCAST_PSQ 32
-
-#define MAX_RX_PROCESS_CNT (RX_RING_SIZE)
-
-
-#define MAX_PACKETS_IN_QUEUE (512) //(512) // to pass WMM A5-WPAPSK
-#define MAX_PACKETS_IN_MCAST_PS_QUEUE 32
-#define MAX_PACKETS_IN_PS_QUEUE 128 //32
-#define WMM_NUM_OF_AC 4 /* AC0, AC1, AC2, and AC3 */
-
-
-
-// RxFilter
-#define STANORMAL 0x17f97
-#define APNORMAL 0x15f97
-//
-// RTMP_ADAPTER flags
-//
-#define fRTMP_ADAPTER_MAP_REGISTER 0x00000001
-#define fRTMP_ADAPTER_INTERRUPT_IN_USE 0x00000002
-#define fRTMP_ADAPTER_HARDWARE_ERROR 0x00000004
-#define fRTMP_ADAPTER_SCATTER_GATHER 0x00000008
-#define fRTMP_ADAPTER_SEND_PACKET_ERROR 0x00000010
-#define fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS 0x00000020
-#define fRTMP_ADAPTER_HALT_IN_PROGRESS 0x00000040
-#define fRTMP_ADAPTER_RESET_IN_PROGRESS 0x00000080
-#define fRTMP_ADAPTER_NIC_NOT_EXIST 0x00000100
-#define fRTMP_ADAPTER_TX_RING_ALLOCATED 0x00000200
-#define fRTMP_ADAPTER_REMOVE_IN_PROGRESS 0x00000400
-#define fRTMP_ADAPTER_MIMORATE_INUSED 0x00000800
-#define fRTMP_ADAPTER_RX_RING_ALLOCATED 0x00001000
-#define fRTMP_ADAPTER_INTERRUPT_ACTIVE 0x00002000
-#define fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS 0x00004000
-#define fRTMP_ADAPTER_REASSOC_IN_PROGRESS 0x00008000
-#define fRTMP_ADAPTER_MEDIA_STATE_PENDING 0x00010000
-#define fRTMP_ADAPTER_RADIO_OFF 0x00020000
-#define fRTMP_ADAPTER_BULKOUT_RESET 0x00040000
-#define fRTMP_ADAPTER_BULKIN_RESET 0x00080000
-#define fRTMP_ADAPTER_RDG_ACTIVE 0x00100000
-#define fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE 0x00200000
-#define fRTMP_ADAPTER_SCAN_2040 0x04000000
-#define fRTMP_ADAPTER_RADIO_MEASUREMENT 0x08000000
-
-#define fRTMP_ADAPTER_START_UP 0x10000000 //Devive already initialized and enabled Tx/Rx.
-#define fRTMP_ADAPTER_MEDIA_STATE_CHANGE 0x20000000
-#define fRTMP_ADAPTER_IDLE_RADIO_OFF 0x40000000
-
-// Lock bit for accessing different ring buffers
-//#define fRTMP_ADAPTER_TX_RING_BUSY 0x80000000
-//#define fRTMP_ADAPTER_MGMT_RING_BUSY 0x40000000
-//#define fRTMP_ADAPTER_ATIM_RING_BUSY 0x20000000
-//#define fRTMP_ADAPTER_RX_RING_BUSY 0x10000000
-
-// Lock bit for accessing different queue
-//#define fRTMP_ADAPTER_TX_QUEUE_BUSY 0x08000000
-//#define fRTMP_ADAPTER_MGMT_QUEUE_BUSY 0x04000000
-
-//
-// STA operation status flags
-//
-#define fOP_STATUS_INFRA_ON 0x00000001
-#define fOP_STATUS_ADHOC_ON 0x00000002
-#define fOP_STATUS_BG_PROTECTION_INUSED 0x00000004
-#define fOP_STATUS_SHORT_SLOT_INUSED 0x00000008
-#define fOP_STATUS_SHORT_PREAMBLE_INUSED 0x00000010
-#define fOP_STATUS_RECEIVE_DTIM 0x00000020
-//#define fOP_STATUS_TX_RATE_SWITCH_ENABLED 0x00000040
-#define fOP_STATUS_MEDIA_STATE_CONNECTED 0x00000080
-#define fOP_STATUS_WMM_INUSED 0x00000100
-#define fOP_STATUS_AGGREGATION_INUSED 0x00000200
-#define fOP_STATUS_DOZE 0x00000400 // debug purpose
-#define fOP_STATUS_PIGGYBACK_INUSED 0x00000800 // piggy-back, and aggregation
-#define fOP_STATUS_APSD_INUSED 0x00001000
-#define fOP_STATUS_TX_AMSDU_INUSED 0x00002000
-#define fOP_STATUS_MAX_RETRY_ENABLED 0x00004000
-#define fOP_STATUS_WAKEUP_NOW 0x00008000
-#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000
-
-#ifdef DOT11N_DRAFT3
-#define fOP_STATUS_SCAN_2040 0x00040000
-#endif // DOT11N_DRAFT3 //
-
-#define CCKSETPROTECT 0x1
-#define OFDMSETPROTECT 0x2
-#define MM20SETPROTECT 0x4
-#define MM40SETPROTECT 0x8
-#define GF20SETPROTECT 0x10
-#define GR40SETPROTECT 0x20
-#define ALLN_SETPROTECT (GR40SETPROTECT | GF20SETPROTECT | MM40SETPROTECT | MM20SETPROTECT)
-
-//
-// AP's client table operation status flags
-//
-#define fCLIENT_STATUS_WMM_CAPABLE 0x00000001 // CLIENT can parse QOS DATA frame
-#define fCLIENT_STATUS_AGGREGATION_CAPABLE 0x00000002 // CLIENT can receive Ralink's proprietary TX aggregation frame
-#define fCLIENT_STATUS_PIGGYBACK_CAPABLE 0x00000004 // CLIENT support piggy-back
-#define fCLIENT_STATUS_AMSDU_INUSED 0x00000008
-#define fCLIENT_STATUS_SGI20_CAPABLE 0x00000010
-#define fCLIENT_STATUS_SGI40_CAPABLE 0x00000020
-#define fCLIENT_STATUS_TxSTBC_CAPABLE 0x00000040
-#define fCLIENT_STATUS_RxSTBC_CAPABLE 0x00000080
-#define fCLIENT_STATUS_HTC_CAPABLE 0x00000100
-#define fCLIENT_STATUS_RDG_CAPABLE 0x00000200
-#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE 0x00000400
-#define fCLIENT_STATUS_APSD_CAPABLE 0x00000800 /* UAPSD STATION */
-
-#ifdef DOT11N_DRAFT3
-#define fCLIENT_STATUS_BSSCOEXIST_CAPABLE 0x00001000
-#endif // DOT11N_DRAFT3 //
-
-#define fCLIENT_STATUS_RALINK_CHIPSET 0x00100000
-//
-// STA configuration flags
-//
-//#define fSTA_CFG_ENABLE_TX_BURST 0x00000001
-
-// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case
-#define HT_NO_PROTECT 0
-#define HT_LEGACY_PROTECT 1
-#define HT_40_PROTECT 2
-#define HT_2040_PROTECT 3
-#define HT_RTSCTS_6M 7
-//following is our own definition in order to turn on our ASIC protection register in INFRASTRUCTURE.
-#define HT_ATHEROS 8 // rt2860c has problem with atheros chip. we need to turn on RTS/CTS .
-#define HT_FORCERTSCTS 9 // Force turn on RTS/CTS first. then go to evaluate if this force RTS is necessary.
-
-//
-// RX Packet Filter control flags. Apply on pAd->PacketFilter
-//
-#define fRX_FILTER_ACCEPT_DIRECT NDIS_PACKET_TYPE_DIRECTED
-#define fRX_FILTER_ACCEPT_MULTICAST NDIS_PACKET_TYPE_MULTICAST
-#define fRX_FILTER_ACCEPT_BROADCAST NDIS_PACKET_TYPE_BROADCAST
-#define fRX_FILTER_ACCEPT_ALL_MULTICAST NDIS_PACKET_TYPE_ALL_MULTICAST
-
-//
-// Error code section
-//
-// NDIS_ERROR_CODE_ADAPTER_NOT_FOUND
-#define ERRLOG_READ_PCI_SLOT_FAILED 0x00000101L
-#define ERRLOG_WRITE_PCI_SLOT_FAILED 0x00000102L
-#define ERRLOG_VENDOR_DEVICE_NOMATCH 0x00000103L
-
-// NDIS_ERROR_CODE_ADAPTER_DISABLED
-#define ERRLOG_BUS_MASTER_DISABLED 0x00000201L
-
-// NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION
-#define ERRLOG_INVALID_SPEED_DUPLEX 0x00000301L
-#define ERRLOG_SET_SECONDARY_FAILED 0x00000302L
-
-// NDIS_ERROR_CODE_OUT_OF_RESOURCES
-#define ERRLOG_OUT_OF_MEMORY 0x00000401L
-#define ERRLOG_OUT_OF_SHARED_MEMORY 0x00000402L
-#define ERRLOG_OUT_OF_MAP_REGISTERS 0x00000403L
-#define ERRLOG_OUT_OF_BUFFER_POOL 0x00000404L
-#define ERRLOG_OUT_OF_NDIS_BUFFER 0x00000405L
-#define ERRLOG_OUT_OF_PACKET_POOL 0x00000406L
-#define ERRLOG_OUT_OF_NDIS_PACKET 0x00000407L
-#define ERRLOG_OUT_OF_LOOKASIDE_MEMORY 0x00000408L
-
-// NDIS_ERROR_CODE_HARDWARE_FAILURE
-#define ERRLOG_SELFTEST_FAILED 0x00000501L
-#define ERRLOG_INITIALIZE_ADAPTER 0x00000502L
-#define ERRLOG_REMOVE_MINIPORT 0x00000503L
-
-// NDIS_ERROR_CODE_RESOURCE_CONFLICT
-#define ERRLOG_MAP_IO_SPACE 0x00000601L
-#define ERRLOG_QUERY_ADAPTER_RESOURCES 0x00000602L
-#define ERRLOG_NO_IO_RESOURCE 0x00000603L
-#define ERRLOG_NO_INTERRUPT_RESOURCE 0x00000604L
-#define ERRLOG_NO_MEMORY_RESOURCE 0x00000605L
-
-
-// WDS definition
-#define MAX_WDS_ENTRY 4
-#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
-
-#define WDS_DISABLE_MODE 0
-#define WDS_RESTRICT_MODE 1
-#define WDS_BRIDGE_MODE 2
-#define WDS_REPEATER_MODE 3
-#define WDS_LAZY_MODE 4
-
-
-#define MAX_MESH_NUM 0
-
-#define MAX_APCLI_NUM 0
-#ifdef APCLI_SUPPORT
-#undef MAX_APCLI_NUM
-#define MAX_APCLI_NUM 1
-#endif // APCLI_SUPPORT //
-
-#define MAX_MBSSID_NUM 1
-
-/* sanity check for apidx */
-#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
- { if (apidx > MAX_MBSSID_NUM) { \
- printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
- apidx = MAIN_MBSSID; } }
-
-#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
-
-#define MAIN_MBSSID 0
-#define FIRST_MBSSID 1
-
-
-#define MAX_BEACON_SIZE 512
-// If the MAX_MBSSID_NUM is larger than 6,
-// it shall reserve some WCID space(wcid 222~253) for beacon frames.
-// - these wcid 238~253 are reserved for beacon#6(ra6).
-// - these wcid 222~237 are reserved for beacon#7(ra7).
-#if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
-#define HW_RESERVED_WCID 222
-#elif defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 7)
-#define HW_RESERVED_WCID 238
-#else
-#define HW_RESERVED_WCID 255
-#endif
-
-// Then dedicate wcid of DFS and Carrier-Sense.
-#define DFS_CTS_WCID (HW_RESERVED_WCID - 1)
-#define CS_CTS_WCID (HW_RESERVED_WCID - 2)
-#define LAST_SPECIFIC_WCID (HW_RESERVED_WCID - 2)
-
-// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211.
-// If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228.
-#define MAX_AVAILABLE_CLIENT_WCID (LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
-
-// TX need WCID to find Cipher Key
-// these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8.
-#define GET_GroupKey_WCID(__wcid, __bssidx) \
- { \
- __wcid = LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM) + __bssidx; \
- }
-
-#define IsGroupKeyWCID(__wcid) (((__wcid) < LAST_SPECIFIC_WCID) && ((__wcid) >= (LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM))))
-
-
-// definition to support multiple BSSID
-#define BSS0 0
-#define BSS1 1
-#define BSS2 2
-#define BSS3 3
-#define BSS4 4
-#define BSS5 5
-#define BSS6 6
-#define BSS7 7
-
-
-//============================================================
-// Length definitions
-#define PEER_KEY_NO 2
-#define MAC_ADDR_LEN 6
-#define TIMESTAMP_LEN 8
-#define MAX_LEN_OF_SUPPORTED_RATES MAX_LENGTH_OF_SUPPORT_RATES // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
-#define MAX_LEN_OF_KEY 32 // 32 octets == 256 bits, Redefine for WPA
-#define MAX_NUM_OF_CHANNELS MAX_NUM_OF_CHS // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
-#define MAX_NUM_OF_11JCHANNELS 20 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
-#define MAX_LEN_OF_SSID 32
-#define CIPHER_TEXT_LEN 128
-#define HASH_TABLE_SIZE 256
-#define MAX_VIE_LEN 1024 // New for WPA cipher suite variable IE sizes.
-#define MAX_SUPPORT_MCS 32
-
-//============================================================
-// ASIC WCID Table definition.
-//============================================================
-#define BSSID_WCID 1 // in infra mode, always put bssid with this WCID
-#define MCAST_WCID 0x0
-#define BSS0Mcast_WCID 0x0
-#define BSS1Mcast_WCID 0xf8
-#define BSS2Mcast_WCID 0xf9
-#define BSS3Mcast_WCID 0xfa
-#define BSS4Mcast_WCID 0xfb
-#define BSS5Mcast_WCID 0xfc
-#define BSS6Mcast_WCID 0xfd
-#define BSS7Mcast_WCID 0xfe
-#define RESERVED_WCID 0xff
-
-#define MAX_NUM_OF_ACL_LIST MAX_NUMBER_OF_ACL
-
-#define MAX_LEN_OF_MAC_TABLE MAX_NUMBER_OF_MAC // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
-
-#if MAX_LEN_OF_MAC_TABLE>MAX_AVAILABLE_CLIENT_WCID
-#error MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!!!!
-#endif
-
-#define MAX_NUM_OF_WDS_LINK_PERBSSID 3
-#define MAX_NUM_OF_WDS_LINK (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
-#define MAX_NUM_OF_EVENT MAX_NUMBER_OF_EVENT
-#define WDS_LINK_START_WCID (MAX_LEN_OF_MAC_TABLE-1)
-
-#define NUM_OF_TID 8
-#define MAX_AID_BA 4
-#define MAX_LEN_OF_BA_REC_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) //Block ACK recipient
-#define MAX_LEN_OF_BA_ORI_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) // Block ACK originator
-#define MAX_LEN_OF_BSS_TABLE 64
-#define MAX_REORDERING_MPDU_NUM 512
-
-// key related definitions
-#define SHARE_KEY_NUM 4
-#define MAX_LEN_OF_SHARE_KEY 16 // byte count
-#define MAX_LEN_OF_PEER_KEY 16 // byte count
-#define PAIRWISE_KEY_NUM 64 // in MAC ASIC pairwise key table
-#define GROUP_KEY_NUM 4
-#define PMK_LEN 32
-#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
-#define PMKID_NO 4 // Number of PMKID saved supported
-#define MAX_LEN_OF_MLME_BUFFER 2048
-
-// power status related definitions
-#define PWR_ACTIVE 0
-#define PWR_SAVE 1
-#define PWR_MMPS 2 //MIMO power save
-//#define PWR_UNKNOWN 2
-
-// Auth and Assoc mode related definitions
-#define AUTH_MODE_OPEN 0x00
-#define AUTH_MODE_KEY 0x01
-//#define AUTH_MODE_AUTO_SWITCH 0x03
-//#define AUTH_MODE_DEAUTH 0x04
-//#define AUTH_MODE_UPLAYER 0x05 // reserved for 802.11i use
-
-// BSS Type definitions
-#define BSS_ADHOC 0 // = Ndis802_11IBSS
-#define BSS_INFRA 1 // = Ndis802_11Infrastructure
-#define BSS_ANY 2 // = Ndis802_11AutoUnknown
-#define BSS_MONITOR 3 // = Ndis802_11Monitor
-
-
-// Reason code definitions
-#define REASON_RESERVED 0
-#define REASON_UNSPECIFY 1
-#define REASON_NO_LONGER_VALID 2
-#define REASON_DEAUTH_STA_LEAVING 3
-#define REASON_DISASSOC_INACTIVE 4
-#define REASON_DISASSPC_AP_UNABLE 5
-#define REASON_CLS2ERR 6
-#define REASON_CLS3ERR 7
-#define REASON_DISASSOC_STA_LEAVING 8
-#define REASON_STA_REQ_ASSOC_NOT_AUTH 9
-#define REASON_INVALID_IE 13
-#define REASON_MIC_FAILURE 14
-#define REASON_4_WAY_TIMEOUT 15
-#define REASON_GROUP_KEY_HS_TIMEOUT 16
-#define REASON_IE_DIFFERENT 17
-#define REASON_MCIPHER_NOT_VALID 18
-#define REASON_UCIPHER_NOT_VALID 19
-#define REASON_AKMP_NOT_VALID 20
-#define REASON_UNSUPPORT_RSNE_VER 21
-#define REASON_INVALID_RSNE_CAP 22
-#define REASON_8021X_AUTH_FAIL 23
-#define REASON_CIPHER_SUITE_REJECTED 24
-#define REASON_DECLINED 37
-
-#define REASON_QOS_UNSPECIFY 32
-#define REASON_QOS_LACK_BANDWIDTH 33
-#define REASON_POOR_CHANNEL_CONDITION 34
-#define REASON_QOS_OUTSIDE_TXOP_LIMITION 35
-#define REASON_QOS_QSTA_LEAVING_QBSS 36
-#define REASON_QOS_UNWANTED_MECHANISM 37
-#define REASON_QOS_MECH_SETUP_REQUIRED 38
-#define REASON_QOS_REQUEST_TIMEOUT 39
-#define REASON_QOS_CIPHER_NOT_SUPPORT 45
-
-// Status code definitions
-#define MLME_SUCCESS 0
-#define MLME_UNSPECIFY_FAIL 1
-#define MLME_CANNOT_SUPPORT_CAP 10
-#define MLME_REASSOC_DENY_ASSOC_EXIST 11
-#define MLME_ASSOC_DENY_OUT_SCOPE 12
-#define MLME_ALG_NOT_SUPPORT 13
-#define MLME_SEQ_NR_OUT_OF_SEQUENCE 14
-#define MLME_REJ_CHALLENGE_FAILURE 15
-#define MLME_REJ_TIMEOUT 16
-#define MLME_ASSOC_REJ_UNABLE_HANDLE_STA 17
-#define MLME_ASSOC_REJ_DATA_RATE 18
-
-#define MLME_ASSOC_REJ_NO_EXT_RATE 22
-#define MLME_ASSOC_REJ_NO_EXT_RATE_PBCC 23
-#define MLME_ASSOC_REJ_NO_CCK_OFDM 24
-
-#define MLME_QOS_UNSPECIFY 32
-#define MLME_REQUEST_DECLINED 37
-#define MLME_REQUEST_WITH_INVALID_PARAM 38
-#define MLME_DLS_NOT_ALLOW_IN_QBSS 48
-#define MLME_DEST_STA_NOT_IN_QBSS 49
-#define MLME_DEST_STA_IS_NOT_A_QSTA 50
-
-#define MLME_INVALID_FORMAT 0x51
-#define MLME_FAIL_NO_RESOURCE 0x52
-#define MLME_STATE_MACHINE_REJECT 0x53
-#define MLME_MAC_TABLE_FAIL 0x54
-
-// IE code
-#define IE_SSID 0
-#define IE_SUPP_RATES 1
-#define IE_FH_PARM 2
-#define IE_DS_PARM 3
-#define IE_CF_PARM 4
-#define IE_TIM 5
-#define IE_IBSS_PARM 6
-#define IE_COUNTRY 7 // 802.11d
-#define IE_802_11D_REQUEST 10 // 802.11d
-#define IE_QBSS_LOAD 11 // 802.11e d9
-#define IE_EDCA_PARAMETER 12 // 802.11e d9
-#define IE_TSPEC 13 // 802.11e d9
-#define IE_TCLAS 14 // 802.11e d9
-#define IE_SCHEDULE 15 // 802.11e d9
-#define IE_CHALLENGE_TEXT 16
-#define IE_POWER_CONSTRAINT 32 // 802.11h d3.3
-#define IE_POWER_CAPABILITY 33 // 802.11h d3.3
-#define IE_TPC_REQUEST 34 // 802.11h d3.3
-#define IE_TPC_REPORT 35 // 802.11h d3.3
-#define IE_SUPP_CHANNELS 36 // 802.11h d3.3
-#define IE_CHANNEL_SWITCH_ANNOUNCEMENT 37 // 802.11h d3.3
-#define IE_MEASUREMENT_REQUEST 38 // 802.11h d3.3
-#define IE_MEASUREMENT_REPORT 39 // 802.11h d3.3
-#define IE_QUIET 40 // 802.11h d3.3
-#define IE_IBSS_DFS 41 // 802.11h d3.3
-#define IE_ERP 42 // 802.11g
-#define IE_TS_DELAY 43 // 802.11e d9
-#define IE_TCLAS_PROCESSING 44 // 802.11e d9
-#define IE_QOS_CAPABILITY 46 // 802.11e d6
-#define IE_HT_CAP 45 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
-#define IE_AP_CHANNEL_REPORT 51 // 802.11k d6
-#define IE_HT_CAP2 52 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
-#define IE_RSN 48 // 802.11i d3.0
-#define IE_WPA2 48 // WPA2
-#define IE_EXT_SUPP_RATES 50 // 802.11g
-#define IE_SUPP_REG_CLASS 59 // 802.11y. Supported regulatory classes.
-#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT 60 // 802.11n
-#define IE_ADD_HT 61 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
-#define IE_ADD_HT2 53 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
-
-
-// For 802.11n D3.03
-//#define IE_NEW_EXT_CHA_OFFSET 62 // 802.11n d1. New extension channel offset elemet
-#define IE_SECONDARY_CH_OFFSET 62 // 802.11n D3.03 Secondary Channel Offset element
-#define IE_WAPI 68 // WAPI information element
-#define IE_2040_BSS_COEXIST 72 // 802.11n D3.0.3
-#define IE_2040_BSS_INTOLERANT_REPORT 73 // 802.11n D3.03
-#define IE_OVERLAPBSS_SCAN_PARM 74 // 802.11n D3.03
-#define IE_EXT_CAPABILITY 127 // 802.11n D3.03
-
-
-#define IE_WPA 221 // WPA
-#define IE_VENDOR_SPECIFIC 221 // Wifi WMM (WME)
-
-#define OUI_BROADCOM_HT 51 //
-#define OUI_BROADCOM_HTADD 52 //
-#define OUI_PREN_HT_CAP 51 //
-#define OUI_PREN_ADD_HT 52 //
-
-// CCX information
-#define IE_AIRONET_CKIP 133 // CCX1.0 ID 85H for CKIP
-#define IE_AP_TX_POWER 150 // CCX 2.0 for AP transmit power
-#define IE_MEASUREMENT_CAPABILITY 221 // CCX 2.0
-#define IE_CCX_V2 221
-#define IE_AIRONET_IPADDRESS 149 // CCX ID 95H for IP Address
-#define IE_AIRONET_CCKMREASSOC 156 // CCX ID 9CH for CCKM Reassociation Request element
-#define CKIP_NEGOTIATION_LENGTH 30
-#define AIRONET_IPADDRESS_LENGTH 10
-#define AIRONET_CCKMREASSOC_LENGTH 24
-
-// ========================================================
-// MLME state machine definition
-// ========================================================
-
-// STA MLME state mahcines
-#define ASSOC_STATE_MACHINE 1
-#define AUTH_STATE_MACHINE 2
-#define AUTH_RSP_STATE_MACHINE 3
-#define SYNC_STATE_MACHINE 4
-#define MLME_CNTL_STATE_MACHINE 5
-#define WPA_PSK_STATE_MACHINE 6
-#define LEAP_STATE_MACHINE 7
-#define AIRONET_STATE_MACHINE 8
-#define ACTION_STATE_MACHINE 9
-
-// AP MLME state machines
-#define AP_ASSOC_STATE_MACHINE 11
-#define AP_AUTH_STATE_MACHINE 12
-#define AP_AUTH_RSP_STATE_MACHINE 13
-#define AP_SYNC_STATE_MACHINE 14
-#define AP_CNTL_STATE_MACHINE 15
-#define AP_WPA_STATE_MACHINE 16
-
-#ifdef QOS_DLS_SUPPORT
-#define DLS_STATE_MACHINE 26
-#endif // QOS_DLS_SUPPORT //
-
-//
-// STA's CONTROL/CONNECT state machine: states, events, total function #
-//
-#define CNTL_IDLE 0
-#define CNTL_WAIT_DISASSOC 1
-#define CNTL_WAIT_JOIN 2
-#define CNTL_WAIT_REASSOC 3
-#define CNTL_WAIT_START 4
-#define CNTL_WAIT_AUTH 5
-#define CNTL_WAIT_ASSOC 6
-#define CNTL_WAIT_AUTH2 7
-#define CNTL_WAIT_OID_LIST_SCAN 8
-#define CNTL_WAIT_OID_DISASSOC 9
-#ifdef RT2870
-#define CNTL_WAIT_SCAN_FOR_CONNECT 10
-#endif // RT2870 //
-
-#define MT2_ASSOC_CONF 34
-#define MT2_AUTH_CONF 35
-#define MT2_DEAUTH_CONF 36
-#define MT2_DISASSOC_CONF 37
-#define MT2_REASSOC_CONF 38
-#define MT2_PWR_MGMT_CONF 39
-#define MT2_JOIN_CONF 40
-#define MT2_SCAN_CONF 41
-#define MT2_START_CONF 42
-#define MT2_GET_CONF 43
-#define MT2_SET_CONF 44
-#define MT2_RESET_CONF 45
-#define MT2_MLME_ROAMING_REQ 52
-
-#define CNTL_FUNC_SIZE 1
-
-//
-// STA's ASSOC state machine: states, events, total function #
-//
-#define ASSOC_IDLE 0
-#define ASSOC_WAIT_RSP 1
-#define REASSOC_WAIT_RSP 2
-#define DISASSOC_WAIT_RSP 3
-#define MAX_ASSOC_STATE 4
-
-#define ASSOC_MACHINE_BASE 0
-#define MT2_MLME_ASSOC_REQ 0
-#define MT2_MLME_REASSOC_REQ 1
-#define MT2_MLME_DISASSOC_REQ 2
-#define MT2_PEER_DISASSOC_REQ 3
-#define MT2_PEER_ASSOC_REQ 4
-#define MT2_PEER_ASSOC_RSP 5
-#define MT2_PEER_REASSOC_REQ 6
-#define MT2_PEER_REASSOC_RSP 7
-#define MT2_DISASSOC_TIMEOUT 8
-#define MT2_ASSOC_TIMEOUT 9
-#define MT2_REASSOC_TIMEOUT 10
-#define MAX_ASSOC_MSG 11
-
-#define ASSOC_FUNC_SIZE (MAX_ASSOC_STATE * MAX_ASSOC_MSG)
-
-//
-// ACT state machine: states, events, total function #
-//
-#define ACT_IDLE 0
-#define MAX_ACT_STATE 1
-
-#define ACT_MACHINE_BASE 0
-
-//Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please don'es modify it by your self.
-//Category
-#define MT2_PEER_SPECTRUM_CATE 0
-#define MT2_PEER_QOS_CATE 1
-#define MT2_PEER_DLS_CATE 2
-#define MT2_PEER_BA_CATE 3
-#define MT2_PEER_PUBLIC_CATE 4
-#define MT2_PEER_RM_CATE 5
-#define MT2_PEER_HT_CATE 7 // 7.4.7
-#define MAX_PEER_CATE_MSG 7
-#define MT2_MLME_ADD_BA_CATE 8
-#define MT2_MLME_ORI_DELBA_CATE 9
-#define MT2_MLME_REC_DELBA_CATE 10
-#define MT2_MLME_QOS_CATE 11
-#define MT2_MLME_DLS_CATE 12
-#define MT2_ACT_INVALID 13
-#define MAX_ACT_MSG 14
-
-//Category field
-#define CATEGORY_SPECTRUM 0
-#define CATEGORY_QOS 1
-#define CATEGORY_DLS 2
-#define CATEGORY_BA 3
-#define CATEGORY_PUBLIC 4
-#define CATEGORY_RM 5
-#define CATEGORY_HT 7
-
-
-// DLS Action frame definition
-#define ACTION_DLS_REQUEST 0
-#define ACTION_DLS_RESPONSE 1
-#define ACTION_DLS_TEARDOWN 2
-
-//Spectrum Action field value 802.11h 7.4.1
-#define SPEC_MRQ 0 // Request
-#define SPEC_MRP 1 //Report
-#define SPEC_TPCRQ 2
-#define SPEC_TPCRP 3
-#define SPEC_CHANNEL_SWITCH 4
-
-
-//BA Action field value
-#define ADDBA_REQ 0
-#define ADDBA_RESP 1
-#define DELBA 2
-
-//Public's Action field value in Public Category. Some in 802.11y and some in 11n
-#define ACTION_BSS_2040_COEXIST 0 // 11n
-#define ACTION_DSE_ENABLEMENT 1 // 11y D9.0
-#define ACTION_DSE_DEENABLEMENT 2 // 11y D9.0
-#define ACTION_DSE_REG_LOCATION_ANNOUNCE 3 // 11y D9.0
-#define ACTION_EXT_CH_SWITCH_ANNOUNCE 4 // 11y D9.0
-#define ACTION_DSE_MEASUREMENT_REQ 5 // 11y D9.0
-#define ACTION_DSE_MEASUREMENT_REPORT 6 // 11y D9.0
-#define ACTION_MEASUREMENT_PILOT_ACTION 7 // 11y D9.0
-#define ACTION_DSE_POWER_CONSTRAINT 8 // 11y D9.0
-
-
-//HT Action field value
-#define NOTIFY_BW_ACTION 0
-#define SMPS_ACTION 1
-#define PSMP_ACTION 2
-#define SETPCO_ACTION 3
-#define MIMO_CHA_MEASURE_ACTION 4
-#define MIMO_N_BEACONFORM 5
-#define MIMO_BEACONFORM 6
-#define ANTENNA_SELECT 7
-#define HT_INFO_EXCHANGE 8
-
-#define ACT_FUNC_SIZE (MAX_ACT_STATE * MAX_ACT_MSG)
-//
-// STA's AUTHENTICATION state machine: states, evvents, total function #
-//
-#define AUTH_REQ_IDLE 0
-#define AUTH_WAIT_SEQ2 1
-#define AUTH_WAIT_SEQ4 2
-#define MAX_AUTH_STATE 3
-
-#define AUTH_MACHINE_BASE 0
-#define MT2_MLME_AUTH_REQ 0
-#define MT2_PEER_AUTH_EVEN 1
-#define MT2_AUTH_TIMEOUT 2
-#define MAX_AUTH_MSG 3
-
-#define AUTH_FUNC_SIZE (MAX_AUTH_STATE * MAX_AUTH_MSG)
-
-//
-// STA's AUTH_RSP state machine: states, events, total function #
-//
-#define AUTH_RSP_IDLE 0
-#define AUTH_RSP_WAIT_CHAL 1
-#define MAX_AUTH_RSP_STATE 2
-
-#define AUTH_RSP_MACHINE_BASE 0
-#define MT2_AUTH_CHALLENGE_TIMEOUT 0
-#define MT2_PEER_AUTH_ODD 1
-#define MT2_PEER_DEAUTH 2
-#define MAX_AUTH_RSP_MSG 3
-
-#define AUTH_RSP_FUNC_SIZE (MAX_AUTH_RSP_STATE * MAX_AUTH_RSP_MSG)
-
-//
-// STA's SYNC state machine: states, events, total function #
-//
-#define SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define JOIN_WAIT_BEACON 1
-#define SCAN_LISTEN 2
-#define MAX_SYNC_STATE 3
-
-#define SYNC_MACHINE_BASE 0
-#define MT2_MLME_SCAN_REQ 0
-#define MT2_MLME_JOIN_REQ 1
-#define MT2_MLME_START_REQ 2
-#define MT2_PEER_BEACON 3
-#define MT2_PEER_PROBE_RSP 4
-#define MT2_PEER_ATIM 5
-#define MT2_SCAN_TIMEOUT 6
-#define MT2_BEACON_TIMEOUT 7
-#define MT2_ATIM_TIMEOUT 8
-#define MT2_PEER_PROBE_REQ 9
-#define MAX_SYNC_MSG 10
-
-#define SYNC_FUNC_SIZE (MAX_SYNC_STATE * MAX_SYNC_MSG)
-
-//Messages for the DLS state machine
-#define DLS_IDLE 0
-#define MAX_DLS_STATE 1
-
-#define DLS_MACHINE_BASE 0
-#define MT2_MLME_DLS_REQ 0
-#define MT2_PEER_DLS_REQ 1
-#define MT2_PEER_DLS_RSP 2
-#define MT2_MLME_DLS_TEAR_DOWN 3
-#define MT2_PEER_DLS_TEAR_DOWN 4
-#define MAX_DLS_MSG 5
-
-#define DLS_FUNC_SIZE (MAX_DLS_STATE * MAX_DLS_MSG)
-
-//
-// STA's WPA-PSK State machine: states, events, total function #
-//
-#define WPA_PSK_IDLE 0
-#define MAX_WPA_PSK_STATE 1
-
-#define WPA_MACHINE_BASE 0
-#define MT2_EAPPacket 0
-#define MT2_EAPOLStart 1
-#define MT2_EAPOLLogoff 2
-#define MT2_EAPOLKey 3
-#define MT2_EAPOLASFAlert 4
-#define MAX_WPA_PSK_MSG 5
-
-#define WPA_PSK_FUNC_SIZE (MAX_WPA_PSK_STATE * MAX_WPA_PSK_MSG)
-
-//
-// STA's CISCO-AIRONET State machine: states, events, total function #
-//
-#define AIRONET_IDLE 0
-#define AIRONET_SCANNING 1
-#define MAX_AIRONET_STATE 2
-
-#define AIRONET_MACHINE_BASE 0
-#define MT2_AIRONET_MSG 0
-#define MT2_AIRONET_SCAN_REQ 1
-#define MT2_AIRONET_SCAN_DONE 2
-#define MAX_AIRONET_MSG 3
-
-#define AIRONET_FUNC_SIZE (MAX_AIRONET_STATE * MAX_AIRONET_MSG)
-
-//
-// AP's CONTROL/CONNECT state machine: states, events, total function #
-//
-#define AP_CNTL_FUNC_SIZE 1
-
-//
-// AP's ASSOC state machine: states, events, total function #
-//
-#define AP_ASSOC_IDLE 0
-#define AP_MAX_ASSOC_STATE 1
-
-#define AP_ASSOC_MACHINE_BASE 0
-#define APMT2_MLME_DISASSOC_REQ 0
-#define APMT2_PEER_DISASSOC_REQ 1
-#define APMT2_PEER_ASSOC_REQ 2
-#define APMT2_PEER_REASSOC_REQ 3
-#define APMT2_CLS3ERR 4
-#define AP_MAX_ASSOC_MSG 5
-
-#define AP_ASSOC_FUNC_SIZE (AP_MAX_ASSOC_STATE * AP_MAX_ASSOC_MSG)
-
-//
-// AP's AUTHENTICATION state machine: states, events, total function #
-//
-#define AP_AUTH_REQ_IDLE 0
-#define AP_MAX_AUTH_STATE 1
-
-#define AP_AUTH_MACHINE_BASE 0
-#define APMT2_MLME_DEAUTH_REQ 0
-#define APMT2_CLS2ERR 1
-#define AP_MAX_AUTH_MSG 2
-
-#define AP_AUTH_FUNC_SIZE (AP_MAX_AUTH_STATE * AP_MAX_AUTH_MSG)
-
-//
-// AP's AUTH-RSP state machine: states, events, total function #
-//
-#define AP_AUTH_RSP_IDLE 0
-#define AP_MAX_AUTH_RSP_STATE 1
-
-#define AP_AUTH_RSP_MACHINE_BASE 0
-#define APMT2_AUTH_CHALLENGE_TIMEOUT 0
-#define APMT2_PEER_AUTH_ODD 1
-#define APMT2_PEER_DEAUTH 2
-#define AP_MAX_AUTH_RSP_MSG 3
-
-#define AP_AUTH_RSP_FUNC_SIZE (AP_MAX_AUTH_RSP_STATE * AP_MAX_AUTH_RSP_MSG)
-
-//
-// AP's SYNC state machine: states, events, total function #
-//
-#define AP_SYNC_IDLE 0
-#define AP_SCAN_LISTEN 1
-#define AP_MAX_SYNC_STATE 2
-
-#define AP_SYNC_MACHINE_BASE 0
-#define APMT2_PEER_PROBE_REQ 0
-#define APMT2_PEER_BEACON 1
-#define APMT2_MLME_SCAN_REQ 2
-#define APMT2_PEER_PROBE_RSP 3
-#define APMT2_SCAN_TIMEOUT 4
-#define APMT2_MLME_SCAN_CNCL 5
-#define AP_MAX_SYNC_MSG 6
-
-#define AP_SYNC_FUNC_SIZE (AP_MAX_SYNC_STATE * AP_MAX_SYNC_MSG)
-
-//
-// AP's WPA state machine: states, events, total function #
-//
-#define AP_WPA_PTK 0
-#define AP_MAX_WPA_PTK_STATE 1
-
-#define AP_WPA_MACHINE_BASE 0
-#define APMT2_EAPPacket 0
-#define APMT2_EAPOLStart 1
-#define APMT2_EAPOLLogoff 2
-#define APMT2_EAPOLKey 3
-#define APMT2_EAPOLASFAlert 4
-#define AP_MAX_WPA_MSG 5
-
-#define AP_WPA_FUNC_SIZE (AP_MAX_WPA_PTK_STATE * AP_MAX_WPA_MSG)
-
-#ifdef APCLI_SUPPORT
-//ApCli authentication state machine
-#define APCLI_AUTH_REQ_IDLE 0
-#define APCLI_AUTH_WAIT_SEQ2 1
-#define APCLI_AUTH_WAIT_SEQ4 2
-#define APCLI_MAX_AUTH_STATE 3
-
-#define APCLI_AUTH_MACHINE_BASE 0
-#define APCLI_MT2_MLME_AUTH_REQ 0
-#define APCLI_MT2_MLME_DEAUTH_REQ 1
-#define APCLI_MT2_PEER_AUTH_EVEN 2
-#define APCLI_MT2_PEER_DEAUTH 3
-#define APCLI_MT2_AUTH_TIMEOUT 4
-#define APCLI_MAX_AUTH_MSG 5
-
-#define APCLI_AUTH_FUNC_SIZE (APCLI_MAX_AUTH_STATE * APCLI_MAX_AUTH_MSG)
-
-//ApCli association state machine
-#define APCLI_ASSOC_IDLE 0
-#define APCLI_ASSOC_WAIT_RSP 1
-#define APCLI_MAX_ASSOC_STATE 2
-
-#define APCLI_ASSOC_MACHINE_BASE 0
-#define APCLI_MT2_MLME_ASSOC_REQ 0
-#define APCLI_MT2_MLME_DISASSOC_REQ 1
-#define APCLI_MT2_PEER_DISASSOC_REQ 2
-#define APCLI_MT2_PEER_ASSOC_RSP 3
-#define APCLI_MT2_ASSOC_TIMEOUT 4
-#define APCLI_MAX_ASSOC_MSG 5
-
-#define APCLI_ASSOC_FUNC_SIZE (APCLI_MAX_ASSOC_STATE * APCLI_MAX_ASSOC_MSG)
-
-//ApCli sync state machine
-#define APCLI_SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define APCLI_JOIN_WAIT_PROBE_RSP 1
-#define APCLI_MAX_SYNC_STATE 2
-
-#define APCLI_SYNC_MACHINE_BASE 0
-#define APCLI_MT2_MLME_PROBE_REQ 0
-#define APCLI_MT2_PEER_PROBE_RSP 1
-#define APCLI_MT2_PROBE_TIMEOUT 2
-#define APCLI_MAX_SYNC_MSG 3
-
-#define APCLI_SYNC_FUNC_SIZE (APCLI_MAX_SYNC_STATE * APCLI_MAX_SYNC_MSG)
-
-//ApCli ctrl state machine
-#define APCLI_CTRL_DISCONNECTED 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define APCLI_CTRL_PROBE 1
-#define APCLI_CTRL_AUTH 2
-#define APCLI_CTRL_AUTH_2 3
-#define APCLI_CTRL_ASSOC 4
-#define APCLI_CTRL_DEASSOC 5
-#define APCLI_CTRL_CONNECTED 6
-#define APCLI_MAX_CTRL_STATE 7
-
-#define APCLI_CTRL_MACHINE_BASE 0
-#define APCLI_CTRL_JOIN_REQ 0
-#define APCLI_CTRL_PROBE_RSP 1
-#define APCLI_CTRL_AUTH_RSP 2
-#define APCLI_CTRL_DISCONNECT_REQ 3
-#define APCLI_CTRL_PEER_DISCONNECT_REQ 4
-#define APCLI_CTRL_ASSOC_RSP 5
-#define APCLI_CTRL_DEASSOC_RSP 6
-#define APCLI_CTRL_JOIN_REQ_TIMEOUT 7
-#define APCLI_CTRL_AUTH_REQ_TIMEOUT 8
-#define APCLI_CTRL_ASSOC_REQ_TIMEOUT 9
-#define APCLI_MAX_CTRL_MSG 10
-
-#define APCLI_CTRL_FUNC_SIZE (APCLI_MAX_CTRL_STATE * APCLI_MAX_CTRL_MSG)
-
-#if 0 // remove those variables by AlbertY
-// ApCli WPA state machine
-#define APCLI_WPA_PSK_IDLE 0
-#define APCLI_MAX_WPA_PSK_STATE 1
-
-// ApCli WPA MSG Type
-#define APCLI_WPA_MACHINE_BASE 0
-#define APCLI_MT2_EAPPacket 0
-#define APCLI_MT2_EAPOLStart 1
-#define APCLI_MT2_EAPOLLogoff 2
-#define APCLI_MT2_EAPOLKey 3
-#define APCLI_MT2_EAPOLASFAlert 4
-#define APCLI_MAX_WPA_PSK_MSG 5
-
-#define APCLI_WPA_PSK_FUNC_SIZE (APCLI_MAX_WPA_PSK_STATE * APCLI_MAX_WPA_PSK_MSG)
-#endif // end - 0 //
-
-#endif // APCLI_SUPPORT //
-
-
-// =============================================================================
-
-// value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header
-#define BTYPE_MGMT 0
-#define BTYPE_CNTL 1
-#define BTYPE_DATA 2
-
-// value domain of 802.11 MGMT frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_ASSOC_REQ 0
-#define SUBTYPE_ASSOC_RSP 1
-#define SUBTYPE_REASSOC_REQ 2
-#define SUBTYPE_REASSOC_RSP 3
-#define SUBTYPE_PROBE_REQ 4
-#define SUBTYPE_PROBE_RSP 5
-#define SUBTYPE_BEACON 8
-#define SUBTYPE_ATIM 9
-#define SUBTYPE_DISASSOC 10
-#define SUBTYPE_AUTH 11
-#define SUBTYPE_DEAUTH 12
-#define SUBTYPE_ACTION 13
-#define SUBTYPE_ACTION_NO_ACK 14
-
-// value domain of 802.11 CNTL frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_WRAPPER 7
-#define SUBTYPE_BLOCK_ACK_REQ 8
-#define SUBTYPE_BLOCK_ACK 9
-#define SUBTYPE_PS_POLL 10
-#define SUBTYPE_RTS 11
-#define SUBTYPE_CTS 12
-#define SUBTYPE_ACK 13
-#define SUBTYPE_CFEND 14
-#define SUBTYPE_CFEND_CFACK 15
-
-// value domain of 802.11 DATA frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_DATA 0
-#define SUBTYPE_DATA_CFACK 1
-#define SUBTYPE_DATA_CFPOLL 2
-#define SUBTYPE_DATA_CFACK_CFPOLL 3
-#define SUBTYPE_NULL_FUNC 4
-#define SUBTYPE_CFACK 5
-#define SUBTYPE_CFPOLL 6
-#define SUBTYPE_CFACK_CFPOLL 7
-#define SUBTYPE_QDATA 8
-#define SUBTYPE_QDATA_CFACK 9
-#define SUBTYPE_QDATA_CFPOLL 10
-#define SUBTYPE_QDATA_CFACK_CFPOLL 11
-#define SUBTYPE_QOS_NULL 12
-#define SUBTYPE_QOS_CFACK 13
-#define SUBTYPE_QOS_CFPOLL 14
-#define SUBTYPE_QOS_CFACK_CFPOLL 15
-
-// ACK policy of QOS Control field bit 6:5
-#define NORMAL_ACK 0x00 // b6:5 = 00
-#define NO_ACK 0x20 // b6:5 = 01
-#define NO_EXPLICIT_ACK 0x40 // b6:5 = 10
-#define BLOCK_ACK 0x60 // b6:5 = 11
-
-//
-// rtmp_data.c use these definition
-//
-#define LENGTH_802_11 24
-#define LENGTH_802_11_AND_H 30
-#define LENGTH_802_11_CRC_H 34
-#define LENGTH_802_11_CRC 28
-#define LENGTH_802_11_WITH_ADDR4 30
-#define LENGTH_802_3 14
-#define LENGTH_802_3_TYPE 2
-#define LENGTH_802_1_H 8
-#define LENGTH_EAPOL_H 4
-#define LENGTH_WMMQOS_H 2
-#define LENGTH_CRC 4
-#define MAX_SEQ_NUMBER 0x0fff
-#define LENGTH_802_3_NO_TYPE 12
-#define LENGTH_802_1Q 4 /* VLAN related */
-
-// STA_CSR4.field.TxResult
-#define TX_RESULT_SUCCESS 0
-#define TX_RESULT_ZERO_LENGTH 1
-#define TX_RESULT_UNDER_RUN 2
-#define TX_RESULT_OHY_ERROR 4
-#define TX_RESULT_RETRY_FAIL 6
-
-// All PHY rate summary in TXD
-// Preamble MODE in TxD
-#define MODE_CCK 0
-#define MODE_OFDM 1
-#ifdef DOT11_N_SUPPORT
-#define MODE_HTMIX 2
-#define MODE_HTGREENFIELD 3
-#endif // DOT11_N_SUPPORT //
-// MCS for CCK. BW.SGI.STBC are reserved
-#define MCS_LONGP_RATE_1 0 // long preamble CCK 1Mbps
-#define MCS_LONGP_RATE_2 1 // long preamble CCK 1Mbps
-#define MCS_LONGP_RATE_5_5 2
-#define MCS_LONGP_RATE_11 3
-#define MCS_SHORTP_RATE_1 4 // long preamble CCK 1Mbps. short is forbidden in 1Mbps
-#define MCS_SHORTP_RATE_2 5 // short preamble CCK 2Mbps
-#define MCS_SHORTP_RATE_5_5 6
-#define MCS_SHORTP_RATE_11 7
-// To send duplicate legacy OFDM. set BW=BW_40. SGI.STBC are reserved
-#define MCS_RATE_6 0 // legacy OFDM
-#define MCS_RATE_9 1 // OFDM
-#define MCS_RATE_12 2 // OFDM
-#define MCS_RATE_18 3 // OFDM
-#define MCS_RATE_24 4 // OFDM
-#define MCS_RATE_36 5 // OFDM
-#define MCS_RATE_48 6 // OFDM
-#define MCS_RATE_54 7 // OFDM
-// HT
-#define MCS_0 0 // 1S
-#define MCS_1 1
-#define MCS_2 2
-#define MCS_3 3
-#define MCS_4 4
-#define MCS_5 5
-#define MCS_6 6
-#define MCS_7 7
-#define MCS_8 8 // 2S
-#define MCS_9 9
-#define MCS_10 10
-#define MCS_11 11
-#define MCS_12 12
-#define MCS_13 13
-#define MCS_14 14
-#define MCS_15 15
-#define MCS_16 16 // 3*3
-#define MCS_17 17
-#define MCS_18 18
-#define MCS_19 19
-#define MCS_20 20
-#define MCS_21 21
-#define MCS_22 22
-#define MCS_23 23
-#define MCS_32 32
-#define MCS_AUTO 33
-
-#ifdef DOT11_N_SUPPORT
-// OID_HTPHYMODE
-// MODE
-#define HTMODE_MM 0
-#define HTMODE_GF 1
-#endif // DOT11_N_SUPPORT //
-
-// Fixed Tx MODE - HT, CCK or OFDM
-#define FIXED_TXMODE_HT 0
-#define FIXED_TXMODE_CCK 1
-#define FIXED_TXMODE_OFDM 2
-// BW
-#define BW_20 BAND_WIDTH_20
-#define BW_40 BAND_WIDTH_40
-#define BW_BOTH BAND_WIDTH_BOTH
-#define BW_10 BAND_WIDTH_10 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-
-#ifdef DOT11_N_SUPPORT
-// SHORTGI
-#define GI_400 GAP_INTERVAL_400 // only support in HT mode
-#define GI_BOTH GAP_INTERVAL_BOTH
-#endif // DOT11_N_SUPPORT //
-#define GI_800 GAP_INTERVAL_800
-// STBC
-#define STBC_NONE 0
-#ifdef DOT11_N_SUPPORT
-#define STBC_USE 1 // limited use in rt2860b phy
-#define RXSTBC_ONE 1 // rx support of one spatial stream
-#define RXSTBC_TWO 2 // rx support of 1 and 2 spatial stream
-#define RXSTBC_THR 3 // rx support of 1~3 spatial stream
-// MCS FEEDBACK
-#define MCSFBK_NONE 0 // not support mcs feedback /
-#define MCSFBK_RSV 1 // reserved
-#define MCSFBK_UNSOLICIT 2 // only support unsolict mcs feedback
-#define MCSFBK_MRQ 3 // response to both MRQ and unsolict mcs feedback
-
-// MIMO power safe
-#define MMPS_STATIC 0
-#define MMPS_DYNAMIC 1
-#define MMPS_RSV 2
-#define MMPS_ENABLE 3
-
-
-// A-MSDU size
-#define AMSDU_0 0
-#define AMSDU_1 1
-
-#endif // DOT11_N_SUPPORT //
-
-// MCS use 7 bits
-#define TXRATEMIMO 0x80
-#define TXRATEMCS 0x7F
-#define TXRATEOFDM 0x7F
-#define RATE_1 0
-#define RATE_2 1
-#define RATE_5_5 2
-#define RATE_11 3
-#define RATE_6 4 // OFDM
-#define RATE_9 5 // OFDM
-#define RATE_12 6 // OFDM
-#define RATE_18 7 // OFDM
-#define RATE_24 8 // OFDM
-#define RATE_36 9 // OFDM
-#define RATE_48 10 // OFDM
-#define RATE_54 11 // OFDM
-#define RATE_FIRST_OFDM_RATE RATE_6
-#define RATE_LAST_OFDM_RATE RATE_54
-#define RATE_6_5 12 // HT mix
-#define RATE_13 13 // HT mix
-#define RATE_19_5 14 // HT mix
-#define RATE_26 15 // HT mix
-#define RATE_39 16 // HT mix
-#define RATE_52 17 // HT mix
-#define RATE_58_5 18 // HT mix
-#define RATE_65 19 // HT mix
-#define RATE_78 20 // HT mix
-#define RATE_104 21 // HT mix
-#define RATE_117 22 // HT mix
-#define RATE_130 23 // HT mix
-//#define RATE_AUTO_SWITCH 255 // for StaCfg.FixedTxRate only
-#define HTRATE_0 12
-#define RATE_FIRST_MM_RATE HTRATE_0
-#define RATE_FIRST_HT_RATE HTRATE_0
-#define RATE_LAST_HT_RATE HTRATE_0
-
-// pTxWI->txop
-#define IFS_HTTXOP 0 // The txop will be handles by ASIC.
-#define IFS_PIFS 1
-#define IFS_SIFS 2
-#define IFS_BACKOFF 3
-
-// pTxD->RetryMode
-#define LONG_RETRY 1
-#define SHORT_RETRY 0
-
-// Country Region definition
-#define REGION_MINIMUM_BG_BAND 0
-#define REGION_0_BG_BAND 0 // 1-11
-#define REGION_1_BG_BAND 1 // 1-13
-#define REGION_2_BG_BAND 2 // 10-11
-#define REGION_3_BG_BAND 3 // 10-13
-#define REGION_4_BG_BAND 4 // 14
-#define REGION_5_BG_BAND 5 // 1-14
-#define REGION_6_BG_BAND 6 // 3-9
-#define REGION_7_BG_BAND 7 // 5-13
-#define REGION_31_BG_BAND 31 // 5-13
-#define REGION_MAXIMUM_BG_BAND 7
-
-#define REGION_MINIMUM_A_BAND 0
-#define REGION_0_A_BAND 0 // 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165
-#define REGION_1_A_BAND 1 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
-#define REGION_2_A_BAND 2 // 36, 40, 44, 48, 52, 56, 60, 64
-#define REGION_3_A_BAND 3 // 52, 56, 60, 64, 149, 153, 157, 161
-#define REGION_4_A_BAND 4 // 149, 153, 157, 161, 165
-#define REGION_5_A_BAND 5 // 149, 153, 157, 161
-#define REGION_6_A_BAND 6 // 36, 40, 44, 48
-#define REGION_7_A_BAND 7 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_8_A_BAND 8 // 52, 56, 60, 64
-#define REGION_9_A_BAND 9 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_10_A_BAND 10 // 36, 40, 44, 48, 149, 153, 157, 161, 165
-#define REGION_11_A_BAND 11 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
-#define REGION_MAXIMUM_A_BAND 11
-
-// pTxD->CipherAlg
-#define CIPHER_NONE 0
-#define CIPHER_WEP64 1
-#define CIPHER_WEP128 2
-#define CIPHER_TKIP 3
-#define CIPHER_AES 4
-#define CIPHER_CKIP64 5
-#define CIPHER_CKIP128 6
-#define CIPHER_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
-#define CIPHER_SMS4 8
-
-// value domain of pAd->RfIcType
-#define RFIC_2820 1 // 2.4G 2T3R
-#define RFIC_2850 2 // 2.4G/5G 2T3R
-#define RFIC_2720 3 // 2.4G 1T2R
-#define RFIC_2750 4 // 2.4G/5G 1T2R
-#define RFIC_3020 5 // 2.4G 1T1R
-#define RFIC_2020 6 // 2.4G B/G
-
-// LED Status.
-#define LED_LINK_DOWN 0
-#define LED_LINK_UP 1
-#define LED_RADIO_OFF 2
-#define LED_RADIO_ON 3
-#define LED_HALT 4
-#define LED_WPS 5
-#define LED_ON_SITE_SURVEY 6
-#define LED_POWER_UP 7
-
-// value domain of pAd->LedCntl.LedMode and E2PROM
-#define LED_MODE_DEFAULT 0
-#define LED_MODE_TWO_LED 1
-#define LED_MODE_SIGNAL_STREGTH 8 // EEPROM define =8
-
-// RC4 init value, used fro WEP & TKIP
-#define PPPINITFCS32 0xffffffff /* Initial FCS value */
-
-// value domain of pAd->StaCfg.PortSecured. 802.1X controlled port definition
-#define WPA_802_1X_PORT_SECURED 1
-#define WPA_802_1X_PORT_NOT_SECURED 2
-
-#define PAIRWISE_KEY 1
-#define GROUP_KEY 2
-
-//definition of DRS
-#define MAX_STEP_OF_TX_RATE_SWITCH 32
-
-
-// pre-allocated free NDIS PACKET/BUFFER poll for internal usage
-#define MAX_NUM_OF_FREE_NDIS_PACKET 128
-
-//Block ACK
-#define MAX_TX_REORDERBUF 64
-#define MAX_RX_REORDERBUF 64
-#define DEFAULT_TX_TIMEOUT 30
-#define DEFAULT_RX_TIMEOUT 30
-
-// definition of Recipient or Originator
-#define I_RECIPIENT TRUE
-#define I_ORIGINATOR FALSE
-
-#define DEFAULT_BBP_TX_POWER 0
-#define DEFAULT_RF_TX_POWER 5
-
-#define MAX_INI_BUFFER_SIZE 4096
-#define MAX_PARAM_BUFFER_SIZE (2048) // enough for ACL (18*64)
- //18 : the length of Mac address acceptable format "01:02:03:04:05:06;")
- //64 : MAX_NUM_OF_ACL_LIST
-// definition of pAd->OpMode
-#define OPMODE_STA 0
-#define OPMODE_AP 1
-//#define OPMODE_L3_BRG 2 // as AP and STA at the same time
-
-#ifdef RT_BIG_ENDIAN
-#define DIR_READ 0
-#define DIR_WRITE 1
-#define TYPE_TXD 0
-#define TYPE_RXD 1
-#define TYPE_TXINFO 0
-#define TYPE_RXINFO 1
-#define TYPE_TXWI 0
-#define TYPE_RXWI 1
-#endif
-
-// ========================= AP rtmp_def.h ===========================
-// value domain for pAd->EventTab.Log[].Event
-#define EVENT_RESET_ACCESS_POINT 0 // Log = "hh:mm:ss Restart Access Point"
-#define EVENT_ASSOCIATED 1 // Log = "hh:mm:ss STA 00:01:02:03:04:05 associated"
-#define EVENT_DISASSOCIATED 2 // Log = "hh:mm:ss STA 00:01:02:03:04:05 left this BSS"
-#define EVENT_AGED_OUT 3 // Log = "hh:mm:ss STA 00:01:02:03:04:05 was aged-out and removed from this BSS"
-#define EVENT_COUNTER_M 4
-#define EVENT_INVALID_PSK 5
-#define EVENT_MAX_EVENT_TYPE 6
-// ==== end of AP rtmp_def.h ============
-
-// definition RSSI Number
-#define RSSI_0 0
-#define RSSI_1 1
-#define RSSI_2 2
-
-// definition of radar detection
-#define RD_NORMAL_MODE 0 // Not found radar signal
-#define RD_SWITCHING_MODE 1 // Found radar signal, and doing channel switch
-#define RD_SILENCE_MODE 2 // After channel switch, need to be silence a while to ensure radar not found
-
-//Driver defined cid for mapping status and command.
-#define SLEEPCID 0x11
-#define WAKECID 0x22
-#define QUERYPOWERCID 0x33
-#define OWNERMCU 0x1
-#define OWNERCPU 0x0
-
-// MBSSID definition
-#define ENTRY_NOT_FOUND 0xFF
-
-
-/* After Linux 2.6.9,
- * VLAN module use Private (from user) interface flags (netdevice->priv_flags).
- * #define IFF_802_1Q_VLAN 0x1 -- 802.1Q VLAN device. in if.h
- * ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
- *
- * For this reason, we MUST use EVEN value in priv_flags
- */
-#define INT_MAIN 0x0100
-#define INT_MBSSID 0x0200
-#define INT_WDS 0x0300
-#define INT_APCLI 0x0400
-#define INT_MESH 0x0500
-
-// Use bitmap to allow coexist of ATE_TXFRAME and ATE_RXFRAME(i.e.,to support LoopBack mode)
-#ifdef RALINK_ATE
-#define ATE_START 0x00 // Start ATE
-#define ATE_STOP 0x80 // Stop ATE
-#define ATE_TXCONT 0x05 // Continuous Transmit
-#define ATE_TXCARR 0x09 // Transmit Carrier
-#define ATE_TXCARRSUPP 0x11 // Transmit Carrier Suppression
-#define ATE_TXFRAME 0x01 // Transmit Frames
-#define ATE_RXFRAME 0x02 // Receive Frames
-#ifdef RALINK_28xx_QA
-#define ATE_TXSTOP 0xe2 // Stop Transmition(i.e., TXCONT, TXCARR, TXCARRSUPP, and TXFRAME)
-#define ATE_RXSTOP 0xfd // Stop receiving Frames
-#define BBP22_TXFRAME 0x00 // Transmit Frames
-#define BBP22_TXCONT_OR_CARRSUPP 0x80 // Continuous Transmit or Carrier Suppression
-#define BBP22_TXCARR 0xc1 // Transmit Carrier
-#define BBP24_TXCONT 0x00 // Continuous Transmit
-#define BBP24_CARRSUPP 0x01 // Carrier Suppression
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-// WEP Key TYPE
-#define WEP_HEXADECIMAL_TYPE 0
-#define WEP_ASCII_TYPE 1
-
-
-
-// WIRELESS EVENTS definition
-/* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
-#define IW_CUSTOM_MAX_LEN 255 /* In bytes */
-
-// For system event - start
-#define IW_SYS_EVENT_FLAG_START 0x0200
-#define IW_ASSOC_EVENT_FLAG 0x0200
-#define IW_DISASSOC_EVENT_FLAG 0x0201
-#define IW_DEAUTH_EVENT_FLAG 0x0202
-#define IW_AGEOUT_EVENT_FLAG 0x0203
-#define IW_COUNTER_MEASURES_EVENT_FLAG 0x0204
-#define IW_REPLAY_COUNTER_DIFF_EVENT_FLAG 0x0205
-#define IW_RSNIE_DIFF_EVENT_FLAG 0x0206
-#define IW_MIC_DIFF_EVENT_FLAG 0x0207
-#define IW_ICV_ERROR_EVENT_FLAG 0x0208
-#define IW_MIC_ERROR_EVENT_FLAG 0x0209
-#define IW_GROUP_HS_TIMEOUT_EVENT_FLAG 0x020A
-#define IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG 0x020B
-#define IW_RSNIE_SANITY_FAIL_EVENT_FLAG 0x020C
-#define IW_SET_KEY_DONE_WPA1_EVENT_FLAG 0x020D
-#define IW_SET_KEY_DONE_WPA2_EVENT_FLAG 0x020E
-#define IW_STA_LINKUP_EVENT_FLAG 0x020F
-#define IW_STA_LINKDOWN_EVENT_FLAG 0x0210
-#define IW_SCAN_COMPLETED_EVENT_FLAG 0x0211
-#define IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG 0x0212
-// if add new system event flag, please upadte the IW_SYS_EVENT_FLAG_END
-#define IW_SYS_EVENT_FLAG_END 0x0212
-#define IW_SYS_EVENT_TYPE_NUM (IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
-// For system event - end
-
-// For spoof attack event - start
-#define IW_SPOOF_EVENT_FLAG_START 0x0300
-#define IW_CONFLICT_SSID_EVENT_FLAG 0x0300
-#define IW_SPOOF_ASSOC_RESP_EVENT_FLAG 0x0301
-#define IW_SPOOF_REASSOC_RESP_EVENT_FLAG 0x0302
-#define IW_SPOOF_PROBE_RESP_EVENT_FLAG 0x0303
-#define IW_SPOOF_BEACON_EVENT_FLAG 0x0304
-#define IW_SPOOF_DISASSOC_EVENT_FLAG 0x0305
-#define IW_SPOOF_AUTH_EVENT_FLAG 0x0306
-#define IW_SPOOF_DEAUTH_EVENT_FLAG 0x0307
-#define IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG 0x0308
-#define IW_REPLAY_ATTACK_EVENT_FLAG 0x0309
-// if add new spoof attack event flag, please upadte the IW_SPOOF_EVENT_FLAG_END
-#define IW_SPOOF_EVENT_FLAG_END 0x0309
-#define IW_SPOOF_EVENT_TYPE_NUM (IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
-// For spoof attack event - end
-
-// For flooding attack event - start
-#define IW_FLOOD_EVENT_FLAG_START 0x0400
-#define IW_FLOOD_AUTH_EVENT_FLAG 0x0400
-#define IW_FLOOD_ASSOC_REQ_EVENT_FLAG 0x0401
-#define IW_FLOOD_REASSOC_REQ_EVENT_FLAG 0x0402
-#define IW_FLOOD_PROBE_REQ_EVENT_FLAG 0x0403
-#define IW_FLOOD_DISASSOC_EVENT_FLAG 0x0404
-#define IW_FLOOD_DEAUTH_EVENT_FLAG 0x0405
-#define IW_FLOOD_EAP_REQ_EVENT_FLAG 0x0406
-// if add new flooding attack event flag, please upadte the IW_FLOOD_EVENT_FLAG_END
-#define IW_FLOOD_EVENT_FLAG_END 0x0406
-#define IW_FLOOD_EVENT_TYPE_NUM (IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
-// For flooding attack - end
-
-// End - WIRELESS EVENTS definition
-
-#ifdef CONFIG_STA_SUPPORT
-// definition for DLS, kathy
-#define MAX_NUM_OF_INIT_DLS_ENTRY 1
-#define MAX_NUM_OF_DLS_ENTRY MAX_NUMBER_OF_DLS_ENTRY
-
-//Block ACK , rt2860, kathy
-#define MAX_TX_REORDERBUF 64
-#define MAX_RX_REORDERBUF 64
-#define DEFAULT_TX_TIMEOUT 30
-#define DEFAULT_RX_TIMEOUT 30
-#ifndef CONFIG_AP_SUPPORT
-#define MAX_BARECI_SESSION 8
-#endif
-
-#ifndef IW_ESSID_MAX_SIZE
-/* Maximum size of the ESSID and pAd->nickname strings */
-#define IW_ESSID_MAX_SIZE 32
-#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef MCAST_RATE_SPECIFIC
-#define MCAST_DISABLE 0
-#define MCAST_CCK 1
-#define MCAST_OFDM 2
-#define MCAST_HTMIX 3
-#endif // MCAST_RATE_SPECIFIC //
-
-// For AsicRadioOff/AsicRadioOn function
-#define DOT11POWERSAVE 0
-#define GUIRADIO_OFF 1
-#define RTMP_HALT 2
-#define GUI_IDLE_POWER_SAVE 3
-// --
-
-
-// definition for WpaSupport flag
-#define WPA_SUPPLICANT_DISABLE 0
-#define WPA_SUPPLICANT_ENABLE 1
-#define WPA_SUPPLICANT_ENABLE_WITH_WEB_UI 2
-
-// Endian byte swapping codes
-#define SWAP16(x) \
- ((UINT16)( \
- (((UINT16)(x) & (UINT16) 0x00ffU) << 8) | \
- (((UINT16)(x) & (UINT16) 0xff00U) >> 8) ))
-
-#define SWAP32(x) \
- ((UINT32)( \
- (((UINT32)(x) & (UINT32) 0x000000ffUL) << 24) | \
- (((UINT32)(x) & (UINT32) 0x0000ff00UL) << 8) | \
- (((UINT32)(x) & (UINT32) 0x00ff0000UL) >> 8) | \
- (((UINT32)(x) & (UINT32) 0xff000000UL) >> 24) ))
-
-#define SWAP64(x) \
- ((UINT64)( \
- (UINT64)(((UINT64)(x) & (UINT64) 0x00000000000000ffULL) << 56) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x000000000000ff00ULL) << 40) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x0000000000ff0000ULL) << 24) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x00000000ff000000ULL) << 8) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x000000ff00000000ULL) >> 8) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
-
-#ifdef RT_BIG_ENDIAN
-
-#define cpu2le64(x) SWAP64((x))
-#define le2cpu64(x) SWAP64((x))
-#define cpu2le32(x) SWAP32((x))
-#define le2cpu32(x) SWAP32((x))
-#define cpu2le16(x) SWAP16((x))
-#define le2cpu16(x) SWAP16((x))
-#define cpu2be64(x) ((UINT64)(x))
-#define be2cpu64(x) ((UINT64)(x))
-#define cpu2be32(x) ((UINT32)(x))
-#define be2cpu32(x) ((UINT32)(x))
-#define cpu2be16(x) ((UINT16)(x))
-#define be2cpu16(x) ((UINT16)(x))
-
-#else // Little_Endian
-
-#define cpu2le64(x) ((UINT64)(x))
-#define le2cpu64(x) ((UINT64)(x))
-#define cpu2le32(x) ((UINT32)(x))
-#define le2cpu32(x) ((UINT32)(x))
-#define cpu2le16(x) ((UINT16)(x))
-#define le2cpu16(x) ((UINT16)(x))
-#define cpu2be64(x) SWAP64((x))
-#define be2cpu64(x) SWAP64((x))
-#define cpu2be32(x) SWAP32((x))
-#define be2cpu32(x) SWAP32((x))
-#define cpu2be16(x) SWAP16((x))
-#define be2cpu16(x) SWAP16((x))
-
-#endif // RT_BIG_ENDIAN
-
-#endif // __RTMP_DEF_H__
-
-
+#include "../rt2860/rtmp_def.h"
diff --git a/drivers/staging/rt2870/rtmp_type.h b/drivers/staging/rt2870/rtmp_type.h
index 1fd7df1e1791..fbf97d0fa5d3 100644
--- a/drivers/staging/rt2870/rtmp_type.h
+++ b/drivers/staging/rt2870/rtmp_type.h
@@ -1,94 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_type.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 1-2-2004
-*/
-#ifndef __RTMP_TYPE_H__
-#define __RTMP_TYPE_H__
-
-#define PACKED __attribute__ ((packed))
-
-// Put platform dependent declaration here
-// For example, linux type definition
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned int UINT32;
-typedef unsigned long long UINT64;
-typedef int INT32;
-typedef long long INT64;
-
-typedef unsigned char * PUINT8;
-typedef unsigned short * PUINT16;
-typedef unsigned int * PUINT32;
-typedef unsigned long long * PUINT64;
-typedef int * PINT32;
-typedef long long * PINT64;
-
-typedef signed char CHAR;
-typedef signed short SHORT;
-typedef signed int INT;
-typedef signed long LONG;
-typedef signed long long LONGLONG;
-
-
-typedef unsigned char UCHAR;
-typedef unsigned short USHORT;
-typedef unsigned int UINT;
-typedef unsigned long ULONG;
-typedef unsigned long long ULONGLONG;
-
-typedef unsigned char BOOLEAN;
-typedef void VOID;
-
-typedef VOID * PVOID;
-typedef CHAR * PCHAR;
-typedef UCHAR * PUCHAR;
-typedef USHORT * PUSHORT;
-typedef LONG * PLONG;
-typedef ULONG * PULONG;
-typedef UINT * PUINT;
-
-typedef unsigned int NDIS_MEDIA_STATE;
-
-typedef union _LARGE_INTEGER {
- struct {
- UINT LowPart;
- INT32 HighPart;
- } u;
- INT64 QuadPart;
-} LARGE_INTEGER;
-
-#endif // __RTMP_TYPE_H__
-
+#include "../rt2860/rtmp_type.h"
diff --git a/drivers/staging/rt2870/spectrum.h b/drivers/staging/rt2870/spectrum.h
index 94cfa5b174fc..8aa23a1833b1 100644
--- a/drivers/staging/rt2870/spectrum.h
+++ b/drivers/staging/rt2870/spectrum.h
@@ -1,322 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __SPECTRUM_H__
-#define __SPECTRUM_H__
-
-#include "rtmp_type.h"
-#include "spectrum_def.h"
-
-typedef struct PACKED _TPC_REPORT_INFO
-{
- UINT8 TxPwr;
- UINT8 LinkMargin;
-} TPC_REPORT_INFO, *PTPC_REPORT_INFO;
-
-typedef struct PACKED _CH_SW_ANN_INFO
-{
- UINT8 ChSwMode;
- UINT8 Channel;
- UINT8 ChSwCnt;
-} CH_SW_ANN_INFO, *PCH_SW_ANN_INFO;
-
-typedef union PACKED _MEASURE_REQ_MODE
-{
-#ifdef RT_BIG_ENDIAN
- struct PACKED
- {
- UINT8 Rev1:4;
- UINT8 Report:1;
- UINT8 Request:1;
- UINT8 Enable:1;
- UINT8 Rev0:1;
- } field;
-#else
- struct PACKED
- {
- UINT8 Rev0:1;
- UINT8 Enable:1;
- UINT8 Request:1;
- UINT8 Report:1;
- UINT8 Rev1:4;
- } field;
-#endif // RT_BIG_ENDIAN //
- UINT8 word;
-} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
-
-typedef struct PACKED _MEASURE_REQ
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
-} MEASURE_REQ, *PMEASURE_REQ;
-
-typedef struct PACKED _MEASURE_REQ_INFO
-{
- UINT8 Token;
- MEASURE_REQ_MODE ReqMode;
- UINT8 ReqType;
- MEASURE_REQ MeasureReq;
-} MEASURE_REQ_INFO, *PMEASURE_REQ_INFO;
-
-typedef union PACKED _MEASURE_BASIC_REPORT_MAP
-{
-#ifdef RT_BIG_ENDIAN
- struct PACKED
- {
- UINT8 Rev:3;
- UINT8 Unmeasure:1;
- UINT8 Radar:1;
- UINT8 UnidentifiedSignal:1;
- UINT8 OfdmPreamble:1;
- UINT8 BSS:1;
- } field;
-#else
- struct PACKED
- {
- UINT8 BSS:1;
- UINT8 OfdmPreamble:1;
- UINT8 UnidentifiedSignal:1;
- UINT8 Radar:1;
- UINT8 Unmeasure:1;
- UINT8 Rev:3;
- } field;
-#endif // RT_BIG_ENDIAN //
- UINT8 word;
-} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
-
-typedef struct PACKED _MEASURE_BASIC_REPORT
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
- MEASURE_BASIC_REPORT_MAP Map;
-} MEASURE_BASIC_REPORT, *PMEASURE_BASIC_REPORT;
-
-typedef struct PACKED _MEASURE_CCA_REPORT
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
- UINT8 CCA_Busy_Fraction;
-} MEASURE_CCA_REPORT, *PMEASURE_CCA_REPORT;
-
-typedef struct PACKED _MEASURE_RPI_REPORT
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
- UINT8 RPI_Density[8];
-} MEASURE_RPI_REPORT, *PMEASURE_RPI_REPORT;
-
-typedef union PACKED _MEASURE_REPORT_MODE
-{
- struct PACKED
- {
-#ifdef RT_BIG_ENDIAN
- UINT8 Rev:5;
- UINT8 Refused:1;
- UINT8 Incapable:1;
- UINT8 Late:1;
-#else
- UINT8 Late:1;
- UINT8 Incapable:1;
- UINT8 Refused:1;
- UINT8 Rev:5;
-#endif // RT_BIG_ENDIAN //
- } field;
- UINT8 word;
-} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
-
-typedef struct PACKED _MEASURE_REPORT_INFO
-{
- UINT8 Token;
- MEASURE_REPORT_MODE ReportMode;
- UINT8 ReportType;
- UINT8 Octect[0];
-} MEASURE_REPORT_INFO, *PMEASURE_REPORT_INFO;
-
-typedef struct PACKED _QUIET_INFO
-{
- UINT8 QuietCnt;
- UINT8 QuietPeriod;
- UINT8 QuietDuration;
- UINT8 QuietOffset;
-} QUIET_INFO, *PQUIET_INFO;
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 MeasureCh,
- IN UINT16 MeasureDuration);
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 ReportInfoLen,
- IN PUINT8 pReportInfo);
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UCHAR DialogToken);
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 TxPwr,
- IN UINT8 LinkMargin);
-
-/*
- ==========================================================================
- Description:
- Prepare Channel Switch Announcement action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
- 2. Channel switch announcement mode.
- 2. a New selected channel.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueChSwAnn(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 ChSwMode,
- IN UINT8 NewCh);
-
-/*
- ==========================================================================
- Description:
- Spectrun action frames Handler such as channel switch annoucement,
- measurement report, measurement request actions frames.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-VOID PeerSpectrumAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-/*
- ==========================================================================
- Description:
-
- Parametrs:
-
- Return : None.
- ==========================================================================
- */
-INT Set_MeasureReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TpcReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-VOID MeasureReqTabInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID MeasureReqTabExit(
- IN PRTMP_ADAPTER pAd);
-
-VOID TpcReqTabInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID TpcReqTabExit(
- IN PRTMP_ADAPTER pAd);
-
-VOID NotifyChSwAnnToPeerAPs(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pRA,
- IN PUCHAR pTA,
- IN UINT8 ChSwMode,
- IN UINT8 Channel);
-#endif // __SPECTRUM_H__ //
-
+#include "../rt2860/spectrum.h"
diff --git a/drivers/staging/rt2870/spectrum_def.h b/drivers/staging/rt2870/spectrum_def.h
index 4ca4817bba05..a65f551e3918 100644
--- a/drivers/staging/rt2870/spectrum_def.h
+++ b/drivers/staging/rt2870/spectrum_def.h
@@ -1,95 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- spectrum_def.h
-
- Abstract:
- Handle association related requests either from WSTA or from local MLME
-
- Revision History:
- Who When What
- --------- ---------- ----------------------------------------------
- Fonchi Wu 2008 created for 802.11h
- */
-
-#ifndef __SPECTRUM_DEF_H__
-#define __SPECTRUM_DEF_H__
-
-#define MAX_MEASURE_REQ_TAB_SIZE 3
-#define MAX_HASH_MEASURE_REQ_TAB_SIZE MAX_MEASURE_REQ_TAB_SIZE
-
-#define MAX_TPC_REQ_TAB_SIZE 3
-#define MAX_HASH_TPC_REQ_TAB_SIZE MAX_TPC_REQ_TAB_SIZE
-
-#define MIN_RCV_PWR 100 /* Negative value ((dBm) */
-
-#define RM_TPC_REQ 0
-#define RM_MEASURE_REQ 1
-
-#define RM_BASIC 0
-#define RM_CCA 1
-#define RM_RPI_HISTOGRAM 2
-
-#define TPC_REQ_AGE_OUT 500 /* ms */
-#define MQ_REQ_AGE_OUT 500 /* ms */
-
-#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
-#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
-
-typedef struct _MEASURE_REQ_ENTRY
-{
- struct _MEASURE_REQ_ENTRY *pNext;
- ULONG lastTime;
- BOOLEAN Valid;
- UINT8 DialogToken;
- UINT8 MeasureDialogToken[3]; // 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure.
-} MEASURE_REQ_ENTRY, *PMEASURE_REQ_ENTRY;
-
-typedef struct _MEASURE_REQ_TAB
-{
- UCHAR Size;
- PMEASURE_REQ_ENTRY Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
- MEASURE_REQ_ENTRY Content[MAX_MEASURE_REQ_TAB_SIZE];
-} MEASURE_REQ_TAB, *PMEASURE_REQ_TAB;
-
-typedef struct _TPC_REQ_ENTRY
-{
- struct _TPC_REQ_ENTRY *pNext;
- ULONG lastTime;
- BOOLEAN Valid;
- UINT8 DialogToken;
-} TPC_REQ_ENTRY, *PTPC_REQ_ENTRY;
-
-typedef struct _TPC_REQ_TAB
-{
- UCHAR Size;
- PTPC_REQ_ENTRY Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
- TPC_REQ_ENTRY Content[MAX_TPC_REQ_TAB_SIZE];
-} TPC_REQ_TAB, *PTPC_REQ_TAB;
-
-#endif // __SPECTRUM_DEF_H__ //
-
+#include "../rt2860/spectrum_def.h"
diff --git a/drivers/staging/rt2870/sta/aironet.c b/drivers/staging/rt2870/sta/aironet.c
index 4af4a1906181..72b7f2e6bf7f 100644
--- a/drivers/staging/rt2870/sta/aironet.c
+++ b/drivers/staging/rt2870/sta/aironet.c
@@ -1,1312 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- aironet.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 04-06-15 Initial
-*/
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
- ==========================================================================
- */
-VOID AironetStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_AIRONET_STATE, MAX_AIRONET_MSG, (STATE_MACHINE_FUNC)Drop, AIRONET_IDLE, AIRONET_MACHINE_BASE);
- StateMachineSetAction(S, AIRONET_IDLE, MT2_AIRONET_MSG, (STATE_MACHINE_FUNC)AironetMsgAction);
- StateMachineSetAction(S, AIRONET_IDLE, MT2_AIRONET_SCAN_REQ, (STATE_MACHINE_FUNC)AironetRequestAction);
- StateMachineSetAction(S, AIRONET_SCANNING, MT2_AIRONET_SCAN_DONE, (STATE_MACHINE_FUNC)AironetReportAction);
-}
-
-/*
- ==========================================================================
- Description:
- This is state machine function.
- When receiving EAPOL packets which is for 802.1x key management.
- Use both in WPA, and WPAPSK case.
- In this function, further dispatch to different functions according to the received packet. 3 categories are :
- 1. normal 4-way pairwisekey and 2-way groupkey handshake
- 2. MIC error (Countermeasures attack) report packet from STA.
- 3. Request for pairwise/group key update from STA
- Return:
- ==========================================================================
-*/
-VOID AironetMsgAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Length;
- UCHAR Index, i;
- PUCHAR pData;
- PAIRONET_RM_REQUEST_FRAME pRMReq;
- PRM_REQUEST_ACTION pReqElem;
-
- DBGPRINT(RT_DEBUG_TRACE, ("-----> AironetMsgAction\n"));
-
- // 0. Get Aironet IAPP header first
- pRMReq = (PAIRONET_RM_REQUEST_FRAME) &Elem->Msg[LENGTH_802_11];
- pData = (PUCHAR) &Elem->Msg[LENGTH_802_11];
-
- // 1. Change endian format form network to little endian
- Length = be2cpu16(pRMReq->IAPP.Length);
-
- // 2.0 Sanity check, this should only happen when CCX 2.0 support is enabled
- if (pAd->StaCfg.CCXEnable != TRUE)
- return;
-
- // 2.1 Radio measurement must be on
- if (pAd->StaCfg.CCXControl.field.RMEnable != 1)
- return;
-
- // 2.2. Debug print all bit information
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP ID & Length %d\n", Length));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Type %x\n", pRMReq->IAPP.Type));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP SubType %x\n", pRMReq->IAPP.SubType));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Dialog Token %x\n", pRMReq->IAPP.Token));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Activation Delay %x\n", pRMReq->Delay));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Measurement Offset %x\n", pRMReq->Offset));
-
- // 3. Check IAPP frame type, it must be 0x32 for Cisco Aironet extension
- if (pRMReq->IAPP.Type != AIRONET_IAPP_TYPE)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP type for Cisco Aironet extension\n"));
- return;
- }
-
- // 4. Check IAPP frame subtype, it must be 0x01 for Cisco Aironet extension request.
- // Since we are acting as client only, we will disregards reply subtype.
- if (pRMReq->IAPP.SubType != AIRONET_IAPP_SUBTYPE_REQUEST)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP subtype for Cisco Aironet extension\n"));
- return;
- }
-
- // 5. Verify Destination MAC and Source MAC, both should be all zeros.
- if (! MAC_ADDR_EQUAL(pRMReq->IAPP.DA, ZERO_MAC_ADDR))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP DA for Cisco Aironet extension, it's not Zero\n"));
- return;
- }
-
- if (! MAC_ADDR_EQUAL(pRMReq->IAPP.SA, ZERO_MAC_ADDR))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP SA for Cisco Aironet extension, it's not Zero\n"));
- return;
- }
-
- // 6. Reinit all report related fields
- NdisZeroMemory(pAd->StaCfg.FrameReportBuf, 2048);
- NdisZeroMemory(pAd->StaCfg.BssReportOffset, sizeof(USHORT) * MAX_LEN_OF_BSS_TABLE);
- NdisZeroMemory(pAd->StaCfg.MeasurementRequest, sizeof(RM_REQUEST_ACTION) * 4);
-
- // 7. Point to the start of first element report element
- pAd->StaCfg.FrameReportLen = LENGTH_802_11 + sizeof(AIRONET_IAPP_HEADER);
- DBGPRINT(RT_DEBUG_TRACE, ("FR len = %d\n", pAd->StaCfg.FrameReportLen));
- pAd->StaCfg.LastBssIndex = 0xff;
- pAd->StaCfg.RMReqCnt = 0;
- pAd->StaCfg.ParallelReq = FALSE;
- pAd->StaCfg.ParallelDuration = 0;
- pAd->StaCfg.ParallelChannel = 0;
- pAd->StaCfg.IAPPToken = pRMReq->IAPP.Token;
- pAd->StaCfg.CurrentRMReqIdx = 0;
- pAd->StaCfg.CLBusyBytes = 0;
- // Reset the statistics
- for (i = 0; i < 8; i++)
- pAd->StaCfg.RPIDensity[i] = 0;
-
- Index = 0;
-
- // 8. Save dialog token for report
- pAd->StaCfg.IAPPToken = pRMReq->IAPP.Token;
-
- // Save Activation delay & measurement offset, Not really needed
-
- // 9. Point to the first request element
- pData += sizeof(AIRONET_RM_REQUEST_FRAME);
- // Length should exclude the CISCO Aironet SNAP header
- Length -= (sizeof(AIRONET_RM_REQUEST_FRAME) - LENGTH_802_1_H);
-
- // 10. Start Parsing the Measurement elements.
- // Be careful about multiple MR elements within one frames.
- while (Length > 0)
- {
- pReqElem = (PRM_REQUEST_ACTION) pData;
- switch (pReqElem->ReqElem.Eid)
- {
- case IE_MEASUREMENT_REQUEST:
- // From the example, it seems we only need to support one request in one frame
- // There is no multiple request in one frame.
- // Besides, looks like we need to take care the measurement request only.
- // The measurement request is always 4 bytes.
-
- // Start parsing this type of request.
- // 0. Eid is IE_MEASUREMENT_REQUEST
- // 1. Length didn't include Eid and Length field, it always be 8.
- // 2. Measurement Token, we nned to save it for the corresponding report.
- // 3. Measurement Mode, Although there are definitions, but we din't see value other than
- // 0 from test specs examples.
- // 4. Measurement Type, this is what we need to do.
- switch (pReqElem->ReqElem.Type)
- {
- case MSRN_TYPE_CHANNEL_LOAD_REQ:
- case MSRN_TYPE_NOISE_HIST_REQ:
- case MSRN_TYPE_BEACON_REQ:
- // Check the Enable non-serving channel measurement control
- if (pAd->StaCfg.CCXControl.field.DCRMEnable == 0)
- {
- // Check channel before enqueue the action
- if (pReqElem->Measurement.Channel != pAd->CommonCfg.Channel)
- break;
- }
- else
- {
- // If off channel measurement, check the TU duration limit
- if (pReqElem->Measurement.Channel != pAd->CommonCfg.Channel)
- if (pReqElem->Measurement.Duration > pAd->StaCfg.CCXControl.field.TuLimit)
- break;
- }
-
- // Save requests and execute actions later
- NdisMoveMemory(&pAd->StaCfg.MeasurementRequest[Index], pReqElem, sizeof(RM_REQUEST_ACTION));
- Index += 1;
- break;
-
- case MSRN_TYPE_FRAME_REQ:
- // Since it's option, we will support later
- // FrameRequestAction(pAd, pData);
- break;
-
- default:
- break;
- }
-
- // Point to next Measurement request
- pData += sizeof(RM_REQUEST_ACTION);
- Length -= sizeof(RM_REQUEST_ACTION);
- break;
-
- // We accept request only, all others are dropped
- case IE_MEASUREMENT_REPORT:
- case IE_AP_TX_POWER:
- case IE_MEASUREMENT_CAPABILITY:
- default:
- return;
- }
- }
-
- // 11. Update some flags and index
- pAd->StaCfg.RMReqCnt = Index;
-
- if (Index)
- {
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<----- AironetMsgAction\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID AironetRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRM_REQUEST_ACTION pReq;
-
- // 1. Point to next request element
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- // 2. Parse measurement type and call appropriate functions
- if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
- // Channel Load measurement request
- ChannelLoadRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
- // Noise Histogram measurement request
- NoiseHistRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_BEACON_REQ)
- // Beacon measurement request
- BeaconRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else
- // Unknown. Do nothing and return, this should never happen
- return;
-
- // 3. Peek into the next request, if it's parallel, we will update the scan time to the largest one
- if ((pAd->StaCfg.CurrentRMReqIdx + 1) < pAd->StaCfg.RMReqCnt)
- {
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx + 1];
- // Check for parallel bit
- if ((pReq->ReqElem.Mode & 0x01) && (pReq->Measurement.Channel == pAd->StaCfg.CCXScanChannel))
- {
- // Update parallel mode request information
- pAd->StaCfg.ParallelReq = TRUE;
- pAd->StaCfg.CCXScanTime = ((pReq->Measurement.Duration > pAd->StaCfg.CCXScanTime) ?
- (pReq->Measurement.Duration) : (pAd->StaCfg.CCXScanTime));
- }
- }
-
- // 4. Call RT28XX_MLME_HANDLER to execute the request mlme commands, Scan request is the only one used
- RT28XX_MLME_HANDLER(pAd);
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare channel load report action, special scan operation added
- to support
-
- Arguments:
- pAd Pointer to our adapter
- pData Start from element ID
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ChannelLoadRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PRM_REQUEST_ACTION pReq;
- MLME_SCAN_REQ_STRUCT ScanReq;
- UCHAR ZeroSsid[32];
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- PHEADER_802_11 pNullFrame;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadRequestAction ----->\n"));
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
- NdisZeroMemory(ZeroSsid, 32);
-
- // Prepare for special scan request
- // The scan definition is different with our Active, Passive scan definition.
- // For CCX2, Active means send out probe request with broadcast BSSID.
- // Passive means no probe request sent, only listen to the beacons.
- // The channel scanned is fixed as specified, no need to scan all channels.
- // The scan wait time is specified in the request too.
- // Passive scan Mode
-
- // Control state machine is not idle, reject the request
- if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_CHANNEL_LOAD);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- pAd->StaCfg.CCXReqType = MSRN_TYPE_CHANNEL_LOAD_REQ;
- pAd->StaCfg.CLBusyBytes = 0;
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, 0x1010);
-
- // Set channel load measurement flag
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadRequestAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare noise histogram report action, special scan operation added
- to support
-
- Arguments:
- pAd Pointer to our adapter
- pData Start from element ID
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID NoiseHistRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PRM_REQUEST_ACTION pReq;
- MLME_SCAN_REQ_STRUCT ScanReq;
- UCHAR ZeroSsid[32], i;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- PHEADER_802_11 pNullFrame;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistRequestAction ----->\n"));
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
- NdisZeroMemory(ZeroSsid, 32);
-
- // Prepare for special scan request
- // The scan definition is different with our Active, Passive scan definition.
- // For CCX2, Active means send out probe request with broadcast BSSID.
- // Passive means no probe request sent, only listen to the beacons.
- // The channel scanned is fixed as specified, no need to scan all channels.
- // The scan wait time is specified in the request too.
- // Passive scan Mode
-
- // Control state machine is not idle, reject the request
- if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_NOISE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_NOISE_HIST_REQ;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- // Reset the statistics
- for (i = 0; i < 8; i++)
- pAd->StaCfg.RPIDensity[i] = 0;
-
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, 0x1010);
-
- // Set channel load measurement flag
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistRequestAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare Beacon report action, special scan operation added
- to support
-
- Arguments:
- pAd Pointer to our adapter
- pData Start from element ID
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID BeaconRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PRM_REQUEST_ACTION pReq;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- PHEADER_802_11 pNullFrame;
- MLME_SCAN_REQ_STRUCT ScanReq;
- UCHAR ZeroSsid[32];
-
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconRequestAction ----->\n"));
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
- NdisZeroMemory(ZeroSsid, 32);
-
- // Prepare for special scan request
- // The scan definition is different with our Active, Passive scan definition.
- // For CCX2, Active means send out probe request with broadcast BSSID.
- // Passive means no probe request sent, only listen to the beacons.
- // The channel scanned is fixed as specified, no need to scan all channels.
- // The scan wait time is specified in the request too.
- if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_PASSIVE)
- {
- // Passive scan Mode
- DBGPRINT(RT_DEBUG_TRACE, ("Passive Scan Mode!\n"));
-
- // Control state machine is not idle, reject the request
- if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_PASSIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_BEACON_REQ;
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
- }
- else if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_ACTIVE)
- {
- // Active scan Mode
- DBGPRINT(RT_DEBUG_TRACE, ("Active Scan Mode!\n"));
-
- // Control state machine is not idle, reject the request
- if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_BEACON_REQ;
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
- }
- else if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_BEACON_TABLE)
- {
- // Beacon report Mode, report all the APS in current bss table
- DBGPRINT(RT_DEBUG_TRACE, ("Beacon Report Mode!\n"));
-
- // Copy current BSS table to CCX table, we can omit this step later on.
- NdisMoveMemory(&pAd->StaCfg.CCXBssTab, &pAd->ScanTab, sizeof(BSS_TABLE));
-
- // Create beacon report from Bss table
- AironetCreateBeaconReportFromBssTable(pAd);
-
- // Set state to scanning
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-
- // Enqueue report request
- // Cisco scan request is finished, prepare beacon report
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
- }
- else
- {
- // Wrong scan Mode
- DBGPRINT(RT_DEBUG_TRACE, ("Wrong Scan Mode!\n"));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconRequestAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID AironetReportAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRM_REQUEST_ACTION pReq;
- ULONG Now32;
-
- NdisGetSystemUpTime(&Now32);
- pAd->StaCfg.LastBeaconRxTime = Now32;
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetReportAction ----->\n"));
-
- // 1. Parse measurement type and call appropriate functions
- if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
- // Channel Load measurement request
- ChannelLoadReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
- // Noise Histogram measurement request
- NoiseHistReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_BEACON_REQ)
- // Beacon measurement request
- BeaconReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else
- // Unknown. Do nothing and return
- ;
-
- // 2. Point to the correct index of action element, start from 0
- pAd->StaCfg.CurrentRMReqIdx++;
-
- // 3. Check for parallel actions
- if (pAd->StaCfg.ParallelReq == TRUE)
- {
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- // Process next action right away
- if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
- // Channel Load measurement request
- ChannelLoadReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
- // Noise Histogram measurement request
- NoiseHistReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
-
- pAd->StaCfg.ParallelReq = FALSE;
- pAd->StaCfg.CurrentRMReqIdx++;
- }
-
- if (pAd->StaCfg.CurrentRMReqIdx >= pAd->StaCfg.RMReqCnt)
- {
- // 4. There is no more unprocessed measurement request, go for transmit this report
- AironetFinalReportAction(pAd);
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
- }
- else
- {
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- if (pReq->Measurement.Channel != pAd->CommonCfg.Channel)
- {
- RTMPusecDelay(100000);
- }
-
- // 5. There are more requests to be measure
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID AironetFinalReportAction(
- IN PRTMP_ADAPTER pAd)
-{
- PUCHAR pDest;
- PAIRONET_IAPP_HEADER pIAPP;
- PHEADER_802_11 pHeader;
- UCHAR AckRate = RATE_2;
- USHORT AckDuration = 0;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetFinalReportAction ----->\n"));
-
- // 0. Set up the frame pointer, Frame was inited at the end of message action
- pDest = &pAd->StaCfg.FrameReportBuf[LENGTH_802_11];
-
- // 1. Update report IAPP fields
- pIAPP = (PAIRONET_IAPP_HEADER) pDest;
-
- // 2. Copy Cisco SNAP header
- NdisMoveMemory(pIAPP->CiscoSnapHeader, SNAP_AIRONET, LENGTH_802_1_H);
-
- // 3. network order for this 16bit length
- pIAPP->Length = cpu2be16(pAd->StaCfg.FrameReportLen - LENGTH_802_11 - LENGTH_802_1_H);
-
- // 3.1 sanity check the report length, ignore it if there is nothing to report
- if (be2cpu16(pIAPP->Length) <= 18)
- return;
-
- // 4. Type must be 0x32
- pIAPP->Type = AIRONET_IAPP_TYPE;
-
- // 5. SubType for report must be 0x81
- pIAPP->SubType = AIRONET_IAPP_SUBTYPE_REPORT;
-
- // 6. DA is not used and must be zero, although the whole frame was cleared at the start of function
- // We will do it again here. We can use BSSID instead
- COPY_MAC_ADDR(pIAPP->DA, pAd->CommonCfg.Bssid);
-
- // 7. SA is the client reporting which must be our MAC
- COPY_MAC_ADDR(pIAPP->SA, pAd->CurrentAddress);
-
- // 8. Copy the saved dialog token
- pIAPP->Token = pAd->StaCfg.IAPPToken;
-
- // 9. Make the Report frame 802.11 header
- // Reuse function in wpa.c
- pHeader = (PHEADER_802_11) pAd->StaCfg.FrameReportBuf;
- pAd->Sequence ++;
- WpaMacHeaderInit(pAd, pHeader, 0, pAd->CommonCfg.Bssid);
-
- // ACK size is 14 include CRC, and its rate is based on real time information
- AckRate = pAd->CommonCfg.ExpectedACKRate[pAd->CommonCfg.MlmeRate];
- AckDuration = RTMPCalcDuration(pAd, AckRate, 14);
- pHeader->Duration = pAd->CommonCfg.Dsifs + AckDuration;
-
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- // 10. Prepare report frame with dynamic outbuffer. Just simply copy everything.
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- pAd->StaCfg.FrameReportLen, pAd->StaCfg.FrameReportBuf,
- END_OF_ARGS);
-
- // 11. Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.CCXReqType = MSRN_TYPE_UNUSED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetFinalReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ChannelLoadReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PCHANNEL_LOAD_REPORT pLoad;
- PUCHAR pDest;
- UCHAR CCABusyFraction;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadReportAction ----->\n"));
-
- // Disable Rx with promiscuous reception, make it back to normal
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
-
- // 0. Setup pointer for processing beacon & probe response
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
-
- // 1. Fill Measurement report element field.
- pReport->Eid = IE_MEASUREMENT_REPORT;
- // Fixed Length at 9, not include Eid and length fields
- pReport->Length = 9;
- pReport->Token = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_CHANNEL_LOAD_REQ;
-
- // 2. Fill channel report measurement data
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
- pLoad = (PCHANNEL_LOAD_REPORT) pDest;
- pLoad->Channel = pAd->StaCfg.MeasurementRequest[Index].Measurement.Channel;
- pLoad->Spare = 0;
- pLoad->Duration = pAd->StaCfg.MeasurementRequest[Index].Measurement.Duration;
-
- // 3. Calculate the CCA Busy Fraction
- // (Bytes + ACK size) * 8 / Tx speed * 255 / 1000 / measurement duration, use 24 us Tx speed
- // = (Bytes + ACK) / 12 / duration
- // 9 is the good value for pAd->StaCfg.CLFactor
- // CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / 9 / pLoad->Duration);
- CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / pAd->StaCfg.CLFactor / pLoad->Duration);
- if (CCABusyFraction < 10)
- CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / 3 / pLoad->Duration) + 1;
-
- pLoad->CCABusy = CCABusyFraction;
- DBGPRINT(RT_DEBUG_TRACE, ("CLBusyByte %ld, Duration %d, Result, %d\n", pAd->StaCfg.CLBusyBytes, pLoad->Duration, CCABusyFraction));
-
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen %d\n", pAd->StaCfg.FrameReportLen));
- pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(CHANNEL_LOAD_REPORT));
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen %d\n", pAd->StaCfg.FrameReportLen));
-
- // 4. Clear channel load measurement flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- // 5. reset to idle state
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID NoiseHistReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PNOISE_HIST_REPORT pNoise;
- PUCHAR pDest;
- UCHAR i,NoiseCnt;
- USHORT TotalRPICnt, TotalRPISum;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistReportAction ----->\n"));
-
- // 0. Disable Rx with promiscuous reception, make it back to normal
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
- // 1. Setup pointer for processing beacon & probe response
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
-
- // 2. Fill Measurement report element field.
- pReport->Eid = IE_MEASUREMENT_REPORT;
- // Fixed Length at 16, not include Eid and length fields
- pReport->Length = 16;
- pReport->Token = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_NOISE_HIST_REQ;
-
- // 3. Fill noise histogram report measurement data
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
- pNoise = (PNOISE_HIST_REPORT) pDest;
- pNoise->Channel = pAd->StaCfg.MeasurementRequest[Index].Measurement.Channel;
- pNoise->Spare = 0;
- pNoise->Duration = pAd->StaCfg.MeasurementRequest[Index].Measurement.Duration;
- // 4. Fill Noise histogram, the total RPI counts should be 0.4 * TU
- // We estimate 4000 normal packets received durning 10 seconds test.
- // Adjust it if required.
- // 3 is a good value for pAd->StaCfg.NHFactor
- // TotalRPICnt = pNoise->Duration * 3 / 10;
- TotalRPICnt = pNoise->Duration * pAd->StaCfg.NHFactor / 10;
- TotalRPISum = 0;
-
- for (i = 0; i < 8; i++)
- {
- TotalRPISum += pAd->StaCfg.RPIDensity[i];
- DBGPRINT(RT_DEBUG_TRACE, ("RPI %d Conuts %d\n", i, pAd->StaCfg.RPIDensity[i]));
- }
-
- // Double check if the counter is larger than our expectation.
- // We will replace it with the total number plus a fraction.
- if (TotalRPISum > TotalRPICnt)
- TotalRPICnt = TotalRPISum + pNoise->Duration / 20;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Total RPI Conuts %d\n", TotalRPICnt));
-
- // 5. Initialize noise count for the total summation of 0xff
- NoiseCnt = 0;
- for (i = 1; i < 8; i++)
- {
- pNoise->Density[i] = (UCHAR) (pAd->StaCfg.RPIDensity[i] * 255 / TotalRPICnt);
- if ((pNoise->Density[i] == 0) && (pAd->StaCfg.RPIDensity[i] != 0))
- pNoise->Density[i]++;
- NoiseCnt += pNoise->Density[i];
- DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[%d] = 0x%02x\n", i, pNoise->Density[i]));
- }
-
- // 6. RPI[0] represents the rest of counts
- pNoise->Density[0] = 0xff - NoiseCnt;
- DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[0] = 0x%02x\n", pNoise->Density[0]));
-
- pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(NOISE_HIST_REPORT));
-
- // 7. Clear channel load measurement flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- // 8. reset to idle state
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare Beacon report action,
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID BeaconReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconReportAction ----->\n"));
-
- // Looks like we don't have anything thing need to do here.
- // All measurement report already finished in AddBeaconReport
- // The length is in the FrameReportLen
-
- // reset Beacon index for next beacon request
- pAd->StaCfg.LastBssIndex = 0xff;
-
- // reset to idle state
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
- Index Current BSSID in CCXBsstab entry index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID AironetAddBeaconReport(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Index,
- IN PMLME_QUEUE_ELEM pElem)
-{
- PVOID pMsg;
- PUCHAR pSrc, pDest;
- UCHAR ReqIdx;
- ULONG MsgLen;
- USHORT Length;
- PFRAME_802_11 pFrame;
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PEID_STRUCT pEid;
- PBEACON_REPORT pBeaconReport;
- PBSS_ENTRY pBss;
-
- // 0. Setup pointer for processing beacon & probe response
- pMsg = pElem->Msg;
- MsgLen = pElem->MsgLen;
- pFrame = (PFRAME_802_11) pMsg;
- pSrc = pFrame->Octet; // Start from AP TSF
- pBss = (PBSS_ENTRY) &pAd->StaCfg.CCXBssTab.BssEntry[Index];
- ReqIdx = pAd->StaCfg.CurrentRMReqIdx;
-
- // 1 Check the Index, if we already create this entry, only update the average RSSI
- if ((Index <= pAd->StaCfg.LastBssIndex) && (pAd->StaCfg.LastBssIndex != 0xff))
- {
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.BssReportOffset[Index]];
- // Point to bss report information
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
- pBeaconReport = (PBEACON_REPORT) pDest;
-
- // Update Rx power, in dBm
- // Get the original RSSI readback from BBP
- pBeaconReport->RxPower += pAd->BbpRssiToDbmDelta;
- // Average the Rssi reading
- pBeaconReport->RxPower = (pBeaconReport->RxPower + pBss->Rssi) / 2;
- // Get to dBm format
- pBeaconReport->RxPower -= pAd->BbpRssiToDbmDelta;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Bssid %02x:%02x:%02x:%02x:%02x:%02x ",
- pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2],
- pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
- DBGPRINT(RT_DEBUG_TRACE, ("RxPower[%ld] Rssi %d, Avg Rssi %d\n", Index, (pBss->Rssi - pAd->BbpRssiToDbmDelta), pBeaconReport->RxPower - 256));
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen = %d\n", pAd->StaCfg.BssReportOffset[Index]));
-
- // Update other information here
-
- // Done
- return;
- }
-
- // 2. Update reported Index
- pAd->StaCfg.LastBssIndex = Index;
-
- // 3. Setup the buffer address for copying this BSSID into reporting frame
- // The offset should start after 802.11 header and report frame header.
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
-
- // 4. Save the start offset of each Bss in report frame
- pAd->StaCfg.BssReportOffset[Index] = pAd->StaCfg.FrameReportLen;
-
- // 5. Fill Measurement report fields
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
- pReport->Eid = IE_MEASUREMENT_REPORT;
- pReport->Length = 0;
- pReport->Token = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_BEACON_REQ;
- Length = sizeof(MEASUREMENT_REPORT_ELEMENT);
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
-
- // 6. Start thebeacon report format
- pBeaconReport = (PBEACON_REPORT) pDest;
- pDest += sizeof(BEACON_REPORT);
- Length += sizeof(BEACON_REPORT);
-
- // 7. Copy Channel number
- pBeaconReport->Channel = pBss->Channel;
- pBeaconReport->Spare = 0;
- pBeaconReport->Duration = pAd->StaCfg.MeasurementRequest[ReqIdx].Measurement.Duration;
- pBeaconReport->PhyType = ((pBss->SupRateLen+pBss->ExtRateLen > 4) ? PHY_ERP : PHY_DSS);
- // 8. Rx power, in dBm
- pBeaconReport->RxPower = pBss->Rssi - pAd->BbpRssiToDbmDelta;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Bssid %02x:%02x:%02x:%02x:%02x:%02x ",
- pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2],
- pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
- DBGPRINT(RT_DEBUG_TRACE, ("RxPower[%ld], Rssi %d\n", Index, pBeaconReport->RxPower - 256));
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen = %d\n", pAd->StaCfg.FrameReportLen));
-
- pBeaconReport->BeaconInterval = pBss->BeaconPeriod;
- COPY_MAC_ADDR(pBeaconReport->BSSID, pFrame->Hdr.Addr3);
- NdisMoveMemory(pBeaconReport->ParentTSF, pSrc, 4);
- NdisMoveMemory(pBeaconReport->TargetTSF, &pElem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pBeaconReport->TargetTSF[4], &pElem->TimeStamp.u.HighPart, 4);
-
- // 9. Skip the beacon frame and offset to start of capabilityinfo since we already processed capabilityinfo
- pSrc += (TIMESTAMP_LEN + 2);
- pBeaconReport->CapabilityInfo = *(USHORT *)pSrc;
-
- // 10. Point to start of element ID
- pSrc += 2;
- pEid = (PEID_STRUCT) pSrc;
-
- // 11. Start process all variable Eid oayload and add the appropriate to the frame report
- while (((PUCHAR) pEid + pEid->Len + 1) < ((PUCHAR) pFrame + MsgLen))
- {
- // Only limited EID are required to report for CCX 2. It includes SSID, Supported rate,
- // FH paramenter set, DS parameter set, CF parameter set, IBSS parameter set,
- // TIM (report first 4 bytes only, radio measurement capability
- switch (pEid->Eid)
- {
- case IE_SSID:
- case IE_SUPP_RATES:
- case IE_FH_PARM:
- case IE_DS_PARM:
- case IE_CF_PARM:
- case IE_IBSS_PARM:
- NdisMoveMemory(pDest, pEid, pEid->Len + 2);
- pDest += (pEid->Len + 2);
- Length += (pEid->Len + 2);
- break;
-
- case IE_MEASUREMENT_CAPABILITY:
- // Since this IE is duplicated with WPA security IE, we has to do sanity check before
- // recognize it.
- // 1. It also has fixed 6 bytes IE length.
- if (pEid->Len != 6)
- break;
- // 2. Check the Cisco Aironet OUI
- if (NdisEqualMemory(CISCO_OUI, (pSrc + 2), 3))
- {
- // Matched, this is what we want
- NdisMoveMemory(pDest, pEid, pEid->Len + 2);
- pDest += (pEid->Len + 2);
- Length += (pEid->Len + 2);
- }
- break;
-
- case IE_TIM:
- if (pEid->Len > 4)
- {
- // May truncate and report the first 4 bytes only, with the eid & len, total should be 6
- NdisMoveMemory(pDest, pEid, 6);
- pDest += 6;
- Length += 6;
- }
- else
- {
- NdisMoveMemory(pDest, pEid, pEid->Len + 2);
- pDest += (pEid->Len + 2);
- Length += (pEid->Len + 2);
- }
- break;
-
- default:
- break;
- }
- // 12. Move to next element ID
- pSrc += (2 + pEid->Len);
- pEid = (PEID_STRUCT) pSrc;
- }
-
- // 13. Update the length in the header, not include EID and length
- pReport->Length = Length - 4;
-
- // 14. Update the frame report buffer data length
- pAd->StaCfg.FrameReportLen += Length;
- DBGPRINT(RT_DEBUG_TRACE, ("FR len = %d\n", pAd->StaCfg.FrameReportLen));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
- Index Current BSSID in CCXBsstab entry index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID AironetCreateBeaconReportFromBssTable(
- IN PRTMP_ADAPTER pAd)
-{
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PBEACON_REPORT pBeaconReport;
- UCHAR Index, ReqIdx;
- USHORT Length;
- PUCHAR pDest;
- PBSS_ENTRY pBss;
-
- // 0. setup base pointer
- ReqIdx = pAd->StaCfg.CurrentRMReqIdx;
-
- for (Index = 0; Index < pAd->StaCfg.CCXBssTab.BssNr; Index++)
- {
- // 1. Setup the buffer address for copying this BSSID into reporting frame
- // The offset should start after 802.11 header and report frame header.
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
- pBss = (PBSS_ENTRY) &pAd->StaCfg.CCXBssTab.BssEntry[Index];
- Length = 0;
-
- // 2. Fill Measurement report fields
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
- pReport->Eid = IE_MEASUREMENT_REPORT;
- pReport->Length = 0;
- pReport->Token = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_BEACON_REQ;
- Length = sizeof(MEASUREMENT_REPORT_ELEMENT);
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
-
- // 3. Start the beacon report format
- pBeaconReport = (PBEACON_REPORT) pDest;
- pDest += sizeof(BEACON_REPORT);
- Length += sizeof(BEACON_REPORT);
-
- // 4. Copy Channel number
- pBeaconReport->Channel = pBss->Channel;
- pBeaconReport->Spare = 0;
- pBeaconReport->Duration = pAd->StaCfg.MeasurementRequest[ReqIdx].Measurement.Duration;
- pBeaconReport->PhyType = ((pBss->SupRateLen+pBss->ExtRateLen > 4) ? PHY_ERP : PHY_DSS);
- pBeaconReport->RxPower = pBss->Rssi - pAd->BbpRssiToDbmDelta;
- pBeaconReport->BeaconInterval = pBss->BeaconPeriod;
- pBeaconReport->CapabilityInfo = pBss->CapabilityInfo;
- COPY_MAC_ADDR(pBeaconReport->BSSID, pBss->Bssid);
- NdisMoveMemory(pBeaconReport->ParentTSF, pBss->PTSF, 4);
- NdisMoveMemory(pBeaconReport->TargetTSF, pBss->TTSF, 8);
-
- // 5. Create SSID
- *pDest++ = 0x00;
- *pDest++ = pBss->SsidLen;
- NdisMoveMemory(pDest, pBss->Ssid, pBss->SsidLen);
- pDest += pBss->SsidLen;
- Length += (2 + pBss->SsidLen);
-
- // 6. Create SupportRates
- *pDest++ = 0x01;
- *pDest++ = pBss->SupRateLen;
- NdisMoveMemory(pDest, pBss->SupRate, pBss->SupRateLen);
- pDest += pBss->SupRateLen;
- Length += (2 + pBss->SupRateLen);
-
- // 7. DS Parameter
- *pDest++ = 0x03;
- *pDest++ = 1;
- *pDest++ = pBss->Channel;
- Length += 3;
-
- // 8. IBSS parameter if presents
- if (pBss->BssType == BSS_ADHOC)
- {
- *pDest++ = 0x06;
- *pDest++ = 2;
- *(PUSHORT) pDest = pBss->AtimWin;
- pDest += 2;
- Length += 4;
- }
-
- // 9. Update length field, not include EID and length
- pReport->Length = Length - 4;
-
- // 10. Update total frame size
- pAd->StaCfg.FrameReportLen += Length;
- }
-}
+#include "../../rt2860/sta/aironet.c"
diff --git a/drivers/staging/rt2870/sta/assoc.c b/drivers/staging/rt2870/sta/assoc.c
index a76dab500bcb..46564d7a01a9 100644
--- a/drivers/staging/rt2870/sta/assoc.c
+++ b/drivers/staging/rt2870/sta/assoc.c
@@ -1,2039 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- assoc.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-9-3 porting from RT2500
-*/
-#include "../rt_config.h"
-
-UCHAR CipherWpaTemplate[] = {
- 0xdd, // WPA IE
- 0x16, // Length
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x01 // authentication
- };
-
-UCHAR CipherWpa2Template[] = {
- 0x30, // RSN IE
- 0x14, // Length
- 0x01, 0x00, // Version
- 0x00, 0x0f, 0xac, 0x02, // group cipher, TKIP
- 0x01, 0x00, // number of pairwise
- 0x00, 0x0f, 0xac, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x0f, 0xac, 0x02, // authentication
- 0x00, 0x00, // RSN capability
- };
-
-UCHAR Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID AssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, (STATE_MACHINE_FUNC)Drop, ASSOC_IDLE, ASSOC_MACHINE_BASE);
-
- // first column
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)MlmeAssocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)MlmeReassocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)MlmeDisassocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
-
- // second column
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
- //
- // Patch 3Com AP MOde:3CRWE454G72
- // We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp.
- //
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT, (STATE_MACHINE_FUNC)AssocTimeoutAction);
-
- // third column
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
- //
- // Patch, AP doesn't send Reassociate Rsp frame to Station.
- //
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT, (STATE_MACHINE_FUNC)ReassocTimeoutAction);
-
- // fourth column
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT, (STATE_MACHINE_FUNC)DisassocTimeoutAction);
-
- // initialize the timer
- RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer, GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer, GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer, GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- Association timeout procedure. After association timeout, this function
- will be called and it will put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Reassociation timeout procedure. After reassociation timeout, this
- function will be called and put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ReassocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Disassociation timeout procedure. After disassociation timeout, this
- function will be called and put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID DisassocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- mlme assoc req handling procedure
- Parameters:
- Adapter - Adapter pointer
- Elem - MLME Queue Element
- Pre:
- the station has been authenticated and the following information is stored in the config
- -# SSID
- -# supported rates and their length
- -# listen interval (Adapter->StaCfg.default_listen_count)
- -# Transmit power (Adapter->StaCfg.tx_power)
- Post :
- -# An association request frame is generated and sent to the air
- -# Association timer starts
- -# Association state -> ASSOC_WAIT_RSP
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR ApAddr[6];
- HEADER_802_11 AssocHdr;
- UCHAR Ccx2Len = 5;
- UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
- USHORT ListenIntv;
- ULONG Timeout;
- USHORT CapabilityInfo;
- BOOLEAN TimerCancelled;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- ULONG tmp;
- USHORT VarIesOffset;
- UCHAR CkipFlag;
- UCHAR CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH];
- UCHAR AironetCkipIe = IE_AIRONET_CKIP;
- UCHAR AironetCkipLen = CKIP_NEGOTIATION_LENGTH;
- UCHAR AironetIPAddressIE = IE_AIRONET_IPADDRESS;
- UCHAR AironetIPAddressLen = AIRONET_IPADDRESS_LENGTH;
- UCHAR AironetIPAddressBuffer[AIRONET_IPADDRESS_LENGTH] = {0x00, 0x40, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00};
- USHORT Status;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block Assoc request durning WPA block period!\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
- // check sanity first
- else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
- {
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
- // Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- return;
- }
-
- // Add by James 03/06/27
- pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
- // Association don't need to report MAC address
- pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
- NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL;
- pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo;
- pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
- // Only reassociate need this
- //COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr);
- pAd->StaCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-
- NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
- // First add SSID
- VarIesOffset = 0;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SsidLen, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- VarIesOffset += pAd->MlmeAux.SsidLen;
-
- // Second add Supported rates
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SupRateLen, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
- VarIesOffset += pAd->MlmeAux.SupRateLen;
- // End Add by James
-
- if ((pAd->CommonCfg.Channel > 14) &&
- (pAd->CommonCfg.bIEEE80211H == TRUE))
- CapabilityInfo |= 0x0100;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
- MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr, ApAddr);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AssocHdr,
- 2, &CapabilityInfo,
- 2, &ListenIntv,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- // HT
- if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
- {
- HtLen = SIZE_HT_CAP_IE + 4;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
-#else
- NdisZeroMemory(&HtCapabilityTmp, sizeof(HT_CAPABILITY_IE));
- NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, pAd->MlmeAux.HtCapabilityLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen,&HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
-
- // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
- // Case I: (Aggregation + Piggy-Back)
- // 1. user enable aggregation, AND
- // 2. Mac support piggy-back
- // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
- // Case II: (Aggregation)
- // 1. user enable aggregation, AND
- // 2. AP annouces it's AGGREGATION-capable in BEACON
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- }
- else
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
-
- if (pAd->MlmeAux.APEdcaParm.bValid)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
- {
- QBSS_STA_INFO_PARM QosInfo;
-
- NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
- QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
- QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
- QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
- QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
- QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
- WmeIe[8] |= *(PUCHAR)&QosInfo;
- }
- else
- {
- // The Parameter Set Count is set to ¡§0¡¨ in the association request frames
- // WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 9, &WmeIe[0],
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- //
- // Let WPA(#221) Element ID on the end of this association frame.
- // Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp.
- // For example: Put Vendor Specific IE on the front of WPA IE.
- // This happens on AP (Model No:Linksys WRK54G)
- //
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
- )
- )
- {
- UCHAR RSNIe = IE_WPA;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- {
- RSNIe = IE_WPA2;
- }
-
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-
- // Check for WPA PMK cache list
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
- {
- INT idx;
- BOOLEAN FoundPMK = FALSE;
- // Search chched PMKID, append it if existed
- for (idx = 0; idx < PMKID_NO; idx++)
- {
- if (NdisEqualMemory(ApAddr, &pAd->StaCfg.SavedPMK[idx].BSSID, 6))
- {
- FoundPMK = TRUE;
- break;
- }
- }
-
- if (FoundPMK)
- {
- // Set PMK number
- *(PUSHORT) &pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len] = 1;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len + 2], &pAd->StaCfg.SavedPMK[idx].PMKID, 16);
- pAd->StaCfg.RSNIE_Len += 18;
- }
- }
-
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- }
-
- FrameLen += tmp;
-
- {
- // Append Variable IE
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->StaCfg.RSNIE_Len, 1);
- VarIesOffset += 1;
- }
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
- VarIesOffset += pAd->StaCfg.RSNIE_Len;
-
- // Set Variable IEs Length
- pAd->StaCfg.ReqVarIELen = VarIesOffset;
- }
-
- // We have update that at PeerBeaconAtJoinRequest()
- CkipFlag = pAd->StaCfg.CkipFlag;
- if (CkipFlag != 0)
- {
- NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH);
- CkipNegotiationBuffer[2] = 0x66;
- // Make it try KP & MIC, since we have to follow the result from AssocRsp
- CkipNegotiationBuffer[8] = 0x18;
- CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22;
- CkipFlag = 0x18;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCkipIe,
- 1, &AironetCkipLen,
- AironetCkipLen, CkipNegotiationBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // Add CCX v2 request if CCX2 admin state is on
- if (pAd->StaCfg.CCXControl.field.Enable == 1)
- {
-
- //
- // Add AironetIPAddressIE for Cisco CCX 2.X
- // Add CCX Version
- //
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetIPAddressIE,
- 1, &AironetIPAddressLen,
- AironetIPAddressLen, AironetIPAddressBuffer,
- 1, &Ccx2Ie,
- 1, &Ccx2Len,
- Ccx2Len, Ccx2IeInfo,
- END_OF_ARGS);
- FrameLen += tmp;
-
- //
- // Add CipherSuite CCKM or LeapTkip if setting.
- //
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCiscoCCKMLen, CipherSuiteCiscoCCKM,
- END_OF_ARGS);
- FrameLen += tmp;
-
- // Third add RSN
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen); //Save CipherSuite
- VarIesOffset += CipherSuiteCiscoCCKMLen;
- }
- else if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCCXTkipLen, CipherSuiteCCXTkip,
- END_OF_ARGS);
- FrameLen += tmp;
-
- // Third add RSN
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCCXTkip, CipherSuiteCCXTkipLen);
- VarIesOffset += CipherSuiteCCXTkipLen;
- }
-#endif // LEAP_SUPPORT //
-
- // Add by James 03/06/27
- // Set Variable IEs Length
- pAd->StaCfg.ReqVarIELen = VarIesOffset;
- pAd->StaCfg.AssocInfo.RequestIELength = VarIesOffset;
-
- // OffsetResponseIEs follow ReqVarIE
- pAd->StaCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->StaCfg.ReqVarIELen;
- // End Add by James
- }
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- mlme reassoc req handling procedure
- Parameters:
- Elem -
- Pre:
- -# SSID (Adapter->StaCfg.ssid[])
- -# BSSID (AP address, Adapter->StaCfg.bssid)
- -# Supported rates (Adapter->StaCfg.supported_rates[])
- -# Supported rates length (Adapter->StaCfg.supported_rates_len)
- -# Tx power (Adapter->StaCfg.tx_power)
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR ApAddr[6];
- HEADER_802_11 ReassocHdr;
- UCHAR Ccx2Len = 5;
- UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
- USHORT CapabilityInfo, ListenIntv;
- ULONG Timeout;
- ULONG FrameLen = 0;
- BOOLEAN TimerCancelled;
- NDIS_STATUS NStatus;
- ULONG tmp;
- PUCHAR pOutBuffer = NULL;
-//CCX 2.X
-#ifdef LEAP_SUPPORT
- UCHAR CkipFlag;
- UCHAR CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH];
- UCHAR AironetCkipIe = IE_AIRONET_CKIP;
- UCHAR AironetCkipLen = CKIP_NEGOTIATION_LENGTH;
- UCHAR AironetIPAddressIE = IE_AIRONET_IPADDRESS;
- UCHAR AironetIPAddressLen = AIRONET_IPADDRESS_LENGTH;
- UCHAR AironetIPAddressBuffer[AIRONET_IPADDRESS_LENGTH] = {0x00, 0x40, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00};
- UCHAR AironetCCKMReassocIE = IE_AIRONET_CCKMREASSOC;
- UCHAR AironetCCKMReassocLen = AIRONET_CCKMREASSOC_LENGTH;
- UCHAR AironetCCKMReassocBuffer[AIRONET_CCKMREASSOC_LENGTH];
- UCHAR AironetOUI[] = {0x00, 0x40, 0x96, 0x00};
- UCHAR MICMN[16];
- UCHAR CalcMicBuffer[80];
- ULONG CalcMicBufferLen = 0;
-#endif // LEAP_SUPPORT //
- USHORT Status;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block ReAssoc request durning WPA block period!\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- // the parameters are the same as the association
- else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
- {
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- return;
- }
-
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
- // make frame, use bssid as the AP address??
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send RE-ASSOC request...\n"));
- MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0, ApAddr, ApAddr);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &ReassocHdr,
- 2, &CapabilityInfo,
- 2, &ListenIntv,
- MAC_ADDR_LEN, ApAddr,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- if (pAd->MlmeAux.APEdcaParm.bValid)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
- {
- QBSS_STA_INFO_PARM QosInfo;
-
- NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
- QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
- QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
- QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
- QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
- QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
- WmeIe[8] |= *(PUCHAR)&QosInfo;
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 9, &WmeIe[0],
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- // HT
- if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
- {
- HtLen = SIZE_HT_CAP_IE + 4;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
-
- // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
- // Case I: (Aggregation + Piggy-Back)
- // 1. user enable aggregation, AND
- // 2. Mac support piggy-back
- // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
- // Case II: (Aggregation)
- // 1. user enable aggregation, AND
- // 2. AP annouces it's AGGREGATION-capable in BEACON
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- }
- else
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- CkipFlag = pAd->StaCfg.CkipFlag; // We have update that at PeerBeaconAtJoinRequest()
- if (CkipFlag != 0)
- {
- NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH);
- CkipNegotiationBuffer[2] = 0x66;
- // Make it try KP & MIC, since we have to follow the result from AssocRsp
- CkipNegotiationBuffer[8] = 0x18;
- CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCkipIe,
- 1, &AironetCkipLen,
- AironetCkipLen, CkipNegotiationBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetIPAddressIE,
- 1, &AironetIPAddressLen,
- AironetIPAddressLen, AironetIPAddressBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
-
- //
- // The RN is incremented before each reassociation request.
- //
- pAd->StaCfg.CCKMRN++;
- //
- // Calculate MIC = hmac-md5(krk, STA-ID|BSSID|RSNIE|TSF|RN);
- //
- COPY_MAC_ADDR(CalcMicBuffer, pAd->CurrentAddress);
- CalcMicBufferLen = MAC_ADDR_LEN;
- COPY_MAC_ADDR(CalcMicBuffer + CalcMicBufferLen, pAd->MlmeAux.Bssid);
- CalcMicBufferLen += MAC_ADDR_LEN;
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen);
- CalcMicBufferLen += CipherSuiteCiscoCCKMLen;
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR) &pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp));
- CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp);
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR)&pAd->StaCfg.CCKMRN, sizeof(pAd->StaCfg.CCKMRN));
- CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMRN);
- hmac_md5(pAd->StaCfg.KRK, LEN_EAP_MICK, CalcMicBuffer, CalcMicBufferLen, MICMN);
-
- //
- // fill up CCKM reassociation request element
- //
- NdisMoveMemory(AironetCCKMReassocBuffer, AironetOUI, 4);
- NdisMoveMemory(AironetCCKMReassocBuffer + 4, (PUCHAR)&pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, 8);
- NdisMoveMemory(AironetCCKMReassocBuffer + 12, (PUCHAR) &pAd->StaCfg.CCKMRN, 4);
- NdisMoveMemory(AironetCCKMReassocBuffer +16, MICMN, 8);
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCCKMReassocIE,
- 1, &AironetCCKMReassocLen,
- AironetCCKMReassocLen, AironetCCKMReassocBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCiscoCCKMLen,CipherSuiteCiscoCCKM,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-#endif // LEAP_SUPPORT //
-
- // Add CCX v2 request if CCX2 admin state is on
- if (pAd->StaCfg.CCXControl.field.Enable == 1)
- {
- //
- // Add CCX Version
- //
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &Ccx2Ie,
- 1, &Ccx2Len,
- Ccx2Len, Ccx2IeInfo,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
- pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- Upper layer issues disassoc request
- Parameters:
- Elem -
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PMLME_DISASSOC_REQ_STRUCT pDisassocReq;
- HEADER_802_11 DisassocHdr;
- PHEADER_802_11 pDisassocHdr;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- NDIS_STATUS NStatus;
- BOOLEAN TimerCancelled;
- ULONG Timeout = 0;
- USHORT Status;
-
-#ifdef QOS_DLS_SUPPORT
- // send DLS-TEAR_DOWN message,
- if (pAd->CommonCfg.bDLSCapable)
- {
- UCHAR i;
-
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
- }
-#endif // QOS_DLS_SUPPORT //
-
- // skip sanity check
- pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
- return;
- }
-
-
-
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
- pDisassocReq->Addr[0], pDisassocReq->Addr[1], pDisassocReq->Addr[2],
- pDisassocReq->Addr[3], pDisassocReq->Addr[4], pDisassocReq->Addr[5], pDisassocReq->Reason));
- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); // patch peap ttls switching issue
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DisassocHdr,
- 2, &pDisassocReq->Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- // To patch Instance and Buffalo(N) AP
- // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
- // Therefore, we send both of them.
- pDisassocHdr = (PHEADER_802_11)pOutBuffer;
- pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
- COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pDisassocReq->Addr);
-
- RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */
- pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-}
-
-/*
- ==========================================================================
- Description:
- peer sends assoc rsp back
- Parameters:
- Elme - MLME message containing the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAssocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo, Status, Aid;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
- UCHAR Addr2[MAC_ADDR_LEN];
- BOOLEAN TimerCancelled;
- UCHAR CkipFlag;
- EDCA_PARM EdcaParm;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
- if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
- &HtCapability,&AddHtInfo, &HtCapabilityLen,&AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
- {
- // The frame is for me ?
- if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status));
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem->Wcid, pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-#endif // DOT11_N_SUPPORT //
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
- if(Status == MLME_SUCCESS)
- {
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR idx;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (idx=0; idx<SupRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
- }
-
- for (idx=0; idx<ExtRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
- }
- // go to procedure listed on page 376
- AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
- &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
-
- StaAddMacTableEntry(pAd, &pAd->MacTab.Content[BSSID_WCID], MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo);
-
- pAd->StaCfg.CkipFlag = CkipFlag;
- if (CkipFlag & 0x18)
- {
- NdisZeroMemory(pAd->StaCfg.TxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.RxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.CKIPMIC, 4);
- pAd->StaCfg.GIV[0] = RandomByte(pAd);
- pAd->StaCfg.GIV[1] = RandomByte(pAd);
- pAd->StaCfg.GIV[2] = RandomByte(pAd);
- pAd->StaCfg.bCkipOn = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag));
- }
- }
- else
- {
- // Faile on Association, we need to check the status code
- // Is that a Rogue AP?
-#ifdef LEAP_SUPPORT
- if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (Status == MLME_ALG_NOT_SUPPORT))
- { //Possibly Rogue AP
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, pAd->MlmeAux.Bssid, LEAP_REASON_INVALID_AUTH);
- }
-#endif // LEAP_SUPPORT //
- }
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
- peer sends reassoc rsp
- Parametrs:
- Elem - MLME message cntaining the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerReassocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo;
- USHORT Status;
- USHORT Aid;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR CkipFlag;
- BOOLEAN TimerCancelled;
- EDCA_PARM EdcaParm;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
- if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
- &HtCapability, &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
- {
- if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status));
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
- if(Status == MLME_SUCCESS)
- {
- // go to procedure listed on page 376
- AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
- &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- wext_notify_event_assoc(pAd);
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- }
-
- //
- // Cisco Leap CCKM supported Re-association.
- //
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- if (CCKMAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen) == TRUE)
- {
- pAd->StaCfg.CkipFlag = CkipFlag;
- if (CkipFlag & 0x18)
- {
- NdisZeroMemory(pAd->StaCfg.TxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.RxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.CKIPMIC, 4);
- pAd->StaCfg.GIV[0] = RandomByte(pAd);
- pAd->StaCfg.GIV[1] = RandomByte(pAd);
- pAd->StaCfg.GIV[2] = RandomByte(pAd);
- pAd->StaCfg.bCkipOn = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag));
- }
-
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - CCKMAssocRspSanity() sanity check fail\n"));
- }
- }
- else
-#endif // LEAP_SUPPORT //
- {
- // CkipFlag is no use for reassociate
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- procedures on IEEE 802.11/1999 p.376
- Parametrs:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocPostProc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr2,
- IN USHORT CapabilityInfo,
- IN USHORT Aid,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN PEDCA_PARM pEdcaParm,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN ADD_HT_INFO_IE *pAddHtInfo) // AP might use this additional ht info IE
-{
- ULONG Idx;
-
- pAd->MlmeAux.BssType = BSS_INFRA;
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2);
- pAd->MlmeAux.Aid = Aid;
- pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
-#ifdef DOT11_N_SUPPORT
- // Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on.
- if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE))
- {
- pEdcaParm->bValid = TRUE;
- pEdcaParm->Aifsn[0] = 3;
- pEdcaParm->Aifsn[1] = 7;
- pEdcaParm->Aifsn[2] = 2;
- pEdcaParm->Aifsn[3] = 2;
-
- pEdcaParm->Cwmin[0] = 4;
- pEdcaParm->Cwmin[1] = 4;
- pEdcaParm->Cwmin[2] = 3;
- pEdcaParm->Cwmin[3] = 2;
-
- pEdcaParm->Cwmax[0] = 10;
- pEdcaParm->Cwmax[1] = 10;
- pEdcaParm->Cwmax[2] = 4;
- pEdcaParm->Cwmax[3] = 3;
-
- pEdcaParm->Txop[0] = 0;
- pEdcaParm->Txop[1] = 0;
- pEdcaParm->Txop[2] = 96;
- pEdcaParm->Txop[3] = 48;
-
- }
-#endif // DOT11_N_SUPPORT //
-
- NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
-
- // filter out un-supported rates
- pAd->MlmeAux.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
-
- // filter out un-supported rates
- pAd->MlmeAux.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-
-#ifdef DOT11_N_SUPPORT
- if (HtCapabilityLen > 0)
- {
- RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n",
- pAd->MacTab.Content[BSSID_WCID].MmpsMode, pAd->MacTab.Content[BSSID_WCID].AMsduSize));
-#endif // DOT11_N_SUPPORT //
-
- // Set New WPA information
- Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
- if (Idx == BSS_NOT_FOUND)
- {
- DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
- }
- else
- {
- // Init variable
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0;
- NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, MAX_LEN_OF_RSNIE);
-
- // Store appropriate RSN_IE for WPA SM negotiation later
- if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0))
- {
- PUCHAR pVIE;
- USHORT len;
- PEID_STRUCT pEid;
-
- pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs;
- len = pAd->ScanTab.BssEntry[Idx].VarIELen;
-
- while (len > 0)
- {
- pEid = (PEID_STRUCT) pVIE;
- // For WPA/WPAPSK
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- && (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
- }
- // For WPA2/WPA2PSK
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- && (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
- }
-
- if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> no RSN_IE \n"));
- }
- else
- {
- hex_dump("RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- left part of IEEE 802.11/1999 p.374
- Parameters:
- Elem - MLME message containing the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDisassocAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Reason;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
- if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() Reason = %d\n", Reason));
- if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2))
- {
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
-
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- // Cisco_LEAP has start a timer
- // We should cancel it if using LEAP
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
- //Check is it mach the LEAP Authentication failed as possible a Rogue AP
- //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Association.
- if ((pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
- }
- }
-#endif // LEAP_SUPPORT //
- //
- // Get Current System time and Turn on AdjacentAPReport
- //
- NdisGetSystemUpTime(&pAd->StaCfg.CCXAdjacentAPLinkDownTime);
- pAd->StaCfg.CCXAdjacentAPReportFlag = TRUE;
- LinkDown(pAd, TRUE);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() sanity check fail\n"));
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after assoc timeout
- Parameters:
- Elme -
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after reassoc timeout
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ReassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after disassoc timeout
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID DisassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenAssoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenReassoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenDisassociate(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- right part of IEEE 802.11/1999 page 374
- Note:
- This event should never cause ASSOC state machine perform state
- transition, and has no relationship with CNTL machine. So we separate
- this routine as a service outside of ASSOC state transition table.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID Cls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr)
-{
- HEADER_802_11 DisassocHdr;
- PHEADER_802_11 pDisassocHdr;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- NDIS_STATUS NStatus;
- USHORT Reason = REASON_CLS3ERR;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid); // patch peap ttls switching issue
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DisassocHdr,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- // To patch Instance and Buffalo(N) AP
- // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
- // Therefore, we send both of them.
- pDisassocHdr = (PHEADER_802_11)pOutBuffer;
- pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DisassocReason = REASON_CLS3ERR;
- COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pAddr);
-}
-
- /*
- ==========================================================================
- Description:
- Switch between WEP and CKIP upon new association up.
- Parameters:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID SwitchBetweenWepAndCkip(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
- SHAREDKEY_MODE_STRUC csr1;
-
- // if KP is required. change the CipherAlg in hardware shard key table from WEP
- // to CKIP. else remain as WEP
- if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10))
- {
- // modify hardware key table so that MAC use correct algorithm to decrypt RX
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE, &csr1.word);
- if (csr1.field.Bss0Key0CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key0CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key0CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key0CipherAlg = CIPHER_CKIP128;
-
- if (csr1.field.Bss0Key1CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key1CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key1CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key1CipherAlg = CIPHER_CKIP128;
-
- if (csr1.field.Bss0Key2CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key2CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key2CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key2CipherAlg = CIPHER_CKIP128;
-
- if (csr1.field.Bss0Key3CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key3CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key3CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key3CipherAlg = CIPHER_CKIP128;
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE, csr1.word);
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchBetweenWepAndCkip: modify BSS0 cipher to %s\n", CipherName[csr1.field.Bss0Key0CipherAlg]));
-
- // modify software key table so that driver can specify correct algorithm in TXD upon TX
- for (i=0; i<SHARE_KEY_NUM; i++)
- {
- if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_WEP64)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_CKIP64;
- else if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_WEP128)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_CKIP128;
- }
- }
-
- // else if KP NOT inused. change the CipherAlg in hardware shard key table from CKIP
- // to WEP.
- else
- {
- // modify hardware key table so that MAC use correct algorithm to decrypt RX
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE, &csr1.word);
- if (csr1.field.Bss0Key0CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key0CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key0CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key0CipherAlg = CIPHER_WEP128;
-
- if (csr1.field.Bss0Key1CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key1CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key1CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key1CipherAlg = CIPHER_WEP128;
-
- if (csr1.field.Bss0Key2CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key2CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key2CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key2CipherAlg = CIPHER_WEP128;
-
- if (csr1.field.Bss0Key3CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key3CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key3CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key3CipherAlg = CIPHER_WEP128;
-
- // modify software key table so that driver can specify correct algorithm in TXD upon TX
- for (i=0; i<SHARE_KEY_NUM; i++)
- {
- if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_CKIP64)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_WEP64;
- else if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_CKIP128)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_WEP128;
- }
-
- //
- // On WPA-NONE, must update CipherAlg.
- // Because the OID_802_11_WEP_STATUS was been set after OID_802_11_ADD_KEY
- // and CipherAlg will be CIPHER_NONE by Windows ZeroConfig.
- // So we need to update CipherAlg after connect.
- //
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- for (i = 0; i < SHARE_KEY_NUM; i++)
- {
- if (pAd->SharedKey[BSS0][i].KeyLen != 0)
- {
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
- {
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_TKIP;
- }
- else if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_AES;
- }
- }
- else
- {
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
- }
- }
-
- csr1.field.Bss0Key0CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
- csr1.field.Bss0Key1CipherAlg = pAd->SharedKey[BSS0][1].CipherAlg;
- csr1.field.Bss0Key2CipherAlg = pAd->SharedKey[BSS0][2].CipherAlg;
- csr1.field.Bss0Key3CipherAlg = pAd->SharedKey[BSS0][3].CipherAlg;
- }
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE, csr1.word);
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchBetweenWepAndCkip: modify BSS0 cipher to %s\n", CipherName[csr1.field.Bss0Key0CipherAlg]));
- }
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-VOID SendAssocIEsToWpaSupplicant(
- IN PRTMP_ADAPTER pAd)
-{
- union iwreq_data wrqu;
- unsigned char custom[IW_CUSTOM_MAX] = {0};
-
- if ((pAd->StaCfg.ReqVarIELen + 17) <= IW_CUSTOM_MAX)
- {
- sprintf(custom, "ASSOCINFO_ReqIEs=");
- NdisMoveMemory(custom+17, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.length = pAd->StaCfg.ReqVarIELen + 17;
- wrqu.data.flags = RT_REQIE_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
-
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOCINFO_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen + 17 > MAX_CUSTOM_LEN\n"));
-
- return;
-}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-int wext_notify_event_assoc(
- IN RTMP_ADAPTER *pAd)
-{
- union iwreq_data wrqu;
- char custom[IW_CUSTOM_MAX] = {0};
-
-#if WIRELESS_EXT > 17
- if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX)
- {
- wrqu.data.length = pAd->StaCfg.ReqVarIELen;
- memcpy(custom, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
- wireless_send_event(pAd->net_dev, IWEVASSOCREQIE, &wrqu, custom);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
-#else
- if (((pAd->StaCfg.ReqVarIELen*2) + 17) <= IW_CUSTOM_MAX)
- {
- UCHAR idx;
- wrqu.data.length = (pAd->StaCfg.ReqVarIELen*2) + 17;
- sprintf(custom, "ASSOCINFO(ReqIEs=");
- for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++)
- sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]);
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("(pAd->StaCfg.ReqVarIELen*2) + 17 > MAX_CUSTOM_LEN\n"));
-#endif
-
- return 0;
-
-}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-
-BOOLEAN StaAddMacTableEntry(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN USHORT CapabilityInfo)
-{
- UCHAR MaxSupportedRate = RATE_11;
-
- if (ADHOC_ON(pAd))
- CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- if ((pAd->CommonCfg.PhyMode == PHY_11G) && (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
- return FALSE;
-
-#ifdef DOT11_N_SUPPORT
- // 11n only
- if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G))&& (HtCapabilityLen == 0))
- return FALSE;
-#endif // DOT11_N_SUPPORT //
-
- if (!pEntry)
- return FALSE;
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- if (pEntry)
- {
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
- if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) ||
- (pAd->CommonCfg.PhyMode == PHY_11B))
- {
- pEntry->RateLen = 4;
- if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE)
- MaxSupportedRate = RATE_11;
- }
- else
- pEntry->RateLen = 12;
-
- pEntry->MaxHTPhyMode.word = 0;
- pEntry->MinHTPhyMode.word = 0;
- pEntry->HTPhyMode.word = 0;
- pEntry->MaxSupportedRate = MaxSupportedRate;
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
- pEntry->CapabilityInfo = CapabilityInfo;
- CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
- CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE);
- }
-
-#ifdef DOT11_N_SUPPORT
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR i;
-
- if (ADHOC_ON(pAd))
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
- if ((pHtCapability->HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((pHtCapability->HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(pHtCapability->HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(pHtCapability->HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // 3*3
- if (pAd->MACVersion >= RALINK_2883_VERSION && pAd->MACVersion < RALINK_3070_VERSION)
- pEntry->MaxHTPhyMode.field.TxBF = pAd->CommonCfg.RegTransmitSetting.field.TxBF;
-
- // find max fixed rate
- for (i=23; i>=0; i--) // 3*3
- {
- j = i/8;
- bitmask = (1<<(i-(j*8)));
- if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask) && (pHtCapability->MCSSet[j] & bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = i;
- break;
- }
- if (i==0)
- break;
- }
-
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (pHtCapability->HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = pHtCapability->HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)pHtCapability->HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)pHtCapability->HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED);
- if (pHtCapability->HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (pHtCapability->HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (pHtCapability->HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (pHtCapability->HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (pHtCapability->ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
- }
- else
- {
- pAd->MacTab.fAnyStationIsLegacy = TRUE;
- }
-
- NdisMoveMemory(&pEntry->HTCapability, pHtCapability, sizeof(HT_CAPABILITY_IE));
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
-
- // Set asic auto fall back
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- // If the legacy mode is set, overwrite the transmit setting of this entry.
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
-
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
- pEntry->Sst = SST_ASSOC;
- pEntry->AuthState = AS_AUTH_OPEN;
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
-
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- wext_notify_event_assoc(pAd);
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- return TRUE;
-}
-
-
+#include "../../rt2860/sta/assoc.c"
diff --git a/drivers/staging/rt2870/sta/auth.c b/drivers/staging/rt2870/sta/auth.c
index 73fb8d6ea76f..57632f9ec784 100644
--- a/drivers/staging/rt2870/sta/auth.c
+++ b/drivers/staging/rt2870/sta/auth.c
@@ -1,474 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- auth.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-9-3 porting from RT2500
-*/
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- authenticate state machine init, including state transition and timer init
- Parameters:
- Sm - pointer to the auth state machine
- Note:
- The state machine looks like this
-
- AUTH_REQ_IDLE AUTH_WAIT_SEQ2 AUTH_WAIT_SEQ4
- MT2_MLME_AUTH_REQ mlme_auth_req_action invalid_state_when_auth invalid_state_when_auth
- MT2_PEER_AUTH_EVEN drop peer_auth_even_at_seq2_action peer_auth_even_at_seq4_action
- MT2_AUTH_TIMEOUT Drop auth_timeout_action auth_timeout_action
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-
-void AuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_REQ_IDLE, AUTH_MACHINE_BASE);
-
- // the first column
- StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)MlmeAuthReqAction);
-
- // the second column
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq2Action);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-
- // the third column
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq4Action);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-
- RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer, GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- function to be executed at timer thread when auth timer expires
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- DBGPRINT(RT_DEBUG_TRACE,("AUTH - AuthTimeout\n"));
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- // send a de-auth to reset AP's state machine (Patch AP-Dir635)
- if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
- Cls2errAction(pAd, pAd->MlmeAux.Bssid);
-
-
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeAuthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr[6];
- USHORT Alg, Seq, Status;
- ULONG Timeout;
- HEADER_802_11 AuthHdr;
- BOOLEAN TimerCancelled;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Block Auth request durning WPA block period!\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- else if(MlmeAuthReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr, &Timeout, &Alg))
- {
- // reset timer
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
- pAd->MlmeAux.Alg = Alg;
- Seq = 1;
- Status = MLME_SUCCESS;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeAuthReqAction(Alg:%d) allocate memory failed\n", Alg));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#1 (Alg=%d)...\n", Alg));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&AuthHdr,
- 2, &Alg,
- 2, &Seq,
- 2, &Status,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AuthTimer, Timeout);
- pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
- }
- else
- {
- DBGPRINT_ERR(("AUTH - MlmeAuthReqAction() sanity check failed\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAuthRspAtSeq2Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Seq, Status, RemoteStatus, Alg;
- UCHAR ChlgText[CIPHER_TEXT_LEN];
- UCHAR CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
- UCHAR Element[2];
- HEADER_802_11 AuthHdr;
- BOOLEAN TimerCancelled;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Status2;
-
- if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
- {
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n", Alg, Status));
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-
- if (Status == MLME_SUCCESS)
- {
- // Authentication Mode "LEAP" has allow for CCX 1.X
- if ((pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- )
- {
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-#ifdef LEAP_SUPPORT
- pAd->Mlme.LeapMachine.CurrState = LEAP_IDLE;
-#endif // LEAP_SUPPORT //
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- else
- {
- // 2. shared key, need to be challenged
- Seq++;
- RemoteStatus = MLME_SUCCESS;
-
- // Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status2 = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status2);
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#3...\n"));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr2, pAd->MlmeAux.Bssid);
- AuthHdr.FC.Wep = 1;
- // Encrypt challenge text & auth information
- RTMPInitWepEngine(
- pAd,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
- CyperChlgText);
-
- Alg = cpu2le16(*(USHORT *)&Alg);
- Seq = cpu2le16(*(USHORT *)&Seq);
- RemoteStatus= cpu2le16(*(USHORT *)&RemoteStatus);
-
- RTMPEncryptData(pAd, (PUCHAR) &Alg, CyperChlgText + 4, 2);
- RTMPEncryptData(pAd, (PUCHAR) &Seq, CyperChlgText + 6, 2);
- RTMPEncryptData(pAd, (PUCHAR) &RemoteStatus, CyperChlgText + 8, 2);
- Element[0] = 16;
- Element[1] = 128;
- RTMPEncryptData(pAd, Element, CyperChlgText + 10, 2);
- RTMPEncryptData(pAd, ChlgText, CyperChlgText + 12, 128);
- RTMPSetICV(pAd, CyperChlgText + 140);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AuthHdr,
- CIPHER_TEXT_LEN + 16, CyperChlgText,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AuthTimer, AUTH_TIMEOUT);
- pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ4;
- }
- }
- else
- {
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- //Invalid Authentication possible rogue AP
- //Add this Ap to Rogue AP.
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_INVALID_AUTH);
- }
-#endif // LEAP_SUPPORT //
- pAd->StaCfg.AuthFailReason = Status;
- COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthSanity() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAuthRspAtSeq4Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Alg, Seq, Status;
- CHAR ChlgText[CIPHER_TEXT_LEN];
- BOOLEAN TimerCancelled;
-
- if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
- {
- if(MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#4 to me\n"));
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-
- if (Status != MLME_SUCCESS)
- {
- pAd->StaCfg.AuthFailReason = Status;
- COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
- }
-
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- HEADER_802_11 DeauthHdr;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Status;
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *)Elem->Msg;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send DE-AUTH request (Reason=%d)...\n", pInfo->Reason));
- MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DeauthHdr,
- 2, &pInfo->Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DeauthReason = pInfo->Reason;
- COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
-
- // send wireless event - for deauthentication
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AuthTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID InvalidStateWhenAuth(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n", pAd->Mlme.AuthMachine.CurrState));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- Some STA/AP
- Note:
- This action should never trigger AUTH state transition, therefore we
- separate it from AUTH state machine, and make it as a standalone service
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID Cls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr)
-{
- HEADER_802_11 DeauthHdr;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Reason = REASON_CLS2ERR;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Class 2 error, Send DEAUTH frame...\n"));
- MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DeauthHdr,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DeauthReason = Reason;
- COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
-}
-
-
+#include "../../rt2860/sta/auth.c"
diff --git a/drivers/staging/rt2870/sta/auth_rsp.c b/drivers/staging/rt2870/sta/auth_rsp.c
index 6e3c2d24cdad..783e266d3e8f 100644
--- a/drivers/staging/rt2870/sta/auth_rsp.c
+++ b/drivers/staging/rt2870/sta/auth_rsp.c
@@ -1,166 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- auth_rsp.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-10-1 copy from RT2560
-*/
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- authentication state machine init procedure
- Parameters:
- Sm - the state machine
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID AuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_RSP_IDLE, AUTH_RSP_MACHINE_BASE);
-
- // column 1
- StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
-
- // column 2
- StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID PeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT Reason,
- IN USHORT Status)
-{
- HEADER_802_11 AuthHdr;
- ULONG FrameLen = 0;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
-
- if (Reason != MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
- return;
- }
-
- //Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AuthHdr,
- 2, &Alg,
- 2, &Seq,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID PeerDeauthAction(
- IN PRTMP_ADAPTER pAd,
- IN PMLME_QUEUE_ELEM Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Reason;
-
- if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
- {
- if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason));
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-
- // send wireless event - for deauthentication
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- LinkDown(pAd, TRUE);
-
- // Authentication Mode Cisco_LEAP has start a timer
- // We should cancel it if using LEAP
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
- //Check is it mach the LEAP Authentication failed as possible a Rogue AP
- //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Authenticaton.
- if ((pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED) && (pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE))
- {
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
- }
- }
-#endif // LEAP_SUPPORT //
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
- }
-}
-
+#include "../../rt2860/sta/auth_rsp.c"
diff --git a/drivers/staging/rt2870/sta/connect.c b/drivers/staging/rt2870/sta/connect.c
index c93140a8caa3..f6c7bbf542dc 100644
--- a/drivers/staging/rt2870/sta/connect.c
+++ b/drivers/staging/rt2870/sta/connect.c
@@ -1,2822 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- connect.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-08-08 Major modification from RT2560
-*/
-#include "../rt_config.h"
-
-UCHAR CipherSuiteWpaNoneTkip[] = {
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x00 // authentication
- };
-UCHAR CipherSuiteWpaNoneTkipLen = (sizeof(CipherSuiteWpaNoneTkip) / sizeof(UCHAR));
-
-UCHAR CipherSuiteWpaNoneAes[] = {
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x04, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x04, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x00 // authentication
- };
-UCHAR CipherSuiteWpaNoneAesLen = (sizeof(CipherSuiteWpaNoneAes) / sizeof(UCHAR));
-
-// The following MACRO is called after 1. starting an new IBSS, 2. succesfully JOIN an IBSS,
-// or 3. succesfully ASSOCIATE to a BSS, 4. successfully RE_ASSOCIATE to a BSS
-// All settings successfuly negotiated furing MLME state machines become final settings
-// and are copied to pAd->StaActive
-#define COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
-{ \
- (_pAd)->CommonCfg.SsidLen = (_pAd)->MlmeAux.SsidLen; \
- NdisMoveMemory((_pAd)->CommonCfg.Ssid, (_pAd)->MlmeAux.Ssid, (_pAd)->MlmeAux.SsidLen); \
- COPY_MAC_ADDR((_pAd)->CommonCfg.Bssid, (_pAd)->MlmeAux.Bssid); \
- (_pAd)->CommonCfg.Channel = (_pAd)->MlmeAux.Channel; \
- (_pAd)->CommonCfg.CentralChannel = (_pAd)->MlmeAux.CentralChannel; \
- (_pAd)->StaActive.Aid = (_pAd)->MlmeAux.Aid; \
- (_pAd)->StaActive.AtimWin = (_pAd)->MlmeAux.AtimWin; \
- (_pAd)->StaActive.CapabilityInfo = (_pAd)->MlmeAux.CapabilityInfo; \
- (_pAd)->CommonCfg.BeaconPeriod = (_pAd)->MlmeAux.BeaconPeriod; \
- (_pAd)->StaActive.CfpMaxDuration = (_pAd)->MlmeAux.CfpMaxDuration; \
- (_pAd)->StaActive.CfpPeriod = (_pAd)->MlmeAux.CfpPeriod; \
- (_pAd)->StaActive.SupRateLen = (_pAd)->MlmeAux.SupRateLen; \
- NdisMoveMemory((_pAd)->StaActive.SupRate, (_pAd)->MlmeAux.SupRate, (_pAd)->MlmeAux.SupRateLen);\
- (_pAd)->StaActive.ExtRateLen = (_pAd)->MlmeAux.ExtRateLen; \
- NdisMoveMemory((_pAd)->StaActive.ExtRate, (_pAd)->MlmeAux.ExtRate, (_pAd)->MlmeAux.ExtRateLen);\
- NdisMoveMemory(&(_pAd)->CommonCfg.APEdcaParm, &(_pAd)->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));\
- NdisMoveMemory(&(_pAd)->CommonCfg.APQosCapability, &(_pAd)->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));\
- NdisMoveMemory(&(_pAd)->CommonCfg.APQbssLoad, &(_pAd)->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));\
- COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].Addr, (_pAd)->MlmeAux.Bssid); \
- (_pAd)->MacTab.Content[BSSID_WCID].Aid = (_pAd)->MlmeAux.Aid; \
- (_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = (_pAd)->StaCfg.PairCipher;\
- COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.BssId, (_pAd)->MlmeAux.Bssid);\
- (_pAd)->MacTab.Content[BSSID_WCID].RateLen = (_pAd)->StaActive.SupRateLen + (_pAd)->StaActive.ExtRateLen;\
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
-*/
-VOID MlmeCntlInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- // Control state machine differs from other state machines, the interface
- // follows the standard interface
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID MlmeCntlMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem)
-{
- switch(pAd->Mlme.CntlMachine.CurrState)
- {
- case CNTL_IDLE:
- CntlIdleProc(pAd, Elem);
- break;
- case CNTL_WAIT_DISASSOC:
- CntlWaitDisassocProc(pAd, Elem);
- break;
- case CNTL_WAIT_JOIN:
- CntlWaitJoinProc(pAd, Elem);
- break;
-
- // CNTL_WAIT_REASSOC is the only state in CNTL machine that does
- // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
- // Therefore not protected by NDIS's "only one outstanding OID request"
- // rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
- // Current approach is to block new SET request at RTMPSetInformation()
- // when CntlMachine.CurrState is not CNTL_IDLE
- case CNTL_WAIT_REASSOC:
- CntlWaitReassocProc(pAd, Elem);
- break;
-
- case CNTL_WAIT_START:
- CntlWaitStartProc(pAd, Elem);
- break;
- case CNTL_WAIT_AUTH:
- CntlWaitAuthProc(pAd, Elem);
- break;
- case CNTL_WAIT_AUTH2:
- CntlWaitAuthProc2(pAd, Elem);
- break;
- case CNTL_WAIT_ASSOC:
- CntlWaitAssocProc(pAd, Elem);
- break;
-
- case CNTL_WAIT_OID_LIST_SCAN:
- if(Elem->MsgType == MT2_SCAN_CONF)
- {
- // Resume TxRing after SCANING complete. We hope the out-of-service time
- // won't be too long to let upper layer time-out the waiting frames
- RTMPResumeMsduTransmission(pAd);
- if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED)
- {
- // Cisco scan request is finished, prepare beacon report
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
- }
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
- //
- // Set LED status to previous status.
- //
- if (pAd->bLedOnScanning)
- {
- pAd->bLedOnScanning = FALSE;
- RTMPSetLED(pAd, pAd->LedStatus);
- }
-#ifdef DOT11N_DRAFT3
- // AP sent a 2040Coexistence mgmt frame, then station perform a scan, and then send back the respone.
- if (pAd->CommonCfg.BSSCoexist2040.field.InfoReq == 1)
- {
- Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE);
- }
-#endif // DOT11N_DRAFT3 //
- }
- break;
-
- case CNTL_WAIT_OID_DISASSOC:
- if (Elem->MsgType == MT2_DISASSOC_CONF)
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
- break;
-#ifdef RT2870
- //
- // This state is for that we want to connect to an AP but
- // it didn't find on BSS List table. So we need to scan the air first,
- // after that we can try to connect to the desired AP if available.
- //
- case CNTL_WAIT_SCAN_FOR_CONNECT:
- if(Elem->MsgType == MT2_SCAN_CONF)
- {
- // Resume TxRing after SCANING complete. We hope the out-of-service time
- // won't be too long to let upper layer time-out the waiting frames
- RTMPResumeMsduTransmission(pAd);
-#ifdef CCX_SUPPORT
- if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED)
- {
- // Cisco scan request is finished, prepare beacon report
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
- }
-#endif // CCX_SUPPORT //
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
- //
- // Check if we can connect to.
- //
- BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
- if (pAd->MlmeAux.SsidBssTab.BssNr > 0)
- {
- MlmeAutoReconnectLastSSID(pAd);
- }
- }
- break;
-#endif // RT2870 //
- default:
- DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem->MsgType));
- break;
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlIdleProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- return;
-
- switch(Elem->MsgType)
- {
- case OID_802_11_SSID:
- CntlOidSsidProc(pAd, Elem);
- break;
-
- case OID_802_11_BSSID:
- CntlOidRTBssidProc(pAd,Elem);
- break;
-
- case OID_802_11_BSSID_LIST_SCAN:
- CntlOidScanProc(pAd,Elem);
- break;
-
- case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE_WITH_WEB_UI)
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAd->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
- }
- break;
-
- case MT2_MLME_ROAMING_REQ:
- CntlMlmeRoamingProc(pAd, Elem);
- break;
-
- case OID_802_11_MIC_FAILURE_REPORT_FRAME:
- WpaMicFailureReportFrame(pAd, Elem);
- break;
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS_PARAM:
- CntlOidDLSSetupProc(pAd, Elem);
- break;
-#endif // QOS_DLS_SUPPORT //
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem->MsgType));
- break;
- }
-}
-
-VOID CntlOidScanProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_SCAN_REQ_STRUCT ScanReq;
- ULONG BssIdx = BSS_NOT_FOUND;
- BSS_ENTRY CurrBss;
-
-#ifdef RALINK_ATE
-/* Disable scanning when ATE is running. */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
- // record current BSS if network is connected.
- // 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- BssIdx = BssSsidTableSearch(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->CommonCfg.Channel);
- if (BssIdx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(&CurrBss, &pAd->ScanTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
- }
- }
-
- // clean up previous SCAN result, add current BSS back to table if any
- BssTableInit(&pAd->ScanTab);
- if (BssIdx != BSS_NOT_FOUND)
- {
- // DDK Note: If the NIC is associated with a particular BSSID and SSID
- // that are not contained in the list of BSSIDs generated by this scan, the
- // BSSID description of the currently associated BSSID and SSID should be
- // appended to the list of BSSIDs in the NIC's database.
- // To ensure this, we append this BSS as the first entry in SCAN result
- NdisMoveMemory(&pAd->ScanTab.BssEntry[0], &CurrBss, sizeof(BSS_ENTRY));
- pAd->ScanTab.BssNr = 1;
- }
-
- ScanParmFill(pAd, &ScanReq, "", 0, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
- sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-}
-
-/*
- ==========================================================================
- Description:
- Before calling this routine, user desired SSID should already been
- recorded in CommonCfg.Ssid[]
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidSsidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem)
-{
- PNDIS_802_11_SSID pOidSsid = (NDIS_802_11_SSID *)Elem->Msg;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
- ULONG Now;
-
- // Step 1. record the desired user settings to MlmeAux
- NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, pOidSsid->Ssid, pOidSsid->SsidLength);
- pAd->MlmeAux.SsidLen = (UCHAR)pOidSsid->SsidLength;
- NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
-
- //
- // Update Reconnect Ssid, that user desired to connect.
- //
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
-
- // step 2. find all matching BSS in the lastest SCAN result (inBssTab)
- // & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order
- BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n",
- pAd->MlmeAux.SsidBssTab.BssNr, pAd->ScanTab.BssNr, pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid));
- NdisGetSystemUpTime(&Now);
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
- (pAd->CommonCfg.SsidLen == pAd->MlmeAux.SsidBssTab.BssEntry[0].SsidLen) &&
- NdisEqualMemory(pAd->CommonCfg.Ssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Ssid, pAd->CommonCfg.SsidLen) &&
- MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Bssid))
- {
- // Case 1. already connected with an AP who has the desired SSID
- // with highest RSSI
-
- // Add checking Mode "LEAP" for CCX 1.0
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- ) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- // case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
- // connection process
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else if (pAd->bConfigChanged == TRUE)
- {
- // case 1.2 Important Config has changed, we have to reconnect to the same AP
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else
- {
- // case 1.3. already connected to the SSID with highest RSSI.
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
- //
- // (HCT 12.1) 1c_wlan_mediaevents required
- // media connect events are indicated when associating with the same AP
- //
- if (INFRA_ON(pAd))
- {
- //
- // Since MediaState already is NdisMediaStateConnected
- // We just indicate the connect event again to meet the WHQL required.
- //
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_UP; // Update extra information to link is up
- }
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- }
- else if (INFRA_ON(pAd))
- {
- //
- // For RT61
- // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
- // RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect
- // But media status is connected, so the SSID not report correctly.
- //
- if (!SSID_EQUAL(pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen))
- {
- //
- // Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event.
- //
- pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
- }
- // case 2. active INFRA association existent
- // roaming is done within miniport driver, nothing to do with configuration
- // utility. so upon a new SET(OID_802_11_SSID) is received, we just
- // disassociate with the current associated AP,
- // then perform a new association with this new SSID, no matter the
- // new/old SSID are the same or not.
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else
- {
- if (ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
- LinkDown(pAd, FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
- }
-
- if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) &&
- (pAd->StaCfg.bAutoReconnect == TRUE) &&
- (pAd->MlmeAux.BssType == BSS_INFRA) &&
- (MlmeValidateSSID(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen) == TRUE)
- )
- {
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n"));
- ScanParmFill(pAd, &ScanReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- // Reset Missed scan number
- pAd->StaCfg.LastScanTime = Now;
- }
- else
- {
- pAd->MlmeAux.BssIdx = 0;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidRTBssidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem)
-{
- ULONG BssIdx;
- PUCHAR pOidBssid = (PUCHAR)Elem->Msg;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
- MLME_JOIN_REQ_STRUCT JoinReq;
-
-#ifdef RALINK_ATE
-/* No need to perform this routine when ATE is running. */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- // record user desired settings
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pOidBssid);
- pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
- //
- // Update Reconnect Ssid, that user desired to connect.
- //
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-
- // find the desired BSS in the latest SCAN result table
- BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);
- if (BssIdx == BSS_NOT_FOUND)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- return;
- }
-
- // copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why?
- // Because we need this entry to become the JOIN target in later on SYNC state machine
- pAd->MlmeAux.BssIdx = 0;
- pAd->MlmeAux.SsidBssTab.BssNr = 1;
- NdisMoveMemory(&pAd->MlmeAux.SsidBssTab.BssEntry[0], &pAd->ScanTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
-
- //pAd->MlmeAux.AutoReconnectSsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
- //NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->ScanTab.BssEntry[BssIdx].SsidLen);
-
- // Add SSID into MlmeAux for site surey joining hidden SSID
- //pAd->MlmeAux.SsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
- //NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->MlmeAux.SsidLen);
-
- // 2002-11-26 skip the following checking. i.e. if user wants to re-connect to same AP
- // we just follow normal procedure. The reason of user doing this may because he/she changed
- // AP to another channel, but we still received BEACON from it thus don't claim Link Down.
- // Since user knows he's changed AP channel, he'll re-connect again. By skipping the following
- // checking, we'll disassociate then re-do normal association with this AP at the new channel.
- // 2003-1-6 Re-enable this feature based on microsoft requirement which prefer not to re-do
- // connection when setting the same BSSID.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
- MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pOidBssid))
- {
- // already connected to the same BSSID, go back to idle state directly
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - already in this BSSID. ignore this SET_BSSID request\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- else
- {
- if (INFRA_ON(pAd))
- {
- // disassoc from current AP first
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - disassociate with current AP ...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else
- {
- if (ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - drop current ADHOC\n"));
- LinkDown(pAd, FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
- }
-
- // Change the wepstatus to original wepstatus
- pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- // Set the Pairwise and Group cipher to match the intended AP setting
- // We can only connect to AP with less secured cipher setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher;
- else if (pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher;
- else if (pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-
- // RSN capability
- pAd->StaCfg.RsnCapability = pAd->ScanTab.BssEntry[BssIdx].WPA2.RsnCapability;
- }
-
- // Set Mix cipher flag
- pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
- if (pAd->StaCfg.bMixCipher == TRUE)
- {
- // If mix cipher, re-build RSNIE
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- }
- // No active association, join the BSS immediately
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pOidBssid[0],pOidBssid[1],pOidBssid[2],pOidBssid[3],pOidBssid[4],pOidBssid[5]));
-
- JoinParmFill(pAd, &JoinReq, pAd->MlmeAux.BssIdx);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT), &JoinReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
- }
- }
-}
-
-// Roaming is the only external request triggering CNTL state machine
-// despite of other "SET OID" operation. All "SET OID" related oerations
-// happen in sequence, because no other SET OID will be sent to this device
-// until the the previous SET operation is complete (successful o failed).
-// So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
-// or been corrupted by other "SET OID"?
-//
-// IRQL = DISPATCH_LEVEL
-VOID CntlMlmeRoamingProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- // TODO:
- // AP in different channel may show lower RSSI than actual value??
- // should we add a weighting factor to compensate it?
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
-
- NdisMoveMemory(&pAd->MlmeAux.SsidBssTab, &pAd->MlmeAux.RoamTab, sizeof(pAd->MlmeAux.RoamTab));
- pAd->MlmeAux.SsidBssTab.BssNr = pAd->MlmeAux.RoamTab.BssNr;
-
- BssTableSortByRssi(&pAd->MlmeAux.SsidBssTab);
- pAd->MlmeAux.BssIdx = 0;
- IterateOnBssTab(pAd);
-}
-
-#ifdef QOS_DLS_SUPPORT
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidDLSSetupProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRT_802_11_DLS pDLS = (PRT_802_11_DLS)Elem->Msg;
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- INT i;
- USHORT reason = REASON_UNSPECIFY;
-
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - (OID set %02x:%02x:%02x:%02x:%02x:%02x with Valid=%d, Status=%d, TimeOut=%d, CountDownTimer=%d)\n",
- pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5],
- pDLS->Valid, pDLS->Status, pDLS->TimeOut, pDLS->CountDownTimer));
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- // DLS will not be supported when Adhoc mode
- if (INFRA_ON(pAd))
- {
- for (i = 0; i < MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- (pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 1. Same setting, just drop it
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - setting unchanged\n"));
- break;
- }
- else if (!pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 2. Disable DLS link case, just tear down DLS link
- reason = REASON_QOS_UNWANTED_MECHANISM;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - start tear down procedure\n"));
- break;
- }
- else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid)
- {
- // 3. Enable case, start DLS setup procedure
- NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
-
- //Update countdown timer
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS setup case\n"));
- break;
- }
- else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 4. update mac case, tear down old DLS and setup new DLS
- reason = REASON_QOS_UNWANTED_MECHANISM;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS tear down and restart case\n"));
- break;
- }
- else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut))
- {
- // 5. update timeout case, start DLS setup procedure (no tear down)
- pAd->StaCfg.DLSEntry[i].TimeOut = pDLS->TimeOut;
- //Update countdown timer
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS update timeout case\n"));
- break;
- }
- else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- (pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 6. re-setup case, start DLS setup procedure (no tear down)
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS retry setup procedure\n"));
- break;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN,("CNTL - DLS not changed in entry - %d - Valid=%d, Status=%d, TimeOut=%d\n",
- i, pAd->StaCfg.DLSEntry[i].Valid, pAd->StaCfg.DLSEntry[i].Status, pAd->StaCfg.DLSEntry[i].TimeOut));
- }
- }
- }
-}
-#endif // QOS_DLS_SUPPORT //
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitDisassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_START_REQ_STRUCT StartReq;
-
- if (Elem->MsgType == MT2_DISASSOC_CONF)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Dis-associate successful\n"));
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- LinkDown(pAd, FALSE);
-
- // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
- if ((pAd->MlmeAux.SsidBssTab.BssNr==0) && (pAd->StaCfg.BssType == BSS_ADHOC))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
- StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
- // case 2. try each matched BSS
- else
- {
- pAd->MlmeAux.BssIdx = 0;
-
- IterateOnBssTab(pAd);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitJoinProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_JOIN_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- // 1. joined an IBSS, we are pretty much done here
- if (pAd->MlmeAux.BssType == BSS_ADHOC)
- {
- //
- // 5G bands rules of Japan:
- // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
- //
- if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
- RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
- )
- {
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
- return;
- }
-
- LinkUp(pAd, BSS_ADHOC);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- }
- // 2. joined a new INFRA network, start from authentication
- else
- {
-#ifdef LEAP_SUPPORT
- // Add AuthMode "LEAP" for CCX 1.X
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
- }
- else
-#endif // LEAP_SUPPORT //
- {
- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeShared);
- }
- else
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- }
- }
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH;
- }
- }
- else
- {
- // 3. failed, try next BSS
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitStartProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Result;
-
- if (Elem->MsgType == MT2_START_CONF)
- {
- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
- if (Result == MLME_SUCCESS)
- {
- //
- // 5G bands rules of Japan:
- // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
- //
- if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
- RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
- )
- {
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
- return;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- N_ChannelCheck(pAd);
- SetCommonHT(pAd);
- NdisMoveMemory(&pAd->MlmeAux.AddHtInfo, &pAd->CommonCfg.AddHTInfo, sizeof(ADD_HT_INFO_IE));
- RTMPCheckHt(pAd, BSSID_WCID, &pAd->CommonCfg.HtCapability, &pAd->CommonCfg.AddHTInfo);
- pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
- NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
- NdisMoveMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], &pAd->CommonCfg.HtCapability.MCSSet[0], 16);
- COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
- if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE))
- {
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel + 2;
- }
- else if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW))
- {
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel - 2;
- }
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- }
- LinkUp(pAd, BSS_ADHOC);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- // Before send beacon, driver need do radar detection
- if ((pAd->CommonCfg.Channel > 14 )
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- pAd->CommonCfg.RadarDetect.RDMode = RD_SILENCE_MODE;
- pAd->CommonCfg.RadarDetect.RDCount = 0;
-#ifdef DFS_SUPPORT
- BbpRadarDetectionStart(pAd);
-#endif // DFS_SUPPORT //
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Start IBSS fail. BUG!!!!!\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAuthProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_ASSOC_REQ_STRUCT AssocReq;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_AUTH_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
- AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
-
-#ifdef LEAP_SUPPORT
- //
- // Cisco Leap CCKM supported Re-association.
- //
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- //if CCKM is turn on , that's mean Fast Reauthentication
- //Use CCKM Reassociation instead of normal association for Fast Roaming.
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
- }
- else
-#endif // LEAP_SUPPORT //
- {
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
- }
- }
- else
- {
- // This fail may because of the AP already keep us in its MAC table without
- // ageing-out. The previous authentication attempt must have let it remove us.
- // so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try again...\n"));
-#ifdef LEAP_SUPPORT
- //Add AuthMode "LEAP" for CCX 1.X
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
- }
- else
-#endif // LEAP_SUPPORT //
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
- {
- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeShared);
- }
- else
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- }
- }
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAuthProc2(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_ASSOC_REQ_STRUCT AssocReq;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_AUTH_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
- AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
- }
- else
- {
-#ifdef LEAP_SUPPORT
- // Process LEAP first, since it use different control variable
- // We don't want to affect other poven operation
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- // LEAP Auth not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - *LEAP* AUTH FAIL, give up; try next BSS\n"));
- DBGPRINT(RT_DEBUG_TRACE, ("Total match BSSID [=%d]\n", pAd->MlmeAux.SsidBssTab.BssNr));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- else
-#endif // LEAP_SUPPORT //
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) &&
- (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try OPEN system...\n"));
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
- }
- else
- {
- // not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, give up; try next BSS\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; //???????
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAssocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
-
- if (Elem->MsgType == MT2_ASSOC_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- LinkUp(pAd, BSS_INFRA);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association successful on BSS #%ld\n",pAd->MlmeAux.BssIdx));
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
- else
- {
- // not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association fails on BSS #%ld\n",pAd->MlmeAux.BssIdx));
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitReassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Result;
-
- if (Elem->MsgType == MT2_REASSOC_CONF)
- {
- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
- if (Result == MLME_SUCCESS)
- {
- //
- // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
- //
- LinkUp(pAd, BSS_INFRA);
-
- // send wireless event - for association
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
-
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd))
- {
- STA_PORT_SECURED(pAd);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
-#endif // LEAP_SUPPORT //
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
- }
- else
- {
- // reassoc failed, try to pick next BSS in the BSS Table
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition fails on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
- pAd->MlmeAux.RoamIdx++;
- IterateOnBssTab2(pAd);
- }
- }
-}
-
-
-VOID AdhocTurnOnQos(
- IN PRTMP_ADAPTER pAd)
-{
-#define AC0_DEF_TXOP 0
-#define AC1_DEF_TXOP 0
-#define AC2_DEF_TXOP 94
-#define AC3_DEF_TXOP 47
-
- // Turn on QOs if use HT rate.
- if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
- {
- pAd->CommonCfg.APEdcaParm.bValid = TRUE;
- pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
- pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
- pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
- pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-
- pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
- pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
-
- pAd->CommonCfg.APEdcaParm.Cwmax[0] = 10;
- pAd->CommonCfg.APEdcaParm.Cwmax[1] = 6;
- pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
-
- pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[2] = AC2_DEF_TXOP;
- pAd->CommonCfg.APEdcaParm.Txop[3] = AC3_DEF_TXOP;
- }
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID LinkUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssType)
-{
- ULONG Now;
- UINT32 Data;
- BOOLEAN Cancelled;
- UCHAR Value = 0, idx;
- MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
-
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
- //
- // ASSOC - DisassocTimeoutAction
- // CNTL - Dis-associate successful
- // !!! LINK DOWN !!!
- // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
- //
- // To prevent DisassocTimeoutAction to call Link down after we link up,
- // cancel the DisassocTimer no matter what it start or not.
- //
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
-
- COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
-#ifdef DOT11_N_SUPPORT
- COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-#endif // DOT11_N_SUPPORT //
- // It's quite difficult to tell if a newly added KEY is WEP or CKIP until a new BSS
- // is formed (either ASSOC/RE-ASSOC done or IBSS started. LinkUP should be a safe place
- // to examine if cipher algorithm switching is required.
- //rt2860b. Don't know why need this
- SwitchBetweenWepAndCkip(pAd);
-
-
- if (BssType == BSS_ADHOC)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // No carrier detection when adhoc
- // CarrierDetectionStop(pAd);
- pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- AdhocTurnOnQos(pAd);
-#endif // DOT11_N_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!Adhoc LINK UP !!! \n" ));
- }
- else
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!Infra LINK UP !!! \n" ));
- }
-
- // 3*3
- // reset Tx beamforming bit
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x01);
- Value |= pAd->CommonCfg.RegTransmitSetting.field.TxBF;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
-#ifdef DOT11_N_SUPPORT
- // Change to AP channel
- if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- // Must using 40MHz.
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- Value |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- // RX : control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
- Value &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data &= 0xfffffffe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- // Must using 40MHz.
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- Value |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data |= 0x1;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
- Value |= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data &= 0xfffffffe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
- Value &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! 20MHz LINK UP !!! \n" ));
- }
-
- RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
- //
- // Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission
- //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
- BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
-
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Density =%d, )\n", pAd->MacTab.Content[BSSID_WCID].MpduDensity));
-#endif // DOT11_N_SUPPORT //
-
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-
- AsicSetSlotTime(pAd, TRUE);
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
- // Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit
- AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE, FALSE);
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))
- {
- // Update HT protectionfor based on AP's operating mode.
- if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
- }
- else
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
- NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS));
-
- NdisGetSystemUpTime(&Now);
- pAd->StaCfg.LastBeaconRxTime = Now; // last RX timestamp
-
- if ((pAd->CommonCfg.TxPreamble != Rt802_11PreambleLong) &&
- CAP_IS_SHORT_PREAMBLE_ON(pAd->StaActive.CapabilityInfo))
- {
- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
- }
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
- if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE)
- {
-#ifdef DFS_SUPPORT
- RadarDetectionStop(pAd);
-#endif // DFS_SUPPORT //
- }
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
- if (BssType == BSS_ADHOC)
- {
- MakeIbssBeacon(pAd);
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- ; //Do nothing
- }
- else
- {
- AsicEnableIbssSync(pAd);
- }
-
- // In ad hoc mode, use MAC table from index 1.
- // p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here.
- RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00);
- RTMP_IO_WRITE32(pAd, 0x1808, 0x00);
-
- // If WEP is enabled, add key material and cipherAlg into Asic
- // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
-
- if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
- {
- PUCHAR Key;
- UCHAR CipherAlg;
-
- for (idx=0; idx < SHARE_KEY_NUM; idx++)
- {
- CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
- Key = pAd->SharedKey[BSS0][idx].Key;
-
- if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
- {
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- if (idx == pAd->StaCfg.DefaultKeyId)
- {
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
- }
- }
-
-
- }
- }
- // If WPANone is enabled, add key material and cipherAlg into Asic
- // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
- else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAd->StaCfg.DefaultKeyId = 0; // always be zero
-
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
-
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd->StaCfg.PairCipher));
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- }
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pAd->SharedKey[BSS0][0].CipherAlg, NULL);
-
- }
-
- }
- else // BSS_INFRA
- {
- // Check the new SSID with last SSID
- while (Cancelled == TRUE)
- {
- if (pAd->CommonCfg.LastSsidLen == pAd->CommonCfg.SsidLen)
- {
- if (RTMPCompareMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen) == 0)
- {
- // Link to the old one no linkdown is required.
- break;
- }
- }
- // Send link down event before set to link up
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));
- break;
- }
-
- //
- // On WPA mode, Remove All Keys if not connect to the last BSSID
- // Key will be set after 4-way handshake.
- //
- if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- ULONG IV;
-
- // Remove all WPA keys
- RTMPWPARemoveAllKeys(pAd);
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-
- // Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP
- // If IV related values are too large in GroupMsg2, AP would ignore this message.
- IV = 0;
- IV |= (pAd->StaCfg.DefaultKeyId << 30);
- AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
- }
- // NOTE:
- // the decision of using "short slot time" or not may change dynamically due to
- // new STA association to the AP. so we have to decide that upon parsing BEACON, not here
-
- // NOTE:
- // the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically
- // due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here
-
- ComposePsPoll(pAd);
- ComposeNullFrame(pAd);
-
- AsicEnableBssSync(pAd);
-
- // Add BSSID to WCID search table
- AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- // add this BSSID entry into HASH table
- {
- UCHAR HashIdx;
-
- //pEntry = &pAd->MacTab.Content[BSSID_WCID];
- HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid);
- if (pAd->MacTab.Hash[HashIdx] == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pAd->MacTab.Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
-
- // If WEP is enabled, add paiewise and shared key
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (((pAd->StaCfg.WpaSupplicantUP)&&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)&&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) ||
- ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)&&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)))
-#else
- if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- PUCHAR Key;
- UCHAR CipherAlg;
-
- for (idx=0; idx < SHARE_KEY_NUM; idx++)
- {
- CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
- Key = pAd->SharedKey[BSS0][idx].Key;
-
- if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
- {
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- if (idx == pAd->StaCfg.DefaultKeyId)
- {
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
-
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);
- }
- }
- }
- }
-
- // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
- // should wait until at least 2 active nodes in this BSSID.
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- // For GUI ++
- if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- {
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- RTMP_IndicateMediaState(pAd);
- }
- // --
-
- // Add BSSID in my MAC Table.
- NdisAcquireSpinLock(&pAd->MacTabLock);
- RTMPMoveMemory(pAd->MacTab.Content[BSSID_WCID].Addr, pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
- pAd->MacTab.Content[BSSID_WCID].Aid = BSSID_WCID;
- pAd->MacTab.Content[BSSID_WCID].pAd = pAd;
- pAd->MacTab.Content[BSSID_WCID].ValidAsCLI = TRUE; //Although this is bssid..still set ValidAsCl
- pAd->MacTab.Size = 1; // infra mode always set MACtab size =1.
- pAd->MacTab.Content[BSSID_WCID].Sst = SST_ASSOC;
- pAd->MacTab.Content[BSSID_WCID].AuthState = SST_ASSOC;
- pAd->MacTab.Content[BSSID_WCID].WepStatus = pAd->StaCfg.WepStatus;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! ClientStatusFlags=%lx)\n",
- pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
- MlmeUpdateTxRates(pAd, TRUE, BSS0);
-#ifdef DOT11_N_SUPPORT
- MlmeUpdateHtTxRates(pAd, BSS0);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd->StaActive.SupportedPhyInfo.bHtEnable));
-#endif // DOT11_N_SUPPORT //
-
- //
- // Report Adjacent AP report.
- //
-#ifdef LEAP_SUPPORT
- CCXAdjacentAPReport(pAd);
-#endif // LEAP_SUPPORT //
-
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && (pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)
- {
-
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- RTMPSetPiggyBack(pAd, TRUE);
- DBGPRINT(RT_DEBUG_TRACE, ("Turn on Piggy-Back\n"));
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- }
- }
-
- if (pAd->MlmeAux.APRalinkIe != 0x0)
- {
-#ifdef DOT11_N_SUPPORT
- if (CLIENT_STATUS_TEST_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RDG_CAPABLE))
- {
- AsicEnableRDG(pAd);
- }
-#endif // DOT11_N_SUPPORT //
- OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);
- }
- else
- {
- OPSTATUS_CLEAR_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
- CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);
- }
- }
-
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n", pAd->CommonCfg.BACapability.word, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-#endif // DOT11_N_SUPPORT //
-
- // Set LED
- RTMPSetLED(pAd, LED_LINK_UP);
-
- pAd->Mlme.PeriodicRound = 0;
- pAd->Mlme.OneSecPeriodicRound = 0;
- pAd->bConfigChanged = FALSE; // Reset config flag
- pAd->ExtraInfo = GENERAL_LINK_UP; // Update extra information to link is up
-
- // Set asic auto fall back
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID], &pTable, &TableSize, &pAd->CommonCfg.TxRateIndex);
- AsicUpdateAutoFallBackTable(pAd, pTable);
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
- pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
- if (pAd->StaCfg.bAutoTxRateSwitch == FALSE)
- {
- pEntry->bAutoTxRateSwitch = FALSE;
-#ifdef DOT11_N_SUPPORT
- if (pEntry->HTPhyMode.field.MCS == 32)
- pEntry->HTPhyMode.field.ShortGI = GI_800;
-
- if ((pEntry->HTPhyMode.field.MCS > MCS_7) || (pEntry->HTPhyMode.field.MCS == 32))
- pEntry->HTPhyMode.field.STBC = STBC_NONE;
-#endif // DOT11_N_SUPPORT //
- // If the legacy mode is set, overwrite the transmit setting of this entry.
- if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM)
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- else
- pEntry->bAutoTxRateSwitch = TRUE;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- // Let Link Status Page display first initial rate.
- pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
- // Select DAC according to HT or Legacy
- if (pAd->StaActive.SupportedPhyInfo.MCSSet[0] != 0x00)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
- Value &= (~0x18);
- if (pAd->Antenna.field.TxPath == 2)
- {
- Value |= 0x10;
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
- Value &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- {
- }
- else if (pEntry->MaxRAmpduFactor == 0)
- {
- // If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0.
- // Because our Init value is 1 at MACRegTable.
- RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff);
- }
-#endif // DOT11_N_SUPPORT //
-
- // Patch for Marvel AP to gain high throughput
- // Need to set as following,
- // 1. Set txop in register-EDCA_AC0_CFG as 0x60
- // 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero
- // 3. PBF_MAX_PCNT as 0x1F3FBF9F
- // 4. kick per two packets when dequeue
- //
- // Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable
- //
- // if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is.
-#ifdef DOT11_N_SUPPORT
- if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)))
- || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)))
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n"));
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (pAd->CommonCfg.bEnableTxBurst)
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- Data |= 0x60;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = TRUE;
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3FBF9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 2\n"));
- }
- else
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n"));
- }
-
-#ifdef DOT11_N_SUPPORT
- // Re-check to turn on TX burst or not.
- if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) && ((STA_WEP_ON(pAd))||(STA_TKIP_ON(pAd))))
- {
- pAd->CommonCfg.IOTestParm.bNextDisableRxBA = TRUE;
- if (pAd->CommonCfg.bEnableTxBurst)
- {
- UINT32 MACValue = 0;
- // Force disable TXOP value in this case. The same action in MLMEUpdateProtect too.
- // I didn't change PBF_MAX_PCNT setting.
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &MACValue);
- MACValue &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, MACValue);
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
- }
- }
- else
- {
- pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE;
- }
-#endif // DOT11_N_SUPPORT //
-
- pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE;
- COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!pAd->bNextDisableRxBA= %d \n", pAd->CommonCfg.IOTestParm.bNextDisableRxBA));
- // BSSID add in one MAC entry too. Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap
- // Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver.
- // Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same.
-
- if (pAd->StaCfg.WepStatus <= Ndis802_11WEPDisabled)
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pEntry->PortSecured = pAd->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- //
- // Patch Atheros AP TX will breakdown issue.
- // AP Model: DLink DWL-8200AP
- //
- if (INFRA_ON(pAd) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && STA_TKIP_ON(pAd))
- {
- RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x01);
- }
- else
- {
- RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x00);
- }
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if ((pAd->CommonCfg.BACapability.field.b2040CoexistScanSup) && (pAd->CommonCfg.Channel <= 11))
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SCAN_2040);
- BuildEffectedChannelList(pAd);
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-}
-
-/*
- ==========================================================================
-
- Routine Description:
- Disconnect current BSSID
-
- Arguments:
- pAd - Pointer to our adapter
- IsReqFromAP - Request from AP
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- We need more information to know it's this requst from AP.
- If yes! we need to do extra handling, for example, remove the WPA key.
- Otherwise on 4-way handshaking will faied, since the WPA key didn't be
- remove while auto reconnect.
- Disconnect request from AP, it means we will start afresh 4-way handshaking
- on WPA mode.
-
- ==========================================================================
-*/
-VOID LinkDown(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN IsReqFromAP)
-{
- UCHAR i, ByteValue = 0;
-
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
- if (ADHOC_ON(pAd)) // Adhoc mode link down
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n"));
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MacTab.Size=%d !!!\n", pAd->MacTab.Size));
- }
- else // Infra structure mode
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n"));
-
-#ifdef QOS_DLS_SUPPORT
- // DLS tear down frame must be sent before link down
- // send DLS-TEAR_DOWN message
- if (pAd->CommonCfg.bDLSCapable)
- {
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-#endif // QOS_DLS_SUPPORT //
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- // Saved last SSID for linkup comparison
- pAd->CommonCfg.LastSsidLen = pAd->CommonCfg.SsidLen;
- NdisMoveMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen);
- COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
- if (pAd->MlmeAux.CurrReqIsFromNdis == TRUE)
- {
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"));
- pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
- }
- else
- {
- //
- // If disassociation request is from NDIS, then we don't need to delete BSSID from entry.
- // Otherwise lost beacon or receive De-Authentication from AP,
- // then we should delete BSSID from BssTable.
- // If we don't delete from entry, roaming will fail.
- //
- BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
- }
-
- // restore back to -
- // 1. long slot (20 us) or short slot (9 us) time
- // 2. turn on/off RTS/CTS and/or CTS-to-self protection
- // 3. short preamble
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
-
- if (pAd->StaCfg.CCXAdjacentAPReportFlag == TRUE)
- {
- //
- // Record current AP's information.
- // for later used reporting Adjacent AP report.
- //
- pAd->StaCfg.CCXAdjacentAPChannel = pAd->CommonCfg.Channel;
- pAd->StaCfg.CCXAdjacentAPSsidLen = pAd->CommonCfg.SsidLen;
- NdisMoveMemory(pAd->StaCfg.CCXAdjacentAPSsid, pAd->CommonCfg.Ssid, pAd->StaCfg.CCXAdjacentAPSsidLen);
- COPY_MAC_ADDR(pAd->StaCfg.CCXAdjacentAPBssid, pAd->CommonCfg.Bssid);
- }
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // Country IE of the AP will be evaluated and will be used.
- if (pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None)
- {
- NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pAd->StaCfg.StaOriCountryCode[0], 2);
- pAd->CommonCfg.Geography = pAd->StaCfg.StaOriGeography;
- BuildChannelListEx(pAd);
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- }
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
- MacTableDeleteEntry(pAd, pAd->MacTab.Content[i].Aid, pAd->MacTab.Content[i].Addr);
- }
-
- pAd->StaCfg.CCXQosECWMin = 4;
- pAd->StaCfg.CCXQosECWMax = 10;
-
- AsicSetSlotTime(pAd, TRUE); //FALSE);
- AsicSetEdcaParm(pAd, NULL);
-
- // Set LED
- RTMPSetLED(pAd, LED_LINK_DOWN);
- pAd->LedIndicatorStregth = 0xF0;
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
-
- AsicDisableSync(pAd);
-
- pAd->Mlme.PeriodicRound = 0;
- pAd->Mlme.OneSecPeriodicRound = 0;
-
- if (pAd->StaCfg.BssType == BSS_INFRA)
- {
- // Remove StaCfg Information after link down
- NdisZeroMemory(pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
- NdisZeroMemory(pAd->CommonCfg.Ssid, MAX_LEN_OF_SSID);
- pAd->CommonCfg.SsidLen = 0;
- }
-#ifdef DOT11_N_SUPPORT
- NdisZeroMemory(&pAd->MlmeAux.HtCapability, sizeof(HT_CAPABILITY_IE));
- NdisZeroMemory(&pAd->MlmeAux.AddHtInfo, sizeof(ADD_HT_INFO_IE));
- pAd->MlmeAux.HtCapabilityLen = 0;
- pAd->MlmeAux.NewExtChannelOffset = 0xff;
-#endif // DOT11_N_SUPPORT //
-
- // Reset WPA-PSK state. Only reset when supplicant enabled
- if (pAd->StaCfg.WpaState != SS_NOTUSE)
- {
- pAd->StaCfg.WpaState = SS_START;
- // Clear Replay counter
- NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
-
-#ifdef QOS_DLS_SUPPORT
- if (pAd->CommonCfg.bDLSCapable)
- NdisZeroMemory(pAd->StaCfg.DlsReplayCounter, 8);
-#endif // QOS_DLS_SUPPORT //
- }
-
-
- //
- // if link down come from AP, we need to remove all WPA keys on WPA mode.
- // otherwise will cause 4-way handshaking failed, since the WPA key not empty.
- //
- if ((IsReqFromAP) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- // Remove all WPA keys
- RTMPWPARemoveAllKeys(pAd);
- }
-
- // 802.1x port control
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Prevent clear PortSecured here with static WEP
- // NetworkManger set security policy first then set SSID to connect AP.
- if (pAd->StaCfg.WpaSupplicantUP &&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
- (pAd->StaCfg.IEEE8021X == FALSE))
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- pAd->StaCfg.MicErrCnt = 0;
-
- // Turn off Ckip control flag
- pAd->StaCfg.bCkipOn = FALSE;
- pAd->StaCfg.CCXEnable = FALSE;
-
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- // Update extra information to link is up
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
-
- //pAd->StaCfg.AdhocBOnlyJoined = FALSE;
- //pAd->StaCfg.AdhocBGJoined = FALSE;
- //pAd->StaCfg.Adhoc20NJoined = FALSE;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
-
- // Reset the Current AP's IP address
- NdisZeroMemory(pAd->StaCfg.AironetIPAddress, 4);
-#ifdef RT2870
- pAd->bUsbTxBulkAggre = FALSE;
-#endif // RT2870 //
-
- // Clean association information
- NdisZeroMemory(&pAd->StaCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));
- pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
- pAd->StaCfg.ReqVarIELen = 0;
- pAd->StaCfg.ResVarIELen = 0;
-
- //
- // Reset RSSI value after link down
- //
- pAd->StaCfg.RssiSample.AvgRssi0 = 0;
- pAd->StaCfg.RssiSample.AvgRssi0X8 = 0;
- pAd->StaCfg.RssiSample.AvgRssi1 = 0;
- pAd->StaCfg.RssiSample.AvgRssi1X8 = 0;
- pAd->StaCfg.RssiSample.AvgRssi2 = 0;
- pAd->StaCfg.RssiSample.AvgRssi2X8 = 0;
-
- // Restore MlmeRate
- pAd->CommonCfg.MlmeRate = pAd->CommonCfg.BasicMlmeRate;
- pAd->CommonCfg.RtsRate = pAd->CommonCfg.BasicMlmeRate;
-
-#ifdef DOT11_N_SUPPORT
- //
- // After Link down, reset piggy-back setting in ASIC. Disable RDG.
- //
- if (pAd->CommonCfg.BBPCurrentBW == BW_40)
- {
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &ByteValue);
- ByteValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, ByteValue);
- }
-#endif // DOT11_N_SUPPORT //
- // Reset DAC
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &ByteValue);
- ByteValue &= (~0x18);
- if (pAd->Antenna.field.TxPath == 2)
- {
- ByteValue |= 0x10;
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, ByteValue);
-
- RTMPSetPiggyBack(pAd,FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
-
-#ifdef DOT11_N_SUPPORT
- pAd->CommonCfg.BACapability.word = pAd->CommonCfg.REGBACapability.word;
-#endif // DOT11_N_SUPPORT //
-
- // Restore all settings in the following.
- AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT|CCKSETPROTECT|OFDMSETPROTECT), TRUE, FALSE);
- AsicDisableRDG(pAd);
- pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE;
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SCAN_2040);
- pAd->CommonCfg.BSSCoexist2040.word = 0;
- TriEventInit(pAd);
- for (i = 0; i < (pAd->ChannelListNum - 1); i++)
- {
- pAd->ChannelList[i].bEffectedChannel = FALSE;
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
- RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP) {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID IterateOnBssTab(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_START_REQ_STRUCT StartReq;
- MLME_JOIN_REQ_STRUCT JoinReq;
- ULONG BssIdx;
-
- // Change the wepstatus to original wepstatus
- pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
- BssIdx = pAd->MlmeAux.BssIdx;
- if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr)
- {
- // Check cipher suite, AP must have more secured cipher than station setting
- // Set the Pairwise and Group cipher to match the intended AP setting
- // We can only connect to AP with less secured cipher setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher;
- else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher;
- else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-
- // RSN capability
- pAd->StaCfg.RsnCapability = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.RsnCapability;
- }
-
- // Set Mix cipher flag
- pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
- if (pAd->StaCfg.bMixCipher == TRUE)
- {
- // If mix cipher, re-build RSNIE
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - iterate BSS %ld of %d\n", BssIdx, pAd->MlmeAux.SsidBssTab.BssNr));
- JoinParmFill(pAd, &JoinReq, BssIdx);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT),
- &JoinReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
- }
- else if (pAd->StaCfg.BssType == BSS_ADHOC)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
- StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
- else // no more BSS
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All roaming failed, stay @ ch #%d\n", pAd->CommonCfg.Channel));
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
-}
-
-// for re-association only
-// IRQL = DISPATCH_LEVEL
-VOID IterateOnBssTab2(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_REASSOC_REQ_STRUCT ReassocReq;
- ULONG BssIdx;
- BSS_ENTRY *pBss;
-
- BssIdx = pAd->MlmeAux.RoamIdx;
- pBss = &pAd->MlmeAux.RoamTab.BssEntry[BssIdx];
-
- if (BssIdx < pAd->MlmeAux.RoamTab.BssNr)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - iterate BSS %ld of %d\n", BssIdx, pAd->MlmeAux.RoamTab.BssNr));
-
- AsicSwitchChannel(pAd, pBss->Channel, FALSE);
- AsicLockChannel(pAd, pBss->Channel);
-
- // reassociate message has the same structure as associate message
- AssocParmFill(pAd, &ReassocReq, pBss->Bssid, pBss->CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
- sizeof(MLME_REASSOC_REQ_STRUCT), &ReassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
- }
- else // no more BSS
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All fast roaming failed, back to ch #%d\n",pAd->CommonCfg.Channel));
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID JoinParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
- IN ULONG BssIdx)
-{
- JoinReq->BssIdx = BssIdx;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID ScanParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN UCHAR ScanType)
-{
- NdisZeroMemory(ScanReq->Ssid, MAX_LEN_OF_SSID);
- ScanReq->SsidLen = SsidLen;
- NdisMoveMemory(ScanReq->Ssid, Ssid, SsidLen);
- ScanReq->BssType = BssType;
- ScanReq->ScanType = ScanType;
-}
-
-#ifdef QOS_DLS_SUPPORT
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID DlsParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
- IN PRT_802_11_DLS pDls,
- IN USHORT reason)
-{
- pDlsReq->pDLS = pDls;
- pDlsReq->Reason = reason;
-}
-#endif // QOS_DLS_SUPPORT //
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID StartParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_START_REQ_STRUCT *StartReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen)
-{
- ASSERT(SsidLen <= MAX_LEN_OF_SSID);
- NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen);
- StartReq->SsidLen = SsidLen;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID AuthParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
- IN PUCHAR pAddr,
- IN USHORT Alg)
-{
- COPY_MAC_ADDR(AuthReq->Addr, pAddr);
- AuthReq->Alg = Alg;
- AuthReq->Timeout = AUTH_TIMEOUT;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-
-
-#ifdef RT2870
-
-VOID MlmeCntlConfirm(
- IN PRTMP_ADAPTER pAd,
- IN ULONG MsgType,
- IN USHORT Msg)
-{
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg);
-}
-
-VOID ComposePsPoll(
- IN PRTMP_ADAPTER pAd)
-{
- PTXINFO_STRUC pTxInfo;
- PTXWI_STRUC pTxWI;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ComposePsPoll\n"));
- NdisZeroMemory(&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
-
- pAd->PsPollFrame.FC.PwrMgmt = 0;
- pAd->PsPollFrame.FC.Type = BTYPE_CNTL;
- pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL;
- pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000;
- COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress);
-
- RTMPZeroMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0], 100);
- pTxInfo = (PTXINFO_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0];
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(PSPOLL_FRAME)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxWI = (PTXWI_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(PSPOLL_FRAME)),
- 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
- RTMPMoveMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
- // Append 4 extra zero bytes.
- pAd->PsPollContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(PSPOLL_FRAME) + 4;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID ComposeNullFrame(
- IN PRTMP_ADAPTER pAd)
-{
- PTXINFO_STRUC pTxInfo;
- PTXWI_STRUC pTxWI;
-
- NdisZeroMemory(&pAd->NullFrame, sizeof(HEADER_802_11));
- pAd->NullFrame.FC.Type = BTYPE_DATA;
- pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC;
- pAd->NullFrame.FC.ToDs = 1;
- COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid);
- RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[0], 100);
- pTxInfo = (PTXINFO_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[0];
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(HEADER_802_11)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxWI = (PTXWI_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(HEADER_802_11)),
- 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
- RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
- pAd->NullContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
-}
-#endif // RT2870 //
-
-
-/*
- ==========================================================================
- Description:
- Pre-build a BEACON frame in the shared memory
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-ULONG MakeIbssBeacon(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR DsLen = 1, IbssLen = 2;
- UCHAR LocalErpIe[3] = {IE_ERP, 1, 0x04};
- HEADER_802_11 BcnHdr;
- USHORT CapabilityInfo;
- LARGE_INTEGER FakeTimestamp;
- ULONG FrameLen = 0;
- PTXWI_STRUC pTxWI = &pAd->BeaconTxWI;
- CHAR *pBeaconFrame = pAd->BeaconBuf;
- BOOLEAN Privacy;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen = 0;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen = 0;
- UCHAR RSNIe = IE_WPA;
-
- if ((pAd->CommonCfg.PhyMode == PHY_11B) && (pAd->CommonCfg.Channel <= 14))
- {
- SupRate[0] = 0x82; // 1 mbps
- SupRate[1] = 0x84; // 2 mbps
- SupRate[2] = 0x8b; // 5.5 mbps
- SupRate[3] = 0x96; // 11 mbps
- SupRateLen = 4;
- ExtRateLen = 0;
- }
- else if (pAd->CommonCfg.Channel > 14)
- {
- SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
- SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
- SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
- SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- SupRateLen = 8;
- ExtRateLen = 0;
-
- //
- // Also Update MlmeRate & RtsRate for G only & A only
- //
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_OFDM;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- else
- {
- SupRate[0] = 0x82; // 1 mbps
- SupRate[1] = 0x84; // 2 mbps
- SupRate[2] = 0x8b; // 5.5 mbps
- SupRate[3] = 0x96; // 11 mbps
- SupRateLen = 4;
-
- ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps,
- ExtRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- ExtRate[2] = 0x18; // 12 mbps, in units of 0.5 Mbps,
- ExtRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- ExtRate[4] = 0x30; // 24 mbps, in units of 0.5 Mbps,
- ExtRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- ExtRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- ExtRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- ExtRateLen = 8;
- }
-
- pAd->StaActive.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->StaActive.SupRate, SupRate, SupRateLen);
- pAd->StaActive.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, ExtRateLen);
-
- // compose IBSS beacon frame
- MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR, pAd->CommonCfg.Bssid);
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
-
- MakeOutgoingFrame(pBeaconFrame, &FrameLen,
- sizeof(HEADER_802_11), &BcnHdr,
- TIMESTAMP_LEN, &FakeTimestamp,
- 2, &pAd->CommonCfg.BeaconPeriod,
- 2, &CapabilityInfo,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &SupRateLen,
- SupRateLen, SupRate,
- 1, &DsIe,
- 1, &DsLen,
- 1, &pAd->CommonCfg.Channel,
- 1, &IbssIe,
- 1, &IbssLen,
- 2, &pAd->StaActive.AtimWin,
- END_OF_ARGS);
-
- // add ERP_IE and EXT_RAE IE of in 802.11g
- if (ExtRateLen)
- {
- ULONG tmp;
-
- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
- 3, LocalErpIe,
- 1, &ExtRateIe,
- 1, &ExtRateLen,
- ExtRateLen, ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // If adhoc secruity is set for WPA-None, append the cipher suite IE
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- ULONG tmp;
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-
- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen, HtLen1;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
- ADD_HT_INFO_IE addHTInfoTmp;
- USHORT b2lTmp, b2lTmp2;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(pAd->CommonCfg.HtCapability);
- HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- 1, &AddHtInfoIe,
- 1, &HtLen1,
- HtLen1, &pAd->CommonCfg.AddHTInfo,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- NdisMoveMemory(&addHTInfoTmp, &pAd->CommonCfg.AddHTInfo, HtLen1);
- *(USHORT *)(&addHTInfoTmp.AddHtInfo2) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo2));
- *(USHORT *)(&addHTInfoTmp.AddHtInfo3) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo3));
-
- MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- 1, &AddHtInfoIe,
- 1, &HtLen1,
- HtLen1, &addHTInfoTmp,
- END_OF_ARGS);
-#endif
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
-
- //beacon use reserved WCID 0xff
- if (pAd->CommonCfg.Channel > 14)
- {
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
- PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
- }
- else
- {
- // Set to use 1Mbps for Adhoc beacon.
- HTTRANSMIT_SETTING Transmit;
- Transmit.word = 0;
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
- PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &Transmit);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, pBeaconFrame, DIR_WRITE, FALSE);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif
-
- DBGPRINT(RT_DEBUG_TRACE, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
- FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel, pAd->CommonCfg.PhyMode));
- return FrameLen;
-}
-
-
+#include "../../rt2860/sta/connect.c"
diff --git a/drivers/staging/rt2870/sta/dls.c b/drivers/staging/rt2870/sta/dls.c
deleted file mode 100644
index 56bfbc33d6f5..000000000000
--- a/drivers/staging/rt2870/sta/dls.c
+++ /dev/null
@@ -1,2210 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- dls.c
-
- Abstract:
- Handle WMM-DLS state machine
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 02-14-2006
- Arvin Tai 06-03-2008 Modified for RT28xx
- */
-
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- dls state machine init, including state transition and timer init
- Parameters:
- Sm - pointer to the dls state machine
- Note:
- The state machine looks like this
-
- DLS_IDLE
- MT2_MLME_DLS_REQUEST MlmeDlsReqAction
- MT2_PEER_DLS_REQUEST PeerDlsReqAction
- MT2_PEER_DLS_RESPONSE PeerDlsRspAction
- MT2_MLME_DLS_TEARDOWN MlmeTearDownAction
- MT2_PEER_DLS_TEARDOWN PeerTearDownAction
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-void DlsStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- UCHAR i;
-
- StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_DLS_STATE, MAX_DLS_MSG, (STATE_MACHINE_FUNC)Drop, DLS_IDLE, DLS_MACHINE_BASE);
-
- // the first column
- StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_REQ, (STATE_MACHINE_FUNC)MlmeDlsReqAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_REQ, (STATE_MACHINE_FUNC)PeerDlsReqAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_RSP, (STATE_MACHINE_FUNC)PeerDlsRspAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)MlmeDlsTearDownAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)PeerDlsTearDownAction);
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- pAd->StaCfg.DLSEntry[i].pAd = pAd;
- RTMPInitTimer(pAd, &pAd->StaCfg.DLSEntry[i].Timer, GET_TIMER_FUNCTION(DlsTimeoutAction), pAd, FALSE);
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- HEADER_802_11 DlsReqHdr;
- PRT_802_11_DLS pDLS = NULL;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_REQUEST;
- ULONG tmp;
- USHORT reason;
- ULONG Timeout;
- BOOLEAN TimerCancelled;
-
- if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &reason))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsReqAction() \n"));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsReqAction() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsReqHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsReqHdr,
- 1, &Category,
- 1, &Action,
- 6, &pDLS->MacAddr,
- 6, pAd->CurrentAddress,
- 2, &pAd->StaActive.CapabilityInfo,
- 2, &pDLS->TimeOut,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR HtLen;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(HT_CAPABILITY_IE);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- FrameLen = FrameLen + tmp;
- }
-#endif // DOT11_N_SUPPORT //
-
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
- Timeout = DLS_TIMEOUT;
- RTMPSetTimer(&pDLS->Timer, Timeout);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT StatusCode = MLME_SUCCESS;
- HEADER_802_11 DlsRspHdr;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_RESPONSE;
- ULONG tmp;
- USHORT CapabilityInfo;
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT DLSTimeOut;
- SHORT i;
- ULONG Timeout;
- BOOLEAN TimerCancelled;
- PRT_802_11_DLS pDLS = NULL;
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR SupportedRatesLen;
- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR HtCapabilityLen;
- HT_CAPABILITY_IE HtCapability;
-
- if (!PeerDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &DLSTimeOut,
- &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
- return;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (i = 0; i < SupportedRatesLen; i++)
- {
- if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
- MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() from %02x:%02x:%02x:%02x:%02x:%02x\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() allocate memory failed \n"));
- return;
- }
-
- if (!INFRA_ON(pAd))
- {
- StatusCode = MLME_REQUEST_DECLINED;
- }
- else if (!pAd->CommonCfg.bWmmCapable)
- {
- StatusCode = MLME_DEST_STA_IS_NOT_A_QSTA;
- }
- else if (!pAd->CommonCfg.bDLSCapable)
- {
- StatusCode = MLME_REQUEST_DECLINED;
- }
- else
- {
- // find table to update parameters
- for (i = (MAX_NUM_OF_DLS_ENTRY-1); i >= 0; i--)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- }
-
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
- pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- pDLS = &pAd->StaCfg.DLSEntry[i];
- break;
- }
- }
-
- // can not find in table, create a new one
- if (i < 0)
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() can not find same entry \n"));
- for (i=(MAX_NUM_OF_DLS_ENTRY - 1); i >= MAX_NUM_OF_INIT_DLS_ENTRY; i--)
- {
- if (!pAd->StaCfg.DLSEntry[i].Valid)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- }
-
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- pAd->StaCfg.DLSEntry[i].Valid = TRUE;
- pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
- pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
- NdisMoveMemory(pAd->StaCfg.DLSEntry[i].MacAddr, SA, MAC_ADDR_LEN);
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- pDLS = &pAd->StaCfg.DLSEntry[i];
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsReqAction() Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
-
- printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS);
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- break;
- }
- }
- }
- StatusCode = MLME_SUCCESS;
-
- // can not find in table, create a new one
- if (i < 0)
- {
- StatusCode = MLME_QOS_UNSPECIFY;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() DLSEntry table full(only can support %d DLS session) \n", MAX_NUM_OF_DLS_ENTRY - MAX_NUM_OF_INIT_DLS_ENTRY));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() use entry(%d) %02x:%02x:%02x:%02x:%02x:%02x\n",
- i, SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
- }
-
- ActHeaderInit(pAd, &DlsRspHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- if (StatusCode == MLME_SUCCESS)
- {
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsRspHdr,
- 1, &Category,
- 1, &Action,
- 2, &StatusCode,
- 6, SA,
- 6, pAd->CurrentAddress,
- 2, &pAd->StaActive.CapabilityInfo,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR HtLen;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(HT_CAPABILITY_IE);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- FrameLen = FrameLen + tmp;
- }
-#endif // DOT11_N_SUPPORT //
-
- if (pDLS && (pDLS->Status != DLS_FINISH))
- {
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
- Timeout = DLS_TIMEOUT;
- RTMPSetTimer(&pDLS->Timer, Timeout);
- }
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsRspHdr,
- 1, &Category,
- 1, &Action,
- 2, &StatusCode,
- 6, SA,
- 6, pAd->CurrentAddress,
- END_OF_ARGS);
- }
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo;
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT StatusCode;
- SHORT i;
- BOOLEAN TimerCancelled;
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR SupportedRatesLen;
- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR HtCapabilityLen;
- HT_CAPABILITY_IE HtCapability;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- if (!INFRA_ON(pAd))
- return;
-
- if (!PeerDlsRspSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &StatusCode,
- &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
- return;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (i=0; i<SupportedRatesLen; i++)
- {
- if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
- MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x with StatusCode=%d, CapabilityInfo=0x%x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], StatusCode, CapabilityInfo));
-
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (StatusCode == MLME_SUCCESS)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsRspAction Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
- }
- else
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
- }
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
-
- //initialize seq no for DLS frames.
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- }
- else
- {
- // DLS setup procedure failed.
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
- }
- }
- }
-
- if (i >= MAX_NUM_OF_INIT_DLS_ENTRY)
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() update timeout value \n"));
- for (i=(MAX_NUM_OF_DLS_ENTRY-1); i>=MAX_NUM_OF_INIT_DLS_ENTRY; i--)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (StatusCode == MLME_SUCCESS)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- DBGPRINT(RT_DEBUG_OFF, ("DLS - PeerDlsRspAction Receive Peer HT Capable STA from %02x:%02x:%02x:%02x:%02x:%02x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS);
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
- }
- else
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
- }
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- }
- else
- {
- // DLS setup procedure failed.
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
- }
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_TEARDOWN;
- USHORT ReasonCode = REASON_QOS_UNSPECIFY;
- HEADER_802_11 DlsTearDownHdr;
- PRT_802_11_DLS pDLS;
- BOOLEAN TimerCancelled;
- UCHAR i;
-
- if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &ReasonCode))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsTearDownAction() with ReasonCode=%d \n", ReasonCode));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsTearDownAction() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsTearDownHdr,
- 1, &Category,
- 1, &Action,
- 6, &pDLS->MacAddr,
- 6, pAd->CurrentAddress,
- 2, &ReasonCode,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
-
- // Remove key in local dls table entry
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // clear peer dls table entry
- for (i = MAX_NUM_OF_INIT_DLS_ENTRY; i < MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT ReasonCode;
- UINT i;
- BOOLEAN TimerCancelled;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- if (!INFRA_ON(pAd))
- return;
-
- if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsTearDownAction() from %02x:%02x:%02x:%02x:%02x:%02x with ReasonCode=%d\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], ReasonCode));
-
- // clear local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // clear peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID RTMPCheckDLSTimeOut(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_UNSPECIFY;
-
- if (! pAd->CommonCfg.bDLSCapable)
- return;
-
- if (! INFRA_ON(pAd))
- return;
-
- // If timeout value is equaled to zero, it means always not be timeout.
-
- // update local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer --;
-
- if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- }
- }
-
- // update peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer --;
-
- if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN RTMPRcvFrameDLSCheck(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN ULONG Len,
- IN PRT28XX_RXD_STRUC pRxD)
-{
- ULONG i;
- BOOLEAN bFindEntry = FALSE;
- BOOLEAN bSTAKeyFrame = FALSE;
- PEAPOL_PACKET pEap;
- PUCHAR pProto, pAddr = NULL;
- PUCHAR pSTAKey = NULL;
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
- UCHAR Mic[16], OldMic[16];
- UCHAR digest[80];
- UCHAR DlsPTK[80];
- UCHAR temp[64];
- BOOLEAN TimerCancelled;
- CIPHER_KEY PairwiseKey;
-
-
- if (! pAd->CommonCfg.bDLSCapable)
- return bSTAKeyFrame;
-
- if (! INFRA_ON(pAd))
- return bSTAKeyFrame;
-
- if (! (pHeader->FC.SubType & 0x08))
- return bSTAKeyFrame;
-
- if (Len < LENGTH_802_11 + 6 + 2 + 2)
- return bSTAKeyFrame;
-
- pProto = (PUCHAR)pHeader + LENGTH_802_11 + 2 + 6; // QOS Control field , 0xAA 0xAA 0xAA 0x00 0x00 0x00
- pAddr = pHeader->Addr2;
-
- // L2PAD bit on will pad 2 bytes at LLC
- if (pRxD->L2PAD)
- {
- pProto += 2;
- }
-
- if (RTMPEqualMemory(EAPOL, pProto, 2) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- pEap = (PEAPOL_PACKET) (pProto + 2);
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff Len=%ld, DataLen=%d, KeyMic=%d, Install=%d, KeyAck=%d, Secure=%d, EKD_DL=%d, Error=%d, Request=%d\n", Len,
- (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16),
- pEap->KeyDesc.KeyInfo.KeyMic,
- pEap->KeyDesc.KeyInfo.Install,
- pEap->KeyDesc.KeyInfo.KeyAck,
- pEap->KeyDesc.KeyInfo.Secure,
- pEap->KeyDesc.KeyInfo.EKD_DL,
- pEap->KeyDesc.KeyInfo.Error,
- pEap->KeyDesc.KeyInfo.Request));
-
- if ((Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16)) && pEap->KeyDesc.KeyInfo.KeyMic
- && pEap->KeyDesc.KeyInfo.Install && pEap->KeyDesc.KeyInfo.KeyAck && pEap->KeyDesc.KeyInfo.Secure
- && pEap->KeyDesc.KeyInfo.EKD_DL && !pEap->KeyDesc.KeyInfo.Error && !pEap->KeyDesc.KeyInfo.Request)
- {
- // First validate replay counter, only accept message with larger replay counter
- // Let equal pass, some AP start with all zero replay counter
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
- if ((RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- return bSTAKeyFrame;
-
- //RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter (%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
- pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
- pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
- pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
-
- // put these code segment to get the replay counter
- if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
- return bSTAKeyFrame;
-
- // Check MIC value
- // Save the MIC and replace with zero
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- NdisMoveMemory(OldMic, pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1((PUCHAR) pEap, pEap->Body_Len[1] + 4, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic);
- }
-
- if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in Msg1 of STAKey handshake! \n"));
- return bSTAKeyFrame;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("MIC VALID in Msg1 of STAKey handshake! \n"));
-#if 1
- if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0C)
- && (pEap->KeyDesc.KeyData[4] == 0x43) && (pEap->KeyDesc.KeyData[5] == 0x02))
- {
- pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
- pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%ld, KeyDataLen=%d\n",
- pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
-
- bSTAKeyFrame = TRUE;
- }
-#else
- if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0F)
- && (pEap->KeyDesc.KeyData[4] == 0xAC) && (pEap->KeyDesc.KeyData[5] == 0x02))
- {
- pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
- pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%d, KeyDataLen=%d\n",
- pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
-
- bSTAKeyFrame = TRUE;
- }
-#endif
-
- }
- else if (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE))
- {
-#if 0
- RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
-#endif
- RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter 2(%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
- pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
- pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
- pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
-
- }
- }
-
- // If timeout value is equaled to zero, it means always not be timeout.
- // update local dls table entry
- for (i= 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (bSTAKeyFrame)
- {
- PMAC_TABLE_ENTRY pEntry;
-
- // STAKey frame, add pairwise key table
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-
- PairwiseKey.KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
- NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
-
- PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
-
- pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- // Add Pair-wise key to Asic
-#ifdef RT2870
- {
- RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
- COPY_MAC_ADDR(KeyInfo.MacAddr,pAd->StaCfg.DLSEntry[i].MacAddr);
- KeyInfo.MacTabMatchWCID=pAd->StaCfg.DLSEntry[i].MacTabMatchWCID;
- NdisMoveMemory(&KeyInfo.CipherKey, &PairwiseKey,sizeof(CIPHER_KEY));
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_KEY_TABLE, &KeyInfo, sizeof(RT_ADD_PAIRWISE_KEY_ENTRY));
- }
- {
- PMAC_TABLE_ENTRY pDLSEntry;
- pDLSEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- pDLSEntry->PairwiseKey.CipherAlg=PairwiseKey.CipherAlg;
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_RX_WCID_TABLE, pDLSEntry, sizeof(MAC_TABLE_ENTRY));
- }
-#endif // RT2870 //
- NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n"));
-
- RTMPSendSTAKeyHandShake(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Initiator side)\n"));
- }
- else
- {
- // Data frame, update timeout value
- if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- }
- }
-
- bFindEntry = TRUE;
- }
- }
-
- // update peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (bSTAKeyFrame)
- {
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- // STAKey frame, add pairwise key table, and send STAkey Msg-2
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-
- PairwiseKey.KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
- NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
-
- PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
-
- pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- // Add Pair-wise key to Asic
-#ifdef RT2870
- {
- RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
- COPY_MAC_ADDR(KeyInfo.MacAddr,pAd->StaCfg.DLSEntry[i].MacAddr);
- KeyInfo.MacTabMatchWCID=pAd->StaCfg.DLSEntry[i].MacTabMatchWCID;
- NdisMoveMemory(&KeyInfo.CipherKey, &PairwiseKey,sizeof(CIPHER_KEY));
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_KEY_TABLE, &KeyInfo, sizeof(RT_ADD_PAIRWISE_KEY_ENTRY));
- }
- {
- PMAC_TABLE_ENTRY pDLSEntry;
- pDLSEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- pDLSEntry->PairwiseKey.CipherAlg=PairwiseKey.CipherAlg;
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_RX_WCID_TABLE, pDLSEntry, sizeof(MAC_TABLE_ENTRY));
- }
-#endif // RT2870 //
- NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Initiator STA MAC Address STAKey)\n"));
-
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyHandShake(pAd, pAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Peer side)\n"));
- }
- }
- else
- {
- // Data frame, update timeout value
- if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- }
- }
-
- bFindEntry = TRUE;
- }
- }
-
-
- return bSTAKeyFrame;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check if the frame can be sent through DLS direct link interface
-
- Arguments:
- pAd Pointer to adapter
-
- Return Value:
- DLS entry index
-
- Note:
-
- ========================================================================
-*/
-INT RTMPCheckDLSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- INT rval = -1;
- INT i;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return rval;
-
- if (!INFRA_ON(pAd))
- return rval;
-
- do{
- // check local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- rval = i;
- break;
- }
- }
-
- // check peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- rval = i;
- break;
- }
- }
- } while (FALSE);
-
- return rval;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- HEADER_802_11 DlsTearDownHdr;
- ULONG FrameLen = 0;
- USHORT Reason = REASON_QOS_QSTA_LEAVING_QBSS;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_TEARDOWN;
- UCHAR i = 0;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame \n"));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ASSOC - RTMPSendDLSTearDownFrame() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsTearDownHdr,
- 1, &Category,
- 1, &Action,
- 6, pDA,
- 6, pAd->CurrentAddress,
- 2, &Reason,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- // Remove key in local dls table entry
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // Remove key in peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame and remove key in (i=%d) \n", i));
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-NDIS_STATUS RTMPSendSTAKeyRequest(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- UCHAR Header802_3[14];
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- UCHAR digest[80];
- PUCHAR pOutBuffer = NULL;
- PNDIS_PACKET pNdisPacket;
- UCHAR temp[64];
- UCHAR DlsPTK[80];
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyRequest() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-
- pAd->Sequence ++;
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE andPeer MAC address
-
- // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
-
- // Key descriptor version
- Packet.KeyDesc.KeyInfo.KeyDescVer =
- (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
- Packet.KeyDesc.KeyInfo.Request = 1;
-
- Packet.KeyDesc.KeyDataLen[1] = 12;
-
- // use our own OUI to distinguish proprietary with standard.
- Packet.KeyDesc.KeyData[0] = 0xDD;
- Packet.KeyDesc.KeyData[1] = 0x0A;
- Packet.KeyDesc.KeyData[2] = 0x00;
- Packet.KeyDesc.KeyData[3] = 0x0C;
- Packet.KeyDesc.KeyData[4] = 0x43;
- Packet.KeyDesc.KeyData[5] = 0x03;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Allocate buffer for transmitting message
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return NStatus;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- // calculate MIC
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- NdisZeroMemory(digest, sizeof(digest));
- HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
- }
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(Header802_3), Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
- STASendPacket(pAd, pNdisPacket);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyRequest- Send STAKey request (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
-
- return NStatus;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-NDIS_STATUS RTMPSendSTAKeyHandShake(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- UCHAR Header802_3[14];
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- UCHAR digest[80];
- PUCHAR pOutBuffer = NULL;
- PNDIS_PACKET pNdisPacket;
- UCHAR temp[64];
- UCHAR DlsPTK[80]; // Due to dirver can not get PTK, use proprietary PTK
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyHandShake() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-
- pAd->Sequence ++;
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE and Peer MAC address
-
- // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
-
- // Key descriptor version
- Packet.KeyDesc.KeyInfo.KeyDescVer =
- (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- Packet.KeyDesc.KeyDataLen[1] = 12;
-
- // use our own OUI to distinguish proprietary with standard.
- Packet.KeyDesc.KeyData[0] = 0xDD;
- Packet.KeyDesc.KeyData[1] = 0x0A;
- Packet.KeyDesc.KeyData[2] = 0x00;
- Packet.KeyDesc.KeyData[3] = 0x0C;
- Packet.KeyDesc.KeyData[4] = 0x43;
- Packet.KeyDesc.KeyData[5] = 0x03;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Allocate buffer for transmitting message
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return NStatus;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- // calculate MIC
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- NdisZeroMemory(digest, sizeof(digest));
- HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
- }
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(Header802_3), Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
- STASendPacket(pAd, pNdisPacket);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyHandShake- Send STAKey Message-2 (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
-
- return NStatus;
-}
-
-VOID DlsTimeoutAction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason;
- PRT_802_11_DLS pDLS = (PRT_802_11_DLS)FunctionContext;
- PRTMP_ADAPTER pAd = pDLS->pAd;
-
- DBGPRINT(RT_DEBUG_TRACE, ("DlsTimeout - Tear down DLS links (%02x:%02x:%02x:%02x:%02x:%02x)\n",
- pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5]));
-
- if ((pDLS) && (pDLS->Valid))
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pDLS->Valid = FALSE;
- pDLS->Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, pDLS, reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-
-/*
-================================================================
-Description : because DLS and CLI share the same WCID table in ASIC.
-Mesh entry also insert to pAd->MacTab.content[]. Such is marked as ValidAsDls = TRUE.
-Also fills the pairwise key.
-Because front MAX_AID_BA entries have direct mapping to BAEntry, which is only used as CLI. So we insert Dls
-from index MAX_AID_BA.
-================================================================
-*/
-MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UINT DlsEntryIdx)
-{
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableInsertDlsEntry\n"));
- // if FULL, return
- if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
- return NULL;
-
- do
- {
- if((pEntry = DlsEntryTableLookup(pAd, pAddr, TRUE)) != NULL)
- break;
-
- // allocate one MAC entry
- pEntry = MacTableInsertEntry(pAd, pAddr, DlsEntryIdx + MIN_NET_DEVICE_FOR_DLS, TRUE);
- if (pEntry)
- {
- pAd->StaCfg.DLSEntry[DlsEntryIdx].MacTabMatchWCID = pEntry->Aid;
- pEntry->MatchDlsEntryIdx = DlsEntryIdx;
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertDlsEntry - allocate entry #%d, Total= %d\n",pEntry->Aid, pAd->MacTab.Size));
-
- // If legacy WEP is used, set pair-wise cipherAlg into WCID attribute table for this entry
- if ((pEntry->ValidAsDls) && (pEntry->WepStatus == Ndis802_11WEPEnabled))
- {
- UCHAR KeyIdx = 0;
- UCHAR CipherAlg = 0;
-
- KeyIdx = pAd->StaCfg.DefaultKeyId;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pEntry);
- }
-
- break;
- }
- } while(FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableInsertDlsEntry\n"));
-
- return pEntry;
-}
-
-
-/*
- ==========================================================================
- Description:
- Delete all Mesh Entry in pAd->MacTab
- ==========================================================================
- */
-BOOLEAN MacTableDeleteDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableDeleteDlsEntry\n"));
-
- if (!VALID_WCID(wcid))
- return FALSE;
-
- MacTableDeleteEntry(pAd, wcid, pAddr);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableDeleteDlsEntry\n"));
-
- return TRUE;
-}
-
-MAC_TABLE_ENTRY *DlsEntryTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount)
-{
- ULONG HashIdx;
- MAC_TABLE_ENTRY *pEntry = NULL;
-
- RTMP_SEM_LOCK(&pAd->MacTabLock);
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- pEntry = pAd->MacTab.Hash[HashIdx];
-
- while (pEntry)
- {
- if ((pEntry->ValidAsDls == TRUE)
- && MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
- if(bResetIdelCount)
- pEntry->NoDataIdleCount = 0;
- break;
- }
- else
- pEntry = pEntry->pNext;
- }
-
- RTMP_SEM_UNLOCK(&pAd->MacTabLock);
- return pEntry;
-}
-
-MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR wcid,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount)
-{
- ULONG DLsIndex;
- PMAC_TABLE_ENTRY pCurEntry = NULL;
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- if (!VALID_WCID(wcid))
- return NULL;
-
- RTMP_SEM_LOCK(&pAd->MacTabLock);
-
- do
- {
- pCurEntry = &pAd->MacTab.Content[wcid];
-
- DLsIndex = 0xff;
- if ((pCurEntry) && (pCurEntry->ValidAsDls== TRUE))
- {
- DLsIndex = pCurEntry->MatchDlsEntryIdx;
- }
-
- if (DLsIndex == 0xff)
- break;
-
- if (MAC_ADDR_EQUAL(pCurEntry->Addr, pAddr))
- {
- if(bResetIdelCount)
- pCurEntry->NoDataIdleCount = 0;
- pEntry = pCurEntry;
- break;
- }
- } while(FALSE);
-
- RTMP_SEM_UNLOCK(&pAd->MacTabLock);
-
- return pEntry;
-}
-
-INT Set_DlsEntryInfo_Display_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- INT i;
-
- printk("\n%-19s%-8s\n", "MAC", "TIMEOUT\n");
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[pAd->StaCfg.DLSEntry[i].MacTabMatchWCID];
-
- printk("%02x:%02x:%02x:%02x:%02x:%02x ",
- pAd->StaCfg.DLSEntry[i].MacAddr[0], pAd->StaCfg.DLSEntry[i].MacAddr[1], pAd->StaCfg.DLSEntry[i].MacAddr[2],
- pAd->StaCfg.DLSEntry[i].MacAddr[3], pAd->StaCfg.DLSEntry[i].MacAddr[4], pAd->StaCfg.DLSEntry[i].MacAddr[5]);
- printk("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut);
-
- printk("\n");
- printk("\n%-19s%-4s%-4s%-4s%-4s%-7s%-7s%-7s","MAC", "AID", "BSS", "PSM", "WMM", "RSSI0", "RSSI1", "RSSI2");
-#ifdef DOT11_N_SUPPORT
- printk("%-8s%-10s%-6s%-6s%-6s%-6s", "MIMOPS", "PhMd", "BW", "MCS", "SGI", "STBC");
-#endif // DOT11_N_SUPPORT //
- printk("\n%02X:%02X:%02X:%02X:%02X:%02X ",
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- printk("%-4d", (int)pEntry->Aid);
- printk("%-4d", (int)pEntry->apidx);
- printk("%-4d", (int)pEntry->PsMode);
- printk("%-4d", (int)CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE));
- printk("%-7d", pEntry->RssiSample.AvgRssi0);
- printk("%-7d", pEntry->RssiSample.AvgRssi1);
- printk("%-7d", pEntry->RssiSample.AvgRssi2);
-#ifdef DOT11_N_SUPPORT
- printk("%-8d", (int)pEntry->MmpsMode);
- printk("%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
- printk("%-6s", GetBW(pEntry->HTPhyMode.field.BW));
- printk("%-6d", pEntry->HTPhyMode.field.MCS);
- printk("%-6d", pEntry->HTPhyMode.field.ShortGI);
- printk("%-6d", pEntry->HTPhyMode.field.STBC);
-#endif // DOT11_N_SUPPORT //
- printk("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
- (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
- printk("\n");
-
- }
- }
-
- return TRUE;
-}
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[MAC_ADDR_LEN];
- USHORT Timeout;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- RT_802_11_DLS Dls;
-
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and timeout value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- Timeout = simple_strtol((token+1), 0, 10);
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%d", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], (int)Timeout);
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- Dls.TimeOut = Timeout;
- COPY_MAC_ADDR(Dls.MacAddr, mac);
- Dls.Valid = 1;
-
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_DlsTearDownEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR macAddr[MAC_ADDR_LEN];
- CHAR *value;
- INT i;
- RT_802_11_DLS Dls;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
- AtoH(value, &macAddr[i++], 2);
- }
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x", macAddr[0], macAddr[1],
- macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- COPY_MAC_ADDR(Dls.MacAddr, macAddr);
- Dls.Valid = 0;
-
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
-
- return TRUE;
-}
-
diff --git a/drivers/staging/rt2870/sta/rtmp_data.c b/drivers/staging/rt2870/sta/rtmp_data.c
index 9942ecaf5e2e..b67e06952bcf 100644
--- a/drivers/staging/rt2870/sta/rtmp_data.c
+++ b/drivers/staging/rt2870/sta/rtmp_data.c
@@ -1,2619 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_data.c
-
- Abstract:
- Data path subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Aug/17/04 major modification for RT2561/2661
- Jan Lee Mar/17/06 major modification for RT2860 New Ring Design
-*/
-#include "../rt_config.h"
-
-
-VOID STARxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- UCHAR *pTmpBuf;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- // All EAPoL frames have to pass to upper layer (ex. WPA_SUPPLICANT daemon)
- // TBD : process fragmented EAPol frames
- {
- // In 802.1x mode, if the received frame is EAP-SUCCESS packet, turn on the PortSecured variable
- if ( pAd->StaCfg.IEEE8021X == TRUE &&
- (EAP_CODE_SUCCESS == WpaCheckEapCode(pAd, pRxBlk->pData, pRxBlk->DataSize, LENGTH_802_1_H)))
- {
- PUCHAR Key;
- UCHAR CipherAlg;
- int idx = 0;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("Receive EAP-SUCCESS Packet\n"));
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- if (pAd->StaCfg.IEEE8021x_required_keys == FALSE)
- {
- idx = pAd->StaCfg.DesireSharedKeyId;
- CipherAlg = pAd->StaCfg.DesireSharedKey[idx].CipherAlg;
- Key = pAd->StaCfg.DesireSharedKey[idx].Key;
-
- if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
- {
-#ifdef RT2870
- union
- {
- char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1];
- NDIS_802_11_WEP keyinfo;
- } WepKey;
- int len;
-
-
- NdisZeroMemory(&WepKey, sizeof(WepKey));
- len =pAd->StaCfg.DesireSharedKey[idx].KeyLen;
-
- NdisMoveMemory(WepKey.keyinfo.KeyMaterial,
- pAd->StaCfg.DesireSharedKey[idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].KeyLen);
-
- WepKey.keyinfo.KeyIndex = 0x80000000 + idx;
- WepKey.keyinfo.KeyLength = len;
- pAd->SharedKey[BSS0][idx].KeyLen =(UCHAR) (len <= 5 ? 5 : 13);
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- // need to enqueue cmd to thread
- RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1);
-#endif // RT2870 //
- // For Preventing ShardKey Table is cleared by remove key procedure.
- pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg;
- pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen;
- NdisMoveMemory(pAd->SharedKey[BSS0][idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].KeyLen);
- }
- }
- }
-
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // Special DATA frame that has to pass to MLME
- // 1. Cisco Aironet frames for CCX2. We need pass it to MLME for special process
- // 2. EAPOL handshaking frames when driver supplicant enabled, pass to MLME for special process
- {
- pTmpBuf = pRxBlk->pData - LENGTH_802_11;
- NdisMoveMemory(pTmpBuf, pRxBlk->pHeader, LENGTH_802_11);
- REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pTmpBuf, pRxBlk->DataSize + LENGTH_802_11, pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! report EAPOL/AIRONET DATA to MLME (len=%d) !!!\n", pRxBlk->DataSize));
- }
- }
-
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
-
-}
-
-VOID STARxDataFrameAnnounce(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
-
- // non-EAP frame
- if (!RTMPCheckWPAframe(pAd, pEntry, pRxBlk->pData, pRxBlk->DataSize, FromWhichBSSID))
- {
- {
- // drop all non-EAP DATA frame before
- // this client's Port-Access-Control is secured
- if (pRxBlk->pHeader->FC.Wep)
- {
- // unsupported cipher suite
- if (pAd->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- else
- {
- // encryption in-use but receive a non-EAPOL clear text frame, drop it
- if ((pAd->StaCfg.WepStatus != Ndis802_11EncryptionDisabled) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- }
- RX_BLK_CLEAR_FLAG(pRxBlk, fRX_EAP);
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_ARALINK))
- {
- // Normal legacy, AMPDU or AMSDU
- CmmRxnonRalinkFrameIndicate(pAd, pRxBlk, FromWhichBSSID);
-
- }
- else
- {
- // ARALINK
- CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- }
-#ifdef QOS_DLS_SUPPORT
- RX_BLK_CLEAR_FLAG(pRxBlk, fRX_DLS);
-#endif // QOS_DLS_SUPPORT //
- }
- else
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_EAP);
-#ifdef DOT11_N_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
- {
- Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // Determin the destination of the EAP frame
- // to WPA state machine or upper layer
- STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- }
- }
-}
-
-
-// For TKIP frame, calculate the MIC value
-BOOLEAN STACheckTkipMICValue(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk)
-{
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- UCHAR *pData = pRxBlk->pData;
- USHORT DataSize = pRxBlk->DataSize;
- UCHAR UserPriority = pRxBlk->UserPriority;
- PCIPHER_KEY pWpaKey;
- UCHAR *pDA, *pSA;
-
- pWpaKey = &pAd->SharedKey[BSS0][pRxBlk->pRxWI->KeyIndex];
-
- pDA = pHeader->Addr1;
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_INFRA))
- {
- pSA = pHeader->Addr3;
- }
- else
- {
- pSA = pHeader->Addr2;
- }
-
- if (RTMPTkipCompareMICValue(pAd,
- pData,
- pDA,
- pSA,
- pWpaKey->RxMic,
- UserPriority,
- DataSize) == FALSE)
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error 2\n"));
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- WpaSendMicFailureToWpaSupplicant(pAd, (pWpaKey->Type == PAIRWISEKEY) ? TRUE : FALSE);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- RTMPReportMicError(pAd, pWpaKey);
- }
-
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-//
-// All Rx routines use RX_BLK structure to hande rx events
-// It is very important to build pRxBlk attributes
-// 1. pHeader pointer to 802.11 Header
-// 2. pData pointer to payload including LLC (just skip Header)
-// 3. set payload size including LLC to DataSize
-// 4. set some flags with RX_BLK_SET_FLAG()
-//
-VOID STAHandleRxDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- BOOLEAN bFragment = FALSE;
- MAC_TABLE_ENTRY *pEntry = NULL;
- UCHAR FromWhichBSSID = BSS0;
- UCHAR UserPriority = 0;
-
- {
- // before LINK UP, all DATA frames are rejected
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
-#ifdef QOS_DLS_SUPPORT
- //if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
- if (RTMPRcvFrameDLSCheck(pAd, pHeader, pRxWI->MPDUtotalByteCount, pRxD))
- {
- return;
- }
-#endif // QOS_DLS_SUPPORT //
-
- // Drop not my BSS frames
- if (pRxD->MyBss == 0)
- {
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
-
- pAd->RalinkCounters.RxCountSinceLastNULL++;
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable && (pHeader->FC.SubType & 0x08))
- {
- UCHAR *pData;
- DBGPRINT(RT_DEBUG_TRACE,("bAPSDCapable\n"));
-
- // Qos bit 4
- pData = (PUCHAR)pHeader + LENGTH_802_11;
- if ((*pData >> 4) & 0x01)
- {
- DBGPRINT(RT_DEBUG_TRACE,("RxDone- Rcv EOSP frame, driver may fall into sleep\n"));
- pAd->CommonCfg.bInServicePeriod = FALSE;
-
- // Force driver to fall into sleep mode when rcv EOSP frame
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- USHORT TbttNumToNextWakeUp;
- USHORT NextDtim = pAd->StaCfg.DtimPeriod;
- ULONG Now;
-
- NdisGetSystemUpTime(&Now);
- NextDtim -= (USHORT)(Now - pAd->StaCfg.LastBeaconRxTime)/pAd->CommonCfg.BeaconPeriod;
-
- TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
- TbttNumToNextWakeUp = NextDtim;
-
- MlmeSetPsmBit(pAd, PWR_SAVE);
- // if WMM-APSD is failed, try to disable following line
- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
- }
- }
-
- if ((pHeader->FC.MoreData) && (pAd->CommonCfg.bInServicePeriod))
- {
- DBGPRINT(RT_DEBUG_TRACE,("Sending another trigger frame when More Data bit is set to 1\n"));
- }
- }
-
- // Drop NULL, CF-ACK(no data), CF-POLL(no data), and CF-ACK+CF-POLL(no data) data frame
- if ((pHeader->FC.SubType & 0x04)) // bit 2 : no DATA
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // Drop not my BSS frame (we can not only check the MyBss bit in RxD)
-#ifdef QOS_DLS_SUPPORT
- if (!pAd->CommonCfg.bDLSCapable)
- {
-#endif // QOS_DLS_SUPPORT //
- if (INFRA_ON(pAd))
- {
- // Infrastructure mode, check address 2 for BSSID
- if (!RTMPEqualMemory(&pHeader->Addr2, &pAd->CommonCfg.Bssid, 6))
- {
- // Receive frame not my BSSID
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- else // Ad-Hoc mode or Not associated
- {
- // Ad-Hoc mode, check address 3 for BSSID
- if (!RTMPEqualMemory(&pHeader->Addr3, &pAd->CommonCfg.Bssid, 6))
- {
- // Receive frame not my BSSID
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
-#ifdef QOS_DLS_SUPPORT
- }
-#endif // QOS_DLS_SUPPORT //
-
- //
- // find pEntry
- //
- if (pRxWI->WirelessCliID < MAX_LEN_OF_MAC_TABLE)
- {
- pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
- }
- else
- {
- // 1. release packet if infra mode
- // 2. new a pEntry if ad-hoc mode
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // infra or ad-hoc
- if (INFRA_ON(pAd))
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA);
-#ifdef QOS_DLS_SUPPORT
- if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
- RX_BLK_SET_FLAG(pRxBlk, fRX_DLS);
- else
-#endif // QOS_DLS_SUPPORT //
- ASSERT(pRxWI->WirelessCliID == BSSID_WCID);
- }
-
- // check Atheros Client
- if ((pEntry->bIAmBadAtheros == FALSE) && (pRxD->AMPDU == 1) && (pHeader->FC.Retry ))
- {
- pEntry->bIAmBadAtheros = TRUE;
- pAd->CommonCfg.IOTestParm.bCurrentAtheros = TRUE;
- pAd->CommonCfg.IOTestParm.bLastAtheros = TRUE;
- if (!STA_AES_ON(pAd))
- {
- AsicUpdateProtect(pAd, 8, ALLN_SETPROTECT, TRUE, FALSE);
- }
- }
- }
-
- pRxBlk->pData = (UCHAR *)pHeader;
-
- //
- // update RxBlk->pData, DataSize
- // 802.11 Header, QOS, HTC, Hw Padding
- //
-
- // 1. skip 802.11 HEADER
- {
- pRxBlk->pData += LENGTH_802_11;
- pRxBlk->DataSize -= LENGTH_802_11;
- }
-
- // 2. QOS
- if (pHeader->FC.SubType & 0x08)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_QOS);
- UserPriority = *(pRxBlk->pData) & 0x0f;
- // bit 7 in QoS Control field signals the HT A-MSDU format
- if ((*pRxBlk->pData) & 0x80)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_AMSDU);
- }
-
- // skip QOS contorl field
- pRxBlk->pData += 2;
- pRxBlk->DataSize -=2;
- }
- pRxBlk->UserPriority = UserPriority;
-
- // 3. Order bit: A-Ralink or HTC+
- if (pHeader->FC.Order)
- {
-#ifdef AGGREGATION_SUPPORT
- if ((pRxWI->PHYMODE <= MODE_OFDM) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)))
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_ARALINK);
- }
- else
-#endif
- {
-#ifdef DOT11_N_SUPPORT
- RX_BLK_SET_FLAG(pRxBlk, fRX_HTC);
- // skip HTC contorl field
- pRxBlk->pData += 4;
- pRxBlk->DataSize -= 4;
-#endif // DOT11_N_SUPPORT //
- }
- }
-
- // 4. skip HW padding
- if (pRxD->L2PAD)
- {
- // just move pData pointer
- // because DataSize excluding HW padding
- RX_BLK_SET_FLAG(pRxBlk, fRX_PAD);
- pRxBlk->pData += 2;
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pRxD->BA)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_AMPDU);
- }
-#endif // DOT11_N_SUPPORT //
-
-
- //
- // Case I Process Broadcast & Multicast data frame
- //
- if (pRxD->Bcast || pRxD->Mcast)
- {
- INC_COUNTER64(pAd->WlanCounters.MulticastReceivedFrameCount);
-
- // Drop Mcast/Bcast frame with fragment bit on
- if (pHeader->FC.MoreFrag)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // Filter out Bcast frame which AP relayed for us
- if (pHeader->FC.FrDs && MAC_ADDR_EQUAL(pHeader->Addr3, pAd->CurrentAddress))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- else if (pRxD->U2M)
- {
- pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
-
-
-#ifdef QOS_DLS_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_DLS))
- {
- MAC_TABLE_ENTRY *pDlsEntry = NULL;
-
- pDlsEntry = DlsEntryTableLookupByWcid(pAd, pRxWI->WirelessCliID, pHeader->Addr2, TRUE);
- if(pDlsEntry)
- Update_Rssi_Sample(pAd, &pDlsEntry->RssiSample, pRxWI);
- }
- else
-#endif // QOS_DLS_SUPPORT //
- if (ADHOC_ON(pAd))
- {
- pEntry = MacTableLookup(pAd, pHeader->Addr2);
- if (pEntry)
- Update_Rssi_Sample(pAd, &pEntry->RssiSample, pRxWI);
- }
-
-
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
- pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
- pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
-
- pAd->RalinkCounters.OneSecRxOkDataCnt++;
-
-
- if (!((pHeader->Frag == 0) && (pHeader->FC.MoreFrag == 0)))
- {
- // re-assemble the fragmented packets
- // return complete frame (pRxPacket) or NULL
- bFragment = TRUE;
- pRxPacket = RTMPDeFragmentDataFrame(pAd, pRxBlk);
- }
-
- if (pRxPacket)
- {
- pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
-
- // process complete frame
- if (bFragment && (pRxD->Decrypted) && (pEntry->WepStatus == Ndis802_11Encryption2Enabled))
- {
- // Minus MIC length
- pRxBlk->DataSize -= 8;
-
- // For TKIP frame, calculate the MIC value
- if (STACheckTkipMICValue(pAd, pEntry, pRxBlk) == FALSE)
- {
- return;
- }
- }
-
- STARxDataFrameAnnounce(pAd, pEntry, pRxBlk, FromWhichBSSID);
- return;
- }
- else
- {
- // just return
- // because RTMPDeFragmentDataFrame() will release rx packet,
- // if packet is fragmented
- return;
- }
- }
-
- ASSERT(0);
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-VOID STAHandleRxMgmtFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
-
- do
- {
-
- // We should collect RSSI not only U2M data but also my beacon
- if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2)))
- {
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
- pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
- pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
- }
-
- // First check the size, it MUST not exceed the mlme queue size
- if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("STAHandleRxMgmtFrame: frame too large, size = %d \n", pRxWI->MPDUtotalByteCount));
- break;
- }
-
- REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pHeader, pRxWI->MPDUtotalByteCount,
- pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
- } while (FALSE);
-
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
-}
-
-VOID STAHandleRxControlFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
-#ifdef DOT11_N_SUPPORT
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
-#endif // DOT11_N_SUPPORT //
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
-
- switch (pHeader->FC.SubType)
- {
- case SUBTYPE_BLOCK_ACK_REQ:
-#ifdef DOT11_N_SUPPORT
- {
- CntlEnqueueForRecv(pAd, pRxWI->WirelessCliID, (pRxWI->MPDUtotalByteCount), (PFRAME_BA_REQ)pHeader);
- }
- break;
-#endif // DOT11_N_SUPPORT //
- case SUBTYPE_BLOCK_ACK:
- case SUBTYPE_ACK:
- default:
- break;
- }
-
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Process RxDone interrupt, running in DPC level
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- This routine has to maintain Rx ring read pointer.
- Need to consider QOS DATA format when converting to 802.3
- ========================================================================
-*/
-BOOLEAN STARxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN argc)
-{
- NDIS_STATUS Status;
- UINT32 RxProcessed, RxPending;
- BOOLEAN bReschedule = FALSE;
- RT28XX_RXD_STRUC *pRxD;
- UCHAR *pData;
- PRXWI_STRUC pRxWI;
- PNDIS_PACKET pRxPacket;
- PHEADER_802_11 pHeader;
- RX_BLK RxCell;
-
- RxProcessed = RxPending = 0;
-
- // process whole rx ring
- while (1)
- {
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST) ||
- !RTMP_TEST_FLAG(pAd,fRTMP_ADAPTER_START_UP))
- {
- break;
- }
-
-
- RxProcessed ++; // test
-
- // 1. allocate a new data packet into rx ring to replace received packet
- // then processing the received packet
- // 2. the callee must take charge of release of packet
- // 3. As far as driver is concerned ,
- // the rx packet must
- // a. be indicated to upper layer or
- // b. be released if it is discarded
- pRxPacket = GetPacketFromRxRing(pAd, &(RxCell.RxD), &bReschedule, &RxPending);
- if (pRxPacket == NULL)
- {
- // no more packet to process
- break;
- }
-
- // get rx ring descriptor
- pRxD = &(RxCell.RxD);
- // get rx data buffer
- pData = GET_OS_PKT_DATAPTR(pRxPacket);
- pRxWI = (PRXWI_STRUC) pData;
- pHeader = (PHEADER_802_11) (pData+RXWI_SIZE) ;
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader, DIR_READ, TRUE);
- RTMPWIEndianChange((PUCHAR)pRxWI, TYPE_RXWI);
-#endif
-
- // build RxCell
- RxCell.pRxWI = pRxWI;
- RxCell.pHeader = pHeader;
- RxCell.pRxPacket = pRxPacket;
- RxCell.pData = (UCHAR *) pHeader;
- RxCell.DataSize = pRxWI->MPDUtotalByteCount;
- RxCell.Flags = 0;
-
- // Increase Total receive byte counter after real data received no mater any error or not
- pAd->RalinkCounters.ReceivedByteCount += pRxWI->MPDUtotalByteCount;
- pAd->RalinkCounters.RxCount ++;
-
- INC_COUNTER64(pAd->WlanCounters.ReceivedFragmentCount);
-
- if (pRxWI->MPDUtotalByteCount < 14)
- Status = NDIS_STATUS_FAILURE;
-
- if (MONITOR_ON(pAd))
- {
- send_monitor_packets(pAd, &RxCell);
- break;
- }
- /* RT2870 invokes STARxDoneInterruptHandle() in rtusb_bulk.c */
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- pAd->ate.RxCntPerSec++;
- ATESampleRssi(pAd, pRxWI);
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQARxStart == TRUE)
- {
- /* (*pRxD) has been swapped in GetPacketFromRxRing() */
- ATE_QA_Statistics(pAd, pRxWI, pRxD, pHeader);
- }
-#endif // RALINK_28xx_QA //
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
- continue;
- }
-#endif // RALINK_ATE //
-
- // Check for all RxD errors
- Status = RTMPCheckRxError(pAd, pHeader, pRxWI, pRxD);
-
- // Handle the received frame
- if (Status == NDIS_STATUS_SUCCESS)
- {
- switch (pHeader->FC.Type)
- {
- // CASE I, receive a DATA frame
- case BTYPE_DATA:
- {
- // process DATA frame
- STAHandleRxDataFrame(pAd, &RxCell);
- }
- break;
- // CASE II, receive a MGMT frame
- case BTYPE_MGMT:
- {
- STAHandleRxMgmtFrame(pAd, &RxCell);
- }
- break;
- // CASE III. receive a CNTL frame
- case BTYPE_CNTL:
- {
- STAHandleRxControlFrame(pAd, &RxCell);
- }
- break;
- // discard other type
- default:
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- break;
- }
- }
- else
- {
- pAd->Counters8023.RxErrors++;
- // discard this frame
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- }
- }
-
- return bReschedule;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Arguments:
- pAd Pointer to our adapter
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPHandleTwakeupInterrupt(
- IN PRTMP_ADAPTER pAd)
-{
- AsicForceWakeup(pAd, FALSE);
-}
-
-/*
-========================================================================
-Routine Description:
- Early checking and OS-depened parsing for Tx packet send to our STA driver.
-
-Arguments:
- NDIS_HANDLE MiniportAdapterContext Pointer refer to the device handle, i.e., the pAd.
- PPNDIS_PACKET ppPacketArray The packet array need to do transmission.
- UINT NumberOfPackets Number of packet in packet array.
-
-Return Value:
- NONE
-
-Note:
- This function do early checking and classification for send-out packet.
- You only can put OS-depened & STA related code in here.
-========================================================================
-*/
-VOID STASendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets)
-{
- UINT Index;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) MiniportAdapterContext;
- PNDIS_PACKET pPacket;
- BOOLEAN allowToSend = FALSE;
-
-
- for (Index = 0; Index < NumberOfPackets; Index++)
- {
- pPacket = ppPacketArray[Index];
-
- do
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- {
- // Drop send request since hardware is in reset state
- break;
- }
- else if (!INFRA_ON(pAd) && !ADHOC_ON(pAd))
- {
- // Drop send request since there are no physical connection yet
- break;
- }
- else
- {
- // Record that orignal packet source is from NDIS layer,so that
- // later on driver knows how to release this NDIS PACKET
-#ifdef QOS_DLS_SUPPORT
- MAC_TABLE_ENTRY *pEntry;
- PUCHAR pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-
- pEntry = MacTableLookup(pAd, pSrcBufVA);
- if (pEntry && (pEntry->ValidAsDls == TRUE))
- {
- RTMP_SET_PACKET_WCID(pPacket, pEntry->Aid);
- }
- else
-#endif // QOS_DLS_SUPPORT //
- RTMP_SET_PACKET_WCID(pPacket, 0); // this field is useless when in STA mode
- RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
- NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_PENDING);
- pAd->RalinkCounters.PendingNdisPacketCount++;
-
- allowToSend = TRUE;
- }
- } while(FALSE);
-
- if (allowToSend == TRUE)
- STASendPacket(pAd, pPacket);
- else
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
-
- // Dequeue outgoing frames from TxSwQueue[] and process it
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-
-}
-
-
-/*
-========================================================================
-Routine Description:
- This routine is used to do packet parsing and classification for Tx packet
- to STA device, and it will en-queue packets to our TxSwQueue depends on AC
- class.
-
-Arguments:
- pAd Pointer to our adapter
- pPacket Pointer to send packet
-
-Return Value:
- NDIS_STATUS_SUCCESS If succes to queue the packet into TxSwQueue.
- NDIS_STATUS_FAILURE If failed to do en-queue.
-
-Note:
- You only can put OS-indepened & STA related code in here.
-========================================================================
-*/
-NDIS_STATUS STASendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- UINT AllowFragSize;
- UCHAR NumberOfFrag;
-// UCHAR RTSRequired;
- UCHAR QueIdx, UserPriority;
- MAC_TABLE_ENTRY *pEntry = NULL;
- unsigned int IrqFlags;
- UCHAR FlgIsIP = 0;
- UCHAR Rate;
-
- // Prepare packet information structure for buffer descriptor
- // chained within a single NDIS packet.
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- if (pSrcBufVA == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> pSrcBufVA == NULL !!!SrcBufLen=%x\n",SrcBufLen));
- // Resourece is low, system did not allocate virtual address
- // return NDIS_STATUS_FAILURE directly to upper layer
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return NDIS_STATUS_FAILURE;
- }
-
-
- if (SrcBufLen < 14)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> Ndis Packet buffer error !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return (NDIS_STATUS_FAILURE);
- }
-
- // In HT rate adhoc mode, A-MPDU is often used. So need to lookup BA Table and MAC Entry.
- // Note multicast packets in adhoc also use BSSID_WCID index.
- {
- if(INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- USHORT tmpWcid;
-
- tmpWcid = RTMP_GET_PACKET_WCID(pPacket);
- if (VALID_WCID(tmpWcid) &&
- (pAd->MacTab.Content[tmpWcid].ValidAsDls== TRUE))
- {
- pEntry = &pAd->MacTab.Content[tmpWcid];
- Rate = pAd->MacTab.Content[tmpWcid].CurrTxRate;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- {
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID);
- Rate = pAd->CommonCfg.TxRate;
- }
- }
- else if (ADHOC_ON(pAd))
- {
- if (*pSrcBufVA & 0x01)
- {
- RTMP_SET_PACKET_WCID(pPacket, MCAST_WCID);
- pEntry = &pAd->MacTab.Content[MCAST_WCID];
- }
- else
- {
- pEntry = MacTableLookup(pAd, pSrcBufVA);
- }
- Rate = pAd->CommonCfg.TxRate;
- }
- }
-
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket->Cannot find pEntry(%2x:%2x:%2x:%2x:%2x:%2x) in MacTab!\n", PRINT_MAC(pSrcBufVA)));
- // Resourece is low, system did not allocate virtual address
- // return NDIS_STATUS_FAILURE directly to upper layer
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return NDIS_STATUS_FAILURE;
- }
-
- if (ADHOC_ON(pAd)
- )
- {
- RTMP_SET_PACKET_WCID(pPacket, (UCHAR)pEntry->Aid);
- }
-
- //
- // Check the Ethernet Frame type of this packet, and set the RTMP_SET_PACKET_SPECIFIC flags.
- // Here we set the PACKET_SPECIFIC flags(LLC, VLAN, DHCP/ARP, EAPOL).
- RTMPCheckEtherType(pAd, pPacket);
-
-
-
- //
- // WPA 802.1x secured port control - drop all non-802.1x frame before port secured
- //
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef WPA_SUPPLICANT_SUPPORT
- || (pAd->StaCfg.IEEE8021X == TRUE)
-#endif // WPA_SUPPLICANT_SUPPORT //
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- )
- && ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAd->StaCfg.MicErrCnt >= 2))
- && (RTMP_GET_PACKET_EAPOL(pPacket)== FALSE)
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("STASendPacket --> Drop packet before port secured !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
- return (NDIS_STATUS_FAILURE);
- }
-
-
- // STEP 1. Decide number of fragments required to deliver this MSDU.
- // The estimation here is not very accurate because difficult to
- // take encryption overhead into consideration here. The result
- // "NumberOfFrag" is then just used to pre-check if enough free
- // TXD are available to hold this MSDU.
-
-
- if (*pSrcBufVA & 0x01) // fragmentation not allowed on multicast & broadcast
- NumberOfFrag = 1;
- else if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED))
- NumberOfFrag = 1; // Aggregation overwhelms fragmentation
- else if (CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED))
- NumberOfFrag = 1; // Aggregation overwhelms fragmentation
-#ifdef DOT11_N_SUPPORT
- else if ((pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTMIX) || (pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTGREENFIELD))
- NumberOfFrag = 1; // MIMO RATE overwhelms fragmentation
-#endif // DOT11_N_SUPPORT //
- else
- {
- // The calculated "NumberOfFrag" is a rough estimation because of various
- // encryption/encapsulation overhead not taken into consideration. This number is just
- // used to make sure enough free TXD are available before fragmentation takes place.
- // In case the actual required number of fragments of an NDIS packet
- // excceeds "NumberOfFrag"caculated here and not enough free TXD available, the
- // last fragment (i.e. last MPDU) will be dropped in RTMPHardTransmit() due to out of
- // resource, and the NDIS packet will be indicated NDIS_STATUS_FAILURE. This should
- // rarely happen and the penalty is just like a TX RETRY fail. Affordable.
-
- AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
- NumberOfFrag = ((PacketInfo.TotalPacketLength - LENGTH_802_3 + LENGTH_802_1_H) / AllowFragSize) + 1;
- // To get accurate number of fragmentation, Minus 1 if the size just match to allowable fragment size
- if (((PacketInfo.TotalPacketLength - LENGTH_802_3 + LENGTH_802_1_H) % AllowFragSize) == 0)
- {
- NumberOfFrag--;
- }
- }
-
- // Save fragment number to Ndis packet reserved field
- RTMP_SET_PACKET_FRAGMENTS(pPacket, NumberOfFrag);
-
-
- // STEP 2. Check the requirement of RTS:
- // If multiple fragment required, RTS is required only for the first fragment
- // if the fragment size large than RTS threshold
- // For RT28xx, Let ASIC send RTS/CTS
- RTMP_SET_PACKET_RTS(pPacket, 0);
- RTMP_SET_PACKET_TXRATE(pPacket, pAd->CommonCfg.TxRate);
-
- //
- // STEP 3. Traffic classification. outcome = <UserPriority, QueIdx>
- //
- UserPriority = 0;
- QueIdx = QID_AC_BE;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE))
- {
- USHORT Protocol;
- UCHAR LlcSnapLen = 0, Byte0, Byte1;
- do
- {
- // get Ethernet protocol field
- Protocol = (USHORT)((pSrcBufVA[12] << 8) + pSrcBufVA[13]);
- if (Protocol <= 1500)
- {
- // get Ethernet protocol field from LLC/SNAP
- if (Sniff2BytesFromNdisBuffer(PacketInfo.pFirstBuffer, LENGTH_802_3 + 6, &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
- break;
-
- Protocol = (USHORT)((Byte0 << 8) + Byte1);
- LlcSnapLen = 8;
- }
-
- // always AC_BE for non-IP packet
- if (Protocol != 0x0800)
- break;
-
- // get IP header
- if (Sniff2BytesFromNdisBuffer(PacketInfo.pFirstBuffer, LENGTH_802_3 + LlcSnapLen, &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
- break;
-
- // return AC_BE if packet is not IPv4
- if ((Byte0 & 0xf0) != 0x40)
- break;
-
- FlgIsIP = 1;
- UserPriority = (Byte1 & 0xe0) >> 5;
- QueIdx = MapUserPriorityToAccessCategory[UserPriority];
-
- // TODO: have to check ACM bit. apply TSPEC if ACM is ON
- // TODO: downgrade UP & QueIdx before passing ACM
- if (pAd->CommonCfg.APEdcaParm.bACM[QueIdx])
- {
- UserPriority = 0;
- QueIdx = QID_AC_BE;
- }
- } while (FALSE);
- }
-
- RTMP_SET_PACKET_UP(pPacket, UserPriority);
-
-
-
- // Make sure SendTxWait queue resource won't be used by other threads
- RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
- if (pAd->TxSwQueue[QueIdx].Number >= MAX_PACKETS_IN_QUEUE)
- {
- RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-#ifdef BLOCK_NET_IF
- StopNetIfQueue(pAd, QueIdx, pPacket);
-#endif // BLOCK_NET_IF //
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
- return NDIS_STATUS_FAILURE;
- }
- else
- {
- InsertTailQueue(&pAd->TxSwQueue[QueIdx], PACKET_TO_QUEUE_ENTRY(pPacket));
- }
- RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&&
- IS_HT_STA(pEntry))
- {
- //PMAC_TABLE_ENTRY pMacEntry = &pAd->MacTab.Content[BSSID_WCID];
- if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) &&
- ((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) &&
- (pEntry->PortSecured == WPA_802_1X_PORT_SECURED)
- // For IOT compatibility, if
- // 1. It is Ralink chip or
- // 2. It is OPEN or AES mode,
- // then BA session can be bulit.
- && ((pEntry->ValidAsCLI && pAd->MlmeAux.APRalinkIe != 0x0) ||
- (pEntry->WepStatus == Ndis802_11WEPDisabled || pEntry->WepStatus == Ndis802_11Encryption3Enabled))
- )
- {
- BAOriSessionSetUp(pAd, pEntry, 0, 0, 10, FALSE);
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- pAd->RalinkCounters.OneSecOsTxCount[QueIdx]++; // TODO: for debug only. to be removed
- return NDIS_STATUS_SUCCESS;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- This subroutine will scan through releative ring descriptor to find
- out avaliable free ring descriptor and compare with request size.
-
- Arguments:
- pAd Pointer to our adapter
- QueIdx Selected TX Ring
-
- Return Value:
- NDIS_STATUS_FAILURE Not enough free descriptor
- NDIS_STATUS_SUCCESS Enough free descriptor
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-
-#ifdef RT2870
-/*
- Actually, this function used to check if the TxHardware Queue still has frame need to send.
- If no frame need to send, go to sleep, else, still wake up.
-*/
-NDIS_STATUS RTMPFreeTXDRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN UCHAR NumberRequired,
- IN PUCHAR FreeNumberIs)
-{
- //ULONG FreeNumber = 0;
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- unsigned long IrqFlags;
- HT_TX_CONTEXT *pHTTXContext;
-
- switch (QueIdx)
- {
- case QID_AC_BK:
- case QID_AC_BE:
- case QID_AC_VI:
- case QID_AC_VO:
- case QID_HCCA:
- {
- pHTTXContext = &pAd->TxContext[QueIdx];
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
- if ((pHTTXContext->CurWritePosition != pHTTXContext->ENextBulkOutPosition) ||
- (pHTTXContext->IRPPending == TRUE))
- {
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
- Status = NDIS_STATUS_SUCCESS;
- }
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
- }
- break;
-
- case QID_MGMT:
- if (pAd->MgmtRing.TxSwFreeIdx != MGMT_RING_SIZE)
- Status = NDIS_STATUS_FAILURE;
- else
- Status = NDIS_STATUS_SUCCESS;
- break;
-
- default:
- DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
- break;
- }
-
- return (Status);
-
-}
-#endif // RT2870 //
-
-
-VOID RTMPSendDisassociationFrame(
- IN PRTMP_ADAPTER pAd)
-{
-}
-
-VOID RTMPSendNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull)
-{
- UCHAR NullFrame[48];
- ULONG Length;
- PHEADER_802_11 pHeader_802_11;
-
-
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- // WPA 802.1x secured port control
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef WPA_SUPPLICANT_SUPPORT
- || (pAd->StaCfg.IEEE8021X == TRUE)
-#endif
- ) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- return;
- }
-
- NdisZeroMemory(NullFrame, 48);
- Length = sizeof(HEADER_802_11);
-
- pHeader_802_11 = (PHEADER_802_11) NullFrame;
-
- pHeader_802_11->FC.Type = BTYPE_DATA;
- pHeader_802_11->FC.SubType = SUBTYPE_NULL_FUNC;
- pHeader_802_11->FC.ToDs = 1;
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
-
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- {
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- }
- else
- {
- pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE) ? 1: 0;
- }
- pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + RTMPCalcDuration(pAd, TxRate, 14);
-
- pAd->Sequence++;
- pHeader_802_11->Sequence = pAd->Sequence;
-
- // Prepare QosNull function frame
- if (bQosNull)
- {
- pHeader_802_11->FC.SubType = SUBTYPE_QOS_NULL;
-
- // copy QOS control bytes
- NullFrame[Length] = 0;
- NullFrame[Length+1] = 0;
- Length += 2;// if pad with 2 bytes for alignment, APSD will fail
- }
-
- HAL_KickOutNullFrameTx(pAd, 0, NullFrame, Length);
-
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID RTMPSendRTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN unsigned int NextMpduSize,
- IN UCHAR TxRate,
- IN UCHAR RTSRate,
- IN USHORT AckDuration,
- IN UCHAR QueIdx,
- IN UCHAR FrameGap)
-{
-}
-
-
-
-// --------------------------------------------------------
-// FIND ENCRYPT KEY AND DECIDE CIPHER ALGORITHM
-// Find the WPA key, either Group or Pairwise Key
-// LEAP + TKIP also use WPA key.
-// --------------------------------------------------------
-// Decide WEP bit and cipher suite to be used. Same cipher suite should be used for whole fragment burst
-// In Cisco CCX 2.0 Leap Authentication
-// WepStatus is Ndis802_11Encryption1Enabled but the key will use PairwiseKey
-// Instead of the SharedKey, SharedKey Length may be Zero.
-VOID STAFindCipherAlgorithm(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- NDIS_802_11_ENCRYPTION_STATUS Cipher; // To indicate cipher used for this packet
- UCHAR CipherAlg = CIPHER_NONE; // cipher alogrithm
- UCHAR KeyIdx = 0xff;
- PUCHAR pSrcBufVA;
- PCIPHER_KEY pKey = NULL;
-
- pSrcBufVA = GET_OS_PKT_DATAPTR(pTxBlk->pPacket);
-
- {
- // Select Cipher
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
- Cipher = pAd->StaCfg.GroupCipher; // Cipher for Multicast or Broadcast
- else
- Cipher = pAd->StaCfg.PairCipher; // Cipher for Unicast
-
- if (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
- {
- ASSERT(pAd->SharedKey[BSS0][0].CipherAlg <= CIPHER_CKIP128);
-
- // 4-way handshaking frame must be clear
- if (!(TX_BLK_TEST_FLAG(pTxBlk, fTX_bClearEAPFrame)) && (pAd->SharedKey[BSS0][0].CipherAlg) &&
- (pAd->SharedKey[BSS0][0].KeyLen))
- {
- CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
- KeyIdx = 0;
- }
- }
- else if (Cipher == Ndis802_11Encryption1Enabled)
- {
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.CkipFlag & 0x10) // Cisco CKIP KP is on
- {
- if (LEAP_CCKM_ON(pAd))
- {
- if (((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))))
- KeyIdx = 1;
- else
- KeyIdx = 0;
- }
- else
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
- else if (pAd->StaCfg.CkipFlag & 0x08) // only CKIP CMIC
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- else if (LEAP_CCKM_ON(pAd))
- {
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
- KeyIdx = 1;
- else
- KeyIdx = 0;
- }
- else // standard WEP64 or WEP128
-#endif // LEAP_SUPPORT //
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
- else if ((Cipher == Ndis802_11Encryption2Enabled) ||
- (Cipher == Ndis802_11Encryption3Enabled))
- {
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))) // multicast
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- else if (pAd->SharedKey[BSS0][0].KeyLen)
- KeyIdx = 0;
- else
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
-
- if (KeyIdx == 0xff)
- CipherAlg = CIPHER_NONE;
- else if ((Cipher == Ndis802_11EncryptionDisabled) || (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 0))
- CipherAlg = CIPHER_NONE;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ( pAd->StaCfg.WpaSupplicantUP &&
- (Cipher == Ndis802_11Encryption1Enabled) &&
- (pAd->StaCfg.IEEE8021X == TRUE) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- CipherAlg = CIPHER_NONE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- {
- //Header_802_11.FC.Wep = 1;
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- pKey = &pAd->SharedKey[BSS0][KeyIdx];
- }
- }
-
- pTxBlk->CipherAlg = CipherAlg;
- pTxBlk->pKey = pKey;
-}
-
-
-VOID STABuildCommon802_11Header(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
-
- HEADER_802_11 *pHeader_802_11;
-#ifdef QOS_DLS_SUPPORT
- BOOLEAN bDLSFrame = FALSE;
- INT DlsEntryIndex = 0;
-#endif // QOS_DLS_SUPPORT //
-
- //
- // MAKE A COMMON 802.11 HEADER
- //
-
- // normal wlan header size : 24 octets
- pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-
- pHeader_802_11 = (HEADER_802_11 *) &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-
- NdisZeroMemory(pHeader_802_11, sizeof(HEADER_802_11));
-
- pHeader_802_11->FC.FrDs = 0;
- pHeader_802_11->FC.Type = BTYPE_DATA;
- pHeader_802_11->FC.SubType = ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA : SUBTYPE_DATA);
-
-#ifdef QOS_DLS_SUPPORT
- if (INFRA_ON(pAd))
- {
- // Check if the frame can be sent through DLS direct link interface
- // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
- DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
- if (DlsEntryIndex >= 0)
- bDLSFrame = TRUE;
- else
- bDLSFrame = FALSE;
- }
-#endif // QOS_DLS_SUPPORT //
-
- if (pTxBlk->pMacEntry)
- {
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS))
- {
- pHeader_802_11->Sequence = pTxBlk->pMacEntry->NonQosDataSeq;
- pTxBlk->pMacEntry->NonQosDataSeq = (pTxBlk->pMacEntry->NonQosDataSeq+1) & MAXSEQ;
- }
- else
- {
- pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority];
- pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
- }
- }
- else
- {
- pHeader_802_11->Sequence = pAd->Sequence;
- pAd->Sequence = (pAd->Sequence+1) & MAXSEQ; // next sequence
- }
-
- pHeader_802_11->Frag = 0;
-
- pHeader_802_11->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
- {
- if (INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
- pHeader_802_11->FC.ToDs = 0;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pTxBlk->pSrcBufHeader);
- pHeader_802_11->FC.ToDs = 1;
- }
- }
- else if (ADHOC_ON(pAd))
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
- pHeader_802_11->FC.ToDs = 0;
- }
- }
-
- if (pTxBlk->CipherAlg != CIPHER_NONE)
- pHeader_802_11->FC.Wep = 1;
-
- // -----------------------------------------------------------------
- // STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
- // -----------------------------------------------------------------
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- else
- pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-}
-
-#ifdef DOT11_N_SUPPORT
-VOID STABuildCache802_11Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR *pHeader)
-{
- MAC_TABLE_ENTRY *pMacEntry;
- PHEADER_802_11 pHeader80211;
-
- pHeader80211 = (PHEADER_802_11)pHeader;
- pMacEntry = pTxBlk->pMacEntry;
-
- //
- // Update the cached 802.11 HEADER
- //
-
- // normal wlan header size : 24 octets
- pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-
- // More Bit
- pHeader80211->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
- // Sequence
- pHeader80211->Sequence = pMacEntry->TxSeq[pTxBlk->UserPriority];
- pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
-
- {
- // Check if the frame can be sent through DLS direct link interface
- // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
-#ifdef QOS_DLS_SUPPORT
- BOOLEAN bDLSFrame = FALSE;
- INT DlsEntryIndex = 0;
-
- DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
- if (DlsEntryIndex >= 0)
- bDLSFrame = TRUE;
- else
- bDLSFrame = FALSE;
-#endif // QOS_DLS_SUPPORT //
-
- // The addr3 of normal packet send from DS is Dest Mac address.
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- COPY_MAC_ADDR(pHeader80211->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
- pHeader80211->FC.ToDs = 0;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- if (ADHOC_ON(pAd))
- COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
- else
- COPY_MAC_ADDR(pHeader80211->Addr3, pTxBlk->pSrcBufHeader);
- }
-
- // -----------------------------------------------------------------
- // STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
- // -----------------------------------------------------------------
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- pHeader80211->FC.PwrMgmt = PWR_SAVE;
- else
- pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-}
-#endif // DOT11_N_SUPPORT //
-
-static inline PUCHAR STA_Build_ARalink_Frame_Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- HEADER_802_11 *pHeader_802_11;
- PNDIS_PACKET pNextPacket;
- UINT32 nextBufLen;
- PQUEUE_ENTRY pQEntry;
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // steal "order" bit to mark "aggregation"
- pHeader_802_11->FC.Order = 1;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- // padding at front of LLC header. LLC header should at 4-bytes aligment.
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR)ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- // For RA Aggregation,
- // put the 2nd MSDU length(extra 2-byte field) after QOS_CONTROL in little endian format
- pQEntry = pTxBlk->TxPacketList.Head;
- pNextPacket = QUEUE_ENTRY_TO_PKT(pQEntry);
- nextBufLen = GET_OS_PKT_LEN(pNextPacket);
- if (RTMP_GET_PACKET_VLAN(pNextPacket))
- nextBufLen -= LENGTH_802_1Q;
-
- *pHeaderBufPtr = (UCHAR)nextBufLen & 0xff;
- *(pHeaderBufPtr+1) = (UCHAR)(nextBufLen >> 8);
-
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += 2;
-
- return pHeaderBufPtr;
-
-}
-
-#ifdef DOT11_N_SUPPORT
-static inline PUCHAR STA_Build_AMSDU_Frame_Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;//, pSaveBufPtr;
- HEADER_802_11 *pHeader_802_11;
-
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- //
- // A-MSDU packet
- //
- *pHeaderBufPtr |= 0x80;
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
-
- //pSaveBufPtr = pHeaderBufPtr;
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- // @@@ MpduHeaderLen excluding padding @@@
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- return pHeaderBufPtr;
-
-}
-
-
-VOID STA_AMPDU_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- MAC_TABLE_ENTRY *pMacEntry;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
- ASSERT(pTxBlk);
-
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if ( RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- pMacEntry = pTxBlk->pMacEntry;
- if (pMacEntry->isCached)
- {
- // NOTE: Please make sure the size of pMacEntry->CachedBuf[] is smaller than pTxBlk->HeaderBuf[]!!!!
- NdisMoveMemory((PUCHAR)&pTxBlk->HeaderBuf[TXINFO_SIZE], (PUCHAR)&pMacEntry->CachedBuf[0], TXWI_SIZE + sizeof(HEADER_802_11));
- pHeaderBufPtr = (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE]);
- STABuildCache802_11Header(pAd, pTxBlk, pHeaderBufPtr);
- }
- else
- {
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- }
-
-
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
-
- //
- // build HTC+
- // HTC control filed following QoS field
- //
- if ((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pTxBlk->pMacEntry, fCLIENT_STATUS_RDG_CAPABLE))
- {
- if (pMacEntry->isCached == FALSE)
- {
- // mark HTC bit
- pHeader_802_11->FC.Order = 1;
-
- NdisZeroMemory(pHeaderBufPtr, 4);
- *(pHeaderBufPtr+3) |= 0x80;
- }
- pHeaderBufPtr += 4;
- pTxBlk->MpduHeaderLen += 4;
- }
-
- //pTxBlk->MpduHeaderLen = pHeaderBufPtr - pTxBlk->HeaderBuf - TXWI_SIZE - TXINFO_SIZE;
- ASSERT(pTxBlk->MpduHeaderLen >= 24);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- // @@@ MpduHeaderLen excluding padding @@@
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- {
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
- }
-
- if (pMacEntry->isCached)
- {
- RTMPWriteTxWI_Cache(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
- }
- else
- {
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- NdisZeroMemory((PUCHAR)(&pMacEntry->CachedBuf[0]), sizeof(pMacEntry->CachedBuf));
- NdisMoveMemory((PUCHAR)(&pMacEntry->CachedBuf[0]), (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), (pHeaderBufPtr - (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE])));
- pMacEntry->isCached = TRUE;
- }
-
- // calculate Transmitted AMPDU count and ByteCount
- {
- pAd->RalinkCounters.TransmittedMPDUsInAMPDUCount.u.LowPart ++;
- pAd->RalinkCounters.TransmittedOctetsInAMPDUCount.QuadPart += pTxBlk->SrcBufLen;
- }
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
-
- HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
- }
-
-}
-
-
-VOID STA_AMSDU_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- USHORT subFramePayloadLen = 0; // AMSDU Subframe length without AMSDU-Header / Padding.
- USHORT totalMPDUSize=0;
- UCHAR *subFrameHeader;
- UCHAR padding = 0;
- USHORT FirstTx = 0, LastTxIdx = 0;
- BOOLEAN bVLANPkt;
- int frameNum = 0;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- ASSERT((pTxBlk->TxPacketList.Number > 1));
-
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- if (frameNum == 0)
- {
- pHeaderBufPtr = STA_Build_AMSDU_Frame_Header(pAd, pTxBlk);
-
- // NOTE: TxWI->MPDUtotalByteCount will be updated after final frame was handled.
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
- }
- else
- {
- pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
- padding = ROUND_UP(LENGTH_AMSDU_SUBFRAMEHEAD + subFramePayloadLen, 4) - (LENGTH_AMSDU_SUBFRAMEHEAD + subFramePayloadLen);
- NdisZeroMemory(pHeaderBufPtr, padding + LENGTH_AMSDU_SUBFRAMEHEAD);
- pHeaderBufPtr += padding;
- pTxBlk->MpduHeaderLen = padding;
- }
-
- //
- // A-MSDU subframe
- // DA(6)+SA(6)+Length(2) + LLC/SNAP Encap
- //
- subFrameHeader = pHeaderBufPtr;
- subFramePayloadLen = pTxBlk->SrcBufLen;
-
- NdisMoveMemory(subFrameHeader, pTxBlk->pSrcBufHeader, 12);
-
-
- pHeaderBufPtr += LENGTH_AMSDU_SUBFRAMEHEAD;
- pTxBlk->MpduHeaderLen += LENGTH_AMSDU_SUBFRAMEHEAD;
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
-
- subFramePayloadLen = pTxBlk->SrcBufLen;
-
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- subFramePayloadLen += LENGTH_802_1_H;
- }
-
- // update subFrame Length field
- subFrameHeader[12] = (subFramePayloadLen & 0xFF00) >> 8;
- subFrameHeader[13] = subFramePayloadLen & 0xFF;
-
- totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
- if (frameNum ==0)
- FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
- else
- LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
-
- frameNum++;
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- // calculate Transmitted AMSDU Count and ByteCount
- {
- pAd->RalinkCounters.TransmittedAMSDUCount.u.LowPart ++;
- pAd->RalinkCounters.TransmittedOctetsInAMSDU.QuadPart += totalMPDUSize;
- }
-
- }
-
- HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
- HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID STA_Legacy_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
- ASSERT(pTxBlk);
-
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- if (pTxBlk->TxFrameType == TX_MCAST_FRAME)
- {
- INC_COUNTER64(pAd->WlanCounters.MulticastTransmittedFrameCount);
- }
-
- if (RTMP_GET_PACKET_RTS(pTxBlk->pPacket))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bRtsRequired);
- else
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bRtsRequired);
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- if (pTxBlk->TxRate < pAd->CommonCfg.MinTxRate)
- pTxBlk->TxRate = pAd->CommonCfg.MinTxRate;
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- // The remaining content of MPDU header should locate at 4-octets aligment
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- {
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- //
- // if original Ethernet frame contains no LLC/SNAP,
- // then an extra LLC/SNAP encap is required
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- UCHAR vlan_size;
-
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // skip vlan tag
- vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader+12+vlan_size, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
- }
-
- //
- // prepare for TXWI
- // use Wcid as Key Index
- //
-
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
-
- HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-
-VOID STA_ARalink_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- USHORT totalMPDUSize=0;
- USHORT FirstTx, LastTxIdx;
- int frameNum = 0;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- ASSERT((pTxBlk->TxPacketList.Number== 2));
-
-
- FirstTx = LastTxIdx = 0; // Is it ok init they as 0?
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- if (frameNum == 0)
- { // For first frame, we need to create the 802.11 header + padding(optional) + RA-AGG-LEN + SNAP Header
-
- pHeaderBufPtr = STA_Build_ARalink_Frame_Header(pAd, pTxBlk);
-
- // It's ok write the TxWI here, because the TxWI->MPDUtotalByteCount
- // will be updated after final frame was handled.
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
-
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
- }
- else
- { // For second aggregated frame, we need create the 802.3 header to headerBuf, because PCI will copy it to SDPtr0.
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
- pTxBlk->MpduHeaderLen = 0;
-
- // A-Ralink sub-sequent frame header is the same as 802.3 header.
- // DA(6)+SA(6)+FrameType(2)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader, 12);
- pHeaderBufPtr += 12;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen = LENGTH_ARALINK_SUBFRAMEHEAD;
- }
-
- totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
- if (frameNum ==0)
- FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
- else
- LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
-
- frameNum++;
-
- pAd->RalinkCounters.OneSecTxAggregationCount++;
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- }
-
- HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
- HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
-}
-
-
-VOID STA_Fragment_Frame_Tx(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- UCHAR fragNum = 0;
- PACKET_INFO PacketInfo;
- USHORT EncryptionOverhead = 0;
- UINT32 FreeMpduSize, SrcRemainingBytes;
- USHORT AckDuration;
- UINT NextMpduSize;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- ASSERT(TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag));
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- if (pTxBlk->CipherAlg == CIPHER_TKIP)
- {
- pTxBlk->pPacket = duplicate_pkt_with_TKIP_MIC(pAd, pTxBlk->pPacket);
- if (pTxBlk->pPacket == NULL)
- return;
- RTMP_QueryPacketInfo(pTxBlk->pPacket, &PacketInfo, &pTxBlk->pSrcBufHeader, &pTxBlk->SrcBufLen);
- }
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *)pHeaderBufPtr;
-
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- //
- // if original Ethernet frame contains no LLC/SNAP,
- // then an extra LLC/SNAP encap is required
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- UCHAR vlan_size;
-
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // skip vlan tag
- vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader+12+vlan_size, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
-
- // If TKIP is used and fragmentation is required. Driver has to
- // append TKIP MIC at tail of the scatter buffer
- // MAC ASIC will only perform IV/EIV/ICV insertion but no TKIP MIC
- if (pTxBlk->CipherAlg == CIPHER_TKIP)
- {
-
- // NOTE: DON'T refer the skb->len directly after following copy. Becasue the length is not adjust
- // to correct lenght, refer to pTxBlk->SrcBufLen for the packet length in following progress.
- NdisMoveMemory(pTxBlk->pSrcBufData + pTxBlk->SrcBufLen, &pAd->PrivateInfo.Tx.MIC[0], 8);
- //skb_put((RTPKT_TO_OSPKT(pTxBlk->pPacket))->tail, 8);
- pTxBlk->SrcBufLen += 8;
- pTxBlk->TotalFrameLen += 8;
- pTxBlk->CipherAlg = CIPHER_TKIP_NO_MIC;
- }
-
- //
- // calcuate the overhead bytes that encryption algorithm may add. This
- // affects the calculate of "duration" field
- //
- if ((pTxBlk->CipherAlg == CIPHER_WEP64) || (pTxBlk->CipherAlg == CIPHER_WEP128))
- EncryptionOverhead = 8; //WEP: IV[4] + ICV[4];
- else if (pTxBlk->CipherAlg == CIPHER_TKIP_NO_MIC)
- EncryptionOverhead = 12;//TKIP: IV[4] + EIV[4] + ICV[4], MIC will be added to TotalPacketLength
- else if (pTxBlk->CipherAlg == CIPHER_TKIP)
- EncryptionOverhead = 20;//TKIP: IV[4] + EIV[4] + ICV[4] + MIC[8]
- else if (pTxBlk->CipherAlg == CIPHER_AES)
- EncryptionOverhead = 16; // AES: IV[4] + EIV[4] + MIC[8]
- else
- EncryptionOverhead = 0;
-
- // decide how much time an ACK/CTS frame will consume in the air
- AckDuration = RTMPCalcDuration(pAd, pAd->CommonCfg.ExpectedACKRate[pTxBlk->TxRate], 14);
-
- // Init the total payload length of this frame.
- SrcRemainingBytes = pTxBlk->SrcBufLen;
-
- pTxBlk->TotalFragNum = 0xff;
-
- do {
-
- FreeMpduSize = pAd->CommonCfg.FragmentThreshold - LENGTH_CRC;
-
- FreeMpduSize -= pTxBlk->MpduHeaderLen;
-
- if (SrcRemainingBytes <= FreeMpduSize)
- { // this is the last or only fragment
-
- pTxBlk->SrcBufLen = SrcRemainingBytes;
-
- pHeader_802_11->FC.MoreFrag = 0;
- pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + AckDuration;
-
- // Indicate the lower layer that this's the last fragment.
- pTxBlk->TotalFragNum = fragNum;
- }
- else
- { // more fragment is required
-
- pTxBlk->SrcBufLen = FreeMpduSize;
-
- NextMpduSize = min(((UINT)SrcRemainingBytes - pTxBlk->SrcBufLen), ((UINT)pAd->CommonCfg.FragmentThreshold));
- pHeader_802_11->FC.MoreFrag = 1;
- pHeader_802_11->Duration = (3 * pAd->CommonCfg.Dsifs) + (2 * AckDuration) + RTMPCalcDuration(pAd, pTxBlk->TxRate, NextMpduSize + EncryptionOverhead);
- }
-
- if (fragNum == 0)
- pTxBlk->FrameGap = IFS_HTTXOP;
- else
- pTxBlk->FrameGap = IFS_SIFS;
-
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, &FreeNumber);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- // Update the frame number, remaining size of the NDIS packet payload.
-
- // space for 802.11 header.
- if (fragNum == 0 && pTxBlk->pExtraLlcSnapEncap)
- pTxBlk->MpduHeaderLen -= LENGTH_802_1_H;
-
- fragNum++;
- SrcRemainingBytes -= pTxBlk->SrcBufLen;
- pTxBlk->pSrcBufData += pTxBlk->SrcBufLen;
-
- pHeader_802_11->Frag++; // increase Frag #
-
- }while(SrcRemainingBytes > 0);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-
-#define RELEASE_FRAMES_OF_TXBLK(_pAd, _pTxBlk, _pQEntry, _Status) \
- while(_pTxBlk->TxPacketList.Head) \
- { \
- _pQEntry = RemoveHeadQueue(&_pTxBlk->TxPacketList); \
- RELEASE_NDIS_PACKET(_pAd, QUEUE_ENTRY_TO_PACKET(_pQEntry), _Status); \
- }
-
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware encryption before really
- sent out to air.
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to outgoing Ndis frame
- NumberOfFrag Number of fragment required
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS STAHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx)
-{
- NDIS_PACKET *pPacket;
- PQUEUE_ENTRY pQEntry;
-
- // ---------------------------------------------
- // STEP 0. DO SANITY CHECK AND SOME EARLY PREPARATION.
- // ---------------------------------------------
- //
- ASSERT(pTxBlk->TxPacketList.Number);
- if (pTxBlk->TxPacketList.Head == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pTxBlk->TotalFrameNum == %ld!\n", pTxBlk->TxPacketList.Number));
- return NDIS_STATUS_FAILURE;
- }
-
- pPacket = QUEUE_ENTRY_TO_PACKET(pTxBlk->TxPacketList.Head);
-
-#if 0 //def CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- if ((pAd->CommonCfg.CarrierDetect.Enable == TRUE) && (isCarrierDetectExist(pAd) == TRUE))
- {
- DBGPRINT(RT_DEBUG_INFO,("STAHardTransmit --> radar detect not in normal mode !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return (NDIS_STATUS_FAILURE);
- }
-#endif // CARRIER_DETECTION_SUPPORT //
-
- // ------------------------------------------------------------------
- // STEP 1. WAKE UP PHY
- // outgoing frame always wakeup PHY to prevent frame lost and
- // turn off PSM bit to improve performance
- // ------------------------------------------------------------------
- // not to change PSM bit, just send this frame out?
- if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n"));
- AsicForceWakeup(pAd, TRUE);
- }
-
- // It should not change PSM bit, when APSD turn on.
- if ((!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable) && (pAd->CommonCfg.bAPSDForcePowerSave == FALSE))
- || (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
- || (RTMP_GET_PACKET_WAI(pTxBlk->pPacket)))
- {
- if ((pAd->StaCfg.Psm == PWR_SAVE) &&
- (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP))
- MlmeSetPsmBit(pAd, PWR_ACTIVE);
- }
-
- switch (pTxBlk->TxFrameType)
- {
-#ifdef DOT11_N_SUPPORT
- case TX_AMPDU_FRAME:
- STA_AMPDU_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_AMSDU_FRAME:
- STA_AMSDU_Frame_Tx(pAd, pTxBlk);
- break;
-#endif // DOT11_N_SUPPORT //
- case TX_LEGACY_FRAME:
- STA_Legacy_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_MCAST_FRAME:
- STA_Legacy_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_RALINK_FRAME:
- STA_ARalink_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_FRAG_FRAME:
- STA_Fragment_Frame_Tx(pAd, pTxBlk);
- break;
- default:
- {
- // It should not happened!
- DBGPRINT(RT_DEBUG_ERROR, ("Send a pacekt was not classified!! It should not happen!\n"));
- while(pTxBlk->TxPacketList.Number)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (pPacket)
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
- }
- break;
- }
-
- return (NDIS_STATUS_SUCCESS);
-
-}
-
-ULONG HashBytesPolynomial(UCHAR *value, unsigned int len)
-{
- unsigned char *word = value;
- unsigned int ret = 0;
- unsigned int i;
-
- for(i=0; i < len; i++)
- {
- int mod = i % 32;
- ret ^=(unsigned int) (word[i]) << mod;
- ret ^=(unsigned int) (word[i]) >> (32 - mod);
- }
- return ret;
-}
-
-VOID Sta_Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID)
-{
- if (TRUE
- )
- {
- announce_802_3_packet(pAd, pPacket);
- }
- else
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
-}
-
+#include "../../rt2860/sta/rtmp_data.c"
diff --git a/drivers/staging/rt2870/sta/sanity.c b/drivers/staging/rt2870/sta/sanity.c
index 239872464bed..f1f2333bb993 100644
--- a/drivers/staging/rt2870/sta/sanity.c
+++ b/drivers/staging/rt2870/sta/sanity.c
@@ -1,420 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sanity.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 add WMM support
-*/
-#include "../rt_config.h"
-
-extern UCHAR CISCO_OUI[];
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR BROADCOM_OUI[];
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeStartReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen)
-{
- MLME_START_REQ_STRUCT *Info;
-
- Info = (MLME_START_REQ_STRUCT *)(Msg);
-
- if (Info->SsidLen > MAX_LEN_OF_SSID)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqSanity fail - wrong SSID length\n"));
- return FALSE;
- }
-
- *pSsidLen = Info->SsidLen;
- NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT USHORT *pAid,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- OUT UCHAR *pHtCapabilityLen,
- OUT UCHAR *pAddHtInfoLen,
- OUT UCHAR *pNewExtChannelOffset,
- OUT PEDCA_PARM pEdcaParm,
- OUT UCHAR *pCkipFlag)
-{
- CHAR IeType, *Ptr;
- PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PEID_STRUCT pEid;
- ULONG Length = 0;
-
- *pNewExtChannelOffset = 0xff;
- *pHtCapabilityLen = 0;
- *pAddHtInfoLen = 0;
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
- Length += 2;
- NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
- Length += 2;
- *pCkipFlag = 0;
- *pExtRateLen = 0;
- pEdcaParm->bValid = FALSE;
-
- if (*pStatus != MLME_SUCCESS)
- return TRUE;
-
- NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
- Length += 2;
-
- // Aid already swaped byte order in RTMPFrameEndianChange() for big endian platform
- *pAid = (*pAid) & 0x3fff; // AID is low 14-bit
-
- // -- get supported rates from payload and advance the pointer
- IeType = pFrame->Octet[6];
- *pSupRateLen = pFrame->Octet[7];
- if ((IeType != IE_SUPP_RATES) || (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
- return FALSE;
- }
- else
- NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
-
- Length = Length + 2 + *pSupRateLen;
-
- // many AP implement proprietary IEs in non-standard order, we'd better
- // tolerate mis-ordered IEs to get best compatibility
- pEid = (PEID_STRUCT) &pFrame->Octet[8 + (*pSupRateLen)];
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- switch (pEid->Eid)
- {
- case IE_EXT_SUPP_RATES:
- if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
- *pExtRateLen = pEid->Len;
- }
- break;
-
- case IE_HT_CAP:
- case IE_HT_CAP2:
- if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
- {
- NdisMoveMemory(pHtCapability, pEid->Octet, SIZE_HT_CAP_IE);
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
-
- *pHtCapabilityLen = SIZE_HT_CAP_IE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
- }
-
- break;
-#ifdef DOT11_N_SUPPORT
- case IE_ADD_HT:
- case IE_ADD_HT2:
- if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
- {
- // This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
- // copy first sizeof(ADD_HT_INFO_IE)
- NdisMoveMemory(pAddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
-
- *(USHORT *)(&pAddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo2));
- *(USHORT *)(&pAddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo3));
-
- *pAddHtInfoLen = SIZE_ADD_HT_INFO_IE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
- }
-
- break;
- case IE_SECONDARY_CH_OFFSET:
- if (pEid->Len == 1)
- {
- *pNewExtChannelOffset = pEid->Octet[0];
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
- }
-#endif // DOT11_N_SUPPORT //
- break;
- case IE_AIRONET_CKIP:
- // 0. Check Aironet IE length, it must be larger or equal to 28
- // Cisco's AP VxWork version(will not be supported) used this IE length as 28
- // Cisco's AP IOS version used this IE length as 30
- if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
- break;
-
- // 1. Copy CKIP flag byte to buffer for process
- *pCkipFlag = *(pEid->Octet + 8);
- break;
-
- case IE_AIRONET_IPADDRESS:
- if (pEid->Len != 0x0A)
- break;
-
- // Get Cisco Aironet IP information
- if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
- NdisMoveMemory(pAd->StaCfg.AironetIPAddress, pEid->Octet + 4, 4);
- break;
-
- // CCX2, WMM use the same IE value
- // case IE_CCX_V2:
- case IE_VENDOR_SPECIFIC:
- // handle WME PARAMTER ELEMENT
- if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
- {
- PUCHAR ptr;
- int i;
-
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- //pEdcaParm->bMoreDataAck = FALSE; // pEid->Octet[0] & 0x80;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
- ptr = &pEid->Octet[8];
- for (i=0; i<4; i++)
- {
- UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
- pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
- pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
- pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
- pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
- pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
- ptr += 4; // point to next AC
- }
- }
-
- // handle CCX IE
- else
- {
- // 0. Check the size and CCX admin control
- if (pAd->StaCfg.CCXControl.field.Enable == 0)
- break;
- if (pEid->Len != 5)
- break;
-
- // Turn CCX2 if matched
- if (NdisEqualMemory(pEid->Octet, Ccx2IeInfo, 5) == 1)
- pAd->StaCfg.CCXEnable = TRUE;
- break;
- }
- break;
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity - ignore unrecognized EID = %d\n", pEid->Eid));
- break;
- }
-
- Length = Length + 2 + pEid->Len;
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- // Force CCX2 enable to TRUE for those AP didn't replay CCX v2 IE, we still force it to be on
- if (pAd->StaCfg.CCXControl.field.Enable == 1)
- pAd->StaCfg.CCXEnable = TRUE;
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen)
-{
- UCHAR Idx;
- UCHAR RateLen;
- CHAR IeType;
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-
- if ((pFrame->Octet[0] != IE_SSID) || (pFrame->Octet[1] > MAX_LEN_OF_SSID))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",pFrame->Octet[0],pFrame->Octet[1]));
- return FALSE;
- }
-
- *pSsidLen = pFrame->Octet[1];
- NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
-
- Idx = *pSsidLen + 2;
-
- // -- get supported rates from payload and advance the pointer
- IeType = pFrame->Octet[Idx];
- RateLen = pFrame->Octet[Idx + 1];
- if (IeType != IE_SUPP_RATES)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",pFrame->Octet[Idx],pFrame->Octet[Idx+1]));
- return FALSE;
- }
- else
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
- return (FALSE);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN GetTimBit(
- IN CHAR *Ptr,
- IN USHORT Aid,
- OUT UCHAR *TimLen,
- OUT UCHAR *BcastFlag,
- OUT UCHAR *DtimCount,
- OUT UCHAR *DtimPeriod,
- OUT UCHAR *MessageToMe)
-{
- UCHAR BitCntl, N1, N2, MyByte, MyBit;
- CHAR *IdxPtr;
-
- IdxPtr = Ptr;
-
- IdxPtr ++;
- *TimLen = *IdxPtr;
-
- // get DTIM Count from TIM element
- IdxPtr ++;
- *DtimCount = *IdxPtr;
-
- // get DTIM Period from TIM element
- IdxPtr++;
- *DtimPeriod = *IdxPtr;
-
- // get Bitmap Control from TIM element
- IdxPtr++;
- BitCntl = *IdxPtr;
-
- if ((*DtimCount == 0) && (BitCntl & 0x01))
- *BcastFlag = TRUE;
- else
- *BcastFlag = FALSE;
-
- // Parse Partial Virtual Bitmap from TIM element
- N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
- N2 = *TimLen - 4 + N1; // N2 is the last bitmap byte#
-
- if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
- *MessageToMe = FALSE;
- else
- {
- MyByte = (Aid >> 3) - N1; // my byte position in the bitmap byte-stream
- MyBit = Aid % 16 - ((MyByte & 0x01)? 8:0);
-
- IdxPtr += (MyByte + 1);
-
- //if (*IdxPtr)
- // DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
-
- if (*IdxPtr & (0x01 << MyBit))
- *MessageToMe = TRUE;
- else
- *MessageToMe = FALSE;
- }
-
- return TRUE;
-}
-
+#include "../../rt2860/sta/sanity.c"
diff --git a/drivers/staging/rt2870/sta/sync.c b/drivers/staging/rt2870/sta/sync.c
index a48975566e08..66c8772ad346 100644
--- a/drivers/staging/rt2870/sta/sync.c
+++ b/drivers/staging/rt2870/sta/sync.c
@@ -1,1753 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sync.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 modified for rt2561/2661
- Jan Lee 2006-08-01 modified for rt2860 for 802.11n
-*/
-#include "../rt_config.h"
-
-#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec
-
-/*
- ==========================================================================
- Description:
- The sync state machine,
- Parameters:
- Sm - pointer to the state machine
- Note:
- the state machine looks like the following
-
- ==========================================================================
- */
-VOID SyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG, (STATE_MACHINE_FUNC)Drop, SYNC_IDLE, SYNC_MACHINE_BASE);
-
- // column 1
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)MlmeScanReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)MlmeJoinReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)MlmeStartReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeacon);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
-
- //column 2
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtJoinAction);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_BEACON_TIMEOUT, (STATE_MACHINE_FUNC)BeaconTimeoutAtJoinAction);
-
- // column 3
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_PROBE_RSP, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_SCAN_TIMEOUT, (STATE_MACHINE_FUNC)ScanTimeoutAction);
-
- // timer init
- RTMPInitTimer(pAd, &pAd->MlmeAux.BeaconTimer, GET_TIMER_FUNCTION(BeaconTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer, GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- Beacon timeout handler, executed in timer thread
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID BeaconTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- DBGPRINT(RT_DEBUG_TRACE,("SYNC - BeaconTimeout\n"));
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
- )
- {
- UCHAR BBPValue = 0;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
- }
-#endif // DOT11_N_SUPPORT //
-
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Scan timeout handler, executed in timer thread
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
- if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL))
- {
- RT28XX_MLME_HANDLER(pAd);
- }
- else
- {
- // To prevent SyncMachine.CurrState is SCAN_LISTEN forever.
- pAd->MlmeAux.Channel = 0;
- ScanNextChannel(pAd);
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME SCAN req state machine procedure
- ==========================================================================
- */
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
- BOOLEAN TimerCancelled;
- ULONG Now;
- USHORT Status;
- PHEADER_802_11 pHdr80211;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
-
- // Check the total scan tries for one single OID command
- // If this is the CCX 2.0 Case, skip that!
- if ( !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeScanReqAction before Startup\n"));
- return;
- }
-
- // Increase the scan retry counters.
- pAd->StaCfg.ScanCnt++;
-
-
- // first check the parameter sanity
- if (MlmeScanReqSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- &BssType,
- Ssid,
- &SsidLen,
- &ScanType))
- {
-
- // Check for channel load and noise hist request
- // Suspend MSDU only at scan request, not the last two mentioned
- if ((ScanType == SCAN_CISCO_NOISE) || (ScanType == SCAN_CISCO_CHANNEL_LOAD))
- {
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- RTMPSuspendMsduTransmission(pAd); // Suspend MSDU transmission here
- }
- else
- {
- // Suspend MSDU transmission here
- RTMPSuspendMsduTransmission(pAd);
- }
-
- //
- // To prevent data lost.
- // Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
- // And should send an NULL data with turned PSM bit off to AP, when scan progress done
- //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
- {
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- pHdr80211 = (PHEADER_802_11) pOutBuffer;
- MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pHdr80211->Duration = 0;
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame for off channel RM\n"));
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPusecDelay(5000);
- }
- }
-
- NdisGetSystemUpTime(&Now);
- pAd->StaCfg.LastScanTime = Now;
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
-
- // record desired BSS parameters
- pAd->MlmeAux.BssType = BssType;
- pAd->MlmeAux.ScanType = ScanType;
- pAd->MlmeAux.SsidLen = SsidLen;
- NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
-
- // start from the first channel
- pAd->MlmeAux.Channel = FirstChannel(pAd);
-
- // Change the scan channel when dealing with CCX beacon report
- if ((ScanType == SCAN_CISCO_PASSIVE) || (ScanType == SCAN_CISCO_ACTIVE) ||
- (ScanType == SCAN_CISCO_CHANNEL_LOAD) || (ScanType == SCAN_CISCO_NOISE))
- pAd->MlmeAux.Channel = pAd->StaCfg.CCXScanChannel;
-
- // Let BBP register at 20MHz to do scan
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
- ScanNextChannel(pAd);
- }
- else
- {
- DBGPRINT_ERR(("SYNC - MlmeScanReqAction() sanity check fail\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME JOIN req state machine procedure
- ==========================================================================
- */
-VOID MlmeJoinReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR BBPValue = 0;
- BSS_ENTRY *pBss;
- BOOLEAN TimerCancelled;
- HEADER_802_11 Hdr80211;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- PUCHAR pOutBuffer = NULL;
- PUCHAR pSupRate = NULL;
- UCHAR SupRateLen;
- PUCHAR pExtRate = NULL;
- UCHAR ExtRateLen;
- UCHAR ASupRate[] = {0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C};
- UCHAR ASupRateLen = sizeof(ASupRate)/sizeof(UCHAR);
- MLME_JOIN_REQ_STRUCT *pInfo = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
-
-
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- pBss = &pAd->MlmeAux.SsidBssTab.BssEntry[pInfo->BssIdx];
-
- // record the desired SSID & BSSID we're waiting for
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pBss->Bssid);
-
- // If AP's SSID is not hidden, it is OK for updating ssid to MlmeAux again.
- if (pBss->Hidden == 0)
- {
- NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);
- pAd->MlmeAux.SsidLen = pBss->SsidLen;
- }
-
- pAd->MlmeAux.BssType = pBss->BssType;
- pAd->MlmeAux.Channel = pBss->Channel;
- pAd->MlmeAux.CentralChannel = pBss->CentralChannel;
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // Country IE of the AP will be evaluated and will be used.
- if ((pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None) &&
- (pBss->bHasCountryIE == TRUE))
- {
- NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pBss->CountryString[0], 2);
- if (pBss->CountryString[2] == 'I')
- pAd->CommonCfg.Geography = IDOR;
- else if (pBss->CountryString[2] == 'O')
- pAd->CommonCfg.Geography = ODOR;
- else
- pAd->CommonCfg.Geography = BOTH;
- BuildChannelListEx(pAd);
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // Let BBP register at 20MHz to do scan
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
-
- // switch channel and waiting for beacon timer
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
- RTMPSetTimer(&pAd->MlmeAux.BeaconTimer, JOIN_TIMEOUT);
-
- do
- {
- if (((pAd->CommonCfg.bIEEE80211H == 1) &&
- (pAd->MlmeAux.Channel > 14) &&
- RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- //
- // We can't send any Probe request frame to meet 802.11h.
- //
- if (pBss->Hidden == 0)
- break;
- }
-
- //
- // send probe request
- //
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- if (pAd->MlmeAux.Channel <= 14)
- {
- pSupRate = pAd->CommonCfg.SupRate;
- SupRateLen = pAd->CommonCfg.SupRateLen;
- pExtRate = pAd->CommonCfg.ExtRate;
- ExtRateLen = pAd->CommonCfg.ExtRateLen;
- }
- else
- {
- //
- // Overwrite Support Rate, CCK rate are not allowed
- //
- pSupRate = ASupRate;
- SupRateLen = ASupRateLen;
- ExtRateLen = 0;
- }
-
- if (pAd->MlmeAux.BssType == BSS_INFRA)
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, pAd->MlmeAux.Bssid, pAd->MlmeAux.Bssid);
- else
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &SupRateLen,
- SupRateLen, pSupRate,
- END_OF_ARGS);
-
- if (ExtRateLen)
- {
- ULONG Tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtRateIe,
- 1, &ExtRateLen,
- ExtRateLen, pExtRate,
- END_OF_ARGS);
- FrameLen += Tmp;
- }
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- } while (FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n",
- pBss->Channel, pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2], pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
-
- pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
-}
-
-/*
- ==========================================================================
- Description:
- MLME START Request state machine procedure, starting an IBSS
- ==========================================================================
- */
-VOID MlmeStartReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
- BOOLEAN TimerCancelled;
-
- // New for WPA security suites
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- LARGE_INTEGER TimeStamp;
- BOOLEAN Privacy;
- USHORT Status;
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- TimeStamp.u.LowPart = 0;
- TimeStamp.u.HighPart = 0;
-
- if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen))
- {
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- //
- // Start a new IBSS. All IBSS parameters are decided now....
- //
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
- pAd->MlmeAux.BssType = BSS_ADHOC;
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
- pAd->MlmeAux.SsidLen = SsidLen;
-
- // generate a radom number as BSSID
- MacAddrRandomBssid(pAd, pAd->MlmeAux.Bssid);
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - generate a radom number as BSSID \n"));
-
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- pAd->MlmeAux.CapabilityInfo = CAP_GENERATE(0,1,Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 1, 0);
- pAd->MlmeAux.BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
- pAd->MlmeAux.AtimWin = pAd->StaCfg.AtimWin;
- pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
-
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.CentralChannel;
-
- pAd->MlmeAux.SupRateLen= pAd->CommonCfg.SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
- pAd->MlmeAux.ExtRateLen = pAd->CommonCfg.ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy, &pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0], &pAd->MlmeAux.HtCapability, &pAd->MlmeAux.AddHtInfo);
- pAd->MlmeAux.HtCapabilityLen = sizeof(HT_CAPABILITY_IE);
- // Not turn pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE here.
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n"));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->MlmeAux.HtCapabilityLen = 0;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- }
- // temporarily not support QOS in IBSS
- NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
-
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeStartReqAction(ch= %d,sup rates= %d, ext rates=%d)\n",
- pAd->MlmeAux.Channel, pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
- }
- else
- {
- DBGPRINT_ERR(("SYNC - MlmeStartReqAction() sanity check fail.\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- peer sends beacon back when scanning
- ==========================================================================
- */
-VOID PeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
- SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe;
- CF_PARM CfParm;
- USHORT BeaconPeriod, AtimWin, CapabilityInfo;
- PFRAME_802_11 pFrame;
- LARGE_INTEGER TimeStamp;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- USHORT LenVIE;
- UCHAR CkipFlag;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- ULONG RalinkIe;
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
-
- // NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00);
- pFrame = (PFRAME_802_11) Elem->Msg;
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
-#ifdef DOT11_N_SUPPORT
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-#endif // DOT11_N_SUPPORT //
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &CfParm,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- ULONG Idx;
- CHAR Rssi = 0;
-
- Idx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Idx != BSS_NOT_FOUND)
- Rssi = pAd->ScanTab.BssEntry[Idx].Rssi;
-
- Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
-
-#ifdef DOT11_N_SUPPORT
- if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
- HtCapabilityLen = SIZE_HT_CAP_IE;
-#endif // DOT11_N_SUPPORT //
- if ((pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) && (Channel == pAd->StaCfg.CCXScanChannel))
- {
- Idx = BssTableSetEntry(pAd, &pAd->StaCfg.CCXBssTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen,ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
- if (Idx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(pAd->StaCfg.CCXBssTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->StaCfg.CCXBssTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->StaCfg.CCXBssTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
- if (pAd->StaCfg.CCXReqType == MSRN_TYPE_BEACON_REQ)
- AironetAddBeaconReport(pAd, Idx, Elem);
- }
- }
- else
- {
- Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (pAd->ChannelList[pAd->CommonCfg.ChannelListIdx].bEffectedChannel == TRUE)
- {
- UCHAR RegClass;
- PeerBeaconAndProbeRspSanity2(pAd, Elem->Msg, Elem->MsgLen, &RegClass);
- TriEventTableSetEntry(pAd, &pAd->CommonCfg.TriggerEventTab, Bssid, &HtCapability, HtCapabilityLen, RegClass, Channel);
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
- if (Idx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
- }
- }
- }
- // sanity check fail, ignored
-}
-
-/*
- ==========================================================================
- Description:
- When waiting joining the (I)BSS, beacon received from external
- ==========================================================================
- */
-VOID PeerBeaconAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
- DtimCount, DtimPeriod, BcastFlag, NewChannel;
- LARGE_INTEGER TimeStamp;
- USHORT BeaconPeriod, AtimWin, CapabilityInfo;
- CF_PARM Cf;
- BOOLEAN TimerCancelled;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- UCHAR CkipFlag;
- USHORT LenVIE;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- USHORT Status;
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- ULONG RalinkIe;
- ULONG Idx;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-#ifdef DOT11_N_SUPPORT
- UCHAR CentralChannel;
-#endif // DOT11_N_SUPPORT //
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &Cf,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- // Disqualify 11b only adhoc when we are in 11g only adhoc mode
- if ((BssType == BSS_ADHOC) && (pAd->CommonCfg.PhyMode == PHY_11G) && ((SupRateLen+ExtRateLen)< 12))
- return;
-
- // BEACON from desired BSS/IBSS found. We should be able to decide most
- // BSS parameters here.
- // Q. But what happen if this JOIN doesn't conclude a successful ASSOCIATEION?
- // Do we need to receover back all parameters belonging to previous BSS?
- // A. Should be not. There's no back-door recover to previous AP. It still need
- // a new JOIN-AUTH-ASSOC sequence.
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n", Channel));
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- // Update RSSI to prevent No signal display when cards first initialized
- pAd->StaCfg.RssiSample.LastRssi0 = ConvertToRssi(pAd, Elem->Rssi0, RSSI_0);
- pAd->StaCfg.RssiSample.LastRssi1 = ConvertToRssi(pAd, Elem->Rssi1, RSSI_1);
- pAd->StaCfg.RssiSample.LastRssi2 = ConvertToRssi(pAd, Elem->Rssi2, RSSI_2);
- pAd->StaCfg.RssiSample.AvgRssi0 = pAd->StaCfg.RssiSample.LastRssi0;
- pAd->StaCfg.RssiSample.AvgRssi0X8 = pAd->StaCfg.RssiSample.AvgRssi0 << 3;
- pAd->StaCfg.RssiSample.AvgRssi1 = pAd->StaCfg.RssiSample.LastRssi1;
- pAd->StaCfg.RssiSample.AvgRssi1X8 = pAd->StaCfg.RssiSample.AvgRssi1 << 3;
- pAd->StaCfg.RssiSample.AvgRssi2 = pAd->StaCfg.RssiSample.LastRssi2;
- pAd->StaCfg.RssiSample.AvgRssi2X8 = pAd->StaCfg.RssiSample.AvgRssi2 << 3;
-
- //
- // We need to check if SSID only set to any, then we can record the current SSID.
- // Otherwise will cause hidden SSID association failed.
- //
- if (pAd->MlmeAux.SsidLen == 0)
- {
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
- pAd->MlmeAux.SsidLen = SsidLen;
- }
- else
- {
- Idx = BssSsidTableSearch(&pAd->ScanTab, Bssid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Channel);
-
- if (Idx != BSS_NOT_FOUND)
- {
- //
- // Multiple SSID case, used correct CapabilityInfo
- //
- CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
- }
- }
- NdisMoveMemory(pAd->MlmeAux.Bssid, Bssid, MAC_ADDR_LEN);
- pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
- pAd->MlmeAux.BssType = BssType;
- pAd->MlmeAux.BeaconPeriod = BeaconPeriod;
- pAd->MlmeAux.Channel = Channel;
- pAd->MlmeAux.AtimWin = AtimWin;
- pAd->MlmeAux.CfpPeriod = Cf.CfpPeriod;
- pAd->MlmeAux.CfpMaxDuration = Cf.CfpMaxDuration;
- pAd->MlmeAux.APRalinkIe = RalinkIe;
-
- // Copy AP's supported rate to MlmeAux for creating assoication request
- // Also filter out not supported rate
- pAd->MlmeAux.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
- pAd->MlmeAux.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-
- NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, 16);
-#ifdef DOT11_N_SUPPORT
- pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
- pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
-
- // filter out un-supported ht rates
- if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo, &AddHtInfo, SIZE_ADD_HT_INFO_IE);
-
- // StaActive.SupportedHtPhy.MCSSet stores Peer AP's 11n Rx capability
- NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, HtCapability.MCSSet, 16);
- pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
- pAd->MlmeAux.HtCapabilityLen = SIZE_HT_CAP_IE;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
- if (PreNHtCapabilityLen > 0)
- pAd->StaActive.SupportedPhyInfo.bPreNHt = TRUE;
- RTMPCheckHt(pAd, BSSID_WCID, &HtCapability, &AddHtInfo);
- // Copy AP Parameter to StaActive. This is also in LinkUp.
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
- pAd->StaActive.SupportedHtPhy.MpduDensity, pAd->StaActive.SupportedHtPhy.MaxRAmpduFactor, HtCapability.HtCapInfo.ChannelWidth));
-
- if (AddHtInfoLen > 0)
- {
- CentralChannel = AddHtInfo.ControlChan;
- // Check again the Bandwidth capability of this AP.
- if ((AddHtInfo.ControlChan > 2)&& (AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- CentralChannel = AddHtInfo.ControlChan - 2;
- }
- else if ((AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- CentralChannel = AddHtInfo.ControlChan + 2;
- }
-
- // Check Error .
- if (pAd->MlmeAux.CentralChannel != CentralChannel)
- DBGPRINT(RT_DEBUG_ERROR, ("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n", CentralChannel, AddHtInfo.ControlChan, pAd->MlmeAux.CentralChannel));
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d, .\n", CentralChannel, AddHtInfo.ControlChan));
-
- }
-
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // To prevent error, let legacy AP must have same CentralChannel and Channel.
- if ((HtCapabilityLen == 0) && (PreNHtCapabilityLen == 0))
- pAd->MlmeAux.CentralChannel = pAd->MlmeAux.Channel;
-
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo, SIZE_ADD_HT_INFO_IE);
- }
-
- RTMPUpdateMlmeRate(pAd);
-
- // copy QOS related information
- if ((pAd->CommonCfg.bWmmCapable)
-#ifdef DOT11_N_SUPPORT
- || (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-#endif // DOT11_N_SUPPORT //
- )
- {
- NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, &EdcaParm, sizeof(EDCA_PARM));
- NdisMoveMemory(&pAd->MlmeAux.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisMoveMemory(&pAd->MlmeAux.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
- else
- {
- NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-
-#ifdef LEAP_SUPPORT
- // Update CkipFlag
- pAd->StaCfg.CkipFlag = CkipFlag;
-
- // Keep TimeStamp for Re-Association used.
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- pAd->StaCfg.CCKMBeaconAtJoinTimeStamp = TimeStamp;
-#endif // LEAP_SUPPORT //
-
- if (AironetCellPowerLimit != 0xFF)
- {
- //We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power
- ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
- }
- else //Used the default TX Power Percentage.
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
- }
- // not to me BEACON, ignored
- }
- // sanity check fail, ignore this frame
-}
-
-/*
- ==========================================================================
- Description:
- receive BEACON from peer
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- CHAR Ssid[MAX_LEN_OF_SSID];
- CF_PARM CfParm;
- UCHAR SsidLen, MessageToMe=0, BssType, Channel, NewChannel, index=0;
- UCHAR DtimCount=0, DtimPeriod=0, BcastFlag=0;
- USHORT CapabilityInfo, AtimWin, BeaconPeriod;
- LARGE_INTEGER TimeStamp;
- USHORT TbttNumToNextWakeUp;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- UCHAR CkipFlag;
- USHORT LenVIE;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- ULONG RalinkIe;
- // New for WPA security suites
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen, PreNHtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- if (!(INFRA_ON(pAd) || ADHOC_ON(pAd)
- ))
- return;
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &CfParm,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- BOOLEAN is_my_bssid, is_my_ssid;
- ULONG Bssidx, Now;
- BSS_ENTRY *pBss;
- CHAR RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
- is_my_bssid = MAC_ADDR_EQUAL(Bssid, pAd->CommonCfg.Bssid)? TRUE : FALSE;
- is_my_ssid = SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen)? TRUE:FALSE;
-
-
- // ignore BEACON not for my SSID
- if ((! is_my_ssid) && (! is_my_bssid))
- return;
-
- // It means STA waits disassoc completely from this AP, ignores this beacon.
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_WAIT_DISASSOC)
- return;
-
-#ifdef DOT11_N_SUPPORT
- // Copy Control channel for this BSSID.
- if (AddHtInfoLen != 0)
- Channel = AddHtInfo.ControlChan;
-
- if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
- HtCapabilityLen = SIZE_HT_CAP_IE;
-#endif // DOT11_N_SUPPORT //
-
- //
- // Housekeeping "SsidBssTab" table for later-on ROAMing usage.
- //
- Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- // discover new AP of this network, create BSS entry
- Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,
- &HtCapability, &AddHtInfo,HtCapabilityLen,AddHtInfoLen,NewExtChannelOffset, Channel,
- RealRssi, TimeStamp, CkipFlag, &EdcaParm, &QosCapability,
- &QbssLoad, LenVIE, pVIE);
- if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
- return;
-
- NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
-
-
-
- }
-
- if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
- {
- // Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection).
- // In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results.
- AsicSwitchChannel(pAd, 1, FALSE);
- AsicLockChannel(pAd, 1);
- LinkDown(pAd, FALSE);
- MlmeQueueInit(&pAd->Mlme.Queue);
- BssTableInit(&pAd->ScanTab);
- RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
-
- // channel sanity check
- for (index = 0 ; index < pAd->ChannelListNum; index++)
- {
- if (pAd->ChannelList[index].Channel == NewChannel)
- {
- pAd->ScanTab.BssEntry[Bssidx].Channel = NewChannel;
- pAd->CommonCfg.Channel = NewChannel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeacon - STA receive channel switch announcement IE (New Channel =%d)\n", NewChannel));
- break;
- }
- }
-
- if (index >= pAd->ChannelListNum)
- {
- DBGPRINT_ERR(("PeerBeacon(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum));
- }
- }
-
- // if the ssid matched & bssid unmatched, we should select the bssid with large value.
- // This might happened when two STA start at the same time
- if ((! is_my_bssid) && ADHOC_ON(pAd))
- {
- INT i;
-
- // Add the safeguard against the mismatch of adhoc wep status
- if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus)
- {
- return;
- }
-
- // collapse into the ADHOC network which has bigger BSSID value.
- for (i = 0; i < 6; i++)
- {
- if (Bssid[i] > pAd->CommonCfg.Bssid[i])
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- AsicDisableSync(pAd);
- COPY_MAC_ADDR(pAd->CommonCfg.Bssid, Bssid);
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
- MakeIbssBeacon(pAd); // re-build BEACON frame
- AsicEnableIbssSync(pAd); // copy BEACON frame to on-chip memory
- is_my_bssid = TRUE;
- break;
- }
- else if (Bssid[i] < pAd->CommonCfg.Bssid[i])
- break;
- }
- }
-
-
- NdisGetSystemUpTime(&Now);
- pBss = &pAd->ScanTab.BssEntry[Bssidx];
- pBss->Rssi = RealRssi; // lastest RSSI
- pBss->LastBeaconRxTime = Now; // last RX timestamp
-
- //
- // BEACON from my BSSID - either IBSS or INFRA network
- //
- if (is_my_bssid)
- {
- RXWI_STRUC RxWI;
-
- pAd->StaCfg.DtimCount = DtimCount;
- pAd->StaCfg.DtimPeriod = DtimPeriod;
- pAd->StaCfg.LastBeaconRxTime = Now;
-
-
- RxWI.RSSI0 = Elem->Rssi0;
- RxWI.RSSI1 = Elem->Rssi1;
- RxWI.RSSI2 = Elem->Rssi2;
-
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, &RxWI);
- if (AironetCellPowerLimit != 0xFF)
- {
- //
- // We get the Cisco (ccx) "TxPower Limit" required
- // Changed to appropriate TxPower Limit for Ciso Compatible Extensions
- //
- ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
- }
- else
- {
- //
- // AironetCellPowerLimit equal to 0xFF means the Cisco (ccx) "TxPower Limit" not exist.
- // Used the default TX Power Percentage, that set from UI.
- //
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
- }
-
- if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
- {
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR idx;
- MAC_TABLE_ENTRY *pEntry;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (idx=0; idx<SupRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
- }
-
- for (idx=0; idx<ExtRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
- }
-
- // look up the existing table
- pEntry = MacTableLookup(pAd, Addr2);
-
- // Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon.
- // To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station.
- if ((ADHOC_ON(pAd) && (Elem->Wcid == RESERVED_WCID)) ||
- (pEntry && ((pEntry->LastBeaconRxTime + ADHOC_ENTRY_BEACON_LOST_TIME) < Now)))
- {
- if (pEntry == NULL)
- // Another adhoc joining, add to our MAC table.
- pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);
-
- if (StaAddMacTableEntry(pAd, pEntry, MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo) == FALSE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
- return;
- }
-
- if (pEntry &&
- (Elem->Wcid == RESERVED_WCID))
- {
- idx = pAd->StaCfg.DefaultKeyId;
- RT28XX_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry);
- }
- }
-
- if (pEntry && pEntry->ValidAsCLI)
- pEntry->LastBeaconRxTime = Now;
-
- // At least another peer in this IBSS, declare MediaState as CONNECTED
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_UP;
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-
- // 2003/03/12 - john
- // Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that
- // "site survey" result should always include the current connected network.
- //
- Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
- }
- }
-
- if (INFRA_ON(pAd))
- {
- BOOLEAN bUseShortSlot, bUseBGProtection;
-
- // decide to use/change to -
- // 1. long slot (20 us) or short slot (9 us) time
- // 2. turn on/off RTS/CTS and/or CTS-to-self protection
- // 3. short preamble
-
- //bUseShortSlot = pAd->CommonCfg.bUseShortSlotTime && CAP_IS_SHORT_SLOT(CapabilityInfo);
- bUseShortSlot = CAP_IS_SHORT_SLOT(CapabilityInfo);
- if (bUseShortSlot != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
- AsicSetSlotTime(pAd, bUseShortSlot);
-
- bUseBGProtection = (pAd->CommonCfg.UseBGProtection == 1) || // always use
- ((pAd->CommonCfg.UseBGProtection == 0) && ERP_IS_USE_PROTECTION(Erp));
-
- if (pAd->CommonCfg.Channel > 14) // always no BG protection in A-band. falsely happened when switching A/G band to a dual-band AP
- bUseBGProtection = FALSE;
-
- if (bUseBGProtection != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- if (bUseBGProtection)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),FALSE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
- }
- else
- {
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),TRUE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
- }
-
- DBGPRINT(RT_DEBUG_WARN, ("SYNC - AP changed B/G protection to %d\n", bUseBGProtection));
- }
-
-#ifdef DOT11_N_SUPPORT
- // check Ht protection mode. and adhere to the Non-GF device indication by AP.
- if ((AddHtInfoLen != 0) &&
- ((AddHtInfo.AddHtInfo2.OperaionMode != pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode) ||
- (AddHtInfo.AddHtInfo2.NonGfPresent != pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent)))
- {
- pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent = AddHtInfo.AddHtInfo2.NonGfPresent;
- pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode = AddHtInfo.AddHtInfo2.OperaionMode;
- if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
- }
- else
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP changed N OperaionMode to %d\n", pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode));
- }
-#endif // DOT11_N_SUPPORT //
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) &&
- ERP_IS_USE_BARKER_PREAMBLE(Erp))
- {
- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP forced to use LONG preamble\n"));
- }
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- (EdcaParm.bValid == TRUE) &&
- (EdcaParm.EdcaUpdateCount != pAd->CommonCfg.APEdcaParm.EdcaUpdateCount))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP change EDCA parameters(from %d to %d)\n",
- pAd->CommonCfg.APEdcaParm.EdcaUpdateCount,
- EdcaParm.EdcaUpdateCount));
- AsicSetEdcaParm(pAd, &EdcaParm);
- }
-
- // copy QOS related information
- NdisMoveMemory(&pAd->CommonCfg.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisMoveMemory(&pAd->CommonCfg.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
-
- // only INFRASTRUCTURE mode support power-saving feature
- if ((INFRA_ON(pAd) && (pAd->StaCfg.Psm == PWR_SAVE)) || (pAd->CommonCfg.bAPSDForcePowerSave))
- {
- UCHAR FreeNumber;
- // 1. AP has backlogged unicast-to-me frame, stay AWAKE, send PSPOLL
- // 2. AP has backlogged broadcast/multicast frame and we want those frames, stay AWAKE
- // 3. we have outgoing frames in TxRing or MgmtRing, better stay AWAKE
- // 4. Psm change to PWR_SAVE, but AP not been informed yet, we better stay AWAKE
- // 5. otherwise, put PHY back to sleep to save battery.
- if (MessageToMe)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
- pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
- {
- pAd->CommonCfg.bNeedSendTriggerFrame = TRUE;
- }
- else
- RT28XX_PS_POLL_ENQUEUE(pAd);
- }
- else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
- {
- }
- else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_VI].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_VO].Number != 0) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_BK, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_BE, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_VI, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_VO, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_MGMT, MGMT_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS))
- {
- // TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
- // can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
- }
- else
- {
- USHORT NextDtim = DtimCount;
-
- if (NextDtim == 0)
- NextDtim = DtimPeriod;
-
- TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
- TbttNumToNextWakeUp = NextDtim;
-
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
- }
- }
- }
- }
- // not my BSSID, ignore it
- }
- // sanity check fail, ignore this frame
-}
-
-/*
- ==========================================================================
- Description:
- Receive PROBE REQ from remote peer when operating in IBSS mode
- ==========================================================================
- */
-VOID PeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- CHAR Ssid[MAX_LEN_OF_SSID];
- UCHAR SsidLen;
-#ifdef DOT11_N_SUPPORT
- UCHAR HtLen, AddHtLen, NewExtLen;
-#endif // DOT11_N_SUPPORT //
- HEADER_802_11 ProbeRspHdr;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- LARGE_INTEGER FakeTimestamp;
- UCHAR DsLen = 1, IbssLen = 2;
- UCHAR LocalErpIe[3] = {IE_ERP, 1, 0};
- BOOLEAN Privacy;
- USHORT CapabilityInfo;
- UCHAR RSNIe = IE_WPA;
-
- if (! ADHOC_ON(pAd))
- return;
-
- if (PeerProbeReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen))
- {
- if ((SsidLen == 0) || SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
- {
- // allocate and send out ProbeRsp frame
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- //pAd->StaCfg.AtimWin = 0; // ??????
-
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &ProbeRspHdr,
- TIMESTAMP_LEN, &FakeTimestamp,
- 2, &pAd->CommonCfg.BeaconPeriod,
- 2, &CapabilityInfo,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &pAd->StaActive.SupRateLen,
- pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
- 1, &DsIe,
- 1, &DsLen,
- 1, &pAd->CommonCfg.Channel,
- 1, &IbssIe,
- 1, &IbssLen,
- 2, &pAd->StaActive.AtimWin,
- END_OF_ARGS);
-
- if (pAd->StaActive.ExtRateLen)
- {
- ULONG tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 3, LocalErpIe,
- 1, &ExtRateIe,
- 1, &pAd->StaActive.ExtRateLen,
- pAd->StaActive.ExtRateLen, &pAd->StaActive.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // If adhoc secruity is set for WPA-None, append the cipher suite IE
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- ULONG tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- ULONG TmpLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- HtLen = sizeof(pAd->CommonCfg.HtCapability);
- AddHtLen = sizeof(pAd->CommonCfg.AddHTInfo);
- NewExtLen = 1;
- //New extension channel offset IE is included in Beacon, Probe Rsp or channel Switch Announcement Frame
- if (pAd->bBroadComHT == TRUE)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- sizeof(HT_CAPABILITY_IE), &pAd->CommonCfg.HtCapability,
- 1, &AddHtInfoIe,
- 1, &AddHtLen,
- sizeof(ADD_HT_INFO_IE), &pAd->CommonCfg.AddHTInfo,
- 1, &NewExtChanIe,
- 1, &NewExtLen,
- sizeof(NEW_EXT_CHAN_IE), &pAd->CommonCfg.NewExtChanOffset,
- END_OF_ARGS);
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- }
-}
-
-VOID BeaconTimeoutAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeoutAtJoinAction\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- Scan timeout procedure. basically add channel index by 1 and rescan
- ==========================================================================
- */
-VOID ScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- pAd->MlmeAux.Channel = NextChannel(pAd, pAd->MlmeAux.Channel);
-
- // Only one channel scanned for CISCO beacon request
- if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
- pAd->MlmeAux.Channel = 0;
-
- // this routine will stop if pAd->MlmeAux.Channel == 0
- ScanNextChannel(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenJoin(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenStart(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID EnqueuePsPoll(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
-
- if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP)
- pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
- MiniportMMRequest(pAd, 0, (PUCHAR)&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
-}
-
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID EnqueueProbeRequest(
- IN PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS NState;
- PUCHAR pOutBuffer;
- ULONG FrameLen = 0;
- HEADER_802_11 Hdr80211;
-
- DBGPRINT(RT_DEBUG_TRACE, ("force out a ProbeRequest ...\n"));
-
- NState = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NState == NDIS_STATUS_SUCCESS)
- {
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
-
- // this ProbeRequest explicitly specify SSID to reduce unwanted ProbeResponse
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &pAd->StaActive.SupRateLen,
- pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
-
-}
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
-VOID BuildEffectedChannelList(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR EChannel[11];
- UCHAR i, j, k;
- UCHAR UpperChannel = 0, LowerChannel = 0;
-
- RTMPZeroMemory(EChannel, 11);
- i = 0;
- // Find upper channel and lower channel.
- if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
- {
- UpperChannel = pAd->CommonCfg.Channel;
- LowerChannel = pAd->CommonCfg.CentralChannel;
- }
- else if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
- {
- UpperChannel = pAd->CommonCfg.CentralChannel;
- LowerChannel = pAd->CommonCfg.Channel;
- }
- else
- {
- return;
- }
-
- // Record channels that is below lower channel..
- if (LowerChannel > 1)
- {
- EChannel[0] = LowerChannel - 1;
- i = 1;
- if (LowerChannel > 2)
- {
- EChannel[1] = LowerChannel - 2;
- i = 2;
- if (LowerChannel > 3)
- {
- EChannel[2] = LowerChannel - 3;
- i = 3;
- }
- }
- }
- // Record channels that is between lower channel and upper channel.
- for (k = LowerChannel;k < UpperChannel;k++)
- {
- EChannel[i] = k;
- i++;
- }
- // Record channels that is above upper channel..
- if (LowerChannel < 11)
- {
- EChannel[i] = UpperChannel + 1;
- i++;
- if (LowerChannel < 10)
- {
- EChannel[i] = LowerChannel + 2;
- i++;
- if (LowerChannel < 9)
- {
- EChannel[i] = LowerChannel + 3;
- i++;
- }
- }
- }
- //
- for (j = 0;j < i;j++)
- {
- for (k = 0;k < pAd->ChannelListNum;k++)
- {
- if (pAd->ChannelList[k].Channel == EChannel[j])
- {
- pAd->ChannelList[k].bEffectedChannel = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,(" EffectedChannel( =%d)\n", EChannel[j]));
- break;
- }
- }
- }
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-BOOLEAN ScanRunning(
- IN PRTMP_ADAPTER pAd)
-{
- return (pAd->Mlme.SyncMachine.CurrState == SCAN_LISTEN) ? TRUE : FALSE;
-}
-
+#include "../../rt2860/sta/sync.c"
diff --git a/drivers/staging/rt2870/sta/wpa.c b/drivers/staging/rt2870/sta/wpa.c
index 8626dcde6054..57a2eb2d0896 100644
--- a/drivers/staging/rt2870/sta/wpa.c
+++ b/drivers/staging/rt2870/sta/wpa.c
@@ -1,2107 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- wpa.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 03-07-22 Initial
- Paul Lin 03-11-28 Modify for supplicant
-*/
-#include "../rt_config.h"
-
-#define WPARSNIE 0xdd
-#define WPA2RSNIE 0x30
-
-//extern UCHAR BIT8[];
-UCHAR CipherWpaPskTkip[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x02 // authentication
- };
-UCHAR CipherWpaPskTkipLen = (sizeof(CipherWpaPskTkip) / sizeof(UCHAR));
-
-UCHAR CipherWpaPskAes[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x04, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x04, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x02 // authentication
- };
-UCHAR CipherWpaPskAesLen = (sizeof(CipherWpaPskAes) / sizeof(UCHAR));
-
-UCHAR CipherSuiteCiscoCCKM[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x40, 0x96, 0x01, // Multicast
- 0x01, 0x00, // Number of uicast
- 0x00, 0x40, 0x96, 0x01, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x40, 0x96, 0x00 // Authentication
- };
-UCHAR CipherSuiteCiscoCCKMLen = (sizeof(CipherSuiteCiscoCCKM) / sizeof(UCHAR));
-
-UCHAR CipherSuiteCiscoCCKM24[] = {
- 0xDD, 0x18, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x40, 0x96, 0x01, // Multicast
- 0x01, 0x00, // Number of uicast
- 0x00, 0x40, 0x96, 0x01, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x40, 0x96, 0x00,
- 0x28, 0x00// Authentication
- };
-
-UCHAR CipherSuiteCiscoCCKM24Len = (sizeof(CipherSuiteCiscoCCKM24) / sizeof(UCHAR));
-
-UCHAR CipherSuiteCCXTkip[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x01 // authentication
- };
-UCHAR CipherSuiteCCXTkipLen = (sizeof(CipherSuiteCCXTkip) / sizeof(UCHAR));
-
-UCHAR CCX_LLC_HDR[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02};
-UCHAR LLC_NORMAL[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-
-UCHAR EAPOL_FRAME[] = {0x88, 0x8E};
-
-BOOLEAN CheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- OUT UCHAR *Offset);
-
-void inc_byte_array(UCHAR *counter, int len);
-
-/*
- ========================================================================
-
- Routine Description:
- Classify WPA EAP message type
-
- Arguments:
- EAPType Value of EAP message type
- MsgType Internal Message definition for MLME state machine
-
- Return Value:
- TRUE Found appropriate message type
- FALSE No appropriate message type
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- All these constants are defined in wpa.h
- For supplicant, there is only EAPOL Key message avaliable
-
- ========================================================================
-*/
-BOOLEAN WpaMsgTypeSubst(
- IN UCHAR EAPType,
- OUT INT *MsgType)
-{
- switch (EAPType)
- {
- case EAPPacket:
- *MsgType = MT2_EAPPacket;
- break;
- case EAPOLStart:
- *MsgType = MT2_EAPOLStart;
- break;
- case EAPOLLogoff:
- *MsgType = MT2_EAPOLLogoff;
- break;
- case EAPOLKey:
- *MsgType = MT2_EAPOLKey;
- break;
- case EAPOLASFAlert:
- *MsgType = MT2_EAPOLASFAlert;
- break;
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
- ==========================================================================
- */
-VOID WpaPskStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_WPA_PSK_STATE, MAX_WPA_PSK_MSG, (STATE_MACHINE_FUNC)Drop, WPA_PSK_IDLE, WPA_MACHINE_BASE);
- StateMachineSetAction(S, WPA_PSK_IDLE, MT2_EAPOLKey, (STATE_MACHINE_FUNC)WpaEAPOLKeyAction);
-}
-
-/*
- ==========================================================================
- Description:
- This is state machine function.
- When receiving EAPOL packets which is for 802.1x key management.
- Use both in WPA, and WPAPSK case.
- In this function, further dispatch to different functions according to the received packet. 3 categories are :
- 1. normal 4-way pairwisekey and 2-way groupkey handshake
- 2. MIC error (Countermeasures attack) report packet from STA.
- 3. Request for pairwise/group key update from STA
- Return:
- ==========================================================================
-*/
-VOID WpaEAPOLKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- INT MsgType = EAPOL_MSG_INVALID;
- PKEY_DESCRIPTER pKeyDesc;
- PHEADER_802_11 pHeader; //red
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
- UCHAR EapolVr;
- KEY_INFO peerKeyInfo;
-
- DBGPRINT(RT_DEBUG_TRACE, ("-----> WpaEAPOLKeyAction\n"));
-
- // Get 802.11 header first
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Get EAPoL-Key Descriptor
- pKeyDesc = (PKEY_DESCRIPTER) &Elem->Msg[(LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H)];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pKeyDesc->KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT *)&peerKeyInfo) = cpu2le16(*((USHORT *)&peerKeyInfo));
-
-
- // 1. Check EAPOL frame version and type
- EapolVr = (UCHAR) Elem->Msg[LENGTH_802_11+LENGTH_802_1_H];
-
- if (((EapolVr != EAPOL_VER) && (EapolVr != EAPOL_VER2)) || ((pKeyDesc->Type != WPA1_KEY_DESC) && (pKeyDesc->Type != WPA2_KEY_DESC)))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Key descripter does not match with WPA rule\n"));
- return;
- }
-
- // First validate replay counter, only accept message with larger replay counter
- // Let equal pass, some AP start with all zero replay counter
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
-
- if((RTMPCompareMemory(pKeyDesc->ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pKeyDesc->ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" ReplayCounter not match \n"));
- return;
- }
-
- // Process WPA2PSK frame
- if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.EKD_DL == 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 0) &&
- (peerKeyInfo.Secure == 0) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 1\n"));
- } else if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.EKD_DL == 1) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 1) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_3;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 3\n"));
- } else if((peerKeyInfo.KeyType == GROUPKEY) &&
- (peerKeyInfo.EKD_DL == 1) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 1) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_GROUP_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Group Message 1\n"));
- }
-
- // We will assume link is up (assoc suceess and port not secured).
- // All state has to be able to process message from previous state
- switch(pAd->StaCfg.WpaState)
- {
- case SS_START:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- Wpa2PairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- break;
-
- case SS_WAIT_MSG_3:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- Wpa2PairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- Wpa2PairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- }
- break;
-
- case SS_WAIT_GROUP: // When doing group key exchange
- case SS_FINISH: // This happened when update group key
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- Wpa2PairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- Wpa2PairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- }
- else if(MsgType == EAPOL_GROUP_MSG_1)
- {
- WpaGroupMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
- break;
-
- default:
- break;
- }
- }
- // Process WPAPSK Frame
- // Classify message Type, either pairwise message 1, 3, or group message 1 for supplicant
- else if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- {
- if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.KeyIndex == 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 0) &&
- (peerKeyInfo.Secure == 0) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 1\n"));
- }
- else if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.KeyIndex == 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 0) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_3;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 3\n"));
- }
- else if((peerKeyInfo.KeyType == GROUPKEY) &&
- (peerKeyInfo.KeyIndex != 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 1) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_GROUP_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Group Message 1\n"));
- }
-
- // We will assume link is up (assoc suceess and port not secured).
- // All state has to be able to process message from previous state
- switch(pAd->StaCfg.WpaState)
- {
- case SS_START:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- WpaPairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- break;
-
- case SS_WAIT_MSG_3:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- WpaPairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- WpaPairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- }
- break;
-
- case SS_WAIT_GROUP: // When doing group key exchange
- case SS_FINISH: // This happened when update group key
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- WpaPairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- WpaPairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- }
- else if(MsgType == EAPOL_GROUP_MSG_1)
- {
- WpaGroupMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
- break;
-
- default:
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<----- WpaEAPOLKeyAction\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process Pairwise key 4-way handshaking
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaPairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PHEADER_802_11 pHeader;
- UCHAR *mpool, *PTK, *digest;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- PEAPOL_PACKET pMsg1;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg1Action ----->\n"));
-
- // allocate memory pool
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 256);
-
- if (mpool == NULL)
- return;
-
- // PTK Len = 80.
- PTK = (UCHAR *) ROUND_UP(mpool, 4);
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(PTK + 80, 4);
-
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Process message 1 from authenticator
- pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- // 1. Save Replay counter, it will use to verify message 3 and construct message 2
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 2. Save ANonce
- NdisMoveMemory(pAd->StaCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
-
- // Generate random SNonce
- GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce);
-
- // Calc PTK(ANonce, SNonce)
- WpaCountPTK(pAd,
- pAd->StaCfg.PMK,
- pAd->StaCfg.ANonce,
- pAd->CommonCfg.Bssid,
- pAd->StaCfg.SNonce,
- pAd->CurrentAddress,
- PTK,
- LEN_PTK);
-
- // Save key to PTK entry
- NdisMoveMemory(pAd->StaCfg.PTK, PTK, LEN_PTK);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero Message 2 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- //
- // Message 2 as EAPOL-Key(0,1,0,0,0,P,0,SNonce,MIC,RSN IE)
- //
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- // 1. Key descriptor version and appropriate RSN IE
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- // fill in Data Material and its length
- Packet.KeyDesc.KeyData[0] = IE_WPA;
- Packet.KeyDesc.KeyData[1] = pAd->StaCfg.RSNIE_Len;
- Packet.KeyDesc.KeyDataLen[1] = pAd->StaCfg.RSNIE_Len + 2;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[2], pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
-
- // Update packet length after decide Key data payload
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + Packet.KeyDesc.KeyDataLen[1];
-
- // Update Key length
- Packet.KeyDesc.KeyLength[0] = pMsg1->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pMsg1->KeyDesc.KeyLength[1];
- // 2. Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // 3. KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- //Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
-
- // 4. Fill SNonce
- NdisMoveMemory(Packet.KeyDesc.KeyNonce, pAd->StaCfg.SNonce, LEN_KEY_DESC_NONCE);
-
- // 5. Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Send EAPOL(0, 1, 0, 0, 0, P, 0, SNonce, MIC, RSN_IE)
- // Out buffer for transmitting message 2
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- os_free_mem(pAd, mpool);
- return;
- }
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // 6. Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
-
- HMAC_SHA1(pOutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- hmac_md5(PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- //hex_dump("MIC", Mic, LEN_KEY_DESC_MIC);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // 5. Copy frame to Tx ring and send Msg 2 to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
- os_free_mem(pAd, (PUCHAR)mpool);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg1Action <-----\n"));
-}
-
-VOID Wpa2PairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PHEADER_802_11 pHeader;
- UCHAR *mpool, *PTK, *digest;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- PEAPOL_PACKET pMsg1;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
-
- DBGPRINT(RT_DEBUG_TRACE, ("Wpa2PairMsg1Action ----->\n"));
-
- // allocate memory pool
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 256);
-
- if (mpool == NULL)
- return;
-
- // PTK Len = 80.
- PTK = (UCHAR *) ROUND_UP(mpool, 4);
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(PTK + 80, 4);
-
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Process message 1 from authenticator
- pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- // 1. Save Replay counter, it will use to verify message 3 and construct message 2
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 2. Save ANonce
- NdisMoveMemory(pAd->StaCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
-
- // Generate random SNonce
- GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce);
-
- if(pMsg1->KeyDesc.KeyDataLen[1] > 0 )
- {
- // cached PMKID
- }
-
- // Calc PTK(ANonce, SNonce)
- WpaCountPTK(pAd,
- pAd->StaCfg.PMK,
- pAd->StaCfg.ANonce,
- pAd->CommonCfg.Bssid,
- pAd->StaCfg.SNonce,
- pAd->CurrentAddress,
- PTK,
- LEN_PTK);
-
- // Save key to PTK entry
- NdisMoveMemory(pAd->StaCfg.PTK, PTK, LEN_PTK);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message 2 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- //
- // Message 2 as EAPOL-Key(0,1,0,0,0,P,0,SNonce,MIC,RSN IE)
- //
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
-
- // 1. Key descriptor version and appropriate RSN IE
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- // fill in Data Material and its length
- Packet.KeyDesc.KeyData[0] = IE_WPA2;
- Packet.KeyDesc.KeyData[1] = pAd->StaCfg.RSNIE_Len;
- Packet.KeyDesc.KeyDataLen[1] = pAd->StaCfg.RSNIE_Len + 2;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[2], pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
-
- // Update packet length after decide Key data payload
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + Packet.KeyDesc.KeyDataLen[1];
-
- // 2. Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // 3. KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = 0;
- Packet.KeyDesc.KeyLength[1] = pMsg1->KeyDesc.KeyLength[1];
-
- // 4. Fill SNonce
- NdisMoveMemory(Packet.KeyDesc.KeyNonce, pAd->StaCfg.SNonce, LEN_KEY_DESC_NONCE);
-
- // 5. Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Send EAPOL-Key(0,1,0,0,0,P,0,SNonce,MIC,RSN IE)
- // Out buffer for transmitting message 2
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- os_free_mem(pAd, mpool);
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // 6. Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1(pOutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
-
- // Make Transmitting frame
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // 5. Copy frame to Tx ring
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- MlmeFreeMemory(pAd, pOutBuffer);
- os_free_mem(pAd, mpool);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Wpa2PairMsg1Action <-----\n"));
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process Pairwise key 4-way handshaking
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaPairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- PHEADER_802_11 pHeader;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- PEAPOL_PACKET pMsg3;
- UCHAR Mic[16], OldMic[16];
- MAC_TABLE_ENTRY *pEntry = NULL;
- UCHAR skip_offset;
- KEY_INFO peerKeyInfo;
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg3Action ----->\n"));
-
- // Record 802.11 header & the received EAPOL packet Msg3
- pHeader = (PHEADER_802_11) Elem->Msg;
- pMsg3 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pMsg3->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT*)&peerKeyInfo) = cpu2le16(*((USHORT*)&peerKeyInfo));
-
-
- // 1. Verify cipher type match
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer != 2))
- {
- return;
- }
- else if(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
- {
- return;
- }
-
- // Verify RSN IE
- //if (!RTMPEqualMemory(pMsg3->KeyDesc.KeyData, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len))
- if (!CheckRSNIE(pAd, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1], &skip_offset))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in Msg 3 of WPA1 4-way handshake!! \n"));
- hex_dump("The original RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
- hex_dump("The received RSN_IE", pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("RSN_IE VALID in Msg 3 of WPA1 4-way handshake!! \n"));
-
-
- // 2. Check MIC value
- // Save the MIC and replace with zero
- NdisMoveMemory(OldMic, pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- UCHAR digest[80];
-
- HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else // TKIP
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, Mic);
- }
-
- if(!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n"));
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n"));
-
- // 3. Check Replay Counter, it has to be larger than last one. No need to be exact one larger
- if(RTMPCompareMemory(pMsg3->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
- return;
-
- // Update new replay counter
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 4. Double check ANonce
- if(!NdisEqualMemory(pAd->StaCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
- return;
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero Message 4 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
-
- //
- // Message 4 as EAPOL-Key(0,1,0,0,0,P,0,0,MIC,0)
- //
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
-
- // Key descriptor version and appropriate RSN IE
- Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = pMsg3->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pMsg3->KeyDesc.KeyLength[1];
-
- // Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // In Msg3, KeyInfo.secure =0 if Group Key HS to come. 1 if no group key HS
- // Station sends Msg4 KeyInfo.secure should be the same as that in Msg.3
- Packet.KeyDesc.KeyInfo.Secure= peerKeyInfo.Secure;
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Key Replay count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Out buffer for transmitting message 4
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- return;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- UCHAR digest[80];
-
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- // Update PTK
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- // Make transmitting frame
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // Copy frame to Tx ring and Send Message 4 to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg3Action <-----\n"));
-}
-
-VOID Wpa2PairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- PHEADER_802_11 pHeader;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- PEAPOL_PACKET pMsg3;
- UCHAR Mic[16], OldMic[16];
- UCHAR *mpool, *KEYDATA, *digest;
- UCHAR Key[32];
- MAC_TABLE_ENTRY *pEntry = NULL;
- KEY_INFO peerKeyInfo;
-
- // allocate memory
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 1024);
-
- if(mpool == NULL)
- return;
-
- // KEYDATA Len = 512.
- KEYDATA = (UCHAR *) ROUND_UP(mpool, 4);
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(KEYDATA + 512, 4);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Wpa2PairMsg3Action ----->\n"));
-
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Process message 3 frame.
- pMsg3 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pMsg3->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT*)&peerKeyInfo) = cpu2le16(*((USHORT*)&peerKeyInfo));
-
- // 1. Verify cipher type match
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer!= 2))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- else if(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // 2. Check MIC value
- // Save the MIC and replace with zero
- NdisMoveMemory(OldMic, pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, Mic);
- }
-
- if(!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n"));
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n"));
-
- // 3. Check Replay Counter, it has to be larger than last one. No need to be exact one larger
- if(RTMPCompareMemory(pMsg3->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Update new replay counter
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 4. Double check ANonce
- if(!NdisEqualMemory(pAd->StaCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Obtain GTK
- // 5. Decrypt GTK from Key Data
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("EKD = %d\n", peerKeyInfo.EKD_DL));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // Decrypt AES GTK
- AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA, pMsg3->KeyDesc.KeyDataLen[1],pMsg3->KeyDesc.KeyData);
- }
- else // TKIP
- {
- INT i;
- // Decrypt TKIP GTK
- // Construct 32 bytes RC4 Key
- NdisMoveMemory(Key, pMsg3->KeyDesc.KeyIv, 16);
- NdisMoveMemory(&Key[16], &pAd->StaCfg.PTK[16], 16);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
- //discard first 256 bytes
- for(i = 0; i < 256; i++)
- ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
- // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);
- }
-
- if (!ParseKeyData(pAd, KEYDATA, pMsg3->KeyDesc.KeyDataLen[1], 1))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Update GTK to ASIC
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message 4 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
-
- //
- // Message 4 as EAPOL-Key(0,1,0,0,0,P,0,0,MIC,0)
- //
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
-
- // Key descriptor version and appropriate RSN IE
- Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = pMsg3->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pMsg3->KeyDesc.KeyLength[1];
-
- // Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Key Replay count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Out buffer for transmitting message 4
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- // Update PTK
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(&pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(&pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(&pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- // Make Transmitting frame
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // Copy frame to Tx ring and Send Message 4 to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
- os_free_mem(pAd, (PUCHAR)mpool);
-
-
- // send wireless event - for set key done WPA2
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pEntry->Addr, BSS0, 0);
-
- DBGPRINT(RT_DEBUG_ERROR, ("Wpa2PairMsg3Action <-----\n"));
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process Group key 2-way handshaking
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaGroupMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- PEAPOL_PACKET pGroup;
- UCHAR *mpool, *digest, *KEYDATA;
- UCHAR Mic[16], OldMic[16];
- UCHAR GTK[32], Key[32];
- KEY_INFO peerKeyInfo;
-
- // allocate memory
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 1024);
-
- if(mpool == NULL)
- return;
-
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(mpool, 4);
- // KEYDATA Len = 512.
- KEYDATA = (UCHAR *) ROUND_UP(digest + 80, 4);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaGroupMsg1Action ----->\n"));
-
- // Process Group Message 1 frame. skip 802.11 header(24) & LLC_SNAP header(8)
- pGroup = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pGroup->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT*)&peerKeyInfo) = cpu2le16(*((USHORT*)&peerKeyInfo));
-
- // 0. Check cipher type match
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer != 2))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- else if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // 1. Verify Replay counter
- // Check Replay Counter, it has to be larger than last one. No need to be exact one larger
- if(RTMPCompareMemory(pGroup->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Update new replay counter
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 2. Verify MIC is valid
- // Save the MIC and replace with zero
- NdisMoveMemory(OldMic, pGroup->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pGroup->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
- HMAC_SHA1((PUCHAR) pGroup, pGroup->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pGroup, pGroup->Body_Len[1] + 4, Mic);
- }
-
- if(!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in group msg 1 of 2-way handshake!!!!!!!!!! \n"));
- MlmeFreeMemory(pAd, (PUCHAR)mpool);
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in group msg 1 of 2-way handshake!!!!!!!!!! \n"));
-
-
- // 3. Decrypt GTK from Key Data
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // Decrypt AES GTK
- AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA, pGroup->KeyDesc.KeyDataLen[1], pGroup->KeyDesc.KeyData);
- }
- else // TKIP
- {
- INT i;
-
- // Decrypt TKIP GTK
- // Construct 32 bytes RC4 Key
- NdisMoveMemory(Key, pGroup->KeyDesc.KeyIv, 16);
- NdisMoveMemory(&Key[16], &pAd->StaCfg.PTK[16], 16);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
- //discard first 256 bytes
- for(i = 0; i < 256; i++)
- ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
- // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pGroup->KeyDesc.KeyData, pGroup->KeyDesc.KeyDataLen[1]);
- }
-
- // Process decrypted key data material
- // Parse keyData to handle KDE format for WPA2PSK
- if (peerKeyInfo.EKD_DL)
- {
- if (!ParseKeyData(pAd, KEYDATA, pGroup->KeyDesc.KeyDataLen[1], 0))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- }
- else // WPAPSK
- {
- // set key material, TxMic and RxMic for WPAPSK
- NdisMoveMemory(GTK, KEYDATA, 32);
- NdisMoveMemory(pAd->StaCfg.GTK, GTK, 32);
- pAd->StaCfg.DefaultKeyId = peerKeyInfo.KeyIndex;
-
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, GTK, LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, &GTK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, &GTK[24], LEN_TKIP_TXMICK);
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
-
- //hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK);
- }
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
-
- // init header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero Group message 1 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
-
- //
- // Group Message 2 as EAPOL-Key(1,0,0,0,G,0,0,MIC,0)
- //
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
- else
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
-
- // Key descriptor version and appropriate RSN IE
- Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = pGroup->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pGroup->KeyDesc.KeyLength[1];
-
- // Key Index as G-Msg 1
- if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- Packet.KeyDesc.KeyInfo.KeyIndex = peerKeyInfo.KeyIndex;
-
- // Key Type Group key
- Packet.KeyDesc.KeyInfo.KeyType = GROUPKEY;
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Secure bit
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Key Replay count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Out buffer for transmitting group message 2
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- MlmeFreeMemory(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // 5. Copy frame to Tx ring and prepare for encryption
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, FALSE);
-
- // 6 Free allocated memory
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
- os_free_mem(pAd, (PUCHAR)mpool);
-
- // send wireless event - for set key done WPA2
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaGroupMsg1Action <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init WPA MAC header
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr1)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.ToDs = 1;
- if (wep == 1)
- pHdr80211->FC.Wep = 1;
-
- // Addr1: BSSID, Addr2: SA, Addr3: DA
- COPY_MAC_ADDR(pHdr80211->Addr1, pAddr1);
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHdr80211->Addr3, pAd->CommonCfg.Bssid);
- pHdr80211->Sequence = pAd->Sequence;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware encryption before really
- sent out to air.
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to outgoing Ndis frame
- NumberOfFrag Number of fragment required
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN BOOLEAN is4wayFrame)
-
-{
- NDIS_STATUS Status;
- PNDIS_PACKET pPacket;
- UCHAR Index;
-
- do
- {
- // 1. build a NDIS packet and call RTMPSendPacket();
- // be careful about how/when to release this internal allocated NDIS PACKET buffer
- Status = RTMPAllocateNdisPacket(pAd, &pPacket, pHeader802_3, HdrLen, pData, DataLen);
- if (Status != NDIS_STATUS_SUCCESS)
- break;
-
- if (is4wayFrame)
- RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 1);
- else
- RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 0);
-
- // 2. send out the packet
- Status = STASendPacket(pAd, pPacket);
- if(Status == NDIS_STATUS_SUCCESS)
- {
- // Dequeue one frame from TxSwQueue0..3 queue and process it
- // There are three place calling dequeue for TX ring.
- // 1. Here, right after queueing the frame.
- // 2. At the end of TxRingTxDone service routine.
- // 3. Upon NDIS call RTMPSendPackets
- if((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)))
- {
- for(Index = 0; Index < 5; Index ++)
- if(pAd->TxSwQueue[Index].Number > 0)
- RTMPDeQueuePacket(pAd, FALSE, Index, MAX_TX_PROCESS);
- }
- }
- } while(FALSE);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check Sanity RSN IE form AP
-
- Arguments:
-
- Return Value:
-
-
- ========================================================================
-*/
-BOOLEAN CheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- OUT UCHAR *Offset)
-{
- PUCHAR pVIE;
- UCHAR len;
- PEID_STRUCT pEid;
- BOOLEAN result = FALSE;
-
- pVIE = pData;
- len = DataLen;
- *Offset = 0;
-
- while (len > sizeof(RSNIE2))
- {
- pEid = (PEID_STRUCT) pVIE;
- // WPA RSN IE
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) &&
- (NdisEqualMemory(pVIE, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len)) &&
- (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == (pEid->Len + 2)))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> WPA/WPAPSK RSN IE matched in Msg 3, Length(%d) \n", (pEid->Len + 2)));
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- // WPA2 RSN IE
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) &&
- (NdisEqualMemory(pVIE, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len)) &&
- (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == (pEid->Len + 2)))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", (pEid->Len + 2)));
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- else
- {
- break;
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> skip_offset(%d) \n", *Offset));
-
- return result;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Parse KEYDATA field. KEYDATA[] May contain 2 RSN IE and optionally GTK.
- GTK is encaptulated in KDE format at p.83 802.11i D10
-
- Arguments:
-
- Return Value:
-
- Note:
- 802.11i D10
-
- ========================================================================
-*/
-BOOLEAN ParseKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR bPairewise)
-{
- PKDE_ENCAP pKDE = NULL;
- PUCHAR pMyKeyData = pKeyData;
- UCHAR KeyDataLength = KeyDataLen;
- UCHAR GTKLEN;
- UCHAR skip_offset;
-
- // Verify The RSN IE contained in Pairewise-Msg 3 and skip it
- if (bPairewise)
- {
- // Check RSN IE whether it is WPA2/WPA2PSK
- if (!CheckRSNIE(pAd, pKeyData, KeyDataLen, &skip_offset))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ParseKeyData ==> WPA2/WPA2PSK RSN IE mismatched \n"));
- hex_dump("Get KEYDATA :", pKeyData, KeyDataLen);
- return FALSE;
- }
- else
- {
- // skip RSN IE
- pMyKeyData += skip_offset;
- KeyDataLength -= skip_offset;
-
- //DBGPRINT(RT_DEBUG_TRACE, ("ParseKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", skip_offset));
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("ParseKeyData ==> KeyDataLength %d without RSN_IE \n", KeyDataLength));
-
- // Parse EKD format
- if (KeyDataLength >= 8)
- {
- pKDE = (PKDE_ENCAP) pMyKeyData;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: KeyDataLength is too short \n"));
- return FALSE;
- }
-
-
- // Sanity check - shared key index should not be 0
- if (pKDE->GTKEncap.Kid == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index zero \n"));
- return FALSE;
- }
-
- // Sanity check - KED length
- if (KeyDataLength < (pKDE->Len + 2))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
- return FALSE;
- }
-
- // Get GTK length - refer to IEEE 802.11i-2004 p.82
- GTKLEN = pKDE->Len -6;
-
- if (GTKLEN < MIN_LEN_OF_GTK)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
- return FALSE;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("GTK Key with KDE formet got index=%d, len=%d \n", pKDE->GTKEncap.Kid, GTKLEN));
-
- // Update GTK
- // set key material, TxMic and RxMic for WPAPSK
- NdisMoveMemory(pAd->StaCfg.GTK, pKDE->GTKEncap.GTK, 32);
- pAd->StaCfg.DefaultKeyId = pKDE->GTKEncap.Kid;
-
- // Update shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKDE->GTKEncap.GTK, LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, &pKDE->GTKEncap.GTK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, &pKDE->GTKEncap.GTK[24], LEN_TKIP_TXMICK);
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
-
- return TRUE;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Cisco CCKM PRF function
-
- Arguments:
- key Cisco Base Transient Key (BTK)
- key_len The key length of the BTK
- data Ruquest Number(RN) + BSSID
- data_len The length of the data
- output Store for PTK(Pairwise transient keys)
- len The length of the output
- Return Value:
- None
-
- Note:
- 802.1i Annex F.9
-
- ========================================================================
-*/
-VOID CCKMPRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len)
-{
- INT i;
- UCHAR input[1024];
- INT currentindex = 0;
- INT total_len;
-
- NdisMoveMemory(input, data, data_len);
- total_len = data_len;
- input[total_len] = 0;
- total_len++;
- for (i = 0; i < (len + 19) / 20; i++)
- {
- HMAC_SHA1(input, total_len, key, key_len, &output[currentindex]);
- currentindex += 20;
- input[total_len - 1]++;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process MIC error indication and record MIC error timer.
-
- Arguments:
- pAd Pointer to our adapter
- pWpaKey Pointer to the WPA key structure
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReportMicError(
- IN PRTMP_ADAPTER pAd,
- IN PCIPHER_KEY pWpaKey)
-{
- ULONG Now;
- UCHAR unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1:0);
-
- // Record Last MIC error time and count
- Now = jiffies;
- if (pAd->StaCfg.MicErrCnt == 0)
- {
- pAd->StaCfg.MicErrCnt++;
- pAd->StaCfg.LastMicErrorTime = Now;
- NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
- }
- else if (pAd->StaCfg.MicErrCnt == 1)
- {
- if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now)
- {
- // Update Last MIC error time, this did not violate two MIC errors within 60 seconds
- pAd->StaCfg.LastMicErrorTime = Now;
- }
- else
- {
-
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- pAd->StaCfg.LastMicErrorTime = Now;
- // Violate MIC error counts, MIC countermeasures kicks in
- pAd->StaCfg.MicErrCnt++;
- // We shall block all reception
- // We shall clean all Tx ring and disassoicate from AP after next EAPOL frame
- //
- // No necessary to clean all Tx ring, on RTMPHardTransmit will stop sending non-802.1X EAPOL packets
- // if pAd->StaCfg.MicErrCnt greater than 2.
- //
- // RTMPRingCleanUp(pAd, QID_AC_BK);
- // RTMPRingCleanUp(pAd, QID_AC_BE);
- // RTMPRingCleanUp(pAd, QID_AC_VI);
- // RTMPRingCleanUp(pAd, QID_AC_VO);
- // RTMPRingCleanUp(pAd, QID_HCCA);
- }
- }
- else
- {
- // MIC error count >= 2
- // This should not happen
- ;
- }
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_MIC_FAILURE_REPORT_FRAME,
- 1,
- &unicastKey);
-
- if (pAd->StaCfg.MicErrCnt == 2)
- {
- RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
- }
-}
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#define LENGTH_EAP_H 4
-// If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)).
-INT WpaCheckEapCode(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFrame,
- IN USHORT FrameLen,
- IN USHORT OffSet)
-{
-
- PUCHAR pData;
- INT result = 0;
-
- if( FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H )
- return result;
-
- pData = pFrame + OffSet; // skip offset bytes
-
- if(*(pData+1) == EAPPacket) // 802.1x header - Packet Type
- {
- result = *(pData+4); // EAP header - Code
- }
-
- return result;
-}
-
-VOID WpaSendMicFailureToWpaSupplicant(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUnicast)
-{
- union iwreq_data wrqu;
- char custom[IW_CUSTOM_MAX] = {0};
-
- sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
- if (bUnicast)
- sprintf(custom, "%s unicast", custom);
- wrqu.data.length = strlen(custom);
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
-
- return;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-VOID WpaMicFailureReportFrame(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- BOOLEAN bUnicast;
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
-
- bUnicast = (Elem->Msg[0] == 1 ? TRUE:FALSE);
- pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
-
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
-
- // Request field presented
- Packet.KeyDesc.KeyInfo.Request = 1;
-
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Error field presented
- Packet.KeyDesc.KeyInfo.Error = 1;
-
- // Update packet length after decide Key data payload
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE;
-
- // Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
- inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
-
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
- UCHAR digest[20] = {0};
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // opy frame to Tx ring and send MIC failure report frame to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, FALSE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame <-----\n"));
-}
-
-/** from wpa_supplicant
- * inc_byte_array - Increment arbitrary length byte array by one
- * @counter: Pointer to byte array
- * @len: Length of the counter in bytes
- *
- * This function increments the last byte of the counter by one and continues
- * rolling over to more significant bytes if the byte was incremented from
- * 0xff to 0x00.
- */
-void inc_byte_array(UCHAR *counter, int len)
-{
- int pos = len - 1;
- while (pos >= 0) {
- counter[pos]++;
- if (counter[pos] != 0)
- break;
- pos--;
- }
-}
-
-VOID WpaDisassocApAndBlockAssoc(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (PRTMP_ADAPTER)FunctionContext;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
-
- // disassoc from current AP first
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_MIC_FAILURE);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- pAd->StaCfg.bBlockAssoc = TRUE;
-}
-
+#include "../../rt2860/sta/wpa.c"
diff --git a/drivers/staging/rt2870/sta_ioctl.c b/drivers/staging/rt2870/sta_ioctl.c
index 4b432ce4442e..3553a6c898b9 100644
--- a/drivers/staging/rt2870/sta_ioctl.c
+++ b/drivers/staging/rt2870/sta_ioctl.c
@@ -1,7068 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sta_ioctl.c
-
- Abstract:
- IOCTL related subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 01-03-2003 created
- Rory Chen 02-14-2005 modify to support RT61
-*/
-
-#include "rt_config.h"
-
-#ifdef DBG
-extern ULONG RTDebugLevel;
-#endif
-
-#define NR_WEP_KEYS 4
-#define WEP_SMALL_KEY_LEN (40/8)
-#define WEP_LARGE_KEY_LEN (104/8)
-
-#define GROUP_KEY_NO 4
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
-#else
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F)
-#endif
-
-extern UCHAR CipherWpa2Template[];
-extern UCHAR CipherWpaPskTkip[];
-extern UCHAR CipherWpaPskTkipLen;
-
-typedef struct PACKED _RT_VERSION_INFO{
- UCHAR DriverVersionW;
- UCHAR DriverVersionX;
- UCHAR DriverVersionY;
- UCHAR DriverVersionZ;
- UINT DriverBuildYear;
- UINT DriverBuildMonth;
- UINT DriverBuildDay;
-} RT_VERSION_INFO, *PRT_VERSION_INFO;
-
-struct iw_priv_args privtab[] = {
-{ RTPRIV_IOCTL_SET,
- IW_PRIV_TYPE_CHAR | 1024, 0,
- "set"},
-
-{ RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-/* --- sub-ioctls definitions --- */
- { SHOW_CONN_STATUS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
- { SHOW_DRVIER_VERION,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
- { SHOW_BA_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
- { SHOW_DESC_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
- { RAIO_OFF,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
- { RAIO_ON,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
-#ifdef QOS_DLS_SUPPORT
- { SHOW_DLS_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
-#endif // QOS_DLS_SUPPORT //
- { SHOW_CFG_VALUE,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
- { SHOW_ADHOC_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
-
-/* --- sub-ioctls relations --- */
-
-#ifdef DBG
-{ RTPRIV_IOCTL_BBP,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "bbp"},
-{ RTPRIV_IOCTL_MAC,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "mac"},
-{ RTPRIV_IOCTL_E2P,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "e2p"},
-#endif /* DBG */
-
-{ RTPRIV_IOCTL_STATISTICS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "stat"},
-{ RTPRIV_IOCTL_GSITESURVEY,
- 0, IW_PRIV_TYPE_CHAR | 1024,
- "get_site_survey"},
-};
-
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WMM_SUPPORT
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-VOID RTMPIoctlBBP(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-#endif // DBG //
-
-
-NDIS_STATUS RTMPWPANoneAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-INT Set_FragTest_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef DOT11_N_SUPPORT
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CARRIER_DETECTION_SUPPORT //
-
-INT Show_Adhoc_MacTable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PCHAR extra);
-
-static struct {
- CHAR *name;
- INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
- {"DriverVersion", Set_DriverVersion_Proc},
- {"CountryRegion", Set_CountryRegion_Proc},
- {"CountryRegionABand", Set_CountryRegionABand_Proc},
- {"SSID", Set_SSID_Proc},
- {"WirelessMode", Set_WirelessMode_Proc},
- {"TxBurst", Set_TxBurst_Proc},
- {"TxPreamble", Set_TxPreamble_Proc},
- {"TxPower", Set_TxPower_Proc},
- {"Channel", Set_Channel_Proc},
- {"BGProtection", Set_BGProtection_Proc},
- {"RTSThreshold", Set_RTSThreshold_Proc},
- {"FragThreshold", Set_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
- {"HtBw", Set_HtBw_Proc},
- {"HtMcs", Set_HtMcs_Proc},
- {"HtGi", Set_HtGi_Proc},
- {"HtOpMode", Set_HtOpMode_Proc},
- {"HtExtcha", Set_HtExtcha_Proc},
- {"HtMpduDensity", Set_HtMpduDensity_Proc},
- {"HtBaWinSize", Set_HtBaWinSize_Proc},
- {"HtRdg", Set_HtRdg_Proc},
- {"HtAmsdu", Set_HtAmsdu_Proc},
- {"HtAutoBa", Set_HtAutoBa_Proc},
- {"HtBaDecline", Set_BADecline_Proc},
- {"HtProtect", Set_HtProtect_Proc},
- {"HtMimoPs", Set_HtMimoPs_Proc},
-#endif // DOT11_N_SUPPORT //
-
-#ifdef AGGREGATION_SUPPORT
- {"PktAggregate", Set_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
- {"WmmCapable", Set_WmmCapable_Proc},
-#endif
- {"IEEE80211H", Set_IEEE80211H_Proc},
- {"NetworkType", Set_NetworkType_Proc},
- {"AuthMode", Set_AuthMode_Proc},
- {"EncrypType", Set_EncrypType_Proc},
- {"DefaultKeyID", Set_DefaultKeyID_Proc},
- {"Key1", Set_Key1_Proc},
- {"Key2", Set_Key2_Proc},
- {"Key3", Set_Key3_Proc},
- {"Key4", Set_Key4_Proc},
- {"WPAPSK", Set_WPAPSK_Proc},
- {"ResetCounter", Set_ResetStatCounter_Proc},
- {"PSMode", Set_PSMode_Proc},
-#ifdef DBG
- {"Debug", Set_Debug_Proc},
-#endif
-
-#ifdef RALINK_ATE
- {"ATE", Set_ATE_Proc},
- {"ATEDA", Set_ATE_DA_Proc},
- {"ATESA", Set_ATE_SA_Proc},
- {"ATEBSSID", Set_ATE_BSSID_Proc},
- {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
- {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
- {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
- {"ATETXANT", Set_ATE_TX_Antenna_Proc},
- {"ATERXANT", Set_ATE_RX_Antenna_Proc},
- {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
- {"ATETXBW", Set_ATE_TX_BW_Proc},
- {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
- {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
- {"ATETXMCS", Set_ATE_TX_MCS_Proc},
- {"ATETXMODE", Set_ATE_TX_MODE_Proc},
- {"ATETXGI", Set_ATE_TX_GI_Proc},
- {"ATERXFER", Set_ATE_RX_FER_Proc},
- {"ATERRF", Set_ATE_Read_RF_Proc},
- {"ATEWRF1", Set_ATE_Write_RF1_Proc},
- {"ATEWRF2", Set_ATE_Write_RF2_Proc},
- {"ATEWRF3", Set_ATE_Write_RF3_Proc},
- {"ATEWRF4", Set_ATE_Write_RF4_Proc},
- {"ATELDE2P", Set_ATE_Load_E2P_Proc},
- {"ATERE2P", Set_ATE_Read_E2P_Proc},
- {"ATESHOW", Set_ATE_Show_Proc},
- {"ATEHELP", Set_ATE_Help_Proc},
-
-#ifdef RALINK_28xx_QA
- {"TxStop", Set_TxStop_Proc},
- {"RxStop", Set_RxStop_Proc},
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- {"WpaSupport", Set_Wpa_Support},
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
- {"FixedTxMode", Set_FixedTxMode_Proc},
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- {"OpMode", Set_OpMode_Proc},
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-#ifdef DOT11_N_SUPPORT
- {"TGnWifiTest", Set_TGnWifiTest_Proc},
- {"ForceGF", Set_ForceGF_Proc},
-#endif // DOT11_N_SUPPORT //
-#ifdef QOS_DLS_SUPPORT
- {"DlsAddEntry", Set_DlsAddEntry_Proc},
- {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
-#endif // QOS_DLS_SUPPORT //
- {"LongRetry", Set_LongRetryLimit_Proc},
- {"ShortRetry", Set_ShortRetryLimit_Proc},
-#ifdef EXT_BUILD_CHANNEL_LIST
- {"11dClientMode", Set_Ieee80211dClientMode_Proc},
-#endif // EXT_BUILD_CHANNEL_LIST //
-#ifdef CARRIER_DETECTION_SUPPORT
- {"CarrierDetect", Set_CarrierDetect_Proc},
-#endif // CARRIER_DETECTION_SUPPORT //
-
- {NULL,}
-};
-
-
-VOID RTMPAddKey(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_802_11_KEY pKey)
-{
- ULONG KeyIdx;
- MAC_TABLE_ENTRY *pEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- if (pKey->KeyIndex & 0x80000000)
- {
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- NdisZeroMemory(pAd->StaCfg.PMK, 32);
- NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
- goto end;
- }
- // Update PTK
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else
- {
- // Update GTK
- pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else // dynamic WEP from wpa_supplicant
- {
- UCHAR CipherAlg;
- PUCHAR Key;
-
- if(pKey->KeyLength == 32)
- goto end;
-
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
-
- if (KeyIdx < 4)
- {
- // it is a default shared key, for Pairwise key setting
- if (pKey->KeyIndex & 0x80000000)
- {
- pEntry = MacTableLookup(pAd, pKey->BSSID);
-
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
-
- // set key material and key length
- pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // set Cipher type
- if (pKey->KeyLength == 5)
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
- else
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
-
- // Add Pair-wise key to Asic
- AsicAddPairwiseKeyEntry(
- pAd,
- pEntry->Addr,
- (UCHAR)pEntry->Aid,
- &pEntry->PairwiseKey);
-
- // update WCID attribute table and IVEIV table for this entry
- RTMPAddWcidAttributeEntry(
- pAd,
- BSS0,
- KeyIdx, // The value may be not zero
- pEntry->PairwiseKey.CipherAlg,
- pEntry);
-
- }
- }
- else
- {
- // Default key for tx (shared key)
- pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-
- // set key material and key length
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // Set Ciper type
- if (pKey->KeyLength == 5)
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
- else
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- Key = pAd->SharedKey[BSS0][KeyIdx].Key;
-
- // Set Group key material to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
-
- }
- }
- }
-end:
- return;
-}
-
-char * rtstrchr(const char * s, int c)
-{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *) s;
-}
-
-/*
-This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
-*/
-
-int
-rt_ioctl_giwname(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
-// PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-#ifdef RT2870
- strncpy(name, "RT2870 Wireless", IFNAMSIZ);
-#endif // RT2870 //
- return 0;
-}
-
-int rt_ioctl_siwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- int chan = -1;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
-
- if (freq->e > 1)
- return -EINVAL;
-
- if((freq->e == 0) && (freq->m <= 1000))
- chan = freq->m; // Setting by channel number
- else
- MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
-
- if (ChannelSanity(pAdapter, chan) == TRUE)
- {
- pAdapter->CommonCfg.Channel = chan;
- DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
- }
- else
- return -EINVAL;
-
- return 0;
-}
-int rt_ioctl_giwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter = NULL;
- UCHAR ch;
- ULONG m;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- ch = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
-
- MAP_CHANNEL_ID_TO_KHZ(ch, m);
- freq->m = m * 100;
- freq->e = 1;
- return 0;
-}
-
-int rt_ioctl_siwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (*mode)
- {
- case IW_MODE_ADHOC:
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- break;
- case IW_MODE_INFRA:
- Set_NetworkType_Proc(pAdapter, "Infra");
- break;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- case IW_MODE_MONITOR:
- Set_NetworkType_Proc(pAdapter, "Monitor");
- break;
-#endif
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
- return -EINVAL;
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- return 0;
-}
-
-int rt_ioctl_giwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (ADHOC_ON(pAdapter))
- *mode = IW_MODE_ADHOC;
- else if (INFRA_ON(pAdapter))
- *mode = IW_MODE_INFRA;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- else if (MONITOR_ON(pAdapter))
- {
- *mode = IW_MODE_MONITOR;
- }
-#endif
- else
- *mode = IW_MODE_AUTO;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
- return 0;
-}
-
-int rt_ioctl_siwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- return 0;
-}
-
-int rt_ioctl_giwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- return 0;
-}
-
-int rt_ioctl_giwrange(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- struct iw_range *range = (struct iw_range *) extra;
- u16 val;
- int i;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
- data->length = sizeof(struct iw_range);
- memset(range, 0, sizeof(struct iw_range));
-
- range->txpower_capa = IW_TXPOW_DBM;
-
- if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
- {
- range->min_pmp = 1 * 1024;
- range->max_pmp = 65535 * 1024;
- range->min_pmt = 1 * 1024;
- range->max_pmt = 1000 * 1024;
- range->pmp_flags = IW_POWER_PERIOD;
- range->pmt_flags = IW_POWER_TIMEOUT;
- range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
- IW_POWER_UNICAST_R | IW_POWER_ALL_R;
- }
-
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = 14;
-
- range->retry_capa = IW_RETRY_LIMIT;
- range->retry_flags = IW_RETRY_LIMIT;
- range->min_retry = 0;
- range->max_retry = 255;
-
- range->num_channels = pAdapter->ChannelListNum;
-
- val = 0;
- for (i = 1; i <= range->num_channels; i++)
- {
- u32 m;
- range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
- range->freq[val].m = m * 100; /* HZ */
-
- range->freq[val].e = 1;
- val++;
- if (val == IW_MAX_FREQUENCIES)
- break;
- }
- range->num_frequency = val;
-
- range->max_qual.qual = 100; /* what is correct max? This was not
- * documented exactly. At least
- * 69 has been observed. */
- range->max_qual.level = 0; /* dB */
- range->max_qual.noise = 0; /* dB */
-
- /* What would be suitable values for "average/typical" qual? */
- range->avg_qual.qual = 20;
- range->avg_qual.level = -60;
- range->avg_qual.noise = -95;
- range->sensitivity = 3;
-
- range->max_encoding_tokens = NR_WEP_KEYS;
- range->num_encoding_sizes = 2;
- range->encoding_size[0] = 5;
- range->encoding_size[1] = 13;
-
- range->min_rts = 0;
- range->max_rts = 2347;
- range->min_frag = 256;
- range->max_frag = 2346;
-
-#if WIRELESS_EXT > 17
- /* IW_ENC_CAPA_* bit field */
- range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
- IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-#endif
-
- return 0;
-}
-
-int rt_ioctl_siwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- NDIS_802_11_MAC_ADDRESS Bssid;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- memset(Bssid, 0, MAC_ADDR_LEN);
- memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
-
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
-
- return 0;
-}
-
-int rt_ioctl_giwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
- return -ENOTCONN;
- }
-
- return 0;
-}
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a. These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- * drivers for compatibility
- */
-static void set_quality(PRTMP_ADAPTER pAdapter,
- struct iw_quality *iq,
- signed char rssi)
-{
- __u8 ChannelQuality;
-
- // Normalize Rssi
- if (rssi >= -50)
- ChannelQuality = 100;
- else if (rssi >= -80) // between -50 ~ -80dbm
- ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
- else if (rssi >= -90) // between -80 ~ -90dbm
- ChannelQuality = (__u8)((rssi + 90) * 26)/10;
- else
- ChannelQuality = 0;
-
- iq->qual = (__u8)ChannelQuality;
-
- iq->level = (__u8)(rssi);
- iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
- iq->noise += 256 - 143;
- iq->updated = pAdapter->iw_stats.qual.updated;
-}
-
-int rt_ioctl_iwaplist(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- struct sockaddr addr[IW_MAX_AP];
- struct iw_quality qual[IW_MAX_AP];
- int i;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- data->length = 0;
- return 0;
- //return -ENETDOWN;
- }
-
- for (i = 0; i <IW_MAX_AP ; i++)
- {
- if (i >= pAdapter->ScanTab.BssNr)
- break;
- addr[i].sa_family = ARPHRD_ETHER;
- memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
- }
- data->length = i;
- memcpy(extra, &addr, i*sizeof(addr[0]));
- data->flags = 1; /* signal quality present (sort of) */
- memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
-
- return 0;
-}
-
-#ifdef SIOCGIWSCAN
-int rt_ioctl_siwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- ULONG Now;
- int Status = NDIS_STATUS_SUCCESS;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- return -EINVAL;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount++;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- return 0;
- do{
- Now = jiffies;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
- (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- RT28XX_MLME_HANDLER(pAdapter);
- }while(0);
- return 0;
-}
-
-int rt_ioctl_giwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
-
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- int i=0;
- char *current_ev = extra, *previous_ev = extra;
- char *end_buf;
- char *current_val, custom[MAX_CUSTOM_LEN] = {0};
-#ifndef IWEVGENIE
- char idx;
-#endif // IWEVGENIE //
- struct iw_event iwe;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- return -EAGAIN;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount = 0;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if (pAdapter->ScanTab.BssNr == 0)
- {
- data->length = 0;
- return 0;
- }
-
-#if WIRELESS_EXT >= 17
- if (data->length > 0)
- end_buf = extra + data->length;
- else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#endif
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- if (current_ev >= end_buf)
- {
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //MAC address
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //ESSID
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
- iwe.u.data.flags = 1;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Network Type
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWMODE;
- if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
- {
- iwe.u.mode = IW_MODE_ADHOC;
- }
- else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
- {
- iwe.u.mode = IW_MODE_INFRA;
- }
- else
- {
- iwe.u.mode = IW_MODE_AUTO;
- }
- iwe.len = IW_EV_UINT_LEN;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Channel and Frequency
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWFREQ;
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- else
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- iwe.u.freq.e = 0;
- iwe.u.freq.i = 0;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Add quality statistics
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.level = 0;
- iwe.u.qual.noise = 0;
- set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Encyption key
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWENCODE;
- if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
- iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Bit Rate
- //================================
- if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
- {
- UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWRATE;
- current_val = current_ev + IW_EV_LCP_LEN;
- if (tmpRate == 0x82)
- iwe.u.bitrate.value = 1 * 1000000;
- else if (tmpRate == 0x84)
- iwe.u.bitrate.value = 2 * 1000000;
- else if (tmpRate == 0x8B)
- iwe.u.bitrate.value = 5.5 * 1000000;
- else if (tmpRate == 0x96)
- iwe.u.bitrate.value = 11 * 1000000;
- else
- iwe.u.bitrate.value = (tmpRate/2) * 1000000;
-
- iwe.u.bitrate.disabled = 0;
- current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
- current_val, end_buf, &iwe,
- IW_EV_PARAM_LEN);
-
- if((current_val-current_ev)>IW_EV_LCP_LEN)
- current_ev = current_val;
- else
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
-#ifdef IWEVGENIE
- //WPA IE
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#else
- //WPA IE
- //================================
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "wpa_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "rsn_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#endif // IWEVGENIE //
- }
-
- data->length = current_ev - extra;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
- return 0;
-}
-#endif
-
-int rt_ioctl_siwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->flags)
- {
- PCHAR pSsidString = NULL;
-
- // Includes null character.
- if (data->length > (IW_ESSID_MAX_SIZE + 1))
- return -E2BIG;
-
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, essid, data->length);
- if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
- return -EINVAL;
- }
- else
- return -ENOMEM;
- }
- else
- {
- // ANY ssid
- if (Set_SSID_Proc(pAdapter, "") == FALSE)
- return -EINVAL;
- }
- return 0;
-}
-
-int rt_ioctl_giwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- data->flags = 1;
- if (MONITOR_ON(pAdapter))
- {
- data->length = 0;
- return 0;
- }
-
- if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#ifdef RT2870
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // RT2870 //
- else
- {//the ANY ssid was specified
- data->length = 0;
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
- }
-
- return 0;
-
-}
-
-int rt_ioctl_siwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->length > IW_ESSID_MAX_SIZE)
- return -EINVAL;
-
- memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
- memcpy(pAdapter->nickname, nickname, data->length);
-
-
- return 0;
-}
-
-int rt_ioctl_giwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (data->length > strlen(pAdapter->nickname) + 1)
- data->length = strlen(pAdapter->nickname) + 1;
- if (data->length > 0) {
- memcpy(nickname, pAdapter->nickname, data->length-1);
- nickname[data->length-1] = '\0';
- }
- return 0;
-}
-
-int rt_ioctl_siwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (rts->disabled)
- val = MAX_RTS_THRESHOLD;
- else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
- return -EINVAL;
- else if (rts->value == 0)
- val = MAX_RTS_THRESHOLD;
- else
- val = rts->value;
-
- if (val != pAdapter->CommonCfg.RtsThreshold)
- pAdapter->CommonCfg.RtsThreshold = val;
-
- return 0;
-}
-
-int rt_ioctl_giwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- rts->value = pAdapter->CommonCfg.RtsThreshold;
- rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
- rts->fixed = 1;
-
- return 0;
-}
-
-int rt_ioctl_siwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (frag->disabled)
- val = MAX_FRAG_THRESHOLD;
- else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
- val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
- else if (frag->value == 0)
- val = MAX_FRAG_THRESHOLD;
- else
- return -EINVAL;
-
- pAdapter->CommonCfg.FragmentThreshold = val;
- return 0;
-}
-
-int rt_ioctl_giwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- frag->value = pAdapter->CommonCfg.FragmentThreshold;
- frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
- frag->fixed = 1;
-
- return 0;
-}
-
-#define MAX_WEP_KEY_SIZE 13
-#define MIN_WEP_KEY_SIZE 5
-int rt_ioctl_siwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_DISABLED))
- {
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
- else if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- if (erq->flags & IW_ENCODE_RESTRICTED)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
-
- if (erq->length > 0)
- {
- int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
- /* Check the size of the key */
- if (erq->length > MAX_WEP_KEY_SIZE) {
- return -EINVAL;
- }
- /* Check key index */
- if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
- keyIdx, pAdapter->StaCfg.DefaultKeyId));
-
- //Using default key
- keyIdx = pAdapter->StaCfg.DefaultKeyId;
- }
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
-
- if (erq->length == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (erq->length == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- /* Disable the key */
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-
- /* Check if the key is not marked as invalid */
- if(!(erq->flags & IW_ENCODE_NOKEY)) {
- /* Copy the key in the driver */
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
- }
- }
- else
- {
- /* Do we want to just set the transmit key index ? */
- int index = (erq->flags & IW_ENCODE_INDEX) - 1;
- if ((index >= 0) && (index < 4))
- {
- pAdapter->StaCfg.DefaultKeyId = index;
- }
- else
- /* Don't complain if only change the mode */
- if (!(erq->flags & IW_ENCODE_MODE)) {
- return -EINVAL;
- }
- }
-
-done:
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
- return 0;
-}
-
-int
-rt_ioctl_giwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *key)
-{
- int kid;
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- kid = erq->flags & IW_ENCODE_INDEX;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
-
- if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
- {
- erq->length = 0;
- erq->flags = IW_ENCODE_DISABLED;
- }
- else if ((kid > 0) && (kid <=4))
- {
- // copy wep key
- erq->flags = kid ; /* NB: base 1 */
- if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
- erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
- //if ((kid == pAdapter->PortCfg.DefaultKeyId))
- //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
-
- }
- else if (kid == 0)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
- // copy default key ID
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
- erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- }
-
- return 0;
-
-}
-
-static int
-rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
- void *w, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter;
- POS_COOKIE pObj;
- char *this_char = extra;
- char *value;
- int Status=0;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
- pObj = (POS_COOKIE) pAdapter->OS_Cookie;
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (!*this_char)
- return -EINVAL;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value)
- return -EINVAL;
-
- // reject setting nothing besides ANY ssid(ssidLen=0)
- if (!*value && (strcmp(this_char, "SSID") != 0))
- return -EINVAL;
-
- for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
- {
- if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
- {
- if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
- { //FALSE:Set private failed then return Invalid argument
- Status = -EINVAL;
- }
- break; //Exit for loop.
- }
- }
-
- if(PRTMP_PRIVATE_SET_PROC->name == NULL)
- { //Not found argument
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
- }
-
- return Status;
-}
-
-
-static int
-rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- PRTMP_ADAPTER pAd = dev->ml_priv;
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n\n");
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- }
- sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
-
- sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
- sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
-
- sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if (pAd->ate.RxAntennaSel == 0)
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
- else
- {
- sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- }
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
-
- return Status;
-}
-
-#ifdef DOT11_N_SUPPORT
-void getBaInfo(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pOutBuf)
-{
- INT i, j;
- BA_ORI_ENTRY *pOriBAEntry;
- BA_REC_ENTRY *pRecBAEntry;
-
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
- if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
- {
- sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
- pOutBuf,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
-
- sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BARecWcidArray[j] != 0)
- {
- pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
- }
- }
- sprintf(pOutBuf, "%s\n", pOutBuf);
-
- sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BAOriWcidArray[j] != 0)
- {
- pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
- }
- }
- sprintf(pOutBuf, "%s\n\n", pOutBuf);
- }
- if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
- break;
- }
-
- return;
-}
-#endif // DOT11_N_SUPPORT //
-
-static int
-rt_private_show(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
- u32 subcmd = wrq->flags;
-
- if (dev->priv_flags == INT_MAIN)
- pAd = dev->ml_priv;
- else
- {
- pVirtualAd = dev->ml_priv;
- pAd = pVirtualAd->RtmpDev->ml_priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(subcmd)
- {
-
- case SHOW_CONN_STATUS:
- if (MONITOR_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAd->CommonCfg.RegTransmitSetting.field.BW)
- sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
- else
-#endif // DOT11_N_SUPPORT //
- sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
- }
- else
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- if (INFRA_ON(pAd))
- {
- sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
- pAd->CommonCfg.Ssid,
- pAd->CommonCfg.Bssid[0],
- pAd->CommonCfg.Bssid[1],
- pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],
- pAd->CommonCfg.Bssid[4],
- pAd->CommonCfg.Bssid[5]);
- DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
- }
- else if (ADHOC_ON(pAd))
- sprintf(extra, "Connected\n");
- }
- else
- {
- sprintf(extra, "Disconnected\n");
- DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
- }
- }
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case SHOW_DRVIER_VERION:
- sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#ifdef DOT11_N_SUPPORT
- case SHOW_BA_INFO:
- getBaInfo(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#endif // DOT11_N_SUPPORT //
- case SHOW_DESC_INFO:
- {
- Show_DescInfo_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
- case RAIO_OFF:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = FALSE;
- if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == FALSE)
- {
- MlmeRadioOff(pAd);
- // Update extra information
- pAd->ExtraInfo = SW_RADIO_OFF;
- }
- }
- sprintf(extra, "Radio Off\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case RAIO_ON:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = TRUE;
- //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAd);
- // Update extra information
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- }
- sprintf(extra, "Radio On\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case SHOW_DLS_ENTRY_INFO:
- {
- Set_DlsEntryInfo_Display_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
-#endif // QOS_DLS_SUPPORT //
-
- case SHOW_CFG_VALUE:
- {
- Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
- if (Status == 0)
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- }
- break;
- case SHOW_ADHOC_ENTRY_INFO:
- Show_Adhoc_MacTable_Proc(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
- break;
- }
-
- return Status;
-}
-
-#ifdef SIOCSIWMLME
-int rt_ioctl_siwmlme(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
- MLME_QUEUE_ELEM MsgElem;
- MLME_DISASSOC_REQ_STRUCT DisAssocReq;
- MLME_DEAUTH_REQ_STRUCT DeAuthReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
-
- if (pMlme == NULL)
- return -EINVAL;
-
- switch(pMlme->cmd)
- {
-#ifdef IW_MLME_DEAUTH
- case IW_MLME_DEAUTH:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
- COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
- DeAuthReq.Reason = pMlme->reason_code;
- MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
- MlmeDeauthReqAction(pAd, &MsgElem);
- if (INFRA_ON(pAd))
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- break;
-#endif // IW_MLME_DEAUTH //
-#ifdef IW_MLME_DISASSOC
- case IW_MLME_DISASSOC:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
- COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
- DisAssocReq.Reason = pMlme->reason_code;
-
- MsgElem.Machine = ASSOC_STATE_MACHINE;
- MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
- MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
- MlmeDisassocReqAction(pAd, &MsgElem);
- break;
-#endif // IW_MLME_DISASSOC //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
- break;
- }
-
- return 0;
-}
-#endif // SIOCSIWMLME //
-
-#if WIRELESS_EXT > 17
-int rt_ioctl_siwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_WPA_VERSION:
- if (param->value == IW_AUTH_WPA_VERSION_WPA)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- }
- else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_CIPHER_GROUP:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_KEY_MGMT:
- if (param->value == IW_AUTH_KEY_MGMT_802_1X)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- else
- // WEP 1x
- pAdapter->StaCfg.IEEE8021X = TRUE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == 0)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- break;
- case IW_AUTH_PRIVACY_INVOKED:
- /*if (param->value == 0)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }*/
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_DROP_UNENCRYPTED:
- if (param->value != 0)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_80211_AUTH_ALG:
- if (param->value & IW_AUTH_ALG_SHARED_KEY)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- }
- else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- }
- else
- return -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_WPA_ENABLED:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
- break;
- default:
- return -EOPNOTSUPP;
-}
-
- return 0;
-}
-
-int rt_ioctl_giwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_DROP_UNENCRYPTED:
- param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
- param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
- break;
-
- case IW_AUTH_WPA_ENABLED:
- param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
- break;
-
- default:
- return -EOPNOTSUPP;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
- return 0;
-}
-
-void fnSetCipherKey(
- IN PRTMP_ADAPTER pAdapter,
- IN INT keyIdx,
- IN UCHAR CipherAlg,
- IN BOOLEAN bGTK,
- IN struct iw_encode_ext *ext)
-{
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- pAdapter->SharedKey[BSS0][keyIdx].Key,
- pAdapter->SharedKey[BSS0][keyIdx].TxMic,
- pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-
- if (bGTK)
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- NULL);
- else
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- &pAdapter->MacTab.Content[BSSID_WCID]);
-}
-
-int rt_ioctl_siwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
- {
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int keyIdx, alg = ext->alg;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (encoding->flags & IW_ENCODE_DISABLED)
- {
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- // set BSSID wcid entry of the Pair-wise Key table as no-security mode
- AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
- }
- else
- {
- // Get Key Index and convet to our own defined key index
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- return -EINVAL;
-
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- pAdapter->StaCfg.DefaultKeyId = keyIdx;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
- }
-
- switch (alg) {
- case IW_ENCODE_ALG_NONE:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
- break;
- case IW_ENCODE_ALG_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
- if (ext->key_len == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (ext->key_len == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- return -EINVAL;
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
-
- if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
- pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
- {
- // Set Group key material to Asic
- AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
-
- STA_PORT_SECURED(pAdapter);
-
- // Indicate Connected for GUI
- pAdapter->IndicateMediaState = NdisMediaStateConnected;
- }
- break;
- case IW_ENCODE_ALG_TKIP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
- if (ext->key_len == 32)
- {
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else
- return -EINVAL;
- break;
- case IW_ENCODE_ALG_CCMP:
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- break;
- default:
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-int
-rt_ioctl_giwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- PCHAR pKey = NULL;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int idx, max_key_len;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
-
- max_key_len = encoding->length - sizeof(*ext);
- if (max_key_len < 0)
- return -EINVAL;
-
- idx = encoding->flags & IW_ENCODE_INDEX;
- if (idx)
- {
- if (idx < 1 || idx > 4)
- return -EINVAL;
- idx--;
-
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
- {
- if (idx != pAd->StaCfg.DefaultKeyId)
- {
- ext->key_len = 0;
- return 0;
- }
- }
- }
- else
- idx = pAd->StaCfg.DefaultKeyId;
-
- encoding->flags = idx + 1;
- memset(ext, 0, sizeof(*ext));
-
- ext->key_len = 0;
- switch(pAd->StaCfg.WepStatus) {
- case Ndis802_11WEPDisabled:
- ext->alg = IW_ENCODE_ALG_NONE;
- encoding->flags |= IW_ENCODE_DISABLED;
- break;
- case Ndis802_11WEPEnabled:
- ext->alg = IW_ENCODE_ALG_WEP;
- if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
- return -E2BIG;
- else
- {
- ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
- pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
- }
- break;
- case Ndis802_11Encryption2Enabled:
- case Ndis802_11Encryption3Enabled:
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
- ext->alg = IW_ENCODE_ALG_TKIP;
- else
- ext->alg = IW_ENCODE_ALG_CCMP;
-
- if (max_key_len < 32)
- return -E2BIG;
- else
- {
- ext->key_len = 32;
- pKey = &pAd->StaCfg.PMK[0];
- }
- break;
- default:
- return -EINVAL;
- }
-
- if (ext->key_len && pKey)
- {
- encoding->flags |= IW_ENCODE_ENABLED;
- memcpy(ext->key, pKey, ext->key_len);
- }
-
- return 0;
-}
-
-#ifdef SIOCSIWGENIE
-int rt_ioctl_siwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
-
- if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
- (wrqu->data.length && extra == NULL))
- return -EINVAL;
-
- if (wrqu->data.length)
- {
- pAd->StaCfg.RSNIE_Len = wrqu->data.length;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
- }
- else
- {
- pAd->StaCfg.RSNIE_Len = 0;
- NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
- }
-
- return 0;
-}
-#endif // SIOCSIWGENIE //
-
-int rt_ioctl_giwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
-
- if ((pAd->StaCfg.RSNIE_Len == 0) ||
- (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
- {
- wrqu->data.length = 0;
- return 0;
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
- return -E2BIG;
-
- wrqu->data.length = pAd->StaCfg.RSNIE_Len;
- memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
- else
-#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- UCHAR RSNIe = IE_WPA;
-
- if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
- return -E2BIG;
- wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- RSNIe = IE_RSN;
-
- extra[0] = (char)RSNIe;
- extra[1] = pAd->StaCfg.RSNIE_Len;
- memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
-
- return 0;
-}
-
-int rt_ioctl_siwpmksa(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
- INT CachedIdx = 0, idx = 0;
-
- if (pPmksa == NULL)
- return -EINVAL;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
- switch(pPmksa->cmd)
- {
- case IW_PMKSA_FLUSH:
- NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
- break;
- case IW_PMKSA_REMOVE:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- {
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
- for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
- {
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
- }
- pAd->StaCfg.SavedPMKNum--;
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
- break;
- case IW_PMKSA_ADD:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- pAd->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
- break;
- }
-
- return 0;
-}
-#endif // #if WIRELESS_EXT > 17
-
-#ifdef DBG
-static int
-rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
- {
- CHAR *this_char;
- CHAR *value = NULL;
- UCHAR regBBP = 0;
-// CHAR arg[255]={0};
- UINT32 bbpId;
- UINT32 bbpValue;
- BOOLEAN bIsPrintAllBBP = FALSE;
- INT Status = 0;
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- if (wrq->length > 1) //No parameters.
- {
- sprintf(extra, "\n");
-
- //Parsing Read or Write
- this_char = wrq->pointer;
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
- if (sscanf(this_char, "%d", &(bbpId)) == 1)
- {
- if (bbpId <= 136)
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Write
- if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
- {
- if (bbpId <= 136)
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- }
- else
- bIsPrintAllBBP = TRUE;
-
-next:
- if (bIsPrintAllBBP)
- {
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n");
- for (bbpId = 0; bbpId <= 136; bbpId++)
- {
- if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
- break;
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
- if (bbpId%5 == 4)
- sprintf(extra+strlen(extra), "\n");
- }
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
-
- return Status;
-}
-#endif // DBG //
-
-int rt_ioctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
- /* rate = -1 => auto rate
- rate = X, fixed = 1 => (fixed rate X)
- */
- if (rate == -1)
- {
- //Auto Rate
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, -1);
-
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- else
- {
- if (fixed)
- {
- pAd->StaCfg.bAutoTxRateSwitch = FALSE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, rate);
- else
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
- }
- else
- {
- // TODO: rate = X, fixed = 0 => (rates <= X)
- return -EOPNOTSUPP;
- }
- }
-
- return 0;
-}
-
-int rt_ioctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- int rate_index = 0, rate_count = 0;
- HTTRANSMIT_SETTING ht_setting;
- __s32 ralinkrate[] =
- {2, 4, 11, 22, // CCK
- 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
- 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
- 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
- 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
- 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
- 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
- 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
- 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
- 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
-
- rate_count = sizeof(ralinkrate)/sizeof(__s32);
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
- (INFRA_ON(pAd)) &&
- ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
- ht_setting.word = pAd->StaCfg.HTPhyMode.word;
- else
- ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-
-#ifdef DOT11_N_SUPPORT
- if (ht_setting.field.MODE >= MODE_HTMIX)
- {
-// rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
- rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (ht_setting.field.MODE == MODE_OFDM)
- rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
- else if (ht_setting.field.MODE == MODE_CCK)
- rate_index = (UCHAR)(ht_setting.field.MCS);
-
- if (rate_index < 0)
- rate_index = 0;
-
- if (rate_index > rate_count)
- rate_index = rate_count;
-
- wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
- wrqu->bitrate.disabled = 0;
-
- return 0;
-}
-
-static const iw_handler rt_handler[] =
-{
- (iw_handler) NULL, /* SIOCSIWCOMMIT */
- (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
- (iw_handler) NULL, /* SIOCSIWNWID */
- (iw_handler) NULL, /* SIOCGIWNWID */
- (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
- (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
- (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
- (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
- (iw_handler) NULL, /* SIOCSIWSENS */
- (iw_handler) NULL, /* SIOCGIWSENS */
- (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
- (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
- (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
- (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
- (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
- (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
- (iw_handler) NULL, /* SIOCSIWSPY */
- (iw_handler) NULL, /* SIOCGIWSPY */
- (iw_handler) NULL, /* SIOCSIWTHRSPY */
- (iw_handler) NULL, /* SIOCGIWTHRSPY */
- (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
- (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
-#ifdef SIOCSIWMLME
- (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
-#else
- (iw_handler) NULL, /* SIOCSIWMLME */
-#endif // SIOCSIWMLME //
- (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
-#ifdef SIOCGIWSCAN
- (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
- (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
-#else
- (iw_handler) NULL, /* SIOCSIWSCAN */
- (iw_handler) NULL, /* SIOCGIWSCAN */
-#endif /* SIOCGIWSCAN */
- (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
- (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
- (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
- (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
- (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
- (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
- (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
- (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
- (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
- (iw_handler) NULL, /* SIOCSIWTXPOW */
- (iw_handler) NULL, /* SIOCGIWTXPOW */
- (iw_handler) NULL, /* SIOCSIWRETRY */
- (iw_handler) NULL, /* SIOCGIWRETRY */
- (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
- (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
- (iw_handler) NULL, /* SIOCSIWPOWER */
- (iw_handler) NULL, /* SIOCGIWPOWER */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
-#if WIRELESS_EXT > 17
- (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
- (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
- (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
- (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
- (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
- (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
- (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
-#endif
-};
-
-static const iw_handler rt_priv_handlers[] = {
- (iw_handler) NULL, /* + 0x00 */
- (iw_handler) NULL, /* + 0x01 */
-#ifndef CONFIG_AP_SUPPORT
- (iw_handler) rt_ioctl_setparam, /* + 0x02 */
-#else
- (iw_handler) NULL, /* + 0x02 */
-#endif // CONFIG_AP_SUPPORT //
-#ifdef DBG
- (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
-#else
- (iw_handler) NULL, /* + 0x03 */
-#endif
- (iw_handler) NULL, /* + 0x04 */
- (iw_handler) NULL, /* + 0x05 */
- (iw_handler) NULL, /* + 0x06 */
- (iw_handler) NULL, /* + 0x07 */
- (iw_handler) NULL, /* + 0x08 */
- (iw_handler) rt_private_get_statistics, /* + 0x09 */
- (iw_handler) NULL, /* + 0x0A */
- (iw_handler) NULL, /* + 0x0B */
- (iw_handler) NULL, /* + 0x0C */
- (iw_handler) NULL, /* + 0x0D */
- (iw_handler) NULL, /* + 0x0E */
- (iw_handler) NULL, /* + 0x0F */
- (iw_handler) NULL, /* + 0x10 */
- (iw_handler) rt_private_show, /* + 0x11 */
- (iw_handler) NULL, /* + 0x12 */
- (iw_handler) NULL, /* + 0x13 */
- (iw_handler) NULL, /* + 0x15 */
- (iw_handler) NULL, /* + 0x17 */
- (iw_handler) NULL, /* + 0x18 */
-};
-
-const struct iw_handler_def rt28xx_iw_handler_def =
-{
-#define N(a) (sizeof (a) / sizeof (a[0]))
- .standard = (iw_handler *) rt_handler,
- .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
- .private = (iw_handler *) rt_priv_handlers,
- .num_private = N(rt_priv_handlers),
- .private_args = (struct iw_priv_args *) privtab,
- .num_private_args = N(privtab),
-#if IW_HANDLER_VERSION >= 7
- .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif
-};
-
-INT RTMPSetInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_MAC_ADDRESS Bssid;
- RT_802_11_PHY_MODE PhyMode;
- RT_802_11_STA_CONFIG StaConfig;
- NDIS_802_11_RATES aryRates;
- RT_802_11_PREAMBLE Preamble;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- PNDIS_802_11_KEY pKey = NULL;
- PNDIS_802_11_WEP pWepKey =NULL;
- PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
- NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
- NDIS_802_11_NETWORK_TYPE NetType;
- ULONG Now;
- UINT KeyIdx = 0;
- INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
- ULONG PowerTemp;
- BOOLEAN RadioState;
- BOOLEAN StateMachineTouched = FALSE;
-#ifdef DOT11_N_SUPPORT
- OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
- PNDIS_802_11_PMKID pPmkId = NULL;
- BOOLEAN IEEE8021xState = FALSE;
- BOOLEAN IEEE8021x_required_keys = FALSE;
- UCHAR wpa_supplicant_enable = 0;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef SNMP_SUPPORT
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR ctmp;
-#endif // SNMP_SUPPORT //
-
-
-
-#ifdef DOT11_N_SUPPORT
- MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
- switch(cmd & 0x7FFF) {
- case RT_OID_802_11_COUNTRY_REGION:
- if (wrq->u.data.length < sizeof(UCHAR))
- Status = -EINVAL;
- // Only avaliable when EEPROM not programming
- else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
- {
- ULONG Country;
- UCHAR TmpPhy;
-
- Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
- pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
- TmpPhy = pAdapter->CommonCfg.PhyMode;
- pAdapter->CommonCfg.PhyMode = 0xff;
- // Build all corresponding channel information
- RTMPSetPhyMode(pAdapter, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
- pAdapter->CommonCfg.CountryRegion));
- }
- break;
- case OID_802_11_BSSID_LIST_SCAN:
- #ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- Now = jiffies;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- break;
- }
-
- //Benson add 20080527, when radio off, sta don't need to scan
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
- break;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
- break;
- case OID_802_11_SSID:
- if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
- Status = -EINVAL;
- else
- {
- PCHAR pSsidString = NULL;
- Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- if (Ssid.SsidLength > MAX_LEN_OF_SSID)
- Status = -EINVAL;
- else
- {
- if (Ssid.SsidLength == 0)
- {
- Set_SSID_Proc(pAdapter, "");
- }
- else
- {
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
- Set_SSID_Proc(pAdapter, pSsidString);
- kfree(pSsidString);
- }
- else
- Status = -ENOMEM;
- }
- }
- }
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- }
- break;
- case RT_OID_802_11_RADIO:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
- if (pAdapter->StaCfg.bSwRadio != RadioState)
- {
- pAdapter->StaCfg.bSwRadio = RadioState;
- if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
- {
- pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
- if (pAdapter->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- else
- {
- MlmeRadioOff(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = SW_RADIO_OFF;
- }
- }
- }
- }
- break;
- case RT_OID_802_11_PHY_MODE:
- if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PhyMode <= MaxPhyMode)
- {
- RTMPSetPhyMode(pAdapter, PhyMode);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
- }
- break;
- case RT_OID_802_11_STA_CONFIG:
- if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
- pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
- pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
- if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
- (StaConfig.AdhocMode <= MaxPhyMode))
- {
- // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
- // if setting changed, need to reset current TX rate as well as BEACON frame format
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- {
- pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
- RTMPSetPhyMode(pAdapter, PhyMode);
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- MakeIbssBeacon(pAdapter); // re-build BEACON frame
- AsicEnableIbssSync(pAdapter); // copy to on-chip memory
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
- pAdapter->CommonCfg.bEnableTxBurst,
- pAdapter->CommonCfg.UseBGProtection,
- pAdapter->CommonCfg.bUseShortSlotTime));
- }
- break;
- case OID_802_11_DESIRED_RATES:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
- NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
- pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
- pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
- pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
- pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
- // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- }
- break;
- case RT_OID_802_11_PREAMBLE:
- if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
- if (Preamble == Rt802_11PreambleShort)
- {
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
- }
- else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
- {
- // if user wants AUTO, initialize to LONG here, then change according to AP's
- // capability upon association.
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
- }
- break;
- case OID_802_11_WEP_STATUS:
- if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
- // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
- if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
- {
- if (pAdapter->StaCfg.WepStatus != WepStatus)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.WepStatus = WepStatus;
- pAdapter->StaCfg.OrigWepStatus = WepStatus;
- pAdapter->StaCfg.PairCipher = WepStatus;
- pAdapter->StaCfg.GroupCipher = WepStatus;
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
- }
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
- if (AuthMode > Ndis802_11AuthModeMax)
- {
- Status = -EINVAL;
- break;
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode != AuthMode)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.AuthMode = AuthMode;
- }
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
- }
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (BssType == Ndis802_11IBSS)
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- else if (BssType == Ndis802_11Infrastructure)
- Set_NetworkType_Proc(pAdapter, "Infra");
- else if (BssType == Ndis802_11Monitor)
- Set_NetworkType_Proc(pAdapter, "Monitor");
- else
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
- }
- }
- break;
- case OID_802_11_REMOVE_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
- if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
- {
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx >= 4){
- Status = -EINVAL;
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- }
- }
- }
- break;
- case RT_OID_802_11_RESET_COUNTERS:
- NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
- NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
- NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
- pAdapter->Counters8023.RxNoBuffer = 0;
- pAdapter->Counters8023.GoodReceives = 0;
- pAdapter->Counters8023.RxNoBuffer = 0;
-#ifdef RT2870
- pAdapter->BulkOutComplete = 0;
- pAdapter->BulkOutCompleteOther= 0;
- pAdapter->BulkOutCompleteCancel = 0;
- pAdapter->BulkOutReq = 0;
- pAdapter->BulkInReq= 0;
- pAdapter->BulkInComplete = 0;
- pAdapter->BulkInCompleteFail = 0;
-#endif // RT2870 //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
- break;
- case OID_802_11_RTS_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
- if (RtsThresh > MAX_RTS_THRESHOLD)
- Status = -EINVAL;
- else
- pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- {
- if (FragThresh == 0)
- {
- pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
- }
- else
- Status = -EINVAL;
- }
- else
- pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerMode == Ndis802_11PowerModeCAM)
- Set_PSMode_Proc(pAdapter, "CAM");
- else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
- Set_PSMode_Proc(pAdapter, "Max_PSP");
- else if (PowerMode == Ndis802_11PowerModeFast_PSP)
- Set_PSMode_Proc(pAdapter, "Fast_PSP");
- else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
- Set_PSMode_Proc(pAdapter, "Legacy_PSP");
- else
- Status = -EINVAL;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- if (wrq->u.data.length < sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerTemp > 100)
- PowerTemp = 0xffffffff; // AUTO
- pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
- pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- }
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (NetType == Ndis802_11DS)
- RTMPSetPhyMode(pAdapter, PHY_11B);
- else if (NetType == Ndis802_11OFDM24)
- RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
- else if (NetType == Ndis802_11OFDM5)
- RTMPSetPhyMode(pAdapter, PHY_11A);
- else
- Status = -EINVAL;
-#ifdef DOT11_N_SUPPORT
- if (Status == NDIS_STATUS_SUCCESS)
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
- }
- break;
- // For WPA PSK PMK key
- case RT_OID_802_11_ADD_WPA:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
- }
- else
- {
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
- {
- Status = -EOPNOTSUPP;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
- }
- else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
- {
- NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
- // Use RaConfig as PSK agent.
- // Start STA supplicant state machine
- if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- pAdapter->StaCfg.WpaState = SS_START;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- else
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- }
- kfree(pKey);
- break;
- case OID_802_11_REMOVE_KEY:
- pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pRemoveKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pRemoveKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
- }
- else
- {
- KeyIdx = pRemoveKey->KeyIndex;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx > 3)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
- }
- }
- }
- }
- kfree(pRemoveKey);
- break;
- // New for WPA
- case OID_802_11_ADD_KEY:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
- }
- else
- {
- RTMPAddKey(pAdapter, pKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- kfree(pKey);
- break;
- case OID_802_11_CONFIGURATION:
- if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
- pConfig = &Config;
-
- if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
- pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
-
- pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
- MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
- //
- // Save the channel on MlmeAux for CntlOidRTBssidProc used.
- //
- pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
- pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- break;
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_HT_PHYMODE:
- if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
- Status = -EINVAL;
- else
- {
- POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
-
- Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
- pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
- pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- RTMPSetHT(pAdapter, pHTPhyMode);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
- pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
- pAdapter->StaCfg.HTPhyMode.field.STBC));
- break;
-#endif // DOT11_N_SUPPORT //
- case RT_OID_802_11_SET_APSD_SETTING:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- ULONG apsd ;
- Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
-
- /*-------------------------------------------------------------------
- |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
- ---------------------------------------------------------------------
- | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
- ---------------------------------------------------------------------*/
- pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
- pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
- pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
- }
- break;
-
- case RT_OID_802_11_SET_APSD_PSM:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- // Driver needs to notify AP when PSM changes
- Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
- if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
- {
- MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
- RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- }
- break;
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
- Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
- if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
- {
- int i;
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- }
- break;
-
- case RT_OID_802_11_SET_DLS_PARAM:
- if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
- Status = -EINVAL;
- else
- {
- RT_802_11_DLS Dls;
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- case RT_OID_802_11_SET_WMM:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
- }
- break;
-
- case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- //
- // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
- // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
- // when query OID_802_11_BSSID_LIST.
- //
- // TRUE: NumberOfItems will set to 0.
- // FALSE: NumberOfItems no change.
- //
- pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
- // Set to immediately send the media disconnect event
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
-
- if (INFRA_ON(pAdapter))
- {
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_DISASSOCIATE,
- 0,
- NULL);
-
- StateMachineTouched = TRUE;
- }
- break;
-
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_IMME_BA_CAP:
- if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
- Status = -EINVAL;
- else
- {
- OID_BACAP_STRUC Orde ;
- Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
- if (Orde.Policy > BA_NOTUSE)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- }
- else if (Orde.Policy == BA_NOTUSE)
- {
- pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
- }
- else
- {
- pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
- pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-
- if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
-
- }
-
- pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
- }
-
- break;
- case RT_OID_802_11_ADD_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- UCHAR index;
- OID_ADD_BA_ENTRY BA;
- MAC_TABLE_ENTRY *pEntry;
-
- Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
- if (BA.TID > 15)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
- else
- {
- //BATableInsertEntry
- //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
- index = BA.TID;
- // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
- pEntry = MacTableLookup(pAdapter, BA.MACAddr);
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
- break;
- }
- if (BA.IsRecipient == FALSE)
- {
- if (pEntry->bIAmBadAtheros == TRUE)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
-
- BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
- }
- else
- {
- //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
- BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
- , BA.MACAddr[4], BA.MACAddr[5]));
- }
- }
- break;
-
- case RT_OID_802_11_TEAR_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- POID_ADD_BA_ENTRY pBA;
- MAC_TABLE_ENTRY *pEntry;
-
- pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if (pBA == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
- Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
-
- if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
-
- if (pBA->IsRecipient == FALSE)
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
- BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- else
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- if (pEntry)
- {
- BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- kfree(pBA);
- }
- }
- break;
-#endif // DOT11_N_SUPPORT //
-
- // For WPA_SUPPLICANT to set static wep key
- case OID_802_11_ADD_WEP:
- pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pWepKey == NULL)
- {
- Status = -ENOMEM;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
- break;
- }
- Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
- if (Status)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
- }
- else
- {
- KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
- // KeyIdx must be 0 ~ 3
- if (KeyIdx > 4)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
- }
- else
- {
- UCHAR CipherAlg = 0;
- PUCHAR Key;
-
- // set key material and key length
- NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
-
- switch(pWepKey->KeyLength)
- {
- case 5:
- CipherAlg = CIPHER_WEP64;
- break;
- case 13:
- CipherAlg = CIPHER_WEP128;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
- Status = -EINVAL;
- break;
- }
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
-
- // Default key for tx (shared key)
- if (pWepKey->KeyIndex & 0x80000000)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- // set key material and key length
- NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
- pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-#endif // WPA_SUPPLICANT_SUPPORT //
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
- (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- Key = pWepKey->KeyMaterial;
-
- // Set Group key material to Asic
- AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
-
- STA_PORT_SECURED(pAdapter);
-
- // Indicate Connected for GUI
- pAdapter->IndicateMediaState = NdisMediaStateConnected;
- }
- else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
-#endif // WPA_SUPPLICANT_SUPPORT
- {
- Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- if (pWepKey->KeyIndex & 0x80000000)
- {
- PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
- }
- }
- kfree(pWepKey);
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case OID_SET_COUNTERMEASURES:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.bBlockAssoc = TRUE;
- else
- // WPA MIC error should block association attempt for 60 seconds
- pAdapter->StaCfg.bBlockAssoc = FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- }
- break;
- case OID_802_11_DEAUTHENTICATION:
- if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
- Status = -EINVAL;
- else
- {
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
- Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
- MlmeDeauthReqAction(pAdapter, MsgElem);
- kfree(MsgElem);
-
- if (INFRA_ON(pAdapter))
- {
- LinkDown(pAdapter, FALSE);
- pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
- }
- break;
- case OID_802_11_DROP_UNENCRYPTED:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- NdisAcquireSpinLock(&pAdapter->MacTabLock);
- pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAdapter->MacTabLock);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
- }
- break;
- case OID_802_11_SET_IEEE8021X:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
- }
- break;
- case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
- }
- break;
- case OID_802_11_PMKID:
- pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pPmkId == NULL) {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
-
- // check the PMKID information
- if (pPmkId->BSSIDInfoCount == 0)
- NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- else
- {
- PBSSID_INFO pBssIdInfo;
- UINT BssIdx;
- UINT CachedIdx;
-
- for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
- {
- // point to the indexed BSSID_INFO structure
- pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
- // Find the entry in the saved data base.
- for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- pAdapter->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- }
- }
- }
- if(pPmkId)
- kfree(pPmkId);
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
-#ifdef SNMP_SUPPORT
- case OID_802_11_SHORTRETRYLIMIT:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
- }
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
- }
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
- pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- //pKey = &WepKey;
-
- if ( pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
- }
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
- DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
-
- // it is a shared key
- if (KeyIdx > 4)
- Status = -EINVAL;
- else
- {
- pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
- if (pKey->KeyIndex & 0x80000000)
- {
- // Default key for tx (shared key)
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
- //RestartAPIsRequired = TRUE;
- }
- break;
-
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
-
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
-
- break;
-
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
- sprintf(&ctmp,"%d", ctmp);
- Set_Channel_Proc(pAdapter, &ctmp);
- }
- break;
-#endif
-
-
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
-
- return Status;
-}
-
-INT RTMPQueryInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
- PNDIS_WLAN_BSSID_EX pBss;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
- RT_802_11_LINK_STATUS *pLinkStatus = NULL;
- RT_802_11_STA_CONFIG *pStaConfig = NULL;
- NDIS_802_11_STATISTICS *pStatistics = NULL;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- RT_802_11_PREAMBLE PreamType;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_MEDIA_STATE MediaState;
- ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
- USHORT BssLen = 0;
- PUCHAR pBuf = NULL, pPtr;
- INT Status = NDIS_STATUS_SUCCESS;
- UINT we_version_compiled;
- UCHAR i, Padding = 0;
- BOOLEAN RadioState;
- UCHAR driverVersion[8];
- OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
-
-
-#ifdef SNMP_SUPPORT
- //for snmp, kathy
- DefaultKeyIdxValue *pKeyIdxValue;
- INT valueLen;
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR tmp[64];
-#endif //SNMP
-
- switch(cmd)
- {
- case RT_OID_DEVICE_NAME:
- wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
- Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
- break;
- case RT_OID_VERSION_INFO:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
- wrq->u.data.length = 8*sizeof(UCHAR);
- sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
- driverVersion[7] = '\0';
- if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#ifdef RALINK_ATE
- case RT_QUERY_ATE_TXDONE_COUNT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
- wrq->u.data.length = sizeof(UINT32);
- if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#endif // RALINK_ATE //
- case OID_802_11_BSSID_LIST:
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
- return -EAGAIN;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- // Claculate total buffer size required
- BssBufSize = sizeof(ULONG);
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- // Align pointer to 4 bytes boundary.
- //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
- //if (Padding == 4)
- // Padding = 0;
- BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
- }
-
- // For safety issue, we add 256 bytes just in case
- BssBufSize += 256;
- // Allocate the same size as passed from higher layer
- pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
- if(pBuf == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- // Init 802_11_BSSID_LIST_EX structure
- NdisZeroMemory(pBuf, BssBufSize);
- pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
- pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
-
- // Calculate total buffer length
- BssLen = 4; // Consist of NumberOfItems
- // Point to start of NDIS_WLAN_BSSID_EX
- // pPtr = pBuf + sizeof(ULONG);
- pPtr = (PUCHAR) &pBssidList->Bssid[0];
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
- NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
- {
- //
- // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
- // and then failed to send EAPOl farame.
- //
- if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- else
- pBss->Ssid.SsidLength = 0;
- }
- else
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
- pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
- pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
- pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
- pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
- pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
-
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
-
- if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
- pBss->InfrastructureMode = Ndis802_11Infrastructure;
- else
- pBss->InfrastructureMode = Ndis802_11IBSS;
-
- NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
- NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
- pAdapter->ScanTab.BssEntry[i].ExtRate,
- pAdapter->ScanTab.BssEntry[i].ExtRateLen);
-
- if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
- {
- pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- }
- else
- {
- pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
- }
- pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
-
-#if WIRELESS_EXT < 17
- if ((BssLen + pBss->Length) < wrq->u.data.length)
- BssLen += pBss->Length;
- else
- {
- pBssidList->NumberOfItems = i;
- break;
- }
-#else
- BssLen += pBss->Length;
-#endif
- }
-
-#if WIRELESS_EXT < 17
- wrq->u.data.length = BssLen;
-#else
- if (BssLen > wrq->u.data.length)
- {
- kfree(pBssidList);
- return -E2BIG;
- }
- else
- wrq->u.data.length = BssLen;
-#endif
- Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
- kfree(pBssidList);
- break;
- case OID_802_3_CURRENT_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
- case OID_GEN_MEDIA_CONNECT_STATUS:
- if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
- MediaState = NdisMediaStateConnected;
- else
- MediaState = NdisMediaStateDisconnected;
-
- wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
- Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-#endif // RALINK_ATE //
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
- Status = -ENOTCONN;
- }
- break;
- case OID_802_11_SSID:
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
- Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
- memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
- wrq->u.data.length = sizeof(NDIS_802_11_SSID);
- Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
- break;
- case RT_OID_802_11_QUERY_LINK_STATUS:
- pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
- if (pLinkStatus)
- {
- pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
- pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
- pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
- pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
- pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
- wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
- Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
- kfree(pLinkStatus);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_CONFIGURATION:
- pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
- if (pConfiguration)
- {
- pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
- pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
- pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
- wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
- Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
- pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
- kfree(pConfiguration);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_SNR_0:
- if ((pAdapter->StaCfg.LastSNR0 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
- }
- else
- Status = -EFAULT;
- break;
- case RT_OID_802_11_SNR_1:
- if ((pAdapter->Antenna.field.RxPath > 1) &&
- (pAdapter->StaCfg.LastSNR1 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
- }
- else
- Status = -EFAULT;
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
- break;
- case OID_802_11_RSSI_TRIGGER:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
- break;
- case OID_802_11_RSSI:
- case RT_OID_802_11_RSSI:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_1:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_2:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_802_11_STATISTICS:
- pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
- if (pStatistics)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
- // add the most up-to-date h/w raw counters into software counters
- NICUpdateRawCounters(pAdapter);
-
- // Sanity check for calculation of sucessful count
- if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
- pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
-
- pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
- pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
- pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
- pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
- pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
- pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
- pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
- pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
- pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
- pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
- pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
-#ifdef DBG
- pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
-#else
- pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
- pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
-#endif
- wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
- Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
- kfree(pStatistics);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_GEN_RCV_OK:
- ulInfo = pAdapter->Counters8023.GoodReceives;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_GEN_RCV_NO_BUFFER:
- ulInfo = pAdapter->Counters8023.RxNoBuffer;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_PHY_MODE:
- ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_STA_CONFIG:
- pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
- if (pStaConfig)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
- pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
- pStaConfig->EnableTurboRate = 0;
- pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
- pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
- //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
- pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
- pStaConfig->Rsv1 = 0;
- pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
- wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
- Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
- kfree(pStaConfig);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_RTS_THRESHOLD:
- RtsThresh = pAdapter->CommonCfg.RtsThreshold;
- wrq->u.data.length = sizeof(RtsThresh);
- Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- FragThresh = pAdapter->CommonCfg.FragmentThreshold;
- if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
- FragThresh = 0;
- wrq->u.data.length = sizeof(FragThresh);
- Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- PowerMode = pAdapter->StaCfg.WindowsPowerMode;
- wrq->u.data.length = sizeof(PowerMode);
- Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
- break;
- case RT_OID_802_11_RADIO:
- RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
- wrq->u.data.length = sizeof(RadioState);
- Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- BssType = Ndis802_11IBSS;
- else if (pAdapter->StaCfg.BssType == BSS_INFRA)
- BssType = Ndis802_11Infrastructure;
- else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
- BssType = Ndis802_11Monitor;
- else
- BssType = Ndis802_11AutoUnknown;
-
- wrq->u.data.length = sizeof(BssType);
- Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
- break;
- case RT_OID_802_11_PREAMBLE:
- PreamType = pAdapter->CommonCfg.TxPreamble;
- wrq->u.data.length = sizeof(PreamType);
- Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- AuthMode = pAdapter->StaCfg.AuthMode;
- wrq->u.data.length = sizeof(AuthMode);
- Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
- break;
- case OID_802_11_WEP_STATUS:
- WepStatus = pAdapter->StaCfg.WepStatus;
- wrq->u.data.length = sizeof(WepStatus);
- Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
- break;
- case OID_802_11_TX_POWER_LEVEL:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- break;
- case OID_802_11_NETWORK_TYPES_SUPPORTED:
- if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
- {
- NetworkTypeList[0] = 3; // NumberOfItems = 3
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
- wrq->u.data.length = 16;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- else
- {
- NetworkTypeList[0] = 2; // NumberOfItems = 2
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- wrq->u.data.length = 12;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- wrq->u.data.length = sizeof(ULONG);
- if (pAdapter->CommonCfg.PhyMode == PHY_11A)
- ulInfo = Ndis802_11OFDM5;
- else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
- ulInfo = Ndis802_11OFDM24;
- else
- ulInfo = Ndis802_11DS;
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_LAST_RX_RATE:
- ulInfo = (ULONG)pAdapter->LastRxRate;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_LAST_TX_RATE:
- //ulInfo = (ULONG)pAdapter->LastTxRate;
- ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_EEPROM_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_NOISE_LEVEL:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
- break;
- case RT_OID_802_11_EXTRA_INFO:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
- break;
- case RT_OID_WE_VERSION_COMPILED:
- wrq->u.data.length = sizeof(UINT);
- we_version_compiled = WIRELESS_EXT;
- Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_APSD_SETTING:
- apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
- | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
-
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
- apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
- break;
- case RT_OID_802_11_QUERY_APSD_PSM:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- break;
- case RT_OID_802_11_QUERY_WMM:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case RT_OID_NEW_DRIVER:
- {
- UCHAR enabled = 1;
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- case RT_OID_DRIVER_DEVICE_NAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
- wrq->u.data.length = 16;
- if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
-
- pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_COUNTRY_REGION:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
- wrq->u.data.length = sizeof(ulInfo);
- ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
- ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
- if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
-
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- i = 0;
-#ifdef MULTIPLE_CARD_SUPPORT
- i = 1;
-#endif // MULTIPLE_CARD_SUPPORT //
- if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
- break;
-#ifdef SNMP_SUPPORT
- case RT_OID_802_11_MAC_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREROUI:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
- wrq->u.data.length = ManufacturerOUI_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTURERNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_RESOURCETYPEIDNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
- wrq->u.data.length = strlen(ResourceTypeIdName);
- Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
- ulInfo = 1; // 1 is support wep else 2 is not support.
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_POWERMANAGEMENTMODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
- if (pAdapter->StaCfg.Psm == PSMP_ACTION)
- ulInfo = 1; // 1 is power active else 2 is power save.
- else
- ulInfo = 2;
-
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
- //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
- pKeyIdxValue = wrq->u.data.pointer;
- DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
- valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- NdisMoveMemory(pKeyIdxValue->Value,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
- valueLen);
- pKeyIdxValue->Value[valueLen]='\0';
-
- wrq->u.data.length = sizeof(DefaultKeyIdxValue);
-
- Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- pAdapter->SharedKey[BSS0][0].Key[0],
- pAdapter->SharedKey[BSS0][1].Key[0],
- pAdapter->SharedKey[BSS0][2].Key[0],
- pAdapter->SharedKey[BSS0][3].Key[0]));
- break;
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
- break;
-
- case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- wrq->u.data.length);
- break;
-
- case OID_802_11_SHORTRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRODUCTID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
-
-#ifdef RT2870
- sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
-
-#endif // RT2870 //
- wrq->u.data.length = strlen(tmp);
- Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
- wrq->u.data.length = sizeof(UCHAR);
- DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-#endif //SNMP_SUPPORT
-
- case OID_802_11_BUILD_CHANNEL_EX:
- {
- UCHAR value;
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
- wrq->u.data.length = sizeof(UCHAR);
-#ifdef EXT_BUILD_CHANNEL_LIST
- DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 1;
-#else
- DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 0;
-#endif // EXT_BUILD_CHANNEL_LIST //
- Status = copy_to_user(wrq->u.data.pointer, &value, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- }
- break;
-
- case OID_802_11_GET_CH_LIST:
- {
- PRT_CHANNEL_LIST_INFO pChListBuf;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
- if (pAdapter->ChannelListNum == 0)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
- if (pChListBuf == NULL)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
- for (i = 0; i < pChListBuf->ChannelListNum; i++)
- pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
-
- wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-
- if (pChListBuf)
- kfree(pChListBuf);
- }
- break;
-
- case OID_802_11_GET_COUNTRY_CODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
- wrq->u.data.length = 2;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
- case OID_802_11_GET_CHANNEL_GEOGRAPHY:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
- wrq->u.data.length = 1;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_QUERY_DLS:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- break;
-
- case RT_OID_802_11_QUERY_DLS_PARAM:
- {
- PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
- if (pDlsInfo == NULL)
- break;
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
- }
-
- pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
- wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
-
- if (pDlsInfo)
- kfree(pDlsInfo);
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
- return Status;
-}
-
-INT rt28xx_sta_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- POS_COOKIE pObj;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- RTMP_ADAPTER *pAd = NULL;
- struct iwreq *wrq = (struct iwreq *) rq;
- BOOLEAN StateMachineTouched = FALSE;
- INT Status = NDIS_STATUS_SUCCESS;
- USHORT subcmd;
-
- if (net_dev->priv_flags == INT_MAIN)
- {
- pAd = net_dev->ml_priv;
- }
- else
- {
- pVirtualAd = net_dev->ml_priv;
- pAd = pVirtualAd->RtmpDev->ml_priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (wrq->u.data.pointer == NULL)
- {
- return Status;
- }
-
- if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- }
-
- { // determine this ioctl command is comming from which interface.
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(cmd)
- {
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
- case RTPRIV_IOCTL_ATE:
- {
- RtmpDoAte(pAd, wrq);
- }
- break;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
- case SIOCGIFHWADDR:
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
- memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
- break;
- case SIOCGIWNAME:
- {
- char *name=&wrq->u.name[0];
- rt_ioctl_giwname(net_dev, NULL, name, NULL);
- break;
- }
- case SIOCGIWESSID: //Get ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWESSID: //Set ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWNWID: // set network id (the cell)
- case SIOCGIWNWID: // get network id
- Status = -EOPNOTSUPP;
- break;
- case SIOCSIWFREQ: //set channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCGIWFREQ: // get channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCSIWNICKN: //set node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWNICKN: //get node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWRATE: //get default bit rate (bps)
- rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCSIWRATE: //set default bit rate (bps)
- rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCGIWFRAG: //get fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCSIWFRAG: //set fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCGIWENCODE: //get encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCSIWENCODE: //set encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCGIWAP: //get access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCSIWAP: //set access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCGIWMODE: //get operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCSIWMODE: //set operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCGIWSENS: //get sensitivity (dBm)
- case SIOCSIWSENS: //set sensitivity (dBm)
- case SIOCGIWPOWER: //get Power Management settings
- case SIOCSIWPOWER: //set Power Management settings
- case SIOCGIWTXPOW: //get transmit power (dBm)
- case SIOCSIWTXPOW: //set transmit power (dBm)
- case SIOCGIWRANGE: //Get range of parameters
- case SIOCGIWRETRY: //get retry limits and lifetime
- case SIOCSIWRETRY: //set retry limits and lifetime
- Status = -EOPNOTSUPP;
- break;
- case RT_PRIV_IOCTL:
- subcmd = wrq->u.data.flags;
- if( subcmd & OID_GET_SET_TOGGLE)
- Status = RTMPSetInformation(pAd, rq, subcmd);
- else
- Status = RTMPQueryInformation(pAd, rq, subcmd);
- break;
- case SIOCGIWPRIV:
- if (wrq->u.data.pointer)
- {
- if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
- break;
- wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
- if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
- Status = -EFAULT;
- }
- break;
- case RTPRIV_IOCTL_SET:
- if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
- break;
- rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
- break;
- case RTPRIV_IOCTL_GSITESURVEY:
- RTMPIoctlGetSiteSurvey(pAd, wrq);
- break;
-#ifdef DBG
- case RTPRIV_IOCTL_MAC:
- RTMPIoctlMAC(pAd, wrq);
- break;
- case RTPRIV_IOCTL_E2P:
- RTMPIoctlE2PROM(pAd, wrq);
- break;
-#endif // DBG //
- case SIOCETHTOOL:
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
- if(StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAd);
-
- return Status;
-}
-
-/*
- ==========================================================================
- Description:
- Set SSID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- NDIS_802_11_SSID Ssid, *pSsid=NULL;
- BOOLEAN StateMachineTouched = FALSE;
- int success = TRUE;
-
- if( strlen(arg) <= MAX_LEN_OF_SSID)
- {
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- if (strlen(arg) != 0)
- {
- NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
- Ssid.SsidLength = strlen(arg);
- }
- else //ANY ssid
- {
- Ssid.SsidLength = 0;
- memcpy(Ssid.Ssid, "", 0);
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
- }
- pSsid = &Ssid;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- pAdapter->bConfigChanged = TRUE;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_SSID,
- sizeof(NDIS_802_11_SSID),
- (VOID *)pSsid);
-
- StateMachineTouched = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- }
- else
- success = FALSE;
-
- if (StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAdapter);
-
- return success;
-}
-
-#ifdef WMM_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WmmCapable Enable or Disable
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN bWmmCapable;
-
- bWmmCapable = simple_strtol(arg, 0, 10);
-
- if ((bWmmCapable == 1)
-#ifdef RT2870
- && (pAd->NumberOfPipes >= 5)
-#endif // RT2870 //
- )
- pAd->CommonCfg.bWmmCapable = TRUE;
- else if (bWmmCapable == 0)
- pAd->CommonCfg.bWmmCapable = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
- pAd->CommonCfg.bWmmCapable));
-
- return TRUE;
-}
-#endif // WMM_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Set Network Type(Infrastructure/Adhoc mode)
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UINT32 Value = 0;
-
- if (strcmp(arg, "Adhoc") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_ADHOC)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (INFRA_ON(pAdapter))
- {
- //BOOLEAN Cancelled;
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
- }
- }
- pAdapter->StaCfg.BssType = BSS_ADHOC;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
- }
- else if (strcmp(arg, "Infra") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_INFRA)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (ADHOC_ON(pAdapter))
- {
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
- }
- }
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
-
- pAdapter->StaCfg.BssType = BSS_INFRA;
- }
- else if (strcmp(arg, "Monitor") == 0)
- {
- UCHAR bbpValue = 0;
- BCN_TIME_CFG_STRUC csr;
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- // disable all periodic state machine
- pAdapter->StaCfg.bAutoReconnect = FALSE;
- // reset all mlme state machine
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
- if (pAdapter->CommonCfg.CentralChannel == 0)
- {
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
- pAdapter->CommonCfg.CentralChannel = 36;
- else
-#endif // DOT11_N_SUPPORT //
- pAdapter->CommonCfg.CentralChannel = 6;
- }
-#ifdef DOT11_N_SUPPORT
- else
- N_ChannelCheck(pAdapter);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
- {
- // 40MHz ,control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- // RX : control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
-
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value &= 0xfffffffe;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
- {
- // 40MHz ,control channel at upper
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value |= 0x1;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue |= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // 20MHz
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_20;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
- }
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
- // ASIC supporsts sniffer function with replacing RSSI with timestamp.
- //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- //Value |= (0x80);
- //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- // disable sync
- RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
- csr.field.bBeaconGen = 0;
- csr.field.bTBTTEnable = 0;
- csr.field.TsfSyncMode = 0;
- RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-
- pAdapter->StaCfg.BssType = BSS_MONITOR;
- pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Authentication mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
- else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
- else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- return FALSE;
-
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Encryption Type
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- else
- return FALSE;
-
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Default Key ID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- ULONG KeyIdx;
-
- KeyIdx = simple_strtol(arg, 0, 10);
- if((KeyIdx >= 1 ) && (KeyIdx <= 4))
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WEP KEY1
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
-
- pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 0,
- pAdapter->SharedKey[BSS0][0].CipherAlg,
- pAdapter->SharedKey[BSS0][0].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
-
- Description:
- Set WEP KEY2
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 1,
- pAdapter->SharedKey[BSS0][1].CipherAlg,
- pAdapter->SharedKey[BSS0][1].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY3
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 2,
- pAdapter->SharedKey[BSS0][2].CipherAlg,
- pAdapter->SharedKey[BSS0][2].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY4
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 3,
- pAdapter->SharedKey[BSS0][3].CipherAlg,
- pAdapter->SharedKey[BSS0][3].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WPA PSK key
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UCHAR keyMaterial[40];
-
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- )
- return TRUE; // do nothing
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
-
- NdisZeroMemory(keyMaterial, 40);
-
- if ((strlen(arg) < 8) || (strlen(arg) > 64))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
- return FALSE;
- }
-
- if (strlen(arg) == 64)
- {
- AtoH(arg, keyMaterial, 32);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-
- }
- else
- {
- PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
- }
-
-
-
- if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
- pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- }
- else
- {
- // Start STA supplicant state machine
- pAdapter->StaCfg.WpaState = SS_START;
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Power Saving mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (pAdapter->StaCfg.BssType == BSS_INFRA)
- {
- if ((strcmp(arg, "Max_PSP") == 0) ||
- (strcmp(arg, "max_psp") == 0) ||
- (strcmp(arg, "MAX_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- pAdapter->StaCfg.DefaultListenCount = 5;
-
- }
- else if ((strcmp(arg, "Fast_PSP") == 0) ||
- (strcmp(arg, "fast_psp") == 0) ||
- (strcmp(arg, "FAST_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else if ((strcmp(arg, "Legacy_PSP") == 0) ||
- (strcmp(arg, "legacy_psp") == 0) ||
- (strcmp(arg, "LEGACY_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else
- {
- //Default Ndis802_11PowerModeCAM
- // clear PSM bit immediately
- MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
- }
- else
- return FALSE;
-
-
- return TRUE;
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WpaSupport flag.
- Value:
- 0: Driver ignore wpa_supplicant.
- 1: wpa_supplicant initiates scanning and AP selection.
- 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- if ( simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
- else if ( simple_strtol(arg, 0, 10) == 1)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
- else if ( simple_strtol(arg, 0, 10) == 2)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
- else
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
-
- return TRUE;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-/*
- ==========================================================================
- Description:
- Read / Write MAC
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
- 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
- ==========================================================================
-*/
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- ULONG macAddr = 0;
- UCHAR temp[16], temp2[16];
- UINT32 macValue = 0;
- INT Status;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // Mac Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
- if (macAddr < 0xFFFF)
- {
- RTMP_IO_READ32(pAdapter, macAddr, &macValue);
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[8-k+j] = temp2[j];
- }
-
- while(k < 8)
- temp2[7-k++]='0';
- temp2[8]='\0';
-
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 4);
- macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
-
- // debug mode
- if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
- {
- // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
- if (macValue & 0x000000ff)
- {
- pAdapter->BbpTuning.bEnable = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
- }
- else
- {
- UCHAR R66;
- pAdapter->BbpTuning.bEnable = FALSE;
- R66 = 0x26 + GET_LNA_GAIN(pAdapter);
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
- }
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
-
- RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
- }
- }
- }
-next:
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
-}
-
-/*
- ==========================================================================
- Description:
- Read / Write E2PROM
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
- 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
- ==========================================================================
-*/
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- USHORT eepAddr = 0;
- UCHAR temp[16], temp2[16];
- USHORT eepValue;
- int Status;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
-
-
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
-
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // E2PROM addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
- if (eepAddr < 0xFFFF)
- {
- RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[4-k+j] = temp2[j];
- }
-
- while(k < 4)
- temp2[3-k++]='0';
- temp2[4]='\0';
-
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 2);
- eepValue = *temp*256 + temp[1];
-
- RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
- }
- }
-next:
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
-}
-#endif // DBG //
-
-
-
-
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.bTGnWifiTest = FALSE;
- else
- pAd->StaCfg.bTGnWifiTest = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
- return TRUE;
-}
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
- else if (simple_strtol(arg, 0, 10) == 1)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
- else if (simple_strtol(arg, 0, 10) == 2)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
- else
- return FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
- return TRUE;
-}
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
- return TRUE;
-}
-#endif // CARRIER_DETECTION_SUPPORT //
-
-
-INT Show_Adhoc_MacTable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PCHAR extra)
-{
- INT i;
-
- sprintf(extra, "\n");
-
-#ifdef DOT11_N_SUPPORT
- sprintf(extra, "%sHT Operating Mode : %d\n", extra, pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
-#endif // DOT11_N_SUPPORT //
-
- sprintf(extra, "%s\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", extra,
- "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
-
- if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
- break;
- if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- {
- sprintf(extra, "%s%02X:%02X:%02X:%02X:%02X:%02X ", extra,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- sprintf(extra, "%s%-4d", extra, (int)pEntry->Aid);
- sprintf(extra, "%s%-4d", extra, (int)pEntry->apidx);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi0);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi1);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi2);
- sprintf(extra, "%s%-10s", extra, GetPhyMode(pEntry->HTPhyMode.field.MODE));
- sprintf(extra, "%s%-6s", extra, GetBW(pEntry->HTPhyMode.field.BW));
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.MCS);
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.ShortGI);
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.STBC);
- sprintf(extra, "%s%-10d, %d, %d%%\n", extra, pEntry->DebugFIFOCount, pEntry->DebugTxCount,
- (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
- sprintf(extra, "%s\n", extra);
- }
- }
-
- return TRUE;
-}
-
-
+#include "../rt2860/sta_ioctl.c"
diff --git a/drivers/staging/rt2870/sta_ioctl.c.patch b/drivers/staging/rt2870/sta_ioctl.c.patch
deleted file mode 100644
index 8672b147a761..000000000000
--- a/drivers/staging/rt2870/sta_ioctl.c.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- sta_ioctl.c 2008-09-19 14:37:52.000000000 +0800
-+++ sta_ioctl.c.fc9 2008-09-19 14:38:20.000000000 +0800
-@@ -49,15 +49,9 @@
-
- #define GROUP_KEY_NO 4
-
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
- #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
- #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
- #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
--#else
--#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E)
--#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E)
--#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F)
--#endif
-
- extern UCHAR CipherWpa2Template[];
- extern UCHAR CipherWpaPskTkip[];
diff --git a/drivers/staging/rt2870/tmp60 b/drivers/staging/rt2870/tmp60
deleted file mode 100644
index 975e44484379..000000000000
--- a/drivers/staging/rt2870/tmp60
+++ /dev/null
@@ -1,7037 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sta_ioctl.c
-
- Abstract:
- IOCTL related subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 01-03-2003 created
- Rory Chen 02-14-2005 modify to support RT61
-*/
-
-#include "rt_config.h"
-
-#ifdef DBG
-extern ULONG RTDebugLevel;
-#endif
-
-#define NR_WEP_KEYS 4
-#define WEP_SMALL_KEY_LEN (40/8)
-#define WEP_LARGE_KEY_LEN (104/8)
-
-#define GROUP_KEY_NO 4
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
-#else
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F)
-#endif
-
-extern UCHAR CipherWpa2Template[];
-extern UCHAR CipherWpaPskTkip[];
-extern UCHAR CipherWpaPskTkipLen;
-
-typedef struct PACKED _RT_VERSION_INFO{
- UCHAR DriverVersionW;
- UCHAR DriverVersionX;
- UCHAR DriverVersionY;
- UCHAR DriverVersionZ;
- UINT DriverBuildYear;
- UINT DriverBuildMonth;
- UINT DriverBuildDay;
-} RT_VERSION_INFO, *PRT_VERSION_INFO;
-
-struct iw_priv_args privtab[] = {
-{ RTPRIV_IOCTL_SET,
- IW_PRIV_TYPE_CHAR | 1024, 0,
- "set"},
-
-{ RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-/* --- sub-ioctls definitions --- */
- { SHOW_CONN_STATUS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
- { SHOW_DRVIER_VERION,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
- { SHOW_BA_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
- { SHOW_DESC_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
- { RAIO_OFF,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
- { RAIO_ON,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
-#ifdef QOS_DLS_SUPPORT
- { SHOW_DLS_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
-#endif // QOS_DLS_SUPPORT //
- { SHOW_CFG_VALUE,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
- { SHOW_ADHOC_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
-
-/* --- sub-ioctls relations --- */
-
-#ifdef DBG
-{ RTPRIV_IOCTL_BBP,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "bbp"},
-{ RTPRIV_IOCTL_MAC,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "mac"},
-{ RTPRIV_IOCTL_E2P,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "e2p"},
-#endif /* DBG */
-
-{ RTPRIV_IOCTL_STATISTICS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "stat"},
-{ RTPRIV_IOCTL_GSITESURVEY,
- 0, IW_PRIV_TYPE_CHAR | 1024,
- "get_site_survey"},
-};
-
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WMM_SUPPORT
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-VOID RTMPIoctlBBP(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-#endif // DBG //
-
-
-NDIS_STATUS RTMPWPANoneAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-INT Set_FragTest_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef DOT11_N_SUPPORT
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CARRIER_DETECTION_SUPPORT //
-
-INT Show_Adhoc_MacTable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PCHAR extra);
-
-static struct {
- CHAR *name;
- INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
- {"DriverVersion", Set_DriverVersion_Proc},
- {"CountryRegion", Set_CountryRegion_Proc},
- {"CountryRegionABand", Set_CountryRegionABand_Proc},
- {"SSID", Set_SSID_Proc},
- {"WirelessMode", Set_WirelessMode_Proc},
- {"TxBurst", Set_TxBurst_Proc},
- {"TxPreamble", Set_TxPreamble_Proc},
- {"TxPower", Set_TxPower_Proc},
- {"Channel", Set_Channel_Proc},
- {"BGProtection", Set_BGProtection_Proc},
- {"RTSThreshold", Set_RTSThreshold_Proc},
- {"FragThreshold", Set_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
- {"HtBw", Set_HtBw_Proc},
- {"HtMcs", Set_HtMcs_Proc},
- {"HtGi", Set_HtGi_Proc},
- {"HtOpMode", Set_HtOpMode_Proc},
- {"HtExtcha", Set_HtExtcha_Proc},
- {"HtMpduDensity", Set_HtMpduDensity_Proc},
- {"HtBaWinSize", Set_HtBaWinSize_Proc},
- {"HtRdg", Set_HtRdg_Proc},
- {"HtAmsdu", Set_HtAmsdu_Proc},
- {"HtAutoBa", Set_HtAutoBa_Proc},
- {"HtBaDecline", Set_BADecline_Proc},
- {"HtProtect", Set_HtProtect_Proc},
- {"HtMimoPs", Set_HtMimoPs_Proc},
-#endif // DOT11_N_SUPPORT //
-
-#ifdef AGGREGATION_SUPPORT
- {"PktAggregate", Set_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
- {"WmmCapable", Set_WmmCapable_Proc},
-#endif
- {"IEEE80211H", Set_IEEE80211H_Proc},
- {"NetworkType", Set_NetworkType_Proc},
- {"AuthMode", Set_AuthMode_Proc},
- {"EncrypType", Set_EncrypType_Proc},
- {"DefaultKeyID", Set_DefaultKeyID_Proc},
- {"Key1", Set_Key1_Proc},
- {"Key2", Set_Key2_Proc},
- {"Key3", Set_Key3_Proc},
- {"Key4", Set_Key4_Proc},
- {"WPAPSK", Set_WPAPSK_Proc},
- {"ResetCounter", Set_ResetStatCounter_Proc},
- {"PSMode", Set_PSMode_Proc},
-#ifdef DBG
- {"Debug", Set_Debug_Proc},
-#endif
-
-#ifdef RALINK_ATE
- {"ATE", Set_ATE_Proc},
- {"ATEDA", Set_ATE_DA_Proc},
- {"ATESA", Set_ATE_SA_Proc},
- {"ATEBSSID", Set_ATE_BSSID_Proc},
- {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
- {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
- {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
- {"ATETXANT", Set_ATE_TX_Antenna_Proc},
- {"ATERXANT", Set_ATE_RX_Antenna_Proc},
- {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
- {"ATETXBW", Set_ATE_TX_BW_Proc},
- {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
- {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
- {"ATETXMCS", Set_ATE_TX_MCS_Proc},
- {"ATETXMODE", Set_ATE_TX_MODE_Proc},
- {"ATETXGI", Set_ATE_TX_GI_Proc},
- {"ATERXFER", Set_ATE_RX_FER_Proc},
- {"ATERRF", Set_ATE_Read_RF_Proc},
- {"ATEWRF1", Set_ATE_Write_RF1_Proc},
- {"ATEWRF2", Set_ATE_Write_RF2_Proc},
- {"ATEWRF3", Set_ATE_Write_RF3_Proc},
- {"ATEWRF4", Set_ATE_Write_RF4_Proc},
- {"ATELDE2P", Set_ATE_Load_E2P_Proc},
- {"ATERE2P", Set_ATE_Read_E2P_Proc},
- {"ATESHOW", Set_ATE_Show_Proc},
- {"ATEHELP", Set_ATE_Help_Proc},
-
-#ifdef RALINK_28xx_QA
- {"TxStop", Set_TxStop_Proc},
- {"RxStop", Set_RxStop_Proc},
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- {"WpaSupport", Set_Wpa_Support},
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
- {"FixedTxMode", Set_FixedTxMode_Proc},
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- {"OpMode", Set_OpMode_Proc},
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-#ifdef DOT11_N_SUPPORT
- {"TGnWifiTest", Set_TGnWifiTest_Proc},
- {"ForceGF", Set_ForceGF_Proc},
-#endif // DOT11_N_SUPPORT //
-#ifdef QOS_DLS_SUPPORT
- {"DlsAddEntry", Set_DlsAddEntry_Proc},
- {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
-#endif // QOS_DLS_SUPPORT //
- {"LongRetry", Set_LongRetryLimit_Proc},
- {"ShortRetry", Set_ShortRetryLimit_Proc},
-#ifdef EXT_BUILD_CHANNEL_LIST
- {"11dClientMode", Set_Ieee80211dClientMode_Proc},
-#endif // EXT_BUILD_CHANNEL_LIST //
-#ifdef CARRIER_DETECTION_SUPPORT
- {"CarrierDetect", Set_CarrierDetect_Proc},
-#endif // CARRIER_DETECTION_SUPPORT //
-
- {NULL,}
-};
-
-
-VOID RTMPAddKey(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_802_11_KEY pKey)
-{
- ULONG KeyIdx;
- MAC_TABLE_ENTRY *pEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- if (pKey->KeyIndex & 0x80000000)
- {
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- NdisZeroMemory(pAd->StaCfg.PMK, 32);
- NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
- goto end;
- }
- // Update PTK
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else
- {
- // Update GTK
- pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else // dynamic WEP from wpa_supplicant
- {
- UCHAR CipherAlg;
- PUCHAR Key;
-
- if(pKey->KeyLength == 32)
- goto end;
-
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
-
- if (KeyIdx < 4)
- {
- // it is a default shared key, for Pairwise key setting
- if (pKey->KeyIndex & 0x80000000)
- {
- pEntry = MacTableLookup(pAd, pKey->BSSID);
-
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
-
- // set key material and key length
- pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // set Cipher type
- if (pKey->KeyLength == 5)
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
- else
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
-
- // Add Pair-wise key to Asic
- AsicAddPairwiseKeyEntry(
- pAd,
- pEntry->Addr,
- (UCHAR)pEntry->Aid,
- &pEntry->PairwiseKey);
-
- // update WCID attribute table and IVEIV table for this entry
- RTMPAddWcidAttributeEntry(
- pAd,
- BSS0,
- KeyIdx, // The value may be not zero
- pEntry->PairwiseKey.CipherAlg,
- pEntry);
-
- }
- }
- else
- {
- // Default key for tx (shared key)
- pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-
- // set key material and key length
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // Set Ciper type
- if (pKey->KeyLength == 5)
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
- else
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- Key = pAd->SharedKey[BSS0][KeyIdx].Key;
-
- // Set Group key material to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
-
- }
- }
- }
-end:
- return;
-}
-
-char * rtstrchr(const char * s, int c)
-{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *) s;
-}
-
-/*
-This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
-*/
-
-int
-rt_ioctl_giwname(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
-// PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
-#ifdef RT2870
- strncpy(name, "RT2870 Wireless", IFNAMSIZ);
-#endif // RT2870 //
- return 0;
-}
-
-int rt_ioctl_siwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- int chan = -1;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
-
- if (freq->e > 1)
- return -EINVAL;
-
- if((freq->e == 0) && (freq->m <= 1000))
- chan = freq->m; // Setting by channel number
- else
- MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
-
- if (ChannelSanity(pAdapter, chan) == TRUE)
- {
- pAdapter->CommonCfg.Channel = chan;
- DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
- }
- else
- return -EINVAL;
-
- return 0;
-}
-int rt_ioctl_giwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter = NULL;
- UCHAR ch;
- ULONG m;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- ch = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
-
- MAP_CHANNEL_ID_TO_KHZ(ch, m);
- freq->m = m * 100;
- freq->e = 1;
- return 0;
-}
-
-int rt_ioctl_siwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (*mode)
- {
- case IW_MODE_ADHOC:
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- break;
- case IW_MODE_INFRA:
- Set_NetworkType_Proc(pAdapter, "Infra");
- break;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- case IW_MODE_MONITOR:
- Set_NetworkType_Proc(pAdapter, "Monitor");
- break;
-#endif
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
- return -EINVAL;
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- return 0;
-}
-
-int rt_ioctl_giwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (ADHOC_ON(pAdapter))
- *mode = IW_MODE_ADHOC;
- else if (INFRA_ON(pAdapter))
- *mode = IW_MODE_INFRA;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- else if (MONITOR_ON(pAdapter))
- {
- *mode = IW_MODE_MONITOR;
- }
-#endif
- else
- *mode = IW_MODE_AUTO;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
- return 0;
-}
-
-int rt_ioctl_siwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- return 0;
-}
-
-int rt_ioctl_giwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- return 0;
-}
-
-int rt_ioctl_giwrange(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- struct iw_range *range = (struct iw_range *) extra;
- u16 val;
- int i;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
- data->length = sizeof(struct iw_range);
- memset(range, 0, sizeof(struct iw_range));
-
- range->txpower_capa = IW_TXPOW_DBM;
-
- if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
- {
- range->min_pmp = 1 * 1024;
- range->max_pmp = 65535 * 1024;
- range->min_pmt = 1 * 1024;
- range->max_pmt = 1000 * 1024;
- range->pmp_flags = IW_POWER_PERIOD;
- range->pmt_flags = IW_POWER_TIMEOUT;
- range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
- IW_POWER_UNICAST_R | IW_POWER_ALL_R;
- }
-
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = 14;
-
- range->retry_capa = IW_RETRY_LIMIT;
- range->retry_flags = IW_RETRY_LIMIT;
- range->min_retry = 0;
- range->max_retry = 255;
-
- range->num_channels = pAdapter->ChannelListNum;
-
- val = 0;
- for (i = 1; i <= range->num_channels; i++)
- {
- u32 m;
- range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
- range->freq[val].m = m * 100; /* HZ */
-
- range->freq[val].e = 1;
- val++;
- if (val == IW_MAX_FREQUENCIES)
- break;
- }
- range->num_frequency = val;
-
- range->max_qual.qual = 100; /* what is correct max? This was not
- * documented exactly. At least
- * 69 has been observed. */
- range->max_qual.level = 0; /* dB */
- range->max_qual.noise = 0; /* dB */
-
- /* What would be suitable values for "average/typical" qual? */
- range->avg_qual.qual = 20;
- range->avg_qual.level = -60;
- range->avg_qual.noise = -95;
- range->sensitivity = 3;
-
- range->max_encoding_tokens = NR_WEP_KEYS;
- range->num_encoding_sizes = 2;
- range->encoding_size[0] = 5;
- range->encoding_size[1] = 13;
-
- range->min_rts = 0;
- range->max_rts = 2347;
- range->min_frag = 256;
- range->max_frag = 2346;
-
-#if WIRELESS_EXT > 17
- /* IW_ENC_CAPA_* bit field */
- range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
- IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-#endif
-
- return 0;
-}
-
-int rt_ioctl_siwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- NDIS_802_11_MAC_ADDRESS Bssid;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- memset(Bssid, 0, MAC_ADDR_LEN);
- memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
-
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
-
- return 0;
-}
-
-int rt_ioctl_giwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
- return -ENOTCONN;
- }
-
- return 0;
-}
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a. These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- * drivers for compatibility
- */
-static void set_quality(PRTMP_ADAPTER pAdapter,
- struct iw_quality *iq,
- signed char rssi)
-{
- __u8 ChannelQuality;
-
- // Normalize Rssi
- if (rssi >= -50)
- ChannelQuality = 100;
- else if (rssi >= -80) // between -50 ~ -80dbm
- ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
- else if (rssi >= -90) // between -80 ~ -90dbm
- ChannelQuality = (__u8)((rssi + 90) * 26)/10;
- else
- ChannelQuality = 0;
-
- iq->qual = (__u8)ChannelQuality;
-
- iq->level = (__u8)(rssi);
- iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
- iq->noise += 256 - 143;
- iq->updated = pAdapter->iw_stats.qual.updated;
-}
-
-int rt_ioctl_iwaplist(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- struct sockaddr addr[IW_MAX_AP];
- struct iw_quality qual[IW_MAX_AP];
- int i;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- data->length = 0;
- return 0;
- //return -ENETDOWN;
- }
-
- for (i = 0; i <IW_MAX_AP ; i++)
- {
- if (i >= pAdapter->ScanTab.BssNr)
- break;
- addr[i].sa_family = ARPHRD_ETHER;
- memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
- }
- data->length = i;
- memcpy(extra, &addr, i*sizeof(addr[0]));
- data->flags = 1; /* signal quality present (sort of) */
- memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
-
- return 0;
-}
-
-#ifdef SIOCGIWSCAN
-int rt_ioctl_siwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- ULONG Now;
- int Status = NDIS_STATUS_SUCCESS;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- return -EINVAL;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount++;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- return 0;
- do{
- Now = jiffies;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
- (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- RT28XX_MLME_HANDLER(pAdapter);
- }while(0);
- return 0;
-}
-
-int rt_ioctl_giwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
-
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- int i=0;
- char *current_ev = extra, *previous_ev = extra;
- char *end_buf;
- char *current_val, custom[MAX_CUSTOM_LEN] = {0};
-#ifndef IWEVGENIE
- char idx;
-#endif // IWEVGENIE //
- struct iw_event iwe;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- return -EAGAIN;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount = 0;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if (pAdapter->ScanTab.BssNr == 0)
- {
- data->length = 0;
- return 0;
- }
-
-#if WIRELESS_EXT >= 17
- if (data->length > 0)
- end_buf = extra + data->length;
- else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#endif
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- if (current_ev >= end_buf)
- {
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //MAC address
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //ESSID
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
- iwe.u.data.flags = 1;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Network Type
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWMODE;
- if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
- {
- iwe.u.mode = IW_MODE_ADHOC;
- }
- else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
- {
- iwe.u.mode = IW_MODE_INFRA;
- }
- else
- {
- iwe.u.mode = IW_MODE_AUTO;
- }
- iwe.len = IW_EV_UINT_LEN;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Channel and Frequency
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWFREQ;
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- else
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- iwe.u.freq.e = 0;
- iwe.u.freq.i = 0;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Add quality statistics
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.level = 0;
- iwe.u.qual.noise = 0;
- set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Encyption key
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWENCODE;
- if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
- iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Bit Rate
- //================================
- if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
- {
- UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWRATE;
- current_val = current_ev + IW_EV_LCP_LEN;
- if (tmpRate == 0x82)
- iwe.u.bitrate.value = 1 * 1000000;
- else if (tmpRate == 0x84)
- iwe.u.bitrate.value = 2 * 1000000;
- else if (tmpRate == 0x8B)
- iwe.u.bitrate.value = 5.5 * 1000000;
- else if (tmpRate == 0x96)
- iwe.u.bitrate.value = 11 * 1000000;
- else
- iwe.u.bitrate.value = (tmpRate/2) * 1000000;
-
- iwe.u.bitrate.disabled = 0;
- current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
- current_val, end_buf, &iwe,
- IW_EV_PARAM_LEN);
-
- if((current_val-current_ev)>IW_EV_LCP_LEN)
- current_ev = current_val;
- else
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
-#ifdef IWEVGENIE
- //WPA IE
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#else
- //WPA IE
- //================================
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "wpa_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "rsn_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#endif // IWEVGENIE //
- }
-
- data->length = current_ev - extra;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
- return 0;
-}
-#endif
-
-int rt_ioctl_siwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->flags)
- {
- PCHAR pSsidString = NULL;
-
- // Includes null character.
- if (data->length > (IW_ESSID_MAX_SIZE + 1))
- return -E2BIG;
-
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, essid, data->length);
- if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
- return -EINVAL;
- }
- else
- return -ENOMEM;
- }
- else
- {
- // ANY ssid
- if (Set_SSID_Proc(pAdapter, "") == FALSE)
- return -EINVAL;
- }
- return 0;
-}
-
-int rt_ioctl_giwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- data->flags = 1;
- if (MONITOR_ON(pAdapter))
- {
- data->length = 0;
- return 0;
- }
-
- if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#ifdef RT2870
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // RT2870 //
- else
- {//the ANY ssid was specified
- data->length = 0;
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
- }
-
- return 0;
-
-}
-
-int rt_ioctl_siwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->length > IW_ESSID_MAX_SIZE)
- return -EINVAL;
-
- memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
- memcpy(pAdapter->nickname, nickname, data->length);
-
-
- return 0;
-}
-
-int rt_ioctl_giwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (data->length > strlen(pAdapter->nickname) + 1)
- data->length = strlen(pAdapter->nickname) + 1;
- if (data->length > 0) {
- memcpy(nickname, pAdapter->nickname, data->length-1);
- nickname[data->length-1] = '\0';
- }
- return 0;
-}
-
-int rt_ioctl_siwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (rts->disabled)
- val = MAX_RTS_THRESHOLD;
- else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
- return -EINVAL;
- else if (rts->value == 0)
- val = MAX_RTS_THRESHOLD;
- else
- val = rts->value;
-
- if (val != pAdapter->CommonCfg.RtsThreshold)
- pAdapter->CommonCfg.RtsThreshold = val;
-
- return 0;
-}
-
-int rt_ioctl_giwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- rts->value = pAdapter->CommonCfg.RtsThreshold;
- rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
- rts->fixed = 1;
-
- return 0;
-}
-
-int rt_ioctl_siwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (frag->disabled)
- val = MAX_FRAG_THRESHOLD;
- else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
- val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
- else if (frag->value == 0)
- val = MAX_FRAG_THRESHOLD;
- else
- return -EINVAL;
-
- pAdapter->CommonCfg.FragmentThreshold = val;
- return 0;
-}
-
-int rt_ioctl_giwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- frag->value = pAdapter->CommonCfg.FragmentThreshold;
- frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
- frag->fixed = 1;
-
- return 0;
-}
-
-#define MAX_WEP_KEY_SIZE 13
-#define MIN_WEP_KEY_SIZE 5
-int rt_ioctl_siwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_DISABLED))
- {
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
- else if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- if (erq->flags & IW_ENCODE_RESTRICTED)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
-
- if (erq->length > 0)
- {
- int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
- /* Check the size of the key */
- if (erq->length > MAX_WEP_KEY_SIZE) {
- return -EINVAL;
- }
- /* Check key index */
- if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
- keyIdx, pAdapter->StaCfg.DefaultKeyId));
-
- //Using default key
- keyIdx = pAdapter->StaCfg.DefaultKeyId;
- }
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
-
- if (erq->length == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (erq->length == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- /* Disable the key */
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-
- /* Check if the key is not marked as invalid */
- if(!(erq->flags & IW_ENCODE_NOKEY)) {
- /* Copy the key in the driver */
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
- }
- }
- else
- {
- /* Do we want to just set the transmit key index ? */
- int index = (erq->flags & IW_ENCODE_INDEX) - 1;
- if ((index >= 0) && (index < 4))
- {
- pAdapter->StaCfg.DefaultKeyId = index;
- }
- else
- /* Don't complain if only change the mode */
- if(!erq->flags & IW_ENCODE_MODE) {
- return -EINVAL;
- }
- }
-
-done:
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
- return 0;
-}
-
-int
-rt_ioctl_giwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *key)
-{
- int kid;
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- kid = erq->flags & IW_ENCODE_INDEX;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
-
- if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
- {
- erq->length = 0;
- erq->flags = IW_ENCODE_DISABLED;
- }
- else if ((kid > 0) && (kid <=4))
- {
- // copy wep key
- erq->flags = kid ; /* NB: base 1 */
- if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
- erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
- //if ((kid == pAdapter->PortCfg.DefaultKeyId))
- //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
-
- }
- else if (kid == 0)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
- // copy default key ID
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
- erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- }
-
- return 0;
-
-}
-
-static int
-rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
- void *w, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter;
- POS_COOKIE pObj;
- char *this_char = extra;
- char *value;
- int Status=0;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
- pObj = (POS_COOKIE) pAdapter->OS_Cookie;
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (!*this_char)
- return -EINVAL;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value)
- return -EINVAL;
-
- // reject setting nothing besides ANY ssid(ssidLen=0)
- if (!*value && (strcmp(this_char, "SSID") != 0))
- return -EINVAL;
-
- for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
- {
- if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
- {
- if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
- { //FALSE:Set private failed then return Invalid argument
- Status = -EINVAL;
- }
- break; //Exit for loop.
- }
- }
-
- if(PRTMP_PRIVATE_SET_PROC->name == NULL)
- { //Not found argument
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
- }
-
- return Status;
-}
-
-
-static int
-rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n\n");
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- }
- sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
-
- sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
- sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
-
- sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if (pAd->ate.RxAntennaSel == 0)
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
- else
- {
- sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- }
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
-
- return Status;
-}
-
-#ifdef DOT11_N_SUPPORT
-void getBaInfo(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pOutBuf)
-{
- INT i, j;
- BA_ORI_ENTRY *pOriBAEntry;
- BA_REC_ENTRY *pRecBAEntry;
-
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
- if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
- {
- sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
- pOutBuf,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
-
- sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BARecWcidArray[j] != 0)
- {
- pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
- }
- }
- sprintf(pOutBuf, "%s\n", pOutBuf);
-
- sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BAOriWcidArray[j] != 0)
- {
- pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
- }
- }
- sprintf(pOutBuf, "%s\n\n", pOutBuf);
- }
- if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
- break;
- }
-
- return;
-}
-#endif // DOT11_N_SUPPORT //
-
-static int
-rt_private_show(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
- u32 subcmd = wrq->flags;
-
- if (dev->priv_flags == INT_MAIN)
- pAd = dev->priv;
- else
- {
- pVirtualAd = dev->priv;
- pAd = pVirtualAd->RtmpDev->priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(subcmd)
- {
-
- case SHOW_CONN_STATUS:
- if (MONITOR_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAd->CommonCfg.RegTransmitSetting.field.BW)
- sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
- else
-#endif // DOT11_N_SUPPORT //
- sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
- }
- else
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- if (INFRA_ON(pAd))
- {
- sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
- pAd->CommonCfg.Ssid,
- pAd->CommonCfg.Bssid[0],
- pAd->CommonCfg.Bssid[1],
- pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],
- pAd->CommonCfg.Bssid[4],
- pAd->CommonCfg.Bssid[5]);
- DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
- }
- else if (ADHOC_ON(pAd))
- sprintf(extra, "Connected\n");
- }
- else
- {
- sprintf(extra, "Disconnected\n");
- DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
- }
- }
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case SHOW_DRVIER_VERION:
- sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#ifdef DOT11_N_SUPPORT
- case SHOW_BA_INFO:
- getBaInfo(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#endif // DOT11_N_SUPPORT //
- case SHOW_DESC_INFO:
- {
- Show_DescInfo_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
- case RAIO_OFF:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = FALSE;
- if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == FALSE)
- {
- MlmeRadioOff(pAd);
- // Update extra information
- pAd->ExtraInfo = SW_RADIO_OFF;
- }
- }
- sprintf(extra, "Radio Off\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case RAIO_ON:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = TRUE;
- //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAd);
- // Update extra information
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- }
- sprintf(extra, "Radio On\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case SHOW_DLS_ENTRY_INFO:
- {
- Set_DlsEntryInfo_Display_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
-#endif // QOS_DLS_SUPPORT //
-
- case SHOW_CFG_VALUE:
- {
- Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
- if (Status == 0)
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- }
- break;
- case SHOW_ADHOC_ENTRY_INFO:
- Show_Adhoc_MacTable_Proc(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
- break;
- }
-
- return Status;
-}
-
-#ifdef SIOCSIWMLME
-int rt_ioctl_siwmlme(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
- MLME_QUEUE_ELEM MsgElem;
- MLME_DISASSOC_REQ_STRUCT DisAssocReq;
- MLME_DEAUTH_REQ_STRUCT DeAuthReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
-
- if (pMlme == NULL)
- return -EINVAL;
-
- switch(pMlme->cmd)
- {
-#ifdef IW_MLME_DEAUTH
- case IW_MLME_DEAUTH:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
- COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
- DeAuthReq.Reason = pMlme->reason_code;
- MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
- MlmeDeauthReqAction(pAd, &MsgElem);
- if (INFRA_ON(pAd))
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- break;
-#endif // IW_MLME_DEAUTH //
-#ifdef IW_MLME_DISASSOC
- case IW_MLME_DISASSOC:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
- COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
- DisAssocReq.Reason = pMlme->reason_code;
-
- MsgElem.Machine = ASSOC_STATE_MACHINE;
- MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
- MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
- MlmeDisassocReqAction(pAd, &MsgElem);
- break;
-#endif // IW_MLME_DISASSOC //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
- break;
- }
-
- return 0;
-}
-#endif // SIOCSIWMLME //
-
-#if WIRELESS_EXT > 17
-int rt_ioctl_siwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_WPA_VERSION:
- if (param->value == IW_AUTH_WPA_VERSION_WPA)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- }
- else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_CIPHER_GROUP:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_KEY_MGMT:
- if (param->value == IW_AUTH_KEY_MGMT_802_1X)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- else
- // WEP 1x
- pAdapter->StaCfg.IEEE8021X = TRUE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == 0)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- break;
- case IW_AUTH_PRIVACY_INVOKED:
- /*if (param->value == 0)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }*/
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_DROP_UNENCRYPTED:
- if (param->value != 0)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_80211_AUTH_ALG:
- if (param->value & IW_AUTH_ALG_SHARED_KEY)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- }
- else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- }
- else
- return -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_WPA_ENABLED:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
- break;
- default:
- return -EOPNOTSUPP;
-}
-
- return 0;
-}
-
-int rt_ioctl_giwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_DROP_UNENCRYPTED:
- param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
- param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
- break;
-
- case IW_AUTH_WPA_ENABLED:
- param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
- break;
-
- default:
- return -EOPNOTSUPP;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
- return 0;
-}
-
-void fnSetCipherKey(
- IN PRTMP_ADAPTER pAdapter,
- IN INT keyIdx,
- IN UCHAR CipherAlg,
- IN BOOLEAN bGTK,
- IN struct iw_encode_ext *ext)
-{
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- pAdapter->SharedKey[BSS0][keyIdx].Key,
- pAdapter->SharedKey[BSS0][keyIdx].TxMic,
- pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-
- if (bGTK)
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- NULL);
- else
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- &pAdapter->MacTab.Content[BSSID_WCID]);
-}
-
-int rt_ioctl_siwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
- {
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int keyIdx, alg = ext->alg;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (encoding->flags & IW_ENCODE_DISABLED)
- {
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- // set BSSID wcid entry of the Pair-wise Key table as no-security mode
- AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
- }
- else
- {
- // Get Key Index and convet to our own defined key index
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- return -EINVAL;
-
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- pAdapter->StaCfg.DefaultKeyId = keyIdx;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
- }
-
- switch (alg) {
- case IW_ENCODE_ALG_NONE:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
- break;
- case IW_ENCODE_ALG_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
- if (ext->key_len == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (ext->key_len == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- return -EINVAL;
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
- break;
- case IW_ENCODE_ALG_TKIP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
- if (ext->key_len == 32)
- {
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else
- return -EINVAL;
- break;
- case IW_ENCODE_ALG_CCMP:
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- break;
- default:
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-int
-rt_ioctl_giwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- PCHAR pKey = NULL;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int idx, max_key_len;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
-
- max_key_len = encoding->length - sizeof(*ext);
- if (max_key_len < 0)
- return -EINVAL;
-
- idx = encoding->flags & IW_ENCODE_INDEX;
- if (idx)
- {
- if (idx < 1 || idx > 4)
- return -EINVAL;
- idx--;
-
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
- {
- if (idx != pAd->StaCfg.DefaultKeyId)
- {
- ext->key_len = 0;
- return 0;
- }
- }
- }
- else
- idx = pAd->StaCfg.DefaultKeyId;
-
- encoding->flags = idx + 1;
- memset(ext, 0, sizeof(*ext));
-
- ext->key_len = 0;
- switch(pAd->StaCfg.WepStatus) {
- case Ndis802_11WEPDisabled:
- ext->alg = IW_ENCODE_ALG_NONE;
- encoding->flags |= IW_ENCODE_DISABLED;
- break;
- case Ndis802_11WEPEnabled:
- ext->alg = IW_ENCODE_ALG_WEP;
- if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
- return -E2BIG;
- else
- {
- ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
- pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
- }
- break;
- case Ndis802_11Encryption2Enabled:
- case Ndis802_11Encryption3Enabled:
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
- ext->alg = IW_ENCODE_ALG_TKIP;
- else
- ext->alg = IW_ENCODE_ALG_CCMP;
-
- if (max_key_len < 32)
- return -E2BIG;
- else
- {
- ext->key_len = 32;
- pKey = &pAd->StaCfg.PMK[0];
- }
- break;
- default:
- return -EINVAL;
- }
-
- if (ext->key_len && pKey)
- {
- encoding->flags |= IW_ENCODE_ENABLED;
- memcpy(ext->key, pKey, ext->key_len);
- }
-
- return 0;
-}
-
-#ifdef SIOCSIWGENIE
-int rt_ioctl_siwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
-
- if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
- (wrqu->data.length && extra == NULL))
- return -EINVAL;
-
- if (wrqu->data.length)
- {
- pAd->StaCfg.RSNIE_Len = wrqu->data.length;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
- }
- else
- {
- pAd->StaCfg.RSNIE_Len = 0;
- NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
- }
-
- return 0;
-}
-#endif // SIOCSIWGENIE //
-
-int rt_ioctl_giwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
-
- if ((pAd->StaCfg.RSNIE_Len == 0) ||
- (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
- {
- wrqu->data.length = 0;
- return 0;
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
- return -E2BIG;
-
- wrqu->data.length = pAd->StaCfg.RSNIE_Len;
- memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
- else
-#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- UCHAR RSNIe = IE_WPA;
-
- if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
- return -E2BIG;
- wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- RSNIe = IE_RSN;
-
- extra[0] = (char)RSNIe;
- extra[1] = pAd->StaCfg.RSNIE_Len;
- memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
-
- return 0;
-}
-
-int rt_ioctl_siwpmksa(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
- INT CachedIdx = 0, idx = 0;
-
- if (pPmksa == NULL)
- return -EINVAL;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
- switch(pPmksa->cmd)
- {
- case IW_PMKSA_FLUSH:
- NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
- break;
- case IW_PMKSA_REMOVE:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- {
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
- for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
- {
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
- }
- pAd->StaCfg.SavedPMKNum--;
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
- break;
- case IW_PMKSA_ADD:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- pAd->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
- break;
- }
-
- return 0;
-}
-#endif // #if WIRELESS_EXT > 17
-
-#ifdef DBG
-static int
-rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
- {
- CHAR *this_char;
- CHAR *value = NULL;
- UCHAR regBBP = 0;
-// CHAR arg[255]={0};
- UINT32 bbpId;
- UINT32 bbpValue;
- BOOLEAN bIsPrintAllBBP = FALSE;
- INT Status = 0;
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- if (wrq->length > 1) //No parameters.
- {
- sprintf(extra, "\n");
-
- //Parsing Read or Write
- this_char = wrq->pointer;
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
- if (sscanf(this_char, "%d", &(bbpId)) == 1)
- {
- if (bbpId <= 136)
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Write
- if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
- {
- if (bbpId <= 136)
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- }
- else
- bIsPrintAllBBP = TRUE;
-
-next:
- if (bIsPrintAllBBP)
- {
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n");
- for (bbpId = 0; bbpId <= 136; bbpId++)
- {
- if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
- break;
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
- if (bbpId%5 == 4)
- sprintf(extra+strlen(extra), "\n");
- }
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
-
- return Status;
-}
-#endif // DBG //
-
-int rt_ioctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
- /* rate = -1 => auto rate
- rate = X, fixed = 1 => (fixed rate X)
- */
- if (rate == -1)
- {
- //Auto Rate
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, -1);
-
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- else
- {
- if (fixed)
- {
- pAd->StaCfg.bAutoTxRateSwitch = FALSE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, rate);
- else
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
- }
- else
- {
- // TODO: rate = X, fixed = 0 => (rates <= X)
- return -EOPNOTSUPP;
- }
- }
-
- return 0;
-}
-
-int rt_ioctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- int rate_index = 0, rate_count = 0;
- HTTRANSMIT_SETTING ht_setting;
- __s32 ralinkrate[] =
- {2, 4, 11, 22, // CCK
- 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
- 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
- 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
- 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
- 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
- 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
- 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
- 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
- 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
-
- rate_count = sizeof(ralinkrate)/sizeof(__s32);
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
- (INFRA_ON(pAd)) &&
- ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
- ht_setting.word = pAd->StaCfg.HTPhyMode.word;
- else
- ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-
-#ifdef DOT11_N_SUPPORT
- if (ht_setting.field.MODE >= MODE_HTMIX)
- {
-// rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
- rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (ht_setting.field.MODE == MODE_OFDM)
- rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
- else if (ht_setting.field.MODE == MODE_CCK)
- rate_index = (UCHAR)(ht_setting.field.MCS);
-
- if (rate_index < 0)
- rate_index = 0;
-
- if (rate_index > rate_count)
- rate_index = rate_count;
-
- wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
- wrqu->bitrate.disabled = 0;
-
- return 0;
-}
-
-static const iw_handler rt_handler[] =
-{
- (iw_handler) NULL, /* SIOCSIWCOMMIT */
- (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
- (iw_handler) NULL, /* SIOCSIWNWID */
- (iw_handler) NULL, /* SIOCGIWNWID */
- (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
- (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
- (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
- (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
- (iw_handler) NULL, /* SIOCSIWSENS */
- (iw_handler) NULL, /* SIOCGIWSENS */
- (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
- (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
- (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
- (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
- (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
- (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
- (iw_handler) NULL, /* SIOCSIWSPY */
- (iw_handler) NULL, /* SIOCGIWSPY */
- (iw_handler) NULL, /* SIOCSIWTHRSPY */
- (iw_handler) NULL, /* SIOCGIWTHRSPY */
- (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
- (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
-#ifdef SIOCSIWMLME
- (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
-#else
- (iw_handler) NULL, /* SIOCSIWMLME */
-#endif // SIOCSIWMLME //
- (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
-#ifdef SIOCGIWSCAN
- (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
- (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
-#else
- (iw_handler) NULL, /* SIOCSIWSCAN */
- (iw_handler) NULL, /* SIOCGIWSCAN */
-#endif /* SIOCGIWSCAN */
- (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
- (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
- (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
- (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
- (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
- (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
- (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
- (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
- (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
- (iw_handler) NULL, /* SIOCSIWTXPOW */
- (iw_handler) NULL, /* SIOCGIWTXPOW */
- (iw_handler) NULL, /* SIOCSIWRETRY */
- (iw_handler) NULL, /* SIOCGIWRETRY */
- (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
- (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
- (iw_handler) NULL, /* SIOCSIWPOWER */
- (iw_handler) NULL, /* SIOCGIWPOWER */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
-#if WIRELESS_EXT > 17
- (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
- (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
- (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
- (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
- (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
- (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
- (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
-#endif
-};
-
-static const iw_handler rt_priv_handlers[] = {
- (iw_handler) NULL, /* + 0x00 */
- (iw_handler) NULL, /* + 0x01 */
-#ifndef CONFIG_AP_SUPPORT
- (iw_handler) rt_ioctl_setparam, /* + 0x02 */
-#else
- (iw_handler) NULL, /* + 0x02 */
-#endif // CONFIG_AP_SUPPORT //
-#ifdef DBG
- (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
-#else
- (iw_handler) NULL, /* + 0x03 */
-#endif
- (iw_handler) NULL, /* + 0x04 */
- (iw_handler) NULL, /* + 0x05 */
- (iw_handler) NULL, /* + 0x06 */
- (iw_handler) NULL, /* + 0x07 */
- (iw_handler) NULL, /* + 0x08 */
- (iw_handler) rt_private_get_statistics, /* + 0x09 */
- (iw_handler) NULL, /* + 0x0A */
- (iw_handler) NULL, /* + 0x0B */
- (iw_handler) NULL, /* + 0x0C */
- (iw_handler) NULL, /* + 0x0D */
- (iw_handler) NULL, /* + 0x0E */
- (iw_handler) NULL, /* + 0x0F */
- (iw_handler) NULL, /* + 0x10 */
- (iw_handler) rt_private_show, /* + 0x11 */
- (iw_handler) NULL, /* + 0x12 */
- (iw_handler) NULL, /* + 0x13 */
- (iw_handler) NULL, /* + 0x15 */
- (iw_handler) NULL, /* + 0x17 */
- (iw_handler) NULL, /* + 0x18 */
-};
-
-const struct iw_handler_def rt28xx_iw_handler_def =
-{
-#define N(a) (sizeof (a) / sizeof (a[0]))
- .standard = (iw_handler *) rt_handler,
- .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
- .private = (iw_handler *) rt_priv_handlers,
- .num_private = N(rt_priv_handlers),
- .private_args = (struct iw_priv_args *) privtab,
- .num_private_args = N(privtab),
-#if IW_HANDLER_VERSION >= 7
- .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif
-};
-
-INT RTMPSetInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_MAC_ADDRESS Bssid;
- RT_802_11_PHY_MODE PhyMode;
- RT_802_11_STA_CONFIG StaConfig;
- NDIS_802_11_RATES aryRates;
- RT_802_11_PREAMBLE Preamble;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- PNDIS_802_11_KEY pKey = NULL;
- PNDIS_802_11_WEP pWepKey =NULL;
- PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
- NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
- NDIS_802_11_NETWORK_TYPE NetType;
- ULONG Now;
- UINT KeyIdx = 0;
- INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
- ULONG PowerTemp;
- BOOLEAN RadioState;
- BOOLEAN StateMachineTouched = FALSE;
-#ifdef DOT11_N_SUPPORT
- OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
- PNDIS_802_11_PMKID pPmkId = NULL;
- BOOLEAN IEEE8021xState = FALSE;
- BOOLEAN IEEE8021x_required_keys = FALSE;
- UCHAR wpa_supplicant_enable = 0;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef SNMP_SUPPORT
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR ctmp;
-#endif // SNMP_SUPPORT //
-
-
-
-#ifdef DOT11_N_SUPPORT
- MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
- switch(cmd & 0x7FFF) {
- case RT_OID_802_11_COUNTRY_REGION:
- if (wrq->u.data.length < sizeof(UCHAR))
- Status = -EINVAL;
- // Only avaliable when EEPROM not programming
- else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
- {
- ULONG Country;
- UCHAR TmpPhy;
-
- Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
- pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
- TmpPhy = pAdapter->CommonCfg.PhyMode;
- pAdapter->CommonCfg.PhyMode = 0xff;
- // Build all corresponding channel information
- RTMPSetPhyMode(pAdapter, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
- pAdapter->CommonCfg.CountryRegion));
- }
- break;
- case OID_802_11_BSSID_LIST_SCAN:
- #ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- Now = jiffies;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- break;
- }
-
- //Benson add 20080527, when radio off, sta don't need to scan
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
- break;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
- break;
- case OID_802_11_SSID:
- if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
- Status = -EINVAL;
- else
- {
- PCHAR pSsidString = NULL;
- Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- if (Ssid.SsidLength > MAX_LEN_OF_SSID)
- Status = -EINVAL;
- else
- {
- if (Ssid.SsidLength == 0)
- {
- Set_SSID_Proc(pAdapter, "");
- }
- else
- {
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
- Set_SSID_Proc(pAdapter, pSsidString);
- kfree(pSsidString);
- }
- else
- Status = -ENOMEM;
- }
- }
- }
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- }
- break;
- case RT_OID_802_11_RADIO:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
- if (pAdapter->StaCfg.bSwRadio != RadioState)
- {
- pAdapter->StaCfg.bSwRadio = RadioState;
- if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
- {
- pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
- if (pAdapter->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- else
- {
- MlmeRadioOff(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = SW_RADIO_OFF;
- }
- }
- }
- }
- break;
- case RT_OID_802_11_PHY_MODE:
- if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PhyMode <= MaxPhyMode)
- {
- RTMPSetPhyMode(pAdapter, PhyMode);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
- }
- break;
- case RT_OID_802_11_STA_CONFIG:
- if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
- pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
- pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
- if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
- (StaConfig.AdhocMode <= MaxPhyMode))
- {
- // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
- // if setting changed, need to reset current TX rate as well as BEACON frame format
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- {
- pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
- RTMPSetPhyMode(pAdapter, PhyMode);
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- MakeIbssBeacon(pAdapter); // re-build BEACON frame
- AsicEnableIbssSync(pAdapter); // copy to on-chip memory
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
- pAdapter->CommonCfg.bEnableTxBurst,
- pAdapter->CommonCfg.UseBGProtection,
- pAdapter->CommonCfg.bUseShortSlotTime));
- }
- break;
- case OID_802_11_DESIRED_RATES:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
- NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
- pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
- pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
- pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
- pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
- // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- }
- break;
- case RT_OID_802_11_PREAMBLE:
- if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
- if (Preamble == Rt802_11PreambleShort)
- {
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
- }
- else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
- {
- // if user wants AUTO, initialize to LONG here, then change according to AP's
- // capability upon association.
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
- }
- break;
- case OID_802_11_WEP_STATUS:
- if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
- // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
- if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
- {
- if (pAdapter->StaCfg.WepStatus != WepStatus)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.WepStatus = WepStatus;
- pAdapter->StaCfg.OrigWepStatus = WepStatus;
- pAdapter->StaCfg.PairCipher = WepStatus;
- pAdapter->StaCfg.GroupCipher = WepStatus;
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
- }
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
- if (AuthMode > Ndis802_11AuthModeMax)
- {
- Status = -EINVAL;
- break;
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode != AuthMode)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.AuthMode = AuthMode;
- }
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
- }
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (BssType == Ndis802_11IBSS)
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- else if (BssType == Ndis802_11Infrastructure)
- Set_NetworkType_Proc(pAdapter, "Infra");
- else if (BssType == Ndis802_11Monitor)
- Set_NetworkType_Proc(pAdapter, "Monitor");
- else
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
- }
- }
- break;
- case OID_802_11_REMOVE_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
- if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
- {
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx >= 4){
- Status = -EINVAL;
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- }
- }
- }
- break;
- case RT_OID_802_11_RESET_COUNTERS:
- NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
- NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
- NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
- pAdapter->Counters8023.RxNoBuffer = 0;
- pAdapter->Counters8023.GoodReceives = 0;
- pAdapter->Counters8023.RxNoBuffer = 0;
-#ifdef RT2870
- pAdapter->BulkOutComplete = 0;
- pAdapter->BulkOutCompleteOther= 0;
- pAdapter->BulkOutCompleteCancel = 0;
- pAdapter->BulkOutReq = 0;
- pAdapter->BulkInReq= 0;
- pAdapter->BulkInComplete = 0;
- pAdapter->BulkInCompleteFail = 0;
-#endif // RT2870 //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
- break;
- case OID_802_11_RTS_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
- if (RtsThresh > MAX_RTS_THRESHOLD)
- Status = -EINVAL;
- else
- pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- {
- if (FragThresh == 0)
- {
- pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
- }
- else
- Status = -EINVAL;
- }
- else
- pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerMode == Ndis802_11PowerModeCAM)
- Set_PSMode_Proc(pAdapter, "CAM");
- else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
- Set_PSMode_Proc(pAdapter, "Max_PSP");
- else if (PowerMode == Ndis802_11PowerModeFast_PSP)
- Set_PSMode_Proc(pAdapter, "Fast_PSP");
- else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
- Set_PSMode_Proc(pAdapter, "Legacy_PSP");
- else
- Status = -EINVAL;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- if (wrq->u.data.length < sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerTemp > 100)
- PowerTemp = 0xffffffff; // AUTO
- pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
- pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- }
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (NetType == Ndis802_11DS)
- RTMPSetPhyMode(pAdapter, PHY_11B);
- else if (NetType == Ndis802_11OFDM24)
- RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
- else if (NetType == Ndis802_11OFDM5)
- RTMPSetPhyMode(pAdapter, PHY_11A);
- else
- Status = -EINVAL;
-#ifdef DOT11_N_SUPPORT
- if (Status == NDIS_STATUS_SUCCESS)
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
- }
- break;
- // For WPA PSK PMK key
- case RT_OID_802_11_ADD_WPA:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
- }
- else
- {
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
- {
- Status = -EOPNOTSUPP;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
- }
- else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
- {
- NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
- // Use RaConfig as PSK agent.
- // Start STA supplicant state machine
- if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- pAdapter->StaCfg.WpaState = SS_START;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- else
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- }
- kfree(pKey);
- break;
- case OID_802_11_REMOVE_KEY:
- pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pRemoveKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pRemoveKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
- }
- else
- {
- KeyIdx = pRemoveKey->KeyIndex;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx > 3)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
- }
- }
- }
- }
- kfree(pRemoveKey);
- break;
- // New for WPA
- case OID_802_11_ADD_KEY:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
- }
- else
- {
- RTMPAddKey(pAdapter, pKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- kfree(pKey);
- break;
- case OID_802_11_CONFIGURATION:
- if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
- pConfig = &Config;
-
- if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
- pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
-
- pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
- MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
- //
- // Save the channel on MlmeAux for CntlOidRTBssidProc used.
- //
- pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
- pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- break;
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_HT_PHYMODE:
- if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
- Status = -EINVAL;
- else
- {
- POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
-
- Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
- pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
- pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- RTMPSetHT(pAdapter, pHTPhyMode);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
- pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
- pAdapter->StaCfg.HTPhyMode.field.STBC));
- break;
-#endif // DOT11_N_SUPPORT //
- case RT_OID_802_11_SET_APSD_SETTING:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- ULONG apsd ;
- Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
-
- /*-------------------------------------------------------------------
- |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
- ---------------------------------------------------------------------
- | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
- ---------------------------------------------------------------------*/
- pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
- pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
- pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
- }
- break;
-
- case RT_OID_802_11_SET_APSD_PSM:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- // Driver needs to notify AP when PSM changes
- Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
- if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
- {
- MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
- RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- }
- break;
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
- Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
- if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
- {
- int i;
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- }
- break;
-
- case RT_OID_802_11_SET_DLS_PARAM:
- if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
- Status = -EINVAL;
- else
- {
- RT_802_11_DLS Dls;
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- case RT_OID_802_11_SET_WMM:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
- }
- break;
-
- case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- //
- // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
- // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
- // when query OID_802_11_BSSID_LIST.
- //
- // TRUE: NumberOfItems will set to 0.
- // FALSE: NumberOfItems no change.
- //
- pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
- // Set to immediately send the media disconnect event
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
-
- if (INFRA_ON(pAdapter))
- {
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_DISASSOCIATE,
- 0,
- NULL);
-
- StateMachineTouched = TRUE;
- }
- break;
-
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_IMME_BA_CAP:
- if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
- Status = -EINVAL;
- else
- {
- OID_BACAP_STRUC Orde ;
- Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
- if (Orde.Policy > BA_NOTUSE)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- }
- else if (Orde.Policy == BA_NOTUSE)
- {
- pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
- }
- else
- {
- pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
- pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-
- if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
-
- }
-
- pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
- }
-
- break;
- case RT_OID_802_11_ADD_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- UCHAR index;
- OID_ADD_BA_ENTRY BA;
- MAC_TABLE_ENTRY *pEntry;
-
- Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
- if (BA.TID > 15)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
- else
- {
- //BATableInsertEntry
- //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
- index = BA.TID;
- // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
- pEntry = MacTableLookup(pAdapter, BA.MACAddr);
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
- break;
- }
- if (BA.IsRecipient == FALSE)
- {
- if (pEntry->bIAmBadAtheros == TRUE)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
-
- BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
- }
- else
- {
- //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
- BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
- , BA.MACAddr[4], BA.MACAddr[5]));
- }
- }
- break;
-
- case RT_OID_802_11_TEAR_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- POID_ADD_BA_ENTRY pBA;
- MAC_TABLE_ENTRY *pEntry;
-
- pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if (pBA == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
- Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
-
- if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
-
- if (pBA->IsRecipient == FALSE)
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
- BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- else
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- if (pEntry)
- {
- BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- kfree(pBA);
- }
- }
- break;
-#endif // DOT11_N_SUPPORT //
-
- // For WPA_SUPPLICANT to set static wep key
- case OID_802_11_ADD_WEP:
- pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pWepKey == NULL)
- {
- Status = -ENOMEM;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
- break;
- }
- Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
- if (Status)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
- }
- else
- {
- KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
- // KeyIdx must be 0 ~ 3
- if (KeyIdx > 4)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
- }
- else
- {
- UCHAR CipherAlg = 0;
- PUCHAR Key;
-
- // set key material and key length
- NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
-
- switch(pWepKey->KeyLength)
- {
- case 5:
- CipherAlg = CIPHER_WEP64;
- break;
- case 13:
- CipherAlg = CIPHER_WEP128;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
- Status = -EINVAL;
- break;
- }
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
-
- // Default key for tx (shared key)
- if (pWepKey->KeyIndex & 0x80000000)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- // set key material and key length
- NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
- pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-#endif // WPA_SUPPLICANT_SUPPORT //
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
-#endif // WPA_SUPPLICANT_SUPPORT
- {
- Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- if (pWepKey->KeyIndex & 0x80000000)
- {
- PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
- }
- }
- kfree(pWepKey);
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case OID_SET_COUNTERMEASURES:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.bBlockAssoc = TRUE;
- else
- // WPA MIC error should block association attempt for 60 seconds
- pAdapter->StaCfg.bBlockAssoc = FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- }
- break;
- case OID_802_11_DEAUTHENTICATION:
- if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
- Status = -EINVAL;
- else
- {
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
- Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
- MlmeDeauthReqAction(pAdapter, MsgElem);
- kfree(MsgElem);
-
- if (INFRA_ON(pAdapter))
- {
- LinkDown(pAdapter, FALSE);
- pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
- }
- break;
- case OID_802_11_DROP_UNENCRYPTED:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- NdisAcquireSpinLock(&pAdapter->MacTabLock);
- pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAdapter->MacTabLock);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
- }
- break;
- case OID_802_11_SET_IEEE8021X:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
- }
- break;
- case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
- }
- break;
- case OID_802_11_PMKID:
- pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pPmkId == NULL) {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
-
- // check the PMKID information
- if (pPmkId->BSSIDInfoCount == 0)
- NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- else
- {
- PBSSID_INFO pBssIdInfo;
- UINT BssIdx;
- UINT CachedIdx;
-
- for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
- {
- // point to the indexed BSSID_INFO structure
- pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
- // Find the entry in the saved data base.
- for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- pAdapter->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- }
- }
- }
- if(pPmkId)
- kfree(pPmkId);
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
-#ifdef SNMP_SUPPORT
- case OID_802_11_SHORTRETRYLIMIT:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
- }
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
- }
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
- pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- //pKey = &WepKey;
-
- if ( pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
- }
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
- DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
-
- // it is a shared key
- if (KeyIdx > 4)
- Status = -EINVAL;
- else
- {
- pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
- if (pKey->KeyIndex & 0x80000000)
- {
- // Default key for tx (shared key)
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
- //RestartAPIsRequired = TRUE;
- }
- break;
-
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
-
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
-
- break;
-
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
- sprintf(&ctmp,"%d", ctmp);
- Set_Channel_Proc(pAdapter, &ctmp);
- }
- break;
-#endif
-
-
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
-
- return Status;
-}
-
-INT RTMPQueryInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
- PNDIS_WLAN_BSSID_EX pBss;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
- RT_802_11_LINK_STATUS *pLinkStatus = NULL;
- RT_802_11_STA_CONFIG *pStaConfig = NULL;
- NDIS_802_11_STATISTICS *pStatistics = NULL;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- RT_802_11_PREAMBLE PreamType;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_MEDIA_STATE MediaState;
- ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
- USHORT BssLen = 0;
- PUCHAR pBuf = NULL, pPtr;
- INT Status = NDIS_STATUS_SUCCESS;
- UINT we_version_compiled;
- UCHAR i, Padding = 0;
- BOOLEAN RadioState;
- UCHAR driverVersion[8];
- OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
-
-
-#ifdef SNMP_SUPPORT
- //for snmp, kathy
- DefaultKeyIdxValue *pKeyIdxValue;
- INT valueLen;
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR tmp[64];
-#endif //SNMP
-
- switch(cmd)
- {
- case RT_OID_DEVICE_NAME:
- wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
- Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
- break;
- case RT_OID_VERSION_INFO:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
- wrq->u.data.length = 8*sizeof(UCHAR);
- sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
- driverVersion[7] = '\0';
- if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#ifdef RALINK_ATE
- case RT_QUERY_ATE_TXDONE_COUNT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
- wrq->u.data.length = sizeof(UINT32);
- if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#endif // RALINK_ATE //
- case OID_802_11_BSSID_LIST:
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
- return -EAGAIN;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- // Claculate total buffer size required
- BssBufSize = sizeof(ULONG);
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- // Align pointer to 4 bytes boundary.
- //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
- //if (Padding == 4)
- // Padding = 0;
- BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
- }
-
- // For safety issue, we add 256 bytes just in case
- BssBufSize += 256;
- // Allocate the same size as passed from higher layer
- pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
- if(pBuf == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- // Init 802_11_BSSID_LIST_EX structure
- NdisZeroMemory(pBuf, BssBufSize);
- pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
- pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
-
- // Calculate total buffer length
- BssLen = 4; // Consist of NumberOfItems
- // Point to start of NDIS_WLAN_BSSID_EX
- // pPtr = pBuf + sizeof(ULONG);
- pPtr = (PUCHAR) &pBssidList->Bssid[0];
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
- NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
- {
- //
- // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
- // and then failed to send EAPOl farame.
- //
- if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- else
- pBss->Ssid.SsidLength = 0;
- }
- else
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
- pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
- pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
- pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
- pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
- pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
-
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
-
- if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
- pBss->InfrastructureMode = Ndis802_11Infrastructure;
- else
- pBss->InfrastructureMode = Ndis802_11IBSS;
-
- NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
- NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
- pAdapter->ScanTab.BssEntry[i].ExtRate,
- pAdapter->ScanTab.BssEntry[i].ExtRateLen);
-
- if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
- {
- pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- }
- else
- {
- pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
- }
- pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
-
-#if WIRELESS_EXT < 17
- if ((BssLen + pBss->Length) < wrq->u.data.length)
- BssLen += pBss->Length;
- else
- {
- pBssidList->NumberOfItems = i;
- break;
- }
-#else
- BssLen += pBss->Length;
-#endif
- }
-
-#if WIRELESS_EXT < 17
- wrq->u.data.length = BssLen;
-#else
- if (BssLen > wrq->u.data.length)
- {
- kfree(pBssidList);
- return -E2BIG;
- }
- else
- wrq->u.data.length = BssLen;
-#endif
- Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
- kfree(pBssidList);
- break;
- case OID_802_3_CURRENT_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
- case OID_GEN_MEDIA_CONNECT_STATUS:
- if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
- MediaState = NdisMediaStateConnected;
- else
- MediaState = NdisMediaStateDisconnected;
-
- wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
- Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-#endif // RALINK_ATE //
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
- Status = -ENOTCONN;
- }
- break;
- case OID_802_11_SSID:
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
- Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
- memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
- wrq->u.data.length = sizeof(NDIS_802_11_SSID);
- Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
- break;
- case RT_OID_802_11_QUERY_LINK_STATUS:
- pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
- if (pLinkStatus)
- {
- pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
- pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
- pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
- pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
- pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
- wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
- Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
- kfree(pLinkStatus);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_CONFIGURATION:
- pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
- if (pConfiguration)
- {
- pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
- pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
- pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
- wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
- Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
- pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
- kfree(pConfiguration);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_SNR_0:
- if ((pAdapter->StaCfg.LastSNR0 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
- }
- else
- Status = -EFAULT;
- break;
- case RT_OID_802_11_SNR_1:
- if ((pAdapter->Antenna.field.RxPath > 1) &&
- (pAdapter->StaCfg.LastSNR1 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
- }
- else
- Status = -EFAULT;
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
- break;
- case OID_802_11_RSSI_TRIGGER:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
- break;
- case OID_802_11_RSSI:
- case RT_OID_802_11_RSSI:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_1:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_2:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_802_11_STATISTICS:
- pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
- if (pStatistics)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
- // add the most up-to-date h/w raw counters into software counters
- NICUpdateRawCounters(pAdapter);
-
- // Sanity check for calculation of sucessful count
- if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
- pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
-
- pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
- pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
- pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
- pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
- pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
- pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
- pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
- pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
- pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
- pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
- pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
-#ifdef DBG
- pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
-#else
- pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
- pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
-#endif
- wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
- Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
- kfree(pStatistics);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_GEN_RCV_OK:
- ulInfo = pAdapter->Counters8023.GoodReceives;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_GEN_RCV_NO_BUFFER:
- ulInfo = pAdapter->Counters8023.RxNoBuffer;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_PHY_MODE:
- ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_STA_CONFIG:
- pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
- if (pStaConfig)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
- pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
- pStaConfig->EnableTurboRate = 0;
- pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
- pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
- //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
- pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
- pStaConfig->Rsv1 = 0;
- pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
- wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
- Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
- kfree(pStaConfig);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_RTS_THRESHOLD:
- RtsThresh = pAdapter->CommonCfg.RtsThreshold;
- wrq->u.data.length = sizeof(RtsThresh);
- Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- FragThresh = pAdapter->CommonCfg.FragmentThreshold;
- if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
- FragThresh = 0;
- wrq->u.data.length = sizeof(FragThresh);
- Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- PowerMode = pAdapter->StaCfg.WindowsPowerMode;
- wrq->u.data.length = sizeof(PowerMode);
- Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
- break;
- case RT_OID_802_11_RADIO:
- RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
- wrq->u.data.length = sizeof(RadioState);
- Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- BssType = Ndis802_11IBSS;
- else if (pAdapter->StaCfg.BssType == BSS_INFRA)
- BssType = Ndis802_11Infrastructure;
- else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
- BssType = Ndis802_11Monitor;
- else
- BssType = Ndis802_11AutoUnknown;
-
- wrq->u.data.length = sizeof(BssType);
- Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
- break;
- case RT_OID_802_11_PREAMBLE:
- PreamType = pAdapter->CommonCfg.TxPreamble;
- wrq->u.data.length = sizeof(PreamType);
- Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- AuthMode = pAdapter->StaCfg.AuthMode;
- wrq->u.data.length = sizeof(AuthMode);
- Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
- break;
- case OID_802_11_WEP_STATUS:
- WepStatus = pAdapter->StaCfg.WepStatus;
- wrq->u.data.length = sizeof(WepStatus);
- Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
- break;
- case OID_802_11_TX_POWER_LEVEL:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- break;
- case OID_802_11_NETWORK_TYPES_SUPPORTED:
- if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
- {
- NetworkTypeList[0] = 3; // NumberOfItems = 3
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
- wrq->u.data.length = 16;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- else
- {
- NetworkTypeList[0] = 2; // NumberOfItems = 2
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- wrq->u.data.length = 12;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- wrq->u.data.length = sizeof(ULONG);
- if (pAdapter->CommonCfg.PhyMode == PHY_11A)
- ulInfo = Ndis802_11OFDM5;
- else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
- ulInfo = Ndis802_11OFDM24;
- else
- ulInfo = Ndis802_11DS;
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_LAST_RX_RATE:
- ulInfo = (ULONG)pAdapter->LastRxRate;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_LAST_TX_RATE:
- //ulInfo = (ULONG)pAdapter->LastTxRate;
- ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_EEPROM_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_NOISE_LEVEL:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
- break;
- case RT_OID_802_11_EXTRA_INFO:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
- break;
- case RT_OID_WE_VERSION_COMPILED:
- wrq->u.data.length = sizeof(UINT);
- we_version_compiled = WIRELESS_EXT;
- Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_APSD_SETTING:
- apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
- | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
-
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
- apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
- break;
- case RT_OID_802_11_QUERY_APSD_PSM:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- break;
- case RT_OID_802_11_QUERY_WMM:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case RT_OID_NEW_DRIVER:
- {
- UCHAR enabled = 1;
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- case RT_OID_DRIVER_DEVICE_NAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
- wrq->u.data.length = 16;
- if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
-
- pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_COUNTRY_REGION:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
- wrq->u.data.length = sizeof(ulInfo);
- ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
- ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
- if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
-
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- i = 0;
-#ifdef MULTIPLE_CARD_SUPPORT
- i = 1;
-#endif // MULTIPLE_CARD_SUPPORT //
- if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
- break;
-#ifdef SNMP_SUPPORT
- case RT_OID_802_11_MAC_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREROUI:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
- wrq->u.data.length = ManufacturerOUI_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTURERNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_RESOURCETYPEIDNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
- wrq->u.data.length = strlen(ResourceTypeIdName);
- Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
- ulInfo = 1; // 1 is support wep else 2 is not support.
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_POWERMANAGEMENTMODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
- if (pAdapter->StaCfg.Psm == PSMP_ACTION)
- ulInfo = 1; // 1 is power active else 2 is power save.
- else
- ulInfo = 2;
-
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
- //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
- pKeyIdxValue = wrq->u.data.pointer;
- DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
- valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- NdisMoveMemory(pKeyIdxValue->Value,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
- valueLen);
- pKeyIdxValue->Value[valueLen]='\0';
-
- wrq->u.data.length = sizeof(DefaultKeyIdxValue);
-
- Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- pAdapter->SharedKey[BSS0][0].Key[0],
- pAdapter->SharedKey[BSS0][1].Key[0],
- pAdapter->SharedKey[BSS0][2].Key[0],
- pAdapter->SharedKey[BSS0][3].Key[0]));
- break;
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
- break;
-
- case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- wrq->u.data.length);
- break;
-
- case OID_802_11_SHORTRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRODUCTID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
-
-#ifdef RT2870
- sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
-
-#endif // RT2870 //
- wrq->u.data.length = strlen(tmp);
- Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
- wrq->u.data.length = sizeof(UCHAR);
- DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-#endif //SNMP_SUPPORT
-
- case OID_802_11_BUILD_CHANNEL_EX:
- {
- UCHAR value;
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
- wrq->u.data.length = sizeof(UCHAR);
-#ifdef EXT_BUILD_CHANNEL_LIST
- DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 1;
-#else
- DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 0;
-#endif // EXT_BUILD_CHANNEL_LIST //
- Status = copy_to_user(wrq->u.data.pointer, &value, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- }
- break;
-
- case OID_802_11_GET_CH_LIST:
- {
- PRT_CHANNEL_LIST_INFO pChListBuf;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
- if (pAdapter->ChannelListNum == 0)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
- if (pChListBuf == NULL)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
- for (i = 0; i < pChListBuf->ChannelListNum; i++)
- pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
-
- wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-
- if (pChListBuf)
- kfree(pChListBuf);
- }
- break;
-
- case OID_802_11_GET_COUNTRY_CODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
- wrq->u.data.length = 2;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
- case OID_802_11_GET_CHANNEL_GEOGRAPHY:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
- wrq->u.data.length = 1;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_QUERY_DLS:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- break;
-
- case RT_OID_802_11_QUERY_DLS_PARAM:
- {
- PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
- if (pDlsInfo == NULL)
- break;
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
- }
-
- pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
- wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
-
- if (pDlsInfo)
- kfree(pDlsInfo);
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
- return Status;
-}
-
-INT rt28xx_sta_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- POS_COOKIE pObj;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- RTMP_ADAPTER *pAd = NULL;
- struct iwreq *wrq = (struct iwreq *) rq;
- BOOLEAN StateMachineTouched = FALSE;
- INT Status = NDIS_STATUS_SUCCESS;
- USHORT subcmd;
-
- if (net_dev->priv_flags == INT_MAIN)
- {
- pAd = net_dev->priv;
- }
- else
- {
- pVirtualAd = net_dev->priv;
- pAd = pVirtualAd->RtmpDev->priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (wrq->u.data.pointer == NULL)
- {
- return Status;
- }
-
- if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- }
-
- { // determine this ioctl command is comming from which interface.
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(cmd)
- {
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
- case RTPRIV_IOCTL_ATE:
- {
- RtmpDoAte(pAd, wrq);
- }
- break;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
- case SIOCGIFHWADDR:
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
- memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
- break;
- case SIOCGIWNAME:
- {
- char *name=&wrq->u.name[0];
- rt_ioctl_giwname(net_dev, NULL, name, NULL);
- break;
- }
- case SIOCGIWESSID: //Get ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWESSID: //Set ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWNWID: // set network id (the cell)
- case SIOCGIWNWID: // get network id
- Status = -EOPNOTSUPP;
- break;
- case SIOCSIWFREQ: //set channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCGIWFREQ: // get channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCSIWNICKN: //set node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWNICKN: //get node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWRATE: //get default bit rate (bps)
- rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCSIWRATE: //set default bit rate (bps)
- rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCGIWFRAG: //get fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCSIWFRAG: //set fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCGIWENCODE: //get encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCSIWENCODE: //set encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCGIWAP: //get access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCSIWAP: //set access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCGIWMODE: //get operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCSIWMODE: //set operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCGIWSENS: //get sensitivity (dBm)
- case SIOCSIWSENS: //set sensitivity (dBm)
- case SIOCGIWPOWER: //get Power Management settings
- case SIOCSIWPOWER: //set Power Management settings
- case SIOCGIWTXPOW: //get transmit power (dBm)
- case SIOCSIWTXPOW: //set transmit power (dBm)
- case SIOCGIWRANGE: //Get range of parameters
- case SIOCGIWRETRY: //get retry limits and lifetime
- case SIOCSIWRETRY: //set retry limits and lifetime
- Status = -EOPNOTSUPP;
- break;
- case RT_PRIV_IOCTL:
- subcmd = wrq->u.data.flags;
- if( subcmd & OID_GET_SET_TOGGLE)
- Status = RTMPSetInformation(pAd, rq, subcmd);
- else
- Status = RTMPQueryInformation(pAd, rq, subcmd);
- break;
- case SIOCGIWPRIV:
- if (wrq->u.data.pointer)
- {
- if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
- break;
- wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
- if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
- Status = -EFAULT;
- }
- break;
- case RTPRIV_IOCTL_SET:
- if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
- break;
- rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
- break;
- case RTPRIV_IOCTL_GSITESURVEY:
- RTMPIoctlGetSiteSurvey(pAd, wrq);
- break;
-#ifdef DBG
- case RTPRIV_IOCTL_MAC:
- RTMPIoctlMAC(pAd, wrq);
- break;
- case RTPRIV_IOCTL_E2P:
- RTMPIoctlE2PROM(pAd, wrq);
- break;
-#endif // DBG //
- case SIOCETHTOOL:
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
- if(StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAd);
-
- return Status;
-}
-
-/*
- ==========================================================================
- Description:
- Set SSID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- NDIS_802_11_SSID Ssid, *pSsid=NULL;
- BOOLEAN StateMachineTouched = FALSE;
- int success = TRUE;
-
- if( strlen(arg) <= MAX_LEN_OF_SSID)
- {
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- if (strlen(arg) != 0)
- {
- NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
- Ssid.SsidLength = strlen(arg);
- }
- else //ANY ssid
- {
- Ssid.SsidLength = 0;
- memcpy(Ssid.Ssid, "", 0);
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
- }
- pSsid = &Ssid;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- pAdapter->bConfigChanged = TRUE;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_SSID,
- sizeof(NDIS_802_11_SSID),
- (VOID *)pSsid);
-
- StateMachineTouched = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- }
- else
- success = FALSE;
-
- if (StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAdapter);
-
- return success;
-}
-
-#ifdef WMM_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WmmCapable Enable or Disable
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN bWmmCapable;
-
- bWmmCapable = simple_strtol(arg, 0, 10);
-
- if ((bWmmCapable == 1)
-#ifdef RT2870
- && (pAd->NumberOfPipes >= 5)
-#endif // RT2870 //
- )
- pAd->CommonCfg.bWmmCapable = TRUE;
- else if (bWmmCapable == 0)
- pAd->CommonCfg.bWmmCapable = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
- pAd->CommonCfg.bWmmCapable));
-
- return TRUE;
-}
-#endif // WMM_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Set Network Type(Infrastructure/Adhoc mode)
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UINT32 Value = 0;
-
- if (strcmp(arg, "Adhoc") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_ADHOC)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (INFRA_ON(pAdapter))
- {
- //BOOLEAN Cancelled;
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
- }
- }
- pAdapter->StaCfg.BssType = BSS_ADHOC;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
- }
- else if (strcmp(arg, "Infra") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_INFRA)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (ADHOC_ON(pAdapter))
- {
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
- }
- }
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
-
- pAdapter->StaCfg.BssType = BSS_INFRA;
- }
- else if (strcmp(arg, "Monitor") == 0)
- {
- UCHAR bbpValue = 0;
- BCN_TIME_CFG_STRUC csr;
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- // disable all periodic state machine
- pAdapter->StaCfg.bAutoReconnect = FALSE;
- // reset all mlme state machine
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
- if (pAdapter->CommonCfg.CentralChannel == 0)
- {
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
- pAdapter->CommonCfg.CentralChannel = 36;
- else
-#endif // DOT11_N_SUPPORT //
- pAdapter->CommonCfg.CentralChannel = 6;
- }
-#ifdef DOT11_N_SUPPORT
- else
- N_ChannelCheck(pAdapter);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
- {
- // 40MHz ,control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- // RX : control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
-
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value &= 0xfffffffe;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
- {
- // 40MHz ,control channel at upper
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value |= 0x1;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue |= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // 20MHz
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_20;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
- }
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
- // ASIC supporsts sniffer function with replacing RSSI with timestamp.
- //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- //Value |= (0x80);
- //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- // disable sync
- RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
- csr.field.bBeaconGen = 0;
- csr.field.bTBTTEnable = 0;
- csr.field.TsfSyncMode = 0;
- RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-
- pAdapter->StaCfg.BssType = BSS_MONITOR;
- pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Authentication mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
- else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
- else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- return FALSE;
-
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Encryption Type
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- else
- return FALSE;
-
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Default Key ID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- ULONG KeyIdx;
-
- KeyIdx = simple_strtol(arg, 0, 10);
- if((KeyIdx >= 1 ) && (KeyIdx <= 4))
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WEP KEY1
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
-
- pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 0,
- pAdapter->SharedKey[BSS0][0].CipherAlg,
- pAdapter->SharedKey[BSS0][0].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
-
- Description:
- Set WEP KEY2
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 1,
- pAdapter->SharedKey[BSS0][1].CipherAlg,
- pAdapter->SharedKey[BSS0][1].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY3
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 2,
- pAdapter->SharedKey[BSS0][2].CipherAlg,
- pAdapter->SharedKey[BSS0][2].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY4
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 3,
- pAdapter->SharedKey[BSS0][3].CipherAlg,
- pAdapter->SharedKey[BSS0][3].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WPA PSK key
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UCHAR keyMaterial[40];
-
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- )
- return TRUE; // do nothing
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
-
- NdisZeroMemory(keyMaterial, 40);
-
- if ((strlen(arg) < 8) || (strlen(arg) > 64))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
- return FALSE;
- }
-
- if (strlen(arg) == 64)
- {
- AtoH(arg, keyMaterial, 32);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-
- }
- else
- {
- PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
- }
-
-
-
- if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
- pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- }
- else
- {
- // Start STA supplicant state machine
- pAdapter->StaCfg.WpaState = SS_START;
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Power Saving mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (pAdapter->StaCfg.BssType == BSS_INFRA)
- {
- if ((strcmp(arg, "Max_PSP") == 0) ||
- (strcmp(arg, "max_psp") == 0) ||
- (strcmp(arg, "MAX_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- pAdapter->StaCfg.DefaultListenCount = 5;
-
- }
- else if ((strcmp(arg, "Fast_PSP") == 0) ||
- (strcmp(arg, "fast_psp") == 0) ||
- (strcmp(arg, "FAST_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else if ((strcmp(arg, "Legacy_PSP") == 0) ||
- (strcmp(arg, "legacy_psp") == 0) ||
- (strcmp(arg, "LEGACY_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else
- {
- //Default Ndis802_11PowerModeCAM
- // clear PSM bit immediately
- MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
- }
- else
- return FALSE;
-
-
- return TRUE;
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WpaSupport flag.
- Value:
- 0: Driver ignore wpa_supplicant.
- 1: wpa_supplicant initiates scanning and AP selection.
- 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- if ( simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
- else if ( simple_strtol(arg, 0, 10) == 1)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
- else if ( simple_strtol(arg, 0, 10) == 2)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
- else
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
-
- return TRUE;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-/*
- ==========================================================================
- Description:
- Read / Write MAC
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
- 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
- ==========================================================================
-*/
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- ULONG macAddr = 0;
- UCHAR temp[16], temp2[16];
- UINT32 macValue = 0;
- INT Status;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // Mac Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
- if (macAddr < 0xFFFF)
- {
- RTMP_IO_READ32(pAdapter, macAddr, &macValue);
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[8-k+j] = temp2[j];
- }
-
- while(k < 8)
- temp2[7-k++]='0';
- temp2[8]='\0';
-
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 4);
- macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
-
- // debug mode
- if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
- {
- // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
- if (macValue & 0x000000ff)
- {
- pAdapter->BbpTuning.bEnable = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
- }
- else
- {
- UCHAR R66;
- pAdapter->BbpTuning.bEnable = FALSE;
- R66 = 0x26 + GET_LNA_GAIN(pAdapter);
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
- }
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
-
- RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
- }
- }
- }
-next:
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
-}
-
-/*
- ==========================================================================
- Description:
- Read / Write E2PROM
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
- 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
- ==========================================================================
-*/
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- USHORT eepAddr = 0;
- UCHAR temp[16], temp2[16];
- USHORT eepValue;
- int Status;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
-
-
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
-
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // E2PROM addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
- if (eepAddr < 0xFFFF)
- {
- RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[4-k+j] = temp2[j];
- }
-
- while(k < 4)
- temp2[3-k++]='0';
- temp2[4]='\0';
-
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 2);
- eepValue = *temp*256 + temp[1];
-
- RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
- }
- }
-next:
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
-}
-#endif // DBG //
-
-
-
-
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.bTGnWifiTest = FALSE;
- else
- pAd->StaCfg.bTGnWifiTest = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
- return TRUE;
-}
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
- else if (simple_strtol(arg, 0, 10) == 1)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
- else if (simple_strtol(arg, 0, 10) == 2)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
- else
- return FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
- return TRUE;
-}
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
- return TRUE;
-}
-#endif // CARRIER_DETECTION_SUPPORT //
-
-
-INT Show_Adhoc_MacTable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PCHAR extra)
-{
- INT i;
-
- sprintf(extra, "\n");
-
-#ifdef DOT11_N_SUPPORT
- sprintf(extra, "%sHT Operating Mode : %d\n", extra, pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
-#endif // DOT11_N_SUPPORT //
-
- sprintf(extra, "%s\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", extra,
- "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
-
- if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
- break;
- if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- {
- sprintf(extra, "%s%02X:%02X:%02X:%02X:%02X:%02X ", extra,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- sprintf(extra, "%s%-4d", extra, (int)pEntry->Aid);
- sprintf(extra, "%s%-4d", extra, (int)pEntry->apidx);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi0);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi1);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi2);
- sprintf(extra, "%s%-10s", extra, GetPhyMode(pEntry->HTPhyMode.field.MODE));
- sprintf(extra, "%s%-6s", extra, GetBW(pEntry->HTPhyMode.field.BW));
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.MCS);
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.ShortGI);
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.STBC);
- sprintf(extra, "%s%-10d, %d, %d%%\n", extra, pEntry->DebugFIFOCount, pEntry->DebugTxCount,
- (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
- sprintf(extra, "%s\n", extra);
- }
- }
-
- return TRUE;
-}
-
-
diff --git a/drivers/staging/rt2870/tmp61 b/drivers/staging/rt2870/tmp61
deleted file mode 100644
index 975e44484379..000000000000
--- a/drivers/staging/rt2870/tmp61
+++ /dev/null
@@ -1,7037 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sta_ioctl.c
-
- Abstract:
- IOCTL related subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 01-03-2003 created
- Rory Chen 02-14-2005 modify to support RT61
-*/
-
-#include "rt_config.h"
-
-#ifdef DBG
-extern ULONG RTDebugLevel;
-#endif
-
-#define NR_WEP_KEYS 4
-#define WEP_SMALL_KEY_LEN (40/8)
-#define WEP_LARGE_KEY_LEN (104/8)
-
-#define GROUP_KEY_NO 4
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
-#else
-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E)
-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E)
-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F)
-#endif
-
-extern UCHAR CipherWpa2Template[];
-extern UCHAR CipherWpaPskTkip[];
-extern UCHAR CipherWpaPskTkipLen;
-
-typedef struct PACKED _RT_VERSION_INFO{
- UCHAR DriverVersionW;
- UCHAR DriverVersionX;
- UCHAR DriverVersionY;
- UCHAR DriverVersionZ;
- UINT DriverBuildYear;
- UINT DriverBuildMonth;
- UINT DriverBuildDay;
-} RT_VERSION_INFO, *PRT_VERSION_INFO;
-
-struct iw_priv_args privtab[] = {
-{ RTPRIV_IOCTL_SET,
- IW_PRIV_TYPE_CHAR | 1024, 0,
- "set"},
-
-{ RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-/* --- sub-ioctls definitions --- */
- { SHOW_CONN_STATUS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
- { SHOW_DRVIER_VERION,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
- { SHOW_BA_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
- { SHOW_DESC_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
- { RAIO_OFF,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
- { RAIO_ON,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
-#ifdef QOS_DLS_SUPPORT
- { SHOW_DLS_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
-#endif // QOS_DLS_SUPPORT //
- { SHOW_CFG_VALUE,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
- { SHOW_ADHOC_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
-
-/* --- sub-ioctls relations --- */
-
-#ifdef DBG
-{ RTPRIV_IOCTL_BBP,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "bbp"},
-{ RTPRIV_IOCTL_MAC,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "mac"},
-{ RTPRIV_IOCTL_E2P,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "e2p"},
-#endif /* DBG */
-
-{ RTPRIV_IOCTL_STATISTICS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "stat"},
-{ RTPRIV_IOCTL_GSITESURVEY,
- 0, IW_PRIV_TYPE_CHAR | 1024,
- "get_site_survey"},
-};
-
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WMM_SUPPORT
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-VOID RTMPIoctlBBP(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-#endif // DBG //
-
-
-NDIS_STATUS RTMPWPANoneAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-INT Set_FragTest_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef DOT11_N_SUPPORT
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CARRIER_DETECTION_SUPPORT //
-
-INT Show_Adhoc_MacTable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PCHAR extra);
-
-static struct {
- CHAR *name;
- INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
- {"DriverVersion", Set_DriverVersion_Proc},
- {"CountryRegion", Set_CountryRegion_Proc},
- {"CountryRegionABand", Set_CountryRegionABand_Proc},
- {"SSID", Set_SSID_Proc},
- {"WirelessMode", Set_WirelessMode_Proc},
- {"TxBurst", Set_TxBurst_Proc},
- {"TxPreamble", Set_TxPreamble_Proc},
- {"TxPower", Set_TxPower_Proc},
- {"Channel", Set_Channel_Proc},
- {"BGProtection", Set_BGProtection_Proc},
- {"RTSThreshold", Set_RTSThreshold_Proc},
- {"FragThreshold", Set_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
- {"HtBw", Set_HtBw_Proc},
- {"HtMcs", Set_HtMcs_Proc},
- {"HtGi", Set_HtGi_Proc},
- {"HtOpMode", Set_HtOpMode_Proc},
- {"HtExtcha", Set_HtExtcha_Proc},
- {"HtMpduDensity", Set_HtMpduDensity_Proc},
- {"HtBaWinSize", Set_HtBaWinSize_Proc},
- {"HtRdg", Set_HtRdg_Proc},
- {"HtAmsdu", Set_HtAmsdu_Proc},
- {"HtAutoBa", Set_HtAutoBa_Proc},
- {"HtBaDecline", Set_BADecline_Proc},
- {"HtProtect", Set_HtProtect_Proc},
- {"HtMimoPs", Set_HtMimoPs_Proc},
-#endif // DOT11_N_SUPPORT //
-
-#ifdef AGGREGATION_SUPPORT
- {"PktAggregate", Set_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
- {"WmmCapable", Set_WmmCapable_Proc},
-#endif
- {"IEEE80211H", Set_IEEE80211H_Proc},
- {"NetworkType", Set_NetworkType_Proc},
- {"AuthMode", Set_AuthMode_Proc},
- {"EncrypType", Set_EncrypType_Proc},
- {"DefaultKeyID", Set_DefaultKeyID_Proc},
- {"Key1", Set_Key1_Proc},
- {"Key2", Set_Key2_Proc},
- {"Key3", Set_Key3_Proc},
- {"Key4", Set_Key4_Proc},
- {"WPAPSK", Set_WPAPSK_Proc},
- {"ResetCounter", Set_ResetStatCounter_Proc},
- {"PSMode", Set_PSMode_Proc},
-#ifdef DBG
- {"Debug", Set_Debug_Proc},
-#endif
-
-#ifdef RALINK_ATE
- {"ATE", Set_ATE_Proc},
- {"ATEDA", Set_ATE_DA_Proc},
- {"ATESA", Set_ATE_SA_Proc},
- {"ATEBSSID", Set_ATE_BSSID_Proc},
- {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
- {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
- {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
- {"ATETXANT", Set_ATE_TX_Antenna_Proc},
- {"ATERXANT", Set_ATE_RX_Antenna_Proc},
- {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
- {"ATETXBW", Set_ATE_TX_BW_Proc},
- {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
- {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
- {"ATETXMCS", Set_ATE_TX_MCS_Proc},
- {"ATETXMODE", Set_ATE_TX_MODE_Proc},
- {"ATETXGI", Set_ATE_TX_GI_Proc},
- {"ATERXFER", Set_ATE_RX_FER_Proc},
- {"ATERRF", Set_ATE_Read_RF_Proc},
- {"ATEWRF1", Set_ATE_Write_RF1_Proc},
- {"ATEWRF2", Set_ATE_Write_RF2_Proc},
- {"ATEWRF3", Set_ATE_Write_RF3_Proc},
- {"ATEWRF4", Set_ATE_Write_RF4_Proc},
- {"ATELDE2P", Set_ATE_Load_E2P_Proc},
- {"ATERE2P", Set_ATE_Read_E2P_Proc},
- {"ATESHOW", Set_ATE_Show_Proc},
- {"ATEHELP", Set_ATE_Help_Proc},
-
-#ifdef RALINK_28xx_QA
- {"TxStop", Set_TxStop_Proc},
- {"RxStop", Set_RxStop_Proc},
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- {"WpaSupport", Set_Wpa_Support},
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
- {"FixedTxMode", Set_FixedTxMode_Proc},
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- {"OpMode", Set_OpMode_Proc},
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-#ifdef DOT11_N_SUPPORT
- {"TGnWifiTest", Set_TGnWifiTest_Proc},
- {"ForceGF", Set_ForceGF_Proc},
-#endif // DOT11_N_SUPPORT //
-#ifdef QOS_DLS_SUPPORT
- {"DlsAddEntry", Set_DlsAddEntry_Proc},
- {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
-#endif // QOS_DLS_SUPPORT //
- {"LongRetry", Set_LongRetryLimit_Proc},
- {"ShortRetry", Set_ShortRetryLimit_Proc},
-#ifdef EXT_BUILD_CHANNEL_LIST
- {"11dClientMode", Set_Ieee80211dClientMode_Proc},
-#endif // EXT_BUILD_CHANNEL_LIST //
-#ifdef CARRIER_DETECTION_SUPPORT
- {"CarrierDetect", Set_CarrierDetect_Proc},
-#endif // CARRIER_DETECTION_SUPPORT //
-
- {NULL,}
-};
-
-
-VOID RTMPAddKey(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_802_11_KEY pKey)
-{
- ULONG KeyIdx;
- MAC_TABLE_ENTRY *pEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- if (pKey->KeyIndex & 0x80000000)
- {
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- NdisZeroMemory(pAd->StaCfg.PMK, 32);
- NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
- goto end;
- }
- // Update PTK
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else
- {
- // Update GTK
- pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else // dynamic WEP from wpa_supplicant
- {
- UCHAR CipherAlg;
- PUCHAR Key;
-
- if(pKey->KeyLength == 32)
- goto end;
-
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
-
- if (KeyIdx < 4)
- {
- // it is a default shared key, for Pairwise key setting
- if (pKey->KeyIndex & 0x80000000)
- {
- pEntry = MacTableLookup(pAd, pKey->BSSID);
-
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
-
- // set key material and key length
- pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // set Cipher type
- if (pKey->KeyLength == 5)
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
- else
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
-
- // Add Pair-wise key to Asic
- AsicAddPairwiseKeyEntry(
- pAd,
- pEntry->Addr,
- (UCHAR)pEntry->Aid,
- &pEntry->PairwiseKey);
-
- // update WCID attribute table and IVEIV table for this entry
- RTMPAddWcidAttributeEntry(
- pAd,
- BSS0,
- KeyIdx, // The value may be not zero
- pEntry->PairwiseKey.CipherAlg,
- pEntry);
-
- }
- }
- else
- {
- // Default key for tx (shared key)
- pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-
- // set key material and key length
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // Set Ciper type
- if (pKey->KeyLength == 5)
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
- else
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- Key = pAd->SharedKey[BSS0][KeyIdx].Key;
-
- // Set Group key material to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
-
- }
- }
- }
-end:
- return;
-}
-
-char * rtstrchr(const char * s, int c)
-{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *) s;
-}
-
-/*
-This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
-*/
-
-int
-rt_ioctl_giwname(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
-// PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
-#ifdef RT2870
- strncpy(name, "RT2870 Wireless", IFNAMSIZ);
-#endif // RT2870 //
- return 0;
-}
-
-int rt_ioctl_siwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- int chan = -1;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
-
- if (freq->e > 1)
- return -EINVAL;
-
- if((freq->e == 0) && (freq->m <= 1000))
- chan = freq->m; // Setting by channel number
- else
- MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
-
- if (ChannelSanity(pAdapter, chan) == TRUE)
- {
- pAdapter->CommonCfg.Channel = chan;
- DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
- }
- else
- return -EINVAL;
-
- return 0;
-}
-int rt_ioctl_giwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter = NULL;
- UCHAR ch;
- ULONG m;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- ch = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
-
- MAP_CHANNEL_ID_TO_KHZ(ch, m);
- freq->m = m * 100;
- freq->e = 1;
- return 0;
-}
-
-int rt_ioctl_siwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (*mode)
- {
- case IW_MODE_ADHOC:
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- break;
- case IW_MODE_INFRA:
- Set_NetworkType_Proc(pAdapter, "Infra");
- break;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- case IW_MODE_MONITOR:
- Set_NetworkType_Proc(pAdapter, "Monitor");
- break;
-#endif
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
- return -EINVAL;
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- return 0;
-}
-
-int rt_ioctl_giwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (ADHOC_ON(pAdapter))
- *mode = IW_MODE_ADHOC;
- else if (INFRA_ON(pAdapter))
- *mode = IW_MODE_INFRA;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- else if (MONITOR_ON(pAdapter))
- {
- *mode = IW_MODE_MONITOR;
- }
-#endif
- else
- *mode = IW_MODE_AUTO;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
- return 0;
-}
-
-int rt_ioctl_siwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- return 0;
-}
-
-int rt_ioctl_giwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- return 0;
-}
-
-int rt_ioctl_giwrange(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- struct iw_range *range = (struct iw_range *) extra;
- u16 val;
- int i;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
- data->length = sizeof(struct iw_range);
- memset(range, 0, sizeof(struct iw_range));
-
- range->txpower_capa = IW_TXPOW_DBM;
-
- if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
- {
- range->min_pmp = 1 * 1024;
- range->max_pmp = 65535 * 1024;
- range->min_pmt = 1 * 1024;
- range->max_pmt = 1000 * 1024;
- range->pmp_flags = IW_POWER_PERIOD;
- range->pmt_flags = IW_POWER_TIMEOUT;
- range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
- IW_POWER_UNICAST_R | IW_POWER_ALL_R;
- }
-
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = 14;
-
- range->retry_capa = IW_RETRY_LIMIT;
- range->retry_flags = IW_RETRY_LIMIT;
- range->min_retry = 0;
- range->max_retry = 255;
-
- range->num_channels = pAdapter->ChannelListNum;
-
- val = 0;
- for (i = 1; i <= range->num_channels; i++)
- {
- u32 m;
- range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
- range->freq[val].m = m * 100; /* HZ */
-
- range->freq[val].e = 1;
- val++;
- if (val == IW_MAX_FREQUENCIES)
- break;
- }
- range->num_frequency = val;
-
- range->max_qual.qual = 100; /* what is correct max? This was not
- * documented exactly. At least
- * 69 has been observed. */
- range->max_qual.level = 0; /* dB */
- range->max_qual.noise = 0; /* dB */
-
- /* What would be suitable values for "average/typical" qual? */
- range->avg_qual.qual = 20;
- range->avg_qual.level = -60;
- range->avg_qual.noise = -95;
- range->sensitivity = 3;
-
- range->max_encoding_tokens = NR_WEP_KEYS;
- range->num_encoding_sizes = 2;
- range->encoding_size[0] = 5;
- range->encoding_size[1] = 13;
-
- range->min_rts = 0;
- range->max_rts = 2347;
- range->min_frag = 256;
- range->max_frag = 2346;
-
-#if WIRELESS_EXT > 17
- /* IW_ENC_CAPA_* bit field */
- range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
- IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-#endif
-
- return 0;
-}
-
-int rt_ioctl_siwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- NDIS_802_11_MAC_ADDRESS Bssid;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- memset(Bssid, 0, MAC_ADDR_LEN);
- memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
-
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
-
- return 0;
-}
-
-int rt_ioctl_giwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
- return -ENOTCONN;
- }
-
- return 0;
-}
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a. These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- * drivers for compatibility
- */
-static void set_quality(PRTMP_ADAPTER pAdapter,
- struct iw_quality *iq,
- signed char rssi)
-{
- __u8 ChannelQuality;
-
- // Normalize Rssi
- if (rssi >= -50)
- ChannelQuality = 100;
- else if (rssi >= -80) // between -50 ~ -80dbm
- ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
- else if (rssi >= -90) // between -80 ~ -90dbm
- ChannelQuality = (__u8)((rssi + 90) * 26)/10;
- else
- ChannelQuality = 0;
-
- iq->qual = (__u8)ChannelQuality;
-
- iq->level = (__u8)(rssi);
- iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
- iq->noise += 256 - 143;
- iq->updated = pAdapter->iw_stats.qual.updated;
-}
-
-int rt_ioctl_iwaplist(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- struct sockaddr addr[IW_MAX_AP];
- struct iw_quality qual[IW_MAX_AP];
- int i;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- data->length = 0;
- return 0;
- //return -ENETDOWN;
- }
-
- for (i = 0; i <IW_MAX_AP ; i++)
- {
- if (i >= pAdapter->ScanTab.BssNr)
- break;
- addr[i].sa_family = ARPHRD_ETHER;
- memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
- }
- data->length = i;
- memcpy(extra, &addr, i*sizeof(addr[0]));
- data->flags = 1; /* signal quality present (sort of) */
- memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
-
- return 0;
-}
-
-#ifdef SIOCGIWSCAN
-int rt_ioctl_siwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- ULONG Now;
- int Status = NDIS_STATUS_SUCCESS;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- return -EINVAL;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount++;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- return 0;
- do{
- Now = jiffies;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
- (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- RT28XX_MLME_HANDLER(pAdapter);
- }while(0);
- return 0;
-}
-
-int rt_ioctl_giwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
-
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- int i=0;
- char *current_ev = extra, *previous_ev = extra;
- char *end_buf;
- char *current_val, custom[MAX_CUSTOM_LEN] = {0};
-#ifndef IWEVGENIE
- char idx;
-#endif // IWEVGENIE //
- struct iw_event iwe;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- return -EAGAIN;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount = 0;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if (pAdapter->ScanTab.BssNr == 0)
- {
- data->length = 0;
- return 0;
- }
-
-#if WIRELESS_EXT >= 17
- if (data->length > 0)
- end_buf = extra + data->length;
- else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#endif
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- if (current_ev >= end_buf)
- {
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //MAC address
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //ESSID
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
- iwe.u.data.flags = 1;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Network Type
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWMODE;
- if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
- {
- iwe.u.mode = IW_MODE_ADHOC;
- }
- else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
- {
- iwe.u.mode = IW_MODE_INFRA;
- }
- else
- {
- iwe.u.mode = IW_MODE_AUTO;
- }
- iwe.len = IW_EV_UINT_LEN;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Channel and Frequency
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWFREQ;
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- else
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- iwe.u.freq.e = 0;
- iwe.u.freq.i = 0;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Add quality statistics
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.level = 0;
- iwe.u.qual.noise = 0;
- set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
- current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Encyption key
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWENCODE;
- if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
- iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
-
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Bit Rate
- //================================
- if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
- {
- UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWRATE;
- current_val = current_ev + IW_EV_LCP_LEN;
- if (tmpRate == 0x82)
- iwe.u.bitrate.value = 1 * 1000000;
- else if (tmpRate == 0x84)
- iwe.u.bitrate.value = 2 * 1000000;
- else if (tmpRate == 0x8B)
- iwe.u.bitrate.value = 5.5 * 1000000;
- else if (tmpRate == 0x96)
- iwe.u.bitrate.value = 11 * 1000000;
- else
- iwe.u.bitrate.value = (tmpRate/2) * 1000000;
-
- iwe.u.bitrate.disabled = 0;
- current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
- current_val, end_buf, &iwe,
- IW_EV_PARAM_LEN);
-
- if((current_val-current_ev)>IW_EV_LCP_LEN)
- current_ev = current_val;
- else
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
-#ifdef IWEVGENIE
- //WPA IE
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#else
- //WPA IE
- //================================
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "wpa_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "rsn_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#endif // IWEVGENIE //
- }
-
- data->length = current_ev - extra;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
- return 0;
-}
-#endif
-
-int rt_ioctl_siwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->flags)
- {
- PCHAR pSsidString = NULL;
-
- // Includes null character.
- if (data->length > (IW_ESSID_MAX_SIZE + 1))
- return -E2BIG;
-
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, essid, data->length);
- if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
- return -EINVAL;
- }
- else
- return -ENOMEM;
- }
- else
- {
- // ANY ssid
- if (Set_SSID_Proc(pAdapter, "") == FALSE)
- return -EINVAL;
- }
- return 0;
-}
-
-int rt_ioctl_giwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- data->flags = 1;
- if (MONITOR_ON(pAdapter))
- {
- data->length = 0;
- return 0;
- }
-
- if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#ifdef RT2870
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // RT2870 //
- else
- {//the ANY ssid was specified
- data->length = 0;
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
- }
-
- return 0;
-
-}
-
-int rt_ioctl_siwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->length > IW_ESSID_MAX_SIZE)
- return -EINVAL;
-
- memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
- memcpy(pAdapter->nickname, nickname, data->length);
-
-
- return 0;
-}
-
-int rt_ioctl_giwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (data->length > strlen(pAdapter->nickname) + 1)
- data->length = strlen(pAdapter->nickname) + 1;
- if (data->length > 0) {
- memcpy(nickname, pAdapter->nickname, data->length-1);
- nickname[data->length-1] = '\0';
- }
- return 0;
-}
-
-int rt_ioctl_siwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (rts->disabled)
- val = MAX_RTS_THRESHOLD;
- else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
- return -EINVAL;
- else if (rts->value == 0)
- val = MAX_RTS_THRESHOLD;
- else
- val = rts->value;
-
- if (val != pAdapter->CommonCfg.RtsThreshold)
- pAdapter->CommonCfg.RtsThreshold = val;
-
- return 0;
-}
-
-int rt_ioctl_giwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- rts->value = pAdapter->CommonCfg.RtsThreshold;
- rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
- rts->fixed = 1;
-
- return 0;
-}
-
-int rt_ioctl_siwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (frag->disabled)
- val = MAX_FRAG_THRESHOLD;
- else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
- val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
- else if (frag->value == 0)
- val = MAX_FRAG_THRESHOLD;
- else
- return -EINVAL;
-
- pAdapter->CommonCfg.FragmentThreshold = val;
- return 0;
-}
-
-int rt_ioctl_giwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- frag->value = pAdapter->CommonCfg.FragmentThreshold;
- frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
- frag->fixed = 1;
-
- return 0;
-}
-
-#define MAX_WEP_KEY_SIZE 13
-#define MIN_WEP_KEY_SIZE 5
-int rt_ioctl_siwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_DISABLED))
- {
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
- else if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- if (erq->flags & IW_ENCODE_RESTRICTED)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
-
- if (erq->length > 0)
- {
- int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
- /* Check the size of the key */
- if (erq->length > MAX_WEP_KEY_SIZE) {
- return -EINVAL;
- }
- /* Check key index */
- if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
- keyIdx, pAdapter->StaCfg.DefaultKeyId));
-
- //Using default key
- keyIdx = pAdapter->StaCfg.DefaultKeyId;
- }
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
-
- if (erq->length == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (erq->length == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- /* Disable the key */
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-
- /* Check if the key is not marked as invalid */
- if(!(erq->flags & IW_ENCODE_NOKEY)) {
- /* Copy the key in the driver */
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
- }
- }
- else
- {
- /* Do we want to just set the transmit key index ? */
- int index = (erq->flags & IW_ENCODE_INDEX) - 1;
- if ((index >= 0) && (index < 4))
- {
- pAdapter->StaCfg.DefaultKeyId = index;
- }
- else
- /* Don't complain if only change the mode */
- if(!erq->flags & IW_ENCODE_MODE) {
- return -EINVAL;
- }
- }
-
-done:
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
- return 0;
-}
-
-int
-rt_ioctl_giwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *key)
-{
- int kid;
- PRTMP_ADAPTER pAdapter = NULL;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- if (pVirtualAd && pVirtualAd->RtmpDev)
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- kid = erq->flags & IW_ENCODE_INDEX;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
-
- if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
- {
- erq->length = 0;
- erq->flags = IW_ENCODE_DISABLED;
- }
- else if ((kid > 0) && (kid <=4))
- {
- // copy wep key
- erq->flags = kid ; /* NB: base 1 */
- if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
- erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
- //if ((kid == pAdapter->PortCfg.DefaultKeyId))
- //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
-
- }
- else if (kid == 0)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
- // copy default key ID
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
- erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- }
-
- return 0;
-
-}
-
-static int
-rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
- void *w, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter;
- POS_COOKIE pObj;
- char *this_char = extra;
- char *value;
- int Status=0;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->priv;
- }
- else
- {
- pVirtualAd = dev->priv;
- pAdapter = pVirtualAd->RtmpDev->priv;
- }
- pObj = (POS_COOKIE) pAdapter->OS_Cookie;
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (!*this_char)
- return -EINVAL;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value)
- return -EINVAL;
-
- // reject setting nothing besides ANY ssid(ssidLen=0)
- if (!*value && (strcmp(this_char, "SSID") != 0))
- return -EINVAL;
-
- for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
- {
- if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
- {
- if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
- { //FALSE:Set private failed then return Invalid argument
- Status = -EINVAL;
- }
- break; //Exit for loop.
- }
- }
-
- if(PRTMP_PRIVATE_SET_PROC->name == NULL)
- { //Not found argument
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
- }
-
- return Status;
-}
-
-
-static int
-rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n\n");
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- }
- sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
-
- sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
- sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
-
- sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if (pAd->ate.RxAntennaSel == 0)
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
- else
- {
- sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- }
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
-
- return Status;
-}
-
-#ifdef DOT11_N_SUPPORT
-void getBaInfo(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pOutBuf)
-{
- INT i, j;
- BA_ORI_ENTRY *pOriBAEntry;
- BA_REC_ENTRY *pRecBAEntry;
-
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
- if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
- {
- sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
- pOutBuf,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
-
- sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BARecWcidArray[j] != 0)
- {
- pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
- }
- }
- sprintf(pOutBuf, "%s\n", pOutBuf);
-
- sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BAOriWcidArray[j] != 0)
- {
- pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
- }
- }
- sprintf(pOutBuf, "%s\n\n", pOutBuf);
- }
- if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
- break;
- }
-
- return;
-}
-#endif // DOT11_N_SUPPORT //
-
-static int
-rt_private_show(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
- u32 subcmd = wrq->flags;
-
- if (dev->priv_flags == INT_MAIN)
- pAd = dev->priv;
- else
- {
- pVirtualAd = dev->priv;
- pAd = pVirtualAd->RtmpDev->priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(subcmd)
- {
-
- case SHOW_CONN_STATUS:
- if (MONITOR_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAd->CommonCfg.RegTransmitSetting.field.BW)
- sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
- else
-#endif // DOT11_N_SUPPORT //
- sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
- }
- else
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- if (INFRA_ON(pAd))
- {
- sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
- pAd->CommonCfg.Ssid,
- pAd->CommonCfg.Bssid[0],
- pAd->CommonCfg.Bssid[1],
- pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],
- pAd->CommonCfg.Bssid[4],
- pAd->CommonCfg.Bssid[5]);
- DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
- }
- else if (ADHOC_ON(pAd))
- sprintf(extra, "Connected\n");
- }
- else
- {
- sprintf(extra, "Disconnected\n");
- DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
- }
- }
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case SHOW_DRVIER_VERION:
- sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#ifdef DOT11_N_SUPPORT
- case SHOW_BA_INFO:
- getBaInfo(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#endif // DOT11_N_SUPPORT //
- case SHOW_DESC_INFO:
- {
- Show_DescInfo_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
- case RAIO_OFF:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = FALSE;
- if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == FALSE)
- {
- MlmeRadioOff(pAd);
- // Update extra information
- pAd->ExtraInfo = SW_RADIO_OFF;
- }
- }
- sprintf(extra, "Radio Off\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case RAIO_ON:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = TRUE;
- //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAd);
- // Update extra information
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- }
- sprintf(extra, "Radio On\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case SHOW_DLS_ENTRY_INFO:
- {
- Set_DlsEntryInfo_Display_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
-#endif // QOS_DLS_SUPPORT //
-
- case SHOW_CFG_VALUE:
- {
- Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
- if (Status == 0)
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- }
- break;
- case SHOW_ADHOC_ENTRY_INFO:
- Show_Adhoc_MacTable_Proc(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
- break;
- }
-
- return Status;
-}
-
-#ifdef SIOCSIWMLME
-int rt_ioctl_siwmlme(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
- MLME_QUEUE_ELEM MsgElem;
- MLME_DISASSOC_REQ_STRUCT DisAssocReq;
- MLME_DEAUTH_REQ_STRUCT DeAuthReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
-
- if (pMlme == NULL)
- return -EINVAL;
-
- switch(pMlme->cmd)
- {
-#ifdef IW_MLME_DEAUTH
- case IW_MLME_DEAUTH:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
- COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
- DeAuthReq.Reason = pMlme->reason_code;
- MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
- MlmeDeauthReqAction(pAd, &MsgElem);
- if (INFRA_ON(pAd))
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- break;
-#endif // IW_MLME_DEAUTH //
-#ifdef IW_MLME_DISASSOC
- case IW_MLME_DISASSOC:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
- COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
- DisAssocReq.Reason = pMlme->reason_code;
-
- MsgElem.Machine = ASSOC_STATE_MACHINE;
- MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
- MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
- MlmeDisassocReqAction(pAd, &MsgElem);
- break;
-#endif // IW_MLME_DISASSOC //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
- break;
- }
-
- return 0;
-}
-#endif // SIOCSIWMLME //
-
-#if WIRELESS_EXT > 17
-int rt_ioctl_siwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_WPA_VERSION:
- if (param->value == IW_AUTH_WPA_VERSION_WPA)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- }
- else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_CIPHER_GROUP:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_KEY_MGMT:
- if (param->value == IW_AUTH_KEY_MGMT_802_1X)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- else
- // WEP 1x
- pAdapter->StaCfg.IEEE8021X = TRUE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == 0)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- break;
- case IW_AUTH_PRIVACY_INVOKED:
- /*if (param->value == 0)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }*/
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_DROP_UNENCRYPTED:
- if (param->value != 0)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_80211_AUTH_ALG:
- if (param->value & IW_AUTH_ALG_SHARED_KEY)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- }
- else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- }
- else
- return -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
- break;
- case IW_AUTH_WPA_ENABLED:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
- break;
- default:
- return -EOPNOTSUPP;
-}
-
- return 0;
-}
-
-int rt_ioctl_giwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_DROP_UNENCRYPTED:
- param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
- param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
- break;
-
- case IW_AUTH_WPA_ENABLED:
- param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
- break;
-
- default:
- return -EOPNOTSUPP;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
- return 0;
-}
-
-void fnSetCipherKey(
- IN PRTMP_ADAPTER pAdapter,
- IN INT keyIdx,
- IN UCHAR CipherAlg,
- IN BOOLEAN bGTK,
- IN struct iw_encode_ext *ext)
-{
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- pAdapter->SharedKey[BSS0][keyIdx].Key,
- pAdapter->SharedKey[BSS0][keyIdx].TxMic,
- pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-
- if (bGTK)
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- NULL);
- else
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- &pAdapter->MacTab.Content[BSSID_WCID]);
-}
-
-int rt_ioctl_siwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
- {
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int keyIdx, alg = ext->alg;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (encoding->flags & IW_ENCODE_DISABLED)
- {
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- // set BSSID wcid entry of the Pair-wise Key table as no-security mode
- AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
- }
- else
- {
- // Get Key Index and convet to our own defined key index
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- return -EINVAL;
-
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- pAdapter->StaCfg.DefaultKeyId = keyIdx;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
- }
-
- switch (alg) {
- case IW_ENCODE_ALG_NONE:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
- break;
- case IW_ENCODE_ALG_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
- if (ext->key_len == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (ext->key_len == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- return -EINVAL;
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
- break;
- case IW_ENCODE_ALG_TKIP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
- if (ext->key_len == 32)
- {
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else
- return -EINVAL;
- break;
- case IW_ENCODE_ALG_CCMP:
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- break;
- default:
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-int
-rt_ioctl_giwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- PCHAR pKey = NULL;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int idx, max_key_len;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
-
- max_key_len = encoding->length - sizeof(*ext);
- if (max_key_len < 0)
- return -EINVAL;
-
- idx = encoding->flags & IW_ENCODE_INDEX;
- if (idx)
- {
- if (idx < 1 || idx > 4)
- return -EINVAL;
- idx--;
-
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
- {
- if (idx != pAd->StaCfg.DefaultKeyId)
- {
- ext->key_len = 0;
- return 0;
- }
- }
- }
- else
- idx = pAd->StaCfg.DefaultKeyId;
-
- encoding->flags = idx + 1;
- memset(ext, 0, sizeof(*ext));
-
- ext->key_len = 0;
- switch(pAd->StaCfg.WepStatus) {
- case Ndis802_11WEPDisabled:
- ext->alg = IW_ENCODE_ALG_NONE;
- encoding->flags |= IW_ENCODE_DISABLED;
- break;
- case Ndis802_11WEPEnabled:
- ext->alg = IW_ENCODE_ALG_WEP;
- if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
- return -E2BIG;
- else
- {
- ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
- pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
- }
- break;
- case Ndis802_11Encryption2Enabled:
- case Ndis802_11Encryption3Enabled:
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
- ext->alg = IW_ENCODE_ALG_TKIP;
- else
- ext->alg = IW_ENCODE_ALG_CCMP;
-
- if (max_key_len < 32)
- return -E2BIG;
- else
- {
- ext->key_len = 32;
- pKey = &pAd->StaCfg.PMK[0];
- }
- break;
- default:
- return -EINVAL;
- }
-
- if (ext->key_len && pKey)
- {
- encoding->flags |= IW_ENCODE_ENABLED;
- memcpy(ext->key, pKey, ext->key_len);
- }
-
- return 0;
-}
-
-#ifdef SIOCSIWGENIE
-int rt_ioctl_siwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
-
- if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
- (wrqu->data.length && extra == NULL))
- return -EINVAL;
-
- if (wrqu->data.length)
- {
- pAd->StaCfg.RSNIE_Len = wrqu->data.length;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
- }
- else
- {
- pAd->StaCfg.RSNIE_Len = 0;
- NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
- }
-
- return 0;
-}
-#endif // SIOCSIWGENIE //
-
-int rt_ioctl_giwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
-
- if ((pAd->StaCfg.RSNIE_Len == 0) ||
- (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
- {
- wrqu->data.length = 0;
- return 0;
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
- return -E2BIG;
-
- wrqu->data.length = pAd->StaCfg.RSNIE_Len;
- memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
- else
-#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- UCHAR RSNIe = IE_WPA;
-
- if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
- return -E2BIG;
- wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- RSNIe = IE_RSN;
-
- extra[0] = (char)RSNIe;
- extra[1] = pAd->StaCfg.RSNIE_Len;
- memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
-
- return 0;
-}
-
-int rt_ioctl_siwpmksa(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
- INT CachedIdx = 0, idx = 0;
-
- if (pPmksa == NULL)
- return -EINVAL;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
- switch(pPmksa->cmd)
- {
- case IW_PMKSA_FLUSH:
- NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
- break;
- case IW_PMKSA_REMOVE:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- {
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
- for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
- {
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
- }
- pAd->StaCfg.SavedPMKNum--;
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
- break;
- case IW_PMKSA_ADD:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- pAd->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
- break;
- }
-
- return 0;
-}
-#endif // #if WIRELESS_EXT > 17
-
-#ifdef DBG
-static int
-rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
- {
- CHAR *this_char;
- CHAR *value = NULL;
- UCHAR regBBP = 0;
-// CHAR arg[255]={0};
- UINT32 bbpId;
- UINT32 bbpValue;
- BOOLEAN bIsPrintAllBBP = FALSE;
- INT Status = 0;
- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
-
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- if (wrq->length > 1) //No parameters.
- {
- sprintf(extra, "\n");
-
- //Parsing Read or Write
- this_char = wrq->pointer;
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
- if (sscanf(this_char, "%d", &(bbpId)) == 1)
- {
- if (bbpId <= 136)
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Write
- if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
- {
- if (bbpId <= 136)
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- }
- else
- bIsPrintAllBBP = TRUE;
-
-next:
- if (bIsPrintAllBBP)
- {
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n");
- for (bbpId = 0; bbpId <= 136; bbpId++)
- {
- if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
- break;
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
- if (bbpId%5 == 4)
- sprintf(extra+strlen(extra), "\n");
- }
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
-
- return Status;
-}
-#endif // DBG //
-
-int rt_ioctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
- /* rate = -1 => auto rate
- rate = X, fixed = 1 => (fixed rate X)
- */
- if (rate == -1)
- {
- //Auto Rate
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, -1);
-
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- else
- {
- if (fixed)
- {
- pAd->StaCfg.bAutoTxRateSwitch = FALSE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, rate);
- else
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
- }
- else
- {
- // TODO: rate = X, fixed = 0 => (rates <= X)
- return -EOPNOTSUPP;
- }
- }
-
- return 0;
-}
-
-int rt_ioctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
- int rate_index = 0, rate_count = 0;
- HTTRANSMIT_SETTING ht_setting;
- __s32 ralinkrate[] =
- {2, 4, 11, 22, // CCK
- 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
- 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
- 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
- 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
- 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
- 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
- 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
- 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
- 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
-
- rate_count = sizeof(ralinkrate)/sizeof(__s32);
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
- (INFRA_ON(pAd)) &&
- ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
- ht_setting.word = pAd->StaCfg.HTPhyMode.word;
- else
- ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-
-#ifdef DOT11_N_SUPPORT
- if (ht_setting.field.MODE >= MODE_HTMIX)
- {
-// rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
- rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (ht_setting.field.MODE == MODE_OFDM)
- rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
- else if (ht_setting.field.MODE == MODE_CCK)
- rate_index = (UCHAR)(ht_setting.field.MCS);
-
- if (rate_index < 0)
- rate_index = 0;
-
- if (rate_index > rate_count)
- rate_index = rate_count;
-
- wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
- wrqu->bitrate.disabled = 0;
-
- return 0;
-}
-
-static const iw_handler rt_handler[] =
-{
- (iw_handler) NULL, /* SIOCSIWCOMMIT */
- (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
- (iw_handler) NULL, /* SIOCSIWNWID */
- (iw_handler) NULL, /* SIOCGIWNWID */
- (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
- (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
- (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
- (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
- (iw_handler) NULL, /* SIOCSIWSENS */
- (iw_handler) NULL, /* SIOCGIWSENS */
- (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
- (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
- (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
- (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
- (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
- (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
- (iw_handler) NULL, /* SIOCSIWSPY */
- (iw_handler) NULL, /* SIOCGIWSPY */
- (iw_handler) NULL, /* SIOCSIWTHRSPY */
- (iw_handler) NULL, /* SIOCGIWTHRSPY */
- (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
- (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
-#ifdef SIOCSIWMLME
- (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
-#else
- (iw_handler) NULL, /* SIOCSIWMLME */
-#endif // SIOCSIWMLME //
- (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
-#ifdef SIOCGIWSCAN
- (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
- (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
-#else
- (iw_handler) NULL, /* SIOCSIWSCAN */
- (iw_handler) NULL, /* SIOCGIWSCAN */
-#endif /* SIOCGIWSCAN */
- (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
- (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
- (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
- (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
- (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
- (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
- (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
- (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
- (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
- (iw_handler) NULL, /* SIOCSIWTXPOW */
- (iw_handler) NULL, /* SIOCGIWTXPOW */
- (iw_handler) NULL, /* SIOCSIWRETRY */
- (iw_handler) NULL, /* SIOCGIWRETRY */
- (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
- (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
- (iw_handler) NULL, /* SIOCSIWPOWER */
- (iw_handler) NULL, /* SIOCGIWPOWER */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
-#if WIRELESS_EXT > 17
- (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
- (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
- (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
- (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
- (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
- (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
- (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
-#endif
-};
-
-static const iw_handler rt_priv_handlers[] = {
- (iw_handler) NULL, /* + 0x00 */
- (iw_handler) NULL, /* + 0x01 */
-#ifndef CONFIG_AP_SUPPORT
- (iw_handler) rt_ioctl_setparam, /* + 0x02 */
-#else
- (iw_handler) NULL, /* + 0x02 */
-#endif // CONFIG_AP_SUPPORT //
-#ifdef DBG
- (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
-#else
- (iw_handler) NULL, /* + 0x03 */
-#endif
- (iw_handler) NULL, /* + 0x04 */
- (iw_handler) NULL, /* + 0x05 */
- (iw_handler) NULL, /* + 0x06 */
- (iw_handler) NULL, /* + 0x07 */
- (iw_handler) NULL, /* + 0x08 */
- (iw_handler) rt_private_get_statistics, /* + 0x09 */
- (iw_handler) NULL, /* + 0x0A */
- (iw_handler) NULL, /* + 0x0B */
- (iw_handler) NULL, /* + 0x0C */
- (iw_handler) NULL, /* + 0x0D */
- (iw_handler) NULL, /* + 0x0E */
- (iw_handler) NULL, /* + 0x0F */
- (iw_handler) NULL, /* + 0x10 */
- (iw_handler) rt_private_show, /* + 0x11 */
- (iw_handler) NULL, /* + 0x12 */
- (iw_handler) NULL, /* + 0x13 */
- (iw_handler) NULL, /* + 0x15 */
- (iw_handler) NULL, /* + 0x17 */
- (iw_handler) NULL, /* + 0x18 */
-};
-
-const struct iw_handler_def rt28xx_iw_handler_def =
-{
-#define N(a) (sizeof (a) / sizeof (a[0]))
- .standard = (iw_handler *) rt_handler,
- .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
- .private = (iw_handler *) rt_priv_handlers,
- .num_private = N(rt_priv_handlers),
- .private_args = (struct iw_priv_args *) privtab,
- .num_private_args = N(privtab),
-#if IW_HANDLER_VERSION >= 7
- .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif
-};
-
-INT RTMPSetInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_MAC_ADDRESS Bssid;
- RT_802_11_PHY_MODE PhyMode;
- RT_802_11_STA_CONFIG StaConfig;
- NDIS_802_11_RATES aryRates;
- RT_802_11_PREAMBLE Preamble;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- PNDIS_802_11_KEY pKey = NULL;
- PNDIS_802_11_WEP pWepKey =NULL;
- PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
- NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
- NDIS_802_11_NETWORK_TYPE NetType;
- ULONG Now;
- UINT KeyIdx = 0;
- INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
- ULONG PowerTemp;
- BOOLEAN RadioState;
- BOOLEAN StateMachineTouched = FALSE;
-#ifdef DOT11_N_SUPPORT
- OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
- PNDIS_802_11_PMKID pPmkId = NULL;
- BOOLEAN IEEE8021xState = FALSE;
- BOOLEAN IEEE8021x_required_keys = FALSE;
- UCHAR wpa_supplicant_enable = 0;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef SNMP_SUPPORT
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR ctmp;
-#endif // SNMP_SUPPORT //
-
-
-
-#ifdef DOT11_N_SUPPORT
- MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
- switch(cmd & 0x7FFF) {
- case RT_OID_802_11_COUNTRY_REGION:
- if (wrq->u.data.length < sizeof(UCHAR))
- Status = -EINVAL;
- // Only avaliable when EEPROM not programming
- else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
- {
- ULONG Country;
- UCHAR TmpPhy;
-
- Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
- pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
- TmpPhy = pAdapter->CommonCfg.PhyMode;
- pAdapter->CommonCfg.PhyMode = 0xff;
- // Build all corresponding channel information
- RTMPSetPhyMode(pAdapter, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
- pAdapter->CommonCfg.CountryRegion));
- }
- break;
- case OID_802_11_BSSID_LIST_SCAN:
- #ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- Now = jiffies;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- break;
- }
-
- //Benson add 20080527, when radio off, sta don't need to scan
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
- break;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
- break;
- case OID_802_11_SSID:
- if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
- Status = -EINVAL;
- else
- {
- PCHAR pSsidString = NULL;
- Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- if (Ssid.SsidLength > MAX_LEN_OF_SSID)
- Status = -EINVAL;
- else
- {
- if (Ssid.SsidLength == 0)
- {
- Set_SSID_Proc(pAdapter, "");
- }
- else
- {
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
- Set_SSID_Proc(pAdapter, pSsidString);
- kfree(pSsidString);
- }
- else
- Status = -ENOMEM;
- }
- }
- }
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- }
- break;
- case RT_OID_802_11_RADIO:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
- if (pAdapter->StaCfg.bSwRadio != RadioState)
- {
- pAdapter->StaCfg.bSwRadio = RadioState;
- if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
- {
- pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
- if (pAdapter->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- else
- {
- MlmeRadioOff(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = SW_RADIO_OFF;
- }
- }
- }
- }
- break;
- case RT_OID_802_11_PHY_MODE:
- if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PhyMode <= MaxPhyMode)
- {
- RTMPSetPhyMode(pAdapter, PhyMode);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
- }
- break;
- case RT_OID_802_11_STA_CONFIG:
- if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
- pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
- pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
- if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
- (StaConfig.AdhocMode <= MaxPhyMode))
- {
- // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
- // if setting changed, need to reset current TX rate as well as BEACON frame format
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- {
- pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
- RTMPSetPhyMode(pAdapter, PhyMode);
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- MakeIbssBeacon(pAdapter); // re-build BEACON frame
- AsicEnableIbssSync(pAdapter); // copy to on-chip memory
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
- pAdapter->CommonCfg.bEnableTxBurst,
- pAdapter->CommonCfg.UseBGProtection,
- pAdapter->CommonCfg.bUseShortSlotTime));
- }
- break;
- case OID_802_11_DESIRED_RATES:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
- NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
- pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
- pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
- pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
- pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
- // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- }
- break;
- case RT_OID_802_11_PREAMBLE:
- if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
- if (Preamble == Rt802_11PreambleShort)
- {
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
- }
- else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
- {
- // if user wants AUTO, initialize to LONG here, then change according to AP's
- // capability upon association.
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
- }
- break;
- case OID_802_11_WEP_STATUS:
- if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
- // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
- if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
- {
- if (pAdapter->StaCfg.WepStatus != WepStatus)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.WepStatus = WepStatus;
- pAdapter->StaCfg.OrigWepStatus = WepStatus;
- pAdapter->StaCfg.PairCipher = WepStatus;
- pAdapter->StaCfg.GroupCipher = WepStatus;
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
- }
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
- if (AuthMode > Ndis802_11AuthModeMax)
- {
- Status = -EINVAL;
- break;
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode != AuthMode)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.AuthMode = AuthMode;
- }
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
- }
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (BssType == Ndis802_11IBSS)
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- else if (BssType == Ndis802_11Infrastructure)
- Set_NetworkType_Proc(pAdapter, "Infra");
- else if (BssType == Ndis802_11Monitor)
- Set_NetworkType_Proc(pAdapter, "Monitor");
- else
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
- }
- }
- break;
- case OID_802_11_REMOVE_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
- if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
- {
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx >= 4){
- Status = -EINVAL;
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- }
- }
- }
- break;
- case RT_OID_802_11_RESET_COUNTERS:
- NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
- NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
- NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
- pAdapter->Counters8023.RxNoBuffer = 0;
- pAdapter->Counters8023.GoodReceives = 0;
- pAdapter->Counters8023.RxNoBuffer = 0;
-#ifdef RT2870
- pAdapter->BulkOutComplete = 0;
- pAdapter->BulkOutCompleteOther= 0;
- pAdapter->BulkOutCompleteCancel = 0;
- pAdapter->BulkOutReq = 0;
- pAdapter->BulkInReq= 0;
- pAdapter->BulkInComplete = 0;
- pAdapter->BulkInCompleteFail = 0;
-#endif // RT2870 //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
- break;
- case OID_802_11_RTS_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
- if (RtsThresh > MAX_RTS_THRESHOLD)
- Status = -EINVAL;
- else
- pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- {
- if (FragThresh == 0)
- {
- pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
- }
- else
- Status = -EINVAL;
- }
- else
- pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerMode == Ndis802_11PowerModeCAM)
- Set_PSMode_Proc(pAdapter, "CAM");
- else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
- Set_PSMode_Proc(pAdapter, "Max_PSP");
- else if (PowerMode == Ndis802_11PowerModeFast_PSP)
- Set_PSMode_Proc(pAdapter, "Fast_PSP");
- else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
- Set_PSMode_Proc(pAdapter, "Legacy_PSP");
- else
- Status = -EINVAL;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- if (wrq->u.data.length < sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerTemp > 100)
- PowerTemp = 0xffffffff; // AUTO
- pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
- pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- }
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (NetType == Ndis802_11DS)
- RTMPSetPhyMode(pAdapter, PHY_11B);
- else if (NetType == Ndis802_11OFDM24)
- RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
- else if (NetType == Ndis802_11OFDM5)
- RTMPSetPhyMode(pAdapter, PHY_11A);
- else
- Status = -EINVAL;
-#ifdef DOT11_N_SUPPORT
- if (Status == NDIS_STATUS_SUCCESS)
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
- }
- break;
- // For WPA PSK PMK key
- case RT_OID_802_11_ADD_WPA:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
- }
- else
- {
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
- {
- Status = -EOPNOTSUPP;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
- }
- else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
- {
- NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
- // Use RaConfig as PSK agent.
- // Start STA supplicant state machine
- if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- pAdapter->StaCfg.WpaState = SS_START;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- else
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- }
- kfree(pKey);
- break;
- case OID_802_11_REMOVE_KEY:
- pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pRemoveKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pRemoveKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
- }
- else
- {
- KeyIdx = pRemoveKey->KeyIndex;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx > 3)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
- }
- }
- }
- }
- kfree(pRemoveKey);
- break;
- // New for WPA
- case OID_802_11_ADD_KEY:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
- }
- else
- {
- RTMPAddKey(pAdapter, pKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- kfree(pKey);
- break;
- case OID_802_11_CONFIGURATION:
- if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
- pConfig = &Config;
-
- if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
- pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
-
- pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
- MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
- //
- // Save the channel on MlmeAux for CntlOidRTBssidProc used.
- //
- pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
- pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- break;
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_HT_PHYMODE:
- if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
- Status = -EINVAL;
- else
- {
- POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
-
- Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
- pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
- pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- RTMPSetHT(pAdapter, pHTPhyMode);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
- pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
- pAdapter->StaCfg.HTPhyMode.field.STBC));
- break;
-#endif // DOT11_N_SUPPORT //
- case RT_OID_802_11_SET_APSD_SETTING:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- ULONG apsd ;
- Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
-
- /*-------------------------------------------------------------------
- |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
- ---------------------------------------------------------------------
- | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
- ---------------------------------------------------------------------*/
- pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
- pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
- pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
- }
- break;
-
- case RT_OID_802_11_SET_APSD_PSM:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- // Driver needs to notify AP when PSM changes
- Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
- if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
- {
- MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
- RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- }
- break;
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
- Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
- if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
- {
- int i;
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- }
- break;
-
- case RT_OID_802_11_SET_DLS_PARAM:
- if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
- Status = -EINVAL;
- else
- {
- RT_802_11_DLS Dls;
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- case RT_OID_802_11_SET_WMM:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
- }
- break;
-
- case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- //
- // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
- // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
- // when query OID_802_11_BSSID_LIST.
- //
- // TRUE: NumberOfItems will set to 0.
- // FALSE: NumberOfItems no change.
- //
- pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
- // Set to immediately send the media disconnect event
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
-
- if (INFRA_ON(pAdapter))
- {
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_DISASSOCIATE,
- 0,
- NULL);
-
- StateMachineTouched = TRUE;
- }
- break;
-
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_IMME_BA_CAP:
- if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
- Status = -EINVAL;
- else
- {
- OID_BACAP_STRUC Orde ;
- Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
- if (Orde.Policy > BA_NOTUSE)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- }
- else if (Orde.Policy == BA_NOTUSE)
- {
- pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
- }
- else
- {
- pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
- pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-
- if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
-
- }
-
- pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
- }
-
- break;
- case RT_OID_802_11_ADD_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- UCHAR index;
- OID_ADD_BA_ENTRY BA;
- MAC_TABLE_ENTRY *pEntry;
-
- Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
- if (BA.TID > 15)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
- else
- {
- //BATableInsertEntry
- //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
- index = BA.TID;
- // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
- pEntry = MacTableLookup(pAdapter, BA.MACAddr);
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
- break;
- }
- if (BA.IsRecipient == FALSE)
- {
- if (pEntry->bIAmBadAtheros == TRUE)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
-
- BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
- }
- else
- {
- //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
- BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
- , BA.MACAddr[4], BA.MACAddr[5]));
- }
- }
- break;
-
- case RT_OID_802_11_TEAR_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- POID_ADD_BA_ENTRY pBA;
- MAC_TABLE_ENTRY *pEntry;
-
- pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if (pBA == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
- Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
-
- if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
-
- if (pBA->IsRecipient == FALSE)
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
- BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- else
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- if (pEntry)
- {
- BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- kfree(pBA);
- }
- }
- break;
-#endif // DOT11_N_SUPPORT //
-
- // For WPA_SUPPLICANT to set static wep key
- case OID_802_11_ADD_WEP:
- pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pWepKey == NULL)
- {
- Status = -ENOMEM;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
- break;
- }
- Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
- if (Status)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
- }
- else
- {
- KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
- // KeyIdx must be 0 ~ 3
- if (KeyIdx > 4)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
- }
- else
- {
- UCHAR CipherAlg = 0;
- PUCHAR Key;
-
- // set key material and key length
- NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
-
- switch(pWepKey->KeyLength)
- {
- case 5:
- CipherAlg = CIPHER_WEP64;
- break;
- case 13:
- CipherAlg = CIPHER_WEP128;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
- Status = -EINVAL;
- break;
- }
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
-
- // Default key for tx (shared key)
- if (pWepKey->KeyIndex & 0x80000000)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- // set key material and key length
- NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
- pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-#endif // WPA_SUPPLICANT_SUPPORT //
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
-#endif // WPA_SUPPLICANT_SUPPORT
- {
- Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- if (pWepKey->KeyIndex & 0x80000000)
- {
- PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
- }
- }
- kfree(pWepKey);
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case OID_SET_COUNTERMEASURES:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.bBlockAssoc = TRUE;
- else
- // WPA MIC error should block association attempt for 60 seconds
- pAdapter->StaCfg.bBlockAssoc = FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- }
- break;
- case OID_802_11_DEAUTHENTICATION:
- if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
- Status = -EINVAL;
- else
- {
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
- Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
- MlmeDeauthReqAction(pAdapter, MsgElem);
- kfree(MsgElem);
-
- if (INFRA_ON(pAdapter))
- {
- LinkDown(pAdapter, FALSE);
- pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
- }
- break;
- case OID_802_11_DROP_UNENCRYPTED:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- NdisAcquireSpinLock(&pAdapter->MacTabLock);
- pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAdapter->MacTabLock);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
- }
- break;
- case OID_802_11_SET_IEEE8021X:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
- }
- break;
- case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
- }
- break;
- case OID_802_11_PMKID:
- pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pPmkId == NULL) {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
-
- // check the PMKID information
- if (pPmkId->BSSIDInfoCount == 0)
- NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- else
- {
- PBSSID_INFO pBssIdInfo;
- UINT BssIdx;
- UINT CachedIdx;
-
- for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
- {
- // point to the indexed BSSID_INFO structure
- pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
- // Find the entry in the saved data base.
- for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- pAdapter->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- }
- }
- }
- if(pPmkId)
- kfree(pPmkId);
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
-#ifdef SNMP_SUPPORT
- case OID_802_11_SHORTRETRYLIMIT:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
- }
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
- }
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
- pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- //pKey = &WepKey;
-
- if ( pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
- }
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
- DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
-
- // it is a shared key
- if (KeyIdx > 4)
- Status = -EINVAL;
- else
- {
- pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
- if (pKey->KeyIndex & 0x80000000)
- {
- // Default key for tx (shared key)
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
- //RestartAPIsRequired = TRUE;
- }
- break;
-
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
-
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
-
- break;
-
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
- sprintf(&ctmp,"%d", ctmp);
- Set_Channel_Proc(pAdapter, &ctmp);
- }
- break;
-#endif
-
-
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
-
- return Status;
-}
-
-INT RTMPQueryInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
- PNDIS_WLAN_BSSID_EX pBss;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
- RT_802_11_LINK_STATUS *pLinkStatus = NULL;
- RT_802_11_STA_CONFIG *pStaConfig = NULL;
- NDIS_802_11_STATISTICS *pStatistics = NULL;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- RT_802_11_PREAMBLE PreamType;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_MEDIA_STATE MediaState;
- ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
- USHORT BssLen = 0;
- PUCHAR pBuf = NULL, pPtr;
- INT Status = NDIS_STATUS_SUCCESS;
- UINT we_version_compiled;
- UCHAR i, Padding = 0;
- BOOLEAN RadioState;
- UCHAR driverVersion[8];
- OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
-
-
-#ifdef SNMP_SUPPORT
- //for snmp, kathy
- DefaultKeyIdxValue *pKeyIdxValue;
- INT valueLen;
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR tmp[64];
-#endif //SNMP
-
- switch(cmd)
- {
- case RT_OID_DEVICE_NAME:
- wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
- Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
- break;
- case RT_OID_VERSION_INFO:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
- wrq->u.data.length = 8*sizeof(UCHAR);
- sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
- driverVersion[7] = '\0';
- if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#ifdef RALINK_ATE
- case RT_QUERY_ATE_TXDONE_COUNT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
- wrq->u.data.length = sizeof(UINT32);
- if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#endif // RALINK_ATE //
- case OID_802_11_BSSID_LIST:
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
- return -EAGAIN;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- // Claculate total buffer size required
- BssBufSize = sizeof(ULONG);
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- // Align pointer to 4 bytes boundary.
- //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
- //if (Padding == 4)
- // Padding = 0;
- BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
- }
-
- // For safety issue, we add 256 bytes just in case
- BssBufSize += 256;
- // Allocate the same size as passed from higher layer
- pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
- if(pBuf == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- // Init 802_11_BSSID_LIST_EX structure
- NdisZeroMemory(pBuf, BssBufSize);
- pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
- pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
-
- // Calculate total buffer length
- BssLen = 4; // Consist of NumberOfItems
- // Point to start of NDIS_WLAN_BSSID_EX
- // pPtr = pBuf + sizeof(ULONG);
- pPtr = (PUCHAR) &pBssidList->Bssid[0];
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
- NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
- {
- //
- // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
- // and then failed to send EAPOl farame.
- //
- if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- else
- pBss->Ssid.SsidLength = 0;
- }
- else
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
- pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
- pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
- pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
- pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
- pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
-
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
-
- if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
- pBss->InfrastructureMode = Ndis802_11Infrastructure;
- else
- pBss->InfrastructureMode = Ndis802_11IBSS;
-
- NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
- NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
- pAdapter->ScanTab.BssEntry[i].ExtRate,
- pAdapter->ScanTab.BssEntry[i].ExtRateLen);
-
- if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
- {
- pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- }
- else
- {
- pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
- }
- pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
-
-#if WIRELESS_EXT < 17
- if ((BssLen + pBss->Length) < wrq->u.data.length)
- BssLen += pBss->Length;
- else
- {
- pBssidList->NumberOfItems = i;
- break;
- }
-#else
- BssLen += pBss->Length;
-#endif
- }
-
-#if WIRELESS_EXT < 17
- wrq->u.data.length = BssLen;
-#else
- if (BssLen > wrq->u.data.length)
- {
- kfree(pBssidList);
- return -E2BIG;
- }
- else
- wrq->u.data.length = BssLen;
-#endif
- Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
- kfree(pBssidList);
- break;
- case OID_802_3_CURRENT_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
- case OID_GEN_MEDIA_CONNECT_STATUS:
- if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
- MediaState = NdisMediaStateConnected;
- else
- MediaState = NdisMediaStateDisconnected;
-
- wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
- Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-#endif // RALINK_ATE //
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
- Status = -ENOTCONN;
- }
- break;
- case OID_802_11_SSID:
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
- Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
- memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
- wrq->u.data.length = sizeof(NDIS_802_11_SSID);
- Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
- break;
- case RT_OID_802_11_QUERY_LINK_STATUS:
- pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
- if (pLinkStatus)
- {
- pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
- pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
- pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
- pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
- pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
- wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
- Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
- kfree(pLinkStatus);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_CONFIGURATION:
- pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
- if (pConfiguration)
- {
- pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
- pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
- pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
- wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
- Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
- pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
- kfree(pConfiguration);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_SNR_0:
- if ((pAdapter->StaCfg.LastSNR0 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
- }
- else
- Status = -EFAULT;
- break;
- case RT_OID_802_11_SNR_1:
- if ((pAdapter->Antenna.field.RxPath > 1) &&
- (pAdapter->StaCfg.LastSNR1 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
- }
- else
- Status = -EFAULT;
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
- break;
- case OID_802_11_RSSI_TRIGGER:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
- break;
- case OID_802_11_RSSI:
- case RT_OID_802_11_RSSI:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_1:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_2:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_802_11_STATISTICS:
- pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
- if (pStatistics)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
- // add the most up-to-date h/w raw counters into software counters
- NICUpdateRawCounters(pAdapter);
-
- // Sanity check for calculation of sucessful count
- if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
- pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
-
- pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
- pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
- pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
- pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
- pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
- pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
- pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
- pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
- pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
- pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
- pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
-#ifdef DBG
- pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
-#else
- pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
- pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
-#endif
- wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
- Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
- kfree(pStatistics);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_GEN_RCV_OK:
- ulInfo = pAdapter->Counters8023.GoodReceives;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_GEN_RCV_NO_BUFFER:
- ulInfo = pAdapter->Counters8023.RxNoBuffer;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_PHY_MODE:
- ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_STA_CONFIG:
- pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
- if (pStaConfig)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
- pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
- pStaConfig->EnableTurboRate = 0;
- pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
- pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
- //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
- pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
- pStaConfig->Rsv1 = 0;
- pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
- wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
- Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
- kfree(pStaConfig);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_RTS_THRESHOLD:
- RtsThresh = pAdapter->CommonCfg.RtsThreshold;
- wrq->u.data.length = sizeof(RtsThresh);
- Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- FragThresh = pAdapter->CommonCfg.FragmentThreshold;
- if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
- FragThresh = 0;
- wrq->u.data.length = sizeof(FragThresh);
- Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- PowerMode = pAdapter->StaCfg.WindowsPowerMode;
- wrq->u.data.length = sizeof(PowerMode);
- Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
- break;
- case RT_OID_802_11_RADIO:
- RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
- wrq->u.data.length = sizeof(RadioState);
- Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- BssType = Ndis802_11IBSS;
- else if (pAdapter->StaCfg.BssType == BSS_INFRA)
- BssType = Ndis802_11Infrastructure;
- else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
- BssType = Ndis802_11Monitor;
- else
- BssType = Ndis802_11AutoUnknown;
-
- wrq->u.data.length = sizeof(BssType);
- Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
- break;
- case RT_OID_802_11_PREAMBLE:
- PreamType = pAdapter->CommonCfg.TxPreamble;
- wrq->u.data.length = sizeof(PreamType);
- Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- AuthMode = pAdapter->StaCfg.AuthMode;
- wrq->u.data.length = sizeof(AuthMode);
- Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
- break;
- case OID_802_11_WEP_STATUS:
- WepStatus = pAdapter->StaCfg.WepStatus;
- wrq->u.data.length = sizeof(WepStatus);
- Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
- break;
- case OID_802_11_TX_POWER_LEVEL:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- break;
- case OID_802_11_NETWORK_TYPES_SUPPORTED:
- if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
- {
- NetworkTypeList[0] = 3; // NumberOfItems = 3
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
- wrq->u.data.length = 16;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- else
- {
- NetworkTypeList[0] = 2; // NumberOfItems = 2
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- wrq->u.data.length = 12;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- wrq->u.data.length = sizeof(ULONG);
- if (pAdapter->CommonCfg.PhyMode == PHY_11A)
- ulInfo = Ndis802_11OFDM5;
- else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
- ulInfo = Ndis802_11OFDM24;
- else
- ulInfo = Ndis802_11DS;
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_LAST_RX_RATE:
- ulInfo = (ULONG)pAdapter->LastRxRate;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_LAST_TX_RATE:
- //ulInfo = (ULONG)pAdapter->LastTxRate;
- ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_EEPROM_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_NOISE_LEVEL:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
- break;
- case RT_OID_802_11_EXTRA_INFO:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
- break;
- case RT_OID_WE_VERSION_COMPILED:
- wrq->u.data.length = sizeof(UINT);
- we_version_compiled = WIRELESS_EXT;
- Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_APSD_SETTING:
- apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
- | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
-
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
- apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
- break;
- case RT_OID_802_11_QUERY_APSD_PSM:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- break;
- case RT_OID_802_11_QUERY_WMM:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case RT_OID_NEW_DRIVER:
- {
- UCHAR enabled = 1;
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- case RT_OID_DRIVER_DEVICE_NAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
- wrq->u.data.length = 16;
- if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
-
- pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_COUNTRY_REGION:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
- wrq->u.data.length = sizeof(ulInfo);
- ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
- ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
- if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
-
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- i = 0;
-#ifdef MULTIPLE_CARD_SUPPORT
- i = 1;
-#endif // MULTIPLE_CARD_SUPPORT //
- if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
- break;
-#ifdef SNMP_SUPPORT
- case RT_OID_802_11_MAC_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREROUI:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
- wrq->u.data.length = ManufacturerOUI_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTURERNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_RESOURCETYPEIDNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
- wrq->u.data.length = strlen(ResourceTypeIdName);
- Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
- ulInfo = 1; // 1 is support wep else 2 is not support.
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_POWERMANAGEMENTMODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
- if (pAdapter->StaCfg.Psm == PSMP_ACTION)
- ulInfo = 1; // 1 is power active else 2 is power save.
- else
- ulInfo = 2;
-
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
- //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
- pKeyIdxValue = wrq->u.data.pointer;
- DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
- valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- NdisMoveMemory(pKeyIdxValue->Value,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
- valueLen);
- pKeyIdxValue->Value[valueLen]='\0';
-
- wrq->u.data.length = sizeof(DefaultKeyIdxValue);
-
- Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- pAdapter->SharedKey[BSS0][0].Key[0],
- pAdapter->SharedKey[BSS0][1].Key[0],
- pAdapter->SharedKey[BSS0][2].Key[0],
- pAdapter->SharedKey[BSS0][3].Key[0]));
- break;
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
- break;
-
- case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- wrq->u.data.length);
- break;
-
- case OID_802_11_SHORTRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRODUCTID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
-
-#ifdef RT2870
- sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
-
-#endif // RT2870 //
- wrq->u.data.length = strlen(tmp);
- Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
- wrq->u.data.length = sizeof(UCHAR);
- DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-#endif //SNMP_SUPPORT
-
- case OID_802_11_BUILD_CHANNEL_EX:
- {
- UCHAR value;
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
- wrq->u.data.length = sizeof(UCHAR);
-#ifdef EXT_BUILD_CHANNEL_LIST
- DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 1;
-#else
- DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 0;
-#endif // EXT_BUILD_CHANNEL_LIST //
- Status = copy_to_user(wrq->u.data.pointer, &value, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- }
- break;
-
- case OID_802_11_GET_CH_LIST:
- {
- PRT_CHANNEL_LIST_INFO pChListBuf;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
- if (pAdapter->ChannelListNum == 0)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
- if (pChListBuf == NULL)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
- for (i = 0; i < pChListBuf->ChannelListNum; i++)
- pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
-
- wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-
- if (pChListBuf)
- kfree(pChListBuf);
- }
- break;
-
- case OID_802_11_GET_COUNTRY_CODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
- wrq->u.data.length = 2;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
- case OID_802_11_GET_CHANNEL_GEOGRAPHY:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
- wrq->u.data.length = 1;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_QUERY_DLS:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- break;
-
- case RT_OID_802_11_QUERY_DLS_PARAM:
- {
- PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
- if (pDlsInfo == NULL)
- break;
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
- }
-
- pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
- wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
-
- if (pDlsInfo)
- kfree(pDlsInfo);
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
- return Status;
-}
-
-INT rt28xx_sta_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- POS_COOKIE pObj;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- RTMP_ADAPTER *pAd = NULL;
- struct iwreq *wrq = (struct iwreq *) rq;
- BOOLEAN StateMachineTouched = FALSE;
- INT Status = NDIS_STATUS_SUCCESS;
- USHORT subcmd;
-
- if (net_dev->priv_flags == INT_MAIN)
- {
- pAd = net_dev->priv;
- }
- else
- {
- pVirtualAd = net_dev->priv;
- pAd = pVirtualAd->RtmpDev->priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (wrq->u.data.pointer == NULL)
- {
- return Status;
- }
-
- if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- }
-
- { // determine this ioctl command is comming from which interface.
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(cmd)
- {
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
- case RTPRIV_IOCTL_ATE:
- {
- RtmpDoAte(pAd, wrq);
- }
- break;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
- case SIOCGIFHWADDR:
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
- memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
- break;
- case SIOCGIWNAME:
- {
- char *name=&wrq->u.name[0];
- rt_ioctl_giwname(net_dev, NULL, name, NULL);
- break;
- }
- case SIOCGIWESSID: //Get ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWESSID: //Set ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWNWID: // set network id (the cell)
- case SIOCGIWNWID: // get network id
- Status = -EOPNOTSUPP;
- break;
- case SIOCSIWFREQ: //set channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCGIWFREQ: // get channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCSIWNICKN: //set node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWNICKN: //get node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWRATE: //get default bit rate (bps)
- rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCSIWRATE: //set default bit rate (bps)
- rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCGIWFRAG: //get fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCSIWFRAG: //set fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCGIWENCODE: //get encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCSIWENCODE: //set encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCGIWAP: //get access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCSIWAP: //set access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCGIWMODE: //get operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCSIWMODE: //set operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCGIWSENS: //get sensitivity (dBm)
- case SIOCSIWSENS: //set sensitivity (dBm)
- case SIOCGIWPOWER: //get Power Management settings
- case SIOCSIWPOWER: //set Power Management settings
- case SIOCGIWTXPOW: //get transmit power (dBm)
- case SIOCSIWTXPOW: //set transmit power (dBm)
- case SIOCGIWRANGE: //Get range of parameters
- case SIOCGIWRETRY: //get retry limits and lifetime
- case SIOCSIWRETRY: //set retry limits and lifetime
- Status = -EOPNOTSUPP;
- break;
- case RT_PRIV_IOCTL:
- subcmd = wrq->u.data.flags;
- if( subcmd & OID_GET_SET_TOGGLE)
- Status = RTMPSetInformation(pAd, rq, subcmd);
- else
- Status = RTMPQueryInformation(pAd, rq, subcmd);
- break;
- case SIOCGIWPRIV:
- if (wrq->u.data.pointer)
- {
- if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
- break;
- wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
- if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
- Status = -EFAULT;
- }
- break;
- case RTPRIV_IOCTL_SET:
- if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
- break;
- rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
- break;
- case RTPRIV_IOCTL_GSITESURVEY:
- RTMPIoctlGetSiteSurvey(pAd, wrq);
- break;
-#ifdef DBG
- case RTPRIV_IOCTL_MAC:
- RTMPIoctlMAC(pAd, wrq);
- break;
- case RTPRIV_IOCTL_E2P:
- RTMPIoctlE2PROM(pAd, wrq);
- break;
-#endif // DBG //
- case SIOCETHTOOL:
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
- if(StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAd);
-
- return Status;
-}
-
-/*
- ==========================================================================
- Description:
- Set SSID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- NDIS_802_11_SSID Ssid, *pSsid=NULL;
- BOOLEAN StateMachineTouched = FALSE;
- int success = TRUE;
-
- if( strlen(arg) <= MAX_LEN_OF_SSID)
- {
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- if (strlen(arg) != 0)
- {
- NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
- Ssid.SsidLength = strlen(arg);
- }
- else //ANY ssid
- {
- Ssid.SsidLength = 0;
- memcpy(Ssid.Ssid, "", 0);
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
- }
- pSsid = &Ssid;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- pAdapter->bConfigChanged = TRUE;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_SSID,
- sizeof(NDIS_802_11_SSID),
- (VOID *)pSsid);
-
- StateMachineTouched = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- }
- else
- success = FALSE;
-
- if (StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAdapter);
-
- return success;
-}
-
-#ifdef WMM_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WmmCapable Enable or Disable
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN bWmmCapable;
-
- bWmmCapable = simple_strtol(arg, 0, 10);
-
- if ((bWmmCapable == 1)
-#ifdef RT2870
- && (pAd->NumberOfPipes >= 5)
-#endif // RT2870 //
- )
- pAd->CommonCfg.bWmmCapable = TRUE;
- else if (bWmmCapable == 0)
- pAd->CommonCfg.bWmmCapable = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
- pAd->CommonCfg.bWmmCapable));
-
- return TRUE;
-}
-#endif // WMM_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Set Network Type(Infrastructure/Adhoc mode)
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UINT32 Value = 0;
-
- if (strcmp(arg, "Adhoc") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_ADHOC)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (INFRA_ON(pAdapter))
- {
- //BOOLEAN Cancelled;
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
- }
- }
- pAdapter->StaCfg.BssType = BSS_ADHOC;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
- }
- else if (strcmp(arg, "Infra") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_INFRA)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (ADHOC_ON(pAdapter))
- {
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
- }
- }
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
-
- pAdapter->StaCfg.BssType = BSS_INFRA;
- }
- else if (strcmp(arg, "Monitor") == 0)
- {
- UCHAR bbpValue = 0;
- BCN_TIME_CFG_STRUC csr;
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- // disable all periodic state machine
- pAdapter->StaCfg.bAutoReconnect = FALSE;
- // reset all mlme state machine
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
- if (pAdapter->CommonCfg.CentralChannel == 0)
- {
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
- pAdapter->CommonCfg.CentralChannel = 36;
- else
-#endif // DOT11_N_SUPPORT //
- pAdapter->CommonCfg.CentralChannel = 6;
- }
-#ifdef DOT11_N_SUPPORT
- else
- N_ChannelCheck(pAdapter);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
- {
- // 40MHz ,control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- // RX : control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
-
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value &= 0xfffffffe;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
- {
- // 40MHz ,control channel at upper
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value |= 0x1;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue |= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // 20MHz
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_20;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
- }
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
- // ASIC supporsts sniffer function with replacing RSSI with timestamp.
- //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- //Value |= (0x80);
- //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- // disable sync
- RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
- csr.field.bBeaconGen = 0;
- csr.field.bTBTTEnable = 0;
- csr.field.TsfSyncMode = 0;
- RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-
- pAdapter->StaCfg.BssType = BSS_MONITOR;
- pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Authentication mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
- else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
- else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- return FALSE;
-
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Encryption Type
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- else
- return FALSE;
-
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Default Key ID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- ULONG KeyIdx;
-
- KeyIdx = simple_strtol(arg, 0, 10);
- if((KeyIdx >= 1 ) && (KeyIdx <= 4))
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WEP KEY1
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
-
- pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 0,
- pAdapter->SharedKey[BSS0][0].CipherAlg,
- pAdapter->SharedKey[BSS0][0].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
-
- Description:
- Set WEP KEY2
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 1,
- pAdapter->SharedKey[BSS0][1].CipherAlg,
- pAdapter->SharedKey[BSS0][1].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY3
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 2,
- pAdapter->SharedKey[BSS0][2].CipherAlg,
- pAdapter->SharedKey[BSS0][2].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY4
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 3,
- pAdapter->SharedKey[BSS0][3].CipherAlg,
- pAdapter->SharedKey[BSS0][3].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WPA PSK key
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UCHAR keyMaterial[40];
-
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- )
- return TRUE; // do nothing
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
-
- NdisZeroMemory(keyMaterial, 40);
-
- if ((strlen(arg) < 8) || (strlen(arg) > 64))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
- return FALSE;
- }
-
- if (strlen(arg) == 64)
- {
- AtoH(arg, keyMaterial, 32);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-
- }
- else
- {
- PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
- }
-
-
-
- if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
- pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- }
- else
- {
- // Start STA supplicant state machine
- pAdapter->StaCfg.WpaState = SS_START;
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Power Saving mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (pAdapter->StaCfg.BssType == BSS_INFRA)
- {
- if ((strcmp(arg, "Max_PSP") == 0) ||
- (strcmp(arg, "max_psp") == 0) ||
- (strcmp(arg, "MAX_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- pAdapter->StaCfg.DefaultListenCount = 5;
-
- }
- else if ((strcmp(arg, "Fast_PSP") == 0) ||
- (strcmp(arg, "fast_psp") == 0) ||
- (strcmp(arg, "FAST_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else if ((strcmp(arg, "Legacy_PSP") == 0) ||
- (strcmp(arg, "legacy_psp") == 0) ||
- (strcmp(arg, "LEGACY_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else
- {
- //Default Ndis802_11PowerModeCAM
- // clear PSM bit immediately
- MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
- }
- else
- return FALSE;
-
-
- return TRUE;
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WpaSupport flag.
- Value:
- 0: Driver ignore wpa_supplicant.
- 1: wpa_supplicant initiates scanning and AP selection.
- 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- if ( simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
- else if ( simple_strtol(arg, 0, 10) == 1)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
- else if ( simple_strtol(arg, 0, 10) == 2)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
- else
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
-
- return TRUE;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-/*
- ==========================================================================
- Description:
- Read / Write MAC
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
- 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
- ==========================================================================
-*/
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- ULONG macAddr = 0;
- UCHAR temp[16], temp2[16];
- UINT32 macValue = 0;
- INT Status;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // Mac Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
- if (macAddr < 0xFFFF)
- {
- RTMP_IO_READ32(pAdapter, macAddr, &macValue);
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[8-k+j] = temp2[j];
- }
-
- while(k < 8)
- temp2[7-k++]='0';
- temp2[8]='\0';
-
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 4);
- macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
-
- // debug mode
- if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
- {
- // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
- if (macValue & 0x000000ff)
- {
- pAdapter->BbpTuning.bEnable = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
- }
- else
- {
- UCHAR R66;
- pAdapter->BbpTuning.bEnable = FALSE;
- R66 = 0x26 + GET_LNA_GAIN(pAdapter);
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
- }
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
-
- RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
- }
- }
- }
-next:
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
-}
-
-/*
- ==========================================================================
- Description:
- Read / Write E2PROM
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
- 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
- ==========================================================================
-*/
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- USHORT eepAddr = 0;
- UCHAR temp[16], temp2[16];
- USHORT eepValue;
- int Status;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
-
-
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
-
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // E2PROM addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
- if (eepAddr < 0xFFFF)
- {
- RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[4-k+j] = temp2[j];
- }
-
- while(k < 4)
- temp2[3-k++]='0';
- temp2[4]='\0';
-
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 2);
- eepValue = *temp*256 + temp[1];
-
- RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
- }
- }
-next:
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
-}
-#endif // DBG //
-
-
-
-
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.bTGnWifiTest = FALSE;
- else
- pAd->StaCfg.bTGnWifiTest = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
- return TRUE;
-}
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
- else if (simple_strtol(arg, 0, 10) == 1)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
- else if (simple_strtol(arg, 0, 10) == 2)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
- else
- return FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
- return TRUE;
-}
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
- return TRUE;
-}
-#endif // CARRIER_DETECTION_SUPPORT //
-
-
-INT Show_Adhoc_MacTable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PCHAR extra)
-{
- INT i;
-
- sprintf(extra, "\n");
-
-#ifdef DOT11_N_SUPPORT
- sprintf(extra, "%sHT Operating Mode : %d\n", extra, pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
-#endif // DOT11_N_SUPPORT //
-
- sprintf(extra, "%s\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", extra,
- "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
-
- if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
- break;
- if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- {
- sprintf(extra, "%s%02X:%02X:%02X:%02X:%02X:%02X ", extra,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- sprintf(extra, "%s%-4d", extra, (int)pEntry->Aid);
- sprintf(extra, "%s%-4d", extra, (int)pEntry->apidx);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi0);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi1);
- sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi2);
- sprintf(extra, "%s%-10s", extra, GetPhyMode(pEntry->HTPhyMode.field.MODE));
- sprintf(extra, "%s%-6s", extra, GetBW(pEntry->HTPhyMode.field.BW));
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.MCS);
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.ShortGI);
- sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.STBC);
- sprintf(extra, "%s%-10d, %d, %d%%\n", extra, pEntry->DebugFIFOCount, pEntry->DebugTxCount,
- (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
- sprintf(extra, "%s\n", extra);
- }
- }
-
- return TRUE;
-}
-
-
diff --git a/drivers/staging/rt2870/wpa.h b/drivers/staging/rt2870/wpa.h
index 0134ae6097cf..712507224146 100644
--- a/drivers/staging/rt2870/wpa.h
+++ b/drivers/staging/rt2870/wpa.h
@@ -1,357 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- wpa.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-
-#ifndef __WPA_H__
-#define __WPA_H__
-
-// EAPOL Key descripter frame format related length
-#define LEN_KEY_DESC_NONCE 32
-#define LEN_KEY_DESC_IV 16
-#define LEN_KEY_DESC_RSC 8
-#define LEN_KEY_DESC_ID 8
-#define LEN_KEY_DESC_REPLAY 8
-#define LEN_KEY_DESC_MIC 16
-
-// The length is the EAPoL-Key frame except key data field.
-// Please refer to 802.11i-2004 ,Figure 43u in p.78
-#define LEN_EAPOL_KEY_MSG (sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)
-
-// EAP Code Type.
-#define EAP_CODE_REQUEST 1
-#define EAP_CODE_RESPONSE 2
-#define EAP_CODE_SUCCESS 3
-#define EAP_CODE_FAILURE 4
-
-// EAPOL frame Protocol Version
-#define EAPOL_VER 1
-#define EAPOL_VER2 2
-
-// EAPOL-KEY Descriptor Type
-#define WPA1_KEY_DESC 0xfe
-#define WPA2_KEY_DESC 0x02
-
-// Key Descriptor Version of Key Information
-#define DESC_TYPE_TKIP 1
-#define DESC_TYPE_AES 2
-#define DESC_TYPE_MESH 3
-
-#define LEN_MSG1_2WAY 0x7f
-#define MAX_LEN_OF_EAP_HS 256
-
-#define LEN_MASTER_KEY 32
-
-// EAPOL EK, MK
-#define LEN_EAP_EK 16
-#define LEN_EAP_MICK 16
-#define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK))
-// TKIP key related
-#define LEN_PMKID 16
-#define LEN_TKIP_EK 16
-#define LEN_TKIP_RXMICK 8
-#define LEN_TKIP_TXMICK 8
-#define LEN_AES_EK 16
-#define LEN_AES_KEY LEN_AES_EK
-#define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK))
-#define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
-#define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
-#define MIN_LEN_OF_GTK 5
-
-// RSN IE Length definition
-#define MAX_LEN_OF_RSNIE 90
-#define MIN_LEN_OF_RSNIE 8
-
-//EAP Packet Type
-#define EAPPacket 0
-#define EAPOLStart 1
-#define EAPOLLogoff 2
-#define EAPOLKey 3
-#define EAPOLASFAlert 4
-#define EAPTtypeMax 5
-
-#define EAPOL_MSG_INVALID 0
-#define EAPOL_PAIR_MSG_1 1
-#define EAPOL_PAIR_MSG_2 2
-#define EAPOL_PAIR_MSG_3 3
-#define EAPOL_PAIR_MSG_4 4
-#define EAPOL_GROUP_MSG_1 5
-#define EAPOL_GROUP_MSG_2 6
-
-#define PAIRWISEKEY 1
-#define GROUPKEY 0
-
-// Retry timer counter initial value
-#define PEER_MSG1_RETRY_TIMER_CTR 0
-#define PEER_MSG3_RETRY_TIMER_CTR 10
-#define GROUP_MSG1_RETRY_TIMER_CTR 20
-
-
-#define EAPOL_START_DISABLE 0
-#define EAPOL_START_PSK 1
-#define EAPOL_START_1X 2
-
-#define MIX_CIPHER_WPA_TKIP_ON(x) (((x) & 0x08) != 0)
-#define MIX_CIPHER_WPA_AES_ON(x) (((x) & 0x04) != 0)
-#define MIX_CIPHER_WPA2_TKIP_ON(x) (((x) & 0x02) != 0)
-#define MIX_CIPHER_WPA2_AES_ON(x) (((x) & 0x01) != 0)
-
-#define ROUND_UP(__x, __y) \
- (((ULONG)((__x)+((__y)-1))) & ((ULONG)~((__y)-1)))
-
-#define ADD_ONE_To_64BIT_VAR(_V) \
-{ \
- UCHAR cnt = LEN_KEY_DESC_REPLAY; \
- do \
- { \
- cnt--; \
- _V[cnt]++; \
- if (cnt == 0) \
- break; \
- }while (_V[cnt] == 0); \
-}
-
-#define IS_WPA_CAPABILITY(a) (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
-
-// EAPOL Key Information definition within Key descriptor format
-typedef struct PACKED _KEY_INFO
-{
-#ifdef RT_BIG_ENDIAN
- UCHAR KeyAck:1;
- UCHAR Install:1;
- UCHAR KeyIndex:2;
- UCHAR KeyType:1;
- UCHAR KeyDescVer:3;
- UCHAR Rsvd:3;
- UCHAR EKD_DL:1; // EKD for AP; DL for STA
- UCHAR Request:1;
- UCHAR Error:1;
- UCHAR Secure:1;
- UCHAR KeyMic:1;
-#else
- UCHAR KeyMic:1;
- UCHAR Secure:1;
- UCHAR Error:1;
- UCHAR Request:1;
- UCHAR EKD_DL:1; // EKD for AP; DL for STA
- UCHAR Rsvd:3;
- UCHAR KeyDescVer:3;
- UCHAR KeyType:1;
- UCHAR KeyIndex:2;
- UCHAR Install:1;
- UCHAR KeyAck:1;
-#endif
-} KEY_INFO, *PKEY_INFO;
-
-// EAPOL Key descriptor format
-typedef struct PACKED _KEY_DESCRIPTER
-{
- UCHAR Type;
- KEY_INFO KeyInfo;
- UCHAR KeyLength[2];
- UCHAR ReplayCounter[LEN_KEY_DESC_REPLAY];
- UCHAR KeyNonce[LEN_KEY_DESC_NONCE];
- UCHAR KeyIv[LEN_KEY_DESC_IV];
- UCHAR KeyRsc[LEN_KEY_DESC_RSC];
- UCHAR KeyId[LEN_KEY_DESC_ID];
- UCHAR KeyMic[LEN_KEY_DESC_MIC];
- UCHAR KeyDataLen[2];
- UCHAR KeyData[MAX_LEN_OF_RSNIE];
-} KEY_DESCRIPTER, *PKEY_DESCRIPTER;
-
-typedef struct PACKED _EAPOL_PACKET
-{
- UCHAR ProVer;
- UCHAR ProType;
- UCHAR Body_Len[2];
- KEY_DESCRIPTER KeyDesc;
-} EAPOL_PACKET, *PEAPOL_PACKET;
-
-//802.11i D10 page 83
-typedef struct PACKED _GTK_ENCAP
-{
-#ifndef RT_BIG_ENDIAN
- UCHAR Kid:2;
- UCHAR tx:1;
- UCHAR rsv:5;
- UCHAR rsv1;
-#else
- UCHAR rsv:5;
- UCHAR tx:1;
- UCHAR Kid:2;
- UCHAR rsv1;
-#endif
- UCHAR GTK[TKIP_GTK_LENGTH];
-} GTK_ENCAP, *PGTK_ENCAP;
-
-typedef struct PACKED _KDE_ENCAP
-{
- UCHAR Type;
- UCHAR Len;
- UCHAR OUI[3];
- UCHAR DataType;
- GTK_ENCAP GTKEncap;
-} KDE_ENCAP, *PKDE_ENCAP;
-
-// For WPA1
-typedef struct PACKED _RSNIE {
- UCHAR oui[4];
- USHORT version;
- UCHAR mcast[4];
- USHORT ucount;
- struct PACKED {
- UCHAR oui[4];
- }ucast[1];
-} RSNIE, *PRSNIE;
-
-// For WPA2
-typedef struct PACKED _RSNIE2 {
- USHORT version;
- UCHAR mcast[4];
- USHORT ucount;
- struct PACKED {
- UCHAR oui[4];
- }ucast[1];
-} RSNIE2, *PRSNIE2;
-
-// AKM Suite
-typedef struct PACKED _RSNIE_AUTH {
- USHORT acount;
- struct PACKED {
- UCHAR oui[4];
- }auth[1];
-} RSNIE_AUTH,*PRSNIE_AUTH;
-
-typedef union PACKED _RSN_CAPABILITIES {
- struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Rsvd:10;
- USHORT GTKSA_R_Counter:2;
- USHORT PTKSA_R_Counter:2;
- USHORT No_Pairwise:1;
- USHORT PreAuth:1;
-#else
- USHORT PreAuth:1;
- USHORT No_Pairwise:1;
- USHORT PTKSA_R_Counter:2;
- USHORT GTKSA_R_Counter:2;
- USHORT Rsvd:10;
-#endif
- } field;
- USHORT word;
-} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
-
-typedef struct PACKED _EAP_HDR {
- UCHAR ProVer;
- UCHAR ProType;
- UCHAR Body_Len[2];
- UCHAR code;
- UCHAR identifier;
- UCHAR length[2]; // including code and identifier, followed by length-2 octets of data
-} EAP_HDR, *PEAP_HDR;
-
-// For supplicant state machine states. 802.11i Draft 4.1, p. 97
-// We simplified it
-typedef enum _WpaState
-{
- SS_NOTUSE, // 0
- SS_START, // 1
- SS_WAIT_MSG_3, // 2
- SS_WAIT_GROUP, // 3
- SS_FINISH, // 4
- SS_KEYUPDATE, // 5
-} WPA_STATE;
-
-//
-// The definition of the cipher combination
-//
-// bit3 bit2 bit1 bit0
-// +------------+------------+
-// | WPA | WPA2 |
-// +------+-----+------+-----+
-// | TKIP | AES | TKIP | AES |
-// | 0 | 1 | 1 | 0 | -> 0x06
-// | 0 | 1 | 1 | 1 | -> 0x07
-// | 1 | 0 | 0 | 1 | -> 0x09
-// | 1 | 0 | 1 | 1 | -> 0x0B
-// | 1 | 1 | 0 | 1 | -> 0x0D
-// | 1 | 1 | 1 | 0 | -> 0x0E
-// | 1 | 1 | 1 | 1 | -> 0x0F
-// +------+-----+------+-----+
-//
-typedef enum _WpaMixPairCipher
-{
- MIX_CIPHER_NOTUSE = 0x00,
- WPA_NONE_WPA2_TKIPAES = 0x03, // WPA2-TKIPAES
- WPA_AES_WPA2_TKIP = 0x06,
- WPA_AES_WPA2_TKIPAES = 0x07,
- WPA_TKIP_WPA2_AES = 0x09,
- WPA_TKIP_WPA2_TKIPAES = 0x0B,
- WPA_TKIPAES_WPA2_NONE = 0x0C, // WPA-TKIPAES
- WPA_TKIPAES_WPA2_AES = 0x0D,
- WPA_TKIPAES_WPA2_TKIP = 0x0E,
- WPA_TKIPAES_WPA2_TKIPAES = 0x0F,
-} WPA_MIX_PAIR_CIPHER;
-
-typedef struct PACKED _RSN_IE_HEADER_STRUCT {
- UCHAR Eid;
- UCHAR Length;
- USHORT Version; // Little endian format
-} RSN_IE_HEADER_STRUCT, *PRSN_IE_HEADER_STRUCT;
-
-// Cipher suite selector types
-typedef struct PACKED _CIPHER_SUITE_STRUCT {
- UCHAR Oui[3];
- UCHAR Type;
-} CIPHER_SUITE_STRUCT, *PCIPHER_SUITE_STRUCT;
-
-// Authentication and Key Management suite selector
-typedef struct PACKED _AKM_SUITE_STRUCT {
- UCHAR Oui[3];
- UCHAR Type;
-} AKM_SUITE_STRUCT, *PAKM_SUITE_STRUCT;
-
-// RSN capability
-typedef struct PACKED _RSN_CAPABILITY {
- USHORT Rsv:10;
- USHORT GTKSAReplayCnt:2;
- USHORT PTKSAReplayCnt:2;
- USHORT NoPairwise:1;
- USHORT PreAuth:1;
-} RSN_CAPABILITY, *PRSN_CAPABILITY;
-
-#endif
+#include "../rt2860/wpa.h"
diff --git a/drivers/staging/rt3070/2870_main_dev.c b/drivers/staging/rt3070/2870_main_dev.c
index 401ddb012131..32427c0bb3b9 100644
--- a/drivers/staging/rt3070/2870_main_dev.c
+++ b/drivers/staging/rt3070/2870_main_dev.c
@@ -1,1627 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_main.c
-
- Abstract:
- main initialization routines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Jan Lee 01-10-2005 modified
- Sample Jun/01/07 Merge RT2870 and RT2860 drivers.
-*/
-
-#include "rt_config.h"
-
-
-// Following information will be show when you run 'modinfo'
-// *** If you have a solution for the bug in current version of driver, please mail to me.
-// Otherwise post to forum in ralinktech's web site(www.ralinktech.com) and let all users help you. ***
-MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>");
-MODULE_DESCRIPTION("RT2870 Wireless Lan Linux Driver");
-#ifdef CONFIG_STA_SUPPORT
-MODULE_LICENSE("GPL");
-#ifdef MODULE_VERSION
-MODULE_VERSION(STA_DRIVER_VERSION);
-#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// record whether the card in the card list is used in the card file
-extern UINT8 MC_CardUsed[];
-#endif // MULTIPLE_CARD_SUPPORT //
-
-/* Kernel thread and vars, which handles packets that are completed. Only
- * packets that have a "complete" function are sent here. This way, the
- * completion is run out of kernel context, and doesn't block the rest of
- * the stack. */
-//static int mlme_kill = 0; // Mlme kernel thread
-//static int RTUSBCmd_kill = 0; // Command kernel thread
-//static int TimerFunc_kill = 0; // TimerQ kernel thread
-
-//static wait_queue_head_t timerWaitQ;
-//static wait_queue_t waitQ;
-
-extern INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
- IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
-
-
-/* module table */
-struct usb_device_id rtusb_usb_id[] = RT2870_USB_DEVICES;
-INT const rtusb_usb_id_len = sizeof(rtusb_usb_id) / sizeof(struct usb_device_id);
-MODULE_DEVICE_TABLE(usb, rtusb_usb_id);
-
-#ifndef PF_NOFREEZE
-#define PF_NOFREEZE 0
-#endif
-
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-
-/**************************************************************************/
-/**************************************************************************/
-//tested for kernel 2.4 series
-/**************************************************************************/
-/**************************************************************************/
-static void *rtusb_probe(struct usb_device *dev, UINT interface,
- const struct usb_device_id *id_table);
-static void rtusb_disconnect(struct usb_device *dev, void *ptr);
-
-struct usb_driver rtusb_driver = {
- name:"rt2870",
- probe:rtusb_probe,
- disconnect:rtusb_disconnect,
- id_table:rtusb_usb_id,
- };
-
-#else
-
-#ifdef CONFIG_PM
-static int rt2870_suspend(struct usb_interface *intf, pm_message_t state);
-static int rt2870_resume(struct usb_interface *intf);
-#endif // CONFIG_PM //
-
-/**************************************************************************/
-/**************************************************************************/
-//tested for kernel 2.6series
-/**************************************************************************/
-/**************************************************************************/
-static int rtusb_probe (struct usb_interface *intf,
- const struct usb_device_id *id);
-static void rtusb_disconnect(struct usb_interface *intf);
-
-struct usb_driver rtusb_driver = {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
- .owner = THIS_MODULE,
-#endif
- .name="rt2870",
- .probe=rtusb_probe,
- .disconnect=rtusb_disconnect,
- .id_table=rtusb_usb_id,
-
-#ifdef CONFIG_PM
- suspend: rt2870_suspend,
- resume: rt2870_resume,
-#endif
- };
-
-#ifdef CONFIG_PM
-
-VOID RT2860RejectPendingPackets(
- IN PRTMP_ADAPTER pAd)
-{
- // clear PS packets
- // clear TxSw packets
-}
-
-static int rt2870_suspend(
- struct usb_interface *intf,
- pm_message_t state)
-{
- struct net_device *net_dev;
- PRTMP_ADAPTER pAd = usb_get_intfdata(intf);
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_suspend()\n"));
- net_dev = pAd->net_dev;
- netif_device_detach(net_dev);
-
- pAd->PM_FlgSuspend = 1;
- if (netif_running(net_dev)) {
- RTUSBCancelPendingBulkInIRP(pAd);
- RTUSBCancelPendingBulkOutIRP(pAd);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_suspend()\n"));
- return 0;
-}
-
-static int rt2870_resume(
- struct usb_interface *intf)
-{
- struct net_device *net_dev;
- PRTMP_ADAPTER pAd = usb_get_intfdata(intf);
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()\n"));
-
- pAd->PM_FlgSuspend = 0;
- net_dev = pAd->net_dev;
- netif_device_attach(net_dev);
- netif_start_queue(net_dev);
- netif_carrier_on(net_dev);
- netif_wake_queue(net_dev);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()\n"));
- return 0;
-}
-#endif // CONFIG_PM //
-#endif // LINUX_VERSION_CODE //
-
-
-// Init driver module
-INT __init rtusb_init(void)
-{
- printk("rtusb init --->\n");
- return usb_register(&rtusb_driver);
-}
-
-// Deinit driver module
-VOID __exit rtusb_exit(void)
-{
- usb_deregister(&rtusb_driver);
- printk("<--- rtusb exit\n");
-}
-
-module_init(rtusb_init);
-module_exit(rtusb_exit);
-
-
-
-
-/*--------------------------------------------------------------------- */
-/* function declarations */
-/*--------------------------------------------------------------------- */
-
-/*
-========================================================================
-Routine Description:
- MLME kernel thread.
-
-Arguments:
- *Context the pAd, driver control block pointer
-
-Return Value:
- 0 close the thread
-
-Note:
-========================================================================
-*/
-INT MlmeThread(
- IN void *Context)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)Context;
- POS_COOKIE pObj;
- int status;
-
- pObj = (POS_COOKIE)pAd->OS_Cookie;
-
- rtmp_os_thread_init("rt2870MlmeThread", (PVOID)&(pAd->mlmeComplete));
-
- while (pAd->mlme_kill == 0)
- {
- /* lock the device pointers */
- //down(&(pAd->mlme_semaphore));
- status = down_interruptible(&(pAd->mlme_semaphore));
-
- /* lock the device pointers , need to check if required*/
- //down(&(pAd->usbdev_semaphore));
-
- if (!pAd->PM_FlgSuspend)
- MlmeHandler(pAd);
-
- /* unlock the device pointers */
- //up(&(pAd->usbdev_semaphore));
- if (status != 0)
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
- break;
- }
- }
-
- /* notify the exit routine that we're actually exiting now
- *
- * complete()/wait_for_completion() is similar to up()/down(),
- * except that complete() is safe in the case where the structure
- * is getting deleted in a parallel mode of execution (i.e. just
- * after the down() -- that's necessary for the thread-shutdown
- * case.
- *
- * complete_and_exit() goes even further than this -- it is safe in
- * the case that the thread of the caller is going away (not just
- * the structure) -- this is necessary for the module-remove case.
- * This is important in preemption kernels, which transfer the flow
- * of execution immediately upon a complete().
- */
- DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__FUNCTION__));
-
- pObj->MLMEThr_pid = NULL;
-
- complete_and_exit (&pAd->mlmeComplete, 0);
- return 0;
-
-}
-
-
-/*
-========================================================================
-Routine Description:
- USB command kernel thread.
-
-Arguments:
- *Context the pAd, driver control block pointer
-
-Return Value:
- 0 close the thread
-
-Note:
-========================================================================
-*/
-INT RTUSBCmdThread(
- IN void * Context)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)Context;
- POS_COOKIE pObj;
- int status;
-
- pObj = (POS_COOKIE)pAd->OS_Cookie;
-
- rtmp_os_thread_init("rt2870CmdThread", (PVOID)&(pAd->CmdQComplete));
-
- NdisAcquireSpinLock(&pAd->CmdQLock);
- pAd->CmdQ.CmdQState = RT2870_THREAD_RUNNING;
- NdisReleaseSpinLock(&pAd->CmdQLock);
-
- while (pAd->CmdQ.CmdQState == RT2870_THREAD_RUNNING)
- {
- /* lock the device pointers */
- //down(&(pAd->RTUSBCmd_semaphore));
- status = down_interruptible(&(pAd->RTUSBCmd_semaphore));
-
- if (pAd->CmdQ.CmdQState == RT2870_THREAD_STOPED)
- break;
-
- if (status != 0)
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
- break;
- }
- /* lock the device pointers , need to check if required*/
- //down(&(pAd->usbdev_semaphore));
-
- if (!pAd->PM_FlgSuspend)
- CMDHandler(pAd);
-
- /* unlock the device pointers */
- //up(&(pAd->usbdev_semaphore));
- }
-
- if (!pAd->PM_FlgSuspend)
- { // Clear the CmdQElements.
- CmdQElmt *pCmdQElmt = NULL;
-
- NdisAcquireSpinLock(&pAd->CmdQLock);
- pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
- while(pAd->CmdQ.size)
- {
- RTUSBDequeueCmd(&pAd->CmdQ, &pCmdQElmt);
- if (pCmdQElmt)
- {
- if (pCmdQElmt->CmdFromNdis == TRUE)
- {
- if (pCmdQElmt->buffer != NULL)
- NdisFreeMemory(pCmdQElmt->buffer, pCmdQElmt->bufferlength, 0);
-
- NdisFreeMemory(pCmdQElmt, sizeof(CmdQElmt), 0);
- }
- else
- {
- if ((pCmdQElmt->buffer != NULL) && (pCmdQElmt->bufferlength != 0))
- NdisFreeMemory(pCmdQElmt->buffer, pCmdQElmt->bufferlength, 0);
- {
- NdisFreeMemory(pCmdQElmt, sizeof(CmdQElmt), 0);
- }
- }
- }
- }
-
- NdisReleaseSpinLock(&pAd->CmdQLock);
- }
- /* notify the exit routine that we're actually exiting now
- *
- * complete()/wait_for_completion() is similar to up()/down(),
- * except that complete() is safe in the case where the structure
- * is getting deleted in a parallel mode of execution (i.e. just
- * after the down() -- that's necessary for the thread-shutdown
- * case.
- *
- * complete_and_exit() goes even further than this -- it is safe in
- * the case that the thread of the caller is going away (not just
- * the structure) -- this is necessary for the module-remove case.
- * This is important in preemption kernels, which transfer the flow
- * of execution immediately upon a complete().
- */
- DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n"));
-
- pObj->RTUSBCmdThr_pid = NULL;
-
- complete_and_exit (&pAd->CmdQComplete, 0);
- return 0;
-
-}
-
-
-static void RT2870_TimerQ_Handle(RTMP_ADAPTER *pAd)
-{
- int status;
- RALINK_TIMER_STRUCT *pTimer;
- RT2870_TIMER_ENTRY *pEntry;
- unsigned long irqFlag;
-
- while(!pAd->TimerFunc_kill)
- {
-// printk("waiting for event!\n");
- pTimer = NULL;
-
- status = down_interruptible(&(pAd->RTUSBTimer_semaphore));
-
- if (pAd->TimerQ.status == RT2870_THREAD_STOPED)
- break;
-
- // event happened.
- while(pAd->TimerQ.pQHead)
- {
- RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlag);
- pEntry = pAd->TimerQ.pQHead;
- if (pEntry)
- {
- pTimer = pEntry->pRaTimer;
-
- // update pQHead
- pAd->TimerQ.pQHead = pEntry->pNext;
- if (pEntry == pAd->TimerQ.pQTail)
- pAd->TimerQ.pQTail = NULL;
-
- // return this queue entry to timerQFreeList.
- pEntry->pNext = pAd->TimerQ.pQPollFreeList;
- pAd->TimerQ.pQPollFreeList = pEntry;
- }
- RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlag);
-
- if (pTimer)
- {
- if (pTimer->handle != NULL)
- if (!pAd->PM_FlgSuspend)
- pTimer->handle(NULL, (PVOID) pTimer->cookie, NULL, pTimer);
- if ((pTimer->Repeat) && (pTimer->State == FALSE))
- RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);
- }
- }
-
- if (status != 0)
- {
- pAd->TimerQ.status = RT2870_THREAD_STOPED;
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
- break;
- }
- }
-}
-
-
-INT TimerQThread(
- IN OUT PVOID Context)
-{
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
-
- pAd = (PRTMP_ADAPTER)Context;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- rtmp_os_thread_init("rt2870TimerQHandle", (PVOID)&(pAd->TimerQComplete));
-
- RT2870_TimerQ_Handle(pAd);
-
- /* notify the exit routine that we're actually exiting now
- *
- * complete()/wait_for_completion() is similar to up()/down(),
- * except that complete() is safe in the case where the structure
- * is getting deleted in a parallel mode of execution (i.e. just
- * after the down() -- that's necessary for the thread-shutdown
- * case.
- *
- * complete_and_exit() goes even further than this -- it is safe in
- * the case that the thread of the caller is going away (not just
- * the structure) -- this is necessary for the module-remove case.
- * This is important in preemption kernels, which transfer the flow
- * of execution immediately upon a complete().
- */
- DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__FUNCTION__));
-
- pObj->TimerQThr_pid = NULL;
-
- complete_and_exit(&pAd->TimerQComplete, 0);
- return 0;
-
-}
-
-
-RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
- IN RTMP_ADAPTER *pAd,
- IN RALINK_TIMER_STRUCT *pTimer)
-{
- RT2870_TIMER_ENTRY *pQNode = NULL, *pQTail;
- unsigned long irqFlags;
-
-
- RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
- if (pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)
- {
- if(pAd->TimerQ.pQPollFreeList)
- {
- pQNode = pAd->TimerQ.pQPollFreeList;
- pAd->TimerQ.pQPollFreeList = pQNode->pNext;
-
- pQNode->pRaTimer = pTimer;
- pQNode->pNext = NULL;
-
- pQTail = pAd->TimerQ.pQTail;
- if (pAd->TimerQ.pQTail != NULL)
- pQTail->pNext = pQNode;
- pAd->TimerQ.pQTail = pQNode;
- if (pAd->TimerQ.pQHead == NULL)
- pAd->TimerQ.pQHead = pQNode;
- }
- RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-
- if (pQNode)
- up(&pAd->RTUSBTimer_semaphore);
- //wake_up(&timerWaitQ);
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
- }
- return pQNode;
-}
-
-
-BOOLEAN RT2870_TimerQ_Remove(
- IN RTMP_ADAPTER *pAd,
- IN RALINK_TIMER_STRUCT *pTimer)
-{
- RT2870_TIMER_ENTRY *pNode, *pPrev = NULL;
- unsigned long irqFlags;
-
- RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
- if (pAd->TimerQ.status >= RT2870_THREAD_INITED)
- {
- pNode = pAd->TimerQ.pQHead;
- while (pNode)
- {
- if (pNode->pRaTimer == pTimer)
- break;
- pPrev = pNode;
- pNode = pNode->pNext;
- }
-
- // Now move it to freeList queue.
- if (pNode)
- {
- if (pNode == pAd->TimerQ.pQHead)
- pAd->TimerQ.pQHead = pNode->pNext;
- if (pNode == pAd->TimerQ.pQTail)
- pAd->TimerQ.pQTail = pPrev;
- if (pPrev != NULL)
- pPrev->pNext = pNode->pNext;
-
- // return this queue entry to timerQFreeList.
- pNode->pNext = pAd->TimerQ.pQPollFreeList;
- pAd->TimerQ.pQPollFreeList = pNode;
- }
- }
- RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-
- return TRUE;
-}
-
-
-void RT2870_TimerQ_Exit(RTMP_ADAPTER *pAd)
-{
- RT2870_TIMER_ENTRY *pTimerQ;
- unsigned long irqFlags;
-
- RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
- while (pAd->TimerQ.pQHead)
- {
- pTimerQ = pAd->TimerQ.pQHead;
- pAd->TimerQ.pQHead = pTimerQ->pNext;
- // remove the timeQ
- }
- pAd->TimerQ.pQPollFreeList = NULL;
- os_free_mem(pAd, pAd->TimerQ.pTimerQPoll);
- pAd->TimerQ.pQTail = NULL;
- pAd->TimerQ.pQHead = NULL;
- pAd->TimerQ.status = RT2870_THREAD_STOPED;
- RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-}
-
-
-void RT2870_TimerQ_Init(RTMP_ADAPTER *pAd)
-{
- int i;
- RT2870_TIMER_ENTRY *pQNode, *pEntry;
- unsigned long irqFlags;
-
- NdisAllocateSpinLock(&pAd->TimerQLock);
-
- RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
- NdisZeroMemory(&pAd->TimerQ, sizeof(pAd->TimerQ));
- //InterlockedExchange(&pAd->TimerQ.count, 0);
-
- /* Initialise the wait q head */
- //init_waitqueue_head(&timerWaitQ);
-
- os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll, sizeof(RT2870_TIMER_ENTRY) * TIMER_QUEUE_SIZE_MAX);
- if (pAd->TimerQ.pTimerQPoll)
- {
- pEntry = NULL;
- pQNode = (RT2870_TIMER_ENTRY *)pAd->TimerQ.pTimerQPoll;
- for (i = 0 ;i <TIMER_QUEUE_SIZE_MAX; i++)
- {
- pQNode->pNext = pEntry;
- pEntry = pQNode;
- pQNode++;
- }
- pAd->TimerQ.pQPollFreeList = pEntry;
- pAd->TimerQ.pQHead = NULL;
- pAd->TimerQ.pQTail = NULL;
- pAd->TimerQ.status = RT2870_THREAD_INITED;
- }
- RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-}
-
-
-VOID RT2870_WatchDog(IN RTMP_ADAPTER *pAd)
-{
- PHT_TX_CONTEXT pHTTXContext;
- int idx;
- ULONG irqFlags;
- PURB pUrb;
- BOOLEAN needDumpSeq = FALSE;
- UINT32 MACValue;
-
-
- idx = 0;
- RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
- if ((MACValue & 0xff) !=0 )
- {
- DBGPRINT(RT_DEBUG_TRACE, ("TX QUEUE 0 Not EMPTY(Value=0x%0x). !!!!!!!!!!!!!!!\n", MACValue));
- RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40012);
- while((MACValue &0xff) != 0 && (idx++ < 10))
- {
- RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
- NdisMSleep(1);
- }
- RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
- }
-
-//PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- idx = 0;
- if ((MACValue & 0xff00) !=0 )
- {
- DBGPRINT(RT_DEBUG_TRACE, ("TX QUEUE 1 Not EMPTY(Value=0x%0x). !!!!!!!!!!!!!!!\n", MACValue));
- RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf4000a);
- while((MACValue &0xff00) != 0 && (idx++ < 10))
- {
- RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
- NdisMSleep(1);
- }
- RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (pAd->watchDogRxOverFlowCnt >= 2)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n"));
- if ((!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_BULKIN_RESET |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Call CMDTHREAD_RESET_BULK_IN to cancel the pending Rx Bulk!\n"));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, NULL, 0);
- needDumpSeq = TRUE;
- }
- pAd->watchDogRxOverFlowCnt = 0;
- }
-
-
- for (idx = 0; idx < NUM_OF_TX_RING; idx++)
- {
- pUrb = NULL;
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags);
- if ((pAd->BulkOutPending[idx] == TRUE) && pAd->watchDogTxPendingCnt)
- {
- pAd->watchDogTxPendingCnt[idx]++;
-
- if ((pAd->watchDogTxPendingCnt[idx] > 2) &&
- (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_BULKOUT_RESET)))
- )
- {
- // FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it!
- pHTTXContext = (PHT_TX_CONTEXT)(&pAd->TxContext[idx]);
- if (pHTTXContext->IRPPending)
- { // Check TxContext.
- pUrb = pHTTXContext->pUrb;
- }
- else if (idx == MGMTPIPEIDX)
- {
- PTX_CONTEXT pMLMEContext, pNULLContext, pPsPollContext;
-
- //Check MgmtContext.
- pMLMEContext = (PTX_CONTEXT)(pAd->MgmtRing.Cell[pAd->MgmtRing.TxDmaIdx].AllocVa);
- pPsPollContext = (PTX_CONTEXT)(&pAd->PsPollContext);
- pNULLContext = (PTX_CONTEXT)(&pAd->NullContext);
-
- if (pMLMEContext->IRPPending)
- {
- ASSERT(pMLMEContext->IRPPending);
- pUrb = pMLMEContext->pUrb;
- }
- else if (pNULLContext->IRPPending)
- {
- ASSERT(pNULLContext->IRPPending);
- pUrb = pNULLContext->pUrb;
- }
- else if (pPsPollContext->IRPPending)
- {
- ASSERT(pPsPollContext->IRPPending);
- pUrb = pPsPollContext->pUrb;
- }
- }
-
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n", idx));
- if (pUrb)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Unlink the pending URB!\n"));
- // unlink it now
- RTUSB_UNLINK_URB(pUrb);
- // Sleep 200 microseconds to give cancellation time to work
- RTMPusecDelay(200);
- needDumpSeq = TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Unkonw bulkOut URB maybe hanged!!!!!!!!!!!!\n"));
- }
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
- }
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
- }
- }
-
-#ifdef DOT11_N_SUPPORT
- // For Sigma debug, dump the ba_reordering sequence.
- if((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0))
- {
- USHORT Idx;
- PBA_REC_ENTRY pBAEntry = NULL;
- UCHAR count = 0;
- struct reordering_mpdu *mpdu_blk;
-
- Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0];
-
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- if((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n"));
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
- mpdu_blk = pBAEntry->list.next;
- while (mpdu_blk)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("\t%d:Seq-%d, bAMSDU-%d!\n", count, mpdu_blk->Sequence, mpdu_blk->bAMSDU));
- mpdu_blk = mpdu_blk->next;
- count++;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("\npBAEntry->LastIndSeq=%d!\n", pBAEntry->LastIndSeq));
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
- }
- }
-#endif // DOT11_N_SUPPORT //
-}
-
-/*
-========================================================================
-Routine Description:
- Release allocated resources.
-
-Arguments:
- *dev Point to the PCI or USB device
- pAd driver control block pointer
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-static void _rtusb_disconnect(struct usb_device *dev, PRTMP_ADAPTER pAd)
-{
- struct net_device *net_dev = NULL;
-
-
- DBGPRINT(RT_DEBUG_ERROR, ("rtusb_disconnect: unregister usbnet usb-%s-%s\n",
- dev->bus->bus_name, dev->devpath));
- if (!pAd)
- {
-#ifdef MULTIPLE_CARD_SUPPORT
- if ((pAd->MC_RowID >= 0) && (pAd->MC_RowID <= MAX_NUM_OF_MULTIPLE_CARD))
- MC_CardUsed[pAd->MC_RowID] = 0; // not clear MAC address
-#endif // MULTIPLE_CARD_SUPPORT //
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- while(MOD_IN_USE > 0)
- {
- MOD_DEC_USE_COUNT;
- }
-#else
- usb_put_dev(dev);
-#endif // LINUX_VERSION_CODE //
-
- printk("rtusb_disconnect: pAd == NULL!\n");
- return;
- }
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST);
-
-
-
- // for debug, wait to show some messages to /proc system
- udelay(1);
-
-
-
-
- net_dev = pAd->net_dev;
- if (pAd->net_dev != NULL)
- {
- printk("rtusb_disconnect: unregister_netdev(), dev->name=%s!\n", net_dev->name);
- unregister_netdev (pAd->net_dev);
- }
- udelay(1);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
-#else
- flush_scheduled_work();
-#endif // LINUX_VERSION_CODE //
- udelay(1);
-
- // free net_device memory
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- kfree(net_dev);
-#else
- free_netdev(net_dev);
-#endif // LINUX_VERSION_CODE //
-
- // free adapter memory
- RTMPFreeAdapter(pAd);
-
- // release a use of the usb device structure
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- while(MOD_IN_USE > 0)
- {
- MOD_DEC_USE_COUNT;
- }
-#else
- usb_put_dev(dev);
-#endif // LINUX_VERSION_CODE //
- udelay(1);
-
- DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n"));
-}
-
-
-/*
-========================================================================
-Routine Description:
- Probe RT28XX chipset.
-
-Arguments:
- *dev Point to the PCI or USB device
- interface
- *id_table Point to the PCI or USB device ID
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
-static void *rtusb_probe(struct usb_device *dev, UINT interface,
- const struct usb_device_id *id)
-{
- PRTMP_ADAPTER pAd;
- rt28xx_probe((void *)dev, (void *)id, interface, &pAd);
- return (void *)pAd;
-}
-
-//Disconnect function is called within exit routine
-static void rtusb_disconnect(struct usb_device *dev, void *ptr)
-{
- _rtusb_disconnect(dev, ((PRTMP_ADAPTER)ptr));
-}
-
-#else /* kernel 2.6 series */
-static int rtusb_probe (struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- PRTMP_ADAPTER pAd;
- return (int)rt28xx_probe((void *)intf, (void *)id, 0, &pAd);
-}
-
-
-static void rtusb_disconnect(struct usb_interface *intf)
-{
- struct usb_device *dev = interface_to_usbdev(intf);
- PRTMP_ADAPTER pAd;
-
-
- pAd = usb_get_intfdata(intf);
- usb_set_intfdata(intf, NULL);
-
- _rtusb_disconnect(dev, pAd);
-}
-#endif // LINUX_VERSION_CODE //
-
-
-/*
-========================================================================
-Routine Description:
- Close kernel threads.
-
-Arguments:
- *pAd the raxx interface data pointer
-
-Return Value:
- NONE
-
-Note:
-========================================================================
-*/
-VOID RT28xxThreadTerminate(
- IN RTMP_ADAPTER *pAd)
-{
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
- INT ret;
-
-
- // Sleep 50 milliseconds so pending io might finish normally
- RTMPusecDelay(50000);
-
- // We want to wait until all pending receives and sends to the
- // device object. We cancel any
- // irps. Wait until sends and receives have stopped.
- RTUSBCancelPendingIRPs(pAd);
-
- // Terminate Threads
- if (pObj->MLMEThr_pid)
- {
- printk("Terminate the MLMEThr_pid=%d!\n", pid_nr(pObj->MLMEThr_pid));
- mb();
- pAd->mlme_kill = 1;
- //RT28XX_MLME_HANDLER(pAd);
- mb();
- ret = kill_pid(pObj->MLMEThr_pid, SIGTERM, 1);
- if (ret)
- {
- printk (KERN_WARNING "%s: unable to Mlme thread, pid=%d, ret=%d!\n",
- pAd->net_dev->name, pid_nr(pObj->MLMEThr_pid), ret);
- }
- else
- {
- //wait_for_completion (&pAd->notify);
- wait_for_completion (&pAd->mlmeComplete);
- pObj->MLMEThr_pid = NULL;
- }
- }
-
- if (pObj->RTUSBCmdThr_pid >= 0)
- {
- printk("Terminate the RTUSBCmdThr_pid=%d!\n", pid_nr(pObj->RTUSBCmdThr_pid));
- mb();
- NdisAcquireSpinLock(&pAd->CmdQLock);
- pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
- NdisReleaseSpinLock(&pAd->CmdQLock);
- mb();
- //RTUSBCMDUp(pAd);
- ret = kill_pid(pObj->RTUSBCmdThr_pid, SIGTERM, 1);
- if (ret)
- {
- printk(KERN_WARNING "%s: unable to RTUSBCmd thread, pid=%d, ret=%d!\n",
- pAd->net_dev->name, pid_nr(pObj->RTUSBCmdThr_pid), ret);
- }
- else
- {
- //wait_for_completion (&pAd->notify);
- wait_for_completion (&pAd->CmdQComplete);
- pObj->RTUSBCmdThr_pid = NULL;
- }
- }
- if (pObj->TimerQThr_pid >= 0)
- {
- POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
-
- printk("Terminate the TimerQThr_pid=%d!\n", pid_nr(pObj->TimerQThr_pid));
- mb();
- pAd->TimerFunc_kill = 1;
- mb();
- ret = kill_pid(pObj->TimerQThr_pid, SIGTERM, 1);
- if (ret)
- {
- printk(KERN_WARNING "%s: unable to stop TimerQThread, pid=%d, ret=%d!\n",
- pAd->net_dev->name, pid_nr(pObj->TimerQThr_pid), ret);
- }
- else
- {
- printk("wait_for_completion TimerQThr\n");
- wait_for_completion(&pAd->TimerQComplete);
- pObj->TimerQThr_pid = NULL;
- }
- }
- // Kill tasklets
- pAd->mlme_kill = 0;
- pAd->CmdQ.CmdQState = RT2870_THREAD_UNKNOWN;
- pAd->TimerFunc_kill = 0;
-}
-
-
-void kill_thread_task(IN PRTMP_ADAPTER pAd)
-{
- POS_COOKIE pObj;
-
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- tasklet_kill(&pObj->rx_done_task);
- tasklet_kill(&pObj->mgmt_dma_done_task);
- tasklet_kill(&pObj->ac0_dma_done_task);
- tasklet_kill(&pObj->ac1_dma_done_task);
- tasklet_kill(&pObj->ac2_dma_done_task);
- tasklet_kill(&pObj->ac3_dma_done_task);
- tasklet_kill(&pObj->hcca_dma_done_task);
- tasklet_kill(&pObj->tbtt_task);
-
-}
-
-
-/*
-========================================================================
-Routine Description:
- Check the chipset vendor/product ID.
-
-Arguments:
- _dev_p Point to the PCI or USB device
-
-Return Value:
- TRUE Check ok
- FALSE Check fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXChipsetCheck(
- IN void *_dev_p)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
-#else
- struct usb_interface *intf = (struct usb_interface *)_dev_p;
- struct usb_device *dev_p = interface_to_usbdev(intf);
-#endif // LINUX_VERSION_CODE //
- UINT32 i;
-
-
- for(i=0; i<rtusb_usb_id_len; i++)
- {
- if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor &&
- dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct)
- {
- printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
- dev_p->descriptor.idVendor, dev_p->descriptor.idProduct);
- break;
- }
- }
-
- if (i == rtusb_usb_id_len)
- {
- printk("rt2870: Error! Device Descriptor not matching!\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Init net device structure.
-
-Arguments:
- _dev_p Point to the PCI or USB device
- *net_dev Point to the net device
- *pAd the raxx interface data pointer
-
-Return Value:
- TRUE Init ok
- FALSE Init fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXNetDevInit(
- IN void *_dev_p,
- IN struct net_device *net_dev,
- IN RTMP_ADAPTER *pAd)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
-#else
- struct usb_interface *intf = (struct usb_interface *)_dev_p;
- struct usb_device *dev_p = interface_to_usbdev(intf);
-#endif // LINUX_VERSION_CODE //
-
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- pAd->config = dev_p->config;
-#else
- pAd->config = &dev_p->config->desc;
-#endif // LINUX_VERSION_CODE //
- return TRUE;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Init net device structure.
-
-Arguments:
- _dev_p Point to the PCI or USB device
- *pAd the raxx interface data pointer
-
-Return Value:
- TRUE Config ok
- FALSE Config fail
-
-Note:
-========================================================================
-*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-BOOLEAN RT28XXProbePostConfig(
- IN void *_dev_p,
- IN RTMP_ADAPTER *pAd,
- IN INT32 interface)
-{
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
- struct usb_interface *intf;
- struct usb_interface_descriptor *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
- ULONG BulkOutIdx;
- UINT32 i;
-
-
- /* get the active interface descriptor */
- intf = &dev_p->actconfig->interface[interface];
- iface_desc = &intf->altsetting[0];
-
- /* get # of enpoints */
- pAd->NumberOfPipes = iface_desc->bNumEndpoints;
- DBGPRINT(RT_DEBUG_TRACE, ("NumEndpoints=%d\n", iface_desc->bNumEndpoints));
-
- /* Configure Pipes */
- endpoint = &iface_desc->endpoint[0];
- BulkOutIdx = 0;
-
- for(i=0; i<pAd->NumberOfPipes; i++)
- {
- if ((endpoint[i].bmAttributes == USB_ENDPOINT_XFER_BULK) &&
- ((endpoint[i].bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN))
- {
- pAd->BulkInEpAddr = endpoint[i].bEndpointAddress;
- pAd->BulkInMaxPacketSize = endpoint[i].wMaxPacketSize;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("BULK IN MaximumPacketSize = %d\n", pAd->BulkInMaxPacketSize));
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("EP address = 0x%2x \n", endpoint[i].bEndpointAddress));
- }
- else if ((endpoint[i].bmAttributes == USB_ENDPOINT_XFER_BULK) &&
- ((endpoint[i].bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT))
- {
- // There are 6 bulk out EP. EP6 highest priority.
- // EP1-4 is EDCA. EP5 is HCCA.
- pAd->BulkOutEpAddr[BulkOutIdx++] = endpoint[i].bEndpointAddress;
- pAd->BulkOutMaxPacketSize = endpoint[i].wMaxPacketSize;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("BULK OUT MaximumPacketSize = %d\n", pAd->BulkOutMaxPacketSize));
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("EP address = 0x%2x \n", endpoint[i].bEndpointAddress));
- }
- }
-
- if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0]))
- {
- printk("Could not find both bulk-in and bulk-out endpoints\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-#else
-BOOLEAN RT28XXProbePostConfig(
- IN void *_dev_p,
- IN RTMP_ADAPTER *pAd,
- IN INT32 interface)
-{
- struct usb_interface *intf = (struct usb_interface *)_dev_p;
- struct usb_host_interface *iface_desc;
- ULONG BulkOutIdx;
- UINT32 i;
-
-
- /* get the active interface descriptor */
- iface_desc = intf->cur_altsetting;
-
- /* get # of enpoints */
- pAd->NumberOfPipes = iface_desc->desc.bNumEndpoints;
- DBGPRINT(RT_DEBUG_TRACE,
- ("NumEndpoints=%d\n", iface_desc->desc.bNumEndpoints));
-
- /* Configure Pipes */
- BulkOutIdx = 0;
-
- for(i=0; i<pAd->NumberOfPipes; i++)
- {
- if ((iface_desc->endpoint[i].desc.bmAttributes ==
- USB_ENDPOINT_XFER_BULK) &&
- ((iface_desc->endpoint[i].desc.bEndpointAddress &
- USB_ENDPOINT_DIR_MASK) == USB_DIR_IN))
- {
- pAd->BulkInEpAddr = iface_desc->endpoint[i].desc.bEndpointAddress;
- pAd->BulkInMaxPacketSize = iface_desc->endpoint[i].desc.wMaxPacketSize;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("BULK IN MaximumPacketSize = %d\n", pAd->BulkInMaxPacketSize));
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("EP address = 0x%2x\n", iface_desc->endpoint[i].desc.bEndpointAddress));
- }
- else if ((iface_desc->endpoint[i].desc.bmAttributes ==
- USB_ENDPOINT_XFER_BULK) &&
- ((iface_desc->endpoint[i].desc.bEndpointAddress &
- USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT))
- {
- // there are 6 bulk out EP. EP6 highest priority.
- // EP1-4 is EDCA. EP5 is HCCA.
- pAd->BulkOutEpAddr[BulkOutIdx++] = iface_desc->endpoint[i].desc.bEndpointAddress;
- pAd->BulkOutMaxPacketSize = iface_desc->endpoint[i].desc.wMaxPacketSize;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("BULK OUT MaximumPacketSize = %d\n", pAd->BulkOutMaxPacketSize));
- DBGPRINT_RAW(RT_DEBUG_TRACE,
- ("EP address = 0x%2x \n", iface_desc->endpoint[i].desc.bEndpointAddress));
- }
- }
-
- if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0]))
- {
- printk("%s: Could not find both bulk-in and bulk-out endpoints\n", __FUNCTION__);
- return FALSE;
- }
-
- return TRUE;
-}
-#endif // LINUX_VERSION_CODE //
-
-
-/*
-========================================================================
-Routine Description:
- Disable DMA.
-
-Arguments:
- *pAd the raxx interface data pointer
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-VOID RT28XXDMADisable(
- IN RTMP_ADAPTER *pAd)
-{
- // no use
-}
-
-
-
-/*
-========================================================================
-Routine Description:
- Enable DMA.
-
-Arguments:
- *pAd the raxx interface data pointer
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-VOID RT28XXDMAEnable(
- IN RTMP_ADAPTER *pAd)
-{
- WPDMA_GLO_CFG_STRUC GloCfg;
- USB_DMA_CFG_STRUC UsbCfg;
- int i = 0;
-
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x4);
- do
- {
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
- if ((GloCfg.field.TxDMABusy == 0) && (GloCfg.field.RxDMABusy == 0))
- break;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> DMABusy\n"));
- RTMPusecDelay(1000);
- i++;
- }while ( i <200);
-
-
- RTMPusecDelay(50);
- GloCfg.field.EnTXWriteBackDDONE = 1;
- GloCfg.field.EnableRxDMA = 1;
- GloCfg.field.EnableTxDMA = 1;
- DBGPRINT(RT_DEBUG_TRACE, ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));
- RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
- UsbCfg.word = 0;
- UsbCfg.field.phyclear = 0;
- /* usb version is 1.1,do not use bulk in aggregation */
- if (pAd->BulkInMaxPacketSize == 512)
- UsbCfg.field.RxBulkAggEn = 1;
- /* for last packet, PBF might use more than limited, so minus 2 to prevent from error */
- UsbCfg.field.RxBulkAggLmt = (MAX_RXBULK_SIZE /1024)-3;
- UsbCfg.field.RxBulkAggTOut = 0x80; /* 2006-10-18 */
- UsbCfg.field.RxBulkEn = 1;
- UsbCfg.field.TxBulkEn = 1;
-
- RTUSBWriteMACRegister(pAd, USB_DMA_CFG, UsbCfg.word);
-
-}
-
-/*
-========================================================================
-Routine Description:
- Write Beacon buffer to Asic.
-
-Arguments:
- *pAd the raxx interface data pointer
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-VOID RT28xx_UpdateBeaconToAsic(
- IN RTMP_ADAPTER *pAd,
- IN INT apidx,
- IN ULONG FrameLen,
- IN ULONG UpdatePos)
-{
- PUCHAR pBeaconFrame = NULL;
- UCHAR *ptr;
- UINT i, padding;
- BEACON_SYNC_STRUCT *pBeaconSync = pAd->CommonCfg.pBeaconSync;
- UINT32 longValue;
-// USHORT shortValue;
- BOOLEAN bBcnReq = FALSE;
- UCHAR bcn_idx = 0;
-
-
- if (pBeaconFrame == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,("pBeaconFrame is NULL!\n"));
- return;
- }
-
- if (pBeaconSync == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,("pBeaconSync is NULL!\n"));
- return;
- }
-
- //if ((pAd->WdsTab.Mode == WDS_BRIDGE_MODE) ||
- // ((pAd->ApCfg.MBSSID[apidx].MSSIDDev == NULL) || !(pAd->ApCfg.MBSSID[apidx].MSSIDDev->flags & IFF_UP))
- // )
- if (bBcnReq == FALSE)
- {
- /* when the ra interface is down, do not send its beacon frame */
- /* clear all zero */
- for(i=0; i<TXWI_SIZE; i+=4) {
- RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i, 0x00);
- }
- pBeaconSync->BeaconBitMap &= (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
- NdisZeroMemory(pBeaconSync->BeaconTxWI[bcn_idx], TXWI_SIZE);
- }
- else
- {
- ptr = (PUCHAR)&pAd->BeaconTxWI;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(ptr, TYPE_TXWI);
-#endif
- if (NdisEqualMemory(pBeaconSync->BeaconTxWI[bcn_idx], &pAd->BeaconTxWI, TXWI_SIZE) == FALSE)
- { // If BeaconTxWI changed, we need to rewrite the TxWI for the Beacon frames.
- pBeaconSync->BeaconBitMap &= (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
- NdisMoveMemory(pBeaconSync->BeaconTxWI[bcn_idx], &pAd->BeaconTxWI, TXWI_SIZE);
- }
-
- if ((pBeaconSync->BeaconBitMap & (1 << bcn_idx)) != (1 << bcn_idx))
- {
- for (i=0; i<TXWI_SIZE; i+=4) // 16-byte TXWI field
- {
- longValue = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
- RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i, longValue);
- ptr += 4;
- }
- }
-
- ptr = pBeaconSync->BeaconBuf[bcn_idx];
- padding = (FrameLen & 0x01);
- NdisZeroMemory((PUCHAR)(pBeaconFrame + FrameLen), padding);
- FrameLen += padding;
- for (i = 0 ; i < FrameLen /*HW_BEACON_OFFSET*/; i += 2)
- {
- if (NdisEqualMemory(ptr, pBeaconFrame, 2) == FALSE)
- {
- NdisMoveMemory(ptr, pBeaconFrame, 2);
- //shortValue = *ptr + (*(ptr+1)<<8);
- //RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, shortValue);
- RTUSBMultiWrite(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, ptr, 2);
- }
- ptr +=2;
- pBeaconFrame += 2;
- }
-
- pBeaconSync->BeaconBitMap |= (1 << bcn_idx);
-
- // For AP interface, set the DtimBitOn so that we can send Bcast/Mcast frame out after this beacon frame.
- }
-
-}
-
-
-VOID RT2870_BssBeaconStop(
- IN RTMP_ADAPTER *pAd)
-{
- BEACON_SYNC_STRUCT *pBeaconSync;
- int i, offset;
- BOOLEAN Cancelled = TRUE;
-
- pBeaconSync = pAd->CommonCfg.pBeaconSync;
- if (pBeaconSync && pBeaconSync->EnableBeacon)
- {
- INT NumOfBcn;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NumOfBcn = MAX_MESH_NUM;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
-
- for(i=0; i<NumOfBcn; i++)
- {
- NdisZeroMemory(pBeaconSync->BeaconBuf[i], HW_BEACON_OFFSET);
- NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-
- for (offset=0; offset<HW_BEACON_OFFSET; offset+=4)
- RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[i] + offset, 0x00);
-
- pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
- pBeaconSync->TimIELocationInBeacon[i] = 0;
- }
- pBeaconSync->BeaconBitMap = 0;
- pBeaconSync->DtimBitOn = 0;
- }
-}
-
-
-VOID RT2870_BssBeaconStart(
- IN RTMP_ADAPTER *pAd)
-{
- int apidx;
- BEACON_SYNC_STRUCT *pBeaconSync;
-// LARGE_INTEGER tsfTime, deltaTime;
-
- pBeaconSync = pAd->CommonCfg.pBeaconSync;
- if (pBeaconSync && pBeaconSync->EnableBeacon)
- {
- INT NumOfBcn;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NumOfBcn = MAX_MESH_NUM;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- for(apidx=0; apidx<NumOfBcn; apidx++)
- {
- UCHAR CapabilityInfoLocationInBeacon = 0;
- UCHAR TimIELocationInBeacon = 0;
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- NdisZeroMemory(pBeaconSync->BeaconBuf[apidx], HW_BEACON_OFFSET);
- pBeaconSync->CapabilityInfoLocationInBeacon[apidx] = CapabilityInfoLocationInBeacon;
- pBeaconSync->TimIELocationInBeacon[apidx] = TimIELocationInBeacon;
- NdisZeroMemory(pBeaconSync->BeaconTxWI[apidx], TXWI_SIZE);
- }
- pBeaconSync->BeaconBitMap = 0;
- pBeaconSync->DtimBitOn = 0;
- pAd->CommonCfg.BeaconUpdateTimer.Repeat = TRUE;
-
- pAd->CommonCfg.BeaconAdjust = 0;
- pAd->CommonCfg.BeaconFactor = 0xffffffff / (pAd->CommonCfg.BeaconPeriod << 10);
- pAd->CommonCfg.BeaconRemain = (0xffffffff % (pAd->CommonCfg.BeaconPeriod << 10)) + 1;
- printk("RT2870_BssBeaconStart:BeaconFactor=%d, BeaconRemain=%d!\n", pAd->CommonCfg.BeaconFactor, pAd->CommonCfg.BeaconRemain);
- RTMPSetTimer(&pAd->CommonCfg.BeaconUpdateTimer, pAd->CommonCfg.BeaconPeriod);
-
- }
-}
-
-
-VOID RT2870_BssBeaconInit(
- IN RTMP_ADAPTER *pAd)
-{
- BEACON_SYNC_STRUCT *pBeaconSync;
- int i;
-
- NdisAllocMemory(pAd->CommonCfg.pBeaconSync, sizeof(BEACON_SYNC_STRUCT), MEM_ALLOC_FLAG);
- if (pAd->CommonCfg.pBeaconSync)
- {
- pBeaconSync = pAd->CommonCfg.pBeaconSync;
- NdisZeroMemory(pBeaconSync, sizeof(BEACON_SYNC_STRUCT));
- for(i=0; i < HW_BEACON_MAX_COUNT; i++)
- {
- NdisZeroMemory(pBeaconSync->BeaconBuf[i], HW_BEACON_OFFSET);
- pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
- pBeaconSync->TimIELocationInBeacon[i] = 0;
- NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
- }
- pBeaconSync->BeaconBitMap = 0;
-
- //RTMPInitTimer(pAd, &pAd->CommonCfg.BeaconUpdateTimer, GET_TIMER_FUNCTION(BeaconUpdateExec), pAd, TRUE);
- pBeaconSync->EnableBeacon = TRUE;
- }
-}
-
-
-VOID RT2870_BssBeaconExit(
- IN RTMP_ADAPTER *pAd)
-{
- BEACON_SYNC_STRUCT *pBeaconSync;
- BOOLEAN Cancelled = TRUE;
- int i;
-
- if (pAd->CommonCfg.pBeaconSync)
- {
- pBeaconSync = pAd->CommonCfg.pBeaconSync;
- pBeaconSync->EnableBeacon = FALSE;
- RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
- pBeaconSync->BeaconBitMap = 0;
-
- for(i=0; i<HW_BEACON_MAX_COUNT; i++)
- {
- NdisZeroMemory(pBeaconSync->BeaconBuf[i], HW_BEACON_OFFSET);
- pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
- pBeaconSync->TimIELocationInBeacon[i] = 0;
- NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
- }
-
- NdisFreeMemory(pAd->CommonCfg.pBeaconSync, HW_BEACON_OFFSET * HW_BEACON_MAX_COUNT, 0);
- pAd->CommonCfg.pBeaconSync = NULL;
- }
-}
-
-VOID BeaconUpdateExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)FunctionContext;
- LARGE_INTEGER tsfTime_a;//, tsfTime_b, deltaTime_exp, deltaTime_ab;
- UINT32 delta, remain, remain_low, remain_high;
-// BOOLEAN positive;
-
- ReSyncBeaconTime(pAd);
-
-
-
- RTMP_IO_READ32(pAd, TSF_TIMER_DW0, &tsfTime_a.u.LowPart);
- RTMP_IO_READ32(pAd, TSF_TIMER_DW1, &tsfTime_a.u.HighPart);
-
-
- //positive=getDeltaTime(tsfTime_a, expectedTime, &deltaTime_exp);
- remain_high = pAd->CommonCfg.BeaconRemain * tsfTime_a.u.HighPart;
- remain_low = tsfTime_a.u.LowPart % (pAd->CommonCfg.BeaconPeriod << 10);
- remain = (remain_high + remain_low)%(pAd->CommonCfg.BeaconPeriod << 10);
- delta = (pAd->CommonCfg.BeaconPeriod << 10) - remain;
-
- pAd->CommonCfg.BeaconUpdateTimer.TimerValue = (delta >> 10) + 10;
-
-}
-
+#include "../rt2870/2870_main_dev.c"
diff --git a/drivers/staging/rt3070/Makefile b/drivers/staging/rt3070/Makefile
index 55980c929254..df7ac19e0883 100644
--- a/drivers/staging/rt3070/Makefile
+++ b/drivers/staging/rt3070/Makefile
@@ -3,11 +3,7 @@ obj-$(CONFIG_RT3070) += rt3070sta.o
# TODO: all of these should be removed
EXTRA_CFLAGS += -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
EXTRA_CFLAGS += -DRT2870 -DRT30xx -DRT3070
-EXTRA_CFLAGS += -DCONFIG_STA_SUPPORT
EXTRA_CFLAGS += -DDBG
-EXTRA_CFLAGS += -DDOT11_N_SUPPORT
-EXTRA_CFLAGS += -DWPA_SUPPLICANT_SUPPORT
-EXTRA_CFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT
rt3070sta-objs := \
common/md5.o \
diff --git a/drivers/staging/rt3070/action.h b/drivers/staging/rt3070/action.h
index ce3877dce81b..345fa8922ed3 100644
--- a/drivers/staging/rt3070/action.h
+++ b/drivers/staging/rt3070/action.h
@@ -1,68 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- aironet.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 04-06-15 Initial
-*/
-
-#ifndef __ACTION_H__
-#define __ACTION_H__
-
-typedef struct PACKED __HT_INFO_OCTET
-{
-#ifdef RT_BIG_ENDIAN
- UCHAR Reserved:5;
- UCHAR STA_Channel_Width:1;
- UCHAR Forty_MHz_Intolerant:1;
- UCHAR Request:1;
-#else
- UCHAR Request:1;
- UCHAR Forty_MHz_Intolerant:1;
- UCHAR STA_Channel_Width:1;
- UCHAR Reserved:5;
-#endif
-} HT_INFORMATION_OCTET;
-
-
-typedef struct PACKED __FRAME_HT_INFO
-{
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- HT_INFORMATION_OCTET HT_Info;
-} FRAME_HT_INFO, *PFRAME_HT_INFO;
-
-#endif /* __ACTION_H__ */
-
-
+#include "../rt2870/common/action.h"
diff --git a/drivers/staging/rt3070/aironet.h b/drivers/staging/rt3070/aironet.h
index 1e07b19b8cdc..78088f2087ef 100644
--- a/drivers/staging/rt3070/aironet.h
+++ b/drivers/staging/rt3070/aironet.h
@@ -1,210 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- aironet.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 04-06-15 Initial
-*/
-
-#ifndef __AIRONET_H__
-#define __AIRONET_H__
-
-// Measurement Type definition
-#define MSRN_TYPE_UNUSED 0
-#define MSRN_TYPE_CHANNEL_LOAD_REQ 1
-#define MSRN_TYPE_NOISE_HIST_REQ 2
-#define MSRN_TYPE_BEACON_REQ 3
-#define MSRN_TYPE_FRAME_REQ 4
-
-// Scan Mode in Beacon Request
-#define MSRN_SCAN_MODE_PASSIVE 0
-#define MSRN_SCAN_MODE_ACTIVE 1
-#define MSRN_SCAN_MODE_BEACON_TABLE 2
-
-// PHY type definition for Aironet beacon report, CCX 2 table 36-9
-#define PHY_FH 1
-#define PHY_DSS 2
-#define PHY_UNUSED 3
-#define PHY_OFDM 4
-#define PHY_HR_DSS 5
-#define PHY_ERP 6
-
-// RPI table in dBm
-#define RPI_0 0 // Power <= -87
-#define RPI_1 1 // -87 < Power <= -82
-#define RPI_2 2 // -82 < Power <= -77
-#define RPI_3 3 // -77 < Power <= -72
-#define RPI_4 4 // -72 < Power <= -67
-#define RPI_5 5 // -67 < Power <= -62
-#define RPI_6 6 // -62 < Power <= -57
-#define RPI_7 7 // -57 < Power
-
-// Cisco Aironet IAPP definetions
-#define AIRONET_IAPP_TYPE 0x32
-#define AIRONET_IAPP_SUBTYPE_REQUEST 0x01
-#define AIRONET_IAPP_SUBTYPE_REPORT 0x81
-
-// Measurement Request detail format
-typedef struct _MEASUREMENT_REQUEST {
- UCHAR Channel;
- UCHAR ScanMode; // Use only in beacon request, other requests did not use this field
- USHORT Duration;
-} MEASUREMENT_REQUEST, *PMEASUREMENT_REQUEST;
-
-// Beacon Measurement Report
-// All these field might change to UCHAR, because we didn't do anything to these report.
-// We copy all these beacons and report to CCX 2 AP.
-typedef struct _BEACON_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR PhyType; // Definiation is listed above table 36-9
- UCHAR RxPower;
- UCHAR BSSID[6];
- UCHAR ParentTSF[4];
- UCHAR TargetTSF[8];
- USHORT BeaconInterval;
- USHORT CapabilityInfo;
-} BEACON_REPORT, *PBEACON_REPORT;
-
-// Frame Measurement Report (Optional)
-typedef struct _FRAME_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR TA;
- UCHAR BSSID[6];
- UCHAR RSSI;
- UCHAR Count;
-} FRAME_REPORT, *PFRAME_REPORT;
-
-#pragma pack(1)
-// Channel Load Report
-typedef struct _CHANNEL_LOAD_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR CCABusy;
-} CHANNEL_LOAD_REPORT, *PCHANNEL_LOAD_REPORT;
-#pragma pack()
-
-// Nosie Histogram Report
-typedef struct _NOISE_HIST_REPORT {
- UCHAR Channel;
- UCHAR Spare;
- USHORT Duration;
- UCHAR Density[8];
-} NOISE_HIST_REPORT, *PNOISE_HIST_REPORT;
-
-// Radio Management Capability element
-typedef struct _RADIO_MANAGEMENT_CAPABILITY {
- UCHAR Eid; // TODO: Why the Eid is 1 byte, not normal 2 bytes???
- UCHAR Length;
- UCHAR AironetOui[3]; // AIronet OUI (00 40 96)
- UCHAR Type; // Type / Version
- USHORT Status; // swap16 required
-} RADIO_MANAGEMENT_CAPABILITY, *PRADIO_MANAGEMENT_CAPABILITY;
-
-// Measurement Mode Bit definition
-typedef struct _MEASUREMENT_MODE {
- UCHAR Rsvd:4;
- UCHAR Report:1;
- UCHAR NotUsed:1;
- UCHAR Enable:1;
- UCHAR Parallel:1;
-} MEASUREMENT_MODE, *PMEASUREMENT_MODE;
-
-// Measurement Request element, This is little endian mode
-typedef struct _MEASUREMENT_REQUEST_ELEMENT {
- USHORT Eid;
- USHORT Length; // swap16 required
- USHORT Token; // non-zero unique token
- UCHAR Mode; // Measurement Mode
- UCHAR Type; // Measurement type
-} MEASUREMENT_REQUEST_ELEMENT, *PMEASUREMENT_REQUEST_ELEMENT;
-
-// Measurement Report element, This is little endian mode
-typedef struct _MEASUREMENT_REPORT_ELEMENT {
- USHORT Eid;
- USHORT Length; // swap16 required
- USHORT Token; // non-zero unique token
- UCHAR Mode; // Measurement Mode
- UCHAR Type; // Measurement type
-} MEASUREMENT_REPORT_ELEMENT, *PMEASUREMENT_REPORT_ELEMENT;
-
-// Cisco Aironet IAPP Frame Header, Network byte order used
-typedef struct _AIRONET_IAPP_HEADER {
- UCHAR CiscoSnapHeader[8]; // 8 bytes Cisco snap header
- USHORT Length; // IAPP ID & length, remember to swap16 in LE system
- UCHAR Type; // IAPP type
- UCHAR SubType; // IAPP subtype
- UCHAR DA[6]; // Destination MAC address
- UCHAR SA[6]; // Source MAC address
- USHORT Token; // Dialog token, no need to swap16 since it is for yoken usage only
-} AIRONET_IAPP_HEADER, *PAIRONET_IAPP_HEADER;
-
-// Radio Measurement Request frame
-typedef struct _AIRONET_RM_REQUEST_FRAME {
- AIRONET_IAPP_HEADER IAPP; // Common header
- UCHAR Delay; // Activation Delay
- UCHAR Offset; // Measurement offset
-} AIRONET_RM_REQUEST_FRAME, *PAIRONET_RM_REQUEST_FRAME;
-
-// Radio Measurement Report frame
-typedef struct _AIRONET_RM_REPORT_FRAME {
- AIRONET_IAPP_HEADER IAPP; // Common header
-} AIRONET_RM_REPORT_FRAME, *PAIRONET_RM_REPORT_FRAME;
-
-// Saved element request actions which will saved in StaCfg.
-typedef struct _RM_REQUEST_ACTION {
- MEASUREMENT_REQUEST_ELEMENT ReqElem; // Saved request element
- MEASUREMENT_REQUEST Measurement; // Saved measurement within the request element
-} RM_REQUEST_ACTION, *PRM_REQUEST_ACTION;
-
-// CCX administration control
-typedef union _CCX_CONTROL {
- struct {
- UINT32 Enable:1; // Enable CCX2
- UINT32 LeapEnable:1; // Enable LEAP at CCX2
- UINT32 RMEnable:1; // Radio Measurement Enable
- UINT32 DCRMEnable:1; // Non serving channel Radio Measurement enable
- UINT32 QOSEnable:1; // Enable QOS for CCX 2.0 support
- UINT32 FastRoamEnable:1; // Enable fast roaming
- UINT32 Rsvd:2; // Not used
- UINT32 dBmToRoam:8; // the condition to roam when receiving Rssi less than this value. It's negative value.
- UINT32 TuLimit:16; // Limit for different channel scan
- } field;
- UINT32 word;
-} CCX_CONTROL, *PCCX_CONTROL;
-
-#endif // __AIRONET_H__
+#include "../rt2870/aironet.h"
diff --git a/drivers/staging/rt3070/ap.h b/drivers/staging/rt3070/ap.h
index f5ba042e52ba..ab8de4bbad04 100644
--- a/drivers/staging/rt3070/ap.h
+++ b/drivers/staging/rt3070/ap.h
@@ -1,557 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- ap.h
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
- James Tan 09-06-2002 modified (Revise NTCRegTable)
- John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
-*/
-#ifndef __AP_H__
-#define __AP_H__
-
-
-
-// ========================= AP RTMP.h ================================
-
-
-
-// =============================================================
-// Function Prototypes
-// =============================================================
-
-// ap_data.c
-
-BOOLEAN APBridgeToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN ULONG fromwdsidx);
-
-BOOLEAN APHandleRxDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID APSendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets);
-
-NDIS_STATUS APSendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-NDIS_STATUS APHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx);
-
-VOID APRxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-NDIS_STATUS APCheckRxError(
- IN PRTMP_ADAPTER pAd,
- IN PRT28XX_RXD_STRUC pRxD,
- IN UCHAR Wcid);
-
-BOOLEAN APCheckClass2Class3Error(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN PHEADER_802_11 pHeader);
-
-VOID APHandleRxPsPoll(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN USHORT Aid,
- IN BOOLEAN isActive);
-
-VOID RTMPDescriptorEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType);
-
-VOID RTMPFrameEndianChange(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG Dir,
- IN BOOLEAN FromRxDoneInt);
-
-// ap_assoc.c
-
-VOID APAssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APPeerAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MbssKickOutStas(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN USHORT Reason);
-
-VOID APMlmeKickOutSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pStaAddr,
- IN UCHAR Wcid,
- IN USHORT Reason);
-
-VOID APMlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APCls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN PHEADER_802_11 pHeader);
-
-
-USHORT APBuildAssociation(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN USHORT CapabilityInfo,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN UCHAR *RSN,
- IN UCHAR *pRSNLen,
- IN BOOLEAN bWmmCapable,
- IN ULONG RalinkIe,
-#ifdef DOT11N_DRAFT3
- IN EXT_CAP_INFO_ELEMENT ExtCapInfo,
-#endif // DOT11N_DRAFT3 //
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- OUT USHORT *pAid);
-
-/*
-VOID RTMPAddClientSec(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN PUCHAR pKey,
- IN PUCHAR pTxMic,
- IN PUCHAR pRxMic,
- IN MAC_TABLE_ENTRY *pEntry);
-*/
-
-// ap_auth.c
-
-void APAuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APMlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APCls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN PHEADER_802_11 pHeader);
-
-// ap_authrsp.c
-
-VOID APAuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[]);
-
-VOID APPeerAuthAtAuthRspIdleAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT StatusCode);
-
-// ap_connect.c
-
-BOOLEAN BeaconTransmitRequired(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx);
-
-VOID APMakeBssBeacon(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx);
-
-VOID APUpdateBeaconFrame(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx);
-
-VOID APMakeAllBssBeacon(
- IN PRTMP_ADAPTER pAd);
-
-VOID APUpdateAllBeaconFrame(
- IN PRTMP_ADAPTER pAd);
-
-
-// ap_sync.c
-
-VOID APSyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID APInvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerBeaconAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APMlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APScanCnclAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ApSiteSurvey(
- IN PRTMP_ADAPTER pAd);
-
-VOID SupportRate(
- IN PUCHAR SupRate,
- IN UCHAR SupRateLen,
- IN PUCHAR ExtRate,
- IN UCHAR ExtRateLen,
- OUT PUCHAR *Rates,
- OUT PUCHAR RatesLen,
- OUT PUCHAR pMaxSupportRate);
-
-
-BOOLEAN ApScanRunning(
- IN PRTMP_ADAPTER pAd);
-
-#ifdef DOT11N_DRAFT3
-VOID APOverlappingBSSScan(
- IN RTMP_ADAPTER *pAd);
-#endif // DOT11N_DRAFT3 //
-
-// ap_wpa.c
-
-VOID APWpaStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-// ap_mlme.c
-
-VOID APMlmePeriodicExec(
- IN PRTMP_ADAPTER pAd);
-
-VOID APMlmeSelectTxRateTable(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR *ppTable,
- IN PUCHAR pTableSize,
- IN PUCHAR pInitTxRateIdx);
-
-VOID APMlmeSetTxRate(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PRTMP_TX_RATE_SWITCH pTxRate);
-
-VOID APMlmeDynamicTxRateSwitching(
- IN PRTMP_ADAPTER pAd);
-
-VOID APQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN APMsgTypeSubst(
- IN PRTMP_ADAPTER pAd,
- IN PFRAME_802_11 pFrame,
- OUT INT *Machine,
- OUT INT *MsgType);
-
-VOID APQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-#ifdef RT2870
-VOID BeaconUpdateExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-#endif // RT2870 //
-
-VOID RTMPSetPiggyBack(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bPiggyBack);
-
-VOID APAsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd);
-
-VOID APAsicRxAntEvalTimeout(
- IN PRTMP_ADAPTER pAd);
-
-// ap.c
-
-VOID APSwitchChannel(
- IN PRTMP_ADAPTER pAd,
- IN INT Channel);
-
-NDIS_STATUS APInitialize(
- IN PRTMP_ADAPTER pAd);
-
-VOID APShutdown(
- IN PRTMP_ADAPTER pAd);
-
-VOID APStartUp(
- IN PRTMP_ADAPTER pAd);
-
-VOID APStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID APCleanupPsQueue(
- IN PRTMP_ADAPTER pAd,
- IN PQUEUE_HEADER pQueue);
-
-VOID MacTableReset(
- IN PRTMP_ADAPTER pAd);
-
-MAC_TABLE_ENTRY *MacTableInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR apidx,
- IN BOOLEAN CleanAll);
-
-BOOLEAN MacTableDeleteEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr);
-
-MAC_TABLE_ENTRY *MacTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr);
-
-VOID MacTableMaintenance(
- IN PRTMP_ADAPTER pAd);
-
-UINT32 MacTableAssocStaNumGet(
- IN PRTMP_ADAPTER pAd);
-
-MAC_TABLE_ENTRY *APSsPsInquiry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- OUT SST *Sst,
- OUT USHORT *Aid,
- OUT UCHAR *PsMode,
- OUT UCHAR *Rate);
-
-BOOLEAN APPsIndicate(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN ULONG Wcid,
- IN UCHAR Psm);
-
-VOID ApLogEvent(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN USHORT Event);
-
-#ifdef DOT11_N_SUPPORT
-VOID APUpdateOperationMode(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
-
-VOID APUpdateCapabilityAndErpIe(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN ApCheckAccessControlList(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR Apidx);
-
-VOID ApUpdateAccessControlList(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Apidx);
-
-VOID ApEnqueueNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR TxRate,
- IN UCHAR PID,
- IN UCHAR apidx,
- IN BOOLEAN bQosNull,
- IN BOOLEAN bEOSP,
- IN UCHAR OldUP);
-
-VOID ApSendFrame(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuffer,
- IN ULONG Length,
- IN UCHAR TxRate,
- IN UCHAR PID);
-
-VOID ApEnqueueAckFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR TxRate,
- IN UCHAR apidx);
-
-UCHAR APAutoSelectChannel(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN Optimal);
-
-// ap_sanity.c
-
-
-BOOLEAN PeerAssocReqCmmSanity(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN isRessoc,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pListenInterval,
- OUT PUCHAR pApAddr,
- OUT UCHAR *pSsidLen,
- OUT char *Ssid,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *RSN,
- OUT UCHAR *pRSNLen,
- OUT BOOLEAN *pbWmmCapable,
- OUT ULONG *pRalinkIe,
-#ifdef DOT11N_DRAFT3
- OUT EXT_CAP_INFO_ELEMENT *pExtCapInfo,
-#endif // DOT11N_DRAFT3 //
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-
-BOOLEAN PeerDisassocReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN PeerDeauthReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN APPeerAuthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr1,
- OUT PUCHAR pAddr2,
- OUT USHORT *Alg,
- OUT USHORT *Seq,
- OUT USHORT *Status,
- CHAR *ChlgText);
-
-BOOLEAN APPeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *SsidLen);
-
-BOOLEAN APPeerBeaconAndProbeRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT PUCHAR pBssid,
- OUT CHAR Ssid[],
- OUT UCHAR *SsidLen,
- OUT UCHAR *BssType,
- OUT USHORT *BeaconPeriod,
- OUT UCHAR *Channel,
- OUT LARGE_INTEGER *Timestamp,
- OUT USHORT *CapabilityInfo,
- OUT UCHAR Rate[],
- OUT UCHAR *RateLen,
- OUT BOOLEAN *ExtendedRateIeExist,
- OUT UCHAR *Erp);
-
-
-// ================== end of AP RTMP.h ========================
-
-
-#endif // __AP_H__
-
+#include "../rt2870/ap.h"
diff --git a/drivers/staging/rt3070/chlist.h b/drivers/staging/rt3070/chlist.h
index 7151e8668cb5..8ee1ff527f5d 100644
--- a/drivers/staging/rt3070/chlist.h
+++ b/drivers/staging/rt3070/chlist.h
@@ -1,1253 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- chlist.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Fonchi Wu 2007-12-19 created
-*/
-
-#ifndef __CHLIST_H__
-#define __CHLIST_H__
-
-#include "rtmp_type.h"
-#include "rtmp_def.h"
-
-
-#define ODOR 0
-#define IDOR 1
-#define BOTH 2
-
-#define BAND_5G 0
-#define BAND_24G 1
-#define BAND_BOTH 2
-
-typedef struct _CH_DESP {
- UCHAR FirstChannel;
- UCHAR NumOfCh;
- CHAR MaxTxPwr; // dBm
- UCHAR Geography; // 0:out door, 1:in door, 2:both
- BOOLEAN DfsReq; // Dfs require, 0: No, 1: yes.
-} CH_DESP, *PCH_DESP;
-
-typedef struct _CH_REGION {
- UCHAR CountReg[3];
- UCHAR DfsType; // 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56
- CH_DESP ChDesp[10];
-} CH_REGION, *PCH_REGION;
-
-static CH_REGION ChRegion[] =
-{
- { // Antigua and Berbuda
- "AG",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Argentina
- "AR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Aruba
- "AW",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Australia
- "AU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Austria
- "AT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Bahamas
- "BS",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Barbados
- "BB",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Bermuda
- "BM",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Brazil
- "BR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 24, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Belgium
- "BE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 18, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 18, IDOR, FALSE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Bulgaria
- "BG",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Canada
- "CA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Cayman IsLands
- "KY",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Chile
- "CL",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // China
- "CN",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Colombia
- "CO",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Costa Rica
- "CR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Cyprus
- "CY",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Czech_Republic
- "CZ",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Denmark
- "DK",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Dominican Republic
- "DO",
- CE,
- {
- { 1, 0, 20, BOTH, FALSE}, // 2.4 G, ch 0
- { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Equador
- "EC",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 100, 11, 27, BOTH, FALSE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // El Salvador
- "SV",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 30, BOTH, TRUE}, // 5G, ch 52~64
- { 149, 4, 36, BOTH, TRUE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Finland
- "FI",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // France
- "FR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Germany
- "DE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Greece
- "GR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Guam
- "GU",
- CE,
- {
- { 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Guatemala
- "GT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Haiti
- "HT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Honduras
- "HN",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Hong Kong
- "HK",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Hungary
- "HU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Iceland
- "IS",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // India
- "IN",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 24, IDOR, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Indonesia
- "ID",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Ireland
- "IE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Israel
- "IL",
- CE,
- {
- { 1, 3, 20, IDOR, FALSE}, // 2.4 G, ch 1~3
- { 4, 6, 20, BOTH, FALSE}, // 2.4 G, ch 4~9
- { 10, 4, 20, IDOR, FALSE}, // 2.4 G, ch 10~13
- { 0}, // end
- }
- },
-
- { // Italy
- "IT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Japan
- "JP",
- JAP,
- {
- { 1, 14, 20, BOTH, FALSE}, // 2.4 G, ch 1~14
- { 34, 4, 23, IDOR, FALSE}, // 5G, ch 34~46
- { 0}, // end
- }
- },
-
- { // Jordan
- "JO",
- CE,
- {
- { 1, 13, 20, IDOR, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 149, 4, 23, IDOR, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Latvia
- "LV",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Liechtenstein
- "LI",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Lithuania
- "LT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Luxemburg
- "LU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Malaysia
- "MY",
- CE,
- {
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Malta
- "MT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Marocco
- "MA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
- { 0}, // end
- }
- },
-
- { // Mexico
- "MX",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 5, 30, IDOR, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Netherlands
- "NL",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // New Zealand
- "NZ",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 24, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Norway
- "NO",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Peru
- "PE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Portugal
- "PT",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Poland
- "PL",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Romania
- "RO",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Russia
- "RU",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 149, 4, 20, IDOR, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Saudi Arabia
- "SA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 23, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Serbia_and_Montenegro
- "CS",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 0}, // end
- }
- },
-
- { // Singapore
- "SG",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Slovakia
- "SK",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Slovenia
- "SI",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // South Africa
- "ZA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // South Korea
- "KR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 8, 20, BOTH, FALSE}, // 5G, ch 100~128
- { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Spain
- "ES",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 17, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Sweden
- "SE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Switzerland
- "CH",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
- { 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Taiwan
- "TW",
- CE,
- {
- { 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // Turkey
- "TR",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
- { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
- { 0}, // end
- }
- },
-
- { // UK
- "GB",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
- { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 0}, // end
- }
- },
-
- { // Ukraine
- "UA",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 0}, // end
- }
- },
-
- { // United_Arab_Emirates
- "AE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 0}, // end
- }
- },
-
- { // United_States
- "US",
- CE,
- {
- { 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 17, IDOR, FALSE}, // 5G, ch 52~64
- { 52, 4, 24, BOTH, TRUE}, // 5G, ch 52~64
- { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
- { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-
- { // Venezuela
- "VE",
- CE,
- {
- { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
- { 0}, // end
- }
- },
-
- { // Default
- "",
- CE,
- {
- { 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
- { 36, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
- { 100, 11, 20, BOTH, FALSE}, // 5G, ch 100~140
- { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
- { 0}, // end
- }
- },
-};
-
-static inline PCH_REGION GetChRegion(
- IN PUCHAR CntryCode)
-{
- INT loop = 0;
- PCH_REGION pChRegion = NULL;
-
- while (strcmp(ChRegion[loop].CountReg, "") != 0)
- {
- if (strncmp(ChRegion[loop].CountReg, CntryCode, 2) == 0)
- {
- pChRegion = &ChRegion[loop];
- break;
- }
- loop++;
- }
-
- if (pChRegion == NULL)
- pChRegion = &ChRegion[loop];
- return pChRegion;
-}
-
-static inline VOID ChBandCheck(
- IN UCHAR PhyMode,
- OUT PUCHAR pChType)
-{
- switch(PhyMode)
- {
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AN_MIXED:
-#endif // DOT11_N_SUPPORT //
- *pChType = BAND_5G;
- break;
- case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AGN_MIXED:
- case PHY_11ABGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- *pChType = BAND_BOTH;
- break;
-
- default:
- *pChType = BAND_24G;
- break;
- }
-}
-
-static inline UCHAR FillChList(
- IN PRTMP_ADAPTER pAd,
- IN PCH_DESP pChDesp,
- IN UCHAR Offset,
- IN UCHAR increment)
-{
- INT i, j, l;
- UCHAR channel;
-
- j = Offset;
- for (i = 0; i < pChDesp->NumOfCh; i++)
- {
- channel = pChDesp->FirstChannel + i * increment;
- for (l=0; l<MAX_NUM_OF_CHANNELS; l++)
- {
- if (channel == pAd->TxPower[l].Channel)
- {
- pAd->ChannelList[j].Power = pAd->TxPower[l].Power;
- pAd->ChannelList[j].Power2 = pAd->TxPower[l].Power2;
- break;
- }
- }
- if (l == MAX_NUM_OF_CHANNELS)
- continue;
-
- pAd->ChannelList[j].Channel = pChDesp->FirstChannel + i * increment;
- pAd->ChannelList[j].MaxTxPwr = pChDesp->MaxTxPwr;
- pAd->ChannelList[j].DfsReq = pChDesp->DfsReq;
- j++;
- }
- pAd->ChannelListNum = j;
-
- return j;
-}
-
-static inline VOID CreateChList(
- IN PRTMP_ADAPTER pAd,
- IN PCH_REGION pChRegion,
- IN UCHAR Geography)
-{
- INT i;
- UCHAR offset = 0;
- PCH_DESP pChDesp;
- UCHAR ChType;
- UCHAR increment;
-
- if (pChRegion == NULL)
- return;
-
- ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
-
- for (i=0; i<10; i++)
- {
- pChDesp = &pChRegion->ChDesp[i];
- if (pChDesp->FirstChannel == 0)
- break;
-
- if (ChType == BAND_5G)
- {
- if (pChDesp->FirstChannel <= 14)
- continue;
- }
- else if (ChType == BAND_24G)
- {
- if (pChDesp->FirstChannel > 14)
- continue;
- }
-
- if ((pChDesp->Geography == BOTH)
- || (pChDesp->Geography == Geography))
- {
- if (pChDesp->FirstChannel > 14)
- increment = 4;
- else
- increment = 1;
- offset = FillChList(pAd, pChDesp, offset, increment);
- }
- }
-}
-
-static inline VOID BuildChannelListEx(
- IN PRTMP_ADAPTER pAd)
-{
- PCH_REGION pChReg;
-
- pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
- CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
-}
-
-static inline VOID BuildBeaconChList(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf,
- OUT PULONG pBufLen)
-{
- INT i;
- ULONG TmpLen;
- PCH_REGION pChRegion;
- PCH_DESP pChDesp;
- UCHAR ChType;
-
- pChRegion = GetChRegion(pAd->CommonCfg.CountryCode);
-
- if (pChRegion == NULL)
- return;
-
- ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
- *pBufLen = 0;
-
- for (i=0; i<10; i++)
- {
- pChDesp = &pChRegion->ChDesp[i];
- if (pChDesp->FirstChannel == 0)
- break;
-
- if (ChType == BAND_5G)
- {
- if (pChDesp->FirstChannel <= 14)
- continue;
- }
- else if (ChType == BAND_24G)
- {
- if (pChDesp->FirstChannel > 14)
- continue;
- }
-
- if ((pChDesp->Geography == BOTH)
- || (pChDesp->Geography == pAd->CommonCfg.Geography))
- {
- MakeOutgoingFrame(pBuf + *pBufLen, &TmpLen,
- 1, &pChDesp->FirstChannel,
- 1, &pChDesp->NumOfCh,
- 1, &pChDesp->MaxTxPwr,
- END_OF_ARGS);
- *pBufLen += TmpLen;
- }
- }
-}
-
-
-#ifdef DOT11_N_SUPPORT
-static inline BOOLEAN IsValidChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel)
-
-{
- INT i;
-
- for (i = 0; i < pAd->ChannelListNum; i++)
- {
- if (pAd->ChannelList[i].Channel == channel)
- break;
- }
-
- if (i == pAd->ChannelListNum)
- return FALSE;
- else
- return TRUE;
-}
-
-
-static inline UCHAR GetExtCh(
- IN UCHAR Channel,
- IN UCHAR Direction)
-{
- CHAR ExtCh;
-
- if (Direction == EXTCHA_ABOVE)
- ExtCh = Channel + 4;
- else
- ExtCh = (Channel - 4) > 0 ? (Channel - 4) : 0;
-
- return ExtCh;
-}
-
-
-static inline VOID N_ChannelCheck(
- IN PRTMP_ADAPTER pAd)
-{
- //UCHAR ChannelNum = pAd->ChannelListNum;
- UCHAR Channel = pAd->CommonCfg.Channel;
-
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
- {
- if (Channel > 14)
- {
- if ((Channel == 36) || (Channel == 44) || (Channel == 52) || (Channel == 60) || (Channel == 100) || (Channel == 108) ||
- (Channel == 116) || (Channel == 124) || (Channel == 132) || (Channel == 149) || (Channel == 157))
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- }
- else if ((Channel == 40) || (Channel == 48) || (Channel == 56) || (Channel == 64) || (Channel == 104) || (Channel == 112) ||
- (Channel == 120) || (Channel == 128) || (Channel == 136) || (Channel == 153) || (Channel == 161))
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- }
- }
- else
- {
- do
- {
- UCHAR ExtCh;
- UCHAR Dir = pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
- ExtCh = GetExtCh(Channel, Dir);
- if (IsValidChannel(pAd, ExtCh))
- break;
-
- Dir = (Dir == EXTCHA_ABOVE) ? EXTCHA_BELOW : EXTCHA_ABOVE;
- ExtCh = GetExtCh(Channel, Dir);
- if (IsValidChannel(pAd, ExtCh))
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = Dir;
- break;
- }
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- } while(FALSE);
-
- if (Channel == 14)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- //pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT()
- }
- }
- }
-
-
-}
-
-
-static inline VOID N_SetCenCh(
- IN PRTMP_ADAPTER pAd)
-{
- if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
- {
- if (pAd->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
- {
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
- }
- else
- {
- if (pAd->CommonCfg.Channel == 14)
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 1;
- else
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
- }
- }
- else
- {
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-
-static inline UINT8 GetCuntryMaxTxPwr(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 channel)
-{
- int i;
- for (i = 0; i < pAd->ChannelListNum; i++)
- {
- if (pAd->ChannelList[i].Channel == channel)
- break;
- }
-
- if (i == pAd->ChannelListNum)
- return 0xff;
- else
- return pAd->ChannelList[i].MaxTxPwr;
-}
-#endif // __CHLIST_H__
-
+#include "../rt2870/chlist.h"
diff --git a/drivers/staging/rt3070/common/2870_rtmp_init.c b/drivers/staging/rt3070/common/2870_rtmp_init.c
index fdf8dc176a67..5456454b8d3e 100644
--- a/drivers/staging/rt3070/common/2870_rtmp_init.c
+++ b/drivers/staging/rt3070/common/2870_rtmp_init.c
@@ -1,1762 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- 2870_rtmp_init.c
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 2002-08-01 created
- John Chang 2004-08-20 RT2561/2661 use scatter-gather scheme
- Jan Lee 2006-09-15 RT2860. Change for 802.11n , EEPROM, Led, BA, HT.
- Sample Lin 2007-05-31 Merge RT2860 and RT2870 drivers.
-*/
-
-#include "../rt_config.h"
-
-
-static void rx_done_tasklet(unsigned long data);
-static void rt2870_hcca_dma_done_tasklet(unsigned long data);
-static void rt2870_ac3_dma_done_tasklet(unsigned long data);
-static void rt2870_ac2_dma_done_tasklet(unsigned long data);
-static void rt2870_ac1_dma_done_tasklet(unsigned long data);
-static void rt2870_ac0_dma_done_tasklet(unsigned long data);
-static void rt2870_mgmt_dma_done_tasklet(unsigned long data);
-static void rt2870_null_frame_complete_tasklet(unsigned long data);
-static void rt2870_rts_frame_complete_tasklet(unsigned long data);
-static void rt2870_pspoll_frame_complete_tasklet(unsigned long data);
-static void rt2870_dataout_complete_tasklet(unsigned long data);
-
-
-/*
-========================================================================
-Routine Description:
- Initialize receive data structures.
-
-Arguments:
- pAd Pointer to our adapter
-
-Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_RESOURCES
-
-Note:
- Initialize all receive releated private buffer, include those define
- in RTMP_ADAPTER structure and all private data structures. The mahor
- work is to allocate buffer for each packet and chain buffer to
- NDIS packet descriptor.
-========================================================================
-*/
-NDIS_STATUS NICInitRecv(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitRecv\n"));
- pObj = pObj;
-
- //InterlockedExchange(&pAd->PendingRx, 0);
- pAd->PendingRx = 0;
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = 0 ; //RX_RING_SIZE -1; // Rx Bulk pointer
- pAd->NextRxBulkInPosition = 0;
-
- for (i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
-
- //Allocate URB
- pRxContext->pUrb = RTUSB_ALLOC_URB(0);
- if (pRxContext->pUrb == NULL)
- {
- Status = NDIS_STATUS_RESOURCES;
- goto out1;
- }
-
- // Allocate transfer buffer
- pRxContext->TransferBuffer = RTUSB_URB_ALLOC_BUFFER(pObj->pUsb_Dev, MAX_RXBULK_SIZE, &pRxContext->data_dma);
- if (pRxContext->TransferBuffer == NULL)
- {
- Status = NDIS_STATUS_RESOURCES;
- goto out1;
- }
-
- NdisZeroMemory(pRxContext->TransferBuffer, MAX_RXBULK_SIZE);
-
- pRxContext->pAd = pAd;
- pRxContext->pIrp = NULL;
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
- //pRxContext->ReorderInUse = FALSE;
- pRxContext->bRxHandling = FALSE;
- pRxContext->BulkInOffset = 0;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitRecv\n"));
- return Status;
-
-out1:
- for (i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
-
- if (NULL != pRxContext->TransferBuffer)
- {
- RTUSB_URB_FREE_BUFFER(pObj->pUsb_Dev, MAX_RXBULK_SIZE,
- pRxContext->TransferBuffer, pRxContext->data_dma);
- pRxContext->TransferBuffer = NULL;
- }
-
- if (NULL != pRxContext->pUrb)
- {
- RTUSB_UNLINK_URB(pRxContext->pUrb);
- RTUSB_FREE_URB(pRxContext->pUrb);
- pRxContext->pUrb = NULL;
- }
- }
-
- return Status;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Initialize transmit data structures.
-
-Arguments:
- pAd Pointer to our adapter
-
-Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_RESOURCES
-
-Note:
-========================================================================
-*/
-NDIS_STATUS NICInitTransmit(
- IN PRTMP_ADAPTER pAd)
-{
-#define LM_USB_ALLOC(pObj, Context, TB_Type, BufferSize, Status, msg1, err1, msg2, err2) \
- Context->pUrb = RTUSB_ALLOC_URB(0); \
- if (Context->pUrb == NULL) { \
- DBGPRINT(RT_DEBUG_ERROR, msg1); \
- Status = NDIS_STATUS_RESOURCES; \
- goto err1; } \
- \
- Context->TransferBuffer = \
- (TB_Type)RTUSB_URB_ALLOC_BUFFER(pObj->pUsb_Dev, BufferSize, &Context->data_dma); \
- if (Context->TransferBuffer == NULL) { \
- DBGPRINT(RT_DEBUG_ERROR, msg2); \
- Status = NDIS_STATUS_RESOURCES; \
- goto err2; }
-
-#define LM_URB_FREE(pObj, Context, BufferSize) \
- if (NULL != Context->pUrb) { \
- RTUSB_UNLINK_URB(Context->pUrb); \
- RTUSB_FREE_URB(Context->pUrb); \
- Context->pUrb = NULL; } \
- if (NULL != Context->TransferBuffer) { \
- RTUSB_URB_FREE_BUFFER(pObj->pUsb_Dev, BufferSize, \
- Context->TransferBuffer, \
- Context->data_dma); \
- Context->TransferBuffer = NULL; }
-
- UCHAR i, acidx;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PTX_CONTEXT pNullContext = &(pAd->NullContext);
- PTX_CONTEXT pPsPollContext = &(pAd->PsPollContext);
- PTX_CONTEXT pRTSContext = &(pAd->RTSContext);
- PTX_CONTEXT pMLMEContext = NULL;
-// PHT_TX_CONTEXT pHTTXContext = NULL;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
- PVOID RingBaseVa;
-// RTMP_TX_RING *pTxRing;
- RTMP_MGMT_RING *pMgmtRing;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitTransmit\n"));
- pObj = pObj;
-
- // Init 4 set of Tx parameters
- for(acidx = 0; acidx < NUM_OF_TX_RING; acidx++)
- {
- // Initialize all Transmit releated queues
- InitializeQueueHeader(&pAd->TxSwQueue[acidx]);
-
- // Next Local tx ring pointer waiting for buck out
- pAd->NextBulkOutIndex[acidx] = acidx;
- pAd->BulkOutPending[acidx] = FALSE; // Buck Out control flag
- //pAd->DataBulkDoneIdx[acidx] = 0;
- }
-
- //pAd->NextMLMEIndex = 0;
- //pAd->PushMgmtIndex = 0;
- //pAd->PopMgmtIndex = 0;
- //InterlockedExchange(&pAd->MgmtQueueSize, 0);
- //InterlockedExchange(&pAd->TxCount, 0);
-
- //pAd->PrioRingFirstIndex = 0;
- //pAd->PrioRingTxCnt = 0;
-
- do
- {
- //
- // TX_RING_SIZE, 4 ACs
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- for(acidx=0; acidx<4; acidx++)
-#endif // CONFIG_STA_SUPPORT //
- {
-#if 1 //def DOT11_N_SUPPORT
- PHT_TX_CONTEXT pHTTXContext = &(pAd->TxContext[acidx]);
-
- NdisZeroMemory(pHTTXContext, sizeof(HT_TX_CONTEXT));
- //Allocate URB
- LM_USB_ALLOC(pObj, pHTTXContext, PHTTX_BUFFER, sizeof(HTTX_BUFFER), Status,
- ("<-- ERROR in Alloc TX TxContext[%d] urb!! \n", acidx),
- done,
- ("<-- ERROR in Alloc TX TxContext[%d] HTTX_BUFFER !! \n", acidx),
- out1);
-
- NdisZeroMemory(pHTTXContext->TransferBuffer->Aggregation, 4);
- pHTTXContext->pAd = pAd;
- pHTTXContext->pIrp = NULL;
- pHTTXContext->IRPPending = FALSE;
- pHTTXContext->NextBulkOutPosition = 0;
- pHTTXContext->ENextBulkOutPosition = 0;
- pHTTXContext->CurWritePosition = 0;
- pHTTXContext->CurWriteRealPos = 0;
- pHTTXContext->BulkOutSize = 0;
- pHTTXContext->BulkOutPipeId = acidx;
- pHTTXContext->bRingEmpty = TRUE;
- pHTTXContext->bCopySavePad = FALSE;
-#endif // DOT11_N_SUPPORT //
- pAd->BulkOutPending[acidx] = FALSE;
- }
-
-
- //
- // MGMT_RING_SIZE
- //
- // Allocate MGMT ring descriptor's memory
- pAd->MgmtDescRing.AllocSize = MGMT_RING_SIZE * sizeof(TX_CONTEXT);
- RTMPAllocateMemory(&pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocSize);
- if (pAd->MgmtDescRing.AllocVa == NULL)
- {
- DBGPRINT_ERR(("Failed to allocate a big buffer for MgmtDescRing!\n"));
- Status = NDIS_STATUS_RESOURCES;
- goto out1;
- }
- NdisZeroMemory(pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocSize);
- RingBaseVa = pAd->MgmtDescRing.AllocVa;
-
- // Initialize MGMT Ring and associated buffer memory
- pMgmtRing = &pAd->MgmtRing;
- for (i = 0; i < MGMT_RING_SIZE; i++)
- {
- // link the pre-allocated Mgmt buffer to MgmtRing.Cell
- pMgmtRing->Cell[i].AllocSize = sizeof(TX_CONTEXT);
- pMgmtRing->Cell[i].AllocVa = RingBaseVa;
- pMgmtRing->Cell[i].pNdisPacket = NULL;
- pMgmtRing->Cell[i].pNextNdisPacket = NULL;
-
- //Allocate URB for MLMEContext
- pMLMEContext = (PTX_CONTEXT) pAd->MgmtRing.Cell[i].AllocVa;
- pMLMEContext->pUrb = RTUSB_ALLOC_URB(0);
- if (pMLMEContext->pUrb == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("<-- ERROR in Alloc TX MLMEContext[%d] urb!! \n", i));
- Status = NDIS_STATUS_RESOURCES;
- goto out2;
- }
- pMLMEContext->pAd = pAd;
- pMLMEContext->pIrp = NULL;
- pMLMEContext->TransferBuffer = NULL;
- pMLMEContext->InUse = FALSE;
- pMLMEContext->IRPPending = FALSE;
- pMLMEContext->bWaitingBulkOut = FALSE;
- pMLMEContext->BulkOutSize = 0;
- pMLMEContext->SelfIdx = i;
-
- // Offset to next ring descriptor address
- RingBaseVa = (PUCHAR) RingBaseVa + sizeof(TX_CONTEXT);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("MGMT Ring: total %d entry allocated\n", i));
-
- //pAd->MgmtRing.TxSwFreeIdx = (MGMT_RING_SIZE - 1);
- pAd->MgmtRing.TxSwFreeIdx = MGMT_RING_SIZE;
- pAd->MgmtRing.TxCpuIdx = 0;
- pAd->MgmtRing.TxDmaIdx = 0;
-
- //
- // BEACON_RING_SIZE
- //
- for(i=0; i<BEACON_RING_SIZE; i++) // 2
- {
- PTX_CONTEXT pBeaconContext = &(pAd->BeaconContext[i]);
-
-
- NdisZeroMemory(pBeaconContext, sizeof(TX_CONTEXT));
-
- //Allocate URB
- LM_USB_ALLOC(pObj, pBeaconContext, PTX_BUFFER, sizeof(TX_BUFFER), Status,
- ("<-- ERROR in Alloc TX BeaconContext[%d] urb!! \n", i),
- out2,
- ("<-- ERROR in Alloc TX BeaconContext[%d] TX_BUFFER !! \n", i),
- out3);
-
- pBeaconContext->pAd = pAd;
- pBeaconContext->pIrp = NULL;
- pBeaconContext->InUse = FALSE;
- pBeaconContext->IRPPending = FALSE;
- }
-
- //
- // NullContext
- //
- NdisZeroMemory(pNullContext, sizeof(TX_CONTEXT));
-
- //Allocate URB
- LM_USB_ALLOC(pObj, pNullContext, PTX_BUFFER, sizeof(TX_BUFFER), Status,
- ("<-- ERROR in Alloc TX NullContext urb!! \n"),
- out3,
- ("<-- ERROR in Alloc TX NullContext TX_BUFFER !! \n"),
- out4);
-
- pNullContext->pAd = pAd;
- pNullContext->pIrp = NULL;
- pNullContext->InUse = FALSE;
- pNullContext->IRPPending = FALSE;
-
- //
- // RTSContext
- //
- NdisZeroMemory(pRTSContext, sizeof(TX_CONTEXT));
-
- //Allocate URB
- LM_USB_ALLOC(pObj, pRTSContext, PTX_BUFFER, sizeof(TX_BUFFER), Status,
- ("<-- ERROR in Alloc TX RTSContext urb!! \n"),
- out4,
- ("<-- ERROR in Alloc TX RTSContext TX_BUFFER !! \n"),
- out5);
-
- pRTSContext->pAd = pAd;
- pRTSContext->pIrp = NULL;
- pRTSContext->InUse = FALSE;
- pRTSContext->IRPPending = FALSE;
-
- //
- // PsPollContext
- //
- //NdisZeroMemory(pPsPollContext, sizeof(TX_CONTEXT));
- //Allocate URB
- LM_USB_ALLOC(pObj, pPsPollContext, PTX_BUFFER, sizeof(TX_BUFFER), Status,
- ("<-- ERROR in Alloc TX PsPollContext urb!! \n"),
- out5,
- ("<-- ERROR in Alloc TX PsPollContext TX_BUFFER !! \n"),
- out6);
-
- pPsPollContext->pAd = pAd;
- pPsPollContext->pIrp = NULL;
- pPsPollContext->InUse = FALSE;
- pPsPollContext->IRPPending = FALSE;
- pPsPollContext->bAggregatible = FALSE;
- pPsPollContext->LastOne = TRUE;
-
- } while (FALSE);
-
-
-done:
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitTransmit\n"));
-
- return Status;
-
- /* --------------------------- ERROR HANDLE --------------------------- */
-out6:
- LM_URB_FREE(pObj, pPsPollContext, sizeof(TX_BUFFER));
-
-out5:
- LM_URB_FREE(pObj, pRTSContext, sizeof(TX_BUFFER));
-
-out4:
- LM_URB_FREE(pObj, pNullContext, sizeof(TX_BUFFER));
-
-out3:
- for(i=0; i<BEACON_RING_SIZE; i++)
- {
- PTX_CONTEXT pBeaconContext = &(pAd->BeaconContext[i]);
- if (pBeaconContext)
- LM_URB_FREE(pObj, pBeaconContext, sizeof(TX_BUFFER));
- }
-
-out2:
- if (pAd->MgmtDescRing.AllocVa)
- {
- pMgmtRing = &pAd->MgmtRing;
- for(i=0; i<MGMT_RING_SIZE; i++)
- {
- pMLMEContext = (PTX_CONTEXT) pAd->MgmtRing.Cell[i].AllocVa;
- if (pMLMEContext)
- LM_URB_FREE(pObj, pMLMEContext, sizeof(TX_BUFFER));
- }
- NdisFreeMemory(pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocSize, 0);
- pAd->MgmtDescRing.AllocVa = NULL;
- }
-
-out1:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- for(acidx=0; acidx<4; acidx++)
-#endif // CONFIG_STA_SUPPORT //
- {
- PHT_TX_CONTEXT pTxContext = &(pAd->TxContext[acidx]);
- if (pTxContext)
- LM_URB_FREE(pObj, pTxContext, sizeof(HTTX_BUFFER));
- }
-
- // Here we didn't have any pre-allocated memory need to free.
-
- return Status;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Allocate DMA memory blocks for send, receive.
-
-Arguments:
- pAd Pointer to our adapter
-
-Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
- NDIS_STATUS_RESOURCES
-
-Note:
-========================================================================
-*/
-NDIS_STATUS RTMPAllocTxRxRingMemory(
- IN PRTMP_ADAPTER pAd)
-{
-// COUNTER_802_11 pCounter = &pAd->WlanCounters;
- NDIS_STATUS Status;
- INT num;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocTxRxRingMemory\n"));
-
-
- do
- {
- // Init the CmdQ and CmdQLock
- NdisAllocateSpinLock(&pAd->CmdQLock);
- NdisAcquireSpinLock(&pAd->CmdQLock);
- RTUSBInitializeCmdQ(&pAd->CmdQ);
- NdisReleaseSpinLock(&pAd->CmdQLock);
-
-
- NdisAllocateSpinLock(&pAd->MLMEBulkOutLock);
- //NdisAllocateSpinLock(&pAd->MLMEWaitQueueLock);
- NdisAllocateSpinLock(&pAd->BulkOutLock[0]);
- NdisAllocateSpinLock(&pAd->BulkOutLock[1]);
- NdisAllocateSpinLock(&pAd->BulkOutLock[2]);
- NdisAllocateSpinLock(&pAd->BulkOutLock[3]);
- NdisAllocateSpinLock(&pAd->BulkOutLock[4]);
- NdisAllocateSpinLock(&pAd->BulkOutLock[5]);
- NdisAllocateSpinLock(&pAd->BulkInLock);
-
- for (num = 0; num < NUM_OF_TX_RING; num++)
- {
- NdisAllocateSpinLock(&pAd->TxContextQueueLock[num]);
- }
-
-#ifdef RALINK_ATE
- NdisAllocateSpinLock(&pAd->GenericLock);
-#endif // RALINK_ATE //
-
-// NdisAllocateSpinLock(&pAd->MemLock); // Not used in RT28XX
-
-// NdisAllocateSpinLock(&pAd->MacTabLock); // init it in UserCfgInit()
-// NdisAllocateSpinLock(&pAd->BATabLock); // init it in BATableInit()
-
-// for(num=0; num<MAX_LEN_OF_BA_REC_TABLE; num++)
-// {
-// NdisAllocateSpinLock(&pAd->BATable.BARecEntry[num].RxReRingLock);
-// }
-
- //
- // Init Mac Table
- //
-// MacTableInitialize(pAd);
-
- //
- // Init send data structures and related parameters
- //
- Status = NICInitTransmit(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- break;
-
- //
- // Init receive data structures and related parameters
- //
- Status = NICInitRecv(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- break;
-
- pAd->PendingIoCount = 1;
-
- } while (FALSE);
-
- NdisZeroMemory(&pAd->FragFrame, sizeof(FRAGMENT_FRAME));
- pAd->FragFrame.pFragPacket = RTMP_AllocateFragPacketBuffer(pAd, RX_BUFFER_NORMSIZE);
-
- if (pAd->FragFrame.pFragPacket == NULL)
- {
- Status = NDIS_STATUS_RESOURCES;
- }
-
- DBGPRINT_S(Status, ("<-- RTMPAllocTxRxRingMemory, Status=%x\n", Status));
- return Status;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Calls USB_InterfaceStop and frees memory allocated for the URBs
- calls NdisMDeregisterDevice and frees the memory
- allocated in VNetInitialize for the Adapter Object
-
-Arguments:
- *pAd the raxx interface data pointer
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-VOID RTMPFreeTxRxRingMemory(
- IN PRTMP_ADAPTER pAd)
-{
-#define LM_URB_FREE(pObj, Context, BufferSize) \
- if (NULL != Context->pUrb) { \
- RTUSB_UNLINK_URB(Context->pUrb); \
- RTUSB_FREE_URB(Context->pUrb); \
- Context->pUrb = NULL; } \
- if (NULL != Context->TransferBuffer) { \
- RTUSB_URB_FREE_BUFFER(pObj->pUsb_Dev, BufferSize, \
- Context->TransferBuffer, \
- Context->data_dma); \
- Context->TransferBuffer = NULL; }
-
-
- UINT i, acidx;
- PTX_CONTEXT pNullContext = &pAd->NullContext;
- PTX_CONTEXT pPsPollContext = &pAd->PsPollContext;
- PTX_CONTEXT pRTSContext = &pAd->RTSContext;
-// PHT_TX_CONTEXT pHTTXContext;
- //PRTMP_REORDERBUF pReorderBuf;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-// RTMP_TX_RING *pTxRing;
-
- DBGPRINT(RT_DEBUG_ERROR, ("---> RTMPFreeTxRxRingMemory\n"));
- pObj = pObj;
-
- // Free all resources for the RECEIVE buffer queue.
- for(i=0; i<(RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
- if (pRxContext)
- LM_URB_FREE(pObj, pRxContext, MAX_RXBULK_SIZE);
- }
-
- // Free PsPoll frame resource
- LM_URB_FREE(pObj, pPsPollContext, sizeof(TX_BUFFER));
-
- // Free NULL frame resource
- LM_URB_FREE(pObj, pNullContext, sizeof(TX_BUFFER));
-
- // Free RTS frame resource
- LM_URB_FREE(pObj, pRTSContext, sizeof(TX_BUFFER));
-
-
- // Free beacon frame resource
- for(i=0; i<BEACON_RING_SIZE; i++)
- {
- PTX_CONTEXT pBeaconContext = &(pAd->BeaconContext[i]);
- if (pBeaconContext)
- LM_URB_FREE(pObj, pBeaconContext, sizeof(TX_BUFFER));
- }
-
-
- // Free mgmt frame resource
- for(i = 0; i < MGMT_RING_SIZE; i++)
- {
- PTX_CONTEXT pMLMEContext = (PTX_CONTEXT)pAd->MgmtRing.Cell[i].AllocVa;
- //LM_URB_FREE(pObj, pMLMEContext, sizeof(TX_BUFFER));
- if (NULL != pAd->MgmtRing.Cell[i].pNdisPacket)
- {
- RTMPFreeNdisPacket(pAd, pAd->MgmtRing.Cell[i].pNdisPacket);
- pAd->MgmtRing.Cell[i].pNdisPacket = NULL;
- pMLMEContext->TransferBuffer = NULL;
- }
-
- if (pMLMEContext)
- {
- if (NULL != pMLMEContext->pUrb)
- {
- RTUSB_UNLINK_URB(pMLMEContext->pUrb);
- RTUSB_FREE_URB(pMLMEContext->pUrb);
- pMLMEContext->pUrb = NULL;
- }
- }
- }
- if (pAd->MgmtDescRing.AllocVa)
- NdisFreeMemory(pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocSize, 0);
-
-
- // Free Tx frame resource
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- for(acidx=0; acidx<4; acidx++)
-#endif // CONFIG_STA_SUPPORT //
- {
- PHT_TX_CONTEXT pHTTXContext = &(pAd->TxContext[acidx]);
- if (pHTTXContext)
- LM_URB_FREE(pObj, pHTTXContext, sizeof(HTTX_BUFFER));
- }
-
- if (pAd->FragFrame.pFragPacket)
- RELEASE_NDIS_PACKET(pAd, pAd->FragFrame.pFragPacket, NDIS_STATUS_SUCCESS);
-
- for(i=0; i<6; i++)
- {
- NdisFreeSpinLock(&pAd->BulkOutLock[i]);
- }
-
- NdisFreeSpinLock(&pAd->BulkInLock);
- NdisFreeSpinLock(&pAd->MLMEBulkOutLock);
-
- NdisFreeSpinLock(&pAd->CmdQLock);
-#ifdef RALINK_ATE
- NdisFreeSpinLock(&pAd->GenericLock);
-#endif // RALINK_ATE //
- // Clear all pending bulk-out request flags.
- RTUSB_CLEAR_BULK_FLAG(pAd, 0xffffffff);
-
-// NdisFreeSpinLock(&pAd->MacTabLock);
-
-// for(i=0; i<MAX_LEN_OF_BA_REC_TABLE; i++)
-// {
-// NdisFreeSpinLock(&pAd->BATable.BARecEntry[i].RxReRingLock);
-// }
-
- DBGPRINT(RT_DEBUG_ERROR, ("<--- ReleaseAdapter\n"));
-}
-
-
-/*
-========================================================================
-Routine Description:
- Allocate memory for adapter control block.
-
-Arguments:
- pAd Pointer to our adapter
-
-Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
- NDIS_STATUS_RESOURCES
-
-Note:
-========================================================================
-*/
-NDIS_STATUS AdapterBlockAllocateMemory(
- IN PVOID handle,
- OUT PVOID *ppAd)
-{
- PUSB_DEV usb_dev;
- POS_COOKIE pObj = (POS_COOKIE) handle;
-
-
- usb_dev = pObj->pUsb_Dev;
-
- pObj->MLMEThr_pid = NULL;
- pObj->RTUSBCmdThr_pid = NULL;
-
- *ppAd = (PVOID)vmalloc(sizeof(RTMP_ADAPTER));
-
- if (*ppAd)
- {
- NdisZeroMemory(*ppAd, sizeof(RTMP_ADAPTER));
- ((PRTMP_ADAPTER)*ppAd)->OS_Cookie = handle;
- return (NDIS_STATUS_SUCCESS);
- }
- else
- {
- return (NDIS_STATUS_FAILURE);
- }
-}
-
-
-/*
-========================================================================
-Routine Description:
- Create kernel threads & tasklets.
-
-Arguments:
- *net_dev Pointer to wireless net device interface
-
-Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
-
-Note:
-========================================================================
-*/
-NDIS_STATUS CreateThreads(
- IN struct net_device *net_dev)
-{
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
- pid_t pid_number;
-
- //init_MUTEX(&(pAd->usbdev_semaphore));
-
- init_MUTEX_LOCKED(&(pAd->mlme_semaphore));
- init_completion (&pAd->mlmeComplete);
-
- init_MUTEX_LOCKED(&(pAd->RTUSBCmd_semaphore));
- init_completion (&pAd->CmdQComplete);
-
- init_MUTEX_LOCKED(&(pAd->RTUSBTimer_semaphore));
- init_completion (&pAd->TimerQComplete);
-
- // Creat MLME Thread
- pObj->MLMEThr_pid = NULL;
- pid_number = kernel_thread(MlmeThread, pAd, CLONE_VM);
- if (pid_number < 0)
- {
- printk (KERN_WARNING "%s: unable to start Mlme thread\n",pAd->net_dev->name);
- return NDIS_STATUS_FAILURE;
- }
- pObj->MLMEThr_pid = find_get_pid(pid_number);
- // Wait for the thread to start
- wait_for_completion(&(pAd->mlmeComplete));
-
- // Creat Command Thread
- pObj->RTUSBCmdThr_pid = NULL;
- pid_number = kernel_thread(RTUSBCmdThread, pAd, CLONE_VM);
- if (pid_number < 0)
- {
- printk (KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAd->net_dev->name);
- return NDIS_STATUS_FAILURE;
- }
- pObj->RTUSBCmdThr_pid = find_get_pid(pid_number);
- wait_for_completion(&(pAd->CmdQComplete));
-
- pObj->TimerQThr_pid = NULL;
- pid_number = kernel_thread(TimerQThread, pAd, CLONE_VM);
- if (pid_number < 0)
- {
- printk (KERN_WARNING "%s: unable to start TimerQThread\n",pAd->net_dev->name);
- return NDIS_STATUS_FAILURE;
- }
- pObj->TimerQThr_pid = find_get_pid(pid_number);
- // Wait for the thread to start
- wait_for_completion(&(pAd->TimerQComplete));
-
- // Create receive tasklet
- tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (ULONG)pAd);
- tasklet_init(&pObj->mgmt_dma_done_task, rt2870_mgmt_dma_done_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->ac0_dma_done_task, rt2870_ac0_dma_done_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->ac1_dma_done_task, rt2870_ac1_dma_done_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->ac2_dma_done_task, rt2870_ac2_dma_done_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->ac3_dma_done_task, rt2870_ac3_dma_done_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->hcca_dma_done_task, rt2870_hcca_dma_done_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->tbtt_task, tbtt_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->null_frame_complete_task, rt2870_null_frame_complete_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->rts_frame_complete_task, rt2870_rts_frame_complete_tasklet, (unsigned long)pAd);
- tasklet_init(&pObj->pspoll_frame_complete_task, rt2870_pspoll_frame_complete_tasklet, (unsigned long)pAd);
-
- return NDIS_STATUS_SUCCESS;
-}
-
-
-#ifdef CONFIG_STA_SUPPORT
-/*
-========================================================================
-Routine Description:
- As STA's BSSID is a WC too, it uses shared key table.
- This function write correct unicast TX key to ASIC WCID.
- And we still make a copy in our MacTab.Content[BSSID_WCID].PairwiseKey.
- Caller guarantee TKIP/AES always has keyidx = 0. (pairwise key)
- Caller guarantee WEP calls this function when set Txkey, default key index=0~3.
-
-Arguments:
- pAd Pointer to our adapter
- pKey Pointer to the where the key stored
-
-Return Value:
- NDIS_SUCCESS Add key successfully
-
-Note:
-========================================================================
-*/
-VOID RTMPAddBSSIDCipher(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Aid,
- IN PNDIS_802_11_KEY pKey,
- IN UCHAR CipherAlg)
-{
- PUCHAR pTxMic, pRxMic;
- BOOLEAN bKeyRSC, bAuthenticator; // indicate the receive SC set by KeyRSC value
-// UCHAR CipherAlg;
- UCHAR i;
- ULONG WCIDAttri;
- USHORT offset;
- UCHAR KeyIdx, IVEIV[8];
- UINT32 Value;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddBSSIDCipher==> Aid = %d\n",Aid));
-
- // Bit 29 of Add-key KeyRSC
- bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
-
- // Bit 28 of Add-key Authenticator
- bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
- KeyIdx = (UCHAR)pKey->KeyIndex&0xff;
-
- if (KeyIdx > 4)
- return;
-
-
- if (pAd->MacTab.Content[Aid].PairwiseKey.CipherAlg == CIPHER_TKIP)
- { if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- // for WPA-None Tx, Rx MIC is the same
- pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
- pRxMic = pTxMic;
- }
- else if (bAuthenticator == TRUE)
- {
- pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
- pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
- }
- else
- {
- pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
- pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
- }
-
- offset = PAIRWISE_KEY_TABLE_BASE + (Aid * HW_KEY_ENTRY_SIZE) + 0x10;
- for (i=0; i<8; )
- {
- Value = *(pTxMic+i);
- Value += (*(pTxMic+i+1)<<8);
- Value += (*(pTxMic+i+2)<<16);
- Value += (*(pTxMic+i+3)<<24);
- RTUSBWriteMACRegister(pAd, offset+i, Value);
- i+=4;
- }
-
- offset = PAIRWISE_KEY_TABLE_BASE + (Aid * HW_KEY_ENTRY_SIZE) + 0x18;
- for (i=0; i<8; )
- {
- Value = *(pRxMic+i);
- Value += (*(pRxMic+i+1)<<8);
- Value += (*(pRxMic+i+2)<<16);
- Value += (*(pRxMic+i+3)<<24);
- RTUSBWriteMACRegister(pAd, offset+i, Value);
- i+=4;
- }
-
- // Only Key lenth equal to TKIP key have these
- NdisMoveMemory(pAd->MacTab.Content[Aid].PairwiseKey.RxMic, pRxMic, 8);
- NdisMoveMemory(pAd->MacTab.Content[Aid].PairwiseKey.TxMic, pTxMic, 8);
-
- DBGPRINT(RT_DEBUG_TRACE,
- (" TxMIC = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x \n",
- pTxMic[0],pTxMic[1],pTxMic[2],pTxMic[3],
- pTxMic[4],pTxMic[5],pTxMic[6],pTxMic[7]));
- DBGPRINT(RT_DEBUG_TRACE,
- (" RxMIC = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x \n",
- pRxMic[0],pRxMic[1],pRxMic[2],pRxMic[3],
- pRxMic[4],pRxMic[5],pRxMic[6],pRxMic[7]));
- }
-
- // 2. Record Security Key.
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen= (UCHAR)pKey->KeyLength;
- NdisMoveMemory(pAd->MacTab.Content[Aid].PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // 3. Check RxTsc. And used to init to ASIC IV.
- if (bKeyRSC == TRUE)
- NdisMoveMemory(pAd->MacTab.Content[Aid].PairwiseKey.RxTsc, &pKey->KeyRSC, 6);
- else
- NdisZeroMemory(pAd->MacTab.Content[Aid].PairwiseKey.RxTsc, 6);
-
- // 4. Init TxTsc to one based on WiFi WPA specs
- pAd->MacTab.Content[Aid].PairwiseKey.TxTsc[0] = 1;
- pAd->MacTab.Content[Aid].PairwiseKey.TxTsc[1] = 0;
- pAd->MacTab.Content[Aid].PairwiseKey.TxTsc[2] = 0;
- pAd->MacTab.Content[Aid].PairwiseKey.TxTsc[3] = 0;
- pAd->MacTab.Content[Aid].PairwiseKey.TxTsc[4] = 0;
- pAd->MacTab.Content[Aid].PairwiseKey.TxTsc[5] = 0;
-
- CipherAlg = pAd->MacTab.Content[Aid].PairwiseKey.CipherAlg;
-
- offset = PAIRWISE_KEY_TABLE_BASE + (Aid * HW_KEY_ENTRY_SIZE);
- RTUSBMultiWrite(pAd, (USHORT) offset, pKey->KeyMaterial,
- ((pKey->KeyLength == LEN_TKIP_KEY) ? 16 : (USHORT)pKey->KeyLength));
-
- offset = SHARED_KEY_TABLE_BASE + (KeyIdx * HW_KEY_ENTRY_SIZE);
- RTUSBMultiWrite(pAd, (USHORT) offset, pKey->KeyMaterial, (USHORT)pKey->KeyLength);
-
- offset = PAIRWISE_IVEIV_TABLE_BASE + (Aid * HW_IVEIV_ENTRY_SIZE);
- NdisZeroMemory(IVEIV, 8);
-
- // IV/EIV
- if ((CipherAlg == CIPHER_TKIP) ||
- (CipherAlg == CIPHER_TKIP_NO_MIC) ||
- (CipherAlg == CIPHER_AES))
- {
- IVEIV[3] = 0x20; // Eiv bit on. keyid always 0 for pairwise key
- }
- // default key idx needs to set.
- // in TKIP/AES KeyIdx = 0 , WEP KeyIdx is default tx key.
- else
- {
- IVEIV[3] |= (KeyIdx<< 6);
- }
- RTUSBMultiWrite(pAd, (USHORT) offset, IVEIV, 8);
-
- // WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:1=PAIRWISE KEY, BSSIdx is 0
- if ((CipherAlg == CIPHER_TKIP) ||
- (CipherAlg == CIPHER_TKIP_NO_MIC) ||
- (CipherAlg == CIPHER_AES))
- {
- WCIDAttri = (CipherAlg<<1)|SHAREDKEYTABLE;
- }
- else
- WCIDAttri = (CipherAlg<<1)|SHAREDKEYTABLE;
-
- offset = MAC_WCID_ATTRIBUTE_BASE + (Aid* HW_WCID_ATTRI_SIZE);
- RTUSBWriteMACRegister(pAd, offset, WCIDAttri);
- RTUSBReadMACRegister(pAd, offset, &Value);
-
- DBGPRINT(RT_DEBUG_TRACE, ("BSSID_WCID : offset = %x, WCIDAttri = %lx\n",
- offset, WCIDAttri));
-
- // pAddr
- // Add Bssid mac address at linkup. not here. check!
- /*offset = MAC_WCID_BASE + (BSSID_WCID * HW_WCID_ENTRY_SIZE);
- *for (i=0; i<MAC_ADDR_LEN; i++)
- {
- RTMP_IO_WRITE8(pAd, offset+i, pKey->BSSID[i]);
- }
- */
-
- DBGPRINT(RT_DEBUG_ERROR, ("AddBSSIDasWCIDEntry: Alg=%s, KeyLength = %d\n",
- CipherName[CipherAlg], pKey->KeyLength));
- DBGPRINT(RT_DEBUG_TRACE, ("Key [idx=%x] [KeyLen = %d]\n",
- pKey->KeyIndex, pKey->KeyLength));
- for(i=0; i<pKey->KeyLength; i++)
- DBGPRINT_RAW(RT_DEBUG_TRACE,(" %x:", pKey->KeyMaterial[i]));
- DBGPRINT(RT_DEBUG_TRACE,(" \n"));
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
-========================================================================
-Routine Description:
- Get a received packet.
-
-Arguments:
- pAd device control block
- pSaveRxD receive descriptor information
- *pbReschedule need reschedule flag
- *pRxPending pending received packet flag
-
-Return Value:
- the recieved packet
-
-Note:
-========================================================================
-*/
-#define RT2870_RXDMALEN_FIELD_SIZE 4
-PNDIS_PACKET GetPacketFromRxRing(
- IN PRTMP_ADAPTER pAd,
- OUT PRT28XX_RXD_STRUC pSaveRxD,
- OUT BOOLEAN *pbReschedule,
- IN OUT UINT32 *pRxPending)
-{
- PRX_CONTEXT pRxContext;
- PNDIS_PACKET pSkb;
- PUCHAR pData;
- ULONG ThisFrameLen;
- ULONG RxBufferLength;
- PRXWI_STRUC pRxWI;
-
- pRxContext = &pAd->RxContext[pAd->NextRxBulkInReadIndex];
- if ((pRxContext->Readable == FALSE) || (pRxContext->InUse == TRUE))
- return NULL;
-
- RxBufferLength = pRxContext->BulkInOffset - pAd->ReadPosition;
- if (RxBufferLength < (RT2870_RXDMALEN_FIELD_SIZE + sizeof(RXWI_STRUC) + sizeof(RXINFO_STRUC)))
- {
- goto label_null;
- }
-
- pData = &pRxContext->TransferBuffer[pAd->ReadPosition]; /* 4KB */
- // The RXDMA field is 4 bytes, now just use the first 2 bytes. The Length including the (RXWI + MSDU + Padding)
- ThisFrameLen = *pData + (*(pData+1)<<8);
- if (ThisFrameLen == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("BIRIdx(%d): RXDMALen is zero.[%ld], BulkInBufLen = %ld)\n",
- pAd->NextRxBulkInReadIndex, ThisFrameLen, pRxContext->BulkInOffset));
- goto label_null;
- }
- if ((ThisFrameLen&0x3) != 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("BIRIdx(%d): RXDMALen not multiple of 4.[%ld], BulkInBufLen = %ld)\n",
- pAd->NextRxBulkInReadIndex, ThisFrameLen, pRxContext->BulkInOffset));
- goto label_null;
- }
-
- if ((ThisFrameLen + 8)> RxBufferLength) // 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(RXINFO_STRUC))
- {
- DBGPRINT(RT_DEBUG_TRACE,("BIRIdx(%d):FrameLen(0x%lx) outranges. BulkInLen=0x%lx, remaining RxBufLen=0x%lx, ReadPos=0x%lx\n",
- pAd->NextRxBulkInReadIndex, ThisFrameLen, pRxContext->BulkInOffset, RxBufferLength, pAd->ReadPosition));
-
- // error frame. finish this loop
- goto label_null;
- }
-
- // skip USB frame length field
- pData += RT2870_RXDMALEN_FIELD_SIZE;
- pRxWI = (PRXWI_STRUC)pData;
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(pData, TYPE_RXWI);
-#endif // RT_BIG_ENDIAN //
- if (pRxWI->MPDUtotalByteCount > ThisFrameLen)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s():pRxWIMPDUtotalByteCount(%d) large than RxDMALen(%ld)\n",
- __FUNCTION__, pRxWI->MPDUtotalByteCount, ThisFrameLen));
- goto label_null;
- }
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange(pData, TYPE_RXWI);
-#endif // RT_BIG_ENDIAN //
-
- // allocate a rx packet
- pSkb = dev_alloc_skb(ThisFrameLen);
- if (pSkb == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,("%s():Cannot Allocate sk buffer for this Bulk-In buffer!\n", __FUNCTION__));
- goto label_null;
- }
-
- // copy the rx packet
- memcpy(skb_put(pSkb, ThisFrameLen), pData, ThisFrameLen);
- RTPKT_TO_OSPKT(pSkb)->dev = get_netdev_from_bssid(pAd, BSS0);
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pSkb), PKTSRC_NDIS);
-
- // copy RxD
- *pSaveRxD = *(PRXINFO_STRUC)(pData + ThisFrameLen);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pSaveRxD, TYPE_RXINFO);
-#endif // RT_BIG_ENDIAN //
-
- // update next packet read position.
- pAd->ReadPosition += (ThisFrameLen + RT2870_RXDMALEN_FIELD_SIZE + RXINFO_SIZE); // 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(RXINFO_STRUC))
-
- return pSkb;
-
-label_null:
-
- return NULL;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Handle received packets.
-
-Arguments:
- data - URB information pointer
-
-Return Value:
- None
-
-Note:
-========================================================================
-*/
-static void rx_done_tasklet(unsigned long data)
-{
- purbb_t pUrb;
- PRX_CONTEXT pRxContext;
- PRTMP_ADAPTER pAd;
- NTSTATUS Status;
- unsigned int IrqFlags;
-
- pUrb = (purbb_t)data;
- pRxContext = (PRX_CONTEXT)pUrb->context;
- pAd = pRxContext->pAd;
- Status = pUrb->status;
-
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->BulkInOffset += pUrb->actual_length;
- //NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-
- if (Status == USB_ST_NOERROR)
- {
- pAd->BulkInComplete++;
- pAd->NextRxBulkInPosition = 0;
- if (pRxContext->BulkInOffset) // As jan's comment, it may bulk-in success but size is zero.
- {
- pRxContext->Readable = TRUE;
- INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE);
- }
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- }
- else // STATUS_OTHER
- {
- pAd->BulkInCompleteFail++;
- // Still read this packet although it may comtain wrong bytes.
- pRxContext->Readable = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- // Parsing all packets. because after reset, the index will reset to all zero.
- if ((!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_BULKIN_RESET |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk In Failed. Status=%d, BIIdx=0x%x, BIRIdx=0x%x, actual_length= 0x%x\n",
- Status, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex, pRxContext->pUrb->actual_length));
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, NULL, 0);
- }
- }
-
- ASSERT((pRxContext->InUse == pRxContext->IRPPending));
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- // If the driver is in ATE mode and Rx frame is set into here.
- if (pAd->ContinBulkIn == TRUE)
- {
- RTUSBBulkReceive(pAd);
- }
- }
- else
-#endif // RALINK_ATE //
- RTUSBBulkReceive(pAd);
-
- return;
-
-}
-
-
-static void rt2870_mgmt_dma_done_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pMLMEContext;
- int index;
- PNDIS_PACKET pPacket;
- purbb_t pUrb;
- NTSTATUS Status;
- unsigned long IrqFlags;
-
-
- pUrb = (purbb_t)data;
- pMLMEContext = (PTX_CONTEXT)pUrb->context;
- pAd = pMLMEContext->pAd;
- Status = pUrb->status;
- index = pMLMEContext->SelfIdx;
-
- ASSERT((pAd->MgmtRing.TxDmaIdx == index));
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
-
- if (Status != USB_ST_NOERROR)
- {
- //Bulk-Out fail status handle
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out MLME Failed, Status=%d!\n", Status));
- // TODO: How to handle about the MLMEBulkOut failed issue. Need to resend the mgmt pkt?
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
- }
- }
-
- pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
- RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
- // Reset MLME context flags
- pMLMEContext->IRPPending = FALSE;
- pMLMEContext->InUse = FALSE;
- pMLMEContext->bWaitingBulkOut = FALSE;
- pMLMEContext->BulkOutSize = 0;
-
- pPacket = pAd->MgmtRing.Cell[index].pNdisPacket;
- pAd->MgmtRing.Cell[index].pNdisPacket = NULL;
-
- // Increase MgmtRing Index
- INC_RING_INDEX(pAd->MgmtRing.TxDmaIdx, MGMT_RING_SIZE);
- pAd->MgmtRing.TxSwFreeIdx++;
- RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
- // No-matter success or fail, we free the mgmt packet.
- if (pPacket)
- RTMPFreeNdisPacket(pAd, pPacket);
-
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- // do nothing and return directly.
- }
- else
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET) &&
- ((pAd->bulkResetPipeid & BULKOUT_MGMT_RESET_FLAG) == BULKOUT_MGMT_RESET_FLAG))
- { // For Mgmt Bulk-Out failed, ignore it now.
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- {
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- if (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE /* pMLMEContext->bWaitingBulkOut == TRUE */)
- {
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
- }
- RTUSBKickBulkOut(pAd);
- }
- }
-
-}
-
-
-static void rt2870_hcca_dma_done_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId = 4;
- purbb_t pUrb;
-
-
- pUrb = (purbb_t)data;
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
-
- rt2870_dataout_complete_tasklet((unsigned long)pUrb);
-
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- // do nothing and return directly.
- }
- else
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))
- {
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- { pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
- /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
- (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
- (pHTTXContext->bCurWriting == FALSE))
- {
- RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId, MAX_TX_PROCESS);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL<<4);
- RTUSBKickBulkOut(pAd);
- }
- }
-
-
- return;
-}
-
-
-static void rt2870_ac3_dma_done_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId = 3;
- purbb_t pUrb;
-
-
- pUrb = (purbb_t)data;
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
-
- rt2870_dataout_complete_tasklet((unsigned long)pUrb);
-
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- // do nothing and return directly.
- }
- else
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))
- {
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- { pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
- /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
- (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
- (pHTTXContext->bCurWriting == FALSE))
- {
- RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId, MAX_TX_PROCESS);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL<<3);
- RTUSBKickBulkOut(pAd);
- }
- }
-
-
- return;
-}
-
-
-static void rt2870_ac2_dma_done_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId = 2;
- purbb_t pUrb;
-
-
- pUrb = (purbb_t)data;
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
-
- rt2870_dataout_complete_tasklet((unsigned long)pUrb);
-
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- // do nothing and return directly.
- }
- else
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))
- {
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- { pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
- /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
- (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
- (pHTTXContext->bCurWriting == FALSE))
- {
- RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId, MAX_TX_PROCESS);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL<<2);
- RTUSBKickBulkOut(pAd);
- }
- }
-
- return;
-}
-
-
-static void rt2870_ac1_dma_done_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId = 1;
- purbb_t pUrb;
-
-
- pUrb = (purbb_t)data;
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
-
- rt2870_dataout_complete_tasklet((unsigned long)pUrb);
-
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- // do nothing and return directly.
- }
- else
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))
- {
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- { pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
- /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
- (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
- (pHTTXContext->bCurWriting == FALSE))
- {
- RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId, MAX_TX_PROCESS);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL<<1);
- RTUSBKickBulkOut(pAd);
- }
- }
-
-
- return;
-}
-
-
-static void rt2870_ac0_dma_done_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId = 0;
- purbb_t pUrb;
-
-
- pUrb = (purbb_t)data;
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
-
- rt2870_dataout_complete_tasklet((unsigned long)pUrb);
-
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- // do nothing and return directly.
- }
- else
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))
- {
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- { pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
- /* ((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
- (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
- (pHTTXContext->bCurWriting == FALSE))
- {
- RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId, MAX_TX_PROCESS);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL);
- RTUSBKickBulkOut(pAd);
- }
- }
-
-
- return;
-
-}
-
-
-static void rt2870_null_frame_complete_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pNullContext;
- purbb_t pUrb;
- NTSTATUS Status;
- unsigned long irqFlag;
-
-
- pUrb = (purbb_t)data;
- pNullContext = (PTX_CONTEXT)pUrb->context;
- pAd = pNullContext->pAd;
- Status = pUrb->status;
-
- // Reset Null frame context flags
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], irqFlag);
- pNullContext->IRPPending = FALSE;
- pNullContext->InUse = FALSE;
- pAd->BulkOutPending[0] = FALSE;
- pAd->watchDogTxPendingCnt[0] = 0;
-
- if (Status == USB_ST_NOERROR)
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
- else // STATUS_OTHER
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out Null Frame Failed, ReasonCode=%d!\n", Status));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
- }
- }
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-
-}
-
-
-static void rt2870_rts_frame_complete_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pRTSContext;
- purbb_t pUrb;
- NTSTATUS Status;
- unsigned long irqFlag;
-
-
- pUrb = (purbb_t)data;
- pRTSContext = (PTX_CONTEXT)pUrb->context;
- pAd = pRTSContext->pAd;
- Status = pUrb->status;
-
- // Reset RTS frame context flags
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], irqFlag);
- pRTSContext->IRPPending = FALSE;
- pRTSContext->InUse = FALSE;
-
- if (Status == USB_ST_NOERROR)
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
- else // STATUS_OTHER
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out RTS Frame Failed\n"));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
- }
- }
-
- RTMP_SEM_LOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId]);
- pAd->BulkOutPending[pRTSContext->BulkOutPipeId] = FALSE;
- RTMP_SEM_UNLOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId]);
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-
-}
-
-
-static void rt2870_pspoll_frame_complete_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pPsPollContext;
- purbb_t pUrb;
- NTSTATUS Status;
-
-
- pUrb = (purbb_t)data;
- pPsPollContext = (PTX_CONTEXT)pUrb->context;
- pAd = pPsPollContext->pAd;
- Status = pUrb->status;
-
- // Reset PsPoll context flags
- pPsPollContext->IRPPending = FALSE;
- pPsPollContext->InUse = FALSE;
- pAd->watchDogTxPendingCnt[0] = 0;
-
- if (Status == USB_ST_NOERROR)
- {
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
- else // STATUS_OTHER
- {
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Bulk Out PSPoll Failed\n"));
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- }
- }
-
- RTMP_SEM_LOCK(&pAd->BulkOutLock[0]);
- pAd->BulkOutPending[0] = FALSE;
- RTMP_SEM_UNLOCK(&pAd->BulkOutLock[0]);
-
- // Always call Bulk routine, even reset bulk.
- // The protectioon of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-
-}
-
-
-static void rt2870_dataout_complete_tasklet(unsigned long data)
-{
- PRTMP_ADAPTER pAd;
- purbb_t pUrb;
- POS_COOKIE pObj;
- PHT_TX_CONTEXT pHTTXContext;
- UCHAR BulkOutPipeId;
- NTSTATUS Status;
- unsigned long IrqFlags;
-
-
- pUrb = (purbb_t)data;
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
- Status = pUrb->status;
-
- // Store BulkOut PipeId
- BulkOutPipeId = pHTTXContext->BulkOutPipeId;
- pAd->BulkOutDataOneSecCount++;
-
- //DBGPRINT(RT_DEBUG_LOUD, ("Done-B(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", BulkOutPipeId, in_interrupt(), pHTTXContext->CurWritePosition,
- // pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad));
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- pHTTXContext->IRPPending = FALSE;
- pAd->watchDogTxPendingCnt[BulkOutPipeId] = 0;
-
- if (Status == USB_ST_NOERROR)
- {
- pAd->BulkOutComplete++;
-
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- pAd->Counters8023.GoodTransmits++;
- //RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- FREE_HTTX_RING(pAd, BulkOutPipeId, pHTTXContext);
- //RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
-
- }
- else // STATUS_OTHER
- {
- PUCHAR pBuf;
-
- pAd->BulkOutCompleteOther++;
-
- pBuf = &pHTTXContext->TransferBuffer->field.WirelessPacket[pHTTXContext->NextBulkOutPosition];
-
- if (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST |
- fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- pAd->bulkResetPipeid = BulkOutPipeId;
- pAd->bulkResetReq[BulkOutPipeId] = pAd->BulkOutReq;
- }
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("BulkOutDataPacket failed: ReasonCode=%d!\n", Status));
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("\t>>BulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n", pAd->BulkOutReq, pAd->BulkOutComplete, pAd->BulkOutCompleteOther));
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("\t>>BulkOut Header:%x %x %x %x %x %x %x %x\n", pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7]));
- //DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOutCompleteCancel=0x%x, BulkOutCompleteOther=0x%x\n", pAd->BulkOutCompleteCancel, pAd->BulkOutCompleteOther));
-
- }
-
- //
- // bInUse = TRUE, means some process are filling TX data, after that must turn on bWaitingBulkOut
- // bWaitingBulkOut = TRUE, means the TX data are waiting for bulk out.
- //
- //RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- if ((pHTTXContext->ENextBulkOutPosition != pHTTXContext->CurWritePosition) &&
- (pHTTXContext->ENextBulkOutPosition != (pHTTXContext->CurWritePosition+8)) &&
- !RTUSB_TEST_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId)))
- {
- // Indicate There is data avaliable
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
- }
- //RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protection of rest bulk should be in BulkOut routine
- RTUSBKickBulkOut(pAd);
-}
-
-/* End of 2870_rtmp_init.c */
+#include "../../rt2870/common/2870_rtmp_init.c"
diff --git a/drivers/staging/rt3070/common/action.c b/drivers/staging/rt3070/common/action.c
index b8ae53633661..035fd803f613 100644
--- a/drivers/staging/rt3070/common/action.c
+++ b/drivers/staging/rt3070/common/action.c
@@ -1,1038 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- action.c
-
- Abstract:
- Handle association related requests either from WSTA or from local MLME
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 2006 created for rt2860
- */
-
-#include "../rt_config.h"
-#include "../action.h"
-
-
-static VOID ReservedAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
- Note:
- The state machine looks like the following
-
- ASSOC_IDLE
- MT2_MLME_DISASSOC_REQ mlme_disassoc_req_action
- MT2_PEER_DISASSOC_REQ peer_disassoc_action
- MT2_PEER_ASSOC_REQ drop
- MT2_PEER_REASSOC_REQ drop
- MT2_CLS3ERR cls3err_action
- ==========================================================================
- */
-VOID ActionStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, (STATE_MACHINE_FUNC *)Trans, MAX_ACT_STATE, MAX_ACT_MSG, (STATE_MACHINE_FUNC)Drop, ACT_IDLE, ACT_MACHINE_BASE);
-
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE, (STATE_MACHINE_FUNC)PeerSpectrumAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction);
-
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction);
-#ifdef QOS_DLS_SUPPORT
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)PeerDLSAction);
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE, (STATE_MACHINE_FUNC)PeerHTAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE, (STATE_MACHINE_FUNC)MlmeADDBAAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
-#endif // DOT11_N_SUPPORT //
-
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE, (STATE_MACHINE_FUNC)PeerPublicAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE, (STATE_MACHINE_FUNC)PeerRMAction);
-
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE, (STATE_MACHINE_FUNC)MlmeQOSAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE, (STATE_MACHINE_FUNC)MlmeDLSAction);
- StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID, (STATE_MACHINE_FUNC)MlmeInvalidAction);
-}
-
-#ifdef DOT11_N_SUPPORT
-VOID MlmeADDBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- MLME_ADDBA_REQ_STRUCT *pInfo;
- UCHAR Addr[6];
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG Idx;
- FRAME_ADDBA_REQ Frame;
- ULONG FrameLen;
- BA_ORI_ENTRY *pBAEntry = NULL;
-
- pInfo = (MLME_ADDBA_REQ_STRUCT *)Elem->Msg;
- NdisZeroMemory(&Frame, sizeof(FRAME_ADDBA_REQ));
-
- if(MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr))
- {
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeADDBAAction() allocate memory failed \n"));
- return;
- }
- // 1. find entry
- Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
- if (Idx == 0)
- {
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
- return;
- }
- else
- {
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pInfo->pAddr);
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
- Frame.Category = CATEGORY_BA;
- Frame.Action = ADDBA_REQ;
- Frame.BaParm.AMSDUSupported = 0;
- Frame.BaParm.BAPolicy = IMMED_BA;
- Frame.BaParm.TID = pInfo->TID;
- Frame.BaParm.BufSize = pInfo->BaBufSize;
- Frame.Token = pInfo->Token;
- Frame.TimeOutValue = pInfo->TimeOutValue;
- Frame.BaStartSeq.field.FragNum = 0;
- Frame.BaStartSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
-
- *(USHORT *)(&Frame.BaParm) = cpu2le16(*(USHORT *)(&Frame.BaParm));
- Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
- Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ADDBA_REQ), &Frame,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- //MiniportDataMMRequest(pAd, MapUserPriorityToAccessCategory[pInfo->TID], pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n", Frame.BaStartSeq.field.StartSeq, FrameLen, Frame.BaParm.BufSize));
- }
-}
-
-/*
- ==========================================================================
- Description:
- send DELBA and delete BaEntry if any
- Parametrs:
- Elem - MLME message MLME_DELBA_REQ_STRUCT
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDELBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DELBA_REQ_STRUCT *pInfo;
- PUCHAR pOutBuffer = NULL;
- PUCHAR pOutBuffer2 = NULL;
- NDIS_STATUS NStatus;
- ULONG Idx;
- FRAME_DELBA_REQ Frame;
- ULONG FrameLen;
- FRAME_BAR FrameBar;
-
- pInfo = (MLME_DELBA_REQ_STRUCT *)Elem->Msg;
- // must send back DELBA
- NdisZeroMemory(&Frame, sizeof(FRAME_DELBA_REQ));
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
-
- if(MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen))
- {
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
- return;
- }
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_ERROR, ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
- return;
- }
-
- // SEND BAR (Send BAR to refresh peer reordering buffer.)
- Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
-
- FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL funciton.
- FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.TID = pInfo->TID; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.ACKPolicy = IMMED_BA; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.Compressed = 1; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.MTID = 0; // make sure sequence not clear in DEL funciton.
-
- MakeOutgoingFrame(pOutBuffer2, &FrameLen,
- sizeof(FRAME_BAR), &FrameBar,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer2);
- DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
-
- // SEND DELBA FRAME
- FrameLen = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[pInfo->Wcid].Addr);
- }
-#endif // CONFIG_STA_SUPPORT //
- Frame.Category = CATEGORY_BA;
- Frame.Action = DELBA;
- Frame.DelbaParm.Initiator = pInfo->Initiator;
- Frame.DelbaParm.TID = pInfo->TID;
- Frame.ReasonCode = 39; // Time Out
- *(USHORT *)(&Frame.DelbaParm) = cpu2le16(*(USHORT *)(&Frame.DelbaParm));
- Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_DELBA_REQ), &Frame,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n", pInfo->Initiator));
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID MlmeQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-VOID MlmeDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-VOID MlmeInvalidAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- //PUCHAR pOutBuffer = NULL;
- //Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11
-}
-
-VOID PeerQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-#ifdef QOS_DLS_SUPPORT
-VOID PeerDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- switch(Action)
- {
- case ACTION_DLS_REQUEST:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsReqAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
-
- case ACTION_DLS_RESPONSE:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsRspAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
-
- case ACTION_DLS_TEARDOWN:
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- PeerDlsTearDownAction(pAd, Elem);
-#endif // CONFIG_STA_SUPPORT //
- break;
- }
-}
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
-VOID PeerBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- switch(Action)
- {
- case ADDBA_REQ:
- PeerAddBAReqAction(pAd,Elem);
- break;
- case ADDBA_RESP:
- PeerAddBARspAction(pAd,Elem);
- break;
- case DELBA:
- PeerDelBAAction(pAd,Elem);
- break;
- }
-}
-
-
-#ifdef DOT11N_DRAFT3
-
-#ifdef CONFIG_STA_SUPPORT
-VOID StaPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Bss2040Coexist)
-{
- BSS_2040_COEXIST_IE BssCoexist;
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- BssCoexist.word = Bss2040Coexist;
- // AP asks Station to return a 20/40 BSS Coexistence mgmt frame. So we first starts a scan, then send back 20/40 BSS Coexistence mgmt frame
- if ((BssCoexist.field.InfoReq == 1) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)))
- {
- // Clear record first. After scan , will update those bit and send back to transmiter.
- pAd->CommonCfg.BSSCoexist2040.field.InfoReq = 1;
- pAd->CommonCfg.BSSCoexist2040.field.Intolerant40 = 0;
- pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 0;
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_2040_BSS_COEXIST);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- }
-}
-
-
-/*
-Description : Build Intolerant Channel Rerpot from Trigger event table.
-return : how many bytes copied.
-*/
-ULONG BuildIntolerantChannelRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest)
-{
- ULONG FrameLen = 0;
- ULONG ReadOffset = 0;
- UCHAR i;
- UCHAR LastRegClass = 0xff;
- PUCHAR pLen;
-
- for ( i = 0;i < MAX_TRIGGER_EVENT;i++)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid == TRUE)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass == LastRegClass)
- {
- *(pDest + ReadOffset) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
- *pLen++;
- ReadOffset++;
- FrameLen++;
- }
- else
- {
- *(pDest + ReadOffset) = IE_2040_BSS_INTOLERANT_REPORT; // IE
- *(pDest + ReadOffset + 1) = 2; // Len = RegClass byte + channel byte.
- pLen = pDest + ReadOffset + 1;
- LastRegClass = pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass;
- *(pDest + ReadOffset + 2) = LastRegClass; // Len = RegClass byte + channel byte.
- *(pDest + ReadOffset + 3) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
- FrameLen += 4;
- ReadOffset += 4;
- }
-
- }
- }
- return FrameLen;
-}
-
-
-/*
-Description : Send 20/40 BSS Coexistence Action frame If one trigger event is triggered.
-*/
-VOID Send2040CoexistAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- FRAME_ACTION_HDR Frame;
- ULONG FrameLen;
- ULONG IntolerantChaRepLen;
-
- IntolerantChaRepLen = 0;
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction() allocate memory failed \n"));
- return;
- }
- ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[Wcid].Addr, pAd->CommonCfg.Bssid);
- Frame.Category = CATEGORY_PUBLIC;
- Frame.Action = ACTION_BSS_2040_COEXIST;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ACTION_HDR), &Frame,
- END_OF_ARGS);
-
- *(pOutBuffer + FrameLen) = pAd->CommonCfg.BSSCoexist2040.word;
- FrameLen++;
-
- if (bAddIntolerantCha == TRUE)
- IntolerantChaRepLen = BuildIntolerantChannelRep(pAd, pOutBuffer + FrameLen);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen + IntolerantChaRepLen);
- DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction( BSSCoexist2040 = 0x%x ) \n", pAd->CommonCfg.BSSCoexist2040.word));
-
-}
-
-
-/*
- ==========================================================================
- Description:
- After scan, Update 20/40 BSS Coexistence IE and send out.
- According to 802.11n D3.03 11.14.10
-
- Parameters:
- ==========================================================================
- */
-VOID Update2040CoexistFrameAndNotify(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha)
-{
- BSS_2040_COEXIST_IE OldValue;
-
- OldValue.word = pAd->CommonCfg.BSSCoexist2040.word;
- if ((pAd->CommonCfg.TriggerEventTab.EventANo > 0) || (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0))
- pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 1;
-
- // Need to check !!!!
- // How STA will set Intolerant40 if implementation dependent. Now we don't set this bit first.!!!!!
- // So Only check BSS20WidthReq change.
- if (OldValue.field.BSS20WidthReq != pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq)
- {
- Send2040CoexistAction(pAd, Wcid, bAddIntolerantCha);
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-BOOLEAN ChannelSwitchSanityCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary)
-{
- UCHAR i;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- if ((NewChannel > 7) && (Secondary == 1))
- return FALSE;
-
- if ((NewChannel < 5) && (Secondary == 3))
- return FALSE;
-
- // 0. Check if new channel is in the channellist.
- for (i = 0;i < pAd->ChannelListNum;i++)
- {
- if (pAd->ChannelList[i].Channel == NewChannel)
- {
- break;
- }
- }
-
- if (i == pAd->ChannelListNum)
- return FALSE;
-
- return TRUE;
-}
-
-
-VOID ChannelSwitchAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary)
-{
- UCHAR BBPValue = 0;
- ULONG MACValue;
-
- DBGPRINT(RT_DEBUG_TRACE,("SPECTRUM - ChannelSwitchAction(NewChannel = %d , Secondary = %d) \n", NewChannel, Secondary));
-
- if (ChannelSwitchSanityCheck(pAd, Wcid, NewChannel, Secondary) == FALSE)
- return;
-
- // 1. Switches to BW = 20.
- if (Secondary == 0)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- pAd->CommonCfg.Channel = NewChannel;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel,FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("!!!20MHz !!! \n" ));
- }
- // 1. Switches to BW = 40 And Station supports BW = 40.
- else if (((Secondary == 1) || (Secondary == 3)) && (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == 1))
- {
- pAd->CommonCfg.Channel = NewChannel;
-
- if (Secondary == 1)
- {
- // Secondary above.
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
- MACValue &= 0xfe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
- BBPValue&= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else
- {
- // Secondary below.
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
- MACValue &= 0xfe;
- MACValue |= 0x1;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
- BBPValue&= (~0x20);
- BBPValue|= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 1;
- }
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-VOID PeerPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-#ifdef DOT11N_DRAFT3
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-#endif // DOT11N_DRAFT3 //
-
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
-#ifdef DOT11N_DRAFT3
- switch(Action)
- {
- case ACTION_BSS_2040_COEXIST: // Format defined in IEEE 7.4.7a.1 in 11n Draf3.03
- {
- //UCHAR BssCoexist;
- BSS_2040_COEXIST_ELEMENT *pCoexistInfo;
- BSS_2040_COEXIST_IE *pBssCoexistIe;
- BSS_2040_INTOLERANT_CH_REPORT *pIntolerantReport = NULL;
-
- if (Elem->MsgLen <= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT)) )
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ACTION - 20/40 BSS Coexistence Management Frame length too short! len = %ld!\n", Elem->MsgLen));
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("ACTION - 20/40 BSS Coexistence Management action----> \n"));
- hex_dump("CoexistenceMgmtFrame", Elem->Msg, Elem->MsgLen);
-
-
- pCoexistInfo = (BSS_2040_COEXIST_ELEMENT *) &Elem->Msg[LENGTH_802_11+2];
- //hex_dump("CoexistInfo", (PUCHAR)pCoexistInfo, sizeof(BSS_2040_COEXIST_ELEMENT));
- if (Elem->MsgLen >= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT) + sizeof(BSS_2040_INTOLERANT_CH_REPORT)))
- {
- pIntolerantReport = (BSS_2040_INTOLERANT_CH_REPORT *)((PUCHAR)pCoexistInfo + sizeof(BSS_2040_COEXIST_ELEMENT));
- }
- //hex_dump("IntolerantReport ", (PUCHAR)pIntolerantReport, sizeof(BSS_2040_INTOLERANT_CH_REPORT));
-
- pBssCoexistIe = (BSS_2040_COEXIST_IE *)(&pCoexistInfo->BssCoexistIe);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (INFRA_ON(pAd))
- {
- StaPublicAction(pAd, pCoexistInfo);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- }
- break;
- }
-
-#endif // DOT11N_DRAFT3 //
-
-}
-
-
-static VOID ReservedAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Category;
-
- if (Elem->MsgLen <= LENGTH_802_11)
- {
- return;
- }
-
- Category = Elem->Msg[LENGTH_802_11];
- DBGPRINT(RT_DEBUG_TRACE,("Rcv reserved category(%d) Action Frame\n", Category));
- hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
-}
-
-VOID PeerRMAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- return;
-}
-
-#ifdef DOT11_N_SUPPORT
-static VOID respond_ht_information_exchange_action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- FRAME_HT_INFO HTINFOframe, *pFrame;
- UCHAR *pAddr;
-
-
- // 2. Always send back ADDBA Response
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
-
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
- return;
- }
-
- // get RA
- pFrame = (FRAME_HT_INFO *) &Elem->Msg[0];
- pAddr = pFrame->Hdr.Addr2;
-
- NdisZeroMemory(&HTINFOframe, sizeof(FRAME_HT_INFO));
- // 2-1. Prepare ADDBA Response frame.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
- ActHeaderInit(pAd, &HTINFOframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- HTINFOframe.Category = CATEGORY_HT;
- HTINFOframe.Action = HT_INFO_EXCHANGE;
- HTINFOframe.HT_Info.Request = 0;
- HTINFOframe.HT_Info.Forty_MHz_Intolerant = pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
- HTINFOframe.HT_Info.STA_Channel_Width = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_HT_INFO), &HTINFOframe,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-
-#ifdef DOT11N_DRAFT3
-VOID SendNotifyBWActionFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- FRAME_ACTION_HDR Frame;
- ULONG FrameLen;
- PUCHAR pAddr1;
-
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ACT - SendNotifyBWAction() allocate memory failed \n"));
- return;
- }
-
- if (Wcid == MCAST_WCID)
- pAddr1 = &BROADCAST_ADDR[0];
- else
- pAddr1 = pAd->MacTab.Content[Wcid].Addr;
- ActHeaderInit(pAd, &Frame.Hdr, pAddr1, pAd->ApCfg.MBSSID[apidx].Bssid, pAd->ApCfg.MBSSID[apidx].Bssid);
-
- Frame.Category = CATEGORY_HT;
- Frame.Action = NOTIFY_BW_ACTION;
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ACTION_HDR), &Frame,
- END_OF_ARGS);
-
- *(pOutBuffer + FrameLen) = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
- FrameLen++;
-
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- DBGPRINT(RT_DEBUG_TRACE,("ACT - SendNotifyBWAction(NotifyBW= %d)!\n", pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth));
-
-}
-#endif // DOT11N_DRAFT3 //
-
-
-VOID PeerHTAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- switch(Action)
- {
- case NOTIFY_BW_ACTION:
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Notify Channel bandwidth action----> \n"));
-#ifdef CONFIG_STA_SUPPORT
- if(pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- {
- // Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
- // sending BW_Notify Action frame, and cause us to linkup and linkdown.
- // In legacy mode, don't need to parse HT action frame.
- DBGPRINT(RT_DEBUG_TRACE,("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
- Elem->Msg[LENGTH_802_11+2] ));
- break;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (Elem->Msg[LENGTH_802_11+2] == 0) // 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
- pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
-
- break;
-
- case SMPS_ACTION:
- // 7.3.1.25
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - SMPS action----> \n"));
- if (((Elem->Msg[LENGTH_802_11+2]&0x1) == 0))
- {
- pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
- }
- else if (((Elem->Msg[LENGTH_802_11+2]&0x2) == 0))
- {
- pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
- }
- else
- {
- pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Aid(%d) MIMO PS = %d\n", Elem->Wcid, pAd->MacTab.Content[Elem->Wcid].MmpsMode));
- // rt2860c : add something for smps change.
- break;
-
- case SETPCO_ACTION:
- break;
-
- case MIMO_CHA_MEASURE_ACTION:
- break;
-
- case HT_INFO_EXCHANGE:
- {
- HT_INFORMATION_OCTET *pHT_info;
-
- pHT_info = (HT_INFORMATION_OCTET *) &Elem->Msg[LENGTH_802_11+2];
- // 7.4.8.10
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Information Exchange action----> \n"));
- if (pHT_info->Request)
- {
- respond_ht_information_exchange_action(pAd, Elem);
- }
- }
- break;
- }
-}
-
-
-/*
- ==========================================================================
- Description:
- Retry sending ADDBA Reqest.
-
- IRQL = DISPATCH_LEVEL
-
- Parametrs:
- p8023Header: if this is already 802.3 format, p8023Header is NULL
-
- Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
- FALSE , then continue indicaterx at this moment.
- ==========================================================================
- */
-VOID ORIBATimerTimeout(
- IN PRTMP_ADAPTER pAd)
-{
- MAC_TABLE_ENTRY *pEntry;
- INT i, total;
-// FRAME_BAR FrameBar;
-// ULONG FrameLen;
-// NDIS_STATUS NStatus;
-// PUCHAR pOutBuffer = NULL;
-// USHORT Sequence;
- UCHAR TID;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- total = pAd->MacTab.Size * NUM_OF_TID;
-
- for (i = 1; ((i <MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)) ; i++)
- {
- if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done)
- {
- pEntry = &pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].Wcid];
- TID = pAd->BATable.BAOriEntry[i].TID;
-
- ASSERT(pAd->BATable.BAOriEntry[i].Wcid < MAX_LEN_OF_MAC_TABLE);
- }
- total --;
- }
-}
-
-
-VOID SendRefreshBAR(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- FRAME_BAR FrameBar;
- ULONG FrameLen;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- USHORT Sequence;
- UCHAR i, TID;
- USHORT idx;
- BA_ORI_ENTRY *pBAEntry;
-
- for (i = 0; i <NUM_OF_TID; i++)
- {
- idx = pEntry->BAOriWcidArray[i];
- if (idx == 0)
- {
- continue;
- }
- pBAEntry = &pAd->BATable.BAOriEntry[idx];
-
- if (pBAEntry->ORI_BA_Status == Originator_Done)
- {
- TID = pBAEntry->TID;
-
- ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
- return;
- }
-
- Sequence = pEntry->TxSeq[TID];
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pEntry->Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
-
- FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
- FrameBar.StartingSeq.field.StartSeq = Sequence; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.TID = TID; // make sure sequence not clear in DEL funciton.
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_BAR), &FrameBar,
- END_OF_ARGS);
- //if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET)))
- if (1) // Now we always send BAR.
- {
- //MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- //MiniportDataMMRequest(pAd, MapUserPriorityToAccessCategory[TID], pOutBuffer, FrameLen);
- }
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID ActHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN PUCHAR Addr1,
- IN PUCHAR Addr2,
- IN PUCHAR Addr3)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
- pHdr80211->FC.Type = BTYPE_MGMT;
- pHdr80211->FC.SubType = SUBTYPE_ACTION;
-
- COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
- COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
- COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
-}
-
-VOID BarHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PFRAME_BAR pCntlBar,
- IN PUCHAR pDA,
- IN PUCHAR pSA)
-{
-// USHORT Duration;
-
- NdisZeroMemory(pCntlBar, sizeof(FRAME_BAR));
- pCntlBar->FC.Type = BTYPE_CNTL;
- pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
- pCntlBar->BarControl.MTID = 0;
- pCntlBar->BarControl.Compressed = 1;
- pCntlBar->BarControl.ACKPolicy = 0;
-
-
- pCntlBar->Duration = 16 + RTMPCalcDuration(pAd, RATE_1, sizeof(FRAME_BA));
-
- COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
- COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
-}
-
-
-/*
- ==========================================================================
- Description:
- Insert Category and action code into the action frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. category code of the frame.
- 4. action code of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID InsertActField(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 Category,
- IN UINT8 ActCode)
-{
- ULONG TempLen;
-
- MakeOutgoingFrame( pFrameBuf, &TempLen,
- 1, &Category,
- 1, &ActCode,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
+#include "../../rt2870/common/action.c"
diff --git a/drivers/staging/rt3070/common/ba_action.c b/drivers/staging/rt3070/common/ba_action.c
index 17e1f87d98db..2d638ea8c87a 100644
--- a/drivers/staging/rt3070/common/ba_action.c
+++ b/drivers/staging/rt3070/common/ba_action.c
@@ -1,1810 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-
-#ifdef DOT11_N_SUPPORT
-
-#include "../rt_config.h"
-
-
-
-#define BA_ORI_INIT_SEQ (pEntry->TxSeq[TID]) //1 // inital sequence number of BA session
-
-#define ORI_SESSION_MAX_RETRY 8
-#define ORI_BA_SESSION_TIMEOUT (2000) // ms
-#define REC_BA_SESSION_IDLE_TIMEOUT (1000) // ms
-
-#define REORDERING_PACKET_TIMEOUT ((100 * HZ)/1000) // system ticks -- 100 ms
-#define MAX_REORDERING_PACKET_TIMEOUT ((3000 * HZ)/1000) // system ticks -- 100 ms
-
-#define RESET_RCV_SEQ (0xFFFF)
-
-static void ba_mpdu_blk_free(PRTMP_ADAPTER pAd, struct reordering_mpdu *mpdu_blk);
-
-
-BA_ORI_ENTRY *BATableAllocOriEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx);
-
-BA_REC_ENTRY *BATableAllocRecEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx);
-
-VOID BAOriSessionSetupTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID BARecSessionIdleTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-
-BUILD_TIMER_FUNCTION(BAOriSessionSetupTimeout);
-BUILD_TIMER_FUNCTION(BARecSessionIdleTimeout);
-
-#define ANNOUNCE_REORDERING_PACKET(_pAd, _mpdu_blk) \
- Announce_Reordering_Packet(_pAd, _mpdu_blk);
-
-VOID BA_MaxWinSizeReasign(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntryPeer,
- OUT UCHAR *pWinSize)
-{
- UCHAR MaxSize;
-
-
- if (pAd->MACVersion >= RALINK_2883_VERSION) // 3*3
- {
- if (pAd->MACVersion >= RALINK_3070_VERSION)
- {
- if (pEntryPeer->WepStatus != Ndis802_11EncryptionDisabled)
- MaxSize = 7; // for non-open mode
- else
- MaxSize = 13;
- }
- else
- MaxSize = 31;
- }
- else if (pAd->MACVersion >= RALINK_2880E_VERSION) // 2880 e
- {
- if (pEntryPeer->WepStatus != Ndis802_11EncryptionDisabled)
- MaxSize = 7; // for non-open mode
- else
- MaxSize = 13;
- }
- else
- MaxSize = 7;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ba> Win Size = %d, Max Size = %d\n",
- *pWinSize, MaxSize));
-
- if ((*pWinSize) > MaxSize)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ba> reassign max win size from %d to %d\n",
- *pWinSize, MaxSize));
-
- *pWinSize = MaxSize;
- }
-}
-
-void Announce_Reordering_Packet(IN PRTMP_ADAPTER pAd,
- IN struct reordering_mpdu *mpdu)
-{
- PNDIS_PACKET pPacket;
-
- pPacket = mpdu->pPacket;
-
- if (mpdu->bAMSDU)
- {
- ASSERT(0);
- BA_Reorder_AMSDU_Annnounce(pAd, pPacket);
- }
- else
- {
- //
- // pass this 802.3 packet to upper layer or forward this packet to WM directly
- //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket, RTMP_GET_PACKET_IF(pPacket));
-#endif // CONFIG_STA_SUPPORT //
- }
-}
-
-/*
- * Insert a reordering mpdu into sorted linked list by sequence no.
- */
-BOOLEAN ba_reordering_mpdu_insertsorted(struct reordering_list *list, struct reordering_mpdu *mpdu)
-{
-
- struct reordering_mpdu **ppScan = &list->next;
-
- while (*ppScan != NULL)
- {
- if (SEQ_SMALLER((*ppScan)->Sequence, mpdu->Sequence, MAXSEQ))
- {
- ppScan = &(*ppScan)->next;
- }
- else if ((*ppScan)->Sequence == mpdu->Sequence)
- {
- /* give up this duplicated frame */
- return(FALSE);
- }
- else
- {
- /* find position */
- break;
- }
- }
-
- mpdu->next = *ppScan;
- *ppScan = mpdu;
- list->qlen++;
- return TRUE;
-}
-
-
-/*
- * caller lock critical section if necessary
- */
-static inline void ba_enqueue(struct reordering_list *list, struct reordering_mpdu *mpdu_blk)
-{
- list->qlen++;
- mpdu_blk->next = list->next;
- list->next = mpdu_blk;
-}
-
-/*
- * caller lock critical section if necessary
- */
-static inline struct reordering_mpdu * ba_dequeue(struct reordering_list *list)
-{
- struct reordering_mpdu *mpdu_blk = NULL;
-
- ASSERT(list);
-
- if (list->qlen)
- {
- list->qlen--;
- mpdu_blk = list->next;
- if (mpdu_blk)
- {
- list->next = mpdu_blk->next;
- mpdu_blk->next = NULL;
- }
- }
- return mpdu_blk;
-}
-
-
-static inline struct reordering_mpdu *ba_reordering_mpdu_dequeue(struct reordering_list *list)
-{
- return(ba_dequeue(list));
-}
-
-
-static inline struct reordering_mpdu *ba_reordering_mpdu_probe(struct reordering_list *list)
- {
- ASSERT(list);
-
- return(list->next);
- }
-
-
-/*
- * free all resource for reordering mechanism
- */
-void ba_reordering_resource_release(PRTMP_ADAPTER pAd)
-{
- BA_TABLE *Tab;
- PBA_REC_ENTRY pBAEntry;
- struct reordering_mpdu *mpdu_blk;
- int i;
-
- Tab = &pAd->BATable;
-
- /* I. release all pending reordering packet */
- NdisAcquireSpinLock(&pAd->BATabLock);
- for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++)
- {
- pBAEntry = &Tab->BARecEntry[i];
- if (pBAEntry->REC_BA_Status != Recipient_NONE)
- {
- while ((mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list)))
- {
- ASSERT(mpdu_blk->pPacket);
- RELEASE_NDIS_PACKET(pAd, mpdu_blk->pPacket, NDIS_STATUS_FAILURE);
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
- }
- }
- NdisReleaseSpinLock(&pAd->BATabLock);
-
- ASSERT(pBAEntry->list.qlen == 0);
- /* II. free memory of reordering mpdu table */
- NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
- os_free_mem(pAd, pAd->mpdu_blk_pool.mem);
- NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-}
-
-
-
-/*
- * Allocate all resource for reordering mechanism
- */
-BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num)
-{
- int i;
- PUCHAR mem;
- struct reordering_mpdu *mpdu_blk;
- struct reordering_list *freelist;
-
- /* allocate spinlock */
- NdisAllocateSpinLock(&pAd->mpdu_blk_pool.lock);
-
- /* initialize freelist */
- freelist = &pAd->mpdu_blk_pool.freelist;
- freelist->next = NULL;
- freelist->qlen = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Allocate %d memory for BA reordering\n", (UINT32)(num*sizeof(struct reordering_mpdu))));
-
- /* allocate number of mpdu_blk memory */
- os_alloc_mem(pAd, (PUCHAR *)&mem, (num*sizeof(struct reordering_mpdu)));
-
- pAd->mpdu_blk_pool.mem = mem;
-
- if (mem == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Can't Allocate Memory for BA Reordering\n"));
- return(FALSE);
- }
-
- /* build mpdu_blk free list */
- for (i=0; i<num; i++)
- {
- /* get mpdu_blk */
- mpdu_blk = (struct reordering_mpdu *) mem;
- /* initial mpdu_blk */
- NdisZeroMemory(mpdu_blk, sizeof(struct reordering_mpdu));
- /* next mpdu_blk */
- mem += sizeof(struct reordering_mpdu);
- /* insert mpdu_blk into freelist */
- ba_enqueue(freelist, mpdu_blk);
- }
-
- return(TRUE);
-}
-
-//static int blk_count=0; // sample take off, no use
-
-static struct reordering_mpdu *ba_mpdu_blk_alloc(PRTMP_ADAPTER pAd)
-{
- struct reordering_mpdu *mpdu_blk;
-
- NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
- mpdu_blk = ba_dequeue(&pAd->mpdu_blk_pool.freelist);
- if (mpdu_blk)
- {
-// blk_count++;
- /* reset mpdu_blk */
- NdisZeroMemory(mpdu_blk, sizeof(struct reordering_mpdu));
- }
- NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
- return mpdu_blk;
-}
-
-static void ba_mpdu_blk_free(PRTMP_ADAPTER pAd, struct reordering_mpdu *mpdu_blk)
-{
- ASSERT(mpdu_blk);
-
- NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
-// blk_count--;
- ba_enqueue(&pAd->mpdu_blk_pool.freelist, mpdu_blk);
- NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-}
-
-
-static USHORT ba_indicate_reordering_mpdus_in_order(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN USHORT StartSeq)
-{
- struct reordering_mpdu *mpdu_blk;
- USHORT LastIndSeq = RESET_RCV_SEQ;
-
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
- while ((mpdu_blk = ba_reordering_mpdu_probe(&pBAEntry->list)))
- {
- /* find in-order frame */
- if (!SEQ_STEPONE(mpdu_blk->Sequence, StartSeq, MAXSEQ))
- {
- break;
- }
- /* dequeue in-order frame from reodering list */
- mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list);
- /* pass this frame up */
- ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
- /* move to next sequence */
- StartSeq = mpdu_blk->Sequence;
- LastIndSeq = StartSeq;
- /* free mpdu_blk */
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
-
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-
- /* update last indicated sequence */
- return LastIndSeq;
-}
-
-static void ba_indicate_reordering_mpdus_le_seq(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN USHORT Sequence)
-{
- struct reordering_mpdu *mpdu_blk;
-
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
- while ((mpdu_blk = ba_reordering_mpdu_probe(&pBAEntry->list)))
- {
- /* find in-order frame */
- if ((mpdu_blk->Sequence == Sequence) || SEQ_SMALLER(mpdu_blk->Sequence, Sequence, MAXSEQ))
- {
- /* dequeue in-order frame from reodering list */
- mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list);
- /* pass this frame up */
- ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
- /* free mpdu_blk */
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
- else
- {
- break;
- }
- }
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-}
-
-
-static void ba_refresh_reordering_mpdus(
- IN PRTMP_ADAPTER pAd,
- PBA_REC_ENTRY pBAEntry)
-{
- struct reordering_mpdu *mpdu_blk;
-
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
- /* dequeue in-order frame from reodering list */
- while ((mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list)))
- {
- /* pass this frame up */
- ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
-
- pBAEntry->LastIndSeq = mpdu_blk->Sequence;
- ba_mpdu_blk_free(pAd, mpdu_blk);
-
- /* update last indicated sequence */
- }
- ASSERT(pBAEntry->list.qlen == 0);
- pBAEntry->LastIndSeq = RESET_RCV_SEQ;
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-}
-
-
-//static
-void ba_flush_reordering_timeout_mpdus(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN ULONG Now32)
-
-{
- USHORT Sequence;
-
-// if ((RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+REORDERING_PACKET_TIMEOUT)) &&
-// (pBAEntry->list.qlen > ((pBAEntry->BAWinSize*7)/8))) //||
-// (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(10*REORDERING_PACKET_TIMEOUT))) &&
-// (pBAEntry->list.qlen > (pBAEntry->BAWinSize/8)))
- if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(MAX_REORDERING_PACKET_TIMEOUT/6)))
- &&(pBAEntry->list.qlen > 1)
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%08lx-%08lx = %d > %d): %x, flush all!\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
- (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), MAX_REORDERING_PACKET_TIMEOUT,
- pBAEntry->LastIndSeq));
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- pBAEntry->LastIndSeqAtTimer = Now32;
- }
- else
- if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(REORDERING_PACKET_TIMEOUT)))
- && (pBAEntry->list.qlen > 0)
- )
- {
-// printk("timeout[%d] (%lx-%lx = %d > %d): %x, ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
-// (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), REORDERING_PACKET_TIMEOUT,
-// pBAEntry->LastIndSeq);
- //
- // force LastIndSeq to shift to LastIndSeq+1
- //
- Sequence = (pBAEntry->LastIndSeq+1) & MAXSEQ;
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
- pBAEntry->LastIndSeqAtTimer = Now32;
- pBAEntry->LastIndSeq = Sequence;
- //
- // indicate in-order mpdus
- //
- Sequence = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, Sequence);
- if (Sequence != RESET_RCV_SEQ)
- {
- pBAEntry->LastIndSeq = Sequence;
- }
-
- //printk("%x, flush one!\n", pBAEntry->LastIndSeq);
-
- }
-}
-
-
-/*
- * generate ADDBA request to
- * set up BA agreement
- */
-VOID BAOriSessionSetUp(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN UCHAR TID,
- IN USHORT TimeOut,
- IN ULONG DelayTime,
- IN BOOLEAN isForced)
-
-{
- //MLME_ADDBA_REQ_STRUCT AddbaReq;
- BA_ORI_ENTRY *pBAEntry = NULL;
- USHORT Idx;
- BOOLEAN Cancelled;
-
- if ((pAd->CommonCfg.BACapability.field.AutoBA != TRUE) && (isForced == FALSE))
- return;
-
- // if this entry is limited to use legacy tx mode, it doesn't generate BA.
- if (RTMPStaFixedTxMode(pAd, pEntry) != FIXED_TXMODE_HT)
- return;
-
- if ((pEntry->BADeclineBitmap & (1<<TID)) && (isForced == FALSE))
- {
- // try again after 3 secs
- DelayTime = 3000;
-// printk("DeCline BA from Peer\n");
-// return;
- }
-
-
- Idx = pEntry->BAOriWcidArray[TID];
- if (Idx == 0)
- {
- // allocate a BA session
- pBAEntry = BATableAllocOriEntry(pAd, &Idx);
- if (pBAEntry == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ADDBA - MlmeADDBAAction() allocate BA session failed \n"));
- return;
- }
- }
- else
- {
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
- }
-
- if (pBAEntry->ORI_BA_Status >= Originator_WaitRes)
- {
- return;
- }
-
- pEntry->BAOriWcidArray[TID] = Idx;
-
- // Initialize BA session
- pBAEntry->ORI_BA_Status = Originator_WaitRes;
- pBAEntry->Wcid = pEntry->Aid;
- pBAEntry->BAWinSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
- pBAEntry->Sequence = BA_ORI_INIT_SEQ;
- pBAEntry->Token = 1; // (2008-01-21) Jan Lee recommends it - this token can't be 0
- pBAEntry->TID = TID;
- pBAEntry->TimeOutValue = TimeOut;
- pBAEntry->pAdapter = pAd;
-
- DBGPRINT(RT_DEBUG_TRACE,("Send AddBA to %02x:%02x:%02x:%02x:%02x:%02x Tid:%d isForced:%d Wcid:%d\n"
- ,pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2]
- ,pEntry->Addr[3],pEntry->Addr[4],pEntry->Addr[5]
- ,TID,isForced,pEntry->Aid));
-
- if (!(pEntry->TXBAbitmap & (1<<TID)))
- {
- RTMPInitTimer(pAd, &pBAEntry->ORIBATimer, GET_TIMER_FUNCTION(BAOriSessionSetupTimeout), pBAEntry, FALSE);
- }
- else
- RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-
- // set timer to send ADDBA request
- RTMPSetTimer(&pBAEntry->ORIBATimer, DelayTime);
-}
-
-VOID BAOriSessionAdd(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN PFRAME_ADDBA_RSP pFrame)
-{
- BA_ORI_ENTRY *pBAEntry = NULL;
- BOOLEAN Cancelled;
- UCHAR TID;
- USHORT Idx;
- PUCHAR pOutBuffer2 = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- FRAME_BAR FrameBar;
-
- TID = pFrame->BaParm.TID;
- Idx = pEntry->BAOriWcidArray[TID];
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
-
- // Start fill in parameters.
- if ((Idx !=0) && (pBAEntry->TID == TID) && (pBAEntry->ORI_BA_Status == Originator_WaitRes))
- {
- pBAEntry->BAWinSize = min(pBAEntry->BAWinSize, ((UCHAR)pFrame->BaParm.BufSize));
- BA_MaxWinSizeReasign(pAd, pEntry, &pBAEntry->BAWinSize);
-
- pBAEntry->TimeOutValue = pFrame->TimeOutValue;
- pBAEntry->ORI_BA_Status = Originator_Done;
- // reset sequence number
- pBAEntry->Sequence = BA_ORI_INIT_SEQ;
- // Set Bitmap flag.
- pEntry->TXBAbitmap |= (1<<TID);
- RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-
- pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue;
-
- DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __FUNCTION__, pEntry->TXBAbitmap,
- pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue));
-
- // SEND BAR ;
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - BAOriSessionAdd() allocate memory failed \n"));
- return;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pBAEntry->Wcid].Addr, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
-
- FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
- FrameBar.StartingSeq.field.StartSeq = pBAEntry->Sequence; // make sure sequence not clear in DEL funciton.
- FrameBar.BarControl.TID = pBAEntry->TID; // make sure sequence not clear in DEL funciton.
- MakeOutgoingFrame(pOutBuffer2, &FrameLen,
- sizeof(FRAME_BAR), &FrameBar,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer2);
-
-
- if (pBAEntry->ORIBATimer.TimerValue)
- RTMPSetTimer(&pBAEntry->ORIBATimer, pBAEntry->ORIBATimer.TimerValue); // in mSec
- }
-}
-
-BOOLEAN BARecSessionAdd(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN PFRAME_ADDBA_REQ pFrame)
-{
- BA_REC_ENTRY *pBAEntry = NULL;
- BOOLEAN Status = TRUE;
- BOOLEAN Cancelled;
- USHORT Idx;
- UCHAR TID;
- UCHAR BAWinSize;
- //UINT32 Value;
- //UINT offset;
-
-
- ASSERT(pEntry);
-
- // find TID
- TID = pFrame->BaParm.TID;
-
- BAWinSize = min(((UCHAR)pFrame->BaParm.BufSize), (UCHAR)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
-
- // Intel patch
- if (BAWinSize == 0)
- {
- BAWinSize = 64;
- }
-
- Idx = pEntry->BARecWcidArray[TID];
-
-
- if (Idx == 0)
- {
- pBAEntry = BATableAllocRecEntry(pAd, &Idx);
- }
- else
- {
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- // flush all pending reordering mpdus
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __FUNCTION__, pAd->BATable.numAsRecipient, Idx,
- pFrame->BaParm.BufSize, BAWinSize));
-
- // Start fill in parameters.
- if (pBAEntry != NULL)
- {
- ASSERT(pBAEntry->list.qlen == 0);
-
- pBAEntry->REC_BA_Status = Recipient_HandleRes;
- pBAEntry->BAWinSize = BAWinSize;
- pBAEntry->Wcid = pEntry->Aid;
- pBAEntry->TID = TID;
- pBAEntry->TimeOutValue = pFrame->TimeOutValue;
- pBAEntry->REC_BA_Status = Recipient_Accept;
- // initial sequence number
- pBAEntry->LastIndSeq = RESET_RCV_SEQ; //pFrame->BaStartSeq.field.StartSeq;
-
- printk("Start Seq = %08x\n", pFrame->BaStartSeq.field.StartSeq);
-
- if (pEntry->RXBAbitmap & (1<<TID))
- {
- RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
- }
- else
- {
- RTMPInitTimer(pAd, &pBAEntry->RECBATimer, GET_TIMER_FUNCTION(BARecSessionIdleTimeout), pBAEntry, TRUE);
- }
-
- // Set Bitmap flag.
- pEntry->RXBAbitmap |= (1<<TID);
- pEntry->BARecWcidArray[TID] = Idx;
-
- pEntry->BADeclineBitmap &= ~(1<<TID);
-
- // Set BA session mask in WCID table.
- RT28XX_ADD_BA_SESSION_TO_ASIC(pAd, pEntry->Aid, TID);
-
- DBGPRINT(RT_DEBUG_TRACE,("MACEntry[%d]RXBAbitmap = 0x%x. BARecWcidArray=%d\n",
- pEntry->Aid, pEntry->RXBAbitmap, pEntry->BARecWcidArray[TID]));
- }
- else
- {
- Status = FALSE;
- DBGPRINT(RT_DEBUG_TRACE,("Can't Accept ADDBA for %02x:%02x:%02x:%02x:%02x:%02x TID = %d\n",
- PRINT_MAC(pEntry->Addr), TID));
- }
- return(Status);
-}
-
-
-BA_REC_ENTRY *BATableAllocRecEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx)
-{
- int i;
- BA_REC_ENTRY *pBAEntry = NULL;
-
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- if (pAd->BATable.numAsRecipient >= MAX_BARECI_SESSION)
- {
- printk("BA Recipeint Session (%ld) > %d\n", pAd->BATable.numAsRecipient,
- MAX_BARECI_SESSION);
- goto done;
- }
-
- // reserve idx 0 to identify BAWcidArray[TID] as empty
- for (i=1; i < MAX_LEN_OF_BA_REC_TABLE; i++)
- {
- pBAEntry =&pAd->BATable.BARecEntry[i];
- if ((pBAEntry->REC_BA_Status == Recipient_NONE))
- {
- // get one
- pAd->BATable.numAsRecipient++;
- pBAEntry->REC_BA_Status = Recipient_USED;
- *Idx = i;
- break;
- }
- }
-
-done:
- NdisReleaseSpinLock(&pAd->BATabLock);
- return pBAEntry;
-}
-
-BA_ORI_ENTRY *BATableAllocOriEntry(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Idx)
-{
- int i;
- BA_ORI_ENTRY *pBAEntry = NULL;
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- if (pAd->BATable.numAsOriginator >= (MAX_LEN_OF_BA_ORI_TABLE))
- {
- goto done;
- }
-
- // reserve idx 0 to identify BAWcidArray[TID] as empty
- for (i=1; i<MAX_LEN_OF_BA_ORI_TABLE; i++)
- {
- pBAEntry =&pAd->BATable.BAOriEntry[i];
- if ((pBAEntry->ORI_BA_Status == Originator_NONE))
- {
- // get one
- pAd->BATable.numAsOriginator++;
- pBAEntry->ORI_BA_Status = Originator_USED;
- pBAEntry->pAdapter = pAd;
- *Idx = i;
- break;
- }
- }
-
-done:
- NdisReleaseSpinLock(&pAd->BATabLock);
- return pBAEntry;
-}
-
-
-VOID BATableFreeOriEntry(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Idx)
-{
- BA_ORI_ENTRY *pBAEntry = NULL;
- MAC_TABLE_ENTRY *pEntry;
-
-
- if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_ORI_TABLE))
- return;
-
- pBAEntry =&pAd->BATable.BAOriEntry[Idx];
-
- if (pBAEntry->ORI_BA_Status != Originator_NONE)
- {
- pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
- pEntry->BAOriWcidArray[pBAEntry->TID] = 0;
-
-
- NdisAcquireSpinLock(&pAd->BATabLock);
- if (pBAEntry->ORI_BA_Status == Originator_Done)
- {
- pEntry->TXBAbitmap &= (~(1<<(pBAEntry->TID) ));
- DBGPRINT(RT_DEBUG_TRACE, ("BATableFreeOriEntry numAsOriginator= %ld\n", pAd->BATable.numAsRecipient));
- // Erase Bitmap flag.
- }
-
- ASSERT(pAd->BATable.numAsOriginator != 0);
-
- pAd->BATable.numAsOriginator -= 1;
-
- pBAEntry->ORI_BA_Status = Originator_NONE;
- pBAEntry->Token = 0;
- NdisReleaseSpinLock(&pAd->BATabLock);
- }
-}
-
-
-VOID BATableFreeRecEntry(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Idx)
-{
- BA_REC_ENTRY *pBAEntry = NULL;
- MAC_TABLE_ENTRY *pEntry;
-
-
- if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_REC_TABLE))
- return;
-
- pBAEntry =&pAd->BATable.BARecEntry[Idx];
-
- if (pBAEntry->REC_BA_Status != Recipient_NONE)
- {
- pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
- pEntry->BARecWcidArray[pBAEntry->TID] = 0;
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- ASSERT(pAd->BATable.numAsRecipient != 0);
-
- pAd->BATable.numAsRecipient -= 1;
-
- pBAEntry->REC_BA_Status = Recipient_NONE;
- NdisReleaseSpinLock(&pAd->BATabLock);
- }
-}
-
-
-VOID BAOriSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive,
- IN BOOLEAN bForceSend)
-{
- ULONG Idx = 0;
- BA_ORI_ENTRY *pBAEntry;
- BOOLEAN Cancelled;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- {
- return;
- }
-
- //
- // Locate corresponding BA Originator Entry in BA Table with the (pAddr,TID).
- //
- Idx = pAd->MacTab.Content[Wcid].BAOriWcidArray[TID];
- if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_ORI_TABLE))
- {
- if (bForceSend == TRUE)
- {
- // force send specified TID DelBA
- MLME_DELBA_REQ_STRUCT DelbaReq;
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
- NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-
- COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
- DelbaReq.Wcid = Wcid;
- DelbaReq.TID = TID;
- DelbaReq.Initiator = ORIGINATOR;
-#if 1
- Elem->MsgLen = sizeof(DelbaReq);
- NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
- MlmeDELBAAction(pAd, Elem);
- kfree(Elem);
-#else
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
- RT28XX_MLME_HANDLER(pAd);
-#endif
- }
-
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID));
-
- pBAEntry = &pAd->BATable.BAOriEntry[Idx];
- DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status));
- //
- // Prepare DelBA action frame and send to the peer.
- //
- if ((bPassive == FALSE) && (TID == pBAEntry->TID) && (pBAEntry->ORI_BA_Status == Originator_Done))
- {
- MLME_DELBA_REQ_STRUCT DelbaReq;
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
- NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-
- COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
- DelbaReq.Wcid = Wcid;
- DelbaReq.TID = pBAEntry->TID;
- DelbaReq.Initiator = ORIGINATOR;
-#if 1
- Elem->MsgLen = sizeof(DelbaReq);
- NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
- MlmeDELBAAction(pAd, Elem);
- kfree(Elem);
-#else
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
- RT28XX_MLME_HANDLER(pAd);
-#endif
- }
- RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
- BATableFreeOriEntry(pAd, Idx);
-
- if (bPassive)
- {
- //BAOriSessionSetUp(pAd, &pAd->MacTab.Content[Wcid], TID, 0, 10000, TRUE);
- }
-}
-
-VOID BARecSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive)
-{
- ULONG Idx = 0;
- BA_REC_ENTRY *pBAEntry;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- {
- return;
- }
-
- //
- // Locate corresponding BA Originator Entry in BA Table with the (pAddr,TID).
- //
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- if (Idx == 0)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID));
-
-
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, REC_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->REC_BA_Status));
- //
- // Prepare DelBA action frame and send to the peer.
- //
- if ((TID == pBAEntry->TID) && (pBAEntry->REC_BA_Status == Recipient_Accept))
- {
- MLME_DELBA_REQ_STRUCT DelbaReq;
- BOOLEAN Cancelled;
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
- //ULONG offset;
- //UINT32 VALUE;
-
- RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
-
- //
- // 1. Send DELBA Action Frame
- //
- if (bPassive == FALSE)
- {
- NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
- NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-
- COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
- DelbaReq.Wcid = Wcid;
- DelbaReq.TID = TID;
- DelbaReq.Initiator = RECIPIENT;
-#if 1
- Elem->MsgLen = sizeof(DelbaReq);
- NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
- MlmeDELBAAction(pAd, Elem);
- kfree(Elem);
-#else
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
- RT28XX_MLME_HANDLER(pAd);
-#endif
- }
-
-
- //
- // 2. Free resource of BA session
- //
- // flush all pending reordering mpdus
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
-
- NdisAcquireSpinLock(&pAd->BATabLock);
-
- // Erase Bitmap flag.
- pBAEntry->LastIndSeq = RESET_RCV_SEQ;
- pBAEntry->BAWinSize = 0;
- // Erase Bitmap flag at software mactable
- pAd->MacTab.Content[Wcid].RXBAbitmap &= (~(1<<(pBAEntry->TID)));
- pAd->MacTab.Content[Wcid].BARecWcidArray[TID] = 0;
-
- RT28XX_DEL_BA_SESSION_FROM_ASIC(pAd, Wcid, TID);
-
- NdisReleaseSpinLock(&pAd->BATabLock);
-
- }
-
- BATableFreeRecEntry(pAd, Idx);
-}
-
-VOID BASessionTearDownALL(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid)
-{
- int i;
-
- for (i=0; i<NUM_OF_TID; i++)
- {
- BAOriSessionTearDown(pAd, Wcid, i, FALSE, FALSE);
- BARecSessionTearDown(pAd, Wcid, i, FALSE);
- }
-}
-
-
-/*
- ==========================================================================
- Description:
- Retry sending ADDBA Reqest.
-
- IRQL = DISPATCH_LEVEL
-
- Parametrs:
- p8023Header: if this is already 802.3 format, p8023Header is NULL
-
- Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
- FALSE , then continue indicaterx at this moment.
- ==========================================================================
- */
-VOID BAOriSessionSetupTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- BA_ORI_ENTRY *pBAEntry = (BA_ORI_ENTRY *)FunctionContext;
- MAC_TABLE_ENTRY *pEntry;
- PRTMP_ADAPTER pAd;
-
- if (pBAEntry == NULL)
- return;
-
- pAd = pBAEntry->pAdapter;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
-
- if ((pBAEntry->ORI_BA_Status == Originator_WaitRes) && (pBAEntry->Token < ORI_SESSION_MAX_RETRY))
- {
- MLME_ADDBA_REQ_STRUCT AddbaReq;
-
- NdisZeroMemory(&AddbaReq, sizeof(AddbaReq));
- COPY_MAC_ADDR(AddbaReq.pAddr, pEntry->Addr);
- AddbaReq.Wcid = (UCHAR)(pEntry->Aid);
- AddbaReq.TID = pBAEntry->TID;
- AddbaReq.BaBufSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
- AddbaReq.TimeOutValue = 0;
- AddbaReq.Token = pBAEntry->Token;
- MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ADD_BA_CATE, sizeof(MLME_ADDBA_REQ_STRUCT), (PVOID)&AddbaReq);
- RT28XX_MLME_HANDLER(pAd);
- //DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) : Send ADD BA again\n", pBAEntry->Token));
-
- DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) to %02x:%02x:%02x:%02x:%02x:%02x Tid:%d Wcid:%d\n"
- ,pBAEntry->Token
- ,pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2]
- ,pEntry->Addr[3],pEntry->Addr[4],pEntry->Addr[5]
- ,pBAEntry->TID,pEntry->Aid));
-
- pBAEntry->Token++;
- RTMPSetTimer(&pBAEntry->ORIBATimer, ORI_BA_SESSION_TIMEOUT);
- }
- else
- {
- BATableFreeOriEntry(pAd, pEntry->BAOriWcidArray[pBAEntry->TID]);
- }
-}
-
-/*
- ==========================================================================
- Description:
- Retry sending ADDBA Reqest.
-
- IRQL = DISPATCH_LEVEL
-
- Parametrs:
- p8023Header: if this is already 802.3 format, p8023Header is NULL
-
- Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
- FALSE , then continue indicaterx at this moment.
- ==========================================================================
- */
-VOID BARecSessionIdleTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
-
- BA_REC_ENTRY *pBAEntry = (BA_REC_ENTRY *)FunctionContext;
- PRTMP_ADAPTER pAd;
- ULONG Now32;
-
- if (pBAEntry == NULL)
- return;
-
- if ((pBAEntry->REC_BA_Status == Recipient_Accept))
- {
- NdisGetSystemUpTime(&Now32);
-
- if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer + REC_BA_SESSION_IDLE_TIMEOUT)))
- {
- pAd = pBAEntry->pAdapter;
- // flush all pending reordering mpdus
- ba_refresh_reordering_mpdus(pAd, pBAEntry);
- printk("%ld: REC BA session Timeout\n", Now32);
- }
- }
-}
-
-
-VOID PeerAddBAReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- // 7.4.4.1
- //ULONG Idx;
- UCHAR Status = 1;
- UCHAR pAddr[6];
- FRAME_ADDBA_RSP ADDframe;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- PFRAME_ADDBA_REQ pAddreqFrame = NULL;
- //UCHAR BufSize;
- ULONG FrameLen;
- PULONG ptemp;
- PMAC_TABLE_ENTRY pMacEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __FUNCTION__, Elem->Wcid));
-
- //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen);
-
- //ADDBA Request from unknown peer, ignore this.
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- pMacEntry = &pAd->MacTab.Content[Elem->Wcid];
- DBGPRINT(RT_DEBUG_TRACE,("BA - PeerAddBAReqAction----> \n"));
- ptemp = (PULONG)Elem->Msg;
- //DBGPRINT_RAW(RT_DEBUG_EMU, ("%08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x\n", *(ptemp), *(ptemp+1), *(ptemp+2), *(ptemp+3), *(ptemp+4), *(ptemp+5), *(ptemp+6), *(ptemp+7), *(ptemp+8)));
-
- if (PeerAddBAReqActionSanity(pAd, Elem->Msg, Elem->MsgLen, pAddr))
- {
-
- if ((pAd->CommonCfg.bBADecline == FALSE) && IS_HT_STA(pMacEntry))
- {
- pAddreqFrame = (PFRAME_ADDBA_REQ)(&Elem->Msg[0]);
- printk("Rcv Wcid(%d) AddBAReq\n", Elem->Wcid);
- if (BARecSessionAdd(pAd, &pAd->MacTab.Content[Elem->Wcid], pAddreqFrame))
- Status = 0;
- else
- Status = 38; // more parameters have invalid values
- }
- else
- {
- Status = 37; // the request has been declined.
- }
- }
-
- if (pAd->MacTab.Content[Elem->Wcid].ValidAsCLI)
- ASSERT(pAd->MacTab.Content[Elem->Wcid].Sst == SST_ASSOC);
-
- pAddreqFrame = (PFRAME_ADDBA_REQ)(&Elem->Msg[0]);
- // 2. Always send back ADDBA Response
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ACTION - PeerBAAction() allocate memory failed \n"));
- return;
- }
-
- NdisZeroMemory(&ADDframe, sizeof(FRAME_ADDBA_RSP));
- // 2-1. Prepare ADDBA Response frame.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ADHOC_ON(pAd))
- ActHeaderInit(pAd, &ADDframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- else
- ActHeaderInit(pAd, &ADDframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
- }
-#endif // CONFIG_STA_SUPPORT //
- ADDframe.Category = CATEGORY_BA;
- ADDframe.Action = ADDBA_RESP;
- ADDframe.Token = pAddreqFrame->Token;
- // What is the Status code?? need to check.
- ADDframe.StatusCode = Status;
- ADDframe.BaParm.BAPolicy = IMMED_BA;
- ADDframe.BaParm.AMSDUSupported = 0;
- ADDframe.BaParm.TID = pAddreqFrame->BaParm.TID;
- ADDframe.BaParm.BufSize = min(((UCHAR)pAddreqFrame->BaParm.BufSize), (UCHAR)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
- if (ADDframe.BaParm.BufSize == 0)
- {
- ADDframe.BaParm.BufSize = 64;
- }
- ADDframe.TimeOutValue = 0; //pAddreqFrame->TimeOutValue;
-
- *(USHORT *)(&ADDframe.BaParm) = cpu2le16(*(USHORT *)(&ADDframe.BaParm));
- ADDframe.StatusCode = cpu2le16(ADDframe.StatusCode);
- ADDframe.TimeOutValue = cpu2le16(ADDframe.TimeOutValue);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_ADDBA_RSP), &ADDframe,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __FUNCTION__, Elem->Wcid, ADDframe.BaParm.TID,
- ADDframe.BaParm.BufSize));
-}
-
-
-VOID PeerAddBARspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- //UCHAR Idx, i;
- //PUCHAR pOutBuffer = NULL;
- PFRAME_ADDBA_RSP pFrame = NULL;
- //PBA_ORI_ENTRY pBAEntry;
-
- //ADDBA Response from unknown peer, ignore this.
- if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __FUNCTION__, Elem->Wcid));
-
- //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen);
-
- if (PeerAddBARspActionSanity(pAd, Elem->Msg, Elem->MsgLen))
- {
- pFrame = (PFRAME_ADDBA_RSP)(&Elem->Msg[0]);
-
- DBGPRINT(RT_DEBUG_TRACE, ("\t\t StatusCode = %d\n", pFrame->StatusCode));
- switch (pFrame->StatusCode)
- {
- case 0:
- // I want a BAsession with this peer as an originator.
- BAOriSessionAdd(pAd, &pAd->MacTab.Content[Elem->Wcid], pFrame);
- break;
- default:
- // check status == USED ???
- BAOriSessionTearDown(pAd, Elem->Wcid, pFrame->BaParm.TID, TRUE, FALSE);
- break;
- }
- // Rcv Decline StatusCode
- if ((pFrame->StatusCode == 37)
-#ifdef CONFIG_STA_SUPPORT
- || ((pAd->OpMode == OPMODE_STA) && STA_TGN_WIFI_ON(pAd) && (pFrame->StatusCode != 0))
-#endif // CONFIG_STA_SUPPORT //
- )
- {
- pAd->MacTab.Content[Elem->Wcid].BADeclineBitmap |= 1<<pFrame->BaParm.TID;
- }
- }
-}
-
-VOID PeerDelBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- //UCHAR Idx;
- //PUCHAR pOutBuffer = NULL;
- PFRAME_DELBA_REQ pDelFrame = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __FUNCTION__));
- //DELBA Request from unknown peer, ignore this.
- if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen))
- {
- pDelFrame = (PFRAME_DELBA_REQ)(&Elem->Msg[0]);
- if (pDelFrame->DelbaParm.Initiator == ORIGINATOR)
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - PeerDelBAAction----> ORIGINATOR\n"));
- BARecSessionTearDown(pAd, Elem->Wcid, pDelFrame->DelbaParm.TID, TRUE);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("BA - PeerDelBAAction----> RECIPIENT, Reason = %d\n", pDelFrame->ReasonCode));
- //hex_dump("DelBA Frame", pDelFrame, Elem->MsgLen);
- BAOriSessionTearDown(pAd, Elem->Wcid, pDelFrame->DelbaParm.TID, TRUE, FALSE);
- }
- }
-}
-
-
-BOOLEAN CntlEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG MsgLen,
- IN PFRAME_BA_REQ pMsg)
-{
- PFRAME_BA_REQ pFrame = pMsg;
- //PRTMP_REORDERBUF pBuffer;
- //PRTMP_REORDERBUF pDmaBuf;
- PBA_REC_ENTRY pBAEntry;
- //BOOLEAN Result;
- ULONG Idx;
- //UCHAR NumRxPkt;
- UCHAR TID;//, i;
-
- TID = (UCHAR)pFrame->BARControl.TID;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __FUNCTION__, Wcid, TID));
- //hex_dump("BAR", (PCHAR) pFrame, MsgLen);
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return FALSE;
-
- // First check the size, it MUST not exceed the mlme queue size
- if (MsgLen > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("CntlEnqueueForRecv: frame too large, size = %ld \n", MsgLen));
- return FALSE;
- }
- else if (MsgLen != sizeof(FRAME_BA_REQ))
- {
- DBGPRINT_ERR(("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
- else if (MsgLen != sizeof(FRAME_BA_REQ))
- {
- DBGPRINT_ERR(("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
-
- if ((Wcid < MAX_LEN_OF_MAC_TABLE) && (TID < 8))
- {
- // if this receiving packet is from SA that is in our OriEntry. Since WCID <9 has direct mapping. no need search.
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- }
- else
- {
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("BAR(%ld) : Tid (%d) - %04x:%04x\n", Wcid, TID, pFrame->BAStartingSeq.field.StartSeq, pBAEntry->LastIndSeq ));
-
- if (SEQ_SMALLER(pBAEntry->LastIndSeq, pFrame->BAStartingSeq.field.StartSeq, MAXSEQ))
- {
- //printk("BAR Seq = %x, LastIndSeq = %x\n", pFrame->BAStartingSeq.field.StartSeq, pBAEntry->LastIndSeq);
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, pFrame->BAStartingSeq.field.StartSeq);
- pBAEntry->LastIndSeq = (pFrame->BAStartingSeq.field.StartSeq == 0) ? MAXSEQ :(pFrame->BAStartingSeq.field.StartSeq -1);
- }
- //ba_refresh_reordering_mpdus(pAd, pBAEntry);
- return TRUE;
-}
-
-/*
-Description : Send PSMP Action frame If PSMP mode switches.
-*/
-VOID SendPSMPAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Psmp)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- //ULONG Idx;
- FRAME_PSMP_ACTION Frame;
- ULONG FrameLen;
-#ifdef RT30xx
- UCHAR bbpdata=0;
- UINT32 macdata;
-#endif // RT30xx //
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
- return;
- }
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[Wcid].Addr);
-#endif // CONFIG_STA_SUPPORT //
-
- Frame.Category = CATEGORY_HT;
- Frame.Action = SMPS_ACTION;
- switch (Psmp)
- {
- case MMPS_ENABLE:
-#ifdef RT30xx
- if (IS_RT3090(pAd))
- {
- // disable MMPS BBP control register
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata);
- bbpdata &= ~(0x04); //bit 2
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata);
-
- // disable MMPS MAC control register
- RTMP_IO_READ32(pAd, 0x1210, &macdata);
- macdata &= ~(0x09); //bit 0, 3
- RTMP_IO_WRITE32(pAd, 0x1210, macdata);
- }
-#endif // RT30xx //
- Frame.Psmp = 0;
- break;
- case MMPS_DYNAMIC:
-#ifdef RT30xx
- if (IS_RT3090(pAd))
- {
- // enable MMPS BBP control register
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata);
- bbpdata |= 0x04; //bit 2
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata);
-
- // enable MMPS MAC control register
- RTMP_IO_READ32(pAd, 0x1210, &macdata);
- macdata |= 0x09; //bit 0, 3
- RTMP_IO_WRITE32(pAd, 0x1210, macdata);
- }
-#endif // RT30xx //
- Frame.Psmp = 3;
- break;
- case MMPS_STATIC:
-#ifdef RT30xx
- if (IS_RT3090(pAd))
- {
- // enable MMPS BBP control register
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata);
- bbpdata |= 0x04; //bit 2
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata);
-
- // enable MMPS MAC control register
- RTMP_IO_READ32(pAd, 0x1210, &macdata);
- macdata |= 0x09; //bit 0, 3
- RTMP_IO_WRITE32(pAd, 0x1210, macdata);
- }
-#endif // RT30xx //
- Frame.Psmp = 1;
- break;
- }
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(FRAME_PSMP_ACTION), &Frame,
- END_OF_ARGS);
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_ERROR,("HT - SendPSMPAction( %d ) \n", Frame.Psmp));
-}
-
-
-#define RADIO_MEASUREMENT_REQUEST_ACTION 0
-
-typedef struct PACKED
-{
- UCHAR RegulatoryClass;
- UCHAR ChannelNumber;
- USHORT RandomInterval;
- USHORT MeasurementDuration;
- UCHAR MeasurementMode;
- UCHAR BSSID[MAC_ADDR_LEN];
- UCHAR ReportingCondition;
- UCHAR Threshold;
- UCHAR SSIDIE[2]; // 2 byte
-} BEACON_REQUEST;
-
-typedef struct PACKED
-{
- UCHAR ID;
- UCHAR Length;
- UCHAR Token;
- UCHAR RequestMode;
- UCHAR Type;
-} MEASUREMENT_REQ;
-
-
-
-
-void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PNDIS_PACKET pRxPkt;
- UCHAR Header802_3[LENGTH_802_3];
-
- // 1. get 802.3 Header
- // 2. remove LLC
- // a. pointer pRxBlk->pData to payload
- // b. modify pRxBlk->DataSize
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
- ASSERT(pRxBlk->pRxPacket);
- pRxPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
- RTPKT_TO_OSPKT(pRxPkt)->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- RTPKT_TO_OSPKT(pRxPkt)->data = pRxBlk->pData;
- RTPKT_TO_OSPKT(pRxPkt)->len = pRxBlk->DataSize;
- RTPKT_TO_OSPKT(pRxPkt)->tail = RTPKT_TO_OSPKT(pRxPkt)->data + RTPKT_TO_OSPKT(pRxPkt)->len;
-
- //
- // copy 802.3 header, if necessary
- //
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef LINUX
- NdisMoveMemory(skb_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
-#endif
-#ifdef UCOS
- NdisMoveMemory(net_pkt_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
-#endif
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-}
-
-
-#define INDICATE_LEGACY_OR_AMSDU(_pAd, _pRxBlk, _fromWhichBSSID) \
- do \
- { \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_AMSDU)) \
- { \
- Indicate_AMSDU_Packet(_pAd, _pRxBlk, _fromWhichBSSID); \
- } \
- else if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_EAP)) \
- { \
- Indicate_EAPOL_Packet(_pAd, _pRxBlk, _fromWhichBSSID); \
- } \
- else \
- { \
- Indicate_Legacy_Packet(_pAd, _pRxBlk, _fromWhichBSSID); \
- } \
- } while (0);
-
-
-
-static VOID ba_enqueue_reordering_packet(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- struct reordering_mpdu *mpdu_blk;
- UINT16 Sequence = (UINT16) pRxBlk->pHeader->Sequence;
-
- mpdu_blk = ba_mpdu_blk_alloc(pAd);
- if (mpdu_blk != NULL)
- {
- // Write RxD buffer address & allocated buffer length
- NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
- mpdu_blk->Sequence = Sequence;
-
- mpdu_blk->bAMSDU = RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU);
-
- convert_reordering_packet_to_preAMSDU_or_802_3_packet(pAd, pRxBlk, FromWhichBSSID);
-
- STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
-
- //
- // it is necessary for reordering packet to record
- // which BSS it come from
- //
- RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
-
- mpdu_blk->pPacket = pRxBlk->pRxPacket;
-
- if (ba_reordering_mpdu_insertsorted(&pBAEntry->list, mpdu_blk) == FALSE)
- {
- // had been already within reordering list
- // don't indicate
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_SUCCESS);
- ba_mpdu_blk_free(pAd, mpdu_blk);
- }
-
- ASSERT((0<= pBAEntry->list.qlen) && (pBAEntry->list.qlen <= pBAEntry->BAWinSize));
- NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!! (%d) Can't allocate reordering mpdu blk\n",
- pBAEntry->list.qlen));
- /*
- * flush all pending reordering mpdus
- * and receving mpdu to upper layer
- * make tcp/ip to take care reordering mechanism
- */
- //ba_refresh_reordering_mpdus(pAd, pBAEntry);
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
-
- pBAEntry->LastIndSeq = Sequence;
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- }
-}
-
-
-/*
- ==========================================================================
- Description:
- Indicate this packet to upper layer or put it into reordering buffer
-
- Parametrs:
- pRxBlk : carry necessary packet info 802.11 format
- FromWhichBSSID : the packet received from which BSS
-
- Return :
- none
-
- Note :
- the packet queued into reordering buffer need to cover to 802.3 format
- or pre_AMSDU format
- ==========================================================================
- */
-
-VOID Indicate_AMPDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- USHORT Idx;
- PBA_REC_ENTRY pBAEntry = NULL;
- UINT16 Sequence = pRxBlk->pHeader->Sequence;
- ULONG Now32;
- UCHAR Wcid = pRxBlk->pRxWI->WirelessCliID;
- UCHAR TID = pRxBlk->pRxWI->TID;
-
-
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU) && (pRxBlk->DataSize > MAX_RX_PKT_LEN))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- if (Wcid < MAX_LEN_OF_MAC_TABLE)
- {
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- if (Idx == 0)
- {
- /* Rec BA Session had been torn down */
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- }
- else
- {
- // impossible !!!
- ASSERT(0);
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- ASSERT(pBAEntry);
-
- // update last rx time
- NdisGetSystemUpTime(&Now32);
-
- pBAEntry->rcvSeq = Sequence;
-
-
- ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32);
- pBAEntry->LastIndSeqAtTimer = Now32;
-
- //
- // Reset Last Indicate Sequence
- //
- if (pBAEntry->LastIndSeq == RESET_RCV_SEQ)
- {
- ASSERT((pBAEntry->list.qlen == 0) && (pBAEntry->list.next == NULL));
-
- // reset rcv sequence of BA session
- pBAEntry->LastIndSeq = Sequence;
- pBAEntry->LastIndSeqAtTimer = Now32;
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
-
-
- //
- // I. Check if in order.
- //
- if (SEQ_STEPONE(Sequence, pBAEntry->LastIndSeq, MAXSEQ))
- {
- USHORT LastIndSeq;
-
- pBAEntry->LastIndSeq = Sequence;
- INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
- LastIndSeq = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, pBAEntry->LastIndSeq);
- if (LastIndSeq != RESET_RCV_SEQ)
- {
- pBAEntry->LastIndSeq = LastIndSeq;
- }
- pBAEntry->LastIndSeqAtTimer = Now32;
- }
- //
- // II. Drop Duplicated Packet
- //
- else if (Sequence == pBAEntry->LastIndSeq)
- {
-
- // drop and release packet
- pBAEntry->nDropPacket++;
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- }
- //
- // III. Drop Old Received Packet
- //
- else if (SEQ_SMALLER(Sequence, pBAEntry->LastIndSeq, MAXSEQ))
- {
-
- // drop and release packet
- pBAEntry->nDropPacket++;
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- }
- //
- // IV. Receive Sequence within Window Size
- //
- else if (SEQ_SMALLER(Sequence, (((pBAEntry->LastIndSeq+pBAEntry->BAWinSize+1)) & MAXSEQ), MAXSEQ))
- {
- ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk, FromWhichBSSID);
- }
- //
- // V. Receive seq surpasses Win(lastseq + nMSDU). So refresh all reorder buffer
- //
- else
- {
- LONG WinStartSeq, TmpSeq;
-
-
- TmpSeq = Sequence - (pBAEntry->BAWinSize) -1;
- if (TmpSeq < 0)
- {
- TmpSeq = (MAXSEQ+1) + TmpSeq;
- }
- WinStartSeq = (TmpSeq+1) & MAXSEQ;
- ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, WinStartSeq);
- pBAEntry->LastIndSeq = WinStartSeq; //TmpSeq;
-
- pBAEntry->LastIndSeqAtTimer = Now32;
-
- ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk, FromWhichBSSID);
-
- TmpSeq = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, pBAEntry->LastIndSeq);
- if (TmpSeq != RESET_RCV_SEQ)
- {
- pBAEntry->LastIndSeq = TmpSeq;
- }
- }
-}
-
-#endif // DOT11_N_SUPPORT //
-
+#include "../../rt2870/common/ba_action.c"
diff --git a/drivers/staging/rt3070/common/cmm_data.c b/drivers/staging/rt3070/common/cmm_data.c
index 85f92b9f83da..02e202db4dad 100644
--- a/drivers/staging/rt3070/common/cmm_data.c
+++ b/drivers/staging/rt3070/common/cmm_data.c
@@ -1,2827 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-*/
-
-#include "../rt_config.h"
-
-#define MAX_TX_IN_TBTT (16)
-
-
-UCHAR SNAP_802_1H[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
-UCHAR SNAP_BRIDGE_TUNNEL[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
-// Add Cisco Aironet SNAP heade for CCX2 support
-UCHAR SNAP_AIRONET[] = {0xaa, 0xaa, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00};
-UCHAR CKIP_LLC_SNAP[] = {0xaa, 0xaa, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02};
-UCHAR EAPOL_LLC_SNAP[]= {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e};
-UCHAR EAPOL[] = {0x88, 0x8e};
-UCHAR TPID[] = {0x81, 0x00}; /* VLAN related */
-
-UCHAR IPX[] = {0x81, 0x37};
-UCHAR APPLE_TALK[] = {0x80, 0xf3};
-UCHAR RateIdToPlcpSignal[12] = {
- 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec
- 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14
- 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14
-
-UCHAR OfdmSignalToRateId[16] = {
- RATE_54, RATE_54, RATE_54, RATE_54, // OFDM PLCP Signal = 0, 1, 2, 3 respectively
- RATE_54, RATE_54, RATE_54, RATE_54, // OFDM PLCP Signal = 4, 5, 6, 7 respectively
- RATE_48, RATE_24, RATE_12, RATE_6, // OFDM PLCP Signal = 8, 9, 10, 11 respectively
- RATE_54, RATE_36, RATE_18, RATE_9, // OFDM PLCP Signal = 12, 13, 14, 15 respectively
-};
-
-UCHAR OfdmRateToRxwiMCS[12] = {
- 0, 0, 0, 0,
- 0, 1, 2, 3, // OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3
- 4, 5, 6, 7, // OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7
-};
-UCHAR RxwiMCSToOfdmRate[12] = {
- RATE_6, RATE_9, RATE_12, RATE_18,
- RATE_24, RATE_36, RATE_48, RATE_54, // OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3
- 4, 5, 6, 7, // OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7
-};
-
-char* MCSToMbps[] = {"1Mbps","2Mbps","5.5Mbps","11Mbps","06Mbps","09Mbps","12Mbps","18Mbps","24Mbps","36Mbps","48Mbps","54Mbps","MM-0","MM-1","MM-2","MM-3","MM-4","MM-5","MM-6","MM-7","MM-8","MM-9","MM-10","MM-11","MM-12","MM-13","MM-14","MM-15","MM-32","ee1","ee2","ee3"};
-
-UCHAR default_cwmin[]={CW_MIN_IN_BITS, CW_MIN_IN_BITS, CW_MIN_IN_BITS-1, CW_MIN_IN_BITS-2};
-//UCHAR default_cwmax[]={CW_MAX_IN_BITS, CW_MAX_IN_BITS, CW_MIN_IN_BITS, CW_MIN_IN_BITS-1};
-UCHAR default_sta_aifsn[]={3,7,2,2};
-
-UCHAR MapUserPriorityToAccessCategory[8] = {QID_AC_BE, QID_AC_BK, QID_AC_BK, QID_AC_BE, QID_AC_VI, QID_AC_VI, QID_AC_VO, QID_AC_VO};
-
-
-/*
- ========================================================================
-
- Routine Description:
- API for MLME to transmit management frame to AP (BSS Mode)
- or station (IBSS Mode)
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to the outgoing 802.11 frame
- Length Size of outgoing management frame
-
- Return Value:
- NDIS_STATUS_FAILURE
- NDIS_STATUS_PENDING
- NDIS_STATUS_SUCCESS
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS MiniportMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length)
-{
- PNDIS_PACKET pPacket;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- ULONG FreeNum;
- UCHAR IrqState;
- UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
-
- ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
-
- QueIdx=3;
-
- // 2860C use Tx Ring
-
- IrqState = pAd->irq_disabled;
-
- do
- {
- // Reset is in progress, stop immediately
- if ( RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)||
- !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
- {
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- // Check Free priority queue
- // Since we use PBF Queue2 for management frame. Its corresponding DMA ring should be using TxRing.
-
- // 2860C use Tx Ring
- if (pAd->MACVersion == 0x28600100)
- {
- FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
- }
- else
- {
- FreeNum = GET_MGMTRING_FREENO(pAd);
- }
-
- if ((FreeNum > 0))
- {
- // We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870
- NdisZeroMemory(&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE));
- Status = RTMPAllocateNdisPacket(pAd, &pPacket, (PUCHAR)&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE), pData, Length);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_WARN, ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n"));
- break;
- }
-
- //pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- //pAd->CommonCfg.MlmeRate = RATE_2;
-
-
- Status = MlmeHardTransmit(pAd, QueIdx, pPacket);
- if (Status != NDIS_STATUS_SUCCESS)
- RTMPFreeNdisPacket(pAd, pPacket);
- }
- else
- {
- pAd->RalinkCounters.MgmtRingFullCount++;
- DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in MgmtRing, MgmtRingFullCount=%ld!\n",
- QueIdx, pAd->RalinkCounters.MgmtRingFullCount));
- }
-
- } while (FALSE);
-
-
- return Status;
-}
-
-
-
-NDIS_STATUS MlmeDataHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-#define MAX_DATAMM_RETRY 3
-/*
- ========================================================================
-
- Routine Description:
- API for MLME to transmit management frame to AP (BSS Mode)
- or station (IBSS Mode)
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to the outgoing 802.11 frame
- Length Size of outgoing management frame
-
- Return Value:
- NDIS_STATUS_FAILURE
- NDIS_STATUS_PENDING
- NDIS_STATUS_SUCCESS
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS MiniportDataMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length)
-{
- PNDIS_PACKET pPacket;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- ULONG FreeNum;
- int retry = 0;
- UCHAR IrqState;
- UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
-
- ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
-
- // 2860C use Tx Ring
- IrqState = pAd->irq_disabled;
-
- do
- {
- // Reset is in progress, stop immediately
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)||
- !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
- {
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- // Check Free priority queue
- // Since we use PBF Queue2 for management frame. Its corresponding DMA ring should be using TxRing.
-
- // 2860C use Tx Ring
-
- // free Tx(QueIdx) resources
- FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
-
- if ((FreeNum > 0))
- {
- // We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870
- NdisZeroMemory(&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE));
- Status = RTMPAllocateNdisPacket(pAd, &pPacket, (PUCHAR)&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE), pData, Length);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_WARN, ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n"));
- break;
- }
-
- //pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- //pAd->CommonCfg.MlmeRate = RATE_2;
-
-
- Status = MlmeDataHardTransmit(pAd, QueIdx, pPacket);
- if (Status != NDIS_STATUS_SUCCESS)
- RTMPFreeNdisPacket(pAd, pPacket);
- retry = MAX_DATAMM_RETRY;
- }
- else
- {
- retry ++;
-
- printk("retry %d\n", retry);
- pAd->RalinkCounters.MgmtRingFullCount++;
-
- if (retry >= MAX_DATAMM_RETRY)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in DataRing, MgmtRingFullCount=%ld!\n",
- QueIdx, pAd->RalinkCounters.MgmtRingFullCount));
- }
- }
-
- } while (retry < MAX_DATAMM_RETRY);
-
-
- return Status;
-}
-
-
-
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware transmit function
-
- Arguments:
- pAd Pointer to our adapter
- pBuffer Pointer to memory of outgoing frame
- Length Size of outgoing management frame
-
- Return Value:
- NDIS_STATUS_FAILURE
- NDIS_STATUS_PENDING
- NDIS_STATUS_SUCCESS
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS MlmeHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
-#ifdef CARRIER_DETECTION_SUPPORT
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- return NDIS_STATUS_FAILURE;
- }
-
- return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket);
-
-}
-
-NDIS_STATUS MlmeDataHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
-#ifdef CARRIER_DETECTION_SUPPORT
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- return NDIS_STATUS_FAILURE;
- }
-
-#ifdef RT2870
- return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket);
-#endif // RT2870 //
-}
-
-
-
-
-
-NDIS_STATUS MlmeHardTransmitMgmtRing(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- PHEADER_802_11 pHeader_802_11;
- BOOLEAN bAckRequired, bInsertTimestamp;
- UCHAR MlmeRate;
- PTXWI_STRUC pFirstTxWI;
- MAC_TABLE_ENTRY *pMacEntry = NULL;
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- // Make sure MGMT ring resource won't be used by other threads
-// sample, for IRQ LOCK -> SEM LOCK
-// IrqState = pAd->irq_disabled;
-// if (!IrqState)
- RTMP_SEM_LOCK(&pAd->MgmtRingLock);
-
-
- if (pSrcBufVA == NULL)
- {
- // The buffer shouldn't be NULL
-// if (!IrqState)
- RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
- return NDIS_STATUS_FAILURE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // outgoing frame always wakeup PHY to prevent frame lost
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- AsicForceWakeup(pAd, TRUE);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pFirstTxWI = (PTXWI_STRUC)(pSrcBufVA + TXINFO_SIZE);
- pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE); //TXWI_SIZE);
-
- if (pHeader_802_11->Addr1[0] & 0x01)
- {
- MlmeRate = pAd->CommonCfg.BasicMlmeRate;
- }
- else
- {
- MlmeRate = pAd->CommonCfg.MlmeRate;
- }
-
- // Verify Mlme rate for a / g bands.
- if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6)) // 11A band
- MlmeRate = RATE_6;
-
- if ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
- (pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL))
- {
- pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Fixed W52 with Activity scan issue in ABG_MIXED and ABGN_MIXED mode.
- if (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED
-#ifdef DOT11_N_SUPPORT
- || pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED
-#endif // DOT11_N_SUPPORT //
- )
- {
- if (pAd->LatchRfRegs.Channel > 14)
- pAd->CommonCfg.MlmeTransmit.field.MODE = 1;
- else
- pAd->CommonCfg.MlmeTransmit.field.MODE = 0;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- //
- // Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE)
- // Snice it's been set to 0 while on MgtMacHeaderInit
- // By the way this will cause frame to be send on PWR_SAVE failed.
- //
- // pHeader_802_11->FC.PwrMgmt = 0; // (pAd->StaCfg.Psm == PWR_SAVE);
- //
- // In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
-#ifdef CONFIG_STA_SUPPORT
- // Data-Null packets alse pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD
- if ((pHeader_802_11->FC.Type != BTYPE_DATA) && (pHeader_802_11->FC.Type != BTYPE_CNTL))
- {
- if ((pAd->StaCfg.Psm == PWR_SAVE) &&
- (pHeader_802_11->FC.SubType == SUBTYPE_ACTION))
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- else
- pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- bInsertTimestamp = FALSE;
- if (pHeader_802_11->FC.Type == BTYPE_CNTL) // must be PS-POLL
- {
-#ifdef CONFIG_STA_SUPPORT
- //Set PM bit in ps-poll, to fix WLK 1.2 PowerSaveMode_ext failure issue.
- if ((pAd->OpMode == OPMODE_STA) && (pHeader_802_11->FC.SubType == SUBTYPE_PS_POLL))
- {
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- }
-#endif // CONFIG_STA_SUPPORT //
- bAckRequired = FALSE;
- }
- else // BTYPE_MGMT or BTYPE_DATA(must be NULL frame)
- {
- //pAd->Sequence++;
- //pHeader_802_11->Sequence = pAd->Sequence;
-
- if (pHeader_802_11->Addr1[0] & 0x01) // MULTICAST, BROADCAST
- {
- bAckRequired = FALSE;
- pHeader_802_11->Duration = 0;
- }
- else
- {
- bAckRequired = TRUE;
- pHeader_802_11->Duration = RTMPCalcDuration(pAd, MlmeRate, 14);
- if (pHeader_802_11->FC.SubType == SUBTYPE_PROBE_RSP)
- {
- bInsertTimestamp = TRUE;
- }
- }
- }
-
- pHeader_802_11->Sequence = pAd->Sequence++;
- if (pAd->Sequence >0xfff)
- pAd->Sequence = 0;
-
- // Before radar detection done, mgmt frame can not be sent but probe req
- // Because we need to use probe req to trigger driver to send probe req in passive scan
- if ((pHeader_802_11->FC.SubType != SUBTYPE_PROBE_REQ)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE))
- {
- DBGPRINT(RT_DEBUG_ERROR,("MlmeHardTransmit --> radar detect not in normal mode !!!\n"));
-// if (!IrqState)
- RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
- return (NDIS_STATUS_FAILURE);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader_802_11, DIR_WRITE, FALSE);
-#endif
-
- //
- // fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET
- // should always has only one ohysical buffer, and the whole frame size equals
- // to the first scatter buffer size
- //
-
- // Initialize TX Descriptor
- // For inter-frame gap, the number is for this frame and next frame
- // For MLME rate, we will fix as 2Mb to match other vendor's implement
-// pAd->CommonCfg.MlmeTransmit.field.MODE = 1;
-
-// management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not.
- if (pMacEntry == NULL)
- {
- RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE,
- 0, RESERVED_WCID, (SrcBufLen - TXINFO_SIZE - TXWI_SIZE), PID_MGMT, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
- }
- else
- {
- RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE,
- bInsertTimestamp, FALSE, bAckRequired, FALSE,
- 0, pMacEntry->Aid, (SrcBufLen - TXINFO_SIZE - TXWI_SIZE),
- pMacEntry->MaxHTPhyMode.field.MCS, 0,
- (UCHAR)pMacEntry->MaxHTPhyMode.field.MCS,
- IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pFirstTxWI, TYPE_TXWI);
-#endif
-
- // Now do hardware-depened kick out.
- HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen);
-
- // Make sure to release MGMT ring resource
-// if (!IrqState)
- RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
- return NDIS_STATUS_SUCCESS;
-}
-
-
-/********************************************************************************
-
- New DeQueue Procedures.
-
- ********************************************************************************/
-
-#define DEQUEUE_LOCK(lock, bIntContext, IrqFlags) \
- do{ \
- if (bIntContext == FALSE) \
- RTMP_IRQ_LOCK((lock), IrqFlags); \
- }while(0)
-
-#define DEQUEUE_UNLOCK(lock, bIntContext, IrqFlags) \
- do{ \
- if (bIntContext == FALSE) \
- RTMP_IRQ_UNLOCK((lock), IrqFlags); \
- }while(0)
-
-
-/*
- ========================================================================
- Tx Path design algorithm:
- Basically, we divide the packets into four types, Broadcast/Multicast, 11N Rate(AMPDU, AMSDU, Normal), B/G Rate(ARALINK, Normal),
- Specific Packet Type. Following show the classification rule and policy for each kinds of packets.
- Classification Rule=>
- Multicast: (*addr1 & 0x01) == 0x01
- Specific : bDHCPFrame, bARPFrame, bEAPOLFrame, etc.
- 11N Rate : If peer support HT
- (1).AMPDU -- If TXBA is negotiated.
- (2).AMSDU -- If AMSDU is capable for both peer and ourself.
- *). AMSDU can embedded in a AMPDU, but now we didn't support it.
- (3).Normal -- Other packets which send as 11n rate.
-
- B/G Rate : If peer is b/g only.
- (1).ARALINK-- If both of peer/us supprot Ralink proprietary Aggregation and the TxRate is large than RATE_6
- (2).Normal -- Other packets which send as b/g rate.
- Fragment:
- The packet must be unicast, NOT A-RALINK, NOT A-MSDU, NOT 11n, then can consider about fragment.
-
- Classified Packet Handle Rule=>
- Multicast:
- No ACK, //pTxBlk->bAckRequired = FALSE;
- No WMM, //pTxBlk->bWMM = FALSE;
- No piggyback, //pTxBlk->bPiggyBack = FALSE;
- Force LowRate, //pTxBlk->bForceLowRate = TRUE;
- Specific : Basically, for specific packet, we should handle it specifically, but now all specific packets are use
- the same policy to handle it.
- Force LowRate, //pTxBlk->bForceLowRate = TRUE;
-
- 11N Rate :
- No piggyback, //pTxBlk->bPiggyBack = FALSE;
-
- (1).AMSDU
- pTxBlk->bWMM = TRUE;
- (2).AMPDU
- pTxBlk->bWMM = TRUE;
- (3).Normal
-
- B/G Rate :
- (1).ARALINK
-
- (2).Normal
- ========================================================================
-*/
-static UCHAR TxPktClassification(
- IN RTMP_ADAPTER *pAd,
- IN PNDIS_PACKET pPacket)
-{
- UCHAR TxFrameType = TX_UNKOWN_FRAME;
- UCHAR Wcid;
- MAC_TABLE_ENTRY *pMacEntry = NULL;
-#ifdef DOT11_N_SUPPORT
- BOOLEAN bHTRate = FALSE;
-#endif // DOT11_N_SUPPORT //
-
- Wcid = RTMP_GET_PACKET_WCID(pPacket);
- if (Wcid == MCAST_WCID)
- { // Handle for RA is Broadcast/Multicast Address.
- return TX_MCAST_FRAME;
- }
-
- // Handle for unicast packets
- pMacEntry = &pAd->MacTab.Content[Wcid];
- if (RTMP_GET_PACKET_LOWRATE(pPacket))
- { // It's a specific packet need to force low rate, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame
- TxFrameType = TX_LEGACY_FRAME;
- }
-#ifdef DOT11_N_SUPPORT
- else if (IS_HT_RATE(pMacEntry))
- { // it's a 11n capable packet
-
- // Depends on HTPhyMode to check if the peer support the HTRate transmission.
- // Currently didn't support A-MSDU embedded in A-MPDU
- bHTRate = TRUE;
- if (RTMP_GET_PACKET_MOREDATA(pPacket) || (pMacEntry->PsMode == PWR_SAVE))
- TxFrameType = TX_LEGACY_FRAME;
-#ifdef UAPSD_AP_SUPPORT
- else if (RTMP_GET_PACKET_EOSP(pPacket))
- TxFrameType = TX_LEGACY_FRAME;
-#endif // UAPSD_AP_SUPPORT //
- else if((pMacEntry->TXBAbitmap & (1<<(RTMP_GET_PACKET_UP(pPacket)))) != 0)
- return TX_AMPDU_FRAME;
- else if(CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AMSDU_INUSED))
- return TX_AMSDU_FRAME;
- else
- TxFrameType = TX_LEGACY_FRAME;
- }
-#endif // DOT11_N_SUPPORT //
- else
- { // it's a legacy b/g packet.
- if ((CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE) && pAd->CommonCfg.bAggregationCapable) &&
- (RTMP_GET_PACKET_TXRATE(pPacket) >= RATE_6) &&
- (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))))
- { // if peer support Ralink Aggregation, we use it.
- TxFrameType = TX_RALINK_FRAME;
- }
- else
- {
- TxFrameType = TX_LEGACY_FRAME;
- }
- }
-
- // Currently, our fragment only support when a unicast packet send as NOT-ARALINK, NOT-AMSDU and NOT-AMPDU.
- if ((RTMP_GET_PACKET_FRAGMENTS(pPacket) > 1) && (TxFrameType == TX_LEGACY_FRAME))
- TxFrameType = TX_FRAG_FRAME;
-
- return TxFrameType;
-}
-
-
-BOOLEAN RTMP_FillTxBlkInfo(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PACKET_INFO PacketInfo;
- PNDIS_PACKET pPacket;
- PMAC_TABLE_ENTRY pMacEntry = NULL;
-
- pPacket = pTxBlk->pPacket;
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pTxBlk->pSrcBufHeader, &pTxBlk->SrcBufLen);
-
- pTxBlk->Wcid = RTMP_GET_PACKET_WCID(pPacket);
- pTxBlk->apidx = RTMP_GET_PACKET_IF(pPacket);
- pTxBlk->UserPriority = RTMP_GET_PACKET_UP(pPacket);
- pTxBlk->FrameGap = IFS_HTTXOP; // ASIC determine Frame Gap
-
- if (RTMP_GET_PACKET_CLEAR_EAP_FRAME(pTxBlk->pPacket))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bClearEAPFrame);
- else
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bClearEAPFrame);
-
- // Default to clear this flag
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bForceNonQoS);
-
-
- if (pTxBlk->Wcid == MCAST_WCID)
- {
- pTxBlk->pMacEntry = NULL;
- {
-#ifdef MCAST_RATE_SPECIFIC
- PUCHAR pDA = GET_OS_PKT_DATAPTR(pPacket);
- if (((*pDA & 0x01) == 0x01) && (*pDA != 0xff))
- pTxBlk->pTransmit = &pAd->CommonCfg.MCastPhyMode;
- else
-#endif // MCAST_RATE_SPECIFIC //
- pTxBlk->pTransmit = &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
- }
-
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired); // AckRequired = FALSE, when broadcast packet in Adhoc mode.
- //TX_BLK_SET_FLAG(pTxBlk, fTX_bForceLowRate);
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAllowFrag);
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
- if (RTMP_GET_PACKET_MOREDATA(pPacket))
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
- }
-
- }
- else
- {
- pTxBlk->pMacEntry = &pAd->MacTab.Content[pTxBlk->Wcid];
- pTxBlk->pTransmit = &pTxBlk->pMacEntry->HTPhyMode;
-
- pMacEntry = pTxBlk->pMacEntry;
-
-
- // For all unicast packets, need Ack unless the Ack Policy is not set as NORMAL_ACK.
- if (pAd->CommonCfg.AckPolicy[pTxBlk->QueIdx] != NORMAL_ACK)
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);
- else
- TX_BLK_SET_FLAG(pTxBlk, fTX_bAckRequired);
-
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- // If support WMM, enable it.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM);
-
-// if (pAd->StaCfg.bAutoTxRateSwitch)
-// TX_BLK_SET_FLAG(pTxBlk, fTX_AutoRateSwitch);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if (pTxBlk->TxFrameType == TX_LEGACY_FRAME)
- {
- if ( (RTMP_GET_PACKET_LOWRATE(pPacket)) ||
- ((pAd->OpMode == OPMODE_AP) && (pMacEntry->MaxHTPhyMode.field.MODE == MODE_CCK) && (pMacEntry->MaxHTPhyMode.field.MCS == RATE_1)))
- { // Specific packet, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame, need force low rate.
- pTxBlk->pTransmit = &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
-#ifdef DOT11_N_SUPPORT
- // Modify the WMM bit for ICV issue. If we have a packet with EOSP field need to set as 1, how to handle it???
- if (IS_HT_STA(pTxBlk->pMacEntry) &&
- (CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RALINK_CHIPSET)) &&
- ((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RDG_CAPABLE)))
- {
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
- TX_BLK_SET_FLAG(pTxBlk, fTX_bForceNonQoS);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
-#ifdef DOT11_N_SUPPORT
- if ( (IS_HT_RATE(pMacEntry) == FALSE) &&
- (CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE)))
- { // Currently piggy-back only support when peer is operate in b/g mode.
- TX_BLK_SET_FLAG(pTxBlk, fTX_bPiggyBack);
- }
-#endif // DOT11_N_SUPPORT //
-
- if (RTMP_GET_PACKET_MOREDATA(pPacket))
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
- }
-#ifdef UAPSD_AP_SUPPORT
- if (RTMP_GET_PACKET_EOSP(pPacket))
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM_UAPSD_EOSP);
- }
-#endif // UAPSD_AP_SUPPORT //
- }
- else if (pTxBlk->TxFrameType == TX_FRAG_FRAME)
- {
- TX_BLK_SET_FLAG(pTxBlk, fTX_bAllowFrag);
- }
-
- pMacEntry->DebugTxCount++;
- }
-
- return TRUE;
-
-FillTxBlkErr:
- return FALSE;
-}
-
-
-BOOLEAN CanDoAggregateTransmit(
- IN RTMP_ADAPTER *pAd,
- IN NDIS_PACKET *pPacket,
- IN TX_BLK *pTxBlk)
-{
-
- //printk("Check if can do aggregation! TxFrameType=%d!\n", pTxBlk->TxFrameType);
-
- if (RTMP_GET_PACKET_WCID(pPacket) == MCAST_WCID)
- return FALSE;
-
- if (RTMP_GET_PACKET_DHCP(pPacket) ||
- RTMP_GET_PACKET_EAPOL(pPacket) ||
- RTMP_GET_PACKET_WAI(pPacket))
- return FALSE;
-
- if ((pTxBlk->TxFrameType == TX_AMSDU_FRAME) &&
- ((pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))> (RX_BUFFER_AGGRESIZE - 100)))
- { // For AMSDU, allow the packets with total length < max-amsdu size
- return FALSE;
- }
-
- if ((pTxBlk->TxFrameType == TX_RALINK_FRAME) &&
- (pTxBlk->TxPacketList.Number == 2))
- { // For RALINK-Aggregation, allow two frames in one batch.
- return FALSE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- if ((INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA)) // must be unicast to AP
- return TRUE;
- else
-#endif // CONFIG_STA_SUPPORT //
- return FALSE;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- To do the enqueue operation and extract the first item of waiting
- list. If a number of available shared memory segments could meet
- the request of extracted item, the extracted item will be fragmented
- into shared memory segments.
-
- Arguments:
- pAd Pointer to our adapter
- pQueue Pointer to Waiting Queue
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPDeQueuePacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bIntContext,
- IN UCHAR QIdx, /* BulkOutPipeId */
- IN UCHAR Max_Tx_Packets)
-{
- PQUEUE_ENTRY pEntry = NULL;
- PNDIS_PACKET pPacket;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- UCHAR Count=0;
- PQUEUE_HEADER pQueue;
- ULONG FreeNumber[NUM_OF_TX_RING];
- UCHAR QueIdx, sQIdx, eQIdx;
- unsigned long IrqFlags = 0;
- BOOLEAN hasTxDesc = FALSE;
- TX_BLK TxBlk;
- TX_BLK *pTxBlk;
-
-#ifdef DBG_DIAGNOSE
- BOOLEAN firstRound;
- RtmpDiagStruct *pDiagStruct = &pAd->DiagStruct;
-#endif
-
-
- if (QIdx == NUM_OF_TX_RING)
- {
- sQIdx = 0;
-//PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- eQIdx = 3; // 4 ACs, start from 0.
-#endif // CONFIG_STA_SUPPORT //
- }
- else
- {
- sQIdx = eQIdx = QIdx;
- }
-
- for (QueIdx=sQIdx; QueIdx <= eQIdx; QueIdx++)
- {
- Count=0;
-
- RT28XX_START_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-#ifdef DBG_DIAGNOSE
- firstRound = ((QueIdx == 0) ? TRUE : FALSE);
-#endif // DBG_DIAGNOSE //
-
- while (1)
- {
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST))))
- {
- RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
- return;
- }
-
- if (Count >= Max_Tx_Packets)
- break;
-
- DEQUEUE_LOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- if (&pAd->TxSwQueue[QueIdx] == NULL)
- {
-#ifdef DBG_DIAGNOSE
- if (firstRound == TRUE)
- pDiagStruct->TxSWQueCnt[pDiagStruct->ArrayCurIdx][0]++;
-#endif // DBG_DIAGNOSE //
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- break;
- }
-
-
- // probe the Queue Head
- pQueue = &pAd->TxSwQueue[QueIdx];
- if ((pEntry = pQueue->Head) == NULL)
- {
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- break;
- }
-
- pTxBlk = &TxBlk;
- NdisZeroMemory((PUCHAR)pTxBlk, sizeof(TX_BLK));
- //InitializeQueueHeader(&pTxBlk->TxPacketList); // Didn't need it because we already memzero it.
- pTxBlk->QueIdx = QueIdx;
-
- pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
-
- // Early check to make sure we have enoguh Tx Resource.
- hasTxDesc = RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, FreeNumber[QueIdx], pPacket);
- if (!hasTxDesc)
- {
- pAd->PrivateInfo.TxRingFullCnt++;
-
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-
- break;
- }
-
- pTxBlk->TxFrameType = TxPktClassification(pAd, pPacket);
- pEntry = RemoveHeadQueue(pQueue);
- pTxBlk->TotalFrameNum++;
- pTxBlk->TotalFragNum += RTMP_GET_PACKET_FRAGMENTS(pPacket); // The real fragment number maybe vary
- pTxBlk->TotalFrameLen += GET_OS_PKT_LEN(pPacket);
- pTxBlk->pPacket = pPacket;
- InsertTailQueue(&pTxBlk->TxPacketList, PACKET_TO_QUEUE_ENTRY(pPacket));
-
- if (pTxBlk->TxFrameType == TX_RALINK_FRAME || pTxBlk->TxFrameType == TX_AMSDU_FRAME)
- {
- // Enhance SW Aggregation Mechanism
- if (NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, FreeNumber[QueIdx], pTxBlk->TxFrameType))
- {
- InsertHeadQueue(pQueue, PACKET_TO_QUEUE_ENTRY(pPacket));
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
- break;
- }
-
- do{
- if((pEntry = pQueue->Head) == NULL)
- break;
-
- // For TX_AMSDU_FRAME/TX_RALINK_FRAME, Need to check if next pakcet can do aggregation.
- pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
- FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
- hasTxDesc = RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, FreeNumber[QueIdx], pPacket);
- if ((hasTxDesc == FALSE) || (CanDoAggregateTransmit(pAd, pPacket, pTxBlk) == FALSE))
- break;
-
- //Remove the packet from the TxSwQueue and insert into pTxBlk
- pEntry = RemoveHeadQueue(pQueue);
- ASSERT(pEntry);
- pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
- pTxBlk->TotalFrameNum++;
- pTxBlk->TotalFragNum += RTMP_GET_PACKET_FRAGMENTS(pPacket); // The real fragment number maybe vary
- pTxBlk->TotalFrameLen += GET_OS_PKT_LEN(pPacket);
- InsertTailQueue(&pTxBlk->TxPacketList, PACKET_TO_QUEUE_ENTRY(pPacket));
- }while(1);
-
- if (pTxBlk->TxPacketList.Number == 1)
- pTxBlk->TxFrameType = TX_LEGACY_FRAME;
- }
-
-#ifdef RT2870
- DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-#endif // RT2870 //
-
- Count += pTxBlk->TxPacketList.Number;
-
- // Do HardTransmit now.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- Status = STAHardTransmit(pAd, pTxBlk, QueIdx);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-#ifdef RT2870
- if (!hasTxDesc)
- RTUSBKickBulkOut(pAd);
-#endif // RT2870 //
-
-#ifdef BLOCK_NET_IF
- if ((pAd->blockQueueTab[QueIdx].SwTxQueueBlockFlag == TRUE)
- && (pAd->TxSwQueue[QueIdx].Number < 1))
- {
- releaseNetIf(&pAd->blockQueueTab[QueIdx]);
- }
-#endif // BLOCK_NET_IF //
-
- }
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculates the duration which is required to transmit out frames
- with given size and specified rate.
-
- Arguments:
- pAd Pointer to our adapter
- Rate Transmit rate
- Size Frame size in units of byte
-
- Return Value:
- Duration number in units of usec
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-USHORT RTMPCalcDuration(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Rate,
- IN ULONG Size)
-{
- ULONG Duration = 0;
-
- if (Rate < RATE_FIRST_OFDM_RATE) // CCK
- {
- if ((Rate > RATE_1) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED))
- Duration = 96; // 72+24 preamble+plcp
- else
- Duration = 192; // 144+48 preamble+plcp
-
- Duration += (USHORT)((Size << 4) / RateIdTo500Kbps[Rate]);
- if ((Size << 4) % RateIdTo500Kbps[Rate])
- Duration ++;
- }
- else if (Rate <= RATE_LAST_OFDM_RATE)// OFDM rates
- {
- Duration = 20 + 6; // 16+4 preamble+plcp + Signal Extension
- Duration += 4 * (USHORT)((11 + Size * 4) / RateIdTo500Kbps[Rate]);
- if ((11 + Size * 4) % RateIdTo500Kbps[Rate])
- Duration += 4;
- }
- else //mimo rate
- {
- Duration = 20 + 6; // 16+4 preamble+plcp + Signal Extension
- }
-
- return (USHORT)Duration;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculates the duration which is required to transmit out frames
- with given size and specified rate.
-
- Arguments:
- pTxWI Pointer to head of each MPDU to HW.
- Ack Setting for Ack requirement bit
- Fragment Setting for Fragment bit
- RetryMode Setting for retry mode
- Ifs Setting for IFS gap
- Rate Setting for transmit rate
- Service Setting for service
- Length Frame length
- TxPreamble Short or Long preamble when using CCK rates
- QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- See also : BASmartHardTransmit() !!!
-
- ========================================================================
-*/
-VOID RTMPWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pOutTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN CFACK,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR TID,
- IN UCHAR TxRate,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING *pTransmit)
-{
- PMAC_TABLE_ENTRY pMac = NULL;
- TXWI_STRUC TxWI;
- PTXWI_STRUC pTxWI;
-
- if (WCID < MAX_LEN_OF_MAC_TABLE)
- pMac = &pAd->MacTab.Content[WCID];
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- NdisZeroMemory(&TxWI, TXWI_SIZE);
- pTxWI = &TxWI;
-
- pTxWI->FRAG= FRAG;
-
- pTxWI->CFACK = CFACK;
- pTxWI->TS= InsTimestamp;
- pTxWI->AMPDU = AMPDU;
- pTxWI->ACK = Ack;
- pTxWI->txop= Txopmode;
-
- pTxWI->NSEQ = NSeq;
- // John tune the performace with Intel Client in 20 MHz performance
-#ifdef DOT11_N_SUPPORT
- BASize = pAd->CommonCfg.TxBASize;
-
- if( BASize >7 )
- BASize =7;
- pTxWI->BAWinSize = BASize;
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->WirelessCliID = WCID;
- pTxWI->MPDUtotalByteCount = Length;
- pTxWI->PacketId = PID;
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
- pTxWI->CFACK = CfAck;
-
-#ifdef DOT11_N_SUPPORT
- if (pMac)
- {
- if (pAd->CommonCfg.bMIMOPSEnable)
- {
- if ((pMac->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
- {
- // Dynamic MIMO Power Save Mode
- pTxWI->MIMOps = 1;
- }
- else if (pMac->MmpsMode == MMPS_STATIC)
- {
- // Static MIMO Power Save Mode
- if (pTransmit->field.MODE >= MODE_HTMIX && pTransmit->field.MCS > 7)
- {
- pTxWI->MCS = 7;
- pTxWI->MIMOps = 0;
- }
- }
- }
- //pTxWI->MIMOps = (pMac->PsMode == PWR_MMPS)? 1:0;
- if (pMac->bIAmBadAtheros && (pMac->WepStatus != Ndis802_11WEPDisabled))
- {
- pTxWI->MpduDensity = 7;
- }
- else
- {
- pTxWI->MpduDensity = pMac->MpduDensity;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->PacketId = pTxWI->MCS;
- NdisMoveMemory(pOutTxWI, &TxWI, sizeof(TXWI_STRUC));
-}
-
-
-VOID RTMPWriteTxWI_Data(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk)
-{
- HTTRANSMIT_SETTING *pTransmit;
- PMAC_TABLE_ENTRY pMacEntry;
-#ifdef DOT11_N_SUPPORT
- UCHAR BASize;
-#endif // DOT11_N_SUPPORT //
-
-
- ASSERT(pTxWI);
-
- pTransmit = pTxBlk->pTransmit;
- pMacEntry = pTxBlk->pMacEntry;
-
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- NdisZeroMemory(pTxWI, TXWI_SIZE);
-
- pTxWI->FRAG = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag);
- pTxWI->ACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired);
- pTxWI->txop = pTxBlk->FrameGap;
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (pMacEntry &&
- (pAd->StaCfg.BssType == BSS_INFRA) &&
- (pMacEntry->ValidAsDls == TRUE))
- pTxWI->WirelessCliID = BSSID_WCID;
- else
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- pTxWI->WirelessCliID = pTxBlk->Wcid;
-
- pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
- pTxWI->CFACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bPiggyBack);
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
- pTxWI->AMPDU = ((pTxBlk->TxFrameType == TX_AMPDU_FRAME) ? TRUE : FALSE);
-
- // John tune the performace with Intel Client in 20 MHz performance
- BASize = pAd->CommonCfg.TxBASize;
- if((pTxBlk->TxFrameType == TX_AMPDU_FRAME) && (pMacEntry))
- {
- UCHAR RABAOriIdx = 0; //The RA's BA Originator table index.
-
- RABAOriIdx = pTxBlk->pMacEntry->BAOriWcidArray[pTxBlk->UserPriority];
- BASize = pAd->BATable.BAOriEntry[RABAOriIdx].BAWinSize;
- }
-
- pTxWI->TxBF = pTransmit->field.TxBF;
- pTxWI->BAWinSize = BASize;
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
-
-#ifdef DOT11_N_SUPPORT
- if (pMacEntry)
- {
- if ((pMacEntry->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
- {
- // Dynamic MIMO Power Save Mode
- pTxWI->MIMOps = 1;
- }
- else if (pMacEntry->MmpsMode == MMPS_STATIC)
- {
- // Static MIMO Power Save Mode
- if (pTransmit->field.MODE >= MODE_HTMIX && pTransmit->field.MCS > 7)
- {
- pTxWI->MCS = 7;
- pTxWI->MIMOps = 0;
- }
- }
-
- if (pMacEntry->bIAmBadAtheros && (pMacEntry->WepStatus != Ndis802_11WEPDisabled))
- {
- pTxWI->MpduDensity = 7;
- }
- else
- {
- pTxWI->MpduDensity = pMacEntry->MpduDensity;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DBG_DIAGNOSE
- if (pTxBlk->QueIdx== 0)
- {
- pAd->DiagStruct.TxDataCnt[pAd->DiagStruct.ArrayCurIdx]++;
- pAd->DiagStruct.TxMcsCnt[pAd->DiagStruct.ArrayCurIdx][pTxWI->MCS]++;
- }
-#endif // DBG_DIAGNOSE //
-
- // for rate adapation
- pTxWI->PacketId = pTxWI->MCS;
-#ifdef INF_AMAZON_SE
-/*Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate */
- if( RTMP_GET_PACKET_NOBULKOUT(pTxBlk->pPacket))
- {
- if(pTxWI->PHYMODE == MODE_CCK)
- {
- pTxWI->PacketId = 6;
- }
- }
-#endif // INF_AMAZON_SE //
-}
-
-
-VOID RTMPWriteTxWI_Cache(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk)
-{
- PHTTRANSMIT_SETTING /*pTxHTPhyMode,*/ pTransmit;
- PMAC_TABLE_ENTRY pMacEntry;
-
- //
- // update TXWI
- //
- pMacEntry = pTxBlk->pMacEntry;
- pTransmit = pTxBlk->pTransmit;
-
- //if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))
- //if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pMacEntry))
- //if (TX_BLK_TEST_FLAG(pTxBlk, fTX_AutoRateSwitch))
- if (pMacEntry->bAutoTxRateSwitch)
- {
- pTxWI->txop = IFS_HTTXOP;
-
- // If CCK or OFDM, BW must be 20
- pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
- pTxWI->ShortGI = pTransmit->field.ShortGI;
- pTxWI->STBC = pTransmit->field.STBC;
-
- pTxWI->MCS = pTransmit->field.MCS;
- pTxWI->PHYMODE = pTransmit->field.MODE;
-
- // set PID for TxRateSwitching
- pTxWI->PacketId = pTransmit->field.MCS;
- }
-
-#ifdef DOT11_N_SUPPORT
- pTxWI->AMPDU = ((pMacEntry->NoBADataCountDown == 0) ? TRUE: FALSE);
- pTxWI->MIMOps = 0;
-
-#ifdef DOT11N_DRAFT3
- if (pTxWI->BW)
- pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
-#endif // DOT11N_DRAFT3 //
-
- if (pAd->CommonCfg.bMIMOPSEnable)
- {
- // MIMO Power Save Mode
- if ((pMacEntry->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
- {
- // Dynamic MIMO Power Save Mode
- pTxWI->MIMOps = 1;
- }
- else if (pMacEntry->MmpsMode == MMPS_STATIC)
- {
- // Static MIMO Power Save Mode
- if ((pTransmit->field.MODE >= MODE_HTMIX) && (pTransmit->field.MCS > 7))
- {
- pTxWI->MCS = 7;
- pTxWI->MIMOps = 0;
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DBG_DIAGNOSE
- if (pTxBlk->QueIdx== 0)
- {
- pAd->DiagStruct.TxDataCnt[pAd->DiagStruct.ArrayCurIdx]++;
- pAd->DiagStruct.TxMcsCnt[pAd->DiagStruct.ArrayCurIdx][pTxWI->MCS]++;
- }
-#endif // DBG_DIAGNOSE //
-
- pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculates the duration which is required to transmit out frames
- with given size and specified rate.
-
- Arguments:
- pTxD Pointer to transmit descriptor
- Ack Setting for Ack requirement bit
- Fragment Setting for Fragment bit
- RetryMode Setting for retry mode
- Ifs Setting for IFS gap
- Rate Setting for transmit rate
- Service Setting for service
- Length Frame length
- TxPreamble Short or Long preamble when using CCK rates
- QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPWriteTxDescriptor(
- IN PRTMP_ADAPTER pAd,
- IN PTXD_STRUC pTxD,
- IN BOOLEAN bWIV,
- IN UCHAR QueueSEL)
-{
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-
- pTxD->WIV = (bWIV) ? 1: 0;
- pTxD->QSEL= (QueueSEL);
- if (pAd->bGenOneHCCA == TRUE)
- pTxD->QSEL= FIFO_HCCA;
- pTxD->DMADONE = 0;
-}
-
-
-// should be called only when -
-// 1. MEADIA_CONNECTED
-// 2. AGGREGATION_IN_USED
-// 3. Fragmentation not in used
-// 4. either no previous frame (pPrevAddr1=NULL) .OR. previoud frame is aggregatible
-BOOLEAN TxFrameIsAggregatible(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pPrevAddr1,
- IN PUCHAR p8023hdr)
-{
-
- // can't aggregate EAPOL (802.1x) frame
- if ((p8023hdr[12] == 0x88) && (p8023hdr[13] == 0x8e))
- return FALSE;
-
- // can't aggregate multicast/broadcast frame
- if (p8023hdr[0] & 0x01)
- return FALSE;
-
- if (INFRA_ON(pAd)) // must be unicast to AP
- return TRUE;
- else if ((pPrevAddr1 == NULL) || MAC_ADDR_EQUAL(pPrevAddr1, p8023hdr)) // unicast to same STA
- return TRUE;
- else
- return FALSE;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check the MSDU Aggregation policy
- 1.HT aggregation is A-MSDU
- 2.legaacy rate aggregation is software aggregation by Ralink.
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN PeerIsAggreOn(
- IN PRTMP_ADAPTER pAd,
- IN ULONG TxRate,
- IN PMAC_TABLE_ENTRY pMacEntry)
-{
- ULONG AFlags = (fCLIENT_STATUS_AMSDU_INUSED | fCLIENT_STATUS_AGGREGATION_CAPABLE);
-
- if (pMacEntry != NULL && CLIENT_STATUS_TEST_FLAG(pMacEntry, AFlags))
- {
-#ifdef DOT11_N_SUPPORT
- if (pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
- {
- return TRUE;
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef AGGREGATION_SUPPORT
- if (TxRate >= RATE_6 && pAd->CommonCfg.bAggregationCapable && (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))))
- { // legacy Ralink Aggregation support
- return TRUE;
- }
-#endif // AGGREGATION_SUPPORT //
- }
-
- return FALSE;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check and fine the packet waiting in SW queue with highest priority
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- pQueue Pointer to Waiting Queue
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-PQUEUE_HEADER RTMPCheckTxSwQueue(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pQueIdx)
-{
-
- ULONG Number;
- // 2004-11-15 to be removed. test aggregation only
-// if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)) && (*pNumber < 2))
-// return NULL;
-
- Number = pAd->TxSwQueue[QID_AC_BK].Number
- + pAd->TxSwQueue[QID_AC_BE].Number
- + pAd->TxSwQueue[QID_AC_VI].Number
- + pAd->TxSwQueue[QID_AC_VO].Number
- + pAd->TxSwQueue[QID_HCCA].Number;
-
- if (pAd->TxSwQueue[QID_AC_VO].Head != NULL)
- {
- *pQueIdx = QID_AC_VO;
- return (&pAd->TxSwQueue[QID_AC_VO]);
- }
- else if (pAd->TxSwQueue[QID_AC_VI].Head != NULL)
- {
- *pQueIdx = QID_AC_VI;
- return (&pAd->TxSwQueue[QID_AC_VI]);
- }
- else if (pAd->TxSwQueue[QID_AC_BE].Head != NULL)
- {
- *pQueIdx = QID_AC_BE;
- return (&pAd->TxSwQueue[QID_AC_BE]);
- }
- else if (pAd->TxSwQueue[QID_AC_BK].Head != NULL)
- {
- *pQueIdx = QID_AC_BK;
- return (&pAd->TxSwQueue[QID_AC_BK]);
- }
- else if (pAd->TxSwQueue[QID_HCCA].Head != NULL)
- {
- *pQueIdx = QID_HCCA;
- return (&pAd->TxSwQueue[QID_HCCA]);
- }
-
- // No packet pending in Tx Sw queue
- *pQueIdx = QID_AC_BK;
-
- return (NULL);
-}
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- Suspend MSDU transmission
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPSuspendMsduTransmission(
- IN PRTMP_ADAPTER pAd)
-{
- DBGPRINT(RT_DEBUG_TRACE,("SCANNING, suspend MSDU transmission ...\n"));
-
-
- //
- // Before BSS_SCAN_IN_PROGRESS, we need to keep Current R66 value and
- // use Lowbound as R66 value on ScanNextChannel(...)
- //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
-
- // set BBP_R66 to 0x30/0x40 when scanning (AsicSwitchChannel will set R66 according to channel when scanning)
- //RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x26 + GET_LNA_GAIN(pAd)));
- RTMPSetAGCInitValue(pAd, BW_20);
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- //RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x000f0000); // abort all TX rings
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Resume MSDU transmission
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPResumeMsduTransmission(
- IN PRTMP_ADAPTER pAd)
-{
-// UCHAR IrqState;
-
- DBGPRINT(RT_DEBUG_TRACE,("SCAN done, resume MSDU transmission ...\n"));
-
-
- // After finish BSS_SCAN_IN_PROGRESS, we need to restore Current R66 value
- // R66 should not be 0
- if (pAd->BbpTuning.R66CurrentValue == 0)
- {
- pAd->BbpTuning.R66CurrentValue = 0x38;
- DBGPRINT_ERR(("RTMPResumeMsduTransmission, R66CurrentValue=0...\n"));
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, pAd->BbpTuning.R66CurrentValue);
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-// sample, for IRQ LOCK to SEM LOCK
-// IrqState = pAd->irq_disabled;
-// if (IrqState)
-// RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-// else
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-}
-
-
-UINT deaggregate_AMSDU_announce(
- IN PRTMP_ADAPTER pAd,
- PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize)
-{
- USHORT PayloadSize;
- USHORT SubFrameSize;
- PHEADER_802_3 pAMSDUsubheader;
- UINT nMSDU;
- UCHAR Header802_3[14];
-
- PUCHAR pPayload, pDA, pSA, pRemovedLLCSNAP;
- PNDIS_PACKET pClonePacket;
-
-
-
- nMSDU = 0;
-
- while (DataSize > LENGTH_802_3)
- {
-
- nMSDU++;
-
- //hex_dump("subheader", pData, 64);
- pAMSDUsubheader = (PHEADER_802_3)pData;
- //pData += LENGTH_802_3;
- PayloadSize = pAMSDUsubheader->Octet[1] + (pAMSDUsubheader->Octet[0]<<8);
- SubFrameSize = PayloadSize + LENGTH_802_3;
-
-
- if ((DataSize < SubFrameSize) || (PayloadSize > 1518 ))
- {
- break;
- }
-
- //printk("%d subframe: Size = %d\n", nMSDU, PayloadSize);
-
- pPayload = pData + LENGTH_802_3;
- pDA = pData;
- pSA = pData + MAC_ADDR_LEN;
-
- // convert to 802.3 header
- CONVERT_TO_802_3(Header802_3, pDA, pSA, pPayload, PayloadSize, pRemovedLLCSNAP);
-
-#ifdef CONFIG_STA_SUPPORT
- if ((Header802_3[12] == 0x88) && (Header802_3[13] == 0x8E) )
- {
- // avoid local heap overflow, use dyanamic allocation
- MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
- memmove(Elem->Msg+(LENGTH_802_11 + LENGTH_802_1_H), pPayload, PayloadSize);
- Elem->MsgLen = LENGTH_802_11 + LENGTH_802_1_H + PayloadSize;
- WpaEAPOLKeyAction(pAd, Elem);
- kfree(Elem);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pRemovedLLCSNAP)
- {
- pPayload -= LENGTH_802_3;
- PayloadSize += LENGTH_802_3;
- NdisMoveMemory(pPayload, &Header802_3[0], LENGTH_802_3);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pClonePacket = ClonePacket(pAd, pPacket, pPayload, PayloadSize);
- if (pClonePacket)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pClonePacket, RTMP_GET_PACKET_IF(pPacket));
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- // A-MSDU has padding to multiple of 4 including subframe header.
- // align SubFrameSize up to multiple of 4
- SubFrameSize = (SubFrameSize+3)&(~0x3);
-
-
- if (SubFrameSize > 1528 || SubFrameSize < 32)
- {
- break;
- }
-
- if (DataSize > SubFrameSize)
- {
- pData += SubFrameSize;
- DataSize -= SubFrameSize;
- }
- else
- {
- // end of A-MSDU
- DataSize = 0;
- }
- }
-
- // finally release original rx packet
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
-
- return nMSDU;
-}
-
-
-UINT BA_Reorder_AMSDU_Annnounce(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PUCHAR pData;
- USHORT DataSize;
- UINT nMSDU = 0;
-
- pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
- DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
-
- nMSDU = deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
-
- return nMSDU;
-}
-
-
-/*
- ==========================================================================
- Description:
- Look up the MAC address in the MAC table. Return NULL if not found.
- Return:
- pEntry - pointer to the MAC entry; NULL is not found
- ==========================================================================
-*/
-MAC_TABLE_ENTRY *MacTableLookup(
- IN PRTMP_ADAPTER pAd,
- PUCHAR pAddr)
-{
- ULONG HashIdx;
- MAC_TABLE_ENTRY *pEntry = NULL;
-
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- pEntry = pAd->MacTab.Hash[HashIdx];
-
- while (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsWDS || pEntry->ValidAsApCli || pEntry->ValidAsMesh))
- {
- if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
- break;
- }
- else
- pEntry = pEntry->pNext;
- }
-
- return pEntry;
-}
-
-MAC_TABLE_ENTRY *MacTableInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR apidx,
- IN BOOLEAN CleanAll)
-{
- UCHAR HashIdx;
- int i, FirstWcid;
- MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
-// USHORT offset;
-// ULONG addr;
-
- // if FULL, return
- if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
- return NULL;
-
- FirstWcid = 1;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- if (pAd->StaCfg.BssType == BSS_INFRA)
- FirstWcid = 2;
-#endif // CONFIG_STA_SUPPORT //
-
- // allocate one MAC entry
- NdisAcquireSpinLock(&pAd->MacTabLock);
- for (i = FirstWcid; i< MAX_LEN_OF_MAC_TABLE; i++) // skip entry#0 so that "entry index == AID" for fast lookup
- {
- // pick up the first available vacancy
- if ((pAd->MacTab.Content[i].ValidAsCLI == FALSE) &&
- (pAd->MacTab.Content[i].ValidAsWDS == FALSE) &&
- (pAd->MacTab.Content[i].ValidAsApCli== FALSE) &&
- (pAd->MacTab.Content[i].ValidAsMesh == FALSE)
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- && (pAd->MacTab.Content[i].ValidAsDls == FALSE)
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- )
- {
- pEntry = &pAd->MacTab.Content[i];
- if (CleanAll == TRUE)
- {
- pEntry->MaxSupportedRate = RATE_11;
- pEntry->CurrTxRate = RATE_11;
- NdisZeroMemory(pEntry, sizeof(MAC_TABLE_ENTRY));
- pEntry->PairwiseKey.KeyLen = 0;
- pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
- }
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (apidx >= MIN_NET_DEVICE_FOR_DLS)
- {
- pEntry->ValidAsCLI = FALSE;
- pEntry->ValidAsWDS = FALSE;
- pEntry->ValidAsApCli = FALSE;
- pEntry->ValidAsMesh = FALSE;
- pEntry->ValidAsDls = TRUE;
- pEntry->isCached = FALSE;
- }
- else
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pEntry->ValidAsCLI = TRUE;
- pEntry->ValidAsWDS = FALSE;
- pEntry->ValidAsApCli = FALSE;
- pEntry->ValidAsMesh = FALSE;
- pEntry->ValidAsDls = FALSE;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- pEntry->bIAmBadAtheros = FALSE;
- pEntry->pAd = pAd;
- pEntry->CMTimerRunning = FALSE;
- pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
- pEntry->RSNIE_Len = 0;
- NdisZeroMemory(pEntry->R_Counter, sizeof(pEntry->R_Counter));
- pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
-
- if (pEntry->ValidAsMesh)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_MESH);
- else if (pEntry->ValidAsApCli)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_APCLI);
- else if (pEntry->ValidAsWDS)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_WDS);
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- else if (pEntry->ValidAsDls)
- pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_DLS);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- else
- pEntry->apidx = apidx;
-
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
- pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- pEntry->GTKState = REKEY_NEGOTIATING;
- pEntry->PairwiseKey.KeyLen = 0;
- pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- if (pEntry->ValidAsDls == TRUE)
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
- else
-#endif //QOS_DLS_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND;
- COPY_MAC_ADDR(pEntry->Addr, pAddr);
- pEntry->Sst = SST_NOT_AUTH;
- pEntry->AuthState = AS_NOT_AUTH;
- pEntry->Aid = (USHORT)i; //0;
- pEntry->CapabilityInfo = 0;
- pEntry->PsMode = PWR_ACTIVE;
- pEntry->PsQIdleCount = 0;
- pEntry->NoDataIdleCount = 0;
- pEntry->ContinueTxFailCnt = 0;
- InitializeQueueHeader(&pEntry->PsQueue);
-
-
- pAd->MacTab.Size ++;
-
- // Add this entry into ASIC RX WCID search table
- RT28XX_STA_ENTRY_ADD(pAd, pEntry);
-
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertEntry - allocate entry #%d, Total= %d\n",i, pAd->MacTab.Size));
- break;
- }
- }
-
- // add this MAC entry into HASH table
- if (pEntry)
- {
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- if (pAd->MacTab.Hash[HashIdx] == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pAd->MacTab.Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
-
- NdisReleaseSpinLock(&pAd->MacTabLock);
- return pEntry;
-}
-
-/*
- ==========================================================================
- Description:
- Delete a specified client from MAC table
- ==========================================================================
- */
-BOOLEAN MacTableDeleteEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr)
-{
- USHORT HashIdx;
- MAC_TABLE_ENTRY *pEntry, *pPrevEntry, *pProbeEntry;
- BOOLEAN Cancelled;
- //USHORT offset; // unused variable
- //UCHAR j; // unused variable
-
- if (wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
-
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- //pEntry = pAd->MacTab.Hash[HashIdx];
- pEntry = &pAd->MacTab.Content[wcid];
-
- if (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsApCli || pEntry->ValidAsWDS || pEntry->ValidAsMesh
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- || pEntry->ValidAsDls
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- ))
- {
- if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
-
- // Delete this entry from ASIC on-chip WCID Table
- RT28XX_STA_ENTRY_MAC_RESET(pAd, wcid);
-
-#ifdef DOT11_N_SUPPORT
- // free resources of BA
- BASessionTearDownALL(pAd, pEntry->Aid);
-#endif // DOT11_N_SUPPORT //
-
-
- pPrevEntry = NULL;
- pProbeEntry = pAd->MacTab.Hash[HashIdx];
- ASSERT(pProbeEntry);
-
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- // not found !!!
- ASSERT(pProbeEntry != NULL);
-
- RT28XX_STA_ENTRY_KEY_DEL(pAd, BSS0, wcid);
-
-
- if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
- {
- RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
- pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
- }
-
-
- NdisZeroMemory(pEntry, sizeof(MAC_TABLE_ENTRY));
- pAd->MacTab.Size --;
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableDeleteEntry1 - Total= %d\n", pAd->MacTab.Size));
- }
- else
- {
- printk("\n%s: Impossible Wcid = %d !!!!!\n", __FUNCTION__, wcid);
- }
- }
-
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- //Reset operating mode when no Sta.
- if (pAd->MacTab.Size == 0)
- {
-#ifdef DOT11_N_SUPPORT
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode = 0;
-#endif // DOT11_N_SUPPORT //
- //AsicUpdateProtect(pAd, 0 /*pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode*/, (ALLN_SETPROTECT), TRUE, 0 /*pAd->MacTab.fAnyStationNonGF*/);
- RT28XX_UPDATE_PROTECT(pAd); // edit by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
- }
-
- return TRUE;
-}
-
-
-/*
- ==========================================================================
- Description:
- This routine reset the entire MAC table. All packets pending in
- the power-saving queues are freed here.
- ==========================================================================
- */
-VOID MacTableReset(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableReset\n"));
- //NdisAcquireSpinLock(&pAd->MacTabLock);
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
- {
-
-#ifdef DOT11_N_SUPPORT
- // free resources of BA
- BASessionTearDownALL(pAd, i);
-#endif // DOT11_N_SUPPORT //
-
- pAd->MacTab.Content[i].ValidAsCLI = FALSE;
-
-
-
-#ifdef RT2870
- NdisZeroMemory(pAd->MacTab.Content[i].Addr, 6);
- RT28XX_STA_ENTRY_MAC_RESET(pAd, i);
-#endif // RT2870 //
-
- //AsicDelWcidTab(pAd, i);
- }
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID AssocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
- IN PUCHAR pAddr,
- IN USHORT CapabilityInfo,
- IN ULONG Timeout,
- IN USHORT ListenIntv)
-{
- COPY_MAC_ADDR(AssocReq->Addr, pAddr);
- // Add mask to support 802.11b mode only
- AssocReq->CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO; // not cf-pollable, not cf-poll-request
- AssocReq->Timeout = Timeout;
- AssocReq->ListenIntv = ListenIntv;
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID DisassocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
- IN PUCHAR pAddr,
- IN USHORT Reason)
-{
- COPY_MAC_ADDR(DisassocReq->Addr, pAddr);
- DisassocReq->Reason = Reason;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check the out going frame, if this is an DHCP or ARP datagram
- will be duplicate another frame at low data rate transmit.
-
- Arguments:
- pAd Pointer to our adapter
- pPacket Pointer to outgoing Ndis frame
-
- Return Value:
- TRUE To be duplicate at Low data rate transmit. (1mb)
- FALSE Do nothing.
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- MAC header + IP Header + UDP Header
- 14 Bytes 20 Bytes
-
- UDP Header
- 00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|
- Source Port
- 16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
- Destination Port
-
- port 0x43 means Bootstrap Protocol, server.
- Port 0x44 means Bootstrap Protocol, client.
-
- ========================================================================
-*/
-
-BOOLEAN RTMPCheckDHCPFrame(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- ULONG NumberOfBytesRead = 0;
- ULONG CurrentOffset = 0;
- PVOID pVirtualAddress = NULL;
- UINT NdisBufferLength;
- PUCHAR pSrc;
- USHORT Protocol;
- UCHAR ByteOffset36 = 0;
- UCHAR ByteOffset38 = 0;
- BOOLEAN ReadFirstParm = TRUE;
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, (PUCHAR *)&pVirtualAddress, &NdisBufferLength);
-
- NumberOfBytesRead += NdisBufferLength;
- pSrc = (PUCHAR) pVirtualAddress;
- Protocol = *(pSrc + 12) * 256 + *(pSrc + 13);
-
- //
- // Check DHCP & BOOTP protocol
- //
- while (NumberOfBytesRead <= PacketInfo.TotalPacketLength)
- {
- if ((NumberOfBytesRead >= 35) && (ReadFirstParm == TRUE))
- {
- CurrentOffset = 35 - (NumberOfBytesRead - NdisBufferLength);
- ByteOffset36 = *(pSrc + CurrentOffset);
- ReadFirstParm = FALSE;
- }
-
- if (NumberOfBytesRead >= 37)
- {
- CurrentOffset = 37 - (NumberOfBytesRead - NdisBufferLength);
- ByteOffset38 = *(pSrc + CurrentOffset);
- //End of Read
- break;
- }
- return FALSE;
- }
-
- // Check for DHCP & BOOTP protocol
- if ((ByteOffset36 != 0x44) || (ByteOffset38 != 0x43))
- {
- //
- // 2054 (hex 0806) for ARP datagrams
- // if this packet is not ARP datagrams, then do nothing
- // ARP datagrams will also be duplicate at 1mb broadcast frames
- //
- if (Protocol != 0x0806 )
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-BOOLEAN RTMPCheckEtherType(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- USHORT TypeLen;
- UCHAR Byte0, Byte1;
- PUCHAR pSrcBuf;
- UINT32 pktLen;
- UINT16 srcPort, dstPort;
- BOOLEAN status = TRUE;
-
-
- pSrcBuf = GET_OS_PKT_DATAPTR(pPacket);
- pktLen = GET_OS_PKT_LEN(pPacket);
-
- ASSERT(pSrcBuf);
-
- RTMP_SET_PACKET_SPECIFIC(pPacket, 0);
-
- // get Ethernet protocol field
- TypeLen = (pSrcBuf[12] << 8) + pSrcBuf[13];
-
- pSrcBuf += LENGTH_802_3; // Skip the Ethernet Header.
-
- if (TypeLen <= 1500)
- { // 802.3, 802.3 LLC
- /*
- DestMAC(6) + SrcMAC(6) + Lenght(2) +
- DSAP(1) + SSAP(1) + Control(1) +
- if the DSAP = 0xAA, SSAP=0xAA, Contorl = 0x03, it has a 5-bytes SNAP header.
- => + SNAP (5, OriginationID(3) + etherType(2))
- */
- if (pSrcBuf[0] == 0xAA && pSrcBuf[1] == 0xAA && pSrcBuf[2] == 0x03)
- {
- Sniff2BytesFromNdisBuffer(pSrcBuf, 6, &Byte0, &Byte1);
- RTMP_SET_PACKET_LLCSNAP(pPacket, 1);
- TypeLen = (USHORT)((Byte0 << 8) + Byte1);
- pSrcBuf += 8; // Skip this LLC/SNAP header
- }
- else
- {
- //It just has 3-byte LLC header, maybe a legacy ether type frame. we didn't handle it.
- }
- }
-
- // If it's a VLAN packet, get the real Type/Length field.
- if (TypeLen == 0x8100)
- {
- /* 0x8100 means VLAN packets */
-
- /* Dest. MAC Address (6-bytes) +
- Source MAC Address (6-bytes) +
- Length/Type = 802.1Q Tag Type (2-byte) +
- Tag Control Information (2-bytes) +
- Length / Type (2-bytes) +
- data payload (0-n bytes) +
- Pad (0-p bytes) +
- Frame Check Sequence (4-bytes) */
-
- RTMP_SET_PACKET_VLAN(pPacket, 1);
- Sniff2BytesFromNdisBuffer(pSrcBuf, 2, &Byte0, &Byte1);
- TypeLen = (USHORT)((Byte0 << 8) + Byte1);
-
- pSrcBuf += 4; // Skip the VLAN Header.
- }
-
- switch (TypeLen)
- {
- case 0x0800:
- {
- ASSERT((pktLen > 34));
- if (*(pSrcBuf + 9) == 0x11)
- { // udp packet
- ASSERT((pktLen > 34)); // 14 for ethernet header, 20 for IP header
-
- pSrcBuf += 20; // Skip the IP header
- srcPort = OS_NTOHS(*((UINT16 *)pSrcBuf));
- dstPort = OS_NTOHS(*((UINT16 *)(pSrcBuf +2)));
-
- if ((srcPort==0x44 && dstPort==0x43) || (srcPort==0x43 && dstPort==0x44))
- { //It's a BOOTP/DHCP packet
- RTMP_SET_PACKET_DHCP(pPacket, 1);
- }
- }
- }
- break;
- case 0x0806:
- {
- //ARP Packet.
- RTMP_SET_PACKET_DHCP(pPacket, 1);
- }
- break;
- case 0x888e:
- {
- // EAPOL Packet.
- RTMP_SET_PACKET_EAPOL(pPacket, 1);
- }
- break;
- default:
- status = FALSE;
- break;
- }
-
- return status;
-
-}
-
-
-
-VOID Update_Rssi_Sample(
- IN PRTMP_ADAPTER pAd,
- IN RSSI_SAMPLE *pRssi,
- IN PRXWI_STRUC pRxWI)
- {
- CHAR rssi0 = pRxWI->RSSI0;
- CHAR rssi1 = pRxWI->RSSI1;
- CHAR rssi2 = pRxWI->RSSI2;
-
- if (rssi0 != 0)
- {
- pRssi->LastRssi0 = ConvertToRssi(pAd, (CHAR)rssi0, RSSI_0);
- pRssi->AvgRssi0X8 = (pRssi->AvgRssi0X8 - pRssi->AvgRssi0) + pRssi->LastRssi0;
- pRssi->AvgRssi0 = pRssi->AvgRssi0X8 >> 3;
- }
-
- if (rssi1 != 0)
- {
- pRssi->LastRssi1 = ConvertToRssi(pAd, (CHAR)rssi1, RSSI_1);
- pRssi->AvgRssi1X8 = (pRssi->AvgRssi1X8 - pRssi->AvgRssi1) + pRssi->LastRssi1;
- pRssi->AvgRssi1 = pRssi->AvgRssi1X8 >> 3;
- }
-
- if (rssi2 != 0)
- {
- pRssi->LastRssi2 = ConvertToRssi(pAd, (CHAR)rssi2, RSSI_2);
- pRssi->AvgRssi2X8 = (pRssi->AvgRssi2X8 - pRssi->AvgRssi2) + pRssi->LastRssi2;
- pRssi->AvgRssi2 = pRssi->AvgRssi2X8 >> 3;
- }
-}
-
-
-
-// Normal legacy Rx packet indication
-VOID Indicate_Legacy_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- UCHAR Header802_3[LENGTH_802_3];
-
- // 1. get 802.3 Header
- // 2. remove LLC
- // a. pointer pRxBlk->pData to payload
- // b. modify pRxBlk->DataSize
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
- if (pRxBlk->DataSize > MAX_RX_PKT_LEN)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
-
- STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
-
-#ifdef RT2870
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.bDisableReordering == 0)
- {
- PBA_REC_ENTRY pBAEntry;
- ULONG Now32;
- UCHAR Wcid = pRxBlk->pRxWI->WirelessCliID;
- UCHAR TID = pRxBlk->pRxWI->TID;
- USHORT Idx;
-
-#define REORDERING_PACKET_TIMEOUT ((100 * HZ)/1000) // system ticks -- 100 ms
-
- if (Wcid < MAX_LEN_OF_MAC_TABLE)
- {
- Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
- if (Idx != 0)
- {
- pBAEntry = &pAd->BATable.BARecEntry[Idx];
- // update last rx time
- NdisGetSystemUpTime(&Now32);
- if ((pBAEntry->list.qlen > 0) &&
- RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(REORDERING_PACKET_TIMEOUT)))
- )
- {
- printk("Indicate_Legacy_Packet():flush reordering_timeout_mpdus! RxWI->Flags=%d, pRxWI.TID=%d, RxD->AMPDU=%d!\n", pRxBlk->Flags, pRxBlk->pRxWI->TID, pRxBlk->RxD.AMPDU);
- hex_dump("Dump the legacy Packet:", GET_OS_PKT_DATAPTR(pRxBlk->pRxPacket), 64);
- ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32);
- }
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-#endif // RT2870 //
-
- wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-
- //
- // pass this 802.3 packet to upper layer or forward this packet to WM directly
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxPacket, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-
-// Normal, AMPDU or AMSDU
-VOID CmmRxnonRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
-#ifdef DOT11_N_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
- {
- Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
-#ifdef DOT11_N_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
- {
- // handle A-MSDU
- Indicate_AMSDU_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- }
-}
-
-
-VOID CmmRxRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- UCHAR Header802_3[LENGTH_802_3];
- UINT16 Msdu2Size;
- UINT16 Payload1Size, Payload2Size;
- PUCHAR pData2;
- PNDIS_PACKET pPacket2 = NULL;
-
-
-
- Msdu2Size = *(pRxBlk->pData) + (*(pRxBlk->pData+1) << 8);
-
- if ((Msdu2Size <= 1536) && (Msdu2Size < pRxBlk->DataSize))
- {
- /* skip two byte MSDU2 len */
- pRxBlk->pData += 2;
- pRxBlk->DataSize -= 2;
- }
- else
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // get 802.3 Header and remove LLC
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-#endif // CONFIG_STA_SUPPORT //
-
-
- ASSERT(pRxBlk->pRxPacket);
-
- // Ralink Aggregation frame
- pAd->RalinkCounters.OneSecRxAggregationCount ++;
- Payload1Size = pRxBlk->DataSize - Msdu2Size;
- Payload2Size = Msdu2Size - LENGTH_802_3;
-
- pData2 = pRxBlk->pData + Payload1Size + LENGTH_802_3;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pPacket2 = duplicate_pkt(pAd, (pData2-LENGTH_802_3), LENGTH_802_3, pData2, Payload2Size, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
- if (!pPacket2)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // update payload size of 1st packet
- pRxBlk->DataSize = Payload1Size;
- wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxBlk->pRxPacket, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
-
- if (pPacket2)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket2, FromWhichBSSID);
-#endif // CONFIG_STA_SUPPORT //
- }
-}
-
-
-#define RESET_FRAGFRAME(_fragFrame) \
- { \
- _fragFrame.RxSize = 0; \
- _fragFrame.Sequence = 0; \
- _fragFrame.LastFrag = 0; \
- _fragFrame.Flags = 0; \
- }
-
-
-PNDIS_PACKET RTMPDeFragmentDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- UCHAR *pData = pRxBlk->pData;
- USHORT DataSize = pRxBlk->DataSize;
- PNDIS_PACKET pRetPacket = NULL;
- UCHAR *pFragBuffer = NULL;
- BOOLEAN bReassDone = FALSE;
- UCHAR HeaderRoom = 0;
-
-
- ASSERT(pHeader);
-
- HeaderRoom = pData - (UCHAR *)pHeader;
-
- // Re-assemble the fragmented packets
- if (pHeader->Frag == 0) // Frag. Number is 0 : First frag or only one pkt
- {
- // the first pkt of fragment, record it.
- if (pHeader->FC.MoreFrag)
- {
- ASSERT(pAd->FragFrame.pFragPacket);
- pFragBuffer = GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
- pAd->FragFrame.RxSize = DataSize + HeaderRoom;
- NdisMoveMemory(pFragBuffer, pHeader, pAd->FragFrame.RxSize);
- pAd->FragFrame.Sequence = pHeader->Sequence;
- pAd->FragFrame.LastFrag = pHeader->Frag; // Should be 0
- ASSERT(pAd->FragFrame.LastFrag == 0);
- goto done; // end of processing this frame
- }
- }
- else //Middle & End of fragment
- {
- if ((pHeader->Sequence != pAd->FragFrame.Sequence) ||
- (pHeader->Frag != (pAd->FragFrame.LastFrag + 1)))
- {
- // Fragment is not the same sequence or out of fragment number order
- // Reset Fragment control blk
- RESET_FRAGFRAME(pAd->FragFrame);
- DBGPRINT(RT_DEBUG_ERROR, ("Fragment is not the same sequence or out of fragment number order.\n"));
- goto done; // give up this frame
- }
- else if ((pAd->FragFrame.RxSize + DataSize) > MAX_FRAME_SIZE)
- {
- // Fragment frame is too large, it exeeds the maximum frame size.
- // Reset Fragment control blk
- RESET_FRAGFRAME(pAd->FragFrame);
- DBGPRINT(RT_DEBUG_ERROR, ("Fragment frame is too large, it exeeds the maximum frame size.\n"));
- goto done; // give up this frame
- }
-
- //
- // Broadcom AP(BCM94704AGR) will send out LLC in fragment's packet, LLC only can accpet at first fragment.
- // In this case, we will dropt it.
- //
- if (NdisEqualMemory(pData, SNAP_802_1H, sizeof(SNAP_802_1H)))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Find another LLC at Middle or End fragment(SN=%d, Frag=%d)\n", pHeader->Sequence, pHeader->Frag));
- goto done; // give up this frame
- }
-
- pFragBuffer = GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
-
- // concatenate this fragment into the re-assembly buffer
- NdisMoveMemory((pFragBuffer + pAd->FragFrame.RxSize), pData, DataSize);
- pAd->FragFrame.RxSize += DataSize;
- pAd->FragFrame.LastFrag = pHeader->Frag; // Update fragment number
-
- // Last fragment
- if (pHeader->FC.MoreFrag == FALSE)
- {
- bReassDone = TRUE;
- }
- }
-
-done:
- // always release rx fragmented packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-
- // return defragmented packet if packet is reassembled completely
- // otherwise return NULL
- if (bReassDone)
- {
- PNDIS_PACKET pNewFragPacket;
-
- // allocate a new packet buffer for fragment
- pNewFragPacket = RTMP_AllocateFragPacketBuffer(pAd, RX_BUFFER_NORMSIZE);
- if (pNewFragPacket)
- {
- // update RxBlk
- pRetPacket = pAd->FragFrame.pFragPacket;
- pAd->FragFrame.pFragPacket = pNewFragPacket;
- pRxBlk->pHeader = (PHEADER_802_11) GET_OS_PKT_DATAPTR(pRetPacket);
- pRxBlk->pData = (UCHAR *)pRxBlk->pHeader + HeaderRoom;
- pRxBlk->DataSize = pAd->FragFrame.RxSize - HeaderRoom;
- pRxBlk->pRxPacket = pRetPacket;
- }
- else
- {
- RESET_FRAGFRAME(pAd->FragFrame);
- }
- }
-
- return pRetPacket;
-}
-
-
-VOID Indicate_AMSDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- UINT nMSDU;
-
- update_os_packet_info(pAd, pRxBlk, FromWhichBSSID);
- RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
- nMSDU = deaggregate_AMSDU_announce(pAd, pRxBlk->pRxPacket, pRxBlk->pData, pRxBlk->DataSize);
-}
-
-VOID Indicate_EAPOL_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- MAC_TABLE_ENTRY *pEntry = NULL;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (pEntry == NULL)
- {
- DBGPRINT(RT_DEBUG_WARN, ("Indicate_EAPOL_Packet: drop and release the invalid packet.\n"));
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-}
-
-#define BCN_TBTT_OFFSET 64 //defer 64 us
-VOID ReSyncBeaconTime(
- IN PRTMP_ADAPTER pAd)
-{
-
- UINT32 Offset;
-
-
- Offset = (pAd->TbttTickCount) % (BCN_TBTT_OFFSET);
-
- pAd->TbttTickCount++;
-
- //
- // The updated BeaconInterval Value will affect Beacon Interval after two TBTT
- // beacasue the original BeaconInterval had been loaded into next TBTT_TIMER
- //
- if (Offset == (BCN_TBTT_OFFSET-2))
- {
- BCN_TIME_CFG_STRUC csr;
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
- csr.field.BeaconInterval = (pAd->CommonCfg.BeaconPeriod << 4) - 1 ; // ASIC register in units of 1/16 TU = 64us
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
- }
- else
- {
- if (Offset == (BCN_TBTT_OFFSET-1))
- {
- BCN_TIME_CFG_STRUC csr;
-
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
- csr.field.BeaconInterval = (pAd->CommonCfg.BeaconPeriod) << 4; // ASIC register in units of 1/16 TU
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
- }
- }
-}
-
+#include "../../rt2870/common/cmm_data.c"
diff --git a/drivers/staging/rt3070/common/cmm_data_2870.c b/drivers/staging/rt3070/common/cmm_data_2870.c
index b1066aa2bb23..0e51ee414a2c 100644
--- a/drivers/staging/rt3070/common/cmm_data_2870.c
+++ b/drivers/staging/rt3070/common/cmm_data_2870.c
@@ -1,980 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-*/
-/*
- All functions in this file must be USB-depended, or you should out your function
- in other files.
-
-*/
-#include "../rt_config.h"
-
-
-/*
- We can do copy the frame into pTxContext when match following conditions.
- =>
- =>
- =>
-*/
-static inline NDIS_STATUS RtmpUSBCanDoWrite(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN HT_TX_CONTEXT *pHTTXContext)
-{
- NDIS_STATUS canWrite = NDIS_STATUS_RESOURCES;
-
- if (((pHTTXContext->CurWritePosition) < pHTTXContext->NextBulkOutPosition) && (pHTTXContext->CurWritePosition + LOCAL_TXBUF_SIZE) > pHTTXContext->NextBulkOutPosition)
- {
- DBGPRINT(RT_DEBUG_ERROR,("RtmpUSBCanDoWrite c1!\n"));
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
- }
- else if ((pHTTXContext->CurWritePosition == 8) && (pHTTXContext->NextBulkOutPosition < LOCAL_TXBUF_SIZE))
- {
- DBGPRINT(RT_DEBUG_ERROR,("RtmpUSBCanDoWrite c2!\n"));
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
- }
- else if (pHTTXContext->bCurWriting == TRUE)
- {
- DBGPRINT(RT_DEBUG_ERROR,("RtmpUSBCanDoWrite c3!\n"));
- }
- else
- {
- canWrite = NDIS_STATUS_SUCCESS;
- }
-
-
- return canWrite;
-}
-
-
-USHORT RtmpUSB_WriteSubTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN BOOLEAN bIsLast,
- OUT USHORT *FreeNumber)
-{
-
- // Dummy function. Should be removed in the future.
- return 0;
-
-}
-
-USHORT RtmpUSB_WriteFragTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR fragNum,
- OUT USHORT *FreeNumber)
-{
- HT_TX_CONTEXT *pHTTXContext;
- USHORT hwHdrLen; // The hwHdrLen consist of 802.11 header length plus the header padding length.
- UINT32 fillOffset;
- TXINFO_STRUC *pTxInfo;
- TXWI_STRUC *pTxWI;
- PUCHAR pWirelessPacket = NULL;
- UCHAR QueIdx;
- NDIS_STATUS Status;
- unsigned long IrqFlags;
- UINT32 USBDMApktLen = 0, DMAHdrLen, padding;
- BOOLEAN TxQLastRound = FALSE;
-
- //
- // get Tx Ring Resource & Dma Buffer address
- //
- QueIdx = pTxBlk->QueIdx;
- pHTTXContext = &pAd->TxContext[QueIdx];
-
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- pHTTXContext = &pAd->TxContext[QueIdx];
- fillOffset = pHTTXContext->CurWritePosition;
-
- if(fragNum == 0)
- {
- // Check if we have enough space for this bulk-out batch.
- Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
- if (Status == NDIS_STATUS_SUCCESS)
- {
- pHTTXContext->bCurWriting = TRUE;
-
- // Reserve space for 8 bytes padding.
- if ((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition))
- {
- pHTTXContext->ENextBulkOutPosition += 8;
- pHTTXContext->CurWritePosition += 8;
- fillOffset += 8;
- }
- pTxBlk->Priv = 0;
- pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return(Status);
- }
- }
- else
- {
- // For sub-sequent frames of this bulk-out batch. Just copy it to our bulk-out buffer.
- Status = ((pHTTXContext->bCurWriting == TRUE) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE);
- if (Status == NDIS_STATUS_SUCCESS)
- {
- fillOffset += pTxBlk->Priv;
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return(Status);
- }
- }
-
- NdisZeroMemory((PUCHAR)(&pTxBlk->HeaderBuf[0]), TXINFO_SIZE);
- pTxInfo = (PTXINFO_STRUC)(&pTxBlk->HeaderBuf[0]);
- pTxWI= (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]);
-
- pWirelessPacket = &pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset];
-
- // copy TXWI + WLAN Header + LLC into DMA Header Buffer
- //hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4);
- hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
- // Build our URB for USBD
- DMAHdrLen = TXWI_SIZE + hwHdrLen;
- USBDMApktLen = DMAHdrLen + pTxBlk->SrcBufLen;
- padding = (4 - (USBDMApktLen % 4)) & 0x03; // round up to 4 byte alignment
- USBDMApktLen += padding;
-
- pTxBlk->Priv += (TXINFO_SIZE + USBDMApktLen);
-
- // For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(USBDMApktLen), FALSE, FIFO_EDCA, FALSE /*NextValid*/, FALSE);
-
- if (fragNum == pTxBlk->TotalFragNum)
- {
- pTxInfo->USBDMATxburst = 0;
- if ((pHTTXContext->CurWritePosition + pTxBlk->Priv + 3906)> MAX_TXBULK_LIMIT)
- {
- pTxInfo->SwUseLastRound = 1;
- TxQLastRound = TRUE;
- }
- }
- else
- {
- pTxInfo->USBDMATxburst = 1;
- }
-
- NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)(pWirelessPacket + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
- pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
- pHTTXContext->CurWriteRealPos += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
-
- // Zero the last padding.
- pWirelessPacket += pTxBlk->SrcBufLen;
- NdisZeroMemory(pWirelessPacket, padding + 8);
-
- if (fragNum == pTxBlk->TotalFragNum)
- {
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- // Update the pHTTXContext->CurWritePosition. 3906 used to prevent the NextBulkOut is a A-RALINK/A-MSDU Frame.
- pHTTXContext->CurWritePosition += pTxBlk->Priv;
- if (TxQLastRound == TRUE)
- pHTTXContext->CurWritePosition = 8;
- pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
-
- // Finally, set bCurWriting as FALSE
- pHTTXContext->bCurWriting = FALSE;
-
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- // succeed and release the skb buffer
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
- }
-
-
- return(Status);
-
-}
-
-
-USHORT RtmpUSB_WriteSingleTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN BOOLEAN bIsLast,
- OUT USHORT *FreeNumber)
-{
- HT_TX_CONTEXT *pHTTXContext;
- USHORT hwHdrLen;
- UINT32 fillOffset;
- TXINFO_STRUC *pTxInfo;
- TXWI_STRUC *pTxWI;
- PUCHAR pWirelessPacket;
- UCHAR QueIdx;
- unsigned long IrqFlags;
- NDIS_STATUS Status;
- UINT32 USBDMApktLen = 0, DMAHdrLen, padding;
- BOOLEAN bTxQLastRound = FALSE;
-
- // For USB, didn't need PCI_MAP_SINGLE()
- //SrcBufPA = PCI_MAP_SINGLE(pAd, (char *) pTxBlk->pSrcBufData, pTxBlk->SrcBufLen, PCI_DMA_TODEVICE);
-
-
- //
- // get Tx Ring Resource & Dma Buffer address
- //
- QueIdx = pTxBlk->QueIdx;
-
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
- pHTTXContext = &pAd->TxContext[QueIdx];
- fillOffset = pHTTXContext->CurWritePosition;
-
-
-
- // Check ring full.
- Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
- if(Status == NDIS_STATUS_SUCCESS)
- {
- pHTTXContext->bCurWriting = TRUE;
-
- pTxInfo = (PTXINFO_STRUC)(&pTxBlk->HeaderBuf[0]);
- pTxWI= (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]);
-
- // Reserve space for 8 bytes padding.
- if ((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition))
- {
- pHTTXContext->ENextBulkOutPosition += 8;
- pHTTXContext->CurWritePosition += 8;
- fillOffset += 8;
- }
- pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
- pWirelessPacket = &pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset];
-
- // copy TXWI + WLAN Header + LLC into DMA Header Buffer
- //hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4);
- hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
- // Build our URB for USBD
- DMAHdrLen = TXWI_SIZE + hwHdrLen;
- USBDMApktLen = DMAHdrLen + pTxBlk->SrcBufLen;
- padding = (4 - (USBDMApktLen % 4)) & 0x03; // round up to 4 byte alignment
- USBDMApktLen += padding;
-
- pTxBlk->Priv = (TXINFO_SIZE + USBDMApktLen);
-
- // For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload
- //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(USBDMApktLen), FALSE, FIFO_EDCA, FALSE /*NextValid*/, FALSE);
-#endif // CONFIG_STA_SUPPORT //
-
- if ((pHTTXContext->CurWritePosition + 3906 + pTxBlk->Priv) > MAX_TXBULK_LIMIT)
- {
- pTxInfo->SwUseLastRound = 1;
- bTxQLastRound = TRUE;
- }
- NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)(pWirelessPacket + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
- pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-
- // We unlock it here to prevent the first 8 bytes maybe over-writed issue.
- // 1. First we got CurWritePosition but the first 8 bytes still not write to the pTxcontext.
- // 2. An interrupt break our routine and handle bulk-out complete.
- // 3. In the bulk-out compllete, it need to do another bulk-out,
- // if the ENextBulkOutPosition is just the same as CurWritePosition, it will save the first 8 bytes from CurWritePosition,
- // but the payload still not copyed. the pTxContext->SavedPad[] will save as allzero. and set the bCopyPad = TRUE.
- // 4. Interrupt complete.
- // 5. Our interrupted routine go back and fill the first 8 bytes to pTxContext.
- // 6. Next time when do bulk-out, it found the bCopyPad==TRUE and will copy the SavedPad[] to pTxContext->NextBulkOutPosition.
- // and the packet will wrong.
- pHTTXContext->CurWriteRealPos += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
- pWirelessPacket += pTxBlk->SrcBufLen;
- NdisZeroMemory(pWirelessPacket, padding + 8);
-
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- pHTTXContext->CurWritePosition += pTxBlk->Priv;
- if (bTxQLastRound)
- pHTTXContext->CurWritePosition = 8;
- pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
- pHTTXContext->bCurWriting = FALSE;
- }
-
-
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-
- // succeed and release the skb buffer
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
-
- return(Status);
-
-}
-
-
-USHORT RtmpUSB_WriteMultiTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR frameNum,
- OUT USHORT *FreeNumber)
-{
- HT_TX_CONTEXT *pHTTXContext;
- USHORT hwHdrLen; // The hwHdrLen consist of 802.11 header length plus the header padding length.
- UINT32 fillOffset;
- TXINFO_STRUC *pTxInfo;
- TXWI_STRUC *pTxWI;
- PUCHAR pWirelessPacket = NULL;
- UCHAR QueIdx;
- NDIS_STATUS Status;
- unsigned long IrqFlags;
- //UINT32 USBDMApktLen = 0, DMAHdrLen, padding;
-
- //
- // get Tx Ring Resource & Dma Buffer address
- //
- QueIdx = pTxBlk->QueIdx;
- pHTTXContext = &pAd->TxContext[QueIdx];
-
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- if(frameNum == 0)
- {
- // Check if we have enough space for this bulk-out batch.
- Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
- if (Status == NDIS_STATUS_SUCCESS)
- {
- pHTTXContext->bCurWriting = TRUE;
-
- pTxInfo = (PTXINFO_STRUC)(&pTxBlk->HeaderBuf[0]);
- pTxWI= (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]);
-
-
- // Reserve space for 8 bytes padding.
- if ((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition))
- {
-
- pHTTXContext->CurWritePosition += 8;
- pHTTXContext->ENextBulkOutPosition += 8;
- }
- fillOffset = pHTTXContext->CurWritePosition;
- pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
- pWirelessPacket = &pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset];
-
- //
- // Copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer
- //
- if (pTxBlk->TxFrameType == TX_AMSDU_FRAME)
- //hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD;
- hwHdrLen = pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD + pTxBlk->HdrPadLen + LENGTH_AMSDU_SUBFRAMEHEAD;
- else if (pTxBlk->TxFrameType == TX_RALINK_FRAME)
- //hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_ARALINK_HEADER_FIELD, 4)+LENGTH_ARALINK_HEADER_FIELD;
- hwHdrLen = pTxBlk->MpduHeaderLen-LENGTH_ARALINK_HEADER_FIELD + pTxBlk->HdrPadLen + LENGTH_ARALINK_HEADER_FIELD;
- else
- //hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4);
- hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
- // Update the pTxBlk->Priv.
- pTxBlk->Priv = TXINFO_SIZE + TXWI_SIZE + hwHdrLen;
-
- // pTxInfo->USBDMApktLen now just a temp value and will to correct latter.
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(pTxBlk->Priv), FALSE, FIFO_EDCA, FALSE /*NextValid*/, FALSE);
-
- // Copy it.
- NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, pTxBlk->Priv);
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)(pWirelessPacket+ TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
- pHTTXContext->CurWriteRealPos += pTxBlk->Priv;
- pWirelessPacket += pTxBlk->Priv;
- }
- }
- else
- { // For sub-sequent frames of this bulk-out batch. Just copy it to our bulk-out buffer.
-
- Status = ((pHTTXContext->bCurWriting == TRUE) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE);
- if (Status == NDIS_STATUS_SUCCESS)
- {
- fillOffset = (pHTTXContext->CurWritePosition + pTxBlk->Priv);
- pWirelessPacket = &pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset];
-
- //hwHdrLen = pTxBlk->MpduHeaderLen;
- NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf, pTxBlk->MpduHeaderLen);
- pWirelessPacket += (pTxBlk->MpduHeaderLen);
- pTxBlk->Priv += pTxBlk->MpduHeaderLen;
- }
- else
- { // It should not happened now unless we are going to shutdown.
- DBGPRINT(RT_DEBUG_ERROR, ("WriteMultiTxResource():bCurWriting is FALSE when handle sub-sequent frames.\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- }
-
-
- // We unlock it here to prevent the first 8 bytes maybe over-write issue.
- // 1. First we got CurWritePosition but the first 8 bytes still not write to the pTxContext.
- // 2. An interrupt break our routine and handle bulk-out complete.
- // 3. In the bulk-out compllete, it need to do another bulk-out,
- // if the ENextBulkOutPosition is just the same as CurWritePosition, it will save the first 8 bytes from CurWritePosition,
- // but the payload still not copyed. the pTxContext->SavedPad[] will save as allzero. and set the bCopyPad = TRUE.
- // 4. Interrupt complete.
- // 5. Our interrupted routine go back and fill the first 8 bytes to pTxContext.
- // 6. Next time when do bulk-out, it found the bCopyPad==TRUE and will copy the SavedPad[] to pTxContext->NextBulkOutPosition.
- // and the packet will wrong.
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("WriteMultiTxResource: CWPos = %ld, NBOutPos = %ld.\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition));
- goto done;
- }
-
- // Copy the frame content into DMA buffer and update the pTxBlk->Priv
- NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
- pWirelessPacket += pTxBlk->SrcBufLen;
- pTxBlk->Priv += pTxBlk->SrcBufLen;
-
-done:
- // Release the skb buffer here
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
-
- return(Status);
-
-}
-
-
-VOID RtmpUSB_FinalWriteTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN USHORT totalMPDUSize,
- IN USHORT TxIdx)
-{
- UCHAR QueIdx;
- HT_TX_CONTEXT *pHTTXContext;
- UINT32 fillOffset;
- TXINFO_STRUC *pTxInfo;
- TXWI_STRUC *pTxWI;
- UINT32 USBDMApktLen, padding;
- unsigned long IrqFlags;
- PUCHAR pWirelessPacket;
-
- QueIdx = pTxBlk->QueIdx;
- pHTTXContext = &pAd->TxContext[QueIdx];
-
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
- if (pHTTXContext->bCurWriting == TRUE)
- {
- fillOffset = pHTTXContext->CurWritePosition;
- if (((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition) || ((pHTTXContext->ENextBulkOutPosition-8) == pHTTXContext->CurWritePosition))
- && (pHTTXContext->bCopySavePad == TRUE))
- pWirelessPacket = (PUCHAR)(&pHTTXContext->SavedPad[0]);
- else
- pWirelessPacket = (PUCHAR)(&pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset]);
-
- //
- // Update TxInfo->USBDMApktLen ,
- // the length = TXWI_SIZE + 802.11_hdr + 802.11_hdr_pad + payload_of_all_batch_frames + Bulk-Out-padding
- //
- pTxInfo = (PTXINFO_STRUC)(pWirelessPacket);
-
- // Calculate the bulk-out padding
- USBDMApktLen = pTxBlk->Priv - TXINFO_SIZE;
- padding = (4 - (USBDMApktLen % 4)) & 0x03; // round up to 4 byte alignment
- USBDMApktLen += padding;
-
- pTxInfo->USBDMATxPktLen = USBDMApktLen;
-
- //
- // Update TXWI->MPDUtotalByteCount ,
- // the length = 802.11 header + payload_of_all_batch_frames
- pTxWI= (PTXWI_STRUC)(pWirelessPacket + TXINFO_SIZE);
- pTxWI->MPDUtotalByteCount = totalMPDUSize;
-
- //
- // Update the pHTTXContext->CurWritePosition
- //
- pHTTXContext->CurWritePosition += (TXINFO_SIZE + USBDMApktLen);
- if ((pHTTXContext->CurWritePosition + 3906)> MAX_TXBULK_LIMIT)
- { // Add 3906 for prevent the NextBulkOut packet size is a A-RALINK/A-MSDU Frame.
- pHTTXContext->CurWritePosition = 8;
- pTxInfo->SwUseLastRound = 1;
- }
- pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
-
- //
- // Zero the last padding.
- //
- pWirelessPacket = (&pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset + pTxBlk->Priv]);
- NdisZeroMemory(pWirelessPacket, padding + 8);
-
- // Finally, set bCurWriting as FALSE
- pHTTXContext->bCurWriting = FALSE;
-
- }
- else
- { // It should not happened now unless we are going to shutdown.
- DBGPRINT(RT_DEBUG_ERROR, ("FinalWriteTxResource():bCurWriting is FALSE when handle last frames.\n"));
- }
-
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-}
-
-
-VOID RtmpUSBDataLastTxIdx(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN USHORT TxIdx)
-{
- // DO nothing for USB.
-}
-
-
-/*
- When can do bulk-out:
- 1. TxSwFreeIdx < TX_RING_SIZE;
- It means has at least one Ring entity is ready for bulk-out, kick it out.
- 2. If TxSwFreeIdx == TX_RING_SIZE
- Check if the CurWriting flag is FALSE, if it's FALSE, we can do kick out.
-
-*/
-VOID RtmpUSBDataKickOut(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx)
-{
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
- RTUSBKickBulkOut(pAd);
-
-}
-
-
-/*
- Must be run in Interrupt context
- This function handle RT2870 specific TxDesc and cpu index update and kick the packet out.
- */
-int RtmpUSBMgmtKickOut(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pSrcBufVA,
- IN UINT SrcBufLen)
-{
- PTXINFO_STRUC pTxInfo;
- ULONG BulkOutSize;
- UCHAR padLen;
- PUCHAR pDest;
- ULONG SwIdx = pAd->MgmtRing.TxCpuIdx;
- PTX_CONTEXT pMLMEContext = (PTX_CONTEXT)pAd->MgmtRing.Cell[SwIdx].AllocVa;
- unsigned long IrqFlags;
-
-
- pTxInfo = (PTXINFO_STRUC)(pSrcBufVA);
-
- // Build our URB for USBD
- BulkOutSize = SrcBufLen;
- BulkOutSize = (BulkOutSize + 3) & (~3);
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(BulkOutSize - TXINFO_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
-
- BulkOutSize += 4; // Always add 4 extra bytes at every packet.
-
- // If BulkOutSize is multiple of BulkOutMaxPacketSize, add extra 4 bytes again.
- if ((BulkOutSize % pAd->BulkOutMaxPacketSize) == 0)
- BulkOutSize += 4;
-
- padLen = BulkOutSize - SrcBufLen;
- ASSERT((padLen <= RTMP_PKT_TAIL_PADDING));
-
- // Now memzero all extra padding bytes.
- pDest = (PUCHAR)(pSrcBufVA + SrcBufLen);
- skb_put(GET_OS_PKT_TYPE(pPacket), padLen);
- NdisZeroMemory(pDest, padLen);
-
- RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
- pAd->MgmtRing.Cell[pAd->MgmtRing.TxCpuIdx].pNdisPacket = pPacket;
- pMLMEContext->TransferBuffer = (PTX_BUFFER)(GET_OS_PKT_DATAPTR(pPacket));
-
- // Length in TxInfo should be 8 less than bulkout size.
- pMLMEContext->BulkOutSize = BulkOutSize;
- pMLMEContext->InUse = TRUE;
- pMLMEContext->bWaitingBulkOut = TRUE;
-
-
- //for debug
- //hex_dump("RtmpUSBMgmtKickOut", &pMLMEContext->TransferBuffer->field.WirelessPacket[0], (pMLMEContext->BulkOutSize > 16 ? 16 : pMLMEContext->BulkOutSize));
-
- //pAd->RalinkCounters.KickTxCount++;
- //pAd->RalinkCounters.OneSecTxDoneCount++;
-
- //if (pAd->MgmtRing.TxSwFreeIdx == MGMT_RING_SIZE)
- // needKickOut = TRUE;
-
- // Decrease the TxSwFreeIdx and Increase the TX_CTX_IDX
- pAd->MgmtRing.TxSwFreeIdx--;
- INC_RING_INDEX(pAd->MgmtRing.TxCpuIdx, MGMT_RING_SIZE);
-
- RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
- //if (needKickOut)
- RTUSBKickBulkOut(pAd);
-
- return 0;
-}
-
-
-VOID RtmpUSBNullFrameKickOut(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN UCHAR *pNullFrame,
- IN UINT32 frameLen)
-{
- if (pAd->NullContext.InUse == FALSE)
- {
- PTX_CONTEXT pNullContext;
- PTXINFO_STRUC pTxInfo;
- PTXWI_STRUC pTxWI;
- PUCHAR pWirelessPkt;
-
- pNullContext = &(pAd->NullContext);
-
- // Set the in use bit
- pNullContext->InUse = TRUE;
- pWirelessPkt = (PUCHAR)&pNullContext->TransferBuffer->field.WirelessPacket[0];
-
- RTMPZeroMemory(&pWirelessPkt[0], 100);
- pTxInfo = (PTXINFO_STRUC)&pWirelessPkt[0];
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(HEADER_802_11)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxInfo->QSEL = FIFO_EDCA;
- pTxWI = (PTXWI_STRUC)&pWirelessPkt[TXINFO_SIZE];
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(HEADER_802_11)),
- 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
- RTMPMoveMemory(&pWirelessPkt[TXWI_SIZE+TXINFO_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)&pWirelessPkt[TXINFO_SIZE + TXWI_SIZE], DIR_WRITE, FALSE);
-#endif // RT_BIG_ENDIAN //
- pAd->NullContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
-
- // Fill out frame length information for global Bulk out arbitor
- //pNullContext->BulkOutSize = TransferBufferLength;
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - send NULL Frame @%d Mbps...\n", RateIdToMbps[pAd->CommonCfg.TxRate]));
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL);
-
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
- }
-
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ========================================================================
-
- Routine Description:
- Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound
-
- Arguments:
- pRxD Pointer to the Rx descriptor
-
- Return Value:
- NDIS_STATUS_SUCCESS No err
- NDIS_STATUS_FAILURE Error
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTMPCheckRxError(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC pRxINFO)
-{
- PCIPHER_KEY pWpaKey;
- INT dBm;
-
- if (pAd->bPromiscuous == TRUE)
- return(NDIS_STATUS_SUCCESS);
- if(pRxINFO == NULL)
- return(NDIS_STATUS_FAILURE);
-
- // Phy errors & CRC errors
- if (pRxINFO->Crc)
- {
- // Check RSSI for Noise Hist statistic collection.
- dBm = (INT) (pRxWI->RSSI0) - pAd->BbpRssiToDbmDelta;
- if (dBm <= -87)
- pAd->StaCfg.RPIDensity[0] += 1;
- else if (dBm <= -82)
- pAd->StaCfg.RPIDensity[1] += 1;
- else if (dBm <= -77)
- pAd->StaCfg.RPIDensity[2] += 1;
- else if (dBm <= -72)
- pAd->StaCfg.RPIDensity[3] += 1;
- else if (dBm <= -67)
- pAd->StaCfg.RPIDensity[4] += 1;
- else if (dBm <= -62)
- pAd->StaCfg.RPIDensity[5] += 1;
- else if (dBm <= -57)
- pAd->StaCfg.RPIDensity[6] += 1;
- else if (dBm > -57)
- pAd->StaCfg.RPIDensity[7] += 1;
-
- return(NDIS_STATUS_FAILURE);
- }
-
- // Add Rx size to channel load counter, we should ignore error counts
- pAd->StaCfg.CLBusyBytes += (pRxWI->MPDUtotalByteCount+ 14);
-
- // Drop ToDs promiscous frame, it is opened due to CCX 2 channel load statistics
- if (pHeader->FC.ToDs)
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Err;FC.ToDs\n"));
- return NDIS_STATUS_FAILURE;
- }
-
- // Paul 04-03 for OFDM Rx length issue
- if (pRxWI->MPDUtotalByteCount > MAX_AGGREGATION_SIZE)
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n"));
- return NDIS_STATUS_FAILURE;
- }
-
- // Drop not U2M frames, cant's drop here because we will drop beacon in this case
- // I am kind of doubting the U2M bit operation
- // if (pRxD->U2M == 0)
- // return(NDIS_STATUS_FAILURE);
-
- // drop decyption fail frame
- if (pRxINFO->Decrypted && pRxINFO->CipherErr)
- {
-
- //
- // MIC Error
- //
- if ((pRxINFO->CipherErr == 2) && pRxINFO->MyBss)
- {
- pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex];
- RTMPReportMicError(pAd, pWpaKey);
- DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error\n"));
- }
-
- if (pRxINFO->Decrypted &&
- (pAd->SharedKey[BSS0][pRxWI->KeyIndex].CipherAlg == CIPHER_AES) &&
- (pHeader->Sequence == pAd->FragFrame.Sequence))
- {
- //
- // Acceptable since the First FragFrame no CipherErr problem.
- //
- return(NDIS_STATUS_SUCCESS);
- }
-
- return(NDIS_STATUS_FAILURE);
- }
-
- return(NDIS_STATUS_SUCCESS);
-}
-
-VOID RT28xxUsbStaAsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx)
-{
- AUTO_WAKEUP_STRUC AutoWakeupCfg;
-
- AutoWakeupCfg.word = 0;
- RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-
- AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-}
-
-VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp)
-{
- AUTO_WAKEUP_STRUC AutoWakeupCfg;
-
- // we have decided to SLEEP, so at least do it for a BEACON period.
- if (TbttNumToNextWakeUp == 0)
- TbttNumToNextWakeUp = 1;
-
- AutoWakeupCfg.word = 0;
- RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-
- AutoWakeupCfg.field.NumofSleepingTbtt = TbttNumToNextWakeUp - 1;
- AutoWakeupCfg.field.EnableAutoWakeup = 1;
- AutoWakeupCfg.field.AutoLeadTime = 5;
- RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-
- AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02); // send POWER-SAVE command to MCU. Timeout 40us.
-
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-VOID RT28xxUsbMlmeRadioOn(
- IN PRTMP_ADAPTER pAd)
-{
- DBGPRINT(RT_DEBUG_TRACE,("RT28xxUsbMlmeRadioOn()\n"));
-
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- return;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
- RTMPusecDelay(10000);
- }
-#endif // CONFIG_STA_SUPPORT //
- NICResetFromError(pAd);
-
- // Enable Tx/Rx
- RTMPEnableRxTx(pAd);
-
-#ifdef RT3070
- if (IS_RT3071(pAd))
- {
- RT30xxReverseRFSleepModeSetup(pAd);
- }
-#endif // RT3070 //
-
- // Clear Radio off flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- RTUSBBulkReceive(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- // Set LED
- RTMPSetLED(pAd, LED_RADIO_ON);
-}
-
-VOID RT28xxUsbMlmeRadioOFF(
- IN PRTMP_ADAPTER pAd)
-{
- WPDMA_GLO_CFG_STRUC GloCfg;
- UINT32 Value, i;
-
- DBGPRINT(RT_DEBUG_TRACE,("RT28xxUsbMlmeRadioOFF()\n"));
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- return;
-
- // Set LED
- RTMPSetLED(pAd, LED_RADIO_OFF);
- // Set Radio off flag
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Link down first if any association exists
- if (INFRA_ON(pAd) || ADHOC_ON(pAd))
- LinkDown(pAd, FALSE);
- RTMPusecDelay(10000);
-
- //==========================================
- // Clean up old bss table
- BssTableInit(&pAd->ScanTab);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- if (pAd->CommonCfg.BBPCurrentBW == BW_40)
- {
- // Must using 40MHz.
- AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
- }
- else
- {
- // Must using 20MHz.
- AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
- }
-
- // Disable Tx/Rx DMA
- RTUSBReadMACRegister(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
- GloCfg.field.EnableTxDMA = 0;
- GloCfg.field.EnableRxDMA = 0;
- RTUSBWriteMACRegister(pAd, WPDMA_GLO_CFG, GloCfg.word); // abort all TX rings
-
- // Waiting for DMA idle
- i = 0;
- do
- {
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
- if ((GloCfg.field.TxDMABusy == 0) && (GloCfg.field.RxDMABusy == 0))
- break;
-
- RTMPusecDelay(1000);
- }while (i++ < 100);
-
- // Disable MAC Tx/Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= (0xfffffff3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // MAC_SYS_CTRL => value = 0x0 => 40mA
- //RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0);
-
- // PWR_PIN_CFG => value = 0x0 => 40mA
- //RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0);
-
- // TX_PIN_CFG => value = 0x0 => 20mA
- //RTMP_IO_WRITE32(pAd, TX_PIN_CFG, 0);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
-#endif // CONFIG_STA_SUPPORT //
-}
-
+#include "../../rt2870/common/cmm_data_2870.c"
diff --git a/drivers/staging/rt3070/common/cmm_info.c b/drivers/staging/rt3070/common/cmm_info.c
index 54cb1a35f7bf..6e981e523fb5 100644
--- a/drivers/staging/rt3070/common/cmm_info.c
+++ b/drivers/staging/rt3070/common/cmm_info.c
@@ -1,3395 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-*/
-
-#include "../rt_config.h"
-
-INT Show_SSID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-#ifdef DOT11_N_SUPPORT
-INT Show_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // DOT11_N_SUPPORT //
-
-INT Show_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_CountryCode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-#ifdef AGGREGATION_SUPPORT
-INT Show_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // AGGREGATION_SUPPORT //
-
-#ifdef WMM_SUPPORT
-INT Show_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // WMM_SUPPORT //
-
-INT Show_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-#ifdef CONFIG_STA_SUPPORT
-INT Show_NetworkType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-#endif // CONFIG_STA_SUPPORT //
-
-INT Show_AuthMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_EncrypType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key1_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key2_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key3_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_Key4_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-INT Show_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf);
-
-static struct {
- CHAR *name;
- INT (*show_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
- {"SSID", Show_SSID_Proc},
- {"WirelessMode", Show_WirelessMode_Proc},
- {"TxBurst", Show_TxBurst_Proc},
- {"TxPreamble", Show_TxPreamble_Proc},
- {"TxPower", Show_TxPower_Proc},
- {"Channel", Show_Channel_Proc},
- {"BGProtection", Show_BGProtection_Proc},
- {"RTSThreshold", Show_RTSThreshold_Proc},
- {"FragThreshold", Show_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
- {"HtBw", Show_HtBw_Proc},
- {"HtMcs", Show_HtMcs_Proc},
- {"HtGi", Show_HtGi_Proc},
- {"HtOpMode", Show_HtOpMode_Proc},
- {"HtExtcha", Show_HtExtcha_Proc},
- {"HtMpduDensity", Show_HtMpduDensity_Proc},
- {"HtBaWinSize", Show_HtBaWinSize_Proc},
- {"HtRdg", Show_HtRdg_Proc},
- {"HtAmsdu", Show_HtAmsdu_Proc},
- {"HtAutoBa", Show_HtAutoBa_Proc},
-#endif // DOT11_N_SUPPORT //
- {"CountryRegion", Show_CountryRegion_Proc},
- {"CountryRegionABand", Show_CountryRegionABand_Proc},
- {"CountryCode", Show_CountryCode_Proc},
-#ifdef AGGREGATION_SUPPORT
- {"PktAggregate", Show_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
- {"WmmCapable", Show_WmmCapable_Proc},
-#endif
- {"IEEE80211H", Show_IEEE80211H_Proc},
-#ifdef CONFIG_STA_SUPPORT
- {"NetworkType", Show_NetworkType_Proc},
-#endif // CONFIG_STA_SUPPORT //
- {"AuthMode", Show_AuthMode_Proc},
- {"EncrypType", Show_EncrypType_Proc},
- {"DefaultKeyID", Show_DefaultKeyID_Proc},
- {"Key1", Show_Key1_Proc},
- {"Key2", Show_Key2_Proc},
- {"Key3", Show_Key3_Proc},
- {"Key4", Show_Key4_Proc},
- {"WPAPSK", Show_WPAPSK_Proc},
- {NULL, NULL}
-};
-
-/*
- ==========================================================================
- Description:
- Get Driver version.
-
- Return:
- ==========================================================================
-*/
-INT Set_DriverVersion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
-#endif // CONFIG_STA_SUPPORT //
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Country Region.
- This command will not work, if the field of CountryRegion in eeprom is programmed.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG region;
-
- region = simple_strtol(arg, 0, 10);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- return -EOPNOTSUPP;
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // Country can be set only when EEPROM not programmed
- if (pAd->CommonCfg.CountryRegion & 0x80)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n"));
- return FALSE;
- }
-
- if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
- {
- pAd->CommonCfg.CountryRegion = (UCHAR) region;
- }
- else if (region == REGION_31_BG_BAND)
- {
- pAd->CommonCfg.CountryRegion = (UCHAR) region;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameters out of range\n"));
- return FALSE;
- }
-
- // if set country region, driver needs to be reset
- BuildChannelList(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Country Region for A band.
- This command will not work, if the field of CountryRegion in eeprom is programmed.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG region;
-
- region = simple_strtol(arg, 0, 10);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- return -EOPNOTSUPP;
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // Country can be set only when EEPROM not programmed
- if (pAd->CommonCfg.CountryRegionForABand & 0x80)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n"));
- return FALSE;
- }
-
- if((region >= 0) && (region <= REGION_MAXIMUM_A_BAND))
- {
- pAd->CommonCfg.CountryRegionForABand = (UCHAR) region;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameters out of range\n"));
- return FALSE;
- }
-
- // if set country region, driver needs to be reset
- BuildChannelList(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Wireless Mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG WirelessMode;
- INT success = TRUE;
-
- WirelessMode = simple_strtol(arg, 0, 10);
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- INT MaxPhyMode = PHY_11G;
-
-#ifdef DOT11_N_SUPPORT
- MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
- if (WirelessMode <= MaxPhyMode)
- {
- RTMPSetPhyMode(pAd, WirelessMode);
-#ifdef DOT11_N_SUPPORT
- if (WirelessMode >= PHY_11ABGN_MIXED)
- {
- pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
- pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
- }
- else
- {
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
- }
-#endif // DOT11_N_SUPPORT //
- // Set AdhocMode rates
- if (pAd->StaCfg.BssType == BSS_ADHOC)
- {
- MlmeUpdateTxRates(pAd, FALSE, 0);
- MakeIbssBeacon(pAd); // re-build BEACON frame
- AsicEnableIbssSync(pAd); // copy to on-chip memory
- }
- }
- else
- {
- success = FALSE;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // it is needed to set SSID to take effect
- if (success == TRUE)
- {
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%ld)\n", WirelessMode));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
- }
-
- return success;
-}
-
-/*
- ==========================================================================
- Description:
- Set Channel
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- INT success = TRUE;
- UCHAR Channel;
-
- Channel = (UCHAR) simple_strtol(arg, 0, 10);
-
- // check if this channel is valid
- if (ChannelSanity(pAd, Channel) == TRUE)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->CommonCfg.Channel = Channel;
-
- if (MONITOR_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- N_ChannelCheck(pAd);
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
- {
- N_SetCenCh(pAd);
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
- pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- success = TRUE;
- }
- else
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- success = FALSE;
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- if (success == TRUE)
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
-
- return success;
-}
-
-/*
- ==========================================================================
- Description:
- Set Short Slot Time Enable or Disable
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ShortSlot_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG ShortSlot;
-
- ShortSlot = simple_strtol(arg, 0, 10);
-
- if (ShortSlot == 1)
- pAd->CommonCfg.bUseShortSlotTime = TRUE;
- else if (ShortSlot == 0)
- pAd->CommonCfg.bUseShortSlotTime = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Tx power
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG TxPower;
- INT success = FALSE;
-
- TxPower = (ULONG) simple_strtol(arg, 0, 10);
- if (TxPower <= 100)
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->CommonCfg.TxPowerDefault = TxPower;
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
- }
-#endif // CONFIG_STA_SUPPORT //
- success = TRUE;
- }
- else
- success = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
-
- return success;
-}
-
-/*
- ==========================================================================
- Description:
- Set 11B/11G Protection
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- switch (simple_strtol(arg, 0, 10))
- {
- case 0: //AUTO
- pAd->CommonCfg.UseBGProtection = 0;
- break;
- case 1: //Always On
- pAd->CommonCfg.UseBGProtection = 1;
- break;
- case 2: //Always OFF
- pAd->CommonCfg.UseBGProtection = 2;
- break;
- default: //Invalid argument
- return FALSE;
- }
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set TxPreamble
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- RT_802_11_PREAMBLE Preamble;
-
- Preamble = simple_strtol(arg, 0, 10);
-
-
- switch (Preamble)
- {
- case Rt802_11PreambleShort:
- pAd->CommonCfg.TxPreamble = Preamble;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
-#endif // CONFIG_STA_SUPPORT //
- break;
- case Rt802_11PreambleLong:
-#ifdef CONFIG_STA_SUPPORT
- case Rt802_11PreambleAuto:
- // if user wants AUTO, initialize to LONG here, then change according to AP's
- // capability upon association.
-#endif // CONFIG_STA_SUPPORT //
- pAd->CommonCfg.TxPreamble = Preamble;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
-#endif // CONFIG_STA_SUPPORT //
- break;
- default: //Invalid argument
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set RTS Threshold
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
-
- RtsThresh = simple_strtol(arg, 0, 10);
-
- if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
- pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
-#ifdef CONFIG_STA_SUPPORT
- else if (RtsThresh == 0)
- pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-#endif // CONFIG_STA_SUPPORT //
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Fragment Threshold
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
-
- FragThresh = simple_strtol(arg, 0, 10);
-
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- {
- //Illegal FragThresh so we set it to default
- pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- }
- else if (FragThresh % 2 == 1)
- {
- // The length of each fragment shall always be an even number of octets, except for the last fragment
- // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
- pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
- }
- else
- {
- pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
- pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
- else
- pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set TxBurst
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG TxBurst;
-
- TxBurst = simple_strtol(arg, 0, 10);
- if (TxBurst == 1)
- pAd->CommonCfg.bEnableTxBurst = TRUE;
- else if (TxBurst == 0)
- pAd->CommonCfg.bEnableTxBurst = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
-
- return TRUE;
-}
-
-#ifdef AGGREGATION_SUPPORT
-/*
- ==========================================================================
- Description:
- Set TxBurst
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG aggre;
-
- aggre = simple_strtol(arg, 0, 10);
-
- if (aggre == 1)
- pAd->CommonCfg.bAggregationCapable = TRUE;
- else if (aggre == 0)
- pAd->CommonCfg.bAggregationCapable = FALSE;
- else
- return FALSE; //Invalid argument
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
-
- return TRUE;
-}
-#endif
-
-/*
- ==========================================================================
- Description:
- Set IEEE80211H.
- This parameter is 1 when needs radar detection, otherwise 0
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG ieee80211h;
-
- ieee80211h = simple_strtol(arg, 0, 10);
-
- if (ieee80211h == 1)
- pAd->CommonCfg.bIEEE80211H = TRUE;
- else if (ieee80211h == 0)
- pAd->CommonCfg.bIEEE80211H = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
-
- return TRUE;
-}
-
-
-#ifdef DBG
-/*
- ==========================================================================
- Description:
- For Debug information
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Debug_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
-
- if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
- RTDebugLevel = simple_strtol(arg, 0, 10);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
-
- return TRUE;
-}
-#endif
-
-INT Show_DescInfo_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Reset statistics counter
-
- Arguments:
- pAdapter Pointer to our adapter
- arg
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ResetStatCounter_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- //UCHAR i;
- //MAC_TABLE_ENTRY *pEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
-
- // add the most up-to-date h/w raw counters into software counters
- NICUpdateRawCounters(pAd);
-
- NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
- NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
- NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
-
- return TRUE;
-}
-
-BOOLEAN RTMPCheckStrPrintAble(
- IN CHAR *pInPutStr,
- IN UCHAR strLen)
-{
- UCHAR i=0;
-
- for (i=0; i<strLen; i++)
- {
- if ((pInPutStr[i] < 0x21) ||
- (pInPutStr[i] > 0x7E))
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Remove WPA Key process
-
- Arguments:
- pAd Pointer to our adapter
- pBuf Pointer to the where the key stored
-
- Return Value:
- NDIS_SUCCESS Add key successfully
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPSetDesiredRates(
- IN PRTMP_ADAPTER pAdapter,
- IN LONG Rates)
-{
- NDIS_802_11_RATES aryRates;
-
- memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
- switch (pAdapter->CommonCfg.PhyMode)
- {
- case PHY_11A: // A only
- switch (Rates)
- {
- case 6000000: //6M
- aryRates[0] = 0x0c; // 6M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
- break;
- case 9000000: //9M
- aryRates[0] = 0x12; // 9M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
- break;
- case 12000000: //12M
- aryRates[0] = 0x18; // 12M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
- break;
- case 18000000: //18M
- aryRates[0] = 0x24; // 18M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
- break;
- case 24000000: //24M
- aryRates[0] = 0x30; // 24M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
- break;
- case 36000000: //36M
- aryRates[0] = 0x48; // 36M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
- break;
- case 48000000: //48M
- aryRates[0] = 0x60; // 48M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
- break;
- case 54000000: //54M
- aryRates[0] = 0x6c; // 54M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
- break;
- case -1: //Auto
- default:
- aryRates[0] = 0x6c; // 54Mbps
- aryRates[1] = 0x60; // 48Mbps
- aryRates[2] = 0x48; // 36Mbps
- aryRates[3] = 0x30; // 24Mbps
- aryRates[4] = 0x24; // 18M
- aryRates[5] = 0x18; // 12M
- aryRates[6] = 0x12; // 9M
- aryRates[7] = 0x0c; // 6M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- break;
- }
- break;
- case PHY_11BG_MIXED: // B/G Mixed
- case PHY_11B: // B only
- case PHY_11ABG_MIXED: // A/B/G Mixed
- default:
- switch (Rates)
- {
- case 1000000: //1M
- aryRates[0] = 0x02;
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
- break;
- case 2000000: //2M
- aryRates[0] = 0x04;
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
- break;
- case 5000000: //5.5M
- aryRates[0] = 0x0b; // 5.5M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
- break;
- case 11000000: //11M
- aryRates[0] = 0x16; // 11M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
- break;
- case 6000000: //6M
- aryRates[0] = 0x0c; // 6M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
- break;
- case 9000000: //9M
- aryRates[0] = 0x12; // 9M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
- break;
- case 12000000: //12M
- aryRates[0] = 0x18; // 12M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
- break;
- case 18000000: //18M
- aryRates[0] = 0x24; // 18M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
- break;
- case 24000000: //24M
- aryRates[0] = 0x30; // 24M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
- break;
- case 36000000: //36M
- aryRates[0] = 0x48; // 36M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
- break;
- case 48000000: //48M
- aryRates[0] = 0x60; // 48M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
- break;
- case 54000000: //54M
- aryRates[0] = 0x6c; // 54M
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
- break;
- case -1: //Auto
- default:
- if (pAdapter->CommonCfg.PhyMode == PHY_11B)
- { //B Only
- aryRates[0] = 0x16; // 11Mbps
- aryRates[1] = 0x0b; // 5.5Mbps
- aryRates[2] = 0x04; // 2Mbps
- aryRates[3] = 0x02; // 1Mbps
- }
- else
- { //(B/G) Mixed or (A/B/G) Mixed
- aryRates[0] = 0x6c; // 54Mbps
- aryRates[1] = 0x60; // 48Mbps
- aryRates[2] = 0x48; // 36Mbps
- aryRates[3] = 0x30; // 24Mbps
- aryRates[4] = 0x16; // 11Mbps
- aryRates[5] = 0x0b; // 5.5Mbps
- aryRates[6] = 0x04; // 2Mbps
- aryRates[7] = 0x02; // 1Mbps
- }
- pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- break;
- }
- break;
- }
-
- NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
- DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
- pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
- pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
- pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
- pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
- // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
-}
-
-NDIS_STATUS RTMPWPARemoveKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf)
-{
- PNDIS_802_11_REMOVE_KEY pKey;
- ULONG KeyIdx;
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- BOOLEAN bTxKey; // Set the key as transmit key
- BOOLEAN bPairwise; // Indicate the key is pairwise key
- BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
- // Otherwise, it will set by the NIC.
- BOOLEAN bAuthenticator; // indicate key is set by authenticator.
- INT i;
-
- DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
-
- pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
- KeyIdx = pKey->KeyIndex & 0xff;
- // Bit 31 of Add-key, Tx Key
- bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
- // Bit 30 of Add-key PairwiseKey
- bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
- // Bit 29 of Add-key KeyRSC
- bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
- // Bit 28 of Add-key Authenticator
- bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
-
- // 1. If bTx is TRUE, return failure information
- if (bTxKey == TRUE)
- return(NDIS_STATUS_INVALID_DATA);
-
- // 2. Check Pairwise Key
- if (bPairwise)
- {
- // a. If BSSID is broadcast, remove all pairwise keys.
- // b. If not broadcast, remove the pairwise specified by BSSID
- for (i = 0; i < SHARE_KEY_NUM; i++)
- {
- if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
- {
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
- pAd->SharedKey[BSS0][i].KeyLen = 0;
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
- }
- }
- // 3. Group Key
- else
- {
- // a. If BSSID is broadcast, remove all group keys indexed
- // b. If BSSID matched, delete the group key indexed.
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
- Status = NDIS_STATUS_SUCCESS;
- }
-
- return (Status);
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ========================================================================
-
- Routine Description:
- Remove All WPA Keys
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPWPARemoveAllKeys(
- IN PRTMP_ADAPTER pAd)
-{
-
- UCHAR i;
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
-
- // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
- // Link up. And it will be replaced if user changed it.
- if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return;
-
- // For WPA-None, there is no need to remove it, since WinXP won't set it again after
- // Link up. And it will be replaced if user changed it.
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- return;
-
- // set BSSID wcid entry of the Pair-wise Key table as no-security mode
- AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
-
- // set all shared key mode as no-security.
- for (i = 0; i < SHARE_KEY_NUM; i++)
- {
- DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
- NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
-
- AsicRemoveSharedKeyEntry(pAd, BSS0, i);
- }
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ========================================================================
- Routine Description:
- Change NIC PHY mode. Re-association may be necessary. possible settings
- include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
-
- Arguments:
- pAd - Pointer to our adapter
- phymode -
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPSetPhyMode(
- IN PRTMP_ADAPTER pAd,
- IN ULONG phymode)
-{
- INT i;
- // the selected phymode must be supported by the RF IC encoded in E2PROM
-
- pAd->CommonCfg.PhyMode = (UCHAR)phymode;
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
-#ifdef EXT_BUILD_CHANNEL_LIST
- BuildChannelListEx(pAd);
-#else
- BuildChannelList(pAd);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // sanity check user setting
- for (i = 0; i < pAd->ChannelListNum; i++)
- {
- if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
- break;
- }
-
- if (i == pAd->ChannelListNum)
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->CommonCfg.Channel = FirstChannel(pAd);
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
- }
-
- NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- switch (phymode) {
- case PHY_11B:
- pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRateLen = 4;
- pAd->CommonCfg.ExtRateLen = 0;
- pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
- //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
- break;
-
- case PHY_11G:
- case PHY_11BG_MIXED:
- case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11N_2_4G:
- case PHY_11ABGN_MIXED:
- case PHY_11BGN_MIXED:
- case PHY_11GN_MIXED:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRateLen = 8;
- pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.ExtRateLen = 4;
- pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
- break;
-
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AN_MIXED:
- case PHY_11AGN_MIXED:
- case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
- pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.SupRateLen = 8;
- pAd->CommonCfg.ExtRateLen = 0;
- pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
- pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
- //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
- break;
-
- default:
- break;
- }
-
-
- pAd->CommonCfg.BandState = UNKNOWN_BAND;
-}
-
-
-#ifdef DOT11_N_SUPPORT
-/*
- ========================================================================
- Routine Description:
- Caller ensures we has 802.11n support.
- Calls at setting HT from AP/STASetinformation
-
- Arguments:
- pAd - Pointer to our adapter
- phymode -
-
- ========================================================================
-*/
-VOID RTMPSetHT(
- IN PRTMP_ADAPTER pAd,
- IN OID_SET_HT_PHYMODE *pHTPhyMode)
-{
- //ULONG *pmcs;
- UINT32 Value = 0;
- UCHAR BBPValue = 0;
- UCHAR BBP3Value = 0;
- UCHAR RxStream = pAd->CommonCfg.RxStream;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
- pHTPhyMode->MCS, pHTPhyMode->BW,
- pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
-
- // Don't zero supportedHyPhy structure.
- RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
- RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
- RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
- RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
-
- if (pAd->CommonCfg.bRdg)
- {
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
- }
- else
- {
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
- }
-
- pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
- pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
-
- // Mimo power save, A-MSDU size,
- pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
- pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
- pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-
- pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
- pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
- pAd->CommonCfg.DesiredHtPhy.AmsduSize,
- pAd->CommonCfg.DesiredHtPhy.MimoPs,
- pAd->CommonCfg.DesiredHtPhy.MpduDensity,
- pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
-
- if(pHTPhyMode->HtMode == HTMODE_GF)
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
- pAd->CommonCfg.DesiredHtPhy.GF = 1;
- }
- else
- pAd->CommonCfg.DesiredHtPhy.GF = 0;
-
- // Decide Rx MCSSet
- switch (RxStream)
- {
- case 1:
- pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
- break;
-
- case 2:
- pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
- break;
-
- case 3: // 3*3
- pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
- pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
- break;
- }
-
- if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
- {
- pHTPhyMode->BW = BW_20;
- pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
- }
-
- if(pHTPhyMode->BW == BW_40)
- {
- pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
- pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
- if (pAd->CommonCfg.Channel <= 14)
- pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
-
- pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
- // Set Regsiter for extension channel position.
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
- if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
- {
- Value |= 0x1;
- BBP3Value |= (0x20);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
- }
- else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
- {
- Value &= 0xfe;
- BBP3Value &= (~0x20);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
- }
-
- // Turn on BBP 40MHz mode now only as AP .
- // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
- if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
- )
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- }
- }
- else
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
- pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
- pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- // Turn on BBP 20MHz mode by request here.
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- }
- }
-
- if(pHTPhyMode->STBC == STBC_USE)
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
- pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
- pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
- pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
- }
- else
- {
- pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
- pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
- }
-
- if(pHTPhyMode->SHORTGI == GI_400)
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
- }
- else
- {
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
- pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
- pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
- }
-
- // We support link adaptation for unsolicit MCS feedback, set to 2.
- pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
- pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
- // 1, the extension channel above the control channel.
-
- // EDCA parameters used for AP's own transmission
- if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
- {
- pAd->CommonCfg.APEdcaParm.bValid = TRUE;
- pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
- pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
- pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
- pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-
- pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
- pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
-
- pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
- pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
- pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
-
- pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
- pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
- }
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- RTMPSetIndividualHT(pAd, 0);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Caller ensures we has 802.11n support.
- Calls at setting HT from AP/STASetinformation
-
- Arguments:
- pAd - Pointer to our adapter
- phymode -
-
- ========================================================================
-*/
-VOID RTMPSetIndividualHT(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx)
-{
- PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
- UCHAR TxStream = pAd->CommonCfg.TxStream;
- UCHAR DesiredMcs = MCS_AUTO;
-
- do
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
- DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
- //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
- break;
- }
-#endif // CONFIG_STA_SUPPORT //
- } while (FALSE);
-
- if (pDesired_ht_phy == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
- return;
- }
- RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
- // Check the validity of MCS
- if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
- {
- DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
- DesiredMcs = MCS_7;
- }
-
- if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
- {
- DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
- DesiredMcs = MCS_0;
- }
-
- pDesired_ht_phy->bHtEnable = TRUE;
-
- // Decide desired Tx MCS
- switch (TxStream)
- {
- case 1:
- if (DesiredMcs == MCS_AUTO)
- {
- pDesired_ht_phy->MCSSet[0]= 0xff;
- pDesired_ht_phy->MCSSet[1]= 0x00;
- }
- else if (DesiredMcs <= MCS_7)
- {
- pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
- pDesired_ht_phy->MCSSet[1]= 0x00;
- }
- break;
-
- case 2:
- if (DesiredMcs == MCS_AUTO)
- {
- pDesired_ht_phy->MCSSet[0]= 0xff;
- pDesired_ht_phy->MCSSet[1]= 0xff;
- }
- else if (DesiredMcs <= MCS_15)
- {
- ULONG mode;
-
- mode = DesiredMcs / 8;
- if (mode < 2)
- pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
- }
- break;
-
- case 3: // 3*3
- if (DesiredMcs == MCS_AUTO)
- {
- /* MCS0 ~ MCS23, 3 bytes */
- pDesired_ht_phy->MCSSet[0]= 0xff;
- pDesired_ht_phy->MCSSet[1]= 0xff;
- pDesired_ht_phy->MCSSet[2]= 0xff;
- }
- else if (DesiredMcs <= MCS_23)
- {
- ULONG mode;
-
- mode = DesiredMcs / 8;
- if (mode < 3)
- pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
- }
- break;
- }
-
- if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
- {
- if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
- pDesired_ht_phy->MCSSet[4] = 0x1;
- }
-
- // update HT Rate setting
- if (pAd->OpMode == OPMODE_STA)
- MlmeUpdateHtTxRates(pAd, BSS0);
- else
- MlmeUpdateHtTxRates(pAd, apidx);
-}
-
-
-/*
- ========================================================================
- Routine Description:
- Update HT IE from our capability.
-
- Arguments:
- Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
-
-
- ========================================================================
-*/
-VOID RTMPUpdateHTIE(
- IN RT_HT_CAPABILITY *pRtHt,
- IN UCHAR *pMcsSet,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo)
-{
- RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
- RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
-
- pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
- pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
- pHtCapability->HtCapInfo.GF = pRtHt->GF;
- pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
- pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
- pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
- pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
- pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
- pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
- pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
-
- pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
- pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
- pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
- pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
- RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
-}
-#endif // DOT11_N_SUPPORT //
-
-/*
- ========================================================================
- Description:
- Add Client security information into ASIC WCID table and IVEIV table.
- Return:
- ========================================================================
-*/
-VOID RTMPAddWcidAttributeEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- UINT32 WCIDAttri = 0;
- USHORT offset;
- UCHAR IVEIV = 0;
- USHORT Wcid = 0;
-
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (BssIdx > BSS0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
- return;
- }
-
- // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
- // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
- // the AID:2~ assign to mesh link entry.
- if (pEntry && ADHOC_ON(pAd))
- Wcid = pEntry->Aid;
- else if (pEntry && INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- if (pEntry->ValidAsDls == TRUE)
- Wcid = pEntry->Aid;
- else
-#endif // QOS_DLS_SUPPORT //
- Wcid = BSSID_WCID;
- }
- else
- Wcid = MCAST_WCID;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // Update WCID attribute table
- offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pEntry && pEntry->ValidAsMesh)
- WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
-#ifdef QOS_DLS_SUPPORT
- else if ((pEntry) && (pEntry->ValidAsDls) &&
- ((CipherAlg == CIPHER_TKIP) ||
- (CipherAlg == CIPHER_TKIP_NO_MIC) ||
- (CipherAlg == CIPHER_AES) ||
- (CipherAlg == CIPHER_NONE)))
- WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
-#endif // QOS_DLS_SUPPORT //
- else
- WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-
-
- // Update IV/EIV table
- offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
-
- // WPA mode
- if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
- {
- // Eiv bit on. keyid always is 0 for pairwise key
- IVEIV = (KeyIdx <<6) | 0x20;
- }
- else
- {
- // WEP KeyIdx is default tx key.
- IVEIV = (KeyIdx << 6);
- }
-
- // For key index and ext IV bit, so only need to update the position(offset+3).
-#ifdef RT2870
- RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
-#endif // RT2870 //
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
- DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
-
-}
-
-/*
- ==========================================================================
- Description:
- Parse encryption type
-Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- ==========================================================================
-*/
-CHAR *GetEncryptType(CHAR enc)
-{
- if(enc == Ndis802_11WEPDisabled)
- return "NONE";
- if(enc == Ndis802_11WEPEnabled)
- return "WEP";
- if(enc == Ndis802_11Encryption2Enabled)
- return "TKIP";
- if(enc == Ndis802_11Encryption3Enabled)
- return "AES";
- if(enc == Ndis802_11Encryption4Enabled)
- return "TKIPAES";
- else
- return "UNKNOW";
-}
-
-CHAR *GetAuthMode(CHAR auth)
-{
- if(auth == Ndis802_11AuthModeOpen)
- return "OPEN";
- if(auth == Ndis802_11AuthModeShared)
- return "SHARED";
- if(auth == Ndis802_11AuthModeAutoSwitch)
- return "AUTOWEP";
- if(auth == Ndis802_11AuthModeWPA)
- return "WPA";
- if(auth == Ndis802_11AuthModeWPAPSK)
- return "WPAPSK";
- if(auth == Ndis802_11AuthModeWPANone)
- return "WPANONE";
- if(auth == Ndis802_11AuthModeWPA2)
- return "WPA2";
- if(auth == Ndis802_11AuthModeWPA2PSK)
- return "WPA2PSK";
- if(auth == Ndis802_11AuthModeWPA1WPA2)
- return "WPA1WPA2";
- if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
- return "WPA1PSKWPA2PSK";
-
- return "UNKNOW";
-}
-
-#if 1 //#ifndef UCOS
-/*
- ==========================================================================
- Description:
- Get site survey results
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) UI needs to wait 4 seconds after issue a site survey command
- 2.) iwpriv ra0 get_site_survey
- 3.) UI needs to prepare at least 4096bytes to get the results
- ==========================================================================
-*/
-#define LINE_LEN (4+33+20+8+10+9+7+3) // Channel+SSID+Bssid+WepStatus+AuthMode+Signal+WiressMode+NetworkType
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-VOID RTMPIoctlGetSiteSurvey(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *msg;
- INT i=0;
- INT WaitCnt;
- INT Status=0;
- CHAR Ssid[MAX_LEN_OF_SSID +1];
- INT Rssi = 0, max_len = LINE_LEN;
- UINT Rssi_Quality = 0;
- NDIS_802_11_NETWORK_TYPE wireless_mode;
-
- os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
-
- if (msg == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
- return;
- }
-
- memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
- memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
- sprintf(msg,"%s","\n");
- sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-8s%-10s%-9s%-7s%-3s\n",
- "Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- WaitCnt = 0;
-#ifdef CONFIG_STA_SUPPORT
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
- OS_WAIT(500);
-#endif // CONFIG_STA_SUPPORT //
-
- for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
- {
- if( pAdapter->ScanTab.BssEntry[i].Channel==0)
- break;
-
- if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
- break;
-
- //Channel
- sprintf(msg+strlen(msg),"%-4d", pAdapter->ScanTab.BssEntry[i].Channel);
- //SSID
- memcpy(Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- Ssid[pAdapter->ScanTab.BssEntry[i].SsidLen] = '\0';
- sprintf(msg+strlen(msg),"%-33s", Ssid);
- //BSSID
- sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
- pAdapter->ScanTab.BssEntry[i].Bssid[0],
- pAdapter->ScanTab.BssEntry[i].Bssid[1],
- pAdapter->ScanTab.BssEntry[i].Bssid[2],
- pAdapter->ScanTab.BssEntry[i].Bssid[3],
- pAdapter->ScanTab.BssEntry[i].Bssid[4],
- pAdapter->ScanTab.BssEntry[i].Bssid[5]);
- //Encryption Type
- sprintf(msg+strlen(msg),"%-8s",GetEncryptType(pAdapter->ScanTab.BssEntry[i].WepStatus));
- //Authentication Mode
- if (pAdapter->ScanTab.BssEntry[i].WepStatus == Ndis802_11WEPEnabled)
- sprintf(msg+strlen(msg),"%-10s", "UNKNOW");
- else
- sprintf(msg+strlen(msg),"%-10s",GetAuthMode(pAdapter->ScanTab.BssEntry[i].AuthMode));
- // Rssi
- Rssi = (INT)pAdapter->ScanTab.BssEntry[i].Rssi;
- if (Rssi >= -50)
- Rssi_Quality = 100;
- else if (Rssi >= -80) // between -50 ~ -80dbm
- Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
- else if (Rssi >= -90) // between -80 ~ -90dbm
- Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
- else // < -84 dbm
- Rssi_Quality = 0;
- sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
- // Wireless Mode
- wireless_mode = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
- if (wireless_mode == Ndis802_11FH ||
- wireless_mode == Ndis802_11DS)
- sprintf(msg+strlen(msg),"%-7s", "11b");
- else if (wireless_mode == Ndis802_11OFDM5)
- sprintf(msg+strlen(msg),"%-7s", "11a");
- else if (wireless_mode == Ndis802_11OFDM5_N)
- sprintf(msg+strlen(msg),"%-7s", "11a/n");
- else if (wireless_mode == Ndis802_11OFDM24)
- sprintf(msg+strlen(msg),"%-7s", "11b/g");
- else if (wireless_mode == Ndis802_11OFDM24_N)
- sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
- else
- sprintf(msg+strlen(msg),"%-7s", "unknow");
- //Network Type
- if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_ADHOC)
- sprintf(msg+strlen(msg),"%-3s", " Ad");
- else
- sprintf(msg+strlen(msg),"%-3s", " In");
-
- sprintf(msg+strlen(msg),"\n");
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- }
-
-#ifdef CONFIG_STA_SUPPORT
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-#endif // CONFIG_STA_SUPPORT //
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
- os_free_mem(NULL, (PUCHAR)msg);
-}
-
-
-#define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
-VOID RTMPIoctlGetMacTable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq)
-{
- INT i;
- RT_802_11_MAC_TABLE MacTab;
- char *msg;
-
- MacTab.Num = 0;
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
- {
- COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
- MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
- MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
-#ifdef DOT11_N_SUPPORT
- MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
-#endif // DOT11_N_SUPPORT //
-
- // Fill in RSSI per entry
- MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
- MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
- MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
-
- // the connected time per entry
- MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
- MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
- MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
- MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
- MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
- MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
- MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
- MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
-
- MacTab.Num += 1;
- }
- }
- wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
- if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
- }
-
- msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
- memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
- sprintf(msg,"%s","\n");
- sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
- "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
-
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
- if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
- {
- if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
- break;
- sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
- sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
- sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
- sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
- sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
- sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
- sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
- }
- }
- // for compatible with old API just do the printk to console
- //wrq->u.data.length = strlen(msg);
- //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
- }
-
- kfree(msg);
-}
-#endif // UCOS //
-
-#ifdef DOT11_N_SUPPORT
-INT Set_BASetup_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], tid;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
-/*
- The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the tid value.
-*/
- //printk("\n%s\n", arg);
-
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- tid = simple_strtol((token+1), 0, 10);
- if (tid > 15)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], tid);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nSetup BA Session: Tid = %d\n", tid);
- BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_BADecline_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG bBADecline;
-
- bBADecline = simple_strtol(arg, 0, 10);
-
- if (bBADecline == 0)
- {
- pAd->CommonCfg.bBADecline = FALSE;
- }
- else if (bBADecline == 1)
- {
- pAd->CommonCfg.bBADecline = TRUE;
- }
- else
- {
- return FALSE; //Invalid argument
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
-
- return TRUE;
-}
-
-INT Set_BAOriTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], tid;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
- //printk("\n%s\n", arg);
-/*
- The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the tid value.
-*/
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- tid = simple_strtol((token+1), 0, 10);
- if (tid > NUM_OF_TID)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], tid);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nTear down Ori BA Session: Tid = %d\n", tid);
- BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_BARecTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], tid;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
- //printk("\n%s\n", arg);
-/*
- The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the tid value.
-*/
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- tid = simple_strtol((token+1), 0, 10);
- if (tid > NUM_OF_TID)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], tid);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nTear down Rec BA Session: Tid = %d\n", tid);
- BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG HtBw;
-
- HtBw = simple_strtol(arg, 0, 10);
- if (HtBw == BW_40)
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- else if (HtBw == BW_20)
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
-
- return TRUE;
-}
-
-INT Set_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG HtMcs, Mcs_tmp;
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN bAutoRate = FALSE;
-#endif // CONFIG_STA_SUPPORT //
-
- Mcs_tmp = simple_strtol(arg, 0, 10);
-
- if (Mcs_tmp <= 15 || Mcs_tmp == 32)
- HtMcs = Mcs_tmp;
- else
- HtMcs = MCS_AUTO;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
- pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
-
- if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
- {
- if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
- (HtMcs >= 0 && HtMcs <= 3) &&
- (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
- {
- RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
- }
- else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
- (HtMcs >= 0 && HtMcs <= 7) &&
- (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
- {
- RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
- }
- else
- bAutoRate = TRUE;
-
- if (bAutoRate)
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- RTMPSetDesiredRates(pAd, -1);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
- }
- if (ADHOC_ON(pAd))
- return TRUE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- SetCommonHT(pAd);
-
- return TRUE;
-}
-
-INT Set_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG HtGi;
-
- HtGi = simple_strtol(arg, 0, 10);
-
- if ( HtGi == GI_400)
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
- else if ( HtGi == GI_800 )
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
-
- return TRUE;
-}
-
-
-INT Set_HtTxBASize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR Size;
-
- Size = simple_strtol(arg, 0, 10);
-
- if (Size <=0 || Size >=64)
- {
- Size = 8;
- }
- pAd->CommonCfg.TxBASize = Size-1;
- DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
-
- return TRUE;
-}
-
-
-INT Set_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == HTMODE_GF)
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
- else if ( Value == HTMODE_MM )
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
-
- return TRUE;
-
-}
-
-INT Set_HtStbc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == STBC_USE)
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
- else if ( Value == STBC_NONE )
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
-
- return TRUE;
-}
-
-INT Set_HtHtc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->HTCEnable = FALSE;
- else if ( Value ==1 )
- pAd->HTCEnable = TRUE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
-
- return TRUE;
-}
-
-INT Set_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == 0)
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- else if ( Value ==1 )
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
-
- return TRUE;
-}
-
-INT Set_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value <=7 && Value >= 0)
- pAd->CommonCfg.BACapability.field.MpduDensity = Value;
- else
- pAd->CommonCfg.BACapability.field.MpduDensity = 4;
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
-
- return TRUE;
-}
-
-INT Set_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
-
- if (Value >=1 && Value <= 64)
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
- }
- else
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
- }
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
-
- return TRUE;
-}
-
-INT Set_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value == 0)
- pAd->CommonCfg.bRdg = FALSE;
- else if ( Value ==1 )
- {
- pAd->HTCEnable = TRUE;
- pAd->CommonCfg.bRdg = TRUE;
- }
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
-
- return TRUE;
-}
-
-INT Set_HtLinkAdapt_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->bLinkAdapt = FALSE;
- else if ( Value ==1 )
- {
- pAd->HTCEnable = TRUE;
- pAd->bLinkAdapt = TRUE;
- }
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
-
- return TRUE;
-}
-
-INT Set_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
- else if ( Value == 1 )
- pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
-
- return TRUE;
-}
-
-INT Set_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
- }
- else if (Value == 1)
- {
- pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
- pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
- }
- else
- return FALSE; //Invalid argument
-
- pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
- pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
-
- return TRUE;
-
-}
-
-INT Set_HtProtect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.bHTProtect = FALSE;
- else if (Value == 1)
- pAd->CommonCfg.bHTProtect = TRUE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
-
- return TRUE;
-}
-
-INT Set_SendPSMPAction_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[6], mode;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- MAC_TABLE_ENTRY *pEntry;
-
- //printk("\n%s\n", arg);
-/*
- The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
- =>The six 2 digit hex-decimal number previous are the Mac address,
- =>The seventh decimal number is the mode value.
-*/
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- mode = simple_strtol((token+1), 0, 10);
- if (mode > MMPS_ENABLE)
- return FALSE;
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], mode);
-
- pEntry = MacTableLookup(pAd, mac);
-
- if (pEntry) {
- printk("\nSendPSMPAction MIPS mode = %d\n", mode);
- SendPSMPAction(pAd, pEntry->Aid, mode);
- }
-
- return TRUE;
- }
-
- return FALSE;
-
-
-}
-
-INT Set_HtMIMOPSmode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- if (Value <=3 && Value >= 0)
- pAd->CommonCfg.BACapability.field.MMPSmode = Value;
- else
- pAd->CommonCfg.BACapability.field.MMPSmode = 3;
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
-
- return TRUE;
-}
-
-
-INT Set_ForceShortGI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->WIFItestbed.bShortGI = FALSE;
- else if (Value == 1)
- pAd->WIFItestbed.bShortGI = TRUE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
-
- return TRUE;
-}
-
-
-
-INT Set_ForceGF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->WIFItestbed.bGreenField = FALSE;
- else if (Value == 1)
- pAd->WIFItestbed.bGreenField = TRUE;
- else
- return FALSE; //Invalid argument
-
- SetCommonHT(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
-
- return TRUE;
-}
-
-INT Set_HtMimoPs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
- if (Value == 0)
- pAd->CommonCfg.bMIMOPSEnable = FALSE;
- else if (Value == 1)
- pAd->CommonCfg.bMIMOPSEnable = TRUE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
-
- return TRUE;
-}
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
-INT SetCommonHT(
- IN PRTMP_ADAPTER pAd)
-{
- OID_SET_HT_PHYMODE SetHT;
-
- if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
- return FALSE;
-
- SetHT.PhyMode = pAd->CommonCfg.PhyMode;
- SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
- SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
- SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
- SetHT.MCS = MCS_AUTO;
- SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
- SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
- SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
-
- RTMPSetHT(pAd, &SetHT);
-
- return TRUE;
-}
-#endif // DOT11_N_SUPPORT //
-
-INT Set_FixedTxMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR fix_tx_mode = FIXED_TXMODE_HT;
-
- if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_OFDM;
- }
- else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_CCK;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
-
- return TRUE;
-}
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-INT Set_OpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ULONG Value;
-
- Value = simple_strtol(arg, 0, 10);
-
-#ifdef RT2870
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
-#endif // RT2870 //
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Can not switch operate mode on interface up !! \n"));
- return FALSE;
- }
-
- if (Value == 0)
- pAd->OpMode = OPMODE_STA;
- else if (Value == 1)
- pAd->OpMode = OPMODE_AP;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_OpMode_Proc::(OpMode=%s)\n", pAd->OpMode == 1 ? "AP Mode" : "STA Mode"));
-
- return TRUE;
-}
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-
-/////////////////////////////////////////////////////////////////////////
-PCHAR RTMPGetRalinkAuthModeStr(
- IN NDIS_802_11_AUTHENTICATION_MODE authMode)
-{
- switch(authMode)
- {
- case Ndis802_11AuthModeOpen:
- return "OPEN";
- default:
- case Ndis802_11AuthModeWPAPSK:
- return "WPAPSK";
- case Ndis802_11AuthModeShared:
- return "SHARED";
- case Ndis802_11AuthModeWPA:
- return "WPA";
- case Ndis802_11AuthModeWPA2:
- return "WPA2";
- case Ndis802_11AuthModeWPA2PSK:
- return "WPA2PSK";
- case Ndis802_11AuthModeWPA1PSKWPA2PSK:
- return "WPAPSKWPA2PSK";
- case Ndis802_11AuthModeWPA1WPA2:
- return "WPA1WPA2";
- }
-}
-
-PCHAR RTMPGetRalinkEncryModeStr(
- IN USHORT encryMode)
-{
- switch(encryMode)
- {
- default:
- case Ndis802_11WEPDisabled:
- return "NONE";
- case Ndis802_11WEPEnabled:
- return "WEP";
- case Ndis802_11Encryption2Enabled:
- return "TKIP";
- case Ndis802_11Encryption3Enabled:
- return "AES";
- case Ndis802_11Encryption4Enabled:
- return "TKIPAES";
- }
-}
-
-INT RTMPShowCfgValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pName,
- IN PUCHAR pBuf)
-{
- INT Status = 0;
-
- for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
- {
- if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
- {
- if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
- Status = -EINVAL;
- break; //Exit for loop.
- }
- }
-
- if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
- {
- sprintf(pBuf, "\n");
- for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
- sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
- }
-
- return Status;
-}
-
-INT Show_SSID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
-#endif // CONFIG_STA_SUPPORT //
- return 0;
-}
-
-INT Show_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.PhyMode)
- {
- case PHY_11BG_MIXED:
- sprintf(pBuf, "\t11B/G");
- break;
- case PHY_11B:
- sprintf(pBuf, "\t11B");
- break;
- case PHY_11A:
- sprintf(pBuf, "\t11A");
- break;
- case PHY_11ABG_MIXED:
- sprintf(pBuf, "\t11A/B/G");
- break;
- case PHY_11G:
- sprintf(pBuf, "\t11G");
- break;
-#ifdef DOT11_N_SUPPORT
- case PHY_11ABGN_MIXED:
- sprintf(pBuf, "\t11A/B/G/N");
- break;
- case PHY_11N_2_4G:
- sprintf(pBuf, "\t11N only with 2.4G");
- break;
- case PHY_11GN_MIXED:
- sprintf(pBuf, "\t11G/N");
- break;
- case PHY_11AN_MIXED:
- sprintf(pBuf, "\t11A/N");
- break;
- case PHY_11BGN_MIXED:
- sprintf(pBuf, "\t11B/G/N");
- break;
- case PHY_11AGN_MIXED:
- sprintf(pBuf, "\t11A/G/N");
- break;
- case PHY_11N_5G:
- sprintf(pBuf, "\t11N only with 5G");
- break;
-#endif // DOT11_N_SUPPORT //
- default:
- sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
- break;
- }
- return 0;
-}
-
-
-INT Show_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
- return 0;
-}
-
-INT Show_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.TxPreamble)
- {
- case Rt802_11PreambleShort:
- sprintf(pBuf, "\tShort");
- break;
- case Rt802_11PreambleLong:
- sprintf(pBuf, "\tLong");
- break;
- case Rt802_11PreambleAuto:
- sprintf(pBuf, "\tAuto");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
- break;
- }
-
- return 0;
-}
-
-INT Show_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
- return 0;
-}
-
-INT Show_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
- return 0;
-}
-
-INT Show_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.UseBGProtection)
- {
- case 1: //Always On
- sprintf(pBuf, "\tON");
- break;
- case 2: //Always OFF
- sprintf(pBuf, "\tOFF");
- break;
- case 0: //AUTO
- sprintf(pBuf, "\tAuto");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
- break;
- }
- return 0;
-}
-
-INT Show_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
- return 0;
-}
-
-INT Show_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
- return 0;
-}
-
-#ifdef DOT11_N_SUPPORT
-INT Show_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
- {
- sprintf(pBuf, "\t40 MHz");
- }
- else
- {
- sprintf(pBuf, "\t20 MHz");
- }
- return 0;
-}
-
-INT Show_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
-#endif // CONFIG_STA_SUPPORT //
- return 0;
-}
-
-INT Show_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
- {
- case GI_400:
- sprintf(pBuf, "\tGI_400");
- break;
- case GI_800:
- sprintf(pBuf, "\tGI_800");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
- break;
- }
- return 0;
-}
-
-INT Show_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
- {
- case HTMODE_GF:
- sprintf(pBuf, "\tGF");
- break;
- case HTMODE_MM:
- sprintf(pBuf, "\tMM");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
- break;
- }
- return 0;
-}
-
-INT Show_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
- {
- case EXTCHA_BELOW:
- sprintf(pBuf, "\tBelow");
- break;
- case EXTCHA_ABOVE:
- sprintf(pBuf, "\tAbove");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
- break;
- }
- return 0;
-}
-
-
-INT Show_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
- return 0;
-}
-
-INT Show_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
- return 0;
-}
-
-INT Show_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
- return 0;
-}
-
-INT Show_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
- return 0;
-}
-
-INT Show_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
- return 0;
-}
-#endif // DOT11_N_SUPPORT //
-
-INT Show_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
- return 0;
-}
-
-INT Show_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
- return 0;
-}
-
-INT Show_CountryCode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
- return 0;
-}
-
-#ifdef AGGREGATION_SUPPORT
-INT Show_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
- return 0;
-}
-#endif // AGGREGATION_SUPPORT //
-
-#ifdef WMM_SUPPORT
-INT Show_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
-#endif // CONFIG_STA_SUPPORT //
-
- return 0;
-}
-#endif // WMM_SUPPORT //
-
-INT Show_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
- return 0;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-INT Show_NetworkType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- switch(pAd->StaCfg.BssType)
- {
- case BSS_ADHOC:
- sprintf(pBuf, "\tAdhoc");
- break;
- case BSS_INFRA:
- sprintf(pBuf, "\tInfra");
- break;
- case BSS_ANY:
- sprintf(pBuf, "\tAny");
- break;
- case BSS_MONITOR:
- sprintf(pBuf, "\tMonitor");
- break;
- default:
- sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
- break;
- }
- return 0;
-}
-#endif // CONFIG_STA_SUPPORT //
-
-INT Show_AuthMode_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AuthMode = pAd->StaCfg.AuthMode;
-#endif // CONFIG_STA_SUPPORT //
-
- if ((AuthMode >= Ndis802_11AuthModeOpen) &&
- (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
- sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
- else
- sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
-
- return 0;
-}
-
-INT Show_EncrypType_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- WepStatus = pAd->StaCfg.WepStatus;
-#endif // CONFIG_STA_SUPPORT //
-
- if ((WepStatus >= Ndis802_11WEPEnabled) &&
- (WepStatus <= Ndis802_11Encryption4KeyAbsent))
- sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
- else
- sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
-
- return 0;
-}
-
-INT Show_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- UCHAR DefaultKeyId = 0;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- DefaultKeyId = pAd->StaCfg.DefaultKeyId;
-#endif // CONFIG_STA_SUPPORT //
-
- sprintf(pBuf, "\t%d", DefaultKeyId);
-
- return 0;
-}
-
-INT Show_WepKey_Proc(
- IN PRTMP_ADAPTER pAd,
- IN INT KeyIdx,
- OUT PUCHAR pBuf)
-{
- UCHAR Key[16] = {0}, KeyLength = 0;
- INT index = BSS0;
-
- KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
- NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
-
- //check key string is ASCII or not
- if (RTMPCheckStrPrintAble(Key, KeyLength))
- sprintf(pBuf, "\t%s", Key);
- else
- {
- int idx;
- sprintf(pBuf, "\t");
- for (idx = 0; idx < KeyLength; idx++)
- sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
- }
- return 0;
-}
-
-INT Show_Key1_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 0, pBuf);
- return 0;
-}
-
-INT Show_Key2_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 1, pBuf);
- return 0;
-}
-
-INT Show_Key3_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 2, pBuf);
- return 0;
-}
-
-INT Show_Key4_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- Show_WepKey_Proc(pAd, 3, pBuf);
- return 0;
-}
-
-INT Show_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pBuf)
-{
- INT idx;
- UCHAR PMK[32] = {0};
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
-#endif // CONFIG_STA_SUPPORT //
-
- sprintf(pBuf, "\tPMK = ");
- for (idx = 0; idx < 32; idx++)
- sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);
-
- return 0;
-}
-
+#include "../../rt2870/common/cmm_info.c"
diff --git a/drivers/staging/rt3070/common/cmm_sanity.c b/drivers/staging/rt3070/common/cmm_sanity.c
index 6118df8de7bb..82ccf9e85f32 100644
--- a/drivers/staging/rt3070/common/cmm_sanity.c
+++ b/drivers/staging/rt3070/common/cmm_sanity.c
@@ -1,1669 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sanity.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 add WMM support
-*/
-#include "../rt_config.h"
-
-
-extern UCHAR CISCO_OUI[];
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR BROADCOM_OUI[];
-extern UCHAR WPS_OUI[];
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN MlmeAddBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2)
-{
- PMLME_ADDBA_REQ_STRUCT pInfo;
-
- pInfo = (MLME_ADDBA_REQ_STRUCT *)Msg;
-
- if ((MsgLen != sizeof(MLME_ADDBA_REQ_STRUCT)))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - message lenght not correct.\n"));
- return FALSE;
- }
-
- if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - The peer Mac is not associated yet.\n"));
- return FALSE;
- }
-
- /*
- if ((pInfo->BaBufSize > MAX_RX_REORDERBUF) || (pInfo->BaBufSize < 2))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - Rx Reordering buffer too big or too small\n"));
- return FALSE;
- }
- */
-
- if ((pInfo->pAddr[0]&0x01) == 0x01)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - broadcast address not support BA\n"));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN MlmeDelBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen)
-{
- MLME_DELBA_REQ_STRUCT *pInfo;
- pInfo = (MLME_DELBA_REQ_STRUCT *)Msg;
-
- if ((MsgLen != sizeof(MLME_DELBA_REQ_STRUCT)))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - message lenght not correct.\n"));
- return FALSE;
- }
-
- if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer Mac is not associated yet.\n"));
- return FALSE;
- }
-
- if ((pInfo->TID & 0xf0))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer TID is incorrect.\n"));
- return FALSE;
- }
-
- if (NdisEqualMemory(pAd->MacTab.Content[pInfo->Wcid].Addr, pInfo->Addr, MAC_ADDR_LEN) == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - the peer addr dosen't exist.\n"));
- return FALSE;
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerAddBAReqActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PFRAME_ADDBA_REQ pAddFrame;
- pAddFrame = (PFRAME_ADDBA_REQ)(pMsg);
- if (MsgLen < (sizeof(FRAME_ADDBA_REQ)))
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
- // we support immediate BA.
- *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
- pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
- pAddFrame->BaStartSeq.word = cpu2le16(pAddFrame->BaStartSeq.word);
-
- if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request Ba Policy[%d] not support\n", pAddFrame->BaParm.BAPolicy));
- DBGPRINT(RT_DEBUG_ERROR,("ADDBA Request. tid=%x, Bufsize=%x, AMSDUSupported=%x \n", pAddFrame->BaParm.TID, pAddFrame->BaParm.BufSize, pAddFrame->BaParm.AMSDUSupported));
- return FALSE;
- }
-
- // we support immediate BA.
- if (pAddFrame->BaParm.TID &0xfff0)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Request incorrect TID = %d\n", pAddFrame->BaParm.TID));
- return FALSE;
- }
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- return TRUE;
-}
-
-BOOLEAN PeerAddBARspActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen)
-{
- //PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PFRAME_ADDBA_RSP pAddFrame;
-
- pAddFrame = (PFRAME_ADDBA_RSP)(pMsg);
- if (MsgLen < (sizeof(FRAME_ADDBA_RSP)))
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBARspActionSanity: ADDBA Response frame length size = %ld incorrect\n", MsgLen));
- return FALSE;
- }
- // we support immediate BA.
- *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
- pAddFrame->StatusCode = cpu2le16(pAddFrame->StatusCode);
- pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
-
- if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBAReqActionSanity: ADDBA Response Ba Policy[%d] not support\n", pAddFrame->BaParm.BAPolicy));
- return FALSE;
- }
-
- // we support immediate BA.
- if (pAddFrame->BaParm.TID &0xfff0)
- {
- DBGPRINT(RT_DEBUG_ERROR,("PeerAddBARspActionSanity: ADDBA Response incorrect TID = %d\n", pAddFrame->BaParm.TID));
- return FALSE;
- }
- return TRUE;
-
-}
-
-BOOLEAN PeerDelBAActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN VOID *pMsg,
- IN ULONG MsgLen )
-{
- //PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PFRAME_DELBA_REQ pDelFrame;
- if (MsgLen != (sizeof(FRAME_DELBA_REQ)))
- return FALSE;
-
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- pDelFrame = (PFRAME_DELBA_REQ)(pMsg);
-
- *(USHORT *)(&pDelFrame->DelbaParm) = cpu2le16(*(USHORT *)(&pDelFrame->DelbaParm));
- pDelFrame->ReasonCode = cpu2le16(pDelFrame->ReasonCode);
-
- if (pDelFrame->DelbaParm.TID &0xfff0)
- return FALSE;
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerBeaconAndProbeRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- IN UCHAR MsgChannel,
- OUT PUCHAR pAddr2,
- OUT PUCHAR pBssid,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen,
- OUT UCHAR *pBssType,
- OUT USHORT *pBeaconPeriod,
- OUT UCHAR *pChannel,
- OUT UCHAR *pNewChannel,
- OUT LARGE_INTEGER *pTimestamp,
- OUT CF_PARM *pCfParm,
- OUT USHORT *pAtimWin,
- OUT USHORT *pCapabilityInfo,
- OUT UCHAR *pErp,
- OUT UCHAR *pDtimCount,
- OUT UCHAR *pDtimPeriod,
- OUT UCHAR *pBcastFlag,
- OUT UCHAR *pMessageToMe,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT UCHAR *pCkipFlag,
- OUT UCHAR *pAironetCellPowerLimit,
- OUT PEDCA_PARM pEdcaParm,
- OUT PQBSS_LOAD_PARM pQbssLoad,
- OUT PQOS_CAPABILITY_PARM pQosCapability,
- OUT ULONG *pRalinkIe,
- OUT UCHAR *pHtCapabilityLen,
-#ifdef CONFIG_STA_SUPPORT
- OUT UCHAR *pPreNHtCapabilityLen,
-#endif // CONFIG_STA_SUPPORT //
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT UCHAR *AddHtInfoLen,
- OUT ADD_HT_INFO_IE *AddHtInfo,
- OUT UCHAR *NewExtChannelOffset, // Ht extension channel offset(above or below)
- OUT USHORT *LengthVIE,
- OUT PNDIS_802_11_VARIABLE_IEs pVIE)
-{
- CHAR *Ptr;
-#ifdef CONFIG_STA_SUPPORT
- CHAR TimLen;
-#endif // CONFIG_STA_SUPPORT //
- PFRAME_802_11 pFrame;
- PEID_STRUCT pEid;
- UCHAR SubType;
- UCHAR Sanity;
- //UCHAR ECWMin, ECWMax;
- //MAC_CSR9_STRUC Csr9;
- ULONG Length = 0;
-
- // For some 11a AP which didn't have DS_IE, we use two conditions to decide the channel
- // 1. If the AP is 11n enabled, then check the control channel.
- // 2. If the AP didn't have any info about channel, use the channel we received this frame as the channel. (May inaccuracy!!)
- UCHAR CtrlChannel = 0;
-
- // Add for 3 necessary EID field check
- Sanity = 0;
-
- *pAtimWin = 0;
- *pErp = 0;
- *pDtimCount = 0;
- *pDtimPeriod = 0;
- *pBcastFlag = 0;
- *pMessageToMe = 0;
- *pExtRateLen = 0;
- *pCkipFlag = 0; // Default of CkipFlag is 0
- *pAironetCellPowerLimit = 0xFF; // Default of AironetCellPowerLimit is 0xFF
- *LengthVIE = 0; // Set the length of VIE to init value 0
- *pHtCapabilityLen = 0; // Set the length of VIE to init value 0
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->OpMode == OPMODE_STA)
- *pPreNHtCapabilityLen = 0; // Set the length of VIE to init value 0
-#endif // CONFIG_STA_SUPPORT //
- *AddHtInfoLen = 0; // Set the length of VIE to init value 0
- *pRalinkIe = 0;
- *pNewChannel = 0;
- *NewExtChannelOffset = 0xff; //Default 0xff means no such IE
- pCfParm->bValid = FALSE; // default: no IE_CF found
- pQbssLoad->bValid = FALSE; // default: no IE_QBSS_LOAD found
- pEdcaParm->bValid = FALSE; // default: no IE_EDCA_PARAMETER found
- pQosCapability->bValid = FALSE; // default: no IE_QOS_CAPABILITY found
-
- pFrame = (PFRAME_802_11)Msg;
-
- // get subtype from header
- SubType = (UCHAR)pFrame->Hdr.FC.SubType;
-
- // get Addr2 and BSSID from header
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- COPY_MAC_ADDR(pBssid, pFrame->Hdr.Addr3);
-
-// hex_dump("Beacon", Msg, MsgLen);
-
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- // get timestamp from payload and advance the pointer
- NdisMoveMemory(pTimestamp, Ptr, TIMESTAMP_LEN);
-
- pTimestamp->u.LowPart = cpu2le32(pTimestamp->u.LowPart);
- pTimestamp->u.HighPart = cpu2le32(pTimestamp->u.HighPart);
-
- Ptr += TIMESTAMP_LEN;
- Length += TIMESTAMP_LEN;
-
- // get beacon interval from payload and advance the pointer
- NdisMoveMemory(pBeaconPeriod, Ptr, 2);
- Ptr += 2;
- Length += 2;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
- Length += 2;
-
- if (CAP_IS_ESS_ON(*pCapabilityInfo))
- *pBssType = BSS_INFRA;
- else
- *pBssType = BSS_ADHOC;
-
- pEid = (PEID_STRUCT) Ptr;
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- //
- // Secure copy VIE to VarIE[MAX_VIE_LEN] didn't overflow.
- //
- if ((*LengthVIE + pEid->Len + 2) >= MAX_VIE_LEN)
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - Variable IEs out of resource [len(=%d) > MAX_VIE_LEN(=%d)]\n",
- (*LengthVIE + pEid->Len + 2), MAX_VIE_LEN));
- break;
- }
-
- switch(pEid->Eid)
- {
- case IE_SSID:
- // Already has one SSID EID in this beacon, ignore the second one
- if (Sanity & 0x1)
- break;
- if(pEid->Len <= MAX_LEN_OF_SSID)
- {
- NdisMoveMemory(Ssid, pEid->Octet, pEid->Len);
- *pSsidLen = pEid->Len;
- Sanity |= 0x1;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
-
- case IE_SUPP_RATES:
- if(pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- Sanity |= 0x2;
- NdisMoveMemory(SupRate, pEid->Octet, pEid->Len);
- *pSupRateLen = pEid->Len;
-
- // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
- // from ScanTab. We should report as is. And filter out unsupported
- // rates in MlmeAux.
- // Check against the supported rates
- // RTMPCheckRates(pAd, SupRate, pSupRateLen);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SUPP_RATES (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
-
- case IE_HT_CAP:
- if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
- {
- NdisMoveMemory(pHtCapability, pEid->Octet, sizeof(HT_CAPABILITY_IE));
- *pHtCapabilityLen = SIZE_HT_CAP_IE; // Nnow we only support 26 bytes.
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- *pPreNHtCapabilityLen = 0; // Nnow we only support 26 bytes.
-
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_HT_CAP. pEid->Len = %d\n", pEid->Len));
- }
-
- break;
- case IE_ADD_HT:
- if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
- {
- // This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
- // copy first sizeof(ADD_HT_INFO_IE)
- NdisMoveMemory(AddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
- *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
-
- CtrlChannel = AddHtInfo->ControlChan;
-
- *(USHORT *)(&AddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo2));
- *(USHORT *)(&AddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo3));
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_ADD_HT. \n"));
- }
-
- break;
- case IE_SECONDARY_CH_OFFSET:
- if (pEid->Len == 1)
- {
- *NewExtChannelOffset = pEid->Octet[0];
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
- }
-
- break;
- case IE_FH_PARM:
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n"));
- break;
-
- case IE_DS_PARM:
- if(pEid->Len == 1)
- {
- *pChannel = *pEid->Octet;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (ChannelSanity(pAd, *pChannel) == 0)
- {
-
- return FALSE;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- Sanity |= 0x4;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
-
- case IE_CF_PARM:
- if(pEid->Len == 6)
- {
- pCfParm->bValid = TRUE;
- pCfParm->CfpCount = pEid->Octet[0];
- pCfParm->CfpPeriod = pEid->Octet[1];
- pCfParm->CfpMaxDuration = pEid->Octet[2] + 256 * pEid->Octet[3];
- pCfParm->CfpDurRemaining = pEid->Octet[4] + 256 * pEid->Octet[5];
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_CF_PARM\n"));
- return FALSE;
- }
- break;
-
- case IE_IBSS_PARM:
- if(pEid->Len == 2)
- {
- NdisMoveMemory(pAtimWin, pEid->Octet, pEid->Len);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_IBSS_PARM\n"));
- return FALSE;
- }
- break;
-
-#ifdef CONFIG_STA_SUPPORT
- case IE_TIM:
- if(INFRA_ON(pAd) && SubType == SUBTYPE_BEACON)
- {
- GetTimBit((PUCHAR)pEid, pAd->StaActive.Aid, &TimLen, pBcastFlag, pDtimCount, pDtimPeriod, pMessageToMe);
- }
- break;
-#endif // CONFIG_STA_SUPPORT //
- case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
- if(pEid->Len == 3)
- {
- *pNewChannel = pEid->Octet[1]; //extract new channel number
- }
- break;
-
- // New for WPA
- // CCX v2 has the same IE, we need to parse that too
- // Wifi WMM use the same IE vale, need to parse that too
- // case IE_WPA:
- case IE_VENDOR_SPECIFIC:
- // Check Broadcom/Atheros 802.11n OUI version, for HT Capability IE.
- // This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
- /*if (NdisEqualMemory(pEid->Octet, BROADCOM_OUI, 3) && (pEid->Len >= 4))
- {
- if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 30))
- {
- {
- NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(HT_CAPABILITY_IE));
- *pHtCapabilityLen = SIZE_HT_CAP_IE; // Nnow we only support 26 bytes.
- }
- }
- if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 26))
- {
- {
- NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(ADD_HT_INFO_IE));
- *AddHtInfoLen = SIZE_ADD_HT_INFO_IE; // Nnow we only support 26 bytes.
- }
- }
- }
- */
- // Check the OUI version, filter out non-standard usage
- if (NdisEqualMemory(pEid->Octet, RALINK_OUI, 3) && (pEid->Len == 7))
- {
- //*pRalinkIe = pEid->Octet[3];
- if (pEid->Octet[3] != 0)
- *pRalinkIe = pEid->Octet[3];
- else
- *pRalinkIe = 0xf0000000; // Set to non-zero value (can't set bit0-2) to represent this is Ralink Chip. So at linkup, we will set ralinkchip flag.
- }
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
- // This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
-
- // Other vendors had production before IE_HT_CAP value is assigned. To backward support those old-firmware AP,
- // Check broadcom-defiend pre-802.11nD1.0 OUI for HT related IE, including HT Capatilities IE and HT Information IE
- else if ((*pHtCapabilityLen == 0) && NdisEqualMemory(pEid->Octet, PRE_N_HT_OUI, 3) && (pEid->Len >= 4) && (pAd->OpMode == OPMODE_STA))
- {
- if ((pEid->Octet[3] == OUI_PREN_HT_CAP) && (pEid->Len >= 30) && (*pHtCapabilityLen == 0))
- {
- NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(HT_CAPABILITY_IE));
- *pPreNHtCapabilityLen = SIZE_HT_CAP_IE;
- }
-
- if ((pEid->Octet[3] == OUI_PREN_ADD_HT) && (pEid->Len >= 26))
- {
- NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(ADD_HT_INFO_IE));
- *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
- }
- }
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
- else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- {
- // Copy to pVIE which will report to microsoft bssid list.
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
- else if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
- {
- PUCHAR ptr;
- int i;
-
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
- ptr = &pEid->Octet[8];
- for (i=0; i<4; i++)
- {
- UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
- pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
- pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
- pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
- pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
- pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
- ptr += 4; // point to next AC
- }
- }
- else if (NdisEqualMemory(pEid->Octet, WME_INFO_ELEM, 6) && (pEid->Len == 7))
- {
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
-
- // use default EDCA parameter
- pEdcaParm->bACM[QID_AC_BE] = 0;
- pEdcaParm->Aifsn[QID_AC_BE] = 3;
- pEdcaParm->Cwmin[QID_AC_BE] = CW_MIN_IN_BITS;
- pEdcaParm->Cwmax[QID_AC_BE] = CW_MAX_IN_BITS;
- pEdcaParm->Txop[QID_AC_BE] = 0;
-
- pEdcaParm->bACM[QID_AC_BK] = 0;
- pEdcaParm->Aifsn[QID_AC_BK] = 7;
- pEdcaParm->Cwmin[QID_AC_BK] = CW_MIN_IN_BITS;
- pEdcaParm->Cwmax[QID_AC_BK] = CW_MAX_IN_BITS;
- pEdcaParm->Txop[QID_AC_BK] = 0;
-
- pEdcaParm->bACM[QID_AC_VI] = 0;
- pEdcaParm->Aifsn[QID_AC_VI] = 2;
- pEdcaParm->Cwmin[QID_AC_VI] = CW_MIN_IN_BITS-1;
- pEdcaParm->Cwmax[QID_AC_VI] = CW_MAX_IN_BITS;
- pEdcaParm->Txop[QID_AC_VI] = 96; // AC_VI: 96*32us ~= 3ms
-
- pEdcaParm->bACM[QID_AC_VO] = 0;
- pEdcaParm->Aifsn[QID_AC_VO] = 2;
- pEdcaParm->Cwmin[QID_AC_VO] = CW_MIN_IN_BITS-2;
- pEdcaParm->Cwmax[QID_AC_VO] = CW_MAX_IN_BITS-1;
- pEdcaParm->Txop[QID_AC_VO] = 48; // AC_VO: 48*32us ~= 1.5ms
- }
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- else
- {
- }
-
- break;
-
- case IE_EXT_SUPP_RATES:
- if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
- *pExtRateLen = pEid->Len;
-
- // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
- // from ScanTab. We should report as is. And filter out unsupported
- // rates in MlmeAux.
- // Check against the supported rates
- // RTMPCheckRates(pAd, ExtRate, pExtRateLen);
- }
- break;
-
- case IE_ERP:
- if (pEid->Len == 1)
- {
- *pErp = (UCHAR)pEid->Octet[0];
- }
- break;
-
- case IE_AIRONET_CKIP:
- // 0. Check Aironet IE length, it must be larger or equal to 28
- // Cisco AP350 used length as 28
- // Cisco AP12XX used length as 30
- if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
- break;
-
- // 1. Copy CKIP flag byte to buffer for process
- *pCkipFlag = *(pEid->Octet + 8);
- break;
-
- case IE_AP_TX_POWER:
- // AP Control of Client Transmit Power
- //0. Check Aironet IE length, it must be 6
- if (pEid->Len != 0x06)
- break;
-
- // Get cell power limit in dBm
- if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
- *pAironetCellPowerLimit = *(pEid->Octet + 4);
- break;
-
- // WPA2 & 802.11i RSN
- case IE_RSN:
- // There is no OUI for version anymore, check the group cipher OUI before copying
- if (RTMPEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- {
- // Copy to pVIE which will report to microsoft bssid list.
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- }
- break;
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- case IE_COUNTRY:
- Ptr = (PUCHAR) pVIE;
- NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
- *LengthVIE += (pEid->Len + 2);
- break;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
- default:
- break;
- }
-
- Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- // For some 11a AP. it did not have the channel EID, patch here
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- UCHAR LatchRfChannel = MsgChannel;
- if ((pAd->LatchRfRegs.Channel > 14) && ((Sanity & 0x4) == 0))
- {
- if (CtrlChannel != 0)
- *pChannel = CtrlChannel;
- else
- *pChannel = LatchRfChannel;
- Sanity |= 0x4;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (Sanity != 0x7)
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - missing field, Sanity=0x%02x\n", Sanity));
- return FALSE;
- }
- else
- {
- return TRUE;
- }
-
-}
-
-#ifdef DOT11N_DRAFT3
-/*
- ==========================================================================
- Description:
- MLME message sanity check for some IE addressed in 802.11n d3.03.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerBeaconAndProbeRspSanity2(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *RegClass)
-{
- CHAR *Ptr;
- PFRAME_802_11 pFrame;
- PEID_STRUCT pEid;
- ULONG Length = 0;
-
- pFrame = (PFRAME_802_11)Msg;
-
- *RegClass = 0;
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- // get timestamp from payload and advance the pointer
- Ptr += TIMESTAMP_LEN;
- Length += TIMESTAMP_LEN;
-
- // get beacon interval from payload and advance the pointer
- Ptr += 2;
- Length += 2;
-
- // get capability info from payload and advance the pointer
- Ptr += 2;
- Length += 2;
-
- pEid = (PEID_STRUCT) Ptr;
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- switch(pEid->Eid)
- {
- case IE_SUPP_REG_CLASS:
- if(pEid->Len > 0)
- {
- *RegClass = *pEid->Octet;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",pEid->Len));
- return FALSE;
- }
- break;
- }
-
- Length = Length + 2 + pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- return TRUE;
-
-}
-#endif // DOT11N_DRAFT3 //
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeScanReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *pBssType,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen,
- OUT UCHAR *pScanType)
-{
- MLME_SCAN_REQ_STRUCT *Info;
-
- Info = (MLME_SCAN_REQ_STRUCT *)(Msg);
- *pBssType = Info->BssType;
- *pSsidLen = Info->SsidLen;
- NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
- *pScanType = Info->ScanType;
-
- if ((*pBssType == BSS_INFRA || *pBssType == BSS_ADHOC || *pBssType == BSS_ANY)
- && (*pScanType == SCAN_ACTIVE || *pScanType == SCAN_PASSIVE
-#ifdef CONFIG_STA_SUPPORT
- || *pScanType == SCAN_CISCO_PASSIVE || *pScanType == SCAN_CISCO_ACTIVE
- || *pScanType == SCAN_CISCO_CHANNEL_LOAD || *pScanType == SCAN_CISCO_NOISE
-#endif // CONFIG_STA_SUPPORT //
- ))
- {
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqSanity fail - wrong BssType or ScanType\n"));
- return FALSE;
- }
-}
-
-// IRQL = DISPATCH_LEVEL
-UCHAR ChannelSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel)
-{
- int i;
-
- for (i = 0; i < pAd->ChannelListNum; i ++)
- {
- if (channel == pAd->ChannelList[i].Channel)
- return 1;
- }
- return 0;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerDeauthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pReason)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerAuthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT USHORT *pAlg,
- OUT USHORT *pSeq,
- OUT USHORT *pStatus,
- CHAR *pChlgText)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr, pFrame->Hdr.Addr2);
- NdisMoveMemory(pAlg, &pFrame->Octet[0], 2);
- NdisMoveMemory(pSeq, &pFrame->Octet[2], 2);
- NdisMoveMemory(pStatus, &pFrame->Octet[4], 2);
-
- if ((*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- )
- {
- if (*pSeq == 1 || *pSeq == 2)
- {
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
- return FALSE;
- }
- }
- else if (*pAlg == Ndis802_11AuthModeShared)
- {
- if (*pSeq == 1 || *pSeq == 4)
- {
- return TRUE;
- }
- else if (*pSeq == 2 || *pSeq == 3)
- {
- NdisMoveMemory(pChlgText, &pFrame->Octet[8], CIPHER_TEXT_LEN);
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
- return FALSE;
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong algorithm\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeAuthReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT ULONG *pTimeout,
- OUT USHORT *pAlg)
-{
- MLME_AUTH_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_AUTH_REQ_STRUCT *)Msg;
- COPY_MAC_ADDR(pAddr, pInfo->Addr);
- *pTimeout = pInfo->Timeout;
- *pAlg = pInfo->Alg;
-
- if (((*pAlg == Ndis802_11AuthModeShared) ||(*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- ) &&
- ((*pAddr & 0x01) == 0))
- {
- return TRUE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeAuthReqSanity fail - wrong algorithm\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN MlmeAssocReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pApAddr,
- OUT USHORT *pCapabilityInfo,
- OUT ULONG *pTimeout,
- OUT USHORT *pListenIntv)
-{
- MLME_ASSOC_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_ASSOC_REQ_STRUCT *)Msg;
- *pTimeout = pInfo->Timeout; // timeout
- COPY_MAC_ADDR(pApAddr, pInfo->Addr); // AP address
- *pCapabilityInfo = pInfo->CapabilityInfo; // capability info
- *pListenIntv = pInfo->ListenIntv;
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerDisassocSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pReason)
-{
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
-
- return TRUE;
-}
-
-/*
- ========================================================================
- Routine Description:
- Sanity check NetworkType (11b, 11g or 11a)
-
- Arguments:
- pBss - Pointer to BSS table.
-
- Return Value:
- Ndis802_11DS .......(11b)
- Ndis802_11OFDM24....(11g)
- Ndis802_11OFDM5.....(11a)
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
- IN PBSS_ENTRY pBss)
-{
- NDIS_802_11_NETWORK_TYPE NetWorkType;
- UCHAR rate, i;
-
- NetWorkType = Ndis802_11DS;
-
- if (pBss->Channel <= 14)
- {
- //
- // First check support Rate.
- //
- for (i = 0; i < pBss->SupRateLen; i++)
- {
- rate = pBss->SupRate[i] & 0x7f; // Mask out basic rate set bit
- if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
- {
- continue;
- }
- else
- {
- //
- // Otherwise (even rate > 108) means Ndis802_11OFDM24
- //
- NetWorkType = Ndis802_11OFDM24;
- break;
- }
- }
-
- //
- // Second check Extend Rate.
- //
- if (NetWorkType != Ndis802_11OFDM24)
- {
- for (i = 0; i < pBss->ExtRateLen; i++)
- {
- rate = pBss->SupRate[i] & 0x7f; // Mask out basic rate set bit
- if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
- {
- continue;
- }
- else
- {
- //
- // Otherwise (even rate > 108) means Ndis802_11OFDM24
- //
- NetWorkType = Ndis802_11OFDM24;
- break;
- }
- }
- }
- }
- else
- {
- NetWorkType = Ndis802_11OFDM5;
- }
-
- if (pBss->HtCapabilityLen != 0)
- {
- if (NetWorkType == Ndis802_11OFDM5)
- NetWorkType = Ndis802_11OFDM5_N;
- else
- NetWorkType = Ndis802_11OFDM24_N;
- }
-
- return NetWorkType;
-}
-
-/*
- ==========================================================================
- Description:
- WPA message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN PeerWpaMessageSanity(
- IN PRTMP_ADAPTER pAd,
- IN PEAPOL_PACKET pMsg,
- IN ULONG MsgLen,
- IN UCHAR MsgType,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- UCHAR mic[LEN_KEY_DESC_MIC], digest[80], KEYDATA[MAX_LEN_OF_RSNIE];
- BOOLEAN bReplayDiff = FALSE;
- BOOLEAN bWPA2 = FALSE;
- KEY_INFO EapolKeyInfo;
- UCHAR GroupKeyIndex = 0;
-
-
- NdisZeroMemory(mic, sizeof(mic));
- NdisZeroMemory(digest, sizeof(digest));
- NdisZeroMemory(KEYDATA, sizeof(KEYDATA));
- NdisZeroMemory((PUCHAR)&EapolKeyInfo, sizeof(EapolKeyInfo));
-
- NdisMoveMemory((PUCHAR)&EapolKeyInfo, (PUCHAR)&pMsg->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT *)&EapolKeyInfo) = cpu2le16(*((USHORT *)&EapolKeyInfo));
-
- // Choose WPA2 or not
- if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
- bWPA2 = TRUE;
-
- // 0. Check MsgType
- if ((MsgType > EAPOL_GROUP_MSG_2) || (MsgType < EAPOL_PAIR_MSG_1))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("The message type is invalid(%d)! \n", MsgType));
- return FALSE;
- }
-
- // 1. Replay counter check
- if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1) // For supplicant
- {
- // First validate replay counter, only accept message with larger replay counter.
- // Let equal pass, some AP start with all zero replay counter
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
-
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
- if ((RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- {
- bReplayDiff = TRUE;
- }
- }
- else if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2) // For authenticator
- {
- // check Replay Counter coresponds to MSG from authenticator, otherwise discard
- if (!NdisEqualMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY))
- {
- bReplayDiff = TRUE;
- }
- }
-
- // Replay Counter different condition
- if (bReplayDiff)
- {
- // send wireless event - for replay counter different
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_REPLAY_COUNTER_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
-
- if (MsgType < EAPOL_GROUP_MSG_1)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in pairwise msg %d of 4-way handshake!\n", MsgType));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
- }
-
- hex_dump("Receive replay counter ", pMsg->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- hex_dump("Current replay counter ", pEntry->R_Counter, LEN_KEY_DESC_REPLAY);
- return FALSE;
- }
-
- // 2. Verify MIC except Pairwise Msg1
- if (MsgType != EAPOL_PAIR_MSG_1)
- {
- UCHAR rcvd_mic[LEN_KEY_DESC_MIC];
-
- // Record the received MIC for check later
- NdisMoveMemory(rcvd_mic, pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
- if (pEntry->WepStatus == Ndis802_11Encryption2Enabled) // TKIP
- {
- hmac_md5(pEntry->PTK, LEN_EAP_MICK, (PUCHAR)pMsg, MsgLen, mic);
- }
- else if (pEntry->WepStatus == Ndis802_11Encryption3Enabled) // AES
- {
- HMAC_SHA1((PUCHAR)pMsg, MsgLen, pEntry->PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
- }
-
- if (!NdisEqualMemory(rcvd_mic, mic, LEN_KEY_DESC_MIC))
- {
- // send wireless event - for MIC different
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_MIC_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
-
- if (MsgType < EAPOL_GROUP_MSG_1)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in pairwise msg %d of 4-way handshake!\n", MsgType));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
- }
-
- hex_dump("Received MIC", rcvd_mic, LEN_KEY_DESC_MIC);
- hex_dump("Desired MIC", mic, LEN_KEY_DESC_MIC);
-
- return FALSE;
- }
- }
-
- // Extract the context of the Key Data field if it exist
- // The field in pairwise_msg_2_WPA1(WPA2) & pairwise_msg_3_WPA1 is un-encrypted.
- // The field in group_msg_1_WPA1(WPA2) & pairwise_msg_3_WPA2 is encrypted.
- if (pMsg->KeyDesc.KeyDataLen[1] > 0)
- {
- // Decrypt this field
- if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
- {
- if(pEntry->WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA, pMsg->KeyDesc.KeyDataLen[1],pMsg->KeyDesc.KeyData);
- }
- else
- {
- INT i;
- UCHAR Key[32];
- // Decrypt TKIP GTK
- // Construct 32 bytes RC4 Key
- NdisMoveMemory(Key, pMsg->KeyDesc.KeyIv, 16);
- NdisMoveMemory(&Key[16], &pEntry->PTK[16], 16);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
- //discard first 256 bytes
- for(i = 0; i < 256; i++)
- ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
- // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
- }
-
- if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
- GroupKeyIndex = EapolKeyInfo.KeyIndex;
-
- }
- else if ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3 && !bWPA2))
- {
- NdisMoveMemory(KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
- }
- else
- {
-
- return TRUE;
- }
-
- // Parse Key Data field to
- // 1. verify RSN IE for pairwise_msg_2_WPA1(WPA2) ,pairwise_msg_3_WPA1(WPA2)
- // 2. verify KDE format for pairwise_msg_3_WPA2, group_msg_1_WPA2
- // 3. update shared key for pairwise_msg_3_WPA2, group_msg_1_WPA1(WPA2)
- if (!RTMPParseEapolKeyData(pAd, KEYDATA, pMsg->KeyDesc.KeyDataLen[1], GroupKeyIndex, MsgType, bWPA2, pEntry))
- {
- return FALSE;
- }
- }
-
- return TRUE;
-
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN MlmeDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PRT_802_11_DLS *pDLS,
- OUT PUSHORT pReason)
-{
- MLME_DLS_REQ_STRUCT *pInfo;
-
- pInfo = (MLME_DLS_REQ_STRUCT *)Msg;
-
- *pDLS = pInfo->pDLS;
- *pReason = pInfo->Reason;
-
- return TRUE;
-}
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN PeerDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pDlsTimeout,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
- PEID_STRUCT eid_ptr;
-
- // to prevent caller from using garbage output value
- *pCapabilityInfo = 0;
- *pDlsTimeout = 0;
- *pHtCapabilityLen = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
-
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pDlsTimeout, Ptr, 2);
- Ptr += 2;
-
- // Category and Action field + DA + SA + capability + Timeout
- eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
-
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_SUPP_RATES:
- if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
- {
- NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
- DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
- *pRatesLen = eid_ptr->Len;
- }
- else
- {
- *pRatesLen = 8;
- Rates[0] = 0x82;
- Rates[1] = 0x84;
- Rates[2] = 0x8b;
- Rates[3] = 0x96;
- Rates[4] = 0x12;
- Rates[5] = 0x24;
- Rates[6] = 0x48;
- Rates[7] = 0x6c;
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
- *pRatesLen = (*pRatesLen) + eid_ptr->Len;
- }
- else
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
- *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
- }
- break;
-
- case IE_HT_CAP:
- if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
- {
- NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
- *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_HT_CAP\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
- }
- break;
-
- default:
- break;
- }
-
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerDlsRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
- PEID_STRUCT eid_ptr;
-
- // to prevent caller from using garbage output value
- *pStatus = 0;
- *pCapabilityInfo = 0;
- *pHtCapabilityLen = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get status code from payload and advance the pointer
- NdisMoveMemory(pStatus, Ptr, 2);
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- if (pStatus == 0)
- {
- // get capability info from payload and advance the pointer
- NdisMoveMemory(pCapabilityInfo, Ptr, 2);
- Ptr += 2;
- }
-
- // Category and Action field + status code + DA + SA + capability
- eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
-
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_SUPP_RATES:
- if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
- {
- NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
- DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
- *pRatesLen = eid_ptr->Len;
- }
- else
- {
- *pRatesLen = 8;
- Rates[0] = 0x82;
- Rates[1] = 0x84;
- Rates[2] = 0x8b;
- Rates[3] = 0x96;
- Rates[4] = 0x12;
- Rates[5] = 0x24;
- Rates[6] = 0x48;
- Rates[7] = 0x6c;
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
- }
- break;
-
- case IE_EXT_SUPP_RATES:
- if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
- *pRatesLen = (*pRatesLen) + eid_ptr->Len;
- }
- else
- {
- NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
- *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
- }
- break;
-
- case IE_HT_CAP:
- if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
- {
- NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
- *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_HT_CAP\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
- }
- break;
-
- default:
- break;
- }
-
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return TRUE;
-}
-
-BOOLEAN PeerDlsTearDownSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pReason)
-{
- CHAR *Ptr;
- PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
-
- // to prevent caller from using garbage output value
- *pReason = 0;
-
- Ptr = Fr->Octet;
-
- // offset to destination MAC address (Category and Action field)
- Ptr += 2;
-
- // get DA from payload and advance the pointer
- NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get SA from payload and advance the pointer
- NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
- Ptr += MAC_ADDR_LEN;
-
- // get reason code from payload and advance the pointer
- NdisMoveMemory(pReason, Ptr, 2);
- Ptr += 2;
-
- return TRUE;
-}
-#endif // QOS_DLS_SUPPORT //
-
+#include "../../rt2870/common/cmm_sanity.c"
diff --git a/drivers/staging/rt3070/common/cmm_sync.c b/drivers/staging/rt3070/common/cmm_sync.c
index 2be7c77a384e..3b517420f48d 100644
--- a/drivers/staging/rt3070/common/cmm_sync.c
+++ b/drivers/staging/rt3070/common/cmm_sync.c
@@ -1,711 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sync.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 modified for rt2561/2661
-*/
-#include "../rt_config.h"
-
-// 2.4 Ghz channel plan index in the TxPower arrays.
-#define BG_BAND_REGION_0_START 0 // 1,2,3,4,5,6,7,8,9,10,11
-#define BG_BAND_REGION_0_SIZE 11
-#define BG_BAND_REGION_1_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13
-#define BG_BAND_REGION_1_SIZE 13
-#define BG_BAND_REGION_2_START 9 // 10,11
-#define BG_BAND_REGION_2_SIZE 2
-#define BG_BAND_REGION_3_START 9 // 10,11,12,13
-#define BG_BAND_REGION_3_SIZE 4
-#define BG_BAND_REGION_4_START 13 // 14
-#define BG_BAND_REGION_4_SIZE 1
-#define BG_BAND_REGION_5_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
-#define BG_BAND_REGION_5_SIZE 14
-#define BG_BAND_REGION_6_START 2 // 3,4,5,6,7,8,9
-#define BG_BAND_REGION_6_SIZE 7
-#define BG_BAND_REGION_7_START 4 // 5,6,7,8,9,10,11,12,13
-#define BG_BAND_REGION_7_SIZE 9
-#define BG_BAND_REGION_31_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
-#define BG_BAND_REGION_31_SIZE 14
-
-// 5 Ghz channel plan index in the TxPower arrays.
-UCHAR A_BAND_REGION_0_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_1_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
-UCHAR A_BAND_REGION_2_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64};
-UCHAR A_BAND_REGION_3_CHANNEL_LIST[]={52, 56, 60, 64, 149, 153, 157, 161};
-UCHAR A_BAND_REGION_4_CHANNEL_LIST[]={149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_5_CHANNEL_LIST[]={149, 153, 157, 161};
-UCHAR A_BAND_REGION_6_CHANNEL_LIST[]={36, 40, 44, 48};
-UCHAR A_BAND_REGION_7_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_8_CHANNEL_LIST[]={52, 56, 60, 64};
-UCHAR A_BAND_REGION_9_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_10_CHANNEL_LIST[]={36, 40, 44, 48, 149, 153, 157, 161, 165};
-UCHAR A_BAND_REGION_11_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161};
-
-//BaSizeArray follows the 802.11n definition as MaxRxFactor. 2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8.
-UCHAR BaSizeArray[4] = {8,16,32,64};
-
-/*
- ==========================================================================
- Description:
- Update StaCfg->ChannelList[] according to 1) Country Region 2) RF IC type,
- and 3) PHY-mode user selected.
- The outcome is used by driver when doing site survey.
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID BuildChannelList(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i, j, index=0, num=0;
- PUCHAR pChannelList = NULL;
-
- NdisZeroMemory(pAd->ChannelList, MAX_NUM_OF_CHANNELS * sizeof(CHANNEL_TX_POWER));
-
- // if not 11a-only mode, channel list starts from 2.4Ghz band
- if ((pAd->CommonCfg.PhyMode != PHY_11A)
-#ifdef DOT11_N_SUPPORT
- && (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED) && (pAd->CommonCfg.PhyMode != PHY_11N_5G)
-#endif // DOT11_N_SUPPORT //
- )
- {
- switch (pAd->CommonCfg.CountryRegion & 0x7f)
- {
- case REGION_0_BG_BAND: // 1 -11
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_0_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_0_SIZE);
- index += BG_BAND_REGION_0_SIZE;
- break;
- case REGION_1_BG_BAND: // 1 - 13
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_1_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_1_SIZE);
- index += BG_BAND_REGION_1_SIZE;
- break;
- case REGION_2_BG_BAND: // 10 - 11
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_2_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_2_SIZE);
- index += BG_BAND_REGION_2_SIZE;
- break;
- case REGION_3_BG_BAND: // 10 - 13
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_3_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_3_SIZE);
- index += BG_BAND_REGION_3_SIZE;
- break;
- case REGION_4_BG_BAND: // 14
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_4_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_4_SIZE);
- index += BG_BAND_REGION_4_SIZE;
- break;
- case REGION_5_BG_BAND: // 1 - 14
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_5_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_5_SIZE);
- index += BG_BAND_REGION_5_SIZE;
- break;
- case REGION_6_BG_BAND: // 3 - 9
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_6_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_6_SIZE);
- index += BG_BAND_REGION_6_SIZE;
- break;
- case REGION_7_BG_BAND: // 5 - 13
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_7_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_7_SIZE);
- index += BG_BAND_REGION_7_SIZE;
- break;
- case REGION_31_BG_BAND: // 1 - 14
- NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_31_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_31_SIZE);
- index += BG_BAND_REGION_31_SIZE;
- break;
- default: // Error. should never happen
- break;
- }
- for (i=0; i<index; i++)
- pAd->ChannelList[i].MaxTxPwr = 20;
- }
-
- if ((pAd->CommonCfg.PhyMode == PHY_11A) || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-#ifdef DOT11_N_SUPPORT
- || (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
- || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)
-#endif // DOT11_N_SUPPORT //
- )
- {
- switch (pAd->CommonCfg.CountryRegionForABand & 0x7f)
- {
- case REGION_0_A_BAND:
- num = sizeof(A_BAND_REGION_0_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_0_CHANNEL_LIST;
- break;
- case REGION_1_A_BAND:
- num = sizeof(A_BAND_REGION_1_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_1_CHANNEL_LIST;
- break;
- case REGION_2_A_BAND:
- num = sizeof(A_BAND_REGION_2_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_2_CHANNEL_LIST;
- break;
- case REGION_3_A_BAND:
- num = sizeof(A_BAND_REGION_3_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_3_CHANNEL_LIST;
- break;
- case REGION_4_A_BAND:
- num = sizeof(A_BAND_REGION_4_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_4_CHANNEL_LIST;
- break;
- case REGION_5_A_BAND:
- num = sizeof(A_BAND_REGION_5_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_5_CHANNEL_LIST;
- break;
- case REGION_6_A_BAND:
- num = sizeof(A_BAND_REGION_6_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_6_CHANNEL_LIST;
- break;
- case REGION_7_A_BAND:
- num = sizeof(A_BAND_REGION_7_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_7_CHANNEL_LIST;
- break;
- case REGION_8_A_BAND:
- num = sizeof(A_BAND_REGION_8_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_8_CHANNEL_LIST;
- break;
- case REGION_9_A_BAND:
- num = sizeof(A_BAND_REGION_9_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_9_CHANNEL_LIST;
- break;
-
- case REGION_10_A_BAND:
- num = sizeof(A_BAND_REGION_10_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_10_CHANNEL_LIST;
- break;
-
- case REGION_11_A_BAND:
- num = sizeof(A_BAND_REGION_11_CHANNEL_LIST)/sizeof(UCHAR);
- pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
- break;
-
- default: // Error. should never happen
- DBGPRINT(RT_DEBUG_WARN,("countryregion=%d not support", pAd->CommonCfg.CountryRegionForABand));
- break;
- }
-
- if (num != 0)
- {
- UCHAR RadarCh[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
- for (i=0; i<num; i++)
- {
- for (j=0; j<MAX_NUM_OF_CHANNELS; j++)
- {
- if (pChannelList[i] == pAd->TxPower[j].Channel)
- NdisMoveMemory(&pAd->ChannelList[index+i], &pAd->TxPower[j], sizeof(CHANNEL_TX_POWER));
- }
- for (j=0; j<15; j++)
- {
- if (pChannelList[i] == RadarCh[j])
- pAd->ChannelList[index+i].DfsReq = TRUE;
- }
- pAd->ChannelList[index+i].MaxTxPwr = 20;
- }
- index += num;
- }
- }
-
- pAd->ChannelListNum = index;
- DBGPRINT(RT_DEBUG_TRACE,("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
- pAd->CommonCfg.CountryRegion, pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType, pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
-#ifdef DBG
- for (i=0;i<pAd->ChannelListNum;i++)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE,("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ", pAd->ChannelList[i].Channel, pAd->ChannelList[i].Power, pAd->ChannelList[i].Power2));
- }
-#endif
-}
-
-/*
- ==========================================================================
- Description:
- This routine return the first channel number according to the country
- code selection and RF IC selection (signal band or dual band). It is called
- whenever driver need to start a site survey of all supported channels.
- Return:
- ch - the first channel number of current country code setting
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-UCHAR FirstChannel(
- IN PRTMP_ADAPTER pAd)
-{
- return pAd->ChannelList[0].Channel;
-}
-
-/*
- ==========================================================================
- Description:
- This routine returns the next channel number. This routine is called
- during driver need to start a site survey of all supported channels.
- Return:
- next_channel - the next channel number valid in current country code setting.
- Note:
- return 0 if no more next channel
- ==========================================================================
- */
-UCHAR NextChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel)
-{
- int i;
- UCHAR next_channel = 0;
-
- for (i = 0; i < (pAd->ChannelListNum - 1); i++)
- if (channel == pAd->ChannelList[i].Channel)
- {
- next_channel = pAd->ChannelList[i+1].Channel;
- break;
- }
- return next_channel;
-}
-
-/*
- ==========================================================================
- Description:
- This routine is for Cisco Compatible Extensions 2.X
- Spec31. AP Control of Client Transmit Power
- Return:
- None
- Note:
- Required by Aironet dBm(mW)
- 0dBm(1mW), 1dBm(5mW), 13dBm(20mW), 15dBm(30mW),
- 17dBm(50mw), 20dBm(100mW)
-
- We supported
- 3dBm(Lowest), 6dBm(10%), 9dBm(25%), 12dBm(50%),
- 14dBm(75%), 15dBm(100%)
-
- The client station's actual transmit power shall be within +/- 5dB of
- the minimum value or next lower value.
- ==========================================================================
- */
-VOID ChangeToCellPowerLimit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AironetCellPowerLimit)
-{
- //valud 0xFF means that hasn't found power limit information
- //from the AP's Beacon/Probe response.
- if (AironetCellPowerLimit == 0xFF)
- return;
-
- if (AironetCellPowerLimit < 6) //Used Lowest Power Percentage.
- pAd->CommonCfg.TxPowerPercentage = 6;
- else if (AironetCellPowerLimit < 9)
- pAd->CommonCfg.TxPowerPercentage = 10;
- else if (AironetCellPowerLimit < 12)
- pAd->CommonCfg.TxPowerPercentage = 25;
- else if (AironetCellPowerLimit < 14)
- pAd->CommonCfg.TxPowerPercentage = 50;
- else if (AironetCellPowerLimit < 15)
- pAd->CommonCfg.TxPowerPercentage = 75;
- else
- pAd->CommonCfg.TxPowerPercentage = 100; //else used maximum
-
- if (pAd->CommonCfg.TxPowerPercentage > pAd->CommonCfg.TxPowerDefault)
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
-
-}
-
-CHAR ConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- LNAGain = GET_LNA_GAIN(pAd);
- if (pAd->LatchRfRegs.Channel > 14)
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-12 - RssiOffset - LNAGain - Rssi);
-}
-
-/*
- ==========================================================================
- Description:
- Scan next channel
- ==========================================================================
- */
-VOID ScanNextChannel(
- IN PRTMP_ADAPTER pAd)
-{
- HEADER_802_11 Hdr80211;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- UCHAR SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
-#ifdef CONFIG_STA_SUPPORT
- USHORT Status;
- PHEADER_802_11 pHdr80211;
-#endif // CONFIG_STA_SUPPORT //
- UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (MONITOR_ON(pAd))
- return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- if (pAd->MlmeAux.Channel == 0)
- {
- if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
-#ifdef CONFIG_STA_SUPPORT
- && (INFRA_ON(pAd)
- || (pAd->OpMode == OPMODE_AP))
-#endif // CONFIG_STA_SUPPORT //
- )
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
- }
- else
- {
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //
- // To prevent data lost.
- // Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
- // Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done
- //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
- {
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- pHdr80211 = (PHEADER_802_11) pOutBuffer;
- MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pHdr80211->Duration = 0;
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame\n"));
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPusecDelay(5000);
- }
- }
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- }
-#ifdef RT2870
-#ifdef CONFIG_STA_SUPPORT
- else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->OpMode == OPMODE_STA))
- {
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
- }
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
- else
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // BBP and RF are not accessible in PS mode, we has to wake them up first
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- AsicForceWakeup(pAd, TRUE);
-
- // leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON
- if (pAd->StaCfg.Psm == PWR_SAVE)
- MlmeSetPsmBit(pAd, PWR_ACTIVE);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, TRUE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->MlmeAux.Channel > 14)
- {
- if ((pAd->CommonCfg.bIEEE80211H == 1) && RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
- {
- ScanType = SCAN_PASSIVE;
- ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
- }
- }
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // carrier detection
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- ScanType = SCAN_PASSIVE;
- ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
- }
-#endif // CARRIER_DETECTION_SUPPORT //
- }
-
-#endif // CONFIG_STA_SUPPORT //
-
- //Global country domain(ch1-11:active scan, ch12-14 passive scan)
- if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12) && ((pAd->CommonCfg.CountryRegion & 0x7f) == REGION_31_BG_BAND))
- {
- ScanType = SCAN_PASSIVE;
- }
-
- // We need to shorten active scan time in order for WZC connect issue
- // Chnage the channel scan time for CISCO stuff based on its IAPP announcement
- if (ScanType == FAST_SCAN_ACTIVE)
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, FAST_ACTIVE_SCAN_TIME);
-#ifdef CONFIG_STA_SUPPORT
- else if (((ScanType == SCAN_CISCO_ACTIVE) ||
- (ScanType == SCAN_CISCO_PASSIVE) ||
- (ScanType == SCAN_CISCO_CHANNEL_LOAD) ||
- (ScanType == SCAN_CISCO_NOISE)) && (pAd->OpMode == OPMODE_STA))
- {
- if (pAd->StaCfg.CCXScanTime < 25)
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime * 2);
- else
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, pAd->StaCfg.CCXScanTime);
- }
-#endif // CONFIG_STA_SUPPORT //
- else // must be SCAN_PASSIVE or SCAN_ACTIVE
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-#ifdef DOT11_N_SUPPORT
- || (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
-#endif // DOT11_N_SUPPORT //
- )
- {
- if (pAd->MlmeAux.Channel > 14)
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, ScanTimeIn5gChannel);
- else
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MIN_CHANNEL_TIME);
- }
- else
- RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MAX_CHANNEL_TIME);
- }
-
- if ((ScanType == SCAN_ACTIVE) || (ScanType == FAST_SCAN_ACTIVE) ||
- (ScanType == SCAN_CISCO_ACTIVE))
- {
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - ScanNextChannel() allocate memory fail\n"));
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return;
- }
-
- // There is no need to send broadcast probe request if active scan is in effect.
- if ((ScanType == SCAN_ACTIVE) || (ScanType == FAST_SCAN_ACTIVE)
- )
- SsidLen = pAd->MlmeAux.SsidLen;
- else
- SsidLen = 0;
-
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &SsidLen,
- SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &pAd->CommonCfg.SupRateLen,
- pAd->CommonCfg.SupRateLen, pAd->CommonCfg.SupRate,
- END_OF_ARGS);
-
- if (pAd->CommonCfg.ExtRateLen)
- {
- ULONG Tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtRateIe,
- 1, &pAd->CommonCfg.ExtRateLen,
- pAd->CommonCfg.ExtRateLen, pAd->CommonCfg.ExtRate,
- END_OF_ARGS);
- FrameLen += Tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- ULONG Tmp;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
- if (pAd->bBroadComHT == TRUE)
- {
- HtLen = pAd->MlmeAux.HtCapabilityLen + 4;
-#ifdef RT_BIG_ENDIAN
- NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#else
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
-#endif // RT_BIG_ENDIAN //
- }
- else
- {
- HtLen = pAd->MlmeAux.HtCapabilityLen;
-#ifdef RT_BIG_ENDIAN
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, SIZE_HT_CAP_IE);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#else
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#endif // RT_BIG_ENDIAN //
- }
- FrameLen += Tmp;
-
-#ifdef DOT11N_DRAFT3
- if (pAd->CommonCfg.BACapability.field.b2040CoexistScanSup == 1)
- {
- ULONG Tmp;
- HtLen = 1;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtHtCapIe,
- 1, &HtLen,
- 1, &pAd->CommonCfg.BSSCoexist2040.word,
- END_OF_ARGS);
-
- FrameLen += Tmp;
- }
-#endif // DOT11N_DRAFT3 //
- }
-#endif // DOT11_N_SUPPORT //
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
-
- // For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe reponse
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
-#endif // CONFIG_STA_SUPPORT //
-
- }
-}
-
-VOID MgtProbReqMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR SubType,
- IN UCHAR ToDs,
- IN PUCHAR pDA,
- IN PUCHAR pBssid)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-
- pHdr80211->FC.Type = BTYPE_MGMT;
- pHdr80211->FC.SubType = SubType;
- if (SubType == SUBTYPE_ACK)
- pHdr80211->FC.Type = BTYPE_CNTL;
- pHdr80211->FC.ToDs = ToDs;
- COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
-}
-
-
+#include "../../rt2870/common/cmm_sync.c"
diff --git a/drivers/staging/rt3070/common/cmm_wpa.c b/drivers/staging/rt3070/common/cmm_wpa.c
index 81c332ac2524..6483d329286d 100644
--- a/drivers/staging/rt3070/common/cmm_wpa.c
+++ b/drivers/staging/rt3070/common/cmm_wpa.c
@@ -1,1606 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- wpa.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 03-07-22 Initial
- Paul Lin 03-11-28 Modify for supplicant
-*/
-#include "../rt_config.h"
-// WPA OUI
-UCHAR OUI_WPA_NONE_AKM[4] = {0x00, 0x50, 0xF2, 0x00};
-UCHAR OUI_WPA_VERSION[4] = {0x00, 0x50, 0xF2, 0x01};
-UCHAR OUI_WPA_TKIP[4] = {0x00, 0x50, 0xF2, 0x02};
-UCHAR OUI_WPA_CCMP[4] = {0x00, 0x50, 0xF2, 0x04};
-UCHAR OUI_WPA_8021X_AKM[4] = {0x00, 0x50, 0xF2, 0x01};
-UCHAR OUI_WPA_PSK_AKM[4] = {0x00, 0x50, 0xF2, 0x02};
-// WPA2 OUI
-UCHAR OUI_WPA2_WEP40[4] = {0x00, 0x0F, 0xAC, 0x01};
-UCHAR OUI_WPA2_TKIP[4] = {0x00, 0x0F, 0xAC, 0x02};
-UCHAR OUI_WPA2_CCMP[4] = {0x00, 0x0F, 0xAC, 0x04};
-UCHAR OUI_WPA2_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x01};
-UCHAR OUI_WPA2_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x02};
-// MSA OUI
-UCHAR OUI_MSA_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x05}; // Not yet final - IEEE 802.11s-D1.06
-UCHAR OUI_MSA_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x06}; // Not yet final - IEEE 802.11s-D1.06
-
-/*
- ========================================================================
-
- Routine Description:
- The pseudo-random function(PRF) that hashes various inputs to
- derive a pseudo-random value. To add liveness to the pseudo-random
- value, a nonce should be one of the inputs.
-
- It is used to generate PTK, GTK or some specific random value.
-
- Arguments:
- UCHAR *key, - the key material for HMAC_SHA1 use
- INT key_len - the length of key
- UCHAR *prefix - a prefix label
- INT prefix_len - the length of the label
- UCHAR *data - a specific data with variable length
- INT data_len - the length of a specific data
- INT len - the output lenght
-
- Return Value:
- UCHAR *output - the calculated result
-
- Note:
- 802.11i-2004 Annex H.3
-
- ========================================================================
-*/
-VOID PRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *prefix,
- IN INT prefix_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len)
-{
- INT i;
- UCHAR *input;
- INT currentindex = 0;
- INT total_len;
-
- // Allocate memory for input
- os_alloc_mem(NULL, (PUCHAR *)&input, 1024);
-
- if (input == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!!PRF: no memory!!!\n"));
- return;
- }
-
- // Generate concatenation input
- NdisMoveMemory(input, prefix, prefix_len);
-
- // Concatenate a single octet containing 0
- input[prefix_len] = 0;
-
- // Concatenate specific data
- NdisMoveMemory(&input[prefix_len + 1], data, data_len);
- total_len = prefix_len + 1 + data_len;
-
- // Concatenate a single octet containing 0
- // This octet shall be update later
- input[total_len] = 0;
- total_len++;
-
- // Iterate to calculate the result by hmac-sha-1
- // Then concatenate to last result
- for (i = 0; i < (len + 19) / 20; i++)
- {
- HMAC_SHA1(input, total_len, key, key_len, &output[currentindex]);
- currentindex += 20;
-
- // update the last octet
- input[total_len - 1]++;
- }
- os_free_mem(NULL, input);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- It utilizes PRF-384 or PRF-512 to derive session-specific keys from a PMK.
- It shall be called by 4-way handshake processing.
-
- Arguments:
- pAd - pointer to our pAdapter context
- PMK - pointer to PMK
- ANonce - pointer to ANonce
- AA - pointer to Authenticator Address
- SNonce - pointer to SNonce
- SA - pointer to Supplicant Address
- len - indicate the length of PTK (octet)
-
- Return Value:
- Output pointer to the PTK
-
- Note:
- Refer to IEEE 802.11i-2004 8.5.1.2
-
- ========================================================================
-*/
-VOID WpaCountPTK(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *PMK,
- IN UCHAR *ANonce,
- IN UCHAR *AA,
- IN UCHAR *SNonce,
- IN UCHAR *SA,
- OUT UCHAR *output,
- IN UINT len)
-{
- UCHAR concatenation[76];
- UINT CurrPos = 0;
- UCHAR temp[32];
- UCHAR Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
- 'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n'};
-
- // initiate the concatenation input
- NdisZeroMemory(temp, sizeof(temp));
- NdisZeroMemory(concatenation, 76);
-
- // Get smaller address
- if (RTMPCompareMemory(SA, AA, 6) == 1)
- NdisMoveMemory(concatenation, AA, 6);
- else
- NdisMoveMemory(concatenation, SA, 6);
- CurrPos += 6;
-
- // Get larger address
- if (RTMPCompareMemory(SA, AA, 6) == 1)
- NdisMoveMemory(&concatenation[CurrPos], SA, 6);
- else
- NdisMoveMemory(&concatenation[CurrPos], AA, 6);
-
- // store the larger mac address for backward compatible of
- // ralink proprietary STA-key issue
- NdisMoveMemory(temp, &concatenation[CurrPos], MAC_ADDR_LEN);
- CurrPos += 6;
-
- // Get smaller Nonce
- if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
- NdisMoveMemory(&concatenation[CurrPos], temp, 32); // patch for ralink proprietary STA-key issue
- else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
- NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
- else
- NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
- CurrPos += 32;
-
- // Get larger Nonce
- if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
- NdisMoveMemory(&concatenation[CurrPos], temp, 32); // patch for ralink proprietary STA-key issue
- else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
- NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
- else
- NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
- CurrPos += 32;
-
- hex_dump("concatenation=", concatenation, 76);
-
- // Use PRF to generate PTK
- PRF(PMK, LEN_MASTER_KEY, Prefix, 22, concatenation, 76, output, len);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Generate random number by software.
-
- Arguments:
- pAd - pointer to our pAdapter context
- macAddr - pointer to local MAC address
-
- Return Value:
-
- Note:
- 802.1ii-2004 Annex H.5
-
- ========================================================================
-*/
-VOID GenRandom(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *macAddr,
- OUT UCHAR *random)
-{
- INT i, curr;
- UCHAR local[80], KeyCounter[32];
- UCHAR result[80];
- ULONG CurrentTime;
- UCHAR prefix[] = {'I', 'n', 'i', 't', ' ', 'C', 'o', 'u', 'n', 't', 'e', 'r'};
-
- // Zero the related information
- NdisZeroMemory(result, 80);
- NdisZeroMemory(local, 80);
- NdisZeroMemory(KeyCounter, 32);
-
- for (i = 0; i < 32; i++)
- {
- // copy the local MAC address
- COPY_MAC_ADDR(local, macAddr);
- curr = MAC_ADDR_LEN;
-
- // concatenate the current time
- NdisGetSystemUpTime(&CurrentTime);
- NdisMoveMemory(&local[curr], &CurrentTime, sizeof(CurrentTime));
- curr += sizeof(CurrentTime);
-
- // concatenate the last result
- NdisMoveMemory(&local[curr], result, 32);
- curr += 32;
-
- // concatenate a variable
- NdisMoveMemory(&local[curr], &i, 2);
- curr += 2;
-
- // calculate the result
- PRF(KeyCounter, 32, prefix,12, local, curr, result, 32);
- }
-
- NdisMoveMemory(random, result, 32);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Build cipher suite in RSN-IE.
- It only shall be called by RTMPMakeRSNIE.
-
- Arguments:
- pAd - pointer to our pAdapter context
- ElementID - indicate the WPA1 or WPA2
- WepStatus - indicate the encryption type
- bMixCipher - a boolean to indicate the pairwise cipher and group
- cipher are the same or not
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-static VOID RTMPInsertRsnIeCipher(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR ElementID,
- IN UINT WepStatus,
- IN BOOLEAN bMixCipher,
- IN UCHAR FlexibleCipher,
- OUT PUCHAR pRsnIe,
- OUT UCHAR *rsn_len)
-{
- UCHAR PairwiseCnt;
-
- *rsn_len = 0;
-
- // decide WPA2 or WPA1
- if (ElementID == Wpa2Ie)
- {
- RSNIE2 *pRsnie_cipher = (RSNIE2*)pRsnIe;
-
- // Assign the verson as 1
- pRsnie_cipher->version = 1;
-
- switch (WepStatus)
- {
- // TKIP mode
- case Ndis802_11Encryption2Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
- *rsn_len = sizeof(RSNIE2);
- break;
-
- // AES mode
- case Ndis802_11Encryption3Enabled:
- if (bMixCipher)
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
- else
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_CCMP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
- *rsn_len = sizeof(RSNIE2);
- break;
-
- // TKIP-AES mix mode
- case Ndis802_11Encryption4Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
-
- PairwiseCnt = 1;
- // Insert WPA2 TKIP as the first pairwise cipher
- if (MIX_CIPHER_WPA2_TKIP_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
- // Insert WPA2 AES as the secondary pairwise cipher
- if (MIX_CIPHER_WPA2_AES_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA2_CCMP, 4);
- PairwiseCnt = 2;
- }
- }
- else
- {
- // Insert WPA2 AES as the first pairwise cipher
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
- }
-
- pRsnie_cipher->ucount = PairwiseCnt;
- *rsn_len = sizeof(RSNIE2) + (4 * (PairwiseCnt - 1));
- break;
- }
-
- // swap for big-endian platform
- pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
- pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
- }
- else
- {
- RSNIE *pRsnie_cipher = (RSNIE*)pRsnIe;
-
- // Assign OUI and version
- NdisMoveMemory(pRsnie_cipher->oui, OUI_WPA_VERSION, 4);
- pRsnie_cipher->version = 1;
-
- switch (WepStatus)
- {
- // TKIP mode
- case Ndis802_11Encryption2Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
- *rsn_len = sizeof(RSNIE);
- break;
-
- // AES mode
- case Ndis802_11Encryption3Enabled:
- if (bMixCipher)
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
- else
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_CCMP, 4);
- pRsnie_cipher->ucount = 1;
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
- *rsn_len = sizeof(RSNIE);
- break;
-
- // TKIP-AES mix mode
- case Ndis802_11Encryption4Enabled:
- NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
-
- PairwiseCnt = 1;
- // Insert WPA TKIP as the first pairwise cipher
- if (MIX_CIPHER_WPA_TKIP_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
- // Insert WPA AES as the secondary pairwise cipher
- if (MIX_CIPHER_WPA_AES_ON(FlexibleCipher))
- {
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA_CCMP, 4);
- PairwiseCnt = 2;
- }
- }
- else
- {
- // Insert WPA AES as the first pairwise cipher
- NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
- }
-
- pRsnie_cipher->ucount = PairwiseCnt;
- *rsn_len = sizeof(RSNIE) + (4 * (PairwiseCnt - 1));
- break;
- }
-
- // swap for big-endian platform
- pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
- pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
- }
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Build AKM suite in RSN-IE.
- It only shall be called by RTMPMakeRSNIE.
-
- Arguments:
- pAd - pointer to our pAdapter context
- ElementID - indicate the WPA1 or WPA2
- AuthMode - indicate the authentication mode
- apidx - indicate the interface index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-static VOID RTMPInsertRsnIeAKM(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR ElementID,
- IN UINT AuthMode,
- IN UCHAR apidx,
- OUT PUCHAR pRsnIe,
- OUT UCHAR *rsn_len)
-{
- RSNIE_AUTH *pRsnie_auth;
-
- pRsnie_auth = (RSNIE_AUTH*)(pRsnIe + (*rsn_len));
-
- // decide WPA2 or WPA1
- if (ElementID == Wpa2Ie)
- {
- switch (AuthMode)
- {
- case Ndis802_11AuthModeWPA2:
- case Ndis802_11AuthModeWPA1WPA2:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_8021X_AKM, 4);
- break;
-
- case Ndis802_11AuthModeWPA2PSK:
- case Ndis802_11AuthModeWPA1PSKWPA2PSK:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_PSK_AKM, 4);
- break;
- }
- }
- else
- {
- switch (AuthMode)
- {
- case Ndis802_11AuthModeWPA:
- case Ndis802_11AuthModeWPA1WPA2:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_8021X_AKM, 4);
- break;
-
- case Ndis802_11AuthModeWPAPSK:
- case Ndis802_11AuthModeWPA1PSKWPA2PSK:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_PSK_AKM, 4);
- break;
-
- case Ndis802_11AuthModeWPANone:
- pRsnie_auth->acount = 1;
- NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_NONE_AKM, 4);
- break;
- }
- }
-
- pRsnie_auth->acount = cpu2le16(pRsnie_auth->acount);
-
- (*rsn_len) += sizeof(RSNIE_AUTH); // update current RSNIE length
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Build capability in RSN-IE.
- It only shall be called by RTMPMakeRSNIE.
-
- Arguments:
- pAd - pointer to our pAdapter context
- ElementID - indicate the WPA1 or WPA2
- apidx - indicate the interface index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-static VOID RTMPInsertRsnIeCap(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR ElementID,
- IN UCHAR apidx,
- OUT PUCHAR pRsnIe,
- OUT UCHAR *rsn_len)
-{
- RSN_CAPABILITIES *pRSN_Cap;
-
- // it could be ignored in WPA1 mode
- if (ElementID == WpaIe)
- return;
-
- pRSN_Cap = (RSN_CAPABILITIES*)(pRsnIe + (*rsn_len));
-
-
- pRSN_Cap->word = cpu2le16(pRSN_Cap->word);
-
- (*rsn_len) += sizeof(RSN_CAPABILITIES); // update current RSNIE length
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Build RSN IE context. It is not included element-ID and length.
-
- Arguments:
- pAd - pointer to our pAdapter context
- AuthMode - indicate the authentication mode
- WepStatus - indicate the encryption type
- apidx - indicate the interface index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPMakeRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN UINT AuthMode,
- IN UINT WepStatus,
- IN UCHAR apidx)
-{
- PUCHAR pRsnIe = NULL; // primary RSNIE
- UCHAR *rsnielen_cur_p = 0; // the length of the primary RSNIE
- UCHAR *rsnielen_ex_cur_p = 0; // the length of the secondary RSNIE
- UCHAR PrimaryRsnie;
- BOOLEAN bMixCipher = FALSE; // indicate the pairwise and group cipher are different
- UCHAR p_offset;
- WPA_MIX_PAIR_CIPHER FlexibleCipher = MIX_CIPHER_NOTUSE; // it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode
-
- rsnielen_cur_p = NULL;
- rsnielen_ex_cur_p = NULL;
-
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- if (AuthMode < Ndis802_11AuthModeWPA)
- return;
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // Support WPAPSK or WPA2PSK in STA-Infra mode
- // Support WPANone in STA-Adhoc mode
- if ((AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (AuthMode != Ndis802_11AuthModeWPANone)
- )
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("==> RTMPMakeRSNIE(STA)\n"));
-
- // Zero RSNIE context
- pAd->StaCfg.RSNIE_Len = 0;
- NdisZeroMemory(pAd->StaCfg.RSN_IE, MAX_LEN_OF_RSNIE);
-
- // Pointer to RSNIE
- rsnielen_cur_p = &pAd->StaCfg.RSNIE_Len;
- pRsnIe = pAd->StaCfg.RSN_IE;
-
- bMixCipher = pAd->StaCfg.bMixCipher;
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // indicate primary RSNIE as WPA or WPA2
- if ((AuthMode == Ndis802_11AuthModeWPA) ||
- (AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (AuthMode == Ndis802_11AuthModeWPANone) ||
- (AuthMode == Ndis802_11AuthModeWPA1WPA2) ||
- (AuthMode == Ndis802_11AuthModeWPA1PSKWPA2PSK))
- PrimaryRsnie = WpaIe;
- else
- PrimaryRsnie = Wpa2Ie;
-
- {
- // Build the primary RSNIE
- // 1. insert cipher suite
- RTMPInsertRsnIeCipher(pAd, PrimaryRsnie, WepStatus, bMixCipher, FlexibleCipher, pRsnIe, &p_offset);
-
- // 2. insert AKM
- RTMPInsertRsnIeAKM(pAd, PrimaryRsnie, AuthMode, apidx, pRsnIe, &p_offset);
-
- // 3. insert capability
- RTMPInsertRsnIeCap(pAd, PrimaryRsnie, apidx, pRsnIe, &p_offset);
- }
-
- // 4. update the RSNIE length
- *rsnielen_cur_p = p_offset;
-
- hex_dump("The primary RSNIE", pRsnIe, (*rsnielen_cur_p));
-
-
-}
-
-/*
- ==========================================================================
- Description:
- Check whether the received frame is EAP frame.
-
- Arguments:
- pAd - pointer to our pAdapter context
- pEntry - pointer to active entry
- pData - the received frame
- DataByteCount - the received frame's length
- FromWhichBSSID - indicate the interface index
-
- Return:
- TRUE - This frame is EAP frame
- FALSE - otherwise
- ==========================================================================
-*/
-BOOLEAN RTMPCheckWPAframe(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR pData,
- IN ULONG DataByteCount,
- IN UCHAR FromWhichBSSID)
-{
- ULONG Body_len;
- BOOLEAN Cancelled;
-
-
- if(DataByteCount < (LENGTH_802_1_H + LENGTH_EAPOL_H))
- return FALSE;
-
-
- // Skip LLC header
- if (NdisEqualMemory(SNAP_802_1H, pData, 6) ||
- // Cisco 1200 AP may send packet with SNAP_BRIDGE_TUNNEL
- NdisEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6))
- {
- pData += 6;
- }
- // Skip 2-bytes EAPoL type
- if (NdisEqualMemory(EAPOL, pData, 2))
- {
- pData += 2;
- }
- else
- return FALSE;
-
- switch (*(pData+1))
- {
- case EAPPacket:
- Body_len = (*(pData+2)<<8) | (*(pData+3));
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAP-Packet frame, TYPE = 0, Length = %ld\n", Body_len));
- break;
- case EAPOLStart:
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Start frame, TYPE = 1 \n"));
- if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Cancel the EnqueueEapolStartTimerRunning \n"));
- RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
- pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
- }
- break;
- case EAPOLLogoff:
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLLogoff frame, TYPE = 2 \n"));
- break;
- case EAPOLKey:
- Body_len = (*(pData+2)<<8) | (*(pData+3));
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Key frame, TYPE = 3, Length = %ld\n", Body_len));
- break;
- case EAPOLASFAlert:
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLASFAlert frame, TYPE = 4 \n"));
- break;
- default:
- return FALSE;
-
- }
- return TRUE;
-}
-
-
-/*
- ==========================================================================
- Description:
- ENCRYPT AES GTK before sending in EAPOL frame.
- AES GTK length = 128 bit, so fix blocks for aes-key-wrap as 2 in this function.
- This function references to RFC 3394 for aes key wrap algorithm.
- Return:
- ==========================================================================
-*/
-VOID AES_GTK_KEY_WRAP(
- IN UCHAR *key,
- IN UCHAR *plaintext,
- IN UCHAR p_len,
- OUT UCHAR *ciphertext)
-{
- UCHAR A[8], BIN[16], BOUT[16];
- UCHAR R[512];
- INT num_blocks = p_len/8; // unit:64bits
- INT i, j;
- aes_context aesctx;
- UCHAR xor;
-
- rtmp_aes_set_key(&aesctx, key, 128);
-
- // Init IA
- for (i = 0; i < 8; i++)
- A[i] = 0xa6;
-
- //Input plaintext
- for (i = 0; i < num_blocks; i++)
- {
- for (j = 0 ; j < 8; j++)
- R[8 * (i + 1) + j] = plaintext[8 * i + j];
- }
-
- // Key Mix
- for (j = 0; j < 6; j++)
- {
- for(i = 1; i <= num_blocks; i++)
- {
- //phase 1
- NdisMoveMemory(BIN, A, 8);
- NdisMoveMemory(&BIN[8], &R[8 * i], 8);
- rtmp_aes_encrypt(&aesctx, BIN, BOUT);
-
- NdisMoveMemory(A, &BOUT[0], 8);
- xor = num_blocks * j + i;
- A[7] = BOUT[7] ^ xor;
- NdisMoveMemory(&R[8 * i], &BOUT[8], 8);
- }
- }
-
- // Output ciphertext
- NdisMoveMemory(ciphertext, A, 8);
-
- for (i = 1; i <= num_blocks; i++)
- {
- for (j = 0 ; j < 8; j++)
- ciphertext[8 * i + j] = R[8 * i + j];
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Misc function to decrypt AES body
-
- Arguments:
-
- Return Value:
-
- Note:
- This function references to RFC 3394 for aes key unwrap algorithm.
-
- ========================================================================
-*/
-VOID AES_GTK_KEY_UNWRAP(
- IN UCHAR *key,
- OUT UCHAR *plaintext,
- IN UCHAR c_len,
- IN UCHAR *ciphertext)
-
-{
- UCHAR A[8], BIN[16], BOUT[16];
- UCHAR xor;
- INT i, j;
- aes_context aesctx;
- UCHAR *R;
- INT num_blocks = c_len/8; // unit:64bits
-
-
- os_alloc_mem(NULL, (PUCHAR *)&R, 512);
-
- if (R == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!!AES_GTK_KEY_UNWRAP: no memory!!!\n"));
- return;
- } /* End of if */
-
- // Initialize
- NdisMoveMemory(A, ciphertext, 8);
- //Input plaintext
- for(i = 0; i < (c_len-8); i++)
- {
- R[ i] = ciphertext[i + 8];
- }
-
- rtmp_aes_set_key(&aesctx, key, 128);
-
- for(j = 5; j >= 0; j--)
- {
- for(i = (num_blocks-1); i > 0; i--)
- {
- xor = (num_blocks -1 )* j + i;
- NdisMoveMemory(BIN, A, 8);
- BIN[7] = A[7] ^ xor;
- NdisMoveMemory(&BIN[8], &R[(i-1)*8], 8);
- rtmp_aes_decrypt(&aesctx, BIN, BOUT);
- NdisMoveMemory(A, &BOUT[0], 8);
- NdisMoveMemory(&R[(i-1)*8], &BOUT[8], 8);
- }
- }
-
- // OUTPUT
- for(i = 0; i < c_len; i++)
- {
- plaintext[i] = R[i];
- }
-
-
- os_free_mem(NULL, R);
-}
-
-/*
- ==========================================================================
- Description:
- Report the EAP message type
-
- Arguments:
- msg - EAPOL_PAIR_MSG_1
- EAPOL_PAIR_MSG_2
- EAPOL_PAIR_MSG_3
- EAPOL_PAIR_MSG_4
- EAPOL_GROUP_MSG_1
- EAPOL_GROUP_MSG_2
-
- Return:
- message type string
-
- ==========================================================================
-*/
-CHAR *GetEapolMsgType(CHAR msg)
-{
- if(msg == EAPOL_PAIR_MSG_1)
- return "Pairwise Message 1";
- else if(msg == EAPOL_PAIR_MSG_2)
- return "Pairwise Message 2";
- else if(msg == EAPOL_PAIR_MSG_3)
- return "Pairwise Message 3";
- else if(msg == EAPOL_PAIR_MSG_4)
- return "Pairwise Message 4";
- else if(msg == EAPOL_GROUP_MSG_1)
- return "Group Message 1";
- else if(msg == EAPOL_GROUP_MSG_2)
- return "Group Message 2";
- else
- return "Invalid Message";
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Check Sanity RSN IE of EAPoL message
-
- Arguments:
-
- Return Value:
-
-
- ========================================================================
-*/
-BOOLEAN RTMPCheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- IN MAC_TABLE_ENTRY *pEntry,
- OUT UCHAR *Offset)
-{
- PUCHAR pVIE;
- UCHAR len;
- PEID_STRUCT pEid;
- BOOLEAN result = FALSE;
-
- pVIE = pData;
- len = DataLen;
- *Offset = 0;
-
- while (len > sizeof(RSNIE2))
- {
- pEid = (PEID_STRUCT) pVIE;
- // WPA RSN IE
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
- {
- if ((pEntry->AuthMode == Ndis802_11AuthModeWPA || pEntry->AuthMode == Ndis802_11AuthModeWPAPSK) &&
- (NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
- (pEntry->RSNIE_Len == (pEid->Len + 2)))
- {
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- // WPA2 RSN IE
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
- {
- if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2 || pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK) &&
- (NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
- (pEntry->RSNIE_Len == (pEid->Len + 2))/* ToDo-AlbertY for mesh*/)
- {
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- else
- {
- break;
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
-
-
- return result;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Parse KEYDATA field. KEYDATA[] May contain 2 RSN IE and optionally GTK.
- GTK is encaptulated in KDE format at p.83 802.11i D10
-
- Arguments:
-
- Return Value:
-
- Note:
- 802.11i D10
-
- ========================================================================
-*/
-BOOLEAN RTMPParseEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR GroupKeyIndex,
- IN UCHAR MsgType,
- IN BOOLEAN bWPA2,
- IN MAC_TABLE_ENTRY *pEntry)
-{
- PKDE_ENCAP pKDE = NULL;
- PUCHAR pMyKeyData = pKeyData;
- UCHAR KeyDataLength = KeyDataLen;
- UCHAR GTKLEN = 0;
- UCHAR DefaultIdx = 0;
- UCHAR skip_offset;
-
- // Verify The RSN IE contained in pairewise_msg_2 && pairewise_msg_3 and skip it
- if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_3)
- {
- // Check RSN IE whether it is WPA2/WPA2PSK
- if (!RTMPCheckRSNIE(pAd, pKeyData, KeyDataLen, pEntry, &skip_offset))
- {
- // send wireless event - for RSN IE different
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_RSNIE_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
-
- DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in msg %d of 4-way handshake!\n", MsgType));
- hex_dump("Receive RSN_IE ", pKeyData, KeyDataLen);
- hex_dump("Desired RSN_IE ", pEntry->RSN_IE, pEntry->RSNIE_Len);
-
- return FALSE;
- }
- else
- {
- if (bWPA2 && MsgType == EAPOL_PAIR_MSG_3)
- {
- // skip RSN IE
- pMyKeyData += skip_offset;
- KeyDataLength -= skip_offset;
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPParseEapolKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", skip_offset));
- }
- else
- return TRUE;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("RTMPParseEapolKeyData ==> KeyDataLength %d without RSN_IE \n", KeyDataLength));
-
- // Parse EKD format in pairwise_msg_3_WPA2 && group_msg_1_WPA2
- if (bWPA2 && (MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1))
- {
- if (KeyDataLength >= 8) // KDE format exclude GTK length
- {
- pKDE = (PKDE_ENCAP) pMyKeyData;
-
-
- DefaultIdx = pKDE->GTKEncap.Kid;
-
- // Sanity check - KED length
- if (KeyDataLength < (pKDE->Len + 2))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
- return FALSE;
- }
-
- // Get GTK length - refer to IEEE 802.11i-2004 p.82
- GTKLEN = pKDE->Len -6;
- if (GTKLEN < LEN_AES_KEY)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
- return FALSE;
- }
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: KDE format length is too short \n"));
- return FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("GTK in KDE format ,DefaultKeyID=%d, KeyLen=%d \n", DefaultIdx, GTKLEN));
- // skip it
- pMyKeyData += 8;
- KeyDataLength -= 8;
-
- }
- else if (!bWPA2 && MsgType == EAPOL_GROUP_MSG_1)
- {
- DefaultIdx = GroupKeyIndex;
- DBGPRINT(RT_DEBUG_TRACE, ("GTK DefaultKeyID=%d \n", DefaultIdx));
- }
-
- // Sanity check - shared key index must be 1 ~ 3
- if (DefaultIdx < 1 || DefaultIdx > 3)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index(%d) is invalid in %s %s \n", DefaultIdx, ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
- return FALSE;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- // Todo
-#endif // CONFIG_STA_SUPPORT //
-
- return TRUE;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Construct EAPoL message for WPA handshaking
- Its format is below,
-
- +--------------------+
- | Protocol Version | 1 octet
- +--------------------+
- | Protocol Type | 1 octet
- +--------------------+
- | Body Length | 2 octets
- +--------------------+
- | Descriptor Type | 1 octet
- +--------------------+
- | Key Information | 2 octets
- +--------------------+
- | Key Length | 1 octet
- +--------------------+
- | Key Repaly Counter | 8 octets
- +--------------------+
- | Key Nonce | 32 octets
- +--------------------+
- | Key IV | 16 octets
- +--------------------+
- | Key RSC | 8 octets
- +--------------------+
- | Key ID or Reserved | 8 octets
- +--------------------+
- | Key MIC | 16 octets
- +--------------------+
- | Key Data Length | 2 octets
- +--------------------+
- | Key Data | n octets
- +--------------------+
-
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ConstructEapolMsg(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AuthMode,
- IN UCHAR WepStatus,
- IN UCHAR GroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN UCHAR *ReplayCounter,
- IN UCHAR *KeyNonce,
- IN UCHAR *TxRSC,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_Len,
- OUT PEAPOL_PACKET pMsg)
-{
- BOOLEAN bWPA2 = FALSE;
-
- // Choose WPA2 or not
- if ((AuthMode == Ndis802_11AuthModeWPA2) || (AuthMode == Ndis802_11AuthModeWPA2PSK))
- bWPA2 = TRUE;
-
- // Init Packet and Fill header
- pMsg->ProVer = EAPOL_VER;
- pMsg->ProType = EAPOLKey;
-
- // Default 95 bytes, the EAPoL-Key descriptor exclude Key-data field
- pMsg->Body_Len[1] = LEN_EAPOL_KEY_MSG;
-
- // Fill in EAPoL descriptor
- if (bWPA2)
- pMsg->KeyDesc.Type = WPA2_KEY_DESC;
- else
- pMsg->KeyDesc.Type = WPA1_KEY_DESC;
-
- // Fill in Key information, refer to IEEE Std 802.11i-2004 page 78
- // When either the pairwise or the group cipher is AES, the DESC_TYPE_AES(2) shall be used.
- pMsg->KeyDesc.KeyInfo.KeyDescVer =
- (((WepStatus == Ndis802_11Encryption3Enabled) || (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- // Specify Key Type as Group(0) or Pairwise(1)
- if (MsgType >= EAPOL_GROUP_MSG_1)
- pMsg->KeyDesc.KeyInfo.KeyType = GROUPKEY;
- else
- pMsg->KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // Specify Key Index, only group_msg1_WPA1
- if (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1))
- pMsg->KeyDesc.KeyInfo.KeyIndex = DefaultKeyIdx;
-
- if (MsgType == EAPOL_PAIR_MSG_3)
- pMsg->KeyDesc.KeyInfo.Install = 1;
-
- if ((MsgType == EAPOL_PAIR_MSG_1) || (MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1))
- pMsg->KeyDesc.KeyInfo.KeyAck = 1;
-
- if (MsgType != EAPOL_PAIR_MSG_1)
- pMsg->KeyDesc.KeyInfo.KeyMic = 1;
-
- if ((bWPA2 && (MsgType >= EAPOL_PAIR_MSG_3)) || (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1)))
- {
- pMsg->KeyDesc.KeyInfo.Secure = 1;
- }
-
- if (bWPA2 && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
- {
- pMsg->KeyDesc.KeyInfo.EKD_DL = 1;
- }
-
- // key Information element has done.
- *(USHORT *)(&pMsg->KeyDesc.KeyInfo) = cpu2le16(*(USHORT *)(&pMsg->KeyDesc.KeyInfo));
-
- // Fill in Key Length
- {
- if (MsgType >= EAPOL_GROUP_MSG_1)
- {
- // the length of group key cipher
- pMsg->KeyDesc.KeyLength[1] = ((GroupKeyWepStatus == Ndis802_11Encryption2Enabled) ? TKIP_GTK_LENGTH : LEN_AES_KEY);
- }
- else
- {
- // the length of pairwise key cipher
- pMsg->KeyDesc.KeyLength[1] = ((WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);
- }
- }
-
- // Fill in replay counter
- NdisMoveMemory(pMsg->KeyDesc.ReplayCounter, ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Fill Key Nonce field
- // ANonce : pairwise_msg1 & pairwise_msg3
- // SNonce : pairwise_msg2
- // GNonce : group_msg1_wpa1
- if ((MsgType <= EAPOL_PAIR_MSG_3) || ((!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))))
- NdisMoveMemory(pMsg->KeyDesc.KeyNonce, KeyNonce, LEN_KEY_DESC_NONCE);
-
- // Fill key IV - WPA2 as 0, WPA1 as random
- if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
- {
- // Suggest IV be random number plus some number,
- NdisMoveMemory(pMsg->KeyDesc.KeyIv, &KeyNonce[16], LEN_KEY_DESC_IV);
- pMsg->KeyDesc.KeyIv[15] += 2;
- }
-
- // Fill Key RSC field
- // It contains the RSC for the GTK being installed.
- if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
- {
- NdisMoveMemory(pMsg->KeyDesc.KeyRsc, TxRSC, 6);
- }
-
- // Clear Key MIC field for MIC calculation later
- NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
- ConstructEapolKeyData(pAd,
- AuthMode,
- WepStatus,
- GroupKeyWepStatus,
- MsgType,
- DefaultKeyIdx,
- bWPA2,
- PTK,
- GTK,
- RSNIE,
- RSNIE_Len,
- pMsg);
-
- // Calculate MIC and fill in KeyMic Field except Pairwise Msg 1.
- if (MsgType != EAPOL_PAIR_MSG_1)
- {
- CalculateMIC(pAd, WepStatus, PTK, pMsg);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> ConstructEapolMsg for %s %s\n", ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
- DBGPRINT(RT_DEBUG_TRACE, (" Body length = %d \n", pMsg->Body_Len[1]));
- DBGPRINT(RT_DEBUG_TRACE, (" Key length = %d \n", pMsg->KeyDesc.KeyLength[1]));
-
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Construct the Key Data field of EAPoL message
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ConstructEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AuthMode,
- IN UCHAR WepStatus,
- IN UCHAR GroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN BOOLEAN bWPA2Capable,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_LEN,
- OUT PEAPOL_PACKET pMsg)
-{
- UCHAR *mpool, *Key_Data, *Rc4GTK;
- UCHAR ekey[(LEN_KEY_DESC_IV+LEN_EAP_EK)];
- UCHAR data_offset;
-
-
- if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)
- return;
-
- // allocate memory pool
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 1500);
-
- if (mpool == NULL)
- return;
-
- /* Rc4GTK Len = 512 */
- Rc4GTK = (UCHAR *) ROUND_UP(mpool, 4);
- /* Key_Data Len = 512 */
- Key_Data = (UCHAR *) ROUND_UP(Rc4GTK + 512, 4);
-
- NdisZeroMemory(Key_Data, 512);
- pMsg->KeyDesc.KeyDataLen[1] = 0;
- data_offset = 0;
-
- // Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3
- if (RSNIE_LEN && ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3)))
- {
- if (bWPA2Capable)
- Key_Data[data_offset + 0] = IE_WPA2;
- else
- Key_Data[data_offset + 0] = IE_WPA;
-
- Key_Data[data_offset + 1] = RSNIE_LEN;
- NdisMoveMemory(&Key_Data[data_offset + 2], RSNIE, RSNIE_LEN);
- data_offset += (2 + RSNIE_LEN);
- }
-
- // Encapsulate KDE format in pairwise_msg3_WPA2 & group_msg1_WPA2
- if (bWPA2Capable && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
- {
- // Key Data Encapsulation (KDE) format - 802.11i-2004 Figure-43w and Table-20h
- Key_Data[data_offset + 0] = 0xDD;
-
- if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
- {
- Key_Data[data_offset + 1] = 0x16;// 4+2+16(OUI+DataType+DataField)
- }
- else
- {
- Key_Data[data_offset + 1] = 0x26;// 4+2+32(OUI+DataType+DataField)
- }
-
- Key_Data[data_offset + 2] = 0x00;
- Key_Data[data_offset + 3] = 0x0F;
- Key_Data[data_offset + 4] = 0xAC;
- Key_Data[data_offset + 5] = 0x01;
-
- // GTK KDE format - 802.11i-2004 Figure-43x
- Key_Data[data_offset + 6] = (DefaultKeyIdx & 0x03);
- Key_Data[data_offset + 7] = 0x00; // Reserved Byte
-
- data_offset += 8;
- }
-
-
- // Encapsulate GTK and encrypt the key-data field with KEK.
- // Only for pairwise_msg3_WPA2 and group_msg1
- if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable) || (MsgType == EAPOL_GROUP_MSG_1))
- {
- // Fill in GTK
- if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
- {
- NdisMoveMemory(&Key_Data[data_offset], GTK, LEN_AES_KEY);
- data_offset += LEN_AES_KEY;
- }
- else
- {
- NdisMoveMemory(&Key_Data[data_offset], GTK, TKIP_GTK_LENGTH);
- data_offset += TKIP_GTK_LENGTH;
- }
-
- // Still dont know why, but if not append will occur "GTK not include in MSG3"
- // Patch for compatibility between zero config and funk
- if (MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable)
- {
- if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
- {
- Key_Data[data_offset + 0] = 0xDD;
- Key_Data[data_offset + 1] = 0;
- data_offset += 2;
- }
- else
- {
- Key_Data[data_offset + 0] = 0xDD;
- Key_Data[data_offset + 1] = 0;
- Key_Data[data_offset + 2] = 0;
- Key_Data[data_offset + 3] = 0;
- Key_Data[data_offset + 4] = 0;
- Key_Data[data_offset + 5] = 0;
- data_offset += 6;
- }
- }
-
- // Encrypt the data material in key data field
- if (WepStatus == Ndis802_11Encryption3Enabled)
- {
- AES_GTK_KEY_WRAP(&PTK[16], Key_Data, data_offset, Rc4GTK);
- // AES wrap function will grow 8 bytes in length
- data_offset += 8;
- }
- else
- {
- // PREPARE Encrypted "Key DATA" field. (Encrypt GTK with RC4, usinf PTK[16]->[31] as Key, IV-field as IV)
- // put TxTsc in Key RSC field
- pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
-
- // ekey is the contanetion of IV-field, and PTK[16]->PTK[31]
- NdisMoveMemory(ekey, pMsg->KeyDesc.KeyIv, LEN_KEY_DESC_IV);
- NdisMoveMemory(&ekey[LEN_KEY_DESC_IV], &PTK[16], LEN_EAP_EK);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, ekey, sizeof(ekey)); //INIT SBOX, KEYLEN+3(IV)
- pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, Key_Data, data_offset);
- WPAARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, Rc4GTK, Key_Data, data_offset);
- }
-
- NdisMoveMemory(pMsg->KeyDesc.KeyData, Rc4GTK, data_offset);
- }
- else
- {
- NdisMoveMemory(pMsg->KeyDesc.KeyData, Key_Data, data_offset);
- }
-
- // set key data length field and total length
- pMsg->KeyDesc.KeyDataLen[1] = data_offset;
- pMsg->Body_Len[1] += data_offset;
-
- os_free_mem(pAd, mpool);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Calcaulate MIC. It is used during 4-ways handsharking.
-
- Arguments:
- pAd - pointer to our pAdapter context
- PeerWepStatus - indicate the encryption type
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID CalculateMIC(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerWepStatus,
- IN UCHAR *PTK,
- OUT PEAPOL_PACKET pMsg)
-{
- UCHAR *OutBuffer;
- ULONG FrameLen = 0;
- UCHAR mic[LEN_KEY_DESC_MIC];
- UCHAR digest[80];
-
- // allocate memory for MIC calculation
- os_alloc_mem(pAd, (PUCHAR *)&OutBuffer, 512);
-
- if (OutBuffer == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("!!!CalculateMIC: no memory!!!\n"));
- return;
- }
-
- // make a frame for calculating MIC.
- MakeOutgoingFrame(OutBuffer, &FrameLen,
- pMsg->Body_Len[1] + 4, pMsg,
- END_OF_ARGS);
-
- NdisZeroMemory(mic, sizeof(mic));
-
- // Calculate MIC
- if (PeerWepStatus == Ndis802_11Encryption3Enabled)
- {
- HMAC_SHA1(OutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, mic);
- }
-
- // store the calculated MIC
- NdisMoveMemory(pMsg->KeyDesc.KeyMic, mic, LEN_KEY_DESC_MIC);
-
- os_free_mem(pAd, OutBuffer);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Some received frames can't decrypt by Asic, so decrypt them by software.
-
- Arguments:
- pAd - pointer to our pAdapter context
- PeerWepStatus - indicate the encryption type
-
- Return Value:
- NDIS_STATUS_SUCCESS - decryption successful
- NDIS_STATUS_FAILURE - decryption failure
-
- ========================================================================
-*/
-NDIS_STATUS RTMPSoftDecryptBroadCastData(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN NDIS_802_11_ENCRYPTION_STATUS GroupCipher,
- IN PCIPHER_KEY pShard_key)
-{
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
-
-
-
- // handle WEP decryption
- if (GroupCipher == Ndis802_11Encryption1Enabled)
- {
- if (RTMPSoftDecryptWEP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, pShard_key))
- {
-
- //Minus IV[4] & ICV[4]
- pRxWI->MPDUtotalByteCount -= 8;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR : Software decrypt WEP data fails.\n"));
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
- }
- // handle TKIP decryption
- else if (GroupCipher == Ndis802_11Encryption2Enabled)
- {
- if (RTMPSoftDecryptTKIP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, 0, pShard_key))
- {
-
- //Minus 8 bytes MIC, 8 bytes IV/EIV, 4 bytes ICV
- pRxWI->MPDUtotalByteCount -= 20;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptTKIP Failed\n"));
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
- }
- // handle AES decryption
- else if (GroupCipher == Ndis802_11Encryption3Enabled)
- {
- if (RTMPSoftDecryptAES(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount , pShard_key))
- {
-
- //8 bytes MIC, 8 bytes IV/EIV (CCMP Header)
- pRxWI->MPDUtotalByteCount -= 16;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptAES Failed\n"));
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
- }
- else
- {
- // give up this frame
- return NDIS_STATUS_FAILURE;
- }
-
- return NDIS_STATUS_SUCCESS;
-
-}
-
+#include "../../rt2870/common/cmm_wpa.c"
diff --git a/drivers/staging/rt3070/common/dfs.c b/drivers/staging/rt3070/common/dfs.c
index 28d60145791c..c584a6924c3c 100644
--- a/drivers/staging/rt3070/common/dfs.c
+++ b/drivers/staging/rt3070/common/dfs.c
@@ -1,441 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- ap_dfs.c
-
- Abstract:
- Support DFS function.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Fonchi 03-12-2007 created
-*/
-
-#include "../rt_config.h"
-
-typedef struct _RADAR_DURATION_TABLE
-{
- ULONG RDDurRegion;
- ULONG RadarSignalDuration;
- ULONG Tolerance;
-} RADAR_DURATION_TABLE, *PRADAR_DURATION_TABLE;
-
-
-static UCHAR RdIdleTimeTable[MAX_RD_REGION][4] =
-{
- {9, 250, 250, 250}, // CE
- {4, 250, 250, 250}, // FCC
- {4, 250, 250, 250}, // JAP
- {15, 250, 250, 250}, // JAP_W53
- {4, 250, 250, 250} // JAP_W56
-};
-
-/*
- ========================================================================
-
- Routine Description:
- Bbp Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
-
- ========================================================================
-*/
-VOID BbpRadarDetectionStart(
- IN PRTMP_ADAPTER pAd)
-{
- UINT8 RadarPeriod;
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 114, 0x02);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 121, 0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 122, 0x00);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 123, 0x08/*0x80*/);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 124, 0x28);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 125, 0xff);
-
- RadarPeriod = ((UINT)RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + (UINT)pAd->CommonCfg.RadarDetect.DfsSessionTime) < 250 ?
- (RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + pAd->CommonCfg.RadarDetect.DfsSessionTime) : 250;
-
- RTMP_IO_WRITE8(pAd, 0x7020, 0x1d);
- RTMP_IO_WRITE8(pAd, 0x7021, 0x40);
-
- RadarDetectionStart(pAd, 0, RadarPeriod);
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Bbp Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
-
- ========================================================================
-*/
-VOID BbpRadarDetectionStop(
- IN PRTMP_ADAPTER pAd)
-{
- RTMP_IO_WRITE8(pAd, 0x7020, 0x1d);
- RTMP_IO_WRITE8(pAd, 0x7021, 0x60);
-
- RadarDetectionStop(pAd);
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
-
- ========================================================================
-*/
-VOID RadarDetectionStart(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN CTSProtect,
- IN UINT8 CTSPeriod)
-{
- UINT8 DfsActiveTime = (pAd->CommonCfg.RadarDetect.DfsSessionTime & 0x1f);
- UINT8 CtsProtect = (CTSProtect == 1) ? 0x02 : 0x01; // CTS protect.
-
- if (CTSProtect != 0)
- {
- switch(pAd->CommonCfg.RadarDetect.RDDurRegion)
- {
- case FCC:
- case JAP_W56:
- CtsProtect = 0x03;
- break;
-
- case CE:
- case JAP_W53:
- default:
- CtsProtect = 0x02;
- break;
- }
- }
- else
- CtsProtect = 0x01;
-
-
- // send start-RD with CTS protection command to MCU
- // highbyte [7] reserve
- // highbyte [6:5] 0x: stop Carrier/Radar detection
- // highbyte [10]: Start Carrier/Radar detection without CTS protection, 11: Start Carrier/Radar detection with CTS protection
- // highbyte [4:0] Radar/carrier detection duration. In 1ms.
-
- // lowbyte [7:0] Radar/carrier detection period, in 1ms.
- AsicSendCommandToMcu(pAd, 0x60, 0xff, CTSPeriod, DfsActiveTime | (CtsProtect << 5));
- //AsicSendCommandToMcu(pAd, 0x63, 0xff, 10, 0);
-
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Radar detection routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- TRUE Found radar signal
- FALSE Not found radar signal
-
- ========================================================================
-*/
-VOID RadarDetectionStop(
- IN PRTMP_ADAPTER pAd)
-{
- DBGPRINT(RT_DEBUG_TRACE,("RadarDetectionStop.\n"));
- AsicSendCommandToMcu(pAd, 0x60, 0xff, 0x00, 0x00); // send start-RD with CTS protection command to MCU
-
- return;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Radar channel check routine
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- TRUE need to do radar detect
- FALSE need not to do radar detect
-
- ========================================================================
-*/
-BOOLEAN RadarChannelCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Ch)
-{
-#if 1
- INT i;
- BOOLEAN result = FALSE;
-
- for (i=0; i<pAd->ChannelListNum; i++)
- {
- if (Ch == pAd->ChannelList[i].Channel)
- {
- result = pAd->ChannelList[i].DfsReq;
- break;
- }
- }
-
- return result;
-#else
- INT i;
- UCHAR Channel[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
-
- for (i=0; i<15; i++)
- {
- if (Ch == Channel[i])
- {
- break;
- }
- }
-
- if (i != 15)
- return TRUE;
- else
- return FALSE;
-#endif
-}
-
-ULONG JapRadarType(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- const UCHAR Channel[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
-
- if (pAd->CommonCfg.RadarDetect.RDDurRegion != JAP)
- {
- return pAd->CommonCfg.RadarDetect.RDDurRegion;
- }
-
- for (i=0; i<15; i++)
- {
- if (pAd->CommonCfg.Channel == Channel[i])
- {
- break;
- }
- }
-
- if (i < 4)
- return JAP_W53;
- else if (i < 15)
- return JAP_W56;
- else
- return JAP; // W52
-
-}
-
-ULONG RTMPBbpReadRadarDuration(
- IN PRTMP_ADAPTER pAd)
-{
- UINT8 byteValue = 0;
- ULONG result;
-
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R115, &byteValue);
-
- result = 0;
- switch (byteValue)
- {
- case 1: // radar signal detected by pulse mode.
- case 2: // radar signal detected by width mode.
- result = RTMPReadRadarDuration(pAd);
- break;
-
- case 0: // No radar signal.
- default:
-
- result = 0;
- break;
- }
-
- return result;
-}
-
-ULONG RTMPReadRadarDuration(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG result = 0;
-
-#ifdef DFS_SUPPORT
- UINT8 duration1 = 0, duration2 = 0, duration3 = 0;
-
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R116, &duration1);
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R117, &duration2);
- BBP_IO_READ8_BY_REG_ID(pAd, BBP_R118, &duration3);
- result = (duration1 << 16) + (duration2 << 8) + duration3;
-#endif // DFS_SUPPORT //
-
- return result;
-
-}
-
-VOID RTMPCleanRadarDuration(
- IN PRTMP_ADAPTER pAd)
-{
- return;
-}
-
-/*
- ========================================================================
- Routine Description:
- Radar wave detection. The API should be invoke each second.
-
- Arguments:
- pAd - Adapter pointer
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID ApRadarDetectPeriodic(
- IN PRTMP_ADAPTER pAd)
-{
- INT i;
-
- pAd->CommonCfg.RadarDetect.InServiceMonitorCount++;
-
- for (i=0; i<pAd->ChannelListNum; i++)
- {
- if (pAd->ChannelList[i].RemainingTimeForUse > 0)
- {
- pAd->ChannelList[i].RemainingTimeForUse --;
- if ((pAd->Mlme.PeriodicRound%5) == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RadarDetectPeriodic - ch=%d, RemainingTimeForUse=%d\n", pAd->ChannelList[i].Channel, pAd->ChannelList[i].RemainingTimeForUse));
- }
- }
- }
-
- //radar detect
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- RadarDetectPeriodic(pAd);
- }
-
- return;
-}
-
-// Periodic Radar detection, switch channel will occur in RTMPHandleTBTTInterrupt()
-// Before switch channel, driver needs doing channel switch announcement.
-VOID RadarDetectPeriodic(
- IN PRTMP_ADAPTER pAd)
-{
- // need to check channel availability, after switch channel
- if (pAd->CommonCfg.RadarDetect.RDMode != RD_SILENCE_MODE)
- return;
-
- // channel availability check time is 60sec, use 65 for assurance
- if (pAd->CommonCfg.RadarDetect.RDCount++ > pAd->CommonCfg.RadarDetect.ChMovingTime)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n"));
- BbpRadarDetectionStop(pAd);
- AsicEnableBssSync(pAd);
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
-
- return;
- }
-
- return;
-}
-
-
-/*
- ==========================================================================
- Description:
- change channel moving time for DFS testing.
-
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 set ChMovTime=[value]
- ==========================================================================
-*/
-INT Set_ChMovingTime_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT8 Value;
-
- Value = simple_strtol(arg, 0, 10);
-
- pAd->CommonCfg.RadarDetect.ChMovingTime = Value;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__,
- pAd->CommonCfg.RadarDetect.ChMovingTime));
-
- return TRUE;
-}
-
-INT Set_LongPulseRadarTh_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT8 Value;
-
- Value = simple_strtol(arg, 0, 10) > 10 ? 10 : simple_strtol(arg, 0, 10);
-
- pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__,
- pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
-
- return TRUE;
-}
-
-
+#include "../../rt2870/common/dfs.c"
diff --git a/drivers/staging/rt3070/common/eeprom.c b/drivers/staging/rt3070/common/eeprom.c
index 63e1dc14d151..0c567d3dad0f 100644
--- a/drivers/staging/rt3070/common/eeprom.c
+++ b/drivers/staging/rt3070/common/eeprom.c
@@ -1,1498 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- eeprom.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#include "../rt_config.h"
-
-// IRQL = PASSIVE_LEVEL
-VOID RaiseClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x)
-{
- *x = *x | EESK;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
- RTMPusecDelay(1); // Max frequency = 1MHz in Spec. definition
-}
-
-// IRQL = PASSIVE_LEVEL
-VOID LowerClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x)
-{
- *x = *x & ~EESK;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
- RTMPusecDelay(1);
-}
-
-// IRQL = PASSIVE_LEVEL
-USHORT ShiftInBits(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x,i;
- USHORT data=0;
-
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~( EEDO | EEDI);
-
- for(i=0; i<16; i++)
- {
- data = data << 1;
- RaiseClock(pAd, &x);
-
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- LowerClock(pAd, &x); //prevent read failed
-
- x &= ~(EEDI);
- if(x & EEDO)
- data |= 1;
- }
-
- return data;
-}
-
-// IRQL = PASSIVE_LEVEL
-VOID ShiftOutBits(
- IN PRTMP_ADAPTER pAd,
- IN USHORT data,
- IN USHORT count)
-{
- UINT32 x,mask;
-
- mask = 0x01 << (count - 1);
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~(EEDO | EEDI);
-
- do
- {
- x &= ~EEDI;
- if(data & mask) x |= EEDI;
-
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- mask = mask >> 1;
- } while(mask);
-
- x &= ~EEDI;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-}
-
-// IRQL = PASSIVE_LEVEL
-VOID EEpromCleanup(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x;
-
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- x &= ~(EECS | EEDI);
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-}
-
-VOID EWEN(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x;
-
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- // output the read_opcode and six pulse in that order
- ShiftOutBits(pAd, EEPROM_EWEN_OPCODE, 5);
- ShiftOutBits(pAd, 0, 6);
-
- EEpromCleanup(pAd);
-}
-
-VOID EWDS(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 x;
-
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
-
- // output the read_opcode and six pulse in that order
- ShiftOutBits(pAd, EEPROM_EWDS_OPCODE, 5);
- ShiftOutBits(pAd, 0, 6);
-
- EEpromCleanup(pAd);
-}
-
-// IRQL = PASSIVE_LEVEL
-USHORT RTMP_EEPROM_READ16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset)
-{
- UINT32 x;
- USHORT data;
-
- if (pAd->NicConfig2.field.AntDiversity)
- {
- pAd->EepromAccess = TRUE;
- }
-//2008/09/11:KH add to support efuse<--
-//2008/09/11:KH add to support efuse-->
-{
- Offset /= 2;
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // patch can not access e-Fuse issue
- if (!IS_RT3090(pAd))
- {
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
- }
-
- // output the read_opcode and register number in that order
- ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
- ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
-
- // Now read the data (16 bits) in from the selected EEPROM word
- data = ShiftInBits(pAd);
-
- EEpromCleanup(pAd);
-
- // Antenna and EEPROM access are both using EESK pin,
- // Therefor we should avoid accessing EESK at the same time
- // Then restore antenna after EEPROM access
- if ((pAd->NicConfig2.field.AntDiversity) || (pAd->RfIcType == RFIC_3020))
- {
- pAd->EepromAccess = FALSE;
- AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
- }
-}
- return data;
-} //ReadEEprom
-
-VOID RTMP_EEPROM_WRITE16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Data)
-{
- UINT32 x;
-
- if (pAd->NicConfig2.field.AntDiversity)
- {
- pAd->EepromAccess = TRUE;
- }
- //2008/09/11:KH add to support efuse<--
-//2008/09/11:KH add to support efuse-->
- {
- Offset /= 2;
-
- EWEN(pAd);
-
- // reset bits and set EECS
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EEDI | EEDO | EESK);
- x |= EECS;
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- // patch can not access e-Fuse issue
- if (!IS_RT3090(pAd))
- {
- // kick a pulse
- RaiseClock(pAd, &x);
- LowerClock(pAd, &x);
- }
-
- // output the read_opcode ,register number and data in that order
- ShiftOutBits(pAd, EEPROM_WRITE_OPCODE, 3);
- ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
- ShiftOutBits(pAd, Data, 16); // 16-bit access
-
- // read DO status
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
- EEpromCleanup(pAd);
-
- RTMPusecDelay(10000); //delay for twp(MAX)=10ms
-
- EWDS(pAd);
-
- EEpromCleanup(pAd);
-
- // Antenna and EEPROM access are both using EESK pin,
- // Therefor we should avoid accessing EESK at the same time
- // Then restore antenna after EEPROM access
- if ((pAd->NicConfig2.field.AntDiversity) || (pAd->RfIcType == RFIC_3020))
- {
- pAd->EepromAccess = FALSE;
- AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
- }
-}
-}
-
-//2008/09/11:KH add to support efuse<--
-#ifdef RT30xx
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-UCHAR eFuseReadRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- OUT USHORT* pData)
-{
- EFUSE_CTRL_STRUC eFuseCtrlStruc;
- int i;
- USHORT efuseDataOffset;
- UINT32 data;
-
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
- //Use the eeprom logical address and covert to address to block number
- eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
- //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 0.
- eFuseCtrlStruc.field.EFSROM_MODE = 0;
-
- //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
- eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
- NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
- RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
- //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
- i = 0;
- while(i < 100)
- {
- //rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4);
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
- if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
- {
- break;
- }
- RTMPusecDelay(2);
- i++;
- }
-
- //if EFSROM_AOUT is not found in physical address, write 0xffff
- if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f)
- {
- for(i=0; i<Length/2; i++)
- *(pData+2*i) = 0xffff;
- }
- else
- {
- //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x590-0x59C)
- efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ;
- //data hold 4 bytes data.
- //In RTMP_IO_READ32 will automatically execute 32-bytes swapping
- RTMP_IO_READ32(pAd, efuseDataOffset, &data);
- //Decide the upper 2 bytes or the bottom 2 bytes.
- // Little-endian S | S Big-endian
- // addr 3 2 1 0 | 0 1 2 3
- // Ori-V D C B A | A B C D
- //After swapping
- // D C B A | D C B A
- //Return 2-bytes
- //The return byte statrs from S. Therefore, the little-endian will return BA, the Big-endian will return DC.
- //For returning the bottom 2 bytes, the Big-endian should shift right 2-bytes.
-#ifdef RT_BIG_ENDIAN
- data = data << (8*((Offset & 0x3)^0x2));
-#else
- data = data >> (8*(Offset & 0x3));
-#endif
-
- NdisMoveMemory(pData, &data, Length);
- }
-
- return (UCHAR) eFuseCtrlStruc.field.EFSROM_AOUT;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID eFusePhysicalReadRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- OUT USHORT* pData)
-{
- EFUSE_CTRL_STRUC eFuseCtrlStruc;
- int i;
- USHORT efuseDataOffset;
- UINT32 data;
-
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
- eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
- //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1.
- //Read in physical view
- eFuseCtrlStruc.field.EFSROM_MODE = 1;
-
- //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
- eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
- NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
- RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
- //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
- i = 0;
- while(i < 100)
- {
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
- if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
- break;
- RTMPusecDelay(2);
- i++;
- }
-
- //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590)
- //Because the size of each EFUSE_DATA is 4 Bytes, the size of address of each is 2 bits.
- //The previous 2 bits is the EFUSE_DATA number, the last 2 bits is used to decide which bytes
- //Decide which EFUSE_DATA to read
- //590:F E D C
- //594:B A 9 8
- //598:7 6 5 4
- //59C:3 2 1 0
- efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ;
-
- RTMP_IO_READ32(pAd, efuseDataOffset, &data);
-
-#ifdef RT_BIG_ENDIAN
- data = data << (8*((Offset & 0x3)^0x2));
-#else
- data = data >> (8*(Offset & 0x3));
-#endif
-
- NdisMoveMemory(pData, &data, Length);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID eFuseReadPhysical(
- IN PRTMP_ADAPTER pAd,
- IN PUSHORT lpInBuffer,
- IN ULONG nInBufferSize,
- OUT PUSHORT lpOutBuffer,
- IN ULONG nOutBufferSize
-)
-{
- USHORT* pInBuf = (USHORT*)lpInBuffer;
- USHORT* pOutBuf = (USHORT*)lpOutBuffer;
-
- USHORT Offset = pInBuf[0]; //addr
- USHORT Length = pInBuf[1]; //length
- int i;
-
- for(i=0; i<Length; i+=2)
- {
- eFusePhysicalReadRegisters(pAd,Offset+i, 2, &pOutBuf[i/2]);
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS eFuseRead(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT Length)
-{
- USHORT* pOutBuf = (USHORT*)pData;
- NTSTATUS Status = STATUS_SUCCESS;
- UCHAR EFSROM_AOUT;
- int i;
-
- for(i=0; i<Length; i+=2)
- {
- EFSROM_AOUT = eFuseReadRegisters(pAd, Offset+i, 2, &pOutBuf[i/2]);
- }
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID eFusePhysicalWriteRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- OUT USHORT* pData)
-{
- EFUSE_CTRL_STRUC eFuseCtrlStruc;
- int i;
- USHORT efuseDataOffset;
- UINT32 data, eFuseDataBuffer[4];
-
- //Step0. Write 16-byte of data to EFUSE_DATA0-3 (0x590-0x59C), where EFUSE_DATA0 is the LSB DW, EFUSE_DATA3 is the MSB DW.
-
- /////////////////////////////////////////////////////////////////
- //read current values of 16-byte block
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
- eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
- //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1.
- eFuseCtrlStruc.field.EFSROM_MODE = 1;
-
- //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
- eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
- NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
- RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
- //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
- i = 0;
- while(i < 100)
- {
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
- break;
- RTMPusecDelay(2);
- i++;
- }
-
- //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590)
- efuseDataOffset = EFUSE_DATA3;
- for(i=0; i< 4; i++)
- {
- RTMP_IO_READ32(pAd, efuseDataOffset, (PUINT32) &eFuseDataBuffer[i]);
- efuseDataOffset -= 4;
- }
-
- //Update the value, the offset is multiple of 2, length is 2
- efuseDataOffset = (Offset & 0xc) >> 2;
- data = pData[0] & 0xffff;
- //The offset should be 0x***10 or 0x***00
- if((Offset % 4) != 0)
- {
- eFuseDataBuffer[efuseDataOffset] = (eFuseDataBuffer[efuseDataOffset] & 0xffff) | (data << 16);
- }
- else
- {
- eFuseDataBuffer[efuseDataOffset] = (eFuseDataBuffer[efuseDataOffset] & 0xffff0000) | data;
- }
-
- efuseDataOffset = EFUSE_DATA3;
- for(i=0; i< 4; i++)
- {
- RTMP_IO_WRITE32(pAd, efuseDataOffset, eFuseDataBuffer[i]);
- efuseDataOffset -= 4;
- }
- /////////////////////////////////////////////////////////////////
-
- //Step1. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
- eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
- //Step2. Write EFSROM_MODE (0x580, bit7:bit6) to 3.
- eFuseCtrlStruc.field.EFSROM_MODE = 3;
-
- //Step3. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical write procedure.
- eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
- NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
- RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
- //Step4. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. It¡¦s done.
- i = 0;
- while(i < 100)
- {
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
- break;
-
- RTMPusecDelay(2);
- i++;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS eFuseWriteRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- IN USHORT* pData)
-{
- USHORT i;
- USHORT eFuseData;
- USHORT LogicalAddress, BlkNum = 0xffff;
- UCHAR EFSROM_AOUT;
-
- USHORT addr,tmpaddr, InBuf[3], tmpOffset;
- USHORT buffer[8];
- BOOLEAN bWriteSuccess = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters Offset=%x, pData=%x\n", Offset, *pData));
-
- //Step 0. find the entry in the mapping table
- //The address of EEPROM is 2-bytes alignment.
- //The last bit is used for alignment, so it must be 0.
- tmpOffset = Offset & 0xfffe;
- EFSROM_AOUT = eFuseReadRegisters(pAd, tmpOffset, 2, &eFuseData);
-
- if( EFSROM_AOUT == 0x3f)
- { //find available logical address pointer
- //the logical address does not exist, find an empty one
- //from the first address of block 45=16*45=0x2d0 to the last address of block 47
- //==>48*16-3(reserved)=2FC
- for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
- {
- //Retrive the logical block nubmer form each logical address pointer
- //It will access two logical address pointer each time.
- eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
- if( (LogicalAddress & 0xff) == 0)
- {//Not used logical address pointer
- BlkNum = i-EFUSE_USAGE_MAP_START;
- break;
- }
- else if(( (LogicalAddress >> 8) & 0xff) == 0)
- {//Not used logical address pointer
- if (i != EFUSE_USAGE_MAP_END)
- {
- BlkNum = i-EFUSE_USAGE_MAP_START+1;
- }
- break;
- }
- }
- }
- else
- {
- BlkNum = EFSROM_AOUT;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters BlkNum = %d \n", BlkNum));
-
- if(BlkNum == 0xffff)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n"));
- return FALSE;
- }
-
- //Step 1. Save data of this block which is pointed by the avaible logical address pointer
- // read and save the original block data
- for(i =0; i<8; i++)
- {
- addr = BlkNum * 0x10 ;
-
- InBuf[0] = addr+2*i;
- InBuf[1] = 2;
- InBuf[2] = 0x0;
-
- eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
-
- buffer[i] = InBuf[2];
- }
-
- //Step 2. Update the data in buffer, and write the data to Efuse
- buffer[ (Offset >> 1) % 8] = pData[0];
-
- do
- {
- //Step 3. Write the data to Efuse
- if(!bWriteSuccess)
- {
- for(i =0; i<8; i++)
- {
- addr = BlkNum * 0x10 ;
-
- InBuf[0] = addr+2*i;
- InBuf[1] = 2;
- InBuf[2] = buffer[i];
-
- eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2);
- }
- }
- else
- {
- addr = BlkNum * 0x10 ;
-
- InBuf[0] = addr+(Offset % 16);
- InBuf[1] = 2;
- InBuf[2] = pData[0];
-
- eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2);
- }
-
- //Step 4. Write mapping table
- addr = EFUSE_USAGE_MAP_START+BlkNum;
-
- tmpaddr = addr;
-
- if(addr % 2 != 0)
- addr = addr -1;
- InBuf[0] = addr;
- InBuf[1] = 2;
-
- //convert the address from 10 to 8 bit ( bit7, 6 = parity and bit5 ~ 0 = bit9~4), and write to logical map entry
- tmpOffset = Offset;
- tmpOffset >>= 4;
- tmpOffset |= ((~((tmpOffset & 0x01) ^ ( tmpOffset >> 1 & 0x01) ^ (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01))) << 6) & 0x40;
- tmpOffset |= ((~( (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01) ^ (tmpOffset >> 4 & 0x01) ^ ( tmpOffset >> 5 & 0x01))) << 7) & 0x80;
-
- // write the logical address
- if(tmpaddr%2 != 0)
- InBuf[2] = tmpOffset<<8;
- else
- InBuf[2] = tmpOffset;
-
- eFuseWritePhysical(pAd,&InBuf[0], 6, NULL, 0);
-
- //Step 5. Compare data if not the same, invalidate the mapping entry, then re-write the data until E-fuse is exhausted
- bWriteSuccess = TRUE;
- for(i =0; i<8; i++)
- {
- addr = BlkNum * 0x10 ;
-
- InBuf[0] = addr+2*i;
- InBuf[1] = 2;
- InBuf[2] = 0x0;
-
- eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
-
- if(buffer[i] != InBuf[2])
- {
- bWriteSuccess = FALSE;
- break;
- }
- }
-
- //Step 6. invlidate mapping entry and find a free mapping entry if not succeed
- if (!bWriteSuccess)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Not bWriteSuccess BlkNum = %d\n", BlkNum));
-
- // the offset of current mapping entry
- addr = EFUSE_USAGE_MAP_START+BlkNum;
-
- //find a new mapping entry
- BlkNum = 0xffff;
- for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
- {
- eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
- if( (LogicalAddress & 0xff) == 0)
- {
- BlkNum = i-EFUSE_USAGE_MAP_START;
- break;
- }
- else if(( (LogicalAddress >> 8) & 0xff) == 0)
- {
- if (i != EFUSE_USAGE_MAP_END)
- {
- BlkNum = i+1-EFUSE_USAGE_MAP_START;
- }
- break;
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Not bWriteSuccess new BlkNum = %d\n", BlkNum));
- if(BlkNum == 0xffff)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n"));
- return FALSE;
- }
-
- //invalidate the original mapping entry if new entry is not found
- tmpaddr = addr;
-
- if(addr % 2 != 0)
- addr = addr -1;
- InBuf[0] = addr;
- InBuf[1] = 2;
-
- eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
-
- // write the logical address
- if(tmpaddr%2 != 0)
- {
- // Invalidate the high byte
- for (i=8; i<15; i++)
- {
- if( ( (InBuf[2] >> i) & 0x01) == 0)
- {
- InBuf[2] |= (0x1 <<i);
- break;
- }
- }
- }
- else
- {
- // invalidate the low byte
- for (i=0; i<8; i++)
- {
- if( ( (InBuf[2] >> i) & 0x01) == 0)
- {
- InBuf[2] |= (0x1 <<i);
- break;
- }
- }
- }
- eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 0);
- }
- }
- while(!bWriteSuccess);
-
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID eFuseWritePhysical(
- IN PRTMP_ADAPTER pAd,
- PUSHORT lpInBuffer,
- ULONG nInBufferSize,
- PUCHAR lpOutBuffer,
- ULONG nOutBufferSize
-)
-{
- USHORT* pInBuf = (USHORT*)lpInBuffer;
- int i;
- //USHORT* pOutBuf = (USHORT*)ioBuffer;
-
- USHORT Offset = pInBuf[0]; //addr
- USHORT Length = pInBuf[1]; //length
- USHORT* pValueX = &pInBuf[2]; //value ...
- // Little-endian S | S Big-endian
- // addr 3 2 1 0 | 0 1 2 3
- // Ori-V D C B A | A B C D
- //After swapping
- // D C B A | D C B A
- //Both the little and big-endian use the same sequence to write data.
- //Therefore, we only need swap data when read the data.
- for(i=0; i<Length; i+=2)
- {
- eFusePhysicalWriteRegisters(pAd, Offset+i, 2, &pValueX[i/2]);
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS eFuseWrite(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length)
-{
- int i;
-
- USHORT* pValueX = (PUSHORT) pData; //value ...
- //The input value=3070 will be stored as following
- // Little-endian S | S Big-endian
- // addr 1 0 | 0 1
- // Ori-V 30 70 | 30 70
- //After swapping
- // 30 70 | 70 30
- //Casting
- // 3070 | 7030 (x)
- //The swapping should be removed for big-endian
- for(i=0; i<length; i+=2)
- {
- eFuseWriteRegisters(pAd, Offset+i, 2, &pValueX[i/2]);
- }
-
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-INT set_eFuseGetFreeBlockCount_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT i;
- USHORT LogicalAddress;
- USHORT efusefreenum=0;
- if(!pAd->bUseEfuse)
- return FALSE;
- for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i+=2)
- {
- eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
- if( (LogicalAddress & 0xff) == 0)
- {
- efusefreenum= (UCHAR) (EFUSE_USAGE_MAP_END-i+1);
- break;
- }
- else if(( (LogicalAddress >> 8) & 0xff) == 0)
- {
- efusefreenum = (UCHAR) (EFUSE_USAGE_MAP_END-i);
- break;
- }
-
- if(i == EFUSE_USAGE_MAP_END)
- efusefreenum = 0;
- }
- printk("efuseFreeNumber is %d\n",efusefreenum);
- return TRUE;
-}
-INT set_eFusedump_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-USHORT InBuf[3];
- INT i=0;
- if(!pAd->bUseEfuse)
- return FALSE;
- for(i =0; i<EFUSE_USAGE_MAP_END/2; i++)
- {
- InBuf[0] = 2*i;
- InBuf[1] = 2;
- InBuf[2] = 0x0;
-
- eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
- if(i%4==0)
- printk("\nBlock %x:",i/8);
- printk("%04x ",InBuf[2]);
- }
- return TRUE;
-}
-INT set_eFuseLoadFromBin_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *src;
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- UCHAR *buffer;
- UCHAR BinFileSize=0;
- INT i = 0,j=0,k=1;
- USHORT *PDATA;
- USHORT DATA;
- BinFileSize=strlen("RT30xxEEPROM.bin");
- src = kmalloc(128, MEM_ALLOC_FLAG);
- NdisZeroMemory(src, 128);
-
- if(strlen(arg)>0)
- {
-
- NdisMoveMemory(src, arg, strlen(arg));
- }
-
- else
- {
-
- NdisMoveMemory(src, "RT30xxEEPROM.bin", BinFileSize);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("FileName=%s\n",src));
- buffer = kmalloc(MAX_EEPROM_BIN_FILE_SIZE, MEM_ALLOC_FLAG);
-
- if(buffer == NULL)
- {
- kfree(src);
- return FALSE;
-}
- PDATA=kmalloc(sizeof(USHORT)*8,MEM_ALLOC_FLAG);
-
- if(PDATA==NULL)
- {
- kfree(src);
-
- kfree(buffer);
- return FALSE;
- }
- /* Don't change to uid 0, let the file be opened as the "normal" user */
-#if 0
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid=current->fsgid = 0;
-#endif
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- if (src && *src)
- {
- srcf = filp_open(src, O_RDONLY, 0);
- if (IS_ERR(srcf))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
- return FALSE;
- }
- else
- {
- // The object must have a read method
- if (srcf->f_op && srcf->f_op->read)
- {
- memset(buffer, 0x00, MAX_EEPROM_BIN_FILE_SIZE);
- while(srcf->f_op->read(srcf, &buffer[i], 1, &srcf->f_pos)==1)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[i]));
- if((i+1)%8==0)
- DBGPRINT(RT_DEBUG_TRACE, ("\n"));
- i++;
- if(i>=MAX_EEPROM_BIN_FILE_SIZE)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld reading %s, The file is too large[1024]\n", -PTR_ERR(srcf),src));
- kfree(PDATA);
- kfree(buffer);
- kfree(src);
- return FALSE;
- }
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("--> Error!! System doest not support read function\n"));
- kfree(PDATA);
- kfree(buffer);
- kfree(src);
- return FALSE;
- }
- }
-
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("--> Error src or srcf is null\n"));
- kfree(PDATA);
- kfree(buffer);
- return FALSE;
-
- }
-
-
- retval=filp_close(srcf,NULL);
-
- if (retval)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
- }
- set_fs(orgfs);
-#if 0
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
-#endif
- for(j=0;j<i;j++)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[j]));
- if((j+1)%2==0)
- PDATA[j/2%8]=((buffer[j]<<8)&0xff00)|(buffer[j-1]&0xff);
- if(j%16==0)
- {
- k=buffer[j];
- }
- else
- {
- k&=buffer[j];
- if((j+1)%16==0)
- {
-
- DBGPRINT(RT_DEBUG_TRACE, (" result=%02X,blk=%02x\n",k,j/16));
-
- if(k!=0xff)
- eFuseWriteRegistersFromBin(pAd,(USHORT)j-15, 16, PDATA);
- else
- {
- if(eFuseReadRegisters(pAd,j, 2,(PUSHORT)&DATA)!=0x3f)
- eFuseWriteRegistersFromBin(pAd,(USHORT)j-15, 16, PDATA);
- }
- /*
- for(l=0;l<8;l++)
- printk("%04x ",PDATA[l]);
- printk("\n");
- */
- NdisZeroMemory(PDATA,16);
-
-
- }
- }
-
-
- }
-
-
- kfree(PDATA);
- kfree(buffer);
- kfree(src);
- return TRUE;
-}
-NTSTATUS eFuseWriteRegistersFromBin(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- IN USHORT* pData)
-{
- USHORT i;
- USHORT eFuseData;
- USHORT LogicalAddress, BlkNum = 0xffff;
- UCHAR EFSROM_AOUT,Loop=0;
- EFUSE_CTRL_STRUC eFuseCtrlStruc;
- USHORT efuseDataOffset;
- UINT32 data,tempbuffer;
- USHORT addr,tmpaddr, InBuf[3], tmpOffset;
- UINT32 buffer[4];
- BOOLEAN bWriteSuccess = TRUE;
- BOOLEAN bNotWrite=TRUE;
- BOOLEAN bAllocateNewBlk=TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin Offset=%x, pData=%04x:%04x:%04x:%04x\n", Offset, *pData,*(pData+1),*(pData+2),*(pData+3)));
-
- do
- {
- //Step 0. find the entry in the mapping table
- //The address of EEPROM is 2-bytes alignment.
- //The last bit is used for alignment, so it must be 0.
- Loop++;
- tmpOffset = Offset & 0xfffe;
- EFSROM_AOUT = eFuseReadRegisters(pAd, tmpOffset, 2, &eFuseData);
-
- if( EFSROM_AOUT == 0x3f)
- { //find available logical address pointer
- //the logical address does not exist, find an empty one
- //from the first address of block 45=16*45=0x2d0 to the last address of block 47
- //==>48*16-3(reserved)=2FC
- bAllocateNewBlk=TRUE;
- for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
- {
- //Retrive the logical block nubmer form each logical address pointer
- //It will access two logical address pointer each time.
- eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
- if( (LogicalAddress & 0xff) == 0)
- {//Not used logical address pointer
- BlkNum = i-EFUSE_USAGE_MAP_START;
- break;
- }
- else if(( (LogicalAddress >> 8) & 0xff) == 0)
- {//Not used logical address pointer
- if (i != EFUSE_USAGE_MAP_END)
- {
- BlkNum = i-EFUSE_USAGE_MAP_START+1;
- }
- break;
- }
- }
- }
- else
- {
- bAllocateNewBlk=FALSE;
- BlkNum = EFSROM_AOUT;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters BlkNum = %d \n", BlkNum));
-
- if(BlkNum == 0xffff)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n"));
- return FALSE;
- }
- //Step 1.1.0
- //If the block is not existing in mapping table, create one
- //and write down the 16-bytes data to the new block
- if(bAllocateNewBlk)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Allocate New Blk\n"));
- efuseDataOffset = EFUSE_DATA3;
- for(i=0; i< 4; i++)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Allocate New Blk, Data%d=%04x%04x\n",3-i,pData[2*i+1],pData[2*i]));
- tempbuffer=((pData[2*i+1]<<16)&0xffff0000)|pData[2*i];
-
-
- RTMP_IO_WRITE32(pAd, efuseDataOffset,tempbuffer);
- efuseDataOffset -= 4;
-
- }
- /////////////////////////////////////////////////////////////////
-
- //Step1.1.1. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
- eFuseCtrlStruc.field.EFSROM_AIN = BlkNum* 0x10 ;
-
- //Step1.1.2. Write EFSROM_MODE (0x580, bit7:bit6) to 3.
- eFuseCtrlStruc.field.EFSROM_MODE = 3;
-
- //Step1.1.3. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical write procedure.
- eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
- NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
-
- RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
- //Step1.1.4. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. It¡¦s done.
- i = 0;
- while(i < 100)
- {
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
- break;
-
- RTMPusecDelay(2);
- i++;
- }
-
- }
- else
- { //Step1.2.
- //If the same logical number is existing, check if the writting data and the data
- //saving in this block are the same.
- /////////////////////////////////////////////////////////////////
- //read current values of 16-byte block
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- //Step1.2.0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment.
- eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
- //Step1.2.1. Write EFSROM_MODE (0x580, bit7:bit6) to 1.
- eFuseCtrlStruc.field.EFSROM_MODE = 0;
-
- //Step1.2.2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure.
- eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
- NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
- RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
- //Step1.2.3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
- i = 0;
- while(i < 100)
- {
- RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc);
-
- if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
- break;
- RTMPusecDelay(2);
- i++;
- }
-
- //Step1.2.4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590)
- efuseDataOffset = EFUSE_DATA3;
- for(i=0; i< 4; i++)
- {
- RTMP_IO_READ32(pAd, efuseDataOffset, (PUINT32) &buffer[i]);
- efuseDataOffset -= 4;
- }
- //Step1.2.5. Check if the data of efuse and the writing data are the same.
- for(i =0; i<4; i++)
- {
- tempbuffer=((pData[2*i+1]<<16)&0xffff0000)|pData[2*i];
- DBGPRINT(RT_DEBUG_TRACE, ("buffer[%d]=%x,pData[%d]=%x,pData[%d]=%x,tempbuffer=%x\n",i,buffer[i],2*i,pData[2*i],2*i+1,pData[2*i+1],tempbuffer));
-
- if(((buffer[i]&0xffff0000)==(pData[2*i+1]<<16))&&((buffer[i]&0xffff)==pData[2*i]))
- bNotWrite&=TRUE;
- else
- {
- bNotWrite&=FALSE;
- break;
- }
- }
- if(!bNotWrite)
- {
- printk("The data is not the same\n");
-
- for(i =0; i<8; i++)
- {
- addr = BlkNum * 0x10 ;
-
- InBuf[0] = addr+2*i;
- InBuf[1] = 2;
- InBuf[2] = pData[i];
-
- eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2);
- }
-
- }
- else
- return TRUE;
- }
-
-
-
- //Step 2. Write mapping table
- addr = EFUSE_USAGE_MAP_START+BlkNum;
-
- tmpaddr = addr;
-
- if(addr % 2 != 0)
- addr = addr -1;
- InBuf[0] = addr;
- InBuf[1] = 2;
-
- //convert the address from 10 to 8 bit ( bit7, 6 = parity and bit5 ~ 0 = bit9~4), and write to logical map entry
- tmpOffset = Offset;
- tmpOffset >>= 4;
- tmpOffset |= ((~((tmpOffset & 0x01) ^ ( tmpOffset >> 1 & 0x01) ^ (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01))) << 6) & 0x40;
- tmpOffset |= ((~( (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01) ^ (tmpOffset >> 4 & 0x01) ^ ( tmpOffset >> 5 & 0x01))) << 7) & 0x80;
-
- // write the logical address
- if(tmpaddr%2 != 0)
- InBuf[2] = tmpOffset<<8;
- else
- InBuf[2] = tmpOffset;
-
- eFuseWritePhysical(pAd,&InBuf[0], 6, NULL, 0);
-
- //Step 3. Compare data if not the same, invalidate the mapping entry, then re-write the data until E-fuse is exhausted
- bWriteSuccess = TRUE;
- for(i =0; i<8; i++)
- {
- addr = BlkNum * 0x10 ;
-
- InBuf[0] = addr+2*i;
- InBuf[1] = 2;
- InBuf[2] = 0x0;
-
- eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
- DBGPRINT(RT_DEBUG_TRACE, ("addr=%x, buffer[i]=%x,InBuf[2]=%x\n",InBuf[0],pData[i],InBuf[2]));
- if(pData[i] != InBuf[2])
- {
- bWriteSuccess = FALSE;
- break;
- }
- }
-
- //Step 4. invlidate mapping entry and find a free mapping entry if not succeed
-
- if (!bWriteSuccess&&Loop<2)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin::Not bWriteSuccess BlkNum = %d\n", BlkNum));
-
- // the offset of current mapping entry
- addr = EFUSE_USAGE_MAP_START+BlkNum;
-
- //find a new mapping entry
- BlkNum = 0xffff;
- for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2)
- {
- eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
- if( (LogicalAddress & 0xff) == 0)
- {
- BlkNum = i-EFUSE_USAGE_MAP_START;
- break;
- }
- else if(( (LogicalAddress >> 8) & 0xff) == 0)
- {
- if (i != EFUSE_USAGE_MAP_END)
- {
- BlkNum = i+1-EFUSE_USAGE_MAP_START;
- }
- break;
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin::Not bWriteSuccess new BlkNum = %d\n", BlkNum));
- if(BlkNum == 0xffff)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin: out of free E-fuse space!!!\n"));
- return FALSE;
- }
-
- //invalidate the original mapping entry if new entry is not found
- tmpaddr = addr;
-
- if(addr % 2 != 0)
- addr = addr -1;
- InBuf[0] = addr;
- InBuf[1] = 2;
-
- eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
-
- // write the logical address
- if(tmpaddr%2 != 0)
- {
- // Invalidate the high byte
- for (i=8; i<15; i++)
- {
- if( ( (InBuf[2] >> i) & 0x01) == 0)
- {
- InBuf[2] |= (0x1 <<i);
- break;
- }
- }
- }
- else
- {
- // invalidate the low byte
- for (i=0; i<8; i++)
- {
- if( ( (InBuf[2] >> i) & 0x01) == 0)
- {
- InBuf[2] |= (0x1 <<i);
- break;
- }
- }
- }
- eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 0);
- }
-
- }
- while(!bWriteSuccess&&Loop<2);
-
- return TRUE;
-}
-
-#endif // RT30xx //
-//2008/09/11:KH add to support efuse-->
-
+#include "../../rt2870/common/eeprom.c"
diff --git a/drivers/staging/rt3070/common/md5.c b/drivers/staging/rt3070/common/md5.c
index 774776b4b8c3..07528842267a 100644
--- a/drivers/staging/rt3070/common/md5.c
+++ b/drivers/staging/rt3070/common/md5.c
@@ -1,1427 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- md5.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- jan 10-28-03 Initial
- Rita 11-23-04 Modify MD5 and SHA-1
- Rita 10-14-05 Modify SHA-1 in big-endian platform
- */
-#include "../rt_config.h"
-
-/**
- * md5_mac:
- * @key: pointer to the key used for MAC generation
- * @key_len: length of the key in bytes
- * @data: pointer to the data area for which the MAC is generated
- * @data_len: length of the data in bytes
- * @mac: pointer to the buffer holding space for the MAC; the buffer should
- * have space for 128-bit (16 bytes) MD5 hash value
- *
- * md5_mac() determines the message authentication code by using secure hash
- * MD5(key | data | key).
- */
-void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
-{
- MD5_CTX context;
-
- MD5Init(&context);
- MD5Update(&context, key, key_len);
- MD5Update(&context, data, data_len);
- MD5Update(&context, key, key_len);
- MD5Final(mac, &context);
-}
-
-/**
- * hmac_md5:
- * @key: pointer to the key used for MAC generation
- * @key_len: length of the key in bytes
- * @data: pointer to the data area for which the MAC is generated
- * @data_len: length of the data in bytes
- * @mac: pointer to the buffer holding space for the MAC; the buffer should
- * have space for 128-bit (16 bytes) MD5 hash value
- *
- * hmac_md5() determines the message authentication code using HMAC-MD5.
- * This implementation is based on the sample code presented in RFC 2104.
- */
-void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac)
-{
- MD5_CTX context;
- u8 k_ipad[65]; /* inner padding - key XORd with ipad */
- u8 k_opad[65]; /* outer padding - key XORd with opad */
- u8 tk[16];
- int i;
-
- //assert(key != NULL && data != NULL && mac != NULL);
-
- /* if key is longer than 64 bytes reset it to key = MD5(key) */
- if (key_len > 64) {
- MD5_CTX ttcontext;
-
- MD5Init(&ttcontext);
- MD5Update(&ttcontext, key, key_len);
- MD5Final(tk, &ttcontext);
- //key=(PUCHAR)ttcontext.buf;
- key = tk;
- key_len = 16;
- }
-
- /* the HMAC_MD5 transform looks like:
- *
- * MD5(K XOR opad, MD5(K XOR ipad, text))
- *
- * where K is an n byte key
- * ipad is the byte 0x36 repeated 64 times
- * opad is the byte 0x5c repeated 64 times
- * and text is the data being protected */
-
- /* start out by storing key in pads */
- NdisZeroMemory(k_ipad, sizeof(k_ipad));
- NdisZeroMemory(k_opad, sizeof(k_opad));
- //assert(key_len < sizeof(k_ipad));
- NdisMoveMemory(k_ipad, key, key_len);
- NdisMoveMemory(k_opad, key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i = 0; i < 64; i++) {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- /* perform inner MD5 */
- MD5Init(&context); /* init context for 1st pass */
- MD5Update(&context, k_ipad, 64); /* start with inner pad */
- MD5Update(&context, data, data_len); /* then text of datagram */
- MD5Final(mac, &context); /* finish up 1st pass */
-
- /* perform outer MD5 */
- MD5Init(&context); /* init context for 2nd pass */
- MD5Update(&context, k_opad, 64); /* start with outer pad */
- MD5Update(&context, mac, 16); /* then results of 1st hash */
- MD5Final(mac, &context); /* finish up 2nd pass */
-}
-
-#ifndef RT_BIG_ENDIAN
-#define byteReverse(buf, len) /* Nothing */
-#else
-void byteReverse(unsigned char *buf, unsigned longs);
-void byteReverse(unsigned char *buf, unsigned longs)
-{
- do {
- *(UINT32 *)buf = SWAP32(*(UINT32 *)buf);
- buf += 4;
- } while (--longs);
-}
-#endif
-
-
-/* ========================== MD5 implementation =========================== */
-// four base functions for MD5
-#define MD5_F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define MD5_F2(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define MD5_F3(x, y, z) ((x) ^ (y) ^ (z))
-#define MD5_F4(x, y, z) ((y) ^ ((x) | (~z)))
-#define CYCLIC_LEFT_SHIFT(w, s) (((w) << (s)) | ((w) >> (32-(s))))
-
-#define MD5Step(f, w, x, y, z, data, t, s) \
- ( w += f(x, y, z) + data + t, w = (CYCLIC_LEFT_SHIFT(w, s)) & 0xffffffff, w += x )
-
-
-/*
- * Function Description:
- * Initiate MD5 Context satisfied in RFC 1321
- *
- * Arguments:
- * pCtx Pointer to MD5 context
- *
- * Return Value:
- * None
- */
-VOID MD5Init(MD5_CTX *pCtx)
-{
- pCtx->Buf[0]=0x67452301;
- pCtx->Buf[1]=0xefcdab89;
- pCtx->Buf[2]=0x98badcfe;
- pCtx->Buf[3]=0x10325476;
-
- pCtx->LenInBitCount[0]=0;
- pCtx->LenInBitCount[1]=0;
-}
-
-
-/*
- * Function Description:
- * Update MD5 Context, allow of an arrary of octets as the next portion
- * of the message
- *
- * Arguments:
- * pCtx Pointer to MD5 context
- * pData Pointer to input data
- * LenInBytes The length of input data (unit: byte)
- *
- * Return Value:
- * None
- *
- * Note:
- * Called after MD5Init or MD5Update(itself)
- */
-VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
-{
-
- UINT32 TfTimes;
- UINT32 temp;
- unsigned int i;
-
- temp = pCtx->LenInBitCount[0];
-
- pCtx->LenInBitCount[0] = (UINT32) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
-
- if (pCtx->LenInBitCount[0] < temp)
- pCtx->LenInBitCount[1]++; //carry in
-
- pCtx->LenInBitCount[1] += LenInBytes >> 29;
-
- // mod 64 bytes
- temp = (temp >> 3) & 0x3f;
-
- // process lacks of 64-byte data
- if (temp)
- {
- UCHAR *pAds = (UCHAR *) pCtx->Input + temp;
-
- if ((temp+LenInBytes) < 64)
- {
- NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);
- return;
- }
-
- NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp);
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
- pData += 64-temp;
- LenInBytes -= 64-temp;
- } // end of if (temp)
-
-
- TfTimes = (LenInBytes >> 6);
-
- for (i=TfTimes; i>0; i--)
- {
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64);
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
- pData += 64;
- LenInBytes -= 64;
- } // end of for
-
- // buffering lacks of 64-byte data
- if(LenInBytes)
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes);
-
-}
-
-
-/*
- * Function Description:
- * Append padding bits and length of original message in the tail
- * The message digest has to be completed in the end
- *
- * Arguments:
- * Digest Output of Digest-Message for MD5
- * pCtx Pointer to MD5 context
- *
- * Return Value:
- * None
- *
- * Note:
- * Called after MD5Update
- */
-VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
-{
- UCHAR Remainder;
- UCHAR PadLenInBytes;
- UCHAR *pAppend=0;
- unsigned int i;
-
- Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f);
-
- PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder);
-
- pAppend = (UCHAR *)pCtx->Input + Remainder;
-
- // padding bits without crossing block(64-byte based) boundary
- if (Remainder < 56)
- {
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes);
-
- // add data-length field, from low to high
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff);
- }
-
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of if
-
- // padding bits with crossing block(64-byte based) boundary
- else
- {
- // the first block ===
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1));
- PadLenInBytes -= (64 - Remainder - 1);
-
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
-
- // the second block ===
- NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes);
-
- // add data-length field
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff);
- }
-
- byteReverse(pCtx->Input, 16);
- MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of else
-
-
- NdisMoveMemory((UCHAR *)Digest, (UINT32 *)pCtx->Buf, 16); // output
- byteReverse((UCHAR *)Digest, 4);
- NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free
-}
-
-
-/*
- * Function Description:
- * The central algorithm of MD5, consists of four rounds and sixteen
- * steps per round
- *
- * Arguments:
- * Buf Buffers of four states (output: 16 bytes)
- * Mes Input data (input: 64 bytes)
- *
- * Return Value:
- * None
- *
- * Note:
- * Called by MD5Update or MD5Final
- */
-VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16])
-{
- UINT32 Reg[4], Temp;
- unsigned int i;
-
- static UCHAR LShiftVal[16] =
- {
- 7, 12, 17, 22,
- 5, 9 , 14, 20,
- 4, 11, 16, 23,
- 6, 10, 15, 21,
- };
-
-
- // [equal to 4294967296*abs(sin(index))]
- static UINT32 MD5Table[64] =
- {
- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
-
- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
- 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
-
- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
-
- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
- };
-
-
- for (i=0; i<4; i++)
- Reg[i]=Buf[i];
-
-
- // 64 steps in MD5 algorithm
- for (i=0; i<16; i++)
- {
- MD5Step(MD5_F1, Reg[0], Reg[1], Reg[2], Reg[3], Mes[i],
- MD5Table[i], LShiftVal[i & 0x3]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
- for (i=16; i<32; i++)
- {
- MD5Step(MD5_F2, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(5*(i & 0xf)+1) & 0xf],
- MD5Table[i], LShiftVal[(0x1 << 2)+(i & 0x3)]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
- for (i=32; i<48; i++)
- {
- MD5Step(MD5_F3, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(3*(i & 0xf)+5) & 0xf],
- MD5Table[i], LShiftVal[(0x1 << 3)+(i & 0x3)]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
- for (i=48; i<64; i++)
- {
- MD5Step(MD5_F4, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(7*(i & 0xf)) & 0xf],
- MD5Table[i], LShiftVal[(0x3 << 2)+(i & 0x3)]);
-
- // one-word right shift
- Temp = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
- }
-
-
- // (temporary)output
- for (i=0; i<4; i++)
- Buf[i] += Reg[i];
-
-}
-
-
-
-/* ========================= SHA-1 implementation ========================== */
-// four base functions for SHA-1
-#define SHA1_F1(b, c, d) (((b) & (c)) | ((~b) & (d)))
-#define SHA1_F2(b, c, d) ((b) ^ (c) ^ (d))
-#define SHA1_F3(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
-
-
-#define SHA1Step(f, a, b, c, d, e, w, k) \
- ( e += ( f(b, c, d) + w + k + CYCLIC_LEFT_SHIFT(a, 5)) & 0xffffffff, \
- b = CYCLIC_LEFT_SHIFT(b, 30) )
-
-//Initiate SHA-1 Context satisfied in RFC 3174
-VOID SHAInit(SHA_CTX *pCtx)
-{
- pCtx->Buf[0]=0x67452301;
- pCtx->Buf[1]=0xefcdab89;
- pCtx->Buf[2]=0x98badcfe;
- pCtx->Buf[3]=0x10325476;
- pCtx->Buf[4]=0xc3d2e1f0;
-
- pCtx->LenInBitCount[0]=0;
- pCtx->LenInBitCount[1]=0;
-}
-
-/*
- * Function Description:
- * Update SHA-1 Context, allow of an arrary of octets as the next
- * portion of the message
- *
- * Arguments:
- * pCtx Pointer to SHA-1 context
- * pData Pointer to input data
- * LenInBytes The length of input data (unit: byte)
- *
- * Return Value:
- * error indicate more than pow(2,64) bits of data
- *
- * Note:
- * Called after SHAInit or SHAUpdate(itself)
- */
-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
-{
- UINT32 TfTimes;
- UINT32 temp1,temp2;
- unsigned int i;
- UCHAR err=1;
-
- temp1 = pCtx->LenInBitCount[0];
- temp2 = pCtx->LenInBitCount[1];
-
- pCtx->LenInBitCount[0] = (UINT32) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
- if (pCtx->LenInBitCount[0] < temp1)
- pCtx->LenInBitCount[1]++; //carry in
-
-
- pCtx->LenInBitCount[1] = (UINT32) (pCtx->LenInBitCount[1] +(LenInBytes >> 29));
- if (pCtx->LenInBitCount[1] < temp2)
- return (err); //check total length of original data
-
-
- // mod 64 bytes
- temp1 = (temp1 >> 3) & 0x3f;
-
- // process lacks of 64-byte data
- if (temp1)
- {
- UCHAR *pAds = (UCHAR *) pCtx->Input + temp1;
-
- if ((temp1+LenInBytes) < 64)
- {
- NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);
- return (0);
- }
-
- NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp1);
- byteReverse((UCHAR *)pCtx->Input, 16);
-
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
- pData += 64-temp1;
- LenInBytes -= 64-temp1;
- } // end of if (temp1)
-
-
- TfTimes = (LenInBytes >> 6);
-
- for (i=TfTimes; i>0; i--)
- {
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64);
- byteReverse((UCHAR *)pCtx->Input, 16);
-
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
- pData += 64;
- LenInBytes -= 64;
- } // end of for
-
- // buffering lacks of 64-byte data
- if(LenInBytes)
- NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes);
-
- return (0);
-
-}
-
-// Append padding bits and length of original message in the tail
-// The message digest has to be completed in the end
-VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20])
-{
- UCHAR Remainder;
- UCHAR PadLenInBytes;
- UCHAR *pAppend=0;
- unsigned int i;
-
- Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f);
-
- pAppend = (UCHAR *)pCtx->Input + Remainder;
-
- PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder);
-
- // padding bits without crossing block(64-byte based) boundary
- if (Remainder < 56)
- {
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes);
-
- // add data-length field, from high to low
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff);
- }
-
- byteReverse((UCHAR *)pCtx->Input, 16);
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 14);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of if
-
- // padding bits with crossing block(64-byte based) boundary
- else
- {
- // the first block ===
- *pAppend = 0x80;
- PadLenInBytes --;
-
- NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1));
- PadLenInBytes -= (64 - Remainder - 1);
-
- byteReverse((UCHAR *)pCtx->Input, 16);
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
-
-
- // the second block ===
- NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes);
-
- // add data-length field
- for (i=0; i<4; i++)
- {
- pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff);
- pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff);
- }
-
- byteReverse((UCHAR *)pCtx->Input, 16);
- NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
- SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
- } // end of else
-
-
- //Output, bytereverse
- for (i=0; i<20; i++)
- {
- Digest [i] = (UCHAR)(pCtx->Buf[i>>2] >> 8*(3-(i & 0x3)));
- }
-
- NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free
-}
-
-
-// The central algorithm of SHA-1, consists of four rounds and
-// twenty steps per round
-VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20])
-{
- UINT32 Reg[5],Temp;
- unsigned int i;
- UINT32 W[80];
-
- static UINT32 SHA1Table[4] = { 0x5a827999, 0x6ed9eba1,
- 0x8f1bbcdc, 0xca62c1d6 };
-
- Reg[0]=Buf[0];
- Reg[1]=Buf[1];
- Reg[2]=Buf[2];
- Reg[3]=Buf[3];
- Reg[4]=Buf[4];
-
- //the first octet of a word is stored in the 0th element, bytereverse
- for(i = 0; i < 16; i++)
- {
- W[i] = (Mes[i] >> 24) & 0xff;
- W[i] |= (Mes[i] >> 8 ) & 0xff00;
- W[i] |= (Mes[i] << 8 ) & 0xff0000;
- W[i] |= (Mes[i] << 24) & 0xff000000;
- }
-
-
- for (i = 0; i < 64; i++)
- W[16+i] = CYCLIC_LEFT_SHIFT(W[i] ^ W[2+i] ^ W[8+i] ^ W[13+i], 1);
-
-
- // 80 steps in SHA-1 algorithm
- for (i=0; i<80; i++)
- {
- if (i<20)
- SHA1Step(SHA1_F1, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[0]);
-
- else if (i>=20 && i<40)
- SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[1]);
-
- else if (i>=40 && i<60)
- SHA1Step(SHA1_F3, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[2]);
-
- else
- SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
- W[i], SHA1Table[3]);
-
-
- // one-word right shift
- Temp = Reg[4];
- Reg[4] = Reg[3];
- Reg[3] = Reg[2];
- Reg[2] = Reg[1];
- Reg[1] = Reg[0];
- Reg[0] = Temp;
-
- } // end of for-loop
-
-
- // (temporary)output
- for (i=0; i<5; i++)
- Buf[i] += Reg[i];
-
-}
-
-
-/* ========================= AES En/Decryption ========================== */
-
-/* forward S-box */
-static uint32 FSb[256] =
-{
- 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
- 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
- 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
- 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
- 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC,
- 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
- 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A,
- 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
- 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
- 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
- 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B,
- 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
- 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85,
- 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
- 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
- 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
- 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17,
- 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
- 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88,
- 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
- 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
- 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
- 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9,
- 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
- 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6,
- 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
- 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
- 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
- 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94,
- 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
- 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68,
- 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
-};
-
-/* forward table */
-#define FT \
-\
- V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \
- V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \
- V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \
- V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \
- V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \
- V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \
- V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \
- V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \
- V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \
- V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \
- V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \
- V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \
- V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \
- V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \
- V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \
- V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \
- V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \
- V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \
- V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \
- V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \
- V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \
- V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \
- V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \
- V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \
- V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \
- V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \
- V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \
- V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \
- V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \
- V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \
- V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \
- V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \
- V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \
- V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \
- V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \
- V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \
- V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \
- V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \
- V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \
- V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \
- V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \
- V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \
- V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \
- V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \
- V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \
- V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \
- V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \
- V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \
- V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \
- V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \
- V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \
- V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \
- V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \
- V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \
- V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \
- V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \
- V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \
- V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \
- V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \
- V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \
- V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \
- V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \
- V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \
- V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A)
-
-#define V(a,b,c,d) 0x##a##b##c##d
-static uint32 FT0[256] = { FT };
-#undef V
-
-#define V(a,b,c,d) 0x##d##a##b##c
-static uint32 FT1[256] = { FT };
-#undef V
-
-#define V(a,b,c,d) 0x##c##d##a##b
-static uint32 FT2[256] = { FT };
-#undef V
-
-#define V(a,b,c,d) 0x##b##c##d##a
-static uint32 FT3[256] = { FT };
-#undef V
-
-#undef FT
-
-/* reverse S-box */
-
-static uint32 RSb[256] =
-{
- 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38,
- 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
- 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
- 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
- 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D,
- 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
- 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2,
- 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
- 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
- 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
- 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA,
- 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
- 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A,
- 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
- 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
- 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
- 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA,
- 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
- 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85,
- 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
- 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
- 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
- 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20,
- 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
- 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31,
- 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
- 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
- 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
- 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0,
- 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
- 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26,
- 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
-};
-
-/* reverse table */
-
-#define RT \
-\
- V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \
- V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \
- V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \
- V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \
- V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \
- V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \
- V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \
- V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \
- V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \
- V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \
- V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \
- V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \
- V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \
- V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \
- V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \
- V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \
- V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \
- V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \
- V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \
- V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \
- V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \
- V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \
- V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \
- V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \
- V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \
- V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \
- V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \
- V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \
- V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \
- V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \
- V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \
- V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \
- V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \
- V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \
- V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \
- V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \
- V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \
- V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \
- V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \
- V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \
- V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \
- V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \
- V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \
- V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \
- V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \
- V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \
- V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \
- V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \
- V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \
- V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \
- V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \
- V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \
- V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \
- V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \
- V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \
- V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \
- V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \
- V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \
- V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \
- V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \
- V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \
- V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \
- V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \
- V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42)
-
-#define V(a,b,c,d) 0x##a##b##c##d
-static uint32 RT0[256] = { RT };
-#undef V
-
-#define V(a,b,c,d) 0x##d##a##b##c
-static uint32 RT1[256] = { RT };
-#undef V
-
-#define V(a,b,c,d) 0x##c##d##a##b
-static uint32 RT2[256] = { RT };
-#undef V
-
-#define V(a,b,c,d) 0x##b##c##d##a
-static uint32 RT3[256] = { RT };
-#undef V
-
-#undef RT
-
-/* round constants */
-
-static uint32 RCON[10] =
-{
- 0x01000000, 0x02000000, 0x04000000, 0x08000000,
- 0x10000000, 0x20000000, 0x40000000, 0x80000000,
- 0x1B000000, 0x36000000
-};
-
-/* key schedule tables */
-
-static int KT_init = 1;
-
-static uint32 KT0[256];
-static uint32 KT1[256];
-static uint32 KT2[256];
-static uint32 KT3[256];
-
-/* platform-independant 32-bit integer manipulation macros */
-
-#define GET_UINT32(n,b,i) \
-{ \
- (n) = ( (uint32) (b)[(i) ] << 24 ) \
- | ( (uint32) (b)[(i) + 1] << 16 ) \
- | ( (uint32) (b)[(i) + 2] << 8 ) \
- | ( (uint32) (b)[(i) + 3] ); \
-}
-
-#define PUT_UINT32(n,b,i) \
-{ \
- (b)[(i) ] = (uint8) ( (n) >> 24 ); \
- (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \
- (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \
- (b)[(i) + 3] = (uint8) ( (n) ); \
-}
-
-/* AES key scheduling routine */
-
-int rtmp_aes_set_key( aes_context *ctx, uint8 *key, int nbits )
-{
- int i;
- uint32 *RK, *SK;
-
- switch( nbits )
- {
- case 128: ctx->nr = 10; break;
- case 192: ctx->nr = 12; break;
- case 256: ctx->nr = 14; break;
- default : return( 1 );
- }
-
- RK = ctx->erk;
-
- for( i = 0; i < (nbits >> 5); i++ )
- {
- GET_UINT32( RK[i], key, i * 4 );
- }
-
- /* setup encryption round keys */
-
- switch( nbits )
- {
- case 128:
-
- for( i = 0; i < 10; i++, RK += 4 )
- {
- RK[4] = RK[0] ^ RCON[i] ^
- ( FSb[ (uint8) ( RK[3] >> 16 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[3] >> 8 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[3] ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[3] >> 24 ) ] );
-
- RK[5] = RK[1] ^ RK[4];
- RK[6] = RK[2] ^ RK[5];
- RK[7] = RK[3] ^ RK[6];
- }
- break;
-
- case 192:
-
- for( i = 0; i < 8; i++, RK += 6 )
- {
- RK[6] = RK[0] ^ RCON[i] ^
- ( FSb[ (uint8) ( RK[5] >> 16 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[5] >> 8 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[5] ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[5] >> 24 ) ] );
-
- RK[7] = RK[1] ^ RK[6];
- RK[8] = RK[2] ^ RK[7];
- RK[9] = RK[3] ^ RK[8];
- RK[10] = RK[4] ^ RK[9];
- RK[11] = RK[5] ^ RK[10];
- }
- break;
-
- case 256:
-
- for( i = 0; i < 7; i++, RK += 8 )
- {
- RK[8] = RK[0] ^ RCON[i] ^
- ( FSb[ (uint8) ( RK[7] >> 16 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[7] >> 8 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[7] ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[7] >> 24 ) ] );
-
- RK[9] = RK[1] ^ RK[8];
- RK[10] = RK[2] ^ RK[9];
- RK[11] = RK[3] ^ RK[10];
-
- RK[12] = RK[4] ^
- ( FSb[ (uint8) ( RK[11] >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( RK[11] >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( RK[11] >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( RK[11] ) ] );
-
- RK[13] = RK[5] ^ RK[12];
- RK[14] = RK[6] ^ RK[13];
- RK[15] = RK[7] ^ RK[14];
- }
- break;
- }
-
- /* setup decryption round keys */
-
- if( KT_init )
- {
- for( i = 0; i < 256; i++ )
- {
- KT0[i] = RT0[ FSb[i] ];
- KT1[i] = RT1[ FSb[i] ];
- KT2[i] = RT2[ FSb[i] ];
- KT3[i] = RT3[ FSb[i] ];
- }
-
- KT_init = 0;
- }
-
- SK = ctx->drk;
-
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
-
- for( i = 1; i < ctx->nr; i++ )
- {
- RK -= 8;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
-
- *SK++ = KT0[ (uint8) ( *RK >> 24 ) ] ^
- KT1[ (uint8) ( *RK >> 16 ) ] ^
- KT2[ (uint8) ( *RK >> 8 ) ] ^
- KT3[ (uint8) ( *RK ) ]; RK++;
- }
-
- RK -= 8;
-
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
- *SK++ = *RK++;
-
- return( 0 );
-}
-
-/* AES 128-bit block encryption routine */
-
-void rtmp_aes_encrypt(aes_context *ctx, uint8 input[16], uint8 output[16] )
-{
- uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
-
- RK = ctx->erk;
- GET_UINT32( X0, input, 0 ); X0 ^= RK[0];
- GET_UINT32( X1, input, 4 ); X1 ^= RK[1];
- GET_UINT32( X2, input, 8 ); X2 ^= RK[2];
- GET_UINT32( X3, input, 12 ); X3 ^= RK[3];
-
-#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
-{ \
- RK += 4; \
- \
- X0 = RK[0] ^ FT0[ (uint8) ( Y0 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y1 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y2 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y3 ) ]; \
- \
- X1 = RK[1] ^ FT0[ (uint8) ( Y1 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y2 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y3 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y0 ) ]; \
- \
- X2 = RK[2] ^ FT0[ (uint8) ( Y2 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y3 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y0 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y1 ) ]; \
- \
- X3 = RK[3] ^ FT0[ (uint8) ( Y3 >> 24 ) ] ^ \
- FT1[ (uint8) ( Y0 >> 16 ) ] ^ \
- FT2[ (uint8) ( Y1 >> 8 ) ] ^ \
- FT3[ (uint8) ( Y2 ) ]; \
-}
-
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */
-
- if( ctx->nr > 10 )
- {
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */
- }
-
- if( ctx->nr > 12 )
- {
- AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */
- AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */
- }
-
- /* last round */
-
- RK += 4;
-
- X0 = RK[0] ^ ( FSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y3 ) ] );
-
- X1 = RK[1] ^ ( FSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y0 ) ] );
-
- X2 = RK[2] ^ ( FSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y1 ) ] );
-
- X3 = RK[3] ^ ( FSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^
- ( FSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^
- ( FSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^
- ( FSb[ (uint8) ( Y2 ) ] );
-
- PUT_UINT32( X0, output, 0 );
- PUT_UINT32( X1, output, 4 );
- PUT_UINT32( X2, output, 8 );
- PUT_UINT32( X3, output, 12 );
-}
-
-/* AES 128-bit block decryption routine */
-
-void rtmp_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] )
-{
- uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
-
- RK = ctx->drk;
-
- GET_UINT32( X0, input, 0 ); X0 ^= RK[0];
- GET_UINT32( X1, input, 4 ); X1 ^= RK[1];
- GET_UINT32( X2, input, 8 ); X2 ^= RK[2];
- GET_UINT32( X3, input, 12 ); X3 ^= RK[3];
-
-#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
-{ \
- RK += 4; \
- \
- X0 = RK[0] ^ RT0[ (uint8) ( Y0 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y3 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y2 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y1 ) ]; \
- \
- X1 = RK[1] ^ RT0[ (uint8) ( Y1 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y0 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y3 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y2 ) ]; \
- \
- X2 = RK[2] ^ RT0[ (uint8) ( Y2 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y1 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y0 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y3 ) ]; \
- \
- X3 = RK[3] ^ RT0[ (uint8) ( Y3 >> 24 ) ] ^ \
- RT1[ (uint8) ( Y2 >> 16 ) ] ^ \
- RT2[ (uint8) ( Y1 >> 8 ) ] ^ \
- RT3[ (uint8) ( Y0 ) ]; \
-}
-
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 1 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 2 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 3 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 4 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 5 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 6 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 7 */
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */
-
- if( ctx->nr > 10 )
- {
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */
- }
-
- if( ctx->nr > 12 )
- {
- AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */
- AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */
- }
-
- /* last round */
-
- RK += 4;
-
- X0 = RK[0] ^ ( RSb[ (uint8) ( Y0 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y3 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y2 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y1 ) ] );
-
- X1 = RK[1] ^ ( RSb[ (uint8) ( Y1 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y0 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y3 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y2 ) ] );
-
- X2 = RK[2] ^ ( RSb[ (uint8) ( Y2 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y1 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y0 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y3 ) ] );
-
- X3 = RK[3] ^ ( RSb[ (uint8) ( Y3 >> 24 ) ] << 24 ) ^
- ( RSb[ (uint8) ( Y2 >> 16 ) ] << 16 ) ^
- ( RSb[ (uint8) ( Y1 >> 8 ) ] << 8 ) ^
- ( RSb[ (uint8) ( Y0 ) ] );
-
- PUT_UINT32( X0, output, 0 );
- PUT_UINT32( X1, output, 4 );
- PUT_UINT32( X2, output, 8 );
- PUT_UINT32( X3, output, 12 );
-}
-
-/*
- ========================================================================
-
- Routine Description:
- SHA1 function
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID HMAC_SHA1(
- IN UCHAR *text,
- IN UINT text_len,
- IN UCHAR *key,
- IN UINT key_len,
- IN UCHAR *digest)
-{
- SHA_CTX context;
- UCHAR k_ipad[65]; /* inner padding - key XORd with ipad */
- UCHAR k_opad[65]; /* outer padding - key XORd with opad */
- INT i;
-
- // if key is longer than 64 bytes reset it to key=SHA1(key)
- if (key_len > 64)
- {
- SHA_CTX tctx;
- SHAInit(&tctx);
- SHAUpdate(&tctx, key, key_len);
- SHAFinal(&tctx, key);
- key_len = 20;
- }
- NdisZeroMemory(k_ipad, sizeof(k_ipad));
- NdisZeroMemory(k_opad, sizeof(k_opad));
- NdisMoveMemory(k_ipad, key, key_len);
- NdisMoveMemory(k_opad, key, key_len);
-
- // XOR key with ipad and opad values
- for (i = 0; i < 64; i++)
- {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- // perform inner SHA1
- SHAInit(&context); /* init context for 1st pass */
- SHAUpdate(&context, k_ipad, 64); /* start with inner pad */
- SHAUpdate(&context, text, text_len); /* then text of datagram */
- SHAFinal(&context, digest); /* finish up 1st pass */
-
- //perform outer SHA1
- SHAInit(&context); /* init context for 2nd pass */
- SHAUpdate(&context, k_opad, 64); /* start with outer pad */
- SHAUpdate(&context, digest, 20); /* then results of 1st hash */
- SHAFinal(&context, digest); /* finish up 2nd pass */
-
-}
-
-/*
-* F(P, S, c, i) = U1 xor U2 xor ... Uc
-* U1 = PRF(P, S || Int(i))
-* U2 = PRF(P, U1)
-* Uc = PRF(P, Uc-1)
-*/
-
-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output)
-{
- unsigned char digest[36], digest1[SHA_DIGEST_LEN];
- int i, j;
-
- /* U1 = PRF(P, S || int(i)) */
- memcpy(digest, ssid, ssidlength);
- digest[ssidlength] = (unsigned char)((count>>24) & 0xff);
- digest[ssidlength+1] = (unsigned char)((count>>16) & 0xff);
- digest[ssidlength+2] = (unsigned char)((count>>8) & 0xff);
- digest[ssidlength+3] = (unsigned char)(count & 0xff);
- HMAC_SHA1(digest, ssidlength+4, (unsigned char*) password, (int) strlen(password), digest1); // for WPA update
-
- /* output = U1 */
- memcpy(output, digest1, SHA_DIGEST_LEN);
-
- for (i = 1; i < iterations; i++)
- {
- /* Un = PRF(P, Un-1) */
- HMAC_SHA1(digest1, SHA_DIGEST_LEN, (unsigned char*) password, (int) strlen(password), digest); // for WPA update
- memcpy(digest1, digest, SHA_DIGEST_LEN);
-
- /* output = output xor Un */
- for (j = 0; j < SHA_DIGEST_LEN; j++)
- {
- output[j] ^= digest[j];
- }
- }
-}
-/*
-* password - ascii string up to 63 characters in length
-* ssid - octet string up to 32 octets
-* ssidlength - length of ssid in octets
-* output must be 40 octets in length and outputs 256 bits of key
-*/
-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output)
-{
- if ((strlen(password) > 63) || (ssidlength > 32))
- return 0;
-
- F(password, ssid, ssidlength, 4096, 1, output);
- F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]);
- return 1;
-}
-
-
+#include "../../rt2870/common/md5.c"
diff --git a/drivers/staging/rt3070/common/mlme.c b/drivers/staging/rt3070/common/mlme.c
index 0ffbfa36699e..c2d0d4e10cb7 100644
--- a/drivers/staging/rt3070/common/mlme.c
+++ b/drivers/staging/rt3070/common/mlme.c
@@ -1,9136 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- mlme.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-08-25 Modify from RT2500 code base
- John Chang 2004-09-06 modified for RT2600
-*/
-
-#include "../rt_config.h"
-#include <stdarg.h>
-
-UCHAR CISCO_OUI[] = {0x00, 0x40, 0x96};
-
-UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};
-UCHAR RSN_OUI[] = {0x00, 0x0f, 0xac};
-UCHAR WAPI_OUI[] = {0x00, 0x14, 0x72};
-UCHAR WME_INFO_ELEM[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
-UCHAR WME_PARM_ELEM[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
-UCHAR Ccx2QosInfo[] = {0x00, 0x40, 0x96, 0x04};
-UCHAR RALINK_OUI[] = {0x00, 0x0c, 0x43};
-UCHAR BROADCOM_OUI[] = {0x00, 0x90, 0x4c};
-UCHAR WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04};
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-UCHAR PRE_N_HT_OUI[] = {0x00, 0x90, 0x4c};
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-UCHAR RateSwitchTable[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x11, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
- 0x04, 0x21, 0, 30, 50,
- 0x05, 0x21, 1, 20, 50,
- 0x06, 0x21, 2, 20, 50,
- 0x07, 0x21, 3, 15, 50,
- 0x08, 0x21, 4, 15, 30,
- 0x09, 0x21, 5, 10, 25,
- 0x0a, 0x21, 6, 8, 25,
- 0x0b, 0x21, 7, 8, 25,
- 0x0c, 0x20, 12, 15, 30,
- 0x0d, 0x20, 13, 8, 20,
- 0x0e, 0x20, 14, 8, 20,
- 0x0f, 0x20, 15, 8, 25,
- 0x10, 0x22, 15, 8, 25,
- 0x11, 0x00, 0, 0, 0,
- 0x12, 0x00, 0, 0, 0,
- 0x13, 0x00, 0, 0, 0,
- 0x14, 0x00, 0, 0, 0,
- 0x15, 0x00, 0, 0, 0,
- 0x16, 0x00, 0, 0, 0,
- 0x17, 0x00, 0, 0, 0,
- 0x18, 0x00, 0, 0, 0,
- 0x19, 0x00, 0, 0, 0,
- 0x1a, 0x00, 0, 0, 0,
- 0x1b, 0x00, 0, 0, 0,
- 0x1c, 0x00, 0, 0, 0,
- 0x1d, 0x00, 0, 0, 0,
- 0x1e, 0x00, 0, 0, 0,
- 0x1f, 0x00, 0, 0, 0,
-};
-
-UCHAR RateSwitchTable11B[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x04, 0x03, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
-};
-
-UCHAR RateSwitchTable11BG[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
- 0x04, 0x10, 2, 20, 35,
- 0x05, 0x10, 3, 16, 35,
- 0x06, 0x10, 4, 10, 25,
- 0x07, 0x10, 5, 16, 25,
- 0x08, 0x10, 6, 10, 25,
- 0x09, 0x10, 7, 10, 13,
-};
-
-UCHAR RateSwitchTable11G[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x08, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x10, 0, 20, 101,
- 0x01, 0x10, 1, 20, 35,
- 0x02, 0x10, 2, 20, 35,
- 0x03, 0x10, 3, 16, 35,
- 0x04, 0x10, 4, 10, 25,
- 0x05, 0x10, 5, 16, 25,
- 0x06, 0x10, 6, 10, 25,
- 0x07, 0x10, 7, 10, 13,
-};
-
-#ifdef DOT11_N_SUPPORT
-UCHAR RateSwitchTable11N1S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x09, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 10, 25,
- 0x06, 0x21, 6, 8, 14,
- 0x07, 0x21, 7, 8, 14,
- 0x08, 0x23, 7, 8, 14,
-};
-
-UCHAR RateSwitchTable11N2S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11N3S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11N2SForABand[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0b, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x20, 12, 15, 30,
- 0x07, 0x20, 13, 8, 20,
- 0x08, 0x20, 14, 8, 20,
- 0x09, 0x20, 15, 8, 25,
- 0x0a, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11N3SForABand[] = { // 3*3
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0b, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30, 101,
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x20, 12, 15, 30,
- 0x07, 0x20, 13, 8, 20,
- 0x08, 0x20, 14, 8, 20,
- 0x09, 0x20, 15, 8, 25,
- 0x0a, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11BGN1S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0d, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x00, 0, 40, 101,
- 0x01, 0x00, 1, 40, 50,
- 0x02, 0x00, 2, 35, 45,
- 0x03, 0x00, 3, 20, 45,
- 0x04, 0x21, 0, 30,101, //50
- 0x05, 0x21, 1, 20, 50,
- 0x06, 0x21, 2, 20, 50,
- 0x07, 0x21, 3, 15, 50,
- 0x08, 0x21, 4, 15, 30,
- 0x09, 0x21, 5, 10, 25,
- 0x0a, 0x21, 6, 8, 14,
- 0x0b, 0x21, 7, 8, 14,
- 0x0c, 0x23, 7, 8, 14,
-};
-
-UCHAR RateSwitchTable11BGN2S[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11BGN3S[] = { // 3*3
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0a, 0x00, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 20, 50,
- 0x04, 0x21, 4, 15, 50,
-#if 1
- 0x05, 0x20, 20, 15, 30,
- 0x06, 0x20, 21, 8, 20,
- 0x07, 0x20, 22, 8, 20,
- 0x08, 0x20, 23, 8, 25,
- 0x09, 0x22, 23, 8, 25,
-#else // for RT2860 2*3 test
- 0x05, 0x20, 12, 15, 30,
- 0x06, 0x20, 13, 8, 20,
- 0x07, 0x20, 14, 8, 20,
- 0x08, 0x20, 15, 8, 25,
- 0x09, 0x22, 15, 8, 25,
-#endif
-};
-
-UCHAR RateSwitchTable11BGN2SForABand[] = {
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0b, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x20, 12, 15, 30,
- 0x07, 0x20, 13, 8, 20,
- 0x08, 0x20, 14, 8, 20,
- 0x09, 0x20, 15, 8, 25,
- 0x0a, 0x22, 15, 8, 25,
-};
-
-UCHAR RateSwitchTable11BGN3SForABand[] = { // 3*3
-// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF)
- 0x0c, 0x09, 0, 0, 0, // Initial used item after association
- 0x00, 0x21, 0, 30,101, //50
- 0x01, 0x21, 1, 20, 50,
- 0x02, 0x21, 2, 20, 50,
- 0x03, 0x21, 3, 15, 50,
- 0x04, 0x21, 4, 15, 30,
- 0x05, 0x21, 5, 15, 30,
- 0x06, 0x21, 12, 15, 30,
- 0x07, 0x20, 20, 15, 30,
- 0x08, 0x20, 21, 8, 20,
- 0x09, 0x20, 22, 8, 20,
- 0x0a, 0x20, 23, 8, 25,
- 0x0b, 0x22, 23, 8, 25,
-};
-#endif // DOT11_N_SUPPORT //
-
-PUCHAR ReasonString[] = {
- /* 0 */ "Reserved",
- /* 1 */ "Unspecified Reason",
- /* 2 */ "Previous Auth no longer valid",
- /* 3 */ "STA is leaving / has left",
- /* 4 */ "DIS-ASSOC due to inactivity",
- /* 5 */ "AP unable to hanle all associations",
- /* 6 */ "class 2 error",
- /* 7 */ "class 3 error",
- /* 8 */ "STA is leaving / has left",
- /* 9 */ "require auth before assoc/re-assoc",
- /* 10 */ "Reserved",
- /* 11 */ "Reserved",
- /* 12 */ "Reserved",
- /* 13 */ "invalid IE",
- /* 14 */ "MIC error",
- /* 15 */ "4-way handshake timeout",
- /* 16 */ "2-way (group key) handshake timeout",
- /* 17 */ "4-way handshake IE diff among AssosReq/Rsp/Beacon",
- /* 18 */
-};
-
-extern UCHAR OfdmRateToRxwiMCS[];
-// since RT61 has better RX sensibility, we have to limit TX ACK rate not to exceed our normal data TX rate.
-// otherwise the WLAN peer may not be able to receive the ACK thus downgrade its data TX rate
-ULONG BasicRateMask[12] = {0xfffff001 /* 1-Mbps */, 0xfffff003 /* 2 Mbps */, 0xfffff007 /* 5.5 */, 0xfffff00f /* 11 */,
- 0xfffff01f /* 6 */ , 0xfffff03f /* 9 */ , 0xfffff07f /* 12 */ , 0xfffff0ff /* 18 */,
- 0xfffff1ff /* 24 */ , 0xfffff3ff /* 36 */ , 0xfffff7ff /* 48 */ , 0xffffffff /* 54 */};
-
-UCHAR MULTICAST_ADDR[MAC_ADDR_LEN] = {0x1, 0x00, 0x00, 0x00, 0x00, 0x00};
-UCHAR BROADCAST_ADDR[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than
-// this value, then it's quaranteed capable of operating in 36 mbps TX rate in
-// clean environment.
-// TxRate: 1 2 5.5 11 6 9 12 18 24 36 48 54 72 100
-CHAR RssiSafeLevelForTxRate[] ={ -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 };
-
-UCHAR RateIdToMbps[] = { 1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 72, 100};
-USHORT RateIdTo500Kbps[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144, 200};
-
-UCHAR SsidIe = IE_SSID;
-UCHAR SupRateIe = IE_SUPP_RATES;
-UCHAR ExtRateIe = IE_EXT_SUPP_RATES;
-#ifdef DOT11_N_SUPPORT
-UCHAR HtCapIe = IE_HT_CAP;
-UCHAR AddHtInfoIe = IE_ADD_HT;
-UCHAR NewExtChanIe = IE_SECONDARY_CH_OFFSET;
-#ifdef DOT11N_DRAFT3
-UCHAR ExtHtCapIe = IE_EXT_CAPABILITY;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-UCHAR ErpIe = IE_ERP;
-UCHAR DsIe = IE_DS_PARM;
-UCHAR TimIe = IE_TIM;
-UCHAR WpaIe = IE_WPA;
-UCHAR Wpa2Ie = IE_WPA2;
-UCHAR IbssIe = IE_IBSS_PARM;
-UCHAR Ccx2Ie = IE_CCX_V2;
-UCHAR WapiIe = IE_WAPI;
-
-extern UCHAR WPA_OUI[];
-
-UCHAR SES_OUI[] = {0x00, 0x90, 0x4c};
-
-UCHAR ZeroSsid[32] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-
-// Reset the RFIC setting to new series
-RTMP_RF_REGS RF2850RegTable[] = {
-// ch R1 R2 R3(TX0~4=0) R4
- {1, 0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b},
- {2, 0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f},
- {3, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b},
- {4, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f},
- {5, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b},
- {6, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f},
- {7, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b},
- {8, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f},
- {9, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b},
- {10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f},
- {11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b},
- {12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f},
- {13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b},
- {14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193},
-
- // 802.11 UNI / HyperLan 2
- {36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3},
- {38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193},
- {40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183},
- {44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3},
- {46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b},
- {48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b},
- {52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193},
- {54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3},
- {56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b},
- {60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183},
- {62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193},
- {64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3}, // Plugfest#4, Day4, change RFR3 left4th 9->5.
-
- // 802.11 HyperLan 2
- {100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783},
-
- // 2008.04.30 modified
- // The system team has AN to improve the EVM value
- // for channel 102 to 108 for the RT2850/RT2750 dual band solution.
- {102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793},
- {104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3},
- {108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193},
-
- {110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183},
- {112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b},
- {116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3},
- {118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193},
- {120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183},
- {124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193},
- {126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b}, // 0x980ed1bb->0x980ed15b required by Rory 20070927
- {128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3},
- {132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b},
- {134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193},
- {136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b},
- {140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183},
-
- // 802.11 UNII
- {149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7},
- {151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187},
- {153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f},
- {157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f},
- {159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7},
- {161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187},
- {165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197},
-
- // Japan
- {184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b},
- {188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13},
- {192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b},
- {196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23},
- {208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13},
- {212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b},
- {216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23},
-
- // still lack of MMAC(Japan) ch 34,38,42,46
-};
-UCHAR NUM_OF_2850_CHNL = (sizeof(RF2850RegTable) / sizeof(RTMP_RF_REGS));
-
-FREQUENCY_ITEM FreqItems3020[] =
-{
- /**************************************************/
- // ISM : 2.4 to 2.483 GHz //
- /**************************************************/
- // 11g
- /**************************************************/
- //-CH---N-------R---K-----------
- {1, 241, 2, 2},
- {2, 241, 2, 7},
- {3, 242, 2, 2},
- {4, 242, 2, 7},
- {5, 243, 2, 2},
- {6, 243, 2, 7},
- {7, 244, 2, 2},
- {8, 244, 2, 7},
- {9, 245, 2, 2},
- {10, 245, 2, 7},
- {11, 246, 2, 2},
- {12, 246, 2, 7},
- {13, 247, 2, 2},
- {14, 248, 2, 4},
-};
-//2008/07/10:KH Modified to share this variable
-UCHAR NUM_OF_3020_CHNL=(sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM));
-
-/*
- ==========================================================================
- Description:
- initialize the MLME task and its data structure (queue, spinlock,
- timer, state machines).
-
- IRQL = PASSIVE_LEVEL
-
- Return:
- always return NDIS_STATUS_SUCCESS
-
- ==========================================================================
-*/
-NDIS_STATUS MlmeInit(
- IN PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> MLME Initialize\n"));
-
- do
- {
- Status = MlmeQueueInit(&pAd->Mlme.Queue);
- if(Status != NDIS_STATUS_SUCCESS)
- break;
-
- pAd->Mlme.bRunning = FALSE;
- NdisAllocateSpinLock(&pAd->Mlme.TaskLock);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- BssTableInit(&pAd->ScanTab);
-
- // init STA state machines
- AssocStateMachineInit(pAd, &pAd->Mlme.AssocMachine, pAd->Mlme.AssocFunc);
- AuthStateMachineInit(pAd, &pAd->Mlme.AuthMachine, pAd->Mlme.AuthFunc);
- AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine, pAd->Mlme.AuthRspFunc);
- SyncStateMachineInit(pAd, &pAd->Mlme.SyncMachine, pAd->Mlme.SyncFunc);
- WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc);
- AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);
-
-#ifdef QOS_DLS_SUPPORT
- DlsStateMachineInit(pAd, &pAd->Mlme.DlsMachine, pAd->Mlme.DlsFunc);
-#endif // QOS_DLS_SUPPORT //
-
-
- // Since we are using switch/case to implement it, the init is different from the above
- // state machine init
- MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
-
- ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine, pAd->Mlme.ActFunc);
-
- // Init mlme periodic timer
- RTMPInitTimer(pAd, &pAd->Mlme.PeriodicTimer, GET_TIMER_FUNCTION(MlmePeriodicExec), pAd, TRUE);
-
- // Set mlme periodic timer
- RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
-
- // software-based RX Antenna diversity
- RTMPInitTimer(pAd, &pAd->Mlme.RxAntEvalTimer, GET_TIMER_FUNCTION(AsicRxAntEvalTimeout), pAd, FALSE);
-
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- } while (FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- MLME Initialize\n"));
-
- return Status;
-}
-
-/*
- ==========================================================================
- Description:
- main loop of the MLME
- Pre:
- Mlme has to be initialized, and there are something inside the queue
- Note:
- This function is invoked from MPSetInformation and MPReceive;
- This task guarantee only one MlmeHandler will run.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeHandler(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_QUEUE_ELEM *Elem = NULL;
-
- // Only accept MLME and Frame from peer side, no other (control/data) frame should
- // get into this state machine
-
- NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
- if(pAd->Mlme.bRunning)
- {
- NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
- return;
- }
- else
- {
- pAd->Mlme.bRunning = TRUE;
- }
- NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-
- while (!MlmeQueueEmpty(&pAd->Mlme.Queue))
- {
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Device Halted or Removed or MlmeRest, exit MlmeHandler! (queue num = %ld)\n", pAd->Mlme.Queue.Num));
- break;
- }
-
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now in MlmeHandler\n"));
- break;
- }
-#endif // RALINK_ATE //
-
- //From message type, determine which state machine I should drive
- if (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
- {
-#ifdef RT2870
- if (Elem->MsgType == MT2_RESET_CONF)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! reset MLME state machine !!!\n"));
- MlmeRestartStateMachine(pAd);
- Elem->Occupied = FALSE;
- Elem->MsgLen = 0;
- continue;
- }
-#endif // RT2870 //
-
- // if dequeue success
- switch (Elem->Machine)
- {
- // STA state machines
-#ifdef CONFIG_STA_SUPPORT
- case ASSOC_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem);
- break;
- case AUTH_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AuthMachine, Elem);
- break;
- case AUTH_RSP_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AuthRspMachine, Elem);
- break;
- case SYNC_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.SyncMachine, Elem);
- break;
- case MLME_CNTL_STATE_MACHINE:
- MlmeCntlMachinePerformAction(pAd, &pAd->Mlme.CntlMachine, Elem);
- break;
- case WPA_PSK_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);
- break;
-#ifdef LEAP_SUPPORT
- case LEAP_STATE_MACHINE:
- LeapMachinePerformAction(pAd, &pAd->Mlme.LeapMachine, Elem);
- break;
-#endif
- case AIRONET_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.AironetMachine, Elem);
- break;
-
-#ifdef QOS_DLS_SUPPORT
- case DLS_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.DlsMachine, Elem);
- break;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
- case ACTION_STATE_MACHINE:
- StateMachinePerformAction(pAd, &pAd->Mlme.ActMachine, Elem);
- break;
-
-
-
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("ERROR: Illegal machine %ld in MlmeHandler()\n", Elem->Machine));
- break;
- } // end of switch
-
- // free MLME element
- Elem->Occupied = FALSE;
- Elem->MsgLen = 0;
-
- }
- else {
- DBGPRINT_ERR(("MlmeHandler: MlmeQueue empty\n"));
- }
- }
-
- NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
- pAd->Mlme.bRunning = FALSE;
- NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-}
-
-/*
- ==========================================================================
- Description:
- Destructor of MLME (Destroy queue, state machine, spin lock and timer)
- Parameters:
- Adapter - NIC Adapter pointer
- Post:
- The MLME task will no longer work properly
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID MlmeHalt(
- IN PRTMP_ADAPTER pAd)
-{
- BOOLEAN Cancelled;
-#ifdef RT3070
- UINT32 TxPinCfg = 0x00050F0F;
-#endif // RT3070 //
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeHalt\n"));
-
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- // disable BEACON generation and other BEACON related hardware timers
- AsicDisableSync(pAd);
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef QOS_DLS_SUPPORT
- UCHAR i;
-#endif // QOS_DLS_SUPPORT //
- // Cancel pending timers
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-#ifdef QOS_DLS_SUPPORT
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
- }
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
- RTMPCancelTimer(&pAd->Mlme.RxAntEvalTimer, &Cancelled);
-
-
-
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- // Set LED
- RTMPSetLED(pAd, LED_HALT);
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
-#ifdef RT2870
- {
- LED_CFG_STRUC LedCfg;
- RTMP_IO_READ32(pAd, LED_CFG, &LedCfg.word);
- LedCfg.field.LedPolar = 0;
- LedCfg.field.RLedMode = 0;
- LedCfg.field.GLedMode = 0;
- LedCfg.field.YLedMode = 0;
- RTMP_IO_WRITE32(pAd, LED_CFG, LedCfg.word);
- }
-#endif // RT2870 //
-#ifdef RT3070
- //
- // Turn off LNA_PE
- //
- if (IS_RT3070(pAd) || IS_RT3071(pAd))
- {
- TxPinCfg &= 0xFFFFF0F0;
- RTUSBWriteMACRegister(pAd, TX_PIN_CFG, TxPinCfg);
- }
-#endif // RT3070 //
- }
-
- RTMPusecDelay(5000); // 5 msec to gurantee Ant Diversity timer canceled
-
- MlmeQueueDestroy(&pAd->Mlme.Queue);
- NdisFreeSpinLock(&pAd->Mlme.TaskLock);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeHalt\n"));
-}
-
-VOID MlmeResetRalinkCounters(
- IN PRTMP_ADAPTER pAd)
-{
- pAd->RalinkCounters.LastOneSecRxOkDataCnt = pAd->RalinkCounters.OneSecRxOkDataCnt;
- // clear all OneSecxxx counters.
- pAd->RalinkCounters.OneSecBeaconSentCnt = 0;
- pAd->RalinkCounters.OneSecFalseCCACnt = 0;
- pAd->RalinkCounters.OneSecRxFcsErrCnt = 0;
- pAd->RalinkCounters.OneSecRxOkCnt = 0;
- pAd->RalinkCounters.OneSecTxFailCount = 0;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount = 0;
- pAd->RalinkCounters.OneSecTxRetryOkCount = 0;
- pAd->RalinkCounters.OneSecRxOkDataCnt = 0;
-
- // TODO: for debug only. to be removed
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] = 0;
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] = 0;
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] = 0;
- pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BE] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BK] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VI] = 0;
- pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VO] = 0;
- pAd->RalinkCounters.OneSecTxDoneCount = 0;
- pAd->RalinkCounters.OneSecRxCount = 0;
- pAd->RalinkCounters.OneSecTxAggregationCount = 0;
- pAd->RalinkCounters.OneSecRxAggregationCount = 0;
-
- return;
-}
-
-unsigned long rx_AMSDU;
-unsigned long rx_Total;
-
-/*
- ==========================================================================
- Description:
- This routine is executed periodically to -
- 1. Decide if it's a right time to turn on PwrMgmt bit of all
- outgoiing frames
- 2. Calculate ChannelQuality based on statistics of the last
- period, so that TX rate won't toggling very frequently between a
- successful TX and a failed TX.
- 3. If the calculated ChannelQuality indicated current connection not
- healthy, then a ROAMing attempt is tried here.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-#define ADHOC_BEACON_LOST_TIME (8*OS_HZ) // 8 sec
-VOID MlmePeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- ULONG TxTotalCnt;
- PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RADIO_MEASUREMENT |
- fRTMP_ADAPTER_RESET_IN_PROGRESS))))
- return;
-
- RT28XX_MLME_PRE_SANITY_CHECK(pAd);
-
-#ifdef RALINK_ATE
- /* Do not show RSSI until "Normal 1 second Mlme PeriodicExec". */
- if (ATE_ON(pAd))
- {
- if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE != (MLME_TASK_EXEC_MULTIPLE - 1))
- {
- pAd->Mlme.PeriodicRound ++;
- return;
- }
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
-
- if (pAd->Mlme.PeriodicRound & 0x1)
- {
- // This is the fix for wifi 11n extension channel overlapping test case. for 2860D
- if (((pAd->MACVersion & 0xffff) == 0x0101) &&
- (STA_TGN_WIFI_ON(pAd)) &&
- (pAd->CommonCfg.IOTestParm.bToggle == FALSE))
-
- {
- RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x24Bf);
- pAd->CommonCfg.IOTestParm.bToggle = TRUE;
- }
- else if ((STA_TGN_WIFI_ON(pAd)) &&
- ((pAd->MACVersion & 0xffff) == 0x0101))
- {
- RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x243f);
- pAd->CommonCfg.IOTestParm.bToggle = FALSE;
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pAd->bUpdateBcnCntDone = FALSE;
-
-// RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3);
- pAd->Mlme.PeriodicRound ++;
-
-#ifdef RT2870
- // execute every 100ms, update the Tx FIFO Cnt for update Tx Rate.
- NICUpdateFifoStaCounters(pAd);
-#endif // RT2870 //
- // execute every 500ms
- if ((pAd->Mlme.PeriodicRound % 5 == 0) && RTMPAutoRateSwitchCheck(pAd)/*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))*/)
- {
-#ifdef CONFIG_STA_SUPPORT
- // perform dynamic tx rate switching based on past TX history
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)))
- MlmeDynamicTxRateSwitching(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // Normal 1 second Mlme PeriodicExec.
- if (pAd->Mlme.PeriodicRound %MLME_TASK_EXEC_MULTIPLE == 0)
- {
- pAd->Mlme.OneSecPeriodicRound ++;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- /* request from Baron : move this routine from later to here */
- /* for showing Rx error count in ATE RXFRAME */
- NICUpdateRawCounters(pAd);
- if (pAd->ate.bRxFer == 1)
- {
- pAd->ate.RxTotalCnt += pAd->ate.RxCntPerSec;
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx packet cnt = %d/%d\n", pAd->ate.RxCntPerSec, pAd->ate.RxTotalCnt);
- pAd->ate.RxCntPerSec = 0;
-
- if (pAd->ate.RxAntennaSel == 0)
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx AvgRssi0=%d, AvgRssi1=%d, AvgRssi2=%d\n\n",
- pAd->ate.AvgRssi0, pAd->ate.AvgRssi1, pAd->ate.AvgRssi2);
- else
- ate_print(KERN_EMERG "MlmePeriodicExec: Rx AvgRssi=%d\n\n", pAd->ate.AvgRssi0);
- }
- MlmeResetRalinkCounters(pAd);
- return;
- }
-#endif // RALINK_ATE //
-
-
- if (rx_Total)
- {
-
- // reset counters
- rx_AMSDU = 0;
- rx_Total = 0;
- }
-
- //ORIBATimerTimeout(pAd);
-
- // Media status changed, report to NDIS
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE))
- {
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
-
- }
- else
- {
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- }
- }
-
- NdisGetSystemUpTime(&pAd->Mlme.Now32);
-
- // add the most up-to-date h/w raw counters into software variable, so that
- // the dynamic tuning mechanism below are based on most up-to-date information
- NICUpdateRawCounters(pAd);
-
-#ifdef RT2870
- RT2870_WatchDog(pAd);
-#endif // RT2870 //
-
-#ifdef DOT11_N_SUPPORT
- // Need statistics after read counter. So put after NICUpdateRawCounters
- ORIBATimerTimeout(pAd);
-#endif // DOT11_N_SUPPORT //
-
- // The time period for checking antenna is according to traffic
- {
- if (pAd->Mlme.bEnableAutoAntennaCheck)
- {
- TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- // dynamic adjust antenna evaluation period according to the traffic
- if (TxTotalCnt > 50)
- {
- if (pAd->Mlme.OneSecPeriodicRound % 10 == 0)
- {
- AsicEvaluateRxAnt(pAd);
- }
- }
- else
- {
- if (pAd->Mlme.OneSecPeriodicRound % 3 == 0)
- {
- AsicEvaluateRxAnt(pAd);
- }
- }
- }
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- STAMlmePeriodicExec(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- MlmeResetRalinkCounters(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- {
- // When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock
- // and sending CTS-to-self over and over.
- // Software Patch Solution:
- // 1. Polling debug state register 0x10F4 every one second.
- // 2. If in 0x10F4 the ((bit29==1) && (bit7==1)) OR ((bit29==1) && (bit5==1)), it means the deadlock has occurred.
- // 3. If the deadlock occurred, reset MAC/BBP by setting 0x1004 to 0x0001 for a while then setting it back to 0x000C again.
-
- UINT32 MacReg = 0;
-
- RTMP_IO_READ32(pAd, 0x10F4, &MacReg);
- if (((MacReg & 0x20000000) && (MacReg & 0x80)) || ((MacReg & 0x20000000) && (MacReg & 0x20)))
- {
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
- RTMPusecDelay(1);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xC);
-
- DBGPRINT(RT_DEBUG_WARN,("Warning, MAC specific condition occurs \n"));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RT28XX_MLME_HANDLER(pAd);
- }
-
-
- pAd->bUpdateBcnCntDone = FALSE;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-VOID STAMlmePeriodicExec(
- PRTMP_ADAPTER pAd)
-{
- ULONG TxTotalCnt;
- int i;
-
-//
-// We return here in ATE mode, because the statistics
-// that ATE needs are not collected via this routine.
-//
-#ifdef RALINK_ATE
- // It is supposed that we will never reach here in ATE mode.
- ASSERT(!(ATE_ON(pAd)));
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // WPA MIC error should block association attempt for 60 seconds
- if (pAd->StaCfg.bBlockAssoc && (pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ) < pAd->Mlme.Now32))
- pAd->StaCfg.bBlockAssoc = FALSE;
- }
-
- if ((pAd->PreMediaState != pAd->IndicateMediaState) && (pAd->CommonCfg.bWirelessEvent))
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- pAd->PreMediaState = pAd->IndicateMediaState;
- }
-
-
-
-
- AsicStaBbpTuning(pAd);
-
- TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- // update channel quality for Roaming and UI LinkQuality display
- MlmeCalculateChannelQuality(pAd, pAd->Mlme.Now32);
- }
-
- // must be AFTER MlmeDynamicTxRateSwitching() because it needs to know if
- // Radio is currently in noisy environment
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- AsicAdjustTxPower(pAd);
-
- if (INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- // Check DLS time out, then tear down those session
- RTMPCheckDLSTimeOut(pAd);
-#endif // QOS_DLS_SUPPORT //
-
- // Is PSM bit consistent with user power management policy?
- // This is the only place that will set PSM bit ON.
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- MlmeCheckPsmChange(pAd, pAd->Mlme.Now32);
-
- pAd->RalinkCounters.LastOneSecTotalTxCount = TxTotalCnt;
-
- if ((pAd->StaCfg.LastBeaconRxTime + 1*OS_HZ < pAd->Mlme.Now32) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
- ((TxTotalCnt + pAd->RalinkCounters.OneSecRxOkCnt < 600)))
- {
- RTMPSetAGCInitValue(pAd, BW_20);
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - No BEACON. restore R66 to the low bound(%d) \n", (0x2E + GET_LNA_GAIN(pAd))));
- }
-
- //if ((pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
- // (pAd->RalinkCounters.OneSecTxRetryOkCount == 0))
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable)
- {
- // When APSD is enabled, the period changes as 20 sec
- if ((pAd->Mlme.OneSecPeriodicRound % 20) == 8)
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- }
- else
- {
- // Send out a NULL frame every 10 sec to inform AP that STA is still alive (Avoid being age out)
- if ((pAd->Mlme.OneSecPeriodicRound % 10) == 8)
- {
- if (pAd->CommonCfg.bWmmCapable)
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- else
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE);
- }
- }
- }
-
- if (CQI_IS_DEAD(pAd->Mlme.ChannelQuality))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - No BEACON. Dead CQI. Auto Recovery attempt #%ld\n", pAd->RalinkCounters.BadCQIAutoRecoveryCount));
- pAd->StaCfg.CCXAdjacentAPReportFlag = TRUE;
- pAd->StaCfg.CCXAdjacentAPLinkDownTime = pAd->StaCfg.LastBeaconRxTime;
-
- // Lost AP, send disconnect & link down event
- LinkDown(pAd, FALSE);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- // RTMPPatchMacBbpBug(pAd);
- MlmeAutoReconnectLastSSID(pAd);
- }
- else if (CQI_IS_BAD(pAd->Mlme.ChannelQuality))
- {
- pAd->RalinkCounters.BadCQIAutoRecoveryCount ++;
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Bad CQI. Auto Recovery attempt #%ld\n", pAd->RalinkCounters.BadCQIAutoRecoveryCount));
- MlmeAutoReconnectLastSSID(pAd);
- }
-
- // Add auto seamless roaming
- if (pAd->StaCfg.bFastRoaming)
- {
- SHORT dBmToRoam = (SHORT)pAd->StaCfg.dBmToRoam;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Rssi=%d, dBmToRoam=%d\n", RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2), (CHAR)dBmToRoam));
-
- if (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) <= (CHAR)dBmToRoam)
- {
- MlmeCheckForFastRoaming(pAd, pAd->Mlme.Now32);
- }
- }
- }
- else if (ADHOC_ON(pAd))
- {
- //radar detect
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- RadarDetectPeriodic(pAd);
- }
-
- // If all peers leave, and this STA becomes the last one in this IBSS, then change MediaState
- // to DISCONNECTED. But still holding this IBSS (i.e. sending BEACON) so that other STAs can
- // join later.
- if ((pAd->StaCfg.LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < pAd->Mlme.Now32) &&
- OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- MLME_START_REQ_STRUCT StartReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n"));
- LinkDown(pAd, FALSE);
-
- StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
-
- for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i];
-
- if (pEntry->ValidAsCLI == FALSE)
- continue;
-
- if (pEntry->LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < pAd->Mlme.Now32)
- MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
- }
- }
- else // no INFRA nor ADHOC connection
- {
-
- if (pAd->StaCfg.bScanReqIsFromWebUI &&
- ((pAd->StaCfg.LastScanTime + 30 * OS_HZ) > pAd->Mlme.Now32))
- goto SKIP_AUTO_SCAN_CONN;
- else
- pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
-
- if ((pAd->StaCfg.bAutoReconnect == TRUE)
- && RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)
- && (MlmeValidateSSID(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen) == TRUE))
- {
- if ((pAd->ScanTab.BssNr==0) && (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
- {
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- if ((pAd->StaCfg.LastScanTime + 10 * OS_HZ) < pAd->Mlme.Now32)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("STAMlmePeriodicExec():CNTL - ScanTab.BssNr==0, start a new ACTIVE scan SSID[%s]\n", pAd->MlmeAux.AutoReconnectSsid));
- ScanParmFill(pAd, &ScanReq, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- // Reset Missed scan number
- pAd->StaCfg.LastScanTime = pAd->Mlme.Now32;
- }
- else if (pAd->StaCfg.BssType == BSS_ADHOC) // Quit the forever scan when in a very clean room
- MlmeAutoReconnectLastSSID(pAd);
- }
- else if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- if ((pAd->Mlme.OneSecPeriodicRound % 7) == 0)
- {
- MlmeAutoScan(pAd);
- pAd->StaCfg.LastScanTime = pAd->Mlme.Now32;
- }
- else
- {
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- if ((pAd->Mlme.OneSecPeriodicRound % 5) == 1)
- MlmeAutoReconnectLastSSID(pAd);
- }
- else
-#endif // CARRIER_DETECTION_SUPPORT //
- MlmeAutoReconnectLastSSID(pAd);
- }
- }
- }
- }
-
-SKIP_AUTO_SCAN_CONN:
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap !=0) && (pAd->MacTab.fAnyBASession == FALSE))
- {
- pAd->MacTab.fAnyBASession = TRUE;
- AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, FALSE, FALSE);
- }
- else if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap ==0) && (pAd->MacTab.fAnyBASession == TRUE))
- {
- pAd->MacTab.fAnyBASession = FALSE;
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040))
- TriEventCounterMaintenance(pAd);
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
- return;
-}
-
-// Link down report
-VOID LinkDownExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
-
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeAutoScan(
- IN PRTMP_ADAPTER pAd)
-{
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Driver auto scan\n"));
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeAutoReconnectLastSSID(
- IN PRTMP_ADAPTER pAd)
-{
-
-
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) &&
- (MlmeValidateSSID(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen) == TRUE))
- {
- NDIS_802_11_SSID OidSsid;
- OidSsid.SsidLength = pAd->MlmeAux.AutoReconnectSsidLen;
- NdisMoveMemory(OidSsid.Ssid, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Driver auto reconnect to last OID_802_11_SSID setting - %s, len - %d\n", pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen));
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_SSID,
- sizeof(NDIS_802_11_SSID),
- &OidSsid);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ==========================================================================
- Validate SSID for connection try and rescan purpose
- Valid SSID will have visible chars only.
- The valid length is from 0 to 32.
- IRQL = DISPATCH_LEVEL
- ==========================================================================
- */
-BOOLEAN MlmeValidateSSID(
- IN PUCHAR pSsid,
- IN UCHAR SsidLen)
-{
- int index;
-
- if (SsidLen > MAX_LEN_OF_SSID)
- return (FALSE);
-
- // Check each character value
- for (index = 0; index < SsidLen; index++)
- {
- if (pSsid[index] < 0x20)
- return (FALSE);
- }
-
- // All checked
- return (TRUE);
-}
-
-VOID MlmeSelectTxRateTable(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR *ppTable,
- IN PUCHAR pTableSize,
- IN PUCHAR pInitTxRateIdx)
-{
- do
- {
- // decide the rate table for tuning
- if (pAd->CommonCfg.TxRateTableSize > 0)
- {
- *ppTable = RateSwitchTable;
- *pTableSize = RateSwitchTable[0];
- *pInitTxRateIdx = RateSwitchTable[1];
-
- break;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- if ((pAd->OpMode == OPMODE_STA) && ADHOC_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
- (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
- {// 11N 1S Adhoc
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
-
- }
- else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
- (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- (pEntry->HTCapability.MCSSet[1] == 0xff) &&
- (pAd->Antenna.field.TxPath == 2))
- {// 11N 2S Adhoc
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11N2S;
- *pTableSize = RateSwitchTable11N2S[0];
- *pInitTxRateIdx = RateSwitchTable11N2S[1];
- }
- else
- {
- *ppTable = RateSwitchTable11N2SForABand;
- *pTableSize = RateSwitchTable11N2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
- }
-
- }
- else
-#endif // DOT11_N_SUPPORT //
- if ((pEntry->RateLen == 4)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {
- *ppTable = RateSwitchTable11B;
- *pTableSize = RateSwitchTable11B[0];
- *pInitTxRateIdx = RateSwitchTable11B[1];
-
- }
- else if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11BG;
- *pTableSize = RateSwitchTable11BG[0];
- *pInitTxRateIdx = RateSwitchTable11BG[1];
-
- }
- else
- {
- *ppTable = RateSwitchTable11G;
- *pTableSize = RateSwitchTable11G[0];
- *pInitTxRateIdx = RateSwitchTable11G[1];
-
- }
- break;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- //if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 12) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
- // ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
- if ((pEntry->RateLen == 12) && (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1)))
- {// 11BGN 1S AP
- *ppTable = RateSwitchTable11BGN1S;
- *pTableSize = RateSwitchTable11BGN1S[0];
- *pInitTxRateIdx = RateSwitchTable11BGN1S[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 12) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
- // (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2))
- if ((pEntry->RateLen == 12) && (pEntry->HTCapability.MCSSet[0] == 0xff) &&
- (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->CommonCfg.TxStream == 2))
- {// 11BGN 2S AP
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11BGN2S;
- *pTableSize = RateSwitchTable11BGN2S[0];
- *pInitTxRateIdx = RateSwitchTable11BGN2S[1];
-
- }
- else
- {
- *ppTable = RateSwitchTable11BGN2SForABand;
- *pTableSize = RateSwitchTable11BGN2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11BGN2SForABand[1];
-
- }
- break;
- }
-
- //else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
- if ((pEntry->HTCapability.MCSSet[0] == 0xff) && ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1)))
- {// 11N 1S AP
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2))
- if ((pEntry->HTCapability.MCSSet[0] == 0xff) && (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->CommonCfg.TxStream == 2))
- {// 11N 2S AP
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- *ppTable = RateSwitchTable11N2S;
- *pTableSize = RateSwitchTable11N2S[0];
- *pInitTxRateIdx = RateSwitchTable11N2S[1];
- }
- else
- {
- *ppTable = RateSwitchTable11N2SForABand;
- *pTableSize = RateSwitchTable11N2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
- }
-
- break;
- }
-#endif // DOT11_N_SUPPORT //
- //else if ((pAd->StaActive.SupRateLen == 4) && (pAd->StaActive.ExtRateLen == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->RateLen == 4)
-#ifdef DOT11_N_SUPPORT
-//Iverson mark for Adhoc b mode,sta will use rate 54 Mbps when connect with sta b/g/n mode
-// && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {// B only AP
- *ppTable = RateSwitchTable11B;
- *pTableSize = RateSwitchTable11B[0];
- *pInitTxRateIdx = RateSwitchTable11B[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen > 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->RateLen > 8)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {// B/G mixed AP
- *ppTable = RateSwitchTable11BG;
- *pTableSize = RateSwitchTable11BG[0];
- *pInitTxRateIdx = RateSwitchTable11BG[1];
-
- break;
- }
-
- //else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->RateLen == 8)
-#ifdef DOT11_N_SUPPORT
- && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
-#endif // DOT11_N_SUPPORT //
- )
- {// G only AP
- *ppTable = RateSwitchTable11G;
- *pTableSize = RateSwitchTable11G[0];
- *pInitTxRateIdx = RateSwitchTable11G[1];
-
- break;
- }
-#ifdef DOT11_N_SUPPORT
-#endif // DOT11_N_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef DOT11_N_SUPPORT
- //else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
- if ((pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0))
-#endif // DOT11_N_SUPPORT //
- { // Legacy mode
- if (pAd->CommonCfg.MaxTxRate <= RATE_11)
- {
- *ppTable = RateSwitchTable11B;
- *pTableSize = RateSwitchTable11B[0];
- *pInitTxRateIdx = RateSwitchTable11B[1];
- }
- else if ((pAd->CommonCfg.MaxTxRate > RATE_11) && (pAd->CommonCfg.MinTxRate > RATE_11))
- {
- *ppTable = RateSwitchTable11G;
- *pTableSize = RateSwitchTable11G[0];
- *pInitTxRateIdx = RateSwitchTable11G[1];
-
- }
- else
- {
- *ppTable = RateSwitchTable11BG;
- *pTableSize = RateSwitchTable11BG[0];
- *pInitTxRateIdx = RateSwitchTable11BG[1];
- }
- break;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- if (pAd->CommonCfg.TxStream == 1)
- {
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 1S AP \n"));
- }
- else
- {
- *ppTable = RateSwitchTable11N2S;
- *pTableSize = RateSwitchTable11N2S[0];
- *pInitTxRateIdx = RateSwitchTable11N2S[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
- }
- }
- else
- {
- if (pAd->CommonCfg.TxStream == 1)
- {
- *ppTable = RateSwitchTable11N1S;
- *pTableSize = RateSwitchTable11N1S[0];
- *pInitTxRateIdx = RateSwitchTable11N1S[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 1S AP \n"));
- }
- else
- {
- *ppTable = RateSwitchTable11N2SForABand;
- *pTableSize = RateSwitchTable11N2SForABand[0];
- *pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
- }
- }
-#endif // DOT11_N_SUPPORT //
- DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode (SupRateLen=%d, ExtRateLen=%d, MCSSet[0]=0x%x, MCSSet[1]=0x%x)\n",
- pAd->StaActive.SupRateLen, pAd->StaActive.ExtRateLen, pAd->StaActive.SupportedPhyInfo.MCSSet[0], pAd->StaActive.SupportedPhyInfo.MCSSet[1]));
- }
-#endif // CONFIG_STA_SUPPORT //
- } while(FALSE);
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ==========================================================================
- Description:
- This routine checks if there're other APs out there capable for
- roaming. Caller should call this routine only when Link up in INFRA mode
- and channel quality is below CQI_GOOD_THRESHOLD.
-
- IRQL = DISPATCH_LEVEL
-
- Output:
- ==========================================================================
- */
-VOID MlmeCheckForRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32)
-{
- USHORT i;
- BSS_TABLE *pRoamTab = &pAd->MlmeAux.RoamTab;
- BSS_ENTRY *pBss;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeCheckForRoaming\n"));
- // put all roaming candidates into RoamTab, and sort in RSSI order
- BssTableInit(pRoamTab);
- for (i = 0; i < pAd->ScanTab.BssNr; i++)
- {
- pBss = &pAd->ScanTab.BssEntry[i];
-
- if ((pBss->LastBeaconRxTime + BEACON_LOST_TIME) < Now32)
- continue; // AP disappear
- if (pBss->Rssi <= RSSI_THRESHOLD_FOR_ROAMING)
- continue; // RSSI too weak. forget it.
- if (MAC_ADDR_EQUAL(pBss->Bssid, pAd->CommonCfg.Bssid))
- continue; // skip current AP
- if (pBss->Rssi < (pAd->StaCfg.RssiSample.LastRssi0 + RSSI_DELTA))
- continue; // only AP with stronger RSSI is eligible for roaming
-
- // AP passing all above rules is put into roaming candidate table
- NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
- pRoamTab->BssNr += 1;
- }
-
- if (pRoamTab->BssNr > 0)
- {
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- pAd->RalinkCounters.PoorCQIRoamingCount ++;
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming attempt #%ld\n", pAd->RalinkCounters.PoorCQIRoamingCount));
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_MLME_ROAMING_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForRoaming(# of candidate= %d)\n",pRoamTab->BssNr));
-}
-
-/*
- ==========================================================================
- Description:
- This routine checks if there're other APs out there capable for
- roaming. Caller should call this routine only when link up in INFRA mode
- and channel quality is below CQI_GOOD_THRESHOLD.
-
- IRQL = DISPATCH_LEVEL
-
- Output:
- ==========================================================================
- */
-VOID MlmeCheckForFastRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now)
-{
- USHORT i;
- BSS_TABLE *pRoamTab = &pAd->MlmeAux.RoamTab;
- BSS_ENTRY *pBss;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeCheckForFastRoaming\n"));
- // put all roaming candidates into RoamTab, and sort in RSSI order
- BssTableInit(pRoamTab);
- for (i = 0; i < pAd->ScanTab.BssNr; i++)
- {
- pBss = &pAd->ScanTab.BssEntry[i];
-
- if ((pBss->Rssi <= -50) && (pBss->Channel == pAd->CommonCfg.Channel))
- continue; // RSSI too weak. forget it.
- if (MAC_ADDR_EQUAL(pBss->Bssid, pAd->CommonCfg.Bssid))
- continue; // skip current AP
- if (!SSID_EQUAL(pBss->Ssid, pBss->SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
- continue; // skip different SSID
- if (pBss->Rssi < (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) + RSSI_DELTA))
- continue; // skip AP without better RSSI
-
- DBGPRINT(RT_DEBUG_TRACE, ("LastRssi0 = %d, pBss->Rssi = %d\n", RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2), pBss->Rssi));
- // AP passing all above rules is put into roaming candidate table
- NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
- pRoamTab->BssNr += 1;
- }
-
- if (pRoamTab->BssNr > 0)
- {
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
- {
- pAd->RalinkCounters.PoorCQIRoamingCount ++;
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming attempt #%ld\n", pAd->RalinkCounters.PoorCQIRoamingCount));
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_MLME_ROAMING_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
- }
- // Maybe site survey required
- else
- {
- if ((pAd->StaCfg.LastScanTime + 10 * 1000) < Now)
- {
- // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
- DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming, No eligable entry, try new scan!\n"));
- pAd->StaCfg.ScanCnt = 2;
- pAd->StaCfg.LastScanTime = Now;
- MlmeAutoScan(pAd);
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForFastRoaming (BssNr=%d)\n", pRoamTab->BssNr));
-}
-
-/*
- ==========================================================================
- Description:
- This routine calculates TxPER, RxPER of the past N-sec period. And
- according to the calculation result, ChannelQuality is calculated here
- to decide if current AP is still doing the job.
-
- If ChannelQuality is not good, a ROAMing attempt may be tried later.
- Output:
- StaCfg.ChannelQuality - 0..100
-
- IRQL = DISPATCH_LEVEL
-
- NOTE: This routine decide channle quality based on RX CRC error ratio.
- Caller should make sure a function call to NICUpdateRawCounters(pAd)
- is performed right before this routine, so that this routine can decide
- channel quality based on the most up-to-date information
- ==========================================================================
- */
-VOID MlmeCalculateChannelQuality(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32)
-{
- ULONG TxOkCnt, TxCnt, TxPER, TxPRR;
- ULONG RxCnt, RxPER;
- UCHAR NorRssi;
- CHAR MaxRssi;
- ULONG BeaconLostTime = BEACON_LOST_TIME;
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // longer beacon lost time when carrier detection enabled
- if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
- {
- BeaconLostTime = BEACON_LOST_TIME + BEACON_LOST_TIME/2;
- }
-#endif // CARRIER_DETECTION_SUPPORT //
-
- MaxRssi = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
-
- //
- // calculate TX packet error ratio and TX retry ratio - if too few TX samples, skip TX related statistics
- //
- TxOkCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + pAd->RalinkCounters.OneSecTxRetryOkCount;
- TxCnt = TxOkCnt + pAd->RalinkCounters.OneSecTxFailCount;
- if (TxCnt < 5)
- {
- TxPER = 0;
- TxPRR = 0;
- }
- else
- {
- TxPER = (pAd->RalinkCounters.OneSecTxFailCount * 100) / TxCnt;
- TxPRR = ((TxCnt - pAd->RalinkCounters.OneSecTxNoRetryOkCount) * 100) / TxCnt;
- }
-
- //
- // calculate RX PER - don't take RxPER into consideration if too few sample
- //
- RxCnt = pAd->RalinkCounters.OneSecRxOkCnt + pAd->RalinkCounters.OneSecRxFcsErrCnt;
- if (RxCnt < 5)
- RxPER = 0;
- else
- RxPER = (pAd->RalinkCounters.OneSecRxFcsErrCnt * 100) / RxCnt;
-
- //
- // decide ChannelQuality based on: 1)last BEACON received time, 2)last RSSI, 3)TxPER, and 4)RxPER
- //
- if (INFRA_ON(pAd) &&
- (pAd->RalinkCounters.OneSecTxNoRetryOkCount < 2) && // no heavy traffic
- (pAd->StaCfg.LastBeaconRxTime + BeaconLostTime < Now32))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("BEACON lost > %ld msec with TxOkCnt=%ld -> CQI=0\n", BeaconLostTime, TxOkCnt));
- pAd->Mlme.ChannelQuality = 0;
- }
- else
- {
- // Normalize Rssi
- if (MaxRssi > -40)
- NorRssi = 100;
- else if (MaxRssi < -90)
- NorRssi = 0;
- else
- NorRssi = (MaxRssi + 90) * 2;
-
- // ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER (RSSI 0..100), (TxPER 100..0), (RxPER 100..0)
- pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * NorRssi +
- TX_WEIGHTING * (100 - TxPRR) +
- RX_WEIGHTING* (100 - RxPER)) / 100;
- if (pAd->Mlme.ChannelQuality >= 100)
- pAd->Mlme.ChannelQuality = 100;
- }
-
-}
-
-VOID MlmeSetTxRate(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PRTMP_TX_RATE_SWITCH pTxRate)
-{
- UCHAR MaxMode = MODE_OFDM;
-
-#ifdef DOT11_N_SUPPORT
- MaxMode = MODE_HTGREENFIELD;
-
- if (pTxRate->STBC && (pAd->StaCfg.MaxHTPhyMode.field.STBC) && (pAd->Antenna.field.TxPath == 2))
- pAd->StaCfg.HTPhyMode.field.STBC = STBC_USE;
- else
-#endif // DOT11_N_SUPPORT //
- pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
-
- if (pTxRate->CurrMCS < MCS_AUTO)
- pAd->StaCfg.HTPhyMode.field.MCS = pTxRate->CurrMCS;
-
- if (pAd->StaCfg.HTPhyMode.field.MCS > 7)
- pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
-
- if (ADHOC_ON(pAd))
- {
- // If peer adhoc is b-only mode, we can't send 11g rate.
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
- pEntry->HTPhyMode.field.STBC = STBC_NONE;
-
- //
- // For Adhoc MODE_CCK, driver will use AdhocBOnlyJoined flag to roll back to B only if necessary
- //
- pEntry->HTPhyMode.field.MODE = pTxRate->Mode;
- pEntry->HTPhyMode.field.ShortGI = pAd->StaCfg.HTPhyMode.field.ShortGI;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
-
- // Patch speed error in status page
- pAd->StaCfg.HTPhyMode.field.MODE = pEntry->HTPhyMode.field.MODE;
- }
- else
- {
- if (pTxRate->Mode <= MaxMode)
- pAd->StaCfg.HTPhyMode.field.MODE = pTxRate->Mode;
-
-#ifdef DOT11_N_SUPPORT
- if (pTxRate->ShortGI && (pAd->StaCfg.MaxHTPhyMode.field.ShortGI))
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_400;
- else
-#endif // DOT11_N_SUPPORT //
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-
-#ifdef DOT11_N_SUPPORT
- // Reexam each bandwidth's SGI support.
- if (pAd->StaCfg.HTPhyMode.field.ShortGI == GI_400)
- {
- if ((pEntry->HTPhyMode.field.BW == BW_20) && (!CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE)))
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
- if ((pEntry->HTPhyMode.field.BW == BW_40) && (!CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE)))
- pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
- }
-
- // Turn RTS/CTS rate to 6Mbps.
- if ((pEntry->HTPhyMode.field.MCS == 0) && (pAd->StaCfg.HTPhyMode.field.MCS != 0))
- {
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- if (pAd->MacTab.fAnyBASession)
- {
- AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- else
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- }
- else if ((pEntry->HTPhyMode.field.MCS == 8) && (pAd->StaCfg.HTPhyMode.field.MCS != 8))
- {
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- if (pAd->MacTab.fAnyBASession)
- {
- AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- else
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
- }
- else if ((pEntry->HTPhyMode.field.MCS != 0) && (pAd->StaCfg.HTPhyMode.field.MCS == 0))
- {
- AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
-
- }
- else if ((pEntry->HTPhyMode.field.MCS != 8) && (pAd->StaCfg.HTPhyMode.field.MCS == 8))
- {
- AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT, TRUE, (BOOLEAN)pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent);
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.field.STBC = pAd->StaCfg.HTPhyMode.field.STBC;
- pEntry->HTPhyMode.field.ShortGI = pAd->StaCfg.HTPhyMode.field.ShortGI;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
-#ifdef DOT11_N_SUPPORT
- if ((pAd->StaCfg.MaxHTPhyMode.field.MODE == MODE_HTGREENFIELD) &&
- pAd->WIFItestbed.bGreenField)
- pEntry->HTPhyMode.field.MODE = MODE_HTGREENFIELD;
-#endif // DOT11_N_SUPPORT //
- }
-
- pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
-}
-
-/*
- ==========================================================================
- Description:
- This routine calculates the acumulated TxPER of eaxh TxRate. And
- according to the calculation result, change CommonCfg.TxRate which
- is the stable TX Rate we expect the Radio situation could sustained.
-
- CommonCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate}
- Output:
- CommonCfg.TxRate -
-
- IRQL = DISPATCH_LEVEL
-
- NOTE:
- call this routine every second
- ==========================================================================
- */
-VOID MlmeDynamicTxRateSwitching(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx;
- ULONG i, AccuTxTotalCnt = 0, TxTotalCnt;
- ULONG TxErrorRatio = 0;
- BOOLEAN bTxRateChanged, bUpgradeQuality = FALSE;
- PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate = NULL;
- PUCHAR pTable;
- UCHAR TableSize = 0;
- UCHAR InitTxRateIdx = 0, TrainUp, TrainDown;
- CHAR Rssi, RssiOffset = 0;
- TX_STA_CNT1_STRUC StaTx1;
- TX_STA_CNT0_STRUC TxStaCnt0;
- ULONG TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
- MAC_TABLE_ENTRY *pEntry;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- //
- // walk through MAC table, see if need to change AP's TX rate toward each entry
- //
- for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- pEntry = &pAd->MacTab.Content[i];
-
- // check if this entry need to switch rate automatically
- if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
- continue;
-
- if ((pAd->MacTab.Size == 1) || (pEntry->ValidAsDls))
- {
- Rssi = RTMPMaxRssi(pAd,
- pAd->StaCfg.RssiSample.AvgRssi0,
- pAd->StaCfg.RssiSample.AvgRssi1,
- pAd->StaCfg.RssiSample.AvgRssi2);
-
- // Update statistic counter
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
- pAd->bUpdateBcnCntDone = TRUE;
- TxRetransmit = StaTx1.field.TxRetransmit;
- TxSuccess = StaTx1.field.TxSuccess;
- TxFailCount = TxStaCnt0.field.TxFailCount;
- TxTotalCnt = TxRetransmit + TxSuccess + TxFailCount;
-
- pAd->RalinkCounters.OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
- pAd->RalinkCounters.OneSecTxFailCount += TxStaCnt0.field.TxFailCount;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
- pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
- pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
-
- // if no traffic in the past 1-sec period, don't change TX rate,
- // but clear all bad history. because the bad history may affect the next
- // Chariot throughput test
- AccuTxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((TxRetransmit + TxFailCount) * 100) / TxTotalCnt;
- }
- else
- {
- if (INFRA_ON(pAd) && (i == 1))
- Rssi = RTMPMaxRssi(pAd,
- pAd->StaCfg.RssiSample.AvgRssi0,
- pAd->StaCfg.RssiSample.AvgRssi1,
- pAd->StaCfg.RssiSample.AvgRssi2);
- else
- Rssi = RTMPMaxRssi(pAd,
- pEntry->RssiSample.AvgRssi0,
- pEntry->RssiSample.AvgRssi1,
- pEntry->RssiSample.AvgRssi2);
-
- TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
- pEntry->OneSecTxRetryOkCount +
- pEntry->OneSecTxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((pEntry->OneSecTxRetryOkCount + pEntry->OneSecTxFailCount) * 100) / TxTotalCnt;
- }
-
- CurrRateIdx = pEntry->CurrTxRateIndex;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &InitTxRateIdx);
-
- if (CurrRateIdx >= TableSize)
- {
- CurrRateIdx = TableSize - 1;
- }
-
- // When switch from Fixed rate -> auto rate, the REAL TX rate might be different from pAd->CommonCfg.TxRateIndex.
- // So need to sync here.
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
- if ((pEntry->HTPhyMode.field.MCS != pCurrTxRate->CurrMCS)
- //&& (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- )
- {
-
- // Need to sync Real Tx rate and our record.
- // Then return for next DRS.
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(InitTxRateIdx+1)*5];
- pEntry->CurrTxRateIndex = InitTxRateIdx;
- MlmeSetTxRate(pAd, pEntry, pCurrTxRate);
-
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
- continue;
- }
-
- // decide the next upgrade rate and downgrade rate, if any
- if ((CurrRateIdx > 0) && (CurrRateIdx < (TableSize - 1)))
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx -1;
- }
- else if (CurrRateIdx == 0)
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx;
- }
- else if (CurrRateIdx == (TableSize - 1))
- {
- UpRateIdx = CurrRateIdx;
- DownRateIdx = CurrRateIdx - 1;
- }
-
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-
-#ifdef DOT11_N_SUPPORT
- if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX))
- {
- TrainUp = (pCurrTxRate->TrainUp + (pCurrTxRate->TrainUp >> 1));
- TrainDown = (pCurrTxRate->TrainDown + (pCurrTxRate->TrainDown >> 1));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- TrainUp = pCurrTxRate->TrainUp;
- TrainDown = pCurrTxRate->TrainDown;
- }
-
- //pAd->DrsCounters.LastTimeTxRateChangeAction = pAd->DrsCounters.LastSecTxRateChangeAction;
-
- //
- // Keep the last time TxRateChangeAction status.
- //
- pEntry->LastTimeTxRateChangeAction = pEntry->LastSecTxRateChangeAction;
-
-
-
- //
- // CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI
- // (criteria copied from RT2500 for Netopia case)
- //
- if (TxTotalCnt <= 15)
- {
- CHAR idx = 0;
- UCHAR TxRateIdx;
- //UCHAR MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0, MCS7 = 0, MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
- UCHAR MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0, MCS5 =0, MCS6 = 0, MCS7 = 0;
- UCHAR MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
- UCHAR MCS20 = 0, MCS21 = 0, MCS22 = 0, MCS23 = 0; // 3*3
-
- // check the existence and index of each needed MCS
- while (idx < pTable[0])
- {
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(idx+1)*5];
-
- if (pCurrTxRate->CurrMCS == MCS_0)
- {
- MCS0 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_1)
- {
- MCS1 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_2)
- {
- MCS2 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_3)
- {
- MCS3 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_4)
- {
- MCS4 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_5)
- {
- MCS5 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_6)
- {
- MCS6 = idx;
- }
- //else if (pCurrTxRate->CurrMCS == MCS_7)
- else if ((pCurrTxRate->CurrMCS == MCS_7) && (pCurrTxRate->ShortGI == GI_800)) // prevent the highest MCS using short GI when 1T and low throughput
- {
- MCS7 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_12)
- {
- MCS12 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_13)
- {
- MCS13 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_14)
- {
- MCS14 = idx;
- }
- else if ((pCurrTxRate->CurrMCS == MCS_15) && (pCurrTxRate->ShortGI == GI_800))
- {
- MCS15 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_20) // 3*3
- {
- MCS20 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_21)
- {
- MCS21 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_22)
- {
- MCS22 = idx;
- }
- else if (pCurrTxRate->CurrMCS == MCS_23)
- {
- MCS23 = idx;
- }
- idx ++;
- }
-
- if (pAd->LatchRfRegs.Channel <= 14)
- {
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- RssiOffset = 2;
- }
- else
- {
- RssiOffset = 5;
- }
- }
- else
- {
- if (pAd->NicConfig2.field.ExternalLNAForA)
- {
- RssiOffset = 5;
- }
- else
- {
- RssiOffset = 8;
- }
- }
-#ifdef DOT11_N_SUPPORT
- /*if (MCS15)*/
- if ((pTable == RateSwitchTable11BGN3S) ||
- (pTable == RateSwitchTable11N3S) ||
- (pTable == RateSwitchTable))
- {// N mode with 3 stream // 3*3
- if (MCS23 && (Rssi >= -70))
- TxRateIdx = MCS15;
- else if (MCS22 && (Rssi >= -72))
- TxRateIdx = MCS14;
- else if (MCS21 && (Rssi >= -76))
- TxRateIdx = MCS13;
- else if (MCS20 && (Rssi >= -78))
- TxRateIdx = MCS12;
- else if (MCS4 && (Rssi >= -82))
- TxRateIdx = MCS4;
- else if (MCS3 && (Rssi >= -84))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi >= -86))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi >= -88))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
-// else if ((pTable == RateSwitchTable11BGN2S) || (pTable == RateSwitchTable11BGN2SForABand) ||(pTable == RateSwitchTable11N2S) ||(pTable == RateSwitchTable11N2SForABand) || (pTable == RateSwitchTable))
- else if ((pTable == RateSwitchTable11BGN2S) || (pTable == RateSwitchTable11BGN2SForABand) ||(pTable == RateSwitchTable11N2S) ||(pTable == RateSwitchTable11N2SForABand)) // 3*3
- {// N mode with 2 stream
- if (MCS15 && (Rssi >= (-70+RssiOffset)))
- TxRateIdx = MCS15;
- else if (MCS14 && (Rssi >= (-72+RssiOffset)))
- TxRateIdx = MCS14;
- else if (MCS13 && (Rssi >= (-76+RssiOffset)))
- TxRateIdx = MCS13;
- else if (MCS12 && (Rssi >= (-78+RssiOffset)))
- TxRateIdx = MCS12;
- else if (MCS4 && (Rssi >= (-82+RssiOffset)))
- TxRateIdx = MCS4;
- else if (MCS3 && (Rssi >= (-84+RssiOffset)))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi >= (-86+RssiOffset)))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi >= (-88+RssiOffset)))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
- else if ((pTable == RateSwitchTable11BGN1S) || (pTable == RateSwitchTable11N1S))
- {// N mode with 1 stream
- if (MCS7 && (Rssi > (-72+RssiOffset)))
- TxRateIdx = MCS7;
- else if (MCS6 && (Rssi > (-74+RssiOffset)))
- TxRateIdx = MCS6;
- else if (MCS5 && (Rssi > (-77+RssiOffset)))
- TxRateIdx = MCS5;
- else if (MCS4 && (Rssi > (-79+RssiOffset)))
- TxRateIdx = MCS4;
- else if (MCS3 && (Rssi > (-81+RssiOffset)))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi > (-83+RssiOffset)))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi > (-86+RssiOffset)))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
- else
-#endif // DOT11_N_SUPPORT //
- {// Legacy mode
- if (MCS7 && (Rssi > -70))
- TxRateIdx = MCS7;
- else if (MCS6 && (Rssi > -74))
- TxRateIdx = MCS6;
- else if (MCS5 && (Rssi > -78))
- TxRateIdx = MCS5;
- else if (MCS4 && (Rssi > -82))
- TxRateIdx = MCS4;
- else if (MCS4 == 0) // for B-only mode
- TxRateIdx = MCS3;
- else if (MCS3 && (Rssi > -85))
- TxRateIdx = MCS3;
- else if (MCS2 && (Rssi > -87))
- TxRateIdx = MCS2;
- else if (MCS1 && (Rssi > -90))
- TxRateIdx = MCS1;
- else
- TxRateIdx = MCS0;
- }
-
- // if (TxRateIdx != pAd->CommonCfg.TxRateIndex)
- {
- pEntry->CurrTxRateIndex = TxRateIdx;
- pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(pEntry->CurrTxRateIndex+1)*5];
- MlmeSetTxRate(pAd, pEntry, pNextTxRate);
- }
-
- NdisZeroMemory(pEntry->TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pEntry->PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
- pEntry->fLastSecAccordingRSSI = TRUE;
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
-
- continue;
- }
-
- if (pEntry->fLastSecAccordingRSSI == TRUE)
- {
- pEntry->fLastSecAccordingRSSI = FALSE;
- pEntry->LastSecTxRateChangeAction = 0;
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
-
- continue;
- }
-
- do
- {
- BOOLEAN bTrainUpDown = FALSE;
-
- pEntry->CurrTxRateStableTime ++;
-
- // downgrade TX quality if PER >= Rate-Down threshold
- if (TxErrorRatio >= TrainDown)
- {
- bTrainUpDown = TRUE;
- pEntry->TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
- }
- // upgrade TX quality if PER <= Rate-Up threshold
- else if (TxErrorRatio <= TrainUp)
- {
- bTrainUpDown = TRUE;
- bUpgradeQuality = TRUE;
- if (pEntry->TxQuality[CurrRateIdx])
- pEntry->TxQuality[CurrRateIdx] --; // quality very good in CurrRate
-
- if (pEntry->TxRateUpPenalty)
- pEntry->TxRateUpPenalty --;
- else if (pEntry->TxQuality[UpRateIdx])
- pEntry->TxQuality[UpRateIdx] --; // may improve next UP rate's quality
- }
-
- pEntry->PER[CurrRateIdx] = (UCHAR)TxErrorRatio;
-
- if (bTrainUpDown)
- {
- // perform DRS - consider TxRate Down first, then rate up.
- if ((CurrRateIdx != DownRateIdx) && (pEntry->TxQuality[CurrRateIdx] >= DRS_TX_QUALITY_WORST_BOUND))
- {
- pEntry->CurrTxRateIndex = DownRateIdx;
- }
- else if ((CurrRateIdx != UpRateIdx) && (pEntry->TxQuality[UpRateIdx] <= 0))
- {
- pEntry->CurrTxRateIndex = UpRateIdx;
- }
- }
- } while (FALSE);
-
- // if rate-up happen, clear all bad history of all TX rates
- if (pEntry->CurrTxRateIndex > CurrRateIdx)
- {
- pEntry->CurrTxRateStableTime = 0;
- pEntry->TxRateUpPenalty = 0;
- pEntry->LastSecTxRateChangeAction = 1; // rate UP
- NdisZeroMemory(pEntry->TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pEntry->PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
-
- //
- // For TxRate fast train up
- //
- if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning)
- {
- RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
-
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = TRUE;
- }
- bTxRateChanged = TRUE;
- }
- // if rate-down happen, only clear DownRate's bad history
- else if (pEntry->CurrTxRateIndex < CurrRateIdx)
- {
- pEntry->CurrTxRateStableTime = 0;
- pEntry->TxRateUpPenalty = 0; // no penalty
- pEntry->LastSecTxRateChangeAction = 2; // rate DOWN
- pEntry->TxQuality[pEntry->CurrTxRateIndex] = 0;
- pEntry->PER[pEntry->CurrTxRateIndex] = 0;
-
- //
- // For TxRate fast train down
- //
- if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning)
- {
- RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
-
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = TRUE;
- }
- bTxRateChanged = TRUE;
- }
- else
- {
- pEntry->LastSecTxRateChangeAction = 0; // rate no change
- bTxRateChanged = FALSE;
- }
-
- pEntry->LastTxOkCount = TxSuccess;
-
- // reset all OneSecTx counters
- RESET_ONE_SEC_TX_CNT(pEntry);
-
- pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(pEntry->CurrTxRateIndex+1)*5];
- if (bTxRateChanged && pNextTxRate)
- {
- MlmeSetTxRate(pAd, pEntry, pNextTxRate);
- }
- }
-}
-
-/*
- ========================================================================
- Routine Description:
- Station side, Auto TxRate faster train up timer call back function.
-
- Arguments:
- SystemSpecific1 - Not used.
- FunctionContext - Pointer to our Adapter context.
- SystemSpecific2 - Not used.
- SystemSpecific3 - Not used.
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID StaQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)FunctionContext;
- UCHAR UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx = 0;
- ULONG TxTotalCnt;
- ULONG TxErrorRatio = 0;
- BOOLEAN bTxRateChanged; //, bUpgradeQuality = FALSE;
- PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate = NULL;
- PUCHAR pTable;
- UCHAR TableSize = 0;
- UCHAR InitTxRateIdx = 0, TrainUp, TrainDown;
- TX_STA_CNT1_STRUC StaTx1;
- TX_STA_CNT0_STRUC TxStaCnt0;
- CHAR Rssi, ratio;
- ULONG TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
- MAC_TABLE_ENTRY *pEntry;
- ULONG i;
-
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
-
- //
- // walk through MAC table, see if need to change AP's TX rate toward each entry
- //
- for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
- {
- pEntry = &pAd->MacTab.Content[i];
-
- // check if this entry need to switch rate automatically
- if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
- continue;
-
- if (INFRA_ON(pAd) && (i == 1))
- Rssi = RTMPMaxRssi(pAd,
- pAd->StaCfg.RssiSample.AvgRssi0,
- pAd->StaCfg.RssiSample.AvgRssi1,
- pAd->StaCfg.RssiSample.AvgRssi2);
- else
- Rssi = RTMPMaxRssi(pAd,
- pEntry->RssiSample.AvgRssi0,
- pEntry->RssiSample.AvgRssi1,
- pEntry->RssiSample.AvgRssi2);
-
- CurrRateIdx = pAd->CommonCfg.TxRateIndex;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &InitTxRateIdx);
-
- // decide the next upgrade rate and downgrade rate, if any
- if ((CurrRateIdx > 0) && (CurrRateIdx < (TableSize - 1)))
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx -1;
- }
- else if (CurrRateIdx == 0)
- {
- UpRateIdx = CurrRateIdx + 1;
- DownRateIdx = CurrRateIdx;
- }
- else if (CurrRateIdx == (TableSize - 1))
- {
- UpRateIdx = CurrRateIdx;
- DownRateIdx = CurrRateIdx - 1;
- }
-
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-
-#ifdef DOT11_N_SUPPORT
- if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX))
- {
- TrainUp = (pCurrTxRate->TrainUp + (pCurrTxRate->TrainUp >> 1));
- TrainDown = (pCurrTxRate->TrainDown + (pCurrTxRate->TrainDown >> 1));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- TrainUp = pCurrTxRate->TrainUp;
- TrainDown = pCurrTxRate->TrainDown;
- }
-
- if (pAd->MacTab.Size == 1)
- {
- // Update statistic counter
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
-
- TxRetransmit = StaTx1.field.TxRetransmit;
- TxSuccess = StaTx1.field.TxSuccess;
- TxFailCount = TxStaCnt0.field.TxFailCount;
- TxTotalCnt = TxRetransmit + TxSuccess + TxFailCount;
-
- pAd->RalinkCounters.OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
- pAd->RalinkCounters.OneSecTxFailCount += TxStaCnt0.field.TxFailCount;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
- pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
- pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((TxRetransmit + TxFailCount) * 100) / TxTotalCnt;
- }
- else
- {
- TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
- pEntry->OneSecTxRetryOkCount +
- pEntry->OneSecTxFailCount;
-
- if (TxTotalCnt)
- TxErrorRatio = ((pEntry->OneSecTxRetryOkCount + pEntry->OneSecTxFailCount) * 100) / TxTotalCnt;
- }
-
-
- //
- // CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI
- // (criteria copied from RT2500 for Netopia case)
- //
- if (TxTotalCnt <= 12)
- {
- NdisZeroMemory(pAd->DrsCounters.TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pAd->DrsCounters.PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
-
- if ((pAd->DrsCounters.LastSecTxRateChangeAction == 1) && (CurrRateIdx != DownRateIdx))
- {
- pAd->CommonCfg.TxRateIndex = DownRateIdx;
- pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
- }
- else if ((pAd->DrsCounters.LastSecTxRateChangeAction == 2) && (CurrRateIdx != UpRateIdx))
- {
- pAd->CommonCfg.TxRateIndex = UpRateIdx;
- }
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("QuickDRS: TxTotalCnt <= 15, train back to original rate \n"));
- return;
- }
-
- do
- {
- ULONG OneSecTxNoRetryOKRationCount;
-
- if (pAd->DrsCounters.LastTimeTxRateChangeAction == 0)
- ratio = 5;
- else
- ratio = 4;
-
- // downgrade TX quality if PER >= Rate-Down threshold
- if (TxErrorRatio >= TrainDown)
- {
- pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
- }
-
- pAd->DrsCounters.PER[CurrRateIdx] = (UCHAR)TxErrorRatio;
-
- OneSecTxNoRetryOKRationCount = (TxSuccess * ratio);
-
- // perform DRS - consider TxRate Down first, then rate up.
- if ((pAd->DrsCounters.LastSecTxRateChangeAction == 1) && (CurrRateIdx != DownRateIdx))
- {
- if ((pAd->DrsCounters.LastTxOkCount + 2) >= OneSecTxNoRetryOKRationCount)
- {
- pAd->CommonCfg.TxRateIndex = DownRateIdx;
- pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
-
- }
-
- }
- else if ((pAd->DrsCounters.LastSecTxRateChangeAction == 2) && (CurrRateIdx != UpRateIdx))
- {
- if ((TxErrorRatio >= 50) || (TxErrorRatio >= TrainDown))
- {
-
- }
- else if ((pAd->DrsCounters.LastTxOkCount + 2) >= OneSecTxNoRetryOKRationCount)
- {
- pAd->CommonCfg.TxRateIndex = UpRateIdx;
- }
- }
- }while (FALSE);
-
- // if rate-up happen, clear all bad history of all TX rates
- if (pAd->CommonCfg.TxRateIndex > CurrRateIdx)
- {
- pAd->DrsCounters.TxRateUpPenalty = 0;
- NdisZeroMemory(pAd->DrsCounters.TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH);
- NdisZeroMemory(pAd->DrsCounters.PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH);
- bTxRateChanged = TRUE;
- }
- // if rate-down happen, only clear DownRate's bad history
- else if (pAd->CommonCfg.TxRateIndex < CurrRateIdx)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE,("QuickDRS: --TX rate from %d to %d \n", CurrRateIdx, pAd->CommonCfg.TxRateIndex));
-
- pAd->DrsCounters.TxRateUpPenalty = 0; // no penalty
- pAd->DrsCounters.TxQuality[pAd->CommonCfg.TxRateIndex] = 0;
- pAd->DrsCounters.PER[pAd->CommonCfg.TxRateIndex] = 0;
- bTxRateChanged = TRUE;
- }
- else
- {
- bTxRateChanged = FALSE;
- }
-
- pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(pAd->CommonCfg.TxRateIndex+1)*5];
- if (bTxRateChanged && pNextTxRate)
- {
- MlmeSetTxRate(pAd, pEntry, pNextTxRate);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- This routine is executed periodically inside MlmePeriodicExec() after
- association with an AP.
- It checks if StaCfg.Psm is consistent with user policy (recorded in
- StaCfg.WindowsPowerMode). If not, enforce user policy. However,
- there're some conditions to consider:
- 1. we don't support power-saving in ADHOC mode, so Psm=PWR_ACTIVE all
- the time when Mibss==TRUE
- 2. When link up in INFRA mode, Psm should not be switch to PWR_SAVE
- if outgoing traffic available in TxRing or MgmtRing.
- Output:
- 1. change pAd->StaCfg.Psm to PWR_SAVE or leave it untouched
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeCheckPsmChange(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32)
-{
- ULONG PowerMode;
-
- // condition -
- // 1. Psm maybe ON only happen in INFRASTRUCTURE mode
- // 2. user wants either MAX_PSP or FAST_PSP
- // 3. but current psm is not in PWR_SAVE
- // 4. CNTL state machine is not doing SCANning
- // 5. no TX SUCCESS event for the past 1-sec period
-#ifdef NDIS51_MINIPORT
- if (pAd->StaCfg.WindowsPowerProfile == NdisPowerProfileBattery)
- PowerMode = pAd->StaCfg.WindowsBatteryPowerMode;
- else
-#endif
- PowerMode = pAd->StaCfg.WindowsPowerMode;
-
- if (INFRA_ON(pAd) &&
- (PowerMode != Ndis802_11PowerModeCAM) &&
- (pAd->StaCfg.Psm == PWR_ACTIVE) &&
-// (! RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) /*&&
- (pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
- (pAd->RalinkCounters.OneSecTxRetryOkCount == 0)*/)
- {
- // add by johnli, use Rx OK data count per second to calculate throughput
- // If Ttraffic is too high ( > 400 Rx per second), don't go to sleep mode. If tx rate is low, use low criteria
- // Mode=CCK/MCS=3 => 11 Mbps, Mode=OFDM/MCS=3 => 18 Mbps
- if (((pAd->StaCfg.HTPhyMode.field.MCS <= 3) &&
-/* Iverson mark
- (pAd->StaCfg.HTPhyMode.field.MODE <= MODE_OFDM) &&
-*/
- (pAd->RalinkCounters.OneSecRxOkDataCnt < (ULONG)100)) ||
- ((pAd->StaCfg.HTPhyMode.field.MCS > 3) &&
-/* Iverson mark
- (pAd->StaCfg.HTPhyMode.field.MODE > MODE_OFDM) &&
-*/
- (pAd->RalinkCounters.OneSecRxOkDataCnt < (ULONG)400)))
- {
- // Get this time
- NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
- pAd->RalinkCounters.RxCountSinceLastNULL = 0;
- MlmeSetPsmBit(pAd, PWR_SAVE);
- if (!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable))
- {
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE);
- }
- else
- {
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- }
- }
- }
-}
-
-// IRQL = PASSIVE_LEVEL
-// IRQL = DISPATCH_LEVEL
-VOID MlmeSetPsmBit(
- IN PRTMP_ADAPTER pAd,
- IN USHORT psm)
-{
- AUTO_RSP_CFG_STRUC csr4;
-
- pAd->StaCfg.Psm = psm;
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
- csr4.field.AckCtsPsmBit = (psm == PWR_SAVE)? 1:0;
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeSetTxPreamble(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TxPreamble)
-{
- AUTO_RSP_CFG_STRUC csr4;
-
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- //TxPreamble = Rt802_11PreambleLong;
-
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
- if (TxPreamble == Rt802_11PreambleLong)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetTxPreamble (= LONG PREAMBLE)\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- csr4.field.AutoResponderPreamble = 0;
- }
- else
- {
- // NOTE: 1Mbps should always use long preamble
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetTxPreamble (= SHORT PREAMBLE)\n"));
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- csr4.field.AutoResponderPreamble = 1;
- }
-
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
-}
-
-/*
- ==========================================================================
- Description:
- Update basic rate bitmap
- ==========================================================================
- */
-
-VOID UpdateBasicRateBitmap(
- IN PRTMP_ADAPTER pAdapter)
-{
- INT i, j;
- /* 1 2 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 */
- UCHAR rate[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
- UCHAR *sup_p = pAdapter->CommonCfg.SupRate;
- UCHAR *ext_p = pAdapter->CommonCfg.ExtRate;
- ULONG bitmap = pAdapter->CommonCfg.BasicRateBitmap;
-
-
- /* if A mode, always use fix BasicRateBitMap */
- //if (pAdapter->CommonCfg.Channel == PHY_11A)
- if (pAdapter->CommonCfg.Channel > 14)
- pAdapter->CommonCfg.BasicRateBitmap = 0x150; /* 6, 12, 24M */
- /* End of if */
-
- if (pAdapter->CommonCfg.BasicRateBitmap > 4095)
- {
- /* (2 ^ MAX_LEN_OF_SUPPORTED_RATES) -1 */
- return;
- } /* End of if */
-
- for(i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- sup_p[i] &= 0x7f;
- ext_p[i] &= 0x7f;
- } /* End of for */
-
- for(i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- if (bitmap & (1 << i))
- {
- for(j=0; j<MAX_LEN_OF_SUPPORTED_RATES; j++)
- {
- if (sup_p[j] == rate[i])
- sup_p[j] |= 0x80;
- /* End of if */
- } /* End of for */
-
- for(j=0; j<MAX_LEN_OF_SUPPORTED_RATES; j++)
- {
- if (ext_p[j] == rate[i])
- ext_p[j] |= 0x80;
- /* End of if */
- } /* End of for */
- } /* End of if */
- } /* End of for */
-} /* End of UpdateBasicRateBitmap */
-
-// IRQL = PASSIVE_LEVEL
-// IRQL = DISPATCH_LEVEL
-// bLinkUp is to identify the inital link speed.
-// TRUE indicates the rate update at linkup, we should not try to set the rate at 54Mbps.
-VOID MlmeUpdateTxRates(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bLinkUp,
- IN UCHAR apidx)
-{
- int i, num;
- UCHAR Rate = RATE_6, MaxDesire = RATE_1, MaxSupport = RATE_1;
- UCHAR MinSupport = RATE_54;
- ULONG BasicRateBitmap = 0;
- UCHAR CurrBasicRate = RATE_1;
- UCHAR *pSupRate, SupRateLen, *pExtRate, ExtRateLen;
- PHTTRANSMIT_SETTING pHtPhy = NULL;
- PHTTRANSMIT_SETTING pMaxHtPhy = NULL;
- PHTTRANSMIT_SETTING pMinHtPhy = NULL;
- BOOLEAN *auto_rate_cur_p;
- UCHAR HtMcs = MCS_AUTO;
-
- // find max desired rate
- UpdateBasicRateBitmap(pAd);
-
- num = 0;
- auto_rate_cur_p = NULL;
- for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- switch (pAd->CommonCfg.DesireRate[i] & 0x7f)
- {
- case 2: Rate = RATE_1; num++; break;
- case 4: Rate = RATE_2; num++; break;
- case 11: Rate = RATE_5_5; num++; break;
- case 22: Rate = RATE_11; num++; break;
- case 12: Rate = RATE_6; num++; break;
- case 18: Rate = RATE_9; num++; break;
- case 24: Rate = RATE_12; num++; break;
- case 36: Rate = RATE_18; num++; break;
- case 48: Rate = RATE_24; num++; break;
- case 72: Rate = RATE_36; num++; break;
- case 96: Rate = RATE_48; num++; break;
- case 108: Rate = RATE_54; num++; break;
- //default: Rate = RATE_1; break;
- }
- if (MaxDesire < Rate) MaxDesire = Rate;
- }
-
-//===========================================================================
-//===========================================================================
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pHtPhy = &pAd->StaCfg.HTPhyMode;
- pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
- pMinHtPhy = &pAd->StaCfg.MinHTPhyMode;
-
- auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
- HtMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
-
- if ((pAd->StaCfg.BssType == BSS_ADHOC) &&
- (pAd->CommonCfg.PhyMode == PHY_11B) &&
- (MaxDesire > RATE_11))
- {
- MaxDesire = RATE_11;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- pAd->CommonCfg.MaxDesiredRate = MaxDesire;
- pMinHtPhy->word = 0;
- pMaxHtPhy->word = 0;
- pHtPhy->word = 0;
-
- // Auto rate switching is enabled only if more than one DESIRED RATES are
- // specified; otherwise disabled
- if (num <= 1)
- {
- //OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = FALSE;
- *auto_rate_cur_p = FALSE;
- }
- else
- {
- //OPSTATUS_SET_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = TRUE;
- *auto_rate_cur_p = TRUE;
- }
-
-#if 1
- if (HtMcs != MCS_AUTO)
- {
- //OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = FALSE;
- *auto_rate_cur_p = FALSE;
- }
- else
- {
- //OPSTATUS_SET_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED);
- //pAd->CommonCfg.bAutoTxRateSwitch = TRUE;
- *auto_rate_cur_p = TRUE;
- }
-#endif
-
-#ifdef CONFIG_STA_SUPPORT
- if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
- {
- pSupRate = &pAd->StaActive.SupRate[0];
- pExtRate = &pAd->StaActive.ExtRate[0];
- SupRateLen = pAd->StaActive.SupRateLen;
- ExtRateLen = pAd->StaActive.ExtRateLen;
- }
- else
-#endif // CONFIG_STA_SUPPORT //
- {
- pSupRate = &pAd->CommonCfg.SupRate[0];
- pExtRate = &pAd->CommonCfg.ExtRate[0];
- SupRateLen = pAd->CommonCfg.SupRateLen;
- ExtRateLen = pAd->CommonCfg.ExtRateLen;
- }
-
- // find max supported rate
- for (i=0; i<SupRateLen; i++)
- {
- switch (pSupRate[i] & 0x7f)
- {
- case 2: Rate = RATE_1; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0001; break;
- case 4: Rate = RATE_2; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0002; break;
- case 11: Rate = RATE_5_5; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0004; break;
- case 22: Rate = RATE_11; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0008; break;
- case 12: Rate = RATE_6; /*if (pSupRate[i] & 0x80)*/ BasicRateBitmap |= 0x0010; break;
- case 18: Rate = RATE_9; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0020; break;
- case 24: Rate = RATE_12; /*if (pSupRate[i] & 0x80)*/ BasicRateBitmap |= 0x0040; break;
- case 36: Rate = RATE_18; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0080; break;
- case 48: Rate = RATE_24; /*if (pSupRate[i] & 0x80)*/ BasicRateBitmap |= 0x0100; break;
- case 72: Rate = RATE_36; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0200; break;
- case 96: Rate = RATE_48; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0400; break;
- case 108: Rate = RATE_54; if (pSupRate[i] & 0x80) BasicRateBitmap |= 0x0800; break;
- default: Rate = RATE_1; break;
- }
- if (MaxSupport < Rate) MaxSupport = Rate;
-
- if (MinSupport > Rate) MinSupport = Rate;
- }
-
- for (i=0; i<ExtRateLen; i++)
- {
- switch (pExtRate[i] & 0x7f)
- {
- case 2: Rate = RATE_1; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0001; break;
- case 4: Rate = RATE_2; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0002; break;
- case 11: Rate = RATE_5_5; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0004; break;
- case 22: Rate = RATE_11; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0008; break;
- case 12: Rate = RATE_6; /*if (pExtRate[i] & 0x80)*/ BasicRateBitmap |= 0x0010; break;
- case 18: Rate = RATE_9; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0020; break;
- case 24: Rate = RATE_12; /*if (pExtRate[i] & 0x80)*/ BasicRateBitmap |= 0x0040; break;
- case 36: Rate = RATE_18; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0080; break;
- case 48: Rate = RATE_24; /*if (pExtRate[i] & 0x80)*/ BasicRateBitmap |= 0x0100; break;
- case 72: Rate = RATE_36; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0200; break;
- case 96: Rate = RATE_48; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0400; break;
- case 108: Rate = RATE_54; if (pExtRate[i] & 0x80) BasicRateBitmap |= 0x0800; break;
- default: Rate = RATE_1; break;
- }
- if (MaxSupport < Rate) MaxSupport = Rate;
-
- if (MinSupport > Rate) MinSupport = Rate;
- }
-
- RTMP_IO_WRITE32(pAd, LEGACY_BASIC_RATE, BasicRateBitmap);
-
- // calculate the exptected ACK rate for each TX rate. This info is used to caculate
- // the DURATION field of outgoing uniicast DATA/MGMT frame
- for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
- {
- if (BasicRateBitmap & (0x01 << i))
- CurrBasicRate = (UCHAR)i;
- pAd->CommonCfg.ExpectedACKRate[i] = CurrBasicRate;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateTxRates[MaxSupport = %d] = MaxDesire %d Mbps\n", RateIdToMbps[MaxSupport], RateIdToMbps[MaxDesire]));
- // max tx rate = min {max desire rate, max supported rate}
- if (MaxSupport < MaxDesire)
- pAd->CommonCfg.MaxTxRate = MaxSupport;
- else
- pAd->CommonCfg.MaxTxRate = MaxDesire;
-
- pAd->CommonCfg.MinTxRate = MinSupport;
- // 2003-07-31 john - 2500 doesn't have good sensitivity at high OFDM rates. to increase the success
- // ratio of initial DHCP packet exchange, TX rate starts from a lower rate depending
- // on average RSSI
- // 1. RSSI >= -70db, start at 54 Mbps (short distance)
- // 2. -70 > RSSI >= -75, start at 24 Mbps (mid distance)
- // 3. -75 > RSSI, start at 11 Mbps (long distance)
- //if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)/* &&
- // OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)*/)
- if (*auto_rate_cur_p)
- {
- short dbm = 0;
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- dbm = pAd->StaCfg.RssiSample.AvgRssi0 - pAd->BbpRssiToDbmDelta;
-#endif // CONFIG_STA_SUPPORT //
- if (bLinkUp == TRUE)
- pAd->CommonCfg.TxRate = RATE_24;
- else
- pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-
- if (dbm < -75)
- pAd->CommonCfg.TxRate = RATE_11;
- else if (dbm < -70)
- pAd->CommonCfg.TxRate = RATE_24;
-
- // should never exceed MaxTxRate (consider 11B-only mode)
- if (pAd->CommonCfg.TxRate > pAd->CommonCfg.MaxTxRate)
- pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-
- pAd->CommonCfg.TxRateIndex = 0;
- }
- else
- {
- pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
- pHtPhy->field.MCS = (pAd->CommonCfg.MaxTxRate > 3) ? (pAd->CommonCfg.MaxTxRate - 4) : pAd->CommonCfg.MaxTxRate;
- pHtPhy->field.MODE = (pAd->CommonCfg.MaxTxRate > 3) ? MODE_OFDM : MODE_CCK;
-
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC = pHtPhy->field.STBC;
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI = pHtPhy->field.ShortGI;
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS = pHtPhy->field.MCS;
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE = pHtPhy->field.MODE;
- }
-
- if (pAd->CommonCfg.TxRate <= RATE_11)
- {
- pMaxHtPhy->field.MODE = MODE_CCK;
- pMaxHtPhy->field.MCS = pAd->CommonCfg.TxRate;
- pMinHtPhy->field.MCS = pAd->CommonCfg.MinTxRate;
- }
- else
- {
- pMaxHtPhy->field.MODE = MODE_OFDM;
- pMaxHtPhy->field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.TxRate];
- if (pAd->CommonCfg.MinTxRate >= RATE_6 && (pAd->CommonCfg.MinTxRate <= RATE_54))
- {pMinHtPhy->field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MinTxRate];}
- else
- {pMinHtPhy->field.MCS = pAd->CommonCfg.MinTxRate;}
- }
-
- pHtPhy->word = (pMaxHtPhy->word);
- if (bLinkUp && (pAd->OpMode == OPMODE_STA))
- {
- pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word = pHtPhy->word;
- pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word = pMaxHtPhy->word;
- pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word = pMinHtPhy->word;
- }
- else
- {
- switch (pAd->CommonCfg.PhyMode)
- {
- case PHY_11BG_MIXED:
- case PHY_11B:
-#ifdef DOT11_N_SUPPORT
- case PHY_11BGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.MlmeRate = RATE_1;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
-
-//#ifdef WIFI_TEST
- pAd->CommonCfg.RtsRate = RATE_11;
-//#else
-// pAd->CommonCfg.RtsRate = RATE_1;
-//#endif
- break;
- case PHY_11G:
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11AGN_MIXED:
- case PHY_11GN_MIXED:
- case PHY_11N_2_4G:
- case PHY_11AN_MIXED:
- case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- break;
- case PHY_11ABG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11ABGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- if (pAd->CommonCfg.Channel <= 14)
- {
- pAd->CommonCfg.MlmeRate = RATE_1;
- pAd->CommonCfg.RtsRate = RATE_1;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
- }
- else
- {
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- break;
- default: // error
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->CommonCfg.RtsRate = RATE_1;
- break;
- }
- //
- // Keep Basic Mlme Rate.
- //
- pAd->MacTab.Content[MCAST_WCID].HTPhyMode.word = pAd->CommonCfg.MlmeTransmit.word;
- if (pAd->CommonCfg.MlmeTransmit.field.MODE == MODE_OFDM)
- pAd->MacTab.Content[MCAST_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[RATE_24];
- else
- pAd->MacTab.Content[MCAST_WCID].HTPhyMode.field.MCS = RATE_1;
- pAd->CommonCfg.BasicMlmeRate = pAd->CommonCfg.MlmeRate;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, MinRate=%d, Rate Switching =%d)\n",
- RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport], RateIdToMbps[pAd->CommonCfg.MaxTxRate], RateIdToMbps[pAd->CommonCfg.MinTxRate],
- /*OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)*/*auto_rate_cur_p));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04lx)\n",
- RateIdToMbps[pAd->CommonCfg.TxRate], RateIdToMbps[pAd->CommonCfg.RtsRate], BasicRateBitmap));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeUpdateTxRates (MlmeTransmit=0x%x, MinHTPhyMode=%x, MaxHTPhyMode=0x%x, HTPhyMode=0x%x)\n",
- pAd->CommonCfg.MlmeTransmit.word, pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word ));
-}
-
-#ifdef DOT11_N_SUPPORT
-/*
- ==========================================================================
- Description:
- This function update HT Rate setting.
- Input Wcid value is valid for 2 case :
- 1. it's used for Station in infra mode that copy AP rate to Mactable.
- 2. OR Station in adhoc mode to copy peer's HT rate to Mactable.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeUpdateHtTxRates(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx)
-{
- UCHAR StbcMcs; //j, StbcMcs, bitmask;
- CHAR i; // 3*3
- RT_HT_CAPABILITY *pRtHtCap = NULL;
- RT_HT_PHY_INFO *pActiveHtPhy = NULL;
- ULONG BasicMCS;
- UCHAR j, bitmask;
- PRT_HT_PHY_INFO pDesireHtPhy = NULL;
- PHTTRANSMIT_SETTING pHtPhy = NULL;
- PHTTRANSMIT_SETTING pMaxHtPhy = NULL;
- PHTTRANSMIT_SETTING pMinHtPhy = NULL;
- BOOLEAN *auto_rate_cur_p;
-
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates===> \n"));
-
- auto_rate_cur_p = NULL;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- pDesireHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
- pActiveHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
- pHtPhy = &pAd->StaCfg.HTPhyMode;
- pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
- pMinHtPhy = &pAd->StaCfg.MinHTPhyMode;
-
- auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
- {
- if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- return;
-
- pRtHtCap = &pAd->StaActive.SupportedHtPhy;
- pActiveHtPhy = &pAd->StaActive.SupportedPhyInfo;
- StbcMcs = (UCHAR)pAd->MlmeAux.AddHtInfo.AddHtInfo3.StbcMcs;
- BasicMCS =pAd->MlmeAux.AddHtInfo.MCSSet[0]+(pAd->MlmeAux.AddHtInfo.MCSSet[1]<<8)+(StbcMcs<<16);
- if ((pAd->CommonCfg.DesiredHtPhy.TxSTBC) && (pRtHtCap->RxSTBC) && (pAd->Antenna.field.TxPath == 2))
- pMaxHtPhy->field.STBC = STBC_USE;
- else
- pMaxHtPhy->field.STBC = STBC_NONE;
- }
- else
-#endif // CONFIG_STA_SUPPORT //
- {
- if (pDesireHtPhy->bHtEnable == FALSE)
- return;
-
- pRtHtCap = &pAd->CommonCfg.DesiredHtPhy;
- StbcMcs = (UCHAR)pAd->CommonCfg.AddHTInfo.AddHtInfo3.StbcMcs;
- BasicMCS = pAd->CommonCfg.AddHTInfo.MCSSet[0]+(pAd->CommonCfg.AddHTInfo.MCSSet[1]<<8)+(StbcMcs<<16);
- if ((pAd->CommonCfg.DesiredHtPhy.TxSTBC) && (pRtHtCap->RxSTBC) && (pAd->Antenna.field.TxPath == 2))
- pMaxHtPhy->field.STBC = STBC_USE;
- else
- pMaxHtPhy->field.STBC = STBC_NONE;
- }
-
- // Decide MAX ht rate.
- if ((pRtHtCap->GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- pMaxHtPhy->field.MODE = MODE_HTGREENFIELD;
- else
- pMaxHtPhy->field.MODE = MODE_HTMIX;
-
- if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth) && (pRtHtCap->ChannelWidth))
- pMaxHtPhy->field.BW = BW_40;
- else
- pMaxHtPhy->field.BW = BW_20;
-
- if (pMaxHtPhy->field.BW == BW_20)
- pMaxHtPhy->field.ShortGI = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 & pRtHtCap->ShortGIfor20);
- else
- pMaxHtPhy->field.ShortGI = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 & pRtHtCap->ShortGIfor40);
-
- for (i=23; i>=0; i--) // 3*3
- {
- j = i/8;
- bitmask = (1<<(i-(j*8)));
-
- if ((pActiveHtPhy->MCSSet[j] & bitmask) && (pDesireHtPhy->MCSSet[j] & bitmask))
- {
- pMaxHtPhy->field.MCS = i;
- break;
- }
-
- if (i==0)
- break;
- }
-
- // Copy MIN ht rate. rt2860???
- pMinHtPhy->field.BW = BW_20;
- pMinHtPhy->field.MCS = 0;
- pMinHtPhy->field.STBC = 0;
- pMinHtPhy->field.ShortGI = 0;
- //If STA assigns fixed rate. update to fixed here.
-#ifdef CONFIG_STA_SUPPORT
- if ( (pAd->OpMode == OPMODE_STA) && (pDesireHtPhy->MCSSet[0] != 0xff))
- {
- if (pDesireHtPhy->MCSSet[4] != 0)
- {
- pMaxHtPhy->field.MCS = 32;
- pMinHtPhy->field.MCS = 32;
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates<=== Use Fixed MCS = %d\n",pMinHtPhy->field.MCS));
- }
-
- for (i=23; (CHAR)i >= 0; i--) // 3*3
- {
- j = i/8;
- bitmask = (1<<(i-(j*8)));
- if ( (pDesireHtPhy->MCSSet[j] & bitmask) && (pActiveHtPhy->MCSSet[j] & bitmask))
- {
- pMaxHtPhy->field.MCS = i;
- pMinHtPhy->field.MCS = i;
- break;
- }
- if (i==0)
- break;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- // Decide ht rate
- pHtPhy->field.STBC = pMaxHtPhy->field.STBC;
- pHtPhy->field.BW = pMaxHtPhy->field.BW;
- pHtPhy->field.MODE = pMaxHtPhy->field.MODE;
- pHtPhy->field.MCS = pMaxHtPhy->field.MCS;
- pHtPhy->field.ShortGI = pMaxHtPhy->field.ShortGI;
-
- // use default now. rt2860
- if (pDesireHtPhy->MCSSet[0] != 0xff)
- *auto_rate_cur_p = FALSE;
- else
- *auto_rate_cur_p = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateHtTxRates<---.AMsduSize = %d \n", pAd->CommonCfg.DesiredHtPhy.AmsduSize ));
- DBGPRINT(RT_DEBUG_TRACE,("TX: MCS[0] = %x (choose %d), BW = %d, ShortGI = %d, MODE = %d, \n", pActiveHtPhy->MCSSet[0],pHtPhy->field.MCS,
- pHtPhy->field.BW, pHtPhy->field.ShortGI, pHtPhy->field.MODE));
- DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates<=== \n"));
-}
-#endif // DOT11_N_SUPPORT //
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeRadioOff(
- IN PRTMP_ADAPTER pAd)
-{
- RT28XX_MLME_RADIO_OFF(pAd);
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeRadioOn(
- IN PRTMP_ADAPTER pAd)
-{
- RT28XX_MLME_RADIO_ON(pAd);
-}
-
-// ===========================================================================================
-// bss_table.c
-// ===========================================================================================
-
-
-/*! \brief initialize BSS table
- * \param p_tab pointer to the table
- * \return none
- * \pre
- * \post
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-VOID BssTableInit(
- IN BSS_TABLE *Tab)
-{
- int i;
-
- Tab->BssNr = 0;
- Tab->BssOverlapNr = 0;
- for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++)
- {
- NdisZeroMemory(&Tab->BssEntry[i], sizeof(BSS_ENTRY));
- Tab->BssEntry[i].Rssi = -127; // initial the rssi as a minimum value
- }
-}
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableInit(
- IN PRTMP_ADAPTER pAd,
- IN BA_TABLE *Tab)
-{
- int i;
-
- Tab->numAsOriginator = 0;
- Tab->numAsRecipient = 0;
- NdisAllocateSpinLock(&pAd->BATabLock);
- for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++)
- {
- Tab->BARecEntry[i].REC_BA_Status = Recipient_NONE;
- NdisAllocateSpinLock(&(Tab->BARecEntry[i].RxReRingLock));
- }
- for (i = 0; i < MAX_LEN_OF_BA_ORI_TABLE; i++)
- {
- Tab->BAOriEntry[i].ORI_BA_Status = Originator_NONE;
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-/*! \brief search the BSS table by SSID
- * \param p_tab pointer to the bss table
- * \param ssid SSID string
- * \return index of the table, BSS_NOT_FOUND if not in the table
- * \pre
- * \post
- * \note search by sequential search
-
- IRQL = DISPATCH_LEVEL
-
- */
-ULONG BssTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN UCHAR Channel)
-{
- UCHAR i;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- //
- // Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G.
- // We should distinguish this case.
- //
- if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
- ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
- MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid))
- {
- return i;
- }
- }
- return (ULONG)BSS_NOT_FOUND;
-}
-
-ULONG BssSsidTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel)
-{
- UCHAR i;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- //
- // Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G.
- // We should distinguish this case.
- //
- if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
- ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
- MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid) &&
- SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen))
- {
- return i;
- }
- }
- return (ULONG)BSS_NOT_FOUND;
-}
-
-ULONG BssTableSearchWithSSID(
- IN BSS_TABLE *Tab,
- IN PUCHAR Bssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel)
-{
- UCHAR i;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
- ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
- MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid) &&
- (SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen) ||
- (NdisEqualMemory(pSsid, ZeroSsid, SsidLen)) ||
- (NdisEqualMemory(Tab->BssEntry[i].Ssid, ZeroSsid, Tab->BssEntry[i].SsidLen))))
- {
- return i;
- }
- }
- return (ULONG)BSS_NOT_FOUND;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID BssTableDeleteEntry(
- IN OUT BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN UCHAR Channel)
-{
- UCHAR i, j;
-
- for (i = 0; i < Tab->BssNr; i++)
- {
- if ((Tab->BssEntry[i].Channel == Channel) &&
- (MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid)))
- {
- for (j = i; j < Tab->BssNr - 1; j++)
- {
- NdisMoveMemory(&(Tab->BssEntry[j]), &(Tab->BssEntry[j + 1]), sizeof(BSS_ENTRY));
- }
- NdisZeroMemory(&(Tab->BssEntry[Tab->BssNr - 1]), sizeof(BSS_ENTRY));
- Tab->BssNr -= 1;
- return;
- }
- }
-}
-
-#ifdef DOT11_N_SUPPORT
-/*
- ========================================================================
- Routine Description:
- Delete the Originator Entry in BAtable. Or decrease numAs Originator by 1 if needed.
-
- Arguments:
- // IRQL = DISPATCH_LEVEL
- ========================================================================
-*/
-VOID BATableDeleteORIEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN BA_ORI_ENTRY *pBAORIEntry)
-{
-
- if (pBAORIEntry->ORI_BA_Status != Originator_NONE)
- {
- NdisAcquireSpinLock(&pAd->BATabLock);
- if (pBAORIEntry->ORI_BA_Status == Originator_Done)
- {
- pAd->BATable.numAsOriginator -= 1;
- DBGPRINT(RT_DEBUG_TRACE, ("BATableDeleteORIEntry numAsOriginator= %ld\n", pAd->BATable.numAsRecipient));
- // Erase Bitmap flag.
- }
- pAd->MacTab.Content[pBAORIEntry->Wcid].TXBAbitmap &= (~(1<<(pBAORIEntry->TID) )); // If STA mode, erase flag here
- pAd->MacTab.Content[pBAORIEntry->Wcid].BAOriWcidArray[pBAORIEntry->TID] = 0; // If STA mode, erase flag here
- pBAORIEntry->ORI_BA_Status = Originator_NONE;
- pBAORIEntry->Token = 1;
- // Not clear Sequence here.
- NdisReleaseSpinLock(&pAd->BATabLock);
- }
-}
-#endif // DOT11_N_SUPPORT //
-
-/*! \brief
- * \param
- * \return
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-VOID BssEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_ENTRY *pBss,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN PCF_PARM pCfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR Channel,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE)
-{
- COPY_MAC_ADDR(pBss->Bssid, pBssid);
- // Default Hidden SSID to be TRUE, it will be turned to FALSE after coping SSID
- pBss->Hidden = 1;
- if (SsidLen > 0)
- {
- // For hidden SSID AP, it might send beacon with SSID len equal to 0
- // Or send beacon /probe response with SSID len matching real SSID length,
- // but SSID is all zero. such as "00-00-00-00" with length 4.
- // We have to prevent this case overwrite correct table
- if (NdisEqualMemory(Ssid, ZeroSsid, SsidLen) == 0)
- {
- NdisZeroMemory(pBss->Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pBss->Ssid, Ssid, SsidLen);
- pBss->SsidLen = SsidLen;
- pBss->Hidden = 0;
- }
- }
- else
- pBss->SsidLen = 0;
- pBss->BssType = BssType;
- pBss->BeaconPeriod = BeaconPeriod;
- if (BssType == BSS_INFRA)
- {
- if (pCfParm->bValid)
- {
- pBss->CfpCount = pCfParm->CfpCount;
- pBss->CfpPeriod = pCfParm->CfpPeriod;
- pBss->CfpMaxDuration = pCfParm->CfpMaxDuration;
- pBss->CfpDurRemaining = pCfParm->CfpDurRemaining;
- }
- }
- else
- {
- pBss->AtimWin = AtimWin;
- }
-
- pBss->CapabilityInfo = CapabilityInfo;
- // The privacy bit indicate security is ON, it maight be WEP, TKIP or AES
- // Combine with AuthMode, they will decide the connection methods.
- pBss->Privacy = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo);
- ASSERT(SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
- if (SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES)
- NdisMoveMemory(pBss->SupRate, SupRate, SupRateLen);
- else
- NdisMoveMemory(pBss->SupRate, SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- pBss->SupRateLen = SupRateLen;
- ASSERT(ExtRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pBss->ExtRate, ExtRate, ExtRateLen);
- NdisMoveMemory(&pBss->HtCapability, pHtCapability, HtCapabilityLen);
- NdisMoveMemory(&pBss->AddHtInfo, pAddHtInfo, AddHtInfoLen);
- pBss->NewExtChanOffset = NewExtChanOffset;
- pBss->ExtRateLen = ExtRateLen;
- pBss->Channel = Channel;
- pBss->CentralChannel = Channel;
- pBss->Rssi = Rssi;
- // Update CkipFlag. if not exists, the value is 0x0
- pBss->CkipFlag = CkipFlag;
-
- // New for microsoft Fixed IEs
- NdisMoveMemory(pBss->FixIEs.Timestamp, &TimeStamp, 8);
- pBss->FixIEs.BeaconInterval = BeaconPeriod;
- pBss->FixIEs.Capabilities = CapabilityInfo;
-
- // New for microsoft Variable IEs
- if (LengthVIE != 0)
- {
- pBss->VarIELen = LengthVIE;
- NdisMoveMemory(pBss->VarIEs, pVIE, pBss->VarIELen);
- }
- else
- {
- pBss->VarIELen = 0;
- }
-
- pBss->AddHtInfoLen = 0;
- pBss->HtCapabilityLen = 0;
-#ifdef DOT11_N_SUPPORT
- if (HtCapabilityLen> 0)
- {
- pBss->HtCapabilityLen = HtCapabilityLen;
- NdisMoveMemory(&pBss->HtCapability, pHtCapability, HtCapabilityLen);
- if (AddHtInfoLen > 0)
- {
- pBss->AddHtInfoLen = AddHtInfoLen;
- NdisMoveMemory(&pBss->AddHtInfo, pAddHtInfo, AddHtInfoLen);
-
- if ((pAddHtInfo->ControlChan > 2)&& (pAddHtInfo->AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (pHtCapability->HtCapInfo.ChannelWidth == BW_40))
- {
- pBss->CentralChannel = pAddHtInfo->ControlChan - 2;
- }
- else if ((pAddHtInfo->AddHtInfo.ExtChanOffset == EXTCHA_ABOVE) && (pHtCapability->HtCapInfo.ChannelWidth == BW_40))
- {
- pBss->CentralChannel = pAddHtInfo->ControlChan + 2;
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- BssCipherParse(pBss);
-
- // new for QOS
- if (pEdcaParm)
- NdisMoveMemory(&pBss->EdcaParm, pEdcaParm, sizeof(EDCA_PARM));
- else
- pBss->EdcaParm.bValid = FALSE;
- if (pQosCapability)
- NdisMoveMemory(&pBss->QosCapability, pQosCapability, sizeof(QOS_CAPABILITY_PARM));
- else
- pBss->QosCapability.bValid = FALSE;
- if (pQbssLoad)
- NdisMoveMemory(&pBss->QbssLoad, pQbssLoad, sizeof(QBSS_LOAD_PARM));
- else
- pBss->QbssLoad.bValid = FALSE;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- PEID_STRUCT pEid;
- USHORT Length = 0;
-
-
- NdisZeroMemory(&pBss->WpaIE.IE[0], MAX_CUSTOM_LEN);
- NdisZeroMemory(&pBss->RsnIE.IE[0], MAX_CUSTOM_LEN);
-#ifdef EXT_BUILD_CHANNEL_LIST
- NdisZeroMemory(&pBss->CountryString[0], 3);
- pBss->bHasCountryIE = FALSE;
-#endif // EXT_BUILD_CHANNEL_LIST //
- pEid = (PEID_STRUCT) pVIE;
- while ((Length + 2 + (USHORT)pEid->Len) <= LengthVIE)
- {
- switch(pEid->Eid)
- {
- case IE_WPA:
- if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- {
- if ((pEid->Len + 2) > MAX_CUSTOM_LEN)
- {
- pBss->WpaIE.IELen = 0;
- break;
- }
- pBss->WpaIE.IELen = pEid->Len + 2;
- NdisMoveMemory(pBss->WpaIE.IE, pEid, pBss->WpaIE.IELen);
- }
- break;
- case IE_RSN:
- if (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- {
- if ((pEid->Len + 2) > MAX_CUSTOM_LEN)
- {
- pBss->RsnIE.IELen = 0;
- break;
- }
- pBss->RsnIE.IELen = pEid->Len + 2;
- NdisMoveMemory(pBss->RsnIE.IE, pEid, pBss->RsnIE.IELen);
- }
- break;
-#ifdef EXT_BUILD_CHANNEL_LIST
- case IE_COUNTRY:
- NdisMoveMemory(&pBss->CountryString[0], pEid->Octet, 3);
- pBss->bHasCountryIE = TRUE;
- break;
-#endif // EXT_BUILD_CHANNEL_LIST //
- }
- Length = Length + 2 + (USHORT)pEid->Len; // Eid[1] + Len[1]+ content[Len]
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-}
-
-/*!
- * \brief insert an entry into the bss table
- * \param p_tab The BSS table
- * \param Bssid BSSID
- * \param ssid SSID
- * \param ssid_len Length of SSID
- * \param bss_type
- * \param beacon_period
- * \param timestamp
- * \param p_cf
- * \param atim_win
- * \param cap
- * \param rates
- * \param rates_len
- * \param channel_idx
- * \return none
- * \pre
- * \post
- * \note If SSID is identical, the old entry will be replaced by the new one
-
- IRQL = DISPATCH_LEVEL
-
- */
-ULONG BssTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN CF_PARM *CfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR ChannelNo,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE)
-{
- ULONG Idx;
-
- Idx = BssTableSearchWithSSID(Tab, pBssid, Ssid, SsidLen, ChannelNo);
- if (Idx == BSS_NOT_FOUND)
- {
- if (Tab->BssNr >= MAX_LEN_OF_BSS_TABLE)
- {
- //
- // It may happen when BSS Table was full.
- // The desired AP will not be added into BSS Table
- // In this case, if we found the desired AP then overwrite BSS Table.
- //
- if(!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, pBssid) ||
- SSID_EQUAL(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Ssid, SsidLen))
- {
- Idx = Tab->BssOverlapNr;
- BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin,
- CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
- NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- Tab->BssOverlapNr = (Tab->BssOverlapNr++) % MAX_LEN_OF_BSS_TABLE;
- }
- return Idx;
- }
- else
- {
- return BSS_NOT_FOUND;
- }
- }
- Idx = Tab->BssNr;
- BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin,
- CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
- NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- Tab->BssNr++;
- }
- else
- {
- /* avoid Hidden SSID form beacon to overwirite correct SSID from probe response */
- if ((SSID_EQUAL(Ssid, SsidLen, Tab->BssEntry[Idx].Ssid, Tab->BssEntry[Idx].SsidLen)) ||
- (NdisEqualMemory(Tab->BssEntry[Idx].Ssid, ZeroSsid, Tab->BssEntry[Idx].SsidLen)))
- {
- BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod,CfParm, AtimWin,
- CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
- NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
- }
- }
-
- return Idx;
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
-VOID TriEventInit(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
-
- for (i = 0;i < MAX_TRIGGER_EVENT;i++)
- pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
-
- pAd->CommonCfg.TriggerEventTab.EventANo = 0;
- pAd->CommonCfg.TriggerEventTab.EventBCountDown = 0;
-}
-
-ULONG TriEventTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT TRIGGER_EVENT_TAB *Tab,
- IN PUCHAR pBssid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN UCHAR RegClass,
- IN UCHAR ChannelNo)
-{
- // Event A
- if (HtCapabilityLen == 0)
- {
- if (Tab->EventANo < MAX_TRIGGER_EVENT)
- {
- RTMPMoveMemory(Tab->EventA[Tab->EventANo].BSSID, pBssid, 6);
- Tab->EventA[Tab->EventANo].bValid = TRUE;
- Tab->EventA[Tab->EventANo].Channel = ChannelNo;
- Tab->EventA[Tab->EventANo].CDCounter = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
- if (RegClass != 0)
- {
- // Beacon has Regulatory class IE. So use beacon's
- Tab->EventA[Tab->EventANo].RegClass = RegClass;
- }
- else
- {
- // Use Station's Regulatory class instead.
- if (pAd->StaActive.SupportedHtPhy.bHtEnable == TRUE)
- {
- if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
- {
- Tab->EventA[Tab->EventANo].RegClass = 32;
- }
- else if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
- Tab->EventA[Tab->EventANo].RegClass = 33;
- }
- else
- Tab->EventA[Tab->EventANo].RegClass = ??;
-
- }
-
- Tab->EventANo ++;
- }
- }
- else if (pHtCapability->HtCapInfo.Intolerant40)
- {
- Tab->EventBCountDown = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
- }
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Trigger Event table Maintainence called once every second.
-
- Arguments:
- // IRQL = DISPATCH_LEVEL
- ========================================================================
-*/
-VOID TriEventCounterMaintenance(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i;
- BOOLEAN bNotify = FALSE;
- for (i = 0;i < MAX_TRIGGER_EVENT;i++)
- {
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid && (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter > 0))
- {
- pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter--;
- if (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter == 0)
- {
- pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
- pAd->CommonCfg.TriggerEventTab.EventANo --;
- // Need to send 20/40 Coexistence Notify frame if has status change.
- bNotify = TRUE;
- }
- }
- }
- if (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0)
- {
- pAd->CommonCfg.TriggerEventTab.EventBCountDown--;
- if (pAd->CommonCfg.TriggerEventTab.EventBCountDown == 0)
- bNotify = TRUE;
- }
-
- if (bNotify == TRUE)
- Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE);
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-// IRQL = DISPATCH_LEVEL
-VOID BssTableSsidSort(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_TABLE *OutTab,
- IN CHAR Ssid[],
- IN UCHAR SsidLen)
-{
- INT i;
- BssTableInit(OutTab);
-
- for (i = 0; i < pAd->ScanTab.BssNr; i++)
- {
- BSS_ENTRY *pInBss = &pAd->ScanTab.BssEntry[i];
- BOOLEAN bIsHiddenApIncluded = FALSE;
-
- if (((pAd->CommonCfg.bIEEE80211H == 1) &&
- (pAd->MlmeAux.Channel > 14) &&
- RadarChannelCheck(pAd, pInBss->Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- if (pInBss->Hidden)
- bIsHiddenApIncluded = TRUE;
- }
-
- if ((pInBss->BssType == pAd->StaCfg.BssType) &&
- (SSID_EQUAL(Ssid, SsidLen, pInBss->Ssid, pInBss->SsidLen) || bIsHiddenApIncluded))
- {
- BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // If no Country IE exists no Connection will be established when IEEE80211dClientMode is strict.
- if ((pAd->StaCfg.IEEE80211dClientMode == Rt802_11_D_Strict) &&
- (pInBss->bHasCountryIE == FALSE))
- {
- DBGPRINT(RT_DEBUG_TRACE,("StaCfg.IEEE80211dClientMode == Rt802_11_D_Strict, but this AP doesn't have country IE.\n"));
- continue;
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef DOT11_N_SUPPORT
- // 2.4G/5G N only mode
- if ((pInBss->HtCapabilityLen == 0) &&
- ((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)))
- {
- DBGPRINT(RT_DEBUG_TRACE,("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
- continue;
- }
-#endif // DOT11_N_SUPPORT //
-
- // New for WPA2
- // Check the Authmode first
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // Check AuthMode and AuthModeAux for matching, in case AP support dual-mode
- if ((pAd->StaCfg.AuthMode != pInBss->AuthMode) && (pAd->StaCfg.AuthMode != pInBss->AuthModeAux))
- // None matched
- continue;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA.GroupCipher)
- continue;
-
- // check group cipher
- if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipherAux))
- continue;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA2.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA2.GroupCipher)
- continue;
-
- // check group cipher
- if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipherAux))
- continue;
- }
- }
- // Bss Type matched, SSID matched.
- // We will check wepstatus for qualification Bss
- else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
- {
- DBGPRINT(RT_DEBUG_TRACE,("StaCfg.WepStatus=%d, while pInBss->WepStatus=%d\n", pAd->StaCfg.WepStatus, pInBss->WepStatus));
- //
- // For the SESv2 case, we will not qualify WepStatus.
- //
- if (!pInBss->bSES)
- continue;
- }
-
- // Since the AP is using hidden SSID, and we are trying to connect to ANY
- // It definitely will fail. So, skip it.
- // CCX also require not even try to connect it!!
- if (SsidLen == 0)
- continue;
-
-#ifdef DOT11_N_SUPPORT
- // If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
- // If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
- if ((pInBss->CentralChannel != pInBss->Channel) &&
- (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
- {
- if (RTMPCheckChannel(pAd, pInBss->CentralChannel, pInBss->Channel) == FALSE)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- SetCommonHT(pAd);
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- }
- else
- {
- if (pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BAND_WIDTH_20)
- {
- SetCommonHT(pAd);
- }
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- // copy matching BSS from InTab to OutTab
- NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
-
- OutTab->BssNr++;
- }
- else if ((pInBss->BssType == pAd->StaCfg.BssType) && (SsidLen == 0))
- {
- BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-
-#ifdef DOT11_N_SUPPORT
- // 2.4G/5G N only mode
- if ((pInBss->HtCapabilityLen == 0) &&
- ((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)))
- {
- DBGPRINT(RT_DEBUG_TRACE,("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
- continue;
- }
-#endif // DOT11_N_SUPPORT //
-
- // New for WPA2
- // Check the Authmode first
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // Check AuthMode and AuthModeAux for matching, in case AP support dual-mode
- if ((pAd->StaCfg.AuthMode != pInBss->AuthMode) && (pAd->StaCfg.AuthMode != pInBss->AuthModeAux))
- // None matched
- continue;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA.GroupCipher)
- continue;
-
- // check group cipher
- if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA.PairCipherAux))
- continue;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- // If it's not mixed mode, we should only let BSS pass with the same encryption
- if (pInBss->WPA2.bMixMode == FALSE)
- if (pAd->StaCfg.WepStatus != pInBss->WPA2.GroupCipher)
- continue;
-
- // check group cipher
- if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
- continue;
-
- // check pairwise cipher, skip if none matched
- // If profile set to AES, let it pass without question.
- // If profile set to TKIP, we must find one mateched
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) &&
- (pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipherAux))
- continue;
- }
- }
- // Bss Type matched, SSID matched.
- // We will check wepstatus for qualification Bss
- else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
- continue;
-
-#ifdef DOT11_N_SUPPORT
- // If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
- // If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
- if ((pInBss->CentralChannel != pInBss->Channel) &&
- (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
- {
- if (RTMPCheckChannel(pAd, pInBss->CentralChannel, pInBss->Channel) == FALSE)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- SetCommonHT(pAd);
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- // copy matching BSS from InTab to OutTab
- NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
-
- OutTab->BssNr++;
- }
-
- if (OutTab->BssNr >= MAX_LEN_OF_BSS_TABLE)
- break;
- }
-
- BssTableSortByRssi(OutTab);
-}
-
-
-// IRQL = DISPATCH_LEVEL
-VOID BssTableSortByRssi(
- IN OUT BSS_TABLE *OutTab)
-{
- INT i, j;
- BSS_ENTRY TmpBss;
-
- for (i = 0; i < OutTab->BssNr - 1; i++)
- {
- for (j = i+1; j < OutTab->BssNr; j++)
- {
- if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi)
- {
- NdisMoveMemory(&TmpBss, &OutTab->BssEntry[j], sizeof(BSS_ENTRY));
- NdisMoveMemory(&OutTab->BssEntry[j], &OutTab->BssEntry[i], sizeof(BSS_ENTRY));
- NdisMoveMemory(&OutTab->BssEntry[i], &TmpBss, sizeof(BSS_ENTRY));
- }
- }
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-VOID BssCipherParse(
- IN OUT PBSS_ENTRY pBss)
-{
- PEID_STRUCT pEid;
- PUCHAR pTmp;
- PRSN_IE_HEADER_STRUCT pRsnHeader;
- PCIPHER_SUITE_STRUCT pCipher;
- PAKM_SUITE_STRUCT pAKM;
- USHORT Count;
- INT Length;
- NDIS_802_11_ENCRYPTION_STATUS TmpCipher;
-
- //
- // WepStatus will be reset later, if AP announce TKIP or AES on the beacon frame.
- //
- if (pBss->Privacy)
- {
- pBss->WepStatus = Ndis802_11WEPEnabled;
- }
- else
- {
- pBss->WepStatus = Ndis802_11WEPDisabled;
- }
- // Set default to disable & open authentication before parsing variable IE
- pBss->AuthMode = Ndis802_11AuthModeOpen;
- pBss->AuthModeAux = Ndis802_11AuthModeOpen;
-
- // Init WPA setting
- pBss->WPA.PairCipher = Ndis802_11WEPDisabled;
- pBss->WPA.PairCipherAux = Ndis802_11WEPDisabled;
- pBss->WPA.GroupCipher = Ndis802_11WEPDisabled;
- pBss->WPA.RsnCapability = 0;
- pBss->WPA.bMixMode = FALSE;
-
- // Init WPA2 setting
- pBss->WPA2.PairCipher = Ndis802_11WEPDisabled;
- pBss->WPA2.PairCipherAux = Ndis802_11WEPDisabled;
- pBss->WPA2.GroupCipher = Ndis802_11WEPDisabled;
- pBss->WPA2.RsnCapability = 0;
- pBss->WPA2.bMixMode = FALSE;
-
-
- Length = (INT) pBss->VarIELen;
-
- while (Length > 0)
- {
- // Parse cipher suite base on WPA1 & WPA2, they should be parsed differently
- pTmp = ((PUCHAR) pBss->VarIEs) + pBss->VarIELen - Length;
- pEid = (PEID_STRUCT) pTmp;
- switch (pEid->Eid)
- {
- case IE_WPA:
- //Parse Cisco IE_WPA (LEAP, CCKM, etc.)
- if ( NdisEqualMemory((pTmp+8), CISCO_OUI, 3))
- {
- pTmp += 11;
- switch (*pTmp)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- pBss->WepStatus = Ndis802_11Encryption1Enabled;
- pBss->WPA.PairCipher = Ndis802_11Encryption1Enabled;
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- pBss->WepStatus = Ndis802_11Encryption2Enabled;
- pBss->WPA.PairCipher = Ndis802_11Encryption1Enabled;
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- case 4:
- pBss->WepStatus = Ndis802_11Encryption3Enabled;
- pBss->WPA.PairCipher = Ndis802_11Encryption1Enabled;
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- default:
- break;
- }
-
- // if Cisco IE_WPA, break
- break;
- }
- else if (NdisEqualMemory(pEid->Octet, SES_OUI, 3) && (pEid->Len == 7))
- {
- pBss->bSES = TRUE;
- break;
- }
- else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4) != 1)
- {
- // if unsupported vendor specific IE
- break;
- }
- // Skip OUI, version, and multicast suite
- // This part should be improved in the future when AP supported multiple cipher suite.
- // For now, it's OK since almost all APs have fixed cipher suite supported.
- // pTmp = (PUCHAR) pEid->Octet;
- pTmp += 11;
-
- // Cipher Suite Selectors from Spec P802.11i/D3.2 P26.
- // Value Meaning
- // 0 None
- // 1 WEP-40
- // 2 Tkip
- // 3 WRAP
- // 4 AES
- // 5 WEP-104
- // Parse group cipher
- switch (*pTmp)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- pBss->WPA.GroupCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- pBss->WPA.GroupCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- // number of unicast suite
- pTmp += 1;
-
- // skip all unicast cipher suites
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // Parsing all unicast cipher suite
- while (Count > 0)
- {
- // Skip OUI
- pTmp += 3;
- TmpCipher = Ndis802_11WEPDisabled;
- switch (*pTmp)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- TmpCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- TmpCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- TmpCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- if (TmpCipher > pBss->WPA.PairCipher)
- {
- // Move the lower cipher suite to PairCipherAux
- pBss->WPA.PairCipherAux = pBss->WPA.PairCipher;
- pBss->WPA.PairCipher = TmpCipher;
- }
- else
- {
- pBss->WPA.PairCipherAux = TmpCipher;
- }
- pTmp++;
- Count--;
- }
-
- // 4. get AKM suite counts
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
- pTmp += 3;
-
- switch (*pTmp)
- {
- case 1:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPA;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPA;
- break;
- case 2:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPAPSK;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPAPSK;
- break;
- default:
- break;
- }
- pTmp += 1;
-
- // Fixed for WPA-None
- if (pBss->BssType == BSS_ADHOC)
- {
- pBss->AuthMode = Ndis802_11AuthModeWPANone;
- pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
- pBss->WepStatus = pBss->WPA.GroupCipher;
- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
- pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
- }
- else
- pBss->WepStatus = pBss->WPA.PairCipher;
-
- // Check the Pair & Group, if different, turn on mixed mode flag
- if (pBss->WPA.GroupCipher != pBss->WPA.PairCipher)
- pBss->WPA.bMixMode = TRUE;
-
- break;
-
- case IE_RSN:
- pRsnHeader = (PRSN_IE_HEADER_STRUCT) pTmp;
-
- // 0. Version must be 1
- if (le2cpu16(pRsnHeader->Version) != 1)
- break;
- pTmp += sizeof(RSN_IE_HEADER_STRUCT);
-
- // 1. Check group cipher
- pCipher = (PCIPHER_SUITE_STRUCT) pTmp;
- if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
- break;
-
- // Parse group cipher
- switch (pCipher->Type)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- pBss->WPA2.GroupCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- pBss->WPA2.GroupCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- pBss->WPA2.GroupCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- // set to correct offset for next parsing
- pTmp += sizeof(CIPHER_SUITE_STRUCT);
-
- // 2. Get pairwise cipher counts
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // 3. Get pairwise cipher
- // Parsing all unicast cipher suite
- while (Count > 0)
- {
- // Skip OUI
- pCipher = (PCIPHER_SUITE_STRUCT) pTmp;
- TmpCipher = Ndis802_11WEPDisabled;
- switch (pCipher->Type)
- {
- case 1:
- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
- TmpCipher = Ndis802_11Encryption1Enabled;
- break;
- case 2:
- TmpCipher = Ndis802_11Encryption2Enabled;
- break;
- case 4:
- TmpCipher = Ndis802_11Encryption3Enabled;
- break;
- default:
- break;
- }
- if (TmpCipher > pBss->WPA2.PairCipher)
- {
- // Move the lower cipher suite to PairCipherAux
- pBss->WPA2.PairCipherAux = pBss->WPA2.PairCipher;
- pBss->WPA2.PairCipher = TmpCipher;
- }
- else
- {
- pBss->WPA2.PairCipherAux = TmpCipher;
- }
- pTmp += sizeof(CIPHER_SUITE_STRUCT);
- Count--;
- }
-
- // 4. get AKM suite counts
- //Count = *(PUSHORT) pTmp;
- Count = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // 5. Get AKM ciphers
- pAKM = (PAKM_SUITE_STRUCT) pTmp;
- if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
- break;
-
- switch (pAKM->Type)
- {
- case 1:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPA2;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPA2;
- break;
- case 2:
- // Set AP support WPA mode
- if (pBss->AuthMode == Ndis802_11AuthModeOpen)
- pBss->AuthMode = Ndis802_11AuthModeWPA2PSK;
- else
- pBss->AuthModeAux = Ndis802_11AuthModeWPA2PSK;
- break;
- default:
- break;
- }
- pTmp += (Count * sizeof(AKM_SUITE_STRUCT));
-
- // Fixed for WPA-None
- if (pBss->BssType == BSS_ADHOC)
- {
- pBss->AuthMode = Ndis802_11AuthModeWPANone;
- pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
- pBss->WPA.PairCipherAux = pBss->WPA2.PairCipherAux;
- pBss->WPA.GroupCipher = pBss->WPA2.GroupCipher;
- pBss->WepStatus = pBss->WPA.GroupCipher;
- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
- pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
- }
- pBss->WepStatus = pBss->WPA2.PairCipher;
-
- // 6. Get RSN capability
- //pBss->WPA2.RsnCapability = *(PUSHORT) pTmp;
- pBss->WPA2.RsnCapability = (pTmp[1]<<8) + pTmp[0];
- pTmp += sizeof(USHORT);
-
- // Check the Pair & Group, if different, turn on mixed mode flag
- if (pBss->WPA2.GroupCipher != pBss->WPA2.PairCipher)
- pBss->WPA2.bMixMode = TRUE;
-
- break;
- default:
- break;
- }
- Length -= (pEid->Len + 2);
- }
-}
-
-// ===========================================================================================
-// mac_table.c
-// ===========================================================================================
-
-/*! \brief generates a random mac address value for IBSS BSSID
- * \param Addr the bssid location
- * \return none
- * \pre
- * \post
- */
-VOID MacAddrRandomBssid(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pAddr)
-{
- INT i;
-
- for (i = 0; i < MAC_ADDR_LEN; i++)
- {
- pAddr[i] = RandomByte(pAd);
- }
-
- pAddr[0] = (pAddr[0] & 0xfe) | 0x02; // the first 2 bits must be 01xxxxxxxx
-}
-
-/*! \brief init the management mac frame header
- * \param p_hdr mac header
- * \param subtype subtype of the frame
- * \param p_ds destination address, don't care if it is a broadcast address
- * \return none
- * \pre the station has the following information in the pAd->StaCfg
- * - bssid
- * - station address
- * \post
- * \note this function initializes the following field
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-VOID MgtMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR SubType,
- IN UCHAR ToDs,
- IN PUCHAR pDA,
- IN PUCHAR pBssid)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-
- pHdr80211->FC.Type = BTYPE_MGMT;
- pHdr80211->FC.SubType = SubType;
-// if (SubType == SUBTYPE_ACK) // sample, no use, it will conflict with ACTION frame sub type
-// pHdr80211->FC.Type = BTYPE_CNTL;
- pHdr80211->FC.ToDs = ToDs;
- COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
-#endif // CONFIG_STA_SUPPORT //
- COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
-}
-
-// ===========================================================================================
-// mem_mgmt.c
-// ===========================================================================================
-
-/*!***************************************************************************
- * This routine build an outgoing frame, and fill all information specified
- * in argument list to the frame body. The actual frame size is the summation
- * of all arguments.
- * input params:
- * Buffer - pointer to a pre-allocated memory segment
- * args - a list of <int arg_size, arg> pairs.
- * NOTE NOTE NOTE!!!! the last argument must be NULL, otherwise this
- * function will FAIL!!!
- * return:
- * Size of the buffer
- * usage:
- * MakeOutgoingFrame(Buffer, output_length, 2, &fc, 2, &dur, 6, p_addr1, 6,p_addr2, END_OF_ARGS);
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ****************************************************************************/
-ULONG MakeOutgoingFrame(
- OUT CHAR *Buffer,
- OUT ULONG *FrameLen, ...)
-{
- CHAR *p;
- int leng;
- ULONG TotLeng;
- va_list Args;
-
- // calculates the total length
- TotLeng = 0;
- va_start(Args, FrameLen);
- do
- {
- leng = va_arg(Args, int);
- if (leng == END_OF_ARGS)
- {
- break;
- }
- p = va_arg(Args, PVOID);
- NdisMoveMemory(&Buffer[TotLeng], p, leng);
- TotLeng = TotLeng + leng;
- } while(TRUE);
-
- va_end(Args); /* clean up */
- *FrameLen = TotLeng;
- return TotLeng;
-}
-
-// ===========================================================================================
-// mlme_queue.c
-// ===========================================================================================
-
-/*! \brief Initialize The MLME Queue, used by MLME Functions
- * \param *Queue The MLME Queue
- * \return Always Return NDIS_STATE_SUCCESS in this implementation
- * \pre
- * \post
- * \note Because this is done only once (at the init stage), no need to be locked
-
- IRQL = PASSIVE_LEVEL
-
- */
-NDIS_STATUS MlmeQueueInit(
- IN MLME_QUEUE *Queue)
-{
- INT i;
-
- NdisAllocateSpinLock(&Queue->Lock);
-
- Queue->Num = 0;
- Queue->Head = 0;
- Queue->Tail = 0;
-
- for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++)
- {
- Queue->Entry[i].Occupied = FALSE;
- Queue->Entry[i].MsgLen = 0;
- NdisZeroMemory(Queue->Entry[i].Msg, MGMT_DMA_BUFFER_SIZE);
- }
-
- return NDIS_STATUS_SUCCESS;
-}
-
-/*! \brief Enqueue a message for other threads, if they want to send messages to MLME thread
- * \param *Queue The MLME Queue
- * \param Machine The State Machine Id
- * \param MsgType The Message Type
- * \param MsgLen The Message length
- * \param *Msg The message pointer
- * \return TRUE if enqueue is successful, FALSE if the queue is full
- * \pre
- * \post
- * \note The message has to be initialized
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeEnqueue(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Machine,
- IN ULONG MsgType,
- IN ULONG MsgLen,
- IN VOID *Msg)
-{
- INT Tail;
- MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return FALSE;
-
- // First check the size, it MUST not exceed the mlme queue size
- if (MsgLen > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("MlmeEnqueue: msg too large, size = %ld \n", MsgLen));
- return FALSE;
- }
-
- if (MlmeQueueFull(Queue))
- {
- return FALSE;
- }
-
- NdisAcquireSpinLock(&(Queue->Lock));
- Tail = Queue->Tail;
- Queue->Tail++;
- Queue->Num++;
- if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
- {
- Queue->Tail = 0;
- }
-
- Queue->Entry[Tail].Wcid = RESERVED_WCID;
- Queue->Entry[Tail].Occupied = TRUE;
- Queue->Entry[Tail].Machine = Machine;
- Queue->Entry[Tail].MsgType = MsgType;
- Queue->Entry[Tail].MsgLen = MsgLen;
-
- if (Msg != NULL)
- {
- NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
- }
-
- NdisReleaseSpinLock(&(Queue->Lock));
- return TRUE;
-}
-
-/*! \brief This function is used when Recv gets a MLME message
- * \param *Queue The MLME Queue
- * \param TimeStampHigh The upper 32 bit of timestamp
- * \param TimeStampLow The lower 32 bit of timestamp
- * \param Rssi The receiving RSSI strength
- * \param MsgLen The length of the message
- * \param *Msg The message pointer
- * \return TRUE if everything ok, FALSE otherwise (like Queue Full)
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG TimeStampHigh,
- IN ULONG TimeStampLow,
- IN UCHAR Rssi0,
- IN UCHAR Rssi1,
- IN UCHAR Rssi2,
- IN ULONG MsgLen,
- IN VOID *Msg,
- IN UCHAR Signal)
-{
- INT Tail, Machine;
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
- INT MsgType;
- MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
-
-#ifdef RALINK_ATE
- /* Nothing to do in ATE mode */
- if(ATE_ON(pAd))
- return FALSE;
-#endif // RALINK_ATE //
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- DBGPRINT_ERR(("MlmeEnqueueForRecv: fRTMP_ADAPTER_HALT_IN_PROGRESS\n"));
- return FALSE;
- }
-
- // First check the size, it MUST not exceed the mlme queue size
- if (MsgLen > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("MlmeEnqueueForRecv: frame too large, size = %ld \n", MsgLen));
- return FALSE;
- }
-
- if (MlmeQueueFull(Queue))
- {
- return FALSE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (!MsgTypeSubst(pAd, pFrame, &Machine, &MsgType))
- {
- DBGPRINT_ERR(("MlmeEnqueueForRecv: un-recongnized mgmt->subtype=%d\n",pFrame->Hdr.FC.SubType));
- return FALSE;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // OK, we got all the informations, it is time to put things into queue
- NdisAcquireSpinLock(&(Queue->Lock));
- Tail = Queue->Tail;
- Queue->Tail++;
- Queue->Num++;
- if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
- {
- Queue->Tail = 0;
- }
- Queue->Entry[Tail].Occupied = TRUE;
- Queue->Entry[Tail].Machine = Machine;
- Queue->Entry[Tail].MsgType = MsgType;
- Queue->Entry[Tail].MsgLen = MsgLen;
- Queue->Entry[Tail].TimeStamp.u.LowPart = TimeStampLow;
- Queue->Entry[Tail].TimeStamp.u.HighPart = TimeStampHigh;
- Queue->Entry[Tail].Rssi0 = Rssi0;
- Queue->Entry[Tail].Rssi1 = Rssi1;
- Queue->Entry[Tail].Rssi2 = Rssi2;
- Queue->Entry[Tail].Signal = Signal;
- Queue->Entry[Tail].Wcid = (UCHAR)Wcid;
-
- Queue->Entry[Tail].Channel = pAd->LatchRfRegs.Channel;
-
- if (Msg != NULL)
- {
- NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
- }
-
- NdisReleaseSpinLock(&(Queue->Lock));
-
- RT28XX_MLME_HANDLER(pAd);
-
- return TRUE;
-}
-
-
-/*! \brief Dequeue a message from the MLME Queue
- * \param *Queue The MLME Queue
- * \param *Elem The message dequeued from MLME Queue
- * \return TRUE if the Elem contains something, FALSE otherwise
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeDequeue(
- IN MLME_QUEUE *Queue,
- OUT MLME_QUEUE_ELEM **Elem)
-{
- NdisAcquireSpinLock(&(Queue->Lock));
- *Elem = &(Queue->Entry[Queue->Head]);
- Queue->Num--;
- Queue->Head++;
- if (Queue->Head == MAX_LEN_OF_MLME_QUEUE)
- {
- Queue->Head = 0;
- }
- NdisReleaseSpinLock(&(Queue->Lock));
- return TRUE;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID MlmeRestartStateMachine(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN Cancelled;
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef QOS_DLS_SUPPORT
- UCHAR i;
-#endif // QOS_DLS_SUPPORT //
- // Cancel all timer events
- // Be careful to cancel new added timer
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-#ifdef QOS_DLS_SUPPORT
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
- }
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Change back to original channel in case of doing scan
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- // Resume MSDU which is turned off durning scan
- RTMPResumeMsduTransmission(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Set all state machines back IDLE
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
-#ifdef QOS_DLS_SUPPORT
- pAd->Mlme.DlsMachine.CurrState = DLS_IDLE;
-#endif // QOS_DLS_SUPPORT //
- }
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-/*! \brief test if the MLME Queue is empty
- * \param *Queue The MLME Queue
- * \return TRUE if the Queue is empty, FALSE otherwise
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeQueueEmpty(
- IN MLME_QUEUE *Queue)
-{
- BOOLEAN Ans;
-
- NdisAcquireSpinLock(&(Queue->Lock));
- Ans = (Queue->Num == 0);
- NdisReleaseSpinLock(&(Queue->Lock));
-
- return Ans;
-}
-
-/*! \brief test if the MLME Queue is full
- * \param *Queue The MLME Queue
- * \return TRUE if the Queue is empty, FALSE otherwise
- * \pre
- * \post
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeQueueFull(
- IN MLME_QUEUE *Queue)
-{
- BOOLEAN Ans;
-
- NdisAcquireSpinLock(&(Queue->Lock));
- Ans = (Queue->Num == MAX_LEN_OF_MLME_QUEUE || Queue->Entry[Queue->Tail].Occupied);
- NdisReleaseSpinLock(&(Queue->Lock));
-
- return Ans;
-}
-
-/*! \brief The destructor of MLME Queue
- * \param
- * \return
- * \pre
- * \post
- * \note Clear Mlme Queue, Set Queue->Num to Zero.
-
- IRQL = PASSIVE_LEVEL
-
- */
-VOID MlmeQueueDestroy(
- IN MLME_QUEUE *pQueue)
-{
- NdisAcquireSpinLock(&(pQueue->Lock));
- pQueue->Num = 0;
- pQueue->Head = 0;
- pQueue->Tail = 0;
- NdisReleaseSpinLock(&(pQueue->Lock));
- NdisFreeSpinLock(&(pQueue->Lock));
-}
-
-/*! \brief To substitute the message type if the message is coming from external
- * \param pFrame The frame received
- * \param *Machine The state machine
- * \param *MsgType the message type for the state machine
- * \return TRUE if the substitution is successful, FALSE otherwise
- * \pre
- * \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-#ifdef CONFIG_STA_SUPPORT
-BOOLEAN MsgTypeSubst(
- IN PRTMP_ADAPTER pAd,
- IN PFRAME_802_11 pFrame,
- OUT INT *Machine,
- OUT INT *MsgType)
-{
- USHORT Seq;
- UCHAR EAPType;
- PUCHAR pData;
-
- // Pointer to start of data frames including SNAP header
- pData = (PUCHAR) pFrame + LENGTH_802_11;
-
- // The only data type will pass to this function is EAPOL frame
- if (pFrame->Hdr.FC.Type == BTYPE_DATA)
- {
- if (NdisEqualMemory(SNAP_AIRONET, pData, LENGTH_802_1_H))
- {
- // Cisco Aironet SNAP header
- *Machine = AIRONET_STATE_MACHINE;
- *MsgType = MT2_AIRONET_MSG;
- return (TRUE);
- }
-#ifdef LEAP_SUPPORT
- if ( pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP ) //LEAP
- {
- // LEAP frames
- *Machine = LEAP_STATE_MACHINE;
- EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
- return (LeapMsgTypeSubst(EAPType, MsgType));
- }
- else
-#endif // LEAP_SUPPORT //
- {
- *Machine = WPA_PSK_STATE_MACHINE;
- EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
- return(WpaMsgTypeSubst(EAPType, MsgType));
- }
- }
-
- switch (pFrame->Hdr.FC.SubType)
- {
- case SUBTYPE_ASSOC_REQ:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_ASSOC_REQ;
- break;
- case SUBTYPE_ASSOC_RSP:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_ASSOC_RSP;
- break;
- case SUBTYPE_REASSOC_REQ:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_REASSOC_REQ;
- break;
- case SUBTYPE_REASSOC_RSP:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_REASSOC_RSP;
- break;
- case SUBTYPE_PROBE_REQ:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_PROBE_REQ;
- break;
- case SUBTYPE_PROBE_RSP:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_PROBE_RSP;
- break;
- case SUBTYPE_BEACON:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_BEACON;
- break;
- case SUBTYPE_ATIM:
- *Machine = SYNC_STATE_MACHINE;
- *MsgType = MT2_PEER_ATIM;
- break;
- case SUBTYPE_DISASSOC:
- *Machine = ASSOC_STATE_MACHINE;
- *MsgType = MT2_PEER_DISASSOC_REQ;
- break;
- case SUBTYPE_AUTH:
- // get the sequence number from payload 24 Mac Header + 2 bytes algorithm
- NdisMoveMemory(&Seq, &pFrame->Octet[2], sizeof(USHORT));
- if (Seq == 1 || Seq == 3)
- {
- *Machine = AUTH_RSP_STATE_MACHINE;
- *MsgType = MT2_PEER_AUTH_ODD;
- }
- else if (Seq == 2 || Seq == 4)
- {
- *Machine = AUTH_STATE_MACHINE;
- *MsgType = MT2_PEER_AUTH_EVEN;
- }
- else
- {
- return FALSE;
- }
- break;
- case SUBTYPE_DEAUTH:
- *Machine = AUTH_RSP_STATE_MACHINE;
- *MsgType = MT2_PEER_DEAUTH;
- break;
- case SUBTYPE_ACTION:
- *Machine = ACTION_STATE_MACHINE;
- // Sometimes Sta will return with category bytes with MSB = 1, if they receive catogory out of their support
- if ((pFrame->Octet[0]&0x7F) > MAX_PEER_CATE_MSG)
- {
- *MsgType = MT2_ACT_INVALID;
- }
- else
- {
- *MsgType = (pFrame->Octet[0]&0x7F);
- }
- break;
- default:
- return FALSE;
- break;
- }
-
- return TRUE;
-}
-#endif // CONFIG_STA_SUPPORT //
-
-// ===========================================================================================
-// state_machine.c
-// ===========================================================================================
-
-/*! \brief Initialize the state machine.
- * \param *S pointer to the state machine
- * \param Trans State machine transition function
- * \param StNr number of states
- * \param MsgNr number of messages
- * \param DefFunc default function, when there is invalid state/message combination
- * \param InitState initial state of the state machine
- * \param Base StateMachine base, internal use only
- * \pre p_sm should be a legal pointer
- * \post
-
- IRQL = PASSIVE_LEVEL
-
- */
-VOID StateMachineInit(
- IN STATE_MACHINE *S,
- IN STATE_MACHINE_FUNC Trans[],
- IN ULONG StNr,
- IN ULONG MsgNr,
- IN STATE_MACHINE_FUNC DefFunc,
- IN ULONG InitState,
- IN ULONG Base)
-{
- ULONG i, j;
-
- // set number of states and messages
- S->NrState = StNr;
- S->NrMsg = MsgNr;
- S->Base = Base;
-
- S->TransFunc = Trans;
-
- // init all state transition to default function
- for (i = 0; i < StNr; i++)
- {
- for (j = 0; j < MsgNr; j++)
- {
- S->TransFunc[i * MsgNr + j] = DefFunc;
- }
- }
-
- // set the starting state
- S->CurrState = InitState;
-}
-
-/*! \brief This function fills in the function pointer into the cell in the state machine
- * \param *S pointer to the state machine
- * \param St state
- * \param Msg incoming message
- * \param f the function to be executed when (state, message) combination occurs at the state machine
- * \pre *S should be a legal pointer to the state machine, st, msg, should be all within the range, Base should be set in the initial state
- * \post
-
- IRQL = PASSIVE_LEVEL
-
- */
-VOID StateMachineSetAction(
- IN STATE_MACHINE *S,
- IN ULONG St,
- IN ULONG Msg,
- IN STATE_MACHINE_FUNC Func)
-{
- ULONG MsgIdx;
-
- MsgIdx = Msg - S->Base;
-
- if (St < S->NrState && MsgIdx < S->NrMsg)
- {
- // boundary checking before setting the action
- S->TransFunc[St * S->NrMsg + MsgIdx] = Func;
- }
-}
-
-/*! \brief This function does the state transition
- * \param *Adapter the NIC adapter pointer
- * \param *S the state machine
- * \param *Elem the message to be executed
- * \return None
-
- IRQL = DISPATCH_LEVEL
-
- */
-VOID StateMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem)
-{
- (*(S->TransFunc[S->CurrState * S->NrMsg + Elem->MsgType - S->Base]))(pAd, Elem);
-}
-
-/*
- ==========================================================================
- Description:
- The drop function, when machine executes this, the message is simply
- ignored. This function does nothing, the message is freed in
- StateMachinePerformAction()
- ==========================================================================
- */
-VOID Drop(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-}
-
-// ===========================================================================================
-// lfsr.c
-// ===========================================================================================
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID LfsrInit(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Seed)
-{
- if (Seed == 0)
- pAd->Mlme.ShiftReg = 1;
- else
- pAd->Mlme.ShiftReg = Seed;
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-UCHAR RandomByte(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- UCHAR R, Result;
-
- R = 0;
-
- if (pAd->Mlme.ShiftReg == 0)
- NdisGetSystemUpTime((ULONG *)&pAd->Mlme.ShiftReg);
-
- for (i = 0; i < 8; i++)
- {
- if (pAd->Mlme.ShiftReg & 0x00000001)
- {
- pAd->Mlme.ShiftReg = ((pAd->Mlme.ShiftReg ^ LFSR_MASK) >> 1) | 0x80000000;
- Result = 1;
- }
- else
- {
- pAd->Mlme.ShiftReg = pAd->Mlme.ShiftReg >> 1;
- Result = 0;
- }
- R = (R << 1) | Result;
- }
-
- return R;
-}
-
-VOID AsicUpdateAutoFallBackTable(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pRateTable)
-{
- UCHAR i;
- HT_FBK_CFG0_STRUC HtCfg0;
- HT_FBK_CFG1_STRUC HtCfg1;
- LG_FBK_CFG0_STRUC LgCfg0;
- LG_FBK_CFG1_STRUC LgCfg1;
- PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate;
-
- // set to initial value
- HtCfg0.word = 0x65432100;
- HtCfg1.word = 0xedcba988;
- LgCfg0.word = 0xedcba988;
- LgCfg1.word = 0x00002100;
-
- pNextTxRate = (PRTMP_TX_RATE_SWITCH)pRateTable+1;
- for (i = 1; i < *((PUCHAR) pRateTable); i++)
- {
- pCurrTxRate = (PRTMP_TX_RATE_SWITCH)pRateTable+1+i;
- switch (pCurrTxRate->Mode)
- {
- case 0: //CCK
- break;
- case 1: //OFDM
- {
- switch(pCurrTxRate->CurrMCS)
- {
- case 0:
- LgCfg0.field.OFDMMCS0FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 1:
- LgCfg0.field.OFDMMCS1FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 2:
- LgCfg0.field.OFDMMCS2FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 3:
- LgCfg0.field.OFDMMCS3FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 4:
- LgCfg0.field.OFDMMCS4FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 5:
- LgCfg0.field.OFDMMCS5FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 6:
- LgCfg0.field.OFDMMCS6FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- case 7:
- LgCfg0.field.OFDMMCS7FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;
- break;
- }
- }
- break;
-#ifdef DOT11_N_SUPPORT
- case 2: //HT-MIX
- case 3: //HT-GF
- {
- if ((pNextTxRate->Mode >= MODE_HTMIX) && (pCurrTxRate->CurrMCS != pNextTxRate->CurrMCS))
- {
- switch(pCurrTxRate->CurrMCS)
- {
- case 0:
- HtCfg0.field.HTMCS0FBK = pNextTxRate->CurrMCS;
- break;
- case 1:
- HtCfg0.field.HTMCS1FBK = pNextTxRate->CurrMCS;
- break;
- case 2:
- HtCfg0.field.HTMCS2FBK = pNextTxRate->CurrMCS;
- break;
- case 3:
- HtCfg0.field.HTMCS3FBK = pNextTxRate->CurrMCS;
- break;
- case 4:
- HtCfg0.field.HTMCS4FBK = pNextTxRate->CurrMCS;
- break;
- case 5:
- HtCfg0.field.HTMCS5FBK = pNextTxRate->CurrMCS;
- break;
- case 6:
- HtCfg0.field.HTMCS6FBK = pNextTxRate->CurrMCS;
- break;
- case 7:
- HtCfg0.field.HTMCS7FBK = pNextTxRate->CurrMCS;
- break;
- case 8:
- HtCfg1.field.HTMCS8FBK = pNextTxRate->CurrMCS;
- break;
- case 9:
- HtCfg1.field.HTMCS9FBK = pNextTxRate->CurrMCS;
- break;
- case 10:
- HtCfg1.field.HTMCS10FBK = pNextTxRate->CurrMCS;
- break;
- case 11:
- HtCfg1.field.HTMCS11FBK = pNextTxRate->CurrMCS;
- break;
- case 12:
- HtCfg1.field.HTMCS12FBK = pNextTxRate->CurrMCS;
- break;
- case 13:
- HtCfg1.field.HTMCS13FBK = pNextTxRate->CurrMCS;
- break;
- case 14:
- HtCfg1.field.HTMCS14FBK = pNextTxRate->CurrMCS;
- break;
- case 15:
- HtCfg1.field.HTMCS15FBK = pNextTxRate->CurrMCS;
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("AsicUpdateAutoFallBackTable: not support CurrMCS=%d\n", pCurrTxRate->CurrMCS));
- }
- }
- }
- break;
-#endif // DOT11_N_SUPPORT //
- }
-
- pNextTxRate = pCurrTxRate;
- }
-
- RTMP_IO_WRITE32(pAd, HT_FBK_CFG0, HtCfg0.word);
- RTMP_IO_WRITE32(pAd, HT_FBK_CFG1, HtCfg1.word);
- RTMP_IO_WRITE32(pAd, LG_FBK_CFG0, LgCfg0.word);
- RTMP_IO_WRITE32(pAd, LG_FBK_CFG1, LgCfg1.word);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set MAC register value according operation mode.
- OperationMode AND bNonGFExist are for MM and GF Proteciton.
- If MM or GF mask is not set, those passing argument doesn't not take effect.
-
- Operation mode meaning:
- = 0 : Pure HT, no preotection.
- = 0x01; there may be non-HT devices in both the control and extension channel, protection is optional in BSS.
- = 0x10: No Transmission in 40M is protected.
- = 0x11: Transmission in both 40M and 20M shall be protected
- if (bNonGFExist)
- we should choose not to use GF. But still set correct ASIC registers.
- ========================================================================
-*/
-VOID AsicUpdateProtect(
- IN PRTMP_ADAPTER pAd,
- IN USHORT OperationMode,
- IN UCHAR SetMask,
- IN BOOLEAN bDisableBGProtect,
- IN BOOLEAN bNonGFExist)
-{
- PROT_CFG_STRUC ProtCfg, ProtCfg4;
- UINT32 Protect[6];
- USHORT offset;
- UCHAR i;
- UINT32 MacReg = 0;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
- if (!(pAd->CommonCfg.bHTProtect) && (OperationMode != 8))
- {
- return;
- }
-
- if (pAd->BATable.numAsOriginator)
- {
- //
- // enable the RTS/CTS to avoid channel collision
- //
- SetMask = ALLN_SETPROTECT;
- OperationMode = 8;
- }
-#endif // DOT11_N_SUPPORT //
-
- // Config ASIC RTS threshold register
- RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
- MacReg &= 0xFF0000FF;
-
- // If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
- if ((
-#ifdef DOT11_N_SUPPORT
- (pAd->CommonCfg.BACapability.field.AmsduEnable) ||
-#endif // DOT11_N_SUPPORT //
- (pAd->CommonCfg.bAggregationCapable == TRUE))
- && pAd->CommonCfg.RtsThreshold == MAX_RTS_THRESHOLD)
- {
- MacReg |= (0x1000 << 8);
- }
- else
- {
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
- }
-
- RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
-
- // Initial common protection settings
- RTMPZeroMemory(Protect, sizeof(Protect));
- ProtCfg4.word = 0;
- ProtCfg.word = 0;
- ProtCfg.field.TxopAllowGF40 = 1;
- ProtCfg.field.TxopAllowGF20 = 1;
- ProtCfg.field.TxopAllowMM40 = 1;
- ProtCfg.field.TxopAllowMM20 = 1;
- ProtCfg.field.TxopAllowOfdm = 1;
- ProtCfg.field.TxopAllowCck = 1;
- ProtCfg.field.RTSThEn = 1;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-
- // update PHY mode and rate
- if (pAd->CommonCfg.Channel > 14)
- ProtCfg.field.ProtectRate = 0x4000;
- ProtCfg.field.ProtectRate |= pAd->CommonCfg.RtsRate;
-
- // Handle legacy(B/G) protection
- if (bDisableBGProtect)
- {
- //ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0;
- Protect[0] = ProtCfg.word;
- Protect[1] = ProtCfg.word;
- }
- else
- {
- //ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0; // CCK do not need to be protected
- Protect[0] = ProtCfg.word;
- ProtCfg.field.ProtectCtrl = ASIC_CTS; // OFDM needs using CCK to protect
- Protect[1] = ProtCfg.word;
- }
-
-#ifdef DOT11_N_SUPPORT
- // Decide HT frame protection.
- if ((SetMask & ALLN_SETPROTECT) != 0)
- {
- switch(OperationMode)
- {
- case 0x0:
- // NO PROTECT
- // 1.All STAs in the BSS are 20/40 MHz HT
- // 2. in ai 20/40MHz BSS
- // 3. all STAs are 20MHz in a 20MHz BSS
- // Pure HT. no protection.
-
- // MM20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[2] = 0x01744004;
-
- // MM40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[3] = 0x03f44084;
-
- // CF20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[4] = 0x01744004;
-
- // CF40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[5] = 0x03f44084;
-
- if (bNonGFExist)
- {
- // PROT_NAV(19:18) -- 01 (Short NAV protectiion)
- // PROT_CTRL(17:16) -- 01 (RTS/CTS)
- Protect[4] = 0x01754004;
- Protect[5] = 0x03f54084;
- }
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
- break;
-
- case 1:
- // This is "HT non-member protection mode."
- // If there may be non-HT STAs my BSS
- ProtCfg.word = 0x01744004; // PROT_CTRL(17:16) : 0 (None)
- ProtCfg4.word = 0x03f44084; // duplicaet legacy 24M. BW set 1.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- ProtCfg.word = 0x01740003; //ERP use Protection bit is set, use protection rate at Clause 18..
- ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083;
- }
- //Assign Protection method for 20&40 MHz packets
- ProtCfg.field.ProtectCtrl = ASIC_RTS;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
- ProtCfg4.field.ProtectCtrl = ASIC_RTS;
- ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
- Protect[2] = ProtCfg.word;
- Protect[3] = ProtCfg4.word;
- Protect[4] = ProtCfg.word;
- Protect[5] = ProtCfg4.word;
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
- break;
-
- case 2:
- // If only HT STAs are in BSS. at least one is 20MHz. Only protect 40MHz packets
- ProtCfg.word = 0x01744004; // PROT_CTRL(17:16) : 0 (None)
- ProtCfg4.word = 0x03f44084; // duplicaet legacy 24M. BW set 1.
-
- //Assign Protection method for 40MHz packets
- ProtCfg4.field.ProtectCtrl = ASIC_RTS;
- ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
- Protect[2] = ProtCfg.word;
- Protect[3] = ProtCfg4.word;
- if (bNonGFExist)
- {
- ProtCfg.field.ProtectCtrl = ASIC_RTS;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
- }
- Protect[4] = ProtCfg.word;
- Protect[5] = ProtCfg4.word;
-
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
- break;
-
- case 3:
- // HT mixed mode. PROTECT ALL!
- // Assign Rate
- ProtCfg.word = 0x01744004; //duplicaet legacy 24M. BW set 1.
- ProtCfg4.word = 0x03f44084;
- // both 20MHz and 40MHz are protected. Whether use RTS or CTS-to-self depends on the
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- ProtCfg.word = 0x01740003; //ERP use Protection bit is set, use protection rate at Clause 18..
- ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083
- }
- //Assign Protection method for 20&40 MHz packets
- ProtCfg.field.ProtectCtrl = ASIC_RTS;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
- ProtCfg4.field.ProtectCtrl = ASIC_RTS;
- ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
- Protect[2] = ProtCfg.word;
- Protect[3] = ProtCfg4.word;
- Protect[4] = ProtCfg.word;
- Protect[5] = ProtCfg4.word;
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
- break;
-
- case 8:
- Protect[2] = 0x01754004;
- Protect[3] = 0x03f54084;
- Protect[4] = 0x01754004;
- Protect[5] = 0x03f54084;
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
- break;
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- offset = CCK_PROT_CFG;
- for (i = 0;i < 6;i++)
- {
- if ((SetMask & (1<< i)))
- {
- RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);
- }
- }
-}
-
-
-#ifdef RT30xx
-/*
- ========================================================================
-
- Routine Description: Write RT30xx RF register through MAC
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RT30xxWriteRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RegID,
- IN UCHAR Value)
-{
- RF_CSR_CFG_STRUC rfcsr;
- UINT i = 0;
-
- do
- {
- RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
-
- if (!rfcsr.field.RF_CSR_KICK)
- break;
- i++;
- }
- while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
- if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
- return STATUS_UNSUCCESSFUL;
- }
-
- rfcsr.field.RF_CSR_WR = 1;
- rfcsr.field.RF_CSR_KICK = 1;
- rfcsr.field.TESTCSR_RFACC_REGNUM = RegID;
- rfcsr.field.RF_CSR_DATA = Value;
-
- RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
-
- return STATUS_SUCCESS;
-}
-
-
-/*
- ========================================================================
-
- Routine Description: Read RT30xx RF register through MAC
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RT30xxReadRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RegID,
- IN PUCHAR pValue)
-{
- RF_CSR_CFG_STRUC rfcsr;
- UINT i=0, k=0;
-
- for (i=0; i<MAX_BUSY_COUNT; i++)
- {
- RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
-
- if (rfcsr.field.RF_CSR_KICK == BUSY)
- {
- continue;
- }
- rfcsr.word = 0;
- rfcsr.field.RF_CSR_WR = 0;
- rfcsr.field.RF_CSR_KICK = 1;
- rfcsr.field.TESTCSR_RFACC_REGNUM = RegID;
- RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
- for (k=0; k<MAX_BUSY_COUNT; k++)
- {
- RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
-
- if (rfcsr.field.RF_CSR_KICK == IDLE)
- break;
- }
- if ((rfcsr.field.RF_CSR_KICK == IDLE) &&
- (rfcsr.field.TESTCSR_RFACC_REGNUM == RegID))
- {
- *pValue = (UCHAR)rfcsr.field.RF_CSR_DATA;
- break;
- }
- }
- if (rfcsr.field.RF_CSR_KICK == BUSY)
- {
- DBGPRINT_ERR(("RF read R%d=0x%x fail, i[%d], k[%d]\n", RegID, rfcsr.word,i,k));
- return STATUS_UNSUCCESSFUL;
- }
-
- return STATUS_SUCCESS;
-}
-#endif // RT30xx //
-
-#ifdef RT30xx
-// add by johnli, RF power sequence setup
-/*
- ==========================================================================
- Description:
-
- Load RF normal operation-mode setup
-
- ==========================================================================
- */
-VOID RT30xxLoadRFNormalModeSetup(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR RFValue;
-
- // RX0_PD & TX0_PD, RF R1 register Bit 2 & Bit 3 to 0 and RF_BLOCK_en,RX1_PD & TX1_PD, Bit0, Bit 4 & Bit5 to 1
- RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
- RFValue = (RFValue & (~0x0C)) | 0x31;
- RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
- // TX_LO2_en, RF R15 register Bit 3 to 0
- RT30xxReadRFRegister(pAd, RF_R15, &RFValue);
- RFValue &= (~0x08);
- RT30xxWriteRFRegister(pAd, RF_R15, RFValue);
-
- // TX_LO1_en, RF R17 register Bit 3 to 0
- RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
- RFValue &= (~0x08);
- // to fix rx long range issue
- if (((pAd->MACVersion & 0xffff) >= 0x0211) && (pAd->NicConfig2.field.ExternalLNAForG == 0))
- {
- RFValue |= 0x20;
- }
- RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
-
- // RX_LO1_en, RF R20 register Bit 3 to 0
- RT30xxReadRFRegister(pAd, RF_R20, &RFValue);
- RFValue &= (~0x08);
- RT30xxWriteRFRegister(pAd, RF_R20, RFValue);
-
- // RX_LO2_en, RF R21 register Bit 3 to 0
- RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
- RFValue &= (~0x08);
- RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
-
- // LDORF_VC, RF R27 register Bit 2 to 0
- RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
- if ((pAd->MACVersion & 0xffff) < 0x0211)
- RFValue = (RFValue & (~0x77)) | 0x3;
- else
- RFValue = (RFValue & (~0x77));
- RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
- /* end johnli */
-}
-
-/*
- ==========================================================================
- Description:
-
- Load RF sleep-mode setup
-
- ==========================================================================
- */
-VOID RT30xxLoadRFSleepModeSetup(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR RFValue;
- UINT32 MACValue;
-
- // RF_BLOCK_en. RF R1 register Bit 0 to 0
- RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
- RFValue &= (~0x01);
- RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
- // VCO_IC, RF R7 register Bit 4 & Bit 5 to 0
- RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
- RFValue &= (~0x30);
- RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
-
- // Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 0
- RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
- RFValue &= (~0x0E);
- RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
-
- // RX_CTB_en, RF R21 register Bit 7 to 0
- RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
- RFValue &= (~0x80);
- RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
-
- // LDORF_VC, RF R27 register Bit 0, Bit 1 & Bit 2 to 1
- RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
- RFValue |= 0x77;
- RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
-
- RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
- MACValue |= 0x1D000000;
- RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
-}
-
-/*
- ==========================================================================
- Description:
-
- Reverse RF sleep-mode setup
-
- ==========================================================================
- */
-VOID RT30xxReverseRFSleepModeSetup(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR RFValue;
- UINT32 MACValue;
-
- // RF_BLOCK_en, RF R1 register Bit 0 to 1
- RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
- RFValue |= 0x01;
- RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
- // VCO_IC, RF R7 register Bit 4 & Bit 5 to 1
- RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
- RFValue |= 0x30;
- RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
-
- // Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 1
- RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
- RFValue |= 0x0E;
- RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
-
- // RX_CTB_en, RF R21 register Bit 7 to 1
- RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
- RFValue |= 0x80;
- RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
-
- // LDORF_VC, RF R27 register Bit 2 to 0
- RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
- if ((pAd->MACVersion & 0xffff) < 0x0211)
- RFValue = (RFValue & (~0x77)) | 0x3;
- else
- RFValue = (RFValue & (~0x77));
- RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
-
- // RT3071 version E has fixed this issue
- if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211))
- {
- // patch tx EVM issue temporarily
- RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
- MACValue = ((MACValue & 0xE0FFFFFF) | 0x0D000000);
- RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
- }
- else
- {
- RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
- MACValue = ((MACValue & 0xE0FFFFFF) | 0x01000000);
- RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
- }
-}
-// end johnli
-#endif // RT30xx //
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSwitchChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel,
- IN BOOLEAN bScan)
-{
- ULONG R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0;
- CHAR TxPwer = 0, TxPwer2 = DEFAULT_RF_TX_POWER; //Bbp94 = BBPR94_DEFAULT, TxPwer2 = DEFAULT_RF_TX_POWER;
- UCHAR index;
- UINT32 Value = 0; //BbpReg, Value;
- RTMP_RF_REGS *RFRegTable;
-
- // Search Tx power value
-#if 1
- // We can't use ChannelList to search channel, since some central channl's txpowr doesn't list
- // in ChannelList, so use TxPower array instead.
- //
- for (index = 0; index < MAX_NUM_OF_CHANNELS; index++)
- {
- if (Channel == pAd->TxPower[index].Channel)
- {
- TxPwer = pAd->TxPower[index].Power;
- TxPwer2 = pAd->TxPower[index].Power2;
- break;
- }
- }
-#else
- for (index = 0; index < pAd->ChannelListNum; index++)
- {
- if (Channel == pAd->ChannelList[index].Channel)
- {
- TxPwer = pAd->ChannelList[index].Power;
- TxPwer2 = pAd->ChannelList[index].Power2;
- break;
- }
- }
-#endif
-
- if (index == MAX_NUM_OF_CHANNELS)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Can't find the Channel#%d \n", Channel));
- }
-
-#ifdef RT30xx
- // The RF programming sequence is difference between 3xxx and 2xxx
- if ((IS_RT3070(pAd) || IS_RT3090(pAd)) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020) ||
- (pAd->RfIcType == RFIC_3021) || (pAd->RfIcType == RFIC_3022)))
- {
- /* modify by WY for Read RF Reg. error */
- UCHAR RFValue;
-
- for (index = 0; index < NUM_OF_3020_CHNL; index++)
- {
- if (Channel == FreqItems3020[index].Channel)
- {
- // Programming channel parameters
- RT30xxWriteRFRegister(pAd, RF_R02, FreqItems3020[index].N);
- RT30xxWriteRFRegister(pAd, RF_R03, FreqItems3020[index].K);
- RT30xxReadRFRegister(pAd, RF_R06, &RFValue);
- RFValue = (RFValue & 0xFC) | FreqItems3020[index].R;
- RT30xxWriteRFRegister(pAd, RF_R06, RFValue);
-
- // Set Tx0 Power
- RT30xxReadRFRegister(pAd, RF_R12, &RFValue);
- RFValue = (RFValue & 0xE0) | TxPwer;
- RT30xxWriteRFRegister(pAd, RF_R12, RFValue);
-
- // Set Tx1 Power
- RT30xxReadRFRegister(pAd, RF_R13, &RFValue);
- RFValue = (RFValue & 0xE0) | TxPwer2;
- RT30xxWriteRFRegister(pAd, RF_R13, RFValue);
-
- // Tx/Rx Stream setting
- RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
- //if (IS_RT3090(pAd))
- // RFValue |= 0x01; // Enable RF block.
- RFValue &= 0x03; //clear bit[7~2]
- if (pAd->Antenna.field.TxPath == 1)
- RFValue |= 0xA0;
- else if (pAd->Antenna.field.TxPath == 2)
- RFValue |= 0x80;
- if (pAd->Antenna.field.RxPath == 1)
- RFValue |= 0x50;
- else if (pAd->Antenna.field.RxPath == 2)
- RFValue |= 0x40;
- RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
- // Set RF offset
- RT30xxReadRFRegister(pAd, RF_R23, &RFValue);
- RFValue = (RFValue & 0x80) | pAd->RfFreqOffset;
- RT30xxWriteRFRegister(pAd, RF_R23, RFValue);
-
- // Set BW
- if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40))
- {
- RFValue = pAd->Mlme.CaliBW40RfR24;
- //DISABLE_11N_CHECK(pAd);
- }
- else
- {
- RFValue = pAd->Mlme.CaliBW20RfR24;
- }
- RT30xxWriteRFRegister(pAd, RF_R24, RFValue);
- RT30xxWriteRFRegister(pAd, RF_R31, RFValue);
-
- // Enable RF tuning
- RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
- RFValue = RFValue | 0x1;
- RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
-
- // latch channel for future usage.
- pAd->LatchRfRegs.Channel = Channel;
-
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
- Channel,
- pAd->RfIcType,
- TxPwer,
- TxPwer2,
- pAd->Antenna.field.TxPath,
- FreqItems3020[index].N,
- FreqItems3020[index].K,
- FreqItems3020[index].R));
-
- break;
- }
- }
- }
- else
-#endif // RT30xx //
-
- {
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- R2 |= 0x40; // write 1 to off Rxpath.
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
-
- if (Channel > 14)
- {
- // initialize R3, R4
- R3 = (RFRegTable[index].R3 & 0xffffc1ff);
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15);
-
- // 5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB
- // R3
- if ((TxPwer >= -7) && (TxPwer < 0))
- {
- TxPwer = (7+TxPwer);
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10);
- DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: TxPwer=%d \n", TxPwer));
- }
- else
- {
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10) | (1 << 9);
- }
-
- // R4
- if ((TxPwer2 >= -7) && (TxPwer2 < 0))
- {
- TxPwer2 = (7+TxPwer2);
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7);
- DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: TxPwer2=%d \n", TxPwer2));
- }
- else
- {
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7) | (1 << 6);
- }
- }
- else
- {
- R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); // set TX power0
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15) | (TxPwer2 <<6);// Set freq Offset & TxPwr1
- }
-
- // Based on BBP current mode before changing RF channel.
- if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40))
- {
- R4 |=0x200000;
- }
-
- // Update variables
- pAd->LatchRfRegs.Channel = Channel;
- pAd->LatchRfRegs.R1 = RFRegTable[index].R1;
- pAd->LatchRfRegs.R2 = R2;
- pAd->LatchRfRegs.R3 = R3;
- pAd->LatchRfRegs.R4 = R4;
-
- // Set RF value 1's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 2's set R3[bit2] = [1]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 | 0x04));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 3's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
- }
-
- // Change BBP setting during siwtch from a->g, g->a
- if (Channel <= 14)
- {
- ULONG TxPinCfg = 0x00050F0A;//Gary 2007/08/09 0x050A0A
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd))); // According the Rory's suggestion to solve the middle range issue.
- //RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
-
- // Rx High power VGA offset for LNA select
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);
- }
-
- // 5G band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x04);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
- else
- {
- ULONG TxPinCfg = 0x00050F05;//Gary 2007/8/9 0x050505
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd))); // According the Rory's suggestion to solve the middle range issue.
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
-
- // Rx High power VGA offset for LNA select
- if (pAd->NicConfig2.field.ExternalLNAForA)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);
- }
-
- // 5G band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x02);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
-
- // R66 should be set according to Channel and use 20MHz when scanning
- //RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x2E + GET_LNA_GAIN(pAd)));
- if (bScan)
- RTMPSetAGCInitValue(pAd, BW_20);
- else
- RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
-
- //
- // On 11A, We should delay and wait RF/BBP to be stable
- // and the appropriate time should be 1000 micro seconds
- // 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
- //
- RTMPusecDelay(1000);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%lu, Pwr1=%lu, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- (R3 & 0x00003e00) >> 9,
- (R4 & 0x000007c0) >> 6,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
-}
-
-/*
- ==========================================================================
- Description:
- This function is required for 2421 only, and should not be used during
- site survey. It's only required after NIC decided to stay at a channel
- for a longer period.
- When this function is called, it's always after AsicSwitchChannel().
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicLockChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicAntennaSelect(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
- if (pAd->Mlme.OneSecPeriodicRound % 2 == 1)
- {
- // patch for AsicSetRxAnt failed
- pAd->RxAnt.EvaluatePeriod = 0;
-
- // check every 2 second. If rcv-beacon less than 5 in the past 2 second, then AvgRSSI is no longer a
- // valid indication of the distance between this AP and its clients.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- SHORT realavgrssi1;
-
- // if no traffic then reset average rssi to trigger evaluation
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->StaCfg.NumOfAvgRssiSample < 5)
- {
- pAd->RxAnt.Pair1LastAvgRssi = (-99);
- pAd->RxAnt.Pair2LastAvgRssi = (-99);
- DBGPRINT(RT_DEBUG_TRACE, ("MlmePeriodicExec: no traffic/beacon, reset RSSI\n"));
- }
-
- pAd->StaCfg.NumOfAvgRssiSample = 0;
-#endif // CONFIG_STA_SUPPORT //
- realavgrssi1 = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt] >> 3);
-
- DBGPRINT(RT_DEBUG_TRACE,("Ant-realrssi0(%d), Lastrssi0(%d), EvaluateStableCnt=%d\n", realavgrssi1, pAd->RxAnt.Pair1LastAvgRssi, pAd->RxAnt.EvaluateStableCnt));
-
- // if the difference between two rssi is larger or less than 5, then evaluate the other antenna
- if ((pAd->RxAnt.EvaluateStableCnt < 2) || (realavgrssi1 > (pAd->RxAnt.Pair1LastAvgRssi + 5)) || (realavgrssi1 < (pAd->RxAnt.Pair1LastAvgRssi - 5)))
- {
- pAd->RxAnt.Pair1LastAvgRssi = realavgrssi1;
- AsicEvaluateRxAnt(pAd);
- }
- }
- else
- {
- // if not connected, always switch antenna to try to connect
- UCHAR temp;
-
- temp = pAd->RxAnt.Pair1PrimaryRxAnt;
- pAd->RxAnt.Pair1PrimaryRxAnt = pAd->RxAnt.Pair1SecondaryRxAnt;
- pAd->RxAnt.Pair1SecondaryRxAnt = temp;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MlmePeriodicExec: no connect, switch to another one to try connection\n"));
-
- AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
- }
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Antenna miscellaneous setting.
-
- Arguments:
- pAd Pointer to our adapter
- BandState Indicate current Band State.
-
- Return Value:
- None
-
- IRQL <= DISPATCH_LEVEL
-
- Note:
- 1.) Frame End type control
- only valid for G only (RF_2527 & RF_2529)
- 0: means DPDT, set BBP R4 bit 5 to 1
- 1: means SPDT, set BBP R4 bit 5 to 0
-
-
- ========================================================================
-*/
-VOID AsicAntennaSetting(
- IN PRTMP_ADAPTER pAd,
- IN ABGBAND_STATE BandState)
-{
-}
-
-VOID AsicRfTuningExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
-}
-
-/*
- ==========================================================================
- Description:
- Gives CCK TX rate 2 more dB TX power.
- This routine works only in LINK UP in INFRASTRUCTURE mode.
-
- calculate desired Tx power in RF R3.Tx0~5, should consider -
- 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
- 1. TxPowerPercentage
- 2. auto calibration based on TSSI feedback
- 3. extra 2 db for CCK
- 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
-
- NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
- it should be called AFTER MlmeDynamicTxRatSwitching()
- ==========================================================================
- */
-VOID AsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd)
-{
- INT i, j;
- CHAR DeltaPwr = 0;
- BOOLEAN bAutoTxAgc = FALSE;
- UCHAR TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;
- UCHAR BbpR1 = 0, BbpR49 = 0, idx;
- PCHAR pTxAgcCompensate;
- ULONG TxPwr[5];
- CHAR Value;
-
-
-
- if (pAd->CommonCfg.BBPCurrentBW == BW_40)
- {
- if (pAd->CommonCfg.CentralChannel > 14)
- {
- TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
- }
- }
- else
- {
- if (pAd->CommonCfg.Channel > 14)
- {
- TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
- }
- }
-
- // TX power compensation for temperature variation based on TSSI. try every 4 second
- if (pAd->Mlme.OneSecPeriodicRound % 4 == 0)
- {
- if (pAd->CommonCfg.Channel <= 14)
- {
- /* bg channel */
- bAutoTxAgc = pAd->bAutoTxAgcG;
- TssiRef = pAd->TssiRefG;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryG[0];
- TxAgcStep = pAd->TxAgcStepG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- /* a channel */
- bAutoTxAgc = pAd->bAutoTxAgcA;
- TssiRef = pAd->TssiRefA;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryA[0];
- TxAgcStep = pAd->TxAgcStepA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- {
- /* BbpR1 is unsigned char */
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);
-
- /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
- /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
- /* step value is defined in pAd->TxAgcStepG for tx power value */
-
- /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
- /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- above value are examined in mass factory production */
- /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
-
- /* plus (+) is 0x00 ~ 0x45, minus (-) is 0xa0 ~ 0xf0 */
- /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
- /* if value is 0xa5, tx power will be -= TxAgcStep*(2-1) */
-
- if (BbpR49 > pTssiMinusBoundary[1])
- {
- // Reading is larger than the reference value
- // check for how large we need to decrease the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 <= pTssiMinusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should decrease, idx = 0 means there is nothing to compensate
-// if (R3 > (ULONG) (TxAgcStep * (idx-1)))
- *pTxAgcCompensate = -(TxAgcStep * (idx-1));
-// else
-// *pTxAgcCompensate = -((UCHAR)R3);
-
- DeltaPwr += (*pTxAgcCompensate);
- DBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else if (BbpR49 < pTssiPlusBoundary[1])
- {
- // Reading is smaller than the reference value
- // check for how large we need to increase the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 >= pTssiPlusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should increase, idx = 0 means there is nothing to compensate
- *pTxAgcCompensate = TxAgcStep * (idx-1);
- DeltaPwr += (*pTxAgcCompensate);
- DBGPRINT(RT_DEBUG_TRACE, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else
- {
- *pTxAgcCompensate = 0;
- DBGPRINT(RT_DEBUG_TRACE, (" Tx Power, BBP R49=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, 0));
- }
- }
- }
- else
- {
- if (pAd->CommonCfg.Channel <= 14)
- {
- bAutoTxAgc = pAd->bAutoTxAgcG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- bAutoTxAgc = pAd->bAutoTxAgcA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- DeltaPwr += (*pTxAgcCompensate);
- }
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpR1);
- BbpR1 &= 0xFC;
-
-#ifdef SINGLE_SKU
- // Handle regulatory max tx power constrain
- do
- {
- UCHAR TxPwrInEEPROM = 0xFF, CountryTxPwr = 0xFF, criterion;
- UCHAR AdjustMaxTxPwr[40];
-
- if (pAd->CommonCfg.Channel > 14) // 5G band
- TxPwrInEEPROM = ((pAd->CommonCfg.DefineMaxTxPwr & 0xFF00) >> 8);
- else // 2.4G band
- TxPwrInEEPROM = (pAd->CommonCfg.DefineMaxTxPwr & 0x00FF);
- CountryTxPwr = GetCuntryMaxTxPwr(pAd, pAd->CommonCfg.Channel);
-
- // error handling, range check
- if ((TxPwrInEEPROM > 0x50) || (CountryTxPwr > 0x50))
- {
- DBGPRINT(RT_DEBUG_ERROR,("AsicAdjustTxPower - Invalid max tx power (=0x%02x), CountryTxPwr=%d\n", TxPwrInEEPROM, CountryTxPwr));
- break;
- }
-
- criterion = *((PUCHAR)TxPwr + 2) & 0xF; // FAE use OFDM 6M as criterion
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (criterion=%d, TxPwrInEEPROM=%d, CountryTxPwr=%d)\n", criterion, TxPwrInEEPROM, CountryTxPwr));
-
- // Adjust max tx power according to the relationship of tx power in E2PROM
- for (i=0; i<5; i++)
- {
- // CCK will have 4dBm larger than OFDM
- // Therefore, we should separate to parse the tx power field
- if (i == 0)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- if (j < 4)
- {
- // CCK will have 4dBm larger than OFDM
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion) + 4;
- }
- else
- {
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- }
- else
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- }
- }
-
- // Adjust tx power according to the relationship
- for (i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
-
- // The system tx power is larger than the regulatory, the power should be restrain
- if (AdjustMaxTxPwr[i*8+j] > CountryTxPwr)
- {
- // decrease to zero and don't need to take care BBPR1
- if ((Value - (AdjustMaxTxPwr[i*8+j] - CountryTxPwr)) > 0)
- Value -= (AdjustMaxTxPwr[i*8+j] - CountryTxPwr);
- else
- Value = 0;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- }
- else
- DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d, no change)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
-
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
- }
- }
- } while (FALSE);
-#endif // SINGLE_SKU //
-
- /* calculate delta power based on the percentage specified from UI */
- // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
- // We lower TX power here according to the percentage specified from UI
- if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff) // AUTO TX POWER control
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW // DeltaPwr -= 1;
- {
- DeltaPwr -= 1;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW // DeltaPwr -= 3;
- {
- DeltaPwr -= 3;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW // DeltaPwr -= 6;
- {
- BbpR1 |= 0x01;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW // DeltaPwr -= 9;
- {
- BbpR1 |= 0x01;
- DeltaPwr -= 3;
- }
- else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW // DeltaPwr -= 12;
- {
- BbpR1 |= 0x02;
- }
-
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpR1);
-
- /* reset different new tx power for different TX rate */
- for(i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F); /* 0 ~ 15 */
-
- if ((Value + DeltaPwr) < 0)
- {
- Value = 0; /* min */
- }
- else if ((Value + DeltaPwr) > 0xF)
- {
- Value = 0xF; /* max */
- }
- else
- {
- Value += DeltaPwr; /* temperature compensation */
- }
-
- /* fill new value to CSR offset */
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
-
- /* write tx power value to CSR */
- /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
- TX power for OFDM 6M/9M
- TX power for CCK5.5M/11M
- TX power for CCK1M/2M */
- /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);
- }
- }
-
-
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ==========================================================================
- Description:
- put PHY to sleep here, and set next wakeup timer. PHY doesn't not wakeup
- automatically. Instead, MCU will issue a TwakeUpInterrupt to host after
- the wakeup timer timeout. Driver has to issue a separate command to wake
- PHY up.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp)
-{
- RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp);
-}
-
-/*
- ==========================================================================
- Description:
- AsicForceWakeup() is used whenever manual wakeup is required
- AsicForceSleep() should only be used when not in INFRA BSS. When
- in INFRA BSS, we should use AsicSleepThenAutoWakeup() instead.
- ==========================================================================
- */
-VOID AsicForceSleep(
- IN PRTMP_ADAPTER pAd)
-{
-
-}
-
-/*
- ==========================================================================
- Description:
- AsicForceWakeup() is used whenever Twakeup timer (set via AsicSleepThenAutoWakeup)
- expired.
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
- ==========================================================================
- */
-VOID AsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("--> AsicForceWakeup \n"));
- RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx);
-}
-#endif // CONFIG_STA_SUPPORT //
-/*
- ==========================================================================
- Description:
- Set My BSSID
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSetBssid(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid)
-{
- ULONG Addr4;
- DBGPRINT(RT_DEBUG_TRACE, ("==============> AsicSetBssid %x:%x:%x:%x:%x:%x\n",
- pBssid[0],pBssid[1],pBssid[2],pBssid[3], pBssid[4],pBssid[5]));
-
- Addr4 = (ULONG)(pBssid[0]) |
- (ULONG)(pBssid[1] << 8) |
- (ULONG)(pBssid[2] << 16) |
- (ULONG)(pBssid[3] << 24);
- RTMP_IO_WRITE32(pAd, MAC_BSSID_DW0, Addr4);
-
- Addr4 = 0;
- // always one BSSID in STA mode
- Addr4 = (ULONG)(pBssid[4]) | (ULONG)(pBssid[5] << 8);
-
- RTMP_IO_WRITE32(pAd, MAC_BSSID_DW1, Addr4);
-}
-
-VOID AsicSetMcastWC(
- IN PRTMP_ADAPTER pAd)
-{
- MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[MCAST_WCID];
- USHORT offset;
-
- pEntry->Sst = SST_ASSOC;
- pEntry->Aid = MCAST_WCID; // Softap supports 1 BSSID and use WCID=0 as multicast Wcid index
- pEntry->PsMode = PWR_ACTIVE;
- pEntry->CurrTxRate = pAd->CommonCfg.MlmeRate;
- offset = MAC_WCID_BASE + BSS0Mcast_WCID * HW_WCID_ENTRY_SIZE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicDelWcidTab(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid)
-{
- ULONG Addr0 = 0x0, Addr1 = 0x0;
- ULONG offset;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicDelWcidTab==>Wcid = 0x%x\n",Wcid));
- offset = MAC_WCID_BASE + Wcid * HW_WCID_ENTRY_SIZE;
- RTMP_IO_WRITE32(pAd, offset, Addr0);
- offset += 4;
- RTMP_IO_WRITE32(pAd, offset, Addr1);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicEnableRDG(
- IN PRTMP_ADAPTER pAd)
-{
- TX_LINK_CFG_STRUC TxLinkCfg;
- UINT32 Data = 0;
-
- RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
- TxLinkCfg.field.TxRDGEn = 1;
- RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- Data |= 0x80;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- //OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicDisableRDG(
- IN PRTMP_ADAPTER pAd)
-{
- TX_LINK_CFG_STRUC TxLinkCfg;
- UINT32 Data = 0;
-
-
- RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
- TxLinkCfg.field.TxRDGEn = 0;
- RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-
- Data &= 0xFFFFFF00;
- //Data |= 0x20;
-#ifndef WIFI_TEST
- //if ( pAd->CommonCfg.bEnableTxBurst )
- // Data |= 0x60; // for performance issue not set the TXOP to 0
-#endif
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE)
-#ifdef DOT11_N_SUPPORT
- && (pAd->MacTab.fAnyStationMIMOPSDynamic == FALSE)
-#endif // DOT11_N_SUPPORT //
- )
- {
- // For CWC test, change txop from 0x30 to 0x20 in TxBurst mode
- if (pAd->CommonCfg.bEnableTxBurst)
- Data |= 0x20;
- }
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicDisableSync(
- IN PRTMP_ADAPTER pAd)
-{
- BCN_TIME_CFG_STRUC csr;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->Disable TSF synchronization\n"));
-
- // 2003-12-20 disable TSF and TBTT while NIC in power-saving have side effect
- // that NIC will never wakes up because TSF stops and no more
- // TBTT interrupts
- pAd->TbttTickCount = 0;
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
- csr.field.bBeaconGen = 0;
- csr.field.bTBTTEnable = 0;
- csr.field.TsfSyncMode = 0;
- csr.field.bTsfTicking = 0;
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicEnableBssSync(
- IN PRTMP_ADAPTER pAd)
-{
- BCN_TIME_CFG_STRUC csr;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableBssSync(INFRA mode)\n"));
-
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-// RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, 0x00000000);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- csr.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
- csr.field.bTsfTicking = 1;
- csr.field.TsfSyncMode = 1; // sync TSF in INFRASTRUCTURE mode
- csr.field.bBeaconGen = 0; // do NOT generate BEACON
- csr.field.bTBTTEnable = 1;
- }
-#endif // CONFIG_STA_SUPPORT //
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-}
-
-/*
- ==========================================================================
- Description:
- Note:
- BEACON frame in shared memory should be built ok before this routine
- can be called. Otherwise, a garbage frame maybe transmitted out every
- Beacon period.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicEnableIbssSync(
- IN PRTMP_ADAPTER pAd)
-{
- BCN_TIME_CFG_STRUC csr9;
- PUCHAR ptr;
- UINT i;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableIbssSync(ADHOC mode. MPDUtotalByteCount = %d)\n", pAd->BeaconTxWI.MPDUtotalByteCount));
-
- RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr9.word);
- csr9.field.bBeaconGen = 0;
- csr9.field.bTBTTEnable = 0;
- csr9.field.bTsfTicking = 0;
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
-
-
-#ifdef RT2870
- // move BEACON TXD and frame content to on-chip memory
- ptr = (PUCHAR)&pAd->BeaconTxWI;
- for (i=0; i<TXWI_SIZE; i+=2) // 16-byte TXWI field
- {
- //UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
- //RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + i, longptr);
- RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + i, ptr, 2);
- ptr += 2;
- }
-
- // start right after the 16-byte TXWI field
- ptr = pAd->BeaconBuf;
- for (i=0; i< pAd->BeaconTxWI.MPDUtotalByteCount; i+=2)
- {
- //UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
- //RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr);
- RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, ptr, 2);
- ptr +=2;
- }
-#endif // RT2870 //
-
- //
- // For Wi-Fi faily generated beacons between participating stations.
- // Set TBTT phase adaptive adjustment step to 8us (default 16us)
- // don't change settings 2006-5- by Jerry
- //RTMP_IO_WRITE32(pAd, TBTT_SYNC_CFG, 0x00001010);
-
- // start sending BEACON
- csr9.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
- csr9.field.bTsfTicking = 1;
- csr9.field.TsfSyncMode = 2; // sync TSF in IBSS mode
- csr9.field.bTBTTEnable = 1;
- csr9.field.bBeaconGen = 1;
- RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSetEdcaParm(
- IN PRTMP_ADAPTER pAd,
- IN PEDCA_PARM pEdcaParm)
-{
- EDCA_AC_CFG_STRUC Ac0Cfg, Ac1Cfg, Ac2Cfg, Ac3Cfg;
- AC_TXOP_CSR0_STRUC csr0;
- AC_TXOP_CSR1_STRUC csr1;
- AIFSN_CSR_STRUC AifsnCsr;
- CWMIN_CSR_STRUC CwminCsr;
- CWMAX_CSR_STRUC CwmaxCsr;
- int i;
-
- Ac0Cfg.word = 0;
- Ac1Cfg.word = 0;
- Ac2Cfg.word = 0;
- Ac3Cfg.word = 0;
- if ((pEdcaParm == NULL) || (pEdcaParm->bValid == FALSE))
- {
- DBGPRINT(RT_DEBUG_TRACE,("AsicSetEdcaParm\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WMM_INUSED);
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI || pAd->MacTab.Content[i].ValidAsApCli)
- CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.Content[i], fCLIENT_STATUS_WMM_CAPABLE);
- }
-
- //========================================================
- // MAC Register has a copy .
- //========================================================
-//#ifndef WIFI_TEST
- if( pAd->CommonCfg.bEnableTxBurst )
- {
- // For CWC test, change txop from 0x30 to 0x20 in TxBurst mode
- Ac0Cfg.field.AcTxop = 0x20; // Suggest by John for TxBurst in HT Mode
- }
- else
- Ac0Cfg.field.AcTxop = 0; // QID_AC_BE
-//#else
-// Ac0Cfg.field.AcTxop = 0; // QID_AC_BE
-//#endif
- Ac0Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac0Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac0Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Ac0Cfg.word);
-
- Ac1Cfg.field.AcTxop = 0; // QID_AC_BK
- Ac1Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac1Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac1Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word);
-
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- {
- Ac2Cfg.field.AcTxop = 192; // AC_VI: 192*32us ~= 6ms
- Ac3Cfg.field.AcTxop = 96; // AC_VO: 96*32us ~= 3ms
- }
- else
- {
- Ac2Cfg.field.AcTxop = 96; // AC_VI: 96*32us ~= 3ms
- Ac3Cfg.field.AcTxop = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- Ac2Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac2Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac2Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC2_CFG, Ac2Cfg.word);
- Ac3Cfg.field.Cwmin = CW_MIN_IN_BITS;
- Ac3Cfg.field.Cwmax = CW_MAX_IN_BITS;
- Ac3Cfg.field.Aifsn = 2;
- RTMP_IO_WRITE32(pAd, EDCA_AC3_CFG, Ac3Cfg.word);
-
- //========================================================
- // DMA Register has a copy too.
- //========================================================
- csr0.field.Ac0Txop = 0; // QID_AC_BE
- csr0.field.Ac1Txop = 0; // QID_AC_BK
- RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- {
- csr1.field.Ac2Txop = 192; // AC_VI: 192*32us ~= 6ms
- csr1.field.Ac3Txop = 96; // AC_VO: 96*32us ~= 3ms
- }
- else
- {
- csr1.field.Ac2Txop = 96; // AC_VI: 96*32us ~= 3ms
- csr1.field.Ac3Txop = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr1.word);
-
- CwminCsr.word = 0;
- CwminCsr.field.Cwmin0 = CW_MIN_IN_BITS;
- CwminCsr.field.Cwmin1 = CW_MIN_IN_BITS;
- CwminCsr.field.Cwmin2 = CW_MIN_IN_BITS;
- CwminCsr.field.Cwmin3 = CW_MIN_IN_BITS;
- RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
-
- CwmaxCsr.word = 0;
- CwmaxCsr.field.Cwmax0 = CW_MAX_IN_BITS;
- CwmaxCsr.field.Cwmax1 = CW_MAX_IN_BITS;
- CwmaxCsr.field.Cwmax2 = CW_MAX_IN_BITS;
- CwmaxCsr.field.Cwmax3 = CW_MAX_IN_BITS;
- RTMP_IO_WRITE32(pAd, WMM_CWMAX_CFG, CwmaxCsr.word);
-
- RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, 0x00002222);
-
- NdisZeroMemory(&pAd->CommonCfg.APEdcaParm, sizeof(EDCA_PARM));
- }
- else
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WMM_INUSED);
- //========================================================
- // MAC Register has a copy.
- //========================================================
- //
- // Modify Cwmin/Cwmax/Txop on queue[QID_AC_VI], Recommend by Jerry 2005/07/27
- // To degrade our VIDO Queue's throughput for WiFi WMM S3T07 Issue.
- //
- //pEdcaParm->Txop[QID_AC_VI] = pEdcaParm->Txop[QID_AC_VI] * 7 / 10; // rt2860c need this
-
- Ac0Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BE];
- Ac0Cfg.field.Cwmin= pEdcaParm->Cwmin[QID_AC_BE];
- Ac0Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BE];
- Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE]; //+1;
-
- Ac1Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BK];
- Ac1Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_BK]; //+2;
- Ac1Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BK];
- Ac1Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BK]; //+1;
-
- Ac2Cfg.field.AcTxop = (pEdcaParm->Txop[QID_AC_VI] * 6) / 10;
- Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI];
- Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI];
- Ac2Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VI];
-#ifdef INF_AMAZON_SE
-#endif // INF_AMAZON_SE //
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Tuning for Wi-Fi WMM S06
- if (pAd->CommonCfg.bWiFiTest &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- Ac2Cfg.field.Aifsn -= 1;
-
- // Tuning for TGn Wi-Fi 5.2.32
- // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
- if (STA_TGN_WIFI_ON(pAd) &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- {
- Ac0Cfg.field.Aifsn = 3;
- Ac2Cfg.field.AcTxop = 5;
- }
-
-#ifdef RT30xx
- if (pAd->RfIcType == RFIC_3020 || pAd->RfIcType == RFIC_2020)
- {
- // Tuning for WiFi WMM S3-T07: connexant legacy sta ==> broadcom 11n sta.
- Ac2Cfg.field.Aifsn = 5;
- }
-#endif // RT30xx //
- }
-#endif // CONFIG_STA_SUPPORT //
-
- Ac3Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VO];
- Ac3Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VO];
- Ac3Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VO];
- Ac3Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VO];
-
-//#ifdef WIFI_TEST
- if (pAd->CommonCfg.bWiFiTest)
- {
- if (Ac3Cfg.field.AcTxop == 102)
- {
- Ac0Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BE] ? pEdcaParm->Txop[QID_AC_BE] : 10;
- Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE]-1; /* AIFSN must >= 1 */
- Ac1Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BK];
- Ac1Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BK];
- Ac2Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VI];
- } /* End of if */
- }
-//#endif // WIFI_TEST //
-
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Ac0Cfg.word);
- RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word);
- RTMP_IO_WRITE32(pAd, EDCA_AC2_CFG, Ac2Cfg.word);
- RTMP_IO_WRITE32(pAd, EDCA_AC3_CFG, Ac3Cfg.word);
-
-
- //========================================================
- // DMA Register has a copy too.
- //========================================================
- csr0.field.Ac0Txop = Ac0Cfg.field.AcTxop;
- csr0.field.Ac1Txop = Ac1Cfg.field.AcTxop;
- RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
-
- csr1.field.Ac2Txop = Ac2Cfg.field.AcTxop;
- csr1.field.Ac3Txop = Ac3Cfg.field.AcTxop;
- RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr1.word);
-
- CwminCsr.word = 0;
- CwminCsr.field.Cwmin0 = pEdcaParm->Cwmin[QID_AC_BE];
- CwminCsr.field.Cwmin1 = pEdcaParm->Cwmin[QID_AC_BK];
- CwminCsr.field.Cwmin2 = pEdcaParm->Cwmin[QID_AC_VI];
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- CwminCsr.field.Cwmin3 = pEdcaParm->Cwmin[QID_AC_VO] - 1; //for TGn wifi test
-#endif // CONFIG_STA_SUPPORT //
- RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
-
- CwmaxCsr.word = 0;
- CwmaxCsr.field.Cwmax0 = pEdcaParm->Cwmax[QID_AC_BE];
- CwmaxCsr.field.Cwmax1 = pEdcaParm->Cwmax[QID_AC_BK];
- CwmaxCsr.field.Cwmax2 = pEdcaParm->Cwmax[QID_AC_VI];
- CwmaxCsr.field.Cwmax3 = pEdcaParm->Cwmax[QID_AC_VO];
- RTMP_IO_WRITE32(pAd, WMM_CWMAX_CFG, CwmaxCsr.word);
-
- AifsnCsr.word = 0;
- AifsnCsr.field.Aifsn0 = Ac0Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_BE];
- AifsnCsr.field.Aifsn1 = Ac1Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_BK];
- AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn; //pEdcaParm->Aifsn[QID_AC_VI];
-#ifdef INF_AMAZON_SE
-#endif // INF_AMAZON_SE //
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Tuning for Wi-Fi WMM S06
- if (pAd->CommonCfg.bWiFiTest &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn - 4;
-
- // Tuning for TGn Wi-Fi 5.2.32
- // STA TestBed changes in this item: connexant legacy sta ==> broadcom 11n sta
- if (STA_TGN_WIFI_ON(pAd) &&
- pEdcaParm->Aifsn[QID_AC_VI] == 10)
- {
- AifsnCsr.field.Aifsn0 = 3;
- AifsnCsr.field.Aifsn2 = 7;
- }
-
- if (INFRA_ON(pAd))
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_WMM_CAPABLE);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AifsnCsr.field.Aifsn3 = Ac3Cfg.field.Aifsn - 1; //pEdcaParm->Aifsn[QID_AC_VO]; //for TGn wifi test
-#ifdef RT30xx
- if (pAd->RfIcType == RFIC_3020 || pAd->RfIcType == RFIC_2020)
- {
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- AifsnCsr.field.Aifsn2 = 0x2; //pEdcaParm->Aifsn[QID_AC_VI]; //for WiFi WMM S4-T04.
- }
-#endif // RT30xx //
-#endif // CONFIG_STA_SUPPORT //
- RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, AifsnCsr.word);
-
- NdisMoveMemory(&pAd->CommonCfg.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
- if (!ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE,("EDCA [#%d]: AIFSN CWmin CWmax TXOP(us) ACM\n", pEdcaParm->EdcaUpdateCount));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_BE %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[0],
- pEdcaParm->Cwmin[0],
- pEdcaParm->Cwmax[0],
- pEdcaParm->Txop[0]<<5,
- pEdcaParm->bACM[0]));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_BK %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[1],
- pEdcaParm->Cwmin[1],
- pEdcaParm->Cwmax[1],
- pEdcaParm->Txop[1]<<5,
- pEdcaParm->bACM[1]));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_VI %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[2],
- pEdcaParm->Cwmin[2],
- pEdcaParm->Cwmax[2],
- pEdcaParm->Txop[2]<<5,
- pEdcaParm->bACM[2]));
- DBGPRINT(RT_DEBUG_TRACE,(" AC_VO %2d %2d %2d %4d %d\n",
- pEdcaParm->Aifsn[3],
- pEdcaParm->Cwmin[3],
- pEdcaParm->Cwmax[3],
- pEdcaParm->Txop[3]<<5,
- pEdcaParm->bACM[3]));
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicSetSlotTime(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUseShortSlotTime)
-{
- ULONG SlotTime;
- UINT32 RegValue = 0;
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->CommonCfg.Channel > 14)
- bUseShortSlotTime = TRUE;
-#endif // CONFIG_STA_SUPPORT //
-
- if (bUseShortSlotTime)
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
- else
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
-
- SlotTime = (bUseShortSlotTime)? 9 : 20;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // force using short SLOT time for FAE to demo performance when TxBurst is ON
- if (pAd->CommonCfg.bEnableTxBurst)
- SlotTime = 9;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- //
- // For some reasons, always set it to short slot time.
- //
- // ToDo: Should consider capability with 11B
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.BssType == BSS_ADHOC)
- SlotTime = 20;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_IO_READ32(pAd, BKOFF_SLOT_CFG, &RegValue);
- RegValue = RegValue & 0xFFFFFF00;
-
- RegValue |= SlotTime;
-
- RTMP_IO_WRITE32(pAd, BKOFF_SLOT_CFG, RegValue);
-}
-
-/*
- ========================================================================
- Description:
- Add Shared key information into ASIC.
- Update shared key, TxMic and RxMic to Asic Shared key table
- Update its cipherAlg to Asic Shared key Mode.
-
- Return:
- ========================================================================
-*/
-VOID AsicAddSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN PUCHAR pKey,
- IN PUCHAR pTxMic,
- IN PUCHAR pRxMic)
-{
- ULONG offset; //, csr0;
- SHAREDKEY_MODE_STRUC csr1;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicAddSharedKeyEntry BssIndex=%d, KeyIdx=%d\n", BssIndex,KeyIdx));
-//============================================================================================
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicAddSharedKeyEntry: %s key #%d\n", CipherName[CipherAlg], BssIndex*4 + KeyIdx));
- DBGPRINT_RAW(RT_DEBUG_TRACE, (" Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pKey[0],pKey[1],pKey[2],pKey[3],pKey[4],pKey[5],pKey[6],pKey[7],pKey[8],pKey[9],pKey[10],pKey[11],pKey[12],pKey[13],pKey[14],pKey[15]));
- if (pRxMic)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, (" Rx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pRxMic[0],pRxMic[1],pRxMic[2],pRxMic[3],pRxMic[4],pRxMic[5],pRxMic[6],pRxMic[7]));
- }
- if (pTxMic)
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, (" Tx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pTxMic[0],pTxMic[1],pTxMic[2],pTxMic[3],pTxMic[4],pTxMic[5],pTxMic[6],pTxMic[7]));
- }
-//============================================================================================
- //
- // fill key material - key + TX MIC + RX MIC
- //
-
-#ifdef RT2870
-{
- offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE;
- RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_SHARE_KEY);
-
- offset += MAX_LEN_OF_SHARE_KEY;
- if (pTxMic)
- {
- RTUSBMultiWrite(pAd, offset, pTxMic, 8);
- }
-
- offset += 8;
- if (pRxMic)
- {
- RTUSBMultiWrite(pAd, offset, pRxMic, 8);
- }
-}
-#endif // RT2870 //
-
- //
- // Update cipher algorithm. WSTA always use BSS0
- //
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), &csr1.word);
- DBGPRINT(RT_DEBUG_TRACE,("Read: SHARED_KEY_MODE_BASE at this Bss[%d] KeyIdx[%d]= 0x%x \n", BssIndex,KeyIdx, csr1.word));
- if ((BssIndex%2) == 0)
- {
- if (KeyIdx == 0)
- csr1.field.Bss0Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss0Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss0Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss0Key3CipherAlg = CipherAlg;
- }
- else
- {
- if (KeyIdx == 0)
- csr1.field.Bss1Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss1Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss1Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss1Key3CipherAlg = CipherAlg;
- }
- DBGPRINT(RT_DEBUG_TRACE,("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n", BssIndex, csr1.word));
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), csr1.word);
-
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID AsicRemoveSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx)
-{
- //ULONG SecCsr0;
- SHAREDKEY_MODE_STRUC csr1;
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicRemoveSharedKeyEntry: #%d \n", BssIndex*4 + KeyIdx));
-
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), &csr1.word);
- if ((BssIndex%2) == 0)
- {
- if (KeyIdx == 0)
- csr1.field.Bss0Key0CipherAlg = 0;
- else if (KeyIdx == 1)
- csr1.field.Bss0Key1CipherAlg = 0;
- else if (KeyIdx == 2)
- csr1.field.Bss0Key2CipherAlg = 0;
- else
- csr1.field.Bss0Key3CipherAlg = 0;
- }
- else
- {
- if (KeyIdx == 0)
- csr1.field.Bss1Key0CipherAlg = 0;
- else if (KeyIdx == 1)
- csr1.field.Bss1Key1CipherAlg = 0;
- else if (KeyIdx == 2)
- csr1.field.Bss1Key2CipherAlg = 0;
- else
- csr1.field.Bss1Key3CipherAlg = 0;
- }
- DBGPRINT(RT_DEBUG_TRACE,("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n", BssIndex, csr1.word));
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), csr1.word);
- ASSERT(BssIndex < 4);
- ASSERT(KeyIdx < 4);
-
-}
-
-
-VOID AsicUpdateWCIDAttribute(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR CipherAlg,
- IN BOOLEAN bUsePairewiseKeyTable)
-{
- ULONG WCIDAttri = 0, offset;
-
- //
- // Update WCID attribute.
- // Only TxKey could update WCID attribute.
- //
- offset = MAC_WCID_ATTRIBUTE_BASE + (WCID * HW_WCID_ATTRI_SIZE);
- WCIDAttri = (BssIndex << 4) | (CipherAlg << 1) | (bUsePairewiseKeyTable);
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-}
-
-VOID AsicUpdateWCIDIVEIV(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN ULONG uIV,
- IN ULONG uEIV)
-{
- ULONG offset;
-
- offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
-
- RTMP_IO_WRITE32(pAd, offset, uIV);
- RTMP_IO_WRITE32(pAd, offset + 4, uEIV);
-}
-
-VOID AsicUpdateRxWCIDTable(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN PUCHAR pAddr)
-{
- ULONG offset;
- ULONG Addr;
-
- offset = MAC_WCID_BASE + (WCID * HW_WCID_ENTRY_SIZE);
- Addr = pAddr[0] + (pAddr[1] << 8) +(pAddr[2] << 16) +(pAddr[3] << 24);
- RTMP_IO_WRITE32(pAd, offset, Addr);
- Addr = pAddr[4] + (pAddr[5] << 8);
- RTMP_IO_WRITE32(pAd, offset + 4, Addr);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Set Cipher Key, Cipher algorithm, IV/EIV to Asic
-
- Arguments:
- pAd Pointer to our adapter
- WCID WCID Entry number.
- BssIndex BSSID index, station or none multiple BSSID support
- this value should be 0.
- KeyIdx This KeyIdx will set to IV's KeyID if bTxKey enabled
- pCipherKey Pointer to Cipher Key.
- bUsePairewiseKeyTable TRUE means saved the key in SharedKey table,
- otherwise PairewiseKey table
- bTxKey This is the transmit key if enabled.
-
- Return Value:
- None
-
- Note:
- This routine will set the relative key stuff to Asic including WCID attribute,
- Cipher Key, Cipher algorithm and IV/EIV.
-
- IV/EIV will be update if this CipherKey is the transmission key because
- ASIC will base on IV's KeyID value to select Cipher Key.
-
- If bTxKey sets to FALSE, this is not the TX key, but it could be
- RX key
-
- For AP mode bTxKey must be always set to TRUE.
- ========================================================================
-*/
-VOID AsicAddKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN PCIPHER_KEY pCipherKey,
- IN BOOLEAN bUsePairewiseKeyTable,
- IN BOOLEAN bTxKey)
-{
- ULONG offset;
-// ULONG WCIDAttri = 0;
- UCHAR IV4 = 0;
- PUCHAR pKey = pCipherKey->Key;
-// ULONG KeyLen = pCipherKey->KeyLen;
- PUCHAR pTxMic = pCipherKey->TxMic;
- PUCHAR pRxMic = pCipherKey->RxMic;
- PUCHAR pTxtsc = pCipherKey->TxTsc;
- UCHAR CipherAlg = pCipherKey->CipherAlg;
- SHAREDKEY_MODE_STRUC csr1;
-
-// ASSERT(KeyLen <= MAX_LEN_OF_PEER_KEY);
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n"));
- //
- // 1.) decide key table offset
- //
- if (bUsePairewiseKeyTable)
- offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
- else
- offset = SHARED_KEY_TABLE_BASE + (4 * BssIndex + KeyIdx) * HW_KEY_ENTRY_SIZE;
-
- //
- // 2.) Set Key to Asic
- //
- //for (i = 0; i < KeyLen; i++)
-
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_PEER_KEY);
- offset += MAX_LEN_OF_PEER_KEY;
-
- //
- // 3.) Set MIC key if available
- //
- if (pTxMic)
- {
- RTUSBMultiWrite(pAd, offset, pTxMic, 8);
- }
- offset += LEN_TKIP_TXMICK;
-
- if (pRxMic)
- {
- RTUSBMultiWrite(pAd, offset, pRxMic, 8);
- }
-#endif // RT2870 //
-
- //
- // 4.) Modify IV/EIV if needs
- // This will force Asic to use this key ID by setting IV.
- //
- if (bTxKey)
- {
-
-#ifdef RT2870
- UINT32 tmpVal;
-
- //
- // Write IV
- //
- IV4 = (KeyIdx << 6);
- if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) ||(CipherAlg == CIPHER_AES))
- IV4 |= 0x20; // turn on extension bit means EIV existence
-
- tmpVal = pTxtsc[1] + (((pTxtsc[1] | 0x20) & 0x7f) << 8) + (pTxtsc[0] << 16) + (IV4 << 24);
- RTMP_IO_WRITE32(pAd, offset, tmpVal);
-
- //
- // Write EIV
- //
- offset += 4;
- RTMP_IO_WRITE32(pAd, offset, *(PUINT32)&pCipherKey->TxTsc[2]);
-#endif // RT2870 //
- AsicUpdateWCIDAttribute(pAd, WCID, BssIndex, CipherAlg, bUsePairewiseKeyTable);
- }
-
- if (!bUsePairewiseKeyTable)
- {
- //
- // Only update the shared key security mode
- //
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2), &csr1.word);
- if ((BssIndex % 2) == 0)
- {
- if (KeyIdx == 0)
- csr1.field.Bss0Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss0Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss0Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss0Key3CipherAlg = CipherAlg;
- }
- else
- {
- if (KeyIdx == 0)
- csr1.field.Bss1Key0CipherAlg = CipherAlg;
- else if (KeyIdx == 1)
- csr1.field.Bss1Key1CipherAlg = CipherAlg;
- else if (KeyIdx == 2)
- csr1.field.Bss1Key2CipherAlg = CipherAlg;
- else
- csr1.field.Bss1Key3CipherAlg = CipherAlg;
- }
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2), csr1.word);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<== AsicAddKeyEntry\n"));
-}
-
-
-/*
- ========================================================================
- Description:
- Add Pair-wise key material into ASIC.
- Update pairwise key, TxMic and RxMic to Asic Pair-wise key table
-
- Return:
- ========================================================================
-*/
-VOID AsicAddPairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR WCID,
- IN CIPHER_KEY *pCipherKey)
-{
- INT i;
- ULONG offset;
- PUCHAR pKey = pCipherKey->Key;
- PUCHAR pTxMic = pCipherKey->TxMic;
- PUCHAR pRxMic = pCipherKey->RxMic;
-#ifdef DBG
- UCHAR CipherAlg = pCipherKey->CipherAlg;
-#endif // DBG //
-
- // EKEY
- offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, &pCipherKey->Key[0], MAX_LEN_OF_PEER_KEY);
-#endif // RT2870 //
- for (i=0; i<MAX_LEN_OF_PEER_KEY; i+=4)
- {
- UINT32 Value;
- RTMP_IO_READ32(pAd, offset + i, &Value);
- }
-
- offset += MAX_LEN_OF_PEER_KEY;
-
- // MIC KEY
- if (pTxMic)
- {
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, &pCipherKey->TxMic[0], 8);
-#endif // RT2870 //
- }
- offset += 8;
- if (pRxMic)
- {
-#ifdef RT2870
- RTUSBMultiWrite(pAd, offset, &pCipherKey->RxMic[0], 8);
-#endif // RT2870 //
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicAddPairwiseKeyEntry: WCID #%d Alg=%s\n",WCID, CipherName[CipherAlg]));
- DBGPRINT(RT_DEBUG_TRACE,(" Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pKey[0],pKey[1],pKey[2],pKey[3],pKey[4],pKey[5],pKey[6],pKey[7],pKey[8],pKey[9],pKey[10],pKey[11],pKey[12],pKey[13],pKey[14],pKey[15]));
- if (pRxMic)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" Rx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pRxMic[0],pRxMic[1],pRxMic[2],pRxMic[3],pRxMic[4],pRxMic[5],pRxMic[6],pRxMic[7]));
- }
- if (pTxMic)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" Tx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
- pTxMic[0],pTxMic[1],pTxMic[2],pTxMic[3],pTxMic[4],pTxMic[5],pTxMic[6],pTxMic[7]));
- }
-}
-/*
- ========================================================================
- Description:
- Remove Pair-wise key material from ASIC.
-
- Return:
- ========================================================================
-*/
-VOID AsicRemovePairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR Wcid)
-{
- ULONG WCIDAttri;
- USHORT offset;
-
- // re-set the entry's WCID attribute as OPEN-NONE.
- offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
- WCIDAttri = (BssIdx<<4) | PAIRWISEKEYTABLE;
- RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-}
-
-BOOLEAN AsicSendCommandToMcu(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Command,
- IN UCHAR Token,
- IN UCHAR Arg0,
- IN UCHAR Arg1)
-{
- HOST_CMD_CSR_STRUC H2MCmd;
- H2M_MAILBOX_STRUC H2MMailbox;
- ULONG i = 0;
- do
- {
- RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
- if (H2MMailbox.field.Owner == 0)
- break;
-
- RTMPusecDelay(2);
- } while(i++ < 100);
-
- if (i >= 100)
- {
- {
- DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
- }
- return FALSE;
- }
-
-
- H2MMailbox.field.Owner = 1; // pass ownership to MCU
- H2MMailbox.field.CmdToken = Token;
- H2MMailbox.field.HighByte = Arg1;
- H2MMailbox.field.LowByte = Arg0;
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
-
- H2MCmd.word = 0;
- H2MCmd.field.HostCommand = Command;
- RTMP_IO_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
-
- if (Command != 0x80)
- {
- }
-
- return TRUE;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Verify the support rate for different PHY type
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID RTMPCheckRates(
- IN PRTMP_ADAPTER pAd,
- IN OUT UCHAR SupRate[],
- IN OUT UCHAR *SupRateLen)
-{
- UCHAR RateIdx, i, j;
- UCHAR NewRate[12], NewRateLen;
-
- NewRateLen = 0;
-
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- RateIdx = 4;
- else
- RateIdx = 12;
-
- // Check for support rates exclude basic rate bit
- for (i = 0; i < *SupRateLen; i++)
- for (j = 0; j < RateIdx; j++)
- if ((SupRate[i] & 0x7f) == RateIdTo500Kbps[j])
- NewRate[NewRateLen++] = SupRate[i];
-
- *SupRateLen = NewRateLen;
- NdisMoveMemory(SupRate, NewRate, NewRateLen);
-}
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef DOT11_N_SUPPORT
-BOOLEAN RTMPCheckChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR CentralChannel,
- IN UCHAR Channel)
-{
- UCHAR k;
- UCHAR UpperChannel = 0, LowerChannel = 0;
- UCHAR NoEffectChannelinList = 0;
-
- // Find upper and lower channel according to 40MHz current operation.
- if (CentralChannel < Channel)
- {
- UpperChannel = Channel;
- if (CentralChannel > 2)
- LowerChannel = CentralChannel - 2;
- else
- return FALSE;
- }
- else if (CentralChannel > Channel)
- {
- UpperChannel = CentralChannel + 2;
- LowerChannel = Channel;
- }
-
- for (k = 0;k < pAd->ChannelListNum;k++)
- {
- if (pAd->ChannelList[k].Channel == UpperChannel)
- {
- NoEffectChannelinList ++;
- }
- if (pAd->ChannelList[k].Channel == LowerChannel)
- {
- NoEffectChannelinList ++;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Total Channel in Channel List = [%d]\n", NoEffectChannelinList));
- if (NoEffectChannelinList == 2)
- return TRUE;
- else
- return FALSE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Verify the support rate for HT phy type
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- FALSE if pAd->CommonCfg.SupportedHtPhy doesn't accept the pHtCapability. (AP Mode)
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-BOOLEAN RTMPCheckHt(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo)
-{
- if (Wcid >= MAX_LEN_OF_MAC_TABLE)
- return FALSE;
-
- // If use AMSDU, set flag.
- if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_AMSDU_INUSED);
- // Save Peer Capability
- if (pHtCapability->HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_SGI20_CAPABLE);
- if (pHtCapability->HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_SGI40_CAPABLE);
- if (pHtCapability->HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (pHtCapability->HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport)
- {
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_RDG_CAPABLE);
- }
-
- if (Wcid < MAX_LEN_OF_MAC_TABLE)
- {
- pAd->MacTab.Content[Wcid].MpduDensity = pHtCapability->HtCapParm.MpduDensity;
- }
-
- // Will check ChannelWidth for MCSSet[4] below
- pAd->MlmeAux.HtCapability.MCSSet[4] = 0x1;
- switch (pAd->CommonCfg.RxStream)
- {
- case 1:
- pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[1] = 0x00;
- pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
- pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
- break;
- case 2:
- pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
- pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
- break;
- case 3:
- pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[2] = 0xff;
- pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
- break;
- }
-
- pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth = pAddHtInfo->AddHtInfo.RecomWidth & pAd->CommonCfg.DesiredHtPhy.ChannelWidth;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPCheckHt:: HtCapInfo.ChannelWidth=%d, RecomWidth=%d, DesiredHtPhy.ChannelWidth=%d, BW40MAvailForA/G=%d/%d, PhyMode=%d \n",
- pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth, pAddHtInfo->AddHtInfo.RecomWidth, pAd->CommonCfg.DesiredHtPhy.ChannelWidth,
- pAd->NicConfig2.field.BW40MAvailForA, pAd->NicConfig2.field.BW40MAvailForG, pAd->CommonCfg.PhyMode));
-
- pAd->MlmeAux.HtCapability.HtCapInfo.GF = pHtCapability->HtCapInfo.GF &pAd->CommonCfg.DesiredHtPhy.GF;
-
- // Send Assoc Req with my HT capability.
- pAd->MlmeAux.HtCapability.HtCapInfo.AMsduSize = pAd->CommonCfg.DesiredHtPhy.AmsduSize;
- pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs = pAd->CommonCfg.DesiredHtPhy.MimoPs;
- pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20 = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor20) & (pHtCapability->HtCapInfo.ShortGIfor20);
- pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40 = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40) & (pHtCapability->HtCapInfo.ShortGIfor40);
- pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC = (pAd->CommonCfg.DesiredHtPhy.TxSTBC)&(pHtCapability->HtCapInfo.RxSTBC);
- pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC = (pAd->CommonCfg.DesiredHtPhy.RxSTBC)&(pHtCapability->HtCapInfo.TxSTBC);
- pAd->MlmeAux.HtCapability.HtCapParm.MaxRAmpduFactor = pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor;
- pAd->MlmeAux.HtCapability.HtCapParm.MpduDensity = pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity;
- pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC = pHtCapability->ExtHtCapInfo.PlusHTC;
- pAd->MacTab.Content[Wcid].HTCapability.ExtHtCapInfo.PlusHTC = pHtCapability->ExtHtCapInfo.PlusHTC;
- if (pAd->CommonCfg.bRdg)
- {
- pAd->MlmeAux.HtCapability.ExtHtCapInfo.RDGSupport = pHtCapability->ExtHtCapInfo.RDGSupport;
- pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC = 1;
- }
-
- if (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_20)
- pAd->MlmeAux.HtCapability.MCSSet[4] = 0x0; // BW20 can't transmit MCS32
-
- COPY_AP_HTSETTINGS_FROM_BEACON(pAd, pHtCapability);
- return TRUE;
-}
-#endif // DOT11_N_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ========================================================================
-
- Routine Description:
- Verify the support rate for different PHY type
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID RTMPUpdateMlmeRate(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR MinimumRate;
- UCHAR ProperMlmeRate; //= RATE_54;
- UCHAR i, j, RateIdx = 12; //1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
- BOOLEAN bMatch = FALSE;
-
- switch (pAd->CommonCfg.PhyMode)
- {
- case PHY_11B:
- ProperMlmeRate = RATE_11;
- MinimumRate = RATE_1;
- break;
- case PHY_11BG_MIXED:
-#ifdef DOT11_N_SUPPORT
- case PHY_11ABGN_MIXED:
- case PHY_11BGN_MIXED:
-#endif // DOT11_N_SUPPORT //
- if ((pAd->MlmeAux.SupRateLen == 4) &&
- (pAd->MlmeAux.ExtRateLen == 0))
- // B only AP
- ProperMlmeRate = RATE_11;
- else
- ProperMlmeRate = RATE_24;
-
- if (pAd->MlmeAux.Channel <= 14)
- MinimumRate = RATE_1;
- else
- MinimumRate = RATE_6;
- break;
- case PHY_11A:
-#ifdef DOT11_N_SUPPORT
- case PHY_11N_2_4G: // rt2860 need to check mlmerate for 802.11n
- case PHY_11GN_MIXED:
- case PHY_11AGN_MIXED:
- case PHY_11AN_MIXED:
- case PHY_11N_5G:
-#endif // DOT11_N_SUPPORT //
- ProperMlmeRate = RATE_24;
- MinimumRate = RATE_6;
- break;
- case PHY_11ABG_MIXED:
- ProperMlmeRate = RATE_24;
- if (pAd->MlmeAux.Channel <= 14)
- MinimumRate = RATE_1;
- else
- MinimumRate = RATE_6;
- break;
- default: // error
- ProperMlmeRate = RATE_1;
- MinimumRate = RATE_1;
- break;
- }
-
- for (i = 0; i < pAd->MlmeAux.SupRateLen; i++)
- {
- for (j = 0; j < RateIdx; j++)
- {
- if ((pAd->MlmeAux.SupRate[i] & 0x7f) == RateIdTo500Kbps[j])
- {
- if (j == ProperMlmeRate)
- {
- bMatch = TRUE;
- break;
- }
- }
- }
-
- if (bMatch)
- break;
- }
-
- if (bMatch == FALSE)
- {
- for (i = 0; i < pAd->MlmeAux.ExtRateLen; i++)
- {
- for (j = 0; j < RateIdx; j++)
- {
- if ((pAd->MlmeAux.ExtRate[i] & 0x7f) == RateIdTo500Kbps[j])
- {
- if (j == ProperMlmeRate)
- {
- bMatch = TRUE;
- break;
- }
- }
- }
-
- if (bMatch)
- break;
- }
- }
-
- if (bMatch == FALSE)
- {
- ProperMlmeRate = MinimumRate;
- }
-
- pAd->CommonCfg.MlmeRate = MinimumRate;
- pAd->CommonCfg.RtsRate = ProperMlmeRate;
- if (pAd->CommonCfg.MlmeRate >= RATE_6)
- {
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_OFDM;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- else
- {
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
- pAd->CommonCfg.MlmeTransmit.field.MCS = pAd->CommonCfg.MlmeRate;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_CCK;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = pAd->CommonCfg.MlmeRate;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateMlmeRate ==> MlmeTransmit = 0x%x \n" , pAd->CommonCfg.MlmeTransmit.word));
-}
-
-CHAR RTMPMaxRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi0,
- IN CHAR Rssi1,
- IN CHAR Rssi2)
-{
- CHAR larger = -127;
-
- if ((pAd->Antenna.field.RxPath == 1) && (Rssi0 != 0))
- {
- larger = Rssi0;
- }
-
- if ((pAd->Antenna.field.RxPath >= 2) && (Rssi1 != 0))
- {
- larger = max(Rssi0, Rssi1);
- }
-
- if ((pAd->Antenna.field.RxPath == 3) && (Rssi2 != 0))
- {
- larger = max(larger, Rssi2);
- }
-
- if (larger == -127)
- larger = 0;
-
- return larger;
-}
-
-
-// Antenna divesity use GPIO3 and EESK pin for control
-// Antenna and EEPROM access are both using EESK pin,
-// Therefor we should avoid accessing EESK at the same time
-// Then restore antenna after EEPROM access
-VOID AsicSetRxAnt(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Ant)
-{
-#ifdef RT30xx
- UINT32 Value;
- UINT32 x;
-
- if ((pAd->EepromAccess) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- return;
- }
-
- // the antenna selection is through firmware and MAC register(GPIO3)
- if (Ant == 0)
- {
- // Main antenna
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x |= (EESK);
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
- Value &= ~(0x0808);
- RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to main antenna\n"));
- }
- else
- {
- // Aux antenna
- RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
- x &= ~(EESK);
- RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
- RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
- Value &= ~(0x0808);
- Value |= 0x08;
- RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to aux antenna\n"));
- }
-#endif // RT30xx //
-}
-
-
-/*
- ========================================================================
- Routine Description:
- Periodic evaluate antenna link status
-
- Arguments:
- pAd - Adapter pointer
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID AsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BBPR3 = 0;
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_NIC_NOT_EXIST |
- fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS) ||
- OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
-#ifdef RT30xx
- || (pAd->EepromAccess)
-#endif // RT30xx //
- )
- return;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //if (pAd->StaCfg.Psm == PWR_SAVE)
- // return;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // two antenna selection mechanism- one is antenna diversity, the other is failed antenna remove
- // one is antenna diversity:there is only one antenna can rx and tx
- // the other is failed antenna remove:two physical antenna can rx and tx
- if (pAd->NicConfig2.field.AntDiversity)
- {
- DBGPRINT(RT_DEBUG_TRACE,("AntDiv - before evaluate Pair1-Ant (%d,%d)\n",
- pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
-
- AsicSetRxAnt(pAd, pAd->RxAnt.Pair1SecondaryRxAnt);
-
- pAd->RxAnt.EvaluatePeriod = 1; // 1:Means switch to SecondaryRxAnt, 0:Means switch to Pair1PrimaryRxAnt
- pAd->RxAnt.FirstPktArrivedWhenEvaluate = FALSE;
- pAd->RxAnt.RcvPktNumWhenEvaluate = 0;
-
- // a one-shot timer to end the evalution
- // dynamic adjust antenna evaluation period according to the traffic
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 100);
- else
- RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300);
- }
- else
- {
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->StaCfg.Psm == PWR_SAVE)
- return;
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
- BBPR3 &= (~0x18);
- if(pAd->Antenna.field.RxPath == 3)
- {
- BBPR3 |= (0x10);
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- BBPR3 |= (0x8);
- }
- else if(pAd->Antenna.field.RxPath == 1)
- {
- BBPR3 |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- {
- ULONG TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
- pAd->RalinkCounters.OneSecTxRetryOkCount +
- pAd->RalinkCounters.OneSecTxFailCount;
-
- // dynamic adjust antenna evaluation period according to the traffic
- if (TxTotalCnt > 50)
- {
- RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 20);
- pAd->Mlme.bLowThroughput = FALSE;
- }
- else
- {
- RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300);
- pAd->Mlme.bLowThroughput = TRUE;
- }
- }
- }
-}
-
-/*
- ========================================================================
- Routine Description:
- After evaluation, check antenna link status
-
- Arguments:
- pAd - Adapter pointer
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID AsicRxAntEvalTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR BBPR3 = 0;
- CHAR larger = -127, rssi0, rssi1, rssi2;
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_NIC_NOT_EXIST) ||
- OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
-#ifdef RT30xx
- || (pAd->EepromAccess)
-#endif // RT30xx //
- )
- return;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //if (pAd->StaCfg.Psm == PWR_SAVE)
- // return;
-
- if (pAd->NicConfig2.field.AntDiversity)
- {
- if ((pAd->RxAnt.RcvPktNumWhenEvaluate != 0) && (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >= pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt]))
- {
- UCHAR temp;
-
- //
- // select PrimaryRxAntPair
- // Role change, Used Pair1SecondaryRxAnt as PrimaryRxAntPair.
- // Since Pair1SecondaryRxAnt Quality good than Pair1PrimaryRxAnt
- //
- temp = pAd->RxAnt.Pair1PrimaryRxAnt;
- pAd->RxAnt.Pair1PrimaryRxAnt = pAd->RxAnt.Pair1SecondaryRxAnt;
- pAd->RxAnt.Pair1SecondaryRxAnt = temp;
-
- pAd->RxAnt.Pair1LastAvgRssi = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >> 3);
- pAd->RxAnt.EvaluateStableCnt = 0;
- }
- else
- {
- // if the evaluated antenna is not better than original, switch back to original antenna
- AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
- pAd->RxAnt.EvaluateStableCnt ++;
- }
-
- pAd->RxAnt.EvaluatePeriod = 0; // 1:Means switch to SecondaryRxAnt, 0:Means switch to Pair1PrimaryRxAnt
-
- DBGPRINT(RT_DEBUG_TRACE,("AsicRxAntEvalAction::After Eval(fix in #%d), <%d, %d>, RcvPktNumWhenEvaluate=%ld\n",
- pAd->RxAnt.Pair1PrimaryRxAnt, (pAd->RxAnt.Pair1AvgRssi[0] >> 3), (pAd->RxAnt.Pair1AvgRssi[1] >> 3), pAd->RxAnt.RcvPktNumWhenEvaluate));
- }
- else
- {
- if (pAd->StaCfg.Psm == PWR_SAVE)
- return;
-
- // if the traffic is low, use average rssi as the criteria
- if (pAd->Mlme.bLowThroughput == TRUE)
- {
- rssi0 = pAd->StaCfg.RssiSample.LastRssi0;
- rssi1 = pAd->StaCfg.RssiSample.LastRssi1;
- rssi2 = pAd->StaCfg.RssiSample.LastRssi2;
- }
- else
- {
- rssi0 = pAd->StaCfg.RssiSample.AvgRssi0;
- rssi1 = pAd->StaCfg.RssiSample.AvgRssi1;
- rssi2 = pAd->StaCfg.RssiSample.AvgRssi2;
- }
-
- if(pAd->Antenna.field.RxPath == 3)
- {
- larger = max(rssi0, rssi1);
-
- if (larger > (rssi2 + 20))
- pAd->Mlme.RealRxPath = 2;
- else
- pAd->Mlme.RealRxPath = 3;
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- if (rssi0 > (rssi1 + 20))
- pAd->Mlme.RealRxPath = 1;
- else
- pAd->Mlme.RealRxPath = 2;
- }
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
- BBPR3 &= (~0x18);
- if(pAd->Mlme.RealRxPath == 3)
- {
- BBPR3 |= (0x10);
- }
- else if(pAd->Mlme.RealRxPath == 2)
- {
- BBPR3 |= (0x8);
- }
- else if(pAd->Mlme.RealRxPath == 1)
- {
- BBPR3 |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
- }
- }
-
-#endif // CONFIG_STA_SUPPORT //
-
-}
-
-
-
-VOID APSDPeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- return;
-
- pAd->CommonCfg.TriggerTimerCount++;
-
-// Driver should not send trigger frame, it should be send by application layer
-/*
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable
- && (pAd->CommonCfg.bNeedSendTriggerFrame ||
- (((pAd->CommonCfg.TriggerTimerCount%20) == 19) && (!pAd->CommonCfg.bAPSDAC_BE || !pAd->CommonCfg.bAPSDAC_BK || !pAd->CommonCfg.bAPSDAC_VI || !pAd->CommonCfg.bAPSDAC_VO))))
- {
- DBGPRINT(RT_DEBUG_TRACE,("Sending trigger frame and enter service period when support APSD\n"));
- RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
- pAd->CommonCfg.bNeedSendTriggerFrame = FALSE;
- pAd->CommonCfg.TriggerTimerCount = 0;
- pAd->CommonCfg.bInServicePeriod = TRUE;
- }*/
-}
-
-/*
- ========================================================================
- Routine Description:
- Set/reset MAC registers according to bPiggyBack parameter
-
- Arguments:
- pAd - Adapter pointer
- bPiggyBack - Enable / Disable Piggy-Back
-
- Return Value:
- None
-
- ========================================================================
-*/
-VOID RTMPSetPiggyBack(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bPiggyBack)
-{
- TX_LINK_CFG_STRUC TxLinkCfg;
-
- RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
-
- TxLinkCfg.field.TxCFAckEn = bPiggyBack;
- RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-}
-
-/*
- ========================================================================
- Routine Description:
- check if this entry need to switch rate automatically
-
- Arguments:
- pAd
- pEntry
-
- Return Value:
- TURE
- FALSE
-
- ========================================================================
-*/
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry)
-{
- BOOLEAN result = TRUE;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // only associated STA counts
- if (pEntry && (pEntry->ValidAsCLI) && (pEntry->Sst == SST_ASSOC))
- {
- result = pAd->StaCfg.bAutoTxRateSwitch;
- }
- else
- result = FALSE;
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
-
- return result;
-}
-
-
-BOOLEAN RTMPAutoRateSwitchCheck(
- IN PRTMP_ADAPTER pAd)
-{
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.bAutoTxRateSwitch)
- return TRUE;
- }
-#endif // CONFIG_STA_SUPPORT //
- return FALSE;
-}
-
-
-/*
- ========================================================================
- Routine Description:
- check if this entry need to fix tx legacy rate
-
- Arguments:
- pAd
- pEntry
-
- Return Value:
- TURE
- FALSE
-
- ========================================================================
-*/
-UCHAR RTMPStaFixedTxMode(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry)
-{
- UCHAR tx_mode = FIXED_TXMODE_HT;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- tx_mode = (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return tx_mode;
-}
-
-/*
- ========================================================================
- Routine Description:
- Overwrite HT Tx Mode by Fixed Legency Tx Mode, if specified.
-
- Arguments:
- pAd
- pEntry
-
- Return Value:
- TURE
- FALSE
-
- ========================================================================
-*/
-VOID RTMPUpdateLegacyTxSetting(
- UCHAR fixed_tx_mode,
- PMAC_TABLE_ENTRY pEntry)
-{
- HTTRANSMIT_SETTING TransmitSetting;
-
- if (fixed_tx_mode == FIXED_TXMODE_HT)
- return;
-
- TransmitSetting.word = 0;
-
- TransmitSetting.field.MODE = pEntry->HTPhyMode.field.MODE;
- TransmitSetting.field.MCS = pEntry->HTPhyMode.field.MCS;
-
- if (fixed_tx_mode == FIXED_TXMODE_CCK)
- {
- TransmitSetting.field.MODE = MODE_CCK;
- // CCK mode allow MCS 0~3
- if (TransmitSetting.field.MCS > MCS_3)
- TransmitSetting.field.MCS = MCS_3;
- }
- else
- {
- TransmitSetting.field.MODE = MODE_OFDM;
- // OFDM mode allow MCS 0~7
- if (TransmitSetting.field.MCS > MCS_7)
- TransmitSetting.field.MCS = MCS_7;
- }
-
- if (pEntry->HTPhyMode.field.MODE >= TransmitSetting.field.MODE)
- {
- pEntry->HTPhyMode.word = TransmitSetting.word;
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateLegacyTxSetting : wcid-%d, MODE=%s, MCS=%d \n",
- pEntry->Aid, GetPhyMode(pEntry->HTPhyMode.field.MODE), pEntry->HTPhyMode.field.MCS));
- }
-}
-
-#ifdef CONFIG_STA_SUPPORT
-/*
- ==========================================================================
- Description:
- dynamic tune BBP R66 to find a balance between sensibility and
- noise isolation
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AsicStaBbpTuning(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR OrigR66Value = 0, R66;//, R66UpperBound = 0x30, R66LowerBound = 0x30;
- CHAR Rssi;
-
- // 2860C did not support Fase CCA, therefore can't tune
- if (pAd->MACVersion == 0x28600100)
- return;
-
- //
- // work as a STA
- //
- if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) // no R66 tuning when SCANNING
- return;
-
- if ((pAd->OpMode == OPMODE_STA)
- && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- && !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- )
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value);
- R66 = OrigR66Value;
-
- if (pAd->Antenna.field.RxPath > 1)
- Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
- else
- Rssi = pAd->StaCfg.RssiSample.AvgRssi0;
-
- if (pAd->LatchRfRegs.Channel <= 14)
- { //BG band
-#ifdef RT30xx
- // RT3070 is a no LNA solution, it should have different control regarding to AGC gain control
- // Otherwise, it will have some throughput side effect when low RSSI
- if (IS_RT30xx(pAd))
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = 0x1C + 2*GET_LNA_GAIN(pAd) + 0x20;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x1C + 2*GET_LNA_GAIN(pAd);
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
- else
-#endif // RT30xx //
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = (0x2E + GET_LNA_GAIN(pAd)) + 0x10;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
-
- }
- else
- { //A band
- if (pAd->CommonCfg.BBPCurrentBW == BW_20)
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = 0x32 + (GET_LNA_GAIN(pAd)*5)/3 + 0x10;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x32 + (GET_LNA_GAIN(pAd)*5)/3;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
- else
- {
- if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
- {
- R66 = 0x3A + (GET_LNA_GAIN(pAd)*5)/3 + 0x10;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- else
- {
- R66 = 0x3A + (GET_LNA_GAIN(pAd)*5)/3;
- if (OrigR66Value != R66)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
- }
- }
-
-
- }
-}
-#endif // CONFIG_STA_SUPPORT //
-
-VOID RTMPSetAGCInitValue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BandWidth)
-{
- UCHAR R66 = 0x30;
-
- if (pAd->LatchRfRegs.Channel <= 14)
- { // BG band
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- { //A band
- if (BandWidth == BW_20)
- {
- R66 = (UCHAR)(0x32 + (GET_LNA_GAIN(pAd)*5)/3);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
-#ifdef DOT11_N_SUPPORT
- else
- {
- R66 = (UCHAR)(0x3A + (GET_LNA_GAIN(pAd)*5)/3);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
-}
-
-VOID AsicTurnOffRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
- // RF R2 bit 18 = 0
- UINT32 R1 = 0, R2 = 0, R3 = 0;
- UCHAR index;
- RTMP_RF_REGS *RFRegTable;
-
-#ifdef RT30xx
- // The RF programming sequence is difference between 3xxx and 2xxx
- if (IS_RT3090(pAd))
- {
- RT30xxLoadRFSleepModeSetup(pAd); // add by johnli, RF power sequence setup, load RF sleep-mode setup
- }
- else
- {
-#endif // RT30xx //
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R1 = RFRegTable[index].R1 & 0xffffdfff;
- R2 = RFRegTable[index].R2 & 0xfffbffff;
- R3 = RFRegTable[index].R3 & 0xfff3ffff;
-
- RTMP_RF_IO_WRITE32(pAd, R1);
- RTMP_RF_IO_WRITE32(pAd, R2);
-
- // Program R1b13 to 1, R3/b18,19 to 0, R2b18 to 0.
- // Set RF R2 bit18=0, R3 bit[18:19]=0
- //if (pAd->StaCfg.bRadio == FALSE)
- if (1)
- {
- RTMP_RF_IO_WRITE32(pAd, R3);
-
- DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOffRFClk#%d(RF=%d, ) , R2=0x%08x, R3 = 0x%08x \n",
- Channel, pAd->RfIcType, R2, R3));
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOffRFClk#%d(RF=%d, ) , R2=0x%08x \n",
- Channel, pAd->RfIcType, R2));
- break;
- }
- }
- break;
-
- default:
- break;
- }
-#ifdef RT30xx
- }
-#endif // RT30xx //
-
-}
-
-
-VOID AsicTurnOnRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel)
-{
- // RF R2 bit 18 = 0
- UINT32 R1 = 0, R2 = 0, R3 = 0;
- UCHAR index;
- RTMP_RF_REGS *RFRegTable;
-
-#ifdef RT30xx
- // The RF programming sequence is difference between 3xxx and 2xxx
- if (IS_RT3090(pAd))
- {
- }
- else
- {
-#endif // RT30xx //
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R3 = pAd->LatchRfRegs.R3;
- R3 &= 0xfff3ffff;
- R3 |= 0x00080000;
- RTMP_RF_IO_WRITE32(pAd, R3);
-
- R1 = RFRegTable[index].R1;
- RTMP_RF_IO_WRITE32(pAd, R1);
-
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- R2 |= 0x40; // write 1 to off Rxpath.
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
- RTMP_RF_IO_WRITE32(pAd, R2);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
-#ifdef RT30xx
- }
-#endif // RT30xx //
-
-}
-
+#include "../../rt2870/common/mlme.c"
diff --git a/drivers/staging/rt3070/common/netif_block.c b/drivers/staging/rt3070/common/netif_block.c
deleted file mode 100644
index 4773c11bedd0..000000000000
--- a/drivers/staging/rt3070/common/netif_block.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "../rt_config.h"
-#include "netif_block.h"
-
-static NETIF_ENTRY freeNetIfEntryPool[FREE_NETIF_POOL_SIZE];
-static LIST_HEADER freeNetIfEntryList;
-
-void initblockQueueTab(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
-
- initList(&freeNetIfEntryList);
- for (i = 0; i < FREE_NETIF_POOL_SIZE; i++)
- insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)&freeNetIfEntryPool[i]);
-
- for (i=0; i < NUM_OF_TX_RING; i++)
- initList(&pAd->blockQueueTab[i].NetIfList);
-
- return;
-}
-
-BOOLEAN blockNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
- IN PNET_DEV pNetDev)
-{
- PNETIF_ENTRY pNetIfEntry = NULL;
-
- if ((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(&freeNetIfEntryList)) != NULL)
- {
- netif_stop_queue(pNetDev);
- pNetIfEntry->pNetDev = pNetDev;
- insertTailList(&pBlockQueueEntry->NetIfList, (PLIST_ENTRY)pNetIfEntry);
-
- pBlockQueueEntry->SwTxQueueBlockFlag = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("netif_stop_queue(%s)\n", pNetDev->name));
- }
- else
- return FALSE;
-
- return TRUE;
-}
-
-VOID releaseNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry)
-{
- PNETIF_ENTRY pNetIfEntry = NULL;
- PLIST_HEADER pNetIfList = &pBlockQueueEntry->NetIfList;
-
- while((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(pNetIfList)) != NULL)
- {
- PNET_DEV pNetDev = pNetIfEntry->pNetDev;
- netif_wake_queue(pNetDev);
- insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)pNetIfEntry);
-
- DBGPRINT(RT_DEBUG_TRACE, ("netif_wake_queue(%s)\n", pNetDev->name));
- }
- pBlockQueueEntry->SwTxQueueBlockFlag = FALSE;
- return;
-}
-
-
-VOID StopNetIfQueue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket)
-{
- PNET_DEV NetDev = NULL;
- UCHAR IfIdx = 0;
- BOOLEAN valid = FALSE;
-
-#ifdef WDS_SUPPORT
- if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_WDS)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_WDS) % MAX_WDS_ENTRY;
- NetDev = pAd->WdsTab.WdsEntry[IfIdx].dev;
- }
- else
-#endif // WDS_SUPPORT //
- {
-#ifdef MBSS_SUPPORT
- if (pAd->OpMode == OPMODE_AP)
- {
- IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_MBSSID) % MAX_MBSSID_NUM;
- NetDev = pAd->ApCfg.MBSSID[IfIdx].MSSIDDev;
- }
- else
- {
- IfIdx = MAIN_MBSSID;
- NetDev = pAd->net_dev;
- }
-#else
- IfIdx = MAIN_MBSSID;
- NetDev = pAd->net_dev;
-#endif
- }
-
- // WMM support 4 software queues.
- // One software queue full doesn't mean device have no capbility to transmit packet.
- // So disable block Net-If queue function while WMM enable.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- valid = (pAd->CommonCfg.bWmmCapable == TRUE) ? FALSE : TRUE;
-#endif // CONFIG_STA_SUPPORT //
-
- if (valid)
- blockNetIf(&pAd->blockQueueTab[QueIdx], NetDev);
- return;
-}
-
diff --git a/drivers/staging/rt3070/common/rtmp_init.c b/drivers/staging/rt3070/common/rtmp_init.c
index 4503f6c6d954..4709e5f28a8a 100644
--- a/drivers/staging/rt3070/common/rtmp_init.c
+++ b/drivers/staging/rt3070/common/rtmp_init.c
@@ -1,4197 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_init.c
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 2002-08-01 created
- John Chang 2004-08-20 RT2561/2661 use scatter-gather scheme
- Jan Lee 2006-09-15 RT2860. Change for 802.11n , EEPROM, Led, BA, HT.
-*/
-#include "../rt_config.h"
-#include "../firmware.h"
-
-//#define BIN_IN_FILE /* use *.bin firmware */
-
-UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
-ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008,
- 0x00000010, 0x00000020, 0x00000040, 0x00000080,
- 0x00000100, 0x00000200, 0x00000400, 0x00000800,
- 0x00001000, 0x00002000, 0x00004000, 0x00008000,
- 0x00010000, 0x00020000, 0x00040000, 0x00080000,
- 0x00100000, 0x00200000, 0x00400000, 0x00800000,
- 0x01000000, 0x02000000, 0x04000000, 0x08000000,
- 0x10000000, 0x20000000, 0x40000000, 0x80000000};
-
-char* CipherName[] = {"none","wep64","wep128","TKIP","AES","CKIP64","CKIP128"};
-
-const unsigned short ccitt_16Table[] = {
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
- 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
- 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
- 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
- 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
- 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
- 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
- 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
- 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
- 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
- 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
- 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
- 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
- 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
- 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
- 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
- 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
- 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
- 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
- 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
- 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
- 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
- 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
-};
-#define ByteCRC16(v, crc) \
- (unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])
-
-unsigned char BitReverse(unsigned char x)
-{
- int i;
- unsigned char Temp=0;
- for(i=0; ; i++)
- {
- if(x & 0x80) Temp |= 0x80;
- if(i==7) break;
- x <<= 1;
- Temp >>= 1;
- }
- return Temp;
-}
-
-//
-// BBP register initialization set
-//
-REG_PAIR BBPRegTable[] = {
- {BBP_R65, 0x2C}, // fix rssi issue
- {BBP_R66, 0x38}, // Also set this default value to pAd->BbpTuning.R66CurrentValue at initial
- {BBP_R69, 0x12},
- {BBP_R70, 0xa}, // BBP_R70 will change to 0x8 in ApStartUp and LinkUp for rt2860C, otherwise value is 0xa
- {BBP_R73, 0x10},
- {BBP_R81, 0x37},
- {BBP_R82, 0x62},
- {BBP_R83, 0x6A},
- {BBP_R84, 0x99}, // 0x19 is for rt2860E and after. This is for extension channel overlapping IOT. 0x99 is for rt2860D and before
- {BBP_R86, 0x00}, // middle range issue, Rory @2008-01-28
- {BBP_R91, 0x04}, // middle range issue, Rory @2008-01-28
- {BBP_R92, 0x00}, // middle range issue, Rory @2008-01-28
- {BBP_R103, 0x00}, // near range high-power issue, requested from Gary @2008-0528
- {BBP_R105, 0x05}, // 0x05 is for rt2860E to turn on FEQ control. It is safe for rt2860D and before, because Bit 7:2 are reserved in rt2860D and before.
-};
-#define NUM_BBP_REG_PARMS (sizeof(BBPRegTable) / sizeof(REG_PAIR))
-
-//
-// RF register initialization set
-//
-#ifdef RT30xx
-REG_PAIR RT30xx_RFRegTable[] = {
- {RF_R04, 0x40},
- {RF_R05, 0x03},
- {RF_R06, 0x02},
- {RF_R07, 0x70},
- {RF_R09, 0x0F},
- {RF_R10, 0x41},
- {RF_R11, 0x21},
- {RF_R12, 0x7B},
- {RF_R14, 0x90},
- {RF_R15, 0x58},
- {RF_R16, 0xB3},
- {RF_R17, 0x92},
- {RF_R18, 0x2C},
- {RF_R19, 0x02},
- {RF_R20, 0xBA},
- {RF_R21, 0xDB},
- {RF_R24, 0x16},
- {RF_R25, 0x01},
- {RF_R29, 0x1F},
-};
-#define NUM_RF_REG_PARMS (sizeof(RT30xx_RFRegTable) / sizeof(REG_PAIR))
-#endif // RT30xx //
-
-//
-// ASIC register initialization sets
-//
-
-RTMP_REG_PAIR MACRegTable[] = {
-#if defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x200)
- {BCN_OFFSET0, 0xf8f0e8e0}, /* 0x3800(e0), 0x3A00(e8), 0x3C00(f0), 0x3E00(f8), 512B for each beacon */
- {BCN_OFFSET1, 0x6f77d0c8}, /* 0x3200(c8), 0x3400(d0), 0x1DC0(77), 0x1BC0(6f), 512B for each beacon */
-#elif defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x100)
- {BCN_OFFSET0, 0xece8e4e0}, /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */
- {BCN_OFFSET1, 0xfcf8f4f0}, /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */
-#else
- #error You must re-calculate new value for BCN_OFFSET0 & BCN_OFFSET1 in MACRegTable[]!!!
-#endif // HW_BEACON_OFFSET //
-
- {LEGACY_BASIC_RATE, 0x0000013f}, // Basic rate set bitmap
- {HT_BASIC_RATE, 0x00008003}, // Basic HT rate set , 20M, MCS=3, MM. Format is the same as in TXWI.
- {MAC_SYS_CTRL, 0x00}, // 0x1004, , default Disable RX
- {RX_FILTR_CFG, 0x17f97}, //0x1400 , RX filter control,
- {BKOFF_SLOT_CFG, 0x209}, // default set short slot time, CC_DELAY_TIME should be 2
- //{TX_SW_CFG0, 0x40a06}, // Gary,2006-08-23
- {TX_SW_CFG0, 0x0}, // Gary,2008-05-21 for CWC test
- {TX_SW_CFG1, 0x80606}, // Gary,2006-08-23
- {TX_LINK_CFG, 0x1020}, // Gary,2006-08-23
- {TX_TIMEOUT_CFG, 0x000a2090},
- {MAX_LEN_CFG, MAX_AGGREGATION_SIZE | 0x00001000}, // 0x3018, MAX frame length. Max PSDU = 16kbytes.
- {LED_CFG, 0x7f031e46}, // Gary, 2006-08-23
-
-//#ifdef CONFIG_STA_SUPPORT
-// {WMM_AIFSN_CFG, 0x00002273},
-// {WMM_CWMIN_CFG, 0x00002344},
-// {WMM_CWMAX_CFG, 0x000034aa},
-//#endif // CONFIG_STA_SUPPORT //
-#ifdef INF_AMAZON_SE
- {PBF_MAX_PCNT, 0x1F3F6F6F}, //iverson modify for usb issue, 2008/09/19
- // 6F + 6F < total page count FE
- // so that RX doesn't occupy TX's buffer space when WMM congestion.
-#else
- {PBF_MAX_PCNT, 0x1F3FBF9F}, //0x1F3f7f9f}, //Jan, 2006/04/20
-#endif // INF_AMAZON_SE //
- //{TX_RTY_CFG, 0x6bb80408}, // Jan, 2006/11/16
- {TX_RTY_CFG, 0x47d01f0f}, // Jan, 2006/11/16, Set TxWI->ACK =0 in Probe Rsp Modify for 2860E ,2007-08-03
- {AUTO_RSP_CFG, 0x00000013}, // Initial Auto_Responder, because QA will turn off Auto-Responder
- {CCK_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
- {OFDM_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
-//PS packets use Tx1Q (for HCCA) when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-#ifdef RT2870
-#ifdef CONFIG_STA_SUPPORT
- {PBF_CFG, 0xf40006}, // Only enable Queue 2
-#endif // CONFIG_STA_SUPPORT //
- {MM40_PROT_CFG, 0x3F44084}, // Initial Auto_Responder, because QA will turn off Auto-Responder
- {WPDMA_GLO_CFG, 0x00000030},
-#endif // RT2870 //
- {GF20_PROT_CFG, 0x01744004}, // set 19:18 --> Short NAV for MIMO PS
- {GF40_PROT_CFG, 0x03F44084},
- {MM20_PROT_CFG, 0x01744004},
- {TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f*/ /*0x000024bf*/}, //Extension channel backoff.
- {TX_RTS_CFG, 0x00092b20},
-//#ifdef WIFI_TEST
- {EXP_ACK_TIME, 0x002400ca}, // default value
-//#else
-// {EXP_ACK_TIME, 0x005400ca}, // suggested by Gray @ 20070323 for 11n intel-sta throughput
-//#endif // end - WIFI_TEST //
- {TXOP_HLDR_ET, 0x00000002},
-
- /* Jerry comments 2008/01/16: we use SIFS = 10us in CCK defaultly, but it seems that 10us
- is too small for INTEL 2200bg card, so in MBSS mode, the delta time between beacon0
- and beacon1 is SIFS (10us), so if INTEL 2200bg card connects to BSS0, the ping
- will always lost. So we change the SIFS of CCK from 10us to 16us. */
- {XIFS_TIME_CFG, 0x33a41010},
- {PWR_PIN_CFG, 0x00000003}, // patch for 2880-E
-};
-
-
-#ifdef CONFIG_STA_SUPPORT
-RTMP_REG_PAIR STAMACRegTable[] = {
- {WMM_AIFSN_CFG, 0x00002273},
- {WMM_CWMIN_CFG, 0x00002344},
- {WMM_CWMAX_CFG, 0x000034aa},
-};
-#endif // CONFIG_STA_SUPPORT //
-
-#define NUM_MAC_REG_PARMS (sizeof(MACRegTable) / sizeof(RTMP_REG_PAIR))
-#ifdef CONFIG_STA_SUPPORT
-#define NUM_STA_MAC_REG_PARMS (sizeof(STAMACRegTable) / sizeof(RTMP_REG_PAIR))
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RT2870
-//
-// RT2870 Firmware Spec only used 1 oct for version expression
-//
-#define FIRMWARE_MINOR_VERSION 7
-
-#endif // RT2870 //
-
-// New 8k byte firmware size for RT3071/RT3072
-#define FIRMWAREIMAGE_MAX_LENGTH 0x2000
-#define FIRMWAREIMAGE_LENGTH (sizeof (FirmwareImage) / sizeof(UCHAR))
-#define FIRMWARE_MAJOR_VERSION 0
-
-#define FIRMWAREIMAGEV1_LENGTH 0x1000
-#define FIRMWAREIMAGEV2_LENGTH 0x1000
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- Allocate RTMP_ADAPTER data block and do some initialization
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTMPAllocAdapterBlock(
- IN PVOID handle,
- OUT PRTMP_ADAPTER *ppAdapter)
-{
- PRTMP_ADAPTER pAd;
- NDIS_STATUS Status;
- INT index;
- UCHAR *pBeaconBuf = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocAdapterBlock\n"));
-
- *ppAdapter = NULL;
-
- do
- {
- // Allocate RTMP_ADAPTER memory block
- pBeaconBuf = kmalloc(MAX_BEACON_SIZE, MEM_ALLOC_FLAG);
- if (pBeaconBuf == NULL)
- {
- Status = NDIS_STATUS_FAILURE;
- DBGPRINT_ERR(("Failed to allocate memory - BeaconBuf!\n"));
- break;
- }
-
- Status = AdapterBlockAllocateMemory(handle, (PVOID *)&pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("Failed to allocate memory - ADAPTER\n"));
- break;
- }
- pAd->BeaconBuf = pBeaconBuf;
- printk("\n\n=== pAd = %p, size = %d ===\n\n", pAd, (UINT32)sizeof(RTMP_ADAPTER));
-
-
- // Init spin locks
- NdisAllocateSpinLock(&pAd->MgmtRingLock);
-
- for (index =0 ; index < NUM_OF_TX_RING; index++)
- {
- NdisAllocateSpinLock(&pAd->TxSwQueueLock[index]);
- NdisAllocateSpinLock(&pAd->DeQueueLock[index]);
- pAd->DeQueueRunning[index] = FALSE;
- }
-
- NdisAllocateSpinLock(&pAd->irq_lock);
-
- } while (FALSE);
-
- if ((Status != NDIS_STATUS_SUCCESS) && (pBeaconBuf))
- kfree(pBeaconBuf);
-
- *ppAdapter = pAd;
-
- DBGPRINT_S(Status, ("<-- RTMPAllocAdapterBlock, Status=%x\n", Status));
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Read initial Tx power per MCS and BW from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReadTxPwrPerRate(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG data, Adata, Gdata;
- USHORT i, value, value2;
- INT Apwrdelta, Gpwrdelta;
- UCHAR t1,t2,t3,t4;
- BOOLEAN bValid, bApwrdeltaMinus = TRUE, bGpwrdeltaMinus = TRUE;
-
- //
- // Get power delta for 20MHz and 40MHz.
- //
- DBGPRINT(RT_DEBUG_TRACE, ("Txpower per Rate\n"));
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_DELTA, value2);
- Apwrdelta = 0;
- Gpwrdelta = 0;
-
- if ((value2 & 0xff) != 0xff)
- {
- if ((value2 & 0x80))
- Gpwrdelta = (value2&0xf);
-
- if ((value2 & 0x40))
- bGpwrdeltaMinus = FALSE;
- else
- bGpwrdeltaMinus = TRUE;
- }
- if ((value2 & 0xff00) != 0xff00)
- {
- if ((value2 & 0x8000))
- Apwrdelta = ((value2&0xf00)>>8);
-
- if ((value2 & 0x4000))
- bApwrdeltaMinus = FALSE;
- else
- bApwrdeltaMinus = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Gpwrdelta = %x, Apwrdelta = %x .\n", Gpwrdelta, Apwrdelta));
-
- //
- // Get Txpower per MCS for 20MHz in 2.4G.
- //
- for (i=0; i<5; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i*4, value);
- data = value;
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i*4 + 2, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
- data |= (value<<16);
-
- pAd->Tx20MPwrCfgABand[i] = pAd->Tx40MPwrCfgABand[i] = Adata;
- pAd->Tx20MPwrCfgGBand[i] = pAd->Tx40MPwrCfgGBand[i] = Gdata;
-
- if (data != 0xffffffff)
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, data);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("20MHz BW, 2.4G band-%lx, Adata = %lx, Gdata = %lx \n", data, Adata, Gdata));
- }
-
- //
- // Check this block is valid for 40MHz in 2.4G. If invalid, use parameter for 20MHz in 2.4G
- //
- bValid = TRUE;
- for (i=0; i<6; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + 2 + i*2, value);
- if (((value & 0x00FF) == 0x00FF) || ((value & 0xFF00) == 0xFF00))
- {
- bValid = FALSE;
- break;
- }
- }
-
- //
- // Get Txpower per MCS for 40MHz in 2.4G.
- //
- if (bValid)
- {
- for (i=0; i<4; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + i*4, value);
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + i*4 + 2, value);
- if (bGpwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Gpwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Gpwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Gpwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Gpwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Gpwrdelta)
- t1 = (value&0xf)-(Gpwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Gpwrdelta)
- t2 = ((value&0xf0)>>4)-(Gpwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Gpwrdelta)
- t3 = ((value&0xf00)>>8)-(Gpwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Gpwrdelta)
- t4 = ((value&0xf000)>>12)-(Gpwrdelta);
- else
- t4 = 0;
- }
- Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
-
- if (i == 0)
- pAd->Tx40MPwrCfgGBand[i+1] = (pAd->Tx40MPwrCfgGBand[i+1] & 0x0000FFFF) | (Gdata & 0xFFFF0000);
- else
- pAd->Tx40MPwrCfgGBand[i+1] = Gdata;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("40MHz BW, 2.4G band, Gdata = %lx \n", Gdata));
- }
- }
-
- //
- // Check this block is valid for 20MHz in 5G. If invalid, use parameter for 20MHz in 2.4G
- //
- bValid = TRUE;
- for (i=0; i<8; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + 2 + i*2, value);
- if (((value & 0x00FF) == 0x00FF) || ((value & 0xFF00) == 0xFF00))
- {
- bValid = FALSE;
- break;
- }
- }
-
- //
- // Get Txpower per MCS for 20MHz in 5G.
- //
- if (bValid)
- {
- for (i=0; i<5; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + i*4, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + i*4 + 2, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
-
- if (i == 0)
- pAd->Tx20MPwrCfgABand[i] = (pAd->Tx20MPwrCfgABand[i] & 0x0000FFFF) | (Adata & 0xFFFF0000);
- else
- pAd->Tx20MPwrCfgABand[i] = Adata;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("20MHz BW, 5GHz band, Adata = %lx \n", Adata));
- }
- }
-
- //
- // Check this block is valid for 40MHz in 5G. If invalid, use parameter for 20MHz in 2.4G
- //
- bValid = TRUE;
- for (i=0; i<6; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + 2 + i*2, value);
- if (((value & 0x00FF) == 0x00FF) || ((value & 0xFF00) == 0xFF00))
- {
- bValid = FALSE;
- break;
- }
- }
-
- //
- // Get Txpower per MCS for 40MHz in 5G.
- //
- if (bValid)
- {
- for (i=0; i<4; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + i*4, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + i*4 + 2, value);
- if (bApwrdeltaMinus == FALSE)
- {
- t1 = (value&0xf)+(Apwrdelta);
- if (t1 > 0xf)
- t1 = 0xf;
- t2 = ((value&0xf0)>>4)+(Apwrdelta);
- if (t2 > 0xf)
- t2 = 0xf;
- t3 = ((value&0xf00)>>8)+(Apwrdelta);
- if (t3 > 0xf)
- t3 = 0xf;
- t4 = ((value&0xf000)>>12)+(Apwrdelta);
- if (t4 > 0xf)
- t4 = 0xf;
- }
- else
- {
- if ((value&0xf) > Apwrdelta)
- t1 = (value&0xf)-(Apwrdelta);
- else
- t1 = 0;
- if (((value&0xf0)>>4) > Apwrdelta)
- t2 = ((value&0xf0)>>4)-(Apwrdelta);
- else
- t2 = 0;
- if (((value&0xf00)>>8) > Apwrdelta)
- t3 = ((value&0xf00)>>8)-(Apwrdelta);
- else
- t3 = 0;
- if (((value&0xf000)>>12) > Apwrdelta)
- t4 = ((value&0xf000)>>12)-(Apwrdelta);
- else
- t4 = 0;
- }
- Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
-
- if (i == 0)
- pAd->Tx40MPwrCfgABand[i+1] = (pAd->Tx40MPwrCfgABand[i+1] & 0x0000FFFF) | (Adata & 0xFFFF0000);
- else
- pAd->Tx40MPwrCfgABand[i+1] = Adata;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("40MHz BW, 5GHz band, Adata = %lx \n", Adata));
- }
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Read initial channel power parameters from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReadChannelPwr(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR i, choffset;
- EEPROM_TX_PWR_STRUC Power;
- EEPROM_TX_PWR_STRUC Power2;
-
- // Read Tx power value for all channels
- // Value from 1 - 0x7f. Default value is 24.
- // Power value : 2.4G 0x00 (0) ~ 0x1F (31)
- // : 5.5G 0xF9 (-7) ~ 0x0F (15)
-
- // 0. 11b/g, ch1 - ch 14
- for (i = 0; i < 7; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2, Power2.word);
- pAd->TxPower[i * 2].Channel = i * 2 + 1;
- pAd->TxPower[i * 2 + 1].Channel = i * 2 + 2;
-
- if ((Power.field.Byte0 > 31) || (Power.field.Byte0 < 0))
- pAd->TxPower[i * 2].Power = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 > 31) || (Power.field.Byte1 < 0))
- pAd->TxPower[i * 2 + 1].Power = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2 + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 > 31) || (Power2.field.Byte0 < 0))
- pAd->TxPower[i * 2].Power2 = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 > 31) || (Power2.field.Byte1 < 0))
- pAd->TxPower[i * 2 + 1].Power2 = DEFAULT_RF_TX_POWER;
- else
- pAd->TxPower[i * 2 + 1].Power2 = Power2.field.Byte1;
- }
-
- // 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz)
- // 1.1 Fill up channel
- choffset = 14;
- for (i = 0; i < 4; i++)
- {
- pAd->TxPower[3 * i + choffset + 0].Channel = 36 + i * 8 + 0;
- pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 1].Channel = 36 + i * 8 + 2;
- pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 2].Channel = 36 + i * 8 + 4;
- pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
- }
-
- // 1.2 Fill up power
- for (i = 0; i < 6; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2, Power2.word);
-
- if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
- }
-
- // 2. HipperLAN 2 100, 102 ,104; 108, 110, 112; 116, 118, 120; 124, 126, 128; 132, 134, 136; 140 (including central frequency in BW 40MHz)
- // 2.1 Fill up channel
- choffset = 14 + 12;
- for (i = 0; i < 5; i++)
- {
- pAd->TxPower[3 * i + choffset + 0].Channel = 100 + i * 8 + 0;
- pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 1].Channel = 100 + i * 8 + 2;
- pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 2].Channel = 100 + i * 8 + 4;
- pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
- }
- pAd->TxPower[3 * 5 + choffset + 0].Channel = 140;
- pAd->TxPower[3 * 5 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * 5 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- // 2.2 Fill up power
- for (i = 0; i < 8; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2, Power2.word);
-
- if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
- }
-
- // 3. U-NII upper band: 149, 151, 153; 157, 159, 161; 165 (including central frequency in BW 40MHz)
- // 3.1 Fill up channel
- choffset = 14 + 12 + 16;
- for (i = 0; i < 2; i++)
- {
- pAd->TxPower[3 * i + choffset + 0].Channel = 149 + i * 8 + 0;
- pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 1].Channel = 149 + i * 8 + 2;
- pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
- pAd->TxPower[3 * i + choffset + 2].Channel = 149 + i * 8 + 4;
- pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
- }
- pAd->TxPower[3 * 2 + choffset + 0].Channel = 165;
- pAd->TxPower[3 * 2 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
- pAd->TxPower[3 * 2 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
- // 3.2 Fill up power
- for (i = 0; i < 4; i++)
- {
-// Power.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2);
-// Power2.word = RTMP_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2, Power.word);
- RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2, Power2.word);
-
- if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
-
- if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
-
- if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
- pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
-
- if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
- pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
- }
-
- // 4. Print and Debug
- choffset = 14 + 12 + 16 + 7;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Read the following from the registry
- 1. All the parameters
- 2. NetworkAddres
-
- Arguments:
- Adapter Pointer to our adapter
- WrapperConfigurationContext For use by NdisOpenConfiguration
-
- Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
- NDIS_STATUS_RESOURCES
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS NICReadRegParameters(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_HANDLE WrapperConfigurationContext
- )
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- DBGPRINT_S(Status, ("<-- NICReadRegParameters, Status=%x\n", Status));
- return Status;
-}
-
-
-#ifdef RT30xx
-/*
- ========================================================================
-
- Routine Description:
- For RF filter calibration purpose
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID RTMPFilterCalibration(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue=0;
- UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0;
- UCHAR RF_R24_Value = 0;
-
- // Give bbp filter initial value
- pAd->Mlme.CaliBW20RfR24 = 0x1F;
- pAd->Mlme.CaliBW40RfR24 = 0x2F; //Bit[5] must be 1 for BW 40
-
- do
- {
- if (loop == 1) //BandWidth = 40 MHz
- {
- // Write 0x27 to RF_R24 to program filter
- RF_R24_Value = 0x27;
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
- if (IS_RT3090(pAd))
- FilterTarget = 0x15;
- else
- FilterTarget = 0x19;
-
- // when calibrate BW40, BBP mask must set to BW40.
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- BBPValue|= (0x10);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
- // set to BW40
- RT30xxReadRFRegister(pAd, RF_R31, &value);
- value |= 0x20;
- RT30xxWriteRFRegister(pAd, RF_R31, value);
- }
- else //BandWidth = 20 MHz
- {
- // Write 0x07 to RF_R24 to program filter
- RF_R24_Value = 0x07;
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
- if (IS_RT3090(pAd))
- FilterTarget = 0x13;
- else
- FilterTarget = 0x16;
-
- // set to BW20
- RT30xxReadRFRegister(pAd, RF_R31, &value);
- value &= (~0x20);
- RT30xxWriteRFRegister(pAd, RF_R31, value);
- }
-
- // Write 0x01 to RF_R22 to enable baseband loopback mode
- RT30xxReadRFRegister(pAd, RF_R22, &value);
- value |= 0x01;
- RT30xxWriteRFRegister(pAd, RF_R22, value);
-
- // Write 0x00 to BBP_R24 to set power & frequency of passband test tone
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
-
- do
- {
- // Write 0x90 to BBP_R25 to transmit test tone
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
-
- RTMPusecDelay(1000);
- // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0]
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
- R55x = value & 0xFF;
-
- } while ((ReTry++ < 100) && (R55x == 0));
-
- // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0x06);
-
- while(TRUE)
- {
- // Write 0x90 to BBP_R25 to transmit test tone
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
-
- //We need to wait for calibration
- RTMPusecDelay(1000);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
- value &= 0xFF;
- if ((R55x - value) < FilterTarget)
- {
- RF_R24_Value ++;
- }
- else if ((R55x - value) == FilterTarget)
- {
- RF_R24_Value ++;
- count ++;
- }
- else
- {
- break;
- }
-
- // prevent infinite loop cause driver hang.
- if (loopcnt++ > 100)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt));
- break;
- }
-
- // Write RF_R24 to program filter
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
- }
-
- if (count > 0)
- {
- RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
- }
-
- // Store for future usage
- if (loopcnt < 100)
- {
- if (loop++ == 0)
- {
- //BandWidth = 20 MHz
- pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value;
- }
- else
- {
- //BandWidth = 40 MHz
- pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value;
- break;
- }
- }
- else
- break;
-
- RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
-
- // reset count
- count = 0;
- } while(TRUE);
-
- //
- // Set back to initial state
- //
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
-
- RT30xxReadRFRegister(pAd, RF_R22, &value);
- value &= ~(0x01);
- RT30xxWriteRFRegister(pAd, RF_R22, value);
-
- // set BBP back to BW20
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue&= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
-}
-#endif // RT30xx //
-
-
-#ifdef RT3070
-VOID NICInitRT30xxRFRegisters(IN PRTMP_ADAPTER pAd)
-{
- INT i;
- // Driver must read EEPROM to get RfIcType before initial RF registers
- // Initialize RF register to default value
- if (IS_RT3070(pAd) || IS_RT3071(pAd))
- {
- // Init RF calibration
- // Driver should toggle RF R30 bit7 before init RF registers
- UINT32 RfReg = 0;
- UINT32 data;
-
- RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg);
- RfReg |= 0x80;
- RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
- RTMPusecDelay(1000);
- RfReg &= 0x7F;
- RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg);
-
- // Initialize RF register to default value
- for (i = 0; i < NUM_RF_REG_PARMS; i++)
- {
- RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value);
- }
-
- // add by johnli
- if (IS_RT3070(pAd))
- {
- // Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate
- RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
- data = ((data & 0xF0FFFFFF) | 0x0D000000);
- RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
- }
- else if (IS_RT3071(pAd))
- {
- // Driver should set RF R6 bit6 on before init RF registers
- RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg);
- RfReg |= 0x40;
- RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg);
-
- // init R31
- RT30xxWriteRFRegister(pAd, RF_R31, 0x14);
-
- // RT3071 version E has fixed this issue
- if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211))
- {
- // patch tx EVM issue temporarily
- RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
- data = ((data & 0xE0FFFFFF) | 0x0D000000);
- RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
- }
- else
- {
- RTMP_IO_READ32(pAd, LDO_CFG0, &data);
- data = ((data & 0xE0FFFFFF) | 0x01000000);
- RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
- }
-
- // patch LNA_PE_G1 failed issue
- RTUSBReadMACRegister(pAd, GPIO_SWITCH, &data);
- data &= ~(0x20);
- RTUSBWriteMACRegister(pAd, GPIO_SWITCH, data);
- }
-
- //For RF filter Calibration
- RTMPFilterCalibration(pAd);
-
- // Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration()
- if ((pAd->MACVersion & 0xffff) < 0x0211)
- RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
-
- // set led open drain enable
- RTUSBReadMACRegister(pAd, OPT_14, &data);
- data |= 0x01;
- RTUSBWriteMACRegister(pAd, OPT_14, data);
-
- if (IS_RT3071(pAd))
- {
- // add by johnli, RF power sequence setup, load RF normal operation-mode setup
- RT30xxLoadRFNormalModeSetup(pAd);
- }
- }
-
-}
-#endif // RT3070 //
-
-
-/*
- ========================================================================
-
- Routine Description:
- Read initial parameters from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID NICReadEEPROMParameters(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mac_addr)
-{
- UINT32 data = 0;
- USHORT i, value, value2;
- UCHAR TmpPhy;
- EEPROM_TX_PWR_STRUC Power;
- EEPROM_VERSION_STRUC Version;
- EEPROM_ANTENNA_STRUC Antenna;
- EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n"));
-
- // Init EEPROM Address Number, before access EEPROM; if 93c46, EEPROMAddressNum=6, else if 93c66, EEPROMAddressNum=8
- RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
- DBGPRINT(RT_DEBUG_TRACE, ("--> E2PROM_CSR = 0x%x\n", data));
-
- if((data & 0x30) == 0)
- pAd->EEPROMAddressNum = 6; // 93C46
- else if((data & 0x30) == 0x10)
- pAd->EEPROMAddressNum = 8; // 93C66
- else
- pAd->EEPROMAddressNum = 8; // 93C86
- DBGPRINT(RT_DEBUG_TRACE, ("--> EEPROMAddressNum = %d\n", pAd->EEPROMAddressNum ));
-
- // RT2860 MAC no longer auto load MAC address from E2PROM. Driver has to intialize
- // MAC address registers according to E2PROM setting
- if (mac_addr == NULL ||
- strlen(mac_addr) != 17 ||
- mac_addr[2] != ':' || mac_addr[5] != ':' || mac_addr[8] != ':' ||
- mac_addr[11] != ':' || mac_addr[14] != ':')
- {
- USHORT Addr01,Addr23,Addr45 ;
-
- RT28xx_EEPROM_READ16(pAd, 0x04, Addr01);
- RT28xx_EEPROM_READ16(pAd, 0x06, Addr23);
- RT28xx_EEPROM_READ16(pAd, 0x08, Addr45);
-
- pAd->PermanentAddress[0] = (UCHAR)(Addr01 & 0xff);
- pAd->PermanentAddress[1] = (UCHAR)(Addr01 >> 8);
- pAd->PermanentAddress[2] = (UCHAR)(Addr23 & 0xff);
- pAd->PermanentAddress[3] = (UCHAR)(Addr23 >> 8);
- pAd->PermanentAddress[4] = (UCHAR)(Addr45 & 0xff);
- pAd->PermanentAddress[5] = (UCHAR)(Addr45 >> 8);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from E2PROM \n"));
- }
- else
- {
- INT j;
- PUCHAR macptr;
-
- macptr = mac_addr;
-
- for (j=0; j<MAC_ADDR_LEN; j++)
- {
- AtoH(macptr, &pAd->PermanentAddress[j], 1);
- macptr=macptr+3;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from module parameter \n"));
- }
-
-
- {
- //more conveninet to test mbssid, so ap's bssid &0xf1
- if (pAd->PermanentAddress[0] == 0xff)
- pAd->PermanentAddress[0] = RandomByte(pAd)&0xf8;
-
- //if (pAd->PermanentAddress[5] == 0xff)
- // pAd->PermanentAddress[5] = RandomByte(pAd)&0xf8;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->PermanentAddress[0], pAd->PermanentAddress[1],
- pAd->PermanentAddress[2], pAd->PermanentAddress[3],
- pAd->PermanentAddress[4], pAd->PermanentAddress[5]));
- if (pAd->bLocalAdminMAC == FALSE)
- {
- MAC_DW0_STRUC csr2;
- MAC_DW1_STRUC csr3;
- COPY_MAC_ADDR(pAd->CurrentAddress, pAd->PermanentAddress);
- csr2.field.Byte0 = pAd->CurrentAddress[0];
- csr2.field.Byte1 = pAd->CurrentAddress[1];
- csr2.field.Byte2 = pAd->CurrentAddress[2];
- csr2.field.Byte3 = pAd->CurrentAddress[3];
- RTMP_IO_WRITE32(pAd, MAC_ADDR_DW0, csr2.word);
- csr3.word = 0;
- csr3.field.Byte4 = pAd->CurrentAddress[4];
- csr3.field.Byte5 = pAd->CurrentAddress[5];
- csr3.field.U2MeMask = 0xff;
- RTMP_IO_WRITE32(pAd, MAC_ADDR_DW1, csr3.word);
- DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->PermanentAddress[0], pAd->PermanentAddress[1],
- pAd->PermanentAddress[2], pAd->PermanentAddress[3],
- pAd->PermanentAddress[4], pAd->PermanentAddress[5]));
- }
- }
-
- // if not return early. cause fail at emulation.
- // Init the channel number for TX channel power
- RTMPReadChannelPwr(pAd);
-
- // if E2PROM version mismatch with driver's expectation, then skip
- // all subsequent E2RPOM retieval and set a system error bit to notify GUI
- RT28xx_EEPROM_READ16(pAd, EEPROM_VERSION_OFFSET, Version.word);
- pAd->EepromVersion = Version.field.Version + Version.field.FaeReleaseNumber * 256;
- DBGPRINT(RT_DEBUG_TRACE, ("E2PROM: Version = %d, FAE release #%d\n", Version.field.Version, Version.field.FaeReleaseNumber));
-
- if (Version.field.Version > VALID_EEPROM_VERSION)
- {
- DBGPRINT_ERR(("E2PROM: WRONG VERSION 0x%x, should be %d\n",Version.field.Version, VALID_EEPROM_VERSION));
- /*pAd->SystemErrorBitmap |= 0x00000001;
-
- // hard-code default value when no proper E2PROM installed
- pAd->bAutoTxAgcA = FALSE;
- pAd->bAutoTxAgcG = FALSE;
-
- // Default the channel power
- for (i = 0; i < MAX_NUM_OF_CHANNELS; i++)
- pAd->TxPower[i].Power = DEFAULT_RF_TX_POWER;
-
- // Default the channel power
- for (i = 0; i < MAX_NUM_OF_11JCHANNELS; i++)
- pAd->TxPower11J[i].Power = DEFAULT_RF_TX_POWER;
-
- for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++)
- pAd->EEPROMDefaultValue[i] = 0xffff;
- return; */
- }
-
- // Read BBP default value from EEPROM and store to array(EEPROMDefaultValue) in pAd
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, value);
- pAd->EEPROMDefaultValue[0] = value;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC2_OFFSET, value);
- pAd->EEPROMDefaultValue[1] = value;
-
- RT28xx_EEPROM_READ16(pAd, 0x38, value); // Country Region
- pAd->EEPROMDefaultValue[2] = value;
-
- for(i = 0; i < 8; i++)
- {
- RT28xx_EEPROM_READ16(pAd, EEPROM_BBP_BASE_OFFSET + i*2, value);
- pAd->EEPROMDefaultValue[i+3] = value;
- }
-
- // We have to parse NIC configuration 0 at here.
- // If TSSI did not have preloaded value, it should reset the TxAutoAgc to false
- // Therefore, we have to read TxAutoAgc control beforehand.
- // Read Tx AGC control bit
- Antenna.word = pAd->EEPROMDefaultValue[0];
- if (Antenna.word == 0xFFFF)
- {
-#ifdef RT30xx
- if(IS_RT3090(pAd))
- {
- Antenna.word = 0;
- Antenna.field.RfIcType = RFIC_3020;
- Antenna.field.TxPath = 1;
- Antenna.field.RxPath = 1;
- }
- else
- {
-#endif // RT30xx //
- Antenna.word = 0;
- Antenna.field.RfIcType = RFIC_2820;
- Antenna.field.TxPath = 1;
- Antenna.field.RxPath = 2;
- DBGPRINT(RT_DEBUG_WARN, ("E2PROM error, hard code as 0x%04x\n", Antenna.word));
-#ifdef RT30xx
- }
-#endif // RT30xx //
- }
-
- // Choose the desired Tx&Rx stream.
- if ((pAd->CommonCfg.TxStream == 0) || (pAd->CommonCfg.TxStream > Antenna.field.TxPath))
- pAd->CommonCfg.TxStream = Antenna.field.TxPath;
-
- if ((pAd->CommonCfg.RxStream == 0) || (pAd->CommonCfg.RxStream > Antenna.field.RxPath))
- {
- pAd->CommonCfg.RxStream = Antenna.field.RxPath;
-
- if ((pAd->MACVersion < RALINK_2883_VERSION) &&
- (pAd->CommonCfg.RxStream > 2))
- {
- // only 2 Rx streams for RT2860 series
- pAd->CommonCfg.RxStream = 2;
- }
- }
-
- // 3*3
- // read value from EEPROM and set them to CSR174 ~ 177 in chain0 ~ chain2
- // yet implement
- for(i=0; i<3; i++)
- {
- }
-
- NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((NicConfig2.word & 0x00ff) == 0xff)
- {
- NicConfig2.word &= 0xff00;
- }
-
- if ((NicConfig2.word >> 8) == 0xff)
- {
- NicConfig2.word &= 0x00ff;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (NicConfig2.field.DynamicTxAgcControl == 1)
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
- else
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("NICReadEEPROMParameters: RxPath = %d, TxPath = %d\n", Antenna.field.RxPath, Antenna.field.TxPath));
-
- // Save the antenna for future use
- pAd->Antenna.word = Antenna.word;
-
- //
- // Reset PhyMode if we don't support 802.11a
- // Only RFIC_2850 & RFIC_2750 support 802.11a
- //
- if ((Antenna.field.RfIcType != RFIC_2850) && (Antenna.field.RfIcType != RFIC_2750))
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11A))
- pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;
-#ifdef DOT11_N_SUPPORT
- else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) ||
- (pAd->CommonCfg.PhyMode == PHY_11N_5G))
- pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED;
-#endif // DOT11_N_SUPPORT //
- }
-
- // Read TSSI reference and TSSI boundary for temperature compensation. This is ugly
- // 0. 11b/g
- {
- /* these are tempature reference value (0x00 ~ 0xFE)
- ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- TssiPlusBoundaryG [4] [3] [2] [1] [0] (smaller) +
- TssiMinusBoundaryG[0] [1] [2] [3] [4] (larger) */
- RT28xx_EEPROM_READ16(pAd, 0x6E, Power.word);
- pAd->TssiMinusBoundaryG[4] = Power.field.Byte0;
- pAd->TssiMinusBoundaryG[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x70, Power.word);
- pAd->TssiMinusBoundaryG[2] = Power.field.Byte0;
- pAd->TssiMinusBoundaryG[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x72, Power.word);
- pAd->TssiRefG = Power.field.Byte0; /* reference value [0] */
- pAd->TssiPlusBoundaryG[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x74, Power.word);
- pAd->TssiPlusBoundaryG[2] = Power.field.Byte0;
- pAd->TssiPlusBoundaryG[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0x76, Power.word);
- pAd->TssiPlusBoundaryG[4] = Power.field.Byte0;
- pAd->TxAgcStepG = Power.field.Byte1;
- pAd->TxAgcCompensateG = 0;
- pAd->TssiMinusBoundaryG[0] = pAd->TssiRefG;
- pAd->TssiPlusBoundaryG[0] = pAd->TssiRefG;
-
- // Disable TxAgc if the based value is not right
- if (pAd->TssiRefG == 0xff)
- pAd->bAutoTxAgcG = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE,("E2PROM: G Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n",
- pAd->TssiMinusBoundaryG[4], pAd->TssiMinusBoundaryG[3], pAd->TssiMinusBoundaryG[2], pAd->TssiMinusBoundaryG[1],
- pAd->TssiRefG,
- pAd->TssiPlusBoundaryG[1], pAd->TssiPlusBoundaryG[2], pAd->TssiPlusBoundaryG[3], pAd->TssiPlusBoundaryG[4],
- pAd->TxAgcStepG, pAd->bAutoTxAgcG));
- }
- // 1. 11a
- {
- RT28xx_EEPROM_READ16(pAd, 0xD4, Power.word);
- pAd->TssiMinusBoundaryA[4] = Power.field.Byte0;
- pAd->TssiMinusBoundaryA[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xD6, Power.word);
- pAd->TssiMinusBoundaryA[2] = Power.field.Byte0;
- pAd->TssiMinusBoundaryA[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xD8, Power.word);
- pAd->TssiRefA = Power.field.Byte0;
- pAd->TssiPlusBoundaryA[1] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xDA, Power.word);
- pAd->TssiPlusBoundaryA[2] = Power.field.Byte0;
- pAd->TssiPlusBoundaryA[3] = Power.field.Byte1;
- RT28xx_EEPROM_READ16(pAd, 0xDC, Power.word);
- pAd->TssiPlusBoundaryA[4] = Power.field.Byte0;
- pAd->TxAgcStepA = Power.field.Byte1;
- pAd->TxAgcCompensateA = 0;
- pAd->TssiMinusBoundaryA[0] = pAd->TssiRefA;
- pAd->TssiPlusBoundaryA[0] = pAd->TssiRefA;
-
- // Disable TxAgc if the based value is not right
- if (pAd->TssiRefA == 0xff)
- pAd->bAutoTxAgcA = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE,("E2PROM: A Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n",
- pAd->TssiMinusBoundaryA[4], pAd->TssiMinusBoundaryA[3], pAd->TssiMinusBoundaryA[2], pAd->TssiMinusBoundaryA[1],
- pAd->TssiRefA,
- pAd->TssiPlusBoundaryA[1], pAd->TssiPlusBoundaryA[2], pAd->TssiPlusBoundaryA[3], pAd->TssiPlusBoundaryA[4],
- pAd->TxAgcStepA, pAd->bAutoTxAgcA));
- }
- pAd->BbpRssiToDbmDelta = 0x0;
-
- // Read frequency offset setting for RF
- RT28xx_EEPROM_READ16(pAd, EEPROM_FREQ_OFFSET, value);
- if ((value & 0x00FF) != 0x00FF)
- pAd->RfFreqOffset = (ULONG) (value & 0x00FF);
- else
- pAd->RfFreqOffset = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("E2PROM: RF FreqOffset=0x%lx \n", pAd->RfFreqOffset));
-
- //CountryRegion byte offset (38h)
- value = pAd->EEPROMDefaultValue[2] >> 8; // 2.4G band
- value2 = pAd->EEPROMDefaultValue[2] & 0x00FF; // 5G band
-
- if ((value <= REGION_MAXIMUM_BG_BAND) && (value2 <= REGION_MAXIMUM_A_BAND))
- {
- pAd->CommonCfg.CountryRegion = ((UCHAR) value) | 0x80;
- pAd->CommonCfg.CountryRegionForABand = ((UCHAR) value2) | 0x80;
- TmpPhy = pAd->CommonCfg.PhyMode;
- pAd->CommonCfg.PhyMode = 0xff;
- RTMPSetPhyMode(pAd, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
-
- //
- // Get RSSI Offset on EEPROM 0x9Ah & 0x9Ch.
- // The valid value are (-10 ~ 10)
- //
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, value);
- pAd->BGRssiOffset0 = value & 0x00ff;
- pAd->BGRssiOffset1 = (value >> 8);
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET+2, value);
- pAd->BGRssiOffset2 = value & 0x00ff;
- pAd->ALNAGain1 = (value >> 8);
- RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, value);
- pAd->BLNAGain = value & 0x00ff;
- pAd->ALNAGain0 = (value >> 8);
-
- // Validate 11b/g RSSI_0 offset.
- if ((pAd->BGRssiOffset0 < -10) || (pAd->BGRssiOffset0 > 10))
- pAd->BGRssiOffset0 = 0;
-
- // Validate 11b/g RSSI_1 offset.
- if ((pAd->BGRssiOffset1 < -10) || (pAd->BGRssiOffset1 > 10))
- pAd->BGRssiOffset1 = 0;
-
- // Validate 11b/g RSSI_2 offset.
- if ((pAd->BGRssiOffset2 < -10) || (pAd->BGRssiOffset2 > 10))
- pAd->BGRssiOffset2 = 0;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, value);
- pAd->ARssiOffset0 = value & 0x00ff;
- pAd->ARssiOffset1 = (value >> 8);
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET+2), value);
- pAd->ARssiOffset2 = value & 0x00ff;
- pAd->ALNAGain2 = (value >> 8);
-
- if (((UCHAR)pAd->ALNAGain1 == 0xFF) || (pAd->ALNAGain1 == 0x00))
- pAd->ALNAGain1 = pAd->ALNAGain0;
- if (((UCHAR)pAd->ALNAGain2 == 0xFF) || (pAd->ALNAGain2 == 0x00))
- pAd->ALNAGain2 = pAd->ALNAGain0;
-
- // Validate 11a RSSI_0 offset.
- if ((pAd->ARssiOffset0 < -10) || (pAd->ARssiOffset0 > 10))
- pAd->ARssiOffset0 = 0;
-
- // Validate 11a RSSI_1 offset.
- if ((pAd->ARssiOffset1 < -10) || (pAd->ARssiOffset1 > 10))
- pAd->ARssiOffset1 = 0;
-
- //Validate 11a RSSI_2 offset.
- if ((pAd->ARssiOffset2 < -10) || (pAd->ARssiOffset2 > 10))
- pAd->ARssiOffset2 = 0;
-
- //
- // Get LED Setting.
- //
- RT28xx_EEPROM_READ16(pAd, 0x3a, value);
- pAd->LedCntl.word = (value&0xff00) >> 8;
- RT28xx_EEPROM_READ16(pAd, EEPROM_LED1_OFFSET, value);
- pAd->Led1 = value;
- RT28xx_EEPROM_READ16(pAd, EEPROM_LED2_OFFSET, value);
- pAd->Led2 = value;
- RT28xx_EEPROM_READ16(pAd, EEPROM_LED3_OFFSET, value);
- pAd->Led3 = value;
-
- RTMPReadTxPwrPerRate(pAd);
-
-#ifdef SINGLE_SKU
- //pAd->CommonCfg.DefineMaxTxPwr = RTMP_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR);
- RT28xx_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR, pAd->CommonCfg.DefineMaxTxPwr);
-#endif // SINGLE_SKU //
-#ifdef RT30xx
- if (IS_RT30xx(pAd))
- {
- eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value);
- pAd->EFuseTag = (value & 0xff);
- }
-#endif // RT30xx //
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set default value from EEPROM
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID NICInitAsicFromEEPROM(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef CONFIG_STA_SUPPORT
- UINT32 data = 0;
- UCHAR BBPR1 = 0;
-#endif // CONFIG_STA_SUPPORT //
- USHORT i;
- EEPROM_ANTENNA_STRUC Antenna;
- EEPROM_NIC_CONFIG2_STRUC NicConfig2;
- UCHAR BBPR3 = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitAsicFromEEPROM\n"));
- for(i = 3; i < NUM_EEPROM_BBP_PARMS; i++)
- {
- UCHAR BbpRegIdx, BbpValue;
-
- if ((pAd->EEPROMDefaultValue[i] != 0xFFFF) && (pAd->EEPROMDefaultValue[i] != 0))
- {
- BbpRegIdx = (UCHAR)(pAd->EEPROMDefaultValue[i] >> 8);
- BbpValue = (UCHAR)(pAd->EEPROMDefaultValue[i] & 0xff);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BbpRegIdx, BbpValue);
- }
- }
-
- Antenna.word = pAd->EEPROMDefaultValue[0];
- if (Antenna.word == 0xFFFF)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("E2PROM error, hard code as 0x%04x\n", Antenna.word));
- BUG_ON(Antenna.word == 0xFFFF);
- }
- pAd->Mlme.RealRxPath = (UCHAR) Antenna.field.RxPath;
- pAd->RfIcType = (UCHAR) Antenna.field.RfIcType;
-
- DBGPRINT(RT_DEBUG_WARN, ("pAd->RfIcType = %d, RealRxPath=%d, TxPath = %d\n", pAd->RfIcType, pAd->Mlme.RealRxPath,Antenna.field.TxPath));
-
- // Save the antenna for future use
- pAd->Antenna.word = Antenna.word;
-
- NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((NicConfig2.word & 0x00ff) == 0xff)
- {
- NicConfig2.word &= 0xff00;
- }
-
- if ((NicConfig2.word >> 8) == 0xff)
- {
- NicConfig2.word &= 0x00ff;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Save the antenna for future use
- pAd->NicConfig2.word = NicConfig2.word;
-
- // set default antenna as main
- if (pAd->RfIcType == RFIC_3020)
- AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
-
- //
- // Send LED Setting to MCU.
- //
- if (pAd->LedCntl.word == 0xFF)
- {
- pAd->LedCntl.word = 0x01;
- pAd->Led1 = 0x5555;
- pAd->Led2 = 0x2221;
-
-#ifdef RT2870
- pAd->Led3 = 0x5627;
-#endif // RT2870 //
- }
-
- AsicSendCommandToMcu(pAd, 0x52, 0xff, (UCHAR)pAd->Led1, (UCHAR)(pAd->Led1 >> 8));
- AsicSendCommandToMcu(pAd, 0x53, 0xff, (UCHAR)pAd->Led2, (UCHAR)(pAd->Led2 >> 8));
- AsicSendCommandToMcu(pAd, 0x54, 0xff, (UCHAR)pAd->Led3, (UCHAR)(pAd->Led3 >> 8));
- pAd->LedIndicatorStregth = 0xFF;
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, before link up
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Read Hardware controlled Radio state enable bit
- if (NicConfig2.field.HardwareRadioControl == 1)
- {
- pAd->StaCfg.bHardwareRadio = TRUE;
-
- // Read GPIO pin2 as Hardware controlled radio state
- RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data);
- if ((data & 0x04) == 0)
- {
- pAd->StaCfg.bHwRadio = FALSE;
- pAd->StaCfg.bRadio = FALSE;
-// RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818);
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
- }
- }
- else
- pAd->StaCfg.bHardwareRadio = FALSE;
-
- if (pAd->StaCfg.bRadio == FALSE)
- {
- RTMPSetLED(pAd, LED_RADIO_OFF);
- }
- else
- {
- RTMPSetLED(pAd, LED_RADIO_ON);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Turn off patching for cardbus controller
- if (NicConfig2.field.CardbusAcceleration == 1)
- {
-// pAd->bTest1 = TRUE;
- }
-
- if (NicConfig2.field.DynamicTxAgcControl == 1)
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
- else
- pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
- //
- // Since BBP has been progamed, to make sure BBP setting will be
- // upate inside of AsicAntennaSelect, so reset to UNKNOWN_BAND!!
- //
- pAd->CommonCfg.BandState = UNKNOWN_BAND;
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
- BBPR3 &= (~0x18);
- if(pAd->Antenna.field.RxPath == 3)
- {
- BBPR3 |= (0x10);
- }
- else if(pAd->Antenna.field.RxPath == 2)
- {
- BBPR3 |= (0x8);
- }
- else if(pAd->Antenna.field.RxPath == 1)
- {
- BBPR3 |= (0x0);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Handle the difference when 1T
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BBPR1);
- if(pAd->Antenna.field.TxPath == 1)
- {
- BBPR1 &= (~0x18);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BBPR1);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n", pAd->CommonCfg.bHardwareRadio, pAd->CommonCfg.bHardwareRadio));
- }
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("TxPath = %d, RxPath = %d, RFIC=%d, Polar+LED mode=%x\n", pAd->Antenna.field.TxPath, pAd->Antenna.field.RxPath, pAd->RfIcType, pAd->LedCntl.word));
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitAsicFromEEPROM\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Initialize NIC hardware
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS NICInitializeAdapter(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset)
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- WPDMA_GLO_CFG_STRUC GloCfg;
-// INT_MASK_CSR_STRUC IntMask;
- ULONG i =0, j=0;
- AC_TXOP_CSR0_STRUC csr0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAdapter\n"));
-
- // 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits:
-retry:
- i = 0;
- do
- {
- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
- if ((GloCfg.field.TxDMABusy == 0) && (GloCfg.field.RxDMABusy == 0))
- break;
-
- RTMPusecDelay(1000);
- i++;
- }while ( i<100);
- DBGPRINT(RT_DEBUG_TRACE, ("<== DMA offset 0x208 = 0x%x\n", GloCfg.word));
- GloCfg.word &= 0xff0;
- GloCfg.field.EnTXWriteBackDDONE =1;
- RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
- // Record HW Beacon offset
- pAd->BeaconOffset[0] = HW_BEACON_BASE0;
- pAd->BeaconOffset[1] = HW_BEACON_BASE1;
- pAd->BeaconOffset[2] = HW_BEACON_BASE2;
- pAd->BeaconOffset[3] = HW_BEACON_BASE3;
- pAd->BeaconOffset[4] = HW_BEACON_BASE4;
- pAd->BeaconOffset[5] = HW_BEACON_BASE5;
- pAd->BeaconOffset[6] = HW_BEACON_BASE6;
- pAd->BeaconOffset[7] = HW_BEACON_BASE7;
-
- //
- // write all shared Ring's base address into ASIC
- //
-
- // asic simulation sequence put this ahead before loading firmware.
- // pbf hardware reset
-
- // Initialze ASIC for TX & Rx operation
- if (NICInitializeAsic(pAd , bHardReset) != NDIS_STATUS_SUCCESS)
- {
- if (j++ == 0)
- {
- NICLoadFirmware(pAd);
- goto retry;
- }
- return NDIS_STATUS_FAILURE;
- }
-
-
-
-
- // WMM parameter
- csr0.word = 0;
- RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
- if (pAd->CommonCfg.PhyMode == PHY_11B)
- {
- csr0.field.Ac0Txop = 192; // AC_VI: 192*32us ~= 6ms
- csr0.field.Ac1Txop = 96; // AC_VO: 96*32us ~= 3ms
- }
- else
- {
- csr0.field.Ac0Txop = 96; // AC_VI: 96*32us ~= 3ms
- csr0.field.Ac1Txop = 48; // AC_VO: 48*32us ~= 1.5ms
- }
- RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word);
-
-
-
-
- // reset action
- // Load firmware
- // Status = NICLoadFirmware(pAd);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAdapter\n"));
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Initialize ASIC
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS NICInitializeAsic(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset)
-{
- ULONG Index = 0;
- UCHAR R0 = 0xff;
- UINT32 MacCsr12 = 0, Counter = 0;
-#ifdef RT2870
- UINT32 MacCsr0 = 0;
- NTSTATUS Status;
- UCHAR Value = 0xff;
-#endif // RT2870 //
-#ifdef RT30xx
- UINT32 eFuseCtrl;
-#endif // RT30xx //
- USHORT KeyIdx;
- INT i,apidx;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n"));
-
-
-#ifdef RT2870
- //
- // Make sure MAC gets ready after NICLoadFirmware().
- //
- Index = 0;
-
- //To avoid hang-on issue when interface up in kernel 2.4,
- //we use a local variable "MacCsr0" instead of using "pAd->MACVersion" directly.
- do
- {
- RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-
- if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF))
- break;
-
- RTMPusecDelay(10);
- } while (Index++ < 100);
-
- pAd->MACVersion = MacCsr0;
- DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
- // turn on bit13 (set to zero) after rt2860D. This is to solve high-current issue.
- RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacCsr12);
- MacCsr12 &= (~0x2000);
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, MacCsr12);
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
- RTMP_IO_WRITE32(pAd, USB_DMA_CFG, 0x0);
- Status = RTUSBVenderReset(pAd);
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-
- // Initialize MAC register to default value
- for(Index=0; Index<NUM_MAC_REG_PARMS; Index++)
- {
-#ifdef RT3070
- if ((MACRegTable[Index].Register == TX_SW_CFG0) && (IS_RT3070(pAd) || IS_RT3071(pAd)))
- {
- MACRegTable[Index].Value = 0x00000400;
- }
-#endif // RT3070 //
- RTMP_IO_WRITE32(pAd, (USHORT)MACRegTable[Index].Register, MACRegTable[Index].Value);
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++)
- {
- RTMP_IO_WRITE32(pAd, (USHORT)STAMACRegTable[Index].Register, STAMACRegTable[Index].Value);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
-
-#ifdef RT30xx
- // Initialize RT3070 serial MAc registers which is different from RT2870 serial
- if (IS_RT3090(pAd))
- {
- RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
-
- // RT3071 version E has fixed this issue
- if ((pAd->MACVersion & 0xffff) < 0x0211)
- {
- if (pAd->NicConfig2.field.DACTestBit == 1)
- {
- RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x1F); // To fix throughput drop drastically
- }
- else
- {
- RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0F); // To fix throughput drop drastically
- }
- }
- else
- {
- RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0);
- }
- }
- else if (IS_RT3070(pAd))
- {
- RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
- RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x1F); // To fix throughput drop drastically
- }
-#endif // RT30xx //
-
- //
- // Before program BBP, we need to wait BBP/RF get wake up.
- //
- Index = 0;
- do
- {
- RTMP_IO_READ32(pAd, MAC_STATUS_CFG, &MacCsr12);
-
- if ((MacCsr12 & 0x03) == 0) // if BB.RF is stable
- break;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Check MAC_STATUS_CFG = Busy = %x\n", MacCsr12));
- RTMPusecDelay(1000);
- } while (Index++ < 100);
-
- // The commands to firmware should be after these commands, these commands will init firmware
- // PCI and USB are not the same because PCI driver needs to wait for PCI bus ready
- RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0); // initialize BBP R/W access agent
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
- RTMPusecDelay(1000);
-
- // Read BBP register, make sure BBP is up and running before write new data
- Index = 0;
- do
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R0, &R0);
- DBGPRINT(RT_DEBUG_TRACE, ("BBP version = %x\n", R0));
- } while ((++Index < 20) && ((R0 == 0xff) || (R0 == 0x00)));
- //ASSERT(Index < 20); //this will cause BSOD on Check-build driver
-
- if ((R0 == 0xff) || (R0 == 0x00))
- return NDIS_STATUS_FAILURE;
-
- // Initialize BBP register to default value
- for (Index = 0; Index < NUM_BBP_REG_PARMS; Index++)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, BBPRegTable[Index].Value);
- }
-
- // for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT.
- // RT3090 should not program BBP R84 to 0x19, otherwise TX will block.
- if (((pAd->MACVersion&0xffff) != 0x0101) && (!IS_RT30xx(pAd)))
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
-
-// add by johnli, RF power sequence setup
-#ifdef RT30xx
- if (IS_RT30xx(pAd))
- { //update for RT3070/71/72/90/91/92.
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R79, 0x13);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R80, 0x05);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R81, 0x33);
- }
-
- if (IS_RT3090(pAd))
- {
- UCHAR bbpreg=0;
-
- // enable DC filter
- if ((pAd->MACVersion & 0xffff) >= 0x0211)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0);
- }
-
- // improve power consumption
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R138, &bbpreg);
- if (pAd->Antenna.field.TxPath == 1)
- {
- // turn off tx DAC_1
- bbpreg = (bbpreg | 0x20);
- }
-
- if (pAd->Antenna.field.RxPath == 1)
- {
- // turn off tx ADC_1
- bbpreg &= (~0x2);
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R138, bbpreg);
-
- // improve power consumption in RT3071 Ver.E
- if ((pAd->MACVersion & 0xffff) >= 0x0211)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg);
- bbpreg &= (~0x3);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg);
- }
- }
-#endif // RT30xx //
-// end johnli
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x12);
- }
-
- if (pAd->MACVersion >= RALINK_2880E_VERSION && pAd->MACVersion < RALINK_3070_VERSION) // 3*3
- {
- // enlarge MAX_LEN_CFG
- UINT32 csr;
- RTMP_IO_READ32(pAd, MAX_LEN_CFG, &csr);
- csr &= 0xFFF;
- csr |= 0x2000;
- RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, csr);
- }
-
-#ifdef RT2870
-{
- UCHAR MAC_Value[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0,0};
-
- //Initialize WCID table
- Value = 0xff;
- for(Index =0 ;Index < 254;Index++)
- {
- RTUSBMultiWrite(pAd, (USHORT)(MAC_WCID_BASE + Index * 8), MAC_Value, 8);
- }
-}
-#endif // RT2870 //
-
- // Add radio off control
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pAd->StaCfg.bRadio == FALSE)
- {
-// RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818);
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
- DBGPRINT(RT_DEBUG_TRACE, ("Set Radio Off\n"));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Clear raw counters
- RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
-
- // ASIC will keep garbage value after boot
- // Clear all seared key table when initial
- // This routine can be ignored in radio-ON/OFF operation.
- if (bHardReset)
- {
- for (KeyIdx = 0; KeyIdx < 4; KeyIdx++)
- {
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4*KeyIdx, 0);
- }
-
- // Clear all pairwise key table when initial
- for (KeyIdx = 0; KeyIdx < 256; KeyIdx++)
- {
- RTMP_IO_WRITE32(pAd, MAC_WCID_ATTRIBUTE_BASE + (KeyIdx * HW_WCID_ATTRI_SIZE), 1);
- }
- }
-
- // assert HOST ready bit
-// RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x0); // 2004-09-14 asked by Mark
-// RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x4);
-
- // It isn't necessary to clear this space when not hard reset.
- if (bHardReset == TRUE)
- {
- // clear all on-chip BEACON frame space
- for (apidx = 0; apidx < HW_BEACON_MAX_COUNT; apidx++)
- {
- for (i = 0; i < HW_BEACON_OFFSET>>2; i+=4)
- RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[apidx] + i, 0x00);
- }
- }
-#ifdef RT2870
- AsicDisableSync(pAd);
- // Clear raw counters
- RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
- RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
- // Default PCI clock cycle per ms is different as default setting, which is based on PCI.
- RTMP_IO_READ32(pAd, USB_CYC_CFG, &Counter);
- Counter&=0xffffff00;
- Counter|=0x000001e;
- RTMP_IO_WRITE32(pAd, USB_CYC_CFG, Counter);
-#endif // RT2870 //
-#ifdef RT30xx
- pAd->bUseEfuse=FALSE;
- RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl);
- pAd->bUseEfuse = ( (eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
- if(pAd->bUseEfuse)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("NVM is Efuse\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n"));
-
- }
-#endif // RT30xx //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // for rt2860E and after, init TXOP_CTRL_CFG with 0x583f. This is for extension channel overlapping IOT.
- if ((pAd->MACVersion&0xffff) != 0x0101)
- RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x583f);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAsic\n"));
- return NDIS_STATUS_SUCCESS;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Reset NIC Asics
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
- Reset NIC to initial state AS IS system boot up time.
-
- ========================================================================
-*/
-VOID NICIssueReset(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 Value = 0;
- DBGPRINT(RT_DEBUG_TRACE, ("--> NICIssueReset\n"));
-
- // Abort Tx, prevent ASIC from writing to Host memory
- //RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x001f0000);
-
- // Disable Rx, register value supposed will remain after reset
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= (0xfffffff3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Issue reset and clear from reset state
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x03); // 2004-09-17 change from 0x01
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x00);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- NICIssueReset\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check ASIC registers and find any reason the system might hang
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-BOOLEAN NICCheckForHang(
- IN PRTMP_ADAPTER pAd)
-{
- return (FALSE);
-}
-
-VOID NICUpdateFifoStaCounters(
- IN PRTMP_ADAPTER pAd)
-{
- TX_STA_FIFO_STRUC StaFifo;
- MAC_TABLE_ENTRY *pEntry;
- UCHAR i = 0;
- UCHAR pid = 0, wcid = 0;
- CHAR reTry;
- UCHAR succMCS;
-
-#ifdef RALINK_ATE
- /* Nothing to do in ATE mode */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- do
- {
- RTMP_IO_READ32(pAd, TX_STA_FIFO, &StaFifo.word);
-
- if (StaFifo.field.bValid == 0)
- break;
-
- wcid = (UCHAR)StaFifo.field.wcid;
-
-
- /* ignore NoACK and MGMT frame use 0xFF as WCID */
- if ((StaFifo.field.TxAckRequired == 0) || (wcid >= MAX_LEN_OF_MAC_TABLE))
- {
- i++;
- continue;
- }
-
- /* PID store Tx MCS Rate */
- pid = (UCHAR)StaFifo.field.PidType;
-
- pEntry = &pAd->MacTab.Content[wcid];
-
- pEntry->DebugFIFOCount++;
-
-#ifdef DOT11_N_SUPPORT
- if (StaFifo.field.TxBF) // 3*3
- pEntry->TxBFCount++;
-#endif // DOT11_N_SUPPORT //
-
-#ifdef UAPSD_AP_SUPPORT
- UAPSD_SP_AUE_Handle(pAd, pEntry, StaFifo.field.TxSuccess);
-#endif // UAPSD_AP_SUPPORT //
-
- if (!StaFifo.field.TxSuccess)
- {
- pEntry->FIFOCount++;
- pEntry->OneSecTxFailCount++;
-
- if (pEntry->FIFOCount >= 1)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("#"));
-#ifdef DOT11_N_SUPPORT
- pEntry->NoBADataCountDown = 64;
-#endif // DOT11_N_SUPPORT //
-
- if(pEntry->PsMode == PWR_ACTIVE)
- {
-#ifdef DOT11_N_SUPPORT
- int tid;
- for (tid=0; tid<NUM_OF_TID; tid++)
- {
- BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
- // Update the continuous transmission counter except PS mode
- pEntry->ContinueTxFailCnt++;
- }
- else
- {
- // Clear the FIFOCount when sta in Power Save mode. Basically we assume
- // this tx error happened due to sta just go to sleep.
- pEntry->FIFOCount = 0;
- pEntry->ContinueTxFailCnt = 0;
- }
- //pEntry->FIFOCount = 0;
- }
- //pEntry->bSendBAR = TRUE;
- }
- else
- {
-#ifdef DOT11_N_SUPPORT
- if ((pEntry->PsMode != PWR_SAVE) && (pEntry->NoBADataCountDown > 0))
- {
- pEntry->NoBADataCountDown--;
- if (pEntry->NoBADataCountDown==0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("@\n"));
- }
- }
-#endif // DOT11_N_SUPPORT //
- pEntry->FIFOCount = 0;
- pEntry->OneSecTxNoRetryOkCount++;
- // update NoDataIdleCount when sucessful send packet to STA.
- pEntry->NoDataIdleCount = 0;
- pEntry->ContinueTxFailCnt = 0;
- }
-
- succMCS = StaFifo.field.SuccessRate & 0x7F;
-
- reTry = pid - succMCS;
-
- if (StaFifo.field.TxSuccess)
- {
- pEntry->TXMCSExpected[pid]++;
- if (pid == succMCS)
- {
- pEntry->TXMCSSuccessful[pid]++;
- }
- else
- {
- pEntry->TXMCSAutoFallBack[pid][succMCS]++;
- }
- }
- else
- {
- pEntry->TXMCSFailed[pid]++;
- }
-
- if (reTry > 0)
- {
- if ((pid >= 12) && succMCS <=7)
- {
- reTry -= 4;
- }
- pEntry->OneSecTxRetryOkCount += reTry;
- }
-
- i++;
- // ASIC store 16 stack
- } while ( i < (2*TX_RING_SIZE) );
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Read statistical counters from hardware registers and record them
- in software variables for later on query
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID NICUpdateRawCounters(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 OldValue;//, Value2;
- //ULONG PageSum, OneSecTransmitCount;
- //ULONG TxErrorRatio, Retry, Fail;
- RX_STA_CNT0_STRUC RxStaCnt0;
- RX_STA_CNT1_STRUC RxStaCnt1;
- RX_STA_CNT2_STRUC RxStaCnt2;
- TX_STA_CNT0_STRUC TxStaCnt0;
- TX_STA_CNT1_STRUC StaTx1;
- TX_STA_CNT2_STRUC StaTx2;
- TX_AGG_CNT_STRUC TxAggCnt;
- TX_AGG_CNT0_STRUC TxAggCnt0;
- TX_AGG_CNT1_STRUC TxAggCnt1;
- TX_AGG_CNT2_STRUC TxAggCnt2;
- TX_AGG_CNT3_STRUC TxAggCnt3;
- TX_AGG_CNT4_STRUC TxAggCnt4;
- TX_AGG_CNT5_STRUC TxAggCnt5;
- TX_AGG_CNT6_STRUC TxAggCnt6;
- TX_AGG_CNT7_STRUC TxAggCnt7;
-
- RTMP_IO_READ32(pAd, RX_STA_CNT0, &RxStaCnt0.word);
- RTMP_IO_READ32(pAd, RX_STA_CNT2, &RxStaCnt2.word);
-
- {
- RTMP_IO_READ32(pAd, RX_STA_CNT1, &RxStaCnt1.word);
- // Update RX PLCP error counter
- pAd->PrivateInfo.PhyRxErrCnt += RxStaCnt1.field.PlcpErr;
- // Update False CCA counter
- pAd->RalinkCounters.OneSecFalseCCACnt += RxStaCnt1.field.FalseCca;
- }
-
- // Update FCS counters
- OldValue= pAd->WlanCounters.FCSErrorCount.u.LowPart;
- pAd->WlanCounters.FCSErrorCount.u.LowPart += (RxStaCnt0.field.CrcErr); // >> 7);
- if (pAd->WlanCounters.FCSErrorCount.u.LowPart < OldValue)
- pAd->WlanCounters.FCSErrorCount.u.HighPart++;
-
- // Add FCS error count to private counters
- pAd->RalinkCounters.OneSecRxFcsErrCnt += RxStaCnt0.field.CrcErr;
- OldValue = pAd->RalinkCounters.RealFcsErrCount.u.LowPart;
- pAd->RalinkCounters.RealFcsErrCount.u.LowPart += RxStaCnt0.field.CrcErr;
- if (pAd->RalinkCounters.RealFcsErrCount.u.LowPart < OldValue)
- pAd->RalinkCounters.RealFcsErrCount.u.HighPart++;
-
- // Update Duplicate Rcv check
- pAd->RalinkCounters.DuplicateRcv += RxStaCnt2.field.RxDupliCount;
- pAd->WlanCounters.FrameDuplicateCount.u.LowPart += RxStaCnt2.field.RxDupliCount;
- // Update RX Overflow counter
- pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount);
-
- //pAd->RalinkCounters.RxCount = 0;
-#ifdef RT2870
- if (pAd->RalinkCounters.RxCount != pAd->watchDogRxCnt)
- {
- pAd->watchDogRxCnt = pAd->RalinkCounters.RxCount;
- pAd->watchDogRxOverFlowCnt = 0;
- }
- else
- {
- if (RxStaCnt2.field.RxFifoOverflowCount)
- pAd->watchDogRxOverFlowCnt++;
- else
- pAd->watchDogRxOverFlowCnt = 0;
- }
-#endif // RT2870 //
-
-
- //if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) ||
- // (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) && (pAd->MacTab.Size != 1)))
- if (!pAd->bUpdateBcnCntDone)
- {
- // Update BEACON sent count
- RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
- RTMP_IO_READ32(pAd, TX_STA_CNT2, &StaTx2.word);
- pAd->RalinkCounters.OneSecBeaconSentCnt += TxStaCnt0.field.TxBeaconCount;
- pAd->RalinkCounters.OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
- pAd->RalinkCounters.OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
- pAd->RalinkCounters.OneSecTxFailCount += TxStaCnt0.field.TxFailCount;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
- pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
- pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
- }
-
- //if (pAd->bStaFifoTest == TRUE)
- {
- RTMP_IO_READ32(pAd, TX_AGG_CNT, &TxAggCnt.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT0, &TxAggCnt0.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT1, &TxAggCnt1.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT2, &TxAggCnt2.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT3, &TxAggCnt3.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT4, &TxAggCnt4.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT5, &TxAggCnt5.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT6, &TxAggCnt6.word);
- RTMP_IO_READ32(pAd, TX_AGG_CNT7, &TxAggCnt7.word);
- pAd->RalinkCounters.TxAggCount += TxAggCnt.field.AggTxCount;
- pAd->RalinkCounters.TxNonAggCount += TxAggCnt.field.NonAggTxCount;
- pAd->RalinkCounters.TxAgg1MPDUCount += TxAggCnt0.field.AggSize1Count;
- pAd->RalinkCounters.TxAgg2MPDUCount += TxAggCnt0.field.AggSize2Count;
-
- pAd->RalinkCounters.TxAgg3MPDUCount += TxAggCnt1.field.AggSize3Count;
- pAd->RalinkCounters.TxAgg4MPDUCount += TxAggCnt1.field.AggSize4Count;
- pAd->RalinkCounters.TxAgg5MPDUCount += TxAggCnt2.field.AggSize5Count;
- pAd->RalinkCounters.TxAgg6MPDUCount += TxAggCnt2.field.AggSize6Count;
-
- pAd->RalinkCounters.TxAgg7MPDUCount += TxAggCnt3.field.AggSize7Count;
- pAd->RalinkCounters.TxAgg8MPDUCount += TxAggCnt3.field.AggSize8Count;
- pAd->RalinkCounters.TxAgg9MPDUCount += TxAggCnt4.field.AggSize9Count;
- pAd->RalinkCounters.TxAgg10MPDUCount += TxAggCnt4.field.AggSize10Count;
-
- pAd->RalinkCounters.TxAgg11MPDUCount += TxAggCnt5.field.AggSize11Count;
- pAd->RalinkCounters.TxAgg12MPDUCount += TxAggCnt5.field.AggSize12Count;
- pAd->RalinkCounters.TxAgg13MPDUCount += TxAggCnt6.field.AggSize13Count;
- pAd->RalinkCounters.TxAgg14MPDUCount += TxAggCnt6.field.AggSize14Count;
-
- pAd->RalinkCounters.TxAgg15MPDUCount += TxAggCnt7.field.AggSize15Count;
- pAd->RalinkCounters.TxAgg16MPDUCount += TxAggCnt7.field.AggSize16Count;
-
- // Calculate the transmitted A-MPDU count
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += TxAggCnt0.field.AggSize1Count;
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt0.field.AggSize2Count / 2);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt1.field.AggSize3Count / 3);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt1.field.AggSize4Count / 4);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt2.field.AggSize5Count / 5);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt2.field.AggSize6Count / 6);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt3.field.AggSize7Count / 7);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt3.field.AggSize8Count / 8);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt4.field.AggSize9Count / 9);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt4.field.AggSize10Count / 10);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt5.field.AggSize11Count / 11);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt5.field.AggSize12Count / 12);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize13Count / 13);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize14Count / 14);
-
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize15Count / 15);
- pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize16Count / 16);
- }
-
-#ifdef DBG_DIAGNOSE
- {
- RtmpDiagStruct *pDiag;
- COUNTER_RALINK *pRalinkCounters;
- UCHAR ArrayCurIdx, i;
-
- pDiag = &pAd->DiagStruct;
- pRalinkCounters = &pAd->RalinkCounters;
- ArrayCurIdx = pDiag->ArrayCurIdx;
-
- if (pDiag->inited == 0)
- {
- NdisZeroMemory(pDiag, sizeof(struct _RtmpDiagStrcut_));
- pDiag->ArrayStartIdx = pDiag->ArrayCurIdx = 0;
- pDiag->inited = 1;
- }
- else
- {
- // Tx
- pDiag->TxFailCnt[ArrayCurIdx] = TxStaCnt0.field.TxFailCount;
- pDiag->TxAggCnt[ArrayCurIdx] = TxAggCnt.field.AggTxCount;
- pDiag->TxNonAggCnt[ArrayCurIdx] = TxAggCnt.field.NonAggTxCount;
- pDiag->TxAMPDUCnt[ArrayCurIdx][0] = TxAggCnt0.field.AggSize1Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][1] = TxAggCnt0.field.AggSize2Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][2] = TxAggCnt1.field.AggSize3Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][3] = TxAggCnt1.field.AggSize4Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][4] = TxAggCnt2.field.AggSize5Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][5] = TxAggCnt2.field.AggSize6Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][6] = TxAggCnt3.field.AggSize7Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][7] = TxAggCnt3.field.AggSize8Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][8] = TxAggCnt4.field.AggSize9Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][9] = TxAggCnt4.field.AggSize10Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][10] = TxAggCnt5.field.AggSize11Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][11] = TxAggCnt5.field.AggSize12Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][12] = TxAggCnt6.field.AggSize13Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][13] = TxAggCnt6.field.AggSize14Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][14] = TxAggCnt7.field.AggSize15Count;
- pDiag->TxAMPDUCnt[ArrayCurIdx][15] = TxAggCnt7.field.AggSize16Count;
-
- pDiag->RxCrcErrCnt[ArrayCurIdx] = RxStaCnt0.field.CrcErr;
-
- INC_RING_INDEX(pDiag->ArrayCurIdx, DIAGNOSE_TIME);
- ArrayCurIdx = pDiag->ArrayCurIdx;
- for (i =0; i < 9; i++)
- {
- pDiag->TxDescCnt[ArrayCurIdx][i]= 0;
- pDiag->TxSWQueCnt[ArrayCurIdx][i] =0;
- pDiag->TxMcsCnt[ArrayCurIdx][i] = 0;
- pDiag->RxMcsCnt[ArrayCurIdx][i] = 0;
- }
- pDiag->TxDataCnt[ArrayCurIdx] = 0;
- pDiag->TxFailCnt[ArrayCurIdx] = 0;
- pDiag->RxDataCnt[ArrayCurIdx] = 0;
- pDiag->RxCrcErrCnt[ArrayCurIdx] = 0;
-// for (i = 9; i < 16; i++)
- for (i = 9; i < 24; i++) // 3*3
- {
- pDiag->TxDescCnt[ArrayCurIdx][i] = 0;
- pDiag->TxMcsCnt[ArrayCurIdx][i] = 0;
- pDiag->RxMcsCnt[ArrayCurIdx][i] = 0;
-}
-
- if (pDiag->ArrayCurIdx == pDiag->ArrayStartIdx)
- INC_RING_INDEX(pDiag->ArrayStartIdx, DIAGNOSE_TIME);
- }
-
- }
-#endif // DBG_DIAGNOSE //
-
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Reset NIC from error
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
- Reset NIC from error state
-
- ========================================================================
-*/
-VOID NICResetFromError(
- IN PRTMP_ADAPTER pAd)
-{
- // Reset BBP (according to alex, reset ASIC will force reset BBP
- // Therefore, skip the reset BBP
- // RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x2);
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
- // Remove ASIC from reset state
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-
- NICInitializeAdapter(pAd, FALSE);
- NICInitAsicFromEEPROM(pAd);
-
- // Switch to current channel, since during reset process, the connection should remains on.
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- erase 8051 firmware image in MAC ASIC
-
- Arguments:
- Adapter Pointer to our adapter
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-VOID NICEraseFirmware(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
-
- for(i=0; i<MAX_FIRMWARE_IMAGE_SIZE; i+=4)
- RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, 0);
-
-}/* End of NICEraseFirmware */
-
-/*
- ========================================================================
-
- Routine Description:
- Load 8051 firmware RT2561.BIN file into MAC ASIC
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- NDIS_STATUS_SUCCESS firmware image load ok
- NDIS_STATUS_FAILURE image not found
-
- IRQL = PASSIVE_LEVEL
-
- ========================================================================
-*/
-NDIS_STATUS NICLoadFirmware(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef BIN_IN_FILE
-#define NICLF_DEFAULT_USE() \
- flg_default_firm_use = TRUE; \
- printk("%s - Use default firmware!\n", __FUNCTION__);
-
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR src;
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid, i;
- mm_segment_t orgfs;
- PUCHAR pFirmwareImage;
- UINT FileLength = 0;
- UINT32 MacReg;
- ULONG Index;
- ULONG firm;
- BOOLEAN flg_default_firm_use = FALSE;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __FUNCTION__));
-
- /* init */
- pFirmwareImage = NULL;
- src = RTMP_FIRMWARE_FILE_NAME;
-
- /* save uid and gid used for filesystem access.
- set user and group to 0 (root) */
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- pAd->FirmwareVersion = (FIRMWARE_MAJOR_VERSION << 8) + \
- FIRMWARE_MINOR_VERSION;
-
-
- /* allocate firmware buffer */
- pFirmwareImage = kmalloc(MAX_FIRMWARE_IMAGE_SIZE, MEM_ALLOC_FLAG);
- if (pFirmwareImage == NULL)
- {
- /* allocate fail, use default firmware array in firmware.h */
- printk("%s - Allocate memory fail!\n", __FUNCTION__);
- NICLF_DEFAULT_USE();
- }
- else
- {
- /* allocate ok! zero the firmware buffer */
- memset(pFirmwareImage, 0x00, MAX_FIRMWARE_IMAGE_SIZE);
- } /* End of if */
-
-
- /* if ok, read firmware file from *.bin file */
- if (flg_default_firm_use == FALSE)
- {
- do
- {
- /* open the bin file */
- srcf = filp_open(src, O_RDONLY, 0);
-
- if (IS_ERR(srcf))
- {
- printk("%s - Error %ld opening %s\n",
- __FUNCTION__, -PTR_ERR(srcf), src);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
-
- /* the object must have a read method */
- if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
- {
- printk("%s - %s does not have a write method\n", __FUNCTION__, src);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
-
- /* read the firmware from the file *.bin */
- FileLength = srcf->f_op->read(srcf,
- pFirmwareImage,
- MAX_FIRMWARE_IMAGE_SIZE,
- &srcf->f_pos);
-
- if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
- {
- printk("%s: error file length (=%d) in RT2860AP.BIN\n",
- __FUNCTION__, FileLength);
- NICLF_DEFAULT_USE();
- break;
- }
- else
- {
- PUCHAR ptr = pFirmwareImage;
- USHORT crc = 0xffff;
-
-
- /* calculate firmware CRC */
- for(i=0; i<(MAX_FIRMWARE_IMAGE_SIZE-2); i++, ptr++)
- crc = ByteCRC16(BitReverse(*ptr), crc);
- /* End of for */
-
- if ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2] != \
- (UCHAR)BitReverse((UCHAR)(crc>>8))) ||
- (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1] != \
- (UCHAR)BitReverse((UCHAR)crc)))
- {
- /* CRC fail */
- printk("%s: CRC = 0x%02x 0x%02x "
- "error, should be 0x%02x 0x%02x\n",
- __FUNCTION__,
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
- (UCHAR)(crc>>8), (UCHAR)(crc));
- NICLF_DEFAULT_USE();
- break;
- }
- else
- {
- /* firmware is ok */
- pAd->FirmwareVersion = \
- (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4] << 8) +
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3];
-
- /* check if firmware version of the file is too old */
- if ((pAd->FirmwareVersion) < \
- ((FIRMWARE_MAJOR_VERSION << 8) +
- FIRMWARE_MINOR_VERSION))
- {
- printk("%s: firmware version too old!\n", __FUNCTION__);
- NICLF_DEFAULT_USE();
- break;
- } /* End of if */
- } /* End of if */
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("NICLoadFirmware: CRC ok, ver=%d.%d\n",
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4],
- pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3]));
- } /* End of if (FileLength == MAX_FIRMWARE_IMAGE_SIZE) */
- break;
- } while(TRUE);
-
- /* close firmware file */
- if (IS_ERR(srcf))
- ;
- else
- {
- retval = filp_close(srcf, NULL);
- if (retval)
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("--> Error %d closing %s\n", -retval, src));
- } /* End of if */
- } /* End of if */
- } /* End of if */
-
-
- /* write firmware to ASIC */
- if (flg_default_firm_use == TRUE)
- {
- /* use default fimeware, free allocated buffer */
- if (pFirmwareImage != NULL)
- kfree(pFirmwareImage);
- /* End of if */
-
- /* use default *.bin array */
- pFirmwareImage = FirmwareImage;
- FileLength = sizeof(FirmwareImage);
- } /* End of if */
-
- /* enable Host program ram write selection */
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x10000);
-
- for(i=0; i<FileLength; i+=4)
- {
- firm = pFirmwareImage[i] +
- (pFirmwareImage[i+3] << 24) +
- (pFirmwareImage[i+2] << 16) +
- (pFirmwareImage[i+1] << 8);
-
- RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, firm);
- } /* End of for */
-
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00000);
- RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00001);
-
- /* initialize BBP R/W access agent */
- RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0);
- RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
-
- if (flg_default_firm_use == FALSE)
- {
- /* use file firmware, free allocated buffer */
- if (pFirmwareImage != NULL)
- kfree(pFirmwareImage);
- /* End of if */
- } /* End of if */
-
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
-#else
-
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR pFirmwareImage;
- ULONG FileLength, Index;
- //ULONG firm;
- UINT32 MacReg = 0;
- UINT32 Version = (pAd->MACVersion >> 16);
-
- pFirmwareImage = FirmwareImage;
- FileLength = sizeof(FirmwareImage);
-
- // New 8k byte firmware size for RT3071/RT3072
- //printk("Usb Chip\n");
- if (FIRMWAREIMAGE_LENGTH == FIRMWAREIMAGE_MAX_LENGTH)
- //The firmware image consists of two parts. One is the origianl and the other is the new.
- //Use Second Part
- {
-#ifdef RT2870
- if ((Version != 0x2860) && (Version != 0x2872) && (Version != 0x3070))
- { // Use Firmware V2.
- //printk("KH:Use New Version,part2\n");
- pFirmwareImage = (PUCHAR)&FirmwareImage[FIRMWAREIMAGEV1_LENGTH];
- FileLength = FIRMWAREIMAGEV2_LENGTH;
- }
- else
- {
- //printk("KH:Use New Version,part1\n");
- pFirmwareImage = FirmwareImage;
- FileLength = FIRMWAREIMAGEV1_LENGTH;
- }
-#endif // RT2870 //
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("KH: bin file should be 8KB.\n"));
- Status = NDIS_STATUS_FAILURE;
- }
-
- RT28XX_WRITE_FIRMWARE(pAd, pFirmwareImage, FileLength);
-
-#endif
-
- /* check if MCU is ready */
- Index = 0;
- do
- {
- RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacReg);
-
- if (MacReg & 0x80)
- break;
-
- RTMPusecDelay(1000);
- } while (Index++ < 1000);
-
- if (Index >= 1000)
- {
- Status = NDIS_STATUS_FAILURE;
- DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
- } /* End of if */
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("<=== %s (status=%d)\n", __FUNCTION__, Status));
- return Status;
-} /* End of NICLoadFirmware */
-
-
-/*
- ========================================================================
-
- Routine Description:
- Load Tx rate switching parameters
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- NDIS_STATUS_SUCCESS firmware image load ok
- NDIS_STATUS_FAILURE image not found
-
- IRQL = PASSIVE_LEVEL
-
- Rate Table Format:
- 1. (B0: Valid Item number) (B1:Initial item from zero)
- 2. Item Number(Dec) Mode(Hex) Current MCS(Dec) TrainUp(Dec) TrainDown(Dec)
-
- ========================================================================
-*/
-NDIS_STATUS NICLoadRateSwitchingParams(
- IN PRTMP_ADAPTER pAd)
-{
- return NDIS_STATUS_SUCCESS;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- if pSrc1 all zero with length Length, return 0.
- If not all zero, return 1
-
- Arguments:
- pSrc1
-
- Return Value:
- 1: not all zero
- 0: all zero
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-ULONG RTMPNotAllZero(
- IN PVOID pSrc1,
- IN ULONG Length)
-{
- PUCHAR pMem1;
- ULONG Index = 0;
-
- pMem1 = (PUCHAR) pSrc1;
-
- for (Index = 0; Index < Length; Index++)
- {
- if (pMem1[Index] != 0x0)
- {
- break;
- }
- }
-
- if (Index == Length)
- {
- return (0);
- }
- else
- {
- return (1);
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Compare two memory block
-
- Arguments:
- pSrc1 Pointer to first memory address
- pSrc2 Pointer to second memory address
-
- Return Value:
- 0: memory is equal
- 1: pSrc1 memory is larger
- 2: pSrc2 memory is larger
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-ULONG RTMPCompareMemory(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- IN ULONG Length)
-{
- PUCHAR pMem1;
- PUCHAR pMem2;
- ULONG Index = 0;
-
- pMem1 = (PUCHAR) pSrc1;
- pMem2 = (PUCHAR) pSrc2;
-
- for (Index = 0; Index < Length; Index++)
- {
- if (pMem1[Index] > pMem2[Index])
- return (1);
- else if (pMem1[Index] < pMem2[Index])
- return (2);
- }
-
- // Equal
- return (0);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Zero out memory block
-
- Arguments:
- pSrc1 Pointer to memory address
- Length Size
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPZeroMemory(
- IN PVOID pSrc,
- IN ULONG Length)
-{
- PUCHAR pMem;
- ULONG Index = 0;
-
- pMem = (PUCHAR) pSrc;
-
- for (Index = 0; Index < Length; Index++)
- {
- pMem[Index] = 0x00;
- }
-}
-
-VOID RTMPFillMemory(
- IN PVOID pSrc,
- IN ULONG Length,
- IN UCHAR Fill)
-{
- PUCHAR pMem;
- ULONG Index = 0;
-
- pMem = (PUCHAR) pSrc;
-
- for (Index = 0; Index < Length; Index++)
- {
- pMem[Index] = Fill;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Copy data from memory block 1 to memory block 2
-
- Arguments:
- pDest Pointer to destination memory address
- pSrc Pointer to source memory address
- Length Copy size
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPMoveMemory(
- OUT PVOID pDest,
- IN PVOID pSrc,
- IN ULONG Length)
-{
- PUCHAR pMem1;
- PUCHAR pMem2;
- UINT Index;
-
- ASSERT((Length==0) || (pDest && pSrc));
-
- pMem1 = (PUCHAR) pDest;
- pMem2 = (PUCHAR) pSrc;
-
- for (Index = 0; Index < Length; Index++)
- {
- pMem1[Index] = pMem2[Index];
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Initialize port configuration structure
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID UserCfgInit(
- IN PRTMP_ADAPTER pAd)
-{
-// EDCA_PARM DefaultEdcaParm;
- UINT key_index, bss_index;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit\n"));
-
- //
- // part I. intialize common configuration
- //
-#ifdef RT2870
- pAd->BulkOutReq = 0;
-
- pAd->BulkOutComplete = 0;
- pAd->BulkOutCompleteOther = 0;
- pAd->BulkOutCompleteCancel = 0;
- pAd->BulkInReq = 0;
- pAd->BulkInComplete = 0;
- pAd->BulkInCompleteFail = 0;
-
- //pAd->QuickTimerP = 100;
- //pAd->TurnAggrBulkInCount = 0;
- pAd->bUsbTxBulkAggre = 0;
-
- // init as unsed value to ensure driver will set to MCU once.
- pAd->LedIndicatorStregth = 0xFF;
-
- pAd->CommonCfg.MaxPktOneTxBulk = 2;
- pAd->CommonCfg.TxBulkFactor = 1;
- pAd->CommonCfg.RxBulkFactor =1;
-
- pAd->CommonCfg.TxPower = 100; //mW
-
- NdisZeroMemory(&pAd->CommonCfg.IOTestParm, sizeof(pAd->CommonCfg.IOTestParm));
-#endif // RT2870 //
-
- for(key_index=0; key_index<SHARE_KEY_NUM; key_index++)
- {
- for(bss_index = 0; bss_index < MAX_MBSSID_NUM; bss_index++)
- {
- pAd->SharedKey[bss_index][key_index].KeyLen = 0;
- pAd->SharedKey[bss_index][key_index].CipherAlg = CIPHER_NONE;
- } /* End of for */
- } /* End of for */
-
- pAd->EepromAccess = FALSE;
-
- pAd->Antenna.word = 0;
- pAd->CommonCfg.BBPCurrentBW = BW_20;
-
- pAd->LedCntl.word = 0;
-
- pAd->bAutoTxAgcA = FALSE; // Default is OFF
- pAd->bAutoTxAgcG = FALSE; // Default is OFF
- pAd->RfIcType = RFIC_2820;
-
- // Init timer for reset complete event
- pAd->CommonCfg.CentralChannel = 1;
- pAd->bForcePrintTX = FALSE;
- pAd->bForcePrintRX = FALSE;
- pAd->bStaFifoTest = FALSE;
- pAd->bProtectionTest = FALSE;
- pAd->bHCCATest = FALSE;
- pAd->bGenOneHCCA = FALSE;
- pAd->CommonCfg.Dsifs = 10; // in units of usec
- pAd->CommonCfg.TxPower = 100; //mW
- pAd->CommonCfg.TxPowerPercentage = 0xffffffff; // AUTO
- pAd->CommonCfg.TxPowerDefault = 0xffffffff; // AUTO
- pAd->CommonCfg.TxPreamble = Rt802_11PreambleAuto; // use Long preamble on TX by defaut
- pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
- pAd->CommonCfg.RtsThreshold = 2347;
- pAd->CommonCfg.FragmentThreshold = 2346;
- pAd->CommonCfg.UseBGProtection = 0; // 0: AUTO
- pAd->CommonCfg.bEnableTxBurst = TRUE; //0;
- pAd->CommonCfg.PhyMode = 0xff; // unknown
- pAd->CommonCfg.BandState = UNKNOWN_BAND;
- pAd->CommonCfg.RadarDetect.CSPeriod = 10;
- pAd->CommonCfg.RadarDetect.CSCount = 0;
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
- pAd->CommonCfg.RadarDetect.ChMovingTime = 65;
- pAd->CommonCfg.RadarDetect.LongPulseRadarTh = 3;
- pAd->CommonCfg.bAPSDCapable = FALSE;
- pAd->CommonCfg.bNeedSendTriggerFrame = FALSE;
- pAd->CommonCfg.TriggerTimerCount = 0;
- pAd->CommonCfg.bAPSDForcePowerSave = FALSE;
- pAd->CommonCfg.bCountryFlag = FALSE;
- pAd->CommonCfg.TxStream = 0;
- pAd->CommonCfg.RxStream = 0;
-
- NdisZeroMemory(&pAd->BeaconTxWI, sizeof(pAd->BeaconTxWI));
-
-#ifdef DOT11_N_SUPPORT
- NdisZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
- pAd->HTCEnable = FALSE;
- pAd->bBroadComHT = FALSE;
- pAd->CommonCfg.bRdg = FALSE;
-
-#ifdef DOT11N_DRAFT3
- pAd->CommonCfg.Dot11OBssScanPassiveDwell = dot11OBSSScanPassiveDwell; // Unit : TU. 5~1000
- pAd->CommonCfg.Dot11OBssScanActiveDwell = dot11OBSSScanActiveDwell; // Unit : TU. 10~1000
- pAd->CommonCfg.Dot11BssWidthTriggerScanInt = dot11BSSWidthTriggerScanInterval; // Unit : Second
- pAd->CommonCfg.Dot11OBssScanPassiveTotalPerChannel = dot11OBSSScanPassiveTotalPerChannel; // Unit : TU. 200~10000
- pAd->CommonCfg.Dot11OBssScanActiveTotalPerChannel = dot11OBSSScanActiveTotalPerChannel; // Unit : TU. 20~10000
- pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor = dot11BSSWidthChannelTransactionDelayFactor;
- pAd->CommonCfg.Dot11OBssScanActivityThre = dot11BSSScanActivityThreshold; // Unit : percentage
- pAd->CommonCfg.Dot11BssWidthChanTranDelay = (pAd->CommonCfg.Dot11BssWidthTriggerScanInt * pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor);
-#endif // DOT11N_DRAFT3 //
-
- NdisZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
- pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
- pAd->CommonCfg.BACapability.field.MpduDensity = 0;
- pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64; //32;
- pAd->CommonCfg.BACapability.field.TxBAWinLimit = 64; //32;
- DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit. BACapability = 0x%x\n", pAd->CommonCfg.BACapability.word));
-
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- BATableInit(pAd, &pAd->BATable);
-
- pAd->CommonCfg.bExtChannelSwitchAnnouncement = 1;
- pAd->CommonCfg.bHTProtect = 1;
- pAd->CommonCfg.bMIMOPSEnable = TRUE;
- pAd->CommonCfg.bBADecline = FALSE;
- pAd->CommonCfg.bDisableReordering = FALSE;
-
- pAd->CommonCfg.TxBASize = 7;
-
- pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word;
-#endif // DOT11_N_SUPPORT //
-
- //pAd->CommonCfg.HTPhyMode.field.BW = BW_20;
- //pAd->CommonCfg.HTPhyMode.field.MCS = MCS_AUTO;
- //pAd->CommonCfg.HTPhyMode.field.ShortGI = GI_800;
- //pAd->CommonCfg.HTPhyMode.field.STBC = STBC_NONE;
- pAd->CommonCfg.TxRate = RATE_6;
-
- pAd->CommonCfg.MlmeTransmit.field.MCS = MCS_RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.BW = BW_20;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-
- pAd->CommonCfg.BeaconPeriod = 100; // in mSec
-
- //
- // part II. intialize STA specific configuration
- //
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_DIRECT);
- RX_FILTER_CLEAR_FLAG(pAd, fRX_FILTER_ACCEPT_MULTICAST);
- RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_BROADCAST);
- RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_ALL_MULTICAST);
-
- pAd->StaCfg.Psm = PWR_ACTIVE;
-
- pAd->StaCfg.OrigWepStatus = Ndis802_11EncryptionDisabled;
- pAd->StaCfg.PairCipher = Ndis802_11EncryptionDisabled;
- pAd->StaCfg.GroupCipher = Ndis802_11EncryptionDisabled;
- pAd->StaCfg.bMixCipher = FALSE;
- pAd->StaCfg.DefaultKeyId = 0;
-
- // 802.1x port control
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.LastMicErrorTime = 0;
- pAd->StaCfg.MicErrCnt = 0;
- pAd->StaCfg.bBlockAssoc = FALSE;
- pAd->StaCfg.WpaState = SS_NOTUSE;
-
- pAd->CommonCfg.NdisRadioStateOff = FALSE; // New to support microsoft disable radio with OID command
-
- pAd->StaCfg.RssiTrigger = 0;
- NdisZeroMemory(&pAd->StaCfg.RssiSample, sizeof(RSSI_SAMPLE));
- pAd->StaCfg.RssiTriggerMode = RSSI_TRIGGERED_UPON_BELOW_THRESHOLD;
- pAd->StaCfg.AtimWin = 0;
- pAd->StaCfg.DefaultListenCount = 3;//default listen count;
- pAd->StaCfg.BssType = BSS_INFRA; // BSS_INFRA or BSS_ADHOC or BSS_MONITOR
- pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
-
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- }
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- pAd->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
-
- // global variables mXXXX used in MAC protocol state machines
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-
- // PHY specification
- pAd->CommonCfg.PhyMode = PHY_11BG_MIXED; // default PHY mode
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED); // CCK use LONG preamble
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // user desired power mode
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- pAd->StaCfg.bWindowsACCAMEnable = FALSE;
-
-#ifdef LEAP_SUPPORT
- // CCX v1.0 releated init value
- RTMPInitTimer(pAd, &pAd->StaCfg.LeapAuthTimer, GET_TIMER_FUNCTION(LeapAuthTimeout), pAd, FALSE);
- pAd->StaCfg.LeapAuthMode = CISCO_AuthModeLEAPNone;
- pAd->StaCfg.bCkipOn = FALSE;
-#endif // LEAP_SUPPORT //
-
- RTMPInitTimer(pAd, &pAd->StaCfg.StaQuickResponeForRateUpTimer, GET_TIMER_FUNCTION(StaQuickResponeForRateUpExec), pAd, FALSE);
- pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
-
- // Patch for Ndtest
- pAd->StaCfg.ScanCnt = 0;
-
- // CCX 2.0 control flag init
- pAd->StaCfg.CCXEnable = FALSE;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_UNUSED;
- pAd->StaCfg.CCXQosECWMin = 4;
- pAd->StaCfg.CCXQosECWMax = 10;
-
- pAd->StaCfg.bHwRadio = TRUE; // Default Hardware Radio status is On
- pAd->StaCfg.bSwRadio = TRUE; // Default Software Radio status is On
- pAd->StaCfg.bRadio = TRUE; // bHwRadio && bSwRadio
- pAd->StaCfg.bHardwareRadio = FALSE; // Default is OFF
- pAd->StaCfg.bShowHiddenSSID = FALSE; // Default no show
-
- // Nitro mode control
- pAd->StaCfg.bAutoReconnect = TRUE;
-
- // Save the init time as last scan time, the system should do scan after 2 seconds.
- // This patch is for driver wake up from standby mode, system will do scan right away.
- pAd->StaCfg.LastScanTime = 0;
- NdisZeroMemory(pAd->nickname, IW_ESSID_MAX_SIZE+1);
- sprintf(pAd->nickname, "%s", STA_NIC_DEVICE_NAME);
- RTMPInitTimer(pAd, &pAd->StaCfg.WpaDisassocAndBlockAssocTimer, GET_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc), pAd, FALSE);
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAd->StaCfg.IEEE8021X = FALSE;
- pAd->StaCfg.IEEE8021x_required_keys = FALSE;
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Default for extra information is not valid
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
-
- // Default Config change flag
- pAd->bConfigChanged = FALSE;
-
- //
- // part III. AP configurations
- //
-
-
- //
- // part IV. others
- //
- // dynamic BBP R66:sensibity tuning to overcome background noise
- pAd->BbpTuning.bEnable = TRUE;
- pAd->BbpTuning.FalseCcaLowerThreshold = 100;
- pAd->BbpTuning.FalseCcaUpperThreshold = 512;
- pAd->BbpTuning.R66Delta = 4;
- pAd->Mlme.bEnableAutoAntennaCheck = TRUE;
-
- //
- // Also initial R66CurrentValue, RTUSBResumeMsduTransmission might use this value.
- // if not initial this value, the default value will be 0.
- //
- pAd->BbpTuning.R66CurrentValue = 0x38;
-
- pAd->Bbp94 = BBPR94_DEFAULT;
- pAd->BbpForCCK = FALSE;
-
- // Default is FALSE for test bit 1
- //pAd->bTest1 = FALSE;
-
- // initialize MAC table and allocate spin lock
- NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE));
- InitializeQueueHeader(&pAd->MacTab.McastPsQueue);
- NdisAllocateSpinLock(&pAd->MacTabLock);
-
- //RTMPInitTimer(pAd, &pAd->RECBATimer, RECBATimerTimeout, pAd, TRUE);
- //RTMPSetTimer(&pAd->RECBATimer, REORDER_EXEC_INTV);
-
-#ifdef RALINK_ATE
- NdisZeroMemory(&pAd->ate, sizeof(ATE_INFO));
- pAd->ate.Mode = ATE_STOP;
- pAd->ate.TxCount = 200;/* to exceed TX_RING_SIZE ... */
- pAd->ate.TxLength = 1024;
- pAd->ate.TxWI.ShortGI = 0;// LONG GI : 800 ns
- pAd->ate.TxWI.PHYMODE = MODE_CCK;
- pAd->ate.TxWI.MCS = 3;
- pAd->ate.TxWI.BW = BW_20;
- pAd->ate.Channel = 1;
- pAd->ate.QID = QID_AC_BE;
- pAd->ate.Addr1[0] = 0x00;
- pAd->ate.Addr1[1] = 0x11;
- pAd->ate.Addr1[2] = 0x22;
- pAd->ate.Addr1[3] = 0xAA;
- pAd->ate.Addr1[4] = 0xBB;
- pAd->ate.Addr1[5] = 0xCC;
- NdisMoveMemory(pAd->ate.Addr2, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- NdisMoveMemory(pAd->ate.Addr3, pAd->ate.Addr1, ETH_LENGTH_OF_ADDRESS);
- pAd->ate.bRxFer = 0;
- pAd->ate.bQATxStart = FALSE;
- pAd->ate.bQARxStart = FALSE;
-#ifdef RALINK_28xx_QA
- //pAd->ate.Repeat = 0;
- pAd->ate.TxStatus = 0;
- pAd->ate.AtePid = 0;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-
- pAd->CommonCfg.bWiFiTest = FALSE;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n"));
-}
-
-// IRQL = PASSIVE_LEVEL
-UCHAR BtoH(char ch)
-{
- if (ch >= '0' && ch <= '9') return (ch - '0'); // Handle numerals
- if (ch >= 'A' && ch <= 'F') return (ch - 'A' + 0xA); // Handle capitol hex digits
- if (ch >= 'a' && ch <= 'f') return (ch - 'a' + 0xA); // Handle small hex digits
- return(255);
-}
-
-//
-// FUNCTION: AtoH(char *, UCHAR *, int)
-//
-// PURPOSE: Converts ascii string to network order hex
-//
-// PARAMETERS:
-// src - pointer to input ascii string
-// dest - pointer to output hex
-// destlen - size of dest
-//
-// COMMENTS:
-//
-// 2 ascii bytes make a hex byte so must put 1st ascii byte of pair
-// into upper nibble and 2nd ascii byte of pair into lower nibble.
-//
-// IRQL = PASSIVE_LEVEL
-
-void AtoH(char * src, UCHAR * dest, int destlen)
-{
- char * srcptr;
- PUCHAR destTemp;
-
- srcptr = src;
- destTemp = (PUCHAR) dest;
-
- while(destlen--)
- {
- *destTemp = BtoH(*srcptr++) << 4; // Put 1st ascii byte in upper nibble.
- *destTemp += BtoH(*srcptr++); // Add 2nd ascii byte to above.
- destTemp++;
- }
-}
-
-VOID RTMPPatchMacBbpBug(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG Index;
-
- // Initialize BBP register to default value
- for (Index = 0; Index < NUM_BBP_REG_PARMS; Index++)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, (UCHAR)BBPRegTable[Index].Value);
- }
-
- // Initialize RF register to default value
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- // Re-init BBP register from EEPROM value
- NICInitAsicFromEEPROM(pAd);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init timer objects
-
- Arguments:
- pAd Pointer to our adapter
- pTimer Timer structure
- pTimerFunc Function to execute when timer expired
- Repeat Ture for period timer
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitTimer(
- IN PRTMP_ADAPTER pAd,
- IN PRALINK_TIMER_STRUCT pTimer,
- IN PVOID pTimerFunc,
- IN PVOID pData,
- IN BOOLEAN Repeat)
-{
- //
- // Set Valid to TRUE for later used.
- // It will crash if we cancel a timer or set a timer
- // that we haven't initialize before.
- //
- pTimer->Valid = TRUE;
-
- pTimer->PeriodicType = Repeat;
- pTimer->State = FALSE;
- pTimer->cookie = (ULONG) pData;
-
-#ifdef RT2870
- pTimer->pAd = pAd;
-#endif // RT2870 //
-
- RTMP_OS_Init_Timer(pAd, &pTimer->TimerObj, pTimerFunc, (PVOID) pTimer);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init timer objects
-
- Arguments:
- pTimer Timer structure
- Value Timer value in milliseconds
-
- Return Value:
- None
-
- Note:
- To use this routine, must call RTMPInitTimer before.
-
- ========================================================================
-*/
-VOID RTMPSetTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value)
-{
- if (pTimer->Valid)
- {
- pTimer->TimerValue = Value;
- pTimer->State = FALSE;
- if (pTimer->PeriodicType == TRUE)
- {
- pTimer->Repeat = TRUE;
- RTMP_SetPeriodicTimer(&pTimer->TimerObj, Value);
- }
- else
- {
- pTimer->Repeat = FALSE;
- RTMP_OS_Add_Timer(&pTimer->TimerObj, Value);
- }
- }
- else
- {
- DBGPRINT_ERR(("RTMPSetTimer failed, Timer hasn't been initialize!\n"));
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Init timer objects
-
- Arguments:
- pTimer Timer structure
- Value Timer value in milliseconds
-
- Return Value:
- None
-
- Note:
- To use this routine, must call RTMPInitTimer before.
-
- ========================================================================
-*/
-VOID RTMPModTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value)
-{
- BOOLEAN Cancel;
-
- if (pTimer->Valid)
- {
- pTimer->TimerValue = Value;
- pTimer->State = FALSE;
- if (pTimer->PeriodicType == TRUE)
- {
- RTMPCancelTimer(pTimer, &Cancel);
- RTMPSetTimer(pTimer, Value);
- }
- else
- {
- RTMP_OS_Mod_Timer(&pTimer->TimerObj, Value);
- }
- }
- else
- {
- DBGPRINT_ERR(("RTMPModTimer failed, Timer hasn't been initialize!\n"));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Cancel timer objects
-
- Arguments:
- Adapter Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
- 1.) To use this routine, must call RTMPInitTimer before.
- 2.) Reset NIC to initial state AS IS system boot up time.
-
- ========================================================================
-*/
-VOID RTMPCancelTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- OUT BOOLEAN *pCancelled)
-{
- if (pTimer->Valid)
- {
- if (pTimer->State == FALSE)
- pTimer->Repeat = FALSE;
- RTMP_OS_Del_Timer(&pTimer->TimerObj, pCancelled);
-
- if (*pCancelled == TRUE)
- pTimer->State = TRUE;
-
-#ifdef RT2870
- // We need to go-through the TimerQ to findout this timer handler and remove it if
- // it's still waiting for execution.
-
- RT2870_TimerQ_Remove(pTimer->pAd, pTimer);
-#endif // RT2870 //
- }
- else
- {
- //
- // NdisMCancelTimer just canced the timer and not mean release the timer.
- // And don't set the "Valid" to False. So that we can use this timer again.
- //
- DBGPRINT_ERR(("RTMPCancelTimer failed, Timer hasn't been initialize!\n"));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set LED Status
-
- Arguments:
- pAd Pointer to our adapter
- Status LED Status
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPSetLED(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Status)
-{
- //ULONG data;
- UCHAR HighByte = 0;
- UCHAR LowByte;
-
-// In ATE mode of RT2860 AP/STA, we have erased 8051 firmware.
-// So LED mode is not supported when ATE is running.
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- LowByte = pAd->LedCntl.field.LedMode&0x7f;
- switch (Status)
- {
- case LED_LINK_DOWN:
- HighByte = 0x20;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- pAd->LedIndicatorStregth = 0;
- break;
- case LED_LINK_UP:
- if (pAd->CommonCfg.Channel > 14)
- HighByte = 0xa0;
- else
- HighByte = 0x60;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_RADIO_ON:
- HighByte = 0x20;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_HALT:
- LowByte = 0; // Driver sets MAC register and MAC controls LED
- case LED_RADIO_OFF:
- HighByte = 0;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_WPS:
- HighByte = 0x10;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_ON_SITE_SURVEY:
- HighByte = 0x08;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- case LED_POWER_UP:
- HighByte = 0x04;
- AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
- break;
- default:
- DBGPRINT(RT_DEBUG_WARN, ("RTMPSetLED::Unknown Status %d\n", Status));
- break;
- }
-
- //
- // Keep LED status for LED SiteSurvey mode.
- // After SiteSurvey, we will set the LED mode to previous status.
- //
- if ((Status != LED_ON_SITE_SURVEY) && (Status != LED_POWER_UP))
- pAd->LedStatus = Status;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetLED::Mode=%d,HighByte=0x%02x,LowByte=0x%02x\n", pAd->LedCntl.field.LedMode, HighByte, LowByte));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set LED Signal Stregth
-
- Arguments:
- pAd Pointer to our adapter
- Dbm Signal Stregth
-
- Return Value:
- None
-
- IRQL = PASSIVE_LEVEL
-
- Note:
- Can be run on any IRQL level.
-
- According to Microsoft Zero Config Wireless Signal Stregth definition as belows.
- <= -90 No Signal
- <= -81 Very Low
- <= -71 Low
- <= -67 Good
- <= -57 Very Good
- > -57 Excellent
- ========================================================================
-*/
-VOID RTMPSetSignalLED(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_802_11_RSSI Dbm)
-{
- UCHAR nLed = 0;
-
- //
- // if not Signal Stregth, then do nothing.
- //
- if (pAd->LedCntl.field.LedMode != LED_MODE_SIGNAL_STREGTH)
- {
- return;
- }
-
- if (Dbm <= -90)
- nLed = 0;
- else if (Dbm <= -81)
- nLed = 1;
- else if (Dbm <= -71)
- nLed = 3;
- else if (Dbm <= -67)
- nLed = 7;
- else if (Dbm <= -57)
- nLed = 15;
- else
- nLed = 31;
-
- //
- // Update Signal Stregth to firmware if changed.
- //
- if (pAd->LedIndicatorStregth != nLed)
- {
- AsicSendCommandToMcu(pAd, 0x51, 0xff, nLed, pAd->LedCntl.field.Polarity);
- pAd->LedIndicatorStregth = nLed;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Enable RX
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL <= DISPATCH_LEVEL
-
- Note:
- Before Enable RX, make sure you have enabled Interrupt.
- ========================================================================
-*/
-VOID RTMPEnableRxTx(
- IN PRTMP_ADAPTER pAd)
-{
-// WPDMA_GLO_CFG_STRUC GloCfg;
-// ULONG i = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPEnableRxTx\n"));
-
- // Enable Rx DMA.
- RT28XXDMAEnable(pAd);
-
- // enable RX of MAC block
- if (pAd->OpMode == OPMODE_AP)
- {
- UINT32 rx_filter_flag = APNORMAL;
-
-
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag); // enable RX of DMA block
- }
- else
- {
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
- }
-
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc);
- DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n"));
-}
-
-
+#include "../../rt2870/common/rtmp_init.c"
diff --git a/drivers/staging/rt3070/common/rtmp_tkip.c b/drivers/staging/rt3070/common/rtmp_tkip.c
index bf8986e83679..57a5ee96f311 100644
--- a/drivers/staging/rt3070/common/rtmp_tkip.c
+++ b/drivers/staging/rt3070/common/rtmp_tkip.c
@@ -1,1613 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_tkip.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Wu 02-25-02 Initial
-*/
-
-#include "../rt_config.h"
-
-// Rotation functions on 32 bit values
-#define ROL32( A, n ) \
- ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
-#define ROR32( A, n ) ROL32( (A), 32-(n) )
-
-UINT Tkip_Sbox_Lower[256] =
-{
- 0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54,
- 0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A,
- 0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B,
- 0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B,
- 0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F,
- 0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F,
- 0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5,
- 0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F,
- 0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB,
- 0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97,
- 0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED,
- 0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A,
- 0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94,
- 0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3,
- 0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04,
- 0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D,
- 0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39,
- 0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95,
- 0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83,
- 0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76,
- 0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4,
- 0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B,
- 0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0,
- 0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18,
- 0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51,
- 0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85,
- 0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12,
- 0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9,
- 0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7,
- 0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A,
- 0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8,
- 0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A
-};
-
-UINT Tkip_Sbox_Upper[256] =
-{
- 0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91,
- 0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC,
- 0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB,
- 0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B,
- 0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83,
- 0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A,
- 0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F,
- 0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA,
- 0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B,
- 0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13,
- 0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6,
- 0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85,
- 0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11,
- 0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B,
- 0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1,
- 0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF,
- 0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E,
- 0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6,
- 0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B,
- 0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD,
- 0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8,
- 0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2,
- 0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49,
- 0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10,
- 0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97,
- 0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F,
- 0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C,
- 0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27,
- 0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33,
- 0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5,
- 0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0,
- 0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C
-};
-
-/*****************************/
-/******** SBOX Table *********/
-/*****************************/
-
-UCHAR SboxTable[256] =
-{
- 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
- 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
- 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
- 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
- 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
- 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
- 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
- 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
- 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
- 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
- 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
- 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
- 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
- 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
- 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
- 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
- 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
- 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
- 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
- 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
- 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
- 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
- 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
- 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
- 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
- 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
- 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
- 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
- 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
- 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
- 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
- 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round);
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a);
-//
-// Expanded IV for TKIP function.
-//
-typedef struct PACKED _IV_CONTROL_
-{
- union PACKED
- {
- struct PACKED
- {
- UCHAR rc0;
- UCHAR rc1;
- UCHAR rc2;
-
- union PACKED
- {
- struct PACKED
- {
-#ifdef RT_BIG_ENDIAN
- UCHAR KeyID:2;
- UCHAR ExtIV:1;
- UCHAR Rsvd:5;
-#else
- UCHAR Rsvd:5;
- UCHAR ExtIV:1;
- UCHAR KeyID:2;
-#endif
- } field;
- UCHAR Byte;
- } CONTROL;
- } field;
-
- ULONG word;
- } IV16;
-
- ULONG IV32;
-} TKIP_IV, *PTKIP_IV;
-
-
-/*
- ========================================================================
-
- Routine Description:
- Convert from UCHAR[] to ULONG in a portable way
-
- Arguments:
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-ULONG RTMPTkipGetUInt32(
- IN PUCHAR pMICKey)
-{
- ULONG res = 0;
- INT i;
-
- for (i = 0; i < 4; i++)
- {
- res |= (*pMICKey++) << (8 * i);
- }
-
- return res;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Convert from ULONG to UCHAR[] in a portable way
-
- Arguments:
- pDst pointer to destination for convert ULONG to UCHAR[]
- val the value for convert
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipPutUInt32(
- IN OUT PUCHAR pDst,
- IN ULONG val)
-{
- INT i;
-
- for(i = 0; i < 4; i++)
- {
- *pDst++ = (UCHAR) (val & 0xff);
- val >>= 8;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Set the MIC Key.
-
- Arguments:
- pAd Pointer to our adapter
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipSetMICKey(
- IN PTKIP_KEY_INFO pTkip,
- IN PUCHAR pMICKey)
-{
- // Set the key
- pTkip->K0 = RTMPTkipGetUInt32(pMICKey);
- pTkip->K1 = RTMPTkipGetUInt32(pMICKey + 4);
- // and reset the message
- pTkip->L = pTkip->K0;
- pTkip->R = pTkip->K1;
- pTkip->nBytesInM = 0;
- pTkip->M = 0;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Calculate the MIC Value.
-
- Arguments:
- pAd Pointer to our adapter
- uChar Append this uChar
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipAppendByte(
- IN PTKIP_KEY_INFO pTkip,
- IN UCHAR uChar)
-{
- // Append the byte to our word-sized buffer
- pTkip->M |= (uChar << (8* pTkip->nBytesInM));
- pTkip->nBytesInM++;
- // Process the word if it is full.
- if( pTkip->nBytesInM >= 4 )
- {
- pTkip->L ^= pTkip->M;
- pTkip->R ^= ROL32( pTkip->L, 17 );
- pTkip->L += pTkip->R;
- pTkip->R ^= ((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->L & 0x00ff00ff) << 8);
- pTkip->L += pTkip->R;
- pTkip->R ^= ROL32( pTkip->L, 3 );
- pTkip->L += pTkip->R;
- pTkip->R ^= ROR32( pTkip->L, 2 );
- pTkip->L += pTkip->R;
- // Clear the buffer
- pTkip->M = 0;
- pTkip->nBytesInM = 0;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Calculate the MIC Value.
-
- Arguments:
- pAd Pointer to our adapter
- pSrc Pointer to source data for Calculate MIC Value
- Len Indicate the length of the source data
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPTkipAppend(
- IN PTKIP_KEY_INFO pTkip,
- IN PUCHAR pSrc,
- IN UINT nBytes)
-{
- // This is simple
- while(nBytes > 0)
- {
- RTMPTkipAppendByte(pTkip, *pSrc++);
- nBytes--;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get the MIC Value.
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- the MIC Value is store in pAd->PrivateInfo.MIC
- ========================================================================
-*/
-VOID RTMPTkipGetMIC(
- IN PTKIP_KEY_INFO pTkip)
-{
- // Append the minimum padding
- RTMPTkipAppendByte(pTkip, 0x5a );
- RTMPTkipAppendByte(pTkip, 0 );
- RTMPTkipAppendByte(pTkip, 0 );
- RTMPTkipAppendByte(pTkip, 0 );
- RTMPTkipAppendByte(pTkip, 0 );
- // and then zeroes until the length is a multiple of 4
- while( pTkip->nBytesInM != 0 )
- {
- RTMPTkipAppendByte(pTkip, 0 );
- }
- // The appendByte function has already computed the result.
- RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
- RTMPTkipPutUInt32(pTkip->MIC + 4, pTkip->R);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init Tkip function.
-
- Arguments:
- pAd Pointer to our adapter
- pTKey Pointer to the Temporal Key (TK), TK shall be 128bits.
- KeyId TK Key ID
- pTA Pointer to transmitter address
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitTkipEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN UCHAR KeyId,
- IN PUCHAR pTA,
- IN PUCHAR pMICKey,
- IN PUCHAR pTSC,
- OUT PULONG pIV16,
- OUT PULONG pIV32)
-{
- TKIP_IV tkipIv;
-
- // Prepare 8 bytes TKIP encapsulation for MPDU
- NdisZeroMemory(&tkipIv, sizeof(TKIP_IV));
- tkipIv.IV16.field.rc0 = *(pTSC + 1);
- tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;
- tkipIv.IV16.field.rc2 = *pTSC;
- tkipIv.IV16.field.CONTROL.field.ExtIV = 1; // 0: non-extended IV, 1: an extended IV
- tkipIv.IV16.field.CONTROL.field.KeyID = KeyId;
-// tkipIv.IV32 = *(PULONG)(pTSC + 2);
- NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4); // Copy IV
-
- *pIV16 = tkipIv.IV16.word;
- *pIV32 = tkipIv.IV32;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init MIC Value calculation function which include set MIC key &
- calculate first 16 bytes (DA + SA + priority + 0)
-
- Arguments:
- pAd Pointer to our adapter
- pTKey Pointer to the Temporal Key (TK), TK shall be 128bits.
- pDA Pointer to DA address
- pSA Pointer to SA address
- pMICKey pointer to MIC Key
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitMICEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN UCHAR UserPriority,
- IN PUCHAR pMICKey)
-{
- ULONG Priority = UserPriority;
-
- // Init MIC value calculation
- RTMPTkipSetMICKey(&pAd->PrivateInfo.Tx, pMICKey);
- // DA
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pDA, MAC_ADDR_LEN);
- // SA
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSA, MAC_ADDR_LEN);
- // Priority + 3 bytes of 0
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, (PUCHAR)&Priority, 4);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Compare MIC value of received MSDU
-
- Arguments:
- pAd Pointer to our adapter
- pSrc Pointer to the received Plain text data
- pDA Pointer to DA address
- pSA Pointer to SA address
- pMICKey pointer to MIC Key
- Len the length of the received plain text data exclude MIC value
-
- Return Value:
- TRUE MIC value matched
- FALSE MIC value mismatched
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN RTMPTkipCompareMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UCHAR UserPriority,
- IN UINT Len)
-{
- UCHAR OldMic[8];
- ULONG Priority = UserPriority;
-
- // Init MIC value calculation
- RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
- // DA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pDA, MAC_ADDR_LEN);
- // SA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
- // Priority + 3 bytes of 0
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
-
- // Calculate MIC value from plain text data
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
-
- // Get MIC valude from received frame
- NdisMoveMemory(OldMic, pSrc + Len, 8);
-
- // Get MIC value from decrypted plain data
- RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-
- // Move MIC value from MSDU, this steps should move to data path.
- // Since the MIC value might cross MPDUs.
- if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n")); //MIC error.
-
-
- return (FALSE);
- }
- return (TRUE);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Compare MIC value of received MSDU
-
- Arguments:
- pAd Pointer to our adapter
- pLLC LLC header
- pSrc Pointer to the received Plain text data
- pDA Pointer to DA address
- pSA Pointer to SA address
- pMICKey pointer to MIC Key
- Len the length of the received plain text data exclude MIC value
-
- Return Value:
- TRUE MIC value matched
- FALSE MIC value mismatched
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN RTMPTkipCompareMICValueWithLLC(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pLLC,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UINT Len)
-{
- UCHAR OldMic[8];
- ULONG Priority = 0;
-
- // Init MIC value calculation
- RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
- // DA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pDA, MAC_ADDR_LEN);
- // SA
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
- // Priority + 3 bytes of 0
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
-
- // Start with LLC header
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pLLC, 8);
-
- // Calculate MIC value from plain text data
- RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
-
- // Get MIC valude from received frame
- NdisMoveMemory(OldMic, pSrc + Len, 8);
-
- // Get MIC value from decrypted plain data
- RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-
- // Move MIC value from MSDU, this steps should move to data path.
- // Since the MIC value might cross MPDUs.
- if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValueWithLLC(): TKIP MIC Error !\n")); //MIC error.
-
-
- return (FALSE);
- }
- return (TRUE);
-}
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware transmit function
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to Ndis Packet for MIC calculation
- pEncap Pointer to LLC encap data
- LenEncap Total encap length, might be 0 which indicates no encap
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPCalculateMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pEncap,
- IN PCIPHER_KEY pKey,
- IN UCHAR apidx)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- PUCHAR pSrc;
- UCHAR UserPriority;
- UCHAR vlan_offset = 0;
-
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- UserPriority = RTMP_GET_PACKET_UP(pPacket);
- pSrc = pSrcBufVA;
-
- // determine if this is a vlan packet
- if (((*(pSrc + 12) << 8) + *(pSrc + 13)) == 0x8100)
- vlan_offset = 4;
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
- {
- RTMPInitMICEngine(
- pAd,
- pKey->Key,
- pSrc,
- pSrc + 6,
- UserPriority,
- pKey->TxMic);
- }
-
-
- if (pEncap != NULL)
- {
- // LLC encapsulation
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pEncap, 6);
- // Protocol Type
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset, 2);
- }
- SrcBufLen -= (14 + vlan_offset);
- pSrc += (14 + vlan_offset);
- do
- {
- if (SrcBufLen > 0)
- {
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc, SrcBufLen);
- }
-
- break; // No need handle next packet
-
- } while (TRUE); // End of copying payload
-
- // Compute the final MIC Value
- RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
-}
-
-
-/************************************************************/
-/* tkip_sbox() */
-/* Returns a 16 bit value from a 64K entry table. The Table */
-/* is synthesized from two 256 entry byte wide tables. */
-/************************************************************/
-
-UINT tkip_sbox(UINT index)
-{
- UINT index_low;
- UINT index_high;
- UINT left, right;
-
- index_low = (index % 256);
- index_high = ((index >> 8) % 256);
-
- left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256);
- right = Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
-
- return (left ^ right);
-}
-
-UINT rotr1(UINT a)
-{
- unsigned int b;
-
- if ((a & 0x01) == 0x01)
- {
- b = (a >> 1) | 0x8000;
- }
- else
- {
- b = (a >> 1) & 0x7fff;
- }
- b = b % 65536;
- return b;
-}
-
-VOID RTMPTkipMixKey(
- UCHAR *key,
- UCHAR *ta,
- ULONG pnl, /* Least significant 16 bits of PN */
- ULONG pnh, /* Most significant 32 bits of PN */
- UCHAR *rc4key,
- UINT *p1k)
-{
-
- UINT tsc0;
- UINT tsc1;
- UINT tsc2;
-
- UINT ppk0;
- UINT ppk1;
- UINT ppk2;
- UINT ppk3;
- UINT ppk4;
- UINT ppk5;
-
- INT i;
- INT j;
-
- tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
- tsc1 = (unsigned int)(pnh % 65536);
- tsc2 = (unsigned int)(pnl % 65536); /* lsb */
-
- /* Phase 1, step 1 */
- p1k[0] = tsc1;
- p1k[1] = tsc0;
- p1k[2] = (UINT)(ta[0] + (ta[1]*256));
- p1k[3] = (UINT)(ta[2] + (ta[3]*256));
- p1k[4] = (UINT)(ta[4] + (ta[5]*256));
-
- /* Phase 1, step 2 */
- for (i=0; i<8; i++)
- {
- j = 2*(i & 1);
- p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*key[1+j]) + key[j])) % 65536 )) % 65536;
- p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*key[5+j]) + key[4+j])) % 65536 )) % 65536;
- p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*key[9+j]) + key[8+j])) % 65536 )) % 65536;
- p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*key[13+j]) + key[12+j])) % 65536 )) % 65536;
- p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*key[1+j]) + key[j]))) % 65536 )) % 65536;
- p1k[4] = (p1k[4] + i) % 65536;
- }
-
- /* Phase 2, Step 1 */
- ppk0 = p1k[0];
- ppk1 = p1k[1];
- ppk2 = p1k[2];
- ppk3 = p1k[3];
- ppk4 = p1k[4];
- ppk5 = (p1k[4] + tsc2) % 65536;
-
- /* Phase2, Step 2 */
- ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*key[1]) + key[0])) % 65536);
- ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*key[3]) + key[2])) % 65536);
- ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*key[5]) + key[4])) % 65536);
- ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*key[7]) + key[6])) % 65536);
- ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*key[9]) + key[8])) % 65536);
- ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*key[11]) + key[10])) % 65536);
-
- ppk0 = ppk0 + rotr1(ppk5 ^ ((256*key[13]) + key[12]));
- ppk1 = ppk1 + rotr1(ppk0 ^ ((256*key[15]) + key[14]));
- ppk2 = ppk2 + rotr1(ppk1);
- ppk3 = ppk3 + rotr1(ppk2);
- ppk4 = ppk4 + rotr1(ppk3);
- ppk5 = ppk5 + rotr1(ppk4);
-
- /* Phase 2, Step 3 */
- /* Phase 2, Step 3 */
-
- tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
- tsc1 = (unsigned int)(pnh % 65536);
- tsc2 = (unsigned int)(pnl % 65536); /* lsb */
-
- rc4key[0] = (tsc2 >> 8) % 256;
- rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
- rc4key[2] = tsc2 % 256;
- rc4key[3] = ((ppk5 ^ ((256*key[1]) + key[0])) >> 1) % 256;
-
- rc4key[4] = ppk0 % 256;
- rc4key[5] = (ppk0 >> 8) % 256;
-
- rc4key[6] = ppk1 % 256;
- rc4key[7] = (ppk1 >> 8) % 256;
-
- rc4key[8] = ppk2 % 256;
- rc4key[9] = (ppk2 >> 8) % 256;
-
- rc4key[10] = ppk3 % 256;
- rc4key[11] = (ppk3 >> 8) % 256;
-
- rc4key[12] = ppk4 % 256;
- rc4key[13] = (ppk4 >> 8) % 256;
-
- rc4key[14] = ppk5 % 256;
- rc4key[15] = (ppk5 >> 8) % 256;
-}
-
-
-/************************************************/
-/* construct_mic_header1() */
-/* Builds the first MIC header block from */
-/* header fields. */
-/************************************************/
-
-void construct_mic_header1(
- unsigned char *mic_header1,
- int header_length,
- unsigned char *mpdu)
-{
- mic_header1[0] = (unsigned char)((header_length - 2) / 256);
- mic_header1[1] = (unsigned char)((header_length - 2) % 256);
- mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */
- mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */
- mic_header1[4] = mpdu[4]; /* A1 */
- mic_header1[5] = mpdu[5];
- mic_header1[6] = mpdu[6];
- mic_header1[7] = mpdu[7];
- mic_header1[8] = mpdu[8];
- mic_header1[9] = mpdu[9];
- mic_header1[10] = mpdu[10]; /* A2 */
- mic_header1[11] = mpdu[11];
- mic_header1[12] = mpdu[12];
- mic_header1[13] = mpdu[13];
- mic_header1[14] = mpdu[14];
- mic_header1[15] = mpdu[15];
-}
-
-/************************************************/
-/* construct_mic_header2() */
-/* Builds the last MIC header block from */
-/* header fields. */
-/************************************************/
-
-void construct_mic_header2(
- unsigned char *mic_header2,
- unsigned char *mpdu,
- int a4_exists,
- int qc_exists)
-{
- int i;
-
- for (i = 0; i<16; i++) mic_header2[i]=0x00;
-
- mic_header2[0] = mpdu[16]; /* A3 */
- mic_header2[1] = mpdu[17];
- mic_header2[2] = mpdu[18];
- mic_header2[3] = mpdu[19];
- mic_header2[4] = mpdu[20];
- mic_header2[5] = mpdu[21];
-
- // In Sequence Control field, mute sequence numer bits (12-bit)
- mic_header2[6] = mpdu[22] & 0x0f; /* SC */
- mic_header2[7] = 0x00; /* mpdu[23]; */
-
- if ((!qc_exists) & a4_exists)
- {
- for (i=0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */
-
- }
-
- if (qc_exists && (!a4_exists))
- {
- mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */
- mic_header2[9] = mpdu[25] & 0x00;
- }
-
- if (qc_exists && a4_exists)
- {
- for (i=0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */
-
- mic_header2[14] = mpdu[30] & 0x0f;
- mic_header2[15] = mpdu[31] & 0x00;
- }
-}
-
-
-/************************************************/
-/* construct_mic_iv() */
-/* Builds the MIC IV from header fields and PN */
-/************************************************/
-
-void construct_mic_iv(
- unsigned char *mic_iv,
- int qc_exists,
- int a4_exists,
- unsigned char *mpdu,
- unsigned int payload_length,
- unsigned char *pn_vector)
-{
- int i;
-
- mic_iv[0] = 0x59;
- if (qc_exists && a4_exists)
- mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */
- if (qc_exists && !a4_exists)
- mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */
- if (!qc_exists)
- mic_iv[1] = 0x00;
- for (i = 2; i < 8; i++)
- mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */
-#ifdef CONSISTENT_PN_ORDER
- for (i = 8; i < 14; i++)
- mic_iv[i] = pn_vector[i - 8]; /* mic_iv[8:13] = PN[0:5] */
-#else
- for (i = 8; i < 14; i++)
- mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */
-#endif
- i = (payload_length / 256);
- i = (payload_length % 256);
- mic_iv[14] = (unsigned char) (payload_length / 256);
- mic_iv[15] = (unsigned char) (payload_length % 256);
-
-}
-
-
-
-/************************************/
-/* bitwise_xor() */
-/* A 128 bit, bitwise exclusive or */
-/************************************/
-
-void bitwise_xor(unsigned char *ina, unsigned char *inb, unsigned char *out)
-{
- int i;
- for (i=0; i<16; i++)
- {
- out[i] = ina[i] ^ inb[i];
- }
-}
-
-
-void aes128k128d(unsigned char *key, unsigned char *data, unsigned char *ciphertext)
-{
- int round;
- int i;
- unsigned char intermediatea[16];
- unsigned char intermediateb[16];
- unsigned char round_key[16];
-
- for(i=0; i<16; i++) round_key[i] = key[i];
-
- for (round = 0; round < 11; round++)
- {
- if (round == 0)
- {
- xor_128(round_key, data, ciphertext);
- next_key(round_key, round);
- }
- else if (round == 10)
- {
- byte_sub(ciphertext, intermediatea);
- shift_row(intermediatea, intermediateb);
- xor_128(intermediateb, round_key, ciphertext);
- }
- else /* 1 - 9 */
- {
- byte_sub(ciphertext, intermediatea);
- shift_row(intermediatea, intermediateb);
- mix_column(&intermediateb[0], &intermediatea[0]);
- mix_column(&intermediateb[4], &intermediatea[4]);
- mix_column(&intermediateb[8], &intermediatea[8]);
- mix_column(&intermediateb[12], &intermediatea[12]);
- xor_128(intermediatea, round_key, ciphertext);
- next_key(round_key, round);
- }
- }
-
-}
-
-void construct_ctr_preload(
- unsigned char *ctr_preload,
- int a4_exists,
- int qc_exists,
- unsigned char *mpdu,
- unsigned char *pn_vector,
- int c)
-{
-
- int i = 0;
- for (i=0; i<16; i++) ctr_preload[i] = 0x00;
- i = 0;
-
- ctr_preload[0] = 0x01; /* flag */
- if (qc_exists && a4_exists) ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */
- if (qc_exists && !a4_exists) ctr_preload[1] = mpdu[24] & 0x0f;
-
- for (i = 2; i < 8; i++)
- ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
-#ifdef CONSISTENT_PN_ORDER
- for (i = 8; i < 14; i++)
- ctr_preload[i] = pn_vector[i - 8]; /* ctr_preload[8:13] = PN[0:5] */
-#else
- for (i = 8; i < 14; i++)
- ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */
-#endif
- ctr_preload[14] = (unsigned char) (c / 256); // Ctr
- ctr_preload[15] = (unsigned char) (c % 256);
-
-}
-
-
-//
-// TRUE: Success!
-// FALSE: Decrypt Error!
-//
-BOOLEAN RTMPSoftDecryptTKIP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN UCHAR UserPriority,
- IN PCIPHER_KEY pWpaKey)
-{
- UCHAR KeyID;
- UINT HeaderLen;
- UCHAR fc0;
- UCHAR fc1;
- USHORT fc;
- UINT frame_type;
- UINT frame_subtype;
- UINT from_ds;
- UINT to_ds;
- INT a4_exists;
- INT qc_exists;
- USHORT duration;
- USHORT seq_control;
- USHORT qos_control;
- UCHAR TA[MAC_ADDR_LEN];
- UCHAR DA[MAC_ADDR_LEN];
- UCHAR SA[MAC_ADDR_LEN];
- UCHAR RC4Key[16];
- UINT p1k[5]; //for mix_key;
- ULONG pnl;/* Least significant 16 bits of PN */
- ULONG pnh;/* Most significant 32 bits of PN */
- UINT num_blocks;
- UINT payload_remainder;
- ARCFOURCONTEXT ArcFourContext;
- UINT crc32 = 0;
- UINT trailfcs = 0;
- UCHAR MIC[8];
- UCHAR TrailMIC[8];
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
- fc0 = *pData;
- fc1 = *(pData + 1);
-
- fc = *((PUSHORT)pData);
-
- frame_type = ((fc0 >> 2) & 0x03);
- frame_subtype = ((fc0 >> 4) & 0x0f);
-
- from_ds = (fc1 & 0x2) >> 1;
- to_ds = (fc1 & 0x1);
-
- a4_exists = (from_ds & to_ds);
- qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
- (frame_subtype == 0x09) || /* Likely to change. */
- (frame_subtype == 0x0a) ||
- (frame_subtype == 0x0b)
- );
-
- HeaderLen = 24;
- if (a4_exists)
- HeaderLen += 6;
-
- KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
- KeyID = KeyID >> 6;
-
- if (pWpaKey[KeyID].KeyLen == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP failed!(KeyID[%d] Length can not be 0)\n", KeyID));
- return FALSE;
- }
-
- duration = *((PUSHORT)(pData+2));
-
- seq_control = *((PUSHORT)(pData+22));
-
- if (qc_exists)
- {
- if (a4_exists)
- {
- qos_control = *((PUSHORT)(pData+30));
- }
- else
- {
- qos_control = *((PUSHORT)(pData+24));
- }
- }
-
- if (to_ds == 0 && from_ds == 1)
- {
- NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
- NdisMoveMemory(SA, pData+16, MAC_ADDR_LEN);
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN); //BSSID
- }
- else if (to_ds == 0 && from_ds == 0 )
- {
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
- NdisMoveMemory(SA, pData+10, MAC_ADDR_LEN);
- }
- else if (to_ds == 1 && from_ds == 0)
- {
- NdisMoveMemory(SA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(DA, pData+16, MAC_ADDR_LEN);
- }
- else if (to_ds == 1 && from_ds == 1)
- {
- NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
- NdisMoveMemory(DA, pData+16, MAC_ADDR_LEN);
- NdisMoveMemory(SA, pData+22, MAC_ADDR_LEN);
- }
-
- num_blocks = (DataByteCnt - 16) / 16;
- payload_remainder = (DataByteCnt - 16) % 16;
-
- pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);
- pnh = *((PULONG)(pData + HeaderLen + 4));
- pnh = cpu2le32(pnh);
- RTMPTkipMixKey(pWpaKey[KeyID].Key, TA, pnl, pnh, RC4Key, p1k);
-
- ARCFOUR_INIT(&ArcFourContext, RC4Key, 16);
-
- ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen, pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
- NdisMoveMemory(&trailfcs, pData + DataByteCnt - 8 - 4, 4);
- crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 4); //Skip IV+EIV 8 bytes & Skip last 4 bytes(FCS).
- crc32 ^= 0xffffffff; /* complement */
-
- if(crc32 != cpu2le32(trailfcs))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP, WEP Data ICV Error !\n")); //ICV error.
-
- return (FALSE);
- }
-
- NdisMoveMemory(TrailMIC, pData + DataByteCnt - 8 - 8 - 4, 8);
- RTMPInitMICEngine(pAd, pWpaKey[KeyID].Key, DA, SA, UserPriority, pWpaKey[KeyID].RxMic);
- RTMPTkipAppend(&pAd->PrivateInfo.Tx, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 12);
- RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
- NdisMoveMemory(MIC, pAd->PrivateInfo.Tx.MIC, 8);
-
- if (!NdisEqualMemory(MIC, TrailMIC, 8))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n")); //MIC error.
- //RTMPReportMicError(pAd, &pWpaKey[KeyID]); // marked by AlbertY @ 20060630
- return (FALSE);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
- //DBGPRINT(RT_DEBUG_TRACE, "RTMPSoftDecryptTKIP Decript done!!\n");
- return TRUE;
-}
-
-
-
-
-BOOLEAN RTMPSoftDecryptAES(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pWpaKey)
-{
- UCHAR KeyID;
- UINT HeaderLen;
- UCHAR PN[6];
- UINT payload_len;
- UINT num_blocks;
- UINT payload_remainder;
- USHORT fc;
- UCHAR fc0;
- UCHAR fc1;
- UINT frame_type;
- UINT frame_subtype;
- UINT from_ds;
- UINT to_ds;
- INT a4_exists;
- INT qc_exists;
- UCHAR aes_out[16];
- int payload_index;
- UINT i;
- UCHAR ctr_preload[16];
- UCHAR chain_buffer[16];
- UCHAR padded_buffer[16];
- UCHAR mic_iv[16];
- UCHAR mic_header1[16];
- UCHAR mic_header2[16];
- UCHAR MIC[8];
- UCHAR TrailMIC[8];
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
- fc0 = *pData;
- fc1 = *(pData + 1);
-
- fc = *((PUSHORT)pData);
-
- frame_type = ((fc0 >> 2) & 0x03);
- frame_subtype = ((fc0 >> 4) & 0x0f);
-
- from_ds = (fc1 & 0x2) >> 1;
- to_ds = (fc1 & 0x1);
-
- a4_exists = (from_ds & to_ds);
- qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
- (frame_subtype == 0x09) || /* Likely to change. */
- (frame_subtype == 0x0a) ||
- (frame_subtype == 0x0b)
- );
-
- HeaderLen = 24;
- if (a4_exists)
- HeaderLen += 6;
-
- KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
- KeyID = KeyID >> 6;
-
- if (pWpaKey[KeyID].KeyLen == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptAES failed!(KeyID[%d] Length can not be 0)\n", KeyID));
- return FALSE;
- }
-
- PN[0] = *(pData+ HeaderLen);
- PN[1] = *(pData+ HeaderLen + 1);
- PN[2] = *(pData+ HeaderLen + 4);
- PN[3] = *(pData+ HeaderLen + 5);
- PN[4] = *(pData+ HeaderLen + 6);
- PN[5] = *(pData+ HeaderLen + 7);
-
- payload_len = DataByteCnt - HeaderLen - 8 - 8; // 8 bytes for CCMP header , 8 bytes for MIC
- payload_remainder = (payload_len) % 16;
- num_blocks = (payload_len) / 16;
-
-
-
- // Find start of payload
- payload_index = HeaderLen + 8; //IV+EIV
-
- for (i=0; i< num_blocks; i++)
- {
- construct_ctr_preload(ctr_preload,
- a4_exists,
- qc_exists,
- pData,
- PN,
- i+1 );
-
- aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
- bitwise_xor(aes_out, pData + payload_index, chain_buffer);
- NdisMoveMemory(pData + payload_index - 8, chain_buffer, 16);
- payload_index += 16;
- }
-
- //
- // If there is a short final block, then pad it
- // encrypt it and copy the unpadded part back
- //
- if (payload_remainder > 0)
- {
- construct_ctr_preload(ctr_preload,
- a4_exists,
- qc_exists,
- pData,
- PN,
- num_blocks + 1);
-
- NdisZeroMemory(padded_buffer, 16);
- NdisMoveMemory(padded_buffer, pData + payload_index, payload_remainder);
-
- aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
- bitwise_xor(aes_out, padded_buffer, chain_buffer);
- NdisMoveMemory(pData + payload_index - 8, chain_buffer, payload_remainder);
- payload_index += payload_remainder;
- }
-
- //
- // Descrypt the MIC
- //
- construct_ctr_preload(ctr_preload,
- a4_exists,
- qc_exists,
- pData,
- PN,
- 0);
- NdisZeroMemory(padded_buffer, 16);
- NdisMoveMemory(padded_buffer, pData + payload_index, 8);
-
- aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
- bitwise_xor(aes_out, padded_buffer, chain_buffer);
-
- NdisMoveMemory(TrailMIC, chain_buffer, 8);
-
- //
- // Calculate MIC
- //
-
- //Force the protected frame bit on
- *(pData + 1) = *(pData + 1) | 0x40;
-
- // Find start of payload
- // Because the CCMP header has been removed
- payload_index = HeaderLen;
-
- construct_mic_iv(
- mic_iv,
- qc_exists,
- a4_exists,
- pData,
- payload_len,
- PN);
-
- construct_mic_header1(
- mic_header1,
- HeaderLen,
- pData);
-
- construct_mic_header2(
- mic_header2,
- pData,
- a4_exists,
- qc_exists);
-
- aes128k128d(pWpaKey[KeyID].Key, mic_iv, aes_out);
- bitwise_xor(aes_out, mic_header1, chain_buffer);
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
- bitwise_xor(aes_out, mic_header2, chain_buffer);
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
-
- // iterate through each 16 byte payload block
- for (i = 0; i < num_blocks; i++)
- {
- bitwise_xor(aes_out, pData + payload_index, chain_buffer);
- payload_index += 16;
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
- }
-
- // Add on the final payload block if it needs padding
- if (payload_remainder > 0)
- {
- NdisZeroMemory(padded_buffer, 16);
- NdisMoveMemory(padded_buffer, pData + payload_index, payload_remainder);
-
- bitwise_xor(aes_out, padded_buffer, chain_buffer);
- aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
- }
-
- // aes_out contains padded mic, discard most significant
- // 8 bytes to generate 64 bit MIC
- for (i = 0 ; i < 8; i++) MIC[i] = aes_out[i];
-
- if (!NdisEqualMemory(MIC, TrailMIC, 8))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptAES, MIC Error !\n")); //MIC error.
- return FALSE;
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pData, DIR_READ, FALSE);
-#endif
-
- return TRUE;
-}
-
-/****************************************/
-/* aes128k128d() */
-/* Performs a 128 bit AES encrypt with */
-/* 128 bit data. */
-/****************************************/
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0;i<16; i++)
- {
- out[i] = a[i] ^ b[i];
- }
-}
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round)
-{
- UCHAR rcon;
- UCHAR sbox_key[4];
- UCHAR rcon_table[12] =
- {
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
- 0x1b, 0x36, 0x36, 0x36
- };
-
- sbox_key[0] = RTMPCkipSbox(key[13]);
- sbox_key[1] = RTMPCkipSbox(key[14]);
- sbox_key[2] = RTMPCkipSbox(key[15]);
- sbox_key[3] = RTMPCkipSbox(key[12]);
-
- rcon = rcon_table[round];
-
- xor_32(&key[0], sbox_key, &key[0]);
- key[0] = key[0] ^ rcon;
-
- xor_32(&key[4], &key[0], &key[4]);
- xor_32(&key[8], &key[4], &key[8]);
- xor_32(&key[12], &key[8], &key[12]);
-}
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0;i<4; i++)
- {
- out[i] = a[i] ^ b[i];
- }
-}
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- INT i;
-
- for (i=0; i< 16; i++)
- {
- out[i] = RTMPCkipSbox(in[i]);
- }
-}
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a)
-{
- return SboxTable[(int)a];
-}
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- out[0] = in[0];
- out[1] = in[5];
- out[2] = in[10];
- out[3] = in[15];
- out[4] = in[4];
- out[5] = in[9];
- out[6] = in[14];
- out[7] = in[3];
- out[8] = in[8];
- out[9] = in[13];
- out[10] = in[2];
- out[11] = in[7];
- out[12] = in[12];
- out[13] = in[1];
- out[14] = in[6];
- out[15] = in[11];
-}
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out)
-{
- INT i;
- UCHAR add1b[4];
- UCHAR add1bf7[4];
- UCHAR rotl[4];
- UCHAR swap_halfs[4];
- UCHAR andf7[4];
- UCHAR rotr[4];
- UCHAR temp[4];
- UCHAR tempb[4];
-
- for (i=0 ; i<4; i++)
- {
- if ((in[i] & 0x80)== 0x80)
- add1b[i] = 0x1b;
- else
- add1b[i] = 0x00;
- }
-
- swap_halfs[0] = in[2]; /* Swap halfs */
- swap_halfs[1] = in[3];
- swap_halfs[2] = in[0];
- swap_halfs[3] = in[1];
-
- rotl[0] = in[3]; /* Rotate left 8 bits */
- rotl[1] = in[0];
- rotl[2] = in[1];
- rotl[3] = in[2];
-
- andf7[0] = in[0] & 0x7f;
- andf7[1] = in[1] & 0x7f;
- andf7[2] = in[2] & 0x7f;
- andf7[3] = in[3] & 0x7f;
-
- for (i = 3; i>0; i--) /* logical shift left 1 bit */
- {
- andf7[i] = andf7[i] << 1;
- if ((andf7[i-1] & 0x80) == 0x80)
- {
- andf7[i] = (andf7[i] | 0x01);
- }
- }
- andf7[0] = andf7[0] << 1;
- andf7[0] = andf7[0] & 0xfe;
-
- xor_32(add1b, andf7, add1bf7);
-
- xor_32(in, add1bf7, rotr);
-
- temp[0] = rotr[0]; /* Rotate right 8 bits */
- rotr[0] = rotr[1];
- rotr[1] = rotr[2];
- rotr[2] = rotr[3];
- rotr[3] = temp[0];
-
- xor_32(add1bf7, rotr, temp);
- xor_32(swap_halfs, rotl,tempb);
- xor_32(temp, tempb, out);
-}
-
+#include "../../rt2870/common/rtmp_tkip.c"
diff --git a/drivers/staging/rt3070/common/rtmp_wep.c b/drivers/staging/rt3070/common/rtmp_wep.c
index f5f0a3bb17eb..71979856e11a 100644
--- a/drivers/staging/rt3070/common/rtmp_wep.c
+++ b/drivers/staging/rt3070/common/rtmp_wep.c
@@ -1,508 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_wep.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Wu 10-28-02 Initial
-*/
-
-#include "../rt_config.h"
-
-UINT FCSTAB_32[256] =
-{
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
- 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
- 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
- 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
- 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
- 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
- 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
- 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
- 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
- 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
- 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
- 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
- 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
- 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
- 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
- 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
- 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
- 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
- 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
- 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
- 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
- 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
- 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
- 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
- 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
- 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
- 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
- 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
- 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
- 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
- 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
- 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
- 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
- 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
- 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
- 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
- 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
- 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
- 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
- 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
- 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
- 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
- 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-/*
-UCHAR WEPKEY[] = {
- //IV
- 0x00, 0x11, 0x22,
- //WEP KEY
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
- };
- */
-
-/*
- ========================================================================
-
- Routine Description:
- Init WEP function.
-
- Arguments:
- pAd Pointer to our adapter
- pKey Pointer to the WEP KEY
- KeyId WEP Key ID
- KeyLen the length of WEP KEY
- pDest Pointer to the destination which Encryption data will store in.
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPInitWepEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN UCHAR KeyId,
- IN UCHAR KeyLen,
- IN OUT PUCHAR pDest)
-{
- UINT i;
- UCHAR WEPKEY[] = {
- //IV
- 0x00, 0x11, 0x22,
- //WEP KEY
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
- };
-
- pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10) && (pAd->OpMode == OPMODE_STA))
- {
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, pKey, KeyLen); //INIT SBOX, KEYLEN+3(IV)
- NdisMoveMemory(pDest, pKey, 3); //Append Init Vector
- }
- else
-#endif // CONFIG_STA_SUPPORT //
- {
- NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
-
- for(i = 0; i < 3; i++)
- WEPKEY[i] = RandomByte(pAd); //Call mlme RandomByte() function.
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); //INIT SBOX, KEYLEN+3(IV)
-
- NdisMoveMemory(pDest, WEPKEY, 3); //Append Init Vector
- }
- *(pDest+3) = (KeyId << 6); //Append KEYID
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Encrypt transimitted data
-
- Arguments:
- pAd Pointer to our adapter
- pSrc Pointer to the transimitted source data that will be encrypt
- pDest Pointer to the destination where entryption data will be store in.
- Len Indicate the length of the source data
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPEncryptData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDest,
- IN UINT Len)
-{
- pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, pSrc, Len);
- ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, pSrc, Len);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Decrypt received WEP data
-
- Arguments:
- pAdapter Pointer to our adapter
- pSrc Pointer to the received data
- Len the length of the received data
-
- Return Value:
- TRUE Decrypt WEP data success
- FALSE Decrypt WEP data failed
-
- Note:
-
- ========================================================================
-*/
-BOOLEAN RTMPSoftDecryptWEP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pGroupKey)
-{
- UINT trailfcs;
- UINT crc32;
- UCHAR KeyIdx;
- UCHAR WEPKEY[] = {
- //IV
- 0x00, 0x11, 0x22,
- //WEP KEY
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
- };
- UCHAR *pPayload = (UCHAR *)pData + LENGTH_802_11;
- ULONG payload_len = DataByteCnt - LENGTH_802_11;
-
- NdisMoveMemory(WEPKEY, pPayload, 3); //Get WEP IV
-
- KeyIdx = (*(pPayload + 3) & 0xc0) >> 6;
- if (pGroupKey[KeyIdx].KeyLen == 0)
- return (FALSE);
-
- NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key, pGroupKey[KeyIdx].KeyLen);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, pGroupKey[KeyIdx].KeyLen + 3);
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4, payload_len - 4);
- NdisMoveMemory(&trailfcs, pPayload + payload_len - 8, 4);
- crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pPayload, payload_len - 8); //Skip last 4 bytes(FCS).
- crc32 ^= 0xffffffff; /* complement */
-
- if(crc32 != cpu2le32(trailfcs))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("! WEP Data CRC Error !\n")); //CRC error.
- return (FALSE);
- }
- return (TRUE);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Encryption Algorithm "ARCFOUR" initialize
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pKey Pointer to the WEP KEY
- KeyLen Indicate the length fo the WEP KEY
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID ARCFOUR_INIT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pKey,
- IN UINT KeyLen)
-{
- UCHAR t, u;
- UINT keyindex;
- UINT stateindex;
- PUCHAR state;
- UINT counter;
-
- state = Ctx->STATE;
- Ctx->X = 0;
- Ctx->Y = 0;
- for (counter = 0; counter < 256; counter++)
- state[counter] = (UCHAR)counter;
- keyindex = 0;
- stateindex = 0;
- for (counter = 0; counter < 256; counter++)
- {
- t = state[counter];
- stateindex = (stateindex + pKey[keyindex] + t) & 0xff;
- u = state[stateindex];
- state[stateindex] = t;
- state[counter] = u;
- if (++keyindex >= KeyLen)
- keyindex = 0;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get bytes from ARCFOUR CONTEXT (S-BOX)
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
-
- Return Value:
- UCHAR - the value of the ARCFOUR CONTEXT (S-BOX)
-
- Note:
-
- ========================================================================
-*/
-UCHAR ARCFOUR_BYTE(
- IN PARCFOURCONTEXT Ctx)
-{
- UINT x;
- UINT y;
- UCHAR sx, sy;
- PUCHAR state;
-
- state = Ctx->STATE;
- x = (Ctx->X + 1) & 0xff;
- sx = state[x];
- y = (sx + Ctx->Y) & 0xff;
- sy = state[y];
- Ctx->X = x;
- Ctx->Y = y;
- state[y] = sx;
- state[x] = sy;
-
- return(state[(sx + sy) & 0xff]);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Decryption Algorithm
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pDest Pointer to the Destination
- pSrc Pointer to the Source data
- Len Indicate the length of the Source data
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ARCFOUR_DECRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len)
-{
- UINT i;
-
- for (i = 0; i < Len; i++)
- pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Encryption Algorithm
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pDest Pointer to the Destination
- pSrc Pointer to the Source data
- Len Indicate the length of the Source dta
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID ARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len)
-{
- UINT i;
-
- for (i = 0; i < Len; i++)
- pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
- ========================================================================
-
- Routine Description:
- The Stream Cipher Encryption Algorithm which conform to the special requirement to encrypt GTK.
-
- Arguments:
- Ctx Pointer to ARCFOUR CONTEXT (SBOX)
- pDest Pointer to the Destination
- pSrc Pointer to the Source data
- Len Indicate the length of the Source dta
-
-
- ========================================================================
-*/
-
-VOID WPAARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len)
-{
- UINT i;
- //discard first 256 bytes
- for (i = 0; i < 256; i++)
- ARCFOUR_BYTE(Ctx);
-
- for (i = 0; i < Len; i++)
- pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Calculate a new FCS given the current FCS and the new data.
-
- Arguments:
- Fcs the original FCS value
- Cp pointer to the data which will be calculate the FCS
- Len the length of the data
-
- Return Value:
- UINT - FCS 32 bits
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-UINT RTMP_CALC_FCS32(
- IN UINT Fcs,
- IN PUCHAR Cp,
- IN INT Len)
-{
- while (Len--)
- Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
-
- return (Fcs);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Get last FCS and encrypt it to the destination
-
- Arguments:
- pDest Pointer to the Destination
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPSetICV(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest)
-{
- pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff; /* complement */
- pAd->PrivateInfo.FCSCRC32 = cpu2le32(pAd->PrivateInfo.FCSCRC32);
-
- ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, (PUCHAR) &pAd->PrivateInfo.FCSCRC32, 4);
-}
-
+#include "../../rt2870/common/rtmp_wep.c"
diff --git a/drivers/staging/rt3070/common/rtusb_bulk.c b/drivers/staging/rt3070/common/rtusb_bulk.c
index 1a05703520fc..762ecfe6044f 100644
--- a/drivers/staging/rt3070/common/rtusb_bulk.c
+++ b/drivers/staging/rt3070/common/rtusb_bulk.c
@@ -1,1382 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtusb_bulk.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 06-25-2004 created
-
-*/
-
-#include "../rt_config.h"
-// Match total 6 bulkout endpoint to corresponding queue.
-UCHAR EpToQueue[6]={FIFO_EDCA, FIFO_EDCA, FIFO_EDCA, FIFO_EDCA, FIFO_EDCA, FIFO_MGMT};
-
-//static BOOLEAN SingleBulkOut = FALSE;
-
-void RTUSB_FILL_BULK_URB (struct urb *pUrb,
- struct usb_device *pUsb_Dev,
- unsigned int bulkpipe,
- void *pTransferBuf,
- int BufSize,
- usb_complete_t Complete,
- void *pContext)
-{
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- usb_fill_bulk_urb(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize, (usb_complete_t)Complete, pContext);
-#else
- FILL_BULK_URB(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize, Complete, pContext);
-#endif
-
-}
-
-VOID RTUSBInitTxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PTX_CONTEXT pTxContext,
- IN UCHAR BulkOutPipeId,
- IN usb_complete_t Func)
-{
- PURB pUrb;
- PUCHAR pSrc = NULL;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- pUrb = pTxContext->pUrb;
- ASSERT(pUrb);
-
- // Store BulkOut PipeId
- pTxContext->BulkOutPipeId = BulkOutPipeId;
-
- if (pTxContext->bAggregatible)
- {
- pSrc = &pTxContext->TransferBuffer->Aggregation[2];
- }
- else
- {
- pSrc = (PUCHAR) pTxContext->TransferBuffer->field.WirelessPacket;
- }
-
-
- //Initialize a tx bulk urb
- RTUSB_FILL_BULK_URB(pUrb,
- pObj->pUsb_Dev,
- usb_sndbulkpipe(pObj->pUsb_Dev, pAd->BulkOutEpAddr[BulkOutPipeId]),
- pSrc,
- pTxContext->BulkOutSize,
- Func,
- pTxContext);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- if (pTxContext->bAggregatible)
- pUrb->transfer_dma = (pTxContext->data_dma + TX_BUFFER_NORMSIZE + 2);
- else
- pUrb->transfer_dma = pTxContext->data_dma;
-
- pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-#endif
-
-}
-
-VOID RTUSBInitHTTxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PHT_TX_CONTEXT pTxContext,
- IN UCHAR BulkOutPipeId,
- IN ULONG BulkOutSize,
- IN usb_complete_t Func)
-{
- PURB pUrb;
- PUCHAR pSrc = NULL;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- pUrb = pTxContext->pUrb;
- ASSERT(pUrb);
-
- // Store BulkOut PipeId
- pTxContext->BulkOutPipeId = BulkOutPipeId;
-
- pSrc = &pTxContext->TransferBuffer->field.WirelessPacket[pTxContext->NextBulkOutPosition];
-
-
- //Initialize a tx bulk urb
- RTUSB_FILL_BULK_URB(pUrb,
- pObj->pUsb_Dev,
- usb_sndbulkpipe(pObj->pUsb_Dev, pAd->BulkOutEpAddr[BulkOutPipeId]),
- pSrc,
- BulkOutSize,
- Func,
- pTxContext);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- pUrb->transfer_dma = (pTxContext->data_dma + pTxContext->NextBulkOutPosition);
- pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-#endif
-
-}
-
-VOID RTUSBInitRxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PRX_CONTEXT pRxContext)
-{
- PURB pUrb;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
- ULONG RX_bulk_size;
-
-
- pUrb = pRxContext->pUrb;
- ASSERT(pUrb);
-
- if ( pAd->BulkInMaxPacketSize == 64)
- RX_bulk_size = 4096;
- else
- RX_bulk_size = MAX_RXBULK_SIZE;
-
- //Initialize a rx bulk urb
- RTUSB_FILL_BULK_URB(pUrb,
- pObj->pUsb_Dev,
- usb_rcvbulkpipe(pObj->pUsb_Dev, pAd->BulkInEpAddr),
- &(pRxContext->TransferBuffer[pAd->NextRxBulkInPosition]),
- RX_bulk_size - (pAd->NextRxBulkInPosition),
- (usb_complete_t)RTUSBBulkRxComplete,
- (void *)pRxContext);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- pUrb->transfer_dma = pRxContext->data_dma + pAd->NextRxBulkInPosition;
- pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-#endif
-
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-
-#define BULK_OUT_LOCK(pLock, IrqFlags) \
- if(1 /*!(in_interrupt() & 0xffff0000)*/) \
- RTMP_IRQ_LOCK((pLock), IrqFlags);
-
-#define BULK_OUT_UNLOCK(pLock, IrqFlags) \
- if(1 /*!(in_interrupt() & 0xffff0000)*/) \
- RTMP_IRQ_UNLOCK((pLock), IrqFlags);
-
-
-VOID RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId,
- IN UCHAR Index)
-{
-
- PHT_TX_CONTEXT pHTTXContext;
- PURB pUrb;
- int ret = 0;
- PTXINFO_STRUC pTxInfo, pLastTxInfo = NULL;
- PTXWI_STRUC pTxWI;
- ULONG TmpBulkEndPos, ThisBulkSize;
- unsigned long IrqFlags = 0, IrqFlags2 = 0;
- PUCHAR pWirelessPkt, pAppendant;
- BOOLEAN bTxQLastRound = FALSE;
- UCHAR allzero[4]= {0x0,0x0,0x0,0x0};
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- if ((pAd->BulkOutPending[BulkOutPipeId] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX))
- {
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
- pAd->BulkOutPending[BulkOutPipeId] = TRUE;
-
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
- )
- {
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
-
- pHTTXContext = &(pAd->TxContext[BulkOutPipeId]);
-
- BULK_OUT_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2);
- if ((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition)
- || ((pHTTXContext->ENextBulkOutPosition-8) == pHTTXContext->CurWritePosition))
- {
- BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2);
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
-
- // Clear Data flag
- RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId));
- RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
-
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
-
- // Clear Data flag
- RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId));
- RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
-
- //DBGPRINT(RT_DEBUG_TRACE,("BulkOut-B:I=0x%lx, CWPos=%ld, CWRPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", in_interrupt(),
- // pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->NextBulkOutPosition,
- // pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad));
- pHTTXContext->NextBulkOutPosition = pHTTXContext->ENextBulkOutPosition;
- ThisBulkSize = 0;
- TmpBulkEndPos = pHTTXContext->NextBulkOutPosition;
- pWirelessPkt = &pHTTXContext->TransferBuffer->field.WirelessPacket[0];
-
- if ((pHTTXContext->bCopySavePad == TRUE))
- {
- if (RTMPEqualMemory(pHTTXContext->SavedPad, allzero,4))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR,("e1, allzero : %x %x %x %x %x %x %x %x \n",
- pHTTXContext->SavedPad[0], pHTTXContext->SavedPad[1], pHTTXContext->SavedPad[2],pHTTXContext->SavedPad[3]
- ,pHTTXContext->SavedPad[4], pHTTXContext->SavedPad[5], pHTTXContext->SavedPad[6],pHTTXContext->SavedPad[7]));
- }
- NdisMoveMemory(&pWirelessPkt[TmpBulkEndPos], pHTTXContext->SavedPad, 8);
- pHTTXContext->bCopySavePad = FALSE;
- if (pAd->bForcePrintTX == TRUE)
- DBGPRINT(RT_DEBUG_TRACE,("RTUSBBulkOutDataPacket --> COPY PAD. CurWrite = %ld, NextBulk = %ld. ENextBulk = %ld.\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition));
- }
-
- do
- {
- pTxInfo = (PTXINFO_STRUC)&pWirelessPkt[TmpBulkEndPos];
- pTxWI = (PTXWI_STRUC)&pWirelessPkt[TmpBulkEndPos + TXINFO_SIZE];
-
- if (pAd->bForcePrintTX == TRUE)
- DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkOutDataPacket AMPDU = %d.\n", pTxWI->AMPDU));
-
- // add by Iverson, limit BulkOut size to 4k to pass WMM b mode 2T1R test items
- //if ((ThisBulkSize != 0) && (pTxWI->AMPDU == 0))
- if ((ThisBulkSize != 0) && (pTxWI->PHYMODE == MODE_CCK))
- {
-#ifdef INF_AMAZON_SE
- /*Iverson Add for AMAZON USB (RT2070 && RT3070) to pass WMM A2-T4 ~ A2-T10*/
- if(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
- {
- /*Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate*/
- if(pTxWI->PacketId == 6)
- {
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- else if (BulkOutPipeId == 1)
- {
- /*BK No Limit BulkOut size .*/
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- else if (((ThisBulkSize&0xffff8000) != 0) || (((ThisBulkSize&0x1000) == 0x1000) && (BulkOutPipeId == 0) ))
- {
- /*BE Limit BulkOut size to about 4k bytes.*/
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- else if (((ThisBulkSize&0xffff8000) != 0) || (((ThisBulkSize&0x1c00) == 0x1c00) && (BulkOutPipeId == 2) ))
- {
- /*VI Limit BulkOut size to about 7k bytes.*/
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- else if (((ThisBulkSize&0xffff8000) != 0) || (((ThisBulkSize&0x2500) == 0x2500) && (BulkOutPipeId == 3) ))
- {
- /*VO Limit BulkOut size to about 9k bytes.*/
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- }
- else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x1000) == 0x1000))
- {
- /* Limit BulkOut size to about 4k bytes.*/
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
-#else
- if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x1000) == 0x1000))
- {
- // Limit BulkOut size to about 4k bytes.
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
-#endif // INF_AMAZON_SE //
-
- else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize&0xfffff800) != 0) ) /*|| ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0))*/)
- {
- // For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size.
- // For performence in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04.
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- }
- // end Iverson
- else
- {
-#ifdef INF_AMAZON_SE
-//#ifdef DOT11_N_SUPPORT
-// if(((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x6000) == 0x6000) || ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0)))
-// {
-// /* AMAZON_SE: BG mode Disable BulkOut Aggregate, N mode BulkOut Aggregaet size 24K */
-// pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
-// break;
-// }
-// else
-//#endif // DOT11_N_SUPPORT //
-// {
- if(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && (pTxWI->AMPDU == 0))
- {
- if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize&0xfffff800) != 0)) ||
- (ThisBulkSize != 0))
- {
- /* AMAZON_SE: RT2070 Disable BulkOut Aggregate when WMM for USB issue */
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- }
-/*
- else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x6000) == 0x6000))
- {
- // Limit BulkOut size to about 24k bytes.
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- }
-*/
-#endif // INF_AMAZON_SE //
-
- if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x6000) == 0x6000))
- { // Limit BulkOut size to about 24k bytes.
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
-
- else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize&0xfffff800) != 0) ) /*|| ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0))*/)
- { // For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size.
- // For performence in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04.
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- }
-
- if (TmpBulkEndPos == pHTTXContext->CurWritePosition)
- {
- pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
- break;
- }
- //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if (pTxInfo->QSEL != FIFO_EDCA)
- {
- printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __FUNCTION__, pTxInfo->QSEL);
- printk("\tCWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad);
- hex_dump("Wrong QSel Pkt:", (PUCHAR)&pWirelessPkt[TmpBulkEndPos], (pHTTXContext->CurWritePosition - pHTTXContext->NextBulkOutPosition));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- if (pTxInfo->USBDMATxPktLen <= 8)
- {
- BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2);
- DBGPRINT(RT_DEBUG_ERROR /*RT_DEBUG_TRACE*/,("e2, USBDMATxPktLen==0, Size=%ld, bCSPad=%d, CWPos=%ld, NBPos=%ld, CWRPos=%ld!\n",
- pHTTXContext->BulkOutSize, pHTTXContext->bCopySavePad, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->CurWriteRealPos));
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR /*RT_DEBUG_TRACE*/,("%x %x %x %x %x %x %x %x \n",
- pHTTXContext->SavedPad[0], pHTTXContext->SavedPad[1], pHTTXContext->SavedPad[2],pHTTXContext->SavedPad[3]
- ,pHTTXContext->SavedPad[4], pHTTXContext->SavedPad[5], pHTTXContext->SavedPad[6],pHTTXContext->SavedPad[7]));
- }
- pAd->bForcePrintTX = TRUE;
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- //DBGPRINT(RT_DEBUG_LOUD,("Out:pTxInfo->USBDMATxPktLen=%d!\n", pTxInfo->USBDMATxPktLen));
- return;
- }
-
- // Increase Total transmit byte counter
- pAd->RalinkCounters.OneSecTransmittedByteCount += pTxWI->MPDUtotalByteCount;
- pAd->RalinkCounters.TransmittedByteCount += pTxWI->MPDUtotalByteCount;
-
- pLastTxInfo = pTxInfo;
-
- // Make sure we use EDCA QUEUE.
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pTxInfo->QSEL = FIFO_EDCA; //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-#endif // CONFIG_STA_SUPPORT //
- ThisBulkSize += (pTxInfo->USBDMATxPktLen+4);
- TmpBulkEndPos += (pTxInfo->USBDMATxPktLen+4);
-
- if (TmpBulkEndPos != pHTTXContext->CurWritePosition)
- pTxInfo->USBDMANextVLD = 1;
-
- if (pTxInfo->SwUseLastRound == 1)
- {
- if (pHTTXContext->CurWritePosition == 8)
- pTxInfo->USBDMANextVLD = 0;
- pTxInfo->SwUseLastRound = 0;
-
- bTxQLastRound = TRUE;
- pHTTXContext->ENextBulkOutPosition = 8;
-
- #ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
- #endif // RT_BIG_ENDIAN //
-
- break;
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
- }while (TRUE);
-
- // adjust the pTxInfo->USBDMANextVLD value of last pTxInfo.
- if (pLastTxInfo)
- {
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
- pLastTxInfo->USBDMANextVLD = 0;
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
- }
-
- /*
- We need to copy SavedPad when following condition matched!
- 1. Not the last round of the TxQueue and
- 2. any match of following cases:
- (1). The End Position of this bulk out is reach to the Currenct Write position and
- the TxInfo and related header already write to the CurWritePosition.
- =>(ENextBulkOutPosition == CurWritePosition) && (CurWriteRealPos > CurWritePosition)
-
- (2). The EndPosition of the bulk out is not reach to the Current Write Position.
- =>(ENextBulkOutPosition != CurWritePosition)
- */
- if ((bTxQLastRound == FALSE) &&
- (((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition) && (pHTTXContext->CurWriteRealPos > pHTTXContext->CurWritePosition)) ||
- (pHTTXContext->ENextBulkOutPosition != pHTTXContext->CurWritePosition))
- )
- {
- NdisMoveMemory(pHTTXContext->SavedPad, &pWirelessPkt[pHTTXContext->ENextBulkOutPosition], 8);
- pHTTXContext->bCopySavePad = TRUE;
- if (RTMPEqualMemory(pHTTXContext->SavedPad, allzero,4))
- {
- PUCHAR pBuf = &pHTTXContext->SavedPad[0];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("WARNING-Zero-3:%02x%02x%02x%02x%02x%02x%02x%02x,CWPos=%ld, CWRPos=%ld, bCW=%d, NBPos=%ld, TBPos=%ld, TBSize=%ld\n",
- pBuf[0], pBuf[1], pBuf[2],pBuf[3],pBuf[4], pBuf[5], pBuf[6],pBuf[7], pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos,
- pHTTXContext->bCurWriting, pHTTXContext->NextBulkOutPosition, TmpBulkEndPos, ThisBulkSize));
-
- pBuf = &pWirelessPkt[pHTTXContext->CurWritePosition];
- DBGPRINT_RAW(RT_DEBUG_ERROR,("\tCWPos=%02x%02x%02x%02x%02x%02x%02x%02x\n", pBuf[0], pBuf[1], pBuf[2],pBuf[3],pBuf[4], pBuf[5], pBuf[6],pBuf[7]));
- }
- //DBGPRINT(RT_DEBUG_LOUD,("ENPos==CWPos=%ld, CWRPos=%ld, bCSPad=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->bCopySavePad));
- }
-
- if (pAd->bForcePrintTX == TRUE)
- DBGPRINT(RT_DEBUG_TRACE,("BulkOut-A:Size=%ld, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", ThisBulkSize, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad));
- //DBGPRINT(RT_DEBUG_LOUD,("BulkOut-A:Size=%ld, CWPos=%ld, CWRPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d, bLRound=%d!\n", ThisBulkSize, pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad, bTxQLastRound));
-
- // USB DMA engine requires to pad extra 4 bytes. This pad doesn't count into real bulkoutsize.
- pAppendant = &pWirelessPkt[TmpBulkEndPos];
- NdisZeroMemory(pAppendant, 8);
- ThisBulkSize += 4;
- pHTTXContext->LastOne = TRUE;
- if ((ThisBulkSize % pAd->BulkOutMaxPacketSize) == 0)
- ThisBulkSize += 4;
- pHTTXContext->BulkOutSize = ThisBulkSize;
-
- pAd->watchDogTxPendingCnt[BulkOutPipeId] = 1;
- BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2);
-
- // Init Tx context descriptor
- RTUSBInitHTTxDesc(pAd, pHTTXContext, BulkOutPipeId, ThisBulkSize, (usb_complete_t)RTUSBBulkOutDataPacketComplete);
-
- pUrb = pHTTXContext->pUrb;
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret));
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- pAd->watchDogTxPendingCnt[BulkOutPipeId] = 0;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- return;
- }
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pHTTXContext->IRPPending = TRUE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutReq++;
-
-}
-
-
-VOID RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- PHT_TX_CONTEXT pHTTXContext;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
- UCHAR BulkOutPipeId;
-
-
- pHTTXContext = (PHT_TX_CONTEXT)pUrb->context;
- pAd = pHTTXContext->pAd;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- // Store BulkOut PipeId
- BulkOutPipeId = pHTTXContext->BulkOutPipeId;
- pAd->BulkOutDataOneSecCount++;
-
- switch (BulkOutPipeId)
- {
- case 0:
- pObj->ac0_dma_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->ac0_dma_done_task);
- break;
- case 1:
- pObj->ac1_dma_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->ac1_dma_done_task);
- break;
- case 2:
- pObj->ac2_dma_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->ac2_dma_done_task);
- break;
- case 3:
- pObj->ac3_dma_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->ac3_dma_done_task);
- break;
- case 4:
- pObj->hcca_dma_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->hcca_dma_done_task);
- break;
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note: NULL frame use BulkOutPipeId = 0
-
- ========================================================================
-*/
-VOID RTUSBBulkOutNullFrame(
- IN PRTMP_ADAPTER pAd)
-{
- PTX_CONTEXT pNullContext = &(pAd->NullContext);
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- if ((pAd->BulkOutPending[0] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX))
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
- return;
- }
- pAd->BulkOutPending[0] = TRUE;
- pAd->watchDogTxPendingCnt[0] = 1;
- pNullContext->IRPPending = TRUE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
- // Increase Total transmit byte counter
- pAd->RalinkCounters.TransmittedByteCount += pNullContext->BulkOutSize;
-
-
- // Clear Null frame bulk flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL);
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pNullContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
- // Init Tx context descriptor
- RTUSBInitTxDesc(pAd, pNullContext, 0, (usb_complete_t)RTUSBBulkOutNullFrameComplete);
-
- pUrb = pNullContext->pUrb;
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- pAd->BulkOutPending[0] = FALSE;
- pAd->watchDogTxPendingCnt[0] = 0;
- pNullContext->IRPPending = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutNullFrame: Submit Tx URB failed %d\n", ret));
- return;
- }
-
-}
-
-// NULL frame use BulkOutPipeId = 0
-VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pNullContext;
- NTSTATUS Status;
- POS_COOKIE pObj;
-
-
- pNullContext = (PTX_CONTEXT)pUrb->context;
- pAd = pNullContext->pAd;
- Status = pUrb->status;
-
- pObj = (POS_COOKIE) pAd->OS_Cookie;
- pObj->null_frame_complete_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->null_frame_complete_task);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note: MLME use BulkOutPipeId = 0
-
- ========================================================================
-*/
-VOID RTUSBBulkOutMLMEPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PTX_CONTEXT pMLMEContext;
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
- pMLMEContext = (PTX_CONTEXT)pAd->MgmtRing.Cell[pAd->MgmtRing.TxDmaIdx].AllocVa;
- pUrb = pMLMEContext->pUrb;
-
- if ((pAd->MgmtRing.TxSwFreeIdx >= MGMT_RING_SIZE) ||
- (pMLMEContext->InUse == FALSE) ||
- (pMLMEContext->bWaitingBulkOut == FALSE))
- {
-
-
- // Clear MLME bulk flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-
- return;
- }
-
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
- if ((pAd->BulkOutPending[MGMTPIPEIDX] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX))
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
- return;
- }
-
- pAd->BulkOutPending[MGMTPIPEIDX] = TRUE;
- pAd->watchDogTxPendingCnt[MGMTPIPEIDX] = 1;
- pMLMEContext->IRPPending = TRUE;
- pMLMEContext->bWaitingBulkOut = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
- // Increase Total transmit byte counter
- pAd->RalinkCounters.TransmittedByteCount += pMLMEContext->BulkOutSize;
-
- // Clear MLME bulk flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pMLMEContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
- // Init Tx context descriptor
- RTUSBInitTxDesc(pAd, pMLMEContext, MGMTPIPEIDX, (usb_complete_t)RTUSBBulkOutMLMEPacketComplete);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- //For mgmt urb buffer, because we use sk_buff, so we need to notify the USB controller do dma mapping.
- pUrb->transfer_dma = 0;
- pUrb->transfer_flags &= (~URB_NO_TRANSFER_DMA_MAP);
-#endif
-
- pUrb = pMLMEContext->pUrb;
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutMLMEPacket: Submit MLME URB failed %d\n", ret));
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
- pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
- pAd->watchDogTxPendingCnt[MGMTPIPEIDX] = 0;
- pMLMEContext->IRPPending = FALSE;
- pMLMEContext->bWaitingBulkOut = TRUE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
- return;
- }
-
- //DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutMLMEPacket \n"));
-// printk("<---RTUSBBulkOutMLMEPacket,Cpu=%d!, Dma=%d, SwIdx=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx);
-}
-
-
-VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- PTX_CONTEXT pMLMEContext;
- PRTMP_ADAPTER pAd;
- NTSTATUS Status;
- POS_COOKIE pObj;
- int index;
-
- //DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutMLMEPacketComplete\n"));
- pMLMEContext = (PTX_CONTEXT)pUrb->context;
- pAd = pMLMEContext->pAd;
- pObj = (POS_COOKIE)pAd->OS_Cookie;
- Status = pUrb->status;
- index = pMLMEContext->SelfIdx;
-
- pObj->mgmt_dma_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note: PsPoll use BulkOutPipeId = 0
-
- ========================================================================
-*/
-VOID RTUSBBulkOutPsPoll(
- IN PRTMP_ADAPTER pAd)
-{
- PTX_CONTEXT pPsPollContext = &(pAd->PsPollContext);
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- if ((pAd->BulkOutPending[0] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX))
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
- return;
- }
- pAd->BulkOutPending[0] = TRUE;
- pAd->watchDogTxPendingCnt[0] = 1;
- pPsPollContext->IRPPending = TRUE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
-
- // Clear PS-Poll bulk flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL);
-
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR)pPsPollContext->TransferBuffer, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-
- // Init Tx context descriptor
- RTUSBInitTxDesc(pAd, pPsPollContext, MGMTPIPEIDX, (usb_complete_t)RTUSBBulkOutPsPollComplete);
-
- pUrb = pPsPollContext->pUrb;
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- pAd->BulkOutPending[0] = FALSE;
- pAd->watchDogTxPendingCnt[0] = 0;
- pPsPollContext->IRPPending = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutPsPoll: Submit Tx URB failed %d\n", ret));
- return;
- }
-
-}
-
-// PS-Poll frame use BulkOutPipeId = 0
-VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb,struct pt_regs *pt_regs)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pPsPollContext;
- NTSTATUS Status;
- POS_COOKIE pObj;
-
-
- pPsPollContext= (PTX_CONTEXT)pUrb->context;
- pAd = pPsPollContext->pAd;
- Status = pUrb->status;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
- pObj->pspoll_frame_complete_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->pspoll_frame_complete_task);
-
-}
-
-VOID DoBulkIn(IN RTMP_ADAPTER *pAd)
-{
- PRX_CONTEXT pRxContext;
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext = &(pAd->RxContext[pAd->NextRxBulkInIndex]);
- if ((pAd->PendingRx > 0) || (pRxContext->Readable == TRUE) || (pRxContext->InUse == TRUE))
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- return;
- }
- pRxContext->InUse = TRUE;
- pRxContext->IRPPending = TRUE;
- pAd->PendingRx++;
- pAd->BulkInReq++;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- // Init Rx context descriptor
- NdisZeroMemory(pRxContext->TransferBuffer, pRxContext->BulkInOffset);
- RTUSBInitRxDesc(pAd, pRxContext);
-
- pUrb = pRxContext->pUrb;
- if ((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- { // fail
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pAd->PendingRx--;
- pAd->BulkInReq--;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkReceive: Submit Rx URB failed %d\n", ret));
- }
- else
- { // success
- ASSERT((pRxContext->InUse == pRxContext->IRPPending));
- //printk("BIDone, Pend=%d,BIIdx=%d,BIRIdx=%d!\n", pAd->PendingRx, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex);
- }
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- USB_RxPacket initializes a URB and uses the Rx IRP to submit it
- to USB. It checks if an Rx Descriptor is available and passes the
- the coresponding buffer to be filled. If no descriptor is available
- fails the request. When setting the completion routine we pass our
- Adapter Object as Context.
-
- Arguments:
-
- Return Value:
- TRUE found matched tuple cache
- FALSE no matched found
-
- Note:
-
- ========================================================================
-*/
-#define fRTMP_ADAPTER_NEED_STOP_RX \
- (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
- fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_RESET_IN_PROGRESS | \
- fRTMP_ADAPTER_REMOVE_IN_PROGRESS | fRTMP_ADAPTER_BULKIN_RESET)
-
-#define fRTMP_ADAPTER_NEED_STOP_HANDLE_RX \
- (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
- fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_RESET_IN_PROGRESS | \
- fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
-
-VOID RTUSBBulkReceive(
- IN PRTMP_ADAPTER pAd)
-{
- PRX_CONTEXT pRxContext;
- unsigned long IrqFlags;
-
-
- /* sanity check */
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_HANDLE_RX))
- return;
-
- while(1)
- {
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext = &(pAd->RxContext[pAd->NextRxBulkInReadIndex]);
- if (((pRxContext->InUse == FALSE) && (pRxContext->Readable == TRUE)) &&
- (pRxContext->bRxHandling == FALSE))
- {
- pRxContext->bRxHandling = TRUE;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- // read RxContext, Since not
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- STARxDoneInterruptHandle(pAd, TRUE);
-#endif // CONFIG_STA_SUPPORT //
-
- // Finish to handle this bulkIn buffer.
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext->BulkInOffset = 0;
- pRxContext->Readable = FALSE;
- pRxContext->bRxHandling = FALSE;
- pAd->ReadPosition = 0;
- pAd->TransferBufferLength = 0;
- INC_RING_INDEX(pAd->NextRxBulkInReadIndex, RX_RING_SIZE);
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- }
- else
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- break;
- }
- }
-
- if (!(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_RX)))
- DoBulkIn(pAd);
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- This routine process Rx Irp and call rx complete function.
-
- Arguments:
- DeviceObject Pointer to the device object for next lower
- device. DeviceObject passed in here belongs to
- the next lower driver in the stack because we
- were invoked via IoCallDriver in USB_RxPacket
- AND it is not OUR device object
- Irp Ptr to completed IRP
- Context Ptr to our Adapter object (context specified
- in IoSetCompletionRoutine
-
- Return Value:
- Always returns STATUS_MORE_PROCESSING_REQUIRED
-
- Note:
- Always returns STATUS_MORE_PROCESSING_REQUIRED
- ========================================================================
-*/
-VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- // use a receive tasklet to handle received packets;
- // or sometimes hardware IRQ will be disabled here, so we can not
- // use spin_lock_bh()/spin_unlock_bh() after IRQ is disabled. :<
- PRX_CONTEXT pRxContext;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
-
-
- pRxContext = (PRX_CONTEXT)pUrb->context;
- pAd = pRxContext->pAd;
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- pObj->rx_done_task.data = (unsigned long)pUrb;
- tasklet_hi_schedule(&pObj->rx_done_task);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBKickBulkOut(
- IN PRTMP_ADAPTER pAd)
-{
- // BulkIn Reset will reset whole USB PHY. So we need to make sure fRTMP_ADAPTER_BULKIN_RESET not flaged.
- if (!RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX)
-#ifdef RALINK_ATE
- && !(ATE_ON(pAd))
-#endif // RALINK_ATE //
- )
- {
- // 2. PS-Poll frame is next
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL))
- {
- RTUSBBulkOutPsPoll(pAd);
- }
-
- // 5. Mlme frame is next
- else if ((RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME)) &&
- (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE))
- {
- RTUSBBulkOutMLMEPacket(pAd, pAd->MgmtRing.TxDmaIdx);
- }
-
- // 6. Data frame normal is next
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 0, pAd->NextBulkOutIndex[0]);
- }
- }
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_2))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 1, pAd->NextBulkOutIndex[1]);
- }
- }
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_3))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 2, pAd->NextBulkOutIndex[2]);
- }
- }
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_4))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- RTUSBBulkOutDataPacket(pAd, 3, pAd->NextBulkOutIndex[3]);
- }
- }
- //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_5))
- {
- if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) ||
- (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- ))
- {
- }
- }
-
- // 7. Null frame is the last
- else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL))
- {
- if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- RTUSBBulkOutNullFrame(pAd);
- }
- }
-
- // 8. No data avaliable
- else
- {
-
- }
- }
-#ifdef RALINK_ATE
- /* If the mode is in ATE mode. */
- else if((ATE_ON(pAd)) &&
- !RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX))// PETER : watch out !
- {
- if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE))
- {
- ATE_RTUSBBulkOutDataPacket(pAd, 0);
- }
- }
-#endif // RALINK_ATE //
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Call from Reset action after BulkOut failed.
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBCleanUpDataBulkOutQueue(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR Idx;
- PHT_TX_CONTEXT pTxContext;
-
- DBGPRINT(RT_DEBUG_TRACE, ("--->CleanUpDataBulkOutQueue\n"));
-
- for (Idx = 0; Idx < 4; Idx++)
- {
- pTxContext = &pAd->TxContext[Idx];
-
- pTxContext->CurWritePosition = pTxContext->NextBulkOutPosition;
- pTxContext->LastOne = FALSE;
- NdisAcquireSpinLock(&pAd->BulkOutLock[Idx]);
- pAd->BulkOutPending[Idx] = FALSE;
- NdisReleaseSpinLock(&pAd->BulkOutLock[Idx]);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<---CleanUpDataBulkOutQueue\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBCleanUpMLMEBulkOutQueue(
- IN PRTMP_ADAPTER pAd)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("--->CleanUpMLMEBulkOutQueue\n"));
- DBGPRINT(RT_DEBUG_TRACE, ("<---CleanUpMLMEBulkOutQueue\n"));
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBCancelPendingIRPs(
- IN PRTMP_ADAPTER pAd)
-{
- RTUSBCancelPendingBulkInIRP(pAd);
- RTUSBCancelPendingBulkOutIRP(pAd);
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd)
-{
- PRX_CONTEXT pRxContext;
- UINT i;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("--->RTUSBCancelPendingBulkInIRP\n"));
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- pRxContext = &(pAd->RxContext[i]);
- if(pRxContext->IRPPending == TRUE)
- {
- RTUSB_UNLINK_URB(pRxContext->pUrb);
- pRxContext->IRPPending = FALSE;
- pRxContext->InUse = FALSE;
- //NdisInterlockedDecrement(&pAd->PendingRx);
- //pAd->PendingRx--;
- }
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("<---RTUSBCancelPendingBulkInIRP\n"));
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBCancelPendingBulkOutIRP(
- IN PRTMP_ADAPTER pAd)
-{
- PHT_TX_CONTEXT pHTTXContext;
- PTX_CONTEXT pMLMEContext;
- PTX_CONTEXT pBeaconContext;
- PTX_CONTEXT pNullContext;
- PTX_CONTEXT pPsPollContext;
- PTX_CONTEXT pRTSContext;
- UINT i, Idx;
-// unsigned int IrqFlags;
-// NDIS_SPIN_LOCK *pLock;
-// BOOLEAN *pPending;
-
-
-// pLock = &pAd->BulkOutLock[MGMTPIPEIDX];
-// pPending = &pAd->BulkOutPending[MGMTPIPEIDX];
-
- for (Idx = 0; Idx < 4; Idx++)
- {
- pHTTXContext = &(pAd->TxContext[Idx]);
-
- if (pHTTXContext->IRPPending == TRUE)
- {
-
- // Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself
- // remove it from the HeadPendingSendList and NULL out HeadPendingSendList
- // when the last IRP on the list has been cancelled; that's how we exit this loop
- //
-
- RTUSB_UNLINK_URB(pHTTXContext->pUrb);
-
- // Sleep 200 microseconds to give cancellation time to work
- RTMPusecDelay(200);
- }
-
-#ifdef RALINK_ATE
- pHTTXContext->bCopySavePad = 0;
- pHTTXContext->CurWritePosition = 0;
- pHTTXContext->CurWriteRealPos = 0;
- pHTTXContext->bCurWriting = FALSE;
- pHTTXContext->NextBulkOutPosition = 0;
- pHTTXContext->ENextBulkOutPosition = 0;
-#endif // RALINK_ATE //
- pAd->BulkOutPending[Idx] = FALSE;
- }
-
- //RTMP_IRQ_LOCK(pLock, IrqFlags);
- for (i = 0; i < MGMT_RING_SIZE; i++)
- {
- pMLMEContext = (PTX_CONTEXT)pAd->MgmtRing.Cell[i].AllocVa;
- if(pMLMEContext && (pMLMEContext->IRPPending == TRUE))
- {
-
- // Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself
- // remove it from the HeadPendingSendList and NULL out HeadPendingSendList
- // when the last IRP on the list has been cancelled; that's how we exit this loop
- //
-
- RTUSB_UNLINK_URB(pMLMEContext->pUrb);
- pMLMEContext->IRPPending = FALSE;
-
- // Sleep 200 microsecs to give cancellation time to work
- RTMPusecDelay(200);
- }
- }
- pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
- //RTMP_IRQ_UNLOCK(pLock, IrqFlags);
-
-
- for (i = 0; i < BEACON_RING_SIZE; i++)
- {
- pBeaconContext = &(pAd->BeaconContext[i]);
-
- if(pBeaconContext->IRPPending == TRUE)
- {
-
- // Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself
- // remove it from the HeadPendingSendList and NULL out HeadPendingSendList
- // when the last IRP on the list has been cancelled; that's how we exit this loop
- //
-
- RTUSB_UNLINK_URB(pBeaconContext->pUrb);
-
- // Sleep 200 microsecs to give cancellation time to work
- RTMPusecDelay(200);
- }
- }
-
- pNullContext = &(pAd->NullContext);
- if (pNullContext->IRPPending == TRUE)
- RTUSB_UNLINK_URB(pNullContext->pUrb);
-
- pRTSContext = &(pAd->RTSContext);
- if (pRTSContext->IRPPending == TRUE)
- RTUSB_UNLINK_URB(pRTSContext->pUrb);
-
- pPsPollContext = &(pAd->PsPollContext);
- if (pPsPollContext->IRPPending == TRUE)
- RTUSB_UNLINK_URB(pPsPollContext->pUrb);
-
- for (Idx = 0; Idx < 4; Idx++)
- {
- NdisAcquireSpinLock(&pAd->BulkOutLock[Idx]);
- pAd->BulkOutPending[Idx] = FALSE;
- NdisReleaseSpinLock(&pAd->BulkOutLock[Idx]);
- }
-}
-
+#include "../../rt2870/common/rtusb_bulk.c"
diff --git a/drivers/staging/rt3070/common/rtusb_data.c b/drivers/staging/rt3070/common/rtusb_data.c
index 521309a2ae53..d05deb870f46 100644
--- a/drivers/staging/rt3070/common/rtusb_data.c
+++ b/drivers/staging/rt3070/common/rtusb_data.c
@@ -1,218 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtusb_data.c
-
- Abstract:
- Ralink USB driver Tx/Rx functions.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan 03-25-2006 created
-
-*/
-#include "../rt_config.h"
-
-extern UCHAR Phy11BGNextRateUpward[]; // defined in mlme.c
-extern UCHAR EpToQueue[];
-
-
-VOID REPORT_AMSDU_FRAMES_TO_LLC(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataSize)
-{
- PNDIS_PACKET pPacket;
- UINT nMSDU;
- struct sk_buff *pSkb;
-
- nMSDU = 0;
- /* allocate a rx packet */
- pSkb = dev_alloc_skb(RX_BUFFER_AGGRESIZE);
- pPacket = (PNDIS_PACKET)OSPKT_TO_RTPKT(pSkb);
- if (pSkb)
- {
-
- /* convert 802.11 to 802.3 packet */
- pSkb->dev = get_netdev_from_bssid(pAd, BSS0);
- RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
- deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,("Can't allocate skb\n"));
- }
-}
-
-NDIS_STATUS RTUSBFreeDescriptorRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId,
- IN UINT32 NumberRequired)
-{
-// UCHAR FreeNumber = 0;
-// UINT Index;
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- unsigned long IrqFlags;
- HT_TX_CONTEXT *pHTTXContext;
-
-
- pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- if ((pHTTXContext->CurWritePosition < pHTTXContext->NextBulkOutPosition) && ((pHTTXContext->CurWritePosition + NumberRequired + LOCAL_TXBUF_SIZE) > pHTTXContext->NextBulkOutPosition))
- {
-
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
- }
- else if ((pHTTXContext->CurWritePosition == 8) && (pHTTXContext->NextBulkOutPosition < (NumberRequired + LOCAL_TXBUF_SIZE)))
- {
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
- }
- else if (pHTTXContext->bCurWriting == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE,("RTUSBFreeD c3 --> QueIdx=%d, CWPos=%ld, NBOutPos=%ld!\n", BulkOutPipeId, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition));
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
- }
- else
- {
- Status = NDIS_STATUS_SUCCESS;
- }
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
-
- return (Status);
-}
-
-
-NDIS_STATUS RTUSBFreeDescriptorRelease(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR BulkOutPipeId)
-{
- unsigned long IrqFlags;
- HT_TX_CONTEXT *pHTTXContext;
-
- pHTTXContext = &pAd->TxContext[BulkOutPipeId];
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- pHTTXContext->bCurWriting = FALSE;
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
- return (NDIS_STATUS_SUCCESS);
-}
-
-
-BOOLEAN RTUSBNeedQueueBackForAgg(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR BulkOutPipeId)
-{
- unsigned long IrqFlags;
- HT_TX_CONTEXT *pHTTXContext;
- BOOLEAN needQueBack = FALSE;
-
- pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
- if ((pHTTXContext->IRPPending == TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */)
- {
- if ((pHTTXContext->CurWritePosition < pHTTXContext->ENextBulkOutPosition) &&
- (((pHTTXContext->ENextBulkOutPosition+MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT) || (pHTTXContext->CurWritePosition > MAX_AGGREGATION_SIZE)))
- {
- needQueBack = TRUE;
- }
- else if ((pHTTXContext->CurWritePosition > pHTTXContext->ENextBulkOutPosition) &&
- ((pHTTXContext->ENextBulkOutPosition + MAX_AGGREGATION_SIZE) < pHTTXContext->CurWritePosition))
- {
- needQueBack = TRUE;
- }
- }
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
- return needQueBack;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBRejectPendingPackets(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR Index;
- PQUEUE_ENTRY pEntry;
- PNDIS_PACKET pPacket;
- PQUEUE_HEADER pQueue;
-
-
- for (Index = 0; Index < 4; Index++)
- {
- NdisAcquireSpinLock(&pAd->TxSwQueueLock[Index]);
- while (pAd->TxSwQueue[Index].Head != NULL)
- {
- pQueue = (PQUEUE_HEADER) &(pAd->TxSwQueue[Index]);
- pEntry = RemoveHeadQueue(pQueue);
- pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
- NdisReleaseSpinLock(&pAd->TxSwQueueLock[Index]);
-
- }
-
-}
-
-VOID RTMPWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst)
-{
- pTxInfo->USBDMATxPktLen = USBDMApktLen;
- pTxInfo->QSEL = QueueSel;
- if (QueueSel != FIFO_EDCA)
- DBGPRINT(RT_DEBUG_TRACE, ("====> QueueSel != FIFO_EDCA<============\n"));
- pTxInfo->USBDMANextVLD = FALSE; //NextValid; // Need to check with Jan about this.
- pTxInfo->USBDMATxburst = TxBurst;
- pTxInfo->WIV = bWiv;
- pTxInfo->SwUseLastRound = 0;
- pTxInfo->rsv = 0;
- pTxInfo->rsv2 = 0;
-}
-
+#include "../../rt2870/common/rtusb_data.c"
diff --git a/drivers/staging/rt3070/common/rtusb_io.c b/drivers/staging/rt3070/common/rtusb_io.c
index a6a52e3445f9..20a0b56e58b0 100644
--- a/drivers/staging/rt3070/common/rtusb_io.c
+++ b/drivers/staging/rt3070/common/rtusb_io.c
@@ -1,1908 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtusb_io.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 06-25-2004 created
-*/
-
-#include "../rt_config.h"
-
-
-/*
- ========================================================================
-
- Routine Description: NIC initialization complete
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-
-NTSTATUS RTUSBFirmwareRun(
- IN PRTMP_ADAPTER pAd)
-{
- NTSTATUS Status;
-
- Status = RTUSB_VendorRequest(
- pAd,
- USBD_TRANSFER_DIRECTION_OUT,
- DEVICE_VENDOR_REQUEST_OUT,
- 0x01,
- 0x8,
- 0,
- NULL,
- 0);
-
- return Status;
-}
-
-
-
-/*
- ========================================================================
-
- Routine Description: Write Firmware to NIC.
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBFirmwareWrite(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFwImage,
- IN ULONG FwLen)
-{
- UINT32 MacReg;
- NTSTATUS Status;
-// ULONG i;
- USHORT writeLen;
-
- Status = RTUSBReadMACRegister(pAd, MAC_CSR0, &MacReg);
-
-
- writeLen = FwLen;
- RTUSBMultiWrite(pAd, FIRMWARE_IMAGE_BASE, pFwImage, writeLen);
-
- Status = RTUSBWriteMACRegister(pAd, 0x7014, 0xffffffff);
- Status = RTUSBWriteMACRegister(pAd, 0x701c, 0xffffffff);
- Status = RTUSBFirmwareRun(pAd);
-
- RTMPusecDelay(10000);
- RTUSBWriteMACRegister(pAd,H2M_MAILBOX_CSR,0);
- AsicSendCommandToMcu(pAd, 0x72, 0x00, 0x00, 0x00);//reset rf by MCU supported by new firmware
-
- return Status;
-}
-
-
-/*
- ========================================================================
-
- Routine Description: Get current firmware operation mode (Return Value)
-
- Arguments:
-
- Return Value:
- 0 or 1 = Downloaded by host driver
- others = Driver doesn't download firmware
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBFirmwareOpmode(
- IN PRTMP_ADAPTER pAd,
- OUT PUINT32 pValue)
-{
- NTSTATUS Status;
-
- Status = RTUSB_VendorRequest(
- pAd,
- (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK),
- DEVICE_VENDOR_REQUEST_IN,
- 0x1,
- 0x11,
- 0,
- pValue,
- 4);
- return Status;
-}
-NTSTATUS RTUSBVenderReset(
- IN PRTMP_ADAPTER pAd)
-{
- NTSTATUS Status;
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("-->RTUSBVenderReset\n"));
- Status = RTUSB_VendorRequest(
- pAd,
- USBD_TRANSFER_DIRECTION_OUT,
- DEVICE_VENDOR_REQUEST_OUT,
- 0x01,
- 0x1,
- 0,
- NULL,
- 0);
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("<--RTUSBVenderReset\n"));
- return Status;
-}
-/*
- ========================================================================
-
- Routine Description: Read various length data from RT2573
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBMultiRead(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT length)
-{
- NTSTATUS Status;
-
- Status = RTUSB_VendorRequest(
- pAd,
- (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK),
- DEVICE_VENDOR_REQUEST_IN,
- 0x7,
- 0,
- Offset,
- pData,
- length);
-
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description: Write various length data to RT2573
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBMultiWrite_OneByte(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData)
-{
- NTSTATUS Status;
-
- // TODO: In 2870, use this funciton carefully cause it's not stable.
- Status = RTUSB_VendorRequest(
- pAd,
- USBD_TRANSFER_DIRECTION_OUT,
- DEVICE_VENDOR_REQUEST_OUT,
- 0x6,
- 0,
- Offset,
- pData,
- 1);
-
- return Status;
-}
-
-NTSTATUS RTUSBMultiWrite(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length)
-{
- NTSTATUS Status;
-
-
- USHORT index = 0,Value;
- PUCHAR pSrc = pData;
- USHORT resude = 0;
-
- resude = length % 2;
- length += resude;
- do
- {
- Value =(USHORT)( *pSrc | (*(pSrc + 1) << 8));
- Status = RTUSBSingleWrite(pAd,Offset + index,Value);
- index +=2;
- length -= 2;
- pSrc = pSrc + 2;
- }while(length > 0);
-
- return Status;
-}
-
-
-NTSTATUS RTUSBSingleWrite(
- IN RTMP_ADAPTER *pAd,
- IN USHORT Offset,
- IN USHORT Value)
-{
- NTSTATUS Status;
-
- Status = RTUSB_VendorRequest(
- pAd,
- USBD_TRANSFER_DIRECTION_OUT,
- DEVICE_VENDOR_REQUEST_OUT,
- 0x2,
- Value,
- Offset,
- NULL,
- 0);
-
- return Status;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description: Read 32-bit MAC register
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBReadMACRegister(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUINT32 pValue)
-{
- NTSTATUS Status;
- UINT32 localVal;
-
- Status = RTUSB_VendorRequest(
- pAd,
- (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK),
- DEVICE_VENDOR_REQUEST_IN,
- 0x7,
- 0,
- Offset,
- &localVal,
- 4);
-
- *pValue = le2cpu32(localVal);
-
-
- if (Status < 0)
- *pValue = 0xffffffff;
-
- return Status;
-}
-
-
-/*
- ========================================================================
-
- Routine Description: Write 32-bit MAC register
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBWriteMACRegister(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN UINT32 Value)
-{
- NTSTATUS Status;
- UINT32 localVal;
-
- localVal = Value;
-
- Status = RTUSBSingleWrite(pAd, Offset, (USHORT)(localVal & 0xffff));
- Status = RTUSBSingleWrite(pAd, Offset + 2, (USHORT)((localVal & 0xffff0000) >> 16));
-
- return Status;
-}
-
-
-
-#if 1
-/*
- ========================================================================
-
- Routine Description: Read 8-bit BBP register
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBReadBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN PUCHAR pValue)
-{
- BBP_CSR_CFG_STRUC BbpCsr;
- UINT i = 0;
- NTSTATUS status;
-
- // Verify the busy condition
- do
- {
- status = RTUSBReadMACRegister(pAd, BBP_CSR_CFG, &BbpCsr.word);
- if(status >= 0)
- {
- if (!(BbpCsr.field.Busy == BUSY))
- break;
- }
- printk("RTUSBReadBBPRegister(BBP_CSR_CFG_1):retry count=%d!\n", i);
- i++;
- }
- while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
- if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- //
- // Read failed then Return Default value.
- //
- *pValue = pAd->BbpWriteLatch[Id];
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
- return STATUS_UNSUCCESSFUL;
- }
-
- // Prepare for write material
- BbpCsr.word = 0;
- BbpCsr.field.fRead = 1;
- BbpCsr.field.Busy = 1;
- BbpCsr.field.RegNum = Id;
- RTUSBWriteMACRegister(pAd, BBP_CSR_CFG, BbpCsr.word);
-
- i = 0;
- // Verify the busy condition
- do
- {
- status = RTUSBReadMACRegister(pAd, BBP_CSR_CFG, &BbpCsr.word);
- if (status >= 0)
- {
- if (!(BbpCsr.field.Busy == BUSY))
- {
- *pValue = (UCHAR)BbpCsr.field.Value;
- break;
- }
- }
- printk("RTUSBReadBBPRegister(BBP_CSR_CFG_2):retry count=%d!\n", i);
- i++;
- }
- while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
- if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- //
- // Read failed then Return Default value.
- //
- *pValue = pAd->BbpWriteLatch[Id];
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
- return STATUS_UNSUCCESSFUL;
- }
-
- return STATUS_SUCCESS;
-}
-#else
-/*
- ========================================================================
-
- Routine Description: Read 8-bit BBP register via firmware
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBReadBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN PUCHAR pValue)
-{
- BBP_CSR_CFG_STRUC BbpCsr;
- int i, k;
- for (i=0; i<MAX_BUSY_COUNT; i++)
- {
- RTUSBReadMACRegister(pAd, H2M_BBP_AGENT, &BbpCsr.word);
- if (BbpCsr.field.Busy == BUSY)
- {
- continue;
- }
- BbpCsr.word = 0;
- BbpCsr.field.fRead = 1;
- BbpCsr.field.BBP_RW_MODE = 1;
- BbpCsr.field.Busy = 1;
- BbpCsr.field.RegNum = Id;
- RTUSBWriteMACRegister(pAd, H2M_BBP_AGENT, BbpCsr.word);
- AsicSendCommandToMcu(pAd, 0x80, 0xff, 0x0, 0x0);
- for (k=0; k<MAX_BUSY_COUNT; k++)
- {
- RTUSBReadMACRegister(pAd, H2M_BBP_AGENT, &BbpCsr.word);
- if (BbpCsr.field.Busy == IDLE)
- break;
- }
- if ((BbpCsr.field.Busy == IDLE) &&
- (BbpCsr.field.RegNum == Id))
- {
- *pValue = (UCHAR)BbpCsr.field.Value;
- break;
- }
- }
- if (BbpCsr.field.Busy == BUSY)
- {
- DBGPRINT_ERR(("BBP read R%d=0x%x fail\n", Id, BbpCsr.word));
- *pValue = pAd->BbpWriteLatch[Id];
- return STATUS_UNSUCCESSFUL;
- }
- return STATUS_SUCCESS;
-}
-#endif
-
-#if 1
-/*
- ========================================================================
-
- Routine Description: Write 8-bit BBP register
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBWriteBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN UCHAR Value)
-{
- BBP_CSR_CFG_STRUC BbpCsr;
- UINT i = 0;
- NTSTATUS status;
- // Verify the busy condition
- do
- {
- status = RTUSBReadMACRegister(pAd, BBP_CSR_CFG, &BbpCsr.word);
- if (status >= 0)
- {
- if (!(BbpCsr.field.Busy == BUSY))
- break;
- }
- printk("RTUSBWriteBBPRegister(BBP_CSR_CFG):retry count=%d!\n", i);
- i++;
- }
- while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
- if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
- return STATUS_UNSUCCESSFUL;
- }
-
- // Prepare for write material
- BbpCsr.word = 0;
- BbpCsr.field.fRead = 0;
- BbpCsr.field.Value = Value;
- BbpCsr.field.Busy = 1;
- BbpCsr.field.RegNum = Id;
- RTUSBWriteMACRegister(pAd, BBP_CSR_CFG, BbpCsr.word);
-
- pAd->BbpWriteLatch[Id] = Value;
-
- return STATUS_SUCCESS;
-}
-#else
-/*
- ========================================================================
-
- Routine Description: Write 8-bit BBP register via firmware
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-
-NTSTATUS RTUSBWriteBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN UCHAR Value)
-
-{
- BBP_CSR_CFG_STRUC BbpCsr;
- int BusyCnt;
- for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++)
- {
- RTMP_IO_READ32(pAd, H2M_BBP_AGENT, &BbpCsr.word);
- if (BbpCsr.field.Busy == BUSY)
- continue;
- BbpCsr.word = 0;
- BbpCsr.field.fRead = 0;
- BbpCsr.field.BBP_RW_MODE = 1;
- BbpCsr.field.Busy = 1;
- BbpCsr.field.Value = Value;
- BbpCsr.field.RegNum = Id;
- RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, BbpCsr.word);
- AsicSendCommandToMcu(pAd, 0x80, 0xff, 0x0, 0x0);
- pAd->BbpWriteLatch[Id] = Value;
- break;
- }
- if (BusyCnt == MAX_BUSY_COUNT)
- {
- DBGPRINT_ERR(("BBP write R%d=0x%x fail\n", Id, BbpCsr.word));
- return STATUS_UNSUCCESSFUL;
- }
- return STATUS_SUCCESS;
-}
-#endif
-/*
- ========================================================================
-
- Routine Description: Write RF register through MAC
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBWriteRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 Value)
-{
- PHY_CSR4_STRUC PhyCsr4;
- UINT i = 0;
- NTSTATUS status;
-
- NdisZeroMemory(&PhyCsr4, sizeof(PHY_CSR4_STRUC));
- do
- {
- status = RTUSBReadMACRegister(pAd, RF_CSR_CFG0, &PhyCsr4.word);
- if (status >= 0)
- {
- if (!(PhyCsr4.field.Busy))
- break;
- }
- printk("RTUSBWriteRFRegister(RF_CSR_CFG0):retry count=%d!\n", i);
- i++;
- }
- while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
- if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
- return STATUS_UNSUCCESSFUL;
- }
-
- RTUSBWriteMACRegister(pAd, RF_CSR_CFG0, Value);
-
- return STATUS_SUCCESS;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBReadEEPROM(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT length)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
-#ifdef RT30xx
- if(pAd->bUseEfuse)
- {
- Status =eFuseRead(pAd, Offset, pData, length);
- }
- else
-#endif // RT30xx //
- {
- Status = RTUSB_VendorRequest(
- pAd,
- (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK),
- DEVICE_VENDOR_REQUEST_IN,
- 0x9,
- 0,
- Offset,
- pData,
- length);
- }
-
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBWriteEEPROM(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
-#ifdef RT30xx
- if(pAd->bUseEfuse)
- {
- Status = eFuseWrite(pAd, Offset, pData, length);
- }
- else
-#endif // RT30xx //
- {
- Status = RTUSB_VendorRequest(
- pAd,
- USBD_TRANSFER_DIRECTION_OUT,
- DEVICE_VENDOR_REQUEST_OUT,
- 0x8,
- 0,
- Offset,
- pData,
- length);
- }
-
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBPutToSleep(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 value;
-
- // Timeout 0x40 x 50us
- value = (SLEEPCID<<16)+(OWNERMCU<<24)+ (0x40<<8)+1;
- RTUSBWriteMACRegister(pAd, 0x7010, value);
- RTUSBWriteMACRegister(pAd, 0x404, 0x30);
- //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("Sleep Mailbox testvalue %x\n", value));
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSBWakeUp(
- IN PRTMP_ADAPTER pAd)
-{
- NTSTATUS Status;
-
- Status = RTUSB_VendorRequest(
- pAd,
- USBD_TRANSFER_DIRECTION_OUT,
- DEVICE_VENDOR_REQUEST_OUT,
- 0x01,
- 0x09,
- 0,
- NULL,
- 0);
-
- return Status;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBInitializeCmdQ(
- IN PCmdQ cmdq)
-{
- cmdq->head = NULL;
- cmdq->tail = NULL;
- cmdq->size = 0;
- cmdq->CmdQState = RT2870_THREAD_INITED;
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTUSBEnqueueCmdFromNdis(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_OID Oid,
- IN BOOLEAN SetInformation,
- IN PVOID pInformationBuffer,
- IN UINT32 InformationBufferLength)
-{
- NDIS_STATUS status;
- PCmdQElmt cmdqelmt = NULL;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-
- if (pObj->RTUSBCmdThr_pid < 0)
- return (NDIS_STATUS_RESOURCES);
-
- status = RTMPAllocateMemory((PVOID *)&cmdqelmt, sizeof(CmdQElmt));
- if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL))
- return (NDIS_STATUS_RESOURCES);
-
- cmdqelmt->buffer = NULL;
- if (pInformationBuffer != NULL)
- {
- status = RTMPAllocateMemory((PVOID *)&cmdqelmt->buffer, InformationBufferLength);
- if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt->buffer == NULL))
- {
- kfree(cmdqelmt);
- return (NDIS_STATUS_RESOURCES);
- }
- else
- {
- NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer, InformationBufferLength);
- cmdqelmt->bufferlength = InformationBufferLength;
- }
- }
- else
- cmdqelmt->bufferlength = 0;
-
- cmdqelmt->command = Oid;
- cmdqelmt->CmdFromNdis = TRUE;
- if (SetInformation == TRUE)
- cmdqelmt->SetOperation = TRUE;
- else
- cmdqelmt->SetOperation = FALSE;
-
- NdisAcquireSpinLock(&pAd->CmdQLock);
- if (pAd->CmdQ.CmdQState & RT2870_THREAD_CAN_DO_INSERT)
- {
- EnqueueCmd((&pAd->CmdQ), cmdqelmt);
- status = NDIS_STATUS_SUCCESS;
- }
- else
- {
- status = NDIS_STATUS_FAILURE;
- }
- NdisReleaseSpinLock(&pAd->CmdQLock);
-
- if (status == NDIS_STATUS_FAILURE)
- {
- if (cmdqelmt->buffer)
- NdisFreeMemory(cmdqelmt->buffer, cmdqelmt->bufferlength, 0);
- NdisFreeMemory(cmdqelmt, sizeof(CmdQElmt), 0);
- }
- else
- RTUSBCMDUp(pAd);
-
-
- return(NDIS_STATUS_SUCCESS);
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTUSBEnqueueInternalCmd(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_OID Oid,
- IN PVOID pInformationBuffer,
- IN UINT32 InformationBufferLength)
-{
- NDIS_STATUS status;
- PCmdQElmt cmdqelmt = NULL;
-
-
- status = RTMPAllocateMemory((PVOID *)&cmdqelmt, sizeof(CmdQElmt));
- if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL))
- return (NDIS_STATUS_RESOURCES);
- NdisZeroMemory(cmdqelmt, sizeof(CmdQElmt));
-
- if(InformationBufferLength > 0)
- {
- status = RTMPAllocateMemory((PVOID *)&cmdqelmt->buffer, InformationBufferLength);
- if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt->buffer == NULL))
- {
- NdisFreeMemory(cmdqelmt, sizeof(CmdQElmt), 0);
- return (NDIS_STATUS_RESOURCES);
- }
- else
- {
- NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer, InformationBufferLength);
- cmdqelmt->bufferlength = InformationBufferLength;
- }
- }
- else
- {
- cmdqelmt->buffer = NULL;
- cmdqelmt->bufferlength = 0;
- }
-
- cmdqelmt->command = Oid;
- cmdqelmt->CmdFromNdis = FALSE;
-
- if (cmdqelmt != NULL)
- {
- NdisAcquireSpinLock(&pAd->CmdQLock);
- if (pAd->CmdQ.CmdQState & RT2870_THREAD_CAN_DO_INSERT)
- {
- EnqueueCmd((&pAd->CmdQ), cmdqelmt);
- status = NDIS_STATUS_SUCCESS;
- }
- else
- {
- status = NDIS_STATUS_FAILURE;
- }
- NdisReleaseSpinLock(&pAd->CmdQLock);
-
- if (status == NDIS_STATUS_FAILURE)
- {
- if (cmdqelmt->buffer)
- NdisFreeMemory(cmdqelmt->buffer, cmdqelmt->bufferlength, 0);
- NdisFreeMemory(cmdqelmt, sizeof(CmdQElmt), 0);
- }
- else
- RTUSBCMDUp(pAd);
- }
- return(NDIS_STATUS_SUCCESS);
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- IRQL =
-
- Note:
-
- ========================================================================
-*/
-VOID RTUSBDequeueCmd(
- IN PCmdQ cmdq,
- OUT PCmdQElmt *pcmdqelmt)
-{
- *pcmdqelmt = cmdq->head;
-
- if (*pcmdqelmt != NULL)
- {
- cmdq->head = cmdq->head->next;
- cmdq->size--;
- if (cmdq->size == 0)
- cmdq->tail = NULL;
- }
-}
-
-/*
- ========================================================================
- usb_control_msg - Builds a control urb, sends it off and waits for completion
- @dev: pointer to the usb device to send the message to
- @pipe: endpoint "pipe" to send the message to
- @request: USB message request value
- @requesttype: USB message request type value
- @value: USB message value
- @index: USB message index value
- @data: pointer to the data to send
- @size: length in bytes of the data to send
- @timeout: time in jiffies to wait for the message to complete before
- timing out (if 0 the wait is forever)
- Context: !in_interrupt ()
-
- This function sends a simple control message to a specified endpoint
- and waits for the message to complete, or timeout.
- If successful, it returns the number of bytes transferred, otherwise a negative error number.
-
- Don't use this function from within an interrupt context, like a
- bottom half handler. If you need an asynchronous message, or need to send
- a message from within interrupt context, use usb_submit_urb()
- If a thread in your driver uses this call, make sure your disconnect()
- method can wait for it to complete. Since you don't have a handle on
- the URB used, you can't cancel the request.
-
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSB_VendorRequest(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TransferFlags,
- IN UCHAR RequestType,
- IN UCHAR Request,
- IN USHORT Value,
- IN USHORT Index,
- IN PVOID TransferBuffer,
- IN UINT32 TransferBufferLength)
-{
- int ret;
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("device disconnected\n"));
- return -1;
- }
- else if (in_interrupt())
- {
- DBGPRINT(RT_DEBUG_ERROR, ("in_interrupt, RTUSB_VendorRequest Request%02x Value%04x Offset%04x\n",Request,Value,Index));
-
- return -1;
- }
- else
- {
-#define MAX_RETRY_COUNT 10
-
- int retryCount = 0;
- void *tmpBuf = TransferBuffer;
-
- // Acquire Control token
-#ifdef INF_AMAZON_SE
- ret = down_interruptible(&(pAd->UsbVendorReq_semaphore));
- if (pAd->UsbVendorReqBuf)
- {
- ASSERT(TransferBufferLength <MAX_PARAM_BUFFER_SIZE);
-
- tmpBuf = (void *)pAd->UsbVendorReqBuf;
- NdisZeroMemory(pAd->UsbVendorReqBuf, TransferBufferLength);
-
- if (RequestType == DEVICE_VENDOR_REQUEST_OUT)
- NdisMoveMemory(tmpBuf, TransferBuffer, TransferBufferLength);
- }
-#endif // INF_AMAZON_SE //
- do {
- if( RequestType == DEVICE_VENDOR_REQUEST_OUT)
- ret=usb_control_msg(pObj->pUsb_Dev, usb_sndctrlpipe( pObj->pUsb_Dev, 0 ), Request, RequestType, Value,Index, tmpBuf, TransferBufferLength, CONTROL_TIMEOUT_JIFFIES);
- else if(RequestType == DEVICE_VENDOR_REQUEST_IN)
- ret=usb_control_msg(pObj->pUsb_Dev, usb_rcvctrlpipe( pObj->pUsb_Dev, 0 ), Request, RequestType, Value,Index, tmpBuf, TransferBufferLength, CONTROL_TIMEOUT_JIFFIES);
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("vendor request direction is failed\n"));
- ret = -1;
- }
-
- retryCount++;
- if (ret < 0) {
- printk("#\n");
- RTMPusecDelay(5000);
- }
- } while((ret < 0) && (retryCount < MAX_RETRY_COUNT));
-
-#ifdef INF_AMAZON_SE
- if ((pAd->UsbVendorReqBuf) && (RequestType == DEVICE_VENDOR_REQUEST_IN))
- NdisMoveMemory(TransferBuffer, tmpBuf, TransferBufferLength);
- up(&(pAd->UsbVendorReq_semaphore));
-#endif // INF_AMAZON_SE //
-
- if (ret < 0) {
-// DBGPRINT(RT_DEBUG_ERROR, ("USBVendorRequest failed ret=%d \n",ret));
- DBGPRINT(RT_DEBUG_ERROR, ("RTUSB_VendorRequest failed(%d),TxFlags=0x%x, ReqType=%s, Req=0x%x, Index=0x%x\n",
- ret, TransferFlags, (RequestType == DEVICE_VENDOR_REQUEST_OUT ? "OUT" : "IN"), Request, Index));
- if (Request == 0x2)
- DBGPRINT(RT_DEBUG_ERROR, ("\tRequest Value=0x%04x!\n", Value));
-
- if ((TransferBuffer!= NULL) && (TransferBufferLength > 0))
- hex_dump("Failed TransferBuffer value", TransferBuffer, TransferBufferLength);
- }
- }
- return ret;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Creates an IRP to submite an IOCTL_INTERNAL_USB_RESET_PORT
- synchronously. Callers of this function must be running at
- PASSIVE LEVEL.
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-NTSTATUS RTUSB_ResetDevice(
- IN PRTMP_ADAPTER pAd)
-{
- NTSTATUS Status = TRUE;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("--->USB_ResetDevice\n"));
- //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
- return Status;
-}
-
-VOID CMDHandler(
- IN PRTMP_ADAPTER pAd)
-{
- PCmdQElmt cmdqelmt;
- PUCHAR pData;
- NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
-// ULONG Now = 0;
- NTSTATUS ntStatus;
-// unsigned long IrqFlags;
-
- while (pAd->CmdQ.size > 0)
- {
- NdisStatus = NDIS_STATUS_SUCCESS;
-
- NdisAcquireSpinLock(&pAd->CmdQLock);
- RTUSBDequeueCmd(&pAd->CmdQ, &cmdqelmt);
- NdisReleaseSpinLock(&pAd->CmdQLock);
-
- if (cmdqelmt == NULL)
- break;
-
- pData = cmdqelmt->buffer;
-
- if(!(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)))
- {
- switch (cmdqelmt->command)
- {
- case CMDTHREAD_CHECK_GPIO:
- {
-#ifdef CONFIG_STA_SUPPORT
- UINT32 data;
-#endif // CONFIG_STA_SUPPORT //
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
-
-
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Read GPIO pin2 as Hardware controlled radio state
-
- RTUSBReadMACRegister( pAd, GPIO_CTRL_CFG, &data);
-
- if (data & 0x04)
- {
- pAd->StaCfg.bHwRadio = TRUE;
- }
- else
- {
- pAd->StaCfg.bHwRadio = FALSE;
- }
-
- if(pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if(pAd->StaCfg.bRadio == TRUE)
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("!!! Radio On !!!\n"));
-
- MlmeRadioOn(pAd);
- // Update extra information
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- else
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("!!! Radio Off !!!\n"));
-
- MlmeRadioOff(pAd);
- // Update extra information
- pAd->ExtraInfo = HW_RADIO_OFF;
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- break;
-
-#ifdef CONFIG_STA_SUPPORT
- case CMDTHREAD_QKERIODIC_EXECUT:
- {
- StaQuickResponeForRateUpExec(NULL, pAd, NULL, NULL);
- }
- break;
-#endif // CONFIG_STA_SUPPORT //
-
- case CMDTHREAD_RESET_BULK_OUT:
- {
- UINT32 MACValue;
- UCHAR Index;
- int ret=0;
- PHT_TX_CONTEXT pHTTXContext;
-// RTMP_TX_RING *pTxRing;
- unsigned long IrqFlags;
-#ifdef RALINK_ATE
- PTX_CONTEXT pNullContext = &(pAd->NullContext);
-#endif // RALINK_ATE //
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("CmdThread : CMDTHREAD_RESET_BULK_OUT(ResetPipeid=0x%0x)===>\n", pAd->bulkResetPipeid));
- // All transfers must be aborted or cancelled before attempting to reset the pipe.
- //RTUSBCancelPendingBulkOutIRP(pAd);
- // Wait 10ms to let previous packet that are already in HW FIFO to clear. by MAXLEE 12-25-2007
- Index = 0;
- do
- {
- RTUSBReadMACRegister(pAd, TXRXQ_PCNT, &MACValue);
- if ((MACValue & 0xf00000/*0x800000*/) == 0)
- break;
- Index++;
- RTMPusecDelay(10000);
- }while(Index < 100);
- MACValue = 0;
- RTUSBReadMACRegister(pAd, USB_DMA_CFG, &MACValue);
- // To prevent Read Register error, we 2nd check the validity.
- if ((MACValue & 0xc00000) == 0)
- RTUSBReadMACRegister(pAd, USB_DMA_CFG, &MACValue);
- // To prevent Read Register error, we 3rd check the validity.
- if ((MACValue & 0xc00000) == 0)
- RTUSBReadMACRegister(pAd, USB_DMA_CFG, &MACValue);
- MACValue |= 0x80000;
- RTUSBWriteMACRegister(pAd, USB_DMA_CFG, MACValue);
-
- // Wait 1ms to prevent next URB to bulkout before HW reset. by MAXLEE 12-25-2007
- RTMPusecDelay(1000);
-
- MACValue &= (~0x80000);
- RTUSBWriteMACRegister(pAd, USB_DMA_CFG, MACValue);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\tSet 0x2a0 bit19. Clear USB DMA TX path\n"));
-
- // Wait 5ms to prevent next URB to bulkout before HW reset. by MAXLEE 12-25-2007
- //RTMPusecDelay(5000);
-
- if ((pAd->bulkResetPipeid & BULKOUT_MGMT_RESET_FLAG) == BULKOUT_MGMT_RESET_FLAG)
- {
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- if (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE /* pMLMEContext->bWaitingBulkOut == TRUE */)
- {
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
- }
- RTUSBKickBulkOut(pAd);
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\tTX MGMT RECOVER Done!\n"));
- }
- else
- {
- pHTTXContext = &(pAd->TxContext[pAd->bulkResetPipeid]);
- //NdisAcquireSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]);
- RTMP_INT_LOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
- if ( pAd->BulkOutPending[pAd->bulkResetPipeid] == FALSE)
- {
- pAd->BulkOutPending[pAd->bulkResetPipeid] = TRUE;
- pHTTXContext->IRPPending = TRUE;
- pAd->watchDogTxPendingCnt[pAd->bulkResetPipeid] = 1;
-
- // no matter what, clean the flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-
- //NdisReleaseSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]);
- RTMP_INT_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
-/*-----------------------------------------------------------------------------------------------*/
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- pNullContext->IRPPending = TRUE;
- //
- // If driver is still in ATE TXFRAME mode,
- // keep on transmitting ATE frames.
- //
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("pAd->ate.Mode == %d\npAd->ContinBulkOut == %d\npAd->BulkOutRemained == %d\n", pAd->ate.Mode, pAd->ContinBulkOut, atomic_read(&pAd->BulkOutRemained)));
- if((pAd->ate.Mode == ATE_TXFRAME) && ((pAd->ContinBulkOut == TRUE) || (atomic_read(&pAd->BulkOutRemained) > 0)))
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("After CMDTHREAD_RESET_BULK_OUT, continue to bulk out frames !\n"));
-
- // Init Tx context descriptor
- RTUSBInitTxDesc(pAd, pNullContext, 0/* pAd->bulkResetPipeid */, (usb_complete_t)ATE_RTUSBBulkOutDataPacketComplete);
-
- if((ret = RTUSB_SUBMIT_URB(pNullContext->pUrb))!=0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ATE_RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret));
- }
-
- pAd->BulkOutReq++;
- }
- }
- else
-#endif // RALINK_ATE //
-/*-----------------------------------------------------------------------------------------------*/
- {
- RTUSBInitHTTxDesc(pAd, pHTTXContext, pAd->bulkResetPipeid, pHTTXContext->BulkOutSize, (usb_complete_t)RTUSBBulkOutDataPacketComplete);
-
- if((ret = RTUSB_SUBMIT_URB(pHTTXContext->pUrb))!=0)
- {
- RTMP_INT_LOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
- pAd->BulkOutPending[pAd->bulkResetPipeid] = FALSE;
- pHTTXContext->IRPPending = FALSE;
- pAd->watchDogTxPendingCnt[pAd->bulkResetPipeid] = 0;
- RTMP_INT_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
-
- DBGPRINT(RT_DEBUG_ERROR, ("CmdThread : CMDTHREAD_RESET_BULK_OUT: Submit Tx URB failed %d\n", ret));
- }
- else
- {
- RTMP_IRQ_LOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
- DBGPRINT_RAW(RT_DEBUG_TRACE,("\tCMDTHREAD_RESET_BULK_OUT: TxContext[%d]:CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d, pending=%d!\n",
- pAd->bulkResetPipeid, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition,
- pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad, pAd->BulkOutPending[pAd->bulkResetPipeid]));
- DBGPRINT_RAW(RT_DEBUG_TRACE,("\t\tBulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n",
- pAd->BulkOutReq, pAd->BulkOutComplete, pAd->BulkOutCompleteOther));
- RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("\tCMDTHREAD_RESET_BULK_OUT: Submit Tx DATA URB for failed BulkReq(0x%lx) Done, status=%d!\n", pAd->bulkResetReq[pAd->bulkResetPipeid], pHTTXContext->pUrb->status));
-
- }
- }
- }
- else
- {
- //NdisReleaseSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]);
- //RTMP_INT_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("CmdThread : TX DATA RECOVER FAIL for BulkReq(0x%lx) because BulkOutPending[%d] is TRUE!\n", pAd->bulkResetReq[pAd->bulkResetPipeid], pAd->bulkResetPipeid));
- if (pAd->bulkResetPipeid == 0)
- {
- UCHAR pendingContext = 0;
- PHT_TX_CONTEXT pHTTXContext = (PHT_TX_CONTEXT)(&pAd->TxContext[pAd->bulkResetPipeid ]);
- PTX_CONTEXT pMLMEContext = (PTX_CONTEXT)(pAd->MgmtRing.Cell[pAd->MgmtRing.TxDmaIdx].AllocVa);
- PTX_CONTEXT pNULLContext = (PTX_CONTEXT)(&pAd->PsPollContext);
- PTX_CONTEXT pPsPollContext = (PTX_CONTEXT)(&pAd->NullContext);
-
- if (pHTTXContext->IRPPending)
- pendingContext |= 1;
- else if (pMLMEContext->IRPPending)
- pendingContext |= 2;
- else if (pNULLContext->IRPPending)
- pendingContext |= 4;
- else if (pPsPollContext->IRPPending)
- pendingContext |= 8;
- else
- pendingContext = 0;
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("\tTX Occupied by %d!\n", pendingContext));
- }
-
- // no matter what, clean the flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-
- RTMP_INT_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags);
-
- RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << pAd->bulkResetPipeid));
- }
-
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- //RTUSBKickBulkOut(pAd);
- }
-
- }
- /*
- // Don't cancel BULKIN.
- while ((atomic_read(&pAd->PendingRx) > 0) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- if (atomic_read(&pAd->PendingRx) > 0)
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("BulkIn IRP Pending!!cancel it!\n"));
- RTUSBCancelPendingBulkInIRP(pAd);
- }
- RTMPusecDelay(100000);
- }
-
- if ((atomic_read(&pAd->PendingRx) == 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)))
- {
- UCHAR i;
- RTUSBRxPacket(pAd);
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = 0; // Rx Bulk pointer
- for (i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
-
- pRxContext->pAd = pAd;
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
- pRxContext->ReorderInUse = FALSE;
-
- }
- RTUSBBulkReceive(pAd);
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTUSBBulkReceive\n"));
- }*/
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("CmdThread : CMDTHREAD_RESET_BULK_OUT<===\n"));
- break;
-
- case CMDTHREAD_RESET_BULK_IN:
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("CmdThread : CMDTHREAD_RESET_BULK_IN === >\n"));
-
- // All transfers must be aborted or cancelled before attempting to reset the pipe.
- {
- UINT32 MACValue;
-/*-----------------------------------------------------------------------------------------------*/
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if((pAd->PendingRx > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("ATE : BulkIn IRP Pending!!!\n"));
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
- RTMPusecDelay(100000);
- pAd->PendingRx = 0;
- }
- }
- else
-#endif // RALINK_ATE //
-/*-----------------------------------------------------------------------------------------------*/
- {
- //while ((atomic_read(&pAd->PendingRx) > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- if((pAd->PendingRx > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("BulkIn IRP Pending!!!\n"));
- RTUSBCancelPendingBulkInIRP(pAd);
- RTMPusecDelay(100000);
- pAd->PendingRx = 0;
- }
- }
-
- // Wait 10ms before reading register.
- RTMPusecDelay(10000);
- ntStatus = RTUSBReadMACRegister(pAd, MAC_CSR0, &MACValue);
-
- if ((NT_SUCCESS(ntStatus) == TRUE) &&
- (!(RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)))))
- {
- UCHAR i;
-
- if (RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)))
- break;
- pAd->NextRxBulkInPosition = pAd->RxContext[pAd->NextRxBulkInIndex].BulkInOffset;
- DBGPRINT(RT_DEBUG_TRACE, ("BULK_IN_RESET: NBIIdx=0x%x,NBIRIdx=0x%x, BIRPos=0x%lx. BIReq=x%lx, BIComplete=0x%lx, BICFail0x%lx\n",
- pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex, pAd->NextRxBulkInPosition, pAd->BulkInReq, pAd->BulkInComplete, pAd->BulkInCompleteFail));
- for (i = 0; i < RX_RING_SIZE; i++)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("\tRxContext[%d]: IRPPending=%d, InUse=%d, Readable=%d!\n"
- , i, pAd->RxContext[i].IRPPending, pAd->RxContext[i].InUse, pAd->RxContext[i].Readable));
- }
- /*
-
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("==========================================\n"));
-
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = 0; // Rx Bulk pointer
- for (i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
-
- pRxContext->pAd = pAd;
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
- pRxContext->ReorderInUse = FALSE;
-
- }*/
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
- for (i = 0; i < pAd->CommonCfg.NumOfBulkInIRP; i++)
- {
- //RTUSBBulkReceive(pAd);
- PRX_CONTEXT pRxContext;
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext = &(pAd->RxContext[pAd->NextRxBulkInIndex]);
- if ((pAd->PendingRx > 0) || (pRxContext->Readable == TRUE) || (pRxContext->InUse == TRUE))
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- break;
- }
- pRxContext->InUse = TRUE;
- pRxContext->IRPPending = TRUE;
- pAd->PendingRx++;
- pAd->BulkInReq++;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
- // Init Rx context descriptor
- RTUSBInitRxDesc(pAd, pRxContext);
- pUrb = pRxContext->pUrb;
- if ((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- { // fail
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pAd->PendingRx--;
- pAd->BulkInReq--;
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- DBGPRINT(RT_DEBUG_ERROR, ("CMDTHREAD_RESET_BULK_IN: Submit Rx URB failed(%d), status=%d\n", ret, pUrb->status));
- }
- else
- { // success
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("CMDTHREAD_RESET_BULK_IN: Submit Rx URB Done, status=%d!\n", pUrb->status));
- ASSERT((pRxContext->InUse == pRxContext->IRPPending));
- }
- }
-
- }
- else
- {
- // Card must be removed
- if (NT_SUCCESS(ntStatus) != TRUE)
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST);
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("CMDTHREAD_RESET_BULK_IN: Read Register Failed!Card must be removed!!\n\n"));
- }
- else
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR, ("CMDTHREAD_RESET_BULK_IN: Cannot do bulk in because flags(0x%lx) on !\n", pAd->Flags));
- }
- }
- }
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("CmdThread : CMDTHREAD_RESET_BULK_IN <===\n"));
- break;
-
- case CMDTHREAD_SET_ASIC_WCID:
- {
- RT_SET_ASIC_WCID SetAsicWcid;
- USHORT offset;
- UINT32 MACValue, MACRValue = 0;
- SetAsicWcid = *((PRT_SET_ASIC_WCID)(pData));
-
- if (SetAsicWcid.WCID >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- offset = MAC_WCID_BASE + ((UCHAR)SetAsicWcid.WCID)*HW_WCID_ENTRY_SIZE;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("CmdThread : CMDTHREAD_SET_ASIC_WCID : WCID = %ld, SetTid = %lx, DeleteTid = %lx.\n", SetAsicWcid.WCID, SetAsicWcid.SetTid, SetAsicWcid.DeleteTid));
- MACValue = (pAd->MacTab.Content[SetAsicWcid.WCID].Addr[3]<<24)+(pAd->MacTab.Content[SetAsicWcid.WCID].Addr[2]<<16)+(pAd->MacTab.Content[SetAsicWcid.WCID].Addr[1]<<8)+(pAd->MacTab.Content[SetAsicWcid.WCID].Addr[0]);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("1-MACValue= %x,\n", MACValue));
- RTUSBWriteMACRegister(pAd, offset, MACValue);
- // Read bitmask
- RTUSBReadMACRegister(pAd, offset+4, &MACRValue);
- if ( SetAsicWcid.DeleteTid != 0xffffffff)
- MACRValue &= (~SetAsicWcid.DeleteTid);
- if (SetAsicWcid.SetTid != 0xffffffff)
- MACRValue |= (SetAsicWcid.SetTid);
- MACRValue &= 0xffff0000;
-
- MACValue = (pAd->MacTab.Content[SetAsicWcid.WCID].Addr[5]<<8)+pAd->MacTab.Content[SetAsicWcid.WCID].Addr[4];
- MACValue |= MACRValue;
- RTUSBWriteMACRegister(pAd, offset+4, MACValue);
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("2-MACValue= %x,\n", MACValue));
- }
- break;
-
- case CMDTHREAD_SET_ASIC_WCID_CIPHER:
- {
-#ifdef CONFIG_STA_SUPPORT
- RT_SET_ASIC_WCID_ATTRI SetAsicWcidAttri;
- USHORT offset;
- UINT32 MACRValue = 0;
- SHAREDKEY_MODE_STRUC csr1;
- SetAsicWcidAttri = *((PRT_SET_ASIC_WCID_ATTRI)(pData));
-
- if (SetAsicWcidAttri.WCID >= MAX_LEN_OF_MAC_TABLE)
- return;
-
- offset = MAC_WCID_ATTRIBUTE_BASE + ((UCHAR)SetAsicWcidAttri.WCID)*HW_WCID_ATTRI_SIZE;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("Cmd : CMDTHREAD_SET_ASIC_WCID_CIPHER : WCID = %ld, Cipher = %lx.\n", SetAsicWcidAttri.WCID, SetAsicWcidAttri.Cipher));
- // Read bitmask
- RTUSBReadMACRegister(pAd, offset, &MACRValue);
- MACRValue = 0;
- MACRValue |= (((UCHAR)SetAsicWcidAttri.Cipher) << 1);
-
- RTUSBWriteMACRegister(pAd, offset, MACRValue);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("2-offset = %x , MACValue= %x,\n", offset, MACRValue));
-
- offset = PAIRWISE_IVEIV_TABLE_BASE + ((UCHAR)SetAsicWcidAttri.WCID)*HW_IVEIV_ENTRY_SIZE;
- MACRValue = 0;
- if ( (SetAsicWcidAttri.Cipher <= CIPHER_WEP128))
- MACRValue |= ( pAd->StaCfg.DefaultKeyId << 30);
- else
- MACRValue |= (0x20000000);
- RTUSBWriteMACRegister(pAd, offset, MACRValue);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("2-offset = %x , MACValue= %x,\n", offset, MACRValue));
-
- //
- // Update cipher algorithm. WSTA always use BSS0
- //
- // for adhoc mode only ,because wep status slow than add key, when use zero config
- if (pAd->StaCfg.BssType == BSS_ADHOC )
- {
- offset = MAC_WCID_ATTRIBUTE_BASE;
-
- RTUSBReadMACRegister(pAd, offset, &MACRValue);
- MACRValue &= (~0xe);
- MACRValue |= (((UCHAR)SetAsicWcidAttri.Cipher) << 1);
-
- RTUSBWriteMACRegister(pAd, offset, MACRValue);
-
- //Update group key cipher,,because wep status slow than add key, when use zero config
- RTUSBReadMACRegister(pAd, SHARED_KEY_MODE_BASE+4*(0/2), &csr1.word);
-
- csr1.field.Bss0Key0CipherAlg = SetAsicWcidAttri.Cipher;
- csr1.field.Bss0Key1CipherAlg = SetAsicWcidAttri.Cipher;
-
- RTUSBWriteMACRegister(pAd, SHARED_KEY_MODE_BASE+4*(0/2), csr1.word);
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- break;
-
-//Benson modified for USB interface, avoid in interrupt when write key, 20080724 -->
- case RT_CMD_SET_KEY_TABLE: //General call for AsicAddPairwiseKeyEntry()
- {
- RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
- KeyInfo = *((PRT_ADD_PAIRWISE_KEY_ENTRY)(pData));
- AsicAddPairwiseKeyEntry(pAd,
- KeyInfo.MacAddr,
- (UCHAR)KeyInfo.MacTabMatchWCID,
- &KeyInfo.CipherKey);
- }
- break;
- case RT_CMD_SET_RX_WCID_TABLE: //General call for RTMPAddWcidAttributeEntry()
- {
- PMAC_TABLE_ENTRY pEntry;
- UCHAR KeyIdx;
- UCHAR CipherAlg;
- UCHAR ApIdx;
-
- pEntry = (PMAC_TABLE_ENTRY)(pData);
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- KeyIdx = 0;
- CipherAlg = pEntry->PairwiseKey.CipherAlg;
- ApIdx = BSS0;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-
- RTMPAddWcidAttributeEntry(
- pAd,
- ApIdx,
- KeyIdx,
- CipherAlg,
- pEntry);
- }
- break;
-//Benson modified for USB interface, avoid in interrupt when write key, 20080724 <--
-
- case CMDTHREAD_SET_CLIENT_MAC_ENTRY:
- {
- MAC_TABLE_ENTRY *pEntry;
- pEntry = (MAC_TABLE_ENTRY *)pData;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- AsicRemovePairwiseKeyEntry(pAd, pEntry->apidx, (UCHAR)pEntry->Aid);
- if ((pEntry->AuthMode <= Ndis802_11AuthModeAutoSwitch) && (pEntry->WepStatus == Ndis802_11Encryption1Enabled))
- {
- UINT32 uIV = 0;
- PUCHAR ptr;
-
- ptr = (PUCHAR) &uIV;
- *(ptr + 3) = (pAd->StaCfg.DefaultKeyId << 6);
- AsicUpdateWCIDIVEIV(pAd, pEntry->Aid, uIV, 0);
- AsicUpdateWCIDAttribute(pAd, pEntry->Aid, BSS0, pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, FALSE);
- }
- else if (pEntry->AuthMode == Ndis802_11AuthModeWPANone)
- {
- UINT32 uIV = 0;
- PUCHAR ptr;
-
- ptr = (PUCHAR) &uIV;
- *(ptr + 3) = (pAd->StaCfg.DefaultKeyId << 6);
- AsicUpdateWCIDIVEIV(pAd, pEntry->Aid, uIV, 0);
- AsicUpdateWCIDAttribute(pAd, pEntry->Aid, BSS0, pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, FALSE);
- }
- else
- {
- //
- // Other case, disable engine.
- // Don't worry WPA key, we will add WPA Key after 4-Way handshaking.
- //
- USHORT offset;
- offset = MAC_WCID_ATTRIBUTE_BASE + (pEntry->Aid * HW_WCID_ATTRI_SIZE);
- // RX_PKEY_MODE:0 for no security; RX_KEY_TAB:0 for shared key table; BSS_IDX:0
- RTUSBWriteMACRegister(pAd, offset, 0);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
- printk("UpdateRxWCIDTable(): Aid=%d, Addr=%02x:%02x:%02x:%02x:%02x:%02x!\n", pEntry->Aid,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2], pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
- }
- break;
-
-// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
- case CMDTHREAD_UPDATE_PROTECT:
- {
- AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
- }
- break;
-// end johnli
-
- case OID_802_11_ADD_WEP:
- {
-#ifdef CONFIG_STA_SUPPORT
- UINT i;
- UINT32 KeyIdx;
- PNDIS_802_11_WEP pWepKey;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CmdThread::OID_802_11_ADD_WEP \n"));
-
- pWepKey = (PNDIS_802_11_WEP)pData;
- KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
-
- // it is a shared key
- if ((KeyIdx >= 4) || ((pWepKey->KeyLength != 5) && (pWepKey->KeyLength != 13)))
- {
- NdisStatus = NDIS_STATUS_INVALID_DATA;
- DBGPRINT(RT_DEBUG_ERROR, ("CmdThread::OID_802_11_ADD_WEP, INVALID_DATA!!\n"));
- }
- else
- {
- UCHAR CipherAlg;
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
- CipherAlg = (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 5)? CIPHER_WEP64 : CIPHER_WEP128;
-
- //
- // Change the WEP cipher to CKIP cipher if CKIP KP on.
- // Funk UI or Meetinghouse UI will add ckip key from this path.
- //
-
- if (pAd->OpMode == OPMODE_STA)
- {
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = pAd->SharedKey[BSS0][KeyIdx].KeyLen;
- }
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
- if (pWepKey->KeyIndex & 0x80000000)
- {
- // Default key for tx (shared key)
- UCHAR IVEIV[8];
- UINT32 WCIDAttri, Value;
- USHORT offset, offset2;
- NdisZeroMemory(IVEIV, 8);
- pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- // Add BSSID to WCTable. because this is Tx wep key.
- // WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:1=PAIRWISE KEY, BSSIdx is 0
- WCIDAttri = (CipherAlg<<1)|SHAREDKEYTABLE;
-
- offset = MAC_WCID_ATTRIBUTE_BASE + (BSSID_WCID* HW_WCID_ATTRI_SIZE);
- RTUSBWriteMACRegister(pAd, offset, WCIDAttri);
- // 1. IV/EIV
- // Specify key index to find shared key.
- IVEIV[3] = (UCHAR)(KeyIdx<< 6); //WEP Eiv bit off. groupkey index is not 0
- offset = PAIRWISE_IVEIV_TABLE_BASE + (BSS0Mcast_WCID * HW_IVEIV_ENTRY_SIZE);
- offset2 = PAIRWISE_IVEIV_TABLE_BASE + (BSSID_WCID* HW_IVEIV_ENTRY_SIZE);
- for (i=0; i<8;)
- {
- Value = IVEIV[i];
- Value += (IVEIV[i+1]<<8);
- Value += (IVEIV[i+2]<<16);
- Value += (IVEIV[i+3]<<24);
- RTUSBWriteMACRegister(pAd, offset+i, Value);
- RTUSBWriteMACRegister(pAd, offset2+i, Value);
- i+=4;
- }
-
- // 2. WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:use share key, BSSIdx is 0
- WCIDAttri = (pAd->SharedKey[BSS0][KeyIdx].CipherAlg<<1)|SHAREDKEYTABLE;
- offset = MAC_WCID_ATTRIBUTE_BASE + (BSS0Mcast_WCID* HW_WCID_ATTRI_SIZE);
- DBGPRINT(RT_DEBUG_TRACE, ("BSS0Mcast_WCID : offset = %x, WCIDAttri = %x\n", offset, WCIDAttri));
- RTUSBWriteMACRegister(pAd, offset, WCIDAttri);
-
- }
- AsicAddSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx, CipherAlg, pWepKey->KeyMaterial, NULL, NULL);
- DBGPRINT(RT_DEBUG_TRACE, ("CmdThread::OID_802_11_ADD_WEP (KeyIdx=%d, Len=%d-byte)\n", KeyIdx, pWepKey->KeyLength));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- break;
-
- case CMDTHREAD_802_11_COUNTER_MEASURE:
- break;
-
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("--> Control Thread !! ERROR !! Unknown(cmdqelmt->command=0x%x) !! \n", cmdqelmt->command));
- break;
- }
- }
-
- if (cmdqelmt->CmdFromNdis == TRUE)
- {
- if (cmdqelmt->buffer != NULL)
- NdisFreeMemory(cmdqelmt->buffer, cmdqelmt->bufferlength, 0);
-
- NdisFreeMemory(cmdqelmt, sizeof(CmdQElmt), 0);
- }
- else
- {
- if ((cmdqelmt->buffer != NULL) && (cmdqelmt->bufferlength != 0))
- NdisFreeMemory(cmdqelmt->buffer, cmdqelmt->bufferlength, 0);
- {
- NdisFreeMemory(cmdqelmt, sizeof(CmdQElmt), 0);
- }
- }
- } /* end of while */
-}
-
+#include "../../rt2870/common/rtusb_io.c"
diff --git a/drivers/staging/rt3070/common/spectrum.c b/drivers/staging/rt3070/common/spectrum.c
index da57b1202d64..de3b949e52fb 100644
--- a/drivers/staging/rt3070/common/spectrum.c
+++ b/drivers/staging/rt3070/common/spectrum.c
@@ -1,1876 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- action.c
-
- Abstract:
- Handle association related requests either from WSTA or from local MLME
-
- Revision History:
- Who When What
- --------- ---------- ----------------------------------------------
- Fonchi Wu 2008 created for 802.11h
- */
-
-#include "../rt_config.h"
-#include "../action.h"
-
-VOID MeasureReqTabInit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisAllocateSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
-
- pAd->CommonCfg.pMeasureReqTab = kmalloc(sizeof(MEASURE_REQ_TAB), GFP_ATOMIC);
- if (pAd->CommonCfg.pMeasureReqTab)
- NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB));
- else
- DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __FUNCTION__));
-
- return;
-}
-
-VOID MeasureReqTabExit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisFreeSpinLock(pAd->CommonCfg.MeasureReqTabLock);
-
- if (pAd->CommonCfg.pMeasureReqTab)
- kfree(pAd->CommonCfg.pMeasureReqTab);
- pAd->CommonCfg.pMeasureReqTab = NULL;
-
- return;
-}
-
-static PMEASURE_REQ_ENTRY MeasureReqLookUp(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- UINT HashIdx;
- PMEASURE_REQ_TAB pTab = pAd->CommonCfg.pMeasureReqTab;
- PMEASURE_REQ_ENTRY pEntry = NULL;
- PMEASURE_REQ_ENTRY pPrevEntry = NULL;
-
- if (pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__));
- return NULL;
- }
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
-
- HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(DialogToken);
- pEntry = pTab->Hash[HashIdx];
-
- while (pEntry)
- {
- if (pEntry->DialogToken == DialogToken)
- break;
- else
- {
- pPrevEntry = pEntry;
- pEntry = pEntry->pNext;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-
- return pEntry;
-}
-
-static PMEASURE_REQ_ENTRY MeasureReqInsert(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- INT i;
- ULONG HashIdx;
- PMEASURE_REQ_TAB pTab = pAd->CommonCfg.pMeasureReqTab;
- PMEASURE_REQ_ENTRY pEntry = NULL, pCurrEntry;
- ULONG Now;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__));
- return NULL;
- }
-
- pEntry = MeasureReqLookUp(pAd, DialogToken);
- if (pEntry == NULL)
- {
- RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
- for (i = 0; i < MAX_MEASURE_REQ_TAB_SIZE; i++)
- {
- NdisGetSystemUpTime(&Now);
- pEntry = &pTab->Content[i];
-
- if ((pEntry->Valid == TRUE)
- && RTMP_TIME_AFTER((unsigned long)Now, (unsigned long)(pEntry->lastTime + MQ_REQ_AGE_OUT)))
- {
- PMEASURE_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PMEASURE_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(MEASURE_REQ_ENTRY));
- pTab->Size--;
-
- break;
- }
-
- if (pEntry->Valid == FALSE)
- break;
- }
-
- if (i < MAX_MEASURE_REQ_TAB_SIZE)
- {
- NdisGetSystemUpTime(&Now);
- pEntry->lastTime = Now;
- pEntry->Valid = TRUE;
- pEntry->DialogToken = DialogToken;
- pTab->Size++;
- }
- else
- {
- pEntry = NULL;
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __FUNCTION__));
- }
-
- // add this Neighbor entry into HASH table
- if (pEntry)
- {
- HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(DialogToken);
- if (pTab->Hash[HashIdx] == NULL)
- {
- pTab->Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pTab->Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
- }
-
- return pEntry;
-}
-
-static VOID MeasureReqDelete(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- PMEASURE_REQ_TAB pTab = pAd->CommonCfg.pMeasureReqTab;
- PMEASURE_REQ_ENTRY pEntry = NULL;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__));
- return;
- }
-
- // if empty, return
- if (pTab->Size == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pMeasureReqTab empty.\n"));
- return;
- }
-
- pEntry = MeasureReqLookUp(pAd, DialogToken);
- if (pEntry != NULL)
- {
- PMEASURE_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PMEASURE_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(MEASURE_REQ_ENTRY));
- pTab->Size--;
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
- }
-
- return;
-}
-
-VOID TpcReqTabInit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisAllocateSpinLock(&pAd->CommonCfg.TpcReqTabLock);
-
- pAd->CommonCfg.pTpcReqTab = kmalloc(sizeof(TPC_REQ_TAB), GFP_ATOMIC);
- if (pAd->CommonCfg.pTpcReqTab)
- NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB));
- else
- DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __FUNCTION__));
-
- return;
-}
-
-VOID TpcReqTabExit(
- IN PRTMP_ADAPTER pAd)
-{
- NdisFreeSpinLock(pAd->CommonCfg.TpcReqTabLock);
-
- if (pAd->CommonCfg.pTpcReqTab)
- kfree(pAd->CommonCfg.pTpcReqTab);
- pAd->CommonCfg.pTpcReqTab = NULL;
-
- return;
-}
-
-static PTPC_REQ_ENTRY TpcReqLookUp(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- UINT HashIdx;
- PTPC_REQ_TAB pTab = pAd->CommonCfg.pTpcReqTab;
- PTPC_REQ_ENTRY pEntry = NULL;
- PTPC_REQ_ENTRY pPrevEntry = NULL;
-
- if (pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__));
- return NULL;
- }
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
-
- HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(DialogToken);
- pEntry = pTab->Hash[HashIdx];
-
- while (pEntry)
- {
- if (pEntry->DialogToken == DialogToken)
- break;
- else
- {
- pPrevEntry = pEntry;
- pEntry = pEntry->pNext;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-
- return pEntry;
-}
-
-
-static PTPC_REQ_ENTRY TpcReqInsert(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- INT i;
- ULONG HashIdx;
- PTPC_REQ_TAB pTab = pAd->CommonCfg.pTpcReqTab;
- PTPC_REQ_ENTRY pEntry = NULL, pCurrEntry;
- ULONG Now;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__));
- return NULL;
- }
-
- pEntry = TpcReqLookUp(pAd, DialogToken);
- if (pEntry == NULL)
- {
- RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
- for (i = 0; i < MAX_TPC_REQ_TAB_SIZE; i++)
- {
- NdisGetSystemUpTime(&Now);
- pEntry = &pTab->Content[i];
-
- if ((pEntry->Valid == TRUE)
- && RTMP_TIME_AFTER((unsigned long)Now, (unsigned long)(pEntry->lastTime + TPC_REQ_AGE_OUT)))
- {
- PTPC_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PTPC_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(TPC_REQ_ENTRY));
- pTab->Size--;
-
- break;
- }
-
- if (pEntry->Valid == FALSE)
- break;
- }
-
- if (i < MAX_TPC_REQ_TAB_SIZE)
- {
- NdisGetSystemUpTime(&Now);
- pEntry->lastTime = Now;
- pEntry->Valid = TRUE;
- pEntry->DialogToken = DialogToken;
- pTab->Size++;
- }
- else
- {
- pEntry = NULL;
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __FUNCTION__));
- }
-
- // add this Neighbor entry into HASH table
- if (pEntry)
- {
- HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(DialogToken);
- if (pTab->Hash[HashIdx] == NULL)
- {
- pTab->Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pTab->Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
- }
-
- return pEntry;
-}
-
-static VOID TpcReqDelete(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 DialogToken)
-{
- PTPC_REQ_TAB pTab = pAd->CommonCfg.pTpcReqTab;
- PTPC_REQ_ENTRY pEntry = NULL;
-
- if(pTab == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__));
- return;
- }
-
- // if empty, return
- if (pTab->Size == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pTpcReqTab empty.\n"));
- return;
- }
-
- pEntry = TpcReqLookUp(pAd, DialogToken);
- if (pEntry != NULL)
- {
- PTPC_REQ_ENTRY pPrevEntry = NULL;
- ULONG HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
- PTPC_REQ_ENTRY pProbeEntry = pTab->Hash[HashIdx];
-
- RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
- // update Hash list
- do
- {
- if (pProbeEntry == pEntry)
- {
- if (pPrevEntry == NULL)
- {
- pTab->Hash[HashIdx] = pEntry->pNext;
- }
- else
- {
- pPrevEntry->pNext = pEntry->pNext;
- }
- break;
- }
-
- pPrevEntry = pProbeEntry;
- pProbeEntry = pProbeEntry->pNext;
- } while (pProbeEntry);
-
- NdisZeroMemory(pEntry, sizeof(TPC_REQ_ENTRY));
- pTab->Size--;
-
- RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Get Current TimeS tamp.
-
- Parametrs:
-
- Return : Current Time Stamp.
- ==========================================================================
- */
-static UINT64 GetCurrentTimeStamp(
- IN PRTMP_ADAPTER pAd)
-{
- // get current time stamp.
- return 0;
-}
-
-/*
- ==========================================================================
- Description:
- Get Current Transmit Power.
-
- Parametrs:
-
- Return : Current Time Stamp.
- ==========================================================================
- */
-static UINT8 GetCurTxPwr(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 Wcid)
-{
- return 16; /* 16 dBm */
-}
-
-/*
- ==========================================================================
- Description:
- Insert Dialog Token into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Dialog token.
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertDialogToken(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 DialogToken)
-{
- ULONG TempLen;
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &DialogToken,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert TPC Request IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
-
- Return : None.
- ==========================================================================
- */
- static VOID InsertTpcReqIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen)
-{
- ULONG TempLen;
- ULONG Len = 0;
- UINT8 ElementID = IE_TPC_REQUEST;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert TPC Report IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Transmit Power.
- 4. Link Margin.
-
- Return : None.
- ==========================================================================
- */
- static VOID InsertTpcReportIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 TxPwr,
- IN UINT8 LinkMargin)
-{
- ULONG TempLen;
- ULONG Len = sizeof(TPC_REPORT_INFO);
- UINT8 ElementID = IE_TPC_REPORT;
- TPC_REPORT_INFO TpcReportIE;
-
- TpcReportIE.TxPwr = TxPwr;
- TpcReportIE.LinkMargin = LinkMargin;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, &TpcReportIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert Channel Switch Announcement IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. channel switch announcement mode.
- 4. new selected channel.
- 5. channel switch announcement count.
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertChSwAnnIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 ChSwMode,
- IN UINT8 NewChannel,
- IN UINT8 ChSwCnt)
-{
- ULONG TempLen;
- ULONG Len = sizeof(CH_SW_ANN_INFO);
- UINT8 ElementID = IE_CHANNEL_SWITCH_ANNOUNCEMENT;
- CH_SW_ANN_INFO ChSwAnnIE;
-
- ChSwAnnIE.ChSwMode = ChSwMode;
- ChSwAnnIE.Channel = NewChannel;
- ChSwAnnIE.ChSwCnt = ChSwCnt;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, &ChSwAnnIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert Measure Request IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Measure Token.
- 4. Measure Request Mode.
- 5. Measure Request Type.
- 6. Measure Channel.
- 7. Measure Start time.
- 8. Measure Duration.
-
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertMeasureReqIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN PMEASURE_REQ_INFO pMeasureReqIE)
-{
- ULONG TempLen;
- UINT8 Len = sizeof(MEASURE_REQ_INFO);
- UINT8 ElementID = IE_MEASUREMENT_REQUEST;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, pMeasureReqIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Insert Measure Report IE into frame.
-
- Parametrs:
- 1. frame buffer pointer.
- 2. frame length.
- 3. Measure Token.
- 4. Measure Request Mode.
- 5. Measure Request Type.
- 6. Length of Report Infomation
- 7. Pointer of Report Infomation Buffer.
-
- Return : None.
- ==========================================================================
- */
-static VOID InsertMeasureReportIE(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN PMEASURE_REPORT_INFO pMeasureReportIE,
- IN UINT8 ReportLnfoLen,
- IN PUINT8 pReportInfo)
-{
- ULONG TempLen;
- ULONG Len;
- UINT8 ElementID = IE_MEASUREMENT_REPORT;
-
- Len = sizeof(MEASURE_REPORT_INFO) + ReportLnfoLen;
-
- MakeOutgoingFrame(pFrameBuf, &TempLen,
- 1, &ElementID,
- 1, &Len,
- Len, pMeasureReportIE,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
-
- if ((ReportLnfoLen > 0) && (pReportInfo != NULL))
- {
- MakeOutgoingFrame(pFrameBuf + *pFrameLen, &TempLen,
- ReportLnfoLen, pReportInfo,
- END_OF_ARGS);
-
- *pFrameLen = *pFrameLen + TempLen;
- }
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 MeasureCh,
- IN UINT16 MeasureDuration)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- HEADER_802_11 ActHdr;
- MEASURE_REQ_INFO MeasureReqIE;
- UINT8 RmReqDailogToken = RandomByte(pAd);
- UINT64 MeasureStartTime = GetCurrentTimeStamp(pAd);
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_MRQ);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, MeasureToken);
-
- // prepare Measurement IE.
- NdisZeroMemory(&MeasureReqIE, sizeof(MEASURE_REQ_INFO));
- MeasureReqIE.Token = RmReqDailogToken;
- MeasureReqIE.ReqMode.word = MeasureReqMode;
- MeasureReqIE.ReqType = MeasureReqType;
- MeasureReqIE.MeasureReq.ChNum = MeasureCh;
- MeasureReqIE.MeasureReq.MeasureStartTime = cpu2le64(MeasureStartTime);
- MeasureReqIE.MeasureReq.MeasureDuration = cpu2le16(MeasureDuration);
- InsertMeasureReqIE(pAd, (pOutBuffer + FrameLen), &FrameLen, &MeasureReqIE);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 ReportInfoLen,
- IN PUINT8 pReportInfo)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- HEADER_802_11 ActHdr;
- MEASURE_REPORT_INFO MeasureRepIE;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_MRP);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
- // prepare Measurement IE.
- NdisZeroMemory(&MeasureRepIE, sizeof(MEASURE_REPORT_INFO));
- MeasureRepIE.Token = MeasureToken;
- MeasureRepIE.ReportMode.word = MeasureReqMode;
- MeasureRepIE.ReportType = MeasureReqType;
- InsertMeasureReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen, &MeasureRepIE, ReportInfoLen, pReportInfo);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UCHAR DialogToken)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
-
- HEADER_802_11 ActHdr;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_TPCRQ);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
- // Insert TPC Request IE.
- InsertTpcReqIE(pAd, (pOutBuffer + FrameLen), &FrameLen);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 TxPwr,
- IN UINT8 LinkMargin)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
-
- HEADER_802_11 ActHdr;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_TPCRP);
-
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
- // Insert TPC Request IE.
- InsertTpcReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen, TxPwr, LinkMargin);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Prepare Channel Switch Announcement action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
- 2. Channel switch announcement mode.
- 2. a New selected channel.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueChSwAnn(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 ChSwMode,
- IN UINT8 NewCh)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
-
- HEADER_802_11 ActHdr;
-
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
-
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
-
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_CHANNEL_SWITCH);
-
- InsertChSwAnnIE(pAd, (pOutBuffer + FrameLen), &FrameLen, ChSwMode, NewCh, 0);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- return;
-}
-
-static BOOLEAN DfsRequirementCheck(
- IN PRTMP_ADAPTER pAd,
- IN UINT8 Channel)
-{
- BOOLEAN Result = FALSE;
- INT i;
-
- do
- {
- // check DFS procedure is running.
- // make sure DFS procedure won't start twice.
- if (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
- {
- Result = FALSE;
- break;
- }
-
- // check the new channel carried from Channel Switch Announcemnet is valid.
- for (i=0; i<pAd->ChannelListNum; i++)
- {
- if ((Channel == pAd->ChannelList[i].Channel)
- &&(pAd->ChannelList[i].RemainingTimeForUse == 0))
- {
- // found radar signal in the channel. the channel can't use at least for 30 minutes.
- pAd->ChannelList[i].RemainingTimeForUse = 1800;//30 min = 1800 sec
- Result = TRUE;
- break;
- }
- }
- } while(FALSE);
-
- return Result;
-}
-
-VOID NotifyChSwAnnToPeerAPs(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pRA,
- IN PUCHAR pTA,
- IN UINT8 ChSwMode,
- IN UINT8 Channel)
-{
-#ifdef WDS_SUPPORT
- if (!((pRA[0] & 0xff) == 0xff)) // is pRA a broadcase address.
- {
- INT i;
- // info neighbor APs that Radar signal found throgh WDS link.
- for (i = 0; i < MAX_WDS_ENTRY; i++)
- {
- if (ValidWdsEntry(pAd, i))
- {
- PUCHAR pDA = pAd->WdsTab.WdsEntry[i].PeerWdsAddr;
-
- // DA equal to SA. have no necessary orignal AP which found Radar signal.
- if (MAC_ADDR_EQUAL(pTA, pDA))
- continue;
-
- // send Channel Switch Action frame to info Neighbro APs.
- EnqueueChSwAnn(pAd, pDA, ChSwMode, Channel);
- }
- }
- }
-#endif // WDS_SUPPORT //
-}
-
-static VOID StartDFSProcedure(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel,
- IN UINT8 ChSwMode)
-{
- // start DFS procedure
- pAd->CommonCfg.Channel = Channel;
-#ifdef DOT11_N_SUPPORT
- N_ChannelCheck(pAd);
-#endif // DOT11_N_SUPPORT //
- pAd->CommonCfg.RadarDetect.RDMode = RD_SWITCHING_MODE;
- pAd->CommonCfg.RadarDetect.CSCount = 0;
-}
-
-/*
- ==========================================================================
- Description:
- Channel Switch Announcement action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Channel switch announcement infomation buffer.
-
-
- Return : None.
- ==========================================================================
- */
-
-/*
- Channel Switch Announcement IE.
- +----+-----+-----------+------------+-----------+
- | ID | Len |Ch Sw Mode | New Ch Num | Ch Sw Cnt |
- +----+-----+-----------+------------+-----------+
- 1 1 1 1 1
-*/
-static BOOLEAN PeerChSwAnnSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PCH_SW_ANN_INFO pChSwAnnInfo)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
-
- // skip 802.11 header.
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pChSwAnnInfo == NULL)
- return result;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
- NdisMoveMemory(&pChSwAnnInfo->ChSwMode, eid_ptr->Octet, 1);
- NdisMoveMemory(&pChSwAnnInfo->Channel, eid_ptr->Octet + 1, 1);
- NdisMoveMemory(&pChSwAnnInfo->ChSwCnt, eid_ptr->Octet + 2, 1);
-
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- Measurement request action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Measurement request infomation buffer.
-
- Return : None.
- ==========================================================================
- */
-static BOOLEAN PeerMeasureReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken,
- OUT PMEASURE_REQ_INFO pMeasureReqInfo)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
- PUCHAR ptr;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
-
- // skip 802.11 header.
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pMeasureReqInfo == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_MEASUREMENT_REQUEST:
- NdisMoveMemory(&pMeasureReqInfo->Token, eid_ptr->Octet, 1);
- NdisMoveMemory(&pMeasureReqInfo->ReqMode.word, eid_ptr->Octet + 1, 1);
- NdisMoveMemory(&pMeasureReqInfo->ReqType, eid_ptr->Octet + 2, 1);
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pMeasureReqInfo->MeasureReq.ChNum, ptr, 1);
- NdisMoveMemory(&MeasureStartTime, ptr + 1, 8);
- pMeasureReqInfo->MeasureReq.MeasureStartTime = SWAP64(MeasureStartTime);
- NdisMoveMemory(&MeasureDuration, ptr + 9, 2);
- pMeasureReqInfo->MeasureReq.MeasureDuration = SWAP16(MeasureDuration);
-
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- Measurement report action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Measurement report infomation buffer.
- 4. basic report infomation buffer.
-
- Return : None.
- ==========================================================================
- */
-
-/*
- Measurement Report IE.
- +----+-----+-------+-------------+--------------+----------------+
- | ID | Len | Token | Report Mode | Measure Type | Measure Report |
- +----+-----+-------+-------------+--------------+----------------+
- 1 1 1 1 1 variable
-
- Basic Report.
- +--------+------------+----------+-----+
- | Ch Num | Start Time | Duration | Map |
- +--------+------------+----------+-----+
- 1 8 2 1
-
- Map Field Bit Format.
- +-----+---------------+---------------------+-------+------------+----------+
- | Bss | OFDM Preamble | Unidentified signal | Radar | Unmeasured | Reserved |
- +-----+---------------+---------------------+-------+------------+----------+
- 0 1 2 3 4 5-7
-*/
-static BOOLEAN PeerMeasureReportSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken,
- OUT PMEASURE_REPORT_INFO pMeasureReportInfo,
- OUT PUINT8 pReportBuf)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
- PUCHAR ptr;
-
- // skip 802.11 header.
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pMeasureReportInfo == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_MEASUREMENT_REPORT:
- NdisMoveMemory(&pMeasureReportInfo->Token, eid_ptr->Octet, 1);
- NdisMoveMemory(&pMeasureReportInfo->ReportMode, eid_ptr->Octet + 1, 1);
- NdisMoveMemory(&pMeasureReportInfo->ReportType, eid_ptr->Octet + 2, 1);
- if (pMeasureReportInfo->ReportType == RM_BASIC)
- {
- PMEASURE_BASIC_REPORT pReport = (PMEASURE_BASIC_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pReport->ChNum, ptr, 1);
- NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
- NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
- NdisMoveMemory(&pReport->Map, ptr + 11, 1);
-
- }
- else if (pMeasureReportInfo->ReportType == RM_CCA)
- {
- PMEASURE_CCA_REPORT pReport = (PMEASURE_CCA_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pReport->ChNum, ptr, 1);
- NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
- NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
- NdisMoveMemory(&pReport->CCA_Busy_Fraction, ptr + 11, 1);
-
- }
- else if (pMeasureReportInfo->ReportType == RM_RPI_HISTOGRAM)
- {
- PMEASURE_RPI_REPORT pReport = (PMEASURE_RPI_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pReport->ChNum, ptr, 1);
- NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
- NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
- NdisMoveMemory(&pReport->RPI_Density, ptr + 11, 8);
- }
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Request action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Dialog Token.
-
- Return : None.
- ==========================================================================
- */
-static BOOLEAN PeerTpcReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
-
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pDialogToken == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_TPC_REQUEST:
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Report action frame sanity check.
-
- Parametrs:
- 1. MLME message containing the received frame
- 2. message length.
- 3. Dialog Token.
- 4. TPC Report IE.
-
- Return : None.
- ==========================================================================
- */
-static BOOLEAN PeerTpcRepSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUINT8 pDialogToken,
- OUT PTPC_REPORT_INFO pTpcRepInfo)
-{
- PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
- PUCHAR pFramePtr = Fr->Octet;
- BOOLEAN result = FALSE;
- PEID_STRUCT eid_ptr;
-
- MsgLen -= sizeof(HEADER_802_11);
-
- // skip category and action code.
- pFramePtr += 2;
- MsgLen -= 2;
-
- if (pDialogToken == NULL)
- return result;
-
- NdisMoveMemory(pDialogToken, pFramePtr, 1);
- pFramePtr += 1;
- MsgLen -= 1;
-
- eid_ptr = (PEID_STRUCT)pFramePtr;
- while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((PUCHAR)pFramePtr + MsgLen))
- {
- switch(eid_ptr->Eid)
- {
- case IE_TPC_REPORT:
- NdisMoveMemory(&pTpcRepInfo->TxPwr, eid_ptr->Octet, 1);
- NdisMoveMemory(&pTpcRepInfo->LinkMargin, eid_ptr->Octet + 1, 1);
- result = TRUE;
- break;
-
- default:
- break;
- }
- eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
- }
-
- return result;
-}
-
-/*
- ==========================================================================
- Description:
- Channel Switch Announcement action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerChSwAnnAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- CH_SW_ANN_INFO ChSwAnnInfo;
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR index = 0, Channel = 0, NewChannel = 0;
- ULONG Bssidx = 0;
-#endif // CONFIG_STA_SUPPORT //
-
- NdisZeroMemory(&ChSwAnnInfo, sizeof(CH_SW_ANN_INFO));
- if (! PeerChSwAnnSanity(pAd, Elem->Msg, Elem->MsgLen, &ChSwAnnInfo))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Invalid Channel Switch Action Frame.\n"));
- return;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->OpMode == OPMODE_STA)
- {
- Bssidx = BssTableSearch(&pAd->ScanTab, pFr->Hdr.Addr3, pAd->CommonCfg.Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerChSwAnnAction - Bssidx is not found\n"));
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("\n****Bssidx is %d, Channel = %d\n", index, pAd->ScanTab.BssEntry[Bssidx].Channel));
- hex_dump("SSID",pAd->ScanTab.BssEntry[Bssidx].Bssid ,6);
-
- Channel = pAd->CommonCfg.Channel;
- NewChannel = ChSwAnnInfo.Channel;
-
- if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
- {
- // Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection).
- // In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results.
- AsicSwitchChannel(pAd, 1, FALSE);
- AsicLockChannel(pAd, 1);
- LinkDown(pAd, FALSE);
- MlmeQueueInit(&pAd->Mlme.Queue);
- BssTableInit(&pAd->ScanTab);
- RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
-
- // channel sanity check
- for (index = 0 ; index < pAd->ChannelListNum; index++)
- {
- if (pAd->ChannelList[index].Channel == NewChannel)
- {
- pAd->ScanTab.BssEntry[Bssidx].Channel = NewChannel;
- pAd->CommonCfg.Channel = NewChannel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("&&&&&&&&&&&&&&&&PeerChSwAnnAction - STA receive channel switch announcement IE (New Channel =%d)\n", NewChannel));
- break;
- }
- }
-
- if (index >= pAd->ChannelListNum)
- {
- DBGPRINT_ERR(("&&&&&&&&&&&&&&&&&&&&&&&&&&PeerChSwAnnAction(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return;
-}
-
-
-/*
- ==========================================================================
- Description:
- Measurement Request action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerMeasureReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
- UINT8 DialogToken;
- MEASURE_REQ_INFO MeasureReqInfo;
- MEASURE_REPORT_MODE ReportMode;
-
- if(PeerMeasureReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReqInfo))
- {
- ReportMode.word = 0;
- ReportMode.field.Incapable = 1;
- EnqueueMeasurementRep(pAd, pFr->Hdr.Addr2, DialogToken, MeasureReqInfo.Token, ReportMode.word, MeasureReqInfo.ReqType, 0, NULL);
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Measurement Report action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerMeasureReportAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MEASURE_REPORT_INFO MeasureReportInfo;
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
- UINT8 DialogToken;
- PUINT8 pMeasureReportInfo;
-
-// if (pAd->CommonCfg.bIEEE80211H != TRUE)
-// return;
-
- if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __FUNCTION__, sizeof(MEASURE_RPI_REPORT)));
- return;
- }
-
- NdisZeroMemory(&MeasureReportInfo, sizeof(MEASURE_REPORT_INFO));
- NdisZeroMemory(pMeasureReportInfo, sizeof(MEASURE_RPI_REPORT));
- if (PeerMeasureReportSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReportInfo, pMeasureReportInfo))
- {
- do {
- PMEASURE_REQ_ENTRY pEntry = NULL;
-
- // Not a autonomous measure report.
- // check the dialog token field. drop it if the dialog token doesn't match.
- if ((DialogToken != 0)
- && ((pEntry = MeasureReqLookUp(pAd, DialogToken)) == NULL))
- break;
-
- if (pEntry != NULL)
- MeasureReqDelete(pAd, pEntry->DialogToken);
-
- if (MeasureReportInfo.ReportType == RM_BASIC)
- {
- PMEASURE_BASIC_REPORT pBasicReport = (PMEASURE_BASIC_REPORT)pMeasureReportInfo;
- if ((pBasicReport->Map.field.Radar)
- && (DfsRequirementCheck(pAd, pBasicReport->ChNum) == TRUE))
- {
- NotifyChSwAnnToPeerAPs(pAd, pFr->Hdr.Addr1, pFr->Hdr.Addr2, 1, pBasicReport->ChNum);
- StartDFSProcedure(pAd, pBasicReport->ChNum, 1);
- }
- }
- } while (FALSE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Invalid Measurement Report Frame.\n"));
-
- kfree(pMeasureReportInfo);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Request action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerTpcReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
- PUCHAR pFramePtr = pFr->Octet;
- UINT8 DialogToken;
- UINT8 TxPwr = GetCurTxPwr(pAd, Elem->Wcid);
- UINT8 LinkMargin = 0;
- CHAR RealRssi;
-
- // link margin: Ratio of the received signal power to the minimum desired by the station (STA). The
- // STA may incorporate rate information and channel conditions, including interference, into its computation
- // of link margin.
-
- RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
- ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
- ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
- // skip Category and action code.
- pFramePtr += 2;
-
- // Dialog token.
- NdisMoveMemory(&DialogToken, pFramePtr, 1);
-
- LinkMargin = (RealRssi / MIN_RCV_PWR);
- if (PeerTpcReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken))
- EnqueueTPCRep(pAd, pFr->Hdr.Addr2, DialogToken, TxPwr, LinkMargin);
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- TPC Report action frame handler.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-static VOID PeerTpcRepAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UINT8 DialogToken;
- TPC_REPORT_INFO TpcRepInfo;
- PTPC_REQ_ENTRY pEntry = NULL;
-
- NdisZeroMemory(&TpcRepInfo, sizeof(TPC_REPORT_INFO));
- if (PeerTpcRepSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &TpcRepInfo))
- {
- if ((pEntry = TpcReqLookUp(pAd, DialogToken)) != NULL)
- {
- TpcReqDelete(pAd, pEntry->DialogToken);
- DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n",
- __FUNCTION__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin));
- }
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
- Spectrun action frames Handler such as channel switch annoucement,
- measurement report, measurement request actions frames.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-VOID PeerSpectrumAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
-
- UCHAR Action = Elem->Msg[LENGTH_802_11+1];
-
- if (pAd->CommonCfg.bIEEE80211H != TRUE)
- return;
-
- switch(Action)
- {
- case SPEC_MRQ:
- // current rt2860 unable do such measure specified in Measurement Request.
- // reject all measurement request.
- PeerMeasureReqAction(pAd, Elem);
- break;
-
- case SPEC_MRP:
- PeerMeasureReportAction(pAd, Elem);
- break;
-
- case SPEC_TPCRQ:
- PeerTpcReqAction(pAd, Elem);
- break;
-
- case SPEC_TPCRP:
- PeerTpcRepAction(pAd, Elem);
- break;
-
- case SPEC_CHANNEL_SWITCH:
-{
-#ifdef DOT11N_DRAFT3
- SEC_CHA_OFFSET_IE Secondary;
- CHA_SWITCH_ANNOUNCE_IE ChannelSwitch;
-
- // 802.11h only has Channel Switch Announcement IE.
- RTMPMoveMemory(&ChannelSwitch, &Elem->Msg[LENGTH_802_11+4], sizeof (CHA_SWITCH_ANNOUNCE_IE));
-
- // 802.11n D3.03 adds secondary channel offset element in the end.
- if (Elem->MsgLen == (LENGTH_802_11 + 2 + sizeof (CHA_SWITCH_ANNOUNCE_IE) + sizeof (SEC_CHA_OFFSET_IE)))
- {
- RTMPMoveMemory(&Secondary, &Elem->Msg[LENGTH_802_11+9], sizeof (SEC_CHA_OFFSET_IE));
- }
- else
- {
- Secondary.SecondaryChannelOffset = 0;
- }
-
- if ((Elem->Msg[LENGTH_802_11+2] == IE_CHANNEL_SWITCH_ANNOUNCEMENT) && (Elem->Msg[LENGTH_802_11+3] == 3))
- {
- ChannelSwitchAction(pAd, Elem->Wcid, ChannelSwitch.NewChannel, Secondary.SecondaryChannelOffset);
- }
-#endif // DOT11N_DRAFT3 //
-}
- PeerChSwAnnAction(pAd, Elem);
- break;
- }
-
- return;
-}
-
-/*
- ==========================================================================
- Description:
-
- Parametrs:
-
- Return : None.
- ==========================================================================
- */
-INT Set_MeasureReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT Aid = 1;
- UINT ArgIdx;
- PUCHAR thisChar;
-
- MEASURE_REQ_MODE MeasureReqMode;
- UINT8 MeasureReqToken = RandomByte(pAd);
- UINT8 MeasureReqType = RM_BASIC;
- UINT8 MeasureCh = 1;
-
- ArgIdx = 1;
- while ((thisChar = strsep((char **)&arg, "-")) != NULL)
- {
- switch(ArgIdx)
- {
- case 1: // Aid.
- Aid = simple_strtol(thisChar, 0, 16);
- break;
-
- case 2: // Measurement Request Type.
- MeasureReqType = simple_strtol(thisChar, 0, 16);
- if (MeasureReqType > 3)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __FUNCTION__, MeasureReqType));
- return TRUE;
- }
- break;
-
- case 3: // Measurement channel.
- MeasureCh = simple_strtol(thisChar, 0, 16);
- break;
- }
- ArgIdx++;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __FUNCTION__, Aid, MeasureReqType, MeasureCh));
- if (!VALID_WCID(Aid))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid));
- return TRUE;
- }
-
- MeasureReqMode.word = 0;
- MeasureReqMode.field.Enable = 1;
-
- MeasureReqInsert(pAd, MeasureReqToken);
-
- EnqueueMeasurementReq(pAd, pAd->MacTab.Content[Aid].Addr,
- MeasureReqToken, MeasureReqMode.word, MeasureReqType, MeasureCh, 2000);
-
- return TRUE;
-}
-
-INT Set_TpcReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT Aid;
-
- UINT8 TpcReqToken = RandomByte(pAd);
-
- Aid = simple_strtol(arg, 0, 16);
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __FUNCTION__, Aid));
- if (!VALID_WCID(Aid))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid));
- return TRUE;
- }
-
- TpcReqInsert(pAd, TpcReqToken);
-
- EnqueueTPCReq(pAd, pAd->MacTab.Content[Aid].Addr, TpcReqToken);
-
- return TRUE;
-}
-
+#include "../../rt2870/common/spectrum.c"
diff --git a/drivers/staging/rt3070/dfs.h b/drivers/staging/rt3070/dfs.h
index 752a6352d9dd..b9c92e354f20 100644
--- a/drivers/staging/rt3070/dfs.h
+++ b/drivers/staging/rt3070/dfs.h
@@ -1,100 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- dfs.h
-
- Abstract:
- Support DFS function.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Fonchi 03-12-2007 created
-*/
-
-#define RADAR_PULSE 1
-#define RADAR_WIDTH 2
-
-#define WIDTH_RD_IDLE 0
-#define WIDTH_RD_CHECK 1
-
-
-VOID BbpRadarDetectionStart(
- IN PRTMP_ADAPTER pAd);
-
-VOID BbpRadarDetectionStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RadarDetectionStart(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN CTS_Protect,
- IN UINT8 CTSPeriod);
-
-VOID RadarDetectionStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RadarDetectPeriodic(
- IN PRTMP_ADAPTER pAd);
-
-
-BOOLEAN RadarChannelCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Ch);
-
-ULONG JapRadarType(
- IN PRTMP_ADAPTER pAd);
-
-ULONG RTMPBbpReadRadarDuration(
- IN PRTMP_ADAPTER pAd);
-
-ULONG RTMPReadRadarDuration(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPCleanRadarDuration(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPPrepareRDCTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN ULONG Duration,
- IN UCHAR RTSRate,
- IN ULONG CTSBaseAddr,
- IN UCHAR FrameGap);
-
-VOID RTMPPrepareRadarDetectParams(
- IN PRTMP_ADAPTER pAd);
-
-
-INT Set_ChMovingTime_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_LongPulseRadarTh_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
+#include "../rt2870/dfs.h"
diff --git a/drivers/staging/rt3070/leap.h b/drivers/staging/rt3070/leap.h
deleted file mode 100644
index 6818c1ff4d73..000000000000
--- a/drivers/staging/rt3070/leap.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- leap.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef __LEAP_H__
-#define __LEAP_H__
-
-// Messages for Associate state machine
-#define LEAP_MACHINE_BASE 30
-
-#define LEAP_MSG_REQUEST_IDENTITY 31
-#define LEAP_MSG_REQUEST_LEAP 32
-#define LEAP_MSG_SUCCESS 33
-#define LEAP_MSG_FAILED 34
-#define LEAP_MSG_RESPONSE_LEAP 35
-#define LEAP_MSG_EAPOLKEY 36
-#define LEAP_MSG_UNKNOWN 37
-#define LEAP_MSG 38
-//! assoc state-machine states
-#define LEAP_IDLE 0
-#define LEAP_WAIT_IDENTITY_REQUEST 1
-#define LEAP_WAIT_CHANLLENGE_REQUEST 2
-#define LEAP_WAIT_SUCCESS 3
-#define LEAP_WAIT_CHANLLENGE_RESPONSE 4
-#define LEAP_WAIT_EAPOLKEY 5
-
-#define LEAP_REASON_INVALID_AUTH 0x01
-#define LEAP_REASON_AUTH_TIMEOUT 0x02
-#define LEAP_REASON_CHALLENGE_FROM_AP_FAILED 0x03
-#define LEAP_REASON_CHALLENGE_TO_AP_FAILED 0x04
-
-#define CISCO_AuthModeLEAP 0x80
-#define CISCO_AuthModeLEAPNone 0x00
-#define LEAP_AUTH_TIMEOUT 30000
-#define LEAP_CHALLENGE_RESPONSE_LENGTH 24
-#define LEAP_CHALLENGE_REQUEST_LENGTH 8
-
-typedef struct _LEAP_EAPOL_HEADER_ {
- UCHAR Version;
- UCHAR Type;
- UCHAR Length[2];
-} LEAP_EAPOL_HEADER, *PLEAP_EAPOL_HEADER;
-
-typedef struct _LEAP_EAPOL_PACKET_ {
- UCHAR Code;
- UCHAR Identifier;
- UCHAR Length[2];
- UCHAR Type;
-} LEAP_EAPOL_PACKET, *PLEAP_EAPOL_PACKET;
-
-typedef struct _LEAP_EAP_CONTENTS_ {
- UCHAR Version;
- UCHAR Reserved;
- UCHAR Length;
-} LEAP_EAP_CONTENTS, *PLEAP_EAP_CONTENTS;
-
-/*** EAPOL key ***/
-typedef struct _EAPOL_KEY_HEADER_ {
- UCHAR Type;
- UCHAR Length[2];
- UCHAR Counter[8];
- UCHAR IV[16];
- UCHAR Index;
- UCHAR Signature[16];
-} EAPOL_KEY_HEADER, *PEAPOL_KEY_HEADER;
-
-BOOLEAN LeapMsgTypeSubst(
- IN UCHAR EAPType,
- OUT ULONG *MsgType);
-
-VOID LeapMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr3);
-
-VOID LeapStartAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapIdentityAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapPeerChallengeAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HashPwd(
- IN PUCHAR pwd,
- IN INT pwdlen,
- OUT PUCHAR hash);
-
-VOID PeerChallengeResponse(
- IN PUCHAR szChallenge,
- IN PUCHAR smbPasswd,
- OUT PUCHAR szResponse);
-
-VOID ParityKey(
- OUT PUCHAR szOut,
- IN PUCHAR szIn);
-
-VOID DesKey(
- OUT ULONG k[16][2],
- IN PUCHAR key,
- IN INT decrypt);
-
-VOID Des(
- IN ULONG ks[16][2],
- OUT UCHAR block[8]);
-
-VOID DesEncrypt(
- IN PUCHAR szClear,
- IN PUCHAR szKey,
- OUT PUCHAR szOut);
-
-VOID LeapNetworkChallengeAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID LeapNetworkChallengeResponse(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HashpwdHash(
- IN PUCHAR hash,
- IN PUCHAR hashhash);
-
-VOID ProcessSessionKey(
- OUT PUCHAR SessionKey,
- IN PUCHAR hash2,
- IN PUCHAR ChallengeToRadius,
- IN PUCHAR ChallengeResponseFromRadius,
- IN PUCHAR ChallengeFromRadius,
- IN PUCHAR ChallengeResponseToRadius);
-
-VOID LeapEapolKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID RogueApTableInit(
- IN ROGUEAP_TABLE *Tab);
-
-ULONG RogueApTableSearch(
- IN ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr);
-
-VOID RogueApEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT ROGUEAP_ENTRY *pRogueAp,
- IN PUCHAR pAddr,
- IN UCHAR FaileCode);
-
-ULONG RogueApTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr,
- IN UCHAR FaileCode);
-
-VOID RogueApTableDeleteEntry(
- IN OUT ROGUEAP_TABLE *Tab,
- IN PUCHAR pAddr);
-
-VOID LeapAuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LeapSendRogueAPReport(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN CCKMAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen);
-
-#endif // __LEAP_H__
diff --git a/drivers/staging/rt3070/link_list.h b/drivers/staging/rt3070/link_list.h
index f6521133fd5e..5550b2f45164 100644
--- a/drivers/staging/rt3070/link_list.h
+++ b/drivers/staging/rt3070/link_list.h
@@ -1,134 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __LINK_LIST_H__
-#define __LINK_LIST_H__
-
-typedef struct _LIST_ENTRY
-{
- struct _LIST_ENTRY *pNext;
-} LIST_ENTRY, *PLIST_ENTRY;
-
-typedef struct _LIST_HEADR
-{
- PLIST_ENTRY pHead;
- PLIST_ENTRY pTail;
- UCHAR size;
-} LIST_HEADER, *PLIST_HEADER;
-
-static inline VOID initList(
- IN PLIST_HEADER pList)
-{
- pList->pHead = pList->pTail = NULL;
- pList->size = 0;
- return;
-}
-
-static inline VOID insertTailList(
- IN PLIST_HEADER pList,
- IN PLIST_ENTRY pEntry)
-{
- pEntry->pNext = NULL;
- if (pList->pTail)
- pList->pTail->pNext = pEntry;
- else
- pList->pHead = pEntry;
- pList->pTail = pEntry;
- pList->size++;
-
- return;
-}
-
-static inline PLIST_ENTRY removeHeadList(
- IN PLIST_HEADER pList)
-{
- PLIST_ENTRY pNext;
- PLIST_ENTRY pEntry;
-
- pEntry = pList->pHead;
- if (pList->pHead != NULL)
- {
- pNext = pList->pHead->pNext;
- pList->pHead = pNext;
- if (pNext == NULL)
- pList->pTail = NULL;
- pList->size--;
- }
- return pEntry;
-}
-
-static inline int getListSize(
- IN PLIST_HEADER pList)
-{
- return pList->size;
-}
-
-static inline PLIST_ENTRY delEntryList(
- IN PLIST_HEADER pList,
- IN PLIST_ENTRY pEntry)
-{
- PLIST_ENTRY pCurEntry;
- PLIST_ENTRY pPrvEntry;
-
- if(pList->pHead == NULL)
- return NULL;
-
- if(pEntry == pList->pHead)
- {
- pCurEntry = pList->pHead;
- pList->pHead = pCurEntry->pNext;
-
- if(pList->pHead == NULL)
- pList->pTail = NULL;
-
- pList->size--;
- return pCurEntry;
- }
-
- pPrvEntry = pList->pHead;
- pCurEntry = pPrvEntry->pNext;
- while(pCurEntry != NULL)
- {
- if (pEntry == pCurEntry)
- {
- pPrvEntry->pNext = pCurEntry->pNext;
-
- if(pEntry == pList->pTail)
- pList->pTail = pPrvEntry;
-
- pList->size--;
- break;
- }
- pPrvEntry = pCurEntry;
- pCurEntry = pPrvEntry->pNext;
- }
-
- return pCurEntry;
-}
-
-#endif // ___LINK_LIST_H__ //
-
+#include "../rt2870/link_list.h"
diff --git a/drivers/staging/rt3070/md5.h b/drivers/staging/rt3070/md5.h
index d85db12170d5..1042a994dc72 100644
--- a/drivers/staging/rt3070/md5.h
+++ b/drivers/staging/rt3070/md5.h
@@ -1,107 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- md5.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- jan 10-28-03 Initial
- Rita 11-23-04 Modify MD5 and SHA-1
-*/
-
-#ifndef uint8
-#define uint8 unsigned char
-#endif
-
-#ifndef uint32
-#define uint32 unsigned long int
-#endif
-
-
-#ifndef __MD5_H__
-#define __MD5_H__
-
-#define MD5_MAC_LEN 16
-
-typedef struct _MD5_CTX {
- UINT32 Buf[4]; // buffers of four states
- UCHAR Input[64]; // input message
- UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
-} MD5_CTX;
-
-VOID MD5Init(MD5_CTX *pCtx);
-VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
-VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx);
-VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16]);
-
-void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
-void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
-
-//
-// SHA context
-//
-typedef struct _SHA_CTX
-{
- UINT32 Buf[5]; // buffers of five states
- UCHAR Input[80]; // input message
- UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
-
-} SHA_CTX;
-
-VOID SHAInit(SHA_CTX *pCtx);
-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
-VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]);
-VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20]);
-
-#define SHA_DIGEST_LEN 20
-#endif // __MD5_H__
-
-/******************************************************************************/
-#ifndef _AES_H
-#define _AES_H
-
-typedef struct
-{
- uint32 erk[64]; /* encryption round keys */
- uint32 drk[64]; /* decryption round keys */
- int nr; /* number of rounds */
-}
-aes_context;
-
-int rtmp_aes_set_key( aes_context *ctx, uint8 *key, int nbits );
-void rtmp_aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
-void rtmp_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
-
-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);
-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);
-
-#endif /* aes.h */
-
+#include "../rt2870/md5.h"
diff --git a/drivers/staging/rt3070/mlme.h b/drivers/staging/rt3070/mlme.h
index b0035e1fa8ea..773c0edfcea9 100644
--- a/drivers/staging/rt3070/mlme.h
+++ b/drivers/staging/rt3070/mlme.h
@@ -1,1468 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- mlme.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2003-08-28 Created
- John Chang 2004-09-06 modified for RT2600
-
-*/
-#ifndef __MLME_H__
-#define __MLME_H__
-
-//extern UCHAR BROADCAST_ADDR[];
-
-// maximum supported capability information -
-// ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
-#define SUPPORTED_CAPABILITY_INFO 0x0533
-
-#define END_OF_ARGS -1
-#define LFSR_MASK 0x80000057
-#define MLME_TASK_EXEC_INTV 100/*200*/ //
-#define LEAD_TIME 5
-#define MLME_TASK_EXEC_MULTIPLE 10 /*5*/ // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
-#define REORDER_EXEC_INTV 100 // 0.1 sec
-//#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps
-
-// The definition of Radar detection duration region
-#define CE 0
-#define FCC 1
-#define JAP 2
-#define JAP_W53 3
-#define JAP_W56 4
-#define MAX_RD_REGION 5
-
-#ifdef NDIS51_MINIPORT
-#define BEACON_LOST_TIME 4000 // 2048 msec = 2 sec
-#else
-#define BEACON_LOST_TIME 4 * OS_HZ // 2048 msec = 2 sec
-#endif
-
-#define DLS_TIMEOUT 1200 // unit: msec
-#define AUTH_TIMEOUT 300 // unit: msec
-#define ASSOC_TIMEOUT 300 // unit: msec
-#define JOIN_TIMEOUT 2 * OS_HZ // unit: msec
-#define SHORT_CHANNEL_TIME 90 // unit: msec
-#define MIN_CHANNEL_TIME 110 // unit: msec, for dual band scan
-#define MAX_CHANNEL_TIME 140 // unit: msec, for single band scan
-#define FAST_ACTIVE_SCAN_TIME 30 // Active scan waiting for probe response time
-#define CW_MIN_IN_BITS 4 // actual CwMin = 2^CW_MIN_IN_BITS - 1
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifndef CONFIG_AP_SUPPORT
-#define CW_MAX_IN_BITS 10 // actual CwMax = 2^CW_MAX_IN_BITS - 1
-#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-extern UINT32 CW_MAX_IN_BITS;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-// Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
-// SHould not refer to this constant anymore
-//#define RSSI_TO_DBM_OFFSET 120 // for RT2530 RSSI-115 = dBm
-#define RSSI_FOR_MID_TX_POWER -55 // -55 db is considered mid-distance
-#define RSSI_FOR_LOW_TX_POWER -45 // -45 db is considered very short distance and
- // eligible to use a lower TX power
-#define RSSI_FOR_LOWEST_TX_POWER -30
-//#define MID_TX_POWER_DELTA 0 // 0 db from full TX power upon mid-distance to AP
-#define LOW_TX_POWER_DELTA 6 // -3 db from full TX power upon very short distance. 1 grade is 0.5 db
-#define LOWEST_TX_POWER_DELTA 16 // -8 db from full TX power upon shortest distance. 1 grade is 0.5 db
-
-#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD 0
-#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD 1
-#define RSSI_THRESHOLD_FOR_ROAMING 25
-#define RSSI_DELTA 5
-
-// Channel Quality Indication
-#define CQI_IS_GOOD(cqi) ((cqi) >= 50)
-//#define CQI_IS_FAIR(cqi) (((cqi) >= 20) && ((cqi) < 50))
-#define CQI_IS_POOR(cqi) (cqi < 50) //(((cqi) >= 5) && ((cqi) < 20))
-#define CQI_IS_BAD(cqi) (cqi < 5)
-#define CQI_IS_DEAD(cqi) (cqi == 0)
-
-// weighting factor to calculate Channel quality, total should be 100%
-#define RSSI_WEIGHTING 50
-#define TX_WEIGHTING 30
-#define RX_WEIGHTING 20
-
-//#define PEER_KEY_NOT_USED 0
-//#define PEER_KEY_64_BIT 64
-//#define PEER_KEY_128_BIT 128
-
-//#define PEER_KEY_64BIT_LEN 8
-//#define PEER_KEY_128BIT_LEN 16
-
-#define BSS_NOT_FOUND 0xFFFFFFFF
-
-
-#ifdef CONFIG_STA_SUPPORT
-#define MAX_LEN_OF_MLME_QUEUE 40 //10
-#endif // CONFIG_STA_SUPPORT //
-
-#define SCAN_PASSIVE 18 // scan with no probe request, only wait beacon and probe response
-#define SCAN_ACTIVE 19 // scan with probe request, and wait beacon and probe response
-#define SCAN_CISCO_PASSIVE 20 // Single channel passive scan
-#define SCAN_CISCO_ACTIVE 21 // Single channel active scan
-#define SCAN_CISCO_NOISE 22 // Single channel passive scan for noise histogram collection
-#define SCAN_CISCO_CHANNEL_LOAD 23 // Single channel passive scan for channel load collection
-#define FAST_SCAN_ACTIVE 24 // scan with probe request, and wait beacon and probe response
-
-#ifdef DOT11N_DRAFT3
-#define SCAN_2040_BSS_COEXIST 26
-#endif // DOT11N_DRAFT3 //
-
-//#define BSS_TABLE_EMPTY(x) ((x).BssNr == 0)
-#define MAC_ADDR_IS_GROUP(Addr) (((Addr[0]) & 0x01))
-#define MAC_ADDR_HASH(Addr) (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
-#define TID_MAC_HASH(Addr,TID) (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define TID_MAC_HASH_INDEX(Addr,TID) (TID_MAC_HASH(Addr,TID) % HASH_TABLE_SIZE)
-
-// LED Control
-// assoiation ON. one LED ON. another blinking when TX, OFF when idle
-// no association, both LED off
-#define ASIC_LED_ACT_ON(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
-#define ASIC_LED_ACT_OFF(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
-
-// bit definition of the 2-byte pBEACON->Capability field
-#define CAP_IS_ESS_ON(x) (((x) & 0x0001) != 0)
-#define CAP_IS_IBSS_ON(x) (((x) & 0x0002) != 0)
-#define CAP_IS_CF_POLLABLE_ON(x) (((x) & 0x0004) != 0)
-#define CAP_IS_CF_POLL_REQ_ON(x) (((x) & 0x0008) != 0)
-#define CAP_IS_PRIVACY_ON(x) (((x) & 0x0010) != 0)
-#define CAP_IS_SHORT_PREAMBLE_ON(x) (((x) & 0x0020) != 0)
-#define CAP_IS_PBCC_ON(x) (((x) & 0x0040) != 0)
-#define CAP_IS_AGILITY_ON(x) (((x) & 0x0080) != 0)
-#define CAP_IS_SPECTRUM_MGMT(x) (((x) & 0x0100) != 0) // 802.11e d9
-#define CAP_IS_QOS(x) (((x) & 0x0200) != 0) // 802.11e d9
-#define CAP_IS_SHORT_SLOT(x) (((x) & 0x0400) != 0)
-#define CAP_IS_APSD(x) (((x) & 0x0800) != 0) // 802.11e d9
-#define CAP_IS_IMMED_BA(x) (((x) & 0x1000) != 0) // 802.11e d9
-#define CAP_IS_DSSS_OFDM(x) (((x) & 0x2000) != 0)
-#define CAP_IS_DELAY_BA(x) (((x) & 0x4000) != 0) // 802.11e d9
-
-#define CAP_GENERATE(ess,ibss,priv,s_pre,s_slot,spectrum) (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
-
-//#define STA_QOS_CAPABILITY 0 // 1-byte. see 802.11e d9.0 for bit definition
-
-#define ERP_IS_NON_ERP_PRESENT(x) (((x) & 0x01) != 0) // 802.11g
-#define ERP_IS_USE_PROTECTION(x) (((x) & 0x02) != 0) // 802.11g
-#define ERP_IS_USE_BARKER_PREAMBLE(x) (((x) & 0x04) != 0) // 802.11g
-
-#define DRS_TX_QUALITY_WORST_BOUND 8// 3 // just test by gary
-#define DRS_PENALTY 8
-
-#define BA_NOTUSE 2
-//BA Policy subfiled value in ADDBA frame
-#define IMMED_BA 1
-#define DELAY_BA 0
-
-// BA Initiator subfield in DELBA frame
-#define ORIGINATOR 1
-#define RECIPIENT 0
-
-// ADDBA Status Code
-#define ADDBA_RESULTCODE_SUCCESS 0
-#define ADDBA_RESULTCODE_REFUSED 37
-#define ADDBA_RESULTCODE_INVALID_PARAMETERS 38
-
-// DELBA Reason Code
-#define DELBA_REASONCODE_QSTA_LEAVING 36
-#define DELBA_REASONCODE_END_BA 37
-#define DELBA_REASONCODE_UNKNOWN_BA 38
-#define DELBA_REASONCODE_TIMEOUT 39
-
-// reset all OneSecTx counters
-#define RESET_ONE_SEC_TX_CNT(__pEntry) \
-if (((__pEntry)) != NULL) \
-{ \
- (__pEntry)->OneSecTxRetryOkCount = 0; \
- (__pEntry)->OneSecTxFailCount = 0; \
- (__pEntry)->OneSecTxNoRetryOkCount = 0; \
-}
-
-//
-// 802.11 frame formats
-//
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT LSIGTxopProSup:1;
- USHORT Forty_Mhz_Intolerant:1;
- USHORT PSMP:1;
- USHORT CCKmodein40:1;
- USHORT AMsduSize:1;
- USHORT DelayedBA:1; //rt2860c not support
- USHORT RxSTBC:2;
- USHORT TxSTBC:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT ShortGIfor20:1;
- USHORT GF:1; //green field
- USHORT MimoPs:2;//momi power safe
- USHORT ChannelWidth:1;
- USHORT AdvCoding:1;
-#else
- USHORT AdvCoding:1;
- USHORT ChannelWidth:1;
- USHORT MimoPs:2;//momi power safe
- USHORT GF:1; //green field
- USHORT ShortGIfor20:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT TxSTBC:1;
- USHORT RxSTBC:2;
- USHORT DelayedBA:1; //rt2860c not support
- USHORT AMsduSize:1; // only support as zero
- USHORT CCKmodein40:1;
- USHORT PSMP:1;
- USHORT Forty_Mhz_Intolerant:1;
- USHORT LSIGTxopProSup:1;
-#endif /* !RT_BIG_ENDIAN */
-} HT_CAP_INFO, *PHT_CAP_INFO;
-
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:3;//momi power safe
- UCHAR MpduDensity:3;
- UCHAR MaxRAmpduFactor:2;
-#else
- UCHAR MaxRAmpduFactor:2;
- UCHAR MpduDensity:3;
- UCHAR rsv:3;//momi power safe
-#endif /* !RT_BIG_ENDIAN */
-} HT_CAP_PARM, *PHT_CAP_PARM;
-
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
- UCHAR MCSSet[10];
- UCHAR SupRate[2]; // unit : 1Mbps
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:3;
- UCHAR MpduDensity:1;
- UCHAR TxStream:2;
- UCHAR TxRxNotEqual:1;
- UCHAR TxMCSSetDefined:1;
-#else
- UCHAR TxMCSSetDefined:1;
- UCHAR TxRxNotEqual:1;
- UCHAR TxStream:2;
- UCHAR MpduDensity:1;
- UCHAR rsv:3;
-#endif // RT_BIG_ENDIAN //
- UCHAR rsv3[3];
-} HT_MCS_SET, *PHT_MCS_SET;
-
-// HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:4;
- USHORT RDGSupport:1; //reverse Direction Grant support
- USHORT PlusHTC:1; //+HTC control field support
- USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
- USHORT rsv:5;//momi power safe
- USHORT TranTime:2;
- USHORT Pco:1;
-#else
- USHORT Pco:1;
- USHORT TranTime:2;
- USHORT rsv:5;//momi power safe
- USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
- USHORT PlusHTC:1; //+HTC control field support
- USHORT RDGSupport:1; //reverse Direction Grant support
- USHORT rsv2:4;
-#endif /* RT_BIG_ENDIAN */
-} EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
-
-// HT Beamforming field in HT Cap IE .
-typedef struct PACKED _HT_BF_CAP{
-#ifdef RT_BIG_ENDIAN
- ULONG rsv:3;
- ULONG ChanEstimation:2;
- ULONG CSIRowBFSup:2;
- ULONG ComSteerBFAntSup:2;
- ULONG NoComSteerBFAntSup:2;
- ULONG CSIBFAntSup:2;
- ULONG MinGrouping:2;
- ULONG ExpComBF:2;
- ULONG ExpNoComBF:2;
- ULONG ExpCSIFbk:2;
- ULONG ExpComSteerCapable:1;
- ULONG ExpNoComSteerCapable:1;
- ULONG ExpCSICapable:1;
- ULONG Calibration:2;
- ULONG ImpTxBFCapable:1;
- ULONG TxNDPCapable:1;
- ULONG RxNDPCapable:1;
- ULONG TxSoundCapable:1;
- ULONG RxSoundCapable:1;
- ULONG TxBFRecCapable:1;
-#else
- ULONG TxBFRecCapable:1;
- ULONG RxSoundCapable:1;
- ULONG TxSoundCapable:1;
- ULONG RxNDPCapable:1;
- ULONG TxNDPCapable:1;
- ULONG ImpTxBFCapable:1;
- ULONG Calibration:2;
- ULONG ExpCSICapable:1;
- ULONG ExpNoComSteerCapable:1;
- ULONG ExpComSteerCapable:1;
- ULONG ExpCSIFbk:2;
- ULONG ExpNoComBF:2;
- ULONG ExpComBF:2;
- ULONG MinGrouping:2;
- ULONG CSIBFAntSup:2;
- ULONG NoComSteerBFAntSup:2;
- ULONG ComSteerBFAntSup:2;
- ULONG CSIRowBFSup:2;
- ULONG ChanEstimation:2;
- ULONG rsv:3;
-#endif // RT_BIG_ENDIAN //
-} HT_BF_CAP, *PHT_BF_CAP;
-
-// HT antenna selection field in HT Cap IE .
-typedef struct PACKED _HT_AS_CAP{
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv:1;
- UCHAR TxSoundPPDU:1;
- UCHAR RxASel:1;
- UCHAR AntIndFbk:1;
- UCHAR ExpCSIFbk:1;
- UCHAR AntIndFbkTxASEL:1;
- UCHAR ExpCSIFbkTxASEL:1;
- UCHAR AntSelect:1;
-#else
- UCHAR AntSelect:1;
- UCHAR ExpCSIFbkTxASEL:1;
- UCHAR AntIndFbkTxASEL:1;
- UCHAR ExpCSIFbk:1;
- UCHAR AntIndFbk:1;
- UCHAR RxASel:1;
- UCHAR TxSoundPPDU:1;
- UCHAR rsv:1;
-#endif // RT_BIG_ENDIAN //
-} HT_AS_CAP, *PHT_AS_CAP;
-
-// Draft 1.0 set IE length 26, but is extensible..
-#define SIZE_HT_CAP_IE 26
-// The structure for HT Capability IE.
-typedef struct PACKED _HT_CAPABILITY_IE{
- HT_CAP_INFO HtCapInfo;
- HT_CAP_PARM HtCapParm;
-// HT_MCS_SET HtMCSSet;
- UCHAR MCSSet[16];
- EXT_HT_CAP_INFO ExtHtCapInfo;
- HT_BF_CAP TxBFCap; // beamforming cap. rt2860c not support beamforming.
- HT_AS_CAP ASCap; //antenna selection.
-} HT_CAPABILITY_IE, *PHT_CAPABILITY_IE;
-
-
-// 802.11n draft3 related structure definitions.
-// 7.3.2.60
-#define dot11OBSSScanPassiveDwell 20 // in TU. min amount of time that the STA continously scans each channel when performing an active OBSS scan.
-#define dot11OBSSScanActiveDwell 10 // in TU.min amount of time that the STA continously scans each channel when performing an passive OBSS scan.
-#define dot11BSSWidthTriggerScanInterval 300 // in sec. max interval between scan operations to be performed to detect BSS channel width trigger events.
-#define dot11OBSSScanPassiveTotalPerChannel 200 // in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan.
-#define dot11OBSSScanActiveTotalPerChannel 20 //in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
-#define dot11BSSWidthChannelTransactionDelayFactor 5 // min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
- // interval between overlapping BSS scan operations.
-#define dot11BSSScanActivityThreshold 25 // in %%, max total time that a STA may be active on the medium during a period of
- // (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
- // being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
-
-typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
- USHORT ScanPassiveDwell;
- USHORT ScanActiveDwell;
- USHORT TriggerScanInt; // Trigger scan interval
- USHORT PassiveTalPerChannel; // passive total per channel
- USHORT ActiveTalPerChannel; // active total per channel
- USHORT DelayFactor; // BSS width channel transition delay factor
- USHORT ScanActThre; // Scan Activity threshold
-}OVERLAP_BSS_SCAN_IE, *POVERLAP_BSS_SCAN_IE;
-
-
-// 7.3.2.56. 20/40 Coexistence element used in Element ID = 72 = IE_2040_BSS_COEXIST
-typedef union PACKED _BSS_2040_COEXIST_IE{
- struct PACKED {
- #ifdef RT_BIG_ENDIAN
- UCHAR rsv:5;
- UCHAR BSS20WidthReq:1;
- UCHAR Intolerant40:1;
- UCHAR InfoReq:1;
- #else
- UCHAR InfoReq:1;
- UCHAR Intolerant40:1; // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
- UCHAR BSS20WidthReq:1; // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
- UCHAR rsv:5;
-#endif // RT_BIG_ENDIAN //
- } field;
- UCHAR word;
-} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
-
-
-typedef struct _TRIGGER_EVENTA{
- BOOLEAN bValid;
- UCHAR BSSID[6];
- UCHAR RegClass; // Regulatory Class
- USHORT Channel;
- ULONG CDCounter; // Maintain a seperate count down counter for each Event A.
-} TRIGGER_EVENTA, *PTRIGGER_EVENTA;
-
-// 20/40 trigger event table
-// If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
-#define MAX_TRIGGER_EVENT 64
-typedef struct _TRIGGER_EVENT_TAB{
- UCHAR EventANo;
- TRIGGER_EVENTA EventA[MAX_TRIGGER_EVENT];
- ULONG EventBCountDown; // Count down counter for Event B.
-} TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
-
-// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
-// This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
-typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
-#ifdef RT_BIG_ENDIAN
- UCHAR rsv2:5;
- UCHAR ExtendChannelSwitch:1;
- UCHAR rsv:1;
- UCHAR BssCoexistMgmtSupport:1;
-#else
- UCHAR BssCoexistMgmtSupport:1;
- UCHAR rsv:1;
- UCHAR ExtendChannelSwitch:1;
- UCHAR rsv2:5;
-#endif // RT_BIG_ENDIAN //
-}EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
-
-
-// 802.11n 7.3.2.61
-typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
- UCHAR ElementID; // ID = IE_2040_BSS_COEXIST = 72
- UCHAR Len;
- BSS_2040_COEXIST_IE BssCoexistIe;
-}BSS_2040_COEXIST_ELEMENT, *PBSS_2040_COEXIST_ELEMENT;
-
-
-//802.11n 7.3.2.59
-typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
- UCHAR ElementID; // ID = IE_2040_BSS_INTOLERANT_REPORT = 73
- UCHAR Len;
- UCHAR RegulatoryClass;
- UCHAR ChList[0];
-}BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
-
-
-// The structure for channel switch annoucement IE. This is in 802.11n D3.03
-typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
- UCHAR SwitchMode; //channel switch mode
- UCHAR NewChannel; //
- UCHAR SwitchCount; //
-} CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
-
-
-// The structure for channel switch annoucement IE. This is in 802.11n D3.03
-typedef struct PACKED _SEC_CHA_OFFSET_IE{
- UCHAR SecondaryChannelOffset; // 1: Secondary above, 3: Secondary below, 0: no Secondary
-} SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
-
-
-// This structure is extracted from struct RT_HT_CAPABILITY
-typedef struct {
- BOOLEAN bHtEnable; // If we should use ht rate.
- BOOLEAN bPreNHt; // If we should use ht rate.
- //Substract from HT Capability IE
- UCHAR MCSSet[16]; //only supoort MCS=0-15,32 ,
-} RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
-
-//This structure substracts ralink supports from all 802.11n-related features.
-//Features not listed here but contained in 802.11n spec are not supported in rt2860.
-typedef struct {
-#ifdef RT_BIG_ENDIAN
- USHORT rsv:5;
- USHORT AmsduSize:1; // Max receiving A-MSDU size
- USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
- USHORT RxSTBC:2; // 2 bits
- USHORT TxSTBC:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT ShortGIfor20:1;
- USHORT GF:1; //green field
- USHORT MimoPs:2;//mimo power safe MMPS_
- USHORT ChannelWidth:1;
-#else
- USHORT ChannelWidth:1;
- USHORT MimoPs:2;//mimo power safe MMPS_
- USHORT GF:1; //green field
- USHORT ShortGIfor20:1;
- USHORT ShortGIfor40:1; //for40MHz
- USHORT TxSTBC:1;
- USHORT RxSTBC:2; // 2 bits
- USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
- USHORT AmsduSize:1; // Max receiving A-MSDU size
- USHORT rsv:5;
-#endif
-
- //Substract from Addiont HT INFO IE
-#ifdef RT_BIG_ENDIAN
- UCHAR RecomWidth:1;
- UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
- UCHAR MpduDensity:3;
- UCHAR MaxRAmpduFactor:2;
-#else
- UCHAR MaxRAmpduFactor:2;
- UCHAR MpduDensity:3;
- UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
- UCHAR RecomWidth:1;
-#endif
-
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:11;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv3:1;
- USHORT NonGfPresent:1;
- USHORT OperaionMode:2;
-#else
- USHORT OperaionMode:2;
- USHORT NonGfPresent:1;
- USHORT rsv3:1;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv2:11;
-#endif
-
- // New Extension Channel Offset IE
- UCHAR NewExtChannelOffset;
- // Extension Capability IE = 127
- UCHAR BSSCoexist2040;
-} RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
-
-// field in Addtional HT Information IE .
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR SerInterGranu:3;
- UCHAR S_PSMPSup:1;
- UCHAR RifsMode:1;
- UCHAR RecomWidth:1;
- UCHAR ExtChanOffset:2;
-#else
- UCHAR ExtChanOffset:2;
- UCHAR RecomWidth:1;
- UCHAR RifsMode:1;
- UCHAR S_PSMPSup:1; //Indicate support for scheduled PSMP
- UCHAR SerInterGranu:3; //service interval granularity
-#endif
-} ADD_HTINFO, *PADD_HTINFO;
-
-typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT rsv2:11;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv:1;
- USHORT NonGfPresent:1;
- USHORT OperaionMode:2;
-#else
- USHORT OperaionMode:2;
- USHORT NonGfPresent:1;
- USHORT rsv:1;
- USHORT OBSS_NonHTExist:1;
- USHORT rsv2:11;
-#endif
-} ADD_HTINFO2, *PADD_HTINFO2;
-
-
-// TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
-typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT rsv:4;
- USHORT PcoPhase:1;
- USHORT PcoActive:1;
- USHORT LsigTxopProt:1;
- USHORT STBCBeacon:1;
- USHORT DualCTSProtect:1;
- USHORT DualBeacon:1;
- USHORT StbcMcs:6;
-#else
- USHORT StbcMcs:6;
- USHORT DualBeacon:1;
- USHORT DualCTSProtect:1;
- USHORT STBCBeacon:1;
- USHORT LsigTxopProt:1; // L-SIG TXOP protection full support
- USHORT PcoActive:1;
- USHORT PcoPhase:1;
- USHORT rsv:4;
-#endif // RT_BIG_ENDIAN //
-} ADD_HTINFO3, *PADD_HTINFO3;
-
-#define SIZE_ADD_HT_INFO_IE 22
-typedef struct PACKED{
- UCHAR ControlChan;
- ADD_HTINFO AddHtInfo;
- ADD_HTINFO2 AddHtInfo2;
- ADD_HTINFO3 AddHtInfo3;
- UCHAR MCSSet[16]; // Basic MCS set
-} ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
-
-typedef struct PACKED{
- UCHAR NewExtChanOffset;
-} NEW_EXT_CHAN_IE, *PNEW_EXT_CHAN_IE;
-
-
-// 4-byte HTC field. maybe included in any frame except non-QOS data frame. The Order bit must set 1.
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UINT32 RDG:1; //RDG / More PPDU
- UINT32 ACConstraint:1; //feedback request
- UINT32 rsv:5; //calibration sequence
- UINT32 ZLFAnnouce:1; // ZLF announcement
- UINT32 CSISTEERING:2; //CSI/ STEERING
- UINT32 FBKReq:2; //feedback request
- UINT32 CalSeq:2; //calibration sequence
- UINT32 CalPos:2; // calibration position
- UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
- UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
- UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
- UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
- UINT32 TRQ:1; //sounding request
- UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
-#else
- UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
- UINT32 TRQ:1; //sounding request
- UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
- UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
- UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
- UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
- UINT32 CalPos:2; // calibration position
- UINT32 CalSeq:2; //calibration sequence
- UINT32 FBKReq:2; //feedback request
- UINT32 CSISTEERING:2; //CSI/ STEERING
- UINT32 ZLFAnnouce:1; // ZLF announcement
- UINT32 rsv:5; //calibration sequence
- UINT32 ACConstraint:1; //feedback request
- UINT32 RDG:1; //RDG / More PPDU
-#endif /* !RT_BIG_ENDIAN */
-} HT_CONTROL, *PHT_CONTROL;
-
-// 2-byte QOS CONTROL field
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Txop_QueueSize:8;
- USHORT AMsduPresent:1;
- USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
- USHORT EOSP:1;
- USHORT TID:4;
-#else
- USHORT TID:4;
- USHORT EOSP:1;
- USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
- USHORT AMsduPresent:1;
- USHORT Txop_QueueSize:8;
-#endif /* !RT_BIG_ENDIAN */
-} QOS_CONTROL, *PQOS_CONTROL;
-
-// 2-byte Frame control field
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Order:1; // Strict order expected
- USHORT Wep:1; // Wep data
- USHORT MoreData:1; // More data bit
- USHORT PwrMgmt:1; // Power management bit
- USHORT Retry:1; // Retry status bit
- USHORT MoreFrag:1; // More fragment bit
- USHORT FrDs:1; // From DS indication
- USHORT ToDs:1; // To DS indication
- USHORT SubType:4; // MSDU subtype
- USHORT Type:2; // MSDU type
- USHORT Ver:2; // Protocol version
-#else
- USHORT Ver:2; // Protocol version
- USHORT Type:2; // MSDU type
- USHORT SubType:4; // MSDU subtype
- USHORT ToDs:1; // To DS indication
- USHORT FrDs:1; // From DS indication
- USHORT MoreFrag:1; // More fragment bit
- USHORT Retry:1; // Retry status bit
- USHORT PwrMgmt:1; // Power management bit
- USHORT MoreData:1; // More data bit
- USHORT Wep:1; // Wep data
- USHORT Order:1; // Strict order expected
-#endif /* !RT_BIG_ENDIAN */
-} FRAME_CONTROL, *PFRAME_CONTROL;
-
-typedef struct PACKED _HEADER_802_11 {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR Addr3[MAC_ADDR_LEN];
-#ifdef RT_BIG_ENDIAN
- USHORT Sequence:12;
- USHORT Frag:4;
-#else
- USHORT Frag:4;
- USHORT Sequence:12;
-#endif /* !RT_BIG_ENDIAN */
- UCHAR Octet[0];
-} HEADER_802_11, *PHEADER_802_11;
-
-typedef struct PACKED _FRAME_802_11 {
- HEADER_802_11 Hdr;
- UCHAR Octet[1];
-} FRAME_802_11, *PFRAME_802_11;
-
-// QoSNull embedding of management action. When HT Control MA field set to 1.
-typedef struct PACKED _MA_BODY {
- UCHAR Category;
- UCHAR Action;
- UCHAR Octet[1];
-} MA_BODY, *PMA_BODY;
-
-typedef struct PACKED _HEADER_802_3 {
- UCHAR DAAddr1[MAC_ADDR_LEN];
- UCHAR SAAddr2[MAC_ADDR_LEN];
- UCHAR Octet[2];
-} HEADER_802_3, *PHEADER_802_3;
-////Block ACK related format
-// 2-byte BA Parameter field in DELBA frames to terminate an already set up bA
-typedef struct PACKED{
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4; // value of TC os TS
- USHORT Initiator:1; // 1: originator 0:recipient
- USHORT Rsv:11; // always set to 0
-#else
- USHORT Rsv:11; // always set to 0
- USHORT Initiator:1; // 1: originator 0:recipient
- USHORT TID:4; // value of TC os TS
-#endif /* !RT_BIG_ENDIAN */
-} DELBA_PARM, *PDELBA_PARM;
-
-// 2-byte BA Parameter Set field in ADDBA frames to signal parm for setting up a BA
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT BufSize:10; // number of buffe of size 2304 octetsr
- USHORT TID:4; // value of TC os TS
- USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
- USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
-#else
- USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
- USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
- USHORT TID:4; // value of TC os TS
- USHORT BufSize:10; // number of buffe of size 2304 octetsr
-#endif /* !RT_BIG_ENDIAN */
-} BA_PARM, *PBA_PARM;
-
-// 2-byte BA Starting Seq CONTROL field
-typedef union PACKED {
- struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
- USHORT FragNum:4; // always set to 0
-#else
- USHORT FragNum:4; // always set to 0
- USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
-#endif /* RT_BIG_ENDIAN */
- } field;
- USHORT word;
-} BASEQ_CONTROL, *PBASEQ_CONTROL;
-
-//BAControl and BARControl are the same
-// 2-byte BA CONTROL field in BA frame
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv:9;
- USHORT Compressed:1;
- USHORT MTID:1; //EWC V1.24
- USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
-#else
- USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
- USHORT MTID:1; //EWC V1.24
- USHORT Compressed:1;
- USHORT Rsv:9;
- USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
-} BA_CONTROL, *PBA_CONTROL;
-
-// 2-byte BAR CONTROL field in BAR frame
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv1:9;
- USHORT Compressed:1;
- USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
- USHORT ACKPolicy:1;
-#else
- USHORT ACKPolicy:1; // 0:normal ack, 1:no ack.
- USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
- USHORT Compressed:1;
- USHORT Rsv1:9;
- USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
-} BAR_CONTROL, *PBAR_CONTROL;
-
-// BARControl in MTBAR frame
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT NumTID:4;
- USHORT Rsv1:9;
- USHORT Compressed:1;
- USHORT MTID:1;
- USHORT ACKPolicy:1;
-#else
- USHORT ACKPolicy:1;
- USHORT MTID:1;
- USHORT Compressed:1;
- USHORT Rsv1:9;
- USHORT NumTID:4;
-#endif /* !RT_BIG_ENDIAN */
-} MTBAR_CONTROL, *PMTBAR_CONTROL;
-
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT TID:4;
- USHORT Rsv1:12;
-#else
- USHORT Rsv1:12;
- USHORT TID:4;
-#endif /* !RT_BIG_ENDIAN */
-} PER_TID_INFO, *PPER_TID_INFO;
-
-typedef struct {
- PER_TID_INFO PerTID;
- BASEQ_CONTROL BAStartingSeq;
-} EACH_TID, *PEACH_TID;
-
-
-typedef struct PACKED _PSPOLL_FRAME {
- FRAME_CONTROL FC;
- USHORT Aid;
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR Ta[MAC_ADDR_LEN];
-} PSPOLL_FRAME, *PPSPOLL_FRAME;
-
-typedef struct PACKED _RTS_FRAME {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
-}RTS_FRAME, *PRTS_FRAME;
-
-// BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap.
-typedef struct PACKED _FRAME_BA_REQ {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BAR_CONTROL BARControl;
- BASEQ_CONTROL BAStartingSeq;
-} FRAME_BA_REQ, *PFRAME_BA_REQ;
-
-typedef struct PACKED _FRAME_MTBA_REQ {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- MTBAR_CONTROL MTBARControl;
- PER_TID_INFO PerTIDInfo;
- BASEQ_CONTROL BAStartingSeq;
-} FRAME_MTBA_REQ, *PFRAME_MTBA_REQ;
-
-// Compressed format is mandantory in HT STA
-typedef struct PACKED _FRAME_MTBA {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BA_CONTROL BAControl;
- BASEQ_CONTROL BAStartingSeq;
- UCHAR BitMap[8];
-} FRAME_MTBA, *PFRAME_MTBA;
-
-typedef struct PACKED _FRAME_PSMP_ACTION {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Psmp; // 7.3.1.25
-} FRAME_PSMP_ACTION, *PFRAME_PSMP_ACTION;
-
-typedef struct PACKED _FRAME_ACTION_HDR {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
-} FRAME_ACTION_HDR, *PFRAME_ACTION_HDR;
-
-//Action Frame
-//Action Frame Category:Spectrum, Action:Channel Switch. 7.3.2.20
-typedef struct PACKED _CHAN_SWITCH_ANNOUNCE {
- UCHAR ElementID; // ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37
- UCHAR Len;
- CHA_SWITCH_ANNOUNCE_IE CSAnnounceIe;
-} CHAN_SWITCH_ANNOUNCE, *PCHAN_SWITCH_ANNOUNCE;
-
-
-//802.11n : 7.3.2.20a
-typedef struct PACKED _SECOND_CHAN_OFFSET {
- UCHAR ElementID; // ID = IE_SECONDARY_CH_OFFSET = 62
- UCHAR Len;
- SEC_CHA_OFFSET_IE SecChOffsetIe;
-} SECOND_CHAN_OFFSET, *PSECOND_CHAN_OFFSET;
-
-
-typedef struct PACKED _FRAME_SPETRUM_CS {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- CHAN_SWITCH_ANNOUNCE CSAnnounce;
- SECOND_CHAN_OFFSET SecondChannel;
-} FRAME_SPETRUM_CS, *PFRAME_SPETRUM_CS;
-
-
-typedef struct PACKED _FRAME_ADDBA_REQ {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Token; // 1
- BA_PARM BaParm; // 2 - 10
- USHORT TimeOutValue; // 0 - 0
- BASEQ_CONTROL BaStartSeq; // 0-0
-} FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
-
-typedef struct PACKED _FRAME_ADDBA_RSP {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Token;
- USHORT StatusCode;
- BA_PARM BaParm; //0 - 2
- USHORT TimeOutValue;
-} FRAME_ADDBA_RSP, *PFRAME_ADDBA_RSP;
-
-typedef struct PACKED _FRAME_DELBA_REQ {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- DELBA_PARM DelbaParm;
- USHORT ReasonCode;
-} FRAME_DELBA_REQ, *PFRAME_DELBA_REQ;
-
-
-//7.2.1.7
-typedef struct PACKED _FRAME_BAR {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BAR_CONTROL BarControl;
- BASEQ_CONTROL StartingSeq;
-} FRAME_BAR, *PFRAME_BAR;
-
-//7.2.1.7
-typedef struct PACKED _FRAME_BA {
- FRAME_CONTROL FC;
- USHORT Duration;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- BAR_CONTROL BarControl;
- BASEQ_CONTROL StartingSeq;
- UCHAR bitmask[8];
-} FRAME_BA, *PFRAME_BA;
-
-
-// Radio Measuement Request Frame Format
-typedef struct PACKED _FRAME_RM_REQ_ACTION {
- HEADER_802_11 Hdr;
- UCHAR Category;
- UCHAR Action;
- UCHAR Token;
- USHORT Repetition;
- UCHAR data[0];
-} FRAME_RM_REQ_ACTION, *PFRAME_RM_REQ_ACTION;
-
-typedef struct PACKED {
- UCHAR ID;
- UCHAR Length;
- UCHAR ChannelSwitchMode;
- UCHAR NewRegClass;
- UCHAR NewChannelNum;
- UCHAR ChannelSwitchCount;
-} HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE, *PHT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE;
-
-
-//
-// _Limit must be the 2**n - 1
-// _SEQ1 , _SEQ2 must be within 0 ~ _Limit
-//
-#define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit) ((_SEQ1 == ((_SEQ2+1) & _Limit)))
-#define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit) (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
-#define SEQ_LARGER(_SEQ1, _SEQ2, _Limit) ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
-#define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) && \
- SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
-
-//
-// Contention-free parameter (without ID and Length)
-//
-typedef struct PACKED {
- BOOLEAN bValid; // 1: variable contains valid value
- UCHAR CfpCount;
- UCHAR CfpPeriod;
- USHORT CfpMaxDuration;
- USHORT CfpDurRemaining;
-} CF_PARM, *PCF_PARM;
-
-typedef struct _CIPHER_SUITE {
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher 1, this one has more secured cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipherAux; // Unicast cipher 2 if AP announce two unicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Group cipher
- USHORT RsnCapability; // RSN capability from beacon
- BOOLEAN bMixMode; // Indicate Pair & Group cipher might be different
-} CIPHER_SUITE, *PCIPHER_SUITE;
-
-// EDCA configuration from AP's BEACON/ProbeRsp
-typedef struct {
- BOOLEAN bValid; // 1: variable contains valid value
- BOOLEAN bAdd; // 1: variable contains valid value
- BOOLEAN bQAck;
- BOOLEAN bQueueRequest;
- BOOLEAN bTxopRequest;
- BOOLEAN bAPSDCapable;
-// BOOLEAN bMoreDataAck;
- UCHAR EdcaUpdateCount;
- UCHAR Aifsn[4]; // 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO
- UCHAR Cwmin[4];
- UCHAR Cwmax[4];
- USHORT Txop[4]; // in unit of 32-us
- BOOLEAN bACM[4]; // 1: Admission Control of AC_BK is mandattory
-} EDCA_PARM, *PEDCA_PARM;
-
-// QBSS LOAD information from QAP's BEACON/ProbeRsp
-typedef struct {
- BOOLEAN bValid; // 1: variable contains valid value
- USHORT StaNum;
- UCHAR ChannelUtilization;
- USHORT RemainingAdmissionControl; // in unit of 32-us
-} QBSS_LOAD_PARM, *PQBSS_LOAD_PARM;
-
-// QBSS Info field in QSTA's assoc req
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR Rsv2:1;
- UCHAR MaxSPLength:2;
- UCHAR Rsv1:1;
- UCHAR UAPSD_AC_BE:1;
- UCHAR UAPSD_AC_BK:1;
- UCHAR UAPSD_AC_VI:1;
- UCHAR UAPSD_AC_VO:1;
-#else
- UCHAR UAPSD_AC_VO:1;
- UCHAR UAPSD_AC_VI:1;
- UCHAR UAPSD_AC_BK:1;
- UCHAR UAPSD_AC_BE:1;
- UCHAR Rsv1:1;
- UCHAR MaxSPLength:2;
- UCHAR Rsv2:1;
-#endif /* !RT_BIG_ENDIAN */
-} QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
-
-// QBSS Info field in QAP's Beacon/ProbeRsp
-typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN
- UCHAR UAPSD:1;
- UCHAR Rsv:3;
- UCHAR ParamSetCount:4;
-#else
- UCHAR ParamSetCount:4;
- UCHAR Rsv:3;
- UCHAR UAPSD:1;
-#endif /* !RT_BIG_ENDIAN */
-} QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
-
-// QOS Capability reported in QAP's BEACON/ProbeRsp
-// QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq
-typedef struct {
- BOOLEAN bValid; // 1: variable contains valid value
- BOOLEAN bQAck;
- BOOLEAN bQueueRequest;
- BOOLEAN bTxopRequest;
-// BOOLEAN bMoreDataAck;
- UCHAR EdcaUpdateCount;
-} QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
-
-#ifdef CONFIG_STA_SUPPORT
-typedef struct {
- UCHAR IELen;
- UCHAR IE[MAX_CUSTOM_LEN];
-} WPA_IE_;
-#endif // CONFIG_STA_SUPPORT //
-
-
-typedef struct {
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR Channel;
- UCHAR CentralChannel; //Store the wide-band central channel for 40MHz. .used in 40MHz AP. Or this is the same as Channel.
- UCHAR BssType;
- USHORT AtimWin;
- USHORT BeaconPeriod;
-
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen;
- HT_CAPABILITY_IE HtCapability;
- UCHAR HtCapabilityLen;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR AddHtInfoLen;
- UCHAR NewExtChanOffset;
- CHAR Rssi;
- UCHAR Privacy; // Indicate security function ON/OFF. Don't mess up with auth mode.
- UCHAR Hidden;
-
- USHORT DtimPeriod;
- USHORT CapabilityInfo;
-
- USHORT CfpCount;
- USHORT CfpPeriod;
- USHORT CfpMaxDuration;
- USHORT CfpDurRemaining;
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
-
- ULONG LastBeaconRxTime; // OS's timestamp
-
- BOOLEAN bSES;
-
- // New for WPA2
- CIPHER_SUITE WPA; // AP announced WPA cipher suite
- CIPHER_SUITE WPA2; // AP announced WPA2 cipher suite
-
- // New for microsoft WPA support
- NDIS_802_11_FIXED_IEs FixIEs;
- NDIS_802_11_AUTHENTICATION_MODE AuthModeAux; // Addition mode for WPA2 / WPA capable AP
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus; // Unicast Encryption Algorithm extract from VAR_IE
- USHORT VarIELen; // Length of next VIE include EID & Length
- UCHAR VarIEs[MAX_VIE_LEN];
-
- // CCX Ckip information
- UCHAR CkipFlag;
-
- // CCX 2 TSF
- UCHAR PTSF[4]; // Parent TSF
- UCHAR TTSF[8]; // Target TSF
-
- // 802.11e d9, and WMM
- EDCA_PARM EdcaParm;
- QOS_CAPABILITY_PARM QosCapability;
- QBSS_LOAD_PARM QbssLoad;
-#ifdef CONFIG_STA_SUPPORT
- WPA_IE_ WpaIE;
- WPA_IE_ RsnIE;
-#ifdef EXT_BUILD_CHANNEL_LIST
- UCHAR CountryString[3];
- BOOLEAN bHasCountryIE;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
-} BSS_ENTRY, *PBSS_ENTRY;
-
-typedef struct {
- UCHAR BssNr;
- UCHAR BssOverlapNr;
- BSS_ENTRY BssEntry[MAX_LEN_OF_BSS_TABLE];
-} BSS_TABLE, *PBSS_TABLE;
-
-
-typedef struct _MLME_QUEUE_ELEM {
- ULONG Machine;
- ULONG MsgType;
- ULONG MsgLen;
- UCHAR Msg[MGMT_DMA_BUFFER_SIZE];
- LARGE_INTEGER TimeStamp;
- UCHAR Rssi0;
- UCHAR Rssi1;
- UCHAR Rssi2;
- UCHAR Signal;
- UCHAR Channel;
- UCHAR Wcid;
- BOOLEAN Occupied;
-#ifdef MLME_EX
- USHORT Idx;
-#endif // MLME_EX //
-} MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM;
-
-typedef struct _MLME_QUEUE {
- ULONG Num;
- ULONG Head;
- ULONG Tail;
- NDIS_SPIN_LOCK Lock;
- MLME_QUEUE_ELEM Entry[MAX_LEN_OF_MLME_QUEUE];
-} MLME_QUEUE, *PMLME_QUEUE;
-
-typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem);
-
-typedef struct _STATE_MACHINE {
- ULONG Base;
- ULONG NrState;
- ULONG NrMsg;
- ULONG CurrState;
- STATE_MACHINE_FUNC *TransFunc;
-} STATE_MACHINE, *PSTATE_MACHINE;
-
-
-// MLME AUX data structure that hold temporarliy settings during a connection attempt.
-// Once this attemp succeeds, all settings will be copy to pAd->StaActive.
-// A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of
-// several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely
-// separate this under-trial settings away from pAd->StaActive so that once
-// this new attempt failed, driver can auto-recover back to the active settings.
-typedef struct _MLME_AUX {
- UCHAR BssType;
- UCHAR Ssid[MAX_LEN_OF_SSID];
- UCHAR SsidLen;
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR AutoReconnectSsid[MAX_LEN_OF_SSID];
- UCHAR AutoReconnectSsidLen;
- USHORT Alg;
- UCHAR ScanType;
- UCHAR Channel;
- UCHAR CentralChannel;
- USHORT Aid;
- USHORT CapabilityInfo;
- USHORT BeaconPeriod;
- USHORT CfpMaxDuration;
- USHORT CfpPeriod;
- USHORT AtimWin;
-
- // Copy supported rate from desired AP's beacon. We are trying to match
- // AP's supported and extended rate settings.
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRateLen;
- HT_CAPABILITY_IE HtCapability;
- UCHAR HtCapabilityLen;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR NewExtChannelOffset;
- //RT_HT_CAPABILITY SupportedHtPhy;
-
- // new for QOS
- QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
- EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
- QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
-
- // new to keep Ralink specific feature
- ULONG APRalinkIe;
-
- BSS_TABLE SsidBssTab; // AP list for the same SSID
- BSS_TABLE RoamTab; // AP list eligible for roaming
- ULONG BssIdx;
- ULONG RoamIdx;
-
- BOOLEAN CurrReqIsFromNdis;
-
- RALINK_TIMER_STRUCT BeaconTimer, ScanTimer;
- RALINK_TIMER_STRUCT AuthTimer;
- RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
-} MLME_AUX, *PMLME_AUX;
-
-typedef struct _MLME_ADDBA_REQ_STRUCT{
- UCHAR Wcid; //
- UCHAR pAddr[MAC_ADDR_LEN];
- UCHAR BaBufSize;
- USHORT TimeOutValue;
- UCHAR TID;
- UCHAR Token;
- USHORT BaStartSeq;
-} MLME_ADDBA_REQ_STRUCT, *PMLME_ADDBA_REQ_STRUCT;
-
-
-typedef struct _MLME_DELBA_REQ_STRUCT{
- UCHAR Wcid; //
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR TID;
- UCHAR Initiator;
-} MLME_DELBA_REQ_STRUCT, *PMLME_DELBA_REQ_STRUCT;
-
-// assoc struct is equal to reassoc
-typedef struct _MLME_ASSOC_REQ_STRUCT{
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT CapabilityInfo;
- USHORT ListenIntv;
- ULONG Timeout;
-} MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT;
-
-typedef struct _MLME_DISASSOC_REQ_STRUCT{
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Reason;
-} MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT;
-
-typedef struct _MLME_AUTH_REQ_STRUCT {
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Alg;
- ULONG Timeout;
-} MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT;
-
-typedef struct _MLME_DEAUTH_REQ_STRUCT {
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Reason;
-} MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
-
-typedef struct {
- ULONG BssIdx;
-} MLME_JOIN_REQ_STRUCT;
-
-typedef struct _MLME_SCAN_REQ_STRUCT {
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR BssType;
- UCHAR ScanType;
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
-} MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT;
-
-typedef struct _MLME_START_REQ_STRUCT {
- CHAR Ssid[MAX_LEN_OF_SSID];
- UCHAR SsidLen;
-} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-// structure for DLS
-typedef struct _RT_802_11_DLS {
- USHORT TimeOut; // Use to time out while slience, unit: second , set by UI
- USHORT CountDownTimer; // Use to time out while slience,unit: second , used by driver only
- NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
- UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
- BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
- RALINK_TIMER_STRUCT Timer; // Use to time out while handshake
- USHORT Sequence;
- USHORT MacTabMatchWCID; // ASIC
- BOOLEAN bHTCap;
- PVOID pAd;
-} RT_802_11_DLS, *PRT_802_11_DLS;
-
-typedef struct _MLME_DLS_REQ_STRUCT {
- PRT_802_11_DLS pDLS;
- USHORT Reason;
-} MLME_DLS_REQ_STRUCT, *PMLME_DLS_REQ_STRUCT;
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-typedef struct PACKED {
- UCHAR Eid;
- UCHAR Len;
- CHAR Octet[1];
-} EID_STRUCT,*PEID_STRUCT, BEACON_EID_STRUCT, *PBEACON_EID_STRUCT;
-
-typedef struct PACKED _RTMP_TX_RATE_SWITCH
-{
- UCHAR ItemNo;
-#ifdef RT_BIG_ENDIAN
- UCHAR Rsv2:2;
- UCHAR Mode:2;
- UCHAR Rsv1:1;
- UCHAR BW:1;
- UCHAR ShortGI:1;
- UCHAR STBC:1;
-#else
- UCHAR STBC:1;
- UCHAR ShortGI:1;
- UCHAR BW:1;
- UCHAR Rsv1:1;
- UCHAR Mode:2;
- UCHAR Rsv2:2;
-#endif
- UCHAR CurrMCS;
- UCHAR TrainUp;
- UCHAR TrainDown;
-} RRTMP_TX_RATE_SWITCH, *PRTMP_TX_RATE_SWITCH;
-
-// ========================== AP mlme.h ===============================
-#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps
-#define DEFAULT_DTIM_PERIOD 1
-
-// weighting factor to calculate Channel quality, total should be 100%
-//#define RSSI_WEIGHTING 0
-//#define TX_WEIGHTING 40
-//#define RX_WEIGHTING 60
-
-#define MAC_TABLE_AGEOUT_TIME 300 // unit: sec
-#define MAC_TABLE_ASSOC_TIMEOUT 5 // unit: sec
-#define MAC_TABLE_FULL(Tab) ((Tab).size == MAX_LEN_OF_MAC_TABLE)
-
-// AP shall drop the sta if contine Tx fail count reach it.
-#define MAC_ENTRY_LIFE_CHECK_CNT 20 // packet cnt.
-
-// Value domain of pMacEntry->Sst
-typedef enum _Sst {
- SST_NOT_AUTH, // 0: equivalent to IEEE 802.11/1999 state 1
- SST_AUTH, // 1: equivalent to IEEE 802.11/1999 state 2
- SST_ASSOC // 2: equivalent to IEEE 802.11/1999 state 3
-} SST;
-
-// value domain of pMacEntry->AuthState
-typedef enum _AuthState {
- AS_NOT_AUTH,
- AS_AUTH_OPEN, // STA has been authenticated using OPEN SYSTEM
- AS_AUTH_KEY, // STA has been authenticated using SHARED KEY
- AS_AUTHENTICATING // STA is waiting for AUTH seq#3 using SHARED KEY
-} AUTH_STATE;
-
-//for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
-typedef enum _ApWpaState {
- AS_NOTUSE, // 0
- AS_DISCONNECT, // 1
- AS_DISCONNECTED, // 2
- AS_INITIALIZE, // 3
- AS_AUTHENTICATION, // 4
- AS_AUTHENTICATION2, // 5
- AS_INITPMK, // 6
- AS_INITPSK, // 7
- AS_PTKSTART, // 8
- AS_PTKINIT_NEGOTIATING, // 9
- AS_PTKINITDONE, // 10
- AS_UPDATEKEYS, // 11
- AS_INTEGRITY_FAILURE, // 12
- AS_KEYUPDATE, // 13
-} AP_WPA_STATE;
-
-// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
-typedef enum _GTKState {
- REKEY_NEGOTIATING,
- REKEY_ESTABLISHED,
- KEYERROR,
-} GTK_STATE;
-
-// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
-typedef enum _WpaGTKState {
- SETKEYS,
- SETKEYS_DONE,
-} WPA_GTK_STATE;
-// ====================== end of AP mlme.h ============================
-
-
-#endif // MLME_H__
+#include "../rt2870/mlme.h"
diff --git a/drivers/staging/rt3070/netif_block.h b/drivers/staging/rt3070/netif_block.h
deleted file mode 100644
index 6e5151c41095..000000000000
--- a/drivers/staging/rt3070/netif_block.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __NET_IF_BLOCK_H__
-#define __NET_IF_BLOCK_H__
-
-//#include <linux/device.h>
-#include "link_list.h"
-#include "rtmp.h"
-
-#define FREE_NETIF_POOL_SIZE 32
-
-typedef struct _NETIF_ENTRY
-{
- struct _NETIF_ENTRY *pNext;
- PNET_DEV pNetDev;
-} NETIF_ENTRY, *PNETIF_ENTRY;
-
-void initblockQueueTab(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN blockNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
- IN PNET_DEV pNetDev);
-
-VOID releaseNetIf(
- IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry);
-
-VOID StopNetIfQueue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-#endif // __NET_IF_BLOCK_H__
-
diff --git a/drivers/staging/rt3070/oid.h b/drivers/staging/rt3070/oid.h
index f78bf0a5f140..cbf16a8ae615 100644
--- a/drivers/staging/rt3070/oid.h
+++ b/drivers/staging/rt3070/oid.h
@@ -1,1142 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- oid.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef _OID_H_
-#define _OID_H_
-
-//#include <linux/wireless.h>
-
-
-#define TRUE 1
-#define FALSE 0
-//
-// IEEE 802.11 Structures and definitions
-//
-#define MAX_TX_POWER_LEVEL 100 /* mW */
-#define MAX_RSSI_TRIGGER -10 /* dBm */
-#define MIN_RSSI_TRIGGER -200 /* dBm */
-#define MAX_FRAG_THRESHOLD 2346 /* byte count */
-#define MIN_FRAG_THRESHOLD 256 /* byte count */
-#define MAX_RTS_THRESHOLD 2347 /* byte count */
-
-// new types for Media Specific Indications
-// Extension channel offset
-#define EXTCHA_NONE 0
-#define EXTCHA_ABOVE 0x1
-#define EXTCHA_BELOW 0x3
-
-// BW
-#define BAND_WIDTH_20 0
-#define BAND_WIDTH_40 1
-#define BAND_WIDTH_BOTH 2
-#define BAND_WIDTH_10 3 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-// SHORTGI
-#define GAP_INTERVAL_400 1 // only support in HT mode
-#define GAP_INTERVAL_800 0
-#define GAP_INTERVAL_BOTH 2
-
-#define NdisMediaStateConnected 1
-#define NdisMediaStateDisconnected 0
-
-#define NDIS_802_11_LENGTH_SSID 32
-#define NDIS_802_11_LENGTH_RATES 8
-#define NDIS_802_11_LENGTH_RATES_EX 16
-#define MAC_ADDR_LENGTH 6
-#define MAX_NUM_OF_CHS 49 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL terminationc
-#define MAX_NUMBER_OF_EVENT 10 // entry # in EVENT table
-#define MAX_NUMBER_OF_MAC 32 // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
-#define MAX_NUMBER_OF_ACL 64
-#define MAX_LENGTH_OF_SUPPORT_RATES 12 // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
-#define MAX_NUMBER_OF_DLS_ENTRY 4
-
-
-
-#ifndef UNDER_CE
-// OID definition, since NDIS 5.0 didn't define these, we need to define for our own
-//#if _WIN32_WINNT<=0x0500
-
-#define OID_GEN_MACHINE_NAME 0x0001021A
-
-#ifdef RALINK_ATE
-#define RT_QUERY_ATE_TXDONE_COUNT 0x0401
-#endif // RALINK_ATE //
-#define RT_QUERY_SIGNAL_CONTEXT 0x0402
-#define RT_SET_IAPP_PID 0x0404
-#define RT_SET_APD_PID 0x0405
-#define RT_SET_DEL_MAC_ENTRY 0x0406
-
-//
-// IEEE 802.11 OIDs
-//
-#define OID_GET_SET_TOGGLE 0x8000
-
-#define OID_802_11_NETWORK_TYPES_SUPPORTED 0x0103
-#define OID_802_11_NETWORK_TYPE_IN_USE 0x0104
-#define OID_802_11_RSSI_TRIGGER 0x0107
-#define RT_OID_802_11_RSSI 0x0108 //rt2860 only , kathy
-#define RT_OID_802_11_RSSI_1 0x0109 //rt2860 only , kathy
-#define RT_OID_802_11_RSSI_2 0x010A //rt2860 only , kathy
-#define OID_802_11_NUMBER_OF_ANTENNAS 0x010B
-#define OID_802_11_RX_ANTENNA_SELECTED 0x010C
-#define OID_802_11_TX_ANTENNA_SELECTED 0x010D
-#define OID_802_11_SUPPORTED_RATES 0x010E
-#define OID_802_11_ADD_WEP 0x0112
-#define OID_802_11_REMOVE_WEP 0x0113
-#define OID_802_11_DISASSOCIATE 0x0114
-#define OID_802_11_PRIVACY_FILTER 0x0118
-#define OID_802_11_ASSOCIATION_INFORMATION 0x011E
-#define OID_802_11_TEST 0x011F
-#define RT_OID_802_11_COUNTRY_REGION 0x0507
-#define OID_802_11_BSSID_LIST_SCAN 0x0508
-#define OID_802_11_SSID 0x0509
-#define OID_802_11_BSSID 0x050A
-#define RT_OID_802_11_RADIO 0x050B
-#define RT_OID_802_11_PHY_MODE 0x050C
-#define RT_OID_802_11_STA_CONFIG 0x050D
-#define OID_802_11_DESIRED_RATES 0x050E
-#define RT_OID_802_11_PREAMBLE 0x050F
-#define OID_802_11_WEP_STATUS 0x0510
-#define OID_802_11_AUTHENTICATION_MODE 0x0511
-#define OID_802_11_INFRASTRUCTURE_MODE 0x0512
-#define RT_OID_802_11_RESET_COUNTERS 0x0513
-#define OID_802_11_RTS_THRESHOLD 0x0514
-#define OID_802_11_FRAGMENTATION_THRESHOLD 0x0515
-#define OID_802_11_POWER_MODE 0x0516
-#define OID_802_11_TX_POWER_LEVEL 0x0517
-#define RT_OID_802_11_ADD_WPA 0x0518
-#define OID_802_11_REMOVE_KEY 0x0519
-#define OID_802_11_ADD_KEY 0x0520
-#define OID_802_11_CONFIGURATION 0x0521
-#define OID_802_11_TX_PACKET_BURST 0x0522
-#define RT_OID_802_11_QUERY_NOISE_LEVEL 0x0523
-#define RT_OID_802_11_EXTRA_INFO 0x0524
-#ifdef DBG
-#define RT_OID_802_11_HARDWARE_REGISTER 0x0525
-#endif
-#define OID_802_11_ENCRYPTION_STATUS OID_802_11_WEP_STATUS
-#define OID_802_11_DEAUTHENTICATION 0x0526
-#define OID_802_11_DROP_UNENCRYPTED 0x0527
-#define OID_802_11_MIC_FAILURE_REPORT_FRAME 0x0528
-
-// For 802.1x daemin using to require current driver configuration
-#define OID_802_11_RADIUS_QUERY_SETTING 0x0540
-
-#define RT_OID_DEVICE_NAME 0x0607
-#define RT_OID_VERSION_INFO 0x0608
-#define OID_802_11_BSSID_LIST 0x0609
-#define OID_802_3_CURRENT_ADDRESS 0x060A
-#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B
-#define RT_OID_802_11_QUERY_LINK_STATUS 0x060C
-#define OID_802_11_RSSI 0x060D
-#define OID_802_11_STATISTICS 0x060E
-#define OID_GEN_RCV_OK 0x060F
-#define OID_GEN_RCV_NO_BUFFER 0x0610
-#define RT_OID_802_11_QUERY_EEPROM_VERSION 0x0611
-#define RT_OID_802_11_QUERY_FIRMWARE_VERSION 0x0612
-#define RT_OID_802_11_QUERY_LAST_RX_RATE 0x0613
-#define RT_OID_802_11_TX_POWER_LEVEL_1 0x0614
-#define RT_OID_802_11_QUERY_PIDVID 0x0615
-//for WPA_SUPPLICANT_SUPPORT
-#define OID_SET_COUNTERMEASURES 0x0616
-#define OID_802_11_SET_IEEE8021X 0x0617
-#define OID_802_11_SET_IEEE8021X_REQUIRE_KEY 0x0618
-#define OID_802_11_PMKID 0x0620
-#define RT_OID_WPA_SUPPLICANT_SUPPORT 0x0621
-#define RT_OID_WE_VERSION_COMPILED 0x0622
-#define RT_OID_NEW_DRIVER 0x0623
-
-
-//rt2860 , kathy
-#define RT_OID_802_11_SNR_0 0x0630
-#define RT_OID_802_11_SNR_1 0x0631
-#define RT_OID_802_11_QUERY_LAST_TX_RATE 0x0632
-#define RT_OID_802_11_QUERY_HT_PHYMODE 0x0633
-#define RT_OID_802_11_SET_HT_PHYMODE 0x0634
-#define OID_802_11_RELOAD_DEFAULTS 0x0635
-#define RT_OID_802_11_QUERY_APSD_SETTING 0x0636
-#define RT_OID_802_11_SET_APSD_SETTING 0x0637
-#define RT_OID_802_11_QUERY_APSD_PSM 0x0638
-#define RT_OID_802_11_SET_APSD_PSM 0x0639
-#define RT_OID_802_11_QUERY_DLS 0x063A
-#define RT_OID_802_11_SET_DLS 0x063B
-#define RT_OID_802_11_QUERY_DLS_PARAM 0x063C
-#define RT_OID_802_11_SET_DLS_PARAM 0x063D
-#define RT_OID_802_11_QUERY_WMM 0x063E
-#define RT_OID_802_11_SET_WMM 0x063F
-#define RT_OID_802_11_QUERY_IMME_BA_CAP 0x0640
-#define RT_OID_802_11_SET_IMME_BA_CAP 0x0641
-#define RT_OID_802_11_QUERY_BATABLE 0x0642
-#define RT_OID_802_11_ADD_IMME_BA 0x0643
-#define RT_OID_802_11_TEAR_IMME_BA 0x0644
-#define RT_OID_DRIVER_DEVICE_NAME 0x0645
-#define RT_OID_802_11_QUERY_DAT_HT_PHYMODE 0x0646
-#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT 0x0647
-
-// Ralink defined OIDs
-// Dennis Lee move to platform specific
-
-#define RT_OID_802_11_BSSID (OID_GET_SET_TOGGLE | OID_802_11_BSSID)
-#define RT_OID_802_11_SSID (OID_GET_SET_TOGGLE | OID_802_11_SSID)
-#define RT_OID_802_11_INFRASTRUCTURE_MODE (OID_GET_SET_TOGGLE | OID_802_11_INFRASTRUCTURE_MODE)
-#define RT_OID_802_11_ADD_WEP (OID_GET_SET_TOGGLE | OID_802_11_ADD_WEP)
-#define RT_OID_802_11_ADD_KEY (OID_GET_SET_TOGGLE | OID_802_11_ADD_KEY)
-#define RT_OID_802_11_REMOVE_WEP (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_WEP)
-#define RT_OID_802_11_REMOVE_KEY (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_KEY)
-#define RT_OID_802_11_DISASSOCIATE (OID_GET_SET_TOGGLE | OID_802_11_DISASSOCIATE)
-#define RT_OID_802_11_AUTHENTICATION_MODE (OID_GET_SET_TOGGLE | OID_802_11_AUTHENTICATION_MODE)
-#define RT_OID_802_11_PRIVACY_FILTER (OID_GET_SET_TOGGLE | OID_802_11_PRIVACY_FILTER)
-#define RT_OID_802_11_BSSID_LIST_SCAN (OID_GET_SET_TOGGLE | OID_802_11_BSSID_LIST_SCAN)
-#define RT_OID_802_11_WEP_STATUS (OID_GET_SET_TOGGLE | OID_802_11_WEP_STATUS)
-#define RT_OID_802_11_RELOAD_DEFAULTS (OID_GET_SET_TOGGLE | OID_802_11_RELOAD_DEFAULTS)
-#define RT_OID_802_11_NETWORK_TYPE_IN_USE (OID_GET_SET_TOGGLE | OID_802_11_NETWORK_TYPE_IN_USE)
-#define RT_OID_802_11_TX_POWER_LEVEL (OID_GET_SET_TOGGLE | OID_802_11_TX_POWER_LEVEL)
-#define RT_OID_802_11_RSSI_TRIGGER (OID_GET_SET_TOGGLE | OID_802_11_RSSI_TRIGGER)
-#define RT_OID_802_11_FRAGMENTATION_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_FRAGMENTATION_THRESHOLD)
-#define RT_OID_802_11_RTS_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_RTS_THRESHOLD)
-#define RT_OID_802_11_RX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_RX_ANTENNA_SELECTED)
-#define RT_OID_802_11_TX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_TX_ANTENNA_SELECTED)
-#define RT_OID_802_11_SUPPORTED_RATES (OID_GET_SET_TOGGLE | OID_802_11_SUPPORTED_RATES)
-#define RT_OID_802_11_DESIRED_RATES (OID_GET_SET_TOGGLE | OID_802_11_DESIRED_RATES)
-#define RT_OID_802_11_CONFIGURATION (OID_GET_SET_TOGGLE | OID_802_11_CONFIGURATION)
-#define RT_OID_802_11_POWER_MODE (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE)
-
-
-
-typedef enum _NDIS_802_11_STATUS_TYPE
-{
- Ndis802_11StatusType_Authentication,
- Ndis802_11StatusType_MediaStreamMode,
- Ndis802_11StatusType_PMKID_CandidateList,
- Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
-} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
-
-typedef UCHAR NDIS_802_11_MAC_ADDRESS[6];
-
-typedef struct _NDIS_802_11_STATUS_INDICATION
-{
- NDIS_802_11_STATUS_TYPE StatusType;
-} NDIS_802_11_STATUS_INDICATION, *PNDIS_802_11_STATUS_INDICATION;
-
-// mask for authentication/integrity fields
-#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
-
-#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
-#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
-#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
-#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
-
-typedef struct _NDIS_802_11_AUTHENTICATION_REQUEST
-{
- ULONG Length; // Length of structure
- NDIS_802_11_MAC_ADDRESS Bssid;
- ULONG Flags;
-} NDIS_802_11_AUTHENTICATION_REQUEST, *PNDIS_802_11_AUTHENTICATION_REQUEST;
-
-//Added new types for PMKID Candidate lists.
-typedef struct _PMKID_CANDIDATE {
- NDIS_802_11_MAC_ADDRESS BSSID;
- ULONG Flags;
-} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
-
-typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
-{
- ULONG Version; // Version of the structure
- ULONG NumCandidates; // No. of pmkid candidates
- PMKID_CANDIDATE CandidateList[1];
-} NDIS_802_11_PMKID_CANDIDATE_LIST, *PNDIS_802_11_PMKID_CANDIDATE_LIST;
-
-//Flags for PMKID Candidate list structure
-#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
-
-// Added new types for OFDM 5G and 2.4G
-typedef enum _NDIS_802_11_NETWORK_TYPE
-{
- Ndis802_11FH,
- Ndis802_11DS,
- Ndis802_11OFDM5,
- Ndis802_11OFDM5_N,
- Ndis802_11OFDM24,
- Ndis802_11OFDM24_N,
- Ndis802_11Automode,
- Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
-} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
-
-typedef struct _NDIS_802_11_NETWORK_TYPE_LIST
-{
- UINT NumberOfItems; // in list below, at least 1
- NDIS_802_11_NETWORK_TYPE NetworkType [1];
-} NDIS_802_11_NETWORK_TYPE_LIST, *PNDIS_802_11_NETWORK_TYPE_LIST;
-
-typedef enum _NDIS_802_11_POWER_MODE
-{
- Ndis802_11PowerModeCAM,
- Ndis802_11PowerModeMAX_PSP,
- Ndis802_11PowerModeFast_PSP,
- Ndis802_11PowerModeLegacy_PSP,
- Ndis802_11PowerModeMax // not a real mode, defined as an upper bound
-} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
-
-typedef ULONG NDIS_802_11_TX_POWER_LEVEL; // in milliwatts
-
-//
-// Received Signal Strength Indication
-//
-typedef LONG NDIS_802_11_RSSI; // in dBm
-
-typedef struct _NDIS_802_11_CONFIGURATION_FH
-{
- ULONG Length; // Length of structure
- ULONG HopPattern; // As defined by 802.11, MSB set
- ULONG HopSet; // to one if non-802.11
- ULONG DwellTime; // units are Kusec
-} NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
-
-typedef struct _NDIS_802_11_CONFIGURATION
-{
- ULONG Length; // Length of structure
- ULONG BeaconPeriod; // units are Kusec
- ULONG ATIMWindow; // units are Kusec
- ULONG DSConfig; // Frequency, units are kHz
- NDIS_802_11_CONFIGURATION_FH FHConfig;
-} NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
-
-typedef struct _NDIS_802_11_STATISTICS
-{
- ULONG Length; // Length of structure
- LARGE_INTEGER TransmittedFragmentCount;
- LARGE_INTEGER MulticastTransmittedFrameCount;
- LARGE_INTEGER FailedCount;
- LARGE_INTEGER RetryCount;
- LARGE_INTEGER MultipleRetryCount;
- LARGE_INTEGER RTSSuccessCount;
- LARGE_INTEGER RTSFailureCount;
- LARGE_INTEGER ACKFailureCount;
- LARGE_INTEGER FrameDuplicateCount;
- LARGE_INTEGER ReceivedFragmentCount;
- LARGE_INTEGER MulticastReceivedFrameCount;
- LARGE_INTEGER FCSErrorCount;
- LARGE_INTEGER TKIPLocalMICFailures;
- LARGE_INTEGER TKIPRemoteMICErrors;
- LARGE_INTEGER TKIPICVErrors;
- LARGE_INTEGER TKIPCounterMeasuresInvoked;
- LARGE_INTEGER TKIPReplays;
- LARGE_INTEGER CCMPFormatErrors;
- LARGE_INTEGER CCMPReplays;
- LARGE_INTEGER CCMPDecryptErrors;
- LARGE_INTEGER FourWayHandshakeFailures;
-} NDIS_802_11_STATISTICS, *PNDIS_802_11_STATISTICS;
-
-typedef ULONG NDIS_802_11_KEY_INDEX;
-typedef ULONGLONG NDIS_802_11_KEY_RSC;
-
-#define MAX_RADIUS_SRV_NUM 2 // 802.1x failover number
-
-typedef struct PACKED _RADIUS_SRV_INFO {
- UINT32 radius_ip;
- UINT32 radius_port;
- UCHAR radius_key[64];
- UCHAR radius_key_len;
-} RADIUS_SRV_INFO, *PRADIUS_SRV_INFO;
-
-typedef struct PACKED _RADIUS_KEY_INFO
-{
- UCHAR radius_srv_num;
- RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
- UCHAR ieee8021xWEP; // dynamic WEP
- UCHAR key_index;
- UCHAR key_length; // length of key in bytes
- UCHAR key_material[13];
-} RADIUS_KEY_INFO, *PRADIUS_KEY_INFO;
-
-// It's used by 802.1x daemon to require relative configuration
-typedef struct PACKED _RADIUS_CONF
-{
- UINT32 Length; // Length of this structure
- UCHAR mbss_num; // indicate multiple BSS number
- UINT32 own_ip_addr;
- UINT32 retry_interval;
- UINT32 session_timeout_interval;
- UCHAR EAPifname[IFNAMSIZ];
- UCHAR EAPifname_len;
- UCHAR PreAuthifname[IFNAMSIZ];
- UCHAR PreAuthifname_len;
- RADIUS_KEY_INFO RadiusInfo[8/*MAX_MBSSID_NUM*/];
-} RADIUS_CONF, *PRADIUS_CONF;
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-// Key mapping keys require a BSSID
-typedef struct _NDIS_802_11_KEY
-{
- UINT Length; // Length of this structure
- UINT KeyIndex;
- UINT KeyLength; // length of key in bytes
- NDIS_802_11_MAC_ADDRESS BSSID;
- NDIS_802_11_KEY_RSC KeyRSC;
- UCHAR KeyMaterial[1]; // variable length depending on above field
-} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
-#endif // CONFIG_STA_SUPPORT //
-
-typedef struct _NDIS_802_11_REMOVE_KEY
-{
- UINT Length; // Length of this structure
- UINT KeyIndex;
- NDIS_802_11_MAC_ADDRESS BSSID;
-} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
-
-typedef struct _NDIS_802_11_WEP
-{
- UINT Length; // Length of this structure
- UINT KeyIndex; // 0 is the per-client key, 1-N are the
- // global keys
- UINT KeyLength; // length of key in bytes
- UCHAR KeyMaterial[1];// variable length depending on above field
-} NDIS_802_11_WEP, *PNDIS_802_11_WEP;
-
-
-typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
-{
- Ndis802_11IBSS,
- Ndis802_11Infrastructure,
- Ndis802_11AutoUnknown,
- Ndis802_11Monitor,
- Ndis802_11InfrastructureMax // Not a real value, defined as upper bound
-} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
-
-// Add new authentication modes
-typedef enum _NDIS_802_11_AUTHENTICATION_MODE
-{
- Ndis802_11AuthModeOpen,
- Ndis802_11AuthModeShared,
- Ndis802_11AuthModeAutoSwitch,
- Ndis802_11AuthModeWPA,
- Ndis802_11AuthModeWPAPSK,
- Ndis802_11AuthModeWPANone,
- Ndis802_11AuthModeWPA2,
- Ndis802_11AuthModeWPA2PSK,
- Ndis802_11AuthModeWPA1WPA2,
- Ndis802_11AuthModeWPA1PSKWPA2PSK,
- Ndis802_11AuthModeMax // Not a real mode, defined as upper bound
-} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
-
-typedef UCHAR NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; // Set of 8 data rates
-typedef UCHAR NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; // Set of 16 data rates
-
-typedef struct PACKED _NDIS_802_11_SSID
-{
- UINT SsidLength; // length of SSID field below, in bytes;
- // this can be zero.
- UCHAR Ssid[NDIS_802_11_LENGTH_SSID]; // SSID information field
-} NDIS_802_11_SSID, *PNDIS_802_11_SSID;
-
-
-typedef struct PACKED _NDIS_WLAN_BSSID
-{
- ULONG Length; // Length of this structure
- NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
- UCHAR Reserved[2];
- NDIS_802_11_SSID Ssid; // SSID
- ULONG Privacy; // WEP encryption requirement
- NDIS_802_11_RSSI Rssi; // receive signal strength in dBm
- NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
- NDIS_802_11_CONFIGURATION Configuration;
- NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
- NDIS_802_11_RATES SupportedRates;
-} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;
-
-typedef struct PACKED _NDIS_802_11_BSSID_LIST
-{
- UINT NumberOfItems; // in list below, at least 1
- NDIS_WLAN_BSSID Bssid[1];
-} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
-
-// Added Capabilities, IELength and IEs for each BSSID
-typedef struct PACKED _NDIS_WLAN_BSSID_EX
-{
- ULONG Length; // Length of this structure
- NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
- UCHAR Reserved[2];
- NDIS_802_11_SSID Ssid; // SSID
- UINT Privacy; // WEP encryption requirement
- NDIS_802_11_RSSI Rssi; // receive signal
- // strength in dBm
- NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
- NDIS_802_11_CONFIGURATION Configuration;
- NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
- NDIS_802_11_RATES_EX SupportedRates;
- ULONG IELength;
- UCHAR IEs[1];
-} NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
-
-typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
-{
- UINT NumberOfItems; // in list below, at least 1
- NDIS_WLAN_BSSID_EX Bssid[1];
-} NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
-
-typedef struct PACKED _NDIS_802_11_FIXED_IEs
-{
- UCHAR Timestamp[8];
- USHORT BeaconInterval;
- USHORT Capabilities;
-} NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
-
-typedef struct _NDIS_802_11_VARIABLE_IEs
-{
- UCHAR ElementID;
- UCHAR Length; // Number of bytes in data field
- UCHAR data[1];
-} NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
-
-typedef ULONG NDIS_802_11_FRAGMENTATION_THRESHOLD;
-
-typedef ULONG NDIS_802_11_RTS_THRESHOLD;
-
-typedef ULONG NDIS_802_11_ANTENNA;
-
-typedef enum _NDIS_802_11_PRIVACY_FILTER
-{
- Ndis802_11PrivFilterAcceptAll,
- Ndis802_11PrivFilter8021xWEP
-} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
-
-// Added new encryption types
-// Also aliased typedef to new name
-typedef enum _NDIS_802_11_WEP_STATUS
-{
- Ndis802_11WEPEnabled,
- Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
- Ndis802_11WEPDisabled,
- Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
- Ndis802_11WEPKeyAbsent,
- Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
- Ndis802_11WEPNotSupported,
- Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
- Ndis802_11Encryption2Enabled,
- Ndis802_11Encryption2KeyAbsent,
- Ndis802_11Encryption3Enabled,
- Ndis802_11Encryption3KeyAbsent,
- Ndis802_11Encryption4Enabled, // TKIP or AES mix
- Ndis802_11Encryption4KeyAbsent,
-} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
- NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
-
-typedef enum _NDIS_802_11_RELOAD_DEFAULTS
-{
- Ndis802_11ReloadWEPKeys
-} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
-
-#define NDIS_802_11_AI_REQFI_CAPABILITIES 1
-#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
-#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
-
-#define NDIS_802_11_AI_RESFI_CAPABILITIES 1
-#define NDIS_802_11_AI_RESFI_STATUSCODE 2
-#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
-
-typedef struct _NDIS_802_11_AI_REQFI
-{
- USHORT Capabilities;
- USHORT ListenInterval;
- NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
-} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
-
-typedef struct _NDIS_802_11_AI_RESFI
-{
- USHORT Capabilities;
- USHORT StatusCode;
- USHORT AssociationId;
-} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
-
-typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
-{
- ULONG Length;
- USHORT AvailableRequestFixedIEs;
- NDIS_802_11_AI_REQFI RequestFixedIEs;
- ULONG RequestIELength;
- ULONG OffsetRequestIEs;
- USHORT AvailableResponseFixedIEs;
- NDIS_802_11_AI_RESFI ResponseFixedIEs;
- ULONG ResponseIELength;
- ULONG OffsetResponseIEs;
-} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
-
-typedef struct _NDIS_802_11_AUTHENTICATION_EVENT
-{
- NDIS_802_11_STATUS_INDICATION Status;
- NDIS_802_11_AUTHENTICATION_REQUEST Request[1];
-} NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
-
-/*
-typedef struct _NDIS_802_11_TEST
-{
- ULONG Length;
- ULONG Type;
- union
- {
- NDIS_802_11_AUTHENTICATION_EVENT AuthenticationEvent;
- NDIS_802_11_RSSI RssiTrigger;
- };
-} NDIS_802_11_TEST, *PNDIS_802_11_TEST;
- */
-
-// 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE
-typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
-{
- Ndis802_11MediaStreamOff,
- Ndis802_11MediaStreamOn,
-} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
-
-// PMKID Structures
-typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
-
-#ifdef CONFIG_STA_SUPPORT
-typedef struct _BSSID_INFO
-{
- NDIS_802_11_MAC_ADDRESS BSSID;
- NDIS_802_11_PMKID_VALUE PMKID;
-} BSSID_INFO, *PBSSID_INFO;
-
-typedef struct _NDIS_802_11_PMKID
-{
- UINT Length;
- UINT BSSIDInfoCount;
- BSSID_INFO BSSIDInfo[1];
-} NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
-#endif // CONFIG_STA_SUPPORT //
-
-
-typedef struct _NDIS_802_11_AUTHENTICATION_ENCRYPTION
-{
- NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
- NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
-} NDIS_802_11_AUTHENTICATION_ENCRYPTION, *PNDIS_802_11_AUTHENTICATION_ENCRYPTION;
-
-typedef struct _NDIS_802_11_CAPABILITY
-{
- ULONG Length;
- ULONG Version;
- ULONG NoOfPMKIDs;
- ULONG NoOfAuthEncryptPairsSupported;
- NDIS_802_11_AUTHENTICATION_ENCRYPTION AuthenticationEncryptionSupported[1];
-} NDIS_802_11_CAPABILITY, *PNDIS_802_11_CAPABILITY;
-
-//#endif //of WIN 2k
-#endif //UNDER_CE
-
-#if WIRELESS_EXT <= 11
-#ifndef SIOCDEVPRIVATE
-#define SIOCDEVPRIVATE 0x8BE0
-#endif
-#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
-#endif
-
-#ifdef CONFIG_STA_SUPPORT
-#define RT_PRIV_IOCTL_EXT (SIOCIWFIRSTPRIV + 0x01) // Sync. with AP for wsc upnp daemon
-#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
-
-#ifdef DBG
-#define RTPRIV_IOCTL_BBP (SIOCIWFIRSTPRIV + 0x03)
-#define RTPRIV_IOCTL_MAC (SIOCIWFIRSTPRIV + 0x05)
-#define RTPRIV_IOCTL_RF (SIOCIWFIRSTPRIV + 0x13)
-#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
-#endif
-
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-#define RTPRIV_IOCTL_ATE (SIOCIWFIRSTPRIV + 0x08)
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
-#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
-#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
-#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
-#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E) // Sync. with RT61 (for wpa_supplicant)
-#define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
-
-#define RTPRIV_IOCTL_SHOW (SIOCIWFIRSTPRIV + 0x11)
-enum {
- SHOW_CONN_STATUS = 4,
- SHOW_DRVIER_VERION = 5,
- SHOW_BA_INFO = 6,
- SHOW_DESC_INFO = 7,
-#ifdef RT2870
- SHOW_RXBULK_INFO = 8,
- SHOW_TXBULK_INFO = 9,
-#endif // RT2870 //
- RAIO_OFF = 10,
- RAIO_ON = 11,
-#ifdef QOS_DLS_SUPPORT
- SHOW_DLS_ENTRY_INFO = 19,
-#endif // QOS_DLS_SUPPORT //
- SHOW_CFG_VALUE = 20,
-};
-
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-
-#ifdef SNMP_SUPPORT
-//SNMP ieee 802dot11, kathy , 2008_0220
-// dot11res(3)
-#define RT_OID_802_11_MANUFACTUREROUI 0x0700
-#define RT_OID_802_11_MANUFACTURERNAME 0x0701
-#define RT_OID_802_11_RESOURCETYPEIDNAME 0x0702
-
-// dot11smt(1)
-#define RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED 0x0703
-#define RT_OID_802_11_POWERMANAGEMENTMODE 0x0704
-#define OID_802_11_WEPDEFAULTKEYVALUE 0x0705 // read , write
-#define OID_802_11_WEPDEFAULTKEYID 0x0706
-#define RT_OID_802_11_WEPKEYMAPPINGLENGTH 0x0707
-#define OID_802_11_SHORTRETRYLIMIT 0x0708
-#define OID_802_11_LONGRETRYLIMIT 0x0709
-#define RT_OID_802_11_PRODUCTID 0x0710
-#define RT_OID_802_11_MANUFACTUREID 0x0711
-
-// //dot11Phy(4)
-#define OID_802_11_CURRENTCHANNEL 0x0712
-
-//dot11mac
-#define RT_OID_802_11_MAC_ADDRESS 0x0713
-#endif // SNMP_SUPPORT //
-
-#define OID_802_11_BUILD_CHANNEL_EX 0x0714
-#define OID_802_11_GET_CH_LIST 0x0715
-#define OID_802_11_GET_COUNTRY_CODE 0x0716
-#define OID_802_11_GET_CHANNEL_GEOGRAPHY 0x0717
-
-//#define RT_OID_802_11_STATISTICS (OID_GET_SET_TOGGLE | OID_802_11_STATISTICS)
-
-#ifdef CONFIG_STA_SUPPORT
-#define RT_OID_WSC_SET_PASSPHRASE 0x0740 // passphrase for wpa(2)-psk
-#define RT_OID_WSC_DRIVER_AUTO_CONNECT 0x0741
-#define RT_OID_WSC_QUERY_DEFAULT_PROFILE 0x0742
-#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX 0x0743
-#define RT_OID_WSC_SET_ACTION 0x0744
-#define RT_OID_WSC_SET_SSID 0x0745
-#define RT_OID_WSC_SET_PIN_CODE 0x0746
-#define RT_OID_WSC_SET_MODE 0x0747 // PIN or PBC
-#define RT_OID_WSC_SET_CONF_MODE 0x0748 // Enrollee or Registrar
-#define RT_OID_WSC_SET_PROFILE 0x0749
-#endif // CONFIG_STA_SUPPORT //
-#define RT_OID_802_11_WSC_QUERY_PROFILE 0x0750
-// for consistency with RT61
-#define RT_OID_WSC_QUERY_STATUS 0x0751
-#define RT_OID_WSC_PIN_CODE 0x0752
-#define RT_OID_WSC_UUID 0x0753
-#define RT_OID_WSC_SET_SELECTED_REGISTRAR 0x0754
-#define RT_OID_WSC_EAPMSG 0x0755
-#define RT_OID_WSC_MANUFACTURER 0x0756
-#define RT_OID_WSC_MODEL_NAME 0x0757
-#define RT_OID_WSC_MODEL_NO 0x0758
-#define RT_OID_WSC_SERIAL_NO 0x0759
-#define RT_OID_WSC_MAC_ADDRESS 0x0760
-
-#ifdef LLTD_SUPPORT
-// for consistency with RT61
-#define RT_OID_GET_PHY_MODE 0x761
-#endif // LLTD_SUPPORT //
-
-#ifdef NINTENDO_AP
-//#define RT_OID_NINTENDO 0x0D010770
-#define RT_OID_802_11_NINTENDO_GET_TABLE 0x0771 //((RT_OID_NINTENDO + 0x01) & 0xffff)
-#define RT_OID_802_11_NINTENDO_SET_TABLE 0x0772 //((RT_OID_NINTENDO + 0x02) & 0xffff)
-#define RT_OID_802_11_NINTENDO_CAPABLE 0x0773 //((RT_OID_NINTENDO + 0x03) & 0xffff)
-#endif // NINTENDO_AP //
-
-//Add Paul Chen for Accton
-//#define RT_OID_TX_POWER_LEVEL 0xFF020010
-//#define RT_OID_SET_TX_POWER_LEVEL (OID_GET_SET_TOGGLE | RT_OID_TX_POWER_LEVEL)
-
-// New for MeetingHouse Api support
-#define OID_MH_802_1X_SUPPORTED 0xFFEDC100
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
-typedef union _HTTRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT MODE:2; // Use definition MODE_xxx.
-// USHORT rsv:3;
- USHORT TxBF:1;
- USHORT rsv:2;
- USHORT STBC:2; //SPACE
- USHORT ShortGI:1;
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT MCS:7; // MCS
- } field;
-#else
- struct {
- USHORT MCS:7; // MCS
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT ShortGI:1;
- USHORT STBC:2; //SPACE
-// USHORT rsv:3;
- USHORT rsv:2;
- USHORT TxBF:1;
- USHORT MODE:2; // Use definition MODE_xxx.
- } field;
-#endif
- USHORT word;
- } HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
-
-typedef enum _RT_802_11_PREAMBLE {
- Rt802_11PreambleLong,
- Rt802_11PreambleShort,
- Rt802_11PreambleAuto
-} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
-
-// Only for STA, need to sync with AP
-// 2005-03-08 match current RaConfig.
-typedef enum _RT_802_11_PHY_MODE {
- PHY_11BG_MIXED = 0,
- PHY_11B,
- PHY_11A,
- PHY_11ABG_MIXED,
- PHY_11G,
-#ifdef DOT11_N_SUPPORT
- PHY_11ABGN_MIXED, // both band 5
- PHY_11N_2_4G, // 11n-only with 2.4G band 6
- PHY_11GN_MIXED, // 2.4G band 7
- PHY_11AN_MIXED, // 5G band 8
- PHY_11BGN_MIXED, // if check 802.11b. 9
- PHY_11AGN_MIXED, // if check 802.11b. 10
- PHY_11N_5G, // 11n-only with 5G band 11
-#endif // DOT11_N_SUPPORT //
-} RT_802_11_PHY_MODE;
-
-// put all proprietery for-query objects here to reduce # of Query_OID
-typedef struct _RT_802_11_LINK_STATUS {
- ULONG CurrTxRate; // in units of 0.5Mbps
- ULONG ChannelQuality; // 0..100 %
- ULONG TxByteCount; // both ok and fail
- ULONG RxByteCount; // both ok and fail
- ULONG CentralChannel; // 40MHz central channel number
-} RT_802_11_LINK_STATUS, *PRT_802_11_LINK_STATUS;
-
-typedef struct _RT_802_11_EVENT_LOG {
- LARGE_INTEGER SystemTime; // timestammp via NdisGetCurrentSystemTime()
- UCHAR Addr[MAC_ADDR_LENGTH];
- USHORT Event; // EVENT_xxx
-} RT_802_11_EVENT_LOG, *PRT_802_11_EVENT_LOG;
-
-typedef struct _RT_802_11_EVENT_TABLE {
- ULONG Num;
- ULONG Rsv; // to align Log[] at LARGE_INEGER boundary
- RT_802_11_EVENT_LOG Log[MAX_NUMBER_OF_EVENT];
-} RT_802_11_EVENT_TABLE, PRT_802_11_EVENT_TABLE;
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
-typedef union _MACHTTRANSMIT_SETTING {
- struct {
- USHORT MCS:7; // MCS
- USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
- USHORT ShortGI:1;
- USHORT STBC:2; //SPACE
- USHORT rsv:3;
- USHORT MODE:2; // Use definition MODE_xxx.
- } field;
- USHORT word;
- } MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
-
-typedef struct _RT_802_11_MAC_ENTRY {
- UCHAR Addr[MAC_ADDR_LENGTH];
- UCHAR Aid;
- UCHAR Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
- UCHAR MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
- CHAR AvgRssi0;
- CHAR AvgRssi1;
- CHAR AvgRssi2;
- UINT32 ConnectedTime;
- MACHTTRANSMIT_SETTING TxRate;
-} RT_802_11_MAC_ENTRY, *PRT_802_11_MAC_ENTRY;
-
-typedef struct _RT_802_11_MAC_TABLE {
- ULONG Num;
- RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
-} RT_802_11_MAC_TABLE, *PRT_802_11_MAC_TABLE;
-
-// structure for query/set hardware register - MAC, BBP, RF register
-typedef struct _RT_802_11_HARDWARE_REGISTER {
- ULONG HardwareType; // 0:MAC, 1:BBP, 2:RF register, 3:EEPROM
- ULONG Offset; // Q/S register offset addr
- ULONG Data; // R/W data buffer
-} RT_802_11_HARDWARE_REGISTER, *PRT_802_11_HARDWARE_REGISTER;
-
-// structure to tune BBP R17 "RX AGC VGC init"
-//typedef struct _RT_802_11_RX_AGC_VGC_TUNING {
-// UCHAR FalseCcaLowerThreshold; // 0-255, def 10
-// UCHAR FalseCcaUpperThreshold; // 0-255, def 100
-// UCHAR VgcDelta; // R17 +-= VgcDelta whenever flase CCA over UpprThreshold
-// // or lower than LowerThresholdupper threshold
-// UCHAR VgcUpperBound; // max value of R17
-//} RT_802_11_RX_AGC_VGC_TUNING, *PRT_802_11_RX_AGC_VGC_TUNING;
-
-typedef struct _RT_802_11_AP_CONFIG {
- ULONG EnableTxBurst; // 0-disable, 1-enable
- ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
- ULONG IsolateInterStaTraffic; // 0-disable, 1-enable isolation
- ULONG HideSsid; // 0-disable, 1-enable hiding
- ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
- ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time
- ULONG Rsv1; // must be 0
- ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
-} RT_802_11_AP_CONFIG, *PRT_802_11_AP_CONFIG;
-
-// structure to query/set STA_CONFIG
-typedef struct _RT_802_11_STA_CONFIG {
- ULONG EnableTxBurst; // 0-disable, 1-enable
- ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
- ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
- ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time when applicable
- ULONG AdhocMode; // 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only
- ULONG HwRadioStatus; // 0-OFF, 1-ON, default is 1, Read-Only
- ULONG Rsv1; // must be 0
- ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
-} RT_802_11_STA_CONFIG, *PRT_802_11_STA_CONFIG;
-
-//
-// For OID Query or Set about BA structure
-//
-typedef struct _OID_BACAP_STRUC {
- UCHAR RxBAWinLimit;
- UCHAR TxBAWinLimit;
- UCHAR Policy; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
- UCHAR MpduDensity; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
- UCHAR AmsduEnable; //Enable AMSDU transmisstion
- UCHAR AmsduSize; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UCHAR MMPSmode; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- BOOLEAN AutoBA; // Auto BA will automatically
-} OID_BACAP_STRUC, *POID_BACAP_STRUC;
-
-typedef struct _RT_802_11_ACL_ENTRY {
- UCHAR Addr[MAC_ADDR_LENGTH];
- USHORT Rsv;
-} RT_802_11_ACL_ENTRY, *PRT_802_11_ACL_ENTRY;
-
-typedef struct PACKED _RT_802_11_ACL {
- ULONG Policy; // 0-disable, 1-positive list, 2-negative list
- ULONG Num;
- RT_802_11_ACL_ENTRY Entry[MAX_NUMBER_OF_ACL];
-} RT_802_11_ACL, *PRT_802_11_ACL;
-
-typedef struct _RT_802_11_WDS {
- ULONG Num;
- NDIS_802_11_MAC_ADDRESS Entry[24/*MAX_NUM_OF_WDS_LINK*/];
- ULONG KeyLength;
- UCHAR KeyMaterial[32];
-} RT_802_11_WDS, *PRT_802_11_WDS;
-
-typedef struct _RT_802_11_TX_RATES_ {
- UCHAR SupRateLen;
- UCHAR SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
- UCHAR ExtRateLen;
- UCHAR ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
-} RT_802_11_TX_RATES, *PRT_802_11_TX_RATES;
-
-
-// Definition of extra information code
-#define GENERAL_LINK_UP 0x0 // Link is Up
-#define GENERAL_LINK_DOWN 0x1 // Link is Down
-#define HW_RADIO_OFF 0x2 // Hardware radio off
-#define SW_RADIO_OFF 0x3 // Software radio off
-#define AUTH_FAIL 0x4 // Open authentication fail
-#define AUTH_FAIL_KEYS 0x5 // Shared authentication fail
-#define ASSOC_FAIL 0x6 // Association failed
-#define EAP_MIC_FAILURE 0x7 // Deauthencation because MIC failure
-#define EAP_4WAY_TIMEOUT 0x8 // Deauthencation on 4-way handshake timeout
-#define EAP_GROUP_KEY_TIMEOUT 0x9 // Deauthencation on group key handshake timeout
-#define EAP_SUCCESS 0xa // EAP succeed
-#define DETECT_RADAR_SIGNAL 0xb // Radar signal occur in current channel
-#define EXTRA_INFO_MAX 0xb // Indicate Last OID
-
-#define EXTRA_INFO_CLEAR 0xffffffff
-
-// This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use.
-typedef struct {
- RT_802_11_PHY_MODE PhyMode; //
- UCHAR TransmitNo;
- UCHAR HtMode; //HTMODE_GF or HTMODE_MM
- UCHAR ExtOffset; //extension channel above or below
- UCHAR MCS;
- UCHAR BW;
- UCHAR STBC;
- UCHAR SHORTGI;
- UCHAR rsv;
-} OID_SET_HT_PHYMODE, *POID_SET_HT_PHYMODE;
-
-#ifdef NINTENDO_AP
-#define NINTENDO_MAX_ENTRY 16
-#define NINTENDO_SSID_NAME_LN 8
-#define NINTENDO_SSID_NAME "NWCUSBAP"
-#define NINTENDO_PROBE_REQ_FLAG_MASK 0x03
-#define NINTENDO_PROBE_REQ_ON 0x01
-#define NINTENDO_PROBE_REQ_SIGNAL 0x02
-#define NINTENDO_PROBE_RSP_ON 0x01
-#define NINTENDO_SSID_NICKNAME_LN 20
-
-#define NINTENDO_WEPKEY_LN 13
-
-typedef struct _NINTENDO_SSID
-{
- UCHAR NINTENDOFixChar[NINTENDO_SSID_NAME_LN];
- UCHAR zero1;
- UCHAR registe;
- UCHAR ID;
- UCHAR zero2;
- UCHAR NICKname[NINTENDO_SSID_NICKNAME_LN];
-} RT_NINTENDO_SSID, *PRT_NINTENDO_SSID;
-
-typedef struct _NINTENDO_ENTRY
-{
- UCHAR NICKname[NINTENDO_SSID_NICKNAME_LN];
- UCHAR DS_Addr[ETH_LENGTH_OF_ADDRESS];
- UCHAR registe;
- UCHAR UserSpaceAck;
-} RT_NINTENDO_ENTRY, *PRT_NINTENDO_ENTRY;
-
-//RTPRIV_IOCTL_NINTENDO_GET_TABLE
-//RTPRIV_IOCTL_NINTENDO_SET_TABLE
-typedef struct _NINTENDO_TABLE
-{
- UINT number;
- RT_NINTENDO_ENTRY entry[NINTENDO_MAX_ENTRY];
-} RT_NINTENDO_TABLE, *PRT_NINTENDO_TABLE;
-
-//RTPRIV_IOCTL_NINTENDO_SEED_WEPKEY
-typedef struct _NINTENDO_SEED_WEPKEY
-{
- UCHAR seed[NINTENDO_SSID_NICKNAME_LN];
- UCHAR wepkey[16];//use 13 for 104 bits wep key
-} RT_NINTENDO_SEED_WEPKEY, *PRT_NINTENDO_SEED_WEPKEY;
-#endif // NINTENDO_AP //
-
-#ifdef LLTD_SUPPORT
-typedef struct _RT_LLTD_ASSOICATION_ENTRY {
- UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
- unsigned short MOR; // maximum operational rate
- UCHAR phyMode;
-} RT_LLTD_ASSOICATION_ENTRY, *PRT_LLTD_ASSOICATION_ENTRY;
-
-typedef struct _RT_LLTD_ASSOICATION_TABLE {
- unsigned int Num;
- RT_LLTD_ASSOICATION_ENTRY Entry[MAX_NUMBER_OF_MAC];
-} RT_LLTD_ASSOICATION_TABLE, *PRT_LLTD_ASSOICATION_TABLE;
-#endif // LLTD_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-//rt2860, kathy 2007-0118
-// structure for DLS
-typedef struct _RT_802_11_DLS_UI {
- USHORT TimeOut; // unit: second , set by UI
- USHORT CountDownTimer; // unit: second , used by driver only
- NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
- UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
- BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
-} RT_802_11_DLS_UI, *PRT_802_11_DLS_UI;
-
-typedef struct _RT_802_11_DLS_INFO {
- RT_802_11_DLS_UI Entry[MAX_NUMBER_OF_DLS_ENTRY];
- UCHAR num;
-} RT_802_11_DLS_INFO, *PRT_802_11_DLS_INFO;
-
-typedef enum _RT_802_11_DLS_MODE {
- DLS_NONE,
- DLS_WAIT_KEY,
- DLS_FINISH
-} RT_802_11_DLS_MODE;
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-#define RT_ASSOC_EVENT_FLAG 0x0101
-#define RT_DISASSOC_EVENT_FLAG 0x0102
-#define RT_REQIE_EVENT_FLAG 0x0103
-#define RT_RESPIE_EVENT_FLAG 0x0104
-#define RT_ASSOCINFO_EVENT_FLAG 0x0105
-#define RT_PMKIDCAND_FLAG 0x0106
-#define RT_INTERFACE_DOWN 0x0107
-#define RT_INTERFACE_UP 0x0108
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-
-#define MAX_CUSTOM_LEN 128
-
-#ifdef CONFIG_STA_SUPPORT
-typedef enum _RT_802_11_D_CLIENT_MODE
-{
- Rt802_11_D_None,
- Rt802_11_D_Flexible,
- Rt802_11_D_Strict,
-} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
-#endif // CONFIG_STA_SUPPORT //
-
-typedef struct _RT_CHANNEL_LIST_INFO
-{
- UCHAR ChannelList[MAX_NUM_OF_CHS]; // list all supported channels for site survey
- UCHAR ChannelListNum; // number of channel in ChannelList[]
-} RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO;
-
-// WSC configured credential
-typedef struct _WSC_CREDENTIAL
-{
- NDIS_802_11_SSID SSID; // mandatory
- USHORT AuthType; // mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk
- USHORT EncrType; // mandatory, 1: none, 2: wep, 4: tkip, 8: aes
- UCHAR Key[64]; // mandatory, Maximum 64 byte
- USHORT KeyLength;
- UCHAR MacAddr[6]; // mandatory, AP MAC address
- UCHAR KeyIndex; // optional, default is 1
- UCHAR Rsvd[3]; // Make alignment
-} WSC_CREDENTIAL, *PWSC_CREDENTIAL;
-
-// WSC configured profiles
-typedef struct _WSC_PROFILE
-{
- UINT ProfileCnt;
- WSC_CREDENTIAL Profile[8]; // Support up to 8 profiles
-} WSC_PROFILE, *PWSC_PROFILE;
-
-
-
-#endif // _OID_H_
-
+#include "../rt2870/oid.h"
diff --git a/drivers/staging/rt3070/rt2870.h b/drivers/staging/rt3070/rt2870.h
index d32a2bf1d040..16d8717b9dbd 100644
--- a/drivers/staging/rt3070/rt2870.h
+++ b/drivers/staging/rt3070/rt2870.h
@@ -1,756 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __RT2870_H__
-#define __RT2870_H__
-
-//usb header files
-#include <linux/usb.h>
-
-/* rtmp_def.h */
-//
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#define BULKAGGRE_ZISE 100
-#define RT28XX_DRVDATA_SET(_a) usb_set_intfdata(_a, pAd);
-#define RT28XX_PUT_DEVICE usb_put_dev
-#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)
-#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, GFP_ATOMIC)
-#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_buffer_alloc(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
-#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_buffer_free(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)
-#else
-#define BULKAGGRE_ZISE 60
-#define RT28XX_DRVDATA_SET(_a)
-#define RT28XX_PUT_DEVICE(dev_p)
-#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso)
-#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb)
-#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) kmalloc(BufSize, GFP_ATOMIC)
-#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) kfree(pTransferBuf)
-#endif
-
-#define RXBULKAGGRE_ZISE 12
-#define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
-#define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
-#define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
-#define MAX_MLME_HANDLER_MEMORY 20
-#define BUFFER_SIZE 2400 //2048
-#define TX_RING 0xa
-#define PRIO_RING 0xc
-
-
-// Flags for Bulkflags control for bulk out data
-//
-#define fRTUSB_BULK_OUT_DATA_NULL 0x00000001
-#define fRTUSB_BULK_OUT_RTS 0x00000002
-#define fRTUSB_BULK_OUT_MLME 0x00000004
-
-#define fRTUSB_BULK_OUT_DATA_NORMAL 0x00010000
-#define fRTUSB_BULK_OUT_DATA_NORMAL_2 0x00020000
-#define fRTUSB_BULK_OUT_DATA_NORMAL_3 0x00040000
-#define fRTUSB_BULK_OUT_DATA_NORMAL_4 0x00080000
-#define fRTUSB_BULK_OUT_DATA_NORMAL_5 0x00100000
-
-#define fRTUSB_BULK_OUT_PSPOLL 0x00000020
-#define fRTUSB_BULK_OUT_DATA_FRAG 0x00000040
-#define fRTUSB_BULK_OUT_DATA_FRAG_2 0x00000080
-#define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000100
-#define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000200
-
-#ifdef RALINK_ATE
-#define fRTUSB_BULK_OUT_DATA_ATE 0x00100000
-#endif // RALINK_ATE //
-
-#define RT2870_USB_DEVICES \
-{ \
- {USB_DEVICE(0x148F,0x2770)}, /* Ralink */ \
- {USB_DEVICE(0x148F,0x2870)}, /* Ralink */ \
- {USB_DEVICE(0x148F,0x3070)}, /* Ralink 3070 */ \
- {USB_DEVICE(0x148F,0x3071)}, /* Ralink 3071 */ \
- {USB_DEVICE(0x148F,0x3072)}, /* Ralink 3072 */ \
- {USB_DEVICE(0x0B05,0x1731)}, /* Asus */ \
- {USB_DEVICE(0x0B05,0x1732)}, /* Asus */ \
- {USB_DEVICE(0x0B05,0x1742)}, /* Asus */ \
- {USB_DEVICE(0x0DF6,0x0017)}, /* Sitecom */ \
- {USB_DEVICE(0x0DF6,0x002B)}, /* Sitecom */ \
- {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */ \
- {USB_DEVICE(0x0DF6,0x003E)}, /* Sitecom 3070 */ \
- {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */ \
- {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom 2770 */ \
- {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \
- {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \
- {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \
- {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */ \
- {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */ \
- {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */ \
- {USB_DEVICE(0x2001,0x3C09)}, /* D-Link */ \
- {USB_DEVICE(0x2001,0x3C0A)}, /* D-Link 3072*/ \
- {USB_DEVICE(0x14B2,0x3C07)}, /* AL */ \
- {USB_DEVICE(0x14B2,0x3C12)}, /* AL 3070 */ \
- {USB_DEVICE(0x050D,0x8053)}, /* Belkin */ \
- {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */ \
- {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */ \
- {USB_DEVICE(0x07AA,0x002F)}, /* Corega */ \
- {USB_DEVICE(0x07AA,0x003C)}, /* Corega */ \
- {USB_DEVICE(0x07AA,0x003F)}, /* Corega */ \
- {USB_DEVICE(0x18C5,0x0012)}, /* Corega 3070 */ \
- {USB_DEVICE(0x1044,0x800B)}, /* Gigabyte */ \
- {USB_DEVICE(0x1044,0x800D)}, /* Gigabyte GN-WB32L 3070 */ \
- {USB_DEVICE(0x15A9,0x0006)}, /* Sparklan */ \
- {USB_DEVICE(0x083A,0xB522)}, /* SMC */ \
- {USB_DEVICE(0x083A,0xA618)}, /* SMC */ \
- {USB_DEVICE(0x083A,0x8522)}, /* Arcadyan */ \
- {USB_DEVICE(0x083A,0x7512)}, /* Arcadyan 2770 */ \
- {USB_DEVICE(0x083A,0x7522)}, /* Arcadyan */ \
- {USB_DEVICE(0x083A,0x7511)}, /* Arcadyan 3070 */ \
- {USB_DEVICE(0x0CDE,0x0022)}, /* ZCOM */ \
- {USB_DEVICE(0x0586,0x3416)}, /* Zyxel */ \
- {USB_DEVICE(0x0CDE,0x0025)}, /* Zyxel */ \
- {USB_DEVICE(0x1740,0x9701)}, /* EnGenius */ \
- {USB_DEVICE(0x1740,0x9702)}, /* EnGenius */ \
- {USB_DEVICE(0x1740,0x9703)}, /* EnGenius 3070 */ \
- {USB_DEVICE(0x0471,0x200f)}, /* Philips */ \
- {USB_DEVICE(0x14B2,0x3C25)}, /* Draytek */ \
- {USB_DEVICE(0x13D3,0x3247)}, /* AzureWave */ \
- {USB_DEVICE(0x13D3,0x3273)}, /* AzureWave 3070*/ \
- {USB_DEVICE(0x083A,0x6618)}, /* Accton */ \
- {USB_DEVICE(0x15c5,0x0008)}, /* Amit */ \
- {USB_DEVICE(0x0E66,0x0001)}, /* Hawking */ \
- {USB_DEVICE(0x0E66,0x0003)}, /* Hawking */ \
- {USB_DEVICE(0x129B,0x1828)}, /* Siemens */ \
- {USB_DEVICE(0x157E,0x300E)}, /* U-Media */ \
- {USB_DEVICE(0x050d,0x805c)}, \
- {USB_DEVICE(0x1482,0x3C09)}, /* Abocom*/ \
- {USB_DEVICE(0x14B2,0x3C09)}, /* Alpha */ \
- {USB_DEVICE(0x04E8,0x2018)}, /* samsung */ \
- {USB_DEVICE(0x07B8,0x3070)}, /* AboCom 3070 */ \
- {USB_DEVICE(0x07B8,0x3071)}, /* AboCom 3071 */ \
- {USB_DEVICE(0x07B8,0x3072)}, /* Abocom 3072 */ \
- {USB_DEVICE(0x7392,0x7711)}, /* Edimax 3070 */ \
- {USB_DEVICE(0x5A57,0x0280)}, /* Zinwell */ \
- {USB_DEVICE(0x5A57,0x0282)}, /* Zinwell */ \
- {USB_DEVICE(0x1A32,0x0304)}, /* Quanta 3070 */ \
- {USB_DEVICE(0x0789,0x0162)}, /* Logitec 2870 */ \
- {USB_DEVICE(0x0789,0x0163)}, /* Logitec 2870 */ \
- {USB_DEVICE(0x0789,0x0164)}, /* Logitec 2870 */ \
- {USB_DEVICE(0x1EDA,0x2310)}, /* AirTies 3070 */ \
- { }/* Terminating entry */ \
-}
-
-#define FREE_HTTX_RING(_p, _b, _t) \
-{ \
- if ((_t)->ENextBulkOutPosition == (_t)->CurWritePosition) \
- { \
- (_t)->bRingEmpty = TRUE; \
- } \
- /*NdisInterlockedDecrement(&(_p)->TxCount); */\
-}
-
-//
-// RXINFO appends at the end of each rx packet.
-//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _RXINFO_STRUC {
- UINT32 PlcpSignal:12;
- UINT32 LastAMSDU:1;
- UINT32 CipherAlg:1;
- UINT32 PlcpRssil:1;
- UINT32 Decrypted:1;
- UINT32 AMPDU:1; // To be moved
- UINT32 L2PAD:1;
- UINT32 RSSI:1;
- UINT32 HTC:1;
- UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header.
- UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
- UINT32 Crc:1; // 1: CRC error
- UINT32 MyBss:1; // 1: this frame belongs to the same BSSID
- UINT32 Bcast:1; // 1: this is a broadcast frame
- UINT32 Mcast:1; // 1: this is a multicast frame
- UINT32 U2M:1; // 1: this RX frame is unicast to me
- UINT32 FRAG:1;
- UINT32 NULLDATA:1;
- UINT32 DATA:1;
- UINT32 BA:1;
-} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#else
-typedef struct PACKED _RXINFO_STRUC {
- UINT32 BA:1;
- UINT32 DATA:1;
- UINT32 NULLDATA:1;
- UINT32 FRAG:1;
- UINT32 U2M:1; // 1: this RX frame is unicast to me
- UINT32 Mcast:1; // 1: this is a multicast frame
- UINT32 Bcast:1; // 1: this is a broadcast frame
- UINT32 MyBss:1; // 1: this frame belongs to the same BSSID
- UINT32 Crc:1; // 1: CRC error
- UINT32 CipherErr:2; // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
- UINT32 AMSDU:1; // rx with 802.3 header, not 802.11 header.
- UINT32 HTC:1;
- UINT32 RSSI:1;
- UINT32 L2PAD:1;
- UINT32 AMPDU:1; // To be moved
- UINT32 Decrypted:1;
- UINT32 PlcpRssil:1;
- UINT32 CipherAlg:1;
- UINT32 LastAMSDU:1;
- UINT32 PlcpSignal:12;
-} RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#endif
-
-
-//
-// TXINFO
-//
-#ifdef RT_BIG_ENDIAN
-typedef struct _TXINFO_STRUC {
- // Word 0
- UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
- UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid
- UINT32 rsv2:2; // Software use.
- UINT32 SwUseLastRound:1; // Software use.
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 rsv:8;
- UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame.
-} TXINFO_STRUC, *PTXINFO_STRUC;
-#else
-typedef struct _TXINFO_STRUC {
- // Word 0
- UINT32 USBDMATxPktLen:16; //used ONLY in USB bulk Aggregation, Total byte counts of all sub-frame.
- UINT32 rsv:8;
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 SwUseLastRound:1; // Software use.
- UINT32 rsv2:2; // Software use.
- UINT32 USBDMANextVLD:1; //used ONLY in USB bulk Aggregation, NextValid
- UINT32 USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
-} TXINFO_STRUC, *PTXINFO_STRUC;
-#endif
-
-#define TXINFO_SIZE 4
-#define RXINFO_SIZE 4
-#define TXPADDING_SIZE 11
-
-//
-// Management ring buffer format
-//
-typedef struct _MGMT_STRUC {
- BOOLEAN Valid;
- PUCHAR pBuffer;
- ULONG Length;
-} MGMT_STRUC, *PMGMT_STRUC;
-
-
-/* ----------------- EEPROM Related MACRO ----------------- */
-#ifdef RT30xx
-#define RT28xx_EEPROM_READ16(pAd, offset, var) \
- do { \
- RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2); \
- if(!pAd->bUseEfuse) \
- var = le2cpu16(var); \
- }while(0)
-
-#define RT28xx_EEPROM_WRITE16(pAd, offset, var) \
- do{ \
- USHORT _tmpVar=var; \
- if(!pAd->bUseEfuse) \
- _tmpVar = cpu2le16(var); \
- RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2); \
- }while(0)
-#endif // RT30xx //
-#ifndef RT30xx
-#define RT28xx_EEPROM_READ16(pAd, offset, var) \
- do { \
- RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2); \
- var = le2cpu16(var); \
- }while(0)
-
-#define RT28xx_EEPROM_WRITE16(pAd, offset, var) \
- do{ \
- USHORT _tmpVar=var; \
- _tmpVar = cpu2le16(var); \
- RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2); \
- }while(0)
-#endif // RT30xx //
-
-/* ----------------- TASK/THREAD Related MACRO ----------------- */
-#define RT28XX_TASK_THREAD_INIT(pAd, Status) \
- Status = CreateThreads(net_dev);
-
-
-/* ----------------- Frimware Related MACRO ----------------- */
-#define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
- RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
-
-/* ----------------- TX Related MACRO ----------------- */
-#define RT28XX_START_DEQUEUE(pAd, QueIdx, irqFlags) \
- { \
- RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
- if (pAd->DeQueueRunning[QueIdx]) \
- { \
- RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
- printk("DeQueueRunning[%d]= TRUE!\n", QueIdx); \
- continue; \
- } \
- else \
- { \
- pAd->DeQueueRunning[QueIdx] = TRUE; \
- RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
- } \
- }
-#define RT28XX_STOP_DEQUEUE(pAd, QueIdx, irqFlags) \
- do{ \
- RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
- pAd->DeQueueRunning[QueIdx] = FALSE; \
- RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
- }while(0)
-
-
-#define RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
- (RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS)
-
-#define RT28XX_RELEASE_DESC_RESOURCE(pAd, QueIdx) \
- do{}while(0)
-
-#define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType) \
- ((_TxFrameType == TX_RALINK_FRAME) && (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx)))
-
-
-
-#define fRTMP_ADAPTER_NEED_STOP_TX \
- (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
- fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_BULKOUT_RESET | \
- fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
-
-
-#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
- RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
-
-#define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) \
- RtmpUSB_WriteSingleTxResource(pAd, pTxBlk,bIsLast, pFreeNumber)
-
-#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
- RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
-
-#define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) \
- RtmpUSB_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber)
-
-#define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) \
- RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)
-
-#define HAL_LastTxIdx(pAd, QueIdx,TxIdx) \
- /*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx)*/
-
-#define HAL_KickOutTx(pAd, pTxBlk, QueIdx) \
- RtmpUSBDataKickOut(pAd, pTxBlk, QueIdx)
-
-
-#define HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen) \
- RtmpUSBMgmtKickOut(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)
-
-#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen) \
- RtmpUSBNullFrameKickOut(_pAd, _QueIdx, _pNullFrame, _frameLen)
-
-#define RTMP_PKT_TAIL_PADDING 11 // 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding)
-
-extern UCHAR EpToQueue[6];
-
-
-#ifdef RT2870
-#define GET_TXRING_FREENO(_pAd, _QueIdx) (_QueIdx) //(_pAd->TxRing[_QueIdx].TxSwFreeIdx)
-#define GET_MGMTRING_FREENO(_pAd) (_pAd->MgmtRing.TxSwFreeIdx)
-#endif // RT2870 //
-
-
-/* ----------------- RX Related MACRO ----------------- */
-//#define RT28XX_RX_ERROR_CHECK RTMPCheckRxWI
-
-#define RT28XX_RV_ALL_BUF_END(bBulkReceive) \
- /* We return STATUS_MORE_PROCESSING_REQUIRED so that the completion */ \
- /* routine (IofCompleteRequest) will stop working on the irp. */ \
- if (bBulkReceive == TRUE) RTUSBBulkReceive(pAd);
-
-
-/* ----------------- ASIC Related MACRO ----------------- */
-// reset MAC of a station entry to 0xFFFFFFFFFFFF
-#define RT28XX_STA_ENTRY_MAC_RESET(pAd, Wcid) \
- { RT_SET_ASIC_WCID SetAsicWcid; \
- SetAsicWcid.WCID = Wcid; \
- SetAsicWcid.SetTid = 0xffffffff; \
- SetAsicWcid.DeleteTid = 0xffffffff; \
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID, \
- &SetAsicWcid, sizeof(RT_SET_ASIC_WCID)); }
-
-// add this entry into ASIC RX WCID search table
-#define RT28XX_STA_ENTRY_ADD(pAd, pEntry) \
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_CLIENT_MAC_ENTRY, \
- pEntry, sizeof(MAC_TABLE_ENTRY));
-
-// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
-// Set MAC register value according operation mode
-#define RT28XX_UPDATE_PROTECT(pAd) \
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_UPDATE_PROTECT, NULL, 0);
-// end johnli
-
-// remove Pair-wise key material from ASIC
-// yet implement
-#define RT28XX_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)
-
-// add Client security information into ASIC WCID table and IVEIV table
-#define RT28XX_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry) \
- { RT28XX_STA_ENTRY_MAC_RESET(pAd, pEntry->Aid); \
- if (pEntry->Aid >= 1) { \
- RT_SET_ASIC_WCID_ATTRI SetAsicWcidAttri; \
- SetAsicWcidAttri.WCID = pEntry->Aid; \
- if ((pEntry->AuthMode <= Ndis802_11AuthModeAutoSwitch) && \
- (pEntry->WepStatus == Ndis802_11Encryption1Enabled)) \
- { \
- SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg; \
- } \
- else if (pEntry->AuthMode == Ndis802_11AuthModeWPANone) \
- { \
- SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg; \
- } \
- else SetAsicWcidAttri.Cipher = 0; \
- DBGPRINT(RT_DEBUG_TRACE, ("aid cipher = %ld\n",SetAsicWcidAttri.Cipher)); \
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID_CIPHER, \
- &SetAsicWcidAttri, sizeof(RT_SET_ASIC_WCID_ATTRI)); } }
-
-// Insert the BA bitmap to ASIC for the Wcid entry
-#define RT28XX_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \
- do{ \
- RT_SET_ASIC_WCID SetAsicWcid; \
- SetAsicWcid.WCID = (_Aid); \
- SetAsicWcid.SetTid = (0x10000<<(_TID)); \
- SetAsicWcid.DeleteTid = 0xffffffff; \
- RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(RT_SET_ASIC_WCID)); \
- }while(0)
-
-// Remove the BA bitmap from ASIC for the Wcid entry
-#define RT28XX_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \
- do{ \
- RT_SET_ASIC_WCID SetAsicWcid; \
- SetAsicWcid.WCID = (_Wcid); \
- SetAsicWcid.SetTid = (0xffffffff); \
- SetAsicWcid.DeleteTid = (0x10000<<(_TID) ); \
- RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(RT_SET_ASIC_WCID)); \
- }while(0)
-
-
-/* ----------------- PCI/USB Related MACRO ----------------- */
-#define RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p) \
- ((POS_COOKIE)handle)->pUsb_Dev = dev_p;
-
-// no use
-#define RT28XX_UNMAP()
-#define RT28XX_IRQ_REQUEST(net_dev)
-#define RT28XX_IRQ_RELEASE(net_dev)
-#define RT28XX_IRQ_INIT(pAd)
-#define RT28XX_IRQ_ENABLE(pAd)
-
-
-/* ----------------- MLME Related MACRO ----------------- */
-#define RT28XX_MLME_HANDLER(pAd) RTUSBMlmeUp(pAd)
-
-#define RT28XX_MLME_PRE_SANITY_CHECK(pAd) \
- { if ((pAd->CommonCfg.bHardwareRadio == TRUE) && \
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && \
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) { \
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_CHECK_GPIO, NULL, 0); } }
-
-#define RT28XX_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
- { RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_QKERIODIC_EXECUT, NULL, 0); \
- RTUSBMlmeUp(pAd); }
-
-#define RT28XX_MLME_RESET_STATE_MACHINE(pAd) \
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL); \
- RTUSBMlmeUp(pAd);
-
-#define RT28XX_HANDLE_COUNTER_MEASURE(_pAd, _pEntry) \
- { RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_802_11_COUNTER_MEASURE, _pEntry, sizeof(MAC_TABLE_ENTRY)); \
- RTUSBMlmeUp(_pAd); \
- }
-
-
-/* ----------------- Power Save Related MACRO ----------------- */
-#define RT28XX_PS_POLL_ENQUEUE(pAd) \
- { RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL); \
- RTUSBKickBulkOut(pAd); }
-
-#define RT28xx_CHIP_NAME "RT2870"
-#define USB_CYC_CFG 0x02a4
-#define NT_SUCCESS(status) (((status) > 0) ? (1):(0))
-#define InterlockedIncrement atomic_inc
-#define NdisInterlockedIncrement atomic_inc
-#define InterlockedDecrement atomic_dec
-#define NdisInterlockedDecrement atomic_dec
-#define InterlockedExchange atomic_set
-//#define NdisMSendComplete RTMP_SendComplete
-#define NdisMCancelTimer RTMPCancelTimer
-#define NdisAllocMemory(_ptr, _size, _flag) \
- do{_ptr = kmalloc((_size),(_flag));}while(0)
-#define NdisFreeMemory(a, b, c) kfree((a))
-#define NdisMSleep RTMPusecDelay /* unit: microsecond */
-
-
-#define USBD_TRANSFER_DIRECTION_OUT 0
-#define USBD_TRANSFER_DIRECTION_IN 0
-#define USBD_SHORT_TRANSFER_OK 0
-#define PURB purbb_t
-
-#define RTUSB_FREE_URB(pUrb) usb_free_urb(pUrb)
-
-//#undef MlmeAllocateMemory
-//#undef MlmeFreeMemory
-
-typedef struct usb_device * PUSB_DEV;
-
-/* MACRO for linux usb */
-typedef struct urb *purbb_t;
-typedef struct usb_ctrlrequest devctrlrequest;
-#define PIRP PVOID
-#define PMDL PVOID
-#define NDIS_OID UINT
-#ifndef USB_ST_NOERROR
-#define USB_ST_NOERROR 0
-#endif
-
-// vendor-specific control operations
-#define CONTROL_TIMEOUT_JIFFIES ( (100 * HZ) / 1000)
-#define UNLINK_TIMEOUT_MS 3
-
-/* unlink urb */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
-#define RTUSB_UNLINK_URB(pUrb) usb_kill_urb(pUrb)
-#else
-#define RTUSB_UNLINK_URB(pUrb) usb_unlink_urb(pUrb)
-#endif
-
-// Prototypes of completion funuc.
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define RTUSBBulkOutDataPacketComplete(purb, pt_regs) RTUSBBulkOutDataPacketComplete(purb)
-#define RTUSBBulkOutMLMEPacketComplete(pUrb, pt_regs) RTUSBBulkOutMLMEPacketComplete(pUrb)
-#define RTUSBBulkOutNullFrameComplete(pUrb, pt_regs) RTUSBBulkOutNullFrameComplete(pUrb)
-#define RTUSBBulkOutRTSFrameComplete(pUrb, pt_regs) RTUSBBulkOutRTSFrameComplete(pUrb)
-#define RTUSBBulkOutPsPollComplete(pUrb, pt_regs) RTUSBBulkOutPsPollComplete(pUrb)
-#define RTUSBBulkRxComplete(pUrb, pt_regs) RTUSBBulkRxComplete(pUrb)
-#endif
-
-
-VOID RTUSBBulkOutDataPacketComplete(purbb_t purb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutRTSFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-
-
-#define RTUSBMlmeUp(pAd) \
-{ \
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
- if(pObj->MLMEThr_pid>0) \
- up(&(pAd->mlme_semaphore)); \
-}
-
-#define RTUSBCMDUp(pAd) \
-{ \
- POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
- if(pObj->RTUSBCmdThr_pid>0) \
- up(&(pAd->RTUSBCmd_semaphore)); \
-}
-
-
-static inline NDIS_STATUS RTMPAllocateMemory(
- OUT PVOID *ptr,
- IN size_t size)
-{
- *ptr = kmalloc(size, GFP_ATOMIC);
- if(*ptr)
- return NDIS_STATUS_SUCCESS;
- else
- return NDIS_STATUS_RESOURCES;
-}
-
-/* rtmp.h */
-#define BEACON_RING_SIZE 2
-#define DEVICE_VENDOR_REQUEST_OUT 0x40
-#define DEVICE_VENDOR_REQUEST_IN 0xc0
-#define INTERFACE_VENDOR_REQUEST_OUT 0x41
-#define INTERFACE_VENDOR_REQUEST_IN 0xc1
-#define MGMTPIPEIDX 0 // EP6 is highest priority
-
-#define BULKOUT_MGMT_RESET_FLAG 0x80
-
-#define RTUSB_SET_BULK_FLAG(_M, _F) ((_M)->BulkFlags |= (_F))
-#define RTUSB_CLEAR_BULK_FLAG(_M, _F) ((_M)->BulkFlags &= ~(_F))
-#define RTUSB_TEST_BULK_FLAG(_M, _F) (((_M)->BulkFlags & (_F)) != 0)
-
-#define EnqueueCmd(cmdq, cmdqelmt) \
-{ \
- if (cmdq->size == 0) \
- cmdq->head = cmdqelmt; \
- else \
- cmdq->tail->next = cmdqelmt; \
- cmdq->tail = cmdqelmt; \
- cmdqelmt->next = NULL; \
- cmdq->size++; \
-}
-
-typedef struct _RT_SET_ASIC_WCID {
- ULONG WCID; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
- ULONG SetTid; // time-based: seconds, packet-based: kilo-packets
- ULONG DeleteTid; // time-based: seconds, packet-based: kilo-packets
-} RT_SET_ASIC_WCID,*PRT_SET_ASIC_WCID;
-
-typedef struct _RT_SET_ASIC_WCID_ATTRI {
- ULONG WCID; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
- ULONG Cipher; // ASIC Cipher definition
- UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
-} RT_SET_ASIC_WCID_ATTRI,*PRT_SET_ASIC_WCID_ATTRI;
-
-typedef struct _MLME_MEMORY_STRUCT {
- PVOID AllocVa; //Pointer to the base virtual address of the allocated memory
- struct _MLME_MEMORY_STRUCT *Next; //Pointer to the next virtual address of the allocated memory
-} MLME_MEMORY_STRUCT, *PMLME_MEMORY_STRUCT;
-
-typedef struct _MLME_MEMORY_HANDLER {
- BOOLEAN MemRunning; //The flag of the Mlme memory handler's status
- UINT MemoryCount; //Total nonpaged system-space memory not size
- UINT InUseCount; //Nonpaged system-space memory in used counts
- UINT UnUseCount; //Nonpaged system-space memory available counts
- INT PendingCount; //Nonpaged system-space memory for free counts
- PMLME_MEMORY_STRUCT pInUseHead; //Pointer to the first nonpaed memory not used
- PMLME_MEMORY_STRUCT pInUseTail; //Pointer to the last nonpaged memory not used
- PMLME_MEMORY_STRUCT pUnUseHead; //Pointer to the first nonpaged memory in used
- PMLME_MEMORY_STRUCT pUnUseTail; //Pointer to the last nonpaged memory in used
- PULONG MemFreePending[MAX_MLME_HANDLER_MEMORY]; //an array to keep pending free-memory's pointer (32bits)
-} MLME_MEMORY_HANDLER, *PMLME_MEMORY_HANDLER;
-
-typedef struct _CmdQElmt {
- UINT command;
- PVOID buffer;
- ULONG bufferlength;
- BOOLEAN CmdFromNdis;
- BOOLEAN SetOperation;
- struct _CmdQElmt *next;
-} CmdQElmt, *PCmdQElmt;
-
-typedef struct _CmdQ {
- UINT size;
- CmdQElmt *head;
- CmdQElmt *tail;
- UINT32 CmdQState;
-}CmdQ, *PCmdQ;
-
-//
-// For WPA SUPPLICANT: WIRELESS EXT support wireless events: v14 or newer
-//
-#if WIRELESS_EXT >= 14
-//#define WPA_SUPPLICANT_SUPPORT 1
-#endif
-
-/* oid.h */
-// Cipher suite type for mixed mode group cipher, P802.11i-2004
-typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
- Cipher_Type_NONE,
- Cipher_Type_WEP40,
- Cipher_Type_TKIP,
- Cipher_Type_RSVD,
- Cipher_Type_CCMP,
- Cipher_Type_WEP104
-} RT_802_11_CIPHER_SUITE_TYPE, *PRT_802_11_CIPHER_SUITE_TYPE;
-
-//CMDTHREAD_MULTI_READ_MAC
-//CMDTHREAD_MULTI_WRITE_MAC
-//CMDTHREAD_VENDOR_EEPROM_READ
-//CMDTHREAD_VENDOR_EEPROM_WRITE
-typedef struct _CMDHandler_TLV {
- USHORT Offset;
- USHORT Length;
- UCHAR DataFirst;
-} CMDHandler_TLV, *PCMDHandler_TLV;
-
-// New for MeetingHouse Api support
-#define CMDTHREAD_VENDOR_RESET 0x0D730101 // cmd
-#define CMDTHREAD_VENDOR_UNPLUG 0x0D730102 // cmd
-#define CMDTHREAD_VENDOR_SWITCH_FUNCTION 0x0D730103 // cmd
-#define CMDTHREAD_MULTI_WRITE_MAC 0x0D730107 // cmd
-#define CMDTHREAD_MULTI_READ_MAC 0x0D730108 // cmd
-#define CMDTHREAD_VENDOR_EEPROM_WRITE 0x0D73010A // cmd
-#define CMDTHREAD_VENDOR_EEPROM_READ 0x0D73010B // cmd
-#define CMDTHREAD_VENDOR_ENTER_TESTMODE 0x0D73010C // cmd
-#define CMDTHREAD_VENDOR_EXIT_TESTMODE 0x0D73010D // cmd
-#define CMDTHREAD_VENDOR_WRITE_BBP 0x0D730119 // cmd
-#define CMDTHREAD_VENDOR_READ_BBP 0x0D730118 // cmd
-#define CMDTHREAD_VENDOR_WRITE_RF 0x0D73011A // cmd
-#define CMDTHREAD_VENDOR_FLIP_IQ 0x0D73011D // cmd
-#define CMDTHREAD_RESET_BULK_OUT 0x0D730210 // cmd
-#define CMDTHREAD_RESET_BULK_IN 0x0D730211 // cmd
-#define CMDTHREAD_SET_PSM_BIT_SAVE 0x0D730212 // cmd
-#define CMDTHREAD_SET_RADIO 0x0D730214 // cmd
-#define CMDTHREAD_UPDATE_TX_RATE 0x0D730216 // cmd
-#define CMDTHREAD_802_11_ADD_KEY_WEP 0x0D730218 // cmd
-#define CMDTHREAD_RESET_FROM_ERROR 0x0D73021A // cmd
-#define CMDTHREAD_LINK_DOWN 0x0D73021B // cmd
-#define CMDTHREAD_RESET_FROM_NDIS 0x0D73021C // cmd
-#define CMDTHREAD_CHECK_GPIO 0x0D730215 // cmd
-#define CMDTHREAD_FORCE_WAKE_UP 0x0D730222 // cmd
-#define CMDTHREAD_SET_BW 0x0D730225 // cmd
-#define CMDTHREAD_SET_ASIC_WCID 0x0D730226 // cmd
-#define CMDTHREAD_SET_ASIC_WCID_CIPHER 0x0D730227 // cmd
-#define CMDTHREAD_QKERIODIC_EXECUT 0x0D73023D // cmd
-#define RT_CMD_SET_KEY_TABLE 0x0D730228 // cmd
-#define RT_CMD_SET_RX_WCID_TABLE 0x0D730229 // cmd
-#define CMDTHREAD_SET_CLIENT_MAC_ENTRY 0x0D73023E // cmd
-#define CMDTHREAD_802_11_QUERY_HARDWARE_REGISTER 0x0D710105 // cmd
-#define CMDTHREAD_802_11_SET_PHY_MODE 0x0D79010C // cmd
-#define CMDTHREAD_802_11_SET_STA_CONFIG 0x0D790111 // cmd
-#define CMDTHREAD_802_11_SET_PREAMBLE 0x0D790101 // cmd
-#define CMDTHREAD_802_11_COUNTER_MEASURE 0x0D790102 // cmd
-// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
-#define CMDTHREAD_UPDATE_PROTECT 0x0D790103 // cmd
-// end johnli
-
-#define WPA1AKMBIT 0x01
-#define WPA2AKMBIT 0x02
-#define WPA1PSKAKMBIT 0x04
-#define WPA2PSKAKMBIT 0x08
-#define TKIPBIT 0x01
-#define CCMPBIT 0x02
-
-
-#define RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx) \
- RT28xxUsbStaAsicForceWakeup(pAd, bFromTx);
-
-#define RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
- RT28xxUsbStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
-
-#define RT28XX_MLME_RADIO_ON(pAd) \
- RT28xxUsbMlmeRadioOn(pAd);
-
-#define RT28XX_MLME_RADIO_OFF(pAd) \
- RT28xxUsbMlmeRadioOFF(pAd);
-
-#endif //__RT2870_H__
+#include "../rt2870/rt2870.h"
diff --git a/drivers/staging/rt3070/rt28xx.h b/drivers/staging/rt3070/rt28xx.h
index b637c4ee6096..c47ddc8bd9e9 100644
--- a/drivers/staging/rt3070/rt28xx.h
+++ b/drivers/staging/rt3070/rt28xx.h
@@ -1,2725 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rt28xx.h
-
- Abstract:
- RT28xx ASIC related definition & structures
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee Jan-3-2006 created for RT2860c
-*/
-
-#ifndef __RT28XX_H__
-#define __RT28XX_H__
-
-
-//
-// PCI registers - base address 0x0000
-//
-#define PCI_CFG 0x0000
-#define PCI_EECTRL 0x0004
-#define PCI_MCUCTRL 0x0008
-
-#define OPT_14 0x114
-
-typedef int NTSTATUS;
-#define RETRY_LIMIT 10
-#define STATUS_SUCCESS 0x00
-#define STATUS_UNSUCCESSFUL 0x01
-
-//
-// SCH/DMA registers - base address 0x0200
-//
-// INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit
-//
-#define DMA_CSR0 0x200
-#define INT_SOURCE_CSR 0x200
-#ifdef RT_BIG_ENDIAN
-typedef union _INT_SOURCE_CSR_STRUC {
- struct {
- UINT32 :14;
- UINT32 TxCoherent:1;
- UINT32 RxCoherent:1;
- UINT32 GPTimer:1;
- UINT32 AutoWakeup:1;//bit14
- UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
- UINT32 PreTBTT:1;
- UINT32 TBTTInt:1;
- UINT32 RxTxCoherent:1;
- UINT32 MCUCommandINT:1;
- UINT32 MgmtDmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 RxDone:1;
- UINT32 TxDelayINT:1; //delayed interrupt, not interrupt until several int or time limit hit
- UINT32 RxDelayINT:1; //dealyed interrupt
- } field;
- UINT32 word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-#else
-typedef union _INT_SOURCE_CSR_STRUC {
- struct {
- UINT32 RxDelayINT:1;
- UINT32 TxDelayINT:1;
- UINT32 RxDone:1;
- UINT32 Ac0DmaDone:1;//4
- UINT32 Ac1DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 HccaDmaDone:1; // bit7
- UINT32 MgmtDmaDone:1;
- UINT32 MCUCommandINT:1;//bit 9
- UINT32 RxTxCoherent:1;
- UINT32 TBTTInt:1;
- UINT32 PreTBTT:1;
- UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
- UINT32 AutoWakeup:1;//bit14
- UINT32 GPTimer:1;
- UINT32 RxCoherent:1;//bit16
- UINT32 TxCoherent:1;
- UINT32 :14;
- } field;
- UINT32 word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-#endif
-
-//
-// INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF
-//
-#define INT_MASK_CSR 0x204
-#ifdef RT_BIG_ENDIAN
-typedef union _INT_MASK_CSR_STRUC {
- struct {
- UINT32 TxCoherent:1;
- UINT32 RxCoherent:1;
- UINT32 :20;
- UINT32 MCUCommandINT:1;
- UINT32 MgmtDmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 RxDone:1;
- UINT32 TxDelay:1;
- UINT32 RXDelay_INT_MSK:1;
- } field;
- UINT32 word;
-}INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-#else
-typedef union _INT_MASK_CSR_STRUC {
- struct {
- UINT32 RXDelay_INT_MSK:1;
- UINT32 TxDelay:1;
- UINT32 RxDone:1;
- UINT32 Ac0DmaDone:1;
- UINT32 Ac1DmaDone:1;
- UINT32 Ac2DmaDone:1;
- UINT32 Ac3DmaDone:1;
- UINT32 HccaDmaDone:1;
- UINT32 MgmtDmaDone:1;
- UINT32 MCUCommandINT:1;
- UINT32 :20;
- UINT32 RxCoherent:1;
- UINT32 TxCoherent:1;
- } field;
- UINT32 word;
-} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-#endif
-#define WPDMA_GLO_CFG 0x208
-#ifdef RT_BIG_ENDIAN
-typedef union _WPDMA_GLO_CFG_STRUC {
- struct {
- UINT32 HDR_SEG_LEN:16;
- UINT32 RXHdrScater:8;
- UINT32 BigEndian:1;
- UINT32 EnTXWriteBackDDONE:1;
- UINT32 WPDMABurstSIZE:2;
- UINT32 RxDMABusy:1;
- UINT32 EnableRxDMA:1;
- UINT32 TxDMABusy:1;
- UINT32 EnableTxDMA:1;
- } field;
- UINT32 word;
-}WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-#else
-typedef union _WPDMA_GLO_CFG_STRUC {
- struct {
- UINT32 EnableTxDMA:1;
- UINT32 TxDMABusy:1;
- UINT32 EnableRxDMA:1;
- UINT32 RxDMABusy:1;
- UINT32 WPDMABurstSIZE:2;
- UINT32 EnTXWriteBackDDONE:1;
- UINT32 BigEndian:1;
- UINT32 RXHdrScater:8;
- UINT32 HDR_SEG_LEN:16;
- } field;
- UINT32 word;
-} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-#endif
-#define WPDMA_RST_IDX 0x20c
-#ifdef RT_BIG_ENDIAN
-typedef union _WPDMA_RST_IDX_STRUC {
- struct {
- UINT32 :15;
- UINT32 RST_DRX_IDX0:1;
- UINT32 rsv:10;
- UINT32 RST_DTX_IDX5:1;
- UINT32 RST_DTX_IDX4:1;
- UINT32 RST_DTX_IDX3:1;
- UINT32 RST_DTX_IDX2:1;
- UINT32 RST_DTX_IDX1:1;
- UINT32 RST_DTX_IDX0:1;
- } field;
- UINT32 word;
-}WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#else
-typedef union _WPDMA_RST_IDX_STRUC {
- struct {
- UINT32 RST_DTX_IDX0:1;
- UINT32 RST_DTX_IDX1:1;
- UINT32 RST_DTX_IDX2:1;
- UINT32 RST_DTX_IDX3:1;
- UINT32 RST_DTX_IDX4:1;
- UINT32 RST_DTX_IDX5:1;
- UINT32 rsv:10;
- UINT32 RST_DRX_IDX0:1;
- UINT32 :15;
- } field;
- UINT32 word;
-} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#endif
-#define DELAY_INT_CFG 0x0210
-#ifdef RT_BIG_ENDIAN
-typedef union _DELAY_INT_CFG_STRUC {
- struct {
- UINT32 TXDLY_INT_EN:1;
- UINT32 TXMAX_PINT:7;
- UINT32 TXMAX_PTIME:8;
- UINT32 RXDLY_INT_EN:1;
- UINT32 RXMAX_PINT:7;
- UINT32 RXMAX_PTIME:8;
- } field;
- UINT32 word;
-}DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#else
-typedef union _DELAY_INT_CFG_STRUC {
- struct {
- UINT32 RXMAX_PTIME:8;
- UINT32 RXMAX_PINT:7;
- UINT32 RXDLY_INT_EN:1;
- UINT32 TXMAX_PTIME:8;
- UINT32 TXMAX_PINT:7;
- UINT32 TXDLY_INT_EN:1;
- } field;
- UINT32 word;
-} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#endif
-#define WMM_AIFSN_CFG 0x0214
-#ifdef RT_BIG_ENDIAN
-typedef union _AIFSN_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Aifsn3:4; // for AC_VO
- UINT32 Aifsn2:4; // for AC_VI
- UINT32 Aifsn1:4; // for AC_BK
- UINT32 Aifsn0:4; // for AC_BE
- } field;
- UINT32 word;
-} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-#else
-typedef union _AIFSN_CSR_STRUC {
- struct {
- UINT32 Aifsn0:4; // for AC_BE
- UINT32 Aifsn1:4; // for AC_BK
- UINT32 Aifsn2:4; // for AC_VI
- UINT32 Aifsn3:4; // for AC_VO
- UINT32 Rsv:16;
- } field;
- UINT32 word;
-} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-#endif
-//
-// CWMIN_CSR: CWmin for each EDCA AC
-//
-#define WMM_CWMIN_CFG 0x0218
-#ifdef RT_BIG_ENDIAN
-typedef union _CWMIN_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Cwmin3:4; // for AC_VO
- UINT32 Cwmin2:4; // for AC_VI
- UINT32 Cwmin1:4; // for AC_BK
- UINT32 Cwmin0:4; // for AC_BE
- } field;
- UINT32 word;
-} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-#else
-typedef union _CWMIN_CSR_STRUC {
- struct {
- UINT32 Cwmin0:4; // for AC_BE
- UINT32 Cwmin1:4; // for AC_BK
- UINT32 Cwmin2:4; // for AC_VI
- UINT32 Cwmin3:4; // for AC_VO
- UINT32 Rsv:16;
- } field;
- UINT32 word;
-} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-#endif
-
-//
-// CWMAX_CSR: CWmin for each EDCA AC
-//
-#define WMM_CWMAX_CFG 0x021c
-#ifdef RT_BIG_ENDIAN
-typedef union _CWMAX_CSR_STRUC {
- struct {
- UINT32 Rsv:16;
- UINT32 Cwmax3:4; // for AC_VO
- UINT32 Cwmax2:4; // for AC_VI
- UINT32 Cwmax1:4; // for AC_BK
- UINT32 Cwmax0:4; // for AC_BE
- } field;
- UINT32 word;
-} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-#else
-typedef union _CWMAX_CSR_STRUC {
- struct {
- UINT32 Cwmax0:4; // for AC_BE
- UINT32 Cwmax1:4; // for AC_BK
- UINT32 Cwmax2:4; // for AC_VI
- UINT32 Cwmax3:4; // for AC_VO
- UINT32 Rsv:16;
- } field;
- UINT32 word;
-} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-#endif
-
-
-//
-// AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
-//
-#define WMM_TXOP0_CFG 0x0220
-#ifdef RT_BIG_ENDIAN
-typedef union _AC_TXOP_CSR0_STRUC {
- struct {
- USHORT Ac1Txop; // for AC_BE, in unit of 32us
- USHORT Ac0Txop; // for AC_BK, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-#else
-typedef union _AC_TXOP_CSR0_STRUC {
- struct {
- USHORT Ac0Txop; // for AC_BK, in unit of 32us
- USHORT Ac1Txop; // for AC_BE, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-#endif
-
-//
-// AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
-//
-#define WMM_TXOP1_CFG 0x0224
-#ifdef RT_BIG_ENDIAN
-typedef union _AC_TXOP_CSR1_STRUC {
- struct {
- USHORT Ac3Txop; // for AC_VO, in unit of 32us
- USHORT Ac2Txop; // for AC_VI, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-#else
-typedef union _AC_TXOP_CSR1_STRUC {
- struct {
- USHORT Ac2Txop; // for AC_VI, in unit of 32us
- USHORT Ac3Txop; // for AC_VO, in unit of 32us
- } field;
- UINT32 word;
-} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-#endif
-#define RINGREG_DIFF 0x10
-#define GPIO_CTRL_CFG 0x0228 //MAC_CSR13
-#define MCU_CMD_CFG 0x022c
-#define TX_BASE_PTR0 0x0230 //AC_BK base address
-#define TX_MAX_CNT0 0x0234
-#define TX_CTX_IDX0 0x0238
-#define TX_DTX_IDX0 0x023c
-#define TX_BASE_PTR1 0x0240 //AC_BE base address
-#define TX_MAX_CNT1 0x0244
-#define TX_CTX_IDX1 0x0248
-#define TX_DTX_IDX1 0x024c
-#define TX_BASE_PTR2 0x0250 //AC_VI base address
-#define TX_MAX_CNT2 0x0254
-#define TX_CTX_IDX2 0x0258
-#define TX_DTX_IDX2 0x025c
-#define TX_BASE_PTR3 0x0260 //AC_VO base address
-#define TX_MAX_CNT3 0x0264
-#define TX_CTX_IDX3 0x0268
-#define TX_DTX_IDX3 0x026c
-#define TX_BASE_PTR4 0x0270 //HCCA base address
-#define TX_MAX_CNT4 0x0274
-#define TX_CTX_IDX4 0x0278
-#define TX_DTX_IDX4 0x027c
-#define TX_BASE_PTR5 0x0280 //MGMT base address
-#define TX_MAX_CNT5 0x0284
-#define TX_CTX_IDX5 0x0288
-#define TX_DTX_IDX5 0x028c
-#define TX_MGMTMAX_CNT TX_MAX_CNT5
-#define TX_MGMTCTX_IDX TX_CTX_IDX5
-#define TX_MGMTDTX_IDX TX_DTX_IDX5
-#define RX_BASE_PTR 0x0290 //RX base address
-#define RX_MAX_CNT 0x0294
-#define RX_CRX_IDX 0x0298
-#define RX_DRX_IDX 0x029c
-#define USB_DMA_CFG 0x02a0
-#ifdef RT_BIG_ENDIAN
-typedef union _USB_DMA_CFG_STRUC {
- struct {
- UINT32 TxBusy:1; //USB DMA TX FSM busy . debug only
- UINT32 RxBusy:1; //USB DMA RX FSM busy . debug only
- UINT32 EpoutValid:6; //OUT endpoint data valid. debug only
- UINT32 TxBulkEn:1; //Enable USB DMA Tx
- UINT32 RxBulkEn:1; //Enable USB DMA Rx
- UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
- UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
- UINT32 TxClear:1; //Clear USB DMA TX path
- UINT32 rsv:2;
- UINT32 phyclear:1; //phy watch dog enable. write 1
- UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 1024 bytes
- UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
- } field;
- UINT32 word;
-} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-#else
-typedef union _USB_DMA_CFG_STRUC {
- struct {
- UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
- UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 256 bytes
- UINT32 phyclear:1; //phy watch dog enable. write 1
- UINT32 rsv:2;
- UINT32 TxClear:1; //Clear USB DMA TX path
- UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
- UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
- UINT32 RxBulkEn:1; //Enable USB DMA Rx
- UINT32 TxBulkEn:1; //Enable USB DMA Tx
- UINT32 EpoutValid:6; //OUT endpoint data valid
- UINT32 RxBusy:1; //USB DMA RX FSM busy
- UINT32 TxBusy:1; //USB DMA TX FSM busy
- } field;
- UINT32 word;
-} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-#endif
-
-//
-// 3 PBF registers
-//
-//
-// Most are for debug. Driver doesn't touch PBF register.
-#define PBF_SYS_CTRL 0x0400
-#define PBF_CFG 0x0408
-#define PBF_MAX_PCNT 0x040C
-#define PBF_CTRL 0x0410
-#define PBF_INT_STA 0x0414
-#define PBF_INT_ENA 0x0418
-#define TXRXQ_PCNT 0x0438
-#define PBF_DBG 0x043c
-#define PBF_CAP_CTRL 0x0440
-
-
-// eFuse registers
-#define EFUSE_CTRL 0x0580
-#define EFUSE_DATA0 0x0590
-#define EFUSE_DATA1 0x0594
-#define EFUSE_DATA2 0x0598
-#define EFUSE_DATA3 0x059c
-#define EFUSE_USAGE_MAP_START 0x2d0
-#define EFUSE_USAGE_MAP_END 0x2fc
-#define EFUSE_TAG 0x2fe
-#define EFUSE_USAGE_MAP_SIZE 45
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EFUSE_CTRL_STRUC {
- struct {
- UINT32 SEL_EFUSE:1;
- UINT32 EFSROM_KICK:1;
- UINT32 RESERVED:4;
- UINT32 EFSROM_AIN:10;
- UINT32 EFSROM_LDO_ON_TIME:2;
- UINT32 EFSROM_LDO_OFF_TIME:6;
- UINT32 EFSROM_MODE:2;
- UINT32 EFSROM_AOUT:6;
- } field;
- UINT32 word;
-} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
-#else
-typedef union _EFUSE_CTRL_STRUC {
- struct {
- UINT32 EFSROM_AOUT:6;
- UINT32 EFSROM_MODE:2;
- UINT32 EFSROM_LDO_OFF_TIME:6;
- UINT32 EFSROM_LDO_ON_TIME:2;
- UINT32 EFSROM_AIN:10;
- UINT32 RESERVED:4;
- UINT32 EFSROM_KICK:1;
- UINT32 SEL_EFUSE:1;
- } field;
- UINT32 word;
-} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
-#endif // RT_BIG_ENDIAN //
-
-#define LDO_CFG0 0x05d4
-#define GPIO_SWITCH 0x05dc
-
-//
-// 4 MAC registers
-//
-//
-// 4.1 MAC SYSTEM configuration registers (offset:0x1000)
-//
-#define MAC_CSR0 0x1000
-#ifdef RT_BIG_ENDIAN
-typedef union _ASIC_VER_ID_STRUC {
- struct {
- USHORT ASICVer; // version : 2860
- USHORT ASICRev; // reversion : 0
- } field;
- UINT32 word;
-} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#else
-typedef union _ASIC_VER_ID_STRUC {
- struct {
- USHORT ASICRev; // reversion : 0
- USHORT ASICVer; // version : 2860
- } field;
- UINT32 word;
-} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#endif
-#define MAC_SYS_CTRL 0x1004 //MAC_CSR1
-#define MAC_ADDR_DW0 0x1008 // MAC ADDR DW0
-#define MAC_ADDR_DW1 0x100c // MAC ADDR DW1
-//
-// MAC_CSR2: STA MAC register 0
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_DW0_STRUC {
- struct {
- UCHAR Byte3; // MAC address byte 3
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte0; // MAC address byte 0
- } field;
- UINT32 word;
-} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-#else
-typedef union _MAC_DW0_STRUC {
- struct {
- UCHAR Byte0; // MAC address byte 0
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte3; // MAC address byte 3
- } field;
- UINT32 word;
-} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-#endif
-
-//
-// MAC_CSR3: STA MAC register 1
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_DW1_STRUC {
- struct {
- UCHAR Rsvd1;
- UCHAR U2MeMask;
- UCHAR Byte5; // MAC address byte 5
- UCHAR Byte4; // MAC address byte 4
- } field;
- UINT32 word;
-} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-#else
-typedef union _MAC_DW1_STRUC {
- struct {
- UCHAR Byte4; // MAC address byte 4
- UCHAR Byte5; // MAC address byte 5
- UCHAR U2MeMask;
- UCHAR Rsvd1;
- } field;
- UINT32 word;
-} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-#endif
-
-#define MAC_BSSID_DW0 0x1010 // MAC BSSID DW0
-#define MAC_BSSID_DW1 0x1014 // MAC BSSID DW1
-
-//
-// MAC_CSR5: BSSID register 1
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MAC_CSR5_STRUC {
- struct {
- USHORT Rsvd:11;
- USHORT MBssBcnNum:3;
- USHORT BssIdMode:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
- UCHAR Byte5; // BSSID byte 5
- UCHAR Byte4; // BSSID byte 4
- } field;
- UINT32 word;
-} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-#else
-typedef union _MAC_CSR5_STRUC {
- struct {
- UCHAR Byte4; // BSSID byte 4
- UCHAR Byte5; // BSSID byte 5
- USHORT BssIdMask:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
- USHORT MBssBcnNum:3;
- USHORT Rsvd:11;
- } field;
- UINT32 word;
-} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-#endif
-
-#define MAX_LEN_CFG 0x1018 // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
-#define BBP_CSR_CFG 0x101c //
-//
-// BBP_CSR_CFG: BBP serial control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _BBP_CSR_CFG_STRUC {
- struct {
- UINT32 :12;
- UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
- UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
- UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
- UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
- UINT32 RegNum:8; // Selected BBP register
- UINT32 Value:8; // Register value to program into BBP
- } field;
- UINT32 word;
-} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#else
-typedef union _BBP_CSR_CFG_STRUC {
- struct {
- UINT32 Value:8; // Register value to program into BBP
- UINT32 RegNum:8; // Selected BBP register
- UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
- UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
- UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
- UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
- UINT32 :12;
- } field;
- UINT32 word;
-} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#endif
-#define RF_CSR_CFG0 0x1020
-//
-// RF_CSR_CFG: RF control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG0_STRUC {
- struct {
- UINT32 Busy:1; // 0: idle 1: 8busy
- UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
- UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
- UINT32 bitwidth:5; // Selected BBP register
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#else
-typedef union _RF_CSR_CFG0_STRUC {
- struct {
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- UINT32 bitwidth:5; // Selected BBP register
- UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
- UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
- UINT32 Busy:1; // 0: idle 1: 8busy
- } field;
- UINT32 word;
-} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#endif
-#define RF_CSR_CFG1 0x1024
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG1_STRUC {
- struct {
- UINT32 rsv:7; // 0: idle 1: 8busy
- UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#else
-typedef union _RF_CSR_CFG1_STRUC {
- struct {
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
- UINT32 rsv:7; // 0: idle 1: 8busy
- } field;
- UINT32 word;
-} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#endif
-#define RF_CSR_CFG2 0x1028 //
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG2_STRUC {
- struct {
- UINT32 rsv:8; // 0: idle 1: 8busy
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- } field;
- UINT32 word;
-} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#else
-typedef union _RF_CSR_CFG2_STRUC {
- struct {
- UINT32 RegIdAndContent:24; // Register value to program into BBP
- UINT32 rsv:8; // 0: idle 1: 8busy
- } field;
- UINT32 word;
-} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#endif
-#define LED_CFG 0x102c // MAC_CSR14
-#ifdef RT_BIG_ENDIAN
-typedef union _LED_CFG_STRUC {
- struct {
- UINT32 :1;
- UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
- UINT32 YLedMode:2; // yellow Led Mode
- UINT32 GLedMode:2; // green Led Mode
- UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
- UINT32 rsv:2;
- UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
- UINT32 OffPeriod:8; // blinking off period unit 1ms
- UINT32 OnPeriod:8; // blinking on period unit 1ms
- } field;
- UINT32 word;
-} LED_CFG_STRUC, *PLED_CFG_STRUC;
-#else
-typedef union _LED_CFG_STRUC {
- struct {
- UINT32 OnPeriod:8; // blinking on period unit 1ms
- UINT32 OffPeriod:8; // blinking off period unit 1ms
- UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
- UINT32 rsv:2;
- UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
- UINT32 GLedMode:2; // green Led Mode
- UINT32 YLedMode:2; // yellow Led Mode
- UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
- UINT32 :1;
- } field;
- UINT32 word;
-} LED_CFG_STRUC, *PLED_CFG_STRUC;
-#endif
-//
-// 4.2 MAC TIMING configuration registers (offset:0x1100)
-//
-#define XIFS_TIME_CFG 0x1100 // MAC_CSR8 MAC_CSR9
-#ifdef RT_BIG_ENDIAN
-typedef union _IFS_SLOT_CFG_STRUC {
- struct {
- UINT32 rsv:2;
- UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
- UINT32 EIFS:9; // unit 1us
- UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
- UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
- UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
- } field;
- UINT32 word;
-} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-#else
-typedef union _IFS_SLOT_CFG_STRUC {
- struct {
- UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
- UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
- UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
- UINT32 EIFS:9; // unit 1us
- UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
- UINT32 rsv:2;
- } field;
- UINT32 word;
-} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-#endif
-
-#define BKOFF_SLOT_CFG 0x1104 // mac_csr9 last 8 bits
-#define NAV_TIME_CFG 0x1108 // NAV (MAC_CSR15)
-#define CH_TIME_CFG 0x110C // Count as channel busy
-#define PBF_LIFE_TIMER 0x1110 //TX/RX MPDU timestamp timer (free run)Unit: 1us
-#define BCN_TIME_CFG 0x1114 // TXRX_CSR9
-
-#define BCN_OFFSET0 0x042C
-#define BCN_OFFSET1 0x0430
-
-//
-// BCN_TIME_CFG : Synchronization control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _BCN_TIME_CFG_STRUC {
- struct {
- UINT32 TxTimestampCompensate:8;
- UINT32 :3;
- UINT32 bBeaconGen:1; // Enable beacon generator
- UINT32 bTBTTEnable:1;
- UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
- UINT32 bTsfTicking:1; // Enable TSF auto counting
- UINT32 BeaconInterval:16; // in unit of 1/16 TU
- } field;
- UINT32 word;
-} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#else
-typedef union _BCN_TIME_CFG_STRUC {
- struct {
- UINT32 BeaconInterval:16; // in unit of 1/16 TU
- UINT32 bTsfTicking:1; // Enable TSF auto counting
- UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
- UINT32 bTBTTEnable:1;
- UINT32 bBeaconGen:1; // Enable beacon generator
- UINT32 :3;
- UINT32 TxTimestampCompensate:8;
- } field;
- UINT32 word;
-} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#endif
-#define TBTT_SYNC_CFG 0x1118 // txrx_csr10
-#define TSF_TIMER_DW0 0x111C // Local TSF timer lsb 32 bits. Read-only
-#define TSF_TIMER_DW1 0x1120 // msb 32 bits. Read-only.
-#define TBTT_TIMER 0x1124 // TImer remains till next TBTT. Read-only. TXRX_CSR14
-#define INT_TIMER_CFG 0x1128 //
-#define INT_TIMER_EN 0x112c // GP-timer and pre-tbtt Int enable
-#define CH_IDLE_STA 0x1130 // channel idle time
-#define CH_BUSY_STA 0x1134 // channle busy time
-//
-// 4.2 MAC POWER configuration registers (offset:0x1200)
-//
-#define MAC_STATUS_CFG 0x1200 // old MAC_CSR12
-#define PWR_PIN_CFG 0x1204 // old MAC_CSR12
-#define AUTO_WAKEUP_CFG 0x1208 // old MAC_CSR10
-//
-// AUTO_WAKEUP_CFG: Manual power control / status register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _AUTO_WAKEUP_STRUC {
- struct {
- UINT32 :16;
- UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
- UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
- UINT32 AutoLeadTime:8;
- } field;
- UINT32 word;
-} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-#else
-typedef union _AUTO_WAKEUP_STRUC {
- struct {
- UINT32 AutoLeadTime:8;
- UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
- UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
- UINT32 :16;
- } field;
- UINT32 word;
-} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-#endif
-//
-// 4.3 MAC TX configuration registers (offset:0x1300)
-//
-
-#define EDCA_AC0_CFG 0x1300 //AC_TXOP_CSR0 0x3474
-#define EDCA_AC1_CFG 0x1304
-#define EDCA_AC2_CFG 0x1308
-#define EDCA_AC3_CFG 0x130c
-#ifdef RT_BIG_ENDIAN
-typedef union _EDCA_AC_CFG_STRUC {
- struct {
- UINT32 :12; //
- UINT32 Cwmax:4; //unit power of 2
- UINT32 Cwmin:4; //
- UINT32 Aifsn:4; // # of slot time
- UINT32 AcTxop:8; // in unit of 32us
- } field;
- UINT32 word;
-} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-#else
-typedef union _EDCA_AC_CFG_STRUC {
- struct {
- UINT32 AcTxop:8; // in unit of 32us
- UINT32 Aifsn:4; // # of slot time
- UINT32 Cwmin:4; //
- UINT32 Cwmax:4; //unit power of 2
- UINT32 :12; //
- } field;
- UINT32 word;
-} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-#endif
-
-#define EDCA_TID_AC_MAP 0x1310
-#define TX_PWR_CFG_0 0x1314
-#define TX_PWR_CFG_1 0x1318
-#define TX_PWR_CFG_2 0x131C
-#define TX_PWR_CFG_3 0x1320
-#define TX_PWR_CFG_4 0x1324
-#define TX_PIN_CFG 0x1328
-#define TX_BAND_CFG 0x132c // 0x1 use upper 20MHz. 0 juse lower 20MHz
-#define TX_SW_CFG0 0x1330
-#define TX_SW_CFG1 0x1334
-#define TX_SW_CFG2 0x1338
-#define TXOP_THRES_CFG 0x133c
-#define TXOP_CTRL_CFG 0x1340
-#define TX_RTS_CFG 0x1344
-
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_RTS_CFG_STRUC {
- struct {
- UINT32 rsv:7;
- UINT32 RtsFbkEn:1; // enable rts rate fallback
- UINT32 RtsThres:16; // unit:byte
- UINT32 AutoRtsRetryLimit:8;
- } field;
- UINT32 word;
-} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#else
-typedef union _TX_RTS_CFG_STRUC {
- struct {
- UINT32 AutoRtsRetryLimit:8;
- UINT32 RtsThres:16; // unit:byte
- UINT32 RtsFbkEn:1; // enable rts rate fallback
- UINT32 rsv:7; // 1: HT non-STBC control frame enable
- } field;
- UINT32 word;
-} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#endif
-#define TX_TIMEOUT_CFG 0x1348
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_TIMEOUT_CFG_STRUC {
- struct {
- UINT32 rsv2:8;
- UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
- UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
- UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
- UINT32 rsv:4;
- } field;
- UINT32 word;
-} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#else
-typedef union _TX_TIMEOUT_CFG_STRUC {
- struct {
- UINT32 rsv:4;
- UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
- UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
- UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
- UINT32 rsv2:8; // 1: HT non-STBC control frame enable
- } field;
- UINT32 word;
-} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#endif
-#define TX_RTY_CFG 0x134c
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_RTY_CFG_STRUC {
- struct {
- UINT32 rsv:1;
- UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
- UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 LongRtyThre:12; // Long retry threshoold
- UINT32 LongRtyLimit:8; //long retry limit
- UINT32 ShortRtyLimit:8; // short retry limit
-
- } field;
- UINT32 word;
-} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#else
-typedef union PACKED _TX_RTY_CFG_STRUC {
- struct {
- UINT32 ShortRtyLimit:8; // short retry limit
- UINT32 LongRtyLimit:8; //long retry limit
- UINT32 LongRtyThre:12; // Long retry threshoold
- UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
- UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
- UINT32 rsv:1; // 1: HT non-STBC control frame enable
- } field;
- UINT32 word;
-} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#endif
-#define TX_LINK_CFG 0x1350
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_LINK_CFG_STRUC {
- struct PACKED {
- UINT32 RemotMFS:8; //remote MCS feedback sequence number
- UINT32 RemotMFB:8; // remote MCS feedback
- UINT32 rsv:3; //
- UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
- UINT32 TxRDGEn:1; // RDG TX enable
- UINT32 TxMRQEn:1; // MCS request TX enable
- UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
- UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
- UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
- } field;
- UINT32 word;
-} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#else
-typedef union PACKED _TX_LINK_CFG_STRUC {
- struct PACKED {
- UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
- UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
- UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
- UINT32 TxMRQEn:1; // MCS request TX enable
- UINT32 TxRDGEn:1; // RDG TX enable
- UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
- UINT32 rsv:3; //
- UINT32 RemotMFB:8; // remote MCS feedback
- UINT32 RemotMFS:8; //remote MCS feedback sequence number
- } field;
- UINT32 word;
-} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#endif
-#define HT_FBK_CFG0 0x1354
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _HT_FBK_CFG0_STRUC {
- struct {
- UINT32 HTMCS7FBK:4;
- UINT32 HTMCS6FBK:4;
- UINT32 HTMCS5FBK:4;
- UINT32 HTMCS4FBK:4;
- UINT32 HTMCS3FBK:4;
- UINT32 HTMCS2FBK:4;
- UINT32 HTMCS1FBK:4;
- UINT32 HTMCS0FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#else
-typedef union PACKED _HT_FBK_CFG0_STRUC {
- struct {
- UINT32 HTMCS0FBK:4;
- UINT32 HTMCS1FBK:4;
- UINT32 HTMCS2FBK:4;
- UINT32 HTMCS3FBK:4;
- UINT32 HTMCS4FBK:4;
- UINT32 HTMCS5FBK:4;
- UINT32 HTMCS6FBK:4;
- UINT32 HTMCS7FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#endif
-#define HT_FBK_CFG1 0x1358
-#ifdef RT_BIG_ENDIAN
-typedef union _HT_FBK_CFG1_STRUC {
- struct {
- UINT32 HTMCS15FBK:4;
- UINT32 HTMCS14FBK:4;
- UINT32 HTMCS13FBK:4;
- UINT32 HTMCS12FBK:4;
- UINT32 HTMCS11FBK:4;
- UINT32 HTMCS10FBK:4;
- UINT32 HTMCS9FBK:4;
- UINT32 HTMCS8FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#else
-typedef union _HT_FBK_CFG1_STRUC {
- struct {
- UINT32 HTMCS8FBK:4;
- UINT32 HTMCS9FBK:4;
- UINT32 HTMCS10FBK:4;
- UINT32 HTMCS11FBK:4;
- UINT32 HTMCS12FBK:4;
- UINT32 HTMCS13FBK:4;
- UINT32 HTMCS14FBK:4;
- UINT32 HTMCS15FBK:4;
- } field;
- UINT32 word;
-} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#endif
-#define LG_FBK_CFG0 0x135c
-#ifdef RT_BIG_ENDIAN
-typedef union _LG_FBK_CFG0_STRUC {
- struct {
- UINT32 OFDMMCS7FBK:4; //initial value is 6
- UINT32 OFDMMCS6FBK:4; //initial value is 5
- UINT32 OFDMMCS5FBK:4; //initial value is 4
- UINT32 OFDMMCS4FBK:4; //initial value is 3
- UINT32 OFDMMCS3FBK:4; //initial value is 2
- UINT32 OFDMMCS2FBK:4; //initial value is 1
- UINT32 OFDMMCS1FBK:4; //initial value is 0
- UINT32 OFDMMCS0FBK:4; //initial value is 0
- } field;
- UINT32 word;
-} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#else
-typedef union _LG_FBK_CFG0_STRUC {
- struct {
- UINT32 OFDMMCS0FBK:4; //initial value is 0
- UINT32 OFDMMCS1FBK:4; //initial value is 0
- UINT32 OFDMMCS2FBK:4; //initial value is 1
- UINT32 OFDMMCS3FBK:4; //initial value is 2
- UINT32 OFDMMCS4FBK:4; //initial value is 3
- UINT32 OFDMMCS5FBK:4; //initial value is 4
- UINT32 OFDMMCS6FBK:4; //initial value is 5
- UINT32 OFDMMCS7FBK:4; //initial value is 6
- } field;
- UINT32 word;
-} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#endif
-#define LG_FBK_CFG1 0x1360
-#ifdef RT_BIG_ENDIAN
-typedef union _LG_FBK_CFG1_STRUC {
- struct {
- UINT32 rsv:16;
- UINT32 CCKMCS3FBK:4; //initial value is 2
- UINT32 CCKMCS2FBK:4; //initial value is 1
- UINT32 CCKMCS1FBK:4; //initial value is 0
- UINT32 CCKMCS0FBK:4; //initial value is 0
- } field;
- UINT32 word;
-} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-#else
-typedef union _LG_FBK_CFG1_STRUC {
- struct {
- UINT32 CCKMCS0FBK:4; //initial value is 0
- UINT32 CCKMCS1FBK:4; //initial value is 0
- UINT32 CCKMCS2FBK:4; //initial value is 1
- UINT32 CCKMCS3FBK:4; //initial value is 2
- UINT32 rsv:16;
- } field;
- UINT32 word;
-} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-#endif
-
-//=======================================================
-//================ Protection Paramater================================
-//=======================================================
-#define CCK_PROT_CFG 0x1364 //CCK Protection
-#define ASIC_SHORTNAV 1
-#define ASIC_LONGNAV 2
-#define ASIC_RTS 1
-#define ASIC_CTS 2
-#ifdef RT_BIG_ENDIAN
-typedef union _PROT_CFG_STRUC {
- struct {
- UINT32 rsv:5;
- UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
- UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
- UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
- UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
- UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
- UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
- } field;
- UINT32 word;
-} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-#else
-typedef union _PROT_CFG_STRUC {
- struct {
- UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
- UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
- UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
- UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
- UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
- UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
- UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
- UINT32 rsv:5;
- } field;
- UINT32 word;
-} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-#endif
-
-#define OFDM_PROT_CFG 0x1368 //OFDM Protection
-#define MM20_PROT_CFG 0x136C //MM20 Protection
-#define MM40_PROT_CFG 0x1370 //MM40 Protection
-#define GF20_PROT_CFG 0x1374 //GF20 Protection
-#define GF40_PROT_CFG 0x1378 //GR40 Protection
-#define EXP_CTS_TIME 0x137C //
-#define EXP_ACK_TIME 0x1380 //
-
-//
-// 4.4 MAC RX configuration registers (offset:0x1400)
-//
-#define RX_FILTR_CFG 0x1400 //TXRX_CSR0
-#define AUTO_RSP_CFG 0x1404 //TXRX_CSR4
-//
-// TXRX_CSR4: Auto-Responder/
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _AUTO_RSP_CFG_STRUC {
- struct {
- UINT32 :24;
- UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
- UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
- UINT32 rsv:1; // Power bit value in conrtrol frame
- UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
- UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
- UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
- UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
- UINT32 AutoResponderEnable:1;
- } field;
- UINT32 word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-#else
-typedef union _AUTO_RSP_CFG_STRUC {
- struct {
- UINT32 AutoResponderEnable:1;
- UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
- UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
- UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
- UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
- UINT32 rsv:1; // Power bit value in conrtrol frame
- UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
- UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
- UINT32 :24;
- } field;
- UINT32 word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-#endif
-
-#define LEGACY_BASIC_RATE 0x1408 // TXRX_CSR5 0x3054
-#define HT_BASIC_RATE 0x140c
-#define HT_CTRL_CFG 0x1410
-#define SIFS_COST_CFG 0x1414
-#define RX_PARSER_CFG 0x1418 //Set NAV for all received frames
-
-//
-// 4.5 MAC Security configuration (offset:0x1500)
-//
-#define TX_SEC_CNT0 0x1500 //
-#define RX_SEC_CNT0 0x1504 //
-#define CCMP_FC_MUTE 0x1508 //
-//
-// 4.6 HCCA/PSMP (offset:0x1600)
-//
-#define TXOP_HLDR_ADDR0 0x1600
-#define TXOP_HLDR_ADDR1 0x1604
-#define TXOP_HLDR_ET 0x1608
-#define QOS_CFPOLL_RA_DW0 0x160c
-#define QOS_CFPOLL_A1_DW1 0x1610
-#define QOS_CFPOLL_QC 0x1614
-//
-// 4.7 MAC Statistis registers (offset:0x1700)
-//
-#define RX_STA_CNT0 0x1700 //
-#define RX_STA_CNT1 0x1704 //
-#define RX_STA_CNT2 0x1708 //
-
-//
-// RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT0_STRUC {
- struct {
- USHORT PhyErr;
- USHORT CrcErr;
- } field;
- UINT32 word;
-} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-#else
-typedef union _RX_STA_CNT0_STRUC {
- struct {
- USHORT CrcErr;
- USHORT PhyErr;
- } field;
- UINT32 word;
-} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-#endif
-
-//
-// RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT1_STRUC {
- struct {
- USHORT PlcpErr;
- USHORT FalseCca;
- } field;
- UINT32 word;
-} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-#else
-typedef union _RX_STA_CNT1_STRUC {
- struct {
- USHORT FalseCca;
- USHORT PlcpErr;
- } field;
- UINT32 word;
-} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-#endif
-
-//
-// RX_STA_CNT2_STRUC:
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _RX_STA_CNT2_STRUC {
- struct {
- USHORT RxFifoOverflowCount;
- USHORT RxDupliCount;
- } field;
- UINT32 word;
-} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#else
-typedef union _RX_STA_CNT2_STRUC {
- struct {
- USHORT RxDupliCount;
- USHORT RxFifoOverflowCount;
- } field;
- UINT32 word;
-} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#endif
-#define TX_STA_CNT0 0x170C //
-//
-// STA_CSR3: TX Beacon count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT0_STRUC {
- struct {
- USHORT TxBeaconCount;
- USHORT TxFailCount;
- } field;
- UINT32 word;
-} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#else
-typedef union _TX_STA_CNT0_STRUC {
- struct {
- USHORT TxFailCount;
- USHORT TxBeaconCount;
- } field;
- UINT32 word;
-} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#endif
-#define TX_STA_CNT1 0x1710 //
-//
-// TX_STA_CNT1: TX tx count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT1_STRUC {
- struct {
- USHORT TxRetransmit;
- USHORT TxSuccess;
- } field;
- UINT32 word;
-} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#else
-typedef union _TX_STA_CNT1_STRUC {
- struct {
- USHORT TxSuccess;
- USHORT TxRetransmit;
- } field;
- UINT32 word;
-} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#endif
-#define TX_STA_CNT2 0x1714 //
-//
-// TX_STA_CNT2: TX tx count
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_STA_CNT2_STRUC {
- struct {
- USHORT TxUnderFlowCount;
- USHORT TxZeroLenCount;
- } field;
- UINT32 word;
-} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#else
-typedef union _TX_STA_CNT2_STRUC {
- struct {
- USHORT TxZeroLenCount;
- USHORT TxUnderFlowCount;
- } field;
- UINT32 word;
-} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#endif
-#define TX_STA_FIFO 0x1718 //
-//
-// TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union PACKED _TX_STA_FIFO_STRUC {
- struct {
- UINT32 Reserve:2;
- UINT32 TxBF:1; // 3*3
- UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
-// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 wcid:8; //wireless client index
- UINT32 TxAckRequired:1; // ack required
- UINT32 TxAggre:1; // Tx is aggregated
- UINT32 TxSuccess:1; // Tx success. whether success or not
- UINT32 PidType:4;
- UINT32 bValid:1; // 1:This register contains a valid TX result
- } field;
- UINT32 word;
-} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-#else
-typedef union PACKED _TX_STA_FIFO_STRUC {
- struct {
- UINT32 bValid:1; // 1:This register contains a valid TX result
- UINT32 PidType:4;
- UINT32 TxSuccess:1; // Tx No retry success
- UINT32 TxAggre:1; // Tx Retry Success
- UINT32 TxAckRequired:1; // Tx fail
- UINT32 wcid:8; //wireless client index
-// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
- UINT32 TxBF:1;
- UINT32 Reserve:2;
- } field;
- UINT32 word;
-} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT 0x171c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT_STRUC {
- struct {
- USHORT AggTxCount;
- USHORT NonAggTxCount;
- } field;
- UINT32 word;
-} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-#else
-typedef union _TX_AGG_CNT_STRUC {
- struct {
- USHORT NonAggTxCount;
- USHORT AggTxCount;
- } field;
- UINT32 word;
-} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT0 0x1720
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT0_STRUC {
- struct {
- USHORT AggSize2Count;
- USHORT AggSize1Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-#else
-typedef union _TX_AGG_CNT0_STRUC {
- struct {
- USHORT AggSize1Count;
- USHORT AggSize2Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT1 0x1724
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT1_STRUC {
- struct {
- USHORT AggSize4Count;
- USHORT AggSize3Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#else
-typedef union _TX_AGG_CNT1_STRUC {
- struct {
- USHORT AggSize3Count;
- USHORT AggSize4Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#endif
-#define TX_AGG_CNT2 0x1728
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT2_STRUC {
- struct {
- USHORT AggSize6Count;
- USHORT AggSize5Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-#else
-typedef union _TX_AGG_CNT2_STRUC {
- struct {
- USHORT AggSize5Count;
- USHORT AggSize6Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT3 0x172c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT3_STRUC {
- struct {
- USHORT AggSize8Count;
- USHORT AggSize7Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-#else
-typedef union _TX_AGG_CNT3_STRUC {
- struct {
- USHORT AggSize7Count;
- USHORT AggSize8Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-#endif
-// Debug counter
-#define TX_AGG_CNT4 0x1730
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT4_STRUC {
- struct {
- USHORT AggSize10Count;
- USHORT AggSize9Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#else
-typedef union _TX_AGG_CNT4_STRUC {
- struct {
- USHORT AggSize9Count;
- USHORT AggSize10Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#endif
-#define TX_AGG_CNT5 0x1734
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT5_STRUC {
- struct {
- USHORT AggSize12Count;
- USHORT AggSize11Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#else
-typedef union _TX_AGG_CNT5_STRUC {
- struct {
- USHORT AggSize11Count;
- USHORT AggSize12Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#endif
-#define TX_AGG_CNT6 0x1738
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT6_STRUC {
- struct {
- USHORT AggSize14Count;
- USHORT AggSize13Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#else
-typedef union _TX_AGG_CNT6_STRUC {
- struct {
- USHORT AggSize13Count;
- USHORT AggSize14Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#endif
-#define TX_AGG_CNT7 0x173c
-#ifdef RT_BIG_ENDIAN
-typedef union _TX_AGG_CNT7_STRUC {
- struct {
- USHORT AggSize16Count;
- USHORT AggSize15Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#else
-typedef union _TX_AGG_CNT7_STRUC {
- struct {
- USHORT AggSize15Count;
- USHORT AggSize16Count;
- } field;
- UINT32 word;
-} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#endif
-#define MPDU_DENSITY_CNT 0x1740
-#ifdef RT_BIG_ENDIAN
-typedef union _MPDU_DEN_CNT_STRUC {
- struct {
- USHORT RXZeroDelCount; //RX zero length delimiter count
- USHORT TXZeroDelCount; //TX zero length delimiter count
- } field;
- UINT32 word;
-} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-#else
-typedef union _MPDU_DEN_CNT_STRUC {
- struct {
- USHORT TXZeroDelCount; //TX zero length delimiter count
- USHORT RXZeroDelCount; //RX zero length delimiter count
- } field;
- UINT32 word;
-} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-#endif
-//
-// TXRX control registers - base address 0x3000
-//
-// rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
-#define TXRX_CSR1 0x77d0
-
-//
-// Security key table memory, base address = 0x1000
-//
-#define MAC_WCID_BASE 0x1800 //8-bytes(use only 6-bytes) * 256 entry =
-#define HW_WCID_ENTRY_SIZE 8
-#define PAIRWISE_KEY_TABLE_BASE 0x4000 // 32-byte * 256-entry = -byte
-#define HW_KEY_ENTRY_SIZE 0x20
-#define PAIRWISE_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
-#define MAC_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
-#define HW_IVEIV_ENTRY_SIZE 8
-#define MAC_WCID_ATTRIBUTE_BASE 0x6800 // 4-byte * 256-entry = -byte
-#define HW_WCID_ATTRI_SIZE 4
-#define WCID_RESERVED 0x6bfc
-#define SHARED_KEY_TABLE_BASE 0x6c00 // 32-byte * 16-entry = 512-byte
-#define SHARED_KEY_MODE_BASE 0x7000 // 32-byte * 16-entry = 512-byte
-#define HW_SHARED_KEY_MODE_SIZE 4
-#define SHAREDKEYTABLE 0
-#define PAIRWISEKEYTABLE 1
-
-
-#ifdef RT_BIG_ENDIAN
-typedef union _SHAREDKEY_MODE_STRUC {
- struct {
- UINT32 :1;
- UINT32 Bss1Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key0CipherAlg:3;
- } field;
- UINT32 word;
-} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-#else
-typedef union _SHAREDKEY_MODE_STRUC {
- struct {
- UINT32 Bss0Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss0Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss1Key3CipherAlg:3;
- UINT32 :1;
- } field;
- UINT32 word;
-} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-#endif
-// 64-entry for pairwise key table
-typedef struct _HW_WCID_ENTRY { // 8-byte per entry
- UCHAR Address[6];
- UCHAR Rsv[2];
-} HW_WCID_ENTRY, PHW_WCID_ENTRY;
-
-
-
-//
-// Other on-chip shared memory space, base = 0x2000
-//
-
-// CIS space - base address = 0x2000
-#define HW_CIS_BASE 0x2000
-
-// Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function.
-#define HW_CS_CTS_BASE 0x7700
-// DFS CTS frame base address. It's where mac stores CTS frame for DFS.
-#define HW_DFS_CTS_BASE 0x7780
-#define HW_CTS_FRAME_SIZE 0x80
-
-// 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes
-// to save debugging settings
-#define HW_DEBUG_SETTING_BASE 0x77f0 // 0x77f0~0x77ff total 16 bytes
-#define HW_DEBUG_SETTING_BASE2 0x7770 // 0x77f0~0x77ff total 16 bytes
-
-// In order to support maximum 8 MBSS and its maximum length is 512 for each beacon
-// Three section discontinue memory segments will be used.
-// 1. The original region for BCN 0~3
-// 2. Extract memory from FCE table for BCN 4~5
-// 3. Extract memory from Pair-wise key table for BCN 6~7
-// It occupied those memory of wcid 238~253 for BCN 6
-// and wcid 222~237 for BCN 7
-#define HW_BEACON_MAX_SIZE 0x1000 /* unit: byte */
-#define HW_BEACON_BASE0 0x7800
-#define HW_BEACON_BASE1 0x7A00
-#define HW_BEACON_BASE2 0x7C00
-#define HW_BEACON_BASE3 0x7E00
-#define HW_BEACON_BASE4 0x7200
-#define HW_BEACON_BASE5 0x7400
-#define HW_BEACON_BASE6 0x5DC0
-#define HW_BEACON_BASE7 0x5BC0
-
-#define HW_BEACON_MAX_COUNT 8
-#define HW_BEACON_OFFSET 0x0200
-#define HW_BEACON_CONTENT_LEN (HW_BEACON_OFFSET - TXWI_SIZE)
-
-// HOST-MCU shared memory - base address = 0x2100
-#define HOST_CMD_CSR 0x404
-#define H2M_MAILBOX_CSR 0x7010
-#define H2M_MAILBOX_CID 0x7014
-#define H2M_MAILBOX_STATUS 0x701c
-#define H2M_INT_SRC 0x7024
-#define H2M_BBP_AGENT 0x7028
-#define M2H_CMD_DONE_CSR 0x000c
-#define MCU_TXOP_ARRAY_BASE 0x000c // TODO: to be provided by Albert
-#define MCU_TXOP_ENTRY_SIZE 32 // TODO: to be provided by Albert
-#define MAX_NUM_OF_TXOP_ENTRY 16 // TODO: must be same with 8051 firmware
-#define MCU_MBOX_VERSION 0x01 // TODO: to be confirmed by Albert
-#define MCU_MBOX_VERSION_OFFSET 5 // TODO: to be provided by Albert
-
-//
-// Host DMA registers - base address 0x200 . TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT,
-//
-//
-// DMA RING DESCRIPTOR
-//
-#define E2PROM_CSR 0x0004
-#define IO_CNTL_CSR 0x77d0
-
-#ifdef RT2870
-// 8051 firmware image for usb - use last-half base address = 0x3000
-#define FIRMWARE_IMAGE_BASE 0x3000
-#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 // 4kbyte
-#endif // RT2870 //
-
-// TODO: ????? old RT2560 registers. to keep them or remove them?
-//#define MCAST0 0x0178 // multicast filter register 0
-//#define MCAST1 0x017c // multicast filter register 1
-
-
-// ================================================================
-// Tx / Rx / Mgmt ring descriptor definition
-// ================================================================
-
-// the following PID values are used to mark outgoing frame type in TXD->PID so that
-// proper TX statistics can be collected based on these categories
-// b3-2 of PID field -
-#define PID_MGMT 0x05
-#define PID_BEACON 0x0c
-#define PID_DATA_NORMALUCAST 0x02
-#define PID_DATA_AMPDU 0x04
-#define PID_DATA_NO_ACK 0x08
-#define PID_DATA_NOT_NORM_ACK 0x03
-// value domain of pTxD->HostQId (4-bit: 0~15)
-#define QID_AC_BK 1 // meet ACI definition in 802.11e
-#define QID_AC_BE 0 // meet ACI definition in 802.11e
-#define QID_AC_VI 2
-#define QID_AC_VO 3
-#define QID_HCCA 4
-#define NUM_OF_TX_RING 5
-#define QID_MGMT 13
-#define QID_RX 14
-#define QID_OTHER 15
-
-
-// ------------------------------------------------------
-// BBP & RF definition
-// ------------------------------------------------------
-#define BUSY 1
-#define IDLE 0
-
-#define RF_R00 0
-#define RF_R01 1
-#define RF_R02 2
-#define RF_R03 3
-#define RF_R04 4
-#define RF_R05 5
-#define RF_R06 6
-#define RF_R07 7
-#define RF_R08 8
-#define RF_R09 9
-#define RF_R10 10
-#define RF_R11 11
-#define RF_R12 12
-#define RF_R13 13
-#define RF_R14 14
-#define RF_R15 15
-#define RF_R16 16
-#define RF_R17 17
-#define RF_R18 18
-#define RF_R19 19
-#define RF_R20 20
-#define RF_R21 21
-#define RF_R22 22
-#define RF_R23 23
-#define RF_R24 24
-#define RF_R25 25
-#define RF_R26 26
-#define RF_R27 27
-#define RF_R28 28
-#define RF_R29 29
-#define RF_R30 30
-#define RF_R31 31
-
-#define BBP_R0 0 // version
-#define BBP_R1 1 // TSSI
-#define BBP_R2 2 // TX configure
-#define BBP_R3 3
-#define BBP_R4 4
-#define BBP_R5 5
-#define BBP_R6 6
-#define BBP_R14 14 // RX configure
-#define BBP_R16 16
-#define BBP_R17 17 // RX sensibility
-#define BBP_R18 18
-#define BBP_R21 21
-#define BBP_R22 22
-#define BBP_R24 24
-#define BBP_R25 25
-#define BBP_R31 31
-#define BBP_R49 49 //TSSI
-#define BBP_R50 50
-#define BBP_R51 51
-#define BBP_R52 52
-#define BBP_R55 55
-#define BBP_R62 62 // Rx SQ0 Threshold HIGH
-#define BBP_R63 63
-#define BBP_R64 64
-#define BBP_R65 65
-#define BBP_R66 66
-#define BBP_R67 67
-#define BBP_R68 68
-#define BBP_R69 69
-#define BBP_R70 70 // Rx AGC SQ CCK Xcorr threshold
-#define BBP_R73 73
-#define BBP_R75 75
-#define BBP_R77 77
-#define BBP_R79 79
-#define BBP_R80 80
-#define BBP_R81 81
-#define BBP_R82 82
-#define BBP_R83 83
-#define BBP_R84 84
-#define BBP_R86 86
-#define BBP_R91 91
-#define BBP_R92 92
-#define BBP_R94 94 // Tx Gain Control
-#define BBP_R103 103
-#define BBP_R105 105
-#define BBP_R113 113
-#define BBP_R114 114
-#define BBP_R115 115
-#define BBP_R116 116
-#define BBP_R117 117
-#define BBP_R118 118
-#define BBP_R119 119
-#define BBP_R120 120
-#define BBP_R121 121
-#define BBP_R122 122
-#define BBP_R123 123
-#ifdef RT30xx
-#define BBP_R138 138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
-#endif // RT30xx //
-
-
-#define BBPR94_DEFAULT 0x06 // Add 1 value will gain 1db
-
-//#define PHY_TR_SWITCH_TIME 5 // usec
-
-//#define BBP_R17_LOW_SENSIBILITY 0x50
-//#define BBP_R17_MID_SENSIBILITY 0x41
-//#define BBP_R17_DYNAMIC_UP_BOUND 0x40
-#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
-#define RSSI_FOR_LOW_SENSIBILITY -58
-#define RSSI_FOR_MID_LOW_SENSIBILITY -80
-#define RSSI_FOR_MID_SENSIBILITY -90
-
-//-------------------------------------------------------------------------
-// EEPROM definition
-//-------------------------------------------------------------------------
-#define EEDO 0x08
-#define EEDI 0x04
-#define EECS 0x02
-#define EESK 0x01
-#define EERL 0x80
-
-#define EEPROM_WRITE_OPCODE 0x05
-#define EEPROM_READ_OPCODE 0x06
-#define EEPROM_EWDS_OPCODE 0x10
-#define EEPROM_EWEN_OPCODE 0x13
-
-#define NUM_EEPROM_BBP_PARMS 19 // Include NIC Config 0, 1, CR, TX ALC step, BBPs
-#define NUM_EEPROM_TX_G_PARMS 7
-#define EEPROM_NIC1_OFFSET 0x34 // The address is from NIC config 0, not BBP register ID
-#define EEPROM_NIC2_OFFSET 0x36 // The address is from NIC config 0, not BBP register ID
-#define EEPROM_BBP_BASE_OFFSET 0xf0 // The address is from NIC config 0, not BBP register ID
-#define EEPROM_G_TX_PWR_OFFSET 0x52
-#define EEPROM_G_TX2_PWR_OFFSET 0x60
-#define EEPROM_LED1_OFFSET 0x3c
-#define EEPROM_LED2_OFFSET 0x3e
-#define EEPROM_LED3_OFFSET 0x40
-#define EEPROM_LNA_OFFSET 0x44
-#define EEPROM_RSSI_BG_OFFSET 0x46
-#define EEPROM_RSSI_A_OFFSET 0x4a
-#define EEPROM_DEFINE_MAX_TXPWR 0x4e
-#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G 0xde // 20MHZ 2.4G tx power.
-#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G 0xee // 40MHZ 2.4G tx power.
-#define EEPROM_TXPOWER_BYRATE_20MHZ_5G 0xfa // 20MHZ 5G tx power.
-#define EEPROM_TXPOWER_BYRATE_40MHZ_5G 0x10a // 40MHZ 5G tx power.
-#define EEPROM_A_TX_PWR_OFFSET 0x78
-#define EEPROM_A_TX2_PWR_OFFSET 0xa6
-//#define EEPROM_Japan_TX_PWR_OFFSET 0x90 // 802.11j
-//#define EEPROM_Japan_TX2_PWR_OFFSET 0xbe
-//#define EEPROM_TSSI_REF_OFFSET 0x54
-//#define EEPROM_TSSI_DELTA_OFFSET 0x24
-//#define EEPROM_CCK_TX_PWR_OFFSET 0x62
-//#define EEPROM_CALIBRATE_OFFSET 0x7c
-#define EEPROM_VERSION_OFFSET 0x02
-#define EEPROM_FREQ_OFFSET 0x3a
-#define EEPROM_TXPOWER_BYRATE 0xde // 20MHZ power.
-#define EEPROM_TXPOWER_DELTA 0x50 // 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ.
-#define VALID_EEPROM_VERSION 1
-
-// PairKeyMode definition
-#define PKMODE_NONE 0
-#define PKMODE_WEP64 1
-#define PKMODE_WEP128 2
-#define PKMODE_TKIP 3
-#define PKMODE_AES 4
-#define PKMODE_CKIP64 5
-#define PKMODE_CKIP128 6
-#define PKMODE_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
-
-// =================================================================================
-// WCID format
-// =================================================================================
-//7.1 WCID ENTRY format : 8bytes
-typedef struct _WCID_ENTRY_STRUC {
- UCHAR RXBABitmap7; // bit0 for TID8, bit7 for TID 15
- UCHAR RXBABitmap0; // bit0 for TID0, bit7 for TID 7
- UCHAR MAC[6]; // 0 for shared key table. 1 for pairwise key table
-} WCID_ENTRY_STRUC, *PWCID_ENTRY_STRUC;
-
-//8.1.1 SECURITY KEY format : 8DW
-// 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table
-typedef struct _HW_KEY_ENTRY { // 32-byte per entry
- UCHAR Key[16];
- UCHAR TxMic[8];
- UCHAR RxMic[8];
-} HW_KEY_ENTRY, *PHW_KEY_ENTRY;
-
-//8.1.2 IV/EIV format : 2DW
-
-//8.1.3 RX attribute entry format : 1DW
-#ifdef RT_BIG_ENDIAN
-typedef struct _MAC_ATTRIBUTE_STRUC {
- UINT32 rsv:22;
- UINT32 RXWIUDF:3;
- UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
- UINT32 PairKeyMode:3;
- UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
-} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-#else
-typedef struct _MAC_ATTRIBUTE_STRUC {
- UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
- UINT32 PairKeyMode:3;
- UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
- UINT32 RXWIUDF:3;
- UINT32 rsv:22;
-} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-#endif
-
-
-// =================================================================================
-// TX / RX ring descriptor format
-// =================================================================================
-
-// the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO.
-// MAC block use this TXINFO to control the transmission behavior of this frame.
-#define FIFO_MGMT 0
-#define FIFO_HCCA 1
-#define FIFO_EDCA 2
-
-//
-// TX descriptor format, Tx ring, Mgmt Ring
-//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _TXD_STRUC {
- // Word 0
- UINT32 SDPtr0;
- // Word 1
- UINT32 DMADONE:1;
- UINT32 LastSec0:1;
- UINT32 SDLen0:14;
- UINT32 Burst:1;
- UINT32 LastSec1:1;
- UINT32 SDLen1:14;
- // Word 2
- UINT32 SDPtr1;
- // Word 3
- UINT32 ICO:1;
- UINT32 UCO:1;
- UINT32 TCO:1;
- UINT32 rsv:2;
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 rsv2:24;
-} TXD_STRUC, *PTXD_STRUC;
-#else
-typedef struct PACKED _TXD_STRUC {
- // Word 0
- UINT32 SDPtr0;
- // Word 1
- UINT32 SDLen1:14;
- UINT32 LastSec1:1;
- UINT32 Burst:1;
- UINT32 SDLen0:14;
- UINT32 LastSec0:1;
- UINT32 DMADONE:1;
- //Word2
- UINT32 SDPtr1;
- //Word3
- UINT32 rsv2:24;
- UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
- UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
- UINT32 rsv:2;
- UINT32 TCO:1; //
- UINT32 UCO:1; //
- UINT32 ICO:1; //
-} TXD_STRUC, *PTXD_STRUC;
-#endif
-
-
-//
-// TXD Wireless Information format for Tx ring and Mgmt Ring
-//
-//txop : for txop mode
-// 0:txop for the MPDU frame will be handles by ASIC by register
-// 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _TXWI_STRUC {
- // Word 0
- UINT32 PHYMODE:2;
- UINT32 TxBF:1; // 3*3
- UINT32 rsv2:1;
-// UINT32 rsv2:2;
- UINT32 Ifs:1; //
- UINT32 STBC:2; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 MCS:7;
-
- UINT32 rsv:6;
- UINT32 txop:2; //tx back off mode 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
- UINT32 MpduDensity:3;
- UINT32 AMPDU:1;
-
- UINT32 TS:1;
- UINT32 CFACK:1;
- UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
- UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
- // Word 1
- UINT32 PacketId:4;
- UINT32 MPDUtotalByteCount:12;
- UINT32 WirelessCliID:8;
- UINT32 BAWinSize:6;
- UINT32 NSEQ:1;
- UINT32 ACK:1;
- // Word 2
- UINT32 IV;
- // Word 3
- UINT32 EIV;
-} TXWI_STRUC, *PTXWI_STRUC;
-#else
-typedef struct PACKED _TXWI_STRUC {
- // Word 0
- UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
- UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
- UINT32 CFACK:1;
- UINT32 TS:1;
-
- UINT32 AMPDU:1;
- UINT32 MpduDensity:3;
- UINT32 txop:2; //FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
- UINT32 rsv:6;
-
- UINT32 MCS:7;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 STBC:2; // 1: STBC support MCS =0-7, 2,3 : RESERVE
- UINT32 Ifs:1; //
-// UINT32 rsv2:2; //channel bandwidth 20MHz or 40 MHz
- UINT32 rsv2:1;
- UINT32 TxBF:1; // 3*3
- UINT32 PHYMODE:2;
- // Word 1
- UINT32 ACK:1;
- UINT32 NSEQ:1;
- UINT32 BAWinSize:6;
- UINT32 WirelessCliID:8;
- UINT32 MPDUtotalByteCount:12;
- UINT32 PacketId:4;
- //Word2
- UINT32 IV;
- //Word3
- UINT32 EIV;
-} TXWI_STRUC, *PTXWI_STRUC;
-#endif
-//
-// Rx descriptor format, Rx Ring
-//
-//
-// RXWI wireless information format, in PBF. invisible in driver.
-//
-#ifdef RT_BIG_ENDIAN
-typedef struct PACKED _RXWI_STRUC {
- // Word 0
- UINT32 TID:4;
- UINT32 MPDUtotalByteCount:12;
- UINT32 UDF:3;
- UINT32 BSSID:3;
- UINT32 KeyIndex:2;
- UINT32 WirelessCliID:8;
- // Word 1
- UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
- UINT32 rsv:3;
- UINT32 STBC:2;
- UINT32 ShortGI:1;
- UINT32 BW:1;
- UINT32 MCS:7;
- UINT32 SEQUENCE:12;
- UINT32 FRAG:4;
- // Word 2
- UINT32 rsv1:8;
- UINT32 RSSI2:8;
- UINT32 RSSI1:8;
- UINT32 RSSI0:8;
- // Word 3
- UINT32 rsv2:16;
- UINT32 SNR1:8;
- UINT32 SNR0:8;
-} RXWI_STRUC, *PRXWI_STRUC;
-#else
-typedef struct PACKED _RXWI_STRUC {
- // Word 0
- UINT32 WirelessCliID:8;
- UINT32 KeyIndex:2;
- UINT32 BSSID:3;
- UINT32 UDF:3;
- UINT32 MPDUtotalByteCount:12;
- UINT32 TID:4;
- // Word 1
- UINT32 FRAG:4;
- UINT32 SEQUENCE:12;
- UINT32 MCS:7;
- UINT32 BW:1;
- UINT32 ShortGI:1;
- UINT32 STBC:2;
- UINT32 rsv:3;
- UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
- //Word2
- UINT32 RSSI0:8;
- UINT32 RSSI1:8;
- UINT32 RSSI2:8;
- UINT32 rsv1:8;
- //Word3
- UINT32 SNR0:8;
- UINT32 SNR1:8;
- UINT32 rsv2:16;
-} RXWI_STRUC, *PRXWI_STRUC;
-#endif
-
-
-// =================================================================================
-// HOST-MCU communication data structure
-// =================================================================================
-
-//
-// H2M_MAILBOX_CSR: Host-to-MCU Mailbox
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _H2M_MAILBOX_STRUC {
- struct {
- UINT32 Owner:8;
- UINT32 CmdToken:8; // 0xff tells MCU not to report CmdDoneInt after excuting the command
- UINT32 HighByte:8;
- UINT32 LowByte:8;
- } field;
- UINT32 word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-#else
-typedef union _H2M_MAILBOX_STRUC {
- struct {
- UINT32 LowByte:8;
- UINT32 HighByte:8;
- UINT32 CmdToken:8;
- UINT32 Owner:8;
- } field;
- UINT32 word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-#endif
-
-//
-// M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _M2H_CMD_DONE_STRUC {
- struct {
- UINT32 CmdToken3;
- UINT32 CmdToken2;
- UINT32 CmdToken1;
- UINT32 CmdToken0;
- } field;
- UINT32 word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-#else
-typedef union _M2H_CMD_DONE_STRUC {
- struct {
- UINT32 CmdToken0;
- UINT32 CmdToken1;
- UINT32 CmdToken2;
- UINT32 CmdToken3;
- } field;
- UINT32 word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-#endif
-
-
-
-//
-// MCU_LEDCS: MCU LED Control Setting.
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _MCU_LEDCS_STRUC {
- struct {
- UCHAR Polarity:1;
- UCHAR LedMode:7;
- } field;
- UCHAR word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-#else
-typedef union _MCU_LEDCS_STRUC {
- struct {
- UCHAR LedMode:7;
- UCHAR Polarity:1;
- } field;
- UCHAR word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-#endif
-// =================================================================================
-// Register format
-// =================================================================================
-
-
-
-//NAV_TIME_CFG :NAV
-#ifdef RT_BIG_ENDIAN
-typedef union _NAV_TIME_CFG_STRUC {
- struct {
- USHORT rsv:6;
- USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
- USHORT Eifs:9; // in unit of 1-us
- UCHAR SlotTime; // in unit of 1-us
- UCHAR Sifs; // in unit of 1-us
- } field;
- UINT32 word;
-} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-#else
-typedef union _NAV_TIME_CFG_STRUC {
- struct {
- UCHAR Sifs; // in unit of 1-us
- UCHAR SlotTime; // in unit of 1-us
- USHORT Eifs:9; // in unit of 1-us
- USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
- USHORT rsv:6;
- } field;
- UINT32 word;
-} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-#endif
-
-
-
-
-
-//
-// RX_FILTR_CFG: /RX configuration register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union RX_FILTR_CFG_STRUC {
- struct {
- UINT32 :15;
- UINT32 DropRsvCntlType:1;
-
- UINT32 DropBAR:1; //
- UINT32 DropBA:1; //
- UINT32 DropPsPoll:1; // Drop Ps-Poll
- UINT32 DropRts:1; // Drop Ps-Poll
-
- UINT32 DropCts:1; // Drop Ps-Poll
- UINT32 DropAck:1; // Drop Ps-Poll
- UINT32 DropCFEnd:1; // Drop Ps-Poll
- UINT32 DropCFEndAck:1; // Drop Ps-Poll
-
- UINT32 DropDuplicate:1; // Drop duplicate frame
- UINT32 DropBcast:1; // Drop broadcast frames
- UINT32 DropMcast:1; // Drop multicast frames
- UINT32 DropVerErr:1; // Drop version error frame
-
- UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
- UINT32 DropNotToMe:1; // Drop not to me unicast frame
- UINT32 DropPhyErr:1; // Drop physical error
- UINT32 DropCRCErr:1; // Drop CRC error
- } field;
- UINT32 word;
-} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-#else
-typedef union _RX_FILTR_CFG_STRUC {
- struct {
- UINT32 DropCRCErr:1; // Drop CRC error
- UINT32 DropPhyErr:1; // Drop physical error
- UINT32 DropNotToMe:1; // Drop not to me unicast frame
- UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
-
- UINT32 DropVerErr:1; // Drop version error frame
- UINT32 DropMcast:1; // Drop multicast frames
- UINT32 DropBcast:1; // Drop broadcast frames
- UINT32 DropDuplicate:1; // Drop duplicate frame
-
- UINT32 DropCFEndAck:1; // Drop Ps-Poll
- UINT32 DropCFEnd:1; // Drop Ps-Poll
- UINT32 DropAck:1; // Drop Ps-Poll
- UINT32 DropCts:1; // Drop Ps-Poll
-
- UINT32 DropRts:1; // Drop Ps-Poll
- UINT32 DropPsPoll:1; // Drop Ps-Poll
- UINT32 DropBA:1; //
- UINT32 DropBAR:1; //
-
- UINT32 DropRsvCntlType:1;
- UINT32 :15;
- } field;
- UINT32 word;
-} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-#endif
-
-
-
-
-//
-// PHY_CSR4: RF serial control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _PHY_CSR4_STRUC {
- struct {
- UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
- UINT32 PLL_LD:1; // RF PLL_LD status
- UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
- UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
- UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
- } field;
- UINT32 word;
-} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-#else
-typedef union _PHY_CSR4_STRUC {
- struct {
- UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
- UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
- UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
- UINT32 PLL_LD:1; // RF PLL_LD status
- UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
- } field;
- UINT32 word;
-} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-#endif
-
-
-//
-// SEC_CSR5: shared key table security mode register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _SEC_CSR5_STRUC {
- struct {
- UINT32 :1;
- UINT32 Bss3Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key0CipherAlg:3;
- } field;
- UINT32 word;
-} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-#else
-typedef union _SEC_CSR5_STRUC {
- struct {
- UINT32 Bss2Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss2Key3CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key0CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key1CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key2CipherAlg:3;
- UINT32 :1;
- UINT32 Bss3Key3CipherAlg:3;
- UINT32 :1;
- } field;
- UINT32 word;
-} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-#endif
-
-
-//
-// HOST_CMD_CSR: For HOST to interrupt embedded processor
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _HOST_CMD_CSR_STRUC {
- struct {
- UINT32 Rsv:24;
- UINT32 HostCommand:8;
- } field;
- UINT32 word;
-} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-#else
-typedef union _HOST_CMD_CSR_STRUC {
- struct {
- UINT32 HostCommand:8;
- UINT32 Rsv:24;
- } field;
- UINT32 word;
-} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-#endif
-
-
-//
-// AIFSN_CSR: AIFSN for each EDCA AC
-//
-
-
-
-//
-// E2PROM_CSR: EEPROM control register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _E2PROM_CSR_STRUC {
- struct {
- UINT32 Rsvd:25;
- UINT32 LoadStatus:1; // 1:loading, 0:done
- UINT32 Type:1; // 1: 93C46, 0:93C66
- UINT32 EepromDO:1;
- UINT32 EepromDI:1;
- UINT32 EepromCS:1;
- UINT32 EepromSK:1;
- UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
- } field;
- UINT32 word;
-} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-#else
-typedef union _E2PROM_CSR_STRUC {
- struct {
- UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
- UINT32 EepromSK:1;
- UINT32 EepromCS:1;
- UINT32 EepromDI:1;
- UINT32 EepromDO:1;
- UINT32 Type:1; // 1: 93C46, 0:93C66
- UINT32 LoadStatus:1; // 1:loading, 0:done
- UINT32 Rsvd:25;
- } field;
- UINT32 word;
-} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-#endif
-
-
-// -------------------------------------------------------------------
-// E2PROM data layout
-// -------------------------------------------------------------------
-
-//
-// EEPROM antenna select format
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_ANTENNA_STRUC {
- struct {
- USHORT Rsv:4;
- USHORT RfIcType:4; // see E2PROM document
- USHORT TxPath:4; // 1: 1T, 2: 2T
- USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
- } field;
- USHORT word;
-} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-#else
-typedef union _EEPROM_ANTENNA_STRUC {
- struct {
- USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
- USHORT TxPath:4; // 1: 1T, 2: 2T
- USHORT RfIcType:4; // see E2PROM document
- USHORT Rsv:4;
- } field;
- USHORT word;
-} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_NIC_CINFIG2_STRUC {
- struct {
- USHORT DACTestBit:1; // control if driver should patch the DAC issue
- USHORT Rsv2:3; // must be 0
- USHORT AntDiversity:1; // Antenna diversity
- USHORT Rsv1:1; // must be 0
- USHORT BW40MAvailForA:1; // 0:enable, 1:disable
- USHORT BW40MAvailForG:1; // 0:enable, 1:disable
- USHORT EnableWPSPBC:1; // WPS PBC Control bit
- USHORT BW40MSidebandForA:1;
- USHORT BW40MSidebandForG:1;
- USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
- USHORT ExternalLNAForA:1; // external LNA enable for 5G
- USHORT ExternalLNAForG:1; // external LNA enable for 2.4G
- USHORT DynamicTxAgcControl:1; //
- USHORT HardwareRadioControl:1; // Whether RF is controlled by driver or HW. 1:enable hw control, 0:disable
- } field;
- USHORT word;
-} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-#else
-typedef union _EEPROM_NIC_CINFIG2_STRUC {
- struct {
- USHORT HardwareRadioControl:1; // 1:enable, 0:disable
- USHORT DynamicTxAgcControl:1; //
- USHORT ExternalLNAForG:1; //
- USHORT ExternalLNAForA:1; // external LNA enable for 2.4G
- USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
- USHORT BW40MSidebandForG:1;
- USHORT BW40MSidebandForA:1;
- USHORT EnableWPSPBC:1; // WPS PBC Control bit
- USHORT BW40MAvailForG:1; // 0:enable, 1:disable
- USHORT BW40MAvailForA:1; // 0:enable, 1:disable
- USHORT Rsv1:1; // must be 0
- USHORT AntDiversity:1; // Antenna diversity
- USHORT Rsv2:3; // must be 0
- USHORT DACTestBit:1; // control if driver should patch the DAC issue
- } field;
- USHORT word;
-} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-#endif
-
-//
-// TX_PWR Value valid range 0xFA(-6) ~ 0x24(36)
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_TX_PWR_STRUC {
- struct {
- CHAR Byte1; // High Byte
- CHAR Byte0; // Low Byte
- } field;
- USHORT word;
-} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-#else
-typedef union _EEPROM_TX_PWR_STRUC {
- struct {
- CHAR Byte0; // Low Byte
- CHAR Byte1; // High Byte
- } field;
- USHORT word;
-} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_VERSION_STRUC {
- struct {
- UCHAR Version; // High Byte
- UCHAR FaeReleaseNumber; // Low Byte
- } field;
- USHORT word;
-} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-#else
-typedef union _EEPROM_VERSION_STRUC {
- struct {
- UCHAR FaeReleaseNumber; // Low Byte
- UCHAR Version; // High Byte
- } field;
- USHORT word;
-} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_LED_STRUC {
- struct {
- USHORT Rsvd:3; // Reserved
- USHORT LedMode:5; // Led mode.
- USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
- USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
- USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
- USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
- USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
- USHORT PolarityACT:1; // Polarity ACT setting.
- USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
- USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
- } field;
- USHORT word;
-} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-#else
-typedef union _EEPROM_LED_STRUC {
- struct {
- USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
- USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
- USHORT PolarityACT:1; // Polarity ACT setting.
- USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
- USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
- USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
- USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
- USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
- USHORT LedMode:5; // Led mode.
- USHORT Rsvd:3; // Reserved
- } field;
- USHORT word;
-} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-#endif
-
-#ifdef RT_BIG_ENDIAN
-typedef union _EEPROM_TXPOWER_DELTA_STRUC {
- struct {
- UCHAR TxPowerEnable:1;// Enable
- UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
- UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
- } field;
- UCHAR value;
-} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-#else
-typedef union _EEPROM_TXPOWER_DELTA_STRUC {
- struct {
- UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
- UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
- UCHAR TxPowerEnable:1;// Enable
- } field;
- UCHAR value;
-} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-#endif
-
-//
-// QOS_CSR0: TXOP holder address0 register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _QOS_CSR0_STRUC {
- struct {
- UCHAR Byte3; // MAC address byte 3
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte0; // MAC address byte 0
- } field;
- UINT32 word;
-} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-#else
-typedef union _QOS_CSR0_STRUC {
- struct {
- UCHAR Byte0; // MAC address byte 0
- UCHAR Byte1; // MAC address byte 1
- UCHAR Byte2; // MAC address byte 2
- UCHAR Byte3; // MAC address byte 3
- } field;
- UINT32 word;
-} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-#endif
-
-//
-// QOS_CSR1: TXOP holder address1 register
-//
-#ifdef RT_BIG_ENDIAN
-typedef union _QOS_CSR1_STRUC {
- struct {
- UCHAR Rsvd1;
- UCHAR Rsvd0;
- UCHAR Byte5; // MAC address byte 5
- UCHAR Byte4; // MAC address byte 4
- } field;
- UINT32 word;
-} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-#else
-typedef union _QOS_CSR1_STRUC {
- struct {
- UCHAR Byte4; // MAC address byte 4
- UCHAR Byte5; // MAC address byte 5
- UCHAR Rsvd0;
- UCHAR Rsvd1;
- } field;
- UINT32 word;
-} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-#endif
-
-#define RF_CSR_CFG 0x500
-#ifdef RT_BIG_ENDIAN
-typedef union _RF_CSR_CFG_STRUC {
- struct {
- UINT Rsvd1:14; // Reserved
- UINT RF_CSR_KICK:1; // kick RF register read/write
- UINT RF_CSR_WR:1; // 0: read 1: write
- UINT Rsvd2:3; // Reserved
- UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
- UINT RF_CSR_DATA:8; // DATA
- } field;
- UINT word;
-} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-#else
-typedef union _RF_CSR_CFG_STRUC {
- struct {
- UINT RF_CSR_DATA:8; // DATA
- UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
- UINT Rsvd2:3; // Reserved
- UINT RF_CSR_WR:1; // 0: read 1: write
- UINT RF_CSR_KICK:1; // kick RF register read/write
- UINT Rsvd1:14; // Reserved
- } field;
- UINT word;
-} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-#endif
-
-#endif // __RT28XX_H__
+#include "../rt2870/rt28xx.h"
diff --git a/drivers/staging/rt3070/rt_ate.c b/drivers/staging/rt3070/rt_ate.c
deleted file mode 100644
index 9238d960121c..000000000000
--- a/drivers/staging/rt3070/rt_ate.c
+++ /dev/null
@@ -1,6506 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-#ifdef UCOS
-INT IoctlResponse(PUCHAR payload, PUCHAR msg, INT len);
-#endif // UCOS //
-
-#define ATE_BBP_REG_NUM 168
-UCHAR restore_BBP[ATE_BBP_REG_NUM]={0};
-
-#ifdef RALINK_ATE
-UCHAR TemplateFrame[24] = {0x08/* Data type */,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
-extern RTMP_RF_REGS RF2850RegTable[];
-extern UCHAR NUM_OF_2850_CHNL;
-
-#ifdef RT2870
-extern UCHAR EpToQueue[];
-extern VOID RTUSBRejectPendingPackets( IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-#ifdef RT30xx
-//2008/07/10:KH adds to support 3070 ATE<--
-extern FREQUENCY_ITEM FreqItems3020[];
-extern UCHAR NUM_OF_3020_CHNL;
-//2008/07/10:KH adds to support 3070 ATE-->
-#endif // RT30xx //
-
-#ifdef UCOS
-extern INT ConsoleResponse(IN PUCHAR buff);
-extern int (*remote_display)(char *);
-#endif // UCOS //
-
-static CHAR CCKRateTable[] = {0, 1, 2, 3, 8, 9, 10, 11, -1}; /* CCK Mode. */
-static CHAR OFDMRateTable[] = {0, 1, 2, 3, 4, 5, 6, 7, -1}; /* OFDM Mode. */
-static CHAR HTMIXRateTable[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}; /* HT Mix Mode. */
-
-static INT TxDmaBusy(
- IN PRTMP_ADAPTER pAd);
-
-static INT RxDmaBusy(
- IN PRTMP_ADAPTER pAd);
-
-static VOID RtmpDmaEnable(
- IN PRTMP_ADAPTER pAd,
- IN INT Enable);
-
-static VOID BbpSoftReset(
- IN PRTMP_ADAPTER pAd);
-
-static VOID RtmpRfIoWrite(
- IN PRTMP_ADAPTER pAd);
-
-static INT ATESetUpFrame(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TxIdx);
-
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index);
-
-static INT ATECmdHandler(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-static int CheckMCSValid(
- IN UCHAR Mode,
- IN UCHAR Mcs);
-
-
-#ifdef RT2870
-static VOID ATEWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst);
-
-static VOID ATEWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR MIMOps,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING Transmit);
-
-#endif // RT2870 //
-
-static VOID SetJapanFilter(
- IN PRTMP_ADAPTER pAd);
-
-/*=========================end of prototype=========================*/
-
-
-#ifdef RT2870
-static INT TxDmaBusy(
- IN PRTMP_ADAPTER pAd)
-{
- INT result;
- USB_DMA_CFG_STRUC UsbCfg;
-
- RTMP_IO_READ32(pAd, USB_DMA_CFG, &UsbCfg.word); // disable DMA
- if (UsbCfg.field.TxBusy)
- result = 1;
- else
- result = 0;
-
- return result;
-}
-
-static INT RxDmaBusy(
- IN PRTMP_ADAPTER pAd)
-{
- INT result;
- USB_DMA_CFG_STRUC UsbCfg;
-
- RTMP_IO_READ32(pAd, USB_DMA_CFG, &UsbCfg.word); // disable DMA
- if (UsbCfg.field.RxBusy)
- result = 1;
- else
- result = 0;
-
- return result;
-}
-
-static VOID RtmpDmaEnable(
- IN PRTMP_ADAPTER pAd,
- IN INT Enable)
-{
- BOOLEAN value;
- ULONG WaitCnt;
- USB_DMA_CFG_STRUC UsbCfg;
-
- value = Enable > 0 ? 1 : 0;
-
- // check DMA is in busy mode.
- WaitCnt = 0;
- while (TxDmaBusy(pAd) || RxDmaBusy(pAd))
- {
- RTMPusecDelay(10);
- if (WaitCnt++ > 100)
- break;
- }
-
- //Why not to clear USB DMA TX path first ???
- RTMP_IO_READ32(pAd, USB_DMA_CFG, &UsbCfg.word); // disable DMA
- UsbCfg.field.TxBulkEn = value;
- UsbCfg.field.RxBulkEn = value;
- RTMP_IO_WRITE32(pAd, USB_DMA_CFG, UsbCfg.word); // abort all TX rings
- RTMPusecDelay(5000);
-
- return;
-}
-#endif // RT2870 //
-
-static VOID BbpSoftReset(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BbpData = 0;
-
- // Soft reset, set BBP R21 bit0=1->0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R21, &BbpData);
- BbpData |= 0x00000001; //set bit0=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R21, BbpData);
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R21, &BbpData);
- BbpData &= ~(0x00000001); //set bit0=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R21, BbpData);
-
- return;
-}
-
-static VOID RtmpRfIoWrite(
- IN PRTMP_ADAPTER pAd)
-{
- // Set RF value 1's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 2's set R3[bit2] = [1]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 | 0x04));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- RTMPusecDelay(200);
-
- // Set RF value 3's set R3[bit2] = [0]
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));
- RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);
-
- return;
-}
-
-static int CheckMCSValid(
- UCHAR Mode,
- UCHAR Mcs)
-{
- int i;
- PCHAR pRateTab;
-
- switch(Mode)
- {
- case 0:
- pRateTab = CCKRateTable;
- break;
- case 1:
- pRateTab = OFDMRateTable;
- break;
- case 2:
- case 3:
- pRateTab = HTMIXRateTable;
- break;
- default:
- ATEDBGPRINT(RT_DEBUG_ERROR, ("unrecognizable Tx Mode %d\n", Mode));
- return -1;
- break;
- }
-
- i = 0;
- while(pRateTab[i] != -1)
- {
- if (pRateTab[i] == Mcs)
- return 0;
- i++;
- }
-
- return -1;
-}
-
-#if 1
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index)
-{
- ULONG R;
- CHAR TxPower;
- UCHAR Bbp94 = 0;
- BOOLEAN bPowerReduce = FALSE;
-#ifdef RT30xx
- UCHAR RFValue;
-#endif // RT30xx //
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
- ** are not synchronized.
- */
-/*
- pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
- pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
-*/
- return 0;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- TxPower = index == 0 ? pAd->ate.TxPower0 : pAd->ate.TxPower1;
-
- if (pAd->ate.Channel <= 14)
- {
- if (TxPower > 31)
- {
- //
- // R3, R4 can't large than 31 (0x24), 31 ~ 36 used by BBP 94
- //
- R = 31;
- if (TxPower <= 36)
- Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
- //
- R = 0;
- if (TxPower >= -6)
- Bbp94 = BBPR94_DEFAULT + TxPower;
- }
- else
- {
- // 0 ~ 31
- R = (ULONG) TxPower;
- Bbp94 = BBPR94_DEFAULT;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94));
- }
- else// 5.5 GHz
- {
- if (TxPower > 15)
- {
- //
- // R3, R4 can't large than 15 (0x0F)
- //
- R = 15;
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0
- //
- // -1 ~ -7
- ASSERT((TxPower >= -7));
- R = (ULONG)(TxPower + 7);
- bPowerReduce = TRUE;
- }
- else
- {
- // 0 ~ 15
- R = (ULONG) TxPower;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __FUNCTION__, TxPower, R));
- }
-//2008/09/10:KH adds to support 3070 ATE TX Power tunning real time<--
-#ifdef RT30xx
- if(IS_RT30xx(pAd))
- {
- // Set Tx Power
-
- RT30xxReadRFRegister(pAd, RF_R12, (PUCHAR)&RFValue);
- RFValue = (RFValue & 0xE0) | TxPower;
- RT30xxWriteRFRegister(pAd, RF_R12, (UCHAR)RFValue);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("3070 or 2070:%s (TxPower=%d, RFValue=%x)\n", __FUNCTION__, TxPower, RFValue));
-
- }
- else
-#endif // RT30xx //
- {
- if (pAd->ate.Channel <= 14)
- {
- if (index == 0)
- {
- R = R << 9; // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = R << 6; // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else// 5.5GHz
- {
- if (bPowerReduce == FALSE)
- {
- if (index == 0)
- {
- R = (R << 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = (R << 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else
- {
- if (index == 0)
- {
- R = (R << 10); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
-
- /* Clear bit 9 of R3 to reduce 7dB. */
- pAd->LatchRfRegs.R3 = (R & (~(1 << 9)));
- }
- else
- {
- R = (R << 7); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
-
- /* Clear bit 6 of R4 to reduce 7dB. */
- pAd->LatchRfRegs.R4 = (R & (~(1 << 6)));
- }
- }
- }
- RtmpRfIoWrite(pAd);
- }
-//2008/09/10:KH adds to support 3070 ATE TX Power tunning real time-->
-
- return 0;
- }
-}
-#else// 1 //
-static INT ATETxPwrHandler(
- IN PRTMP_ADAPTER pAd,
- IN char index)
-{
- ULONG R;
- CHAR TxPower;
- UCHAR Bbp94 = 0;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- // TODO: how to get current TxPower0/1 from pAd->LatchRfRegs ?
- /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
- ** are not synchronized.
- */
-/*
- pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
- pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
-*/
- return 0;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- TxPower = index == 0 ? pAd->ate.TxPower0 : pAd->ate.TxPower1;
-
- if (TxPower > 31)
- {
- //
- // R3, R4 can't large than 36 (0x24), 31 ~ 36 used by BBP 94
- //
- R = 31;
- if (TxPower <= 36)
- Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
- }
- else if (TxPower < 0)
- {
- //
- // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
- //
- R = 0;
- if (TxPower >= -6)
- Bbp94 = BBPR94_DEFAULT + TxPower;
- }
- else
- {
- // 0 ~ 31
- R = (ULONG) TxPower;
- Bbp94 = BBPR94_DEFAULT;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94));
-
- if (pAd->ate.Channel <= 14)
- {
- if (index == 0)
- {
- R = R << 9; // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = R << 6; // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
- else
- {
- if (index == 0)
- {
- R = (R << 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
- R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
- pAd->LatchRfRegs.R3 = R;
- }
- else
- {
- R = (R << 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
- R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
- pAd->LatchRfRegs.R4 = R;
- }
- }
-
- RtmpRfIoWrite(pAd);
-
- return 0;
- }
-}
-#endif // 1 //
-/*
- ==========================================================================
- Description:
- Set ATE operation mode to
- 0. ATESTART = Start ATE Mode
- 1. ATESTOP = Stop ATE Mode
- 2. TXCONT = Continuous Transmit
- 3. TXCARR = Transmit Carrier
- 4. TXFRAME = Transmit Frames
- 5. RXFRAME = Receive Frames
-#ifdef RALINK_28xx_QA
- 6. TXSTOP = Stop Any Type of Transmition
- 7. RXSTOP = Stop Receiving Frames
-#endif // RALINK_28xx_QA //
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-/* */
-/* */
-/*=======================End of RT2860=======================*/
-
-
-/*======================Start of RT2870======================*/
-/* */
-/* */
-
-#ifdef RT2870
-static INT ATECmdHandler(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UINT32 Value;
- UCHAR BbpData;
- UINT32 MacData;
- UINT i=0, atemode;
- //NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- //PUCHAR pDest;
- UINT32 temp;
- ULONG IrqFlags;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> ATECmdHandler()\n"));
- ATEAsicSwitchChannel(pAd);
- /* AsicLockChannel() is empty function so far in fact */
- AsicLockChannel(pAd, pAd->ate.Channel);
-
- RTMPusecDelay(5000);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- /* Enter ATE mode and set Tx/Rx Idle */
- if (!strcmp(arg, "ATESTART"))
- {
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN Cancelled;
-#endif // CONFIG_STA_SUPPORT //
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: ATESTART\n"));
-
- netif_stop_queue(pAd->net_dev);
-
- atemode = pAd->ate.Mode;
- pAd->ate.Mode = ATE_START;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable auto responder
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &temp);
- temp = temp & 0xFFFFFFFE;
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, temp);
-
- // read MAC_SYS_CTRL and backup MAC_SYS_CTRL value.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- // clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
- // Stop continuous TX production test.
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);//disable or cancel pending irp first ???
-
- if (atemode & ATE_TXCARR
-#ifdef RT30xx
- || atemode & ATE_TXCONT
-#endif // RT30xx //
-)
- {
-#ifdef RT30xx
- //Hardware Reset BBP
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &temp);
- temp = temp |0x00000002;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, temp);
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &temp);
- temp = temp & ~(0x00000002);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, temp);
- //Restore All BBP Value
- for(i=0;i<ATE_BBP_REG_NUM;i++)
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd,i,restore_BBP[i]);
-#endif // RT30xx //
-
- // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
-#ifdef RT30xx
- //Hardware Reset BBP
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &temp);
- temp = temp |0x00000002;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, temp);
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &temp);
- temp = temp & ~(0x00000002);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, temp);
- //Restore All BBP Value
- for(i=0;i<ATE_BBP_REG_NUM;i++)
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd,i,restore_BBP[i]);
-#endif // RT30xx //
-
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // No Carrier Suppression set BBP R24 bit0=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
- BbpData &= 0xFFFFFFFE; //clear bit0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
- }
- // We should free some resource which allocate when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
- // TODO:Should we free some resource which was allocated when LoopBack and ATE_STOP ?
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
- if (atemode & ATE_TXCONT)
- {
- // Not Cont. TX anymore, so set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- // Abort Tx, Rx DMA.
- RtmpDmaEnable(pAd, 0);
-
- {
- // It seems nothing to free,
- // because we didn't allocate any resource when we entered ATE_TXFRAME mode latestly.
- }
-
- // Start Tx, RX DMA
- RtmpDmaEnable(pAd, 1);
- }
-
- RTUSBRejectPendingPackets(pAd);
- RTUSBCleanUpDataBulkOutQueue(pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- //
- // It will be called in MlmeSuspend().
- //
- // Cancel pending timers
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-#endif // CONFIG_STA_SUPPORT //
-
- //RTUSBCleanUpMLMEWaitQueue(pAd); /* not used in RT28xx */
- RTUSBCleanUpMLMEBulkOutQueue(pAd);
-
- // Sometimes kernel will hang on, so we avoid calling MlmeSuspend().
-// MlmeSuspend(pAd, TRUE);
- //RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Make sure there are no pending bulk in/out IRPs before we go on.
-/*=========================================================================*/
- /* pAd->PendingRx is not of type atomic_t anymore in 28xx */
-// while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- while ((pAd->PendingRx > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
- NdisInterlockedDecrement(&pAd->PendingRx);
-#endif
- /* delay 0.5 seconds */
- RTMPusecDelay(500000);
- pAd->PendingRx = 0;
- }
- /* peter : why don't we have to get BulkOutLock first ? */
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- /* pAd->BulkOutPending[y] will be set to FALSE in RTUSBCancelPendingBulkOutIRP(pAd) */
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- /* we have enough time delay in RTUSBCancelPendingBulkOutIRP(pAd)
- ** so this is not necessary
- */
-// RTMPusecDelay(500000);
- }
-
- /* pAd->PendingRx is not of type atomic_t anymore in 28xx */
-// ASSERT(atomic_read(&pAd->PendingRx) == 0);
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
-
- // reset Rx statistics.
- pAd->ate.LastSNR0 = 0;
- pAd->ate.LastSNR1 = 0;
- pAd->ate.LastRssi0 = 0;
- pAd->ate.LastRssi1 = 0;
- pAd->ate.LastRssi2 = 0;
- pAd->ate.AvgRssi0 = 0;
- pAd->ate.AvgRssi1 = 0;
- pAd->ate.AvgRssi2 = 0;
- pAd->ate.AvgRssi0X8 = 0;
- pAd->ate.AvgRssi1X8 = 0;
- pAd->ate.AvgRssi2X8 = 0;
- pAd->ate.NumOfAvgRssiSample = 0;
-
-#ifdef RALINK_28xx_QA
- // Tx frame
- pAd->ate.bQATxStart = FALSE;
- pAd->ate.bQARxStart = FALSE;
- pAd->ate.seq = 0;
-
- // counters
- pAd->ate.U2M = 0;
- pAd->ate.OtherData = 0;
- pAd->ate.Beacon = 0;
- pAd->ate.OtherCount = 0;
- pAd->ate.TxAc0 = 0;
- pAd->ate.TxAc1 = 0;
- pAd->ate.TxAc2 = 0;
- pAd->ate.TxAc3 = 0;
- pAd->ate.TxHCCA = 0;
- pAd->ate.TxMgmt = 0;
- pAd->ate.RSSI0 = 0;
- pAd->ate.RSSI1 = 0;
- pAd->ate.RSSI2 = 0;
- pAd->ate.SNR0 = 0;
- pAd->ate.SNR1 = 0;
-
- // control
- pAd->ate.TxDoneCount = 0;
- pAd->ate.TxStatus = 0; // task Tx status // 0 --> task is idle, 1 --> task is running
-#endif // RALINK_28xx_QA //
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
-
-#ifdef CONFIG_STA_SUPPORT
- AsicDisableSync(pAd);
-
- /*
- ** If we skip "LinkDown()", we should disable protection
- ** to prevent from sending out RTS or CTS-to-self.
- */
- ATEDisableAsicProtect(pAd);
- RTMPStationStop(pAd);
-#endif // CONFIG_STA_SUPPORT //
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
-
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
- //Clean ATE Bulk in/out counter and continue setup
- InterlockedExchange(&pAd->BulkOutRemained, 0);
-
- /* NdisAcquireSpinLock()/NdisReleaseSpinLock() need only one argument in RT28xx */
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = FALSE;
- pAd->ContinBulkIn = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
- }
- else if (!strcmp(arg, "ATESTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE : ATESTOP ===>\n"));
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);//0820
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData); // recover the MAC_SYS_CTRL register back.
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- /*
- ** Abort Tx, RX DMA.
- ** Q : How to do the following I/O if Tx, Rx DMA is aborted ?
- ** Ans : Bulk endpoints are aborted, while the control endpoint is not.
- */
- RtmpDmaEnable(pAd, 0);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- /* Make sure there are no pending bulk in/out IRPs before we go on. */
-/*=========================================================================*/
-// while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- while (pAd->PendingRx > 0)
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
-// NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-#endif
- RTMPusecDelay(500000);
- }
-
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- RTMPusecDelay(500000);
- }
-
-// ASSERT(atomic_read(&pAd->PendingRx) == 0);
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
-/* Reset Rx RING */
-/*=========================================================================*/
-// InterlockedExchange(&pAd->PendingRx, 0);
- pAd->PendingRx = 0;
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = RX_RING_SIZE - 1; // Rx Bulk pointer
- pAd->NextRxBulkInPosition = 0;
- for (i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
- NdisZeroMemory(pRxContext->TransferBuffer, MAX_RXBULK_SIZE);
- /* peter : why don't we have to get BulkInLock first ? */
- pRxContext->pAd = pAd;
- pRxContext->pIrp = NULL;
- /* peter debug ++ */
- pRxContext->BulkInOffset = 0;
- pRxContext->bRxHandling = FALSE;
- /* peter debug -- */
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
-// pRxContext->ReorderInUse = FALSE;
-// pRxContext->ReadPosOffset = 0;
- }
-
-/*=========================================================================*/
-/* Reset Tx RING */
-/*=========================================================================*/
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
-/*=========================================================================*/
- // Enable auto responder.
- RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &temp);
- temp = temp | (0x01);
- RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, temp);
-
-/*================================================*/
- AsicEnableBssSync(pAd);
-
- /* Soft reset BBP.*/
- /* In 2870 chipset, ATE_BBP_IO_READ8_BY_REG_ID() == RTMP_BBP_IO_READ8_BY_REG_ID() */
- /* Both rt2870ap and rt2870sta use BbpSoftReset(pAd) to do BBP soft reset */
- BbpSoftReset(pAd);
-/*================================================*/
- {
-#ifdef CONFIG_STA_SUPPORT
- // Set all state machines back IDLE
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
-#endif // CONFIG_STA_SUPPORT //
-
- //
- // ===> refer to MlmeRestartStateMachine().
- // When we entered ATE_START mode, PeriodicTimer was not cancelled.
- // So we don't have to set it here.
- //
- //RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
-
- ASSERT(pAd->CommonCfg.Channel != 0);
-
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
-
-#ifdef CONFIG_STA_SUPPORT
- RTMPStationStart(pAd);
-#endif // CONFIG_STA_SUPPORT //
- }
-//
-// These two steps have been done when entering ATE_STOP mode.
-//
- // Clean ATE Bulk in/out counter and continue setup.
- InterlockedExchange(&pAd->BulkOutRemained, 0);
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = FALSE;
- pAd->ContinBulkIn = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- /* Wait 50ms to prevent next URB to bulkout during HW reset. */
- /* todo : remove this if not necessary */
- NdisMSleep(50000);
-
- pAd->ate.Mode = ATE_STOP;
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-/*=========================================================================*/
- /* restore RX_FILTR_CFG */
-#ifdef CONFIG_STA_SUPPORT
- /* restore RX_FILTR_CFG in order that QA maybe set it to 0x3 */
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL);
-#endif // CONFIG_STA_SUPPORT //
-/*=========================================================================*/
-
- // Enable Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Wait 10ms to wait all of the bulk-in URBs to complete.
- /* todo : remove this if not necessary */
- NdisMSleep(10000);
-
- // Everything is ready to start normal Tx/Rx.
- RTUSBBulkReceive(pAd);
- netif_start_queue(pAd->net_dev);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== ATE : ATESTOP \n"));
- }
- else if (!strcmp(arg, "TXCARR")) // Tx Carrier
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXCARR\n"));
- pAd->ate.Mode |= ATE_TXCARR;
-
-#ifdef RT30xx
- for(i=0;i<ATE_BBP_REG_NUM;i++)
- restore_BBP[i]=0;
- //Record All BBP Value
- for(i=0;i<ATE_BBP_REG_NUM;i++)
- ATE_BBP_IO_READ8_BY_REG_ID(pAd,i,&restore_BBP[i]);
-#endif // RT30xx //
-
- // Disable Rx
- // May be we need not to do this, because these have been done in ATE_START mode ???
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // QA has done the following steps if it is used.
- if (pAd->ate.bQATxStart == FALSE)
- {
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Carrier Test set BBP R22 bit7=1, bit6=1, bit[5~0]=0x01
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- BbpData |= 0x000000C1; //set bit7=1, bit6=1, bit[5~0]=0x01
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value = Value | 0x00000010;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
- }
- else if (!strcmp(arg, "TXCONT")) // Tx Continue
- {
- if (pAd->ate.bQATxStart == TRUE)
- {
- /* set MAC_SYS_CTRL(0x1004) bit4(Continuous Tx Production Test)
- and bit2(MAC TX enable) back to zero. */
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData &= 0xFFFFFFEB;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- // set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF7F; //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
-
- /* for TxCont mode.
- ** Step 1: Send 50 packets first then wait for a moment.
- ** Step 2: Send more 50 packet then start continue mode.
- */
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXCONT\n"));
-
-#ifdef RT30xx
- for(i=0;i<ATE_BBP_REG_NUM;i++)
- restore_BBP[i]=0;
- //Record All BBP Value
- for(i=0;i<ATE_BBP_REG_NUM;i++)
- ATE_BBP_IO_READ8_BY_REG_ID(pAd,i,&restore_BBP[i]);
-#endif // RT30xx //
-
- // Step 1: send 50 packets first.
- pAd->ate.Mode |= ATE_TXCONT;
- pAd->ate.TxCount = 50;
- pAd->ate.TxDoneCount = 0;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
-
- /* Only needed if we have to send some normal frames. */
- SetJapanFilter(pAd);
-
- // Setup frame format.
- ATESetUpFrame(pAd, 0);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- InterlockedExchange(&pAd->BulkOutRemained, pAd->ate.TxCount);
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#endif // RALINK_28xx_QA //
-
- NdisAcquireSpinLock(&pAd->GenericLock);//0820
- pAd->ContinBulkOut = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
-
- /* To make sure all the 50 frames have been bulk out before executing step 2 */
- while (atomic_read(&pAd->BulkOutRemained) > 0)
- {
- RTMPusecDelay(5000);
- }
-
- // Step 2: send more 50 packets then start continue mode.
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Cont. TX set BBP R22 bit7=1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData |= 0x00000080; //set bit7=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- pAd->ate.TxCount = 50;
- pAd->ate.TxDoneCount = 0;
-
- SetJapanFilter(pAd);
-
- // Setup frame format.
- ATESetUpFrame(pAd, 0);
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- InterlockedExchange(&pAd->BulkOutRemained, pAd->ate.TxCount);
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#endif // RALINK_28xx_QA //
-
- NdisAcquireSpinLock(&pAd->GenericLock);//0820
- pAd->ContinBulkOut = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
-
-#if 1
- RTMPusecDelay(500);
-#else
- while (atomic_read(&pAd->BulkOutRemained) > 0)
- {
- RTMPusecDelay(5000);
- }
-#endif // 1 //
-
- // Set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1.
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData |= 0x00000010;
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
- }
- else if (!strcmp(arg, "TXFRAME")) // Tx Frames
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXFRAME(Count=0x%08x)\n", pAd->ate.TxCount));
- pAd->ate.Mode |= ATE_TXFRAME;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
-
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
-#ifdef RALINK_28xx_QA
- // add this for LoopBack mode
- if (pAd->ate.bQARxStart == FALSE)
- {
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
- }
-
- if (pAd->ate.bQATxStart == TRUE)
- {
- pAd->ate.TxStatus = 1;
- //pAd->ate.Repeat = 0;
- }
-#else
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-#endif // RALINK_28xx_QA //
-
- // Enable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- SetJapanFilter(pAd);
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- pAd->ate.TxDoneCount = 0;
-
- // Setup frame format
- ATESetUpFrame(pAd, 0);
-
- // Start Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Check count is continuous or not yet.
- //
- // Due to the type mismatch between "pAd->BulkOutRemained"(atomic_t) and "pAd->ate.TxCount"(UINT32)
- //
- if (pAd->ate.TxCount == 0)
- {
- InterlockedExchange(&pAd->BulkOutRemained, 0);
- }
- else
- {
- InterlockedExchange(&pAd->BulkOutRemained, pAd->ate.TxCount);
- }
- ATEDBGPRINT(RT_DEBUG_TRACE, ("bulk out count = %d\n", atomic_read(&pAd->BulkOutRemained)));
- ASSERT((atomic_read(&pAd->BulkOutRemained) >= 0));
-
- if (atomic_read(&pAd->BulkOutRemained) == 0)
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Send packet countinuously\n"));
-
- /* In 28xx, NdisAcquireSpinLock() == spin_lock_bh() */
- /* NdisAcquireSpinLock only need one argument in 28xx. */
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = TRUE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- /* In 28xx, BULK_OUT_LOCK() == spin_lock_irqsave() */
- BULK_OUT_LOCK(&pAd->BulkOutLock[0], IrqFlags);// peter : NdisAcquireSpinLock ==> BULK_OUT_LOCK
- pAd->BulkOutPending[0] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);// peter : NdisAcquireSpinLock ==> BULK_OUT_LOCK
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Send packets depend on counter\n"));
-
- NdisAcquireSpinLock(&pAd->GenericLock);
- pAd->ContinBulkOut = FALSE;
- NdisReleaseSpinLock(&pAd->GenericLock);
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[0], IrqFlags);
- pAd->BulkOutPending[0] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
- }
-
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-
- // Kick bulk out
- RTUSBKickBulkOut(pAd);
- }
-#ifdef RALINK_28xx_QA
- else if (!strcmp(arg, "TXSTOP")) //Enter ATE mode and set Tx/Rx Idle
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: TXSTOP\n"));
-
- atemode = pAd->ate.Mode;
- pAd->ate.Mode &= ATE_TXSTOP;
- pAd->ate.bQATxStart = FALSE;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
-
-/*=========================================================================*/
- if (atemode & ATE_TXCARR)
- {
- // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- else if (atemode & ATE_TXCARRSUPP)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
-
- // No Carrier Suppression set BBP R24 bit0=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
- BbpData &= 0xFFFFFFFE; //clear bit0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
- }
- else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
- {
- if (atemode & ATE_TXCONT)
- {
- // No Cont. TX set BBP R22 bit7=0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
- BbpData &= ~(1 << 7); //set bit7=0
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- }
- }
-
-/*=========================================================================*/
- RTUSBRejectPendingPackets(pAd);
- RTUSBCleanUpDataBulkOutQueue(pAd);
-
- /* not used in RT28xx */
- //RTUSBCleanUpMLMEWaitQueue(pAd);
- /* empty function so far */
- RTUSBCleanUpMLMEBulkOutQueue(pAd);
-/*=========================================================================*/
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-/*=========================================================================*/
-
- /* In 28xx, pAd->PendingRx is not of type atomic_t anymore */
-// while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
- /* peter todo : BulkInLock */
- while (pAd->PendingRx > 0)
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
-// NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-#endif
- RTMPusecDelay(500000);
- }
-
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- RTMPusecDelay(500000);
- }
-
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
- // Enable Tx, Rx DMA.
- RtmpDmaEnable(pAd, 1);
-
- /* task Tx status : 0 --> task is idle, 1 --> task is running */
- pAd->ate.TxStatus = 0;
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
-
- // Disable Tx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- MacData &= (0xfffffffb);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- //Clean ATE Bulk in/out counter and continue setup
- InterlockedExchange(&pAd->BulkOutRemained, 0);
-
- pAd->ContinBulkOut = FALSE;
- }
- else if (!strcmp(arg, "RXSTOP"))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: RXSTOP\n"));
- atemode = pAd->ate.Mode;
-
- // Disable Rx
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- pAd->ate.Mode &= ATE_RXSTOP;
- pAd->ate.bQARxStart = FALSE;
-// pAd->ate.TxDoneCount = pAd->ate.TxCount;
-
-/*=========================================================================*/
- RTUSBRejectPendingPackets(pAd);
- RTUSBCleanUpDataBulkOutQueue(pAd);
-
- /* not used in RT28xx */
- //RTUSBCleanUpMLMEWaitQueue(pAd);
- RTUSBCleanUpMLMEBulkOutQueue(pAd);
-/*=========================================================================*/
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-/*=========================================================================*/
-// while ((atomic_read(&pAd->PendingRx) > 0))
- while (pAd->PendingRx > 0)
- {
-#if 1
- ATE_RTUSBCancelPendingBulkInIRP(pAd);
-#else
-// NdisInterlockedDecrement(&pAd->PendingRx);
- pAd->PendingRx--;
-#endif
- RTMPusecDelay(500000);
- }
-
- while (((pAd->BulkOutPending[0] == TRUE) ||
- (pAd->BulkOutPending[1] == TRUE) ||
- (pAd->BulkOutPending[2] == TRUE) ||
- (pAd->BulkOutPending[3] == TRUE)) && (pAd->BulkFlags != 0)) //pAd->BulkFlags != 0 wait bulk out finish
- {
- do
- {
- RTUSBCancelPendingBulkOutIRP(pAd);
- } while (FALSE);
-
- RTMPusecDelay(500000);
- }
-
- ASSERT(pAd->PendingRx == 0);
-/*=========================================================================*/
-
- // Soft reset BBP.
- BbpSoftReset(pAd);
- pAd->ContinBulkIn = FALSE;
- }
-#endif // RALINK_28xx_QA //
- else if (!strcmp(arg, "RXFRAME")) // Rx Frames
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: RXFRAME\n"));
-
- // Disable Rx of MAC block
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Default value in BBP R22 is 0x0.
- BbpData = 0;
-
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
- // Clean bit4 to stop continuous Tx production test.
- MacData &= 0xFFFFFFEF;
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
-
- pAd->ate.Mode |= ATE_RXFRAME;
-
- // Abort Tx, RX DMA.
- RtmpDmaEnable(pAd, 0);
-
- // Disable TX of MAC block
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value &= ~(1 << 2);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Reset Rx RING.
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- PRX_CONTEXT pRxContext = &(pAd->RxContext[i]);
-
- pRxContext->InUse = FALSE;
- pRxContext->IRPPending = FALSE;
- pRxContext->Readable = FALSE;
-
- //
- // Get the urb from kernel back to driver.
- //
- RTUSB_UNLINK_URB(pRxContext->pUrb);
-
- /* Sleep 200 microsecs to give cancellation time to work. */
- NdisMSleep(200);
- pAd->BulkInReq = 0;
-
-// InterlockedExchange(&pAd->PendingRx, 0);
- pAd->PendingRx = 0;
- pAd->NextRxBulkInReadIndex = 0; // Next Rx Read index
- pAd->NextRxBulkInIndex = RX_RING_SIZE - 1; // Rx Bulk pointer
- pAd->NextRxBulkInPosition = 0;
- }
-
- // read to clear counters
- RTUSBReadMACRegister(pAd, RX_STA_CNT0, &temp); //RX PHY & RX CRC count
- RTUSBReadMACRegister(pAd, RX_STA_CNT1, &temp); //RX PLCP error count & CCA false alarm count
- RTUSBReadMACRegister(pAd, RX_STA_CNT2, &temp); //RX FIFO overflow frame count & RX duplicated filtered frame count
-
- pAd->ContinBulkIn = TRUE;
-
- // Enable Tx, RX DMA.
- RtmpDmaEnable(pAd, 1);
-
- // Enable RX of MAC block
- RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
- Value |= (1 << 3);
- RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
- // Kick bulk in
- RTUSBBulkReceive(pAd);
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: Invalid arg!\n"));
- return FALSE;
- }
- RTMPusecDelay(5000);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== ATECmdHandler()\n"));
-
- return TRUE;
-}
-#endif // RT2870 //
-
-INT Set_ATE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (ATECmdHandler(pAd, arg))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_Proc Success\n"));
-
-
- return TRUE;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_Proc Failed\n"));
- return FALSE;
- }
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR1=DA for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_DA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr3[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_DA_Proc (DA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr3[0],
- pAd->ate.Addr3[1], pAd->ate.Addr3[2], pAd->ate.Addr3[3], pAd->ate.Addr3[4], pAd->ate.Addr3[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_DA_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR3=SA for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR2=SA for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_SA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr2[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_SA_Proc (SA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr2[0],
- pAd->ate.Addr2[1], pAd->ate.Addr2[2], pAd->ate.Addr2[3], pAd->ate.Addr2[4], pAd->ate.Addr2[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_SA_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE ADDR2=BSSID for TxFrame(AP : To DS = 0 ; From DS = 1)
- or
- Set ATE ADDR1=BSSID for TxFrame(STA : To DS = 1 ; From DS = 0)
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_BSSID_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *value;
- INT i;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- AtoH(value, &pAd->ate.Addr1[i++], 1);
-#endif // CONFIG_STA_SUPPORT //
- }
-
- if(i != 6)
- return FALSE; //Invalid
-
-
-#ifdef CONFIG_STA_SUPPORT
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_BSSID_Proc (BSSID = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd->ate.Addr1[0],
- pAd->ate.Addr1[1], pAd->ate.Addr1[2], pAd->ate.Addr1[3], pAd->ate.Addr1[4], pAd->ate.Addr1[5]));
-#endif // CONFIG_STA_SUPPORT //
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_BSSID_Proc Success\n"));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Channel
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_CHANNEL_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR channel;
-
- channel = simple_strtol(arg, 0, 10);
-
- if ((channel < 1) || (channel > 216))// to allow A band channel : ((channel < 1) || (channel > 14))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_CHANNEL_Proc::Out of range, it should be in range of 1~14.\n"));
- return FALSE;
- }
- pAd->ate.Channel = channel;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAd->ate.Channel));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_CHANNEL_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Power0
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_POWER0_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR TxPower;
-
- TxPower = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.Channel <= 14)
- {
- if ((TxPower > 31) || (TxPower < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
- else// 5.5GHz
- {
- if ((TxPower > 15) || (TxPower < -7))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
-
- pAd->ate.TxPower0 = TxPower;
- ATETxPwrHandler(pAd, 0);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER0_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Power1
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_POWER1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR TxPower;
-
- TxPower = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.Channel <= 14)
- {
- if ((TxPower > 31) || (TxPower < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
- else
- {
- if ((TxPower > 15) || (TxPower < -7))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower));
- return FALSE;
- }
- }
-
- pAd->ate.TxPower1 = TxPower;
- ATETxPwrHandler(pAd, 1);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER1_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx Antenna
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR value;
-
- value = simple_strtol(arg, 0, 10);
-
- if ((value > 2) || (value < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_Antenna_Proc::Out of range (Value=%d)\n", value));
- return FALSE;
- }
-
- pAd->ate.TxAntennaSel = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_Antenna_Proc (Antenna = %d)\n", pAd->ate.TxAntennaSel));
- ATEDBGPRINT(RT_DEBUG_TRACE,("Ralink: Set_ATE_TX_Antenna_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Rx Antenna
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_RX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR value;
-
- value = simple_strtol(arg, 0, 10);
-
- if ((value > 3) || (value < 0))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_RX_Antenna_Proc::Out of range (Value=%d)\n", value));
- return FALSE;
- }
-
- pAd->ate.RxAntennaSel = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_Antenna_Proc (Antenna = %d)\n", pAd->ate.RxAntennaSel));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_Antenna_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE RF frequence offset
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_FREQOFFSET_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR RFFreqOffset;
- ULONG R4;
-
- RFFreqOffset = simple_strtol(arg, 0, 10);
-#ifndef RT30xx
- if(RFFreqOffset >= 64)
-#endif // RT30xx //
-#ifdef RT30xx
-//2008/08/06: KH modified the limit of offset value from 65 to 95(0x5F)
- if(RFFreqOffset >= 95)
-#endif // RT30xx //
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_FREQOFFSET_Proc::Out of range, it should be in range of 0~63.\n"));
- return FALSE;
- }
-
- pAd->ate.RFFreqOffset = RFFreqOffset;
-#ifdef RT30xx
- if(IS_RT30xx(pAd))
- {
- // Set RF offset
- UCHAR RFValue;
- RT30xxReadRFRegister(pAd, RF_R23, (PUCHAR)&RFValue);
- //2008/08/06: KH modified "pAd->RFFreqOffset" to "pAd->ate.RFFreqOffset"
- RFValue = (RFValue & 0x80) | pAd->ate.RFFreqOffset;
- RT30xxWriteRFRegister(pAd, RF_R23, (UCHAR)RFValue);
- }
- else
-#endif // RT30xx //
- {
-
- R4 = pAd->ate.RFFreqOffset << 15; // shift TX power control to correct RF register bit position
- R4 |= (pAd->LatchRfRegs.R4 & ((~0x001f8000)));
- pAd->LatchRfRegs.R4 = R4;
-
- RtmpRfIoWrite(pAd);
- }
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_FREQOFFSET_Proc (RFFreqOffset = %d)\n", pAd->ate.RFFreqOffset));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_FREQOFFSET_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE RF BW
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_BW_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- int i;
- UCHAR value = 0;
- UCHAR BBPCurrentBW;
-
- BBPCurrentBW = simple_strtol(arg, 0, 10);
-
- if(BBPCurrentBW == 0)
- pAd->ate.TxWI.BW = BW_20;
- else
- pAd->ate.TxWI.BW = BW_40;
-
- if(pAd->ate.TxWI.BW == BW_20)
- {
- if(pAd->ate.Channel <= 14)
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx20MPwrCfgGBand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgGBand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
- else
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx20MPwrCfgABand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgABand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
-
- //Set BBP R4 bit[4:3]=0:0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value &= (~0x18);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
-
- //Set BBP R66=0x3C
- value = 0x3C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
- //Set BBP R68=0x0B
- //to improve Rx sensitivity.
- value = 0x0B;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R68, value);
- //Set BBP R69=0x16
- value = 0x16;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, value);
- //Set BBP R70=0x08
- value = 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, value);
- //Set BBP R73=0x11
- value = 0x11;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, value);
-
- // If Channel=14, Bandwidth=20M and Mode=CCK, Set BBP R4 bit5=1
- // (Japan filter coefficients)
- // This segment of code will only works when ATETXMODE and ATECHANNEL
- // were set to MODE_CCK and 14 respectively before ATETXBW is set to 0.
- //=====================================================================
- if (pAd->ate.Channel == 14)
- {
- int TxMode = pAd->ate.TxWI.PHYMODE;
- if (TxMode == MODE_CCK)
- {
- // when Channel==14 && Mode==CCK && BandWidth==20M, BBP R4 bit5=1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value |= 0x20; //set bit5=1
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
- }
- }
-
- //=====================================================================
- // If bandwidth != 40M, RF Reg4 bit 21 = 0.
-#ifdef RT30xx
- // Set BW
- if(IS_RT30xx(pAd))
- RT30xxWriteRFRegister(pAd, RF_R24, (UCHAR) pAd->Mlme.CaliBW20RfR24);
- else
-#endif // RT30xx //
- {
- pAd->LatchRfRegs.R4 &= ~0x00200000;
- RtmpRfIoWrite(pAd);
- }
-
- }
- else if(pAd->ate.TxWI.BW == BW_40)
- {
- if(pAd->ate.Channel <= 14)
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx40MPwrCfgGBand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgGBand[i]);
- RTMPusecDelay(5000);
- }
- }
- }
- else
- {
- for (i=0; i<5; i++)
- {
- if (pAd->Tx40MPwrCfgABand[i] != 0xffffffff)
- {
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgABand[i]);
- RTMPusecDelay(5000);
- }
- }
-#ifdef DOT11_N_SUPPORT
- if ((pAd->ate.TxWI.PHYMODE >= MODE_HTMIX) && (pAd->ate.TxWI.MCS == 7))
- {
- value = 0x28;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R67, value);
- }
-#endif // DOT11_N_SUPPORT //
- }
-
- //Set BBP R4 bit[4:3]=1:0
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
- value &= (~0x18);
- value |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
-
- //Set BBP R66=0x3C
- value = 0x3C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
- //Set BBP R68=0x0C
- //to improve Rx sensitivity.
- value = 0x0C;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R68, value);
- //Set BBP R69=0x1A
- value = 0x1A;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, value);
- //Set BBP R70=0x0A
- value = 0x0A;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, value);
- //Set BBP R73=0x16
- value = 0x16;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, value);
-
- // If bandwidth = 40M, set RF Reg4 bit 21 = 1.
-#ifdef RT30xx
- // Set BW
- if(IS_RT30xx(pAd))
- RT30xxWriteRFRegister(pAd, RF_R24, (UCHAR) pAd->Mlme.CaliBW40RfR24);
- else
-#endif // RT30xx //
- {
- pAd->LatchRfRegs.R4 |= 0x00200000;
- RtmpRfIoWrite(pAd);
- }
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_BW_Proc (BBPCurrentBW = %d)\n", pAd->ate.TxWI.BW));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_BW_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame length
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_LENGTH_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxLength = simple_strtol(arg, 0, 10);
-
- if((pAd->ate.TxLength < 24) || (pAd->ate.TxLength > (MAX_FRAME_SIZE - 34/* == 2312 */)))
- {
- pAd->ate.TxLength = (MAX_FRAME_SIZE - 34/* == 2312 */);
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_LENGTH_Proc::Out of range, it should be in range of 24~%d.\n", (MAX_FRAME_SIZE - 34/* == 2312 */)));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_LENGTH_Proc (TxLength = %d)\n", pAd->ate.TxLength));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_LENGTH_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame count
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_COUNT_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxCount = simple_strtol(arg, 0, 10);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAd->ate.TxCount));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame MCS
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_MCS_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR MCS;
- int result;
-
- MCS = simple_strtol(arg, 0, 10);
- result = CheckMCSValid(pAd->ate.TxWI.PHYMODE, MCS);
-
- if (result != -1)
- {
- pAd->ate.TxWI.MCS = (UCHAR)MCS;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MCS_Proc::Out of range, refer to rate table.\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MCS_Proc (MCS = %d)\n", pAd->ate.TxWI.MCS));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MCS_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame Mode
- 0: MODE_CCK
- 1: MODE_OFDM
- 2: MODE_HTMIX
- 3: MODE_HTGREENFIELD
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_MODE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxWI.PHYMODE = simple_strtol(arg, 0, 10);
-
- if(pAd->ate.TxWI.PHYMODE > 3)
- {
- pAd->ate.TxWI.PHYMODE = 0;
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MODE_Proc::Out of range. it should be in range of 0~3\n"));
- ATEDBGPRINT(RT_DEBUG_ERROR, ("0: CCK, 1: OFDM, 2: HT_MIX, 3: HT_GREEN_FIELD.\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MODE_Proc (TxMode = %d)\n", pAd->ate.TxWI.PHYMODE));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MODE_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set ATE Tx frame GI
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_ATE_TX_GI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.TxWI.ShortGI = simple_strtol(arg, 0, 10);
-
- if(pAd->ate.TxWI.ShortGI > 1)
- {
- pAd->ate.TxWI.ShortGI = 0;
- ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_GI_Proc::Out of range\n"));
- return FALSE;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_GI_Proc (GI = %d)\n", pAd->ate.TxWI.ShortGI));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_GI_Proc Success\n"));
-
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-INT Set_ATE_RX_FER_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- pAd->ate.bRxFer = simple_strtol(arg, 0, 10);
-
- if (pAd->ate.bRxFer == 1)
- {
- pAd->ate.RxCntPerSec = 0;
- pAd->ate.RxTotalCnt = 0;
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_FER_Proc (bRxFer = %d)\n", pAd->ate.bRxFer));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_FER_Proc Success\n"));
-
-
- return TRUE;
-}
-
-INT Set_ATE_Read_RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-#ifdef RT30xx
-//2008/07/10:KH add to support RT30xx ATE<--
- if(IS_RT30xx(pAd))
- {
- /* modify by WY for Read RF Reg. error */
- UCHAR RFValue;
- INT index=0;
- for (index = 0; index < 32; index++)
- {
- RT30xxReadRFRegister(pAd, index, (PUCHAR)&RFValue);
- printk("R%d=%d\n",index,RFValue);
- }
- }
- else
-//2008/07/10:KH add to support RT30xx ATE-->
-#endif // RT30xx //
- {
- ate_print(KERN_EMERG "R1 = %lx\n", pAd->LatchRfRegs.R1);
- ate_print(KERN_EMERG "R2 = %lx\n", pAd->LatchRfRegs.R2);
- ate_print(KERN_EMERG "R3 = %lx\n", pAd->LatchRfRegs.R3);
- ate_print(KERN_EMERG "R4 = %lx\n", pAd->LatchRfRegs.R4);
- }
- return TRUE;
-}
-
-INT Set_ATE_Write_RF1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-#ifdef RT30xx
-//2008/07/10:KH add to support 3070 ATE<--
- if(IS_RT30xx(pAd))
- {
- printk("Warning!! RT30xx Don't Support\n");
- return FALSE;
-
- }
- else
-//2008/07/10:KH add to support 3070 ATE-->
-#endif // RT30xx //
- {
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R1 = value;
- RtmpRfIoWrite(pAd);
- }
- return TRUE;
-
-}
-
-INT Set_ATE_Write_RF2_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-#ifdef RT30xx
-//2008/07/10:KH add to support 3070 ATE<--
- if(IS_RT30xx(pAd))
- {
- printk("Warning!! RT30xx Don't Support\n");
- return FALSE;
-
- }
- else
-//2008/07/10:KH add to support 3070 ATE-->
-#endif // RT30xx //
- {
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R2 = value;
- RtmpRfIoWrite(pAd);
- }
- return TRUE;
-}
-
-INT Set_ATE_Write_RF3_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-#ifdef RT30xx
-//2008/07/10:KH add to support 3070 ATE<--
- if(IS_RT30xx(pAd))
- {
- printk("Warning!! RT30xx Don't Support\n");
- return FALSE;
-
- }
- else
-//2008/07/10:KH add to support 3070 ATE-->
-#endif // RT30xx //
- {
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R3 = value;
- RtmpRfIoWrite(pAd);
- }
- return TRUE;
-}
-
-INT Set_ATE_Write_RF4_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-#ifdef RT30xx
-//2008/07/10:KH add to support 3070 ATE<--
- if(IS_RT30xx(pAd))
- {
- printk("Warning!! RT30xx Don't Support\n");
- return FALSE;
-
- }
- else
-//2008/07/10:KH add to support 3070 ATE-->
-#endif // RT30xx //
- {
- UINT32 value = simple_strtol(arg, 0, 16);
-
- pAd->LatchRfRegs.R4 = value;
- RtmpRfIoWrite(pAd);
- }
- return TRUE;
-}
-#ifdef RT30xx
-//2008/07/10:KH add to support 3070 ATE<--
-INT SET_ATE_3070RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- CHAR *this_char;
- CHAR *value;
- UINT32 Reg,RFValue;
- if(IS_RT30xx(pAd))
- {
- printk("SET_ATE_3070RF_Proc=%s\n",arg);
- this_char =arg;
- if ((value = strchr(this_char, ':')) != NULL)
- *value++ = 0;
- Reg= simple_strtol(this_char, 0, 16);
- RFValue= simple_strtol(value, 0, 16);
- printk("RF Reg[%d]=%d\n",Reg,RFValue);
- RT30xxWriteRFRegister(pAd, Reg,RFValue);
- }
- else
- printk("Warning!! Only 3070 Support\n");
- return TRUE;
-}
-//2008/07/10:KH add to support 3070 ATE-->
-#endif // RT30xx //
-/*
- ==========================================================================
- Description:
- Load and Write EEPROM from a binary file prepared in advance.
-
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-#ifndef UCOS
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN ret = FALSE;
- PUCHAR src = EEPROM_BIN_FILE_NAME;
- struct file *srcf;
- INT32 retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- USHORT WriteEEPROM[(EEPROM_SIZE/2)];
- UINT32 FileLength = 0;
- UINT32 value = simple_strtol(arg, 0, 10);
-
- ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __FUNCTION__, value));
-
- if (value > 0)
- {
- /* zero the e2p buffer */
- NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
-
- /* save uid and gid used for filesystem access.
- ** set user and group to 0 (root)
- */
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- /* as root */
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- do
- {
- /* open the bin file */
- srcf = filp_open(src, O_RDONLY, 0);
-
- if (IS_ERR(srcf))
- {
- ate_print("%s - Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(srcf), src);
- break;
- }
-
- /* the object must have a read method */
- if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
- {
- ate_print("%s - %s does not have a read method\n", __FUNCTION__, src);
- break;
- }
-
- /* read the firmware from the file *.bin */
- FileLength = srcf->f_op->read(srcf,
- (PUCHAR)WriteEEPROM,
- EEPROM_SIZE,
- &srcf->f_pos);
-
- if (FileLength != EEPROM_SIZE)
- {
- ate_print("%s: error file length (=%d) in e2p.bin\n",
- __FUNCTION__, FileLength);
- break;
- }
- else
- {
- /* write the content of .bin file to EEPROM */
- rt_ee_write_all(pAd, WriteEEPROM);
- ret = TRUE;
- }
- break;
- } while(TRUE);
-
- /* close firmware file */
- if (IS_ERR(srcf))
- {
- ;
- }
- else
- {
- retval = filp_close(srcf, NULL);
- if (retval)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("--> Error %d closing %s\n", -retval, src));
-
- }
- }
-
- /* restore */
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
- }
- ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __FUNCTION__, ret));
-
- return ret;
-
-}
-#else
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT WriteEEPROM[(EEPROM_SIZE/2)];
- struct iwreq *wrq = (struct iwreq *)arg;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __FUNCTION__, wrq->u.data.length));
-
- if (wrq->u.data.length != EEPROM_SIZE)
- {
- ate_print("%s: error length (=%d) from host\n",
- __FUNCTION__, wrq->u.data.length);
- return FALSE;
- }
- else/* (wrq->u.data.length == EEPROM_SIZE) */
- {
- /* zero the e2p buffer */
- NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
-
- /* fill the local buffer */
- NdisMoveMemory((PUCHAR)WriteEEPROM, wrq->u.data.pointer, wrq->u.data.length);
-
- do
- {
- /* write the content of .bin file to EEPROM */
- rt_ee_write_all(pAd, WriteEEPROM);
-
- } while(FALSE);
- }
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __FUNCTION__));
-
- return TRUE;
-
-}
-#endif // !UCOS //
-
-INT Set_ATE_Read_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- USHORT buffer[EEPROM_SIZE/2];
- USHORT *p;
- int i;
-
- rt_ee_read_all(pAd, (USHORT *)buffer);
- p = buffer;
- for (i = 0; i < (EEPROM_SIZE/2); i++)
- {
- ate_print("%4.4x ", *p);
- if (((i+1) % 16) == 0)
- ate_print("\n");
- p++;
- }
- return TRUE;
-}
-
-INT Set_ATE_Show_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print("Mode=%d\n", pAd->ate.Mode);
- ate_print("TxPower0=%d\n", pAd->ate.TxPower0);
- ate_print("TxPower1=%d\n", pAd->ate.TxPower1);
- ate_print("TxAntennaSel=%d\n", pAd->ate.TxAntennaSel);
- ate_print("RxAntennaSel=%d\n", pAd->ate.RxAntennaSel);
- ate_print("BBPCurrentBW=%d\n", pAd->ate.TxWI.BW);
- ate_print("GI=%d\n", pAd->ate.TxWI.ShortGI);
- ate_print("MCS=%d\n", pAd->ate.TxWI.MCS);
- ate_print("TxMode=%d\n", pAd->ate.TxWI.PHYMODE);
- ate_print("Addr1=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr1[0], pAd->ate.Addr1[1], pAd->ate.Addr1[2], pAd->ate.Addr1[3], pAd->ate.Addr1[4], pAd->ate.Addr1[5]);
- ate_print("Addr2=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr2[0], pAd->ate.Addr2[1], pAd->ate.Addr2[2], pAd->ate.Addr2[3], pAd->ate.Addr2[4], pAd->ate.Addr2[5]);
- ate_print("Addr3=%02x:%02x:%02x:%02x:%02x:%02x\n",
- pAd->ate.Addr3[0], pAd->ate.Addr3[1], pAd->ate.Addr3[2], pAd->ate.Addr3[3], pAd->ate.Addr3[4], pAd->ate.Addr3[5]);
- ate_print("Channel=%d\n", pAd->ate.Channel);
- ate_print("TxLength=%d\n", pAd->ate.TxLength);
- ate_print("TxCount=%u\n", pAd->ate.TxCount);
- ate_print("RFFreqOffset=%d\n", pAd->ate.RFFreqOffset);
- ate_print(KERN_EMERG "Set_ATE_Show_Proc Success\n");
- return TRUE;
-}
-
-INT Set_ATE_Help_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ate_print("ATE=ATESTART, ATESTOP, TXCONT, TXCARR, TXFRAME, RXFRAME\n");
- ate_print("ATEDA\n");
- ate_print("ATESA\n");
- ate_print("ATEBSSID\n");
- ate_print("ATECHANNEL, range:0~14(unless A band !)\n");
- ate_print("ATETXPOW0, set power level of antenna 1.\n");
- ate_print("ATETXPOW1, set power level of antenna 2.\n");
- ate_print("ATETXANT, set TX antenna. 0:all, 1:antenna one, 2:antenna two.\n");
- ate_print("ATERXANT, set RX antenna.0:all, 1:antenna one, 2:antenna two, 3:antenna three.\n");
- ate_print("ATETXFREQOFFSET, set frequency offset, range 0~63\n");
- ate_print("ATETXBW, set BandWidth, 0:20MHz, 1:40MHz.\n");
- ate_print("ATETXLEN, set Frame length, range 24~%d\n", (MAX_FRAME_SIZE - 34/* == 2312 */));
- ate_print("ATETXCNT, set how many frame going to transmit.\n");
- ate_print("ATETXMCS, set MCS, reference to rate table.\n");
- ate_print("ATETXMODE, set Mode 0:CCK, 1:OFDM, 2:HT-Mix, 3:GreenField, reference to rate table.\n");
- ate_print("ATETXGI, set GI interval, 0:Long, 1:Short\n");
- ate_print("ATERXFER, 0:disable Rx Frame error rate. 1:enable Rx Frame error rate.\n");
- ate_print("ATERRF, show all RF registers.\n");
- ate_print("ATEWRF1, set RF1 register.\n");
- ate_print("ATEWRF2, set RF2 register.\n");
- ate_print("ATEWRF3, set RF3 register.\n");
- ate_print("ATEWRF4, set RF4 register.\n");
- ate_print("ATELDE2P, load EEPROM from .bin file.\n");
- ate_print("ATERE2P, display all EEPROM content.\n");
- ate_print("ATESHOW, display all parameters of ATE.\n");
- ate_print("ATEHELP, online help.\n");
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
-
- AsicSwitchChannel() dedicated for ATE.
-
- ==========================================================================
-*/
-VOID ATEAsicSwitchChannel(
- IN PRTMP_ADAPTER pAd)
-{
- UINT32 R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0, Value = 0;
- CHAR TxPwer = 0, TxPwer2 = 0;
- UCHAR index, BbpValue = 0, R66 = 0x30;
- RTMP_RF_REGS *RFRegTable;
- UCHAR Channel;
-
-#ifdef RALINK_28xx_QA
- if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
- {
- if (pAd->ate.Channel != pAd->LatchRfRegs.Channel)
- {
- pAd->ate.Channel = pAd->LatchRfRegs.Channel;
- }
- return;
- }
- else
-#endif // RALINK_28xx_QA //
- Channel = pAd->ate.Channel;
-
- // Select antenna
- AsicAntennaSelect(pAd, Channel);
-
- // fill Tx power value
- TxPwer = pAd->ate.TxPower0;
- TxPwer2 = pAd->ate.TxPower1;
-#ifdef RT30xx
-//2008/07/10:KH add to support 3070 ATE<--
-
- // The RF programming sequence is difference between 3xxx and 2xxx
- // The 3070 is 1T1R. Therefore, we don't need to set the number of Tx/Rx path and the only job is to set the parameters of channels.
- if (IS_RT30xx(pAd) && ((pAd->RfIcType == RFIC_3020) ||
-(pAd->RfIcType == RFIC_3021) || (pAd->RfIcType == RFIC_3022) ||
-(pAd->RfIcType == RFIC_2020)))
- {
- /* modify by WY for Read RF Reg. error */
- UCHAR RFValue;
-
- for (index = 0; index < NUM_OF_3020_CHNL; index++)
- {
- if (Channel == FreqItems3020[index].Channel)
- {
- // Programming channel parameters
- RT30xxWriteRFRegister(pAd, RF_R02, FreqItems3020[index].N);
- RT30xxWriteRFRegister(pAd, RF_R03, FreqItems3020[index].K);
-
- RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RFValue);
- RFValue = (RFValue & 0xFC) | FreqItems3020[index].R;
- RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RFValue);
-
- // Set Tx Power
- RT30xxReadRFRegister(pAd, RF_R12, (PUCHAR)&RFValue);
- RFValue = (RFValue & 0xE0) | TxPwer;
- RT30xxWriteRFRegister(pAd, RF_R12, (UCHAR)RFValue);
-
- // Set RF offset
- RT30xxReadRFRegister(pAd, RF_R23, (PUCHAR)&RFValue);
- //2008/08/06: KH modified "pAd->RFFreqOffset" to "pAd->ate.RFFreqOffset"
- RFValue = (RFValue & 0x80) | pAd->ate.RFFreqOffset;
- RT30xxWriteRFRegister(pAd, RF_R23, (UCHAR)RFValue);
-
- // Set BW
- if (pAd->ate.TxWI.BW == BW_40)
- {
- RFValue = pAd->Mlme.CaliBW40RfR24;
- //DISABLE_11N_CHECK(pAd);
- }
- else
- {
- RFValue = pAd->Mlme.CaliBW20RfR24;
- }
- RT30xxWriteRFRegister(pAd, RF_R24, (UCHAR)RFValue);
-
- // Enable RF tuning
- RT30xxReadRFRegister(pAd, RF_R07, (PUCHAR)&RFValue);
- RFValue = RFValue | 0x1;
- RT30xxWriteRFRegister(pAd, RF_R07, (UCHAR)RFValue);
-
- // latch channel for future usage.
- pAd->LatchRfRegs.Channel = Channel;
-
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
- Channel,
- pAd->RfIcType,
- TxPwer,
- TxPwer2,
- pAd->Antenna.field.TxPath,
- FreqItems3020[index].N,
- FreqItems3020[index].K,
- FreqItems3020[index].R));
- }
- else
-//2008/07/10:KH add to support 3070 ATE-->
-#endif // RT30xx //
-{
- RFRegTable = RF2850RegTable;
-
- switch (pAd->RfIcType)
- {
- /* But only 2850 and 2750 support 5.5GHz band... */
- case RFIC_2820:
- case RFIC_2850:
- case RFIC_2720:
- case RFIC_2750:
-
- for (index = 0; index < NUM_OF_2850_CHNL; index++)
- {
- if (Channel == RFRegTable[index].Channel)
- {
- R2 = RFRegTable[index].R2;
- if (pAd->Antenna.field.TxPath == 1)
- {
- R2 |= 0x4000; // If TXpath is 1, bit 14 = 1;
- }
-
- if (pAd->Antenna.field.RxPath == 2)
- {
- switch (pAd->ate.RxAntennaSel)
- {
- case 1:
- R2 |= 0x20040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x00;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 2:
- R2 |= 0x10040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x01;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- default:
- R2 |= 0x40;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- /* Only enable two Antenna to receive. */
- BbpValue |= 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- }
- }
- else if (pAd->Antenna.field.RxPath == 1)
- {
- R2 |= 0x20040; // write 1 to off RxPath
- }
-
- if (pAd->Antenna.field.TxPath == 2)
- {
- if (pAd->ate.TxAntennaSel == 1)
- {
- R2 |= 0x4000; // If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7; //11100111B
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- else if (pAd->ate.TxAntennaSel == 2)
- {
- R2 |= 0x8000; // If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7;
- BbpValue |= 0x08;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- else
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
- BbpValue &= 0xE7;
- BbpValue |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
- }
- }
- if (pAd->Antenna.field.RxPath == 3)
- {
- switch (pAd->ate.RxAntennaSel)
- {
- case 1:
- R2 |= 0x20040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x00;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 2:
- R2 |= 0x10040;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x01;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- case 3:
- R2 |= 0x30000;
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x02;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- default:
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
- BbpValue &= 0xE4;
- BbpValue |= 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
- break;
- }
- }
-
- if (Channel > 14)
- {
- // initialize R3, R4
- R3 = (RFRegTable[index].R3 & 0xffffc1ff);
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15);
-
- // According the Rory's suggestion to solve the middle range issue.
- // 5.5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB
- // R3
- if ((TxPwer >= -7) && (TxPwer < 0))
- {
- TxPwer = (7+TxPwer);
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer=%d \n", TxPwer));
- }
- else
- {
- TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);
- R3 |= (TxPwer << 10) | (1 << 9);
- }
-
- // R4
- if ((TxPwer2 >= -7) && (TxPwer2 < 0))
- {
- TxPwer2 = (7+TxPwer2);
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer2=%d \n", TxPwer2));
- }
- else
- {
- TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
- R4 |= (TxPwer2 << 7) | (1 << 6);
- }
- }
- else
- {
- R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); // set TX power0
- R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15) | (TxPwer2 <<6);// Set freq offset & TxPwr1
- }
-
- // Based on BBP current mode before changing RF channel.
- if (pAd->ate.TxWI.BW == BW_40)
- {
- R4 |=0x200000;
- }
-
- // Update variables
- pAd->LatchRfRegs.Channel = Channel;
- pAd->LatchRfRegs.R1 = RFRegTable[index].R1;
- pAd->LatchRfRegs.R2 = R2;
- pAd->LatchRfRegs.R3 = R3;
- pAd->LatchRfRegs.R4 = R4;
-
- RtmpRfIoWrite(pAd);
-
- break;
- }
- }
- break;
-
- default:
- break;
- }
-}
- // Change BBP setting during switch from a->g, g->a
- if (Channel <= 14)
- {
- ULONG TxPinCfg = 0x00050F0A;// 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
-
- /* For 1T/2R chip only... */
- if (pAd->NicConfig2.field.ExternalLNAForG)
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
- }
- else
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);
- }
-
- // According the Rory's suggestion to solve the middle range issue.
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R86, &BbpValue);
- ASSERT((BbpValue == 0x00));
- if ((BbpValue != 0x00))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
- }
-
- // 5.5GHz band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x04);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R.
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
- else
- {
- ULONG TxPinCfg = 0x00050F05;//2007.10.09 by Brian : 0x00050505 ==> 0x00050F05
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
-
- // According the Rory's suggestion to solve the middle range issue.
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R86, &BbpValue);
- ASSERT((BbpValue == 0x00));
- if ((BbpValue != 0x00))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
- }
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R91, &BbpValue);
- ASSERT((BbpValue == 0x04));
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R92, &BbpValue);
- ASSERT((BbpValue == 0x00));
-
- // 5.5GHz band selection PIN, bit1 and bit2 are complement
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
- Value &= (~0x6);
- Value |= (0x02);
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
- // Turn off unused PA or LNA when only 1T or 1R.
- if (pAd->Antenna.field.TxPath == 1)
- {
- TxPinCfg &= 0xFFFFFFF3;
- }
- if (pAd->Antenna.field.RxPath == 1)
- {
- TxPinCfg &= 0xFFFFF3FF;
- }
-
- RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
- }
-
- // R66 should be set according to Channel and use 20MHz when scanning
- if (Channel <= 14)
- {
- // BG band
- R66 = 0x2E + GET_LNA_GAIN(pAd);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- {
- // 5.5 GHz band
- if (pAd->ate.TxWI.BW == BW_20)
- {
- R66 = (UCHAR)(0x32 + (GET_LNA_GAIN(pAd)*5)/3);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- else
- {
- R66 = (UCHAR)(0x3A + (GET_LNA_GAIN(pAd)*5)/3);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
- }
- }
-
- //
- // On 11A, We should delay and wait RF/BBP to be stable
- // and the appropriate time should be 1000 micro seconds
- // 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
- //
- RTMPusecDelay(1000);
-
- if (Channel > 14)
- {
- // When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not.
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%u, Pwr1=%u, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
- Channel,
- pAd->RfIcType,
- (R3 & 0x00003e00) >> 9,
- (R4 & 0x000007c0) >> 6,
- pAd->Antenna.field.TxPath,
- pAd->LatchRfRegs.R1,
- pAd->LatchRfRegs.R2,
- pAd->LatchRfRegs.R3,
- pAd->LatchRfRegs.R4));
- }
-}
-
-//
-// In fact, no one will call this routine so far !
-//
-/*
- ==========================================================================
- Description:
- Gives CCK TX rate 2 more dB TX power.
- This routine works only in ATE mode.
-
- calculate desired Tx power in RF R3.Tx0~5, should consider -
- 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
- 1. TxPowerPercentage
- 2. auto calibration based on TSSI feedback
- 3. extra 2 db for CCK
- 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
-
- NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
- it should be called AFTER MlmeDynamicTxRateSwitching()
- ==========================================================================
- */
-VOID ATEAsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd)
-{
- INT i, j;
- CHAR DeltaPwr = 0;
- BOOLEAN bAutoTxAgc = FALSE;
- UCHAR TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;
- UCHAR BbpR49 = 0, idx;
- PCHAR pTxAgcCompensate;
- ULONG TxPwr[5];
- CHAR Value;
-
- /* no one calls this procedure so far */
- if (pAd->ate.TxWI.BW == BW_40)
- {
- if (pAd->ate.Channel > 14)
- {
- TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
- }
- }
- else
- {
- if (pAd->ate.Channel > 14)
- {
- TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
- }
- else
- {
- TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
- TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
- TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
- TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
- TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
- }
- }
-
- // TX power compensation for temperature variation based on TSSI.
- // Do it per 4 seconds.
- if (pAd->Mlme.OneSecPeriodicRound % 4 == 0)
- {
- if (pAd->ate.Channel <= 14)
- {
- /* bg channel */
- bAutoTxAgc = pAd->bAutoTxAgcG;
- TssiRef = pAd->TssiRefG;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryG[0];
- TxAgcStep = pAd->TxAgcStepG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- /* a channel */
- bAutoTxAgc = pAd->bAutoTxAgcA;
- TssiRef = pAd->TssiRefA;
- pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];
- pTssiPlusBoundary = &pAd->TssiPlusBoundaryA[0];
- TxAgcStep = pAd->TxAgcStepA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- {
- /* BbpR49 is unsigned char */
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);
-
- /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
- /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
- /* step value is defined in pAd->TxAgcStepG for tx power value */
-
- /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
- /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
- above value are examined in mass factory production */
- /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
-
- /* plus is 0x10 ~ 0x40, minus is 0x60 ~ 0x90 */
- /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
- /* if value is 0x65, tx power will be -= TxAgcStep*(2-1) */
-
- if (BbpR49 > pTssiMinusBoundary[1])
- {
- // Reading is larger than the reference value.
- // Check for how large we need to decrease the Tx power.
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 <= pTssiMinusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should decrease, idx = 0 means there is nothing to compensate
-// if (R3 > (ULONG) (TxAgcStep * (idx-1)))
- *pTxAgcCompensate = -(TxAgcStep * (idx-1));
-// else
-// *pTxAgcCompensate = -((UCHAR)R3);
-
- DeltaPwr += (*pTxAgcCompensate);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else if (BbpR49 < pTssiPlusBoundary[1])
- {
- // Reading is smaller than the reference value
- // check for how large we need to increase the Tx power
- for (idx = 1; idx < 5; idx++)
- {
- if (BbpR49 >= pTssiPlusBoundary[idx]) // Found the range
- break;
- }
- // The index is the step we should increase, idx = 0 means there is nothing to compensate
- *pTxAgcCompensate = TxAgcStep * (idx-1);
- DeltaPwr += (*pTxAgcCompensate);
- ATEDBGPRINT(RT_DEBUG_TRACE, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, idx-1));
- }
- else
- {
- *pTxAgcCompensate = 0;
- ATEDBGPRINT(RT_DEBUG_TRACE, (" Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
- BbpR49, TssiRef, TxAgcStep, 0));
- }
- }
- }
- else
- {
- if (pAd->ate.Channel <= 14)
- {
- bAutoTxAgc = pAd->bAutoTxAgcG;
- pTxAgcCompensate = &pAd->TxAgcCompensateG;
- }
- else
- {
- bAutoTxAgc = pAd->bAutoTxAgcA;
- pTxAgcCompensate = &pAd->TxAgcCompensateA;
- }
-
- if (bAutoTxAgc)
- DeltaPwr += (*pTxAgcCompensate);
- }
-
- /* calculate delta power based on the percentage specified from UI */
- // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
- // We lower TX power here according to the percentage specified from UI
- if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff) // AUTO TX POWER control
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
- ;
- else if (pAd->CommonCfg.TxPowerPercentage > 60) // 61 ~ 90%, treat as 75% in terms of mW
- {
- DeltaPwr -= 1;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 30) // 31 ~ 60%, treat as 50% in terms of mW
- {
- DeltaPwr -= 3;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 15) // 16 ~ 30%, treat as 25% in terms of mW
- {
- DeltaPwr -= 6;
- }
- else if (pAd->CommonCfg.TxPowerPercentage > 9) // 10 ~ 15%, treat as 12.5% in terms of mW
- {
- DeltaPwr -= 9;
- }
- else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW
- {
- DeltaPwr -= 12;
- }
-
- /* reset different new tx power for different TX rate */
- for(i=0; i<5; i++)
- {
- if (TxPwr[i] != 0xffffffff)
- {
- for (j=0; j<8; j++)
- {
- Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F); /* 0 ~ 15 */
-
- if ((Value + DeltaPwr) < 0)
- {
- Value = 0; /* min */
- }
- else if ((Value + DeltaPwr) > 0xF)
- {
- Value = 0xF; /* max */
- }
- else
- {
- Value += DeltaPwr; /* temperature compensation */
- }
-
- /* fill new value to CSR offset */
- TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
- }
-
- /* write tx power value to CSR */
- /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
- TX power for OFDM 6M/9M
- TX power for CCK5.5M/11M
- TX power for CCK1M/2M */
- /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
- RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);
-
-
- }
- }
-
-}
-
-/*
- ========================================================================
- Routine Description:
- Write TxWI for ATE mode.
-
- Return Value:
- None
- ========================================================================
-*/
-
-#ifdef RT2870
-static VOID ATEWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR MIMOps,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING Transmit)
-{
- //
- // Always use Long preamble before verifiation short preamble functionality works well.
- // Todo: remove the following line if short preamble functionality works
- //
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
- pTxWI->FRAG= FRAG;
- pTxWI->TS= InsTimestamp;
- pTxWI->AMPDU = AMPDU;
-
- pTxWI->MIMOps = PWR_ACTIVE;
- pTxWI->MpduDensity = 4;
- pTxWI->ACK = Ack;
- pTxWI->txop = Txopmode;
- pTxWI->NSEQ = NSeq;
- pTxWI->BAWinSize = BASize;
-
- pTxWI->WirelessCliID = WCID;
- pTxWI->MPDUtotalByteCount = Length;
- pTxWI->PacketId = PID;
-
- pTxWI->BW = Transmit.field.BW;
- pTxWI->ShortGI = Transmit.field.ShortGI;
- pTxWI->STBC= Transmit.field.STBC;
-
- pTxWI->MCS = Transmit.field.MCS;
- pTxWI->PHYMODE= Transmit.field.MODE;
-
-#ifdef DOT11_N_SUPPORT
- //
- // MMPS is 802.11n features. Because TxWI->MCS > 7 must be HT mode,
- // so need not check if it's HT rate.
- //
- if ((MIMOps == MMPS_STATIC) && (pTxWI->MCS > 7))
- pTxWI->MCS = 7;
-
- if ((MIMOps == MMPS_DYNAMIC) && (pTxWI->MCS > 7)) // SMPS protect 2 spatial.
- pTxWI->MIMOps = 1;
-#endif // DOT11_N_SUPPORT //
-
- pTxWI->CFACK = CfAck;
-
- return;
-}
-#endif // RT2870 //
-/*
- ========================================================================
-
- Routine Description:
- Disable protection for ATE.
- ========================================================================
-*/
-VOID ATEDisableAsicProtect(
- IN PRTMP_ADAPTER pAd)
-{
- PROT_CFG_STRUC ProtCfg, ProtCfg4;
- UINT32 Protect[6];
- USHORT offset;
- UCHAR i;
- UINT32 MacReg = 0;
-
- // Config ASIC RTS threshold register
- RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
- MacReg &= 0xFF0000FF;
- MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
- RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
-
- // Initial common protection settings
- RTMPZeroMemory(Protect, sizeof(Protect));
- ProtCfg4.word = 0;
- ProtCfg.word = 0;
- ProtCfg.field.TxopAllowGF40 = 1;
- ProtCfg.field.TxopAllowGF20 = 1;
- ProtCfg.field.TxopAllowMM40 = 1;
- ProtCfg.field.TxopAllowMM20 = 1;
- ProtCfg.field.TxopAllowOfdm = 1;
- ProtCfg.field.TxopAllowCck = 1;
- ProtCfg.field.RTSThEn = 1;
- ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-
- // Handle legacy(B/G) protection
- ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;
- ProtCfg.field.ProtectCtrl = 0;
- Protect[0] = ProtCfg.word;
- Protect[1] = ProtCfg.word;
-
- // NO PROTECT
- // 1.All STAs in the BSS are 20/40 MHz HT
- // 2. in ai 20/40MHz BSS
- // 3. all STAs are 20MHz in a 20MHz BSS
- // Pure HT. no protection.
-
- // MM20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[2] = 0x01744004;
-
- // MM40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[3] = 0x03f44084;
-
- // CF20_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 010111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
- Protect[4] = 0x01744004;
-
- // CF40_PROT_CFG
- // Reserved (31:27)
- // PROT_TXOP(25:20) -- 111111
- // PROT_NAV(19:18) -- 01 (Short NAV protection)
- // PROT_CTRL(17:16) -- 00 (None)
- // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
- Protect[5] = 0x03f44084;
-
- pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
-
- offset = CCK_PROT_CFG;
- for (i = 0;i < 6;i++)
- RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);
-
-}
-
-#ifdef RT2870
-/*
- ========================================================================
- Routine Description:
- Write TxInfo for ATE mode.
-
- Return Value:
- None
- ========================================================================
-*/
-static VOID ATEWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst)
-{
- pTxInfo->USBDMATxPktLen = USBDMApktLen;
- pTxInfo->QSEL = QueueSel;
-
- if (QueueSel != FIFO_EDCA)
- ATEDBGPRINT(RT_DEBUG_TRACE, ("=======> QueueSel != FIFO_EDCA<=======\n"));
-
- pTxInfo->USBDMANextVLD = NextValid;
- pTxInfo->USBDMATxburst = TxBurst;
- pTxInfo->WIV = bWiv;
- pTxInfo->SwUseLastRound = 0;
- pTxInfo->rsv = 0;
- pTxInfo->rsv2 = 0;
-
- return;
-}
-#endif // RT2870 //
-
-/* There are two ways to convert Rssi */
-#if 1
-//
-// The way used with GET_LNA_GAIN().
-//
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- LNAGain = GET_LNA_GAIN(pAd);
- if (pAd->LatchRfRegs.Channel > 14)
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-12 - RssiOffset - LNAGain - Rssi);
-}
-#else
-//
-// The way originally used in ATE of rt2860ap.
-//
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber)
-{
- UCHAR RssiOffset, LNAGain;
-
- // Rssi equals to zero should be an invalid value
- if (Rssi == 0)
- return -99;
-
- if (pAd->LatchRfRegs.Channel > 14)
- {
- LNAGain = pAd->ALNAGain;
- if (RssiNumber == 0)
- RssiOffset = pAd->ARssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->ARssiOffset1;
- else
- RssiOffset = pAd->ARssiOffset2;
- }
- else
- {
- LNAGain = pAd->BLNAGain;
- if (RssiNumber == 0)
- RssiOffset = pAd->BGRssiOffset0;
- else if (RssiNumber == 1)
- RssiOffset = pAd->BGRssiOffset1;
- else
- RssiOffset = pAd->BGRssiOffset2;
- }
-
- return (-32 - RssiOffset + LNAGain - Rssi);
-}
-#endif /* end of #if 1 */
-
-/*
- ========================================================================
-
- Routine Description:
- Set Japan filter coefficients if needed.
- Note:
- This routine should only be called when
- entering TXFRAME mode or TXCONT mode.
-
- ========================================================================
-*/
-static VOID SetJapanFilter(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR BbpData = 0;
-
- //
- // If Channel=14 and Bandwidth=20M and Mode=CCK, set BBP R4 bit5=1
- // (Japan Tx filter coefficients)when (TXFRAME or TXCONT).
- //
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BbpData);
-
- if ((pAd->ate.TxWI.PHYMODE == MODE_CCK) && (pAd->ate.Channel == 14) && (pAd->ate.TxWI.BW == BW_20))
- {
- BbpData |= 0x20; // turn on
- ATEDBGPRINT(RT_DEBUG_TRACE, ("SetJapanFilter!!!\n"));
- }
- else
- {
- BbpData &= 0xdf; // turn off
- ATEDBGPRINT(RT_DEBUG_TRACE, ("ClearJapanFilter!!!\n"));
- }
-
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BbpData);
-}
-
-VOID ATESampleRssi(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI)
-{
- /* There are two ways to collect RSSI. */
-#if 1
- //pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
- if (pRxWI->RSSI0 != 0)
- {
- pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
- pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
- pAd->ate.AvgRssi0 = pAd->ate.AvgRssi0X8 >> 3;
- }
- if (pRxWI->RSSI1 != 0)
- {
- pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
- pAd->ate.AvgRssi1X8 = (pAd->ate.AvgRssi1X8 - pAd->ate.AvgRssi1) + pAd->ate.LastRssi1;
- pAd->ate.AvgRssi1 = pAd->ate.AvgRssi1X8 >> 3;
- }
- if (pRxWI->RSSI2 != 0)
- {
- pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
- pAd->ate.AvgRssi2X8 = (pAd->ate.AvgRssi2X8 - pAd->ate.AvgRssi2) + pAd->ate.LastRssi2;
- pAd->ate.AvgRssi2 = pAd->ate.AvgRssi2X8 >> 3;
- }
-
- pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);// CHAR ==> UCHAR ?
- pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);// CHAR ==> UCHAR ?
-
- pAd->ate.NumOfAvgRssiSample ++;
-#else
- pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);
- pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);
- pAd->ate.RxCntPerSec++;
- pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
- pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
- pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
- pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
- pAd->ate.AvgRssi0 = pAd->ate.AvgRssi0X8 >> 3;
- pAd->ate.AvgRssi1X8 = (pAd->ate.AvgRssi1X8 - pAd->ate.AvgRssi1) + pAd->ate.LastRssi1;
- pAd->ate.AvgRssi1 = pAd->ate.AvgRssi1X8 >> 3;
- pAd->ate.AvgRssi2X8 = (pAd->ate.AvgRssi2X8 - pAd->ate.AvgRssi2) + pAd->ate.LastRssi2;
- pAd->ate.AvgRssi2 = pAd->ate.AvgRssi2X8 >> 3;
- pAd->ate.NumOfAvgRssiSample ++;
-#endif
-}
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPStationStop(
- IN PRTMP_ADAPTER pAd)
-{
-// BOOLEAN Cancelled;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStop\n"));
-
- // For rx statistics, we need to keep this timer running.
-// RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStop\n"));
-}
-
-VOID RTMPStationStart(
- IN PRTMP_ADAPTER pAd)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStart\n"));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStart\n"));
-}
-#endif // CONFIG_STA_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Setup Frame format.
- NOTE:
- This routine should only be used in ATE mode.
- ==========================================================================
- */
-
-#ifdef RT2870
-/*======================Start of RT2870======================*/
-/* */
-/* */
-static INT ATESetUpFrame(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TxIdx)
-{
- UINT j;
- PTX_CONTEXT pNullContext;
- PUCHAR pDest;
- HTTRANSMIT_SETTING TxHTPhyMode;
- PTXWI_STRUC pTxWI;
- PTXINFO_STRUC pTxInfo;
- UINT32 TransferBufferLength, OrgBufferLength = 0;
- UCHAR padLen = 0;
-#ifdef RALINK_28xx_QA
- PHEADER_802_11 pHeader80211 = NULL;
-#endif // RALINK_28xx_QA //
-
- if ((RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
- (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- return -1;
- }
-
- /* We always use QID_AC_BE and FIFO_EDCA in ATE mode. */
-
- pNullContext = &(pAd->NullContext);
- ASSERT(pNullContext != NULL);
-
- if (pNullContext->InUse == FALSE)
- {
- // Set the in use bit
- pNullContext->InUse = TRUE;
- NdisZeroMemory(&(pAd->NullFrame), sizeof(HEADER_802_11));
-
- // Fill 802.11 header.
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- pHeader80211 = NdisMoveMemory(&(pAd->NullFrame), pAd->ate.Header, pAd->ate.HLen);
-// pDest = NdisMoveMemory(&(pAd->NullFrame), pAd->ate.Header, pAd->ate.HLen);
-// pHeader80211 = (PHEADER_802_11)pDest;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- // Fill 802.11 header.
- NdisMoveMemory(&(pAd->NullFrame), TemplateFrame, sizeof(HEADER_802_11));
- }
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)&(pAd->NullFrame), DIR_READ, FALSE);
-#endif // RT_BIG_ENDIAN //
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- /* modify sequence number.... */
- if (pAd->ate.TxDoneCount == 0)
- {
- pAd->ate.seq = pHeader80211->Sequence;
- }
- else
- {
- pHeader80211->Sequence = ++pAd->ate.seq;
- }
- /* We already got all the addr. fields from QA GUI. */
- }
- else
-#endif // RALINK_28xx_QA //
- {
- COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->ate.Addr1);
- COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->ate.Addr2);
- COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->ate.Addr3);
- }
-
- RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[0], TX_BUFFER_NORMSIZE);//???
- pTxInfo = (PTXINFO_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[0];
-
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- // Avoid to exceed the range of WirelessPacket[].
- ASSERT(pAd->ate.TxInfo.USBDMATxPktLen <= (MAX_FRAME_SIZE - 34/* == 2312 */));
- NdisMoveMemory(pTxInfo, &(pAd->ate.TxInfo), sizeof(pAd->ate.TxInfo));
- }
- else
-#endif // RALINK_28xx_QA //
- {
- // Avoid to exceed the range of WirelessPacket[].
- ASSERT(pAd->ate.TxLength <= (MAX_FRAME_SIZE - 34/* == 2312 */));
-
- // pTxInfo->USBDMATxPktLen will be updated to include padding later.
- ATEWriteTxInfo(pAd, pTxInfo, (USHORT)(TXWI_SIZE + pAd->ate.TxLength), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxInfo->QSEL = FIFO_EDCA;
- }
-
- pTxWI = (PTXWI_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
-
- // Fill TxWI.
- if (pAd->ate.bQATxStart == TRUE)
- {
- TxHTPhyMode.field.BW = pAd->ate.TxWI.BW;
- TxHTPhyMode.field.ShortGI = pAd->ate.TxWI.ShortGI;
- TxHTPhyMode.field.STBC = pAd->ate.TxWI.STBC;
- TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
- TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
- ATEWriteTxWI(pAd, pTxWI, pAd->ate.TxWI.FRAG, pAd->ate.TxWI.TS, pAd->ate.TxWI.AMPDU, pAd->ate.TxWI.ACK, pAd->ate.TxWI.NSEQ,
- pAd->ate.TxWI.BAWinSize, BSSID_WCID, pAd->ate.TxWI.MPDUtotalByteCount/* include 802.11 header */, pAd->ate.TxWI.PacketId, 0, pAd->ate.TxWI.txop/*IFS_HTTXOP*/, pAd->ate.TxWI.CFACK/*FALSE*/, TxHTPhyMode);
- }
- else
- {
- TxHTPhyMode.field.BW = pAd->ate.TxWI.BW;
- TxHTPhyMode.field.ShortGI = pAd->ate.TxWI.ShortGI;
- TxHTPhyMode.field.STBC = 0;
- TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
- TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
-
- ATEWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE/* No ack required. */, FALSE, 0, BSSID_WCID, pAd->ate.TxLength,
- 0, 0, IFS_HTTXOP, FALSE, TxHTPhyMode);// "MMPS_STATIC" instead of "MMPS_DYNAMIC" ???
- }
-
- RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE+TXWI_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
-
- pDest = &(pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE+TXWI_SIZE+sizeof(HEADER_802_11)]);
-
- // Prepare frame payload
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQATxStart == TRUE)
- {
- // copy pattern
- if ((pAd->ate.PLen != 0))
- {
- for (j = 0; j < pAd->ate.DLen; j+=pAd->ate.PLen)
- {
- RTMPMoveMemory(pDest, pAd->ate.Pattern, pAd->ate.PLen);
- pDest += pAd->ate.PLen;
- }
- }
- TransferBufferLength = TXINFO_SIZE + TXWI_SIZE + pAd->ate.TxWI.MPDUtotalByteCount;
- }
- else
-#endif // RALINK_28xx_QA //
- {
- for (j = 0; j < (pAd->ate.TxLength - sizeof(HEADER_802_11)); j++)
- {
- *pDest = 0xA5;
- pDest += 1;
- }
- TransferBufferLength = TXINFO_SIZE + TXWI_SIZE + pAd->ate.TxLength;
- }
-
-#if 1
- OrgBufferLength = TransferBufferLength;
- TransferBufferLength = (TransferBufferLength + 3) & (~3);
-
- // Always add 4 extra bytes at every packet.
- padLen = TransferBufferLength - OrgBufferLength + 4;/* 4 == last packet padding */
- ASSERT((padLen <= (RTMP_PKT_TAIL_PADDING - 4/* 4 == MaxBulkOutsize alignment padding */)));
-
- /* Now memzero all extra padding bytes. */
- NdisZeroMemory(pDest, padLen);
- pDest += padLen;
-#else
- if ((TransferBufferLength % 4) == 1)
- {
- NdisZeroMemory(pDest, 7);
- pDest += 7;
- TransferBufferLength += 3;
- }
- else if ((TransferBufferLength % 4) == 2)
- {
- NdisZeroMemory(pDest, 6);
- pDest += 6;
- TransferBufferLength += 2;
- }
- else if ((TransferBufferLength % 4) == 3)
- {
- NdisZeroMemory(pDest, 5);
- pDest += 5;
- TransferBufferLength += 1;
- }
-#endif // 1 //
-
- // Update pTxInfo->USBDMATxPktLen to include padding.
- pTxInfo->USBDMATxPktLen = TransferBufferLength - TXINFO_SIZE;
-
- TransferBufferLength += 4;
-
- // If TransferBufferLength is multiple of 64, add extra 4 bytes again.
- if ((TransferBufferLength % pAd->BulkOutMaxPacketSize) == 0)
- {
- NdisZeroMemory(pDest, 4);
- TransferBufferLength += 4;
- }
-
- // Fill out frame length information for global Bulk out arbitor
- pAd->NullContext.BulkOutSize = TransferBufferLength;
- }
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
- RTMPFrameEndianChange(pAd, (((PUCHAR)pTxInfo)+TXWI_SIZE+TXINFO_SIZE), DIR_WRITE, FALSE);
- RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
- return 0;
-}
-
-VOID ATE_RTUSBBulkOutDataPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs)
-{
- PRTMP_ADAPTER pAd;
- PTX_CONTEXT pNullContext;
- UCHAR BulkOutPipeId;
- NTSTATUS Status;
- unsigned long IrqFlags;
- ULONG OldValue;
-
- pNullContext = (PTX_CONTEXT)pUrb->context;
- pAd = pNullContext->pAd;
-
-
- // Reset Null frame context flags
- pNullContext->IRPPending = FALSE;
- pNullContext->InUse = FALSE;
- Status = pUrb->status;
-
- // Store BulkOut PipeId
- BulkOutPipeId = pNullContext->BulkOutPipeId;
- pAd->BulkOutDataOneSecCount++;
-
- if (Status == USB_ST_NOERROR)
- {
-#ifdef RALINK_28xx_QA
- if ((ATE_ON(pAd)) && (pAd->ate.bQATxStart == TRUE))
- {
- if (pAd->ate.QID == BulkOutPipeId)
- {
- // Let Rx can have a chance to break in during Tx process,
- // especially for loopback mode in QA ATE.
- // To trade off between tx performance and loopback mode integrity.
- /* Q : Now Rx is handled by tasklet, do we still need this delay ? */
- /* Ans : Even tasklet is used, Rx/Tx < 1 if we do not delay for a while right here. */
- RTMPusecDelay(500);
- pAd->ate.TxDoneCount++;
- pAd->RalinkCounters.KickTxCount++;
- ASSERT(pAd->ate.QID == 0);
- pAd->ate.TxAc0++;
- }
- }
-#endif // RALINK_28xx_QA //
- pAd->BulkOutComplete++;
-
- pAd->Counters8023.GoodTransmits++;
-
- /* Don't worry about the queue is empty or not. This function will check itself. */
- RTMPDeQueuePacket(pAd, TRUE, BulkOutPipeId, MAX_TX_PROCESS);
-
- /* In 28xx, SendTxWaitQueue ==> TxSwQueue */
-/*
- if (pAd->SendTxWaitQueue[BulkOutPipeId].Number > 0)
- {
- RTMPDeQueuePacket(pAd, BulkOutPipeId);
- }
-*/
- }
- else // STATUS_OTHER
- {
- pAd->BulkOutCompleteOther++;
-
- ATEDBGPRINT(RT_DEBUG_ERROR, ("BulkOutDataPacket Failed STATUS_OTHER = 0x%x . \n", Status));
- ATEDBGPRINT(RT_DEBUG_ERROR, (">>BulkOutReq=0x%lx, BulkOutComplete=0x%lx\n", pAd->BulkOutReq, pAd->BulkOutComplete));
-
- if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)))
- {
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
- /* In 28xx, RT_OID_USB_RESET_BULK_OUT ==> CMDTHREAD_RESET_BULK_OUT */
- RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT, NULL, 0);
- // Check
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- pAd->bulkResetPipeid = BulkOutPipeId;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
- }
-
-
-
- if (atomic_read(&pAd->BulkOutRemained) > 0)
- {
- atomic_dec(&pAd->BulkOutRemained);
- }
-
- // 1st - Transmit Success
- OldValue = pAd->WlanCounters.TransmittedFragmentCount.u.LowPart;
- pAd->WlanCounters.TransmittedFragmentCount.u.LowPart++;
-
- if (pAd->WlanCounters.TransmittedFragmentCount.u.LowPart < OldValue)
- {
- pAd->WlanCounters.TransmittedFragmentCount.u.HighPart++;
- }
-
- if(((pAd->ContinBulkOut == TRUE ) ||(atomic_read(&pAd->BulkOutRemained) > 0)) && (pAd->ate.Mode & ATE_TXFRAME))
- {
- RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
- }
- else
- {
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-#ifdef RALINK_28xx_QA
- pAd->ate.TxStatus = 0;
-#endif // RALINK_28xx_QA //
- }
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- pAd->BulkOutPending[BulkOutPipeId] = FALSE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- // Always call Bulk routine, even reset bulk.
- // The protection of rest bulk should be in BulkOut routine.
- RTUSBKickBulkOut(pAd);
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID ATE_RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId)
-{
- PTX_CONTEXT pNullContext = &(pAd->NullContext);
- PURB pUrb;
- int ret = 0;
- unsigned long IrqFlags;
-
-
- ASSERT(BulkOutPipeId == 0);
-
- /* Build up the frame first. */
-// ATESetUpFrame(pAd, 0);
-
- BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- if (pAd->BulkOutPending[BulkOutPipeId] == TRUE)
- {
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
- return;
- }
-
- pAd->BulkOutPending[BulkOutPipeId] = TRUE;
- BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
- // Increase Total transmit byte counter
- pAd->RalinkCounters.OneSecTransmittedByteCount += pNullContext->BulkOutSize;
- pAd->RalinkCounters.TransmittedByteCount += pNullContext->BulkOutSize;
-
- // Clear ATE frame bulk out flag
- RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE);
-
- // Init Tx context descriptor
- pNullContext->IRPPending = TRUE;
- RTUSBInitTxDesc(pAd, pNullContext, BulkOutPipeId, (usb_complete_t)ATE_RTUSBBulkOutDataPacketComplete);
- pUrb = pNullContext->pUrb;
-
- if((ret = RTUSB_SUBMIT_URB(pUrb))!=0)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("ATE_RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret));
- return;
- }
-
- pAd->BulkOutReq++;
- return;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID ATE_RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd)
-{
- PRX_CONTEXT pRxContext;
- UINT i;
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("--->ATE_RTUSBCancelPendingBulkInIRP\n"));
-#if 1
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- pRxContext = &(pAd->RxContext[i]);
- if(pRxContext->IRPPending == TRUE)
- {
- RTUSB_UNLINK_URB(pRxContext->pUrb);
- pRxContext->IRPPending = FALSE;
- pRxContext->InUse = FALSE;
- //NdisInterlockedDecrement(&pAd->PendingRx);
- //pAd->PendingRx--;
- }
- }
-#else
- for ( i = 0; i < (RX_RING_SIZE); i++)
- {
- pRxContext = &(pAd->RxContext[i]);
- if(atomic_read(&pRxContext->IrpLock) == IRPLOCK_CANCELABLE)
- {
- RTUSB_UNLINK_URB(pRxContext->pUrb);
- }
- InterlockedExchange(&pRxContext->IrpLock, IRPLOCK_CANCE_START);
- }
-#endif // 1 //
- ATEDBGPRINT(RT_DEBUG_TRACE, ("<---ATE_RTUSBCancelPendingBulkInIRP\n"));
- return;
-}
-#endif // RT2870 //
-
-VOID rt_ee_read_all(PRTMP_ADAPTER pAd, USHORT *Data)
-{
- USHORT i;
- USHORT value;
-
- for (i = 0 ; i < EEPROM_SIZE/2 ; )
- {
- /* "value" is expecially for some compilers... */
- RT28xx_EEPROM_READ16(pAd, i*2, value);
- Data[i] = value;
- i++;
- }
-}
-
-VOID rt_ee_write_all(PRTMP_ADAPTER pAd, USHORT *Data)
-{
- USHORT i;
- USHORT value;
-
- for (i = 0 ; i < EEPROM_SIZE/2 ; )
- {
- /* "value" is expecially for some compilers... */
- value = Data[i];
- RT28xx_EEPROM_WRITE16(pAd, i*2, value);
- i ++;
- }
-}
-#ifdef RALINK_28xx_QA
-VOID ATE_QA_Statistics(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC pRxD,
- IN PHEADER_802_11 pHeader)
-{
- // update counter first
- if (pHeader != NULL)
- {
- if (pHeader->FC.Type == BTYPE_DATA)
- {
- if (pRxD->U2M)
- pAd->ate.U2M++;
- else
- pAd->ate.OtherData++;
- }
- else if (pHeader->FC.Type == BTYPE_MGMT)
- {
- if (pHeader->FC.SubType == SUBTYPE_BEACON)
- pAd->ate.Beacon++;
- else
- pAd->ate.OtherCount++;
- }
- else if (pHeader->FC.Type == BTYPE_CNTL)
- {
- pAd->ate.OtherCount++;
- }
- }
- pAd->ate.RSSI0 = pRxWI->RSSI0;
- pAd->ate.RSSI1 = pRxWI->RSSI1;
- pAd->ate.RSSI2 = pRxWI->RSSI2;
- pAd->ate.SNR0 = pRxWI->SNR0;
- pAd->ate.SNR1 = pRxWI->SNR1;
-}
-
-/* command id with Cmd Type == 0x0008(for 28xx)/0x0005(for iNIC) */
-#define RACFG_CMD_RF_WRITE_ALL 0x0000
-#define RACFG_CMD_E2PROM_READ16 0x0001
-#define RACFG_CMD_E2PROM_WRITE16 0x0002
-#define RACFG_CMD_E2PROM_READ_ALL 0x0003
-#define RACFG_CMD_E2PROM_WRITE_ALL 0x0004
-#define RACFG_CMD_IO_READ 0x0005
-#define RACFG_CMD_IO_WRITE 0x0006
-#define RACFG_CMD_IO_READ_BULK 0x0007
-#define RACFG_CMD_BBP_READ8 0x0008
-#define RACFG_CMD_BBP_WRITE8 0x0009
-#define RACFG_CMD_BBP_READ_ALL 0x000a
-#define RACFG_CMD_GET_COUNTER 0x000b
-#define RACFG_CMD_CLEAR_COUNTER 0x000c
-
-#define RACFG_CMD_RSV1 0x000d
-#define RACFG_CMD_RSV2 0x000e
-#define RACFG_CMD_RSV3 0x000f
-
-#define RACFG_CMD_TX_START 0x0010
-#define RACFG_CMD_GET_TX_STATUS 0x0011
-#define RACFG_CMD_TX_STOP 0x0012
-#define RACFG_CMD_RX_START 0x0013
-#define RACFG_CMD_RX_STOP 0x0014
-#define RACFG_CMD_GET_NOISE_LEVEL 0x0015
-
-#define RACFG_CMD_ATE_START 0x0080
-#define RACFG_CMD_ATE_STOP 0x0081
-
-#define RACFG_CMD_ATE_START_TX_CARRIER 0x0100
-#define RACFG_CMD_ATE_START_TX_CONT 0x0101
-#define RACFG_CMD_ATE_START_TX_FRAME 0x0102
-#define RACFG_CMD_ATE_SET_BW 0x0103
-#define RACFG_CMD_ATE_SET_TX_POWER0 0x0104
-#define RACFG_CMD_ATE_SET_TX_POWER1 0x0105
-#define RACFG_CMD_ATE_SET_FREQ_OFFSET 0x0106
-#define RACFG_CMD_ATE_GET_STATISTICS 0x0107
-#define RACFG_CMD_ATE_RESET_COUNTER 0x0108
-#define RACFG_CMD_ATE_SEL_TX_ANTENNA 0x0109
-#define RACFG_CMD_ATE_SEL_RX_ANTENNA 0x010a
-#define RACFG_CMD_ATE_SET_PREAMBLE 0x010b
-#define RACFG_CMD_ATE_SET_CHANNEL 0x010c
-#define RACFG_CMD_ATE_SET_ADDR1 0x010d
-#define RACFG_CMD_ATE_SET_ADDR2 0x010e
-#define RACFG_CMD_ATE_SET_ADDR3 0x010f
-#define RACFG_CMD_ATE_SET_RATE 0x0110
-#define RACFG_CMD_ATE_SET_TX_FRAME_LEN 0x0111
-#define RACFG_CMD_ATE_SET_TX_FRAME_COUNT 0x0112
-#define RACFG_CMD_ATE_START_RX_FRAME 0x0113
-#define RACFG_CMD_ATE_E2PROM_READ_BULK 0x0114
-#define RACFG_CMD_ATE_E2PROM_WRITE_BULK 0x0115
-#define RACFG_CMD_ATE_IO_WRITE_BULK 0x0116
-#define RACFG_CMD_ATE_BBP_READ_BULK 0x0117
-#define RACFG_CMD_ATE_BBP_WRITE_BULK 0x0118
-#define RACFG_CMD_ATE_RF_READ_BULK 0x0119
-#define RACFG_CMD_ATE_RF_WRITE_BULK 0x011a
-
-
-
-#define A2Hex(_X, _p) \
-{ \
- UCHAR *p; \
- _X = 0; \
- p = _p; \
- while (((*p >= 'a') && (*p <= 'f')) || ((*p >= 'A') && (*p <= 'F')) || ((*p >= '0') && (*p <= '9'))) \
- { \
- if ((*p >= 'a') && (*p <= 'f')) \
- _X = _X * 16 + *p - 87; \
- else if ((*p >= 'A') && (*p <= 'F')) \
- _X = _X * 16 + *p - 55; \
- else if ((*p >= '0') && (*p <= '9')) \
- _X = _X * 16 + *p - 48; \
- p++; \
- } \
-}
-
-
-static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len);
-static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len);
-static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32 len);
-
-#ifdef UCOS
-int ate_copy_to_user(
- IN PUCHAR payload,
- IN PUCHAR msg,
- IN INT len)
-{
- memmove(payload, msg, len);
- return 0;
-}
-
-#undef copy_to_user
-#define copy_to_user(x,y,z) ate_copy_to_user((PUCHAR)x, (PUCHAR)y, z)
-#endif // UCOS //
-
-#define LEN_OF_ARG 16
-
-VOID RtmpDoAte(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- unsigned short Command_Id;
- struct ate_racfghdr *pRaCfg;
- INT Status = NDIS_STATUS_SUCCESS;
-
-
-
- if((pRaCfg = kmalloc(sizeof(struct ate_racfghdr), GFP_KERNEL)) == NULL)
- {
- Status = -EINVAL;
- return;
- }
-
- NdisZeroMemory(pRaCfg, sizeof(struct ate_racfghdr));
-
- if (copy_from_user((PUCHAR)pRaCfg, wrq->u.data.pointer, wrq->u.data.length))
- {
- Status = -EFAULT;
- kfree(pRaCfg);
- return;
- }
-
-
- Command_Id = ntohs(pRaCfg->command_id);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __FUNCTION__, Command_Id));
-
- switch (Command_Id)
- {
- // We will get this command when QA starts.
- case RACFG_CMD_ATE_START:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START\n"));
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_ATE_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START is done !\n"));
- }
- Set_ATE_Proc(pAdapter, "ATESTART");
- }
- break;
-
- // We will get this command either QA is closed or ated is killed by user.
- case RACFG_CMD_ATE_STOP:
- {
-#ifndef UCOS
- INT32 ret;
-#endif // !UCOS //
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_STOP\n"));
-
- // Distinguish this command came from QA(via ated)
- // or ate daemon according to the existence of pid in payload.
- // No need to prepare feedback if this cmd came directly from ate daemon.
- pRaCfg->length = ntohs(pRaCfg->length);
-
- if (pRaCfg->length == sizeof(pAdapter->ate.AtePid))
- {
- // This command came from QA.
- // Get the pid of ATE daemon.
- memcpy((UCHAR *)&pAdapter->ate.AtePid,
- (&pRaCfg->data[0]) - 2/* == &(pRaCfg->status) */,
- sizeof(pAdapter->ate.AtePid));
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_STOP\n"));
- Status = -EFAULT;
- }
-
- //
- // kill ATE daemon when leaving ATE mode.
- // We must kill ATE daemon first before setting ATESTOP,
- // or Microsoft will report sth. wrong.
-#ifndef UCOS
- ret = kill_proc(pAdapter->ate.AtePid, SIGTERM, 1);
- if (ret)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("%s: unable to signal thread\n", pAdapter->net_dev->name));
- }
-#endif // !UCOS //
- }
-
-#ifdef UCOS
- // Roger add to avoid error message after close QA
- if (pAdapter->CSRBaseAddress == RT2860_CSR_ADDR)
- {
-
- // prepare feedback as soon as we can to avoid QA timeout.
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_AP_START\n"));
- Status = -EFAULT;
- }
- }
-#endif // UCOS //
-
- // AP might have in ATE_STOP mode due to cmd from QA.
- if (ATE_ON(pAdapter))
- {
- // Someone has killed ate daemon while QA GUI is still open.
- Set_ATE_Proc(pAdapter, "ATESTOP");
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_AP_START is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RF_WRITE_ALL:
- {
- UINT32 R1, R2, R3, R4;
- USHORT channel;
-
- memcpy(&R1, pRaCfg->data-2, 4);
- memcpy(&R2, pRaCfg->data+2, 4);
- memcpy(&R3, pRaCfg->data+6, 4);
- memcpy(&R4, pRaCfg->data+10, 4);
- memcpy(&channel, pRaCfg->data+14, 2);
-
- pAdapter->LatchRfRegs.R1 = ntohl(R1);
- pAdapter->LatchRfRegs.R2 = ntohl(R2);
- pAdapter->LatchRfRegs.R3 = ntohl(R3);
- pAdapter->LatchRfRegs.R4 = ntohl(R4);
- pAdapter->LatchRfRegs.Channel = ntohs(channel);
-
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R1);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R2);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R3);
- RTMP_RF_IO_WRITE32(pAdapter, pAdapter->LatchRfRegs.R4);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RF_WRITE_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RF_WRITE_ALL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_READ16:
- {
- USHORT offset, value, tmp;
-
- offset = ntohs(pRaCfg->status);
- /* "tmp" is expecially for some compilers... */
- RT28xx_EEPROM_READ16(pAdapter, offset, tmp);
- value = tmp;
- value = htons(value);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("EEPROM Read offset = 0x%04x, value = 0x%04x\n", offset, value));
-
- // prepare feedback
- pRaCfg->length = htons(4);
- pRaCfg->status = htons(0);
- memcpy(pRaCfg->data, &value, 2);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("sizeof(struct ate_racfghdr) = %d\n", sizeof(struct ate_racfghdr)));
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ16\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_READ16 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_WRITE16:
- {
- USHORT offset, value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&value, pRaCfg->data, 2);
- value = ntohs(value);
- RT28xx_EEPROM_WRITE16(pAdapter, offset, value);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE16\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_WRITE16 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_READ_ALL:
- {
- USHORT buffer[EEPROM_SIZE/2];
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer, EEPROM_SIZE);
-
- // prepare feedback
- pRaCfg->length = htons(2+EEPROM_SIZE);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_E2PROM_READ_ALL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_E2PROM_WRITE_ALL:
- {
- USHORT buffer[EEPROM_SIZE/2];
-
- NdisZeroMemory((UCHAR *)buffer, EEPROM_SIZE);
- memcpy_exs(pAdapter, (UCHAR *)buffer, (UCHAR *)&pRaCfg->status, EEPROM_SIZE);
- rt_ee_write_all(pAdapter,(USHORT *)buffer);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_E2PROM_WRITE_ALL is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_IO_READ:
- {
- UINT32 offset;
- UINT32 value;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract the offset out.
- offset &= 0x0000FFFF;
- RTMP_IO_READ32(pAdapter, offset, &value);
- value = htonl(value);
-
- // prepare feedback
- pRaCfg->length = htons(6);
- pRaCfg->status = htons(0);
- memcpy(pRaCfg->data, &value, 4);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_READ\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_READ is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_IO_WRITE:
- {
- UINT32 offset, value;
-
- memcpy(&offset, pRaCfg->data-2, 4);
- memcpy(&value, pRaCfg->data+2, 4);
-
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract out the offset.
- offset &= 0x0000FFFF;
- value = ntohl(value);
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_IO_WRITE: offset = %x, value = %x\n", offset, value));
- RTMP_IO_WRITE32(pAdapter, offset, value);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_WRITE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_WRITE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_IO_READ_BULK:
- {
- UINT32 offset;
- USHORT len;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
-
- // We do not need the base address.
- // So just extract the offset.
- offset &= 0x0000FFFF;
- memcpy(&len, pRaCfg->data+2, 2);
- len = ntohs(len);
-
- if (len > 371)
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("len is too large, make it smaller\n"));
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(1);
- break;
- }
-
- RTMP_IO_READ_BULK(pAdapter, pRaCfg->data, (UCHAR *)offset, len*4);// unit in four bytes
-
- // prepare feedback
- pRaCfg->length = htons(2+len*4);// unit in four bytes
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_IO_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_IO_READ_BULK is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_BBP_READ8:
- {
- USHORT offset;
- UCHAR value;
-
- value = 0;
- offset = ntohs(pRaCfg->status);
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, offset, &value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, offset, &value);
- }
- // prepare feedback
- pRaCfg->length = htons(3);
- pRaCfg->status = htons(0);
- pRaCfg->data[0] = value;
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("BBP value = %x\n", value));
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_READ8\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_READ8 is done !\n"));
- }
- }
- break;
- case RACFG_CMD_BBP_WRITE8:
- {
- USHORT offset;
- UCHAR value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&value, pRaCfg->data, 1);
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, offset, value);
- }
- else
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, offset, value);
- }
-
- if ((offset == BBP_R1) || (offset == BBP_R3))
- {
- SyncTxRxConfig(pAdapter, offset, value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_WRITE8\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_WRITE8 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_BBP_READ_ALL:
- {
- USHORT j;
-
- for (j = 0; j < 137; j++)
- {
- pRaCfg->data[j] = 0;
-
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j]);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j]);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+137);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_BBP_READ_ALL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_BBP_READ_ALL is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_ATE_E2PROM_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT buffer[EEPROM_SIZE/2];
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- if (offset + len <= EEPROM_SIZE)
- memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer+offset, len);
- else
- ATEDBGPRINT(RT_DEBUG_ERROR, ("exceed EEPROM size\n"));
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_E2PROM_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_E2PROM_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT buffer[EEPROM_SIZE/2];
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- rt_ee_read_all(pAdapter,(USHORT *)buffer);
- memcpy_exs(pAdapter, (UCHAR *)buffer + offset, (UCHAR *)pRaCfg->data + 2, len);
- rt_ee_write_all(pAdapter,(USHORT *)buffer);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_ATE_E2PROM_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_IO_WRITE_BULK:
- {
- UINT32 offset, i, value;
- USHORT len;
-
- memcpy(&offset, &pRaCfg->status, 4);
- offset = ntohl(offset);
- memcpy(&len, pRaCfg->data+2, 2);
- len = ntohs(len);
-
- for (i = 0; i < len; i += 4)
- {
- memcpy_exl(pAdapter, (UCHAR *)&value, pRaCfg->data+4+i, 4);
- printk("Write %x %x\n", offset + i, value);
- RTMP_IO_WRITE32(pAdapter, (offset +i) & 0xffff, value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_IO_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("RACFG_CMD_ATE_IO_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_BBP_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
-
- for (j = offset; j < (offset+len); j++)
- {
- pRaCfg->data[j - offset] = 0;
-
- if (pAdapter->ate.Mode == ATE_STOP)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j - offset]);
- }
- else
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j, &pRaCfg->data[j - offset]);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_BBP_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_BBP_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
- UCHAR *value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- value = pRaCfg->data + 2 + (j - offset);
- if (pAdapter->ate.Mode == ATE_STOP)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, j, *value);
- }
- else
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, j, *value);
- }
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_BBP_WRITE_BULK is done !\n"));
- }
- }
- break;
-
-#ifdef CONFIG_RALINK_RT3052
- case RACFG_CMD_ATE_RF_READ_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- pRaCfg->data[j - offset] = 0;
- RT30xxReadRFRegister(pAdapter, j, &pRaCfg->data[j - offset]);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2+len);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_READ_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RF_READ_BULK is done !\n"));
- }
-
- }
- break;
-
- case RACFG_CMD_ATE_RF_WRITE_BULK:
- {
- USHORT offset;
- USHORT len;
- USHORT j;
- UCHAR *value;
-
- offset = ntohs(pRaCfg->status);
- memcpy(&len, pRaCfg->data, 2);
- len = ntohs(len);
-
- for (j = offset; j < (offset+len); j++)
- {
- value = pRaCfg->data + 2 + (j - offset);
- RT30xxWriteRFRegister(pAdapter, j, *value);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_WRITE_BULK\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RF_WRITE_BULK is done !\n"));
- }
-
- }
- break;
-#endif
-
-
- case RACFG_CMD_GET_NOISE_LEVEL:
- {
- UCHAR channel;
- INT32 buffer[3][10];/* 3 : RxPath ; 10 : no. of per rssi samples */
-
- channel = (ntohs(pRaCfg->status) & 0x00FF);
- CalNoiseLevel(pAdapter, channel, buffer);
- memcpy_exl(pAdapter, (UCHAR *)pRaCfg->data, (UCHAR *)&(buffer[0][0]), (sizeof(INT32)*3*10));
-
- // prepare feedback
- pRaCfg->length = htons(2 + (sizeof(INT32)*3*10));
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_NOISE_LEVEL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_NOISE_LEVEL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_GET_COUNTER:
- {
- memcpy_exl(pAdapter, &pRaCfg->data[0], (UCHAR *)&pAdapter->ate.U2M, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[4], (UCHAR *)&pAdapter->ate.OtherData, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[8], (UCHAR *)&pAdapter->ate.Beacon, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[12], (UCHAR *)&pAdapter->ate.OtherCount, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[16], (UCHAR *)&pAdapter->ate.TxAc0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[20], (UCHAR *)&pAdapter->ate.TxAc1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[24], (UCHAR *)&pAdapter->ate.TxAc2, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->ate.TxAc3, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->ate.TxHCCA, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->ate.TxMgmt, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&pAdapter->ate.RSSI0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[44], (UCHAR *)&pAdapter->ate.RSSI1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&pAdapter->ate.RSSI2, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[52], (UCHAR *)&pAdapter->ate.SNR0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[56], (UCHAR *)&pAdapter->ate.SNR1, 4);
-
- pRaCfg->length = htons(2+60);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_COUNTER is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_CLEAR_COUNTER:
- {
- pAdapter->ate.U2M = 0;
- pAdapter->ate.OtherData = 0;
- pAdapter->ate.Beacon = 0;
- pAdapter->ate.OtherCount = 0;
- pAdapter->ate.TxAc0 = 0;
- pAdapter->ate.TxAc1 = 0;
- pAdapter->ate.TxAc2 = 0;
- pAdapter->ate.TxAc3 = 0;
- pAdapter->ate.TxHCCA = 0;
- pAdapter->ate.TxMgmt = 0;
- pAdapter->ate.TxDoneCount = 0;
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_CLEAR_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_CLEAR_COUNTER is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_TX_START:
- {
- USHORT *p;
- USHORT err = 1;
- UCHAR Bbp22Value = 0, Bbp24Value = 0;
-
- if ((pAdapter->ate.TxStatus != 0) && (pAdapter->ate.Mode & ATE_TXFRAME))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("Ate Tx is already running, to run next Tx, you must stop it first\n"));
- err = 2;
- goto TX_START_ERROR;
- }
- else if ((pAdapter->ate.TxStatus != 0) && !(pAdapter->ate.Mode & ATE_TXFRAME))
- {
- int i = 0;
-
- while ((i++ < 10) && (pAdapter->ate.TxStatus != 0))
- {
- RTMPusecDelay(5000);
- }
-
- // force it to stop
- pAdapter->ate.TxStatus = 0;
- pAdapter->ate.TxDoneCount = 0;
- //pAdapter->ate.Repeat = 0;
- pAdapter->ate.bQATxStart = FALSE;
- }
-
- // If pRaCfg->length == 0, this "RACFG_CMD_TX_START" is for Carrier test or Carrier Suppression.
- if (ntohs(pRaCfg->length) != 0)
- {
- // Get frame info
-#ifdef RT2870
- NdisMoveMemory(&pAdapter->ate.TxInfo, pRaCfg->data - 2, 4);
-#ifdef RT_BIG_ENDIAN
- RTMPDescriptorEndianChange((PUCHAR) &pAdapter->ate.TxInfo, TYPE_TXINFO);
-#endif // RT_BIG_ENDIAN //
-#endif // RT2870 //
-
- NdisMoveMemory(&pAdapter->ate.TxWI, pRaCfg->data + 2, 16);
-#ifdef RT_BIG_ENDIAN
- RTMPWIEndianChange((PUCHAR)&pAdapter->ate.TxWI, TYPE_TXWI);
-#endif // RT_BIG_ENDIAN //
-
- NdisMoveMemory(&pAdapter->ate.TxCount, pRaCfg->data + 18, 4);
- pAdapter->ate.TxCount = ntohl(pAdapter->ate.TxCount);
-
- p = (USHORT *)(&pRaCfg->data[22]);
- //p = pRaCfg->data + 22;
- // always use QID_AC_BE
- pAdapter->ate.QID = 0;
- p = (USHORT *)(&pRaCfg->data[24]);
- //p = pRaCfg->data + 24;
- pAdapter->ate.HLen = ntohs(*p);
-
- if (pAdapter->ate.HLen > 32)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("pAdapter->ate.HLen > 32\n"));
- err = 3;
- goto TX_START_ERROR;
- }
-
- NdisMoveMemory(&pAdapter->ate.Header, pRaCfg->data + 26, pAdapter->ate.HLen);
-
-
- pAdapter->ate.PLen = ntohs(pRaCfg->length) - (pAdapter->ate.HLen + 28);
-
- if (pAdapter->ate.PLen > 32)
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("pAdapter->ate.PLen > 32\n"));
- err = 4;
- goto TX_START_ERROR;
- }
-
- NdisMoveMemory(&pAdapter->ate.Pattern, pRaCfg->data + 26 + pAdapter->ate.HLen, pAdapter->ate.PLen);
- pAdapter->ate.DLen = pAdapter->ate.TxWI.MPDUtotalByteCount - pAdapter->ate.HLen;
- }
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R22, &Bbp22Value);
-
- switch (Bbp22Value)
- {
- case BBP22_TXFRAME:
- {
- if (pAdapter->ate.TxCount == 0)
- {
- }
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXFRAME\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXFRAME");
- }
- break;
-
- case BBP22_TXCONT_OR_CARRSUPP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("BBP22_TXCONT_OR_CARRSUPP\n"));
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, 24, &Bbp24Value);
-
- switch (Bbp24Value)
- {
- case BBP24_TXCONT:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCONT\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXCONT");
- }
- break;
-
- case BBP24_CARRSUPP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCARRSUPP\n"));
- pAdapter->ate.bQATxStart = TRUE;
- pAdapter->ate.Mode |= ATE_TXCARRSUPP;
- }
- break;
-
- default:
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("Unknown Start TX subtype !"));
- }
- break;
- }
- }
- break;
-
- case BBP22_TXCARR:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("START TXCARR\n"));
- pAdapter->ate.bQATxStart = TRUE;
- Set_ATE_Proc(pAdapter, "TXCARR");
- }
- break;
-
- default:
- {
- ATEDBGPRINT(RT_DEBUG_ERROR,("Unknown Start TX subtype !"));
- }
- break;
- }
-
- if (pAdapter->ate.bQATxStart == TRUE)
- {
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() was failed in case RACFG_CMD_TX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_TX_START is done !\n"));
- }
- break;
- }
-
-TX_START_ERROR:
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(err);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_TX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("feedback of TX_START_ERROR is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_GET_TX_STATUS:
- {
- UINT32 count;
-
- // prepare feedback
- pRaCfg->length = htons(6);
- pRaCfg->status = htons(0);
- count = htonl(pAdapter->ate.TxDoneCount);
- NdisMoveMemory(pRaCfg->data, &count, 4);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_GET_TX_STATUS\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_GET_TX_STATUS is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_TX_STOP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_TX_STOP\n"));
-
- Set_ATE_Proc(pAdapter, "TXSTOP");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("copy_to_user() fail in case RACFG_CMD_TX_STOP\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_TX_STOP is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RX_START:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
-
- pAdapter->ate.bQARxStart = TRUE;
- Set_ATE_Proc(pAdapter, "RXFRAME");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_START is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_RX_STOP:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_STOP\n"));
-
- Set_ATE_Proc(pAdapter, "RXSTOP");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_STOP\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_STOP is done !\n"));
- }
- }
- break;
-
- /* The following cases are for new ATE GUI(not QA). */
- /*==================================================*/
- case RACFG_CMD_ATE_START_TX_CARRIER:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CARRIER\n"));
-
- Set_ATE_Proc(pAdapter, "TXCARR");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CARRIER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_CARRIER is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_TX_CONT:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CONT\n"));
-
- Set_ATE_Proc(pAdapter, "TXCONT");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CONT\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_CONT is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_TX_FRAME:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_FRAME\n"));
-
- Set_ATE_Proc(pAdapter, "TXFRAME");
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_FRAME\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_FRAME is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_BW:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_BW\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
-
- Set_ATE_TX_BW_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_BW\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_BW is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_POWER0:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER0\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_POWER0_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER0\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_POWER0 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_POWER1:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER1\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_POWER1_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER1\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_POWER1 is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_FREQ_OFFSET:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_FREQOFFSET_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_FREQ_OFFSET is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_GET_STATISTICS:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_GET_STATISTICS\n"));
-
- memcpy_exl(pAdapter, &pRaCfg->data[0], (UCHAR *)&pAdapter->ate.TxDoneCount, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[4], (UCHAR *)&pAdapter->WlanCounters.RetryCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[8], (UCHAR *)&pAdapter->WlanCounters.FailedCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[12], (UCHAR *)&pAdapter->WlanCounters.RTSSuccessCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[16], (UCHAR *)&pAdapter->WlanCounters.RTSFailureCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[20], (UCHAR *)&pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[24], (UCHAR *)&pAdapter->WlanCounters.FCSErrorCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->Counters8023.RxNoBuffer, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->RalinkCounters.OneSecFalseCCACnt, 4);
-
- if (pAdapter->ate.RxAntennaSel == 0)
- {
- INT32 RSSI0 = 0;
- INT32 RSSI1 = 0;
- INT32 RSSI2 = 0;
-
- RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
- RSSI1 = (INT32)(pAdapter->ate.LastRssi1 - pAdapter->BbpRssiToDbmDelta);
- RSSI2 = (INT32)(pAdapter->ate.LastRssi2 - pAdapter->BbpRssiToDbmDelta);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[44], (UCHAR *)&RSSI1, 4);
- memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&RSSI2, 4);
- pRaCfg->length = htons(2+52);
- }
- else
- {
- INT32 RSSI0 = 0;
-
- RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
- memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
- pRaCfg->length = htons(2+44);
- }
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_GET_STATISTICS\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_GET_STATISTICS is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_RESET_COUNTER:
- {
- SHORT value = 1;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_RESET_COUNTER\n"));
-
- sprintf((PCHAR)str, "%d", value);
- Set_ResetStatCounter_Proc(pAdapter, str);
-
- pAdapter->ate.TxDoneCount = 0;
-
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
-
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_RESET_COUNTER\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RESET_COUNTER is done !\n"));
- }
- }
-
- break;
-
- case RACFG_CMD_ATE_SEL_TX_ANTENNA:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_Antenna_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SEL_TX_ANTENNA is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SEL_RX_ANTENNA:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_RX_Antenna_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SEL_RX_ANTENNA is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_PREAMBLE:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_PREAMBLE\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_MODE_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_PREAMBLE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_PREAMBLE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_CHANNEL:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_CHANNEL\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_CHANNEL_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_CHANNEL\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_CHANNEL is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR1:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR1\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr1, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR1\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR1 is done !\n (ADDR1 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr1[0],
- pAdapter->ate.Addr1[1], pAdapter->ate.Addr1[2], pAdapter->ate.Addr1[3], pAdapter->ate.Addr1[4], pAdapter->ate.Addr1[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR2:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR2\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr2, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR2\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR2 is done !\n (ADDR2 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr2[0],
- pAdapter->ate.Addr2[1], pAdapter->ate.Addr2[2], pAdapter->ate.Addr2[3], pAdapter->ate.Addr2[4], pAdapter->ate.Addr2[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_ADDR3:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_ADDR3\n"));
-
- // Addr is an array of UCHAR,
- // so no need to perform endian swap.
- memcpy(pAdapter->ate.Addr3, (PUCHAR)(pRaCfg->data - 2), MAC_ADDR_LEN);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR3\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_ADDR3 is done !\n (ADDR3 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter->ate.Addr3[0],
- pAdapter->ate.Addr3[1], pAdapter->ate.Addr3[2], pAdapter->ate.Addr3[3], pAdapter->ate.Addr3[4], pAdapter->ate.Addr3[5]));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_RATE:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_RATE\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_MCS_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_RATE\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_RATE is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_FRAME_LEN:
- {
- SHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_LENGTH_Proc(pAdapter, str);
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_FRAME_LEN is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_SET_TX_FRAME_COUNT:
- {
- USHORT value = 0;
- UCHAR str[LEN_OF_ARG];
-
- NdisZeroMemory(str, LEN_OF_ARG);
-
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
-
- memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
- value = ntohs(value);
- {
- sprintf((PCHAR)str, "%d", value);
- Set_ATE_TX_COUNT_Proc(pAdapter, str);
- }
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_SET_TX_FRAME_COUNT is done !\n"));
- }
- }
- break;
-
- case RACFG_CMD_ATE_START_RX_FRAME:
- {
- ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
-
- Set_ATE_Proc(pAdapter, "RXFRAME");
-
- // prepare feedback
- pRaCfg->length = htons(2);
- pRaCfg->status = htons(0);
- wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
- + sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
- + sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
-
- if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
- {
- ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
- Status = -EFAULT;
- }
- else
- {
- ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RX_START is done !\n"));
- }
- }
- break;
- default:
- break;
- }
- ASSERT(pRaCfg != NULL);
- if (pRaCfg != NULL)
- {
- kfree(pRaCfg);
- }
- return;
-}
-
-VOID BubbleSort(INT32 n, INT32 a[])
-{
- INT32 k, j, temp;
-
- for (k = n-1; k>0; k--)
- {
- for (j = 0; j<k; j++)
- {
- if(a[j] > a[j+1])
- {
- temp = a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- }
- }
- }
-}
-
-VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
-{
- INT32 RSSI0, RSSI1, RSSI2;
- CHAR Rssi0Offset, Rssi1Offset, Rssi2Offset;
- UCHAR BbpR50Rssi0 = 0, BbpR51Rssi1 = 0, BbpR52Rssi2 = 0;
- UCHAR Org_BBP66value = 0, Org_BBP69value = 0, Org_BBP70value = 0, data = 0;
- USHORT LNA_Gain = 0;
- INT32 j = 0;
- UCHAR Org_Channel = pAd->ate.Channel;
- USHORT GainValue = 0, OffsetValue = 0;
-
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &Org_BBP66value);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R69, &Org_BBP69value);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R70, &Org_BBP70value);
-
- //**********************************************************************
- // Read the value of LNA gain and Rssi offset
- //**********************************************************************
- RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, GainValue);
-
- // for Noise Level
- if (channel <= 14)
- {
- LNA_Gain = GainValue & 0x00FF;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, OffsetValue);
- Rssi0Offset = OffsetValue & 0x00FF;
- Rssi1Offset = (OffsetValue & 0xFF00) >> 8;
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_BG_OFFSET + 2)/* 0x48 */, OffsetValue);
- Rssi2Offset = OffsetValue & 0x00FF;
- }
- else
- {
- LNA_Gain = (GainValue & 0xFF00) >> 8;
-
- RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, OffsetValue);
- Rssi0Offset = OffsetValue & 0x00FF;
- Rssi1Offset = (OffsetValue & 0xFF00) >> 8;
- RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET + 2)/* 0x4C */, OffsetValue);
- Rssi2Offset = OffsetValue & 0x00FF;
- }
- //**********************************************************************
- {
- pAd->ate.Channel = channel;
- ATEAsicSwitchChannel(pAd);
- mdelay(5);
-
- data = 0x10;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, data);
- data = 0x40;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, data);
- data = 0x40;
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, data);
- mdelay(5);
-
- // Start Rx
- pAd->ate.bQARxStart = TRUE;
- Set_ATE_Proc(pAd, "RXFRAME");
-
- mdelay(5);
-
- for (j = 0; j < 10; j++)
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R50, &BbpR50Rssi0);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R51, &BbpR51Rssi1);
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R52, &BbpR52Rssi2);
-
- mdelay(10);
-
- // Calculate RSSI 0
- if (BbpR50Rssi0 == 0)
- {
- RSSI0 = -100;
- }
- else
- {
- RSSI0 = (INT32)(-12 - BbpR50Rssi0 - LNA_Gain - Rssi0Offset);
- }
- RSSI[0][j] = RSSI0;
-
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- // Calculate RSSI 1
- if (BbpR51Rssi1 == 0)
- {
- RSSI1 = -100;
- }
- else
- {
- RSSI1 = (INT32)(-12 - BbpR51Rssi1 - LNA_Gain - Rssi1Offset);
- }
- RSSI[1][j] = RSSI1;
- }
-
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- // Calculate RSSI 2
- if (BbpR52Rssi2 == 0)
- RSSI2 = -100;
- else
- RSSI2 = (INT32)(-12 - BbpR52Rssi2 - LNA_Gain - Rssi2Offset);
-
- RSSI[2][j] = RSSI2;
- }
- }
-
- // Stop Rx
- Set_ATE_Proc(pAd, "RXSTOP");
-
- mdelay(5);
-
- BubbleSort(10, RSSI[0]); // 1R
-
- if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
- {
- BubbleSort(10, RSSI[1]);
- }
-
- if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
- {
- BubbleSort(10, RSSI[2]);
- }
-
- }
-
- pAd->ate.Channel = Org_Channel;
- ATEAsicSwitchChannel(pAd);
-
- // Restore original value
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, Org_BBP66value);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, Org_BBP69value);
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, Org_BBP70value);
-
- return;
-}
-
-BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
-{
- UCHAR tmp = 0, bbp_data = 0;
-
- if (ATE_ON(pAd))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAd, offset, &bbp_data);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, offset, &bbp_data);
- }
-
- /* confirm again */
- ASSERT(bbp_data == value);
-
- switch(offset)
- {
- case BBP_R1:
- /* Need to sync. tx configuration with legacy ATE. */
- tmp = (bbp_data & ((1 << 4) | (1 << 3))/* 0x18 */) >> 3;
- switch(tmp)
- {
- /* The BBP R1 bit[4:3] = 2 :: Both DACs will be used by QA. */
- case 2:
- /* All */
- pAd->ate.TxAntennaSel = 0;
- break;
- /* The BBP R1 bit[4:3] = 0 :: DAC 0 will be used by QA. */
- case 0:
- /* Antenna one */
- pAd->ate.TxAntennaSel = 1;
- break;
- /* The BBP R1 bit[4:3] = 1 :: DAC 1 will be used by QA. */
- case 1:
- /* Antenna two */
- pAd->ate.TxAntennaSel = 2;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__));
- return FALSE;
- }
- break;/* case BBP_R1 */
-
- case BBP_R3:
- /* Need to sync. rx configuration with legacy ATE. */
- tmp = (bbp_data & ((1 << 1) | (1 << 0))/* 0x03 */);
- switch(tmp)
- {
- /* The BBP R3 bit[1:0] = 3 :: All ADCs will be used by QA. */
- case 3:
- /* All */
- pAd->ate.RxAntennaSel = 0;
- break;
- /* The BBP R3 bit[1:0] = 0 :: ADC 0 will be used by QA, */
- /* unless the BBP R3 bit[4:3] = 2 */
- case 0:
- /* Antenna one */
- pAd->ate.RxAntennaSel = 1;
- tmp = ((bbp_data & ((1 << 4) | (1 << 3))/* 0x03 */) >> 3);
- if (tmp == 2)// 3R
- {
- /* Default : All ADCs will be used by QA */
- pAd->ate.RxAntennaSel = 0;
- }
- break;
- /* The BBP R3 bit[1:0] = 1 :: ADC 1 will be used by QA. */
- case 1:
- /* Antenna two */
- pAd->ate.RxAntennaSel = 2;
- break;
- /* The BBP R3 bit[1:0] = 2 :: ADC 2 will be used by QA. */
- case 2:
- /* Antenna three */
- pAd->ate.RxAntennaSel = 3;
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __FUNCTION__));
- return FALSE;
- }
- break;/* case BBP_R3 */
-
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__));
- return FALSE;
-
- }
- return TRUE;
-}
-
-static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
-{
- ULONG i, Value = 0;
- ULONG *pDst, *pSrc;
- UCHAR *p8;
-
- p8 = src;
- pDst = (ULONG *) dst;
- pSrc = (ULONG *) src;
-
- for (i = 0 ; i < (len/4); i++)
- {
- /* For alignment issue, we need a variable "Value". */
- memmove(&Value, pSrc, 4);
- Value = htonl(Value);
- memmove(pDst, &Value, 4);
- pDst++;
- pSrc++;
- }
- if ((len % 4) != 0)
- {
- /* wish that it will never reach here */
- memmove(&Value, pSrc, (len % 4));
- Value = htonl(Value);
- memmove(pDst, &Value, (len % 4));
- }
-}
-
-static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
-{
- ULONG i;
- UCHAR *pDst, *pSrc;
-
- pDst = dst;
- pSrc = src;
-
- for (i = 0; i < (len/2); i++)
- {
- memmove(pDst, pSrc, 2);
- *((USHORT *)pDst) = htons(*((USHORT *)pDst));
- pDst+=2;
- pSrc+=2;
- }
-
- if ((len % 2) != 0)
- {
- memmove(pDst, pSrc, 1);
- }
-}
-
-static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32 len)
-{
- UINT32 i, Value;
- UINT32 *pDst, *pSrc;
-
- pDst = (UINT32 *) dst;
- pSrc = (UINT32 *) src;
-
- for (i = 0 ; i < (len/4); i++)
- {
- RTMP_IO_READ32(pAd, (ULONG)pSrc, &Value);
- Value = htonl(Value);
- memmove(pDst, &Value, 4);
- pDst++;
- pSrc++;
- }
- return;
-}
-
-INT Set_TxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE,("Set_TxStop_Proc\n"));
-
- if (Set_ATE_Proc(pAd, "TXSTOP"))
- {
- return TRUE;
-}
- else
- {
- return FALSE;
- }
-}
-
-INT Set_RxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- ATEDBGPRINT(RT_DEBUG_TRACE,("Set_RxStop_Proc\n"));
-
- if (Set_ATE_Proc(pAd, "RXSTOP"))
- {
- return TRUE;
-}
- else
- {
- return FALSE;
- }
-}
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
diff --git a/drivers/staging/rt3070/rt_ate.h b/drivers/staging/rt3070/rt_ate.h
deleted file mode 100644
index 829ebb5f7236..000000000000
--- a/drivers/staging/rt3070/rt_ate.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __ATE_H__
-#define __ATE_H__
-
-#ifndef UCOS
-#define ate_print printk
-#define ATEDBGPRINT DBGPRINT
-
-#ifdef RT2870
-#define EEPROM_SIZE 0x400
-#ifdef CONFIG_STA_SUPPORT
-#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2870STA/e2p.bin"
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
-#else // !UCOS //
-#define fATE_LOAD_EEPROM 0x0C43
-#ifdef CONFIG_PRINTK
-extern INT ConsoleResponse(IN PUCHAR buff);
-extern int (*remote_display)(char *);
-extern void puts (const char *s);
-
-/* specificly defined to redirect and show ate-related messages to host. */
-/* Try to define ate_print as a macro. */
-#define ate_print(fmt, args...) \
-do{ int (*org_remote_display)(char *) = NULL; \
- org_remote_display = remote_display;\
- /* Save original "remote_display" */\
- remote_display = (int (*)(char *))ConsoleResponse; \
- printk(fmt, ## args); \
- /* Restore the remote_display function pointer */ \
- remote_display = org_remote_display; }while(0)
-
-#define ATEDBGPRINT(Level, Fmt) \
-{ \
- if ((Level) <= RTDebugLevel) \
- { \
- ate_print Fmt; \
- } \
-}
-#endif // CONFIG_PRINTK //
-#endif // !UCOS //
-
-#define ATE_ON(_p) (((_p)->ate.Mode) != ATE_STOP)
-
-/* RT2880_iNIC will define "RT2860". */
-
-/* RT2880_iNIC will define RT2860. */
-
-#ifdef RT2870
-#define EEPROM_SIZE 0x400
-#ifdef CONFIG_STA_SUPPORT
-#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2870STA/e2p.bin"
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT2870 //
-
-#ifdef RT2870
-#define ATE_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)
-#define ATE_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)
-
-#define BULK_OUT_LOCK(pLock, IrqFlags) \
- if(1 /*!(in_interrupt() & 0xffff0000)*/) \
- RTMP_IRQ_LOCK((pLock), IrqFlags);
-
-#define BULK_OUT_UNLOCK(pLock, IrqFlags) \
- if(1 /*!(in_interrupt() & 0xffff0000)*/) \
- RTMP_IRQ_UNLOCK((pLock), IrqFlags);
-
-// Prototypes of completion funuc.
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define ATE_RTUSBBulkOutDataPacketComplete(purb, pt_regs) ATE_RTUSBBulkOutDataPacketComplete(purb)
-#endif
-
-VOID ATE_RTUSBBulkOutDataPacketComplete(
- IN purbb_t purb,
- OUT struct pt_regs *pt_regs);
-
-VOID ATE_RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId);
-
-VOID ATE_RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-#ifdef RT30xx
-#define ATE_RF_IO_READ8_BY_REG_ID(_A, _I, _pV) RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV)
-#define ATE_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V)
-#endif // RT30xx //
-
-
-VOID rt_ee_read_all(
- IN PRTMP_ADAPTER pAd,
- OUT USHORT *Data);
-
-
-VOID rt_ee_write_all(
- IN PRTMP_ADAPTER pAd,
- IN USHORT *Data);
-
-INT Set_ATE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_DA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_SA_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_BSSID_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_CHANNEL_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_POWER0_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_POWER1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_RX_Antenna_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_FREQOFFSET_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_BW_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_LENGTH_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_COUNT_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_MCS_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_MODE_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_TX_GI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_ATE_RX_FER_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Read_RF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF1_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF2_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF3_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Write_RF4_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Load_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Read_E2P_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Show_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ATE_Help_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
-VOID ATE_QA_Statistics(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC p28xxRxD,
- IN PHEADER_802_11 pHeader);
-
-VOID RtmpDoAte(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID BubbleSort(
- IN INT32 n,
- IN INT32 a[]);
-
-VOID CalNoiseLevel(
- IN PRTMP_ADAPTER pAdapter,
- IN UCHAR channel,
- OUT INT32 buffer[3][10]);
-
-BOOLEAN SyncTxRxConfig(
- IN PRTMP_ADAPTER pAdapter,
- IN USHORT offset,
- IN UCHAR value);
-
-INT Set_TxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RxStop_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-VOID ATEAsicSwitchChannel(
- IN PRTMP_ADAPTER pAd);
-
-VOID ATEAsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd);
-
-VOID ATEDisableAsicProtect(
- IN PRTMP_ADAPTER pAd);
-
-CHAR ATEConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber);
-
-VOID ATESampleRssi(
- IN PRTMP_ADAPTER pAd,
- IN PRXWI_STRUC pRxWI);
-
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPStationStop(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPStationStart(
- IN PRTMP_ADAPTER pAd);
-#endif // CONFIG_STA_SUPPORT //
-#endif // __ATE_H__ //
diff --git a/drivers/staging/rt3070/rt_config.h b/drivers/staging/rt3070/rt_config.h
index 9e06417f63d3..3e8fcbdd5794 100644
--- a/drivers/staging/rt3070/rt_config.h
+++ b/drivers/staging/rt3070/rt_config.h
@@ -1,121 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rt_config.h
-
- Abstract:
- Central header file to maintain all include files for all NDIS
- miniport driver routines.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
-
-*/
-#ifndef __RT_CONFIG_H__
-#define __RT_CONFIG_H__
-
-#include "rtmp_type.h"
-#ifdef UCOS
-#include "includes.h"
-#include <stdio.h>
-#include "rt_ucos.h"
-#endif
-
-#ifdef LINUX
-#include "rt_linux.h"
-#endif
-#include "rtmp_def.h"
-#include "rt28xx.h"
-
-
-#ifdef RT2870
-#include "rt2870.h"
-#endif // RT2870 //
-
-#include "oid.h"
-#include "mlme.h"
-#include "wpa.h"
-#include "md5.h"
-#include "rtmp.h"
-#include "ap.h"
-#include "dfs.h"
-#include "chlist.h"
-#include "spectrum.h"
-#ifdef MLME_EX
-#include "mlme_ex_def.h"
-#include "mlme_ex.h"
-#endif // MLME_EX //
-
-#undef AP_WSC_INCLUDED
-#undef STA_WSC_INCLUDED
-#undef WSC_INCLUDED
-
-
-#ifdef LEAP_SUPPORT
-#include "leap.h"
-#endif // LEAP_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef BLOCK_NET_IF
-#include "netif_block.h"
-#endif // BLOCK_NET_IF //
-
-#ifdef IGMP_SNOOP_SUPPORT
-#include "igmp_snoop.h"
-#endif // IGMP_SNOOP_SUPPORT //
-
-#ifdef RALINK_ATE
-#include "rt_ate.h"
-#endif // RALINK_ATE //
-
-
-
-#if defined(AP_WSC_INCLUDED) || defined(STA_WSC_INCLUDED)
-#define WSC_INCLUDED
-#endif
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifndef WPA_SUPPLICANT_SUPPORT
-#error "Build for being controlled by NetworkManager or wext, please set HAS_WPA_SUPPLICANT=y and HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y"
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef IKANOS_VX_1X0
-#include "vr_ikans.h"
-#endif // IKANOS_VX_1X0 //
-
-#endif // __RT_CONFIG_H__
-
+#include "../rt2870/rt_config.h"
diff --git a/drivers/staging/rt3070/rt_linux.c b/drivers/staging/rt3070/rt_linux.c
index bf3385365da1..6185f2e99924 100644
--- a/drivers/staging/rt3070/rt_linux.c
+++ b/drivers/staging/rt3070/rt_linux.c
@@ -1,1063 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-ULONG RTDebugLevel = RT_DEBUG_ERROR;
-
-BUILD_TIMER_FUNCTION(MlmePeriodicExec);
-//BUILD_TIMER_FUNCTION(MlmeRssiReportExec);
-BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-BUILD_TIMER_FUNCTION(APSDPeriodicExec);
-BUILD_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RT2870
-BUILD_TIMER_FUNCTION(BeaconUpdateExec);
-#endif // RT2870 //
-
-
-#ifdef CONFIG_STA_SUPPORT
-BUILD_TIMER_FUNCTION(BeaconTimeout);
-BUILD_TIMER_FUNCTION(ScanTimeout);
-BUILD_TIMER_FUNCTION(AuthTimeout);
-BUILD_TIMER_FUNCTION(AssocTimeout);
-BUILD_TIMER_FUNCTION(ReassocTimeout);
-BUILD_TIMER_FUNCTION(DisassocTimeout);
-BUILD_TIMER_FUNCTION(LinkDownExec);
-#ifdef LEAP_SUPPORT
-BUILD_TIMER_FUNCTION(LeapAuthTimeout);
-#endif
-BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-#ifdef QOS_DLS_SUPPORT
-BUILD_TIMER_FUNCTION(DlsTimeoutAction);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-
-
-
-// for wireless system event message
-char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
- // system status event
- "had associated successfully", /* IW_ASSOC_EVENT_FLAG */
- "had disassociated", /* IW_DISASSOC_EVENT_FLAG */
- "had deauthenticated", /* IW_DEAUTH_EVENT_FLAG */
- "had been aged-out and disassociated", /* IW_AGEOUT_EVENT_FLAG */
- "occurred CounterMeasures attack", /* IW_COUNTER_MEASURES_EVENT_FLAG */
- "occurred replay counter different in Key Handshaking", /* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
- "occurred RSNIE different in Key Handshaking", /* IW_RSNIE_DIFF_EVENT_FLAG */
- "occurred MIC different in Key Handshaking", /* IW_MIC_DIFF_EVENT_FLAG */
- "occurred ICV error in RX", /* IW_ICV_ERROR_EVENT_FLAG */
- "occurred MIC error in RX", /* IW_MIC_ERROR_EVENT_FLAG */
- "Group Key Handshaking timeout", /* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
- "Pairwise Key Handshaking timeout", /* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
- "RSN IE sanity check failure", /* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
- "set key done in WPA/WPAPSK", /* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
- "set key done in WPA2/WPA2PSK", /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
- "connects with our wireless client", /* IW_STA_LINKUP_EVENT_FLAG */
- "disconnects with our wireless client", /* IW_STA_LINKDOWN_EVENT_FLAG */
- "scan completed" /* IW_SCAN_COMPLETED_EVENT_FLAG */
- "scan terminate!! Busy!! Enqueue fail!!" /* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
- };
-
-// for wireless IDS_spoof_attack event message
-char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
- "detected conflict SSID", /* IW_CONFLICT_SSID_EVENT_FLAG */
- "detected spoofed association response", /* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
- "detected spoofed reassociation responses", /* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
- "detected spoofed probe response", /* IW_SPOOF_PROBE_RESP_EVENT_FLAG */
- "detected spoofed beacon", /* IW_SPOOF_BEACON_EVENT_FLAG */
- "detected spoofed disassociation", /* IW_SPOOF_DISASSOC_EVENT_FLAG */
- "detected spoofed authentication", /* IW_SPOOF_AUTH_EVENT_FLAG */
- "detected spoofed deauthentication", /* IW_SPOOF_DEAUTH_EVENT_FLAG */
- "detected spoofed unknown management frame", /* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
- "detected replay attack" /* IW_REPLAY_ATTACK_EVENT_FLAG */
- };
-
-// for wireless IDS_flooding_attack event message
-char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
- "detected authentication flooding", /* IW_FLOOD_AUTH_EVENT_FLAG */
- "detected association request flooding", /* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
- "detected reassociation request flooding", /* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
- "detected probe request flooding", /* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
- "detected disassociation flooding", /* IW_FLOOD_DISASSOC_EVENT_FLAG */
- "detected deauthentication flooding", /* IW_FLOOD_DEAUTH_EVENT_FLAG */
- "detected 802.1x eap-request flooding" /* IW_FLOOD_EAP_REQ_EVENT_FLAG */
- };
-
-
-/* timeout -- ms */
-VOID RTMP_SetPeriodicTimer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout)
-{
- timeout = ((timeout*HZ) / 1000);
- pTimer->expires = jiffies + timeout;
- add_timer(pTimer);
-}
-
-/* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
-VOID RTMP_OS_Init_Timer(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN TIMER_FUNCTION function,
- IN PVOID data)
-{
- init_timer(pTimer);
- pTimer->data = (unsigned long)data;
- pTimer->function = function;
-}
-
-
-VOID RTMP_OS_Add_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout)
-{
- if (timer_pending(pTimer))
- return;
-
- timeout = ((timeout*HZ) / 1000);
- pTimer->expires = jiffies + timeout;
- add_timer(pTimer);
-}
-
-VOID RTMP_OS_Mod_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout)
-{
- timeout = ((timeout*HZ) / 1000);
- mod_timer(pTimer, jiffies + timeout);
-}
-
-VOID RTMP_OS_Del_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- OUT BOOLEAN *pCancelled)
-{
- if (timer_pending(pTimer))
- {
- *pCancelled = del_timer_sync(pTimer);
- }
- else
- {
- *pCancelled = TRUE;
- }
-
-}
-
-VOID RTMP_OS_Release_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PQUEUE_ENTRY pEntry)
-{
- //RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry);
-}
-
-// Unify all delay routine by using udelay
-VOID RTMPusecDelay(
- IN ULONG usec)
-{
- ULONG i;
-
- for (i = 0; i < (usec / 50); i++)
- udelay(50);
-
- if (usec % 50)
- udelay(usec % 50);
-}
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time)
-{
- time->u.LowPart = jiffies;
-}
-
-// pAd MUST allow to be NULL
-NDIS_STATUS os_alloc_mem(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR *mem,
- IN ULONG size)
-{
- *mem = (PUCHAR) kmalloc(size, GFP_ATOMIC);
- if (*mem)
- return (NDIS_STATUS_SUCCESS);
- else
- return (NDIS_STATUS_FAILURE);
-}
-
-// pAd MUST allow to be NULL
-NDIS_STATUS os_free_mem(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mem)
-{
-
- ASSERT(mem);
- kfree(mem);
- return (NDIS_STATUS_SUCCESS);
-}
-
-
-PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length)
-{
- struct sk_buff *pkt;
-
- pkt = dev_alloc_skb(Length);
-
- if (pkt == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("can't allocate frag rx %ld size packet\n",Length));
- }
-
- if (pkt)
- {
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
- }
-
- return (PNDIS_PACKET) pkt;
-}
-
-
-PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress)
-{
- struct sk_buff *pkt;
-
- pkt = dev_alloc_skb(Length);
-
- if (pkt == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("can't allocate tx %ld size packet\n",Length));
- }
-
- if (pkt)
- {
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
- *VirtualAddress = (PVOID) pkt->data;
- }
- else
- {
- *VirtualAddress = (PVOID) NULL;
- }
-
- return (PNDIS_PACKET) pkt;
-}
-
-
-VOID build_tx_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pFrame,
- IN ULONG FrameLen)
-{
-
- struct sk_buff *pTxPkt;
-
- ASSERT(pPacket);
- pTxPkt = RTPKT_TO_OSPKT(pPacket);
-
- NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
-}
-
-VOID RTMPFreeAdapter(
- IN PRTMP_ADAPTER pAd)
-{
- POS_COOKIE os_cookie;
- int index;
-
- os_cookie=(POS_COOKIE)pAd->OS_Cookie;
-
- kfree(pAd->BeaconBuf);
-
-
- NdisFreeSpinLock(&pAd->MgmtRingLock);
-
-
- for (index =0 ; index < NUM_OF_TX_RING; index++)
- {
- NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
- NdisFreeSpinLock(&pAd->DeQueueLock[index]);
- pAd->DeQueueRunning[index] = FALSE;
- }
-
- NdisFreeSpinLock(&pAd->irq_lock);
-
-
- vfree(pAd); // pci_free_consistent(os_cookie->pci_dev,sizeof(RTMP_ADAPTER),pAd,os_cookie->pAd_pa);
- kfree(os_cookie);
-}
-
-BOOLEAN OS_Need_Clone_Packet(void)
-{
- return (FALSE);
-}
-
-
-
-/*
- ========================================================================
-
- Routine Description:
- clone an input NDIS PACKET to another one. The new internally created NDIS PACKET
- must have only one NDIS BUFFER
- return - byte copied. 0 means can't create NDIS PACKET
- NOTE: internally created NDIS_PACKET should be destroyed by RTMPFreeNdisPacket
-
- Arguments:
- pAd Pointer to our adapter
- pInsAMSDUHdr EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
- *pSrcTotalLen return total packet length. This lenght is calculated with 802.3 format packet.
-
- Return Value:
- NDIS_STATUS_SUCCESS
- NDIS_STATUS_FAILURE
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS RTMPCloneNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN pInsAMSDUHdr,
- IN PNDIS_PACKET pInPacket,
- OUT PNDIS_PACKET *ppOutPacket)
-{
-
- struct sk_buff *pkt;
-
- ASSERT(pInPacket);
- ASSERT(ppOutPacket);
-
- // 1. Allocate a packet
- pkt = dev_alloc_skb(2048);
-
- if (pkt == NULL)
- {
- return NDIS_STATUS_FAILURE;
- }
-
- skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
- NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));
- *ppOutPacket = OSPKT_TO_RTPKT(pkt);
-
-
- RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-
- printk("###Clone###\n");
-
- return NDIS_STATUS_SUCCESS;
-}
-
-
-// the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket()
-NDIS_STATUS RTMPAllocateNdisPacket(
- IN PRTMP_ADAPTER pAd,
- OUT PNDIS_PACKET *ppPacket,
- IN PUCHAR pHeader,
- IN UINT HeaderLen,
- IN PUCHAR pData,
- IN UINT DataLen)
-{
- PNDIS_PACKET pPacket;
- ASSERT(pData);
- ASSERT(DataLen);
-
- // 1. Allocate a packet
- pPacket = (PNDIS_PACKET *) dev_alloc_skb(HeaderLen + DataLen + TXPADDING_SIZE);
- if (pPacket == NULL)
- {
- *ppPacket = NULL;
-#ifdef DEBUG
- printk("RTMPAllocateNdisPacket Fail\n\n");
-#endif
- return NDIS_STATUS_FAILURE;
- }
-
- // 2. clone the frame content
- if (HeaderLen > 0)
- NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket), pHeader, HeaderLen);
- if (DataLen > 0)
- NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket) + HeaderLen, pData, DataLen);
-
- // 3. update length of packet
- skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
-
- RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-// printk("%s : pPacket = %p, len = %d\n", __FUNCTION__, pPacket, GET_OS_PKT_LEN(pPacket));
- *ppPacket = pPacket;
- return NDIS_STATUS_SUCCESS;
-}
-
-/*
- ========================================================================
- Description:
- This routine frees a miniport internally allocated NDIS_PACKET and its
- corresponding NDIS_BUFFER and allocated memory.
- ========================================================================
-*/
-VOID RTMPFreeNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- dev_kfree_skb_any(RTPKT_TO_OSPKT(pPacket));
-}
-
-
-// IRQL = DISPATCH_LEVEL
-// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same
-// scatter gather buffer
-NDIS_STATUS Sniff2BytesFromNdisBuffer(
- IN PNDIS_BUFFER pFirstBuffer,
- IN UCHAR DesiredOffset,
- OUT PUCHAR pByte0,
- OUT PUCHAR pByte1)
-{
- *pByte0 = *(PUCHAR)(pFirstBuffer + DesiredOffset);
- *pByte1 = *(PUCHAR)(pFirstBuffer + DesiredOffset + 1);
-
- return NDIS_STATUS_SUCCESS;
-}
-
-
-void RTMP_QueryPacketInfo(
- IN PNDIS_PACKET pPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen)
-{
- pPacketInfo->BufferCount = 1;
- pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
- pPacketInfo->PhysicalBufferCount = 1;
- pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
- *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
- *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
-}
-
-void RTMP_QueryNextPacketInfo(
- IN PNDIS_PACKET *ppPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen)
-{
- PNDIS_PACKET pPacket = NULL;
-
- if (*ppPacket)
- pPacket = GET_OS_PKT_NEXT(*ppPacket);
-
- if (pPacket)
- {
- pPacketInfo->BufferCount = 1;
- pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
- pPacketInfo->PhysicalBufferCount = 1;
- pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
- *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
- *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
- *ppPacket = GET_OS_PKT_NEXT(pPacket);
- }
- else
- {
- pPacketInfo->BufferCount = 0;
- pPacketInfo->pFirstBuffer = NULL;
- pPacketInfo->PhysicalBufferCount = 0;
- pPacketInfo->TotalPacketLength = 0;
-
- *pSrcBufVA = NULL;
- *pSrcBufLen = 0;
- *ppPacket = NULL;
- }
-}
-
-// not yet support MBSS
-PNET_DEV get_netdev_from_bssid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR FromWhichBSSID)
-{
- PNET_DEV dev_p = NULL;
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- dev_p = pAd->net_dev;
- }
-#endif // CONFIG_STA_SUPPORT //
-
- ASSERT(dev_p);
- return dev_p; /* return one of MBSS */
-}
-
-PNDIS_PACKET DuplicatePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *skb;
- PNDIS_PACKET pRetPacket = NULL;
- USHORT DataSize;
- UCHAR *pData;
-
- DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
- pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
-
-
- skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
- if (skb)
- {
- skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pRetPacket = OSPKT_TO_RTPKT(skb);
- }
-
- return pRetPacket;
-
-}
-
-PNDIS_PACKET duplicate_pkt(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *skb;
- PNDIS_PACKET pPacket = NULL;
-
-
- if ((skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL)
- {
- skb_reserve(skb, 2);
- NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
- skb_put(skb, HdrLen);
- NdisMoveMemory(skb->tail, pData, DataSize);
- skb_put(skb, DataSize);
- skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pPacket = OSPKT_TO_RTPKT(skb);
- }
-
- return pPacket;
-}
-
-
-#define TKIP_TX_MIC_SIZE 8
-PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- struct sk_buff *skb, *newskb;
-
-
- skb = RTPKT_TO_OSPKT(pPacket);
- if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE)
- {
- // alloc a new skb and copy the packet
- newskb = skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE, GFP_ATOMIC);
- dev_kfree_skb_any(skb);
- if (newskb == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Extend Tx.MIC for packet failed!, dropping packet!\n"));
- return NULL;
- }
- skb = newskb;
- }
-
- return OSPKT_TO_RTPKT(skb);
-}
-
-
-
-
-PNDIS_PACKET ClonePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize)
-{
- struct sk_buff *pRxPkt;
- struct sk_buff *pClonedPkt;
-
- ASSERT(pPacket);
- pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
- // clone the packet
- pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
-
- if (pClonedPkt)
- {
- // set the correct dataptr and data len
- pClonedPkt->dev = pRxPkt->dev;
- pClonedPkt->data = pData;
- pClonedPkt->len = DataSize;
- pClonedPkt->tail = pClonedPkt->data + pClonedPkt->len;
- ASSERT(DataSize < 1530);
- }
- return pClonedPkt;
-}
-
-//
-// change OS packet DataPtr and DataLen
-//
-void update_os_packet_info(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *pOSPkt;
-
- ASSERT(pRxBlk->pRxPacket);
- pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
- pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pOSPkt->data = pRxBlk->pData;
- pOSPkt->len = pRxBlk->DataSize;
- pOSPkt->tail = pOSPkt->data + pOSPkt->len;
-}
-
-
-void wlan_802_11_to_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN PUCHAR pHeader802_3,
- IN UCHAR FromWhichBSSID)
-{
- struct sk_buff *pOSPkt;
-
- ASSERT(pRxBlk->pRxPacket);
- ASSERT(pHeader802_3);
-
- pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
- pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
- pOSPkt->data = pRxBlk->pData;
- pOSPkt->len = pRxBlk->DataSize;
- pOSPkt->tail = pOSPkt->data + pOSPkt->len;
-
- //
- // copy 802.3 header
- //
- //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
-
-void announce_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
-
- struct sk_buff *pRxPkt;
-
- ASSERT(pPacket);
-
- pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- /* Push up the protocol stack */
-#ifdef IKANOS_VX_1X0
- IKANOS_DataFrameRx(pAd, pRxPkt->dev, pRxPkt, pRxPkt->len);
-#else
- pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
-
-//#ifdef CONFIG_5VT_ENHANCE
-// *(int*)(pRxPkt->cb) = BRIDGE_TAG;
-//#endif
- netif_rx(pRxPkt);
-#endif // IKANOS_VX_1X0 //
-}
-
-
-PRTMP_SCATTER_GATHER_LIST
-rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg)
-{
- sg->NumberOfElements = 1;
- sg->Elements[0].Address = GET_OS_PKT_DATAPTR(pPacket);
- sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
- return (sg);
-}
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
-{
- unsigned char *pt;
- int x;
-
- if (RTDebugLevel < RT_DEBUG_TRACE)
- return;
-
- pt = pSrcBufVA;
- printk("%s: %p, len = %d\n",str, pSrcBufVA, SrcBufLen);
- for (x=0; x<SrcBufLen; x++)
- {
- if (x % 16 == 0)
- printk("0x%04x : ", x);
- printk("%02x ", ((unsigned char)pt[x]));
- if (x%16 == 15) printk("\n");
- }
- printk("\n");
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Send log message through wireless event
-
- Support standard iw_event with IWEVCUSTOM. It is used below.
-
- iwreq_data.data.flags is used to store event_flag that is defined by user.
- iwreq_data.data.length is the length of the event log.
-
- The format of the event log is composed of the entry's MAC address and
- the desired log message (refer to pWirelessEventText).
-
- ex: 11:22:33:44:55:66 has associated successfully
-
- p.s. The requirement of Wireless Extension is v15 or newer.
-
- ========================================================================
-*/
-VOID RTMPSendWirelessEvent(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Event_flag,
- IN PUCHAR pAddr,
- IN UCHAR BssIdx,
- IN CHAR Rssi)
-{
-#if WIRELESS_EXT >= 15
-
- union iwreq_data wrqu;
- PUCHAR pBuf = NULL, pBufPtr = NULL;
- USHORT event, type, BufLen;
- UCHAR event_table_len = 0;
-
- type = Event_flag & 0xFF00;
- event = Event_flag & 0x00FF;
-
- switch (type)
- {
- case IW_SYS_EVENT_FLAG_START:
- event_table_len = IW_SYS_EVENT_TYPE_NUM;
- break;
-
- case IW_SPOOF_EVENT_FLAG_START:
- event_table_len = IW_SPOOF_EVENT_TYPE_NUM;
- break;
-
- case IW_FLOOD_EVENT_FLAG_START:
- event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
- break;
- }
-
- if (event_table_len == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __FUNCTION__, type));
- return;
- }
-
- if (event >= event_table_len)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __FUNCTION__, event));
- return;
- }
-
- //Allocate memory and copy the msg.
- if((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL)
- {
- //Prepare the payload
- memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
-
- pBufPtr = pBuf;
-
- if (pAddr)
- pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));
- else if (BssIdx < MAX_MBSSID_NUM)
- pBufPtr += sprintf(pBufPtr, "(RT2860) BSS(ra%d) ", BssIdx);
- else
- pBufPtr += sprintf(pBufPtr, "(RT2860) ");
-
- if (type == IW_SYS_EVENT_FLAG_START)
- pBufPtr += sprintf(pBufPtr, "%s", pWirelessSysEventText[event]);
- else if (type == IW_SPOOF_EVENT_FLAG_START)
- pBufPtr += sprintf(pBufPtr, "%s (RSSI=%d)", pWirelessSpoofEventText[event], Rssi);
- else if (type == IW_FLOOD_EVENT_FLAG_START)
- pBufPtr += sprintf(pBufPtr, "%s", pWirelessFloodEventText[event]);
- else
- pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
-
- pBufPtr[pBufPtr - pBuf] = '\0';
- BufLen = pBufPtr - pBuf;
-
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = Event_flag;
- wrqu.data.length = BufLen;
-
- //send wireless event
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
-
- //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __FUNCTION__, pBuf));
-
- kfree(pBuf);
- }
- else
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __FUNCTION__));
-#else
- DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __FUNCTION__));
-#endif /* WIRELESS_EXT >= 15 */
-}
-
-
-#ifdef CONFIG_STA_SUPPORT
-void send_monitor_packets(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- struct sk_buff *pOSPkt;
- wlan_ng_prism2_header *ph;
- int rate_index = 0;
- USHORT header_len = 0;
- UCHAR temp_header[40] = {0};
-
- u_int32_t ralinkrate[256] = {2,4,11,22, 12,18,24,36,48,72,96, 108, 109, 110, 111, 112, 13, 26, 39, 52,78,104, 117, 130, 26, 52, 78,104, 156, 208, 234, 260, 27, 54,81,108,162, 216, 243, 270, // Last 38
- 54, 108, 162, 216, 324, 432, 486, 540, 14, 29, 43, 57, 87, 115, 130, 144, 29, 59,87,115, 173, 230,260, 288, 30, 60,90,120,180,240,270,300,60,120,180,240,360,480,540,600, 0,1,2,3,4,5,6,7,8,9,10,
- 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};
-
-
- ASSERT(pRxBlk->pRxPacket);
- if (pRxBlk->DataSize < 10)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __FUNCTION__, pRxBlk->DataSize));
- goto err_free_sk_buff;
- }
-
- if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
- goto err_free_sk_buff;
- }
-
- pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
- pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
- if (pRxBlk->pHeader->FC.Type == BTYPE_DATA)
- {
- pRxBlk->DataSize -= LENGTH_802_11;
- if ((pRxBlk->pHeader->FC.ToDs == 1) &&
- (pRxBlk->pHeader->FC.FrDs == 1))
- header_len = LENGTH_802_11_WITH_ADDR4;
- else
- header_len = LENGTH_802_11;
-
- // QOS
- if (pRxBlk->pHeader->FC.SubType & 0x08)
- {
- header_len += 2;
- // Data skip QOS contorl field
- pRxBlk->DataSize -=2;
- }
-
- // Order bit: A-Ralink or HTC+
- if (pRxBlk->pHeader->FC.Order)
- {
- header_len += 4;
- // Data skip HTC contorl field
- pRxBlk->DataSize -= 4;
- }
-
- // Copy Header
- if (header_len <= 40)
- NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
-
- // skip HW padding
- if (pRxBlk->RxD.L2PAD)
- pRxBlk->pData += (header_len + 2);
- else
- pRxBlk->pData += header_len;
- } //end if
-
-
- if (pRxBlk->DataSize < pOSPkt->len) {
- skb_trim(pOSPkt,pRxBlk->DataSize);
- } else {
- skb_put(pOSPkt,(pRxBlk->DataSize - pOSPkt->len));
- } //end if
-
- if ((pRxBlk->pData - pOSPkt->data) > 0) {
- skb_put(pOSPkt,(pRxBlk->pData - pOSPkt->data));
- skb_pull(pOSPkt,(pRxBlk->pData - pOSPkt->data));
- } //end if
-
- if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
- if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
- DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __FUNCTION__));
- goto err_free_sk_buff;
- } //end if
- } //end if
-
- if (header_len > 0)
- NdisMoveMemory(skb_push(pOSPkt, header_len), temp_header, header_len);
-
- ph = (wlan_ng_prism2_header *) skb_push(pOSPkt, sizeof(wlan_ng_prism2_header));
- NdisZeroMemory(ph, sizeof(wlan_ng_prism2_header));
-
- ph->msgcode = DIDmsg_lnxind_wlansniffrm;
- ph->msglen = sizeof(wlan_ng_prism2_header);
- strcpy(ph->devname, pAd->net_dev->name);
-
- ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
- ph->hosttime.status = 0;
- ph->hosttime.len = 4;
- ph->hosttime.data = jiffies;
-
- ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
- ph->mactime.status = 0;
- ph->mactime.len = 0;
- ph->mactime.data = 0;
-
- ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
- ph->istx.status = 0;
- ph->istx.len = 0;
- ph->istx.data = 0;
-
- ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
- ph->channel.status = 0;
- ph->channel.len = 4;
-
- ph->channel.data = (u_int32_t)pAd->CommonCfg.Channel;
-
- ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
- ph->rssi.status = 0;
- ph->rssi.len = 4;
- ph->rssi.data = (u_int32_t)RTMPMaxRssi(pAd, ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0, RSSI_0), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI1, RSSI_1), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2, RSSI_2));;
-
- ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
- ph->signal.status = 0;
- ph->signal.len = 4;
- ph->signal.data = 0; //rssi + noise;
-
- ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
- ph->noise.status = 0;
- ph->noise.len = 4;
- ph->noise.data = 0;
-
-#ifdef DOT11_N_SUPPORT
- if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX)
- {
- rate_index = 16 + ((UCHAR)pRxBlk->pRxWI->BW *16) + ((UCHAR)pRxBlk->pRxWI->ShortGI *32) + ((UCHAR)pRxBlk->pRxWI->MCS);
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
- rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
- else
- rate_index = (UCHAR)(pRxBlk->pRxWI->MCS);
- if (rate_index < 0)
- rate_index = 0;
- if (rate_index > 255)
- rate_index = 255;
-
- ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
- ph->rate.status = 0;
- ph->rate.len = 4;
- ph->rate.data = ralinkrate[rate_index];
-
- ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
- ph->frmlen.status = 0;
- ph->frmlen.len = 4;
- ph->frmlen.data = (u_int32_t)pRxBlk->DataSize;
-
-
- pOSPkt->pkt_type = PACKET_OTHERHOST;
- pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
- pOSPkt->ip_summed = CHECKSUM_NONE;
- netif_rx(pOSPkt);
-
- return;
-
-err_free_sk_buff:
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
-{
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- daemonize(pThreadName /*"%s",pAd->net_dev->name*/);
-
- allow_signal(SIGTERM);
- allow_signal(SIGKILL);
- current->flags |= PF_NOFREEZE;
-#else
- unsigned long flags;
-
- daemonize();
- reparent_to_init();
- strcpy(current->comm, pThreadName);
-
- siginitsetinv(&current->blocked, sigmask(SIGTERM) | sigmask(SIGKILL));
-
- /* Allow interception of SIGKILL only
- * Don't allow other signals to interrupt the transmission */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,22)
- spin_lock_irqsave(&current->sigmask_lock, flags);
- flush_signals(current);
- recalc_sigpending(current);
- spin_unlock_irqrestore(&current->sigmask_lock, flags);
-#endif
-#endif
-
- /* signal that we've started the thread */
- complete(pNotify);
-
-}
-
-void RTMP_IndicateMediaState(
- IN PRTMP_ADAPTER pAd)
-{
- if (pAd->CommonCfg.bWirelessEvent)
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- else
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
-}
-
+#include "../rt2870/rt_linux.c"
diff --git a/drivers/staging/rt3070/rt_linux.h b/drivers/staging/rt3070/rt_linux.h
index 0540d02da79b..9f7efee3d609 100644
--- a/drivers/staging/rt3070/rt_linux.h
+++ b/drivers/staging/rt3070/rt_linux.h
@@ -1,887 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-/***********************************************************************/
-/* */
-/* Program: rt_linux.c */
-/* Created: 4/21/2006 1:17:38 PM */
-/* Author: Wu Xi-Kun */
-/* Comments: `description` */
-/* */
-/*---------------------------------------------------------------------*/
-/* */
-/* History: */
-/* Revision 1.1 4/21/2006 1:17:38 PM xsikun */
-/* Initial revision */
-/* */
-/***********************************************************************/
-
-#include "rtmp_type.h"
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/kernel.h>
-
-#include <linux/spinlock.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
-#include <linux/proc_fs.h>
-#include <linux/delay.h>
-#include <linux/if_arp.h>
-#include <linux/ctype.h>
-#include <linux/vmalloc.h>
-
-
-#include <linux/wireless.h>
-#include <net/iw_handler.h>
-
-// load firmware
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-#include <asm/uaccess.h>
-
-
-#define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
-
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
-//#define CONFIG_CKIP_SUPPORT
-
-#undef __inline
-#define __inline static inline
-
-typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
-
-// add by kathy
-
-#ifdef CONFIG_STA_SUPPORT
-
-#ifdef RT2870
-#define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
-#define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
-#define STA_NIC_DEVICE_NAME "RT2870STA"
-#define STA_DRIVER_VERSION "2.0.1.0"
-#ifdef MULTIPLE_CARD_SUPPORT
-#define CARD_INFO_PATH "/etc/Wireless/RT2870STA/RT2870STACard.dat"
-#endif // MULTIPLE_CARD_SUPPORT //
-#endif // RT2870 //
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-
-#define RTMP_TIME_AFTER(a,b) \
- (typecheck(unsigned long, (unsigned long)a) && \
- typecheck(unsigned long, (unsigned long)b) && \
- ((long)(b) - (long)(a) < 0))
-
-#define RTMP_TIME_AFTER_EQ(a,b) \
- (typecheck(unsigned long, (unsigned long)a) && \
- typecheck(unsigned long, (unsigned long)b) && \
- ((long)(a) - (long)(b) >= 0))
-#define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
-#else
-#define RTMP_TIME_AFTER(a,b) time_after(a, b)
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#define RT_MOD_INC_USE_COUNT() \
- if (!try_module_get(THIS_MODULE)) \
- { \
- DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \
- return -1; \
- }
-
-#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
-#else
-#define RT_MOD_INC_USE_COUNT() MOD_INC_USE_COUNT;
-#define RT_MOD_DEC_USE_COUNT() MOD_DEC_USE_COUNT;
-#endif
-
-#define OS_HZ HZ
-
-#define ETH_LENGTH_OF_ADDRESS 6
-
-#define IN
-#define OUT
-
-#define NDIS_STATUS INT
-#define NDIS_STATUS_SUCCESS 0x00
-#define NDIS_STATUS_FAILURE 0x01
-#define NDIS_STATUS_INVALID_DATA 0x02
-#define NDIS_STATUS_RESOURCES 0x03
-
-#define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f
-#define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30
-#define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
-#define MIN_NET_DEVICE_FOR_APCLI 0x20
-#define MIN_NET_DEVICE_FOR_MESH 0x30
-#ifdef CONFIG_STA_SUPPORT
-#define MIN_NET_DEVICE_FOR_DLS 0x40
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef CONFIG_STA_SUPPORT
-#define NDIS_PACKET_TYPE_DIRECTED 0
-#define NDIS_PACKET_TYPE_MULTICAST 1
-#define NDIS_PACKET_TYPE_BROADCAST 2
-#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
-#endif // CONFIG_STA_SUPPORT //
-
-struct os_lock {
- spinlock_t lock;
- unsigned long flags;
-};
-
-
-struct os_cookie {
-
-#ifdef RT2870
- struct usb_device *pUsb_Dev;
-
- struct pid * MLMEThr_pid;
- struct pid * RTUSBCmdThr_pid;
- struct pid * TimerQThr_pid;
-#endif // RT2870 //
-
- struct tasklet_struct rx_done_task;
- struct tasklet_struct mgmt_dma_done_task;
- struct tasklet_struct ac0_dma_done_task;
- struct tasklet_struct ac1_dma_done_task;
- struct tasklet_struct ac2_dma_done_task;
- struct tasklet_struct ac3_dma_done_task;
- struct tasklet_struct hcca_dma_done_task;
- struct tasklet_struct tbtt_task;
-#ifdef RT2870
- struct tasklet_struct null_frame_complete_task;
- struct tasklet_struct rts_frame_complete_task;
- struct tasklet_struct pspoll_frame_complete_task;
-#endif // RT2870 //
-
-
- unsigned long apd_pid; //802.1x daemon pid
- INT ioctl_if_type;
- INT ioctl_if;
-};
-
-typedef struct _VIRTUAL_ADAPTER
-{
- struct net_device *RtmpDev;
- struct net_device *VirtualDev;
-} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
-
-#undef ASSERT
-#define ASSERT(x) \
-{ \
- if (!(x)) \
- { \
- printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
- } \
-}
-
-typedef struct os_cookie * POS_COOKIE;
-typedef struct pci_dev * PPCI_DEV;
-typedef struct net_device * PNET_DEV;
-typedef void * PNDIS_PACKET;
-typedef char NDIS_PACKET;
-typedef PNDIS_PACKET * PPNDIS_PACKET;
-typedef dma_addr_t NDIS_PHYSICAL_ADDRESS;
-typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
-//typedef struct timer_list RALINK_TIMER_STRUCT;
-//typedef struct timer_list * PRALINK_TIMER_STRUCT;
-//typedef struct os_lock NDIS_SPIN_LOCK;
-typedef spinlock_t NDIS_SPIN_LOCK;
-typedef struct timer_list NDIS_MINIPORT_TIMER;
-typedef void * NDIS_HANDLE;
-typedef char * PNDIS_BUFFER;
-
-
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
-
-dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
-void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
-
-
-////////////////////////////////////////
-// MOVE TO rtmp.h ?
-/////////////////////////////////////////
-#define PKTSRC_NDIS 0x7f
-#define PKTSRC_DRIVER 0x0f
-#define PRINT_MAC(addr) \
- addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
-
-
-#define RT2860_PCI_DEVICE_ID 0x0601
-
-#ifdef RT2870
-#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
-
-#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
-#endif // RT2870 //
-
-
-#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
- dma_cache_wback(_ptr, _size)
-
-
-//////////////////////////////////////////
-//
-//////////////////////////////////////////
-
-
-#define NdisMIndicateStatus(_w, _x, _y, _z)
-
-
-typedef struct timer_list RTMP_OS_TIMER;
-
-#ifdef RT2870
-/* ----------------- Timer Related MARCO ---------------*/
-// In RT2870, we have a lot of timer functions and will read/write register, it's
-// not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
-// to ctrl pipe). So we need a wrapper function to take care it.
-
-typedef VOID (*RT2870_TIMER_HANDLE)(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-#endif // RT2870 //
-
-
-typedef struct _RALINK_TIMER_STRUCT {
- RTMP_OS_TIMER TimerObj; // Ndis Timer object
- BOOLEAN Valid; // Set to True when call RTMPInitTimer
- BOOLEAN State; // True if timer cancelled
- BOOLEAN PeriodicType; // True if timer is periodic timer
- BOOLEAN Repeat; // True if periodic timer
- ULONG TimerValue; // Timer value in milliseconds
- ULONG cookie; // os specific object
-#ifdef RT2870
- RT2870_TIMER_HANDLE handle;
- void *pAd;
-#endif // RT2870 //
-} RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
-
-
-#ifdef RT2870
-
-typedef enum _RT2870_KERNEL_THREAD_STATUS_
-{
- RT2870_THREAD_UNKNOWN = 0,
- RT2870_THREAD_INITED = 1,
- RT2870_THREAD_RUNNING = 2,
- RT2870_THREAD_STOPED = 4,
-}RT2870_KERNEL_THREAD_STATUS;
-
-#define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
-
-typedef struct _RT2870_TIMER_ENTRY_
-{
- RALINK_TIMER_STRUCT *pRaTimer;
- struct _RT2870_TIMER_ENTRY_ *pNext;
-}RT2870_TIMER_ENTRY;
-
-
-#define TIMER_QUEUE_SIZE_MAX 128
-typedef struct _RT2870_TIMER_QUEUE_
-{
- unsigned int status;
- //wait_queue_head_t timerWaitQ;
- //atomic_t count;
- UCHAR *pTimerQPoll;
- RT2870_TIMER_ENTRY *pQPollFreeList;
- RT2870_TIMER_ENTRY *pQHead;
- RT2870_TIMER_ENTRY *pQTail;
-}RT2870_TIMER_QUEUE;
-#endif // RT2870 //
-
-
-//#define DBG 1
-
-//
-// MACRO for debugging information
-//
-
-#ifdef DBG
-extern ULONG RTDebugLevel;
-
-#define DBGPRINT_RAW(Level, Fmt) \
-{ \
- if (Level <= RTDebugLevel) \
- { \
- printk Fmt; \
- } \
-}
-
-#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
-
-
-#define DBGPRINT_ERR(Fmt) \
-{ \
- printk("ERROR!!! "); \
- printk Fmt; \
-}
-
-#define DBGPRINT_S(Status, Fmt) \
-{ \
- printk Fmt; \
-}
-
-
-#else
-#define DBGPRINT(Level, Fmt)
-#define DBGPRINT_RAW(Level, Fmt)
-#define DBGPRINT_S(Status, Fmt)
-#define DBGPRINT_ERR(Fmt)
-#endif
-
-
-//
-// spin_lock enhanced for Nested spin lock
-//
-#define NdisAllocateSpinLock(__lock) \
-{ \
- spin_lock_init((spinlock_t *)(__lock)); \
-}
-
-#define NdisFreeSpinLock(lock) \
-{ \
-}
-
-
-#define RTMP_SEM_LOCK(__lock) \
-{ \
- spin_lock_bh((spinlock_t *)(__lock)); \
-}
-
-#define RTMP_SEM_UNLOCK(__lock) \
-{ \
- spin_unlock_bh((spinlock_t *)(__lock)); \
-}
-
-// sample, use semaphore lock to replace IRQ lock, 2007/11/15
-#define RTMP_IRQ_LOCK(__lock, __irqflags) \
-{ \
- __irqflags = 0; \
- spin_lock_bh((spinlock_t *)(__lock)); \
- pAd->irq_disabled |= 1; \
-}
-
-#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
-{ \
- pAd->irq_disabled &= 0; \
- spin_unlock_bh((spinlock_t *)(__lock)); \
-}
-
-#define RTMP_INT_LOCK(__lock, __irqflags) \
-{ \
- spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
-}
-
-#define RTMP_INT_UNLOCK(__lock, __irqflag) \
-{ \
- spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
-}
-
-#ifdef RT2870
-#define RTMP_IO_READ32(_A, _R, _pV) \
- RTUSBReadMACRegister(_A, _R, _pV)
-
-#define RTMP_IO_READ8(_A, _R, _pV) \
-{ \
-}
-
-#define RTMP_IO_WRITE32(_A, _R, _V) \
- RTUSBWriteMACRegister(_A, _R, _V)
-
-
-#define RTMP_IO_WRITE8(_A, _R, _V) \
-{ \
- USHORT _Val = _V; \
- RTUSBSingleWrite(_A, _R, _Val); \
-}
-
-
-#define RTMP_IO_WRITE16(_A, _R, _V) \
-{ \
- RTUSBSingleWrite(_A, _R, _V); \
-}
-#endif // RT2870 //
-
-#ifndef wait_event_interruptible_timeout
-#define __wait_event_interruptible_timeout(wq, condition, ret) \
-do { \
- wait_queue_t __wait; \
- init_waitqueue_entry(&__wait, current); \
- add_wait_queue(&wq, &__wait); \
- for (;;) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- if (condition) \
- break; \
- if (!signal_pending(current)) { \
- ret = schedule_timeout(ret); \
- if (!ret) \
- break; \
- continue; \
- } \
- ret = -ERESTARTSYS; \
- break; \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event_interruptible_timeout(wq, condition, timeout) \
-({ \
- long __ret = timeout; \
- if (!(condition)) \
- __wait_event_interruptible_timeout(wq, condition, __ret); \
- __ret; \
-})
-#endif
-#define ONE_TICK 1
-#define OS_WAIT(_time) \
-{ int _i; \
- long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
- wait_queue_head_t _wait; \
- init_waitqueue_head(&_wait); \
- for (_i=0; _i<(_loop); _i++) \
- wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
-
-
-/* Modified by Wu Xi-Kun 4/21/2006 */
-typedef void (*TIMER_FUNCTION)(unsigned long);
-
-#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
-
-#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
-#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
-
-
-#ifdef RT2870
-#define BUILD_TIMER_FUNCTION(_func) \
-void linux_##_func(unsigned long data) \
-{ \
- PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
- RT2870_TIMER_ENTRY *_pQNode; \
- RTMP_ADAPTER *_pAd; \
- \
- _pTimer->handle = _func; \
- _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
- _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
- if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
- RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
-}
-#endif // RT2870 //
-
-
-#define DECLARE_TIMER_FUNCTION(_func) \
-void linux_##_func(unsigned long data)
-
-#define GET_TIMER_FUNCTION(_func) \
- linux_##_func
-
-DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
-DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
-DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
-DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RT2870
-DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
-#endif // RT2870 //
-
-
-#ifdef CONFIG_STA_SUPPORT
-DECLARE_TIMER_FUNCTION(BeaconTimeout);
-DECLARE_TIMER_FUNCTION(ScanTimeout);
-DECLARE_TIMER_FUNCTION(AuthTimeout);
-DECLARE_TIMER_FUNCTION(AssocTimeout);
-DECLARE_TIMER_FUNCTION(ReassocTimeout);
-DECLARE_TIMER_FUNCTION(DisassocTimeout);
-DECLARE_TIMER_FUNCTION(LinkDownExec);
-#ifdef LEAP_SUPPORT
-DECLARE_TIMER_FUNCTION(LeapAuthTimeout);
-#endif
-DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-DECLARE_TIMER_FUNCTION(PsPollWakeExec);
-DECLARE_TIMER_FUNCTION(RadioOnExec);
-
-#ifdef QOS_DLS_SUPPORT
-DECLARE_TIMER_FUNCTION(DlsTimeoutAction);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#undef AP_WSC_INCLUDED
-#undef STA_WSC_INCLUDED
-#undef WSC_INCLUDED
-
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
-#if defined(AP_WSC_INCLUDED) || defined(STA_WSC_INCLUDED)
-#define WSC_INCLUDED
-#endif
-
-
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
-
-
-/*
- * packet helper
- * - convert internal rt packet to os packet or
- * os packet to rt packet
- */
-#define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
-#define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
-
-#define GET_OS_PKT_DATAPTR(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->data)
-
-#define GET_OS_PKT_LEN(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->len)
-
-#define GET_OS_PKT_DATATAIL(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->tail)
-
-#define GET_OS_PKT_HEAD(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->head)
-
-#define GET_OS_PKT_END(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->end)
-
-#define GET_OS_PKT_NETDEV(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->dev)
-
-#define GET_OS_PKT_TYPE(_pkt) \
- (RTPKT_TO_OSPKT(_pkt))
-
-#define GET_OS_PKT_NEXT(_pkt) \
- (RTPKT_TO_OSPKT(_pkt)->next)
-
-
-#define OS_NTOHS(_Val) \
- (ntohs(_Val))
-#define OS_HTONS(_Val) \
- (htons(_Val))
-#define OS_NTOHL(_Val) \
- (ntohl(_Val))
-#define OS_HTONL(_Val) \
- (htonl(_Val))
-
-/* statistics counter */
-#define STATS_INC_RX_PACKETS(_pAd, _dev)
-#define STATS_INC_TX_PACKETS(_pAd, _dev)
-
-#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
-#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
-
-#define STATS_INC_RX_ERRORS(_pAd, _dev)
-#define STATS_INC_TX_ERRORS(_pAd, _dev)
-
-#define STATS_INC_RX_DROPPED(_pAd, _dev)
-#define STATS_INC_TX_DROPPED(_pAd, _dev)
-
-
-#define CB_OFF 10
-
-
-// check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
-// ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
-//
-//#define RTMP_GET_PACKET_MR(_p) (RTPKT_TO_OSPKT(_p))
-
-// User Priority
-#define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
-#define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
-
-// Fragment #
-#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
-#define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
-
-// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too.
-//(this value also as MAC(on-chip WCID) table index)
-// 0x80~0xff: TX to a WDS link. b0~6: WDS index
-#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
-#define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
-
-// 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
-#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
-#define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
-
-// RTS/CTS-to-self protection method
-#define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
-#define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
-// see RTMP_S(G)ET_PACKET_EMACTAB
-
-// TX rate index
-#define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
-#define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
-
-// From which Interface
-#define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
-#define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
-#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
-#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
-#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
-#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
-#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
-#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
-
-#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
-#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
-
-//#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) (RTPKT_TO_OSPKT(_p)->cb[8] = _bss)
-//#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) (RTPKT_TO_OSPKT(_p)->cb[8])
-
-//
-// Sepcific Pakcet Type definition
-//
-#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
-
-#define RTMP_PACKET_SPECIFIC_DHCP 0x01
-#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
-#define RTMP_PACKET_SPECIFIC_IPV4 0x04
-#define RTMP_PACKET_SPECIFIC_WAI 0x08
-#define RTMP_PACKET_SPECIFIC_VLAN 0x10
-#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
-
-//Specific
-#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
-
-//DHCP
-#define RTMP_SET_PACKET_DHCP(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
- }while(0)
-#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
-
-//EAPOL
-#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
- }while(0)
-#define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
-
-//WAI
-#define RTMP_SET_PACKET_WAI(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
- }while(0)
-#define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
-
-#define RTMP_GET_PACKET_LOWRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
-
-//VLAN
-#define RTMP_SET_PACKET_VLAN(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
- }while(0)
-#define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
-
-//LLC/SNAP
-#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
- }while(0)
-
-#define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
-
-// IP
-#define RTMP_SET_PACKET_IPV4(_p, _flg) \
- do{ \
- if (_flg) \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
- else \
- (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
- }while(0)
-
-#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
-
-// If this flag is set, it indicates that this EAPoL frame MUST be clear.
-#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
-#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
-
-#define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
-#define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
-
-
-#ifdef INF_AMAZON_SE
-/*Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate */
-#define RTMP_SET_PACKET_NOBULKOUT(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23] = _morebit)
-#define RTMP_GET_PACKET_NOBULKOUT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23])
-#endif // INF_AMAZON_SE //
-
-
-
-#ifdef CONFIG_5VT_ENHANCE
-#define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
-#endif
-
-
-#define NDIS_SET_PACKET_STATUS(_p, _status)
-
-
-#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
- rt_get_sg_list_from_packet(_p, _sc)
-
-#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
-#define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
-#define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
-#define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
-#define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
-
-
-#define RTMP_INC_REF(_A) 0
-#define RTMP_DEC_REF(_A) 0
-#define RTMP_GET_REF(_A) 0
-
-
-
-/*
- * ULONG
- * RTMP_GetPhysicalAddressLow(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
-
-/*
- * ULONG
- * RTMP_GetPhysicalAddressHigh(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
-
-/*
- * VOID
- * RTMP_SetPhysicalAddressLow(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
- * IN ULONG Value);
- */
-#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
- PhysicalAddress = Value;
-
-/*
- * VOID
- * RTMP_SetPhysicalAddressHigh(
- * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
- * IN ULONG Value);
- */
-#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
-
-
-//CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
-#define QUEUE_ENTRY_TO_PACKET(pEntry) \
- (PNDIS_PACKET)(pEntry)
-
-#define PACKET_TO_QUEUE_ENTRY(pPacket) \
- (PQUEUE_ENTRY)(pPacket)
-
-
-#ifndef CONTAINING_RECORD
-#define CONTAINING_RECORD(address, type, field) \
-((type *)((PCHAR)(address) - offsetof(type, field)))
-#endif
-
-
-#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
-{ \
- RTMPFreeNdisPacket(_pAd, _pPacket); \
-}
-
-
-#define SWITCH_PhyAB(_pAA, _pBB) \
-{ \
- ULONG AABasePaHigh; \
- ULONG AABasePaLow; \
- ULONG BBBasePaHigh; \
- ULONG BBBasePaLow; \
- BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \
- BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \
- AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \
- AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \
- RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \
- RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \
- RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \
- RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \
-}
-
-
-#define NdisWriteErrorLogEntry(_a, _b, _c, _d)
-#define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS
-
-
-#define NdisAcquireSpinLock RTMP_SEM_LOCK
-#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
-
-static inline void NdisGetSystemUpTime(ULONG *time)
-{
- *time = jiffies;
-}
-
-//pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
-#define QUEUE_ENTRY_TO_PKT(pEntry) \
- ((PNDIS_PACKET) (pEntry))
-
-int rt28xx_packet_xmit(struct sk_buff *skb);
-
-
-
-void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
-
-
-
+#include "../../rt2870/rt_linux.h"
diff --git a/drivers/staging/rt3070/rt_main_dev.c b/drivers/staging/rt3070/rt_main_dev.c
index 81f769cf1096..c8bcd4029c3c 100644
--- a/drivers/staging/rt3070/rt_main_dev.c
+++ b/drivers/staging/rt3070/rt_main_dev.c
@@ -1,1801 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rt_main_dev.c
-
- Abstract:
- Create and register network interface.
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Sample Mar/21/07 Merge RT2870 and RT2860 drivers.
-*/
-
-#include "rt_config.h"
-
-#define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// record whether the card in the card list is used in the card file
-UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD];
-// record used card mac address in the card list
-static UINT8 MC_CardMac[MAX_NUM_OF_MULTIPLE_CARD][6];
-#endif // MULTIPLE_CARD_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-UINT32 CW_MAX_IN_BITS;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-/*---------------------------------------------------------------------*/
-/* Private Variables Used */
-/*---------------------------------------------------------------------*/
-//static RALINK_TIMER_STRUCT PeriodicTimer;
-
-char *mac = ""; // default 00:00:00:00:00:00
-char *hostname = ""; // default CMPC
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)
-MODULE_PARM (mac, "s");
-#else
-module_param (mac, charp, 0);
-#endif
-MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
-
-
-/*---------------------------------------------------------------------*/
-/* Prototypes of Functions Used */
-/*---------------------------------------------------------------------*/
-#ifdef DOT11_N_SUPPORT
-extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
-extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
-extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
-
-
-// public function prototype
-INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
- IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
-
-// private function prototype
-static int rt28xx_init(IN struct net_device *net_dev);
-INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
-
-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
-struct net_device *alloc_netdev(
- int sizeof_priv,
- const char *mask,
- void (*setup)(struct net_device *));
-#endif // LINUX_VERSION_CODE //
-
-static void CfgInitHook(PRTMP_ADAPTER pAd);
-//static BOOLEAN RT28XXAvailRANameAssign(IN CHAR *name_p);
-
-#ifdef CONFIG_STA_SUPPORT
-extern const struct iw_handler_def rt28xx_iw_handler_def;
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-extern const struct iw_handler_def rt28xx_ap_iw_handler_def;
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
- IN struct net_device *net_dev);
-#endif
-
-struct net_device_stats *RT28xx_get_ether_stats(
- IN struct net_device *net_dev);
-
-/*
-========================================================================
-Routine Description:
- Close raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
- 1. if open fail, kernel will not call the close function.
- 2. Free memory for
- (1) Mlme Memory Handler: MlmeHalt()
- (2) TX & RX: RTMPFreeTxRxRingMemory()
- (3) BA Reordering: ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_close(IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
- // Sanity check for pAd
- if (pAd == NULL)
- return 0; // close ok
-
- netif_carrier_off(pAd->net_dev);
- netif_stop_queue(pAd->net_dev);
-
-
-
- VIRTUAL_IF_DOWN(pAd);
-
- RT_MOD_DEC_USE_COUNT();
-
- return 0; // close ok
-}
-
-/*
-========================================================================
-Routine Description:
- Open raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
- 1. if open fail, kernel will not call the close function.
- 2. Free memory for
- (1) Mlme Memory Handler: MlmeHalt()
- (2) TX & RX: RTMPFreeTxRxRingMemory()
- (3) BA Reordering: ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_open(IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
- // Sanity check for pAd
- if (pAd == NULL)
- return 0; // close ok
-
- if (VIRTUAL_IF_UP(pAd) != 0)
- return -1;
-
- // increase MODULE use count
- RT_MOD_INC_USE_COUNT();
-
- netif_start_queue(net_dev);
- netif_carrier_on(net_dev);
- netif_wake_queue(net_dev);
-
- return 0;
-}
-
-/*
-========================================================================
-Routine Description:
- Close raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
- 1. if open fail, kernel will not call the close function.
- 2. Free memory for
- (1) Mlme Memory Handler: MlmeHalt()
- (2) TX & RX: RTMPFreeTxRxRingMemory()
- (3) BA Reordering: ba_reordering_resource_release()
-========================================================================
-*/
-int rt28xx_close(IN PNET_DEV dev)
-{
- struct net_device * net_dev = (struct net_device *)dev;
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
- BOOLEAN Cancelled = FALSE;
- UINT32 i = 0;
-#ifdef RT2870
- DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
- DECLARE_WAITQUEUE(wait, current);
-
- //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif // RT2870 //
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
-
- // Sanity check for pAd
- if (pAd == NULL)
- return 0; // close ok
-
-
-#ifdef WDS_SUPPORT
- WdsDown(pAd);
-#endif // WDS_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- // If dirver doesn't wake up firmware here,
- // NICLoadFirmware will hang forever when interface is up again.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- AsicForceWakeup(pAd, TRUE);
- }
-
-#ifdef QOS_DLS_SUPPORT
- // send DLS-TEAR_DOWN message,
- if (pAd->CommonCfg.bDLSCapable)
- {
- UCHAR i;
-
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
- RT28XX_MLME_HANDLER(pAd);
- }
-#endif // QOS_DLS_SUPPORT //
-
- if (INFRA_ON(pAd) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
- {
- MLME_DISASSOC_REQ_STRUCT DisReq;
- MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
- DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
-
- MsgElem->Machine = ASSOC_STATE_MACHINE;
- MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
- MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
- NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAd->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
- MlmeDisassocReqAction(pAd, MsgElem);
- kfree(MsgElem);
-
- RTMPusecDelay(1000);
- }
-
-#ifdef RT2870
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif // RT2870 //
-
-#ifdef CCX_SUPPORT
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
-#endif
-
- RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
- RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- // send wireless event to wpa_supplicant for infroming interface down.
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_INTERFACE_DOWN;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- MlmeRadioOff(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
- for (i = 0 ; i < NUM_OF_TX_RING; i++)
- {
- while (pAd->DeQueueRunning[i] == TRUE)
- {
- printk("Waiting for TxQueue[%d] done..........\n", i);
- RTMPusecDelay(1000);
- }
- }
-
-#ifdef RT2870
- // ensure there are no more active urbs.
- add_wait_queue (&unlink_wakeup, &wait);
- pAd->wait = &unlink_wakeup;
-
- // maybe wait for deletions to finish.
- i = 0;
- //while((i < 25) && atomic_read(&pAd->PendingRx) > 0)
- while(i < 25)
- {
- unsigned long IrqFlags;
-
- RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
- if (pAd->PendingRx == 0)
- {
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
- break;
- }
- RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
- msleep(UNLINK_TIMEOUT_MS); //Time in millisecond
-#else
- RTMPusecDelay(UNLINK_TIMEOUT_MS*1000); //Time in microsecond
-#endif
- i++;
- }
- pAd->wait = NULL;
- remove_wait_queue (&unlink_wakeup, &wait);
-#endif // RT2870 //
-
- //RTUSBCleanUpMLMEWaitQueue(pAd); /*not used in RT28xx*/
-
-
-#ifdef RT2870
- // We need clear timerQ related structure before exits of the timer thread.
- RT2870_TimerQ_Exit(pAd);
- // Close kernel threads or tasklets
- RT28xxThreadTerminate(pAd);
-#endif // RT2870 //
-
- // Stop Mlme state machine
- MlmeHalt(pAd);
-
- // Close kernel threads or tasklets
- kill_thread_task(pAd);
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- MacTableReset(pAd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
- MeasureReqTabExit(pAd);
- TpcReqTabExit(pAd);
-
-
-
-
- // Free Ring or USB buffers
- RTMPFreeTxRxRingMemory(pAd);
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
-#ifdef DOT11_N_SUPPORT
- // Free BA reorder resource
- ba_reordering_resource_release(pAd);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef RT2870
-#ifdef INF_AMAZON_SE
- if (pAd->UsbVendorReqBuf)
- os_free_mem(pAd, pAd->UsbVendorReqBuf);
-#endif // INF_AMAZON_SE //
-#endif // RT2870 //
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
- return 0; // close ok
-} /* End of rt28xx_close */
-
-static int rt28xx_init(IN struct net_device *net_dev)
-{
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- UINT index;
- UCHAR TmpPhy;
-// ULONG Value=0;
- NDIS_STATUS Status;
-// OID_SET_HT_PHYMODE SetHT;
-// WPDMA_GLO_CFG_STRUC GloCfg;
- UINT32 MacCsr0 = 0;
-
-#ifdef RT2870
-#ifdef INF_AMAZON_SE
- init_MUTEX(&(pAd->UsbVendorReq_semaphore));
- os_alloc_mem(pAd, (PUCHAR)&pAd->UsbVendorReqBuf, MAX_PARAM_BUFFER_SIZE - 1);
- if (pAd->UsbVendorReqBuf == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Allocate vendor request temp buffer failed!\n"));
- goto err0;
- }
-#endif // INF_AMAZON_SE //
-#endif // RT2870 //
-
-#ifdef DOT11_N_SUPPORT
- // Allocate BA Reordering memory
- ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
-#endif // DOT11_N_SUPPORT //
-
- // Make sure MAC gets ready.
- index = 0;
- do
- {
- RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
- pAd->MACVersion = MacCsr0;
-
- if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
- break;
-
- RTMPusecDelay(10);
- } while (index++ < 100);
-
- DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
-/*Iverson patch PCIE L1 issue */
-
- // Disable DMA
- RT28XXDMADisable(pAd);
-
-
- // Load 8051 firmware
- Status = NICLoadFirmware(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
- goto err1;
- }
-
- NICLoadRateSwitchingParams(pAd);
-
- // Disable interrupts here which is as soon as possible
- // This statement should never be true. We might consider to remove it later
-
- Status = RTMPAllocTxRxRingMemory(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
- goto err1;
- }
-
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-
- // initialize MLME
- //
-
- Status = MlmeInit(pAd);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
- goto err2;
- }
-
- // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
- //
- UserCfgInit(pAd);
-
-#ifdef RT2870
- // We need init timerQ related structure before create the timer thread.
- RT2870_TimerQ_Init(pAd);
-#endif // RT2870 //
-
- RT28XX_TASK_THREAD_INIT(pAd, Status);
- if (Status != NDIS_STATUS_SUCCESS)
- goto err1;
-
-// COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].Bssid, netif->hwaddr);
-// pAd->bForcePrintTX = TRUE;
-
- CfgInitHook(pAd);
-
-
-#ifdef BLOCK_NET_IF
- initblockQueueTab(pAd);
-#endif // BLOCK_NET_IF //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisAllocateSpinLock(&pAd->MacTabLock);
-#endif // CONFIG_STA_SUPPORT //
-
- MeasureReqTabInit(pAd);
- TpcReqTabInit(pAd);
-
- //
- // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
- //
- Status = NICInitializeAdapter(pAd, TRUE);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
- if (Status != NDIS_STATUS_SUCCESS)
- goto err3;
- }
-
- // Read parameters from Config File
- Status = RTMPReadParametersHook(pAd);
-
- printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
- goto err4;
- }
-
-#ifdef RT2870
- pAd->CommonCfg.bMultipleIRP = FALSE;
-
- if (pAd->CommonCfg.bMultipleIRP)
- pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
- else
- pAd->CommonCfg.NumOfBulkInIRP = 1;
-#endif // RT2870 //
-
-
- //Init Ba Capability parameters.
-// RT28XX_BA_INIT(pAd);
-#ifdef DOT11_N_SUPPORT
- pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
- pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
- pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
- // UPdata to HT IE
- pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
- pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
- pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-#endif // DOT11_N_SUPPORT //
-
- // after reading Registry, we now know if in AP mode or STA mode
-
- // Load 8051 firmware; crash when FW image not existent
- // Status = NICLoadFirmware(pAd);
- // if (Status != NDIS_STATUS_SUCCESS)
- // break;
-
- printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-
- // We should read EEPROM for all cases. rt2860b
- NICReadEEPROMParameters(pAd, mac);
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-
- NICInitAsicFromEEPROM(pAd); //rt2860b
-
- // Set PHY to appropriate mode
- TmpPhy = pAd->CommonCfg.PhyMode;
- pAd->CommonCfg.PhyMode = 0xff;
- RTMPSetPhyMode(pAd, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
-
- // No valid channels.
- if (pAd->ChannelListNum == 0)
- {
- printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
- goto err4;
- }
-
-#ifdef DOT11_N_SUPPORT
- printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
- pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
- pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef RT30xx
- //Init RT30xx RFRegisters after read RFIC type from EEPROM
- NICInitRT30xxRFRegisters(pAd);
-#endif // RT30xx //
-
-// APInitialize(pAd);
-
-#ifdef IKANOS_VX_1X0
- VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
-#endif // IKANOS_VX_1X0 //
-
- //
- // Initialize RF register to default value
- //
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- if (pAd && (Status != NDIS_STATUS_SUCCESS))
- {
- //
- // Undo everything if it failed
- //
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
-// NdisMDeregisterInterrupt(&pAd->Interrupt);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
- }
-// RTMPFreeAdapter(pAd); // we will free it in disconnect()
- }
- else if (pAd)
- {
- // Microsoft HCT require driver send a disconnect event after driver initialization.
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-// pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
-
-
-#ifdef RT2870
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-
- //
- // Support multiple BulkIn IRP,
- // the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.
- //
- for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++)
- {
- RTUSBBulkReceive(pAd);
- DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" ));
- }
-#endif // RT2870 //
- }// end of else
-
-
- DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
-
- return TRUE;
-
-
-err4:
-err3:
- MlmeHalt(pAd);
-err2:
- RTMPFreeTxRxRingMemory(pAd);
-// RTMPFreeAdapter(pAd);
-err1:
-
-#ifdef DOT11_N_SUPPORT
- os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
-#endif // DOT11_N_SUPPORT //
- RT28XX_IRQ_RELEASE(net_dev);
-
- // shall not set priv to NULL here because the priv didn't been free yet.
- //net_dev->ml_priv = 0;
-#ifdef INF_AMAZON_SE
-err0:
-#endif // INF_AMAZON_SE //
- printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
- return FALSE;
-} /* End of rt28xx_init */
-
-
-/*
-========================================================================
-Routine Description:
- Open raxx interface.
-
-Arguments:
- *net_dev the raxx interface pointer
-
-Return Value:
- 0 Open OK
- otherwise Open Fail
-
-Note:
-========================================================================
-*/
-int rt28xx_open(IN PNET_DEV dev)
-{
- struct net_device * net_dev = (struct net_device *)dev;
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- int retval = 0;
- POS_COOKIE pObj;
-
-
- // Sanity check for pAd
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -1;
- }
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (pAd->OpMode == OPMODE_AP)
- {
- CW_MAX_IN_BITS = 6;
- }
- else if (pAd->OpMode == OPMODE_STA)
- {
- CW_MAX_IN_BITS = 10;
- }
-
-#if WIRELESS_EXT >= 12
- if (net_dev->ml_priv_flags == INT_MAIN)
- {
- if (pAd->OpMode == OPMODE_AP)
- net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
- else if (pAd->OpMode == OPMODE_STA)
- net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
- }
-#endif // WIRELESS_EXT >= 12 //
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- // Init
- pObj = (POS_COOKIE)pAd->OS_Cookie;
-
- // reset Adapter flags
- RTMP_CLEAR_FLAGS(pAd);
-
- // Request interrupt service routine for PCI device
- // register the interrupt routine with the os
- RT28XX_IRQ_REQUEST(net_dev);
-
-
- // Init BssTab & ChannelInfo tabbles for auto channel select.
-
-
- // Chip & other init
- if (rt28xx_init(net_dev) == FALSE)
- goto err;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- NdisZeroMemory(pAd->StaCfg.dev_name, 16);
- NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Set up the Mac address
- NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
-
- // Init IRQ parameters
- RT28XX_IRQ_INIT(pAd);
-
- // Various AP function init
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- // send wireless event to wpa_supplicant for infroming interface down.
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_INTERFACE_UP;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // Enable Interrupt
- RT28XX_IRQ_ENABLE(pAd);
-
- // Now Enable RxTx
- RTMPEnableRxTx(pAd);
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
- {
- UINT32 reg = 0;
- RTMP_IO_READ32(pAd, 0x1300, &reg); // clear garbage interrupts
- printk("0x1300 = %08x\n", reg);
- }
-
- {
-// u32 reg;
-// u8 byte;
-// u16 tmp;
-
-// RTMP_IO_READ32(pAd, XIFS_TIME_CFG, &reg);
-
-// tmp = 0x0805;
-// reg = (reg & 0xffff0000) | tmp;
-// RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg);
-
- }
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
- return (retval);
-
-err:
- return (-1);
-} /* End of rt28xx_open */
-
-static const struct net_device_ops rt3070_netdev_ops = {
- .ndo_open = MainVirtualIF_open,
- .ndo_stop = MainVirtualIF_close,
- .ndo_do_ioctl = rt28xx_ioctl,
- .ndo_get_stats = RT28xx_get_ether_stats,
- .ndo_validate_addr = NULL,
- .ndo_set_mac_address = eth_mac_addr,
- .ndo_change_mtu = eth_change_mtu,
-#ifdef IKANOS_VX_1X0
- .ndo_start_xmit = IKANOS_DataFramesTx,
-#else
- .ndo_start_xmit = rt28xx_send_packets,
-#endif
-};
-
-/* Must not be called for mdev and apdev */
-static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS Status;
- INT i=0;
- CHAR slot_name[IFNAMSIZ];
- struct net_device *device;
-
-
- //ether_setup(dev);
-// dev->set_multicast_list = ieee80211_set_multicast_list;
-// dev->change_mtu = ieee80211_change_mtu;
-#ifdef CONFIG_STA_SUPPORT
-#if WIRELESS_EXT >= 12
- if (pAd->OpMode == OPMODE_STA)
- {
- dev->wireless_handlers = &rt28xx_iw_handler_def;
- }
-#endif //WIRELESS_EXT >= 12
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-#if WIRELESS_EXT >= 12
- if (pAd->OpMode == OPMODE_AP)
- {
- dev->wireless_handlers = &rt28xx_ap_iw_handler_def;
- }
-#endif //WIRELESS_EXT >= 12
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-#if WIRELESS_EXT < 21
- dev->get_wireless_stats = rt28xx_get_wireless_stats;
-#endif
-// dev->uninit = ieee80211_if_reinit;
-// dev->destructor = ieee80211_if_free;
- dev->priv_flags = INT_MAIN;
- dev->netdev_ops = &rt3070_netdev_ops;
- // find available device name
- for (i = 0; i < 8; i++)
- {
-#ifdef MULTIPLE_CARD_SUPPORT
- if (pAd->MC_RowID >= 0)
- sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i);
- else
-#endif // MULTIPLE_CARD_SUPPORT //
- sprintf(slot_name, "ra%d", i);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
- device = dev_get_by_name(dev_net(dev), slot_name);
-#else
- device = dev_get_by_name(dev->nd_net, slot_name);
-#endif
-#else
- device = dev_get_by_name(slot_name);
-#endif
- if (device != NULL) dev_put(device);
-#else
- for (device = dev_base; device != NULL; device = device->next)
- {
- if (strncmp(device->name, slot_name, 4) == 0)
- break;
- }
-#endif
- if(device == NULL)
- break;
- }
-
- if(i == 8)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
-#ifdef MULTIPLE_CARD_SUPPORT
- if (pAd->MC_RowID >= 0)
- sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i);
- else
-#endif // MULTIPLE_CARD_SUPPORT //
- sprintf(dev->name, "ra%d", i);
- Status = NDIS_STATUS_SUCCESS;
- }
-
- return Status;
-
-}
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
-/*
-========================================================================
-Routine Description:
- Get card profile path.
-
-Arguments:
- pAd
-
-Return Value:
- TRUE - Find a card profile
- FALSE - use default profile
-
-Note:
-========================================================================
-*/
-extern INT RTMPGetKeyParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer);
-
-BOOLEAN RTMP_CardInfoRead(
- IN PRTMP_ADAPTER pAd)
-{
-#define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
-#define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
-#define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
-
-#define LETTER_CASE_TRANSLATE(txt_p, card_id) \
- { UINT32 _len; char _char; \
- for(_len=0; _len<strlen(card_id); _len++) { \
- _char = *(txt_p + _len); \
- if (('A' <= _char) && (_char <= 'Z')) \
- *(txt_p+_len) = 'a'+(_char-'A'); \
- } }
-
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30];
- BOOLEAN flg_match_ok = FALSE;
- INT32 card_select_method;
- INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
- EEPROM_ANTENNA_STRUC antenna;
- USHORT addr01, addr23, addr45;
- UINT8 mac[6];
- UINT32 data, card_index;
- UCHAR *start_ptr;
-
-
- // init
- buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if (buffer == NULL)
- return FALSE;
-
- tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(tmpbuf == NULL)
- {
- kfree(buffer);
- return NDIS_STATUS_FAILURE;
- }
-
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid = current->fsgid = 0;
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- // get RF IC type
- RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
-
- if ((data & 0x30) == 0)
- pAd->EEPROMAddressNum = 6; // 93C46
- else if ((data & 0x30) == 0x10)
- pAd->EEPROMAddressNum = 8; // 93C66
- else
- pAd->EEPROMAddressNum = 8; // 93C86
-
- //antenna.word = RTMP_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET);
- RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
-
- if ((antenna.field.RfIcType == RFIC_2850) ||
- (antenna.field.RfIcType == RFIC_2750))
- {
- /* ABGN card */
- strcpy(RFIC_word, "abgn");
- }
- else
- {
- /* BGN card */
- strcpy(RFIC_word, "bgn");
- }
-
- // get MAC address
- //addr01 = RTMP_EEPROM_READ16(pAd, 0x04);
- //addr23 = RTMP_EEPROM_READ16(pAd, 0x06);
- //addr45 = RTMP_EEPROM_READ16(pAd, 0x08);
- RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
- RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
- RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
-
- mac[0] = (UCHAR)(addr01 & 0xff);
- mac[1] = (UCHAR)(addr01 >> 8);
- mac[2] = (UCHAR)(addr23 & 0xff);
- mac[3] = (UCHAR)(addr23 >> 8);
- mac[4] = (UCHAR)(addr45 & 0xff);
- mac[5] = (UCHAR)(addr45 >> 8);
-
- // open card information file
- srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
- if (IS_ERR(srcf))
- {
- /* card information file does not exist */
- DBGPRINT(RT_DEBUG_TRACE,
- ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH));
- return FALSE;
- }
-
- if (srcf->f_op && srcf->f_op->read)
- {
- /* card information file exists so reading the card information */
- memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
- retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
- if (retval < 0)
- {
- /* read fail */
- DBGPRINT(RT_DEBUG_TRACE,
- ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
- }
- else
- {
- /* get card selection method */
- memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
- card_select_method = MC_SELECT_CARDTYPE; // default
-
- if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer))
- {
- if (strcmp(tmpbuf, "CARDID") == 0)
- card_select_method = MC_SELECT_CARDID;
- else if (strcmp(tmpbuf, "MAC") == 0)
- card_select_method = MC_SELECT_MAC;
- else if (strcmp(tmpbuf, "CARDTYPE") == 0)
- card_select_method = MC_SELECT_CARDTYPE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> Card Selection = %d\n", card_select_method));
-
- // init
- card_free_id = -1;
- card_nouse_id = -1;
- card_same_mac_id = -1;
- card_match_id = -1;
-
- // search current card information records
- for(card_index=0;
- card_index<MAX_NUM_OF_MULTIPLE_CARD;
- card_index++)
- {
- if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
- (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
- {
- // MAC is all-0 so the entry is available
- MC_CardUsed[card_index] = 0;
-
- if (card_free_id < 0)
- card_free_id = card_index; // 1st free entry
- }
- else
- {
- if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
- {
- // we find the entry with same MAC
- if (card_same_mac_id < 0)
- card_same_mac_id = card_index; // 1st same entry
- }
- else
- {
- // MAC is not all-0 but used flag == 0
- if ((MC_CardUsed[card_index] == 0) &&
- (card_nouse_id < 0))
- {
- card_nouse_id = card_index; // 1st available entry
- }
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> Free = %d, Same = %d, NOUSE = %d\n",
- card_free_id, card_same_mac_id, card_nouse_id));
-
- if ((card_same_mac_id >= 0) &&
- ((card_select_method == MC_SELECT_CARDID) ||
- (card_select_method == MC_SELECT_CARDTYPE)))
- {
- // same MAC entry is found
- card_match_id = card_same_mac_id;
-
- if (card_select_method == MC_SELECT_CARDTYPE)
- {
- // for CARDTYPE
- sprintf(card_id_buf, "%02dCARDTYPE%s",
- card_match_id, RFIC_word);
-
- if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
- {
- // we found the card ID
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
- }
- }
- }
- else
- {
- // the card is 1st plug-in, try to find the match card profile
- switch(card_select_method)
- {
- case MC_SELECT_CARDID: // CARDID
- default:
- if (card_free_id >= 0)
- card_match_id = card_free_id;
- else
- card_match_id = card_nouse_id;
- break;
-
- case MC_SELECT_MAC: // MAC
- sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
-
- /* try to find the key word in the card file */
- if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
- {
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
-
- /* get the row ID (2 ASCII characters) */
- start_ptr -= 2;
- card_id_buf[0] = *(start_ptr);
- card_id_buf[1] = *(start_ptr+1);
- card_id_buf[2] = 0x00;
-
- card_match_id = simple_strtol(card_id_buf, 0, 10);
- }
- break;
-
- case MC_SELECT_CARDTYPE: // CARDTYPE
- card_nouse_id = -1;
-
- for(card_index=0;
- card_index<MAX_NUM_OF_MULTIPLE_CARD;
- card_index++)
- {
- sprintf(card_id_buf, "%02dCARDTYPE%s",
- card_index, RFIC_word);
-
- if ((start_ptr=rtstrstruncasecmp(buffer,
- card_id_buf)) != NULL)
- {
- LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
-
- if (MC_CardUsed[card_index] == 0)
- {
- /* current the card profile is not used */
- if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
- (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
- {
- // find it and no previous card use it
- card_match_id = card_index;
- break;
- }
- else
- {
- // ever a card use it
- if (card_nouse_id < 0)
- card_nouse_id = card_index;
- }
- }
- }
- }
-
- // if not find a free one, use the available one
- if (card_match_id < 0)
- card_match_id = card_nouse_id;
- break;
- }
- }
-
- if (card_match_id >= 0)
- {
- // make up search keyword
- switch(card_select_method)
- {
- case MC_SELECT_CARDID: // CARDID
- sprintf(card_id_buf, "%02dCARDID", card_match_id);
- break;
-
- case MC_SELECT_MAC: // MAC
- sprintf(card_id_buf,
- "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
- card_match_id,
- mac[0], mac[1], mac[2],
- mac[3], mac[4], mac[5]);
- break;
-
- case MC_SELECT_CARDTYPE: // CARDTYPE
- default:
- sprintf(card_id_buf, "%02dcardtype%s",
- card_match_id, RFIC_word);
- break;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
-
- // read card file path
- if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer))
- {
- if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
- {
- // backup card information
- pAd->MC_RowID = card_match_id; /* base 0 */
- MC_CardUsed[card_match_id] = 1;
- memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
-
- // backup card file path
- NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
- pAd->MC_FileName[strlen(tmpbuf)] = '\0';
- flg_match_ok = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("Card Profile Name = %s\n", pAd->MC_FileName));
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("Card Profile Name length too large!\n"));
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("Can not find search key word in card.dat!\n"));
- }
-
- if ((flg_match_ok != TRUE) &&
- (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
- {
- MC_CardUsed[card_match_id] = 0;
- memset(MC_CardMac[card_match_id], 0, sizeof(mac));
- }
- } // if (card_match_id >= 0)
- }
- }
-
- // close file
- retval = filp_close(srcf, NULL);
- set_fs(orgfs);
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
- kfree(buffer);
- kfree(tmpbuf);
- return flg_match_ok;
-}
-#endif // MULTIPLE_CARD_SUPPORT //
-
-
-/*
-========================================================================
-Routine Description:
- Probe RT28XX chipset.
-
-Arguments:
- _dev_p Point to the PCI or USB device
- _dev_id_p Point to the PCI or USB device ID
-
-Return Value:
- 0 Probe OK
- -ENODEV Probe Fail
-
-Note:
-========================================================================
-*/
-INT __devinit rt28xx_probe(
- IN void *_dev_p,
- IN void *_dev_id_p,
- IN UINT argc,
- OUT PRTMP_ADAPTER *ppAd)
-{
- struct net_device *net_dev;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
- INT status;
- PVOID handle;
-#ifdef RT2870
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* kernel 2.4 series */
- struct usb_device *dev_p = (struct usb_device *)_dev_p;
-#else
- struct usb_interface *intf = (struct usb_interface *)_dev_p;
- struct usb_device *dev_p = interface_to_usbdev(intf);
-
- dev_p = usb_get_dev(dev_p);
-#endif // LINUX_VERSION_CODE //
-#endif // RT2870 //
-
-
-#ifdef CONFIG_STA_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
-#endif // CONFIG_STA_SUPPORT //
-
- // Check chipset vendor/product ID
-// if (RT28XXChipsetCheck(_dev_p) == FALSE)
-// goto err_out;
-
-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
- net_dev = alloc_netdev(sizeof(PRTMP_ADAPTER), "eth%d", ether_setup);
-#else
- net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
-#endif
- if (net_dev == NULL)
- {
- printk("alloc_netdev failed\n");
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
- module_put(THIS_MODULE);
-#endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
-#else
- MOD_DEC_USE_COUNT;
-#endif
- goto err_out;
- }
-
-// sample
-// if (rt_ieee80211_if_setup(net_dev) != NDIS_STATUS_SUCCESS)
-// goto err_out;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- SET_MODULE_OWNER(net_dev);
-#endif
-
- netif_stop_queue(net_dev);
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-/* for supporting Network Manager */
-/* Set the sysfs physical device reference for the network logical device
- * if set prior to registration will cause a symlink during initialization.
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
- SET_NETDEV_DEV(net_dev, &(dev_p->dev));
-#endif
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- // Allocate RTMP_ADAPTER miniport adapter structure
- handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
- RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
-
- status = RTMPAllocAdapterBlock(handle, &pAd);
- if (status != NDIS_STATUS_SUCCESS)
- goto err_out_free_netdev;
-
- net_dev->ml_priv = (PVOID)pAd;
- pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
-
- RT28XXNetDevInit(_dev_p, net_dev, pAd);
-
-#ifdef CONFIG_STA_SUPPORT
- pAd->StaCfg.OriDevType = net_dev->type;
-#endif // CONFIG_STA_SUPPORT //
-
- // Find and assign a free interface name, raxx
-// RT28XXAvailRANameAssign(net_dev->name);
-
- // Post config
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- if (RT28XXProbePostConfig(_dev_p, pAd, argc) == FALSE)
- goto err_out_unmap;
-#else
- if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
- goto err_out_unmap;
-#endif // LINUX_VERSION_CODE //
-
-#ifdef CONFIG_STA_SUPPORT
- pAd->OpMode = OPMODE_STA;
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
- // find its profile path
- pAd->MC_RowID = -1; // use default profile path
- RTMP_CardInfoRead(pAd);
-
- if (pAd->MC_RowID == -1)
-#ifdef CONFIG_STA_SUPPORT
- strcpy(pAd->MC_FileName, STA_PROFILE_PATH);
-#endif // CONFIG_STA_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE,
- ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName));
-#endif // MULTIPLE_CARD_SUPPORT //
-
- // sample move
- if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
- goto err_out_unmap;
-
- // Register this device
- status = register_netdev(net_dev);
- if (status)
- goto err_out_unmap;
-
- // Set driver data
- RT28XX_DRVDATA_SET(_dev_p);
-
-
-
- *ppAd = pAd;
- return 0; // probe ok
-
-
- /* --------------------------- ERROR HANDLE --------------------------- */
-err_out_unmap:
- RTMPFreeAdapter(pAd);
- RT28XX_UNMAP();
-
-err_out_free_netdev:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
- free_netdev(net_dev);
-#else
- kfree(net_dev);
-#endif
-
-err_out:
- RT28XX_PUT_DEVICE(dev_p);
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- return (LONG)NULL;
-#else
- return -ENODEV; /* probe fail */
-#endif // LINUX_VERSION_CODE //
-} /* End of rt28xx_probe */
-
-
-/*
-========================================================================
-Routine Description:
- The entry point for Linux kernel sent packet to our driver.
-
-Arguments:
- sk_buff *skb the pointer refer to a sk_buffer.
-
-Return Value:
- 0
-
-Note:
- This function is the entry point of Tx Path for Os delivery packet to
- our driver. You only can put OS-depened & STA/AP common handle procedures
- in here.
-========================================================================
-*/
-int rt28xx_packet_xmit(struct sk_buff *skb)
-{
- struct net_device *net_dev = skb->dev;
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
- int status = 0;
- PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
-
- /* RT2870STA does this in RTMPSendPackets() */
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES);
- return 0;
- }
-#endif // RALINK_ATE //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- // Drop send request since we are in monitor mode
- if (MONITOR_ON(pAd))
- {
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- goto done;
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- // EapolStart size is 18
- if (skb->len < 14)
- {
- //printk("bad packet size: %d\n", pkt->len);
- hex_dump("bad packet", skb->data, skb->len);
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- goto done;
- }
-
- RTMP_SET_PACKET_5VT(pPacket, 0);
-// MiniportMMRequest(pAd, pkt->data, pkt->len);
-#ifdef CONFIG_5VT_ENHANCE
- if (*(int*)(skb->cb) == BRIDGE_TAG) {
- RTMP_SET_PACKET_5VT(pPacket, 1);
- }
-#endif
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
-
- STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
- }
-
-#endif // CONFIG_STA_SUPPORT //
-
- status = 0;
-done:
-
- return status;
-}
-
-
-/*
-========================================================================
-Routine Description:
- Send a packet to WLAN.
-
-Arguments:
- skb_p points to our adapter
- dev_p which WLAN network interface
-
-Return Value:
- 0: transmit successfully
- otherwise: transmit fail
-
-Note:
-========================================================================
-*/
-INT rt28xx_send_packets(
- IN struct sk_buff *skb_p,
- IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
- if (!(net_dev->flags & IFF_UP))
- {
- RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
- return 0;
- }
-
- NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
- RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
-
- return rt28xx_packet_xmit(skb_p);
-} /* End of MBSS_VirtualIF_PacketSend */
-
-
-
-
-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
-//static struct net_device *alloc_netdev(int sizeof_priv, const char *mask, void (*setup)(struct net_device *)) //sample
-struct net_device *alloc_netdev(
- int sizeof_priv,
- const char *mask,
- void (*setup)(struct net_device *))
-{
- struct net_device *dev;
- INT alloc_size;
-
-
- /* ensure 32-byte alignment of the private area */
- alloc_size = sizeof (*dev) + sizeof_priv + 31;
-
- dev = (struct net_device *) kmalloc(alloc_size, GFP_KERNEL);
- if (dev == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,
- ("alloc_netdev: Unable to allocate device memory.\n"));
- return NULL;
- }
-
- memset(dev, 0, alloc_size);
-
- if (sizeof_priv)
- dev->ml_priv = (void *) (((long)(dev + 1) + 31) & ~31);
-
- setup(dev);
- strcpy(dev->name, mask);
-
- return dev;
-}
-#endif // LINUX_VERSION_CODE //
-
-
-void CfgInitHook(PRTMP_ADAPTER pAd)
-{
- pAd->bBroadComHT = TRUE;
-} /* End of CfgInitHook */
-
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
- IN struct net_device *net_dev)
-{
- PRTMP_ADAPTER pAd = net_dev->ml_priv;
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
-
- pAd->iw_stats.status = 0; // Status - device dependent for now
-
- // link quality
- pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
- if(pAd->iw_stats.qual.qual > 100)
- pAd->iw_stats.qual.qual = 100;
-
-#ifdef CONFIG_STA_SUPPORT
- if (pAd->OpMode == OPMODE_STA)
- pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
-#endif // CONFIG_STA_SUPPORT //
-
- pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
-
- pAd->iw_stats.qual.noise += 256 - 143;
- pAd->iw_stats.qual.updated = 1; // Flags to know if updated
-#ifdef IW_QUAL_DBM
- pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
-#endif // IW_QUAL_DBM //
-
- pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
- pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
-
- DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
- return &pAd->iw_stats;
-} /* End of rt28xx_get_wireless_stats */
-#endif // WIRELESS_EXT //
-
-
-
-void tbtt_tasklet(unsigned long data)
-{
-#define MAX_TX_IN_TBTT (16)
-
-}
-
-INT rt28xx_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- RTMP_ADAPTER *pAd = NULL;
- INT ret = 0;
-
- if (net_dev->priv_flags == INT_MAIN)
- {
- pAd = net_dev->ml_priv;
- }
- else
- {
- pVirtualAd = net_dev->ml_priv;
- pAd = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
- }
-#endif // CONFIG_STA_SUPPORT //
-
- return ret;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- return ethernet statistics counter
-
- Arguments:
- net_dev Pointer to net_device
-
- Return Value:
- net_device_stats*
-
- Note:
-
- ========================================================================
-*/
-struct net_device_stats *RT28xx_get_ether_stats(
- IN struct net_device *net_dev)
-{
- RTMP_ADAPTER *pAd = NULL;
-
- if (net_dev)
- pAd = net_dev->ml_priv;
-
- if (pAd)
- {
-
- pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
- pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
-
- pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
- pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
-
- pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
- pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
-
- pAd->stats.rx_dropped = 0;
- pAd->stats.tx_dropped = 0;
-
- pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
- pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
-
- pAd->stats.rx_length_errors = 0;
- pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
- pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
- pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
- pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
- pAd->stats.rx_missed_errors = 0; // receiver missed packet
-
- // detailed tx_errors
- pAd->stats.tx_aborted_errors = 0;
- pAd->stats.tx_carrier_errors = 0;
- pAd->stats.tx_fifo_errors = 0;
- pAd->stats.tx_heartbeat_errors = 0;
- pAd->stats.tx_window_errors = 0;
-
- // for cslip etc
- pAd->stats.rx_compressed = 0;
- pAd->stats.tx_compressed = 0;
-
- return &pAd->stats;
- }
- else
- return NULL;
-}
-
+#include "../rt2870/rt_main_dev.c"
diff --git a/drivers/staging/rt3070/rt_profile.c b/drivers/staging/rt3070/rt_profile.c
index 6eda27e6b8dc..ab9eb1d55bb1 100644
--- a/drivers/staging/rt3070/rt_profile.c
+++ b/drivers/staging/rt3070/rt_profile.c
@@ -1,2041 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-#ifdef DOT11_N_SUPPORT
-static void HTParametersHook(
- IN PRTMP_ADAPTER pAd,
- IN CHAR *pValueStr,
- IN CHAR *pInput);
-#endif // DOT11_N_SUPPORT //
-
-#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
-
-// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
-BOOLEAN rtstrmactohex(char *s1, char *s2)
-{
- int i = 0;
- char *ptokS = s1, *ptokE = s1;
-
- if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
- return FALSE;
-
- while((*ptokS) != '\0')
- {
- if((ptokE = strchr(ptokS, ':')) != NULL)
- *ptokE++ = '\0';
- if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
- break; // fail
- AtoH(ptokS, &s2[i++], 1);
- ptokS = ptokE;
- if (i == 6)
- break; // parsing finished
- }
-
- return ( i == 6 ? TRUE : FALSE);
-
-}
-
-
-// we assume the s1 and s2 both are strings.
-BOOLEAN rtstrcasecmp(char *s1, char *s2)
-{
- char *p1 = s1, *p2 = s2;
-
- if (strlen(s1) != strlen(s2))
- return FALSE;
-
- while(*p1 != '\0')
- {
- if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
- return FALSE;
- p1++;
- p2++;
- }
-
- return TRUE;
-}
-
-// we assume the s1 (buffer) and s2 (key) both are strings.
-char * rtstrstruncasecmp(char * s1, char * s2)
-{
- INT l1, l2, i;
- char temp1, temp2;
-
- l2 = strlen(s2);
- if (!l2)
- return (char *) s1;
-
- l1 = strlen(s1);
-
- while (l1 >= l2)
- {
- l1--;
-
- for(i=0; i<l2; i++)
- {
- temp1 = *(s1+i);
- temp2 = *(s2+i);
-
- if (('a' <= temp1) && (temp1 <= 'z'))
- temp1 = 'A'+(temp1-'a');
- if (('a' <= temp2) && (temp2 <= 'z'))
- temp2 = 'A'+(temp2-'a');
-
- if (temp1 != temp2)
- break;
- }
-
- if (i == l2)
- return (char *) s1;
-
- s1++;
- }
-
- return NULL; // not found
-}
-
-//add by kathy
-
- /**
- * strstr - Find the first substring in a %NUL terminated string
- * @s1: The string to be searched
- * @s2: The string to search for
- */
-char * rtstrstr(const char * s1,const char * s2)
-{
- INT l1, l2;
-
- l2 = strlen(s2);
- if (!l2)
- return (char *) s1;
-
- l1 = strlen(s1);
-
- while (l1 >= l2)
- {
- l1--;
- if (!memcmp(s1,s2,l2))
- return (char *) s1;
- s1++;
- }
-
- return NULL;
-}
-
-/**
- * rstrtok - Split a string into tokens
- * @s: The string to be searched
- * @ct: The characters to search for
- * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
- */
-char * __rstrtok;
-char * rstrtok(char * s,const char * ct)
-{
- char *sbegin, *send;
-
- sbegin = s ? s : __rstrtok;
- if (!sbegin)
- {
- return NULL;
- }
-
- sbegin += strspn(sbegin,ct);
- if (*sbegin == '\0')
- {
- __rstrtok = NULL;
- return( NULL );
- }
-
- send = strpbrk( sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
-
- __rstrtok = send;
-
- return (sbegin);
-}
-
-/**
- * delimitcnt - return the count of a given delimiter in a given string.
- * @s: The string to be searched.
- * @ct: The delimiter to search for.
- * Notice : We suppose the delimiter is a single-char string(for example : ";").
- */
-INT delimitcnt(char * s,const char * ct)
-{
- INT count = 0;
- /* point to the beginning of the line */
- const char *token = s;
-
- for ( ;; )
- {
- token = strpbrk(token, ct); /* search for delimiters */
-
- if ( token == NULL )
- {
- /* advanced to the terminating null character */
- break;
- }
- /* skip the delimiter */
- ++token;
-
- /*
- * Print the found text: use len with %.*s to specify field width.
- */
-
- /* accumulate delimiter count */
- ++count;
- }
- return count;
-}
-
-/*
- * converts the Internet host address from the standard numbers-and-dots notation
- * into binary data.
- * returns nonzero if the address is valid, zero if not.
- */
-int rtinet_aton(const char *cp, unsigned int *addr)
-{
- unsigned int val;
- int base, n;
- char c;
- unsigned int parts[4];
- unsigned int *pp = parts;
-
- for (;;)
- {
- /*
- * Collect number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, other=decimal.
- */
- val = 0;
- base = 10;
- if (*cp == '0')
- {
- if (*++cp == 'x' || *cp == 'X')
- base = 16, cp++;
- else
- base = 8;
- }
- while ((c = *cp) != '\0')
- {
- if (isdigit((unsigned char) c))
- {
- val = (val * base) + (c - '0');
- cp++;
- continue;
- }
- if (base == 16 && isxdigit((unsigned char) c))
- {
- val = (val << 4) +
- (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
- cp++;
- continue;
- }
- break;
- }
- if (*cp == '.')
- {
- /*
- * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
- * a.b (with b treated as 24 bits)
- */
- if (pp >= parts + 3 || val > 0xff)
- return 0;
- *pp++ = val, cp++;
- }
- else
- break;
- }
-
- /*
- * Check for trailing junk.
- */
- while (*cp)
- if (!isspace((unsigned char) *cp++))
- return 0;
-
- /*
- * Concoct the address according to the number of parts specified.
- */
- n = pp - parts + 1;
- switch (n)
- {
-
- case 1: /* a -- 32 bits */
- break;
-
- case 2: /* a.b -- 8.24 bits */
- if (val > 0xffffff)
- return 0;
- val |= parts[0] << 24;
- break;
-
- case 3: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff)
- return 0;
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
- if (val > 0xff)
- return 0;
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- }
-
- *addr = htonl(val);
- return 1;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Find key section for Get key parameter.
-
- Arguments:
- buffer Pointer to the buffer to start find the key section
- section the key of the secion to be find
-
- Return Value:
- NULL Fail
- Others Success
- ========================================================================
-*/
-PUCHAR RTMPFindSection(
- IN PCHAR buffer)
-{
- CHAR temp_buf[32];
- PUCHAR ptr;
-
- strcpy(temp_buf, "Default");
-
- if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
- return (ptr+strlen("\n"));
- else
- return NULL;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get key parameter.
-
- Arguments:
- key Pointer to key string
- dest Pointer to destination
- destsize The datasize of the destination
- buffer Pointer to the buffer to start find the key
-
- Return Value:
- TRUE Success
- FALSE Fail
-
- Note:
- This routine get the value with the matched key (case case-sensitive)
- ========================================================================
-*/
-INT RTMPGetKeyParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer)
-{
- UCHAR *temp_buf1 = NULL;
- UCHAR *temp_buf2 = NULL;
- CHAR *start_ptr;
- CHAR *end_ptr;
- CHAR *ptr;
- CHAR *offset = 0;
- INT len;
-
- //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
- if(temp_buf1 == NULL)
- return (FALSE);
-
- //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
- if(temp_buf2 == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- return (FALSE);
- }
-
- //find section
- if((offset = RTMPFindSection(buffer)) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf1, "\n");
- strcat(temp_buf1, key);
- strcat(temp_buf1, "=");
-
- //search key
- if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- start_ptr+=strlen("\n");
- if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
- end_ptr=start_ptr+strlen(start_ptr);
-
- if (end_ptr<start_ptr)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
- temp_buf2[end_ptr-start_ptr]='\0';
- len = strlen(temp_buf2);
- strcpy(temp_buf1, temp_buf2);
- if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf2, start_ptr+1);
- ptr = temp_buf2;
- //trim space or tab
- while(*ptr != 0x00)
- {
- if( (*ptr == ' ') || (*ptr == '\t') )
- ptr++;
- else
- break;
- }
-
- len = strlen(ptr);
- memset(dest, 0x00, destsize);
- strncpy(dest, ptr, len >= destsize ? destsize: len);
-
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get key parameter.
-
- Arguments:
- key Pointer to key string
- dest Pointer to destination
- destsize The datasize of the destination
- buffer Pointer to the buffer to start find the key
-
- Return Value:
- TRUE Success
- FALSE Fail
-
- Note:
- This routine get the value with the matched key (case case-sensitive).
- It is called for parsing SSID and any key string.
- ========================================================================
-*/
-INT RTMPGetCriticalParameter(
- IN PCHAR key,
- OUT PCHAR dest,
- IN INT destsize,
- IN PCHAR buffer)
-{
- UCHAR *temp_buf1 = NULL;
- UCHAR *temp_buf2 = NULL;
- CHAR *start_ptr;
- CHAR *end_ptr;
- CHAR *ptr;
- CHAR *offset = 0;
- INT len;
-
- //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
- if(temp_buf1 == NULL)
- return (FALSE);
-
- //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
- if(temp_buf2 == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- return (FALSE);
- }
-
- //find section
- if((offset = RTMPFindSection(buffer)) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf1, "\n");
- strcat(temp_buf1, key);
- strcat(temp_buf1, "=");
-
- //search key
- if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- start_ptr+=strlen("\n");
- if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
- end_ptr=start_ptr+strlen(start_ptr);
-
- if (end_ptr<start_ptr)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
- temp_buf2[end_ptr-start_ptr]='\0';
- len = strlen(temp_buf2);
- strcpy(temp_buf1, temp_buf2);
- if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf2, start_ptr+1);
- ptr = temp_buf2;
-
- //trim tab
- /* We cannot trim space(' ') for SSID and key string. */
- while(*ptr != 0x00)
- {
- //if( (*ptr == ' ') || (*ptr == '\t') )
- if( (*ptr == '\t') )
- ptr++;
- else
- break;
- }
-
- len = strlen(ptr);
- memset(dest, 0x00, destsize);
- strncpy(dest, ptr, len >= destsize ? destsize: len);
-
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return TRUE;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Get multiple key parameter.
-
- Arguments:
- key Pointer to key string
- dest Pointer to destination
- destsize The datasize of the destination
- buffer Pointer to the buffer to start find the key
-
- Return Value:
- TRUE Success
- FALSE Fail
-
- Note:
- This routine get the value with the matched key (case case-sensitive)
- ========================================================================
-*/
-INT RTMPGetKeyParameterWithOffset(
- IN PCHAR key,
- OUT PCHAR dest,
- OUT USHORT *end_offset,
- IN INT destsize,
- IN PCHAR buffer,
- IN BOOLEAN bTrimSpace)
-{
- UCHAR *temp_buf1 = NULL;
- UCHAR *temp_buf2 = NULL;
- CHAR *start_ptr;
- CHAR *end_ptr;
- CHAR *ptr;
- CHAR *offset = 0;
- INT len;
-
- if (*end_offset >= MAX_INI_BUFFER_SIZE)
- return (FALSE);
-
- os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
- if(temp_buf1 == NULL)
- return (FALSE);
-
- os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
- if(temp_buf2 == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- return (FALSE);
- }
-
- //find section
- if(*end_offset == 0)
- {
- if ((offset = RTMPFindSection(buffer)) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
- }
- else
- offset = buffer + (*end_offset);
-
- strcpy(temp_buf1, "\n");
- strcat(temp_buf1, key);
- strcat(temp_buf1, "=");
-
- //search key
- if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- start_ptr+=strlen("\n");
- if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
- end_ptr=start_ptr+strlen(start_ptr);
-
- if (end_ptr<start_ptr)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- *end_offset = end_ptr - buffer;
-
- NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
- temp_buf2[end_ptr-start_ptr]='\0';
- len = strlen(temp_buf2);
- strcpy(temp_buf1, temp_buf2);
- if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
- {
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return (FALSE);
- }
-
- strcpy(temp_buf2, start_ptr+1);
- ptr = temp_buf2;
- //trim space or tab
- while(*ptr != 0x00)
- {
- if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
- ptr++;
- else
- break;
- }
-
- len = strlen(ptr);
- memset(dest, 0x00, destsize);
- strncpy(dest, ptr, len >= destsize ? destsize: len);
-
- os_free_mem(NULL, temp_buf1);
- os_free_mem(NULL, temp_buf2);
- return TRUE;
-}
-
-
-static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
-{
- PUCHAR keybuff;
- INT i = BSSIdx, idx = KeyIdx;
- ULONG KeyLen;
- UCHAR CipherAlg = CIPHER_WEP64;
-
- keybuff = buffer;
- KeyLen = strlen(keybuff);
-
- if (KeyType == 1)
- {//Ascii
- if( (KeyLen == 5) || (KeyLen == 13))
- {
- pAd->SharedKey[i][idx].KeyLen = KeyLen;
- NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
- if (KeyLen == 5)
- CipherAlg = CIPHER_WEP64;
- else
- CipherAlg = CIPHER_WEP128;
- pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-
- DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
- return 1;
- }
- else
- {//Invalid key length
- DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
- return 0;
- }
- }
- else
- {//Hex type
- if( (KeyLen == 10) || (KeyLen == 26))
- {
- pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
- AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
- if (KeyLen == 10)
- CipherAlg = CIPHER_WEP64;
- else
- CipherAlg = CIPHER_WEP128;
- pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-
- DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
- return 1;
- }
- else
- {//Invalid key length
- DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
- return 0;
- }
- }
-}
-static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
-{
- char tok_str[16];
- PUCHAR macptr;
- INT i = 0, idx;
- ULONG KeyType[MAX_MBSSID_NUM];
- ULONG KeyIdx;
-
- NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
-
- //DefaultKeyID
- if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- KeyIdx = simple_strtol(tmpbuf, 0, 10);
- if((KeyIdx >= 1 ) && (KeyIdx <= 4))
- pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
- else
- pAd->StaCfg.DefaultKeyId = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- for (idx = 0; idx < 4; idx++)
- {
- sprintf(tok_str, "Key%dType", idx + 1);
- //Key1Type
- if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- KeyType[i] = simple_strtol(macptr, 0, 10);
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- sprintf(tok_str, "Key%dStr", idx + 1);
- if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
- {
- rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- }
-}
-
-
-#ifdef CONFIG_STA_SUPPORT
-static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
-{
- PUCHAR macptr;
- INT i=0;
- BOOLEAN bWmmEnable = FALSE;
-
- //WmmCapable
- if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- {
- pAd->CommonCfg.bWmmCapable = TRUE;
- bWmmEnable = TRUE;
- }
- else //Disable
- {
- pAd->CommonCfg.bWmmCapable = FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
- }
-
-#ifdef QOS_DLS_SUPPORT
- //DLSCapable
- if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- {
- pAd->CommonCfg.bDLSCapable = TRUE;
- }
- else //Disable
- {
- pAd->CommonCfg.bDLSCapable = FALSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
- }
-#endif // QOS_DLS_SUPPORT //
-
- //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
- if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
-
- DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
- }
- }
-
- if (bWmmEnable)
- {
- //APSDCapable
- if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bAPSDCapable = TRUE;
- else
- pAd->CommonCfg.bAPSDCapable = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
- }
-
- //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
- if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
- {
- BOOLEAN apsd_ac[4];
-
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
-
- DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
- }
-
- pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
- pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
- pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
- pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
- }
- }
-
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-NDIS_STATUS RTMPReadParametersHook(
- IN PRTMP_ADAPTER pAd)
-{
- PUCHAR src = NULL;
- struct file *srcf;
- INT retval, orgfsuid, orgfsgid;
- mm_segment_t orgfs;
- CHAR *buffer;
- CHAR *tmpbuf;
- ULONG RtsThresh;
- ULONG FragThresh;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR keyMaterial[40];
-#endif // CONFIG_STA_SUPPORT //
-
-
- PUCHAR macptr;
- INT i = 0;
-
- buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(buffer == NULL)
- return NDIS_STATUS_FAILURE;
-
- tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
- if(tmpbuf == NULL)
- {
- kfree(buffer);
- return NDIS_STATUS_FAILURE;
- }
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- src = STA_PROFILE_PATH;
-#endif // CONFIG_STA_SUPPORT //
-#ifdef MULTIPLE_CARD_SUPPORT
- src = pAd->MC_FileName;
-#endif // MULTIPLE_CARD_SUPPORT //
-
- // Save uid and gid used for filesystem access.
- // Set user and group to 0 (root)
-#if 0
- orgfsuid = current->fsuid;
- orgfsgid = current->fsgid;
- current->fsuid=current->fsgid = 0;
-#endif
- orgfs = get_fs();
- set_fs(KERNEL_DS);
-
- if (src && *src)
- {
- srcf = filp_open(src, O_RDONLY, 0);
- if (IS_ERR(srcf))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
- }
- else
- {
- // The object must have a read method
- if (srcf->f_op && srcf->f_op->read)
- {
- memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
- retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
- if (retval < 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
- }
- else
- {
- // set file parameter to portcfg
- //CountryRegion
- if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
- {
- pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
- }
- //CountryRegionABand
- if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
- {
- pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
- }
- //CountryCode
- if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
- {
- NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- NdisMoveMemory(pAd->StaCfg.StaOriCountryCode, tmpbuf , 2);
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
- if (strlen(pAd->CommonCfg.CountryCode) != 0)
- {
- pAd->CommonCfg.bCountryFlag = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
- }
- //ChannelGeography
- if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
- {
- UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
- if (Geography <= BOTH)
- {
- pAd->CommonCfg.Geography = Geography;
- pAd->CommonCfg.CountryCode[2] =
- (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
-#ifdef CONFIG_STA_SUPPORT
-#ifdef EXT_BUILD_CHANNEL_LIST
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
-#endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
- }
- }
- else
- {
- pAd->CommonCfg.Geography = BOTH;
- pAd->CommonCfg.CountryCode[2] = ' ';
- }
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //SSID
- if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
- {
- if (strlen(tmpbuf) <= 32)
- {
- pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
- NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
- NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
- pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
- NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __FUNCTION__, tmpbuf));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //NetworkType
- if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
- {
- pAd->bConfigChanged = TRUE;
- if (strcmp(tmpbuf, "Adhoc") == 0)
- pAd->StaCfg.BssType = BSS_ADHOC;
- else //Default Infrastructure mode
- pAd->StaCfg.BssType = BSS_INFRA;
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAd->StaCfg.WpaState = SS_NOTUSE;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- //Channel
- if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
- }
- //WirelessMode
- if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
- {
- int value = 0, maxPhyMode = PHY_11G;
-
-#ifdef DOT11_N_SUPPORT
- maxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
- value = simple_strtol(tmpbuf, 0, 10);
-
- if (value <= maxPhyMode)
- {
- pAd->CommonCfg.PhyMode = value;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
- }
- //BasicRate
- if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
- }
- //BeaconPeriod
- if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
- }
- //TxPower
- if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
- {
- pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
-#endif // CONFIG_STA_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
- }
- //BGProtection
- if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case 1: //Always On
- pAd->CommonCfg.UseBGProtection = 1;
- break;
- case 2: //Always OFF
- pAd->CommonCfg.UseBGProtection = 2;
- break;
- case 0: //AUTO
- default:
- pAd->CommonCfg.UseBGProtection = 0;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
- }
- //OLBCDetection
- if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case 1: //disable OLBC Detection
- pAd->CommonCfg.DisableOLBCDetect = 1;
- break;
- case 0: //enable OLBC Detection
- pAd->CommonCfg.DisableOLBCDetect = 0;
- break;
- default:
- pAd->CommonCfg.DisableOLBCDetect= 0;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
- }
- //TxPreamble
- if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case Rt802_11PreambleShort:
- pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
- break;
- case Rt802_11PreambleLong:
- default:
- pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
- }
- //RTSThreshold
- if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
- {
- RtsThresh = simple_strtol(tmpbuf, 0, 10);
- if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
- pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
- else
- pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
- }
- //FragThreshold
- if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
- {
- FragThresh = simple_strtol(tmpbuf, 0, 10);
- pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
-
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- { //illegal FragThresh so we set it to default
- pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
- }
- else if (FragThresh % 2 == 1)
- {
- // The length of each fragment shall always be an even number of octets, except for the last fragment
- // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
- pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
- }
- else
- {
- pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
- //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
- DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
- }
- //TxBurst
- if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
- {
-//#ifdef WIFI_TEST
-// pAd->CommonCfg.bEnableTxBurst = FALSE;
-//#else
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bEnableTxBurst = TRUE;
- else //Disable
- pAd->CommonCfg.bEnableTxBurst = FALSE;
-//#endif
- DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
- }
-
-#ifdef AGGREGATION_SUPPORT
- //PktAggregate
- if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bAggregationCapable = TRUE;
- else //Disable
- pAd->CommonCfg.bAggregationCapable = FALSE;
-#ifdef PIGGYBACK_SUPPORT
- pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
-#endif // PIGGYBACK_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
- }
-#else
- pAd->CommonCfg.bAggregationCapable = FALSE;
- pAd->CommonCfg.bPiggyBackCapable = FALSE;
-#endif // AGGREGATION_SUPPORT //
-
- // WmmCapable
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
-#endif // CONFIG_STA_SUPPORT //
-
- //ShortSlot
- if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
- pAd->CommonCfg.bUseShortSlotTime = TRUE;
- else //Disable
- pAd->CommonCfg.bUseShortSlotTime = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
- }
- //IEEE80211H
- if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- if(simple_strtol(macptr, 0, 10) != 0) //Enable
- pAd->CommonCfg.bIEEE80211H = TRUE;
- else //Disable
- pAd->CommonCfg.bIEEE80211H = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
- }
- }
- //CSPeriod
- if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0)
- pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
- else
- pAd->CommonCfg.RadarDetect.CSPeriod = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
- }
-
- //RDRegion
- if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
- {
- if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
- }
- else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
- else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
- }
- else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
- }
- else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
- else
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
- }
- else
- {
- pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
- pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
- }
-
- //WirelessEvent
- if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
- {
-#if WIRELESS_EXT >= 15
- if(simple_strtol(tmpbuf, 0, 10) != 0)
- pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
- else
- pAd->CommonCfg.bWirelessEvent = 0; // disable
-#else
- pAd->CommonCfg.bWirelessEvent = 0; // disable
-#endif
- DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
- }
- if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) != 0)
- pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
- else
- pAd->CommonCfg.bWiFiTest = 0; // disable
-
- DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
- }
- //AuthMode
- if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
- {
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
- else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
- else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
- //EncrypType
- if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
- pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
- pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
- pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- else
- pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-
- // Update all wepstatus related
- pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
- pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
- pAd->StaCfg.bMixCipher = FALSE;
-
- //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
- {
- int err=0;
-
- tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
-
- if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- )
- {
- err = 1;
- }
- else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
- {
- PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
- NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
-
- }
- else if (strlen(tmpbuf) == 64)
- {
- AtoH(tmpbuf, keyMaterial, 32);
- NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
- }
- else
- {
- err = 1;
- DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __FUNCTION__));
- }
-
- if (err == 0)
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- // Start STA supplicant state machine
- pAd->StaCfg.WpaState = SS_START;
- }
- else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- /*
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
- */
- pAd->StaCfg.WpaState = SS_NOTUSE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
- //DefaultKeyID, KeyType, KeyStr
- rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
-
-
- //HSCounter
- /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, buffer))
- {
- switch (simple_strtol(tmpbuf, 0, 10))
- {
- case 1: //Enable
- pAd->CommonCfg.bEnableHSCounter = TRUE;
- break;
- case 0: //Disable
- default:
- pAd->CommonCfg.bEnableHSCounter = FALSE;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
- }*/
-
-#ifdef DOT11_N_SUPPORT
- HTParametersHook(pAd, tmpbuf, buffer);
-#endif // DOT11_N_SUPPORT //
-
-
-#ifdef CARRIER_DETECTION_SUPPORT
- //CarrierDetect
- if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, buffer))
- {
- if ((strncmp(tmpbuf, "0", 1) == 0))
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else if ((strncmp(tmpbuf, "1", 1) == 0))
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CarrierDetect.Enable=%d\n", pAd->CommonCfg.CarrierDetect.Enable));
- }
- else
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- //PSMode
- if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
- {
- if (pAd->StaCfg.BssType == BSS_INFRA)
- {
- if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- // MlmeSetPsm(pAd, PWR_SAVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAd->StaCfg.DefaultListenCount = 5;
- }
- else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
- || (strcmp(tmpbuf, "FAST_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- // MlmeSetPsmBit(pAd, PWR_SAVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
- pAd->StaCfg.DefaultListenCount = 3;
- }
- else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
- || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- // MlmeSetPsmBit(pAd, PWR_SAVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAd->StaCfg.DefaultListenCount = 3;
- }
- else
- { //Default Ndis802_11PowerModeCAM
- // clear PSM bit immediately
- MlmeSetPsmBit(pAd, PWR_ACTIVE);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
- if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
- pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
- }
- }
- // FastRoaming
- if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
- {
- if (simple_strtol(tmpbuf, 0, 10) == 0)
- pAd->StaCfg.bFastRoaming = FALSE;
- else
- pAd->StaCfg.bFastRoaming = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
- }
- // RoamThreshold
- if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
- {
- long lInfo = simple_strtol(tmpbuf, 0, 10);
-
- if (lInfo > 90 || lInfo < 60)
- pAd->StaCfg.dBmToRoam = -70;
- else
- pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
- }
-
- if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
- {
- if(simple_strtol(tmpbuf, 0, 10) == 0)
- pAd->StaCfg.bTGnWifiTest = FALSE;
- else
- pAd->StaCfg.bTGnWifiTest = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-
-
-#ifdef RT30xx
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, buffer))
- {
- for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
- {
- if(simple_strtol(macptr, 0, 10) != 0) //Enable
- pAd->CommonCfg.bRxAntDiversity = TRUE;
- else //Disable
- pAd->CommonCfg.bRxAntDiversity = FALSE;
-
- DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
- }
- }
- }
-#endif // CONFIG_STA_SUPPORT //
-#endif // RT30xx //
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
- }
-
- retval=filp_close(srcf,NULL);
-
- if (retval)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
- }
- }
- }
-
- set_fs(orgfs);
-#if 0
- current->fsuid = orgfsuid;
- current->fsgid = orgfsgid;
-#endif
-
- kfree(buffer);
- kfree(tmpbuf);
-
- return (NDIS_STATUS_SUCCESS);
-}
-
-#ifdef DOT11_N_SUPPORT
-static void HTParametersHook(
- IN PRTMP_ADAPTER pAd,
- IN CHAR *pValueStr,
- IN CHAR *pInput)
-{
-
- INT Value;
-
- if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bHTProtect = FALSE;
- }
- else
- {
- pAd->CommonCfg.bHTProtect = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bMIMOPSEnable = FALSE;
- }
- else
- {
- pAd->CommonCfg.bMIMOPSEnable = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
-
- if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value > MMPS_ENABLE)
- {
- pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
- }
- else
- {
- //TODO: add mimo power saving mechanism
- pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
- //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
- }
-
- if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bBADecline = FALSE;
- }
- else
- {
- pAd->CommonCfg.bBADecline = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
-
- if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bDisableReordering = FALSE;
- }
- else
- {
- pAd->CommonCfg.bDisableReordering = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
- pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
- }
- else
- {
- pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
- pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
- }
- pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
- pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- // Tx_+HTC frame
- if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->HTCEnable = FALSE;
- }
- else
- {
- pAd->HTCEnable = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- // Enable HT Link Adaptation Control
- if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->bLinkAdapt = FALSE;
- }
- else
- {
- pAd->HTCEnable = TRUE;
- pAd->bLinkAdapt = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
- }
-
- // Reverse Direction Mechanism
- if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bRdg = FALSE;
- }
- else
- {
- pAd->HTCEnable = TRUE;
- pAd->CommonCfg.bRdg = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
- }
-
-
-
-
- // Tx A-MSUD ?
- if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
- }
- else
- {
- pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
- }
-
- // MPDU Density
- if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value <=7 && Value >= 0)
- {
- pAd->CommonCfg.BACapability.field.MpduDensity = Value;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
- }
- else
- {
- pAd->CommonCfg.BACapability.field.MpduDensity = 4;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
- }
- }
-
- // Max Rx BA Window Size
- if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value >=1 && Value <= 64)
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
- }
- else
- {
- pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
- pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
- }
-
- }
-
- // Guard Interval
- if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == GI_400)
- {
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
- }
-
- // HT Operation Mode : Mixed Mode , Green Field
- if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == HTMODE_GF)
- {
-
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
- }
-
- // Fixed Tx mode : CCK, OFDM
- if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
- {
- UCHAR fix_tx_mode;
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- fix_tx_mode = FIXED_TXMODE_HT;
-
- if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_OFDM;
- }
- else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_CCK;
- }
- else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
- {
- fix_tx_mode = FIXED_TXMODE_HT;
- }
- else
- {
- Value = simple_strtol(pValueStr, 0, 10);
- // 1 : CCK
- // 2 : OFDM
- // otherwise : HT
- if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
- fix_tx_mode = Value;
- else
- fix_tx_mode = FIXED_TXMODE_HT;
- }
-
- pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
- DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
-
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
-
- // Channel Width
- if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == BW_40)
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
- }
-
-#ifdef MCAST_RATE_SPECIFIC
- pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
-#endif // MCAST_RATE_SPECIFIC //
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
- }
-
- if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
- if (Value == 0)
- {
-
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
- }
-
- // MSC
- if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
- {
-
-#ifdef CONFIG_STA_SUPPORT
- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
- {
- Value = simple_strtol(pValueStr, 0, 10);
-
-// if ((Value >= 0 && Value <= 15) || (Value == 32))
- if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
- pAd->StaCfg.bAutoTxRateSwitch = FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
- }
- else
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
- }
- }
-#endif // CONFIG_STA_SUPPORT //
- }
-
- // STBC
- if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == STBC_USE)
- {
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
- }
- else
- {
- pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
- }
-
- // 40_Mhz_Intolerant
- if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
- {
- Value = simple_strtol(pValueStr, 0, 10);
- if (Value == 0)
- {
- pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
- }
- else
- {
- pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
- }
- //HT_TxStream
- if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
- {
- switch (simple_strtol(pValueStr, 0, 10))
- {
- case 1:
- pAd->CommonCfg.TxStream = 1;
- break;
- case 2:
- pAd->CommonCfg.TxStream = 2;
- break;
- case 3: // 3*3
- default:
- pAd->CommonCfg.TxStream = 3;
-
- if (pAd->MACVersion < RALINK_2883_VERSION)
- pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
- }
- //HT_RxStream
- if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
- {
- switch (simple_strtol(pValueStr, 0, 10))
- {
- case 1:
- pAd->CommonCfg.RxStream = 1;
- break;
- case 2:
- pAd->CommonCfg.RxStream = 2;
- break;
- case 3:
- default:
- pAd->CommonCfg.RxStream = 3;
-
- if (pAd->MACVersion < RALINK_2883_VERSION)
- pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
- }
-
-}
-#endif // DOT11_N_SUPPORT //
-
+#include "../rt2870/rt_profile.c"
diff --git a/drivers/staging/rt3070/rtmp.h b/drivers/staging/rt3070/rtmp.h
index d80d74ffbc89..5390ca3eb27a 100644
--- a/drivers/staging/rt3070/rtmp.h
+++ b/drivers/staging/rt3070/rtmp.h
@@ -1,7728 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp.h
-
- Abstract:
- Miniport generic portion header file
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 2002-08-01 created
- James Tan 2002-09-06 modified (Revise NTCRegTable)
- John Chang 2004-09-06 modified for RT2600
-*/
-#ifndef __RTMP_H__
-#define __RTMP_H__
-
-#include "link_list.h"
-#include "spectrum_def.h"
-
-#ifdef MLME_EX
-#include "mlme_ex_def.h"
-#endif // MLME_EX //
-
-#ifdef CONFIG_STA_SUPPORT
-#include "aironet.h"
-#endif // CONFIG_STA_SUPPORT //
-
-#undef AP_WSC_INCLUDED
-#undef STA_WSC_INCLUDED
-#undef WSC_INCLUDED
-
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
-#if defined(AP_WSC_INCLUDED) || defined(STA_WSC_INCLUDED)
-#define WSC_INCLUDED
-#endif
-
-
-
-
-
-//#define DBG 1
-
-//#define DBG_DIAGNOSE 1
-
-#if defined(CONFIG_AP_SUPPORT) && defined(CONFIG_STA_SUPPORT)
-#define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd) if(_pAd->OpMode == OPMODE_AP)
-#define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd) if(_pAd->OpMode == OPMODE_STA)
-#else
-#define IF_DEV_CONFIG_OPMODE_ON_AP(_pAd)
-#define IF_DEV_CONFIG_OPMODE_ON_STA(_pAd)
-#endif
-
-#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
-#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
-#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
-
-#ifdef RT2870
-////////////////////////////////////////////////////////////////////////////
-// The TX_BUFFER structure forms the transmitted USB packet to the device
-////////////////////////////////////////////////////////////////////////////
-typedef struct __TX_BUFFER{
- union {
- UCHAR WirelessPacket[TX_BUFFER_NORMSIZE];
- HEADER_802_11 NullFrame;
- PSPOLL_FRAME PsPollPacket;
- RTS_FRAME RTSFrame;
- }field;
- UCHAR Aggregation[4]; //Buffer for save Aggregation size.
-} TX_BUFFER, *PTX_BUFFER;
-
-typedef struct __HTTX_BUFFER{
- union {
- UCHAR WirelessPacket[MAX_TXBULK_SIZE];
- HEADER_802_11 NullFrame;
- PSPOLL_FRAME PsPollPacket;
- RTS_FRAME RTSFrame;
- }field;
- UCHAR Aggregation[4]; //Buffer for save Aggregation size.
-} HTTX_BUFFER, *PHTTX_BUFFER;
-
-
-// used to track driver-generated write irps
-typedef struct _TX_CONTEXT
-{
- PVOID pAd; //Initialized in MiniportInitialize
- PURB pUrb; //Initialized in MiniportInitialize
- PIRP pIrp; //used to cancel pending bulk out.
- //Initialized in MiniportInitialize
- PTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
- ULONG BulkOutSize;
- UCHAR BulkOutPipeId;
- UCHAR SelfIdx;
- BOOLEAN InUse;
- BOOLEAN bWaitingBulkOut; // at least one packet is in this TxContext, ready for making IRP anytime.
- BOOLEAN bFullForBulkOut; // all tx buffer are full , so waiting for tx bulkout.
- BOOLEAN IRPPending;
- BOOLEAN LastOne;
- BOOLEAN bAggregatible;
- UCHAR Header_802_3[LENGTH_802_3];
- UCHAR Rsv[2];
- ULONG DataOffset;
- UINT TxRate;
- dma_addr_t data_dma; // urb dma on linux
-
-} TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT;
-
-
-// used to track driver-generated write irps
-typedef struct _HT_TX_CONTEXT
-{
- PVOID pAd; //Initialized in MiniportInitialize
- PURB pUrb; //Initialized in MiniportInitialize
- PIRP pIrp; //used to cancel pending bulk out.
- //Initialized in MiniportInitialize
- PHTTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
- ULONG BulkOutSize; // Indicate the total bulk-out size in bytes in one bulk-transmission
- UCHAR BulkOutPipeId;
- BOOLEAN IRPPending;
- BOOLEAN LastOne;
- BOOLEAN bCurWriting;
- BOOLEAN bRingEmpty;
- BOOLEAN bCopySavePad;
- UCHAR SavedPad[8];
- UCHAR Header_802_3[LENGTH_802_3];
- ULONG CurWritePosition; // Indicate the buffer offset which packet will be inserted start from.
- ULONG CurWriteRealPos; // Indicate the buffer offset which packet now are writing to.
- ULONG NextBulkOutPosition; // Indicate the buffer start offset of a bulk-transmission
- ULONG ENextBulkOutPosition; // Indicate the buffer end offset of a bulk-transmission
- UINT TxRate;
- dma_addr_t data_dma; // urb dma on linux
-} HT_TX_CONTEXT, *PHT_TX_CONTEXT, **PPHT_TX_CONTEXT;
-
-
-//
-// Structure to keep track of receive packets and buffers to indicate
-// receive data to the protocol.
-//
-typedef struct _RX_CONTEXT
-{
- PUCHAR TransferBuffer;
- PVOID pAd;
- PIRP pIrp;//used to cancel pending bulk in.
- PURB pUrb;
- //These 2 Boolean shouldn't both be 1 at the same time.
- ULONG BulkInOffset; // number of packets waiting for reordering .
-// BOOLEAN ReorderInUse; // At least one packet in this buffer are in reordering buffer and wait for receive indication
- BOOLEAN bRxHandling; // Notify this packet is being process now.
- BOOLEAN InUse; // USB Hardware Occupied. Wait for USB HW to put packet.
- BOOLEAN Readable; // Receive Complete back. OK for driver to indicate receiving packet.
- BOOLEAN IRPPending; // TODO: To be removed
- atomic_t IrpLock;
- NDIS_SPIN_LOCK RxContextLock;
- dma_addr_t data_dma; // urb dma on linux
-} RX_CONTEXT, *PRX_CONTEXT;
-#endif // RT2870 //
-
-
-//
-// NDIS Version definitions
-//
-#ifdef NDIS50_MINIPORT
-#define RTMP_NDIS_MAJOR_VERSION 5
-#define RTMP_NDIS_MINOR_VERSION 0
-#endif
-
-#ifdef NDIS51_MINIPORT
-#define RTMP_NDIS_MAJOR_VERSION 5
-#define RTMP_NDIS_MINOR_VERSION 1
-#endif
-
-extern char NIC_VENDOR_DESC[];
-extern int NIC_VENDOR_DESC_LEN;
-
-extern unsigned char SNAP_AIRONET[];
-extern unsigned char CipherSuiteCiscoCCKM[];
-extern unsigned char CipherSuiteCiscoCCKMLen;
-extern unsigned char CipherSuiteCiscoCCKM24[];
-extern unsigned char CipherSuiteCiscoCCKM24Len;
-extern unsigned char CipherSuiteCCXTkip[];
-extern unsigned char CipherSuiteCCXTkipLen;
-extern unsigned char CISCO_OUI[];
-extern UCHAR BaSizeArray[4];
-
-extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];
-extern UCHAR MULTICAST_ADDR[MAC_ADDR_LEN];
-extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];
-extern ULONG BIT32[32];
-extern UCHAR BIT8[8];
-extern char* CipherName[];
-extern char* MCSToMbps[];
-extern UCHAR RxwiMCSToOfdmRate[12];
-extern UCHAR SNAP_802_1H[6];
-extern UCHAR SNAP_BRIDGE_TUNNEL[6];
-extern UCHAR SNAP_AIRONET[8];
-extern UCHAR CKIP_LLC_SNAP[8];
-extern UCHAR EAPOL_LLC_SNAP[8];
-extern UCHAR EAPOL[2];
-extern UCHAR IPX[2];
-extern UCHAR APPLE_TALK[2];
-extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14
-extern UCHAR OfdmRateToRxwiMCS[];
-extern UCHAR OfdmSignalToRateId[16] ;
-extern UCHAR default_cwmin[4];
-extern UCHAR default_cwmax[4];
-extern UCHAR default_sta_aifsn[4];
-extern UCHAR MapUserPriorityToAccessCategory[8];
-
-extern USHORT RateUpPER[];
-extern USHORT RateDownPER[];
-extern UCHAR Phy11BNextRateDownward[];
-extern UCHAR Phy11BNextRateUpward[];
-extern UCHAR Phy11BGNextRateDownward[];
-extern UCHAR Phy11BGNextRateUpward[];
-extern UCHAR Phy11ANextRateDownward[];
-extern UCHAR Phy11ANextRateUpward[];
-extern CHAR RssiSafeLevelForTxRate[];
-extern UCHAR RateIdToMbps[];
-extern USHORT RateIdTo500Kbps[];
-
-extern UCHAR CipherSuiteWpaNoneTkip[];
-extern UCHAR CipherSuiteWpaNoneTkipLen;
-
-extern UCHAR CipherSuiteWpaNoneAes[];
-extern UCHAR CipherSuiteWpaNoneAesLen;
-
-extern UCHAR SsidIe;
-extern UCHAR SupRateIe;
-extern UCHAR ExtRateIe;
-
-#ifdef DOT11_N_SUPPORT
-extern UCHAR HtCapIe;
-extern UCHAR AddHtInfoIe;
-extern UCHAR NewExtChanIe;
-#ifdef DOT11N_DRAFT3
-extern UCHAR ExtHtCapIe;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-extern UCHAR ErpIe;
-extern UCHAR DsIe;
-extern UCHAR TimIe;
-extern UCHAR WpaIe;
-extern UCHAR Wpa2Ie;
-extern UCHAR IbssIe;
-extern UCHAR Ccx2Ie;
-extern UCHAR WapiIe;
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WAPI_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR Ccx2IeInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR PowerConstraintIE[];
-
-
-extern UCHAR RateSwitchTable[];
-extern UCHAR RateSwitchTable11B[];
-extern UCHAR RateSwitchTable11G[];
-extern UCHAR RateSwitchTable11BG[];
-
-#ifdef DOT11_N_SUPPORT
-extern UCHAR RateSwitchTable11BGN1S[];
-extern UCHAR RateSwitchTable11BGN2S[];
-extern UCHAR RateSwitchTable11BGN2SForABand[];
-extern UCHAR RateSwitchTable11N1S[];
-extern UCHAR RateSwitchTable11N2S[];
-extern UCHAR RateSwitchTable11N2SForABand[];
-
-#ifdef CONFIG_STA_SUPPORT
-extern UCHAR PRE_N_HT_OUI[];
-#endif // CONFIG_STA_SUPPORT //
-#endif // DOT11_N_SUPPORT //
-
-#define MAXSEQ (0xFFF)
-
-#ifdef RALINK_ATE
-typedef struct _ATE_INFO {
- UCHAR Mode;
- CHAR TxPower0;
- CHAR TxPower1;
- CHAR TxAntennaSel;
- CHAR RxAntennaSel;
- TXWI_STRUC TxWI; // TXWI
- USHORT QID;
- UCHAR Addr1[MAC_ADDR_LEN];
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR Addr3[MAC_ADDR_LEN];
- UCHAR Channel;
- UINT32 TxLength;
- UINT32 TxCount;
- UINT32 TxDoneCount; // Tx DMA Done
- UINT32 RFFreqOffset;
- BOOLEAN bRxFer;
- BOOLEAN bQATxStart; // Have compiled QA in and use it to ATE tx.
- BOOLEAN bQARxStart; // Have compiled QA in and use it to ATE rx.
- UINT32 RxTotalCnt;
- UINT32 RxCntPerSec;
-
- CHAR LastSNR0; // last received SNR
- CHAR LastSNR1; // last received SNR for 2nd antenna
- CHAR LastRssi0; // last received RSSI
- CHAR LastRssi1; // last received RSSI for 2nd antenna
- CHAR LastRssi2; // last received RSSI for 3rd antenna
- CHAR AvgRssi0; // last 8 frames' average RSSI
- CHAR AvgRssi1; // last 8 frames' average RSSI
- CHAR AvgRssi2; // last 8 frames' average RSSI
- SHORT AvgRssi0X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi1X8; // sum of last 8 frames' RSSI
- SHORT AvgRssi2X8; // sum of last 8 frames' RSSI
-
- UINT32 NumOfAvgRssiSample;
-
-#ifdef RALINK_28xx_QA
- // Tx frame
-#ifdef RT2870
- /* not used in RT2860 */
- TXINFO_STRUC TxInfo; // TxInfo
-#endif // RT2870 //
- USHORT HLen; // Header Length
- USHORT PLen; // Pattern Length
- UCHAR Header[32]; // Header buffer
- UCHAR Pattern[32]; // Pattern buffer
- USHORT DLen; // Data Length
- USHORT seq;
- UINT32 CID;
- pid_t AtePid;
- // counters
- UINT32 U2M;
- UINT32 OtherData;
- UINT32 Beacon;
- UINT32 OtherCount;
- UINT32 TxAc0;
- UINT32 TxAc1;
- UINT32 TxAc2;
- UINT32 TxAc3;
- UINT32 TxHCCA;
- UINT32 TxMgmt;
- UINT32 RSSI0;
- UINT32 RSSI1;
- UINT32 RSSI2;
- UINT32 SNR0;
- UINT32 SNR1;
- // control
- //UINT32 Repeat; // Tx Cpu count
- UCHAR TxStatus; // task Tx status // 0 --> task is idle, 1 --> task is running
-#endif // RALINK_28xx_QA //
-} ATE_INFO, *PATE_INFO;
-
-#ifdef RALINK_28xx_QA
-struct ate_racfghdr {
- UINT32 magic_no;
- USHORT command_type;
- USHORT command_id;
- USHORT length;
- USHORT sequence;
- USHORT status;
- UCHAR data[2046];
-} __attribute__((packed));
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
-struct reordering_mpdu
-{
- struct reordering_mpdu *next;
- PNDIS_PACKET pPacket; /* coverted to 802.3 frame */
- int Sequence; /* sequence number of MPDU */
- BOOLEAN bAMSDU;
-};
-
-struct reordering_list
-{
- struct reordering_mpdu *next;
- int qlen;
-};
-
-struct reordering_mpdu_pool
-{
- PVOID mem;
- NDIS_SPIN_LOCK lock;
- struct reordering_list freelist;
-};
-#endif // DOT11_N_SUPPORT //
-
-typedef struct _RSSI_SAMPLE {
- CHAR LastRssi0; // last received RSSI
- CHAR LastRssi1; // last received RSSI
- CHAR LastRssi2; // last received RSSI
- CHAR AvgRssi0;
- CHAR AvgRssi1;
- CHAR AvgRssi2;
- SHORT AvgRssi0X8;
- SHORT AvgRssi1X8;
- SHORT AvgRssi2X8;
-} RSSI_SAMPLE;
-
-//
-// Queue structure and macros
-//
-typedef struct _QUEUE_ENTRY {
- struct _QUEUE_ENTRY *Next;
-} QUEUE_ENTRY, *PQUEUE_ENTRY;
-
-// Queue structure
-typedef struct _QUEUE_HEADER {
- PQUEUE_ENTRY Head;
- PQUEUE_ENTRY Tail;
- ULONG Number;
-} QUEUE_HEADER, *PQUEUE_HEADER;
-
-#define InitializeQueueHeader(QueueHeader) \
-{ \
- (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
- (QueueHeader)->Number = 0; \
-}
-
-#define RemoveHeadQueue(QueueHeader) \
-(QueueHeader)->Head; \
-{ \
- PQUEUE_ENTRY pNext; \
- if ((QueueHeader)->Head != NULL) \
- { \
- pNext = (QueueHeader)->Head->Next; \
- (QueueHeader)->Head = pNext; \
- if (pNext == NULL) \
- (QueueHeader)->Tail = NULL; \
- (QueueHeader)->Number--; \
- } \
-}
-
-#define InsertHeadQueue(QueueHeader, QueueEntry) \
-{ \
- ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- if ((QueueHeader)->Tail == NULL) \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
-}
-
-#define InsertTailQueue(QueueHeader, QueueEntry) \
-{ \
- ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \
- if ((QueueHeader)->Tail) \
- (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
- else \
- (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
- (QueueHeader)->Number++; \
-}
-
-//
-// Macros for flag and ref count operations
-//
-#define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
-#define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
-#define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
-#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
-#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
-
-#define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
-#define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
-#define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
-
-#define CLIENT_STATUS_SET_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags |= (_F))
-#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags &= ~(_F))
-#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F) (((_pEntry)->ClientStatusFlags & (_F)) != 0)
-
-#define RX_FILTER_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter |= (_F))
-#define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
-#define RX_FILTER_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
-
-#ifdef CONFIG_STA_SUPPORT
-#define STA_NO_SECURITY_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
-#define STA_WEP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
-#define STA_TKIP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-#define STA_AES_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
-
-#define STA_TGN_WIFI_ON(_p) (_p->StaCfg.bTGnWifiTest == TRUE)
-#endif // CONFIG_STA_SUPPORT //
-
-#define CKIP_KP_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-#define CKIP_CMIC_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-
-
-#define INC_RING_INDEX(_idx, _RingSize) \
-{ \
- (_idx) = (_idx+1) % (_RingSize); \
-}
-
-// We will have a cost down version which mac version is 0x3090xxxx
-#define IS_RT3090(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
-
-#define IS_RT3070(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
-#define IS_RT3071(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30710000)
-#define IS_RT2070(_pAd) (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27))
-
-#define IS_RT30xx(_pAd) (((_pAd)->MACVersion & 0xfff00000) == 0x30700000)
-
-#define RING_PACKET_INIT(_TxRing, _idx) \
-{ \
- _TxRing->Cell[_idx].pNdisPacket = NULL; \
- _TxRing->Cell[_idx].pNextNdisPacket = NULL; \
-}
-
-#define TXDT_INIT(_TxD) \
-{ \
- NdisZeroMemory(_TxD, TXD_SIZE); \
- _TxD->DMADONE = 1; \
-}
-
-//Set last data segment
-#define RING_SET_LASTDS(_TxD, _IsSD0) \
-{ \
- if (_IsSD0) {_TxD->LastSec0 = 1;} \
- else {_TxD->LastSec1 = 1;} \
-}
-
-// Increase TxTsc value for next transmission
-// TODO:
-// When i==6, means TSC has done one full cycle, do re-keying stuff follow specs
-// Should send a special event microsoft defined to request re-key
-#define INC_TX_TSC(_tsc) \
-{ \
- int i=0; \
- while (++_tsc[i] == 0x0) \
- { \
- i++; \
- if (i == 6) \
- break; \
- } \
-}
-
-#ifdef DOT11_N_SUPPORT
-// StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here.
-#define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
-{ \
- _pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth; \
- _pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs; \
- _pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF; \
- _pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20; \
- _pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40; \
- _pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC; \
- _pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC; \
- _pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset; \
- _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth; \
- _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode; \
- _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent; \
- NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(UCHAR) * 16);\
-}
-
-#define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \
-{ \
- _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (UCHAR)(_pHtCapability->HtCapInfo.AMsduSize); \
- _pAd->MacTab.Content[BSSID_WCID].MmpsMode= (UCHAR)(_pHtCapability->HtCapInfo.MimoPs); \
- _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (UCHAR)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
-}
-#endif // DOT11_N_SUPPORT //
-
-//
-// MACRO for 32-bit PCI register read / write
-//
-// Usage : RTMP_IO_READ32(
-// PRTMP_ADAPTER pAd,
-// ULONG Register_Offset,
-// PULONG pValue)
-//
-// RTMP_IO_WRITE32(
-// PRTMP_ADAPTER pAd,
-// ULONG Register_Offset,
-// ULONG Value)
-//
-
-//
-// BBP & RF are using indirect access. Before write any value into it.
-// We have to make sure there is no outstanding command pending via checking busy bit.
-//
-#define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register
-//
-
-#ifdef RT2870
-#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V)
-#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
-#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
-
-#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
-#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
-#endif // RT2870 //
-
-#ifdef RT30xx
-#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV) RT30xxReadRFRegister(_A, _I, _pV)
-#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V) RT30xxWriteRFRegister(_A, _I, _V)
-#endif // RT30xx //
-
-#define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \
- switch (ch) \
- { \
- case 1: khz = 2412000; break; \
- case 2: khz = 2417000; break; \
- case 3: khz = 2422000; break; \
- case 4: khz = 2427000; break; \
- case 5: khz = 2432000; break; \
- case 6: khz = 2437000; break; \
- case 7: khz = 2442000; break; \
- case 8: khz = 2447000; break; \
- case 9: khz = 2452000; break; \
- case 10: khz = 2457000; break; \
- case 11: khz = 2462000; break; \
- case 12: khz = 2467000; break; \
- case 13: khz = 2472000; break; \
- case 14: khz = 2484000; break; \
- case 36: /* UNII */ khz = 5180000; break; \
- case 40: /* UNII */ khz = 5200000; break; \
- case 44: /* UNII */ khz = 5220000; break; \
- case 48: /* UNII */ khz = 5240000; break; \
- case 52: /* UNII */ khz = 5260000; break; \
- case 56: /* UNII */ khz = 5280000; break; \
- case 60: /* UNII */ khz = 5300000; break; \
- case 64: /* UNII */ khz = 5320000; break; \
- case 149: /* UNII */ khz = 5745000; break; \
- case 153: /* UNII */ khz = 5765000; break; \
- case 157: /* UNII */ khz = 5785000; break; \
- case 161: /* UNII */ khz = 5805000; break; \
- case 165: /* UNII */ khz = 5825000; break; \
- case 100: /* HiperLAN2 */ khz = 5500000; break; \
- case 104: /* HiperLAN2 */ khz = 5520000; break; \
- case 108: /* HiperLAN2 */ khz = 5540000; break; \
- case 112: /* HiperLAN2 */ khz = 5560000; break; \
- case 116: /* HiperLAN2 */ khz = 5580000; break; \
- case 120: /* HiperLAN2 */ khz = 5600000; break; \
- case 124: /* HiperLAN2 */ khz = 5620000; break; \
- case 128: /* HiperLAN2 */ khz = 5640000; break; \
- case 132: /* HiperLAN2 */ khz = 5660000; break; \
- case 136: /* HiperLAN2 */ khz = 5680000; break; \
- case 140: /* HiperLAN2 */ khz = 5700000; break; \
- case 34: /* Japan MMAC */ khz = 5170000; break; \
- case 38: /* Japan MMAC */ khz = 5190000; break; \
- case 42: /* Japan MMAC */ khz = 5210000; break; \
- case 46: /* Japan MMAC */ khz = 5230000; break; \
- case 184: /* Japan */ khz = 4920000; break; \
- case 188: /* Japan */ khz = 4940000; break; \
- case 192: /* Japan */ khz = 4960000; break; \
- case 196: /* Japan */ khz = 4980000; break; \
- case 208: /* Japan, means J08 */ khz = 5040000; break; \
- case 212: /* Japan, means J12 */ khz = 5060000; break; \
- case 216: /* Japan, means J16 */ khz = 5080000; break; \
- default: khz = 2412000; break; \
- } \
- }
-
-#define MAP_KHZ_TO_CHANNEL_ID(khz, ch) { \
- switch (khz) \
- { \
- case 2412000: ch = 1; break; \
- case 2417000: ch = 2; break; \
- case 2422000: ch = 3; break; \
- case 2427000: ch = 4; break; \
- case 2432000: ch = 5; break; \
- case 2437000: ch = 6; break; \
- case 2442000: ch = 7; break; \
- case 2447000: ch = 8; break; \
- case 2452000: ch = 9; break; \
- case 2457000: ch = 10; break; \
- case 2462000: ch = 11; break; \
- case 2467000: ch = 12; break; \
- case 2472000: ch = 13; break; \
- case 2484000: ch = 14; break; \
- case 5180000: ch = 36; /* UNII */ break; \
- case 5200000: ch = 40; /* UNII */ break; \
- case 5220000: ch = 44; /* UNII */ break; \
- case 5240000: ch = 48; /* UNII */ break; \
- case 5260000: ch = 52; /* UNII */ break; \
- case 5280000: ch = 56; /* UNII */ break; \
- case 5300000: ch = 60; /* UNII */ break; \
- case 5320000: ch = 64; /* UNII */ break; \
- case 5745000: ch = 149; /* UNII */ break; \
- case 5765000: ch = 153; /* UNII */ break; \
- case 5785000: ch = 157; /* UNII */ break; \
- case 5805000: ch = 161; /* UNII */ break; \
- case 5825000: ch = 165; /* UNII */ break; \
- case 5500000: ch = 100; /* HiperLAN2 */ break; \
- case 5520000: ch = 104; /* HiperLAN2 */ break; \
- case 5540000: ch = 108; /* HiperLAN2 */ break; \
- case 5560000: ch = 112; /* HiperLAN2 */ break; \
- case 5580000: ch = 116; /* HiperLAN2 */ break; \
- case 5600000: ch = 120; /* HiperLAN2 */ break; \
- case 5620000: ch = 124; /* HiperLAN2 */ break; \
- case 5640000: ch = 128; /* HiperLAN2 */ break; \
- case 5660000: ch = 132; /* HiperLAN2 */ break; \
- case 5680000: ch = 136; /* HiperLAN2 */ break; \
- case 5700000: ch = 140; /* HiperLAN2 */ break; \
- case 5170000: ch = 34; /* Japan MMAC */ break; \
- case 5190000: ch = 38; /* Japan MMAC */ break; \
- case 5210000: ch = 42; /* Japan MMAC */ break; \
- case 5230000: ch = 46; /* Japan MMAC */ break; \
- case 4920000: ch = 184; /* Japan */ break; \
- case 4940000: ch = 188; /* Japan */ break; \
- case 4960000: ch = 192; /* Japan */ break; \
- case 4980000: ch = 196; /* Japan */ break; \
- case 5040000: ch = 208; /* Japan, means J08 */ break; \
- case 5060000: ch = 212; /* Japan, means J12 */ break; \
- case 5080000: ch = 216; /* Japan, means J16 */ break; \
- default: ch = 1; break; \
- } \
- }
-
-//
-// Common fragment list structure - Identical to the scatter gather frag list structure
-//
-//#define RTMP_SCATTER_GATHER_ELEMENT SCATTER_GATHER_ELEMENT
-//#define PRTMP_SCATTER_GATHER_ELEMENT PSCATTER_GATHER_ELEMENT
-#define NIC_MAX_PHYS_BUF_COUNT 8
-
-typedef struct _RTMP_SCATTER_GATHER_ELEMENT {
- PVOID Address;
- ULONG Length;
- PULONG Reserved;
-} RTMP_SCATTER_GATHER_ELEMENT, *PRTMP_SCATTER_GATHER_ELEMENT;
-
-
-typedef struct _RTMP_SCATTER_GATHER_LIST {
- ULONG NumberOfElements;
- PULONG Reserved;
- RTMP_SCATTER_GATHER_ELEMENT Elements[NIC_MAX_PHYS_BUF_COUNT];
-} RTMP_SCATTER_GATHER_LIST, *PRTMP_SCATTER_GATHER_LIST;
-
-//
-// Some utility macros
-//
-#ifndef min
-#define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
-#endif
-
-#ifndef max
-#define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
-#endif
-
-#define GET_LNA_GAIN(_pAd) ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
-
-#define INC_COUNTER64(Val) (Val.QuadPart++)
-
-#define INFRA_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
-#define ADHOC_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
-#define MONITOR_ON(_p) (((_p)->StaCfg.BssType) == BSS_MONITOR)
-#define IDLE_ON(_p) (!INFRA_ON(_p) && !ADHOC_ON(_p))
-
-// Check LEAP & CCKM flags
-#define LEAP_ON(_p) (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
-#define LEAP_CCKM_ON(_p) ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
-
-// if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \
-{ \
- if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) \
- { \
- _pExtraLlcSnapEncap = SNAP_802_1H; \
- if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \
- NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) \
- { \
- _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
- } \
- } \
- else \
- { \
- _pExtraLlcSnapEncap = NULL; \
- } \
-}
-
-// New Define for new Tx Path.
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \
-{ \
- if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) \
- { \
- _pExtraLlcSnapEncap = SNAP_802_1H; \
- if (NdisEqualMemory(IPX, _pBufVA, 2) || \
- NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) \
- { \
- _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
- } \
- } \
- else \
- { \
- _pExtraLlcSnapEncap = NULL; \
- } \
-}
-
-
-#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \
-{ \
- NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN); \
- NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN); \
- NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
-}
-
-// if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way.
-// else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field
-// else remove the LLC/SNAP field from the result Ethernet frame
-// Patch for WHQL only, which did not turn on Netbios but use IPX within its payload
-// Note:
-// _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO
-// _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed
-#define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \
-{ \
- char LLC_Len[2]; \
- \
- _pRemovedLLCSNAP = NULL; \
- if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \
- NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) \
- { \
- PUCHAR pProto = _pData + 6; \
- \
- if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
- NdisEqualMemory(SNAP_802_1H, _pData, 6)) \
- { \
- LLC_Len[0] = (UCHAR)(_DataSize / 256); \
- LLC_Len[1] = (UCHAR)(_DataSize % 256); \
- MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
- } \
- else \
- { \
- MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \
- _pRemovedLLCSNAP = _pData; \
- _DataSize -= LENGTH_802_1_H; \
- _pData += LENGTH_802_1_H; \
- } \
- } \
- else \
- { \
- LLC_Len[0] = (UCHAR)(_DataSize / 256); \
- LLC_Len[1] = (UCHAR)(_DataSize % 256); \
- MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
- } \
-}
-
-#define SWITCH_AB( _pAA, _pBB) \
-{ \
- PVOID pCC; \
- pCC = _pBB; \
- _pBB = _pAA; \
- _pAA = pCC; \
-}
-
-// Enqueue this frame to MLME engine
-// We need to enqueue the whole frame because MLME need to pass data type
-// information from 802.11 header
-#ifdef RT2870
-#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
-{ \
- UINT32 High32TSF=0, Low32TSF=0; \
- MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
-}
-#endif // RT2870 //
-
-#ifdef RT30xx
-//Need to collect each ant's rssi concurrently
-//rssi1 is report to pair2 Ant and rss2 is reprot to pair1 Ant when 4 Ant
-#define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _rssi1, _rssi2) \
-{ \
- SHORT AvgRssi; \
- UCHAR UsedAnt; \
- if (_pAd->RxAnt.EvaluatePeriod == 0) \
- { \
- UsedAnt = _pAd->RxAnt.Pair1PrimaryRxAnt; \
- AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \
- if (AvgRssi < 0) \
- AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \
- else \
- AvgRssi = _rssi1 << 3; \
- _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \
- } \
- else \
- { \
- UsedAnt = _pAd->RxAnt.Pair1SecondaryRxAnt; \
- AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \
- if ((AvgRssi < 0) && (_pAd->RxAnt.FirstPktArrivedWhenEvaluate)) \
- AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \
- else \
- { \
- _pAd->RxAnt.FirstPktArrivedWhenEvaluate = TRUE; \
- AvgRssi = _rssi1 << 3; \
- } \
- _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \
- _pAd->RxAnt.RcvPktNumWhenEvaluate++; \
- } \
-}
-#endif // RT30xx //
-
-
-#define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \
- NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen)
-
-#define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN)
-#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
-
-//
-// Check if it is Japan W53(ch52,56,60,64) channel.
-//
-#define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
-
-#ifdef CONFIG_STA_SUPPORT
-#define STA_PORT_SECURED(_pAd) \
-{ \
- _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
- NdisAcquireSpinLock(&_pAd->MacTabLock); \
- _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
- NdisReleaseSpinLock(&_pAd->MacTabLock); \
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-//
-// Register set pair for initialzation register set definition
-//
-typedef struct _RTMP_REG_PAIR
-{
- ULONG Register;
- ULONG Value;
-} RTMP_REG_PAIR, *PRTMP_REG_PAIR;
-
-typedef struct _REG_PAIR
-{
- UCHAR Register;
- UCHAR Value;
-} REG_PAIR, *PREG_PAIR;
-
-//
-// Register set pair for initialzation register set definition
-//
-typedef struct _RTMP_RF_REGS
-{
- UCHAR Channel;
- ULONG R1;
- ULONG R2;
- ULONG R3;
- ULONG R4;
-} RTMP_RF_REGS, *PRTMP_RF_REGS;
-
-typedef struct _FREQUENCY_ITEM {
- UCHAR Channel;
- UCHAR N;
- UCHAR R;
- UCHAR K;
-} FREQUENCY_ITEM, *PFREQUENCY_ITEM;
-
-//
-// Data buffer for DMA operation, the buffer must be contiguous physical memory
-// Both DMA to / from CPU use the same structure.
-//
-typedef struct _RTMP_DMABUF
-{
- ULONG AllocSize;
- PVOID AllocVa; // TxBuf virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address
-} RTMP_DMABUF, *PRTMP_DMABUF;
-
-
-typedef union _HEADER_802_11_SEQ{
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT Sequence:12;
- USHORT Frag:4;
- } field;
-#else
- struct {
- USHORT Frag:4;
- USHORT Sequence:12;
- } field;
-#endif
- USHORT value;
-} HEADER_802_11_SEQ, *PHEADER_802_11_SEQ;
-
-//
-// Data buffer for DMA operation, the buffer must be contiguous physical memory
-// Both DMA to / from CPU use the same structure.
-//
-typedef struct _RTMP_REORDERBUF
-{
- BOOLEAN IsFull;
- PVOID AllocVa; // TxBuf virtual address
- UCHAR Header802_3[14];
- HEADER_802_11_SEQ Sequence; //support compressed bitmap BA, so no consider fragment in BA
- UCHAR DataOffset;
- USHORT Datasize;
- ULONG AllocSize;
-#ifdef RT2870
- PUCHAR AllocPa;
-#endif // RT2870 //
-} RTMP_REORDERBUF, *PRTMP_REORDERBUF;
-
-//
-// Control block (Descriptor) for all ring descriptor DMA operation, buffer must be
-// contiguous physical memory. NDIS_PACKET stored the binding Rx packet descriptor
-// which won't be released, driver has to wait until upper layer return the packet
-// before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair
-// to describe the packet buffer. For Tx, NDIS_PACKET stored the tx packet descriptor
-// which driver should ACK upper layer when the tx is physically done or failed.
-//
-typedef struct _RTMP_DMACB
-{
- ULONG AllocSize; // Control block size
- PVOID AllocVa; // Control block virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
- PNDIS_PACKET pNdisPacket;
- PNDIS_PACKET pNextNdisPacket;
-
- RTMP_DMABUF DmaBuf; // Associated DMA buffer structure
-} RTMP_DMACB, *PRTMP_DMACB;
-
-typedef struct _RTMP_TX_BUF
-{
- PQUEUE_ENTRY Next;
- UCHAR Index;
- ULONG AllocSize; // Control block size
- PVOID AllocVa; // Control block virtual address
- NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
-} RTMP_TXBUF, *PRTMP_TXBUF;
-
-typedef struct _RTMP_RX_BUF
-{
- BOOLEAN InUse;
- ULONG ByBaRecIndex;
- RTMP_REORDERBUF MAP_RXBuf[MAX_RX_REORDERBUF];
-} RTMP_RXBUF, *PRTMP_RXBUF;
-typedef struct _RTMP_TX_RING
-{
- RTMP_DMACB Cell[TX_RING_SIZE];
- UINT32 TxCpuIdx;
- UINT32 TxDmaIdx;
- UINT32 TxSwFreeIdx; // software next free tx index
-} RTMP_TX_RING, *PRTMP_TX_RING;
-
-typedef struct _RTMP_RX_RING
-{
- RTMP_DMACB Cell[RX_RING_SIZE];
- UINT32 RxCpuIdx;
- UINT32 RxDmaIdx;
- INT32 RxSwReadIdx; // software next read index
-} RTMP_RX_RING, *PRTMP_RX_RING;
-
-typedef struct _RTMP_MGMT_RING
-{
- RTMP_DMACB Cell[MGMT_RING_SIZE];
- UINT32 TxCpuIdx;
- UINT32 TxDmaIdx;
- UINT32 TxSwFreeIdx; // software next free tx index
-} RTMP_MGMT_RING, *PRTMP_MGMT_RING;
-
-//
-// Statistic counter structure
-//
-typedef struct _COUNTER_802_3
-{
- // General Stats
- ULONG GoodTransmits;
- ULONG GoodReceives;
- ULONG TxErrors;
- ULONG RxErrors;
- ULONG RxNoBuffer;
-
- // Ethernet Stats
- ULONG RcvAlignmentErrors;
- ULONG OneCollision;
- ULONG MoreCollisions;
-
-} COUNTER_802_3, *PCOUNTER_802_3;
-
-typedef struct _COUNTER_802_11 {
- ULONG Length;
- LARGE_INTEGER LastTransmittedFragmentCount;
- LARGE_INTEGER TransmittedFragmentCount;
- LARGE_INTEGER MulticastTransmittedFrameCount;
- LARGE_INTEGER FailedCount;
- LARGE_INTEGER RetryCount;
- LARGE_INTEGER MultipleRetryCount;
- LARGE_INTEGER RTSSuccessCount;
- LARGE_INTEGER RTSFailureCount;
- LARGE_INTEGER ACKFailureCount;
- LARGE_INTEGER FrameDuplicateCount;
- LARGE_INTEGER ReceivedFragmentCount;
- LARGE_INTEGER MulticastReceivedFrameCount;
- LARGE_INTEGER FCSErrorCount;
-} COUNTER_802_11, *PCOUNTER_802_11;
-
-typedef struct _COUNTER_RALINK {
- ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput
- ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput
- ULONG BeenDisassociatedCount;
- ULONG BadCQIAutoRecoveryCount;
- ULONG PoorCQIRoamingCount;
- ULONG MgmtRingFullCount;
- ULONG RxCountSinceLastNULL;
- ULONG RxCount;
- ULONG RxRingErrCount;
- ULONG KickTxCount;
- ULONG TxRingErrCount;
- LARGE_INTEGER RealFcsErrCount;
- ULONG PendingNdisPacketCount;
-
- ULONG OneSecOsTxCount[NUM_OF_TX_RING];
- ULONG OneSecDmaDoneCount[NUM_OF_TX_RING];
- UINT32 OneSecTxDoneCount;
- ULONG OneSecRxCount;
- UINT32 OneSecTxAggregationCount;
- UINT32 OneSecRxAggregationCount;
-
- UINT32 OneSecFrameDuplicateCount;
-
-#ifdef RT2870
- ULONG OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput
-#endif // RT2870 //
-
- UINT32 OneSecTxNoRetryOkCount;
- UINT32 OneSecTxRetryOkCount;
- UINT32 OneSecTxFailCount;
- UINT32 OneSecFalseCCACnt; // CCA error count, for debug purpose, might move to global counter
- UINT32 OneSecRxOkCnt; // RX without error
- UINT32 OneSecRxOkDataCnt; // unicast-to-me DATA frame count
- UINT32 OneSecRxFcsErrCnt; // CRC error
- UINT32 OneSecBeaconSentCnt;
- UINT32 LastOneSecTotalTxCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
- UINT32 LastOneSecRxOkDataCnt; // OneSecRxOkDataCnt
- ULONG DuplicateRcv;
- ULONG TxAggCount;
- ULONG TxNonAggCount;
- ULONG TxAgg1MPDUCount;
- ULONG TxAgg2MPDUCount;
- ULONG TxAgg3MPDUCount;
- ULONG TxAgg4MPDUCount;
- ULONG TxAgg5MPDUCount;
- ULONG TxAgg6MPDUCount;
- ULONG TxAgg7MPDUCount;
- ULONG TxAgg8MPDUCount;
- ULONG TxAgg9MPDUCount;
- ULONG TxAgg10MPDUCount;
- ULONG TxAgg11MPDUCount;
- ULONG TxAgg12MPDUCount;
- ULONG TxAgg13MPDUCount;
- ULONG TxAgg14MPDUCount;
- ULONG TxAgg15MPDUCount;
- ULONG TxAgg16MPDUCount;
-
- LARGE_INTEGER TransmittedOctetsInAMSDU;
- LARGE_INTEGER TransmittedAMSDUCount;
- LARGE_INTEGER ReceivedOctesInAMSDUCount;
- LARGE_INTEGER ReceivedAMSDUCount;
- LARGE_INTEGER TransmittedAMPDUCount;
- LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
- LARGE_INTEGER TransmittedOctetsInAMPDUCount;
- LARGE_INTEGER MPDUInReceivedAMPDUCount;
-} COUNTER_RALINK, *PCOUNTER_RALINK;
-
-typedef struct _PID_COUNTER {
- ULONG TxAckRequiredCount; // CRC error
- ULONG TxAggreCount;
- ULONG TxSuccessCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
- ULONG LastSuccessRate;
-} PID_COUNTER, *PPID_COUNTER;
-
-typedef struct _COUNTER_DRS {
- // to record the each TX rate's quality. 0 is best, the bigger the worse.
- USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
- UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
- ULONG CurrTxRateStableTime; // # of second in current TX rate
- BOOLEAN fNoisyEnvironment;
- BOOLEAN fLastSecAccordingRSSI;
- UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
- UCHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
- ULONG LastTxOkCount;
-} COUNTER_DRS, *PCOUNTER_DRS;
-
-//
-// Arcfour Structure Added by PaulWu
-//
-typedef struct _ARCFOUR
-{
- UINT X;
- UINT Y;
- UCHAR STATE[256];
-} ARCFOURCONTEXT, *PARCFOURCONTEXT;
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI too. just copy to TXWI.
-typedef struct _RECEIVE_SETTING {
-#ifdef RT_BIG_ENDIAN
- USHORT MIMO:1;
- USHORT OFDM:1;
- USHORT rsv:3;
- USHORT STBC:2; //SPACE
- USHORT ShortGI:1;
- USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
- USHORT NumOfRX:2; // MIMO. WE HAVE 3R
-#else
- USHORT NumOfRX:2; // MIMO. WE HAVE 3R
- USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
- USHORT ShortGI:1;
- USHORT STBC:2; //SPACE
- USHORT rsv:3;
- USHORT OFDM:1;
- USHORT MIMO:1;
-#endif
- } RECEIVE_SETTING, *PRECEIVE_SETTING;
-
-// Shared key data structure
-typedef struct _WEP_KEY {
- UCHAR KeyLen; // Key length for each key, 0: entry is invalid
- UCHAR Key[MAX_LEN_OF_KEY]; // right now we implement 4 keys, 128 bits max
-} WEP_KEY, *PWEP_KEY;
-
-typedef struct _CIPHER_KEY {
- UCHAR Key[16]; // right now we implement 4 keys, 128 bits max
- UCHAR RxMic[8]; // make alignment
- UCHAR TxMic[8];
- UCHAR TxTsc[6]; // 48bit TSC value
- UCHAR RxTsc[6]; // 48bit TSC value
- UCHAR CipherAlg; // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
- UCHAR KeyLen;
-#ifdef CONFIG_STA_SUPPORT
- UCHAR BssId[6];
-#endif // CONFIG_STA_SUPPORT //
- // Key length for each key, 0: entry is invalid
- UCHAR Type; // Indicate Pairwise/Group when reporting MIC error
-} CIPHER_KEY, *PCIPHER_KEY;
-
-typedef struct _BBP_TUNING_STRUCT {
- BOOLEAN Enable;
- UCHAR FalseCcaCountUpperBound; // 100 per sec
- UCHAR FalseCcaCountLowerBound; // 10 per sec
- UCHAR R17LowerBound; // specified in E2PROM
- UCHAR R17UpperBound; // 0x68 according to David Tung
- UCHAR CurrentR17Value;
-} BBP_TUNING, *PBBP_TUNING;
-
-typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
- UCHAR EvaluatePeriod; // 0:not evalute status, 1: evaluate status, 2: switching status
- UCHAR EvaluateStableCnt;
- UCHAR Pair1PrimaryRxAnt; // 0:Ant-E1, 1:Ant-E2
- UCHAR Pair1SecondaryRxAnt; // 0:Ant-E1, 1:Ant-E2
- UCHAR Pair2PrimaryRxAnt; // 0:Ant-E3, 1:Ant-E4
- UCHAR Pair2SecondaryRxAnt; // 0:Ant-E3, 1:Ant-E4
- SHORT Pair1AvgRssi[2]; // AvgRssi[0]:E1, AvgRssi[1]:E2
- SHORT Pair2AvgRssi[2]; // AvgRssi[0]:E3, AvgRssi[1]:E4
- SHORT Pair1LastAvgRssi; //
- SHORT Pair2LastAvgRssi; //
- ULONG RcvPktNumWhenEvaluate;
- BOOLEAN FirstPktArrivedWhenEvaluate;
- RALINK_TIMER_STRUCT RxAntDiversityTimer;
-} SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY;
-
-typedef struct _LEAP_AUTH_INFO {
- BOOLEAN Enabled; //Ture: Enable LEAP Authentication
- BOOLEAN CCKM; //Ture: Use Fast Reauthentication with CCKM
- UCHAR Reserve[2];
- UCHAR UserName[256]; //LEAP, User name
- ULONG UserNameLen;
- UCHAR Password[256]; //LEAP, User Password
- ULONG PasswordLen;
-} LEAP_AUTH_INFO, *PLEAP_AUTH_INFO;
-
-typedef struct {
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR ErrorCode[2]; //00 01-Invalid authentication type
- //00 02-Authentication timeout
- //00 03-Challenge from AP failed
- //00 04-Challenge to AP failed
- BOOLEAN Reported;
-} ROGUEAP_ENTRY, *PROGUEAP_ENTRY;
-
-typedef struct {
- UCHAR RogueApNr;
- ROGUEAP_ENTRY RogueApEntry[MAX_LEN_OF_BSS_TABLE];
-} ROGUEAP_TABLE, *PROGUEAP_TABLE;
-
-typedef struct {
- BOOLEAN Enable;
- UCHAR Delta;
- BOOLEAN PlusSign;
-} CCK_TX_POWER_CALIBRATE, *PCCK_TX_POWER_CALIBRATE;
-
-//
-// Receive Tuple Cache Format
-//
-typedef struct _TUPLE_CACHE {
- BOOLEAN Valid;
- UCHAR MacAddress[MAC_ADDR_LEN];
- USHORT Sequence;
- USHORT Frag;
-} TUPLE_CACHE, *PTUPLE_CACHE;
-
-//
-// Fragment Frame structure
-//
-typedef struct _FRAGMENT_FRAME {
- PNDIS_PACKET pFragPacket;
- ULONG RxSize;
- USHORT Sequence;
- USHORT LastFrag;
- ULONG Flags; // Some extra frame information. bit 0: LLC presented
-} FRAGMENT_FRAME, *PFRAGMENT_FRAME;
-
-
-//
-// Packet information for NdisQueryPacket
-//
-typedef struct _PACKET_INFO {
- UINT PhysicalBufferCount; // Physical breaks of buffer descripor chained
- UINT BufferCount ; // Number of Buffer descriptor chained
- UINT TotalPacketLength ; // Self explained
- PNDIS_BUFFER pFirstBuffer; // Pointer to first buffer descriptor
-} PACKET_INFO, *PPACKET_INFO;
-
-//
-// Tkip Key structure which RC4 key & MIC calculation
-//
-typedef struct _TKIP_KEY_INFO {
- UINT nBytesInM; // # bytes in M for MICKEY
- ULONG IV16;
- ULONG IV32;
- ULONG K0; // for MICKEY Low
- ULONG K1; // for MICKEY Hig
- ULONG L; // Current state for MICKEY
- ULONG R; // Current state for MICKEY
- ULONG M; // Message accumulator for MICKEY
- UCHAR RC4KEY[16];
- UCHAR MIC[8];
-} TKIP_KEY_INFO, *PTKIP_KEY_INFO;
-
-//
-// Private / Misc data, counters for driver internal use
-//
-typedef struct __PRIVATE_STRUC {
- UINT SystemResetCnt; // System reset counter
- UINT TxRingFullCnt; // Tx ring full occurrance number
- UINT PhyRxErrCnt; // PHY Rx error count, for debug purpose, might move to global counter
- // Variables for WEP encryption / decryption in rtmp_wep.c
- UINT FCSCRC32;
- ARCFOURCONTEXT WEPCONTEXT;
- // Tkip stuff
- TKIP_KEY_INFO Tx;
- TKIP_KEY_INFO Rx;
-} PRIVATE_STRUC, *PPRIVATE_STRUC;
-
-// structure to tune BBP R66 (BBP TUNING)
-typedef struct _BBP_R66_TUNING {
- BOOLEAN bEnable;
- USHORT FalseCcaLowerThreshold; // default 100
- USHORT FalseCcaUpperThreshold; // default 512
- UCHAR R66Delta;
- UCHAR R66CurrentValue;
- BOOLEAN R66LowerUpperSelect; //Before LinkUp, Used LowerBound or UpperBound as R66 value.
-} BBP_R66_TUNING, *PBBP_R66_TUNING;
-
-// structure to store channel TX power
-typedef struct _CHANNEL_TX_POWER {
- USHORT RemainingTimeForUse; //unit: sec
- UCHAR Channel;
-#ifdef DOT11N_DRAFT3
- BOOLEAN bEffectedChannel; // For BW 40 operating in 2.4GHz , the "effected channel" is the channel that is covered in 40Mhz.
-#endif // DOT11N_DRAFT3 //
- CHAR Power;
- CHAR Power2;
- UCHAR MaxTxPwr;
- UCHAR DfsReq;
-} CHANNEL_TX_POWER, *PCHANNEL_TX_POWER;
-
-// structure to store 802.11j channel TX power
-typedef struct _CHANNEL_11J_TX_POWER {
- UCHAR Channel;
- UCHAR BW; // BW_10 or BW_20
- CHAR Power;
- CHAR Power2;
- USHORT RemainingTimeForUse; //unit: sec
-} CHANNEL_11J_TX_POWER, *PCHANNEL_11J_TX_POWER;
-
-typedef enum _ABGBAND_STATE_ {
- UNKNOWN_BAND,
- BG_BAND,
- A_BAND,
-} ABGBAND_STATE;
-
-typedef struct _MLME_STRUCT {
-#ifdef CONFIG_STA_SUPPORT
- // STA state machines
- STATE_MACHINE CntlMachine;
- STATE_MACHINE AssocMachine;
- STATE_MACHINE AuthMachine;
- STATE_MACHINE AuthRspMachine;
- STATE_MACHINE SyncMachine;
- STATE_MACHINE WpaPskMachine;
- STATE_MACHINE LeapMachine;
- STATE_MACHINE AironetMachine;
- STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
- STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
- STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
- STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
- STATE_MACHINE_FUNC WpaPskFunc[WPA_PSK_FUNC_SIZE];
- STATE_MACHINE_FUNC AironetFunc[AIRONET_FUNC_SIZE];
-#endif // CONFIG_STA_SUPPORT //
- STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
- // Action
- STATE_MACHINE ActMachine;
-
-
-#ifdef QOS_DLS_SUPPORT
- STATE_MACHINE DlsMachine;
- STATE_MACHINE_FUNC DlsFunc[DLS_FUNC_SIZE];
-#endif // QOS_DLS_SUPPORT //
-
-
-
-
- ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
- ULONG Now32; // latch the value of NdisGetSystemUpTime()
- ULONG LastSendNULLpsmTime;
-
- BOOLEAN bRunning;
- NDIS_SPIN_LOCK TaskLock;
- MLME_QUEUE Queue;
-
- UINT ShiftReg;
-
- RALINK_TIMER_STRUCT PeriodicTimer;
- RALINK_TIMER_STRUCT APSDPeriodicTimer;
- RALINK_TIMER_STRUCT LinkDownTimer;
- RALINK_TIMER_STRUCT LinkUpTimer;
- ULONG PeriodicRound;
- ULONG OneSecPeriodicRound;
-
- UCHAR RealRxPath;
- BOOLEAN bLowThroughput;
- BOOLEAN bEnableAutoAntennaCheck;
- RALINK_TIMER_STRUCT RxAntEvalTimer;
-
-#ifdef RT30xx
- UCHAR CaliBW40RfR24;
- UCHAR CaliBW20RfR24;
-#endif // RT30xx //
-
-} MLME_STRUCT, *PMLME_STRUCT;
-
-// structure for radar detection and channel switch
-typedef struct _RADAR_DETECT_STRUCT {
- //BOOLEAN IEEE80211H; // 0: disable, 1: enable IEEE802.11h
- UCHAR CSCount; //Channel switch counter
- UCHAR CSPeriod; //Channel switch period (beacon count)
- UCHAR RDCount; //Radar detection counter
- UCHAR RDMode; //Radar Detection mode
- UCHAR RDDurRegion; //Radar detection duration region
- UCHAR BBPR16;
- UCHAR BBPR17;
- UCHAR BBPR18;
- UCHAR BBPR21;
- UCHAR BBPR22;
- UCHAR BBPR64;
- ULONG InServiceMonitorCount; // unit: sec
- UINT8 DfsSessionTime;
- BOOLEAN bFastDfs;
- UINT8 ChMovingTime;
- UINT8 LongPulseRadarTh;
-} RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
-
-#ifdef CARRIER_DETECTION_SUPPORT
-typedef enum CD_STATE_n
-{
- CD_NORMAL,
- CD_SILENCE,
- CD_MAX_STATE
-} CD_STATE;
-
-typedef struct CARRIER_DETECTION_s
-{
- BOOLEAN Enable;
- UINT8 CDSessionTime;
- UINT8 CDPeriod;
- CD_STATE CD_State;
-} CARRIER_DETECTION, *PCARRIER_DETECTION;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-typedef enum _REC_BLOCKACK_STATUS
-{
- Recipient_NONE=0,
- Recipient_USED,
- Recipient_HandleRes,
- Recipient_Accept
-} REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
-
-typedef enum _ORI_BLOCKACK_STATUS
-{
- Originator_NONE=0,
- Originator_USED,
- Originator_WaitRes,
- Originator_Done
-} ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
-
-#ifdef DOT11_N_SUPPORT
-typedef struct _BA_ORI_ENTRY{
- UCHAR Wcid;
- UCHAR TID;
- UCHAR BAWinSize;
- UCHAR Token;
-// Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header.
- USHORT Sequence;
- USHORT TimeOutValue;
- ORI_BLOCKACK_STATUS ORI_BA_Status;
- RALINK_TIMER_STRUCT ORIBATimer;
- PVOID pAdapter;
-} BA_ORI_ENTRY, *PBA_ORI_ENTRY;
-
-typedef struct _BA_REC_ENTRY {
- UCHAR Wcid;
- UCHAR TID;
- UCHAR BAWinSize; // 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU.
- //UCHAR NumOfRxPkt;
- //UCHAR Curindidx; // the head in the RX reordering buffer
- USHORT LastIndSeq;
-// USHORT LastIndSeqAtTimer;
- USHORT TimeOutValue;
- RALINK_TIMER_STRUCT RECBATimer;
- ULONG LastIndSeqAtTimer;
- ULONG nDropPacket;
- ULONG rcvSeq;
- REC_BLOCKACK_STATUS REC_BA_Status;
-// UCHAR RxBufIdxUsed;
- // corresponding virtual address for RX reordering packet storage.
- //RTMP_REORDERDMABUF MAP_RXBuf[MAX_RX_REORDERBUF];
- NDIS_SPIN_LOCK RxReRingLock; // Rx Ring spinlock
-// struct _BA_REC_ENTRY *pNext;
- PVOID pAdapter;
- struct reordering_list list;
-} BA_REC_ENTRY, *PBA_REC_ENTRY;
-
-
-typedef struct {
- ULONG numAsRecipient; // I am recipient of numAsRecipient clients. These client are in the BARecEntry[]
- ULONG numAsOriginator; // I am originator of numAsOriginator clients. These clients are in the BAOriEntry[]
- BA_ORI_ENTRY BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
- BA_REC_ENTRY BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
-} BA_TABLE, *PBA_TABLE;
-
-//For QureyBATableOID use;
-typedef struct PACKED _OID_BA_REC_ENTRY{
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize
- UCHAR rsv;
- UCHAR BufSize[8];
- REC_BLOCKACK_STATUS REC_BA_Status[8];
-} OID_BA_REC_ENTRY, *POID_BA_REC_ENTRY;
-
-//For QureyBATableOID use;
-typedef struct PACKED _OID_BA_ORI_ENTRY{
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status
- UCHAR rsv;
- UCHAR BufSize[8];
- ORI_BLOCKACK_STATUS ORI_BA_Status[8];
-} OID_BA_ORI_ENTRY, *POID_BA_ORI_ENTRY;
-
-typedef struct _QUERYBA_TABLE{
- OID_BA_ORI_ENTRY BAOriEntry[32];
- OID_BA_REC_ENTRY BARecEntry[32];
- UCHAR OriNum;// Number of below BAOriEntry
- UCHAR RecNum;// Number of below BARecEntry
-} QUERYBA_TABLE, *PQUERYBA_TABLE;
-
-typedef union _BACAP_STRUC {
-#ifdef RT_BIG_ENDIAN
- struct {
- UINT32 :4;
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 MpduDensity:3;
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 AutoBA:1; // automatically BA
- UINT32 TxBAWinLimit:8;
- UINT32 RxBAWinLimit:8;
- } field;
-#else
- struct {
- UINT32 RxBAWinLimit:8;
- UINT32 TxBAWinLimit:8;
- UINT32 AutoBA:1; // automatically BA
- UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
- UINT32 MpduDensity:3;
- UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
- UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
- UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
- UINT32 bHtAdhoc:1; // adhoc can use ht rate.
- UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
- UINT32 :4;
- } field;
-#endif
- UINT32 word;
-} BACAP_STRUC, *PBACAP_STRUC;
-#endif // DOT11_N_SUPPORT //
-
-//This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic)
-typedef struct _IOT_STRUC {
- UCHAR Threshold[2];
- UCHAR ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[0]
- UCHAR RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[1]
- ULONG OneSecInWindowCount;
- ULONG OneSecFrameDuplicateCount;
- ULONG OneSecOutWindowCount;
- UCHAR DelOriAct;
- UCHAR DelRecAct;
- UCHAR RTSShortProt;
- UCHAR RTSLongProt;
- BOOLEAN bRTSLongProtOn;
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN bLastAtheros;
- BOOLEAN bCurrentAtheros;
- BOOLEAN bNowAtherosBurstOn;
- BOOLEAN bNextDisableRxBA;
- BOOLEAN bToggle;
-#endif // CONFIG_STA_SUPPORT //
-} IOT_STRUC, *PIOT_STRUC;
-
-// This is the registry setting for 802.11n transmit setting. Used in advanced page.
-typedef union _REG_TRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- UINT32 rsv:13;
- UINT32 EXTCHA:2;
- UINT32 HTMODE:1;
- UINT32 TRANSNO:2;
- UINT32 STBC:1; //SPACE
- UINT32 ShortGI:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 TxBF:1; // 3*3
- UINT32 rsv0:10;
- //UINT32 MCS:7; // MCS
- //UINT32 PhyMode:4;
- } field;
-#else
- struct {
- //UINT32 PhyMode:4;
- //UINT32 MCS:7; // MCS
- UINT32 rsv0:10;
- UINT32 TxBF:1;
- UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
- UINT32 ShortGI:1;
- UINT32 STBC:1; //SPACE
- UINT32 TRANSNO:2;
- UINT32 HTMODE:1;
- UINT32 EXTCHA:2;
- UINT32 rsv:13;
- } field;
-#endif
- UINT32 word;
-} REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
-
-typedef union _DESIRED_TRANSMIT_SETTING {
-#ifdef RT_BIG_ENDIAN
- struct {
- USHORT rsv:3;
- USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
- USHORT PhyMode:4;
- USHORT MCS:7; // MCS
- } field;
-#else
- struct {
- USHORT MCS:7; // MCS
- USHORT PhyMode:4;
- USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
- USHORT rsv:3;
- } field;
-#endif
- USHORT word;
- } DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
-
-typedef struct {
- BOOLEAN IsRecipient;
- UCHAR MACAddr[MAC_ADDR_LEN];
- UCHAR TID;
- UCHAR nMSDU;
- USHORT TimeOut;
- BOOLEAN bAllTid; // If True, delete all TID for BA sessions with this MACaddr.
-} OID_ADD_BA_ENTRY, *POID_ADD_BA_ENTRY;
-
-//
-// Multiple SSID structure
-//
-#define WLAN_MAX_NUM_OF_TIM ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
-#define WLAN_CT_TIM_BCMC_OFFSET 0 /* unit: 32B */
-
-/* clear bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
- pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
-
-/* set bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_SET(apidx) \
- pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
-
-/* clear a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
- { UCHAR tim_offset = wcid >> 3; \
- UCHAR bit_offset = wcid & 0x7; \
- ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
-
-/* set a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
- { UCHAR tim_offset = wcid >> 3; \
- UCHAR bit_offset = wcid & 0x7; \
- ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
-
-#ifdef RT2870
-#define BEACON_BITMAP_MASK 0xff
-typedef struct _BEACON_SYNC_STRUCT_
-{
- UCHAR BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
- UCHAR BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
- ULONG TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
- ULONG CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
- BOOLEAN EnableBeacon; // trigger to enable beacon transmission.
- UCHAR BeaconBitMap; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
- UCHAR DtimBitOn; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
-}BEACON_SYNC_STRUCT;
-#endif // RT2870 //
-
-typedef struct _MULTISSID_STRUCT {
- UCHAR Bssid[MAC_ADDR_LEN];
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
- USHORT CapabilityInfo;
-
- PNET_DEV MSSIDDev;
-
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
- WPA_MIX_PAIR_CIPHER WpaMixPairCipher;
-
- ULONG TxCount;
- ULONG RxCount;
- ULONG ReceivedByteCount;
- ULONG TransmittedByteCount;
- ULONG RxErrorCount;
- ULONG RxDropCount;
-
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting. this is for reading registry setting only. not useful.
- BOOLEAN bAutoTxRateSwitch;
-
- //CIPHER_KEY SharedKey[SHARE_KEY_NUM]; // ref pAd->SharedKey[BSS][4]
- UCHAR DefaultKeyId;
-
- UCHAR TxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11, ...
- UCHAR DesiredRates[MAX_LEN_OF_SUPPORTED_RATES];// OID_802_11_DESIRED_RATES
- UCHAR DesiredRatesIndex;
- UCHAR MaxTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
-
-// ULONG TimBitmap; // bit0 for broadcast, 1 for AID1, 2 for AID2, ...so on
-// ULONG TimBitmap2; // b0 for AID32, b1 for AID33, ... and so on
- UCHAR TimBitmaps[WLAN_MAX_NUM_OF_TIM];
-
- // WPA
- UCHAR GMK[32];
- UCHAR PMK[32];
- UCHAR GTK[32];
- BOOLEAN IEEE8021X;
- BOOLEAN PreAuth;
- UCHAR GNonce[32];
- UCHAR PortSecured;
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter;
- UCHAR BANClass3Data;
- ULONG IsolateInterStaTraffic;
-
- UCHAR RSNIE_Len[2];
- UCHAR RSN_IE[2][MAX_LEN_OF_RSNIE];
-
-
- UCHAR TimIELocationInBeacon;
- UCHAR CapabilityInfoLocationInBeacon;
- // outgoing BEACON frame buffer and corresponding TXWI
- // PTXWI_STRUC BeaconTxWI; //
- CHAR BeaconBuf[MAX_BEACON_SIZE]; // NOTE: BeaconBuf should be 4-byte aligned
-
- BOOLEAN bHideSsid;
- UINT16 StationKeepAliveTime; // unit: second
-
- USHORT VLAN_VID;
- USHORT VLAN_Priority;
-
- RT_802_11_ACL AccessControlList;
-
- // EDCA Qos
- BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
- BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
-
- UCHAR DlsPTK[64]; // Due to windows dirver count on meetinghouse to handle 4-way shake
-
- // For 802.1x daemon setting per BSS
- UCHAR radius_srv_num;
- RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
-
-#ifdef RTL865X_SOC
- unsigned int mylinkid;
-#endif
-
-
- UINT32 RcvdConflictSsidCount;
- UINT32 RcvdSpoofedAssocRespCount;
- UINT32 RcvdSpoofedReassocRespCount;
- UINT32 RcvdSpoofedProbeRespCount;
- UINT32 RcvdSpoofedBeaconCount;
- UINT32 RcvdSpoofedDisassocCount;
- UINT32 RcvdSpoofedAuthCount;
- UINT32 RcvdSpoofedDeauthCount;
- UINT32 RcvdSpoofedUnknownMgmtCount;
- UINT32 RcvdReplayAttackCount;
-
- CHAR RssiOfRcvdConflictSsid;
- CHAR RssiOfRcvdSpoofedAssocResp;
- CHAR RssiOfRcvdSpoofedReassocResp;
- CHAR RssiOfRcvdSpoofedProbeResp;
- CHAR RssiOfRcvdSpoofedBeacon;
- CHAR RssiOfRcvdSpoofedDisassoc;
- CHAR RssiOfRcvdSpoofedAuth;
- CHAR RssiOfRcvdSpoofedDeauth;
- CHAR RssiOfRcvdSpoofedUnknownMgmt;
- CHAR RssiOfRcvdReplayAttack;
-
- BOOLEAN bBcnSntReq;
- UCHAR BcnBufIdx;
-} MULTISSID_STRUCT, *PMULTISSID_STRUCT;
-
-
-
-#ifdef DOT11N_DRAFT3
-typedef enum _BSS2040COEXIST_FLAG{
- BSS_2040_COEXIST_DISABLE = 0,
- BSS_2040_COEXIST_TIMER_FIRED = 1,
- BSS_2040_COEXIST_INFO_SYNC = 2,
- BSS_2040_COEXIST_INFO_NOTIFY = 4,
-}BSS2040COEXIST_FLAG;
-#endif // DOT11N_DRAFT3 //
-
-// configuration common to OPMODE_AP as well as OPMODE_STA
-typedef struct _COMMON_CONFIG {
-
- BOOLEAN bCountryFlag;
- UCHAR CountryCode[3];
- UCHAR Geography;
- UCHAR CountryRegion; // Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel
- UCHAR CountryRegionForABand; // Enum of country region for A band
- UCHAR PhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED
- USHORT Dsifs; // in units of usec
- ULONG PacketFilter; // Packet filter for receiving
-
- CHAR Ssid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
- UCHAR SsidLen; // the actual ssid length in used
- UCHAR LastSsidLen; // the actual ssid length in used
- CHAR LastSsid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
- UCHAR LastBssid[MAC_ADDR_LEN];
-
- UCHAR Bssid[MAC_ADDR_LEN];
- USHORT BeaconPeriod;
- UCHAR Channel;
- UCHAR CentralChannel; // Central Channel when using 40MHz is indicating. not real channel.
-
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen;
- UCHAR DesireRate[MAX_LEN_OF_SUPPORTED_RATES]; // OID_802_11_DESIRED_RATES
- UCHAR MaxDesiredRate;
- UCHAR ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
-
- ULONG BasicRateBitmap; // backup basic ratebitmap
-
- BOOLEAN bAPSDCapable;
- BOOLEAN bInServicePeriod;
- BOOLEAN bAPSDAC_BE;
- BOOLEAN bAPSDAC_BK;
- BOOLEAN bAPSDAC_VI;
- BOOLEAN bAPSDAC_VO;
- BOOLEAN bNeedSendTriggerFrame;
- BOOLEAN bAPSDForcePowerSave; // Force power save mode, should only use in APSD-STAUT
- ULONG TriggerTimerCount;
- UCHAR MaxSPLength;
- UCHAR BBPCurrentBW; // BW_10, BW_20, BW_40
- // move to MULTISSID_STRUCT for MBSS
- //HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
- REG_TRANSMIT_SETTING RegTransmitSetting; //registry transmit setting. this is for reading registry setting only. not useful.
- //UCHAR FixedTxMode; // Fixed Tx Mode (CCK, OFDM), for HT fixed tx mode (GF, MIX) , refer to RegTransmitSetting.field.HTMode
- UCHAR TxRate; // Same value to fill in TXD. TxRate is 6-bit
- UCHAR MaxTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
- UCHAR TxRateIndex; // Tx rate index in RateSwitchTable
- UCHAR TxRateTableSize; // Valid Tx rate table size in RateSwitchTable
- //BOOLEAN bAutoTxRateSwitch;
- UCHAR MinTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
- UCHAR RtsRate; // RATE_xxx
- HTTRANSMIT_SETTING MlmeTransmit; // MGMT frame PHY rate setting when operatin at Ht rate.
- UCHAR MlmeRate; // RATE_xxx, used to send MLME frames
- UCHAR BasicMlmeRate; // Default Rate for sending MLME frames
-
- USHORT RtsThreshold; // in unit of BYTE
- USHORT FragmentThreshold; // in unit of BYTE
-
- UCHAR TxPower; // in unit of mW
- ULONG TxPowerPercentage; // 0~100 %
- ULONG TxPowerDefault; // keep for TxPowerPercentage
-
-#ifdef DOT11_N_SUPPORT
- BACAP_STRUC BACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
- BACAP_STRUC REGBACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
-#endif // DOT11_N_SUPPORT //
- IOT_STRUC IOTestParm; // 802.11n InterOpbility Test Parameter;
- ULONG TxPreamble; // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto
- BOOLEAN bUseZeroToDisableFragment; // Microsoft use 0 as disable
- ULONG UseBGProtection; // 0: auto, 1: always use, 2: always not use
- BOOLEAN bUseShortSlotTime; // 0: disable, 1 - use short slot (9us)
- BOOLEAN bEnableTxBurst; // 1: enble TX PACKET BURST, 0: disable TX PACKET BURST
- BOOLEAN bAggregationCapable; // 1: enable TX aggregation when the peer supports it
- BOOLEAN bPiggyBackCapable; // 1: enable TX piggy-back according MAC's version
- BOOLEAN bIEEE80211H; // 1: enable IEEE802.11h spec.
- ULONG DisableOLBCDetect; // 0: enable OLBC detect; 1 disable OLBC detect
-
-#ifdef DOT11_N_SUPPORT
- BOOLEAN bRdg;
-#endif // DOT11_N_SUPPORT //
- BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
- QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
- EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
- QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
- UCHAR AckPolicy[4]; // ACK policy of the specified AC. see ACK_xxx
-#ifdef CONFIG_STA_SUPPORT
- BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
-#endif // CONFIG_STA_SUPPORT //
- // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
- // BOOLEAN control, either ON or OFF. These flags should always be accessed via
- // OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros.
- // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition
- ULONG OpStatusFlags;
-
- BOOLEAN NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.
- ABGBAND_STATE BandState; // For setting BBP used on B/G or A mode.
- BOOLEAN bRxAntDiversity; // 0:disable, 1:enable Software Rx Antenna Diversity.
-
- // IEEE802.11H--DFS.
- RADAR_DETECT_STRUCT RadarDetect;
-
-#ifdef CARRIER_DETECTION_SUPPORT
- CARRIER_DETECTION CarrierDetect;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- // HT
- UCHAR BASize; // USer desired BAWindowSize. Should not exceed our max capability
- //RT_HT_CAPABILITY SupportedHtPhy;
- RT_HT_CAPABILITY DesiredHtPhy;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHTInfo; // Useful as AP.
- //This IE is used with channel switch announcement element when changing to a new 40MHz.
- //This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp.
- NEW_EXT_CHAN_IE NewExtChanOffset; //7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present
-
-#ifdef DOT11N_DRAFT3
- UCHAR Bss2040CoexistFlag; // bit 0: bBssCoexistTimerRunning, bit 1: NeedSyncAddHtInfo.
- RALINK_TIMER_STRUCT Bss2040CoexistTimer;
-
- //This IE is used for 20/40 BSS Coexistence.
- BSS_2040_COEXIST_IE BSS2040CoexistInfo;
- // ====== 11n D3.0 =======================>
- USHORT Dot11OBssScanPassiveDwell; // Unit : TU. 5~1000
- USHORT Dot11OBssScanActiveDwell; // Unit : TU. 10~1000
- USHORT Dot11BssWidthTriggerScanInt; // Unit : Second
- USHORT Dot11OBssScanPassiveTotalPerChannel; // Unit : TU. 200~10000
- USHORT Dot11OBssScanActiveTotalPerChannel; // Unit : TU. 20~10000
- USHORT Dot11BssWidthChanTranDelayFactor;
- USHORT Dot11OBssScanActivityThre; // Unit : percentage
-
- ULONG Dot11BssWidthChanTranDelay; // multiple of (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
- ULONG CountDownCtr; // CountDown Counter from (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
-
- NDIS_SPIN_LOCK TriggerEventTabLock;
- BSS_2040_COEXIST_IE LastBSSCoexist2040;
- BSS_2040_COEXIST_IE BSSCoexist2040;
- TRIGGER_EVENT_TAB TriggerEventTab;
- UCHAR ChannelListIdx;
- // <====== 11n D3.0 =======================
- BOOLEAN bOverlapScanning;
-#endif // DOT11N_DRAFT3 //
-
- BOOLEAN bHTProtect;
- BOOLEAN bMIMOPSEnable;
- BOOLEAN bBADecline;
- BOOLEAN bDisableReordering;
- BOOLEAN bForty_Mhz_Intolerant;
- BOOLEAN bExtChannelSwitchAnnouncement;
- BOOLEAN bRcvBSSWidthTriggerEvents;
- ULONG LastRcvBSSWidthTriggerEventsTime;
-
- UCHAR TxBASize;
-#endif // DOT11_N_SUPPORT //
-
- // Enable wireless event
- BOOLEAN bWirelessEvent;
- BOOLEAN bWiFiTest; // Enable this parameter for WiFi test
-
- // Tx & Rx Stream number selection
- UCHAR TxStream;
- UCHAR RxStream;
-
- // transmit phy mode, trasmit rate for Multicast.
-#ifdef MCAST_RATE_SPECIFIC
- UCHAR McastTransmitMcs;
- UCHAR McastTransmitPhyMode;
-#endif // MCAST_RATE_SPECIFIC //
-
- BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
-
-#ifdef RT2870
- BOOLEAN bMultipleIRP; // Multiple Bulk IN flag
- UCHAR NumOfBulkInIRP; // if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1
- RT_HT_CAPABILITY SupportedHtPhy;
- ULONG MaxPktOneTxBulk;
- UCHAR TxBulkFactor;
- UCHAR RxBulkFactor;
-
- BEACON_SYNC_STRUCT *pBeaconSync;
- RALINK_TIMER_STRUCT BeaconUpdateTimer;
- UINT32 BeaconAdjust;
- UINT32 BeaconFactor;
- UINT32 BeaconRemain;
-#endif // RT2870 //
-
-
- NDIS_SPIN_LOCK MeasureReqTabLock;
- PMEASURE_REQ_TAB pMeasureReqTab;
-
- NDIS_SPIN_LOCK TpcReqTabLock;
- PTPC_REQ_TAB pTpcReqTab;
-
- // transmit phy mode, trasmit rate for Multicast.
-#ifdef MCAST_RATE_SPECIFIC
- HTTRANSMIT_SETTING MCastPhyMode;
-#endif // MCAST_RATE_SPECIFIC //
-
-#ifdef SINGLE_SKU
- UINT16 DefineMaxTxPwr;
-#endif // SINGLE_SKU //
-
-
-} COMMON_CONFIG, *PCOMMON_CONFIG;
-
-
-#ifdef CONFIG_STA_SUPPORT
-/* Modified by Wu Xi-Kun 4/21/2006 */
-// STA configuration and status
-typedef struct _STA_ADMIN_CONFIG {
- // GROUP 1 -
- // User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
- // the user intended configuration, but not necessary fully equal to the final
- // settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either
- // AP or IBSS holder).
- // Once initialized, user configuration can only be changed via OID_xxx
- UCHAR BssType; // BSS_INFRA or BSS_ADHOC
- USHORT AtimWin; // used when starting a new IBSS
-
- // GROUP 2 -
- // User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
- // the user intended configuration, and should be always applied to the final
- // settings in ACTIVE BSS without compromising with the BSS holder.
- // Once initialized, user configuration can only be changed via OID_xxx
- UCHAR RssiTrigger;
- UCHAR RssiTriggerMode; // RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD
- USHORT DefaultListenCount; // default listen count;
- ULONG WindowsPowerMode; // Power mode for AC power
- ULONG WindowsBatteryPowerMode; // Power mode for battery if exists
- BOOLEAN bWindowsACCAMEnable; // Enable CAM power mode when AC on
- BOOLEAN bAutoReconnect; // Set to TRUE when setting OID_802_11_SSID with no matching BSSID
- ULONG WindowsPowerProfile; // Windows power profile, for NDIS5.1 PnP
-
- // MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1)
- USHORT Psm; // power management mode (PWR_ACTIVE|PWR_SAVE)
- USHORT DisassocReason;
- UCHAR DisassocSta[MAC_ADDR_LEN];
- USHORT DeauthReason;
- UCHAR DeauthSta[MAC_ADDR_LEN];
- USHORT AuthFailReason;
- UCHAR AuthFailSta[MAC_ADDR_LEN];
-
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_WEP_STATUS OrigWepStatus; // Original wep status set from OID
-
- // Add to support different cipher suite for WPA2/WPA mode
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
- BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
- USHORT RsnCapability;
-
- NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
-
- UCHAR PMK[32]; // WPA PSK mode PMK
- UCHAR PTK[64]; // WPA PSK mode PTK
- UCHAR GTK[32]; // GTK from authenticator
- BSSID_INFO SavedPMK[PMKID_NO];
- UINT SavedPMKNum; // Saved PMKID number
-
- UCHAR DefaultKeyId;
-
-
- // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
- UCHAR PortSecured;
-
- // For WPA countermeasures
- ULONG LastMicErrorTime; // record last MIC error time
- ULONG MicErrCnt; // Should be 0, 1, 2, then reset to zero (after disassoiciation).
- BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
- // For WPA-PSK supplicant state
- WPA_STATE WpaState; // Default is SS_NOTUSE and handled by microsoft 802.1x
- UCHAR ReplayCounter[8];
- UCHAR ANonce[32]; // ANonce for WPA-PSK from aurhenticator
- UCHAR SNonce[32]; // SNonce for WPA-PSK
-
- UCHAR LastSNR0; // last received BEACON's SNR
- UCHAR LastSNR1; // last received BEACON's SNR for 2nd antenna
- RSSI_SAMPLE RssiSample;
- ULONG NumOfAvgRssiSample;
-
- ULONG LastBeaconRxTime; // OS's timestamp of the last BEACON RX time
- ULONG Last11bBeaconRxTime; // OS's timestamp of the last 11B BEACON RX time
- ULONG Last11gBeaconRxTime; // OS's timestamp of the last 11G BEACON RX time
- ULONG Last20NBeaconRxTime; // OS's timestamp of the last 20MHz N BEACON RX time
-
- ULONG LastScanTime; // Record last scan time for issue BSSID_SCAN_LIST
- ULONG ScanCnt; // Scan counts since most recent SSID, BSSID, SCAN OID request
- BOOLEAN bSwRadio; // Software controlled Radio On/Off, TRUE: On
- BOOLEAN bHwRadio; // Hardware controlled Radio On/Off, TRUE: On
- BOOLEAN bRadio; // Radio state, And of Sw & Hw radio state
- BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
- BOOLEAN bShowHiddenSSID; // Show all known SSID in SSID list get operation
-
- //BOOLEAN AdhocBOnlyJoined; // Indicate Adhoc B Join.
- //BOOLEAN AdhocBGJoined; // Indicate Adhoc B/G Join.
- //BOOLEAN Adhoc20NJoined; // Indicate Adhoc 20MHz N Join.
-
- // New for WPA, windows want us to to keep association information and
- // Fixed IEs from last association response
- NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
- USHORT ReqVarIELen; // Length of next VIE include EID & Length
- UCHAR ReqVarIEs[MAX_VIE_LEN]; // The content saved here should be little-endian format.
- USHORT ResVarIELen; // Length of next VIE include EID & Length
- UCHAR ResVarIEs[MAX_VIE_LEN];
-
- UCHAR RSNIE_Len;
- UCHAR RSN_IE[MAX_LEN_OF_RSNIE]; // The content saved here should be little-endian format.
-
- // New variables used for CCX 1.0
- BOOLEAN bCkipOn;
- BOOLEAN bCkipCmicOn;
- UCHAR CkipFlag;
- UCHAR GIV[3]; //for CCX iv
- UCHAR RxSEQ[4];
- UCHAR TxSEQ[4];
- UCHAR CKIPMIC[4];
- UCHAR LeapAuthMode;
- LEAP_AUTH_INFO LeapAuthInfo;
- UCHAR HashPwd[16];
- UCHAR NetworkChallenge[8];
- UCHAR NetworkChallengeResponse[24];
- UCHAR PeerChallenge[8];
-
- UCHAR PeerChallengeResponse[24];
- UCHAR SessionKey[16]; //Network session keys (NSK)
- RALINK_TIMER_STRUCT LeapAuthTimer;
- ROGUEAP_TABLE RogueApTab; //Cisco CCX1 Rogue AP Detection
-
- // New control flags for CCX
- CCX_CONTROL CCXControl; // Master administration state
- BOOLEAN CCXEnable; // Actual CCX state
- UCHAR CCXScanChannel; // Selected channel for CCX beacon request
- USHORT CCXScanTime; // Time out to wait for beacon and probe response
- UCHAR CCXReqType; // Current processing CCX request type
- BSS_TABLE CCXBssTab; // BSS Table
- UCHAR FrameReportBuf[2048]; // Buffer for creating frame report
- USHORT FrameReportLen; // Current Frame report length
- ULONG CLBusyBytes; // Save the total bytes received durning channel load scan time
- USHORT RPIDensity[8]; // Array for RPI density collection
- // Start address of each BSS table within FrameReportBuf
- // It's important to update the RxPower of the corresponding Bss
- USHORT BssReportOffset[MAX_LEN_OF_BSS_TABLE];
- USHORT BeaconToken; // Token for beacon report
- ULONG LastBssIndex; // Most current reported Bss index
- RM_REQUEST_ACTION MeasurementRequest[16]; // Saved measurement request
- UCHAR RMReqCnt; // Number of measurement request saved.
- UCHAR CurrentRMReqIdx; // Number of measurement request saved.
- BOOLEAN ParallelReq; // Parallel measurement, only one request performed,
- // It must be the same channel with maximum duration
- USHORT ParallelDuration; // Maximum duration for parallel measurement
- UCHAR ParallelChannel; // Only one channel with parallel measurement
- USHORT IAPPToken; // IAPP dialog token
- UCHAR CCXQosECWMin; // Cisco QOS ECWMin for AC 0
- UCHAR CCXQosECWMax; // Cisco QOS ECWMax for AC 0
- // Hack for channel load and noise histogram parameters
- UCHAR NHFactor; // Parameter for Noise histogram
- UCHAR CLFactor; // Parameter for channel load
-
- UCHAR KRK[16]; //Key Refresh Key.
- UCHAR BTK[32]; //Base Transient Key
- BOOLEAN CCKMLinkUpFlag;
- ULONG CCKMRN; //(Re)Association request number.
- LARGE_INTEGER CCKMBeaconAtJoinTimeStamp; //TSF timer for Re-assocaite to the new AP
- UCHAR AironetCellPowerLimit; //in dBm
- UCHAR AironetIPAddress[4]; //eg. 192.168.1.1
- BOOLEAN CCXAdjacentAPReportFlag; //flag for determining report Assoc Lost time
- CHAR CCXAdjacentAPSsid[MAX_LEN_OF_SSID]; //Adjacent AP's SSID report
- UCHAR CCXAdjacentAPSsidLen; // the actual ssid length in used
- UCHAR CCXAdjacentAPBssid[MAC_ADDR_LEN]; //Adjacent AP's BSSID report
- USHORT CCXAdjacentAPChannel;
- ULONG CCXAdjacentAPLinkDownTime; //for Spec S32.
-
- RALINK_TIMER_STRUCT StaQuickResponeForRateUpTimer;
- BOOLEAN StaQuickResponeForRateUpTimerRunning;
-
- UCHAR DtimCount; // 0.. DtimPeriod-1
- UCHAR DtimPeriod; // default = 3
-
-#ifdef QOS_DLS_SUPPORT
- RT_802_11_DLS DLSEntry[MAX_NUM_OF_DLS_ENTRY];
- UCHAR DlsReplayCounter[8];
-#endif // QOS_DLS_SUPPORT //
- ////////////////////////////////////////////////////////////////////////////////////////
- // This is only for WHQL test.
- BOOLEAN WhqlTest;
- ////////////////////////////////////////////////////////////////////////////////////////
-
- RALINK_TIMER_STRUCT WpaDisassocAndBlockAssocTimer;
- // Fast Roaming
- BOOLEAN bFastRoaming; // 0:disable fast roaming, 1:enable fast roaming
- CHAR dBmToRoam; // the condition to roam when receiving Rssi less than this value. It's negative value.
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- BOOLEAN IEEE8021X;
- BOOLEAN IEEE8021x_required_keys;
- CIPHER_KEY DesireSharedKey[4]; // Record user desired WEP keys
- UCHAR DesireSharedKeyId;
-
- // 0: driver ignores wpa_supplicant
- // 1: wpa_supplicant initiates scanning and AP selection
- // 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters
- UCHAR WpaSupplicantUP;
- UCHAR WpaSupplicantScanCount;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- CHAR dev_name[16];
- USHORT OriDevType;
-
- BOOLEAN bTGnWifiTest;
- BOOLEAN bScanReqIsFromWebUI;
-
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting;
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- BOOLEAN bAutoTxRateSwitch;
-
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- UCHAR IEEE80211dClientMode;
- UCHAR StaOriCountryCode[3];
- UCHAR StaOriGeography;
-#endif // EXT_BUILD_CHANNEL_LIST //
-} STA_ADMIN_CONFIG, *PSTA_ADMIN_CONFIG;
-
-// This data structure keep the current active BSS/IBSS's configuration that this STA
-// had agreed upon joining the network. Which means these parameters are usually decided
-// by the BSS/IBSS creator instead of user configuration. Data in this data structurre
-// is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE.
-// Normally, after SCAN or failed roaming attempts, we need to recover back to
-// the current active settings.
-typedef struct _STA_ACTIVE_CONFIG {
- USHORT Aid;
- USHORT AtimWin; // in kusec; IBSS parameter set element
- USHORT CapabilityInfo;
- USHORT CfpMaxDuration;
- USHORT CfpPeriod;
-
- // Copy supported rate from desired AP's beacon. We are trying to match
- // AP's supported and extended rate settings.
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen;
- UCHAR ExtRateLen;
- // Copy supported ht from desired AP's beacon. We are trying to match
- RT_HT_PHY_INFO SupportedPhyInfo;
- RT_HT_CAPABILITY SupportedHtPhy;
-} STA_ACTIVE_CONFIG, *PSTA_ACTIVE_CONFIG;
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef RT2870
-typedef struct RT_ADD_PAIRWISE_KEY_ENTRY {
- NDIS_802_11_MAC_ADDRESS MacAddr;
- USHORT MacTabMatchWCID; // ASIC
- CIPHER_KEY CipherKey;
-} RT_ADD_PAIRWISE_KEY_ENTRY,*PRT_ADD_PAIRWISE_KEY_ENTRY;
-#endif // RT2870 //
-
-// ----------- start of AP --------------------------
-// AUTH-RSP State Machine Aux data structure
-typedef struct _AP_MLME_AUX {
- UCHAR Addr[MAC_ADDR_LEN];
- USHORT Alg;
- CHAR Challenge[CIPHER_TEXT_LEN];
-} AP_MLME_AUX, *PAP_MLME_AUX;
-
-// structure to define WPA Group Key Rekey Interval
-typedef struct PACKED _RT_802_11_WPA_REKEY {
- ULONG ReKeyMethod; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
- ULONG ReKeyInterval; // time-based: seconds, packet-based: kilo-packets
-} RT_WPA_REKEY,*PRT_WPA_REKEY, RT_802_11_WPA_REKEY, *PRT_802_11_WPA_REKEY;
-
-typedef struct _MAC_TABLE_ENTRY {
- //Choose 1 from ValidAsWDS and ValidAsCLI to validize.
- BOOLEAN ValidAsCLI; // Sta mode, set this TRUE after Linkup,too.
- BOOLEAN ValidAsWDS; // This is WDS Entry. only for AP mode.
- BOOLEAN ValidAsApCli; //This is a AP-Client entry, only for AP mode which enable AP-Client functions.
- BOOLEAN ValidAsMesh;
- BOOLEAN ValidAsDls; // This is DLS Entry. only for STA mode.
- BOOLEAN isCached;
- BOOLEAN bIAmBadAtheros;
-
- UCHAR EnqueueEapolStartTimerRunning; // Enqueue EAPoL-Start for triggering EAP SM
- //jan for wpa
- // record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB
- UCHAR CMTimerRunning;
- UCHAR apidx; // MBSS number
- UCHAR RSNIE_Len;
- UCHAR RSN_IE[MAX_LEN_OF_RSNIE];
- UCHAR ANonce[LEN_KEY_DESC_NONCE];
- UCHAR R_Counter[LEN_KEY_DESC_REPLAY];
- UCHAR PTK[64];
- UCHAR ReTryCounter;
- RALINK_TIMER_STRUCT RetryTimer;
- RALINK_TIMER_STRUCT EnqueueStartForPSKTimer; // A timer which enqueue EAPoL-Start for triggering PSK SM
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
- AP_WPA_STATE WpaState;
- GTK_STATE GTKState;
- USHORT PortSecured;
- NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
- CIPHER_KEY PairwiseKey;
- PVOID pAd;
- INT PMKID_CacheIdx;
- UCHAR PMKID[LEN_PMKID];
-
-
- UCHAR Addr[MAC_ADDR_LEN];
- UCHAR PsMode;
- SST Sst;
- AUTH_STATE AuthState; // for SHARED KEY authentication state machine used only
- BOOLEAN IsReassocSta; // Indicate whether this is a reassociation procedure
- USHORT Aid;
- USHORT CapabilityInfo;
- UCHAR LastRssi;
- ULONG NoDataIdleCount;
- UINT16 StationKeepAliveCount; // unit: second
- ULONG PsQIdleCount;
- QUEUE_HEADER PsQueue;
-
- UINT32 StaConnectTime; // the live time of this station since associated with AP
-
-
-#ifdef DOT11_N_SUPPORT
- BOOLEAN bSendBAR;
- USHORT NoBADataCountDown;
-
- UINT32 CachedBuf[16]; // UINT (4 bytes) for alignment
- UINT TxBFCount; // 3*3
-#endif // DOT11_N_SUPPORT //
- UINT FIFOCount;
- UINT DebugFIFOCount;
- UINT DebugTxCount;
- BOOLEAN bDlsInit;
-
-
-//====================================================
-//WDS entry needs these
-// rt2860 add this. if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab
- UINT MatchWDSTabIdx;
- UCHAR MaxSupportedRate;
- UCHAR CurrTxRate;
- UCHAR CurrTxRateIndex;
- // to record the each TX rate's quality. 0 is best, the bigger the worse.
- USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
-// USHORT OneSecTxOkCount;
- UINT32 OneSecTxNoRetryOkCount;
- UINT32 OneSecTxRetryOkCount;
- UINT32 OneSecTxFailCount;
- UINT32 ContinueTxFailCnt;
- UINT32 CurrTxRateStableTime; // # of second in current TX rate
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
-//====================================================
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
- UINT MatchDlsEntryIdx; // indicate the index in pAd->StaCfg.DLSEntry
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
- BOOLEAN fNoisyEnvironment;
- BOOLEAN fLastSecAccordingRSSI;
- UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
- CHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
- ULONG LastTxOkCount;
- UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
-
- // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
- // BOOLEAN control, either ON or OFF. These flags should always be accessed via
- // CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros.
- // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED
- ULONG ClientStatusFlags;
-
- // TODO: Shall we move that to DOT11_N_SUPPORT???
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-
-#ifdef DOT11_N_SUPPORT
- // HT EWC MIMO-N used parameters
- USHORT RXBAbitmap; // fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format
- USHORT TXBAbitmap; // This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI
- USHORT TXAutoBAbitmap;
- USHORT BADeclineBitmap;
- USHORT BARecWcidArray[NUM_OF_TID]; // The mapping wcid of recipient session. if RXBAbitmap bit is masked
- USHORT BAOriWcidArray[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
- USHORT BAOriSequence[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
-
- // 802.11n features.
- UCHAR MpduDensity;
- UCHAR MaxRAmpduFactor;
- UCHAR AMsduSize;
- UCHAR MmpsMode; // MIMO power save more.
-
- HT_CAPABILITY_IE HTCapability;
-
-#ifdef DOT11N_DRAFT3
- UCHAR BSS2040CoexistenceMgmtSupport;
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
- BOOLEAN bAutoTxRateSwitch;
-
- UCHAR RateLen;
- struct _MAC_TABLE_ENTRY *pNext;
- USHORT TxSeq[NUM_OF_TID];
- USHORT NonQosDataSeq;
-
- RSSI_SAMPLE RssiSample;
-
- UINT32 TXMCSExpected[16];
- UINT32 TXMCSSuccessful[16];
- UINT32 TXMCSFailed[16];
- UINT32 TXMCSAutoFallBack[16][16];
-
-#ifdef CONFIG_STA_SUPPORT
- ULONG LastBeaconRxTime;
-#endif // CONFIG_STA_SUPPORT //
-} MAC_TABLE_ENTRY, *PMAC_TABLE_ENTRY;
-
-typedef struct _MAC_TABLE {
- USHORT Size;
- MAC_TABLE_ENTRY *Hash[HASH_TABLE_SIZE];
- MAC_TABLE_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
- QUEUE_HEADER McastPsQueue;
- ULONG PsQIdleCount;
- BOOLEAN fAnyStationInPsm;
- BOOLEAN fAnyStationBadAtheros; // Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip.
- BOOLEAN fAnyTxOPForceDisable; // Check if it is necessary to disable BE TxOP
- BOOLEAN fAllStationAsRalink; // Check if all stations are ralink-chipset
-#ifdef DOT11_N_SUPPORT
- BOOLEAN fAnyStationIsLegacy; // Check if I use legacy rate to transmit to my BSS Station/
- BOOLEAN fAnyStationNonGF; // Check if any Station can't support GF.
- BOOLEAN fAnyStation20Only; // Check if any Station can't support GF.
- BOOLEAN fAnyStationMIMOPSDynamic; // Check if any Station is MIMO Dynamic
- BOOLEAN fAnyBASession; // Check if there is BA session. Force turn on RTS/CTS
-#endif // DOT11_N_SUPPORT //
-} MAC_TABLE, *PMAC_TABLE;
-
-#ifdef DOT11_N_SUPPORT
-#define IS_HT_STA(_pMacEntry) \
- (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define IS_HT_RATE(_pMacEntry) \
- (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define PEER_IS_HT_RATE(_pMacEntry) \
- (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-#endif // DOT11_N_SUPPORT //
-
-typedef struct _WDS_ENTRY {
- BOOLEAN Valid;
- UCHAR Addr[MAC_ADDR_LEN];
- ULONG NoDataIdleCount;
- struct _WDS_ENTRY *pNext;
-} WDS_ENTRY, *PWDS_ENTRY;
-
-typedef struct _WDS_TABLE_ENTRY {
- USHORT Size;
- UCHAR WdsAddr[MAC_ADDR_LEN];
- WDS_ENTRY *Hash[HASH_TABLE_SIZE];
- WDS_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
- UCHAR MaxSupportedRate;
- UCHAR CurrTxRate;
- USHORT TxQuality[MAX_LEN_OF_SUPPORTED_RATES];
- USHORT OneSecTxOkCount;
- USHORT OneSecTxRetryOkCount;
- USHORT OneSecTxFailCount;
- ULONG CurrTxRateStableTime; // # of second in current TX rate
- UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
-} WDS_TABLE_ENTRY, *PWDS_TABLE_ENTRY;
-
-typedef struct _RT_802_11_WDS_ENTRY {
- PNET_DEV dev;
- UCHAR Valid;
- UCHAR PhyMode;
- UCHAR PeerWdsAddr[MAC_ADDR_LEN];
- UCHAR MacTabMatchWCID; // ASIC
- NDIS_802_11_WEP_STATUS WepStatus;
- UCHAR KeyIdx;
- CIPHER_KEY WdsKey;
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- BOOLEAN bAutoTxRateSwitch;
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting.
-} RT_802_11_WDS_ENTRY, *PRT_802_11_WDS_ENTRY;
-
-typedef struct _WDS_TABLE {
- UCHAR Mode;
- ULONG Size;
- RT_802_11_WDS_ENTRY WdsEntry[MAX_WDS_ENTRY];
-} WDS_TABLE, *PWDS_TABLE;
-
-typedef struct _APCLI_STRUCT {
- PNET_DEV dev;
-#ifdef RTL865X_SOC
- unsigned int mylinkid;
-#endif
- BOOLEAN Enable; // Set it as 1 if the apcli interface was configured to "1" or by iwpriv cmd "ApCliEnable"
- BOOLEAN Valid; // Set it as 1 if the apcli interface associated success to remote AP.
- UCHAR MacTabWCID; //WCID value, which point to the entry of ASIC Mac table.
- UCHAR SsidLen;
- CHAR Ssid[MAX_LEN_OF_SSID];
-
- UCHAR CfgSsidLen;
- CHAR CfgSsid[MAX_LEN_OF_SSID];
- UCHAR CfgApCliBssid[ETH_LENGTH_OF_ADDRESS];
- UCHAR CurrentAddress[ETH_LENGTH_OF_ADDRESS];
-
- ULONG ApCliRcvBeaconTime;
-
- ULONG CtrlCurrState;
- ULONG SyncCurrState;
- ULONG AuthCurrState;
- ULONG AssocCurrState;
- ULONG WpaPskCurrState;
-
- USHORT AuthReqCnt;
- USHORT AssocReqCnt;
-
- ULONG ClientStatusFlags;
- UCHAR MpduDensity;
-
- NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
- NDIS_802_11_WEP_STATUS WepStatus;
-
- // Add to support different cipher suite for WPA2/WPA mode
- NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
- NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
- BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
- USHORT RsnCapability;
-
- UCHAR PSK[100]; // reserve PSK key material
- UCHAR PSKLen;
- UCHAR PMK[32]; // WPA PSK mode PMK
- //UCHAR PTK[64]; // WPA PSK mode PTK
- UCHAR GTK[32]; // GTK from authenticator
-
- //CIPHER_KEY PairwiseKey;
- CIPHER_KEY SharedKey[SHARE_KEY_NUM];
- UCHAR DefaultKeyId;
-
- // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
- //UCHAR PortSecured;
-
- // store RSN_IE built by driver
- UCHAR RSN_IE[MAX_LEN_OF_RSNIE]; // The content saved here should be convert to little-endian format.
- UCHAR RSNIE_Len;
-
- // For WPA countermeasures
- ULONG LastMicErrorTime; // record last MIC error time
- //ULONG MicErrCnt; // Should be 0, 1, 2, then reset to zero (after disassoiciation).
- BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
-
- // For WPA-PSK supplicant state
- //WPA_STATE WpaState; // Default is SS_NOTUSE
- //UCHAR ReplayCounter[8];
- //UCHAR ANonce[32]; // ANonce for WPA-PSK from authenticator
- UCHAR SNonce[32]; // SNonce for WPA-PSK
- UCHAR GNonce[32]; // GNonce for WPA-PSK from authenticator
-
- HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
- RT_HT_PHY_INFO DesiredHtPhyInfo;
- BOOLEAN bAutoTxRateSwitch;
- DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting.
-} APCLI_STRUCT, *PAPCLI_STRUCT;
-
-// ----------- end of AP ----------------------------
-
-#ifdef BLOCK_NET_IF
-typedef struct _BLOCK_QUEUE_ENTRY
-{
- BOOLEAN SwTxQueueBlockFlag;
- LIST_HEADER NetIfList;
-} BLOCK_QUEUE_ENTRY, *PBLOCK_QUEUE_ENTRY;
-#endif // BLOCK_NET_IF //
-
-
-struct wificonf
-{
- BOOLEAN bShortGI;
- BOOLEAN bGreenField;
-};
-
-
-
-
-typedef struct _INF_PCI_CONFIG
-{
- PUCHAR CSRBaseAddress; // PCI MMIO Base Address, all access will use
-}INF_PCI_CONFIG;
-
-typedef struct _INF_USB_CONFIG
-{
- UINT BulkInEpAddr; // bulk-in endpoint address
- UINT BulkOutEpAddr[6]; // bulk-out endpoint address
-
-}INF_USB_CONFIG;
-
-#ifdef IKANOS_VX_1X0
- typedef void (*IkanosWlanTxCbFuncP)(void *, void *);
-
- struct IKANOS_TX_INFO
- {
- struct net_device *netdev;
- IkanosWlanTxCbFuncP *fp;
- };
-#endif // IKANOS_VX_1X0 //
-
-#ifdef NINTENDO_AP
-typedef struct _NINDO_CTRL_BLOCK {
-
- RT_NINTENDO_TABLE DS_TABLE;
-
-#ifdef CHIP25XX
- spinlock_t NINTENDO_TABLE_Lock;
-#else
- NDIS_SPIN_LOCK NINTENDO_TABLE_Lock;
-#endif // CHIP25XX //
-
- UCHAR NINTENDO_UP_BUFFER[512];
- UCHAR Local_KeyIdx;
- CIPHER_KEY Local_SharedKey;
- UCHAR Local_bHideSsid;
- UCHAR Local_AuthMode;
- UCHAR Local_WepStatus;
- USHORT Local_CapabilityInfo;
-} NINDO_CTRL_BLOCK;
-#endif // NINTENDO_AP //
-
-
-#ifdef DBG_DIAGNOSE
-#define DIAGNOSE_TIME 10 // 10 sec
-typedef struct _RtmpDiagStrcut_
-{ // Diagnosis Related element
- unsigned char inited;
- unsigned char qIdx;
- unsigned char ArrayStartIdx;
- unsigned char ArrayCurIdx;
- // Tx Related Count
- USHORT TxDataCnt[DIAGNOSE_TIME];
- USHORT TxFailCnt[DIAGNOSE_TIME];
-// USHORT TxDescCnt[DIAGNOSE_TIME][16]; // TxDesc queue length in scale of 0~14, >=15
- USHORT TxDescCnt[DIAGNOSE_TIME][24]; // 3*3 // TxDesc queue length in scale of 0~14, >=15
-// USHORT TxMcsCnt[DIAGNOSE_TIME][16]; // TxDate MCS Count in range from 0 to 15, step in 1.
- USHORT TxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
- USHORT TxSWQueCnt[DIAGNOSE_TIME][9]; // TxSwQueue length in scale of 0, 1, 2, 3, 4, 5, 6, 7, >=8
-
- USHORT TxAggCnt[DIAGNOSE_TIME];
- USHORT TxNonAggCnt[DIAGNOSE_TIME];
-// USHORT TxAMPDUCnt[DIAGNOSE_TIME][16]; // 10 sec, TxDMA APMDU Aggregation count in range from 0 to 15, in setp of 1.
- USHORT TxAMPDUCnt[DIAGNOSE_TIME][24]; // 3*3 // 10 sec, TxDMA APMDU Aggregation count in range from 0 to 15, in setp of 1.
- USHORT TxRalinkCnt[DIAGNOSE_TIME]; // TxRalink Aggregation Count in 1 sec scale.
- USHORT TxAMSDUCnt[DIAGNOSE_TIME]; // TxAMSUD Aggregation Count in 1 sec scale.
-
- // Rx Related Count
- USHORT RxDataCnt[DIAGNOSE_TIME]; // Rx Total Data count.
- USHORT RxCrcErrCnt[DIAGNOSE_TIME];
-// USHORT RxMcsCnt[DIAGNOSE_TIME][16]; // Rx MCS Count in range from 0 to 15, step in 1.
- USHORT RxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
-}RtmpDiagStruct;
-#endif // DBG_DIAGNOSE //
-
-
-//
-// The miniport adapter structure
-//
-typedef struct _RTMP_ADAPTER
-{
- PVOID OS_Cookie; // save specific structure relative to OS
- PNET_DEV net_dev;
- ULONG VirtualIfCnt;
-
-
-
- NDIS_SPIN_LOCK irq_lock;
- UCHAR irq_disabled;
-
-#ifdef RT2870
-/*****************************************************************************************/
-/* USB related parameters */
-/*****************************************************************************************/
- struct usb_config_descriptor *config;
- UINT BulkInEpAddr; // bulk-in endpoint address
- UINT BulkOutEpAddr[6]; // bulk-out endpoint address
-
- UINT NumberOfPipes;
- USHORT BulkOutMaxPacketSize;
- USHORT BulkInMaxPacketSize;
-
- //======Control Flags
- LONG PendingIoCount;
- ULONG BulkFlags;
- BOOLEAN bUsbTxBulkAggre; // Flags for bulk out data priority
-
-
- //======Timer Thread
- RT2870_TIMER_QUEUE TimerQ;
- NDIS_SPIN_LOCK TimerQLock;
-
-
- //======Cmd Thread
- CmdQ CmdQ;
- NDIS_SPIN_LOCK CmdQLock; // CmdQLock spinlock
-
- BOOLEAN TimerFunc_kill;
- BOOLEAN mlme_kill;
-
-
- //======Semaphores (event)
- struct semaphore mlme_semaphore; /* to sleep thread on */
- struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */
- struct semaphore RTUSBTimer_semaphore;
-#ifdef INF_AMAZON_SE
- struct semaphore UsbVendorReq_semaphore;
- PVOID UsbVendorReqBuf;
-#endif // INF_AMAZON_SE //
- struct completion TimerQComplete;
- struct completion mlmeComplete;
- struct completion CmdQComplete;
- wait_queue_head_t *wait;
-
- //======Lock for 2870 ATE
-#ifdef RALINK_ATE
- NDIS_SPIN_LOCK GenericLock; // ATE Tx/Rx generic spinlock
-#endif // RALINK_ATE //
-
-#endif // RT2870 //
-
-
-/*****************************************************************************************/
- /* Both PCI/USB related parameters */
-/*****************************************************************************************/
-
-
-/*****************************************************************************************/
-/* Tx related parameters */
-/*****************************************************************************************/
- BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; // for ensuring RTUSBDeQueuePacket get call once
- NDIS_SPIN_LOCK DeQueueLock[NUM_OF_TX_RING];
-
-#ifdef RT2870
- // Data related context and AC specified, 4 AC supported
- NDIS_SPIN_LOCK BulkOutLock[6]; // BulkOut spinlock for 4 ACs
- NDIS_SPIN_LOCK MLMEBulkOutLock; // MLME BulkOut lock
-
- HT_TX_CONTEXT TxContext[NUM_OF_TX_RING];
- NDIS_SPIN_LOCK TxContextQueueLock[NUM_OF_TX_RING]; // TxContextQueue spinlock
-
- // 4 sets of Bulk Out index and pending flag
- UCHAR NextBulkOutIndex[4]; // only used for 4 EDCA bulkout pipe
-
- BOOLEAN BulkOutPending[6]; // used for total 6 bulkout pipe
- UCHAR bulkResetPipeid;
- BOOLEAN MgmtBulkPending;
- ULONG bulkResetReq[6];
-#endif // RT2870 //
-
- // resource for software backlog queues
- QUEUE_HEADER TxSwQueue[NUM_OF_TX_RING]; // 4 AC + 1 HCCA
- NDIS_SPIN_LOCK TxSwQueueLock[NUM_OF_TX_RING]; // TxSwQueue spinlock
-
- RTMP_DMABUF MgmtDescRing; // Shared memory for MGMT descriptors
- RTMP_MGMT_RING MgmtRing;
- NDIS_SPIN_LOCK MgmtRingLock; // Prio Ring spinlock
-
-
-/*****************************************************************************************/
-/* Rx related parameters */
-/*****************************************************************************************/
-
-
-#ifdef RT2870
- RX_CONTEXT RxContext[RX_RING_SIZE]; // 1 for redundant multiple IRP bulk in.
- NDIS_SPIN_LOCK BulkInLock; // BulkIn spinlock for 4 ACs
- UCHAR PendingRx; // The Maxima pending Rx value should be RX_RING_SIZE.
- UCHAR NextRxBulkInIndex; // Indicate the current RxContext Index which hold by Host controller.
- UCHAR NextRxBulkInReadIndex; // Indicate the current RxContext Index which driver can read & process it.
- ULONG NextRxBulkInPosition; // Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength.
- ULONG TransferBufferLength; // current length of the packet buffer
- ULONG ReadPosition; // current read position in a packet buffer
-#endif // RT2870 //
-
-
-/*****************************************************************************************/
-/* ASIC related parameters */
-/*****************************************************************************************/
- UINT32 MACVersion; // MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101)..
-
- // ---------------------------
- // E2PROM
- // ---------------------------
- ULONG EepromVersion; // byte 0: version, byte 1: revision, byte 2~3: unused
- UCHAR EEPROMAddressNum; // 93c46=6 93c66=8
- USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
- BOOLEAN EepromAccess;
- UCHAR EFuseTag;
- ULONG FirmwareVersion; // byte 0: Minor version, byte 1: Major version, otherwise unused.
-
- // ---------------------------
- // BBP Control
- // ---------------------------
- UCHAR BbpWriteLatch[140]; // record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID
- UCHAR BbpRssiToDbmDelta;
- BBP_R66_TUNING BbpTuning;
-
- // ----------------------------
- // RFIC control
- // ----------------------------
- UCHAR RfIcType; // RFIC_xxx
- ULONG RfFreqOffset; // Frequency offset for channel switching
- RTMP_RF_REGS LatchRfRegs; // latch th latest RF programming value since RF IC doesn't support READ
-
- EEPROM_ANTENNA_STRUC Antenna; // Since ANtenna definition is different for a & g. We need to save it for future reference.
- EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-
- // This soft Rx Antenna Diversity mechanism is used only when user set
- // RX Antenna = DIVERSITY ON
- SOFT_RX_ANT_DIVERSITY RxAnt;
-
- UCHAR RFProgSeq;
- CHANNEL_TX_POWER TxPower[MAX_NUM_OF_CHANNELS]; // Store Tx power value for all channels.
- CHANNEL_TX_POWER ChannelList[MAX_NUM_OF_CHANNELS]; // list all supported channels for site survey
- CHANNEL_11J_TX_POWER TxPower11J[MAX_NUM_OF_11JCHANNELS]; // 802.11j channel and bw
- CHANNEL_11J_TX_POWER ChannelList11J[MAX_NUM_OF_11JCHANNELS]; // list all supported channels for site survey
-
- UCHAR ChannelListNum; // number of channel in ChannelList[]
- UCHAR Bbp94;
- BOOLEAN BbpForCCK;
- ULONG Tx20MPwrCfgABand[5];
- ULONG Tx20MPwrCfgGBand[5];
- ULONG Tx40MPwrCfgABand[5];
- ULONG Tx40MPwrCfgGBand[5];
-
- BOOLEAN bAutoTxAgcA; // Enable driver auto Tx Agc control
- UCHAR TssiRefA; // Store Tssi reference value as 25 temperature.
- UCHAR TssiPlusBoundaryA[5]; // Tssi boundary for increase Tx power to compensate.
- UCHAR TssiMinusBoundaryA[5]; // Tssi boundary for decrease Tx power to compensate.
- UCHAR TxAgcStepA; // Store Tx TSSI delta increment / decrement value
- CHAR TxAgcCompensateA; // Store the compensation (TxAgcStep * (idx-1))
-
- BOOLEAN bAutoTxAgcG; // Enable driver auto Tx Agc control
- UCHAR TssiRefG; // Store Tssi reference value as 25 temperature.
- UCHAR TssiPlusBoundaryG[5]; // Tssi boundary for increase Tx power to compensate.
- UCHAR TssiMinusBoundaryG[5]; // Tssi boundary for decrease Tx power to compensate.
- UCHAR TxAgcStepG; // Store Tx TSSI delta increment / decrement value
- CHAR TxAgcCompensateG; // Store the compensation (TxAgcStep * (idx-1))
-
- //+++For RT2870, the parameteres is start from BGRssiOffset1 ~ BGRssiOffset3
- CHAR BGRssiOffset0; // Store B/G RSSI#0 Offset value on EEPROM 0x46h
- CHAR BGRssiOffset1; // Store B/G RSSI#1 Offset value
- CHAR BGRssiOffset2; // Store B/G RSSI#2 Offset value
- //---
-
- //+++For RT2870, the parameteres is start from ARssiOffset1 ~ ARssiOffset3
- CHAR ARssiOffset0; // Store A RSSI#0 Offset value on EEPROM 0x4Ah
- CHAR ARssiOffset1; // Store A RSSI#1 Offset value
- CHAR ARssiOffset2; // Store A RSSI#2 Offset value
- //---
-
- CHAR BLNAGain; // Store B/G external LNA#0 value on EEPROM 0x44h
- CHAR ALNAGain0; // Store A external LNA#0 value for ch36~64
- CHAR ALNAGain1; // Store A external LNA#1 value for ch100~128
- CHAR ALNAGain2; // Store A external LNA#2 value for ch132~165
-
- // ----------------------------
- // LED control
- // ----------------------------
- MCU_LEDCS_STRUC LedCntl;
- USHORT Led1; // read from EEPROM 0x3c
- USHORT Led2; // EEPROM 0x3e
- USHORT Led3; // EEPROM 0x40
- UCHAR LedIndicatorStregth;
- UCHAR RssiSingalstrengthOffet;
- BOOLEAN bLedOnScanning;
- UCHAR LedStatus;
-
-/*****************************************************************************************/
-/* 802.11 related parameters */
-/*****************************************************************************************/
- // outgoing BEACON frame buffer and corresponding TXD
- TXWI_STRUC BeaconTxWI;
- PUCHAR BeaconBuf;
- USHORT BeaconOffset[HW_BEACON_MAX_COUNT];
-
- // pre-build PS-POLL and NULL frame upon link up. for efficiency purpose.
- PSPOLL_FRAME PsPollFrame;
- HEADER_802_11 NullFrame;
-
-#ifdef RT2870
- TX_CONTEXT BeaconContext[BEACON_RING_SIZE];
- TX_CONTEXT NullContext;
- TX_CONTEXT PsPollContext;
- TX_CONTEXT RTSContext;
-#endif // RT2870 //
-
-
-
-//=========AP===========
-
-
-//=======STA===========
-#ifdef CONFIG_STA_SUPPORT
-/* Modified by Wu Xi-Kun 4/21/2006 */
- // -----------------------------------------------
- // STA specific configuration & operation status
- // used only when pAd->OpMode == OPMODE_STA
- // -----------------------------------------------
- STA_ADMIN_CONFIG StaCfg; // user desired settings
- STA_ACTIVE_CONFIG StaActive; // valid only when ADHOC_ON(pAd) || INFRA_ON(pAd)
- CHAR nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
- NDIS_MEDIA_STATE PreMediaState;
-#endif // CONFIG_STA_SUPPORT //
-
-//=======Common===========
- // OP mode: either AP or STA
- UCHAR OpMode; // OPMODE_STA, OPMODE_AP
-
- NDIS_MEDIA_STATE IndicateMediaState; // Base on Indication state, default is NdisMediaStateDisConnected
-
-
- // MAT related parameters
-
- // configuration: read from Registry & E2PROM
- BOOLEAN bLocalAdminMAC; // Use user changed MAC
- UCHAR PermanentAddress[MAC_ADDR_LEN]; // Factory default MAC address
- UCHAR CurrentAddress[MAC_ADDR_LEN]; // User changed MAC address
-
- // ------------------------------------------------------
- // common configuration to both OPMODE_STA and OPMODE_AP
- // ------------------------------------------------------
- COMMON_CONFIG CommonCfg;
- MLME_STRUCT Mlme;
-
- // AP needs those vaiables for site survey feature.
- MLME_AUX MlmeAux; // temporary settings used during MLME state machine
- BSS_TABLE ScanTab; // store the latest SCAN result
-
- //About MacTab, the sta driver will use #0 and #1 for multicast and AP.
- MAC_TABLE MacTab; // ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table.
- NDIS_SPIN_LOCK MacTabLock;
-
-#ifdef DOT11_N_SUPPORT
- BA_TABLE BATable;
-#endif // DOT11_N_SUPPORT //
- NDIS_SPIN_LOCK BATabLock;
- RALINK_TIMER_STRUCT RECBATimer;
-
- // encryption/decryption KEY tables
- CIPHER_KEY SharedKey[MAX_MBSSID_NUM][4]; // STA always use SharedKey[BSS0][0..3]
-
- // RX re-assembly buffer for fragmentation
- FRAGMENT_FRAME FragFrame; // Frame storage for fragment frame
-
- // various Counters
- COUNTER_802_3 Counters8023; // 802.3 counters
- COUNTER_802_11 WlanCounters; // 802.11 MIB counters
- COUNTER_RALINK RalinkCounters; // Ralink propriety counters
- COUNTER_DRS DrsCounters; // counters for Dynamic TX Rate Switching
- PRIVATE_STRUC PrivateInfo; // Private information & counters
-
- // flags, see fRTMP_ADAPTER_xxx flags
- ULONG Flags; // Represent current device status
-
- // current TX sequence #
- USHORT Sequence;
-
-#ifdef UNDER_CE
- NDIS_HANDLE hGiISR;
-#endif
-
-
- // Control disconnect / connect event generation
- //+++Didn't used anymore
- ULONG LinkDownTime;
- //---
- ULONG LastRxRate;
- ULONG LastTxRate;
- //+++Used only for Station
- BOOLEAN bConfigChanged; // Config Change flag for the same SSID setting
- //---
-
- ULONG ExtraInfo; // Extra information for displaying status
- ULONG SystemErrorBitmap; // b0: E2PROM version error
-
- //+++Didn't used anymore
- ULONG MacIcVersion; // MAC/BBP serial interface issue solved after ver.D
- //---
-
- // ---------------------------
- // System event log
- // ---------------------------
- RT_802_11_EVENT_TABLE EventTab;
-
-
- BOOLEAN HTCEnable;
-
- /*****************************************************************************************/
- /* Statistic related parameters */
- /*****************************************************************************************/
-#ifdef RT2870
- ULONG BulkOutDataOneSecCount;
- ULONG BulkInDataOneSecCount;
- ULONG BulkLastOneSecCount; // BulkOutDataOneSecCount + BulkInDataOneSecCount
- ULONG watchDogRxCnt;
- ULONG watchDogRxOverFlowCnt;
- ULONG watchDogTxPendingCnt[NUM_OF_TX_RING];
-#endif // RT2870 //
-
- BOOLEAN bUpdateBcnCntDone;
- ULONG watchDogMacDeadlock; // prevent MAC/BBP into deadlock condition
- // ----------------------------
- // DEBUG paramerts
- // ----------------------------
- //ULONG DebugSetting[4];
- BOOLEAN bBanAllBaSetup;
- BOOLEAN bPromiscuous;
-
- // ----------------------------
- // rt2860c emulation-use Parameters
- // ----------------------------
- ULONG rtsaccu[30];
- ULONG ctsaccu[30];
- ULONG cfendaccu[30];
- ULONG bacontent[16];
- ULONG rxint[RX_RING_SIZE+1];
- UCHAR rcvba[60];
- BOOLEAN bLinkAdapt;
- BOOLEAN bForcePrintTX;
- BOOLEAN bForcePrintRX;
- BOOLEAN bDisablescanning; //defined in RT2870 USB
- BOOLEAN bStaFifoTest;
- BOOLEAN bProtectionTest;
- BOOLEAN bHCCATest;
- BOOLEAN bGenOneHCCA;
- BOOLEAN bBroadComHT;
- //+++Following add from RT2870 USB.
- ULONG BulkOutReq;
- ULONG BulkOutComplete;
- ULONG BulkOutCompleteOther;
- ULONG BulkOutCompleteCancel; // seems not use now?
- ULONG BulkInReq;
- ULONG BulkInComplete;
- ULONG BulkInCompleteFail;
- //---
-
- struct wificonf WIFItestbed;
-
-#ifdef RALINK_ATE
- ATE_INFO ate;
-#ifdef RT2870
- BOOLEAN ContinBulkOut; //ATE bulk out control
- BOOLEAN ContinBulkIn; //ATE bulk in control
- atomic_t BulkOutRemained;
- atomic_t BulkInRemained;
-#endif // RT2870 //
-#endif // RALINK_ATE //
-
-#ifdef DOT11_N_SUPPORT
- struct reordering_mpdu_pool mpdu_blk_pool;
-#endif // DOT11_N_SUPPORT //
-
- ULONG OneSecondnonBEpackets; // record non BE packets per second
-
-#if WIRELESS_EXT >= 12
- struct iw_statistics iw_stats;
-#endif
-
- struct net_device_stats stats;
-
-#ifdef BLOCK_NET_IF
- BLOCK_QUEUE_ENTRY blockQueueTab[NUM_OF_TX_RING];
-#endif // BLOCK_NET_IF //
-
-
-
-#ifdef MULTIPLE_CARD_SUPPORT
- INT32 MC_RowID;
- UCHAR MC_FileName[256];
-#endif // MULTIPLE_CARD_SUPPORT //
-
- ULONG TbttTickCount;
-#ifdef PCI_MSI_SUPPORT
- BOOLEAN HaveMsi;
-#endif // PCI_MSI_SUPPORT //
-
-
- UCHAR is_on;
-
-#define TIME_BASE (1000000/OS_HZ)
-#define TIME_ONE_SECOND (1000000/TIME_BASE)
- UCHAR flg_be_adjust;
- ULONG be_adjust_last_time;
-
-#ifdef NINTENDO_AP
- NINDO_CTRL_BLOCK nindo_ctrl_block;
-#endif // NINTENDO_AP //
-
-
-#ifdef IKANOS_VX_1X0
- struct IKANOS_TX_INFO IkanosTxInfo;
- struct IKANOS_TX_INFO IkanosRxInfo[MAX_MBSSID_NUM + MAX_WDS_ENTRY + MAX_APCLI_NUM + MAX_MESH_NUM];
-#endif // IKANOS_VX_1X0 //
-
-
-#ifdef DBG_DIAGNOSE
- RtmpDiagStruct DiagStruct;
-#endif // DBG_DIAGNOSE //
-
-
- UINT8 PM_FlgSuspend;
-
-#ifdef RT30xx
-//======efuse
- BOOLEAN bUseEfuse;
- BOOLEAN bEEPROMFile;
-#endif // RT30xx //
-
-} RTMP_ADAPTER, *PRTMP_ADAPTER;
-
-//
-// Cisco IAPP format
-//
-typedef struct _CISCO_IAPP_CONTENT_
-{
- USHORT Length; //IAPP Length
- UCHAR MessageType; //IAPP type
- UCHAR FunctionCode; //IAPP function type
- UCHAR DestinaionMAC[MAC_ADDR_LEN];
- UCHAR SourceMAC[MAC_ADDR_LEN];
- USHORT Tag; //Tag(element IE) - Adjacent AP report
- USHORT TagLength; //Length of element not including 4 byte header
- UCHAR OUI[4]; //0x00, 0x40, 0x96, 0x00
- UCHAR PreviousAP[MAC_ADDR_LEN]; //MAC Address of access point
- USHORT Channel;
- USHORT SsidLen;
- UCHAR Ssid[MAX_LEN_OF_SSID];
- USHORT Seconds; //Seconds that the client has been disassociated.
-} CISCO_IAPP_CONTENT, *PCISCO_IAPP_CONTENT;
-
-#define DELAYINTMASK 0x0003fffb
-#define INTMASK 0x0003fffb
-#define IndMask 0x0003fffc
-#define RxINT 0x00000005 // Delayed Rx or indivi rx
-#define TxDataInt 0x000000fa // Delayed Tx or indivi tx
-#define TxMgmtInt 0x00000102 // Delayed Tx or indivi tx
-#define TxCoherent 0x00020000 // tx coherent
-#define RxCoherent 0x00010000 // rx coherent
-#define McuCommand 0x00000200 // mcu
-#define PreTBTTInt 0x00001000 // Pre-TBTT interrupt
-#define TBTTInt 0x00000800 // TBTT interrupt
-#define GPTimeOutInt 0x00008000 // GPtimeout interrupt
-#define AutoWakeupInt 0x00004000 // AutoWakeupInt interrupt
-#define FifoStaFullInt 0x00002000 // fifo statistics full interrupt
-
-
-typedef struct _RX_BLK_
-{
-// RXD_STRUC RxD; // sample
- RT28XX_RXD_STRUC RxD;
- PRXWI_STRUC pRxWI;
- PHEADER_802_11 pHeader;
- PNDIS_PACKET pRxPacket;
- UCHAR *pData;
- USHORT DataSize;
- USHORT Flags;
- UCHAR UserPriority; // for calculate TKIP MIC using
-} RX_BLK;
-
-
-#define RX_BLK_SET_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags |= _flag)
-#define RX_BLK_TEST_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags & _flag)
-#define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags &= ~(_flag))
-
-
-#define fRX_WDS 0x0001
-#define fRX_AMSDU 0x0002
-#define fRX_ARALINK 0x0004
-#define fRX_HTC 0x0008
-#define fRX_PAD 0x0010
-#define fRX_AMPDU 0x0020
-#define fRX_QOS 0x0040
-#define fRX_INFRA 0x0080
-#define fRX_EAP 0x0100
-#define fRX_MESH 0x0200
-#define fRX_APCLI 0x0400
-#define fRX_DLS 0x0800
-#define fRX_WPI 0x1000
-
-#define LENGTH_AMSDU_SUBFRAMEHEAD 14
-#define LENGTH_ARALINK_SUBFRAMEHEAD 14
-#define LENGTH_ARALINK_HEADER_FIELD 2
-
-#define TX_UNKOWN_FRAME 0x00
-#define TX_MCAST_FRAME 0x01
-#define TX_LEGACY_FRAME 0x02
-#define TX_AMPDU_FRAME 0x04
-#define TX_AMSDU_FRAME 0x08
-#define TX_RALINK_FRAME 0x10
-#define TX_FRAG_FRAME 0x20
-
-
-// Currently the sizeof(TX_BLK) is 148 bytes.
-typedef struct _TX_BLK_
-{
- UCHAR QueIdx;
- UCHAR TxFrameType; // Indicate the Transmission type of the all frames in one batch
- UCHAR TotalFrameNum; // Total frame number want to send-out in one batch
- USHORT TotalFragNum; // Total frame fragments required in one batch
- USHORT TotalFrameLen; // Total length of all frames want to send-out in one batch
-
- QUEUE_HEADER TxPacketList;
- MAC_TABLE_ENTRY *pMacEntry; // NULL: packet with 802.11 RA field is multicast/broadcast address
- HTTRANSMIT_SETTING *pTransmit;
-
- // Following structure used for the characteristics of a specific packet.
- PNDIS_PACKET pPacket;
- PUCHAR pSrcBufHeader; // Reference to the head of sk_buff->data
- PUCHAR pSrcBufData; // Reference to the sk_buff->data, will changed depends on hanlding progresss
- UINT SrcBufLen; // Length of packet payload which not including Layer 2 header
- PUCHAR pExtraLlcSnapEncap; // NULL means no extra LLC/SNAP is required
- UCHAR HeaderBuf[80]; // TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP
- UCHAR MpduHeaderLen; // 802.11 header length NOT including the padding
- UCHAR HdrPadLen; // recording Header Padding Length;
- UCHAR apidx; // The interface associated to this packet
- UCHAR Wcid; // The MAC entry associated to this packet
- UCHAR UserPriority; // priority class of packet
- UCHAR FrameGap; // what kind of IFS this packet use
- UCHAR MpduReqNum; // number of fragments of this frame
- UCHAR TxRate; // TODO: Obsoleted? Should change to MCS?
- UCHAR CipherAlg; // cipher alogrithm
- PCIPHER_KEY pKey;
-
-
-
- USHORT Flags; //See following definitions for detail.
-
- //YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer.
- ULONG Priv; // Hardware specific value saved in here.
-} TX_BLK, *PTX_BLK;
-
-
-#define fTX_bRtsRequired 0x0001 // Indicate if need send RTS frame for protection. Not used in RT2860/RT2870.
-#define fTX_bAckRequired 0x0002 // the packet need ack response
-#define fTX_bPiggyBack 0x0004 // Legacy device use Piggback or not
-#define fTX_bHTRate 0x0008 // allow to use HT rate
-//#define fTX_bForceLowRate 0x0010 // force to use Low Rate
-#define fTX_bForceNonQoS 0x0010 // force to transmit frame without WMM-QoS in HT mode
-#define fTX_bAllowFrag 0x0020 // allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment
-#define fTX_bMoreData 0x0040 // there are more data packets in PowerSave Queue
-#define fTX_bWMM 0x0080 // QOS Data
-
-#define fTX_bClearEAPFrame 0x0100
-
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
-
-
-#define TX_BLK_ASSIGN_FLAG(_pTxBlk, _flag, value) \
- do { \
- if (value) \
- (_pTxBlk->Flags |= _flag) \
- else \
- (_pTxBlk->Flags &= ~(_flag)) \
- }while(0)
-
-#define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
-#define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
-#define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags &= ~(_flag))
-
-
-
-
-
-//------------------------------------------------------------------------------------------
-
-
-
-#ifdef RT_BIG_ENDIAN
-static inline VOID WriteBackToDescriptor(
- IN PUCHAR Dest,
- IN PUCHAR Src,
- IN BOOLEAN DoEncrypt,
- IN ULONG DescriptorType)
-{
- UINT32 *p1, *p2;
-
- p1 = ((UINT32 *)Dest);
- p2 = ((UINT32 *)Src);
-
- *p1 = *p2;
- *(p1+2) = *(p2+2);
- *(p1+3) = *(p2+3);
- *(p1+1) = *(p2+1); // Word 1; this must be written back last
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of Tx/Rx descriptor .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to Tx/Rx descriptor
- DescriptorType Direction of the frame
-
- Return Value:
- None
-
- Note:
- Call this function when read or update descriptor
- ========================================================================
-*/
-static inline VOID RTMPWIEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType)
-{
- int size;
- int i;
-
- size = ((DescriptorType == TYPE_TXWI) ? TXWI_SIZE : RXWI_SIZE);
-
- if(DescriptorType == TYPE_TXWI)
- {
- *((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData))); // Byte 0~3
- *((UINT32 *)(pData + 4)) = SWAP32(*((UINT32 *)(pData+4))); // Byte 4~7
- }
- else
- {
- for(i=0; i < size/4 ; i++)
- *(((UINT32 *)pData) +i) = SWAP32(*(((UINT32 *)pData)+i));
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of Tx/Rx descriptor .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to Tx/Rx descriptor
- DescriptorType Direction of the frame
-
- Return Value:
- None
-
- Note:
- Call this function when read or update descriptor
- ========================================================================
-*/
-
-#ifdef RT2870
-static inline VOID RTMPDescriptorEndianChange(
- IN PUCHAR pData,
- IN ULONG DescriptorType)
-{
- *((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData)));
-}
-#endif // RT2870 //
-/*
- ========================================================================
-
- Routine Description:
- Endian conversion of all kinds of 802.11 frames .
-
- Arguments:
- pAd Pointer to our adapter
- pData Pointer to the 802.11 frame structure
- Dir Direction of the frame
- FromRxDoneInt Caller is from RxDone interrupt
-
- Return Value:
- None
-
- Note:
- Call this function when read or update buffer data
- ========================================================================
-*/
-static inline VOID RTMPFrameEndianChange(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG Dir,
- IN BOOLEAN FromRxDoneInt)
-{
- PHEADER_802_11 pFrame;
- PUCHAR pMacHdr;
-
- // swab 16 bit fields - Frame Control field
- if(Dir == DIR_READ)
- {
- *(USHORT *)pData = SWAP16(*(USHORT *)pData);
- }
-
- pFrame = (PHEADER_802_11) pData;
- pMacHdr = (PUCHAR) pFrame;
-
- // swab 16 bit fields - Duration/ID field
- *(USHORT *)(pMacHdr + 2) = SWAP16(*(USHORT *)(pMacHdr + 2));
-
- // swab 16 bit fields - Sequence Control field
- *(USHORT *)(pMacHdr + 22) = SWAP16(*(USHORT *)(pMacHdr + 22));
-
- if(pFrame->FC.Type == BTYPE_MGMT)
- {
- switch(pFrame->FC.SubType)
- {
- case SUBTYPE_ASSOC_REQ:
- case SUBTYPE_REASSOC_REQ:
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Listen Interval field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_ASSOC_RSP:
- case SUBTYPE_REASSOC_RSP:
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Status Code field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - AID field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_AUTH:
- // If from APHandleRxDoneInterrupt routine, it is still a encrypt format.
- // The convertion is delayed to RTMPHandleDecryptionDoneInterrupt.
- if(!FromRxDoneInt && pFrame->FC.Wep == 1)
- break;
- else
- {
- // swab 16 bit fields - Auth Alg No. field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Auth Seq No. field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - Status Code field
- pMacHdr += 2;
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- }
- break;
-
- case SUBTYPE_BEACON:
- case SUBTYPE_PROBE_RSP:
- // swab 16 bit fields - BeaconInterval field
- pMacHdr += (sizeof(HEADER_802_11) + TIMESTAMP_LEN);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
-
- // swab 16 bit fields - CapabilityInfo field
- pMacHdr += sizeof(USHORT);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
-
- case SUBTYPE_DEAUTH:
- case SUBTYPE_DISASSOC:
- // swab 16 bit fields - Reason code field
- pMacHdr += sizeof(HEADER_802_11);
- *(USHORT *)pMacHdr = SWAP16(*(USHORT *)pMacHdr);
- break;
- }
- }
- else if( pFrame->FC.Type == BTYPE_DATA )
- {
- }
- else if(pFrame->FC.Type == BTYPE_CNTL)
- {
- switch(pFrame->FC.SubType)
- {
- case SUBTYPE_BLOCK_ACK_REQ:
- {
- PFRAME_BA_REQ pBAReq = (PFRAME_BA_REQ)pFrame;
- *(USHORT *)(&pBAReq->BARControl) = SWAP16(*(USHORT *)(&pBAReq->BARControl));
- pBAReq->BAStartingSeq.word = SWAP16(pBAReq->BAStartingSeq.word);
- }
- break;
- case SUBTYPE_BLOCK_ACK:
- // For Block Ack packet, the HT_CONTROL field is in the same offset with Addr3
- *(UINT32 *)(&pFrame->Addr3[0]) = SWAP32(*(UINT32 *)(&pFrame->Addr3[0]));
- break;
-
- case SUBTYPE_ACK:
- //For ACK packet, the HT_CONTROL field is in the same offset with Addr2
- *(UINT32 *)(&pFrame->Addr2[0])= SWAP32(*(UINT32 *)(&pFrame->Addr2[0]));
- break;
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR,("Invalid Frame Type!!!\n"));
- }
-
- // swab 16 bit fields - Frame Control
- if(Dir == DIR_WRITE)
- {
- *(USHORT *)pData = SWAP16(*(USHORT *)pData);
- }
-}
-#endif // RT_BIG_ENDIAN //
-
-
-static inline VOID ConvertMulticastIP2MAC(
- IN PUCHAR pIpAddr,
- IN PUCHAR *ppMacAddr,
- IN UINT16 ProtoType)
-{
- if (pIpAddr == NULL)
- return;
-
- if (ppMacAddr == NULL || *ppMacAddr == NULL)
- return;
-
- switch (ProtoType)
- {
- case ETH_P_IPV6:
-// memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
- *(*ppMacAddr) = 0x33;
- *(*ppMacAddr + 1) = 0x33;
- *(*ppMacAddr + 2) = pIpAddr[12];
- *(*ppMacAddr + 3) = pIpAddr[13];
- *(*ppMacAddr + 4) = pIpAddr[14];
- *(*ppMacAddr + 5) = pIpAddr[15];
- break;
-
- case ETH_P_IP:
- default:
-// memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
- *(*ppMacAddr) = 0x01;
- *(*ppMacAddr + 1) = 0x00;
- *(*ppMacAddr + 2) = 0x5e;
- *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
- *(*ppMacAddr + 4) = pIpAddr[2];
- *(*ppMacAddr + 5) = pIpAddr[3];
- break;
- }
-
- return;
-}
-
-BOOLEAN RTMPCheckForHang(
- IN NDIS_HANDLE MiniportAdapterContext
- );
-
-VOID RTMPHalt(
- IN NDIS_HANDLE MiniportAdapterContext
- );
-
-//
-// Private routines in rtmp_init.c
-//
-NDIS_STATUS RTMPAllocAdapterBlock(
- IN PVOID handle,
- OUT PRTMP_ADAPTER *ppAdapter
- );
-
-NDIS_STATUS RTMPAllocTxRxRingMemory(
- IN PRTMP_ADAPTER pAd
- );
-
-NDIS_STATUS RTMPFindAdapter(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_HANDLE WrapperConfigurationContext
- );
-
-NDIS_STATUS RTMPReadParametersHook(
- IN PRTMP_ADAPTER pAd
- );
-
-VOID RTMPFreeAdapter(
- IN PRTMP_ADAPTER pAd
- );
-
-NDIS_STATUS NICReadRegParameters(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_HANDLE WrapperConfigurationContext
- );
-
-#ifdef RT30xx
-VOID NICInitRT30xxRFRegisters(
- IN PRTMP_ADAPTER pAd);
-#endif // RT30xx //
-
-VOID NICReadEEPROMParameters(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mac_addr);
-
-VOID NICInitAsicFromEEPROM(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICInitTxRxRingAndBacklogQueue(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICInitializeAdapter(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset);
-
-NDIS_STATUS NICInitializeAsic(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bHardReset);
-
-VOID NICIssueReset(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPRingCleanUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RingType);
-
-VOID RxTest(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS DbgSendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-VOID UserCfgInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICResetFromError(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICEraseFirmware(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICLoadFirmware(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICLoadRateSwitchingParams(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN NICCheckForHang(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICUpdateFifoStaCounters(
- IN PRTMP_ADAPTER pAd);
-
-VOID NICUpdateRawCounters(
- IN PRTMP_ADAPTER pAd);
-
-ULONG RTMPNotAllZero(
- IN PVOID pSrc1,
- IN ULONG Length);
-
-VOID RTMPZeroMemory(
- IN PVOID pSrc,
- IN ULONG Length);
-
-ULONG RTMPCompareMemory(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- IN ULONG Length);
-
-VOID RTMPMoveMemory(
- OUT PVOID pDest,
- IN PVOID pSrc,
- IN ULONG Length);
-
-VOID AtoH(
- char *src,
- UCHAR *dest,
- int destlen);
-
-UCHAR BtoH(
- char ch);
-
-VOID RTMPPatchMacBbpBug(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPPatchCardBus(
- IN PRTMP_ADAPTER pAdapter);
-
-VOID RTMPPatchRalinkCardBus(
- IN PRTMP_ADAPTER pAdapter,
- IN ULONG Bus);
-
-ULONG RTMPReadCBConfig(
- IN ULONG Bus,
- IN ULONG Slot,
- IN ULONG Func,
- IN ULONG Offset);
-
-VOID RTMPWriteCBConfig(
- IN ULONG Bus,
- IN ULONG Slot,
- IN ULONG Func,
- IN ULONG Offset,
- IN ULONG Value);
-
-VOID RTMPInitTimer(
- IN PRTMP_ADAPTER pAd,
- IN PRALINK_TIMER_STRUCT pTimer,
- IN PVOID pTimerFunc,
- IN PVOID pData,
- IN BOOLEAN Repeat);
-
-VOID RTMPSetTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value);
-
-
-VOID RTMPModTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- IN ULONG Value);
-
-VOID RTMPCancelTimer(
- IN PRALINK_TIMER_STRUCT pTimer,
- OUT BOOLEAN *pCancelled);
-
-VOID RTMPSetLED(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Status);
-
-VOID RTMPSetSignalLED(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_802_11_RSSI Dbm);
-
-VOID RTMPEnableRxTx(
- IN PRTMP_ADAPTER pAd);
-
-//
-// prototype in action.c
-//
-VOID ActionStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeADDBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDELBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeInvalidAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef DOT11_N_SUPPORT
-VOID PeerAddBAReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAddBARspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDelBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBAAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // DOT11_N_SUPPORT //
-
-VOID SendPSMPAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Psmp);
-
-
-#ifdef DOT11N_DRAFT3
-VOID SendBSS2040CoexistMgmtAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx,
- IN UCHAR InfoReq);
-
-VOID SendNotifyBWActionFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR apidx);
-
-BOOLEAN ChannelSwitchSanityCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR NewChannel,
- IN UCHAR Secondary);
-
-VOID ChannelSwitchAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR Channel,
- IN UCHAR Secondary);
-
-ULONG BuildIntolerantChannelRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest);
-
-VOID Update2040CoexistFrameAndNotify(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha);
-
-VOID Send2040CoexistAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN BOOLEAN bAddIntolerantCha);
-#endif // DOT11N_DRAFT3 //
-
-VOID PeerRMAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID StaPublicAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Bss2040Coexist);
-#endif // CONFIG_STA_SUPPORT //
-
-
-VOID PeerBSSTranAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef DOT11_N_SUPPORT
-VOID PeerHTAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // DOT11_N_SUPPORT //
-
-VOID PeerQOSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef QOS_DLS_SUPPORT
-VOID PeerDLSAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // QOS_DLS_SUPPORT //
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-VOID DlsParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
- IN PRT_802_11_DLS pDls,
- IN USHORT reason);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
-VOID RECBATimerTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID ORIBATimerTimeout(
- IN PRTMP_ADAPTER pAd);
-
-VOID SendRefreshBAR(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry);
-#endif // DOT11_N_SUPPORT //
-
-VOID ActHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN PUCHAR Addr1,
- IN PUCHAR Addr2,
- IN PUCHAR Addr3);
-
-VOID BarHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PFRAME_BAR pCntlBar,
- IN PUCHAR pDA,
- IN PUCHAR pSA);
-
-VOID InsertActField(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pFrameBuf,
- OUT PULONG pFrameLen,
- IN UINT8 Category,
- IN UINT8 ActCode);
-
-BOOLEAN QosBADataParse(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bAMSDU,
- IN PUCHAR p8023Header,
- IN UCHAR WCID,
- IN UCHAR TID,
- IN USHORT Sequence,
- IN UCHAR DataOffset,
- IN USHORT Datasize,
- IN UINT CurRxIndex);
-
-#ifdef DOT11_N_SUPPORT
-BOOLEAN CntlEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG MsgLen,
- IN PFRAME_BA_REQ pMsg);
-
-VOID BaAutoManSwitch(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11_N_SUPPORT //
-
-VOID HTIOTCheck(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BatRecIdx);
-
-//
-// Private routines in rtmp_data.c
-//
-BOOLEAN RTMPHandleRxDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandleTxDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(
- IN PRTMP_ADAPTER pAd,
- IN INT_SOURCE_CSR_STRUC TxRingBitmap);
-
-VOID RTMPHandleMgmtRingDmaDoneInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandleTBTTInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandlePreTBTTInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-void RTMPHandleTwakeupInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPHandleRxCoherentInterrupt(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN TxFrameIsAggregatible(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pPrevAddr1,
- IN PUCHAR p8023hdr);
-
-BOOLEAN PeerIsAggreOn(
- IN PRTMP_ADAPTER pAd,
- IN ULONG TxRate,
- IN PMAC_TABLE_ENTRY pMacEntry);
-
-NDIS_STATUS Sniff2BytesFromNdisBuffer(
- IN PNDIS_BUFFER pFirstBuffer,
- IN UCHAR DesiredOffset,
- OUT PUCHAR pByte0,
- OUT PUCHAR pByte1);
-
-NDIS_STATUS STASendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-VOID STASendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets);
-
-VOID RTMPDeQueuePacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bIntContext,
- IN UCHAR QueIdx,
- IN UCHAR Max_Tx_Packets);
-
-NDIS_STATUS RTMPHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR QueIdx,
- OUT PULONG pFreeTXDLeft);
-
-NDIS_STATUS STAHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx);
-
-VOID STARxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-NDIS_STATUS RTMPFreeTXDRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RingType,
- IN UCHAR NumberRequired,
- IN PUCHAR FreeNumberIs);
-
-NDIS_STATUS MlmeHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-NDIS_STATUS MlmeHardTransmitMgmtRing(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-NDIS_STATUS MlmeHardTransmitTxRing(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket);
-
-USHORT RTMPCalcDuration(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Rate,
- IN ULONG Size);
-
-VOID RTMPWriteTxWI(
- IN PRTMP_ADAPTER pAd,
- IN PTXWI_STRUC pTxWI,
- IN BOOLEAN FRAG,
- IN BOOLEAN CFACK,
- IN BOOLEAN InsTimestamp,
- IN BOOLEAN AMPDU,
- IN BOOLEAN Ack,
- IN BOOLEAN NSeq, // HW new a sequence.
- IN UCHAR BASize,
- IN UCHAR WCID,
- IN ULONG Length,
- IN UCHAR PID,
- IN UCHAR TID,
- IN UCHAR TxRate,
- IN UCHAR Txopmode,
- IN BOOLEAN CfAck,
- IN HTTRANSMIT_SETTING *pTransmit);
-
-
-VOID RTMPWriteTxWI_Data(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk);
-
-
-VOID RTMPWriteTxWI_Cache(
- IN PRTMP_ADAPTER pAd,
- IN OUT PTXWI_STRUC pTxWI,
- IN TX_BLK *pTxBlk);
-
-VOID RTMPWriteTxDescriptor(
- IN PRTMP_ADAPTER pAd,
- IN PTXD_STRUC pTxD,
- IN BOOLEAN bWIV,
- IN UCHAR QSEL);
-
-VOID RTMPSuspendMsduTransmission(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPResumeMsduTransmission(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS MiniportMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length);
-
-NDIS_STATUS MiniportDataMMRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN PUCHAR pData,
- IN UINT Length);
-
-VOID RTMPSendNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull);
-
-VOID RTMPSendDisassociationFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPSendRTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN unsigned int NextMpduSize,
- IN UCHAR TxRate,
- IN UCHAR RTSRate,
- IN USHORT AckDuration,
- IN UCHAR QueIdx,
- IN UCHAR FrameGap);
-
-
-NDIS_STATUS RTMPApplyPacketFilter(
- IN PRTMP_ADAPTER pAd,
- IN PRT28XX_RXD_STRUC pRxD,
- IN PHEADER_802_11 pHeader);
-
-PQUEUE_HEADER RTMPCheckTxSwQueue(
- IN PRTMP_ADAPTER pAd,
- OUT UCHAR *QueIdx);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPReportMicError(
- IN PRTMP_ADAPTER pAd,
- IN PCIPHER_KEY pWpaKey);
-
-VOID WpaMicFailureReportFrame(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaDisassocApAndBlockAssoc(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-#endif // CONFIG_STA_SUPPORT //
-
-NDIS_STATUS RTMPCloneNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN pInsAMSDUHdr,
- IN PNDIS_PACKET pInPacket,
- OUT PNDIS_PACKET *ppOutPacket);
-
-NDIS_STATUS RTMPAllocateNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET *pPacket,
- IN PUCHAR pHeader,
- IN UINT HeaderLen,
- IN PUCHAR pData,
- IN UINT DataLen);
-
-VOID RTMPFreeNdisPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-BOOLEAN RTMPFreeTXDUponTxDmaDone(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx);
-
-BOOLEAN RTMPCheckDHCPFrame(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-BOOLEAN RTMPCheckEtherType(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-VOID RTMPCckBbpTuning(
- IN PRTMP_ADAPTER pAd,
- IN UINT TxRate);
-
-//
-// Private routines in rtmp_wep.c
-//
-VOID RTMPInitWepEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN UCHAR KeyId,
- IN UCHAR KeyLen,
- IN PUCHAR pDest);
-
-VOID RTMPEncryptData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDest,
- IN UINT Len);
-
-BOOLEAN RTMPDecryptData(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR pSrc,
- IN UINT Len,
- IN UINT idx);
-
-BOOLEAN RTMPSoftDecryptWEP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pGroupKey);
-
-VOID RTMPSetICV(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDest);
-
-VOID ARCFOUR_INIT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pKey,
- IN UINT KeyLen);
-
-UCHAR ARCFOUR_BYTE(
- IN PARCFOURCONTEXT Ctx);
-
-VOID ARCFOUR_DECRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len);
-
-VOID ARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len);
-
-VOID WPAARCFOUR_ENCRYPT(
- IN PARCFOURCONTEXT Ctx,
- IN PUCHAR pDest,
- IN PUCHAR pSrc,
- IN UINT Len);
-
-UINT RTMP_CALC_FCS32(
- IN UINT Fcs,
- IN PUCHAR Cp,
- IN INT Len);
-
-//
-// MLME routines
-//
-
-// Asic/RF/BBP related functions
-
-VOID AsicAdjustTxPower(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicUpdateProtect(
- IN PRTMP_ADAPTER pAd,
- IN USHORT OperaionMode,
- IN UCHAR SetMask,
- IN BOOLEAN bDisableBGProtect,
- IN BOOLEAN bNonGFExist);
-
-VOID AsicSwitchChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel,
- IN BOOLEAN bScan);
-
-VOID AsicLockChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel) ;
-
-VOID AsicAntennaSelect(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel);
-
-VOID AsicAntennaSetting(
- IN PRTMP_ADAPTER pAd,
- IN ABGBAND_STATE BandState);
-
-VOID AsicRfTuningExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID AsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp);
-
-VOID AsicForceSleep(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx);
-#endif // CONFIG_STA_SUPPORT //
-
-VOID AsicSetBssid(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid);
-
-VOID AsicSetMcastWC(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicDelWcidTab(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid);
-
-VOID AsicEnableRDG(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicDisableRDG(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicDisableSync(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicEnableBssSync(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicEnableIbssSync(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicSetEdcaParm(
- IN PRTMP_ADAPTER pAd,
- IN PEDCA_PARM pEdcaParm);
-
-VOID AsicSetSlotTime(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUseShortSlotTime);
-
-VOID AsicAddSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN PUCHAR pKey,
- IN PUCHAR pTxMic,
- IN PUCHAR pRxMic);
-
-VOID AsicRemoveSharedKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx);
-
-VOID AsicUpdateWCIDAttribute(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR CipherAlg,
- IN BOOLEAN bUsePairewiseKeyTable);
-
-VOID AsicUpdateWCIDIVEIV(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN ULONG uIV,
- IN ULONG uEIV);
-
-VOID AsicUpdateRxWCIDTable(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN PUCHAR pAddr);
-
-VOID AsicAddKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT WCID,
- IN UCHAR BssIndex,
- IN UCHAR KeyIdx,
- IN PCIPHER_KEY pCipherKey,
- IN BOOLEAN bUsePairewiseKeyTable,
- IN BOOLEAN bTxKey);
-
-VOID AsicAddPairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UCHAR WCID,
- IN CIPHER_KEY *pCipherKey);
-
-VOID AsicRemovePairwiseKeyEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR Wcid);
-
-BOOLEAN AsicSendCommandToMcu(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Command,
- IN UCHAR Token,
- IN UCHAR Arg0,
- IN UCHAR Arg1);
-
-
-VOID MacAddrRandomBssid(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pAddr);
-
-VOID MgtMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR SubType,
- IN UCHAR ToDs,
- IN PUCHAR pDA,
- IN PUCHAR pBssid);
-
-VOID MlmeRadioOff(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeRadioOn(
- IN PRTMP_ADAPTER pAd);
-
-
-VOID BssTableInit(
- IN BSS_TABLE *Tab);
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableInit(
- IN PRTMP_ADAPTER pAd,
- IN BA_TABLE *Tab);
-#endif // DOT11_N_SUPPORT //
-
-ULONG BssTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN UCHAR Channel);
-
-ULONG BssSsidTableSearch(
- IN BSS_TABLE *Tab,
- IN PUCHAR pBssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel);
-
-ULONG BssTableSearchWithSSID(
- IN BSS_TABLE *Tab,
- IN PUCHAR Bssid,
- IN PUCHAR pSsid,
- IN UCHAR SsidLen,
- IN UCHAR Channel);
-
-VOID BssTableDeleteEntry(
- IN OUT PBSS_TABLE pTab,
- IN PUCHAR pBssid,
- IN UCHAR Channel);
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableDeleteORIEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN BA_ORI_ENTRY *pBAORIEntry);
-
-VOID BATableDeleteRECEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN BA_REC_ENTRY *pBARECEntry);
-
-VOID BATableTearORIEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR TID,
- IN UCHAR Wcid,
- IN BOOLEAN bForceDelete,
- IN BOOLEAN ALL);
-
-VOID BATableTearRECEntry(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR TID,
- IN UCHAR WCID,
- IN BOOLEAN ALL);
-#endif // DOT11_N_SUPPORT //
-
-VOID BssEntrySet(
- IN PRTMP_ADAPTER pAd,
- OUT PBSS_ENTRY pBss,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN PCF_PARM CfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR Channel,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE);
-
-ULONG BssTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT PBSS_TABLE pTab,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN USHORT BeaconPeriod,
- IN CF_PARM *CfParm,
- IN USHORT AtimWin,
- IN USHORT CapabilityInfo,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- IN UCHAR HtCapabilityLen,
- IN UCHAR AddHtInfoLen,
- IN UCHAR NewExtChanOffset,
- IN UCHAR Channel,
- IN CHAR Rssi,
- IN LARGE_INTEGER TimeStamp,
- IN UCHAR CkipFlag,
- IN PEDCA_PARM pEdcaParm,
- IN PQOS_CAPABILITY_PARM pQosCapability,
- IN PQBSS_LOAD_PARM pQbssLoad,
- IN USHORT LengthVIE,
- IN PNDIS_802_11_VARIABLE_IEs pVIE);
-
-#ifdef DOT11_N_SUPPORT
-VOID BATableInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Aid,
- IN USHORT TimeOutValue,
- IN USHORT StartingSeq,
- IN UCHAR TID,
- IN UCHAR BAWinSize,
- IN UCHAR OriginatorStatus,
- IN BOOLEAN IsRecipient);
-
-#ifdef DOT11N_DRAFT3
-VOID Bss2040CoexistTimeOut(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-
-VOID TriEventInit(
- IN PRTMP_ADAPTER pAd);
-
-ULONG TriEventTableSetEntry(
- IN PRTMP_ADAPTER pAd,
- OUT TRIGGER_EVENT_TAB *Tab,
- IN PUCHAR pBssid,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN UCHAR RegClass,
- IN UCHAR ChannelNo);
-
-VOID TriEventCounterMaintenance(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-VOID BssTableSsidSort(
- IN PRTMP_ADAPTER pAd,
- OUT BSS_TABLE *OutTab,
- IN CHAR Ssid[],
- IN UCHAR SsidLen);
-
-VOID BssTableSortByRssi(
- IN OUT BSS_TABLE *OutTab);
-
-VOID BssCipherParse(
- IN OUT PBSS_ENTRY pBss);
-
-NDIS_STATUS MlmeQueueInit(
- IN MLME_QUEUE *Queue);
-
-VOID MlmeQueueDestroy(
- IN MLME_QUEUE *Queue);
-
-BOOLEAN MlmeEnqueue(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Machine,
- IN ULONG MsgType,
- IN ULONG MsgLen,
- IN VOID *Msg);
-
-BOOLEAN MlmeEnqueueForRecv(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid,
- IN ULONG TimeStampHigh,
- IN ULONG TimeStampLow,
- IN UCHAR Rssi0,
- IN UCHAR Rssi1,
- IN UCHAR Rssi2,
- IN ULONG MsgLen,
- IN PVOID Msg,
- IN UCHAR Signal);
-
-
-BOOLEAN MlmeDequeue(
- IN MLME_QUEUE *Queue,
- OUT MLME_QUEUE_ELEM **Elem);
-
-VOID MlmeRestartStateMachine(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeQueueEmpty(
- IN MLME_QUEUE *Queue);
-
-BOOLEAN MlmeQueueFull(
- IN MLME_QUEUE *Queue);
-
-BOOLEAN MsgTypeSubst(
- IN PRTMP_ADAPTER pAd,
- IN PFRAME_802_11 pFrame,
- OUT INT *Machine,
- OUT INT *MsgType);
-
-VOID StateMachineInit(
- IN STATE_MACHINE *Sm,
- IN STATE_MACHINE_FUNC Trans[],
- IN ULONG StNr,
- IN ULONG MsgNr,
- IN STATE_MACHINE_FUNC DefFunc,
- IN ULONG InitState,
- IN ULONG Base);
-
-VOID StateMachineSetAction(
- IN STATE_MACHINE *S,
- IN ULONG St,
- ULONG Msg,
- IN STATE_MACHINE_FUNC F);
-
-VOID StateMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Drop(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID ReassocTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID AssocTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID DisassocTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-//----------------------------------------------
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAssocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerReassocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDisassocAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID DisassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AssocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ReassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Cls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr);
-
-VOID SwitchBetweenWepAndCkip(
- IN PRTMP_ADAPTER pAd);
-
-VOID InvalidStateWhenAssoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenReassoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenDisassociate(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef RT2870
-VOID MlmeCntlConfirm(
- IN PRTMP_ADAPTER pAd,
- IN ULONG MsgType,
- IN USHORT Msg);
-#endif // RT2870 //
-
-VOID ComposePsPoll(
- IN PRTMP_ADAPTER pAd);
-
-VOID ComposeNullFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID AssocPostProc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr2,
- IN USHORT CapabilityInfo,
- IN USHORT Aid,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN PEDCA_PARM pEdcaParm,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN ADD_HT_INFO_IE *pAddHtInfo);
-
-VOID AuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID AuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID MlmeAuthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthRspAtSeq2Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthRspAtSeq4Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AuthTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Cls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr);
-
-VOID MlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenAuth(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-//=============================================
-
-VOID AuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[]);
-
-VOID PeerDeauthAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT Reason,
- IN USHORT Status);
-
-//
-// Private routines in dls.c
-//
-
-#ifdef CONFIG_STA_SUPPORT
-#ifdef QOS_DLS_SUPPORT
-void DlsStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID RTMPCheckDLSTimeOut(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPRcvFrameDLSCheck(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN ULONG Len,
- IN PRT28XX_RXD_STRUC pRxD);
-
-INT RTMPCheckDLSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-NDIS_STATUS RTMPSendSTAKeyRequest(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-NDIS_STATUS RTMPSendSTAKeyHandShake(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-VOID DlsTimeoutAction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN MlmeDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PRT_802_11_DLS *pDLS,
- OUT PUSHORT pReason);
-
-INT Set_DlsEntryInfo_Display_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UINT DlsEntryIdx);
-
-BOOLEAN MacTableDeleteDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr);
-
-MAC_TABLE_ENTRY *DlsEntryTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount);
-
-MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR wcid,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount);
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_DlsTearDownEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef QOS_DLS_SUPPORT
-BOOLEAN PeerDlsReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pDlsTimeout,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDlsRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT UCHAR *pRatesLen,
- OUT UCHAR Rates[],
- OUT UCHAR *pHtCapabilityLen,
- OUT HT_CAPABILITY_IE *pHtCapability);
-
-BOOLEAN PeerDlsTearDownSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pDA,
- OUT PUCHAR pSA,
- OUT USHORT *pReason);
-#endif // QOS_DLS_SUPPORT //
-
-//========================================
-
-VOID SyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID BeaconTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID ScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenJoin(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenStart(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID EnqueueProbeRequest(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN ScanRunning(
- IN PRTMP_ADAPTER pAd);
-//=========================================
-
-VOID MlmeCntlInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeCntlMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlIdleProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlOidScanProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlOidSsidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem);
-
-VOID CntlOidRTBssidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem);
-
-VOID CntlMlmeRoamingProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem);
-
-VOID CntlWaitDisassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitJoinProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitReassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitStartProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAuthProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAuthProc2(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAssocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-#ifdef QOS_DLS_SUPPORT
-VOID CntlOidDLSSetupProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-#endif // QOS_DLS_SUPPORT //
-
-VOID LinkUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssType);
-
-VOID LinkDown(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN IsReqFromAP);
-
-VOID IterateOnBssTab(
- IN PRTMP_ADAPTER pAd);
-
-VOID IterateOnBssTab2(
- IN PRTMP_ADAPTER pAd);;
-
-VOID JoinParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
- IN ULONG BssIdx);
-
-VOID AssocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
- IN PUCHAR pAddr,
- IN USHORT CapabilityInfo,
- IN ULONG Timeout,
- IN USHORT ListenIntv);
-
-VOID ScanParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN UCHAR ScanType);
-
-VOID DisassocParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
- IN PUCHAR pAddr,
- IN USHORT Reason);
-
-VOID StartParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_START_REQ_STRUCT *StartReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen);
-
-VOID AuthParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
- IN PUCHAR pAddr,
- IN USHORT Alg);
-
-VOID EnqueuePsPoll(
- IN PRTMP_ADAPTER pAd);
-
-VOID EnqueueBeaconFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeJoinReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeStartReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID BeaconTimeoutAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeaconAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ScanNextChannel(
- IN PRTMP_ADAPTER pAd);
-
-ULONG MakeIbssBeacon(
- IN PRTMP_ADAPTER pAd);
-
-VOID CCXAdjacentAPReport(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeScanReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT UCHAR *BssType,
- OUT CHAR ssid[],
- OUT UCHAR *SsidLen,
- OUT UCHAR *ScanType);
-
-BOOLEAN PeerBeaconAndProbeRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- IN UCHAR MsgChannel,
- OUT PUCHAR pAddr2,
- OUT PUCHAR pBssid,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen,
- OUT UCHAR *pBssType,
- OUT USHORT *pBeaconPeriod,
- OUT UCHAR *pChannel,
- OUT UCHAR *pNewChannel,
- OUT LARGE_INTEGER *pTimestamp,
- OUT CF_PARM *pCfParm,
- OUT USHORT *pAtimWin,
- OUT USHORT *pCapabilityInfo,
- OUT UCHAR *pErp,
- OUT UCHAR *pDtimCount,
- OUT UCHAR *pDtimPeriod,
- OUT UCHAR *pBcastFlag,
- OUT UCHAR *pMessageToMe,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT UCHAR *pCkipFlag,
- OUT UCHAR *pAironetCellPowerLimit,
- OUT PEDCA_PARM pEdcaParm,
- OUT PQBSS_LOAD_PARM pQbssLoad,
- OUT PQOS_CAPABILITY_PARM pQosCapability,
- OUT ULONG *pRalinkIe,
- OUT UCHAR *pHtCapabilityLen,
-#ifdef CONFIG_STA_SUPPORT
- OUT UCHAR *pPreNHtCapabilityLen,
-#endif // CONFIG_STA_SUPPORT //
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT UCHAR *AddHtInfoLen,
- OUT ADD_HT_INFO_IE *AddHtInfo,
- OUT UCHAR *NewExtChannel,
- OUT USHORT *LengthVIE,
- OUT PNDIS_802_11_VARIABLE_IEs pVIE);
-
-BOOLEAN PeerAddBAReqActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2);
-
-BOOLEAN PeerAddBARspActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen);
-
-BOOLEAN PeerDelBAActionSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN VOID *pMsg,
- IN ULONG MsgLen);
-
-BOOLEAN MlmeAssocReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pApAddr,
- OUT USHORT *CapabilityInfo,
- OUT ULONG *Timeout,
- OUT USHORT *ListenIntv);
-
-BOOLEAN MlmeAuthReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT ULONG *Timeout,
- OUT USHORT *Alg);
-
-BOOLEAN MlmeStartReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT CHAR Ssid[],
- OUT UCHAR *Ssidlen);
-
-BOOLEAN PeerAuthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr,
- OUT USHORT *Alg,
- OUT USHORT *Seq,
- OUT USHORT *Status,
- OUT CHAR ChlgText[]);
-
-BOOLEAN PeerAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT USHORT *pAid,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- OUT UCHAR *pHtCapabilityLen,
- OUT UCHAR *pAddHtInfoLen,
- OUT UCHAR *pNewExtChannelOffset,
- OUT PEDCA_PARM pEdcaParm,
- OUT UCHAR *pCkipFlag);
-
-BOOLEAN PeerDisassocSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN PeerWpaMessageSanity(
- IN PRTMP_ADAPTER pAd,
- IN PEAPOL_PACKET pMsg,
- IN ULONG MsgLen,
- IN UCHAR MsgType,
- IN MAC_TABLE_ENTRY *pEntry);
-
-BOOLEAN PeerDeauthSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *Reason);
-
-BOOLEAN PeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen);
-
-BOOLEAN GetTimBit(
- IN CHAR *Ptr,
- IN USHORT Aid,
- OUT UCHAR *TimLen,
- OUT UCHAR *BcastFlag,
- OUT UCHAR *DtimCount,
- OUT UCHAR *DtimPeriod,
- OUT UCHAR *MessageToMe);
-
-UCHAR ChannelSanity(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel);
-
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
- IN PBSS_ENTRY pBss);
-
-BOOLEAN MlmeDelBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen);
-
-BOOLEAN MlmeAddBAReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2);
-
-ULONG MakeOutgoingFrame(
- OUT CHAR *Buffer,
- OUT ULONG *Length, ...);
-
-VOID LfsrInit(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Seed);
-
-UCHAR RandomByte(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicUpdateAutoFallBackTable(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pTxRate);
-
-VOID MlmePeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LinkDownExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID LinkUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID STAMlmePeriodicExec(
- PRTMP_ADAPTER pAd);
-
-VOID MlmeAutoScan(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeAutoReconnectLastSSID(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeValidateSSID(
- IN PUCHAR pSsid,
- IN UCHAR SsidLen);
-
-VOID MlmeCheckForRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32);
-
-VOID MlmeCheckForFastRoaming(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now);
-
-VOID MlmeDynamicTxRateSwitching(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeSetTxRate(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PRTMP_TX_RATE_SWITCH pTxRate);
-
-VOID MlmeSelectTxRateTable(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR *ppTable,
- IN PUCHAR pTableSize,
- IN PUCHAR pInitTxRateIdx);
-
-VOID MlmeCalculateChannelQuality(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now);
-
-VOID MlmeCheckPsmChange(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Now32);
-
-VOID MlmeSetPsmBit(
- IN PRTMP_ADAPTER pAd,
- IN USHORT psm);
-
-VOID MlmeSetTxPreamble(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TxPreamble);
-
-VOID UpdateBasicRateBitmap(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeUpdateTxRates(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bLinkUp,
- IN UCHAR apidx);
-
-#ifdef DOT11_N_SUPPORT
-VOID MlmeUpdateHtTxRates(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx);
-#endif // DOT11_N_SUPPORT //
-
-VOID RTMPCheckRates(
- IN PRTMP_ADAPTER pAd,
- IN OUT UCHAR SupRate[],
- IN OUT UCHAR *SupRateLen);
-
-#ifdef CONFIG_STA_SUPPORT
-BOOLEAN RTMPCheckChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR CentralChannel,
- IN UCHAR Channel);
-#endif // CONFIG_STA_SUPPORT //
-
-BOOLEAN RTMPCheckHt(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN OUT HT_CAPABILITY_IE *pHtCapability,
- IN OUT ADD_HT_INFO_IE *pAddHtInfo);
-
-VOID StaQuickResponeForRateUpExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID AsicBbpTuning1(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicBbpTuning2(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPUpdateMlmeRate(
- IN PRTMP_ADAPTER pAd);
-
-CHAR RTMPMaxRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi0,
- IN CHAR Rssi1,
- IN CHAR Rssi2);
-
-VOID AsicSetRxAnt(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Ant);
-
-VOID AsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd);
-
-VOID AsicRxAntEvalTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID APSDPeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry);
-
-UCHAR RTMPStaFixedTxMode(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry);
-
-VOID RTMPUpdateLegacyTxSetting(
- UCHAR fixed_tx_mode,
- PMAC_TABLE_ENTRY pEntry);
-
-BOOLEAN RTMPAutoRateSwitchCheck(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS MlmeInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeHandler(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeHalt(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeResetRalinkCounters(
- IN PRTMP_ADAPTER pAd);
-
-VOID BuildChannelList(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR FirstChannel(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR NextChannel(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR channel);
-
-VOID ChangeToCellPowerLimit(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR AironetCellPowerLimit);
-
-VOID RaiseClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x);
-
-VOID LowerClock(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 *x);
-
-USHORT ShiftInBits(
- IN PRTMP_ADAPTER pAd);
-
-VOID ShiftOutBits(
- IN PRTMP_ADAPTER pAd,
- IN USHORT data,
- IN USHORT count);
-
-VOID EEpromCleanup(
- IN PRTMP_ADAPTER pAd);
-
-VOID EWDS(
- IN PRTMP_ADAPTER pAd);
-
-VOID EWEN(
- IN PRTMP_ADAPTER pAd);
-
-USHORT RTMP_EEPROM_READ16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset);
-
-VOID RTMP_EEPROM_WRITE16(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Data);
-
-//
-// Prototypes of function definition in rtmp_tkip.c
-//
-VOID RTMPInitTkipEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pTKey,
- IN UCHAR KeyId,
- IN PUCHAR pTA,
- IN PUCHAR pMICKey,
- IN PUCHAR pTSC,
- OUT PULONG pIV16,
- OUT PULONG pIV32);
-
-VOID RTMPInitMICEngine(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKey,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN UCHAR UserPriority,
- IN PUCHAR pMICKey);
-
-BOOLEAN RTMPTkipCompareMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UCHAR UserPriority,
- IN UINT Len);
-
-VOID RTMPCalculateMICValue(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pEncap,
- IN PCIPHER_KEY pKey,
- IN UCHAR apidx);
-
-BOOLEAN RTMPTkipCompareMICValueWithLLC(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pLLC,
- IN PUCHAR pSrc,
- IN PUCHAR pDA,
- IN PUCHAR pSA,
- IN PUCHAR pMICKey,
- IN UINT Len);
-
-VOID RTMPTkipAppendByte(
- IN PTKIP_KEY_INFO pTkip,
- IN UCHAR uChar);
-
-VOID RTMPTkipAppend(
- IN PTKIP_KEY_INFO pTkip,
- IN PUCHAR pSrc,
- IN UINT nBytes);
-
-VOID RTMPTkipGetMIC(
- IN PTKIP_KEY_INFO pTkip);
-
-BOOLEAN RTMPSoftDecryptTKIP(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN UCHAR UserPriority,
- IN PCIPHER_KEY pWpaKey);
-
-BOOLEAN RTMPSoftDecryptAES(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataByteCnt,
- IN PCIPHER_KEY pWpaKey);
-
-//
-// Prototypes of function definition in cmm_info.c
-//
-NDIS_STATUS RTMPWPARemoveKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-VOID RTMPWPARemoveAllKeys(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN RTMPCheckStrPrintAble(
- IN CHAR *pInPutStr,
- IN UCHAR strLen);
-
-VOID RTMPSetPhyMode(
- IN PRTMP_ADAPTER pAd,
- IN ULONG phymode);
-
-VOID RTMPUpdateHTIE(
- IN RT_HT_CAPABILITY *pRtHt,
- IN UCHAR *pMcsSet,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo);
-
-VOID RTMPAddWcidAttributeEntry(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssIdx,
- IN UCHAR KeyIdx,
- IN UCHAR CipherAlg,
- IN MAC_TABLE_ENTRY *pEntry);
-
-CHAR *GetEncryptType(
- CHAR enc);
-
-CHAR *GetAuthMode(
- CHAR auth);
-
-VOID RTMPIoctlGetSiteSurvey(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlGetMacTable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq);
-
-VOID RTMPIndicateWPA2Status(
- IN PRTMP_ADAPTER pAdapter);
-
-VOID RTMPOPModeSwitching(
- IN PRTMP_ADAPTER pAd);
-
-#ifdef CONFIG_STA_SUPPORT
-VOID RTMPAddBSSIDCipher(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Aid,
- IN PNDIS_802_11_KEY pKey,
- IN UCHAR CipherAlg);
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
-VOID RTMPSetHT(
- IN PRTMP_ADAPTER pAd,
- IN OID_SET_HT_PHYMODE *pHTPhyMode);
-
-VOID RTMPSetIndividualHT(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR apidx);
-#endif // DOT11_N_SUPPORT //
-
-VOID RTMPSendWirelessEvent(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Event_flag,
- IN PUCHAR pAddr,
- IN UCHAR BssIdx,
- IN CHAR Rssi);
-
-VOID NICUpdateCntlCounters(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN UCHAR SubType,
- IN PRXWI_STRUC pRxWI);
-//
-// prototype in wpa.c
-//
-BOOLEAN WpaMsgTypeSubst(
- IN UCHAR EAPType,
- OUT INT *MsgType);
-
-VOID WpaPskStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID WpaEAPOLKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaPairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaPairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaGroupMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID WpaMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr1);
-
-VOID Wpa2PairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID Wpa2PairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-BOOLEAN ParseKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR bPairewise);
-
-VOID RTMPToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN BOOLEAN is4wayFrame);
-
-VOID HMAC_SHA1(
- IN UCHAR *text,
- IN UINT text_len,
- IN UCHAR *key,
- IN UINT key_len,
- IN UCHAR *digest);
-
-VOID PRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *prefix,
- IN INT prefix_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len);
-
-VOID CCKMPRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len);
-
-VOID WpaCountPTK(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *PMK,
- IN UCHAR *ANonce,
- IN UCHAR *AA,
- IN UCHAR *SNonce,
- IN UCHAR *SA,
- OUT UCHAR *output,
- IN UINT len);
-
-VOID GenRandom(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR *macAddr,
- OUT UCHAR *random);
-
-//
-// prototype in aironet.c
-//
-VOID AironetStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID AironetMsgAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID AironetRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ChannelLoadRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID NoiseHistRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID BeaconRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID AironetReportAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID ChannelLoadReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID NoiseHistReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID AironetFinalReportAction(
- IN PRTMP_ADAPTER pAd);
-
-VOID BeaconReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID AironetAddBeaconReport(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Index,
- IN PMLME_QUEUE_ELEM pElem);
-
-VOID AironetCreateBeaconReportFromBssTable(
- IN PRTMP_ADAPTER pAd);
-
-VOID DBGPRINT_TX_RING(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx);
-
-VOID DBGPRINT_RX_RING(
- IN PRTMP_ADAPTER pAd);
-
-CHAR ConvertToRssi(
- IN PRTMP_ADAPTER pAd,
- IN CHAR Rssi,
- IN UCHAR RssiNumber);
-
-
-#ifdef DOT11N_DRAFT3
-VOID BuildEffectedChannelList(
- IN PRTMP_ADAPTER pAd);
-#endif // DOT11N_DRAFT3 //
-
-
-VOID APAsicEvaluateRxAnt(
- IN PRTMP_ADAPTER pAd);
-
-
-VOID APAsicRxAntEvalTimeout(
- IN PRTMP_ADAPTER pAd);
-
-//
-// function prototype in cmm_wpa.c
-//
-BOOLEAN RTMPCheckWPAframe(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN PUCHAR pData,
- IN ULONG DataByteCount,
- IN UCHAR FromWhichBSSID);
-
-VOID AES_GTK_KEY_UNWRAP(
- IN UCHAR *key,
- OUT UCHAR *plaintext,
- IN UCHAR c_len,
- IN UCHAR *ciphertext);
-
-BOOLEAN RTMPCheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- IN MAC_TABLE_ENTRY *pEntry,
- OUT UCHAR *Offset);
-
-BOOLEAN RTMPParseEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR GroupKeyIndex,
- IN UCHAR MsgType,
- IN BOOLEAN bWPA2,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID ConstructEapolMsg(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerAuthMode,
- IN UCHAR PeerWepStatus,
- IN UCHAR MyGroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN UCHAR *ReplayCounter,
- IN UCHAR *KeyNonce,
- IN UCHAR *TxRSC,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_Len,
- OUT PEAPOL_PACKET pMsg);
-
-VOID CalculateMIC(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerWepStatus,
- IN UCHAR *PTK,
- OUT PEAPOL_PACKET pMsg);
-
-NDIS_STATUS RTMPSoftDecryptBroadCastData(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN NDIS_802_11_ENCRYPTION_STATUS GroupCipher,
- IN PCIPHER_KEY pShard_key);
-
-VOID ConstructEapolKeyData(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR PeerAuthMode,
- IN UCHAR PeerWepStatus,
- IN UCHAR GroupKeyWepStatus,
- IN UCHAR MsgType,
- IN UCHAR DefaultKeyIdx,
- IN BOOLEAN bWPA2Capable,
- IN UCHAR *PTK,
- IN UCHAR *GTK,
- IN UCHAR *RSNIE,
- IN UCHAR RSNIE_LEN,
- OUT PEAPOL_PACKET pMsg);
-
-VOID RTMPMakeRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN UINT AuthMode,
- IN UINT WepStatus,
- IN UCHAR apidx);
-
-//
-// function prototype in ap_wpa.c
-//
-
-BOOLEAN APWpaMsgTypeSubst(
- IN UCHAR EAPType,
- OUT INT *MsgType) ;
-
-MAC_TABLE_ENTRY *PACInquiry(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Wcid);
-
-BOOLEAN RTMPCheckMcast(
- IN PRTMP_ADAPTER pAd,
- IN PEID_STRUCT eid_ptr,
- IN MAC_TABLE_ENTRY *pEntry);
-
-BOOLEAN RTMPCheckUcast(
- IN PRTMP_ADAPTER pAd,
- IN PEID_STRUCT eid_ptr,
- IN MAC_TABLE_ENTRY *pEntry);
-
-BOOLEAN RTMPCheckAUTH(
- IN PRTMP_ADAPTER pAd,
- IN PEID_STRUCT eid_ptr,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID WPAStart4WayHS(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN ULONG TimeInterval);
-
-VOID WPAStart2WayGroupHS(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID APWpaEAPPacketAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLStartAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLLogoffAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLASFAlertAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID HandleCounterMeasure(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry);
-
-VOID PeerPairMsg2Action(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerPairMsg4Action(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID CMTimerExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID WPARetryExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID EnqueueStartForPSKExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID RTMPHandleSTAKey(
- IN PRTMP_ADAPTER pAdapter,
- IN MAC_TABLE_ENTRY *pEntry,
- IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerGroupMsg2Action(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN VOID *Msg,
- IN UINT MsgLen);
-
-VOID PairDisAssocAction(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN USHORT Reason);
-
-VOID MlmeDeAuthAction(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN USHORT Reason);
-
-VOID GREKEYPeriodicExec(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3);
-
-VOID CountGTK(
- IN UCHAR *PMK,
- IN UCHAR *GNonce,
- IN UCHAR *AA,
- OUT UCHAR *output,
- IN UINT len);
-
-VOID GetSmall(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- OUT PUCHAR out,
- IN ULONG Length);
-
-VOID GetLarge(
- IN PVOID pSrc1,
- IN PVOID pSrc2,
- OUT PUCHAR out,
- IN ULONG Length);
-
-VOID APGenRandom(
- IN PRTMP_ADAPTER pAd,
- OUT UCHAR *random);
-
-VOID AES_GTK_KEY_WRAP(
- IN UCHAR *key,
- IN UCHAR *plaintext,
- IN UCHAR p_len,
- OUT UCHAR *ciphertext);
-
-VOID WpaSend(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR pPacket,
- IN ULONG Len);
-
-VOID APToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN BOOLEAN bClearFrame);
-
-VOID RTMPAddPMKIDCache(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN PUCHAR pAddr,
- IN UCHAR *PMKID,
- IN UCHAR *PMK);
-
-INT RTMPSearchPMKIDCache(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN PUCHAR pAddr);
-
-VOID RTMPDeletePMKIDCache(
- IN PRTMP_ADAPTER pAd,
- IN INT apidx,
- IN INT idx);
-
-VOID RTMPMaintainPMKIDCache(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPSendTriggerFrame(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuffer,
- IN ULONG Length,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull);
-
-#ifdef RT30xx
-VOID RTMPFilterCalibration(
- IN PRTMP_ADAPTER pAd);
-#endif // RT30xx //
-
-
-//typedef void (*TIMER_FUNCTION)(unsigned long);
-
-
-/* timeout -- ms */
-VOID RTMP_SetPeriodicTimer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout);
-
-VOID RTMP_OS_Init_Timer(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN TIMER_FUNCTION function,
- IN PVOID data);
-
-VOID RTMP_OS_Add_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout);
-
-VOID RTMP_OS_Mod_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- IN unsigned long timeout);
-
-
-VOID RTMP_OS_Del_Timer(
- IN NDIS_MINIPORT_TIMER *pTimer,
- OUT BOOLEAN *pCancelled);
-
-
-VOID RTMP_OS_Release_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PQUEUE_ENTRY pEntry);
-
-VOID RTMPusecDelay(
- IN ULONG usec);
-
-NDIS_STATUS os_alloc_mem(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR *mem,
- IN ULONG size);
-
-NDIS_STATUS os_free_mem(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR mem);
-
-
-void RTMP_AllocateSharedMemory(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-VOID RTMPFreeTxRxRingMemory(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS AdapterBlockAllocateMemory(
- IN PVOID handle,
- OUT PVOID *ppAd);
-
-void RTMP_AllocateTxDescMemory(
- IN PRTMP_ADAPTER pAd,
- IN UINT Index,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateFirstTxBuffer(
- IN PRTMP_ADAPTER pAd,
- IN UINT Index,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateMgmtDescMemory(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateRxDescMemory(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-PNDIS_PACKET RTMP_AllocateRxPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length,
- IN BOOLEAN Cached,
- OUT PVOID *VirtualAddress);
-
-PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Length);
-
-void RTMP_QueryPacketInfo(
- IN PNDIS_PACKET pPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen);
-
-void RTMP_QueryNextPacketInfo(
- IN PNDIS_PACKET *ppPacket,
- OUT PACKET_INFO *pPacketInfo,
- OUT PUCHAR *pSrcBufVA,
- OUT UINT *pSrcBufLen);
-
-
-BOOLEAN RTMP_FillTxBlkInfo(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk);
-
-
-PRTMP_SCATTER_GATHER_LIST
-rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg);
-
-
- void announce_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-UINT BA_Reorder_AMSDU_Annnounce(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket);
-
-
-UINT Handle_AMSDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-
-void convert_802_11_to_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR p8023hdr,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-
-PNET_DEV get_netdev_from_bssid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR FromWhichBSSID);
-
-
-PNDIS_PACKET duplicate_pkt(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-
-PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pOldPkt);
-
-PNDIS_PACKET duplicate_pkt_with_VLAN(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- IN UCHAR FromWhichBSSID);
-
-PNDIS_PACKET duplicate_pkt_with_WPI(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UINT32 ext_head_len,
- IN UINT32 ext_tail_len);
-
-UCHAR VLAN_8023_Header_Copy(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- OUT PUCHAR pData,
- IN UCHAR FromWhichBSSID);
-
-#ifdef DOT11_N_SUPPORT
-void ba_flush_reordering_timeout_mpdus(
- IN PRTMP_ADAPTER pAd,
- IN PBA_REC_ENTRY pBAEntry,
- IN ULONG Now32);
-
-
-VOID BAOriSessionSetUp(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN UCHAR TID,
- IN USHORT TimeOut,
- IN ULONG DelayTime,
- IN BOOLEAN isForced);
-
-VOID BASessionTearDownALL(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid);
-#endif // DOT11_N_SUPPORT //
-
-BOOLEAN OS_Need_Clone_Packet(void);
-
-
-VOID build_tx_packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pFrame,
- IN ULONG FrameLen);
-
-
-VOID BAOriSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive,
- IN BOOLEAN bForceSend);
-
-VOID BARecSessionTearDown(
- IN OUT PRTMP_ADAPTER pAd,
- IN UCHAR Wcid,
- IN UCHAR TID,
- IN BOOLEAN bPassive);
-
-BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
-void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-
-ULONG AutoChBssInsertEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pBssid,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR ChannelNo,
- IN CHAR Rssi);
-
-void AutoChBssTableInit(
- IN PRTMP_ADAPTER pAd);
-
-void ChannelInfoInit(
- IN PRTMP_ADAPTER pAd);
-
-void AutoChBssTableDestroy(
- IN PRTMP_ADAPTER pAd);
-
-void ChannelInfoDestroy(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR New_ApAutoSelectChannel(
- IN PRTMP_ADAPTER pAd);
-
-
-#ifdef NINTENDO_AP
-VOID InitNINTENDO_TABLE(
- IN PRTMP_ADAPTER pAd);
-
-UCHAR CheckNINTENDO_TABLE(
- IN PRTMP_ADAPTER pAd,
- PCHAR pDS_Ssid,
- UCHAR DS_SsidLen,
- PUCHAR pDS_Addr);
-
-UCHAR DelNINTENDO_ENTRY(
- IN PRTMP_ADAPTER pAd,
- UCHAR * pDS_Addr);
-
-VOID RTMPIoctlNintendoCapable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlNintendoGetTable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlNintendoSetTable(
- IN PRTMP_ADAPTER pAd,
- IN struct iwreq *wrq);
-
-#endif // NINTENDO_AP //
-
-BOOLEAN rtstrmactohex(
- IN char *s1,
- IN char *s2);
-
-BOOLEAN rtstrcasecmp(
- IN char *s1,
- IN char *s2);
-
-char *rtstrstruncasecmp(
- IN char *s1,
- IN char *s2);
-
-char *rtstrstr(
- IN const char * s1,
- IN const char * s2);
-
-char *rstrtok(
- IN char * s,
- IN const char * ct);
-
-int rtinet_aton(
- const char *cp,
- unsigned int *addr);
-
-////////// common ioctl functions //////////
-INT Set_DriverVersion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_CountryRegion_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_CountryRegionABand_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_WirelessMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_Channel_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ShortSlot_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TxPower_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BGProtection_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TxPreamble_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_RTSThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_FragThreshold_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TxBurst_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef AGGREGATION_SUPPORT
-INT Set_PktAggregate_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Set_IEEE80211H_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef DBG
-INT Set_Debug_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Show_DescInfo_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ResetStatCounter_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef DOT11_N_SUPPORT
-INT Set_BASetup_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BADecline_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BAOriTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_BARecTearDown_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtBw_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMcs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtGi_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtOpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtStbc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtHtc_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtExtcha_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMpduDensity_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtBaWinSize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtRdg_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtLinkAdapt_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtAmsdu_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtAutoBa_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtProtect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMimoPs_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_ForceShortGI_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_ForceGF_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT SetCommonHT(
- IN PRTMP_ADAPTER pAd);
-
-INT Set_SendPSMPAction_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_HtMIMOPSmode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-
-INT Set_HtTxBASize_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-
-
-#ifdef CONFIG_STA_SUPPORT
-//Dls , kathy
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA);
-
-#ifdef DOT11_N_SUPPORT
-//Block ACK
-VOID QueryBATABLE(
- IN PRTMP_ADAPTER pAd,
- OUT PQUERYBA_TABLE pBAT);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-INT WpaCheckEapCode(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFrame,
- IN USHORT FrameLen,
- IN USHORT OffSet);
-
-VOID WpaSendMicFailureToWpaSupplicant(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUnicast);
-
-VOID SendAssocIEsToWpaSupplicant(
- IN PRTMP_ADAPTER pAd);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-int wext_notify_event_assoc(
- IN RTMP_ADAPTER *pAd);
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-
-#ifdef DOT11_N_SUPPORT
-VOID Handle_BSS_Width_Trigger_Events(
- IN PRTMP_ADAPTER pAd);
-
-void build_ext_channel_switch_ie(
- IN PRTMP_ADAPTER pAd,
- IN HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE *pIE);
-#endif // DOT11_N_SUPPORT //
-
-
-BOOLEAN APRxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN STARxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN argc);
-
-#ifdef DOT11_N_SUPPORT
-// AMPDU packet indication
-VOID Indicate_AMPDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-// AMSDU packet indication
-VOID Indicate_AMSDU_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-#endif // DOT11_N_SUPPORT //
-
-// Normal legacy Rx packet indication
-VOID Indicate_Legacy_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-VOID Indicate_EAPOL_Packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-void update_os_packet_info(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-void wlan_802_11_to_802_3_packet(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN PUCHAR pHeader802_3,
- IN UCHAR FromWhichBSSID);
-
-UINT deaggregate_AMSDU_announce(
- IN PRTMP_ADAPTER pAd,
- PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize);
-
-
-#ifdef CONFIG_STA_SUPPORT
-// remove LLC and get 802_3 Header
-#define RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3) \
-{ \
- PUCHAR _pRemovedLLCSNAP = NULL, _pDA, _pSA; \
- \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) \
- { \
- _pDA = _pRxBlk->pHeader->Addr3; \
- _pSA = (PUCHAR)_pRxBlk->pHeader + sizeof(HEADER_802_11); \
- } \
- else \
- { \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) \
- { \
- _pDA = _pRxBlk->pHeader->Addr1; \
- if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS)) \
- _pSA = _pRxBlk->pHeader->Addr2; \
- else \
- _pSA = _pRxBlk->pHeader->Addr3; \
- } \
- else \
- { \
- _pDA = _pRxBlk->pHeader->Addr1; \
- _pSA = _pRxBlk->pHeader->Addr2; \
- } \
- } \
- \
- CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData, \
- _pRxBlk->DataSize, _pRemovedLLCSNAP); \
-}
-#endif // CONFIG_STA_SUPPORT //
-
-
-BOOLEAN APFowardWirelessStaToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN ULONG FromWhichBSSID);
-
-VOID Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID);
-
-VOID Sta_Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID);
-
-
-#ifdef CONFIG_STA_SUPPORT
-#define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
- Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
- //announce_802_3_packet(_pAd, _pPacket);
-#endif // CONFIG_STA_SUPPORT //
-
-
-PNDIS_PACKET DuplicatePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID);
-
-
-PNDIS_PACKET ClonePacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize);
-
-
-// Normal, AMPDU or AMSDU
-VOID CmmRxnonRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-VOID CmmRxRalinkFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID);
-
-VOID Update_Rssi_Sample(
- IN PRTMP_ADAPTER pAd,
- IN RSSI_SAMPLE *pRssi,
- IN PRXWI_STRUC pRxWI);
-
-PNDIS_PACKET GetPacketFromRxRing(
- IN PRTMP_ADAPTER pAd,
- OUT PRT28XX_RXD_STRUC pSaveRxD,
- OUT BOOLEAN *pbReschedule,
- IN OUT UINT32 *pRxPending);
-
-PNDIS_PACKET RTMPDeFragmentDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk);
-
-////////////////////////////////////////
-
-
-
-
-
-#ifdef SNMP_SUPPORT
-//for snmp , kathy
-typedef struct _DefaultKeyIdxValue
-{
- UCHAR KeyIdx;
- UCHAR Value[16];
-} DefaultKeyIdxValue, *PDefaultKeyIdxValue;
-#endif
-
-
-#ifdef CONFIG_STA_SUPPORT
-enum {
- DIDmsg_lnxind_wlansniffrm = 0x00000044,
- DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
- DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
- DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
- DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
- DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
- DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
- DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
- DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
- DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
- DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
-};
-enum {
- P80211ENUM_msgitem_status_no_value = 0x00
-};
-enum {
- P80211ENUM_truth_false = 0x00,
- P80211ENUM_truth_true = 0x01
-};
-
-/* Definition from madwifi */
-typedef struct {
- UINT32 did;
- UINT16 status;
- UINT16 len;
- UINT32 data;
-} p80211item_uint32_t;
-
-typedef struct {
- UINT32 msgcode;
- UINT32 msglen;
-#define WLAN_DEVNAMELEN_MAX 16
- UINT8 devname[WLAN_DEVNAMELEN_MAX];
- p80211item_uint32_t hosttime;
- p80211item_uint32_t mactime;
- p80211item_uint32_t channel;
- p80211item_uint32_t rssi;
- p80211item_uint32_t sq;
- p80211item_uint32_t signal;
- p80211item_uint32_t noise;
- p80211item_uint32_t rate;
- p80211item_uint32_t istx;
- p80211item_uint32_t frmlen;
-} wlan_ng_prism2_header;
-
-/* The radio capture header precedes the 802.11 header. */
-typedef struct PACKED _ieee80211_radiotap_header {
- UINT8 it_version; /* Version 0. Only increases
- * for drastic changes,
- * introduction of compatible
- * new fields does not count.
- */
- UINT8 it_pad;
- UINT16 it_len; /* length of the whole
- * header in bytes, including
- * it_version, it_pad,
- * it_len, and data fields.
- */
- UINT32 it_present; /* A bitmap telling which
- * fields are present. Set bit 31
- * (0x80000000) to extend the
- * bitmap by another 32 bits.
- * Additional extensions are made
- * by setting bit 31.
- */
-}ieee80211_radiotap_header ;
-
-enum ieee80211_radiotap_type {
- IEEE80211_RADIOTAP_TSFT = 0,
- IEEE80211_RADIOTAP_FLAGS = 1,
- IEEE80211_RADIOTAP_RATE = 2,
- IEEE80211_RADIOTAP_CHANNEL = 3,
- IEEE80211_RADIOTAP_FHSS = 4,
- IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
- IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
- IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
- IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
- IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
- IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
- IEEE80211_RADIOTAP_ANTENNA = 11,
- IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
- IEEE80211_RADIOTAP_DB_ANTNOISE = 13
-};
-
-#define WLAN_RADIOTAP_PRESENT ( \
- (1 << IEEE80211_RADIOTAP_TSFT) | \
- (1 << IEEE80211_RADIOTAP_FLAGS) | \
- (1 << IEEE80211_RADIOTAP_RATE) | \
- 0)
-
-typedef struct _wlan_radiotap_header {
- ieee80211_radiotap_header wt_ihdr;
- INT64 wt_tsft;
- UINT8 wt_flags;
- UINT8 wt_rate;
-} wlan_radiotap_header;
-/* Definition from madwifi */
-
-void send_monitor_packets(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk);
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
- IN struct net_device *net_dev);
-#endif
-
-VOID RTMPSetDesiredRates(
- IN PRTMP_ADAPTER pAdapter,
- IN LONG Rates);
-#endif // CONFIG_STA_SUPPORT //
-
-INT Set_FixedTxMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
-INT Set_OpMode_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-
-static inline char* GetPhyMode(
- int Mode)
-{
- switch(Mode)
- {
- case MODE_CCK:
- return "CCK";
-
- case MODE_OFDM:
- return "OFDM";
-#ifdef DOT11_N_SUPPORT
- case MODE_HTMIX:
- return "HTMIX";
-
- case MODE_HTGREENFIELD:
- return "GREEN";
-#endif // DOT11_N_SUPPORT //
- default:
- return "N/A";
- }
-}
-
-
-static inline char* GetBW(
- int BW)
-{
- switch(BW)
- {
- case BW_10:
- return "10M";
-
- case BW_20:
- return "20M";
-#ifdef DOT11_N_SUPPORT
- case BW_40:
- return "40M";
-#endif // DOT11_N_SUPPORT //
- default:
- return "N/A";
- }
-}
-
-
-VOID RT28xxThreadTerminate(
- IN RTMP_ADAPTER *pAd);
-
-BOOLEAN RT28XXChipsetCheck(
- IN void *_dev_p);
-
-BOOLEAN RT28XXNetDevInit(
- IN void *_dev_p,
- IN struct net_device *net_dev,
- IN RTMP_ADAPTER *pAd);
-
-BOOLEAN RT28XXProbePostConfig(
- IN void *_dev_p,
- IN RTMP_ADAPTER *pAd,
- IN INT32 argc);
-
-VOID RT28XXDMADisable(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT28XXDMAEnable(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT28xx_UpdateBeaconToAsic(
- IN RTMP_ADAPTER * pAd,
- IN INT apidx,
- IN ULONG BeaconLen,
- IN ULONG UpdatePos);
-
-INT rt28xx_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd);
-
-
-#ifdef CONFIG_STA_SUPPORT
-INT rt28xx_sta_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd);
-#endif // CONFIG_STA_SUPPORT //
-
-BOOLEAN RT28XXSecurityKeyAdd(
- IN PRTMP_ADAPTER pAd,
- IN ULONG apidx,
- IN ULONG KeyIdx,
- IN MAC_TABLE_ENTRY *pEntry);
-
-////////////////////////////////////////
-PNDIS_PACKET GetPacketFromRxRing(
- IN PRTMP_ADAPTER pAd,
- OUT PRT28XX_RXD_STRUC pSaveRxD,
- OUT BOOLEAN *pbReschedule,
- IN OUT UINT32 *pRxPending);
-
-
-void kill_thread_task(PRTMP_ADAPTER pAd);
-
-void tbtt_tasklet(unsigned long data);
-
-
-VOID AsicTurnOffRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel);
-
-VOID AsicTurnOnRFClk(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Channel);
-
-#ifdef RT30xx
-NTSTATUS RT30xxWriteRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RegID,
- IN UCHAR Value);
-
-NTSTATUS RT30xxReadRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR RegID,
- IN PUCHAR pValue);
-
-//2008/09/11:KH add to support efuse<--
-UCHAR eFuseReadRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- OUT USHORT* pData);
-
-VOID eFuseReadPhysical(
- IN PRTMP_ADAPTER pAd,
- IN PUSHORT lpInBuffer,
- IN ULONG nInBufferSize,
- OUT PUSHORT lpOutBuffer,
- IN ULONG nOutBufferSize
-);
-
-NTSTATUS eFuseRead(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT Length);
-
-VOID eFusePhysicalWriteRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- OUT USHORT* pData);
-
-NTSTATUS eFuseWriteRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- IN USHORT* pData);
-
-VOID eFuseWritePhysical(
- IN PRTMP_ADAPTER pAd,
- PUSHORT lpInBuffer,
- ULONG nInBufferSize,
- PUCHAR lpOutBuffer,
- ULONG nOutBufferSize
-);
-
-NTSTATUS eFuseWrite(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length);
-
-INT set_eFuseGetFreeBlockCount_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT set_eFusedump_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT set_eFuseLoadFromBin_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-NTSTATUS eFuseWriteRegistersFromBin(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- IN USHORT* pData);
-
-VOID eFusePhysicalReadRegisters(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN USHORT Length,
- OUT USHORT* pData);
-
-NDIS_STATUS NICLoadEEPROM(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN bNeedLoadEEPROM(
- IN PRTMP_ADAPTER pAd);
-//2008/09/11:KH add to support efuse-->
-#endif // RT30xx //
-
-#ifdef RT30xx
-// add by johnli, RF power sequence setup
-VOID RT30xxLoadRFNormalModeSetup(
- IN PRTMP_ADAPTER pAd);
-
-VOID RT30xxLoadRFSleepModeSetup(
- IN PRTMP_ADAPTER pAd);
-
-VOID RT30xxReverseRFSleepModeSetup(
- IN PRTMP_ADAPTER pAd);
-// end johnli
-#endif // RT30xx //
-
-#ifdef RT2870
-//
-// Function Prototype in rtusb_bulk.c
-//
-VOID RTUSBInitTxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PTX_CONTEXT pTxContext,
- IN UCHAR BulkOutPipeId,
- IN usb_complete_t Func);
-
-VOID RTUSBInitHTTxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PHT_TX_CONTEXT pTxContext,
- IN UCHAR BulkOutPipeId,
- IN ULONG BulkOutSize,
- IN usb_complete_t Func);
-
-VOID RTUSBInitRxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PRX_CONTEXT pRxContext);
-
-VOID RTUSBCleanUpDataBulkOutQueue(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCancelPendingBulkOutIRP(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkOutDataPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId,
- IN UCHAR Index);
-
-VOID RTUSBBulkOutNullFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkOutRTSFrame(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCancelPendingBulkInIRP(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCancelPendingIRPs(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkOutMLMEPacket(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index);
-
-VOID RTUSBBulkOutPsPoll(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBCleanUpMLMEBulkOutQueue(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBKickBulkOut(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBBulkReceive(
- IN PRTMP_ADAPTER pAd);
-
-VOID DoBulkIn(
- IN RTMP_ADAPTER *pAd);
-
-VOID RTUSBInitRxDesc(
- IN PRTMP_ADAPTER pAd,
- IN PRX_CONTEXT pRxContext);
-
-VOID RTUSBBulkRxHandle(
- IN unsigned long data);
-
-//
-// Function Prototype in rtusb_io.c
-//
-NTSTATUS RTUSBMultiRead(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT length);
-
-NTSTATUS RTUSBMultiWrite(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length);
-
-NTSTATUS RTUSBMultiWrite_OneByte(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData);
-
-NTSTATUS RTUSBReadBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN PUCHAR pValue);
-
-NTSTATUS RTUSBWriteBBPRegister(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Id,
- IN UCHAR Value);
-
-NTSTATUS RTUSBWriteRFRegister(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 Value);
-
-NTSTATUS RTUSB_VendorRequest(
- IN PRTMP_ADAPTER pAd,
- IN UINT32 TransferFlags,
- IN UCHAR ReservedBits,
- IN UCHAR Request,
- IN USHORT Value,
- IN USHORT Index,
- IN PVOID TransferBuffer,
- IN UINT32 TransferBufferLength);
-
-NTSTATUS RTUSBReadEEPROM(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUCHAR pData,
- IN USHORT length);
-
-NTSTATUS RTUSBWriteEEPROM(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN PUCHAR pData,
- IN USHORT length);
-
-VOID RTUSBPutToSleep(
- IN PRTMP_ADAPTER pAd);
-
-NTSTATUS RTUSBWakeUp(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTUSBInitializeCmdQ(
- IN PCmdQ cmdq);
-
-NDIS_STATUS RTUSBEnqueueCmdFromNdis(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_OID Oid,
- IN BOOLEAN SetInformation,
- IN PVOID pInformationBuffer,
- IN UINT32 InformationBufferLength);
-
-NDIS_STATUS RTUSBEnqueueInternalCmd(
- IN PRTMP_ADAPTER pAd,
- IN NDIS_OID Oid,
- IN PVOID pInformationBuffer,
- IN UINT32 InformationBufferLength);
-
-VOID RTUSBDequeueCmd(
- IN PCmdQ cmdq,
- OUT PCmdQElmt *pcmdqelmt);
-
-INT RTUSBCmdThread(
- IN OUT PVOID Context);
-
-INT TimerQThread(
- IN OUT PVOID Context);
-
-RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
- IN RTMP_ADAPTER *pAd,
- IN RALINK_TIMER_STRUCT *pTimer);
-
-BOOLEAN RT2870_TimerQ_Remove(
- IN RTMP_ADAPTER *pAd,
- IN RALINK_TIMER_STRUCT *pTimer);
-
-void RT2870_TimerQ_Exit(
- IN RTMP_ADAPTER *pAd);
-
-void RT2870_TimerQ_Init(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconExit(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconStop(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconStart(
- IN RTMP_ADAPTER * pAd);
-
-VOID RT2870_BssBeaconInit(
- IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_WatchDog(
- IN RTMP_ADAPTER *pAd);
-
-NTSTATUS RTUSBWriteMACRegister(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- IN UINT32 Value);
-
-NTSTATUS RTUSBReadMACRegister(
- IN PRTMP_ADAPTER pAd,
- IN USHORT Offset,
- OUT PUINT32 pValue);
-
-NTSTATUS RTUSBSingleWrite(
- IN RTMP_ADAPTER *pAd,
- IN USHORT Offset,
- IN USHORT Value);
-
-NTSTATUS RTUSBFirmwareRun(
- IN PRTMP_ADAPTER pAd);
-
-NTSTATUS RTUSBFirmwareWrite(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFwImage,
- IN ULONG FwLen);
-
-NTSTATUS RTUSBFirmwareOpmode(
- IN PRTMP_ADAPTER pAd,
- OUT PUINT32 pValue);
-
-NTSTATUS RTUSBVenderReset(
- IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS RTUSBSetHardWareRegister(
- IN PRTMP_ADAPTER pAdapter,
- IN PVOID pBuf);
-
-NDIS_STATUS RTUSBQueryHardWareRegister(
- IN PRTMP_ADAPTER pAdapter,
- IN PVOID pBuf);
-
-VOID CMDHandler(
- IN PRTMP_ADAPTER pAd);
-
-
-NDIS_STATUS CreateThreads(
- IN struct net_device *net_dev );
-
-
-VOID MacTableInitialize(
- IN PRTMP_ADAPTER pAd);
-
-VOID MlmeSetPsm(
- IN PRTMP_ADAPTER pAd,
- IN USHORT psm);
-
-NDIS_STATUS RTMPWPAAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-VOID AsicRxAntEvalAction(
- IN PRTMP_ADAPTER pAd);
-
-void append_pkt(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN ULONG DataSize,
- OUT PNDIS_PACKET *ppPacket);
-
-UINT deaggregate_AMSDU_announce(
- IN PRTMP_ADAPTER pAd,
- PNDIS_PACKET pPacket,
- IN PUCHAR pData,
- IN ULONG DataSize);
-
-NDIS_STATUS RTMPCheckRxError(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN PRXWI_STRUC pRxWI,
- IN PRT28XX_RXD_STRUC pRxINFO);
-
-
-VOID RTUSBMlmeHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN PMGMT_STRUC pMgmt);
-
-INT MlmeThread(
- IN PVOID Context);
-
-//
-// Function Prototype in rtusb_data.c
-//
-NDIS_STATUS RTUSBFreeDescriptorRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BulkOutPipeId,
- IN UINT32 NumberRequired);
-
-
-BOOLEAN RTUSBNeedQueueBackForAgg(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR BulkOutPipeId);
-
-
-VOID RTMPWriteTxInfo(
- IN PRTMP_ADAPTER pAd,
- IN PTXINFO_STRUC pTxInfo,
- IN USHORT USBDMApktLen,
- IN BOOLEAN bWiv,
- IN UCHAR QueueSel,
- IN UCHAR NextValid,
- IN UCHAR TxBurst);
-
-//
-// Function Prototype in cmm_data_2870.c
-//
-USHORT RtmpUSB_WriteSubTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN BOOLEAN bIsLast,
- OUT USHORT *FreeNumber);
-
-USHORT RtmpUSB_WriteSingleTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN BOOLEAN bIsLast,
- OUT USHORT *FreeNumber);
-
-USHORT RtmpUSB_WriteFragTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR fragNum,
- OUT USHORT *FreeNumber);
-
-USHORT RtmpUSB_WriteMultiTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR frameNum,
- OUT USHORT *FreeNumber);
-
-VOID RtmpUSB_FinalWriteTxResource(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN USHORT totalMPDUSize,
- IN USHORT TxIdx);
-
-VOID RtmpUSBDataLastTxIdx(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN USHORT TxIdx);
-
-VOID RtmpUSBDataKickOut(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx);
-
-
-int RtmpUSBMgmtKickOut(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN PNDIS_PACKET pPacket,
- IN PUCHAR pSrcBufVA,
- IN UINT SrcBufLen);
-
-VOID RtmpUSBNullFrameKickOut(
- IN RTMP_ADAPTER *pAd,
- IN UCHAR QueIdx,
- IN UCHAR *pNullFrame,
- IN UINT32 frameLen);
-
-VOID RT28xxUsbStaAsicForceWakeup(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bFromTx);
-
-VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
- IN PRTMP_ADAPTER pAd,
- IN USHORT TbttNumToNextWakeUp);
-
-VOID RT28xxUsbMlmeRadioOn(
- IN PRTMP_ADAPTER pAd);
-
-VOID RT28xxUsbMlmeRadioOFF(
- IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-////////////////////////////////////////
-
-VOID QBSS_LoadInit(
- IN RTMP_ADAPTER *pAd);
-
-UINT32 QBSS_LoadElementAppend(
- IN RTMP_ADAPTER *pAd,
- OUT UINT8 *buf_p);
-
-VOID QBSS_LoadUpdate(
- IN RTMP_ADAPTER *pAd);
-
-///////////////////////////////////////
-INT RTMPShowCfgValue(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pName,
- IN PUCHAR pBuf);
-
-PCHAR RTMPGetRalinkAuthModeStr(
- IN NDIS_802_11_AUTHENTICATION_MODE authMode);
-
-PCHAR RTMPGetRalinkEncryModeStr(
- IN USHORT encryMode);
-//////////////////////////////////////
-
-#ifdef CONFIG_STA_SUPPORT
-VOID AsicStaBbpTuning(
- IN PRTMP_ADAPTER pAd);
-
-BOOLEAN StaAddMacTableEntry(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN USHORT CapabilityInfo);
-#endif // CONFIG_STA_SUPPORT //
-
-void RTMP_IndicateMediaState(
- IN PRTMP_ADAPTER pAd);
-
-VOID ReSyncBeaconTime(
- IN PRTMP_ADAPTER pAd);
-
-VOID RTMPSetAGCInitValue(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BandWidth);
-
-int rt28xx_close(IN PNET_DEV dev);
-int rt28xx_open(IN PNET_DEV dev);
-
-__inline INT VIRTUAL_IF_UP(PRTMP_ADAPTER pAd)
-{
-extern VOID MeshMakeBeacon(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
-extern VOID MeshUpdateBeaconFrame(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
-
- if (VIRTUAL_IF_NUM(pAd) == 0)
- {
- if (rt28xx_open(pAd->net_dev) != 0)
- return -1;
- }
- else
- {
- }
- VIRTUAL_IF_INC(pAd);
- return 0;
-}
-
-__inline VOID VIRTUAL_IF_DOWN(PRTMP_ADAPTER pAd)
-{
- VIRTUAL_IF_DEC(pAd);
- if (VIRTUAL_IF_NUM(pAd) == 0)
- rt28xx_close(pAd->net_dev);
- return;
-}
-
-
-#endif // __RTMP_H__
-
+#include "../rt2870/rtmp.h"
diff --git a/drivers/staging/rt3070/rtmp_ckipmic.h b/drivers/staging/rt3070/rtmp_ckipmic.h
index a3d949a39d39..4956093f4751 100644
--- a/drivers/staging/rt3070/rtmp_ckipmic.h
+++ b/drivers/staging/rt3070/rtmp_ckipmic.h
@@ -1,113 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_ckipmic.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-#ifndef __RTMP_CKIPMIC_H__
-#define __RTMP_CKIPMIC_H__
-
-typedef struct _MIC_CONTEXT {
- /* --- MMH context */
- UCHAR CK[16]; /* the key */
- UCHAR coefficient[16]; /* current aes counter mode coefficients */
- ULONGLONG accum; /* accumulated mic, reduced to u32 in final() */
- UINT position; /* current position (byte offset) in message */
- UCHAR part[4]; /* for conversion of message to u32 for mmh */
-} MIC_CONTEXT, *PMIC_CONTEXT;
-
-VOID CKIP_key_permute(
- OUT UCHAR *PK, /* output permuted key */
- IN UCHAR *CK, /* input CKIP key */
- IN UCHAR toDsFromDs, /* input toDs/FromDs bits */
- IN UCHAR *piv); /* input pointer to IV */
-
-VOID RTMPCkipMicInit(
- IN PMIC_CONTEXT pContext,
- IN PUCHAR CK);
-
-VOID RTMPMicUpdate(
- IN PMIC_CONTEXT pContext,
- IN PUCHAR pOctets,
- IN INT len);
-
-ULONG RTMPMicGetCoefficient(
- IN PMIC_CONTEXT pContext);
-
-VOID xor_128(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-UCHAR RTMPCkipSbox(
- IN UCHAR a);
-
-VOID xor_32(
- IN PUCHAR a,
- IN PUCHAR b,
- OUT PUCHAR out);
-
-VOID next_key(
- IN PUCHAR key,
- IN INT round);
-
-VOID byte_sub(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID shift_row(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID mix_column(
- IN PUCHAR in,
- OUT PUCHAR out);
-
-VOID RTMPAesEncrypt(
- IN PUCHAR key,
- IN PUCHAR data,
- IN PUCHAR ciphertext);
-
-VOID RTMPMicFinal(
- IN PMIC_CONTEXT pContext,
- OUT UCHAR digest[4]);
-
-VOID RTMPCkipInsertCMIC(
- IN PRTMP_ADAPTER pAd,
- OUT PUCHAR pMIC,
- IN PUCHAR p80211hdr,
- IN PNDIS_PACKET pPacket,
- IN PCIPHER_KEY pKey,
- IN PUCHAR mic_snap);
-
-#endif //__RTMP_CKIPMIC_H__
+#include "../rt2870/rtmp_ckipmic.h"
diff --git a/drivers/staging/rt3070/rtmp_def.h b/drivers/staging/rt3070/rtmp_def.h
index 2599f7c836e8..fa3b6b55cfee 100644
--- a/drivers/staging/rt3070/rtmp_def.h
+++ b/drivers/staging/rt3070/rtmp_def.h
@@ -1,1559 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_def.h
-
- Abstract:
- Miniport related definition header
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
- John Chang 08-05-2003 add definition for 11g & other drafts
-*/
-#ifndef __RTMP_DEF_H__
-#define __RTMP_DEF_H__
-
-#include "oid.h"
-
-#undef AP_WSC_INCLUDED
-#undef STA_WSC_INCLUDED
-#undef WSC_INCLUDED
-
-
-#ifdef CONFIG_STA_SUPPORT
-#endif // CONFIG_STA_SUPPORT //
-
-#if defined(AP_WSC_INCLUDED) || defined(STA_WSC_INCLUDED)
-#define WSC_INCLUDED
-#endif
-//
-// Debug information verbosity: lower values indicate higher urgency
-//
-#define RT_DEBUG_OFF 0
-#define RT_DEBUG_ERROR 1
-#define RT_DEBUG_WARN 2
-#define RT_DEBUG_TRACE 3
-#define RT_DEBUG_INFO 4
-#define RT_DEBUG_LOUD 5
-
-#define NIC_TAG ((ULONG)'0682')
-#define NIC_DBG_STRING ("**RT28xx**")
-
-#ifdef SNMP_SUPPORT
-// for snmp
-// to get manufacturer OUI, kathy, 2008_0220
-#define ManufacturerOUI_LEN 3
-#define ManufacturerNAME ("Ralink Technology Company.")
-#define ResourceTypeIdName ("Ralink_ID")
-#endif
-
-
-//#define PACKED
-
-#define RALINK_2883_VERSION ((UINT32)0x28830300)
-#define RALINK_2880E_VERSION ((UINT32)0x28720200)
-#define RALINK_3070_VERSION ((UINT32)0x30700200)
-
-//
-// NDIS version in use by the NIC driver.
-// The high byte is the major version. The low byte is the minor version.
-//
-#ifdef NDIS51_MINIPORT
-#define NIC_DRIVER_VERSION 0x0501
-#else
-#define NIC_DRIVER_VERSION 0x0500
-#endif
-
-//
-// NDIS media type, current is ethernet, change if native wireless supported
-//
-#define NIC_MEDIA_TYPE NdisMedium802_3
-#define NIC_PCI_HDR_LENGTH 0xe2
-#define NIC_MAX_PACKET_SIZE 2304
-#define NIC_HEADER_SIZE 14
-#define MAX_MAP_REGISTERS_NEEDED 32
-#define MIN_MAP_REGISTERS_NEEDED 2 //Todo: should consider fragment issue.
-
-//
-// interface type, we use PCI
-//
-#define NIC_INTERFACE_TYPE NdisInterfacePci
-#define NIC_INTERRUPT_MODE NdisInterruptLevelSensitive
-
-//
-// buffer size passed in NdisMQueryAdapterResources
-// We should only need three adapter resources (IO, interrupt and memory),
-// Some devices get extra resources, so have room for 10 resources
-// UF_SIZE (sizeof(NDIS_RESOURCE_LIST) + (10*sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)))
-
-
-#define NIC_RESOURCE_B//
-// IO space length
-//
-#define NIC_MAP_IOSPACE_LENGTH sizeof(CSR_STRUC)
-
-#define MAX_RX_PKT_LEN 1520
-
-//
-// Entry number for each DMA descriptor ring
-//
-
-
-#ifdef RT2870
-#define TX_RING_SIZE 8 // 1
-#define PRIO_RING_SIZE 8
-#define MGMT_RING_SIZE 32 // PRIO_RING_SIZE
-#define RX_RING_SIZE 8
-#define MAX_TX_PROCESS 4
-#define LOCAL_TXBUF_SIZE 2048
-#endif // RT2870 //
-
-#ifdef MULTIPLE_CARD_SUPPORT
-// MC: Multple Cards
-#define MAX_NUM_OF_MULTIPLE_CARD 32
-#endif // MULTIPLE_CARD_SUPPORT //
-
-#define MAX_RX_PROCESS 128 //64 //32
-#define NUM_OF_LOCAL_TXBUF 2
-#define TXD_SIZE 16
-#define TXWI_SIZE 16
-#define RXD_SIZE 16
-#define RXWI_SIZE 16
-// TXINFO_SIZE + TXWI_SIZE + 802.11 Header Size + AMSDU sub frame header
-#define TX_DMA_1ST_BUFFER_SIZE 96 // only the 1st physical buffer is pre-allocated
-#define MGMT_DMA_BUFFER_SIZE 1536 //2048
-#define RX_BUFFER_AGGRESIZE 3840 //3904 //3968 //4096 //2048 //4096
-#define RX_BUFFER_NORMSIZE 3840 //3904 //3968 //4096 //2048 //4096
-#define TX_BUFFER_NORMSIZE RX_BUFFER_NORMSIZE
-#define MAX_FRAME_SIZE 2346 // Maximum 802.11 frame size
-#define MAX_AGGREGATION_SIZE 3840 //3904 //3968 //4096
-#define MAX_NUM_OF_TUPLE_CACHE 2
-#define MAX_MCAST_LIST_SIZE 32
-#define MAX_LEN_OF_VENDOR_DESC 64
-//#define MAX_SIZE_OF_MCAST_PSQ (NUM_OF_LOCAL_TXBUF >> 2) // AP won't spend more than 1/4 of total buffers on M/BCAST PSQ
-#define MAX_SIZE_OF_MCAST_PSQ 32
-
-#define MAX_RX_PROCESS_CNT (RX_RING_SIZE)
-
-
-#define MAX_PACKETS_IN_QUEUE (512) //(512) // to pass WMM A5-WPAPSK
-#define MAX_PACKETS_IN_MCAST_PS_QUEUE 32
-#define MAX_PACKETS_IN_PS_QUEUE 128 //32
-#define WMM_NUM_OF_AC 4 /* AC0, AC1, AC2, and AC3 */
-
-
-//2008/09/11:KH add to support efuse<--
-#define MAX_EEPROM_BIN_FILE_SIZE 1024
-//2008/09/11:KH add to support efuse-->
-
-// RxFilter
-#define STANORMAL 0x17f97
-#define APNORMAL 0x15f97
-//
-// RTMP_ADAPTER flags
-//
-#define fRTMP_ADAPTER_MAP_REGISTER 0x00000001
-#define fRTMP_ADAPTER_INTERRUPT_IN_USE 0x00000002
-#define fRTMP_ADAPTER_HARDWARE_ERROR 0x00000004
-#define fRTMP_ADAPTER_SCATTER_GATHER 0x00000008
-#define fRTMP_ADAPTER_SEND_PACKET_ERROR 0x00000010
-#define fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS 0x00000020
-#define fRTMP_ADAPTER_HALT_IN_PROGRESS 0x00000040
-#define fRTMP_ADAPTER_RESET_IN_PROGRESS 0x00000080
-#define fRTMP_ADAPTER_NIC_NOT_EXIST 0x00000100
-#define fRTMP_ADAPTER_TX_RING_ALLOCATED 0x00000200
-#define fRTMP_ADAPTER_REMOVE_IN_PROGRESS 0x00000400
-#define fRTMP_ADAPTER_MIMORATE_INUSED 0x00000800
-#define fRTMP_ADAPTER_RX_RING_ALLOCATED 0x00001000
-#define fRTMP_ADAPTER_INTERRUPT_ACTIVE 0x00002000
-#define fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS 0x00004000
-#define fRTMP_ADAPTER_REASSOC_IN_PROGRESS 0x00008000
-#define fRTMP_ADAPTER_MEDIA_STATE_PENDING 0x00010000
-#define fRTMP_ADAPTER_RADIO_OFF 0x00020000
-#define fRTMP_ADAPTER_BULKOUT_RESET 0x00040000
-#define fRTMP_ADAPTER_BULKIN_RESET 0x00080000
-#define fRTMP_ADAPTER_RDG_ACTIVE 0x00100000
-#define fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE 0x00200000
-#define fRTMP_ADAPTER_SCAN_2040 0x04000000
-#define fRTMP_ADAPTER_RADIO_MEASUREMENT 0x08000000
-
-#define fRTMP_ADAPTER_START_UP 0x10000000 //Devive already initialized and enabled Tx/Rx.
-#define fRTMP_ADAPTER_MEDIA_STATE_CHANGE 0x20000000
-#define fRTMP_ADAPTER_IDLE_RADIO_OFF 0x40000000
-
-// Lock bit for accessing different ring buffers
-//#define fRTMP_ADAPTER_TX_RING_BUSY 0x80000000
-//#define fRTMP_ADAPTER_MGMT_RING_BUSY 0x40000000
-//#define fRTMP_ADAPTER_ATIM_RING_BUSY 0x20000000
-//#define fRTMP_ADAPTER_RX_RING_BUSY 0x10000000
-
-// Lock bit for accessing different queue
-//#define fRTMP_ADAPTER_TX_QUEUE_BUSY 0x08000000
-//#define fRTMP_ADAPTER_MGMT_QUEUE_BUSY 0x04000000
-
-//
-// STA operation status flags
-//
-#define fOP_STATUS_INFRA_ON 0x00000001
-#define fOP_STATUS_ADHOC_ON 0x00000002
-#define fOP_STATUS_BG_PROTECTION_INUSED 0x00000004
-#define fOP_STATUS_SHORT_SLOT_INUSED 0x00000008
-#define fOP_STATUS_SHORT_PREAMBLE_INUSED 0x00000010
-#define fOP_STATUS_RECEIVE_DTIM 0x00000020
-//#define fOP_STATUS_TX_RATE_SWITCH_ENABLED 0x00000040
-#define fOP_STATUS_MEDIA_STATE_CONNECTED 0x00000080
-#define fOP_STATUS_WMM_INUSED 0x00000100
-#define fOP_STATUS_AGGREGATION_INUSED 0x00000200
-#define fOP_STATUS_DOZE 0x00000400 // debug purpose
-#define fOP_STATUS_PIGGYBACK_INUSED 0x00000800 // piggy-back, and aggregation
-#define fOP_STATUS_APSD_INUSED 0x00001000
-#define fOP_STATUS_TX_AMSDU_INUSED 0x00002000
-#define fOP_STATUS_MAX_RETRY_ENABLED 0x00004000
-#define fOP_STATUS_WAKEUP_NOW 0x00008000
-#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000
-
-#ifdef DOT11N_DRAFT3
-#define fOP_STATUS_SCAN_2040 0x00040000
-#endif // DOT11N_DRAFT3 //
-
-#define CCKSETPROTECT 0x1
-#define OFDMSETPROTECT 0x2
-#define MM20SETPROTECT 0x4
-#define MM40SETPROTECT 0x8
-#define GF20SETPROTECT 0x10
-#define GR40SETPROTECT 0x20
-#define ALLN_SETPROTECT (GR40SETPROTECT | GF20SETPROTECT | MM40SETPROTECT | MM20SETPROTECT)
-
-//
-// AP's client table operation status flags
-//
-#define fCLIENT_STATUS_WMM_CAPABLE 0x00000001 // CLIENT can parse QOS DATA frame
-#define fCLIENT_STATUS_AGGREGATION_CAPABLE 0x00000002 // CLIENT can receive Ralink's proprietary TX aggregation frame
-#define fCLIENT_STATUS_PIGGYBACK_CAPABLE 0x00000004 // CLIENT support piggy-back
-#define fCLIENT_STATUS_AMSDU_INUSED 0x00000008
-#define fCLIENT_STATUS_SGI20_CAPABLE 0x00000010
-#define fCLIENT_STATUS_SGI40_CAPABLE 0x00000020
-#define fCLIENT_STATUS_TxSTBC_CAPABLE 0x00000040
-#define fCLIENT_STATUS_RxSTBC_CAPABLE 0x00000080
-#define fCLIENT_STATUS_HTC_CAPABLE 0x00000100
-#define fCLIENT_STATUS_RDG_CAPABLE 0x00000200
-#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE 0x00000400
-#define fCLIENT_STATUS_APSD_CAPABLE 0x00000800 /* UAPSD STATION */
-
-#ifdef DOT11N_DRAFT3
-#define fCLIENT_STATUS_BSSCOEXIST_CAPABLE 0x00001000
-#endif // DOT11N_DRAFT3 //
-
-#define fCLIENT_STATUS_RALINK_CHIPSET 0x00100000
-//
-// STA configuration flags
-//
-//#define fSTA_CFG_ENABLE_TX_BURST 0x00000001
-
-// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case
-#define HT_NO_PROTECT 0
-#define HT_LEGACY_PROTECT 1
-#define HT_40_PROTECT 2
-#define HT_2040_PROTECT 3
-#define HT_RTSCTS_6M 7
-//following is our own definition in order to turn on our ASIC protection register in INFRASTRUCTURE.
-#define HT_ATHEROS 8
-#define HT_FORCERTSCTS 9 // Force turn on RTS/CTS first. then go to evaluate if this force RTS is necessary.
-
-//
-// RX Packet Filter control flags. Apply on pAd->PacketFilter
-//
-#define fRX_FILTER_ACCEPT_DIRECT NDIS_PACKET_TYPE_DIRECTED
-#define fRX_FILTER_ACCEPT_MULTICAST NDIS_PACKET_TYPE_MULTICAST
-#define fRX_FILTER_ACCEPT_BROADCAST NDIS_PACKET_TYPE_BROADCAST
-#define fRX_FILTER_ACCEPT_ALL_MULTICAST NDIS_PACKET_TYPE_ALL_MULTICAST
-
-//
-// Error code section
-//
-// NDIS_ERROR_CODE_ADAPTER_NOT_FOUND
-#define ERRLOG_READ_PCI_SLOT_FAILED 0x00000101L
-#define ERRLOG_WRITE_PCI_SLOT_FAILED 0x00000102L
-#define ERRLOG_VENDOR_DEVICE_NOMATCH 0x00000103L
-
-// NDIS_ERROR_CODE_ADAPTER_DISABLED
-#define ERRLOG_BUS_MASTER_DISABLED 0x00000201L
-
-// NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION
-#define ERRLOG_INVALID_SPEED_DUPLEX 0x00000301L
-#define ERRLOG_SET_SECONDARY_FAILED 0x00000302L
-
-// NDIS_ERROR_CODE_OUT_OF_RESOURCES
-#define ERRLOG_OUT_OF_MEMORY 0x00000401L
-#define ERRLOG_OUT_OF_SHARED_MEMORY 0x00000402L
-#define ERRLOG_OUT_OF_MAP_REGISTERS 0x00000403L
-#define ERRLOG_OUT_OF_BUFFER_POOL 0x00000404L
-#define ERRLOG_OUT_OF_NDIS_BUFFER 0x00000405L
-#define ERRLOG_OUT_OF_PACKET_POOL 0x00000406L
-#define ERRLOG_OUT_OF_NDIS_PACKET 0x00000407L
-#define ERRLOG_OUT_OF_LOOKASIDE_MEMORY 0x00000408L
-
-// NDIS_ERROR_CODE_HARDWARE_FAILURE
-#define ERRLOG_SELFTEST_FAILED 0x00000501L
-#define ERRLOG_INITIALIZE_ADAPTER 0x00000502L
-#define ERRLOG_REMOVE_MINIPORT 0x00000503L
-
-// NDIS_ERROR_CODE_RESOURCE_CONFLICT
-#define ERRLOG_MAP_IO_SPACE 0x00000601L
-#define ERRLOG_QUERY_ADAPTER_RESOURCES 0x00000602L
-#define ERRLOG_NO_IO_RESOURCE 0x00000603L
-#define ERRLOG_NO_INTERRUPT_RESOURCE 0x00000604L
-#define ERRLOG_NO_MEMORY_RESOURCE 0x00000605L
-
-
-// WDS definition
-#define MAX_WDS_ENTRY 4
-#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
-
-#define WDS_DISABLE_MODE 0
-#define WDS_RESTRICT_MODE 1
-#define WDS_BRIDGE_MODE 2
-#define WDS_REPEATER_MODE 3
-#define WDS_LAZY_MODE 4
-
-
-#define MAX_MESH_NUM 0
-
-#define MAX_APCLI_NUM 0
-
-#define MAX_MBSSID_NUM 1
-#ifdef MBSS_SUPPORT
-#undef MAX_MBSSID_NUM
-#define MAX_MBSSID_NUM (8 - MAX_MESH_NUM - MAX_APCLI_NUM)
-#endif // MBSS_SUPPORT //
-
-/* sanity check for apidx */
-#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
- { if (apidx > MAX_MBSSID_NUM) { \
- printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __FUNCTION__, apidx); \
- apidx = MAIN_MBSSID; } }
-
-#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
-
-#define MAIN_MBSSID 0
-#define FIRST_MBSSID 1
-
-
-#define MAX_BEACON_SIZE 512
-// If the MAX_MBSSID_NUM is larger than 6,
-// it shall reserve some WCID space(wcid 222~253) for beacon frames.
-// - these wcid 238~253 are reserved for beacon#6(ra6).
-// - these wcid 222~237 are reserved for beacon#7(ra7).
-#if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
-#define HW_RESERVED_WCID 222
-#elif defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 7)
-#define HW_RESERVED_WCID 238
-#else
-#define HW_RESERVED_WCID 255
-#endif
-
-// Then dedicate wcid of DFS and Carrier-Sense.
-#define DFS_CTS_WCID (HW_RESERVED_WCID - 1)
-#define CS_CTS_WCID (HW_RESERVED_WCID - 2)
-#define LAST_SPECIFIC_WCID (HW_RESERVED_WCID - 2)
-
-// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211.
-// If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228.
-#define MAX_AVAILABLE_CLIENT_WCID (LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
-
-// TX need WCID to find Cipher Key
-// these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8.
-#define GET_GroupKey_WCID(__wcid, __bssidx) \
- { \
- __wcid = LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM) + __bssidx; \
- }
-
-#define IsGroupKeyWCID(__wcid) (((__wcid) < LAST_SPECIFIC_WCID) && ((__wcid) >= (LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM))))
-
-
-// definition to support multiple BSSID
-#define BSS0 0
-#define BSS1 1
-#define BSS2 2
-#define BSS3 3
-#define BSS4 4
-#define BSS5 5
-#define BSS6 6
-#define BSS7 7
-
-
-//============================================================
-// Length definitions
-#define PEER_KEY_NO 2
-#define MAC_ADDR_LEN 6
-#define TIMESTAMP_LEN 8
-#define MAX_LEN_OF_SUPPORTED_RATES MAX_LENGTH_OF_SUPPORT_RATES // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
-#define MAX_LEN_OF_KEY 32 // 32 octets == 256 bits, Redefine for WPA
-#define MAX_NUM_OF_CHANNELS MAX_NUM_OF_CHS // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
-#define MAX_NUM_OF_11JCHANNELS 20 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
-#define MAX_LEN_OF_SSID 32
-#define CIPHER_TEXT_LEN 128
-#define HASH_TABLE_SIZE 256
-#define MAX_VIE_LEN 1024 // New for WPA cipher suite variable IE sizes.
-#define MAX_SUPPORT_MCS 32
-
-//============================================================
-// ASIC WCID Table definition.
-//============================================================
-#define BSSID_WCID 1 // in infra mode, always put bssid with this WCID
-#define MCAST_WCID 0x0
-#define BSS0Mcast_WCID 0x0
-#define BSS1Mcast_WCID 0xf8
-#define BSS2Mcast_WCID 0xf9
-#define BSS3Mcast_WCID 0xfa
-#define BSS4Mcast_WCID 0xfb
-#define BSS5Mcast_WCID 0xfc
-#define BSS6Mcast_WCID 0xfd
-#define BSS7Mcast_WCID 0xfe
-#define RESERVED_WCID 0xff
-
-#define MAX_NUM_OF_ACL_LIST MAX_NUMBER_OF_ACL
-
-#define MAX_LEN_OF_MAC_TABLE MAX_NUMBER_OF_MAC // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
-
-#if MAX_LEN_OF_MAC_TABLE>MAX_AVAILABLE_CLIENT_WCID
-#error MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!!!!
-#endif
-
-#define MAX_NUM_OF_WDS_LINK_PERBSSID 3
-#define MAX_NUM_OF_WDS_LINK (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
-#define MAX_NUM_OF_EVENT MAX_NUMBER_OF_EVENT
-#define WDS_LINK_START_WCID (MAX_LEN_OF_MAC_TABLE-1)
-
-#define NUM_OF_TID 8
-#define MAX_AID_BA 4
-#define MAX_LEN_OF_BA_REC_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) //Block ACK recipient
-#define MAX_LEN_OF_BA_ORI_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) // Block ACK originator
-#define MAX_LEN_OF_BSS_TABLE 64
-#define MAX_REORDERING_MPDU_NUM 512
-
-// key related definitions
-#define SHARE_KEY_NUM 4
-#define MAX_LEN_OF_SHARE_KEY 16 // byte count
-#define MAX_LEN_OF_PEER_KEY 16 // byte count
-#define PAIRWISE_KEY_NUM 64 // in MAC ASIC pairwise key table
-#define GROUP_KEY_NUM 4
-#define PMK_LEN 32
-#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
-#define PMKID_NO 4 // Number of PMKID saved supported
-#define MAX_LEN_OF_MLME_BUFFER 2048
-
-// power status related definitions
-#define PWR_ACTIVE 0
-#define PWR_SAVE 1
-#define PWR_MMPS 2 //MIMO power save
-//#define PWR_UNKNOWN 2
-
-// Auth and Assoc mode related definitions
-#define AUTH_MODE_OPEN 0x00
-#define AUTH_MODE_KEY 0x01
-//#define AUTH_MODE_AUTO_SWITCH 0x03
-//#define AUTH_MODE_DEAUTH 0x04
-//#define AUTH_MODE_UPLAYER 0x05 // reserved for 802.11i use
-
-// BSS Type definitions
-#define BSS_ADHOC 0 // = Ndis802_11IBSS
-#define BSS_INFRA 1 // = Ndis802_11Infrastructure
-#define BSS_ANY 2 // = Ndis802_11AutoUnknown
-#define BSS_MONITOR 3 // = Ndis802_11Monitor
-
-
-// Reason code definitions
-#define REASON_RESERVED 0
-#define REASON_UNSPECIFY 1
-#define REASON_NO_LONGER_VALID 2
-#define REASON_DEAUTH_STA_LEAVING 3
-#define REASON_DISASSOC_INACTIVE 4
-#define REASON_DISASSPC_AP_UNABLE 5
-#define REASON_CLS2ERR 6
-#define REASON_CLS3ERR 7
-#define REASON_DISASSOC_STA_LEAVING 8
-#define REASON_STA_REQ_ASSOC_NOT_AUTH 9
-#define REASON_INVALID_IE 13
-#define REASON_MIC_FAILURE 14
-#define REASON_4_WAY_TIMEOUT 15
-#define REASON_GROUP_KEY_HS_TIMEOUT 16
-#define REASON_IE_DIFFERENT 17
-#define REASON_MCIPHER_NOT_VALID 18
-#define REASON_UCIPHER_NOT_VALID 19
-#define REASON_AKMP_NOT_VALID 20
-#define REASON_UNSUPPORT_RSNE_VER 21
-#define REASON_INVALID_RSNE_CAP 22
-#define REASON_8021X_AUTH_FAIL 23
-#define REASON_CIPHER_SUITE_REJECTED 24
-#define REASON_DECLINED 37
-
-#define REASON_QOS_UNSPECIFY 32
-#define REASON_QOS_LACK_BANDWIDTH 33
-#define REASON_POOR_CHANNEL_CONDITION 34
-#define REASON_QOS_OUTSIDE_TXOP_LIMITION 35
-#define REASON_QOS_QSTA_LEAVING_QBSS 36
-#define REASON_QOS_UNWANTED_MECHANISM 37
-#define REASON_QOS_MECH_SETUP_REQUIRED 38
-#define REASON_QOS_REQUEST_TIMEOUT 39
-#define REASON_QOS_CIPHER_NOT_SUPPORT 45
-
-// Status code definitions
-#define MLME_SUCCESS 0
-#define MLME_UNSPECIFY_FAIL 1
-#define MLME_CANNOT_SUPPORT_CAP 10
-#define MLME_REASSOC_DENY_ASSOC_EXIST 11
-#define MLME_ASSOC_DENY_OUT_SCOPE 12
-#define MLME_ALG_NOT_SUPPORT 13
-#define MLME_SEQ_NR_OUT_OF_SEQUENCE 14
-#define MLME_REJ_CHALLENGE_FAILURE 15
-#define MLME_REJ_TIMEOUT 16
-#define MLME_ASSOC_REJ_UNABLE_HANDLE_STA 17
-#define MLME_ASSOC_REJ_DATA_RATE 18
-
-#define MLME_ASSOC_REJ_NO_EXT_RATE 22
-#define MLME_ASSOC_REJ_NO_EXT_RATE_PBCC 23
-#define MLME_ASSOC_REJ_NO_CCK_OFDM 24
-
-#define MLME_QOS_UNSPECIFY 32
-#define MLME_REQUEST_DECLINED 37
-#define MLME_REQUEST_WITH_INVALID_PARAM 38
-#define MLME_DLS_NOT_ALLOW_IN_QBSS 48
-#define MLME_DEST_STA_NOT_IN_QBSS 49
-#define MLME_DEST_STA_IS_NOT_A_QSTA 50
-
-#define MLME_INVALID_FORMAT 0x51
-#define MLME_FAIL_NO_RESOURCE 0x52
-#define MLME_STATE_MACHINE_REJECT 0x53
-#define MLME_MAC_TABLE_FAIL 0x54
-
-// IE code
-#define IE_SSID 0
-#define IE_SUPP_RATES 1
-#define IE_FH_PARM 2
-#define IE_DS_PARM 3
-#define IE_CF_PARM 4
-#define IE_TIM 5
-#define IE_IBSS_PARM 6
-#define IE_COUNTRY 7 // 802.11d
-#define IE_802_11D_REQUEST 10 // 802.11d
-#define IE_QBSS_LOAD 11 // 802.11e d9
-#define IE_EDCA_PARAMETER 12 // 802.11e d9
-#define IE_TSPEC 13 // 802.11e d9
-#define IE_TCLAS 14 // 802.11e d9
-#define IE_SCHEDULE 15 // 802.11e d9
-#define IE_CHALLENGE_TEXT 16
-#define IE_POWER_CONSTRAINT 32 // 802.11h d3.3
-#define IE_POWER_CAPABILITY 33 // 802.11h d3.3
-#define IE_TPC_REQUEST 34 // 802.11h d3.3
-#define IE_TPC_REPORT 35 // 802.11h d3.3
-#define IE_SUPP_CHANNELS 36 // 802.11h d3.3
-#define IE_CHANNEL_SWITCH_ANNOUNCEMENT 37 // 802.11h d3.3
-#define IE_MEASUREMENT_REQUEST 38 // 802.11h d3.3
-#define IE_MEASUREMENT_REPORT 39 // 802.11h d3.3
-#define IE_QUIET 40 // 802.11h d3.3
-#define IE_IBSS_DFS 41 // 802.11h d3.3
-#define IE_ERP 42 // 802.11g
-#define IE_TS_DELAY 43 // 802.11e d9
-#define IE_TCLAS_PROCESSING 44 // 802.11e d9
-#define IE_QOS_CAPABILITY 46 // 802.11e d6
-#define IE_HT_CAP 45 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
-#define IE_AP_CHANNEL_REPORT 51 // 802.11k d6
-#define IE_HT_CAP2 52 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
-#define IE_RSN 48 // 802.11i d3.0
-#define IE_WPA2 48 // WPA2
-#define IE_EXT_SUPP_RATES 50 // 802.11g
-#define IE_SUPP_REG_CLASS 59 // 802.11y. Supported regulatory classes.
-#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT 60 // 802.11n
-#define IE_ADD_HT 61 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
-#define IE_ADD_HT2 53 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
-
-
-// For 802.11n D3.03
-//#define IE_NEW_EXT_CHA_OFFSET 62 // 802.11n d1. New extension channel offset elemet
-#define IE_SECONDARY_CH_OFFSET 62 // 802.11n D3.03 Secondary Channel Offset element
-#define IE_WAPI 68 // WAPI information element
-#define IE_2040_BSS_COEXIST 72 // 802.11n D3.0.3
-#define IE_2040_BSS_INTOLERANT_REPORT 73 // 802.11n D3.03
-#define IE_OVERLAPBSS_SCAN_PARM 74 // 802.11n D3.03
-#define IE_EXT_CAPABILITY 127 // 802.11n D3.03
-
-
-#define IE_WPA 221 // WPA
-#define IE_VENDOR_SPECIFIC 221 // Wifi WMM (WME)
-
-#define OUI_BROADCOM_HT 51 //
-#define OUI_BROADCOM_HTADD 52 //
-#define OUI_PREN_HT_CAP 51 //
-#define OUI_PREN_ADD_HT 52 //
-
-// CCX information
-#define IE_AIRONET_CKIP 133 // CCX1.0 ID 85H for CKIP
-#define IE_AP_TX_POWER 150 // CCX 2.0 for AP transmit power
-#define IE_MEASUREMENT_CAPABILITY 221 // CCX 2.0
-#define IE_CCX_V2 221
-#define IE_AIRONET_IPADDRESS 149 // CCX ID 95H for IP Address
-#define IE_AIRONET_CCKMREASSOC 156 // CCX ID 9CH for CCKM Reassociation Request element
-#define CKIP_NEGOTIATION_LENGTH 30
-#define AIRONET_IPADDRESS_LENGTH 10
-#define AIRONET_CCKMREASSOC_LENGTH 24
-
-// ========================================================
-// MLME state machine definition
-// ========================================================
-
-// STA MLME state mahcines
-#define ASSOC_STATE_MACHINE 1
-#define AUTH_STATE_MACHINE 2
-#define AUTH_RSP_STATE_MACHINE 3
-#define SYNC_STATE_MACHINE 4
-#define MLME_CNTL_STATE_MACHINE 5
-#define WPA_PSK_STATE_MACHINE 6
-#define LEAP_STATE_MACHINE 7
-#define AIRONET_STATE_MACHINE 8
-#define ACTION_STATE_MACHINE 9
-
-// AP MLME state machines
-#define AP_ASSOC_STATE_MACHINE 11
-#define AP_AUTH_STATE_MACHINE 12
-#define AP_AUTH_RSP_STATE_MACHINE 13
-#define AP_SYNC_STATE_MACHINE 14
-#define AP_CNTL_STATE_MACHINE 15
-#define AP_WPA_STATE_MACHINE 16
-
-#define WSC_STATE_MACHINE 17
-#define WSC_UPNP_STATE_MACHINE 18
-
-
-
-#ifdef QOS_DLS_SUPPORT
-#define DLS_STATE_MACHINE 26
-#endif // QOS_DLS_SUPPORT //
-
-//
-// STA's CONTROL/CONNECT state machine: states, events, total function #
-//
-#define CNTL_IDLE 0
-#define CNTL_WAIT_DISASSOC 1
-#define CNTL_WAIT_JOIN 2
-#define CNTL_WAIT_REASSOC 3
-#define CNTL_WAIT_START 4
-#define CNTL_WAIT_AUTH 5
-#define CNTL_WAIT_ASSOC 6
-#define CNTL_WAIT_AUTH2 7
-#define CNTL_WAIT_OID_LIST_SCAN 8
-#define CNTL_WAIT_OID_DISASSOC 9
-#ifdef RT2870
-#define CNTL_WAIT_SCAN_FOR_CONNECT 10
-#endif // RT2870 //
-
-#define MT2_ASSOC_CONF 34
-#define MT2_AUTH_CONF 35
-#define MT2_DEAUTH_CONF 36
-#define MT2_DISASSOC_CONF 37
-#define MT2_REASSOC_CONF 38
-#define MT2_PWR_MGMT_CONF 39
-#define MT2_JOIN_CONF 40
-#define MT2_SCAN_CONF 41
-#define MT2_START_CONF 42
-#define MT2_GET_CONF 43
-#define MT2_SET_CONF 44
-#define MT2_RESET_CONF 45
-#define MT2_MLME_ROAMING_REQ 52
-
-#define CNTL_FUNC_SIZE 1
-
-//
-// STA's ASSOC state machine: states, events, total function #
-//
-#define ASSOC_IDLE 0
-#define ASSOC_WAIT_RSP 1
-#define REASSOC_WAIT_RSP 2
-#define DISASSOC_WAIT_RSP 3
-#define MAX_ASSOC_STATE 4
-
-#define ASSOC_MACHINE_BASE 0
-#define MT2_MLME_ASSOC_REQ 0
-#define MT2_MLME_REASSOC_REQ 1
-#define MT2_MLME_DISASSOC_REQ 2
-#define MT2_PEER_DISASSOC_REQ 3
-#define MT2_PEER_ASSOC_REQ 4
-#define MT2_PEER_ASSOC_RSP 5
-#define MT2_PEER_REASSOC_REQ 6
-#define MT2_PEER_REASSOC_RSP 7
-#define MT2_DISASSOC_TIMEOUT 8
-#define MT2_ASSOC_TIMEOUT 9
-#define MT2_REASSOC_TIMEOUT 10
-#define MAX_ASSOC_MSG 11
-
-#define ASSOC_FUNC_SIZE (MAX_ASSOC_STATE * MAX_ASSOC_MSG)
-
-//
-// ACT state machine: states, events, total function #
-//
-#define ACT_IDLE 0
-#define MAX_ACT_STATE 1
-
-#define ACT_MACHINE_BASE 0
-
-//Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please don'es modify it by your self.
-//Category
-#define MT2_PEER_SPECTRUM_CATE 0
-#define MT2_PEER_QOS_CATE 1
-#define MT2_PEER_DLS_CATE 2
-#define MT2_PEER_BA_CATE 3
-#define MT2_PEER_PUBLIC_CATE 4
-#define MT2_PEER_RM_CATE 5
-#define MT2_PEER_HT_CATE 7 // 7.4.7
-#define MAX_PEER_CATE_MSG 7
-#define MT2_MLME_ADD_BA_CATE 8
-#define MT2_MLME_ORI_DELBA_CATE 9
-#define MT2_MLME_REC_DELBA_CATE 10
-#define MT2_MLME_QOS_CATE 11
-#define MT2_MLME_DLS_CATE 12
-#define MT2_ACT_INVALID 13
-#define MAX_ACT_MSG 14
-
-//Category field
-#define CATEGORY_SPECTRUM 0
-#define CATEGORY_QOS 1
-#define CATEGORY_DLS 2
-#define CATEGORY_BA 3
-#define CATEGORY_PUBLIC 4
-#define CATEGORY_RM 5
-#define CATEGORY_HT 7
-
-
-// DLS Action frame definition
-#define ACTION_DLS_REQUEST 0
-#define ACTION_DLS_RESPONSE 1
-#define ACTION_DLS_TEARDOWN 2
-
-//Spectrum Action field value 802.11h 7.4.1
-#define SPEC_MRQ 0 // Request
-#define SPEC_MRP 1 //Report
-#define SPEC_TPCRQ 2
-#define SPEC_TPCRP 3
-#define SPEC_CHANNEL_SWITCH 4
-
-
-//BA Action field value
-#define ADDBA_REQ 0
-#define ADDBA_RESP 1
-#define DELBA 2
-
-//Public's Action field value in Public Category. Some in 802.11y and some in 11n
-#define ACTION_BSS_2040_COEXIST 0 // 11n
-#define ACTION_DSE_ENABLEMENT 1 // 11y D9.0
-#define ACTION_DSE_DEENABLEMENT 2 // 11y D9.0
-#define ACTION_DSE_REG_LOCATION_ANNOUNCE 3 // 11y D9.0
-#define ACTION_EXT_CH_SWITCH_ANNOUNCE 4 // 11y D9.0
-#define ACTION_DSE_MEASUREMENT_REQ 5 // 11y D9.0
-#define ACTION_DSE_MEASUREMENT_REPORT 6 // 11y D9.0
-#define ACTION_MEASUREMENT_PILOT_ACTION 7 // 11y D9.0
-#define ACTION_DSE_POWER_CONSTRAINT 8 // 11y D9.0
-
-
-//HT Action field value
-#define NOTIFY_BW_ACTION 0
-#define SMPS_ACTION 1
-#define PSMP_ACTION 2
-#define SETPCO_ACTION 3
-#define MIMO_CHA_MEASURE_ACTION 4
-#define MIMO_N_BEACONFORM 5
-#define MIMO_BEACONFORM 6
-#define ANTENNA_SELECT 7
-#define HT_INFO_EXCHANGE 8
-
-#define ACT_FUNC_SIZE (MAX_ACT_STATE * MAX_ACT_MSG)
-//
-// STA's AUTHENTICATION state machine: states, evvents, total function #
-//
-#define AUTH_REQ_IDLE 0
-#define AUTH_WAIT_SEQ2 1
-#define AUTH_WAIT_SEQ4 2
-#define MAX_AUTH_STATE 3
-
-#define AUTH_MACHINE_BASE 0
-#define MT2_MLME_AUTH_REQ 0
-#define MT2_PEER_AUTH_EVEN 1
-#define MT2_AUTH_TIMEOUT 2
-#define MAX_AUTH_MSG 3
-
-#define AUTH_FUNC_SIZE (MAX_AUTH_STATE * MAX_AUTH_MSG)
-
-//
-// STA's AUTH_RSP state machine: states, events, total function #
-//
-#define AUTH_RSP_IDLE 0
-#define AUTH_RSP_WAIT_CHAL 1
-#define MAX_AUTH_RSP_STATE 2
-
-#define AUTH_RSP_MACHINE_BASE 0
-#define MT2_AUTH_CHALLENGE_TIMEOUT 0
-#define MT2_PEER_AUTH_ODD 1
-#define MT2_PEER_DEAUTH 2
-#define MAX_AUTH_RSP_MSG 3
-
-#define AUTH_RSP_FUNC_SIZE (MAX_AUTH_RSP_STATE * MAX_AUTH_RSP_MSG)
-
-//
-// STA's SYNC state machine: states, events, total function #
-//
-#define SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define JOIN_WAIT_BEACON 1
-#define SCAN_LISTEN 2
-#define MAX_SYNC_STATE 3
-
-#define SYNC_MACHINE_BASE 0
-#define MT2_MLME_SCAN_REQ 0
-#define MT2_MLME_JOIN_REQ 1
-#define MT2_MLME_START_REQ 2
-#define MT2_PEER_BEACON 3
-#define MT2_PEER_PROBE_RSP 4
-#define MT2_PEER_ATIM 5
-#define MT2_SCAN_TIMEOUT 6
-#define MT2_BEACON_TIMEOUT 7
-#define MT2_ATIM_TIMEOUT 8
-#define MT2_PEER_PROBE_REQ 9
-#define MAX_SYNC_MSG 10
-
-#define SYNC_FUNC_SIZE (MAX_SYNC_STATE * MAX_SYNC_MSG)
-
-//Messages for the DLS state machine
-#define DLS_IDLE 0
-#define MAX_DLS_STATE 1
-
-#define DLS_MACHINE_BASE 0
-#define MT2_MLME_DLS_REQ 0
-#define MT2_PEER_DLS_REQ 1
-#define MT2_PEER_DLS_RSP 2
-#define MT2_MLME_DLS_TEAR_DOWN 3
-#define MT2_PEER_DLS_TEAR_DOWN 4
-#define MAX_DLS_MSG 5
-
-#define DLS_FUNC_SIZE (MAX_DLS_STATE * MAX_DLS_MSG)
-
-//
-// STA's WPA-PSK State machine: states, events, total function #
-//
-#define WPA_PSK_IDLE 0
-#define MAX_WPA_PSK_STATE 1
-
-#define WPA_MACHINE_BASE 0
-#define MT2_EAPPacket 0
-#define MT2_EAPOLStart 1
-#define MT2_EAPOLLogoff 2
-#define MT2_EAPOLKey 3
-#define MT2_EAPOLASFAlert 4
-#define MAX_WPA_PSK_MSG 5
-
-#define WPA_PSK_FUNC_SIZE (MAX_WPA_PSK_STATE * MAX_WPA_PSK_MSG)
-
-//
-// STA's CISCO-AIRONET State machine: states, events, total function #
-//
-#define AIRONET_IDLE 0
-#define AIRONET_SCANNING 1
-#define MAX_AIRONET_STATE 2
-
-#define AIRONET_MACHINE_BASE 0
-#define MT2_AIRONET_MSG 0
-#define MT2_AIRONET_SCAN_REQ 1
-#define MT2_AIRONET_SCAN_DONE 2
-#define MAX_AIRONET_MSG 3
-
-#define AIRONET_FUNC_SIZE (MAX_AIRONET_STATE * MAX_AIRONET_MSG)
-
-//
-// WSC State machine: states, events, total function #
-//
-
-//
-// AP's CONTROL/CONNECT state machine: states, events, total function #
-//
-#define AP_CNTL_FUNC_SIZE 1
-
-//
-// AP's ASSOC state machine: states, events, total function #
-//
-#define AP_ASSOC_IDLE 0
-#define AP_MAX_ASSOC_STATE 1
-
-#define AP_ASSOC_MACHINE_BASE 0
-#define APMT2_MLME_DISASSOC_REQ 0
-#define APMT2_PEER_DISASSOC_REQ 1
-#define APMT2_PEER_ASSOC_REQ 2
-#define APMT2_PEER_REASSOC_REQ 3
-#define APMT2_CLS3ERR 4
-#define AP_MAX_ASSOC_MSG 5
-
-#define AP_ASSOC_FUNC_SIZE (AP_MAX_ASSOC_STATE * AP_MAX_ASSOC_MSG)
-
-//
-// AP's AUTHENTICATION state machine: states, events, total function #
-//
-#define AP_AUTH_REQ_IDLE 0
-#define AP_MAX_AUTH_STATE 1
-
-#define AP_AUTH_MACHINE_BASE 0
-#define APMT2_MLME_DEAUTH_REQ 0
-#define APMT2_CLS2ERR 1
-#define AP_MAX_AUTH_MSG 2
-
-#define AP_AUTH_FUNC_SIZE (AP_MAX_AUTH_STATE * AP_MAX_AUTH_MSG)
-
-//
-// AP's AUTH-RSP state machine: states, events, total function #
-//
-#define AP_AUTH_RSP_IDLE 0
-#define AP_MAX_AUTH_RSP_STATE 1
-
-#define AP_AUTH_RSP_MACHINE_BASE 0
-#define APMT2_AUTH_CHALLENGE_TIMEOUT 0
-#define APMT2_PEER_AUTH_ODD 1
-#define APMT2_PEER_DEAUTH 2
-#define AP_MAX_AUTH_RSP_MSG 3
-
-#define AP_AUTH_RSP_FUNC_SIZE (AP_MAX_AUTH_RSP_STATE * AP_MAX_AUTH_RSP_MSG)
-
-//
-// AP's SYNC state machine: states, events, total function #
-//
-#define AP_SYNC_IDLE 0
-#define AP_SCAN_LISTEN 1
-#define AP_MAX_SYNC_STATE 2
-
-#define AP_SYNC_MACHINE_BASE 0
-#define APMT2_PEER_PROBE_REQ 0
-#define APMT2_PEER_BEACON 1
-#define APMT2_MLME_SCAN_REQ 2
-#define APMT2_PEER_PROBE_RSP 3
-#define APMT2_SCAN_TIMEOUT 4
-#define APMT2_MLME_SCAN_CNCL 5
-#define AP_MAX_SYNC_MSG 6
-
-#define AP_SYNC_FUNC_SIZE (AP_MAX_SYNC_STATE * AP_MAX_SYNC_MSG)
-
-//
-// AP's WPA state machine: states, events, total function #
-//
-#define AP_WPA_PTK 0
-#define AP_MAX_WPA_PTK_STATE 1
-
-#define AP_WPA_MACHINE_BASE 0
-#define APMT2_EAPPacket 0
-#define APMT2_EAPOLStart 1
-#define APMT2_EAPOLLogoff 2
-#define APMT2_EAPOLKey 3
-#define APMT2_EAPOLASFAlert 4
-#define AP_MAX_WPA_MSG 5
-
-#define AP_WPA_FUNC_SIZE (AP_MAX_WPA_PTK_STATE * AP_MAX_WPA_MSG)
-
-
-
-// =============================================================================
-
-// value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header
-#define BTYPE_MGMT 0
-#define BTYPE_CNTL 1
-#define BTYPE_DATA 2
-
-// value domain of 802.11 MGMT frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_ASSOC_REQ 0
-#define SUBTYPE_ASSOC_RSP 1
-#define SUBTYPE_REASSOC_REQ 2
-#define SUBTYPE_REASSOC_RSP 3
-#define SUBTYPE_PROBE_REQ 4
-#define SUBTYPE_PROBE_RSP 5
-#define SUBTYPE_BEACON 8
-#define SUBTYPE_ATIM 9
-#define SUBTYPE_DISASSOC 10
-#define SUBTYPE_AUTH 11
-#define SUBTYPE_DEAUTH 12
-#define SUBTYPE_ACTION 13
-#define SUBTYPE_ACTION_NO_ACK 14
-
-// value domain of 802.11 CNTL frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_WRAPPER 7
-#define SUBTYPE_BLOCK_ACK_REQ 8
-#define SUBTYPE_BLOCK_ACK 9
-#define SUBTYPE_PS_POLL 10
-#define SUBTYPE_RTS 11
-#define SUBTYPE_CTS 12
-#define SUBTYPE_ACK 13
-#define SUBTYPE_CFEND 14
-#define SUBTYPE_CFEND_CFACK 15
-
-// value domain of 802.11 DATA frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_DATA 0
-#define SUBTYPE_DATA_CFACK 1
-#define SUBTYPE_DATA_CFPOLL 2
-#define SUBTYPE_DATA_CFACK_CFPOLL 3
-#define SUBTYPE_NULL_FUNC 4
-#define SUBTYPE_CFACK 5
-#define SUBTYPE_CFPOLL 6
-#define SUBTYPE_CFACK_CFPOLL 7
-#define SUBTYPE_QDATA 8
-#define SUBTYPE_QDATA_CFACK 9
-#define SUBTYPE_QDATA_CFPOLL 10
-#define SUBTYPE_QDATA_CFACK_CFPOLL 11
-#define SUBTYPE_QOS_NULL 12
-#define SUBTYPE_QOS_CFACK 13
-#define SUBTYPE_QOS_CFPOLL 14
-#define SUBTYPE_QOS_CFACK_CFPOLL 15
-
-// ACK policy of QOS Control field bit 6:5
-#define NORMAL_ACK 0x00 // b6:5 = 00
-#define NO_ACK 0x20 // b6:5 = 01
-#define NO_EXPLICIT_ACK 0x40 // b6:5 = 10
-#define BLOCK_ACK 0x60 // b6:5 = 11
-
-//
-// rtmp_data.c use these definition
-//
-#define LENGTH_802_11 24
-#define LENGTH_802_11_AND_H 30
-#define LENGTH_802_11_CRC_H 34
-#define LENGTH_802_11_CRC 28
-#define LENGTH_802_11_WITH_ADDR4 30
-#define LENGTH_802_3 14
-#define LENGTH_802_3_TYPE 2
-#define LENGTH_802_1_H 8
-#define LENGTH_EAPOL_H 4
-#define LENGTH_WMMQOS_H 2
-#define LENGTH_CRC 4
-#define MAX_SEQ_NUMBER 0x0fff
-#define LENGTH_802_3_NO_TYPE 12
-#define LENGTH_802_1Q 4 /* VLAN related */
-
-// STA_CSR4.field.TxResult
-#define TX_RESULT_SUCCESS 0
-#define TX_RESULT_ZERO_LENGTH 1
-#define TX_RESULT_UNDER_RUN 2
-#define TX_RESULT_OHY_ERROR 4
-#define TX_RESULT_RETRY_FAIL 6
-
-// All PHY rate summary in TXD
-// Preamble MODE in TxD
-#define MODE_CCK 0
-#define MODE_OFDM 1
-#ifdef DOT11_N_SUPPORT
-#define MODE_HTMIX 2
-#define MODE_HTGREENFIELD 3
-#endif // DOT11_N_SUPPORT //
-// MCS for CCK. BW.SGI.STBC are reserved
-#define MCS_LONGP_RATE_1 0 // long preamble CCK 1Mbps
-#define MCS_LONGP_RATE_2 1 // long preamble CCK 1Mbps
-#define MCS_LONGP_RATE_5_5 2
-#define MCS_LONGP_RATE_11 3
-#define MCS_SHORTP_RATE_1 4 // long preamble CCK 1Mbps. short is forbidden in 1Mbps
-#define MCS_SHORTP_RATE_2 5 // short preamble CCK 2Mbps
-#define MCS_SHORTP_RATE_5_5 6
-#define MCS_SHORTP_RATE_11 7
-// To send duplicate legacy OFDM. set BW=BW_40. SGI.STBC are reserved
-#define MCS_RATE_6 0 // legacy OFDM
-#define MCS_RATE_9 1 // OFDM
-#define MCS_RATE_12 2 // OFDM
-#define MCS_RATE_18 3 // OFDM
-#define MCS_RATE_24 4 // OFDM
-#define MCS_RATE_36 5 // OFDM
-#define MCS_RATE_48 6 // OFDM
-#define MCS_RATE_54 7 // OFDM
-// HT
-#define MCS_0 0 // 1S
-#define MCS_1 1
-#define MCS_2 2
-#define MCS_3 3
-#define MCS_4 4
-#define MCS_5 5
-#define MCS_6 6
-#define MCS_7 7
-#define MCS_8 8 // 2S
-#define MCS_9 9
-#define MCS_10 10
-#define MCS_11 11
-#define MCS_12 12
-#define MCS_13 13
-#define MCS_14 14
-#define MCS_15 15
-#define MCS_16 16 // 3*3
-#define MCS_17 17
-#define MCS_18 18
-#define MCS_19 19
-#define MCS_20 20
-#define MCS_21 21
-#define MCS_22 22
-#define MCS_23 23
-#define MCS_32 32
-#define MCS_AUTO 33
-
-#ifdef DOT11_N_SUPPORT
-// OID_HTPHYMODE
-// MODE
-#define HTMODE_MM 0
-#define HTMODE_GF 1
-#endif // DOT11_N_SUPPORT //
-
-// Fixed Tx MODE - HT, CCK or OFDM
-#define FIXED_TXMODE_HT 0
-#define FIXED_TXMODE_CCK 1
-#define FIXED_TXMODE_OFDM 2
-// BW
-#define BW_20 BAND_WIDTH_20
-#define BW_40 BAND_WIDTH_40
-#define BW_BOTH BAND_WIDTH_BOTH
-#define BW_10 BAND_WIDTH_10 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-
-#ifdef DOT11_N_SUPPORT
-// SHORTGI
-#define GI_400 GAP_INTERVAL_400 // only support in HT mode
-#define GI_BOTH GAP_INTERVAL_BOTH
-#endif // DOT11_N_SUPPORT //
-#define GI_800 GAP_INTERVAL_800
-// STBC
-#define STBC_NONE 0
-#ifdef DOT11_N_SUPPORT
-#define STBC_USE 1 // limited use in rt2860b phy
-#define RXSTBC_ONE 1 // rx support of one spatial stream
-#define RXSTBC_TWO 2 // rx support of 1 and 2 spatial stream
-#define RXSTBC_THR 3 // rx support of 1~3 spatial stream
-// MCS FEEDBACK
-#define MCSFBK_NONE 0 // not support mcs feedback /
-#define MCSFBK_RSV 1 // reserved
-#define MCSFBK_UNSOLICIT 2 // only support unsolict mcs feedback
-#define MCSFBK_MRQ 3 // response to both MRQ and unsolict mcs feedback
-
-// MIMO power safe
-#define MMPS_STATIC 0
-#define MMPS_DYNAMIC 1
-#define MMPS_RSV 2
-#define MMPS_ENABLE 3
-
-
-// A-MSDU size
-#define AMSDU_0 0
-#define AMSDU_1 1
-
-#endif // DOT11_N_SUPPORT //
-
-// MCS use 7 bits
-#define TXRATEMIMO 0x80
-#define TXRATEMCS 0x7F
-#define TXRATEOFDM 0x7F
-#define RATE_1 0
-#define RATE_2 1
-#define RATE_5_5 2
-#define RATE_11 3
-#define RATE_6 4 // OFDM
-#define RATE_9 5 // OFDM
-#define RATE_12 6 // OFDM
-#define RATE_18 7 // OFDM
-#define RATE_24 8 // OFDM
-#define RATE_36 9 // OFDM
-#define RATE_48 10 // OFDM
-#define RATE_54 11 // OFDM
-#define RATE_FIRST_OFDM_RATE RATE_6
-#define RATE_LAST_OFDM_RATE RATE_54
-#define RATE_6_5 12 // HT mix
-#define RATE_13 13 // HT mix
-#define RATE_19_5 14 // HT mix
-#define RATE_26 15 // HT mix
-#define RATE_39 16 // HT mix
-#define RATE_52 17 // HT mix
-#define RATE_58_5 18 // HT mix
-#define RATE_65 19 // HT mix
-#define RATE_78 20 // HT mix
-#define RATE_104 21 // HT mix
-#define RATE_117 22 // HT mix
-#define RATE_130 23 // HT mix
-//#define RATE_AUTO_SWITCH 255 // for StaCfg.FixedTxRate only
-#define HTRATE_0 12
-#define RATE_FIRST_MM_RATE HTRATE_0
-#define RATE_FIRST_HT_RATE HTRATE_0
-#define RATE_LAST_HT_RATE HTRATE_0
-
-// pTxWI->txop
-#define IFS_HTTXOP 0 // The txop will be handles by ASIC.
-#define IFS_PIFS 1
-#define IFS_SIFS 2
-#define IFS_BACKOFF 3
-
-// pTxD->RetryMode
-#define LONG_RETRY 1
-#define SHORT_RETRY 0
-
-// Country Region definition
-#define REGION_MINIMUM_BG_BAND 0
-#define REGION_0_BG_BAND 0 // 1-11
-#define REGION_1_BG_BAND 1 // 1-13
-#define REGION_2_BG_BAND 2 // 10-11
-#define REGION_3_BG_BAND 3 // 10-13
-#define REGION_4_BG_BAND 4 // 14
-#define REGION_5_BG_BAND 5 // 1-14
-#define REGION_6_BG_BAND 6 // 3-9
-#define REGION_7_BG_BAND 7 // 5-13
-#define REGION_31_BG_BAND 31 // 5-13
-#define REGION_MAXIMUM_BG_BAND 7
-
-#define REGION_MINIMUM_A_BAND 0
-#define REGION_0_A_BAND 0 // 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165
-#define REGION_1_A_BAND 1 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
-#define REGION_2_A_BAND 2 // 36, 40, 44, 48, 52, 56, 60, 64
-#define REGION_3_A_BAND 3 // 52, 56, 60, 64, 149, 153, 157, 161
-#define REGION_4_A_BAND 4 // 149, 153, 157, 161, 165
-#define REGION_5_A_BAND 5 // 149, 153, 157, 161
-#define REGION_6_A_BAND 6 // 36, 40, 44, 48
-#define REGION_7_A_BAND 7 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_8_A_BAND 8 // 52, 56, 60, 64
-#define REGION_9_A_BAND 9 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_10_A_BAND 10 // 36, 40, 44, 48, 149, 153, 157, 161, 165
-#define REGION_11_A_BAND 11 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
-#define REGION_MAXIMUM_A_BAND 11
-
-// pTxD->CipherAlg
-#define CIPHER_NONE 0
-#define CIPHER_WEP64 1
-#define CIPHER_WEP128 2
-#define CIPHER_TKIP 3
-#define CIPHER_AES 4
-#define CIPHER_CKIP64 5
-#define CIPHER_CKIP128 6
-#define CIPHER_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
-#define CIPHER_SMS4 8
-
-// value domain of pAd->RfIcType
-#define RFIC_2820 1 // 2.4G 2T3R
-#define RFIC_2850 2 // 2.4G/5G 2T3R
-#define RFIC_2720 3 // 2.4G 1T2R
-#define RFIC_2750 4 // 2.4G/5G 1T2R
-#define RFIC_3020 5 // 2.4G 1T1R
-#define RFIC_2020 6 // 2.4G B/G
-#define RFIC_3021 7 // 2.4G 1T2R
-#define RFIC_3022 8 // 2.4G 2T2R
-
-// LED Status.
-#define LED_LINK_DOWN 0
-#define LED_LINK_UP 1
-#define LED_RADIO_OFF 2
-#define LED_RADIO_ON 3
-#define LED_HALT 4
-#define LED_WPS 5
-#define LED_ON_SITE_SURVEY 6
-#define LED_POWER_UP 7
-
-// value domain of pAd->LedCntl.LedMode and E2PROM
-#define LED_MODE_DEFAULT 0
-#define LED_MODE_TWO_LED 1
-#define LED_MODE_SIGNAL_STREGTH 8 // EEPROM define =8
-
-// RC4 init value, used fro WEP & TKIP
-#define PPPINITFCS32 0xffffffff /* Initial FCS value */
-
-// value domain of pAd->StaCfg.PortSecured. 802.1X controlled port definition
-#define WPA_802_1X_PORT_SECURED 1
-#define WPA_802_1X_PORT_NOT_SECURED 2
-
-#define PAIRWISE_KEY 1
-#define GROUP_KEY 2
-
-//definition of DRS
-#define MAX_STEP_OF_TX_RATE_SWITCH 32
-
-
-// pre-allocated free NDIS PACKET/BUFFER poll for internal usage
-#define MAX_NUM_OF_FREE_NDIS_PACKET 128
-
-//Block ACK
-#define MAX_TX_REORDERBUF 64
-#define MAX_RX_REORDERBUF 64
-#define DEFAULT_TX_TIMEOUT 30
-#define DEFAULT_RX_TIMEOUT 30
-
-// definition of Recipient or Originator
-#define I_RECIPIENT TRUE
-#define I_ORIGINATOR FALSE
-
-#define DEFAULT_BBP_TX_POWER 0
-#define DEFAULT_RF_TX_POWER 5
-
-#define MAX_INI_BUFFER_SIZE 4096
-#define MAX_PARAM_BUFFER_SIZE (2048) // enough for ACL (18*64)
- //18 : the length of Mac address acceptable format "01:02:03:04:05:06;")
- //64 : MAX_NUM_OF_ACL_LIST
-// definition of pAd->OpMode
-#define OPMODE_STA 0
-#define OPMODE_AP 1
-//#define OPMODE_L3_BRG 2 // as AP and STA at the same time
-
-#ifdef RT_BIG_ENDIAN
-#define DIR_READ 0
-#define DIR_WRITE 1
-#define TYPE_TXD 0
-#define TYPE_RXD 1
-#define TYPE_TXINFO 0
-#define TYPE_RXINFO 1
-#define TYPE_TXWI 0
-#define TYPE_RXWI 1
-#endif
-
-// ========================= AP rtmp_def.h ===========================
-// value domain for pAd->EventTab.Log[].Event
-#define EVENT_RESET_ACCESS_POINT 0 // Log = "hh:mm:ss Restart Access Point"
-#define EVENT_ASSOCIATED 1 // Log = "hh:mm:ss STA 00:01:02:03:04:05 associated"
-#define EVENT_DISASSOCIATED 2 // Log = "hh:mm:ss STA 00:01:02:03:04:05 left this BSS"
-#define EVENT_AGED_OUT 3 // Log = "hh:mm:ss STA 00:01:02:03:04:05 was aged-out and removed from this BSS"
-#define EVENT_COUNTER_M 4
-#define EVENT_INVALID_PSK 5
-#define EVENT_MAX_EVENT_TYPE 6
-// ==== end of AP rtmp_def.h ============
-
-// definition RSSI Number
-#define RSSI_0 0
-#define RSSI_1 1
-#define RSSI_2 2
-
-// definition of radar detection
-#define RD_NORMAL_MODE 0 // Not found radar signal
-#define RD_SWITCHING_MODE 1 // Found radar signal, and doing channel switch
-#define RD_SILENCE_MODE 2 // After channel switch, need to be silence a while to ensure radar not found
-
-//Driver defined cid for mapping status and command.
-#define SLEEPCID 0x11
-#define WAKECID 0x22
-#define QUERYPOWERCID 0x33
-#define OWNERMCU 0x1
-#define OWNERCPU 0x0
-
-// MBSSID definition
-#define ENTRY_NOT_FOUND 0xFF
-
-
-/* After Linux 2.6.9,
- * VLAN module use Private (from user) interface flags (netdevice->priv_flags).
- * #define IFF_802_1Q_VLAN 0x1 -- 802.1Q VLAN device. in if.h
- * ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
- *
- * For this reason, we MUST use EVEN value in priv_flags
- */
-#define INT_MAIN 0x0100
-#define INT_MBSSID 0x0200
-#define INT_WDS 0x0300
-#define INT_APCLI 0x0400
-#define INT_MESH 0x0500
-
-// Use bitmap to allow coexist of ATE_TXFRAME and ATE_RXFRAME(i.e.,to support LoopBack mode)
-#ifdef RALINK_ATE
-#define ATE_START 0x00 // Start ATE
-#define ATE_STOP 0x80 // Stop ATE
-#define ATE_TXCONT 0x05 // Continuous Transmit
-#define ATE_TXCARR 0x09 // Transmit Carrier
-#define ATE_TXCARRSUPP 0x11 // Transmit Carrier Suppression
-#define ATE_TXFRAME 0x01 // Transmit Frames
-#define ATE_RXFRAME 0x02 // Receive Frames
-#ifdef RALINK_28xx_QA
-#define ATE_TXSTOP 0xe2 // Stop Transmition(i.e., TXCONT, TXCARR, TXCARRSUPP, and TXFRAME)
-#define ATE_RXSTOP 0xfd // Stop receiving Frames
-#define BBP22_TXFRAME 0x00 // Transmit Frames
-#define BBP22_TXCONT_OR_CARRSUPP 0x80 // Continuous Transmit or Carrier Suppression
-#define BBP22_TXCARR 0xc1 // Transmit Carrier
-#define BBP24_TXCONT 0x00 // Continuous Transmit
-#define BBP24_CARRSUPP 0x01 // Carrier Suppression
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-// WEP Key TYPE
-#define WEP_HEXADECIMAL_TYPE 0
-#define WEP_ASCII_TYPE 1
-
-
-
-// WIRELESS EVENTS definition
-/* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
-#define IW_CUSTOM_MAX_LEN 255 /* In bytes */
-
-// For system event - start
-#define IW_SYS_EVENT_FLAG_START 0x0200
-#define IW_ASSOC_EVENT_FLAG 0x0200
-#define IW_DISASSOC_EVENT_FLAG 0x0201
-#define IW_DEAUTH_EVENT_FLAG 0x0202
-#define IW_AGEOUT_EVENT_FLAG 0x0203
-#define IW_COUNTER_MEASURES_EVENT_FLAG 0x0204
-#define IW_REPLAY_COUNTER_DIFF_EVENT_FLAG 0x0205
-#define IW_RSNIE_DIFF_EVENT_FLAG 0x0206
-#define IW_MIC_DIFF_EVENT_FLAG 0x0207
-#define IW_ICV_ERROR_EVENT_FLAG 0x0208
-#define IW_MIC_ERROR_EVENT_FLAG 0x0209
-#define IW_GROUP_HS_TIMEOUT_EVENT_FLAG 0x020A
-#define IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG 0x020B
-#define IW_RSNIE_SANITY_FAIL_EVENT_FLAG 0x020C
-#define IW_SET_KEY_DONE_WPA1_EVENT_FLAG 0x020D
-#define IW_SET_KEY_DONE_WPA2_EVENT_FLAG 0x020E
-#define IW_STA_LINKUP_EVENT_FLAG 0x020F
-#define IW_STA_LINKDOWN_EVENT_FLAG 0x0210
-#define IW_SCAN_COMPLETED_EVENT_FLAG 0x0211
-#define IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG 0x0212
-// if add new system event flag, please upadte the IW_SYS_EVENT_FLAG_END
-#define IW_SYS_EVENT_FLAG_END 0x0212
-#define IW_SYS_EVENT_TYPE_NUM (IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
-// For system event - end
-
-// For spoof attack event - start
-#define IW_SPOOF_EVENT_FLAG_START 0x0300
-#define IW_CONFLICT_SSID_EVENT_FLAG 0x0300
-#define IW_SPOOF_ASSOC_RESP_EVENT_FLAG 0x0301
-#define IW_SPOOF_REASSOC_RESP_EVENT_FLAG 0x0302
-#define IW_SPOOF_PROBE_RESP_EVENT_FLAG 0x0303
-#define IW_SPOOF_BEACON_EVENT_FLAG 0x0304
-#define IW_SPOOF_DISASSOC_EVENT_FLAG 0x0305
-#define IW_SPOOF_AUTH_EVENT_FLAG 0x0306
-#define IW_SPOOF_DEAUTH_EVENT_FLAG 0x0307
-#define IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG 0x0308
-#define IW_REPLAY_ATTACK_EVENT_FLAG 0x0309
-// if add new spoof attack event flag, please upadte the IW_SPOOF_EVENT_FLAG_END
-#define IW_SPOOF_EVENT_FLAG_END 0x0309
-#define IW_SPOOF_EVENT_TYPE_NUM (IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
-// For spoof attack event - end
-
-// For flooding attack event - start
-#define IW_FLOOD_EVENT_FLAG_START 0x0400
-#define IW_FLOOD_AUTH_EVENT_FLAG 0x0400
-#define IW_FLOOD_ASSOC_REQ_EVENT_FLAG 0x0401
-#define IW_FLOOD_REASSOC_REQ_EVENT_FLAG 0x0402
-#define IW_FLOOD_PROBE_REQ_EVENT_FLAG 0x0403
-#define IW_FLOOD_DISASSOC_EVENT_FLAG 0x0404
-#define IW_FLOOD_DEAUTH_EVENT_FLAG 0x0405
-#define IW_FLOOD_EAP_REQ_EVENT_FLAG 0x0406
-// if add new flooding attack event flag, please upadte the IW_FLOOD_EVENT_FLAG_END
-#define IW_FLOOD_EVENT_FLAG_END 0x0406
-#define IW_FLOOD_EVENT_TYPE_NUM (IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
-// For flooding attack - end
-
-// End - WIRELESS EVENTS definition
-
-#ifdef CONFIG_STA_SUPPORT
-// definition for DLS, kathy
-#define MAX_NUM_OF_INIT_DLS_ENTRY 1
-#define MAX_NUM_OF_DLS_ENTRY MAX_NUMBER_OF_DLS_ENTRY
-
-//Block ACK , rt2860, kathy
-#define MAX_TX_REORDERBUF 64
-#define MAX_RX_REORDERBUF 64
-#define DEFAULT_TX_TIMEOUT 30
-#define DEFAULT_RX_TIMEOUT 30
-#ifndef CONFIG_AP_SUPPORT
-#define MAX_BARECI_SESSION 8
-#endif
-
-#ifndef IW_ESSID_MAX_SIZE
-/* Maximum size of the ESSID and pAd->nickname strings */
-#define IW_ESSID_MAX_SIZE 32
-#endif
-#endif // CONFIG_STA_SUPPORT //
-
-#ifdef MCAST_RATE_SPECIFIC
-#define MCAST_DISABLE 0
-#define MCAST_CCK 1
-#define MCAST_OFDM 2
-#define MCAST_HTMIX 3
-#endif // MCAST_RATE_SPECIFIC //
-
-// For AsicRadioOff/AsicRadioOn function
-#define DOT11POWERSAVE 0
-#define GUIRADIO_OFF 1
-#define RTMP_HALT 2
-#define GUI_IDLE_POWER_SAVE 3
-// --
-
-
-// definition for WpaSupport flag
-#define WPA_SUPPLICANT_DISABLE 0
-#define WPA_SUPPLICANT_ENABLE 1
-#define WPA_SUPPLICANT_ENABLE_WITH_WEB_UI 2
-
-// Endian byte swapping codes
-#define SWAP16(x) \
- ((UINT16)( \
- (((UINT16)(x) & (UINT16) 0x00ffU) << 8) | \
- (((UINT16)(x) & (UINT16) 0xff00U) >> 8) ))
-
-#define SWAP32(x) \
- ((UINT32)( \
- (((UINT32)(x) & (UINT32) 0x000000ffUL) << 24) | \
- (((UINT32)(x) & (UINT32) 0x0000ff00UL) << 8) | \
- (((UINT32)(x) & (UINT32) 0x00ff0000UL) >> 8) | \
- (((UINT32)(x) & (UINT32) 0xff000000UL) >> 24) ))
-
-#define SWAP64(x) \
- ((UINT64)( \
- (UINT64)(((UINT64)(x) & (UINT64) 0x00000000000000ffULL) << 56) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x000000000000ff00ULL) << 40) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x0000000000ff0000ULL) << 24) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x00000000ff000000ULL) << 8) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x000000ff00000000ULL) >> 8) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
- (UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
-
-#ifdef RT_BIG_ENDIAN
-
-#define cpu2le64(x) SWAP64((x))
-#define le2cpu64(x) SWAP64((x))
-#define cpu2le32(x) SWAP32((x))
-#define le2cpu32(x) SWAP32((x))
-#define cpu2le16(x) SWAP16((x))
-#define le2cpu16(x) SWAP16((x))
-#define cpu2be64(x) ((UINT64)(x))
-#define be2cpu64(x) ((UINT64)(x))
-#define cpu2be32(x) ((UINT32)(x))
-#define be2cpu32(x) ((UINT32)(x))
-#define cpu2be16(x) ((UINT16)(x))
-#define be2cpu16(x) ((UINT16)(x))
-
-#else // Little_Endian
-
-#define cpu2le64(x) ((UINT64)(x))
-#define le2cpu64(x) ((UINT64)(x))
-#define cpu2le32(x) ((UINT32)(x))
-#define le2cpu32(x) ((UINT32)(x))
-#define cpu2le16(x) ((UINT16)(x))
-#define le2cpu16(x) ((UINT16)(x))
-#define cpu2be64(x) SWAP64((x))
-#define be2cpu64(x) SWAP64((x))
-#define cpu2be32(x) SWAP32((x))
-#define be2cpu32(x) SWAP32((x))
-#define cpu2be16(x) SWAP16((x))
-#define be2cpu16(x) SWAP16((x))
-
-#endif // RT_BIG_ENDIAN
-
-#endif // __RTMP_DEF_H__
-
-
+#include "../rt2870/rtmp_def.h"
diff --git a/drivers/staging/rt3070/rtmp_type.h b/drivers/staging/rt3070/rtmp_type.h
index 4e4b168b9e92..42384e50679f 100644
--- a/drivers/staging/rt3070/rtmp_type.h
+++ b/drivers/staging/rt3070/rtmp_type.h
@@ -1,95 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_type.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
- Paul Lin 1-2-2004
-*/
-#ifndef __RTMP_TYPE_H__
-#define __RTMP_TYPE_H__
-
-
-#define PACKED __attribute__ ((packed))
-
-// Put platform dependent declaration here
-// For example, linux type definition
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned int UINT32;
-typedef unsigned long long UINT64;
-typedef int INT32;
-typedef long long INT64;
-
-typedef unsigned char * PUINT8;
-typedef unsigned short * PUINT16;
-typedef unsigned int * PUINT32;
-typedef unsigned long long * PUINT64;
-typedef int * PINT32;
-typedef long long * PINT64;
-
-typedef signed char CHAR;
-typedef signed short SHORT;
-typedef signed int INT;
-typedef signed long LONG;
-typedef signed long long LONGLONG;
-
-
-typedef unsigned char UCHAR;
-typedef unsigned short USHORT;
-typedef unsigned int UINT;
-typedef unsigned long ULONG;
-typedef unsigned long long ULONGLONG;
-
-typedef unsigned char BOOLEAN;
-typedef void VOID;
-
-typedef VOID * PVOID;
-typedef CHAR * PCHAR;
-typedef UCHAR * PUCHAR;
-typedef USHORT * PUSHORT;
-typedef LONG * PLONG;
-typedef ULONG * PULONG;
-typedef UINT * PUINT;
-
-typedef unsigned int NDIS_MEDIA_STATE;
-
-typedef union _LARGE_INTEGER {
- struct {
- UINT LowPart;
- INT32 HighPart;
- } u;
- INT64 QuadPart;
-} LARGE_INTEGER;
-
-#endif // __RTMP_TYPE_H__
-
+#include "../rt2870/rtmp_type.h"
diff --git a/drivers/staging/rt3070/spectrum.h b/drivers/staging/rt3070/spectrum.h
index 94cfa5b174fc..1ca9c2584bff 100644
--- a/drivers/staging/rt3070/spectrum.h
+++ b/drivers/staging/rt3070/spectrum.h
@@ -1,322 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
- */
-
-#ifndef __SPECTRUM_H__
-#define __SPECTRUM_H__
-
-#include "rtmp_type.h"
-#include "spectrum_def.h"
-
-typedef struct PACKED _TPC_REPORT_INFO
-{
- UINT8 TxPwr;
- UINT8 LinkMargin;
-} TPC_REPORT_INFO, *PTPC_REPORT_INFO;
-
-typedef struct PACKED _CH_SW_ANN_INFO
-{
- UINT8 ChSwMode;
- UINT8 Channel;
- UINT8 ChSwCnt;
-} CH_SW_ANN_INFO, *PCH_SW_ANN_INFO;
-
-typedef union PACKED _MEASURE_REQ_MODE
-{
-#ifdef RT_BIG_ENDIAN
- struct PACKED
- {
- UINT8 Rev1:4;
- UINT8 Report:1;
- UINT8 Request:1;
- UINT8 Enable:1;
- UINT8 Rev0:1;
- } field;
-#else
- struct PACKED
- {
- UINT8 Rev0:1;
- UINT8 Enable:1;
- UINT8 Request:1;
- UINT8 Report:1;
- UINT8 Rev1:4;
- } field;
-#endif // RT_BIG_ENDIAN //
- UINT8 word;
-} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
-
-typedef struct PACKED _MEASURE_REQ
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
-} MEASURE_REQ, *PMEASURE_REQ;
-
-typedef struct PACKED _MEASURE_REQ_INFO
-{
- UINT8 Token;
- MEASURE_REQ_MODE ReqMode;
- UINT8 ReqType;
- MEASURE_REQ MeasureReq;
-} MEASURE_REQ_INFO, *PMEASURE_REQ_INFO;
-
-typedef union PACKED _MEASURE_BASIC_REPORT_MAP
-{
-#ifdef RT_BIG_ENDIAN
- struct PACKED
- {
- UINT8 Rev:3;
- UINT8 Unmeasure:1;
- UINT8 Radar:1;
- UINT8 UnidentifiedSignal:1;
- UINT8 OfdmPreamble:1;
- UINT8 BSS:1;
- } field;
-#else
- struct PACKED
- {
- UINT8 BSS:1;
- UINT8 OfdmPreamble:1;
- UINT8 UnidentifiedSignal:1;
- UINT8 Radar:1;
- UINT8 Unmeasure:1;
- UINT8 Rev:3;
- } field;
-#endif // RT_BIG_ENDIAN //
- UINT8 word;
-} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
-
-typedef struct PACKED _MEASURE_BASIC_REPORT
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
- MEASURE_BASIC_REPORT_MAP Map;
-} MEASURE_BASIC_REPORT, *PMEASURE_BASIC_REPORT;
-
-typedef struct PACKED _MEASURE_CCA_REPORT
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
- UINT8 CCA_Busy_Fraction;
-} MEASURE_CCA_REPORT, *PMEASURE_CCA_REPORT;
-
-typedef struct PACKED _MEASURE_RPI_REPORT
-{
- UINT8 ChNum;
- UINT64 MeasureStartTime;
- UINT16 MeasureDuration;
- UINT8 RPI_Density[8];
-} MEASURE_RPI_REPORT, *PMEASURE_RPI_REPORT;
-
-typedef union PACKED _MEASURE_REPORT_MODE
-{
- struct PACKED
- {
-#ifdef RT_BIG_ENDIAN
- UINT8 Rev:5;
- UINT8 Refused:1;
- UINT8 Incapable:1;
- UINT8 Late:1;
-#else
- UINT8 Late:1;
- UINT8 Incapable:1;
- UINT8 Refused:1;
- UINT8 Rev:5;
-#endif // RT_BIG_ENDIAN //
- } field;
- UINT8 word;
-} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
-
-typedef struct PACKED _MEASURE_REPORT_INFO
-{
- UINT8 Token;
- MEASURE_REPORT_MODE ReportMode;
- UINT8 ReportType;
- UINT8 Octect[0];
-} MEASURE_REPORT_INFO, *PMEASURE_REPORT_INFO;
-
-typedef struct PACKED _QUIET_INFO
-{
- UINT8 QuietCnt;
- UINT8 QuietPeriod;
- UINT8 QuietDuration;
- UINT8 QuietOffset;
-} QUIET_INFO, *PQUIET_INFO;
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 MeasureCh,
- IN UINT16 MeasureDuration);
-
-/*
- ==========================================================================
- Description:
- Prepare Measurement report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueMeasurementRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 MeasureToken,
- IN UINT8 MeasureReqMode,
- IN UINT8 MeasureReqType,
- IN UINT8 ReportInfoLen,
- IN PUINT8 pReportInfo);
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Request action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCReq(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UCHAR DialogToken);
-
-/*
- ==========================================================================
- Description:
- Prepare TPC Report action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueTPCRep(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 DialogToken,
- IN UINT8 TxPwr,
- IN UINT8 LinkMargin);
-
-/*
- ==========================================================================
- Description:
- Prepare Channel Switch Announcement action frame and enqueue it into
- management queue waiting for transmition.
-
- Parametrs:
- 1. the destination mac address of the frame.
- 2. Channel switch announcement mode.
- 2. a New selected channel.
-
- Return : None.
- ==========================================================================
- */
-VOID EnqueueChSwAnn(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN UINT8 ChSwMode,
- IN UINT8 NewCh);
-
-/*
- ==========================================================================
- Description:
- Spectrun action frames Handler such as channel switch annoucement,
- measurement report, measurement request actions frames.
-
- Parametrs:
- Elme - MLME message containing the received frame
-
- Return : None.
- ==========================================================================
- */
-VOID PeerSpectrumAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem);
-
-/*
- ==========================================================================
- Description:
-
- Parametrs:
-
- Return : None.
- ==========================================================================
- */
-INT Set_MeasureReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-INT Set_TpcReq_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-
-VOID MeasureReqTabInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID MeasureReqTabExit(
- IN PRTMP_ADAPTER pAd);
-
-VOID TpcReqTabInit(
- IN PRTMP_ADAPTER pAd);
-
-VOID TpcReqTabExit(
- IN PRTMP_ADAPTER pAd);
-
-VOID NotifyChSwAnnToPeerAPs(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pRA,
- IN PUCHAR pTA,
- IN UINT8 ChSwMode,
- IN UINT8 Channel);
-#endif // __SPECTRUM_H__ //
-
+#include "../rt2870/spectrum.h"
diff --git a/drivers/staging/rt3070/spectrum_def.h b/drivers/staging/rt3070/spectrum_def.h
index 4ca4817bba05..892bc88c65f5 100644
--- a/drivers/staging/rt3070/spectrum_def.h
+++ b/drivers/staging/rt3070/spectrum_def.h
@@ -1,95 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- spectrum_def.h
-
- Abstract:
- Handle association related requests either from WSTA or from local MLME
-
- Revision History:
- Who When What
- --------- ---------- ----------------------------------------------
- Fonchi Wu 2008 created for 802.11h
- */
-
-#ifndef __SPECTRUM_DEF_H__
-#define __SPECTRUM_DEF_H__
-
-#define MAX_MEASURE_REQ_TAB_SIZE 3
-#define MAX_HASH_MEASURE_REQ_TAB_SIZE MAX_MEASURE_REQ_TAB_SIZE
-
-#define MAX_TPC_REQ_TAB_SIZE 3
-#define MAX_HASH_TPC_REQ_TAB_SIZE MAX_TPC_REQ_TAB_SIZE
-
-#define MIN_RCV_PWR 100 /* Negative value ((dBm) */
-
-#define RM_TPC_REQ 0
-#define RM_MEASURE_REQ 1
-
-#define RM_BASIC 0
-#define RM_CCA 1
-#define RM_RPI_HISTOGRAM 2
-
-#define TPC_REQ_AGE_OUT 500 /* ms */
-#define MQ_REQ_AGE_OUT 500 /* ms */
-
-#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
-#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
-
-typedef struct _MEASURE_REQ_ENTRY
-{
- struct _MEASURE_REQ_ENTRY *pNext;
- ULONG lastTime;
- BOOLEAN Valid;
- UINT8 DialogToken;
- UINT8 MeasureDialogToken[3]; // 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure.
-} MEASURE_REQ_ENTRY, *PMEASURE_REQ_ENTRY;
-
-typedef struct _MEASURE_REQ_TAB
-{
- UCHAR Size;
- PMEASURE_REQ_ENTRY Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
- MEASURE_REQ_ENTRY Content[MAX_MEASURE_REQ_TAB_SIZE];
-} MEASURE_REQ_TAB, *PMEASURE_REQ_TAB;
-
-typedef struct _TPC_REQ_ENTRY
-{
- struct _TPC_REQ_ENTRY *pNext;
- ULONG lastTime;
- BOOLEAN Valid;
- UINT8 DialogToken;
-} TPC_REQ_ENTRY, *PTPC_REQ_ENTRY;
-
-typedef struct _TPC_REQ_TAB
-{
- UCHAR Size;
- PTPC_REQ_ENTRY Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
- TPC_REQ_ENTRY Content[MAX_TPC_REQ_TAB_SIZE];
-} TPC_REQ_TAB, *PTPC_REQ_TAB;
-
-#endif // __SPECTRUM_DEF_H__ //
-
+#include "../rt2870/spectrum_def.h"
diff --git a/drivers/staging/rt3070/sta/aironet.c b/drivers/staging/rt3070/sta/aironet.c
index 4af4a1906181..48fcc4695275 100644
--- a/drivers/staging/rt3070/sta/aironet.c
+++ b/drivers/staging/rt3070/sta/aironet.c
@@ -1,1312 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- aironet.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 04-06-15 Initial
-*/
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
- ==========================================================================
- */
-VOID AironetStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_AIRONET_STATE, MAX_AIRONET_MSG, (STATE_MACHINE_FUNC)Drop, AIRONET_IDLE, AIRONET_MACHINE_BASE);
- StateMachineSetAction(S, AIRONET_IDLE, MT2_AIRONET_MSG, (STATE_MACHINE_FUNC)AironetMsgAction);
- StateMachineSetAction(S, AIRONET_IDLE, MT2_AIRONET_SCAN_REQ, (STATE_MACHINE_FUNC)AironetRequestAction);
- StateMachineSetAction(S, AIRONET_SCANNING, MT2_AIRONET_SCAN_DONE, (STATE_MACHINE_FUNC)AironetReportAction);
-}
-
-/*
- ==========================================================================
- Description:
- This is state machine function.
- When receiving EAPOL packets which is for 802.1x key management.
- Use both in WPA, and WPAPSK case.
- In this function, further dispatch to different functions according to the received packet. 3 categories are :
- 1. normal 4-way pairwisekey and 2-way groupkey handshake
- 2. MIC error (Countermeasures attack) report packet from STA.
- 3. Request for pairwise/group key update from STA
- Return:
- ==========================================================================
-*/
-VOID AironetMsgAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Length;
- UCHAR Index, i;
- PUCHAR pData;
- PAIRONET_RM_REQUEST_FRAME pRMReq;
- PRM_REQUEST_ACTION pReqElem;
-
- DBGPRINT(RT_DEBUG_TRACE, ("-----> AironetMsgAction\n"));
-
- // 0. Get Aironet IAPP header first
- pRMReq = (PAIRONET_RM_REQUEST_FRAME) &Elem->Msg[LENGTH_802_11];
- pData = (PUCHAR) &Elem->Msg[LENGTH_802_11];
-
- // 1. Change endian format form network to little endian
- Length = be2cpu16(pRMReq->IAPP.Length);
-
- // 2.0 Sanity check, this should only happen when CCX 2.0 support is enabled
- if (pAd->StaCfg.CCXEnable != TRUE)
- return;
-
- // 2.1 Radio measurement must be on
- if (pAd->StaCfg.CCXControl.field.RMEnable != 1)
- return;
-
- // 2.2. Debug print all bit information
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP ID & Length %d\n", Length));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Type %x\n", pRMReq->IAPP.Type));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP SubType %x\n", pRMReq->IAPP.SubType));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Dialog Token %x\n", pRMReq->IAPP.Token));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Activation Delay %x\n", pRMReq->Delay));
- DBGPRINT(RT_DEBUG_TRACE, ("IAPP Measurement Offset %x\n", pRMReq->Offset));
-
- // 3. Check IAPP frame type, it must be 0x32 for Cisco Aironet extension
- if (pRMReq->IAPP.Type != AIRONET_IAPP_TYPE)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP type for Cisco Aironet extension\n"));
- return;
- }
-
- // 4. Check IAPP frame subtype, it must be 0x01 for Cisco Aironet extension request.
- // Since we are acting as client only, we will disregards reply subtype.
- if (pRMReq->IAPP.SubType != AIRONET_IAPP_SUBTYPE_REQUEST)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP subtype for Cisco Aironet extension\n"));
- return;
- }
-
- // 5. Verify Destination MAC and Source MAC, both should be all zeros.
- if (! MAC_ADDR_EQUAL(pRMReq->IAPP.DA, ZERO_MAC_ADDR))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP DA for Cisco Aironet extension, it's not Zero\n"));
- return;
- }
-
- if (! MAC_ADDR_EQUAL(pRMReq->IAPP.SA, ZERO_MAC_ADDR))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Wrong IAPP SA for Cisco Aironet extension, it's not Zero\n"));
- return;
- }
-
- // 6. Reinit all report related fields
- NdisZeroMemory(pAd->StaCfg.FrameReportBuf, 2048);
- NdisZeroMemory(pAd->StaCfg.BssReportOffset, sizeof(USHORT) * MAX_LEN_OF_BSS_TABLE);
- NdisZeroMemory(pAd->StaCfg.MeasurementRequest, sizeof(RM_REQUEST_ACTION) * 4);
-
- // 7. Point to the start of first element report element
- pAd->StaCfg.FrameReportLen = LENGTH_802_11 + sizeof(AIRONET_IAPP_HEADER);
- DBGPRINT(RT_DEBUG_TRACE, ("FR len = %d\n", pAd->StaCfg.FrameReportLen));
- pAd->StaCfg.LastBssIndex = 0xff;
- pAd->StaCfg.RMReqCnt = 0;
- pAd->StaCfg.ParallelReq = FALSE;
- pAd->StaCfg.ParallelDuration = 0;
- pAd->StaCfg.ParallelChannel = 0;
- pAd->StaCfg.IAPPToken = pRMReq->IAPP.Token;
- pAd->StaCfg.CurrentRMReqIdx = 0;
- pAd->StaCfg.CLBusyBytes = 0;
- // Reset the statistics
- for (i = 0; i < 8; i++)
- pAd->StaCfg.RPIDensity[i] = 0;
-
- Index = 0;
-
- // 8. Save dialog token for report
- pAd->StaCfg.IAPPToken = pRMReq->IAPP.Token;
-
- // Save Activation delay & measurement offset, Not really needed
-
- // 9. Point to the first request element
- pData += sizeof(AIRONET_RM_REQUEST_FRAME);
- // Length should exclude the CISCO Aironet SNAP header
- Length -= (sizeof(AIRONET_RM_REQUEST_FRAME) - LENGTH_802_1_H);
-
- // 10. Start Parsing the Measurement elements.
- // Be careful about multiple MR elements within one frames.
- while (Length > 0)
- {
- pReqElem = (PRM_REQUEST_ACTION) pData;
- switch (pReqElem->ReqElem.Eid)
- {
- case IE_MEASUREMENT_REQUEST:
- // From the example, it seems we only need to support one request in one frame
- // There is no multiple request in one frame.
- // Besides, looks like we need to take care the measurement request only.
- // The measurement request is always 4 bytes.
-
- // Start parsing this type of request.
- // 0. Eid is IE_MEASUREMENT_REQUEST
- // 1. Length didn't include Eid and Length field, it always be 8.
- // 2. Measurement Token, we nned to save it for the corresponding report.
- // 3. Measurement Mode, Although there are definitions, but we din't see value other than
- // 0 from test specs examples.
- // 4. Measurement Type, this is what we need to do.
- switch (pReqElem->ReqElem.Type)
- {
- case MSRN_TYPE_CHANNEL_LOAD_REQ:
- case MSRN_TYPE_NOISE_HIST_REQ:
- case MSRN_TYPE_BEACON_REQ:
- // Check the Enable non-serving channel measurement control
- if (pAd->StaCfg.CCXControl.field.DCRMEnable == 0)
- {
- // Check channel before enqueue the action
- if (pReqElem->Measurement.Channel != pAd->CommonCfg.Channel)
- break;
- }
- else
- {
- // If off channel measurement, check the TU duration limit
- if (pReqElem->Measurement.Channel != pAd->CommonCfg.Channel)
- if (pReqElem->Measurement.Duration > pAd->StaCfg.CCXControl.field.TuLimit)
- break;
- }
-
- // Save requests and execute actions later
- NdisMoveMemory(&pAd->StaCfg.MeasurementRequest[Index], pReqElem, sizeof(RM_REQUEST_ACTION));
- Index += 1;
- break;
-
- case MSRN_TYPE_FRAME_REQ:
- // Since it's option, we will support later
- // FrameRequestAction(pAd, pData);
- break;
-
- default:
- break;
- }
-
- // Point to next Measurement request
- pData += sizeof(RM_REQUEST_ACTION);
- Length -= sizeof(RM_REQUEST_ACTION);
- break;
-
- // We accept request only, all others are dropped
- case IE_MEASUREMENT_REPORT:
- case IE_AP_TX_POWER:
- case IE_MEASUREMENT_CAPABILITY:
- default:
- return;
- }
- }
-
- // 11. Update some flags and index
- pAd->StaCfg.RMReqCnt = Index;
-
- if (Index)
- {
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<----- AironetMsgAction\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID AironetRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRM_REQUEST_ACTION pReq;
-
- // 1. Point to next request element
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- // 2. Parse measurement type and call appropriate functions
- if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
- // Channel Load measurement request
- ChannelLoadRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
- // Noise Histogram measurement request
- NoiseHistRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_BEACON_REQ)
- // Beacon measurement request
- BeaconRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else
- // Unknown. Do nothing and return, this should never happen
- return;
-
- // 3. Peek into the next request, if it's parallel, we will update the scan time to the largest one
- if ((pAd->StaCfg.CurrentRMReqIdx + 1) < pAd->StaCfg.RMReqCnt)
- {
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx + 1];
- // Check for parallel bit
- if ((pReq->ReqElem.Mode & 0x01) && (pReq->Measurement.Channel == pAd->StaCfg.CCXScanChannel))
- {
- // Update parallel mode request information
- pAd->StaCfg.ParallelReq = TRUE;
- pAd->StaCfg.CCXScanTime = ((pReq->Measurement.Duration > pAd->StaCfg.CCXScanTime) ?
- (pReq->Measurement.Duration) : (pAd->StaCfg.CCXScanTime));
- }
- }
-
- // 4. Call RT28XX_MLME_HANDLER to execute the request mlme commands, Scan request is the only one used
- RT28XX_MLME_HANDLER(pAd);
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare channel load report action, special scan operation added
- to support
-
- Arguments:
- pAd Pointer to our adapter
- pData Start from element ID
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ChannelLoadRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PRM_REQUEST_ACTION pReq;
- MLME_SCAN_REQ_STRUCT ScanReq;
- UCHAR ZeroSsid[32];
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- PHEADER_802_11 pNullFrame;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadRequestAction ----->\n"));
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
- NdisZeroMemory(ZeroSsid, 32);
-
- // Prepare for special scan request
- // The scan definition is different with our Active, Passive scan definition.
- // For CCX2, Active means send out probe request with broadcast BSSID.
- // Passive means no probe request sent, only listen to the beacons.
- // The channel scanned is fixed as specified, no need to scan all channels.
- // The scan wait time is specified in the request too.
- // Passive scan Mode
-
- // Control state machine is not idle, reject the request
- if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_CHANNEL_LOAD);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- pAd->StaCfg.CCXReqType = MSRN_TYPE_CHANNEL_LOAD_REQ;
- pAd->StaCfg.CLBusyBytes = 0;
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, 0x1010);
-
- // Set channel load measurement flag
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadRequestAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare noise histogram report action, special scan operation added
- to support
-
- Arguments:
- pAd Pointer to our adapter
- pData Start from element ID
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID NoiseHistRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PRM_REQUEST_ACTION pReq;
- MLME_SCAN_REQ_STRUCT ScanReq;
- UCHAR ZeroSsid[32], i;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- PHEADER_802_11 pNullFrame;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistRequestAction ----->\n"));
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
- NdisZeroMemory(ZeroSsid, 32);
-
- // Prepare for special scan request
- // The scan definition is different with our Active, Passive scan definition.
- // For CCX2, Active means send out probe request with broadcast BSSID.
- // Passive means no probe request sent, only listen to the beacons.
- // The channel scanned is fixed as specified, no need to scan all channels.
- // The scan wait time is specified in the request too.
- // Passive scan Mode
-
- // Control state machine is not idle, reject the request
- if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_NOISE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_NOISE_HIST_REQ;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- // Reset the statistics
- for (i = 0; i < 8; i++)
- pAd->StaCfg.RPIDensity[i] = 0;
-
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, 0x1010);
-
- // Set channel load measurement flag
- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistRequestAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare Beacon report action, special scan operation added
- to support
-
- Arguments:
- pAd Pointer to our adapter
- pData Start from element ID
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID BeaconRequestAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PRM_REQUEST_ACTION pReq;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- PHEADER_802_11 pNullFrame;
- MLME_SCAN_REQ_STRUCT ScanReq;
- UCHAR ZeroSsid[32];
-
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconRequestAction ----->\n"));
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
- NdisZeroMemory(ZeroSsid, 32);
-
- // Prepare for special scan request
- // The scan definition is different with our Active, Passive scan definition.
- // For CCX2, Active means send out probe request with broadcast BSSID.
- // Passive means no probe request sent, only listen to the beacons.
- // The channel scanned is fixed as specified, no need to scan all channels.
- // The scan wait time is specified in the request too.
- if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_PASSIVE)
- {
- // Passive scan Mode
- DBGPRINT(RT_DEBUG_TRACE, ("Passive Scan Mode!\n"));
-
- // Control state machine is not idle, reject the request
- if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_PASSIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_BEACON_REQ;
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
- }
- else if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_ACTIVE)
- {
- // Active scan Mode
- DBGPRINT(RT_DEBUG_TRACE, ("Active Scan Mode!\n"));
-
- // Control state machine is not idle, reject the request
- if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- return;
-
- // Fill out stuff for scan request
- ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-
- // Reset some internal control flags to make sure this scan works.
- BssTableInit(&pAd->StaCfg.CCXBssTab);
- pAd->StaCfg.ScanCnt = 0;
- pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
- pAd->StaCfg.CCXScanTime = pReq->Measurement.Duration;
- pAd->StaCfg.CCXReqType = MSRN_TYPE_BEACON_REQ;
- DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));
-
- // If it's non serving channel scan, send out a null frame with PSM bit on.
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- {
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- pNullFrame = (PHEADER_802_11) pOutBuffer;
- // Make the power save Null frame with PSM bit on
- MgtMacHeaderInit(pAd, pNullFrame, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pNullFrame->Duration = 0;
- pNullFrame->FC.Type = BTYPE_DATA;
- pNullFrame->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- MlmeFreeMemory(pAd, pOutBuffer);
- DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
- RTMPusecDelay(5000);
- }
-
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
- }
- else if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_BEACON_TABLE)
- {
- // Beacon report Mode, report all the APS in current bss table
- DBGPRINT(RT_DEBUG_TRACE, ("Beacon Report Mode!\n"));
-
- // Copy current BSS table to CCX table, we can omit this step later on.
- NdisMoveMemory(&pAd->StaCfg.CCXBssTab, &pAd->ScanTab, sizeof(BSS_TABLE));
-
- // Create beacon report from Bss table
- AironetCreateBeaconReportFromBssTable(pAd);
-
- // Set state to scanning
- pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-
- // Enqueue report request
- // Cisco scan request is finished, prepare beacon report
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
- }
- else
- {
- // Wrong scan Mode
- DBGPRINT(RT_DEBUG_TRACE, ("Wrong Scan Mode!\n"));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconRequestAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID AironetReportAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRM_REQUEST_ACTION pReq;
- ULONG Now32;
-
- NdisGetSystemUpTime(&Now32);
- pAd->StaCfg.LastBeaconRxTime = Now32;
-
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetReportAction ----->\n"));
-
- // 1. Parse measurement type and call appropriate functions
- if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
- // Channel Load measurement request
- ChannelLoadReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
- // Noise Histogram measurement request
- NoiseHistReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_BEACON_REQ)
- // Beacon measurement request
- BeaconReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else
- // Unknown. Do nothing and return
- ;
-
- // 2. Point to the correct index of action element, start from 0
- pAd->StaCfg.CurrentRMReqIdx++;
-
- // 3. Check for parallel actions
- if (pAd->StaCfg.ParallelReq == TRUE)
- {
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- // Process next action right away
- if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
- // Channel Load measurement request
- ChannelLoadReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
- else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
- // Noise Histogram measurement request
- NoiseHistReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
-
- pAd->StaCfg.ParallelReq = FALSE;
- pAd->StaCfg.CurrentRMReqIdx++;
- }
-
- if (pAd->StaCfg.CurrentRMReqIdx >= pAd->StaCfg.RMReqCnt)
- {
- // 4. There is no more unprocessed measurement request, go for transmit this report
- AironetFinalReportAction(pAd);
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
- }
- else
- {
- pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-
- if (pReq->Measurement.Channel != pAd->CommonCfg.Channel)
- {
- RTMPusecDelay(100000);
- }
-
- // 5. There are more requests to be measure
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID AironetFinalReportAction(
- IN PRTMP_ADAPTER pAd)
-{
- PUCHAR pDest;
- PAIRONET_IAPP_HEADER pIAPP;
- PHEADER_802_11 pHeader;
- UCHAR AckRate = RATE_2;
- USHORT AckDuration = 0;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetFinalReportAction ----->\n"));
-
- // 0. Set up the frame pointer, Frame was inited at the end of message action
- pDest = &pAd->StaCfg.FrameReportBuf[LENGTH_802_11];
-
- // 1. Update report IAPP fields
- pIAPP = (PAIRONET_IAPP_HEADER) pDest;
-
- // 2. Copy Cisco SNAP header
- NdisMoveMemory(pIAPP->CiscoSnapHeader, SNAP_AIRONET, LENGTH_802_1_H);
-
- // 3. network order for this 16bit length
- pIAPP->Length = cpu2be16(pAd->StaCfg.FrameReportLen - LENGTH_802_11 - LENGTH_802_1_H);
-
- // 3.1 sanity check the report length, ignore it if there is nothing to report
- if (be2cpu16(pIAPP->Length) <= 18)
- return;
-
- // 4. Type must be 0x32
- pIAPP->Type = AIRONET_IAPP_TYPE;
-
- // 5. SubType for report must be 0x81
- pIAPP->SubType = AIRONET_IAPP_SUBTYPE_REPORT;
-
- // 6. DA is not used and must be zero, although the whole frame was cleared at the start of function
- // We will do it again here. We can use BSSID instead
- COPY_MAC_ADDR(pIAPP->DA, pAd->CommonCfg.Bssid);
-
- // 7. SA is the client reporting which must be our MAC
- COPY_MAC_ADDR(pIAPP->SA, pAd->CurrentAddress);
-
- // 8. Copy the saved dialog token
- pIAPP->Token = pAd->StaCfg.IAPPToken;
-
- // 9. Make the Report frame 802.11 header
- // Reuse function in wpa.c
- pHeader = (PHEADER_802_11) pAd->StaCfg.FrameReportBuf;
- pAd->Sequence ++;
- WpaMacHeaderInit(pAd, pHeader, 0, pAd->CommonCfg.Bssid);
-
- // ACK size is 14 include CRC, and its rate is based on real time information
- AckRate = pAd->CommonCfg.ExpectedACKRate[pAd->CommonCfg.MlmeRate];
- AckDuration = RTMPCalcDuration(pAd, AckRate, 14);
- pHeader->Duration = pAd->CommonCfg.Dsifs + AckDuration;
-
- // Use MLME enqueue method
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- // 10. Prepare report frame with dynamic outbuffer. Just simply copy everything.
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- pAd->StaCfg.FrameReportLen, pAd->StaCfg.FrameReportBuf,
- END_OF_ARGS);
-
- // 11. Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.CCXReqType = MSRN_TYPE_UNUSED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AironetFinalReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID ChannelLoadReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PCHANNEL_LOAD_REPORT pLoad;
- PUCHAR pDest;
- UCHAR CCABusyFraction;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadReportAction ----->\n"));
-
- // Disable Rx with promiscuous reception, make it back to normal
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
-
- // 0. Setup pointer for processing beacon & probe response
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
-
- // 1. Fill Measurement report element field.
- pReport->Eid = IE_MEASUREMENT_REPORT;
- // Fixed Length at 9, not include Eid and length fields
- pReport->Length = 9;
- pReport->Token = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_CHANNEL_LOAD_REQ;
-
- // 2. Fill channel report measurement data
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
- pLoad = (PCHANNEL_LOAD_REPORT) pDest;
- pLoad->Channel = pAd->StaCfg.MeasurementRequest[Index].Measurement.Channel;
- pLoad->Spare = 0;
- pLoad->Duration = pAd->StaCfg.MeasurementRequest[Index].Measurement.Duration;
-
- // 3. Calculate the CCA Busy Fraction
- // (Bytes + ACK size) * 8 / Tx speed * 255 / 1000 / measurement duration, use 24 us Tx speed
- // = (Bytes + ACK) / 12 / duration
- // 9 is the good value for pAd->StaCfg.CLFactor
- // CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / 9 / pLoad->Duration);
- CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / pAd->StaCfg.CLFactor / pLoad->Duration);
- if (CCABusyFraction < 10)
- CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / 3 / pLoad->Duration) + 1;
-
- pLoad->CCABusy = CCABusyFraction;
- DBGPRINT(RT_DEBUG_TRACE, ("CLBusyByte %ld, Duration %d, Result, %d\n", pAd->StaCfg.CLBusyBytes, pLoad->Duration, CCABusyFraction));
-
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen %d\n", pAd->StaCfg.FrameReportLen));
- pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(CHANNEL_LOAD_REPORT));
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen %d\n", pAd->StaCfg.FrameReportLen));
-
- // 4. Clear channel load measurement flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- // 5. reset to idle state
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID NoiseHistReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PNOISE_HIST_REPORT pNoise;
- PUCHAR pDest;
- UCHAR i,NoiseCnt;
- USHORT TotalRPICnt, TotalRPISum;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistReportAction ----->\n"));
-
- // 0. Disable Rx with promiscuous reception, make it back to normal
- RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
- // 1. Setup pointer for processing beacon & probe response
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
-
- // 2. Fill Measurement report element field.
- pReport->Eid = IE_MEASUREMENT_REPORT;
- // Fixed Length at 16, not include Eid and length fields
- pReport->Length = 16;
- pReport->Token = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[Index].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_NOISE_HIST_REQ;
-
- // 3. Fill noise histogram report measurement data
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
- pNoise = (PNOISE_HIST_REPORT) pDest;
- pNoise->Channel = pAd->StaCfg.MeasurementRequest[Index].Measurement.Channel;
- pNoise->Spare = 0;
- pNoise->Duration = pAd->StaCfg.MeasurementRequest[Index].Measurement.Duration;
- // 4. Fill Noise histogram, the total RPI counts should be 0.4 * TU
- // We estimate 4000 normal packets received durning 10 seconds test.
- // Adjust it if required.
- // 3 is a good value for pAd->StaCfg.NHFactor
- // TotalRPICnt = pNoise->Duration * 3 / 10;
- TotalRPICnt = pNoise->Duration * pAd->StaCfg.NHFactor / 10;
- TotalRPISum = 0;
-
- for (i = 0; i < 8; i++)
- {
- TotalRPISum += pAd->StaCfg.RPIDensity[i];
- DBGPRINT(RT_DEBUG_TRACE, ("RPI %d Conuts %d\n", i, pAd->StaCfg.RPIDensity[i]));
- }
-
- // Double check if the counter is larger than our expectation.
- // We will replace it with the total number plus a fraction.
- if (TotalRPISum > TotalRPICnt)
- TotalRPICnt = TotalRPISum + pNoise->Duration / 20;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Total RPI Conuts %d\n", TotalRPICnt));
-
- // 5. Initialize noise count for the total summation of 0xff
- NoiseCnt = 0;
- for (i = 1; i < 8; i++)
- {
- pNoise->Density[i] = (UCHAR) (pAd->StaCfg.RPIDensity[i] * 255 / TotalRPICnt);
- if ((pNoise->Density[i] == 0) && (pAd->StaCfg.RPIDensity[i] != 0))
- pNoise->Density[i]++;
- NoiseCnt += pNoise->Density[i];
- DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[%d] = 0x%02x\n", i, pNoise->Density[i]));
- }
-
- // 6. RPI[0] represents the rest of counts
- pNoise->Density[0] = 0xff - NoiseCnt;
- DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[0] = 0x%02x\n", pNoise->Density[0]));
-
- pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(NOISE_HIST_REPORT));
-
- // 7. Clear channel load measurement flag
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-
- // 8. reset to idle state
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Prepare Beacon report action,
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID BeaconReportAction(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR Index)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconReportAction ----->\n"));
-
- // Looks like we don't have anything thing need to do here.
- // All measurement report already finished in AddBeaconReport
- // The length is in the FrameReportLen
-
- // reset Beacon index for next beacon request
- pAd->StaCfg.LastBssIndex = 0xff;
-
- // reset to idle state
- pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("BeaconReportAction <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
- Index Current BSSID in CCXBsstab entry index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID AironetAddBeaconReport(
- IN PRTMP_ADAPTER pAd,
- IN ULONG Index,
- IN PMLME_QUEUE_ELEM pElem)
-{
- PVOID pMsg;
- PUCHAR pSrc, pDest;
- UCHAR ReqIdx;
- ULONG MsgLen;
- USHORT Length;
- PFRAME_802_11 pFrame;
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PEID_STRUCT pEid;
- PBEACON_REPORT pBeaconReport;
- PBSS_ENTRY pBss;
-
- // 0. Setup pointer for processing beacon & probe response
- pMsg = pElem->Msg;
- MsgLen = pElem->MsgLen;
- pFrame = (PFRAME_802_11) pMsg;
- pSrc = pFrame->Octet; // Start from AP TSF
- pBss = (PBSS_ENTRY) &pAd->StaCfg.CCXBssTab.BssEntry[Index];
- ReqIdx = pAd->StaCfg.CurrentRMReqIdx;
-
- // 1 Check the Index, if we already create this entry, only update the average RSSI
- if ((Index <= pAd->StaCfg.LastBssIndex) && (pAd->StaCfg.LastBssIndex != 0xff))
- {
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.BssReportOffset[Index]];
- // Point to bss report information
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
- pBeaconReport = (PBEACON_REPORT) pDest;
-
- // Update Rx power, in dBm
- // Get the original RSSI readback from BBP
- pBeaconReport->RxPower += pAd->BbpRssiToDbmDelta;
- // Average the Rssi reading
- pBeaconReport->RxPower = (pBeaconReport->RxPower + pBss->Rssi) / 2;
- // Get to dBm format
- pBeaconReport->RxPower -= pAd->BbpRssiToDbmDelta;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Bssid %02x:%02x:%02x:%02x:%02x:%02x ",
- pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2],
- pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
- DBGPRINT(RT_DEBUG_TRACE, ("RxPower[%ld] Rssi %d, Avg Rssi %d\n", Index, (pBss->Rssi - pAd->BbpRssiToDbmDelta), pBeaconReport->RxPower - 256));
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen = %d\n", pAd->StaCfg.BssReportOffset[Index]));
-
- // Update other information here
-
- // Done
- return;
- }
-
- // 2. Update reported Index
- pAd->StaCfg.LastBssIndex = Index;
-
- // 3. Setup the buffer address for copying this BSSID into reporting frame
- // The offset should start after 802.11 header and report frame header.
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
-
- // 4. Save the start offset of each Bss in report frame
- pAd->StaCfg.BssReportOffset[Index] = pAd->StaCfg.FrameReportLen;
-
- // 5. Fill Measurement report fields
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
- pReport->Eid = IE_MEASUREMENT_REPORT;
- pReport->Length = 0;
- pReport->Token = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_BEACON_REQ;
- Length = sizeof(MEASUREMENT_REPORT_ELEMENT);
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
-
- // 6. Start thebeacon report format
- pBeaconReport = (PBEACON_REPORT) pDest;
- pDest += sizeof(BEACON_REPORT);
- Length += sizeof(BEACON_REPORT);
-
- // 7. Copy Channel number
- pBeaconReport->Channel = pBss->Channel;
- pBeaconReport->Spare = 0;
- pBeaconReport->Duration = pAd->StaCfg.MeasurementRequest[ReqIdx].Measurement.Duration;
- pBeaconReport->PhyType = ((pBss->SupRateLen+pBss->ExtRateLen > 4) ? PHY_ERP : PHY_DSS);
- // 8. Rx power, in dBm
- pBeaconReport->RxPower = pBss->Rssi - pAd->BbpRssiToDbmDelta;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Bssid %02x:%02x:%02x:%02x:%02x:%02x ",
- pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2],
- pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
- DBGPRINT(RT_DEBUG_TRACE, ("RxPower[%ld], Rssi %d\n", Index, pBeaconReport->RxPower - 256));
- DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen = %d\n", pAd->StaCfg.FrameReportLen));
-
- pBeaconReport->BeaconInterval = pBss->BeaconPeriod;
- COPY_MAC_ADDR(pBeaconReport->BSSID, pFrame->Hdr.Addr3);
- NdisMoveMemory(pBeaconReport->ParentTSF, pSrc, 4);
- NdisMoveMemory(pBeaconReport->TargetTSF, &pElem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pBeaconReport->TargetTSF[4], &pElem->TimeStamp.u.HighPart, 4);
-
- // 9. Skip the beacon frame and offset to start of capabilityinfo since we already processed capabilityinfo
- pSrc += (TIMESTAMP_LEN + 2);
- pBeaconReport->CapabilityInfo = *(USHORT *)pSrc;
-
- // 10. Point to start of element ID
- pSrc += 2;
- pEid = (PEID_STRUCT) pSrc;
-
- // 11. Start process all variable Eid oayload and add the appropriate to the frame report
- while (((PUCHAR) pEid + pEid->Len + 1) < ((PUCHAR) pFrame + MsgLen))
- {
- // Only limited EID are required to report for CCX 2. It includes SSID, Supported rate,
- // FH paramenter set, DS parameter set, CF parameter set, IBSS parameter set,
- // TIM (report first 4 bytes only, radio measurement capability
- switch (pEid->Eid)
- {
- case IE_SSID:
- case IE_SUPP_RATES:
- case IE_FH_PARM:
- case IE_DS_PARM:
- case IE_CF_PARM:
- case IE_IBSS_PARM:
- NdisMoveMemory(pDest, pEid, pEid->Len + 2);
- pDest += (pEid->Len + 2);
- Length += (pEid->Len + 2);
- break;
-
- case IE_MEASUREMENT_CAPABILITY:
- // Since this IE is duplicated with WPA security IE, we has to do sanity check before
- // recognize it.
- // 1. It also has fixed 6 bytes IE length.
- if (pEid->Len != 6)
- break;
- // 2. Check the Cisco Aironet OUI
- if (NdisEqualMemory(CISCO_OUI, (pSrc + 2), 3))
- {
- // Matched, this is what we want
- NdisMoveMemory(pDest, pEid, pEid->Len + 2);
- pDest += (pEid->Len + 2);
- Length += (pEid->Len + 2);
- }
- break;
-
- case IE_TIM:
- if (pEid->Len > 4)
- {
- // May truncate and report the first 4 bytes only, with the eid & len, total should be 6
- NdisMoveMemory(pDest, pEid, 6);
- pDest += 6;
- Length += 6;
- }
- else
- {
- NdisMoveMemory(pDest, pEid, pEid->Len + 2);
- pDest += (pEid->Len + 2);
- Length += (pEid->Len + 2);
- }
- break;
-
- default:
- break;
- }
- // 12. Move to next element ID
- pSrc += (2 + pEid->Len);
- pEid = (PEID_STRUCT) pSrc;
- }
-
- // 13. Update the length in the header, not include EID and length
- pReport->Length = Length - 4;
-
- // 14. Update the frame report buffer data length
- pAd->StaCfg.FrameReportLen += Length;
- DBGPRINT(RT_DEBUG_TRACE, ("FR len = %d\n", pAd->StaCfg.FrameReportLen));
-}
-
-/*
- ========================================================================
-
- Routine Description:
-
- Arguments:
- Index Current BSSID in CCXBsstab entry index
-
- Return Value:
-
- Note:
-
- ========================================================================
-*/
-VOID AironetCreateBeaconReportFromBssTable(
- IN PRTMP_ADAPTER pAd)
-{
- PMEASUREMENT_REPORT_ELEMENT pReport;
- PBEACON_REPORT pBeaconReport;
- UCHAR Index, ReqIdx;
- USHORT Length;
- PUCHAR pDest;
- PBSS_ENTRY pBss;
-
- // 0. setup base pointer
- ReqIdx = pAd->StaCfg.CurrentRMReqIdx;
-
- for (Index = 0; Index < pAd->StaCfg.CCXBssTab.BssNr; Index++)
- {
- // 1. Setup the buffer address for copying this BSSID into reporting frame
- // The offset should start after 802.11 header and report frame header.
- pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
- pBss = (PBSS_ENTRY) &pAd->StaCfg.CCXBssTab.BssEntry[Index];
- Length = 0;
-
- // 2. Fill Measurement report fields
- pReport = (PMEASUREMENT_REPORT_ELEMENT) pDest;
- pReport->Eid = IE_MEASUREMENT_REPORT;
- pReport->Length = 0;
- pReport->Token = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Token;
- pReport->Mode = pAd->StaCfg.MeasurementRequest[ReqIdx].ReqElem.Mode;
- pReport->Type = MSRN_TYPE_BEACON_REQ;
- Length = sizeof(MEASUREMENT_REPORT_ELEMENT);
- pDest += sizeof(MEASUREMENT_REPORT_ELEMENT);
-
- // 3. Start the beacon report format
- pBeaconReport = (PBEACON_REPORT) pDest;
- pDest += sizeof(BEACON_REPORT);
- Length += sizeof(BEACON_REPORT);
-
- // 4. Copy Channel number
- pBeaconReport->Channel = pBss->Channel;
- pBeaconReport->Spare = 0;
- pBeaconReport->Duration = pAd->StaCfg.MeasurementRequest[ReqIdx].Measurement.Duration;
- pBeaconReport->PhyType = ((pBss->SupRateLen+pBss->ExtRateLen > 4) ? PHY_ERP : PHY_DSS);
- pBeaconReport->RxPower = pBss->Rssi - pAd->BbpRssiToDbmDelta;
- pBeaconReport->BeaconInterval = pBss->BeaconPeriod;
- pBeaconReport->CapabilityInfo = pBss->CapabilityInfo;
- COPY_MAC_ADDR(pBeaconReport->BSSID, pBss->Bssid);
- NdisMoveMemory(pBeaconReport->ParentTSF, pBss->PTSF, 4);
- NdisMoveMemory(pBeaconReport->TargetTSF, pBss->TTSF, 8);
-
- // 5. Create SSID
- *pDest++ = 0x00;
- *pDest++ = pBss->SsidLen;
- NdisMoveMemory(pDest, pBss->Ssid, pBss->SsidLen);
- pDest += pBss->SsidLen;
- Length += (2 + pBss->SsidLen);
-
- // 6. Create SupportRates
- *pDest++ = 0x01;
- *pDest++ = pBss->SupRateLen;
- NdisMoveMemory(pDest, pBss->SupRate, pBss->SupRateLen);
- pDest += pBss->SupRateLen;
- Length += (2 + pBss->SupRateLen);
-
- // 7. DS Parameter
- *pDest++ = 0x03;
- *pDest++ = 1;
- *pDest++ = pBss->Channel;
- Length += 3;
-
- // 8. IBSS parameter if presents
- if (pBss->BssType == BSS_ADHOC)
- {
- *pDest++ = 0x06;
- *pDest++ = 2;
- *(PUSHORT) pDest = pBss->AtimWin;
- pDest += 2;
- Length += 4;
- }
-
- // 9. Update length field, not include EID and length
- pReport->Length = Length - 4;
-
- // 10. Update total frame size
- pAd->StaCfg.FrameReportLen += Length;
- }
-}
+#include "../../rt2870/sta/aironet.c"
diff --git a/drivers/staging/rt3070/sta/assoc.c b/drivers/staging/rt3070/sta/assoc.c
index 5c33a895bf7f..1987a2a4b05f 100644
--- a/drivers/staging/rt3070/sta/assoc.c
+++ b/drivers/staging/rt3070/sta/assoc.c
@@ -1,2060 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- assoc.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-9-3 porting from RT2500
-*/
-#include "../rt_config.h"
-
-UCHAR CipherWpaTemplate[] = {
- 0xdd, // WPA IE
- 0x16, // Length
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x01 // authentication
- };
-
-UCHAR CipherWpa2Template[] = {
- 0x30, // RSN IE
- 0x14, // Length
- 0x01, 0x00, // Version
- 0x00, 0x0f, 0xac, 0x02, // group cipher, TKIP
- 0x01, 0x00, // number of pairwise
- 0x00, 0x0f, 0xac, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x0f, 0xac, 0x02, // authentication
- 0x00, 0x00, // RSN capability
- };
-
-UCHAR Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID AssocStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, (STATE_MACHINE_FUNC)Drop, ASSOC_IDLE, ASSOC_MACHINE_BASE);
-
- // first column
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)MlmeAssocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)MlmeReassocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)MlmeDisassocReqAction);
- StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
-
- // second column
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
- //
- // Patch 3Com AP MOde:3CRWE454G72
- // We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp.
- //
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
- StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT, (STATE_MACHINE_FUNC)AssocTimeoutAction);
-
- // third column
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
- //
- // Patch, AP doesn't send Reassociate Rsp frame to Station.
- //
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
- StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT, (STATE_MACHINE_FUNC)ReassocTimeoutAction);
-
- // fourth column
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
- StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT, (STATE_MACHINE_FUNC)DisassocTimeoutAction);
-
- // initialize the timer
- RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer, GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer, GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer, GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- Association timeout procedure. After association timeout, this function
- will be called and it will put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Reassociation timeout procedure. After reassociation timeout, this
- function will be called and put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ReassocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Disassociation timeout procedure. After disassociation timeout, this
- function will be called and put a message into the MLME queue
- Parameters:
- Standard timer parameters
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID DisassocTimeout(IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- mlme assoc req handling procedure
- Parameters:
- Adapter - Adapter pointer
- Elem - MLME Queue Element
- Pre:
- the station has been authenticated and the following information is stored in the config
- -# SSID
- -# supported rates and their length
- -# listen interval (Adapter->StaCfg.default_listen_count)
- -# Transmit power (Adapter->StaCfg.tx_power)
- Post :
- -# An association request frame is generated and sent to the air
- -# Association timer starts
- -# Association state -> ASSOC_WAIT_RSP
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeAssocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR ApAddr[6];
- HEADER_802_11 AssocHdr;
- UCHAR Ccx2Len = 5;
- UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
- USHORT ListenIntv;
- ULONG Timeout;
- USHORT CapabilityInfo;
- BOOLEAN TimerCancelled;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- ULONG tmp;
- USHORT VarIesOffset;
- UCHAR CkipFlag;
- UCHAR CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH];
- UCHAR AironetCkipIe = IE_AIRONET_CKIP;
- UCHAR AironetCkipLen = CKIP_NEGOTIATION_LENGTH;
- UCHAR AironetIPAddressIE = IE_AIRONET_IPADDRESS;
- UCHAR AironetIPAddressLen = AIRONET_IPADDRESS_LENGTH;
- UCHAR AironetIPAddressBuffer[AIRONET_IPADDRESS_LENGTH] = {0x00, 0x40, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00};
- USHORT Status;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block Assoc request durning WPA block period!\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
- // check sanity first
- else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
- {
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
- // Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- return;
- }
-
- // Add by James 03/06/27
- pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
- // Association don't need to report MAC address
- pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
- NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL;
- pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo;
- pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
- // Only reassociate need this
- //COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr);
- pAd->StaCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-
- NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
- // First add SSID
- VarIesOffset = 0;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SsidLen, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- VarIesOffset += pAd->MlmeAux.SsidLen;
-
- // Second add Supported rates
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SupRateLen, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
- VarIesOffset += pAd->MlmeAux.SupRateLen;
- // End Add by James
-
- if ((pAd->CommonCfg.Channel > 14) &&
- (pAd->CommonCfg.bIEEE80211H == TRUE))
- CapabilityInfo |= 0x0100;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
- MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr, ApAddr);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AssocHdr,
- 2, &CapabilityInfo,
- 2, &ListenIntv,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- // HT
- if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
- {
- HtLen = SIZE_HT_CAP_IE + 4;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
-#else
- NdisZeroMemory(&HtCapabilityTmp, sizeof(HT_CAPABILITY_IE));
- NdisMoveMemory(&HtCapabilityTmp, &pAd->MlmeAux.HtCapability, pAd->MlmeAux.HtCapabilityLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen,&HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
-
- // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
- // Case I: (Aggregation + Piggy-Back)
- // 1. user enable aggregation, AND
- // 2. Mac support piggy-back
- // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
- // Case II: (Aggregation)
- // 1. user enable aggregation, AND
- // 2. AP annouces it's AGGREGATION-capable in BEACON
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- }
- else
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
-
- if (pAd->MlmeAux.APEdcaParm.bValid)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
- {
- QBSS_STA_INFO_PARM QosInfo;
-
- NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
- QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
- QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
- QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
- QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
- QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
- WmeIe[8] |= *(PUCHAR)&QosInfo;
- }
- else
- {
- // The Parameter Set Count is set to ¡§0¡¨ in the association request frames
- // WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 9, &WmeIe[0],
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- //
- // Let WPA(#221) Element ID on the end of this association frame.
- // Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp.
- // For example: Put Vendor Specific IE on the front of WPA IE.
- // This happens on AP (Model No:Linksys WRK54G)
- //
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
- )
- )
- {
- UCHAR RSNIe = IE_WPA;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- {
- RSNIe = IE_WPA2;
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP != 1)
-#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-
- // Check for WPA PMK cache list
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
- {
- INT idx;
- BOOLEAN FoundPMK = FALSE;
- // Search chched PMKID, append it if existed
- for (idx = 0; idx < PMKID_NO; idx++)
- {
- if (NdisEqualMemory(ApAddr, &pAd->StaCfg.SavedPMK[idx].BSSID, 6))
- {
- FoundPMK = TRUE;
- break;
- }
- }
-
- if (FoundPMK)
- {
- // Set PMK number
- *(PUSHORT) &pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len] = 1;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len + 2], &pAd->StaCfg.SavedPMK[idx].PMKID, 16);
- pAd->StaCfg.RSNIE_Len += 18;
- }
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP == 1)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- }
- else
-#endif
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- }
-
- FrameLen += tmp;
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP != 1)
-#endif
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- // Append Variable IE
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1);
- VarIesOffset += 1;
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->StaCfg.RSNIE_Len, 1);
- VarIesOffset += 1;
- }
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
- VarIesOffset += pAd->StaCfg.RSNIE_Len;
-
- // Set Variable IEs Length
- pAd->StaCfg.ReqVarIELen = VarIesOffset;
- }
-
- // We have update that at PeerBeaconAtJoinRequest()
- CkipFlag = pAd->StaCfg.CkipFlag;
- if (CkipFlag != 0)
- {
- NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH);
- CkipNegotiationBuffer[2] = 0x66;
- // Make it try KP & MIC, since we have to follow the result from AssocRsp
- CkipNegotiationBuffer[8] = 0x18;
- CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22;
- CkipFlag = 0x18;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCkipIe,
- 1, &AironetCkipLen,
- AironetCkipLen, CkipNegotiationBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // Add CCX v2 request if CCX2 admin state is on
- if (pAd->StaCfg.CCXControl.field.Enable == 1)
- {
-
- //
- // Add AironetIPAddressIE for Cisco CCX 2.X
- // Add CCX Version
- //
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetIPAddressIE,
- 1, &AironetIPAddressLen,
- AironetIPAddressLen, AironetIPAddressBuffer,
- 1, &Ccx2Ie,
- 1, &Ccx2Len,
- Ccx2Len, Ccx2IeInfo,
- END_OF_ARGS);
- FrameLen += tmp;
-
- //
- // Add CipherSuite CCKM or LeapTkip if setting.
- //
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCiscoCCKMLen, CipherSuiteCiscoCCKM,
- END_OF_ARGS);
- FrameLen += tmp;
-
- // Third add RSN
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen); //Save CipherSuite
- VarIesOffset += CipherSuiteCiscoCCKMLen;
- }
- else if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled))
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCCXTkipLen, CipherSuiteCCXTkip,
- END_OF_ARGS);
- FrameLen += tmp;
-
- // Third add RSN
- NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCCXTkip, CipherSuiteCCXTkipLen);
- VarIesOffset += CipherSuiteCCXTkipLen;
- }
-#endif // LEAP_SUPPORT //
-
- // Add by James 03/06/27
- // Set Variable IEs Length
- pAd->StaCfg.ReqVarIELen = VarIesOffset;
- pAd->StaCfg.AssocInfo.RequestIELength = VarIesOffset;
-
- // OffsetResponseIEs follow ReqVarIE
- pAd->StaCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->StaCfg.ReqVarIELen;
- // End Add by James
- }
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- mlme reassoc req handling procedure
- Parameters:
- Elem -
- Pre:
- -# SSID (Adapter->StaCfg.ssid[])
- -# BSSID (AP address, Adapter->StaCfg.bssid)
- -# Supported rates (Adapter->StaCfg.supported_rates[])
- -# Supported rates length (Adapter->StaCfg.supported_rates_len)
- -# Tx power (Adapter->StaCfg.tx_power)
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeReassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR ApAddr[6];
- HEADER_802_11 ReassocHdr;
- UCHAR Ccx2Len = 5;
- UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
- USHORT CapabilityInfo, ListenIntv;
- ULONG Timeout;
- ULONG FrameLen = 0;
- BOOLEAN TimerCancelled;
- NDIS_STATUS NStatus;
- ULONG tmp;
- PUCHAR pOutBuffer = NULL;
-//CCX 2.X
-#ifdef LEAP_SUPPORT
- UCHAR CkipFlag;
- UCHAR CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH];
- UCHAR AironetCkipIe = IE_AIRONET_CKIP;
- UCHAR AironetCkipLen = CKIP_NEGOTIATION_LENGTH;
- UCHAR AironetIPAddressIE = IE_AIRONET_IPADDRESS;
- UCHAR AironetIPAddressLen = AIRONET_IPADDRESS_LENGTH;
- UCHAR AironetIPAddressBuffer[AIRONET_IPADDRESS_LENGTH] = {0x00, 0x40, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00};
- UCHAR AironetCCKMReassocIE = IE_AIRONET_CCKMREASSOC;
- UCHAR AironetCCKMReassocLen = AIRONET_CCKMREASSOC_LENGTH;
- UCHAR AironetCCKMReassocBuffer[AIRONET_CCKMREASSOC_LENGTH];
- UCHAR AironetOUI[] = {0x00, 0x40, 0x96, 0x00};
- UCHAR MICMN[16];
- UCHAR CalcMicBuffer[80];
- ULONG CalcMicBufferLen = 0;
-#endif // LEAP_SUPPORT //
- USHORT Status;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block ReAssoc request durning WPA block period!\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- // the parameters are the same as the association
- else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
- {
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- return;
- }
-
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
- // make frame, use bssid as the AP address??
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send RE-ASSOC request...\n"));
- MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0, ApAddr, ApAddr);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &ReassocHdr,
- 2, &CapabilityInfo,
- 2, &ListenIntv,
- MAC_ADDR_LEN, ApAddr,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- if (pAd->MlmeAux.APEdcaParm.bValid)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
- {
- QBSS_STA_INFO_PARM QosInfo;
-
- NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
- QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
- QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
- QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
- QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
- QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
- WmeIe[8] |= *(PUCHAR)&QosInfo;
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 9, &WmeIe[0],
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- // HT
- if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
- {
- HtLen = SIZE_HT_CAP_IE + 4;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 1, &HtLen,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &pAd->MlmeAux.HtCapabilityLen,
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
-
- // add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
- // Case I: (Aggregation + Piggy-Back)
- // 1. user enable aggregation, AND
- // 2. Mac support piggy-back
- // 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON
- // Case II: (Aggregation)
- // 1. user enable aggregation, AND
- // 2. AP annouces it's AGGREGATION-capable in BEACON
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
- }
- else
- {
- ULONG TmpLen;
- UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00};
- MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
- 9, RalinkIe,
- END_OF_ARGS);
- FrameLen += TmpLen;
- }
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- CkipFlag = pAd->StaCfg.CkipFlag; // We have update that at PeerBeaconAtJoinRequest()
- if (CkipFlag != 0)
- {
- NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH);
- CkipNegotiationBuffer[2] = 0x66;
- // Make it try KP & MIC, since we have to follow the result from AssocRsp
- CkipNegotiationBuffer[8] = 0x18;
- CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCkipIe,
- 1, &AironetCkipLen,
- AironetCkipLen, CkipNegotiationBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetIPAddressIE,
- 1, &AironetIPAddressLen,
- AironetIPAddressLen, AironetIPAddressBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
-
- //
- // The RN is incremented before each reassociation request.
- //
- pAd->StaCfg.CCKMRN++;
- //
- // Calculate MIC = hmac-md5(krk, STA-ID|BSSID|RSNIE|TSF|RN);
- //
- COPY_MAC_ADDR(CalcMicBuffer, pAd->CurrentAddress);
- CalcMicBufferLen = MAC_ADDR_LEN;
- COPY_MAC_ADDR(CalcMicBuffer + CalcMicBufferLen, pAd->MlmeAux.Bssid);
- CalcMicBufferLen += MAC_ADDR_LEN;
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen);
- CalcMicBufferLen += CipherSuiteCiscoCCKMLen;
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR) &pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp));
- CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMBeaconAtJoinTimeStamp);
- NdisMoveMemory(CalcMicBuffer + CalcMicBufferLen, (PUCHAR)&pAd->StaCfg.CCKMRN, sizeof(pAd->StaCfg.CCKMRN));
- CalcMicBufferLen += sizeof(pAd->StaCfg.CCKMRN);
- hmac_md5(pAd->StaCfg.KRK, LEN_EAP_MICK, CalcMicBuffer, CalcMicBufferLen, MICMN);
-
- //
- // fill up CCKM reassociation request element
- //
- NdisMoveMemory(AironetCCKMReassocBuffer, AironetOUI, 4);
- NdisMoveMemory(AironetCCKMReassocBuffer + 4, (PUCHAR)&pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, 8);
- NdisMoveMemory(AironetCCKMReassocBuffer + 12, (PUCHAR) &pAd->StaCfg.CCKMRN, 4);
- NdisMoveMemory(AironetCCKMReassocBuffer +16, MICMN, 8);
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &AironetCCKMReassocIE,
- 1, &AironetCCKMReassocLen,
- AironetCCKMReassocLen, AironetCCKMReassocBuffer,
- END_OF_ARGS);
- FrameLen += tmp;
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- CipherSuiteCiscoCCKMLen,CipherSuiteCiscoCCKM,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-#endif // LEAP_SUPPORT //
-
- // Add CCX v2 request if CCX2 admin state is on
- if (pAd->StaCfg.CCXControl.field.Enable == 1)
- {
- //
- // Add CCX Version
- //
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &Ccx2Ie,
- 1, &Ccx2Len,
- Ccx2Len, Ccx2IeInfo,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
- pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- Upper layer issues disassoc request
- Parameters:
- Elem -
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDisassocReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PMLME_DISASSOC_REQ_STRUCT pDisassocReq;
- HEADER_802_11 DisassocHdr;
- PHEADER_802_11 pDisassocHdr;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- NDIS_STATUS NStatus;
- BOOLEAN TimerCancelled;
- ULONG Timeout = 0;
- USHORT Status;
-
-#ifdef QOS_DLS_SUPPORT
- // send DLS-TEAR_DOWN message,
- if (pAd->CommonCfg.bDLSCapable)
- {
- UCHAR i;
-
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- }
- }
- }
-#endif // QOS_DLS_SUPPORT //
-
- // skip sanity check
- pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
- return;
- }
-
-
-
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
- pDisassocReq->Addr[0], pDisassocReq->Addr[1], pDisassocReq->Addr[2],
- pDisassocReq->Addr[3], pDisassocReq->Addr[4], pDisassocReq->Addr[5], pDisassocReq->Reason));
- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); // patch peap ttls switching issue
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DisassocHdr,
- 2, &pDisassocReq->Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- // To patch Instance and Buffalo(N) AP
- // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
- // Therefore, we send both of them.
- pDisassocHdr = (PHEADER_802_11)pOutBuffer;
- pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
- COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pDisassocReq->Addr);
-
- RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */
- pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-}
-
-/*
- ==========================================================================
- Description:
- peer sends assoc rsp back
- Parameters:
- Elme - MLME message containing the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAssocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo, Status, Aid;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
- UCHAR Addr2[MAC_ADDR_LEN];
- BOOLEAN TimerCancelled;
- UCHAR CkipFlag;
- EDCA_PARM EdcaParm;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
- if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
- &HtCapability,&AddHtInfo, &HtCapabilityLen,&AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
- {
- // The frame is for me ?
- if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status));
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem->Wcid, pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-#endif // DOT11_N_SUPPORT //
- RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
- if(Status == MLME_SUCCESS)
- {
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR idx;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (idx=0; idx<SupRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
- }
-
- for (idx=0; idx<ExtRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
- }
- // go to procedure listed on page 376
- AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
- &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
-
- StaAddMacTableEntry(pAd, &pAd->MacTab.Content[BSSID_WCID], MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo);
-
- pAd->StaCfg.CkipFlag = CkipFlag;
- if (CkipFlag & 0x18)
- {
- NdisZeroMemory(pAd->StaCfg.TxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.RxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.CKIPMIC, 4);
- pAd->StaCfg.GIV[0] = RandomByte(pAd);
- pAd->StaCfg.GIV[1] = RandomByte(pAd);
- pAd->StaCfg.GIV[2] = RandomByte(pAd);
- pAd->StaCfg.bCkipOn = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag));
- }
- }
- else
- {
- // Faile on Association, we need to check the status code
- // Is that a Rogue AP?
-#ifdef LEAP_SUPPORT
- if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (Status == MLME_ALG_NOT_SUPPORT))
- { //Possibly Rogue AP
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, pAd->MlmeAux.Bssid, LEAP_REASON_INVALID_AUTH);
- }
-#endif // LEAP_SUPPORT //
- }
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
- peer sends reassoc rsp
- Parametrs:
- Elem - MLME message cntaining the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerReassocRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo;
- USHORT Status;
- USHORT Aid;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
- UCHAR Addr2[MAC_ADDR_LEN];
- UCHAR CkipFlag;
- BOOLEAN TimerCancelled;
- EDCA_PARM EdcaParm;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
- if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
- &HtCapability, &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
- {
- if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status));
- RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
- if(Status == MLME_SUCCESS)
- {
- // go to procedure listed on page 376
- AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
- &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- wext_notify_event_assoc(pAd);
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
- }
-
- //
- // Cisco Leap CCKM supported Re-association.
- //
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- if (CCKMAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen) == TRUE)
- {
- pAd->StaCfg.CkipFlag = CkipFlag;
- if (CkipFlag & 0x18)
- {
- NdisZeroMemory(pAd->StaCfg.TxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.RxSEQ, 4);
- NdisZeroMemory(pAd->StaCfg.CKIPMIC, 4);
- pAd->StaCfg.GIV[0] = RandomByte(pAd);
- pAd->StaCfg.GIV[1] = RandomByte(pAd);
- pAd->StaCfg.GIV[2] = RandomByte(pAd);
- pAd->StaCfg.bCkipOn = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag));
- }
-
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - CCKMAssocRspSanity() sanity check fail\n"));
- }
- }
- else
-#endif // LEAP_SUPPORT //
- {
- // CkipFlag is no use for reassociate
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
- }
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- procedures on IEEE 802.11/1999 p.376
- Parametrs:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocPostProc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr2,
- IN USHORT CapabilityInfo,
- IN USHORT Aid,
- IN UCHAR SupRate[],
- IN UCHAR SupRateLen,
- IN UCHAR ExtRate[],
- IN UCHAR ExtRateLen,
- IN PEDCA_PARM pEdcaParm,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN ADD_HT_INFO_IE *pAddHtInfo) // AP might use this additional ht info IE
-{
- ULONG Idx;
-
- pAd->MlmeAux.BssType = BSS_INFRA;
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2);
- pAd->MlmeAux.Aid = Aid;
- pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
-#ifdef DOT11_N_SUPPORT
- // Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on.
- if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE))
- {
- pEdcaParm->bValid = TRUE;
- pEdcaParm->Aifsn[0] = 3;
- pEdcaParm->Aifsn[1] = 7;
- pEdcaParm->Aifsn[2] = 2;
- pEdcaParm->Aifsn[3] = 2;
-
- pEdcaParm->Cwmin[0] = 4;
- pEdcaParm->Cwmin[1] = 4;
- pEdcaParm->Cwmin[2] = 3;
- pEdcaParm->Cwmin[3] = 2;
-
- pEdcaParm->Cwmax[0] = 10;
- pEdcaParm->Cwmax[1] = 10;
- pEdcaParm->Cwmax[2] = 4;
- pEdcaParm->Cwmax[3] = 3;
-
- pEdcaParm->Txop[0] = 0;
- pEdcaParm->Txop[1] = 0;
- pEdcaParm->Txop[2] = 96;
- pEdcaParm->Txop[3] = 48;
-
- }
-#endif // DOT11_N_SUPPORT //
-
- NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(EDCA_PARM));
-
- // filter out un-supported rates
- pAd->MlmeAux.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
-
- // filter out un-supported rates
- pAd->MlmeAux.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-
-#ifdef DOT11_N_SUPPORT
- if (HtCapabilityLen > 0)
- {
- RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n",
- pAd->MacTab.Content[BSSID_WCID].MmpsMode, pAd->MacTab.Content[BSSID_WCID].AMsduSize));
-#endif // DOT11_N_SUPPORT //
-
- // Set New WPA information
- Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
- if (Idx == BSS_NOT_FOUND)
- {
- DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
- }
- else
- {
- // Init variable
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0;
- NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, MAX_LEN_OF_RSNIE);
-
- // Store appropriate RSN_IE for WPA SM negotiation later
- if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0))
- {
- PUCHAR pVIE;
- USHORT len;
- PEID_STRUCT pEid;
-
- pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs;
- len = pAd->ScanTab.BssEntry[Idx].VarIELen;
-
- while (len > 0)
- {
- pEid = (PEID_STRUCT) pVIE;
- // For WPA/WPAPSK
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
- && (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
- }
- // For WPA2/WPA2PSK
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
- && (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
- pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
- }
-
- if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> no RSN_IE \n"));
- }
- else
- {
- hex_dump("RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- left part of IEEE 802.11/1999 p.374
- Parameters:
- Elem - MLME message containing the received frame
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDisassocAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Reason;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
- if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() Reason = %d\n", Reason));
- if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2))
- {
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
-
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- // Cisco_LEAP has start a timer
- // We should cancel it if using LEAP
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
- //Check is it mach the LEAP Authentication failed as possible a Rogue AP
- //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Association.
- if ((pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
- }
- }
-#endif // LEAP_SUPPORT //
- //
- // Get Current System time and Turn on AdjacentAPReport
- //
- NdisGetSystemUpTime(&pAd->StaCfg.CCXAdjacentAPLinkDownTime);
- pAd->StaCfg.CCXAdjacentAPReportFlag = TRUE;
- LinkDown(pAd, TRUE);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() sanity check fail\n"));
- }
-
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after assoc timeout
- Parameters:
- Elme -
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AssocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after reassoc timeout
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ReassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- what the state machine will do after disassoc timeout
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID DisassocTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenAssoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenReassoc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-VOID InvalidStateWhenDisassociate(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
- pAd->Mlme.AssocMachine.CurrState));
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- right part of IEEE 802.11/1999 page 374
- Note:
- This event should never cause ASSOC state machine perform state
- transition, and has no relationship with CNTL machine. So we separate
- this routine as a service outside of ASSOC state transition table.
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID Cls3errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr)
-{
- HEADER_802_11 DisassocHdr;
- PHEADER_802_11 pDisassocHdr;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- NDIS_STATUS NStatus;
- USHORT Reason = REASON_CLS3ERR;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
- MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid); // patch peap ttls switching issue
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DisassocHdr,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- // To patch Instance and Buffalo(N) AP
- // Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
- // Therefore, we send both of them.
- pDisassocHdr = (PHEADER_802_11)pOutBuffer;
- pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DisassocReason = REASON_CLS3ERR;
- COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pAddr);
-}
-
- /*
- ==========================================================================
- Description:
- Switch between WEP and CKIP upon new association up.
- Parameters:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID SwitchBetweenWepAndCkip(
- IN PRTMP_ADAPTER pAd)
-{
- int i;
- SHAREDKEY_MODE_STRUC csr1;
-
- // if KP is required. change the CipherAlg in hardware shard key table from WEP
- // to CKIP. else remain as WEP
- if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10))
- {
- // modify hardware key table so that MAC use correct algorithm to decrypt RX
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE, &csr1.word);
- if (csr1.field.Bss0Key0CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key0CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key0CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key0CipherAlg = CIPHER_CKIP128;
-
- if (csr1.field.Bss0Key1CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key1CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key1CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key1CipherAlg = CIPHER_CKIP128;
-
- if (csr1.field.Bss0Key2CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key2CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key2CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key2CipherAlg = CIPHER_CKIP128;
-
- if (csr1.field.Bss0Key3CipherAlg == CIPHER_WEP64)
- csr1.field.Bss0Key3CipherAlg = CIPHER_CKIP64;
- else if (csr1.field.Bss0Key3CipherAlg == CIPHER_WEP128)
- csr1.field.Bss0Key3CipherAlg = CIPHER_CKIP128;
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE, csr1.word);
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchBetweenWepAndCkip: modify BSS0 cipher to %s\n", CipherName[csr1.field.Bss0Key0CipherAlg]));
-
- // modify software key table so that driver can specify correct algorithm in TXD upon TX
- for (i=0; i<SHARE_KEY_NUM; i++)
- {
- if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_WEP64)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_CKIP64;
- else if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_WEP128)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_CKIP128;
- }
- }
-
- // else if KP NOT inused. change the CipherAlg in hardware shard key table from CKIP
- // to WEP.
- else
- {
- // modify hardware key table so that MAC use correct algorithm to decrypt RX
- RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE, &csr1.word);
- if (csr1.field.Bss0Key0CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key0CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key0CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key0CipherAlg = CIPHER_WEP128;
-
- if (csr1.field.Bss0Key1CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key1CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key1CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key1CipherAlg = CIPHER_WEP128;
-
- if (csr1.field.Bss0Key2CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key2CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key2CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key2CipherAlg = CIPHER_WEP128;
-
- if (csr1.field.Bss0Key3CipherAlg == CIPHER_CKIP64)
- csr1.field.Bss0Key3CipherAlg = CIPHER_WEP64;
- else if (csr1.field.Bss0Key3CipherAlg == CIPHER_CKIP128)
- csr1.field.Bss0Key3CipherAlg = CIPHER_WEP128;
-
- // modify software key table so that driver can specify correct algorithm in TXD upon TX
- for (i=0; i<SHARE_KEY_NUM; i++)
- {
- if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_CKIP64)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_WEP64;
- else if (pAd->SharedKey[BSS0][i].CipherAlg == CIPHER_CKIP128)
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_WEP128;
- }
-
- //
- // On WPA-NONE, must update CipherAlg.
- // Because the OID_802_11_WEP_STATUS was been set after OID_802_11_ADD_KEY
- // and CipherAlg will be CIPHER_NONE by Windows ZeroConfig.
- // So we need to update CipherAlg after connect.
- //
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- for (i = 0; i < SHARE_KEY_NUM; i++)
- {
- if (pAd->SharedKey[BSS0][i].KeyLen != 0)
- {
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
- {
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_TKIP;
- }
- else if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_AES;
- }
- }
- else
- {
- pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
- }
- }
-
- csr1.field.Bss0Key0CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
- csr1.field.Bss0Key1CipherAlg = pAd->SharedKey[BSS0][1].CipherAlg;
- csr1.field.Bss0Key2CipherAlg = pAd->SharedKey[BSS0][2].CipherAlg;
- csr1.field.Bss0Key3CipherAlg = pAd->SharedKey[BSS0][3].CipherAlg;
- }
- RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE, csr1.word);
- DBGPRINT(RT_DEBUG_TRACE, ("SwitchBetweenWepAndCkip: modify BSS0 cipher to %s\n", CipherName[csr1.field.Bss0Key0CipherAlg]));
- }
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-VOID SendAssocIEsToWpaSupplicant(
- IN PRTMP_ADAPTER pAd)
-{
- union iwreq_data wrqu;
- unsigned char custom[IW_CUSTOM_MAX] = {0};
-
- if ((pAd->StaCfg.ReqVarIELen + 17) <= IW_CUSTOM_MAX)
- {
- sprintf(custom, "ASSOCINFO_ReqIEs=");
- NdisMoveMemory(custom+17, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.length = pAd->StaCfg.ReqVarIELen + 17;
- wrqu.data.flags = RT_REQIE_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
-
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOCINFO_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen + 17 > MAX_CUSTOM_LEN\n"));
-
- return;
-}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-int wext_notify_event_assoc(
- IN RTMP_ADAPTER *pAd)
-{
- union iwreq_data wrqu;
- char custom[IW_CUSTOM_MAX] = {0};
-
-#if WIRELESS_EXT > 17
- if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX)
- {
- wrqu.data.length = pAd->StaCfg.ReqVarIELen;
- memcpy(custom, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
- wireless_send_event(pAd->net_dev, IWEVASSOCREQIE, &wrqu, custom);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
-#else
- if (((pAd->StaCfg.ReqVarIELen*2) + 17) <= IW_CUSTOM_MAX)
- {
- UCHAR idx;
- wrqu.data.length = (pAd->StaCfg.ReqVarIELen*2) + 17;
- sprintf(custom, "ASSOCINFO(ReqIEs=");
- for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++)
- sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]);
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("(pAd->StaCfg.ReqVarIELen*2) + 17 > MAX_CUSTOM_LEN\n"));
-#endif
-
- return 0;
-
-}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-
-BOOLEAN StaAddMacTableEntry(
- IN PRTMP_ADAPTER pAd,
- IN PMAC_TABLE_ENTRY pEntry,
- IN UCHAR MaxSupportedRateIn500Kbps,
- IN HT_CAPABILITY_IE *pHtCapability,
- IN UCHAR HtCapabilityLen,
- IN USHORT CapabilityInfo)
-{
- UCHAR MaxSupportedRate = RATE_11;
-
- if (ADHOC_ON(pAd))
- CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- if ((pAd->CommonCfg.PhyMode == PHY_11G) && (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
- return FALSE;
-
-#ifdef DOT11_N_SUPPORT
- // 11n only
- if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G))&& (HtCapabilityLen == 0))
- return FALSE;
-#endif // DOT11_N_SUPPORT //
-
- if (!pEntry)
- return FALSE;
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- if (pEntry)
- {
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
- if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) ||
- (pAd->CommonCfg.PhyMode == PHY_11B))
- {
- pEntry->RateLen = 4;
- if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE)
- MaxSupportedRate = RATE_11;
- }
- else
- pEntry->RateLen = 12;
-
- pEntry->MaxHTPhyMode.word = 0;
- pEntry->MinHTPhyMode.word = 0;
- pEntry->HTPhyMode.word = 0;
- pEntry->MaxSupportedRate = MaxSupportedRate;
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
- pEntry->CapabilityInfo = CapabilityInfo;
- CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
- CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE);
- }
-
-#ifdef DOT11_N_SUPPORT
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR i;
-
- if (ADHOC_ON(pAd))
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
- if ((pHtCapability->HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((pHtCapability->HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(pHtCapability->HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(pHtCapability->HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // 3*3
- if (pAd->MACVersion >= RALINK_2883_VERSION && pAd->MACVersion < RALINK_3070_VERSION)
- pEntry->MaxHTPhyMode.field.TxBF = pAd->CommonCfg.RegTransmitSetting.field.TxBF;
-
- // find max fixed rate
- for (i=23; i>=0; i--) // 3*3
- {
- j = i/8;
- bitmask = (1<<(i-(j*8)));
- if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask) && (pHtCapability->MCSSet[j] & bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = i;
- break;
- }
- if (i==0)
- break;
- }
-
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (pHtCapability->HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = pHtCapability->HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)pHtCapability->HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)pHtCapability->HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED);
- if (pHtCapability->HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (pHtCapability->HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (pHtCapability->HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (pHtCapability->HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (pHtCapability->ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
- }
- else
- {
- pAd->MacTab.fAnyStationIsLegacy = TRUE;
- }
-
- NdisMoveMemory(&pEntry->HTCapability, pHtCapability, sizeof(HT_CAPABILITY_IE));
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
-
- // Set asic auto fall back
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- // If the legacy mode is set, overwrite the transmit setting of this entry.
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
-
- pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
- pEntry->Sst = SST_ASSOC;
- pEntry->AuthState = AS_AUTH_OPEN;
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
-
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- union iwreq_data wrqu;
-
- SendAssocIEsToWpaSupplicant(pAd);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_ASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- wext_notify_event_assoc(pAd);
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- return TRUE;
-}
-
-
+#include "../../rt2870/sta/assoc.c"
diff --git a/drivers/staging/rt3070/sta/auth.c b/drivers/staging/rt3070/sta/auth.c
index 032b5df058bc..d55198288d92 100644
--- a/drivers/staging/rt3070/sta/auth.c
+++ b/drivers/staging/rt3070/sta/auth.c
@@ -1,475 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- auth.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-9-3 porting from RT2500
-*/
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- authenticate state machine init, including state transition and timer init
- Parameters:
- Sm - pointer to the auth state machine
- Note:
- The state machine looks like this
-
- AUTH_REQ_IDLE AUTH_WAIT_SEQ2 AUTH_WAIT_SEQ4
- MT2_MLME_AUTH_REQ mlme_auth_req_action invalid_state_when_auth invalid_state_when_auth
- MT2_PEER_AUTH_EVEN drop peer_auth_even_at_seq2_action peer_auth_even_at_seq4_action
- MT2_AUTH_TIMEOUT Drop auth_timeout_action auth_timeout_action
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-
-void AuthStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_REQ_IDLE, AUTH_MACHINE_BASE);
-
- // the first column
- StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)MlmeAuthReqAction);
-
- // the second column
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq2Action);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-
- // the third column
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq4Action);
- StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-
- RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer, GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- function to be executed at timer thread when auth timer expires
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AuthTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- DBGPRINT(RT_DEBUG_TRACE,("AUTH - AuthTimeout\n"));
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
- return;
-
- // send a de-auth to reset AP's state machine (Patch AP-Dir635)
- if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
- Cls2errAction(pAd, pAd->MlmeAux.Bssid);
-
-
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeAuthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr[6];
- USHORT Alg, Seq, Status;
- ULONG Timeout;
- HEADER_802_11 AuthHdr;
- BOOLEAN TimerCancelled;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
-
- // Block all authentication request durning WPA block period
- if (pAd->StaCfg.bBlockAssoc == TRUE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Block Auth request durning WPA block period!\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- else if(MlmeAuthReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr, &Timeout, &Alg))
- {
- // reset timer
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
- pAd->MlmeAux.Alg = Alg;
- Seq = 1;
- Status = MLME_SUCCESS;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeAuthReqAction(Alg:%d) allocate memory failed\n", Alg));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#1 (Alg=%d)...\n", Alg));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&AuthHdr,
- 2, &Alg,
- 2, &Seq,
- 2, &Status,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AuthTimer, Timeout);
- pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
- }
- else
- {
- DBGPRINT_ERR(("AUTH - MlmeAuthReqAction() sanity check failed\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAuthRspAtSeq2Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Seq, Status, RemoteStatus, Alg;
- UCHAR ChlgText[CIPHER_TEXT_LEN];
- UCHAR CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
- UCHAR Element[2];
- HEADER_802_11 AuthHdr;
- BOOLEAN TimerCancelled;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Status2;
-
- if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
- {
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n", Alg, Status));
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-
- if (Status == MLME_SUCCESS)
- {
- // Authentication Mode "LEAP" has allow for CCX 1.X
- if ((pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- )
- {
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-#ifdef LEAP_SUPPORT
- pAd->Mlme.LeapMachine.CurrState = LEAP_IDLE;
-#endif // LEAP_SUPPORT //
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- else
- {
- // 2. shared key, need to be challenged
- Seq++;
- RemoteStatus = MLME_SUCCESS;
-
- // Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status2 = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status2);
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#3...\n"));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr2, pAd->MlmeAux.Bssid);
- AuthHdr.FC.Wep = 1;
- // Encrypt challenge text & auth information
- RTMPInitWepEngine(
- pAd,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
- CyperChlgText);
-
- Alg = cpu2le16(*(USHORT *)&Alg);
- Seq = cpu2le16(*(USHORT *)&Seq);
- RemoteStatus= cpu2le16(*(USHORT *)&RemoteStatus);
-
- RTMPEncryptData(pAd, (PUCHAR) &Alg, CyperChlgText + 4, 2);
- RTMPEncryptData(pAd, (PUCHAR) &Seq, CyperChlgText + 6, 2);
- RTMPEncryptData(pAd, (PUCHAR) &RemoteStatus, CyperChlgText + 8, 2);
- Element[0] = 16;
- Element[1] = 128;
- RTMPEncryptData(pAd, Element, CyperChlgText + 10, 2);
- RTMPEncryptData(pAd, ChlgText, CyperChlgText + 12, 128);
- RTMPSetICV(pAd, CyperChlgText + 140);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AuthHdr,
- CIPHER_TEXT_LEN + 16, CyperChlgText,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- RTMPSetTimer(&pAd->MlmeAux.AuthTimer, AUTH_TIMEOUT);
- pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ4;
- }
- }
- else
- {
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- //Invalid Authentication possible rogue AP
- //Add this Ap to Rogue AP.
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_INVALID_AUTH);
- }
-#endif // LEAP_SUPPORT //
- pAd->StaCfg.AuthFailReason = Status;
- COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthSanity() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerAuthRspAtSeq4Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Alg, Seq, Status;
- CHAR ChlgText[CIPHER_TEXT_LEN];
- BOOLEAN TimerCancelled;
-
- if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
- {
- if(MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#4 to me\n"));
- RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-
- if (Status != MLME_SUCCESS)
- {
- pAd->StaCfg.AuthFailReason = Status;
- COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
- }
-
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDeauthReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- HEADER_802_11 DeauthHdr;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Status;
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *)Elem->Msg;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_FAIL_NO_RESOURCE;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
- return;
- }
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send DE-AUTH request (Reason=%d)...\n", pInfo->Reason));
- MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DeauthHdr,
- 2, &pInfo->Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DeauthReason = pInfo->Reason;
- COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
-
- // send wireless event - for deauthentication
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID AuthTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID InvalidStateWhenAuth(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n", pAd->Mlme.AuthMachine.CurrState));
- pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- Some STA/AP
- Note:
- This action should never trigger AUTH state transition, therefore we
- separate it from AUTH state machine, and make it as a standalone service
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID Cls2errAction(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr)
-{
- HEADER_802_11 DeauthHdr;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT Reason = REASON_CLS2ERR;
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Class 2 error, Send DEAUTH frame...\n"));
- MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11),&DeauthHdr,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- pAd->StaCfg.DeauthReason = Reason;
- COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
-}
-
-
+#include "../../rt2870/sta/auth.c"
diff --git a/drivers/staging/rt3070/sta/auth_rsp.c b/drivers/staging/rt3070/sta/auth_rsp.c
index f7aa4b99cf56..c4ea2dc49ad7 100644
--- a/drivers/staging/rt3070/sta/auth_rsp.c
+++ b/drivers/staging/rt3070/sta/auth_rsp.c
@@ -1,167 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- auth_rsp.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-10-1 copy from RT2560
-*/
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- authentication state machine init procedure
- Parameters:
- Sm - the state machine
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-VOID AuthRspStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN PSTATE_MACHINE Sm,
- IN STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_RSP_IDLE, AUTH_RSP_MACHINE_BASE);
-
- // column 1
- StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
-
- // column 2
- StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID PeerAuthSimpleRspGenAndSend(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHdr80211,
- IN USHORT Alg,
- IN USHORT Seq,
- IN USHORT Reason,
- IN USHORT Status)
-{
- HEADER_802_11 AuthHdr;
- ULONG FrameLen = 0;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
-
- if (Reason != MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
- return;
- }
-
- //Get an unused nonpaged memory
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
- MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2, pAd->MlmeAux.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &AuthHdr,
- 2, &Alg,
- 2, &Seq,
- 2, &Reason,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID PeerDeauthAction(
- IN PRTMP_ADAPTER pAd,
- IN PMLME_QUEUE_ELEM Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- USHORT Reason;
-
- if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
- {
- if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason));
-
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-
- // send wireless event - for deauthentication
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- LinkDown(pAd, TRUE);
-
- // Authentication Mode Cisco_LEAP has start a timer
- // We should cancel it if using LEAP
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
- //Check is it mach the LEAP Authentication failed as possible a Rogue AP
- //on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Authenticaton.
- if ((pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED) && (pAd->Mlme.LeapMachine.CurrState != LEAP_IDLE))
- {
- RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
- }
- }
-#endif // LEAP_SUPPORT //
- }
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
- }
-}
-
+#include "../../rt2870/sta/auth_rsp.c"
diff --git a/drivers/staging/rt3070/sta/connect.c b/drivers/staging/rt3070/sta/connect.c
index 152c0bd0f822..d77802caa305 100644
--- a/drivers/staging/rt3070/sta/connect.c
+++ b/drivers/staging/rt3070/sta/connect.c
@@ -1,2857 +1,2 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- connect.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John 2004-08-08 Major modification from RT2560
-*/
-#include "../rt_config.h"
-
-UCHAR CipherSuiteWpaNoneTkip[] = {
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x00 // authentication
- };
-UCHAR CipherSuiteWpaNoneTkipLen = (sizeof(CipherSuiteWpaNoneTkip) / sizeof(UCHAR));
-
-UCHAR CipherSuiteWpaNoneAes[] = {
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x04, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x04, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x00 // authentication
- };
-UCHAR CipherSuiteWpaNoneAesLen = (sizeof(CipherSuiteWpaNoneAes) / sizeof(UCHAR));
-
-// The following MACRO is called after 1. starting an new IBSS, 2. succesfully JOIN an IBSS,
-// or 3. succesfully ASSOCIATE to a BSS, 4. successfully RE_ASSOCIATE to a BSS
-// All settings successfuly negotiated furing MLME state machines become final settings
-// and are copied to pAd->StaActive
-#define COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
-{ \
- (_pAd)->CommonCfg.SsidLen = (_pAd)->MlmeAux.SsidLen; \
- NdisMoveMemory((_pAd)->CommonCfg.Ssid, (_pAd)->MlmeAux.Ssid, (_pAd)->MlmeAux.SsidLen); \
- COPY_MAC_ADDR((_pAd)->CommonCfg.Bssid, (_pAd)->MlmeAux.Bssid); \
- (_pAd)->CommonCfg.Channel = (_pAd)->MlmeAux.Channel; \
- (_pAd)->CommonCfg.CentralChannel = (_pAd)->MlmeAux.CentralChannel; \
- (_pAd)->StaActive.Aid = (_pAd)->MlmeAux.Aid; \
- (_pAd)->StaActive.AtimWin = (_pAd)->MlmeAux.AtimWin; \
- (_pAd)->StaActive.CapabilityInfo = (_pAd)->MlmeAux.CapabilityInfo; \
- (_pAd)->CommonCfg.BeaconPeriod = (_pAd)->MlmeAux.BeaconPeriod; \
- (_pAd)->StaActive.CfpMaxDuration = (_pAd)->MlmeAux.CfpMaxDuration; \
- (_pAd)->StaActive.CfpPeriod = (_pAd)->MlmeAux.CfpPeriod; \
- (_pAd)->StaActive.SupRateLen = (_pAd)->MlmeAux.SupRateLen; \
- NdisMoveMemory((_pAd)->StaActive.SupRate, (_pAd)->MlmeAux.SupRate, (_pAd)->MlmeAux.SupRateLen);\
- (_pAd)->StaActive.ExtRateLen = (_pAd)->MlmeAux.ExtRateLen; \
- NdisMoveMemory((_pAd)->StaActive.ExtRate, (_pAd)->MlmeAux.ExtRate, (_pAd)->MlmeAux.ExtRateLen);\
- NdisMoveMemory(&(_pAd)->CommonCfg.APEdcaParm, &(_pAd)->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));\
- NdisMoveMemory(&(_pAd)->CommonCfg.APQosCapability, &(_pAd)->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));\
- NdisMoveMemory(&(_pAd)->CommonCfg.APQbssLoad, &(_pAd)->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));\
- COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].Addr, (_pAd)->MlmeAux.Bssid); \
- (_pAd)->MacTab.Content[BSSID_WCID].Aid = (_pAd)->MlmeAux.Aid; \
- (_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = (_pAd)->StaCfg.PairCipher;\
- COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.BssId, (_pAd)->MlmeAux.Bssid);\
- (_pAd)->MacTab.Content[BSSID_WCID].RateLen = (_pAd)->StaActive.SupRateLen + (_pAd)->StaActive.ExtRateLen;\
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
-*/
-VOID MlmeCntlInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- // Control state machine differs from other state machines, the interface
- // follows the standard interface
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID MlmeCntlMachinePerformAction(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- IN MLME_QUEUE_ELEM *Elem)
-{
- switch(pAd->Mlme.CntlMachine.CurrState)
- {
- case CNTL_IDLE:
- {
- CntlIdleProc(pAd, Elem);
- }
- break;
- case CNTL_WAIT_DISASSOC:
- CntlWaitDisassocProc(pAd, Elem);
- break;
- case CNTL_WAIT_JOIN:
- CntlWaitJoinProc(pAd, Elem);
- break;
-
- // CNTL_WAIT_REASSOC is the only state in CNTL machine that does
- // not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
- // Therefore not protected by NDIS's "only one outstanding OID request"
- // rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
- // Current approach is to block new SET request at RTMPSetInformation()
- // when CntlMachine.CurrState is not CNTL_IDLE
- case CNTL_WAIT_REASSOC:
- CntlWaitReassocProc(pAd, Elem);
- break;
-
- case CNTL_WAIT_START:
- CntlWaitStartProc(pAd, Elem);
- break;
- case CNTL_WAIT_AUTH:
- CntlWaitAuthProc(pAd, Elem);
- break;
- case CNTL_WAIT_AUTH2:
- CntlWaitAuthProc2(pAd, Elem);
- break;
- case CNTL_WAIT_ASSOC:
- CntlWaitAssocProc(pAd, Elem);
- break;
-
- case CNTL_WAIT_OID_LIST_SCAN:
- if(Elem->MsgType == MT2_SCAN_CONF)
- {
- // Resume TxRing after SCANING complete. We hope the out-of-service time
- // won't be too long to let upper layer time-out the waiting frames
- RTMPResumeMsduTransmission(pAd);
- if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED)
- {
- // Cisco scan request is finished, prepare beacon report
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
- }
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
- //
- // Set LED status to previous status.
- //
- if (pAd->bLedOnScanning)
- {
- pAd->bLedOnScanning = FALSE;
- RTMPSetLED(pAd, pAd->LedStatus);
- }
-#ifdef DOT11N_DRAFT3
- // AP sent a 2040Coexistence mgmt frame, then station perform a scan, and then send back the respone.
- if (pAd->CommonCfg.BSSCoexist2040.field.InfoReq == 1)
- {
- Update2040CoexistFrameAndNotify(pAd, BSSID_WCID, TRUE);
- }
-#endif // DOT11N_DRAFT3 //
- }
- break;
-
- case CNTL_WAIT_OID_DISASSOC:
- if (Elem->MsgType == MT2_DISASSOC_CONF)
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
- break;
-#ifdef RT2870
- //
- // This state is for that we want to connect to an AP but
- // it didn't find on BSS List table. So we need to scan the air first,
- // after that we can try to connect to the desired AP if available.
- //
- case CNTL_WAIT_SCAN_FOR_CONNECT:
- if(Elem->MsgType == MT2_SCAN_CONF)
- {
- // Resume TxRing after SCANING complete. We hope the out-of-service time
- // won't be too long to let upper layer time-out the waiting frames
- RTMPResumeMsduTransmission(pAd);
-#ifdef CCX_SUPPORT
- if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED)
- {
- // Cisco scan request is finished, prepare beacon report
- MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_DONE, 0, NULL);
- }
-#endif // CCX_SUPPORT //
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
- //
- // Check if we can connect to.
- //
- BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
- if (pAd->MlmeAux.SsidBssTab.BssNr > 0)
- {
- MlmeAutoReconnectLastSSID(pAd);
- }
- }
- break;
-#endif // RT2870 //
- default:
- DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", Elem->MsgType));
- break;
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlIdleProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- return;
-
- switch(Elem->MsgType)
- {
- case OID_802_11_SSID:
- CntlOidSsidProc(pAd, Elem);
- break;
-
- case OID_802_11_BSSID:
- CntlOidRTBssidProc(pAd,Elem);
- break;
-
- case OID_802_11_BSSID_LIST_SCAN:
- CntlOidScanProc(pAd,Elem);
- break;
-
- case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE_WITH_WEB_UI)
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAd->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
- }
- break;
-
- case MT2_MLME_ROAMING_REQ:
- CntlMlmeRoamingProc(pAd, Elem);
- break;
-
- case OID_802_11_MIC_FAILURE_REPORT_FRAME:
- WpaMicFailureReportFrame(pAd, Elem);
- break;
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS_PARAM:
- CntlOidDLSSetupProc(pAd, Elem);
- break;
-#endif // QOS_DLS_SUPPORT //
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem->MsgType));
- break;
- }
-}
-
-VOID CntlOidScanProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_SCAN_REQ_STRUCT ScanReq;
- ULONG BssIdx = BSS_NOT_FOUND;
- BSS_ENTRY CurrBss;
-
-#ifdef RALINK_ATE
-/* Disable scanning when ATE is running. */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
-
- // record current BSS if network is connected.
- // 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- BssIdx = BssSsidTableSearch(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->CommonCfg.Channel);
- if (BssIdx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(&CurrBss, &pAd->ScanTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
- }
- }
-
- // clean up previous SCAN result, add current BSS back to table if any
- BssTableInit(&pAd->ScanTab);
- if (BssIdx != BSS_NOT_FOUND)
- {
- // DDK Note: If the NIC is associated with a particular BSSID and SSID
- // that are not contained in the list of BSSIDs generated by this scan, the
- // BSSID description of the currently associated BSSID and SSID should be
- // appended to the list of BSSIDs in the NIC's database.
- // To ensure this, we append this BSS as the first entry in SCAN result
- NdisMoveMemory(&pAd->ScanTab.BssEntry[0], &CurrBss, sizeof(BSS_ENTRY));
- pAd->ScanTab.BssNr = 1;
- }
-
- ScanParmFill(pAd, &ScanReq, "", 0, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
- sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-}
-
-/*
- ==========================================================================
- Description:
- Before calling this routine, user desired SSID should already been
- recorded in CommonCfg.Ssid[]
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidSsidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem)
-{
- PNDIS_802_11_SSID pOidSsid = (NDIS_802_11_SSID *)Elem->Msg;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
- ULONG Now;
-
- // Step 1. record the desired user settings to MlmeAux
- NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, pOidSsid->Ssid, pOidSsid->SsidLength);
- pAd->MlmeAux.SsidLen = (UCHAR)pOidSsid->SsidLength;
- NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
-
- //
- // Update Reconnect Ssid, that user desired to connect.
- //
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
-
- // step 2. find all matching BSS in the lastest SCAN result (inBssTab)
- // & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order
- BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n",
- pAd->MlmeAux.SsidBssTab.BssNr, pAd->ScanTab.BssNr, pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid));
- NdisGetSystemUpTime(&Now);
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
- (pAd->CommonCfg.SsidLen == pAd->MlmeAux.SsidBssTab.BssEntry[0].SsidLen) &&
- NdisEqualMemory(pAd->CommonCfg.Ssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Ssid, pAd->CommonCfg.SsidLen) &&
- MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Bssid))
- {
- // Case 1. already connected with an AP who has the desired SSID
- // with highest RSSI
-
- // Add checking Mode "LEAP" for CCX 1.0
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- ) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- // case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
- // connection process
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else if (pAd->bConfigChanged == TRUE)
- {
- // case 1.2 Important Config has changed, we have to reconnect to the same AP
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else
- {
- // case 1.3. already connected to the SSID with highest RSSI.
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
- //
- // (HCT 12.1) 1c_wlan_mediaevents required
- // media connect events are indicated when associating with the same AP
- //
- if (INFRA_ON(pAd))
- {
- //
- // Since MediaState already is NdisMediaStateConnected
- // We just indicate the connect event again to meet the WHQL required.
- //
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_UP; // Update extra information to link is up
- }
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- }
- else if (INFRA_ON(pAd))
- {
- //
- // For RT61
- // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
- // RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect
- // But media status is connected, so the SSID not report correctly.
- //
- if (!SSID_EQUAL(pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen))
- {
- //
- // Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event.
- //
- pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
- }
- // case 2. active INFRA association existent
- // roaming is done within miniport driver, nothing to do with configuration
- // utility. so upon a new SET(OID_802_11_SSID) is received, we just
- // disassociate with the current associated AP,
- // then perform a new association with this new SSID, no matter the
- // new/old SSID are the same or not.
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else
- {
- if (ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
- LinkDown(pAd, FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
- }
-
- if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) &&
- (pAd->StaCfg.bAutoReconnect == TRUE) &&
- (pAd->MlmeAux.BssType == BSS_INFRA) &&
- (MlmeValidateSSID(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen) == TRUE)
- )
- {
- MLME_SCAN_REQ_STRUCT ScanReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n"));
- ScanParmFill(pAd, &ScanReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, BSS_ANY, SCAN_ACTIVE);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
- // Reset Missed scan number
- pAd->StaCfg.LastScanTime = Now;
- }
- else
- {
- pAd->MlmeAux.BssIdx = 0;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidRTBssidProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM * Elem)
-{
- ULONG BssIdx;
- PUCHAR pOidBssid = (PUCHAR)Elem->Msg;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
- MLME_JOIN_REQ_STRUCT JoinReq;
-
-#ifdef RALINK_ATE
-/* No need to perform this routine when ATE is running. */
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- // record user desired settings
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pOidBssid);
- pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
- //
- // Update Reconnect Ssid, that user desired to connect.
- //
- NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
- pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
- NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-
- // find the desired BSS in the latest SCAN result table
- BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);
- if (BssIdx == BSS_NOT_FOUND)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- return;
- }
-
- // copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why?
- // Because we need this entry to become the JOIN target in later on SYNC state machine
- pAd->MlmeAux.BssIdx = 0;
- pAd->MlmeAux.SsidBssTab.BssNr = 1;
- NdisMoveMemory(&pAd->MlmeAux.SsidBssTab.BssEntry[0], &pAd->ScanTab.BssEntry[BssIdx], sizeof(BSS_ENTRY));
-
- //pAd->MlmeAux.AutoReconnectSsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
- //NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->ScanTab.BssEntry[BssIdx].SsidLen);
-
- // Add SSID into MlmeAux for site surey joining hidden SSID
- //pAd->MlmeAux.SsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
- //NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->MlmeAux.SsidLen);
-
- // 2002-11-26 skip the following checking. i.e. if user wants to re-connect to same AP
- // we just follow normal procedure. The reason of user doing this may because he/she changed
- // AP to another channel, but we still received BEACON from it thus don't claim Link Down.
- // Since user knows he's changed AP channel, he'll re-connect again. By skipping the following
- // checking, we'll disassociate then re-do normal association with this AP at the new channel.
- // 2003-1-6 Re-enable this feature based on microsoft requirement which prefer not to re-do
- // connection when setting the same BSSID.
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
- MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pOidBssid))
- {
- // already connected to the same BSSID, go back to idle state directly
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - already in this BSSID. ignore this SET_BSSID request\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
-
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- }
- else
- {
- if (INFRA_ON(pAd))
- {
- // disassoc from current AP first
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - disassociate with current AP ...\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
- sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- }
- else
- {
- if (ADHOC_ON(pAd))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - drop current ADHOC\n"));
- LinkDown(pAd, FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
- }
-
- // Change the wepstatus to original wepstatus
- pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
- // Check cipher suite, AP must have more secured cipher than station setting
- // Set the Pairwise and Group cipher to match the intended AP setting
- // We can only connect to AP with less secured cipher setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher;
- else if (pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher;
- else if (pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-
- // RSN capability
- pAd->StaCfg.RsnCapability = pAd->ScanTab.BssEntry[BssIdx].WPA2.RsnCapability;
- }
-
- // Set Mix cipher flag
- pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
- if (pAd->StaCfg.bMixCipher == TRUE)
- {
- // If mix cipher, re-build RSNIE
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- }
- // No active association, join the BSS immediately
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pOidBssid[0],pOidBssid[1],pOidBssid[2],pOidBssid[3],pOidBssid[4],pOidBssid[5]));
-
- JoinParmFill(pAd, &JoinReq, pAd->MlmeAux.BssIdx);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT), &JoinReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
- }
- }
-}
-
-// Roaming is the only external request triggering CNTL state machine
-// despite of other "SET OID" operation. All "SET OID" related oerations
-// happen in sequence, because no other SET OID will be sent to this device
-// until the the previous SET operation is complete (successful o failed).
-// So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
-// or been corrupted by other "SET OID"?
-//
-// IRQL = DISPATCH_LEVEL
-VOID CntlMlmeRoamingProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- // TODO:
- // AP in different channel may show lower RSSI than actual value??
- // should we add a weighting factor to compensate it?
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
-
- NdisMoveMemory(&pAd->MlmeAux.SsidBssTab, &pAd->MlmeAux.RoamTab, sizeof(pAd->MlmeAux.RoamTab));
- pAd->MlmeAux.SsidBssTab.BssNr = pAd->MlmeAux.RoamTab.BssNr;
-
- BssTableSortByRssi(&pAd->MlmeAux.SsidBssTab);
- pAd->MlmeAux.BssIdx = 0;
- IterateOnBssTab(pAd);
-}
-
-#ifdef QOS_DLS_SUPPORT
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlOidDLSSetupProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PRT_802_11_DLS pDLS = (PRT_802_11_DLS)Elem->Msg;
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- INT i;
- USHORT reason = REASON_UNSPECIFY;
-
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - (OID set %02x:%02x:%02x:%02x:%02x:%02x with Valid=%d, Status=%d, TimeOut=%d, CountDownTimer=%d)\n",
- pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5],
- pDLS->Valid, pDLS->Status, pDLS->TimeOut, pDLS->CountDownTimer));
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- // DLS will not be supported when Adhoc mode
- if (INFRA_ON(pAd))
- {
- for (i = 0; i < MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- (pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 1. Same setting, just drop it
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - setting unchanged\n"));
- break;
- }
- else if (!pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 2. Disable DLS link case, just tear down DLS link
- reason = REASON_QOS_UNWANTED_MECHANISM;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - start tear down procedure\n"));
- break;
- }
- else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid)
- {
- // 3. Enable case, start DLS setup procedure
- NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
-
- //Update countdown timer
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS setup case\n"));
- break;
- }
- else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 4. update mac case, tear down old DLS and setup new DLS
- reason = REASON_QOS_UNWANTED_MECHANISM;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS tear down and restart case\n"));
- break;
- }
- else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut))
- {
- // 5. update timeout case, start DLS setup procedure (no tear down)
- pAd->StaCfg.DLSEntry[i].TimeOut = pDLS->TimeOut;
- //Update countdown timer
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS update timeout case\n"));
- break;
- }
- else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
- (pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- // 6. re-setup case, start DLS setup procedure (no tear down)
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS retry setup procedure\n"));
- break;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN,("CNTL - DLS not changed in entry - %d - Valid=%d, Status=%d, TimeOut=%d\n",
- i, pAd->StaCfg.DLSEntry[i].Valid, pAd->StaCfg.DLSEntry[i].Status, pAd->StaCfg.DLSEntry[i].TimeOut));
- }
- }
- }
-}
-#endif // QOS_DLS_SUPPORT //
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitDisassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- MLME_START_REQ_STRUCT StartReq;
-
- if (Elem->MsgType == MT2_DISASSOC_CONF)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Dis-associate successful\n"));
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- LinkDown(pAd, FALSE);
-
- // case 1. no matching BSS, and user wants ADHOC, so we just start a new one
- if ((pAd->MlmeAux.SsidBssTab.BssNr==0) && (pAd->StaCfg.BssType == BSS_ADHOC))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
- StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
- // case 2. try each matched BSS
- else
- {
- pAd->MlmeAux.BssIdx = 0;
-
- IterateOnBssTab(pAd);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitJoinProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_JOIN_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- // 1. joined an IBSS, we are pretty much done here
- if (pAd->MlmeAux.BssType == BSS_ADHOC)
- {
- //
- // 5G bands rules of Japan:
- // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
- //
- if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
- RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
- )
- {
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
- return;
- }
-
- LinkUp(pAd, BSS_ADHOC);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- }
- // 2. joined a new INFRA network, start from authentication
- else
- {
-#ifdef LEAP_SUPPORT
- // Add AuthMode "LEAP" for CCX 1.X
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
- }
- else
-#endif // LEAP_SUPPORT //
- {
- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeShared);
- }
- else
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- }
- }
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH;
- }
- }
- else
- {
- // 3. failed, try next BSS
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitStartProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Result;
-
- if (Elem->MsgType == MT2_START_CONF)
- {
- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
- if (Result == MLME_SUCCESS)
- {
- //
- // 5G bands rules of Japan:
- // Ad hoc must be disabled in W53(ch52,56,60,64) channels.
- //
- if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
- RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
- )
- {
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
- return;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- N_ChannelCheck(pAd);
- SetCommonHT(pAd);
- NdisMoveMemory(&pAd->MlmeAux.AddHtInfo, &pAd->CommonCfg.AddHTInfo, sizeof(ADD_HT_INFO_IE));
- RTMPCheckHt(pAd, BSSID_WCID, &pAd->CommonCfg.HtCapability, &pAd->CommonCfg.AddHTInfo);
- pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
- NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
- NdisMoveMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], &pAd->CommonCfg.HtCapability.MCSSet[0], 16);
- COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
- if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE))
- {
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel + 2;
- }
- else if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW))
- {
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel - 2;
- }
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- }
- LinkUp(pAd, BSS_ADHOC);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- // Before send beacon, driver need do radar detection
- if ((pAd->CommonCfg.Channel > 14 )
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- pAd->CommonCfg.RadarDetect.RDMode = RD_SILENCE_MODE;
- pAd->CommonCfg.RadarDetect.RDCount = 0;
-#ifdef DFS_SUPPORT
- BbpRadarDetectionStart(pAd);
-#endif // DFS_SUPPORT //
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
- pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Start IBSS fail. BUG!!!!!\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAuthProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_ASSOC_REQ_STRUCT AssocReq;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_AUTH_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
- AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
-
-#ifdef LEAP_SUPPORT
- //
- // Cisco Leap CCKM supported Re-association.
- //
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- {
- //if CCKM is turn on , that's mean Fast Reauthentication
- //Use CCKM Reassociation instead of normal association for Fast Roaming.
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
- }
- else
-#endif // LEAP_SUPPORT //
- {
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
- }
- }
- else
- {
- // This fail may because of the AP already keep us in its MAC table without
- // ageing-out. The previous authentication attempt must have let it remove us.
- // so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try again...\n"));
-#ifdef LEAP_SUPPORT
- //Add AuthMode "LEAP" for CCX 1.X
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
- }
- else
-#endif // LEAP_SUPPORT //
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
- {
- // either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeShared);
- }
- else
- {
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- }
- }
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAuthProc2(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
- MLME_ASSOC_REQ_STRUCT AssocReq;
- MLME_AUTH_REQ_STRUCT AuthReq;
-
- if (Elem->MsgType == MT2_AUTH_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
- AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
- sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
- }
- else
- {
-#ifdef LEAP_SUPPORT
- // Process LEAP first, since it use different control variable
- // We don't want to affect other poven operation
- if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
- {
- // LEAP Auth not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - *LEAP* AUTH FAIL, give up; try next BSS\n"));
- DBGPRINT(RT_DEBUG_TRACE, ("Total match BSSID [=%d]\n", pAd->MlmeAux.SsidBssTab.BssNr));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- else
-#endif // LEAP_SUPPORT //
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) &&
- (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try OPEN system...\n"));
- AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
- MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
- sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
- }
- else
- {
- // not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, give up; try next BSS\n"));
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; //???????
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitAssocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Reason;
-
- if (Elem->MsgType == MT2_ASSOC_CONF)
- {
- NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
- if (Reason == MLME_SUCCESS)
- {
- LinkUp(pAd, BSS_INFRA);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association successful on BSS #%ld\n",pAd->MlmeAux.BssIdx));
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
- else
- {
- // not success, try next BSS
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association fails on BSS #%ld\n",pAd->MlmeAux.BssIdx));
- pAd->MlmeAux.BssIdx++;
- IterateOnBssTab(pAd);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID CntlWaitReassocProc(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Result;
-
- if (Elem->MsgType == MT2_REASSOC_CONF)
- {
- NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
- if (Result == MLME_SUCCESS)
- {
- //
- // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
- //
- LinkUp(pAd, BSS_INFRA);
-
- // send wireless event - for association
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
-
-#ifdef LEAP_SUPPORT
- if (LEAP_CCKM_ON(pAd))
- {
- STA_PORT_SECURED(pAd);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
-#endif // LEAP_SUPPORT //
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
- }
- else
- {
- // reassoc failed, try to pick next BSS in the BSS Table
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition fails on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
- pAd->MlmeAux.RoamIdx++;
- IterateOnBssTab2(pAd);
- }
- }
-}
-
-
-VOID AdhocTurnOnQos(
- IN PRTMP_ADAPTER pAd)
-{
-#define AC0_DEF_TXOP 0
-#define AC1_DEF_TXOP 0
-#define AC2_DEF_TXOP 94
-#define AC3_DEF_TXOP 47
-
- // Turn on QOs if use HT rate.
- if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
- {
- pAd->CommonCfg.APEdcaParm.bValid = TRUE;
- pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
- pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
- pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
- pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-
- pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
- pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
-
- pAd->CommonCfg.APEdcaParm.Cwmax[0] = 10;
- pAd->CommonCfg.APEdcaParm.Cwmax[1] = 6;
- pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
- pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
-
- pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
- pAd->CommonCfg.APEdcaParm.Txop[2] = AC2_DEF_TXOP;
- pAd->CommonCfg.APEdcaParm.Txop[3] = AC3_DEF_TXOP;
- }
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID LinkUp(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR BssType)
-{
- ULONG Now;
- UINT32 Data;
- BOOLEAN Cancelled;
- UCHAR Value = 0, idx;
- MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
-
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
- //
- // ASSOC - DisassocTimeoutAction
- // CNTL - Dis-associate successful
- // !!! LINK DOWN !!!
- // [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
- //
- // To prevent DisassocTimeoutAction to call Link down after we link up,
- // cancel the DisassocTimer no matter what it start or not.
- //
- RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
-
- COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
-#ifdef DOT11_N_SUPPORT
- COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-#endif // DOT11_N_SUPPORT //
- // It's quite difficult to tell if a newly added KEY is WEP or CKIP until a new BSS
- // is formed (either ASSOC/RE-ASSOC done or IBSS started. LinkUP should be a safe place
- // to examine if cipher algorithm switching is required.
- //rt2860b. Don't know why need this
- SwitchBetweenWepAndCkip(pAd);
-
-
- if (BssType == BSS_ADHOC)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE))
- {
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
- }
- else if ((pAd->CommonCfg.Channel > 2) &&
- (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == BW_40) &&
- (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW))
- {
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
- }
-#endif // DOT11_N_SUPPORT //
-
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- // No carrier detection when adhoc
- // CarrierDetectionStop(pAd);
- pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL;
-#endif // CARRIER_DETECTION_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- AdhocTurnOnQos(pAd);
-#endif // DOT11_N_SUPPORT //
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!Adhoc LINK UP !!! \n" ));
- }
- else
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!Infra LINK UP !!! \n" ));
- }
-
- // 3*3
- // reset Tx beamforming bit
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x01);
- Value |= pAd->CommonCfg.RegTransmitSetting.field.TxBF;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
-#ifdef DOT11_N_SUPPORT
- // Change to AP channel
- if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- // Must using 40MHz.
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- Value |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- // RX : control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
- Value &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data &= 0xfffffffe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- // Must using 40MHz.
- pAd->CommonCfg.BBPCurrentBW = BW_40;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- Value |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data |= 0x1;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
- Value |= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
- Value &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
- RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
- Data &= 0xfffffffe;
- RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
- Value &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-
- if (pAd->MACVersion == 0x28600100)
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! 20MHz LINK UP !!! \n" ));
- }
-
- RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
- //
- // Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission
- //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
- BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
-
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Density =%d, )\n", pAd->MacTab.Content[BSSID_WCID].MpduDensity));
-#endif // DOT11_N_SUPPORT //
-
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-
- AsicSetSlotTime(pAd, TRUE);
- AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
- // Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit
- AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE, FALSE);
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))
- {
- // Update HT protectionfor based on AP's operating mode.
- if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
- }
- else
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
- }
-#endif // DOT11_N_SUPPORT //
-
- NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS));
-
- NdisGetSystemUpTime(&Now);
- pAd->StaCfg.LastBeaconRxTime = Now; // last RX timestamp
-
- if ((pAd->CommonCfg.TxPreamble != Rt802_11PreambleLong) &&
- CAP_IS_SHORT_PREAMBLE_ON(pAd->StaActive.CapabilityInfo))
- {
- MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
- }
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
- if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE)
- {
-#ifdef DFS_SUPPORT
- RadarDetectionStop(pAd);
-#endif // DFS_SUPPORT //
- }
- pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
- if (BssType == BSS_ADHOC)
- {
- MakeIbssBeacon(pAd);
- if ((pAd->CommonCfg.Channel > 14)
- && (pAd->CommonCfg.bIEEE80211H == 1)
- && RadarChannelCheck(pAd, pAd->CommonCfg.Channel))
- {
- ; //Do nothing
- }
- else
- {
- AsicEnableIbssSync(pAd);
- }
-
- // In ad hoc mode, use MAC table from index 1.
- // p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here.
- RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00);
- RTMP_IO_WRITE32(pAd, 0x1808, 0x00);
-
- // If WEP is enabled, add key material and cipherAlg into Asic
- // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
-
- if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
- {
- PUCHAR Key;
- UCHAR CipherAlg;
-
- for (idx=0; idx < SHARE_KEY_NUM; idx++)
- {
- CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
- Key = pAd->SharedKey[BSS0][idx].Key;
-
- if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
- {
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- if (idx == pAd->StaCfg.DefaultKeyId)
- {
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
- }
- }
-
-
- }
- }
- // If WPANone is enabled, add key material and cipherAlg into Asic
- // Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
- else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAd->StaCfg.DefaultKeyId = 0; // always be zero
-
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
-
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd->StaCfg.PairCipher));
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- }
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pAd->SharedKey[BSS0][0].CipherAlg, NULL);
-
- }
-
- }
- else // BSS_INFRA
- {
- // Check the new SSID with last SSID
- while (Cancelled == TRUE)
- {
- if (pAd->CommonCfg.LastSsidLen == pAd->CommonCfg.SsidLen)
- {
- if (RTMPCompareMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen) == 0)
- {
- // Link to the old one no linkdown is required.
- break;
- }
- }
- // Send link down event before set to link up
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));
- break;
- }
-
- //
- // On WPA mode, Remove All Keys if not connect to the last BSSID
- // Key will be set after 4-way handshake.
- //
- if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- ULONG IV;
-
- // Remove all WPA keys
- RTMPWPARemoveAllKeys(pAd);
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-
- // Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP
- // If IV related values are too large in GroupMsg2, AP would ignore this message.
- IV = 0;
- IV |= (pAd->StaCfg.DefaultKeyId << 30);
- AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
- }
- // NOTE:
- // the decision of using "short slot time" or not may change dynamically due to
- // new STA association to the AP. so we have to decide that upon parsing BEACON, not here
-
- // NOTE:
- // the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically
- // due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here
-
- ComposePsPoll(pAd);
- ComposeNullFrame(pAd);
-
- AsicEnableBssSync(pAd);
-
- // Add BSSID to WCID search table
- AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- // add this BSSID entry into HASH table
- {
- UCHAR HashIdx;
-
- //pEntry = &pAd->MacTab.Content[BSSID_WCID];
- HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid);
- if (pAd->MacTab.Hash[HashIdx] == NULL)
- {
- pAd->MacTab.Hash[HashIdx] = pEntry;
- }
- else
- {
- pCurrEntry = pAd->MacTab.Hash[HashIdx];
- while (pCurrEntry->pNext != NULL)
- pCurrEntry = pCurrEntry->pNext;
- pCurrEntry->pNext = pEntry;
- }
- }
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
-
- // If WEP is enabled, add paiewise and shared key
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (((pAd->StaCfg.WpaSupplicantUP)&&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)&&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) ||
- ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)&&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)))
-#else
- if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- PUCHAR Key;
- UCHAR CipherAlg;
-
- for (idx=0; idx < SHARE_KEY_NUM; idx++)
- {
- CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
- Key = pAd->SharedKey[BSS0][idx].Key;
-
- if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
- {
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
-
- if (idx == pAd->StaCfg.DefaultKeyId)
- {
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
-
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);
- }
- }
- }
- }
-
- // only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
- // should wait until at least 2 active nodes in this BSSID.
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- // For GUI ++
- if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- {
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- RTMP_IndicateMediaState(pAd);
- }
- // --
-
- // Add BSSID in my MAC Table.
- NdisAcquireSpinLock(&pAd->MacTabLock);
- RTMPMoveMemory(pAd->MacTab.Content[BSSID_WCID].Addr, pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
- pAd->MacTab.Content[BSSID_WCID].Aid = BSSID_WCID;
- pAd->MacTab.Content[BSSID_WCID].pAd = pAd;
- pAd->MacTab.Content[BSSID_WCID].ValidAsCLI = TRUE; //Although this is bssid..still set ValidAsCl
- pAd->MacTab.Size = 1; // infra mode always set MACtab size =1.
- pAd->MacTab.Content[BSSID_WCID].Sst = SST_ASSOC;
- pAd->MacTab.Content[BSSID_WCID].AuthState = SST_ASSOC;
- pAd->MacTab.Content[BSSID_WCID].AuthMode = pAd->StaCfg.AuthMode;
- pAd->MacTab.Content[BSSID_WCID].WepStatus = pAd->StaCfg.WepStatus;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! ClientStatusFlags=%lx)\n",
- pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
- MlmeUpdateTxRates(pAd, TRUE, BSS0);
-#ifdef DOT11_N_SUPPORT
- MlmeUpdateHtTxRates(pAd, BSS0);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd->StaActive.SupportedPhyInfo.bHtEnable));
-#endif // DOT11_N_SUPPORT //
-
- //
- // Report Adjacent AP report.
- //
-#ifdef LEAP_SUPPORT
- CCXAdjacentAPReport(pAd);
-#endif // LEAP_SUPPORT //
-
- if (pAd->CommonCfg.bAggregationCapable)
- {
- if ((pAd->CommonCfg.bPiggyBackCapable) && (pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)
- {
-
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- RTMPSetPiggyBack(pAd, TRUE);
- DBGPRINT(RT_DEBUG_TRACE, ("Turn on Piggy-Back\n"));
- }
- else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- }
- }
-
- if (pAd->MlmeAux.APRalinkIe != 0x0)
- {
-#ifdef DOT11_N_SUPPORT
- if (CLIENT_STATUS_TEST_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RDG_CAPABLE))
- {
- AsicEnableRDG(pAd);
- }
-#endif // DOT11_N_SUPPORT //
- OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
- CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);
- }
- else
- {
- OPSTATUS_CLEAR_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
- CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);
- }
- }
-
-#ifdef DOT11_N_SUPPORT
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n", pAd->CommonCfg.BACapability.word, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-#endif // DOT11_N_SUPPORT //
-
- // Set LED
- RTMPSetLED(pAd, LED_LINK_UP);
-
- pAd->Mlme.PeriodicRound = 0;
- pAd->Mlme.OneSecPeriodicRound = 0;
- pAd->bConfigChanged = FALSE; // Reset config flag
- pAd->ExtraInfo = GENERAL_LINK_UP; // Update extra information to link is up
-
- // Set asic auto fall back
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID], &pTable, &TableSize, &pAd->CommonCfg.TxRateIndex);
- AsicUpdateAutoFallBackTable(pAd, pTable);
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
- pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
- if (pAd->StaCfg.bAutoTxRateSwitch == FALSE)
- {
- pEntry->bAutoTxRateSwitch = FALSE;
-#ifdef DOT11_N_SUPPORT
- if (pEntry->HTPhyMode.field.MCS == 32)
- pEntry->HTPhyMode.field.ShortGI = GI_800;
-
- if ((pEntry->HTPhyMode.field.MCS > MCS_7) || (pEntry->HTPhyMode.field.MCS == 32))
- pEntry->HTPhyMode.field.STBC = STBC_NONE;
-#endif // DOT11_N_SUPPORT //
- // If the legacy mode is set, overwrite the transmit setting of this entry.
- if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM)
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- else
- pEntry->bAutoTxRateSwitch = TRUE;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- // Let Link Status Page display first initial rate.
- pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
- // Select DAC according to HT or Legacy
- if (pAd->StaActive.SupportedPhyInfo.MCSSet[0] != 0x00)
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
- Value &= (~0x18);
- if (pAd->Antenna.field.TxPath == 2)
- {
- Value |= 0x10;
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
- }
- else
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
- Value &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
- {
- }
- else if (pEntry->MaxRAmpduFactor == 0)
- {
- // If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0.
- // Because our Init value is 1 at MACRegTable.
- RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff);
- }
-#endif // DOT11_N_SUPPORT //
-
- // Patch for Marvel AP to gain high throughput
- // Need to set as following,
- // 1. Set txop in register-EDCA_AC0_CFG as 0x60
- // 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero
- // 3. PBF_MAX_PCNT as 0x1F3FBF9F
- // 4. kick per two packets when dequeue
- //
- // Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable
- //
- // if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is.
-#ifdef DOT11_N_SUPPORT
-// if ((!IS_RT30xx(pAd)) &&
- if (!((pAd->CommonCfg.RxStream == 1)&&(pAd->CommonCfg.TxStream == 1)) &&
- (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
- || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE))))
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n"));
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (pAd->CommonCfg.bEnableTxBurst)
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- Data |= 0x60;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = TRUE;
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3FBF9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 2\n"));
- }
- else
- {
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
- Data &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
- RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
- DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n"));
- }
-
-#ifdef DOT11_N_SUPPORT
- // Re-check to turn on TX burst or not.
- if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) && ((STA_WEP_ON(pAd))||(STA_TKIP_ON(pAd))))
- {
- pAd->CommonCfg.IOTestParm.bNextDisableRxBA = TRUE;
- if (pAd->CommonCfg.bEnableTxBurst)
- {
- UINT32 MACValue = 0;
- // Force disable TXOP value in this case. The same action in MLMEUpdateProtect too.
- // I didn't change PBF_MAX_PCNT setting.
- RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &MACValue);
- MACValue &= 0xFFFFFF00;
- RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, MACValue);
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
- }
- }
- else
- {
- pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE;
- }
-#endif // DOT11_N_SUPPORT //
-
- pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE;
- COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
- DBGPRINT(RT_DEBUG_TRACE, ("!!!pAd->bNextDisableRxBA= %d \n", pAd->CommonCfg.IOTestParm.bNextDisableRxBA));
- // BSSID add in one MAC entry too. Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap
- // Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver.
- // Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same.
-
- if (pAd->StaCfg.WepStatus <= Ndis802_11WEPDisabled)
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pEntry->PortSecured = pAd->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- //
- // Patch Atheros AP TX will breakdown issue.
- // AP Model: DLink DWL-8200AP
- //
- if (INFRA_ON(pAd) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && STA_TKIP_ON(pAd))
- {
- RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x01);
- }
- else
- {
- RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x00);
- }
-
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if ((pAd->CommonCfg.BACapability.field.b2040CoexistScanSup) && (pAd->CommonCfg.Channel <= 11))
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SCAN_2040);
- BuildEffectedChannelList(pAd);
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-}
-
-/*
- ==========================================================================
-
- Routine Description:
- Disconnect current BSSID
-
- Arguments:
- pAd - Pointer to our adapter
- IsReqFromAP - Request from AP
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- We need more information to know it's this requst from AP.
- If yes! we need to do extra handling, for example, remove the WPA key.
- Otherwise on 4-way handshaking will faied, since the WPA key didn't be
- remove while auto reconnect.
- Disconnect request from AP, it means we will start afresh 4-way handshaking
- on WPA mode.
-
- ==========================================================================
-*/
-VOID LinkDown(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN IsReqFromAP)
-{
- UCHAR i, ByteValue = 0;
-
- // Do nothing if monitor mode is on
- if (MONITOR_ON(pAd))
- return;
-
-#ifdef RALINK_ATE
- // Nothing to do in ATE mode.
- if (ATE_ON(pAd))
- return;
-#endif // RALINK_ATE //
-
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n"));
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
- if (ADHOC_ON(pAd)) // Adhoc mode link down
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n"));
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MacTab.Size=%d !!!\n", pAd->MacTab.Size));
- }
- else // Infra structure mode
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n"));
-
-#ifdef QOS_DLS_SUPPORT
- // DLS tear down frame must be sent before link down
- // send DLS-TEAR_DOWN message
- if (pAd->CommonCfg.bDLSCapable)
- {
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-#endif // QOS_DLS_SUPPORT //
-
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- // Saved last SSID for linkup comparison
- pAd->CommonCfg.LastSsidLen = pAd->CommonCfg.SsidLen;
- NdisMoveMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen);
- COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
- if (pAd->MlmeAux.CurrReqIsFromNdis == TRUE)
- {
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"));
- pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
- }
- else
- {
- //
- // If disassociation request is from NDIS, then we don't need to delete BSSID from entry.
- // Otherwise lost beacon or receive De-Authentication from AP,
- // then we should delete BSSID from BssTable.
- // If we don't delete from entry, roaming will fail.
- //
- BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
- }
-
- // restore back to -
- // 1. long slot (20 us) or short slot (9 us) time
- // 2. turn on/off RTS/CTS and/or CTS-to-self protection
- // 3. short preamble
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
-
- if (pAd->StaCfg.CCXAdjacentAPReportFlag == TRUE)
- {
- //
- // Record current AP's information.
- // for later used reporting Adjacent AP report.
- //
- pAd->StaCfg.CCXAdjacentAPChannel = pAd->CommonCfg.Channel;
- pAd->StaCfg.CCXAdjacentAPSsidLen = pAd->CommonCfg.SsidLen;
- NdisMoveMemory(pAd->StaCfg.CCXAdjacentAPSsid, pAd->CommonCfg.Ssid, pAd->StaCfg.CCXAdjacentAPSsidLen);
- COPY_MAC_ADDR(pAd->StaCfg.CCXAdjacentAPBssid, pAd->CommonCfg.Bssid);
- }
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // Country IE of the AP will be evaluated and will be used.
- if (pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None)
- {
- NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pAd->StaCfg.StaOriCountryCode[0], 2);
- pAd->CommonCfg.Geography = pAd->StaCfg.StaOriGeography;
- BuildChannelListEx(pAd);
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- }
-
- for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
- MacTableDeleteEntry(pAd, pAd->MacTab.Content[i].Aid, pAd->MacTab.Content[i].Addr);
- }
-
- pAd->StaCfg.CCXQosECWMin = 4;
- pAd->StaCfg.CCXQosECWMax = 10;
-
- AsicSetSlotTime(pAd, TRUE); //FALSE);
- AsicSetEdcaParm(pAd, NULL);
-
- // Set LED
- RTMPSetLED(pAd, LED_LINK_DOWN);
- pAd->LedIndicatorStregth = 0xF0;
- RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
-
- AsicDisableSync(pAd);
-
- pAd->Mlme.PeriodicRound = 0;
- pAd->Mlme.OneSecPeriodicRound = 0;
-
- if (pAd->StaCfg.BssType == BSS_INFRA)
- {
- // Remove StaCfg Information after link down
- NdisZeroMemory(pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
- NdisZeroMemory(pAd->CommonCfg.Ssid, MAX_LEN_OF_SSID);
- pAd->CommonCfg.SsidLen = 0;
- }
-#ifdef DOT11_N_SUPPORT
- NdisZeroMemory(&pAd->MlmeAux.HtCapability, sizeof(HT_CAPABILITY_IE));
- NdisZeroMemory(&pAd->MlmeAux.AddHtInfo, sizeof(ADD_HT_INFO_IE));
- pAd->MlmeAux.HtCapabilityLen = 0;
- pAd->MlmeAux.NewExtChannelOffset = 0xff;
-#endif // DOT11_N_SUPPORT //
-
- // Reset WPA-PSK state. Only reset when supplicant enabled
- if (pAd->StaCfg.WpaState != SS_NOTUSE)
- {
- pAd->StaCfg.WpaState = SS_START;
- // Clear Replay counter
- NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
-
-#ifdef QOS_DLS_SUPPORT
- if (pAd->CommonCfg.bDLSCapable)
- NdisZeroMemory(pAd->StaCfg.DlsReplayCounter, 8);
-#endif // QOS_DLS_SUPPORT //
- }
-
-
- //
- // if link down come from AP, we need to remove all WPA keys on WPA mode.
- // otherwise will cause 4-way handshaking failed, since the WPA key not empty.
- //
- if ((IsReqFromAP) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- // Remove all WPA keys
- RTMPWPARemoveAllKeys(pAd);
- }
-
- // 802.1x port control
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Prevent clear PortSecured here with static WEP
- // NetworkManger set security policy first then set SSID to connect AP.
- if (pAd->StaCfg.WpaSupplicantUP &&
- (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
- (pAd->StaCfg.IEEE8021X == FALSE))
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
- }
-
- NdisAcquireSpinLock(&pAd->MacTabLock);
- pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAd->MacTabLock);
-
- pAd->StaCfg.MicErrCnt = 0;
-
- // Turn off Ckip control flag
- pAd->StaCfg.bCkipOn = FALSE;
- pAd->StaCfg.CCXEnable = FALSE;
-
- pAd->IndicateMediaState = NdisMediaStateDisconnected;
- // Update extra information to link is up
- pAd->ExtraInfo = GENERAL_LINK_DOWN;
-
- //pAd->StaCfg.AdhocBOnlyJoined = FALSE;
- //pAd->StaCfg.AdhocBGJoined = FALSE;
- //pAd->StaCfg.Adhoc20NJoined = FALSE;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
-
- // Reset the Current AP's IP address
- NdisZeroMemory(pAd->StaCfg.AironetIPAddress, 4);
-#ifdef RT2870
- pAd->bUsbTxBulkAggre = FALSE;
-#endif // RT2870 //
-
- // Clean association information
- NdisZeroMemory(&pAd->StaCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));
- pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
- pAd->StaCfg.ReqVarIELen = 0;
- pAd->StaCfg.ResVarIELen = 0;
-
- //
- // Reset RSSI value after link down
- //
- pAd->StaCfg.RssiSample.AvgRssi0 = 0;
- pAd->StaCfg.RssiSample.AvgRssi0X8 = 0;
- pAd->StaCfg.RssiSample.AvgRssi1 = 0;
- pAd->StaCfg.RssiSample.AvgRssi1X8 = 0;
- pAd->StaCfg.RssiSample.AvgRssi2 = 0;
- pAd->StaCfg.RssiSample.AvgRssi2X8 = 0;
-
- // Restore MlmeRate
- pAd->CommonCfg.MlmeRate = pAd->CommonCfg.BasicMlmeRate;
- pAd->CommonCfg.RtsRate = pAd->CommonCfg.BasicMlmeRate;
-
-#ifdef DOT11_N_SUPPORT
- //
- // After Link down, reset piggy-back setting in ASIC. Disable RDG.
- //
- if (pAd->CommonCfg.BBPCurrentBW == BW_40)
- {
- pAd->CommonCfg.BBPCurrentBW = BW_20;
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &ByteValue);
- ByteValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, ByteValue);
- }
-#endif // DOT11_N_SUPPORT //
- // Reset DAC
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &ByteValue);
- ByteValue &= (~0x18);
- if (pAd->Antenna.field.TxPath == 2)
- {
- ByteValue |= 0x10;
- }
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, ByteValue);
-
- RTMPSetPiggyBack(pAd,FALSE);
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
-
-#ifdef DOT11_N_SUPPORT
- pAd->CommonCfg.BACapability.word = pAd->CommonCfg.REGBACapability.word;
-#endif // DOT11_N_SUPPORT //
-
- // Restore all settings in the following.
- AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT|CCKSETPROTECT|OFDMSETPROTECT), TRUE, FALSE);
- AsicDisableRDG(pAd);
- pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE;
- pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SCAN_2040);
- pAd->CommonCfg.BSSCoexist2040.word = 0;
- TriEventInit(pAd);
- for (i = 0; i < (pAd->ChannelListNum - 1); i++)
- {
- pAd->ChannelList[i].bEffectedChannel = FALSE;
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
- RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff);
- RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP) {
- union iwreq_data wrqu;
- //send disassociate event to wpa_supplicant
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
- {
- union iwreq_data wrqu;
- memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
- wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
- }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-
-#ifdef RT30xx
- if (IS_RT3090(pAd))
- {
- UINT32 macdata;
- // disable MMPS BBP control register
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &ByteValue);
- ByteValue &= ~(0x04); //bit 2
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, ByteValue);
-
- // disable MMPS MAC control register
- RTMP_IO_READ32(pAd, 0x1210, &macdata);
- macdata &= ~(0x09); //bit 0, 3
- RTMP_IO_WRITE32(pAd, 0x1210, macdata);
- }
-#endif // RT30xx //
-
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID IterateOnBssTab(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_START_REQ_STRUCT StartReq;
- MLME_JOIN_REQ_STRUCT JoinReq;
- ULONG BssIdx;
-
- // Change the wepstatus to original wepstatus
- pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
- pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
- BssIdx = pAd->MlmeAux.BssIdx;
- if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr)
- {
- // Check cipher suite, AP must have more secured cipher than station setting
- // Set the Pairwise and Group cipher to match the intended AP setting
- // We can only connect to AP with less secured cipher setting
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher;
- else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.GroupCipher;
-
- if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher;
- else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
- pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux;
- else // There is no PairCipher Aux, downgrade our capability to TKIP
- pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-
- // RSN capability
- pAd->StaCfg.RsnCapability = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.RsnCapability;
- }
-
- // Set Mix cipher flag
- pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
- if (pAd->StaCfg.bMixCipher == TRUE)
- {
- // If mix cipher, re-build RSNIE
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - iterate BSS %ld of %d\n", BssIdx, pAd->MlmeAux.SsidBssTab.BssNr));
- JoinParmFill(pAd, &JoinReq, BssIdx);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT),
- &JoinReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
- }
- else if (pAd->StaCfg.BssType == BSS_ADHOC)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
- StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
- }
- else // no more BSS
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All roaming failed, stay @ ch #%d\n", pAd->CommonCfg.Channel));
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
-}
-
-// for re-association only
-// IRQL = DISPATCH_LEVEL
-VOID IterateOnBssTab2(
- IN PRTMP_ADAPTER pAd)
-{
- MLME_REASSOC_REQ_STRUCT ReassocReq;
- ULONG BssIdx;
- BSS_ENTRY *pBss;
-
- BssIdx = pAd->MlmeAux.RoamIdx;
- pBss = &pAd->MlmeAux.RoamTab.BssEntry[BssIdx];
-
- if (BssIdx < pAd->MlmeAux.RoamTab.BssNr)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - iterate BSS %ld of %d\n", BssIdx, pAd->MlmeAux.RoamTab.BssNr));
-
- AsicSwitchChannel(pAd, pBss->Channel, FALSE);
- AsicLockChannel(pAd, pBss->Channel);
-
- // reassociate message has the same structure as associate message
- AssocParmFill(pAd, &ReassocReq, pBss->Bssid, pBss->CapabilityInfo,
- ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
- sizeof(MLME_REASSOC_REQ_STRUCT), &ReassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
- }
- else // no more BSS
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All fast roaming failed, back to ch #%d\n",pAd->CommonCfg.Channel));
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID JoinParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
- IN ULONG BssIdx)
-{
- JoinReq->BssIdx = BssIdx;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID ScanParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen,
- IN UCHAR BssType,
- IN UCHAR ScanType)
-{
- NdisZeroMemory(ScanReq->Ssid, MAX_LEN_OF_SSID);
- ScanReq->SsidLen = SsidLen;
- NdisMoveMemory(ScanReq->Ssid, Ssid, SsidLen);
- ScanReq->BssType = BssType;
- ScanReq->ScanType = ScanType;
-}
-
-#ifdef QOS_DLS_SUPPORT
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID DlsParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
- IN PRT_802_11_DLS pDls,
- IN USHORT reason)
-{
- pDlsReq->pDLS = pDls;
- pDlsReq->Reason = reason;
-}
-#endif // QOS_DLS_SUPPORT //
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID StartParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_START_REQ_STRUCT *StartReq,
- IN CHAR Ssid[],
- IN UCHAR SsidLen)
-{
- ASSERT(SsidLen <= MAX_LEN_OF_SSID);
- NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen);
- StartReq->SsidLen = SsidLen;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-VOID AuthParmFill(
- IN PRTMP_ADAPTER pAd,
- IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
- IN PUCHAR pAddr,
- IN USHORT Alg)
-{
- COPY_MAC_ADDR(AuthReq->Addr, pAddr);
- AuthReq->Alg = Alg;
- AuthReq->Timeout = AUTH_TIMEOUT;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-
-
-#ifdef RT2870
-
-VOID MlmeCntlConfirm(
- IN PRTMP_ADAPTER pAd,
- IN ULONG MsgType,
- IN USHORT Msg)
-{
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg);
-}
-
-VOID ComposePsPoll(
- IN PRTMP_ADAPTER pAd)
-{
- PTXINFO_STRUC pTxInfo;
- PTXWI_STRUC pTxWI;
-
- DBGPRINT(RT_DEBUG_TRACE, ("ComposePsPoll\n"));
- NdisZeroMemory(&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
-
- pAd->PsPollFrame.FC.PwrMgmt = 0;
- pAd->PsPollFrame.FC.Type = BTYPE_CNTL;
- pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL;
- pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000;
- COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress);
-
- RTMPZeroMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0], 100);
- pTxInfo = (PTXINFO_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[0];
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(PSPOLL_FRAME)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxWI = (PTXWI_STRUC)&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(PSPOLL_FRAME)),
- 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
- RTMPMoveMemory(&pAd->PsPollContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
- // Append 4 extra zero bytes.
- pAd->PsPollContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(PSPOLL_FRAME) + 4;
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID ComposeNullFrame(
- IN PRTMP_ADAPTER pAd)
-{
- PTXINFO_STRUC pTxInfo;
- PTXWI_STRUC pTxWI;
-
- NdisZeroMemory(&pAd->NullFrame, sizeof(HEADER_802_11));
- pAd->NullFrame.FC.Type = BTYPE_DATA;
- pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC;
- pAd->NullFrame.FC.ToDs = 1;
- COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid);
- RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[0], 100);
- pTxInfo = (PTXINFO_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[0];
- RTMPWriteTxInfo(pAd, pTxInfo, (USHORT)(sizeof(HEADER_802_11)+TXWI_SIZE), TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
- pTxWI = (PTXWI_STRUC)&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXINFO_SIZE];
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, BSSID_WCID, (sizeof(HEADER_802_11)),
- 0, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
- RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.WirelessPacket[TXWI_SIZE+TXINFO_SIZE], &pAd->NullFrame, sizeof(HEADER_802_11));
- pAd->NullContext.BulkOutSize = TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
-}
-#endif // RT2870 //
-
-
-/*
- ==========================================================================
- Description:
- Pre-build a BEACON frame in the shared memory
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
-*/
-ULONG MakeIbssBeacon(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR DsLen = 1, IbssLen = 2;
- UCHAR LocalErpIe[3] = {IE_ERP, 1, 0x04};
- HEADER_802_11 BcnHdr;
- USHORT CapabilityInfo;
- LARGE_INTEGER FakeTimestamp;
- ULONG FrameLen = 0;
- PTXWI_STRUC pTxWI = &pAd->BeaconTxWI;
- CHAR *pBeaconFrame = pAd->BeaconBuf;
- BOOLEAN Privacy;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen = 0;
- UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR ExtRateLen = 0;
- UCHAR RSNIe = IE_WPA;
-
- if ((pAd->CommonCfg.PhyMode == PHY_11B) && (pAd->CommonCfg.Channel <= 14))
- {
- SupRate[0] = 0x82; // 1 mbps
- SupRate[1] = 0x84; // 2 mbps
- SupRate[2] = 0x8b; // 5.5 mbps
- SupRate[3] = 0x96; // 11 mbps
- SupRateLen = 4;
- ExtRateLen = 0;
- }
- else if (pAd->CommonCfg.Channel > 14)
- {
- SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
- SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
- SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
- SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- SupRateLen = 8;
- ExtRateLen = 0;
-
- //
- // Also Update MlmeRate & RtsRate for G only & A only
- //
- pAd->CommonCfg.MlmeRate = RATE_6;
- pAd->CommonCfg.RtsRate = RATE_6;
- pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
- pAd->CommonCfg.MlmeTransmit.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = MODE_OFDM;
- pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
- }
- else
- {
- SupRate[0] = 0x82; // 1 mbps
- SupRate[1] = 0x84; // 2 mbps
- SupRate[2] = 0x8b; // 5.5 mbps
- SupRate[3] = 0x96; // 11 mbps
- SupRateLen = 4;
-
- ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps,
- ExtRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
- ExtRate[2] = 0x18; // 12 mbps, in units of 0.5 Mbps,
- ExtRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
- ExtRate[4] = 0x30; // 24 mbps, in units of 0.5 Mbps,
- ExtRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
- ExtRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
- ExtRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
- ExtRateLen = 8;
- }
-
- pAd->StaActive.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->StaActive.SupRate, SupRate, SupRateLen);
- pAd->StaActive.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, ExtRateLen);
-
- // compose IBSS beacon frame
- MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR, pAd->CommonCfg.Bssid);
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
-
- MakeOutgoingFrame(pBeaconFrame, &FrameLen,
- sizeof(HEADER_802_11), &BcnHdr,
- TIMESTAMP_LEN, &FakeTimestamp,
- 2, &pAd->CommonCfg.BeaconPeriod,
- 2, &CapabilityInfo,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &SupRateLen,
- SupRateLen, SupRate,
- 1, &DsIe,
- 1, &DsLen,
- 1, &pAd->CommonCfg.Channel,
- 1, &IbssIe,
- 1, &IbssLen,
- 2, &pAd->StaActive.AtimWin,
- END_OF_ARGS);
-
- // add ERP_IE and EXT_RAE IE of in 802.11g
- if (ExtRateLen)
- {
- ULONG tmp;
-
- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
- 3, LocalErpIe,
- 1, &ExtRateIe,
- 1, &ExtRateLen,
- ExtRateLen, ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // If adhoc secruity is set for WPA-None, append the cipher suite IE
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- ULONG tmp;
- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-
- MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- ULONG TmpLen;
- UCHAR HtLen, HtLen1;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
- ADD_HT_INFO_IE addHTInfoTmp;
- USHORT b2lTmp, b2lTmp2;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(pAd->CommonCfg.HtCapability);
- HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- 1, &AddHtInfoIe,
- 1, &HtLen1,
- HtLen1, &pAd->CommonCfg.AddHTInfo,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- NdisMoveMemory(&addHTInfoTmp, &pAd->CommonCfg.AddHTInfo, HtLen1);
- *(USHORT *)(&addHTInfoTmp.AddHtInfo2) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo2));
- *(USHORT *)(&addHTInfoTmp.AddHtInfo3) = SWAP16(*(USHORT *)(&addHTInfoTmp.AddHtInfo3));
-
- MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- 1, &AddHtInfoIe,
- 1, &HtLen1,
- HtLen1, &addHTInfoTmp,
- END_OF_ARGS);
-#endif
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
-
- //beacon use reserved WCID 0xff
- if (pAd->CommonCfg.Channel > 14)
- {
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
- PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
- }
- else
- {
- // Set to use 1Mbps for Adhoc beacon.
- HTTRANSMIT_SETTING Transmit;
- Transmit.word = 0;
- RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
- PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &Transmit);
- }
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, pBeaconFrame, DIR_WRITE, FALSE);
- RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
-#endif
-
- DBGPRINT(RT_DEBUG_TRACE, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
- FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel, pAd->CommonCfg.PhyMode));
- return FrameLen;
-}
-
+#include "../../rt2870/sta/connect.c"
diff --git a/drivers/staging/rt3070/sta/dls.c b/drivers/staging/rt3070/sta/dls.c
deleted file mode 100644
index 8bcd41329343..000000000000
--- a/drivers/staging/rt3070/sta/dls.c
+++ /dev/null
@@ -1,2170 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- dls.c
-
- Abstract:
- Handle WMM-DLS state machine
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 02-14-2006
- Arvin Tai 06-03-2008 Modified for RT28xx
- */
-
-#include "../rt_config.h"
-
-/*
- ==========================================================================
- Description:
- dls state machine init, including state transition and timer init
- Parameters:
- Sm - pointer to the dls state machine
- Note:
- The state machine looks like this
-
- DLS_IDLE
- MT2_MLME_DLS_REQUEST MlmeDlsReqAction
- MT2_PEER_DLS_REQUEST PeerDlsReqAction
- MT2_PEER_DLS_RESPONSE PeerDlsRspAction
- MT2_MLME_DLS_TEARDOWN MlmeTearDownAction
- MT2_PEER_DLS_TEARDOWN PeerTearDownAction
-
- IRQL = PASSIVE_LEVEL
-
- ==========================================================================
- */
-void DlsStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- UCHAR i;
-
- StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_DLS_STATE, MAX_DLS_MSG, (STATE_MACHINE_FUNC)Drop, DLS_IDLE, DLS_MACHINE_BASE);
-
- // the first column
- StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_REQ, (STATE_MACHINE_FUNC)MlmeDlsReqAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_REQ, (STATE_MACHINE_FUNC)PeerDlsReqAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_RSP, (STATE_MACHINE_FUNC)PeerDlsRspAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)MlmeDlsTearDownAction);
- StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)PeerDlsTearDownAction);
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- pAd->StaCfg.DLSEntry[i].pAd = pAd;
- RTMPInitTimer(pAd, &pAd->StaCfg.DLSEntry[i].Timer, GET_TIMER_FUNCTION(DlsTimeoutAction), pAd, FALSE);
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- HEADER_802_11 DlsReqHdr;
- PRT_802_11_DLS pDLS = NULL;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_REQUEST;
- ULONG tmp;
- USHORT reason;
- ULONG Timeout;
- BOOLEAN TimerCancelled;
-
- if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &reason))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsReqAction() \n"));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsReqAction() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsReqHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsReqHdr,
- 1, &Category,
- 1, &Action,
- 6, &pDLS->MacAddr,
- 6, pAd->CurrentAddress,
- 2, &pAd->StaActive.CapabilityInfo,
- 2, &pDLS->TimeOut,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR HtLen;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(HT_CAPABILITY_IE);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- FrameLen = FrameLen + tmp;
- }
-#endif // DOT11_N_SUPPORT //
-
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
- Timeout = DLS_TIMEOUT;
- RTMPSetTimer(&pDLS->Timer, Timeout);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- USHORT StatusCode = MLME_SUCCESS;
- HEADER_802_11 DlsRspHdr;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_RESPONSE;
- ULONG tmp;
- USHORT CapabilityInfo;
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT DLSTimeOut;
- SHORT i;
- ULONG Timeout;
- BOOLEAN TimerCancelled;
- PRT_802_11_DLS pDLS = NULL;
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR SupportedRatesLen;
- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR HtCapabilityLen;
- HT_CAPABILITY_IE HtCapability;
-
- if (!PeerDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &DLSTimeOut,
- &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
- return;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (i = 0; i < SupportedRatesLen; i++)
- {
- if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
- MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() from %02x:%02x:%02x:%02x:%02x:%02x\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() allocate memory failed \n"));
- return;
- }
-
- if (!INFRA_ON(pAd))
- {
- StatusCode = MLME_REQUEST_DECLINED;
- }
- else if (!pAd->CommonCfg.bWmmCapable)
- {
- StatusCode = MLME_DEST_STA_IS_NOT_A_QSTA;
- }
- else if (!pAd->CommonCfg.bDLSCapable)
- {
- StatusCode = MLME_REQUEST_DECLINED;
- }
- else
- {
- // find table to update parameters
- for (i = (MAX_NUM_OF_DLS_ENTRY-1); i >= 0; i--)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- }
-
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
- pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- pDLS = &pAd->StaCfg.DLSEntry[i];
- break;
- }
- }
-
- // can not find in table, create a new one
- if (i < 0)
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() can not find same entry \n"));
- for (i=(MAX_NUM_OF_DLS_ENTRY - 1); i >= MAX_NUM_OF_INIT_DLS_ENTRY; i--)
- {
- if (!pAd->StaCfg.DLSEntry[i].Valid)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- }
-
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- pAd->StaCfg.DLSEntry[i].Valid = TRUE;
- pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
- pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
- NdisMoveMemory(pAd->StaCfg.DLSEntry[i].MacAddr, SA, MAC_ADDR_LEN);
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- pDLS = &pAd->StaCfg.DLSEntry[i];
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
-
- printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS);
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- break;
- }
- }
- }
- StatusCode = MLME_SUCCESS;
-
- // can not find in table, create a new one
- if (i < 0)
- {
- StatusCode = MLME_QOS_UNSPECIFY;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() DLSEntry table full(only can support %d DLS session) \n", MAX_NUM_OF_DLS_ENTRY - MAX_NUM_OF_INIT_DLS_ENTRY));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() use entry(%d) %02x:%02x:%02x:%02x:%02x:%02x\n",
- i, SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
- }
-
- ActHeaderInit(pAd, &DlsRspHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- if (StatusCode == MLME_SUCCESS)
- {
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsRspHdr,
- 1, &Category,
- 1, &Action,
- 2, &StatusCode,
- 6, SA,
- 6, pAd->CurrentAddress,
- 2, &pAd->StaActive.CapabilityInfo,
- 1, &SupRateIe,
- 1, &pAd->MlmeAux.SupRateLen,
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
- END_OF_ARGS);
-
- if (pAd->MlmeAux.ExtRateLen != 0)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &ExtRateIe,
- 1, &pAd->MlmeAux.ExtRateLen,
- pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR HtLen;
-
-#ifdef RT_BIG_ENDIAN
- HT_CAPABILITY_IE HtCapabilityTmp;
-#endif
-
- // add HT Capability IE
- HtLen = sizeof(HT_CAPABILITY_IE);
-#ifndef RT_BIG_ENDIAN
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &pAd->CommonCfg.HtCapability,
- END_OF_ARGS);
-#else
- NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
- *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
- *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
-
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &HtCapIe,
- 1, &HtLen,
- HtLen, &HtCapabilityTmp,
- END_OF_ARGS);
-#endif
- FrameLen = FrameLen + tmp;
- }
-#endif // DOT11_N_SUPPORT //
-
- if (pDLS && (pDLS->Status != DLS_FINISH))
- {
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
- Timeout = DLS_TIMEOUT;
- RTMPSetTimer(&pDLS->Timer, Timeout);
- }
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsRspHdr,
- 1, &Category,
- 1, &Action,
- 2, &StatusCode,
- 6, SA,
- 6, pAd->CurrentAddress,
- END_OF_ARGS);
- }
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsRspAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT CapabilityInfo;
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT StatusCode;
- SHORT i;
- BOOLEAN TimerCancelled;
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR SupportedRatesLen;
- UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR HtCapabilityLen;
- HT_CAPABILITY_IE HtCapability;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- if (!INFRA_ON(pAd))
- return;
-
- if (!PeerDlsRspSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &StatusCode,
- &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
- return;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (i=0; i<SupportedRatesLen; i++)
- {
- if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
- MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x with StatusCode=%d, CapabilityInfo=0x%x\n",
- SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], StatusCode, CapabilityInfo));
-
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (StatusCode == MLME_SUCCESS)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
- }
- else
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
- }
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
-
- //initialize seq no for DLS frames.
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- }
- else
- {
- // DLS setup procedure failed.
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
- }
- }
- }
-
- if (i >= MAX_NUM_OF_INIT_DLS_ENTRY)
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() update timeout value \n"));
- for (i=(MAX_NUM_OF_DLS_ENTRY-1); i>=MAX_NUM_OF_INIT_DLS_ENTRY; i--)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (StatusCode == MLME_SUCCESS)
- {
- MAC_TABLE_ENTRY *pEntry;
- UCHAR MaxSupportedRate = RATE_11;
-
- pEntry = MacTableInsertDlsEntry(pAd, SA, i);
-
- switch (MaxSupportedRateIn500Kbps)
- {
- case 108: MaxSupportedRate = RATE_54; break;
- case 96: MaxSupportedRate = RATE_48; break;
- case 72: MaxSupportedRate = RATE_36; break;
- case 48: MaxSupportedRate = RATE_24; break;
- case 36: MaxSupportedRate = RATE_18; break;
- case 24: MaxSupportedRate = RATE_12; break;
- case 18: MaxSupportedRate = RATE_9; break;
- case 12: MaxSupportedRate = RATE_6; break;
- case 22: MaxSupportedRate = RATE_11; break;
- case 11: MaxSupportedRate = RATE_5_5; break;
- case 4: MaxSupportedRate = RATE_2; break;
- case 2: MaxSupportedRate = RATE_1; break;
- default: MaxSupportedRate = RATE_11; break;
- }
-
- pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
-
- if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
- pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- pEntry->HTPhyMode.field.MODE = MODE_CCK;
- pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
- pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- pEntry->HTPhyMode.field.MODE = MODE_OFDM;
- pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
- }
-
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MinHTPhyMode.field.BW = BW_20;
-
-#ifdef DOT11_N_SUPPORT
- pEntry->HTCapability.MCSSet[0] = 0;
- pEntry->HTCapability.MCSSet[1] = 0;
-
- // If this Entry supports 802.11n, upgrade to HT rate.
- if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- UCHAR j, bitmask; //k,bitmask;
- CHAR ii;
-
- if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
- }
- else
- {
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pAd->MacTab.fAnyStationNonGF = TRUE;
- pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
- }
-
- if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
- {
- pEntry->MaxHTPhyMode.field.BW= BW_40;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
- }
- else
- {
- pEntry->MaxHTPhyMode.field.BW = BW_20;
- pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
- pAd->MacTab.fAnyStation20Only = TRUE;
- }
-
- // find max fixed rate
- for (ii=15; ii>=0; ii--)
- {
- j = ii/8;
- bitmask = (1<<(ii-(j*8)));
- if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
- {
- pEntry->MaxHTPhyMode.field.MCS = ii;
- break;
- }
- if (ii==0)
- break;
- }
-
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
- {
- printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
- pAd->StaCfg.DesiredTransmitSetting.field.MCS);
- if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
- {
- // Fix MCS as HT Duplicated Mode
- pEntry->MaxHTPhyMode.field.BW = 1;
- pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
- pEntry->MaxHTPhyMode.field.STBC = 0;
- pEntry->MaxHTPhyMode.field.ShortGI = 0;
- pEntry->MaxHTPhyMode.field.MCS = 32;
- }
- else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
- {
- // STA supports fixed MCS
- pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- }
- }
-
- pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
- pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
- pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
- pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
- pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
- if (HtCapability.HtCapInfo.ShortGIfor20)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
- if (HtCapability.HtCapInfo.ShortGIfor40)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
- if (HtCapability.HtCapInfo.TxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
- if (HtCapability.HtCapInfo.RxSTBC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
- if (HtCapability.ExtHtCapInfo.PlusHTC)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
- if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
- if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-
- NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
- }
-#endif // DOT11_N_SUPPORT //
-
- pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
- pEntry->CurrTxRate = pEntry->MaxSupportedRate;
- CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
- if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
- {
- PUCHAR pTable;
- UCHAR TableSize = 0;
-
- MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
- pEntry->bAutoTxRateSwitch = TRUE;
- }
- else
- {
- pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
- pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
- pEntry->bAutoTxRateSwitch = FALSE;
-
- RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
- }
- pEntry->RateLen = SupportedRatesLen;
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
- }
- else
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
- }
- }
- else
- {
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
- }
- pAd->StaCfg.DLSEntry[i].Sequence = 0;
- if (HtCapabilityLen != 0)
- pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
- else
- pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
- }
- else
- {
- // DLS setup procedure failed.
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
- }
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID MlmeDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_TEARDOWN;
- USHORT ReasonCode = REASON_QOS_UNSPECIFY;
- HEADER_802_11 DlsTearDownHdr;
- PRT_802_11_DLS pDLS;
- BOOLEAN TimerCancelled;
- UCHAR i;
-
- if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &ReasonCode))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsTearDownAction() with ReasonCode=%d \n", ReasonCode));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsTearDownAction() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-
- // Build basic frame first
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsTearDownHdr,
- 1, &Category,
- 1, &Action,
- 6, &pDLS->MacAddr,
- 6, pAd->CurrentAddress,
- 2, &ReasonCode,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
-
- // Remove key in local dls table entry
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // clear peer dls table entry
- for (i = MAX_NUM_OF_INIT_DLS_ENTRY; i < MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerDlsTearDownAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
- USHORT ReasonCode;
- UINT i;
- BOOLEAN TimerCancelled;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return;
-
- if (!INFRA_ON(pAd))
- return;
-
- if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsTearDownAction() from %02x:%02x:%02x:%02x:%02x:%02x with ReasonCode=%d\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], ReasonCode));
-
- // clear local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // clear peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
- //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID RTMPCheckDLSTimeOut(
- IN PRTMP_ADAPTER pAd)
-{
- ULONG i;
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_UNSPECIFY;
-
- if (! pAd->CommonCfg.bDLSCapable)
- return;
-
- if (! INFRA_ON(pAd))
- return;
-
- // If timeout value is equaled to zero, it means always not be timeout.
-
- // update local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer --;
-
- if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- }
- }
-
- // update peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer --;
-
- if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN RTMPRcvFrameDLSCheck(
- IN PRTMP_ADAPTER pAd,
- IN PHEADER_802_11 pHeader,
- IN ULONG Len,
- IN PRT28XX_RXD_STRUC pRxD)
-{
- ULONG i;
- BOOLEAN bFindEntry = FALSE;
- BOOLEAN bSTAKeyFrame = FALSE;
- PEAPOL_PACKET pEap;
- PUCHAR pProto, pAddr = NULL;
- PUCHAR pSTAKey = NULL;
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
- UCHAR Mic[16], OldMic[16];
- UCHAR digest[80];
- UCHAR DlsPTK[80];
- UCHAR temp[64];
- BOOLEAN TimerCancelled;
- CIPHER_KEY PairwiseKey;
-
-
- if (! pAd->CommonCfg.bDLSCapable)
- return bSTAKeyFrame;
-
- if (! INFRA_ON(pAd))
- return bSTAKeyFrame;
-
- if (! (pHeader->FC.SubType & 0x08))
- return bSTAKeyFrame;
-
- if (Len < LENGTH_802_11 + 6 + 2 + 2)
- return bSTAKeyFrame;
-
- pProto = (PUCHAR)pHeader + LENGTH_802_11 + 2 + 6; // QOS Control field , 0xAA 0xAA 0xAA 0x00 0x00 0x00
- pAddr = pHeader->Addr2;
-
- // L2PAD bit on will pad 2 bytes at LLC
- if (pRxD->L2PAD)
- {
- pProto += 2;
- }
-
- if (RTMPEqualMemory(EAPOL, pProto, 2) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
- {
- pEap = (PEAPOL_PACKET) (pProto + 2);
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff Len=%ld, DataLen=%d, KeyMic=%d, Install=%d, KeyAck=%d, Secure=%d, EKD_DL=%d, Error=%d, Request=%d\n", Len,
- (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16),
- pEap->KeyDesc.KeyInfo.KeyMic,
- pEap->KeyDesc.KeyInfo.Install,
- pEap->KeyDesc.KeyInfo.KeyAck,
- pEap->KeyDesc.KeyInfo.Secure,
- pEap->KeyDesc.KeyInfo.EKD_DL,
- pEap->KeyDesc.KeyInfo.Error,
- pEap->KeyDesc.KeyInfo.Request));
-
- if ((Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16)) && pEap->KeyDesc.KeyInfo.KeyMic
- && pEap->KeyDesc.KeyInfo.Install && pEap->KeyDesc.KeyInfo.KeyAck && pEap->KeyDesc.KeyInfo.Secure
- && pEap->KeyDesc.KeyInfo.EKD_DL && !pEap->KeyDesc.KeyInfo.Error && !pEap->KeyDesc.KeyInfo.Request)
- {
- // First validate replay counter, only accept message with larger replay counter
- // Let equal pass, some AP start with all zero replay counter
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
- if ((RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- return bSTAKeyFrame;
-
- //RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter (%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
- pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
- pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
- pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
-
- // put these code segment to get the replay counter
- if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
- return bSTAKeyFrame;
-
- // Check MIC value
- // Save the MIC and replace with zero
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- NdisMoveMemory(OldMic, pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1((PUCHAR) pEap, pEap->Body_Len[1] + 4, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic);
- }
-
- if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in Msg1 of STAKey handshake! \n"));
- return bSTAKeyFrame;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("MIC VALID in Msg1 of STAKey handshake! \n"));
-#if 1
- if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0C)
- && (pEap->KeyDesc.KeyData[4] == 0x43) && (pEap->KeyDesc.KeyData[5] == 0x02))
- {
- pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
- pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%ld, KeyDataLen=%d\n",
- pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
-
- bSTAKeyFrame = TRUE;
- }
-#else
- if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0F)
- && (pEap->KeyDesc.KeyData[4] == 0xAC) && (pEap->KeyDesc.KeyData[5] == 0x02))
- {
- pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
- pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%d, KeyDataLen=%d\n",
- pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
-
- bSTAKeyFrame = TRUE;
- }
-#endif
-
- }
- else if (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE))
- {
- RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter 2(%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
- pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
- pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
- pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
-
- }
- }
-
- // If timeout value is equaled to zero, it means always not be timeout.
- // update local dls table entry
- for (i= 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (bSTAKeyFrame)
- {
- PMAC_TABLE_ENTRY pEntry;
-
- // STAKey frame, add pairwise key table
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-
- PairwiseKey.KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
- NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
-
- PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
-
- pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- // Add Pair-wise key to Asic
-#ifdef RT2870
-//Benson modified for USB interface, avoid in interrupt when write key, 20080724 -->
- {
- RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
- COPY_MAC_ADDR(KeyInfo.MacAddr,pAd->StaCfg.DLSEntry[i].MacAddr);
- KeyInfo.MacTabMatchWCID=pAd->StaCfg.DLSEntry[i].MacTabMatchWCID;
- NdisMoveMemory(&KeyInfo.CipherKey, &PairwiseKey,sizeof(CIPHER_KEY));
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_KEY_TABLE, &KeyInfo, sizeof(RT_ADD_PAIRWISE_KEY_ENTRY));
- }
- {
- PMAC_TABLE_ENTRY pDLSEntry;
- pDLSEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- pDLSEntry->PairwiseKey.CipherAlg=PairwiseKey.CipherAlg;
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_RX_WCID_TABLE, pDLSEntry, sizeof(MAC_TABLE_ENTRY));
- }
-//Benson modified for USB interface, avoid in interrupt when write key, 20080724 <--
-#endif // RT2870 //
- NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n"));
-
- RTMPSendSTAKeyHandShake(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Initiator side)\n"));
- }
- else
- {
- // Data frame, update timeout value
- if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- }
- }
-
- bFindEntry = TRUE;
- }
- }
-
- // update peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- if (bSTAKeyFrame)
- {
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- // STAKey frame, add pairwise key table, and send STAkey Msg-2
- pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
- RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-
- PairwiseKey.KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
- NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
-
- PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
-
- pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
- //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
- // Add Pair-wise key to Asic
-#ifdef RT2870
-//Benson modified for USB interface, avoid in interrupt when write key, 20080724 -->
- {
- RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
- COPY_MAC_ADDR(KeyInfo.MacAddr,pAd->StaCfg.DLSEntry[i].MacAddr);
- KeyInfo.MacTabMatchWCID=pAd->StaCfg.DLSEntry[i].MacTabMatchWCID;
- NdisMoveMemory(&KeyInfo.CipherKey, &PairwiseKey,sizeof(CIPHER_KEY));
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_KEY_TABLE, &KeyInfo, sizeof(RT_ADD_PAIRWISE_KEY_ENTRY));
- }
- {
- PMAC_TABLE_ENTRY pDLSEntry;
- pDLSEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
- pDLSEntry->PairwiseKey.CipherAlg=PairwiseKey.CipherAlg;
- RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_RX_WCID_TABLE, pDLSEntry, sizeof(MAC_TABLE_ENTRY));
- }
-//Benson modified for USB interface, avoid in interrupt when write key, 20080724 <--
-#endif // RT2870 //
- NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Initiator STA MAC Address STAKey)\n"));
-
- // If support WPA or WPA2, start STAKey hand shake,
- // If failed hand shake, just tear down peer DLS
- if (RTMPSendSTAKeyHandShake(pAd, pAddr) != NDIS_STATUS_SUCCESS)
- {
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-
- pAd->StaCfg.DLSEntry[i].Valid = FALSE;
- pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Peer side)\n"));
- }
- }
- else
- {
- // Data frame, update timeout value
- if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- {
- pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
- }
- }
-
- bFindEntry = TRUE;
- }
- }
-
-
- return bSTAKeyFrame;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check if the frame can be sent through DLS direct link interface
-
- Arguments:
- pAd Pointer to adapter
-
- Return Value:
- DLS entry index
-
- Note:
-
- ========================================================================
-*/
-INT RTMPCheckDLSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- INT rval = -1;
- INT i;
-
- if (!pAd->CommonCfg.bDLSCapable)
- return rval;
-
- if (!INFRA_ON(pAd))
- return rval;
-
- do{
- // check local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- rval = i;
- break;
- }
- }
-
- // check peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
- MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- rval = i;
- break;
- }
- }
- } while (FALSE);
-
- return rval;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID RTMPSendDLSTearDownFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- HEADER_802_11 DlsTearDownHdr;
- ULONG FrameLen = 0;
- USHORT Reason = REASON_QOS_QSTA_LEAVING_QBSS;
- UCHAR Category = CATEGORY_DLS;
- UCHAR Action = ACTION_DLS_TEARDOWN;
- UCHAR i = 0;
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame \n"));
-
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_ERROR,("ASSOC - RTMPSendDLSTearDownFrame() allocate memory failed \n"));
- return;
- }
-
- ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &DlsTearDownHdr,
- 1, &Category,
- 1, &Action,
- 6, pDA,
- 6, pAd->CurrentAddress,
- 2, &Reason,
- END_OF_ARGS);
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
-
- // Remove key in local dls table entry
- for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // Remove key in peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
- && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
- {
- MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame and remove key in (i=%d) \n", i));
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-NDIS_STATUS RTMPSendSTAKeyRequest(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- UCHAR Header802_3[14];
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- UCHAR digest[80];
- PUCHAR pOutBuffer = NULL;
- PNDIS_PACKET pNdisPacket;
- UCHAR temp[64];
- UCHAR DlsPTK[80];
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyRequest() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-
- pAd->Sequence ++;
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE andPeer MAC address
-
- // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
-
- // Key descriptor version
- Packet.KeyDesc.KeyInfo.KeyDescVer =
- (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
- Packet.KeyDesc.KeyInfo.Request = 1;
-
- Packet.KeyDesc.KeyDataLen[1] = 12;
-
- // use our own OUI to distinguish proprietary with standard.
- Packet.KeyDesc.KeyData[0] = 0xDD;
- Packet.KeyDesc.KeyData[1] = 0x0A;
- Packet.KeyDesc.KeyData[2] = 0x00;
- Packet.KeyDesc.KeyData[3] = 0x0C;
- Packet.KeyDesc.KeyData[4] = 0x43;
- Packet.KeyDesc.KeyData[5] = 0x03;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Allocate buffer for transmitting message
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return NStatus;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- // calculate MIC
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- NdisZeroMemory(digest, sizeof(digest));
- HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
- }
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(Header802_3), Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
- STASendPacket(pAd, pNdisPacket);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyRequest- Send STAKey request (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
-
- return NStatus;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-NDIS_STATUS RTMPSendSTAKeyHandShake(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA)
-{
- UCHAR Header802_3[14];
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- UCHAR digest[80];
- PUCHAR pOutBuffer = NULL;
- PNDIS_PACKET pNdisPacket;
- UCHAR temp[64];
- UCHAR DlsPTK[80]; // Due to dirver can not get PTK, use proprietary PTK
-
- DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyHandShake() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-
- pAd->Sequence ++;
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE and Peer MAC address
-
- // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
- else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
-
- // Key descriptor version
- Packet.KeyDesc.KeyInfo.KeyDescVer =
- (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
-
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- Packet.KeyDesc.KeyDataLen[1] = 12;
-
- // use our own OUI to distinguish proprietary with standard.
- Packet.KeyDesc.KeyData[0] = 0xDD;
- Packet.KeyDesc.KeyData[1] = 0x0A;
- Packet.KeyDesc.KeyData[2] = 0x00;
- Packet.KeyDesc.KeyData[3] = 0x0C;
- Packet.KeyDesc.KeyData[4] = 0x43;
- Packet.KeyDesc.KeyData[5] = 0x03;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Allocate buffer for transmitting message
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus != NDIS_STATUS_SUCCESS)
- return NStatus;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // use proprietary PTK
- NdisZeroMemory(temp, 64);
- NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
- WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
-
- // calculate MIC
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- NdisZeroMemory(digest, sizeof(digest));
- HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- NdisZeroMemory(Mic, sizeof(Mic));
- hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
- }
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(Header802_3), Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
- STASendPacket(pAd, pNdisPacket);
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
- }
-
- MlmeFreeMemory(pAd, pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyHandShake- Send STAKey Message-2 (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
-
- return NStatus;
-}
-
-VOID DlsTimeoutAction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- MLME_DLS_REQ_STRUCT MlmeDlsReq;
- USHORT reason;
- PRT_802_11_DLS pDLS = (PRT_802_11_DLS)FunctionContext;
- PRTMP_ADAPTER pAd = pDLS->pAd;
-
- DBGPRINT(RT_DEBUG_TRACE, ("DlsTimeout - Tear down DLS links (%02x:%02x:%02x:%02x:%02x:%02x)\n",
- pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5]));
-
- if ((pDLS) && (pDLS->Valid))
- {
- reason = REASON_QOS_REQUEST_TIMEOUT;
- pDLS->Valid = FALSE;
- pDLS->Status = DLS_NONE;
- DlsParmFill(pAd, &MlmeDlsReq, pDLS, reason);
- MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
- RT28XX_MLME_HANDLER(pAd);
- }
-}
-
-/*
-================================================================
-Description : because DLS and CLI share the same WCID table in ASIC.
-Mesh entry also insert to pAd->MacTab.content[]. Such is marked as ValidAsDls = TRUE.
-Also fills the pairwise key.
-Because front MAX_AID_BA entries have direct mapping to BAEntry, which is only used as CLI. So we insert Dls
-from index MAX_AID_BA.
-================================================================
-*/
-MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN UINT DlsEntryIdx)
-{
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableInsertDlsEntry\n"));
- // if FULL, return
- if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
- return NULL;
-
- do
- {
- if((pEntry = DlsEntryTableLookup(pAd, pAddr, TRUE)) != NULL)
- break;
-
- // allocate one MAC entry
- pEntry = MacTableInsertEntry(pAd, pAddr, DlsEntryIdx + MIN_NET_DEVICE_FOR_DLS, TRUE);
- if (pEntry)
- {
- pAd->StaCfg.DLSEntry[DlsEntryIdx].MacTabMatchWCID = pEntry->Aid;
- pEntry->MatchDlsEntryIdx = DlsEntryIdx;
- pEntry->AuthMode = pAd->StaCfg.AuthMode;
- pEntry->WepStatus = pAd->StaCfg.WepStatus;
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertDlsEntry - allocate entry #%d, Total= %d\n",pEntry->Aid, pAd->MacTab.Size));
-
- // If legacy WEP is used, set pair-wise cipherAlg into WCID attribute table for this entry
- if ((pEntry->ValidAsDls) && (pEntry->WepStatus == Ndis802_11WEPEnabled))
- {
- UCHAR KeyIdx = 0;
- UCHAR CipherAlg = 0;
-
- KeyIdx = pAd->StaCfg.DefaultKeyId;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
-
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pEntry);
- }
-
- break;
- }
- } while(FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableInsertDlsEntry\n"));
-
- return pEntry;
-}
-
-
-/*
- ==========================================================================
- Description:
- Delete all Mesh Entry in pAd->MacTab
- ==========================================================================
- */
-BOOLEAN MacTableDeleteDlsEntry(
- IN PRTMP_ADAPTER pAd,
- IN USHORT wcid,
- IN PUCHAR pAddr)
-{
- DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableDeleteDlsEntry\n"));
-
- if (!VALID_WCID(wcid))
- return FALSE;
-
- MacTableDeleteEntry(pAd, wcid, pAddr);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableDeleteDlsEntry\n"));
-
- return TRUE;
-}
-
-MAC_TABLE_ENTRY *DlsEntryTableLookup(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount)
-{
- ULONG HashIdx;
- MAC_TABLE_ENTRY *pEntry = NULL;
-
- RTMP_SEM_LOCK(&pAd->MacTabLock);
- HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
- pEntry = pAd->MacTab.Hash[HashIdx];
-
- while (pEntry)
- {
- if ((pEntry->ValidAsDls == TRUE)
- && MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
- {
- if(bResetIdelCount)
- pEntry->NoDataIdleCount = 0;
- break;
- }
- else
- pEntry = pEntry->pNext;
- }
-
- RTMP_SEM_UNLOCK(&pAd->MacTabLock);
- return pEntry;
-}
-
-MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR wcid,
- IN PUCHAR pAddr,
- IN BOOLEAN bResetIdelCount)
-{
- ULONG DLsIndex;
- PMAC_TABLE_ENTRY pCurEntry = NULL;
- PMAC_TABLE_ENTRY pEntry = NULL;
-
- if (!VALID_WCID(wcid))
- return NULL;
-
- RTMP_SEM_LOCK(&pAd->MacTabLock);
-
- do
- {
- pCurEntry = &pAd->MacTab.Content[wcid];
-
- DLsIndex = 0xff;
- if ((pCurEntry) && (pCurEntry->ValidAsDls== TRUE))
- {
- DLsIndex = pCurEntry->MatchDlsEntryIdx;
- }
-
- if (DLsIndex == 0xff)
- break;
-
- if (MAC_ADDR_EQUAL(pCurEntry->Addr, pAddr))
- {
- if(bResetIdelCount)
- pCurEntry->NoDataIdleCount = 0;
- pEntry = pCurEntry;
- break;
- }
- } while(FALSE);
-
- RTMP_SEM_UNLOCK(&pAd->MacTabLock);
-
- return pEntry;
-}
-
-INT Set_DlsEntryInfo_Display_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- INT i;
-
- printk("\n%-19s%-8s\n", "MAC", "TIMEOUT\n");
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- printk("%02x:%02x:%02x:%02x:%02x:%02x ",
- pAd->StaCfg.DLSEntry[i].MacAddr[0], pAd->StaCfg.DLSEntry[i].MacAddr[1], pAd->StaCfg.DLSEntry[i].MacAddr[2],
- pAd->StaCfg.DLSEntry[i].MacAddr[3], pAd->StaCfg.DLSEntry[i].MacAddr[4], pAd->StaCfg.DLSEntry[i].MacAddr[5]);
- printk("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut);
- }
- }
-
- return TRUE;
-}
-
-INT Set_DlsAddEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR mac[MAC_ADDR_LEN];
- USHORT Timeout;
- char *token, sepValue[] = ":", DASH = '-';
- INT i;
- RT_802_11_DLS Dls;
-
- if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and timeout value in decimal format.
- return FALSE;
-
- token = strchr(arg, DASH);
- if ((token != NULL) && (strlen(token)>1))
- {
- Timeout = simple_strtol((token+1), 0, 10);
-
- *token = '\0';
- for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
- {
- if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
- return FALSE;
- AtoH(token, (PUCHAR)(&mac[i]), 1);
- }
- if(i != 6)
- return FALSE;
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%d", mac[0], mac[1],
- mac[2], mac[3], mac[4], mac[5], (int)Timeout);
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- Dls.TimeOut = Timeout;
- COPY_MAC_ADDR(Dls.MacAddr, mac);
- Dls.Valid = 1;
-
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-INT Set_DlsTearDownEntry_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- UCHAR macAddr[MAC_ADDR_LEN];
- CHAR *value;
- INT i;
- RT_802_11_DLS Dls;
-
- if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
- return FALSE;
-
- for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":"))
- {
- if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
- return FALSE; //Invalid
-
- AtoH(value, &macAddr[i++], 2);
- }
-
- printk("\n%02x:%02x:%02x:%02x:%02x:%02x", macAddr[0], macAddr[1],
- macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- COPY_MAC_ADDR(Dls.MacAddr, macAddr);
- Dls.Valid = 0;
-
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
-
- return TRUE;
-}
-
diff --git a/drivers/staging/rt3070/sta/rtmp_data.c b/drivers/staging/rt3070/sta/rtmp_data.c
index b0f259b35c74..bf091206f5cc 100644
--- a/drivers/staging/rt3070/sta/rtmp_data.c
+++ b/drivers/staging/rt3070/sta/rtmp_data.c
@@ -1,2637 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- rtmp_data.c
-
- Abstract:
- Data path subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Aug/17/04 major modification for RT2561/2661
- Jan Lee Mar/17/06 major modification for RT2860 New Ring Design
-*/
-#include "../rt_config.h"
-
-
-
-VOID STARxEAPOLFrameIndicate(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- UCHAR *pTmpBuf;
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- // All EAPoL frames have to pass to upper layer (ex. WPA_SUPPLICANT daemon)
- // TBD : process fragmented EAPol frames
- {
- // In 802.1x mode, if the received frame is EAP-SUCCESS packet, turn on the PortSecured variable
- if ( pAd->StaCfg.IEEE8021X == TRUE &&
- (EAP_CODE_SUCCESS == WpaCheckEapCode(pAd, pRxBlk->pData, pRxBlk->DataSize, LENGTH_802_1_H)))
- {
- PUCHAR Key;
- UCHAR CipherAlg;
- int idx = 0;
-
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("Receive EAP-SUCCESS Packet\n"));
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- if (pAd->StaCfg.IEEE8021x_required_keys == FALSE)
- {
- idx = pAd->StaCfg.DesireSharedKeyId;
- CipherAlg = pAd->StaCfg.DesireSharedKey[idx].CipherAlg;
- Key = pAd->StaCfg.DesireSharedKey[idx].Key;
-
- if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
- {
-#ifdef RT2870
- union
- {
- char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1];
- NDIS_802_11_WEP keyinfo;
- } WepKey;
- int len;
-
-
- NdisZeroMemory(&WepKey, sizeof(WepKey));
- len =pAd->StaCfg.DesireSharedKey[idx].KeyLen;
-
- NdisMoveMemory(WepKey.keyinfo.KeyMaterial,
- pAd->StaCfg.DesireSharedKey[idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].KeyLen);
-
- WepKey.keyinfo.KeyIndex = 0x80000000 + idx;
- WepKey.keyinfo.KeyLength = len;
- pAd->SharedKey[BSS0][idx].KeyLen =(UCHAR) (len <= 5 ? 5 : 13);
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- pAd->ExtraInfo = GENERAL_LINK_UP;
- // need to enqueue cmd to thread
- RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1);
-#endif // RT2870 //
- // For Preventing ShardKey Table is cleared by remove key procedure.
- pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg;
- pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen;
- NdisMoveMemory(pAd->SharedKey[BSS0][idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].Key,
- pAd->StaCfg.DesireSharedKey[idx].KeyLen);
- }
- }
- }
-
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- // Special DATA frame that has to pass to MLME
- // 1. Cisco Aironet frames for CCX2. We need pass it to MLME for special process
- // 2. EAPOL handshaking frames when driver supplicant enabled, pass to MLME for special process
- {
- pTmpBuf = pRxBlk->pData - LENGTH_802_11;
- NdisMoveMemory(pTmpBuf, pRxBlk->pHeader, LENGTH_802_11);
- REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pTmpBuf, pRxBlk->DataSize + LENGTH_802_11, pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! report EAPOL/AIRONET DATA to MLME (len=%d) !!!\n", pRxBlk->DataSize));
- }
- }
-
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
-
-}
-
-VOID STARxDataFrameAnnounce(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk,
- IN UCHAR FromWhichBSSID)
-{
-
- // non-EAP frame
- if (!RTMPCheckWPAframe(pAd, pEntry, pRxBlk->pData, pRxBlk->DataSize, FromWhichBSSID))
- {
-
- {
- // drop all non-EAP DATA frame before
- // this client's Port-Access-Control is secured
- if (pRxBlk->pHeader->FC.Wep)
- {
- // unsupported cipher suite
- if (pAd->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- else
- {
- // encryption in-use but receive a non-EAPOL clear text frame, drop it
- if ((pAd->StaCfg.WepStatus != Ndis802_11EncryptionDisabled) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- }
- RX_BLK_CLEAR_FLAG(pRxBlk, fRX_EAP);
- if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_ARALINK))
- {
- // Normal legacy, AMPDU or AMSDU
- CmmRxnonRalinkFrameIndicate(pAd, pRxBlk, FromWhichBSSID);
-
- }
- else
- {
- // ARALINK
- CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- }
-#ifdef QOS_DLS_SUPPORT
- RX_BLK_CLEAR_FLAG(pRxBlk, fRX_DLS);
-#endif // QOS_DLS_SUPPORT //
- }
- else
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_EAP);
-#ifdef DOT11_N_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
- {
- Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // Determin the destination of the EAP frame
- // to WPA state machine or upper layer
- STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
- }
- }
-}
-
-
-// For TKIP frame, calculate the MIC value
-BOOLEAN STACheckTkipMICValue(
- IN PRTMP_ADAPTER pAd,
- IN MAC_TABLE_ENTRY *pEntry,
- IN RX_BLK *pRxBlk)
-{
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- UCHAR *pData = pRxBlk->pData;
- USHORT DataSize = pRxBlk->DataSize;
- UCHAR UserPriority = pRxBlk->UserPriority;
- PCIPHER_KEY pWpaKey;
- UCHAR *pDA, *pSA;
-
- pWpaKey = &pAd->SharedKey[BSS0][pRxBlk->pRxWI->KeyIndex];
-
- pDA = pHeader->Addr1;
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_INFRA))
- {
- pSA = pHeader->Addr3;
- }
- else
- {
- pSA = pHeader->Addr2;
- }
-
- if (RTMPTkipCompareMICValue(pAd,
- pData,
- pDA,
- pSA,
- pWpaKey->RxMic,
- UserPriority,
- DataSize) == FALSE)
- {
- DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error 2\n"));
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.WpaSupplicantUP)
- {
- WpaSendMicFailureToWpaSupplicant(pAd, (pWpaKey->Type == PAIRWISEKEY) ? TRUE : FALSE);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- RTMPReportMicError(pAd, pWpaKey);
- }
-
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-//
-// All Rx routines use RX_BLK structure to hande rx events
-// It is very important to build pRxBlk attributes
-// 1. pHeader pointer to 802.11 Header
-// 2. pData pointer to payload including LLC (just skip Header)
-// 3. set payload size including LLC to DataSize
-// 4. set some flags with RX_BLK_SET_FLAG()
-//
-VOID STAHandleRxDataFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
- BOOLEAN bFragment = FALSE;
- MAC_TABLE_ENTRY *pEntry = NULL;
- UCHAR FromWhichBSSID = BSS0;
- UCHAR UserPriority = 0;
-
- {
- // before LINK UP, all DATA frames are rejected
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
-#ifdef QOS_DLS_SUPPORT
- //if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
- if (RTMPRcvFrameDLSCheck(pAd, pHeader, pRxWI->MPDUtotalByteCount, pRxD))
- {
- return;
- }
-#endif // QOS_DLS_SUPPORT //
-
- // Drop not my BSS frames
- if (pRxD->MyBss == 0)
- {
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
-
- pAd->RalinkCounters.RxCountSinceLastNULL++;
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable && (pHeader->FC.SubType & 0x08))
- {
- UCHAR *pData;
- DBGPRINT(RT_DEBUG_TRACE,("bAPSDCapable\n"));
-
- // Qos bit 4
- pData = (PUCHAR)pHeader + LENGTH_802_11;
- if ((*pData >> 4) & 0x01)
- {
- DBGPRINT(RT_DEBUG_TRACE,("RxDone- Rcv EOSP frame, driver may fall into sleep\n"));
- pAd->CommonCfg.bInServicePeriod = FALSE;
-
- // Force driver to fall into sleep mode when rcv EOSP frame
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- USHORT TbttNumToNextWakeUp;
- USHORT NextDtim = pAd->StaCfg.DtimPeriod;
- ULONG Now;
-
- NdisGetSystemUpTime(&Now);
- NextDtim -= (USHORT)(Now - pAd->StaCfg.LastBeaconRxTime)/pAd->CommonCfg.BeaconPeriod;
-
- TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
- TbttNumToNextWakeUp = NextDtim;
-
- MlmeSetPsmBit(pAd, PWR_SAVE);
- // if WMM-APSD is failed, try to disable following line
- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
- }
- }
-
- if ((pHeader->FC.MoreData) && (pAd->CommonCfg.bInServicePeriod))
- {
- DBGPRINT(RT_DEBUG_TRACE,("Sending another trigger frame when More Data bit is set to 1\n"));
- }
- }
-
- // Drop NULL, CF-ACK(no data), CF-POLL(no data), and CF-ACK+CF-POLL(no data) data frame
- if ((pHeader->FC.SubType & 0x04)) // bit 2 : no DATA
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // Drop not my BSS frame (we can not only check the MyBss bit in RxD)
-#ifdef QOS_DLS_SUPPORT
- if (!pAd->CommonCfg.bDLSCapable)
- {
-#endif // QOS_DLS_SUPPORT //
- if (INFRA_ON(pAd))
- {
- // Infrastructure mode, check address 2 for BSSID
- if (!RTMPEqualMemory(&pHeader->Addr2, &pAd->CommonCfg.Bssid, 6))
- {
- // Receive frame not my BSSID
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
- else // Ad-Hoc mode or Not associated
- {
- // Ad-Hoc mode, check address 3 for BSSID
- if (!RTMPEqualMemory(&pHeader->Addr3, &pAd->CommonCfg.Bssid, 6))
- {
- // Receive frame not my BSSID
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
- }
-#ifdef QOS_DLS_SUPPORT
- }
-#endif // QOS_DLS_SUPPORT //
-
- //
- // find pEntry
- //
- if (pRxWI->WirelessCliID < MAX_LEN_OF_MAC_TABLE)
- {
- pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
- }
- else
- {
- // 1. release packet if infra mode
- // 2. new a pEntry if ad-hoc mode
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // infra or ad-hoc
- if (INFRA_ON(pAd))
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA);
-#ifdef QOS_DLS_SUPPORT
- if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
- RX_BLK_SET_FLAG(pRxBlk, fRX_DLS);
- else
-#endif // QOS_DLS_SUPPORT //
- ASSERT(pRxWI->WirelessCliID == BSSID_WCID);
- }
-
- // check Atheros Client
- if ((pEntry->bIAmBadAtheros == FALSE) && (pRxD->AMPDU == 1) && (pHeader->FC.Retry ))
- {
- pEntry->bIAmBadAtheros = TRUE;
- pAd->CommonCfg.IOTestParm.bCurrentAtheros = TRUE;
- pAd->CommonCfg.IOTestParm.bLastAtheros = TRUE;
- if (!STA_AES_ON(pAd))
- {
- AsicUpdateProtect(pAd, 8, ALLN_SETPROTECT, TRUE, FALSE);
- }
- }
- }
-
- pRxBlk->pData = (UCHAR *)pHeader;
-
- //
- // update RxBlk->pData, DataSize
- // 802.11 Header, QOS, HTC, Hw Padding
- //
-
- // 1. skip 802.11 HEADER
- {
- pRxBlk->pData += LENGTH_802_11;
- pRxBlk->DataSize -= LENGTH_802_11;
- }
-
- // 2. QOS
- if (pHeader->FC.SubType & 0x08)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_QOS);
- UserPriority = *(pRxBlk->pData) & 0x0f;
- // bit 7 in QoS Control field signals the HT A-MSDU format
- if ((*pRxBlk->pData) & 0x80)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_AMSDU);
- }
-
- // skip QOS contorl field
- pRxBlk->pData += 2;
- pRxBlk->DataSize -=2;
- }
- pRxBlk->UserPriority = UserPriority;
-
- // 3. Order bit: A-Ralink or HTC+
- if (pHeader->FC.Order)
- {
-#ifdef AGGREGATION_SUPPORT
- if ((pRxWI->PHYMODE <= MODE_OFDM) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)))
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_ARALINK);
- }
- else
-#endif
- {
-#ifdef DOT11_N_SUPPORT
- RX_BLK_SET_FLAG(pRxBlk, fRX_HTC);
- // skip HTC contorl field
- pRxBlk->pData += 4;
- pRxBlk->DataSize -= 4;
-#endif // DOT11_N_SUPPORT //
- }
- }
-
- // 4. skip HW padding
- if (pRxD->L2PAD)
- {
- // just move pData pointer
- // because DataSize excluding HW padding
- RX_BLK_SET_FLAG(pRxBlk, fRX_PAD);
- pRxBlk->pData += 2;
- }
-
-#ifdef DOT11_N_SUPPORT
- if (pRxD->BA)
- {
- RX_BLK_SET_FLAG(pRxBlk, fRX_AMPDU);
- }
-#endif // DOT11_N_SUPPORT //
-
-
- //
- // Case I Process Broadcast & Multicast data frame
- //
- if (pRxD->Bcast || pRxD->Mcast)
- {
- INC_COUNTER64(pAd->WlanCounters.MulticastReceivedFrameCount);
-
- // Drop Mcast/Bcast frame with fragment bit on
- if (pHeader->FC.MoreFrag)
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- // Filter out Bcast frame which AP relayed for us
- if (pHeader->FC.FrDs && MAC_ADDR_EQUAL(pHeader->Addr3, pAd->CurrentAddress))
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
- return;
- }
- else if (pRxD->U2M)
- {
- pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
-
-
-#ifdef QOS_DLS_SUPPORT
- if (RX_BLK_TEST_FLAG(pRxBlk, fRX_DLS))
- {
- MAC_TABLE_ENTRY *pDlsEntry = NULL;
-
- pDlsEntry = DlsEntryTableLookupByWcid(pAd, pRxWI->WirelessCliID, pHeader->Addr2, TRUE);
- if(pDlsEntry)
- Update_Rssi_Sample(pAd, &pDlsEntry->RssiSample, pRxWI);
- }
- else
-#endif // QOS_DLS_SUPPORT //
- if (ADHOC_ON(pAd))
- {
- pEntry = MacTableLookup(pAd, pHeader->Addr2);
- if (pEntry)
- Update_Rssi_Sample(pAd, &pEntry->RssiSample, pRxWI);
- }
-
-
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
- pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
- pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
-
- pAd->RalinkCounters.OneSecRxOkDataCnt++;
-
-
- if (!((pHeader->Frag == 0) && (pHeader->FC.MoreFrag == 0)))
- {
- // re-assemble the fragmented packets
- // return complete frame (pRxPacket) or NULL
- bFragment = TRUE;
- pRxPacket = RTMPDeFragmentDataFrame(pAd, pRxBlk);
- }
-
- if (pRxPacket)
- {
- pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
-
- // process complete frame
- if (bFragment && (pRxD->Decrypted) && (pEntry->WepStatus == Ndis802_11Encryption2Enabled))
- {
- // Minus MIC length
- pRxBlk->DataSize -= 8;
-
- // For TKIP frame, calculate the MIC value
- if (STACheckTkipMICValue(pAd, pEntry, pRxBlk) == FALSE)
- {
- return;
- }
- }
-
- STARxDataFrameAnnounce(pAd, pEntry, pRxBlk, FromWhichBSSID);
- return;
- }
- else
- {
- // just return
- // because RTMPDeFragmentDataFrame() will release rx packet,
- // if packet is fragmented
- return;
- }
- }
-
- ASSERT(0);
- // release packet
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-VOID STAHandleRxMgmtFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
- PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
-
- do
- {
-
- // We should collect RSSI not only U2M data but also my beacon
- if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))
- && (pAd->RxAnt.EvaluatePeriod == 0))
- {
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
- pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
- pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
- }
-
-#ifdef RT30xx
- // collect rssi information for antenna diversity
- if (pAd->NicConfig2.field.AntDiversity)
- {
- if ((pRxD->U2M) || ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))))
- {
- COLLECT_RX_ANTENNA_AVERAGE_RSSI(pAd, ConvertToRssi(pAd, (UCHAR)pRxWI->RSSI0, RSSI_0), 0); //Note: RSSI2 not used on RT73
- pAd->StaCfg.NumOfAvgRssiSample ++;
- }
- }
-#endif // RT30xx //
-
- // First check the size, it MUST not exceed the mlme queue size
- if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE)
- {
- DBGPRINT_ERR(("STAHandleRxMgmtFrame: frame too large, size = %d \n", pRxWI->MPDUtotalByteCount));
- break;
- }
-
- REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pHeader, pRxWI->MPDUtotalByteCount,
- pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
- } while (FALSE);
-
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
-}
-
-VOID STAHandleRxControlFrame(
- IN PRTMP_ADAPTER pAd,
- IN RX_BLK *pRxBlk)
-{
-#ifdef DOT11_N_SUPPORT
- PRXWI_STRUC pRxWI = pRxBlk->pRxWI;
-#endif // DOT11_N_SUPPORT //
- PHEADER_802_11 pHeader = pRxBlk->pHeader;
- PNDIS_PACKET pRxPacket = pRxBlk->pRxPacket;
-
- switch (pHeader->FC.SubType)
- {
- case SUBTYPE_BLOCK_ACK_REQ:
-#ifdef DOT11_N_SUPPORT
- {
- CntlEnqueueForRecv(pAd, pRxWI->WirelessCliID, (pRxWI->MPDUtotalByteCount), (PFRAME_BA_REQ)pHeader);
- }
- break;
-#endif // DOT11_N_SUPPORT //
- case SUBTYPE_BLOCK_ACK:
- case SUBTYPE_ACK:
- default:
- break;
- }
-
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Process RxDone interrupt, running in DPC level
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- This routine has to maintain Rx ring read pointer.
- Need to consider QOS DATA format when converting to 802.3
- ========================================================================
-*/
-BOOLEAN STARxDoneInterruptHandle(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN argc)
-{
- NDIS_STATUS Status;
- UINT32 RxProcessed, RxPending;
- BOOLEAN bReschedule = FALSE;
- RT28XX_RXD_STRUC *pRxD;
- UCHAR *pData;
- PRXWI_STRUC pRxWI;
- PNDIS_PACKET pRxPacket;
- PHEADER_802_11 pHeader;
- RX_BLK RxCell;
-
- RxProcessed = RxPending = 0;
-
- // process whole rx ring
- while (1)
- {
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF |
- fRTMP_ADAPTER_RESET_IN_PROGRESS |
- fRTMP_ADAPTER_HALT_IN_PROGRESS |
- fRTMP_ADAPTER_NIC_NOT_EXIST) ||
- !RTMP_TEST_FLAG(pAd,fRTMP_ADAPTER_START_UP))
- {
- break;
- }
-
-
- RxProcessed ++; // test
-
- // 1. allocate a new data packet into rx ring to replace received packet
- // then processing the received packet
- // 2. the callee must take charge of release of packet
- // 3. As far as driver is concerned ,
- // the rx packet must
- // a. be indicated to upper layer or
- // b. be released if it is discarded
- pRxPacket = GetPacketFromRxRing(pAd, &(RxCell.RxD), &bReschedule, &RxPending);
- if (pRxPacket == NULL)
- {
- // no more packet to process
- break;
- }
-
- // get rx ring descriptor
- pRxD = &(RxCell.RxD);
- // get rx data buffer
- pData = GET_OS_PKT_DATAPTR(pRxPacket);
- pRxWI = (PRXWI_STRUC) pData;
- pHeader = (PHEADER_802_11) (pData+RXWI_SIZE) ;
-
-#ifdef RT_BIG_ENDIAN
- RTMPFrameEndianChange(pAd, (PUCHAR)pHeader, DIR_READ, TRUE);
- RTMPWIEndianChange((PUCHAR)pRxWI, TYPE_RXWI);
-#endif
-
- // build RxCell
- RxCell.pRxWI = pRxWI;
- RxCell.pHeader = pHeader;
- RxCell.pRxPacket = pRxPacket;
- RxCell.pData = (UCHAR *) pHeader;
- RxCell.DataSize = pRxWI->MPDUtotalByteCount;
- RxCell.Flags = 0;
-
- // Increase Total receive byte counter after real data received no mater any error or not
- pAd->RalinkCounters.ReceivedByteCount += pRxWI->MPDUtotalByteCount;
- pAd->RalinkCounters.RxCount ++;
-
- INC_COUNTER64(pAd->WlanCounters.ReceivedFragmentCount);
-
- if (pRxWI->MPDUtotalByteCount < 14)
- Status = NDIS_STATUS_FAILURE;
-
- if (MONITOR_ON(pAd))
- {
- send_monitor_packets(pAd, &RxCell);
- break;
- }
- /* RT2870 invokes STARxDoneInterruptHandle() in rtusb_bulk.c */
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- pAd->ate.RxCntPerSec++;
- ATESampleRssi(pAd, pRxWI);
-#ifdef RALINK_28xx_QA
- if (pAd->ate.bQARxStart == TRUE)
- {
- /* (*pRxD) has been swapped in GetPacketFromRxRing() */
- ATE_QA_Statistics(pAd, pRxWI, pRxD, pHeader);
- }
-#endif // RALINK_28xx_QA //
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
- continue;
- }
-#endif // RALINK_ATE //
-
- // Check for all RxD errors
- Status = RTMPCheckRxError(pAd, pHeader, pRxWI, pRxD);
-
- // Handle the received frame
- if (Status == NDIS_STATUS_SUCCESS)
- {
- switch (pHeader->FC.Type)
- {
- // CASE I, receive a DATA frame
- case BTYPE_DATA:
- {
- // process DATA frame
- STAHandleRxDataFrame(pAd, &RxCell);
- }
- break;
- // CASE II, receive a MGMT frame
- case BTYPE_MGMT:
- {
- STAHandleRxMgmtFrame(pAd, &RxCell);
- }
- break;
- // CASE III. receive a CNTL frame
- case BTYPE_CNTL:
- {
- STAHandleRxControlFrame(pAd, &RxCell);
- }
- break;
- // discard other type
- default:
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- break;
- }
- }
- else
- {
- pAd->Counters8023.RxErrors++;
- // discard this frame
- RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
- }
- }
-
- return bReschedule;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Arguments:
- pAd Pointer to our adapter
-
- IRQL = DISPATCH_LEVEL
-
- ========================================================================
-*/
-VOID RTMPHandleTwakeupInterrupt(
- IN PRTMP_ADAPTER pAd)
-{
- AsicForceWakeup(pAd, FALSE);
-}
-
-/*
-========================================================================
-Routine Description:
- Early checking and OS-depened parsing for Tx packet send to our STA driver.
-
-Arguments:
- NDIS_HANDLE MiniportAdapterContext Pointer refer to the device handle, i.e., the pAd.
- PPNDIS_PACKET ppPacketArray The packet array need to do transmission.
- UINT NumberOfPackets Number of packet in packet array.
-
-Return Value:
- NONE
-
-Note:
- This function do early checking and classification for send-out packet.
- You only can put OS-depened & STA related code in here.
-========================================================================
-*/
-VOID STASendPackets(
- IN NDIS_HANDLE MiniportAdapterContext,
- IN PPNDIS_PACKET ppPacketArray,
- IN UINT NumberOfPackets)
-{
- UINT Index;
- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) MiniportAdapterContext;
- PNDIS_PACKET pPacket;
- BOOLEAN allowToSend = FALSE;
-
-
- for (Index = 0; Index < NumberOfPackets; Index++)
- {
- pPacket = ppPacketArray[Index];
-
- do
- {
-
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
- RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
- {
- // Drop send request since hardware is in reset state
- break;
- }
- else if (!INFRA_ON(pAd) && !ADHOC_ON(pAd))
- {
- // Drop send request since there are no physical connection yet
- break;
- }
- else
- {
- // Record that orignal packet source is from NDIS layer,so that
- // later on driver knows how to release this NDIS PACKET
-#ifdef QOS_DLS_SUPPORT
- MAC_TABLE_ENTRY *pEntry;
- PUCHAR pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-
- pEntry = MacTableLookup(pAd, pSrcBufVA);
- if (pEntry && (pEntry->ValidAsDls == TRUE))
- {
- RTMP_SET_PACKET_WCID(pPacket, pEntry->Aid);
- }
- else
-#endif // QOS_DLS_SUPPORT //
- RTMP_SET_PACKET_WCID(pPacket, 0); // this field is useless when in STA mode
- RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
- NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_PENDING);
- pAd->RalinkCounters.PendingNdisPacketCount++;
-
- allowToSend = TRUE;
- }
- } while(FALSE);
-
- if (allowToSend == TRUE)
- STASendPacket(pAd, pPacket);
- else
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
-
- // Dequeue outgoing frames from TxSwQueue[] and process it
- RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-
-}
-
-
-/*
-========================================================================
-Routine Description:
- This routine is used to do packet parsing and classification for Tx packet
- to STA device, and it will en-queue packets to our TxSwQueue depends on AC
- class.
-
-Arguments:
- pAd Pointer to our adapter
- pPacket Pointer to send packet
-
-Return Value:
- NDIS_STATUS_SUCCESS If succes to queue the packet into TxSwQueue.
- NDIS_STATUS_FAILURE If failed to do en-queue.
-
-Note:
- You only can put OS-indepened & STA related code in here.
-========================================================================
-*/
-NDIS_STATUS STASendPacket(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket)
-{
- PACKET_INFO PacketInfo;
- PUCHAR pSrcBufVA;
- UINT SrcBufLen;
- UINT AllowFragSize;
- UCHAR NumberOfFrag;
-// UCHAR RTSRequired;
- UCHAR QueIdx, UserPriority;
- MAC_TABLE_ENTRY *pEntry = NULL;
- unsigned int IrqFlags;
- UCHAR FlgIsIP = 0;
- UCHAR Rate;
-
- // Prepare packet information structure for buffer descriptor
- // chained within a single NDIS packet.
- RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
- if (pSrcBufVA == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> pSrcBufVA == NULL !!!SrcBufLen=%x\n",SrcBufLen));
- // Resourece is low, system did not allocate virtual address
- // return NDIS_STATUS_FAILURE directly to upper layer
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return NDIS_STATUS_FAILURE;
- }
-
-
- if (SrcBufLen < 14)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> Ndis Packet buffer error !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return (NDIS_STATUS_FAILURE);
- }
-
- // In HT rate adhoc mode, A-MPDU is often used. So need to lookup BA Table and MAC Entry.
- // Note multicast packets in adhoc also use BSSID_WCID index.
- {
- if(INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- USHORT tmpWcid;
-
- tmpWcid = RTMP_GET_PACKET_WCID(pPacket);
- if (VALID_WCID(tmpWcid) &&
- (pAd->MacTab.Content[tmpWcid].ValidAsDls== TRUE))
- {
- pEntry = &pAd->MacTab.Content[tmpWcid];
- Rate = pAd->MacTab.Content[tmpWcid].CurrTxRate;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- {
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID);
- Rate = pAd->CommonCfg.TxRate;
- }
- }
- else if (ADHOC_ON(pAd))
- {
- if (*pSrcBufVA & 0x01)
- {
- RTMP_SET_PACKET_WCID(pPacket, MCAST_WCID);
- pEntry = &pAd->MacTab.Content[MCAST_WCID];
- }
- else
- {
- pEntry = MacTableLookup(pAd, pSrcBufVA);
- }
- Rate = pAd->CommonCfg.TxRate;
- }
- }
-
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_ERROR,("STASendPacket->Cannot find pEntry(%2x:%2x:%2x:%2x:%2x:%2x) in MacTab!\n", PRINT_MAC(pSrcBufVA)));
- // Resourece is low, system did not allocate virtual address
- // return NDIS_STATUS_FAILURE directly to upper layer
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- return NDIS_STATUS_FAILURE;
- }
-
- if (ADHOC_ON(pAd)
- )
- {
- RTMP_SET_PACKET_WCID(pPacket, (UCHAR)pEntry->Aid);
- }
-
- //
- // Check the Ethernet Frame type of this packet, and set the RTMP_SET_PACKET_SPECIFIC flags.
- // Here we set the PACKET_SPECIFIC flags(LLC, VLAN, DHCP/ARP, EAPOL).
- RTMPCheckEtherType(pAd, pPacket);
-
-
-
- //
- // WPA 802.1x secured port control - drop all non-802.1x frame before port secured
- //
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef WPA_SUPPLICANT_SUPPORT
- || (pAd->StaCfg.IEEE8021X == TRUE)
-#endif // WPA_SUPPLICANT_SUPPORT //
-#ifdef LEAP_SUPPORT
- || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //
- )
- && ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAd->StaCfg.MicErrCnt >= 2))
- && (RTMP_GET_PACKET_EAPOL(pPacket)== FALSE)
- )
- {
- DBGPRINT(RT_DEBUG_TRACE,("STASendPacket --> Drop packet before port secured !!!\n"));
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
- return (NDIS_STATUS_FAILURE);
- }
-
-
- // STEP 1. Decide number of fragments required to deliver this MSDU.
- // The estimation here is not very accurate because difficult to
- // take encryption overhead into consideration here. The result
- // "NumberOfFrag" is then just used to pre-check if enough free
- // TXD are available to hold this MSDU.
-
-
- if (*pSrcBufVA & 0x01) // fragmentation not allowed on multicast & broadcast
- NumberOfFrag = 1;
- else if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED))
- NumberOfFrag = 1; // Aggregation overwhelms fragmentation
- else if (CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED))
- NumberOfFrag = 1; // Aggregation overwhelms fragmentation
-#ifdef DOT11_N_SUPPORT
- else if ((pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTMIX) || (pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTGREENFIELD))
- NumberOfFrag = 1; // MIMO RATE overwhelms fragmentation
-#endif // DOT11_N_SUPPORT //
- else
- {
- // The calculated "NumberOfFrag" is a rough estimation because of various
- // encryption/encapsulation overhead not taken into consideration. This number is just
- // used to make sure enough free TXD are available before fragmentation takes place.
- // In case the actual required number of fragments of an NDIS packet
- // excceeds "NumberOfFrag"caculated here and not enough free TXD available, the
- // last fragment (i.e. last MPDU) will be dropped in RTMPHardTransmit() due to out of
- // resource, and the NDIS packet will be indicated NDIS_STATUS_FAILURE. This should
- // rarely happen and the penalty is just like a TX RETRY fail. Affordable.
-
- AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
- NumberOfFrag = ((PacketInfo.TotalPacketLength - LENGTH_802_3 + LENGTH_802_1_H) / AllowFragSize) + 1;
- // To get accurate number of fragmentation, Minus 1 if the size just match to allowable fragment size
- if (((PacketInfo.TotalPacketLength - LENGTH_802_3 + LENGTH_802_1_H) % AllowFragSize) == 0)
- {
- NumberOfFrag--;
- }
- }
-
- // Save fragment number to Ndis packet reserved field
- RTMP_SET_PACKET_FRAGMENTS(pPacket, NumberOfFrag);
-
-
- // STEP 2. Check the requirement of RTS:
- // If multiple fragment required, RTS is required only for the first fragment
- // if the fragment size large than RTS threshold
- // For RT28xx, Let ASIC send RTS/CTS
- RTMP_SET_PACKET_RTS(pPacket, 0);
- RTMP_SET_PACKET_TXRATE(pPacket, pAd->CommonCfg.TxRate);
-
- //
- // STEP 3. Traffic classification. outcome = <UserPriority, QueIdx>
- //
- UserPriority = 0;
- QueIdx = QID_AC_BE;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE))
- {
- USHORT Protocol;
- UCHAR LlcSnapLen = 0, Byte0, Byte1;
- do
- {
- // get Ethernet protocol field
- Protocol = (USHORT)((pSrcBufVA[12] << 8) + pSrcBufVA[13]);
- if (Protocol <= 1500)
- {
- // get Ethernet protocol field from LLC/SNAP
- if (Sniff2BytesFromNdisBuffer(PacketInfo.pFirstBuffer, LENGTH_802_3 + 6, &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
- break;
-
- Protocol = (USHORT)((Byte0 << 8) + Byte1);
- LlcSnapLen = 8;
- }
-
- // always AC_BE for non-IP packet
- if (Protocol != 0x0800)
- break;
-
- // get IP header
- if (Sniff2BytesFromNdisBuffer(PacketInfo.pFirstBuffer, LENGTH_802_3 + LlcSnapLen, &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
- break;
-
- // return AC_BE if packet is not IPv4
- if ((Byte0 & 0xf0) != 0x40)
- break;
-
- FlgIsIP = 1;
- UserPriority = (Byte1 & 0xe0) >> 5;
- QueIdx = MapUserPriorityToAccessCategory[UserPriority];
-
- // TODO: have to check ACM bit. apply TSPEC if ACM is ON
- // TODO: downgrade UP & QueIdx before passing ACM
- if (pAd->CommonCfg.APEdcaParm.bACM[QueIdx])
- {
- UserPriority = 0;
- QueIdx = QID_AC_BE;
- }
- } while (FALSE);
- }
-
- RTMP_SET_PACKET_UP(pPacket, UserPriority);
-
-
-
- // Make sure SendTxWait queue resource won't be used by other threads
- RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
- if (pAd->TxSwQueue[QueIdx].Number >= MAX_PACKETS_IN_QUEUE)
- {
- RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-#ifdef BLOCK_NET_IF
- StopNetIfQueue(pAd, QueIdx, pPacket);
-#endif // BLOCK_NET_IF //
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
- return NDIS_STATUS_FAILURE;
- }
- else
- {
- InsertTailQueue(&pAd->TxSwQueue[QueIdx], PACKET_TO_QUEUE_ENTRY(pPacket));
- }
- RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&&
- IS_HT_STA(pEntry))
- {
- //PMAC_TABLE_ENTRY pMacEntry = &pAd->MacTab.Content[BSSID_WCID];
- if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) &&
- ((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) &&
- (pEntry->PortSecured == WPA_802_1X_PORT_SECURED)
- // For IOT compatibility, if
- // 1. It is Ralink chip or
- // 2. It is OPEN or AES mode,
- // then BA session can be bulit.
- && ((pEntry->ValidAsCLI && pAd->MlmeAux.APRalinkIe != 0x0) ||
- (pEntry->WepStatus == Ndis802_11WEPDisabled || pEntry->WepStatus == Ndis802_11Encryption3Enabled))
- )
- {
- BAOriSessionSetUp(pAd, pEntry, 0, 0, 10, FALSE);
- }
- }
-#endif // DOT11_N_SUPPORT //
-
- pAd->RalinkCounters.OneSecOsTxCount[QueIdx]++; // TODO: for debug only. to be removed
- return NDIS_STATUS_SUCCESS;
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- This subroutine will scan through releative ring descriptor to find
- out avaliable free ring descriptor and compare with request size.
-
- Arguments:
- pAd Pointer to our adapter
- QueIdx Selected TX Ring
-
- Return Value:
- NDIS_STATUS_FAILURE Not enough free descriptor
- NDIS_STATUS_SUCCESS Enough free descriptor
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-
-#ifdef RT2870
-/*
- Actually, this function used to check if the TxHardware Queue still has frame need to send.
- If no frame need to send, go to sleep, else, still wake up.
-*/
-NDIS_STATUS RTMPFreeTXDRequest(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR QueIdx,
- IN UCHAR NumberRequired,
- IN PUCHAR FreeNumberIs)
-{
- //ULONG FreeNumber = 0;
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- unsigned long IrqFlags;
- HT_TX_CONTEXT *pHTTXContext;
-
- switch (QueIdx)
- {
- case QID_AC_BK:
- case QID_AC_BE:
- case QID_AC_VI:
- case QID_AC_VO:
- case QID_HCCA:
- {
- pHTTXContext = &pAd->TxContext[QueIdx];
- RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
- if ((pHTTXContext->CurWritePosition != pHTTXContext->ENextBulkOutPosition) ||
- (pHTTXContext->IRPPending == TRUE))
- {
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
- Status = NDIS_STATUS_SUCCESS;
- }
- RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
- }
- break;
-
- case QID_MGMT:
- if (pAd->MgmtRing.TxSwFreeIdx != MGMT_RING_SIZE)
- Status = NDIS_STATUS_FAILURE;
- else
- Status = NDIS_STATUS_SUCCESS;
- break;
-
- default:
- DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
- break;
- }
-
- return (Status);
-
-}
-#endif // RT2870 //
-
-
-VOID RTMPSendDisassociationFrame(
- IN PRTMP_ADAPTER pAd)
-{
-}
-
-VOID RTMPSendNullFrame(
- IN PRTMP_ADAPTER pAd,
- IN UCHAR TxRate,
- IN BOOLEAN bQosNull)
-{
- UCHAR NullFrame[48];
- ULONG Length;
- PHEADER_802_11 pHeader_802_11;
-
-
-#ifdef RALINK_ATE
- if(ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- // WPA 802.1x secured port control
- if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-#ifdef WPA_SUPPLICANT_SUPPORT
- || (pAd->StaCfg.IEEE8021X == TRUE)
-#endif
- ) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- return;
- }
-
- NdisZeroMemory(NullFrame, 48);
- Length = sizeof(HEADER_802_11);
-
- pHeader_802_11 = (PHEADER_802_11) NullFrame;
-
- pHeader_802_11->FC.Type = BTYPE_DATA;
- pHeader_802_11->FC.SubType = SUBTYPE_NULL_FUNC;
- pHeader_802_11->FC.ToDs = 1;
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
-
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- {
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- }
- else
- {
- pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE) ? 1: 0;
- }
- pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + RTMPCalcDuration(pAd, TxRate, 14);
-
- pAd->Sequence++;
- pHeader_802_11->Sequence = pAd->Sequence;
-
- // Prepare QosNull function frame
- if (bQosNull)
- {
- pHeader_802_11->FC.SubType = SUBTYPE_QOS_NULL;
-
- // copy QOS control bytes
- NullFrame[Length] = 0;
- NullFrame[Length+1] = 0;
- Length += 2;// if pad with 2 bytes for alignment, APSD will fail
- }
-
- HAL_KickOutNullFrameTx(pAd, 0, NullFrame, Length);
-
-}
-
-// IRQL = DISPATCH_LEVEL
-VOID RTMPSendRTSFrame(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
- IN unsigned int NextMpduSize,
- IN UCHAR TxRate,
- IN UCHAR RTSRate,
- IN USHORT AckDuration,
- IN UCHAR QueIdx,
- IN UCHAR FrameGap)
-{
-}
-
-
-
-// --------------------------------------------------------
-// FIND ENCRYPT KEY AND DECIDE CIPHER ALGORITHM
-// Find the WPA key, either Group or Pairwise Key
-// LEAP + TKIP also use WPA key.
-// --------------------------------------------------------
-// Decide WEP bit and cipher suite to be used. Same cipher suite should be used for whole fragment burst
-// In Cisco CCX 2.0 Leap Authentication
-// WepStatus is Ndis802_11Encryption1Enabled but the key will use PairwiseKey
-// Instead of the SharedKey, SharedKey Length may be Zero.
-VOID STAFindCipherAlgorithm(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- NDIS_802_11_ENCRYPTION_STATUS Cipher; // To indicate cipher used for this packet
- UCHAR CipherAlg = CIPHER_NONE; // cipher alogrithm
- UCHAR KeyIdx = 0xff;
- PUCHAR pSrcBufVA;
- PCIPHER_KEY pKey = NULL;
-
- pSrcBufVA = GET_OS_PKT_DATAPTR(pTxBlk->pPacket);
-
- {
- // Select Cipher
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
- Cipher = pAd->StaCfg.GroupCipher; // Cipher for Multicast or Broadcast
- else
- Cipher = pAd->StaCfg.PairCipher; // Cipher for Unicast
-
- if (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
- {
- ASSERT(pAd->SharedKey[BSS0][0].CipherAlg <= CIPHER_CKIP128);
-
- // 4-way handshaking frame must be clear
- if (!(TX_BLK_TEST_FLAG(pTxBlk, fTX_bClearEAPFrame)) && (pAd->SharedKey[BSS0][0].CipherAlg) &&
- (pAd->SharedKey[BSS0][0].KeyLen))
- {
- CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
- KeyIdx = 0;
- }
- }
- else if (Cipher == Ndis802_11Encryption1Enabled)
- {
-#ifdef LEAP_SUPPORT
- if (pAd->StaCfg.CkipFlag & 0x10) // Cisco CKIP KP is on
- {
- if (LEAP_CCKM_ON(pAd))
- {
- if (((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))))
- KeyIdx = 1;
- else
- KeyIdx = 0;
- }
- else
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
- else if (pAd->StaCfg.CkipFlag & 0x08) // only CKIP CMIC
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- else if (LEAP_CCKM_ON(pAd))
- {
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
- KeyIdx = 1;
- else
- KeyIdx = 0;
- }
- else // standard WEP64 or WEP128
-#endif // LEAP_SUPPORT //
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
- else if ((Cipher == Ndis802_11Encryption2Enabled) ||
- (Cipher == Ndis802_11Encryption3Enabled))
- {
- if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd))) // multicast
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- else if (pAd->SharedKey[BSS0][0].KeyLen)
- KeyIdx = 0;
- else
- KeyIdx = pAd->StaCfg.DefaultKeyId;
- }
-
- if (KeyIdx == 0xff)
- CipherAlg = CIPHER_NONE;
- else if ((Cipher == Ndis802_11EncryptionDisabled) || (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 0))
- CipherAlg = CIPHER_NONE;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ( pAd->StaCfg.WpaSupplicantUP &&
- (Cipher == Ndis802_11Encryption1Enabled) &&
- (pAd->StaCfg.IEEE8021X == TRUE) &&
- (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- CipherAlg = CIPHER_NONE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- {
- //Header_802_11.FC.Wep = 1;
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- pKey = &pAd->SharedKey[BSS0][KeyIdx];
- }
- }
-
- pTxBlk->CipherAlg = CipherAlg;
- pTxBlk->pKey = pKey;
-}
-
-
-VOID STABuildCommon802_11Header(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
-
- HEADER_802_11 *pHeader_802_11;
-#ifdef QOS_DLS_SUPPORT
- BOOLEAN bDLSFrame = FALSE;
- INT DlsEntryIndex = 0;
-#endif // QOS_DLS_SUPPORT //
-
- //
- // MAKE A COMMON 802.11 HEADER
- //
-
- // normal wlan header size : 24 octets
- pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-
- pHeader_802_11 = (HEADER_802_11 *) &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-
- NdisZeroMemory(pHeader_802_11, sizeof(HEADER_802_11));
-
- pHeader_802_11->FC.FrDs = 0;
- pHeader_802_11->FC.Type = BTYPE_DATA;
- pHeader_802_11->FC.SubType = ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA : SUBTYPE_DATA);
-
-#ifdef QOS_DLS_SUPPORT
- if (INFRA_ON(pAd))
- {
- // Check if the frame can be sent through DLS direct link interface
- // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
- DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
- if (DlsEntryIndex >= 0)
- bDLSFrame = TRUE;
- else
- bDLSFrame = FALSE;
- }
-#endif // QOS_DLS_SUPPORT //
-
- if (pTxBlk->pMacEntry)
- {
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS))
- {
- pHeader_802_11->Sequence = pTxBlk->pMacEntry->NonQosDataSeq;
- pTxBlk->pMacEntry->NonQosDataSeq = (pTxBlk->pMacEntry->NonQosDataSeq+1) & MAXSEQ;
- }
- else
- {
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- pHeader_802_11->Sequence = pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence;
- pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence = (pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence+1) & MAXSEQ;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- {
- pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority];
- pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
- }
- }
- }
- else
- {
- pHeader_802_11->Sequence = pAd->Sequence;
- pAd->Sequence = (pAd->Sequence+1) & MAXSEQ; // next sequence
- }
-
- pHeader_802_11->Frag = 0;
-
- pHeader_802_11->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
- {
- if (INFRA_ON(pAd))
- {
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
- pHeader_802_11->FC.ToDs = 0;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pTxBlk->pSrcBufHeader);
- pHeader_802_11->FC.ToDs = 1;
- }
- }
- else if (ADHOC_ON(pAd))
- {
- COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
- pHeader_802_11->FC.ToDs = 0;
- }
- }
-
- if (pTxBlk->CipherAlg != CIPHER_NONE)
- pHeader_802_11->FC.Wep = 1;
-
- // -----------------------------------------------------------------
- // STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
- // -----------------------------------------------------------------
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
- else
- pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-}
-
-#ifdef DOT11_N_SUPPORT
-VOID STABuildCache802_11Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR *pHeader)
-{
- MAC_TABLE_ENTRY *pMacEntry;
- PHEADER_802_11 pHeader80211;
-
- pHeader80211 = (PHEADER_802_11)pHeader;
- pMacEntry = pTxBlk->pMacEntry;
-
- //
- // Update the cached 802.11 HEADER
- //
-
- // normal wlan header size : 24 octets
- pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-
- // More Bit
- pHeader80211->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
- // Sequence
- pHeader80211->Sequence = pMacEntry->TxSeq[pTxBlk->UserPriority];
- pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
-
- {
- // Check if the frame can be sent through DLS direct link interface
- // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
-#ifdef QOS_DLS_SUPPORT
- BOOLEAN bDLSFrame = FALSE;
- INT DlsEntryIndex = 0;
-
- DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
- if (DlsEntryIndex >= 0)
- bDLSFrame = TRUE;
- else
- bDLSFrame = FALSE;
-#endif // QOS_DLS_SUPPORT //
-
- // The addr3 of normal packet send from DS is Dest Mac address.
-#ifdef QOS_DLS_SUPPORT
- if (bDLSFrame)
- {
- COPY_MAC_ADDR(pHeader80211->Addr1, pTxBlk->pSrcBufHeader);
- COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
- pHeader80211->FC.ToDs = 0;
- }
- else
-#endif // QOS_DLS_SUPPORT //
- if (ADHOC_ON(pAd))
- COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
- else
- COPY_MAC_ADDR(pHeader80211->Addr3, pTxBlk->pSrcBufHeader);
- }
-
- // -----------------------------------------------------------------
- // STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
- // -----------------------------------------------------------------
- if (pAd->CommonCfg.bAPSDForcePowerSave)
- pHeader80211->FC.PwrMgmt = PWR_SAVE;
- else
- pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-}
-#endif // DOT11_N_SUPPORT //
-
-static inline PUCHAR STA_Build_ARalink_Frame_Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- HEADER_802_11 *pHeader_802_11;
- PNDIS_PACKET pNextPacket;
- UINT32 nextBufLen;
- PQUEUE_ENTRY pQEntry;
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // steal "order" bit to mark "aggregation"
- pHeader_802_11->FC.Order = 1;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- // padding at front of LLC header. LLC header should at 4-bytes aligment.
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR)ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- // For RA Aggregation,
- // put the 2nd MSDU length(extra 2-byte field) after QOS_CONTROL in little endian format
- pQEntry = pTxBlk->TxPacketList.Head;
- pNextPacket = QUEUE_ENTRY_TO_PKT(pQEntry);
- nextBufLen = GET_OS_PKT_LEN(pNextPacket);
- if (RTMP_GET_PACKET_VLAN(pNextPacket))
- nextBufLen -= LENGTH_802_1Q;
-
- *pHeaderBufPtr = (UCHAR)nextBufLen & 0xff;
- *(pHeaderBufPtr+1) = (UCHAR)(nextBufLen >> 8);
-
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += 2;
-
- return pHeaderBufPtr;
-
-}
-
-#ifdef DOT11_N_SUPPORT
-static inline PUCHAR STA_Build_AMSDU_Frame_Header(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;//, pSaveBufPtr;
- HEADER_802_11 *pHeader_802_11;
-
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- //
- // A-MSDU packet
- //
- *pHeaderBufPtr |= 0x80;
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
-
- //pSaveBufPtr = pHeaderBufPtr;
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- // @@@ MpduHeaderLen excluding padding @@@
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- return pHeaderBufPtr;
-
-}
-
-
-VOID STA_AMPDU_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- MAC_TABLE_ENTRY *pMacEntry;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
- ASSERT(pTxBlk);
-
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if ( RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- pMacEntry = pTxBlk->pMacEntry;
- if (pMacEntry->isCached)
- {
- // NOTE: Please make sure the size of pMacEntry->CachedBuf[] is smaller than pTxBlk->HeaderBuf[]!!!!
- NdisMoveMemory((PUCHAR)&pTxBlk->HeaderBuf[TXINFO_SIZE], (PUCHAR)&pMacEntry->CachedBuf[0], TXWI_SIZE + sizeof(HEADER_802_11));
- pHeaderBufPtr = (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE]);
- STABuildCache802_11Header(pAd, pTxBlk, pHeaderBufPtr);
- }
- else
- {
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- }
-
-
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
-
- //
- // build HTC+
- // HTC control filed following QoS field
- //
- if ((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pTxBlk->pMacEntry, fCLIENT_STATUS_RDG_CAPABLE))
- {
- if (pMacEntry->isCached == FALSE)
- {
- // mark HTC bit
- pHeader_802_11->FC.Order = 1;
-
- NdisZeroMemory(pHeaderBufPtr, 4);
- *(pHeaderBufPtr+3) |= 0x80;
- }
- pHeaderBufPtr += 4;
- pTxBlk->MpduHeaderLen += 4;
- }
-
- //pTxBlk->MpduHeaderLen = pHeaderBufPtr - pTxBlk->HeaderBuf - TXWI_SIZE - TXINFO_SIZE;
- ASSERT(pTxBlk->MpduHeaderLen >= 24);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- // @@@ MpduHeaderLen excluding padding @@@
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- {
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
- }
-
- if (pMacEntry->isCached)
- {
- RTMPWriteTxWI_Cache(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
- }
- else
- {
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- NdisZeroMemory((PUCHAR)(&pMacEntry->CachedBuf[0]), sizeof(pMacEntry->CachedBuf));
- NdisMoveMemory((PUCHAR)(&pMacEntry->CachedBuf[0]), (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), (pHeaderBufPtr - (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE])));
- pMacEntry->isCached = TRUE;
- }
-
- // calculate Transmitted AMPDU count and ByteCount
- {
- pAd->RalinkCounters.TransmittedMPDUsInAMPDUCount.u.LowPart ++;
- pAd->RalinkCounters.TransmittedOctetsInAMPDUCount.QuadPart += pTxBlk->SrcBufLen;
- }
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
-
- HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
- }
-
-}
-
-
-VOID STA_AMSDU_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- USHORT subFramePayloadLen = 0; // AMSDU Subframe length without AMSDU-Header / Padding.
- USHORT totalMPDUSize=0;
- UCHAR *subFrameHeader;
- UCHAR padding = 0;
- USHORT FirstTx = 0, LastTxIdx = 0;
- BOOLEAN bVLANPkt;
- int frameNum = 0;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- ASSERT((pTxBlk->TxPacketList.Number > 1));
-
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- if (frameNum == 0)
- {
- pHeaderBufPtr = STA_Build_AMSDU_Frame_Header(pAd, pTxBlk);
-
- // NOTE: TxWI->MPDUtotalByteCount will be updated after final frame was handled.
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
- }
- else
- {
- pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
- padding = ROUND_UP(LENGTH_AMSDU_SUBFRAMEHEAD + subFramePayloadLen, 4) - (LENGTH_AMSDU_SUBFRAMEHEAD + subFramePayloadLen);
- NdisZeroMemory(pHeaderBufPtr, padding + LENGTH_AMSDU_SUBFRAMEHEAD);
- pHeaderBufPtr += padding;
- pTxBlk->MpduHeaderLen = padding;
- }
-
- //
- // A-MSDU subframe
- // DA(6)+SA(6)+Length(2) + LLC/SNAP Encap
- //
- subFrameHeader = pHeaderBufPtr;
- subFramePayloadLen = pTxBlk->SrcBufLen;
-
- NdisMoveMemory(subFrameHeader, pTxBlk->pSrcBufHeader, 12);
-
-
- pHeaderBufPtr += LENGTH_AMSDU_SUBFRAMEHEAD;
- pTxBlk->MpduHeaderLen += LENGTH_AMSDU_SUBFRAMEHEAD;
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
-
- subFramePayloadLen = pTxBlk->SrcBufLen;
-
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- subFramePayloadLen += LENGTH_802_1_H;
- }
-
- // update subFrame Length field
- subFrameHeader[12] = (subFramePayloadLen & 0xFF00) >> 8;
- subFrameHeader[13] = subFramePayloadLen & 0xFF;
-
- totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
- if (frameNum ==0)
- FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
- else
- LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
-
- frameNum++;
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- // calculate Transmitted AMSDU Count and ByteCount
- {
- pAd->RalinkCounters.TransmittedAMSDUCount.u.LowPart ++;
- pAd->RalinkCounters.TransmittedOctetsInAMSDU.QuadPart += totalMPDUSize;
- }
-
- }
-
- HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
- HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-#endif // DOT11_N_SUPPORT //
-
-VOID STA_Legacy_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
- ASSERT(pTxBlk);
-
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- if (pTxBlk->TxFrameType == TX_MCAST_FRAME)
- {
- INC_COUNTER64(pAd->WlanCounters.MulticastTransmittedFrameCount);
- }
-
- if (RTMP_GET_PACKET_RTS(pTxBlk->pPacket))
- TX_BLK_SET_FLAG(pTxBlk, fTX_bRtsRequired);
- else
- TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bRtsRequired);
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- if (pTxBlk->TxRate < pAd->CommonCfg.MinTxRate)
- pTxBlk->TxRate = pAd->CommonCfg.MinTxRate;
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- // The remaining content of MPDU header should locate at 4-octets aligment
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
- {
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- //
- // if original Ethernet frame contains no LLC/SNAP,
- // then an extra LLC/SNAP encap is required
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- UCHAR vlan_size;
-
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // skip vlan tag
- vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader+12+vlan_size, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
- }
-
- //
- // prepare for TXWI
- // use Wcid as Key Index
- //
-
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
-
- HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-
-VOID STA_ARalink_Frame_Tx(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk)
-{
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- USHORT totalMPDUSize=0;
- USHORT FirstTx, LastTxIdx;
- int frameNum = 0;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- ASSERT((pTxBlk->TxPacketList.Number== 2));
-
-
- FirstTx = LastTxIdx = 0; // Is it ok init they as 0?
- while(pTxBlk->TxPacketList.Head)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- continue;
- }
-
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- if (frameNum == 0)
- { // For first frame, we need to create the 802.11 header + padding(optional) + RA-AGG-LEN + SNAP Header
-
- pHeaderBufPtr = STA_Build_ARalink_Frame_Header(pAd, pTxBlk);
-
- // It's ok write the TxWI here, because the TxWI->MPDUtotalByteCount
- // will be updated after final frame was handled.
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
-
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
- }
- else
- { // For second aggregated frame, we need create the 802.3 header to headerBuf, because PCI will copy it to SDPtr0.
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
- pTxBlk->MpduHeaderLen = 0;
-
- // A-Ralink sub-sequent frame header is the same as 802.3 header.
- // DA(6)+SA(6)+FrameType(2)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader, 12);
- pHeaderBufPtr += 12;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData-2, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen = LENGTH_ARALINK_SUBFRAMEHEAD;
- }
-
- totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
- //FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
- if (frameNum ==0)
- FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
- else
- LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
-
- frameNum++;
-
- pAd->RalinkCounters.OneSecTxAggregationCount++;
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- }
-
- HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
- HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
-}
-
-
-VOID STA_Fragment_Frame_Tx(
- IN RTMP_ADAPTER *pAd,
- IN TX_BLK *pTxBlk)
-{
- HEADER_802_11 *pHeader_802_11;
- PUCHAR pHeaderBufPtr;
- USHORT FreeNumber;
- UCHAR fragNum = 0;
- PACKET_INFO PacketInfo;
- USHORT EncryptionOverhead = 0;
- UINT32 FreeMpduSize, SrcRemainingBytes;
- USHORT AckDuration;
- UINT NextMpduSize;
- BOOLEAN bVLANPkt;
- PQUEUE_ENTRY pQEntry;
-
-
- ASSERT(pTxBlk);
-
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE)
- {
- RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
- return;
- }
-
- ASSERT(TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag));
- bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
- STAFindCipherAlgorithm(pAd, pTxBlk);
- STABuildCommon802_11Header(pAd, pTxBlk);
-
- if (pTxBlk->CipherAlg == CIPHER_TKIP)
- {
- pTxBlk->pPacket = duplicate_pkt_with_TKIP_MIC(pAd, pTxBlk->pPacket);
- if (pTxBlk->pPacket == NULL)
- return;
- RTMP_QueryPacketInfo(pTxBlk->pPacket, &PacketInfo, &pTxBlk->pSrcBufHeader, &pTxBlk->SrcBufLen);
- }
-
- // skip 802.3 header
- pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
- pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-
- // skip vlan tag
- if (bVLANPkt)
- {
- pTxBlk->pSrcBufData += LENGTH_802_1Q;
- pTxBlk->SrcBufLen -= LENGTH_802_1Q;
- }
-
- pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
- pHeader_802_11 = (HEADER_802_11 *)pHeaderBufPtr;
-
-
- // skip common header
- pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
- if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM))
- {
- //
- // build QOS Control bytes
- //
- *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
- *(pHeaderBufPtr+1) = 0;
- pHeaderBufPtr +=2;
- pTxBlk->MpduHeaderLen += 2;
- }
-
- //
- // padding at front of LLC header
- // LLC header should locate at 4-octets aligment
- //
- pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
- pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
- pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-
-
- //
- // Insert LLC-SNAP encapsulation - 8 octets
- //
- //
- // if original Ethernet frame contains no LLC/SNAP,
- // then an extra LLC/SNAP encap is required
- //
- EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
- if (pTxBlk->pExtraLlcSnapEncap)
- {
- UCHAR vlan_size;
-
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
- pHeaderBufPtr += 6;
- // skip vlan tag
- vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
- // get 2 octets (TypeofLen)
- NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader+12+vlan_size, 2);
- pHeaderBufPtr += 2;
- pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
- }
-
-
- // If TKIP is used and fragmentation is required. Driver has to
- // append TKIP MIC at tail of the scatter buffer
- // MAC ASIC will only perform IV/EIV/ICV insertion but no TKIP MIC
- if (pTxBlk->CipherAlg == CIPHER_TKIP)
- {
-
- // NOTE: DON'T refer the skb->len directly after following copy. Becasue the length is not adjust
- // to correct lenght, refer to pTxBlk->SrcBufLen for the packet length in following progress.
- NdisMoveMemory(pTxBlk->pSrcBufData + pTxBlk->SrcBufLen, &pAd->PrivateInfo.Tx.MIC[0], 8);
- //skb_put((RTPKT_TO_OSPKT(pTxBlk->pPacket))->tail, 8);
- pTxBlk->SrcBufLen += 8;
- pTxBlk->TotalFrameLen += 8;
- pTxBlk->CipherAlg = CIPHER_TKIP_NO_MIC;
- }
-
- //
- // calcuate the overhead bytes that encryption algorithm may add. This
- // affects the calculate of "duration" field
- //
- if ((pTxBlk->CipherAlg == CIPHER_WEP64) || (pTxBlk->CipherAlg == CIPHER_WEP128))
- EncryptionOverhead = 8; //WEP: IV[4] + ICV[4];
- else if (pTxBlk->CipherAlg == CIPHER_TKIP_NO_MIC)
- EncryptionOverhead = 12;//TKIP: IV[4] + EIV[4] + ICV[4], MIC will be added to TotalPacketLength
- else if (pTxBlk->CipherAlg == CIPHER_TKIP)
- EncryptionOverhead = 20;//TKIP: IV[4] + EIV[4] + ICV[4] + MIC[8]
- else if (pTxBlk->CipherAlg == CIPHER_AES)
- EncryptionOverhead = 16; // AES: IV[4] + EIV[4] + MIC[8]
- else
- EncryptionOverhead = 0;
-
- // decide how much time an ACK/CTS frame will consume in the air
- AckDuration = RTMPCalcDuration(pAd, pAd->CommonCfg.ExpectedACKRate[pTxBlk->TxRate], 14);
-
- // Init the total payload length of this frame.
- SrcRemainingBytes = pTxBlk->SrcBufLen;
-
- pTxBlk->TotalFragNum = 0xff;
-
- do {
-
- FreeMpduSize = pAd->CommonCfg.FragmentThreshold - LENGTH_CRC;
-
- FreeMpduSize -= pTxBlk->MpduHeaderLen;
-
- if (SrcRemainingBytes <= FreeMpduSize)
- { // this is the last or only fragment
-
- pTxBlk->SrcBufLen = SrcRemainingBytes;
-
- pHeader_802_11->FC.MoreFrag = 0;
- pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + AckDuration;
-
- // Indicate the lower layer that this's the last fragment.
- pTxBlk->TotalFragNum = fragNum;
- }
- else
- { // more fragment is required
-
- pTxBlk->SrcBufLen = FreeMpduSize;
-
- NextMpduSize = min(((UINT)SrcRemainingBytes - pTxBlk->SrcBufLen), ((UINT)pAd->CommonCfg.FragmentThreshold));
- pHeader_802_11->FC.MoreFrag = 1;
- pHeader_802_11->Duration = (3 * pAd->CommonCfg.Dsifs) + (2 * AckDuration) + RTMPCalcDuration(pAd, pTxBlk->TxRate, NextMpduSize + EncryptionOverhead);
- }
-
- if (fragNum == 0)
- pTxBlk->FrameGap = IFS_HTTXOP;
- else
- pTxBlk->FrameGap = IFS_SIFS;
-
- RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
-
- HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, &FreeNumber);
-
- pAd->RalinkCounters.KickTxCount++;
- pAd->RalinkCounters.OneSecTxDoneCount++;
-
- // Update the frame number, remaining size of the NDIS packet payload.
-
- // space for 802.11 header.
- if (fragNum == 0 && pTxBlk->pExtraLlcSnapEncap)
- pTxBlk->MpduHeaderLen -= LENGTH_802_1_H;
-
- fragNum++;
- SrcRemainingBytes -= pTxBlk->SrcBufLen;
- pTxBlk->pSrcBufData += pTxBlk->SrcBufLen;
-
- pHeader_802_11->Frag++; // increase Frag #
-
- }while(SrcRemainingBytes > 0);
-
- //
- // Kick out Tx
- //
- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-
-#define RELEASE_FRAMES_OF_TXBLK(_pAd, _pTxBlk, _pQEntry, _Status) \
- while(_pTxBlk->TxPacketList.Head) \
- { \
- _pQEntry = RemoveHeadQueue(&_pTxBlk->TxPacketList); \
- RELEASE_NDIS_PACKET(_pAd, QUEUE_ENTRY_TO_PACKET(_pQEntry), _Status); \
- }
-
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware encryption before really
- sent out to air.
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to outgoing Ndis frame
- NumberOfFrag Number of fragment required
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-NDIS_STATUS STAHardTransmit(
- IN PRTMP_ADAPTER pAd,
- IN TX_BLK *pTxBlk,
- IN UCHAR QueIdx)
-{
- NDIS_PACKET *pPacket;
- PQUEUE_ENTRY pQEntry;
-
- // ---------------------------------------------
- // STEP 0. DO SANITY CHECK AND SOME EARLY PREPARATION.
- // ---------------------------------------------
- //
- ASSERT(pTxBlk->TxPacketList.Number);
- if (pTxBlk->TxPacketList.Head == NULL)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("pTxBlk->TotalFrameNum == %ld!\n", pTxBlk->TxPacketList.Number));
- return NDIS_STATUS_FAILURE;
- }
-
- pPacket = QUEUE_ENTRY_TO_PACKET(pTxBlk->TxPacketList.Head);
-
- // ------------------------------------------------------------------
- // STEP 1. WAKE UP PHY
- // outgoing frame always wakeup PHY to prevent frame lost and
- // turn off PSM bit to improve performance
- // ------------------------------------------------------------------
- // not to change PSM bit, just send this frame out?
- if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n"));
- AsicForceWakeup(pAd, TRUE);
- }
-
- // It should not change PSM bit, when APSD turn on.
- if ((!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable) && (pAd->CommonCfg.bAPSDForcePowerSave == FALSE))
- || (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
- || (RTMP_GET_PACKET_WAI(pTxBlk->pPacket)))
- {
- if ((pAd->StaCfg.Psm == PWR_SAVE) &&
- (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP))
- MlmeSetPsmBit(pAd, PWR_ACTIVE);
- }
-
- switch (pTxBlk->TxFrameType)
- {
-#ifdef DOT11_N_SUPPORT
- case TX_AMPDU_FRAME:
- STA_AMPDU_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_AMSDU_FRAME:
- STA_AMSDU_Frame_Tx(pAd, pTxBlk);
- break;
-#endif // DOT11_N_SUPPORT //
- case TX_LEGACY_FRAME:
- STA_Legacy_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_MCAST_FRAME:
- STA_Legacy_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_RALINK_FRAME:
- STA_ARalink_Frame_Tx(pAd, pTxBlk);
- break;
- case TX_FRAG_FRAME:
- STA_Fragment_Frame_Tx(pAd, pTxBlk);
- break;
- default:
- {
- // It should not happened!
- DBGPRINT(RT_DEBUG_ERROR, ("Send a pacekt was not classified!! It should not happen!\n"));
- while(pTxBlk->TxPacketList.Number)
- {
- pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
- pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
- if (pPacket)
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
- }
- break;
- }
-
- return (NDIS_STATUS_SUCCESS);
-
-}
-
-ULONG HashBytesPolynomial(UCHAR *value, unsigned int len)
-{
- unsigned char *word = value;
- unsigned int ret = 0;
- unsigned int i;
-
- for(i=0; i < len; i++)
- {
- int mod = i % 32;
- ret ^=(unsigned int) (word[i]) << mod;
- ret ^=(unsigned int) (word[i]) >> (32 - mod);
- }
- return ret;
-}
-
-VOID Sta_Announce_or_Forward_802_3_Packet(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_PACKET pPacket,
- IN UCHAR FromWhichBSSID)
-{
- if (TRUE
- )
- {
- announce_802_3_packet(pAd, pPacket);
- }
- else
- {
- // release packet
- RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
- }
-}
-
+#include "../../rt2870/sta/rtmp_data.c"
diff --git a/drivers/staging/rt3070/sta/sanity.c b/drivers/staging/rt3070/sta/sanity.c
index 239872464bed..b4954779b316 100644
--- a/drivers/staging/rt3070/sta/sanity.c
+++ b/drivers/staging/rt3070/sta/sanity.c
@@ -1,420 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sanity.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 add WMM support
-*/
-#include "../rt_config.h"
-
-extern UCHAR CISCO_OUI[];
-
-extern UCHAR WPA_OUI[];
-extern UCHAR RSN_OUI[];
-extern UCHAR WME_INFO_ELEM[];
-extern UCHAR WME_PARM_ELEM[];
-extern UCHAR Ccx2QosInfo[];
-extern UCHAR RALINK_OUI[];
-extern UCHAR BROADCOM_OUI[];
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
- */
-BOOLEAN MlmeStartReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen)
-{
- MLME_START_REQ_STRUCT *Info;
-
- Info = (MLME_START_REQ_STRUCT *)(Msg);
-
- if (Info->SsidLen > MAX_LEN_OF_SSID)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqSanity fail - wrong SSID length\n"));
- return FALSE;
- }
-
- *pSsidLen = Info->SsidLen;
- NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerAssocRspSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *pMsg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT USHORT *pCapabilityInfo,
- OUT USHORT *pStatus,
- OUT USHORT *pAid,
- OUT UCHAR SupRate[],
- OUT UCHAR *pSupRateLen,
- OUT UCHAR ExtRate[],
- OUT UCHAR *pExtRateLen,
- OUT HT_CAPABILITY_IE *pHtCapability,
- OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
- OUT UCHAR *pHtCapabilityLen,
- OUT UCHAR *pAddHtInfoLen,
- OUT UCHAR *pNewExtChannelOffset,
- OUT PEDCA_PARM pEdcaParm,
- OUT UCHAR *pCkipFlag)
-{
- CHAR IeType, *Ptr;
- PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
- PEID_STRUCT pEid;
- ULONG Length = 0;
-
- *pNewExtChannelOffset = 0xff;
- *pHtCapabilityLen = 0;
- *pAddHtInfoLen = 0;
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
- Ptr = pFrame->Octet;
- Length += LENGTH_802_11;
-
- NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
- Length += 2;
- NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
- Length += 2;
- *pCkipFlag = 0;
- *pExtRateLen = 0;
- pEdcaParm->bValid = FALSE;
-
- if (*pStatus != MLME_SUCCESS)
- return TRUE;
-
- NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
- Length += 2;
-
- // Aid already swaped byte order in RTMPFrameEndianChange() for big endian platform
- *pAid = (*pAid) & 0x3fff; // AID is low 14-bit
-
- // -- get supported rates from payload and advance the pointer
- IeType = pFrame->Octet[6];
- *pSupRateLen = pFrame->Octet[7];
- if ((IeType != IE_SUPP_RATES) || (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
- return FALSE;
- }
- else
- NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
-
- Length = Length + 2 + *pSupRateLen;
-
- // many AP implement proprietary IEs in non-standard order, we'd better
- // tolerate mis-ordered IEs to get best compatibility
- pEid = (PEID_STRUCT) &pFrame->Octet[8 + (*pSupRateLen)];
-
- // get variable fields from payload and advance the pointer
- while ((Length + 2 + pEid->Len) <= MsgLen)
- {
- switch (pEid->Eid)
- {
- case IE_EXT_SUPP_RATES:
- if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
- {
- NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
- *pExtRateLen = pEid->Len;
- }
- break;
-
- case IE_HT_CAP:
- case IE_HT_CAP2:
- if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
- {
- NdisMoveMemory(pHtCapability, pEid->Octet, SIZE_HT_CAP_IE);
-
- *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
- *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
-
- *pHtCapabilityLen = SIZE_HT_CAP_IE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
- }
-
- break;
-#ifdef DOT11_N_SUPPORT
- case IE_ADD_HT:
- case IE_ADD_HT2:
- if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
- {
- // This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
- // copy first sizeof(ADD_HT_INFO_IE)
- NdisMoveMemory(pAddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
-
- *(USHORT *)(&pAddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo2));
- *(USHORT *)(&pAddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo3));
-
- *pAddHtInfoLen = SIZE_ADD_HT_INFO_IE;
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
- }
-
- break;
- case IE_SECONDARY_CH_OFFSET:
- if (pEid->Len == 1)
- {
- *pNewExtChannelOffset = pEid->Octet[0];
- }
- else
- {
- DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
- }
-#endif // DOT11_N_SUPPORT //
- break;
- case IE_AIRONET_CKIP:
- // 0. Check Aironet IE length, it must be larger or equal to 28
- // Cisco's AP VxWork version(will not be supported) used this IE length as 28
- // Cisco's AP IOS version used this IE length as 30
- if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
- break;
-
- // 1. Copy CKIP flag byte to buffer for process
- *pCkipFlag = *(pEid->Octet + 8);
- break;
-
- case IE_AIRONET_IPADDRESS:
- if (pEid->Len != 0x0A)
- break;
-
- // Get Cisco Aironet IP information
- if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
- NdisMoveMemory(pAd->StaCfg.AironetIPAddress, pEid->Octet + 4, 4);
- break;
-
- // CCX2, WMM use the same IE value
- // case IE_CCX_V2:
- case IE_VENDOR_SPECIFIC:
- // handle WME PARAMTER ELEMENT
- if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
- {
- PUCHAR ptr;
- int i;
-
- // parsing EDCA parameters
- pEdcaParm->bValid = TRUE;
- pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
- pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
- pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
- //pEdcaParm->bMoreDataAck = FALSE; // pEid->Octet[0] & 0x80;
- pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
- pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
- ptr = &pEid->Octet[8];
- for (i=0; i<4; i++)
- {
- UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
- pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
- pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
- pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
- pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
- pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
- ptr += 4; // point to next AC
- }
- }
-
- // handle CCX IE
- else
- {
- // 0. Check the size and CCX admin control
- if (pAd->StaCfg.CCXControl.field.Enable == 0)
- break;
- if (pEid->Len != 5)
- break;
-
- // Turn CCX2 if matched
- if (NdisEqualMemory(pEid->Octet, Ccx2IeInfo, 5) == 1)
- pAd->StaCfg.CCXEnable = TRUE;
- break;
- }
- break;
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity - ignore unrecognized EID = %d\n", pEid->Eid));
- break;
- }
-
- Length = Length + 2 + pEid->Len;
- pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
- }
-
- // Force CCX2 enable to TRUE for those AP didn't replay CCX v2 IE, we still force it to be on
- if (pAd->StaCfg.CCXControl.field.Enable == 1)
- pAd->StaCfg.CCXEnable = TRUE;
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- MLME message sanity check
- Return:
- TRUE if all parameters are OK, FALSE otherwise
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN PeerProbeReqSanity(
- IN PRTMP_ADAPTER pAd,
- IN VOID *Msg,
- IN ULONG MsgLen,
- OUT PUCHAR pAddr2,
- OUT CHAR Ssid[],
- OUT UCHAR *pSsidLen)
-{
- UCHAR Idx;
- UCHAR RateLen;
- CHAR IeType;
- PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
-
- COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-
- if ((pFrame->Octet[0] != IE_SSID) || (pFrame->Octet[1] > MAX_LEN_OF_SSID))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",pFrame->Octet[0],pFrame->Octet[1]));
- return FALSE;
- }
-
- *pSsidLen = pFrame->Octet[1];
- NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
-
- Idx = *pSsidLen + 2;
-
- // -- get supported rates from payload and advance the pointer
- IeType = pFrame->Octet[Idx];
- RateLen = pFrame->Octet[Idx + 1];
- if (IeType != IE_SUPP_RATES)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",pFrame->Octet[Idx],pFrame->Octet[Idx+1]));
- return FALSE;
- }
- else
- {
- if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
- return (FALSE);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-BOOLEAN GetTimBit(
- IN CHAR *Ptr,
- IN USHORT Aid,
- OUT UCHAR *TimLen,
- OUT UCHAR *BcastFlag,
- OUT UCHAR *DtimCount,
- OUT UCHAR *DtimPeriod,
- OUT UCHAR *MessageToMe)
-{
- UCHAR BitCntl, N1, N2, MyByte, MyBit;
- CHAR *IdxPtr;
-
- IdxPtr = Ptr;
-
- IdxPtr ++;
- *TimLen = *IdxPtr;
-
- // get DTIM Count from TIM element
- IdxPtr ++;
- *DtimCount = *IdxPtr;
-
- // get DTIM Period from TIM element
- IdxPtr++;
- *DtimPeriod = *IdxPtr;
-
- // get Bitmap Control from TIM element
- IdxPtr++;
- BitCntl = *IdxPtr;
-
- if ((*DtimCount == 0) && (BitCntl & 0x01))
- *BcastFlag = TRUE;
- else
- *BcastFlag = FALSE;
-
- // Parse Partial Virtual Bitmap from TIM element
- N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
- N2 = *TimLen - 4 + N1; // N2 is the last bitmap byte#
-
- if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
- *MessageToMe = FALSE;
- else
- {
- MyByte = (Aid >> 3) - N1; // my byte position in the bitmap byte-stream
- MyBit = Aid % 16 - ((MyByte & 0x01)? 8:0);
-
- IdxPtr += (MyByte + 1);
-
- //if (*IdxPtr)
- // DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
-
- if (*IdxPtr & (0x01 << MyBit))
- *MessageToMe = TRUE;
- else
- *MessageToMe = FALSE;
- }
-
- return TRUE;
-}
-
+#include "../../rt2870/sta/sanity.c"
diff --git a/drivers/staging/rt3070/sta/sync.c b/drivers/staging/rt3070/sta/sync.c
index 2b5b3b07661d..b7b8eb4f446a 100644
--- a/drivers/staging/rt3070/sta/sync.c
+++ b/drivers/staging/rt3070/sta/sync.c
@@ -1,1755 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sync.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- John Chang 2004-09-01 modified for rt2561/2661
- Jan Lee 2006-08-01 modified for rt2860 for 802.11n
-*/
-#include "../rt_config.h"
-
-#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec
-
-/*
- ==========================================================================
- Description:
- The sync state machine,
- Parameters:
- Sm - pointer to the state machine
- Note:
- the state machine looks like the following
-
- ==========================================================================
- */
-VOID SyncStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *Sm,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG, (STATE_MACHINE_FUNC)Drop, SYNC_IDLE, SYNC_MACHINE_BASE);
-
- // column 1
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)MlmeScanReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)MlmeJoinReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)MlmeStartReqAction);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeacon);
- StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
-
- //column 2
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtJoinAction);
- StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_BEACON_TIMEOUT, (STATE_MACHINE_FUNC)BeaconTimeoutAtJoinAction);
-
- // column 3
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_PROBE_RSP, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
- StateMachineSetAction(Sm, SCAN_LISTEN, MT2_SCAN_TIMEOUT, (STATE_MACHINE_FUNC)ScanTimeoutAction);
-
- // timer init
- RTMPInitTimer(pAd, &pAd->MlmeAux.BeaconTimer, GET_TIMER_FUNCTION(BeaconTimeout), pAd, FALSE);
- RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer, GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
-}
-
-/*
- ==========================================================================
- Description:
- Beacon timeout handler, executed in timer thread
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID BeaconTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
- DBGPRINT(RT_DEBUG_TRACE,("SYNC - BeaconTimeout\n"));
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
-#ifdef DOT11_N_SUPPORT
- if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
- )
- {
- UCHAR BBPValue = 0;
- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- BBPValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
- }
-#endif // DOT11_N_SUPPORT //
-
- MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL);
- RT28XX_MLME_HANDLER(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- Scan timeout handler, executed in timer thread
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID ScanTimeout(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-
-
- // Do nothing if the driver is starting halt state.
- // This might happen when timer already been fired before cancel timer with mlmehalt
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
- return;
-
- if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL))
- {
- RT28XX_MLME_HANDLER(pAd);
- }
- else
- {
- // To prevent SyncMachine.CurrState is SCAN_LISTEN forever.
- pAd->MlmeAux.Channel = 0;
- ScanNextChannel(pAd);
- if (pAd->CommonCfg.bWirelessEvent)
- {
- RTMPSendWirelessEvent(pAd, IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
- }
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME SCAN req state machine procedure
- ==========================================================================
- */
-VOID MlmeScanReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
- BOOLEAN TimerCancelled;
- ULONG Now;
- USHORT Status;
- PHEADER_802_11 pHdr80211;
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
-
- // Check the total scan tries for one single OID command
- // If this is the CCX 2.0 Case, skip that!
- if ( !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeScanReqAction before Startup\n"));
- return;
- }
-
- // Increase the scan retry counters.
- pAd->StaCfg.ScanCnt++;
-
-
- // first check the parameter sanity
- if (MlmeScanReqSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- &BssType,
- Ssid,
- &SsidLen,
- &ScanType))
- {
-
- // Check for channel load and noise hist request
- // Suspend MSDU only at scan request, not the last two mentioned
- if ((ScanType == SCAN_CISCO_NOISE) || (ScanType == SCAN_CISCO_CHANNEL_LOAD))
- {
- if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
- RTMPSuspendMsduTransmission(pAd); // Suspend MSDU transmission here
- }
- else
- {
- // Suspend MSDU transmission here
- RTMPSuspendMsduTransmission(pAd);
- }
-
- //
- // To prevent data lost.
- // Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
- // And should send an NULL data with turned PSM bit off to AP, when scan progress done
- //
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
- {
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- pHdr80211 = (PHEADER_802_11) pOutBuffer;
- MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
- pHdr80211->Duration = 0;
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.PwrMgmt = PWR_SAVE;
-
- // Send using priority queue
- MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame for off channel RM\n"));
- MlmeFreeMemory(pAd, pOutBuffer);
- RTMPusecDelay(5000);
- }
- }
-
- NdisGetSystemUpTime(&Now);
- pAd->StaCfg.LastScanTime = Now;
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
-
- // record desired BSS parameters
- pAd->MlmeAux.BssType = BssType;
- pAd->MlmeAux.ScanType = ScanType;
- pAd->MlmeAux.SsidLen = SsidLen;
- NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
-
- // start from the first channel
- pAd->MlmeAux.Channel = FirstChannel(pAd);
-
- // Change the scan channel when dealing with CCX beacon report
- if ((ScanType == SCAN_CISCO_PASSIVE) || (ScanType == SCAN_CISCO_ACTIVE) ||
- (ScanType == SCAN_CISCO_CHANNEL_LOAD) || (ScanType == SCAN_CISCO_NOISE))
- pAd->MlmeAux.Channel = pAd->StaCfg.CCXScanChannel;
-
- // Let BBP register at 20MHz to do scan
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
- ScanNextChannel(pAd);
- }
- else
- {
- DBGPRINT_ERR(("SYNC - MlmeScanReqAction() sanity check fail\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- MLME JOIN req state machine procedure
- ==========================================================================
- */
-VOID MlmeJoinReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR BBPValue = 0;
- BSS_ENTRY *pBss;
- BOOLEAN TimerCancelled;
- HEADER_802_11 Hdr80211;
- NDIS_STATUS NStatus;
- ULONG FrameLen = 0;
- PUCHAR pOutBuffer = NULL;
- PUCHAR pSupRate = NULL;
- UCHAR SupRateLen;
- PUCHAR pExtRate = NULL;
- UCHAR ExtRateLen;
- UCHAR ASupRate[] = {0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C};
- UCHAR ASupRateLen = sizeof(ASupRate)/sizeof(UCHAR);
- MLME_JOIN_REQ_STRUCT *pInfo = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
-
-
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- pBss = &pAd->MlmeAux.SsidBssTab.BssEntry[pInfo->BssIdx];
-
- // record the desired SSID & BSSID we're waiting for
- COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pBss->Bssid);
-
- // If AP's SSID is not hidden, it is OK for updating ssid to MlmeAux again.
- if (pBss->Hidden == 0)
- {
- NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);
- pAd->MlmeAux.SsidLen = pBss->SsidLen;
- }
-
- pAd->MlmeAux.BssType = pBss->BssType;
- pAd->MlmeAux.Channel = pBss->Channel;
- pAd->MlmeAux.CentralChannel = pBss->CentralChannel;
-
-#ifdef EXT_BUILD_CHANNEL_LIST
- // Country IE of the AP will be evaluated and will be used.
- if ((pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None) &&
- (pBss->bHasCountryIE == TRUE))
- {
- NdisMoveMemory(&pAd->CommonCfg.CountryCode[0], &pBss->CountryString[0], 2);
- if (pBss->CountryString[2] == 'I')
- pAd->CommonCfg.Geography = IDOR;
- else if (pBss->CountryString[2] == 'O')
- pAd->CommonCfg.Geography = ODOR;
- else
- pAd->CommonCfg.Geography = BOTH;
- BuildChannelListEx(pAd);
- }
-#endif // EXT_BUILD_CHANNEL_LIST //
-
- // Let BBP register at 20MHz to do scan
- RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
- BBPValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
-
- // switch channel and waiting for beacon timer
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
- RTMPSetTimer(&pAd->MlmeAux.BeaconTimer, JOIN_TIMEOUT);
-
- do
- {
- if (((pAd->CommonCfg.bIEEE80211H == 1) &&
- (pAd->MlmeAux.Channel > 14) &&
- RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
- || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
-#endif // CARRIER_DETECTION_SUPPORT //
- )
- {
- //
- // We can't send any Probe request frame to meet 802.11h.
- //
- if (pBss->Hidden == 0)
- break;
- }
-
- //
- // send probe request
- //
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
- if (NStatus == NDIS_STATUS_SUCCESS)
- {
- if (pAd->MlmeAux.Channel <= 14)
- {
- pSupRate = pAd->CommonCfg.SupRate;
- SupRateLen = pAd->CommonCfg.SupRateLen;
- pExtRate = pAd->CommonCfg.ExtRate;
- ExtRateLen = pAd->CommonCfg.ExtRateLen;
- }
- else
- {
- //
- // Overwrite Support Rate, CCK rate are not allowed
- //
- pSupRate = ASupRate;
- SupRateLen = ASupRateLen;
- ExtRateLen = 0;
- }
-
- if (pAd->MlmeAux.BssType == BSS_INFRA)
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, pAd->MlmeAux.Bssid, pAd->MlmeAux.Bssid);
- else
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &pAd->MlmeAux.SsidLen,
- pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
- 1, &SupRateIe,
- 1, &SupRateLen,
- SupRateLen, pSupRate,
- END_OF_ARGS);
-
- if (ExtRateLen)
- {
- ULONG Tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
- 1, &ExtRateIe,
- 1, &ExtRateLen,
- ExtRateLen, pExtRate,
- END_OF_ARGS);
- FrameLen += Tmp;
- }
-
-
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- } while (FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n",
- pBss->Channel, pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2], pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
-
- pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
-}
-
-/*
- ==========================================================================
- Description:
- MLME START Request state machine procedure, starting an IBSS
- ==========================================================================
- */
-VOID MlmeStartReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
- BOOLEAN TimerCancelled;
-
- // New for WPA security suites
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- LARGE_INTEGER TimeStamp;
- BOOLEAN Privacy;
- USHORT Status;
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- TimeStamp.u.LowPart = 0;
- TimeStamp.u.HighPart = 0;
-
- if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen))
- {
- // reset all the timers
- RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- //
- // Start a new IBSS. All IBSS parameters are decided now....
- //
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
- pAd->MlmeAux.BssType = BSS_ADHOC;
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
- pAd->MlmeAux.SsidLen = SsidLen;
-
- // generate a radom number as BSSID
- MacAddrRandomBssid(pAd, pAd->MlmeAux.Bssid);
- DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - generate a radom number as BSSID \n"));
-
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- pAd->MlmeAux.CapabilityInfo = CAP_GENERATE(0,1,Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 1, 0);
- pAd->MlmeAux.BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
- pAd->MlmeAux.AtimWin = pAd->StaCfg.AtimWin;
- pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
-
- pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
- pAd->MlmeAux.CentralChannel = pAd->CommonCfg.CentralChannel;
-
- pAd->MlmeAux.SupRateLen= pAd->CommonCfg.SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
- pAd->MlmeAux.ExtRateLen = pAd->CommonCfg.ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy, &pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0], &pAd->MlmeAux.HtCapability, &pAd->MlmeAux.AddHtInfo);
- pAd->MlmeAux.HtCapabilityLen = sizeof(HT_CAPABILITY_IE);
- // Not turn pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE here.
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n"));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- pAd->MlmeAux.HtCapabilityLen = 0;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- }
- // temporarily not support QOS in IBSS
- NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
-
- AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
- AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeStartReqAction(ch= %d,sup rates= %d, ext rates=%d)\n",
- pAd->MlmeAux.Channel, pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
- }
- else
- {
- DBGPRINT_ERR(("SYNC - MlmeStartReqAction() sanity check fail.\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_INVALID_FORMAT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
- }
-}
-
-/*
- ==========================================================================
- Description:
- peer sends beacon back when scanning
- ==========================================================================
- */
-VOID PeerBeaconAtScanAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
- SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe;
- CF_PARM CfParm;
- USHORT BeaconPeriod, AtimWin, CapabilityInfo;
- PFRAME_802_11 pFrame;
- LARGE_INTEGER TimeStamp;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- USHORT LenVIE;
- UCHAR CkipFlag;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- ULONG RalinkIe;
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
-
- // NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00);
- pFrame = (PFRAME_802_11) Elem->Msg;
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
-#ifdef DOT11_N_SUPPORT
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-#endif // DOT11_N_SUPPORT //
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &CfParm,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- ULONG Idx;
- CHAR Rssi = 0;
-
- Idx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Idx != BSS_NOT_FOUND)
- Rssi = pAd->ScanTab.BssEntry[Idx].Rssi;
-
- Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
-
-#ifdef DOT11_N_SUPPORT
- if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
- HtCapabilityLen = SIZE_HT_CAP_IE;
-#endif // DOT11_N_SUPPORT //
- if ((pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) && (Channel == pAd->StaCfg.CCXScanChannel))
- {
- Idx = BssTableSetEntry(pAd, &pAd->StaCfg.CCXBssTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen,ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
- if (Idx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(pAd->StaCfg.CCXBssTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->StaCfg.CCXBssTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->StaCfg.CCXBssTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
- if (pAd->StaCfg.CCXReqType == MSRN_TYPE_BEACON_REQ)
- AironetAddBeaconReport(pAd, Idx, Elem);
- }
- }
- else
- {
- Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
- if (pAd->ChannelList[pAd->CommonCfg.ChannelListIdx].bEffectedChannel == TRUE)
- {
- UCHAR RegClass;
- PeerBeaconAndProbeRspSanity2(pAd, Elem->Msg, Elem->MsgLen, &RegClass);
- TriEventTableSetEntry(pAd, &pAd->CommonCfg.TriggerEventTab, Bssid, &HtCapability, HtCapabilityLen, RegClass, Channel);
- }
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
- if (Idx != BSS_NOT_FOUND)
- {
- NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
- }
- }
- }
- // sanity check fail, ignored
-}
-
-/*
- ==========================================================================
- Description:
- When waiting joining the (I)BSS, beacon received from external
- ==========================================================================
- */
-VOID PeerBeaconAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
- DtimCount, DtimPeriod, BcastFlag, NewChannel;
- LARGE_INTEGER TimeStamp;
- USHORT BeaconPeriod, AtimWin, CapabilityInfo;
- CF_PARM Cf;
- BOOLEAN TimerCancelled;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- UCHAR CkipFlag;
- USHORT LenVIE;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- USHORT Status;
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- ULONG RalinkIe;
- ULONG Idx;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-#ifdef DOT11_N_SUPPORT
- UCHAR CentralChannel;
-#endif // DOT11_N_SUPPORT //
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &Cf,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- // Disqualify 11b only adhoc when we are in 11g only adhoc mode
- if ((BssType == BSS_ADHOC) && (pAd->CommonCfg.PhyMode == PHY_11G) && ((SupRateLen+ExtRateLen)< 12))
- return;
-
- // BEACON from desired BSS/IBSS found. We should be able to decide most
- // BSS parameters here.
- // Q. But what happen if this JOIN doesn't conclude a successful ASSOCIATEION?
- // Do we need to receover back all parameters belonging to previous BSS?
- // A. Should be not. There's no back-door recover to previous AP. It still need
- // a new JOIN-AUTH-ASSOC sequence.
- if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n", Channel));
- RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
- // Update RSSI to prevent No signal display when cards first initialized
- pAd->StaCfg.RssiSample.LastRssi0 = ConvertToRssi(pAd, Elem->Rssi0, RSSI_0);
- pAd->StaCfg.RssiSample.LastRssi1 = ConvertToRssi(pAd, Elem->Rssi1, RSSI_1);
- pAd->StaCfg.RssiSample.LastRssi2 = ConvertToRssi(pAd, Elem->Rssi2, RSSI_2);
- pAd->StaCfg.RssiSample.AvgRssi0 = pAd->StaCfg.RssiSample.LastRssi0;
- pAd->StaCfg.RssiSample.AvgRssi0X8 = pAd->StaCfg.RssiSample.AvgRssi0 << 3;
- pAd->StaCfg.RssiSample.AvgRssi1 = pAd->StaCfg.RssiSample.LastRssi1;
- pAd->StaCfg.RssiSample.AvgRssi1X8 = pAd->StaCfg.RssiSample.AvgRssi1 << 3;
- pAd->StaCfg.RssiSample.AvgRssi2 = pAd->StaCfg.RssiSample.LastRssi2;
- pAd->StaCfg.RssiSample.AvgRssi2X8 = pAd->StaCfg.RssiSample.AvgRssi2 << 3;
-
- //
- // We need to check if SSID only set to any, then we can record the current SSID.
- // Otherwise will cause hidden SSID association failed.
- //
- if (pAd->MlmeAux.SsidLen == 0)
- {
- NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
- pAd->MlmeAux.SsidLen = SsidLen;
- }
- else
- {
- Idx = BssSsidTableSearch(&pAd->ScanTab, Bssid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Channel);
-
- if (Idx != BSS_NOT_FOUND)
- {
- //
- // Multiple SSID case, used correct CapabilityInfo
- //
- CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
- }
- }
- NdisMoveMemory(pAd->MlmeAux.Bssid, Bssid, MAC_ADDR_LEN);
- pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
- pAd->MlmeAux.BssType = BssType;
- pAd->MlmeAux.BeaconPeriod = BeaconPeriod;
- pAd->MlmeAux.Channel = Channel;
- pAd->MlmeAux.AtimWin = AtimWin;
- pAd->MlmeAux.CfpPeriod = Cf.CfpPeriod;
- pAd->MlmeAux.CfpMaxDuration = Cf.CfpMaxDuration;
- pAd->MlmeAux.APRalinkIe = RalinkIe;
-
- // Copy AP's supported rate to MlmeAux for creating assoication request
- // Also filter out not supported rate
- pAd->MlmeAux.SupRateLen = SupRateLen;
- NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
- pAd->MlmeAux.ExtRateLen = ExtRateLen;
- NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
- RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-
- NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, 16);
-#ifdef DOT11_N_SUPPORT
- pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
- pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
-
- // filter out un-supported ht rates
- if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
- {
- RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo, &AddHtInfo, SIZE_ADD_HT_INFO_IE);
-
- // StaActive.SupportedHtPhy.MCSSet stores Peer AP's 11n Rx capability
- NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, HtCapability.MCSSet, 16);
- pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
- pAd->MlmeAux.HtCapabilityLen = SIZE_HT_CAP_IE;
- pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
- if (PreNHtCapabilityLen > 0)
- pAd->StaActive.SupportedPhyInfo.bPreNHt = TRUE;
- RTMPCheckHt(pAd, BSSID_WCID, &HtCapability, &AddHtInfo);
- // Copy AP Parameter to StaActive. This is also in LinkUp.
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
- pAd->StaActive.SupportedHtPhy.MpduDensity, pAd->StaActive.SupportedHtPhy.MaxRAmpduFactor, HtCapability.HtCapInfo.ChannelWidth));
-
- if (AddHtInfoLen > 0)
- {
- CentralChannel = AddHtInfo.ControlChan;
- // Check again the Bandwidth capability of this AP.
- if ((AddHtInfo.ControlChan > 2)&& (AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- CentralChannel = AddHtInfo.ControlChan - 2;
- }
- else if ((AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
- {
- CentralChannel = AddHtInfo.ControlChan + 2;
- }
-
- // Check Error .
- if (pAd->MlmeAux.CentralChannel != CentralChannel)
- DBGPRINT(RT_DEBUG_ERROR, ("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n", CentralChannel, AddHtInfo.ControlChan, pAd->MlmeAux.CentralChannel));
-
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d, .\n", CentralChannel, AddHtInfo.ControlChan));
-
- }
-
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // To prevent error, let legacy AP must have same CentralChannel and Channel.
- if ((HtCapabilityLen == 0) && (PreNHtCapabilityLen == 0))
- pAd->MlmeAux.CentralChannel = pAd->MlmeAux.Channel;
-
- pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
- RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
- RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo, SIZE_ADD_HT_INFO_IE);
- }
-
- RTMPUpdateMlmeRate(pAd);
-
- // copy QOS related information
- if ((pAd->CommonCfg.bWmmCapable)
-#ifdef DOT11_N_SUPPORT
- || (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-#endif // DOT11_N_SUPPORT //
- )
- {
- NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, &EdcaParm, sizeof(EDCA_PARM));
- NdisMoveMemory(&pAd->MlmeAux.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisMoveMemory(&pAd->MlmeAux.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
- else
- {
- NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
- pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
-
-#ifdef LEAP_SUPPORT
- // Update CkipFlag
- pAd->StaCfg.CkipFlag = CkipFlag;
-
- // Keep TimeStamp for Re-Association used.
- if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
- pAd->StaCfg.CCKMBeaconAtJoinTimeStamp = TimeStamp;
-#endif // LEAP_SUPPORT //
-
- if (AironetCellPowerLimit != 0xFF)
- {
- //We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power
- ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
- }
- else //Used the default TX Power Percentage.
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
-
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_SUCCESS;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
- }
- // not to me BEACON, ignored
- }
- // sanity check fail, ignore this frame
-}
-
-/*
- ==========================================================================
- Description:
- receive BEACON from peer
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID PeerBeacon(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
- CHAR Ssid[MAX_LEN_OF_SSID];
- CF_PARM CfParm;
- UCHAR SsidLen, MessageToMe=0, BssType, Channel, NewChannel, index=0;
- UCHAR DtimCount=0, DtimPeriod=0, BcastFlag=0;
- USHORT CapabilityInfo, AtimWin, BeaconPeriod;
- LARGE_INTEGER TimeStamp;
- USHORT TbttNumToNextWakeUp;
- UCHAR Erp;
- UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
- UCHAR SupRateLen, ExtRateLen;
- UCHAR CkipFlag;
- USHORT LenVIE;
- UCHAR AironetCellPowerLimit;
- EDCA_PARM EdcaParm;
- QBSS_LOAD_PARM QbssLoad;
- QOS_CAPABILITY_PARM QosCapability;
- ULONG RalinkIe;
- // New for WPA security suites
- UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
- NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
- HT_CAPABILITY_IE HtCapability;
- ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
- UCHAR HtCapabilityLen, PreNHtCapabilityLen;
- UCHAR AddHtInfoLen;
- UCHAR NewExtChannelOffset = 0xff;
-
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
- if (!(INFRA_ON(pAd) || ADHOC_ON(pAd)
- ))
- return;
-
- // Init Variable IE structure
- pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
- pVIE->Length = 0;
- RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
- RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-
- if (PeerBeaconAndProbeRspSanity(pAd,
- Elem->Msg,
- Elem->MsgLen,
- Elem->Channel,
- Addr2,
- Bssid,
- Ssid,
- &SsidLen,
- &BssType,
- &BeaconPeriod,
- &Channel,
- &NewChannel,
- &TimeStamp,
- &CfParm,
- &AtimWin,
- &CapabilityInfo,
- &Erp,
- &DtimCount,
- &DtimPeriod,
- &BcastFlag,
- &MessageToMe,
- SupRate,
- &SupRateLen,
- ExtRate,
- &ExtRateLen,
- &CkipFlag,
- &AironetCellPowerLimit,
- &EdcaParm,
- &QbssLoad,
- &QosCapability,
- &RalinkIe,
- &HtCapabilityLen,
- &PreNHtCapabilityLen,
- &HtCapability,
- &AddHtInfoLen,
- &AddHtInfo,
- &NewExtChannelOffset,
- &LenVIE,
- pVIE))
- {
- BOOLEAN is_my_bssid, is_my_ssid;
- ULONG Bssidx, Now;
- BSS_ENTRY *pBss;
- CHAR RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
- is_my_bssid = MAC_ADDR_EQUAL(Bssid, pAd->CommonCfg.Bssid)? TRUE : FALSE;
- is_my_ssid = SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen)? TRUE:FALSE;
-
-
- // ignore BEACON not for my SSID
- if ((! is_my_ssid) && (! is_my_bssid))
- return;
-
- // It means STA waits disassoc completely from this AP, ignores this beacon.
- if (pAd->Mlme.CntlMachine.CurrState == CNTL_WAIT_DISASSOC)
- return;
-
-#ifdef DOT11_N_SUPPORT
- // Copy Control channel for this BSSID.
- if (AddHtInfoLen != 0)
- Channel = AddHtInfo.ControlChan;
-
- if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
- HtCapabilityLen = SIZE_HT_CAP_IE;
-#endif // DOT11_N_SUPPORT //
-
- //
- // Housekeeping "SsidBssTab" table for later-on ROAMing usage.
- //
- Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- // discover new AP of this network, create BSS entry
- Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,
- &HtCapability, &AddHtInfo,HtCapabilityLen,AddHtInfoLen,NewExtChannelOffset, Channel,
- RealRssi, TimeStamp, CkipFlag, &EdcaParm, &QosCapability,
- &QbssLoad, LenVIE, pVIE);
- if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
- return;
-
- NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF, &Elem->Msg[24], 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
- NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
-
-
-
- }
-
- if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
- {
- // Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection).
- // In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results.
- AsicSwitchChannel(pAd, 1, FALSE);
- AsicLockChannel(pAd, 1);
- LinkDown(pAd, FALSE);
- MlmeQueueInit(&pAd->Mlme.Queue);
- BssTableInit(&pAd->ScanTab);
- RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
-
- // channel sanity check
- for (index = 0 ; index < pAd->ChannelListNum; index++)
- {
- if (pAd->ChannelList[index].Channel == NewChannel)
- {
- pAd->ScanTab.BssEntry[Bssidx].Channel = NewChannel;
- pAd->CommonCfg.Channel = NewChannel;
- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("PeerBeacon - STA receive channel switch announcement IE (New Channel =%d)\n", NewChannel));
- break;
- }
- }
-
- if (index >= pAd->ChannelListNum)
- {
- DBGPRINT_ERR(("PeerBeacon(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum));
- }
- }
-
- // if the ssid matched & bssid unmatched, we should select the bssid with large value.
- // This might happened when two STA start at the same time
- if ((! is_my_bssid) && ADHOC_ON(pAd))
- {
- INT i;
-
- // Add the safeguard against the mismatch of adhoc wep status
- if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Not matched wep status %d %d\n", pAd->StaCfg.WepStatus, pAd->ScanTab.BssEntry[Bssidx].WepStatus));
- DBGPRINT(RT_DEBUG_TRACE, ("bssid=%s\n", pAd->ScanTab.BssEntry[Bssidx].Bssid));
- return;
- }
-
- // collapse into the ADHOC network which has bigger BSSID value.
- for (i = 0; i < 6; i++)
- {
- if (Bssid[i] > pAd->CommonCfg.Bssid[i])
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- AsicDisableSync(pAd);
- COPY_MAC_ADDR(pAd->CommonCfg.Bssid, Bssid);
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
- MakeIbssBeacon(pAd); // re-build BEACON frame
- AsicEnableIbssSync(pAd); // copy BEACON frame to on-chip memory
- is_my_bssid = TRUE;
- break;
- }
- else if (Bssid[i] < pAd->CommonCfg.Bssid[i])
- break;
- }
- }
-
-
- NdisGetSystemUpTime(&Now);
- pBss = &pAd->ScanTab.BssEntry[Bssidx];
- pBss->Rssi = RealRssi; // lastest RSSI
- pBss->LastBeaconRxTime = Now; // last RX timestamp
-
- //
- // BEACON from my BSSID - either IBSS or INFRA network
- //
- if (is_my_bssid)
- {
- RXWI_STRUC RxWI;
-
- pAd->StaCfg.DtimCount = DtimCount;
- pAd->StaCfg.DtimPeriod = DtimPeriod;
- pAd->StaCfg.LastBeaconRxTime = Now;
-
-
- RxWI.RSSI0 = Elem->Rssi0;
- RxWI.RSSI1 = Elem->Rssi1;
- RxWI.RSSI2 = Elem->Rssi2;
-
- Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, &RxWI);
- if (AironetCellPowerLimit != 0xFF)
- {
- //
- // We get the Cisco (ccx) "TxPower Limit" required
- // Changed to appropriate TxPower Limit for Ciso Compatible Extensions
- //
- ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
- }
- else
- {
- //
- // AironetCellPowerLimit equal to 0xFF means the Cisco (ccx) "TxPower Limit" not exist.
- // Used the default TX Power Percentage, that set from UI.
- //
- pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
- }
-
- if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
- {
- UCHAR MaxSupportedRateIn500Kbps = 0;
- UCHAR idx;
- MAC_TABLE_ENTRY *pEntry;
-
- // supported rates array may not be sorted. sort it and find the maximum rate
- for (idx=0; idx<SupRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
- }
-
- for (idx=0; idx<ExtRateLen; idx++)
- {
- if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
- MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
- }
-
- // look up the existing table
- pEntry = MacTableLookup(pAd, Addr2);
-
- // Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon.
- // To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station.
- if ((ADHOC_ON(pAd) && (Elem->Wcid == RESERVED_WCID)) ||
- (pEntry && ((pEntry->LastBeaconRxTime + ADHOC_ENTRY_BEACON_LOST_TIME) < Now)))
- {
- if (pEntry == NULL)
- // Another adhoc joining, add to our MAC table.
- pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);
-
- if (StaAddMacTableEntry(pAd, pEntry, MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo) == FALSE)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
- return;
- }
-
- if (pEntry &&
- (Elem->Wcid == RESERVED_WCID))
- {
- idx = pAd->StaCfg.DefaultKeyId;
- RT28XX_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry);
- }
- }
-
- if (pEntry && pEntry->ValidAsCLI)
- pEntry->LastBeaconRxTime = Now;
-
- // At least another peer in this IBSS, declare MediaState as CONNECTED
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
- pAd->IndicateMediaState = NdisMediaStateConnected;
- RTMP_IndicateMediaState(pAd);
- pAd->ExtraInfo = GENERAL_LINK_UP;
- AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-
- // 2003/03/12 - john
- // Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that
- // "site survey" result should always include the current connected network.
- //
- Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
- if (Bssidx == BSS_NOT_FOUND)
- {
- Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
- &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
- &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0,
- &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
- }
- }
-
- if (INFRA_ON(pAd))
- {
- BOOLEAN bUseShortSlot, bUseBGProtection;
-
- // decide to use/change to -
- // 1. long slot (20 us) or short slot (9 us) time
- // 2. turn on/off RTS/CTS and/or CTS-to-self protection
- // 3. short preamble
-
- //bUseShortSlot = pAd->CommonCfg.bUseShortSlotTime && CAP_IS_SHORT_SLOT(CapabilityInfo);
- bUseShortSlot = CAP_IS_SHORT_SLOT(CapabilityInfo);
- if (bUseShortSlot != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
- AsicSetSlotTime(pAd, bUseShortSlot);
-
- bUseBGProtection = (pAd->CommonCfg.UseBGProtection == 1) || // always use
- ((pAd->CommonCfg.UseBGProtection == 0) && ERP_IS_USE_PROTECTION(Erp));
-
- if (pAd->CommonCfg.Channel > 14) // always no BG protection in A-band. falsely happened when switching A/G band to a dual-band AP
- bUseBGProtection = FALSE;
-
- if (bUseBGProtection != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
- {
- if (bUseBGProtection)
- {
- OPSTATUS_SET_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),FALSE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
- }
- else
- {
- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),TRUE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
- }
-
- DBGPRINT(RT_DEBUG_WARN, ("SYNC - AP changed B/G protection to %d\n", bUseBGProtection));
- }
-
-#ifdef DOT11_N_SUPPORT
- // check Ht protection mode. and adhere to the Non-GF device indication by AP.
- if ((AddHtInfoLen != 0) &&
- ((AddHtInfo.AddHtInfo2.OperaionMode != pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode) ||
- (AddHtInfo.AddHtInfo2.NonGfPresent != pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent)))
- {
- pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent = AddHtInfo.AddHtInfo2.NonGfPresent;
- pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode = AddHtInfo.AddHtInfo2.OperaionMode;
- if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
- {
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
- }
- else
- AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP changed N OperaionMode to %d\n", pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode));
- }
-#endif // DOT11_N_SUPPORT //
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) &&
- ERP_IS_USE_BARKER_PREAMBLE(Erp))
- {
- MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP forced to use LONG preamble\n"));
- }
-
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
- (EdcaParm.bValid == TRUE) &&
- (EdcaParm.EdcaUpdateCount != pAd->CommonCfg.APEdcaParm.EdcaUpdateCount))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP change EDCA parameters(from %d to %d)\n",
- pAd->CommonCfg.APEdcaParm.EdcaUpdateCount,
- EdcaParm.EdcaUpdateCount));
- AsicSetEdcaParm(pAd, &EdcaParm);
- }
-
- // copy QOS related information
- NdisMoveMemory(&pAd->CommonCfg.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
- NdisMoveMemory(&pAd->CommonCfg.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
- }
-
- // only INFRASTRUCTURE mode support power-saving feature
- if ((INFRA_ON(pAd) && (pAd->StaCfg.Psm == PWR_SAVE)) || (pAd->CommonCfg.bAPSDForcePowerSave))
- {
- UCHAR FreeNumber;
- // 1. AP has backlogged unicast-to-me frame, stay AWAKE, send PSPOLL
- // 2. AP has backlogged broadcast/multicast frame and we want those frames, stay AWAKE
- // 3. we have outgoing frames in TxRing or MgmtRing, better stay AWAKE
- // 4. Psm change to PWR_SAVE, but AP not been informed yet, we better stay AWAKE
- // 5. otherwise, put PHY back to sleep to save battery.
- if (MessageToMe)
- {
- if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
- pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
- {
- pAd->CommonCfg.bNeedSendTriggerFrame = TRUE;
- }
- else
- RT28XX_PS_POLL_ENQUEUE(pAd);
- }
- else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
- {
- }
- else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_VI].Number != 0) ||
- (pAd->TxSwQueue[QID_AC_VO].Number != 0) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_BK, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_BE, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_VI, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_AC_VO, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
- (RTMPFreeTXDRequest(pAd, QID_MGMT, MGMT_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS))
- {
- // TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
- // can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
- }
- else
- {
- USHORT NextDtim = DtimCount;
-
- if (NextDtim == 0)
- NextDtim = DtimPeriod;
-
- TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
- TbttNumToNextWakeUp = NextDtim;
-
- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
- {
- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
- }
- }
- }
- }
- // not my BSSID, ignore it
- }
- // sanity check fail, ignore this frame
-}
-
-/*
- ==========================================================================
- Description:
- Receive PROBE REQ from remote peer when operating in IBSS mode
- ==========================================================================
- */
-VOID PeerProbeReqAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- UCHAR Addr2[MAC_ADDR_LEN];
- CHAR Ssid[MAX_LEN_OF_SSID];
- UCHAR SsidLen;
-#ifdef DOT11_N_SUPPORT
- UCHAR HtLen, AddHtLen, NewExtLen;
-#endif // DOT11_N_SUPPORT //
- HEADER_802_11 ProbeRspHdr;
- NDIS_STATUS NStatus;
- PUCHAR pOutBuffer = NULL;
- ULONG FrameLen = 0;
- LARGE_INTEGER FakeTimestamp;
- UCHAR DsLen = 1, IbssLen = 2;
- UCHAR LocalErpIe[3] = {IE_ERP, 1, 0};
- BOOLEAN Privacy;
- USHORT CapabilityInfo;
- UCHAR RSNIe = IE_WPA;
-
- if (! ADHOC_ON(pAd))
- return;
-
- if (PeerProbeReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen))
- {
- if ((SsidLen == 0) || SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
- {
- // allocate and send out ProbeRsp frame
- NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NStatus != NDIS_STATUS_SUCCESS)
- return;
-
- //pAd->StaCfg.AtimWin = 0; // ??????
-
- Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
- CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &ProbeRspHdr,
- TIMESTAMP_LEN, &FakeTimestamp,
- 2, &pAd->CommonCfg.BeaconPeriod,
- 2, &CapabilityInfo,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &pAd->StaActive.SupRateLen,
- pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
- 1, &DsIe,
- 1, &DsLen,
- 1, &pAd->CommonCfg.Channel,
- 1, &IbssIe,
- 1, &IbssLen,
- 2, &pAd->StaActive.AtimWin,
- END_OF_ARGS);
-
- if (pAd->StaActive.ExtRateLen)
- {
- ULONG tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 3, LocalErpIe,
- 1, &ExtRateIe,
- 1, &pAd->StaActive.ExtRateLen,
- pAd->StaActive.ExtRateLen, &pAd->StaActive.ExtRate,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-
- // If adhoc secruity is set for WPA-None, append the cipher suite IE
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- ULONG tmp;
- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
- 1, &RSNIe,
- 1, &pAd->StaCfg.RSNIE_Len,
- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
- END_OF_ARGS);
- FrameLen += tmp;
- }
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- {
- ULONG TmpLen;
- UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
- HtLen = sizeof(pAd->CommonCfg.HtCapability);
- AddHtLen = sizeof(pAd->CommonCfg.AddHTInfo);
- NewExtLen = 1;
- //New extension channel offset IE is included in Beacon, Probe Rsp or channel Switch Announcement Frame
- if (pAd->bBroadComHT == TRUE)
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &WpaIe,
- 4, &BROADCOM[0],
- pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
- END_OF_ARGS);
- }
- else
- {
- MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
- 1, &HtCapIe,
- 1, &HtLen,
- sizeof(HT_CAPABILITY_IE), &pAd->CommonCfg.HtCapability,
- 1, &AddHtInfoIe,
- 1, &AddHtLen,
- sizeof(ADD_HT_INFO_IE), &pAd->CommonCfg.AddHTInfo,
- 1, &NewExtChanIe,
- 1, &NewExtLen,
- sizeof(NEW_EXT_CHAN_IE), &pAd->CommonCfg.NewExtChanOffset,
- END_OF_ARGS);
- }
- FrameLen += TmpLen;
- }
-#endif // DOT11_N_SUPPORT //
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
- }
-}
-
-VOID BeaconTimeoutAtJoinAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeoutAtJoinAction\n"));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_REJ_TIMEOUT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- Scan timeout procedure. basically add channel index by 1 and rescan
- ==========================================================================
- */
-VOID ScanTimeoutAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- pAd->MlmeAux.Channel = NextChannel(pAd, pAd->MlmeAux.Channel);
-
- // Only one channel scanned for CISCO beacon request
- if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
- (pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
- pAd->MlmeAux.Channel = 0;
-
- // this routine will stop if pAd->MlmeAux.Channel == 0
- ScanNextChannel(pAd);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenScan(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenJoin(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID InvalidStateWhenStart(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- USHORT Status;
- DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
- pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
- Status = MLME_STATE_MACHINE_REJECT;
- MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
-}
-
-/*
- ==========================================================================
- Description:
-
- IRQL = DISPATCH_LEVEL
-
- ==========================================================================
- */
-VOID EnqueuePsPoll(
- IN PRTMP_ADAPTER pAd)
-{
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- return;
- }
-#endif // RALINK_ATE //
-
-
- if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP)
- pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
- MiniportMMRequest(pAd, 0, (PUCHAR)&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
-}
-
-
-/*
- ==========================================================================
- Description:
- ==========================================================================
- */
-VOID EnqueueProbeRequest(
- IN PRTMP_ADAPTER pAd)
-{
- NDIS_STATUS NState;
- PUCHAR pOutBuffer;
- ULONG FrameLen = 0;
- HEADER_802_11 Hdr80211;
-
- DBGPRINT(RT_DEBUG_TRACE, ("force out a ProbeRequest ...\n"));
-
- NState = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
- if (NState == NDIS_STATUS_SUCCESS)
- {
- MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
-
- // this ProbeRequest explicitly specify SSID to reduce unwanted ProbeResponse
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- sizeof(HEADER_802_11), &Hdr80211,
- 1, &SsidIe,
- 1, &pAd->CommonCfg.SsidLen,
- pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
- 1, &SupRateIe,
- 1, &pAd->StaActive.SupRateLen,
- pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
- END_OF_ARGS);
- MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
- }
-
-}
-
-#ifdef DOT11_N_SUPPORT
-#ifdef DOT11N_DRAFT3
-VOID BuildEffectedChannelList(
- IN PRTMP_ADAPTER pAd)
-{
- UCHAR EChannel[11];
- UCHAR i, j, k;
- UCHAR UpperChannel = 0, LowerChannel = 0;
-
- RTMPZeroMemory(EChannel, 11);
- i = 0;
- // Find upper channel and lower channel.
- if (pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
- {
- UpperChannel = pAd->CommonCfg.Channel;
- LowerChannel = pAd->CommonCfg.CentralChannel;
- }
- else if (pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
- {
- UpperChannel = pAd->CommonCfg.CentralChannel;
- LowerChannel = pAd->CommonCfg.Channel;
- }
- else
- {
- return;
- }
-
- // Record channels that is below lower channel..
- if (LowerChannel > 1)
- {
- EChannel[0] = LowerChannel - 1;
- i = 1;
- if (LowerChannel > 2)
- {
- EChannel[1] = LowerChannel - 2;
- i = 2;
- if (LowerChannel > 3)
- {
- EChannel[2] = LowerChannel - 3;
- i = 3;
- }
- }
- }
- // Record channels that is between lower channel and upper channel.
- for (k = LowerChannel;k < UpperChannel;k++)
- {
- EChannel[i] = k;
- i++;
- }
- // Record channels that is above upper channel..
- if (LowerChannel < 11)
- {
- EChannel[i] = UpperChannel + 1;
- i++;
- if (LowerChannel < 10)
- {
- EChannel[i] = LowerChannel + 2;
- i++;
- if (LowerChannel < 9)
- {
- EChannel[i] = LowerChannel + 3;
- i++;
- }
- }
- }
- //
- for (j = 0;j < i;j++)
- {
- for (k = 0;k < pAd->ChannelListNum;k++)
- {
- if (pAd->ChannelList[k].Channel == EChannel[j])
- {
- pAd->ChannelList[k].bEffectedChannel = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,(" EffectedChannel( =%d)\n", EChannel[j]));
- break;
- }
- }
- }
-}
-#endif // DOT11N_DRAFT3 //
-#endif // DOT11_N_SUPPORT //
-
-BOOLEAN ScanRunning(
- IN PRTMP_ADAPTER pAd)
-{
- return (pAd->Mlme.SyncMachine.CurrState == SCAN_LISTEN) ? TRUE : FALSE;
-}
-
+#include "../../rt2870/sta/sync.c"
diff --git a/drivers/staging/rt3070/sta/wpa.c b/drivers/staging/rt3070/sta/wpa.c
index 63d08306bf6f..95543bb1f0ec 100644
--- a/drivers/staging/rt3070/sta/wpa.c
+++ b/drivers/staging/rt3070/sta/wpa.c
@@ -1,2099 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- wpa.c
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Jan Lee 03-07-22 Initial
- Paul Lin 03-11-28 Modify for supplicant
-*/
-#include "../rt_config.h"
-
-#define WPARSNIE 0xdd
-#define WPA2RSNIE 0x30
-
-//extern UCHAR BIT8[];
-UCHAR CipherWpaPskTkip[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x02 // authentication
- };
-UCHAR CipherWpaPskTkipLen = (sizeof(CipherWpaPskTkip) / sizeof(UCHAR));
-
-UCHAR CipherWpaPskAes[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x04, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x04, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x02 // authentication
- };
-UCHAR CipherWpaPskAesLen = (sizeof(CipherWpaPskAes) / sizeof(UCHAR));
-
-UCHAR CipherSuiteCiscoCCKM[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x40, 0x96, 0x01, // Multicast
- 0x01, 0x00, // Number of uicast
- 0x00, 0x40, 0x96, 0x01, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x40, 0x96, 0x00 // Authentication
- };
-UCHAR CipherSuiteCiscoCCKMLen = (sizeof(CipherSuiteCiscoCCKM) / sizeof(UCHAR));
-
-UCHAR CipherSuiteCiscoCCKM24[] = {
- 0xDD, 0x18, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x40, 0x96, 0x01, // Multicast
- 0x01, 0x00, // Number of uicast
- 0x00, 0x40, 0x96, 0x01, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x40, 0x96, 0x00,
- 0x28, 0x00// Authentication
- };
-
-UCHAR CipherSuiteCiscoCCKM24Len = (sizeof(CipherSuiteCiscoCCKM24) / sizeof(UCHAR));
-
-UCHAR CipherSuiteCCXTkip[] = {
- 0xDD, 0x16, // RSN IE
- 0x00, 0x50, 0xf2, 0x01, // oui
- 0x01, 0x00, // Version
- 0x00, 0x50, 0xf2, 0x02, // Multicast
- 0x01, 0x00, // Number of unicast
- 0x00, 0x50, 0xf2, 0x02, // unicast
- 0x01, 0x00, // number of authentication method
- 0x00, 0x50, 0xf2, 0x01 // authentication
- };
-UCHAR CipherSuiteCCXTkipLen = (sizeof(CipherSuiteCCXTkip) / sizeof(UCHAR));
-
-UCHAR CCX_LLC_HDR[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02};
-UCHAR LLC_NORMAL[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-
-UCHAR EAPOL_FRAME[] = {0x88, 0x8E};
-
-BOOLEAN CheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- OUT UCHAR *Offset);
-
-void inc_byte_array(UCHAR *counter, int len);
-
-/*
- ========================================================================
-
- Routine Description:
- Classify WPA EAP message type
-
- Arguments:
- EAPType Value of EAP message type
- MsgType Internal Message definition for MLME state machine
-
- Return Value:
- TRUE Found appropriate message type
- FALSE No appropriate message type
-
- IRQL = DISPATCH_LEVEL
-
- Note:
- All these constants are defined in wpa.h
- For supplicant, there is only EAPOL Key message avaliable
-
- ========================================================================
-*/
-BOOLEAN WpaMsgTypeSubst(
- IN UCHAR EAPType,
- OUT INT *MsgType)
-{
- switch (EAPType)
- {
- case EAPPacket:
- *MsgType = MT2_EAPPacket;
- break;
- case EAPOLStart:
- *MsgType = MT2_EAPOLStart;
- break;
- case EAPOLLogoff:
- *MsgType = MT2_EAPOLLogoff;
- break;
- case EAPOLKey:
- *MsgType = MT2_EAPOLKey;
- break;
- case EAPOLASFAlert:
- *MsgType = MT2_EAPOLASFAlert;
- break;
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- association state machine init, including state transition and timer init
- Parameters:
- S - pointer to the association state machine
- ==========================================================================
- */
-VOID WpaPskStateMachineInit(
- IN PRTMP_ADAPTER pAd,
- IN STATE_MACHINE *S,
- OUT STATE_MACHINE_FUNC Trans[])
-{
- StateMachineInit(S, Trans, MAX_WPA_PSK_STATE, MAX_WPA_PSK_MSG, (STATE_MACHINE_FUNC)Drop, WPA_PSK_IDLE, WPA_MACHINE_BASE);
- StateMachineSetAction(S, WPA_PSK_IDLE, MT2_EAPOLKey, (STATE_MACHINE_FUNC)WpaEAPOLKeyAction);
-}
-
-/*
- ==========================================================================
- Description:
- This is state machine function.
- When receiving EAPOL packets which is for 802.1x key management.
- Use both in WPA, and WPAPSK case.
- In this function, further dispatch to different functions according to the received packet. 3 categories are :
- 1. normal 4-way pairwisekey and 2-way groupkey handshake
- 2. MIC error (Countermeasures attack) report packet from STA.
- 3. Request for pairwise/group key update from STA
- Return:
- ==========================================================================
-*/
-VOID WpaEAPOLKeyAction(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- INT MsgType = EAPOL_MSG_INVALID;
- PKEY_DESCRIPTER pKeyDesc;
- PHEADER_802_11 pHeader; //red
- UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
- UCHAR EapolVr;
- KEY_INFO peerKeyInfo;
-
- DBGPRINT(RT_DEBUG_TRACE, ("-----> WpaEAPOLKeyAction\n"));
-
- // Get 802.11 header first
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Get EAPoL-Key Descriptor
- pKeyDesc = (PKEY_DESCRIPTER) &Elem->Msg[(LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H)];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pKeyDesc->KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT *)&peerKeyInfo) = cpu2le16(*((USHORT *)&peerKeyInfo));
-
-
- // 1. Check EAPOL frame version and type
- EapolVr = (UCHAR) Elem->Msg[LENGTH_802_11+LENGTH_802_1_H];
-
- if (((EapolVr != EAPOL_VER) && (EapolVr != EAPOL_VER2)) || ((pKeyDesc->Type != WPA1_KEY_DESC) && (pKeyDesc->Type != WPA2_KEY_DESC)))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("Key descripter does not match with WPA rule\n"));
- return;
- }
-
- // First validate replay counter, only accept message with larger replay counter
- // Let equal pass, some AP start with all zero replay counter
- NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
-
- if((RTMPCompareMemory(pKeyDesc->ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
- (RTMPCompareMemory(pKeyDesc->ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" ReplayCounter not match \n"));
- return;
- }
-
- // Process WPA2PSK frame
- if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.EKD_DL == 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 0) &&
- (peerKeyInfo.Secure == 0) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 1\n"));
- } else if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.EKD_DL == 1) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 1) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_3;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 3\n"));
- } else if((peerKeyInfo.KeyType == GROUPKEY) &&
- (peerKeyInfo.EKD_DL == 1) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 1) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_GROUP_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Group Message 1\n"));
- }
-
- // We will assume link is up (assoc suceess and port not secured).
- // All state has to be able to process message from previous state
- switch(pAd->StaCfg.WpaState)
- {
- case SS_START:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- Wpa2PairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- break;
-
- case SS_WAIT_MSG_3:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- Wpa2PairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- Wpa2PairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- }
- break;
-
- case SS_WAIT_GROUP: // When doing group key exchange
- case SS_FINISH: // This happened when update group key
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- Wpa2PairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- Wpa2PairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- }
- else if(MsgType == EAPOL_GROUP_MSG_1)
- {
- WpaGroupMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
- break;
-
- default:
- break;
- }
- }
- // Process WPAPSK Frame
- // Classify message Type, either pairwise message 1, 3, or group message 1 for supplicant
- else if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- {
- if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.KeyIndex == 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 0) &&
- (peerKeyInfo.Secure == 0) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 1\n"));
- }
- else if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
- (peerKeyInfo.KeyIndex == 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 0) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_PAIR_MSG_3;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 3\n"));
- }
- else if((peerKeyInfo.KeyType == GROUPKEY) &&
- (peerKeyInfo.KeyIndex != 0) &&
- (peerKeyInfo.KeyAck == 1) &&
- (peerKeyInfo.KeyMic == 1) &&
- (peerKeyInfo.Secure == 1) &&
- (peerKeyInfo.Error == 0) &&
- (peerKeyInfo.Request == 0))
- {
- MsgType = EAPOL_GROUP_MSG_1;
- DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Group Message 1\n"));
- }
-
- // We will assume link is up (assoc suceess and port not secured).
- // All state has to be able to process message from previous state
- switch(pAd->StaCfg.WpaState)
- {
- case SS_START:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- WpaPairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- break;
-
- case SS_WAIT_MSG_3:
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- WpaPairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- WpaPairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- }
- break;
-
- case SS_WAIT_GROUP: // When doing group key exchange
- case SS_FINISH: // This happened when update group key
- if(MsgType == EAPOL_PAIR_MSG_1)
- {
- WpaPairMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- }
- else if(MsgType == EAPOL_PAIR_MSG_3)
- {
- WpaPairMsg3Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_WAIT_GROUP;
- // Reset port secured variable
- pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- }
- else if(MsgType == EAPOL_GROUP_MSG_1)
- {
- WpaGroupMsg1Action(pAd, Elem);
- pAd->StaCfg.WpaState = SS_FINISH;
- }
- break;
-
- default:
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<----- WpaEAPOLKeyAction\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process Pairwise key 4-way handshaking
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaPairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PHEADER_802_11 pHeader;
- UCHAR *mpool, *PTK, *digest;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- PEAPOL_PACKET pMsg1;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg1Action ----->\n"));
-
- // allocate memory pool
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 256);
-
- if (mpool == NULL)
- return;
-
- // PTK Len = 80.
- PTK = (UCHAR *) ROUND_UP(mpool, 4);
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(PTK + 80, 4);
-
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Process message 1 from authenticator
- pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- // 1. Save Replay counter, it will use to verify message 3 and construct message 2
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 2. Save ANonce
- NdisMoveMemory(pAd->StaCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
-
- // Generate random SNonce
- GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce);
-
- // Calc PTK(ANonce, SNonce)
- WpaCountPTK(pAd,
- pAd->StaCfg.PMK,
- pAd->StaCfg.ANonce,
- pAd->CommonCfg.Bssid,
- pAd->StaCfg.SNonce,
- pAd->CurrentAddress,
- PTK,
- LEN_PTK);
-
- // Save key to PTK entry
- NdisMoveMemory(pAd->StaCfg.PTK, PTK, LEN_PTK);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero Message 2 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- //
- // Message 2 as EAPOL-Key(0,1,0,0,0,P,0,SNonce,MIC,RSN IE)
- //
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- // 1. Key descriptor version and appropriate RSN IE
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- // fill in Data Material and its length
- Packet.KeyDesc.KeyData[0] = IE_WPA;
- Packet.KeyDesc.KeyData[1] = pAd->StaCfg.RSNIE_Len;
- Packet.KeyDesc.KeyDataLen[1] = pAd->StaCfg.RSNIE_Len + 2;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[2], pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
-
- // Update packet length after decide Key data payload
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + Packet.KeyDesc.KeyDataLen[1];
-
- // Update Key length
- Packet.KeyDesc.KeyLength[0] = pMsg1->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pMsg1->KeyDesc.KeyLength[1];
- // 2. Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // 3. KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- //Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
-
- // 4. Fill SNonce
- NdisMoveMemory(Packet.KeyDesc.KeyNonce, pAd->StaCfg.SNonce, LEN_KEY_DESC_NONCE);
-
- // 5. Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Send EAPOL(0, 1, 0, 0, 0, P, 0, SNonce, MIC, RSN_IE)
- // Out buffer for transmitting message 2
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- os_free_mem(pAd, mpool);
- return;
- }
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // 6. Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
-
- HMAC_SHA1(pOutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- hmac_md5(PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- //hex_dump("MIC", Mic, LEN_KEY_DESC_MIC);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // 5. Copy frame to Tx ring and send Msg 2 to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
- os_free_mem(pAd, (PUCHAR)mpool);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg1Action <-----\n"));
-}
-
-VOID Wpa2PairMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PHEADER_802_11 pHeader;
- UCHAR *mpool, *PTK, *digest;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- PEAPOL_PACKET pMsg1;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
-
- DBGPRINT(RT_DEBUG_TRACE, ("Wpa2PairMsg1Action ----->\n"));
-
- // allocate memory pool
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 256);
-
- if (mpool == NULL)
- return;
-
- // PTK Len = 80.
- PTK = (UCHAR *) ROUND_UP(mpool, 4);
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(PTK + 80, 4);
-
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Process message 1 from authenticator
- pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- // 1. Save Replay counter, it will use to verify message 3 and construct message 2
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 2. Save ANonce
- NdisMoveMemory(pAd->StaCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
-
- // Generate random SNonce
- GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce);
-
- if(pMsg1->KeyDesc.KeyDataLen[1] > 0 )
- {
- // cached PMKID
- }
-
- // Calc PTK(ANonce, SNonce)
- WpaCountPTK(pAd,
- pAd->StaCfg.PMK,
- pAd->StaCfg.ANonce,
- pAd->CommonCfg.Bssid,
- pAd->StaCfg.SNonce,
- pAd->CurrentAddress,
- PTK,
- LEN_PTK);
-
- // Save key to PTK entry
- NdisMoveMemory(pAd->StaCfg.PTK, PTK, LEN_PTK);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message 2 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- //
- // Message 2 as EAPOL-Key(0,1,0,0,0,P,0,SNonce,MIC,RSN IE)
- //
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
-
- // 1. Key descriptor version and appropriate RSN IE
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- // fill in Data Material and its length
- Packet.KeyDesc.KeyData[0] = IE_WPA2;
- Packet.KeyDesc.KeyData[1] = pAd->StaCfg.RSNIE_Len;
- Packet.KeyDesc.KeyDataLen[1] = pAd->StaCfg.RSNIE_Len + 2;
- NdisMoveMemory(&Packet.KeyDesc.KeyData[2], pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
-
- // Update packet length after decide Key data payload
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + Packet.KeyDesc.KeyDataLen[1];
-
- // 2. Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // 3. KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = 0;
- Packet.KeyDesc.KeyLength[1] = pMsg1->KeyDesc.KeyLength[1];
-
- // 4. Fill SNonce
- NdisMoveMemory(Packet.KeyDesc.KeyNonce, pAd->StaCfg.SNonce, LEN_KEY_DESC_NONCE);
-
- // 5. Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Send EAPOL-Key(0,1,0,0,0,P,0,SNonce,MIC,RSN IE)
- // Out buffer for transmitting message 2
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- os_free_mem(pAd, mpool);
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // 6. Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1(pOutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
-
- // Make Transmitting frame
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // 5. Copy frame to Tx ring
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- MlmeFreeMemory(pAd, pOutBuffer);
- os_free_mem(pAd, mpool);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Wpa2PairMsg1Action <-----\n"));
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process Pairwise key 4-way handshaking
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaPairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- PHEADER_802_11 pHeader;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- PEAPOL_PACKET pMsg3;
- UCHAR Mic[16], OldMic[16];
- MAC_TABLE_ENTRY *pEntry = NULL;
- UCHAR skip_offset;
- KEY_INFO peerKeyInfo;
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg3Action ----->\n"));
-
- // Record 802.11 header & the received EAPOL packet Msg3
- pHeader = (PHEADER_802_11) Elem->Msg;
- pMsg3 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pMsg3->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT*)&peerKeyInfo) = cpu2le16(*((USHORT*)&peerKeyInfo));
-
-
- // 1. Verify cipher type match
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer != 2))
- {
- return;
- }
- else if(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
- {
- return;
- }
-
- // Verify RSN IE
- //if (!RTMPEqualMemory(pMsg3->KeyDesc.KeyData, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len))
- if (!CheckRSNIE(pAd, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1], &skip_offset))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in Msg 3 of WPA1 4-way handshake!! \n"));
- hex_dump("The original RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
- hex_dump("The received RSN_IE", pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("RSN_IE VALID in Msg 3 of WPA1 4-way handshake!! \n"));
-
-
- // 2. Check MIC value
- // Save the MIC and replace with zero
- NdisMoveMemory(OldMic, pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- UCHAR digest[80];
-
- HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else // TKIP
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, Mic);
- }
-
- if(!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n"));
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n"));
-
- // 3. Check Replay Counter, it has to be larger than last one. No need to be exact one larger
- if(RTMPCompareMemory(pMsg3->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
- return;
-
- // Update new replay counter
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 4. Double check ANonce
- if(!NdisEqualMemory(pAd->StaCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
- return;
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero Message 4 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
-
- //
- // Message 4 as EAPOL-Key(0,1,0,0,0,P,0,0,MIC,0)
- //
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
-
- // Key descriptor version and appropriate RSN IE
- Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = pMsg3->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pMsg3->KeyDesc.KeyLength[1];
-
- // Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // In Msg3, KeyInfo.secure =0 if Group Key HS to come. 1 if no group key HS
- // Station sends Msg4 KeyInfo.secure should be the same as that in Msg.3
- Packet.KeyDesc.KeyInfo.Secure= peerKeyInfo.Secure;
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Key Replay count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Out buffer for transmitting message 4
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- return;
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- UCHAR digest[80];
-
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- // Update PTK
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- // Make transmitting frame
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // Copy frame to Tx ring and Send Message 4 to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaPairMsg3Action <-----\n"));
-}
-
-VOID Wpa2PairMsg3Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- PHEADER_802_11 pHeader;
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- PEAPOL_PACKET pMsg3;
- UCHAR Mic[16], OldMic[16];
- UCHAR *mpool, *KEYDATA, *digest;
- UCHAR Key[32];
- MAC_TABLE_ENTRY *pEntry = NULL;
- KEY_INFO peerKeyInfo;
-
- // allocate memory
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 1024);
-
- if(mpool == NULL)
- return;
-
- // KEYDATA Len = 512.
- KEYDATA = (UCHAR *) ROUND_UP(mpool, 4);
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(KEYDATA + 512, 4);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Wpa2PairMsg3Action ----->\n"));
-
- pHeader = (PHEADER_802_11) Elem->Msg;
-
- // Process message 3 frame.
- pMsg3 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pMsg3->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT*)&peerKeyInfo) = cpu2le16(*((USHORT*)&peerKeyInfo));
-
- // 1. Verify cipher type match
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer!= 2))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- else if(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // 2. Check MIC value
- // Save the MIC and replace with zero
- NdisMoveMemory(OldMic, pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pMsg3->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, Mic);
- }
-
- if(!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n"));
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n"));
-
- // 3. Check Replay Counter, it has to be larger than last one. No need to be exact one larger
- if(RTMPCompareMemory(pMsg3->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Update new replay counter
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 4. Double check ANonce
- if(!NdisEqualMemory(pAd->StaCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Obtain GTK
- // 5. Decrypt GTK from Key Data
- DBGPRINT_RAW(RT_DEBUG_TRACE, ("EKD = %d\n", peerKeyInfo.EKD_DL));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // Decrypt AES GTK
- AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA, pMsg3->KeyDesc.KeyDataLen[1],pMsg3->KeyDesc.KeyData);
- }
- else // TKIP
- {
- INT i;
- // Decrypt TKIP GTK
- // Construct 32 bytes RC4 Key
- NdisMoveMemory(Key, pMsg3->KeyDesc.KeyIv, 16);
- NdisMoveMemory(&Key[16], &pAd->StaCfg.PTK[16], 16);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
- //discard first 256 bytes
- for(i = 0; i < 256; i++)
- ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
- // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);
- }
-
- if (!ParseKeyData(pAd, KEYDATA, pMsg3->KeyDesc.KeyDataLen[1], 1))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Update GTK to ASIC
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero message 4 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
-
- //
- // Message 4 as EAPOL-Key(0,1,0,0,0,P,0,0,MIC,0)
- //
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
-
- // Key descriptor version and appropriate RSN IE
- Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = pMsg3->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pMsg3->KeyDesc.KeyLength[1];
-
- // Key Type PeerKey
- Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Key Replay count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Out buffer for transmitting message 4
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- // Update PTK
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(&pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
- NdisMoveMemory(&pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
- NdisMoveMemory(&pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- // Make Transmitting frame
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // Copy frame to Tx ring and Send Message 4 to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, TRUE);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
- os_free_mem(pAd, (PUCHAR)mpool);
-
-
- // send wireless event - for set key done WPA2
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pEntry->Addr, BSS0, 0);
-
- DBGPRINT(RT_DEBUG_ERROR, ("Wpa2PairMsg3Action <-----\n"));
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process Group key 2-way handshaking
-
- Arguments:
- pAd Pointer to our adapter
- Elem Message body
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaGroupMsg1Action(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-
-{
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- PEAPOL_PACKET pGroup;
- UCHAR *mpool, *digest, *KEYDATA;
- UCHAR Mic[16], OldMic[16];
- UCHAR GTK[32], Key[32];
- KEY_INFO peerKeyInfo;
-
- // allocate memory
- os_alloc_mem(pAd, (PUCHAR *)&mpool, 1024);
-
- if(mpool == NULL)
- return;
-
- // digest Len = 80.
- digest = (UCHAR *) ROUND_UP(mpool, 4);
- // KEYDATA Len = 512.
- KEYDATA = (UCHAR *) ROUND_UP(digest + 80, 4);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaGroupMsg1Action ----->\n"));
-
- // Process Group Message 1 frame. skip 802.11 header(24) & LLC_SNAP header(8)
- pGroup = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
- NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
- NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pGroup->KeyDesc.KeyInfo, sizeof(KEY_INFO));
-
- *((USHORT*)&peerKeyInfo) = cpu2le16(*((USHORT*)&peerKeyInfo));
-
- // 0. Check cipher type match
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer != 2))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- else if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // 1. Verify Replay counter
- // Check Replay Counter, it has to be larger than last one. No need to be exact one larger
- if(RTMPCompareMemory(pGroup->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1)
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Update new replay counter
- NdisMoveMemory(pAd->StaCfg.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // 2. Verify MIC is valid
- // Save the MIC and replace with zero
- NdisMoveMemory(OldMic, pGroup->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
- NdisZeroMemory(pGroup->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
- HMAC_SHA1((PUCHAR) pGroup, pGroup->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pGroup, pGroup->Body_Len[1] + 4, Mic);
- }
-
- if(!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
- {
- DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in group msg 1 of 2-way handshake!!!!!!!!!! \n"));
- MlmeFreeMemory(pAd, (PUCHAR)mpool);
- return;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in group msg 1 of 2-way handshake!!!!!!!!!! \n"));
-
-
- // 3. Decrypt GTK from Key Data
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // Decrypt AES GTK
- AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA, pGroup->KeyDesc.KeyDataLen[1], pGroup->KeyDesc.KeyData);
- }
- else // TKIP
- {
- INT i;
-
- // Decrypt TKIP GTK
- // Construct 32 bytes RC4 Key
- NdisMoveMemory(Key, pGroup->KeyDesc.KeyIv, 16);
- NdisMoveMemory(&Key[16], &pAd->StaCfg.PTK[16], 16);
- ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key, 32);
- //discard first 256 bytes
- for(i = 0; i < 256; i++)
- ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
- // Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
- ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pGroup->KeyDesc.KeyData, pGroup->KeyDesc.KeyDataLen[1]);
- }
-
- // Process decrypted key data material
- // Parse keyData to handle KDE format for WPA2PSK
- if (peerKeyInfo.EKD_DL)
- {
- if (!ParseKeyData(pAd, KEYDATA, pGroup->KeyDesc.KeyDataLen[1], 0))
- {
- os_free_mem(pAd, (PUCHAR)mpool);
- return;
- }
- }
- else // WPAPSK
- {
- // set key material, TxMic and RxMic for WPAPSK
- NdisMoveMemory(GTK, KEYDATA, 32);
- NdisMoveMemory(pAd->StaCfg.GTK, GTK, 32);
- pAd->StaCfg.DefaultKeyId = peerKeyInfo.KeyIndex;
-
- // Prepare pair-wise key information into shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, GTK, LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, &GTK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, &GTK[24], LEN_TKIP_TXMICK);
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
- //hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK);
- }
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
-
- // init header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- // Zero Group message 1 body
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE; // No data field
-
- //
- // Group Message 2 as EAPOL-Key(1,0,0,0,G,0,0,MIC,0)
- //
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- Packet.KeyDesc.Type = WPA2_KEY_DESC;
- }
- else
- {
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
- }
-
- // Key descriptor version and appropriate RSN IE
- Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
-
- // Update Key Length
- Packet.KeyDesc.KeyLength[0] = pGroup->KeyDesc.KeyLength[0];
- Packet.KeyDesc.KeyLength[1] = pGroup->KeyDesc.KeyLength[1];
-
- // Key Index as G-Msg 1
- if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- Packet.KeyDesc.KeyInfo.KeyIndex = peerKeyInfo.KeyIndex;
-
- // Key Type Group key
- Packet.KeyDesc.KeyInfo.KeyType = GROUPKEY;
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Secure bit
- Packet.KeyDesc.KeyInfo.Secure = 1;
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
- // Key Replay count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-
- // Out buffer for transmitting group message 2
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- MlmeFreeMemory(pAd, (PUCHAR)mpool);
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- // AES
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- {
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
-
- // 5. Copy frame to Tx ring and prepare for encryption
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, FALSE);
-
- // 6 Free allocated memory
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
- os_free_mem(pAd, (PUCHAR)mpool);
-
- // send wireless event - for set key done WPA2
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaGroupMsg1Action <-----\n"));
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Init WPA MAC header
-
- Arguments:
- pAd Pointer to our adapter
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID WpaMacHeaderInit(
- IN PRTMP_ADAPTER pAd,
- IN OUT PHEADER_802_11 pHdr80211,
- IN UCHAR wep,
- IN PUCHAR pAddr1)
-{
- NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
- pHdr80211->FC.Type = BTYPE_DATA;
- pHdr80211->FC.ToDs = 1;
- if (wep == 1)
- pHdr80211->FC.Wep = 1;
-
- // Addr1: BSSID, Addr2: SA, Addr3: DA
- COPY_MAC_ADDR(pHdr80211->Addr1, pAddr1);
- COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
- COPY_MAC_ADDR(pHdr80211->Addr3, pAd->CommonCfg.Bssid);
- pHdr80211->Sequence = pAd->Sequence;
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Copy frame from waiting queue into relative ring buffer and set
- appropriate ASIC register to kick hardware encryption before really
- sent out to air.
-
- Arguments:
- pAd Pointer to our adapter
- PNDIS_PACKET Pointer to outgoing Ndis frame
- NumberOfFrag Number of fragment required
-
- Return Value:
- None
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPToWirelessSta(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pHeader802_3,
- IN UINT HdrLen,
- IN PUCHAR pData,
- IN UINT DataLen,
- IN BOOLEAN is4wayFrame)
-
-{
- NDIS_STATUS Status;
- PNDIS_PACKET pPacket;
- UCHAR Index;
-
- do
- {
- // 1. build a NDIS packet and call RTMPSendPacket();
- // be careful about how/when to release this internal allocated NDIS PACKET buffer
- Status = RTMPAllocateNdisPacket(pAd, &pPacket, pHeader802_3, HdrLen, pData, DataLen);
- if (Status != NDIS_STATUS_SUCCESS)
- break;
-
- if (is4wayFrame)
- RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 1);
- else
- RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 0);
-
- // 2. send out the packet
- Status = STASendPacket(pAd, pPacket);
- if(Status == NDIS_STATUS_SUCCESS)
- {
- // Dequeue one frame from TxSwQueue0..3 queue and process it
- // There are three place calling dequeue for TX ring.
- // 1. Here, right after queueing the frame.
- // 2. At the end of TxRingTxDone service routine.
- // 3. Upon NDIS call RTMPSendPackets
- if((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)))
- {
- for(Index = 0; Index < 5; Index ++)
- if(pAd->TxSwQueue[Index].Number > 0)
- RTMPDeQueuePacket(pAd, FALSE, Index, MAX_TX_PROCESS);
- }
- }
- } while(FALSE);
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Check Sanity RSN IE form AP
-
- Arguments:
-
- Return Value:
-
-
- ========================================================================
-*/
-BOOLEAN CheckRSNIE(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pData,
- IN UCHAR DataLen,
- OUT UCHAR *Offset)
-{
- PUCHAR pVIE;
- UCHAR len;
- PEID_STRUCT pEid;
- BOOLEAN result = FALSE;
-
- pVIE = pData;
- len = DataLen;
- *Offset = 0;
-
- while (len > sizeof(RSNIE2))
- {
- pEid = (PEID_STRUCT) pVIE;
- // WPA RSN IE
- if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) &&
- (NdisEqualMemory(pVIE, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len)) &&
- (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == (pEid->Len + 2)))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> WPA/WPAPSK RSN IE matched in Msg 3, Length(%d) \n", (pEid->Len + 2)));
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- // WPA2 RSN IE
- else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
- {
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) &&
- (NdisEqualMemory(pVIE, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len)) &&
- (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == (pEid->Len + 2)))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", (pEid->Len + 2)));
- result = TRUE;
- }
-
- *Offset += (pEid->Len + 2);
- }
- else
- {
- break;
- }
-
- pVIE += (pEid->Len + 2);
- len -= (pEid->Len + 2);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> skip_offset(%d) \n", *Offset));
-
- return result;
-
-}
-
-
-/*
- ========================================================================
-
- Routine Description:
- Parse KEYDATA field. KEYDATA[] May contain 2 RSN IE and optionally GTK.
- GTK is encaptulated in KDE format at p.83 802.11i D10
-
- Arguments:
-
- Return Value:
-
- Note:
- 802.11i D10
-
- ========================================================================
-*/
-BOOLEAN ParseKeyData(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pKeyData,
- IN UCHAR KeyDataLen,
- IN UCHAR bPairewise)
-{
- PKDE_ENCAP pKDE = NULL;
- PUCHAR pMyKeyData = pKeyData;
- UCHAR KeyDataLength = KeyDataLen;
- UCHAR GTKLEN;
- UCHAR skip_offset;
-
- // Verify The RSN IE contained in Pairewise-Msg 3 and skip it
- if (bPairewise)
- {
- // Check RSN IE whether it is WPA2/WPA2PSK
- if (!CheckRSNIE(pAd, pKeyData, KeyDataLen, &skip_offset))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ParseKeyData ==> WPA2/WPA2PSK RSN IE mismatched \n"));
- hex_dump("Get KEYDATA :", pKeyData, KeyDataLen);
- return FALSE;
- }
- else
- {
- // skip RSN IE
- pMyKeyData += skip_offset;
- KeyDataLength -= skip_offset;
-
- //DBGPRINT(RT_DEBUG_TRACE, ("ParseKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", skip_offset));
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("ParseKeyData ==> KeyDataLength %d without RSN_IE \n", KeyDataLength));
-
- // Parse EKD format
- if (KeyDataLength >= 8)
- {
- pKDE = (PKDE_ENCAP) pMyKeyData;
- }
- else
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: KeyDataLength is too short \n"));
- return FALSE;
- }
-
-
- // Sanity check - shared key index should not be 0
- if (pKDE->GTKEncap.Kid == 0)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index zero \n"));
- return FALSE;
- }
-
- // Sanity check - KED length
- if (KeyDataLength < (pKDE->Len + 2))
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
- return FALSE;
- }
-
- // Get GTK length - refer to IEEE 802.11i-2004 p.82
- GTKLEN = pKDE->Len -6;
-
- if (GTKLEN < LEN_AES_KEY)
- {
- DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
- return FALSE;
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("GTK Key with KDE formet got index=%d, len=%d \n", pKDE->GTKEncap.Kid, GTKLEN));
-
- // Update GTK
- // set key material, TxMic and RxMic for WPAPSK
- NdisMoveMemory(pAd->StaCfg.GTK, pKDE->GTKEncap.GTK, 32);
- pAd->StaCfg.DefaultKeyId = pKDE->GTKEncap.Kid;
-
- // Update shared key table
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKDE->GTKEncap.GTK, LEN_TKIP_EK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, &pKDE->GTKEncap.GTK[16], LEN_TKIP_RXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, &pKDE->GTKEncap.GTK[24], LEN_TKIP_TXMICK);
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
- return TRUE;
-
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Cisco CCKM PRF function
-
- Arguments:
- key Cisco Base Transient Key (BTK)
- key_len The key length of the BTK
- data Ruquest Number(RN) + BSSID
- data_len The length of the data
- output Store for PTK(Pairwise transient keys)
- len The length of the output
- Return Value:
- None
-
- Note:
- 802.1i Annex F.9
-
- ========================================================================
-*/
-VOID CCKMPRF(
- IN UCHAR *key,
- IN INT key_len,
- IN UCHAR *data,
- IN INT data_len,
- OUT UCHAR *output,
- IN INT len)
-{
- INT i;
- UCHAR input[1024];
- INT currentindex = 0;
- INT total_len;
-
- NdisMoveMemory(input, data, data_len);
- total_len = data_len;
- input[total_len] = 0;
- total_len++;
- for (i = 0; i < (len + 19) / 20; i++)
- {
- HMAC_SHA1(input, total_len, key, key_len, &output[currentindex]);
- currentindex += 20;
- input[total_len - 1]++;
- }
-}
-
-/*
- ========================================================================
-
- Routine Description:
- Process MIC error indication and record MIC error timer.
-
- Arguments:
- pAd Pointer to our adapter
- pWpaKey Pointer to the WPA key structure
-
- Return Value:
- None
-
- IRQL = DISPATCH_LEVEL
-
- Note:
-
- ========================================================================
-*/
-VOID RTMPReportMicError(
- IN PRTMP_ADAPTER pAd,
- IN PCIPHER_KEY pWpaKey)
-{
- ULONG Now;
- UCHAR unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1:0);
-
- // Record Last MIC error time and count
- Now = jiffies;
- if (pAd->StaCfg.MicErrCnt == 0)
- {
- pAd->StaCfg.MicErrCnt++;
- pAd->StaCfg.LastMicErrorTime = Now;
- NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
- }
- else if (pAd->StaCfg.MicErrCnt == 1)
- {
- if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now)
- {
- // Update Last MIC error time, this did not violate two MIC errors within 60 seconds
- pAd->StaCfg.LastMicErrorTime = Now;
- }
- else
- {
-
- if (pAd->CommonCfg.bWirelessEvent)
- RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-
- pAd->StaCfg.LastMicErrorTime = Now;
- // Violate MIC error counts, MIC countermeasures kicks in
- pAd->StaCfg.MicErrCnt++;
- // We shall block all reception
- // We shall clean all Tx ring and disassoicate from AP after next EAPOL frame
- //
- // No necessary to clean all Tx ring, on RTMPHardTransmit will stop sending non-802.1X EAPOL packets
- // if pAd->StaCfg.MicErrCnt greater than 2.
- //
- // RTMPRingCleanUp(pAd, QID_AC_BK);
- // RTMPRingCleanUp(pAd, QID_AC_BE);
- // RTMPRingCleanUp(pAd, QID_AC_VI);
- // RTMPRingCleanUp(pAd, QID_AC_VO);
- // RTMPRingCleanUp(pAd, QID_HCCA);
- }
- }
- else
- {
- // MIC error count >= 2
- // This should not happen
- ;
- }
- MlmeEnqueue(pAd,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_MIC_FAILURE_REPORT_FRAME,
- 1,
- &unicastKey);
-
- if (pAd->StaCfg.MicErrCnt == 2)
- {
- RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
- }
-}
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-#define LENGTH_EAP_H 4
-// If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)).
-INT WpaCheckEapCode(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pFrame,
- IN USHORT FrameLen,
- IN USHORT OffSet)
-{
-
- PUCHAR pData;
- INT result = 0;
-
- if( FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H )
- return result;
-
- pData = pFrame + OffSet; // skip offset bytes
-
- if(*(pData+1) == EAPPacket) // 802.1x header - Packet Type
- {
- result = *(pData+4); // EAP header - Code
- }
-
- return result;
-}
-
-VOID WpaSendMicFailureToWpaSupplicant(
- IN PRTMP_ADAPTER pAd,
- IN BOOLEAN bUnicast)
-{
- union iwreq_data wrqu;
- char custom[IW_CUSTOM_MAX] = {0};
-
- sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
- if (bUnicast)
- sprintf(custom, "%s unicast", custom);
- wrqu.data.length = strlen(custom);
- wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
-
- return;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-VOID WpaMicFailureReportFrame(
- IN PRTMP_ADAPTER pAd,
- IN MLME_QUEUE_ELEM *Elem)
-{
- PUCHAR pOutBuffer = NULL;
- UCHAR Header802_3[14];
- ULONG FrameLen = 0;
- EAPOL_PACKET Packet;
- UCHAR Mic[16];
- BOOLEAN bUnicast;
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
-
- bUnicast = (Elem->Msg[0] == 1 ? TRUE:FALSE);
- pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
-
- // init 802.3 header and Fill Packet
- MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
-
- NdisZeroMemory(&Packet, sizeof(Packet));
- Packet.ProVer = EAPOL_VER;
- Packet.ProType = EAPOLKey;
-
- Packet.KeyDesc.Type = WPA1_KEY_DESC;
-
- // Request field presented
- Packet.KeyDesc.KeyInfo.Request = 1;
-
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
- }
- else // TKIP
- {
- Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
- }
-
- Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
-
- // KeyMic field presented
- Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
- // Error field presented
- Packet.KeyDesc.KeyInfo.Error = 1;
-
- // Update packet length after decide Key data payload
- Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE;
-
- // Key Replay Count
- NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
- inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
-
- // Convert to little-endian format.
- *((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
-
-
- MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
- if(pOutBuffer == NULL)
- {
- return;
- }
-
- // Prepare EAPOL frame for MIC calculation
- // Be careful, only EAPOL frame is counted for MIC calculation
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // Prepare and Fill MIC value
- NdisZeroMemory(Mic, sizeof(Mic));
- if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
- { // AES
- UCHAR digest[20] = {0};
- HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
- NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
- }
- else
- { // TKIP
- hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
- }
- NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
- MakeOutgoingFrame(pOutBuffer, &FrameLen,
- LENGTH_802_3, &Header802_3,
- Packet.Body_Len[1] + 4, &Packet,
- END_OF_ARGS);
-
- // opy frame to Tx ring and send MIC failure report frame to authenticator
- RTMPToWirelessSta(pAd, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, Packet.Body_Len[1] + 4, FALSE);
-
- MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
-
- DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame <-----\n"));
-}
-
-/** from wpa_supplicant
- * inc_byte_array - Increment arbitrary length byte array by one
- * @counter: Pointer to byte array
- * @len: Length of the counter in bytes
- *
- * This function increments the last byte of the counter by one and continues
- * rolling over to more significant bytes if the byte was incremented from
- * 0xff to 0x00.
- */
-void inc_byte_array(UCHAR *counter, int len)
-{
- int pos = len - 1;
- while (pos >= 0) {
- counter[pos]++;
- if (counter[pos] != 0)
- break;
- pos--;
- }
-}
-
-VOID WpaDisassocApAndBlockAssoc(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3)
-{
- RTMP_ADAPTER *pAd = (PRTMP_ADAPTER)FunctionContext;
- MLME_DISASSOC_REQ_STRUCT DisassocReq;
-
- // disassoc from current AP first
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
- DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_MIC_FAILURE);
- MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
- pAd->StaCfg.bBlockAssoc = TRUE;
-}
-
+#include "../../rt2870/sta/wpa.c"
diff --git a/drivers/staging/rt3070/sta_ioctl.c b/drivers/staging/rt3070/sta_ioctl.c
index 079454835a43..ac56507e3c8f 100644
--- a/drivers/staging/rt3070/sta_ioctl.c
+++ b/drivers/staging/rt3070/sta_ioctl.c
@@ -1,7203 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- sta_ioctl.c
-
- Abstract:
- IOCTL related subroutines
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Rory Chen 01-03-2003 created
- Rory Chen 02-14-2005 modify to support RT61
-*/
-
-#include "rt_config.h"
-
-#ifdef DBG
-extern ULONG RTDebugLevel;
-#endif
-
-#define NR_WEP_KEYS 4
-#define WEP_SMALL_KEY_LEN (40/8)
-#define WEP_LARGE_KEY_LEN (104/8)
-
-#define GROUP_KEY_NO 4
-
-extern UCHAR CipherWpa2Template[];
-extern UCHAR CipherWpaPskTkip[];
-extern UCHAR CipherWpaPskTkipLen;
-
-typedef struct PACKED _RT_VERSION_INFO{
- UCHAR DriverVersionW;
- UCHAR DriverVersionX;
- UCHAR DriverVersionY;
- UCHAR DriverVersionZ;
- UINT DriverBuildYear;
- UINT DriverBuildMonth;
- UINT DriverBuildDay;
-} RT_VERSION_INFO, *PRT_VERSION_INFO;
-
-struct iw_priv_args privtab[] = {
-{ RTPRIV_IOCTL_SET,
- IW_PRIV_TYPE_CHAR | 1024, 0,
- "set"},
-
-{ RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- ""},
-/* --- sub-ioctls definitions --- */
- { SHOW_CONN_STATUS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
- { SHOW_DRVIER_VERION,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
- { SHOW_BA_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
- { SHOW_DESC_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
- { RAIO_OFF,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
- { RAIO_ON,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
-#ifdef QOS_DLS_SUPPORT
- { SHOW_DLS_ENTRY_INFO,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
-#endif // QOS_DLS_SUPPORT //
- { SHOW_CFG_VALUE,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
-/* --- sub-ioctls relations --- */
-
-#ifdef DBG
-{ RTPRIV_IOCTL_BBP,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "bbp"},
-{ RTPRIV_IOCTL_MAC,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "mac"},
-#ifdef RT30xx
-{ RTPRIV_IOCTL_RF,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "rf"},
-#endif // RT30xx //
-{ RTPRIV_IOCTL_E2P,
- IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
- "e2p"},
-#endif /* DBG */
-
-{ RTPRIV_IOCTL_STATISTICS,
- 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
- "stat"},
-{ RTPRIV_IOCTL_GSITESURVEY,
- 0, IW_PRIV_TYPE_CHAR | 1024,
- "get_site_survey"},
-
-
-};
-
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WMM_SUPPORT
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif
-
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-
-#ifdef RT30xx
-VOID RTMPIoctlRF(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq);
-#endif // RT30xx //
-#endif // DBG //
-
-
-NDIS_STATUS RTMPWPANoneAddKeyProc(
- IN PRTMP_ADAPTER pAd,
- IN PVOID pBuf);
-
-INT Set_FragTest_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef DOT11_N_SUPPORT
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // DOT11_N_SUPPORT //
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg);
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg);
-#endif // CARRIER_DETECTION_SUPPORT //
-
-static struct {
- CHAR *name;
- INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
- {"DriverVersion", Set_DriverVersion_Proc},
- {"CountryRegion", Set_CountryRegion_Proc},
- {"CountryRegionABand", Set_CountryRegionABand_Proc},
- {"SSID", Set_SSID_Proc},
- {"WirelessMode", Set_WirelessMode_Proc},
- {"TxBurst", Set_TxBurst_Proc},
- {"TxPreamble", Set_TxPreamble_Proc},
- {"TxPower", Set_TxPower_Proc},
- {"Channel", Set_Channel_Proc},
- {"BGProtection", Set_BGProtection_Proc},
- {"RTSThreshold", Set_RTSThreshold_Proc},
- {"FragThreshold", Set_FragThreshold_Proc},
-#ifdef DOT11_N_SUPPORT
- {"HtBw", Set_HtBw_Proc},
- {"HtMcs", Set_HtMcs_Proc},
- {"HtGi", Set_HtGi_Proc},
- {"HtOpMode", Set_HtOpMode_Proc},
- {"HtExtcha", Set_HtExtcha_Proc},
- {"HtMpduDensity", Set_HtMpduDensity_Proc},
- {"HtBaWinSize", Set_HtBaWinSize_Proc},
- {"HtRdg", Set_HtRdg_Proc},
- {"HtAmsdu", Set_HtAmsdu_Proc},
- {"HtAutoBa", Set_HtAutoBa_Proc},
- {"HtBaDecline", Set_BADecline_Proc},
- {"HtProtect", Set_HtProtect_Proc},
- {"HtMimoPs", Set_HtMimoPs_Proc},
-#endif // DOT11_N_SUPPORT //
-
-#ifdef AGGREGATION_SUPPORT
- {"PktAggregate", Set_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
- {"WmmCapable", Set_WmmCapable_Proc},
-#endif
- {"IEEE80211H", Set_IEEE80211H_Proc},
- {"NetworkType", Set_NetworkType_Proc},
- {"AuthMode", Set_AuthMode_Proc},
- {"EncrypType", Set_EncrypType_Proc},
- {"DefaultKeyID", Set_DefaultKeyID_Proc},
- {"Key1", Set_Key1_Proc},
- {"Key2", Set_Key2_Proc},
- {"Key3", Set_Key3_Proc},
- {"Key4", Set_Key4_Proc},
- {"WPAPSK", Set_WPAPSK_Proc},
- {"ResetCounter", Set_ResetStatCounter_Proc},
- {"PSMode", Set_PSMode_Proc},
-#ifdef DBG
- {"Debug", Set_Debug_Proc},
-#endif
-
-#ifdef RALINK_ATE
- {"ATE", Set_ATE_Proc},
- {"ATEDA", Set_ATE_DA_Proc},
- {"ATESA", Set_ATE_SA_Proc},
- {"ATEBSSID", Set_ATE_BSSID_Proc},
- {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
- {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
- {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
- {"ATETXANT", Set_ATE_TX_Antenna_Proc},
- {"ATERXANT", Set_ATE_RX_Antenna_Proc},
- {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
- {"ATETXBW", Set_ATE_TX_BW_Proc},
- {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
- {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
- {"ATETXMCS", Set_ATE_TX_MCS_Proc},
- {"ATETXMODE", Set_ATE_TX_MODE_Proc},
- {"ATETXGI", Set_ATE_TX_GI_Proc},
- {"ATERXFER", Set_ATE_RX_FER_Proc},
- {"ATERRF", Set_ATE_Read_RF_Proc},
- {"ATEWRF1", Set_ATE_Write_RF1_Proc},
- {"ATEWRF2", Set_ATE_Write_RF2_Proc},
- {"ATEWRF3", Set_ATE_Write_RF3_Proc},
- {"ATEWRF4", Set_ATE_Write_RF4_Proc},
- {"ATELDE2P", Set_ATE_Load_E2P_Proc},
- {"ATERE2P", Set_ATE_Read_E2P_Proc},
- {"ATESHOW", Set_ATE_Show_Proc},
- {"ATEHELP", Set_ATE_Help_Proc},
-
-#ifdef RALINK_28xx_QA
- {"TxStop", Set_TxStop_Proc},
- {"RxStop", Set_RxStop_Proc},
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- {"WpaSupport", Set_Wpa_Support},
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
- {"FixedTxMode", Set_FixedTxMode_Proc},
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- {"OpMode", Set_OpMode_Proc},
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
-#ifdef DOT11_N_SUPPORT
- {"TGnWifiTest", Set_TGnWifiTest_Proc},
- {"ForceGF", Set_ForceGF_Proc},
-#endif // DOT11_N_SUPPORT //
-#ifdef QOS_DLS_SUPPORT
- {"DlsAddEntry", Set_DlsAddEntry_Proc},
- {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
-#endif // QOS_DLS_SUPPORT //
- {"LongRetry", Set_LongRetryLimit_Proc},
- {"ShortRetry", Set_ShortRetryLimit_Proc},
-#ifdef EXT_BUILD_CHANNEL_LIST
- {"11dClientMode", Set_Ieee80211dClientMode_Proc},
-#endif // EXT_BUILD_CHANNEL_LIST //
-#ifdef CARRIER_DETECTION_SUPPORT
- {"CarrierDetect", Set_CarrierDetect_Proc},
-#endif // CARRIER_DETECTION_SUPPORT //
-//2008/09/11:KH add to support efuse<--
-#ifdef RT30xx
- {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
- {"efuseDump", set_eFusedump_Proc},
- {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
-#endif // RT30xx //
-//2008/09/11:KH add to support efuse-->
- {NULL,}
-};
-
-
-VOID RTMPAddKey(
- IN PRTMP_ADAPTER pAd,
- IN PNDIS_802_11_KEY pKey)
-{
- ULONG KeyIdx;
- MAC_TABLE_ENTRY *pEntry;
-
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- if (pKey->KeyIndex & 0x80000000)
- {
- if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- NdisZeroMemory(pAd->StaCfg.PMK, 32);
- NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
- goto end;
- }
- // Update PTK
- NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Decide its ChiperAlg
- if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
- else
- pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
- // Update these related information to MAC_TABLE_ENTRY
- pEntry = &pAd->MacTab.Content[BSSID_WCID];
- NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
- NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
- NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
- pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
- // Update pairwise key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pAd->SharedKey[BSS0][0].Key,
- pAd->SharedKey[BSS0][0].TxMic,
- pAd->SharedKey[BSS0][0].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- 0,
- pAd->SharedKey[BSS0][0].CipherAlg,
- pEntry);
-
- if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else
- {
- // Update GTK
- pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
- NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
- else
-#endif // WPA_SUPPLICANT_SUPPORT //
- {
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- }
-
- // Update Shared Key CipherAlg
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
- if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
- else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAd,
- BSS0,
- pAd->StaCfg.DefaultKeyId,
- pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
- NULL);
-
- // set 802.1x port control
- //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAd);
-
- // Indicate Connected for GUI
- pAd->IndicateMediaState = NdisMediaStateConnected;
- }
- }
- else // dynamic WEP from wpa_supplicant
- {
- UCHAR CipherAlg;
- PUCHAR Key;
-
- if(pKey->KeyLength == 32)
- goto end;
-
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
-
- if (KeyIdx < 4)
- {
- // it is a default shared key, for Pairwise key setting
- if (pKey->KeyIndex & 0x80000000)
- {
- pEntry = MacTableLookup(pAd, pKey->BSSID);
-
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
-
- // set key material and key length
- pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
- NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // set Cipher type
- if (pKey->KeyLength == 5)
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
- else
- pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
-
- // Add Pair-wise key to Asic
- AsicAddPairwiseKeyEntry(
- pAd,
- pEntry->Addr,
- (UCHAR)pEntry->Aid,
- &pEntry->PairwiseKey);
-
- // update WCID attribute table and IVEIV table for this entry
- RTMPAddWcidAttributeEntry(
- pAd,
- BSS0,
- KeyIdx, // The value may be not zero
- pEntry->PairwiseKey.CipherAlg,
- pEntry);
-
- }
- }
- else
- {
- // Default key for tx (shared key)
- pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-
- // set key material and key length
- pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
-
- // Set Ciper type
- if (pKey->KeyLength == 5)
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
- else
- pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
-
- CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
- Key = pAd->SharedKey[BSS0][KeyIdx].Key;
-
- // Set Group key material to Asic
- AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- // Update WCID attribute table and IVEIV table for this group key table
- RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
-
- }
- }
- }
-end:
- return;
-}
-
-char * rtstrchr(const char * s, int c)
-{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *) s;
-}
-
-/*
-This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
-*/
-
-int
-rt_ioctl_giwname(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
-// PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-#ifdef RT2870
- strncpy(name, "RT2870 Wireless", IFNAMSIZ);
-#endif // RT2870 //
- return 0;
-}
-
-int rt_ioctl_siwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- int chan = -1;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
-
- if (freq->e > 1)
- return -EINVAL;
-
- if((freq->e == 0) && (freq->m <= 1000))
- chan = freq->m; // Setting by channel number
- else
- MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
-
- if (ChannelSanity(pAdapter, chan) == TRUE)
- {
- pAdapter->CommonCfg.Channel = chan;
- DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
- }
- else
- return -EINVAL;
-
- return 0;
-}
-int rt_ioctl_giwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *freq, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter;
- UCHAR ch;
- ULONG m;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- ch = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
-
- MAP_CHANNEL_ID_TO_KHZ(ch, m);
- freq->m = m * 100;
- freq->e = 1;
- return 0;
-}
-
-int rt_ioctl_siwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (*mode)
- {
- case IW_MODE_ADHOC:
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- break;
- case IW_MODE_INFRA:
- Set_NetworkType_Proc(pAdapter, "Infra");
- break;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- case IW_MODE_MONITOR:
- Set_NetworkType_Proc(pAdapter, "Monitor");
- break;
-#endif
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
- return -EINVAL;
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- return 0;
-}
-
-int rt_ioctl_giwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *mode, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- if (ADHOC_ON(pAdapter))
- *mode = IW_MODE_ADHOC;
- else if (INFRA_ON(pAdapter))
- *mode = IW_MODE_INFRA;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
- else if (MONITOR_ON(pAdapter))
- {
- *mode = IW_MODE_MONITOR;
- }
-#endif
- else
- *mode = IW_MODE_AUTO;
-
- DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
- return 0;
-}
-
-int rt_ioctl_siwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- return 0;
-}
-
-int rt_ioctl_giwsens(struct net_device *dev,
- struct iw_request_info *info,
- char *name, char *extra)
-{
- return 0;
-}
-
-int rt_ioctl_giwrange(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- struct iw_range *range = (struct iw_range *) extra;
- u16 val;
- int i;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
- data->length = sizeof(struct iw_range);
- memset(range, 0, sizeof(struct iw_range));
-
- range->txpower_capa = IW_TXPOW_DBM;
-
- if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
- {
- range->min_pmp = 1 * 1024;
- range->max_pmp = 65535 * 1024;
- range->min_pmt = 1 * 1024;
- range->max_pmt = 1000 * 1024;
- range->pmp_flags = IW_POWER_PERIOD;
- range->pmt_flags = IW_POWER_TIMEOUT;
- range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
- IW_POWER_UNICAST_R | IW_POWER_ALL_R;
- }
-
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = 14;
-
- range->retry_capa = IW_RETRY_LIMIT;
- range->retry_flags = IW_RETRY_LIMIT;
- range->min_retry = 0;
- range->max_retry = 255;
-
- range->num_channels = pAdapter->ChannelListNum;
-
- val = 0;
- for (i = 1; i <= range->num_channels; i++)
- {
- u32 m;
- range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
- range->freq[val].m = m * 100; /* HZ */
-
- range->freq[val].e = 1;
- val++;
- if (val == IW_MAX_FREQUENCIES)
- break;
- }
- range->num_frequency = val;
-
- range->max_qual.qual = 100; /* what is correct max? This was not
- * documented exactly. At least
- * 69 has been observed. */
- range->max_qual.level = 0; /* dB */
- range->max_qual.noise = 0; /* dB */
-
- /* What would be suitable values for "average/typical" qual? */
- range->avg_qual.qual = 20;
- range->avg_qual.level = -60;
- range->avg_qual.noise = -95;
- range->sensitivity = 3;
-
- range->max_encoding_tokens = NR_WEP_KEYS;
- range->num_encoding_sizes = 2;
- range->encoding_size[0] = 5;
- range->encoding_size[1] = 13;
-
- range->min_rts = 0;
- range->max_rts = 2347;
- range->min_frag = 256;
- range->max_frag = 2346;
-
-#if WIRELESS_EXT > 17
- /* IW_ENC_CAPA_* bit field */
- range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
- IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-#endif
-
- return 0;
-}
-
-int rt_ioctl_siwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- NDIS_802_11_MAC_ADDRESS Bssid;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- memset(Bssid, 0, MAC_ADDR_LEN);
- memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
-
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
-
- return 0;
-}
-
-int rt_ioctl_giwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *ap_addr, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- ap_addr->sa_family = ARPHRD_ETHER;
- memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
- return -ENOTCONN;
- }
-
- return 0;
-}
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a. These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- * drivers for compatibility
- */
-static void set_quality(PRTMP_ADAPTER pAdapter,
- struct iw_quality *iq,
- signed char rssi)
-{
- __u8 ChannelQuality;
-
- // Normalize Rssi
- if (rssi >= -50)
- ChannelQuality = 100;
- else if (rssi >= -80) // between -50 ~ -80dbm
- ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
- else if (rssi >= -90) // between -80 ~ -90dbm
- ChannelQuality = (__u8)((rssi + 90) * 26)/10;
- else
- ChannelQuality = 0;
-
- iq->qual = (__u8)ChannelQuality;
-
- iq->level = (__u8)(rssi);
- iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
- iq->noise += 256 - 143;
- iq->updated = pAdapter->iw_stats.qual.updated;
-}
-
-int rt_ioctl_iwaplist(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- struct sockaddr addr[IW_MAX_AP];
- struct iw_quality qual[IW_MAX_AP];
- int i;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- data->length = 0;
- return 0;
- //return -ENETDOWN;
- }
-
- for (i = 0; i <IW_MAX_AP ; i++)
- {
- if (i >= pAdapter->ScanTab.BssNr)
- break;
- addr[i].sa_family = ARPHRD_ETHER;
- memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
- }
- data->length = i;
- memcpy(extra, &addr, i*sizeof(addr[0]));
- data->flags = 1; /* signal quality present (sort of) */
- memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
-
- return 0;
-}
-
-#ifdef SIOCGIWSCAN
-int rt_ioctl_siwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- ULONG Now;
- int Status = NDIS_STATUS_SUCCESS;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- return -EINVAL;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount++;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- return 0;
- do{
- Now = jiffies;
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
- (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- RT28XX_MLME_HANDLER(pAdapter);
- }while(0);
- return 0;
-}
-
-int rt_ioctl_giwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *extra)
-{
-
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- int i=0;
- char *current_ev = extra, *previous_ev = extra;
- char *end_buf;
- char *current_val, custom[MAX_CUSTOM_LEN] = {0};
-#ifndef IWEVGENIE
- char idx;
-#endif // IWEVGENIE //
- struct iw_event iwe;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- return -EAGAIN;
- }
-
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- pAdapter->StaCfg.WpaSupplicantScanCount = 0;
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- if (pAdapter->ScanTab.BssNr == 0)
- {
- data->length = 0;
- return 0;
- }
-
-#if WIRELESS_EXT >= 17
- if (data->length > 0)
- end_buf = extra + data->length;
- else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#else
- end_buf = extra + IW_SCAN_MAX_DATA;
-#endif
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- if (current_ev >= end_buf)
- {
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //MAC address
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
-
- previous_ev = current_ev;
- current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- /*
- Protocol:
- it will show scanned AP's WirelessMode .
- it might be
- 802.11a
- 802.11a/n
- 802.11g/n
- 802.11b/g/n
- 802.11g
- 802.11b/g
- */
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWNAME;
-
-
- {
- PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
- BOOLEAN isGonly=FALSE;
- int rateCnt=0;
-
- if (pBssEntry->Channel>14)
- {
- if (pBssEntry->HtCapabilityLen!=0)
- strcpy(iwe.u.name,"802.11a/n");
- else
- strcpy(iwe.u.name,"802.11a");
- }
- else
- {
- /*
- if one of non B mode rate is set supported rate . it mean G only.
- */
- for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
- {
- /*
- 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
- */
- if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
- isGonly=TRUE;
- }
-
- for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
- {
- if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
- isGonly=TRUE;
- }
-
-
- if (pBssEntry->HtCapabilityLen!=0)
- {
- if (isGonly==TRUE)
- strcpy(iwe.u.name,"802.11g/n");
- else
- strcpy(iwe.u.name,"802.11b/g/n");
- }
- else
- {
- if (isGonly==TRUE)
- strcpy(iwe.u.name,"802.11g");
- else
- {
- if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
- strcpy(iwe.u.name,"802.11b");
- else
- strcpy(iwe.u.name,"802.11b/g");
- }
- }
- }
- }
-
- previous_ev = current_ev;
- current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //ESSID
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
- iwe.u.data.flags = 1;
-
- previous_ev = current_ev;
- current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Network Type
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWMODE;
- if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
- {
- iwe.u.mode = IW_MODE_ADHOC;
- }
- else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
- {
- iwe.u.mode = IW_MODE_INFRA;
- }
- else
- {
- iwe.u.mode = IW_MODE_AUTO;
- }
- iwe.len = IW_EV_UINT_LEN;
-
- previous_ev = current_ev;
- current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Channel and Frequency
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWFREQ;
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- else
- iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
- iwe.u.freq.e = 0;
- iwe.u.freq.i = 0;
-
- previous_ev = current_ev;
- current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Add quality statistics
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.level = 0;
- iwe.u.qual.noise = 0;
- set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
- current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Encyption key
- //================================
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWENCODE;
- if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
- iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
-
- previous_ev = current_ev;
- current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
-
- //Bit Rate
- //================================
- if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
- {
- UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWRATE;
- current_val = current_ev + IW_EV_LCP_LEN;
- if (tmpRate == 0x82)
- iwe.u.bitrate.value = 1 * 1000000;
- else if (tmpRate == 0x84)
- iwe.u.bitrate.value = 2 * 1000000;
- else if (tmpRate == 0x8B)
- iwe.u.bitrate.value = 5.5 * 1000000;
- else if (tmpRate == 0x96)
- iwe.u.bitrate.value = 11 * 1000000;
- else
- iwe.u.bitrate.value = (tmpRate/2) * 1000000;
-
- iwe.u.bitrate.disabled = 0;
- current_val = iwe_stream_add_value(info, current_ev,
- current_val, end_buf, &iwe,
- IW_EV_PARAM_LEN);
-
- if((current_val-current_ev)>IW_EV_LCP_LEN)
- current_ev = current_val;
- else
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
-#ifdef IWEVGENIE
- //WPA IE
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
- current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- memset(&iwe, 0, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
- pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
- current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#else
- //WPA IE
- //================================
- if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "wpa_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-
- //WPA2 IE
- if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
- {
- NdisZeroMemory(&iwe, sizeof(iwe));
- memset(&custom[0], 0, MAX_CUSTOM_LEN);
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
- NdisMoveMemory(custom, "rsn_ie=", 7);
- for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
- sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
- previous_ev = current_ev;
- current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
- if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
- return -E2BIG;
-#else
- break;
-#endif
- }
-#endif // IWEVGENIE //
- }
-
- data->length = current_ev - extra;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
- return 0;
-}
-#endif
-
-int rt_ioctl_siwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->flags)
- {
- PCHAR pSsidString = NULL;
-
- // Includes null character.
- if (data->length > (IW_ESSID_MAX_SIZE + 1))
- return -E2BIG;
-
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, essid, data->length);
- if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
- return -EINVAL;
- }
- else
- return -ENOMEM;
- }
- else
- {
- // ANY ssid
- if (Set_SSID_Proc(pAdapter, "") == FALSE)
- return -EINVAL;
- }
- return 0;
-}
-
-int rt_ioctl_giwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *essid)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- data->flags = 1;
- if (MONITOR_ON(pAdapter))
- {
- data->length = 0;
- return 0;
- }
-
- if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#ifdef RT2870
-#ifdef WPA_SUPPLICANT_SUPPORT
- // Add for RT2870
- else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
- {
- data->length = pAdapter->CommonCfg.SsidLen;
- memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
- }
-#endif // WPA_SUPPLICANT_SUPPORT //
-#endif // RT2870 //
- else
- {//the ANY ssid was specified
- data->length = 0;
- DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
- }
-
- return 0;
-
-}
-
-int rt_ioctl_siwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (data->length > IW_ESSID_MAX_SIZE)
- return -EINVAL;
-
- memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
- memcpy(pAdapter->nickname, nickname, data->length);
-
-
- return 0;
-}
-
-int rt_ioctl_giwnickn(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *data, char *nickname)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- if (data->length > strlen(pAdapter->nickname) + 1)
- data->length = strlen(pAdapter->nickname) + 1;
- if (data->length > 0) {
- memcpy(nickname, pAdapter->nickname, data->length-1);
- nickname[data->length-1] = '\0';
- }
- return 0;
-}
-
-int rt_ioctl_siwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (rts->disabled)
- val = MAX_RTS_THRESHOLD;
- else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
- return -EINVAL;
- else if (rts->value == 0)
- val = MAX_RTS_THRESHOLD;
- else
- val = rts->value;
-
- if (val != pAdapter->CommonCfg.RtsThreshold)
- pAdapter->CommonCfg.RtsThreshold = val;
-
- return 0;
-}
-
-int rt_ioctl_giwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *rts, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- rts->value = pAdapter->CommonCfg.RtsThreshold;
- rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
- rts->fixed = 1;
-
- return 0;
-}
-
-int rt_ioctl_siwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- u16 val;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (frag->disabled)
- val = MAX_FRAG_THRESHOLD;
- else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
- val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
- else if (frag->value == 0)
- val = MAX_FRAG_THRESHOLD;
- else
- return -EINVAL;
-
- pAdapter->CommonCfg.FragmentThreshold = val;
- return 0;
-}
-
-int rt_ioctl_giwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *frag, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- frag->value = pAdapter->CommonCfg.FragmentThreshold;
- frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
- frag->fixed = 1;
-
- return 0;
-}
-
-#define MAX_WEP_KEY_SIZE 13
-#define MIN_WEP_KEY_SIZE 5
-int rt_ioctl_siwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((erq->length == 0) &&
- (erq->flags & IW_ENCODE_DISABLED))
- {
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- goto done;
- }
- else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- if (erq->flags & IW_ENCODE_RESTRICTED)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- }
-
- if (erq->length > 0)
- {
- int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
- /* Check the size of the key */
- if (erq->length > MAX_WEP_KEY_SIZE)
- {
- return -EINVAL;
- }
- /* Check key index */
- if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- {
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
- keyIdx, pAdapter->StaCfg.DefaultKeyId));
-
- //Using default key
- keyIdx = pAdapter->StaCfg.DefaultKeyId;
- }
- else
- {
- pAdapter->StaCfg.DefaultKeyId=keyIdx;
- }
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
-
- if (erq->length == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (erq->length == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- /* Disable the key */
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-
- /* Check if the key is not marked as invalid */
- if(!(erq->flags & IW_ENCODE_NOKEY))
- {
- /* Copy the key in the driver */
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
- }
- }
- else
- {
- /* Do we want to just set the transmit key index ? */
- int index = (erq->flags & IW_ENCODE_INDEX) - 1;
- if ((index >= 0) && (index < 4))
- {
- pAdapter->StaCfg.DefaultKeyId = index;
- }
- else
- /* Don't complain if only change the mode */
- if(!erq->flags & IW_ENCODE_MODE)
- {
- return -EINVAL;
- }
- }
-
-done:
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
- DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
- return 0;
-}
-
-int
-rt_ioctl_giwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *erq, char *key)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- int kid;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- kid = erq->flags & IW_ENCODE_INDEX;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
-
- if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
- {
- erq->length = 0;
- erq->flags = IW_ENCODE_DISABLED;
- }
- else if ((kid > 0) && (kid <=4))
- {
- // copy wep key
- erq->flags = kid ; /* NB: base 1 */
- if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
- erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
- //if ((kid == pAdapter->PortCfg.DefaultKeyId))
- //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
-
- }
- else if (kid == 0)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
- // copy default key ID
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
- erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
- else
- erq->flags |= IW_ENCODE_OPEN; /* XXX */
- erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
- erq->flags |= IW_ENCODE_ENABLED; /* XXX */
- }
-
- return 0;
-
-}
-
-static int
-rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
- void *w, char *extra)
-{
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAdapter;
- POS_COOKIE pObj;
- char *this_char = extra;
- char *value;
- int Status=0;
-
- if (dev->priv_flags == INT_MAIN)
- {
- pAdapter = dev->ml_priv;
- }
- else
- {
- pVirtualAd = dev->ml_priv;
- pAdapter = pVirtualAd->RtmpDev->ml_priv;
- }
- pObj = (POS_COOKIE) pAdapter->OS_Cookie;
-
- if (pAdapter == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (!*this_char)
- return -EINVAL;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value)
- return -EINVAL;
-
- // reject setting nothing besides ANY ssid(ssidLen=0)
- if (!*value && (strcmp(this_char, "SSID") != 0))
- return -EINVAL;
-
- for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
- {
- if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
- {
- if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
- { //FALSE:Set private failed then return Invalid argument
- Status = -EINVAL;
- }
- break; //Exit for loop.
- }
- }
-
- if(PRTMP_PRIVATE_SET_PROC->name == NULL)
- { //Not found argument
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
- }
-
- return Status;
-}
-
-
-static int
-rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- PRTMP_ADAPTER pAd = dev->ml_priv;
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n\n");
-
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- }
- sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
- sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
- sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
-
- sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
- sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
- sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
-
- sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
-#ifdef RALINK_ATE
- if (ATE_ON(pAd))
- {
- if (pAd->ate.RxAntennaSel == 0)
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
- else
- {
- sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
- }
- }
- else
-#endif // RALINK_ATE //
- {
- sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
- sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
-
- return Status;
-}
-
-#ifdef DOT11_N_SUPPORT
-void getBaInfo(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR pOutBuf)
-{
- INT i, j;
- BA_ORI_ENTRY *pOriBAEntry;
- BA_REC_ENTRY *pRecBAEntry;
-
- for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
- {
- PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
- if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
- || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
- {
- sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
- pOutBuf,
- pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
- pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
-
- sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BARecWcidArray[j] != 0)
- {
- pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
- }
- }
- sprintf(pOutBuf, "%s\n", pOutBuf);
-
- sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
- for (j=0; j < NUM_OF_TID; j++)
- {
- if (pEntry->BAOriWcidArray[j] != 0)
- {
- pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
- sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
- }
- }
- sprintf(pOutBuf, "%s\n\n", pOutBuf);
- }
- if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
- break;
- }
-
- return;
-}
-#endif // DOT11_N_SUPPORT //
-
-static int
-rt_private_show(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
-{
- INT Status = 0;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- PRTMP_ADAPTER pAd;
- POS_COOKIE pObj;
- u32 subcmd = wrq->flags;
-
- if (dev->priv_flags == INT_MAIN)
- pAd = dev->ml_priv;
- else
- {
- pVirtualAd = dev->ml_priv;
- pAd = pVirtualAd->RtmpDev->ml_priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- if (extra == NULL)
- {
- wrq->length = 0;
- return -EIO;
- }
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- {
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(subcmd)
- {
-
- case SHOW_CONN_STATUS:
- if (MONITOR_ON(pAd))
- {
-#ifdef DOT11_N_SUPPORT
- if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAd->CommonCfg.RegTransmitSetting.field.BW)
- sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
- else
-#endif // DOT11_N_SUPPORT //
- sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
- }
- else
- {
- if (pAd->IndicateMediaState == NdisMediaStateConnected)
- {
- if (INFRA_ON(pAd))
- {
- sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
- pAd->CommonCfg.Ssid,
- pAd->CommonCfg.Bssid[0],
- pAd->CommonCfg.Bssid[1],
- pAd->CommonCfg.Bssid[2],
- pAd->CommonCfg.Bssid[3],
- pAd->CommonCfg.Bssid[4],
- pAd->CommonCfg.Bssid[5]);
- DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
- }
- else if (ADHOC_ON(pAd))
- sprintf(extra, "Connected\n");
- }
- else
- {
- sprintf(extra, "Disconnected\n");
- DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
- }
- }
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case SHOW_DRVIER_VERION:
- sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#ifdef DOT11_N_SUPPORT
- case SHOW_BA_INFO:
- getBaInfo(pAd, extra);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-#endif // DOT11_N_SUPPORT //
- case SHOW_DESC_INFO:
- {
- Show_DescInfo_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
- case RAIO_OFF:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = FALSE;
- if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == FALSE)
- {
- MlmeRadioOff(pAd);
- // Update extra information
- pAd->ExtraInfo = SW_RADIO_OFF;
- }
- }
- sprintf(extra, "Radio Off\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- case RAIO_ON:
- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- sprintf(extra, "Scanning\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
- }
- pAd->StaCfg.bSwRadio = TRUE;
- //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
- {
- pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
- if (pAd->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAd);
- // Update extra information
- pAd->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- }
- sprintf(extra, "Radio On\n");
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case SHOW_DLS_ENTRY_INFO:
- {
- Set_DlsEntryInfo_Display_Proc(pAd, NULL);
- wrq->length = 0; // 1: size of '\0'
- }
- break;
-#endif // QOS_DLS_SUPPORT //
-
- case SHOW_CFG_VALUE:
- {
- Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
- if (Status == 0)
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- }
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd));
- break;
- }
-
- return Status;
-}
-
-#ifdef SIOCSIWMLME
-int rt_ioctl_siwmlme(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
- MLME_QUEUE_ELEM MsgElem;
- MLME_DISASSOC_REQ_STRUCT DisAssocReq;
- MLME_DEAUTH_REQ_STRUCT DeAuthReq;
-
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__));
-
- if (pMlme == NULL)
- return -EINVAL;
-
- switch(pMlme->cmd)
- {
-#ifdef IW_MLME_DEAUTH
- case IW_MLME_DEAUTH:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__));
- COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
- DeAuthReq.Reason = pMlme->reason_code;
- MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
- MlmeDeauthReqAction(pAd, &MsgElem);
- if (INFRA_ON(pAd))
- {
- LinkDown(pAd, FALSE);
- pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- break;
-#endif // IW_MLME_DEAUTH //
-#ifdef IW_MLME_DISASSOC
- case IW_MLME_DISASSOC:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__));
- COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
- DisAssocReq.Reason = pMlme->reason_code;
-
- MsgElem.Machine = ASSOC_STATE_MACHINE;
- MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
- MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
- NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
- pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
- MlmeDisassocReqAction(pAd, &MsgElem);
- break;
-#endif // IW_MLME_DISASSOC //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__));
- break;
- }
-
- return 0;
-}
-#endif // SIOCSIWMLME //
-
-#if WIRELESS_EXT > 17
-int rt_ioctl_siwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_WPA_VERSION:
- if (param->value == IW_AUTH_WPA_VERSION_WPA)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- }
- else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_CIPHER_GROUP:
- if (param->value == IW_AUTH_CIPHER_NONE)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if (param->value == IW_AUTH_CIPHER_WEP40 ||
- param->value == IW_AUTH_CIPHER_WEP104)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if (param->value == IW_AUTH_CIPHER_TKIP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if (param->value == IW_AUTH_CIPHER_CCMP)
- {
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_KEY_MGMT:
- if (param->value == IW_AUTH_KEY_MGMT_802_1X)
- {
- if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#ifdef WPA_SUPPLICANT_SUPPORT
- pAdapter->StaCfg.IEEE8021X = FALSE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
-#ifdef WPA_SUPPLICANT_SUPPORT
- else
- // WEP 1x
- pAdapter->StaCfg.IEEE8021X = TRUE;
-#endif // WPA_SUPPLICANT_SUPPORT //
- }
- else if (param->value == 0)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- break;
- case IW_AUTH_PRIVACY_INVOKED:
- /*if (param->value == 0)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }*/
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_DROP_UNENCRYPTED:
- if (param->value != 0)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_80211_AUTH_ALG:
- if (param->value & IW_AUTH_ALG_SHARED_KEY)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- }
- else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
- {
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- }
- else
- return -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value));
- break;
- case IW_AUTH_WPA_ENABLED:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value));
- break;
- default:
- return -EOPNOTSUPP;
-}
-
- return 0;
-}
-
-int rt_ioctl_giwauth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- struct iw_param *param = &wrqu->param;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- switch (param->flags & IW_AUTH_INDEX) {
- case IW_AUTH_DROP_UNENCRYPTED:
- param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
- param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
- break;
-
- case IW_AUTH_WPA_ENABLED:
- param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
- break;
-
- default:
- return -EOPNOTSUPP;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
- return 0;
-}
-
-void fnSetCipherKey(
- IN PRTMP_ADAPTER pAdapter,
- IN INT keyIdx,
- IN UCHAR CipherAlg,
- IN BOOLEAN bGTK,
- IN struct iw_encode_ext *ext)
-{
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
-
- // Update group key information to ASIC Shared Key Table
- AsicAddSharedKeyEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- pAdapter->SharedKey[BSS0][keyIdx].Key,
- pAdapter->SharedKey[BSS0][keyIdx].TxMic,
- pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-
- if (bGTK)
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- NULL);
- else
- // Update ASIC WCID attribute table and IVEIV table
- RTMPAddWcidAttributeEntry(pAdapter,
- BSS0,
- keyIdx,
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
- &pAdapter->MacTab.Content[BSSID_WCID]);
-}
-
-int rt_ioctl_siwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
- {
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int keyIdx, alg = ext->alg;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if (encoding->flags & IW_ENCODE_DISABLED)
- {
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- // set BSSID wcid entry of the Pair-wise Key table as no-security mode
- AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
- NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
- DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags));
- }
- else
- {
- // Get Key Index and convet to our own defined key index
- keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
- if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
- return -EINVAL;
-
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- pAdapter->StaCfg.DefaultKeyId = keyIdx;
- DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId));
- }
-
- switch (alg) {
- case IW_ENCODE_ALG_NONE:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__));
- break;
- case IW_ENCODE_ALG_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx));
- if (ext->key_len == MAX_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
- }
- else if (ext->key_len == MIN_WEP_KEY_SIZE)
- {
- pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
- pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
- }
- else
- return -EINVAL;
-
- NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
- NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
- break;
- case IW_ENCODE_ALG_TKIP:
- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len));
- if (ext->key_len == 32)
- {
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- {
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- }
- else
- return -EINVAL;
- break;
- case IW_ENCODE_ALG_CCMP:
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
- {
- fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
-
- // set 802.1x port control
- //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- STA_PORT_SECURED(pAdapter);
- }
- break;
- default:
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-int
-rt_ioctl_giwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- PCHAR pKey = NULL;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int idx, max_key_len;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
-
- max_key_len = encoding->length - sizeof(*ext);
- if (max_key_len < 0)
- return -EINVAL;
-
- idx = encoding->flags & IW_ENCODE_INDEX;
- if (idx)
- {
- if (idx < 1 || idx > 4)
- return -EINVAL;
- idx--;
-
- if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
- (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
- {
- if (idx != pAd->StaCfg.DefaultKeyId)
- {
- ext->key_len = 0;
- return 0;
- }
- }
- }
- else
- idx = pAd->StaCfg.DefaultKeyId;
-
- encoding->flags = idx + 1;
- memset(ext, 0, sizeof(*ext));
-
- ext->key_len = 0;
- switch(pAd->StaCfg.WepStatus) {
- case Ndis802_11WEPDisabled:
- ext->alg = IW_ENCODE_ALG_NONE;
- encoding->flags |= IW_ENCODE_DISABLED;
- break;
- case Ndis802_11WEPEnabled:
- ext->alg = IW_ENCODE_ALG_WEP;
- if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
- return -E2BIG;
- else
- {
- ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
- pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
- }
- break;
- case Ndis802_11Encryption2Enabled:
- case Ndis802_11Encryption3Enabled:
- if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
- ext->alg = IW_ENCODE_ALG_TKIP;
- else
- ext->alg = IW_ENCODE_ALG_CCMP;
-
- if (max_key_len < 32)
- return -E2BIG;
- else
- {
- ext->key_len = 32;
- pKey = &pAd->StaCfg.PMK[0];
- }
- break;
- default:
- return -EINVAL;
- }
-
- if (ext->key_len && pKey)
- {
- encoding->flags |= IW_ENCODE_ENABLED;
- memcpy(ext->key, pKey, ext->key_len);
- }
-
- return 0;
-}
-
-#ifdef SIOCSIWGENIE
-int rt_ioctl_siwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
-
- if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
- (wrqu->data.length && extra == NULL))
- return -EINVAL;
-
- if (wrqu->data.length)
- {
- pAd->StaCfg.RSNIE_Len = wrqu->data.length;
- NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
- }
- else
- {
- pAd->StaCfg.RSNIE_Len = 0;
- NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
- }
-
- return 0;
-}
-#endif // SIOCSIWGENIE //
-
-int rt_ioctl_giwgenie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
-
- if ((pAd->StaCfg.RSNIE_Len == 0) ||
- (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
- {
- wrqu->data.length = 0;
- return 0;
- }
-
-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
-#ifdef SIOCSIWGENIE
- if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
- {
- if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
- return -E2BIG;
-
- wrqu->data.length = pAd->StaCfg.RSNIE_Len;
- memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
- else
-#endif // SIOCSIWGENIE //
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
- {
- UCHAR RSNIe = IE_WPA;
-
- if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
- return -E2BIG;
- wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-
- if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
- RSNIe = IE_RSN;
-
- extra[0] = (char)RSNIe;
- extra[1] = pAd->StaCfg.RSNIE_Len;
- memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
- }
-
- return 0;
-}
-
-int rt_ioctl_siwpmksa(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
- INT CachedIdx = 0, idx = 0;
-
- if (pPmksa == NULL)
- return -EINVAL;
-
- DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
- switch(pPmksa->cmd)
- {
- case IW_PMKSA_FLUSH:
- NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
- break;
- case IW_PMKSA_REMOVE:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- {
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
- NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
- for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
- {
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
- }
- pAd->StaCfg.SavedPMKNum--;
- break;
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
- break;
- case IW_PMKSA_ADD:
- for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- pAd->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
- NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
- }
-
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
- break;
- }
-
- return 0;
-}
-#endif // #if WIRELESS_EXT > 17
-
-#ifdef DBG
-static int
-rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
- struct iw_point *wrq, char *extra)
- {
- CHAR *this_char;
- CHAR *value = NULL;
- UCHAR regBBP = 0;
-// CHAR arg[255]={0};
- UINT32 bbpId;
- UINT32 bbpValue;
- BOOLEAN bIsPrintAllBBP = FALSE;
- INT Status = 0;
- PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
- if (wrq->length > 1) //No parameters.
- {
- sprintf(extra, "\n");
-
- //Parsing Read or Write
- this_char = wrq->pointer;
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
- if (sscanf(this_char, "%d", &(bbpId)) == 1)
- {
-#ifndef RT30xx
- if (bbpId <= 136)
-#endif // RT30xx //
-#ifdef RT30xx
- if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
-#endif // RT30xx //
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Write
- if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
- {
-#ifndef RT30xx
- if (bbpId <= 136)
-#endif // RT30xx //
-#ifdef RT30xx
- if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
-#endif // RT30xx //
- {
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- {
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
- //Read it back for showing
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all bbp
- bIsPrintAllBBP = TRUE;
- goto next;
- }
- }
- }
- else
- bIsPrintAllBBP = TRUE;
-
-next:
- if (bIsPrintAllBBP)
- {
- memset(extra, 0x00, IW_PRIV_SIZE_MASK);
- sprintf(extra, "\n");
-#ifndef RT30xx
- for (bbpId = 0; bbpId <= 136; bbpId++)
-#endif // RT30xx //
-#ifdef RT30xx
- for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
-#endif // RT30xx //
- {
- if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
- break;
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-/*
- sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
- if (bbpId%5 == 4)
- sprintf(extra+strlen(extra), "\n");
-*/
- sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
- }
-
- wrq->length = strlen(extra) + 1; // 1: size of '\0'
- DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
-
- return Status;
-}
-#endif // DBG //
-
-int rt_ioctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
- return -ENETDOWN;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
- /* rate = -1 => auto rate
- rate = X, fixed = 1 => (fixed rate X)
- */
- if (rate == -1)
- {
- //Auto Rate
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
- pAd->StaCfg.bAutoTxRateSwitch = TRUE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, -1);
-
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- else
- {
- if (fixed)
- {
- pAd->StaCfg.bAutoTxRateSwitch = FALSE;
- if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
- (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
- RTMPSetDesiredRates(pAd, rate);
- else
- {
- pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAd);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
- }
- else
- {
- // TODO: rate = X, fixed = 0 => (rates <= X)
- return -EOPNOTSUPP;
- }
- }
-
- return 0;
-}
-
-int rt_ioctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- PRTMP_ADAPTER pAd = dev->ml_priv;
- int rate_index = 0, rate_count = 0;
- HTTRANSMIT_SETTING ht_setting;
- __s32 ralinkrate[] =
- {2, 4, 11, 22, // CCK
- 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
- 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
- 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
- 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
- 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
- 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
- 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
- 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
- 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
-
- rate_count = sizeof(ralinkrate)/sizeof(__s32);
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
-
- if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
- (INFRA_ON(pAd)) &&
- ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
- ht_setting.word = pAd->StaCfg.HTPhyMode.word;
- else
- ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-
-#ifdef DOT11_N_SUPPORT
- if (ht_setting.field.MODE >= MODE_HTMIX)
- {
-// rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
- rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
- }
- else
-#endif // DOT11_N_SUPPORT //
- if (ht_setting.field.MODE == MODE_OFDM)
- rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
- else if (ht_setting.field.MODE == MODE_CCK)
- rate_index = (UCHAR)(ht_setting.field.MCS);
-
- if (rate_index < 0)
- rate_index = 0;
-
- if (rate_index > rate_count)
- rate_index = rate_count;
-
- wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
- wrqu->bitrate.disabled = 0;
-
- return 0;
-}
-
-static const iw_handler rt_handler[] =
-{
- (iw_handler) NULL, /* SIOCSIWCOMMIT */
- (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
- (iw_handler) NULL, /* SIOCSIWNWID */
- (iw_handler) NULL, /* SIOCGIWNWID */
- (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
- (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
- (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
- (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
- (iw_handler) NULL, /* SIOCSIWSENS */
- (iw_handler) NULL, /* SIOCGIWSENS */
- (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
- (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
- (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
- (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
- (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
- (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
- (iw_handler) NULL, /* SIOCSIWSPY */
- (iw_handler) NULL, /* SIOCGIWSPY */
- (iw_handler) NULL, /* SIOCSIWTHRSPY */
- (iw_handler) NULL, /* SIOCGIWTHRSPY */
- (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
- (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
-#ifdef SIOCSIWMLME
- (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
-#else
- (iw_handler) NULL, /* SIOCSIWMLME */
-#endif // SIOCSIWMLME //
- (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
-#ifdef SIOCGIWSCAN
- (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
- (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
-#else
- (iw_handler) NULL, /* SIOCSIWSCAN */
- (iw_handler) NULL, /* SIOCGIWSCAN */
-#endif /* SIOCGIWSCAN */
- (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
- (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
- (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
- (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
- (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
- (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
- (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
- (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
- (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
- (iw_handler) NULL, /* SIOCSIWTXPOW */
- (iw_handler) NULL, /* SIOCGIWTXPOW */
- (iw_handler) NULL, /* SIOCSIWRETRY */
- (iw_handler) NULL, /* SIOCGIWRETRY */
- (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
- (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
- (iw_handler) NULL, /* SIOCSIWPOWER */
- (iw_handler) NULL, /* SIOCGIWPOWER */
- (iw_handler) NULL, /* -- hole -- */
- (iw_handler) NULL, /* -- hole -- */
-#if WIRELESS_EXT > 17
- (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
- (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
- (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
- (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
- (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
- (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
- (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
-#endif
-};
-
-static const iw_handler rt_priv_handlers[] = {
- (iw_handler) NULL, /* + 0x00 */
- (iw_handler) NULL, /* + 0x01 */
-#ifndef CONFIG_AP_SUPPORT
- (iw_handler) rt_ioctl_setparam, /* + 0x02 */
-#else
- (iw_handler) NULL, /* + 0x02 */
-#endif // CONFIG_AP_SUPPORT //
-#ifdef DBG
- (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
-#else
- (iw_handler) NULL, /* + 0x03 */
-#endif
- (iw_handler) NULL, /* + 0x04 */
- (iw_handler) NULL, /* + 0x05 */
- (iw_handler) NULL, /* + 0x06 */
- (iw_handler) NULL, /* + 0x07 */
- (iw_handler) NULL, /* + 0x08 */
- (iw_handler) rt_private_get_statistics, /* + 0x09 */
- (iw_handler) NULL, /* + 0x0A */
- (iw_handler) NULL, /* + 0x0B */
- (iw_handler) NULL, /* + 0x0C */
- (iw_handler) NULL, /* + 0x0D */
- (iw_handler) NULL, /* + 0x0E */
- (iw_handler) NULL, /* + 0x0F */
- (iw_handler) NULL, /* + 0x10 */
- (iw_handler) rt_private_show, /* + 0x11 */
- (iw_handler) NULL, /* + 0x12 */
- (iw_handler) NULL, /* + 0x13 */
- (iw_handler) NULL, /* + 0x15 */
- (iw_handler) NULL, /* + 0x17 */
- (iw_handler) NULL, /* + 0x18 */
-};
-
-const struct iw_handler_def rt28xx_iw_handler_def =
-{
-#define N(a) (sizeof (a) / sizeof (a[0]))
- .standard = (iw_handler *) rt_handler,
- .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
- .private = (iw_handler *) rt_priv_handlers,
- .num_private = N(rt_priv_handlers),
- .private_args = (struct iw_priv_args *) privtab,
- .num_private_args = N(privtab),
-#if IW_HANDLER_VERSION >= 7
- .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif
-};
-
-INT RTMPSetInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_MAC_ADDRESS Bssid;
- RT_802_11_PHY_MODE PhyMode;
- RT_802_11_STA_CONFIG StaConfig;
- NDIS_802_11_RATES aryRates;
- RT_802_11_PREAMBLE Preamble;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- PNDIS_802_11_KEY pKey = NULL;
- PNDIS_802_11_WEP pWepKey =NULL;
- PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
- NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
- NDIS_802_11_NETWORK_TYPE NetType;
- ULONG Now;
- UINT KeyIdx = 0;
- INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
- ULONG PowerTemp;
- BOOLEAN RadioState;
- BOOLEAN StateMachineTouched = FALSE;
-#ifdef DOT11_N_SUPPORT
- OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
-#endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT
- PNDIS_802_11_PMKID pPmkId = NULL;
- BOOLEAN IEEE8021xState = FALSE;
- BOOLEAN IEEE8021x_required_keys = FALSE;
- UCHAR wpa_supplicant_enable = 0;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef SNMP_SUPPORT
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR ctmp;
-#endif // SNMP_SUPPORT //
-
-
-#ifdef DOT11_N_SUPPORT
- MaxPhyMode = PHY_11N_5G;
-#endif // DOT11_N_SUPPORT //
-
-
- DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
- switch(cmd & 0x7FFF) {
- case RT_OID_802_11_COUNTRY_REGION:
- if (wrq->u.data.length < sizeof(UCHAR))
- Status = -EINVAL;
- // Only avaliable when EEPROM not programming
- else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
- {
- ULONG Country;
- UCHAR TmpPhy;
-
- Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
- pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
- TmpPhy = pAdapter->CommonCfg.PhyMode;
- pAdapter->CommonCfg.PhyMode = 0xff;
- // Build all corresponding channel information
- RTMPSetPhyMode(pAdapter, TmpPhy);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
- pAdapter->CommonCfg.CountryRegion));
- }
- break;
- case OID_802_11_BSSID_LIST_SCAN:
- #ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- Now = jiffies;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
-
- if (MONITOR_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
- break;
- }
-
- //Benson add 20080527, when radio off, sta don't need to scan
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
- break;
-
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- Status = NDIS_STATUS_SUCCESS;
- break;
- }
-
- if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
- if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
- ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
- (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
- Status = NDIS_STATUS_SUCCESS;
- pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
- break;
- }
-
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
- pAdapter->StaCfg.LastScanTime = Now;
-
- pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
- RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID_LIST_SCAN,
- 0,
- NULL);
-
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
- break;
- case OID_802_11_SSID:
- if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
- Status = -EINVAL;
- else
- {
- PCHAR pSsidString = NULL;
- Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- if (Ssid.SsidLength > MAX_LEN_OF_SSID)
- Status = -EINVAL;
- else
- {
- if (Ssid.SsidLength == 0)
- {
- Set_SSID_Proc(pAdapter, "");
- }
- else
- {
- pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
- if (pSsidString)
- {
- NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
- NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
- Set_SSID_Proc(pAdapter, pSsidString);
- kfree(pSsidString);
- }
- else
- Status = -ENOMEM;
- }
- }
- }
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
-
- // tell CNTL state machine to call NdisMSetInformationComplete() after completing
- // this request, because this request is initiated by NDIS.
- pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-
- // Prevent to connect AP again in STAMlmePeriodicExec
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
- // Reset allowed scan retries
- pAdapter->StaCfg.ScanCnt = 0;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_BSSID,
- sizeof(NDIS_802_11_MAC_ADDRESS),
- (VOID *)&Bssid);
- Status = NDIS_STATUS_SUCCESS;
- StateMachineTouched = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
- Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
- }
- break;
- case RT_OID_802_11_RADIO:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
- if (pAdapter->StaCfg.bSwRadio != RadioState)
- {
- pAdapter->StaCfg.bSwRadio = RadioState;
- if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
- {
- pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
- if (pAdapter->StaCfg.bRadio == TRUE)
- {
- MlmeRadioOn(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
- }
- else
- {
- MlmeRadioOff(pAdapter);
- // Update extra information
- pAdapter->ExtraInfo = SW_RADIO_OFF;
- }
- }
- }
- }
- break;
- case RT_OID_802_11_PHY_MODE:
- if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PhyMode <= MaxPhyMode)
- {
- RTMPSetPhyMode(pAdapter, PhyMode);
-#ifdef DOT11_N_SUPPORT
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
- }
- break;
- case RT_OID_802_11_STA_CONFIG:
- if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
- pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
- pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
- if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
- (StaConfig.AdhocMode <= MaxPhyMode))
- {
- // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
- // if setting changed, need to reset current TX rate as well as BEACON frame format
- pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- {
- RTMPSetPhyMode(pAdapter, PhyMode);
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- MakeIbssBeacon(pAdapter); // re-build BEACON frame
- AsicEnableIbssSync(pAdapter); // copy to on-chip memory
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
- pAdapter->CommonCfg.bEnableTxBurst,
- pAdapter->CommonCfg.UseBGProtection,
- pAdapter->CommonCfg.bUseShortSlotTime));
- }
- break;
- case OID_802_11_DESIRED_RATES:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
- NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
- NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
- pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
- pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
- pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
- pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
- // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
- MlmeUpdateTxRates(pAdapter, FALSE, 0);
- }
- break;
- case RT_OID_802_11_PREAMBLE:
- if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
- if (Preamble == Rt802_11PreambleShort)
- {
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
- }
- else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
- {
- // if user wants AUTO, initialize to LONG here, then change according to AP's
- // capability upon association.
- pAdapter->CommonCfg.TxPreamble = Preamble;
- MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
- }
- break;
- case OID_802_11_WEP_STATUS:
- if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
- // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
- if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
- {
- if (pAdapter->StaCfg.WepStatus != WepStatus)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.WepStatus = WepStatus;
- pAdapter->StaCfg.OrigWepStatus = WepStatus;
- pAdapter->StaCfg.PairCipher = WepStatus;
- pAdapter->StaCfg.GroupCipher = WepStatus;
- }
- else
- {
- Status = -EINVAL;
- break;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
- }
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
- if (AuthMode > Ndis802_11AuthModeMax)
- {
- Status = -EINVAL;
- break;
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode != AuthMode)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- pAdapter->StaCfg.AuthMode = AuthMode;
- }
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
- }
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (BssType == Ndis802_11IBSS)
- Set_NetworkType_Proc(pAdapter, "Adhoc");
- else if (BssType == Ndis802_11Infrastructure)
- Set_NetworkType_Proc(pAdapter, "Infra");
- else if (BssType == Ndis802_11Monitor)
- Set_NetworkType_Proc(pAdapter, "Monitor");
- else
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
- }
- }
- break;
- case OID_802_11_REMOVE_WEP:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
- if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
- {
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx >= 4){
- Status = -EINVAL;
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- }
- }
- }
- break;
- case RT_OID_802_11_RESET_COUNTERS:
- NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
- NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
- NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
- pAdapter->Counters8023.RxNoBuffer = 0;
- pAdapter->Counters8023.GoodReceives = 0;
- pAdapter->Counters8023.RxNoBuffer = 0;
-#ifdef RT2870
- pAdapter->BulkOutComplete = 0;
- pAdapter->BulkOutCompleteOther= 0;
- pAdapter->BulkOutCompleteCancel = 0;
- pAdapter->BulkOutReq = 0;
- pAdapter->BulkInReq= 0;
- pAdapter->BulkInComplete = 0;
- pAdapter->BulkInCompleteFail = 0;
-#endif // RT2870 //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
- break;
- case OID_802_11_RTS_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
- if (RtsThresh > MAX_RTS_THRESHOLD)
- Status = -EINVAL;
- else
- pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
- if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
- {
- if (FragThresh == 0)
- {
- pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
- pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
- }
- else
- Status = -EINVAL;
- }
- else
- pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerMode == Ndis802_11PowerModeCAM)
- Set_PSMode_Proc(pAdapter, "CAM");
- else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
- Set_PSMode_Proc(pAdapter, "Max_PSP");
- else if (PowerMode == Ndis802_11PowerModeFast_PSP)
- Set_PSMode_Proc(pAdapter, "Fast_PSP");
- else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
- Set_PSMode_Proc(pAdapter, "Legacy_PSP");
- else
- Status = -EINVAL;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- if (wrq->u.data.length < sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
- if (PowerTemp > 100)
- PowerTemp = 0xffffffff; // AUTO
- pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
- pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- }
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
-
- if (NetType == Ndis802_11DS)
- RTMPSetPhyMode(pAdapter, PHY_11B);
- else if (NetType == Ndis802_11OFDM24)
- RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
- else if (NetType == Ndis802_11OFDM5)
- RTMPSetPhyMode(pAdapter, PHY_11A);
- else
- Status = -EINVAL;
-#ifdef DOT11_N_SUPPORT
- if (Status == NDIS_STATUS_SUCCESS)
- SetCommonHT(pAdapter);
-#endif // DOT11_N_SUPPORT //
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
- }
- break;
- // For WPA PSK PMK key
- case RT_OID_802_11_ADD_WPA:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
- }
- else
- {
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
- {
- Status = -EOPNOTSUPP;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
- }
- else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
- (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
- {
- NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
- // Use RaConfig as PSK agent.
- // Start STA supplicant state machine
- if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- pAdapter->StaCfg.WpaState = SS_START;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- else
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- }
- kfree(pKey);
- break;
- case OID_802_11_REMOVE_KEY:
- pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pRemoveKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
-
- Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pRemoveKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
- }
- else
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- {
- RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
- }
- else
- {
- KeyIdx = pRemoveKey->KeyIndex;
-
- if (KeyIdx & 0x80000000)
- {
- // Should never set default bit when remove key
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
- }
- else
- {
- KeyIdx = KeyIdx & 0x0fffffff;
- if (KeyIdx > 3)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
- }
- else
- {
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
- AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
- }
- }
- }
- }
- kfree(pRemoveKey);
- break;
- // New for WPA
- case OID_802_11_ADD_KEY:
- pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
- if(pKey == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- if (pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
- }
- else
- {
- RTMPAddKey(pAdapter, pKey);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
- }
- kfree(pKey);
- break;
- case OID_802_11_CONFIGURATION:
- if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
- pConfig = &Config;
-
- if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
- pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
-
- pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
- MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
- //
- // Save the channel on MlmeAux for CntlOidRTBssidProc used.
- //
- pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
- pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- }
- break;
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_HT_PHYMODE:
- if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
- Status = -EINVAL;
- else
- {
- POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
-
- Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
- pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
- pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
- RTMPSetHT(pAdapter, pHTPhyMode);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
- pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
- pAdapter->StaCfg.HTPhyMode.field.STBC));
- break;
-#endif // DOT11_N_SUPPORT //
- case RT_OID_802_11_SET_APSD_SETTING:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- ULONG apsd ;
- Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
-
- /*-------------------------------------------------------------------
- |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
- ---------------------------------------------------------------------
- | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
- ---------------------------------------------------------------------*/
- pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
- pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
- pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
- pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
- }
- break;
-
- case RT_OID_802_11_SET_APSD_PSM:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- // Driver needs to notify AP when PSM changes
- Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
- if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
- {
- MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
- RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- }
- break;
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_SET_DLS:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
- Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
- if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
- {
- int i;
- // tear down local dls table entry
- for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
-
- // tear down peer dls table entry
- for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
- {
- pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
- pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
- RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
- }
- }
- }
-
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- }
- break;
-
- case RT_OID_802_11_SET_DLS_PARAM:
- if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
- Status = -EINVAL;
- else
- {
- RT_802_11_DLS Dls;
-
- NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
- RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- RT_OID_802_11_SET_DLS_PARAM,
- sizeof(RT_802_11_DLS),
- &Dls);
- DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- case RT_OID_802_11_SET_WMM:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
- }
- break;
-
- case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- break;
- }
-#endif // RALINK_ATE //
- //
- // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
- // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
- // when query OID_802_11_BSSID_LIST.
- //
- // TRUE: NumberOfItems will set to 0.
- // FALSE: NumberOfItems no change.
- //
- pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
- // Set to immediately send the media disconnect event
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
-
- if (INFRA_ON(pAdapter))
- {
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_DISASSOCIATE,
- 0,
- NULL);
-
- StateMachineTouched = TRUE;
- }
- break;
-
-#ifdef DOT11_N_SUPPORT
- case RT_OID_802_11_SET_IMME_BA_CAP:
- if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
- Status = -EINVAL;
- else
- {
- OID_BACAP_STRUC Orde ;
- Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
- if (Orde.Policy > BA_NOTUSE)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- }
- else if (Orde.Policy == BA_NOTUSE)
- {
- pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
- }
- else
- {
- pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
- pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
- pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
- pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-
- // UPdata to HT IE
- pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
- pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
- pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-
- if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
-
- }
-
- pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
- DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
- pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
- }
-
- break;
- case RT_OID_802_11_ADD_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- UCHAR index;
- OID_ADD_BA_ENTRY BA;
- MAC_TABLE_ENTRY *pEntry;
-
- Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
- if (BA.TID > 15)
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
- else
- {
- //BATableInsertEntry
- //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
- index = BA.TID;
- // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
- pEntry = MacTableLookup(pAdapter, BA.MACAddr);
- if (!pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
- break;
- }
- if (BA.IsRecipient == FALSE)
- {
- if (pEntry->bIAmBadAtheros == TRUE)
- pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
-
- BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
- }
- else
- {
- //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
- BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
- , BA.MACAddr[4], BA.MACAddr[5]));
- }
- }
- break;
-
- case RT_OID_802_11_TEAR_IMME_BA:
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
- if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
- Status = -EINVAL;
- else
- {
- POID_ADD_BA_ENTRY pBA;
- MAC_TABLE_ENTRY *pEntry;
-
- pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if (pBA == NULL)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
- Status = NDIS_STATUS_FAILURE;
- }
- else
- {
- Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
-
- if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
- {
- Status = NDIS_STATUS_INVALID_DATA;
- break;
- }
-
- if (pBA->IsRecipient == FALSE)
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
- if (pEntry)
- {
- DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
- BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- else
- {
- pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
- if (pEntry)
- {
- BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
- }
- else
- DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
- }
- kfree(pBA);
- }
- }
- break;
-#endif // DOT11_N_SUPPORT //
-
- // For WPA_SUPPLICANT to set static wep key
- case OID_802_11_ADD_WEP:
- pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pWepKey == NULL)
- {
- Status = -ENOMEM;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
- break;
- }
- Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
- if (Status)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
- }
- else
- {
- KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
- // KeyIdx must be 0 ~ 3
- if (KeyIdx > 4)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
- }
- else
- {
- UCHAR CipherAlg = 0;
- PUCHAR Key;
-
- // set key material and key length
- NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
- pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
-
- switch(pWepKey->KeyLength)
- {
- case 5:
- CipherAlg = CIPHER_WEP64;
- break;
- case 13:
- CipherAlg = CIPHER_WEP128;
- break;
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
- Status = -EINVAL;
- break;
- }
- pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
-
- // Default key for tx (shared key)
- if (pWepKey->KeyIndex & 0x80000000)
- {
-#ifdef WPA_SUPPLICANT_SUPPORT
- // set key material and key length
- NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
- NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
- pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
- pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-#endif // WPA_SUPPLICANT_SUPPORT //
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
-
-#ifdef WPA_SUPPLICANT_SUPPORT
- if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
-#endif // WPA_SUPPLICANT_SUPPORT
- {
- Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
-
- // Set key material and cipherAlg to Asic
- AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
- if (pWepKey->KeyIndex & 0x80000000)
- {
- PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
- // Assign group key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
- // Assign pairwise key info
- RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
- }
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
- }
- }
- kfree(pWepKey);
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case OID_SET_COUNTERMEASURES:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.bBlockAssoc = TRUE;
- else
- // WPA MIC error should block association attempt for 60 seconds
- pAdapter->StaCfg.bBlockAssoc = FALSE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- }
- break;
- case OID_802_11_DEAUTHENTICATION:
- if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
- Status = -EINVAL;
- else
- {
- MLME_DEAUTH_REQ_STRUCT *pInfo;
- MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
- pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
- Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
- MlmeDeauthReqAction(pAdapter, MsgElem);
- kfree(MsgElem);
-
- if (INFRA_ON(pAdapter))
- {
- LinkDown(pAdapter, FALSE);
- pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
- }
- break;
- case OID_802_11_DROP_UNENCRYPTED:
- if (wrq->u.data.length != sizeof(int))
- Status = -EINVAL;
- else
- {
- int enabled = 0;
- Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
- if (enabled == 1)
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
- else
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
- NdisAcquireSpinLock(&pAdapter->MacTabLock);
- pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
- NdisReleaseSpinLock(&pAdapter->MacTabLock);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
- }
- break;
- case OID_802_11_SET_IEEE8021X:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
- }
- break;
- case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
- if (wrq->u.data.length != sizeof(BOOLEAN))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
- pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
- }
- break;
- case OID_802_11_PMKID:
- pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
- if(pPmkId == NULL) {
- Status = -ENOMEM;
- break;
- }
- Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
-
- // check the PMKID information
- if (pPmkId->BSSIDInfoCount == 0)
- NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
- else
- {
- PBSSID_INFO pBssIdInfo;
- UINT BssIdx;
- UINT CachedIdx;
-
- for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
- {
- // point to the indexed BSSID_INFO structure
- pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
- // Find the entry in the saved data base.
- for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
- {
- // compare the BSSID
- if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
- break;
- }
-
- // Found, replace it
- if (CachedIdx < PMKID_NO)
- {
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- pAdapter->StaCfg.SavedPMKNum++;
- }
- // Not found, replace the last one
- else
- {
- // Randomly replace one
- CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
- DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
- NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
- }
- }
- }
- if(pPmkId)
- kfree(pPmkId);
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-
-
-#ifdef SNMP_SUPPORT
- case OID_802_11_SHORTRETRYLIMIT:
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
- }
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
- if (wrq->u.data.length != sizeof(ULONG))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
- }
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
- pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
- Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
- //pKey = &WepKey;
-
- if ( pKey->Length != wrq->u.data.length)
- {
- Status = -EINVAL;
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
- }
- KeyIdx = pKey->KeyIndex & 0x0fffffff;
- DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
-
- // it is a shared key
- if (KeyIdx > 4)
- Status = -EINVAL;
- else
- {
- pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
- NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
- if (pKey->KeyIndex & 0x80000000)
- {
- // Default key for tx (shared key)
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
- }
- //RestartAPIsRequired = TRUE;
- }
- break;
-
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
-
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
-
- break;
-
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
- if (wrq->u.data.length != sizeof(UCHAR))
- Status = -EINVAL;
- else
- {
- Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
- sprintf(&ctmp,"%d", ctmp);
- Set_Channel_Proc(pAdapter, &ctmp);
- }
- break;
-#endif
-
-
-
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
-
- return Status;
-}
-
-INT RTMPQueryInformation(
- IN PRTMP_ADAPTER pAdapter,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
- PNDIS_WLAN_BSSID_EX pBss;
- NDIS_802_11_SSID Ssid;
- NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
- RT_802_11_LINK_STATUS *pLinkStatus = NULL;
- RT_802_11_STA_CONFIG *pStaConfig = NULL;
- NDIS_802_11_STATISTICS *pStatistics = NULL;
- NDIS_802_11_RTS_THRESHOLD RtsThresh;
- NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
- NDIS_802_11_POWER_MODE PowerMode;
- NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
- RT_802_11_PREAMBLE PreamType;
- NDIS_802_11_AUTHENTICATION_MODE AuthMode;
- NDIS_802_11_WEP_STATUS WepStatus;
- NDIS_MEDIA_STATE MediaState;
- ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
- USHORT BssLen = 0;
- PUCHAR pBuf = NULL, pPtr;
- INT Status = NDIS_STATUS_SUCCESS;
- UINT we_version_compiled;
- UCHAR i, Padding = 0;
- BOOLEAN RadioState;
- UCHAR driverVersion[8];
- OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
-
-
-#ifdef SNMP_SUPPORT
- //for snmp, kathy
- DefaultKeyIdxValue *pKeyIdxValue;
- INT valueLen;
- TX_RTY_CFG_STRUC tx_rty_cfg;
- ULONG ShortRetryLimit, LongRetryLimit;
- UCHAR tmp[64];
-#endif //SNMP
-
- switch(cmd)
- {
- case RT_OID_DEVICE_NAME:
- wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
- Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
- break;
- case RT_OID_VERSION_INFO:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
- wrq->u.data.length = 8*sizeof(UCHAR);
- sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
- driverVersion[7] = '\0';
- if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#ifdef RALINK_ATE
- case RT_QUERY_ATE_TXDONE_COUNT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
- wrq->u.data.length = sizeof(UINT32);
- if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
-#endif // RALINK_ATE //
- case OID_802_11_BSSID_LIST:
- if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
- {
- /*
- * Still scanning, indicate the caller should try again.
- */
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
- return -EAGAIN;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- // Claculate total buffer size required
- BssBufSize = sizeof(ULONG);
-
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- // Align pointer to 4 bytes boundary.
- //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
- //if (Padding == 4)
- // Padding = 0;
- BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
- }
-
- // For safety issue, we add 256 bytes just in case
- BssBufSize += 256;
- // Allocate the same size as passed from higher layer
- pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
- if(pBuf == NULL)
- {
- Status = -ENOMEM;
- break;
- }
- // Init 802_11_BSSID_LIST_EX structure
- NdisZeroMemory(pBuf, BssBufSize);
- pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
- pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
-
- // Calculate total buffer length
- BssLen = 4; // Consist of NumberOfItems
- // Point to start of NDIS_WLAN_BSSID_EX
- // pPtr = pBuf + sizeof(ULONG);
- pPtr = (PUCHAR) &pBssidList->Bssid[0];
- for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
- {
- pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
- NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
- if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
- {
- //
- // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
- // and then failed to send EAPOl farame.
- //
- if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- else
- pBss->Ssid.SsidLength = 0;
- }
- else
- {
- pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
- NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
- }
- pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
- pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
- pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
- pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
- pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
- pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
-
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
-
- if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
- pBss->InfrastructureMode = Ndis802_11Infrastructure;
- else
- pBss->InfrastructureMode = Ndis802_11IBSS;
-
- NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
- NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
- pAdapter->ScanTab.BssEntry[i].ExtRate,
- pAdapter->ScanTab.BssEntry[i].ExtRateLen);
-
- if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
- {
- pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- }
- else
- {
- pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
- NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
- NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
- pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
- }
- pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
-
-#if WIRELESS_EXT < 17
- if ((BssLen + pBss->Length) < wrq->u.data.length)
- BssLen += pBss->Length;
- else
- {
- pBssidList->NumberOfItems = i;
- break;
- }
-#else
- BssLen += pBss->Length;
-#endif
- }
-
-#if WIRELESS_EXT < 17
- wrq->u.data.length = BssLen;
-#else
- if (BssLen > wrq->u.data.length)
- {
- kfree(pBssidList);
- return -E2BIG;
- }
- else
- wrq->u.data.length = BssLen;
-#endif
- Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
- kfree(pBssidList);
- break;
- case OID_802_3_CURRENT_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
- case OID_GEN_MEDIA_CONNECT_STATUS:
- if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
- MediaState = NdisMediaStateConnected;
- else
- MediaState = NdisMediaStateDisconnected;
-
- wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
- Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
- break;
- case OID_802_11_BSSID:
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-#endif // RALINK_ATE //
- if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
- {
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
-
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
- Status = -ENOTCONN;
- }
- break;
- case OID_802_11_SSID:
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
- Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
- memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
- wrq->u.data.length = sizeof(NDIS_802_11_SSID);
- Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
- break;
- case RT_OID_802_11_QUERY_LINK_STATUS:
- pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
- if (pLinkStatus)
- {
- pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
- pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
- pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
- pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
- pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
- wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
- Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
- kfree(pLinkStatus);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_CONFIGURATION:
- pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
- if (pConfiguration)
- {
- pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
- pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
- pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
- MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
- wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
- Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
- pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
- kfree(pConfiguration);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_SNR_0:
- if ((pAdapter->StaCfg.LastSNR0 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
- }
- else
- Status = -EFAULT;
- break;
- case RT_OID_802_11_SNR_1:
- if ((pAdapter->Antenna.field.RxPath > 1) &&
- (pAdapter->StaCfg.LastSNR1 > 0))
- {
- ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
- }
- else
- Status = -EFAULT;
- DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
- break;
- case OID_802_11_RSSI_TRIGGER:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
- break;
- case OID_802_11_RSSI:
- case RT_OID_802_11_RSSI:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_1:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_RSSI_2:
- ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_802_11_STATISTICS:
- pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
- if (pStatistics)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
- // add the most up-to-date h/w raw counters into software counters
- NICUpdateRawCounters(pAdapter);
-
- // Sanity check for calculation of sucessful count
- if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
- pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
-
- pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
- pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
- pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
- pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
- pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
- pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
- pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
- pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
- pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
- pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
- pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
-#ifdef DBG
- pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
-#else
- pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
- pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
-#endif
- wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
- Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
- kfree(pStatistics);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_GEN_RCV_OK:
- ulInfo = pAdapter->Counters8023.GoodReceives;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case OID_GEN_RCV_NO_BUFFER:
- ulInfo = pAdapter->Counters8023.RxNoBuffer;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_PHY_MODE:
- ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_STA_CONFIG:
- pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
- if (pStaConfig)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
- pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
- pStaConfig->EnableTurboRate = 0;
- pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
- pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
- //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
- pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
- pStaConfig->Rsv1 = 0;
- pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
- wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
- Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
- kfree(pStaConfig);
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case OID_802_11_RTS_THRESHOLD:
- RtsThresh = pAdapter->CommonCfg.RtsThreshold;
- wrq->u.data.length = sizeof(RtsThresh);
- Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
- break;
- case OID_802_11_FRAGMENTATION_THRESHOLD:
- FragThresh = pAdapter->CommonCfg.FragmentThreshold;
- if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
- FragThresh = 0;
- wrq->u.data.length = sizeof(FragThresh);
- Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
- break;
- case OID_802_11_POWER_MODE:
- PowerMode = pAdapter->StaCfg.WindowsPowerMode;
- wrq->u.data.length = sizeof(PowerMode);
- Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
- break;
- case RT_OID_802_11_RADIO:
- RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
- wrq->u.data.length = sizeof(RadioState);
- Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
- break;
- case OID_802_11_INFRASTRUCTURE_MODE:
- if (pAdapter->StaCfg.BssType == BSS_ADHOC)
- BssType = Ndis802_11IBSS;
- else if (pAdapter->StaCfg.BssType == BSS_INFRA)
- BssType = Ndis802_11Infrastructure;
- else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
- BssType = Ndis802_11Monitor;
- else
- BssType = Ndis802_11AutoUnknown;
-
- wrq->u.data.length = sizeof(BssType);
- Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
- break;
- case RT_OID_802_11_PREAMBLE:
- PreamType = pAdapter->CommonCfg.TxPreamble;
- wrq->u.data.length = sizeof(PreamType);
- Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
- break;
- case OID_802_11_AUTHENTICATION_MODE:
- AuthMode = pAdapter->StaCfg.AuthMode;
- wrq->u.data.length = sizeof(AuthMode);
- Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
- break;
- case OID_802_11_WEP_STATUS:
- WepStatus = pAdapter->StaCfg.WepStatus;
- wrq->u.data.length = sizeof(WepStatus);
- Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
- break;
- case OID_802_11_TX_POWER_LEVEL:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
- break;
- case RT_OID_802_11_TX_POWER_LEVEL_1:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
- break;
- case OID_802_11_NETWORK_TYPES_SUPPORTED:
- if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
- {
- NetworkTypeList[0] = 3; // NumberOfItems = 3
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
- wrq->u.data.length = 16;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- else
- {
- NetworkTypeList[0] = 2; // NumberOfItems = 2
- NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
- NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
- wrq->u.data.length = 12;
- Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
- break;
- case OID_802_11_NETWORK_TYPE_IN_USE:
- wrq->u.data.length = sizeof(ULONG);
- if (pAdapter->CommonCfg.PhyMode == PHY_11A)
- ulInfo = Ndis802_11OFDM5;
- else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
- ulInfo = Ndis802_11OFDM24;
- else
- ulInfo = Ndis802_11DS;
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_LAST_RX_RATE:
- ulInfo = (ULONG)pAdapter->LastRxRate;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_LAST_TX_RATE:
- //ulInfo = (ULONG)pAdapter->LastTxRate;
- ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
- break;
- case RT_OID_802_11_QUERY_EEPROM_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_NOISE_LEVEL:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
- break;
- case RT_OID_802_11_EXTRA_INFO:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
- break;
- case RT_OID_WE_VERSION_COMPILED:
- wrq->u.data.length = sizeof(UINT);
- we_version_compiled = WIRELESS_EXT;
- Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
- break;
- case RT_OID_802_11_QUERY_APSD_SETTING:
- apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
- | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
-
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
- apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
- break;
- case RT_OID_802_11_QUERY_APSD_PSM:
- wrq->u.data.length = sizeof(ULONG);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
- break;
- case RT_OID_802_11_QUERY_WMM:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
- break;
-#ifdef WPA_SUPPLICANT_SUPPORT
- case RT_OID_NEW_DRIVER:
- {
- UCHAR enabled = 1;
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
- }
- break;
- case RT_OID_WPA_SUPPLICANT_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
- break;
-#endif // WPA_SUPPLICANT_SUPPORT //
-
- case RT_OID_DRIVER_DEVICE_NAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
- wrq->u.data.length = 16;
- if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
-
- pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_COUNTRY_REGION:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
- wrq->u.data.length = sizeof(ulInfo);
- ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
- ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
- if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- break;
- case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
- pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
- if (pHTPhyMode)
- {
- pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
- pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
- pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
- pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
- pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
- pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
-
- wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
- if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
- pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
- DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
- }
- else
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
- Status = -EFAULT;
- }
- break;
- case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
- wrq->u.data.length = sizeof(UCHAR);
- i = 0;
-#ifdef MULTIPLE_CARD_SUPPORT
- i = 1;
-#endif // MULTIPLE_CARD_SUPPORT //
- if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
- {
- Status = -EFAULT;
- }
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
- break;
-#ifdef SNMP_SUPPORT
- case RT_OID_802_11_MAC_ADDRESS:
- wrq->u.data.length = MAC_ADDR_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREROUI:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
- wrq->u.data.length = ManufacturerOUI_LEN;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTURERNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_RESOURCETYPEIDNAME:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
- wrq->u.data.length = strlen(ResourceTypeIdName);
- Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
- ulInfo = 1; // 1 is support wep else 2 is not support.
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_POWERMANAGEMENTMODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
- if (pAdapter->StaCfg.Psm == PSMP_ACTION)
- ulInfo = 1; // 1 is power active else 2 is power save.
- else
- ulInfo = 2;
-
- wrq->u.data.length = sizeof(ulInfo);
- Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
- break;
-
- case OID_802_11_WEPDEFAULTKEYVALUE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
- //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
- pKeyIdxValue = wrq->u.data.pointer;
- DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
- valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
- NdisMoveMemory(pKeyIdxValue->Value,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
- valueLen);
- pKeyIdxValue->Value[valueLen]='\0';
-
- wrq->u.data.length = sizeof(DefaultKeyIdxValue);
-
- Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- pAdapter->SharedKey[BSS0][0].Key[0],
- pAdapter->SharedKey[BSS0][1].Key[0],
- pAdapter->SharedKey[BSS0][2].Key[0],
- pAdapter->SharedKey[BSS0][3].Key[0]));
- break;
-
- case OID_802_11_WEPDEFAULTKEYID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
- break;
-
- case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
- wrq->u.data.length = sizeof(UCHAR);
- Status = copy_to_user(wrq->u.data.pointer,
- &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
- wrq->u.data.length);
- break;
-
- case OID_802_11_SHORTRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
- break;
-
- case OID_802_11_LONGRETRYLIMIT:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
- wrq->u.data.length = sizeof(ULONG);
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
- DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
- Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_PRODUCTID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
-
-#ifdef RT2870
- sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
-
-#endif // RT2870 //
- wrq->u.data.length = strlen(tmp);
- Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
- break;
-
- case RT_OID_802_11_MANUFACTUREID:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
- wrq->u.data.length = strlen(ManufacturerNAME);
- Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
- break;
-
- case OID_802_11_CURRENTCHANNEL:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
- wrq->u.data.length = sizeof(UCHAR);
- DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-#endif //SNMP_SUPPORT
-
- case OID_802_11_BUILD_CHANNEL_EX:
- {
- UCHAR value;
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
- wrq->u.data.length = sizeof(UCHAR);
-#ifdef EXT_BUILD_CHANNEL_LIST
- DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 1;
-#else
- DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
- value = 0;
-#endif // EXT_BUILD_CHANNEL_LIST //
- Status = copy_to_user(wrq->u.data.pointer, &value, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- }
- break;
-
- case OID_802_11_GET_CH_LIST:
- {
- PRT_CHANNEL_LIST_INFO pChListBuf;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
- if (pAdapter->ChannelListNum == 0)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
- if (pChListBuf == NULL)
- {
- wrq->u.data.length = 0;
- break;
- }
-
- pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
- for (i = 0; i < pChListBuf->ChannelListNum; i++)
- pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
-
- wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-
- if (pChListBuf)
- kfree(pChListBuf);
- }
- break;
-
- case OID_802_11_GET_COUNTRY_CODE:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
- wrq->u.data.length = 2;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
- case OID_802_11_GET_CHANNEL_GEOGRAPHY:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
- wrq->u.data.length = 1;
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
- DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
- break;
-
-
-#ifdef QOS_DLS_SUPPORT
- case RT_OID_802_11_QUERY_DLS:
- wrq->u.data.length = sizeof(BOOLEAN);
- Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
- break;
-
- case RT_OID_802_11_QUERY_DLS_PARAM:
- {
- PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
- if (pDlsInfo == NULL)
- break;
-
- for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
- {
- RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
- }
-
- pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
- wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
- Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
- DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
-
- if (pDlsInfo)
- kfree(pDlsInfo);
- }
- break;
-#endif // QOS_DLS_SUPPORT //
- default:
- DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
- return Status;
-}
-
-INT rt28xx_sta_ioctl(
- IN struct net_device *net_dev,
- IN OUT struct ifreq *rq,
- IN INT cmd)
-{
- POS_COOKIE pObj;
- VIRTUAL_ADAPTER *pVirtualAd = NULL;
- RTMP_ADAPTER *pAd = NULL;
- struct iwreq *wrq = (struct iwreq *) rq;
- BOOLEAN StateMachineTouched = FALSE;
- INT Status = NDIS_STATUS_SUCCESS;
- USHORT subcmd;
-
- if (net_dev->priv_flags == INT_MAIN)
- {
- pAd = net_dev->ml_priv;
- }
- else
- {
- pVirtualAd = net_dev->ml_priv;
- pAd = pVirtualAd->RtmpDev->ml_priv;
- }
- pObj = (POS_COOKIE) pAd->OS_Cookie;
-
- if (pAd == NULL)
- {
- /* if 1st open fail, pAd will be free;
- So the net_dev->ml_priv will be NULL in 2rd open */
- return -ENETDOWN;
- }
-
- //check if the interface is down
- if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
- {
-#ifdef CONFIG_APSTA_MIXED_SUPPORT
- if (wrq->u.data.pointer == NULL)
- {
- return Status;
- }
-
- if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
-#endif // CONFIG_APSTA_MIXED_SUPPORT //
- {
- DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
- return -ENETDOWN;
- }
- }
-
- { // determine this ioctl command is comming from which interface.
- pObj->ioctl_if_type = INT_MAIN;
- pObj->ioctl_if = MAIN_MBSSID;
- }
-
- switch(cmd)
- {
-#ifdef RALINK_ATE
-#ifdef RALINK_28xx_QA
- case RTPRIV_IOCTL_ATE:
- {
- RtmpDoAte(pAd, wrq);
- }
- break;
-#endif // RALINK_28xx_QA //
-#endif // RALINK_ATE //
- case SIOCGIFHWADDR:
- DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
- memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
- break;
- case SIOCGIWNAME:
- {
- char *name=&wrq->u.name[0];
- rt_ioctl_giwname(net_dev, NULL, name, NULL);
- break;
- }
- case SIOCGIWESSID: //Get ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWESSID: //Set ESSID
- {
- struct iw_point *essid=&wrq->u.essid;
- rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
- break;
- }
- case SIOCSIWNWID: // set network id (the cell)
- case SIOCGIWNWID: // get network id
- Status = -EOPNOTSUPP;
- break;
- case SIOCSIWFREQ: //set channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCGIWFREQ: // get channel/frequency (Hz)
- {
- struct iw_freq *freq=&wrq->u.freq;
- rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
- break;
- }
- case SIOCSIWNICKN: //set node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWNICKN: //get node name/nickname
- {
- struct iw_point *data=&wrq->u.data;
- rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
- break;
- }
- case SIOCGIWRATE: //get default bit rate (bps)
- rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCSIWRATE: //set default bit rate (bps)
- rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
- break;
- case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
- {
- struct iw_param *rts=&wrq->u.rts;
- rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
- break;
- }
- case SIOCGIWFRAG: //get fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCSIWFRAG: //set fragmentation thr (bytes)
- {
- struct iw_param *frag=&wrq->u.frag;
- rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
- break;
- }
- case SIOCGIWENCODE: //get encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCSIWENCODE: //set encoding token & mode
- {
- struct iw_point *erq=&wrq->u.encoding;
- if(erq->pointer)
- rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
- break;
- }
- case SIOCGIWAP: //get access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCSIWAP: //set access point MAC addresses
- {
- struct sockaddr *ap_addr=&wrq->u.ap_addr;
- rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
- break;
- }
- case SIOCGIWMODE: //get operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCSIWMODE: //set operation mode
- {
- __u32 *mode=&wrq->u.mode;
- rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
- break;
- }
- case SIOCGIWSENS: //get sensitivity (dBm)
- case SIOCSIWSENS: //set sensitivity (dBm)
- case SIOCGIWPOWER: //get Power Management settings
- case SIOCSIWPOWER: //set Power Management settings
- case SIOCGIWTXPOW: //get transmit power (dBm)
- case SIOCSIWTXPOW: //set transmit power (dBm)
- case SIOCGIWRANGE: //Get range of parameters
- case SIOCGIWRETRY: //get retry limits and lifetime
- case SIOCSIWRETRY: //set retry limits and lifetime
- Status = -EOPNOTSUPP;
- break;
- case RT_PRIV_IOCTL:
- case RT_PRIV_IOCTL_EXT:
- subcmd = wrq->u.data.flags;
- if( subcmd & OID_GET_SET_TOGGLE)
- Status = RTMPSetInformation(pAd, rq, subcmd);
- else
- Status = RTMPQueryInformation(pAd, rq, subcmd);
- break;
- case SIOCGIWPRIV:
- if (wrq->u.data.pointer)
- {
- if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
- break;
- wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
- if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
- Status = -EFAULT;
- }
- break;
- case RTPRIV_IOCTL_SET:
- if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
- break;
- rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
- break;
- case RTPRIV_IOCTL_GSITESURVEY:
- RTMPIoctlGetSiteSurvey(pAd, wrq);
- break;
-#ifdef DBG
- case RTPRIV_IOCTL_MAC:
- RTMPIoctlMAC(pAd, wrq);
- break;
- case RTPRIV_IOCTL_E2P:
- RTMPIoctlE2PROM(pAd, wrq);
- break;
-#ifdef RT30xx
- case RTPRIV_IOCTL_RF:
- RTMPIoctlRF(pAd, wrq);
- break;
-#endif // RT30xx //
-#endif // DBG //
- case SIOCETHTOOL:
- break;
- default:
- DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
- Status = -EOPNOTSUPP;
- break;
- }
-
- if(StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAd);
-
- return Status;
-}
-
-/*
- ==========================================================================
- Description:
- Set SSID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_SSID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- NDIS_802_11_SSID Ssid, *pSsid=NULL;
- BOOLEAN StateMachineTouched = FALSE;
- int success = TRUE;
-
- if( strlen(arg) <= MAX_LEN_OF_SSID)
- {
- NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
- if (strlen(arg) != 0)
- {
- NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
- Ssid.SsidLength = strlen(arg);
- }
- else //ANY ssid
- {
- Ssid.SsidLength = 0;
- memcpy(Ssid.Ssid, "", 0);
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
- }
- pSsid = &Ssid;
-
- if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
- {
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
- }
-
- pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
- pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
- pAdapter->bConfigChanged = TRUE;
-
- MlmeEnqueue(pAdapter,
- MLME_CNTL_STATE_MACHINE,
- OID_802_11_SSID,
- sizeof(NDIS_802_11_SSID),
- (VOID *)pSsid);
-
- StateMachineTouched = TRUE;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
- }
- else
- success = FALSE;
-
- if (StateMachineTouched) // Upper layer sent a MLME-related operations
- RT28XX_MLME_HANDLER(pAdapter);
-
- return success;
-}
-
-#ifdef WMM_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WmmCapable Enable or Disable
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WmmCapable_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- BOOLEAN bWmmCapable;
-
- bWmmCapable = simple_strtol(arg, 0, 10);
-
- if ((bWmmCapable == 1)
-#ifdef RT2870
- && (pAd->NumberOfPipes >= 5)
-#endif // RT2870 //
- )
- pAd->CommonCfg.bWmmCapable = TRUE;
- else if (bWmmCapable == 0)
- pAd->CommonCfg.bWmmCapable = FALSE;
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
- pAd->CommonCfg.bWmmCapable));
-
- return TRUE;
-}
-#endif // WMM_SUPPORT //
-
-/*
- ==========================================================================
- Description:
- Set Network Type(Infrastructure/Adhoc mode)
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_NetworkType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UINT32 Value = 0;
-
- if (strcmp(arg, "Adhoc") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_ADHOC)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (INFRA_ON(pAdapter))
- {
- //BOOLEAN Cancelled;
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
-
- DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
- }
- }
- pAdapter->StaCfg.BssType = BSS_ADHOC;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
- }
- else if (strcmp(arg, "Infra") == 0)
- {
- if (pAdapter->StaCfg.BssType != BSS_INFRA)
- {
- // Config has changed
- pAdapter->bConfigChanged = TRUE;
- if (MONITOR_ON(pAdapter))
- {
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
- RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- Value &= (~0x80);
- RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- pAdapter->StaCfg.bAutoReconnect = TRUE;
- LinkDown(pAdapter, FALSE);
- }
- if (ADHOC_ON(pAdapter))
- {
- // Set the AutoReconnectSsid to prevent it reconnect to old SSID
- // Since calling this indicate user don't want to connect to that SSID anymore.
- pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
- NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
- LinkDown(pAdapter, FALSE);
- }
- }
- pAdapter->StaCfg.BssType = BSS_INFRA;
- pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
-
- pAdapter->StaCfg.BssType = BSS_INFRA;
- }
- else if (strcmp(arg, "Monitor") == 0)
- {
- UCHAR bbpValue = 0;
- BCN_TIME_CFG_STRUC csr;
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
- OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
- // disable all periodic state machine
- pAdapter->StaCfg.bAutoReconnect = FALSE;
- // reset all mlme state machine
- RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
- DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
- if (pAdapter->CommonCfg.CentralChannel == 0)
- {
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
- pAdapter->CommonCfg.CentralChannel = 36;
- else
-#endif // DOT11_N_SUPPORT //
- pAdapter->CommonCfg.CentralChannel = 6;
- }
-#ifdef DOT11_N_SUPPORT
- else
- N_ChannelCheck(pAdapter);
-#endif // DOT11_N_SUPPORT //
-
-#ifdef DOT11_N_SUPPORT
- if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
- {
- // 40MHz ,control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- // RX : control channel at lower
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue &= (~0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
-
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value &= 0xfffffffe;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
- pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
- pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
- {
- // 40MHz ,control channel at upper
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- bbpValue |= 0x10;
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_40;
- RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
- Value |= 0x1;
- RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
- bbpValue |= (0x20);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
- pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
- pAdapter->CommonCfg.Channel,
- pAdapter->CommonCfg.CentralChannel));
- }
- else
-#endif // DOT11_N_SUPPORT //
- {
- // 20MHz
- RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
- bbpValue &= (~0x18);
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
- pAdapter->CommonCfg.BBPCurrentBW = BW_20;
- AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
- AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
- DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
- }
- // Enable Rx with promiscuous reception
- RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
- // ASIC supporsts sniffer function with replacing RSSI with timestamp.
- //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
- //Value |= (0x80);
- //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
- // disable sync
- RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
- csr.field.bBeaconGen = 0;
- csr.field.bTBTTEnable = 0;
- csr.field.TsfSyncMode = 0;
- RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-
- pAdapter->StaCfg.BssType = BSS_MONITOR;
- pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
- DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
- }
-
- // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Authentication mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_AuthMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
- else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
- else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
- else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
- else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
- else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT
- else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
- else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
- pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-#endif // WPA_SUPPLICANT_SUPPORT //
- else
- return FALSE;
-
- pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Encryption Type
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_EncrypType_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
- }
- else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
- {
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
- }
- else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
- }
- else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
- {
- if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
- pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
- }
- else
- return FALSE;
-
- pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Default Key ID
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_DefaultKeyID_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- ULONG KeyIdx;
-
- KeyIdx = simple_strtol(arg, 0, 10);
- if((KeyIdx >= 1 ) && (KeyIdx <= 4))
- pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
- else
- return FALSE; //Invalid argument
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WEP KEY1
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key1_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
-
- pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 0,
- pAdapter->SharedKey[BSS0][0].CipherAlg,
- pAdapter->SharedKey[BSS0][0].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
-
- Description:
- Set WEP KEY2
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key2_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 1,
- pAdapter->SharedKey[BSS0][1].CipherAlg,
- pAdapter->SharedKey[BSS0][1].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY3
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key3_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 2,
- pAdapter->SharedKey[BSS0][2].CipherAlg,
- pAdapter->SharedKey[BSS0][2].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-/*
- ==========================================================================
- Description:
- Set WEP KEY4
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Key4_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- int KeyLen;
- int i;
- UCHAR CipherAlg=CIPHER_WEP64;
-
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- return TRUE; // do nothing
-
- KeyLen = strlen(arg);
-
- switch (KeyLen)
- {
- case 5: //wep 40 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 10: //wep 40 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP64;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- case 13: //wep 104 Ascii type
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
- memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
- break;
- case 26: //wep 104 Hex type
- for(i=0; i < KeyLen; i++)
- {
- if( !isxdigit(*(arg+i)) )
- return FALSE; //Not Hex value;
- }
- pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
- AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
- CipherAlg = CIPHER_WEP128;
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
- break;
- default: //Invalid argument
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
- return FALSE;
- }
- pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
-
- // Set keys (into ASIC)
- if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
- ; // not support
- else // Old WEP stuff
- {
- AsicAddSharedKeyEntry(pAdapter,
- 0,
- 3,
- pAdapter->SharedKey[BSS0][3].CipherAlg,
- pAdapter->SharedKey[BSS0][3].Key,
- NULL,
- NULL);
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set WPA PSK key
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_WPAPSK_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- UCHAR keyMaterial[40];
-
- if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
- (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
- )
- return TRUE; // do nothing
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
-
- NdisZeroMemory(keyMaterial, 40);
-
- if ((strlen(arg) < 8) || (strlen(arg) > 64))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
- return FALSE;
- }
-
- if (strlen(arg) == 64)
- {
- AtoH(arg, keyMaterial, 32);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-
- }
- else
- {
- PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
- NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
- }
-
-
-
- if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
- pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
- {
- pAdapter->StaCfg.WpaState = SS_NOTUSE;
- }
- else
- {
- // Start STA supplicant state machine
- pAdapter->StaCfg.WpaState = SS_START;
- }
-
- return TRUE;
-}
-
-/*
- ==========================================================================
- Description:
- Set Power Saving mode
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_PSMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (pAdapter->StaCfg.BssType == BSS_INFRA)
- {
- if ((strcmp(arg, "Max_PSP") == 0) ||
- (strcmp(arg, "max_psp") == 0) ||
- (strcmp(arg, "MAX_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- pAdapter->StaCfg.DefaultListenCount = 5;
-
- }
- else if ((strcmp(arg, "Fast_PSP") == 0) ||
- (strcmp(arg, "fast_psp") == 0) ||
- (strcmp(arg, "FAST_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else if ((strcmp(arg, "Legacy_PSP") == 0) ||
- (strcmp(arg, "legacy_psp") == 0) ||
- (strcmp(arg, "LEGACY_PSP") == 0))
- {
- // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
- // to exclude certain situations.
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
- pAdapter->StaCfg.DefaultListenCount = 3;
- }
- else
- {
- //Default Ndis802_11PowerModeCAM
- // clear PSM bit immediately
- MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
- OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
- if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
- pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
- pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
- }
- else
- return FALSE;
-
-
- return TRUE;
-}
-
-#ifdef WPA_SUPPLICANT_SUPPORT
-/*
- ==========================================================================
- Description:
- Set WpaSupport flag.
- Value:
- 0: Driver ignore wpa_supplicant.
- 1: wpa_supplicant initiates scanning and AP selection.
- 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
- Return:
- TRUE if all parameters are OK, FALSE otherwise
- ==========================================================================
-*/
-INT Set_Wpa_Support(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
-
- if ( simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
- else if ( simple_strtol(arg, 0, 10) == 1)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
- else if ( simple_strtol(arg, 0, 10) == 2)
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
- else
- pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
-
- return TRUE;
-}
-#endif // WPA_SUPPLICANT_SUPPORT //
-
-#ifdef DBG
-/*
- ==========================================================================
- Description:
- Read / Write MAC
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
- 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
- ==========================================================================
-*/
-VOID RTMPIoctlMAC(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- ULONG macAddr = 0;
- UCHAR temp[16], temp2[16];
- UINT32 macValue = 0;
- INT Status;
- BOOLEAN bIsPrintAllMAC = FALSE;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // Mac Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
- if (macAddr < 0xFFFF)
- {
- RTMP_IO_READ32(pAdapter, macAddr, &macValue);
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
- }
- else
- {//Invalid parametes, so default printk all mac
- bIsPrintAllMAC = TRUE;
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[8-k+j] = temp2[j];
- }
-
- while(k < 8)
- temp2[7-k++]='0';
- temp2[8]='\0';
-
- {
- AtoH(this_char, temp, 2);
- macAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 4);
- macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
-
- // debug mode
- if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
- {
- // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
- if (macValue & 0x000000ff)
- {
- pAdapter->BbpTuning.bEnable = TRUE;
- DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
- }
- else
- {
- UCHAR R66;
- pAdapter->BbpTuning.bEnable = FALSE;
- R66 = 0x26 + GET_LNA_GAIN(pAdapter);
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- }
- else
-#endif // RALINK_ATE //
- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
- DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
- }
- return;
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
-
- RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
- sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
- }
- }
- }
- else
- bIsPrintAllMAC = TRUE;
-next:
- if (bIsPrintAllMAC)
- {
- struct file *file_w;
- PCHAR fileName = "MacDump.txt";
- mm_segment_t orig_fs;
-
- orig_fs = get_fs();
- set_fs(KERNEL_DS);
-
- // open file
- file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
- if (IS_ERR(file_w))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName));
- }
- else
- {
- if (file_w->f_op && file_w->f_op->write)
- {
- file_w->f_pos = 0;
- macAddr = 0x1000;
-
- while (macAddr <= 0x1800)
- {
- RTMP_IO_READ32(pAdapter, macAddr, &macValue);
- sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
-
- // write data to file
- file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
-
- printk("%s", msg);
- macAddr += 4;
- }
- sprintf(msg, "\nDump all MAC values to %s\n", fileName);
- }
- filp_close(file_w, NULL);
- }
- set_fs(orig_fs);
- }
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
-}
-
-/*
- ==========================================================================
- Description:
- Read / Write E2PROM
- Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
- 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
- ==========================================================================
-*/
-VOID RTMPIoctlE2PROM(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- INT j = 0, k = 0;
- CHAR msg[1024];
- CHAR arg[255];
- USHORT eepAddr = 0;
- UCHAR temp[16], temp2[16];
- USHORT eepValue;
- int Status;
- BOOLEAN bIsPrintAllE2P = FALSE;
-
-
- memset(msg, 0x00, 1024);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
-
-
- if (!*this_char)
- goto next;
-
- if ((value = rtstrchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
-
- // Sanity check
- if(strlen(this_char) > 4)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
-
- // E2PROM addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- if(strlen(this_char) == 4)
- {
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
- if (eepAddr < 0xFFFF)
- {
- RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
- }
- else
- {//Invalid parametes, so default printk all bbp
- bIsPrintAllE2P = TRUE;
- goto next;
- }
- }
- }
- else
- { //Write
- memcpy(&temp2, value, strlen(value));
- temp2[strlen(value)] = '\0';
-
- // Sanity check
- if((strlen(this_char) > 4) || strlen(temp2) > 8)
- goto next;
-
- j = strlen(this_char);
- while(j-- > 0)
- {
- if(this_char[j] > 'f' || this_char[j] < '0')
- return;
- }
- j = strlen(temp2);
- while(j-- > 0)
- {
- if(temp2[j] > 'f' || temp2[j] < '0')
- return;
- }
-
- //MAC Addr
- k = j = strlen(this_char);
- while(j-- > 0)
- {
- this_char[4-k+j] = this_char[j];
- }
-
- while(k < 4)
- this_char[3-k++]='0';
- this_char[4]='\0';
-
- //MAC value
- k = j = strlen(temp2);
- while(j-- > 0)
- {
- temp2[4-k+j] = temp2[j];
- }
-
- while(k < 4)
- temp2[3-k++]='0';
- temp2[4]='\0';
-
- AtoH(this_char, temp, 2);
- eepAddr = *temp*256 + temp[1];
-
- AtoH(temp2, temp, 2);
- eepValue = *temp*256 + temp[1];
-
- RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
- sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
- }
- }
- else
- bIsPrintAllE2P = TRUE;
-next:
- if (bIsPrintAllE2P)
- {
- struct file *file_w;
- PCHAR fileName = "EEPROMDump.txt";
- mm_segment_t orig_fs;
-
- orig_fs = get_fs();
- set_fs(KERNEL_DS);
-
- // open file
- file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
- if (IS_ERR(file_w))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName));
- }
- else
- {
- if (file_w->f_op && file_w->f_op->write)
- {
- file_w->f_pos = 0;
- eepAddr = 0x00;
-
- while (eepAddr <= 0xFE)
- {
- RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
- sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
-
- // write data to file
- file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
-
- printk("%s", msg);
- eepAddr += 2;
- }
- sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
- }
- filp_close(file_w, NULL);
- }
- set_fs(orig_fs);
- }
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
-}
-#ifdef RT30xx
-/*
- ==========================================================================
- Description:
- Read / Write RF register
-Arguments:
- pAdapter Pointer to our adapter
- wrq Pointer to the ioctl argument
-
- Return Value:
- None
-
- Note:
- Usage:
- 1.) iwpriv ra0 rf ==> read all RF registers
- 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
- 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
- ==========================================================================
-*/
-VOID RTMPIoctlRF(
- IN PRTMP_ADAPTER pAdapter,
- IN struct iwreq *wrq)
-{
- CHAR *this_char;
- CHAR *value;
- UCHAR regRF = 0;
- CHAR msg[2048];
- CHAR arg[255];
- INT rfId;
- LONG rfValue;
- int Status;
- BOOLEAN bIsPrintAllRF = FALSE;
-
-
- memset(msg, 0x00, 2048);
- if (wrq->u.data.length > 1) //No parameters.
- {
- Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
- sprintf(msg, "\n");
-
- //Parsing Read or Write
- this_char = arg;
- if (!*this_char)
- goto next;
-
- if ((value = strchr(this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!value || !*value)
- { //Read
- if (sscanf(this_char, "%d", &(rfId)) == 1)
- {
- if (rfId <= 31)
- {
- // In RT2860 ATE mode, we do not load 8051 firmware.
- //We must access RF directly.
- // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, &regRF);
- }
- else
-#endif // RALINK_ATE //
- // according to Andy, Gary, David require.
- // the command rf shall read rf register directly for dubug.
- // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- RT30xxReadRFRegister(pAdapter, rfId, &regRF);
-
- sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
- }
- else
- {//Invalid parametes, so default printk all RF
- bIsPrintAllRF = TRUE;
- goto next;
- }
- }
- else
- { //Invalid parametes, so default printk all RF
- bIsPrintAllRF = TRUE;
- goto next;
- }
- }
- else
- { //Write
- if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
- {
- if (rfId <= 31)
- {
- // In RT2860 ATE mode, we do not load 8051 firmware.
- // We should access RF registers directly.
- // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, &regRF);
- ATE_RF_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
- //Read it back for showing
- ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, &regRF);
- sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
- }
- else
-#endif // RALINK_ATE //
- {
- // according to Andy, Gary, David require.
- // the command RF shall read/write RF register directly for dubug.
- //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
- RT30xxReadRFRegister(pAdapter, rfId, &regRF);
- RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
- //Read it back for showing
- //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
- RT30xxReadRFRegister(pAdapter, rfId, &regRF);
- sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
- }
- }
- else
- {//Invalid parametes, so default printk all RF
- bIsPrintAllRF = TRUE;
- }
- }
- else
- { //Invalid parametes, so default printk all RF
- bIsPrintAllRF = TRUE;
- }
- }
- }
- else
- bIsPrintAllRF = TRUE;
-next:
- if (bIsPrintAllRF)
- {
- memset(msg, 0x00, 2048);
- sprintf(msg, "\n");
- for (rfId = 0; rfId <= 31; rfId++)
- {
- // In RT2860 ATE mode, we do not load 8051 firmware.
- // We should access RF registers directly.
- // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
-#ifdef RALINK_ATE
- if (ATE_ON(pAdapter))
- {
- ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, &regRF);
- }
- else
-#endif // RALINK_ATE //
-
- // according to Andy, Gary, David require.
- // the command RF shall read/write RF register directly for dubug.
- RT30xxReadRFRegister(pAdapter, rfId, &regRF);
- sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
- }
- // Copy the information into the user buffer
- DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
- wrq->u.data.length = strlen(msg);
- if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
- }
- }
- else
- {
- if(strlen(msg) == 1)
- sprintf(msg+strlen(msg), "===>Error command format!");
-
- DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
- // Copy the information into the user buffer
- DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
-
- // Copy the information into the user buffer
- wrq->u.data.length = strlen(msg);
- Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
- }
-
- DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
-}
-#endif // RT30xx //
-#endif // DBG //
-
-
-
-
-INT Set_TGnWifiTest_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->StaCfg.bTGnWifiTest = FALSE;
- else
- pAd->StaCfg.bTGnWifiTest = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
- return TRUE;
-}
-
-INT Set_LongRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-INT Set_ShortRetryLimit_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- TX_RTY_CFG_STRUC tx_rty_cfg;
- UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
- RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
- tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
- RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
- return TRUE;
-}
-
-#ifdef EXT_BUILD_CHANNEL_LIST
-INT Set_Ieee80211dClientMode_Proc(
- IN PRTMP_ADAPTER pAdapter,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
- else if (simple_strtol(arg, 0, 10) == 1)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
- else if (simple_strtol(arg, 0, 10) == 2)
- pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
- else
- return FALSE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
- return TRUE;
-}
-#endif // EXT_BUILD_CHANNEL_LIST //
-
-#ifdef CARRIER_DETECTION_SUPPORT
-INT Set_CarrierDetect_Proc(
- IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
-{
- if (simple_strtol(arg, 0, 10) == 0)
- pAd->CommonCfg.CarrierDetect.Enable = FALSE;
- else
- pAd->CommonCfg.CarrierDetect.Enable = TRUE;
-
- DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
- return TRUE;
-}
-#endif // CARRIER_DETECTION_SUPPORT //
-
+#include "../rt2870/sta_ioctl.c"
diff --git a/drivers/staging/rt3070/wpa.h b/drivers/staging/rt3070/wpa.h
index 88c7c8bf3fcd..94bb23279400 100644
--- a/drivers/staging/rt3070/wpa.h
+++ b/drivers/staging/rt3070/wpa.h
@@ -1,356 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- *************************************************************************
-
- Module Name:
- wpa.h
-
- Abstract:
-
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Name Date Modification logs
-*/
-
-#ifndef __WPA_H__
-#define __WPA_H__
-
-// EAPOL Key descripter frame format related length
-#define LEN_KEY_DESC_NONCE 32
-#define LEN_KEY_DESC_IV 16
-#define LEN_KEY_DESC_RSC 8
-#define LEN_KEY_DESC_ID 8
-#define LEN_KEY_DESC_REPLAY 8
-#define LEN_KEY_DESC_MIC 16
-
-// The length is the EAPoL-Key frame except key data field.
-// Please refer to 802.11i-2004 ,Figure 43u in p.78
-#define LEN_EAPOL_KEY_MSG (sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)
-
-// EAP Code Type.
-#define EAP_CODE_REQUEST 1
-#define EAP_CODE_RESPONSE 2
-#define EAP_CODE_SUCCESS 3
-#define EAP_CODE_FAILURE 4
-
-// EAPOL frame Protocol Version
-#define EAPOL_VER 1
-#define EAPOL_VER2 2
-
-// EAPOL-KEY Descriptor Type
-#define WPA1_KEY_DESC 0xfe
-#define WPA2_KEY_DESC 0x02
-
-// Key Descriptor Version of Key Information
-#define DESC_TYPE_TKIP 1
-#define DESC_TYPE_AES 2
-#define DESC_TYPE_MESH 3
-
-#define LEN_MSG1_2WAY 0x7f
-#define MAX_LEN_OF_EAP_HS 256
-
-#define LEN_MASTER_KEY 32
-
-// EAPOL EK, MK
-#define LEN_EAP_EK 16
-#define LEN_EAP_MICK 16
-#define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK))
-// TKIP key related
-#define LEN_PMKID 16
-#define LEN_TKIP_EK 16
-#define LEN_TKIP_RXMICK 8
-#define LEN_TKIP_TXMICK 8
-#define LEN_AES_EK 16
-#define LEN_AES_KEY LEN_AES_EK
-#define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK))
-#define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
-#define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
-
-// RSN IE Length definition
-#define MAX_LEN_OF_RSNIE 90
-#define MIN_LEN_OF_RSNIE 8
-
-//EAP Packet Type
-#define EAPPacket 0
-#define EAPOLStart 1
-#define EAPOLLogoff 2
-#define EAPOLKey 3
-#define EAPOLASFAlert 4
-#define EAPTtypeMax 5
-
-#define EAPOL_MSG_INVALID 0
-#define EAPOL_PAIR_MSG_1 1
-#define EAPOL_PAIR_MSG_2 2
-#define EAPOL_PAIR_MSG_3 3
-#define EAPOL_PAIR_MSG_4 4
-#define EAPOL_GROUP_MSG_1 5
-#define EAPOL_GROUP_MSG_2 6
-
-#define PAIRWISEKEY 1
-#define GROUPKEY 0
-
-// Retry timer counter initial value
-#define PEER_MSG1_RETRY_TIMER_CTR 0
-#define PEER_MSG3_RETRY_TIMER_CTR 10
-#define GROUP_MSG1_RETRY_TIMER_CTR 20
-
-
-#define EAPOL_START_DISABLE 0
-#define EAPOL_START_PSK 1
-#define EAPOL_START_1X 2
-
-#define MIX_CIPHER_WPA_TKIP_ON(x) (((x) & 0x08) != 0)
-#define MIX_CIPHER_WPA_AES_ON(x) (((x) & 0x04) != 0)
-#define MIX_CIPHER_WPA2_TKIP_ON(x) (((x) & 0x02) != 0)
-#define MIX_CIPHER_WPA2_AES_ON(x) (((x) & 0x01) != 0)
-
-#define ROUND_UP(__x, __y) \
- (((ULONG)((__x)+((__y)-1))) & ((ULONG)~((__y)-1)))
-
-#define ADD_ONE_To_64BIT_VAR(_V) \
-{ \
- UCHAR cnt = LEN_KEY_DESC_REPLAY; \
- do \
- { \
- cnt--; \
- _V[cnt]++; \
- if (cnt == 0) \
- break; \
- }while (_V[cnt] == 0); \
-}
-
-#define IS_WPA_CAPABILITY(a) (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
-
-// EAPOL Key Information definition within Key descriptor format
-typedef struct PACKED _KEY_INFO
-{
-#ifdef RT_BIG_ENDIAN
- UCHAR KeyAck:1;
- UCHAR Install:1;
- UCHAR KeyIndex:2;
- UCHAR KeyType:1;
- UCHAR KeyDescVer:3;
- UCHAR Rsvd:3;
- UCHAR EKD_DL:1; // EKD for AP; DL for STA
- UCHAR Request:1;
- UCHAR Error:1;
- UCHAR Secure:1;
- UCHAR KeyMic:1;
-#else
- UCHAR KeyMic:1;
- UCHAR Secure:1;
- UCHAR Error:1;
- UCHAR Request:1;
- UCHAR EKD_DL:1; // EKD for AP; DL for STA
- UCHAR Rsvd:3;
- UCHAR KeyDescVer:3;
- UCHAR KeyType:1;
- UCHAR KeyIndex:2;
- UCHAR Install:1;
- UCHAR KeyAck:1;
-#endif
-} KEY_INFO, *PKEY_INFO;
-
-// EAPOL Key descriptor format
-typedef struct PACKED _KEY_DESCRIPTER
-{
- UCHAR Type;
- KEY_INFO KeyInfo;
- UCHAR KeyLength[2];
- UCHAR ReplayCounter[LEN_KEY_DESC_REPLAY];
- UCHAR KeyNonce[LEN_KEY_DESC_NONCE];
- UCHAR KeyIv[LEN_KEY_DESC_IV];
- UCHAR KeyRsc[LEN_KEY_DESC_RSC];
- UCHAR KeyId[LEN_KEY_DESC_ID];
- UCHAR KeyMic[LEN_KEY_DESC_MIC];
- UCHAR KeyDataLen[2];
- UCHAR KeyData[MAX_LEN_OF_RSNIE];
-} KEY_DESCRIPTER, *PKEY_DESCRIPTER;
-
-typedef struct PACKED _EAPOL_PACKET
-{
- UCHAR ProVer;
- UCHAR ProType;
- UCHAR Body_Len[2];
- KEY_DESCRIPTER KeyDesc;
-} EAPOL_PACKET, *PEAPOL_PACKET;
-
-//802.11i D10 page 83
-typedef struct PACKED _GTK_ENCAP
-{
-#ifndef RT_BIG_ENDIAN
- UCHAR Kid:2;
- UCHAR tx:1;
- UCHAR rsv:5;
- UCHAR rsv1;
-#else
- UCHAR rsv:5;
- UCHAR tx:1;
- UCHAR Kid:2;
- UCHAR rsv1;
-#endif
- UCHAR GTK[TKIP_GTK_LENGTH];
-} GTK_ENCAP, *PGTK_ENCAP;
-
-typedef struct PACKED _KDE_ENCAP
-{
- UCHAR Type;
- UCHAR Len;
- UCHAR OUI[3];
- UCHAR DataType;
- GTK_ENCAP GTKEncap;
-} KDE_ENCAP, *PKDE_ENCAP;
-
-// For WPA1
-typedef struct PACKED _RSNIE {
- UCHAR oui[4];
- USHORT version;
- UCHAR mcast[4];
- USHORT ucount;
- struct PACKED {
- UCHAR oui[4];
- }ucast[1];
-} RSNIE, *PRSNIE;
-
-// For WPA2
-typedef struct PACKED _RSNIE2 {
- USHORT version;
- UCHAR mcast[4];
- USHORT ucount;
- struct PACKED {
- UCHAR oui[4];
- }ucast[1];
-} RSNIE2, *PRSNIE2;
-
-// AKM Suite
-typedef struct PACKED _RSNIE_AUTH {
- USHORT acount;
- struct PACKED {
- UCHAR oui[4];
- }auth[1];
-} RSNIE_AUTH,*PRSNIE_AUTH;
-
-typedef union PACKED _RSN_CAPABILITIES {
- struct PACKED {
-#ifdef RT_BIG_ENDIAN
- USHORT Rsvd:10;
- USHORT GTKSA_R_Counter:2;
- USHORT PTKSA_R_Counter:2;
- USHORT No_Pairwise:1;
- USHORT PreAuth:1;
-#else
- USHORT PreAuth:1;
- USHORT No_Pairwise:1;
- USHORT PTKSA_R_Counter:2;
- USHORT GTKSA_R_Counter:2;
- USHORT Rsvd:10;
-#endif
- } field;
- USHORT word;
-} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
-
-typedef struct PACKED _EAP_HDR {
- UCHAR ProVer;
- UCHAR ProType;
- UCHAR Body_Len[2];
- UCHAR code;
- UCHAR identifier;
- UCHAR length[2]; // including code and identifier, followed by length-2 octets of data
-} EAP_HDR, *PEAP_HDR;
-
-// For supplicant state machine states. 802.11i Draft 4.1, p. 97
-// We simplified it
-typedef enum _WpaState
-{
- SS_NOTUSE, // 0
- SS_START, // 1
- SS_WAIT_MSG_3, // 2
- SS_WAIT_GROUP, // 3
- SS_FINISH, // 4
- SS_KEYUPDATE, // 5
-} WPA_STATE;
-
-//
-// The definition of the cipher combination
-//
-// bit3 bit2 bit1 bit0
-// +------------+------------+
-// | WPA | WPA2 |
-// +------+-----+------+-----+
-// | TKIP | AES | TKIP | AES |
-// | 0 | 1 | 1 | 0 | -> 0x06
-// | 0 | 1 | 1 | 1 | -> 0x07
-// | 1 | 0 | 0 | 1 | -> 0x09
-// | 1 | 0 | 1 | 1 | -> 0x0B
-// | 1 | 1 | 0 | 1 | -> 0x0D
-// | 1 | 1 | 1 | 0 | -> 0x0E
-// | 1 | 1 | 1 | 1 | -> 0x0F
-// +------+-----+------+-----+
-//
-typedef enum _WpaMixPairCipher
-{
- MIX_CIPHER_NOTUSE = 0x00,
- WPA_NONE_WPA2_TKIPAES = 0x03, // WPA2-TKIPAES
- WPA_AES_WPA2_TKIP = 0x06,
- WPA_AES_WPA2_TKIPAES = 0x07,
- WPA_TKIP_WPA2_AES = 0x09,
- WPA_TKIP_WPA2_TKIPAES = 0x0B,
- WPA_TKIPAES_WPA2_NONE = 0x0C, // WPA-TKIPAES
- WPA_TKIPAES_WPA2_AES = 0x0D,
- WPA_TKIPAES_WPA2_TKIP = 0x0E,
- WPA_TKIPAES_WPA2_TKIPAES = 0x0F,
-} WPA_MIX_PAIR_CIPHER;
-
-typedef struct PACKED _RSN_IE_HEADER_STRUCT {
- UCHAR Eid;
- UCHAR Length;
- USHORT Version; // Little endian format
-} RSN_IE_HEADER_STRUCT, *PRSN_IE_HEADER_STRUCT;
-
-// Cipher suite selector types
-typedef struct PACKED _CIPHER_SUITE_STRUCT {
- UCHAR Oui[3];
- UCHAR Type;
-} CIPHER_SUITE_STRUCT, *PCIPHER_SUITE_STRUCT;
-
-// Authentication and Key Management suite selector
-typedef struct PACKED _AKM_SUITE_STRUCT {
- UCHAR Oui[3];
- UCHAR Type;
-} AKM_SUITE_STRUCT, *PAKM_SUITE_STRUCT;
-
-// RSN capability
-typedef struct PACKED _RSN_CAPABILITY {
- USHORT Rsv:10;
- USHORT GTKSAReplayCnt:2;
- USHORT PTKSAReplayCnt:2;
- USHORT NoPairwise:1;
- USHORT PreAuth:1;
-} RSN_CAPABILITY, *PRSN_CAPABILITY;
-
-#endif
+#include "../rt2870/wpa.h"
diff --git a/drivers/staging/rtl8187se/Kconfig b/drivers/staging/rtl8187se/Kconfig
index f636296b54bc..236e42725447 100644
--- a/drivers/staging/rtl8187se/Kconfig
+++ b/drivers/staging/rtl8187se/Kconfig
@@ -1,6 +1,6 @@
config RTL8187SE
tristate "RealTek RTL8187SE Wireless LAN NIC driver"
depends on PCI
- depends on WIRELESS_EXT && COMPAT_NET_DEV_OPS
+ depends on WIRELESS_EXT
default N
---help---
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
index 0c9fef0b4e3f..c2b61e648e4e 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
@@ -114,7 +114,6 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
goto failed;
}
ieee = netdev_priv(dev);
- dev->hard_start_xmit = ieee80211_xmit;
ieee->dev = dev;
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index e10413cee0df..7e2fecae813c 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -198,7 +198,8 @@ static void __devexit rtl8180_pci_remove(struct pci_dev *pdev);
static void rtl8180_shutdown (struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- dev->stop(dev);
+ if (dev->netdev_ops->ndo_stop)
+ dev->netdev_ops->ndo_stop(dev);
pci_disable_device(pdev);
}
@@ -4551,8 +4552,6 @@ short rtl8180_init(struct net_device *dev)
//DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
}
- dev->get_stats = rtl8180_stats;
-
dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
@@ -5832,6 +5831,18 @@ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-----------------------------PCI STUFF---------------------------
*****************************************************************************/
+static const struct net_device_ops rtl8180_netdev_ops = {
+ .ndo_open = rtl8180_open,
+ .ndo_stop = rtl8180_close,
+ .ndo_get_stats = rtl8180_stats,
+ .ndo_tx_timeout = rtl8180_restart,
+ .ndo_do_ioctl = rtl8180_ioctl,
+ .ndo_set_multicast_list = r8180_set_multicast,
+ .ndo_set_mac_address = r8180_set_mac_adr,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_start_xmit = ieee80211_xmit,
+};
static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
@@ -5936,14 +5947,8 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
dev->irq = pdev->irq;
priv->irq = 0;
- dev->open = rtl8180_open;
- dev->stop = rtl8180_close;
- //dev->hard_start_xmit = ieee80211_xmit;
- dev->tx_timeout = rtl8180_restart;
+ dev->netdev_ops = &rtl8180_netdev_ops;
dev->wireless_handlers = &r8180_wx_handlers_def;
- dev->do_ioctl = rtl8180_ioctl;
- dev->set_multicast_list = r8180_set_multicast;
- dev->set_mac_address = r8180_set_mac_adr;
#if WIRELESS_EXT >= 12
#if WIRELESS_EXT < 17
diff --git a/drivers/staging/rtl8187se/r8180_dm.c b/drivers/staging/rtl8187se/r8180_dm.c
index 93b5a7bb2559..e772f0f6b67c 100644
--- a/drivers/staging/rtl8187se/r8180_dm.c
+++ b/drivers/staging/rtl8187se/r8180_dm.c
@@ -132,7 +132,7 @@ void rtl8180_tx_pw_wq (struct work_struct *work)
// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
// struct ieee80211_device * ieee = (struct ieee80211_device*)
// container_of(work, struct ieee80211_device, watch_dog_wq);
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,tx_pw_wq);
struct net_device *dev = ieee->dev;
#else
@@ -314,7 +314,7 @@ void rtl8180_hw_dig_wq (struct work_struct *work)
// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
// struct ieee80211_device * ieee = (struct ieee80211_device*)
// container_of(work, struct ieee80211_device, watch_dog_wq);
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_dig_wq);
struct net_device *dev = ieee->dev;
#else
@@ -1250,7 +1250,7 @@ SetInitialGain:
#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
void rtl8180_rate_adapter(struct work_struct * work)
{
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,rate_adapter_wq);
struct net_device *dev = ieee->dev;
#else
diff --git a/drivers/staging/rtl8187se/r8180_pm.c b/drivers/staging/rtl8187se/r8180_pm.c
index 3851b9368356..2b3d642db77f 100644
--- a/drivers/staging/rtl8187se/r8180_pm.c
+++ b/drivers/staging/rtl8187se/r8180_pm.c
@@ -30,7 +30,8 @@ int rtl8180_suspend (struct pci_dev *pdev, pm_message_t state)
if (!netif_running(dev))
goto out_pci_suspend;
- dev->stop(dev);
+ if (dev->netdev_ops->ndo_stop)
+ dev->netdev_ops->ndo_stop(dev);
netif_device_detach(dev);
@@ -71,7 +72,8 @@ int rtl8180_resume (struct pci_dev *pdev)
if(!netif_running(dev))
goto out;
- dev->open(dev);
+ if (dev->netdev_ops->ndo_open)
+ dev->netdev_ops->ndo_open(dev);
netif_device_attach(dev);
out:
return 0;
diff --git a/drivers/staging/rtl8192su/Kconfig b/drivers/staging/rtl8192su/Kconfig
new file mode 100644
index 000000000000..4b5552c5926e
--- /dev/null
+++ b/drivers/staging/rtl8192su/Kconfig
@@ -0,0 +1,6 @@
+config RTL8192SU
+ tristate "RealTek RTL8192SU Wireless LAN NIC driver"
+ depends on PCI
+ depends on WIRELESS_EXT && COMPAT_NET_DEV_OPS
+ default N
+ ---help---
diff --git a/drivers/staging/rtl8192su/Makefile b/drivers/staging/rtl8192su/Makefile
new file mode 100644
index 000000000000..f010ab502a97
--- /dev/null
+++ b/drivers/staging/rtl8192su/Makefile
@@ -0,0 +1,66 @@
+NIC_SELECT = RTL8192SU
+
+EXTRA_CFLAGS += -std=gnu89
+EXTRA_CFLAGS += -O2
+EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y
+
+EXTRA_CFLAGS += -DJACKSON_NEW_RX
+EXTRA_CFLAGS += -DTHOMAS_BEACON -DTHOMAS_TURBO
+#EXTRA_CFLAGS += -DUSE_ONE_PIPE
+EXTRA_CFLAGS += -DENABLE_DOT11D
+
+EXTRA_CFLAGS += -DRTL8192SU
+EXTRA_CFLAGS += -DRTL8190_Download_Firmware_From_Header=1
+EXTRA_CFLAGS += -DRTL8192S_PREPARE_FOR_NORMAL_RELEASE
+EXTRA_CFLAGS += -DRTL8192SU_DISABLE_IQK=1
+
+#EXTRA_CFLAGS += -DEEPROM_OLD_FORMAT_SUPPORT
+
+#EXTRA_CFLAGS += -DUSB_RX_AGGREGATION_SUPPORT=0
+#EXTRA_CFLAGS += -DUSB_TX_DRIVER_AGGREGATION_ENABLE=0
+#EXTRA_CFLAGS += -DRTL8192SU_DISABLE_CCK_RATE=0
+EXTRA_CFLAGS += -DRTL8192S_DISABLE_FW_DM=0
+EXTRA_CFLAGS += -DDISABLE_BB_RF=0
+EXTRA_CFLAGS += -DRTL8192SU_USE_PARAM_TXPWR=0
+EXTRA_CFLAGS += -DRTL8192SU_FPGA_UNSPECIFIED_NETWORK=0
+#EXTRA_CFLAGS += -DRTL8192SU_FPGA_2MAC_VERIFICATION #=0
+EXTRA_CFLAGS += -DRTL8192SU_ASIC_VERIFICATION
+EXTRA_CFLAGS += -DRTL8192SU_USB_PHY_TEST=0
+
+#EXTRA_CFLAGS += -DMUTIPLE_BULK_OUT
+EXTRA_CFLAGS += -DCONFIG_RTL8192_PM
+
+r8192s_usb-objs := \
+ r8180_93cx6.o \
+ r8192U_wx.o \
+ r8192S_phy.o \
+ r8192S_rtl6052.o \
+ r8192S_rtl8225.o \
+ r819xU_cmdpkt.o \
+ r8192U_dm.o \
+ r8192SU_HWImg.o \
+ r8192S_firmware.o \
+ r8192S_Efuse.o \
+ r8192U_core.o \
+ r8192U_pm.o
+
+ieee80211-rsl-objs := \
+ ieee80211/ieee80211_rx.o \
+ ieee80211/ieee80211_softmac.o \
+ ieee80211/ieee80211_tx.o \
+ ieee80211/ieee80211_wx.o \
+ ieee80211/ieee80211_module.o \
+ ieee80211/ieee80211_softmac_wx.o\
+ ieee80211/rtl819x_HTProc.o \
+ ieee80211/rtl819x_TSProc.o \
+ ieee80211/rtl819x_BAProc.o \
+ ieee80211/dot11d.o
+
+obj-$(CONFIG_RTL8192SU) += r8192s_usb.o
+obj-$(CONFIG_RTL8192SU) += ieee80211-rsl.o
+obj-$(CONFIG_RTL8192SU) += ieee80211/ieee80211_crypt.o
+obj-$(CONFIG_RTL8192SU) += ieee80211/ieee80211_crypt_tkip.o
+obj-$(CONFIG_RTL8192SU) += ieee80211/ieee80211_crypt_ccmp.o
+obj-$(CONFIG_RTL8192SU) += ieee80211/ieee80211_crypt_wep.o
+
+
diff --git a/drivers/staging/rtl8192su/authors b/drivers/staging/rtl8192su/authors
new file mode 100644
index 000000000000..b08bbae39e72
--- /dev/null
+++ b/drivers/staging/rtl8192su/authors
@@ -0,0 +1 @@
+Andrea Merello <andreamrl@tiscali.it>
diff --git a/drivers/staging/rtl8192su/dot11d.h b/drivers/staging/rtl8192su/dot11d.h
new file mode 100644
index 000000000000..15b7a4ba37b6
--- /dev/null
+++ b/drivers/staging/rtl8192su/dot11d.h
@@ -0,0 +1,102 @@
+#ifndef __INC_DOT11D_H
+#define __INC_DOT11D_H
+
+#ifdef ENABLE_DOT11D
+#include "ieee80211.h"
+
+//#define ENABLE_DOT11D
+
+//#define DOT11D_MAX_CHNL_NUM 83
+
+typedef struct _CHNL_TXPOWER_TRIPLE {
+ u8 FirstChnl;
+ u8 NumChnls;
+ u8 MaxTxPowerInDbm;
+}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
+
+typedef enum _DOT11D_STATE {
+ DOT11D_STATE_NONE = 0,
+ DOT11D_STATE_LEARNED,
+ DOT11D_STATE_DONE,
+}DOT11D_STATE;
+
+typedef struct _RT_DOT11D_INFO {
+ //DECLARE_RT_OBJECT(RT_DOT11D_INFO);
+
+ bool bEnabled; // dot11MultiDomainCapabilityEnabled
+
+ u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element.
+ u8 CountryIeBuf[MAX_IE_LEN];
+ u8 CountryIeSrcAddr[6]; // Source AP of the country IE.
+ u8 CountryIeWatchdog;
+
+ u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan)
+ //u8 ChnlListLen; // #Bytes valid in ChnlList[].
+ //u8 ChnlList[DOT11D_MAX_CHNL_NUM];
+ u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
+
+ DOT11D_STATE State;
+}RT_DOT11D_INFO, *PRT_DOT11D_INFO;
+#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
+#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
+#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo))
+
+#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled
+#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
+
+#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
+#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
+
+#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
+ (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
+ FALSE : \
+ (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length)))
+
+#define CIE_WATCHDOG_TH 1
+#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog
+#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
+#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev)
+
+#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
+
+
+void
+Dot11d_Init(
+ struct ieee80211_device *dev
+ );
+
+void
+Dot11d_Reset(
+ struct ieee80211_device *dev
+ );
+
+void
+Dot11d_UpdateCountryIe(
+ struct ieee80211_device *dev,
+ u8 * pTaddr,
+ u16 CoutryIeLen,
+ u8 * pCoutryIe
+ );
+
+u8
+DOT11D_GetMaxTxPwrInDbm(
+ struct ieee80211_device *dev,
+ u8 Channel
+ );
+
+void
+DOT11D_ScanComplete(
+ struct ieee80211_device * dev
+ );
+
+int IsLegalChannel(
+ struct ieee80211_device * dev,
+ u8 channel
+);
+
+int ToLegalChannel(
+ struct ieee80211_device * dev,
+ u8 channel
+);
+#endif //ENABLE_DOT11D
+#endif // #ifndef __INC_DOT11D_H
diff --git a/drivers/staging/rtl8192su/ieee80211.h b/drivers/staging/rtl8192su/ieee80211.h
new file mode 100644
index 000000000000..0edb09a536f9
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211.h
@@ -0,0 +1,2901 @@
+/*
+ * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
+ * remains copyright by the original authors
+ *
+ * Portions of the merged code are based on Host AP (software wireless
+ * LAN access point) driver for Intersil Prism2/2.5/3.
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * Adaption to a generic IEEE 802.11 stack by James Ketrenos
+ * <jketreno@linux.intel.com>
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * Modified for Realtek's wi-fi cards by Andrea Merello
+ * <andreamrl@tiscali.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+#ifndef IEEE80211_H
+#define IEEE80211_H
+#include <linux/if_ether.h> /* ETH_ALEN */
+#include <linux/kernel.h> /* ARRAY_SIZE */
+#include <linux/version.h>
+#include <linux/module.h>
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#include <linux/jiffies.h>
+#else
+#include <linux/jffs.h>
+#include <linux/tqueue.h>
+#endif
+#include <linux/timer.h>
+#include <linux/sched.h>
+
+#include <linux/delay.h>
+#include <linux/wireless.h>
+
+#include "ieee80211/rtl819x_HT.h"
+#include "ieee80211/rtl819x_BA.h"
+#include "ieee80211/rtl819x_TS.h"
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+#ifndef bool
+typedef enum{false = 0, true} bool;
+#endif
+#endif
+
+#ifndef IW_MODE_MONITOR
+#define IW_MODE_MONITOR 6
+#endif
+
+#ifndef IWEVCUSTOM
+#define IWEVCUSTOM 0x8c02
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#ifndef __bitwise
+#define __bitwise __attribute__((bitwise))
+#endif
+typedef __u16 __le16;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27))
+struct iw_spy_data{
+ /* --- Standard spy support --- */
+ int spy_number;
+ u_char spy_address[IW_MAX_SPY][ETH_ALEN];
+ struct iw_quality spy_stat[IW_MAX_SPY];
+ /* --- Enhanced spy support (event) */
+ struct iw_quality spy_thr_low; /* Low threshold */
+ struct iw_quality spy_thr_high; /* High threshold */
+ u_char spy_thr_under[IW_MAX_SPY];
+};
+#endif
+#endif
+
+#ifndef container_of
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ *
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+#define KEY_TYPE_NA 0x0
+#define KEY_TYPE_WEP40 0x1
+#define KEY_TYPE_TKIP 0x2
+#define KEY_TYPE_CCMP 0x4
+#define KEY_TYPE_WEP104 0x5
+
+/* added for rtl819x tx procedure */
+#define MAX_QUEUE_SIZE 0x10
+
+//
+// 8190 queue mapping
+//
+#define BK_QUEUE 0
+#define BE_QUEUE 1
+#define VI_QUEUE 2
+#define VO_QUEUE 3
+#define HCCA_QUEUE 4
+#define TXCMD_QUEUE 5
+#define MGNT_QUEUE 6
+#define HIGH_QUEUE 7
+#define BEACON_QUEUE 8
+
+#define LOW_QUEUE BE_QUEUE
+#define NORMAL_QUEUE MGNT_QUEUE
+
+//added by amy for ps
+#define SWRF_TIMEOUT 50
+
+//added by amy for LEAP related
+#define IE_CISCO_FLAG_POSITION 0x08 // Flag byte: byte 8, numbered from 0.
+#define SUPPORT_CKIP_MIC 0x08 // bit3
+#define SUPPORT_CKIP_PK 0x10 // bit4
+//added by amy for ps
+// RF Off Level for IPS or HW/SW radio off
+#define RT_RF_OFF_LEVL_ASPM BIT0 // PCI ASPM
+#define RT_RF_OFF_LEVL_CLK_REQ BIT1 // PCI clock request
+#define RT_RF_OFF_LEVL_PCI_D3 BIT2 // PCI D3 mode
+#define RT_RF_OFF_LEVL_HALT_NIC BIT3 // NIC halt, re-initialize hw parameters
+#define RT_RF_OFF_LEVL_FREE_FW BIT4 // FW free, re-download the FW
+#define RT_RF_OFF_LEVL_FW_32K BIT5 // FW in 32k
+#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 // Always enable ASPM and Clock Req in initialization.
+#define RT_RF_LPS_DISALBE_2R BIT30 // When LPS is on, disable 2R if no packet is received or transmittd.
+#define RT_RF_LPS_LEVEL_ASPM BIT31 // LPS with ASPM
+#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
+#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG)))
+#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel->CurPsLevel |= _PS_FLAG)
+/* defined for skb cb field */
+/* At most 28 byte */
+typedef struct cb_desc {
+ /* Tx Desc Related flags (8-9) */
+ u8 bLastIniPkt:1;
+ u8 bCmdOrInit:1;
+ u8 bFirstSeg:1;
+ u8 bLastSeg:1;
+ u8 bEncrypt:1;
+ u8 bTxDisableRateFallBack:1;
+ u8 bTxUseDriverAssingedRate:1;
+ u8 bHwSec:1; //indicate whether use Hw security. WB
+
+ u8 reserved1;
+
+ /* Tx Firmware Relaged flags (10-11)*/
+ u8 bCTSEnable:1;
+ u8 bRTSEnable:1;
+ u8 bUseShortGI:1;
+ u8 bUseShortPreamble:1;
+ u8 bTxEnableFwCalcDur:1;
+ u8 bAMPDUEnable:1;
+ u8 bRTSSTBC:1;
+ u8 RTSSC:1;
+
+ u8 bRTSBW:1;
+ u8 bPacketBW:1;
+ u8 bRTSUseShortPreamble:1;
+ u8 bRTSUseShortGI:1;
+ u8 bMulticast:1;
+ u8 bBroadcast:1;
+ //u8 reserved2:2;
+ u8 drv_agg_enable:1;
+ u8 reserved2:1;
+
+ /* Tx Desc related element(12-19) */
+ u8 rata_index;
+ u8 queue_index;
+ //u8 reserved3;
+ //u8 reserved4;
+ u16 txbuf_size;
+ //u8 reserved5;
+ u8 RATRIndex;
+ u8 reserved6;
+ u8 reserved7;
+ u8 reserved8;
+
+ /* Tx firmware related element(20-27) */
+ u8 data_rate;
+ u8 rts_rate;
+ u8 ampdu_factor;
+ u8 ampdu_density;
+ //u8 reserved9;
+ //u8 reserved10;
+ //u8 reserved11;
+ u8 DrvAggrNum;
+ u16 pkt_size;
+ u8 reserved12;
+}cb_desc, *pcb_desc;
+
+/*--------------------------Define -------------------------------------------*/
+#define MGN_1M 0x02
+#define MGN_2M 0x04
+#define MGN_5_5M 0x0b
+#define MGN_11M 0x16
+
+#define MGN_6M 0x0c
+#define MGN_9M 0x12
+#define MGN_12M 0x18
+#define MGN_18M 0x24
+#define MGN_24M 0x30
+#define MGN_36M 0x48
+#define MGN_48M 0x60
+#define MGN_54M 0x6c
+
+#define MGN_MCS0 0x80
+#define MGN_MCS1 0x81
+#define MGN_MCS2 0x82
+#define MGN_MCS3 0x83
+#define MGN_MCS4 0x84
+#define MGN_MCS5 0x85
+#define MGN_MCS6 0x86
+#define MGN_MCS7 0x87
+#define MGN_MCS8 0x88
+#define MGN_MCS9 0x89
+#define MGN_MCS10 0x8a
+#define MGN_MCS11 0x8b
+#define MGN_MCS12 0x8c
+#define MGN_MCS13 0x8d
+#define MGN_MCS14 0x8e
+#define MGN_MCS15 0x8f
+#define MGN_MCS0_SG 0x90
+#define MGN_MCS1_SG 0x91
+#define MGN_MCS2_SG 0x92
+#define MGN_MCS3_SG 0x93
+#define MGN_MCS4_SG 0x94
+#define MGN_MCS5_SG 0x95
+#define MGN_MCS6_SG 0x96
+#define MGN_MCS7_SG 0x97
+#define MGN_MCS8_SG 0x98
+#define MGN_MCS9_SG 0x99
+#define MGN_MCS10_SG 0x9a
+#define MGN_MCS11_SG 0x9b
+#define MGN_MCS12_SG 0x9c
+#define MGN_MCS13_SG 0x9d
+#define MGN_MCS14_SG 0x9e
+#define MGN_MCS15_SG 0x9f
+
+
+//----------------------------------------------------------------------------
+// 802.11 Management frame Reason Code field
+//----------------------------------------------------------------------------
+enum _ReasonCode{
+ unspec_reason = 0x1,
+ auth_not_valid = 0x2,
+ deauth_lv_ss = 0x3,
+ inactivity = 0x4,
+ ap_overload = 0x5,
+ class2_err = 0x6,
+ class3_err = 0x7,
+ disas_lv_ss = 0x8,
+ asoc_not_auth = 0x9,
+
+ //----MIC_CHECK
+ mic_failure = 0xe,
+ //----END MIC_CHECK
+
+ // Reason code defined in 802.11i D10.0 p.28.
+ invalid_IE = 0x0d,
+ four_way_tmout = 0x0f,
+ two_way_tmout = 0x10,
+ IE_dismatch = 0x11,
+ invalid_Gcipher = 0x12,
+ invalid_Pcipher = 0x13,
+ invalid_AKMP = 0x14,
+ unsup_RSNIEver = 0x15,
+ invalid_RSNIE = 0x16,
+ auth_802_1x_fail= 0x17,
+ ciper_reject = 0x18,
+
+ // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15.
+ QoS_unspec = 0x20, // 32
+ QAP_bandwidth = 0x21, // 33
+ poor_condition = 0x22, // 34
+ no_facility = 0x23, // 35
+ // Where is 36???
+ req_declined = 0x25, // 37
+ invalid_param = 0x26, // 38
+ req_not_honored= 0x27, // 39
+ TS_not_created = 0x2F, // 47
+ DL_not_allowed = 0x30, // 48
+ dest_not_exist = 0x31, // 49
+ dest_not_QSTA = 0x32, // 50
+};
+
+
+
+#define aSifsTime (((priv->ieee80211->current_network.mode == IEEE_A)||(priv->ieee80211->current_network.mode == IEEE_N_24G)||(priv->ieee80211->current_network.mode == IEEE_N_5G))? 16 : 10)
+
+#define MGMT_QUEUE_NUM 5
+
+#define IEEE_CMD_SET_WPA_PARAM 1
+#define IEEE_CMD_SET_WPA_IE 2
+#define IEEE_CMD_SET_ENCRYPTION 3
+#define IEEE_CMD_MLME 4
+
+#define IEEE_PARAM_WPA_ENABLED 1
+#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
+#define IEEE_PARAM_DROP_UNENCRYPTED 3
+#define IEEE_PARAM_PRIVACY_INVOKED 4
+#define IEEE_PARAM_AUTH_ALGS 5
+#define IEEE_PARAM_IEEE_802_1X 6
+//It should consistent with the driver_XXX.c
+// David, 2006.9.26
+#define IEEE_PARAM_WPAX_SELECT 7
+//Added for notify the encryption type selection
+// David, 2006.9.26
+#define IEEE_PROTO_WPA 1
+#define IEEE_PROTO_RSN 2
+//Added for notify the encryption type selection
+// David, 2006.9.26
+#define IEEE_WPAX_USEGROUP 0
+#define IEEE_WPAX_WEP40 1
+#define IEEE_WPAX_TKIP 2
+#define IEEE_WPAX_WRAP 3
+#define IEEE_WPAX_CCMP 4
+#define IEEE_WPAX_WEP104 5
+
+#define IEEE_KEY_MGMT_IEEE8021X 1
+#define IEEE_KEY_MGMT_PSK 2
+
+#define IEEE_MLME_STA_DEAUTH 1
+#define IEEE_MLME_STA_DISASSOC 2
+
+
+#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
+#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
+#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
+#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
+#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
+#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
+
+
+#define IEEE_CRYPT_ALG_NAME_LEN 16
+
+#define MAX_IE_LEN 0xff
+
+// added for kernel conflict
+#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
+#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
+#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
+#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl
+#define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
+#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl
+
+#define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
+
+#define ieee80211_tkip_null ieee80211_tkip_null_rsl
+
+#define ieee80211_wep_null ieee80211_wep_null_rsl
+
+#define free_ieee80211 free_ieee80211_rsl
+#define alloc_ieee80211 alloc_ieee80211_rsl
+
+#define ieee80211_rx ieee80211_rx_rsl
+#define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
+
+#define ieee80211_get_beacon ieee80211_get_beacon_rsl
+#define ieee80211_wake_queue ieee80211_wake_queue_rsl
+#define ieee80211_stop_queue ieee80211_stop_queue_rsl
+#define ieee80211_reset_queue ieee80211_reset_queue_rsl
+#define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl
+#define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
+#define ieee80211_is_shortslot ieee80211_is_shortslot_rsl
+#define ieee80211_is_54g ieee80211_is_54g_rsl
+#define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl
+#define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl
+#define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl
+#define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl
+#define notify_wx_assoc_event notify_wx_assoc_event_rsl
+#define SendDisassociation SendDisassociation_rsl
+#define ieee80211_disassociate ieee80211_disassociate_rsl
+#define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl
+#define ieee80211_stop_scan ieee80211_stop_scan_rsl
+#define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl
+#define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl
+#define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl
+
+#define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl
+#define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl
+#define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl
+#define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl
+#define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl
+#define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl
+#define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl
+#define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl
+#define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl
+#define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl
+#define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl
+#define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl
+#define ieee80211_wx_get_name ieee80211_wx_get_name_rsl
+#define ieee80211_wx_set_power ieee80211_wx_set_power_rsl
+#define ieee80211_wx_get_power ieee80211_wx_get_power_rsl
+#define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl
+#define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl
+#define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl
+
+#define ieee80211_txb_free ieee80211_txb_free_rsl
+
+#define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl
+#define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl
+#define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl
+#define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl
+#if WIRELESS_EXT >= 18
+#define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl
+#define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl
+#define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl
+#define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl
+#endif
+
+
+typedef struct ieee_param {
+ u32 cmd;
+ u8 sta_addr[ETH_ALEN];
+ union {
+ struct {
+ u8 name;
+ u32 value;
+ } wpa_param;
+ struct {
+ u32 len;
+ u8 reserved[32];
+ u8 data[0];
+ } wpa_ie;
+ struct{
+ int command;
+ int reason_code;
+ } mlme;
+ struct {
+ u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
+ u8 set_tx;
+ u32 err;
+ u8 idx;
+ u8 seq[8]; /* sequence counter (set: RX, get: TX) */
+ u16 key_len;
+ u8 key[0];
+ } crypt;
+ } u;
+}ieee_param;
+
+
+#if WIRELESS_EXT < 17
+#define IW_QUAL_QUAL_INVALID 0x10
+#define IW_QUAL_LEVEL_INVALID 0x20
+#define IW_QUAL_NOISE_INVALID 0x40
+#define IW_QUAL_QUAL_UPDATED 0x1
+#define IW_QUAL_LEVEL_UPDATED 0x2
+#define IW_QUAL_NOISE_UPDATED 0x4
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data)
+{
+ task->routine = func;
+ task->data = data;
+ //task->next = NULL;
+ INIT_LIST_HEAD(&task->list);
+ task->sync = 0;
+}
+#endif
+
+// linux under 2.6.9 release may not support it, so modify it for common use
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
+//#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
+#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
+static inline unsigned long msleep_interruptible_rsl(unsigned int msecs)
+{
+ unsigned long timeout = MSECS(msecs) + 1;
+
+ while (timeout) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ timeout = schedule_timeout(timeout);
+ }
+ return timeout;
+}
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
+static inline void msleep(unsigned int msecs)
+{
+ unsigned long timeout = MSECS(msecs) + 1;
+
+ while (timeout) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ timeout = schedule_timeout(timeout);
+ }
+}
+#endif
+#else
+#define MSECS(t) msecs_to_jiffies(t)
+#define msleep_interruptible_rsl msleep_interruptible
+#endif
+
+#define IEEE80211_DATA_LEN 2304
+/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
+ 6.2.1.1.2.
+
+ The figure in section 7.1.2 suggests a body size of up to 2312
+ bytes is allowed, which is a bit confusing, I suspect this
+ represents the 2304 bytes of real data, plus a possible 8 bytes of
+ WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
+#define IEEE80211_1ADDR_LEN 10
+#define IEEE80211_2ADDR_LEN 16
+#define IEEE80211_3ADDR_LEN 24
+#define IEEE80211_4ADDR_LEN 30
+#define IEEE80211_FCS_LEN 4
+#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
+#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
+#define IEEE80211_MGMT_HDR_LEN 24
+#define IEEE80211_DATA_HDR3_LEN 24
+#define IEEE80211_DATA_HDR4_LEN 30
+
+#define MIN_FRAG_THRESHOLD 256U
+#define MAX_FRAG_THRESHOLD 2346U
+
+
+/* Frame control field constants */
+#define IEEE80211_FCTL_VERS 0x0003
+#define IEEE80211_FCTL_FTYPE 0x000c
+#define IEEE80211_FCTL_STYPE 0x00f0
+#define IEEE80211_FCTL_FRAMETYPE 0x00fc
+#define IEEE80211_FCTL_TODS 0x0100
+#define IEEE80211_FCTL_FROMDS 0x0200
+#define IEEE80211_FCTL_DSTODS 0x0300 //added by david
+#define IEEE80211_FCTL_MOREFRAGS 0x0400
+#define IEEE80211_FCTL_RETRY 0x0800
+#define IEEE80211_FCTL_PM 0x1000
+#define IEEE80211_FCTL_MOREDATA 0x2000
+#define IEEE80211_FCTL_WEP 0x4000
+#define IEEE80211_FCTL_ORDER 0x8000
+
+#define IEEE80211_FTYPE_MGMT 0x0000
+#define IEEE80211_FTYPE_CTL 0x0004
+#define IEEE80211_FTYPE_DATA 0x0008
+
+/* management */
+#define IEEE80211_STYPE_ASSOC_REQ 0x0000
+#define IEEE80211_STYPE_ASSOC_RESP 0x0010
+#define IEEE80211_STYPE_REASSOC_REQ 0x0020
+#define IEEE80211_STYPE_REASSOC_RESP 0x0030
+#define IEEE80211_STYPE_PROBE_REQ 0x0040
+#define IEEE80211_STYPE_PROBE_RESP 0x0050
+#define IEEE80211_STYPE_BEACON 0x0080
+#define IEEE80211_STYPE_ATIM 0x0090
+#define IEEE80211_STYPE_DISASSOC 0x00A0
+#define IEEE80211_STYPE_AUTH 0x00B0
+#define IEEE80211_STYPE_DEAUTH 0x00C0
+#define IEEE80211_STYPE_MANAGE_ACT 0x00D0
+
+/* control */
+#define IEEE80211_STYPE_PSPOLL 0x00A0
+#define IEEE80211_STYPE_RTS 0x00B0
+#define IEEE80211_STYPE_CTS 0x00C0
+#define IEEE80211_STYPE_ACK 0x00D0
+#define IEEE80211_STYPE_CFEND 0x00E0
+#define IEEE80211_STYPE_CFENDACK 0x00F0
+#define IEEE80211_STYPE_BLOCKACK 0x0094
+
+/* data */
+#define IEEE80211_STYPE_DATA 0x0000
+#define IEEE80211_STYPE_DATA_CFACK 0x0010
+#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
+#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
+#define IEEE80211_STYPE_NULLFUNC 0x0040
+#define IEEE80211_STYPE_CFACK 0x0050
+#define IEEE80211_STYPE_CFPOLL 0x0060
+#define IEEE80211_STYPE_CFACKPOLL 0x0070
+#define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2
+#define IEEE80211_STYPE_QOS_NULL 0x00C0
+
+#define IEEE80211_SCTL_FRAG 0x000F
+#define IEEE80211_SCTL_SEQ 0xFFF0
+
+/* QOS control */
+#define IEEE80211_QCTL_TID 0x000F
+
+#define FC_QOS_BIT BIT7
+#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false )
+#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) )
+//added by wb. Is this right?
+#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA))
+#define Frame_Order(pframe) (*(u16*)pframe&IEEE80211_FCTL_ORDER)
+#define SN_LESS(a, b) (((a-b)&0x800)!=0)
+#define SN_EQUAL(a, b) (a == b)
+#define MAX_DEV_ADDR_SIZE 8
+typedef enum _ACT_CATEGORY{
+ ACT_CAT_QOS = 1,
+ ACT_CAT_DLS = 2,
+ ACT_CAT_BA = 3,
+ ACT_CAT_HT = 7,
+ ACT_CAT_WMM = 17,
+} ACT_CATEGORY, *PACT_CATEGORY;
+
+typedef enum _TS_ACTION{
+ ACT_ADDTSREQ = 0,
+ ACT_ADDTSRSP = 1,
+ ACT_DELTS = 2,
+ ACT_SCHEDULE = 3,
+} TS_ACTION, *PTS_ACTION;
+
+typedef enum _BA_ACTION{
+ ACT_ADDBAREQ = 0,
+ ACT_ADDBARSP = 1,
+ ACT_DELBA = 2,
+} BA_ACTION, *PBA_ACTION;
+
+typedef enum _InitialGainOpType{
+ IG_Backup=0,
+ IG_Restore,
+ IG_Max
+}InitialGainOpType;
+//added by amy for LED 090319
+//================================================================================
+// LED customization.
+//================================================================================
+typedef enum _LED_CTL_MODE{
+ LED_CTL_POWER_ON = 1,
+ LED_CTL_LINK = 2,
+ LED_CTL_NO_LINK = 3,
+ LED_CTL_TX = 4,
+ LED_CTL_RX = 5,
+ LED_CTL_SITE_SURVEY = 6,
+ LED_CTL_POWER_OFF = 7,
+ LED_CTL_START_TO_LINK = 8,
+ LED_CTL_START_WPS = 9,
+ LED_CTL_STOP_WPS = 10,
+ LED_CTL_START_WPS_BOTTON = 11, //added for runtop
+}LED_CTL_MODE;
+
+/* debug macros */
+#define CONFIG_IEEE80211_DEBUG
+#ifdef CONFIG_IEEE80211_DEBUG
+extern u32 ieee80211_debug_level;
+#define IEEE80211_DEBUG(level, fmt, args...) \
+do { if (ieee80211_debug_level & (level)) \
+ printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
+//wb added to debug out data buf
+//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
+#define IEEE80211_DEBUG_DATA(level, data, datalen) \
+ do{ if ((ieee80211_debug_level & (level)) == (level)) \
+ { \
+ int i; \
+ u8* pdata = (u8*) data; \
+ printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \
+ for(i=0; i<(int)(datalen); i++) \
+ { \
+ printk("%2x ", pdata[i]); \
+ if ((i+1)%16 == 0) printk("\n"); \
+ } \
+ printk("\n"); \
+ } \
+ } while (0)
+#else
+#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
+#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0)
+#endif /* CONFIG_IEEE80211_DEBUG */
+
+/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
+
+#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
+
+/*
+ * To use the debug system;
+ *
+ * If you are defining a new debug classification, simply add it to the #define
+ * list here in the form of:
+ *
+ * #define IEEE80211_DL_xxxx VALUE
+ *
+ * shifting value to the left one bit from the previous entry. xxxx should be
+ * the name of the classification (for example, WEP)
+ *
+ * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
+ * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
+ * to send output to that classification.
+ *
+ * To add your debug level to the list of levels seen when you perform
+ *
+ * % cat /proc/net/ipw/debug_level
+ *
+ * you simply need to add your entry to the ipw_debug_levels array.
+ *
+ * If you do not see debug_level in /proc/net/ipw then you do not have
+ * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
+ *
+ */
+
+#define IEEE80211_DL_INFO (1<<0)
+#define IEEE80211_DL_WX (1<<1)
+#define IEEE80211_DL_SCAN (1<<2)
+#define IEEE80211_DL_STATE (1<<3)
+#define IEEE80211_DL_MGMT (1<<4)
+#define IEEE80211_DL_FRAG (1<<5)
+#define IEEE80211_DL_EAP (1<<6)
+#define IEEE80211_DL_DROP (1<<7)
+
+#define IEEE80211_DL_TX (1<<8)
+#define IEEE80211_DL_RX (1<<9)
+
+#define IEEE80211_DL_HT (1<<10) //HT
+#define IEEE80211_DL_BA (1<<11) //ba
+#define IEEE80211_DL_TS (1<<12) //TS
+#define IEEE80211_DL_QOS (1<<13)
+#define IEEE80211_DL_REORDER (1<<14)
+#define IEEE80211_DL_IOT (1<<15)
+#define IEEE80211_DL_IPS (1<<16)
+#define IEEE80211_DL_TRACE (1<<29) //trace function, need to user net_ratelimit() together in order not to print too much to the screen
+#define IEEE80211_DL_DATA (1<<30) //use this flag to control whether print data buf out.
+#define IEEE80211_DL_ERR (1<<31) //always open
+#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
+#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
+#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
+
+#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
+#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
+#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
+#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
+#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
+#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
+#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
+#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
+#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
+#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
+
+#ifdef CONFIG_IEEE80211_DEBUG
+/* Added by Annie, 2005-11-22. */
+#define MAX_STR_LEN 64
+/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/
+#define PRINTABLE(_ch) (_ch>'!' && _ch<'~')
+#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
+ if((_Comp) & level) \
+ { \
+ int __i; \
+ u8 buffer[MAX_STR_LEN]; \
+ int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
+ memset(buffer, 0, MAX_STR_LEN); \
+ memcpy(buffer, (u8 *)_Ptr, length ); \
+ for( __i=0; __i<MAX_STR_LEN; __i++ ) \
+ { \
+ if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
+ } \
+ buffer[length] = '\0'; \
+ printk("Rtl819x: "); \
+ printk(_TitleString); \
+ printk(": %d, <%s>\n", _Len, buffer); \
+ }
+#else
+#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0)
+#endif
+
+#include <linux/netdevice.h>
+#include <linux/if_arp.h> /* ARPHRD_ETHER */
+
+#ifndef WIRELESS_SPY
+#define WIRELESS_SPY // enable iwspy support
+#endif
+#include <net/iw_handler.h> // new driver API
+
+#ifndef ETH_P_PAE
+#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
+#endif /* ETH_P_PAE */
+
+#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
+
+#ifndef ETH_P_80211_RAW
+#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
+#endif
+
+/* IEEE 802.11 defines */
+
+#define P80211_OUI_LEN 3
+
+struct ieee80211_snap_hdr {
+
+ u8 dsap; /* always 0xAA */
+ u8 ssap; /* always 0xAA */
+ u8 ctrl; /* always 0x03 */
+ u8 oui[P80211_OUI_LEN]; /* organizational universal id */
+
+} __attribute__ ((packed));
+
+#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
+
+#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
+#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
+#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
+
+#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
+#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
+#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
+
+/* Authentication algorithms */
+#define WLAN_AUTH_OPEN 0
+#define WLAN_AUTH_SHARED_KEY 1
+#define WLAN_AUTH_LEAP 2
+
+#define WLAN_AUTH_CHALLENGE_LEN 128
+
+#define WLAN_CAPABILITY_BSS (1<<0)
+#define WLAN_CAPABILITY_IBSS (1<<1)
+#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
+#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
+#define WLAN_CAPABILITY_PRIVACY (1<<4)
+#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
+#define WLAN_CAPABILITY_PBCC (1<<6)
+#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
+#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
+#define WLAN_CAPABILITY_QOS (1<<9)
+#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
+#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
+
+/* 802.11g ERP information element */
+#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
+#define WLAN_ERP_USE_PROTECTION (1<<1)
+#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
+
+/* Status codes */
+enum ieee80211_statuscode {
+ WLAN_STATUS_SUCCESS = 0,
+ WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
+ WLAN_STATUS_CAPS_UNSUPPORTED = 10,
+ WLAN_STATUS_REASSOC_NO_ASSOC = 11,
+ WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
+ WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
+ WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
+ WLAN_STATUS_CHALLENGE_FAIL = 15,
+ WLAN_STATUS_AUTH_TIMEOUT = 16,
+ WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
+ WLAN_STATUS_ASSOC_DENIED_RATES = 18,
+ /* 802.11b */
+ WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
+ WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
+ WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
+ /* 802.11h */
+ WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
+ WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
+ WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
+ /* 802.11g */
+ WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
+ WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
+ /* 802.11i */
+ WLAN_STATUS_INVALID_IE = 40,
+ WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
+ WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
+ WLAN_STATUS_INVALID_AKMP = 43,
+ WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
+ WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
+ WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
+};
+
+/* Reason codes */
+enum ieee80211_reasoncode {
+ WLAN_REASON_UNSPECIFIED = 1,
+ WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
+ WLAN_REASON_DEAUTH_LEAVING = 3,
+ WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
+ WLAN_REASON_DISASSOC_AP_BUSY = 5,
+ WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
+ WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
+ WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
+ WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
+ /* 802.11h */
+ WLAN_REASON_DISASSOC_BAD_POWER = 10,
+ WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
+ /* 802.11i */
+ WLAN_REASON_INVALID_IE = 13,
+ WLAN_REASON_MIC_FAILURE = 14,
+ WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
+ WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
+ WLAN_REASON_IE_DIFFERENT = 17,
+ WLAN_REASON_INVALID_GROUP_CIPHER = 18,
+ WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
+ WLAN_REASON_INVALID_AKMP = 20,
+ WLAN_REASON_UNSUPP_RSN_VERSION = 21,
+ WLAN_REASON_INVALID_RSN_IE_CAP = 22,
+ WLAN_REASON_IEEE8021X_FAILED = 23,
+ WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
+};
+
+#define IEEE80211_STATMASK_SIGNAL (1<<0)
+#define IEEE80211_STATMASK_RSSI (1<<1)
+#define IEEE80211_STATMASK_NOISE (1<<2)
+#define IEEE80211_STATMASK_RATE (1<<3)
+#define IEEE80211_STATMASK_WEMASK 0x7
+
+#define IEEE80211_CCK_MODULATION (1<<0)
+#define IEEE80211_OFDM_MODULATION (1<<1)
+
+#define IEEE80211_24GHZ_BAND (1<<0)
+#define IEEE80211_52GHZ_BAND (1<<1)
+
+#define IEEE80211_CCK_RATE_LEN 4
+#define IEEE80211_CCK_RATE_1MB 0x02
+#define IEEE80211_CCK_RATE_2MB 0x04
+#define IEEE80211_CCK_RATE_5MB 0x0B
+#define IEEE80211_CCK_RATE_11MB 0x16
+#define IEEE80211_OFDM_RATE_LEN 8
+#define IEEE80211_OFDM_RATE_6MB 0x0C
+#define IEEE80211_OFDM_RATE_9MB 0x12
+#define IEEE80211_OFDM_RATE_12MB 0x18
+#define IEEE80211_OFDM_RATE_18MB 0x24
+#define IEEE80211_OFDM_RATE_24MB 0x30
+#define IEEE80211_OFDM_RATE_36MB 0x48
+#define IEEE80211_OFDM_RATE_48MB 0x60
+#define IEEE80211_OFDM_RATE_54MB 0x6C
+#define IEEE80211_BASIC_RATE_MASK 0x80
+
+#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
+#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
+#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
+#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
+#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
+#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
+#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
+#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
+#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
+#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
+#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
+#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
+
+#define IEEE80211_CCK_RATES_MASK 0x0000000F
+#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
+ IEEE80211_CCK_RATE_2MB_MASK)
+#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
+ IEEE80211_CCK_RATE_5MB_MASK | \
+ IEEE80211_CCK_RATE_11MB_MASK)
+
+#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
+#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
+ IEEE80211_OFDM_RATE_12MB_MASK | \
+ IEEE80211_OFDM_RATE_24MB_MASK)
+#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
+ IEEE80211_OFDM_RATE_9MB_MASK | \
+ IEEE80211_OFDM_RATE_18MB_MASK | \
+ IEEE80211_OFDM_RATE_36MB_MASK | \
+ IEEE80211_OFDM_RATE_48MB_MASK | \
+ IEEE80211_OFDM_RATE_54MB_MASK)
+#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
+ IEEE80211_CCK_DEFAULT_RATES_MASK)
+
+#define IEEE80211_NUM_OFDM_RATES 8
+#define IEEE80211_NUM_CCK_RATES 4
+#define IEEE80211_OFDM_SHIFT_MASK_A 4
+
+
+/* this is stolen and modified from the madwifi driver*/
+#define IEEE80211_FC0_TYPE_MASK 0x0c
+#define IEEE80211_FC0_TYPE_DATA 0x08
+#define IEEE80211_FC0_SUBTYPE_MASK 0xB0
+#define IEEE80211_FC0_SUBTYPE_QOS 0x80
+
+#define IEEE80211_QOS_HAS_SEQ(fc) \
+ (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
+ (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
+
+/* this is stolen from ipw2200 driver */
+#define IEEE_IBSS_MAC_HASH_SIZE 31
+struct ieee_ibss_seq {
+ u8 mac[ETH_ALEN];
+ u16 seq_num[17];
+ u16 frag_num[17];
+ unsigned long packet_time[17];
+ struct list_head list;
+};
+
+/* NOTE: This data is for statistical purposes; not all hardware provides this
+ * information for frames received. Not setting these will not cause
+ * any adverse affects. */
+struct ieee80211_rx_stats {
+#if 1
+ u32 mac_time[2];
+ s8 rssi;
+ u8 signal;
+ u8 noise;
+ u16 rate; /* in 100 kbps */
+ u8 received_channel;
+ u8 control;
+ u8 mask;
+ u8 freq;
+ u16 len;
+ u64 tsf;
+ u32 beacon_time;
+ u8 nic_type;
+ u16 Length;
+ // u8 DataRate; // In 0.5 Mbps
+ u8 SignalQuality; // in 0-100 index.
+ s32 RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation.
+ s8 RxPower; // in dBm Translate from PWdB
+ u8 SignalStrength; // in 0-100 index.
+ u16 bHwError:1;
+ u16 bCRC:1;
+ u16 bICV:1;
+ u16 bShortPreamble:1;
+ u16 Antenna:1; //for rtl8185
+ u16 Decrypted:1; //for rtl8185, rtl8187
+ u16 Wakeup:1; //for rtl8185
+ u16 Reserved0:1; //for rtl8185
+ u8 AGC;
+ u32 TimeStampLow;
+ u32 TimeStampHigh;
+ bool bShift;
+ bool bIsQosData; // Added by Annie, 2005-12-22.
+ u8 UserPriority;
+
+ //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //1Attention Please!!!<11n or 8190 specific code should be put below this line>
+ //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ u8 RxDrvInfoSize;
+ u8 RxBufShift;
+ bool bIsAMPDU;
+ bool bFirstMPDU;
+ bool bContainHTC;
+ bool RxIs40MHzPacket;
+ u32 RxPWDBAll;
+ u8 RxMIMOSignalStrength[4]; // in 0~100 index
+ s8 RxMIMOSignalQuality[2];
+ bool bPacketMatchBSSID;
+ bool bIsCCK;
+ bool bPacketToSelf;
+ //added by amy
+ u8* virtual_address;
+ u16 packetlength; // Total packet length: Must equal to sum of all FragLength
+ u16 fraglength; // FragLength should equal to PacketLength in non-fragment case
+ u16 fragoffset; // Data offset for this fragment
+ u16 ntotalfrag;
+ bool bisrxaggrsubframe;
+ bool bPacketBeacon; //cosa add for rssi
+ bool bToSelfBA; //cosa add for rssi
+ char cck_adc_pwdb[4]; //cosa add for rx path selection
+ u16 Seq_Num;
+ u8 nTotalAggPkt; // Number of aggregated packets.
+#endif
+
+};
+
+/* IEEE 802.11 requires that STA supports concurrent reception of at least
+ * three fragmented frames. This define can be increased to support more
+ * concurrent frames, but it should be noted that each entry can consume about
+ * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
+#define IEEE80211_FRAG_CACHE_LEN 4
+
+struct ieee80211_frag_entry {
+ unsigned long first_frag_time;
+ unsigned int seq;
+ unsigned int last_frag;
+ struct sk_buff *skb;
+ u8 src_addr[ETH_ALEN];
+ u8 dst_addr[ETH_ALEN];
+};
+
+struct ieee80211_stats {
+ unsigned int tx_unicast_frames;
+ unsigned int tx_multicast_frames;
+ unsigned int tx_fragments;
+ unsigned int tx_unicast_octets;
+ unsigned int tx_multicast_octets;
+ unsigned int tx_deferred_transmissions;
+ unsigned int tx_single_retry_frames;
+ unsigned int tx_multiple_retry_frames;
+ unsigned int tx_retry_limit_exceeded;
+ unsigned int tx_discards;
+ unsigned int rx_unicast_frames;
+ unsigned int rx_multicast_frames;
+ unsigned int rx_fragments;
+ unsigned int rx_unicast_octets;
+ unsigned int rx_multicast_octets;
+ unsigned int rx_fcs_errors;
+ unsigned int rx_discards_no_buffer;
+ unsigned int tx_discards_wrong_sa;
+ unsigned int rx_discards_undecryptable;
+ unsigned int rx_message_in_msg_fragments;
+ unsigned int rx_message_in_bad_msg_fragments;
+};
+
+struct ieee80211_device;
+
+#include "ieee80211_crypt.h"
+
+#define SEC_KEY_1 (1<<0)
+#define SEC_KEY_2 (1<<1)
+#define SEC_KEY_3 (1<<2)
+#define SEC_KEY_4 (1<<3)
+#define SEC_ACTIVE_KEY (1<<4)
+#define SEC_AUTH_MODE (1<<5)
+#define SEC_UNICAST_GROUP (1<<6)
+#define SEC_LEVEL (1<<7)
+#define SEC_ENABLED (1<<8)
+#define SEC_ENCRYPT (1<<9)
+
+#define SEC_LEVEL_0 0 /* None */
+#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
+#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
+#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
+#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
+
+#define SEC_ALG_NONE 0
+#define SEC_ALG_WEP 1
+#define SEC_ALG_TKIP 2
+#define SEC_ALG_CCMP 3
+
+#define WEP_KEYS 4
+#define WEP_KEY_LEN 13
+#define SCM_KEY_LEN 32
+#define SCM_TEMPORAL_KEY_LENGTH 16
+
+struct ieee80211_security {
+ u16 active_key:2,
+ enabled:1,
+ auth_mode:2,
+ auth_algo:4,
+ unicast_uses_group:1,
+ encrypt:1;
+ u8 key_sizes[WEP_KEYS];
+ u8 keys[WEP_KEYS][SCM_KEY_LEN];
+ u8 level;
+ u16 flags;
+} __attribute__ ((packed));
+
+
+/*
+ 802.11 data frame from AP
+ ,-------------------------------------------------------------------.
+Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
+ |------|------|---------|---------|---------|------|---------|------|
+Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
+ | | tion | (BSSID) | | | ence | data | |
+ `-------------------------------------------------------------------'
+Total: 28-2340 bytes
+*/
+
+/* Management Frame Information Element Types */
+enum ieee80211_mfie {
+ MFIE_TYPE_SSID = 0,
+ MFIE_TYPE_RATES = 1,
+ MFIE_TYPE_FH_SET = 2,
+ MFIE_TYPE_DS_SET = 3,
+ MFIE_TYPE_CF_SET = 4,
+ MFIE_TYPE_TIM = 5,
+ MFIE_TYPE_IBSS_SET = 6,
+ MFIE_TYPE_COUNTRY = 7,
+ MFIE_TYPE_HOP_PARAMS = 8,
+ MFIE_TYPE_HOP_TABLE = 9,
+ MFIE_TYPE_REQUEST = 10,
+ MFIE_TYPE_CHALLENGE = 16,
+ MFIE_TYPE_POWER_CONSTRAINT = 32,
+ MFIE_TYPE_POWER_CAPABILITY = 33,
+ MFIE_TYPE_TPC_REQUEST = 34,
+ MFIE_TYPE_TPC_REPORT = 35,
+ MFIE_TYPE_SUPP_CHANNELS = 36,
+ MFIE_TYPE_CSA = 37,
+ MFIE_TYPE_MEASURE_REQUEST = 38,
+ MFIE_TYPE_MEASURE_REPORT = 39,
+ MFIE_TYPE_QUIET = 40,
+ MFIE_TYPE_IBSS_DFS = 41,
+ MFIE_TYPE_ERP = 42,
+ MFIE_TYPE_RSN = 48,
+ MFIE_TYPE_RATES_EX = 50,
+ MFIE_TYPE_HT_CAP= 45,
+ MFIE_TYPE_HT_INFO= 61,
+ MFIE_TYPE_AIRONET=133,
+ MFIE_TYPE_GENERIC = 221,
+ MFIE_TYPE_QOS_PARAMETER = 222,
+};
+
+/* Minimal header; can be used for passing 802.11 frames with sufficient
+ * information to determine what type of underlying data type is actually
+ * stored in the data. */
+struct ieee80211_hdr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_1addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_2addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_3addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_4addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 addr4[ETH_ALEN];
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_3addrqos {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 payload[0];
+ __le16 qos_ctl;
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_4addrqos {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 addr4[ETH_ALEN];
+ u8 payload[0];
+ __le16 qos_ctl;
+} __attribute__ ((packed));
+
+struct ieee80211_info_element {
+ u8 id;
+ u8 len;
+ u8 data[0];
+} __attribute__ ((packed));
+
+struct ieee80211_authentication {
+ struct ieee80211_hdr_3addr header;
+ __le16 algorithm;
+ __le16 transaction;
+ __le16 status;
+ /*challenge*/
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_disassoc {
+ struct ieee80211_hdr_3addr header;
+ __le16 reason;
+} __attribute__ ((packed));
+
+struct ieee80211_probe_request {
+ struct ieee80211_hdr_3addr header;
+ /* SSID, supported rates */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_probe_response {
+ struct ieee80211_hdr_3addr header;
+ u32 time_stamp[2];
+ __le16 beacon_interval;
+ __le16 capability;
+ /* SSID, supported rates, FH params, DS params,
+ * CF params, IBSS params, TIM (if beacon), RSN */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+/* Alias beacon for probe_response */
+#define ieee80211_beacon ieee80211_probe_response
+
+struct ieee80211_assoc_request_frame {
+ struct ieee80211_hdr_3addr header;
+ __le16 capability;
+ __le16 listen_interval;
+ /* SSID, supported rates, RSN */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_reassoc_request_frame {
+ struct ieee80211_hdr_3addr header;
+ __le16 capability;
+ __le16 listen_interval;
+ u8 current_ap[ETH_ALEN];
+ /* SSID, supported rates, RSN */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_assoc_response_frame {
+ struct ieee80211_hdr_3addr header;
+ __le16 capability;
+ __le16 status;
+ __le16 aid;
+ struct ieee80211_info_element info_element[0]; /* supported rates */
+} __attribute__ ((packed));
+
+struct ieee80211_txb {
+ u8 nr_frags;
+ u8 encrypted;
+ u8 queue_index;
+ u8 rts_included;
+ u16 reserved;
+ __le16 frag_size;
+ __le16 payload_size;
+ struct sk_buff *fragments[0];
+};
+
+#define MAX_TX_AGG_COUNT 16
+struct ieee80211_drv_agg_txb {
+ u8 nr_drv_agg_frames;
+ struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
+}__attribute__((packed));
+
+#define MAX_SUBFRAME_COUNT 64
+struct ieee80211_rxb {
+ u8 nr_subframes;
+ struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
+ u8 dst[ETH_ALEN];
+ u8 src[ETH_ALEN];
+}__attribute__((packed));
+
+typedef union _frameqos {
+ u16 shortdata;
+ u8 chardata[2];
+ struct {
+ u16 tid:4;
+ u16 eosp:1;
+ u16 ack_policy:2;
+ u16 reserved:1;
+ u16 txop:8;
+ }field;
+}frameqos,*pframeqos;
+
+/* SWEEP TABLE ENTRIES NUMBER*/
+#define MAX_SWEEP_TAB_ENTRIES 42
+#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
+/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
+ * only use 8, and then use extended rates for the remaining supported
+ * rates. Other APs, however, stick all of their supported rates on the
+ * main rates information element... */
+#define MAX_RATES_LENGTH ((u8)12)
+#define MAX_RATES_EX_LENGTH ((u8)16)
+#define MAX_NETWORK_COUNT 128
+
+#define MAX_CHANNEL_NUMBER 161
+#define IEEE80211_SOFTMAC_SCAN_TIME 100
+//(HZ / 2)
+#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
+
+#define CRC_LENGTH 4U
+
+#define MAX_WPA_IE_LEN 64
+
+#define NETWORK_EMPTY_ESSID (1<<0)
+#define NETWORK_HAS_OFDM (1<<1)
+#define NETWORK_HAS_CCK (1<<2)
+
+/* QoS structure */
+#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
+#define NETWORK_HAS_QOS_INFORMATION (1<<4)
+#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
+ NETWORK_HAS_QOS_INFORMATION)
+/* 802.11h */
+#define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
+#define NETWORK_HAS_CSA (1<<6)
+#define NETWORK_HAS_QUIET (1<<7)
+#define NETWORK_HAS_IBSS_DFS (1<<8)
+#define NETWORK_HAS_TPC_REPORT (1<<9)
+
+#define NETWORK_HAS_ERP_VALUE (1<<10)
+
+#define QOS_QUEUE_NUM 4
+#define QOS_OUI_LEN 3
+#define QOS_OUI_TYPE 2
+#define QOS_ELEMENT_ID 221
+#define QOS_OUI_INFO_SUB_TYPE 0
+#define QOS_OUI_PARAM_SUB_TYPE 1
+#define QOS_VERSION_1 1
+#define QOS_AIFSN_MIN_VALUE 2
+#if 1
+struct ieee80211_qos_information_element {
+ u8 elementID;
+ u8 length;
+ u8 qui[QOS_OUI_LEN];
+ u8 qui_type;
+ u8 qui_subtype;
+ u8 version;
+ u8 ac_info;
+} __attribute__ ((packed));
+
+struct ieee80211_qos_ac_parameter {
+ u8 aci_aifsn;
+ u8 ecw_min_max;
+ __le16 tx_op_limit;
+} __attribute__ ((packed));
+
+struct ieee80211_qos_parameter_info {
+ struct ieee80211_qos_information_element info_element;
+ u8 reserved;
+ struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
+} __attribute__ ((packed));
+
+struct ieee80211_qos_parameters {
+ __le16 cw_min[QOS_QUEUE_NUM];
+ __le16 cw_max[QOS_QUEUE_NUM];
+ u8 aifs[QOS_QUEUE_NUM];
+ u8 flag[QOS_QUEUE_NUM];
+ __le16 tx_op_limit[QOS_QUEUE_NUM];
+} __attribute__ ((packed));
+
+struct ieee80211_qos_data {
+ struct ieee80211_qos_parameters parameters;
+ int active;
+ int supported;
+ u8 param_count;
+ u8 old_param_count;
+};
+
+struct ieee80211_tim_parameters {
+ u8 tim_count;
+ u8 tim_period;
+} __attribute__ ((packed));
+
+//#else
+struct ieee80211_wmm_ac_param {
+ u8 ac_aci_acm_aifsn;
+ u8 ac_ecwmin_ecwmax;
+ u16 ac_txop_limit;
+};
+
+struct ieee80211_wmm_ts_info {
+ u8 ac_dir_tid;
+ u8 ac_up_psb;
+ u8 reserved;
+} __attribute__ ((packed));
+
+struct ieee80211_wmm_tspec_elem {
+ struct ieee80211_wmm_ts_info ts_info;
+ u16 norm_msdu_size;
+ u16 max_msdu_size;
+ u32 min_serv_inter;
+ u32 max_serv_inter;
+ u32 inact_inter;
+ u32 suspen_inter;
+ u32 serv_start_time;
+ u32 min_data_rate;
+ u32 mean_data_rate;
+ u32 peak_data_rate;
+ u32 max_burst_size;
+ u32 delay_bound;
+ u32 min_phy_rate;
+ u16 surp_band_allow;
+ u16 medium_time;
+}__attribute__((packed));
+#endif
+enum eap_type {
+ EAP_PACKET = 0,
+ EAPOL_START,
+ EAPOL_LOGOFF,
+ EAPOL_KEY,
+ EAPOL_ENCAP_ASF_ALERT
+};
+
+static const char *eap_types[] = {
+ [EAP_PACKET] = "EAP-Packet",
+ [EAPOL_START] = "EAPOL-Start",
+ [EAPOL_LOGOFF] = "EAPOL-Logoff",
+ [EAPOL_KEY] = "EAPOL-Key",
+ [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
+};
+
+static inline const char *eap_get_type(int type)
+{
+ return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
+}
+//added by amy for reorder
+static inline u8 Frame_QoSTID(u8* buf)
+{
+ struct ieee80211_hdr_3addr *hdr;
+ u16 fc;
+ hdr = (struct ieee80211_hdr_3addr *)buf;
+ fc = le16_to_cpu(hdr->frame_ctl);
+ return (u8)((frameqos*)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid;
+}
+
+//added by amy for reorder
+
+struct eapol {
+ u8 snap[6];
+ u16 ethertype;
+ u8 version;
+ u8 type;
+ u16 length;
+} __attribute__ ((packed));
+
+struct ieee80211_softmac_stats{
+ unsigned int rx_ass_ok;
+ unsigned int rx_ass_err;
+ unsigned int rx_probe_rq;
+ unsigned int tx_probe_rs;
+ unsigned int tx_beacons;
+ unsigned int rx_auth_rq;
+ unsigned int rx_auth_rs_ok;
+ unsigned int rx_auth_rs_err;
+ unsigned int tx_auth_rq;
+ unsigned int no_auth_rs;
+ unsigned int no_ass_rs;
+ unsigned int tx_ass_rq;
+ unsigned int rx_ass_rq;
+ unsigned int tx_probe_rq;
+ unsigned int reassoc;
+ unsigned int swtxstop;
+ unsigned int swtxawake;
+ unsigned char CurrentShowTxate;
+ unsigned char last_packet_rate;
+ unsigned int txretrycount;
+};
+
+#define BEACON_PROBE_SSID_ID_POSITION 12
+
+struct ieee80211_info_element_hdr {
+ u8 id;
+ u8 len;
+} __attribute__ ((packed));
+
+/*
+ * These are the data types that can make up management packets
+ *
+ u16 auth_algorithm;
+ u16 auth_sequence;
+ u16 beacon_interval;
+ u16 capability;
+ u8 current_ap[ETH_ALEN];
+ u16 listen_interval;
+ struct {
+ u16 association_id:14, reserved:2;
+ } __attribute__ ((packed));
+ u32 time_stamp[2];
+ u16 reason;
+ u16 status;
+*/
+
+#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
+#define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps
+
+enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
+#define MAX_SP_Len (WMM_all_frame << 4)
+#define IEEE80211_QOS_TID 0x0f
+#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
+
+#define IEEE80211_DTIM_MBCAST 4
+#define IEEE80211_DTIM_UCAST 2
+#define IEEE80211_DTIM_VALID 1
+#define IEEE80211_DTIM_INVALID 0
+
+#define IEEE80211_PS_DISABLED 0
+#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
+#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
+
+//added by David for QoS 2006/6/30
+//#define WMM_Hang_8187
+#ifdef WMM_Hang_8187
+#undef WMM_Hang_8187
+#endif
+
+#define WME_AC_BK 0x00
+#define WME_AC_BE 0x01
+#define WME_AC_VI 0x02
+#define WME_AC_VO 0x03
+#define WME_ACI_MASK 0x03
+#define WME_AIFSN_MASK 0x03
+#define WME_AC_PRAM_LEN 16
+
+#define MAX_RECEIVE_BUFFER_SIZE 9100
+
+//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
+//#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
+#if 1
+#define UP2AC(up) ( \
+ ((up) < 1) ? WME_AC_BE : \
+ ((up) < 3) ? WME_AC_BK : \
+ ((up) < 4) ? WME_AC_BE : \
+ ((up) < 6) ? WME_AC_VI : \
+ WME_AC_VO)
+#endif
+//AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
+#define AC2UP(_ac) ( \
+ ((_ac) == WME_AC_VO) ? 6 : \
+ ((_ac) == WME_AC_VI) ? 5 : \
+ ((_ac) == WME_AC_BK) ? 1 : \
+ 0)
+
+#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
+#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/
+
+struct ether_header {
+ u8 ether_dhost[ETHER_ADDR_LEN];
+ u8 ether_shost[ETHER_ADDR_LEN];
+ u16 ether_type;
+} __attribute__((packed));
+
+#ifndef ETHERTYPE_PAE
+#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
+#endif
+#ifndef ETHERTYPE_IP
+#define ETHERTYPE_IP 0x0800 /* IP protocol */
+#endif
+
+typedef struct _bss_ht{
+
+ bool support_ht;
+
+ // HT related elements
+ u8 ht_cap_buf[32];
+ u16 ht_cap_len;
+ u8 ht_info_buf[32];
+ u16 ht_info_len;
+
+ HT_SPEC_VER ht_spec_ver;
+ //HT_CAPABILITY_ELE bdHTCapEle;
+ //HT_INFORMATION_ELE bdHTInfoEle;
+
+ bool aggregation;
+ bool long_slot_time;
+}bss_ht, *pbss_ht;
+
+typedef enum _erp_t{
+ ERP_NonERPpresent = 0x01,
+ ERP_UseProtection = 0x02,
+ ERP_BarkerPreambleMode = 0x04,
+} erp_t;
+
+
+struct ieee80211_network {
+ /* These entries are used to identify a unique network */
+ u8 bssid[ETH_ALEN];
+ u8 channel;
+ /* Ensure null-terminated for any debug msgs */
+ u8 ssid[IW_ESSID_MAX_SIZE + 1];
+ u8 ssid_len;
+#if 1
+ struct ieee80211_qos_data qos_data;
+#else
+ // Qos related. Added by Annie, 2005-11-01.
+ BSS_QOS BssQos;
+#endif
+
+ //added by amy for LEAP
+ bool bWithAironetIE;
+ bool bCkipSupported;
+ bool bCcxRmEnable;
+ u16 CcxRmState[2];
+ // CCXv4 S59, MBSSID.
+ bool bMBssidValid;
+ u8 MBssidMask;
+ u8 MBssid[6];
+ // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20.
+ bool bWithCcxVerNum;
+ u8 BssCcxVerNumber;
+ /* These are network statistics */
+ struct ieee80211_rx_stats stats;
+ u16 capability;
+ u8 rates[MAX_RATES_LENGTH];
+ u8 rates_len;
+ u8 rates_ex[MAX_RATES_EX_LENGTH];
+ u8 rates_ex_len;
+ unsigned long last_scanned;
+ u8 mode;
+ u32 flags;
+ u32 last_associate;
+ u32 time_stamp[2];
+ u16 beacon_interval;
+ u16 listen_interval;
+ u16 atim_window;
+ u8 erp_value;
+ u8 wpa_ie[MAX_WPA_IE_LEN];
+ size_t wpa_ie_len;
+ u8 rsn_ie[MAX_WPA_IE_LEN];
+ size_t rsn_ie_len;
+
+ struct ieee80211_tim_parameters tim;
+ u8 dtim_period;
+ u8 dtim_data;
+ u32 last_dtim_sta_time[2];
+
+ //appeded for QoS
+ u8 wmm_info;
+ struct ieee80211_wmm_ac_param wmm_param[4];
+ u8 QoS_Enable;
+#ifdef THOMAS_TURBO
+ u8 Turbo_Enable;//enable turbo mode, added by thomas
+#endif
+#ifdef ENABLE_DOT11D
+ u16 CountryIeLen;
+ u8 CountryIeBuf[MAX_IE_LEN];
+#endif
+ // HT Related, by amy, 2008.04.29
+ BSS_HT bssht;
+ // Add to handle broadcom AP management frame CCK rate.
+ bool broadcom_cap_exist;
+ bool realtek_cap_exit;
+ bool marvell_cap_exist;
+ bool ralink_cap_exist;
+ bool atheros_cap_exist;
+ bool cisco_cap_exist;
+ bool unknown_cap_exist;
+// u8 berp_info;
+ bool berp_info_valid;
+ bool buseprotection;
+ //put at the end of the structure.
+ struct list_head list;
+};
+
+#if 1
+enum ieee80211_state {
+
+ /* the card is not linked at all */
+ IEEE80211_NOLINK = 0,
+
+ /* IEEE80211_ASSOCIATING* are for BSS client mode
+ * the driver shall not perform RX filtering unless
+ * the state is LINKED.
+ * The driver shall just check for the state LINKED and
+ * defaults to NOLINK for ALL the other states (including
+ * LINKED_SCANNING)
+ */
+
+ /* the association procedure will start (wq scheduling)*/
+ IEEE80211_ASSOCIATING,
+ IEEE80211_ASSOCIATING_RETRY,
+
+ /* the association procedure is sending AUTH request*/
+ IEEE80211_ASSOCIATING_AUTHENTICATING,
+
+ /* the association procedure has successfully authentcated
+ * and is sending association request
+ */
+ IEEE80211_ASSOCIATING_AUTHENTICATED,
+
+ /* the link is ok. the card associated to a BSS or linked
+ * to a ibss cell or acting as an AP and creating the bss
+ */
+ IEEE80211_LINKED,
+
+ /* same as LINKED, but the driver shall apply RX filter
+ * rules as we are in NO_LINK mode. As the card is still
+ * logically linked, but it is doing a syncro site survey
+ * then it will be back to LINKED state.
+ */
+ IEEE80211_LINKED_SCANNING,
+
+};
+#else
+enum ieee80211_state {
+ IEEE80211_UNINITIALIZED = 0,
+ IEEE80211_INITIALIZED,
+ IEEE80211_ASSOCIATING,
+ IEEE80211_ASSOCIATED,
+ IEEE80211_AUTHENTICATING,
+ IEEE80211_AUTHENTICATED,
+ IEEE80211_SHUTDOWN
+};
+#endif
+
+#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
+#define DEFAULT_FTS 2346
+
+#define CFG_IEEE80211_RESERVE_FCS (1<<0)
+#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
+#define CFG_IEEE80211_RTS (1<<2)
+
+#define IEEE80211_24GHZ_MIN_CHANNEL 1
+#define IEEE80211_24GHZ_MAX_CHANNEL 14
+#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
+ IEEE80211_24GHZ_MIN_CHANNEL + 1)
+
+#define IEEE80211_52GHZ_MIN_CHANNEL 34
+#define IEEE80211_52GHZ_MAX_CHANNEL 165
+#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
+ IEEE80211_52GHZ_MIN_CHANNEL + 1)
+
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
+extern inline int is_multicast_ether_addr(const u8 *addr)
+{
+ return ((addr[0] != 0xff) && (0x01 & addr[0]));
+}
+#endif
+
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
+extern inline int is_broadcast_ether_addr(const u8 *addr)
+{
+ return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
+ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
+}
+#endif
+
+typedef struct tx_pending_t{
+ int frag;
+ struct ieee80211_txb *txb;
+}tx_pending_t;
+
+typedef struct _bandwidth_autoswitch
+{
+ long threshold_20Mhzto40Mhz;
+ long threshold_40Mhzto20Mhz;
+ bool bforced_tx20Mhz;
+ bool bautoswitch_enable;
+}bandwidth_autoswitch,*pbandwidth_autoswitch;
+
+
+//added by amy for order
+
+#define REORDER_WIN_SIZE 128
+#define REORDER_ENTRY_NUM 128
+typedef struct _RX_REORDER_ENTRY
+{
+ struct list_head List;
+ u16 SeqNum;
+ struct ieee80211_rxb* prxb;
+} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
+//added by amy for order
+typedef enum _Fsync_State{
+ Default_Fsync,
+ HW_Fsync,
+ SW_Fsync
+}Fsync_State;
+
+// Power save mode configured.
+typedef enum _RT_PS_MODE
+{
+ eActive, // Active/Continuous access.
+ eMaxPs, // Max power save mode.
+ eFastPs // Fast power save mode.
+}RT_PS_MODE;
+
+typedef enum _IPS_CALLBACK_FUNCION
+{
+ IPS_CALLBACK_NONE = 0,
+ IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
+ IPS_CALLBACK_JOIN_REQUEST = 2,
+}IPS_CALLBACK_FUNCION;
+
+typedef enum _RT_JOIN_ACTION{
+ RT_JOIN_INFRA = 1,
+ RT_JOIN_IBSS = 2,
+ RT_START_IBSS = 3,
+ RT_NO_ACTION = 4,
+}RT_JOIN_ACTION;
+
+typedef struct _IbssParms{
+ u16 atimWin;
+}IbssParms, *PIbssParms;
+#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko.
+
+// RF state.
+typedef enum _RT_RF_POWER_STATE
+{
+ eRfOn,
+ eRfSleep,
+ eRfOff
+}RT_RF_POWER_STATE;
+
+typedef struct _RT_POWER_SAVE_CONTROL
+{
+
+ //
+ // Inactive Power Save(IPS) : Disable RF when disconnected
+ //
+ bool bInactivePs;
+ bool bIPSModeBackup;
+ bool bHaltAdapterClkRQ;
+ bool bSwRfProcessing;
+ RT_RF_POWER_STATE eInactivePowerState;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct work_struct InactivePsWorkItem;
+#else
+ struct tq_struct InactivePsWorkItem;
+#endif
+ struct timer_list InactivePsTimer;
+
+ // Return point for join action
+ IPS_CALLBACK_FUNCION ReturnPoint;
+
+ // Recored Parameters for rescheduled JoinRequest
+ bool bTmpBssDesc;
+ RT_JOIN_ACTION tmpJoinAction;
+ struct ieee80211_network tmpBssDesc;
+
+ // Recored Parameters for rescheduled MgntLinkRequest
+ bool bTmpScanOnly;
+ bool bTmpActiveScan;
+ bool bTmpFilterHiddenAP;
+ bool bTmpUpdateParms;
+ u8 tmpSsidBuf[33];
+ OCTET_STRING tmpSsid2Scan;
+ bool bTmpSsid2Scan;
+ u8 tmpNetworkType;
+ u8 tmpChannelNumber;
+ u16 tmpBcnPeriod;
+ u8 tmpDtimPeriod;
+ u16 tmpmCap;
+ OCTET_STRING tmpSuppRateSet;
+ u8 tmpSuppRateBuf[MAX_NUM_RATES];
+ bool bTmpSuppRate;
+ IbssParms tmpIbpm;
+ bool bTmpIbpm;
+
+ //
+ // Leisre Poswer Save : Disable RF if connected but traffic is not busy
+ //
+ bool bLeisurePs;
+ u32 PowerProfile;
+ u8 LpsIdleCount;
+ u8 RegMaxLPSAwakeIntvl;
+ u8 LPSAwakeIntvl;
+
+ //RF OFF Level
+ u32 CurPsLevel;
+ u32 RegRfPsLevel;
+
+ //Fw Control LPS
+ bool bFwCtrlLPS;
+ u8 FWCtrlPSMode;
+
+ //2009.01.01 added by tynli
+ // Record if there is a link request in IPS RF off progress.
+ bool LinkReqInIPSRFOffPgs;
+ // To make sure that connect info should be executed, so we set the bit to filter the link info which comes after the connect info.
+ bool BufConnectinfoBefore;
+
+}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL;
+
+typedef u32 RT_RF_CHANGE_SOURCE;
+#define RF_CHANGE_BY_SW BIT31
+#define RF_CHANGE_BY_HW BIT30
+#define RF_CHANGE_BY_PS BIT29
+#define RF_CHANGE_BY_IPS BIT28
+#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17.
+
+#ifdef ENABLE_DOT11D
+typedef enum
+{
+ COUNTRY_CODE_FCC = 0,
+ COUNTRY_CODE_IC = 1,
+ COUNTRY_CODE_ETSI = 2,
+ COUNTRY_CODE_SPAIN = 3,
+ COUNTRY_CODE_FRANCE = 4,
+ COUNTRY_CODE_MKK = 5,
+ COUNTRY_CODE_MKK1 = 6,
+ COUNTRY_CODE_ISRAEL = 7,
+ COUNTRY_CODE_TELEC,
+ COUNTRY_CODE_MIC,
+ COUNTRY_CODE_GLOBAL_DOMAIN
+}country_code_type_t;
+#endif
+ // Firmware realted CMD IO.
+typedef enum _FW_CMD_IO_TYPE{
+ FW_CMD_DIG_ENABLE = 0, // For DIG DM
+ FW_CMD_DIG_DISABLE = 1,
+ FW_CMD_DIG_HALT = 2,
+ FW_CMD_DIG_RESUME = 3,
+ FW_CMD_HIGH_PWR_ENABLE = 4, // For High Power DM
+ FW_CMD_HIGH_PWR_DISABLE = 5,
+ FW_CMD_RA_RESET = 6, // For Rate adaptive DM
+ FW_CMD_RA_ACTIVE= 7,
+ FW_CMD_RA_REFRESH_N= 8,
+ FW_CMD_RA_REFRESH_BG= 9,
+ FW_CMD_IQK_ENABLE = 10, // For FW supported IQK
+ FW_CMD_TXPWR_TRACK_ENABLE = 11, // Tx power tracking switch
+ FW_CMD_TXPWR_TRACK_DISABLE = 12, // Tx power tracking switch
+ FW_CMD_PAUSE_DM_BY_SCAN = 13,
+ FW_CMD_RESUME_DM_BY_SCAN = 14,
+ FW_CMD_MID_HIGH_PWR_ENABLE = 15,
+ FW_CMD_LPS_ENTER = 16, // Indifate firmware that driver enters LPS, For PS-Poll hardware bug
+ FW_CMD_LPS_LEAVE = 17, // Indicate firmware that driver leave LPS, 2009/1/4, by Emily
+}FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE;
+#define RT_MAX_LD_SLOT_NUM 10
+typedef struct _RT_LINK_DETECT_T{
+
+ u32 NumRecvBcnInPeriod;
+ u32 NumRecvDataInPeriod;
+
+ u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; // number of Rx beacon / CheckForHang_period to determine link status
+ u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; // number of Rx data / CheckForHang_period to determine link status
+ u16 SlotNum; // number of CheckForHang period to determine link status
+ u16 SlotIndex;
+
+ u32 NumTxOkInPeriod;
+ u32 NumRxOkInPeriod;
+ bool bBusyTraffic;
+}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
+
+
+struct ieee80211_device {
+ struct net_device *dev;
+ struct ieee80211_security sec;
+
+ //hw security related
+// u8 hwsec_support; //support?
+ u8 hwsec_active; //hw security active.
+ bool is_silent_reset;
+ bool is_roaming;
+ bool ieee_up;
+ //added by amy
+ bool bSupportRemoteWakeUp;
+ RT_PS_MODE dot11PowerSaveMode; // Power save mode configured.
+ bool actscanning;
+ //added by amy 090313
+ bool be_scan_inprogress;
+ bool beinretry;
+ RT_RF_POWER_STATE eRFPowerState;
+ RT_RF_CHANGE_SOURCE RfOffReason;
+ bool is_set_key;
+ //11n spec related I wonder if These info structure need to be moved out of ieee80211_device
+
+ //11n HT below
+ PRT_HIGH_THROUGHPUT pHTInfo;
+ //struct timer_list SwBwTimer;
+// spinlock_t chnlop_spinlock;
+ spinlock_t bw_spinlock;
+
+ spinlock_t reorder_spinlock;
+ // for HT operation rate set. we use this one for HT data rate to seperate different descriptors
+ //the way fill this is the same as in the IE
+ u8 Regdot11HTOperationalRateSet[16]; //use RATR format
+ u8 dot11HTOperationalRateSet[16]; //use RATR format
+ u8 RegHTSuppRateSet[16];
+ u8 HTCurrentOperaRate;
+ u8 HTHighestOperaRate;
+ //wb added for rate operation mode to firmware
+ u8 bTxDisableRateFallBack;
+ u8 bTxUseDriverAssingedRate;
+ atomic_t atm_chnlop;
+ atomic_t atm_swbw;
+// u8 HTHighestOperaRate;
+// u8 HTCurrentOperaRate;
+
+ // 802.11e and WMM Traffic Stream Info (TX)
+ struct list_head Tx_TS_Admit_List;
+ struct list_head Tx_TS_Pending_List;
+ struct list_head Tx_TS_Unused_List;
+ TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
+ // 802.11e and WMM Traffic Stream Info (RX)
+ struct list_head Rx_TS_Admit_List;
+ struct list_head Rx_TS_Pending_List;
+ struct list_head Rx_TS_Unused_List;
+ RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
+//#ifdef TO_DO_LIST
+ RX_REORDER_ENTRY RxReorderEntry[128];
+ struct list_head RxReorder_Unused_List;
+//#endif
+ // Qos related. Added by Annie, 2005-11-01.
+// PSTA_QOS pStaQos;
+ u8 ForcedPriority; // Force per-packet priority 1~7. (default: 0, not to force it.)
+
+
+ /* Bookkeeping structures */
+ struct net_device_stats stats;
+ struct ieee80211_stats ieee_stats;
+ struct ieee80211_softmac_stats softmac_stats;
+
+ /* Probe / Beacon management */
+ struct list_head network_free_list;
+ struct list_head network_list;
+ struct ieee80211_network *networks;
+ int scans;
+ int scan_age;
+
+ int iw_mode; /* operating mode (IW_MODE_*) */
+ struct iw_spy_data spy_data;
+
+ spinlock_t lock;
+ spinlock_t wpax_suitlist_lock;
+
+ int tx_headroom; /* Set to size of any additional room needed at front
+ * of allocated Tx SKBs */
+ u32 config;
+
+ /* WEP and other encryption related settings at the device level */
+ int open_wep; /* Set to 1 to allow unencrypted frames */
+ int auth_mode;
+ int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
+ * WEP key changes */
+
+ /* If the host performs {en,de}cryption, then set to 1 */
+ int host_encrypt;
+ int host_encrypt_msdu;
+ int host_decrypt;
+ /* host performs multicast decryption */
+ int host_mc_decrypt;
+
+ /* host should strip IV and ICV from protected frames */
+ /* meaningful only when hardware decryption is being used */
+ int host_strip_iv_icv;
+
+ int host_open_frag;
+ int host_build_iv;
+ int ieee802_1x; /* is IEEE 802.1X used */
+
+ /* WPA data */
+ bool bHalfWirelessN24GMode;
+ int wpa_enabled;
+ int drop_unencrypted;
+ int tkip_countermeasures;
+ int privacy_invoked;
+ size_t wpa_ie_len;
+ u8 *wpa_ie;
+ u8 ap_mac_addr[6];
+ u16 pairwise_key_type;
+ u16 group_key_type;
+ struct list_head crypt_deinit_list;
+ struct ieee80211_crypt_data *crypt[WEP_KEYS];
+ int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
+ struct timer_list crypt_deinit_timer;
+ int crypt_quiesced;
+
+ int bcrx_sta_key; /* use individual keys to override default keys even
+ * with RX of broad/multicast frames */
+
+ /* Fragmentation structures */
+ // each streaming contain a entry
+ struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
+ unsigned int frag_next_idx[17];
+ u16 fts; /* Fragmentation Threshold */
+#define DEFAULT_RTS_THRESHOLD 2346U
+#define MIN_RTS_THRESHOLD 1
+#define MAX_RTS_THRESHOLD 2346U
+ u16 rts; /* RTS threshold */
+
+ /* Association info */
+ u8 bssid[ETH_ALEN];
+
+ /* This stores infos for the current network.
+ * Either the network we are associated in INFRASTRUCTURE
+ * or the network that we are creating in MASTER mode.
+ * ad-hoc is a mixture ;-).
+ * Note that in infrastructure mode, even when not associated,
+ * fields bssid and essid may be valid (if wpa_set and essid_set
+ * are true) as thy carry the value set by the user via iwconfig
+ */
+ struct ieee80211_network current_network;
+
+ enum ieee80211_state state;
+
+ int short_slot;
+ int reg_mode;
+ int mode; /* A, B, G */
+ int modulation; /* CCK, OFDM */
+ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
+ int abg_true; /* ABG flag */
+
+ /* used for forcing the ibss workqueue to terminate
+ * without wait for the syncro scan to terminate
+ */
+ short sync_scan_hurryup;
+ u16 scan_watch_dog;
+ int perfect_rssi;
+ int worst_rssi;
+
+ u16 prev_seq_ctl; /* used to drop duplicate frames */
+
+ /* map of allowed channels. 0 is dummy */
+ // FIXME: remeber to default to a basic channel plan depending of the PHY type
+#ifdef ENABLE_DOT11D
+ void* pDot11dInfo;
+ bool bGlobalDomain;
+#else
+ int channel_map[MAX_CHANNEL_NUMBER+1];
+#endif
+ int rate; /* current rate */
+ int basic_rate;
+ //FIXME: pleace callback, see if redundant with softmac_features
+ short active_scan;
+
+ /* this contains flags for selectively enable softmac support */
+ u16 softmac_features;
+
+ /* if the sequence control field is not filled by HW */
+ u16 seq_ctrl[5];
+
+ /* association procedure transaction sequence number */
+ u16 associate_seq;
+
+ /* AID for RTXed association responses */
+ u16 assoc_id;
+
+ /* power save mode related*/
+ u8 ack_tx_to_ieee;
+ short ps;
+ short sta_sleep;
+ int ps_timeout;
+ int ps_period;
+ struct tasklet_struct ps_task;
+ u32 ps_th;
+ u32 ps_tl;
+
+ short raw_tx;
+ /* used if IEEE_SOFTMAC_TX_QUEUE is set */
+ short queue_stop;
+ short scanning;
+ short proto_started;
+
+ struct semaphore wx_sem;
+ struct semaphore scan_sem;
+
+ spinlock_t mgmt_tx_lock;
+ spinlock_t beacon_lock;
+
+ short beacon_txing;
+
+ short wap_set;
+ short ssid_set;
+
+ u8 wpax_type_set; //{added by David, 2006.9.28}
+ u32 wpax_type_notify; //{added by David, 2006.9.26}
+
+ /* QoS related flag */
+ char init_wmmparam_flag;
+ /* set on initialization */
+ u8 qos_support;
+
+ /* for discarding duplicated packets in IBSS */
+ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
+
+ /* for discarding duplicated packets in BSS */
+ u16 last_rxseq_num[17]; /* rx seq previous per-tid */
+ u16 last_rxfrag_num[17];/* tx frag previous per-tid */
+ unsigned long last_packet_time[17];
+
+ /* for PS mode */
+ unsigned long last_rx_ps_time;
+
+ /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
+ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
+ int mgmt_queue_head;
+ int mgmt_queue_tail;
+//{ added for rtl819x
+#define IEEE80211_QUEUE_LIMIT 128
+ u8 AsocRetryCount;
+ unsigned int hw_header;
+ struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
+ struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
+ struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
+ u32 sta_edca_param[4];
+ bool aggregation;
+ // Enable/Disable Rx immediate BA capability.
+ bool enable_rx_imm_BA;
+ bool bibsscoordinator;
+
+ //+by amy for DM ,080515
+ //Dynamic Tx power for near/far range enable/Disable , by amy , 2008-05-15
+ bool bdynamic_txpower_enable;
+
+ bool bCTSToSelfEnable;
+ u8 CTSToSelfTH;
+
+ u32 fsync_time_interval;
+ u32 fsync_rate_bitmap;
+ u8 fsync_rssi_threshold;
+ bool bfsync_enable;
+
+ u8 fsync_multiple_timeinterval; // FsyncMultipleTimeInterval * FsyncTimeInterval
+ u32 fsync_firstdiff_ratethreshold; // low threshold
+ u32 fsync_seconddiff_ratethreshold; // decrease threshold
+ Fsync_State fsync_state;
+ bool bis_any_nonbepkts;
+ //20Mhz 40Mhz AutoSwitch Threshold
+ bandwidth_autoswitch bandwidth_auto_switch;
+ //for txpower tracking
+ bool FwRWRF;
+
+ //added by amy for AP roaming
+ RT_LINK_DETECT_T LinkDetectInfo;
+ //added by amy for ps
+ RT_POWER_SAVE_CONTROL PowerSaveControl;
+//}
+ /* used if IEEE_SOFTMAC_TX_QUEUE is set */
+ struct tx_pending_t tx_pending;
+
+ /* used if IEEE_SOFTMAC_ASSOCIATE is set */
+ struct timer_list associate_timer;
+
+ /* used if IEEE_SOFTMAC_BEACONS is set */
+ struct timer_list beacon_timer;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct work_struct associate_complete_wq;
+ struct work_struct associate_procedure_wq;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ struct delayed_work softmac_scan_wq;
+ struct delayed_work associate_retry_wq;
+ struct delayed_work start_ibss_wq;
+ struct delayed_work hw_wakeup_wq;
+ struct delayed_work hw_sleep_wq;
+ struct delayed_work link_change_wq;
+#else
+ struct work_struct softmac_scan_wq;
+ struct work_struct associate_retry_wq;
+ struct work_struct start_ibss_wq;
+ struct work_struct hw_wakeup_wq;
+ struct work_struct hw_sleep_wq;
+ struct work_struct link_change_wq;
+#endif
+ struct work_struct wx_sync_scan_wq;
+ struct workqueue_struct *wq;
+#else
+ /* used for periodly scan */
+ struct timer_list scan_timer;
+
+ struct tq_struct associate_complete_wq;
+ struct tq_struct associate_retry_wq;
+ struct tq_struct start_ibss_wq;
+ struct tq_struct associate_procedure_wq;
+ struct tq_struct softmac_scan_wq;
+ struct tq_struct wx_sync_scan_wq;
+ struct tq_struct hw_wakeup_wq;
+ struct tq_struct hw_sleep_wq;
+ struct tq_struct link_change_wq;
+
+#endif
+ // Qos related. Added by Annie, 2005-11-01.
+ //STA_QOS StaQos;
+
+ //u32 STA_EDCA_PARAM[4];
+ //CHANNEL_ACCESS_SETTING ChannelAccessSetting;
+
+
+ /* Callback functions */
+ void (*set_security)(struct net_device *dev,
+ struct ieee80211_security *sec);
+
+ /* Used to TX data frame by using txb structs.
+ * this is not used if in the softmac_features
+ * is set the flag IEEE_SOFTMAC_TX_QUEUE
+ */
+ int (*hard_start_xmit)(struct ieee80211_txb *txb,
+ struct net_device *dev);
+
+ int (*reset_port)(struct net_device *dev);
+ int (*is_queue_full) (struct net_device * dev, int pri);
+
+ int (*handle_management) (struct net_device * dev,
+ struct ieee80211_network * network, u16 type);
+ int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
+
+ /* Softmac-generated frames (mamagement) are TXed via this
+ * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
+ * not set. As some cards may have different HW queues that
+ * one might want to use for data and management frames
+ * the option to have two callbacks might be useful.
+ * This fucntion can't sleep.
+ */
+ int (*softmac_hard_start_xmit)(struct sk_buff *skb,
+ struct net_device *dev);
+
+ /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
+ * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
+ * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
+ * then also management frames are sent via this callback.
+ * This function can't sleep.
+ */
+ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
+ struct net_device *dev,int rate);
+
+ /* stops the HW queue for DATA frames. Useful to avoid
+ * waste time to TX data frame when we are reassociating
+ * This function can sleep.
+ */
+ void (*data_hard_stop)(struct net_device *dev);
+
+ /* OK this is complementar to data_poll_hard_stop */
+ void (*data_hard_resume)(struct net_device *dev);
+
+ /* ask to the driver to retune the radio .
+ * This function can sleep. the driver should ensure
+ * the radio has been swithced before return.
+ */
+ void (*set_chan)(struct net_device *dev,short ch);
+
+ /* These are not used if the ieee stack takes care of
+ * scanning (IEEE_SOFTMAC_SCAN feature set).
+ * In this case only the set_chan is used.
+ *
+ * The syncro version is similar to the start_scan but
+ * does not return until all channels has been scanned.
+ * this is called in user context and should sleep,
+ * it is called in a work_queue when swithcing to ad-hoc mode
+ * or in behalf of iwlist scan when the card is associated
+ * and root user ask for a scan.
+ * the fucntion stop_scan should stop both the syncro and
+ * background scanning and can sleep.
+ * The fucntion start_scan should initiate the background
+ * scanning and can't sleep.
+ */
+ void (*scan_syncro)(struct net_device *dev);
+ void (*start_scan)(struct net_device *dev);
+ void (*stop_scan)(struct net_device *dev);
+
+ /* indicate the driver that the link state is changed
+ * for example it may indicate the card is associated now.
+ * Driver might be interested in this to apply RX filter
+ * rules or simply light the LINK led
+ */
+ void (*link_change)(struct net_device *dev);
+
+ /* these two function indicates to the HW when to start
+ * and stop to send beacons. This is used when the
+ * IEEE_SOFTMAC_BEACONS is not set. For now the
+ * stop_send_bacons is NOT guaranteed to be called only
+ * after start_send_beacons.
+ */
+ void (*start_send_beacons) (struct net_device *dev);
+ void (*stop_send_beacons) (struct net_device *dev);
+
+ /* power save mode related */
+ void (*sta_wake_up) (struct net_device *dev);
+// void (*ps_request_tx_ack) (struct net_device *dev);
+ void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
+ short (*ps_is_queue_empty) (struct net_device *dev);
+#if 0
+ /* Typical STA methods */
+ int (*handle_auth) (struct net_device * dev,
+ struct ieee80211_auth * auth);
+ int (*handle_deauth) (struct net_device * dev,
+ struct ieee80211_deauth * auth);
+ int (*handle_action) (struct net_device * dev,
+ struct ieee80211_action * action,
+ struct ieee80211_rx_stats * stats);
+ int (*handle_disassoc) (struct net_device * dev,
+ struct ieee80211_disassoc * assoc);
+#endif
+ int (*handle_beacon) (struct net_device * dev, struct ieee80211_beacon * beacon, struct ieee80211_network * network);
+#if 0
+ int (*handle_probe_response) (struct net_device * dev,
+ struct ieee80211_probe_response * resp,
+ struct ieee80211_network * network);
+ int (*handle_probe_request) (struct net_device * dev,
+ struct ieee80211_probe_request * req,
+ struct ieee80211_rx_stats * stats);
+#endif
+ int (*handle_assoc_response) (struct net_device * dev, struct ieee80211_assoc_response_frame * resp, struct ieee80211_network * network);
+
+#if 0
+ /* Typical AP methods */
+ int (*handle_assoc_request) (struct net_device * dev);
+ int (*handle_reassoc_request) (struct net_device * dev,
+ struct ieee80211_reassoc_request * req);
+#endif
+
+ /* check whether Tx hw resouce available */
+ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
+ //added by wb for HT related
+// void (*SwChnlByTimerHandler)(struct net_device *dev, int channel);
+ void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
+// void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate);
+ bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
+ void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
+ bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
+ bool (*is_ap_in_wep_tkip)(struct net_device* dev);
+ void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
+ bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO);
+ void (*LedControlHandler)(struct net_device * dev, LED_CTL_MODE LedAction);
+ /* This must be the last item so that it points to the data
+ * allocated beyond this structure by alloc_ieee80211 */
+ u8 priv[0];
+};
+
+#define IEEE_A (1<<0)
+#define IEEE_B (1<<1)
+#define IEEE_G (1<<2)
+#define IEEE_N_24G (1<<4)
+#define IEEE_N_5G (1<<5)
+#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
+
+/* Generate a 802.11 header */
+
+/* Uses the channel change callback directly
+ * instead of [start/stop] scan callbacks
+ */
+#define IEEE_SOFTMAC_SCAN (1<<2)
+
+/* Perform authentication and association handshake */
+#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
+
+/* Generate probe requests */
+#define IEEE_SOFTMAC_PROBERQ (1<<4)
+
+/* Generate respones to probe requests */
+#define IEEE_SOFTMAC_PROBERS (1<<5)
+
+/* The ieee802.11 stack will manages the netif queue
+ * wake/stop for the driver, taking care of 802.11
+ * fragmentation. See softmac.c for details. */
+#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
+
+/* Uses only the softmac_data_hard_start_xmit
+ * even for TX management frames.
+ */
+#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
+
+/* Generate beacons. The stack will enqueue beacons
+ * to the card
+ */
+#define IEEE_SOFTMAC_BEACONS (1<<6)
+
+static inline void *ieee80211_priv(struct net_device *dev)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ return ((struct ieee80211_device *)netdev_priv(dev))->priv;
+#else
+ return ((struct ieee80211_device *)dev->priv)->priv;
+#endif
+}
+
+extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+{
+ /* Single white space is for Linksys APs */
+ if (essid_len == 1 && essid[0] == ' ')
+ return 1;
+
+ /* Otherwise, if the entire essid is 0, we assume it is hidden */
+ while (essid_len) {
+ essid_len--;
+ if (essid[essid_len] != '\0')
+ return 0;
+ }
+
+ return 1;
+}
+
+extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
+{
+ /*
+ * It is possible for both access points and our device to support
+ * combinations of modes, so as long as there is one valid combination
+ * of ap/device supported modes, then return success
+ *
+ */
+ if ((mode & IEEE_A) &&
+ (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
+ (ieee->freq_band & IEEE80211_52GHZ_BAND))
+ return 1;
+
+ if ((mode & IEEE_G) &&
+ (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
+ (ieee->freq_band & IEEE80211_24GHZ_BAND))
+ return 1;
+
+ if ((mode & IEEE_B) &&
+ (ieee->modulation & IEEE80211_CCK_MODULATION) &&
+ (ieee->freq_band & IEEE80211_24GHZ_BAND))
+ return 1;
+
+ return 0;
+}
+
+extern inline int ieee80211_get_hdrlen(u16 fc)
+{
+ int hdrlen = IEEE80211_3ADDR_LEN;
+
+ switch (WLAN_FC_GET_TYPE(fc)) {
+ case IEEE80211_FTYPE_DATA:
+ if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
+ hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
+ if(IEEE80211_QOS_HAS_SEQ(fc))
+ hdrlen += 2; /* QOS ctrl*/
+ break;
+ case IEEE80211_FTYPE_CTL:
+ switch (WLAN_FC_GET_STYPE(fc)) {
+ case IEEE80211_STYPE_CTS:
+ case IEEE80211_STYPE_ACK:
+ hdrlen = IEEE80211_1ADDR_LEN;
+ break;
+ default:
+ hdrlen = IEEE80211_2ADDR_LEN;
+ break;
+ }
+ break;
+ }
+
+ return hdrlen;
+}
+
+static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
+{
+ switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
+ case IEEE80211_1ADDR_LEN:
+ return ((struct ieee80211_hdr_1addr *)hdr)->payload;
+ case IEEE80211_2ADDR_LEN:
+ return ((struct ieee80211_hdr_2addr *)hdr)->payload;
+ case IEEE80211_3ADDR_LEN:
+ return ((struct ieee80211_hdr_3addr *)hdr)->payload;
+ case IEEE80211_4ADDR_LEN:
+ return ((struct ieee80211_hdr_4addr *)hdr)->payload;
+ }
+ return NULL;
+}
+
+static inline int ieee80211_is_ofdm_rate(u8 rate)
+{
+ switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
+ case IEEE80211_OFDM_RATE_6MB:
+ case IEEE80211_OFDM_RATE_9MB:
+ case IEEE80211_OFDM_RATE_12MB:
+ case IEEE80211_OFDM_RATE_18MB:
+ case IEEE80211_OFDM_RATE_24MB:
+ case IEEE80211_OFDM_RATE_36MB:
+ case IEEE80211_OFDM_RATE_48MB:
+ case IEEE80211_OFDM_RATE_54MB:
+ return 1;
+ }
+ return 0;
+}
+
+static inline int ieee80211_is_cck_rate(u8 rate)
+{
+ switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
+ case IEEE80211_CCK_RATE_1MB:
+ case IEEE80211_CCK_RATE_2MB:
+ case IEEE80211_CCK_RATE_5MB:
+ case IEEE80211_CCK_RATE_11MB:
+ return 1;
+ }
+ return 0;
+}
+
+
+/* ieee80211.c */
+extern void free_ieee80211(struct net_device *dev);
+extern struct net_device *alloc_ieee80211(int sizeof_priv);
+
+extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
+
+/* ieee80211_tx.c */
+
+extern int ieee80211_encrypt_fragment(
+ struct ieee80211_device *ieee,
+ struct sk_buff *frag,
+ int hdr_len);
+
+extern int ieee80211_xmit(struct sk_buff *skb,
+ struct net_device *dev);
+extern void ieee80211_txb_free(struct ieee80211_txb *);
+
+
+/* ieee80211_rx.c */
+extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats);
+extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
+ struct ieee80211_hdr_4addr *header,
+ struct ieee80211_rx_stats *stats);
+
+/* ieee80211_wx.c */
+extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key);
+extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key);
+extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key);
+#if WIRELESS_EXT >= 18
+extern int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data* wrqu, char *extra);
+extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data* wrqu, char *extra);
+extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ struct iw_param *data, char *extra);
+extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+#endif
+extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
+
+/* ieee80211_softmac.c */
+extern short ieee80211_is_54g(struct ieee80211_network net);
+extern short ieee80211_is_shortslot(struct ieee80211_network net);
+extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats, u16 type,
+ u16 stype);
+extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
+
+void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
+extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
+
+extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
+extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
+extern void ieee80211_start_bss(struct ieee80211_device *ieee);
+extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
+extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
+extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
+extern void ieee80211_disassociate(struct ieee80211_device *ieee);
+extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
+extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
+extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
+extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
+extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
+extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
+extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
+extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
+extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
+extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
+extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
+extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
+
+extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
+
+/* ieee80211_crypt_ccmp&tkip&wep.c */
+extern void ieee80211_tkip_null(void);
+extern void ieee80211_wep_null(void);
+extern void ieee80211_ccmp_null(void);
+
+/* ieee80211_softmac_wx.c */
+
+extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *ext);
+
+extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra);
+
+extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
+
+extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+//extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
+#else
+ extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
+#endif
+
+
+extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+//HT
+#define MAX_RECEIVE_BUFFER_SIZE 9100 //
+extern void HTDebugHTCapability(u8* CapIE, u8* TitleString );
+extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString);
+
+void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
+extern void HTUpdateDefaultSetting(struct ieee80211_device* ieee);
+extern void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt);
+extern void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt);
+extern void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len);
+extern void HTOnAssocRsp(struct ieee80211_device *ieee);
+extern void HTInitializeHTInfo(struct ieee80211_device* ieee);
+extern void HTInitializeBssDesc(PBSS_HT pBssHT);
+extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
+extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
+extern u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter);
+extern u8 MCS_FILTER_ALL[];
+extern u16 MCS_DATA_RATE[2][2][77] ;
+extern u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame);
+//extern void HTSetConnectBwModeCallback(unsigned long data);
+extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
+extern bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee);
+extern u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate);
+extern u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate);
+extern u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate);
+//function in BAPROC.c
+extern int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb);
+extern int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb);
+extern int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb);
+extern void TsInitAddBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending);
+extern void TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
+extern void BaSetupTimeOut(unsigned long data);
+extern void TxBaInactTimeout(unsigned long data);
+extern void RxBaInactTimeout(unsigned long data);
+extern void ResetBaEntry( PBA_RECORD pBA);
+//function in TS.c
+extern bool GetTs(
+ struct ieee80211_device* ieee,
+ PTS_COMMON_INFO *ppTS,
+ u8* Addr,
+ u8 TID,
+ TR_SELECT TxRxSelect, //Rx:1, Tx:0
+ bool bAddNewTs
+ );
+extern void TSInitialize(struct ieee80211_device *ieee);
+extern void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS);
+extern void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr);
+extern void RemoveAllTS(struct ieee80211_device* ieee);
+void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
+
+extern const long ieee80211_wlan_frequencies[];
+
+extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
+{
+ ieee->scans++;
+}
+
+extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
+{
+ return ieee->scans;
+}
+
+static inline const char *escape_essid(const char *essid, u8 essid_len) {
+ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
+ const char *s = essid;
+ char *d = escaped;
+
+ if (ieee80211_is_empty_essid(essid, essid_len)) {
+ memcpy(escaped, "<hidden>", sizeof("<hidden>"));
+ return escaped;
+ }
+
+ essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
+ while (essid_len--) {
+ if (*s == '\0') {
+ *d++ = '\\';
+ *d++ = '0';
+ s++;
+ } else {
+ *d++ = *s++;
+ }
+ }
+ *d = '\0';
+ return escaped;
+}
+
+/* For the function is more related to hardware setting, it's better to use the
+ * ieee handler to refer to it.
+ */
+extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
+extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
+extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
+ struct ieee80211_info_element *info_element,
+ u16 length,
+ struct ieee80211_network *network,
+ struct ieee80211_rx_stats *stats);
+
+void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index);
+#define RT_ASOC_RETRY_LIMIT 5
+#endif /* IEEE80211_H */
diff --git a/drivers/staging/rtl8192su/ieee80211/EndianFree.h b/drivers/staging/rtl8192su/ieee80211/EndianFree.h
new file mode 100644
index 000000000000..0c417a6234a9
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/EndianFree.h
@@ -0,0 +1,199 @@
+#ifndef __INC_ENDIANFREE_H
+#define __INC_ENDIANFREE_H
+
+/*
+ * Call endian free function when
+ * 1. Read/write packet content.
+ * 2. Before write integer to IO.
+ * 3. After read integer from IO.
+ */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+#ifndef bool
+typedef enum{false = 0, true} bool;
+#endif
+#endif
+
+#define __MACHINE_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
+#define __MACHINE_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net, ppc */
+
+#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN
+
+#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
+// Convert data
+#define EF1Byte(_val) ((u8)(_val))
+#define EF2Byte(_val) ((u16)(_val))
+#define EF4Byte(_val) ((u32)(_val))
+
+#else
+// Convert data
+#define EF1Byte(_val) ((u8)(_val))
+#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8))
+#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\
+ ((((u32)(_val))&0x0000ff00)<<8)|\
+ ((((u32)(_val))&0x00ff0000)>>8)|\
+ ((((u32)(_val))&0xff000000)>>24))
+#endif
+
+// Read data from memory
+#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr)))
+#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr)))
+#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr)))
+
+// Write data to memory
+#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val)
+#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val)
+#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val)
+// Convert Host system specific byte ording (litten or big endia) to Network byte ording (big endian).
+// 2006.05.07, by rcnjko.
+#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
+#define H2N1BYTE(_val) ((u8)(_val))
+#define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
+ ((((u16)(_val))&0xff00)>>8))
+#define H2N4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
+ ((((u32)(_val))&0x0000ff00)<<8) |\
+ ((((u32)(_val))&0x00ff0000)>>8) |\
+ ((((u32)(_val))&0xff000000)>>24))
+#else
+#define H2N1BYTE(_val) ((u8)(_val))
+#define H2N2BYTE(_val) ((u16)(_val))
+#define H2N4BYTE(_val) ((u32)(_val))
+#endif
+
+// Convert from Network byte ording (big endian) to Host system specific byte ording (litten or big endia).
+// 2006.05.07, by rcnjko.
+#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
+#define N2H1BYTE(_val) ((u8)(_val))
+#define N2H2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
+ ((((u16)(_val))&0xff00)>>8))
+#define N2H4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
+ ((((u32)(_val))&0x0000ff00)<<8) |\
+ ((((u32)(_val))&0x00ff0000)>>8) |\
+ ((((u32)(_val))&0xff000000)>>24))
+#else
+#define N2H1BYTE(_val) ((u8)(_val))
+#define N2H2BYTE(_val) ((u16)(_val))
+#define N2H4BYTE(_val) ((u32)(_val))
+#endif
+
+//
+// Example:
+// BIT_LEN_MASK_32(0) => 0x00000000
+// BIT_LEN_MASK_32(1) => 0x00000001
+// BIT_LEN_MASK_32(2) => 0x00000003
+// BIT_LEN_MASK_32(32) => 0xFFFFFFFF
+//
+#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen)))
+//
+// Example:
+// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
+// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
+//
+#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
+
+//
+// Description:
+// Return 4-byte value in host byte ordering from
+// 4-byte pointer in litten-endian system.
+//
+#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart))))
+
+//
+// Description:
+// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to
+// 4-byte value in host byte ordering.
+//
+#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
+ ( \
+ ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
+ & \
+ BIT_LEN_MASK_32(__BitLen) \
+ )
+
+//
+// Description:
+// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering
+// and return the result in 4-byte value in host byte ordering.
+//
+#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
+ ( \
+ LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
+ & \
+ ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
+ )
+
+//
+// Description:
+// Set subfield of little-endian 4-byte value to specified value.
+//
+#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
+ *((u32 *)(__pStart)) = \
+ EF4Byte( \
+ LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
+ | \
+ ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
+ );
+
+
+#define BIT_LEN_MASK_16(__BitLen) \
+ (0xFFFF >> (16 - (__BitLen)))
+
+#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
+ (BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
+
+#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
+ (EF2Byte(*((u16 *)(__pStart))))
+
+#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
+ ( \
+ ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
+ & \
+ BIT_LEN_MASK_16(__BitLen) \
+ )
+
+#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
+ ( \
+ LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
+ & \
+ ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
+ )
+
+#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
+ *((u16 *)(__pStart)) = \
+ EF2Byte( \
+ LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
+ | \
+ ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
+ );
+
+#define BIT_LEN_MASK_8(__BitLen) \
+ (0xFF >> (8 - (__BitLen)))
+
+#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
+ (BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
+
+#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
+ (EF1Byte(*((u8 *)(__pStart))))
+
+#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
+ ( \
+ ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
+ & \
+ BIT_LEN_MASK_8(__BitLen) \
+ )
+
+#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
+ ( \
+ LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
+ & \
+ ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
+ )
+
+#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
+ *((u8 *)(__pStart)) = \
+ EF1Byte( \
+ LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
+ | \
+ ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
+ );
+
+#endif // #ifndef __INC_ENDIANFREE_H
diff --git a/drivers/staging/rtl8192su/ieee80211/Makefile b/drivers/staging/rtl8192su/ieee80211/Makefile
new file mode 100644
index 000000000000..295a18f3c9ca
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/Makefile
@@ -0,0 +1,31 @@
+NIC_SELECT = RTL8192SU
+
+EXTRA_CFLAGS += -O2
+EXTRA_CFLAGS += -DRTL8192S_DISABLE_FW_DM=0
+EXTRA_CFLAGS += -DRTL8192SU
+#EXTRA_CFLAGS += -DJOHN_NOCPY
+EXTRA_CFLAGS += -DTHOMAS_TURBO
+#flags to enable or disble 80211D feature
+EXTRA_CFLAGS += -DENABLE_DOT11D
+ieee80211-rsl-objs := ieee80211_rx.o \
+ ieee80211_softmac.o \
+ ieee80211_tx.o \
+ ieee80211_wx.o \
+ ieee80211_module.o \
+ ieee80211_softmac_wx.o\
+ rtl819x_HTProc.o\
+ rtl819x_TSProc.o\
+ rtl819x_BAProc.o\
+ dot11d.o
+
+ieee80211_crypt-rsl-objs := ieee80211_crypt.o
+ieee80211_crypt_tkip-rsl-objs := ieee80211_crypt_tkip.o
+ieee80211_crypt_ccmp-rsl-objs := ieee80211_crypt_ccmp.o
+ieee80211_crypt_wep-rsl-objs := ieee80211_crypt_wep.o
+
+obj-m +=ieee80211-rsl.o
+obj-m +=ieee80211_crypt-rsl.o
+obj-m +=ieee80211_crypt_wep-rsl.o
+obj-m +=ieee80211_crypt_tkip-rsl.o
+obj-m +=ieee80211_crypt_ccmp-rsl.o
+
diff --git a/drivers/staging/rtl8192su/ieee80211/aes.c b/drivers/staging/rtl8192su/ieee80211/aes.c
new file mode 100644
index 000000000000..0c176e29a797
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/aes.c
@@ -0,0 +1,469 @@
+/*
+ * Cryptographic API.
+ *
+ * AES Cipher Algorithm.
+ *
+ * Based on Brian Gladman's code.
+ *
+ * Linux developers:
+ * Alexander Kjeldaas <astor@fast.no>
+ * Herbert Valerio Riedel <hvr@hvrlab.org>
+ * Kyle McMartin <kyle@debian.org>
+ * Adam J. Richter <adam@yggdrasil.com> (conversion to 2.5 API).
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ---------------------------------------------------------------------------
+ * Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
+ * All rights reserved.
+ *
+ * LICENSE TERMS
+ *
+ * The free distribution and use of this software in both source and binary
+ * form is allowed (with or without changes) provided that:
+ *
+ * 1. distributions of this source code include the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ *
+ * 2. distributions in binary form include the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other associated materials;
+ *
+ * 3. the copyright holder's name is not used to endorse products
+ * built using this software without specific written permission.
+ *
+ * ALTERNATIVELY, provided that this notice is retained in full, this product
+ * may be distributed under the terms of the GNU General Public License (GPL),
+ * in which case the provisions of the GPL apply INSTEAD OF those given above.
+ *
+ * DISCLAIMER
+ *
+ * This software is provided 'as is' with no explicit or implied warranties
+ * in respect of its properties, including, but not limited to, correctness
+ * and/or fitness for purpose.
+ * ---------------------------------------------------------------------------
+ */
+
+/* Some changes from the Gladman version:
+ s/RIJNDAEL(e_key)/E_KEY/g
+ s/RIJNDAEL(d_key)/D_KEY/g
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <asm/byteorder.h>
+
+#define AES_MIN_KEY_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+
+#define AES_BLOCK_SIZE 16
+
+static inline
+u32 generic_rotr32 (const u32 x, const unsigned bits)
+{
+ const unsigned n = bits % 32;
+ return (x >> n) | (x << (32 - n));
+}
+
+static inline
+u32 generic_rotl32 (const u32 x, const unsigned bits)
+{
+ const unsigned n = bits % 32;
+ return (x << n) | (x >> (32 - n));
+}
+
+#define rotl generic_rotl32
+#define rotr generic_rotr32
+
+/*
+ * #define byte(x, nr) ((unsigned char)((x) >> (nr*8)))
+ */
+inline static u8
+byte(const u32 x, const unsigned n)
+{
+ return x >> (n << 3);
+}
+
+#define u32_in(x) le32_to_cpu(*(const u32 *)(x))
+#define u32_out(to, from) (*(u32 *)(to) = cpu_to_le32(from))
+
+struct aes_ctx {
+ int key_length;
+ u32 E[60];
+ u32 D[60];
+};
+
+#define E_KEY ctx->E
+#define D_KEY ctx->D
+
+static u8 pow_tab[256] __initdata;
+static u8 log_tab[256] __initdata;
+static u8 sbx_tab[256] __initdata;
+static u8 isb_tab[256] __initdata;
+static u32 rco_tab[10];
+static u32 ft_tab[4][256];
+static u32 it_tab[4][256];
+
+static u32 fl_tab[4][256];
+static u32 il_tab[4][256];
+
+static inline u8 __init
+f_mult (u8 a, u8 b)
+{
+ u8 aa = log_tab[a], cc = aa + log_tab[b];
+
+ return pow_tab[cc + (cc < aa ? 1 : 0)];
+}
+
+#define ff_mult(a,b) (a && b ? f_mult(a, b) : 0)
+
+#define f_rn(bo, bi, n, k) \
+ bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
+ ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
+ ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
+ ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
+
+#define i_rn(bo, bi, n, k) \
+ bo[n] = it_tab[0][byte(bi[n],0)] ^ \
+ it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
+ it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
+ it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
+
+#define ls_box(x) \
+ ( fl_tab[0][byte(x, 0)] ^ \
+ fl_tab[1][byte(x, 1)] ^ \
+ fl_tab[2][byte(x, 2)] ^ \
+ fl_tab[3][byte(x, 3)] )
+
+#define f_rl(bo, bi, n, k) \
+ bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
+ fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
+ fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
+ fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
+
+#define i_rl(bo, bi, n, k) \
+ bo[n] = il_tab[0][byte(bi[n],0)] ^ \
+ il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
+ il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
+ il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
+
+static void __init
+gen_tabs (void)
+{
+ u32 i, t;
+ u8 p, q;
+
+ /* log and power tables for GF(2**8) finite field with
+ 0x011b as modular polynomial - the simplest primitive
+ root is 0x03, used here to generate the tables */
+
+ for (i = 0, p = 1; i < 256; ++i) {
+ pow_tab[i] = (u8) p;
+ log_tab[p] = (u8) i;
+
+ p ^= (p << 1) ^ (p & 0x80 ? 0x01b : 0);
+ }
+
+ log_tab[1] = 0;
+
+ for (i = 0, p = 1; i < 10; ++i) {
+ rco_tab[i] = p;
+
+ p = (p << 1) ^ (p & 0x80 ? 0x01b : 0);
+ }
+
+ for (i = 0; i < 256; ++i) {
+ p = (i ? pow_tab[255 - log_tab[i]] : 0);
+ q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2));
+ p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2));
+ sbx_tab[i] = p;
+ isb_tab[p] = (u8) i;
+ }
+
+ for (i = 0; i < 256; ++i) {
+ p = sbx_tab[i];
+
+ t = p;
+ fl_tab[0][i] = t;
+ fl_tab[1][i] = rotl (t, 8);
+ fl_tab[2][i] = rotl (t, 16);
+ fl_tab[3][i] = rotl (t, 24);
+
+ t = ((u32) ff_mult (2, p)) |
+ ((u32) p << 8) |
+ ((u32) p << 16) | ((u32) ff_mult (3, p) << 24);
+
+ ft_tab[0][i] = t;
+ ft_tab[1][i] = rotl (t, 8);
+ ft_tab[2][i] = rotl (t, 16);
+ ft_tab[3][i] = rotl (t, 24);
+
+ p = isb_tab[i];
+
+ t = p;
+ il_tab[0][i] = t;
+ il_tab[1][i] = rotl (t, 8);
+ il_tab[2][i] = rotl (t, 16);
+ il_tab[3][i] = rotl (t, 24);
+
+ t = ((u32) ff_mult (14, p)) |
+ ((u32) ff_mult (9, p) << 8) |
+ ((u32) ff_mult (13, p) << 16) |
+ ((u32) ff_mult (11, p) << 24);
+
+ it_tab[0][i] = t;
+ it_tab[1][i] = rotl (t, 8);
+ it_tab[2][i] = rotl (t, 16);
+ it_tab[3][i] = rotl (t, 24);
+ }
+}
+
+#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
+
+#define imix_col(y,x) \
+ u = star_x(x); \
+ v = star_x(u); \
+ w = star_x(v); \
+ t = w ^ (x); \
+ (y) = u ^ v ^ w; \
+ (y) ^= rotr(u ^ t, 8) ^ \
+ rotr(v ^ t, 16) ^ \
+ rotr(t,24)
+
+/* initialise the key schedule from the user supplied key */
+
+#define loop4(i) \
+{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
+ t ^= E_KEY[4 * i]; E_KEY[4 * i + 4] = t; \
+ t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t; \
+ t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t; \
+ t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t; \
+}
+
+#define loop6(i) \
+{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
+ t ^= E_KEY[6 * i]; E_KEY[6 * i + 6] = t; \
+ t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t; \
+ t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t; \
+ t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t; \
+ t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t; \
+ t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t; \
+}
+
+#define loop8(i) \
+{ t = rotr(t, 8); ; t = ls_box(t) ^ rco_tab[i]; \
+ t ^= E_KEY[8 * i]; E_KEY[8 * i + 8] = t; \
+ t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t; \
+ t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t; \
+ t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t; \
+ t = E_KEY[8 * i + 4] ^ ls_box(t); \
+ E_KEY[8 * i + 12] = t; \
+ t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t; \
+ t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t; \
+ t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \
+}
+
+static int
+aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
+{
+ struct aes_ctx *ctx = ctx_arg;
+ u32 i, t, u, v, w;
+
+ if (key_len != 16 && key_len != 24 && key_len != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = key_len;
+
+ E_KEY[0] = u32_in (in_key);
+ E_KEY[1] = u32_in (in_key + 4);
+ E_KEY[2] = u32_in (in_key + 8);
+ E_KEY[3] = u32_in (in_key + 12);
+
+ switch (key_len) {
+ case 16:
+ t = E_KEY[3];
+ for (i = 0; i < 10; ++i)
+ loop4 (i);
+ break;
+
+ case 24:
+ E_KEY[4] = u32_in (in_key + 16);
+ t = E_KEY[5] = u32_in (in_key + 20);
+ for (i = 0; i < 8; ++i)
+ loop6 (i);
+ break;
+
+ case 32:
+ E_KEY[4] = u32_in (in_key + 16);
+ E_KEY[5] = u32_in (in_key + 20);
+ E_KEY[6] = u32_in (in_key + 24);
+ t = E_KEY[7] = u32_in (in_key + 28);
+ for (i = 0; i < 7; ++i)
+ loop8 (i);
+ break;
+ }
+
+ D_KEY[0] = E_KEY[0];
+ D_KEY[1] = E_KEY[1];
+ D_KEY[2] = E_KEY[2];
+ D_KEY[3] = E_KEY[3];
+
+ for (i = 4; i < key_len + 24; ++i) {
+ imix_col (D_KEY[i], E_KEY[i]);
+ }
+
+ return 0;
+}
+
+/* encrypt a block of text */
+
+#define f_nround(bo, bi, k) \
+ f_rn(bo, bi, 0, k); \
+ f_rn(bo, bi, 1, k); \
+ f_rn(bo, bi, 2, k); \
+ f_rn(bo, bi, 3, k); \
+ k += 4
+
+#define f_lround(bo, bi, k) \
+ f_rl(bo, bi, 0, k); \
+ f_rl(bo, bi, 1, k); \
+ f_rl(bo, bi, 2, k); \
+ f_rl(bo, bi, 3, k)
+
+static void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in)
+{
+ const struct aes_ctx *ctx = ctx_arg;
+ u32 b0[4], b1[4];
+ const u32 *kp = E_KEY + 4;
+
+ b0[0] = u32_in (in) ^ E_KEY[0];
+ b0[1] = u32_in (in + 4) ^ E_KEY[1];
+ b0[2] = u32_in (in + 8) ^ E_KEY[2];
+ b0[3] = u32_in (in + 12) ^ E_KEY[3];
+
+ if (ctx->key_length > 24) {
+ f_nround (b1, b0, kp);
+ f_nround (b0, b1, kp);
+ }
+
+ if (ctx->key_length > 16) {
+ f_nround (b1, b0, kp);
+ f_nround (b0, b1, kp);
+ }
+
+ f_nround (b1, b0, kp);
+ f_nround (b0, b1, kp);
+ f_nround (b1, b0, kp);
+ f_nround (b0, b1, kp);
+ f_nround (b1, b0, kp);
+ f_nround (b0, b1, kp);
+ f_nround (b1, b0, kp);
+ f_nround (b0, b1, kp);
+ f_nround (b1, b0, kp);
+ f_lround (b0, b1, kp);
+
+ u32_out (out, b0[0]);
+ u32_out (out + 4, b0[1]);
+ u32_out (out + 8, b0[2]);
+ u32_out (out + 12, b0[3]);
+}
+
+/* decrypt a block of text */
+
+#define i_nround(bo, bi, k) \
+ i_rn(bo, bi, 0, k); \
+ i_rn(bo, bi, 1, k); \
+ i_rn(bo, bi, 2, k); \
+ i_rn(bo, bi, 3, k); \
+ k -= 4
+
+#define i_lround(bo, bi, k) \
+ i_rl(bo, bi, 0, k); \
+ i_rl(bo, bi, 1, k); \
+ i_rl(bo, bi, 2, k); \
+ i_rl(bo, bi, 3, k)
+
+static void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in)
+{
+ const struct aes_ctx *ctx = ctx_arg;
+ u32 b0[4], b1[4];
+ const int key_len = ctx->key_length;
+ const u32 *kp = D_KEY + key_len + 20;
+
+ b0[0] = u32_in (in) ^ E_KEY[key_len + 24];
+ b0[1] = u32_in (in + 4) ^ E_KEY[key_len + 25];
+ b0[2] = u32_in (in + 8) ^ E_KEY[key_len + 26];
+ b0[3] = u32_in (in + 12) ^ E_KEY[key_len + 27];
+
+ if (key_len > 24) {
+ i_nround (b1, b0, kp);
+ i_nround (b0, b1, kp);
+ }
+
+ if (key_len > 16) {
+ i_nround (b1, b0, kp);
+ i_nround (b0, b1, kp);
+ }
+
+ i_nround (b1, b0, kp);
+ i_nround (b0, b1, kp);
+ i_nround (b1, b0, kp);
+ i_nround (b0, b1, kp);
+ i_nround (b1, b0, kp);
+ i_nround (b0, b1, kp);
+ i_nround (b1, b0, kp);
+ i_nround (b0, b1, kp);
+ i_nround (b1, b0, kp);
+ i_lround (b0, b1, kp);
+
+ u32_out (out, b0[0]);
+ u32_out (out + 4, b0[1]);
+ u32_out (out + 8, b0[2]);
+ u32_out (out + 12, b0[3]);
+}
+
+
+static struct crypto_alg aes_alg = {
+ .cra_name = "aes",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(aes_alg.cra_list),
+ .cra_u = {
+ .cipher = {
+ .cia_min_keysize = AES_MIN_KEY_SIZE,
+ .cia_max_keysize = AES_MAX_KEY_SIZE,
+ .cia_setkey = aes_set_key,
+ .cia_encrypt = aes_encrypt,
+ .cia_decrypt = aes_decrypt
+ }
+ }
+};
+
+static int __init aes_init(void)
+{
+ gen_tabs();
+ return crypto_register_alg(&aes_alg);
+}
+
+static void __exit aes_fini(void)
+{
+ crypto_unregister_alg(&aes_alg);
+}
+
+module_init(aes_init);
+module_exit(aes_fini);
+
+MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
+MODULE_LICENSE("Dual BSD/GPL");
+
diff --git a/drivers/staging/rtl8192su/ieee80211/api.c b/drivers/staging/rtl8192su/ieee80211/api.c
new file mode 100644
index 000000000000..c627d029528b
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/api.c
@@ -0,0 +1,246 @@
+/*
+ * Scatterlist Cryptographic API.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 David S. Miller (davem@redhat.com)
+ *
+ * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
+ * and Nettle, by Niels Mé°ˆler.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include "kmap_types.h"
+
+#include <linux/init.h>
+#include <linux/module.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/errno.h>
+#include <linux/rwsem.h>
+#include <linux/slab.h>
+#include "internal.h"
+
+LIST_HEAD(crypto_alg_list);
+DECLARE_RWSEM(crypto_alg_sem);
+
+static inline int crypto_alg_get(struct crypto_alg *alg)
+{
+ return try_inc_mod_count(alg->cra_module);
+}
+
+static inline void crypto_alg_put(struct crypto_alg *alg)
+{
+ if (alg->cra_module)
+ __MOD_DEC_USE_COUNT(alg->cra_module);
+}
+
+struct crypto_alg *crypto_alg_lookup(const char *name)
+{
+ struct crypto_alg *q, *alg = NULL;
+
+ if (!name)
+ return NULL;
+
+ down_read(&crypto_alg_sem);
+
+ list_for_each_entry(q, &crypto_alg_list, cra_list) {
+ if (!(strcmp(q->cra_name, name))) {
+ if (crypto_alg_get(q))
+ alg = q;
+ break;
+ }
+ }
+
+ up_read(&crypto_alg_sem);
+ return alg;
+}
+
+static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
+{
+ tfm->crt_flags = 0;
+
+ switch (crypto_tfm_alg_type(tfm)) {
+ case CRYPTO_ALG_TYPE_CIPHER:
+ return crypto_init_cipher_flags(tfm, flags);
+
+ case CRYPTO_ALG_TYPE_DIGEST:
+ return crypto_init_digest_flags(tfm, flags);
+
+ case CRYPTO_ALG_TYPE_COMPRESS:
+ return crypto_init_compress_flags(tfm, flags);
+
+ default:
+ break;
+ }
+
+ BUG();
+ return -EINVAL;
+}
+
+static int crypto_init_ops(struct crypto_tfm *tfm)
+{
+ switch (crypto_tfm_alg_type(tfm)) {
+ case CRYPTO_ALG_TYPE_CIPHER:
+ return crypto_init_cipher_ops(tfm);
+
+ case CRYPTO_ALG_TYPE_DIGEST:
+ return crypto_init_digest_ops(tfm);
+
+ case CRYPTO_ALG_TYPE_COMPRESS:
+ return crypto_init_compress_ops(tfm);
+
+ default:
+ break;
+ }
+
+ BUG();
+ return -EINVAL;
+}
+
+static void crypto_exit_ops(struct crypto_tfm *tfm)
+{
+ switch (crypto_tfm_alg_type(tfm)) {
+ case CRYPTO_ALG_TYPE_CIPHER:
+ crypto_exit_cipher_ops(tfm);
+ break;
+
+ case CRYPTO_ALG_TYPE_DIGEST:
+ crypto_exit_digest_ops(tfm);
+ break;
+
+ case CRYPTO_ALG_TYPE_COMPRESS:
+ crypto_exit_compress_ops(tfm);
+ break;
+
+ default:
+ BUG();
+
+ }
+}
+
+struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+{
+ struct crypto_tfm *tfm = NULL;
+ struct crypto_alg *alg;
+
+ alg = crypto_alg_mod_lookup(name);
+ if (alg == NULL)
+ goto out;
+
+ tfm = kmalloc(sizeof(*tfm) + alg->cra_ctxsize, GFP_KERNEL);
+ if (tfm == NULL)
+ goto out_put;
+
+ memset(tfm, 0, sizeof(*tfm) + alg->cra_ctxsize);
+
+ tfm->__crt_alg = alg;
+
+ if (crypto_init_flags(tfm, flags))
+ goto out_free_tfm;
+
+ if (crypto_init_ops(tfm)) {
+ crypto_exit_ops(tfm);
+ goto out_free_tfm;
+ }
+
+ goto out;
+
+out_free_tfm:
+ kfree(tfm);
+ tfm = NULL;
+out_put:
+ crypto_alg_put(alg);
+out:
+ return tfm;
+}
+
+void crypto_free_tfm(struct crypto_tfm *tfm)
+{
+ struct crypto_alg *alg = tfm->__crt_alg;
+ int size = sizeof(*tfm) + alg->cra_ctxsize;
+
+ crypto_exit_ops(tfm);
+ crypto_alg_put(alg);
+ memset(tfm, 0, size);
+ kfree(tfm);
+}
+
+int crypto_register_alg(struct crypto_alg *alg)
+{
+ int ret = 0;
+ struct crypto_alg *q;
+
+ down_write(&crypto_alg_sem);
+
+ list_for_each_entry(q, &crypto_alg_list, cra_list) {
+ if (!(strcmp(q->cra_name, alg->cra_name))) {
+ ret = -EEXIST;
+ goto out;
+ }
+ }
+
+ list_add_tail(&alg->cra_list, &crypto_alg_list);
+out:
+ up_write(&crypto_alg_sem);
+ return ret;
+}
+
+int crypto_unregister_alg(struct crypto_alg *alg)
+{
+ int ret = -ENOENT;
+ struct crypto_alg *q;
+
+ BUG_ON(!alg->cra_module);
+
+ down_write(&crypto_alg_sem);
+ list_for_each_entry(q, &crypto_alg_list, cra_list) {
+ if (alg == q) {
+ list_del(&alg->cra_list);
+ ret = 0;
+ goto out;
+ }
+ }
+out:
+ up_write(&crypto_alg_sem);
+ return ret;
+}
+
+int crypto_alg_available(const char *name, u32 flags)
+{
+ int ret = 0;
+ struct crypto_alg *alg = crypto_alg_mod_lookup(name);
+
+ if (alg) {
+ crypto_alg_put(alg);
+ ret = 1;
+ }
+
+ return ret;
+}
+
+static int __init init_crypto(void)
+{
+ printk(KERN_INFO "Initializing Cryptographic API\n");
+ crypto_init_proc();
+ return 0;
+}
+
+__initcall(init_crypto);
+
+/*
+EXPORT_SYMBOL_GPL(crypto_register_alg);
+EXPORT_SYMBOL_GPL(crypto_unregister_alg);
+EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
+EXPORT_SYMBOL_GPL(crypto_free_tfm);
+EXPORT_SYMBOL_GPL(crypto_alg_available);
+*/
+
+EXPORT_SYMBOL_NOVERS(crypto_register_alg);
+EXPORT_SYMBOL_NOVERS(crypto_unregister_alg);
+EXPORT_SYMBOL_NOVERS(crypto_alloc_tfm);
+EXPORT_SYMBOL_NOVERS(crypto_free_tfm);
+EXPORT_SYMBOL_NOVERS(crypto_alg_available);
diff --git a/drivers/staging/rtl8192su/ieee80211/arc4.c b/drivers/staging/rtl8192su/ieee80211/arc4.c
new file mode 100644
index 000000000000..e408472af305
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/arc4.c
@@ -0,0 +1,103 @@
+/*
+ * Cryptographic API
+ *
+ * ARC4 Cipher Algorithm
+ *
+ * Jon Oberheide <jon@oberheide.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include "rtl_crypto.h"
+
+#define ARC4_MIN_KEY_SIZE 1
+#define ARC4_MAX_KEY_SIZE 256
+#define ARC4_BLOCK_SIZE 1
+
+struct arc4_ctx {
+ u8 S[256];
+ u8 x, y;
+};
+
+static int arc4_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
+{
+ struct arc4_ctx *ctx = ctx_arg;
+ int i, j = 0, k = 0;
+
+ ctx->x = 1;
+ ctx->y = 0;
+
+ for(i = 0; i < 256; i++)
+ ctx->S[i] = i;
+
+ for(i = 0; i < 256; i++)
+ {
+ u8 a = ctx->S[i];
+ j = (j + in_key[k] + a) & 0xff;
+ ctx->S[i] = ctx->S[j];
+ ctx->S[j] = a;
+ if((unsigned int)++k >= key_len)
+ k = 0;
+ }
+
+ return 0;
+}
+
+static void arc4_crypt(void *ctx_arg, u8 *out, const u8 *in)
+{
+ struct arc4_ctx *ctx = ctx_arg;
+
+ u8 *const S = ctx->S;
+ u8 x = ctx->x;
+ u8 y = ctx->y;
+ u8 a, b;
+
+ a = S[x];
+ y = (y + a) & 0xff;
+ b = S[y];
+ S[x] = b;
+ S[y] = a;
+ x = (x + 1) & 0xff;
+ *out++ = *in ^ S[(a + b) & 0xff];
+
+ ctx->x = x;
+ ctx->y = y;
+}
+
+static struct crypto_alg arc4_alg = {
+ .cra_name = "arc4",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = ARC4_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct arc4_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(arc4_alg.cra_list),
+ .cra_u = { .cipher = {
+ .cia_min_keysize = ARC4_MIN_KEY_SIZE,
+ .cia_max_keysize = ARC4_MAX_KEY_SIZE,
+ .cia_setkey = arc4_set_key,
+ .cia_encrypt = arc4_crypt,
+ .cia_decrypt = arc4_crypt } }
+};
+
+static int __init arc4_init(void)
+{
+ return crypto_register_alg(&arc4_alg);
+}
+
+
+static void __exit arc4_exit(void)
+{
+ crypto_unregister_alg(&arc4_alg);
+}
+
+module_init(arc4_init);
+module_exit(arc4_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
+MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
diff --git a/drivers/staging/rtl8192su/ieee80211/autoload.c b/drivers/staging/rtl8192su/ieee80211/autoload.c
new file mode 100644
index 000000000000..c97756f3b2ea
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/autoload.c
@@ -0,0 +1,40 @@
+/*
+ * Cryptographic API.
+ *
+ * Algorithm autoloader.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include "kmap_types.h"
+
+#include <linux/kernel.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/string.h>
+#include <linux/kmod.h>
+#include "internal.h"
+
+/*
+ * A far more intelligent version of this is planned. For now, just
+ * try an exact match on the name of the algorithm.
+ */
+void crypto_alg_autoload(const char *name)
+{
+ request_module(name);
+}
+
+struct crypto_alg *crypto_alg_mod_lookup(const char *name)
+{
+ struct crypto_alg *alg = crypto_alg_lookup(name);
+ if (alg == NULL) {
+ crypto_alg_autoload(name);
+ alg = crypto_alg_lookup(name);
+ }
+ return alg;
+}
diff --git a/drivers/staging/rtl8192su/ieee80211/cipher.c b/drivers/staging/rtl8192su/ieee80211/cipher.c
new file mode 100644
index 000000000000..1968acfe32b1
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/cipher.c
@@ -0,0 +1,299 @@
+/*
+ * Cryptographic API.
+ *
+ * Cipher operations.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include <linux/kernel.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/errno.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <asm/scatterlist.h>
+#include "internal.h"
+#include "scatterwalk.h"
+
+typedef void (cryptfn_t)(void *, u8 *, const u8 *);
+typedef void (procfn_t)(struct crypto_tfm *, u8 *,
+ u8*, cryptfn_t, int enc, void *, int);
+
+static inline void xor_64(u8 *a, const u8 *b)
+{
+ ((u32 *)a)[0] ^= ((u32 *)b)[0];
+ ((u32 *)a)[1] ^= ((u32 *)b)[1];
+}
+
+static inline void xor_128(u8 *a, const u8 *b)
+{
+ ((u32 *)a)[0] ^= ((u32 *)b)[0];
+ ((u32 *)a)[1] ^= ((u32 *)b)[1];
+ ((u32 *)a)[2] ^= ((u32 *)b)[2];
+ ((u32 *)a)[3] ^= ((u32 *)b)[3];
+}
+
+
+/*
+ * Generic encrypt/decrypt wrapper for ciphers, handles operations across
+ * multiple page boundaries by using temporary blocks. In user context,
+ * the kernel is given a chance to schedule us once per block.
+ */
+static int crypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, cryptfn_t crfn,
+ procfn_t prfn, int enc, void *info)
+{
+ struct scatter_walk walk_in, walk_out;
+ const unsigned int bsize = crypto_tfm_alg_blocksize(tfm);
+ u8 tmp_src[bsize];
+ u8 tmp_dst[bsize];
+
+ if (!nbytes)
+ return 0;
+
+ if (nbytes % bsize) {
+ tfm->crt_flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
+ return -EINVAL;
+ }
+
+ scatterwalk_start(&walk_in, src);
+ scatterwalk_start(&walk_out, dst);
+
+ for(;;) {
+ u8 *src_p, *dst_p;
+ int in_place;
+
+ scatterwalk_map(&walk_in, 0);
+ scatterwalk_map(&walk_out, 1);
+ src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src);
+ dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst);
+ in_place = scatterwalk_samebuf(&walk_in, &walk_out,
+ src_p, dst_p);
+
+ nbytes -= bsize;
+
+ scatterwalk_copychunks(src_p, &walk_in, bsize, 0);
+
+ prfn(tfm, dst_p, src_p, crfn, enc, info, in_place);
+
+ scatterwalk_done(&walk_in, 0, nbytes);
+
+ scatterwalk_copychunks(dst_p, &walk_out, bsize, 1);
+ scatterwalk_done(&walk_out, 1, nbytes);
+
+ if (!nbytes)
+ return 0;
+
+ crypto_yield(tfm);
+ }
+}
+
+static void cbc_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
+ cryptfn_t fn, int enc, void *info, int in_place)
+{
+ u8 *iv = info;
+
+ /* Null encryption */
+ if (!iv)
+ return;
+
+ if (enc) {
+ tfm->crt_u.cipher.cit_xor_block(iv, src);
+ fn(crypto_tfm_ctx(tfm), dst, iv);
+ memcpy(iv, dst, crypto_tfm_alg_blocksize(tfm));
+ } else {
+ u8 stack[in_place ? crypto_tfm_alg_blocksize(tfm) : 0];
+ u8 *buf = in_place ? stack : dst;
+
+ fn(crypto_tfm_ctx(tfm), buf, src);
+ tfm->crt_u.cipher.cit_xor_block(buf, iv);
+ memcpy(iv, src, crypto_tfm_alg_blocksize(tfm));
+ if (buf != dst)
+ memcpy(dst, buf, crypto_tfm_alg_blocksize(tfm));
+ }
+}
+
+static void ecb_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
+ cryptfn_t fn, int enc, void *info, int in_place)
+{
+ fn(crypto_tfm_ctx(tfm), dst, src);
+}
+
+static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+{
+ struct cipher_alg *cia = &tfm->__crt_alg->cra_cipher;
+
+ if (keylen < cia->cia_min_keysize || keylen > cia->cia_max_keysize) {
+ tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ } else
+ return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen,
+ &tfm->crt_flags);
+}
+
+static int ecb_encrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src, unsigned int nbytes)
+{
+ return crypt(tfm, dst, src, nbytes,
+ tfm->__crt_alg->cra_cipher.cia_encrypt,
+ ecb_process, 1, NULL);
+}
+
+static int ecb_decrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ return crypt(tfm, dst, src, nbytes,
+ tfm->__crt_alg->cra_cipher.cia_decrypt,
+ ecb_process, 1, NULL);
+}
+
+static int cbc_encrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ return crypt(tfm, dst, src, nbytes,
+ tfm->__crt_alg->cra_cipher.cia_encrypt,
+ cbc_process, 1, tfm->crt_cipher.cit_iv);
+}
+
+static int cbc_encrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv)
+{
+ return crypt(tfm, dst, src, nbytes,
+ tfm->__crt_alg->cra_cipher.cia_encrypt,
+ cbc_process, 1, iv);
+}
+
+static int cbc_decrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ return crypt(tfm, dst, src, nbytes,
+ tfm->__crt_alg->cra_cipher.cia_decrypt,
+ cbc_process, 0, tfm->crt_cipher.cit_iv);
+}
+
+static int cbc_decrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv)
+{
+ return crypt(tfm, dst, src, nbytes,
+ tfm->__crt_alg->cra_cipher.cia_decrypt,
+ cbc_process, 0, iv);
+}
+
+static int nocrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ return -ENOSYS;
+}
+
+static int nocrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv)
+{
+ return -ENOSYS;
+}
+
+int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags)
+{
+ u32 mode = flags & CRYPTO_TFM_MODE_MASK;
+
+ tfm->crt_cipher.cit_mode = mode ? mode : CRYPTO_TFM_MODE_ECB;
+ if (flags & CRYPTO_TFM_REQ_WEAK_KEY)
+ tfm->crt_flags = CRYPTO_TFM_REQ_WEAK_KEY;
+
+ return 0;
+}
+
+int crypto_init_cipher_ops(struct crypto_tfm *tfm)
+{
+ int ret = 0;
+ struct cipher_tfm *ops = &tfm->crt_cipher;
+
+ ops->cit_setkey = setkey;
+
+ switch (tfm->crt_cipher.cit_mode) {
+ case CRYPTO_TFM_MODE_ECB:
+ ops->cit_encrypt = ecb_encrypt;
+ ops->cit_decrypt = ecb_decrypt;
+ break;
+
+ case CRYPTO_TFM_MODE_CBC:
+ ops->cit_encrypt = cbc_encrypt;
+ ops->cit_decrypt = cbc_decrypt;
+ ops->cit_encrypt_iv = cbc_encrypt_iv;
+ ops->cit_decrypt_iv = cbc_decrypt_iv;
+ break;
+
+ case CRYPTO_TFM_MODE_CFB:
+ ops->cit_encrypt = nocrypt;
+ ops->cit_decrypt = nocrypt;
+ ops->cit_encrypt_iv = nocrypt_iv;
+ ops->cit_decrypt_iv = nocrypt_iv;
+ break;
+
+ case CRYPTO_TFM_MODE_CTR:
+ ops->cit_encrypt = nocrypt;
+ ops->cit_decrypt = nocrypt;
+ ops->cit_encrypt_iv = nocrypt_iv;
+ ops->cit_decrypt_iv = nocrypt_iv;
+ break;
+
+ default:
+ BUG();
+ }
+
+ if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) {
+
+ switch (crypto_tfm_alg_blocksize(tfm)) {
+ case 8:
+ ops->cit_xor_block = xor_64;
+ break;
+
+ case 16:
+ ops->cit_xor_block = xor_128;
+ break;
+
+ default:
+ printk(KERN_WARNING "%s: block size %u not supported\n",
+ crypto_tfm_alg_name(tfm),
+ crypto_tfm_alg_blocksize(tfm));
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm);
+ ops->cit_iv = kmalloc(ops->cit_ivsize, GFP_KERNEL);
+ if (ops->cit_iv == NULL)
+ ret = -ENOMEM;
+ }
+
+out:
+ return ret;
+}
+
+void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
+{
+ if (tfm->crt_cipher.cit_iv)
+ kfree(tfm->crt_cipher.cit_iv);
+}
diff --git a/drivers/staging/rtl8192su/ieee80211/compress.c b/drivers/staging/rtl8192su/ieee80211/compress.c
new file mode 100644
index 000000000000..c2df80e2ed9d
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/compress.c
@@ -0,0 +1,64 @@
+/*
+ * Cryptographic API.
+ *
+ * Compression operations.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include <linux/types.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/errno.h>
+#include <asm/scatterlist.h>
+#include <linux/string.h>
+#include "internal.h"
+
+static int crypto_compress(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen)
+{
+ return tfm->__crt_alg->cra_compress.coa_compress(crypto_tfm_ctx(tfm),
+ src, slen, dst,
+ dlen);
+}
+
+static int crypto_decompress(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen)
+{
+ return tfm->__crt_alg->cra_compress.coa_decompress(crypto_tfm_ctx(tfm),
+ src, slen, dst,
+ dlen);
+}
+
+int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags)
+{
+ return flags ? -EINVAL : 0;
+}
+
+int crypto_init_compress_ops(struct crypto_tfm *tfm)
+{
+ int ret = 0;
+ struct compress_tfm *ops = &tfm->crt_compress;
+
+ ret = tfm->__crt_alg->cra_compress.coa_init(crypto_tfm_ctx(tfm));
+ if (ret)
+ goto out;
+
+ ops->cot_compress = crypto_compress;
+ ops->cot_decompress = crypto_decompress;
+
+out:
+ return ret;
+}
+
+void crypto_exit_compress_ops(struct crypto_tfm *tfm)
+{
+ tfm->__crt_alg->cra_compress.coa_exit(crypto_tfm_ctx(tfm));
+}
diff --git a/drivers/staging/rtl8192su/ieee80211/crypto_compat.h b/drivers/staging/rtl8192su/ieee80211/crypto_compat.h
new file mode 100644
index 000000000000..587e8bb2db6a
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/crypto_compat.h
@@ -0,0 +1,90 @@
+/*
+ * Header file to maintain compatibility among different kernel versions.
+ *
+ * Copyright (c) 2004-2006 <lawrence_wang@realsil.com.cn>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+#include <linux/crypto.h>
+
+static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
+}
+
+
+static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
+}
+
+#if 0
+/*
+ * crypto_free_tfm - Free crypto transform
+ * @tfm: Transform to free
+ *
+ * crypto_free_tfm() frees up the transform and any associated resources,
+ * then drops the refcount on the associated algorithm.
+ */
+void crypto_free_tfm(struct crypto_tfm *tfm)
+{
+ struct crypto_alg *alg;
+ int size;
+
+ if (unlikely(!tfm))
+ return;
+
+ alg = tfm->__crt_alg;
+ size = sizeof(*tfm) + alg->cra_ctxsize;
+
+ if (alg->cra_exit)
+ alg->cra_exit(tfm);
+ crypto_exit_ops(tfm);
+ crypto_mod_put(alg);
+ memset(tfm, 0, size);
+ kfree(tfm);
+}
+
+#endif
+#if 1
+ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+{
+ struct crypto_tfm *tfm = NULL;
+ int err;
+ printk("call crypto_alloc_tfm!!!\n");
+ do {
+ struct crypto_alg *alg;
+
+ alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
+ err = PTR_ERR(alg);
+ if (IS_ERR(alg))
+ continue;
+
+ tfm = __crypto_alloc_tfm(alg, flags);
+ err = 0;
+ if (IS_ERR(tfm)) {
+ crypto_mod_put(alg);
+ err = PTR_ERR(tfm);
+ tfm = NULL;
+ }
+ } while (err == -EAGAIN && !signal_pending(current));
+
+ return tfm;
+}
+#endif
+//EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
+//EXPORT_SYMBOL_GPL(crypto_free_tfm);
+
+
diff --git a/drivers/staging/rtl8192su/ieee80211/digest.c b/drivers/staging/rtl8192su/ieee80211/digest.c
new file mode 100644
index 000000000000..1a95f2d37837
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/digest.c
@@ -0,0 +1,108 @@
+/*
+ * Cryptographic API.
+ *
+ * Digest operations.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/mm.h>
+#include <linux/errno.h>
+#include <linux/highmem.h>
+#include <asm/scatterlist.h>
+#include "internal.h"
+
+static void init(struct crypto_tfm *tfm)
+{
+ tfm->__crt_alg->cra_digest.dia_init(crypto_tfm_ctx(tfm));
+}
+
+static void update(struct crypto_tfm *tfm,
+ struct scatterlist *sg, unsigned int nsg)
+{
+ unsigned int i;
+
+ for (i = 0; i < nsg; i++) {
+
+ struct page *pg = sg[i].page;
+ unsigned int offset = sg[i].offset;
+ unsigned int l = sg[i].length;
+
+ do {
+ unsigned int bytes_from_page = min(l, ((unsigned int)
+ (PAGE_SIZE)) -
+ offset);
+ char *p = crypto_kmap(pg, 0) + offset;
+
+ tfm->__crt_alg->cra_digest.dia_update
+ (crypto_tfm_ctx(tfm), p,
+ bytes_from_page);
+ crypto_kunmap(p, 0);
+ crypto_yield(tfm);
+ offset = 0;
+ pg++;
+ l -= bytes_from_page;
+ } while (l > 0);
+ }
+}
+
+static void final(struct crypto_tfm *tfm, u8 *out)
+{
+ tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out);
+}
+
+static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+{
+ u32 flags;
+ if (tfm->__crt_alg->cra_digest.dia_setkey == NULL)
+ return -ENOSYS;
+ return tfm->__crt_alg->cra_digest.dia_setkey(crypto_tfm_ctx(tfm),
+ key, keylen, &flags);
+}
+
+static void digest(struct crypto_tfm *tfm,
+ struct scatterlist *sg, unsigned int nsg, u8 *out)
+{
+ unsigned int i;
+
+ tfm->crt_digest.dit_init(tfm);
+
+ for (i = 0; i < nsg; i++) {
+ char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;
+ tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm),
+ p, sg[i].length);
+ crypto_kunmap(p, 0);
+ crypto_yield(tfm);
+ }
+ crypto_digest_final(tfm, out);
+}
+
+int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags)
+{
+ return flags ? -EINVAL : 0;
+}
+
+int crypto_init_digest_ops(struct crypto_tfm *tfm)
+{
+ struct digest_tfm *ops = &tfm->crt_digest;
+
+ ops->dit_init = init;
+ ops->dit_update = update;
+ ops->dit_final = final;
+ ops->dit_digest = digest;
+ ops->dit_setkey = setkey;
+
+ return crypto_alloc_hmac_block(tfm);
+}
+
+void crypto_exit_digest_ops(struct crypto_tfm *tfm)
+{
+ crypto_free_hmac_block(tfm);
+}
diff --git a/drivers/staging/rtl8192su/ieee80211/dot11d.c b/drivers/staging/rtl8192su/ieee80211/dot11d.c
new file mode 100644
index 000000000000..e5f2dedc4372
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/dot11d.c
@@ -0,0 +1,239 @@
+#ifdef ENABLE_DOT11D
+//-----------------------------------------------------------------------------
+// File:
+// Dot11d.c
+//
+// Description:
+// Implement 802.11d.
+//
+//-----------------------------------------------------------------------------
+
+#include "dot11d.h"
+
+void
+Dot11d_Init(struct ieee80211_device *ieee)
+{
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
+
+ pDot11dInfo->bEnabled = 0;
+
+ pDot11dInfo->State = DOT11D_STATE_NONE;
+ pDot11dInfo->CountryIeLen = 0;
+ memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
+ memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
+ RESET_CIE_WATCHDOG(ieee);
+
+ printk("Dot11d_Init()\n");
+}
+
+//
+// Description:
+// Reset to the state as we are just entering a regulatory domain.
+//
+void
+Dot11d_Reset(struct ieee80211_device *ieee)
+{
+ u32 i;
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
+#if 0
+ if(!pDot11dInfo->bEnabled)
+ return;
+#endif
+ // Clear old channel map
+ memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
+ memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
+ // Set new channel map
+ for (i=1; i<=11; i++) {
+ (pDot11dInfo->channel_map)[i] = 1;
+ }
+ for (i=12; i<=14; i++) {
+ (pDot11dInfo->channel_map)[i] = 2;
+ }
+
+ pDot11dInfo->State = DOT11D_STATE_NONE;
+ pDot11dInfo->CountryIeLen = 0;
+ RESET_CIE_WATCHDOG(ieee);
+
+ //printk("Dot11d_Reset()\n");
+}
+
+//
+// Description:
+// Update country IE from Beacon or Probe Resopnse
+// and configure PHY for operation in the regulatory domain.
+//
+// TODO:
+// Configure Tx power.
+//
+// Assumption:
+// 1. IS_DOT11D_ENABLE() is TRUE.
+// 2. Input IE is an valid one.
+//
+void
+Dot11d_UpdateCountryIe(
+ struct ieee80211_device *dev,
+ u8 * pTaddr,
+ u16 CoutryIeLen,
+ u8 * pCoutryIe
+ )
+{
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
+ u8 i, j, NumTriples, MaxChnlNum;
+ PCHNL_TXPOWER_TRIPLE pTriple;
+
+ memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
+ memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
+ MaxChnlNum = 0;
+ NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string.
+ pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3);
+ for(i = 0; i < NumTriples; i++)
+ {
+ if(MaxChnlNum >= pTriple->FirstChnl)
+ { // It is not in a monotonically increasing order, so stop processing.
+ printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
+ return;
+ }
+ if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls))
+ { // It is not a valid set of channel id, so stop processing.
+ printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
+ return;
+ }
+
+ for(j = 0 ; j < pTriple->NumChnls; j++)
+ {
+ pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
+ pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm;
+ MaxChnlNum = pTriple->FirstChnl + j;
+ }
+
+ pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3);
+ }
+#if 1
+ //printk("Dot11d_UpdateCountryIe(): Channel List:\n");
+ printk("Channel List:");
+ for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
+ if(pDot11dInfo->channel_map[i] > 0)
+ printk(" %d", i);
+ printk("\n");
+#endif
+
+ UPDATE_CIE_SRC(dev, pTaddr);
+
+ pDot11dInfo->CountryIeLen = CoutryIeLen;
+ memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen);
+ pDot11dInfo->State = DOT11D_STATE_LEARNED;
+}
+
+
+u8
+DOT11D_GetMaxTxPwrInDbm(
+ struct ieee80211_device *dev,
+ u8 Channel
+ )
+{
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
+ u8 MaxTxPwrInDbm = 255;
+
+ if(MAX_CHANNEL_NUMBER < Channel)
+ {
+ printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
+ return MaxTxPwrInDbm;
+ }
+ if(pDot11dInfo->channel_map[Channel])
+ {
+ MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
+ }
+
+ return MaxTxPwrInDbm;
+}
+
+
+void
+DOT11D_ScanComplete(
+ struct ieee80211_device * dev
+ )
+{
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
+
+ switch(pDot11dInfo->State)
+ {
+ case DOT11D_STATE_LEARNED:
+ pDot11dInfo->State = DOT11D_STATE_DONE;
+ break;
+
+ case DOT11D_STATE_DONE:
+ if( GET_CIE_WATCHDOG(dev) == 0 )
+ { // Reset country IE if previous one is gone.
+ Dot11d_Reset(dev);
+ }
+ break;
+ case DOT11D_STATE_NONE:
+ break;
+ }
+}
+
+int IsLegalChannel(
+ struct ieee80211_device * dev,
+ u8 channel
+)
+{
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
+
+ if(MAX_CHANNEL_NUMBER < channel)
+ {
+ printk("IsLegalChannel(): Invalid Channel\n");
+ return 0;
+ }
+ if(pDot11dInfo->channel_map[channel] > 0)
+ return 1;
+ return 0;
+}
+
+int ToLegalChannel(
+ struct ieee80211_device * dev,
+ u8 channel
+)
+{
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
+ u8 default_chn = 0;
+ u32 i = 0;
+
+ for (i=1; i<= MAX_CHANNEL_NUMBER; i++)
+ {
+ if(pDot11dInfo->channel_map[i] > 0)
+ {
+ default_chn = i;
+ break;
+ }
+ }
+
+ if(MAX_CHANNEL_NUMBER < channel)
+ {
+ printk("IsLegalChannel(): Invalid Channel\n");
+ return default_chn;
+ }
+
+ if(pDot11dInfo->channel_map[channel] > 0)
+ return channel;
+
+ return default_chn;
+}
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(Dot11d_Init);
+EXPORT_SYMBOL(Dot11d_Reset);
+EXPORT_SYMBOL(Dot11d_UpdateCountryIe);
+EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm);
+EXPORT_SYMBOL(DOT11D_ScanComplete);
+EXPORT_SYMBOL(IsLegalChannel);
+EXPORT_SYMBOL(ToLegalChannel);
+#else
+EXPORT_SYMBOL_NOVERS(Dot11d_Init);
+EXPORT_SYMBOL_NOVERS(Dot11d_Reset);
+EXPORT_SYMBOL_NOVERS(Dot11d_UpdateCountryIe);
+EXPORT_SYMBOL_NOVERS(DOT11D_GetMaxTxPwrInDbm);
+EXPORT_SYMBOL_NOVERS(DOT11D_ScanComplete);
+EXPORT_SYMBOL_NOVERS(IsLegalChannel);
+EXPORT_SYMBOL_NOVERS(ToLegalChannel);
+#endif
+
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/dot11d.h b/drivers/staging/rtl8192su/ieee80211/dot11d.h
new file mode 100644
index 000000000000..15b7a4ba37b6
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/dot11d.h
@@ -0,0 +1,102 @@
+#ifndef __INC_DOT11D_H
+#define __INC_DOT11D_H
+
+#ifdef ENABLE_DOT11D
+#include "ieee80211.h"
+
+//#define ENABLE_DOT11D
+
+//#define DOT11D_MAX_CHNL_NUM 83
+
+typedef struct _CHNL_TXPOWER_TRIPLE {
+ u8 FirstChnl;
+ u8 NumChnls;
+ u8 MaxTxPowerInDbm;
+}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
+
+typedef enum _DOT11D_STATE {
+ DOT11D_STATE_NONE = 0,
+ DOT11D_STATE_LEARNED,
+ DOT11D_STATE_DONE,
+}DOT11D_STATE;
+
+typedef struct _RT_DOT11D_INFO {
+ //DECLARE_RT_OBJECT(RT_DOT11D_INFO);
+
+ bool bEnabled; // dot11MultiDomainCapabilityEnabled
+
+ u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element.
+ u8 CountryIeBuf[MAX_IE_LEN];
+ u8 CountryIeSrcAddr[6]; // Source AP of the country IE.
+ u8 CountryIeWatchdog;
+
+ u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan)
+ //u8 ChnlListLen; // #Bytes valid in ChnlList[].
+ //u8 ChnlList[DOT11D_MAX_CHNL_NUM];
+ u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
+
+ DOT11D_STATE State;
+}RT_DOT11D_INFO, *PRT_DOT11D_INFO;
+#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
+#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
+#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo))
+
+#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled
+#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
+
+#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
+#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
+
+#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
+ (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
+ FALSE : \
+ (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length)))
+
+#define CIE_WATCHDOG_TH 1
+#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog
+#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
+#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev)
+
+#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
+
+
+void
+Dot11d_Init(
+ struct ieee80211_device *dev
+ );
+
+void
+Dot11d_Reset(
+ struct ieee80211_device *dev
+ );
+
+void
+Dot11d_UpdateCountryIe(
+ struct ieee80211_device *dev,
+ u8 * pTaddr,
+ u16 CoutryIeLen,
+ u8 * pCoutryIe
+ );
+
+u8
+DOT11D_GetMaxTxPwrInDbm(
+ struct ieee80211_device *dev,
+ u8 Channel
+ );
+
+void
+DOT11D_ScanComplete(
+ struct ieee80211_device * dev
+ );
+
+int IsLegalChannel(
+ struct ieee80211_device * dev,
+ u8 channel
+);
+
+int ToLegalChannel(
+ struct ieee80211_device * dev,
+ u8 channel
+);
+#endif //ENABLE_DOT11D
+#endif // #ifndef __INC_DOT11D_H
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211.h b/drivers/staging/rtl8192su/ieee80211/ieee80211.h
new file mode 100644
index 000000000000..720bfcbfadc1
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211.h
@@ -0,0 +1,2901 @@
+/*
+ * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
+ * remains copyright by the original authors
+ *
+ * Portions of the merged code are based on Host AP (software wireless
+ * LAN access point) driver for Intersil Prism2/2.5/3.
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * Adaption to a generic IEEE 802.11 stack by James Ketrenos
+ * <jketreno@linux.intel.com>
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * Modified for Realtek's wi-fi cards by Andrea Merello
+ * <andreamrl@tiscali.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+#ifndef IEEE80211_H
+#define IEEE80211_H
+#include <linux/if_ether.h> /* ETH_ALEN */
+#include <linux/kernel.h> /* ARRAY_SIZE */
+#include <linux/version.h>
+#include <linux/module.h>
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#include <linux/jiffies.h>
+#else
+#include <linux/jffs.h>
+#include <linux/tqueue.h>
+#endif
+#include <linux/timer.h>
+#include <linux/sched.h>
+
+#include <linux/delay.h>
+#include <linux/wireless.h>
+
+#include "rtl819x_HT.h"
+#include "rtl819x_BA.h"
+#include "rtl819x_TS.h"
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+#ifndef bool
+typedef enum{false = 0, true} bool;
+#endif
+#endif
+
+#ifndef IW_MODE_MONITOR
+#define IW_MODE_MONITOR 6
+#endif
+
+#ifndef IWEVCUSTOM
+#define IWEVCUSTOM 0x8c02
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#ifndef __bitwise
+#define __bitwise __attribute__((bitwise))
+#endif
+typedef __u16 __le16;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27))
+struct iw_spy_data{
+ /* --- Standard spy support --- */
+ int spy_number;
+ u_char spy_address[IW_MAX_SPY][ETH_ALEN];
+ struct iw_quality spy_stat[IW_MAX_SPY];
+ /* --- Enhanced spy support (event) */
+ struct iw_quality spy_thr_low; /* Low threshold */
+ struct iw_quality spy_thr_high; /* High threshold */
+ u_char spy_thr_under[IW_MAX_SPY];
+};
+#endif
+#endif
+
+#ifndef container_of
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ *
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+#define KEY_TYPE_NA 0x0
+#define KEY_TYPE_WEP40 0x1
+#define KEY_TYPE_TKIP 0x2
+#define KEY_TYPE_CCMP 0x4
+#define KEY_TYPE_WEP104 0x5
+
+/* added for rtl819x tx procedure */
+#define MAX_QUEUE_SIZE 0x10
+
+//
+// 8190 queue mapping
+//
+#define BK_QUEUE 0
+#define BE_QUEUE 1
+#define VI_QUEUE 2
+#define VO_QUEUE 3
+#define HCCA_QUEUE 4
+#define TXCMD_QUEUE 5
+#define MGNT_QUEUE 6
+#define HIGH_QUEUE 7
+#define BEACON_QUEUE 8
+
+#define LOW_QUEUE BE_QUEUE
+#define NORMAL_QUEUE MGNT_QUEUE
+
+//added by amy for ps
+#define SWRF_TIMEOUT 50
+
+//added by amy for LEAP related
+#define IE_CISCO_FLAG_POSITION 0x08 // Flag byte: byte 8, numbered from 0.
+#define SUPPORT_CKIP_MIC 0x08 // bit3
+#define SUPPORT_CKIP_PK 0x10 // bit4
+//added by amy for ps
+// RF Off Level for IPS or HW/SW radio off
+#define RT_RF_OFF_LEVL_ASPM BIT0 // PCI ASPM
+#define RT_RF_OFF_LEVL_CLK_REQ BIT1 // PCI clock request
+#define RT_RF_OFF_LEVL_PCI_D3 BIT2 // PCI D3 mode
+#define RT_RF_OFF_LEVL_HALT_NIC BIT3 // NIC halt, re-initialize hw parameters
+#define RT_RF_OFF_LEVL_FREE_FW BIT4 // FW free, re-download the FW
+#define RT_RF_OFF_LEVL_FW_32K BIT5 // FW in 32k
+#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 // Always enable ASPM and Clock Req in initialization.
+#define RT_RF_LPS_DISALBE_2R BIT30 // When LPS is on, disable 2R if no packet is received or transmittd.
+#define RT_RF_LPS_LEVEL_ASPM BIT31 // LPS with ASPM
+#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
+#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG)))
+#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel->CurPsLevel |= _PS_FLAG)
+/* defined for skb cb field */
+/* At most 28 byte */
+typedef struct cb_desc {
+ /* Tx Desc Related flags (8-9) */
+ u8 bLastIniPkt:1;
+ u8 bCmdOrInit:1;
+ u8 bFirstSeg:1;
+ u8 bLastSeg:1;
+ u8 bEncrypt:1;
+ u8 bTxDisableRateFallBack:1;
+ u8 bTxUseDriverAssingedRate:1;
+ u8 bHwSec:1; //indicate whether use Hw security. WB
+
+ u8 reserved1;
+
+ /* Tx Firmware Relaged flags (10-11)*/
+ u8 bCTSEnable:1;
+ u8 bRTSEnable:1;
+ u8 bUseShortGI:1;
+ u8 bUseShortPreamble:1;
+ u8 bTxEnableFwCalcDur:1;
+ u8 bAMPDUEnable:1;
+ u8 bRTSSTBC:1;
+ u8 RTSSC:1;
+
+ u8 bRTSBW:1;
+ u8 bPacketBW:1;
+ u8 bRTSUseShortPreamble:1;
+ u8 bRTSUseShortGI:1;
+ u8 bMulticast:1;
+ u8 bBroadcast:1;
+ //u8 reserved2:2;
+ u8 drv_agg_enable:1;
+ u8 reserved2:1;
+
+ /* Tx Desc related element(12-19) */
+ u8 rata_index;
+ u8 queue_index;
+ //u8 reserved3;
+ //u8 reserved4;
+ u16 txbuf_size;
+ //u8 reserved5;
+ u8 RATRIndex;
+ u8 reserved6;
+ u8 reserved7;
+ u8 reserved8;
+
+ /* Tx firmware related element(20-27) */
+ u8 data_rate;
+ u8 rts_rate;
+ u8 ampdu_factor;
+ u8 ampdu_density;
+ //u8 reserved9;
+ //u8 reserved10;
+ //u8 reserved11;
+ u8 DrvAggrNum;
+ u16 pkt_size;
+ u8 reserved12;
+}cb_desc, *pcb_desc;
+
+/*--------------------------Define -------------------------------------------*/
+#define MGN_1M 0x02
+#define MGN_2M 0x04
+#define MGN_5_5M 0x0b
+#define MGN_11M 0x16
+
+#define MGN_6M 0x0c
+#define MGN_9M 0x12
+#define MGN_12M 0x18
+#define MGN_18M 0x24
+#define MGN_24M 0x30
+#define MGN_36M 0x48
+#define MGN_48M 0x60
+#define MGN_54M 0x6c
+
+#define MGN_MCS0 0x80
+#define MGN_MCS1 0x81
+#define MGN_MCS2 0x82
+#define MGN_MCS3 0x83
+#define MGN_MCS4 0x84
+#define MGN_MCS5 0x85
+#define MGN_MCS6 0x86
+#define MGN_MCS7 0x87
+#define MGN_MCS8 0x88
+#define MGN_MCS9 0x89
+#define MGN_MCS10 0x8a
+#define MGN_MCS11 0x8b
+#define MGN_MCS12 0x8c
+#define MGN_MCS13 0x8d
+#define MGN_MCS14 0x8e
+#define MGN_MCS15 0x8f
+#define MGN_MCS0_SG 0x90
+#define MGN_MCS1_SG 0x91
+#define MGN_MCS2_SG 0x92
+#define MGN_MCS3_SG 0x93
+#define MGN_MCS4_SG 0x94
+#define MGN_MCS5_SG 0x95
+#define MGN_MCS6_SG 0x96
+#define MGN_MCS7_SG 0x97
+#define MGN_MCS8_SG 0x98
+#define MGN_MCS9_SG 0x99
+#define MGN_MCS10_SG 0x9a
+#define MGN_MCS11_SG 0x9b
+#define MGN_MCS12_SG 0x9c
+#define MGN_MCS13_SG 0x9d
+#define MGN_MCS14_SG 0x9e
+#define MGN_MCS15_SG 0x9f
+
+
+//----------------------------------------------------------------------------
+// 802.11 Management frame Reason Code field
+//----------------------------------------------------------------------------
+enum _ReasonCode{
+ unspec_reason = 0x1,
+ auth_not_valid = 0x2,
+ deauth_lv_ss = 0x3,
+ inactivity = 0x4,
+ ap_overload = 0x5,
+ class2_err = 0x6,
+ class3_err = 0x7,
+ disas_lv_ss = 0x8,
+ asoc_not_auth = 0x9,
+
+ //----MIC_CHECK
+ mic_failure = 0xe,
+ //----END MIC_CHECK
+
+ // Reason code defined in 802.11i D10.0 p.28.
+ invalid_IE = 0x0d,
+ four_way_tmout = 0x0f,
+ two_way_tmout = 0x10,
+ IE_dismatch = 0x11,
+ invalid_Gcipher = 0x12,
+ invalid_Pcipher = 0x13,
+ invalid_AKMP = 0x14,
+ unsup_RSNIEver = 0x15,
+ invalid_RSNIE = 0x16,
+ auth_802_1x_fail= 0x17,
+ ciper_reject = 0x18,
+
+ // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15.
+ QoS_unspec = 0x20, // 32
+ QAP_bandwidth = 0x21, // 33
+ poor_condition = 0x22, // 34
+ no_facility = 0x23, // 35
+ // Where is 36???
+ req_declined = 0x25, // 37
+ invalid_param = 0x26, // 38
+ req_not_honored= 0x27, // 39
+ TS_not_created = 0x2F, // 47
+ DL_not_allowed = 0x30, // 48
+ dest_not_exist = 0x31, // 49
+ dest_not_QSTA = 0x32, // 50
+};
+
+
+
+#define aSifsTime (((priv->ieee80211->current_network.mode == IEEE_A)||(priv->ieee80211->current_network.mode == IEEE_N_24G)||(priv->ieee80211->current_network.mode == IEEE_N_5G))? 16 : 10)
+
+#define MGMT_QUEUE_NUM 5
+
+#define IEEE_CMD_SET_WPA_PARAM 1
+#define IEEE_CMD_SET_WPA_IE 2
+#define IEEE_CMD_SET_ENCRYPTION 3
+#define IEEE_CMD_MLME 4
+
+#define IEEE_PARAM_WPA_ENABLED 1
+#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
+#define IEEE_PARAM_DROP_UNENCRYPTED 3
+#define IEEE_PARAM_PRIVACY_INVOKED 4
+#define IEEE_PARAM_AUTH_ALGS 5
+#define IEEE_PARAM_IEEE_802_1X 6
+//It should consistent with the driver_XXX.c
+// David, 2006.9.26
+#define IEEE_PARAM_WPAX_SELECT 7
+//Added for notify the encryption type selection
+// David, 2006.9.26
+#define IEEE_PROTO_WPA 1
+#define IEEE_PROTO_RSN 2
+//Added for notify the encryption type selection
+// David, 2006.9.26
+#define IEEE_WPAX_USEGROUP 0
+#define IEEE_WPAX_WEP40 1
+#define IEEE_WPAX_TKIP 2
+#define IEEE_WPAX_WRAP 3
+#define IEEE_WPAX_CCMP 4
+#define IEEE_WPAX_WEP104 5
+
+#define IEEE_KEY_MGMT_IEEE8021X 1
+#define IEEE_KEY_MGMT_PSK 2
+
+#define IEEE_MLME_STA_DEAUTH 1
+#define IEEE_MLME_STA_DISASSOC 2
+
+
+#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
+#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
+#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
+#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
+#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
+#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
+
+
+#define IEEE_CRYPT_ALG_NAME_LEN 16
+
+#define MAX_IE_LEN 0xff
+
+// added for kernel conflict
+#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
+#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
+#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
+#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl
+#define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
+#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl
+
+#define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
+
+#define ieee80211_tkip_null ieee80211_tkip_null_rsl
+
+#define ieee80211_wep_null ieee80211_wep_null_rsl
+
+#define free_ieee80211 free_ieee80211_rsl
+#define alloc_ieee80211 alloc_ieee80211_rsl
+
+#define ieee80211_rx ieee80211_rx_rsl
+#define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
+
+#define ieee80211_get_beacon ieee80211_get_beacon_rsl
+#define ieee80211_wake_queue ieee80211_wake_queue_rsl
+#define ieee80211_stop_queue ieee80211_stop_queue_rsl
+#define ieee80211_reset_queue ieee80211_reset_queue_rsl
+#define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl
+#define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
+#define ieee80211_is_shortslot ieee80211_is_shortslot_rsl
+#define ieee80211_is_54g ieee80211_is_54g_rsl
+#define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl
+#define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl
+#define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl
+#define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl
+#define notify_wx_assoc_event notify_wx_assoc_event_rsl
+#define SendDisassociation SendDisassociation_rsl
+#define ieee80211_disassociate ieee80211_disassociate_rsl
+#define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl
+#define ieee80211_stop_scan ieee80211_stop_scan_rsl
+#define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl
+#define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl
+#define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl
+
+#define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl
+#define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl
+#define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl
+#define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl
+#define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl
+#define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl
+#define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl
+#define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl
+#define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl
+#define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl
+#define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl
+#define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl
+#define ieee80211_wx_get_name ieee80211_wx_get_name_rsl
+#define ieee80211_wx_set_power ieee80211_wx_set_power_rsl
+#define ieee80211_wx_get_power ieee80211_wx_get_power_rsl
+#define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl
+#define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl
+#define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl
+
+#define ieee80211_txb_free ieee80211_txb_free_rsl
+
+#define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl
+#define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl
+#define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl
+#define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl
+#if WIRELESS_EXT >= 18
+#define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl
+#define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl
+#define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl
+#define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl
+#endif
+
+
+typedef struct ieee_param {
+ u32 cmd;
+ u8 sta_addr[ETH_ALEN];
+ union {
+ struct {
+ u8 name;
+ u32 value;
+ } wpa_param;
+ struct {
+ u32 len;
+ u8 reserved[32];
+ u8 data[0];
+ } wpa_ie;
+ struct{
+ int command;
+ int reason_code;
+ } mlme;
+ struct {
+ u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
+ u8 set_tx;
+ u32 err;
+ u8 idx;
+ u8 seq[8]; /* sequence counter (set: RX, get: TX) */
+ u16 key_len;
+ u8 key[0];
+ } crypt;
+ } u;
+}ieee_param;
+
+
+#if WIRELESS_EXT < 17
+#define IW_QUAL_QUAL_INVALID 0x10
+#define IW_QUAL_LEVEL_INVALID 0x20
+#define IW_QUAL_NOISE_INVALID 0x40
+#define IW_QUAL_QUAL_UPDATED 0x1
+#define IW_QUAL_LEVEL_UPDATED 0x2
+#define IW_QUAL_NOISE_UPDATED 0x4
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data)
+{
+ task->routine = func;
+ task->data = data;
+ //task->next = NULL;
+ INIT_LIST_HEAD(&task->list);
+ task->sync = 0;
+}
+#endif
+
+// linux under 2.6.9 release may not support it, so modify it for common use
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
+//#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
+#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
+static inline unsigned long msleep_interruptible_rsl(unsigned int msecs)
+{
+ unsigned long timeout = MSECS(msecs) + 1;
+
+ while (timeout) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ timeout = schedule_timeout(timeout);
+ }
+ return timeout;
+}
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
+static inline void msleep(unsigned int msecs)
+{
+ unsigned long timeout = MSECS(msecs) + 1;
+
+ while (timeout) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ timeout = schedule_timeout(timeout);
+ }
+}
+#endif
+#else
+#define MSECS(t) msecs_to_jiffies(t)
+#define msleep_interruptible_rsl msleep_interruptible
+#endif
+
+#define IEEE80211_DATA_LEN 2304
+/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
+ 6.2.1.1.2.
+
+ The figure in section 7.1.2 suggests a body size of up to 2312
+ bytes is allowed, which is a bit confusing, I suspect this
+ represents the 2304 bytes of real data, plus a possible 8 bytes of
+ WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
+#define IEEE80211_1ADDR_LEN 10
+#define IEEE80211_2ADDR_LEN 16
+#define IEEE80211_3ADDR_LEN 24
+#define IEEE80211_4ADDR_LEN 30
+#define IEEE80211_FCS_LEN 4
+#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
+#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
+#define IEEE80211_MGMT_HDR_LEN 24
+#define IEEE80211_DATA_HDR3_LEN 24
+#define IEEE80211_DATA_HDR4_LEN 30
+
+#define MIN_FRAG_THRESHOLD 256U
+#define MAX_FRAG_THRESHOLD 2346U
+
+
+/* Frame control field constants */
+#define IEEE80211_FCTL_VERS 0x0003
+#define IEEE80211_FCTL_FTYPE 0x000c
+#define IEEE80211_FCTL_STYPE 0x00f0
+#define IEEE80211_FCTL_FRAMETYPE 0x00fc
+#define IEEE80211_FCTL_TODS 0x0100
+#define IEEE80211_FCTL_FROMDS 0x0200
+#define IEEE80211_FCTL_DSTODS 0x0300 //added by david
+#define IEEE80211_FCTL_MOREFRAGS 0x0400
+#define IEEE80211_FCTL_RETRY 0x0800
+#define IEEE80211_FCTL_PM 0x1000
+#define IEEE80211_FCTL_MOREDATA 0x2000
+#define IEEE80211_FCTL_WEP 0x4000
+#define IEEE80211_FCTL_ORDER 0x8000
+
+#define IEEE80211_FTYPE_MGMT 0x0000
+#define IEEE80211_FTYPE_CTL 0x0004
+#define IEEE80211_FTYPE_DATA 0x0008
+
+/* management */
+#define IEEE80211_STYPE_ASSOC_REQ 0x0000
+#define IEEE80211_STYPE_ASSOC_RESP 0x0010
+#define IEEE80211_STYPE_REASSOC_REQ 0x0020
+#define IEEE80211_STYPE_REASSOC_RESP 0x0030
+#define IEEE80211_STYPE_PROBE_REQ 0x0040
+#define IEEE80211_STYPE_PROBE_RESP 0x0050
+#define IEEE80211_STYPE_BEACON 0x0080
+#define IEEE80211_STYPE_ATIM 0x0090
+#define IEEE80211_STYPE_DISASSOC 0x00A0
+#define IEEE80211_STYPE_AUTH 0x00B0
+#define IEEE80211_STYPE_DEAUTH 0x00C0
+#define IEEE80211_STYPE_MANAGE_ACT 0x00D0
+
+/* control */
+#define IEEE80211_STYPE_PSPOLL 0x00A0
+#define IEEE80211_STYPE_RTS 0x00B0
+#define IEEE80211_STYPE_CTS 0x00C0
+#define IEEE80211_STYPE_ACK 0x00D0
+#define IEEE80211_STYPE_CFEND 0x00E0
+#define IEEE80211_STYPE_CFENDACK 0x00F0
+#define IEEE80211_STYPE_BLOCKACK 0x0094
+
+/* data */
+#define IEEE80211_STYPE_DATA 0x0000
+#define IEEE80211_STYPE_DATA_CFACK 0x0010
+#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
+#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
+#define IEEE80211_STYPE_NULLFUNC 0x0040
+#define IEEE80211_STYPE_CFACK 0x0050
+#define IEEE80211_STYPE_CFPOLL 0x0060
+#define IEEE80211_STYPE_CFACKPOLL 0x0070
+#define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2
+#define IEEE80211_STYPE_QOS_NULL 0x00C0
+
+#define IEEE80211_SCTL_FRAG 0x000F
+#define IEEE80211_SCTL_SEQ 0xFFF0
+
+/* QOS control */
+#define IEEE80211_QCTL_TID 0x000F
+
+#define FC_QOS_BIT BIT7
+#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false )
+#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) )
+//added by wb. Is this right?
+#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA))
+#define Frame_Order(pframe) (*(u16*)pframe&IEEE80211_FCTL_ORDER)
+#define SN_LESS(a, b) (((a-b)&0x800)!=0)
+#define SN_EQUAL(a, b) (a == b)
+#define MAX_DEV_ADDR_SIZE 8
+typedef enum _ACT_CATEGORY{
+ ACT_CAT_QOS = 1,
+ ACT_CAT_DLS = 2,
+ ACT_CAT_BA = 3,
+ ACT_CAT_HT = 7,
+ ACT_CAT_WMM = 17,
+} ACT_CATEGORY, *PACT_CATEGORY;
+
+typedef enum _TS_ACTION{
+ ACT_ADDTSREQ = 0,
+ ACT_ADDTSRSP = 1,
+ ACT_DELTS = 2,
+ ACT_SCHEDULE = 3,
+} TS_ACTION, *PTS_ACTION;
+
+typedef enum _BA_ACTION{
+ ACT_ADDBAREQ = 0,
+ ACT_ADDBARSP = 1,
+ ACT_DELBA = 2,
+} BA_ACTION, *PBA_ACTION;
+
+typedef enum _InitialGainOpType{
+ IG_Backup=0,
+ IG_Restore,
+ IG_Max
+}InitialGainOpType;
+//added by amy for LED 090319
+//================================================================================
+// LED customization.
+//================================================================================
+typedef enum _LED_CTL_MODE{
+ LED_CTL_POWER_ON = 1,
+ LED_CTL_LINK = 2,
+ LED_CTL_NO_LINK = 3,
+ LED_CTL_TX = 4,
+ LED_CTL_RX = 5,
+ LED_CTL_SITE_SURVEY = 6,
+ LED_CTL_POWER_OFF = 7,
+ LED_CTL_START_TO_LINK = 8,
+ LED_CTL_START_WPS = 9,
+ LED_CTL_STOP_WPS = 10,
+ LED_CTL_START_WPS_BOTTON = 11, //added for runtop
+}LED_CTL_MODE;
+
+/* debug macros */
+#define CONFIG_IEEE80211_DEBUG
+#ifdef CONFIG_IEEE80211_DEBUG
+extern u32 ieee80211_debug_level;
+#define IEEE80211_DEBUG(level, fmt, args...) \
+do { if (ieee80211_debug_level & (level)) \
+ printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
+//wb added to debug out data buf
+//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
+#define IEEE80211_DEBUG_DATA(level, data, datalen) \
+ do{ if ((ieee80211_debug_level & (level)) == (level)) \
+ { \
+ int i; \
+ u8* pdata = (u8*) data; \
+ printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \
+ for(i=0; i<(int)(datalen); i++) \
+ { \
+ printk("%2x ", pdata[i]); \
+ if ((i+1)%16 == 0) printk("\n"); \
+ } \
+ printk("\n"); \
+ } \
+ } while (0)
+#else
+#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
+#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0)
+#endif /* CONFIG_IEEE80211_DEBUG */
+
+/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
+
+#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
+
+/*
+ * To use the debug system;
+ *
+ * If you are defining a new debug classification, simply add it to the #define
+ * list here in the form of:
+ *
+ * #define IEEE80211_DL_xxxx VALUE
+ *
+ * shifting value to the left one bit from the previous entry. xxxx should be
+ * the name of the classification (for example, WEP)
+ *
+ * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
+ * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
+ * to send output to that classification.
+ *
+ * To add your debug level to the list of levels seen when you perform
+ *
+ * % cat /proc/net/ipw/debug_level
+ *
+ * you simply need to add your entry to the ipw_debug_levels array.
+ *
+ * If you do not see debug_level in /proc/net/ipw then you do not have
+ * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
+ *
+ */
+
+#define IEEE80211_DL_INFO (1<<0)
+#define IEEE80211_DL_WX (1<<1)
+#define IEEE80211_DL_SCAN (1<<2)
+#define IEEE80211_DL_STATE (1<<3)
+#define IEEE80211_DL_MGMT (1<<4)
+#define IEEE80211_DL_FRAG (1<<5)
+#define IEEE80211_DL_EAP (1<<6)
+#define IEEE80211_DL_DROP (1<<7)
+
+#define IEEE80211_DL_TX (1<<8)
+#define IEEE80211_DL_RX (1<<9)
+
+#define IEEE80211_DL_HT (1<<10) //HT
+#define IEEE80211_DL_BA (1<<11) //ba
+#define IEEE80211_DL_TS (1<<12) //TS
+#define IEEE80211_DL_QOS (1<<13)
+#define IEEE80211_DL_REORDER (1<<14)
+#define IEEE80211_DL_IOT (1<<15)
+#define IEEE80211_DL_IPS (1<<16)
+#define IEEE80211_DL_TRACE (1<<29) //trace function, need to user net_ratelimit() together in order not to print too much to the screen
+#define IEEE80211_DL_DATA (1<<30) //use this flag to control whether print data buf out.
+#define IEEE80211_DL_ERR (1<<31) //always open
+#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
+#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
+#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
+
+#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
+#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
+#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
+#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
+#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
+#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
+#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
+#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
+#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
+#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
+
+#ifdef CONFIG_IEEE80211_DEBUG
+/* Added by Annie, 2005-11-22. */
+#define MAX_STR_LEN 64
+/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/
+#define PRINTABLE(_ch) (_ch>'!' && _ch<'~')
+#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
+ if((_Comp) & level) \
+ { \
+ int __i; \
+ u8 buffer[MAX_STR_LEN]; \
+ int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
+ memset(buffer, 0, MAX_STR_LEN); \
+ memcpy(buffer, (u8 *)_Ptr, length ); \
+ for( __i=0; __i<MAX_STR_LEN; __i++ ) \
+ { \
+ if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
+ } \
+ buffer[length] = '\0'; \
+ printk("Rtl819x: "); \
+ printk(_TitleString); \
+ printk(": %d, <%s>\n", _Len, buffer); \
+ }
+#else
+#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) do {} while (0)
+#endif
+
+#include <linux/netdevice.h>
+#include <linux/if_arp.h> /* ARPHRD_ETHER */
+
+#ifndef WIRELESS_SPY
+#define WIRELESS_SPY // enable iwspy support
+#endif
+#include <net/iw_handler.h> // new driver API
+
+#ifndef ETH_P_PAE
+#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
+#endif /* ETH_P_PAE */
+
+#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
+
+#ifndef ETH_P_80211_RAW
+#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
+#endif
+
+/* IEEE 802.11 defines */
+
+#define P80211_OUI_LEN 3
+
+struct ieee80211_snap_hdr {
+
+ u8 dsap; /* always 0xAA */
+ u8 ssap; /* always 0xAA */
+ u8 ctrl; /* always 0x03 */
+ u8 oui[P80211_OUI_LEN]; /* organizational universal id */
+
+} __attribute__ ((packed));
+
+#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
+
+#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
+#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
+#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
+
+#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
+#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
+#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
+
+/* Authentication algorithms */
+#define WLAN_AUTH_OPEN 0
+#define WLAN_AUTH_SHARED_KEY 1
+#define WLAN_AUTH_LEAP 2
+
+#define WLAN_AUTH_CHALLENGE_LEN 128
+
+#define WLAN_CAPABILITY_BSS (1<<0)
+#define WLAN_CAPABILITY_IBSS (1<<1)
+#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
+#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
+#define WLAN_CAPABILITY_PRIVACY (1<<4)
+#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
+#define WLAN_CAPABILITY_PBCC (1<<6)
+#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
+#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
+#define WLAN_CAPABILITY_QOS (1<<9)
+#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
+#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
+
+/* 802.11g ERP information element */
+#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
+#define WLAN_ERP_USE_PROTECTION (1<<1)
+#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
+
+/* Status codes */
+enum ieee80211_statuscode {
+ WLAN_STATUS_SUCCESS = 0,
+ WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
+ WLAN_STATUS_CAPS_UNSUPPORTED = 10,
+ WLAN_STATUS_REASSOC_NO_ASSOC = 11,
+ WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
+ WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
+ WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
+ WLAN_STATUS_CHALLENGE_FAIL = 15,
+ WLAN_STATUS_AUTH_TIMEOUT = 16,
+ WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
+ WLAN_STATUS_ASSOC_DENIED_RATES = 18,
+ /* 802.11b */
+ WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
+ WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
+ WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
+ /* 802.11h */
+ WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
+ WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
+ WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
+ /* 802.11g */
+ WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
+ WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
+ /* 802.11i */
+ WLAN_STATUS_INVALID_IE = 40,
+ WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
+ WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
+ WLAN_STATUS_INVALID_AKMP = 43,
+ WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
+ WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
+ WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
+};
+
+/* Reason codes */
+enum ieee80211_reasoncode {
+ WLAN_REASON_UNSPECIFIED = 1,
+ WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
+ WLAN_REASON_DEAUTH_LEAVING = 3,
+ WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
+ WLAN_REASON_DISASSOC_AP_BUSY = 5,
+ WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
+ WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
+ WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
+ WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
+ /* 802.11h */
+ WLAN_REASON_DISASSOC_BAD_POWER = 10,
+ WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
+ /* 802.11i */
+ WLAN_REASON_INVALID_IE = 13,
+ WLAN_REASON_MIC_FAILURE = 14,
+ WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
+ WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
+ WLAN_REASON_IE_DIFFERENT = 17,
+ WLAN_REASON_INVALID_GROUP_CIPHER = 18,
+ WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
+ WLAN_REASON_INVALID_AKMP = 20,
+ WLAN_REASON_UNSUPP_RSN_VERSION = 21,
+ WLAN_REASON_INVALID_RSN_IE_CAP = 22,
+ WLAN_REASON_IEEE8021X_FAILED = 23,
+ WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
+};
+
+#define IEEE80211_STATMASK_SIGNAL (1<<0)
+#define IEEE80211_STATMASK_RSSI (1<<1)
+#define IEEE80211_STATMASK_NOISE (1<<2)
+#define IEEE80211_STATMASK_RATE (1<<3)
+#define IEEE80211_STATMASK_WEMASK 0x7
+
+#define IEEE80211_CCK_MODULATION (1<<0)
+#define IEEE80211_OFDM_MODULATION (1<<1)
+
+#define IEEE80211_24GHZ_BAND (1<<0)
+#define IEEE80211_52GHZ_BAND (1<<1)
+
+#define IEEE80211_CCK_RATE_LEN 4
+#define IEEE80211_CCK_RATE_1MB 0x02
+#define IEEE80211_CCK_RATE_2MB 0x04
+#define IEEE80211_CCK_RATE_5MB 0x0B
+#define IEEE80211_CCK_RATE_11MB 0x16
+#define IEEE80211_OFDM_RATE_LEN 8
+#define IEEE80211_OFDM_RATE_6MB 0x0C
+#define IEEE80211_OFDM_RATE_9MB 0x12
+#define IEEE80211_OFDM_RATE_12MB 0x18
+#define IEEE80211_OFDM_RATE_18MB 0x24
+#define IEEE80211_OFDM_RATE_24MB 0x30
+#define IEEE80211_OFDM_RATE_36MB 0x48
+#define IEEE80211_OFDM_RATE_48MB 0x60
+#define IEEE80211_OFDM_RATE_54MB 0x6C
+#define IEEE80211_BASIC_RATE_MASK 0x80
+
+#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
+#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
+#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
+#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
+#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
+#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
+#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
+#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
+#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
+#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
+#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
+#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
+
+#define IEEE80211_CCK_RATES_MASK 0x0000000F
+#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
+ IEEE80211_CCK_RATE_2MB_MASK)
+#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
+ IEEE80211_CCK_RATE_5MB_MASK | \
+ IEEE80211_CCK_RATE_11MB_MASK)
+
+#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
+#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
+ IEEE80211_OFDM_RATE_12MB_MASK | \
+ IEEE80211_OFDM_RATE_24MB_MASK)
+#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
+ IEEE80211_OFDM_RATE_9MB_MASK | \
+ IEEE80211_OFDM_RATE_18MB_MASK | \
+ IEEE80211_OFDM_RATE_36MB_MASK | \
+ IEEE80211_OFDM_RATE_48MB_MASK | \
+ IEEE80211_OFDM_RATE_54MB_MASK)
+#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
+ IEEE80211_CCK_DEFAULT_RATES_MASK)
+
+#define IEEE80211_NUM_OFDM_RATES 8
+#define IEEE80211_NUM_CCK_RATES 4
+#define IEEE80211_OFDM_SHIFT_MASK_A 4
+
+
+/* this is stolen and modified from the madwifi driver*/
+#define IEEE80211_FC0_TYPE_MASK 0x0c
+#define IEEE80211_FC0_TYPE_DATA 0x08
+#define IEEE80211_FC0_SUBTYPE_MASK 0xB0
+#define IEEE80211_FC0_SUBTYPE_QOS 0x80
+
+#define IEEE80211_QOS_HAS_SEQ(fc) \
+ (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
+ (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
+
+/* this is stolen from ipw2200 driver */
+#define IEEE_IBSS_MAC_HASH_SIZE 31
+struct ieee_ibss_seq {
+ u8 mac[ETH_ALEN];
+ u16 seq_num[17];
+ u16 frag_num[17];
+ unsigned long packet_time[17];
+ struct list_head list;
+};
+
+/* NOTE: This data is for statistical purposes; not all hardware provides this
+ * information for frames received. Not setting these will not cause
+ * any adverse affects. */
+struct ieee80211_rx_stats {
+#if 1
+ u32 mac_time[2];
+ s8 rssi;
+ u8 signal;
+ u8 noise;
+ u16 rate; /* in 100 kbps */
+ u8 received_channel;
+ u8 control;
+ u8 mask;
+ u8 freq;
+ u16 len;
+ u64 tsf;
+ u32 beacon_time;
+ u8 nic_type;
+ u16 Length;
+ // u8 DataRate; // In 0.5 Mbps
+ u8 SignalQuality; // in 0-100 index.
+ s32 RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation.
+ s8 RxPower; // in dBm Translate from PWdB
+ u8 SignalStrength; // in 0-100 index.
+ u16 bHwError:1;
+ u16 bCRC:1;
+ u16 bICV:1;
+ u16 bShortPreamble:1;
+ u16 Antenna:1; //for rtl8185
+ u16 Decrypted:1; //for rtl8185, rtl8187
+ u16 Wakeup:1; //for rtl8185
+ u16 Reserved0:1; //for rtl8185
+ u8 AGC;
+ u32 TimeStampLow;
+ u32 TimeStampHigh;
+ bool bShift;
+ bool bIsQosData; // Added by Annie, 2005-12-22.
+ u8 UserPriority;
+
+ //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //1Attention Please!!!<11n or 8190 specific code should be put below this line>
+ //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ u8 RxDrvInfoSize;
+ u8 RxBufShift;
+ bool bIsAMPDU;
+ bool bFirstMPDU;
+ bool bContainHTC;
+ bool RxIs40MHzPacket;
+ u32 RxPWDBAll;
+ u8 RxMIMOSignalStrength[4]; // in 0~100 index
+ s8 RxMIMOSignalQuality[2];
+ bool bPacketMatchBSSID;
+ bool bIsCCK;
+ bool bPacketToSelf;
+ //added by amy
+ u8* virtual_address;
+ u16 packetlength; // Total packet length: Must equal to sum of all FragLength
+ u16 fraglength; // FragLength should equal to PacketLength in non-fragment case
+ u16 fragoffset; // Data offset for this fragment
+ u16 ntotalfrag;
+ bool bisrxaggrsubframe;
+ bool bPacketBeacon; //cosa add for rssi
+ bool bToSelfBA; //cosa add for rssi
+ char cck_adc_pwdb[4]; //cosa add for rx path selection
+ u16 Seq_Num;
+ u8 nTotalAggPkt; // Number of aggregated packets.
+#endif
+
+};
+
+/* IEEE 802.11 requires that STA supports concurrent reception of at least
+ * three fragmented frames. This define can be increased to support more
+ * concurrent frames, but it should be noted that each entry can consume about
+ * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
+#define IEEE80211_FRAG_CACHE_LEN 4
+
+struct ieee80211_frag_entry {
+ unsigned long first_frag_time;
+ unsigned int seq;
+ unsigned int last_frag;
+ struct sk_buff *skb;
+ u8 src_addr[ETH_ALEN];
+ u8 dst_addr[ETH_ALEN];
+};
+
+struct ieee80211_stats {
+ unsigned int tx_unicast_frames;
+ unsigned int tx_multicast_frames;
+ unsigned int tx_fragments;
+ unsigned int tx_unicast_octets;
+ unsigned int tx_multicast_octets;
+ unsigned int tx_deferred_transmissions;
+ unsigned int tx_single_retry_frames;
+ unsigned int tx_multiple_retry_frames;
+ unsigned int tx_retry_limit_exceeded;
+ unsigned int tx_discards;
+ unsigned int rx_unicast_frames;
+ unsigned int rx_multicast_frames;
+ unsigned int rx_fragments;
+ unsigned int rx_unicast_octets;
+ unsigned int rx_multicast_octets;
+ unsigned int rx_fcs_errors;
+ unsigned int rx_discards_no_buffer;
+ unsigned int tx_discards_wrong_sa;
+ unsigned int rx_discards_undecryptable;
+ unsigned int rx_message_in_msg_fragments;
+ unsigned int rx_message_in_bad_msg_fragments;
+};
+
+struct ieee80211_device;
+
+#include "ieee80211_crypt.h"
+
+#define SEC_KEY_1 (1<<0)
+#define SEC_KEY_2 (1<<1)
+#define SEC_KEY_3 (1<<2)
+#define SEC_KEY_4 (1<<3)
+#define SEC_ACTIVE_KEY (1<<4)
+#define SEC_AUTH_MODE (1<<5)
+#define SEC_UNICAST_GROUP (1<<6)
+#define SEC_LEVEL (1<<7)
+#define SEC_ENABLED (1<<8)
+#define SEC_ENCRYPT (1<<9)
+
+#define SEC_LEVEL_0 0 /* None */
+#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
+#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
+#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
+#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
+
+#define SEC_ALG_NONE 0
+#define SEC_ALG_WEP 1
+#define SEC_ALG_TKIP 2
+#define SEC_ALG_CCMP 3
+
+#define WEP_KEYS 4
+#define WEP_KEY_LEN 13
+#define SCM_KEY_LEN 32
+#define SCM_TEMPORAL_KEY_LENGTH 16
+
+struct ieee80211_security {
+ u16 active_key:2,
+ enabled:1,
+ auth_mode:2,
+ auth_algo:4,
+ unicast_uses_group:1,
+ encrypt:1;
+ u8 key_sizes[WEP_KEYS];
+ u8 keys[WEP_KEYS][SCM_KEY_LEN];
+ u8 level;
+ u16 flags;
+} __attribute__ ((packed));
+
+
+/*
+ 802.11 data frame from AP
+ ,-------------------------------------------------------------------.
+Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
+ |------|------|---------|---------|---------|------|---------|------|
+Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
+ | | tion | (BSSID) | | | ence | data | |
+ `-------------------------------------------------------------------'
+Total: 28-2340 bytes
+*/
+
+/* Management Frame Information Element Types */
+enum ieee80211_mfie {
+ MFIE_TYPE_SSID = 0,
+ MFIE_TYPE_RATES = 1,
+ MFIE_TYPE_FH_SET = 2,
+ MFIE_TYPE_DS_SET = 3,
+ MFIE_TYPE_CF_SET = 4,
+ MFIE_TYPE_TIM = 5,
+ MFIE_TYPE_IBSS_SET = 6,
+ MFIE_TYPE_COUNTRY = 7,
+ MFIE_TYPE_HOP_PARAMS = 8,
+ MFIE_TYPE_HOP_TABLE = 9,
+ MFIE_TYPE_REQUEST = 10,
+ MFIE_TYPE_CHALLENGE = 16,
+ MFIE_TYPE_POWER_CONSTRAINT = 32,
+ MFIE_TYPE_POWER_CAPABILITY = 33,
+ MFIE_TYPE_TPC_REQUEST = 34,
+ MFIE_TYPE_TPC_REPORT = 35,
+ MFIE_TYPE_SUPP_CHANNELS = 36,
+ MFIE_TYPE_CSA = 37,
+ MFIE_TYPE_MEASURE_REQUEST = 38,
+ MFIE_TYPE_MEASURE_REPORT = 39,
+ MFIE_TYPE_QUIET = 40,
+ MFIE_TYPE_IBSS_DFS = 41,
+ MFIE_TYPE_ERP = 42,
+ MFIE_TYPE_RSN = 48,
+ MFIE_TYPE_RATES_EX = 50,
+ MFIE_TYPE_HT_CAP= 45,
+ MFIE_TYPE_HT_INFO= 61,
+ MFIE_TYPE_AIRONET=133,
+ MFIE_TYPE_GENERIC = 221,
+ MFIE_TYPE_QOS_PARAMETER = 222,
+};
+
+/* Minimal header; can be used for passing 802.11 frames with sufficient
+ * information to determine what type of underlying data type is actually
+ * stored in the data. */
+struct ieee80211_hdr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_1addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_2addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_3addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_4addr {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 addr4[ETH_ALEN];
+ u8 payload[0];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_3addrqos {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 payload[0];
+ __le16 qos_ctl;
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_4addrqos {
+ __le16 frame_ctl;
+ __le16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ __le16 seq_ctl;
+ u8 addr4[ETH_ALEN];
+ u8 payload[0];
+ __le16 qos_ctl;
+} __attribute__ ((packed));
+
+struct ieee80211_info_element {
+ u8 id;
+ u8 len;
+ u8 data[0];
+} __attribute__ ((packed));
+
+struct ieee80211_authentication {
+ struct ieee80211_hdr_3addr header;
+ __le16 algorithm;
+ __le16 transaction;
+ __le16 status;
+ /*challenge*/
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_disassoc {
+ struct ieee80211_hdr_3addr header;
+ __le16 reason;
+} __attribute__ ((packed));
+
+struct ieee80211_probe_request {
+ struct ieee80211_hdr_3addr header;
+ /* SSID, supported rates */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_probe_response {
+ struct ieee80211_hdr_3addr header;
+ u32 time_stamp[2];
+ __le16 beacon_interval;
+ __le16 capability;
+ /* SSID, supported rates, FH params, DS params,
+ * CF params, IBSS params, TIM (if beacon), RSN */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+/* Alias beacon for probe_response */
+#define ieee80211_beacon ieee80211_probe_response
+
+struct ieee80211_assoc_request_frame {
+ struct ieee80211_hdr_3addr header;
+ __le16 capability;
+ __le16 listen_interval;
+ /* SSID, supported rates, RSN */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_reassoc_request_frame {
+ struct ieee80211_hdr_3addr header;
+ __le16 capability;
+ __le16 listen_interval;
+ u8 current_ap[ETH_ALEN];
+ /* SSID, supported rates, RSN */
+ struct ieee80211_info_element info_element[0];
+} __attribute__ ((packed));
+
+struct ieee80211_assoc_response_frame {
+ struct ieee80211_hdr_3addr header;
+ __le16 capability;
+ __le16 status;
+ __le16 aid;
+ struct ieee80211_info_element info_element[0]; /* supported rates */
+} __attribute__ ((packed));
+
+struct ieee80211_txb {
+ u8 nr_frags;
+ u8 encrypted;
+ u8 queue_index;
+ u8 rts_included;
+ u16 reserved;
+ __le16 frag_size;
+ __le16 payload_size;
+ struct sk_buff *fragments[0];
+};
+
+#define MAX_TX_AGG_COUNT 16
+struct ieee80211_drv_agg_txb {
+ u8 nr_drv_agg_frames;
+ struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
+}__attribute__((packed));
+
+#define MAX_SUBFRAME_COUNT 64
+struct ieee80211_rxb {
+ u8 nr_subframes;
+ struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
+ u8 dst[ETH_ALEN];
+ u8 src[ETH_ALEN];
+}__attribute__((packed));
+
+typedef union _frameqos {
+ u16 shortdata;
+ u8 chardata[2];
+ struct {
+ u16 tid:4;
+ u16 eosp:1;
+ u16 ack_policy:2;
+ u16 reserved:1;
+ u16 txop:8;
+ }field;
+}frameqos,*pframeqos;
+
+/* SWEEP TABLE ENTRIES NUMBER*/
+#define MAX_SWEEP_TAB_ENTRIES 42
+#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
+/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
+ * only use 8, and then use extended rates for the remaining supported
+ * rates. Other APs, however, stick all of their supported rates on the
+ * main rates information element... */
+#define MAX_RATES_LENGTH ((u8)12)
+#define MAX_RATES_EX_LENGTH ((u8)16)
+#define MAX_NETWORK_COUNT 128
+
+#define MAX_CHANNEL_NUMBER 161
+#define IEEE80211_SOFTMAC_SCAN_TIME 100
+//(HZ / 2)
+#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
+
+#define CRC_LENGTH 4U
+
+#define MAX_WPA_IE_LEN 64
+
+#define NETWORK_EMPTY_ESSID (1<<0)
+#define NETWORK_HAS_OFDM (1<<1)
+#define NETWORK_HAS_CCK (1<<2)
+
+/* QoS structure */
+#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
+#define NETWORK_HAS_QOS_INFORMATION (1<<4)
+#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
+ NETWORK_HAS_QOS_INFORMATION)
+/* 802.11h */
+#define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
+#define NETWORK_HAS_CSA (1<<6)
+#define NETWORK_HAS_QUIET (1<<7)
+#define NETWORK_HAS_IBSS_DFS (1<<8)
+#define NETWORK_HAS_TPC_REPORT (1<<9)
+
+#define NETWORK_HAS_ERP_VALUE (1<<10)
+
+#define QOS_QUEUE_NUM 4
+#define QOS_OUI_LEN 3
+#define QOS_OUI_TYPE 2
+#define QOS_ELEMENT_ID 221
+#define QOS_OUI_INFO_SUB_TYPE 0
+#define QOS_OUI_PARAM_SUB_TYPE 1
+#define QOS_VERSION_1 1
+#define QOS_AIFSN_MIN_VALUE 2
+#if 1
+struct ieee80211_qos_information_element {
+ u8 elementID;
+ u8 length;
+ u8 qui[QOS_OUI_LEN];
+ u8 qui_type;
+ u8 qui_subtype;
+ u8 version;
+ u8 ac_info;
+} __attribute__ ((packed));
+
+struct ieee80211_qos_ac_parameter {
+ u8 aci_aifsn;
+ u8 ecw_min_max;
+ __le16 tx_op_limit;
+} __attribute__ ((packed));
+
+struct ieee80211_qos_parameter_info {
+ struct ieee80211_qos_information_element info_element;
+ u8 reserved;
+ struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
+} __attribute__ ((packed));
+
+struct ieee80211_qos_parameters {
+ __le16 cw_min[QOS_QUEUE_NUM];
+ __le16 cw_max[QOS_QUEUE_NUM];
+ u8 aifs[QOS_QUEUE_NUM];
+ u8 flag[QOS_QUEUE_NUM];
+ __le16 tx_op_limit[QOS_QUEUE_NUM];
+} __attribute__ ((packed));
+
+struct ieee80211_qos_data {
+ struct ieee80211_qos_parameters parameters;
+ int active;
+ int supported;
+ u8 param_count;
+ u8 old_param_count;
+};
+
+struct ieee80211_tim_parameters {
+ u8 tim_count;
+ u8 tim_period;
+} __attribute__ ((packed));
+
+//#else
+struct ieee80211_wmm_ac_param {
+ u8 ac_aci_acm_aifsn;
+ u8 ac_ecwmin_ecwmax;
+ u16 ac_txop_limit;
+};
+
+struct ieee80211_wmm_ts_info {
+ u8 ac_dir_tid;
+ u8 ac_up_psb;
+ u8 reserved;
+} __attribute__ ((packed));
+
+struct ieee80211_wmm_tspec_elem {
+ struct ieee80211_wmm_ts_info ts_info;
+ u16 norm_msdu_size;
+ u16 max_msdu_size;
+ u32 min_serv_inter;
+ u32 max_serv_inter;
+ u32 inact_inter;
+ u32 suspen_inter;
+ u32 serv_start_time;
+ u32 min_data_rate;
+ u32 mean_data_rate;
+ u32 peak_data_rate;
+ u32 max_burst_size;
+ u32 delay_bound;
+ u32 min_phy_rate;
+ u16 surp_band_allow;
+ u16 medium_time;
+}__attribute__((packed));
+#endif
+enum eap_type {
+ EAP_PACKET = 0,
+ EAPOL_START,
+ EAPOL_LOGOFF,
+ EAPOL_KEY,
+ EAPOL_ENCAP_ASF_ALERT
+};
+
+static const char *eap_types[] = {
+ [EAP_PACKET] = "EAP-Packet",
+ [EAPOL_START] = "EAPOL-Start",
+ [EAPOL_LOGOFF] = "EAPOL-Logoff",
+ [EAPOL_KEY] = "EAPOL-Key",
+ [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
+};
+
+static inline const char *eap_get_type(int type)
+{
+ return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
+}
+//added by amy for reorder
+static inline u8 Frame_QoSTID(u8* buf)
+{
+ struct ieee80211_hdr_3addr *hdr;
+ u16 fc;
+ hdr = (struct ieee80211_hdr_3addr *)buf;
+ fc = le16_to_cpu(hdr->frame_ctl);
+ return (u8)((frameqos*)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid;
+}
+
+//added by amy for reorder
+
+struct eapol {
+ u8 snap[6];
+ u16 ethertype;
+ u8 version;
+ u8 type;
+ u16 length;
+} __attribute__ ((packed));
+
+struct ieee80211_softmac_stats{
+ unsigned int rx_ass_ok;
+ unsigned int rx_ass_err;
+ unsigned int rx_probe_rq;
+ unsigned int tx_probe_rs;
+ unsigned int tx_beacons;
+ unsigned int rx_auth_rq;
+ unsigned int rx_auth_rs_ok;
+ unsigned int rx_auth_rs_err;
+ unsigned int tx_auth_rq;
+ unsigned int no_auth_rs;
+ unsigned int no_ass_rs;
+ unsigned int tx_ass_rq;
+ unsigned int rx_ass_rq;
+ unsigned int tx_probe_rq;
+ unsigned int reassoc;
+ unsigned int swtxstop;
+ unsigned int swtxawake;
+ unsigned char CurrentShowTxate;
+ unsigned char last_packet_rate;
+ unsigned int txretrycount;
+};
+
+#define BEACON_PROBE_SSID_ID_POSITION 12
+
+struct ieee80211_info_element_hdr {
+ u8 id;
+ u8 len;
+} __attribute__ ((packed));
+
+/*
+ * These are the data types that can make up management packets
+ *
+ u16 auth_algorithm;
+ u16 auth_sequence;
+ u16 beacon_interval;
+ u16 capability;
+ u8 current_ap[ETH_ALEN];
+ u16 listen_interval;
+ struct {
+ u16 association_id:14, reserved:2;
+ } __attribute__ ((packed));
+ u32 time_stamp[2];
+ u16 reason;
+ u16 status;
+*/
+
+#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
+#define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps
+
+enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
+#define MAX_SP_Len (WMM_all_frame << 4)
+#define IEEE80211_QOS_TID 0x0f
+#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
+
+#define IEEE80211_DTIM_MBCAST 4
+#define IEEE80211_DTIM_UCAST 2
+#define IEEE80211_DTIM_VALID 1
+#define IEEE80211_DTIM_INVALID 0
+
+#define IEEE80211_PS_DISABLED 0
+#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
+#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
+
+//added by David for QoS 2006/6/30
+//#define WMM_Hang_8187
+#ifdef WMM_Hang_8187
+#undef WMM_Hang_8187
+#endif
+
+#define WME_AC_BK 0x00
+#define WME_AC_BE 0x01
+#define WME_AC_VI 0x02
+#define WME_AC_VO 0x03
+#define WME_ACI_MASK 0x03
+#define WME_AIFSN_MASK 0x03
+#define WME_AC_PRAM_LEN 16
+
+#define MAX_RECEIVE_BUFFER_SIZE 9100
+
+//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
+//#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
+#if 1
+#define UP2AC(up) ( \
+ ((up) < 1) ? WME_AC_BE : \
+ ((up) < 3) ? WME_AC_BK : \
+ ((up) < 4) ? WME_AC_BE : \
+ ((up) < 6) ? WME_AC_VI : \
+ WME_AC_VO)
+#endif
+//AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
+#define AC2UP(_ac) ( \
+ ((_ac) == WME_AC_VO) ? 6 : \
+ ((_ac) == WME_AC_VI) ? 5 : \
+ ((_ac) == WME_AC_BK) ? 1 : \
+ 0)
+
+#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
+#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/
+
+struct ether_header {
+ u8 ether_dhost[ETHER_ADDR_LEN];
+ u8 ether_shost[ETHER_ADDR_LEN];
+ u16 ether_type;
+} __attribute__((packed));
+
+#ifndef ETHERTYPE_PAE
+#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
+#endif
+#ifndef ETHERTYPE_IP
+#define ETHERTYPE_IP 0x0800 /* IP protocol */
+#endif
+
+typedef struct _bss_ht{
+
+ bool support_ht;
+
+ // HT related elements
+ u8 ht_cap_buf[32];
+ u16 ht_cap_len;
+ u8 ht_info_buf[32];
+ u16 ht_info_len;
+
+ HT_SPEC_VER ht_spec_ver;
+ //HT_CAPABILITY_ELE bdHTCapEle;
+ //HT_INFORMATION_ELE bdHTInfoEle;
+
+ bool aggregation;
+ bool long_slot_time;
+}bss_ht, *pbss_ht;
+
+typedef enum _erp_t{
+ ERP_NonERPpresent = 0x01,
+ ERP_UseProtection = 0x02,
+ ERP_BarkerPreambleMode = 0x04,
+} erp_t;
+
+
+struct ieee80211_network {
+ /* These entries are used to identify a unique network */
+ u8 bssid[ETH_ALEN];
+ u8 channel;
+ /* Ensure null-terminated for any debug msgs */
+ u8 ssid[IW_ESSID_MAX_SIZE + 1];
+ u8 ssid_len;
+#if 1
+ struct ieee80211_qos_data qos_data;
+#else
+ // Qos related. Added by Annie, 2005-11-01.
+ BSS_QOS BssQos;
+#endif
+
+ //added by amy for LEAP
+ bool bWithAironetIE;
+ bool bCkipSupported;
+ bool bCcxRmEnable;
+ u16 CcxRmState[2];
+ // CCXv4 S59, MBSSID.
+ bool bMBssidValid;
+ u8 MBssidMask;
+ u8 MBssid[6];
+ // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20.
+ bool bWithCcxVerNum;
+ u8 BssCcxVerNumber;
+ /* These are network statistics */
+ struct ieee80211_rx_stats stats;
+ u16 capability;
+ u8 rates[MAX_RATES_LENGTH];
+ u8 rates_len;
+ u8 rates_ex[MAX_RATES_EX_LENGTH];
+ u8 rates_ex_len;
+ unsigned long last_scanned;
+ u8 mode;
+ u32 flags;
+ u32 last_associate;
+ u32 time_stamp[2];
+ u16 beacon_interval;
+ u16 listen_interval;
+ u16 atim_window;
+ u8 erp_value;
+ u8 wpa_ie[MAX_WPA_IE_LEN];
+ size_t wpa_ie_len;
+ u8 rsn_ie[MAX_WPA_IE_LEN];
+ size_t rsn_ie_len;
+
+ struct ieee80211_tim_parameters tim;
+ u8 dtim_period;
+ u8 dtim_data;
+ u32 last_dtim_sta_time[2];
+
+ //appeded for QoS
+ u8 wmm_info;
+ struct ieee80211_wmm_ac_param wmm_param[4];
+ u8 QoS_Enable;
+#ifdef THOMAS_TURBO
+ u8 Turbo_Enable;//enable turbo mode, added by thomas
+#endif
+#ifdef ENABLE_DOT11D
+ u16 CountryIeLen;
+ u8 CountryIeBuf[MAX_IE_LEN];
+#endif
+ // HT Related, by amy, 2008.04.29
+ BSS_HT bssht;
+ // Add to handle broadcom AP management frame CCK rate.
+ bool broadcom_cap_exist;
+ bool realtek_cap_exit;
+ bool marvell_cap_exist;
+ bool ralink_cap_exist;
+ bool atheros_cap_exist;
+ bool cisco_cap_exist;
+ bool unknown_cap_exist;
+// u8 berp_info;
+ bool berp_info_valid;
+ bool buseprotection;
+ //put at the end of the structure.
+ struct list_head list;
+};
+
+#if 1
+enum ieee80211_state {
+
+ /* the card is not linked at all */
+ IEEE80211_NOLINK = 0,
+
+ /* IEEE80211_ASSOCIATING* are for BSS client mode
+ * the driver shall not perform RX filtering unless
+ * the state is LINKED.
+ * The driver shall just check for the state LINKED and
+ * defaults to NOLINK for ALL the other states (including
+ * LINKED_SCANNING)
+ */
+
+ /* the association procedure will start (wq scheduling)*/
+ IEEE80211_ASSOCIATING,
+ IEEE80211_ASSOCIATING_RETRY,
+
+ /* the association procedure is sending AUTH request*/
+ IEEE80211_ASSOCIATING_AUTHENTICATING,
+
+ /* the association procedure has successfully authentcated
+ * and is sending association request
+ */
+ IEEE80211_ASSOCIATING_AUTHENTICATED,
+
+ /* the link is ok. the card associated to a BSS or linked
+ * to a ibss cell or acting as an AP and creating the bss
+ */
+ IEEE80211_LINKED,
+
+ /* same as LINKED, but the driver shall apply RX filter
+ * rules as we are in NO_LINK mode. As the card is still
+ * logically linked, but it is doing a syncro site survey
+ * then it will be back to LINKED state.
+ */
+ IEEE80211_LINKED_SCANNING,
+
+};
+#else
+enum ieee80211_state {
+ IEEE80211_UNINITIALIZED = 0,
+ IEEE80211_INITIALIZED,
+ IEEE80211_ASSOCIATING,
+ IEEE80211_ASSOCIATED,
+ IEEE80211_AUTHENTICATING,
+ IEEE80211_AUTHENTICATED,
+ IEEE80211_SHUTDOWN
+};
+#endif
+
+#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
+#define DEFAULT_FTS 2346
+
+#define CFG_IEEE80211_RESERVE_FCS (1<<0)
+#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
+#define CFG_IEEE80211_RTS (1<<2)
+
+#define IEEE80211_24GHZ_MIN_CHANNEL 1
+#define IEEE80211_24GHZ_MAX_CHANNEL 14
+#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
+ IEEE80211_24GHZ_MIN_CHANNEL + 1)
+
+#define IEEE80211_52GHZ_MIN_CHANNEL 34
+#define IEEE80211_52GHZ_MAX_CHANNEL 165
+#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
+ IEEE80211_52GHZ_MIN_CHANNEL + 1)
+
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
+extern inline int is_multicast_ether_addr(const u8 *addr)
+{
+ return ((addr[0] != 0xff) && (0x01 & addr[0]));
+}
+#endif
+
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
+extern inline int is_broadcast_ether_addr(const u8 *addr)
+{
+ return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
+ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
+}
+#endif
+
+typedef struct tx_pending_t{
+ int frag;
+ struct ieee80211_txb *txb;
+}tx_pending_t;
+
+typedef struct _bandwidth_autoswitch
+{
+ long threshold_20Mhzto40Mhz;
+ long threshold_40Mhzto20Mhz;
+ bool bforced_tx20Mhz;
+ bool bautoswitch_enable;
+}bandwidth_autoswitch,*pbandwidth_autoswitch;
+
+
+//added by amy for order
+
+#define REORDER_WIN_SIZE 128
+#define REORDER_ENTRY_NUM 128
+typedef struct _RX_REORDER_ENTRY
+{
+ struct list_head List;
+ u16 SeqNum;
+ struct ieee80211_rxb* prxb;
+} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
+//added by amy for order
+typedef enum _Fsync_State{
+ Default_Fsync,
+ HW_Fsync,
+ SW_Fsync
+}Fsync_State;
+
+// Power save mode configured.
+typedef enum _RT_PS_MODE
+{
+ eActive, // Active/Continuous access.
+ eMaxPs, // Max power save mode.
+ eFastPs // Fast power save mode.
+}RT_PS_MODE;
+
+typedef enum _IPS_CALLBACK_FUNCION
+{
+ IPS_CALLBACK_NONE = 0,
+ IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
+ IPS_CALLBACK_JOIN_REQUEST = 2,
+}IPS_CALLBACK_FUNCION;
+
+typedef enum _RT_JOIN_ACTION{
+ RT_JOIN_INFRA = 1,
+ RT_JOIN_IBSS = 2,
+ RT_START_IBSS = 3,
+ RT_NO_ACTION = 4,
+}RT_JOIN_ACTION;
+
+typedef struct _IbssParms{
+ u16 atimWin;
+}IbssParms, *PIbssParms;
+#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko.
+
+// RF state.
+typedef enum _RT_RF_POWER_STATE
+{
+ eRfOn,
+ eRfSleep,
+ eRfOff
+}RT_RF_POWER_STATE;
+
+typedef struct _RT_POWER_SAVE_CONTROL
+{
+
+ //
+ // Inactive Power Save(IPS) : Disable RF when disconnected
+ //
+ bool bInactivePs;
+ bool bIPSModeBackup;
+ bool bHaltAdapterClkRQ;
+ bool bSwRfProcessing;
+ RT_RF_POWER_STATE eInactivePowerState;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct work_struct InactivePsWorkItem;
+#else
+ struct tq_struct InactivePsWorkItem;
+#endif
+ struct timer_list InactivePsTimer;
+
+ // Return point for join action
+ IPS_CALLBACK_FUNCION ReturnPoint;
+
+ // Recored Parameters for rescheduled JoinRequest
+ bool bTmpBssDesc;
+ RT_JOIN_ACTION tmpJoinAction;
+ struct ieee80211_network tmpBssDesc;
+
+ // Recored Parameters for rescheduled MgntLinkRequest
+ bool bTmpScanOnly;
+ bool bTmpActiveScan;
+ bool bTmpFilterHiddenAP;
+ bool bTmpUpdateParms;
+ u8 tmpSsidBuf[33];
+ OCTET_STRING tmpSsid2Scan;
+ bool bTmpSsid2Scan;
+ u8 tmpNetworkType;
+ u8 tmpChannelNumber;
+ u16 tmpBcnPeriod;
+ u8 tmpDtimPeriod;
+ u16 tmpmCap;
+ OCTET_STRING tmpSuppRateSet;
+ u8 tmpSuppRateBuf[MAX_NUM_RATES];
+ bool bTmpSuppRate;
+ IbssParms tmpIbpm;
+ bool bTmpIbpm;
+
+ //
+ // Leisre Poswer Save : Disable RF if connected but traffic is not busy
+ //
+ bool bLeisurePs;
+ u32 PowerProfile;
+ u8 LpsIdleCount;
+ u8 RegMaxLPSAwakeIntvl;
+ u8 LPSAwakeIntvl;
+
+ //RF OFF Level
+ u32 CurPsLevel;
+ u32 RegRfPsLevel;
+
+ //Fw Control LPS
+ bool bFwCtrlLPS;
+ u8 FWCtrlPSMode;
+
+ //2009.01.01 added by tynli
+ // Record if there is a link request in IPS RF off progress.
+ bool LinkReqInIPSRFOffPgs;
+ // To make sure that connect info should be executed, so we set the bit to filter the link info which comes after the connect info.
+ bool BufConnectinfoBefore;
+
+}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL;
+
+typedef u32 RT_RF_CHANGE_SOURCE;
+#define RF_CHANGE_BY_SW BIT31
+#define RF_CHANGE_BY_HW BIT30
+#define RF_CHANGE_BY_PS BIT29
+#define RF_CHANGE_BY_IPS BIT28
+#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17.
+
+#ifdef ENABLE_DOT11D
+typedef enum
+{
+ COUNTRY_CODE_FCC = 0,
+ COUNTRY_CODE_IC = 1,
+ COUNTRY_CODE_ETSI = 2,
+ COUNTRY_CODE_SPAIN = 3,
+ COUNTRY_CODE_FRANCE = 4,
+ COUNTRY_CODE_MKK = 5,
+ COUNTRY_CODE_MKK1 = 6,
+ COUNTRY_CODE_ISRAEL = 7,
+ COUNTRY_CODE_TELEC,
+ COUNTRY_CODE_MIC,
+ COUNTRY_CODE_GLOBAL_DOMAIN
+}country_code_type_t;
+#endif
+ // Firmware realted CMD IO.
+typedef enum _FW_CMD_IO_TYPE{
+ FW_CMD_DIG_ENABLE = 0, // For DIG DM
+ FW_CMD_DIG_DISABLE = 1,
+ FW_CMD_DIG_HALT = 2,
+ FW_CMD_DIG_RESUME = 3,
+ FW_CMD_HIGH_PWR_ENABLE = 4, // For High Power DM
+ FW_CMD_HIGH_PWR_DISABLE = 5,
+ FW_CMD_RA_RESET = 6, // For Rate adaptive DM
+ FW_CMD_RA_ACTIVE= 7,
+ FW_CMD_RA_REFRESH_N= 8,
+ FW_CMD_RA_REFRESH_BG= 9,
+ FW_CMD_IQK_ENABLE = 10, // For FW supported IQK
+ FW_CMD_TXPWR_TRACK_ENABLE = 11, // Tx power tracking switch
+ FW_CMD_TXPWR_TRACK_DISABLE = 12, // Tx power tracking switch
+ FW_CMD_PAUSE_DM_BY_SCAN = 13,
+ FW_CMD_RESUME_DM_BY_SCAN = 14,
+ FW_CMD_MID_HIGH_PWR_ENABLE = 15,
+ FW_CMD_LPS_ENTER = 16, // Indifate firmware that driver enters LPS, For PS-Poll hardware bug
+ FW_CMD_LPS_LEAVE = 17, // Indicate firmware that driver leave LPS, 2009/1/4, by Emily
+}FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE;
+#define RT_MAX_LD_SLOT_NUM 10
+typedef struct _RT_LINK_DETECT_T{
+
+ u32 NumRecvBcnInPeriod;
+ u32 NumRecvDataInPeriod;
+
+ u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; // number of Rx beacon / CheckForHang_period to determine link status
+ u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; // number of Rx data / CheckForHang_period to determine link status
+ u16 SlotNum; // number of CheckForHang period to determine link status
+ u16 SlotIndex;
+
+ u32 NumTxOkInPeriod;
+ u32 NumRxOkInPeriod;
+ bool bBusyTraffic;
+}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
+
+
+struct ieee80211_device {
+ struct net_device *dev;
+ struct ieee80211_security sec;
+
+ //hw security related
+// u8 hwsec_support; //support?
+ u8 hwsec_active; //hw security active.
+ bool is_silent_reset;
+ bool is_roaming;
+ bool ieee_up;
+ //added by amy
+ bool bSupportRemoteWakeUp;
+ RT_PS_MODE dot11PowerSaveMode; // Power save mode configured.
+ bool actscanning;
+ //added by amy 090313
+ bool be_scan_inprogress;
+ bool beinretry;
+ RT_RF_POWER_STATE eRFPowerState;
+ RT_RF_CHANGE_SOURCE RfOffReason;
+ bool is_set_key;
+ //11n spec related I wonder if These info structure need to be moved out of ieee80211_device
+
+ //11n HT below
+ PRT_HIGH_THROUGHPUT pHTInfo;
+ //struct timer_list SwBwTimer;
+// spinlock_t chnlop_spinlock;
+ spinlock_t bw_spinlock;
+
+ spinlock_t reorder_spinlock;
+ // for HT operation rate set. we use this one for HT data rate to seperate different descriptors
+ //the way fill this is the same as in the IE
+ u8 Regdot11HTOperationalRateSet[16]; //use RATR format
+ u8 dot11HTOperationalRateSet[16]; //use RATR format
+ u8 RegHTSuppRateSet[16];
+ u8 HTCurrentOperaRate;
+ u8 HTHighestOperaRate;
+ //wb added for rate operation mode to firmware
+ u8 bTxDisableRateFallBack;
+ u8 bTxUseDriverAssingedRate;
+ atomic_t atm_chnlop;
+ atomic_t atm_swbw;
+// u8 HTHighestOperaRate;
+// u8 HTCurrentOperaRate;
+
+ // 802.11e and WMM Traffic Stream Info (TX)
+ struct list_head Tx_TS_Admit_List;
+ struct list_head Tx_TS_Pending_List;
+ struct list_head Tx_TS_Unused_List;
+ TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
+ // 802.11e and WMM Traffic Stream Info (RX)
+ struct list_head Rx_TS_Admit_List;
+ struct list_head Rx_TS_Pending_List;
+ struct list_head Rx_TS_Unused_List;
+ RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
+//#ifdef TO_DO_LIST
+ RX_REORDER_ENTRY RxReorderEntry[128];
+ struct list_head RxReorder_Unused_List;
+//#endif
+ // Qos related. Added by Annie, 2005-11-01.
+// PSTA_QOS pStaQos;
+ u8 ForcedPriority; // Force per-packet priority 1~7. (default: 0, not to force it.)
+
+
+ /* Bookkeeping structures */
+ struct net_device_stats stats;
+ struct ieee80211_stats ieee_stats;
+ struct ieee80211_softmac_stats softmac_stats;
+
+ /* Probe / Beacon management */
+ struct list_head network_free_list;
+ struct list_head network_list;
+ struct ieee80211_network *networks;
+ int scans;
+ int scan_age;
+
+ int iw_mode; /* operating mode (IW_MODE_*) */
+ struct iw_spy_data spy_data;
+
+ spinlock_t lock;
+ spinlock_t wpax_suitlist_lock;
+
+ int tx_headroom; /* Set to size of any additional room needed at front
+ * of allocated Tx SKBs */
+ u32 config;
+
+ /* WEP and other encryption related settings at the device level */
+ int open_wep; /* Set to 1 to allow unencrypted frames */
+ int auth_mode;
+ int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
+ * WEP key changes */
+
+ /* If the host performs {en,de}cryption, then set to 1 */
+ int host_encrypt;
+ int host_encrypt_msdu;
+ int host_decrypt;
+ /* host performs multicast decryption */
+ int host_mc_decrypt;
+
+ /* host should strip IV and ICV from protected frames */
+ /* meaningful only when hardware decryption is being used */
+ int host_strip_iv_icv;
+
+ int host_open_frag;
+ int host_build_iv;
+ int ieee802_1x; /* is IEEE 802.1X used */
+
+ /* WPA data */
+ bool bHalfWirelessN24GMode;
+ int wpa_enabled;
+ int drop_unencrypted;
+ int tkip_countermeasures;
+ int privacy_invoked;
+ size_t wpa_ie_len;
+ u8 *wpa_ie;
+ u8 ap_mac_addr[6];
+ u16 pairwise_key_type;
+ u16 group_key_type;
+ struct list_head crypt_deinit_list;
+ struct ieee80211_crypt_data *crypt[WEP_KEYS];
+ int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
+ struct timer_list crypt_deinit_timer;
+ int crypt_quiesced;
+
+ int bcrx_sta_key; /* use individual keys to override default keys even
+ * with RX of broad/multicast frames */
+
+ /* Fragmentation structures */
+ // each streaming contain a entry
+ struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
+ unsigned int frag_next_idx[17];
+ u16 fts; /* Fragmentation Threshold */
+#define DEFAULT_RTS_THRESHOLD 2346U
+#define MIN_RTS_THRESHOLD 1
+#define MAX_RTS_THRESHOLD 2346U
+ u16 rts; /* RTS threshold */
+
+ /* Association info */
+ u8 bssid[ETH_ALEN];
+
+ /* This stores infos for the current network.
+ * Either the network we are associated in INFRASTRUCTURE
+ * or the network that we are creating in MASTER mode.
+ * ad-hoc is a mixture ;-).
+ * Note that in infrastructure mode, even when not associated,
+ * fields bssid and essid may be valid (if wpa_set and essid_set
+ * are true) as thy carry the value set by the user via iwconfig
+ */
+ struct ieee80211_network current_network;
+
+ enum ieee80211_state state;
+
+ int short_slot;
+ int reg_mode;
+ int mode; /* A, B, G */
+ int modulation; /* CCK, OFDM */
+ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
+ int abg_true; /* ABG flag */
+
+ /* used for forcing the ibss workqueue to terminate
+ * without wait for the syncro scan to terminate
+ */
+ short sync_scan_hurryup;
+ u16 scan_watch_dog;
+ int perfect_rssi;
+ int worst_rssi;
+
+ u16 prev_seq_ctl; /* used to drop duplicate frames */
+
+ /* map of allowed channels. 0 is dummy */
+ // FIXME: remeber to default to a basic channel plan depending of the PHY type
+#ifdef ENABLE_DOT11D
+ void* pDot11dInfo;
+ bool bGlobalDomain;
+#else
+ int channel_map[MAX_CHANNEL_NUMBER+1];
+#endif
+ int rate; /* current rate */
+ int basic_rate;
+ //FIXME: pleace callback, see if redundant with softmac_features
+ short active_scan;
+
+ /* this contains flags for selectively enable softmac support */
+ u16 softmac_features;
+
+ /* if the sequence control field is not filled by HW */
+ u16 seq_ctrl[5];
+
+ /* association procedure transaction sequence number */
+ u16 associate_seq;
+
+ /* AID for RTXed association responses */
+ u16 assoc_id;
+
+ /* power save mode related*/
+ u8 ack_tx_to_ieee;
+ short ps;
+ short sta_sleep;
+ int ps_timeout;
+ int ps_period;
+ struct tasklet_struct ps_task;
+ u32 ps_th;
+ u32 ps_tl;
+
+ short raw_tx;
+ /* used if IEEE_SOFTMAC_TX_QUEUE is set */
+ short queue_stop;
+ short scanning;
+ short proto_started;
+
+ struct semaphore wx_sem;
+ struct semaphore scan_sem;
+
+ spinlock_t mgmt_tx_lock;
+ spinlock_t beacon_lock;
+
+ short beacon_txing;
+
+ short wap_set;
+ short ssid_set;
+
+ u8 wpax_type_set; //{added by David, 2006.9.28}
+ u32 wpax_type_notify; //{added by David, 2006.9.26}
+
+ /* QoS related flag */
+ char init_wmmparam_flag;
+ /* set on initialization */
+ u8 qos_support;
+
+ /* for discarding duplicated packets in IBSS */
+ struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
+
+ /* for discarding duplicated packets in BSS */
+ u16 last_rxseq_num[17]; /* rx seq previous per-tid */
+ u16 last_rxfrag_num[17];/* tx frag previous per-tid */
+ unsigned long last_packet_time[17];
+
+ /* for PS mode */
+ unsigned long last_rx_ps_time;
+
+ /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
+ struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
+ int mgmt_queue_head;
+ int mgmt_queue_tail;
+//{ added for rtl819x
+#define IEEE80211_QUEUE_LIMIT 128
+ u8 AsocRetryCount;
+ unsigned int hw_header;
+ struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
+ struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
+ struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
+ u32 sta_edca_param[4];
+ bool aggregation;
+ // Enable/Disable Rx immediate BA capability.
+ bool enable_rx_imm_BA;
+ bool bibsscoordinator;
+
+ //+by amy for DM ,080515
+ //Dynamic Tx power for near/far range enable/Disable , by amy , 2008-05-15
+ bool bdynamic_txpower_enable;
+
+ bool bCTSToSelfEnable;
+ u8 CTSToSelfTH;
+
+ u32 fsync_time_interval;
+ u32 fsync_rate_bitmap;
+ u8 fsync_rssi_threshold;
+ bool bfsync_enable;
+
+ u8 fsync_multiple_timeinterval; // FsyncMultipleTimeInterval * FsyncTimeInterval
+ u32 fsync_firstdiff_ratethreshold; // low threshold
+ u32 fsync_seconddiff_ratethreshold; // decrease threshold
+ Fsync_State fsync_state;
+ bool bis_any_nonbepkts;
+ //20Mhz 40Mhz AutoSwitch Threshold
+ bandwidth_autoswitch bandwidth_auto_switch;
+ //for txpower tracking
+ bool FwRWRF;
+
+ //added by amy for AP roaming
+ RT_LINK_DETECT_T LinkDetectInfo;
+ //added by amy for ps
+ RT_POWER_SAVE_CONTROL PowerSaveControl;
+//}
+ /* used if IEEE_SOFTMAC_TX_QUEUE is set */
+ struct tx_pending_t tx_pending;
+
+ /* used if IEEE_SOFTMAC_ASSOCIATE is set */
+ struct timer_list associate_timer;
+
+ /* used if IEEE_SOFTMAC_BEACONS is set */
+ struct timer_list beacon_timer;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct work_struct associate_complete_wq;
+ struct work_struct associate_procedure_wq;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ struct delayed_work softmac_scan_wq;
+ struct delayed_work associate_retry_wq;
+ struct delayed_work start_ibss_wq;
+ struct delayed_work hw_wakeup_wq;
+ struct delayed_work hw_sleep_wq;
+ struct delayed_work link_change_wq;
+#else
+ struct work_struct softmac_scan_wq;
+ struct work_struct associate_retry_wq;
+ struct work_struct start_ibss_wq;
+ struct work_struct hw_wakeup_wq;
+ struct work_struct hw_sleep_wq;
+ struct work_struct link_change_wq;
+#endif
+ struct work_struct wx_sync_scan_wq;
+ struct workqueue_struct *wq;
+#else
+ /* used for periodly scan */
+ struct timer_list scan_timer;
+
+ struct tq_struct associate_complete_wq;
+ struct tq_struct associate_retry_wq;
+ struct tq_struct start_ibss_wq;
+ struct tq_struct associate_procedure_wq;
+ struct tq_struct softmac_scan_wq;
+ struct tq_struct wx_sync_scan_wq;
+ struct tq_struct hw_wakeup_wq;
+ struct tq_struct hw_sleep_wq;
+ struct tq_struct link_change_wq;
+
+#endif
+ // Qos related. Added by Annie, 2005-11-01.
+ //STA_QOS StaQos;
+
+ //u32 STA_EDCA_PARAM[4];
+ //CHANNEL_ACCESS_SETTING ChannelAccessSetting;
+
+
+ /* Callback functions */
+ void (*set_security)(struct net_device *dev,
+ struct ieee80211_security *sec);
+
+ /* Used to TX data frame by using txb structs.
+ * this is not used if in the softmac_features
+ * is set the flag IEEE_SOFTMAC_TX_QUEUE
+ */
+ int (*hard_start_xmit)(struct ieee80211_txb *txb,
+ struct net_device *dev);
+
+ int (*reset_port)(struct net_device *dev);
+ int (*is_queue_full) (struct net_device * dev, int pri);
+
+ int (*handle_management) (struct net_device * dev,
+ struct ieee80211_network * network, u16 type);
+ int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
+
+ /* Softmac-generated frames (mamagement) are TXed via this
+ * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
+ * not set. As some cards may have different HW queues that
+ * one might want to use for data and management frames
+ * the option to have two callbacks might be useful.
+ * This fucntion can't sleep.
+ */
+ int (*softmac_hard_start_xmit)(struct sk_buff *skb,
+ struct net_device *dev);
+
+ /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
+ * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
+ * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
+ * then also management frames are sent via this callback.
+ * This function can't sleep.
+ */
+ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
+ struct net_device *dev,int rate);
+
+ /* stops the HW queue for DATA frames. Useful to avoid
+ * waste time to TX data frame when we are reassociating
+ * This function can sleep.
+ */
+ void (*data_hard_stop)(struct net_device *dev);
+
+ /* OK this is complementar to data_poll_hard_stop */
+ void (*data_hard_resume)(struct net_device *dev);
+
+ /* ask to the driver to retune the radio .
+ * This function can sleep. the driver should ensure
+ * the radio has been swithced before return.
+ */
+ void (*set_chan)(struct net_device *dev,short ch);
+
+ /* These are not used if the ieee stack takes care of
+ * scanning (IEEE_SOFTMAC_SCAN feature set).
+ * In this case only the set_chan is used.
+ *
+ * The syncro version is similar to the start_scan but
+ * does not return until all channels has been scanned.
+ * this is called in user context and should sleep,
+ * it is called in a work_queue when swithcing to ad-hoc mode
+ * or in behalf of iwlist scan when the card is associated
+ * and root user ask for a scan.
+ * the fucntion stop_scan should stop both the syncro and
+ * background scanning and can sleep.
+ * The fucntion start_scan should initiate the background
+ * scanning and can't sleep.
+ */
+ void (*scan_syncro)(struct net_device *dev);
+ void (*start_scan)(struct net_device *dev);
+ void (*stop_scan)(struct net_device *dev);
+
+ /* indicate the driver that the link state is changed
+ * for example it may indicate the card is associated now.
+ * Driver might be interested in this to apply RX filter
+ * rules or simply light the LINK led
+ */
+ void (*link_change)(struct net_device *dev);
+
+ /* these two function indicates to the HW when to start
+ * and stop to send beacons. This is used when the
+ * IEEE_SOFTMAC_BEACONS is not set. For now the
+ * stop_send_bacons is NOT guaranteed to be called only
+ * after start_send_beacons.
+ */
+ void (*start_send_beacons) (struct net_device *dev);
+ void (*stop_send_beacons) (struct net_device *dev);
+
+ /* power save mode related */
+ void (*sta_wake_up) (struct net_device *dev);
+// void (*ps_request_tx_ack) (struct net_device *dev);
+ void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
+ short (*ps_is_queue_empty) (struct net_device *dev);
+#if 0
+ /* Typical STA methods */
+ int (*handle_auth) (struct net_device * dev,
+ struct ieee80211_auth * auth);
+ int (*handle_deauth) (struct net_device * dev,
+ struct ieee80211_deauth * auth);
+ int (*handle_action) (struct net_device * dev,
+ struct ieee80211_action * action,
+ struct ieee80211_rx_stats * stats);
+ int (*handle_disassoc) (struct net_device * dev,
+ struct ieee80211_disassoc * assoc);
+#endif
+ int (*handle_beacon) (struct net_device * dev, struct ieee80211_beacon * beacon, struct ieee80211_network * network);
+#if 0
+ int (*handle_probe_response) (struct net_device * dev,
+ struct ieee80211_probe_response * resp,
+ struct ieee80211_network * network);
+ int (*handle_probe_request) (struct net_device * dev,
+ struct ieee80211_probe_request * req,
+ struct ieee80211_rx_stats * stats);
+#endif
+ int (*handle_assoc_response) (struct net_device * dev, struct ieee80211_assoc_response_frame * resp, struct ieee80211_network * network);
+
+#if 0
+ /* Typical AP methods */
+ int (*handle_assoc_request) (struct net_device * dev);
+ int (*handle_reassoc_request) (struct net_device * dev,
+ struct ieee80211_reassoc_request * req);
+#endif
+
+ /* check whether Tx hw resouce available */
+ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
+ //added by wb for HT related
+// void (*SwChnlByTimerHandler)(struct net_device *dev, int channel);
+ void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
+// void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate);
+ bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
+ void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
+ bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
+ bool (*is_ap_in_wep_tkip)(struct net_device* dev);
+ void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
+ bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO);
+ void (*LedControlHandler)(struct net_device * dev, LED_CTL_MODE LedAction);
+ /* This must be the last item so that it points to the data
+ * allocated beyond this structure by alloc_ieee80211 */
+ u8 priv[0];
+};
+
+#define IEEE_A (1<<0)
+#define IEEE_B (1<<1)
+#define IEEE_G (1<<2)
+#define IEEE_N_24G (1<<4)
+#define IEEE_N_5G (1<<5)
+#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
+
+/* Generate a 802.11 header */
+
+/* Uses the channel change callback directly
+ * instead of [start/stop] scan callbacks
+ */
+#define IEEE_SOFTMAC_SCAN (1<<2)
+
+/* Perform authentication and association handshake */
+#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
+
+/* Generate probe requests */
+#define IEEE_SOFTMAC_PROBERQ (1<<4)
+
+/* Generate respones to probe requests */
+#define IEEE_SOFTMAC_PROBERS (1<<5)
+
+/* The ieee802.11 stack will manages the netif queue
+ * wake/stop for the driver, taking care of 802.11
+ * fragmentation. See softmac.c for details. */
+#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
+
+/* Uses only the softmac_data_hard_start_xmit
+ * even for TX management frames.
+ */
+#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
+
+/* Generate beacons. The stack will enqueue beacons
+ * to the card
+ */
+#define IEEE_SOFTMAC_BEACONS (1<<6)
+
+static inline void *ieee80211_priv(struct net_device *dev)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ return ((struct ieee80211_device *)netdev_priv(dev))->priv;
+#else
+ return ((struct ieee80211_device *)dev->priv)->priv;
+#endif
+}
+
+extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+{
+ /* Single white space is for Linksys APs */
+ if (essid_len == 1 && essid[0] == ' ')
+ return 1;
+
+ /* Otherwise, if the entire essid is 0, we assume it is hidden */
+ while (essid_len) {
+ essid_len--;
+ if (essid[essid_len] != '\0')
+ return 0;
+ }
+
+ return 1;
+}
+
+extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
+{
+ /*
+ * It is possible for both access points and our device to support
+ * combinations of modes, so as long as there is one valid combination
+ * of ap/device supported modes, then return success
+ *
+ */
+ if ((mode & IEEE_A) &&
+ (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
+ (ieee->freq_band & IEEE80211_52GHZ_BAND))
+ return 1;
+
+ if ((mode & IEEE_G) &&
+ (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
+ (ieee->freq_band & IEEE80211_24GHZ_BAND))
+ return 1;
+
+ if ((mode & IEEE_B) &&
+ (ieee->modulation & IEEE80211_CCK_MODULATION) &&
+ (ieee->freq_band & IEEE80211_24GHZ_BAND))
+ return 1;
+
+ return 0;
+}
+
+extern inline int ieee80211_get_hdrlen(u16 fc)
+{
+ int hdrlen = IEEE80211_3ADDR_LEN;
+
+ switch (WLAN_FC_GET_TYPE(fc)) {
+ case IEEE80211_FTYPE_DATA:
+ if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
+ hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
+ if(IEEE80211_QOS_HAS_SEQ(fc))
+ hdrlen += 2; /* QOS ctrl*/
+ break;
+ case IEEE80211_FTYPE_CTL:
+ switch (WLAN_FC_GET_STYPE(fc)) {
+ case IEEE80211_STYPE_CTS:
+ case IEEE80211_STYPE_ACK:
+ hdrlen = IEEE80211_1ADDR_LEN;
+ break;
+ default:
+ hdrlen = IEEE80211_2ADDR_LEN;
+ break;
+ }
+ break;
+ }
+
+ return hdrlen;
+}
+
+static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
+{
+ switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
+ case IEEE80211_1ADDR_LEN:
+ return ((struct ieee80211_hdr_1addr *)hdr)->payload;
+ case IEEE80211_2ADDR_LEN:
+ return ((struct ieee80211_hdr_2addr *)hdr)->payload;
+ case IEEE80211_3ADDR_LEN:
+ return ((struct ieee80211_hdr_3addr *)hdr)->payload;
+ case IEEE80211_4ADDR_LEN:
+ return ((struct ieee80211_hdr_4addr *)hdr)->payload;
+ }
+ return NULL;
+}
+
+static inline int ieee80211_is_ofdm_rate(u8 rate)
+{
+ switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
+ case IEEE80211_OFDM_RATE_6MB:
+ case IEEE80211_OFDM_RATE_9MB:
+ case IEEE80211_OFDM_RATE_12MB:
+ case IEEE80211_OFDM_RATE_18MB:
+ case IEEE80211_OFDM_RATE_24MB:
+ case IEEE80211_OFDM_RATE_36MB:
+ case IEEE80211_OFDM_RATE_48MB:
+ case IEEE80211_OFDM_RATE_54MB:
+ return 1;
+ }
+ return 0;
+}
+
+static inline int ieee80211_is_cck_rate(u8 rate)
+{
+ switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
+ case IEEE80211_CCK_RATE_1MB:
+ case IEEE80211_CCK_RATE_2MB:
+ case IEEE80211_CCK_RATE_5MB:
+ case IEEE80211_CCK_RATE_11MB:
+ return 1;
+ }
+ return 0;
+}
+
+
+/* ieee80211.c */
+extern void free_ieee80211(struct net_device *dev);
+extern struct net_device *alloc_ieee80211(int sizeof_priv);
+
+extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
+
+/* ieee80211_tx.c */
+
+extern int ieee80211_encrypt_fragment(
+ struct ieee80211_device *ieee,
+ struct sk_buff *frag,
+ int hdr_len);
+
+extern int ieee80211_xmit(struct sk_buff *skb,
+ struct net_device *dev);
+extern void ieee80211_txb_free(struct ieee80211_txb *);
+
+
+/* ieee80211_rx.c */
+extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats);
+extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
+ struct ieee80211_hdr_4addr *header,
+ struct ieee80211_rx_stats *stats);
+
+/* ieee80211_wx.c */
+extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key);
+extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key);
+extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key);
+#if WIRELESS_EXT >= 18
+extern int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data* wrqu, char *extra);
+extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data* wrqu, char *extra);
+extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ struct iw_param *data, char *extra);
+extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+#endif
+extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
+
+/* ieee80211_softmac.c */
+extern short ieee80211_is_54g(struct ieee80211_network net);
+extern short ieee80211_is_shortslot(struct ieee80211_network net);
+extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats, u16 type,
+ u16 stype);
+extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
+
+void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
+extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
+
+extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
+extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
+extern void ieee80211_start_bss(struct ieee80211_device *ieee);
+extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
+extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
+extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
+extern void ieee80211_disassociate(struct ieee80211_device *ieee);
+extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
+extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
+extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
+extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
+extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
+extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
+extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
+extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
+extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
+extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
+extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
+extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
+extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
+
+extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
+
+/* ieee80211_crypt_ccmp&tkip&wep.c */
+extern void ieee80211_tkip_null(void);
+extern void ieee80211_wep_null(void);
+extern void ieee80211_ccmp_null(void);
+
+/* ieee80211_softmac_wx.c */
+
+extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *ext);
+
+extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra);
+
+extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
+
+extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b);
+
+//extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
+#else
+ extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
+#endif
+
+
+extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+
+extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra);
+//HT
+#define MAX_RECEIVE_BUFFER_SIZE 9100 //
+extern void HTDebugHTCapability(u8* CapIE, u8* TitleString );
+extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString);
+
+void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
+extern void HTUpdateDefaultSetting(struct ieee80211_device* ieee);
+extern void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt);
+extern void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt);
+extern void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len);
+extern void HTOnAssocRsp(struct ieee80211_device *ieee);
+extern void HTInitializeHTInfo(struct ieee80211_device* ieee);
+extern void HTInitializeBssDesc(PBSS_HT pBssHT);
+extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
+extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork);
+extern u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter);
+extern u8 MCS_FILTER_ALL[];
+extern u16 MCS_DATA_RATE[2][2][77] ;
+extern u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame);
+//extern void HTSetConnectBwModeCallback(unsigned long data);
+extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
+extern bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee);
+extern u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate);
+extern u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate);
+extern u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate);
+//function in BAPROC.c
+extern int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb);
+extern int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb);
+extern int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb);
+extern void TsInitAddBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending);
+extern void TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
+extern void BaSetupTimeOut(unsigned long data);
+extern void TxBaInactTimeout(unsigned long data);
+extern void RxBaInactTimeout(unsigned long data);
+extern void ResetBaEntry( PBA_RECORD pBA);
+//function in TS.c
+extern bool GetTs(
+ struct ieee80211_device* ieee,
+ PTS_COMMON_INFO *ppTS,
+ u8* Addr,
+ u8 TID,
+ TR_SELECT TxRxSelect, //Rx:1, Tx:0
+ bool bAddNewTs
+ );
+extern void TSInitialize(struct ieee80211_device *ieee);
+extern void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS);
+extern void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr);
+extern void RemoveAllTS(struct ieee80211_device* ieee);
+void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
+
+extern const long ieee80211_wlan_frequencies[];
+
+extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
+{
+ ieee->scans++;
+}
+
+extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
+{
+ return ieee->scans;
+}
+
+static inline const char *escape_essid(const char *essid, u8 essid_len) {
+ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
+ const char *s = essid;
+ char *d = escaped;
+
+ if (ieee80211_is_empty_essid(essid, essid_len)) {
+ memcpy(escaped, "<hidden>", sizeof("<hidden>"));
+ return escaped;
+ }
+
+ essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
+ while (essid_len--) {
+ if (*s == '\0') {
+ *d++ = '\\';
+ *d++ = '0';
+ s++;
+ } else {
+ *d++ = *s++;
+ }
+ }
+ *d = '\0';
+ return escaped;
+}
+
+/* For the function is more related to hardware setting, it's better to use the
+ * ieee handler to refer to it.
+ */
+extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
+extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
+extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
+ struct ieee80211_info_element *info_element,
+ u16 length,
+ struct ieee80211_network *network,
+ struct ieee80211_rx_stats *stats);
+
+void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index);
+#define RT_ASOC_RETRY_LIMIT 5
+#endif /* IEEE80211_H */
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
new file mode 100644
index 000000000000..199ee1695ad3
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
@@ -0,0 +1,273 @@
+/*
+ * Host AP crypto routines
+ *
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ * Portions Copyright (C) 2004, Intel Corporation <jketreno@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ *
+ */
+
+//#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/string.h>
+#include <asm/errno.h>
+
+#include "ieee80211.h"
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("HostAP crypto");
+MODULE_LICENSE("GPL");
+
+struct ieee80211_crypto_alg {
+ struct list_head list;
+ struct ieee80211_crypto_ops *ops;
+};
+
+
+struct ieee80211_crypto {
+ struct list_head algs;
+ spinlock_t lock;
+};
+
+static struct ieee80211_crypto *hcrypt;
+
+void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
+ int force)
+{
+ struct list_head *ptr, *n;
+ struct ieee80211_crypt_data *entry;
+
+ for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
+ ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
+ entry = list_entry(ptr, struct ieee80211_crypt_data, list);
+
+ if (atomic_read(&entry->refcnt) != 0 && !force)
+ continue;
+
+ list_del(ptr);
+
+ if (entry->ops) {
+ entry->ops->deinit(entry->priv);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ module_put(entry->ops->owner);
+#else
+ __MOD_DEC_USE_COUNT(entry->ops->owner);
+#endif
+ }
+ kfree(entry);
+ }
+}
+
+void ieee80211_crypt_deinit_handler(unsigned long data)
+{
+ struct ieee80211_device *ieee = (struct ieee80211_device *)data;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ieee->lock, flags);
+ ieee80211_crypt_deinit_entries(ieee, 0);
+ if (!list_empty(&ieee->crypt_deinit_list)) {
+ printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
+ "deletion list\n", ieee->dev->name);
+ ieee->crypt_deinit_timer.expires = jiffies + HZ;
+ add_timer(&ieee->crypt_deinit_timer);
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+}
+
+void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
+ struct ieee80211_crypt_data **crypt)
+{
+ struct ieee80211_crypt_data *tmp;
+ unsigned long flags;
+
+ if (*crypt == NULL)
+ return;
+
+ tmp = *crypt;
+ *crypt = NULL;
+
+ /* must not run ops->deinit() while there may be pending encrypt or
+ * decrypt operations. Use a list of delayed deinits to avoid needing
+ * locking. */
+
+ spin_lock_irqsave(&ieee->lock, flags);
+ list_add(&tmp->list, &ieee->crypt_deinit_list);
+ if (!timer_pending(&ieee->crypt_deinit_timer)) {
+ ieee->crypt_deinit_timer.expires = jiffies + HZ;
+ add_timer(&ieee->crypt_deinit_timer);
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+}
+
+int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
+{
+ unsigned long flags;
+ struct ieee80211_crypto_alg *alg;
+
+ if (hcrypt == NULL)
+ return -1;
+
+ alg = kmalloc(sizeof(*alg), GFP_KERNEL);
+ if (alg == NULL)
+ return -ENOMEM;
+
+ memset(alg, 0, sizeof(*alg));
+ alg->ops = ops;
+
+ spin_lock_irqsave(&hcrypt->lock, flags);
+ list_add(&alg->list, &hcrypt->algs);
+ spin_unlock_irqrestore(&hcrypt->lock, flags);
+
+ printk(KERN_DEBUG "ieee80211_crypt: registered algorithm '%s'\n",
+ ops->name);
+
+ return 0;
+}
+
+int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
+{
+ unsigned long flags;
+ struct list_head *ptr;
+ struct ieee80211_crypto_alg *del_alg = NULL;
+
+ if (hcrypt == NULL)
+ return -1;
+
+ spin_lock_irqsave(&hcrypt->lock, flags);
+ for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
+ struct ieee80211_crypto_alg *alg =
+ (struct ieee80211_crypto_alg *) ptr;
+ if (alg->ops == ops) {
+ list_del(&alg->list);
+ del_alg = alg;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&hcrypt->lock, flags);
+
+ if (del_alg) {
+ printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
+ "'%s'\n", ops->name);
+ kfree(del_alg);
+ }
+
+ return del_alg ? 0 : -1;
+}
+
+
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
+{
+ unsigned long flags;
+ struct list_head *ptr;
+ struct ieee80211_crypto_alg *found_alg = NULL;
+
+ if (hcrypt == NULL)
+ return NULL;
+
+ spin_lock_irqsave(&hcrypt->lock, flags);
+ for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
+ struct ieee80211_crypto_alg *alg =
+ (struct ieee80211_crypto_alg *) ptr;
+ if (strcmp(alg->ops->name, name) == 0) {
+ found_alg = alg;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&hcrypt->lock, flags);
+
+ if (found_alg)
+ return found_alg->ops;
+ else
+ return NULL;
+}
+
+
+static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
+static void ieee80211_crypt_null_deinit(void *priv) {}
+
+static struct ieee80211_crypto_ops ieee80211_crypt_null = {
+ .name = "NULL",
+ .init = ieee80211_crypt_null_init,
+ .deinit = ieee80211_crypt_null_deinit,
+ .encrypt_mpdu = NULL,
+ .decrypt_mpdu = NULL,
+ .encrypt_msdu = NULL,
+ .decrypt_msdu = NULL,
+ .set_key = NULL,
+ .get_key = NULL,
+ .extra_prefix_len = 0,
+ .extra_postfix_len = 0,
+ .owner = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_init(void)
+{
+ int ret = -ENOMEM;
+
+ hcrypt = kmalloc(sizeof(*hcrypt), GFP_KERNEL);
+ if (!hcrypt)
+ goto out;
+
+ memset(hcrypt, 0, sizeof(*hcrypt));
+ INIT_LIST_HEAD(&hcrypt->algs);
+ spin_lock_init(&hcrypt->lock);
+
+ ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
+ if (ret < 0) {
+ kfree(hcrypt);
+ hcrypt = NULL;
+ }
+out:
+ return ret;
+}
+
+
+static void __exit ieee80211_crypto_deinit(void)
+{
+ struct list_head *ptr, *n;
+
+ if (hcrypt == NULL)
+ return;
+
+ for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs;
+ ptr = n, n = ptr->next) {
+ struct ieee80211_crypto_alg *alg =
+ (struct ieee80211_crypto_alg *) ptr;
+ list_del(ptr);
+ printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
+ "'%s' (deinit)\n", alg->ops->name);
+ kfree(alg);
+ }
+
+ kfree(hcrypt);
+}
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
+EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
+EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
+
+EXPORT_SYMBOL(ieee80211_register_crypto_ops);
+EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
+EXPORT_SYMBOL(ieee80211_get_crypto_ops);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_crypt_deinit_entries);
+EXPORT_SYMBOL_NOVERS(ieee80211_crypt_deinit_handler);
+EXPORT_SYMBOL_NOVERS(ieee80211_crypt_delayed_deinit);
+
+EXPORT_SYMBOL_NOVERS(ieee80211_register_crypto_ops);
+EXPORT_SYMBOL_NOVERS(ieee80211_unregister_crypto_ops);
+EXPORT_SYMBOL_NOVERS(ieee80211_get_crypto_ops);
+#endif
+
+module_init(ieee80211_crypto_init);
+module_exit(ieee80211_crypto_deinit);
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
new file mode 100644
index 000000000000..a84df4b76489
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
@@ -0,0 +1,93 @@
+/*
+ * Original code based on Host AP (software wireless LAN access point) driver
+ * for Intersil Prism2/2.5/3.
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * Adaption to a generic IEEE 802.11 stack by James Ketrenos
+ * <jketreno@linux.intel.com>
+ *
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+/*
+ * This file defines the interface to the ieee80211 crypto module.
+ */
+#ifndef IEEE80211_CRYPT_H
+#define IEEE80211_CRYPT_H
+
+#include <linux/skbuff.h>
+
+struct ieee80211_crypto_ops {
+ const char *name;
+
+ /* init new crypto context (e.g., allocate private data space,
+ * select IV, etc.); returns NULL on failure or pointer to allocated
+ * private data on success */
+ void * (*init)(int keyidx);
+
+ /* deinitialize crypto context and free allocated private data */
+ void (*deinit)(void *priv);
+
+ /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
+ * value from decrypt_mpdu is passed as the keyidx value for
+ * decrypt_msdu. skb must have enough head and tail room for the
+ * encryption; if not, error will be returned; these functions are
+ * called for all MPDUs (i.e., fragments).
+ */
+ int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+ int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+
+ /* These functions are called for full MSDUs, i.e. full frames.
+ * These can be NULL if full MSDU operations are not needed. */
+ int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
+ int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
+ void *priv);
+
+ int (*set_key)(void *key, int len, u8 *seq, void *priv);
+ int (*get_key)(void *key, int len, u8 *seq, void *priv);
+
+ /* procfs handler for printing out key information and possible
+ * statistics */
+ char * (*print_stats)(char *p, void *priv);
+
+ /* maximum number of bytes added by encryption; encrypt buf is
+ * allocated with extra_prefix_len bytes, copy of in_buf, and
+ * extra_postfix_len; encrypt need not use all this space, but
+ * the result must start at the beginning of the buffer and correct
+ * length must be returned */
+ int extra_prefix_len, extra_postfix_len;
+
+ struct module *owner;
+};
+
+struct ieee80211_crypt_data {
+ struct list_head list; /* delayed deletion list */
+ struct ieee80211_crypto_ops *ops;
+ void *priv;
+ atomic_t refcnt;
+};
+
+int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
+int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
+void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
+void ieee80211_crypt_deinit_handler(unsigned long);
+void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
+ struct ieee80211_crypt_data **crypt);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
+#define crypto_alloc_tfm crypto_alloc_tfm_rsl
+#define crypto_free_tfm crypto_free_tfm_rsl
+#endif
+
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
new file mode 100644
index 000000000000..a86c26eceb34
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
@@ -0,0 +1,534 @@
+/*
+ * Host AP crypt: host-based CCMP encryption implementation for Host AP driver
+ *
+ * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+//#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <asm/string.h>
+#include <linux/wireless.h>
+
+#include "ieee80211.h"
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#include "rtl_crypto.h"
+#else
+#include <linux/crypto.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ #include <asm/scatterlist.h>
+#else
+ #include <linux/scatterlist.h>
+#endif
+//#include <asm/scatterlist.h>
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP crypt: CCMP");
+MODULE_LICENSE("GPL");
+
+#ifndef OPENSUSE_SLED
+#define OPENSUSE_SLED 0
+#endif
+
+#define AES_BLOCK_LEN 16
+#define CCMP_HDR_LEN 8
+#define CCMP_MIC_LEN 8
+#define CCMP_TK_LEN 16
+#define CCMP_PN_LEN 6
+
+struct ieee80211_ccmp_data {
+ u8 key[CCMP_TK_LEN];
+ int key_set;
+
+ u8 tx_pn[CCMP_PN_LEN];
+ u8 rx_pn[CCMP_PN_LEN];
+
+ u32 dot11RSNAStatsCCMPFormatErrors;
+ u32 dot11RSNAStatsCCMPReplays;
+ u32 dot11RSNAStatsCCMPDecryptErrors;
+
+ int key_idx;
+
+ struct crypto_tfm *tfm;
+
+ /* scratch buffers for virt_to_page() (crypto API) */
+ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
+ tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
+ u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
+};
+
+void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
+ const u8 pt[16], u8 ct[16])
+{
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ struct scatterlist src, dst;
+
+ src.page = virt_to_page(pt);
+ src.offset = offset_in_page(pt);
+ src.length = AES_BLOCK_LEN;
+
+ dst.page = virt_to_page(ct);
+ dst.offset = offset_in_page(ct);
+ dst.length = AES_BLOCK_LEN;
+
+ crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
+#else
+ crypto_cipher_encrypt_one((void*)tfm, ct, pt);
+#endif
+}
+
+static void * ieee80211_ccmp_init(int key_idx)
+{
+ struct ieee80211_ccmp_data *priv;
+
+ priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+ if (priv == NULL)
+ goto fail;
+ memset(priv, 0, sizeof(*priv));
+ priv->key_idx = key_idx;
+
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ priv->tfm = crypto_alloc_tfm("aes", 0);
+ if (priv->tfm == NULL) {
+ printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
+ "crypto API aes\n");
+ goto fail;
+ }
+ #else
+ priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->tfm)) {
+ printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
+ "crypto API aes\n");
+ priv->tfm = NULL;
+ goto fail;
+ }
+ #endif
+ return priv;
+
+fail:
+ if (priv) {
+ if (priv->tfm)
+ #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
+ crypto_free_tfm(priv->tfm);
+ #else
+ crypto_free_cipher((void*)priv->tfm);
+ #endif
+ kfree(priv);
+ }
+
+ return NULL;
+}
+
+
+static void ieee80211_ccmp_deinit(void *priv)
+{
+ struct ieee80211_ccmp_data *_priv = priv;
+ if (_priv && _priv->tfm)
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
+ crypto_free_tfm(_priv->tfm);
+#else
+ crypto_free_cipher((void*)_priv->tfm);
+#endif
+ kfree(priv);
+}
+
+
+static inline void xor_block(u8 *b, u8 *a, size_t len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ b[i] ^= a[i];
+}
+
+
+
+static void ccmp_init_blocks(struct crypto_tfm *tfm,
+ struct ieee80211_hdr_4addr *hdr,
+ u8 *pn, size_t dlen, u8 *b0, u8 *auth,
+ u8 *s0)
+{
+ u8 *pos, qc = 0;
+ size_t aad_len;
+ u16 fc;
+ int a4_included, qc_included;
+ u8 aad[2 * AES_BLOCK_LEN];
+
+ fc = le16_to_cpu(hdr->frame_ctl);
+ a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+ (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS));
+ /*
+ qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
+ (WLAN_FC_GET_STYPE(fc) & 0x08));
+ */
+ // fixed by David :2006.9.6
+ qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
+ (WLAN_FC_GET_STYPE(fc) & 0x80));
+ aad_len = 22;
+ if (a4_included)
+ aad_len += 6;
+ if (qc_included) {
+ pos = (u8 *) &hdr->addr4;
+ if (a4_included)
+ pos += 6;
+ qc = *pos & 0x0f;
+ aad_len += 2;
+ }
+ /* CCM Initial Block:
+ * Flag (Include authentication header, M=3 (8-octet MIC),
+ * L=1 (2-octet Dlen))
+ * Nonce: 0x00 | A2 | PN
+ * Dlen */
+ b0[0] = 0x59;
+ b0[1] = qc;
+ memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
+ memcpy(b0 + 8, pn, CCMP_PN_LEN);
+ b0[14] = (dlen >> 8) & 0xff;
+ b0[15] = dlen & 0xff;
+
+ /* AAD:
+ * FC with bits 4..6 and 11..13 masked to zero; 14 is always one
+ * A1 | A2 | A3
+ * SC with bits 4..15 (seq#) masked to zero
+ * A4 (if present)
+ * QC (if present)
+ */
+ pos = (u8 *) hdr;
+ aad[0] = 0; /* aad_len >> 8 */
+ aad[1] = aad_len & 0xff;
+ aad[2] = pos[0] & 0x8f;
+ aad[3] = pos[1] & 0xc7;
+ memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
+ pos = (u8 *) &hdr->seq_ctl;
+ aad[22] = pos[0] & 0x0f;
+ aad[23] = 0; /* all bits masked */
+ memset(aad + 24, 0, 8);
+ if (a4_included)
+ memcpy(aad + 24, hdr->addr4, ETH_ALEN);
+ if (qc_included) {
+ aad[a4_included ? 30 : 24] = qc;
+ /* rest of QC masked */
+ }
+
+ /* Start with the first block and AAD */
+ ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
+ xor_block(auth, aad, AES_BLOCK_LEN);
+ ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
+ xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
+ ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
+ b0[0] &= 0x07;
+ b0[14] = b0[15] = 0;
+ ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
+}
+
+
+
+static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct ieee80211_ccmp_data *key = priv;
+ int data_len, i;
+ u8 *pos;
+ struct ieee80211_hdr_4addr *hdr;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+
+ if (skb_headroom(skb) < CCMP_HDR_LEN ||
+ skb_tailroom(skb) < CCMP_MIC_LEN ||
+ skb->len < hdr_len)
+ return -1;
+
+ data_len = skb->len - hdr_len;
+ pos = skb_push(skb, CCMP_HDR_LEN);
+ memmove(pos, pos + CCMP_HDR_LEN, hdr_len);
+ pos += hdr_len;
+// mic = skb_put(skb, CCMP_MIC_LEN);
+
+ i = CCMP_PN_LEN - 1;
+ while (i >= 0) {
+ key->tx_pn[i]++;
+ if (key->tx_pn[i] != 0)
+ break;
+ i--;
+ }
+
+ *pos++ = key->tx_pn[5];
+ *pos++ = key->tx_pn[4];
+ *pos++ = 0;
+ *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */;
+ *pos++ = key->tx_pn[3];
+ *pos++ = key->tx_pn[2];
+ *pos++ = key->tx_pn[1];
+ *pos++ = key->tx_pn[0];
+
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ if (!tcb_desc->bHwSec)
+ {
+ int blocks, last, len;
+ u8 *mic;
+ u8 *b0 = key->tx_b0;
+ u8 *b = key->tx_b;
+ u8 *e = key->tx_e;
+ u8 *s0 = key->tx_s0;
+
+ //mic is moved to here by john
+ mic = skb_put(skb, CCMP_MIC_LEN);
+
+ ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
+
+ blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
+ last = data_len % AES_BLOCK_LEN;
+
+ for (i = 1; i <= blocks; i++) {
+ len = (i == blocks && last) ? last : AES_BLOCK_LEN;
+ /* Authentication */
+ xor_block(b, pos, len);
+ ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
+ /* Encryption, with counter */
+ b0[14] = (i >> 8) & 0xff;
+ b0[15] = i & 0xff;
+ ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
+ xor_block(pos, e, len);
+ pos += len;
+ }
+
+ for (i = 0; i < CCMP_MIC_LEN; i++)
+ mic[i] = b[i] ^ s0[i];
+ }
+ return 0;
+}
+
+
+static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct ieee80211_ccmp_data *key = priv;
+ u8 keyidx, *pos;
+ struct ieee80211_hdr_4addr *hdr;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 pn[6];
+
+ if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
+ key->dot11RSNAStatsCCMPFormatErrors++;
+ return -1;
+ }
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ pos = skb->data + hdr_len;
+ keyidx = pos[3];
+ if (!(keyidx & (1 << 5))) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "CCMP: received packet without ExtIV"
+ " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
+ }
+ key->dot11RSNAStatsCCMPFormatErrors++;
+ return -2;
+ }
+ keyidx >>= 6;
+ if (key->key_idx != keyidx) {
+ printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame "
+ "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv);
+ return -6;
+ }
+ if (!key->key_set) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT
+ " with keyid=%d that does not have a configured"
+ " key\n", MAC_ARG(hdr->addr2), keyidx);
+ }
+ return -3;
+ }
+
+ pn[0] = pos[7];
+ pn[1] = pos[6];
+ pn[2] = pos[5];
+ pn[3] = pos[4];
+ pn[4] = pos[1];
+ pn[5] = pos[0];
+ pos += 8;
+
+ if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "CCMP: replay detected: STA=" MAC_FMT
+ " previous PN %02x%02x%02x%02x%02x%02x "
+ "received PN %02x%02x%02x%02x%02x%02x\n",
+ MAC_ARG(hdr->addr2), MAC_ARG(key->rx_pn),
+ MAC_ARG(pn));
+ }
+ key->dot11RSNAStatsCCMPReplays++;
+ return -4;
+ }
+ if (!tcb_desc->bHwSec)
+ {
+ size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
+ u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
+ u8 *b0 = key->rx_b0;
+ u8 *b = key->rx_b;
+ u8 *a = key->rx_a;
+ int i, blocks, last, len;
+
+
+ ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
+ xor_block(mic, b, CCMP_MIC_LEN);
+
+ blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
+ last = data_len % AES_BLOCK_LEN;
+
+ for (i = 1; i <= blocks; i++) {
+ len = (i == blocks && last) ? last : AES_BLOCK_LEN;
+ /* Decrypt, with counter */
+ b0[14] = (i >> 8) & 0xff;
+ b0[15] = i & 0xff;
+ ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
+ xor_block(pos, b, len);
+ /* Authentication */
+ xor_block(a, pos, len);
+ ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
+ pos += len;
+ }
+
+ if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "CCMP: decrypt failed: STA="
+ MAC_FMT "\n", MAC_ARG(hdr->addr2));
+ }
+ key->dot11RSNAStatsCCMPDecryptErrors++;
+ return -5;
+ }
+
+ memcpy(key->rx_pn, pn, CCMP_PN_LEN);
+ }
+ /* Remove hdr and MIC */
+ memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
+ skb_pull(skb, CCMP_HDR_LEN);
+ skb_trim(skb, skb->len - CCMP_MIC_LEN);
+
+ return keyidx;
+}
+
+
+static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
+{
+ struct ieee80211_ccmp_data *data = priv;
+ int keyidx;
+ struct crypto_tfm *tfm = data->tfm;
+
+ keyidx = data->key_idx;
+ memset(data, 0, sizeof(*data));
+ data->key_idx = keyidx;
+ data->tfm = tfm;
+ if (len == CCMP_TK_LEN) {
+ memcpy(data->key, key, CCMP_TK_LEN);
+ data->key_set = 1;
+ if (seq) {
+ data->rx_pn[0] = seq[5];
+ data->rx_pn[1] = seq[4];
+ data->rx_pn[2] = seq[3];
+ data->rx_pn[3] = seq[2];
+ data->rx_pn[4] = seq[1];
+ data->rx_pn[5] = seq[0];
+ }
+ crypto_cipher_setkey((void*)data->tfm, data->key, CCMP_TK_LEN);
+ } else if (len == 0)
+ data->key_set = 0;
+ else
+ return -1;
+
+ return 0;
+}
+
+
+static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
+{
+ struct ieee80211_ccmp_data *data = priv;
+
+ if (len < CCMP_TK_LEN)
+ return -1;
+
+ if (!data->key_set)
+ return 0;
+ memcpy(key, data->key, CCMP_TK_LEN);
+
+ if (seq) {
+ seq[0] = data->tx_pn[5];
+ seq[1] = data->tx_pn[4];
+ seq[2] = data->tx_pn[3];
+ seq[3] = data->tx_pn[2];
+ seq[4] = data->tx_pn[1];
+ seq[5] = data->tx_pn[0];
+ }
+
+ return CCMP_TK_LEN;
+}
+
+
+static char * ieee80211_ccmp_print_stats(char *p, void *priv)
+{
+ struct ieee80211_ccmp_data *ccmp = priv;
+ p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
+ "tx_pn=%02x%02x%02x%02x%02x%02x "
+ "rx_pn=%02x%02x%02x%02x%02x%02x "
+ "format_errors=%d replays=%d decrypt_errors=%d\n",
+ ccmp->key_idx, ccmp->key_set,
+ MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn),
+ ccmp->dot11RSNAStatsCCMPFormatErrors,
+ ccmp->dot11RSNAStatsCCMPReplays,
+ ccmp->dot11RSNAStatsCCMPDecryptErrors);
+
+ return p;
+}
+
+void ieee80211_ccmp_null(void)
+{
+// printk("============>%s()\n", __FUNCTION__);
+ return;
+}
+
+static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
+ .name = "CCMP",
+ .init = ieee80211_ccmp_init,
+ .deinit = ieee80211_ccmp_deinit,
+ .encrypt_mpdu = ieee80211_ccmp_encrypt,
+ .decrypt_mpdu = ieee80211_ccmp_decrypt,
+ .encrypt_msdu = NULL,
+ .decrypt_msdu = NULL,
+ .set_key = ieee80211_ccmp_set_key,
+ .get_key = ieee80211_ccmp_get_key,
+ .print_stats = ieee80211_ccmp_print_stats,
+ .extra_prefix_len = CCMP_HDR_LEN,
+ .extra_postfix_len = CCMP_MIC_LEN,
+ .owner = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_ccmp_init(void)
+{
+ return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
+}
+
+
+static void __exit ieee80211_crypto_ccmp_exit(void)
+{
+ ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
+}
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_ccmp_null);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_ccmp_null);
+#endif
+
+module_init(ieee80211_crypto_ccmp_init);
+module_exit(ieee80211_crypto_ccmp_exit);
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c
new file mode 100644
index 000000000000..b031b6495247
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c
@@ -0,0 +1,1034 @@
+/*
+ * Host AP crypt: host-based TKIP encryption implementation for Host AP driver
+ *
+ * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+//#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <asm/string.h>
+
+#include "ieee80211.h"
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
+//#include "crypto_compat.h"
+#endif
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#include "rtl_crypto.h"
+#else
+#include <linux/crypto.h>
+#endif
+//#include <asm/scatterlist.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ #include <asm/scatterlist.h>
+#else
+ #include <linux/scatterlist.h>
+#endif
+
+#include <linux/crc32.h>
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP crypt: TKIP");
+MODULE_LICENSE("GPL");
+
+#ifndef OPENSUSE_SLED
+#define OPENSUSE_SLED 0
+#endif
+
+struct ieee80211_tkip_data {
+#define TKIP_KEY_LEN 32
+ u8 key[TKIP_KEY_LEN];
+ int key_set;
+
+ u32 tx_iv32;
+ u16 tx_iv16;
+ u16 tx_ttak[5];
+ int tx_phase1_done;
+
+ u32 rx_iv32;
+ u16 rx_iv16;
+ u16 rx_ttak[5];
+ int rx_phase1_done;
+ u32 rx_iv32_new;
+ u16 rx_iv16_new;
+
+ u32 dot11RSNAStatsTKIPReplays;
+ u32 dot11RSNAStatsTKIPICVErrors;
+ u32 dot11RSNAStatsTKIPLocalMICFailures;
+
+ int key_idx;
+#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
+ struct crypto_blkcipher *rx_tfm_arc4;
+ struct crypto_hash *rx_tfm_michael;
+ struct crypto_blkcipher *tx_tfm_arc4;
+ struct crypto_hash *tx_tfm_michael;
+#else
+ struct crypto_tfm *tx_tfm_arc4;
+ struct crypto_tfm *tx_tfm_michael;
+ struct crypto_tfm *rx_tfm_arc4;
+ struct crypto_tfm *rx_tfm_michael;
+#endif
+ /* scratch buffers for virt_to_page() (crypto API) */
+ u8 rx_hdr[16], tx_hdr[16];
+};
+
+static void * ieee80211_tkip_init(int key_idx)
+{
+ struct ieee80211_tkip_data *priv;
+
+ priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+ if (priv == NULL)
+ goto fail;
+ memset(priv, 0, sizeof(*priv));
+ priv->key_idx = key_idx;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ priv->tx_tfm_arc4 = crypto_alloc_tfm("arc4", 0);
+ if (priv->tx_tfm_arc4 == NULL) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API arc4\n");
+ goto fail;
+ }
+
+ priv->tx_tfm_michael = crypto_alloc_tfm("michael_mic", 0);
+ if (priv->tx_tfm_michael == NULL) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API michael_mic\n");
+ goto fail;
+ }
+
+ priv->rx_tfm_arc4 = crypto_alloc_tfm("arc4", 0);
+ if (priv->rx_tfm_arc4 == NULL) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API arc4\n");
+ goto fail;
+ }
+
+ priv->rx_tfm_michael = crypto_alloc_tfm("michael_mic", 0);
+ if (priv->rx_tfm_michael == NULL) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API michael_mic\n");
+ goto fail;
+ }
+#else
+ priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->tx_tfm_arc4)) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API arc4\n");
+ priv->tx_tfm_arc4 = NULL;
+ goto fail;
+ }
+
+ priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->tx_tfm_michael)) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API michael_mic\n");
+ priv->tx_tfm_michael = NULL;
+ goto fail;
+ }
+
+ priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->rx_tfm_arc4)) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API arc4\n");
+ priv->rx_tfm_arc4 = NULL;
+ goto fail;
+ }
+
+ priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->rx_tfm_michael)) {
+ printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+ "crypto API michael_mic\n");
+ priv->rx_tfm_michael = NULL;
+ goto fail;
+ }
+#endif
+ return priv;
+
+fail:
+ if (priv) {
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ if (priv->tx_tfm_michael)
+ crypto_free_tfm(priv->tx_tfm_michael);
+ if (priv->tx_tfm_arc4)
+ crypto_free_tfm(priv->tx_tfm_arc4);
+ if (priv->rx_tfm_michael)
+ crypto_free_tfm(priv->rx_tfm_michael);
+ if (priv->rx_tfm_arc4)
+ crypto_free_tfm(priv->rx_tfm_arc4);
+
+#else
+ if (priv->tx_tfm_michael)
+ crypto_free_hash(priv->tx_tfm_michael);
+ if (priv->tx_tfm_arc4)
+ crypto_free_blkcipher(priv->tx_tfm_arc4);
+ if (priv->rx_tfm_michael)
+ crypto_free_hash(priv->rx_tfm_michael);
+ if (priv->rx_tfm_arc4)
+ crypto_free_blkcipher(priv->rx_tfm_arc4);
+#endif
+ kfree(priv);
+ }
+
+ return NULL;
+}
+
+
+static void ieee80211_tkip_deinit(void *priv)
+{
+ struct ieee80211_tkip_data *_priv = priv;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ if (_priv->tx_tfm_michael)
+ crypto_free_tfm(_priv->tx_tfm_michael);
+ if (_priv->tx_tfm_arc4)
+ crypto_free_tfm(_priv->tx_tfm_arc4);
+ if (_priv->rx_tfm_michael)
+ crypto_free_tfm(_priv->rx_tfm_michael);
+ if (_priv->rx_tfm_arc4)
+ crypto_free_tfm(_priv->rx_tfm_arc4);
+#else
+ if (_priv) {
+ if (_priv->tx_tfm_michael)
+ crypto_free_hash(_priv->tx_tfm_michael);
+ if (_priv->tx_tfm_arc4)
+ crypto_free_blkcipher(_priv->tx_tfm_arc4);
+ if (_priv->rx_tfm_michael)
+ crypto_free_hash(_priv->rx_tfm_michael);
+ if (_priv->rx_tfm_arc4)
+ crypto_free_blkcipher(_priv->rx_tfm_arc4);
+ }
+#endif
+ kfree(priv);
+}
+
+
+static inline u16 RotR1(u16 val)
+{
+ return (val >> 1) | (val << 15);
+}
+
+
+static inline u8 Lo8(u16 val)
+{
+ return val & 0xff;
+}
+
+
+static inline u8 Hi8(u16 val)
+{
+ return val >> 8;
+}
+
+
+static inline u16 Lo16(u32 val)
+{
+ return val & 0xffff;
+}
+
+
+static inline u16 Hi16(u32 val)
+{
+ return val >> 16;
+}
+
+
+static inline u16 Mk16(u8 hi, u8 lo)
+{
+ return lo | (((u16) hi) << 8);
+}
+
+
+static inline u16 Mk16_le(u16 *v)
+{
+ return le16_to_cpu(*v);
+}
+
+
+static const u16 Sbox[256] =
+{
+ 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
+ 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
+ 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
+ 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
+ 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
+ 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
+ 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
+ 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
+ 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
+ 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
+ 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
+ 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
+ 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
+ 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
+ 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
+ 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
+ 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
+ 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
+ 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
+ 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
+ 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
+ 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
+ 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
+ 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
+ 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
+ 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
+ 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
+ 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
+ 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
+ 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
+ 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
+ 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
+};
+
+
+static inline u16 _S_(u16 v)
+{
+ u16 t = Sbox[Hi8(v)];
+ return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
+}
+
+
+#define PHASE1_LOOP_COUNT 8
+
+
+static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
+{
+ int i, j;
+
+ /* Initialize the 80-bit TTAK from TSC (IV32) and TA[0..5] */
+ TTAK[0] = Lo16(IV32);
+ TTAK[1] = Hi16(IV32);
+ TTAK[2] = Mk16(TA[1], TA[0]);
+ TTAK[3] = Mk16(TA[3], TA[2]);
+ TTAK[4] = Mk16(TA[5], TA[4]);
+
+ for (i = 0; i < PHASE1_LOOP_COUNT; i++) {
+ j = 2 * (i & 1);
+ TTAK[0] += _S_(TTAK[4] ^ Mk16(TK[1 + j], TK[0 + j]));
+ TTAK[1] += _S_(TTAK[0] ^ Mk16(TK[5 + j], TK[4 + j]));
+ TTAK[2] += _S_(TTAK[1] ^ Mk16(TK[9 + j], TK[8 + j]));
+ TTAK[3] += _S_(TTAK[2] ^ Mk16(TK[13 + j], TK[12 + j]));
+ TTAK[4] += _S_(TTAK[3] ^ Mk16(TK[1 + j], TK[0 + j])) + i;
+ }
+}
+
+
+static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
+ u16 IV16)
+{
+ /* Make temporary area overlap WEP seed so that the final copy can be
+ * avoided on little endian hosts. */
+ u16 *PPK = (u16 *) &WEPSeed[4];
+
+ /* Step 1 - make copy of TTAK and bring in TSC */
+ PPK[0] = TTAK[0];
+ PPK[1] = TTAK[1];
+ PPK[2] = TTAK[2];
+ PPK[3] = TTAK[3];
+ PPK[4] = TTAK[4];
+ PPK[5] = TTAK[4] + IV16;
+
+ /* Step 2 - 96-bit bijective mixing using S-box */
+ PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
+ PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
+ PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
+ PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
+ PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
+ PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
+
+ PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
+ PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
+ PPK[2] += RotR1(PPK[1]);
+ PPK[3] += RotR1(PPK[2]);
+ PPK[4] += RotR1(PPK[3]);
+ PPK[5] += RotR1(PPK[4]);
+
+ /* Step 3 - bring in last of TK bits, assign 24-bit WEP IV value
+ * WEPSeed[0..2] is transmitted as WEP IV */
+ WEPSeed[0] = Hi8(IV16);
+ WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
+ WEPSeed[2] = Lo8(IV16);
+ WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
+
+#ifdef __BIG_ENDIAN
+ {
+ int i;
+ for (i = 0; i < 6; i++)
+ PPK[i] = (PPK[i] << 8) | (PPK[i] >> 8);
+ }
+#endif
+}
+
+
+static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct ieee80211_tkip_data *tkey = priv;
+ int len;
+ u8 *pos;
+ struct ieee80211_hdr_4addr *hdr;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+
+ #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
+ struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4};
+ int ret = 0;
+ #endif
+ u8 rc4key[16], *icv;
+ u32 crc;
+ struct scatterlist sg;
+
+ if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
+ skb->len < hdr_len)
+ return -1;
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+
+#if 0
+printk("@@ tkey\n");
+printk("%x|", ((u32*)tkey->key)[0]);
+printk("%x|", ((u32*)tkey->key)[1]);
+printk("%x|", ((u32*)tkey->key)[2]);
+printk("%x|", ((u32*)tkey->key)[3]);
+printk("%x|", ((u32*)tkey->key)[4]);
+printk("%x|", ((u32*)tkey->key)[5]);
+printk("%x|", ((u32*)tkey->key)[6]);
+printk("%x\n", ((u32*)tkey->key)[7]);
+#endif
+
+ if (!tcb_desc->bHwSec)
+ {
+ if (!tkey->tx_phase1_done) {
+ tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
+ tkey->tx_iv32);
+ tkey->tx_phase1_done = 1;
+ }
+ tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
+ }
+ else
+ tkey->tx_phase1_done = 1;
+
+
+ len = skb->len - hdr_len;
+ pos = skb_push(skb, 8);
+ memmove(pos, pos + 8, hdr_len);
+ pos += hdr_len;
+
+ if (tcb_desc->bHwSec)
+ {
+ *pos++ = Hi8(tkey->tx_iv16);
+ *pos++ = (Hi8(tkey->tx_iv16) | 0x20) & 0x7F;
+ *pos++ = Lo8(tkey->tx_iv16);
+ }
+ else
+ {
+ *pos++ = rc4key[0];
+ *pos++ = rc4key[1];
+ *pos++ = rc4key[2];
+ }
+
+ *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
+ *pos++ = tkey->tx_iv32 & 0xff;
+ *pos++ = (tkey->tx_iv32 >> 8) & 0xff;
+ *pos++ = (tkey->tx_iv32 >> 16) & 0xff;
+ *pos++ = (tkey->tx_iv32 >> 24) & 0xff;
+
+ if (!tcb_desc->bHwSec)
+ {
+ icv = skb_put(skb, 4);
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ crc = ~crc32_le(~0, pos, len);
+#else
+ crc = ~ether_crc_le(len, pos);
+#endif
+ icv[0] = crc;
+ icv[1] = crc >> 8;
+ icv[2] = crc >> 16;
+ icv[3] = crc >> 24;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ crypto_cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = len + 4;
+ crypto_cipher_encrypt(tkey->tx_tfm_arc4, &sg, &sg, len + 4);
+#else
+ crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = len + 4;
+#else
+ sg_init_one(&sg, pos, len+4);
+#endif
+ ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
+#endif
+
+ }
+
+ tkey->tx_iv16++;
+ if (tkey->tx_iv16 == 0) {
+ tkey->tx_phase1_done = 0;
+ tkey->tx_iv32++;
+ }
+
+ if (!tcb_desc->bHwSec)
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ return 0;
+ #else
+ return ret;
+ #endif
+ else
+ return 0;
+
+
+}
+
+static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct ieee80211_tkip_data *tkey = priv;
+ u8 keyidx, *pos;
+ u32 iv32;
+ u16 iv16;
+ struct ieee80211_hdr_4addr *hdr;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
+ struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4};
+ #endif
+ u8 rc4key[16];
+ u8 icv[4];
+ u32 crc;
+ struct scatterlist sg;
+ int plen;
+ if (skb->len < hdr_len + 8 + 4)
+ return -1;
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ pos = skb->data + hdr_len;
+ keyidx = pos[3];
+ if (!(keyidx & (1 << 5))) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+ " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
+ }
+ return -2;
+ }
+ keyidx >>= 6;
+ if (tkey->key_idx != keyidx) {
+ printk(KERN_DEBUG "TKIP: RX tkey->key_idx=%d frame "
+ "keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv);
+ return -6;
+ }
+ if (!tkey->key_set) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT
+ " with keyid=%d that does not have a configured"
+ " key\n", MAC_ARG(hdr->addr2), keyidx);
+ }
+ return -3;
+ }
+ iv16 = (pos[0] << 8) | pos[2];
+ iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
+ pos += 8;
+
+ if (!tcb_desc->bHwSec)
+ {
+ if (iv32 < tkey->rx_iv32 ||
+ (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT
+ " previous TSC %08x%04x received TSC "
+ "%08x%04x\n", MAC_ARG(hdr->addr2),
+ tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
+ }
+ tkey->dot11RSNAStatsTKIPReplays++;
+ return -4;
+ }
+
+ if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
+ tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
+ tkey->rx_phase1_done = 1;
+ }
+ tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
+
+ plen = skb->len - hdr_len - 12;
+
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ crypto_cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = plen + 4;
+ crypto_cipher_decrypt(tkey->rx_tfm_arc4, &sg, &sg, plen + 4);
+#else
+ crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = plen + 4;
+#else
+ sg_init_one(&sg, pos, plen+4);
+#endif
+ if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG ": TKIP: failed to decrypt "
+ "received packet from " MAC_FMT "\n",
+ MAC_ARG(hdr->addr2));
+ }
+ return -7;
+ }
+#endif
+
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ crc = ~crc32_le(~0, pos, plen);
+ #else
+ crc = ~ether_crc_le(plen, pos);
+ #endif
+ icv[0] = crc;
+ icv[1] = crc >> 8;
+ icv[2] = crc >> 16;
+ icv[3] = crc >> 24;
+
+ if (memcmp(icv, pos + plen, 4) != 0) {
+ if (iv32 != tkey->rx_iv32) {
+ /* Previously cached Phase1 result was already lost, so
+ * it needs to be recalculated for the next packet. */
+ tkey->rx_phase1_done = 0;
+ }
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "TKIP: ICV error detected: STA="
+ MAC_FMT "\n", MAC_ARG(hdr->addr2));
+ }
+ tkey->dot11RSNAStatsTKIPICVErrors++;
+ return -5;
+ }
+
+ }
+
+ /* Update real counters only after Michael MIC verification has
+ * completed */
+ tkey->rx_iv32_new = iv32;
+ tkey->rx_iv16_new = iv16;
+
+ /* Remove IV and ICV */
+ memmove(skb->data + 8, skb->data, hdr_len);
+ skb_pull(skb, 8);
+ skb_trim(skb, skb->len - 4);
+
+//john's test
+#ifdef JOHN_DUMP
+if( ((u16*)skb->data)[0] & 0x4000){
+ printk("@@ rx decrypted skb->data");
+ int i;
+ for(i=0;i<skb->len;i++){
+ if( (i%24)==0 ) printk("\n");
+ printk("%2x ", ((u8*)skb->data)[i]);
+ }
+ printk("\n");
+}
+#endif /*JOHN_DUMP*/
+ return keyidx;
+}
+
+
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+static int michael_mic(struct crypto_tfm * tfm_michael, u8 *key, u8 *hdr,
+ u8 *data, size_t data_len, u8 *mic)
+{
+ struct scatterlist sg[2];
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ struct hash_desc desc;
+ int ret = 0;
+#endif
+
+ if (tfm_michael == NULL){
+ printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
+ return -1;
+ }
+ sg[0].page = virt_to_page(hdr);
+ sg[0].offset = offset_in_page(hdr);
+ sg[0].length = 16;
+
+ sg[1].page = virt_to_page(data);
+ sg[1].offset = offset_in_page(data);
+ sg[1].length = data_len;
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ crypto_digest_init(tfm_michael);
+ crypto_digest_setkey(tfm_michael, key, 8);
+ crypto_digest_update(tfm_michael, sg, 2);
+ crypto_digest_final(tfm_michael, mic);
+ return 0;
+#else
+if (crypto_hash_setkey(tkey->tfm_michael, key, 8))
+ return -1;
+
+// return 0;
+ desc.tfm = tkey->tfm_michael;
+ desc.flags = 0;
+ ret = crypto_hash_digest(&desc, sg, data_len + 16, mic);
+ return ret;
+#endif
+}
+#else
+static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
+ u8 * data, size_t data_len, u8 * mic)
+{
+ struct hash_desc desc;
+ struct scatterlist sg[2];
+
+ if (tfm_michael == NULL) {
+ printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
+ return -1;
+ }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+ sg[0].page = virt_to_page(hdr);
+ sg[0].offset = offset_in_page(hdr);
+ sg[0].length = 16;
+
+ sg[1].page = virt_to_page(data);
+ sg[1].offset = offset_in_page(data);
+ sg[1].length = data_len;
+#else
+ sg_init_table(sg, 2);
+ sg_set_buf(&sg[0], hdr, 16);
+ sg_set_buf(&sg[1], data, data_len);
+#endif
+
+ if (crypto_hash_setkey(tfm_michael, key, 8))
+ return -1;
+
+ desc.tfm = tfm_michael;
+ desc.flags = 0;
+ return crypto_hash_digest(&desc, sg, data_len + 16, mic);
+}
+#endif
+
+
+
+static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
+{
+ struct ieee80211_hdr_4addr *hdr11;
+
+ hdr11 = (struct ieee80211_hdr_4addr *) skb->data;
+ switch (le16_to_cpu(hdr11->frame_ctl) &
+ (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
+ case IEEE80211_FCTL_TODS:
+ memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+ break;
+ case IEEE80211_FCTL_FROMDS:
+ memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+ break;
+ case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
+ memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+ break;
+ case 0:
+ memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+ memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+ break;
+ }
+
+ hdr[12] = 0; /* priority */
+
+ hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
+}
+
+
+static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct ieee80211_tkip_data *tkey = priv;
+ u8 *pos;
+ struct ieee80211_hdr_4addr *hdr;
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+
+ if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
+ printk(KERN_DEBUG "Invalid packet for Michael MIC add "
+ "(tailroom=%d hdr_len=%d skb->len=%d)\n",
+ skb_tailroom(skb), hdr_len, skb->len);
+ return -1;
+ }
+
+ michael_mic_hdr(skb, tkey->tx_hdr);
+
+ // { david, 2006.9.1
+ // fix the wpa process with wmm enabled.
+ if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) {
+ tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
+ }
+ // }
+ pos = skb_put(skb, 8);
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
+ skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
+#else
+ if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
+ skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
+#endif
+ return -1;
+
+ return 0;
+}
+
+
+#if WIRELESS_EXT >= 18
+static void ieee80211_michael_mic_failure(struct net_device *dev,
+ struct ieee80211_hdr_4addr *hdr,
+ int keyidx)
+{
+ union iwreq_data wrqu;
+ struct iw_michaelmicfailure ev;
+
+ /* TODO: needed parameters: count, keyid, key type, TSC */
+ memset(&ev, 0, sizeof(ev));
+ ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
+ if (hdr->addr1[0] & 0x01)
+ ev.flags |= IW_MICFAILURE_GROUP;
+ else
+ ev.flags |= IW_MICFAILURE_PAIRWISE;
+ ev.src_addr.sa_family = ARPHRD_ETHER;
+ memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = sizeof(ev);
+ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
+}
+#elif WIRELESS_EXT >= 15
+static void ieee80211_michael_mic_failure(struct net_device *dev,
+ struct ieee80211_hdr_4addr *hdr,
+ int keyidx)
+{
+ union iwreq_data wrqu;
+ char buf[128];
+
+ /* TODO: needed parameters: count, keyid, key type, TSC */
+ sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
+ MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
+ MAC_ARG(hdr->addr2));
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = strlen(buf);
+ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
+}
+#else /* WIRELESS_EXT >= 15 */
+static inline void ieee80211_michael_mic_failure(struct net_device *dev,
+ struct ieee80211_hdr_4addr *hdr,
+ int keyidx)
+{
+}
+#endif /* WIRELESS_EXT >= 15 */
+
+static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
+ int hdr_len, void *priv)
+{
+ struct ieee80211_tkip_data *tkey = priv;
+ u8 mic[8];
+ struct ieee80211_hdr_4addr *hdr;
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+
+ if (!tkey->key_set)
+ return -1;
+
+ michael_mic_hdr(skb, tkey->rx_hdr);
+ // { david, 2006.9.1
+ // fix the wpa process with wmm enabled.
+ if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) {
+ tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
+ }
+ // }
+
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
+ skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
+#else
+ if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
+ skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
+#endif
+ return -1;
+ if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
+ struct ieee80211_hdr_4addr *hdr;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ printk(KERN_DEBUG "%s: Michael MIC verification failed for "
+ "MSDU from " MAC_FMT " keyidx=%d\n",
+ skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
+ keyidx);
+ if (skb->dev)
+ ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
+ tkey->dot11RSNAStatsTKIPLocalMICFailures++;
+ return -1;
+ }
+
+ /* Update TSC counters for RX now that the packet verification has
+ * completed. */
+ tkey->rx_iv32 = tkey->rx_iv32_new;
+ tkey->rx_iv16 = tkey->rx_iv16_new;
+
+ skb_trim(skb, skb->len - 8);
+
+ return 0;
+}
+
+
+static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
+{
+ struct ieee80211_tkip_data *tkey = priv;
+ int keyidx;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ struct crypto_tfm *tfm = tkey->tx_tfm_michael;
+ struct crypto_tfm *tfm2 = tkey->tx_tfm_arc4;
+ struct crypto_tfm *tfm3 = tkey->rx_tfm_michael;
+ struct crypto_tfm *tfm4 = tkey->rx_tfm_arc4;
+#else
+ struct crypto_hash *tfm = tkey->tx_tfm_michael;
+ struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
+ struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
+ struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
+#endif
+
+ keyidx = tkey->key_idx;
+ memset(tkey, 0, sizeof(*tkey));
+ tkey->key_idx = keyidx;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ tkey->tx_tfm_michael = tfm;
+ tkey->tx_tfm_arc4 = tfm2;
+ tkey->rx_tfm_michael = tfm3;
+ tkey->rx_tfm_arc4 = tfm4;
+#else
+ tkey->tx_tfm_michael = tfm;
+ tkey->tx_tfm_arc4 = tfm2;
+ tkey->rx_tfm_michael = tfm3;
+ tkey->rx_tfm_arc4 = tfm4;
+#endif
+
+ if (len == TKIP_KEY_LEN) {
+ memcpy(tkey->key, key, TKIP_KEY_LEN);
+ tkey->key_set = 1;
+ tkey->tx_iv16 = 1; /* TSC is initialized to 1 */
+ if (seq) {
+ tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) |
+ (seq[3] << 8) | seq[2];
+ tkey->rx_iv16 = (seq[1] << 8) | seq[0];
+ }
+ } else if (len == 0)
+ tkey->key_set = 0;
+ else
+ return -1;
+
+ return 0;
+}
+
+
+static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
+{
+ struct ieee80211_tkip_data *tkey = priv;
+
+ if (len < TKIP_KEY_LEN)
+ return -1;
+
+ if (!tkey->key_set)
+ return 0;
+ memcpy(key, tkey->key, TKIP_KEY_LEN);
+
+ if (seq) {
+ /* Return the sequence number of the last transmitted frame. */
+ u16 iv16 = tkey->tx_iv16;
+ u32 iv32 = tkey->tx_iv32;
+ if (iv16 == 0)
+ iv32--;
+ iv16--;
+ seq[0] = tkey->tx_iv16;
+ seq[1] = tkey->tx_iv16 >> 8;
+ seq[2] = tkey->tx_iv32;
+ seq[3] = tkey->tx_iv32 >> 8;
+ seq[4] = tkey->tx_iv32 >> 16;
+ seq[5] = tkey->tx_iv32 >> 24;
+ }
+
+ return TKIP_KEY_LEN;
+}
+
+
+static char * ieee80211_tkip_print_stats(char *p, void *priv)
+{
+ struct ieee80211_tkip_data *tkip = priv;
+ p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
+ "tx_pn=%02x%02x%02x%02x%02x%02x "
+ "rx_pn=%02x%02x%02x%02x%02x%02x "
+ "replays=%d icv_errors=%d local_mic_failures=%d\n",
+ tkip->key_idx, tkip->key_set,
+ (tkip->tx_iv32 >> 24) & 0xff,
+ (tkip->tx_iv32 >> 16) & 0xff,
+ (tkip->tx_iv32 >> 8) & 0xff,
+ tkip->tx_iv32 & 0xff,
+ (tkip->tx_iv16 >> 8) & 0xff,
+ tkip->tx_iv16 & 0xff,
+ (tkip->rx_iv32 >> 24) & 0xff,
+ (tkip->rx_iv32 >> 16) & 0xff,
+ (tkip->rx_iv32 >> 8) & 0xff,
+ tkip->rx_iv32 & 0xff,
+ (tkip->rx_iv16 >> 8) & 0xff,
+ tkip->rx_iv16 & 0xff,
+ tkip->dot11RSNAStatsTKIPReplays,
+ tkip->dot11RSNAStatsTKIPICVErrors,
+ tkip->dot11RSNAStatsTKIPLocalMICFailures);
+ return p;
+}
+
+
+static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
+ .name = "TKIP",
+ .init = ieee80211_tkip_init,
+ .deinit = ieee80211_tkip_deinit,
+ .encrypt_mpdu = ieee80211_tkip_encrypt,
+ .decrypt_mpdu = ieee80211_tkip_decrypt,
+ .encrypt_msdu = ieee80211_michael_mic_add,
+ .decrypt_msdu = ieee80211_michael_mic_verify,
+ .set_key = ieee80211_tkip_set_key,
+ .get_key = ieee80211_tkip_get_key,
+ .print_stats = ieee80211_tkip_print_stats,
+ .extra_prefix_len = 4 + 4, /* IV + ExtIV */
+ .extra_postfix_len = 8 + 4, /* MIC + ICV */
+ .owner = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_tkip_init(void)
+{
+ return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
+}
+
+
+static void __exit ieee80211_crypto_tkip_exit(void)
+{
+ ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
+}
+
+void ieee80211_tkip_null(void)
+{
+// printk("============>%s()\n", __FUNCTION__);
+ return;
+}
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_tkip_null);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_tkip_null);
+#endif
+
+module_init(ieee80211_crypto_tkip_init);
+module_exit(ieee80211_crypto_tkip_exit);
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c
new file mode 100644
index 000000000000..7e394328ec90
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c
@@ -0,0 +1,397 @@
+/*
+ * Host AP crypt: host-based WEP encryption implementation for Host AP driver
+ *
+ * Copyright (c) 2002-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+//#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/skbuff.h>
+#include <asm/string.h>
+
+#include "ieee80211.h"
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
+//#include "crypto_compat.h"
+#endif
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#include "rtl_crypto.h"
+#else
+#include <linux/crypto.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ #include <asm/scatterlist.h>
+#else
+ #include <linux/scatterlist.h>
+#endif
+//#include <asm/scatterlist.h>
+#include <linux/crc32.h>
+//
+/*
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#include "rtl_crypto.h"
+#else
+#include <linux/crypto.h>
+#endif
+
+#include <asm/scatterlist.h>
+#include <linux/crc32.h>
+*/
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP crypt: WEP");
+MODULE_LICENSE("GPL");
+#ifndef OPENSUSE_SLED
+#define OPENSUSE_SLED 0
+#endif
+
+struct prism2_wep_data {
+ u32 iv;
+#define WEP_KEY_LEN 13
+ u8 key[WEP_KEY_LEN + 1];
+ u8 key_len;
+ u8 key_idx;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ struct crypto_tfm *tfm;
+ #else
+ struct crypto_blkcipher *tx_tfm;
+ struct crypto_blkcipher *rx_tfm;
+ #endif
+};
+
+
+static void * prism2_wep_init(int keyidx)
+{
+ struct prism2_wep_data *priv;
+
+ priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+ if (priv == NULL)
+ goto fail;
+ memset(priv, 0, sizeof(*priv));
+ priv->key_idx = keyidx;
+
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ priv->tfm = crypto_alloc_tfm("arc4", 0);
+ if (priv->tfm == NULL) {
+ printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
+ "crypto API arc4\n");
+ goto fail;
+ }
+ #else
+ priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->tx_tfm)) {
+ printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
+ "crypto API arc4\n");
+ priv->tx_tfm = NULL;
+ goto fail;
+ }
+ priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->rx_tfm)) {
+ printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
+ "crypto API arc4\n");
+ priv->rx_tfm = NULL;
+ goto fail;
+ }
+ #endif
+
+ /* start WEP IV from a random value */
+ get_random_bytes(&priv->iv, 4);
+
+ return priv;
+
+fail:
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ if (priv) {
+ if (priv->tfm)
+ crypto_free_tfm(priv->tfm);
+ kfree(priv);
+ }
+ #else
+ if (priv) {
+ if (priv->tx_tfm)
+ crypto_free_blkcipher(priv->tx_tfm);
+ if (priv->rx_tfm)
+ crypto_free_blkcipher(priv->rx_tfm);
+ kfree(priv);
+ }
+ #endif
+ return NULL;
+}
+
+
+static void prism2_wep_deinit(void *priv)
+{
+ struct prism2_wep_data *_priv = priv;
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ if (_priv && _priv->tfm)
+ crypto_free_tfm(_priv->tfm);
+ #else
+ if (_priv) {
+ if (_priv->tx_tfm)
+ crypto_free_blkcipher(_priv->tx_tfm);
+ if (_priv->rx_tfm)
+ crypto_free_blkcipher(_priv->rx_tfm);
+ }
+ #endif
+ kfree(priv);
+}
+
+/* Perform WEP encryption on given skb that has at least 4 bytes of headroom
+ * for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted,
+ * so the payload length increases with 8 bytes.
+ *
+ * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
+ */
+static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct prism2_wep_data *wep = priv;
+ u32 klen, len;
+ u8 key[WEP_KEY_LEN + 3];
+ u8 *pos;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
+ struct blkcipher_desc desc = {.tfm = wep->tx_tfm};
+ #endif
+ u32 crc;
+ u8 *icv;
+ struct scatterlist sg;
+ if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
+ skb->len < hdr_len)
+ return -1;
+
+ len = skb->len - hdr_len;
+ pos = skb_push(skb, 4);
+ memmove(pos, pos + 4, hdr_len);
+ pos += hdr_len;
+
+ klen = 3 + wep->key_len;
+
+ wep->iv++;
+
+ /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key
+ * scheduling algorithm of RC4. At least IVs (KeyByte + 3, 0xff, N)
+ * can be used to speedup attacks, so avoid using them. */
+ if ((wep->iv & 0xff00) == 0xff00) {
+ u8 B = (wep->iv >> 16) & 0xff;
+ if (B >= 3 && B < klen)
+ wep->iv += 0x0100;
+ }
+
+ /* Prepend 24-bit IV to RC4 key and TX frame */
+ *pos++ = key[0] = (wep->iv >> 16) & 0xff;
+ *pos++ = key[1] = (wep->iv >> 8) & 0xff;
+ *pos++ = key[2] = wep->iv & 0xff;
+ *pos++ = wep->key_idx << 6;
+
+ /* Copy rest of the WEP key (the secret part) */
+ memcpy(key + 3, wep->key, wep->key_len);
+
+ if (!tcb_desc->bHwSec)
+ {
+
+ /* Append little-endian CRC32 and encrypt it to produce ICV */
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ crc = ~crc32_le(~0, pos, len);
+ #else
+ crc = ~ether_crc_le(len, pos);
+ #endif
+ icv = skb_put(skb, 4);
+ icv[0] = crc;
+ icv[1] = crc >> 8;
+ icv[2] = crc >> 16;
+ icv[3] = crc >> 24;
+
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ crypto_cipher_setkey(wep->tfm, key, klen);
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = len + 4;
+ crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
+ return 0;
+ #else
+ crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
+ #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = len + 4;
+ #else
+ sg_init_one(&sg, pos, len+4);
+ #endif
+ return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
+ #endif
+ }
+
+ return 0;
+}
+
+
+/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of
+ * the frame: IV (4 bytes), encrypted payload (including SNAP header),
+ * ICV (4 bytes). len includes both IV and ICV.
+ *
+ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
+ * failure. If frame is OK, IV and ICV will be removed.
+ */
+static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+ struct prism2_wep_data *wep = priv;
+ u32 klen, plen;
+ u8 key[WEP_KEY_LEN + 3];
+ u8 keyidx, *pos;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) || (OPENSUSE_SLED))
+ struct blkcipher_desc desc = {.tfm = wep->rx_tfm};
+ #endif
+ u32 crc;
+ u8 icv[4];
+ struct scatterlist sg;
+ if (skb->len < hdr_len + 8)
+ return -1;
+
+ pos = skb->data + hdr_len;
+ key[0] = *pos++;
+ key[1] = *pos++;
+ key[2] = *pos++;
+ keyidx = *pos++ >> 6;
+ if (keyidx != wep->key_idx)
+ return -1;
+
+ klen = 3 + wep->key_len;
+
+ /* Copy rest of the WEP key (the secret part) */
+ memcpy(key + 3, wep->key, wep->key_len);
+
+ /* Apply RC4 to data and compute CRC32 over decrypted data */
+ plen = skb->len - hdr_len - 8;
+
+ if (!tcb_desc->bHwSec)
+ {
+#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
+ crypto_cipher_setkey(wep->tfm, key, klen);
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = plen + 4;
+ crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
+ #else
+ crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
+ #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ sg.page = virt_to_page(pos);
+ sg.offset = offset_in_page(pos);
+ sg.length = plen + 4;
+ #else
+ sg_init_one(&sg, pos, plen+4);
+ #endif
+ if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
+ return -7;
+ #endif
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ crc = ~crc32_le(~0, pos, plen);
+ #else
+ crc = ~ether_crc_le(plen, pos);
+ #endif
+ icv[0] = crc;
+ icv[1] = crc >> 8;
+ icv[2] = crc >> 16;
+ icv[3] = crc >> 24;
+ if (memcmp(icv, pos + plen, 4) != 0) {
+ /* ICV mismatch - drop frame */
+ return -2;
+ }
+ }
+ /* Remove IV and ICV */
+ memmove(skb->data + 4, skb->data, hdr_len);
+ skb_pull(skb, 4);
+ skb_trim(skb, skb->len - 4);
+
+ return 0;
+}
+
+
+static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
+{
+ struct prism2_wep_data *wep = priv;
+
+ if (len < 0 || len > WEP_KEY_LEN)
+ return -1;
+
+ memcpy(wep->key, key, len);
+ wep->key_len = len;
+
+ return 0;
+}
+
+
+static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
+{
+ struct prism2_wep_data *wep = priv;
+
+ if (len < wep->key_len)
+ return -1;
+
+ memcpy(key, wep->key, wep->key_len);
+
+ return wep->key_len;
+}
+
+
+static char * prism2_wep_print_stats(char *p, void *priv)
+{
+ struct prism2_wep_data *wep = priv;
+ p += sprintf(p, "key[%d] alg=WEP len=%d\n",
+ wep->key_idx, wep->key_len);
+ return p;
+}
+
+
+static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
+ .name = "WEP",
+ .init = prism2_wep_init,
+ .deinit = prism2_wep_deinit,
+ .encrypt_mpdu = prism2_wep_encrypt,
+ .decrypt_mpdu = prism2_wep_decrypt,
+ .encrypt_msdu = NULL,
+ .decrypt_msdu = NULL,
+ .set_key = prism2_wep_set_key,
+ .get_key = prism2_wep_get_key,
+ .print_stats = prism2_wep_print_stats,
+ .extra_prefix_len = 4, /* IV */
+ .extra_postfix_len = 4, /* ICV */
+ .owner = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_wep_init(void)
+{
+ return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
+}
+
+
+static void __exit ieee80211_crypto_wep_exit(void)
+{
+ ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
+}
+
+void ieee80211_wep_null(void)
+{
+// printk("============>%s()\n", __FUNCTION__);
+ return;
+}
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_wep_null);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_wep_null);
+#endif
+
+module_init(ieee80211_crypto_wep_init);
+module_exit(ieee80211_crypto_wep_exit);
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
new file mode 100644
index 000000000000..f408b4583b82
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
@@ -0,0 +1,394 @@
+/*******************************************************************************
+
+ Copyright(c) 2004 Intel Corporation. All rights reserved.
+
+ Portions of this file are based on the WEP enablement code provided by the
+ Host AP project hostap-drivers v0.1.3
+ Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ <jkmaline@cc.hut.fi>
+ Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59
+ Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The full GNU General Public License is included in this distribution in the
+ file called LICENSE.
+
+ Contact Information:
+ James P. Ketrenos <ipw2100-admin@linux.intel.com>
+ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#include <linux/compiler.h>
+//#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <asm/uaccess.h>
+#include <net/arp.h>
+
+#include "ieee80211.h"
+
+MODULE_DESCRIPTION("802.11 data/management/control stack");
+MODULE_AUTHOR("Copyright (C) 2004 Intel Corporation <jketreno@linux.intel.com>");
+MODULE_LICENSE("GPL");
+
+#define DRV_NAME "ieee80211"
+
+static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
+{
+ if (ieee->networks)
+ return 0;
+
+ ieee->networks = kmalloc(
+ MAX_NETWORK_COUNT * sizeof(struct ieee80211_network),
+ GFP_KERNEL);
+ if (!ieee->networks) {
+ printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
+ ieee->dev->name);
+ return -ENOMEM;
+ }
+
+ memset(ieee->networks, 0,
+ MAX_NETWORK_COUNT * sizeof(struct ieee80211_network));
+
+ return 0;
+}
+
+static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
+{
+ if (!ieee->networks)
+ return;
+ kfree(ieee->networks);
+ ieee->networks = NULL;
+}
+
+static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
+{
+ int i;
+
+ INIT_LIST_HEAD(&ieee->network_free_list);
+ INIT_LIST_HEAD(&ieee->network_list);
+ for (i = 0; i < MAX_NETWORK_COUNT; i++)
+ list_add_tail(&ieee->networks[i].list, &ieee->network_free_list);
+}
+
+
+struct net_device *alloc_ieee80211(int sizeof_priv)
+{
+ struct ieee80211_device *ieee;
+ struct net_device *dev;
+ int i,err;
+
+ IEEE80211_DEBUG_INFO("Initializing...\n");
+
+ dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv);
+ if (!dev) {
+ IEEE80211_ERROR("Unable to network device.\n");
+ goto failed;
+ }
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ ieee = netdev_priv(dev);
+#else
+ ieee = (struct ieee80211_device *)dev->priv;
+#endif
+ dev->hard_start_xmit = ieee80211_xmit;
+
+ memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv);
+ ieee->dev = dev;
+
+ err = ieee80211_networks_allocate(ieee);
+ if (err) {
+ IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
+ err);
+ goto failed;
+ }
+ ieee80211_networks_initialize(ieee);
+
+
+ /* Default fragmentation threshold is maximum payload size */
+ ieee->fts = DEFAULT_FTS;
+ ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
+ ieee->open_wep = 1;
+
+ /* Default to enabling full open WEP with host based encrypt/decrypt */
+ ieee->host_encrypt = 1;
+ ieee->host_decrypt = 1;
+ ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
+
+ INIT_LIST_HEAD(&ieee->crypt_deinit_list);
+ init_timer(&ieee->crypt_deinit_timer);
+ ieee->crypt_deinit_timer.data = (unsigned long)ieee;
+ ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
+
+ spin_lock_init(&ieee->lock);
+ spin_lock_init(&ieee->wpax_suitlist_lock);
+ spin_lock_init(&ieee->bw_spinlock);
+ spin_lock_init(&ieee->reorder_spinlock);
+ //added by WB
+ atomic_set(&(ieee->atm_chnlop), 0);
+ atomic_set(&(ieee->atm_swbw), 0);
+
+ ieee->wpax_type_set = 0;
+ ieee->wpa_enabled = 0;
+ ieee->tkip_countermeasures = 0;
+ ieee->drop_unencrypted = 0;
+ ieee->privacy_invoked = 0;
+ ieee->ieee802_1x = 1;
+ ieee->raw_tx = 0;
+ //ieee->hwsec_support = 1; //defalt support hw security. //use module_param instead.
+ ieee->hwsec_active = 0; //disable hwsec, switch it on when necessary.
+
+ ieee80211_softmac_init(ieee);
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
+ ieee->pHTInfo = (RT_HIGH_THROUGHPUT*)kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL);
+#else
+ ieee->pHTInfo = (RT_HIGH_THROUGHPUT*)kmalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL);
+ memset(ieee->pHTInfo,0,sizeof(RT_HIGH_THROUGHPUT));
+#endif
+ if (ieee->pHTInfo == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n");
+ return NULL;
+ }
+ HTUpdateDefaultSetting(ieee);
+ HTInitializeHTInfo(ieee); //may move to other place.
+ TSInitialize(ieee);
+#if 0
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+ INIT_WORK(&ieee->ht_onAssRsp, (void(*)(void*)) HTOnAssocRsp_wq);
+#else
+ INIT_WORK(&ieee->ht_onAssRsp, (void(*)(void*)) HTOnAssocRsp_wq, ieee);
+#endif
+#endif
+ for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
+ INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
+
+ for (i = 0; i < 17; i++) {
+ ieee->last_rxseq_num[i] = -1;
+ ieee->last_rxfrag_num[i] = -1;
+ ieee->last_packet_time[i] = 0;
+ }
+
+//These function were added to load crypte module autoly
+ ieee80211_tkip_null();
+ ieee80211_wep_null();
+ ieee80211_ccmp_null();
+
+ return dev;
+
+ failed:
+ if (dev)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ free_netdev(dev);
+#else
+ kfree(dev);
+#endif
+ return NULL;
+}
+
+
+void free_ieee80211(struct net_device *dev)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ struct ieee80211_device *ieee = netdev_priv(dev);
+#else
+ struct ieee80211_device *ieee = (struct ieee80211_device *)dev->priv;
+#endif
+ int i;
+ //struct list_head *p, *q;
+// del_timer_sync(&ieee->SwBwTimer);
+#if 1
+ if (ieee->pHTInfo != NULL)
+ {
+ kfree(ieee->pHTInfo);
+ ieee->pHTInfo = NULL;
+ }
+#endif
+ RemoveAllTS(ieee);
+ ieee80211_softmac_free(ieee);
+ del_timer_sync(&ieee->crypt_deinit_timer);
+ ieee80211_crypt_deinit_entries(ieee, 1);
+
+ for (i = 0; i < WEP_KEYS; i++) {
+ struct ieee80211_crypt_data *crypt = ieee->crypt[i];
+ if (crypt) {
+ if (crypt->ops) {
+ crypt->ops->deinit(crypt->priv);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ module_put(crypt->ops->owner);
+#else
+ __MOD_DEC_USE_COUNT(crypt->ops->owner);
+#endif
+ }
+ kfree(crypt);
+ ieee->crypt[i] = NULL;
+ }
+ }
+
+ ieee80211_networks_free(ieee);
+#if 0
+ for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
+ list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
+ kfree(list_entry(p, struct ieee_ibss_seq, list));
+ list_del(p);
+ }
+ }
+
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ free_netdev(dev);
+#else
+ kfree(dev);
+#endif
+}
+
+#ifdef CONFIG_IEEE80211_DEBUG
+
+u32 ieee80211_debug_level = 0;
+static int debug = \
+ // IEEE80211_DL_INFO |
+ // IEEE80211_DL_WX |
+ // IEEE80211_DL_SCAN |
+ // IEEE80211_DL_STATE |
+ // IEEE80211_DL_MGMT |
+ // IEEE80211_DL_FRAG |
+ // IEEE80211_DL_EAP |
+ // IEEE80211_DL_DROP |
+ // IEEE80211_DL_TX |
+ // IEEE80211_DL_RX |
+ //IEEE80211_DL_QOS |
+ // IEEE80211_DL_HT |
+ // IEEE80211_DL_TS |
+// IEEE80211_DL_BA |
+ // IEEE80211_DL_REORDER|
+// IEEE80211_DL_TRACE |
+ //IEEE80211_DL_DATA |
+ IEEE80211_DL_ERR //awayls open this flags to show error out
+ ;
+struct proc_dir_entry *ieee80211_proc = NULL;
+
+static int show_debug_level(char *page, char **start, off_t offset,
+ int count, int *eof, void *data)
+{
+ return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
+}
+
+static int store_debug_level(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ char buf[] = "0x00000000";
+ unsigned long len = min(sizeof(buf) - 1, (u32)count);
+ char *p = (char *)buf;
+ unsigned long val;
+
+ if (copy_from_user(buf, buffer, len))
+ return count;
+ buf[len] = 0;
+ if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
+ p++;
+ if (p[0] == 'x' || p[0] == 'X')
+ p++;
+ val = simple_strtoul(p, &p, 16);
+ } else
+ val = simple_strtoul(p, &p, 10);
+ if (p == buf)
+ printk(KERN_INFO DRV_NAME
+ ": %s is not in hex or decimal form.\n", buf);
+ else
+ ieee80211_debug_level = val;
+
+ return strnlen(buf, count);
+}
+
+static int __init ieee80211_init(void)
+{
+ struct proc_dir_entry *e;
+
+ ieee80211_debug_level = debug;
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net);
+#else
+ ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net);
+#endif
+ if (ieee80211_proc == NULL) {
+ IEEE80211_ERROR("Unable to create " DRV_NAME
+ " proc directory\n");
+ return -EIO;
+ }
+ e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
+ ieee80211_proc);
+ if (!e) {
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ remove_proc_entry(DRV_NAME, proc_net);
+#else
+ remove_proc_entry(DRV_NAME, init_net.proc_net);
+#endif
+ ieee80211_proc = NULL;
+ return -EIO;
+ }
+ e->read_proc = show_debug_level;
+ e->write_proc = store_debug_level;
+ e->data = NULL;
+
+ return 0;
+}
+
+static void __exit ieee80211_exit(void)
+{
+ if (ieee80211_proc) {
+ remove_proc_entry("debug_level", ieee80211_proc);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ remove_proc_entry(DRV_NAME, proc_net);
+#else
+ remove_proc_entry(DRV_NAME, init_net.proc_net);
+#endif
+ ieee80211_proc = NULL;
+ }
+}
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#include <linux/moduleparam.h>
+module_param(debug, int, 0444);
+MODULE_PARM_DESC(debug, "debug output mask");
+
+
+module_exit(ieee80211_exit);
+module_init(ieee80211_init);
+#endif
+#endif
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(alloc_ieee80211);
+EXPORT_SYMBOL(free_ieee80211);
+#else
+EXPORT_SYMBOL_NOVERS(alloc_ieee80211);
+EXPORT_SYMBOL_NOVERS(free_ieee80211);
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
new file mode 100644
index 000000000000..2b2ffd34bc92
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
@@ -0,0 +1,2832 @@
+/*
+ * Original code based Host AP (software wireless LAN access point) driver
+ * for Intersil Prism2/2.5/3 - hostap.o module, common routines
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ ******************************************************************************
+
+ Few modifications for Realtek's Wi-Fi drivers by
+ Andrea Merello <andreamrl@tiscali.it>
+
+ A special thanks goes to Realtek for their support !
+
+******************************************************************************/
+
+
+#include <linux/compiler.h>
+//#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <asm/uaccess.h>
+#include <linux/ctype.h>
+
+#include "ieee80211.h"
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
+ struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats)
+{
+ struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ u16 fc = le16_to_cpu(hdr->frame_ctl);
+
+ skb->dev = ieee->dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ skb_reset_mac_header(skb);
+#else
+ skb->mac.raw = skb->data;
+#endif
+
+ skb_pull(skb, ieee80211_get_hdrlen(fc));
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = __constant_htons(ETH_P_80211_RAW);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static struct ieee80211_frag_entry *
+ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
+ unsigned int frag, u8 tid,u8 *src, u8 *dst)
+{
+ struct ieee80211_frag_entry *entry;
+ int i;
+
+ for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
+ entry = &ieee->frag_cache[tid][i];
+ if (entry->skb != NULL &&
+ time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
+ IEEE80211_DEBUG_FRAG(
+ "expiring fragment cache entry "
+ "seq=%u last_frag=%u\n",
+ entry->seq, entry->last_frag);
+ dev_kfree_skb_any(entry->skb);
+ entry->skb = NULL;
+ }
+
+ if (entry->skb != NULL && entry->seq == seq &&
+ (entry->last_frag + 1 == frag || frag == -1) &&
+ memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
+ memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
+ return entry;
+ }
+
+ return NULL;
+}
+
+/* Called only as a tasklet (software IRQ) */
+static struct sk_buff *
+ieee80211_frag_cache_get(struct ieee80211_device *ieee,
+ struct ieee80211_hdr_4addr *hdr)
+{
+ struct sk_buff *skb = NULL;
+ u16 fc = le16_to_cpu(hdr->frame_ctl);
+ u16 sc = le16_to_cpu(hdr->seq_ctl);
+ unsigned int frag = WLAN_GET_SEQ_FRAG(sc);
+ unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
+ struct ieee80211_frag_entry *entry;
+ struct ieee80211_hdr_3addrqos *hdr_3addrqos;
+ struct ieee80211_hdr_4addrqos *hdr_4addrqos;
+ u8 tid;
+
+ if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
+ hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
+ tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
+ tid = UP2AC(tid);
+ tid ++;
+ } else if (IEEE80211_QOS_HAS_SEQ(fc)) {
+ hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
+ tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
+ tid = UP2AC(tid);
+ tid ++;
+ } else {
+ tid = 0;
+ }
+
+ if (frag == 0) {
+ /* Reserve enough space to fit maximum frame length */
+ skb = dev_alloc_skb(ieee->dev->mtu +
+ sizeof(struct ieee80211_hdr_4addr) +
+ 8 /* LLC */ +
+ 2 /* alignment */ +
+ 8 /* WEP */ +
+ ETH_ALEN /* WDS */ +
+ (IEEE80211_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */);
+ if (skb == NULL)
+ return NULL;
+
+ entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]];
+ ieee->frag_next_idx[tid]++;
+ if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN)
+ ieee->frag_next_idx[tid] = 0;
+
+ if (entry->skb != NULL)
+ dev_kfree_skb_any(entry->skb);
+
+ entry->first_frag_time = jiffies;
+ entry->seq = seq;
+ entry->last_frag = frag;
+ entry->skb = skb;
+ memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
+ memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
+ } else {
+ /* received a fragment of a frame for which the head fragment
+ * should have already been received */
+ entry = ieee80211_frag_cache_find(ieee, seq, frag, tid,hdr->addr2,
+ hdr->addr1);
+ if (entry != NULL) {
+ entry->last_frag = frag;
+ skb = entry->skb;
+ }
+ }
+
+ return skb;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
+ struct ieee80211_hdr_4addr *hdr)
+{
+ u16 fc = le16_to_cpu(hdr->frame_ctl);
+ u16 sc = le16_to_cpu(hdr->seq_ctl);
+ unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
+ struct ieee80211_frag_entry *entry;
+ struct ieee80211_hdr_3addrqos *hdr_3addrqos;
+ struct ieee80211_hdr_4addrqos *hdr_4addrqos;
+ u8 tid;
+
+ if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
+ hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
+ tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
+ tid = UP2AC(tid);
+ tid ++;
+ } else if (IEEE80211_QOS_HAS_SEQ(fc)) {
+ hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
+ tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
+ tid = UP2AC(tid);
+ tid ++;
+ } else {
+ tid = 0;
+ }
+
+ entry = ieee80211_frag_cache_find(ieee, seq, -1, tid,hdr->addr2,
+ hdr->addr1);
+
+ if (entry == NULL) {
+ IEEE80211_DEBUG_FRAG(
+ "could not invalidate fragment cache "
+ "entry (seq=%u)\n", seq);
+ return -1;
+ }
+
+ entry->skb = NULL;
+ return 0;
+}
+
+
+
+/* ieee80211_rx_frame_mgtmt
+ *
+ * Responsible for handling management control frames
+ *
+ * Called by ieee80211_rx */
+static inline int
+ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats, u16 type,
+ u16 stype)
+{
+ /* On the struct stats definition there is written that
+ * this is not mandatory.... but seems that the probe
+ * response parser uses it
+ */
+ struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data;
+
+ rx_stats->len = skb->len;
+ ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats);
+ //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
+ if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames
+ {
+ dev_kfree_skb_any(skb);
+ return 0;
+ }
+
+ ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
+
+ dev_kfree_skb_any(skb);
+
+ return 0;
+
+ #ifdef NOT_YET
+ if (ieee->iw_mode == IW_MODE_MASTER) {
+ printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
+ ieee->dev->name);
+ return 0;
+/*
+ hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
+ skb->data);*/
+ }
+
+ if (ieee->hostapd && type == IEEE80211_TYPE_MGMT) {
+ if (stype == WLAN_FC_STYPE_BEACON &&
+ ieee->iw_mode == IW_MODE_MASTER) {
+ struct sk_buff *skb2;
+ /* Process beacon frames also in kernel driver to
+ * update STA(AP) table statistics */
+ skb2 = skb_clone(skb, GFP_ATOMIC);
+ if (skb2)
+ hostap_rx(skb2->dev, skb2, rx_stats);
+ }
+
+ /* send management frames to the user space daemon for
+ * processing */
+ ieee->apdevstats.rx_packets++;
+ ieee->apdevstats.rx_bytes += skb->len;
+ prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
+ return 0;
+ }
+
+ if (ieee->iw_mode == IW_MODE_MASTER) {
+ if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
+ printk(KERN_DEBUG "%s: unknown management frame "
+ "(type=0x%02x, stype=0x%02x) dropped\n",
+ skb->dev->name, type, stype);
+ return -1;
+ }
+
+ hostap_rx(skb->dev, skb, rx_stats);
+ return 0;
+ }
+
+ printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
+ "received in non-Host AP mode\n", skb->dev->name);
+ return -1;
+ #endif
+}
+
+
+
+/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
+/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+static unsigned char rfc1042_header[] =
+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
+static unsigned char bridge_tunnel_header[] =
+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
+/* No encapsulation header if EtherType < 0x600 (=length) */
+
+/* Called by ieee80211_rx_frame_decrypt */
+static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
+ struct sk_buff *skb, size_t hdrlen)
+{
+ struct net_device *dev = ieee->dev;
+ u16 fc, ethertype;
+ struct ieee80211_hdr_4addr *hdr;
+ u8 *pos;
+
+ if (skb->len < 24)
+ return 0;
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ fc = le16_to_cpu(hdr->frame_ctl);
+
+ /* check that the frame is unicast frame to us */
+ if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+ IEEE80211_FCTL_TODS &&
+ memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
+ memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
+ /* ToDS frame with own addr BSSID and DA */
+ } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+ IEEE80211_FCTL_FROMDS &&
+ memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+ /* FromDS frame with own addr as DA */
+ } else
+ return 0;
+
+ if (skb->len < 24 + 8)
+ return 0;
+
+ /* check for port access entity Ethernet type */
+// pos = skb->data + 24;
+ pos = skb->data + hdrlen;
+ ethertype = (pos[6] << 8) | pos[7];
+ if (ethertype == ETH_P_PAE)
+ return 1;
+
+ return 0;
+}
+
+/* Called only as a tasklet (software IRQ), by ieee80211_rx */
+static inline int
+ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
+ struct ieee80211_crypt_data *crypt)
+{
+ struct ieee80211_hdr_4addr *hdr;
+ int res, hdrlen;
+
+ if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
+ return 0;
+#if 1
+ if (ieee->hwsec_active)
+ {
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
+ tcb_desc->bHwSec = 1;
+ }
+#endif
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+#ifdef CONFIG_IEEE80211_CRYPT_TKIP
+ if (ieee->tkip_countermeasures &&
+ strcmp(crypt->ops->name, "TKIP") == 0) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+ "received packet from " MAC_FMT "\n",
+ ieee->dev->name, MAC_ARG(hdr->addr2));
+ }
+ return -1;
+ }
+#endif
+
+ atomic_inc(&crypt->refcnt);
+ res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
+ atomic_dec(&crypt->refcnt);
+ if (res < 0) {
+ IEEE80211_DEBUG_DROP(
+ "decryption failed (SA=" MAC_FMT
+ ") res=%d\n", MAC_ARG(hdr->addr2), res);
+ if (res == -2)
+ IEEE80211_DEBUG_DROP("Decryption failed ICV "
+ "mismatch (key %d)\n",
+ skb->data[hdrlen + 3] >> 6);
+ ieee->ieee_stats.rx_discards_undecryptable++;
+ return -1;
+ }
+
+ return res;
+}
+
+
+/* Called only as a tasklet (software IRQ), by ieee80211_rx */
+static inline int
+ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
+ int keyidx, struct ieee80211_crypt_data *crypt)
+{
+ struct ieee80211_hdr_4addr *hdr;
+ int res, hdrlen;
+
+ if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
+ return 0;
+ if (ieee->hwsec_active)
+ {
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
+ tcb_desc->bHwSec = 1;
+ }
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+ atomic_inc(&crypt->refcnt);
+ res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
+ atomic_dec(&crypt->refcnt);
+ if (res < 0) {
+ printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
+ " (SA=" MAC_FMT " keyidx=%d)\n",
+ ieee->dev->name, MAC_ARG(hdr->addr2), keyidx);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/* this function is stolen from ipw2200 driver*/
+#define IEEE_PACKET_RETRY_TIME (5*HZ)
+static int is_duplicate_packet(struct ieee80211_device *ieee,
+ struct ieee80211_hdr_4addr *header)
+{
+ u16 fc = le16_to_cpu(header->frame_ctl);
+ u16 sc = le16_to_cpu(header->seq_ctl);
+ u16 seq = WLAN_GET_SEQ_SEQ(sc);
+ u16 frag = WLAN_GET_SEQ_FRAG(sc);
+ u16 *last_seq, *last_frag;
+ unsigned long *last_time;
+ struct ieee80211_hdr_3addrqos *hdr_3addrqos;
+ struct ieee80211_hdr_4addrqos *hdr_4addrqos;
+ u8 tid;
+
+
+ //TO2DS and QoS
+ if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
+ hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header;
+ tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
+ tid = UP2AC(tid);
+ tid ++;
+ } else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS
+ hdr_3addrqos = (struct ieee80211_hdr_3addrqos*)header;
+ tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
+ tid = UP2AC(tid);
+ tid ++;
+ } else { // no QoS
+ tid = 0;
+ }
+
+ switch (ieee->iw_mode) {
+ case IW_MODE_ADHOC:
+ {
+ struct list_head *p;
+ struct ieee_ibss_seq *entry = NULL;
+ u8 *mac = header->addr2;
+ int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
+ //for (pos = (head)->next; pos != (head); pos = pos->next)
+ //__list_for_each(p, &ieee->ibss_mac_hash[index]) {
+ list_for_each(p, &ieee->ibss_mac_hash[index]) {
+ entry = list_entry(p, struct ieee_ibss_seq, list);
+ if (!memcmp(entry->mac, mac, ETH_ALEN))
+ break;
+ }
+ // if (memcmp(entry->mac, mac, ETH_ALEN)){
+ if (p == &ieee->ibss_mac_hash[index]) {
+ entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
+ if (!entry) {
+ printk(KERN_WARNING "Cannot malloc new mac entry\n");
+ return 0;
+ }
+ memcpy(entry->mac, mac, ETH_ALEN);
+ entry->seq_num[tid] = seq;
+ entry->frag_num[tid] = frag;
+ entry->packet_time[tid] = jiffies;
+ list_add(&entry->list, &ieee->ibss_mac_hash[index]);
+ return 0;
+ }
+ last_seq = &entry->seq_num[tid];
+ last_frag = &entry->frag_num[tid];
+ last_time = &entry->packet_time[tid];
+ break;
+ }
+
+ case IW_MODE_INFRA:
+ last_seq = &ieee->last_rxseq_num[tid];
+ last_frag = &ieee->last_rxfrag_num[tid];
+ last_time = &ieee->last_packet_time[tid];
+
+ break;
+ default:
+ return 0;
+ }
+
+// if(tid != 0) {
+// printk(KERN_WARNING ":)))))))))))%x %x %x, fc(%x)\n", tid, *last_seq, seq, header->frame_ctl);
+// }
+ if ((*last_seq == seq) &&
+ time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) {
+ if (*last_frag == frag){
+ //printk(KERN_WARNING "[1] go drop!\n");
+ goto drop;
+
+ }
+ if (*last_frag + 1 != frag)
+ /* out-of-order fragment */
+ //printk(KERN_WARNING "[2] go drop!\n");
+ goto drop;
+ } else
+ *last_seq = seq;
+
+ *last_frag = frag;
+ *last_time = jiffies;
+ return 0;
+
+drop:
+// BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
+// printk("DUP\n");
+
+ return 1;
+}
+bool
+AddReorderEntry(
+ PRX_TS_RECORD pTS,
+ PRX_REORDER_ENTRY pReorderEntry
+ )
+{
+ struct list_head *pList = &pTS->RxPendingPktList;
+#if 1
+ while(pList->next != &pTS->RxPendingPktList)
+ {
+ if( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
+ {
+ pList = pList->next;
+ }
+ else if( SN_EQUAL(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
+ {
+ return false;
+ }
+ else
+ {
+ break;
+ }
+ }
+#endif
+ pReorderEntry->List.next = pList->next;
+ pReorderEntry->List.next->prev = &pReorderEntry->List;
+ pReorderEntry->List.prev = pList;
+ pList->next = &pReorderEntry->List;
+
+ return true;
+}
+
+void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index)
+{
+ u8 i = 0 , j=0;
+ u16 ethertype;
+// if(index > 1)
+// IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__FUNCTION__,index);
+ for(j = 0; j<index; j++)
+ {
+//added by amy for reorder
+ struct ieee80211_rxb* prxb = prxbIndicateArray[j];
+ for(i = 0; i<prxb->nr_subframes; i++) {
+ struct sk_buff *sub_skb = prxb->subframes[i];
+
+ /* convert hdr + possible LLC headers into Ethernet header */
+ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
+ if (sub_skb->len >= 8 &&
+ ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
+ ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
+ memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
+ /* remove RFC1042 or Bridge-Tunnel encapsulation and
+ * replace EtherType */
+ skb_pull(sub_skb, SNAP_SIZE);
+ memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
+ memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
+ } else {
+ u16 len;
+ /* Leave Ethernet header part of hdr and full payload */
+ len = htons(sub_skb->len);
+ memcpy(skb_push(sub_skb, 2), &len, 2);
+ memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
+ memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
+ }
+ //stats->rx_packets++;
+ //stats->rx_bytes += sub_skb->len;
+
+ /* Indicat the packets to upper layer */
+ if (sub_skb) {
+ //printk("0skb_len(%d)\n", skb->len);
+ sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
+ memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
+ sub_skb->dev = ieee->dev;
+ sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+ //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
+ ieee->last_rx_ps_time = jiffies;
+ //printk("1skb_len(%d)\n", skb->len);
+ netif_rx(sub_skb);
+ }
+ }
+ kfree(prxb);
+ prxb = NULL;
+ }
+}
+
+
+void RxReorderIndicatePacket( struct ieee80211_device *ieee,
+ struct ieee80211_rxb* prxb,
+ PRX_TS_RECORD pTS,
+ u16 SeqNum)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ PRX_REORDER_ENTRY pReorderEntry = NULL;
+ struct ieee80211_rxb* prxbIndicateArray[REORDER_WIN_SIZE];
+ u8 WinSize = pHTInfo->RxReorderWinSize;
+ u16 WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096;
+ u8 index = 0;
+ bool bMatchWinStart = false, bPktInBuf = false;
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__,SeqNum,pTS->RxIndicateSeq,WinSize);
+#if 0
+ if(!list_empty(&ieee->RxReorder_Unused_List))
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): ieee->RxReorder_Unused_List is nut NULL\n");
+#endif
+ /* Rx Reorder initialize condition.*/
+ if(pTS->RxIndicateSeq == 0xffff) {
+ pTS->RxIndicateSeq = SeqNum;
+ }
+
+ /* Drop out the packet which SeqNum is smaller than WinStart */
+ if(SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
+ pTS->RxIndicateSeq, SeqNum);
+ pHTInfo->RxReorderDropCounter++;
+ {
+ int i;
+ for(i =0; i < prxb->nr_subframes; i++) {
+ dev_kfree_skb(prxb->subframes[i]);
+ }
+ kfree(prxb);
+ prxb = NULL;
+ }
+ return;
+ }
+
+ /*
+ * Sliding window manipulation. Conditions includes:
+ * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
+ * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
+ */
+ if(SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) {
+ pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
+ bMatchWinStart = true;
+ } else if(SN_LESS(WinEnd, SeqNum)) {
+ if(SeqNum >= (WinSize - 1)) {
+ pTS->RxIndicateSeq = SeqNum + 1 -WinSize;
+ } else {
+ pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1;
+ }
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
+ }
+
+ /*
+ * Indication process.
+ * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets
+ * with the SeqNum smaller than latest WinStart and buffer other packets.
+ */
+ /* For Rx Reorder condition:
+ * 1. All packets with SeqNum smaller than WinStart => Indicate
+ * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it.
+ */
+ if(bMatchWinStart) {
+ /* Current packet is going to be indicated.*/
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
+ pTS->RxIndicateSeq, SeqNum);
+ prxbIndicateArray[0] = prxb;
+// printk("========================>%s(): SeqNum is %d\n",__FUNCTION__,SeqNum);
+ index = 1;
+ } else {
+ /* Current packet is going to be inserted into pending list.*/
+ //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to orderd list\n",__FUNCTION__);
+ if(!list_empty(&ieee->RxReorder_Unused_List)) {
+ pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List);
+ list_del_init(&pReorderEntry->List);
+
+ /* Make a reorder entry and insert into a the packet list.*/
+ pReorderEntry->SeqNum = SeqNum;
+ pReorderEntry->prxb = prxb;
+ // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
+
+#if 1
+ if(!AddReorderEntry(pTS, pReorderEntry)) {
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
+ __FUNCTION__, pTS->RxIndicateSeq, SeqNum);
+ list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
+ {
+ int i;
+ for(i =0; i < prxb->nr_subframes; i++) {
+ dev_kfree_skb(prxb->subframes[i]);
+ }
+ kfree(prxb);
+ prxb = NULL;
+ }
+ } else {
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,
+ "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
+ }
+#endif
+ }
+ else {
+ /*
+ * Packets are dropped if there is not enough reorder entries.
+ * This part shall be modified!! We can just indicate all the
+ * packets in buffer and get reorder entries.
+ */
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
+ {
+ int i;
+ for(i =0; i < prxb->nr_subframes; i++) {
+ dev_kfree_skb(prxb->subframes[i]);
+ }
+ kfree(prxb);
+ prxb = NULL;
+ }
+ }
+ }
+
+ /* Check if there is any packet need indicate.*/
+ while(!list_empty(&pTS->RxPendingPktList)) {
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__FUNCTION__);
+#if 1
+ pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
+ if( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
+ SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
+ {
+ /* This protect buffer from overflow. */
+ if(index >= REORDER_WIN_SIZE) {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n");
+ bPktInBuf = true;
+ break;
+ }
+
+ list_del_init(&pReorderEntry->List);
+
+ if(SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
+ pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
+
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
+ prxbIndicateArray[index] = pReorderEntry->prxb;
+ // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
+ index++;
+
+ list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
+ } else {
+ bPktInBuf = true;
+ break;
+ }
+#endif
+ }
+
+ /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
+ if(index>0) {
+ // Cancel previous pending timer.
+ if(timer_pending(&pTS->RxPktPendingTimer))
+ {
+ del_timer_sync(&pTS->RxPktPendingTimer);
+ }
+ // del_timer_sync(&pTS->RxPktPendingTimer);
+ pTS->RxTimeoutIndicateSeq = 0xffff;
+
+ // Indicate packets
+ if(index>REORDER_WIN_SIZE){
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
+ return;
+ }
+ ieee80211_indicate_packets(ieee, prxbIndicateArray, index);
+ bPktInBuf = false;
+ }
+
+#if 1
+ if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) {
+ // Set new pending timer.
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __FUNCTION__);
+ pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
+#if 0
+ if(timer_pending(&pTS->RxPktPendingTimer))
+ del_timer_sync(&pTS->RxPktPendingTimer);
+ pTS->RxPktPendingTimer.expires = jiffies + MSECS(pHTInfo->RxReorderPendingTime);
+ add_timer(&pTS->RxPktPendingTimer);
+#else
+ mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime));
+#endif
+ }
+#endif
+}
+
+u8 parse_subframe(struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats,
+ struct ieee80211_rxb *rxb,u8* src,u8* dst)
+{
+ struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr* )skb->data;
+ u16 fc = le16_to_cpu(hdr->frame_ctl);
+
+ u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr);
+ u16 ChkLength;
+ bool bIsAggregateFrame = false;
+ u16 nSubframe_Length;
+ u8 nPadding_Length = 0;
+ u16 SeqNum=0;
+
+ struct sk_buff *sub_skb;
+ u8 *data_ptr;
+ /* just for debug purpose */
+ SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl));
+
+ if((IEEE80211_QOS_HAS_SEQ(fc))&&\
+ (((frameqos *)(skb->data + IEEE80211_3ADDR_LEN))->field.reserved)) {
+ bIsAggregateFrame = true;
+ }
+
+ if(IEEE80211_QOS_HAS_SEQ(fc)) {
+ LLCOffset += 2;
+ }
+
+ if(rx_stats->bContainHTC) {
+ LLCOffset += sHTCLng;
+ }
+ //printk("ChkLength = %d\n", LLCOffset);
+ // Null packet, don't indicate it to upper layer
+ ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
+
+ if( skb->len <= ChkLength ) {
+ return 0;
+ }
+
+ skb_pull(skb, LLCOffset);
+
+ if(!bIsAggregateFrame) {
+ rxb->nr_subframes = 1;
+#ifdef JOHN_NOCPY
+ rxb->subframes[0] = skb;
+#else
+ rxb->subframes[0] = skb_copy(skb, GFP_ATOMIC);
+#endif
+
+ memcpy(rxb->src,src,ETH_ALEN);
+ memcpy(rxb->dst,dst,ETH_ALEN);
+ //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len);
+ return 1;
+ } else {
+ rxb->nr_subframes = 0;
+ memcpy(rxb->src,src,ETH_ALEN);
+ memcpy(rxb->dst,dst,ETH_ALEN);
+ while(skb->len > ETHERNET_HEADER_SIZE) {
+ /* Offset 12 denote 2 mac address */
+ nSubframe_Length = *((u16*)(skb->data + 12));
+ //==m==>change the length order
+ nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8);
+
+ if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) {
+#if 0//cosa
+ RT_ASSERT(
+ (nRemain_Length>=(ETHERNET_HEADER_SIZE + nSubframe_Length)),
+ ("ParseSubframe(): A-MSDU subframe parse error!! Subframe Length: %d\n", nSubframe_Length) );
+#endif
+ printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
+ __FUNCTION__,rxb->nr_subframes);
+ printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__, nSubframe_Length);
+ printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length);
+ printk("The Packet SeqNum is %d\n",SeqNum);
+ return 0;
+ }
+
+ /* move the data point to data content */
+ skb_pull(skb, ETHERNET_HEADER_SIZE);
+
+#ifdef JOHN_NOCPY
+ sub_skb = skb_clone(skb, GFP_ATOMIC);
+ sub_skb->len = nSubframe_Length;
+ sub_skb->tail = sub_skb->data + nSubframe_Length;
+#else
+ /* Allocate new skb for releasing to upper layer */
+ sub_skb = dev_alloc_skb(nSubframe_Length + 12);
+ skb_reserve(sub_skb, 12);
+ data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
+ memcpy(data_ptr,skb->data,nSubframe_Length);
+#endif
+ rxb->subframes[rxb->nr_subframes++] = sub_skb;
+ if(rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
+ IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
+ break;
+ }
+ skb_pull(skb,nSubframe_Length);
+
+ if(skb->len != 0) {
+ nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4);
+ if(nPadding_Length == 4) {
+ nPadding_Length = 0;
+ }
+
+ if(skb->len < nPadding_Length) {
+ return 0;
+ }
+
+ skb_pull(skb,nPadding_Length);
+ }
+ }
+#ifdef JOHN_NOCPY
+ dev_kfree_skb(skb);
+#endif
+ //{just for debug added by david
+ //printk("AMSDU::rxb->nr_subframes = %d\n",rxb->nr_subframes);
+ //}
+ return rxb->nr_subframes;
+ }
+}
+
+/* All received frames are sent to this function. @skb contains the frame in
+ * IEEE 802.11 format, i.e., in the format it was sent over air.
+ * This function is called only as a tasklet (software IRQ). */
+int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats)
+{
+ struct net_device *dev = ieee->dev;
+ struct ieee80211_hdr_4addr *hdr;
+ //struct ieee80211_hdr_3addrqos *hdr;
+
+ size_t hdrlen;
+ u16 fc, type, stype, sc;
+ struct net_device_stats *stats;
+ unsigned int frag;
+ u8 *payload;
+ u16 ethertype;
+ //added by amy for reorder
+ u8 TID = 0;
+ u16 SeqNum = 0;
+ PRX_TS_RECORD pTS = NULL;
+ //bool bIsAggregateFrame = false;
+ //added by amy for reorder
+#ifdef NOT_YET
+ struct net_device *wds = NULL;
+ struct sk_buff *skb2 = NULL;
+ struct net_device *wds = NULL;
+ int frame_authorized = 0;
+ int from_assoc_ap = 0;
+ void *sta = NULL;
+#endif
+// u16 qos_ctl = 0;
+ u8 dst[ETH_ALEN];
+ u8 src[ETH_ALEN];
+ u8 bssid[ETH_ALEN];
+ struct ieee80211_crypt_data *crypt = NULL;
+ int keyidx = 0;
+
+ int i;
+ struct ieee80211_rxb* rxb = NULL;
+ // cheat the the hdr type
+ hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ stats = &ieee->stats;
+
+ if (skb->len < 10) {
+ printk(KERN_INFO "%s: SKB length < 10\n",
+ dev->name);
+ goto rx_dropped;
+ }
+
+ fc = le16_to_cpu(hdr->frame_ctl);
+ type = WLAN_FC_GET_TYPE(fc);
+ stype = WLAN_FC_GET_STYPE(fc);
+ sc = le16_to_cpu(hdr->seq_ctl);
+
+ frag = WLAN_GET_SEQ_FRAG(sc);
+ hdrlen = ieee80211_get_hdrlen(fc);
+
+ if(HTCCheck(ieee, skb->data))
+ {
+ if(net_ratelimit())
+ printk("find HTCControl\n");
+ hdrlen += 4;
+ rx_stats->bContainHTC = 1;
+ }
+
+ //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
+#ifdef NOT_YET
+#if WIRELESS_EXT > 15
+ /* Put this code here so that we avoid duplicating it in all
+ * Rx paths. - Jean II */
+#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
+ /* If spy monitoring on */
+ if (iface->spy_data.spy_number > 0) {
+ struct iw_quality wstats;
+ wstats.level = rx_stats->rssi;
+ wstats.noise = rx_stats->noise;
+ wstats.updated = 6; /* No qual value */
+ /* Update spy records */
+ wireless_spy_update(dev, hdr->addr2, &wstats);
+ }
+#endif /* IW_WIRELESS_SPY */
+#endif /* WIRELESS_EXT > 15 */
+ hostap_update_rx_stats(local->ap, hdr, rx_stats);
+#endif
+
+#if WIRELESS_EXT > 15
+ if (ieee->iw_mode == IW_MODE_MONITOR) {
+ ieee80211_monitor_rx(ieee, skb, rx_stats);
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
+ return 1;
+ }
+#endif
+ if (ieee->host_decrypt) {
+ int idx = 0;
+ if (skb->len >= hdrlen + 3)
+ idx = skb->data[hdrlen + 3] >> 6;
+ crypt = ieee->crypt[idx];
+#ifdef NOT_YET
+ sta = NULL;
+
+ /* Use station specific key to override default keys if the
+ * receiver address is a unicast address ("individual RA"). If
+ * bcrx_sta_key parameter is set, station specific key is used
+ * even with broad/multicast targets (this is against IEEE
+ * 802.11, but makes it easier to use different keys with
+ * stations that do not support WEP key mapping). */
+
+ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
+ (void) hostap_handle_sta_crypto(local, hdr, &crypt,
+ &sta);
+#endif
+
+ /* allow NULL decrypt to indicate an station specific override
+ * for default encryption */
+ if (crypt && (crypt->ops == NULL ||
+ crypt->ops->decrypt_mpdu == NULL))
+ crypt = NULL;
+
+ if (!crypt && (fc & IEEE80211_FCTL_WEP)) {
+ /* This seems to be triggered by some (multicast?)
+ * frames from other than current BSS, so just drop the
+ * frames silently instead of filling system log with
+ * these reports. */
+ IEEE80211_DEBUG_DROP("Decryption failed (not set)"
+ " (SA=" MAC_FMT ")\n",
+ MAC_ARG(hdr->addr2));
+ ieee->ieee_stats.rx_discards_undecryptable++;
+ goto rx_dropped;
+ }
+ }
+
+ if (skb->len < IEEE80211_DATA_HDR3_LEN)
+ goto rx_dropped;
+
+ // if QoS enabled, should check the sequence for each of the AC
+ if( (ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active|| !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)){
+ if (is_duplicate_packet(ieee, hdr))
+ goto rx_dropped;
+
+ }
+ else
+ {
+ PRX_TS_RECORD pRxTS = NULL;
+ #if 0
+ struct ieee80211_hdr_3addr *hdr;
+ u16 fc;
+ hdr = (struct ieee80211_hdr_3addr *)skb->data;
+ fc = le16_to_cpu(hdr->frame_ctl);
+ u8 tmp = (fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS);
+
+ u8 tid = (*((u8*)skb->data + (((fc& IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))?30:24)))&0xf;
+ printk("====================>fc:%x, tid:%d, tmp:%d\n", fc, tid, tmp);
+ //u8 tid = (u8)((frameqos*)(buf + ((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24))->field.tid;
+ #endif
+ //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__FUNCTION__, tid);
+#if 1
+ if(GetTs(
+ ieee,
+ (PTS_COMMON_INFO*) &pRxTS,
+ hdr->addr2,
+ (u8)Frame_QoSTID((u8*)(skb->data)),
+ RX_DIR,
+ true))
+ {
+
+ // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
+ if( (fc & (1<<11)) &&
+ (frag == pRxTS->RxLastFragNum) &&
+ (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) )
+ {
+ goto rx_dropped;
+ }
+ else
+ {
+ pRxTS->RxLastFragNum = frag;
+ pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
+ }
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s(): No TS!! Skip the check!!\n",__FUNCTION__);
+ goto rx_dropped;
+ }
+ }
+#endif
+ if (type == IEEE80211_FTYPE_MGMT) {
+
+ #if 0
+ if ( stype == IEEE80211_STYPE_AUTH &&
+ fc & IEEE80211_FCTL_WEP && ieee->host_decrypt &&
+ (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0)
+ {
+ printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
+ "from " MAC_FMT "\n", dev->name,
+ MAC_ARG(hdr->addr2));
+ /* TODO: could inform hostapd about this so that it
+ * could send auth failure report */
+ goto rx_dropped;
+ }
+ #endif
+
+ //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
+ if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
+ goto rx_dropped;
+ else
+ goto rx_exit;
+ }
+
+ /* Data frame - extract src/dst addresses */
+ switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
+ case IEEE80211_FCTL_FROMDS:
+ memcpy(dst, hdr->addr1, ETH_ALEN);
+ memcpy(src, hdr->addr3, ETH_ALEN);
+ memcpy(bssid, hdr->addr2, ETH_ALEN);
+ break;
+ case IEEE80211_FCTL_TODS:
+ memcpy(dst, hdr->addr3, ETH_ALEN);
+ memcpy(src, hdr->addr2, ETH_ALEN);
+ memcpy(bssid, hdr->addr1, ETH_ALEN);
+ break;
+ case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
+ if (skb->len < IEEE80211_DATA_HDR4_LEN)
+ goto rx_dropped;
+ memcpy(dst, hdr->addr3, ETH_ALEN);
+ memcpy(src, hdr->addr4, ETH_ALEN);
+ memcpy(bssid, ieee->current_network.bssid, ETH_ALEN);
+ break;
+ case 0:
+ memcpy(dst, hdr->addr1, ETH_ALEN);
+ memcpy(src, hdr->addr2, ETH_ALEN);
+ memcpy(bssid, hdr->addr3, ETH_ALEN);
+ break;
+ }
+
+#ifdef NOT_YET
+ if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
+ goto rx_dropped;
+ if (wds) {
+ skb->dev = dev = wds;
+ stats = hostap_get_stats(dev);
+ }
+
+ if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
+ (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS &&
+ ieee->stadev &&
+ memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
+ /* Frame from BSSID of the AP for which we are a client */
+ skb->dev = dev = ieee->stadev;
+ stats = hostap_get_stats(dev);
+ from_assoc_ap = 1;
+ }
+#endif
+
+ dev->last_rx = jiffies;
+
+#ifdef NOT_YET
+ if ((ieee->iw_mode == IW_MODE_MASTER ||
+ ieee->iw_mode == IW_MODE_REPEAT) &&
+ !from_assoc_ap) {
+ switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
+ wds != NULL)) {
+ case AP_RX_CONTINUE_NOT_AUTHORIZED:
+ frame_authorized = 0;
+ break;
+ case AP_RX_CONTINUE:
+ frame_authorized = 1;
+ break;
+ case AP_RX_DROP:
+ goto rx_dropped;
+ case AP_RX_EXIT:
+ goto rx_exit;
+ }
+ }
+#endif
+ //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
+ /* Nullfunc frames may have PS-bit set, so they must be passed to
+ * hostap_handle_sta_rx() before being dropped here. */
+ if (stype != IEEE80211_STYPE_DATA &&
+ stype != IEEE80211_STYPE_DATA_CFACK &&
+ stype != IEEE80211_STYPE_DATA_CFPOLL &&
+ stype != IEEE80211_STYPE_DATA_CFACKPOLL&&
+ stype != IEEE80211_STYPE_QOS_DATA//add by David,2006.8.4
+ ) {
+ if (stype != IEEE80211_STYPE_NULLFUNC)
+ IEEE80211_DEBUG_DROP(
+ "RX: dropped data frame "
+ "with no data (type=0x%02x, "
+ "subtype=0x%02x, len=%d)\n",
+ type, stype, skb->len);
+ goto rx_dropped;
+ }
+ if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
+ goto rx_dropped;
+
+ /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
+
+ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
+ (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
+ {
+ printk("decrypt frame error\n");
+ goto rx_dropped;
+ }
+
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+
+ /* skb: hdr + (possibly fragmented) plaintext payload */
+ // PR: FIXME: hostap has additional conditions in the "if" below:
+ // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
+ if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
+ int flen;
+ struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
+ IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
+
+ if (!frag_skb) {
+ IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
+ "Rx cannot get skb from fragment "
+ "cache (morefrag=%d seq=%u frag=%u)\n",
+ (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
+ WLAN_GET_SEQ_SEQ(sc), frag);
+ goto rx_dropped;
+ }
+ flen = skb->len;
+ if (frag != 0)
+ flen -= hdrlen;
+
+ if (frag_skb->tail + flen > frag_skb->end) {
+ printk(KERN_WARNING "%s: host decrypted and "
+ "reassembled frame did not fit skb\n",
+ dev->name);
+ ieee80211_frag_cache_invalidate(ieee, hdr);
+ goto rx_dropped;
+ }
+
+ if (frag == 0) {
+ /* copy first fragment (including full headers) into
+ * beginning of the fragment cache skb */
+ memcpy(skb_put(frag_skb, flen), skb->data, flen);
+ } else {
+ /* append frame payload to the end of the fragment
+ * cache skb */
+ memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
+ flen);
+ }
+ dev_kfree_skb_any(skb);
+ skb = NULL;
+
+ if (fc & IEEE80211_FCTL_MOREFRAGS) {
+ /* more fragments expected - leave the skb in fragment
+ * cache for now; it will be delivered to upper layers
+ * after all fragments have been received */
+ goto rx_exit;
+ }
+
+ /* this was the last fragment and the frame will be
+ * delivered, so remove skb from fragment cache */
+ skb = frag_skb;
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ ieee80211_frag_cache_invalidate(ieee, hdr);
+ }
+
+ /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
+ * encrypted/authenticated */
+ if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
+ ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
+ {
+ printk("==>decrypt msdu error\n");
+ goto rx_dropped;
+ }
+
+ //added by amy for AP roaming
+ ieee->LinkDetectInfo.NumRecvDataInPeriod++;
+ ieee->LinkDetectInfo.NumRxOkInPeriod++;
+
+ hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
+ if (/*ieee->ieee802_1x &&*/
+ ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
+
+#ifdef CONFIG_IEEE80211_DEBUG
+ /* pass unencrypted EAPOL frames even if encryption is
+ * configured */
+ struct eapol *eap = (struct eapol *)(skb->data +
+ 24);
+ IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
+ eap_get_type(eap->type));
+#endif
+ } else {
+ IEEE80211_DEBUG_DROP(
+ "encryption configured, but RX "
+ "frame not encrypted (SA=" MAC_FMT ")\n",
+ MAC_ARG(hdr->addr2));
+ goto rx_dropped;
+ }
+ }
+
+#ifdef CONFIG_IEEE80211_DEBUG
+ if (crypt && !(fc & IEEE80211_FCTL_WEP) &&
+ ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
+ struct eapol *eap = (struct eapol *)(skb->data +
+ 24);
+ IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
+ eap_get_type(eap->type));
+ }
+#endif
+
+ if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
+ !ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
+ IEEE80211_DEBUG_DROP(
+ "dropped unencrypted RX data "
+ "frame from " MAC_FMT
+ " (drop_unencrypted=1)\n",
+ MAC_ARG(hdr->addr2));
+ goto rx_dropped;
+ }
+/*
+ if(ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
+ printk(KERN_WARNING "RX: IEEE802.1X EPAOL frame!\n");
+ }
+*/
+//added by amy for reorder
+#if 1
+ if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
+ && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1))
+ {
+ TID = Frame_QoSTID(skb->data);
+ SeqNum = WLAN_GET_SEQ_SEQ(sc);
+ GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true);
+ if(TID !=0 && TID !=3)
+ {
+ ieee->bis_any_nonbepkts = true;
+ }
+ }
+#endif
+//added by amy for reorder
+ /* skb: hdr + (possible reassembled) full plaintext payload */
+ payload = skb->data + hdrlen;
+ //ethertype = (payload[6] << 8) | payload[7];
+ rxb = (struct ieee80211_rxb*)kmalloc(sizeof(struct ieee80211_rxb),GFP_ATOMIC);
+ if(rxb == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__FUNCTION__);
+ goto rx_dropped;
+ }
+ /* to parse amsdu packets */
+ /* qos data packets & reserved bit is 1 */
+ if(parse_subframe(skb,rx_stats,rxb,src,dst) == 0) {
+ /* only to free rxb, and not submit the packets to upper layer */
+ for(i =0; i < rxb->nr_subframes; i++) {
+ dev_kfree_skb(rxb->subframes[i]);
+ }
+ kfree(rxb);
+ rxb = NULL;
+ goto rx_dropped;
+ }
+
+ ieee->last_rx_ps_time = jiffies;
+//added by amy for reorder
+ if(ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL){
+//added by amy for reorder
+ for(i = 0; i<rxb->nr_subframes; i++) {
+ struct sk_buff *sub_skb = rxb->subframes[i];
+
+ if (sub_skb) {
+ /* convert hdr + possible LLC headers into Ethernet header */
+ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
+ if (sub_skb->len >= 8 &&
+ ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
+ ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
+ memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
+ /* remove RFC1042 or Bridge-Tunnel encapsulation and
+ * replace EtherType */
+ skb_pull(sub_skb, SNAP_SIZE);
+ memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
+ memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
+ } else {
+ u16 len;
+ /* Leave Ethernet header part of hdr and full payload */
+ len = htons(sub_skb->len);
+ memcpy(skb_push(sub_skb, 2), &len, 2);
+ memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
+ memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
+ }
+
+ stats->rx_packets++;
+ stats->rx_bytes += sub_skb->len;
+ if(is_multicast_ether_addr(dst)) {
+ stats->multicast++;
+ }
+
+ /* Indicat the packets to upper layer */
+ //printk("0skb_len(%d)\n", skb->len);
+ sub_skb->protocol = eth_type_trans(sub_skb, dev);
+ memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
+ sub_skb->dev = dev;
+ sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+ //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
+ //printk("1skb_len(%d)\n", skb->len);
+ netif_rx(sub_skb);
+ }
+ }
+ kfree(rxb);
+ rxb = NULL;
+
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__);
+ RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
+ }
+#ifndef JOHN_NOCPY
+ dev_kfree_skb(skb);
+#endif
+
+ rx_exit:
+#ifdef NOT_YET
+ if (sta)
+ hostap_handle_sta_release(sta);
+#endif
+ return 1;
+
+ rx_dropped:
+ if (rxb != NULL)
+ {
+ kfree(rxb);
+ rxb = NULL;
+ }
+ stats->rx_dropped++;
+
+ /* Returning 0 indicates to caller that we have not handled the SKB--
+ * so it is still allocated and can be used again by underlying
+ * hardware as a DMA target */
+ return 0;
+}
+
+#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
+
+static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
+
+/*
+* Make ther structure we read from the beacon packet has
+* the right values
+*/
+static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
+ *info_element, int sub_type)
+{
+
+ if (info_element->qui_subtype != sub_type)
+ return -1;
+ if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
+ return -1;
+ if (info_element->qui_type != QOS_OUI_TYPE)
+ return -1;
+ if (info_element->version != QOS_VERSION_1)
+ return -1;
+
+ return 0;
+}
+
+
+/*
+ * Parse a QoS parameter element
+ */
+static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
+ *element_param, struct ieee80211_info_element
+ *info_element)
+{
+ int ret = 0;
+ u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
+
+ if ((info_element == NULL) || (element_param == NULL))
+ return -1;
+
+ if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
+ memcpy(element_param->info_element.qui, info_element->data,
+ info_element->len);
+ element_param->info_element.elementID = info_element->id;
+ element_param->info_element.length = info_element->len;
+ } else
+ ret = -1;
+ if (ret == 0)
+ ret = ieee80211_verify_qos_info(&element_param->info_element,
+ QOS_OUI_PARAM_SUB_TYPE);
+ return ret;
+}
+
+/*
+ * Parse a QoS information element
+ */
+static int ieee80211_read_qos_info_element(struct
+ ieee80211_qos_information_element
+ *element_info, struct ieee80211_info_element
+ *info_element)
+{
+ int ret = 0;
+ u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
+
+ if (element_info == NULL)
+ return -1;
+ if (info_element == NULL)
+ return -1;
+
+ if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
+ memcpy(element_info->qui, info_element->data,
+ info_element->len);
+ element_info->elementID = info_element->id;
+ element_info->length = info_element->len;
+ } else
+ ret = -1;
+
+ if (ret == 0)
+ ret = ieee80211_verify_qos_info(element_info,
+ QOS_OUI_INFO_SUB_TYPE);
+ return ret;
+}
+
+
+/*
+ * Write QoS parameters from the ac parameters.
+ */
+static int ieee80211_qos_convert_ac_to_parameters(struct
+ ieee80211_qos_parameter_info
+ *param_elm, struct
+ ieee80211_qos_parameters
+ *qos_param)
+{
+ int rc = 0;
+ int i;
+ struct ieee80211_qos_ac_parameter *ac_params;
+ u8 aci;
+ //u8 cw_min;
+ //u8 cw_max;
+
+ for (i = 0; i < QOS_QUEUE_NUM; i++) {
+ ac_params = &(param_elm->ac_params_record[i]);
+
+ aci = (ac_params->aci_aifsn & 0x60) >> 5;
+
+ if(aci >= QOS_QUEUE_NUM)
+ continue;
+ qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
+
+ /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
+ qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci];
+
+ qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F;
+
+ qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4;
+
+ qos_param->flag[aci] =
+ (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
+ qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit);
+ }
+ return rc;
+}
+
+/*
+ * we have a generic data element which it may contain QoS information or
+ * parameters element. check the information element length to decide
+ * which type to read
+ */
+static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
+ *info_element,
+ struct ieee80211_network *network)
+{
+ int rc = 0;
+ struct ieee80211_qos_parameters *qos_param = NULL;
+ struct ieee80211_qos_information_element qos_info_element;
+
+ rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
+
+ if (rc == 0) {
+ network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
+ network->flags |= NETWORK_HAS_QOS_INFORMATION;
+ } else {
+ struct ieee80211_qos_parameter_info param_element;
+
+ rc = ieee80211_read_qos_param_element(&param_element,
+ info_element);
+ if (rc == 0) {
+ qos_param = &(network->qos_data.parameters);
+ ieee80211_qos_convert_ac_to_parameters(&param_element,
+ qos_param);
+ network->flags |= NETWORK_HAS_QOS_PARAMETERS;
+ network->qos_data.param_count =
+ param_element.info_element.ac_info & 0x0F;
+ }
+ }
+
+ if (rc == 0) {
+ IEEE80211_DEBUG_QOS("QoS is supported\n");
+ network->qos_data.supported = 1;
+ }
+ return rc;
+}
+
+#ifdef CONFIG_IEEE80211_DEBUG
+#define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
+
+static const char *get_info_element_string(u16 id)
+{
+ switch (id) {
+ MFIE_STRING(SSID);
+ MFIE_STRING(RATES);
+ MFIE_STRING(FH_SET);
+ MFIE_STRING(DS_SET);
+ MFIE_STRING(CF_SET);
+ MFIE_STRING(TIM);
+ MFIE_STRING(IBSS_SET);
+ MFIE_STRING(COUNTRY);
+ MFIE_STRING(HOP_PARAMS);
+ MFIE_STRING(HOP_TABLE);
+ MFIE_STRING(REQUEST);
+ MFIE_STRING(CHALLENGE);
+ MFIE_STRING(POWER_CONSTRAINT);
+ MFIE_STRING(POWER_CAPABILITY);
+ MFIE_STRING(TPC_REQUEST);
+ MFIE_STRING(TPC_REPORT);
+ MFIE_STRING(SUPP_CHANNELS);
+ MFIE_STRING(CSA);
+ MFIE_STRING(MEASURE_REQUEST);
+ MFIE_STRING(MEASURE_REPORT);
+ MFIE_STRING(QUIET);
+ MFIE_STRING(IBSS_DFS);
+ // MFIE_STRING(ERP_INFO);
+ MFIE_STRING(RSN);
+ MFIE_STRING(RATES_EX);
+ MFIE_STRING(GENERIC);
+ MFIE_STRING(QOS_PARAMETER);
+ default:
+ return "UNKNOWN";
+ }
+}
+#endif
+
+#ifdef ENABLE_DOT11D
+static inline void ieee80211_extract_country_ie(
+ struct ieee80211_device *ieee,
+ struct ieee80211_info_element *info_element,
+ struct ieee80211_network *network,
+ u8 * addr2
+)
+{
+ if(IS_DOT11D_ENABLE(ieee))
+ {
+ if(info_element->len!= 0)
+ {
+ memcpy(network->CountryIeBuf, info_element->data, info_element->len);
+ network->CountryIeLen = info_element->len;
+
+ if(!IS_COUNTRY_IE_VALID(ieee))
+ {
+ Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
+ }
+ }
+
+ //
+ // 070305, rcnjko: I update country IE watch dog here because
+ // some AP (e.g. Cisco 1242) don't include country IE in their
+ // probe response frame.
+ //
+ if(IS_EQUAL_CIE_SRC(ieee, addr2) )
+ {
+ UPDATE_CIE_WATCHDOG(ieee);
+ }
+ }
+
+}
+#endif
+
+int ieee80211_parse_info_param(struct ieee80211_device *ieee,
+ struct ieee80211_info_element *info_element,
+ u16 length,
+ struct ieee80211_network *network,
+ struct ieee80211_rx_stats *stats)
+{
+ u8 i;
+ short offset;
+ u16 tmp_htcap_len=0;
+ u16 tmp_htinfo_len=0;
+ u16 ht_realtek_agg_len=0;
+ u8 ht_realtek_agg_buf[MAX_IE_LEN];
+// u16 broadcom_len = 0;
+#ifdef CONFIG_IEEE80211_DEBUG
+ char rates_str[64];
+ char *p;
+#endif
+
+ while (length >= sizeof(*info_element)) {
+ if (sizeof(*info_element) + info_element->len > length) {
+ IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
+ "info_element->len + 2 > left : "
+ "info_element->len+2=%zd left=%d, id=%d.\n",
+ info_element->len +
+ sizeof(*info_element),
+ length, info_element->id);
+ /* We stop processing but don't return an error here
+ * because some misbehaviour APs break this rule. ie.
+ * Orinoco AP1000. */
+ break;
+ }
+
+ switch (info_element->id) {
+ case MFIE_TYPE_SSID:
+ if (ieee80211_is_empty_essid(info_element->data,
+ info_element->len)) {
+ network->flags |= NETWORK_EMPTY_ESSID;
+ break;
+ }
+
+ network->ssid_len = min(info_element->len,
+ (u8) IW_ESSID_MAX_SIZE);
+ memcpy(network->ssid, info_element->data, network->ssid_len);
+ if (network->ssid_len < IW_ESSID_MAX_SIZE)
+ memset(network->ssid + network->ssid_len, 0,
+ IW_ESSID_MAX_SIZE - network->ssid_len);
+
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
+ network->ssid, network->ssid_len);
+ break;
+
+ case MFIE_TYPE_RATES:
+#ifdef CONFIG_IEEE80211_DEBUG
+ p = rates_str;
+#endif
+ network->rates_len = min(info_element->len,
+ MAX_RATES_LENGTH);
+ for (i = 0; i < network->rates_len; i++) {
+ network->rates[i] = info_element->data[i];
+#ifdef CONFIG_IEEE80211_DEBUG
+ p += snprintf(p, sizeof(rates_str) -
+ (p - rates_str), "%02X ",
+ network->rates[i]);
+#endif
+ if (ieee80211_is_ofdm_rate
+ (info_element->data[i])) {
+ network->flags |= NETWORK_HAS_OFDM;
+ if (info_element->data[i] &
+ IEEE80211_BASIC_RATE_MASK)
+ network->flags &=
+ ~NETWORK_HAS_CCK;
+ }
+ }
+
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
+ rates_str, network->rates_len);
+ break;
+
+ case MFIE_TYPE_RATES_EX:
+#ifdef CONFIG_IEEE80211_DEBUG
+ p = rates_str;
+#endif
+ network->rates_ex_len = min(info_element->len,
+ MAX_RATES_EX_LENGTH);
+ for (i = 0; i < network->rates_ex_len; i++) {
+ network->rates_ex[i] = info_element->data[i];
+#ifdef CONFIG_IEEE80211_DEBUG
+ p += snprintf(p, sizeof(rates_str) -
+ (p - rates_str), "%02X ",
+ network->rates[i]);
+#endif
+ if (ieee80211_is_ofdm_rate
+ (info_element->data[i])) {
+ network->flags |= NETWORK_HAS_OFDM;
+ if (info_element->data[i] &
+ IEEE80211_BASIC_RATE_MASK)
+ network->flags &=
+ ~NETWORK_HAS_CCK;
+ }
+ }
+
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
+ rates_str, network->rates_ex_len);
+ break;
+
+ case MFIE_TYPE_DS_SET:
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
+ info_element->data[0]);
+ network->channel = info_element->data[0];
+ break;
+
+ case MFIE_TYPE_FH_SET:
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
+ break;
+
+ case MFIE_TYPE_CF_SET:
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
+ break;
+
+ case MFIE_TYPE_TIM:
+ if(info_element->len < 4)
+ break;
+
+ network->tim.tim_count = info_element->data[0];
+ network->tim.tim_period = info_element->data[1];
+
+ network->dtim_period = info_element->data[1];
+ if(ieee->state != IEEE80211_LINKED)
+ break;
+#if 0
+ network->last_dtim_sta_time[0] = stats->mac_time[0];
+#else
+ //we use jiffies for legacy Power save
+ network->last_dtim_sta_time[0] = jiffies;
+#endif
+ network->last_dtim_sta_time[1] = stats->mac_time[1];
+
+ network->dtim_data = IEEE80211_DTIM_VALID;
+
+ if(info_element->data[0] != 0)
+ break;
+
+ if(info_element->data[2] & 1)
+ network->dtim_data |= IEEE80211_DTIM_MBCAST;
+
+ offset = (info_element->data[2] >> 1)*2;
+
+ //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
+
+ if(ieee->assoc_id < 8*offset ||
+ ieee->assoc_id > 8*(offset + info_element->len -3))
+
+ break;
+
+ offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ;
+
+ if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
+ network->dtim_data |= IEEE80211_DTIM_UCAST;
+
+ //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
+ break;
+
+ case MFIE_TYPE_ERP:
+ network->erp_value = info_element->data[0];
+ network->flags |= NETWORK_HAS_ERP_VALUE;
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
+ network->erp_value);
+ break;
+ case MFIE_TYPE_IBSS_SET:
+ network->atim_window = info_element->data[0];
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
+ network->atim_window);
+ break;
+
+ case MFIE_TYPE_CHALLENGE:
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
+ break;
+
+ case MFIE_TYPE_GENERIC:
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
+ info_element->len);
+ if (!ieee80211_parse_qos_info_param_IE(info_element,
+ network))
+ break;
+
+ if (info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x50 &&
+ info_element->data[2] == 0xf2 &&
+ info_element->data[3] == 0x01) {
+ network->wpa_ie_len = min(info_element->len + 2,
+ MAX_WPA_IE_LEN);
+ memcpy(network->wpa_ie, info_element,
+ network->wpa_ie_len);
+ break;
+ }
+
+#ifdef THOMAS_TURBO
+ if (info_element->len == 7 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0xe0 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x01 &&
+ info_element->data[4] == 0x02) {
+ network->Turbo_Enable = 1;
+ }
+#endif
+
+ //for HTcap and HTinfo parameters
+ if(tmp_htcap_len == 0){
+ if(info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x90 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x033){
+
+ tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
+ if(tmp_htcap_len != 0){
+ network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+ network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
+ sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
+ memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
+ }
+ }
+ if(tmp_htcap_len != 0){
+ network->bssht.bdSupportHT = true;
+ network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+ }else{
+ network->bssht.bdSupportHT = false;
+ network->bssht.bdHT1R = false;
+ }
+ }
+
+
+ if(tmp_htinfo_len == 0){
+ if(info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x90 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x034){
+
+ tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
+ if(tmp_htinfo_len != 0){
+ network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+ if(tmp_htinfo_len){
+ network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\
+ sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len;
+ memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen);
+ }
+
+ }
+
+ }
+ }
+
+ if(ieee->aggregation){
+ if(network->bssht.bdSupportHT){
+ if(info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0xe0 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x02){
+
+ ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN);
+ memcpy(ht_realtek_agg_buf,info_element->data,info_element->len);
+
+ }
+ if(ht_realtek_agg_len >= 5){
+ network->realtek_cap_exit = true;
+ network->bssht.bdRT2RTAggregation = true;
+
+ if((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02))
+ network->bssht.bdRT2RTLongSlotTime = true;
+
+ if((ht_realtek_agg_buf[4]==1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
+ {
+ network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
+ //bssDesc->Vender = HT_IOT_PEER_REALTEK_92SE;
+ }
+ }
+ }
+
+ }
+
+ //if(tmp_htcap_len !=0 || tmp_htinfo_len != 0)
+ {
+ if((info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x05 &&
+ info_element->data[2] == 0xb5) ||
+ (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x0a &&
+ info_element->data[2] == 0xf7) ||
+ (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x10 &&
+ info_element->data[2] == 0x18)){
+
+ network->broadcom_cap_exist = true;
+
+ }
+ }
+#if 0
+ if (tmp_htcap_len !=0)
+ {
+ u16 cap_ext = ((PHT_CAPABILITY_ELE)&info_element->data[0])->ExtHTCapInfo;
+ if ((cap_ext & 0x0c00) == 0x0c00)
+ {
+ network->ralink_cap_exist = true;
+ }
+ }
+#endif
+ if(info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x0c &&
+ info_element->data[2] == 0x43)
+ {
+ network->ralink_cap_exist = true;
+ }
+ else
+ network->ralink_cap_exist = false;
+ //added by amy for atheros AP
+ if((info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x03 &&
+ info_element->data[2] == 0x7f) ||
+ (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x13 &&
+ info_element->data[2] == 0x74))
+ {
+ // printk("========>%s(): athros AP is exist\n",__FUNCTION__);
+ network->atheros_cap_exist = true;
+ }
+ else
+ network->atheros_cap_exist = false;
+
+ if ((info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x50 &&
+ info_element->data[2] == 0x43) )
+ {
+ network->marvell_cap_exist = true;
+ }
+ else
+ network->marvell_cap_exist = false;
+
+ if(info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x40 &&
+ info_element->data[2] == 0x96)
+ {
+ network->cisco_cap_exist = true;
+ }
+ else
+ network->cisco_cap_exist = false;
+ //added by amy for LEAP of cisco
+ if(info_element->len > 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x40 &&
+ info_element->data[2] == 0x96 &&
+ info_element->data[3] == 0x01)
+ {
+ if(info_element->len == 6)
+ {
+ memcpy(network->CcxRmState, &info_element[4], 2);
+ if(network->CcxRmState[0] != 0)
+ {
+ network->bCcxRmEnable = true;
+ }
+ else
+ network->bCcxRmEnable = false;
+ //
+ // CCXv4 Table 59-1 MBSSID Masks.
+ //
+ network->MBssidMask = network->CcxRmState[1] & 0x07;
+ if(network->MBssidMask != 0)
+ {
+ network->bMBssidValid = true;
+ network->MBssidMask = 0xff << (network->MBssidMask);
+ cpMacAddr(network->MBssid, network->bssid);
+ network->MBssid[5] &= network->MBssidMask;
+ }
+ else
+ {
+ network->bMBssidValid = false;
+ }
+ }
+ else
+ {
+ network->bCcxRmEnable = false;
+ }
+ }
+ if(info_element->len > 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x40 &&
+ info_element->data[2] == 0x96 &&
+ info_element->data[3] == 0x03)
+ {
+ if(info_element->len == 5)
+ {
+ network->bWithCcxVerNum = true;
+ network->BssCcxVerNumber = info_element->data[4];
+ }
+ else
+ {
+ network->bWithCcxVerNum = false;
+ network->BssCcxVerNumber = 0;
+ }
+ }
+ break;
+
+ case MFIE_TYPE_RSN:
+ IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
+ info_element->len);
+ network->rsn_ie_len = min(info_element->len + 2,
+ MAX_WPA_IE_LEN);
+ memcpy(network->rsn_ie, info_element,
+ network->rsn_ie_len);
+ break;
+
+ //HT related element.
+ case MFIE_TYPE_HT_CAP:
+ IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
+ info_element->len);
+ tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
+ if(tmp_htcap_len != 0){
+ network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+ network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
+ sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
+ memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
+
+ //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
+ // windows driver will update WMM parameters each beacon received once connected
+ // Linux driver is a bit different.
+ network->bssht.bdSupportHT = true;
+ network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+ }
+ else{
+ network->bssht.bdSupportHT = false;
+ network->bssht.bdHT1R = false;
+ }
+ break;
+
+
+ case MFIE_TYPE_HT_INFO:
+ IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
+ info_element->len);
+ tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
+ if(tmp_htinfo_len){
+ network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
+ network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\
+ sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len;
+ memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen);
+ }
+ break;
+
+ case MFIE_TYPE_AIRONET:
+ IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
+ info_element->len);
+ if(info_element->len >IE_CISCO_FLAG_POSITION)
+ {
+ network->bWithAironetIE = true;
+
+ // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23):
+ // "A Cisco access point advertises support for CKIP in beacon and probe response packets,
+ // by adding an Aironet element and setting one or both of the CKIP negotiation bits."
+ if( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) ||
+ (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) )
+ {
+ network->bCkipSupported = true;
+ }
+ else
+ {
+ network->bCkipSupported = false;
+ }
+ }
+ else
+ {
+ network->bWithAironetIE = false;
+ network->bCkipSupported = false;
+ }
+ break;
+ case MFIE_TYPE_QOS_PARAMETER:
+ printk(KERN_ERR
+ "QoS Error need to parse QOS_PARAMETER IE\n");
+ break;
+
+#ifdef ENABLE_DOT11D
+ case MFIE_TYPE_COUNTRY:
+ IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
+ info_element->len);
+ //printk("=====>Receive <%s> Country IE\n",network->ssid);
+ ieee80211_extract_country_ie(ieee, info_element, network, network->bssid);//addr2 is same as addr3 when from an AP
+ break;
+#endif
+/* TODO */
+#if 0
+ /* 802.11h */
+ case MFIE_TYPE_POWER_CONSTRAINT:
+ network->power_constraint = info_element->data[0];
+ network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
+ break;
+
+ case MFIE_TYPE_CSA:
+ network->power_constraint = info_element->data[0];
+ network->flags |= NETWORK_HAS_CSA;
+ break;
+
+ case MFIE_TYPE_QUIET:
+ network->quiet.count = info_element->data[0];
+ network->quiet.period = info_element->data[1];
+ network->quiet.duration = info_element->data[2];
+ network->quiet.offset = info_element->data[3];
+ network->flags |= NETWORK_HAS_QUIET;
+ break;
+
+ case MFIE_TYPE_IBSS_DFS:
+ if (network->ibss_dfs)
+ break;
+ network->ibss_dfs = kmemdup(info_element->data,
+ info_element->len,
+ GFP_ATOMIC);
+ if (!network->ibss_dfs)
+ return 1;
+ network->flags |= NETWORK_HAS_IBSS_DFS;
+ break;
+
+ case MFIE_TYPE_TPC_REPORT:
+ network->tpc_report.transmit_power =
+ info_element->data[0];
+ network->tpc_report.link_margin = info_element->data[1];
+ network->flags |= NETWORK_HAS_TPC_REPORT;
+ break;
+#endif
+ default:
+ IEEE80211_DEBUG_MGMT
+ ("Unsupported info element: %s (%d)\n",
+ get_info_element_string(info_element->id),
+ info_element->id);
+ break;
+ }
+
+ length -= sizeof(*info_element) + info_element->len;
+ info_element =
+ (struct ieee80211_info_element *)&info_element->
+ data[info_element->len];
+ }
+
+ if(!network->atheros_cap_exist && !network->broadcom_cap_exist &&
+ !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation)
+ {
+ network->unknown_cap_exist = true;
+ }
+ else
+ {
+ network->unknown_cap_exist = false;
+ }
+ return 0;
+}
+
+static inline u8 ieee80211_SignalStrengthTranslate(
+ u8 CurrSS
+ )
+{
+ u8 RetSS;
+
+ // Step 1. Scale mapping.
+ if(CurrSS >= 71 && CurrSS <= 100)
+ {
+ RetSS = 90 + ((CurrSS - 70) / 3);
+ }
+ else if(CurrSS >= 41 && CurrSS <= 70)
+ {
+ RetSS = 78 + ((CurrSS - 40) / 3);
+ }
+ else if(CurrSS >= 31 && CurrSS <= 40)
+ {
+ RetSS = 66 + (CurrSS - 30);
+ }
+ else if(CurrSS >= 21 && CurrSS <= 30)
+ {
+ RetSS = 54 + (CurrSS - 20);
+ }
+ else if(CurrSS >= 5 && CurrSS <= 20)
+ {
+ RetSS = 42 + (((CurrSS - 5) * 2) / 3);
+ }
+ else if(CurrSS == 4)
+ {
+ RetSS = 36;
+ }
+ else if(CurrSS == 3)
+ {
+ RetSS = 27;
+ }
+ else if(CurrSS == 2)
+ {
+ RetSS = 18;
+ }
+ else if(CurrSS == 1)
+ {
+ RetSS = 9;
+ }
+ else
+ {
+ RetSS = CurrSS;
+ }
+ //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
+
+ // Step 2. Smoothing.
+
+ //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
+
+ return RetSS;
+}
+
+long ieee80211_translate_todbm(u8 signal_strength_index )// 0-100 index.
+{
+ long signal_power; // in dBm.
+
+ // Translate to dBm (x=0.5y-95).
+ signal_power = (long)((signal_strength_index + 1) >> 1);
+ signal_power -= 95;
+
+ return signal_power;
+}
+
+static inline int ieee80211_network_init(
+ struct ieee80211_device *ieee,
+ struct ieee80211_probe_response *beacon,
+ struct ieee80211_network *network,
+ struct ieee80211_rx_stats *stats)
+{
+#ifdef CONFIG_IEEE80211_DEBUG
+ //char rates_str[64];
+ //char *p;
+#endif
+
+ network->qos_data.active = 0;
+ network->qos_data.supported = 0;
+ network->qos_data.param_count = 0;
+ network->qos_data.old_param_count = 0;
+
+ /* Pull out fixed field data */
+ memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
+ network->capability = le16_to_cpu(beacon->capability);
+ network->last_scanned = jiffies;
+ network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
+ network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
+ network->beacon_interval = le32_to_cpu(beacon->beacon_interval);
+ /* Where to pull this? beacon->listen_interval;*/
+ network->listen_interval = 0x0A;
+ network->rates_len = network->rates_ex_len = 0;
+ network->last_associate = 0;
+ network->ssid_len = 0;
+ network->flags = 0;
+ network->atim_window = 0;
+ network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
+ 0x3 : 0x0;
+ network->berp_info_valid = false;
+ network->broadcom_cap_exist = false;
+ network->ralink_cap_exist = false;
+ network->atheros_cap_exist = false;
+ network->cisco_cap_exist = false;
+ network->unknown_cap_exist = false;
+ network->realtek_cap_exit = false;
+ network->marvell_cap_exist = false;
+#ifdef THOMAS_TURBO
+ network->Turbo_Enable = 0;
+#endif
+#ifdef ENABLE_DOT11D
+ network->CountryIeLen = 0;
+ memset(network->CountryIeBuf, 0, MAX_IE_LEN);
+#endif
+//Initialize HT parameters
+ //ieee80211_ht_initialize(&network->bssht);
+ HTInitializeBssDesc(&network->bssht);
+ if (stats->freq == IEEE80211_52GHZ_BAND) {
+ /* for A band (No DS info) */
+ network->channel = stats->received_channel;
+ } else
+ network->flags |= NETWORK_HAS_CCK;
+
+ network->wpa_ie_len = 0;
+ network->rsn_ie_len = 0;
+
+ if (ieee80211_parse_info_param
+ (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats))
+ return 1;
+
+ network->mode = 0;
+ if (stats->freq == IEEE80211_52GHZ_BAND)
+ network->mode = IEEE_A;
+ else {
+ if (network->flags & NETWORK_HAS_OFDM)
+ network->mode |= IEEE_G;
+ if (network->flags & NETWORK_HAS_CCK)
+ network->mode |= IEEE_B;
+ }
+
+ if (network->mode == 0) {
+ IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' "
+ "network.\n",
+ escape_essid(network->ssid,
+ network->ssid_len),
+ MAC_ARG(network->bssid));
+ return 1;
+ }
+
+ if(network->bssht.bdSupportHT){
+ if(network->mode == IEEE_A)
+ network->mode = IEEE_N_5G;
+ else if(network->mode & (IEEE_G | IEEE_B))
+ network->mode = IEEE_N_24G;
+ }
+ if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
+ network->flags |= NETWORK_EMPTY_ESSID;
+
+#if 1
+ stats->signal = 30 + (stats->SignalStrength * 70) / 100;
+ //stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
+ stats->noise = ieee80211_translate_todbm((u8)(100-stats->signal)) -25;
+#endif
+
+ memcpy(&network->stats, stats, sizeof(network->stats));
+
+ return 0;
+}
+
+static inline int is_same_network(struct ieee80211_network *src,
+ struct ieee80211_network *dst, struct ieee80211_device* ieee)
+{
+ /* A network is only a duplicate if the channel, BSSID, ESSID
+ * and the capability field (in particular IBSS and BSS) all match.
+ * We treat all <hidden> with the same BSSID and channel
+ * as one network */
+ return //((src->ssid_len == dst->ssid_len) &&
+ (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
+ (src->channel == dst->channel) &&
+ !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
+ //!memcmp(src->ssid, dst->ssid, src->ssid_len) &&
+ (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
+ ((src->capability & WLAN_CAPABILITY_IBSS) ==
+ (dst->capability & WLAN_CAPABILITY_IBSS)) &&
+ ((src->capability & WLAN_CAPABILITY_BSS) ==
+ (dst->capability & WLAN_CAPABILITY_BSS)));
+}
+
+static inline void update_network(struct ieee80211_network *dst,
+ struct ieee80211_network *src)
+{
+ int qos_active;
+ u8 old_param;
+
+ memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
+ dst->capability = src->capability;
+ memcpy(dst->rates, src->rates, src->rates_len);
+ dst->rates_len = src->rates_len;
+ memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
+ dst->rates_ex_len = src->rates_ex_len;
+ if(src->ssid_len > 0)
+ {
+ memset(dst->ssid, 0, dst->ssid_len);
+ dst->ssid_len = src->ssid_len;
+ memcpy(dst->ssid, src->ssid, src->ssid_len);
+ }
+ dst->mode = src->mode;
+ dst->flags = src->flags;
+ dst->time_stamp[0] = src->time_stamp[0];
+ dst->time_stamp[1] = src->time_stamp[1];
+ if (src->flags & NETWORK_HAS_ERP_VALUE)
+ {
+ dst->erp_value = src->erp_value;
+ dst->berp_info_valid = src->berp_info_valid = true;
+ }
+ dst->beacon_interval = src->beacon_interval;
+ dst->listen_interval = src->listen_interval;
+ dst->atim_window = src->atim_window;
+ dst->dtim_period = src->dtim_period;
+ dst->dtim_data = src->dtim_data;
+ dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
+ dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
+ memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters));
+
+ dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
+ dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
+ dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen;
+ memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen);
+ dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen;
+ memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen);
+ dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer;
+ dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime;
+ dst->broadcom_cap_exist = src->broadcom_cap_exist;
+ dst->ralink_cap_exist = src->ralink_cap_exist;
+ dst->atheros_cap_exist = src->atheros_cap_exist;
+ dst->realtek_cap_exit = src->realtek_cap_exit;
+ dst->marvell_cap_exist = src->marvell_cap_exist;
+ dst->cisco_cap_exist = src->cisco_cap_exist;
+ dst->unknown_cap_exist = src->unknown_cap_exist;
+ memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
+ dst->wpa_ie_len = src->wpa_ie_len;
+ memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
+ dst->rsn_ie_len = src->rsn_ie_len;
+
+ dst->last_scanned = jiffies;
+ /* qos related parameters */
+ //qos_active = src->qos_data.active;
+ qos_active = dst->qos_data.active;
+ //old_param = dst->qos_data.old_param_count;
+ old_param = dst->qos_data.param_count;
+ if(dst->flags & NETWORK_HAS_QOS_MASK){
+ //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB
+ // printk("====>%s(), aifs:%x, %x\n", __FUNCTION__, dst->qos_data.parameters.aifs[0], src->qos_data.parameters.aifs[0]);
+ // memcpy(&dst->qos_data, &src->qos_data,
+ // sizeof(struct ieee80211_qos_data));
+ }
+ else {
+ dst->qos_data.supported = src->qos_data.supported;
+ dst->qos_data.param_count = src->qos_data.param_count;
+ }
+
+ if(dst->qos_data.supported == 1) {
+ dst->QoS_Enable = 1;
+ if(dst->ssid_len)
+ IEEE80211_DEBUG_QOS
+ ("QoS the network %s is QoS supported\n",
+ dst->ssid);
+ else
+ IEEE80211_DEBUG_QOS
+ ("QoS the network is QoS supported\n");
+ }
+ dst->qos_data.active = qos_active;
+ dst->qos_data.old_param_count = old_param;
+
+ /* dst->last_associate is not overwritten */
+#if 1
+ dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame.
+ if(src->wmm_param[0].ac_aci_acm_aifsn|| \
+ src->wmm_param[1].ac_aci_acm_aifsn|| \
+ src->wmm_param[2].ac_aci_acm_aifsn|| \
+ src->wmm_param[1].ac_aci_acm_aifsn) {
+ memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
+ }
+ //dst->QoS_Enable = src->QoS_Enable;
+#else
+ dst->QoS_Enable = 1;//for Rtl8187 simulation
+#endif
+#ifdef THOMAS_TURBO
+ dst->Turbo_Enable = src->Turbo_Enable;
+#endif
+
+#ifdef ENABLE_DOT11D
+ dst->CountryIeLen = src->CountryIeLen;
+ memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen);
+#endif
+
+ //added by amy for LEAP
+ dst->bWithAironetIE = src->bWithAironetIE;
+ dst->bCkipSupported = src->bCkipSupported;
+ memcpy(dst->CcxRmState,src->CcxRmState,2);
+ dst->bCcxRmEnable = src->bCcxRmEnable;
+ dst->MBssidMask = src->MBssidMask;
+ dst->bMBssidValid = src->bMBssidValid;
+ memcpy(dst->MBssid,src->MBssid,6);
+ dst->bWithCcxVerNum = src->bWithCcxVerNum;
+ dst->BssCcxVerNumber = src->BssCcxVerNumber;
+
+}
+
+static inline int is_beacon(__le16 fc)
+{
+ return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
+}
+
+static inline void ieee80211_process_probe_response(
+ struct ieee80211_device *ieee,
+ struct ieee80211_probe_response *beacon,
+ struct ieee80211_rx_stats *stats)
+{
+ struct ieee80211_network network;
+ struct ieee80211_network *target;
+ struct ieee80211_network *oldest = NULL;
+#ifdef CONFIG_IEEE80211_DEBUG
+ struct ieee80211_info_element *info_element = &beacon->info_element[0];
+#endif
+ unsigned long flags;
+ short renew;
+ //u8 wmm_info;
+
+ memset(&network, 0, sizeof(struct ieee80211_network));
+ IEEE80211_DEBUG_SCAN(
+ "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
+ escape_essid(info_element->data, info_element->len),
+ MAC_ARG(beacon->header.addr3),
+ (beacon->capability & (1<<0xf)) ? '1' : '0',
+ (beacon->capability & (1<<0xe)) ? '1' : '0',
+ (beacon->capability & (1<<0xd)) ? '1' : '0',
+ (beacon->capability & (1<<0xc)) ? '1' : '0',
+ (beacon->capability & (1<<0xb)) ? '1' : '0',
+ (beacon->capability & (1<<0xa)) ? '1' : '0',
+ (beacon->capability & (1<<0x9)) ? '1' : '0',
+ (beacon->capability & (1<<0x8)) ? '1' : '0',
+ (beacon->capability & (1<<0x7)) ? '1' : '0',
+ (beacon->capability & (1<<0x6)) ? '1' : '0',
+ (beacon->capability & (1<<0x5)) ? '1' : '0',
+ (beacon->capability & (1<<0x4)) ? '1' : '0',
+ (beacon->capability & (1<<0x3)) ? '1' : '0',
+ (beacon->capability & (1<<0x2)) ? '1' : '0',
+ (beacon->capability & (1<<0x1)) ? '1' : '0',
+ (beacon->capability & (1<<0x0)) ? '1' : '0');
+
+ if (ieee80211_network_init(ieee, beacon, &network, stats)) {
+ IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
+ escape_essid(info_element->data,
+ info_element->len),
+ MAC_ARG(beacon->header.addr3),
+ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
+ IEEE80211_STYPE_PROBE_RESP ?
+ "PROBE RESPONSE" : "BEACON");
+ return;
+ }
+
+#ifdef ENABLE_DOT11D
+ // For Asus EeePc request,
+ // (1) if wireless adapter receive get any 802.11d country code in AP beacon,
+ // wireless adapter should follow the country code.
+ // (2) If there is no any country code in beacon,
+ // then wireless adapter should do active scan from ch1~11 and
+ // passive scan from ch12~14
+
+ if( !IsLegalChannel(ieee, network.channel) )
+ return;
+ if(ieee->bGlobalDomain)
+ {
+ if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP)
+ {
+ // Case 1: Country code
+ if(IS_COUNTRY_IE_VALID(ieee) )
+ {
+ if( !IsLegalChannel(ieee, network.channel) )
+ {
+ printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network.channel);
+ return;
+ }
+ }
+ // Case 2: No any country code.
+ else
+ {
+ // Filter over channel ch12~14
+ if(network.channel > 11)
+ {
+ printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network.channel);
+ return;
+ }
+ }
+ }
+ else
+ {
+ // Case 1: Country code
+ if(IS_COUNTRY_IE_VALID(ieee) )
+ {
+ if( !IsLegalChannel(ieee, network.channel) )
+ {
+ printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network.channel);
+ return;
+ }
+ }
+ // Case 2: No any country code.
+ else
+ {
+ // Filter over channel ch12~14
+ if(network.channel > 14)
+ {
+ printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network.channel);
+ return;
+ }
+ }
+ }
+ }
+#endif
+
+ /* The network parsed correctly -- so now we scan our known networks
+ * to see if we can find it in our list.
+ *
+ * NOTE: This search is definitely not optimized. Once its doing
+ * the "right thing" we'll optimize it for efficiency if
+ * necessary */
+
+ /* Search for this entry in the list and update it if it is
+ * already there. */
+
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if(is_same_network(&ieee->current_network, &network, ieee)) {
+ update_network(&ieee->current_network, &network);
+ if((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G)
+ && ieee->current_network.berp_info_valid){
+ if(ieee->current_network.erp_value& ERP_UseProtection)
+ ieee->current_network.buseprotection = true;
+ else
+ ieee->current_network.buseprotection = false;
+ }
+ if(is_beacon(beacon->header.frame_ctl))
+ {
+ if(ieee->state == IEEE80211_LINKED)
+ ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
+ }
+ else //hidden AP
+ network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & ieee->current_network.flags);
+ }
+
+ list_for_each_entry(target, &ieee->network_list, list) {
+ if (is_same_network(target, &network, ieee))
+ break;
+ if ((oldest == NULL) ||
+ (target->last_scanned < oldest->last_scanned))
+ oldest = target;
+ }
+
+ /* If we didn't find a match, then get a new network slot to initialize
+ * with this beacon's information */
+ if (&target->list == &ieee->network_list) {
+ if (list_empty(&ieee->network_free_list)) {
+ /* If there are no more slots, expire the oldest */
+ list_del(&oldest->list);
+ target = oldest;
+ IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from "
+ "network list.\n",
+ escape_essid(target->ssid,
+ target->ssid_len),
+ MAC_ARG(target->bssid));
+ } else {
+ /* Otherwise just pull from the free list */
+ target = list_entry(ieee->network_free_list.next,
+ struct ieee80211_network, list);
+ list_del(ieee->network_free_list.next);
+ }
+
+
+#ifdef CONFIG_IEEE80211_DEBUG
+ IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n",
+ escape_essid(network.ssid,
+ network.ssid_len),
+ MAC_ARG(network.bssid),
+ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
+ IEEE80211_STYPE_PROBE_RESP ?
+ "PROBE RESPONSE" : "BEACON");
+#endif
+ memcpy(target, &network, sizeof(*target));
+ list_add_tail(&target->list, &ieee->network_list);
+ if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
+ ieee80211_softmac_new_net(ieee,&network);
+ } else {
+ IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
+ escape_essid(target->ssid,
+ target->ssid_len),
+ MAC_ARG(target->bssid),
+ WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
+ IEEE80211_STYPE_PROBE_RESP ?
+ "PROBE RESPONSE" : "BEACON");
+
+ /* we have an entry and we are going to update it. But this entry may
+ * be already expired. In this case we do the same as we found a new
+ * net and call the new_net handler
+ */
+ renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
+ //YJ,add,080819,for hidden ap
+ if(is_beacon(beacon->header.frame_ctl) == 0)
+ network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & target->flags);
+ //if(strncmp(network.ssid, "linksys-c",9) == 0)
+ // printk("====>2 network.ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network.ssid, network.flags, target->ssid, target->flags);
+ if(((network.flags & NETWORK_EMPTY_ESSID) == NETWORK_EMPTY_ESSID) \
+ && (((network.ssid_len > 0) && (strncmp(target->ssid, network.ssid, network.ssid_len)))\
+ ||((ieee->current_network.ssid_len == network.ssid_len)&&(strncmp(ieee->current_network.ssid, network.ssid, network.ssid_len) == 0)&&(ieee->state == IEEE80211_NOLINK))))
+ renew = 1;
+ //YJ,add,080819,for hidden ap,end
+
+ update_network(target, &network);
+ if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
+ ieee80211_softmac_new_net(ieee,&network);
+ }
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+ if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, &network, ieee)&&\
+ (ieee->state == IEEE80211_LINKED)) {
+ if(ieee->handle_beacon != NULL) {
+ ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network);
+ }
+ }
+}
+
+void ieee80211_rx_mgt(struct ieee80211_device *ieee,
+ struct ieee80211_hdr_4addr *header,
+ struct ieee80211_rx_stats *stats)
+{
+ if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
+ ieee->iw_mode == IW_MODE_INFRA &&
+ ieee->state == IEEE80211_LINKED))
+ {
+ tasklet_schedule(&ieee->ps_task);
+ }
+
+ if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
+ WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
+ ieee->last_rx_ps_time = jiffies;
+
+ switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
+
+ case IEEE80211_STYPE_BEACON:
+ IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
+ WLAN_FC_GET_STYPE(header->frame_ctl));
+ IEEE80211_DEBUG_SCAN("Beacon\n");
+ ieee80211_process_probe_response(
+ ieee, (struct ieee80211_probe_response *)header, stats);
+ break;
+
+ case IEEE80211_STYPE_PROBE_RESP:
+ IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
+ WLAN_FC_GET_STYPE(header->frame_ctl));
+ IEEE80211_DEBUG_SCAN("Probe response\n");
+ ieee80211_process_probe_response(
+ ieee, (struct ieee80211_probe_response *)header, stats);
+ break;
+
+ }
+}
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_rx_mgt);
+EXPORT_SYMBOL(ieee80211_rx);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_rx_mgt);
+EXPORT_SYMBOL_NOVERS(ieee80211_rx);
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
new file mode 100644
index 000000000000..6773e84c778e
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
@@ -0,0 +1,3580 @@
+/* IEEE 802.11 SoftMAC layer
+ * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
+ *
+ * Mostly extracted from the rtl8180-sa2400 driver for the
+ * in-kernel generic ieee802.11 stack.
+ *
+ * Few lines might be stolen from other part of the ieee80211
+ * stack. Copyright who own it's copyright
+ *
+ * WPA code stolen from the ipw2200 driver.
+ * Copyright who own it's copyright.
+ *
+ * released under the GPL
+ */
+
+
+#include "ieee80211.h"
+
+#include <linux/random.h>
+#include <linux/delay.h>
+#include <linux/version.h>
+#include <asm/uaccess.h>
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+
+u8 rsn_authen_cipher_suite[16][4] = {
+ {0x00,0x0F,0xAC,0x00}, //Use group key, //Reserved
+ {0x00,0x0F,0xAC,0x01}, //WEP-40 //RSNA default
+ {0x00,0x0F,0xAC,0x02}, //TKIP //NONE //{used just as default}
+ {0x00,0x0F,0xAC,0x03}, //WRAP-historical
+ {0x00,0x0F,0xAC,0x04}, //CCMP
+ {0x00,0x0F,0xAC,0x05}, //WEP-104
+};
+
+short ieee80211_is_54g(struct ieee80211_network net)
+{
+ return ((net.rates_ex_len > 0) || (net.rates_len > 4));
+}
+
+short ieee80211_is_shortslot(struct ieee80211_network net)
+{
+ return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
+}
+
+/* returns the total length needed for pleacing the RATE MFIE
+ * tag and the EXTENDED RATE MFIE tag if needed.
+ * It encludes two bytes per tag for the tag itself and its len
+ */
+unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
+{
+ unsigned int rate_len = 0;
+
+ if (ieee->modulation & IEEE80211_CCK_MODULATION)
+ rate_len = IEEE80211_CCK_RATE_LEN + 2;
+
+ if (ieee->modulation & IEEE80211_OFDM_MODULATION)
+
+ rate_len += IEEE80211_OFDM_RATE_LEN + 2;
+
+ return rate_len;
+}
+
+/* pleace the MFIE rate, tag to the memory (double) poined.
+ * Then it updates the pointer so that
+ * it points after the new MFIE tag added.
+ */
+void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
+{
+ u8 *tag = *tag_p;
+
+ if (ieee->modulation & IEEE80211_CCK_MODULATION){
+ *tag++ = MFIE_TYPE_RATES;
+ *tag++ = 4;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
+ }
+
+ /* We may add an option for custom rates that specific HW might support */
+ *tag_p = tag;
+}
+
+void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
+{
+ u8 *tag = *tag_p;
+
+ if (ieee->modulation & IEEE80211_OFDM_MODULATION){
+
+ *tag++ = MFIE_TYPE_RATES_EX;
+ *tag++ = 8;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
+ *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
+
+ }
+
+ /* We may add an option for custom rates that specific HW might support */
+ *tag_p = tag;
+}
+
+
+void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) {
+ u8 *tag = *tag_p;
+
+ *tag++ = MFIE_TYPE_GENERIC; //0
+ *tag++ = 7;
+ *tag++ = 0x00;
+ *tag++ = 0x50;
+ *tag++ = 0xf2;
+ *tag++ = 0x02;//5
+ *tag++ = 0x00;
+ *tag++ = 0x01;
+#ifdef SUPPORT_USPD
+ if(ieee->current_network.wmm_info & 0x80) {
+ *tag++ = 0x0f|MAX_SP_Len;
+ } else {
+ *tag++ = MAX_SP_Len;
+ }
+#else
+ *tag++ = MAX_SP_Len;
+#endif
+ *tag_p = tag;
+}
+
+#ifdef THOMAS_TURBO
+void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) {
+ u8 *tag = *tag_p;
+
+ *tag++ = MFIE_TYPE_GENERIC; //0
+ *tag++ = 7;
+ *tag++ = 0x00;
+ *tag++ = 0xe0;
+ *tag++ = 0x4c;
+ *tag++ = 0x01;//5
+ *tag++ = 0x02;
+ *tag++ = 0x11;
+ *tag++ = 0x00;
+
+ *tag_p = tag;
+ printk(KERN_ALERT "This is enable turbo mode IE process\n");
+}
+#endif
+
+void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
+{
+ int nh;
+ nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
+
+/*
+ * if the queue is full but we have newer frames then
+ * just overwrites the oldest.
+ *
+ * if (nh == ieee->mgmt_queue_tail)
+ * return -1;
+ */
+ ieee->mgmt_queue_head = nh;
+ ieee->mgmt_queue_ring[nh] = skb;
+
+ //return 0;
+}
+
+struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
+{
+ struct sk_buff *ret;
+
+ if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
+ return NULL;
+
+ ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
+
+ ieee->mgmt_queue_tail =
+ (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
+
+ return ret;
+}
+
+void init_mgmt_queue(struct ieee80211_device *ieee)
+{
+ ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
+}
+
+u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ u8 rate;
+
+ // 2008/01/25 MH For broadcom, MGNT frame set as OFDM 6M.
+ if(pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M)
+ rate = 0x0c;
+ else
+ rate = ieee->basic_rate & 0x7f;
+
+ if(rate == 0){
+ // 2005.01.26, by rcnjko.
+ if(ieee->mode == IEEE_A||
+ ieee->mode== IEEE_N_5G||
+ (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK))
+ rate = 0x0c;
+ else
+ rate = 0x02;
+ }
+
+ /*
+ // Data rate of ProbeReq is already decided. Annie, 2005-03-31
+ if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) )
+ {
+ if(pMgntInfo->dot11CurrentWirelessMode==WIRELESS_MODE_A)
+ rate = 0x0c;
+ else
+ rate = 0x02;
+ }
+ */
+ return rate;
+}
+
+
+void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
+
+inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
+{
+ unsigned long flags;
+ short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
+ struct ieee80211_hdr_3addr *header=
+ (struct ieee80211_hdr_3addr *) skb->data;
+
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8);
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ /* called with 2nd param 0, no mgmt lock required */
+ ieee80211_sta_wakeup(ieee,0);
+
+ tcb_desc->queue_index = MGNT_QUEUE;
+ tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee);
+ tcb_desc->RATRIndex = 7;
+ tcb_desc->bTxDisableRateFallBack = 1;
+ tcb_desc->bTxUseDriverAssingedRate = 1;
+
+ if(single){
+ if(ieee->queue_stop){
+ enqueue_mgmt(ieee,skb);
+ }else{
+ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4);
+
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+
+ /* avoid watchdog triggers */
+ // ieee->dev->trans_start = jiffies;
+ ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+ }else{
+ spin_unlock_irqrestore(&ieee->lock, flags);
+ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
+
+ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
+
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+
+ /* check wether the managed packet queued greater than 5 */
+ if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\
+ (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\
+ (ieee->queue_stop) ) {
+ /* insert the skb packet to the management queue */
+ /* as for the completion function, it does not need
+ * to check it any more.
+ * */
+ printk("%s():insert to waitqueue!\n",__FUNCTION__);
+ skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ //printk("TX packet!\n");
+ ieee->softmac_hard_start_xmit(skb,ieee->dev);
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+ spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
+ }
+}
+
+inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
+{
+
+ short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
+ struct ieee80211_hdr_3addr *header =
+ (struct ieee80211_hdr_3addr *) skb->data;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8);
+
+ tcb_desc->queue_index = MGNT_QUEUE;
+ tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee);
+ tcb_desc->RATRIndex = 7;
+ tcb_desc->bTxDisableRateFallBack = 1;
+ tcb_desc->bTxUseDriverAssingedRate = 1;
+ //printk("=============>%s()\n", __FUNCTION__);
+ if(single){
+
+ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
+
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+
+ /* avoid watchdog triggers */
+ // ieee->dev->trans_start = jiffies;
+ ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
+
+ }else{
+
+ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
+
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+
+ ieee->softmac_hard_start_xmit(skb,ieee->dev);
+
+ }
+ //dev_kfree_skb_any(skb);//edit by thomas
+}
+
+inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
+{
+ unsigned int len,rate_len;
+ u8 *tag;
+ struct sk_buff *skb;
+ struct ieee80211_probe_request *req;
+
+ len = ieee->current_network.ssid_len;
+
+ rate_len = ieee80211_MFIE_rate_len(ieee);
+
+ skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
+ 2 + len + rate_len + ieee->tx_headroom);
+ if (!skb)
+ return NULL;
+
+ skb_reserve(skb, ieee->tx_headroom);
+
+ req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
+ req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
+ req->header.duration_id = 0; //FIXME: is this OK ?
+
+ memset(req->header.addr1, 0xff, ETH_ALEN);
+ memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memset(req->header.addr3, 0xff, ETH_ALEN);
+
+ tag = (u8 *) skb_put(skb,len+2+rate_len);
+
+ *tag++ = MFIE_TYPE_SSID;
+ *tag++ = len;
+ memcpy(tag, ieee->current_network.ssid, len);
+ tag += len;
+
+ ieee80211_MFIE_Brate(ieee,&tag);
+ ieee80211_MFIE_Grate(ieee,&tag);
+ return skb;
+}
+
+struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
+void ieee80211_send_beacon(struct ieee80211_device *ieee)
+{
+ struct sk_buff *skb;
+ if(!ieee->ieee_up)
+ return;
+ //unsigned long flags;
+ skb = ieee80211_get_beacon_(ieee);
+
+ if (skb){
+ softmac_mgmt_xmit(skb, ieee);
+ ieee->softmac_stats.tx_beacons++;
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+// ieee->beacon_timer.expires = jiffies +
+// (MSECS( ieee->current_network.beacon_interval -5));
+
+ //spin_lock_irqsave(&ieee->beacon_lock,flags);
+ if(ieee->beacon_txing && ieee->ieee_up){
+// if(!timer_pending(&ieee->beacon_timer))
+// add_timer(&ieee->beacon_timer);
+ mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5)));
+ }
+ //spin_unlock_irqrestore(&ieee->beacon_lock,flags);
+}
+
+
+void ieee80211_send_beacon_cb(unsigned long _ieee)
+{
+ struct ieee80211_device *ieee =
+ (struct ieee80211_device *) _ieee;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ieee->beacon_lock, flags);
+ ieee80211_send_beacon(ieee);
+ spin_unlock_irqrestore(&ieee->beacon_lock, flags);
+}
+
+
+void ieee80211_send_probe(struct ieee80211_device *ieee)
+{
+ struct sk_buff *skb;
+
+ skb = ieee80211_probe_req(ieee);
+ if (skb){
+ softmac_mgmt_xmit(skb, ieee);
+ ieee->softmac_stats.tx_probe_rq++;
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+}
+
+void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
+{
+ if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
+ ieee80211_send_probe(ieee);
+ ieee80211_send_probe(ieee);
+ }
+}
+
+/* this performs syncro scan blocking the caller until all channels
+ * in the allowed channel map has been checked.
+ */
+void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
+{
+ short ch = 0;
+#ifdef ENABLE_DOT11D
+ u8 channel_map[MAX_CHANNEL_NUMBER+1];
+ memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1);
+#endif
+ ieee->be_scan_inprogress = true;
+ down(&ieee->scan_sem);
+
+ while(1)
+ {
+
+ do{
+ ch++;
+ if (ch > MAX_CHANNEL_NUMBER)
+ goto out; /* scan completed */
+#ifdef ENABLE_DOT11D
+ }while(!channel_map[ch]);
+#else
+ }while(!ieee->channel_map[ch]);
+#endif
+
+ /* this fuction can be called in two situations
+ * 1- We have switched to ad-hoc mode and we are
+ * performing a complete syncro scan before conclude
+ * there are no interesting cell and to create a
+ * new one. In this case the link state is
+ * IEEE80211_NOLINK until we found an interesting cell.
+ * If so the ieee8021_new_net, called by the RX path
+ * will set the state to IEEE80211_LINKED, so we stop
+ * scanning
+ * 2- We are linked and the root uses run iwlist scan.
+ * So we switch to IEEE80211_LINKED_SCANNING to remember
+ * that we are still logically linked (not interested in
+ * new network events, despite for updating the net list,
+ * but we are temporarly 'unlinked' as the driver shall
+ * not filter RX frames and the channel is changing.
+ * So the only situation in witch are interested is to check
+ * if the state become LINKED because of the #1 situation
+ */
+
+ if (ieee->state == IEEE80211_LINKED)
+ goto out;
+ ieee->set_chan(ieee->dev, ch);
+#ifdef ENABLE_DOT11D
+ if(channel_map[ch] == 1)
+#endif
+ ieee80211_send_probe_requests(ieee);
+
+ /* this prevent excessive time wait when we
+ * need to wait for a syncro scan to end..
+ */
+ if(ieee->state < IEEE80211_LINKED)
+ ;
+ else
+ if (ieee->sync_scan_hurryup)
+ goto out;
+
+
+ msleep_interruptible_rsl(IEEE80211_SOFTMAC_SCAN_TIME);
+
+ }
+out:
+ if(ieee->state < IEEE80211_LINKED){
+ ieee->actscanning = false;
+ up(&ieee->scan_sem);
+ ieee->be_scan_inprogress = false;
+ }
+ else{
+ ieee->sync_scan_hurryup = 0;
+#ifdef ENABLE_DOT11D
+ if(IS_DOT11D_ENABLE(ieee))
+ DOT11D_ScanComplete(ieee);
+#endif
+ up(&ieee->scan_sem);
+ ieee->be_scan_inprogress = false;
+}
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/* called both by wq with ieee->lock held */
+void ieee80211_softmac_scan(struct ieee80211_device *ieee)
+{
+#if 0
+ short watchdog = 0;
+ do{
+ ieee->current_network.channel =
+ (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
+ if (watchdog++ > MAX_CHANNEL_NUMBER)
+ return; /* no good chans */
+
+ }while(!ieee->channel_map[ieee->current_network.channel]);
+#endif
+
+ schedule_task(&ieee->softmac_scan_wq);
+}
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void ieee80211_softmac_scan_wq(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work, struct delayed_work, work);
+ struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
+#else
+void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
+{
+#endif
+ u8 last_channel = ieee->current_network.channel; //recored init channel inorder not change current channel when comming out the scan unexpectedly. WB.
+#ifdef ENABLE_DOT11D
+ u8 channel_map[MAX_CHANNEL_NUMBER+1];
+ memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1);
+#endif
+ if(!ieee->ieee_up)
+ return;
+ down(&ieee->scan_sem);
+ do{
+ ieee->current_network.channel =
+ (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
+ if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER)
+ {
+ //if current channel is not in channel map, set to default channel.
+ #ifdef ENABLE_DOT11D
+ if (!channel_map[ieee->current_network.channel]);
+ #else
+ if (!ieee->channel_map[ieee->current_network.channel]);
+ #endif
+ ieee->current_network.channel = 6;
+ goto out; /* no good chans */
+ }
+#ifdef ENABLE_DOT11D
+ }while(!channel_map[ieee->current_network.channel]);
+#else
+ }while(!ieee->channel_map[ieee->current_network.channel]);
+#endif
+ if (ieee->scanning == 0 )
+ goto out;
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+#ifdef ENABLE_DOT11D
+ if(channel_map[ieee->current_network.channel] == 1)
+#endif
+ ieee80211_send_probe_requests(ieee);
+
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
+#else
+ //ieee->scan_timer.expires = jiffies + MSECS(IEEE80211_SOFTMAC_SCAN_TIME);
+ if (ieee->scanning == 1)
+ mod_timer(&ieee->scan_timer,(jiffies + MSECS(IEEE80211_SOFTMAC_SCAN_TIME)));
+#endif
+
+ up(&ieee->scan_sem);
+ return;
+out:
+#ifdef ENABLE_DOT11D
+ if(IS_DOT11D_ENABLE(ieee))
+ DOT11D_ScanComplete(ieee);
+#endif
+ ieee->current_network.channel = last_channel;
+ ieee->actscanning = false;
+ ieee->scan_watch_dog = 0;
+ ieee->scanning = 0;
+ up(&ieee->scan_sem);
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+void ieee80211_softmac_scan_cb(unsigned long _dev)
+{
+ unsigned long flags;
+ struct ieee80211_device *ieee = (struct ieee80211_device *)_dev;
+
+ spin_lock_irqsave(&ieee->lock, flags);
+ ieee80211_softmac_scan(ieee);
+ spin_unlock_irqrestore(&ieee->lock, flags);
+}
+#endif
+
+
+void ieee80211_beacons_start(struct ieee80211_device *ieee)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&ieee->beacon_lock,flags);
+
+ ieee->beacon_txing = 1;
+ ieee80211_send_beacon(ieee);
+
+ spin_unlock_irqrestore(&ieee->beacon_lock,flags);
+}
+
+void ieee80211_beacons_stop(struct ieee80211_device *ieee)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ieee->beacon_lock,flags);
+
+ ieee->beacon_txing = 0;
+ del_timer_sync(&ieee->beacon_timer);
+
+ spin_unlock_irqrestore(&ieee->beacon_lock,flags);
+
+}
+
+
+void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
+{
+ if(ieee->stop_send_beacons)
+ ieee->stop_send_beacons(ieee->dev);
+ if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
+ ieee80211_beacons_stop(ieee);
+}
+
+
+void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
+{
+ if(ieee->start_send_beacons)
+ ieee->start_send_beacons(ieee->dev);
+ if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
+ ieee80211_beacons_start(ieee);
+}
+
+
+void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
+{
+// unsigned long flags;
+
+ //ieee->sync_scan_hurryup = 1;
+
+ down(&ieee->scan_sem);
+// spin_lock_irqsave(&ieee->lock, flags);
+ ieee->scan_watch_dog = 0;
+ if (ieee->scanning == 1){
+ ieee->scanning = 0;
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ cancel_delayed_work(&ieee->softmac_scan_wq);
+#else
+ del_timer_sync(&ieee->scan_timer);
+#endif
+ }
+
+// spin_unlock_irqrestore(&ieee->lock, flags);
+ up(&ieee->scan_sem);
+}
+
+void ieee80211_stop_scan(struct ieee80211_device *ieee)
+{
+ if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
+ ieee80211_softmac_stop_scan(ieee);
+ else
+ ieee->stop_scan(ieee->dev);
+}
+
+/* called with ieee->lock held */
+void ieee80211_start_scan(struct ieee80211_device *ieee)
+{
+#ifdef ENABLE_DOT11D
+ if(IS_DOT11D_ENABLE(ieee) )
+ {
+ if(IS_COUNTRY_IE_VALID(ieee))
+ {
+ RESET_CIE_WATCHDOG(ieee);
+ }
+ }
+#endif
+ if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
+ if (ieee->scanning == 0){
+ ieee->scanning = 1;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
+#else
+
+ queue_work(ieee->wq, &ieee->softmac_scan_wq);
+#endif
+#else
+ ieee80211_softmac_scan(ieee);
+#endif
+ }
+ }else
+ ieee->start_scan(ieee->dev);
+
+}
+
+/* called with wx_sem held */
+void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
+{
+#ifdef ENABLE_DOT11D
+ if(IS_DOT11D_ENABLE(ieee) )
+ {
+ if(IS_COUNTRY_IE_VALID(ieee))
+ {
+ RESET_CIE_WATCHDOG(ieee);
+ }
+ }
+#endif
+ ieee->sync_scan_hurryup = 0;
+ if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
+ ieee80211_softmac_scan_syncro(ieee);
+ else
+ ieee->scan_syncro(ieee->dev);
+
+}
+
+inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
+ struct ieee80211_device *ieee, int challengelen)
+{
+ struct sk_buff *skb;
+ struct ieee80211_authentication *auth;
+ int len = sizeof(struct ieee80211_authentication) + challengelen + ieee->tx_headroom;
+
+
+ skb = dev_alloc_skb(len);
+ if (!skb) return NULL;
+
+ skb_reserve(skb, ieee->tx_headroom);
+ auth = (struct ieee80211_authentication *)
+ skb_put(skb, sizeof(struct ieee80211_authentication));
+
+ auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
+ if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
+
+ auth->header.duration_id = 0x013a; //FIXME
+
+ memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
+ memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
+
+ //auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
+ if(ieee->auth_mode == 0)
+ auth->algorithm = WLAN_AUTH_OPEN;
+ else if(ieee->auth_mode == 1)
+ auth->algorithm = WLAN_AUTH_SHARED_KEY;
+ else if(ieee->auth_mode == 2)
+ auth->algorithm = WLAN_AUTH_OPEN;//0x80;
+ printk("=================>%s():auth->algorithm is %d\n",__FUNCTION__,auth->algorithm);
+ auth->transaction = cpu_to_le16(ieee->associate_seq);
+ ieee->associate_seq++;
+
+ auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
+
+ return skb;
+
+}
+
+
+static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
+{
+ u8 *tag;
+ int beacon_size;
+ struct ieee80211_probe_response *beacon_buf;
+ struct sk_buff *skb = NULL;
+ int encrypt;
+ int atim_len,erp_len;
+ struct ieee80211_crypt_data* crypt;
+
+ char *ssid = ieee->current_network.ssid;
+ int ssid_len = ieee->current_network.ssid_len;
+ int rate_len = ieee->current_network.rates_len+2;
+ int rate_ex_len = ieee->current_network.rates_ex_len;
+ int wpa_ie_len = ieee->wpa_ie_len;
+ u8 erpinfo_content = 0;
+
+ u8* tmp_ht_cap_buf;
+ u8 tmp_ht_cap_len=0;
+ u8* tmp_ht_info_buf;
+ u8 tmp_ht_info_len=0;
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ u8* tmp_generic_ie_buf=NULL;
+ u8 tmp_generic_ie_len=0;
+
+ if(rate_ex_len > 0) rate_ex_len+=2;
+
+ if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
+ atim_len = 4;
+ else
+ atim_len = 0;
+
+#if 1
+ if(ieee80211_is_54g(ieee->current_network))
+ erp_len = 3;
+ else
+ erp_len = 0;
+#else
+ if((ieee->current_network.mode == IEEE_G)
+ ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) {
+ erp_len = 3;
+ erpinfo_content = 0;
+ if(ieee->current_network.buseprotection)
+ erpinfo_content |= ERP_UseProtection;
+ }
+ else
+ erp_len = 0;
+#endif
+
+
+ crypt = ieee->crypt[ieee->tx_keyidx];
+
+
+ encrypt = ieee->host_encrypt && crypt && crypt->ops &&
+ ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
+ //HT ralated element
+#if 1
+ tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap);
+ tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
+ tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo);
+ tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo);
+ HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt);
+ HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt);
+
+
+ if(pHTInfo->bRegRT2RTAggregation)
+ {
+ tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
+ tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
+ HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len);
+ }
+// printk("===============>tmp_ht_cap_len is %d,tmp_ht_info_len is %d, tmp_generic_ie_len is %d\n",tmp_ht_cap_len,tmp_ht_info_len,tmp_generic_ie_len);
+#endif
+ beacon_size = sizeof(struct ieee80211_probe_response)+2+
+ ssid_len
+ +3 //channel
+ +rate_len
+ +rate_ex_len
+ +atim_len
+ +erp_len
+ +wpa_ie_len
+ // +tmp_ht_cap_len
+ // +tmp_ht_info_len
+ // +tmp_generic_ie_len
+// +wmm_len+2
+ +ieee->tx_headroom;
+ skb = dev_alloc_skb(beacon_size);
+ if (!skb)
+ return NULL;
+ skb_reserve(skb, ieee->tx_headroom);
+ beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom));
+ memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
+ memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
+
+ beacon_buf->header.duration_id = 0; //FIXME
+ beacon_buf->beacon_interval =
+ cpu_to_le16(ieee->current_network.beacon_interval);
+ beacon_buf->capability =
+ cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
+ beacon_buf->capability |=
+ cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); //add short preamble here
+
+ if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
+ cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
+
+ crypt = ieee->crypt[ieee->tx_keyidx];
+#if 0
+ encrypt = ieee->host_encrypt && crypt && crypt->ops &&
+ (0 == strcmp(crypt->ops->name, "WEP"));
+#endif
+ if (encrypt)
+ beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
+
+
+ beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
+ beacon_buf->info_element[0].id = MFIE_TYPE_SSID;
+ beacon_buf->info_element[0].len = ssid_len;
+
+ tag = (u8*) beacon_buf->info_element[0].data;
+
+ memcpy(tag, ssid, ssid_len);
+
+ tag += ssid_len;
+
+ *(tag++) = MFIE_TYPE_RATES;
+ *(tag++) = rate_len-2;
+ memcpy(tag,ieee->current_network.rates,rate_len-2);
+ tag+=rate_len-2;
+
+ *(tag++) = MFIE_TYPE_DS_SET;
+ *(tag++) = 1;
+ *(tag++) = ieee->current_network.channel;
+
+ if(atim_len){
+ u16 val16;
+ *(tag++) = MFIE_TYPE_IBSS_SET;
+ *(tag++) = 2;
+ //*((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
+ val16 = cpu_to_le16(ieee->current_network.atim_window);
+ memcpy((u8 *)tag, (u8 *)&val16, 2);
+ tag+=2;
+ }
+
+ if(erp_len){
+ *(tag++) = MFIE_TYPE_ERP;
+ *(tag++) = 1;
+ *(tag++) = erpinfo_content;
+ }
+#if 0
+ //Include High Throuput capability
+
+ *(tag++) = MFIE_TYPE_HT_CAP;
+ *(tag++) = tmp_ht_cap_len - 2;
+ memcpy(tag, tmp_ht_cap_buf, tmp_ht_cap_len - 2);
+ tag += tmp_ht_cap_len - 2;
+#endif
+ if(rate_ex_len){
+ *(tag++) = MFIE_TYPE_RATES_EX;
+ *(tag++) = rate_ex_len-2;
+ memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
+ tag+=rate_ex_len-2;
+ }
+
+#if 0
+ //Include High Throuput info
+
+ *(tag++) = MFIE_TYPE_HT_INFO;
+ *(tag++) = tmp_ht_info_len - 2;
+ memcpy(tag, tmp_ht_info_buf, tmp_ht_info_len -2);
+ tag += tmp_ht_info_len - 2;
+#endif
+ if (wpa_ie_len)
+ {
+ if (ieee->iw_mode == IW_MODE_ADHOC)
+ {//as Windows will set pairwise key same as the group key which is not allowed in Linux, so set this for IOT issue. WB 2008.07.07
+ memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4);
+ }
+ memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
+ tag += wpa_ie_len;
+ }
+
+#if 0
+ //
+ // Construct Realtek Proprietary Aggregation mode (Set AMPDU Factor to 2, 32k)
+ //
+ if(pHTInfo->bRegRT2RTAggregation)
+ {
+ (*tag++) = 0xdd;
+ (*tag++) = tmp_generic_ie_len - 2;
+ memcpy(tag,tmp_generic_ie_buf,tmp_generic_ie_len -2);
+ tag += tmp_generic_ie_len -2;
+
+ }
+#endif
+#if 0
+ if(ieee->qos_support)
+ {
+ (*tag++) = 0xdd;
+ (*tag++) = wmm_len;
+ memcpy(tag,QosOui,wmm_len);
+ tag += wmm_len;
+ }
+#endif
+ //skb->dev = ieee->dev;
+ return skb;
+}
+
+
+struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
+{
+ struct sk_buff *skb;
+ u8* tag;
+
+ struct ieee80211_crypt_data* crypt;
+ struct ieee80211_assoc_response_frame *assoc;
+ short encrypt;
+
+ unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
+ int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len + ieee->tx_headroom;
+
+ skb = dev_alloc_skb(len);
+
+ if (!skb)
+ return NULL;
+
+ skb_reserve(skb, ieee->tx_headroom);
+
+ assoc = (struct ieee80211_assoc_response_frame *)
+ skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
+
+ assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
+ memcpy(assoc->header.addr1, dest,ETH_ALEN);
+ memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
+ WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
+
+
+ if(ieee->short_slot)
+ assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
+
+ if (ieee->host_encrypt)
+ crypt = ieee->crypt[ieee->tx_keyidx];
+ else crypt = NULL;
+
+ encrypt = ( crypt && crypt->ops);
+
+ if (encrypt)
+ assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
+
+ assoc->status = 0;
+ assoc->aid = cpu_to_le16(ieee->assoc_id);
+ if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
+ else ieee->assoc_id++;
+
+ tag = (u8*) skb_put(skb, rate_len);
+
+ ieee80211_MFIE_Brate(ieee, &tag);
+ ieee80211_MFIE_Grate(ieee, &tag);
+
+ return skb;
+}
+
+struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
+{
+ struct sk_buff *skb;
+ struct ieee80211_authentication *auth;
+ int len = ieee->tx_headroom + sizeof(struct ieee80211_authentication)+1;
+
+ skb = dev_alloc_skb(len);
+
+ if (!skb)
+ return NULL;
+
+ skb->len = sizeof(struct ieee80211_authentication);
+
+ auth = (struct ieee80211_authentication *)skb->data;
+
+ auth->status = cpu_to_le16(status);
+ auth->transaction = cpu_to_le16(2);
+ auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
+
+ memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(auth->header.addr1, dest, ETH_ALEN);
+ auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
+ return skb;
+
+
+}
+
+struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
+{
+ struct sk_buff *skb;
+ struct ieee80211_hdr_3addr* hdr;
+
+ skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
+
+ if (!skb)
+ return NULL;
+
+ hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
+
+ memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
+ memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
+
+ hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
+ IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
+ (pwr ? IEEE80211_FCTL_PM:0));
+
+ return skb;
+
+
+}
+
+
+void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
+{
+ struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
+
+ if (buf)
+ softmac_mgmt_xmit(buf, ieee);
+}
+
+
+void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
+{
+ struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
+
+ if (buf)
+ softmac_mgmt_xmit(buf, ieee);
+}
+
+
+void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
+{
+
+
+ struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
+ if (buf)
+ softmac_mgmt_xmit(buf, ieee);
+}
+
+
+inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
+{
+ struct sk_buff *skb;
+ //unsigned long flags;
+
+ struct ieee80211_assoc_request_frame *hdr;
+ u8 *tag;//,*rsn_ie;
+ //short info_addr = 0;
+ //int i;
+ //u16 suite_count = 0;
+ //u8 suit_select = 0;
+ //unsigned int wpa_len = beacon->wpa_ie_len;
+ //for HT
+ u8* ht_cap_buf = NULL;
+ u8 ht_cap_len=0;
+ u8* realtek_ie_buf=NULL;
+ u8 realtek_ie_len=0;
+ int wpa_ie_len= ieee->wpa_ie_len;
+ unsigned int ckip_ie_len=0;
+ unsigned int ccxrm_ie_len=0;
+ unsigned int cxvernum_ie_len=0;
+ struct ieee80211_crypt_data* crypt;
+ int encrypt;
+
+ unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
+ unsigned int wmm_info_len = beacon->qos_data.supported?9:0;
+#ifdef THOMAS_TURBO
+ unsigned int turbo_info_len = beacon->Turbo_Enable?9:0;
+#endif
+
+ int len = 0;
+
+ crypt = ieee->crypt[ieee->tx_keyidx];
+ encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len));
+
+ //Include High Throuput capability && Realtek proprietary
+ if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT)
+ {
+ ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap);
+ ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
+ HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt);
+ if(ieee->pHTInfo->bCurrentRT2RTAggregation)
+ {
+ realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
+ realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer);
+ HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len);
+
+ }
+ }
+ if(ieee->qos_support){
+ wmm_info_len = beacon->qos_data.supported?9:0;
+ }
+
+
+ if(beacon->bCkipSupported)
+ {
+ ckip_ie_len = 30+2;
+ }
+ if(beacon->bCcxRmEnable)
+ {
+ ccxrm_ie_len = 6+2;
+ }
+ if( beacon->BssCcxVerNumber >= 2 )
+ {
+ cxvernum_ie_len = 5+2;
+ }
+#ifdef THOMAS_TURBO
+ len = sizeof(struct ieee80211_assoc_request_frame)+ 2
+ + beacon->ssid_len//essid tagged val
+ + rate_len//rates tagged val
+ + wpa_ie_len
+ + wmm_info_len
+ + turbo_info_len
+ + ht_cap_len
+ + realtek_ie_len
+ + ckip_ie_len
+ + ccxrm_ie_len
+ + cxvernum_ie_len
+ + ieee->tx_headroom;
+#else
+ len = sizeof(struct ieee80211_assoc_request_frame)+ 2
+ + beacon->ssid_len//essid tagged val
+ + rate_len//rates tagged val
+ + wpa_ie_len
+ + wmm_info_len
+ + ht_cap_len
+ + realtek_ie_len
+ + ckip_ie_len
+ + ccxrm_ie_len
+ + cxvernum_ie_len
+ + ieee->tx_headroom;
+#endif
+
+ skb = dev_alloc_skb(len);
+
+ if (!skb)
+ return NULL;
+
+ skb_reserve(skb, ieee->tx_headroom);
+
+ hdr = (struct ieee80211_assoc_request_frame *)
+ skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)+2);
+
+
+ hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ;
+ hdr->header.duration_id= 37; //FIXME
+ memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
+ memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
+
+ memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);//for HW security, John
+
+ hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
+ if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
+ hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
+
+ if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
+ hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); //add short_preamble here
+
+ if(ieee->short_slot)
+ hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
+ if (wmm_info_len) //QOS
+ hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS);
+
+ hdr->listen_interval = 0xa; //FIXME
+
+ hdr->info_element[0].id = MFIE_TYPE_SSID;
+
+ hdr->info_element[0].len = beacon->ssid_len;
+ tag = skb_put(skb, beacon->ssid_len);
+ memcpy(tag, beacon->ssid, beacon->ssid_len);
+
+ tag = skb_put(skb, rate_len);
+
+ ieee80211_MFIE_Brate(ieee, &tag);
+ ieee80211_MFIE_Grate(ieee, &tag);
+ // For CCX 1 S13, CKIP. Added by Annie, 2006-08-14.
+ if( beacon->bCkipSupported )
+ {
+ static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; // "4500-client"
+ u8 CcxAironetBuf[30];
+ OCTET_STRING osCcxAironetIE;
+
+ memset(CcxAironetBuf, 0,30);
+ osCcxAironetIE.Octet = CcxAironetBuf;
+ osCcxAironetIE.Length = sizeof(CcxAironetBuf);
+ //
+ // Ref. CCX test plan v3.61, 3.2.3.1 step 13.
+ // We want to make the device type as "4500-client". 060926, by CCW.
+ //
+ memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui));
+
+ // CCX1 spec V1.13, A01.1 CKIP Negotiation (page23):
+ // "The CKIP negotiation is started with the associate request from the client to the access point,
+ // containing an Aironet element with both the MIC and KP bits set."
+ osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ;
+ tag = skb_put(skb, ckip_ie_len);
+ *tag++ = MFIE_TYPE_AIRONET;
+ *tag++ = osCcxAironetIE.Length;
+ memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length);
+ tag += osCcxAironetIE.Length;
+ }
+
+ if(beacon->bCcxRmEnable)
+ {
+ static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
+ OCTET_STRING osCcxRmCap;
+
+ osCcxRmCap.Octet = CcxRmCapBuf;
+ osCcxRmCap.Length = sizeof(CcxRmCapBuf);
+ tag = skb_put(skb,ccxrm_ie_len);
+ *tag++ = MFIE_TYPE_GENERIC;
+ *tag++ = osCcxRmCap.Length;
+ memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length);
+ tag += osCcxRmCap.Length;
+ }
+
+ if( beacon->BssCcxVerNumber >= 2 )
+ {
+ u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
+ OCTET_STRING osCcxVerNum;
+ CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
+ osCcxVerNum.Octet = CcxVerNumBuf;
+ osCcxVerNum.Length = sizeof(CcxVerNumBuf);
+ tag = skb_put(skb,cxvernum_ie_len);
+ *tag++ = MFIE_TYPE_GENERIC;
+ *tag++ = osCcxVerNum.Length;
+ memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length);
+ tag += osCcxVerNum.Length;
+ }
+ //HT cap element
+ if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
+ if(ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC)
+ {
+ tag = skb_put(skb, ht_cap_len);
+ *tag++ = MFIE_TYPE_HT_CAP;
+ *tag++ = ht_cap_len - 2;
+ memcpy(tag, ht_cap_buf,ht_cap_len -2);
+ tag += ht_cap_len -2;
+ }
+ }
+
+
+ //choose what wpa_supplicant gives to associate.
+ tag = skb_put(skb, wpa_ie_len);
+ if (wpa_ie_len){
+ memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
+ }
+
+ tag = skb_put(skb,wmm_info_len);
+ if(wmm_info_len) {
+ ieee80211_WMM_Info(ieee, &tag);
+ }
+#ifdef THOMAS_TURBO
+ tag = skb_put(skb,turbo_info_len);
+ if(turbo_info_len) {
+ ieee80211_TURBO_Info(ieee, &tag);
+ }
+#endif
+
+ if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
+ if(ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC)
+ {
+ tag = skb_put(skb, ht_cap_len);
+ *tag++ = MFIE_TYPE_GENERIC;
+ *tag++ = ht_cap_len - 2;
+ memcpy(tag, ht_cap_buf,ht_cap_len - 2);
+ tag += ht_cap_len -2;
+ }
+
+ if(ieee->pHTInfo->bCurrentRT2RTAggregation){
+ tag = skb_put(skb, realtek_ie_len);
+ *tag++ = MFIE_TYPE_GENERIC;
+ *tag++ = realtek_ie_len - 2;
+ memcpy(tag, realtek_ie_buf,realtek_ie_len -2 );
+ }
+ }
+// printk("<=====%s(), %p, %p\n", __FUNCTION__, ieee->dev, ieee->dev->dev_addr);
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
+ return skb;
+}
+
+void ieee80211_associate_abort(struct ieee80211_device *ieee)
+{
+
+ unsigned long flags;
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ ieee->associate_seq++;
+
+ /* don't scan, and avoid to have the RX path possibily
+ * try again to associate. Even do not react to AUTH or
+ * ASSOC response. Just wait for the retry wq to be scheduled.
+ * Here we will check if there are good nets to associate
+ * with, so we retry or just get back to NO_LINK and scanning
+ */
+ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
+ IEEE80211_DEBUG_MGMT("Authentication failed\n");
+ ieee->softmac_stats.no_auth_rs++;
+ }else{
+ IEEE80211_DEBUG_MGMT("Association failed\n");
+ ieee->softmac_stats.no_ass_rs++;
+ }
+
+ ieee->state = IEEE80211_ASSOCIATING_RETRY;
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, \
+ IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
+#else
+ schedule_task(&ieee->associate_retry_wq);
+#endif
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+}
+
+void ieee80211_associate_abort_cb(unsigned long dev)
+{
+ ieee80211_associate_abort((struct ieee80211_device *) dev);
+}
+
+
+void ieee80211_associate_step1(struct ieee80211_device *ieee)
+{
+ struct ieee80211_network *beacon = &ieee->current_network;
+ struct sk_buff *skb;
+
+ IEEE80211_DEBUG_MGMT("Stopping scan\n");
+
+ ieee->softmac_stats.tx_auth_rq++;
+ skb=ieee80211_authentication_req(beacon, ieee, 0);
+
+ if (!skb)
+ ieee80211_associate_abort(ieee);
+ else{
+ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
+ IEEE80211_DEBUG_MGMT("Sending authentication request\n");
+ //printk(KERN_WARNING "Sending authentication request\n");
+ softmac_mgmt_xmit(skb, ieee);
+ //BUGON when you try to add_timer twice, using mod_timer may be better, john0709
+ if(!timer_pending(&ieee->associate_timer)){
+ ieee->associate_timer.expires = jiffies + (HZ / 2);
+ add_timer(&ieee->associate_timer);
+ }
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+}
+
+void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
+{
+ u8 *c;
+ struct sk_buff *skb;
+ struct ieee80211_network *beacon = &ieee->current_network;
+// int hlen = sizeof(struct ieee80211_authentication);
+
+ ieee->associate_seq++;
+ ieee->softmac_stats.tx_auth_rq++;
+
+ skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
+ if (!skb)
+ ieee80211_associate_abort(ieee);
+ else{
+ c = skb_put(skb, chlen+2);
+ *(c++) = MFIE_TYPE_CHALLENGE;
+ *(c++) = chlen;
+ memcpy(c, challenge, chlen);
+
+ IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
+
+ ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
+
+ softmac_mgmt_xmit(skb, ieee);
+ mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
+#if 0
+ ieee->associate_timer.expires = jiffies + (HZ / 2);
+ add_timer(&ieee->associate_timer);
+#endif
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+ kfree(challenge);
+}
+
+void ieee80211_associate_step2(struct ieee80211_device *ieee)
+{
+ struct sk_buff* skb;
+ struct ieee80211_network *beacon = &ieee->current_network;
+
+ del_timer_sync(&ieee->associate_timer);
+
+ IEEE80211_DEBUG_MGMT("Sending association request\n");
+
+ ieee->softmac_stats.tx_ass_rq++;
+ skb=ieee80211_association_req(beacon, ieee);
+ if (!skb)
+ ieee80211_associate_abort(ieee);
+ else{
+ softmac_mgmt_xmit(skb, ieee);
+ mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
+#if 0
+ ieee->associate_timer.expires = jiffies + (HZ / 2);
+ add_timer(&ieee->associate_timer);
+#endif
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void ieee80211_associate_complete_wq(struct work_struct *work)
+{
+ struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
+#else
+void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
+{
+#endif
+ printk(KERN_INFO "Associated successfully\n");
+ ieee->is_roaming = false;
+ if(ieee80211_is_54g(ieee->current_network) &&
+ (ieee->modulation & IEEE80211_OFDM_MODULATION)){
+
+ ieee->rate = 108;
+ printk(KERN_INFO"Using G rates:%d\n", ieee->rate);
+ }else{
+ ieee->rate = 22;
+ printk(KERN_INFO"Using B rates:%d\n", ieee->rate);
+ }
+ if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT)
+ {
+ printk("Successfully associated, ht enabled\n");
+ HTOnAssocRsp(ieee);
+ }
+ else
+ {
+ printk("Successfully associated, ht not enabled(%d, %d)\n", ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT);
+ memset(ieee->dot11HTOperationalRateSet, 0, 16);
+ //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ }
+ ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500);
+ // To prevent the immediately calling watch_dog after association.
+ if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
+ {
+ ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
+ ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
+ }
+ ieee->link_change(ieee->dev);
+ if(ieee->is_silent_reset == 0){
+ printk("============>normal associate\n");
+ notify_wx_assoc_event(ieee);
+ }
+ else if(ieee->is_silent_reset == 1)
+ {
+ printk("==================>silent reset associate\n");
+ ieee->is_silent_reset = 0;
+ }
+
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+ netif_carrier_on(ieee->dev);
+}
+
+void ieee80211_associate_complete(struct ieee80211_device *ieee)
+{
+// int i;
+// struct net_device* dev = ieee->dev;
+ del_timer_sync(&ieee->associate_timer);
+
+#if 0
+ for(i = 0; i < 6; i++) {
+ ieee->seq_ctrl[i] = 0;
+ }
+#endif
+ ieee->state = IEEE80211_LINKED;
+#if 0
+ if (ieee->pHTInfo->bCurrentHTSupport)
+ {
+ printk("Successfully associated, ht enabled\n");
+ queue_work(ieee->wq, &ieee->ht_onAssRsp);
+ }
+ else
+ {
+ printk("Successfully associated, ht not enabled\n");
+ memset(ieee->dot11HTOperationalRateSet, 0, 16);
+ HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ }
+#endif
+ //ieee->UpdateHalRATRTableHandler(dev, ieee->dot11HTOperationalRateSet);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(ieee->wq, &ieee->associate_complete_wq);
+#else
+ schedule_task(&ieee->associate_complete_wq);
+#endif
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void ieee80211_associate_procedure_wq(struct work_struct *work)
+{
+ struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
+#else
+void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
+{
+#endif
+ ieee->sync_scan_hurryup = 1;
+ down(&ieee->wx_sem);
+
+ if (ieee->data_hard_stop)
+ ieee->data_hard_stop(ieee->dev);
+
+ ieee80211_stop_scan(ieee);
+ printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel);
+ //ieee->set_chan(ieee->dev, ieee->current_network.channel);
+ HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+
+ ieee->associate_seq = 1;
+ ieee80211_associate_step1(ieee);
+
+ up(&ieee->wx_sem);
+}
+
+inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
+{
+ u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
+ int tmp_ssid_len = 0;
+
+ short apset,ssidset,ssidbroad,apmatch,ssidmatch;
+
+ /* we are interested in new new only if we are not associated
+ * and we are not associating / authenticating
+ */
+ if (ieee->state != IEEE80211_NOLINK)
+ return;
+
+ if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
+ return;
+
+ if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
+ return;
+
+
+ if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
+ /* if the user specified the AP MAC, we need also the essid
+ * This could be obtained by beacons or, if the network does not
+ * broadcast it, it can be put manually.
+ */
+ apset = ieee->wap_set;//(memcmp(ieee->current_network.bssid, zero,ETH_ALEN)!=0 );
+ ssidset = ieee->ssid_set;//ieee->current_network.ssid[0] != '\0';
+ ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
+ apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
+ ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\
+ (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
+
+
+ if ( /* if the user set the AP check if match.
+ * if the network does not broadcast essid we check the user supplyed ANY essid
+ * if the network does broadcast and the user does not set essid it is OK
+ * if the network does broadcast and the user did set essid chech if essid match
+ */
+ ( apset && apmatch &&
+ ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
+ /* if the ap is not set, check that the user set the bssid
+ * and the network does bradcast and that those two bssid matches
+ */
+ (!apset && ssidset && ssidbroad && ssidmatch)
+ ){
+ /* if the essid is hidden replace it with the
+ * essid provided by the user.
+ */
+ if (!ssidbroad){
+ strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE);
+ tmp_ssid_len = ieee->current_network.ssid_len;
+ }
+ memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
+
+ if (!ssidbroad){
+ strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
+ ieee->current_network.ssid_len = tmp_ssid_len;
+ }
+ printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode);
+
+ //ieee->pHTInfo->IOTAction = 0;
+ HTResetIOTSetting(ieee->pHTInfo);
+ if (ieee->iw_mode == IW_MODE_INFRA){
+ /* Join the network for the first time */
+ ieee->AsocRetryCount = 0;
+ //for HT by amy 080514
+ if((ieee->current_network.qos_data.supported == 1) &&
+ // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT))
+ ieee->current_network.bssht.bdSupportHT)
+/*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/
+ {
+ // ieee->pHTInfo->bCurrentHTSupport = true;
+ HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network));
+ }
+ else
+ {
+ ieee->pHTInfo->bCurrentHTSupport = false;
+ }
+
+ ieee->state = IEEE80211_ASSOCIATING;
+ if(ieee->LedControlHandler != NULL)
+ ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(ieee->wq, &ieee->associate_procedure_wq);
+#else
+ schedule_task(&ieee->associate_procedure_wq);
+#endif
+ }else{
+ if(ieee80211_is_54g(ieee->current_network) &&
+ (ieee->modulation & IEEE80211_OFDM_MODULATION)){
+ ieee->rate = 108;
+ ieee->SetWirelessMode(ieee->dev, IEEE_G);
+ printk(KERN_INFO"Using G rates\n");
+ }else{
+ ieee->rate = 22;
+ ieee->SetWirelessMode(ieee->dev, IEEE_B);
+ printk(KERN_INFO"Using B rates\n");
+ }
+ memset(ieee->dot11HTOperationalRateSet, 0, 16);
+ //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ ieee->state = IEEE80211_LINKED;
+ }
+
+ }
+ }
+
+}
+
+void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
+{
+ unsigned long flags;
+ struct ieee80211_network *target;
+
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ list_for_each_entry(target, &ieee->network_list, list) {
+
+ /* if the state become different that NOLINK means
+ * we had found what we are searching for
+ */
+
+ if (ieee->state != IEEE80211_NOLINK)
+ break;
+
+ if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
+ ieee80211_softmac_new_net(ieee, target);
+ }
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+}
+
+
+static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
+{
+ struct ieee80211_authentication *a;
+ u8 *t;
+ if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
+ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
+ return 0xcafe;
+ }
+ *challenge = NULL;
+ a = (struct ieee80211_authentication*) skb->data;
+ if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
+ t = skb->data + sizeof(struct ieee80211_authentication);
+
+ if(*(t++) == MFIE_TYPE_CHALLENGE){
+ *chlen = *(t++);
+ *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
+ memcpy(*challenge, t, *chlen);
+ }
+ }
+
+ return cpu_to_le16(a->status);
+
+}
+
+
+int auth_rq_parse(struct sk_buff *skb,u8* dest)
+{
+ struct ieee80211_authentication *a;
+
+ if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
+ IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
+ return -1;
+ }
+ a = (struct ieee80211_authentication*) skb->data;
+
+ memcpy(dest,a->header.addr2, ETH_ALEN);
+
+ if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
+ return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
+
+ return WLAN_STATUS_SUCCESS;
+}
+
+static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
+{
+ u8 *tag;
+ u8 *skbend;
+ u8 *ssid=NULL;
+ u8 ssidlen = 0;
+
+ struct ieee80211_hdr_3addr *header =
+ (struct ieee80211_hdr_3addr *) skb->data;
+
+ if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
+ return -1; /* corrupted */
+
+ memcpy(src,header->addr2, ETH_ALEN);
+
+ skbend = (u8*)skb->data + skb->len;
+
+ tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
+
+ while (tag+1 < skbend){
+ if (*tag == 0){
+ ssid = tag+2;
+ ssidlen = *(tag+1);
+ break;
+ }
+ tag++; /* point to the len field */
+ tag = tag + *(tag); /* point to the last data byte of the tag */
+ tag++; /* point to the next tag */
+ }
+
+ //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
+ if (ssidlen == 0) return 1;
+
+ if (!ssid) return 1; /* ssid not found in tagged param */
+ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
+
+}
+
+int assoc_rq_parse(struct sk_buff *skb,u8* dest)
+{
+ struct ieee80211_assoc_request_frame *a;
+
+ if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
+ sizeof(struct ieee80211_info_element))) {
+
+ IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
+ return -1;
+ }
+
+ a = (struct ieee80211_assoc_request_frame*) skb->data;
+
+ memcpy(dest,a->header.addr2,ETH_ALEN);
+
+ return 0;
+}
+
+static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb, int *aid)
+{
+ struct ieee80211_assoc_response_frame *response_head;
+ u16 status_code;
+
+ if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
+ IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
+ return 0xcafe;
+ }
+
+ response_head = (struct ieee80211_assoc_response_frame*) skb->data;
+ *aid = le16_to_cpu(response_head->aid) & 0x3fff;
+
+ status_code = le16_to_cpu(response_head->status);
+ if((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \
+ status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&&
+ ((ieee->mode == IEEE_G) &&
+ (ieee->current_network.mode == IEEE_N_24G) &&
+ (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) {
+ ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE;
+ }else {
+ ieee->AsocRetryCount = 0;
+ }
+
+ return le16_to_cpu(response_head->status);
+}
+
+static inline void
+ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
+{
+ u8 dest[ETH_ALEN];
+
+ //IEEE80211DMESG("Rx probe");
+ ieee->softmac_stats.rx_probe_rq++;
+ //DMESG("Dest is "MACSTR, MAC2STR(dest));
+ if (probe_rq_parse(ieee, skb, dest)){
+ //IEEE80211DMESG("Was for me!");
+ ieee->softmac_stats.tx_probe_rs++;
+ ieee80211_resp_to_probe(ieee, dest);
+ }
+}
+
+static inline void
+ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
+{
+ u8 dest[ETH_ALEN];
+ int status;
+ //IEEE80211DMESG("Rx probe");
+ ieee->softmac_stats.rx_auth_rq++;
+
+ if ((status = auth_rq_parse(skb, dest))!= -1){
+ ieee80211_resp_to_auth(ieee, status, dest);
+ }
+ //DMESG("Dest is "MACSTR, MAC2STR(dest));
+
+}
+
+static inline void
+ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
+{
+
+ u8 dest[ETH_ALEN];
+ //unsigned long flags;
+
+ ieee->softmac_stats.rx_ass_rq++;
+ if (assoc_rq_parse(skb,dest) != -1){
+ ieee80211_resp_to_assoc_rq(ieee, dest);
+ }
+
+ printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
+ //FIXME
+ #if 0
+ spin_lock_irqsave(&ieee->lock,flags);
+ add_associate(ieee,dest);
+ spin_unlock_irqrestore(&ieee->lock,flags);
+ #endif
+}
+
+
+
+void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
+{
+
+ struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
+
+ if (buf)
+ softmac_ps_mgmt_xmit(buf, ieee);
+
+}
+
+
+short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
+{
+ int timeout = ieee->ps_timeout;
+ u8 dtim;
+ /*if(ieee->ps == IEEE80211_PS_DISABLED ||
+ ieee->iw_mode != IW_MODE_INFRA ||
+ ieee->state != IEEE80211_LINKED)
+
+ return 0;
+ */
+ dtim = ieee->current_network.dtim_data;
+ //printk("DTIM\n");
+ if(!(dtim & IEEE80211_DTIM_VALID))
+ return 0;
+ timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval
+ //printk("VALID\n");
+ ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
+
+ if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
+ return 2;
+
+ if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
+ return 0;
+
+ if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
+ return 0;
+
+ if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
+ (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
+ return 0;
+
+ if(time_l){
+ *time_l = ieee->current_network.last_dtim_sta_time[0]
+ + (ieee->current_network.beacon_interval);
+ // * ieee->current_network.dtim_period) * 1000;
+ }
+
+ if(time_h){
+ *time_h = ieee->current_network.last_dtim_sta_time[1];
+ if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
+ *time_h += 1;
+ }
+
+ return 1;
+
+
+}
+
+inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
+{
+
+ u32 th,tl;
+ short sleep;
+
+ unsigned long flags,flags2;
+
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if((ieee->ps == IEEE80211_PS_DISABLED ||
+ ieee->iw_mode != IW_MODE_INFRA ||
+ ieee->state != IEEE80211_LINKED)){
+
+ // #warning CHECK_LOCK_HERE
+ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
+
+ ieee80211_sta_wakeup(ieee, 1);
+
+ spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
+ }
+
+ sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
+ /* 2 wake, 1 sleep, 0 do nothing */
+ if(sleep == 0)
+ goto out;
+
+ if(sleep == 1){
+
+ if(ieee->sta_sleep == 1)
+ ieee->enter_sleep_state(ieee->dev,th,tl);
+
+ else if(ieee->sta_sleep == 0){
+ // printk("send null 1\n");
+ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
+
+ if(ieee->ps_is_queue_empty(ieee->dev)){
+
+
+ ieee->sta_sleep = 2;
+
+ ieee->ack_tx_to_ieee = 1;
+
+ ieee80211_sta_ps_send_null_frame(ieee,1);
+
+ ieee->ps_th = th;
+ ieee->ps_tl = tl;
+ }
+ spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
+
+ }
+
+
+ }else if(sleep == 2){
+//#warning CHECK_LOCK_HERE
+ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
+
+ ieee80211_sta_wakeup(ieee,1);
+
+ spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
+ }
+
+out:
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+}
+
+void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
+{
+ if(ieee->sta_sleep == 0){
+ if(nl){
+ printk("Warning: driver is probably failing to report TX ps error\n");
+ ieee->ack_tx_to_ieee = 1;
+ ieee80211_sta_ps_send_null_frame(ieee, 0);
+ }
+ return;
+
+ }
+
+ if(ieee->sta_sleep == 1)
+ ieee->sta_wake_up(ieee->dev);
+
+ ieee->sta_sleep = 0;
+
+ if(nl){
+ ieee->ack_tx_to_ieee = 1;
+ ieee80211_sta_ps_send_null_frame(ieee, 0);
+ }
+}
+
+void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
+{
+ unsigned long flags,flags2;
+
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if(ieee->sta_sleep == 2){
+ /* Null frame with PS bit set */
+ if(success){
+ ieee->sta_sleep = 1;
+ ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl);
+ }
+ /* if the card report not success we can't be sure the AP
+ * has not RXed so we can't assume the AP believe us awake
+ */
+ }
+ /* 21112005 - tx again null without PS bit if lost */
+ else {
+
+ if((ieee->sta_sleep == 0) && !success){
+ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
+ ieee80211_sta_ps_send_null_frame(ieee, 0);
+ spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
+ }
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+}
+void ieee80211_process_action(struct ieee80211_device* ieee, struct sk_buff* skb)
+{
+ struct ieee80211_hdr* header = (struct ieee80211_hdr*)skb->data;
+ u8* act = ieee80211_get_payload(header);
+ u8 tmp = 0;
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
+ if (act == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n");
+ return;
+ }
+ tmp = *act;
+ act ++;
+ switch (tmp)
+ {
+ case ACT_CAT_BA:
+ if (*act == ACT_ADDBAREQ)
+ ieee80211_rx_ADDBAReq(ieee, skb);
+ else if (*act == ACT_ADDBARSP)
+ ieee80211_rx_ADDBARsp(ieee, skb);
+ else if (*act == ACT_DELBA)
+ ieee80211_rx_DELBA(ieee, skb);
+ break;
+ default:
+// if (net_ratelimit())
+// IEEE80211_DEBUG(IEEE80211_DL_BA, "unknown action frame(%d)\n", tmp);
+ break;
+ }
+ return;
+
+}
+inline int
+ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
+ struct ieee80211_rx_stats *rx_stats, u16 type,
+ u16 stype)
+{
+ struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data;
+ u16 errcode;
+ u8* challenge;
+ int chlen=0;
+ int aid;
+ struct ieee80211_assoc_response_frame *assoc_resp;
+// struct ieee80211_info_element *info_element;
+ bool bSupportNmode = true, bHalfSupportNmode = false; //default support N mode, disable halfNmode
+
+ if(!ieee->proto_started)
+ return 0;
+#if 0
+ printk("%d, %d, %d, %d\n", ieee->sta_sleep, ieee->ps, ieee->iw_mode, ieee->state);
+ if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
+ ieee->iw_mode == IW_MODE_INFRA &&
+ ieee->state == IEEE80211_LINKED))
+
+ tasklet_schedule(&ieee->ps_task);
+
+ if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
+ WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
+ ieee->last_rx_ps_time = jiffies;
+#endif
+
+ switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
+
+ case IEEE80211_STYPE_ASSOC_RESP:
+ case IEEE80211_STYPE_REASSOC_RESP:
+
+ IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
+ WLAN_FC_GET_STYPE(header->frame_ctl));
+ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
+ ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
+ ieee->iw_mode == IW_MODE_INFRA){
+ struct ieee80211_network network_resp;
+ struct ieee80211_network *network = &network_resp;
+
+ if (0 == (errcode=assoc_parse(ieee,skb, &aid))){
+ ieee->state=IEEE80211_LINKED;
+ ieee->assoc_id = aid;
+ ieee->softmac_stats.rx_ass_ok++;
+ /* station support qos */
+ /* Let the register setting defaultly with Legacy station */
+ if(ieee->qos_support) {
+ assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data;
+ memset(network, 0, sizeof(*network));
+ if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\
+ rx_stats->len - sizeof(*assoc_resp),\
+ network,rx_stats)){
+ return 1;
+ }
+ else
+ { //filling the PeerHTCap. //maybe not neccesary as we can get its info from current_network.
+ memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen);
+ memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen);
+ }
+ if (ieee->handle_assoc_response != NULL)
+ ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network);
+ }
+ ieee80211_associate_complete(ieee);
+ } else {
+ /* aid could not been allocated */
+ ieee->softmac_stats.rx_ass_err++;
+ printk(
+ "Association response status code 0x%x\n",
+ errcode);
+ IEEE80211_DEBUG_MGMT(
+ "Association response status code 0x%x\n",
+ errcode);
+ if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(ieee->wq, &ieee->associate_procedure_wq);
+#else
+ schedule_task(&ieee->associate_procedure_wq);
+#endif
+ } else {
+ ieee80211_associate_abort(ieee);
+ }
+ }
+ }
+ break;
+
+ case IEEE80211_STYPE_ASSOC_REQ:
+ case IEEE80211_STYPE_REASSOC_REQ:
+
+ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
+ ieee->iw_mode == IW_MODE_MASTER)
+
+ ieee80211_rx_assoc_rq(ieee, skb);
+ break;
+
+ case IEEE80211_STYPE_AUTH:
+
+ if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
+ if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
+ ieee->iw_mode == IW_MODE_INFRA){
+
+ IEEE80211_DEBUG_MGMT("Received authentication response");
+
+ if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
+ if(ieee->open_wep || !challenge){
+ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
+ ieee->softmac_stats.rx_auth_rs_ok++;
+ if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE))
+ {
+ if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
+ {
+ // WEP or TKIP encryption
+ if(IsHTHalfNmodeAPs(ieee))
+ {
+ bSupportNmode = true;
+ bHalfSupportNmode = true;
+ }
+ else
+ {
+ bSupportNmode = false;
+ bHalfSupportNmode = false;
+ }
+ printk("==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode);
+ }
+ }
+ /* Dummy wirless mode setting to avoid encryption issue */
+ if(bSupportNmode) {
+ //N mode setting
+ ieee->SetWirelessMode(ieee->dev, \
+ ieee->current_network.mode);
+ }else{
+ //b/g mode setting
+ /*TODO*/
+ ieee->SetWirelessMode(ieee->dev, IEEE_G);
+ }
+
+ if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true)
+ {
+ printk("===============>entern half N mode\n");
+ ieee->bHalfWirelessN24GMode = true;
+ }
+ else
+ ieee->bHalfWirelessN24GMode = false;
+
+ ieee80211_associate_step2(ieee);
+ }else{
+ ieee80211_auth_challenge(ieee, challenge, chlen);
+ }
+ }else{
+ ieee->softmac_stats.rx_auth_rs_err++;
+ IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
+
+ printk("Authentication respose status code 0x%x",errcode);
+ ieee80211_associate_abort(ieee);
+ }
+
+ }else if (ieee->iw_mode == IW_MODE_MASTER){
+ ieee80211_rx_auth_rq(ieee, skb);
+ }
+ }
+ break;
+
+ case IEEE80211_STYPE_PROBE_REQ:
+
+ if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
+ ((ieee->iw_mode == IW_MODE_ADHOC ||
+ ieee->iw_mode == IW_MODE_MASTER) &&
+ ieee->state == IEEE80211_LINKED)){
+ ieee80211_rx_probe_rq(ieee, skb);
+ }
+ break;
+
+ case IEEE80211_STYPE_DISASSOC:
+ case IEEE80211_STYPE_DEAUTH:
+ /* FIXME for now repeat all the association procedure
+ * both for disassociation and deauthentication
+ */
+ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
+ ieee->state == IEEE80211_LINKED &&
+ ieee->iw_mode == IW_MODE_INFRA){
+ printk("==========>received disassoc/deauth(%x) frame, reason code:%x\n",WLAN_FC_GET_STYPE(header->frame_ctl), ((struct ieee80211_disassoc*)skb->data)->reason);
+ ieee->state = IEEE80211_ASSOCIATING;
+ ieee->softmac_stats.reassoc++;
+ ieee->is_roaming = true;
+ ieee80211_disassociate(ieee);
+ // notify_wx_assoc_event(ieee);
+ //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ RemovePeerTS(ieee, header->addr2);
+ if(ieee->LedControlHandler != NULL)
+ ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); //added by amy for LED 090318
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(ieee->wq, &ieee->associate_procedure_wq);
+#else
+ schedule_task(&ieee->associate_procedure_wq);
+#endif
+ }
+ break;
+ case IEEE80211_STYPE_MANAGE_ACT:
+ ieee80211_process_action(ieee,skb);
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ //dev_kfree_skb_any(skb);
+ return 0;
+}
+
+/* following are for a simplier TX queue management.
+ * Instead of using netif_[stop/wake]_queue the driver
+ * will uses these two function (plus a reset one), that
+ * will internally uses the kernel netif_* and takes
+ * care of the ieee802.11 fragmentation.
+ * So the driver receives a fragment per time and might
+ * call the stop function when it want without take care
+ * to have enought room to TX an entire packet.
+ * This might be useful if each fragment need it's own
+ * descriptor, thus just keep a total free memory > than
+ * the max fragmentation treshold is not enought.. If the
+ * ieee802.11 stack passed a TXB struct then you needed
+ * to keep N free descriptors where
+ * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
+ * In this way you need just one and the 802.11 stack
+ * will take care of buffering fragments and pass them to
+ * to the driver later, when it wakes the queue.
+ */
+void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
+{
+
+ unsigned int queue_index = txb->queue_index;
+ unsigned long flags;
+ int i;
+ cb_desc *tcb_desc = NULL;
+
+ spin_lock_irqsave(&ieee->lock,flags);
+
+ /* called with 2nd parm 0, no tx mgmt lock required */
+ ieee80211_sta_wakeup(ieee,0);
+
+ /* update the tx status */
+// ieee->stats.tx_bytes += txb->payload_size;
+// ieee->stats.tx_packets++;
+ tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
+ if(tcb_desc->bMulticast) {
+ ieee->stats.multicast++;
+ }
+#if 1
+ /* if xmit available, just xmit it immediately, else just insert it to the wait queue */
+ for(i = 0; i < txb->nr_frags; i++) {
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if ((skb_queue_len(&ieee->skb_drv_aggQ[queue_index]) != 0) ||
+#else
+ if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) ||
+#endif
+ (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\
+ (ieee->queue_stop)) {
+ /* insert the skb packet to the wait queue */
+ /* as for the completion function, it does not need
+ * to check it any more.
+ * */
+ //printk("error:no descriptor left@queue_index %d, %d, %d\n", queue_index, skb_queue_len(&ieee->skb_waitQ[queue_index]), ieee->check_nic_enough_desc(ieee->dev,queue_index));
+ //ieee80211_stop_queue(ieee);
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]);
+#else
+ skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]);
+#endif
+ }else{
+ ieee->softmac_data_hard_start_xmit(
+ txb->fragments[i],
+ ieee->dev,ieee->rate);
+ //ieee->stats.tx_packets++;
+ //ieee->stats.tx_bytes += txb->fragments[i]->len;
+ //ieee->dev->trans_start = jiffies;
+ }
+ }
+#endif
+ ieee80211_txb_free(txb);
+
+//exit:
+ spin_unlock_irqrestore(&ieee->lock,flags);
+
+}
+
+/* called with ieee->lock acquired */
+void ieee80211_resume_tx(struct ieee80211_device *ieee)
+{
+ int i;
+ for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
+
+ if (ieee->queue_stop){
+ ieee->tx_pending.frag = i;
+ return;
+ }else{
+
+ ieee->softmac_data_hard_start_xmit(
+ ieee->tx_pending.txb->fragments[i],
+ ieee->dev,ieee->rate);
+ //(i+1)<ieee->tx_pending.txb->nr_frags);
+ ieee->stats.tx_packets++;
+ // ieee->dev->trans_start = jiffies;
+ }
+ }
+
+
+ ieee80211_txb_free(ieee->tx_pending.txb);
+ ieee->tx_pending.txb = NULL;
+}
+
+
+void ieee80211_reset_queue(struct ieee80211_device *ieee)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ieee->lock,flags);
+ init_mgmt_queue(ieee);
+ if (ieee->tx_pending.txb){
+ ieee80211_txb_free(ieee->tx_pending.txb);
+ ieee->tx_pending.txb = NULL;
+ }
+ ieee->queue_stop = 0;
+ spin_unlock_irqrestore(&ieee->lock,flags);
+
+}
+
+void ieee80211_wake_queue(struct ieee80211_device *ieee)
+{
+
+ unsigned long flags;
+ struct sk_buff *skb;
+ struct ieee80211_hdr_3addr *header;
+
+ spin_lock_irqsave(&ieee->lock,flags);
+ if (! ieee->queue_stop) goto exit;
+
+ ieee->queue_stop = 0;
+
+ if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
+ while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
+
+ header = (struct ieee80211_hdr_3addr *) skb->data;
+
+ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
+
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+
+ ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+ }
+ if (!ieee->queue_stop && ieee->tx_pending.txb)
+ ieee80211_resume_tx(ieee);
+
+ if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
+ ieee->softmac_stats.swtxawake++;
+ netif_wake_queue(ieee->dev);
+ }
+
+exit :
+ spin_unlock_irqrestore(&ieee->lock,flags);
+}
+
+
+void ieee80211_stop_queue(struct ieee80211_device *ieee)
+{
+ //unsigned long flags;
+ //spin_lock_irqsave(&ieee->lock,flags);
+
+ if (! netif_queue_stopped(ieee->dev)){
+ netif_stop_queue(ieee->dev);
+ ieee->softmac_stats.swtxstop++;
+ }
+ ieee->queue_stop = 1;
+ //spin_unlock_irqrestore(&ieee->lock,flags);
+
+}
+
+
+inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
+{
+
+ get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
+
+ /* an IBSS cell address must have the two less significant
+ * bits of the first byte = 2
+ */
+ ieee->current_network.bssid[0] &= ~0x01;
+ ieee->current_network.bssid[0] |= 0x02;
+}
+
+/* called in user context only */
+void ieee80211_start_master_bss(struct ieee80211_device *ieee)
+{
+ ieee->assoc_id = 1;
+
+ if (ieee->current_network.ssid_len == 0){
+ strncpy(ieee->current_network.ssid,
+ IEEE80211_DEFAULT_TX_ESSID,
+ IW_ESSID_MAX_SIZE);
+
+ ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
+ ieee->ssid_set = 1;
+ }
+
+ memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
+
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+ ieee->state = IEEE80211_LINKED;
+ ieee->link_change(ieee->dev);
+ notify_wx_assoc_event(ieee);
+
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+
+ netif_carrier_on(ieee->dev);
+}
+
+void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
+{
+ if(ieee->raw_tx){
+
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+
+ netif_carrier_on(ieee->dev);
+ }
+}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void ieee80211_start_ibss_wq(struct work_struct *work)
+{
+
+ struct delayed_work *dwork = container_of(work, struct delayed_work, work);
+ struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq);
+#else
+void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
+{
+#endif
+ /* iwconfig mode ad-hoc will schedule this and return
+ * on the other hand this will block further iwconfig SET
+ * operations because of the wx_sem hold.
+ * Anyway some most set operations set a flag to speed-up
+ * (abort) this wq (when syncro scanning) before sleeping
+ * on the semaphore
+ */
+ if(!ieee->proto_started){
+ printk("==========oh driver down return\n");
+ return;
+ }
+ down(&ieee->wx_sem);
+ //FIXME:set back to 20M whenever HT for ibss is not ready. Otherwise,after being connected to 40M AP, it will still stay in 40M when set to ibss mode. WB 2009.02.04
+ HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+
+ if (ieee->current_network.ssid_len == 0){
+ strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
+ ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
+ ieee->ssid_set = 1;
+ }
+
+ /* check if we have this cell in our network list */
+ ieee80211_softmac_check_all_nets(ieee);
+
+
+#ifdef ENABLE_DOT11D //if creating an ad-hoc, set its channel to 10 temporarily--this is the requirement for ASUS, not 11D, so disable 11d.
+// if((IS_DOT11D_ENABLE(ieee)) && (ieee->state == IEEE80211_NOLINK))
+ if (ieee->state == IEEE80211_NOLINK)
+ ieee->current_network.channel = 6;
+#endif
+ /* if not then the state is not linked. Maybe the user swithced to
+ * ad-hoc mode just after being in monitor mode, or just after
+ * being very few time in managed mode (so the card have had no
+ * time to scan all the chans..) or we have just run up the iface
+ * after setting ad-hoc mode. So we have to give another try..
+ * Here, in ibss mode, should be safe to do this without extra care
+ * (in bss mode we had to make sure no-one tryed to associate when
+ * we had just checked the ieee->state and we was going to start the
+ * scan) beacause in ibss mode the ieee80211_new_net function, when
+ * finds a good net, just set the ieee->state to IEEE80211_LINKED,
+ * so, at worst, we waste a bit of time to initiate an unneeded syncro
+ * scan, that will stop at the first round because it sees the state
+ * associated.
+ */
+ if (ieee->state == IEEE80211_NOLINK)
+ ieee80211_start_scan_syncro(ieee);
+
+ /* the network definitively is not here.. create a new cell */
+ if (ieee->state == IEEE80211_NOLINK){
+ printk("creating new IBSS cell\n");
+ if(!ieee->wap_set)
+ ieee80211_randomize_cell(ieee);
+
+ if(ieee->modulation & IEEE80211_CCK_MODULATION){
+
+ ieee->current_network.rates_len = 4;
+
+ ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
+ ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
+ ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
+ ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
+
+ }else
+ ieee->current_network.rates_len = 0;
+
+ if(ieee->modulation & IEEE80211_OFDM_MODULATION){
+ ieee->current_network.rates_ex_len = 8;
+
+ ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
+ ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
+ ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
+ ieee->current_network.rates_ex[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB;
+ ieee->current_network.rates_ex[4] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB;
+ ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
+ ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
+ ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
+
+ ieee->rate = 108;
+ }else{
+ ieee->current_network.rates_ex_len = 0;
+ ieee->rate = 22;
+ }
+
+ // By default, WMM function will be disabled in IBSS mode
+ ieee->current_network.QoS_Enable = 0;
+ ieee->SetWirelessMode(ieee->dev, IEEE_G);
+ ieee->current_network.atim_window = 0;
+ ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
+ if(ieee->short_slot)
+ ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
+
+ }
+
+ ieee->state = IEEE80211_LINKED;
+
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+ ieee->link_change(ieee->dev);
+ if(ieee->LedControlHandler != NULL)
+ ieee->LedControlHandler(ieee->dev,LED_CTL_LINK);
+ notify_wx_assoc_event(ieee);
+
+ ieee80211_start_send_beacons(ieee);
+
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+ netif_carrier_on(ieee->dev);
+
+ up(&ieee->wx_sem);
+}
+
+inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_delayed_work(ieee->wq, &ieee->start_ibss_wq, 150);
+#else
+ schedule_task(&ieee->start_ibss_wq);
+#endif
+}
+
+/* this is called only in user context, with wx_sem held */
+void ieee80211_start_bss(struct ieee80211_device *ieee)
+{
+ unsigned long flags;
+#ifdef ENABLE_DOT11D
+ //
+ // Ref: 802.11d 11.1.3.3
+ // STA shall not start a BSS unless properly formed Beacon frame including a Country IE.
+ //
+ if(IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee))
+ {
+ if(! ieee->bGlobalDomain)
+ {
+ return;
+ }
+ }
+#endif
+ /* check if we have already found the net we
+ * are interested in (if any).
+ * if not (we are disassociated and we are not
+ * in associating / authenticating phase) start the background scanning.
+ */
+ ieee80211_softmac_check_all_nets(ieee);
+
+ /* ensure no-one start an associating process (thus setting
+ * the ieee->state to ieee80211_ASSOCIATING) while we
+ * have just cheked it and we are going to enable scan.
+ * The ieee80211_new_net function is always called with
+ * lock held (from both ieee80211_softmac_check_all_nets and
+ * the rx path), so we cannot be in the middle of such function
+ */
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if (ieee->state == IEEE80211_NOLINK){
+ ieee->actscanning = true;
+ ieee80211_start_scan(ieee);
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void ieee80211_link_change_wq(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work, struct delayed_work, work);
+ struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, link_change_wq);
+#else
+void ieee80211_link_change_wq(struct ieee80211_device *ieee)
+{
+#endif
+ ieee->link_change(ieee->dev);
+}
+/* called only in userspace context */
+void ieee80211_disassociate(struct ieee80211_device *ieee)
+{
+
+
+ netif_carrier_off(ieee->dev);
+ if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
+ ieee80211_reset_queue(ieee);
+
+ if (ieee->data_hard_stop)
+ ieee->data_hard_stop(ieee->dev);
+#ifdef ENABLE_DOT11D
+ if(IS_DOT11D_ENABLE(ieee))
+ Dot11d_Reset(ieee);
+#endif
+ ieee->state = IEEE80211_NOLINK;
+ ieee->is_set_key = false;
+
+ //LZM for usb dev crash.
+ //ieee->link_change(ieee->dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_delayed_work(ieee->wq, &ieee->link_change_wq, 0);
+#else
+ schedule_task(&ieee->link_change_wq);
+#endif
+
+ //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ notify_wx_assoc_event(ieee);
+
+}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void ieee80211_associate_retry_wq(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work, struct delayed_work, work);
+ struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
+#else
+void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
+{
+#endif
+ unsigned long flags;
+
+ down(&ieee->wx_sem);
+ if(!ieee->proto_started)
+ goto exit;
+
+ if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
+ goto exit;
+
+ /* until we do not set the state to IEEE80211_NOLINK
+ * there are no possibility to have someone else trying
+ * to start an association procdure (we get here with
+ * ieee->state = IEEE80211_ASSOCIATING).
+ * When we set the state to IEEE80211_NOLINK it is possible
+ * that the RX path run an attempt to associate, but
+ * both ieee80211_softmac_check_all_nets and the
+ * RX path works with ieee->lock held so there are no
+ * problems. If we are still disassociated then start a scan.
+ * the lock here is necessary to ensure no one try to start
+ * an association procedure when we have just checked the
+ * state and we are going to start the scan.
+ */
+ ieee->beinretry = true;
+ ieee->state = IEEE80211_NOLINK;
+
+ ieee80211_softmac_check_all_nets(ieee);
+
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if(ieee->state == IEEE80211_NOLINK)
+ {
+ ieee->actscanning = true;
+ ieee80211_start_scan(ieee);
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+ ieee->beinretry = false;
+exit:
+ up(&ieee->wx_sem);
+}
+
+struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
+{
+ u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
+
+ struct sk_buff *skb;
+ struct ieee80211_probe_response *b;
+
+ skb = ieee80211_probe_resp(ieee, broadcast_addr);
+
+ if (!skb)
+ return NULL;
+
+ b = (struct ieee80211_probe_response *) skb->data;
+ b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON);
+
+ return skb;
+
+}
+
+struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
+{
+ struct sk_buff *skb;
+ struct ieee80211_probe_response *b;
+
+ skb = ieee80211_get_beacon_(ieee);
+ if(!skb)
+ return NULL;
+
+ b = (struct ieee80211_probe_response *) skb->data;
+ b->header.seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
+
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+
+ return skb;
+}
+
+void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
+{
+ ieee->sync_scan_hurryup = 1;
+ down(&ieee->wx_sem);
+ ieee80211_stop_protocol(ieee);
+ up(&ieee->wx_sem);
+}
+
+
+void ieee80211_stop_protocol(struct ieee80211_device *ieee)
+{
+ if (!ieee->proto_started)
+ return;
+
+ ieee->proto_started = 0;
+
+ ieee80211_stop_send_beacons(ieee);
+ del_timer_sync(&ieee->associate_timer);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ cancel_delayed_work(&ieee->associate_retry_wq);
+ cancel_delayed_work(&ieee->start_ibss_wq);
+ cancel_delayed_work(&ieee->link_change_wq);
+#endif
+ ieee80211_stop_scan(ieee);
+
+ ieee80211_disassociate(ieee);
+ RemoveAllTS(ieee); //added as we disconnect from the previous BSS, Remove all TS
+}
+
+void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
+{
+ ieee->sync_scan_hurryup = 0;
+ down(&ieee->wx_sem);
+ ieee80211_start_protocol(ieee);
+ up(&ieee->wx_sem);
+}
+
+void ieee80211_start_protocol(struct ieee80211_device *ieee)
+{
+ short ch = 0;
+ int i = 0;
+ if (ieee->proto_started)
+ return;
+
+ ieee->proto_started = 1;
+
+ if (ieee->current_network.channel == 0){
+ do{
+ ch++;
+ if (ch > MAX_CHANNEL_NUMBER)
+ return; /* no channel found */
+#ifdef ENABLE_DOT11D
+ }while(!GET_DOT11D_INFO(ieee)->channel_map[ch]);
+#else
+ }while(!ieee->channel_map[ch]);
+#endif
+ ieee->current_network.channel = ch;
+ }
+
+ if (ieee->current_network.beacon_interval == 0)
+ ieee->current_network.beacon_interval = 100;
+// printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel);
+// ieee->set_chan(ieee->dev,ieee->current_network.channel);
+
+ for(i = 0; i < 17; i++) {
+ ieee->last_rxseq_num[i] = -1;
+ ieee->last_rxfrag_num[i] = -1;
+ ieee->last_packet_time[i] = 0;
+ }
+
+ ieee->init_wmmparam_flag = 0;//reinitialize AC_xx_PARAM registers.
+
+
+ /* if the user set the MAC of the ad-hoc cell and then
+ * switch to managed mode, shall we make sure that association
+ * attempts does not fail just because the user provide the essid
+ * and the nic is still checking for the AP MAC ??
+ */
+ if (ieee->iw_mode == IW_MODE_INFRA)
+ ieee80211_start_bss(ieee);
+
+ else if (ieee->iw_mode == IW_MODE_ADHOC)
+ ieee80211_start_ibss(ieee);
+
+ else if (ieee->iw_mode == IW_MODE_MASTER)
+ ieee80211_start_master_bss(ieee);
+
+ else if(ieee->iw_mode == IW_MODE_MONITOR)
+ ieee80211_start_monitor_mode(ieee);
+}
+
+
+#define DRV_NAME "Ieee80211"
+void ieee80211_softmac_init(struct ieee80211_device *ieee)
+{
+ int i;
+ memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
+
+ ieee->state = IEEE80211_NOLINK;
+ ieee->sync_scan_hurryup = 0;
+ for(i = 0; i < 5; i++) {
+ ieee->seq_ctrl[i] = 0;
+ }
+#ifdef ENABLE_DOT11D
+ ieee->pDot11dInfo = kmalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC);
+ if (!ieee->pDot11dInfo)
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n");
+ memset(ieee->pDot11dInfo, 0, sizeof(RT_DOT11D_INFO));
+#endif
+ //added for AP roaming
+ ieee->LinkDetectInfo.SlotNum = 2;
+ ieee->LinkDetectInfo.NumRecvBcnInPeriod=0;
+ ieee->LinkDetectInfo.NumRecvDataInPeriod=0;
+
+ ieee->assoc_id = 0;
+ ieee->queue_stop = 0;
+ ieee->scanning = 0;
+ ieee->softmac_features = 0; //so IEEE2100-like driver are happy
+ ieee->wap_set = 0;
+ ieee->ssid_set = 0;
+ ieee->proto_started = 0;
+ ieee->basic_rate = IEEE80211_DEFAULT_BASIC_RATE;
+ ieee->rate = 22;
+ ieee->ps = IEEE80211_PS_DISABLED;
+ ieee->sta_sleep = 0;
+ ieee->Regdot11HTOperationalRateSet[0]= 0xff;//support MCS 0~7
+ ieee->Regdot11HTOperationalRateSet[1]= 0xff;//support MCS 8~15
+ ieee->Regdot11HTOperationalRateSet[4]= 0x01;
+ //added by amy
+ ieee->actscanning = false;
+ ieee->beinretry = false;
+ ieee->is_set_key = false;
+ init_mgmt_queue(ieee);
+
+ ieee->sta_edca_param[0] = 0x0000A403;
+ ieee->sta_edca_param[1] = 0x0000A427;
+ ieee->sta_edca_param[2] = 0x005E4342;
+ ieee->sta_edca_param[3] = 0x002F3262;
+ ieee->aggregation = true;
+ ieee->enable_rx_imm_BA = 1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ init_timer(&ieee->scan_timer);
+ ieee->scan_timer.data = (unsigned long)ieee;
+ ieee->scan_timer.function = ieee80211_softmac_scan_cb;
+#endif
+ ieee->tx_pending.txb = NULL;
+
+ init_timer(&ieee->associate_timer);
+ ieee->associate_timer.data = (unsigned long)ieee;
+ ieee->associate_timer.function = ieee80211_associate_abort_cb;
+
+ init_timer(&ieee->beacon_timer);
+ ieee->beacon_timer.data = (unsigned long) ieee;
+ ieee->beacon_timer.function = ieee80211_send_beacon_cb;
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#ifdef PF_SYNCTHREAD
+ ieee->wq = create_workqueue(DRV_NAME,0);
+#else
+ ieee->wq = create_workqueue(DRV_NAME);
+#endif
+#endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ INIT_DELAYED_WORK(&ieee->link_change_wq,ieee80211_link_change_wq);
+ INIT_DELAYED_WORK(&ieee->start_ibss_wq,ieee80211_start_ibss_wq);
+ INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq);
+ INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq);
+ INIT_DELAYED_WORK(&ieee->softmac_scan_wq,ieee80211_softmac_scan_wq);
+ INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq);
+ INIT_WORK(&ieee->wx_sync_scan_wq,ieee80211_wx_sync_scan_wq);
+
+#else
+ INIT_WORK(&ieee->link_change_wq,(void(*)(void*)) ieee80211_link_change_wq,ieee);
+ INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
+ INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
+ INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
+ INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
+ INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
+ INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
+#endif
+
+#else
+ tq_init(&ieee->link_change_wq,(void(*)(void*)) ieee80211_link_change_wq,ieee);
+ tq_init(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
+ tq_init(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
+ tq_init(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
+ tq_init(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
+ tq_init(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
+ tq_init(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
+#endif
+ sema_init(&ieee->wx_sem, 1);
+ sema_init(&ieee->scan_sem, 1);
+
+ spin_lock_init(&ieee->mgmt_tx_lock);
+ spin_lock_init(&ieee->beacon_lock);
+
+ tasklet_init(&ieee->ps_task,
+ (void(*)(unsigned long)) ieee80211_sta_ps,
+ (unsigned long)ieee);
+
+}
+
+void ieee80211_softmac_free(struct ieee80211_device *ieee)
+{
+ down(&ieee->wx_sem);
+#ifdef ENABLE_DOT11D
+ if(NULL != ieee->pDot11dInfo)
+ {
+ kfree(ieee->pDot11dInfo);
+ ieee->pDot11dInfo = NULL;
+ }
+#endif
+ del_timer_sync(&ieee->associate_timer);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ cancel_delayed_work(&ieee->associate_retry_wq);
+ destroy_workqueue(ieee->wq);
+#endif
+
+ up(&ieee->wx_sem);
+}
+
+/********************************************************
+ * Start of WPA code. *
+ * this is stolen from the ipw2200 driver *
+ ********************************************************/
+
+
+static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
+{
+ /* This is called when wpa_supplicant loads and closes the driver
+ * interface. */
+ printk("%s WPA\n",value ? "enabling" : "disabling");
+ ieee->wpa_enabled = value;
+ memset(ieee->ap_mac_addr, 0, 6); //reset ap_mac_addr everytime it starts wpa.
+ return 0;
+}
+
+
+void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
+{
+ /* make sure WPA is enabled */
+ ieee80211_wpa_enable(ieee, 1);
+
+ ieee80211_disassociate(ieee);
+}
+
+
+static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
+{
+
+ int ret = 0;
+
+ switch (command) {
+ case IEEE_MLME_STA_DEAUTH:
+ // silently ignore
+ break;
+
+ case IEEE_MLME_STA_DISASSOC:
+ ieee80211_disassociate(ieee);
+ break;
+
+ default:
+ printk("Unknown MLME request: %d\n", command);
+ ret = -EOPNOTSUPP;
+ }
+
+ return ret;
+}
+
+
+static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
+ struct ieee_param *param, int plen)
+{
+ u8 *buf;
+
+ if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
+ (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL))
+ return -EINVAL;
+
+ if (param->u.wpa_ie.len) {
+ buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL);
+ if (buf == NULL)
+ return -ENOMEM;
+
+ memcpy(buf, param->u.wpa_ie.data, param->u.wpa_ie.len);
+ kfree(ieee->wpa_ie);
+ ieee->wpa_ie = buf;
+ ieee->wpa_ie_len = param->u.wpa_ie.len;
+ } else {
+ kfree(ieee->wpa_ie);
+ ieee->wpa_ie = NULL;
+ ieee->wpa_ie_len = 0;
+ }
+
+ ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
+ return 0;
+}
+
+#define AUTH_ALG_OPEN_SYSTEM 0x1
+#define AUTH_ALG_SHARED_KEY 0x2
+#define AUTH_ALG_LEAP 0x4
+static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
+{
+
+ struct ieee80211_security sec = {
+ .flags = SEC_AUTH_MODE,
+ };
+ int ret = 0;
+
+ if (value & AUTH_ALG_SHARED_KEY) {
+ sec.auth_mode = WLAN_AUTH_SHARED_KEY;
+ ieee->open_wep = 0;
+ ieee->auth_mode = 1;
+ } else if (value & AUTH_ALG_OPEN_SYSTEM){
+ sec.auth_mode = WLAN_AUTH_OPEN;
+ ieee->open_wep = 1;
+ ieee->auth_mode = 0;
+ }
+ else if (value & AUTH_ALG_LEAP){
+ sec.auth_mode = WLAN_AUTH_LEAP;
+ ieee->open_wep = 1;
+ ieee->auth_mode = 2;
+ }
+
+
+ if (ieee->set_security)
+ ieee->set_security(ieee->dev, &sec);
+ //else
+ // ret = -EOPNOTSUPP;
+
+ return ret;
+}
+
+static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
+{
+ int ret=0;
+ unsigned long flags;
+
+ switch (name) {
+ case IEEE_PARAM_WPA_ENABLED:
+ ret = ieee80211_wpa_enable(ieee, value);
+ break;
+
+ case IEEE_PARAM_TKIP_COUNTERMEASURES:
+ ieee->tkip_countermeasures=value;
+ break;
+
+ case IEEE_PARAM_DROP_UNENCRYPTED: {
+ /* HACK:
+ *
+ * wpa_supplicant calls set_wpa_enabled when the driver
+ * is loaded and unloaded, regardless of if WPA is being
+ * used. No other calls are made which can be used to
+ * determine if encryption will be used or not prior to
+ * association being expected. If encryption is not being
+ * used, drop_unencrypted is set to false, else true -- we
+ * can use this to determine if the CAP_PRIVACY_ON bit should
+ * be set.
+ */
+ struct ieee80211_security sec = {
+ .flags = SEC_ENABLED,
+ .enabled = value,
+ };
+ ieee->drop_unencrypted = value;
+ /* We only change SEC_LEVEL for open mode. Others
+ * are set by ipw_wpa_set_encryption.
+ */
+ if (!value) {
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_0;
+ }
+ else {
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_1;
+ }
+ if (ieee->set_security)
+ ieee->set_security(ieee->dev, &sec);
+ break;
+ }
+
+ case IEEE_PARAM_PRIVACY_INVOKED:
+ ieee->privacy_invoked=value;
+ break;
+
+ case IEEE_PARAM_AUTH_ALGS:
+ ret = ieee80211_wpa_set_auth_algs(ieee, value);
+ break;
+
+ case IEEE_PARAM_IEEE_802_1X:
+ ieee->ieee802_1x=value;
+ break;
+ case IEEE_PARAM_WPAX_SELECT:
+ // added for WPA2 mixed mode
+ spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags);
+ ieee->wpax_type_set = 1;
+ ieee->wpax_type_notify = value;
+ spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags);
+ break;
+
+ default:
+ printk("Unknown WPA param: %d\n",name);
+ ret = -EOPNOTSUPP;
+ }
+
+ return ret;
+}
+
+/* implementation borrowed from hostap driver */
+
+static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
+ struct ieee_param *param, int param_len)
+{
+ int ret = 0;
+
+ struct ieee80211_crypto_ops *ops;
+ struct ieee80211_crypt_data **crypt;
+
+ struct ieee80211_security sec = {
+ .flags = 0,
+ };
+
+ param->u.crypt.err = 0;
+ param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
+
+ if (param_len !=
+ (int) ((char *) param->u.crypt.key - (char *) param) +
+ param->u.crypt.key_len) {
+ printk("Len mismatch %d, %d\n", param_len,
+ param->u.crypt.key_len);
+ return -EINVAL;
+ }
+ if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+ param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+ param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+ if (param->u.crypt.idx >= WEP_KEYS)
+ return -EINVAL;
+ crypt = &ieee->crypt[param->u.crypt.idx];
+ } else {
+ return -EINVAL;
+ }
+
+ if (strcmp(param->u.crypt.alg, "none") == 0) {
+ if (crypt) {
+ sec.enabled = 0;
+ // FIXME FIXME
+ //sec.encrypt = 0;
+ sec.level = SEC_LEVEL_0;
+ sec.flags |= SEC_ENABLED | SEC_LEVEL;
+ ieee80211_crypt_delayed_deinit(ieee, crypt);
+ }
+ goto done;
+ }
+ sec.enabled = 1;
+// FIXME FIXME
+// sec.encrypt = 1;
+ sec.flags |= SEC_ENABLED;
+
+ /* IPW HW cannot build TKIP MIC, host decryption still needed. */
+ if (!(ieee->host_encrypt || ieee->host_decrypt) &&
+ strcmp(param->u.crypt.alg, "TKIP"))
+ goto skip_host_crypt;
+
+ ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+ if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
+ request_module("ieee80211_crypt_wep");
+ ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+ //set WEP40 first, it will be modified according to WEP104 or WEP40 at other place
+ } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
+ request_module("ieee80211_crypt_tkip");
+ ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+ } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
+ request_module("ieee80211_crypt_ccmp");
+ ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+ }
+ if (ops == NULL) {
+ printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
+ param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG;
+ ret = -EINVAL;
+ goto done;
+ }
+
+ if (*crypt == NULL || (*crypt)->ops != ops) {
+ struct ieee80211_crypt_data *new_crypt;
+
+ ieee80211_crypt_delayed_deinit(ieee, crypt);
+
+ new_crypt = (struct ieee80211_crypt_data *)
+ kmalloc(sizeof(*new_crypt), GFP_KERNEL);
+ if (new_crypt == NULL) {
+ ret = -ENOMEM;
+ goto done;
+ }
+ memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+ new_crypt->ops = ops;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
+#else
+ if (new_crypt->ops && try_inc_mod_count(new_crypt->ops->owner))
+#endif
+ new_crypt->priv =
+ new_crypt->ops->init(param->u.crypt.idx);
+
+ if (new_crypt->priv == NULL) {
+ kfree(new_crypt);
+ param->u.crypt.err = IEEE_CRYPT_ERR_CRYPT_INIT_FAILED;
+ ret = -EINVAL;
+ goto done;
+ }
+
+ *crypt = new_crypt;
+ }
+
+ if (param->u.crypt.key_len > 0 && (*crypt)->ops->set_key &&
+ (*crypt)->ops->set_key(param->u.crypt.key,
+ param->u.crypt.key_len, param->u.crypt.seq,
+ (*crypt)->priv) < 0) {
+ printk("key setting failed\n");
+ param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED;
+ ret = -EINVAL;
+ goto done;
+ }
+
+ skip_host_crypt:
+ if (param->u.crypt.set_tx) {
+ ieee->tx_keyidx = param->u.crypt.idx;
+ sec.active_key = param->u.crypt.idx;
+ sec.flags |= SEC_ACTIVE_KEY;
+ } else
+ sec.flags &= ~SEC_ACTIVE_KEY;
+
+ if (param->u.crypt.alg != NULL) {
+ memcpy(sec.keys[param->u.crypt.idx],
+ param->u.crypt.key,
+ param->u.crypt.key_len);
+ sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len;
+ sec.flags |= (1 << param->u.crypt.idx);
+
+ if (strcmp(param->u.crypt.alg, "WEP") == 0) {
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_1;
+ } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_2;
+ } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_3;
+ }
+ }
+ done:
+ if (ieee->set_security)
+ ieee->set_security(ieee->dev, &sec);
+
+ /* Do not reset port if card is in Managed mode since resetting will
+ * generate new IEEE 802.11 authentication which may end up in looping
+ * with IEEE 802.1X. If your hardware requires a reset after WEP
+ * configuration (for example... Prism2), implement the reset_port in
+ * the callbacks structures used to initialize the 802.11 stack. */
+ if (ieee->reset_on_keychange &&
+ ieee->iw_mode != IW_MODE_INFRA &&
+ ieee->reset_port &&
+ ieee->reset_port(ieee->dev)) {
+ printk("reset_port failed\n");
+ param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED;
+ return -EINVAL;
+ }
+
+ return ret;
+}
+
+inline struct sk_buff *ieee80211_disassociate_skb(
+ struct ieee80211_network *beacon,
+ struct ieee80211_device *ieee,
+ u8 asRsn)
+{
+ struct sk_buff *skb;
+ struct ieee80211_disassoc *disass;
+
+ skb = dev_alloc_skb(sizeof(struct ieee80211_disassoc));
+ if (!skb)
+ return NULL;
+
+ disass = (struct ieee80211_disassoc *) skb_put(skb,sizeof(struct ieee80211_disassoc));
+ disass->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_DISASSOC);
+ disass->header.duration_id = 0;
+
+ memcpy(disass->header.addr1, beacon->bssid, ETH_ALEN);
+ memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN);
+
+ disass->reason = asRsn;
+ return skb;
+}
+
+
+void
+SendDisassociation(
+ struct ieee80211_device *ieee,
+ u8* asSta,
+ u8 asRsn
+)
+{
+ struct ieee80211_network *beacon = &ieee->current_network;
+ struct sk_buff *skb;
+ skb = ieee80211_disassociate_skb(beacon,ieee,asRsn);
+ if (skb){
+ softmac_mgmt_xmit(skb, ieee);
+ //dev_kfree_skb_any(skb);//edit by thomas
+ }
+}
+
+int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
+{
+ struct ieee_param *param;
+ int ret=0;
+
+ down(&ieee->wx_sem);
+ //IEEE_DEBUG_INFO("wpa_supplicant: len=%d\n", p->length);
+
+ if (p->length < sizeof(struct ieee_param) || !p->pointer){
+ ret = -EINVAL;
+ goto out;
+ }
+
+ param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
+ if (param == NULL){
+ ret = -ENOMEM;
+ goto out;
+ }
+ if (copy_from_user(param, p->pointer, p->length)) {
+ kfree(param);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ switch (param->cmd) {
+
+ case IEEE_CMD_SET_WPA_PARAM:
+ ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
+ param->u.wpa_param.value);
+ break;
+
+ case IEEE_CMD_SET_WPA_IE:
+ ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
+ break;
+
+ case IEEE_CMD_SET_ENCRYPTION:
+ ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
+ break;
+
+ case IEEE_CMD_MLME:
+ ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
+ param->u.mlme.reason_code);
+ break;
+
+ default:
+ printk("Unknown WPA supplicant request: %d\n",param->cmd);
+ ret = -EOPNOTSUPP;
+ break;
+ }
+
+ if (ret == 0 && copy_to_user(p->pointer, param, p->length))
+ ret = -EFAULT;
+
+ kfree(param);
+out:
+ up(&ieee->wx_sem);
+
+ return ret;
+}
+
+void notify_wx_assoc_event(struct ieee80211_device *ieee)
+{
+ union iwreq_data wrqu;
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ if (ieee->state == IEEE80211_LINKED)
+ memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN);
+ else
+ memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+ wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
+}
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_get_beacon);
+EXPORT_SYMBOL(ieee80211_wake_queue);
+EXPORT_SYMBOL(ieee80211_stop_queue);
+EXPORT_SYMBOL(ieee80211_reset_queue);
+EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
+EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
+EXPORT_SYMBOL(ieee80211_is_shortslot);
+EXPORT_SYMBOL(ieee80211_is_54g);
+EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
+EXPORT_SYMBOL(ieee80211_ps_tx_ack);
+EXPORT_SYMBOL(ieee80211_softmac_xmit);
+EXPORT_SYMBOL(ieee80211_stop_send_beacons);
+EXPORT_SYMBOL(notify_wx_assoc_event);
+EXPORT_SYMBOL(SendDisassociation);
+EXPORT_SYMBOL(ieee80211_disassociate);
+EXPORT_SYMBOL(ieee80211_start_send_beacons);
+EXPORT_SYMBOL(ieee80211_stop_scan);
+EXPORT_SYMBOL(ieee80211_send_probe_requests);
+EXPORT_SYMBOL(ieee80211_softmac_scan_syncro);
+EXPORT_SYMBOL(ieee80211_start_scan_syncro);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_get_beacon);
+EXPORT_SYMBOL_NOVERS(ieee80211_wake_queue);
+EXPORT_SYMBOL_NOVERS(ieee80211_stop_queue);
+EXPORT_SYMBOL_NOVERS(ieee80211_reset_queue);
+EXPORT_SYMBOL_NOVERS(ieee80211_softmac_stop_protocol);
+EXPORT_SYMBOL_NOVERS(ieee80211_softmac_start_protocol);
+EXPORT_SYMBOL_NOVERS(ieee80211_is_shortslot);
+EXPORT_SYMBOL_NOVERS(ieee80211_is_54g);
+EXPORT_SYMBOL_NOVERS(ieee80211_wpa_supplicant_ioctl);
+EXPORT_SYMBOL_NOVERS(ieee80211_ps_tx_ack);
+EXPORT_SYMBOL_NOVERS(ieee80211_softmac_xmit);
+EXPORT_SYMBOL_NOVERS(ieee80211_stop_send_beacons);
+EXPORT_SYMBOL_NOVERS(notify_wx_assoc_event);
+EXPORT_SYMBOL_NOVERS(SendDisassociation);
+EXPORT_SYMBOL_NOVERS(ieee80211_disassociate);
+EXPORT_SYMBOL_NOVERS(ieee80211_start_send_beacons);
+EXPORT_SYMBOL_NOVERS(ieee80211_stop_scan);
+EXPORT_SYMBOL_NOVERS(ieee80211_send_probe_requests);
+EXPORT_SYMBOL_NOVERS(ieee80211_softmac_scan_syncro);
+EXPORT_SYMBOL_NOVERS(ieee80211_start_scan_syncro);
+#endif
+//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
new file mode 100644
index 000000000000..1f50c46dcb90
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
@@ -0,0 +1,711 @@
+/* IEEE 802.11 SoftMAC layer
+ * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
+ *
+ * Mostly extracted from the rtl8180-sa2400 driver for the
+ * in-kernel generic ieee802.11 stack.
+ *
+ * Some pieces of code might be stolen from ipw2100 driver
+ * copyright of who own it's copyright ;-)
+ *
+ * PS wx handler mostly stolen from hostap, copyright who
+ * own it's copyright ;-)
+ *
+ * released under the GPL
+ */
+
+
+#include "ieee80211.h"
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+/* FIXME: add A freqs */
+
+const long ieee80211_wlan_frequencies[] = {
+ 2412, 2417, 2422, 2427,
+ 2432, 2437, 2442, 2447,
+ 2452, 2457, 2462, 2467,
+ 2472, 2484
+};
+
+
+int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ int ret;
+ struct iw_freq *fwrq = & wrqu->freq;
+
+ down(&ieee->wx_sem);
+
+ if(ieee->iw_mode == IW_MODE_INFRA){
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
+ /* if setting by freq convert to channel */
+ if (fwrq->e == 1) {
+ if ((fwrq->m >= (int) 2.412e8 &&
+ fwrq->m <= (int) 2.487e8)) {
+ int f = fwrq->m / 100000;
+ int c = 0;
+
+ while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
+ c++;
+
+ /* hack to fall through */
+ fwrq->e = 0;
+ fwrq->m = c + 1;
+ }
+ }
+
+ if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
+ ret = -EOPNOTSUPP;
+ goto out;
+
+ }else { /* Set the channel */
+
+#ifdef ENABLE_DOT11D
+ if (!(GET_DOT11D_INFO(ieee)->channel_map)[fwrq->m]) {
+ ret = -EINVAL;
+ goto out;
+ }
+#endif
+ ieee->current_network.channel = fwrq->m;
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+
+ if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
+ if(ieee->state == IEEE80211_LINKED){
+
+ ieee80211_stop_send_beacons(ieee);
+ ieee80211_start_send_beacons(ieee);
+ }
+ }
+
+ ret = 0;
+out:
+ up(&ieee->wx_sem);
+ return ret;
+}
+
+
+int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct iw_freq *fwrq = & wrqu->freq;
+
+ if (ieee->current_network.channel == 0)
+ return -1;
+ //NM 0.7.0 will not accept channel any more.
+ fwrq->m = ieee80211_wlan_frequencies[ieee->current_network.channel-1] * 100000;
+ fwrq->e = 1;
+// fwrq->m = ieee->current_network.channel;
+// fwrq->e = 0;
+
+ return 0;
+}
+
+int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ unsigned long flags;
+
+ wrqu->ap_addr.sa_family = ARPHRD_ETHER;
+
+ if (ieee->iw_mode == IW_MODE_MONITOR)
+ return -1;
+
+ /* We want avoid to give to the user inconsistent infos*/
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if (ieee->state != IEEE80211_LINKED &&
+ ieee->state != IEEE80211_LINKED_SCANNING &&
+ ieee->wap_set == 0)
+
+ memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+ else
+ memcpy(wrqu->ap_addr.sa_data,
+ ieee->current_network.bssid, ETH_ALEN);
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+ return 0;
+}
+
+
+int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra)
+{
+
+ int ret = 0;
+ u8 zero[] = {0,0,0,0,0,0};
+ unsigned long flags;
+
+ short ifup = ieee->proto_started;//dev->flags & IFF_UP;
+ struct sockaddr *temp = (struct sockaddr *)awrq;
+
+ ieee->sync_scan_hurryup = 1;
+
+ down(&ieee->wx_sem);
+ /* use ifconfig hw ether */
+ if (ieee->iw_mode == IW_MODE_MASTER){
+ ret = -1;
+ goto out;
+ }
+
+ if (temp->sa_family != ARPHRD_ETHER){
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (ifup)
+ ieee80211_stop_protocol(ieee);
+
+ /* just to avoid to give inconsistent infos in the
+ * get wx method. not really needed otherwise
+ */
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
+ ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+ if (ifup)
+ ieee80211_start_protocol(ieee);
+out:
+ up(&ieee->wx_sem);
+ return ret;
+}
+
+ int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
+{
+ int len,ret = 0;
+ unsigned long flags;
+
+ if (ieee->iw_mode == IW_MODE_MONITOR)
+ return -1;
+
+ /* We want avoid to give to the user inconsistent infos*/
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if (ieee->current_network.ssid[0] == '\0' ||
+ ieee->current_network.ssid_len == 0){
+ ret = -1;
+ goto out;
+ }
+
+ if (ieee->state != IEEE80211_LINKED &&
+ ieee->state != IEEE80211_LINKED_SCANNING &&
+ ieee->ssid_set == 0){
+ ret = -1;
+ goto out;
+ }
+ len = ieee->current_network.ssid_len;
+ wrqu->essid.length = len;
+ strncpy(b,ieee->current_network.ssid,len);
+ wrqu->essid.flags = 1;
+
+out:
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+ return ret;
+
+}
+
+int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+
+ u32 target_rate = wrqu->bitrate.value;
+
+ ieee->rate = target_rate/100000;
+ //FIXME: we might want to limit rate also in management protocols.
+ return 0;
+}
+
+
+
+int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ u32 tmp_rate = 0;
+#ifdef RTL8192SU
+ //printk("===>mode:%d, halfNmode:%d\n", ieee->mode, ieee->bHalfWirelessN24GMode);
+ if (ieee->mode & (IEEE_A | IEEE_B | IEEE_G))
+ tmp_rate = ieee->rate;
+ else if (ieee->mode & IEEE_N_5G)
+ tmp_rate = 580;
+ else if (ieee->mode & IEEE_N_24G)
+ {
+ if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+ tmp_rate = HTHalfMcsToDataRate(ieee, 15);
+ else
+ tmp_rate = HTMcsToDataRate(ieee, 15);
+ }
+#else
+ tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate);
+
+#endif
+ wrqu->bitrate.value = tmp_rate * 500000;
+
+ return 0;
+}
+
+
+int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ if (wrqu->rts.disabled || !wrqu->rts.fixed)
+ ieee->rts = DEFAULT_RTS_THRESHOLD;
+ else
+ {
+ if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
+ wrqu->rts.value > MAX_RTS_THRESHOLD)
+ return -EINVAL;
+ ieee->rts = wrqu->rts.value;
+ }
+ return 0;
+}
+
+int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ wrqu->rts.value = ieee->rts;
+ wrqu->rts.fixed = 0; /* no auto select */
+ wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD);
+ return 0;
+}
+int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+
+ ieee->sync_scan_hurryup = 1;
+
+ down(&ieee->wx_sem);
+
+ if (wrqu->mode == ieee->iw_mode)
+ goto out;
+
+ if (wrqu->mode == IW_MODE_MONITOR){
+
+ ieee->dev->type = ARPHRD_IEEE80211;
+ }else{
+ ieee->dev->type = ARPHRD_ETHER;
+ }
+
+ if (!ieee->proto_started){
+ ieee->iw_mode = wrqu->mode;
+ }else{
+ ieee80211_stop_protocol(ieee);
+ ieee->iw_mode = wrqu->mode;
+ ieee80211_start_protocol(ieee);
+ }
+
+out:
+ up(&ieee->wx_sem);
+ return 0;
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+void ieee80211_wx_sync_scan_wq(struct work_struct *work)
+{
+ struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
+#else
+void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
+{
+#endif
+ short chan;
+ HT_EXTCHNL_OFFSET chan_offset=0;
+ HT_CHANNEL_WIDTH bandwidth=0;
+ int b40M = 0;
+ static int count = 0;
+ chan = ieee->current_network.channel;
+ netif_carrier_off(ieee->dev);
+
+ if (ieee->data_hard_stop)
+ ieee->data_hard_stop(ieee->dev);
+
+ ieee80211_stop_send_beacons(ieee);
+
+ ieee->state = IEEE80211_LINKED_SCANNING;
+ ieee->link_change(ieee->dev);
+#ifndef RTL8192SE
+ ieee->InitialGainHandler(ieee->dev,IG_Backup);
+#endif
+#if(RTL8192S_DISABLE_FW_DM == 0)
+ if (ieee->SetFwCmdHandler)
+ {
+ ieee->SetFwCmdHandler(ieee->dev, FW_CMD_DIG_HALT);
+ ieee->SetFwCmdHandler(ieee->dev, FW_CMD_HIGH_PWR_DISABLE);
+ }
+#endif
+ if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) {
+ b40M = 1;
+ chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset;
+ bandwidth = (HT_CHANNEL_WIDTH)ieee->pHTInfo->bCurBW40MHz;
+ printk("Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth);
+ ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ }
+ ieee80211_start_scan_syncro(ieee);
+ if (b40M) {
+ printk("Scan in 20M, back to 40M\n");
+ if (chan_offset == HT_EXTCHNL_OFFSET_UPPER)
+ ieee->set_chan(ieee->dev, chan + 2);
+ else if (chan_offset == HT_EXTCHNL_OFFSET_LOWER)
+ ieee->set_chan(ieee->dev, chan - 2);
+ else
+ ieee->set_chan(ieee->dev, chan);
+ ieee->SetBWModeHandler(ieee->dev, bandwidth, chan_offset);
+ } else {
+ ieee->set_chan(ieee->dev, chan);
+ }
+
+#ifndef RTL8192SE
+ ieee->InitialGainHandler(ieee->dev,IG_Restore);
+#endif
+#if(RTL8192S_DISABLE_FW_DM == 0)
+ if (ieee->SetFwCmdHandler)
+ {
+ ieee->SetFwCmdHandler(ieee->dev, FW_CMD_DIG_RESUME);
+ ieee->SetFwCmdHandler(ieee->dev, FW_CMD_HIGH_PWR_ENABLE);
+ }
+#endif
+ ieee->state = IEEE80211_LINKED;
+ ieee->link_change(ieee->dev);
+ // To prevent the immediately calling watch_dog after scan.
+ if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
+ {
+ ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
+ ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
+ }
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+
+ if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
+ ieee80211_start_send_beacons(ieee);
+
+ netif_carrier_on(ieee->dev);
+ count = 0;
+ up(&ieee->wx_sem);
+
+}
+
+int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ int ret = 0;
+
+ down(&ieee->wx_sem);
+
+ if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
+ ret = -1;
+ goto out;
+ }
+
+ if ( ieee->state == IEEE80211_LINKED){
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
+#else
+ schedule_task(&ieee->wx_sync_scan_wq);
+#endif
+ /* intentionally forget to up sem */
+ return 0;
+ }
+
+out:
+ up(&ieee->wx_sem);
+ return ret;
+}
+
+int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+
+ int ret=0,len;
+ short proto_started;
+ unsigned long flags;
+
+ ieee->sync_scan_hurryup = 1;
+ down(&ieee->wx_sem);
+
+ proto_started = ieee->proto_started;
+
+ if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
+ ret= -E2BIG;
+ goto out;
+ }
+
+ if (ieee->iw_mode == IW_MODE_MONITOR){
+ ret= -1;
+ goto out;
+ }
+
+ if(proto_started)
+ ieee80211_stop_protocol(ieee);
+
+
+ /* this is just to be sure that the GET wx callback
+ * has consisten infos. not needed otherwise
+ */
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ if (wrqu->essid.flags && wrqu->essid.length) {
+ //first flush current network.ssid
+ len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ strncpy(ieee->current_network.ssid, extra, len);
+ ieee->current_network.ssid_len = len;
+#if 0
+ {
+ int i;
+ for (i=0; i<len; i++)
+ printk("%c ", extra[i]);
+ printk("\n");
+ }
+#endif
+#else
+ strncpy(ieee->current_network.ssid, extra, len+1);
+ ieee->current_network.ssid_len = len+1;
+#if 0
+ {
+ int i;
+ for (i=0; i<len + 1; i++)
+ printk("%c ", extra[i]);
+ printk("\n");
+ }
+#endif
+#endif
+ ieee->ssid_set = 1;
+ }
+ else{
+ ieee->ssid_set = 0;
+ ieee->current_network.ssid[0] = '\0';
+ ieee->current_network.ssid_len = 0;
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+
+ if (proto_started)
+ ieee80211_start_protocol(ieee);
+out:
+ up(&ieee->wx_sem);
+ return ret;
+}
+
+ int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+
+ wrqu->mode = ieee->iw_mode;
+ return 0;
+}
+
+ int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+
+ int *parms = (int *)extra;
+ int enable = (parms[0] > 0);
+ short prev = ieee->raw_tx;
+
+ down(&ieee->wx_sem);
+
+ if(enable)
+ ieee->raw_tx = 1;
+ else
+ ieee->raw_tx = 0;
+
+ printk(KERN_INFO"raw TX is %s\n",
+ ieee->raw_tx ? "enabled" : "disabled");
+
+ if(ieee->iw_mode == IW_MODE_MONITOR)
+ {
+ if(prev == 0 && ieee->raw_tx){
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+
+ netif_carrier_on(ieee->dev);
+ }
+
+ if(prev && ieee->raw_tx == 1)
+ netif_carrier_off(ieee->dev);
+ }
+
+ up(&ieee->wx_sem);
+
+ return 0;
+}
+
+int ieee80211_wx_get_name(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ strcpy(wrqu->name, "802.11");
+ if(ieee->modulation & IEEE80211_CCK_MODULATION){
+ strcat(wrqu->name, "b");
+ if(ieee->modulation & IEEE80211_OFDM_MODULATION)
+ strcat(wrqu->name, "/g");
+ }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
+ strcat(wrqu->name, "g");
+ if (ieee->mode & (IEEE_N_24G | IEEE_N_5G))
+ strcat(wrqu->name, "/n");
+
+ if((ieee->state == IEEE80211_LINKED) ||
+ (ieee->state == IEEE80211_LINKED_SCANNING))
+ strcat(wrqu->name," linked");
+ else if(ieee->state != IEEE80211_NOLINK)
+ strcat(wrqu->name," link..");
+
+
+ return 0;
+}
+
+
+/* this is mostly stolen from hostap */
+int ieee80211_wx_set_power(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret = 0;
+#if 1
+ if(
+ (!ieee->sta_wake_up) ||
+ // (!ieee->ps_request_tx_ack) ||
+ (!ieee->enter_sleep_state) ||
+ (!ieee->ps_is_queue_empty)){
+
+ // printk("ERROR. PS mode is tryied to be use but driver missed a callback\n\n");
+
+ return -1;
+ }
+#endif
+ down(&ieee->wx_sem);
+
+ if (wrqu->power.disabled){
+ ieee->ps = IEEE80211_PS_DISABLED;
+ goto exit;
+ }
+ if (wrqu->power.flags & IW_POWER_TIMEOUT) {
+ //ieee->ps_period = wrqu->power.value / 1000;
+ ieee->ps_timeout = wrqu->power.value / 1000;
+ }
+
+ if (wrqu->power.flags & IW_POWER_PERIOD) {
+
+ //ieee->ps_timeout = wrqu->power.value / 1000;
+ ieee->ps_period = wrqu->power.value / 1000;
+ //wrq->value / 1024;
+
+ }
+ switch (wrqu->power.flags & IW_POWER_MODE) {
+ case IW_POWER_UNICAST_R:
+ ieee->ps = IEEE80211_PS_UNICAST;
+ break;
+ case IW_POWER_MULTICAST_R:
+ ieee->ps = IEEE80211_PS_MBCAST;
+ break;
+ case IW_POWER_ALL_R:
+ ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
+ break;
+
+ case IW_POWER_ON:
+ // ieee->ps = IEEE80211_PS_DISABLED;
+ break;
+
+ default:
+ ret = -EINVAL;
+ goto exit;
+
+ }
+exit:
+ up(&ieee->wx_sem);
+ return ret;
+
+}
+
+/* this is stolen from hostap */
+int ieee80211_wx_get_power(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret =0;
+
+ down(&ieee->wx_sem);
+
+ if(ieee->ps == IEEE80211_PS_DISABLED){
+ wrqu->power.disabled = 1;
+ goto exit;
+ }
+
+ wrqu->power.disabled = 0;
+
+ if ((wrqu->power.flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
+ wrqu->power.flags = IW_POWER_TIMEOUT;
+ wrqu->power.value = ieee->ps_timeout * 1000;
+ } else {
+// ret = -EOPNOTSUPP;
+// goto exit;
+ wrqu->power.flags = IW_POWER_PERIOD;
+ wrqu->power.value = ieee->ps_period * 1000;
+//ieee->current_network.dtim_period * ieee->current_network.beacon_interval * 1024;
+ }
+
+ if ((ieee->ps & (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) == (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST))
+ wrqu->power.flags |= IW_POWER_ALL_R;
+ else if (ieee->ps & IEEE80211_PS_MBCAST)
+ wrqu->power.flags |= IW_POWER_MULTICAST_R;
+ else
+ wrqu->power.flags |= IW_POWER_UNICAST_R;
+
+exit:
+ up(&ieee->wx_sem);
+ return ret;
+
+}
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_wx_get_essid);
+EXPORT_SYMBOL(ieee80211_wx_set_essid);
+EXPORT_SYMBOL(ieee80211_wx_set_rate);
+EXPORT_SYMBOL(ieee80211_wx_get_rate);
+EXPORT_SYMBOL(ieee80211_wx_set_wap);
+EXPORT_SYMBOL(ieee80211_wx_get_wap);
+EXPORT_SYMBOL(ieee80211_wx_set_mode);
+EXPORT_SYMBOL(ieee80211_wx_get_mode);
+EXPORT_SYMBOL(ieee80211_wx_set_scan);
+EXPORT_SYMBOL(ieee80211_wx_get_freq);
+EXPORT_SYMBOL(ieee80211_wx_set_freq);
+EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
+EXPORT_SYMBOL(ieee80211_wx_get_name);
+EXPORT_SYMBOL(ieee80211_wx_set_power);
+EXPORT_SYMBOL(ieee80211_wx_get_power);
+EXPORT_SYMBOL(ieee80211_wlan_frequencies);
+EXPORT_SYMBOL(ieee80211_wx_set_rts);
+EXPORT_SYMBOL(ieee80211_wx_get_rts);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_essid);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_essid);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_rate);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_rate);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_wap);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_wap);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_mode);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_mode);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_scan);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_freq);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_freq);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_rawtx);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_name);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_power);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_power);
+EXPORT_SYMBOL_NOVERS(ieee80211_wlan_frequencies);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_rts);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_rts);
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
new file mode 100644
index 000000000000..7294572b990f
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
@@ -0,0 +1,947 @@
+/******************************************************************************
+
+ Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59
+ Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The full GNU General Public License is included in this distribution in the
+ file called LICENSE.
+
+ Contact Information:
+ James P. Ketrenos <ipw2100-admin@linux.intel.com>
+ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************
+
+ Few modifications for Realtek's Wi-Fi drivers by
+ Andrea Merello <andreamrl@tiscali.it>
+
+ A special thanks goes to Realtek for their support !
+
+******************************************************************************/
+
+#include <linux/compiler.h>
+//#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <asm/uaccess.h>
+#include <linux/if_vlan.h>
+
+#include "ieee80211.h"
+
+
+/*
+
+
+802.11 Data Frame
+
+
+802.11 frame_contorl for data frames - 2 bytes
+ ,-----------------------------------------------------------------------------------------.
+bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e |
+ |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
+val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x |
+ |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
+desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep |
+ | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | |
+ '-----------------------------------------------------------------------------------------'
+ /\
+ |
+802.11 Data Frame |
+ ,--------- 'ctrl' expands to >-----------'
+ |
+ ,--'---,-------------------------------------------------------------.
+Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
+ |------|------|---------|---------|---------|------|---------|------|
+Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs |
+ | | tion | (BSSID) | | | ence | data | |
+ `--------------------------------------------------| |------'
+Total: 28 non-data bytes `----.----'
+ |
+ .- 'Frame data' expands to <---------------------------'
+ |
+ V
+ ,---------------------------------------------------.
+Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 |
+ |------|------|---------|----------|------|---------|
+Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP |
+ | DSAP | SSAP | | | | Packet |
+ | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | |
+ `-----------------------------------------| |
+Total: 8 non-data bytes `----.----'
+ |
+ .- 'IP Packet' expands, if WEP enabled, to <--'
+ |
+ V
+ ,-----------------------.
+Bytes | 4 | 0-2296 | 4 |
+ |-----|-----------|-----|
+Desc. | IV | Encrypted | ICV |
+ | | IP Packet | |
+ `-----------------------'
+Total: 8 non-data bytes
+
+
+802.3 Ethernet Data Frame
+
+ ,-----------------------------------------.
+Bytes | 6 | 6 | 2 | Variable | 4 |
+ |-------|-------|------|-----------|------|
+Desc. | Dest. | Source| Type | IP Packet | fcs |
+ | MAC | MAC | | | |
+ `-----------------------------------------'
+Total: 18 non-data bytes
+
+In the event that fragmentation is required, the incoming payload is split into
+N parts of size ieee->fts. The first fragment contains the SNAP header and the
+remaining packets are just data.
+
+If encryption is enabled, each fragment payload size is reduced by enough space
+to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
+So if you have 1500 bytes of payload with ieee->fts set to 500 without
+encryption it will take 3 frames. With WEP it will take 4 frames as the
+payload of each frame is reduced to 492 bytes.
+
+* SKB visualization
+*
+* ,- skb->data
+* |
+* | ETHERNET HEADER ,-<-- PAYLOAD
+* | | 14 bytes from skb->data
+* | 2 bytes for Type --> ,T. | (sizeof ethhdr)
+* | | | |
+* |,-Dest.--. ,--Src.---. | | |
+* | 6 bytes| | 6 bytes | | | |
+* v | | | | | |
+* 0 | v 1 | v | v 2
+* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+* ^ | ^ | ^ |
+* | | | | | |
+* | | | | `T' <---- 2 bytes for Type
+* | | | |
+* | | '---SNAP--' <-------- 6 bytes for SNAP
+* | |
+* `-IV--' <-------------------- 4 bytes for IV (WEP)
+*
+* SNAP HEADER
+*
+*/
+
+static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
+static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
+
+static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
+{
+ struct ieee80211_snap_hdr *snap;
+ u8 *oui;
+
+ snap = (struct ieee80211_snap_hdr *)data;
+ snap->dsap = 0xaa;
+ snap->ssap = 0xaa;
+ snap->ctrl = 0x03;
+
+ if (h_proto == 0x8137 || h_proto == 0x80f3)
+ oui = P802_1H_OUI;
+ else
+ oui = RFC1042_OUI;
+ snap->oui[0] = oui[0];
+ snap->oui[1] = oui[1];
+ snap->oui[2] = oui[2];
+
+ *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
+
+ return SNAP_SIZE + sizeof(u16);
+}
+
+int ieee80211_encrypt_fragment(
+ struct ieee80211_device *ieee,
+ struct sk_buff *frag,
+ int hdr_len)
+{
+ struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx];
+ int res;
+
+ if (!(crypt && crypt->ops))
+ {
+ printk("=========>%s(), crypt is null\n", __FUNCTION__);
+ return -1;
+ }
+#ifdef CONFIG_IEEE80211_CRYPT_TKIP
+ struct ieee80211_hdr *header;
+
+ if (ieee->tkip_countermeasures &&
+ crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
+ header = (struct ieee80211_hdr *) frag->data;
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+ "TX packet to " MAC_FMT "\n",
+ ieee->dev->name, MAC_ARG(header->addr1));
+ }
+ return -1;
+ }
+#endif
+ /* To encrypt, frame format is:
+ * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */
+
+ // PR: FIXME: Copied from hostap. Check fragmentation/MSDU/MPDU encryption.
+ /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
+ * call both MSDU and MPDU encryption functions from here. */
+ atomic_inc(&crypt->refcnt);
+ res = 0;
+ if (crypt->ops->encrypt_msdu)
+ res = crypt->ops->encrypt_msdu(frag, hdr_len, crypt->priv);
+ if (res == 0 && crypt->ops->encrypt_mpdu)
+ res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv);
+
+ atomic_dec(&crypt->refcnt);
+ if (res < 0) {
+ printk(KERN_INFO "%s: Encryption failed: len=%d.\n",
+ ieee->dev->name, frag->len);
+ ieee->ieee_stats.tx_discards++;
+ return -1;
+ }
+
+ return 0;
+}
+
+
+void ieee80211_txb_free(struct ieee80211_txb *txb) {
+ //int i;
+ if (unlikely(!txb))
+ return;
+#if 0
+ for (i = 0; i < txb->nr_frags; i++)
+ if (txb->fragments[i])
+ dev_kfree_skb_any(txb->fragments[i]);
+#endif
+ kfree(txb);
+}
+
+struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
+ int gfp_mask)
+{
+ struct ieee80211_txb *txb;
+ int i;
+ txb = kmalloc(
+ sizeof(struct ieee80211_txb) + (sizeof(u8*) * nr_frags),
+ gfp_mask);
+ if (!txb)
+ return NULL;
+
+ memset(txb, 0, sizeof(struct ieee80211_txb));
+ txb->nr_frags = nr_frags;
+ txb->frag_size = txb_size;
+
+ for (i = 0; i < nr_frags; i++) {
+ txb->fragments[i] = dev_alloc_skb(txb_size);
+ if (unlikely(!txb->fragments[i])) {
+ i--;
+ break;
+ }
+ memset(txb->fragments[i]->cb, 0, sizeof(txb->fragments[i]->cb));
+ }
+ if (unlikely(i != nr_frags)) {
+ while (i >= 0)
+ dev_kfree_skb_any(txb->fragments[i--]);
+ kfree(txb);
+ return NULL;
+ }
+ return txb;
+}
+
+// Classify the to-be send data packet
+// Need to acquire the sent queue index.
+static int
+ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
+{
+ struct ethhdr *eth;
+ struct iphdr *ip;
+ eth = (struct ethhdr *)skb->data;
+ if (eth->h_proto != htons(ETH_P_IP))
+ return 0;
+
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+ ip = ip_hdr(skb);
+#else
+ ip = (struct iphdr*)(skb->data + sizeof(struct ether_header));
+#endif
+ switch (ip->tos & 0xfc) {
+ case 0x20:
+ return 2;
+ case 0x40:
+ return 1;
+ case 0x60:
+ return 3;
+ case 0x80:
+ return 4;
+ case 0xa0:
+ return 5;
+ case 0xc0:
+ return 6;
+ case 0xe0:
+ return 7;
+ default:
+ return 0;
+ }
+}
+
+#define SN_LESS(a, b) (((a-b)&0x800)!=0)
+void ieee80211_tx_query_agg_cap(struct ieee80211_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ PTX_TS_RECORD pTxTs = NULL;
+ struct ieee80211_hdr_1addr* hdr = (struct ieee80211_hdr_1addr*)skb->data;
+
+ if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
+ return;
+ if (!IsQoSDataFrame(skb->data))
+ return;
+
+ if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1))
+ return;
+ //check packet and mode later
+#ifdef TO_DO_LIST
+ if(pTcb->PacketLength >= 4096)
+ return;
+ // For RTL819X, if pairwisekey = wep/tkip, we don't aggrregation.
+ if(!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter))
+ return;
+#endif
+
+ if(pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION)
+ return;
+
+#if 1
+ if(!ieee->GetNmodeSupportBySecCfg(ieee->dev))
+ {
+ return;
+ }
+#endif
+ if(pHTInfo->bCurrentAMPDUEnable)
+ {
+ if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true))
+ {
+ printk("===>can't get TS\n");
+ return;
+ }
+ if (pTxTs->TxAdmittedBARecord.bValid == false)
+ {
+ //as some AP will refuse our action frame until key handshake has been finished. WB
+ if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA))
+ ;
+ else
+ TsStartAddBaProcess(ieee, pTxTs);
+ goto FORCED_AGG_SETTING;
+ }
+ else if (pTxTs->bUsingBa == false)
+ {
+ if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096))
+ pTxTs->bUsingBa = true;
+ else
+ goto FORCED_AGG_SETTING;
+ }
+
+ if (ieee->iw_mode == IW_MODE_INFRA)
+ {
+ tcb_desc->bAMPDUEnable = true;
+ tcb_desc->ampdu_factor = pHTInfo->CurrentAMPDUFactor;
+ tcb_desc->ampdu_density = pHTInfo->CurrentMPDUDensity;
+ }
+ }
+FORCED_AGG_SETTING:
+ switch(pHTInfo->ForcedAMPDUMode )
+ {
+ case HT_AGG_AUTO:
+ break;
+
+ case HT_AGG_FORCE_ENABLE:
+ tcb_desc->bAMPDUEnable = true;
+ tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity;
+ tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor;
+ break;
+
+ case HT_AGG_FORCE_DISABLE:
+ tcb_desc->bAMPDUEnable = false;
+ tcb_desc->ampdu_density = 0;
+ tcb_desc->ampdu_factor = 0;
+ break;
+
+ }
+ return;
+}
+
+extern void ieee80211_qurey_ShortPreambleMode(struct ieee80211_device* ieee, cb_desc* tcb_desc)
+{
+ tcb_desc->bUseShortPreamble = false;
+ if (tcb_desc->data_rate == 2)
+ {//// 1M can only use Long Preamble. 11B spec
+ return;
+ }
+ else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
+ {
+ tcb_desc->bUseShortPreamble = true;
+ }
+ return;
+}
+extern void
+ieee80211_query_HTCapShortGI(struct ieee80211_device *ieee, cb_desc *tcb_desc)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ tcb_desc->bUseShortGI = false;
+
+ if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
+ return;
+
+ if(pHTInfo->bForcedShortGI)
+ {
+ tcb_desc->bUseShortGI = true;
+ return;
+ }
+
+ if((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz)
+ tcb_desc->bUseShortGI = true;
+ else if((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz)
+ tcb_desc->bUseShortGI = true;
+}
+
+void ieee80211_query_BandwidthMode(struct ieee80211_device* ieee, cb_desc *tcb_desc)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ tcb_desc->bPacketBW = false;
+
+ if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
+ return;
+
+ if(tcb_desc->bMulticast || tcb_desc->bBroadcast)
+ return;
+
+ if((tcb_desc->data_rate & 0x80)==0) // If using legacy rate, it shall use 20MHz channel.
+ return;
+ //BandWidthAutoSwitch is for auto switch to 20 or 40 in long distance
+ if(pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz)
+ tcb_desc->bPacketBW = true;
+ return;
+}
+
+void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_desc, struct sk_buff* skb)
+{
+ // Common Settings
+ tcb_desc->bRTSSTBC = false;
+ tcb_desc->bRTSUseShortGI = false; // Since protection frames are always sent by legacy rate, ShortGI will never be used.
+ tcb_desc->bCTSEnable = false; // Most of protection using RTS/CTS
+ tcb_desc->RTSSC = 0; // 20MHz: Don't care; 40MHz: Duplicate.
+ tcb_desc->bRTSBW = false; // RTS frame bandwidth is always 20MHz
+
+ if(tcb_desc->bBroadcast || tcb_desc->bMulticast)//only unicast frame will use rts/cts
+ return;
+
+ if (is_broadcast_ether_addr(skb->data+16)) //check addr3 as infrastructure add3 is DA.
+ return;
+
+ if (ieee->mode < IEEE_N_24G) //b, g mode
+ {
+ // (1) RTS_Threshold is compared to the MPDU, not MSDU.
+ // (2) If there are more than one frag in this MSDU, only the first frag uses protection frame.
+ // Other fragments are protected by previous fragment.
+ // So we only need to check the length of first fragment.
+ if (skb->len > ieee->rts)
+ {
+ tcb_desc->bRTSEnable = true;
+ tcb_desc->rts_rate = MGN_24M;
+ }
+ else if (ieee->current_network.buseprotection)
+ {
+ // Use CTS-to-SELF in protection mode.
+ tcb_desc->bRTSEnable = true;
+ tcb_desc->bCTSEnable = true;
+ tcb_desc->rts_rate = MGN_24M;
+ }
+ //otherwise return;
+ return;
+ }
+ else
+ {// 11n High throughput case.
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ while (true)
+ {
+ //check IOT action
+ if(pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF)
+ {
+ tcb_desc->bCTSEnable = true;
+ tcb_desc->rts_rate = MGN_24M;
+#if defined(RTL8192SE) || defined(RTL8192SU)
+ tcb_desc->bRTSEnable = false;
+#else
+ tcb_desc->bRTSEnable = true;
+#endif
+ break;
+ }
+ else if(pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_PURE_N_MODE))
+ {
+ tcb_desc->bRTSEnable = true;
+ tcb_desc->rts_rate = MGN_24M;
+ break;
+ }
+ //check ERP protection
+ if (ieee->current_network.buseprotection)
+ {// CTS-to-SELF
+ tcb_desc->bRTSEnable = true;
+ tcb_desc->bCTSEnable = true;
+ tcb_desc->rts_rate = MGN_24M;
+ break;
+ }
+ //check HT op mode
+ if(pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT)
+ {
+ u8 HTOpMode = pHTInfo->CurrentOpMode;
+ if((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) ||
+ (!pHTInfo->bCurBW40MHz && HTOpMode == 3) )
+ {
+ tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps.
+ tcb_desc->bRTSEnable = true;
+ break;
+ }
+ }
+ //check rts
+ if (skb->len > ieee->rts)
+ {
+ tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps.
+ tcb_desc->bRTSEnable = true;
+ break;
+ }
+ //to do list: check MIMO power save condition.
+ //check AMPDU aggregation for TXOP
+ if(tcb_desc->bAMPDUEnable)
+ {
+ tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps.
+ // According to 8190 design, firmware sends CF-End only if RTS/CTS is enabled. However, it degrads
+ // throughput around 10M, so we disable of this mechanism. 2007.08.03 by Emily
+ tcb_desc->bRTSEnable = false;
+ break;
+ }
+ // Totally no protection case!!
+ goto NO_PROTECTION;
+ }
+ }
+ // For test , CTS replace with RTS
+ if( 0 )
+ {
+ tcb_desc->bCTSEnable = true;
+ tcb_desc->rts_rate = MGN_24M;
+ tcb_desc->bRTSEnable = true;
+ }
+ if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
+ tcb_desc->bUseShortPreamble = true;
+ if (ieee->mode == IW_MODE_MASTER)
+ goto NO_PROTECTION;
+ return;
+NO_PROTECTION:
+ tcb_desc->bRTSEnable = false;
+ tcb_desc->bCTSEnable = false;
+ tcb_desc->rts_rate = 0;
+ tcb_desc->RTSSC = 0;
+ tcb_desc->bRTSBW = false;
+}
+
+
+void ieee80211_txrate_selectmode(struct ieee80211_device* ieee, cb_desc* tcb_desc)
+{
+#ifdef TO_DO_LIST
+ if(!IsDataFrame(pFrame))
+ {
+ pTcb->bTxDisableRateFallBack = TRUE;
+ pTcb->bTxUseDriverAssingedRate = TRUE;
+ pTcb->RATRIndex = 7;
+ return;
+ }
+
+ if(pMgntInfo->ForcedDataRate!= 0)
+ {
+ pTcb->bTxDisableRateFallBack = TRUE;
+ pTcb->bTxUseDriverAssingedRate = TRUE;
+ return;
+ }
+#endif
+ if(ieee->bTxDisableRateFallBack)
+ tcb_desc->bTxDisableRateFallBack = true;
+
+ if(ieee->bTxUseDriverAssingedRate)
+ tcb_desc->bTxUseDriverAssingedRate = true;
+ if(!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate)
+ {
+ if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC)
+ tcb_desc->RATRIndex = 0;
+ }
+}
+
+void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u8* dst)
+{
+ if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst))
+ return;
+ if (IsQoSDataFrame(skb->data)) //we deal qos data only
+ {
+ PTX_TS_RECORD pTS = NULL;
+ if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, skb->priority, TX_DIR, true))
+ {
+ return;
+ }
+ pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096;
+ }
+}
+
+int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ struct ieee80211_device *ieee = netdev_priv(dev);
+#else
+ struct ieee80211_device *ieee = (struct ieee80211_device *)dev->priv;
+#endif
+ struct ieee80211_txb *txb = NULL;
+ struct ieee80211_hdr_3addrqos *frag_hdr;
+ int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
+ unsigned long flags;
+ struct net_device_stats *stats = &ieee->stats;
+ int ether_type = 0, encrypt;
+ int bytes, fc, qos_ctl = 0, hdr_len;
+ struct sk_buff *skb_frag;
+ struct ieee80211_hdr_3addrqos header = { /* Ensure zero initialized */
+ .duration_id = 0,
+ .seq_ctl = 0,
+ .qos_ctl = 0
+ };
+ u8 dest[ETH_ALEN], src[ETH_ALEN];
+ int qos_actived = ieee->current_network.qos_data.active;
+
+ struct ieee80211_crypt_data* crypt;
+
+ cb_desc *tcb_desc;
+
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ /* If there is no driver handler to take the TXB, dont' bother
+ * creating it... */
+ if ((!ieee->hard_start_xmit && !(ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE))||
+ ((!ieee->softmac_data_hard_start_xmit && (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) {
+ printk(KERN_WARNING "%s: No xmit handler.\n",
+ ieee->dev->name);
+ goto success;
+ }
+
+
+ if(likely(ieee->raw_tx == 0)){
+ if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
+ printk(KERN_WARNING "%s: skb too small (%d).\n",
+ ieee->dev->name, skb->len);
+ goto success;
+ }
+
+ memset(skb->cb, 0, sizeof(skb->cb));
+ ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
+
+ crypt = ieee->crypt[ieee->tx_keyidx];
+
+ encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
+ ieee->host_encrypt && crypt && crypt->ops;
+
+ if (!encrypt && ieee->ieee802_1x &&
+ ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
+ stats->tx_dropped++;
+ goto success;
+ }
+ #ifdef CONFIG_IEEE80211_DEBUG
+ if (crypt && !encrypt && ether_type == ETH_P_PAE) {
+ struct eapol *eap = (struct eapol *)(skb->data +
+ sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16));
+ IEEE80211_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n",
+ eap_get_type(eap->type));
+ }
+ #endif
+
+ /* Save source and destination addresses */
+ memcpy(&dest, skb->data, ETH_ALEN);
+ memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
+
+ /* Advance the SKB to the start of the payload */
+ skb_pull(skb, sizeof(struct ethhdr));
+
+ /* Determine total amount of storage required for TXB packets */
+ bytes = skb->len + SNAP_SIZE + sizeof(u16);
+
+ if (encrypt)
+ fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_WEP;
+ else
+
+ fc = IEEE80211_FTYPE_DATA;
+
+ //if(ieee->current_network.QoS_Enable)
+ if(qos_actived)
+ fc |= IEEE80211_STYPE_QOS_DATA;
+ else
+ fc |= IEEE80211_STYPE_DATA;
+
+ if (ieee->iw_mode == IW_MODE_INFRA) {
+ fc |= IEEE80211_FCTL_TODS;
+ /* To DS: Addr1 = BSSID, Addr2 = SA,
+ Addr3 = DA */
+ memcpy(&header.addr1, ieee->current_network.bssid, ETH_ALEN);
+ memcpy(&header.addr2, &src, ETH_ALEN);
+ memcpy(&header.addr3, &dest, ETH_ALEN);
+ } else if (ieee->iw_mode == IW_MODE_ADHOC) {
+ /* not From/To DS: Addr1 = DA, Addr2 = SA,
+ Addr3 = BSSID */
+ memcpy(&header.addr1, dest, ETH_ALEN);
+ memcpy(&header.addr2, src, ETH_ALEN);
+ memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
+ }
+
+ header.frame_ctl = cpu_to_le16(fc);
+
+ /* Determine fragmentation size based on destination (multicast
+ * and broadcast are not fragmented) */
+ if (is_multicast_ether_addr(header.addr1) ||
+ is_broadcast_ether_addr(header.addr1)) {
+ frag_size = MAX_FRAG_THRESHOLD;
+ qos_ctl |= QOS_CTL_NOTCONTAIN_ACK;
+ }
+ else {
+ frag_size = ieee->fts;//default:392
+ qos_ctl = 0;
+ }
+
+ //if (ieee->current_network.QoS_Enable)
+ if(qos_actived)
+ {
+ hdr_len = IEEE80211_3ADDR_LEN + 2;
+
+ skb->priority = ieee80211_classify(skb, &ieee->current_network);
+ qos_ctl |= skb->priority; //set in the ieee80211_classify
+ header.qos_ctl = cpu_to_le16(qos_ctl & IEEE80211_QOS_TID);
+ } else {
+ hdr_len = IEEE80211_3ADDR_LEN;
+ }
+ /* Determine amount of payload per fragment. Regardless of if
+ * this stack is providing the full 802.11 header, one will
+ * eventually be affixed to this fragment -- so we must account for
+ * it when determining the amount of payload space. */
+ bytes_per_frag = frag_size - hdr_len;
+ if (ieee->config &
+ (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
+ bytes_per_frag -= IEEE80211_FCS_LEN;
+
+ /* Each fragment may need to have room for encryptiong pre/postfix */
+ if (encrypt)
+ bytes_per_frag -= crypt->ops->extra_prefix_len +
+ crypt->ops->extra_postfix_len;
+
+ /* Number of fragments is the total bytes_per_frag /
+ * payload_per_fragment */
+ nr_frags = bytes / bytes_per_frag;
+ bytes_last_frag = bytes % bytes_per_frag;
+ if (bytes_last_frag)
+ nr_frags++;
+ else
+ bytes_last_frag = bytes_per_frag;
+
+ /* When we allocate the TXB we allocate enough space for the reserve
+ * and full fragment bytes (bytes_per_frag doesn't include prefix,
+ * postfix, header, FCS, etc.) */
+ txb = ieee80211_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC);
+ if (unlikely(!txb)) {
+ printk(KERN_WARNING "%s: Could not allocate TXB\n",
+ ieee->dev->name);
+ goto failed;
+ }
+ txb->encrypted = encrypt;
+ txb->payload_size = bytes;
+
+ //if (ieee->current_network.QoS_Enable)
+ if(qos_actived)
+ {
+ txb->queue_index = UP2AC(skb->priority);
+ } else {
+ txb->queue_index = WME_AC_BK;;
+ }
+
+
+
+ for (i = 0; i < nr_frags; i++) {
+ skb_frag = txb->fragments[i];
+ tcb_desc = (cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE);
+ if(qos_actived){
+ skb_frag->priority = skb->priority;//UP2AC(skb->priority);
+ tcb_desc->queue_index = UP2AC(skb->priority);
+ } else {
+ skb_frag->priority = WME_AC_BK;
+ tcb_desc->queue_index = WME_AC_BK;
+ }
+ skb_reserve(skb_frag, ieee->tx_headroom);
+
+ if (encrypt){
+ if (ieee->hwsec_active)
+ tcb_desc->bHwSec = 1;
+ else
+ tcb_desc->bHwSec = 0;
+ skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
+ }
+ else
+ {
+ tcb_desc->bHwSec = 0;
+ }
+ frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
+ memcpy(frag_hdr, &header, hdr_len);
+
+ /* If this is not the last fragment, then add the MOREFRAGS
+ * bit to the frame control */
+ if (i != nr_frags - 1) {
+ frag_hdr->frame_ctl = cpu_to_le16(
+ fc | IEEE80211_FCTL_MOREFRAGS);
+ bytes = bytes_per_frag;
+
+ } else {
+ /* The last fragment takes the remaining length */
+ bytes = bytes_last_frag;
+ }
+ //if(ieee->current_network.QoS_Enable)
+ if(qos_actived)
+ {
+ // add 1 only indicate to corresponding seq number control 2006/7/12
+ frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[UP2AC(skb->priority)+1]<<4 | i);
+ } else {
+ frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i);
+ }
+
+ /* Put a SNAP header on the first fragment */
+ if (i == 0) {
+ ieee80211_put_snap(
+ skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
+ ether_type);
+ bytes -= SNAP_SIZE + sizeof(u16);
+ }
+
+ memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
+
+ /* Advance the SKB... */
+ skb_pull(skb, bytes);
+
+ /* Encryption routine will move the header forward in order
+ * to insert the IV between the header and the payload */
+ if (encrypt)
+ ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
+ if (ieee->config &
+ (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
+ skb_put(skb_frag, 4);
+ }
+
+ if(qos_actived)
+ {
+ if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF)
+ ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0;
+ else
+ ieee->seq_ctrl[UP2AC(skb->priority) + 1]++;
+ } else {
+ if (ieee->seq_ctrl[0] == 0xFFF)
+ ieee->seq_ctrl[0] = 0;
+ else
+ ieee->seq_ctrl[0]++;
+ }
+ }else{
+ if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
+ printk(KERN_WARNING "%s: skb too small (%d).\n",
+ ieee->dev->name, skb->len);
+ goto success;
+ }
+
+ txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
+ if(!txb){
+ printk(KERN_WARNING "%s: Could not allocate TXB\n",
+ ieee->dev->name);
+ goto failed;
+ }
+
+ txb->encrypted = 0;
+ txb->payload_size = skb->len;
+ memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len);
+ }
+
+ success:
+//WB add to fill data tcb_desc here. only first fragment is considered, need to change, and you may remove to other place.
+ if (txb)
+ {
+#if 1
+ cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->bTxEnableFwCalcDur = 1;
+ if (is_multicast_ether_addr(header.addr1))
+ tcb_desc->bMulticast = 1;
+ if (is_broadcast_ether_addr(header.addr1))
+ tcb_desc->bBroadcast = 1;
+ ieee80211_txrate_selectmode(ieee, tcb_desc);
+ if ( tcb_desc->bMulticast || tcb_desc->bBroadcast)
+ tcb_desc->data_rate = ieee->basic_rate;
+ else
+ //tcb_desc->data_rate = CURRENT_RATE(ieee->current_network.mode, ieee->rate, ieee->HTCurrentOperaRate);
+ tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate);
+ ieee80211_qurey_ShortPreambleMode(ieee, tcb_desc);
+ ieee80211_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc);
+ ieee80211_query_HTCapShortGI(ieee, tcb_desc);
+ ieee80211_query_BandwidthMode(ieee, tcb_desc);
+ ieee80211_query_protectionmode(ieee, tcb_desc, txb->fragments[0]);
+ ieee80211_query_seqnum(ieee, txb->fragments[0], header.addr1);
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, txb->fragments[0]->data, txb->fragments[0]->len);
+ //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, tcb_desc, sizeof(cb_desc));
+#endif
+ }
+ spin_unlock_irqrestore(&ieee->lock, flags);
+ dev_kfree_skb_any(skb);
+ if (txb) {
+ if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
+ ieee80211_softmac_xmit(txb, ieee);
+ }else{
+ if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
+ stats->tx_packets++;
+ stats->tx_bytes += txb->payload_size;
+ return 0;
+ }
+ ieee80211_txb_free(txb);
+ }
+ }
+
+ return 0;
+
+ failed:
+ spin_unlock_irqrestore(&ieee->lock, flags);
+ netif_stop_queue(dev);
+ stats->tx_errors++;
+ return 1;
+
+}
+
+EXPORT_SYMBOL(ieee80211_txb_free);
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
new file mode 100644
index 000000000000..118dfe1c977f
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
@@ -0,0 +1,1032 @@
+/******************************************************************************
+
+ Copyright(c) 2004 Intel Corporation. All rights reserved.
+
+ Portions of this file are based on the WEP enablement code provided by the
+ Host AP project hostap-drivers v0.1.3
+ Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ <jkmaline@cc.hut.fi>
+ Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59
+ Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The full GNU General Public License is included in this distribution in the
+ file called LICENSE.
+
+ Contact Information:
+ James P. Ketrenos <ipw2100-admin@linux.intel.com>
+ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************/
+#include <linux/wireless.h>
+#include <linux/version.h>
+#include <linux/kmod.h>
+#include <linux/module.h>
+
+#include "ieee80211.h"
+#if 0
+static const char *ieee80211_modes[] = {
+ "?", "a", "b", "ab", "g", "ag", "bg", "abg"
+};
+#endif
+struct modes_unit {
+ char *mode_string;
+ int mode_size;
+};
+struct modes_unit ieee80211_modes[] = {
+ {"a",1},
+ {"b",1},
+ {"g",1},
+ {"?",1},
+ {"N-24G",5},
+ {"N-5G",4},
+};
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+static inline char *
+iwe_stream_add_event_rsl(char * stream, /* Stream of events */
+ char * ends, /* End of stream */
+ struct iw_event *iwe, /* Payload */
+ int event_len) /* Real size of payload */
+{
+ /* Check if it's possible */
+ if((stream + event_len) < ends) {
+ iwe->len = event_len;
+ ndelay(1); //new
+ memcpy(stream, (char *) iwe, event_len);
+ stream += event_len;
+ }
+ return stream;
+}
+#else
+#define iwe_stream_add_event_rsl iwe_stream_add_event
+#endif
+
+#define MAX_CUSTOM_LEN 64
+static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
+ char *start, char *stop,
+ struct ieee80211_network *network,
+ struct iw_request_info *info)
+{
+ char custom[MAX_CUSTOM_LEN];
+ char proto_name[IFNAMSIZ];
+ char *pname = proto_name;
+ char *p;
+ struct iw_event iwe;
+ int i, j;
+ u16 max_rate, rate;
+ static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
+
+ /* First entry *MUST* be the AP MAC address */
+ iwe.cmd = SIOCGIWAP;
+ iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+ memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_ADDR_LEN);
+#else
+ start = iwe_stream_add_event_rsl(start, stop, &iwe, IW_EV_ADDR_LEN);
+#endif
+ /* Remaining entries will be displayed in the order we provide them */
+
+ /* Add the ESSID */
+ iwe.cmd = SIOCGIWESSID;
+ iwe.u.data.flags = 1;
+// if (network->flags & NETWORK_EMPTY_ESSID) {
+ if (network->ssid_len == 0) {
+ iwe.u.data.length = sizeof("<hidden>");
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, "<hidden>");
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, "<hidden>");
+#endif
+ } else {
+ iwe.u.data.length = min(network->ssid_len, (u8)32);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
+#endif
+ }
+ /* Add the protocol name */
+ iwe.cmd = SIOCGIWNAME;
+ for(i=0; i<(sizeof(ieee80211_modes)/sizeof(ieee80211_modes[0])); i++) {
+ if(network->mode&(1<<i)) {
+ sprintf(pname,ieee80211_modes[i].mode_string,ieee80211_modes[i].mode_size);
+ pname +=ieee80211_modes[i].mode_size;
+ }
+ }
+ *pname = '\0';
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE802.11%s", proto_name);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_CHAR_LEN);
+#else
+ start = iwe_stream_add_event_rsl(start, stop, &iwe, IW_EV_CHAR_LEN);
+#endif
+ /* Add mode */
+ iwe.cmd = SIOCGIWMODE;
+ if (network->capability &
+ (WLAN_CAPABILITY_BSS | WLAN_CAPABILITY_IBSS)) {
+ if (network->capability & WLAN_CAPABILITY_BSS)
+ iwe.u.mode = IW_MODE_MASTER;
+ else
+ iwe.u.mode = IW_MODE_ADHOC;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN);
+#else
+ start = iwe_stream_add_event_rsl(start, stop, &iwe, IW_EV_UINT_LEN);
+#endif
+ }
+
+ /* Add frequency/channel */
+ iwe.cmd = SIOCGIWFREQ;
+/* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode);
+ iwe.u.freq.e = 3; */
+ iwe.u.freq.m = network->channel;
+ iwe.u.freq.e = 0;
+ iwe.u.freq.i = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN);
+#else
+ start = iwe_stream_add_event_rsl(start, stop, &iwe, IW_EV_FREQ_LEN);
+#endif
+ /* Add encryption capability */
+ iwe.cmd = SIOCGIWENCODE;
+ if (network->capability & WLAN_CAPABILITY_PRIVACY)
+ iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+ else
+ iwe.u.data.flags = IW_ENCODE_DISABLED;
+ iwe.u.data.length = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
+#endif
+ /* Add basic and extended rates */
+ max_rate = 0;
+ p = custom;
+ p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
+ for (i = 0, j = 0; i < network->rates_len; ) {
+ if (j < network->rates_ex_len &&
+ ((network->rates_ex[j] & 0x7F) <
+ (network->rates[i] & 0x7F)))
+ rate = network->rates_ex[j++] & 0x7F;
+ else
+ rate = network->rates[i++] & 0x7F;
+ if (rate > max_rate)
+ max_rate = rate;
+ p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
+ "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
+ }
+ for (; j < network->rates_ex_len; j++) {
+ rate = network->rates_ex[j] & 0x7F;
+ p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
+ "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
+ if (rate > max_rate)
+ max_rate = rate;
+ }
+
+ if (network->mode >= IEEE_N_24G)//add N rate here;
+ {
+ PHT_CAPABILITY_ELE ht_cap = NULL;
+ bool is40M = false, isShortGI = false;
+ u8 max_mcs = 0;
+ if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4))
+ ht_cap = (PHT_CAPABILITY_ELE)&network->bssht.bdHTCapBuf[4];
+ else
+ ht_cap = (PHT_CAPABILITY_ELE)&network->bssht.bdHTCapBuf[0];
+ is40M = (ht_cap->ChlWidth)?1:0;
+ isShortGI = (ht_cap->ChlWidth)?
+ ((ht_cap->ShortGI40Mhz)?1:0):
+ ((ht_cap->ShortGI20Mhz)?1:0);
+
+ max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, MCS_FILTER_ALL);
+ rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs&0x7f];
+ if (rate > max_rate)
+ max_rate = rate;
+ }
+#if 0
+ printk("max rate:%d ===basic rate:\n", max_rate);
+ for (i=0;i<network->rates_len;i++)
+ printk(" %x", network->rates[i]);
+ printk("\n=======extend rate\n");
+ for (i=0; i<network->rates_ex_len; i++)
+ printk(" %x", network->rates_ex[i]);
+ printk("\n");
+#endif
+ iwe.cmd = SIOCGIWRATE;
+ iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
+ iwe.u.bitrate.value = max_rate * 500000;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe,
+ IW_EV_PARAM_LEN);
+#else
+ start = iwe_stream_add_event_rsl(start, stop, &iwe,
+ IW_EV_PARAM_LEN);
+#endif
+ iwe.cmd = IWEVCUSTOM;
+ iwe.u.data.length = p - custom;
+ if (iwe.u.data.length)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, custom);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, custom);
+#endif
+ /* Add quality statistics */
+ /* TODO: Fix these values... */
+ iwe.cmd = IWEVQUAL;
+ iwe.u.qual.qual = network->stats.signal;
+ iwe.u.qual.level = network->stats.rssi;
+ iwe.u.qual.noise = network->stats.noise;
+ iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK;
+ if (!(network->stats.mask & IEEE80211_STATMASK_RSSI))
+ iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID;
+ if (!(network->stats.mask & IEEE80211_STATMASK_NOISE))
+ iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
+ if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL))
+ iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
+ iwe.u.qual.updated = 7;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN);
+#else
+ start = iwe_stream_add_event_rsl(start, stop, &iwe, IW_EV_QUAL_LEN);
+#endif
+ iwe.cmd = IWEVCUSTOM;
+ p = custom;
+
+ iwe.u.data.length = p - custom;
+ if (iwe.u.data.length)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, custom);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, custom);
+#endif
+#if (WIRELESS_EXT < 18)
+ if (ieee->wpa_enabled && network->wpa_ie_len){
+ char buf[MAX_WPA_IE_LEN * 2 + 30];
+ // printk("WPA IE\n");
+ u8 *p = buf;
+ p += sprintf(p, "wpa_ie=");
+ for (i = 0; i < network->wpa_ie_len; i++) {
+ p += sprintf(p, "%02x", network->wpa_ie[i]);
+ }
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ iwe.u.data.length = strlen(buf);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, buf);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, buf);
+#endif
+ }
+
+ if (ieee->wpa_enabled && network->rsn_ie_len){
+ char buf[MAX_WPA_IE_LEN * 2 + 30];
+
+ u8 *p = buf;
+ p += sprintf(p, "rsn_ie=");
+ for (i = 0; i < network->rsn_ie_len; i++) {
+ p += sprintf(p, "%02x", network->rsn_ie[i]);
+ }
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ iwe.u.data.length = strlen(buf);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, buf);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, buf);
+#endif
+ }
+#else
+ memset(&iwe, 0, sizeof(iwe));
+ if (network->wpa_ie_len)
+ {
+ char buf[MAX_WPA_IE_LEN];
+ memcpy(buf, network->wpa_ie, network->wpa_ie_len);
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = network->wpa_ie_len;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, buf);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, buf);
+#endif
+ }
+ memset(&iwe, 0, sizeof(iwe));
+ if (network->rsn_ie_len)
+ {
+ char buf[MAX_WPA_IE_LEN];
+ memcpy(buf, network->rsn_ie, network->rsn_ie_len);
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = network->rsn_ie_len;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, buf);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, buf);
+#endif
+ }
+#endif
+
+
+ /* Add EXTRA: Age to display seconds since last beacon/probe response
+ * for given network. */
+ iwe.cmd = IWEVCUSTOM;
+ p = custom;
+ p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
+ " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100));
+ iwe.u.data.length = p - custom;
+ if (iwe.u.data.length)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ start = iwe_stream_add_point(info, start, stop, &iwe, custom);
+#else
+ start = iwe_stream_add_point(start, stop, &iwe, custom);
+#endif
+
+ return start;
+}
+
+int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct ieee80211_network *network;
+ unsigned long flags;
+
+ char *ev = extra;
+// char *stop = ev + IW_SCAN_MAX_DATA;
+ char *stop = ev + wrqu->data.length;//IW_SCAN_MAX_DATA;
+ //char *stop = ev + IW_SCAN_MAX_DATA;
+ int i = 0;
+ int err = 0;
+ IEEE80211_DEBUG_WX("Getting scan\n");
+ down(&ieee->wx_sem);
+ spin_lock_irqsave(&ieee->lock, flags);
+
+ list_for_each_entry(network, &ieee->network_list, list) {
+ i++;
+ if((stop-ev)<200)
+ {
+ err = -E2BIG;
+ break;
+ }
+ if (ieee->scan_age == 0 ||
+ time_after(network->last_scanned + ieee->scan_age, jiffies))
+ ev = rtl819x_translate_scan(ieee, ev, stop, network, info);
+ else
+ IEEE80211_DEBUG_SCAN(
+ "Not showing network '%s ("
+ MAC_FMT ")' due to age (%lums).\n",
+ escape_essid(network->ssid,
+ network->ssid_len),
+ MAC_ARG(network->bssid),
+ (jiffies - network->last_scanned) / (HZ / 100));
+ }
+
+ spin_unlock_irqrestore(&ieee->lock, flags);
+ up(&ieee->wx_sem);
+ wrqu->data.length = ev - extra;
+ wrqu->data.flags = 0;
+
+ IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i);
+
+ return err;
+}
+
+int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
+{
+ struct iw_point *erq = &(wrqu->encoding);
+ struct net_device *dev = ieee->dev;
+ struct ieee80211_security sec = {
+ .flags = 0
+ };
+ int i, key, key_provided, len;
+ struct ieee80211_crypt_data **crypt;
+
+ IEEE80211_DEBUG_WX("SET_ENCODE\n");
+
+ key = erq->flags & IW_ENCODE_INDEX;
+ if (key) {
+ if (key > WEP_KEYS)
+ return -EINVAL;
+ key--;
+ key_provided = 1;
+ } else {
+ key_provided = 0;
+ key = ieee->tx_keyidx;
+ }
+
+ IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
+ "provided" : "default");
+ crypt = &ieee->crypt[key];
+
+ if (erq->flags & IW_ENCODE_DISABLED) {
+ if (key_provided && *crypt) {
+ IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
+ key);
+ ieee80211_crypt_delayed_deinit(ieee, crypt);
+ } else
+ IEEE80211_DEBUG_WX("Disabling encryption.\n");
+
+ /* Check all the keys to see if any are still configured,
+ * and if no key index was provided, de-init them all */
+ for (i = 0; i < WEP_KEYS; i++) {
+ if (ieee->crypt[i] != NULL) {
+ if (key_provided)
+ break;
+ ieee80211_crypt_delayed_deinit(
+ ieee, &ieee->crypt[i]);
+ }
+ }
+
+ if (i == WEP_KEYS) {
+ sec.enabled = 0;
+ sec.level = SEC_LEVEL_0;
+ sec.flags |= SEC_ENABLED | SEC_LEVEL;
+ }
+
+ goto done;
+ }
+
+
+
+ sec.enabled = 1;
+ sec.flags |= SEC_ENABLED;
+
+ if (*crypt != NULL && (*crypt)->ops != NULL &&
+ strcmp((*crypt)->ops->name, "WEP") != 0) {
+ /* changing to use WEP; deinit previously used algorithm
+ * on this key */
+ ieee80211_crypt_delayed_deinit(ieee, crypt);
+ }
+
+ if (*crypt == NULL) {
+ struct ieee80211_crypt_data *new_crypt;
+
+ /* take WEP into use */
+ new_crypt = kmalloc(sizeof(struct ieee80211_crypt_data),
+ GFP_KERNEL);
+ if (new_crypt == NULL)
+ return -ENOMEM;
+ memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+ new_crypt->ops = ieee80211_get_crypto_ops("WEP");
+ if (!new_crypt->ops) {
+ request_module("ieee80211_crypt_wep");
+ new_crypt->ops = ieee80211_get_crypto_ops("WEP");
+ }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
+#else
+ if (new_crypt->ops && try_inc_mod_count(new_crypt->ops->owner))
+#endif
+ new_crypt->priv = new_crypt->ops->init(key);
+
+ if (!new_crypt->ops || !new_crypt->priv) {
+ kfree(new_crypt);
+ new_crypt = NULL;
+
+ printk(KERN_WARNING "%s: could not initialize WEP: "
+ "load module ieee80211_crypt_wep\n",
+ dev->name);
+ return -EOPNOTSUPP;
+ }
+ *crypt = new_crypt;
+ }
+
+ /* If a new key was provided, set it up */
+ if (erq->length > 0) {
+ len = erq->length <= 5 ? 5 : 13;
+ memcpy(sec.keys[key], keybuf, erq->length);
+ if (len > erq->length)
+ memset(sec.keys[key] + erq->length, 0,
+ len - erq->length);
+ IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
+ key, escape_essid(sec.keys[key], len),
+ erq->length, len);
+ sec.key_sizes[key] = len;
+ (*crypt)->ops->set_key(sec.keys[key], len, NULL,
+ (*crypt)->priv);
+ sec.flags |= (1 << key);
+ /* This ensures a key will be activated if no key is
+ * explicitely set */
+ if (key == sec.active_key)
+ sec.flags |= SEC_ACTIVE_KEY;
+ ieee->tx_keyidx = key;
+
+ } else {
+ len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN,
+ NULL, (*crypt)->priv);
+ if (len == 0) {
+ /* Set a default key of all 0 */
+ printk("Setting key %d to all zero.\n",
+ key);
+
+ IEEE80211_DEBUG_WX("Setting key %d to all zero.\n",
+ key);
+ memset(sec.keys[key], 0, 13);
+ (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
+ (*crypt)->priv);
+ sec.key_sizes[key] = 13;
+ sec.flags |= (1 << key);
+ }
+
+ /* No key data - just set the default TX key index */
+ if (key_provided) {
+ IEEE80211_DEBUG_WX(
+ "Setting key %d to default Tx key.\n", key);
+ ieee->tx_keyidx = key;
+ sec.active_key = key;
+ sec.flags |= SEC_ACTIVE_KEY;
+ }
+ }
+
+ done:
+ ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED);
+ ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
+ sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
+ sec.flags |= SEC_AUTH_MODE;
+ IEEE80211_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ?
+ "OPEN" : "SHARED KEY");
+
+ /* For now we just support WEP, so only set that security level...
+ * TODO: When WPA is added this is one place that needs to change */
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
+
+ if (ieee->set_security)
+ ieee->set_security(dev, &sec);
+
+ /* Do not reset port if card is in Managed mode since resetting will
+ * generate new IEEE 802.11 authentication which may end up in looping
+ * with IEEE 802.1X. If your hardware requires a reset after WEP
+ * configuration (for example... Prism2), implement the reset_port in
+ * the callbacks structures used to initialize the 802.11 stack. */
+ if (ieee->reset_on_keychange &&
+ ieee->iw_mode != IW_MODE_INFRA &&
+ ieee->reset_port && ieee->reset_port(dev)) {
+ printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
+{
+ struct iw_point *erq = &(wrqu->encoding);
+ int len, key;
+ struct ieee80211_crypt_data *crypt;
+
+ IEEE80211_DEBUG_WX("GET_ENCODE\n");
+
+ if(ieee->iw_mode == IW_MODE_MONITOR)
+ return -1;
+
+ key = erq->flags & IW_ENCODE_INDEX;
+ if (key) {
+ if (key > WEP_KEYS)
+ return -EINVAL;
+ key--;
+ } else
+ key = ieee->tx_keyidx;
+
+ crypt = ieee->crypt[key];
+ erq->flags = key + 1;
+
+ if (crypt == NULL || crypt->ops == NULL) {
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_DISABLED;
+ return 0;
+ }
+#if 0
+ if (strcmp(crypt->ops->name, "WEP") != 0) {
+ /* only WEP is supported with wireless extensions, so just
+ * report that encryption is used */
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_ENABLED;
+ return 0;
+ }
+#endif
+ len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
+ erq->length = (len >= 0 ? len : 0);
+
+ erq->flags |= IW_ENCODE_ENABLED;
+
+ if (ieee->open_wep)
+ erq->flags |= IW_ENCODE_OPEN;
+ else
+ erq->flags |= IW_ENCODE_RESTRICTED;
+
+ return 0;
+}
+#if (WIRELESS_EXT >= 18)
+int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret = 0;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct net_device *dev = ieee->dev;
+ struct iw_point *encoding = &wrqu->encoding;
+ struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
+ int i, idx;
+ int group_key = 0;
+ const char *alg, *module;
+ struct ieee80211_crypto_ops *ops;
+ struct ieee80211_crypt_data **crypt;
+
+ struct ieee80211_security sec = {
+ .flags = 0,
+ };
+ //printk("======>encoding flag:%x,ext flag:%x, ext alg:%d\n", encoding->flags,ext->ext_flags, ext->alg);
+ idx = encoding->flags & IW_ENCODE_INDEX;
+ if (idx) {
+ if (idx < 1 || idx > WEP_KEYS)
+ return -EINVAL;
+ idx--;
+ } else
+ idx = ieee->tx_keyidx;
+
+ if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
+
+ crypt = &ieee->crypt[idx];
+
+ group_key = 1;
+ } else {
+ /* some Cisco APs use idx>0 for unicast in dynamic WEP */
+ //printk("not group key, flags:%x, ext->alg:%d\n", ext->ext_flags, ext->alg);
+ if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP)
+ return -EINVAL;
+ if (ieee->iw_mode == IW_MODE_INFRA)
+
+ crypt = &ieee->crypt[idx];
+
+ else
+ return -EINVAL;
+ }
+
+ sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT;
+ if ((encoding->flags & IW_ENCODE_DISABLED) ||
+ ext->alg == IW_ENCODE_ALG_NONE) {
+ if (*crypt)
+ ieee80211_crypt_delayed_deinit(ieee, crypt);
+
+ for (i = 0; i < WEP_KEYS; i++)
+
+ if (ieee->crypt[i] != NULL)
+
+ break;
+
+ if (i == WEP_KEYS) {
+ sec.enabled = 0;
+ // sec.encrypt = 0;
+ sec.level = SEC_LEVEL_0;
+ sec.flags |= SEC_LEVEL;
+ }
+ //printk("disabled: flag:%x\n", encoding->flags);
+ goto done;
+ }
+
+ sec.enabled = 1;
+ // sec.encrypt = 1;
+#if 0
+ if (group_key ? !ieee->host_mc_decrypt :
+ !(ieee->host_encrypt || ieee->host_decrypt ||
+ ieee->host_encrypt_msdu))
+ goto skip_host_crypt;
+#endif
+ switch (ext->alg) {
+ case IW_ENCODE_ALG_WEP:
+ alg = "WEP";
+ module = "ieee80211_crypt_wep";
+ break;
+ case IW_ENCODE_ALG_TKIP:
+ alg = "TKIP";
+ module = "ieee80211_crypt_tkip";
+ break;
+ case IW_ENCODE_ALG_CCMP:
+ alg = "CCMP";
+ module = "ieee80211_crypt_ccmp";
+ break;
+ default:
+ IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
+ dev->name, ext->alg);
+ ret = -EINVAL;
+ goto done;
+ }
+ printk("alg name:%s\n",alg);
+
+ ops = ieee80211_get_crypto_ops(alg);
+ if (ops == NULL) {
+ request_module(module);
+ ops = ieee80211_get_crypto_ops(alg);
+ }
+ if (ops == NULL) {
+ IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
+ dev->name, ext->alg);
+ printk("========>unknown crypto alg %d\n", ext->alg);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ if (*crypt == NULL || (*crypt)->ops != ops) {
+ struct ieee80211_crypt_data *new_crypt;
+
+ ieee80211_crypt_delayed_deinit(ieee, crypt);
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
+ new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
+#else
+ new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL);
+ memset(new_crypt,0,sizeof(*new_crypt));
+#endif
+ if (new_crypt == NULL) {
+ ret = -ENOMEM;
+ goto done;
+ }
+ new_crypt->ops = ops;
+ if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
+ new_crypt->priv = new_crypt->ops->init(idx);
+ if (new_crypt->priv == NULL) {
+ kfree(new_crypt);
+ ret = -EINVAL;
+ goto done;
+ }
+ *crypt = new_crypt;
+
+ }
+
+ if (ext->key_len > 0 && (*crypt)->ops->set_key &&
+ (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
+ (*crypt)->priv) < 0) {
+ IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name);
+ printk("key setting failed\n");
+ ret = -EINVAL;
+ goto done;
+ }
+#if 1
+ //skip_host_crypt:
+ //printk("skip_host_crypt:ext_flags:%x\n", ext->ext_flags);
+ if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
+ ieee->tx_keyidx = idx;
+ sec.active_key = idx;
+ sec.flags |= SEC_ACTIVE_KEY;
+ }
+
+ if (ext->alg != IW_ENCODE_ALG_NONE) {
+ //memcpy(sec.keys[idx], ext->key, ext->key_len);
+ sec.key_sizes[idx] = ext->key_len;
+ sec.flags |= (1 << idx);
+ if (ext->alg == IW_ENCODE_ALG_WEP) {
+ // sec.encode_alg[idx] = SEC_ALG_WEP;
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_1;
+ } else if (ext->alg == IW_ENCODE_ALG_TKIP) {
+ // sec.encode_alg[idx] = SEC_ALG_TKIP;
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_2;
+ } else if (ext->alg == IW_ENCODE_ALG_CCMP) {
+ // sec.encode_alg[idx] = SEC_ALG_CCMP;
+ sec.flags |= SEC_LEVEL;
+ sec.level = SEC_LEVEL_3;
+ }
+ /* Don't set sec level for group keys. */
+ if (group_key)
+ sec.flags &= ~SEC_LEVEL;
+ }
+#endif
+done:
+ if (ieee->set_security)
+ ieee->set_security(ieee->dev, &sec);
+
+ if (ieee->reset_on_keychange &&
+ ieee->iw_mode != IW_MODE_INFRA &&
+ ieee->reset_port && ieee->reset_port(dev)) {
+ IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name);
+ return -EINVAL;
+ }
+#endif
+ return ret;
+}
+
+int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_point *encoding = &wrqu->encoding;
+ struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
+ struct ieee80211_crypt_data *crypt;
+ int idx, max_key_len;
+
+ max_key_len = encoding->length - sizeof(*ext);
+ if (max_key_len < 0)
+ return -EINVAL;
+
+ idx = encoding->flags & IW_ENCODE_INDEX;
+ if (idx) {
+ if (idx < 1 || idx > WEP_KEYS)
+ return -EINVAL;
+ idx--;
+ } else
+ idx = ieee->tx_keyidx;
+
+ if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
+ ext->alg != IW_ENCODE_ALG_WEP)
+ if (idx != 0 || ieee->iw_mode != IW_MODE_INFRA)
+ return -EINVAL;
+
+ crypt = ieee->crypt[idx];
+ encoding->flags = idx + 1;
+ memset(ext, 0, sizeof(*ext));
+
+ if (crypt == NULL || crypt->ops == NULL ) {
+ ext->alg = IW_ENCODE_ALG_NONE;
+ ext->key_len = 0;
+ encoding->flags |= IW_ENCODE_DISABLED;
+ } else {
+ if (strcmp(crypt->ops->name, "WEP") == 0 )
+ ext->alg = IW_ENCODE_ALG_WEP;
+ else if (strcmp(crypt->ops->name, "TKIP"))
+ ext->alg = IW_ENCODE_ALG_TKIP;
+ else if (strcmp(crypt->ops->name, "CCMP"))
+ ext->alg = IW_ENCODE_ALG_CCMP;
+ else
+ return -EINVAL;
+ ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, NULL, crypt->priv);
+ encoding->flags |= IW_ENCODE_ENABLED;
+ if (ext->key_len &&
+ (ext->alg == IW_ENCODE_ALG_TKIP ||
+ ext->alg == IW_ENCODE_ALG_CCMP))
+ ext->ext_flags |= IW_ENCODE_EXT_TX_SEQ_VALID;
+
+ }
+
+ return 0;
+}
+
+int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct iw_mlme *mlme = (struct iw_mlme *) extra;
+ switch (mlme->cmd) {
+ case IW_MLME_DEAUTH:
+ case IW_MLME_DISASSOC:
+ ieee80211_disassociate(ieee);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+#endif
+ return 0;
+}
+
+int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
+ struct iw_request_info *info,
+ struct iw_param *data, char *extra)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ switch (data->flags & IW_AUTH_INDEX) {
+ case IW_AUTH_WPA_VERSION:
+ /*need to support wpa2 here*/
+ //printk("wpa version:%x\n", data->value);
+ break;
+ case IW_AUTH_CIPHER_PAIRWISE:
+ case IW_AUTH_CIPHER_GROUP:
+ case IW_AUTH_KEY_MGMT:
+ /*
+ * * Host AP driver does not use these parameters and allows
+ * * wpa_supplicant to control them internally.
+ * */
+ break;
+ case IW_AUTH_TKIP_COUNTERMEASURES:
+ ieee->tkip_countermeasures = data->value;
+ break;
+ case IW_AUTH_DROP_UNENCRYPTED:
+ ieee->drop_unencrypted = data->value;
+ break;
+
+ case IW_AUTH_80211_AUTH_ALG:
+ //printk("======>%s():data->value is %d\n",__FUNCTION__,data->value);
+ // ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM)?1:0;
+ if(data->value & IW_AUTH_ALG_SHARED_KEY){
+ ieee->open_wep = 0;
+ ieee->auth_mode = 1;
+ }
+ else if(data->value & IW_AUTH_ALG_OPEN_SYSTEM){
+ ieee->open_wep = 1;
+ ieee->auth_mode = 0;
+ }
+ else if(data->value & IW_AUTH_ALG_LEAP){
+ ieee->open_wep = 1;
+ ieee->auth_mode = 2;
+ //printk("hahahaa:LEAP\n");
+ }
+ else
+ return -EINVAL;
+ //printk("open_wep:%d\n", ieee->open_wep);
+ break;
+
+#if 1
+ case IW_AUTH_WPA_ENABLED:
+ ieee->wpa_enabled = (data->value)?1:0;
+ //printk("enalbe wpa:%d\n", ieee->wpa_enabled);
+ break;
+
+#endif
+ case IW_AUTH_RX_UNENCRYPTED_EAPOL:
+ ieee->ieee802_1x = data->value;
+ break;
+ case IW_AUTH_PRIVACY_INVOKED:
+ ieee->privacy_invoked = data->value;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+#endif
+ return 0;
+}
+#endif
+#if 1
+int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#if 0
+ printk("====>%s()\n", __FUNCTION__);
+ {
+ int i;
+ for (i=0; i<len; i++)
+ printk("%2x ", ie[i]&0xff);
+ printk("\n");
+ }
+#endif
+ u8 *buf;
+
+ if (len>MAX_WPA_IE_LEN || (len && ie == NULL))
+ {
+ // printk("return error out, len:%d\n", len);
+ return -EINVAL;
+ }
+
+
+ if (len)
+ {
+ if (len != ie[1]+2)
+ {
+ printk("len:%d, ie:%d\n", len, ie[1]);
+ return -EINVAL;
+ }
+ buf = kmalloc(len, GFP_KERNEL);
+ if (buf == NULL)
+ return -ENOMEM;
+ memcpy(buf, ie, len);
+ kfree(ieee->wpa_ie);
+ ieee->wpa_ie = buf;
+ ieee->wpa_ie_len = len;
+ }
+ else{
+ if (ieee->wpa_ie)
+ kfree(ieee->wpa_ie);
+ ieee->wpa_ie = NULL;
+ ieee->wpa_ie_len = 0;
+ }
+#endif
+ return 0;
+
+}
+#endif
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+EXPORT_SYMBOL(ieee80211_wx_set_gen_ie);
+#if (WIRELESS_EXT >= 18)
+EXPORT_SYMBOL(ieee80211_wx_set_mlme);
+EXPORT_SYMBOL(ieee80211_wx_set_auth);
+EXPORT_SYMBOL(ieee80211_wx_set_encode_ext);
+EXPORT_SYMBOL(ieee80211_wx_get_encode_ext);
+#endif
+EXPORT_SYMBOL(ieee80211_wx_get_scan);
+EXPORT_SYMBOL(ieee80211_wx_set_encode);
+EXPORT_SYMBOL(ieee80211_wx_get_encode);
+#else
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_gen_ie);
+//EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_mlme);
+//EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_auth);
+//EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_encode_ext);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_scan);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_set_encode);
+EXPORT_SYMBOL_NOVERS(ieee80211_wx_get_encode);
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/internal.h b/drivers/staging/rtl8192su/ieee80211/internal.h
new file mode 100644
index 000000000000..ddc22350d006
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/internal.h
@@ -0,0 +1,115 @@
+/*
+ * Cryptographic API.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _CRYPTO_INTERNAL_H
+#define _CRYPTO_INTERNAL_H
+
+
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/init.h>
+#include <asm/hardirq.h>
+#include <asm/softirq.h>
+#include <asm/kmap_types.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ prefetch(pos->member.next); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member), \
+ prefetch(pos->member.next))
+
+static inline void cond_resched(void)
+{
+ if (need_resched()) {
+ set_current_state(TASK_RUNNING);
+ schedule();
+ }
+}
+#endif
+
+extern enum km_type crypto_km_types[];
+
+static inline enum km_type crypto_kmap_type(int out)
+{
+ return crypto_km_types[(in_softirq() ? 2 : 0) + out];
+}
+
+static inline void *crypto_kmap(struct page *page, int out)
+{
+ return kmap_atomic(page, crypto_kmap_type(out));
+}
+
+static inline void crypto_kunmap(void *vaddr, int out)
+{
+ kunmap_atomic(vaddr, crypto_kmap_type(out));
+}
+
+static inline void crypto_yield(struct crypto_tfm *tfm)
+{
+ if (!in_softirq())
+ cond_resched();
+}
+
+static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
+{
+ return (void *)&tfm[1];
+}
+
+struct crypto_alg *crypto_alg_lookup(const char *name);
+
+#ifdef CONFIG_KMOD
+void crypto_alg_autoload(const char *name);
+struct crypto_alg *crypto_alg_mod_lookup(const char *name);
+#else
+static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
+{
+ return crypto_alg_lookup(name);
+}
+#endif
+
+#ifdef CONFIG_CRYPTO_HMAC
+int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
+void crypto_free_hmac_block(struct crypto_tfm *tfm);
+#else
+static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
+{
+ return 0;
+}
+
+static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
+{ }
+#endif
+
+#ifdef CONFIG_PROC_FS
+void __init crypto_init_proc(void);
+#else
+static inline void crypto_init_proc(void)
+{ }
+#endif
+
+int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
+int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
+int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
+
+int crypto_init_digest_ops(struct crypto_tfm *tfm);
+int crypto_init_cipher_ops(struct crypto_tfm *tfm);
+int crypto_init_compress_ops(struct crypto_tfm *tfm);
+
+void crypto_exit_digest_ops(struct crypto_tfm *tfm);
+void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
+void crypto_exit_compress_ops(struct crypto_tfm *tfm);
+
+#endif /* _CRYPTO_INTERNAL_H */
+
diff --git a/drivers/staging/rtl8192su/ieee80211/kmap_types.h b/drivers/staging/rtl8192su/ieee80211/kmap_types.h
new file mode 100644
index 000000000000..de67bb01b5f5
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/kmap_types.h
@@ -0,0 +1,20 @@
+#ifndef __KMAP_TYPES_H
+
+#define __KMAP_TYPES_H
+
+
+enum km_type {
+ KM_BOUNCE_READ,
+ KM_SKB_SUNRPC_DATA,
+ KM_SKB_DATA_SOFTIRQ,
+ KM_USER0,
+ KM_USER1,
+ KM_BH_IRQ,
+ KM_SOFTIRQ0,
+ KM_SOFTIRQ1,
+ KM_TYPE_NR
+};
+
+#define _ASM_KMAP_TYPES_H
+
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/michael_mic.c b/drivers/staging/rtl8192su/ieee80211/michael_mic.c
new file mode 100644
index 000000000000..df256e487c20
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/michael_mic.c
@@ -0,0 +1,194 @@
+/*
+ * Cryptographic API
+ *
+ * Michael MIC (IEEE 802.11i/TKIP) keyed digest
+ *
+ * Copyright (c) 2004 Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+
+
+struct michael_mic_ctx {
+ u8 pending[4];
+ size_t pending_len;
+
+ u32 l, r;
+};
+
+
+static inline u32 rotl(u32 val, int bits)
+{
+ return (val << bits) | (val >> (32 - bits));
+}
+
+
+static inline u32 rotr(u32 val, int bits)
+{
+ return (val >> bits) | (val << (32 - bits));
+}
+
+
+static inline u32 xswap(u32 val)
+{
+ return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
+}
+
+
+#define michael_block(l, r) \
+do { \
+ r ^= rotl(l, 17); \
+ l += r; \
+ r ^= xswap(l); \
+ l += r; \
+ r ^= rotl(l, 3); \
+ l += r; \
+ r ^= rotr(l, 2); \
+ l += r; \
+} while (0)
+
+
+static inline u32 get_le32(const u8 *p)
+{
+ return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
+}
+
+
+static inline void put_le32(u8 *p, u32 v)
+{
+ p[0] = v;
+ p[1] = v >> 8;
+ p[2] = v >> 16;
+ p[3] = v >> 24;
+}
+
+
+static void michael_init(void *ctx)
+{
+ struct michael_mic_ctx *mctx = ctx;
+ mctx->pending_len = 0;
+}
+
+
+static void michael_update(void *ctx, const u8 *data, unsigned int len)
+{
+ struct michael_mic_ctx *mctx = ctx;
+
+ if (mctx->pending_len) {
+ int flen = 4 - mctx->pending_len;
+ if (flen > len)
+ flen = len;
+ memcpy(&mctx->pending[mctx->pending_len], data, flen);
+ mctx->pending_len += flen;
+ data += flen;
+ len -= flen;
+
+ if (mctx->pending_len < 4)
+ return;
+
+ mctx->l ^= get_le32(mctx->pending);
+ michael_block(mctx->l, mctx->r);
+ mctx->pending_len = 0;
+ }
+
+ while (len >= 4) {
+ mctx->l ^= get_le32(data);
+ michael_block(mctx->l, mctx->r);
+ data += 4;
+ len -= 4;
+ }
+
+ if (len > 0) {
+ mctx->pending_len = len;
+ memcpy(mctx->pending, data, len);
+ }
+}
+
+
+static void michael_final(void *ctx, u8 *out)
+{
+ struct michael_mic_ctx *mctx = ctx;
+ u8 *data = mctx->pending;
+
+ /* Last block and padding (0x5a, 4..7 x 0) */
+ switch (mctx->pending_len) {
+ case 0:
+ mctx->l ^= 0x5a;
+ break;
+ case 1:
+ mctx->l ^= data[0] | 0x5a00;
+ break;
+ case 2:
+ mctx->l ^= data[0] | (data[1] << 8) | 0x5a0000;
+ break;
+ case 3:
+ mctx->l ^= data[0] | (data[1] << 8) | (data[2] << 16) |
+ 0x5a000000;
+ break;
+ }
+ michael_block(mctx->l, mctx->r);
+ /* l ^= 0; */
+ michael_block(mctx->l, mctx->r);
+
+ put_le32(out, mctx->l);
+ put_le32(out + 4, mctx->r);
+}
+
+
+static int michael_setkey(void *ctx, const u8 *key, unsigned int keylen,
+ u32 *flags)
+{
+ struct michael_mic_ctx *mctx = ctx;
+ if (keylen != 8) {
+ if (flags)
+ *flags = CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+ mctx->l = get_le32(key);
+ mctx->r = get_le32(key + 4);
+ return 0;
+}
+
+
+static struct crypto_alg michael_mic_alg = {
+ .cra_name = "michael_mic",
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = 8,
+ .cra_ctxsize = sizeof(struct michael_mic_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(michael_mic_alg.cra_list),
+ .cra_u = { .digest = {
+ .dia_digestsize = 8,
+ .dia_init = michael_init,
+ .dia_update = michael_update,
+ .dia_final = michael_final,
+ .dia_setkey = michael_setkey } }
+};
+
+
+static int __init michael_mic_init(void)
+{
+ return crypto_register_alg(&michael_mic_alg);
+}
+
+
+static void __exit michael_mic_exit(void)
+{
+ crypto_unregister_alg(&michael_mic_alg);
+}
+
+
+module_init(michael_mic_init);
+module_exit(michael_mic_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Michael MIC");
+MODULE_AUTHOR("Jouni Malinen <jkmaline@cc.hut.fi>");
diff --git a/drivers/staging/rtl8192su/ieee80211/proc.c b/drivers/staging/rtl8192su/ieee80211/proc.c
new file mode 100644
index 000000000000..4f3f9ed7751a
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/proc.c
@@ -0,0 +1,116 @@
+/*
+ * Scatterlist Cryptographic API.
+ *
+ * Procfs information.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include <linux/init.h>
+//#include <linux/crypto.h>
+#include "rtl_crypto.h"
+#include <linux/rwsem.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include "internal.h"
+
+extern struct list_head crypto_alg_list;
+extern struct rw_semaphore crypto_alg_sem;
+
+static void *c_start(struct seq_file *m, loff_t *pos)
+{
+ struct list_head *v;
+ loff_t n = *pos;
+
+ down_read(&crypto_alg_sem);
+ list_for_each(v, &crypto_alg_list)
+ if (!n--)
+ return list_entry(v, struct crypto_alg, cra_list);
+ return NULL;
+}
+
+static void *c_next(struct seq_file *m, void *p, loff_t *pos)
+{
+ struct list_head *v = p;
+
+ (*pos)++;
+ v = v->next;
+ return (v == &crypto_alg_list) ?
+ NULL : list_entry(v, struct crypto_alg, cra_list);
+}
+
+static void c_stop(struct seq_file *m, void *p)
+{
+ up_read(&crypto_alg_sem);
+}
+
+static int c_show(struct seq_file *m, void *p)
+{
+ struct crypto_alg *alg = (struct crypto_alg *)p;
+
+ seq_printf(m, "name : %s\n", alg->cra_name);
+ seq_printf(m, "module : %s\n",
+ (alg->cra_module ?
+ alg->cra_module->name :
+ "kernel"));
+
+ switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
+ case CRYPTO_ALG_TYPE_CIPHER:
+ seq_printf(m, "type : cipher\n");
+ seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
+ seq_printf(m, "min keysize : %u\n",
+ alg->cra_cipher.cia_min_keysize);
+ seq_printf(m, "max keysize : %u\n",
+ alg->cra_cipher.cia_max_keysize);
+ break;
+
+ case CRYPTO_ALG_TYPE_DIGEST:
+ seq_printf(m, "type : digest\n");
+ seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
+ seq_printf(m, "digestsize : %u\n",
+ alg->cra_digest.dia_digestsize);
+ break;
+ case CRYPTO_ALG_TYPE_COMPRESS:
+ seq_printf(m, "type : compression\n");
+ break;
+ default:
+ seq_printf(m, "type : unknown\n");
+ break;
+ }
+
+ seq_putc(m, '\n');
+ return 0;
+}
+
+static struct seq_operations crypto_seq_ops = {
+ .start = c_start,
+ .next = c_next,
+ .stop = c_stop,
+ .show = c_show
+};
+
+static int crypto_info_open(struct inode *inode, struct file *file)
+{
+ return seq_open(file, &crypto_seq_ops);
+}
+
+static struct file_operations proc_crypto_ops = {
+ .open = crypto_info_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release
+};
+
+void __init crypto_init_proc(void)
+{
+ struct proc_dir_entry *proc;
+
+ proc = create_proc_entry("crypto", 0, NULL);
+ if (proc)
+ proc->proc_fops = &proc_crypto_ops;
+}
diff --git a/drivers/staging/rtl8192su/ieee80211/readme b/drivers/staging/rtl8192su/ieee80211/readme
new file mode 100644
index 000000000000..5764f2859286
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/readme
@@ -0,0 +1,162 @@
+What this layer should do
+
+- It mantain the old mechanism as alternative, so the
+ ipw2100 driver works with really few changes.
+- Encapsulate / Decapsulate ieee80211 packet
+- Handle fragmentation
+- Optionally provide an alterantive mechanism for netif queue stop/wake,
+ so that the ieee80211 layer will pass one fragment per time instead of
+ one txb struct per time. so the driver can stop the queue in the middle
+ of a packet.
+- Provide two different TX interfaces for cards that can handle management
+ frames on one HW queue, and data on another, and for cards that have only
+ one HW queue (the latter untested and very, very rough).
+- Optionally provide the logic for handling IBSS/MASTER/MONITOR/BSS modes
+ and for the channel, essid and wap get/set wireless extension requests.
+ so that the driver has only to change channel when the ieee stack tell it.
+- Optionally provide a scanning mechanism so that the driver has not to
+ worry about this, just implement the set channel calback and pass
+ frames to the upper layer
+- Optionally provide the bss client protocol handshaking (just with open
+ authentication)
+- Optionally provide the probe request send mechanism
+- Optionally provide the bss master mode logic to handle association
+ protocol (only open authentication) and probe responses.
+- SW wep encryption (with open authentication)
+- It collects some stats
+- It provides beacons to the card when it ask for them
+
+What this layer doesn't do (yet)
+- Perform shared authentication
+- Have full support for master mode (the AP should loop back in the air
+ frames from an associated client to another. This could be done easily
+ with few lines of code, and it is done in my previous version of the
+ stach, but a table of association must be keept and a disassociation
+ policy must be decided and implemented.
+- Handle cleanly the full ieee 802.11 protocol. In AP mode it never
+ disassociate clients, and it is really prone to always allow access.
+ In bss client mode it is a bit rough with AP deauth and disassoc requests.
+- It has not any entry point to view the collected stats.
+- Altought it takes care of the card supported rates in the management frame
+ it sends, support for rate changing on TXed packet is not complete.
+- Give up once associated in bss client mode (it never detect a
+ signal loss condition to disassociate and restart scanning)
+- Provide a mechanism for enabling the TX in monitor mode, so
+ userspace programs can TX raw packets.
+- Provide a mechanism for cards that need that the SW take care of beacon
+ TX completely, in sense that the SW has to enqueue by itself beacons
+ to the card so it TX them (if any...)
+APIs
+
+Callback functions in the original stack has been mantained.
+following has been added (from ieee80211.h)
+
+ /* Softmac-generated frames (mamagement) are TXed via this
+ * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
+ * not set. As some cards may have different HW queues that
+ * one might want to use for data and management frames
+ * the option to have two callbacks might be useful.
+ * This fucntion can't sleep.
+ */
+ int (*softmac_hard_start_xmit)(struct sk_buff *skb,
+ struct net_device *dev);
+
+ /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
+ * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
+ * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
+ * then also management frames are sent via this callback.
+ * This function can't sleep.
+ */
+ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
+ struct net_device *dev);
+
+ /* stops the HW queue for DATA frames. Useful to avoid
+ * waste time to TX data frame when we are reassociating
+ * This function can sleep.
+ */
+ void (*data_hard_stop)(struct net_device *dev);
+
+ /* OK this is complementar to data_poll_hard_stop */
+ void (*data_hard_resume)(struct net_device *dev);
+
+ /* ask to the driver to retune the radio .
+ * This function can sleep. the driver should ensure
+ * the radio has been swithced before return.
+ */
+ void (*set_chan)(struct net_device *dev,short ch);
+
+ /* These are not used if the ieee stack takes care of
+ * scanning (IEEE_SOFTMAC_SCAN feature set).
+ * In this case only the set_chan is used.
+ *
+ * The syncro version is similar to the start_scan but
+ * does not return until all channels has been scanned.
+ * this is called in user context and should sleep,
+ * it is called in a work_queue when swithcing to ad-hoc mode
+ * or in behalf of iwlist scan when the card is associated
+ * and root user ask for a scan.
+ * the fucntion stop_scan should stop both the syncro and
+ * background scanning and can sleep.
+ * The fucntion start_scan should initiate the background
+ * scanning and can't sleep.
+ */
+ void (*scan_syncro)(struct net_device *dev);
+ void (*start_scan)(struct net_device *dev);
+ void (*stop_scan)(struct net_device *dev);
+
+ /* indicate the driver that the link state is changed
+ * for example it may indicate the card is associated now.
+ * Driver might be interested in this to apply RX filter
+ * rules or simply light the LINK led
+ */
+ void (*link_change)(struct net_device *dev);
+
+Functions hard_data_[resume/stop] are optional and should not be used
+if the driver decides to uses data+management frames enqueue in a
+single HQ queue (thus using just the softmac_hard_data_start_xmit
+callback).
+
+Function that the driver can use are:
+
+ieee80211_get_beacon - this is called by the driver when
+ the HW needs a beacon.
+ieee80211_softmac_start_protocol - this should normally be called in the
+ driver open function
+ieee80211_softmac_stop_protocol - the opposite of the above
+ieee80211_wake_queue - this is similar to netif_wake_queue
+ieee80211_reset_queue - this throw away fragments pending(if any)
+ieee80211_stop_queue - this is similar to netif_stop_queue
+
+
+known BUGS:
+- When performing syncro scan (possiblily when swithcing to ad-hoc mode
+ and when running iwlist scan when associated) there is still an odd
+ behaviour.. I have not looked in this more accurately (yet).
+
+locking:
+locking is done by means of three structures.
+1- ieee->lock (by means of spin_[un]lock_irq[save/restore]
+2- ieee->wx_sem
+3- ieee->scan_sem
+
+the lock 1 is what protect most of the critical sections in the ieee stack.
+the lock 2 is used to avoid that more than one of the SET wireless extension
+handlers (as well as start/stop protocol function) are running at the same time.
+the lock 1 is used when we need to modify or read the shared data in the wx handlers.
+In other words the lock 2 will prevent one SET action will run across another SET
+action (by make sleep the 2nd one) but allow GET actions, while the lock 1
+make atomic those little shared data access in both GET and SET operation.
+So get operation will be never be delayed really: they will never sleep..
+Furthermore in the top of some SET operations a flag is set before acquiring
+the lock. This is an help to make the previous running SET operation to
+finish faster if needed (just in case the second one will totally undo the
+first, so there is not need to complete the 1st really.. ).
+The background scanning mechaninsm is protected by the lock 1 except for the
+workqueue. this wq is here just to let the set_chan callback sleep (I thinked it
+might be appreciated by USB network card driver developer). In this case the lock 3
+take its turn.
+Thus the stop function needs both the locks.
+Funny in the syncro scan the lock 2 play its role (as both the syncro_scan
+function and the stop scan function are called with this semaphore held).
+
+
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h
new file mode 100644
index 000000000000..8ddc8bf9dc26
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h
@@ -0,0 +1,69 @@
+#ifndef _BATYPE_H_
+#define _BATYPE_H_
+
+#define TOTAL_TXBA_NUM 16
+#define TOTAL_RXBA_NUM 16
+
+#define BA_SETUP_TIMEOUT 200
+#define BA_INACT_TIMEOUT 60000
+
+#define BA_POLICY_DELAYED 0
+#define BA_POLICY_IMMEDIATE 1
+
+#define ADDBA_STATUS_SUCCESS 0
+#define ADDBA_STATUS_REFUSED 37
+#define ADDBA_STATUS_INVALID_PARAM 38
+
+#define DELBA_REASON_QSTA_LEAVING 36
+#define DELBA_REASON_END_BA 37
+#define DELBA_REASON_UNKNOWN_BA 38
+#define DELBA_REASON_TIMEOUT 39
+/* whether need define BA Action frames here?
+struct ieee80211_ADDBA_Req{
+ struct ieee80211_header_data header;
+ u8 category;
+ u8
+} __attribute__ ((packed));
+*/
+//Is this need?I put here just to make it easier to define structure BA_RECORD //WB
+typedef union _SEQUENCE_CONTROL{
+ u16 ShortData;
+ struct
+ {
+ u16 FragNum:4;
+ u16 SeqNum:12;
+ }field;
+}SEQUENCE_CONTROL, *PSEQUENCE_CONTROL;
+
+typedef union _BA_PARAM_SET {
+ u8 charData[2];
+ u16 shortData;
+ struct {
+ u16 AMSDU_Support:1;
+ u16 BAPolicy:1;
+ u16 TID:4;
+ u16 BufferSize:10;
+ } field;
+} BA_PARAM_SET, *PBA_PARAM_SET;
+
+typedef union _DELBA_PARAM_SET {
+ u8 charData[2];
+ u16 shortData;
+ struct {
+ u16 Reserved:11;
+ u16 Initiator:1;
+ u16 TID:4;
+ } field;
+} DELBA_PARAM_SET, *PDELBA_PARAM_SET;
+
+typedef struct _BA_RECORD {
+ struct timer_list Timer;
+ u8 bValid;
+ u8 DialogToken;
+ BA_PARAM_SET BaParamSet;
+ u16 BaTimeoutValue;
+ SEQUENCE_CONTROL BaStartSeqCtrl;
+} BA_RECORD, *PBA_RECORD;
+
+#endif //end _BATYPE_H_
+
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
new file mode 100644
index 000000000000..cc5623a94b42
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
@@ -0,0 +1,781 @@
+/********************************************************************************************************************************
+ * This file is created to process BA Action Frame. According to 802.11 spec, there are 3 BA action types at all. And as BA is
+ * related to TS, this part need some struture defined in QOS side code. Also TX RX is going to be resturctured, so how to send
+ * ADDBAREQ ADDBARSP and DELBA packet is still on consideration. Temporarily use MANAGE QUEUE instead of Normal Queue.
+ * WB 2008-05-27
+ * *****************************************************************************************************************************/
+#include "ieee80211.h"
+#include "rtl819x_BA.h"
+
+/********************************************************************************************************************
+ *function: Activate BA entry. And if Time is nozero, start timer.
+ * input: PBA_RECORD pBA //BA entry to be enabled
+ * u16 Time //indicate time delay.
+ * output: none
+********************************************************************************************************************/
+void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time)
+{
+ pBA->bValid = true;
+ if(Time != 0)
+ mod_timer(&pBA->Timer, jiffies + MSECS(Time));
+}
+
+/********************************************************************************************************************
+ *function: deactivate BA entry, including its timer.
+ * input: PBA_RECORD pBA //BA entry to be disabled
+ * output: none
+********************************************************************************************************************/
+void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
+{
+ pBA->bValid = false;
+ del_timer_sync(&pBA->Timer);
+}
+/********************************************************************************************************************
+ *function: deactivete BA entry in Tx Ts, and send DELBA.
+ * input:
+ * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry.
+ * output: none
+ * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME
+********************************************************************************************************************/
+u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs)
+{
+ PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure
+ PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord;
+ u8 bSendDELBA = false;
+
+ // Delete pending BA
+ if(pPendingBa->bValid)
+ {
+ DeActivateBAEntry(ieee, pPendingBa);
+ bSendDELBA = true;
+ }
+
+ // Delete admitted BA
+ if(pAdmittedBa->bValid)
+ {
+ DeActivateBAEntry(ieee, pAdmittedBa);
+ bSendDELBA = true;
+ }
+
+ return bSendDELBA;
+}
+
+/********************************************************************************************************************
+ *function: deactivete BA entry in Tx Ts, and send DELBA.
+ * input:
+ * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry.
+ * output: none
+ * notice: As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above
+********************************************************************************************************************/
+u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs)
+{
+ PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord;
+ u8 bSendDELBA = false;
+
+ if(pBa->bValid)
+ {
+ DeActivateBAEntry(ieee, pBa);
+ bSendDELBA = true;
+ }
+
+ return bSendDELBA;
+}
+
+/********************************************************************************************************************
+ *function: reset BA entry
+ * input:
+ * PBA_RECORD pBA //entry to be reset
+ * output: none
+********************************************************************************************************************/
+void ResetBaEntry( PBA_RECORD pBA)
+{
+ pBA->bValid = false;
+ pBA->BaParamSet.shortData = 0;
+ pBA->BaTimeoutValue = 0;
+ pBA->DialogToken = 0;
+ pBA->BaStartSeqCtrl.ShortData = 0;
+}
+//These functions need porting here or not?
+/*******************************************************************************************************************************
+ *function: construct ADDBAREQ and ADDBARSP frame here together.
+ * input: u8* Dst //ADDBA frame's destination
+ * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA.
+ * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
+ * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
+ * output: none
+ * return: sk_buff* skb //return constructed skb to xmit
+*******************************************************************************************************************************/
+static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
+{
+ struct sk_buff *skb = NULL;
+ struct ieee80211_hdr_3addr* BAReq = NULL;
+ u8* tag = NULL;
+ u16 tmp = 0;
+ u16 len = ieee->tx_headroom + 9;
+ //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2))
+ IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:"MAC_FMT", ieee->dev:%p\n", __FUNCTION__, type, MAC_ARG(Dst), ieee->dev);
+ if (pBA == NULL||ieee == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee);
+ return NULL;
+ }
+ skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
+ if (skb == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+ return NULL;
+ }
+
+ memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
+ skb_reserve(skb, ieee->tx_headroom);
+
+ BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
+
+ memcpy(BAReq->addr1, Dst, ETH_ALEN);
+ memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
+
+ memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
+
+ BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
+
+ //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field
+ tag = (u8*)skb_put(skb, 9);
+ *tag ++= ACT_CAT_BA;
+ *tag ++= type;
+ // Dialog Token
+ *tag ++= pBA->DialogToken;
+
+ if (ACT_ADDBARSP == type)
+ {
+ // Status Code
+ printk("=====>to send ADDBARSP\n");
+ tmp = cpu_to_le16(StatusCode);
+ memcpy(tag, (u8*)&tmp, 2);
+ tag += 2;
+ }
+ // BA Parameter Set
+ tmp = cpu_to_le16(pBA->BaParamSet.shortData);
+ memcpy(tag, (u8*)&tmp, 2);
+ tag += 2;
+ // BA Timeout Value
+ tmp = cpu_to_le16(pBA->BaTimeoutValue);
+ memcpy(tag, (u8*)&tmp, 2);
+ tag += 2;
+
+ if (ACT_ADDBAREQ == type)
+ {
+ // BA Start SeqCtrl
+ memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2);
+ tag += 2;
+ }
+
+ IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
+ return skb;
+ //return NULL;
+}
+
+#if 0 //I try to merge ADDBA_REQ and ADDBA_RSP frames together..
+/********************************************************************************************************************
+ *function: construct ADDBAREQ frame
+ * input: u8* dst //ADDBARsp frame's destination
+ * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA_RSP.
+ * u16 StatusCode //status code.
+ * output: none
+ * return: sk_buff* skb //return constructed skb to xmit
+********************************************************************************************************************/
+static struct sk_buff* ieee80211_ADDBA_Rsp( IN struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
+{
+ OCTET_STRING osADDBAFrame, tmp;
+
+ FillOctetString(osADDBAFrame, Buffer, 0);
+ *pLength = 0;
+
+ ConstructMaFrameHdr(
+ Adapter,
+ Addr,
+ ACT_CAT_BA,
+ ACT_ADDBARSP,
+ &osADDBAFrame );
+
+ // Dialog Token
+ FillOctetString(tmp, &pBA->DialogToken, 1);
+ PacketAppendData(&osADDBAFrame, tmp);
+
+ // Status Code
+ FillOctetString(tmp, &StatusCode, 2);
+ PacketAppendData(&osADDBAFrame, tmp);
+
+ // BA Parameter Set
+ FillOctetString(tmp, &pBA->BaParamSet, 2);
+ PacketAppendData(&osADDBAFrame, tmp);
+
+ // BA Timeout Value
+ FillOctetString(tmp, &pBA->BaTimeoutValue, 2);
+ PacketAppendData(&osADDBAFrame, tmp);
+
+ *pLength = osADDBAFrame.Length;
+}
+#endif
+
+/********************************************************************************************************************
+ *function: construct DELBA frame
+ * input: u8* dst //DELBA frame's destination
+ * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
+ * TR_SELECT TxRxSelect //TX RX direction
+ * u16 ReasonCode //status code.
+ * output: none
+ * return: sk_buff* skb //return constructed skb to xmit
+********************************************************************************************************************/
+static struct sk_buff* ieee80211_DELBA(
+ struct ieee80211_device* ieee,
+ u8* dst,
+ PBA_RECORD pBA,
+ TR_SELECT TxRxSelect,
+ u16 ReasonCode
+ )
+{
+ DELBA_PARAM_SET DelbaParamSet;
+ struct sk_buff *skb = NULL;
+ struct ieee80211_hdr_3addr* Delba = NULL;
+ u8* tag = NULL;
+ u16 tmp = 0;
+ //len = head len + DELBA Parameter Set(2) + Reason Code(2)
+ u16 len = 6 + ieee->tx_headroom;
+
+ if (net_ratelimit())
+ IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __FUNCTION__, ReasonCode, MAC_ARG(dst));
+
+ memset(&DelbaParamSet, 0, 2);
+
+ DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0;
+ DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
+
+ skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
+ if (skb == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+ return NULL;
+ }
+// memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr));
+ skb_reserve(skb, ieee->tx_headroom);
+
+ Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
+
+ memcpy(Delba->addr1, dst, ETH_ALEN);
+ memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
+ memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
+ Delba->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
+
+ tag = (u8*)skb_put(skb, 6);
+
+ *tag ++= ACT_CAT_BA;
+ *tag ++= ACT_DELBA;
+
+ // DELBA Parameter Set
+ tmp = cpu_to_le16(DelbaParamSet.shortData);
+ memcpy(tag, (u8*)&tmp, 2);
+ tag += 2;
+ // Reason Code
+ tmp = cpu_to_le16(ReasonCode);
+ memcpy(tag, (u8*)&tmp, 2);
+ tag += 2;
+
+ IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
+ if (net_ratelimit())
+ IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__);
+ return skb;
+}
+
+/********************************************************************************************************************
+ *function: send ADDBAReq frame out
+ * input: u8* dst //ADDBAReq frame's destination
+ * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
+ * output: none
+ * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
+********************************************************************************************************************/
+void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA)
+{
+ struct sk_buff *skb = NULL;
+ skb = ieee80211_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); //construct ACT_ADDBAREQ frames so set statuscode zero.
+
+ if (skb)
+ {
+ softmac_mgmt_xmit(skb, ieee);
+ //add statistic needed here.
+ //and skb will be freed in softmac_mgmt_xmit(), so omit all dev_kfree_skb_any() outside softmac_mgmt_xmit()
+ //WB
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
+ }
+ return;
+}
+
+/********************************************************************************************************************
+ *function: send ADDBARSP frame out
+ * input: u8* dst //DELBA frame's destination
+ * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
+ * u16 StatusCode //RSP StatusCode
+ * output: none
+ * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
+********************************************************************************************************************/
+void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
+{
+ struct sk_buff *skb = NULL;
+ skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames
+ if (skb)
+ {
+ softmac_mgmt_xmit(skb, ieee);
+ //same above
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
+ }
+
+ return;
+
+}
+/********************************************************************************************************************
+ *function: send ADDBARSP frame out
+ * input: u8* dst //DELBA frame's destination
+ * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
+ * TR_SELECT TxRxSelect //TX or RX
+ * u16 ReasonCode //DEL ReasonCode
+ * output: none
+ * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
+********************************************************************************************************************/
+
+void ieee80211_send_DELBA(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode)
+{
+ struct sk_buff *skb = NULL;
+ skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames
+ if (skb)
+ {
+ softmac_mgmt_xmit(skb, ieee);
+ //same above
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
+ }
+ return ;
+}
+
+/********************************************************************************************************************
+ *function: RX ADDBAReq
+ * input: struct sk_buff * skb //incoming ADDBAReq skb.
+ * return: 0(pass), other(fail)
+ * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
+********************************************************************************************************************/
+int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
+{
+ struct ieee80211_hdr_3addr* req = NULL;
+ u16 rc = 0;
+ u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL;
+ PBA_RECORD pBA = NULL;
+ PBA_PARAM_SET pBaParamSet = NULL;
+ u16* pBaTimeoutVal = NULL;
+ PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
+ PRX_TS_RECORD pTS = NULL;
+
+ if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9));
+ return -1;
+ }
+
+ IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
+
+ req = ( struct ieee80211_hdr_3addr*) skb->data;
+ tag = (u8*)req;
+ dst = (u8*)(&req->addr2[0]);
+ tag += sizeof( struct ieee80211_hdr_3addr);
+ pDialogToken = tag + 2; //category+action
+ pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken
+ pBaTimeoutVal = (u16*)(tag + 5);
+ pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7);
+
+ printk("====================>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst));
+//some other capability is not ready now.
+ if( (ieee->current_network.qos_data.active == 0) ||
+ (ieee->pHTInfo->bCurrentHTSupport == false) ||
+ (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) //||
+ // (ieee->pStaQos->bEnableRxImmBA == false) )
+ {
+ rc = ADDBA_STATUS_REFUSED;
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport);
+ goto OnADDBAReq_Fail;
+ }
+ // Search for related traffic stream.
+ // If there is no matched TS, reject the ADDBA request.
+ if( !GetTs(
+ ieee,
+ (PTS_COMMON_INFO*)(&pTS),
+ dst,
+ (u8)(pBaParamSet->field.TID),
+ RX_DIR,
+ true) )
+ {
+ rc = ADDBA_STATUS_REFUSED;
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
+ goto OnADDBAReq_Fail;
+ }
+ pBA = &pTS->RxAdmittedBARecord;
+ // To Determine the ADDBA Req content
+ // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
+ // I want to check StartSeqCtrl to make sure when we start aggregation!!!
+ //
+ if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
+ {
+ rc = ADDBA_STATUS_INVALID_PARAM;
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__);
+ goto OnADDBAReq_Fail;
+ }
+ // Admit the ADDBA Request
+ //
+ DeActivateBAEntry(ieee, pBA);
+ pBA->DialogToken = *pDialogToken;
+ pBA->BaParamSet = *pBaParamSet;
+ pBA->BaTimeoutValue = *pBaTimeoutVal;
+ pBA->BaStartSeqCtrl = *pBaStartSeqCtrl;
+ //for half N mode we only aggregate 1 frame
+ if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)||
+ (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT))
+ pBA->BaParamSet.field.BufferSize = 1;
+ else
+ pBA->BaParamSet.field.BufferSize = 32;
+ ActivateBAEntry(ieee, pBA, 0);//pBA->BaTimeoutValue);
+ ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
+
+ // End of procedure.
+ return 0;
+
+OnADDBAReq_Fail:
+ {
+ BA_RECORD BA;
+ BA.BaParamSet = *pBaParamSet;
+ BA.BaTimeoutValue = *pBaTimeoutVal;
+ BA.DialogToken = *pDialogToken;
+ BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE;
+ ieee80211_send_ADDBARsp(ieee, dst, &BA, rc);
+ return 0; //we send RSP out.
+ }
+
+}
+
+/********************************************************************************************************************
+ *function: RX ADDBARSP
+ * input: struct sk_buff * skb //incoming ADDBAReq skb.
+ * return: 0(pass), other(fail)
+ * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
+********************************************************************************************************************/
+int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
+{
+ struct ieee80211_hdr_3addr* rsp = NULL;
+ PBA_RECORD pPendingBA, pAdmittedBA;
+ PTX_TS_RECORD pTS = NULL;
+ u8* dst = NULL, *pDialogToken = NULL, *tag = NULL;
+ u16* pStatusCode = NULL, *pBaTimeoutVal = NULL;
+ PBA_PARAM_SET pBaParamSet = NULL;
+ u16 ReasonCode;
+
+ if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9));
+ return -1;
+ }
+ rsp = ( struct ieee80211_hdr_3addr*)skb->data;
+ tag = (u8*)rsp;
+ dst = (u8*)(&rsp->addr2[0]);
+ tag += sizeof( struct ieee80211_hdr_3addr);
+ pDialogToken = tag + 2;
+ pStatusCode = (u16*)(tag + 3);
+ pBaParamSet = (PBA_PARAM_SET)(tag + 5);
+ pBaTimeoutVal = (u16*)(tag + 7);
+
+ // Check the capability
+ // Since we can always receive A-MPDU, we just check if it is under HT mode.
+ if( ieee->current_network.qos_data.active == 0 ||
+ ieee->pHTInfo->bCurrentHTSupport == false ||
+ ieee->pHTInfo->bCurrentAMPDUEnable == false )
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable);
+ ReasonCode = DELBA_REASON_UNKNOWN_BA;
+ goto OnADDBARsp_Reject;
+ }
+
+
+ //
+ // Search for related TS.
+ // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
+ //
+ if (!GetTs(
+ ieee,
+ (PTS_COMMON_INFO*)(&pTS),
+ dst,
+ (u8)(pBaParamSet->field.TID),
+ TX_DIR,
+ false) )
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
+ ReasonCode = DELBA_REASON_UNKNOWN_BA;
+ goto OnADDBARsp_Reject;
+ }
+
+ pTS->bAddBaReqInProgress = false;
+ pPendingBA = &pTS->TxPendingBARecord;
+ pAdmittedBA = &pTS->TxAdmittedBARecord;
+
+
+ //
+ // Check if related BA is waiting for setup.
+ // If not, reject by sending DELBA frame.
+ //
+ if((pAdmittedBA->bValid==true))
+ {
+ // Since BA is already setup, we ignore all other ADDBA Response.
+ IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
+ return -1;
+ }
+ else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken))
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
+ ReasonCode = DELBA_REASON_UNKNOWN_BA;
+ goto OnADDBARsp_Reject;
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode);
+ DeActivateBAEntry(ieee, pPendingBA);
+ }
+
+
+ if(*pStatusCode == ADDBA_STATUS_SUCCESS)
+ {
+ //
+ // Determine ADDBA Rsp content here.
+ // We can compare the value of BA parameter set that Peer returned and Self sent.
+ // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
+ //
+ if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
+ {
+ // Since this is a kind of ADDBA failed, we delay next ADDBA process.
+ pTS->bAddBaReqDelayed = true;
+ DeActivateBAEntry(ieee, pAdmittedBA);
+ ReasonCode = DELBA_REASON_END_BA;
+ goto OnADDBARsp_Reject;
+ }
+
+
+ //
+ // Admitted condition
+ //
+ pAdmittedBA->DialogToken = *pDialogToken;
+ pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal;
+ pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl;
+ pAdmittedBA->BaParamSet = *pBaParamSet;
+ DeActivateBAEntry(ieee, pAdmittedBA);
+ ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
+ }
+ else
+ {
+ // Delay next ADDBA process.
+ pTS->bAddBaReqDelayed = true;
+ }
+
+ // End of procedure
+ return 0;
+
+OnADDBARsp_Reject:
+ {
+ BA_RECORD BA;
+ BA.BaParamSet = *pBaParamSet;
+ ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
+ return 0;
+ }
+
+}
+
+/********************************************************************************************************************
+ *function: RX DELBA
+ * input: struct sk_buff * skb //incoming ADDBAReq skb.
+ * return: 0(pass), other(fail)
+ * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
+********************************************************************************************************************/
+int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
+{
+ struct ieee80211_hdr_3addr* delba = NULL;
+ PDELBA_PARAM_SET pDelBaParamSet = NULL;
+ u16* pReasonCode = NULL;
+ u8* dst = NULL;
+
+ if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 6));
+ return -1;
+ }
+
+ if(ieee->current_network.qos_data.active == 0 ||
+ ieee->pHTInfo->bCurrentHTSupport == false )
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport);
+ return -1;
+ }
+
+ IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
+ delba = ( struct ieee80211_hdr_3addr*)skb->data;
+ dst = (u8*)(&delba->addr2[0]);
+ delba += sizeof( struct ieee80211_hdr_3addr);
+ pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
+ pReasonCode = (u16*)(delba+4);
+
+ if(pDelBaParamSet->field.Initiator == 1)
+ {
+ PRX_TS_RECORD pRxTs;
+
+ if( !GetTs(
+ ieee,
+ (PTS_COMMON_INFO*)&pRxTs,
+ dst,
+ (u8)pDelBaParamSet->field.TID,
+ RX_DIR,
+ false) )
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__);
+ return -1;
+ }
+
+ RxTsDeleteBA(ieee, pRxTs);
+ }
+ else
+ {
+ PTX_TS_RECORD pTxTs;
+
+ if(!GetTs(
+ ieee,
+ (PTS_COMMON_INFO*)&pTxTs,
+ dst,
+ (u8)pDelBaParamSet->field.TID,
+ TX_DIR,
+ false) )
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__);
+ return -1;
+ }
+
+ pTxTs->bUsingBa = false;
+ pTxTs->bAddBaReqInProgress = false;
+ pTxTs->bAddBaReqDelayed = false;
+ del_timer_sync(&pTxTs->TsAddBaTimer);
+ //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer);
+ TxTsDeleteBA(ieee, pTxTs);
+ }
+ return 0;
+}
+
+//
+// ADDBA initiate. This can only be called by TX side.
+//
+void
+TsInitAddBA(
+ struct ieee80211_device* ieee,
+ PTX_TS_RECORD pTS,
+ u8 Policy,
+ u8 bOverwritePending
+ )
+{
+ PBA_RECORD pBA = &pTS->TxPendingBARecord;
+
+ if(pBA->bValid==true && bOverwritePending==false)
+ return;
+
+ // Set parameters to "Pending" variable set
+ DeActivateBAEntry(ieee, pBA);
+
+ pBA->DialogToken++; // DialogToken: Only keep the latest dialog token
+ pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!!
+ pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate
+ pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID
+ // BufferSize: This need to be set according to A-MPDU vector
+ pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector
+ pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer
+ pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later.
+
+ ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
+
+ ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA);
+}
+
+void
+TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect)
+{
+
+ if(TxRxSelect == TX_DIR)
+ {
+ PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo;
+
+ if(TxTsDeleteBA(ieee, pTxTs))
+ ieee80211_send_DELBA(
+ ieee,
+ pTsCommonInfo->Addr,
+ (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord),
+ TxRxSelect,
+ DELBA_REASON_END_BA);
+ }
+ else if(TxRxSelect == RX_DIR)
+ {
+ PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo;
+ if(RxTsDeleteBA(ieee, pRxTs))
+ ieee80211_send_DELBA(
+ ieee,
+ pTsCommonInfo->Addr,
+ &pRxTs->RxAdmittedBARecord,
+ TxRxSelect,
+ DELBA_REASON_END_BA );
+ }
+}
+/********************************************************************************************************************
+ *function: BA setup timer
+ * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
+ * return: NULL
+ * notice:
+********************************************************************************************************************/
+void BaSetupTimeOut(unsigned long data)
+{
+ PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
+
+ pTxTs->bAddBaReqInProgress = false;
+ pTxTs->bAddBaReqDelayed = true;
+ pTxTs->TxPendingBARecord.bValid = false;
+}
+
+void TxBaInactTimeout(unsigned long data)
+{
+ PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
+ struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
+ TxTsDeleteBA(ieee, pTxTs);
+ ieee80211_send_DELBA(
+ ieee,
+ pTxTs->TsCommonInfo.Addr,
+ &pTxTs->TxAdmittedBARecord,
+ TX_DIR,
+ DELBA_REASON_TIMEOUT);
+}
+
+void RxBaInactTimeout(unsigned long data)
+{
+ PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
+ struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
+
+ RxTsDeleteBA(ieee, pRxTs);
+ ieee80211_send_DELBA(
+ ieee,
+ pRxTs->TsCommonInfo.Addr,
+ &pRxTs->RxAdmittedBARecord,
+ RX_DIR,
+ DELBA_REASON_TIMEOUT);
+ return ;
+}
+
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
new file mode 100644
index 000000000000..16a7462d7dfb
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
@@ -0,0 +1,517 @@
+#ifndef _RTL819XU_HTTYPE_H_
+#define _RTL819XU_HTTYPE_H_
+
+//------------------------------------------------------------
+// The HT Capability element is present in beacons, association request,
+// reassociation request and probe response frames
+//------------------------------------------------------------
+
+//
+// Operation mode value
+//
+#define HT_OPMODE_NO_PROTECT 0
+#define HT_OPMODE_OPTIONAL 1
+#define HT_OPMODE_40MHZ_PROTECT 2
+#define HT_OPMODE_MIXED 3
+
+//
+// MIMO Power Save Setings
+//
+#define MIMO_PS_STATIC 0
+#define MIMO_PS_DYNAMIC 1
+#define MIMO_PS_NOLIMIT 3
+
+
+//
+// There should be 128 bits to cover all of the MCS rates. However, since
+// 8190 does not support too much rates, one integer is quite enough.
+//
+
+#define sHTCLng 4
+
+
+#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff
+#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00
+#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP
+
+
+typedef enum _HT_MCS_RATE{
+ HT_MCS0 = 0x00000001,
+ HT_MCS1 = 0x00000002,
+ HT_MCS2 = 0x00000004,
+ HT_MCS3 = 0x00000008,
+ HT_MCS4 = 0x00000010,
+ HT_MCS5 = 0x00000020,
+ HT_MCS6 = 0x00000040,
+ HT_MCS7 = 0x00000080,
+ HT_MCS8 = 0x00000100,
+ HT_MCS9 = 0x00000200,
+ HT_MCS10 = 0x00000400,
+ HT_MCS11 = 0x00000800,
+ HT_MCS12 = 0x00001000,
+ HT_MCS13 = 0x00002000,
+ HT_MCS14 = 0x00004000,
+ HT_MCS15 = 0x00008000,
+ // Do not define MCS32 here although 8190 support MCS32
+}HT_MCS_RATE,*PHT_MCS_RATE;
+
+//
+// Represent Channel Width in HT Capabilities
+//
+typedef enum _HT_CHANNEL_WIDTH{
+ HT_CHANNEL_WIDTH_20 = 0,
+ HT_CHANNEL_WIDTH_20_40 = 1,
+}HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH;
+
+//
+// Represent Extention Channel Offset in HT Capabilities
+// This is available only in 40Mhz mode.
+//
+typedef enum _HT_EXTCHNL_OFFSET{
+ HT_EXTCHNL_OFFSET_NO_EXT = 0,
+ HT_EXTCHNL_OFFSET_UPPER = 1,
+ HT_EXTCHNL_OFFSET_NO_DEF = 2,
+ HT_EXTCHNL_OFFSET_LOWER = 3,
+}HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET;
+
+typedef enum _CHNLOP{
+ CHNLOP_NONE = 0, // No Action now
+ CHNLOP_SCAN = 1, // Scan in progress
+ CHNLOP_SWBW = 2, // Bandwidth switching in progress
+ CHNLOP_SWCHNL = 3, // Software Channel switching in progress
+} CHNLOP, *PCHNLOP;
+
+// Determine if the Channel Operation is in progress
+#define CHHLOP_IN_PROGRESS(_pHTInfo) \
+ ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
+
+/*
+typedef union _HT_CAPABILITY{
+ u16 ShortData;
+ u8 CharData[2];
+ struct
+ {
+ u16 AdvCoding:1;
+ u16 ChlWidth:1;
+ u16 MimoPwrSave:2;
+ u16 GreenField:1;
+ u16 ShortGI20Mhz:1;
+ u16 ShortGI40Mhz:1;
+ u16 STBC:1;
+ u16 BeamForm:1;
+ u16 DelayBA:1;
+ u16 MaxAMSDUSize:1;
+ u16 DssCCk:1;
+ u16 PSMP:1;
+ u16 Rsvd:3;
+ }Field;
+}HT_CAPABILITY, *PHT_CAPABILITY;
+
+typedef union _HT_CAPABILITY_MACPARA{
+ u8 ShortData;
+ u8 CharData[1];
+ struct
+ {
+ u8 MaxRxAMPDU:2;
+ u8 MPDUDensity:2;
+ u8 Rsvd:4;
+ }Field;
+}HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA;
+*/
+
+typedef enum _HT_ACTION{
+ ACT_RECOMMAND_WIDTH = 0,
+ ACT_MIMO_PWR_SAVE = 1,
+ ACT_PSMP = 2,
+ ACT_SET_PCO_PHASE = 3,
+ ACT_MIMO_CHL_MEASURE = 4,
+ ACT_RECIPROCITY_CORRECT = 5,
+ ACT_MIMO_CSI_MATRICS = 6,
+ ACT_MIMO_NOCOMPR_STEER = 7,
+ ACT_MIMO_COMPR_STEER = 8,
+ ACT_ANTENNA_SELECT = 9,
+} HT_ACTION, *PHT_ACTION;
+
+
+/* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */
+typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{
+ SC_MODE_DUPLICATE = 0,
+ SC_MODE_LOWER = 1,
+ SC_MODE_UPPER = 2,
+ SC_MODE_FULL40MHZ = 3,
+}HT_BW40_SC_E;
+
+typedef struct _HT_CAPABILITY_ELE{
+
+ //HT capability info
+ u8 AdvCoding:1;
+ u8 ChlWidth:1;
+ u8 MimoPwrSave:2;
+ u8 GreenField:1;
+ u8 ShortGI20Mhz:1;
+ u8 ShortGI40Mhz:1;
+ u8 TxSTBC:1;
+ u8 RxSTBC:2;
+ u8 DelayBA:1;
+ u8 MaxAMSDUSize:1;
+ u8 DssCCk:1;
+ u8 PSMP:1;
+ u8 Rsvd1:1;
+ u8 LSigTxopProtect:1;
+
+ //MAC HT parameters info
+ u8 MaxRxAMPDUFactor:2;
+ u8 MPDUDensity:3;
+ u8 Rsvd2:3;
+
+ //Supported MCS set
+ u8 MCS[16];
+
+
+ //Extended HT Capability Info
+ u16 ExtHTCapInfo;
+
+ //TXBF Capabilities
+ u8 TxBFCap[4];
+
+ //Antenna Selection Capabilities
+ u8 ASCap;
+
+} __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE;
+
+//------------------------------------------------------------
+// The HT Information element is present in beacons
+// Only AP is required to include this element
+//------------------------------------------------------------
+
+typedef struct _HT_INFORMATION_ELE{
+ u8 ControlChl;
+
+ u8 ExtChlOffset:2;
+ u8 RecommemdedTxWidth:1;
+ u8 RIFS:1;
+ u8 PSMPAccessOnly:1;
+ u8 SrvIntGranularity:3;
+
+ u8 OptMode:2;
+ u8 NonGFDevPresent:1;
+ u8 Revd1:5;
+ u8 Revd2:8;
+
+ u8 Rsvd3:6;
+ u8 DualBeacon:1;
+ u8 DualCTSProtect:1;
+
+ u8 SecondaryBeacon:1;
+ u8 LSigTxopProtectFull:1;
+ u8 PcoActive:1;
+ u8 PcoPhase:1;
+ u8 Rsvd4:4;
+
+ u8 BasicMSC[16];
+} __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE;
+
+//
+// MIMO Power Save control field.
+// This is appear in MIMO Power Save Action Frame
+//
+typedef struct _MIMOPS_CTRL{
+ u8 MimoPsEnable:1;
+ u8 MimoPsMode:1;
+ u8 Reserved:6;
+} MIMOPS_CTRL, *PMIMOPS_CTRL;
+
+typedef enum _HT_SPEC_VER{
+ HT_SPEC_VER_IEEE = 0,
+ HT_SPEC_VER_EWC = 1,
+}HT_SPEC_VER, *PHT_SPEC_VER;
+
+typedef enum _HT_AGGRE_MODE_E{
+ HT_AGG_AUTO = 0,
+ HT_AGG_FORCE_ENABLE = 1,
+ HT_AGG_FORCE_DISABLE = 2,
+}HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E;
+
+//------------------------------------------------------------
+// The Data structure is used to keep HT related variables when card is
+// configured as non-AP STA mode. **Note** Current_xxx should be set
+// to default value in HTInitializeHTInfo()
+//------------------------------------------------------------
+
+typedef struct _RT_HIGH_THROUGHPUT{
+ u8 bEnableHT;
+ u8 bCurrentHTSupport;
+
+ u8 bRegBW40MHz; // Tx 40MHz channel capablity
+ u8 bCurBW40MHz; // Tx 40MHz channel capability
+
+ u8 bRegShortGI40MHz; // Tx Short GI for 40Mhz
+ u8 bCurShortGI40MHz; // Tx Short GI for 40MHz
+
+ u8 bRegShortGI20MHz; // Tx Short GI for 20MHz
+ u8 bCurShortGI20MHz; // Tx Short GI for 20MHz
+
+ u8 bRegSuppCCK; // Tx CCK rate capability
+ u8 bCurSuppCCK; // Tx CCK rate capability
+
+ // 802.11n spec version for "peer"
+ HT_SPEC_VER ePeerHTSpecVer;
+
+
+ // HT related information for "Self"
+ HT_CAPABILITY_ELE SelfHTCap; // This is HT cap element sent to peer STA, which also indicate HT Rx capabilities.
+ HT_INFORMATION_ELE SelfHTInfo; // This is HT info element sent to peer STA, which also indicate HT Rx capabilities.
+
+ // HT related information for "Peer"
+ u8 PeerHTCapBuf[32];
+ u8 PeerHTInfoBuf[32];
+
+
+ // A-MSDU related
+ u8 bAMSDU_Support; // This indicates Tx A-MSDU capability
+ u16 nAMSDU_MaxSize; // This indicates Tx A-MSDU capability
+ u8 bCurrent_AMSDU_Support; // This indicates Tx A-MSDU capability
+ u16 nCurrent_AMSDU_MaxSize; // This indicates Tx A-MSDU capability
+
+
+ // AMPDU related <2006.08.10 Emily>
+ u8 bAMPDUEnable; // This indicate Tx A-MPDU capability
+ u8 bCurrentAMPDUEnable; // This indicate Tx A-MPDU capability
+ u8 AMPDU_Factor; // This indicate Tx A-MPDU capability
+ u8 CurrentAMPDUFactor; // This indicate Tx A-MPDU capability
+ u8 MPDU_Density; // This indicate Tx A-MPDU capability
+ u8 CurrentMPDUDensity; // This indicate Tx A-MPDU capability
+
+ // Forced A-MPDU enable
+ HT_AGGRE_MODE_E ForcedAMPDUMode;
+ u8 ForcedAMPDUFactor;
+ u8 ForcedMPDUDensity;
+
+ // Forced A-MSDU enable
+ HT_AGGRE_MODE_E ForcedAMSDUMode;
+ u16 ForcedAMSDUMaxSize;
+
+ u8 bForcedShortGI;
+
+ u8 CurrentOpMode;
+
+ // MIMO PS related
+ u8 SelfMimoPs;
+ u8 PeerMimoPs;
+
+ // 40MHz Channel Offset settings.
+ HT_EXTCHNL_OFFSET CurSTAExtChnlOffset;
+ u8 bCurTxBW40MHz; // If we use 40 MHz to Tx
+ u8 PeerBandwidth;
+
+ // For Bandwidth Switching
+ u8 bSwBwInProgress;
+ CHNLOP ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15.
+ u8 SwBwStep;
+ //struct timer_list SwBwTimer; //moved to ieee80211_device. as timer_list need include some header file here.
+
+ // For Realtek proprietary A-MPDU factor for aggregation
+ u8 bRegRT2RTAggregation;
+ u8 RT2RT_HT_Mode;
+ u8 bCurrentRT2RTAggregation;
+ u8 bCurrentRT2RTLongSlotTime;
+ u8 szRT2RTAggBuffer[10];
+
+ // Rx Reorder control
+ u8 bRegRxReorderEnable;
+ u8 bCurRxReorderEnable;
+ u8 RxReorderWinSize;
+ u8 RxReorderPendingTime;
+ u16 RxReorderDropCounter;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ u8 UsbTxAggrNum;
+#endif
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ u8 UsbRxFwAggrEn;
+ u8 UsbRxFwAggrPageNum;
+ u8 UsbRxFwAggrPacketNum;
+ u8 UsbRxFwAggrTimeout;
+#endif
+
+ // Add for Broadcom(Linksys) IOT. Joseph
+ u8 bIsPeerBcm;
+
+ // For IOT issue.
+ u8 IOTPeer;
+ u32 IOTAction;
+ u8 IOTRaFunc;
+} __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT;
+
+
+//------------------------------------------------------------
+// The Data structure is used to keep HT related variable for "each Sta"
+// when card is configured as "AP mode"
+//------------------------------------------------------------
+
+typedef struct _RT_HTINFO_STA_ENTRY{
+ u8 bEnableHT;
+
+ u8 bSupportCck;
+
+ u16 AMSDU_MaxSize;
+
+ u8 AMPDU_Factor;
+ u8 MPDU_Density;
+
+ u8 HTHighestOperaRate;
+
+ u8 bBw40MHz;
+
+ u8 MimoPs;
+
+ u8 McsRateSet[16];
+
+
+}RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY;
+
+
+
+
+
+//------------------------------------------------------------
+// The Data structure is used to keep HT related variable for "each AP"
+// when card is configured as "STA mode"
+//------------------------------------------------------------
+
+typedef struct _BSS_HT{
+
+ u8 bdSupportHT;
+
+ // HT related elements
+ u8 bdHTCapBuf[32];
+ u16 bdHTCapLen;
+ u8 bdHTInfoBuf[32];
+ u16 bdHTInfoLen;
+
+ HT_SPEC_VER bdHTSpecVer;
+ //HT_CAPABILITY_ELE bdHTCapEle;
+ //HT_INFORMATION_ELE bdHTInfoEle;
+
+ u8 bdRT2RTAggregation;
+ u8 bdRT2RTLongSlotTime;
+ u8 RT2RT_HT_Mode;
+ bool bdHT1R;
+} __attribute__ ((packed)) BSS_HT, *PBSS_HT;
+
+typedef struct _MIMO_RSSI{
+ u32 EnableAntenna;
+ u32 AntennaA;
+ u32 AntennaB;
+ u32 AntennaC;
+ u32 AntennaD;
+ u32 Average;
+}MIMO_RSSI, *PMIMO_RSSI;
+
+typedef struct _MIMO_EVM{
+ u32 EVM1;
+ u32 EVM2;
+}MIMO_EVM, *PMIMO_EVM;
+
+typedef struct _FALSE_ALARM_STATISTICS{
+ u32 Cnt_Parity_Fail;
+ u32 Cnt_Rate_Illegal;
+ u32 Cnt_Crc8_fail;
+ u32 Cnt_all;
+}FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS;
+
+
+extern u8 MCS_FILTER_ALL[16];
+extern u8 MCS_FILTER_1SS[16];
+
+/* 2007/07/11 MH Modify the macro. Becaus STA may link with a N-AP. If we set
+ STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We have
+ to add a macro to judge wireless mode. */
+#define PICK_RATE(_nLegacyRate, _nMcsRate) \
+ (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate)
+/* 2007/07/12 MH We only define legacy and HT wireless mode now. */
+#define LEGACY_WIRELESS_MODE IEEE_MODE_MASK
+
+#define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \
+ ((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\
+ (LegacyRate):\
+ (PICK_RATE(LegacyRate, HTRate))
+
+
+
+// MCS Bw 40 {1~7, 12~15,32}
+#define RATE_ADPT_1SS_MASK 0xFF
+#define RATE_ADPT_2SS_MASK 0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily
+#define RATE_ADPT_MCS32_MASK 0x01
+
+#define IS_11N_MCS_RATE(rate) (rate&0x80)
+
+typedef enum _HT_AGGRE_SIZE{
+ HT_AGG_SIZE_8K = 0,
+ HT_AGG_SIZE_16K = 1,
+ HT_AGG_SIZE_32K = 2,
+ HT_AGG_SIZE_64K = 3,
+}HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E;
+
+/* Indicate different AP vendor for IOT issue */
+typedef enum _HT_IOT_PEER
+{
+ HT_IOT_PEER_UNKNOWN = 0,
+ HT_IOT_PEER_REALTEK = 1,
+ HT_IOT_PEER_REALTEK_92SE = 2,
+ HT_IOT_PEER_BROADCOM = 3,
+ HT_IOT_PEER_RALINK = 4,
+ HT_IOT_PEER_ATHEROS = 5,
+ HT_IOT_PEER_CISCO= 6,
+ HT_IOT_PEER_MARVELL=7,
+ HT_IOT_PEER_92U_SOFTAP = 8,
+ HT_IOT_PEER_SELF_SOFTAP = 9,
+ HT_IOT_PEER_MAX = 10,
+}HT_IOT_PEER_E, *PHTIOT_PEER_E;
+
+//
+// IOT Action for different AP
+//
+typedef enum _HT_IOT_ACTION{
+ HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001,
+ HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002,
+ HT_IOT_ACT_DISABLE_MCS14 = 0x00000004,
+ HT_IOT_ACT_DISABLE_MCS15 = 0x00000008,
+ HT_IOT_ACT_DISABLE_ALL_2SS = 0x00000010,
+ HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000020,
+ HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000040,
+ HT_IOT_ACT_CDD_FSYNC = 0x00000080,
+ HT_IOT_ACT_PURE_N_MODE = 0x00000100,
+ HT_IOT_ACT_FORCED_CTS2SELF = 0x00000200,
+ HT_IOT_ACT_FORCED_RTS = 0x00000400,
+ HT_IOT_ACT_AMSDU_ENABLE = 0x00000800,
+ HT_IOT_ACT_MID_HIGHPOWER = 0x00001000,
+ HT_IOT_ACT_REJECT_ADDBA_REQ = 0x00002000,
+ HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT = 0x00004000,
+ HT_IOT_ACT_EDCA_BIAS_ON_RX = 0x00008000,
+
+ HT_IOT_ACT_HYBRID_AGGREGATION = 0x00010000,
+ HT_IOT_ACT_DISABLE_SHORT_GI = 0x00020000,
+ HT_IOT_ACT_DISABLE_HIGH_POWER = 0x00040000,
+ HT_IOT_ACT_DISABLE_TX_40_MHZ = 0x00080000,
+ HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000,
+ HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000,
+}HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
+
+typedef enum _HT_IOT_RAFUNC{
+ HT_IOT_RAFUNC_PEER_1R = 0x01,
+ HT_IOT_RAFUNC_TX_AMSDU = 0x02,
+ HT_IOT_RAFUNC_DISABLE_ALL = 0x80,
+}HT_IOT_RAFUNC, *PHT_IOT_RAFUNC;
+
+typedef enum _RT_HT_CAP{
+ RT_HT_CAP_USE_TURBO_AGGR = 0x01,
+ RT_HT_CAP_USE_LONG_PREAMBLE = 0x02,
+ RT_HT_CAP_USE_AMPDU = 0x04,
+ RT_HT_CAP_USE_WOW = 0x8,
+ RT_HT_CAP_USE_SOFTAP = 0x10,
+ RT_HT_CAP_USE_92SE = 0x20,
+}RT_HT_CAPBILITY, *PRT_HT_CAPBILITY;
+
+#endif //_RTL819XU_HTTYPE_H_
+
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
new file mode 100644
index 000000000000..f357085f6643
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
@@ -0,0 +1,2037 @@
+
+//As this function is mainly ported from Windows driver, so leave the name little changed. If any confusion caused, tell me. Created by WB. 2008.05.08
+#include "ieee80211.h"
+#include "rtl819x_HT.h"
+u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+u16 MCS_DATA_RATE[2][2][77] =
+ { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260,
+ 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
+ 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
+ 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
+ 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, // Long GI, 20MHz
+ {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
+ 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578,
+ 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217,
+ 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289,
+ 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, // Short GI, 20MHz
+ { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
+ 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
+ 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
+ 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
+ 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz
+ {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
+ 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
+ 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
+ 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600,
+ 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } // Short GI, 40MHz
+ };
+
+static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
+static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
+static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
+static u8 NETGEAR834Bv2_BROADCOM[3] = {0x00, 0x1b, 0x2f};
+static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; //cosa 03202008
+static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
+static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
+static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
+static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
+static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0};
+static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91};
+static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
+static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
+// 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Shoud we put the
+// code in other place??
+//static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96};
+/********************************************************************************************************************
+ *function: This function update default settings in pHTInfo structure
+ * input: PRT_HIGH_THROUGHPUT pHTInfo
+ * output: none
+ * return: none
+ * notice: These value need be modified if any changes.
+ * *****************************************************************************************************************/
+void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ //const typeof( ((struct ieee80211_device *)0)->pHTInfo ) *__mptr = &pHTInfo;
+
+ //printk("pHTinfo:%p, &pHTinfo:%p, mptr:%p, offsetof:%x\n", pHTInfo, &pHTInfo, __mptr, offsetof(struct ieee80211_device, pHTInfo));
+ //printk("===>ieee:%p,\n", ieee);
+ // ShortGI support
+ pHTInfo->bRegShortGI20MHz= 1;
+ pHTInfo->bRegShortGI40MHz= 1;
+
+ // 40MHz channel support
+ pHTInfo->bRegBW40MHz = 1;
+
+ // CCK rate support in 40MHz channel
+ if(pHTInfo->bRegBW40MHz)
+ pHTInfo->bRegSuppCCK = 1;
+ else
+ pHTInfo->bRegSuppCCK = true;
+
+ // AMSDU related
+ pHTInfo->nAMSDU_MaxSize = 7935UL;
+ pHTInfo->bAMSDU_Support = 0;
+
+ // AMPDU related
+ pHTInfo->bAMPDUEnable = 1; //YJ,test,090311
+ pHTInfo->AMPDU_Factor = 2; //// 0: 2n13(8K), 1:2n14(16K), 2:2n15(32K), 3:2n16(64k)
+ pHTInfo->MPDU_Density = 0;// 0: No restriction, 1: 1/8usec, 2: 1/4usec, 3: 1/2usec, 4: 1usec, 5: 2usec, 6: 4usec, 7:8usec
+
+ // MIMO Power Save
+ pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.)
+ if(pHTInfo->SelfMimoPs == 2)
+ pHTInfo->SelfMimoPs = 3;
+ // 8190 only. Assign rate operation mode to firmware
+ ieee->bTxDisableRateFallBack = 0;
+ ieee->bTxUseDriverAssingedRate = 0;
+
+#ifdef TO_DO_LIST
+ // 8190 only. Assign duration operation mode to firmware
+ pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
+#endif
+ // 8190 only, Realtek proprietary aggregation mode
+ // Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
+ pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
+
+ // For Rx Reorder Control
+ pHTInfo->bRegRxReorderEnable = 1;//YJ,test,090311
+ pHTInfo->RxReorderWinSize = 64;
+ pHTInfo->RxReorderPendingTime = 30;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ pHTInfo->UsbTxAggrNum = 4;
+#endif
+#ifdef USB_RX_AGGREGATION_SUPPORT
+#ifdef RTL8192SU
+ pHTInfo->UsbRxFwAggrEn = 1;
+ pHTInfo->UsbRxFwAggrPageNum = 16;
+ pHTInfo->UsbRxFwAggrPacketNum = 8;
+ pHTInfo->UsbRxFwAggrTimeout = 4; ////usb rx FW aggregation timeout threshold.It's in units of 64us
+ // For page size of receive packet buffer.
+ pHTInfo->UsbRxPageSize= 128;
+#else
+ pHTInfo->UsbRxFwAggrEn = 1;
+ pHTInfo->UsbRxFwAggrPageNum = 24;
+ pHTInfo->UsbRxFwAggrPacketNum = 8;
+ pHTInfo->UsbRxFwAggrTimeout = 16; ////usb rx FW aggregation timeout threshold.It's in units of 64us
+#endif
+#endif
+
+
+}
+/********************************************************************************************************************
+ *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq)
+ * input: u8* CapIE //Capability IE to be printed out
+ * u8* TitleString //mainly print out caller function
+ * output: none
+ * return: none
+ * notice: Driver should not print out this message by default.
+ * *****************************************************************************************************************/
+void HTDebugHTCapability(u8* CapIE, u8* TitleString )
+{
+
+ static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
+ PHT_CAPABILITY_ELE pCapELE;
+
+ if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
+ {
+ //EWC IE
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
+ pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]);
+ }else
+ pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]);
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString );
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz");
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO");
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO");
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO");
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935");
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO");
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
+ pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
+ return;
+
+}
+/********************************************************************************************************************
+ *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp)
+ * input: u8* InfoIE //Capability IE to be printed out
+ * u8* TitleString //mainly print out caller function
+ * output: none
+ * return: none
+ * notice: Driver should not print out this message by default.
+ * *****************************************************************************************************************/
+void HTDebugHTInfo(u8* InfoIE, u8* TitleString)
+{
+
+ static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
+ PHT_INFORMATION_ELE pHTInfoEle;
+
+ if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
+ {
+ // Not EWC IE
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
+ pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]);
+ }else
+ pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]);
+
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Information Element>. Called by %s\n", TitleString);
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl);
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSenondary channel =");
+ switch(pHTInfoEle->ExtChlOffset)
+ {
+ case 0:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
+ break;
+ case 1:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
+ break;
+ case 2:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
+ break;
+ case 3:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
+ break;
+ }
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz");
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
+ switch(pHTInfoEle->OptMode)
+ {
+ case 0:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n");
+ break;
+ case 1:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n");
+ break;
+ case 2:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n");
+ break;
+ case 3:
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n");
+ break;
+ }
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\
+ pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]);
+ return;
+}
+
+/*
+* Return: true if station in half n mode and AP supports 40 bw
+*/
+bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
+{
+ bool retValue = false;
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
+ retValue = false;
+ else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw
+ retValue = false;
+ else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
+ retValue = false;
+ else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
+ retValue = true;
+ else
+ retValue = false;
+
+ return retValue;
+}
+
+bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
+{
+ bool retValue = false;
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
+ retValue = false;
+ else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
+ retValue = false;
+ else if(is40MHz) // ap support 40 bw
+ {
+ if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
+ retValue = true;
+ else
+ retValue = false;
+ }
+ else
+ {
+ if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
+ retValue = true;
+ else
+ retValue = false;
+ }
+
+ return retValue;
+}
+
+u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate)
+{
+
+ u8 is40MHz;
+ u8 isShortGI;
+
+ is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0;
+ isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0;
+
+ return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
+}
+
+
+u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0;
+ u8 isShortGI = (pHTInfo->bCurBW40MHz)?
+ ((pHTInfo->bCurShortGI40MHz)?1:0):
+ ((pHTInfo->bCurShortGI20MHz)?1:0);
+ return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
+}
+
+/********************************************************************************************************************
+ *function: This function returns current datarate.
+ * input: struct ieee80211_device* ieee
+ * u8 nDataRate
+ * output: none
+ * return: tx rate
+ * notice: quite unsure about how to use this function //wb
+ * *****************************************************************************************************************/
+u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate)
+{
+ //PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
+ u8 is40MHz = 0;
+ u8 isShortGI = 0;
+
+ if(nDataRate < 12)
+ {
+ return CCKOFDMRate[nDataRate];
+ }
+ else
+ {
+ if (nDataRate >= 0x10 && nDataRate <= 0x1f)//if(nDataRate > 11 && nDataRate < 28 )
+ {
+ is40MHz = 0;
+ isShortGI = 0;
+
+ // nDataRate = nDataRate - 12;
+ }
+ else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
+ {
+ is40MHz = 1;
+ isShortGI = 0;
+
+ //nDataRate = nDataRate - 28;
+ }
+ else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
+ {
+ is40MHz = 0;
+ isShortGI = 1;
+
+ //nDataRate = nDataRate - 44;
+ }
+ else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
+ {
+ is40MHz = 1;
+ isShortGI = 1;
+
+ //nDataRate = nDataRate - 60;
+ }
+ return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
+ }
+}
+
+
+
+bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee)
+{
+ bool retValue = false;
+ struct ieee80211_network* net = &ieee->current_network;
+#if 0
+ if(pMgntInfo->bHalfNMode == false)
+ retValue = false;
+ else
+#endif
+ if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
+ (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
+ (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
+ (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
+ (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
+ (net->ralink_cap_exist))
+ retValue = true;
+ else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
+ (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
+ (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
+ (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) ||
+ (net->broadcom_cap_exist))
+ retValue = true;
+ else if(net->bssht.bdRT2RTAggregation)
+ retValue = true;
+ else
+ retValue = false;
+
+ return retValue;
+}
+
+/********************************************************************************************************************
+ *function: This function returns peer IOT.
+ * input: struct ieee80211_device* ieee
+ * output: none
+ * return:
+ * notice:
+ * *****************************************************************************************************************/
+void HTIOTPeerDetermine(struct ieee80211_device* ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ struct ieee80211_network* net = &ieee->current_network;
+ //FIXME: need to decide 92U_SOFTAP //LZM,090320
+ if(net->bssht.bdRT2RTAggregation){
+ pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
+ if(net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){
+ pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE;
+ }
+ }
+ else if(net->broadcom_cap_exist)
+ pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
+ else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
+ (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
+ (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
+ (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) )
+ pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
+ else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
+ (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
+ (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
+ (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
+ (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
+ net->ralink_cap_exist)
+ pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
+ else if((net->atheros_cap_exist )||
+ (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)||
+ (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0))
+ pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
+ else if(memcmp(net->bssid, CISCO_BROADCOM, 3)==0)
+ pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
+ else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) ||
+ net->marvell_cap_exist)
+ pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL;
+ else
+ pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
+
+ IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer);
+}
+/********************************************************************************************************************
+ *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good
+ * at receiving MCS14~15 frame from some AP.
+ * input: struct ieee80211_device* ieee
+ * u8 * PeerMacAddr
+ * output: none
+ * return: return 1 if driver should declare MCS13 only(otherwise return 0)
+ * *****************************************************************************************************************/
+u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr)
+{
+ u8 ret = 0;
+#if 0
+ // Apply for 819u only
+#if (HAL_CODE_BASE==RTL8192 && DEV_BUS_TYPE==USB_INTERFACE)
+ if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
+ (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)
+ )
+ {
+ ret = 1;
+ }
+
+
+ if(pHTInfo->bCurrentRT2RTAggregation)
+ {
+ // The parameter of pHTInfo->bCurrentRT2RTAggregation must be decided previously
+ ret = 1;
+ }
+#endif
+#endif
+ return ret;
+ }
+
+
+/**
+* Function: HTIOTActIsDisableMCS15
+*
+* Overview: Check whether driver should declare capability of receving MCS15
+*
+* Input:
+* PADAPTER Adapter,
+*
+* Output: None
+* Return: true if driver should disable MCS15
+* 2008.04.15 Emily
+*/
+bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
+{
+ bool retValue = false;
+
+#ifdef TODO
+ // Apply for 819u only
+#if (HAL_CODE_BASE==RTL8192)
+
+#if (DEV_BUS_TYPE == USB_INTERFACE)
+ // Alway disable MCS15 by Jerry Chang's request.by Emily, 2008.04.15
+ retValue = true;
+#elif (DEV_BUS_TYPE == PCI_INTERFACE)
+ // Enable MCS15 if the peer is Cisco AP. by Emily, 2008.05.12
+// if(pBssDesc->bCiscoCapExist)
+// retValue = false;
+// else
+ retValue = false;
+#endif
+#endif
+#endif
+ // Jerry Chang suggest that 8190 1x2 does not need to disable MCS15
+
+ return retValue;
+}
+
+/**
+* Function: HTIOTActIsDisableMCSTwoSpatialStream
+*
+* Overview: Check whether driver should declare capability of receving All 2 ss packets
+*
+* Input:
+* PADAPTER Adapter,
+*
+* Output: None
+* Return: true if driver should disable all two spatial stream packet
+* 2008.04.21 Emily
+*/
+bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee)
+{
+ bool retValue = false;
+#ifdef TODO
+ // Apply for 819u only
+//#if (HAL_CODE_BASE==RTL8192)
+
+ //This rule only apply to Belkin(Ralink) AP
+ if(IS_UNDER_11N_AES_MODE(Adapter))
+ {
+ if((PlatformCompareMemory(PeerMacAddr, BELKINF5D8233V1_RALINK, 3)==0) ||
+ (PlatformCompareMemory(PeerMacAddr, PCI_RALINK, 3)==0) ||
+ (PlatformCompareMemory(PeerMacAddr, EDIMAX_RALINK, 3)==0))
+ {
+ //Set True to disable this function. Disable by default, Emily, 2008.04.23
+ retValue = false;
+ }
+ }
+
+//#endif
+#endif
+#if 1
+#if (defined(RTL8192SE) || (defined(RTL8192SU)))
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
+ {
+ if( (pHTInfo->IOTPeer != HT_IOT_PEER_ATHEROS) &&
+ (pHTInfo->IOTPeer != HT_IOT_PEER_UNKNOWN) &&
+ (pHTInfo->IOTPeer != HT_IOT_PEER_MARVELL) )
+ retValue = true;
+ }
+#endif
+#endif
+ return retValue;
+}
+
+/********************************************************************************************************************
+ *function: Check whether driver should disable EDCA turbo mode
+ * input: struct ieee80211_device* ieee
+ * u8* PeerMacAddr
+ * output: none
+ * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0)
+ * *****************************************************************************************************************/
+u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
+{
+ u8 retValue = false; // default enable EDCA Turbo mode.
+ // Set specific EDCA parameter for different AP in DM handler.
+
+ return retValue;
+#if 0
+ if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0)||
+ (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
+ (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
+ (memcmp(PeerMacAddr, NETGEAR834Bv2_BROADCOM, 3)==0))
+
+ {
+ retValue = 1; //Linksys disable EDCA turbo mode
+ }
+
+ return retValue;
+#endif
+}
+
+/********************************************************************************************************************
+ *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP
+ * input: struct ieee80211_network *network //current network we live
+ * output: none
+ * return: return 1 if true
+ * *****************************************************************************************************************/
+u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+
+ // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
+ // 2008/01/28 MH We must prevent that we select null bssid to link.
+
+ if(network->broadcom_cap_exist)
+ {
+ retValue = 1;
+ }
+
+ return retValue;
+}
+
+u8 HTIOTActIsForcedCTS2Self(struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+
+ if(network->marvell_cap_exist)
+ {
+ retValue = 1;
+ }
+
+ return retValue;
+}
+
+u8 HTIOTActIsForcedRTSCTS(struct ieee80211_device *ieee, struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+ printk("============>%s(), %d\n", __FUNCTION__, network->realtek_cap_exit);
+ // Force protection
+#if defined(RTL8192SE) || defined(RTL8192SU)
+ if(ieee->pHTInfo->bCurrentHTSupport)
+ {
+ //if(!network->realtek_cap_exit)
+ if((ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK)&&
+ (ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE))
+ {
+ if((ieee->pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) == 0)
+ retValue = 1;
+ }
+ }
+#endif
+ return retValue;
+}
+
+u8
+HTIOTActIsForcedAMSDU8K(struct ieee80211_device *ieee, struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+
+ return retValue;
+}
+
+u8 HTIOTActIsCCDFsync(u8* PeerMacAddr)
+{
+ u8 retValue = 0;
+#ifndef RTL8192SE
+ if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
+ (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
+ (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
+ {
+ retValue = 1;
+ }
+#endif
+ return retValue;
+}
+
+/*
+ * 819xS single chip b-cut series cannot handle BAR
+ */
+u8
+HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+ //if(IS_HARDWARE_TYPE_8192SE(Adapter) ||
+ // IS_HARDWARE_TYPE_8192SU(Adapter)
+ //)
+#if (defined RTL8192SE || defined RTL8192SU)
+ {
+ // Do not reject ADDBA REQ because some of the AP may
+ // keep on sending ADDBA REQ qhich cause DHCP fail or ping loss!
+ // by HPFan, 2008/12/30
+
+ //if(pBssDesc->Vender == HT_IOT_PEER_MARVELL)
+ // return FALSE;
+
+ }
+#endif
+
+ return retValue;
+
+}
+
+/*
+ * EDCA parameters bias on downlink
+ */
+ u8
+ HTIOTActIsEDCABiasRx(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+ //if(IS_HARDWARE_TYPE_8192SU(Adapter))
+#ifdef RTL8192SU
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ {
+//#if UNDER_VISTA
+// if(pBssDesc->Vender==HT_IOT_PEER_ATHEROS ||
+// pBssDesc->Vender==HT_IOT_PEER_RALINK)
+//#else
+ if(pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS ||
+ pHTInfo->IOTPeer==HT_IOT_PEER_BROADCOM ||
+ pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
+//#endif
+ return 1;
+
+ }
+#endif
+ return retValue;
+}
+
+u8
+HTIOTActDisableShortGI(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
+ {
+ if(network->bssht.bdHT1R)
+ retValue = 1;
+ }
+
+ return retValue;
+}
+
+u8
+HTIOTActDisableHighPower(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
+ {
+ if(network->bssht.bdHT1R)
+ retValue = 1;
+ }
+
+ return retValue;
+}
+
+void
+HTIOTActDetermineRaFunc(struct ieee80211_device* ieee, bool bPeerRx2ss)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL;
+
+ if(pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
+ pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R;
+
+ if(pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
+ pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
+
+ printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTRaFunc = %8.8x\n", pHTInfo->IOTRaFunc);
+}
+
+
+u8
+HTIOTActIsDisableTx40MHz(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+
+#if (defined RTL8192SU || defined RTL8192SE)
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
+ (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
+ (KEY_TYPE_WEP104 == ieee->group_key_type) ||
+ (KEY_TYPE_WEP40 == ieee->group_key_type) ||
+ (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
+ {
+ if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
+ retValue = 1;
+ }
+#endif
+
+ return retValue;
+}
+
+u8
+HTIOTActIsTxNoAggregation(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+
+#if (defined RTL8192SU || defined RTL8192SE)
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
+ (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
+ (KEY_TYPE_WEP104 == ieee->group_key_type) ||
+ (KEY_TYPE_WEP40 == ieee->group_key_type) ||
+ (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
+ {
+ if(pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK ||
+ pHTInfo->IOTPeer==HT_IOT_PEER_UNKNOWN)
+ retValue = 1;
+ }
+#endif
+
+ return retValue;
+}
+
+
+u8
+HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ u8 retValue = 0;
+
+#if (defined RTL8192SU || defined RTL8192SE)
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
+ (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
+ (KEY_TYPE_WEP104 == ieee->group_key_type) ||
+ (KEY_TYPE_WEP40 == ieee->group_key_type) ||
+ (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
+ {
+ if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
+ retValue = 1;
+ }
+#endif
+
+ return retValue;
+}
+
+
+bool HTIOCActAllowPeerAggOnePacket(struct ieee80211_device* ieee,struct ieee80211_network *network)
+{
+ bool retValue = false;
+#if defined(RTL8192SE) || defined(RTL8192SU)
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ {
+ if(pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL)
+ return true;
+
+ }
+#endif
+ return retValue;
+}
+
+void HTResetIOTSetting(
+ PRT_HIGH_THROUGHPUT pHTInfo
+)
+{
+ pHTInfo->IOTAction = 0;
+ pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
+ pHTInfo->IOTRaFunc = 0;
+}
+
+
+/********************************************************************************************************************
+ *function: Construct Capablility Element in Beacon... if HTEnable is turned on
+ * input: struct ieee80211_device* ieee
+ * u8* posHTCap //pointer to store Capability Ele
+ * u8* len //store length of CE
+ * u8 IsEncrypt //whether encrypt, needed further
+ * output: none
+ * return: none
+ * notice: posHTCap can't be null and should be initialized before.
+ * *****************************************************************************************************************/
+void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt)
+{
+ PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
+ PHT_CAPABILITY_ELE pCapELE = NULL;
+ //u8 bIsDeclareMCS13;
+
+ if ((posHTCap == NULL) || (pHT == NULL))
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
+ return;
+ }
+ memset(posHTCap, 0, *len);
+ if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
+ {
+ u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
+ memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
+ pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]);
+ }else
+ {
+ pCapELE = (PHT_CAPABILITY_ELE)posHTCap;
+ }
+
+
+ //HT capability info
+ pCapELE->AdvCoding = 0; // This feature is not supported now!!
+ if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+ {
+ pCapELE->ChlWidth = 0;
+ }
+ else
+ {
+ pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
+ }
+
+// pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
+ pCapELE->MimoPwrSave = pHT->SelfMimoPs;
+ pCapELE->GreenField = 0; // This feature is not supported now!!
+ pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!!
+ pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!!
+ //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r",
+ //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz);
+ pCapELE->TxSTBC = 1;
+ pCapELE->RxSTBC = 0;
+ pCapELE->DelayBA = 0; // Do not support now!!
+ pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
+ pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
+ pCapELE->PSMP = 0; // Do not support now!!
+ pCapELE->LSigTxopProtect = 0; // Do not support now!!
+
+
+ //MAC HT parameters info
+ // TODO: Nedd to take care of this part
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
+
+ if( IsEncrypt)
+ {
+ pCapELE->MPDUDensity = 7; // 8us
+ pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K
+ }
+ else
+ {
+ pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K
+ pCapELE->MPDUDensity = 0; // no density
+ }
+
+ //Supported MCS set
+ memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
+ if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
+ pCapELE->MCS[1] &= 0x7f;
+
+ if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
+ pCapELE->MCS[1] &= 0xbf;
+
+ if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
+ pCapELE->MCS[1] &= 0x00;
+
+ // 2008.06.12
+ // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
+ if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+ {
+ int i;
+ for(i = 1; i< 16; i++)
+ pCapELE->MCS[i] = 0;
+ }
+
+ //Extended HT Capability Info
+ memset(&pCapELE->ExtHTCapInfo, 0, 2);
+
+
+ //TXBF Capabilities
+ memset(pCapELE->TxBFCap, 0, 4);
+
+ //Antenna Selection Capabilities
+ pCapELE->ASCap = 0;
+//add 2 to give space for element ID and len when construct frames
+ if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
+ *len = 30 + 2;
+ else
+ *len = 26 + 2;
+
+
+
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTCap, *len -2);
+
+ //Print each field in detail. Driver should not print out this message by default
+// HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()");
+ return;
+
+}
+/********************************************************************************************************************
+ *function: Construct Information Element in Beacon... if HTEnable is turned on
+ * input: struct ieee80211_device* ieee
+ * u8* posHTCap //pointer to store Information Ele
+ * u8* len //store len of
+ * u8 IsEncrypt //whether encrypt, needed further
+ * output: none
+ * return: none
+ * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this
+ * *****************************************************************************************************************/
+void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt)
+{
+ PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
+ PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
+ if ((posHTInfo == NULL) || (pHTInfoEle == NULL))
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
+ return;
+ }
+
+ memset(posHTInfo, 0, *len);
+ if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported
+ {
+ pHTInfoEle->ControlChl = ieee->current_network.channel;
+ pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
+ (ieee->current_network.channel<=6)?
+ HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
+ pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
+ pHTInfoEle->RIFS = 0;
+ pHTInfoEle->PSMPAccessOnly = 0;
+ pHTInfoEle->SrvIntGranularity = 0;
+ pHTInfoEle->OptMode = pHT->CurrentOpMode;
+ pHTInfoEle->NonGFDevPresent = 0;
+ pHTInfoEle->DualBeacon = 0;
+ pHTInfoEle->SecondaryBeacon = 0;
+ pHTInfoEle->LSigTxopProtectFull = 0;
+ pHTInfoEle->PcoActive = 0;
+ pHTInfoEle->PcoPhase = 0;
+
+ memset(pHTInfoEle->BasicMSC, 0, 16);
+
+
+ *len = 22 + 2; //same above
+
+ }
+ else
+ {
+ //STA should not generate High Throughput Information Element
+ *len = 0;
+ }
+ //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTInfo, *len - 2);
+ //HTDebugHTInfo(posHTInfo, "HTConstructInforElement");
+ return;
+}
+
+/*
+ * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance
+ * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2
+ * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set
+ * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP
+ * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently
+ * at the same time.
+ *
+ * Frame Format
+ * Element ID Length OUI Type1 Reserved
+ * 1 byte 1 byte 3 bytes 1 byte 1 byte
+ *
+ * OUI = 0x00, 0xe0, 0x4c,
+ * Type = 0x02
+ * Reserved = 0x00
+ *
+ * 2007.8.21 by Emily
+*/
+/********************************************************************************************************************
+ *function: Construct Information Element in Beacon... in RT2RT condition
+ * input: struct ieee80211_device* ieee
+ * u8* posRT2RTAgg //pointer to store Information Ele
+ * u8* len //store len
+ * output: none
+ * return: none
+ * notice:
+ * *****************************************************************************************************************/
+void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len)
+{
+ if (posRT2RTAgg == NULL) {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
+ return;
+ }
+ memset(posRT2RTAgg, 0, *len);
+ *posRT2RTAgg++ = 0x00;
+ *posRT2RTAgg++ = 0xe0;
+ *posRT2RTAgg++ = 0x4c;
+ *posRT2RTAgg++ = 0x02;
+ *posRT2RTAgg++ = 0x01;
+ *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
+
+ if(ieee->bSupportRemoteWakeUp) {
+ *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
+ }
+
+ *len = 6 + 2;
+ return;
+#ifdef TODO
+#if(HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
+ /*
+ //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this
+ section of code.
+ if(IS_UNDER_11N_AES_MODE(Adapter))
+ {
+ posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU;
+ }else
+ {
+ posRT2RTAgg->Octet[5] &= 0xfb;
+ }
+ */
+
+#else
+ // Do Nothing
+#endif
+
+ posRT2RTAgg->Length = 6;
+#endif
+
+
+
+
+}
+
+
+/********************************************************************************************************************
+ *function: Pick the right Rate Adaptive table to use
+ * input: struct ieee80211_device* ieee
+ * u8* pOperateMCS //A pointer to MCS rate bitmap
+ * return: always we return true
+ * notice:
+ * *****************************************************************************************************************/
+u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
+{
+ u8 i;
+ if (pOperateMCS == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n");
+ return false;
+ }
+
+ switch(ieee->mode)
+ {
+ case IEEE_A:
+ case IEEE_B:
+ case IEEE_G:
+ //legacy rate routine handled at selectedrate
+
+ //no MCS rate
+ for(i=0;i<=15;i++){
+ pOperateMCS[i] = 0;
+ }
+ break;
+
+ case IEEE_N_24G: //assume CCK rate ok
+ case IEEE_N_5G:
+ // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G.
+ // Legacy part shall be handled at SelectRateSet().
+
+ //HT part
+ // TODO: may be different if we have different number of antenna
+ pOperateMCS[0] &=RATE_ADPT_1SS_MASK; //support MCS 0~7
+ pOperateMCS[1] &=RATE_ADPT_2SS_MASK;
+ pOperateMCS[3] &=RATE_ADPT_MCS32_MASK;
+ break;
+
+ //should never reach here
+ default:
+
+ break;
+
+ }
+
+ return true;
+}
+
+/*
+* Description:
+* This function will get the highest speed rate in input MCS set.
+*
+* /param Adapter Pionter to Adapter entity
+* pMCSRateSet Pointer to MCS rate bitmap
+* pMCSFilter Pointer to MCS rate filter
+*
+* /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter.
+*
+*/
+/********************************************************************************************************************
+ *function: This function will get the highest speed rate in input MCS set.
+ * input: struct ieee80211_device* ieee
+ * u8* pMCSRateSet //Pointer to MCS rate bitmap
+ * u8* pMCSFilter //Pointer to MCS rate filter
+ * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
+ * notice:
+ * *****************************************************************************************************************/
+u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter)
+{
+ u8 i, j;
+ u8 bitMap;
+ u8 mcsRate = 0;
+ u8 availableMcsRate[16];
+ if (pMCSRateSet == NULL || pMCSFilter == NULL)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
+ return false;
+ }
+ for(i=0; i<16; i++)
+ availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
+
+ for(i = 0; i < 16; i++)
+ {
+ if(availableMcsRate[i] != 0)
+ break;
+ }
+ if(i == 16)
+ return false;
+
+ for(i = 0; i < 16; i++)
+ {
+ if(availableMcsRate[i] != 0)
+ {
+ bitMap = availableMcsRate[i];
+ for(j = 0; j < 8; j++)
+ {
+ if((bitMap%2) != 0)
+ {
+ if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
+ mcsRate = (8*i+j);
+ }
+ bitMap = bitMap>>1;
+ }
+ }
+ }
+ return (mcsRate|0x80);
+}
+
+
+
+/*
+**
+**1.Filter our operation rate set with AP's rate set
+**2.shall reference channel bandwidth, STBC, Antenna number
+**3.generate rate adative table for firmware
+**David 20060906
+**
+** \pHTSupportedCap: the connected STA's supported rate Capability element
+*/
+u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperateMCS)
+{
+
+ u8 i=0;
+
+ // filter out operational rate set not supported by AP, the lenth of it is 16
+ for(i=0;i<=15;i++){
+ pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
+ }
+
+
+ // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number
+
+ // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet
+ // we also shall suggested the first start rate set according to our singal strength
+ HT_PickMCSRate(ieee, pOperateMCS);
+
+ // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
+ if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+ pOperateMCS[1] = 0;
+
+ //
+ // For RTL819X, we support only MCS0~15.
+ // And also, we do not know how to use MCS32 now.
+ //
+ for(i=2; i<=15; i++)
+ pOperateMCS[i] = 0;
+
+ return true;
+}
+void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
+#if 0
+//I need move this function to other places, such as rx?
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void HTOnAssocRsp_wq(struct work_struct *work)
+{
+ struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ht_onAssRsp);
+#else
+void HTOnAssocRsp_wq(struct ieee80211_device *ieee)
+{
+#endif
+#endif
+void HTOnAssocRsp(struct ieee80211_device *ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ PHT_CAPABILITY_ELE pPeerHTCap = NULL;
+ PHT_INFORMATION_ELE pPeerHTInfo = NULL;
+ u16 nMaxAMSDUSize = 0;
+ u8* pMcsFilter = NULL;
+
+ static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
+ static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
+
+ if( pHTInfo->bCurrentHTSupport == false )
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
+ return;
+ }
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTCapBuf, sizeof(HT_CAPABILITY_ELE));
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTInfoBuf, sizeof(HT_INFORMATION_ELE));
+
+// HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq");
+// HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq");
+ //
+ if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap)))
+ pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
+ else
+ pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
+
+ if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
+ pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
+ else
+ pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
+
+
+ ////////////////////////////////////////////////////////
+ // Configurations:
+ ////////////////////////////////////////////////////////
+ IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE));
+// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE));
+ // Config Supported Channel Width setting
+ //
+ HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
+
+// if(pHTInfo->bCurBW40MHz == true)
+ pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
+
+ //
+ // Update short GI/ long GI setting
+ //
+ // TODO:
+ pHTInfo->bCurShortGI20MHz=
+ ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
+ pHTInfo->bCurShortGI40MHz=
+ ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
+
+ //
+ // Config TX STBC setting
+ //
+ // TODO:
+
+ //
+ // Config DSSS/CCK mode in 40MHz mode
+ //
+ // TODO:
+ pHTInfo->bCurSuppCCK =
+ ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
+
+
+ //
+ // Config and configure A-MSDU setting
+ //
+ pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
+
+ nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
+
+ if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
+ pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
+ else
+ pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
+
+ //
+ // Config A-MPDU setting
+ //
+ pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
+ if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
+ {
+ if( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) ||
+ (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) )
+ pHTInfo->bCurrentAMPDUEnable = false;
+ }
+
+ // <1> Decide AMPDU Factor
+
+ // By Emily
+ if(!pHTInfo->bRegRT2RTAggregation)
+ {
+ // Decide AMPDU Factor according to protocol handshake
+ if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
+ pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
+ else
+ pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
+
+ }else
+ {
+ // Set MPDU density to 2 to Realtek AP, and set it to 0 for others
+ // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
+#if 0
+ osTmp= PacketGetElement( asocpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE);
+ if(osTmp.Length >= 5) //00:e0:4c:02:00
+#endif
+ if (ieee->current_network.bssht.bdRT2RTAggregation)
+ {
+ if( ieee->pairwise_key_type != KEY_TYPE_NA)
+ // Realtek may set 32k in security mode and 64k for others
+ pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
+ else
+ pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
+ }else
+ {
+ if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
+ pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
+ else
+ pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
+ }
+ }
+
+ // <2> Set AMPDU Minimum MPDU Start Spacing
+ // 802.11n 3.0 section 9.7d.3
+#if 1
+ if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
+ pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
+ else
+ pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
+ if(ieee->pairwise_key_type != KEY_TYPE_NA )
+ pHTInfo->CurrentMPDUDensity = 7; // 8us
+#else
+ if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
+ pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
+ else
+ pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
+#endif
+ // Force TX AMSDU
+
+ // Lanhsin: mark for tmp to avoid deauth by ap from s3
+ //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
+ if(pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K)
+ {
+
+ pHTInfo->bCurrentAMPDUEnable = false;
+ pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
+ pHTInfo->ForcedAMSDUMaxSize = 7935;
+ }
+
+ // Rx Reorder Setting
+ pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
+
+ //
+ // Filter out unsupported HT rate for this AP
+ // Update RATR table
+ // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism.
+ //
+
+ // Handle Ralink AP bad MCS rate set condition. Joseph.
+ // This fix the bug of Ralink AP. This may be removed in the future.
+ if(pPeerHTCap->MCS[0] == 0)
+ pPeerHTCap->MCS[0] = 0xff;
+
+ // Joseph test //LZM ADD 090318
+ HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0));
+
+ HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
+
+ //
+ // Config MIMO Power Save setting
+ //
+ pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
+ if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
+ pMcsFilter = MCS_FILTER_1SS;
+ else
+ pMcsFilter = MCS_FILTER_ALL;
+ //WB add for MCS8 bug
+// pMcsFilter = MCS_FILTER_1SS;
+ ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
+ ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
+
+ //
+ // Config current operation mode.
+ //
+ pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
+
+
+
+}
+
+void HTSetConnectBwModeCallback(struct ieee80211_device* ieee);
+/********************************************************************************************************************
+ *function: initialize HT info(struct PRT_HIGH_THROUGHPUT)
+ * input: struct ieee80211_device* ieee
+ * output: none
+ * return: none
+ * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP
+********************************************************************************************************************/
+// TODO: Should this funciton be called when receiving of Disassociation?
+void HTInitializeHTInfo(struct ieee80211_device* ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ //
+ // These parameters will be reset when receiving deauthentication packet
+ //
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__);
+ pHTInfo->bCurrentHTSupport = false;
+
+ // 40MHz channel support
+ pHTInfo->bCurBW40MHz = false;
+ pHTInfo->bCurTxBW40MHz = false;
+
+ // Short GI support
+ pHTInfo->bCurShortGI20MHz = false;
+ pHTInfo->bCurShortGI40MHz = false;
+ pHTInfo->bForcedShortGI = false;
+
+ // CCK rate support
+ // This flag is set to true to support CCK rate by default.
+ // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to
+ // 11N BSS.
+ pHTInfo->bCurSuppCCK = true;
+
+ // AMSDU related
+ pHTInfo->bCurrent_AMSDU_Support = false;
+ pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
+
+ // AMPUD related
+ pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
+ pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
+
+
+
+ // Initialize all of the parameters related to 11n
+ memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap));
+ memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo));
+ memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf));
+ memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf));
+
+ pHTInfo->bSwBwInProgress = false;
+ pHTInfo->ChnlOp = CHNLOP_NONE;
+
+ // Set default IEEE spec for Draft N
+ pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
+
+ // Realtek proprietary aggregation mode
+ pHTInfo->bCurrentRT2RTAggregation = false;
+ pHTInfo->bCurrentRT2RTLongSlotTime = false;
+ pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
+
+ pHTInfo->IOTPeer = 0;
+ pHTInfo->IOTAction = 0;
+ pHTInfo->IOTRaFunc = 0;
+
+ //MCS rate initialized here
+ {
+ u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
+ RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7
+ RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15
+ RegHTSuppRateSets[4] = 0x01; //support MCS 32
+ }
+}
+/********************************************************************************************************************
+ *function: initialize Bss HT structure(struct PBSS_HT)
+ * input: PBSS_HT pBssHT //to be initialized
+ * output: none
+ * return: none
+ * notice: This function is called when initialize network structure
+********************************************************************************************************************/
+void HTInitializeBssDesc(PBSS_HT pBssHT)
+{
+
+ pBssHT->bdSupportHT = false;
+ memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
+ pBssHT->bdHTCapLen = 0;
+ memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
+ pBssHT->bdHTInfoLen = 0;
+
+ pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE;
+
+ pBssHT->bdRT2RTAggregation = false;
+ pBssHT->bdRT2RTLongSlotTime = false;
+ pBssHT->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
+}
+#if 0
+//below function has merged into ieee80211_network_init() in ieee80211_rx.c
+void
+HTParsingHTCapElement(
+ IN PADAPTER Adapter,
+ IN OCTET_STRING HTCapIE,
+ OUT PRT_WLAN_BSS pBssDesc
+)
+{
+ PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
+
+ if( HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf) )
+ {
+ RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTCapElement(): HT Capability Element length is too long!\n") );
+ return;
+ }
+
+ // TODO: Check the correctness of HT Cap
+ //Print each field in detail. Driver should not print out this message by default
+ if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc)
+ HTDebugHTCapability(DBG_TRACE, Adapter, &HTCapIE, (pu8)"HTParsingHTCapElement()");
+
+ HTCapIE.Length = HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf)?\
+ sizeof(pBssDesc->BssHT.bdHTCapBuf):HTCapIE.Length; //prevent from overflow
+
+ CopyMem(pBssDesc->BssHT.bdHTCapBuf, HTCapIE.Octet, HTCapIE.Length);
+ pBssDesc->BssHT.bdHTCapLen = HTCapIE.Length;
+
+}
+
+
+void
+HTParsingHTInfoElement(
+ PADAPTER Adapter,
+ OCTET_STRING HTInfoIE,
+ PRT_WLAN_BSS pBssDesc
+)
+{
+ PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
+
+ if( HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf))
+ {
+ RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTInfoElement(): HT Information Element length is too long!\n") );
+ return;
+ }
+
+ // TODO: Check the correctness of HT Info
+ //Print each field in detail. Driver should not print out this message by default
+ if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc)
+ HTDebugHTInfo(DBG_TRACE, Adapter, &HTInfoIE, (pu8)"HTParsingHTInfoElement()");
+
+ HTInfoIE.Length = HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf)?\
+ sizeof(pBssDesc->BssHT.bdHTInfoBuf):HTInfoIE.Length; //prevent from overflow
+
+ CopyMem( pBssDesc->BssHT.bdHTInfoBuf, HTInfoIE.Octet, HTInfoIE.Length);
+ pBssDesc->BssHT.bdHTInfoLen = HTInfoIE.Length;
+}
+
+/*
+ * Get HT related information from beacon and save it in BssDesc
+ *
+ * (1) Parse HTCap, and HTInfo, and record whether it is 11n AP
+ * (2) If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
+ * (3) Check whether peer is Realtek AP (for Realtek proprietary aggregation mode).
+ * Input:
+ * PADAPTER Adapter
+ *
+ * Output:
+ * PRT_TCB BssDesc
+ *
+*/
+void HTGetValueFromBeaconOrProbeRsp(
+ PADAPTER Adapter,
+ POCTET_STRING pSRCmmpdu,
+ PRT_WLAN_BSS bssDesc
+)
+{
+ PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
+ PRT_HIGH_THROUGHPUT pHTInfo = GET_HT_INFO(pMgntInfo);
+ OCTET_STRING HTCapIE, HTInfoIE, HTRealtekAgg, mmpdu;
+ OCTET_STRING BroadcomElement, CiscoElement;
+
+ mmpdu.Octet = pSRCmmpdu->Octet;
+ mmpdu.Length = pSRCmmpdu->Length;
+
+ //2Note:
+ // Mark for IOT testing using Linksys WRT350N, This AP does not contain WMM IE when
+ // it is configured at pure-N mode.
+ // if(bssDesc->BssQos.bdQoSMode & QOS_WMM)
+ //
+
+ HTInitializeBssDesc (&bssDesc->BssHT);
+
+ //2<1> Parse HTCap, and HTInfo
+ // Get HT Capability IE: (1) Get IEEE Draft N IE or (2) Get EWC IE
+ HTCapIE = PacketGetElement(mmpdu, EID_HTCapability, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE);
+ if(HTCapIE.Length == 0)
+ {
+ HTCapIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_CAP, OUI_SUBTYPE_DONT_CARE);
+ if(HTCapIE.Length != 0)
+ bssDesc->BssHT.bdHTSpecVer= HT_SPEC_VER_EWC;
+ }
+ if(HTCapIE.Length != 0)
+ HTParsingHTCapElement(Adapter, HTCapIE, bssDesc);
+
+ // Get HT Information IE: (1) Get IEEE Draft N IE or (2) Get EWC IE
+ HTInfoIE = PacketGetElement(mmpdu, EID_HTInfo, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE);
+ if(HTInfoIE.Length == 0)
+ {
+ HTInfoIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_INFO, OUI_SUBTYPE_DONT_CARE);
+ if(HTInfoIE.Length != 0)
+ bssDesc->BssHT.bdHTSpecVer = HT_SPEC_VER_EWC;
+ }
+ if(HTInfoIE.Length != 0)
+ HTParsingHTInfoElement(Adapter, HTInfoIE, bssDesc);
+
+ //2<2>If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
+ if(HTCapIE.Length != 0)
+ {
+ bssDesc->BssHT.bdSupportHT = true;
+ if(bssDesc->BssQos.bdQoSMode == QOS_DISABLE)
+ QosSetLegacyWMMParamWithHT(Adapter, bssDesc);
+ }
+ else
+ {
+ bssDesc->BssHT.bdSupportHT = false;
+ }
+
+ //2<3>Check whether the peer is Realtek AP/STA
+ if(pHTInfo->bRegRT2RTAggregation)
+ {
+ if(bssDesc->BssHT.bdSupportHT)
+ {
+ HTRealtekAgg = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE);
+ if(HTRealtekAgg.Length >=5 )
+ {
+ bssDesc->BssHT.bdRT2RTAggregation = true;
+
+ if((HTRealtekAgg.Octet[4]==1) && (HTRealtekAgg.Octet[5] & 0x02))
+ bssDesc->BssHT.bdRT2RTLongSlotTime = true;
+ }
+ }
+ }
+
+ //
+ // 2008/01/25 MH Get Broadcom AP IE for manamgent frame CCK rate problem.
+ // AP can not receive CCK managemtn from from 92E.
+ //
+
+ // Initialize every new bss broadcom cap exist as false..
+ bssDesc->bBroadcomCapExist= false;
+
+ if(HTCapIE.Length != 0 || HTInfoIE.Length != 0)
+ {
+ u4Byte Length = 0;
+
+ FillOctetString(BroadcomElement, NULL, 0);
+
+ BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_1, OUI_SUBTYPE_DONT_CARE);
+ Length += BroadcomElement.Length;
+ BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_2, OUI_SUBTYPE_DONT_CARE);
+ Length += BroadcomElement.Length;
+ BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_3, OUI_SUBTYPE_DONT_CARE);
+ Length += BroadcomElement.Length;
+
+ if(Length > 0)
+ bssDesc->bBroadcomCapExist = true;
+ }
+
+
+ // For Cisco IOT issue
+ CiscoElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_CISCO_IE, OUI_SUBTYPE_DONT_CARE);
+ if(CiscoElement.Length != 0){ // 3: 0x00, 0x40, 0x96 ....
+ bssDesc->bCiscoCapExist = true;
+ }else{
+ bssDesc->bCiscoCapExist = false;
+ }
+}
+
+
+#endif
+/********************************************************************************************************************
+ *function: initialize Bss HT structure(struct PBSS_HT)
+ * input: struct ieee80211_device *ieee
+ * struct ieee80211_network *pNetwork //usually current network we are live in
+ * output: none
+ * return: none
+ * notice: This function should ONLY be called before association
+********************************************************************************************************************/
+void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+// u16 nMaxAMSDUSize;
+// PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
+// PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
+// u8* pMcsFilter;
+ u8 bIOTAction = 0;
+
+ //
+ // Save Peer Setting before Association
+ //
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__);
+ /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/
+// if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT)
+ if (pNetwork->bssht.bdSupportHT)
+ {
+ pHTInfo->bCurrentHTSupport = true;
+ pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
+
+ // Save HTCap and HTInfo information Element
+ if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
+ memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
+
+ if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
+ memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
+
+ // Check whether RT to RT aggregation mode is enabled
+ if(pHTInfo->bRegRT2RTAggregation)
+ {
+ pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
+ pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
+ pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode;
+ }
+ else
+ {
+ pHTInfo->bCurrentRT2RTAggregation = false;
+ pHTInfo->bCurrentRT2RTLongSlotTime = false;
+ pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
+ }
+
+ // Determine the IOT Peer Vendor.
+ HTIOTPeerDetermine(ieee);
+
+ // Decide IOT Action
+ // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
+ pHTInfo->IOTAction = 0;
+ bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
+
+ bIOTAction = HTIOTActIsDisableMCS15(ieee);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
+
+ bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
+
+
+ bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
+
+ bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
+
+ bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
+
+ bIOTAction = HTIOTActIsForcedCTS2Self(pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
+
+ //bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
+ //if(bIOTAction)
+ // pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
+
+#if defined(RTL8192SU)
+ bIOTAction = HTIOCActRejcectADDBARequest(pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_REJECT_ADDBA_REQ;
+#endif
+
+ bIOTAction = HTIOCActAllowPeerAggOnePacket(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT;
+
+ bIOTAction = HTIOTActIsEDCABiasRx(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_EDCA_BIAS_ON_RX;
+
+#if defined(RTL8192SU)
+ bIOTAction = HTIOTActDisableShortGI(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_SHORT_GI;
+
+ bIOTAction = HTIOTActDisableHighPower(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_HIGH_POWER;
+#endif
+
+ bIOTAction = HTIOTActIsForcedAMSDU8K(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
+
+#if defined(RTL8192SU)
+ bIOTAction = HTIOTActIsTxNoAggregation(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_TX_NO_AGGREGATION;
+
+ bIOTAction = HTIOTActIsDisableTx40MHz(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_40_MHZ;
+
+ bIOTAction = HTIOTActIsDisableTx2SS(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_2SS;
+#endif
+ //must after HT_IOT_ACT_TX_NO_AGGREGATION
+ bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
+ if(bIOTAction)
+ pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
+
+ printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTAction = %8.8x\n", pHTInfo->IOTAction);
+ }
+ else
+ {
+ pHTInfo->bCurrentHTSupport = false;
+ pHTInfo->bCurrentRT2RTAggregation = false;
+ pHTInfo->bCurrentRT2RTLongSlotTime = false;
+ pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
+
+ pHTInfo->IOTAction = 0;
+ pHTInfo->IOTRaFunc = 0;
+ }
+
+}
+
+void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+// PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
+ PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
+
+ if(pHTInfo->bCurrentHTSupport)
+ {
+ //
+ // Config current operation mode.
+ //
+ if(pNetwork->bssht.bdHTInfoLen != 0)
+ pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
+
+ //
+ // <TODO: Config according to OBSS non-HT STA present!!>
+ //
+ }
+}
+
+void HTUseDefaultSetting(struct ieee80211_device* ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+// u8 regBwOpMode;
+
+ if(pHTInfo->bEnableHT)
+ {
+ pHTInfo->bCurrentHTSupport = true;
+
+ pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK;
+
+ pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz;
+
+ pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz;
+
+ pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz;
+
+ pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
+
+ pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
+
+ pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
+
+ pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
+
+ pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity;
+
+ // Set BWOpMode register
+
+ //update RATR index0
+ HTFilterMCSRate(ieee, ieee->Regdot11HTOperationalRateSet, ieee->dot11HTOperationalRateSet);
+ //function below is not implemented at all. WB
+#ifdef TODO
+ Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet);
+#endif
+ ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL);
+ ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
+
+ }
+ else
+ {
+ pHTInfo->bCurrentHTSupport = false;
+ }
+ return;
+}
+/********************************************************************************************************************
+ *function: check whether HT control field exists
+ * input: struct ieee80211_device *ieee
+ * u8* pFrame //coming skb->data
+ * output: none
+ * return: return true if HT control field exists(false otherwise)
+ * notice:
+********************************************************************************************************************/
+u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame)
+{
+ if(ieee->pHTInfo->bCurrentHTSupport)
+ {
+ if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
+ return true;
+ }
+ }
+ return false;
+}
+
+//
+// This function set bandwidth mode in protocol layer.
+//
+void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+// u32 flags = 0;
+
+ if(pHTInfo->bRegBW40MHz == false)
+ return;
+
+
+
+ // To reduce dummy operation
+// if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) ||
+// (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset))
+// return;
+
+// spin_lock_irqsave(&(ieee->bw_spinlock), flags);
+ if(pHTInfo->bSwBwInProgress) {
+// spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
+ return;
+ }
+ //if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
+ if(Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
+ {
+ // Handle Illegal extention channel offset!!
+ if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
+ Offset = HT_EXTCHNL_OFFSET_NO_EXT;
+ if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
+ pHTInfo->bCurBW40MHz = true;
+ pHTInfo->CurSTAExtChnlOffset = Offset;
+ } else {
+ pHTInfo->bCurBW40MHz = false;
+ pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
+ }
+ } else {
+ pHTInfo->bCurBW40MHz = false;
+ pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
+ }
+
+ pHTInfo->bSwBwInProgress = true;
+
+ // TODO: 2007.7.13 by Emily Wait 2000ms in order to garantee that switching
+ // bandwidth is executed after scan is finished. It is a temporal solution
+ // because software should ganrantee the last operation of switching bandwidth
+ // is executed properlly.
+ HTSetConnectBwModeCallback(ieee);
+
+// spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
+}
+
+void HTSetConnectBwModeCallback(struct ieee80211_device* ieee)
+{
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+
+ IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__);
+ if(pHTInfo->bCurBW40MHz)
+ {
+ if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
+ ieee->set_chan(ieee->dev, ieee->current_network.channel+2);
+ else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
+ ieee->set_chan(ieee->dev, ieee->current_network.channel-2);
+ else
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+
+ ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
+ } else {
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+ ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+ }
+
+ pHTInfo->bSwBwInProgress = false;
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+EXPORT_SYMBOL_NOVERS(HTUpdateSelfAndPeerSetting);
+#else
+EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting);
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
new file mode 100644
index 000000000000..f7b882b99d14
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
@@ -0,0 +1,749 @@
+#ifndef __INC_QOS_TYPE_H
+#define __INC_QOS_TYPE_H
+
+//#include "EndianFree.h"
+#define BIT0 0x00000001
+#define BIT1 0x00000002
+#define BIT2 0x00000004
+#define BIT3 0x00000008
+#define BIT4 0x00000010
+#define BIT5 0x00000020
+#define BIT6 0x00000040
+#define BIT7 0x00000080
+#define BIT8 0x00000100
+#define BIT9 0x00000200
+#define BIT10 0x00000400
+#define BIT11 0x00000800
+#define BIT12 0x00001000
+#define BIT13 0x00002000
+#define BIT14 0x00004000
+#define BIT15 0x00008000
+#define BIT16 0x00010000
+#define BIT17 0x00020000
+#define BIT18 0x00040000
+#define BIT19 0x00080000
+#define BIT20 0x00100000
+#define BIT21 0x00200000
+#define BIT22 0x00400000
+#define BIT23 0x00800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+
+#define MAX_WMMELE_LENGTH 64
+
+//
+// QoS mode.
+// enum 0, 1, 2, 4: since we can use the OR(|) operation.
+//
+// QOS_MODE is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
+//typedef enum _QOS_MODE{
+// QOS_DISABLE = 0,
+// QOS_WMM = 1,
+// QOS_EDCA = 2,
+// QOS_HCCA = 4,
+//}QOS_MODE,*PQOS_MODE;
+//
+typedef u32 QOS_MODE, *PQOS_MODE;
+#define QOS_DISABLE 0
+#define QOS_WMM 1
+#define QOS_WMMSA 2
+#define QOS_EDCA 4
+#define QOS_HCCA 8
+#define QOS_WMM_UAPSD 16 //WMM Power Save, 2006-06-14 Isaiah
+
+#define AC_PARAM_SIZE 4
+#define WMM_PARAM_ELE_BODY_LEN 18
+
+//
+// QoS ACK Policy Field Values
+// Ref: WMM spec 2.1.6: QoS Control Field, p.10.
+//
+typedef enum _ACK_POLICY{
+ eAckPlc0_ACK = 0x00,
+ eAckPlc1_NoACK = 0x01,
+}ACK_POLICY,*PACK_POLICY;
+
+#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE))
+#if 0
+#define GET_QOS_CTRL(_pStart) ReadEF2Byte((u8 *)(_pStart) + 24)
+#define SET_QOS_CTRL(_pStart, _value) WriteEF2Byte((u8 *)(_pStart) + 24, _value)
+
+// WMM control field.
+#define GET_QOS_CTRL_WMM_UP(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 0, 3))
+#define SET_QOS_CTRL_WMM_UP(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 0, 3, (u8)(_value))
+
+#define GET_QOS_CTRL_WMM_EOSP(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 4, 1))
+#define SET_QOS_CTRL_WMM_EOSP(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 4, 1, (u8)(_value))
+
+#define GET_QOS_CTRL_WMM_ACK_POLICY(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 5, 2))
+#define SET_QOS_CTRL_WMM_ACK_POLICY(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 5, 2, (u8)(_value))
+
+// 802.11e control field (by STA, data)
+#define GET_QOS_CTRL_STA_DATA_TID(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 0, 4))
+#define SET_QOS_CTRL_STA_DATA_TID(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 0, 4, (u8)(_value))
+
+#define GET_QOS_CTRL_STA_DATA_QSIZE_FLAG(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 4, 1))
+#define SET_QOS_CTRL_STA_DATA_QSIZE_FLAG(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 4, 1, (u8)(_value))
+
+#define GET_QOS_CTRL_STA_DATA_ACK_POLICY(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 5, 2))
+#define SET_QOS_CTRL_STA_DATA_ACK_POLICY(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 5, 2, (u8)(_value))
+
+#define GET_QOS_CTRL_STA_DATA_TXOP(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 8, 8))
+#define SET_QOS_CTRL_STA_DATA_TXOP(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 8, 8, (u8)(_value))
+
+#define GET_QOS_CTRL_STA_DATA_QSIZE(_pStart) GET_QOS_CTRL_STA_DATA_TXOP(_pStart)
+#define SET_QOS_CTRL_STA_DATA_QSIZE(_pStart, _value) SET_QOS_CTRL_STA_DATA_TXOP(_pStart)
+
+// 802.11e control field (by HC, data)
+#define GET_QOS_CTRL_HC_DATA_TID(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 0, 4))
+#define SET_QOS_CTRL_HC_DATA_TID(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 0, 4, (u8)(_value))
+
+#define GET_QOS_CTRL_HC_DATA_EOSP(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 4, 1))
+#define SET_QOS_CTRL_HC_DATA_EOSP(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 4, 1, (u8)(_value))
+
+#define GET_QOS_CTRL_HC_DATA_ACK_POLICY(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 5, 2))
+#define SET_QOS_CTRL_HC_DATA_ACK_POLICY(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 5, 2, (u8)(_value))
+
+#define GET_QOS_CTRL_HC_DATA_PS_BUFSTATE(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 8, 8))
+#define SET_QOS_CTRL_HC_DATA_PS_BUFSTATE(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 8, 8, (u8)(_value))
+
+// 802.11e control field (by HC, CFP)
+#define GET_QOS_CTRL_HC_CFP_TID(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 0, 4))
+#define SET_QOS_CTRL_HC_CFP_TID(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 0, 4, (u8)(_value))
+
+#define GET_QOS_CTRL_HC_CFP_EOSP(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 4, 1))
+#define SET_QOS_CTRL_HC_CFP_EOSP(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 4, 1, (u8)(_value))
+
+#define GET_QOS_CTRL_HC_CFP_ACK_POLICY(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 5, 2))
+#define SET_QOS_CTRL_HC_CFP_ACK_POLICY(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 5, 2, (u8)(_value))
+
+#define GET_QOS_CTRL_HC_CFP_TXOP_LIMIT(_pStart) ((u8)LE_BITS_TO_2BYTE((u8 *)(_pStart)+24, 8, 8))
+#define SET_QOS_CTRL_HC_CFP_TXOP_LIMIT(_pStart, _value) SET_BITS_TO_LE_2BYTE((u8 *)(_pStart)+24, 8, 8, (u8)(_value))
+
+#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4)
+#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1)
+#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1)
+#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1)
+#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1)
+#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1)
+#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val)
+
+#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2)
+#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val)
+
+
+#define WMM_INFO_ELEMENT_SIZE 7
+
+#define GET_WMM_INFO_ELE_OUI(_pStart) ((u8 *)(_pStart))
+#define SET_WMM_INFO_ELE_OUI(_pStart, _pVal) PlatformMoveMemory(_pStart, _pVal, 3);
+
+#define GET_WMM_INFO_ELE_OUI_TYPE(_pStart) ( EF1Byte( *((u8 *)(_pStart)+3) ) )
+#define SET_WMM_INFO_ELE_OUI_TYPE(_pStart, _val) ( *((u8 *)(_pStart)+3) = EF1Byte(_val) )
+
+#define GET_WMM_INFO_ELE_OUI_SUBTYPE(_pStart) ( EF1Byte( *((u8 *)(_pStart)+4) ) )
+#define SET_WMM_INFO_ELE_OUI_SUBTYPE(_pStart, _val) ( *((u8 *)(_pStart)+4) = EF1Byte(_val) )
+
+#define GET_WMM_INFO_ELE_VERSION(_pStart) ( EF1Byte( *((u8 *)(_pStart)+5) ) )
+#define SET_WMM_INFO_ELE_VERSION(_pStart, _val) ( *((u8 *)(_pStart)+5) = EF1Byte(_val) )
+
+#define GET_WMM_INFO_ELE_QOS_INFO_FIELD(_pStart) ( EF1Byte( *((u8 *)(_pStart)+6) ) )
+#define SET_WMM_INFO_ELE_QOS_INFO_FIELD(_pStart, _val) ( *((u8 *)(_pStart)+6) = EF1Byte(_val) )
+
+
+
+#define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) )
+#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val)
+
+#define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) )
+#define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val)
+
+#define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) )
+#define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val)
+
+#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) )
+#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BTIS_TO_LE_4BYTE(_pStart, 0, 8, _val)
+
+#define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) )
+#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val)
+
+#define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) )
+#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val)
+
+#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u16)LE_BITS_TO_4BYTE(_pStart, 16, 16) )
+#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val)
+
+
+
+
+#define GET_WMM_PARAM_ELE_OUI(_pStart) ((u8 *)(_pStart))
+#define SET_WMM_PARAM_ELE_OUI(_pStart, _pVal) PlatformMoveMemory(_pStart, _pVal, 3)
+
+#define GET_WMM_PARAM_ELE_OUI_TYPE(_pStart) ( EF1Byte( *((u8 *)(_pStart)+3) ) )
+#define SET_WMM_PARAM_ELE_OUI_TYPE(_pStart, _val) ( *((u8 *)(_pStart)+3) = EF1Byte(_val) )
+
+#define GET_WMM_PARAM_ELE_OUI_SUBTYPE(_pStart) ( EF1Byte( *((u8 *)(_pStart)+4) ) )
+#define SET_WMM_PARAM_ELE_OUI_SUBTYPE(_pStart, _val) ( *((u8 *)(_pStart)+4) = EF1Byte(_val) )
+
+#define GET_WMM_PARAM_ELE_VERSION(_pStart) ( EF1Byte( *((u8 *)(_pStart)+5) ) )
+#define SET_WMM_PARAM_ELE_VERSION(_pStart, _val) ( *((u8 *)(_pStart)+5) = EF1Byte(_val) )
+
+#define GET_WMM_PARAM_ELE_QOS_INFO_FIELD(_pStart) ( EF1Byte( *((u8 *)(_pStart)+6) ) )
+#define SET_WMM_PARAM_ELE_QOS_INFO_FIELD(_pStart, _val) ( *((u8 *)(_pStart)+6) = EF1Byte(_val) )
+
+#define GET_WMM_PARAM_ELE_AC_PARAM(_pStart) ( (u8 *)(_pStart)+8 )
+#define SET_WMM_PARAM_ELE_AC_PARAM(_pStart, _pVal) PlatformMoveMemory((_pStart)+8, _pVal, 16)
+#endif
+
+//
+// QoS Control Field
+// Ref:
+// 1. WMM spec 2.1.6: QoS Control Field, p.9.
+// 2. 802.11e/D13.0 7.1.3.5, p.26.
+//
+typedef union _QOS_CTRL_FIELD{
+ u8 charData[2];
+ u16 shortData;
+
+ // WMM spec
+ struct
+ {
+ u8 UP:3;
+ u8 usRsvd1:1;
+ u8 EOSP:1;
+ u8 AckPolicy:2;
+ u8 usRsvd2:1;
+ u8 ucRsvdByte;
+ }WMM;
+
+ // 802.11e: QoS data type frame sent by non-AP QSTAs.
+ struct
+ {
+ u8 TID:4;
+ u8 bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
+ u8 AckPolicy:2;
+ u8 usRsvd:1;
+ u8 TxopOrQsize; // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size.
+ }BySta;
+
+ // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
+ struct
+ {
+ u8 TID:4;
+ u8 EOSP:1;
+ u8 AckPolicy:2;
+ u8 usRsvd:1;
+ u8 PSBufState; // QAP PS Buffer State.
+ }ByHc_Data;
+
+ // 802.11e: QoS (+) CF-Poll frames sent by HC.
+ struct
+ {
+ u8 TID:4;
+ u8 EOSP:1;
+ u8 AckPolicy:2;
+ u8 usRsvd:1;
+ u8 TxopLimit; // TXOP Limit.
+ }ByHc_CFP;
+
+}QOS_CTRL_FIELD, *PQOS_CTRL_FIELD;
+
+
+//
+// QoS Info Field
+// Ref:
+// 1. WMM spec 2.2.1: WME Information Element, p.11.
+// 2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h]
+//
+typedef union _QOS_INFO_FIELD{
+ u8 charData;
+
+ struct
+ {
+ u8 ucParameterSetCount:4;
+ u8 ucReserved:4;
+ }WMM;
+
+ struct
+ {
+ //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
+ u8 ucAC_VO_UAPSD:1;
+ u8 ucAC_VI_UAPSD:1;
+ u8 ucAC_BE_UAPSD:1;
+ u8 ucAC_BK_UAPSD:1;
+ u8 ucReserved1:1;
+ u8 ucMaxSPLen:2;
+ u8 ucReserved2:1;
+
+ }ByWmmPsSta;
+
+ struct
+ {
+ //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
+ u8 ucParameterSetCount:4;
+ u8 ucReserved:3;
+ u8 ucApUapsd:1;
+ }ByWmmPsAp;
+
+ struct
+ {
+ u8 ucAC3_UAPSD:1;
+ u8 ucAC2_UAPSD:1;
+ u8 ucAC1_UAPSD:1;
+ u8 ucAC0_UAPSD:1;
+ u8 ucQAck:1;
+ u8 ucMaxSPLen:2;
+ u8 ucMoreDataAck:1;
+ } By11eSta;
+
+ struct
+ {
+ u8 ucParameterSetCount:4;
+ u8 ucQAck:1;
+ u8 ucQueueReq:1;
+ u8 ucTXOPReq:1;
+ u8 ucReserved:1;
+ } By11eAp;
+
+ struct
+ {
+ u8 ucReserved1:4;
+ u8 ucQAck:1;
+ u8 ucReserved2:2;
+ u8 ucMoreDataAck:1;
+ } ByWmmsaSta;
+
+ struct
+ {
+ u8 ucReserved1:4;
+ u8 ucQAck:1;
+ u8 ucQueueReq:1;
+ u8 ucTXOPReq:1;
+ u8 ucReserved2:1;
+ } ByWmmsaAp;
+
+ struct
+ {
+ u8 ucAC3_UAPSD:1;
+ u8 ucAC2_UAPSD:1;
+ u8 ucAC1_UAPSD:1;
+ u8 ucAC0_UAPSD:1;
+ u8 ucQAck:1;
+ u8 ucMaxSPLen:2;
+ u8 ucMoreDataAck:1;
+ } ByAllSta;
+
+ struct
+ {
+ u8 ucParameterSetCount:4;
+ u8 ucQAck:1;
+ u8 ucQueueReq:1;
+ u8 ucTXOPReq:1;
+ u8 ucApUapsd:1;
+ } ByAllAp;
+
+}QOS_INFO_FIELD, *PQOS_INFO_FIELD;
+
+#if 0
+//
+// WMM Information Element
+// Ref: WMM spec 2.2.1: WME Information Element, p.10.
+//
+typedef struct _WMM_INFO_ELEMENT{
+// u8 ElementID;
+// u8 Length;
+ u8 OUI[3];
+ u8 OUI_Type;
+ u8 OUI_SubType;
+ u8 Version;
+ QOS_INFO_FIELD QosInfo;
+}WMM_INFO_ELEMENT, *PWMM_INFO_ELEMENT;
+#endif
+
+//
+// ACI to AC coding.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
+//
+// AC_CODING is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko.
+//typedef enum _AC_CODING{
+// AC0_BE = 0, // ACI: 0x00 // Best Effort
+// AC1_BK = 1, // ACI: 0x01 // Background
+// AC2_VI = 2, // ACI: 0x10 // Video
+// AC3_VO = 3, // ACI: 0x11 // Voice
+// AC_MAX = 4, // Max: define total number; Should not to be used as a real enum.
+//}AC_CODING,*PAC_CODING;
+//
+typedef u32 AC_CODING;
+#define AC0_BE 0 // ACI: 0x00 // Best Effort
+#define AC1_BK 1 // ACI: 0x01 // Background
+#define AC2_VI 2 // ACI: 0x10 // Video
+#define AC3_VO 3 // ACI: 0x11 // Voice
+#define AC_MAX 4 // Max: define total number; Should not to be used as a real enum.
+
+//
+// ACI/AIFSN Field.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
+//
+typedef union _ACI_AIFSN{
+ u8 charData;
+
+ struct
+ {
+ u8 AIFSN:4;
+ u8 ACM:1;
+ u8 ACI:2;
+ u8 Reserved:1;
+ }f; // Field
+}ACI_AIFSN, *PACI_AIFSN;
+
+//
+// ECWmin/ECWmax field.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
+//
+typedef union _ECW{
+ u8 charData;
+ struct
+ {
+ u8 ECWmin:4;
+ u8 ECWmax:4;
+ }f; // Field
+}ECW, *PECW;
+
+//
+// AC Parameters Record Format.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
+//
+typedef union _AC_PARAM{
+ u32 longData;
+ u8 charData[4];
+
+ struct
+ {
+ ACI_AIFSN AciAifsn;
+ ECW Ecw;
+ u16 TXOPLimit;
+ }f; // Field
+}AC_PARAM, *PAC_PARAM;
+
+
+
+//
+// QoS element subtype
+//
+typedef enum _QOS_ELE_SUBTYPE{
+ QOSELE_TYPE_INFO = 0x00, // 0x00: Information element
+ QOSELE_TYPE_PARAM = 0x01, // 0x01: parameter element
+}QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE;
+
+
+//
+// Direction Field Values.
+// Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
+//
+typedef enum _DIRECTION_VALUE{
+ DIR_UP = 0, // 0x00 // UpLink
+ DIR_DOWN = 1, // 0x01 // DownLink
+ DIR_DIRECT = 2, // 0x10 // DirectLink
+ DIR_BI_DIR = 3, // 0x11 // Bi-Direction
+}DIRECTION_VALUE,*PDIRECTION_VALUE;
+
+
+//
+// TS Info field in WMM TSPEC Element.
+// Ref:
+// 1. WMM spec 2.2.11: WME TSPEC Element, p.18.
+// 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
+//
+typedef union _QOS_TSINFO{
+ u8 charData[3];
+ struct {
+ u8 ucTrafficType:1; //WMM is reserved
+ u8 ucTSID:4;
+ u8 ucDirection:2;
+ u8 ucAccessPolicy:2; //WMM: bit8=0, bit7=1
+ u8 ucAggregation:1; //WMM is reserved
+ u8 ucPSB:1; //WMMSA is APSD
+ u8 ucUP:3;
+ u8 ucTSInfoAckPolicy:2; //WMM is reserved
+ u8 ucSchedule:1; //WMM is reserved
+ u8 ucReserved:7;
+ }field;
+}QOS_TSINFO, *PQOS_TSINFO;
+
+//
+// WMM TSPEC Body.
+// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
+//
+typedef union _TSPEC_BODY{
+ u8 charData[55];
+
+ struct
+ {
+ QOS_TSINFO TSInfo; //u8 TSInfo[3];
+ u16 NominalMSDUsize;
+ u16 MaxMSDUsize;
+ u32 MinServiceItv;
+ u32 MaxServiceItv;
+ u32 InactivityItv;
+ u32 SuspenItv;
+ u32 ServiceStartTime;
+ u32 MinDataRate;
+ u32 MeanDataRate;
+ u32 PeakDataRate;
+ u32 MaxBurstSize;
+ u32 DelayBound;
+ u32 MinPhyRate;
+ u16 SurplusBandwidthAllowance;
+ u16 MediumTime;
+ } f; // Field
+}TSPEC_BODY, *PTSPEC_BODY;
+
+
+//
+// WMM TSPEC Element.
+// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
+//
+typedef struct _WMM_TSPEC{
+ u8 ID;
+ u8 Length;
+ u8 OUI[3];
+ u8 OUI_Type;
+ u8 OUI_SubType;
+ u8 Version;
+ TSPEC_BODY Body;
+} WMM_TSPEC, *PWMM_TSPEC;
+
+//
+// ACM implementation method.
+// Annie, 2005-12-13.
+//
+typedef enum _ACM_METHOD{
+ eAcmWay0_SwAndHw = 0, // By SW and HW.
+ eAcmWay1_HW = 1, // By HW.
+ eAcmWay2_SW = 2, // By SW.
+}ACM_METHOD,*PACM_METHOD;
+
+
+typedef struct _ACM{
+// u8 RegEnableACM;
+ u64 UsedTime;
+ u64 MediumTime;
+ u8 HwAcmCtl; // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B).
+}ACM, *PACM;
+
+typedef u8 AC_UAPSD, *PAC_UAPSD;
+
+#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
+#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
+
+#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
+#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
+
+#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
+#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
+
+#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
+#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
+
+
+//typedef struct _TCLASS{
+// TODO
+//} TCLASS, *PTCLASS;
+typedef union _QOS_TCLAS{
+
+ struct _TYPE_GENERAL{
+ u8 Priority;
+ u8 ClassifierType;
+ u8 Mask;
+ } TYPE_GENERAL;
+
+ struct _TYPE0_ETH{
+ u8 Priority;
+ u8 ClassifierType;
+ u8 Mask;
+ u8 SrcAddr[6];
+ u8 DstAddr[6];
+ u16 Type;
+ } TYPE0_ETH;
+
+ struct _TYPE1_IPV4{
+ u8 Priority;
+ u8 ClassifierType;
+ u8 Mask;
+ u8 Version;
+ u8 SrcIP[4];
+ u8 DstIP[4];
+ u16 SrcPort;
+ u16 DstPort;
+ u8 DSCP;
+ u8 Protocol;
+ u8 Reserved;
+ } TYPE1_IPV4;
+
+ struct _TYPE1_IPV6{
+ u8 Priority;
+ u8 ClassifierType;
+ u8 Mask;
+ u8 Version;
+ u8 SrcIP[16];
+ u8 DstIP[16];
+ u16 SrcPort;
+ u16 DstPort;
+ u8 FlowLabel[3];
+ } TYPE1_IPV6;
+
+ struct _TYPE2_8021Q{
+ u8 Priority;
+ u8 ClassifierType;
+ u8 Mask;
+ u16 TagType;
+ } TYPE2_8021Q;
+} QOS_TCLAS, *PQOS_TCLAS;
+
+//typedef struct _WMM_TSTREAM{
+//
+//- TSPEC
+//- AC (which to mapping)
+//} WMM_TSTREAM, *PWMM_TSTREAM;
+typedef struct _QOS_TSTREAM{
+ u8 AC;
+ WMM_TSPEC TSpec;
+ QOS_TCLAS TClass;
+} QOS_TSTREAM, *PQOS_TSTREAM;
+
+//typedef struct _U_APSD{
+//- TriggerEnable [4]
+//- MaxSPLength
+//- HighestAcBuffered
+//} U_APSD, *PU_APSD;
+
+//joseph TODO:
+// UAPSD function should be implemented by 2 data structure
+// "Qos control field" and "Qos info field"
+//typedef struct _QOS_UAPSD{
+// u8 bTriggerEnable[4];
+// u8 MaxSPLength;
+// u8 HighestBufAC;
+//} QOS_UAPSD, *PQOS_APSD;
+
+//----------------------------------------------------------------------------
+// 802.11 Management frame Status Code field
+//----------------------------------------------------------------------------
+typedef struct _OCTET_STRING{
+ u8 *Octet;
+ u16 Length;
+}OCTET_STRING, *POCTET_STRING;
+#if 0
+#define FillOctetString(_os,_octet,_len) \
+ (_os).Octet=(u8 *)(_octet); \
+ (_os).Length=(_len);
+
+#define WMM_ELEM_HDR_LEN 6
+#define WMMElemSkipHdr(_osWMMElem) \
+ (_osWMMElem).Octet += WMM_ELEM_HDR_LEN; \
+ (_osWMMElem).Length -= WMM_ELEM_HDR_LEN;
+#endif
+//
+// STA QoS data.
+// Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h]
+//
+typedef struct _STA_QOS{
+ //DECLARE_RT_OBJECT(STA_QOS);
+ u8 WMMIEBuf[MAX_WMMELE_LENGTH];
+ u8* WMMIE;
+
+ // Part 1. Self QoS Mode.
+ QOS_MODE QosCapability; //QoS Capability, 2006-06-14 Isaiah
+ QOS_MODE CurrentQosMode;
+
+ // For WMM Power Save Mode :
+ // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah
+ AC_UAPSD b4ac_Uapsd; //VoUapsd(bit0), ViUapsd(bit1), BkUapsd(bit2), BeUapsd(bit3),
+ AC_UAPSD Curr4acUapsd;
+ u8 bInServicePeriod;
+ u8 MaxSPLength;
+ int NumBcnBeforeTrigger;
+
+ // Part 2. EDCA Parameter (perAC)
+ u8 * pWMMInfoEle;
+ u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
+ u8 WMMPELength;
+
+ // <Bruce_Note>
+ //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
+ // By Bruce, 2008-01-30.
+ // Part 2. EDCA Parameter (perAC)
+ QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA
+ QOS_INFO_FIELD QosInfoField_AP; // Retrieved from AP
+
+ AC_PARAM CurAcParameters[4];
+
+ // Part 3. ACM
+ ACM acm[4];
+ ACM_METHOD AcmMethod;
+
+ // Part 4. Per TID (Part 5: TCLASS will be described by TStream)
+ QOS_TSTREAM TStream[16];
+ WMM_TSPEC TSpec;
+
+ u32 QBssWirelessMode;
+
+ // No Ack Setting
+ u8 bNoAck;
+
+ // Enable/Disable Rx immediate BA capability.
+ u8 bEnableRxImmBA;
+
+}STA_QOS, *PSTA_QOS;
+
+//
+// BSS QOS data.
+// Ref: BssDscr in 8185 code. [def. in BssDscr.h]
+//
+typedef struct _BSS_QOS{
+ QOS_MODE bdQoSMode;
+
+ u8 bdWMMIEBuf[MAX_WMMELE_LENGTH];
+ u8* bdWMMIE;
+
+ QOS_ELE_SUBTYPE EleSubType;
+
+ u8 * pWMMInfoEle;
+ u8 * pWMMParamEle;
+
+ QOS_INFO_FIELD QosInfoField;
+ AC_PARAM AcParameter[4];
+}BSS_QOS, *PBSS_QOS;
+
+
+//
+// Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code.
+//#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0)
+//
+#define sQoSCtlLng 2
+#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0)
+
+
+//Added by joseph
+//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
+//#define UP2AC(up) ((up<3)?((up==0)?1:0):(up>>1))
+#define IsACValid(ac) ((ac<=7 )?true:false )
+
+#endif // #ifndef __INC_QOS_TYPE_H
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h
new file mode 100644
index 000000000000..baaac2149de1
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h
@@ -0,0 +1,56 @@
+#ifndef _TSTYPE_H_
+#define _TSTYPE_H_
+#include "rtl819x_Qos.h"
+#define TS_SETUP_TIMEOUT 60 // In millisecond
+#define TS_INACT_TIMEOUT 60
+#define TS_ADDBA_DELAY 60
+
+#define TOTAL_TS_NUM 16
+#define TCLAS_NUM 4
+
+// This define the Tx/Rx directions
+typedef enum _TR_SELECT {
+ TX_DIR = 0,
+ RX_DIR = 1,
+} TR_SELECT, *PTR_SELECT;
+
+typedef struct _TS_COMMON_INFO{
+ struct list_head List;
+ struct timer_list SetupTimer;
+ struct timer_list InactTimer;
+ u8 Addr[6];
+ TSPEC_BODY TSpec;
+ QOS_TCLAS TClass[TCLAS_NUM];
+ u8 TClasProc;
+ u8 TClasNum;
+} TS_COMMON_INFO, *PTS_COMMON_INFO;
+
+typedef struct _TX_TS_RECORD{
+ TS_COMMON_INFO TsCommonInfo;
+ u16 TxCurSeq;
+ BA_RECORD TxPendingBARecord; // For BA Originator
+ BA_RECORD TxAdmittedBARecord; // For BA Originator
+// QOS_DL_RECORD DLRecord;
+ u8 bAddBaReqInProgress;
+ u8 bAddBaReqDelayed;
+ u8 bUsingBa;
+ struct timer_list TsAddBaTimer;
+ u8 num;
+} TX_TS_RECORD, *PTX_TS_RECORD;
+
+typedef struct _RX_TS_RECORD {
+ TS_COMMON_INFO TsCommonInfo;
+ u16 RxIndicateSeq;
+ u16 RxTimeoutIndicateSeq;
+ struct list_head RxPendingPktList;
+ struct timer_list RxPktPendingTimer;
+ BA_RECORD RxAdmittedBARecord; // For BA Recepient
+ u16 RxLastSeqNum;
+ u8 RxLastFragNum;
+ u8 num;
+// QOS_DL_RECORD DLRecord;
+} RX_TS_RECORD, *PRX_TS_RECORD;
+
+
+#endif
+
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
new file mode 100644
index 000000000000..6fb7033ed360
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
@@ -0,0 +1,667 @@
+#include "ieee80211.h"
+#include <linux/etherdevice.h>
+#include "rtl819x_TS.h"
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+#endif
+void TsSetupTimeOut(unsigned long data)
+{
+ // Not implement yet
+ // This is used for WMMSA and ACM , that would send ADDTSReq frame.
+}
+
+void TsInactTimeout(unsigned long data)
+{
+ // Not implement yet
+ // This is used for WMMSA and ACM.
+ // This function would be call when TS is no Tx/Rx for some period of time.
+}
+
+/********************************************************************************************************************
+ *function: I still not understand this function, so wait for further implementation
+ * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
+ * return: NULL
+ * notice:
+********************************************************************************************************************/
+#if 1
+void RxPktPendingTimeout(unsigned long data)
+{
+ PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
+ struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
+
+ PRX_REORDER_ENTRY pReorderEntry = NULL;
+
+ //u32 flags = 0;
+ unsigned long flags = 0;
+ struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
+ u8 index = 0;
+ bool bPktInBuf = false;
+
+
+ spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
+ //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__FUNCTION__);
+ if(pRxTs->RxTimeoutIndicateSeq != 0xffff)
+ {
+ // Indicate the pending packets sequentially according to SeqNum until meet the gap.
+ while(!list_empty(&pRxTs->RxPendingPktList))
+ {
+ pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
+ if(index == 0)
+ pRxTs->RxIndicateSeq = pReorderEntry->SeqNum;
+
+ if( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ||
+ SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) )
+ {
+ list_del_init(&pReorderEntry->List);
+
+ if(SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq))
+ pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096;
+
+ IEEE80211_DEBUG(IEEE80211_DL_REORDER,"RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum);
+ stats_IndicateArray[index] = pReorderEntry->prxb;
+ index++;
+
+ list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List);
+ }
+ else
+ {
+ bPktInBuf = true;
+ break;
+ }
+ }
+ }
+
+ if(index>0)
+ {
+ // Set RxTimeoutIndicateSeq to 0xffff to indicate no pending packets in buffer now.
+ pRxTs->RxTimeoutIndicateSeq = 0xffff;
+
+ // Indicate packets
+ if(index > REORDER_WIN_SIZE){
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
+ spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
+ return;
+ }
+ ieee80211_indicate_packets(ieee, stats_IndicateArray, index);
+ bPktInBuf = false;
+
+ }
+
+ if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff))
+ {
+ pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
+#if 0
+ if(timer_pending(&pTS->RxPktPendingTimer))
+ del_timer_sync(&pTS->RxPktPendingTimer);
+ pTS->RxPktPendingTimer.expires = jiffies + MSECS(pHTInfo->RxReorderPendingTime);
+ add_timer(&pTS->RxPktPendingTimer);
+#else
+ mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime));
+#endif
+
+#if 0
+ if(timer_pending(&pRxTs->RxPktPendingTimer))
+ del_timer_sync(&pRxTs->RxPktPendingTimer);
+ pRxTs->RxPktPendingTimer.expires = jiffies + ieee->pHTInfo->RxReorderPendingTime;
+ add_timer(&pRxTs->RxPktPendingTimer);
+#endif
+ }
+ spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
+ //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
+}
+#endif
+
+/********************************************************************************************************************
+ *function: Add BA timer function
+ * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
+ * return: NULL
+ * notice:
+********************************************************************************************************************/
+void TsAddBaProcess(unsigned long data)
+{
+ PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
+ u8 num = pTxTs->num;
+ struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]);
+
+ TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
+ IEEE80211_DEBUG(IEEE80211_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n");
+}
+
+
+void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo)
+{
+ memset(pTsCommonInfo->Addr, 0, 6);
+ memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY));
+ memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM);
+ pTsCommonInfo->TClasProc = 0;
+ pTsCommonInfo->TClasNum = 0;
+}
+
+void ResetTxTsEntry(PTX_TS_RECORD pTS)
+{
+ ResetTsCommonInfo(&pTS->TsCommonInfo);
+ pTS->TxCurSeq = 0;
+ pTS->bAddBaReqInProgress = false;
+ pTS->bAddBaReqDelayed = false;
+ pTS->bUsingBa = false;
+ ResetBaEntry(&pTS->TxAdmittedBARecord); //For BA Originator
+ ResetBaEntry(&pTS->TxPendingBARecord);
+}
+
+void ResetRxTsEntry(PRX_TS_RECORD pTS)
+{
+ ResetTsCommonInfo(&pTS->TsCommonInfo);
+ pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!!
+ pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!!
+ ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recepient
+}
+
+void TSInitialize(struct ieee80211_device *ieee)
+{
+ PTX_TS_RECORD pTxTS = ieee->TxTsRecord;
+ PRX_TS_RECORD pRxTS = ieee->RxTsRecord;
+ PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry;
+ u8 count = 0;
+ IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __FUNCTION__);
+ // Initialize Tx TS related info.
+ INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
+ INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
+ INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);
+
+ for(count = 0; count < TOTAL_TS_NUM; count++)
+ {
+ //
+ pTxTS->num = count;
+ // The timers for the operation of Traffic Stream and Block Ack.
+ // DLS related timer will be add here in the future!!
+ init_timer(&pTxTS->TsCommonInfo.SetupTimer);
+ pTxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pTxTS;
+ pTxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
+
+ init_timer(&pTxTS->TsCommonInfo.InactTimer);
+ pTxTS->TsCommonInfo.InactTimer.data = (unsigned long)pTxTS;
+ pTxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
+
+ init_timer(&pTxTS->TsAddBaTimer);
+ pTxTS->TsAddBaTimer.data = (unsigned long)pTxTS;
+ pTxTS->TsAddBaTimer.function = TsAddBaProcess;
+
+ init_timer(&pTxTS->TxPendingBARecord.Timer);
+ pTxTS->TxPendingBARecord.Timer.data = (unsigned long)pTxTS;
+ pTxTS->TxPendingBARecord.Timer.function = BaSetupTimeOut;
+
+ init_timer(&pTxTS->TxAdmittedBARecord.Timer);
+ pTxTS->TxAdmittedBARecord.Timer.data = (unsigned long)pTxTS;
+ pTxTS->TxAdmittedBARecord.Timer.function = TxBaInactTimeout;
+
+ ResetTxTsEntry(pTxTS);
+ list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List);
+ pTxTS++;
+ }
+
+ // Initialize Rx TS related info.
+ INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List);
+ INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List);
+ INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List);
+ for(count = 0; count < TOTAL_TS_NUM; count++)
+ {
+ pRxTS->num = count;
+ INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
+
+ init_timer(&pRxTS->TsCommonInfo.SetupTimer);
+ pRxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pRxTS;
+ pRxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
+
+ init_timer(&pRxTS->TsCommonInfo.InactTimer);
+ pRxTS->TsCommonInfo.InactTimer.data = (unsigned long)pRxTS;
+ pRxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
+
+ init_timer(&pRxTS->RxAdmittedBARecord.Timer);
+ pRxTS->RxAdmittedBARecord.Timer.data = (unsigned long)pRxTS;
+ pRxTS->RxAdmittedBARecord.Timer.function = RxBaInactTimeout;
+
+ init_timer(&pRxTS->RxPktPendingTimer);
+ pRxTS->RxPktPendingTimer.data = (unsigned long)pRxTS;
+ pRxTS->RxPktPendingTimer.function = RxPktPendingTimeout;
+
+ ResetRxTsEntry(pRxTS);
+ list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
+ pRxTS++;
+ }
+ // Initialize unused Rx Reorder List.
+ INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
+//#ifdef TO_DO_LIST
+ for(count = 0; count < REORDER_ENTRY_NUM; count++)
+ {
+ list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
+ if(count == (REORDER_ENTRY_NUM-1))
+ break;
+ pRxReorderEntry = &ieee->RxReorderEntry[count+1];
+ }
+//#endif
+
+}
+
+void AdmitTS(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime)
+{
+ del_timer_sync(&pTsCommonInfo->SetupTimer);
+ del_timer_sync(&pTsCommonInfo->InactTimer);
+
+ if(InactTime!=0)
+ mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime));
+}
+
+
+PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect)
+{
+ //DIRECTION_VALUE dir;
+ u8 dir;
+ bool search_dir[4] = {0, 0, 0, 0};
+ struct list_head* psearch_list; //FIXME
+ PTS_COMMON_INFO pRet = NULL;
+ if(ieee->iw_mode == IW_MODE_MASTER) //ap mode
+ {
+ if(TxRxSelect == TX_DIR)
+ {
+ search_dir[DIR_DOWN] = true;
+ search_dir[DIR_BI_DIR]= true;
+ }
+ else
+ {
+ search_dir[DIR_UP] = true;
+ search_dir[DIR_BI_DIR]= true;
+ }
+ }
+ else if(ieee->iw_mode == IW_MODE_ADHOC)
+ {
+ if(TxRxSelect == TX_DIR)
+ search_dir[DIR_UP] = true;
+ else
+ search_dir[DIR_DOWN] = true;
+ }
+ else
+ {
+ if(TxRxSelect == TX_DIR)
+ {
+ search_dir[DIR_UP] = true;
+ search_dir[DIR_BI_DIR]= true;
+ search_dir[DIR_DIRECT]= true;
+ }
+ else
+ {
+ search_dir[DIR_DOWN] = true;
+ search_dir[DIR_BI_DIR]= true;
+ search_dir[DIR_DIRECT]= true;
+ }
+ }
+
+ if(TxRxSelect == TX_DIR)
+ psearch_list = &ieee->Tx_TS_Admit_List;
+ else
+ psearch_list = &ieee->Rx_TS_Admit_List;
+
+ //for(dir = DIR_UP; dir <= DIR_BI_DIR; dir++)
+ for(dir = 0; dir <= DIR_BI_DIR; dir++)
+ {
+ if(search_dir[dir] ==false )
+ continue;
+ list_for_each_entry(pRet, psearch_list, List){
+ // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:"MAC_FMT", TID:%d, dir:%d\n", MAC_ARG(pRet->Addr), pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection);
+ if (memcmp(pRet->Addr, Addr, 6) == 0)
+ if (pRet->TSpec.f.TSInfo.field.ucTSID == TID)
+ if(pRet->TSpec.f.TSInfo.field.ucDirection == dir)
+ {
+ // printk("Bingo! got it\n");
+ break;
+ }
+
+ }
+ if(&pRet->List != psearch_list)
+ break;
+ }
+
+ if(&pRet->List != psearch_list){
+ return pRet ;
+ }
+ else
+ return NULL;
+}
+
+void MakeTSEntry(
+ PTS_COMMON_INFO pTsCommonInfo,
+ u8* Addr,
+ PTSPEC_BODY pTSPEC,
+ PQOS_TCLAS pTCLAS,
+ u8 TCLAS_Num,
+ u8 TCLAS_Proc
+ )
+{
+ u8 count;
+
+ if(pTsCommonInfo == NULL)
+ return;
+
+ memcpy(pTsCommonInfo->Addr, Addr, 6);
+
+ if(pTSPEC != NULL)
+ memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY));
+
+ for(count = 0; count < TCLAS_Num; count++)
+ memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS));
+
+ pTsCommonInfo->TClasProc = TCLAS_Proc;
+ pTsCommonInfo->TClasNum = TCLAS_Num;
+}
+
+
+bool GetTs(
+ struct ieee80211_device* ieee,
+ PTS_COMMON_INFO *ppTS,
+ u8* Addr,
+ u8 TID,
+ TR_SELECT TxRxSelect, //Rx:1, Tx:0
+ bool bAddNewTs
+ )
+{
+ u8 UP = 0;
+ //
+ // We do not build any TS for Broadcast or Multicast stream.
+ // So reject these kinds of search here.
+ //
+ if(is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr))
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "get TS for Broadcast or Multicast\n");
+ return false;
+ }
+#if 0
+ if(ieee->pStaQos->CurrentQosMode == QOS_DISABLE)
+ { UP = 0; } //only use one TS
+ else if(ieee->pStaQos->CurrentQosMode & QOS_WMM)
+ {
+#else
+ if (ieee->current_network.qos_data.supported == 0)
+ UP = 0;
+ else
+ {
+#endif
+ // In WMM case: we use 4 TID only
+ if (!IsACValid(TID))
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is not valid\n", __FUNCTION__, TID);
+ return false;
+ }
+
+ switch(TID)
+ {
+ case 0:
+ case 3:
+ UP = 0;
+ break;
+
+ case 1:
+ case 2:
+ UP = 2;
+ break;
+
+ case 4:
+ case 5:
+ UP = 5;
+ break;
+
+ case 6:
+ case 7:
+ UP = 7;
+ break;
+ }
+ }
+
+ *ppTS = SearchAdmitTRStream(
+ ieee,
+ Addr,
+ UP,
+ TxRxSelect);
+ if(*ppTS != NULL)
+ {
+ return true;
+ }
+ else
+ {
+ if(bAddNewTs == false)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_TS, "add new TS failed(tid:%d)\n", UP);
+ return false;
+ }
+ else
+ {
+ //
+ // Create a new Traffic stream for current Tx/Rx
+ // This is for EDCA and WMM to add a new TS.
+ // For HCCA or WMMSA, TS cannot be addmit without negotiation.
+ //
+ TSPEC_BODY TSpec;
+ PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo;
+ struct list_head* pUnusedList =
+ (TxRxSelect == TX_DIR)?
+ (&ieee->Tx_TS_Unused_List):
+ (&ieee->Rx_TS_Unused_List);
+
+ struct list_head* pAddmitList =
+ (TxRxSelect == TX_DIR)?
+ (&ieee->Tx_TS_Admit_List):
+ (&ieee->Rx_TS_Admit_List);
+
+ DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)?
+ ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP):
+ ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN);
+ IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n");
+ if(!list_empty(pUnusedList))
+ {
+ (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List);
+ list_del_init(&(*ppTS)->List);
+ if(TxRxSelect==TX_DIR)
+ {
+ PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo);
+ ResetTxTsEntry(tmp);
+ }
+ else{
+ PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo);
+ ResetRxTsEntry(tmp);
+ }
+
+ IEEE80211_DEBUG(IEEE80211_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT"\n", UP, Dir, MAC_ARG(Addr));
+ // Prepare TS Info releated field
+ pTSInfo->field.ucTrafficType = 0; // Traffic type: WMM is reserved in this field
+ pTSInfo->field.ucTSID = UP; // TSID
+ pTSInfo->field.ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration.
+ pTSInfo->field.ucAccessPolicy = 1; // Access policy
+ pTSInfo->field.ucAggregation = 0; // Aggregation
+ pTSInfo->field.ucPSB = 0; // Aggregation
+ pTSInfo->field.ucUP = UP; // User priority
+ pTSInfo->field.ucTSInfoAckPolicy = 0; // Ack policy
+ pTSInfo->field.ucSchedule = 0; // Schedule
+
+ MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0);
+ AdmitTS(ieee, *ppTS, 0);
+ list_add_tail(&((*ppTS)->List), pAddmitList);
+ // if there is DirectLink, we need to do additional operation here!!
+
+ return true;
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "in function %s() There is not enough TS record to be used!!", __FUNCTION__);
+ return false;
+ }
+ }
+ }
+}
+
+void RemoveTsEntry(
+ struct ieee80211_device* ieee,
+ PTS_COMMON_INFO pTs,
+ TR_SELECT TxRxSelect
+ )
+{
+ //u32 flags = 0;
+ unsigned long flags = 0;
+ del_timer_sync(&pTs->SetupTimer);
+ del_timer_sync(&pTs->InactTimer);
+ TsInitDelBA(ieee, pTs, TxRxSelect);
+
+ if(TxRxSelect == RX_DIR)
+ {
+//#ifdef TO_DO_LIST
+ PRX_REORDER_ENTRY pRxReorderEntry;
+ PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs;
+ if(timer_pending(&pRxTS->RxPktPendingTimer))
+ del_timer_sync(&pRxTS->RxPktPendingTimer);
+
+ while(!list_empty(&pRxTS->RxPendingPktList))
+ {
+ // PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
+ spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
+ //pRxReorderEntry = list_entry(&pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
+ pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
+ list_del_init(&pRxReorderEntry->List);
+ {
+ int i = 0;
+ struct ieee80211_rxb * prxb = pRxReorderEntry->prxb;
+ if (unlikely(!prxb))
+ {
+ spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
+ return;
+ }
+ for(i =0; i < prxb->nr_subframes; i++) {
+ dev_kfree_skb(prxb->subframes[i]);
+ }
+ kfree(prxb);
+ prxb = NULL;
+ }
+ list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
+ //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
+ spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
+ }
+
+//#endif
+ }
+ else
+ {
+ PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs;
+ del_timer_sync(&pTxTS->TsAddBaTimer);
+ }
+}
+
+void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr)
+{
+ PTS_COMMON_INFO pTS, pTmpTS;
+ printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr));
+#if 1
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
+ {
+ if (memcmp(pTS->Addr, Addr, 6) == 0)
+ {
+ RemoveTsEntry(ieee, pTS, TX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
+ }
+ }
+
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
+ {
+ if (memcmp(pTS->Addr, Addr, 6) == 0)
+ {
+ printk("====>remove Tx_TS_admin_list\n");
+ RemoveTsEntry(ieee, pTS, TX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
+ }
+ }
+
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
+ {
+ if (memcmp(pTS->Addr, Addr, 6) == 0)
+ {
+ RemoveTsEntry(ieee, pTS, RX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
+ }
+ }
+
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
+ {
+ if (memcmp(pTS->Addr, Addr, 6) == 0)
+ {
+ RemoveTsEntry(ieee, pTS, RX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
+ }
+ }
+#endif
+}
+
+void RemoveAllTS(struct ieee80211_device* ieee)
+{
+ PTS_COMMON_INFO pTS, pTmpTS;
+#if 1
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
+ {
+ RemoveTsEntry(ieee, pTS, TX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
+ }
+
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
+ {
+ RemoveTsEntry(ieee, pTS, TX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
+ }
+
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
+ {
+ RemoveTsEntry(ieee, pTS, RX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
+ }
+
+ list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
+ {
+ RemoveTsEntry(ieee, pTS, RX_DIR);
+ list_del_init(&pTS->List);
+ list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
+ }
+#endif
+}
+
+void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS)
+{
+ if(pTxTS->bAddBaReqInProgress == false)
+ {
+ pTxTS->bAddBaReqInProgress = true;
+#if 1
+ if(pTxTS->bAddBaReqDelayed)
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
+ mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY));
+ }
+ else
+ {
+ IEEE80211_DEBUG(IEEE80211_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
+ mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); //set 10 ticks
+ }
+#endif
+ }
+ else
+ IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __FUNCTION__);
+}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+EXPORT_SYMBOL_NOVERS(RemovePeerTS);
+#else
+EXPORT_SYMBOL(RemovePeerTS);
+#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl_crypto.h b/drivers/staging/rtl8192su/ieee80211/rtl_crypto.h
new file mode 100644
index 000000000000..ccf6ae763572
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/rtl_crypto.h
@@ -0,0 +1,399 @@
+/*
+ * Scatterlist Cryptographic API.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 David S. Miller (davem@redhat.com)
+ *
+ * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
+ * and Nettle, by Niels Mé°ˆler.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _LINUX_CRYPTO_H
+#define _LINUX_CRYPTO_H
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/string.h>
+#include <asm/page.h>
+#include <asm/errno.h>
+
+#define crypto_register_alg crypto_register_alg_rsl
+#define crypto_unregister_alg crypto_unregister_alg_rsl
+#define crypto_alloc_tfm crypto_alloc_tfm_rsl
+#define crypto_free_tfm crypto_free_tfm_rsl
+#define crypto_alg_available crypto_alg_available_rsl
+
+/*
+ * Algorithm masks and types.
+ */
+#define CRYPTO_ALG_TYPE_MASK 0x000000ff
+#define CRYPTO_ALG_TYPE_CIPHER 0x00000001
+#define CRYPTO_ALG_TYPE_DIGEST 0x00000002
+#define CRYPTO_ALG_TYPE_COMPRESS 0x00000004
+
+/*
+ * Transform masks and values (for crt_flags).
+ */
+#define CRYPTO_TFM_MODE_MASK 0x000000ff
+#define CRYPTO_TFM_REQ_MASK 0x000fff00
+#define CRYPTO_TFM_RES_MASK 0xfff00000
+
+#define CRYPTO_TFM_MODE_ECB 0x00000001
+#define CRYPTO_TFM_MODE_CBC 0x00000002
+#define CRYPTO_TFM_MODE_CFB 0x00000004
+#define CRYPTO_TFM_MODE_CTR 0x00000008
+
+#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
+#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
+#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
+#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
+#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
+#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
+
+/*
+ * Miscellaneous stuff.
+ */
+#define CRYPTO_UNSPEC 0
+#define CRYPTO_MAX_ALG_NAME 64
+
+struct scatterlist;
+
+/*
+ * Algorithms: modular crypto algorithm implementations, managed
+ * via crypto_register_alg() and crypto_unregister_alg().
+ */
+struct cipher_alg {
+ unsigned int cia_min_keysize;
+ unsigned int cia_max_keysize;
+ int (*cia_setkey)(void *ctx, const u8 *key,
+ unsigned int keylen, u32 *flags);
+ void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src);
+ void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src);
+};
+
+struct digest_alg {
+ unsigned int dia_digestsize;
+ void (*dia_init)(void *ctx);
+ void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
+ void (*dia_final)(void *ctx, u8 *out);
+ int (*dia_setkey)(void *ctx, const u8 *key,
+ unsigned int keylen, u32 *flags);
+};
+
+struct compress_alg {
+ int (*coa_init)(void *ctx);
+ void (*coa_exit)(void *ctx);
+ int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen);
+ int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen);
+};
+
+#define cra_cipher cra_u.cipher
+#define cra_digest cra_u.digest
+#define cra_compress cra_u.compress
+
+struct crypto_alg {
+ struct list_head cra_list;
+ u32 cra_flags;
+ unsigned int cra_blocksize;
+ unsigned int cra_ctxsize;
+ const char cra_name[CRYPTO_MAX_ALG_NAME];
+
+ union {
+ struct cipher_alg cipher;
+ struct digest_alg digest;
+ struct compress_alg compress;
+ } cra_u;
+
+ struct module *cra_module;
+};
+
+/*
+ * Algorithm registration interface.
+ */
+int crypto_register_alg(struct crypto_alg *alg);
+int crypto_unregister_alg(struct crypto_alg *alg);
+
+/*
+ * Algorithm query interface.
+ */
+int crypto_alg_available(const char *name, u32 flags);
+
+/*
+ * Transforms: user-instantiated objects which encapsulate algorithms
+ * and core processing logic. Managed via crypto_alloc_tfm() and
+ * crypto_free_tfm(), as well as the various helpers below.
+ */
+struct crypto_tfm;
+
+struct cipher_tfm {
+ void *cit_iv;
+ unsigned int cit_ivsize;
+ u32 cit_mode;
+ int (*cit_setkey)(struct crypto_tfm *tfm,
+ const u8 *key, unsigned int keylen);
+ int (*cit_encrypt)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes);
+ int (*cit_encrypt_iv)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv);
+ int (*cit_decrypt)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes);
+ int (*cit_decrypt_iv)(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv);
+ void (*cit_xor_block)(u8 *dst, const u8 *src);
+};
+
+struct digest_tfm {
+ void (*dit_init)(struct crypto_tfm *tfm);
+ void (*dit_update)(struct crypto_tfm *tfm,
+ struct scatterlist *sg, unsigned int nsg);
+ void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
+ void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
+ unsigned int nsg, u8 *out);
+ int (*dit_setkey)(struct crypto_tfm *tfm,
+ const u8 *key, unsigned int keylen);
+#ifdef CONFIG_CRYPTO_HMAC
+ void *dit_hmac_block;
+#endif
+};
+
+struct compress_tfm {
+ int (*cot_compress)(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen);
+ int (*cot_decompress)(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen);
+};
+
+#define crt_cipher crt_u.cipher
+#define crt_digest crt_u.digest
+#define crt_compress crt_u.compress
+
+struct crypto_tfm {
+
+ u32 crt_flags;
+
+ union {
+ struct cipher_tfm cipher;
+ struct digest_tfm digest;
+ struct compress_tfm compress;
+ } crt_u;
+
+ struct crypto_alg *__crt_alg;
+};
+
+/*
+ * Transform user interface.
+ */
+
+/*
+ * crypto_alloc_tfm() will first attempt to locate an already loaded algorithm.
+ * If that fails and the kernel supports dynamically loadable modules, it
+ * will then attempt to load a module of the same name or alias. A refcount
+ * is grabbed on the algorithm which is then associated with the new transform.
+ *
+ * crypto_free_tfm() frees up the transform and any associated resources,
+ * then drops the refcount on the associated algorithm.
+ */
+struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
+void crypto_free_tfm(struct crypto_tfm *tfm);
+
+/*
+ * Transform helpers which query the underlying algorithm.
+ */
+static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm)
+{
+ return tfm->__crt_alg->cra_name;
+}
+
+static inline const char *crypto_tfm_alg_modname(struct crypto_tfm *tfm)
+{
+ struct crypto_alg *alg = tfm->__crt_alg;
+
+ if (alg->cra_module)
+ return alg->cra_module->name;
+ else
+ return NULL;
+}
+
+static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
+{
+ return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
+}
+
+static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->__crt_alg->cra_cipher.cia_min_keysize;
+}
+
+static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->__crt_alg->cra_cipher.cia_max_keysize;
+}
+
+static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_ivsize;
+}
+
+static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
+{
+ return tfm->__crt_alg->cra_blocksize;
+}
+
+static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ return tfm->__crt_alg->cra_digest.dia_digestsize;
+}
+
+/*
+ * API wrappers.
+ */
+static inline void crypto_digest_init(struct crypto_tfm *tfm)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ tfm->crt_digest.dit_init(tfm);
+}
+
+static inline void crypto_digest_update(struct crypto_tfm *tfm,
+ struct scatterlist *sg,
+ unsigned int nsg)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ tfm->crt_digest.dit_update(tfm, sg, nsg);
+}
+
+static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ tfm->crt_digest.dit_final(tfm, out);
+}
+
+static inline void crypto_digest_digest(struct crypto_tfm *tfm,
+ struct scatterlist *sg,
+ unsigned int nsg, u8 *out)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ tfm->crt_digest.dit_digest(tfm, sg, nsg, out);
+}
+
+static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
+ const u8 *key, unsigned int keylen)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ if (tfm->crt_digest.dit_setkey == NULL)
+ return -ENOSYS;
+ return tfm->crt_digest.dit_setkey(tfm, key, keylen);
+}
+
+static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
+ const u8 *key, unsigned int keylen)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_setkey(tfm, key, keylen);
+}
+
+static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
+}
+
+static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
+ return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);
+}
+
+static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
+}
+
+static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
+ struct scatterlist *dst,
+ struct scatterlist *src,
+ unsigned int nbytes, u8 *iv)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
+ return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);
+}
+
+static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int len)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ memcpy(tfm->crt_cipher.cit_iv, src, len);
+}
+
+static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
+ u8 *dst, unsigned int len)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+ memcpy(dst, tfm->crt_cipher.cit_iv, len);
+}
+
+static inline int crypto_comp_compress(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
+ return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen);
+}
+
+static inline int crypto_comp_decompress(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int slen,
+ u8 *dst, unsigned int *dlen)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
+ return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen);
+}
+
+/*
+ * HMAC support.
+ */
+#ifdef CONFIG_CRYPTO_HMAC
+void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen);
+void crypto_hmac_update(struct crypto_tfm *tfm,
+ struct scatterlist *sg, unsigned int nsg);
+void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key,
+ unsigned int *keylen, u8 *out);
+void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen,
+ struct scatterlist *sg, unsigned int nsg, u8 *out);
+#endif /* CONFIG_CRYPTO_HMAC */
+
+#endif /* _LINUX_CRYPTO_H */
+
diff --git a/drivers/staging/rtl8192su/ieee80211/scatterwalk.c b/drivers/staging/rtl8192su/ieee80211/scatterwalk.c
new file mode 100644
index 000000000000..49f401fbce88
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/scatterwalk.c
@@ -0,0 +1,126 @@
+/*
+ * Cryptographic API.
+ *
+ * Cipher operations.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * 2002 Adam J. Richter <adam@yggdrasil.com>
+ * 2004 Jean-Luc Cooke <jlcooke@certainkey.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include "kmap_types.h"
+
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <asm/scatterlist.h>
+#include "internal.h"
+#include "scatterwalk.h"
+
+enum km_type crypto_km_types[] = {
+ KM_USER0,
+ KM_USER1,
+ KM_SOFTIRQ0,
+ KM_SOFTIRQ1,
+};
+
+void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, void *scratch)
+{
+ if (nbytes <= walk->len_this_page &&
+ (((unsigned long)walk->data) & (PAGE_CACHE_SIZE - 1)) + nbytes <=
+ PAGE_CACHE_SIZE)
+ return walk->data;
+ else
+ return scratch;
+}
+
+static void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out)
+{
+ if (out)
+ memcpy(sgdata, buf, nbytes);
+ else
+ memcpy(buf, sgdata, nbytes);
+}
+
+void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg)
+{
+ unsigned int rest_of_page;
+
+ walk->sg = sg;
+
+ walk->page = sg->page;
+ walk->len_this_segment = sg->length;
+
+ rest_of_page = PAGE_CACHE_SIZE - (sg->offset & (PAGE_CACHE_SIZE - 1));
+ walk->len_this_page = min(sg->length, rest_of_page);
+ walk->offset = sg->offset;
+}
+
+void scatterwalk_map(struct scatter_walk *walk, int out)
+{
+ walk->data = crypto_kmap(walk->page, out) + walk->offset;
+}
+
+static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
+ unsigned int more)
+{
+ /* walk->data may be pointing the first byte of the next page;
+ however, we know we transfered at least one byte. So,
+ walk->data - 1 will be a virtual address in the mapped page. */
+
+ if (out)
+ flush_dcache_page(walk->page);
+
+ if (more) {
+ walk->len_this_segment -= walk->len_this_page;
+
+ if (walk->len_this_segment) {
+ walk->page++;
+ walk->len_this_page = min(walk->len_this_segment,
+ (unsigned)PAGE_CACHE_SIZE);
+ walk->offset = 0;
+ }
+ else
+ scatterwalk_start(walk, sg_next(walk->sg));
+ }
+}
+
+void scatterwalk_done(struct scatter_walk *walk, int out, int more)
+{
+ crypto_kunmap(walk->data, out);
+ if (walk->len_this_page == 0 || !more)
+ scatterwalk_pagedone(walk, out, more);
+}
+
+/*
+ * Do not call this unless the total length of all of the fragments
+ * has been verified as multiple of the block size.
+ */
+int scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
+ size_t nbytes, int out)
+{
+ if (buf != walk->data) {
+ while (nbytes > walk->len_this_page) {
+ memcpy_dir(buf, walk->data, walk->len_this_page, out);
+ buf += walk->len_this_page;
+ nbytes -= walk->len_this_page;
+
+ crypto_kunmap(walk->data, out);
+ scatterwalk_pagedone(walk, out, 1);
+ scatterwalk_map(walk, out);
+ }
+
+ memcpy_dir(buf, walk->data, nbytes, out);
+ }
+
+ walk->offset += nbytes;
+ walk->len_this_page -= nbytes;
+ walk->len_this_segment -= nbytes;
+ return 0;
+}
diff --git a/drivers/staging/rtl8192su/ieee80211/scatterwalk.h b/drivers/staging/rtl8192su/ieee80211/scatterwalk.h
new file mode 100644
index 000000000000..b16446519017
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211/scatterwalk.h
@@ -0,0 +1,51 @@
+/*
+ * Cryptographic API.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com>
+ * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+
+#ifndef _CRYPTO_SCATTERWALK_H
+#define _CRYPTO_SCATTERWALK_H
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+
+struct scatter_walk {
+ struct scatterlist *sg;
+ struct page *page;
+ void *data;
+ unsigned int len_this_page;
+ unsigned int len_this_segment;
+ unsigned int offset;
+};
+
+/* Define sg_next is an inline routine now in case we want to change
+ scatterlist to a linked list later. */
+static inline struct scatterlist *sg_next(struct scatterlist *sg)
+{
+ return sg + 1;
+}
+
+static inline int scatterwalk_samebuf(struct scatter_walk *walk_in,
+ struct scatter_walk *walk_out,
+ void *src_p, void *dst_p)
+{
+ return walk_in->page == walk_out->page &&
+ walk_in->offset == walk_out->offset &&
+ walk_in->data == src_p && walk_out->data == dst_p;
+}
+
+void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, void *scratch);
+void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
+int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out);
+void scatterwalk_map(struct scatter_walk *walk, int out);
+void scatterwalk_done(struct scatter_walk *walk, int out, int more);
+
+#endif /* _CRYPTO_SCATTERWALK_H */
diff --git a/drivers/staging/rtl8192su/ieee80211_crypt.h b/drivers/staging/rtl8192su/ieee80211_crypt.h
new file mode 100644
index 000000000000..b58a3bcc0dc0
--- /dev/null
+++ b/drivers/staging/rtl8192su/ieee80211_crypt.h
@@ -0,0 +1,86 @@
+/*
+ * Original code based on Host AP (software wireless LAN access point) driver
+ * for Intersil Prism2/2.5/3.
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * Adaption to a generic IEEE 802.11 stack by James Ketrenos
+ * <jketreno@linux.intel.com>
+ *
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+/*
+ * This file defines the interface to the ieee80211 crypto module.
+ */
+#ifndef IEEE80211_CRYPT_H
+#define IEEE80211_CRYPT_H
+
+#include <linux/skbuff.h>
+
+struct ieee80211_crypto_ops {
+ const char *name;
+
+ /* init new crypto context (e.g., allocate private data space,
+ * select IV, etc.); returns NULL on failure or pointer to allocated
+ * private data on success */
+ void * (*init)(int keyidx);
+
+ /* deinitialize crypto context and free allocated private data */
+ void (*deinit)(void *priv);
+
+ /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
+ * value from decrypt_mpdu is passed as the keyidx value for
+ * decrypt_msdu. skb must have enough head and tail room for the
+ * encryption; if not, error will be returned; these functions are
+ * called for all MPDUs (i.e., fragments).
+ */
+ int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+ int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+
+ /* These functions are called for full MSDUs, i.e. full frames.
+ * These can be NULL if full MSDU operations are not needed. */
+ int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
+ int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
+ void *priv);
+
+ int (*set_key)(void *key, int len, u8 *seq, void *priv);
+ int (*get_key)(void *key, int len, u8 *seq, void *priv);
+
+ /* procfs handler for printing out key information and possible
+ * statistics */
+ char * (*print_stats)(char *p, void *priv);
+
+ /* maximum number of bytes added by encryption; encrypt buf is
+ * allocated with extra_prefix_len bytes, copy of in_buf, and
+ * extra_postfix_len; encrypt need not use all this space, but
+ * the result must start at the beginning of the buffer and correct
+ * length must be returned */
+ int extra_prefix_len, extra_postfix_len;
+
+ struct module *owner;
+};
+
+struct ieee80211_crypt_data {
+ struct list_head list; /* delayed deletion list */
+ struct ieee80211_crypto_ops *ops;
+ void *priv;
+ atomic_t refcnt;
+};
+
+int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
+int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
+void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
+void ieee80211_crypt_deinit_handler(unsigned long);
+void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
+ struct ieee80211_crypt_data **crypt);
+
+#endif
diff --git a/drivers/staging/rtl8192su/r8180_93cx6.c b/drivers/staging/rtl8192su/r8180_93cx6.c
new file mode 100644
index 000000000000..8878cfeb0fbb
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8180_93cx6.c
@@ -0,0 +1,146 @@
+/*
+ This files contains card eeprom (93c46 or 93c56) programming routines,
+ memory is addressed by 16 bits words.
+
+ This is part of rtl8180 OpenSource driver.
+ Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+ Parts of this driver are based on the GPL part of the
+ official realtek driver.
+
+ Parts of this driver are based on the rtl8180 driver skeleton
+ from Patric Schenke & Andres Salomon.
+
+ Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
+
+ We want to tanks the Authors of those projects and the Ndiswrapper
+ project Authors.
+*/
+
+#include "r8180_93cx6.h"
+
+void eprom_cs(struct net_device *dev, short bit)
+{
+ if(bit)
+ write_nic_byte_E(dev, EPROM_CMD,
+ (1<<EPROM_CS_SHIFT) | \
+ read_nic_byte_E(dev, EPROM_CMD)); //enable EPROM
+ else
+ write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev, EPROM_CMD)\
+ &~(1<<EPROM_CS_SHIFT)); //disable EPROM
+
+ force_pci_posting(dev);
+ udelay(EPROM_DELAY);
+}
+
+
+void eprom_ck_cycle(struct net_device *dev)
+{
+ write_nic_byte_E(dev, EPROM_CMD,
+ (1<<EPROM_CK_SHIFT) | read_nic_byte_E(dev,EPROM_CMD));
+ force_pci_posting(dev);
+ udelay(EPROM_DELAY);
+ write_nic_byte_E(dev, EPROM_CMD,
+ read_nic_byte_E(dev, EPROM_CMD) &~ (1<<EPROM_CK_SHIFT));
+ force_pci_posting(dev);
+ udelay(EPROM_DELAY);
+}
+
+
+void eprom_w(struct net_device *dev,short bit)
+{
+ if(bit)
+ write_nic_byte_E(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) | \
+ read_nic_byte_E(dev,EPROM_CMD));
+ else
+ write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev,EPROM_CMD)\
+ &~(1<<EPROM_W_SHIFT));
+
+ force_pci_posting(dev);
+ udelay(EPROM_DELAY);
+}
+
+
+short eprom_r(struct net_device *dev)
+{
+ short bit;
+
+ bit=(read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) );
+ udelay(EPROM_DELAY);
+
+ if(bit) return 1;
+ return 0;
+}
+
+
+void eprom_send_bits_string(struct net_device *dev, short b[], int len)
+{
+ int i;
+
+ for(i=0; i<len; i++){
+ eprom_w(dev, b[i]);
+ eprom_ck_cycle(dev);
+ }
+}
+
+
+u32 eprom_read(struct net_device *dev, u32 addr)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ short read_cmd[]={1,1,0};
+ short addr_str[8];
+ int i;
+ int addr_len;
+ u32 ret;
+
+ ret=0;
+ //enable EPROM programming
+ write_nic_byte_E(dev, EPROM_CMD,
+ (EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT));
+ force_pci_posting(dev);
+ udelay(EPROM_DELAY);
+
+ if (priv->epromtype==EPROM_93c56){
+ addr_str[7]=addr & 1;
+ addr_str[6]=addr & (1<<1);
+ addr_str[5]=addr & (1<<2);
+ addr_str[4]=addr & (1<<3);
+ addr_str[3]=addr & (1<<4);
+ addr_str[2]=addr & (1<<5);
+ addr_str[1]=addr & (1<<6);
+ addr_str[0]=addr & (1<<7);
+ addr_len=8;
+ }else{
+ addr_str[5]=addr & 1;
+ addr_str[4]=addr & (1<<1);
+ addr_str[3]=addr & (1<<2);
+ addr_str[2]=addr & (1<<3);
+ addr_str[1]=addr & (1<<4);
+ addr_str[0]=addr & (1<<5);
+ addr_len=6;
+ }
+ eprom_cs(dev, 1);
+ eprom_ck_cycle(dev);
+ eprom_send_bits_string(dev, read_cmd, 3);
+ eprom_send_bits_string(dev, addr_str, addr_len);
+
+ //keep chip pin D to low state while reading.
+ //I'm unsure if it is necessary, but anyway shouldn't hurt
+ eprom_w(dev, 0);
+
+ for(i=0;i<16;i++){
+ //eeprom needs a clk cycle between writing opcode&adr
+ //and reading data. (eeprom outs a dummy 0)
+ eprom_ck_cycle(dev);
+ ret |= (eprom_r(dev)<<(15-i));
+ }
+
+ eprom_cs(dev, 0);
+ eprom_ck_cycle(dev);
+
+ //disable EPROM programming
+ write_nic_byte_E(dev, EPROM_CMD,
+ (EPROM_CMD_NORMAL<<EPROM_CMD_OPERATING_MODE_SHIFT));
+ return ret;
+}
diff --git a/drivers/staging/rtl8192su/r8180_93cx6.h b/drivers/staging/rtl8192su/r8180_93cx6.h
new file mode 100644
index 000000000000..ca228d368174
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8180_93cx6.h
@@ -0,0 +1,45 @@
+/*
+ This is part of rtl8187 OpenSource driver
+ Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+ Parts of this driver are based on the GPL part of the official realtek driver
+ Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
+ Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
+
+ We want to tanks the Authors of such projects and the Ndiswrapper project Authors.
+*/
+
+/*This files contains card eeprom (93c46 or 93c56) programming routines*/
+/*memory is addressed by WORDS*/
+
+#ifdef RTL8192SU
+#include "r8192U.h"
+#include "r8192S_hw.h"
+#else
+#include "r8192U.h"
+#include "r8192U_hw.h"
+#endif
+
+#define EPROM_DELAY 10
+
+#define EPROM_ANAPARAM_ADDRLWORD 0xd
+#define EPROM_ANAPARAM_ADDRHWORD 0xe
+
+#define EPROM_RFCHIPID 0x6
+#define EPROM_TXPW_BASE 0x05
+#define EPROM_RFCHIPID_RTL8225U 5
+#define EPROM_RF_PARAM 0x4
+#define EPROM_CONFIG2 0xc
+
+#define EPROM_VERSION 0x1E
+#define MAC_ADR 0x7
+
+#define CIS 0x18
+
+#define EPROM_TXPW0 0x16
+#define EPROM_TXPW2 0x1b
+#define EPROM_TXPW1 0x3d
+
+
+u32 eprom_read(struct net_device *dev,u32 addr); //reads a 16 bits word
diff --git a/drivers/staging/rtl8192su/r8190_rtl8256.c b/drivers/staging/rtl8192su/r8190_rtl8256.c
new file mode 100644
index 000000000000..74ff337b0583
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8190_rtl8256.c
@@ -0,0 +1,312 @@
+/*
+ This is part of the rtl8192 driver
+ released under the GPL (See file COPYING for details).
+
+ This files contains programming code for the rtl8256
+ radio frontend.
+
+ *Many* thanks to Realtek Corp. for their great support!
+
+*/
+
+#include "r8192U.h"
+#include "r8192U_hw.h"
+#include "r819xU_phyreg.h"
+#include "r819xU_phy.h"
+#include "r8190_rtl8256.h"
+
+/*--------------------------------------------------------------------------
+ * Overview: set RF band width (20M or 40M)
+ * Input: struct net_device* dev
+ * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
+ * Output: NONE
+ * Return: NONE
+ * Note: 8226 support both 20M and 40 MHz
+ *---------------------------------------------------------------------------*/
+void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
+{
+ u8 eRFPath;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ for(eRFPath = 0; eRFPath <RF90_PATH_MAX; eRFPath++)
+ {
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ continue;
+
+ switch(Bandwidth)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ if(priv->card_8192_version == VERSION_819xU_A || priv->card_8192_version == VERSION_819xU_B)// 8256 D-cut, E-cut, xiong: consider it later!
+ {
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x100); //phy para:1ba
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7);
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x021);
+
+ //cosa add for sd3's request 01/23/2008
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab);
+ }
+ else
+ {
+ RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
+ }
+
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ if(priv->card_8192_version == VERSION_819xU_A ||priv->card_8192_version == VERSION_819xU_B)// 8256 D-cut, E-cut, xiong: consider it later!
+ {
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); //phy para:3ba
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3df);
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0a1);
+
+ //cosa add for sd3's request 01/23/2008
+ if(priv->chan == 3 || priv->chan == 9) //I need to set priv->chan whenever current channel changes
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x59b);
+ else
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab);
+ }
+ else
+ {
+ RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
+ }
+
+
+ break;
+ default:
+ RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth );
+ break;
+
+ }
+ }
+ return;
+}
+/*--------------------------------------------------------------------------
+ * Overview: Interface to config 8256
+ * Input: struct net_device* dev
+ * Output: NONE
+ * Return: NONE
+ *---------------------------------------------------------------------------*/
+void PHY_RF8256_Config(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ // Initialize general global value
+ //
+ // TODO: Extend RF_PATH_C and RF_PATH_D in the future
+ priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
+ // Config BB and RF
+ phy_RF8256_Config_ParaFile(dev);
+
+ return;
+}
+/*--------------------------------------------------------------------------
+ * Overview: Interface to config 8256
+ * Input: struct net_device* dev
+ * Output: NONE
+ * Return: NONE
+ *---------------------------------------------------------------------------*/
+void phy_RF8256_Config_ParaFile(struct net_device* dev)
+{
+ u32 u4RegValue = 0;
+ //static s1Byte szRadioAFile[] = RTL819X_PHY_RADIO_A;
+ //static s1Byte szRadioBFile[] = RTL819X_PHY_RADIO_B;
+ //static s1Byte szRadioCFile[] = RTL819X_PHY_RADIO_C;
+ //static s1Byte szRadioDFile[] = RTL819X_PHY_RADIO_D;
+ u8 eRFPath;
+ BB_REGISTER_DEFINITION_T *pPhyReg;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 RegOffSetToBeCheck = 0x3;
+ u32 RegValueToBeCheck = 0x7f1;
+ u32 RF3_Final_Value = 0;
+ u8 ConstRetryTimes = 5, RetryTimes = 5;
+ u8 ret = 0;
+ //3//-----------------------------------------------------------------
+ //3// <2> Initialize RF
+ //3//-----------------------------------------------------------------
+ for(eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ continue;
+
+ pPhyReg = &priv->PHYRegDef[eRFPath];
+
+ // Joseph test for shorten RF config
+ // pHalData->RfReg0Value[eRFPath] = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, rGlobalCtrl, bMaskDWord);
+
+ /*----Store original RFENV control type----*/
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ case RF90_PATH_C:
+ u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
+ break;
+ case RF90_PATH_B :
+ case RF90_PATH_D:
+ u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
+ break;
+ }
+
+ /*----Set RF_ENV enable----*/
+ rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
+
+ /*----Set RF_ENV output high----*/
+ rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
+
+ /* Set bit number of Address and Data for RF register */
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ???
+
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf);
+
+ /*----Check RF block (for FPGA platform only)----*/
+ // TODO: this function should be removed on ASIC , Emily 2007.2.2
+ if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath))
+ {
+ RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath);
+ goto phy_RF8256_Config_ParaFile_Fail;
+ }
+
+ RetryTimes = ConstRetryTimes;
+ RF3_Final_Value = 0;
+ /*----Initialize RF fom connfiguration file----*/
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
+ {
+ ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+ RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
+ RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
+ RetryTimes--;
+ }
+ break;
+ case RF90_PATH_B:
+ while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
+ {
+ ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+ RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
+ RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
+ RetryTimes--;
+ }
+ break;
+ case RF90_PATH_C:
+ while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
+ {
+ ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+ RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
+ RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
+ RetryTimes--;
+ }
+ break;
+ case RF90_PATH_D:
+ while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
+ {
+ ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+ RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
+ RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
+ RetryTimes--;
+ }
+ break;
+ }
+
+ /*----Restore RFENV control type----*/;
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ case RF90_PATH_C:
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
+ break;
+ case RF90_PATH_B :
+ case RF90_PATH_D:
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
+ break;
+ }
+
+ if(ret){
+ RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath);
+ goto phy_RF8256_Config_ParaFile_Fail;
+ }
+
+ }
+
+ RT_TRACE(COMP_PHY, "PHY Initialization Success\n") ;
+ return ;
+
+phy_RF8256_Config_ParaFile_Fail:
+ RT_TRACE(COMP_ERR, "PHY Initialization failed\n") ;
+ return ;
+}
+
+
+void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel)
+{
+ u32 TxAGC=0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //modified by vivi, 20080109
+ TxAGC = powerlevel;
+
+ if(priv->bDynamicTxLowPower == TRUE ) //cosa 05/22/2008 for scan
+ {
+ if(priv->CustomerID == RT_CID_819x_Netcore)
+ TxAGC = 0x22;
+ else
+ TxAGC += priv->CckPwEnl;
+ }
+
+ if(TxAGC > 0x24)
+ TxAGC = 0x24;
+ rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
+}
+
+
+void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //Joseph TxPower for 8192 testing
+ u32 writeVal, powerBase0, powerBase1, writeVal_tmp;
+ u8 index = 0;
+ u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
+ u8 byte0, byte1, byte2, byte3;
+
+ powerBase0 = powerlevel + priv->TxPowerDiff; //OFDM rates
+ powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
+ powerBase1 = powerlevel; //MCS rates
+ powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
+
+ for(index=0; index<6; index++)
+ {
+ writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1);
+ byte0 = (u8)(writeVal & 0x7f);
+ byte1 = (u8)((writeVal & 0x7f00)>>8);
+ byte2 = (u8)((writeVal & 0x7f0000)>>16);
+ byte3 = (u8)((writeVal & 0x7f000000)>>24);
+ if(byte0 > 0x24) // Max power index = 0x24
+ byte0 = 0x24;
+ if(byte1 > 0x24)
+ byte1 = 0x24;
+ if(byte2 > 0x24)
+ byte2 = 0x24;
+ if(byte3 > 0x24)
+ byte3 = 0x24;
+
+ //for tx power track
+ if(index == 3)
+ {
+ writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
+ priv->Pwr_Track = writeVal_tmp;
+ }
+
+ if(priv->bDynamicTxHighPower == TRUE) //Add by Jacken 2008/03/06
+ {
+ // Emily, 20080613. Set low tx power for both MCS and legacy OFDM
+ writeVal = 0x03030303;
+ }
+ else
+ {
+ writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
+ }
+ rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
+ }
+ return;
+
+}
+
diff --git a/drivers/staging/rtl8192su/r8190_rtl8256.h b/drivers/staging/rtl8192su/r8190_rtl8256.h
new file mode 100644
index 000000000000..5c1f650fe824
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8190_rtl8256.h
@@ -0,0 +1,27 @@
+/*
+ This is part of the rtl8180-sa2400 driver
+ released under the GPL (See file COPYING for details).
+ Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
+
+ This files contains programming code for the rtl8256
+ radio frontend.
+
+ *Many* thanks to Realtek Corp. for their great support!
+
+*/
+
+#ifndef RTL8225H
+#define RTL8225H
+
+#ifdef RTL8190P
+#define RTL819X_TOTAL_RF_PATH 4 //for 90P
+#else
+#define RTL819X_TOTAL_RF_PATH 2 //for 8192U
+#endif
+extern void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
+extern void PHY_RF8256_Config(struct net_device* dev);
+extern void phy_RF8256_Config_ParaFile(struct net_device* dev);
+extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel);
+extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel);
+
+#endif
diff --git a/drivers/staging/rtl8192su/r8192SU_HWImg.c b/drivers/staging/rtl8192su/r8192SU_HWImg.c
new file mode 100644
index 000000000000..cbb65795a302
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192SU_HWImg.c
@@ -0,0 +1,4902 @@
+/*Created on 2009/ 1/15, 3:10*/
+
+#include "r8192SU_HWImg.h"
+
+u8 Rtl8192SUFwImgArray[ImgArrayLength] = {
+0x92,0x81,0x2b,0x90,0x30,0x00,0x00,0x00,0x08,0x74,0x00,0x00,0x88,0x96,0x00,0x00,
+0x30,0x00,0x00,0x00,0x00,0x95,0x00,0x00,0x00,0x00,0x2b,0x00,0x03,0x03,0x23,0x00,
+0x92,0x81,0x02,0x01,0x00,0x00,0x12,0x04,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x01,0x01,0x00,0x00,
+0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x7f,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x1f,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x25,0xb0,0x1a,0x3c,0x80,0x03,0x5a,0x37,0x00,0x80,0x1b,0x3c,0x80,0x00,0x7b,0x37,
+0x00,0x00,0x5b,0xaf,0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x37,0x00,0x80,0x1b,0x3c,
+0x80,0x00,0x7b,0x37,0x00,0x00,0x5b,0xaf,0x00,0x80,0x1a,0x3c,0x10,0x6d,0x5a,0x27,
+0x08,0x00,0x40,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x04,0x00,0xa1,0xaf,0x08,0x00,0xa2,0xaf,0x0c,0x00,0xa3,0xaf,0x10,0x00,0xa4,0xaf,
+0x14,0x00,0xa5,0xaf,0x18,0x00,0xa6,0xaf,0x1c,0x00,0xa7,0xaf,0x20,0x00,0xa8,0xaf,
+0x24,0x00,0xa9,0xaf,0x28,0x00,0xaa,0xaf,0x2c,0x00,0xab,0xaf,0x30,0x00,0xac,0xaf,
+0x34,0x00,0xad,0xaf,0x38,0x00,0xae,0xaf,0x3c,0x00,0xaf,0xaf,0x12,0x40,0x00,0x00,
+0x10,0x48,0x00,0x00,0x00,0x70,0x0a,0x40,0x40,0x00,0xb0,0xaf,0x44,0x00,0xb1,0xaf,
+0x48,0x00,0xb2,0xaf,0x4c,0x00,0xb3,0xaf,0x50,0x00,0xb4,0xaf,0x54,0x00,0xb5,0xaf,
+0x58,0x00,0xb6,0xaf,0x5c,0x00,0xb7,0xaf,0x60,0x00,0xb8,0xaf,0x64,0x00,0xb9,0xaf,
+0x68,0x00,0xbc,0xaf,0x6c,0x00,0xbd,0xaf,0x70,0x00,0xbe,0xaf,0x74,0x00,0xbf,0xaf,
+0x78,0x00,0xa8,0xaf,0x7c,0x00,0xa9,0xaf,0x80,0x00,0xaa,0xaf,0xdf,0x1a,0x00,0x08,
+0x21,0x20,0xa0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x25,0xb0,0x06,0x3c,0x00,0x80,0x02,0x3c,0xe8,0xff,0xbd,0x27,0x18,0x03,0xc3,0x34,
+0x00,0x03,0x42,0x24,0x14,0x00,0xbf,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x00,0x62,0xac,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x42,0xb0,0x03,0x3c,
+0x03,0x00,0x63,0x34,0x00,0x00,0x62,0x90,0x02,0x80,0x0a,0x3c,0x02,0x80,0x10,0x3c,
+0xff,0x00,0x42,0x30,0x00,0x46,0x02,0x00,0x10,0x00,0x42,0x30,0x13,0x00,0x40,0x10,
+0x03,0x46,0x08,0x00,0xc4,0x7d,0x42,0x8d,0x68,0x15,0x05,0x26,0xd4,0x63,0xa4,0x94,
+0x01,0x00,0x47,0x24,0x10,0x00,0x02,0x24,0xb0,0x03,0xc9,0x34,0x00,0x00,0x62,0xa0,
+0x07,0x00,0x80,0x10,0x1c,0x03,0xc6,0x34,0xd8,0x63,0xa2,0x8c,0xd4,0x63,0xa0,0xa4,
+0xd8,0x63,0xa0,0xac,0x00,0x00,0x04,0x24,0x00,0x00,0xc2,0xac,0x00,0x00,0x20,0xad,
+0x01,0x00,0x82,0x24,0xc4,0x7d,0x47,0xad,0xd4,0x63,0xa2,0xa4,0x12,0x00,0x00,0x05,
+0x42,0xb0,0x02,0x3c,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x68,0x15,0x04,0x26,0x0c,0x4b,0x83,0x94,0x08,0x4b,0x85,0x94,
+0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,0x80,0x00,0x63,0x30,0x41,0xb0,0x02,0x3c,
+0x25,0x18,0x65,0x00,0x08,0x00,0x42,0x34,0x18,0x00,0xbd,0x27,0x00,0x00,0x43,0xa4,
+0x08,0x00,0xe0,0x03,0x08,0x4b,0x83,0xa4,0x80,0xff,0x03,0x24,0x03,0x00,0x42,0x34,
+0x00,0x00,0x43,0xa0,0xc8,0x0e,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x68,0x15,0x04,0x26,
+0x0c,0x4b,0x83,0x94,0x08,0x4b,0x85,0x94,0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,
+0x80,0x00,0x63,0x30,0x41,0xb0,0x02,0x3c,0x25,0x18,0x65,0x00,0x08,0x00,0x42,0x34,
+0x18,0x00,0xbd,0x27,0x00,0x00,0x43,0xa4,0x08,0x00,0xe0,0x03,0x08,0x4b,0x83,0xa4,
+0xff,0x00,0x84,0x30,0x0b,0x00,0x82,0x2c,0xff,0xff,0xe7,0x30,0x10,0x00,0xa8,0x93,
+0x19,0x00,0x40,0x10,0x21,0x18,0x00,0x00,0x02,0x80,0x03,0x3c,0x80,0x10,0x04,0x00,
+0xc0,0x91,0x63,0x24,0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,0x00,0x00,0x00,0x00,
+0x08,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x43,0xb0,0x02,0x3c,0x78,0x00,0x44,0x34,
+0x07,0x00,0xe2,0x30,0x00,0x00,0x85,0xac,0x04,0x00,0x86,0xac,0x04,0x00,0x40,0x18,
+0x00,0x00,0x00,0x00,0xf8,0xff,0xe2,0x30,0x08,0x00,0x42,0x24,0xff,0xff,0x47,0x30,
+0x21,0x10,0xe8,0x00,0x00,0x80,0x03,0x3c,0x08,0x00,0x82,0xac,0x25,0x10,0x43,0x00,
+0x08,0x00,0x82,0xac,0x01,0x00,0x03,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,0x6c,0x00,0x44,0x34,0x43,0xb0,0x02,0x3c,
+0x20,0x01,0x00,0x08,0x60,0x00,0x44,0x34,0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,
+0x54,0x00,0x44,0x34,0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,0x48,0x00,0x44,0x34,
+0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,0x3c,0x00,0x44,0x34,0x43,0xb0,0x02,0x3c,
+0x20,0x01,0x00,0x08,0x30,0x00,0x44,0x34,0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,
+0x24,0x00,0x44,0x34,0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,0x18,0x00,0x44,0x34,
+0x43,0xb0,0x02,0x3c,0x20,0x01,0x00,0x08,0x0c,0x00,0x44,0x34,0x20,0x01,0x00,0x08,
+0x43,0xb0,0x04,0x3c,0x01,0x00,0x02,0x24,0x25,0xb0,0x03,0x3c,0x04,0x20,0x82,0x00,
+0x18,0x03,0x67,0x34,0x00,0x80,0x02,0x3c,0x43,0xb0,0x03,0x3c,0x34,0x05,0x46,0x24,
+0x88,0x00,0x65,0x34,0x21,0x10,0x00,0x00,0x01,0x00,0x42,0x24,0xff,0xff,0x42,0x30,
+0x05,0x00,0x43,0x2c,0xfd,0xff,0x60,0x14,0x01,0x00,0x42,0x24,0x00,0x00,0xe6,0xac,
+0x00,0x00,0xa2,0x94,0x00,0x00,0x00,0x00,0xff,0xff,0x42,0x30,0x24,0x10,0x44,0x00,
+0xf4,0xff,0x40,0x1c,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x25,0xb0,0x08,0x3c,0x00,0x80,0x02,0x3c,0xc8,0xff,0xbd,0x27,0x18,0x03,0x03,0x35,
+0x90,0x05,0x42,0x24,0x00,0x00,0x62,0xac,0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x1c,0x00,0xb1,0xaf,0x34,0x00,0xbf,0xaf,0x2c,0x00,0xb5,0xaf,
+0x20,0x00,0xb2,0xaf,0x18,0x00,0xb0,0xaf,0x0c,0x00,0xf2,0x84,0x08,0x00,0xf5,0x8c,
+0xff,0x00,0xc6,0x30,0x00,0x01,0x02,0x24,0x23,0x10,0x46,0x00,0xff,0xff,0x51,0x30,
+0xd0,0x03,0x08,0x35,0xff,0x00,0x96,0x30,0x00,0x00,0x12,0xad,0x21,0xa0,0xa0,0x00,
+0x21,0x30,0xc5,0x00,0x00,0x00,0x15,0xad,0x21,0x20,0xc0,0x02,0x21,0x28,0xa0,0x02,
+0x21,0x38,0x20,0x02,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x23,0x18,0x51,0x02,
+0xff,0xff,0x82,0x32,0x00,0x94,0x03,0x00,0x03,0x94,0x12,0x00,0xa6,0x01,0x00,0x08,
+0x02,0x9a,0x02,0x00,0x28,0xb0,0x03,0x3c,0xc0,0x10,0x13,0x00,0x21,0x10,0x43,0x00,
+0x00,0x00,0x44,0x90,0x25,0xb0,0x10,0x3c,0x20,0x10,0x02,0x3c,0xff,0x00,0x93,0x30,
+0x00,0x22,0x13,0x00,0xff,0xff,0x43,0x32,0x01,0x01,0x45,0x2a,0x21,0xa0,0x82,0x00,
+0x21,0xa8,0xb1,0x02,0xd0,0x03,0x02,0x36,0x00,0x01,0x11,0x24,0x0b,0x88,0x65,0x00,
+0x21,0x20,0xc0,0x02,0x00,0x00,0x53,0xac,0x4d,0x01,0x00,0x0c,0xb0,0x03,0x10,0x36,
+0x21,0x30,0x80,0x02,0x21,0x20,0xc0,0x02,0x21,0x28,0xa0,0x02,0x21,0x38,0x20,0x02,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x23,0x18,0x51,0x02,0x00,0x94,0x03,0x00,
+0x03,0x94,0x12,0x00,0x00,0x00,0x12,0xae,0xe2,0xff,0x40,0x1e,0x00,0x00,0x00,0x00,
+0x34,0x00,0xbf,0x8f,0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,
+0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,0xc8,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,
+0x25,0xb0,0x04,0x3c,0x20,0x00,0xb2,0xaf,0x68,0x15,0x52,0x24,0x00,0x80,0x02,0x3c,
+0x18,0x03,0x83,0x34,0xc8,0x06,0x42,0x24,0x28,0x00,0xb4,0xaf,0x24,0x00,0xb3,0xaf,
+0x30,0x00,0xbf,0xaf,0x2c,0x00,0xb5,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x00,0x00,0x62,0xac,0xb0,0x03,0x93,0x34,0x21,0xa0,0x40,0x02,0x54,0x64,0x42,0x8e,
+0xc0,0x64,0x50,0x8e,0x21,0x20,0x00,0x00,0x00,0x00,0x62,0xae,0x58,0x64,0x42,0xae,
+0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0xc0,0x64,0x44,0x8e,
+0xc4,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,0x3f,0x00,0x62,0x24,0x2b,0x10,0x44,0x00,
+0x0a,0x18,0x82,0x00,0xc0,0x64,0x43,0xae,0xc0,0x64,0x85,0x8e,0x00,0x00,0x00,0x00,
+0x00,0x00,0x65,0xae,0x02,0x80,0x02,0x3c,0xff,0xff,0x10,0x32,0x25,0x80,0x02,0x02,
+0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,0xff,0x00,0x15,0x24,0x21,0x20,0x00,0x00,
+0x00,0x00,0x62,0xae,0x0c,0x00,0x11,0x92,0x20,0x10,0x02,0x3c,0x20,0x00,0x07,0x24,
+0x00,0x1a,0x11,0x00,0x21,0x18,0x62,0x00,0x05,0x00,0x35,0x12,0x21,0x30,0x60,0x00,
+0x08,0x64,0x91,0xa2,0x54,0x64,0x83,0xae,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0x04,0x00,0x04,0x8e,0x08,0x00,0x03,0x8e,0xff,0xe0,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x1f,0x00,0x84,0x30,0x24,0x18,0x62,0x00,0x00,0x26,0x04,0x00,0xff,0xdf,0x02,0x3c,
+0x25,0x18,0x64,0x00,0xff,0xff,0x42,0x34,0x24,0x18,0x62,0x00,0x00,0x40,0x04,0x3c,
+0x25,0x18,0x64,0x00,0xc0,0xff,0x02,0x24,0x24,0x18,0x62,0x00,0x08,0x00,0x03,0xae,
+0xc9,0x64,0x84,0x92,0x2a,0xb0,0x02,0x3c,0x01,0x00,0x03,0x24,0x01,0x00,0x84,0x24,
+0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0xc4,0xff,0x35,0x16,0xc9,0x64,0x84,0xa2,
+0xfc,0x4a,0x82,0x8e,0x41,0xb0,0x03,0x3c,0x30,0x00,0xbf,0x8f,0x00,0x38,0x42,0x34,
+0x00,0x00,0x62,0xac,0x2c,0x00,0xb5,0x8f,0xfc,0x4a,0x82,0xae,0x24,0x00,0xb3,0x8f,
+0x28,0x00,0xb4,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,0x25,0xb0,0x04,0x3c,0x00,0x80,0x02,0x3c,
+0xc8,0xff,0xbd,0x27,0x18,0x03,0x83,0x34,0x38,0x08,0x42,0x24,0x34,0x00,0xbf,0xaf,
+0x30,0x00,0xb6,0xaf,0x2c,0x00,0xb5,0xaf,0x28,0x00,0xb4,0xaf,0x24,0x00,0xb3,0xaf,
+0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,0x00,0x00,0x62,0xac,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x02,0x80,0x16,0x3c,
+0x68,0x15,0xd2,0x26,0xb0,0x03,0x93,0x34,0x2d,0x02,0x00,0x08,0x21,0xa8,0x40,0x02,
+0x2a,0xb0,0x02,0x3c,0x08,0x00,0x04,0xae,0x09,0x00,0x42,0x34,0x01,0x00,0x03,0x24,
+0x02,0x00,0x04,0x24,0x00,0x00,0x43,0xa0,0x00,0x00,0x44,0xa0,0x42,0x00,0x34,0x12,
+0x00,0x00,0x00,0x00,0x6c,0x64,0x42,0x8e,0xd8,0x64,0x50,0x8e,0x01,0x00,0x04,0x24,
+0x00,0x00,0x62,0xae,0x70,0x64,0x42,0xae,0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xd8,0x64,0x44,0x8e,0xdc,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,
+0x3f,0x00,0x62,0x24,0x2b,0x10,0x44,0x00,0x0a,0x18,0x82,0x00,0xd8,0x64,0x43,0xae,
+0xd8,0x64,0xa5,0x8e,0x00,0x00,0x00,0x00,0x00,0x00,0x65,0xae,0x02,0x80,0x02,0x3c,
+0xff,0xff,0x10,0x32,0x25,0x80,0x02,0x02,0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,
+0xff,0x00,0x14,0x24,0x01,0x00,0x04,0x24,0x00,0x00,0x62,0xae,0x0c,0x00,0x11,0x92,
+0x20,0x10,0x02,0x3c,0x20,0x00,0x07,0x24,0x00,0x1a,0x11,0x00,0x21,0x18,0x62,0x00,
+0x05,0x00,0x34,0x12,0x21,0x30,0x60,0x00,0x6c,0x64,0xa3,0xae,0x10,0x64,0xb1,0xa2,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x04,0x00,0x04,0x8e,0x08,0x00,0x03,0x8e,
+0xff,0xe0,0x02,0x3c,0xff,0xff,0x42,0x34,0x1f,0x00,0x84,0x30,0x24,0x18,0x62,0x00,
+0x00,0x26,0x04,0x00,0xff,0xdf,0x02,0x3c,0x25,0x18,0x64,0x00,0xff,0xff,0x42,0x34,
+0x24,0x18,0x62,0x00,0x00,0x40,0x04,0x3c,0x25,0x18,0x64,0x00,0xc0,0xff,0x05,0x24,
+0x82,0x11,0x03,0x00,0x24,0x20,0x65,0x00,0x01,0x00,0x42,0x30,0xc0,0xff,0x40,0x10,
+0x04,0x00,0x84,0x34,0x2a,0xb0,0x02,0x3c,0x08,0x00,0x03,0xae,0x09,0x00,0x42,0x34,
+0x01,0x00,0x03,0x24,0x02,0x00,0x04,0x24,0x00,0x00,0x43,0xa0,0x00,0x00,0x44,0xa0,
+0xc0,0xff,0x34,0x16,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x68,0x15,0xc2,0x26,0xfc,0x4a,0x43,0x8c,
+0x34,0x00,0xbf,0x8f,0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,
+0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x00,0x38,0x63,0x34,0x41,0xb0,0x04,0x3c,0x38,0x00,0xbd,0x27,0x00,0x00,0x83,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0x43,0xac,0x25,0xb0,0x04,0x3c,0x00,0x80,0x02,0x3c,
+0xc0,0xff,0xbd,0x27,0x18,0x03,0x83,0x34,0x08,0x0a,0x42,0x24,0x38,0x00,0xbf,0xaf,
+0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x2c,0x00,0xb5,0xaf,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x00,0x00,0x62,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x02,0x80,0x17,0x3c,0x68,0x15,0xf2,0x26,0xb0,0x03,0x93,0x34,0x02,0x80,0x14,0x3c,
+0xab,0x02,0x00,0x08,0x21,0xb0,0x40,0x02,0x2a,0xb0,0x03,0x3c,0x08,0x00,0x04,0xae,
+0x05,0x00,0x63,0x34,0x01,0x00,0x02,0x24,0x02,0x00,0x04,0x24,0x00,0x00,0x62,0xa0,
+0x00,0x00,0x64,0xa0,0xca,0x7d,0x82,0x96,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,
+0xca,0x7d,0x82,0xa6,0xca,0x7d,0x83,0x96,0x25,0xb0,0x02,0x3c,0x66,0x03,0x42,0x34,
+0x00,0x00,0x43,0xa4,0x4a,0x00,0x35,0x12,0x00,0x00,0x00,0x00,0x60,0x64,0x42,0x8e,
+0xcc,0x64,0x50,0x8e,0x01,0x00,0x04,0x24,0x00,0x00,0x62,0xae,0x64,0x64,0x42,0xae,
+0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0xcc,0x64,0x44,0x8e,
+0xd0,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,0x3f,0x00,0x62,0x24,0x2b,0x10,0x44,0x00,
+0x0a,0x18,0x82,0x00,0xcc,0x64,0x43,0xae,0xcc,0x64,0xc5,0x8e,0x00,0x00,0x00,0x00,
+0x00,0x00,0x65,0xae,0x02,0x80,0x02,0x3c,0xff,0xff,0x10,0x32,0x25,0x80,0x02,0x02,
+0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,0xff,0x00,0x15,0x24,0x01,0x00,0x04,0x24,
+0x00,0x00,0x62,0xae,0x0c,0x00,0x11,0x92,0x20,0x10,0x02,0x3c,0x20,0x00,0x07,0x24,
+0x00,0x1a,0x11,0x00,0x21,0x18,0x62,0x00,0x05,0x00,0x35,0x12,0x21,0x30,0x60,0x00,
+0x60,0x64,0xc3,0xae,0x0c,0x64,0xd1,0xa2,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0x04,0x00,0x04,0x8e,0x08,0x00,0x03,0x8e,0xff,0xe0,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x1f,0x00,0x84,0x30,0x24,0x18,0x62,0x00,0x00,0x26,0x04,0x00,0xff,0xdf,0x02,0x3c,
+0x25,0x18,0x64,0x00,0xff,0xff,0x42,0x34,0x24,0x18,0x62,0x00,0x00,0x40,0x04,0x3c,
+0x25,0x18,0x64,0x00,0xc0,0xff,0x05,0x24,0x82,0x11,0x03,0x00,0x24,0x20,0x65,0x00,
+0x01,0x00,0x42,0x30,0xb8,0xff,0x40,0x10,0x04,0x00,0x84,0x34,0x08,0x00,0x03,0xae,
+0x2a,0xb0,0x03,0x3c,0x05,0x00,0x63,0x34,0x01,0x00,0x02,0x24,0x02,0x00,0x04,0x24,
+0x00,0x00,0x62,0xa0,0x00,0x00,0x64,0xa0,0xca,0x7d,0x82,0x96,0x00,0x00,0x00,0x00,
+0x01,0x00,0x42,0x24,0xca,0x7d,0x82,0xa6,0xca,0x7d,0x83,0x96,0x25,0xb0,0x02,0x3c,
+0x66,0x03,0x42,0x34,0x00,0x00,0x43,0xa4,0xb8,0xff,0x35,0x16,0x00,0x00,0x00,0x00,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xe2,0x26,0xfc,0x4a,0x43,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x00,0x38,0x63,0x34,
+0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x83,0xac,0x08,0x00,0xe0,0x03,
+0xfc,0x4a,0x43,0xac,0xc0,0xff,0xbd,0x27,0x2c,0x00,0xb5,0xaf,0x38,0x00,0xbf,0xaf,
+0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,0x24,0x00,0xb3,0xaf,
+0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,0x02,0x80,0x06,0x3c,
+0x7c,0x7e,0xc5,0x90,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,0x18,0x03,0x42,0x34,
+0x24,0x0c,0x63,0x24,0x40,0x00,0xa4,0x30,0x00,0x00,0x43,0xac,0x21,0xa8,0x00,0x00,
+0x03,0x00,0x80,0x10,0x7f,0x00,0xa2,0x30,0xbf,0x00,0xa2,0x30,0x01,0x00,0x15,0x24,
+0x7c,0x7e,0xc2,0xa0,0x7c,0x7e,0xc2,0x90,0x25,0xb0,0x04,0x3c,0x88,0x02,0x83,0x34,
+0x00,0x00,0x62,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x02,0x80,0x16,0x3c,0x68,0x15,0xd2,0x26,0xb0,0x03,0x93,0x34,0x02,0x80,0x14,0x3c,
+0x43,0x03,0x00,0x08,0x21,0xb8,0x40,0x02,0x24,0x10,0xa2,0x00,0x04,0x00,0x42,0x34,
+0x2a,0xb0,0x07,0x3c,0x08,0x00,0x02,0xae,0x0d,0x00,0xe2,0x34,0x04,0x00,0x43,0x24,
+0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,0x02,0x00,0x03,0x24,0x00,0x00,0x44,0xa0,
+0x00,0x00,0x43,0xa0,0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,0x66,0x03,0xc5,0x34,
+0x01,0x00,0x84,0x24,0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,0xff,0x00,0x03,0x24,
+0x00,0x00,0xa2,0xa4,0x5a,0x00,0x23,0x12,0x00,0x00,0x00,0x00,0x24,0x64,0x42,0x8e,
+0x90,0x64,0x50,0x8e,0x03,0x00,0x04,0x24,0x00,0x00,0x62,0xae,0x28,0x64,0x42,0xae,
+0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0x90,0x64,0x44,0x8e,
+0x94,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,0x3f,0x00,0x62,0x24,0x2b,0x10,0x44,0x00,
+0x0a,0x18,0x82,0x00,0x90,0x64,0x43,0xae,0x90,0x64,0xe2,0x8e,0x00,0x00,0x00,0x00,
+0x00,0x00,0x62,0xae,0x02,0x80,0x02,0x3c,0xff,0xff,0x10,0x32,0x25,0x80,0x02,0x02,
+0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xae,
+0x0c,0x00,0x11,0x92,0xff,0x00,0x02,0x24,0x0d,0x00,0x22,0x12,0x00,0x12,0x11,0x00,
+0x20,0x10,0x03,0x3c,0x21,0x10,0x43,0x00,0x5a,0x00,0xa0,0x12,0x24,0x64,0xe2,0xae,
+0xec,0x63,0xf1,0xa2,0x68,0x15,0xc2,0x26,0x24,0x64,0x46,0x8c,0x90,0x64,0x45,0x8c,
+0x03,0x00,0x04,0x24,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0x04,0x00,0x04,0x8e,0x14,0x00,0x03,0x8e,0x08,0x00,0x05,0x8e,0xff,0xe0,0x02,0x3c,
+0x1f,0x00,0x84,0x30,0x42,0x1a,0x03,0x00,0xff,0xff,0x42,0x34,0x00,0x26,0x04,0x00,
+0x24,0x28,0xa2,0x00,0x3f,0x00,0x63,0x30,0x25,0x28,0xa4,0x00,0x0c,0x00,0x63,0x28,
+0x06,0x00,0x60,0x14,0x21,0x20,0xa0,0x00,0x00,0x00,0x02,0x96,0x00,0x00,0x00,0x00,
+0xfd,0x0f,0x42,0x28,0x08,0x00,0x40,0x14,0x82,0x11,0x05,0x00,0xff,0xdf,0x02,0x3c,
+0xff,0xff,0x42,0x34,0x24,0x28,0x82,0x00,0x00,0x40,0x03,0x3c,0x25,0x20,0xa3,0x00,
+0x21,0x28,0x80,0x00,0x82,0x11,0x05,0x00,0x01,0x00,0x42,0x30,0xa6,0xff,0x40,0x10,
+0xc0,0xff,0x02,0x24,0x2a,0xb0,0x07,0x3c,0x0d,0x00,0xe2,0x34,0x04,0x00,0x43,0x24,
+0x08,0x00,0x04,0xae,0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,0x02,0x00,0x03,0x24,
+0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,
+0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,
+0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,0xa8,0xff,0x23,0x16,0x00,0x00,0x00,0x00,
+0x22,0x00,0xa0,0x12,0x68,0x15,0xc2,0x26,0xec,0x63,0x43,0x90,0x41,0x00,0xe4,0x34,
+0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa4,0x8c,
+0x01,0x00,0x02,0x3c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,0x30,0x00,0xb6,0x8f,
+0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,
+0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x00,0x80,0x42,0x34,0x25,0x20,0x82,0x00,
+0x41,0xb0,0x03,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x64,0xac,0x08,0x00,0xe0,0x03,
+0xfc,0x4a,0xa4,0xac,0x65,0x03,0x00,0x08,0xe8,0x63,0xf1,0xa2,0xe8,0x63,0x43,0x90,
+0x40,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,0x00,0x00,0xa3,0xac,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x68,0x15,0xc5,0x26,
+0xfc,0x4a,0xa4,0x8c,0x01,0x00,0x02,0x3c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x00,0x80,0x42,0x34,
+0x25,0x20,0x82,0x00,0x41,0xb0,0x03,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x64,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa4,0xac,0xc0,0xff,0xbd,0x27,0x2c,0x00,0xb5,0xaf,
+0x38,0x00,0xbf,0xaf,0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x02,0x80,0x06,0x3c,0x7c,0x7e,0xc5,0x90,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x18,0x03,0x42,0x34,0x78,0x0f,0x63,0x24,0x10,0x00,0xa4,0x30,0x00,0x00,0x43,0xac,
+0x21,0xa8,0x00,0x00,0x03,0x00,0x80,0x10,0xdf,0x00,0xa2,0x30,0xef,0x00,0xa2,0x30,
+0x01,0x00,0x15,0x24,0x7c,0x7e,0xc2,0xa0,0x7c,0x7e,0xc3,0x90,0x25,0xb0,0x02,0x3c,
+0xb0,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x02,0x80,0x16,0x3c,0x68,0x15,0xd2,0x26,
+0x21,0x98,0x40,0x00,0x02,0x80,0x14,0x3c,0x19,0x04,0x00,0x08,0x21,0xb8,0x40,0x02,
+0x24,0x10,0xa2,0x00,0x04,0x00,0x42,0x34,0x2a,0xb0,0x07,0x3c,0x08,0x00,0x02,0xae,
+0x15,0x00,0xe2,0x34,0x04,0x00,0x43,0x24,0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,
+0x02,0x00,0x03,0x24,0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,0xca,0x7d,0x84,0x96,
+0x25,0xb0,0x06,0x3c,0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,0xca,0x7d,0x84,0xa6,
+0xca,0x7d,0x82,0x96,0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,0x5a,0x00,0x23,0x12,
+0x00,0x00,0x00,0x00,0x30,0x64,0x42,0x8e,0x9c,0x64,0x50,0x8e,0x04,0x00,0x04,0x24,
+0x00,0x00,0x62,0xae,0x34,0x64,0x42,0xae,0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x9c,0x64,0x44,0x8e,0xa0,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,
+0x3f,0x00,0x62,0x24,0x2b,0x10,0x44,0x00,0x0a,0x18,0x82,0x00,0x9c,0x64,0x43,0xae,
+0x9c,0x64,0xe2,0x8e,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xae,0x02,0x80,0x02,0x3c,
+0xff,0xff,0x10,0x32,0x25,0x80,0x02,0x02,0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,
+0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xae,0x0c,0x00,0x11,0x92,0xff,0x00,0x02,0x24,
+0x0d,0x00,0x22,0x12,0x00,0x12,0x11,0x00,0x20,0x10,0x03,0x3c,0x21,0x10,0x43,0x00,
+0x59,0x00,0xa0,0x12,0x30,0x64,0xe2,0xae,0xf4,0x63,0xf1,0xa2,0x68,0x15,0xc2,0x26,
+0x30,0x64,0x46,0x8c,0x9c,0x64,0x45,0x8c,0x04,0x00,0x04,0x24,0x20,0x00,0x07,0x24,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x04,0x00,0x04,0x8e,0x14,0x00,0x03,0x8e,
+0x08,0x00,0x05,0x8e,0xff,0xe0,0x02,0x3c,0x1f,0x00,0x84,0x30,0x42,0x1a,0x03,0x00,
+0xff,0xff,0x42,0x34,0x00,0x26,0x04,0x00,0x24,0x28,0xa2,0x00,0x3f,0x00,0x63,0x30,
+0x25,0x28,0xa4,0x00,0x0c,0x00,0x63,0x28,0x06,0x00,0x60,0x14,0x21,0x20,0xa0,0x00,
+0x00,0x00,0x02,0x96,0x00,0x00,0x00,0x00,0xfd,0x0f,0x42,0x28,0x08,0x00,0x40,0x14,
+0x82,0x11,0x05,0x00,0xff,0xdf,0x02,0x3c,0xff,0xff,0x42,0x34,0x24,0x28,0x82,0x00,
+0x00,0x40,0x03,0x3c,0x25,0x20,0xa3,0x00,0x21,0x28,0x80,0x00,0x82,0x11,0x05,0x00,
+0x01,0x00,0x42,0x30,0xa6,0xff,0x40,0x10,0xc0,0xff,0x02,0x24,0x2a,0xb0,0x07,0x3c,
+0x15,0x00,0xe2,0x34,0x04,0x00,0x43,0x24,0x08,0x00,0x04,0xae,0x0b,0x10,0x75,0x00,
+0x01,0x00,0x04,0x24,0x02,0x00,0x03,0x24,0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,
+0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,
+0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,
+0xa8,0xff,0x23,0x16,0x00,0x00,0x00,0x00,0x21,0x00,0xa0,0x12,0x68,0x15,0xc2,0x26,
+0xf4,0x63,0x43,0x90,0x43,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,
+0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa2,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x06,0x00,0x03,0x3c,
+0x25,0x10,0x43,0x00,0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x82,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa2,0xac,0x3b,0x04,0x00,0x08,0xf0,0x63,0xf1,0xa2,
+0xf0,0x63,0x43,0x90,0x42,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,
+0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa2,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x06,0x00,0x03,0x3c,
+0x25,0x10,0x43,0x00,0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x82,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa2,0xac,0xc0,0xff,0xbd,0x27,0x2c,0x00,0xb5,0xaf,
+0x38,0x00,0xbf,0xaf,0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x02,0x80,0x06,0x3c,0x7c,0x7e,0xc5,0x90,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x18,0x03,0x42,0x34,0xc8,0x12,0x63,0x24,0x01,0x00,0xa4,0x30,0x00,0x00,0x43,0xac,
+0x21,0xa8,0x00,0x00,0x03,0x00,0x80,0x10,0xf7,0x00,0xa2,0x30,0xfe,0x00,0xa2,0x30,
+0x01,0x00,0x15,0x24,0x7c,0x7e,0xc2,0xa0,0x7c,0x7e,0xc3,0x90,0x25,0xb0,0x02,0x3c,
+0xb0,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0x02,0x80,0x16,0x3c,0x68,0x15,0xd2,0x26,0x21,0x98,0x40,0x00,
+0x02,0x80,0x14,0x3c,0xf8,0x04,0x00,0x08,0x21,0xb8,0x40,0x02,0x00,0x00,0x02,0x96,
+0x00,0x00,0x00,0x00,0xfd,0x0f,0x42,0x28,0x54,0x00,0x40,0x10,0xff,0xdf,0x02,0x3c,
+0x00,0x20,0x02,0x3c,0x25,0x28,0xa2,0x00,0x82,0x11,0x05,0x00,0x01,0x00,0x42,0x30,
+0x57,0x00,0x40,0x14,0x2a,0xb0,0x07,0x3c,0xc0,0xff,0x02,0x24,0x24,0x10,0xa2,0x00,
+0x04,0x00,0x42,0x34,0x2a,0xb0,0x07,0x3c,0x08,0x00,0x02,0xae,0x1d,0x00,0xe2,0x34,
+0x04,0x00,0x43,0x24,0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,0x02,0x00,0x03,0x24,
+0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,
+0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,
+0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,0x53,0x00,0x23,0x12,0x00,0x00,0x00,0x00,
+0x3c,0x64,0x42,0x8e,0xa8,0x64,0x50,0x8e,0x05,0x00,0x04,0x24,0x00,0x00,0x62,0xae,
+0x40,0x64,0x42,0xae,0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xa8,0x64,0x44,0x8e,0xac,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,0x3f,0x00,0x62,0x24,
+0x2b,0x10,0x44,0x00,0x0a,0x18,0x82,0x00,0xa8,0x64,0x43,0xae,0xa8,0x64,0xe2,0x8e,
+0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xae,0x02,0x80,0x02,0x3c,0xff,0xff,0x10,0x32,
+0x25,0x80,0x02,0x02,0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,0x00,0x00,0x00,0x00,
+0x00,0x00,0x62,0xae,0x0c,0x00,0x11,0x92,0xff,0x00,0x02,0x24,0x0d,0x00,0x22,0x12,
+0x00,0x12,0x11,0x00,0x20,0x10,0x03,0x3c,0x21,0x10,0x43,0x00,0x52,0x00,0xa0,0x12,
+0x3c,0x64,0xe2,0xae,0x04,0x64,0xf1,0xa2,0x68,0x15,0xc2,0x26,0x3c,0x64,0x46,0x8c,
+0xa8,0x64,0x45,0x8c,0x05,0x00,0x04,0x24,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,
+0x10,0x00,0xa0,0xaf,0x14,0x00,0x03,0x8e,0x04,0x00,0x04,0x8e,0x08,0x00,0x05,0x8e,
+0x42,0x1a,0x03,0x00,0xff,0xe0,0x02,0x3c,0x1f,0x00,0x84,0x30,0x3f,0x00,0x63,0x30,
+0xff,0xff,0x42,0x34,0x24,0x28,0xa2,0x00,0x00,0x26,0x04,0x00,0x0c,0x00,0x63,0x28,
+0xaa,0xff,0x60,0x10,0x25,0x28,0xa4,0x00,0xff,0xdf,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x24,0x10,0xa2,0x00,0x00,0x40,0x03,0x3c,0x25,0x28,0x43,0x00,0x82,0x11,0x05,0x00,
+0x01,0x00,0x42,0x30,0xad,0xff,0x40,0x10,0xc0,0xff,0x02,0x24,0x2a,0xb0,0x07,0x3c,
+0x1d,0x00,0xe2,0x34,0x04,0x00,0x43,0x24,0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,
+0x02,0x00,0x03,0x24,0x08,0x00,0x05,0xae,0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,
+0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,
+0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,
+0xaf,0xff,0x23,0x16,0x00,0x00,0x00,0x00,0x21,0x00,0xa0,0x12,0x68,0x15,0xc2,0x26,
+0x04,0x64,0x43,0x90,0x45,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,
+0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa2,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x18,0x00,0x03,0x3c,
+0x25,0x10,0x43,0x00,0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x82,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa2,0xac,0x1a,0x05,0x00,0x08,0xf8,0x63,0xf1,0xa2,
+0xf8,0x63,0x43,0x90,0x44,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,
+0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa2,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x18,0x00,0x03,0x3c,
+0x25,0x10,0x43,0x00,0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x82,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa2,0xac,0xc0,0xff,0xbd,0x27,0x2c,0x00,0xb5,0xaf,
+0x38,0x00,0xbf,0xaf,0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x02,0x80,0x06,0x3c,0x7c,0x7e,0xc5,0x90,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x18,0x03,0x42,0x34,0x28,0x16,0x63,0x24,0x02,0x00,0xa4,0x30,0x00,0x00,0x43,0xac,
+0x21,0xa8,0x00,0x00,0x03,0x00,0x80,0x10,0xfb,0x00,0xa2,0x30,0xfd,0x00,0xa2,0x30,
+0x01,0x00,0x15,0x24,0x7c,0x7e,0xc2,0xa0,0x7c,0x7e,0xc3,0x90,0x25,0xb0,0x02,0x3c,
+0xb0,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0x02,0x80,0x16,0x3c,0x68,0x15,0xd2,0x26,0x21,0x98,0x40,0x00,
+0x02,0x80,0x14,0x3c,0xd0,0x05,0x00,0x08,0x21,0xb8,0x40,0x02,0x00,0x00,0x02,0x96,
+0x00,0x00,0x00,0x00,0xfd,0x0f,0x42,0x28,0x54,0x00,0x40,0x10,0xff,0xdf,0x02,0x3c,
+0x00,0x20,0x02,0x3c,0x25,0x28,0xa2,0x00,0x82,0x11,0x05,0x00,0x01,0x00,0x42,0x30,
+0x57,0x00,0x40,0x14,0x2a,0xb0,0x07,0x3c,0xc0,0xff,0x02,0x24,0x24,0x10,0xa2,0x00,
+0x04,0x00,0x42,0x34,0x2a,0xb0,0x07,0x3c,0x08,0x00,0x02,0xae,0x25,0x00,0xe2,0x34,
+0x04,0x00,0x43,0x24,0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,0x02,0x00,0x03,0x24,
+0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,
+0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,
+0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,0x53,0x00,0x23,0x12,0x00,0x00,0x00,0x00,
+0x48,0x64,0x42,0x8e,0xb4,0x64,0x50,0x8e,0x06,0x00,0x04,0x24,0x00,0x00,0x62,0xae,
+0x4c,0x64,0x42,0xae,0x00,0x00,0x70,0xae,0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xb4,0x64,0x44,0x8e,0xb8,0x64,0x43,0x8e,0x20,0x00,0x84,0x24,0x3f,0x00,0x62,0x24,
+0x2b,0x10,0x44,0x00,0x0a,0x18,0x82,0x00,0xb4,0x64,0x43,0xae,0xb4,0x64,0xe2,0x8e,
+0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xae,0x02,0x80,0x02,0x3c,0xff,0xff,0x10,0x32,
+0x25,0x80,0x02,0x02,0x00,0x00,0x70,0xae,0x0c,0x00,0x02,0x92,0x00,0x00,0x00,0x00,
+0x00,0x00,0x62,0xae,0x0c,0x00,0x11,0x92,0xff,0x00,0x02,0x24,0x0d,0x00,0x22,0x12,
+0x00,0x12,0x11,0x00,0x20,0x10,0x03,0x3c,0x21,0x10,0x43,0x00,0x52,0x00,0xa0,0x12,
+0x48,0x64,0xe2,0xae,0x00,0x64,0xf1,0xa2,0x68,0x15,0xc2,0x26,0x48,0x64,0x46,0x8c,
+0xb4,0x64,0x45,0x8c,0x06,0x00,0x04,0x24,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,
+0x10,0x00,0xa0,0xaf,0x14,0x00,0x03,0x8e,0x04,0x00,0x04,0x8e,0x08,0x00,0x05,0x8e,
+0x42,0x1a,0x03,0x00,0xff,0xe0,0x02,0x3c,0x1f,0x00,0x84,0x30,0x3f,0x00,0x63,0x30,
+0xff,0xff,0x42,0x34,0x24,0x28,0xa2,0x00,0x00,0x26,0x04,0x00,0x0c,0x00,0x63,0x28,
+0xaa,0xff,0x60,0x10,0x25,0x28,0xa4,0x00,0xff,0xdf,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x24,0x10,0xa2,0x00,0x00,0x40,0x03,0x3c,0x25,0x28,0x43,0x00,0x82,0x11,0x05,0x00,
+0x01,0x00,0x42,0x30,0xad,0xff,0x40,0x10,0xc0,0xff,0x02,0x24,0x2a,0xb0,0x07,0x3c,
+0x25,0x00,0xe2,0x34,0x04,0x00,0x43,0x24,0x0b,0x10,0x75,0x00,0x01,0x00,0x04,0x24,
+0x02,0x00,0x03,0x24,0x08,0x00,0x05,0xae,0x00,0x00,0x44,0xa0,0x00,0x00,0x43,0xa0,
+0xca,0x7d,0x84,0x96,0x25,0xb0,0x06,0x3c,0x66,0x03,0xc5,0x34,0x01,0x00,0x84,0x24,
+0xca,0x7d,0x84,0xa6,0xca,0x7d,0x82,0x96,0xff,0x00,0x03,0x24,0x00,0x00,0xa2,0xa4,
+0xaf,0xff,0x23,0x16,0x00,0x00,0x00,0x00,0x21,0x00,0xa0,0x12,0x68,0x15,0xc2,0x26,
+0x00,0x64,0x43,0x90,0x47,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,
+0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa2,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x60,0x00,0x03,0x3c,
+0x25,0x10,0x43,0x00,0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x82,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa2,0xac,0xf2,0x05,0x00,0x08,0xfc,0x63,0xf1,0xa2,
+0xfc,0x63,0x43,0x90,0x46,0x00,0xe4,0x34,0xb0,0x03,0xc5,0x34,0x00,0x00,0x83,0xa0,
+0x00,0x00,0xa3,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x68,0x15,0xc5,0x26,0xfc,0x4a,0xa2,0x8c,0x38,0x00,0xbf,0x8f,0x34,0x00,0xb7,0x8f,
+0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x60,0x00,0x03,0x3c,
+0x25,0x10,0x43,0x00,0x41,0xb0,0x04,0x3c,0x40,0x00,0xbd,0x27,0x00,0x00,0x82,0xac,
+0x08,0x00,0xe0,0x03,0xfc,0x4a,0xa2,0xac,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x88,0x19,0x63,0x24,0x18,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x02,0x80,0x05,0x3c,0x68,0x15,0xa5,0x24,
+0x04,0x4b,0xa2,0x8c,0xfc,0x4a,0xa4,0x8c,0x00,0x08,0x03,0x3c,0x24,0x10,0x43,0x00,
+0x25,0x20,0x82,0x00,0x41,0xb0,0x03,0x3c,0x00,0x00,0x64,0xac,0x08,0x00,0xe0,0x03,
+0xfc,0x4a,0xa4,0xac,0x25,0xb0,0x04,0x3c,0x00,0x80,0x02,0x3c,0xc0,0xff,0xbd,0x27,
+0x18,0x03,0x83,0x34,0xe4,0x19,0x42,0x24,0x3c,0x00,0xbf,0xaf,0x38,0x00,0xbe,0xaf,
+0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x2c,0x00,0xb5,0xaf,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x00,0x00,0x62,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x02,0x80,0x02,0x3c,0x2a,0xb0,0x03,0x3c,0x68,0x15,0x51,0x24,0xb0,0x03,0x93,0x34,
+0x2c,0x00,0x77,0x34,0x02,0x80,0x15,0x3c,0x02,0x80,0x16,0x3c,0x9c,0x06,0x00,0x08,
+0x02,0x80,0x1e,0x3c,0x14,0x64,0x26,0x92,0xe4,0x64,0x25,0x8e,0x00,0x32,0x06,0x00,
+0x21,0x30,0xc2,0x00,0x78,0x64,0x26,0xae,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0xe4,0x64,0x30,0x8e,0x0a,0x00,0x04,0x24,0x21,0x90,0x00,0x00,0x00,0x00,0x70,0xae,
+0x4d,0x01,0x00,0x0c,0xff,0xff,0x10,0x32,0x02,0x80,0x02,0x3c,0x25,0x80,0x02,0x02,
+0x0c,0x00,0x05,0x92,0x02,0x00,0x04,0x92,0xff,0x00,0x02,0x24,0xff,0x00,0xa3,0x30,
+0x04,0x00,0x62,0x10,0x21,0x80,0x04,0x02,0x00,0x00,0x63,0xae,0x01,0x00,0x12,0x24,
+0x14,0x64,0x25,0xa2,0x88,0x96,0xb0,0xae,0x21,0x28,0x00,0x02,0x02,0x00,0xa2,0x90,
+0x08,0x00,0x10,0x26,0x21,0x20,0x00,0x02,0xff,0x00,0x42,0x30,0x00,0x00,0x62,0xae,
+0x03,0x00,0xa3,0x90,0x00,0x00,0x00,0x00,0x7f,0x00,0x63,0x30,0x00,0x00,0x63,0xae,
+0x00,0x00,0x72,0xae,0x03,0x00,0xa2,0x90,0x84,0x96,0xc3,0x92,0x02,0x00,0xa2,0x90,
+0x00,0x00,0x00,0x00,0xff,0x00,0x42,0x30,0x2c,0x00,0x42,0x28,0x11,0x00,0x40,0x10,
+0x08,0x00,0x02,0x24,0x03,0x00,0xa2,0x90,0x00,0x00,0x00,0x00,0x7f,0x00,0x42,0x30,
+0x84,0x96,0xc2,0xa2,0x02,0x00,0xa3,0x90,0x02,0x80,0x02,0x3c,0x74,0x84,0x42,0x24,
+0xff,0x00,0x63,0x30,0xc0,0x18,0x03,0x00,0x21,0x18,0x62,0x00,0x04,0x00,0x62,0x8c,
+0x00,0x00,0x00,0x00,0x09,0xf8,0x40,0x00,0x80,0x96,0xc2,0xaf,0x21,0xa0,0x40,0x00,
+0x08,0x00,0x02,0x24,0x0a,0x00,0x04,0x24,0x05,0x00,0x82,0x12,0x00,0x01,0x07,0x24,
+0x01,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x01,0x00,0xe2,0xa2,0x01,0x00,0xe3,0xa2,
+0xbc,0xff,0x40,0x16,0x20,0x10,0x02,0x3c,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0xfc,0x4a,0x22,0x8e,0x00,0x04,0x03,0x3c,
+0x41,0xb0,0x04,0x3c,0x25,0x10,0x43,0x00,0x00,0x00,0x82,0xac,0x3c,0x00,0xbf,0x8f,
+0xfc,0x4a,0x22,0xae,0x38,0x00,0xbe,0x8f,0x34,0x00,0xb7,0x8f,0x30,0x00,0xb6,0x8f,
+0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,
+0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x40,0x00,0xbd,0x27,
+0xc8,0xff,0xbd,0x27,0xff,0xff,0xa8,0x30,0x02,0x80,0x02,0x3c,0x25,0x40,0x02,0x01,
+0x30,0x00,0xb6,0xaf,0x20,0x00,0xb2,0xaf,0x34,0x00,0xbf,0xaf,0x2c,0x00,0xb5,0xaf,
+0x28,0x00,0xb4,0xaf,0x24,0x00,0xb3,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x00,0x00,0x03,0x8d,0xff,0xff,0xd2,0x30,0x21,0xb0,0xa0,0x00,0x00,0xc0,0x02,0x24,
+0x08,0x00,0x45,0x26,0x04,0x00,0x06,0x8d,0x24,0x18,0x62,0x00,0xff,0x3f,0xa5,0x30,
+0xf0,0xff,0x02,0x3c,0x25,0x18,0x65,0x00,0xff,0xff,0x42,0x34,0x24,0x18,0x62,0x00,
+0x00,0x80,0x05,0x3c,0x25,0x18,0x65,0x00,0xff,0x01,0xc6,0x34,0x00,0x00,0x03,0xad,
+0x04,0x00,0x06,0xad,0x21,0x48,0x80,0x00,0xff,0xff,0xe7,0x30,0x18,0x00,0x12,0xa5,
+0x1a,0x00,0x07,0xa1,0x18,0x00,0x03,0x8d,0xff,0x7f,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x24,0x18,0x62,0x00,0x02,0x80,0x15,0x3c,0x18,0x00,0x03,0xad,0x68,0x15,0xa5,0x26,
+0xd6,0x63,0xa3,0x90,0x00,0x00,0x00,0x00,0x01,0x00,0x62,0x24,0xd6,0x63,0xa2,0xa0,
+0x18,0x00,0x04,0x8d,0xff,0x80,0x02,0x3c,0x20,0x00,0x45,0x26,0xff,0xff,0x42,0x34,
+0x7f,0x00,0x63,0x30,0xff,0xff,0xb2,0x30,0x24,0x20,0x82,0x00,0x00,0x1e,0x03,0x00,
+0x25,0xb0,0x02,0x3c,0xc0,0x00,0x42,0x34,0x25,0x20,0x83,0x00,0x07,0x00,0x45,0x32,
+0x18,0x00,0x04,0xad,0x00,0x00,0x52,0xa4,0x03,0x00,0xa0,0x10,0xff,0xff,0x42,0x32,
+0x08,0x00,0x42,0x26,0xff,0xff,0x42,0x30,0x68,0x15,0xb4,0x26,0x54,0x65,0x86,0x8e,
+0x58,0x65,0x90,0x8e,0xf8,0xff,0x52,0x30,0x21,0x10,0xd2,0x00,0x2b,0x10,0x02,0x02,
+0x31,0x00,0x40,0x10,0xff,0x00,0x33,0x31,0x23,0x80,0x06,0x02,0x21,0x28,0xc0,0x02,
+0xff,0xff,0x07,0x32,0x01,0x00,0x11,0x24,0x21,0x20,0x60,0x02,0x10,0x01,0x00,0x0c,
+0x10,0x00,0xb1,0xaf,0x23,0x18,0x50,0x02,0xff,0xff,0x72,0x30,0x22,0x10,0x02,0x3c,
+0x21,0x10,0x42,0x02,0x21,0x20,0x60,0x02,0x4d,0x01,0x00,0x0c,0x54,0x65,0x82,0xae,
+0x21,0x28,0xd0,0x02,0x21,0x38,0x40,0x02,0x21,0x20,0x60,0x02,0x10,0x00,0xb1,0xaf,
+0x22,0x10,0x06,0x3c,0x10,0x01,0x00,0x0c,0x68,0x15,0xb1,0x26,0x54,0x65,0x23,0x8e,
+0x25,0xb0,0x10,0x3c,0xb0,0x03,0x02,0x36,0x21,0x20,0x60,0x02,0x00,0x00,0x43,0xac,
+0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0x54,0x65,0x25,0x8e,0xec,0x00,0x02,0x36,
+0xbd,0x00,0x04,0x36,0x00,0x00,0x45,0xac,0x00,0x00,0x83,0x90,0xc2,0x00,0x10,0x36,
+0x34,0x00,0xbf,0x8f,0x10,0x00,0x63,0x34,0x00,0x00,0x83,0xa0,0x30,0x00,0xb6,0x8f,
+0x00,0x00,0x05,0xa6,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,
+0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x01,0x00,0x02,0x24,
+0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,0x21,0x28,0xc0,0x02,0x21,0x20,0x60,0x02,
+0x21,0x38,0x40,0x02,0x01,0x00,0x02,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa2,0xaf,
+0x54,0x65,0x83,0x8e,0x68,0x15,0xb1,0x26,0x25,0xb0,0x10,0x3c,0x21,0x18,0x72,0x00,
+0x54,0x65,0x83,0xae,0x54,0x65,0x23,0x8e,0xb0,0x03,0x02,0x36,0x21,0x20,0x60,0x02,
+0x00,0x00,0x43,0xac,0x4d,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0x54,0x65,0x25,0x8e,
+0xec,0x00,0x02,0x36,0xbd,0x00,0x04,0x36,0x00,0x00,0x45,0xac,0x00,0x00,0x83,0x90,
+0xc2,0x00,0x10,0x36,0x34,0x00,0xbf,0x8f,0x10,0x00,0x63,0x34,0x00,0x00,0x83,0xa0,
+0x30,0x00,0xb6,0x8f,0x00,0x00,0x05,0xa6,0x2c,0x00,0xb5,0x8f,0x28,0x00,0xb4,0x8f,
+0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x01,0x00,0x02,0x24,0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,
+0x25,0xb0,0x02,0x3c,0x14,0x00,0xb1,0xaf,0x18,0x00,0xbf,0xaf,0x10,0x00,0xb0,0xaf,
+0xbf,0x00,0x42,0x34,0x00,0x00,0x43,0x90,0x21,0x28,0x00,0x00,0x08,0x00,0x06,0x24,
+0x04,0x00,0x63,0x2c,0x12,0x00,0x60,0x14,0x21,0x88,0x80,0x00,0x00,0x60,0x02,0x40,
+0x01,0x00,0x41,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x02,0x80,0x03,0x3c,
+0x00,0x7b,0x63,0x24,0x04,0x00,0x64,0x8c,0x00,0x00,0x23,0xae,0x04,0x00,0x71,0xac,
+0x00,0x00,0x91,0xac,0x04,0x00,0x24,0xae,0x00,0x60,0x82,0x40,0x18,0x00,0xbf,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0x08,0x00,0x82,0x94,0x02,0x80,0x04,0x3c,0x97,0x45,0x00,0x0c,0x25,0x20,0x44,0x00,
+0x00,0x60,0x10,0x40,0x01,0x00,0x01,0x36,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x08,0x00,0x25,0x8e,0x0c,0x00,0x26,0x96,0x14,0x00,0x27,0x96,0xf0,0x06,0x00,0x0c,
+0x09,0x00,0x04,0x24,0x04,0x00,0x23,0x8e,0x00,0x00,0x22,0x8e,0x21,0x20,0x20,0x02,
+0x00,0x00,0x62,0xac,0x04,0x00,0x43,0xac,0x00,0x00,0x31,0xae,0xbd,0x4e,0x00,0x0c,
+0x04,0x00,0x31,0xae,0x00,0x60,0x90,0x40,0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x47,0x24,0x8c,0x64,0xe3,0x90,0xff,0xff,0xa5,0x30,0x09,0x00,0xa3,0x10,
+0x21,0x20,0xc0,0x00,0xfc,0x64,0xe2,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0xc2,0xac,
+0x06,0x65,0xe3,0x94,0x0e,0x00,0x02,0x24,0x14,0x00,0xc2,0xac,0x8b,0x07,0x00,0x08,
+0x0c,0x00,0xc3,0xac,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0xd0,0xff,0xbd,0x27,0x4c,0x1f,0x63,0x24,0x18,0x03,0x42,0x34,
+0x28,0x00,0xbf,0xaf,0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,
+0x18,0x00,0xb0,0xaf,0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0x2a,0xb0,0x02,0x3c,0x36,0x00,0x42,0x34,0x00,0x00,0x43,0x90,
+0x02,0x80,0x13,0x3c,0x68,0x15,0x66,0x26,0xc0,0x18,0x03,0x00,0x5c,0x65,0xc5,0x8c,
+0x23,0xb0,0x04,0x3c,0xf0,0x07,0x63,0x30,0xff,0x1f,0x02,0x3c,0x21,0x18,0x64,0x00,
+0xff,0xff,0x42,0x34,0x24,0x20,0x62,0x00,0x23,0x88,0x85,0x00,0x2b,0x38,0x85,0x00,
+0x00,0x04,0x22,0x26,0x00,0x65,0xc3,0x8c,0x0b,0x88,0x47,0x00,0x01,0x04,0x25,0x2e,
+0xfc,0x64,0xc3,0xac,0x60,0x65,0xc4,0xac,0x06,0x65,0xc0,0xa4,0x11,0x00,0xa0,0x14,
+0x05,0x65,0xc0,0xa0,0x00,0xfc,0x83,0x24,0x23,0x10,0x02,0x3c,0x0b,0x18,0x87,0x00,
+0xff,0x03,0x42,0x34,0x2b,0x10,0x43,0x00,0x33,0x00,0x40,0x14,0x00,0x00,0x00,0x00,
+0x23,0x88,0x83,0x00,0x2b,0x10,0x83,0x00,0x5c,0x65,0xc3,0xac,0x03,0x00,0x40,0x10,
+0x01,0x04,0x25,0x2e,0x00,0x04,0x31,0x26,0x01,0x04,0x25,0x2e,0x0e,0x00,0xa0,0x10,
+0x68,0x15,0x70,0x26,0x68,0x15,0x70,0x26,0x60,0x65,0x03,0x8e,0x5c,0x65,0x04,0x8e,
+0x00,0x00,0x00,0x00,0x2b,0x10,0x83,0x00,0x25,0x00,0x40,0x14,0x2b,0x10,0x64,0x00,
+0x51,0x00,0x40,0x14,0x25,0xb0,0x02,0x3c,0x80,0x00,0x03,0x24,0xd0,0x03,0x42,0x34,
+0x00,0x00,0x43,0xac,0x68,0x15,0x70,0x26,0x5c,0x65,0x03,0x96,0x2a,0xb0,0x02,0x3c,
+0x35,0x00,0x42,0x34,0xc2,0x88,0x03,0x00,0x00,0x00,0x51,0xa0,0x8f,0x10,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x06,0x65,0x03,0x96,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,
+0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0xfc,0x4a,0x02,0x8e,0x80,0x00,0x03,0x3c,0x41,0xb0,0x04,0x3c,
+0x25,0x10,0x43,0x00,0x00,0x00,0x82,0xac,0x28,0x00,0xbf,0x8f,0xfc,0x4a,0x02,0xae,
+0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,0x00,0x08,0x00,0x08,0x00,0xfc,0x63,0x24,
+0xfc,0x64,0x05,0x8e,0x21,0x30,0x80,0x00,0xff,0xff,0x27,0x32,0x09,0x00,0x04,0x24,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0xfc,0x64,0x03,0x8e,0x06,0x65,0x05,0x96,
+0x5c,0x65,0x02,0x8e,0x21,0x18,0x71,0x00,0x21,0x28,0x25,0x02,0x21,0x10,0x51,0x00,
+0x09,0x00,0x04,0x24,0x5c,0x65,0x02,0xae,0xfc,0x64,0x03,0xae,0x4d,0x01,0x00,0x0c,
+0x06,0x65,0x05,0xa6,0x68,0x15,0x70,0x26,0x5c,0x65,0x03,0x96,0x2a,0xb0,0x02,0x3c,
+0x35,0x00,0x42,0x34,0xc2,0x88,0x03,0x00,0x00,0x00,0x51,0xa0,0x8f,0x10,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x06,0x65,0x03,0x96,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,
+0x00,0x00,0x43,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0xfc,0x4a,0x02,0x8e,0x80,0x00,0x03,0x3c,0x41,0xb0,0x04,0x3c,
+0x25,0x10,0x43,0x00,0x00,0x00,0x82,0xac,0x28,0x00,0xbf,0x8f,0xfc,0x4a,0x02,0xae,
+0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,0x64,0x65,0x02,0x8e,0xfc,0x64,0x05,0x8e,
+0x21,0x30,0x80,0x00,0x23,0x88,0x44,0x00,0xff,0xff,0x27,0x32,0x09,0x00,0x04,0x24,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0xfc,0x64,0x03,0x8e,0x06,0x65,0x02,0x96,
+0x60,0x65,0x12,0x96,0x21,0x18,0x71,0x00,0x21,0x10,0x22,0x02,0x23,0x10,0x11,0x3c,
+0xfc,0x64,0x03,0xae,0x06,0x65,0x02,0xa6,0x06,0x00,0x40,0x16,0x5c,0x65,0x11,0xae,
+0x09,0x00,0x04,0x24,0x4d,0x01,0x00,0x0c,0x68,0x15,0x70,0x26,0x46,0x08,0x00,0x08,
+0x00,0x00,0x00,0x00,0x4d,0x01,0x00,0x0c,0x09,0x00,0x04,0x24,0xfc,0x64,0x05,0x8e,
+0x09,0x00,0x04,0x24,0x23,0x10,0x06,0x3c,0x21,0x38,0x40,0x02,0x10,0x01,0x00,0x0c,
+0x10,0x00,0xa0,0xaf,0xfc,0x64,0x03,0x8e,0x06,0x65,0x02,0x96,0x21,0x20,0x51,0x02,
+0x21,0x18,0x72,0x00,0x21,0x10,0x42,0x02,0x5c,0x65,0x04,0xae,0x09,0x00,0x04,0x24,
+0xfc,0x64,0x03,0xae,0x75,0x08,0x00,0x08,0x06,0x65,0x02,0xa6,0x02,0x80,0x09,0x3c,
+0x68,0x15,0x28,0x25,0xdc,0x63,0x06,0x8d,0xff,0xff,0x02,0x34,0x3f,0x00,0xc2,0x10,
+0x21,0x38,0x80,0x00,0x2b,0x10,0xc7,0x00,0x30,0x00,0x40,0x10,0x02,0x19,0x06,0x00,
+0x21,0x10,0xc7,0x00,0x23,0x10,0x43,0x00,0x10,0x00,0x46,0x24,0xdc,0x63,0x06,0xad,
+0x68,0x15,0x26,0x25,0x04,0x40,0xc4,0x8c,0xe0,0x63,0x02,0xad,0xff,0xff,0x02,0x34,
+0x2f,0x00,0x82,0x10,0x00,0x00,0x00,0x00,0x2b,0x10,0x87,0x00,0x1f,0x00,0x40,0x10,
+0x02,0x19,0x04,0x00,0x21,0x10,0x87,0x00,0x23,0x10,0x43,0x00,0x10,0x00,0x44,0x24,
+0x04,0x40,0xc4,0xac,0xe0,0x63,0xc2,0xac,0xc0,0x10,0x05,0x00,0x21,0x10,0x45,0x00,
+0x80,0x10,0x02,0x00,0x21,0x10,0x45,0x00,0x68,0x15,0x23,0x25,0x80,0x10,0x02,0x00,
+0x21,0x28,0x43,0x00,0x68,0x51,0xa6,0x8c,0x00,0x21,0x07,0x00,0xff,0xff,0xc2,0x38,
+0x0a,0x30,0x82,0x00,0x2b,0x18,0xc7,0x00,0x07,0x00,0x60,0x10,0x21,0x10,0xc7,0x00,
+0x02,0x19,0x06,0x00,0x23,0x10,0x43,0x00,0x10,0x00,0x46,0x24,0x68,0x51,0xa6,0xac,
+0x08,0x00,0xe0,0x03,0x6c,0x51,0xa2,0xac,0x02,0x19,0x06,0x00,0x23,0x10,0x43,0x00,
+0x68,0x51,0xa2,0xac,0x08,0x00,0xe0,0x03,0x6c,0x51,0xa2,0xac,0x21,0x10,0x87,0x00,
+0x23,0x10,0x43,0x00,0xa5,0x08,0x00,0x08,0x04,0x40,0xc2,0xac,0x21,0x10,0xc7,0x00,
+0x68,0x15,0x26,0x25,0x04,0x40,0xc4,0x8c,0x23,0x10,0x43,0x00,0xdc,0x63,0x02,0xad,
+0xe0,0x63,0x02,0xad,0xff,0xff,0x02,0x34,0xd4,0xff,0x82,0x14,0x2b,0x10,0x87,0x00,
+0x00,0x21,0x07,0x00,0x9e,0x08,0x00,0x08,0x04,0x40,0xc4,0xac,0x00,0x31,0x04,0x00,
+0x91,0x08,0x00,0x08,0xdc,0x63,0x06,0xad,0x63,0x00,0x82,0x24,0x77,0x00,0x42,0x2c,
+0x00,0x00,0x85,0x28,0x04,0x00,0x40,0x10,0x21,0x18,0x00,0x00,0x64,0x00,0x82,0x24,
+0x64,0x00,0x03,0x24,0x0b,0x18,0x45,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0x0c,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x3f,0x00,0x42,0x30,0x04,0x00,0x42,0x28,
+0x17,0x00,0x40,0x10,0x25,0xb0,0x02,0x3c,0x24,0x08,0x42,0x34,0x00,0x00,0x43,0x8c,
+0x00,0x00,0x00,0x00,0x00,0x02,0x63,0x30,0x16,0x00,0x60,0x14,0x01,0x00,0x02,0x24,
+0x05,0x00,0xa3,0x90,0x00,0x00,0x00,0x00,0x82,0x21,0x03,0x00,0x28,0x00,0x82,0x10,
+0xf5,0xff,0x02,0x24,0x02,0x00,0x82,0x28,0x39,0x00,0x40,0x14,0x02,0x00,0x02,0x24,
+0x2e,0x00,0x82,0x10,0xe9,0xff,0x02,0x24,0x03,0x00,0x02,0x24,0x24,0x00,0x82,0x10,
+0x3e,0x00,0x63,0x30,0x05,0x00,0xc4,0x24,0xd2,0x08,0x00,0x08,0x00,0x00,0x00,0x00,
+0x04,0x00,0xa4,0x90,0x00,0x00,0x00,0x00,0x42,0x20,0x04,0x00,0xd2,0x08,0x00,0x08,
+0x96,0xff,0x84,0x24,0x05,0x00,0xa3,0x90,0x00,0x00,0x00,0x00,0x60,0x00,0x64,0x30,
+0x42,0x21,0x04,0x00,0x0e,0x00,0x82,0x10,0x1f,0x00,0x62,0x30,0x02,0x00,0x82,0x28,
+0x1d,0x00,0x40,0x14,0x02,0x00,0x02,0x24,0x14,0x00,0x82,0x10,0x1f,0x00,0x62,0x30,
+0x03,0x00,0x02,0x24,0xeb,0xff,0x82,0x14,0x1f,0x00,0x62,0x30,0x40,0x10,0x02,0x00,
+0xdd,0xff,0x03,0x24,0x23,0x30,0x62,0x00,0xf6,0x08,0x00,0x08,0x05,0x00,0xc4,0x24,
+0x40,0x10,0x02,0x00,0xf5,0xff,0x03,0x24,0x0e,0x09,0x00,0x08,0x23,0x30,0x62,0x00,
+0x3e,0x00,0x63,0x30,0x23,0x30,0x43,0x00,0xf6,0x08,0x00,0x08,0x05,0x00,0xc4,0x24,
+0xdd,0xff,0x02,0x24,0x16,0x09,0x00,0x08,0x23,0x30,0x43,0x00,0x40,0x10,0x02,0x00,
+0xe9,0xff,0x03,0x24,0x0e,0x09,0x00,0x08,0x23,0x30,0x62,0x00,0x3e,0x00,0x63,0x30,
+0x16,0x09,0x00,0x08,0x23,0x30,0x43,0x00,0xd2,0xff,0x80,0x14,0x1f,0x00,0x62,0x30,
+0x40,0x10,0x02,0x00,0xf8,0xff,0x03,0x24,0x0e,0x09,0x00,0x08,0x23,0x30,0x62,0x00,
+0xcc,0xff,0x80,0x14,0x3e,0x00,0x63,0x30,0xf8,0xff,0x02,0x24,0x16,0x09,0x00,0x08,
+0x23,0x30,0x43,0x00,0xa0,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,0x4c,0x00,0xb5,0xaf,
+0x5c,0x00,0xbf,0xaf,0x58,0x00,0xbe,0xaf,0x54,0x00,0xb7,0xaf,0x50,0x00,0xb6,0xaf,
+0x48,0x00,0xb4,0xaf,0x44,0x00,0xb3,0xaf,0x40,0x00,0xb2,0xaf,0x3c,0x00,0xb1,0xaf,
+0x38,0x00,0xb0,0xaf,0x68,0x15,0x55,0x24,0x25,0xb0,0x03,0x3c,0x04,0x01,0x62,0x34,
+0x00,0x00,0x43,0x8c,0x44,0x65,0xa7,0x8e,0x00,0x00,0x00,0x00,0x33,0x00,0xe3,0x10,
+0x48,0x65,0xa3,0xae,0x2b,0x10,0x67,0x00,0xa8,0x00,0x40,0x14,0x2b,0x10,0xe3,0x00,
+0xd1,0x00,0x40,0x14,0x02,0x80,0x02,0x3c,0x68,0x15,0x44,0x24,0x18,0x65,0x83,0x94,
+0x02,0x80,0x02,0x3c,0x21,0x88,0x00,0x00,0x19,0x00,0x40,0x1a,0x25,0x98,0x62,0x00,
+0x21,0xb8,0x80,0x00,0x21,0xb0,0x80,0x00,0x01,0x00,0x14,0x24,0x21,0x20,0x00,0x00,
+0x21,0x80,0x93,0x00,0x00,0x00,0x05,0x8e,0x00,0x00,0x00,0x00,0x07,0x00,0xa0,0x10,
+0x01,0x00,0x22,0x26,0x04,0x00,0x02,0x8e,0x00,0xf0,0x03,0x3c,0x00,0x20,0x04,0x3c,
+0x24,0x10,0x43,0x00,0x1e,0x00,0x44,0x10,0x06,0x00,0x22,0x26,0xff,0xff,0x51,0x30,
+0x82,0x16,0x05,0x00,0x01,0x00,0x42,0x30,0x34,0x00,0x54,0x10,0x00,0x00,0x00,0x00,
+0x80,0x20,0x11,0x00,0x2a,0x10,0x92,0x00,0xed,0xff,0x40,0x14,0x00,0x00,0x00,0x00,
+0xbd,0x4e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x02,0x80,0x02,0x3c,0x08,0x04,0x44,0x24,
+0x21,0x28,0x00,0x00,0x21,0x30,0x00,0x00,0x31,0x1c,0x00,0x0c,0x21,0x38,0x00,0x00,
+0x25,0xb0,0x03,0x3c,0x04,0x01,0x62,0x34,0x00,0x00,0x43,0x8c,0x44,0x65,0xa7,0x8e,
+0x00,0x00,0x00,0x00,0xcf,0xff,0xe3,0x14,0x48,0x65,0xa3,0xae,0x25,0xb0,0x03,0x3c,
+0x00,0x01,0x62,0x34,0x00,0x00,0x47,0xac,0x66,0x09,0x00,0x08,0x44,0x65,0xa7,0xae,
+0xb0,0x4c,0xe2,0x8e,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0xb0,0x4c,0xe2,0xae,
+0x0c,0x00,0x04,0x8e,0x0c,0x00,0x02,0x24,0x3f,0x00,0x83,0x30,0x64,0x00,0x62,0x10,
+0x21,0x28,0xe0,0x02,0x3f,0x00,0x83,0x30,0x0d,0x00,0x02,0x24,0x59,0x00,0x62,0x10,
+0x00,0x00,0x00,0x00,0x3f,0x00,0x83,0x30,0x0e,0x00,0x02,0x24,0x04,0x00,0x62,0x10,
+0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x8e,0x5b,0x09,0x00,0x08,0x06,0x00,0x22,0x26,
+0xbc,0x4c,0xe2,0x8e,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0xbc,0x4c,0xe2,0xae,
+0x00,0x00,0x05,0x8e,0x5b,0x09,0x00,0x08,0x06,0x00,0x22,0x26,0x00,0x40,0xc2,0x8e,
+0x00,0x00,0x00,0x00,0x02,0x12,0x02,0x00,0x0f,0x00,0x42,0x30,0x05,0x00,0x54,0x10,
+0xc2,0x13,0x05,0x00,0x1e,0x00,0x42,0x30,0x21,0x10,0x51,0x00,0x60,0x09,0x00,0x08,
+0xff,0xff,0x51,0x30,0x02,0x40,0xc2,0x92,0x00,0x00,0x00,0x00,0x1e,0x00,0x40,0x14,
+0x02,0x80,0x03,0x3c,0x04,0x00,0x03,0x8e,0x00,0x00,0x00,0x00,0x02,0x14,0x03,0x00,
+0x0f,0x00,0x42,0x30,0x17,0x00,0x40,0x14,0x02,0x17,0x03,0x00,0x03,0x00,0x44,0x30,
+0x08,0x00,0x80,0x10,0x00,0xc0,0x02,0x3c,0x24,0x10,0x62,0x00,0x11,0x00,0x40,0x14,
+0x03,0x00,0x02,0x24,0x10,0x00,0x82,0x10,0x02,0x80,0x03,0x3c,0x0f,0x00,0x80,0x10,
+0x68,0x15,0x63,0x24,0x80,0x10,0x11,0x00,0x21,0x28,0x53,0x00,0xec,0xff,0xa3,0x8c,
+0x25,0xb0,0x02,0x3c,0xd4,0x02,0x42,0x34,0x21,0x20,0x00,0x02,0x00,0x00,0x43,0xac,
+0xdc,0x08,0x00,0x0c,0x00,0x00,0x00,0x00,0x21,0x20,0x40,0x00,0x8b,0x08,0x00,0x0c,
+0x21,0x28,0x00,0x00,0x02,0x80,0x03,0x3c,0x68,0x15,0x63,0x24,0x02,0x40,0x62,0x90,
+0x00,0x00,0x00,0x00,0x85,0x00,0x54,0x10,0x00,0x00,0x00,0x00,0x02,0x80,0x04,0x3c,
+0x68,0x15,0x84,0x24,0x02,0x40,0x83,0x90,0x02,0x00,0x02,0x24,0x68,0x00,0x62,0x10,
+0x00,0x00,0x00,0x00,0x25,0xb0,0x03,0x3c,0x4c,0x00,0x63,0x34,0x00,0x00,0x62,0x90,
+0x00,0x00,0x00,0x00,0x03,0x00,0x42,0x30,0x08,0x00,0x54,0x10,0x02,0x80,0x04,0x3c,
+0x00,0x00,0x05,0x8e,0x00,0x00,0x00,0x00,0xc2,0x13,0x05,0x00,0x1e,0x00,0x42,0x30,
+0x21,0x10,0x51,0x00,0x60,0x09,0x00,0x08,0xff,0xff,0x51,0x30,0xd0,0x02,0x02,0x24,
+0x68,0x15,0x84,0x24,0xdc,0x63,0x82,0xac,0x00,0x00,0x05,0x8e,0xd3,0x09,0x00,0x08,
+0xc2,0x13,0x05,0x00,0xb8,0x4c,0xa2,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,
+0xb8,0x4c,0xa2,0xac,0x0c,0x00,0x04,0x8e,0x86,0x09,0x00,0x08,0x3f,0x00,0x83,0x30,
+0xb4,0x4c,0xe2,0x8e,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0xb4,0x4c,0xe2,0xae,
+0x0c,0x00,0x04,0x8e,0x82,0x09,0x00,0x08,0x3f,0x00,0x83,0x30,0x4c,0x65,0xa2,0x8e,
+0xff,0xff,0x71,0x30,0x23,0x10,0x47,0x00,0xff,0xff,0x50,0x30,0x21,0x18,0x11,0x02,
+0xff,0xff,0x72,0x30,0xa1,0x4e,0x00,0x0c,0x21,0x20,0x40,0x02,0x76,0x00,0x40,0x10,
+0x21,0xf0,0x40,0x00,0x08,0x00,0x42,0x8c,0x44,0x65,0xa6,0x8e,0x21,0x38,0x00,0x02,
+0x21,0x18,0x52,0x00,0x21,0x28,0x40,0x00,0x08,0x00,0x04,0x24,0x14,0x65,0xa3,0xae,
+0x18,0x65,0xa2,0xae,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x4d,0x01,0x00,0x0c,
+0x08,0x00,0x04,0x24,0x18,0x65,0xa5,0x8e,0x25,0xb0,0x03,0x3c,0x24,0x10,0x02,0x3c,
+0x21,0x28,0xb0,0x00,0x00,0x01,0x70,0x34,0x00,0x00,0x02,0xae,0x21,0x38,0x20,0x02,
+0x08,0x00,0x04,0x24,0x24,0x10,0x06,0x3c,0x44,0x65,0xa2,0xae,0x10,0x01,0x00,0x0c,
+0x10,0x00,0xa0,0xaf,0x48,0x65,0xa3,0x8e,0x08,0x00,0x04,0x24,0x4d,0x01,0x00,0x0c,
+0x44,0x65,0xa3,0xae,0x44,0x65,0xa2,0x8e,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xae,
+0x46,0x09,0x00,0x08,0x02,0x80,0x02,0x3c,0x23,0x10,0x67,0x00,0xff,0xff,0x52,0x30,
+0xa1,0x4e,0x00,0x0c,0x21,0x20,0x40,0x02,0x56,0x00,0x40,0x10,0x21,0xf0,0x40,0x00,
+0x08,0x00,0x42,0x8c,0x44,0x65,0xa6,0x8e,0x08,0x00,0x04,0x24,0x21,0x18,0x52,0x00,
+0x21,0x28,0x40,0x00,0x21,0x38,0x40,0x02,0x14,0x65,0xa3,0xae,0x18,0x65,0xa2,0xae,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x48,0x65,0xa3,0x8e,0x08,0x00,0x04,0x24,
+0x4d,0x01,0x00,0x0c,0x44,0x65,0xa3,0xae,0x44,0x65,0xa3,0x8e,0x25,0xb0,0x04,0x3c,
+0x00,0x01,0x82,0x34,0x00,0x00,0x43,0xac,0x46,0x09,0x00,0x08,0x02,0x80,0x02,0x3c,
+0x04,0x00,0x03,0x8e,0x00,0x00,0x00,0x00,0x02,0x14,0x03,0x00,0x0f,0x00,0x42,0x30,
+0x08,0x00,0x42,0x28,0x93,0xff,0x40,0x10,0x02,0x17,0x03,0x00,0x03,0x00,0x42,0x30,
+0x90,0xff,0x40,0x14,0x80,0x10,0x11,0x00,0x21,0x28,0x53,0x00,0xec,0xff,0xa3,0x8c,
+0x25,0xb0,0x02,0x3c,0xd4,0x02,0x42,0x34,0x21,0x20,0x00,0x02,0x00,0x00,0x43,0xac,
+0xdc,0x08,0x00,0x0c,0x00,0x00,0x00,0x00,0x21,0x20,0x40,0x00,0x8b,0x08,0x00,0x0c,
+0x21,0x28,0x00,0x00,0xca,0x09,0x00,0x08,0x25,0xb0,0x03,0x3c,0x04,0x00,0x03,0x8e,
+0x00,0x00,0x00,0x00,0x02,0x14,0x03,0x00,0x0f,0x00,0x42,0x30,0x08,0x00,0x42,0x28,
+0x06,0x00,0x40,0x10,0x00,0xc0,0x02,0x3c,0x02,0x17,0x03,0x00,0x03,0x00,0x42,0x30,
+0x0c,0x00,0x40,0x10,0x80,0x10,0x11,0x00,0x00,0xc0,0x02,0x3c,0x24,0x10,0x62,0x00,
+0x6f,0xff,0x40,0x14,0x02,0x80,0x04,0x3c,0x02,0x17,0x03,0x00,0x03,0x00,0x42,0x30,
+0x03,0x00,0x03,0x24,0x6b,0xff,0x43,0x10,0x68,0x15,0x84,0x24,0x67,0xff,0x40,0x10,
+0x80,0x10,0x11,0x00,0x21,0x28,0x53,0x00,0xec,0xff,0xa3,0x8c,0x25,0xb0,0x02,0x3c,
+0xd4,0x02,0x42,0x34,0x21,0x20,0x00,0x02,0x00,0x00,0x43,0xac,0xdc,0x08,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x21,0x20,0x40,0x00,0x8b,0x08,0x00,0x0c,0x21,0x28,0x00,0x00,
+0xc4,0x09,0x00,0x08,0x02,0x80,0x04,0x3c,0x25,0xb0,0x04,0x3c,0x44,0x44,0x02,0x3c,
+0xbc,0x02,0x83,0x34,0x44,0x44,0x42,0x34,0x00,0x00,0x62,0xac,0x67,0x09,0x00,0x08,
+0x02,0x80,0x02,0x3c,0x48,0x65,0xa5,0x8e,0x25,0xb0,0x04,0x3c,0x66,0x66,0x02,0x3c,
+0x00,0x01,0x83,0x34,0x66,0x66,0x42,0x34,0xbc,0x02,0x84,0x34,0x00,0x00,0x65,0xac,
+0x00,0x00,0x82,0xac,0x66,0x09,0x00,0x08,0x44,0x65,0xa5,0xae,0x00,0x60,0x02,0x40,
+0x01,0x00,0x41,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x02,0x80,0x03,0x3c,
+0xd8,0x8c,0x64,0xac,0x00,0x60,0x82,0x40,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x02,0x80,0x02,0x3c,0xd8,0x8c,0x45,0x8c,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x18,0x03,0x42,0x34,0x10,0x2a,0x63,0x24,0x00,0x00,0x43,0xac,0x04,0x00,0x02,0x24,
+0x1e,0x00,0xa2,0x10,0x05,0x00,0xa2,0x2c,0x10,0x00,0x40,0x10,0x05,0x00,0x02,0x24,
+0x03,0x00,0x02,0x24,0x08,0x00,0xa2,0x10,0x00,0x19,0x04,0x00,0x80,0x10,0x04,0x00,
+0x21,0x10,0x44,0x00,0xc0,0x10,0x02,0x00,0x23,0x10,0x44,0x00,0x00,0x11,0x02,0x00,
+0x21,0x10,0x44,0x00,0x40,0x19,0x02,0x00,0xff,0xff,0x63,0x24,0xfe,0xff,0x60,0x14,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xf3,0xff,0xa2,0x10,
+0x06,0x00,0x02,0x24,0xf2,0xff,0xa2,0x14,0x80,0x10,0x04,0x00,0x40,0x11,0x04,0x00,
+0x23,0x10,0x44,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x44,0x00,0x00,0x19,0x02,0x00,
+0x23,0x18,0x62,0x00,0x9a,0x0a,0x00,0x08,0x00,0x19,0x03,0x00,0x80,0x10,0x04,0x00,
+0x21,0x10,0x44,0x00,0xc0,0x10,0x02,0x00,0x23,0x10,0x44,0x00,0x00,0x11,0x02,0x00,
+0x21,0x10,0x44,0x00,0x9a,0x0a,0x00,0x08,0x00,0x19,0x02,0x00,0x02,0x80,0x02,0x3c,
+0xd8,0x8c,0x45,0x8c,0x00,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,0x18,0x03,0x42,0x34,
+0xcc,0x2a,0x63,0x24,0x00,0x00,0x43,0xac,0x05,0x00,0x02,0x24,0x10,0x00,0xa2,0x10,
+0x06,0x00,0xa2,0x2c,0x09,0x00,0x40,0x14,0x04,0x00,0x02,0x24,0x06,0x00,0x02,0x24,
+0x0f,0x00,0xa2,0x10,0x00,0x11,0x04,0x00,0xff,0xff,0x84,0x24,0xfe,0xff,0x80,0x14,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xfa,0xff,0xa2,0x14,
+0x80,0x10,0x04,0x00,0x21,0x10,0x44,0x00,0xc2,0x0a,0x00,0x08,0x40,0x20,0x02,0x00,
+0x80,0x10,0x04,0x00,0x21,0x10,0x44,0x00,0xc2,0x0a,0x00,0x08,0x80,0x20,0x02,0x00,
+0x23,0x10,0x44,0x00,0xc2,0x0a,0x00,0x08,0x40,0x20,0x02,0x00,0xff,0xff,0x85,0x30,
+0x21,0x30,0x00,0x00,0x25,0xb0,0x03,0x3c,0x2a,0xb0,0x04,0x3c,0xb4,0x00,0x63,0x34,
+0x01,0x00,0xa2,0x24,0x31,0x00,0x84,0x34,0x00,0x00,0x65,0xa0,0x00,0x00,0x85,0xa0,
+0xff,0xff,0x45,0x30,0x12,0x00,0xa0,0x10,0x01,0x00,0x03,0x24,0x28,0xb0,0x07,0x3c,
+0xe8,0x0a,0x00,0x08,0xff,0xff,0x08,0x24,0x00,0x00,0x83,0xa0,0x01,0x00,0x63,0x24,
+0xff,0xff,0x63,0x30,0x2b,0x10,0xa3,0x00,0x09,0x00,0x40,0x14,0x08,0x00,0xc6,0x24,
+0xf9,0xff,0x65,0x14,0x21,0x20,0xc7,0x00,0x01,0x00,0x63,0x24,0xff,0xff,0x63,0x30,
+0x2b,0x10,0xa3,0x00,0x00,0x00,0x88,0xa0,0xf9,0xff,0x40,0x10,0x08,0x00,0xc6,0x24,
+0x00,0x01,0xa2,0x2c,0x13,0x00,0x40,0x10,0x21,0x18,0xa0,0x00,0xff,0x00,0x08,0x24,
+0x28,0xb0,0x07,0x3c,0xfc,0x0a,0x00,0x08,0xff,0xff,0x09,0x24,0xff,0xff,0x43,0x30,
+0x00,0x00,0xa2,0xa0,0x00,0x01,0x62,0x2c,0x0a,0x00,0x40,0x10,0x08,0x00,0xc6,0x24,
+0x01,0x00,0x62,0x24,0xf9,0xff,0x68,0x14,0x21,0x28,0xc7,0x00,0x00,0x01,0x02,0x24,
+0xff,0xff,0x43,0x30,0x00,0x01,0x62,0x2c,0x00,0x00,0xa9,0xa0,0xf8,0xff,0x40,0x14,
+0x08,0x00,0xc6,0x24,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xd8,0xff,0xbd,0x27,
+0x24,0x00,0xbf,0xaf,0x20,0x00,0xb4,0xaf,0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,
+0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x25,0xb0,0x10,0x3c,0x42,0x00,0x14,0x36,
+0xff,0xff,0x02,0x24,0x00,0x00,0x82,0xa2,0xd8,0x00,0x05,0x36,0x40,0x00,0x11,0x36,
+0xa8,0x00,0x13,0x36,0xa0,0x00,0x12,0x36,0x00,0x10,0x03,0x24,0xa4,0x00,0x10,0x36,
+0x00,0x80,0x02,0x3c,0x00,0x00,0x23,0xa6,0x00,0x00,0xa0,0xa0,0x00,0x00,0x40,0xae,
+0x00,0x00,0x00,0xae,0x00,0x00,0x62,0xae,0x00,0x00,0xa3,0x90,0x80,0xff,0x02,0x24,
+0xfd,0x00,0x04,0x24,0x25,0x18,0x62,0x00,0xfc,0x17,0x02,0x24,0x00,0x00,0xa3,0xa0,
+0x00,0x00,0x22,0xa6,0xd3,0x0a,0x00,0x0c,0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x42,0x24,0x68,0x4b,0x45,0x8c,0x60,0x4b,0x43,0x8c,0x64,0x4b,0x44,0x8c,
+0xfc,0x37,0x02,0x24,0x00,0x00,0x43,0xae,0x00,0x00,0x04,0xae,0x00,0x00,0x65,0xae,
+0x00,0x00,0x22,0xa6,0x00,0x00,0x80,0xa2,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0x24,0x00,0xbf,0x8f,0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,
+0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
+0x28,0x00,0xbd,0x27,0xd0,0xff,0xbd,0x27,0x2c,0x00,0xbf,0xaf,0x28,0x00,0xb6,0xaf,
+0x24,0x00,0xb5,0xaf,0x20,0x00,0xb4,0xaf,0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,
+0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x25,0xb0,0x10,0x3c,0x40,0x00,0x05,0x36,
+0x00,0x00,0xa2,0x94,0x24,0xfa,0x03,0x24,0xa8,0x00,0x13,0x36,0x24,0x10,0x43,0x00,
+0x00,0x00,0xa2,0xa4,0xa0,0x00,0x12,0x36,0xa4,0x00,0x10,0x36,0x00,0x00,0x55,0x8e,
+0x00,0x00,0x16,0x8e,0x00,0x00,0x71,0x8e,0x00,0x80,0x14,0x3c,0xfc,0x37,0x02,0x24,
+0x00,0x00,0x40,0xae,0xfd,0x00,0x04,0x24,0x00,0x00,0x00,0xae,0x21,0x88,0x34,0x02,
+0x00,0x00,0x74,0xae,0x00,0x00,0xa2,0xa4,0xd3,0x0a,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x00,0x00,0x55,0xae,0x00,0x00,0x16,0xae,0x00,0x00,0x71,0xae,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x2c,0x00,0xbf,0x8f,0x28,0x00,0xb6,0x8f,
+0x24,0x00,0xb5,0x8f,0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,
+0xd0,0xff,0xbd,0x27,0x2c,0x00,0xbf,0xaf,0x28,0x00,0xb6,0xaf,0x24,0x00,0xb5,0xaf,
+0x20,0x00,0xb4,0xaf,0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,0x14,0x00,0xb1,0xaf,
+0x10,0x00,0xb0,0xaf,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x25,0xb0,0x10,0x3c,0x40,0x00,0x05,0x36,0x00,0x00,0xa2,0x94,
+0xaf,0xff,0x03,0x24,0xa8,0x00,0x13,0x36,0x24,0x10,0x43,0x00,0x00,0x00,0xa2,0xa4,
+0xa0,0x00,0x12,0x36,0xa4,0x00,0x10,0x36,0x00,0x00,0x55,0x8e,0x00,0x00,0x16,0x8e,
+0x00,0x00,0x71,0x8e,0x00,0x80,0x14,0x3c,0xfc,0x37,0x02,0x24,0x00,0x00,0x40,0xae,
+0xfd,0x00,0x04,0x24,0x00,0x00,0x00,0xae,0x21,0x88,0x34,0x02,0x00,0x00,0x74,0xae,
+0x00,0x00,0xa2,0xa4,0xd3,0x0a,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xae,
+0x00,0x00,0x16,0xae,0x00,0x00,0x71,0xae,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0x2c,0x00,0xbf,0x8f,0x28,0x00,0xb6,0x8f,0x24,0x00,0xb5,0x8f,
+0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x25,0xb0,0x04,0x3c,
+0x40,0x00,0x84,0x34,0x00,0x00,0x82,0x94,0xd8,0xfd,0x03,0x24,0x24,0x10,0x43,0x00,
+0xfc,0x37,0x03,0x24,0x00,0x00,0x82,0xa4,0x00,0x00,0x83,0xa4,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x00,0x00,0x82,0x8c,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xff,0xff,0xc6,0x30,
+0x10,0x00,0x02,0x24,0x0c,0x00,0xc2,0x10,0x11,0x00,0xc3,0x28,0x06,0x00,0x60,0x10,
+0x20,0x00,0x02,0x24,0x08,0x00,0x02,0x24,0x0d,0x00,0xc2,0x10,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x06,0x00,0xc2,0x10,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x85,0xa4,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x00,0x00,0x85,0xac,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x00,0x00,0x85,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x25,0xb0,0x02,0x3c,
+0x0a,0x00,0x42,0x34,0x00,0x00,0x43,0x90,0xff,0xff,0xa5,0x24,0x00,0x2c,0x05,0x00,
+0xfd,0x00,0x63,0x30,0x03,0x2c,0x05,0x00,0xff,0xff,0x87,0x30,0x00,0x00,0x43,0xa0,
+0x1a,0x00,0xa0,0x04,0x00,0x00,0x00,0x00,0x21,0x30,0x40,0x00,0x07,0x10,0xa7,0x00,
+0x01,0x00,0x42,0x30,0xfd,0x00,0x64,0x30,0x00,0x00,0x42,0x38,0x02,0x00,0x63,0x34,
+0x0a,0x18,0x82,0x00,0x00,0x00,0xc3,0xa0,0x04,0x00,0x63,0x34,0x00,0x00,0xc3,0xa0,
+0x09,0x00,0x02,0x24,0xff,0xff,0x42,0x24,0xff,0xff,0x41,0x04,0xff,0xff,0x42,0x24,
+0xfb,0x00,0x63,0x30,0x00,0x00,0xc3,0xa0,0x04,0x00,0x02,0x24,0xff,0xff,0x42,0x24,
+0xff,0xff,0x41,0x04,0xff,0xff,0x42,0x24,0xff,0xff,0xa2,0x24,0x00,0x2c,0x02,0x00,
+0x03,0x2c,0x05,0x00,0xea,0xff,0xa1,0x04,0x07,0x10,0xa7,0x00,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x25,0xb0,0x02,0x3c,0x0a,0x00,0x42,0x34,0x00,0x00,0x43,0x90,
+0xff,0xff,0x84,0x24,0x00,0x24,0x04,0x00,0x03,0x24,0x04,0x00,0xff,0x00,0x65,0x30,
+0x1d,0x00,0x80,0x04,0x21,0x38,0x00,0x00,0x21,0x30,0x40,0x00,0x01,0x00,0x08,0x24,
+0x04,0x00,0xa5,0x34,0x00,0x00,0xc5,0xa0,0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
+0xff,0x00,0x45,0x30,0x01,0x00,0xa3,0x30,0x05,0x00,0x60,0x10,0x04,0x00,0x02,0x24,
+0x04,0x10,0x88,0x00,0x25,0x10,0x47,0x00,0xff,0xff,0x47,0x30,0x04,0x00,0x02,0x24,
+0xff,0xff,0x42,0x24,0xff,0xff,0x41,0x04,0xff,0xff,0x42,0x24,0xfb,0x00,0xa5,0x30,
+0x00,0x00,0xc5,0xa0,0x09,0x00,0x02,0x24,0xff,0xff,0x42,0x24,0xff,0xff,0x41,0x04,
+0xff,0xff,0x42,0x24,0xff,0xff,0x82,0x24,0x00,0x24,0x02,0x00,0x03,0x24,0x04,0x00,
+0xe7,0xff,0x81,0x04,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0xe0,0x00,
+0xe0,0xff,0xbd,0x27,0x10,0x00,0xb0,0xaf,0x25,0xb0,0x10,0x3c,0x0a,0x00,0x10,0x36,
+0x18,0x00,0xbf,0xaf,0x14,0x00,0xb1,0xaf,0x00,0x00,0x02,0x92,0xff,0xff,0x91,0x30,
+0x03,0x00,0x05,0x24,0xc0,0x00,0x42,0x30,0x80,0x00,0x43,0x34,0x00,0x00,0x03,0xa2,
+0x04,0x00,0x63,0x34,0x00,0x00,0x03,0xa2,0xfb,0x00,0x63,0x30,0x00,0x00,0x03,0xa2,
+0x08,0x00,0x63,0x34,0x00,0x00,0x03,0xa2,0x04,0x00,0x63,0x34,0x00,0x00,0x03,0xa2,
+0xfb,0x00,0x63,0x30,0x00,0x00,0x03,0xa2,0xd7,0x0b,0x00,0x0c,0x06,0x00,0x04,0x24,
+0x42,0x20,0x11,0x00,0xd7,0x0b,0x00,0x0c,0x06,0x00,0x05,0x24,0xfd,0x0b,0x00,0x0c,
+0x10,0x00,0x04,0x24,0x00,0x00,0x03,0x92,0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,
+0xc0,0x00,0x63,0x30,0x00,0x00,0x03,0xa2,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,0xff,0xff,0xb1,0x30,
+0x18,0x00,0xb2,0xaf,0x10,0x00,0xb0,0xaf,0x1c,0x00,0xbf,0xaf,0x21,0x90,0xc0,0x00,
+0x0a,0x00,0x20,0x12,0xff,0xff,0x90,0x30,0x24,0x0c,0x00,0x0c,0x21,0x20,0x00,0x02,
+0xfe,0xff,0x23,0x26,0x02,0x00,0x04,0x26,0x00,0x00,0x42,0xa6,0xff,0xff,0x71,0x30,
+0xff,0xff,0x90,0x30,0xf8,0xff,0x20,0x16,0x02,0x00,0x52,0x26,0x1c,0x00,0xbf,0x8f,
+0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0x25,0xb0,0x03,0x3c,0x0a,0x00,0x68,0x34,0x00,0x00,0x02,0x91,
+0xff,0xff,0xa5,0x30,0xff,0x00,0x84,0x30,0x1f,0x00,0xa0,0x10,0xff,0x00,0x47,0x30,
+0x21,0x48,0x00,0x01,0x0c,0x00,0x6c,0x34,0x0b,0x00,0x6b,0x34,0xc0,0xff,0x0a,0x24,
+0x21,0x68,0x00,0x01,0x25,0x10,0xea,0x00,0xff,0x00,0x47,0x30,0x00,0x00,0x64,0xa1,
+0x00,0x00,0x27,0xa1,0x00,0x00,0x22,0x91,0x00,0x00,0x00,0x00,0xff,0x00,0x47,0x30,
+0xc0,0x00,0xe3,0x30,0x08,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x21,0x40,0xa0,0x01,
+0x00,0x00,0x02,0x91,0x00,0x00,0x00,0x00,0xff,0x00,0x47,0x30,0xc0,0x00,0xe3,0x30,
+0xfb,0xff,0x60,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x8d,0xfc,0xff,0xa3,0x24,
+0x04,0x00,0x84,0x24,0xff,0xff,0x65,0x30,0x00,0x00,0xc2,0xac,0xff,0x00,0x84,0x30,
+0xe8,0xff,0xa0,0x14,0x04,0x00,0xc6,0x24,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0xff,0x00,0x84,0x30,0x21,0x68,0xe0,0x00,0xff,0xff,0xa5,0x30,0xc0,0x50,0x04,0x00,
+0x00,0x60,0x0c,0x40,0x01,0x00,0x81,0x35,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x00,0x00,0xc2,0x90,0x01,0x00,0xc3,0x90,0x25,0xb0,0x07,0x3c,0x00,0x14,0x02,0x00,
+0x25,0x28,0xa2,0x00,0x00,0x1e,0x03,0x00,0x01,0x80,0x08,0x3c,0x25,0x20,0xa3,0x00,
+0x40,0x02,0xe9,0x34,0x25,0x18,0x48,0x01,0x44,0x02,0xe7,0x34,0x00,0x00,0xe4,0xac,
+0x00,0x00,0x23,0xad,0x03,0x00,0xc2,0x90,0x02,0x00,0xc4,0x90,0x04,0x00,0xc3,0x90,
+0x05,0x00,0xc5,0x90,0x00,0x12,0x02,0x00,0x25,0x20,0x82,0x00,0x00,0x1c,0x03,0x00,
+0x01,0x00,0x4a,0x25,0x25,0x20,0x83,0x00,0x00,0x2e,0x05,0x00,0x25,0x40,0x48,0x01,
+0x25,0x20,0x85,0x00,0x00,0x00,0xe4,0xac,0x01,0x00,0x4a,0x25,0x00,0x00,0x28,0xad,
+0x01,0x80,0x0b,0x3c,0x21,0x40,0x00,0x00,0x21,0x10,0xa8,0x01,0x01,0x00,0x43,0x90,
+0x00,0x00,0x45,0x90,0x02,0x00,0x44,0x90,0x03,0x00,0x46,0x90,0x00,0x1a,0x03,0x00,
+0x25,0x28,0xa3,0x00,0x00,0x24,0x04,0x00,0x25,0x28,0xa4,0x00,0x00,0x36,0x06,0x00,
+0x04,0x00,0x08,0x25,0x25,0x10,0x4b,0x01,0x25,0x20,0xa6,0x00,0x10,0x00,0x03,0x2d,
+0x00,0x00,0xe4,0xac,0x01,0x00,0x4a,0x25,0x00,0x00,0x22,0xad,0xee,0xff,0x60,0x14,
+0x00,0x00,0x00,0x00,0x00,0x60,0x8c,0x40,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0xff,0xff,0x84,0x30,0x42,0xb0,0x08,0x3c,0x80,0x10,0x04,0x00,0x21,0x10,0x48,0x00,
+0x04,0x00,0x46,0xac,0x00,0x00,0x07,0x91,0x40,0x18,0x04,0x00,0x03,0x00,0x06,0x24,
+0xff,0x00,0xe7,0x30,0x04,0x30,0x66,0x00,0x01,0x00,0x02,0x24,0x04,0x10,0x62,0x00,
+0x25,0x30,0xc7,0x00,0xff,0xff,0xa5,0x30,0x25,0x10,0x47,0x00,0x02,0x00,0xa0,0x14,
+0xff,0x00,0xc7,0x30,0xff,0x00,0x47,0x30,0x42,0xb0,0x02,0x3c,0x00,0x00,0x47,0xa0,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x42,0xb0,0x02,0x3c,0x03,0x00,0x47,0x34,
+0x00,0x00,0xe3,0x90,0xff,0x00,0x84,0x30,0x04,0x00,0x84,0x24,0xff,0x00,0x65,0x30,
+0x01,0x00,0x02,0x24,0x04,0x30,0x82,0x00,0x07,0x18,0x85,0x00,0x25,0xb0,0x02,0x3c,
+0xe8,0x03,0x42,0x34,0x01,0x00,0x63,0x30,0x21,0x20,0xc0,0x00,0x00,0x00,0x45,0xa0,
+0x02,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0xa0,0x08,0x00,0xe0,0x03,
+0x24,0x10,0x85,0x00,0x00,0x60,0x03,0x40,0x01,0x00,0x61,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x02,0x80,0x02,0x3c,0xdc,0x8c,0x42,0x24,0x04,0x00,0x45,0x8c,
+0x00,0x00,0x82,0xac,0x04,0x00,0x44,0xac,0x00,0x00,0xa4,0xac,0x04,0x00,0x85,0xac,
+0x00,0x60,0x83,0x40,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x14,0x00,0x83,0x90,
+0x01,0x00,0x02,0x24,0x08,0x00,0x86,0xac,0x18,0x00,0x85,0xac,0x00,0x00,0x84,0xac,
+0x03,0x00,0x62,0x10,0x04,0x00,0x84,0xac,0xed,0x0c,0x00,0x08,0x0c,0x00,0x80,0xac,
+0x0c,0x00,0x82,0x8c,0xed,0x0c,0x00,0x08,0x10,0x00,0x82,0xac,0x00,0x60,0x03,0x40,
+0x01,0x00,0x61,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x04,0x00,0x85,0x8c,
+0x00,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0xac,0x04,0x00,0x45,0xac,
+0x00,0x00,0x84,0xac,0x04,0x00,0x84,0xac,0x00,0x60,0x83,0x40,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0xd0,0xff,0xbd,0x27,0x28,0x00,0xb6,0xaf,0x24,0x00,0xb5,0xaf,
+0x20,0x00,0xb4,0xaf,0x14,0x00,0xb1,0xaf,0x2c,0x00,0xbf,0xaf,0x1c,0x00,0xb3,0xaf,
+0x18,0x00,0xb2,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x80,0x16,0x3c,0x02,0x80,0x14,0x3c,
+0x02,0x80,0x11,0x3c,0x02,0x80,0x15,0x3c,0xc4,0x7d,0x24,0x8e,0x25,0xb0,0x02,0x3c,
+0x54,0x34,0xc3,0x26,0x18,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0xdc,0x8c,0x90,0x8e,
+0x18,0x00,0x80,0x10,0xdc,0x8c,0x82,0x26,0x15,0x00,0x02,0x12,0x00,0x00,0x00,0x00,
+0x21,0x98,0x40,0x00,0x01,0x00,0x12,0x24,0x14,0x00,0x02,0x92,0x00,0x00,0x00,0x00,
+0x1d,0x00,0x52,0x10,0x00,0x00,0x00,0x00,0x09,0x00,0x40,0x14,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x03,0x8e,0xc4,0x7d,0x22,0x8e,0x00,0x00,0x00,0x00,0x23,0x20,0x62,0x00,
+0x2b,0x10,0x43,0x00,0x0e,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0xae,
+0x00,0x00,0x10,0x8e,0x00,0x00,0x00,0x00,0xef,0xff,0x13,0x16,0x00,0x00,0x00,0x00,
+0xc4,0x7d,0x20,0xae,0x08,0x0c,0xa4,0x26,0x21,0x28,0x00,0x00,0x21,0x30,0x00,0x00,
+0x31,0x1c,0x00,0x0c,0x21,0x38,0x00,0x00,0x22,0x0d,0x00,0x08,0x00,0x00,0x00,0x00,
+0x08,0x00,0x02,0x8e,0x18,0x00,0x04,0x8e,0x09,0xf8,0x40,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x0d,0x00,0x08,0x0c,0x00,0x02,0xae,0x0c,0x00,0x03,0x8e,0xc4,0x7d,0x22,0x8e,
+0x00,0x00,0x00,0x00,0x23,0x20,0x62,0x00,0x2b,0x10,0x43,0x00,0xe7,0xff,0x40,0x14,
+0x00,0x00,0x00,0x00,0x08,0x00,0x02,0x8e,0x18,0x00,0x04,0x8e,0x09,0xf8,0x40,0x00,
+0x00,0x00,0x00,0x00,0x10,0x00,0x03,0x8e,0x3c,0x0d,0x00,0x08,0x0c,0x00,0x03,0xae,
+0xff,0x00,0xa5,0x30,0x25,0xb0,0x02,0x3c,0x21,0x28,0xa2,0x00,0xff,0x00,0x84,0x30,
+0x60,0x01,0xa4,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xff,0x00,0x84,0x30,
+0x01,0x00,0x03,0x24,0x10,0x00,0x02,0x3c,0x04,0x18,0x83,0x00,0xf0,0x70,0x42,0x34,
+0x15,0x00,0x84,0x2c,0x06,0x00,0x80,0x10,0x24,0x28,0x62,0x00,0x0f,0x00,0x63,0x30,
+0x04,0x00,0xa0,0x14,0x01,0x00,0x02,0x24,0x02,0x00,0x60,0x14,0x02,0x00,0x02,0x24,
+0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xff,0x00,0xa5,0x30,
+0x04,0x00,0xa2,0x2c,0x14,0x00,0x40,0x10,0xff,0x00,0x84,0x30,0x02,0x80,0x03,0x3c,
+0x8e,0x7d,0x62,0x90,0x00,0x00,0x00,0x00,0xef,0xff,0x42,0x24,0xff,0x00,0x42,0x30,
+0x02,0x00,0x42,0x2c,0x0e,0x00,0x40,0x10,0x02,0x00,0x03,0x24,0x24,0x00,0x83,0x10,
+0x0f,0x10,0x02,0x3c,0x03,0x00,0x82,0x28,0x14,0x00,0x40,0x10,0x03,0x00,0x02,0x24,
+0x01,0x00,0x02,0x24,0x2f,0x00,0x82,0x10,0x00,0x00,0x00,0x00,0xff,0x1f,0x02,0x3c,
+0x08,0x00,0xe0,0x03,0xff,0xff,0x42,0x34,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x35,0x00,0x83,0x10,0x0f,0x1f,0x02,0x3c,0x03,0x00,0x82,0x28,0x16,0x00,0x40,0x10,
+0x03,0x00,0x02,0x24,0x01,0x00,0x02,0x24,0xf4,0xff,0x82,0x14,0x00,0x00,0x00,0x00,
+0x0f,0x1f,0x02,0x3c,0x08,0x00,0xe0,0x03,0x00,0x80,0x42,0x34,0xf0,0xff,0x82,0x14,
+0xff,0x1f,0x02,0x3c,0x01,0x00,0x02,0x24,0x29,0x00,0xa2,0x10,0x0f,0x10,0x02,0x3c,
+0x02,0x00,0xa2,0x28,0x1f,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0x28,0x00,0xa3,0x10,
+0x00,0x00,0x00,0x00,0xe5,0xff,0xa4,0x14,0x00,0x00,0x00,0x00,0x0f,0x10,0x02,0x3c,
+0x08,0x00,0xe0,0x03,0x00,0xf0,0x42,0x34,0xe1,0xff,0x82,0x14,0xff,0x1f,0x02,0x3c,
+0x01,0x00,0x02,0x24,0x1c,0x00,0xa2,0x10,0x0f,0x00,0x02,0x3c,0x02,0x00,0xa2,0x28,
+0x0b,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0x1c,0x00,0xa3,0x10,0x00,0x00,0x00,0x00,
+0xd6,0xff,0xa4,0x14,0x00,0x00,0x00,0x00,0x0f,0x00,0x02,0x3c,0x08,0x00,0xe0,0x03,
+0x00,0xf0,0x42,0x34,0x0f,0x10,0x02,0x3c,0x08,0x00,0xe0,0x03,0x00,0x80,0x42,0x34,
+0xce,0xff,0xa0,0x14,0x00,0x00,0x00,0x00,0x0f,0x00,0x02,0x3c,0x08,0x00,0xe0,0x03,
+0x15,0xf0,0x42,0x34,0xc9,0xff,0xa0,0x14,0x00,0x00,0x00,0x00,0x0f,0x10,0x02,0x3c,
+0x08,0x00,0xe0,0x03,0x15,0xf0,0x42,0x34,0x08,0x00,0xe0,0x03,0x00,0xf0,0x42,0x34,
+0x08,0x00,0xe0,0x03,0x10,0xf0,0x42,0x34,0x08,0x00,0xe0,0x03,0x10,0xf0,0x42,0x34,
+0x0f,0x10,0x02,0x3c,0x08,0x00,0xe0,0x03,0x05,0xf0,0x42,0x34,0x0f,0x00,0x02,0x3c,
+0x08,0x00,0xe0,0x03,0x05,0xf0,0x42,0x34,0xc0,0x40,0x04,0x00,0x21,0x18,0x04,0x01,
+0x80,0x18,0x03,0x00,0x21,0x18,0x64,0x00,0x02,0x80,0x02,0x3c,0x80,0x18,0x03,0x00,
+0x68,0x15,0x42,0x24,0x21,0x18,0x62,0x00,0x74,0x51,0x66,0x8c,0x21,0x38,0x60,0x00,
+0x7a,0x51,0x60,0xa0,0x7b,0x51,0x60,0xa0,0x1c,0x00,0x05,0x24,0xdf,0x0d,0x00,0x08,
+0x01,0x00,0x03,0x24,0x08,0x00,0xa0,0x04,0x21,0x10,0x04,0x01,0x04,0x10,0xa3,0x00,
+0x24,0x10,0xc2,0x00,0xfb,0xff,0x40,0x10,0xff,0xff,0xa5,0x24,0x01,0x00,0xa5,0x24,
+0x7a,0x51,0xe5,0xa0,0x21,0x10,0x04,0x01,0x80,0x10,0x02,0x00,0x21,0x10,0x44,0x00,
+0x02,0x80,0x03,0x3c,0x80,0x10,0x02,0x00,0x68,0x15,0x63,0x24,0x21,0x18,0x43,0x00,
+0x74,0x51,0x66,0x8c,0x21,0x28,0x00,0x00,0xf3,0x0d,0x00,0x08,0x01,0x00,0x07,0x24,
+0x1d,0x00,0xa2,0x28,0x08,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x04,0x10,0xa7,0x00,
+0x24,0x10,0xc2,0x00,0xfa,0xff,0x40,0x10,0x01,0x00,0xa5,0x24,0xff,0xff,0xa5,0x24,
+0x08,0x00,0xe0,0x03,0x7b,0x51,0x65,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0xc8,0xff,0xbd,0x27,0x28,0x00,0xb6,0xaf,0x02,0x80,0x16,0x3c,0x30,0x00,0xbe,0xaf,
+0x2c,0x00,0xb7,0xaf,0x24,0x00,0xb5,0xaf,0x20,0x00,0xb4,0xaf,0x18,0x00,0xb2,0xaf,
+0x14,0x00,0xb1,0xaf,0x01,0x00,0x15,0x24,0x21,0x88,0x00,0x00,0x68,0x15,0xde,0x26,
+0x21,0xa0,0x00,0x00,0x21,0x90,0x00,0x00,0x25,0xb0,0x17,0x3c,0x34,0x00,0xbf,0xaf,
+0x1c,0x00,0xb3,0xaf,0x14,0x0e,0x00,0x08,0x10,0x00,0xb0,0xaf,0x01,0x00,0x31,0x26,
+0x20,0x00,0x22,0x2e,0x94,0x00,0x52,0x26,0x2e,0x00,0x40,0x10,0x94,0x00,0x94,0x26,
+0x68,0x15,0xc2,0x26,0x21,0x30,0x42,0x02,0x78,0x51,0xc5,0x8c,0x00,0x00,0x00,0x00,
+0x02,0x13,0x05,0x00,0x01,0x00,0x42,0x30,0xf4,0xff,0x55,0x14,0x42,0x1a,0x05,0x00,
+0x68,0x51,0xc2,0x8c,0x07,0x00,0x64,0x30,0x02,0x11,0x02,0x00,0x7f,0x00,0x43,0x30,
+0x2d,0x00,0x95,0x10,0x07,0x00,0xb3,0x30,0x02,0x00,0x82,0x28,0x3a,0x00,0x40,0x14,
+0x02,0x00,0x02,0x24,0x30,0x00,0x82,0x10,0x03,0x00,0x02,0x24,0x3c,0x00,0x82,0x10,
+0x1a,0x00,0x62,0x2c,0x21,0x80,0x9e,0x02,0x78,0x51,0x02,0x8e,0x04,0x00,0x63,0x2e,
+0x42,0x12,0x02,0x00,0x0a,0x00,0x60,0x10,0x07,0x00,0x44,0x30,0x73,0x0d,0x00,0x0c,
+0x21,0x28,0x60,0x02,0x80,0x20,0x13,0x00,0x70,0x51,0x02,0xae,0x21,0x20,0x97,0x00,
+0x84,0x01,0x83,0x8c,0x00,0x00,0x00,0x00,0x24,0x18,0x62,0x00,0x74,0x51,0x03,0xae,
+0xce,0x0d,0x00,0x0c,0x21,0x20,0x20,0x02,0x21,0x10,0x37,0x02,0x01,0x00,0x31,0x26,
+0x60,0x01,0x43,0x90,0x20,0x00,0x22,0x2e,0x94,0x00,0x52,0x26,0xd4,0xff,0x40,0x14,
+0x94,0x00,0x94,0x26,0x34,0x00,0xbf,0x8f,0x30,0x00,0xbe,0x8f,0x2c,0x00,0xb7,0x8f,
+0x28,0x00,0xb6,0x8f,0x24,0x00,0xb5,0x8f,0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,
+0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,0x32,0x00,0x62,0x2c,0xda,0xff,0x40,0x10,
+0x21,0x80,0x9e,0x02,0xff,0xf1,0x03,0x24,0x24,0x10,0xa3,0x00,0x00,0x04,0x42,0x34,
+0x29,0x0e,0x00,0x08,0x78,0x51,0xc2,0xac,0x38,0x00,0x62,0x2c,0x12,0x00,0x40,0x14,
+0x14,0x00,0x62,0x2c,0xff,0xf1,0x03,0x24,0x24,0x10,0xa3,0x00,0x00,0x02,0x42,0x34,
+0x29,0x0e,0x00,0x08,0x78,0x51,0xc2,0xac,0xcb,0xff,0x80,0x14,0x21,0x80,0x9e,0x02,
+0xff,0xf1,0x03,0x24,0x24,0x10,0xa3,0x00,0x2a,0x0e,0x00,0x08,0x78,0x51,0xc2,0xac,
+0xc5,0xff,0x40,0x14,0x21,0x80,0x9e,0x02,0xff,0xf1,0x03,0x24,0x24,0x10,0xa3,0x00,
+0x54,0x0e,0x00,0x08,0x00,0x04,0x42,0x34,0xbf,0xff,0x40,0x10,0x21,0x80,0x9e,0x02,
+0xff,0xf1,0x03,0x24,0x24,0x10,0xa3,0x00,0x00,0x06,0x42,0x34,0x2a,0x0e,0x00,0x08,
+0x78,0x51,0xc2,0xac,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xd8,0xff,0xbd,0x27,
+0x10,0x00,0xb0,0xaf,0xc0,0x80,0x04,0x00,0x21,0x80,0x04,0x02,0x80,0x80,0x10,0x00,
+0x21,0x80,0x04,0x02,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,0x80,0x80,0x10,0x00,
+0x20,0x00,0xbf,0xaf,0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,0x21,0x80,0x02,0x02,
+0x14,0x00,0xb1,0xaf,0x78,0x51,0x03,0x8e,0x25,0xb0,0x02,0x3c,0x80,0x01,0x53,0x34,
+0x07,0x00,0x63,0x30,0x80,0x18,0x03,0x00,0x21,0x18,0x62,0x00,0x00,0x00,0x71,0x92,
+0x70,0x51,0x05,0x8e,0x84,0x01,0x62,0x8c,0x21,0x90,0x80,0x00,0xff,0x00,0x31,0x32,
+0x24,0x10,0x45,0x00,0xce,0x0d,0x00,0x0c,0x74,0x51,0x02,0xae,0x7a,0x51,0x04,0x92,
+0x5c,0x0d,0x00,0x0c,0xff,0x00,0x45,0x32,0x7a,0x51,0x04,0x92,0x63,0x0d,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x38,0x04,0x00,0x03,0x24,0x0a,0x88,0x62,0x00,
+0x00,0x00,0x71,0xa2,0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,
+0xff,0xff,0x84,0x30,0x00,0x02,0x82,0x30,0x07,0x00,0x03,0x24,0x0d,0x00,0x40,0x14,
+0x0b,0x00,0x84,0x30,0x0c,0x00,0x82,0x2c,0x0a,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0x02,0x80,0x03,0x3c,0x80,0x10,0x04,0x00,0xf0,0x91,0x63,0x24,0x21,0x10,0x43,0x00,
+0x00,0x00,0x44,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x80,0x00,0x00,0x00,0x00,0x00,
+0x07,0x00,0x03,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,0x06,0x00,0x03,0x24,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,0x05,0x00,0x03,0x24,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x60,0x00,0x04,0x00,0x03,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0x03,0x00,0x03,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,0x02,0x00,0x03,0x24,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,0x01,0x00,0x03,0x24,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x60,0x00,0x21,0x18,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0xa0,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,0x58,0x00,0xbe,0xaf,0x54,0x00,0xb7,0xaf,
+0x50,0x00,0xb6,0xaf,0x4c,0x00,0xb5,0xaf,0x48,0x00,0xb4,0xaf,0x40,0x00,0xb2,0xaf,
+0x3c,0x00,0xb1,0xaf,0x5c,0x00,0xbf,0xaf,0x44,0x00,0xb3,0xaf,0x38,0x00,0xb0,0xaf,
+0x20,0x92,0x42,0x24,0x00,0x00,0x53,0x8c,0x08,0x00,0x03,0x24,0x02,0x80,0x0b,0x3c,
+0x21,0x90,0x00,0x00,0x21,0xa0,0x00,0x00,0x21,0xb8,0x00,0x00,0x21,0xf0,0x00,0x00,
+0x21,0xa8,0x00,0x00,0x21,0xb0,0x00,0x00,0x21,0x88,0x60,0x02,0x10,0x00,0xa3,0xaf,
+0x14,0x00,0xa0,0xaf,0x18,0x00,0xa0,0xaf,0x1c,0x00,0xa0,0xaf,0x20,0x00,0xa0,0xaf,
+0x24,0x00,0xa0,0xaf,0x28,0x00,0xa0,0xaf,0x7a,0x0f,0x00,0x08,0x2c,0x00,0xa0,0xaf,
+0x44,0x51,0x22,0xae,0x60,0x51,0x24,0x8e,0x5c,0x51,0x27,0x8e,0x48,0x51,0x28,0x8e,
+0x4c,0x51,0x25,0x8e,0x54,0x51,0x26,0x8e,0x58,0x51,0x23,0x8e,0x21,0x38,0xe4,0x00,
+0x02,0x80,0x04,0x3c,0x68,0x15,0x84,0x24,0x21,0x10,0x04,0x02,0x21,0x40,0x05,0x01,
+0x21,0x30,0xc3,0x00,0xca,0x44,0x42,0x90,0x44,0x51,0x2a,0x8e,0x0c,0x00,0xe0,0x10,
+0x21,0x48,0x00,0x00,0x2b,0x48,0x47,0x00,0x0b,0x00,0x20,0x15,0x02,0x80,0x02,0x3c,
+0x07,0x00,0x02,0x2e,0x59,0x01,0x40,0x14,0xc0,0x10,0x07,0x00,0x0c,0x00,0x02,0x24,
+0x55,0x01,0x02,0x12,0x0d,0x00,0x02,0x24,0x54,0x01,0x02,0x12,0xc0,0x10,0x07,0x00,
+0x92,0x00,0x20,0x11,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,0x80,0x18,0x10,0x00,
+0x21,0x18,0x62,0x00,0x21,0x20,0x30,0x02,0xb6,0x51,0x85,0x90,0xec,0x44,0x62,0x8c,
+0x00,0x00,0x00,0x00,0x04,0x10,0xa2,0x00,0x2b,0x10,0x4a,0x00,0x87,0x00,0x40,0x10,
+0x00,0x00,0x00,0x00,0xd4,0x51,0x22,0x8e,0x01,0x00,0x07,0x24,0x04,0x18,0x07,0x02,
+0x24,0x10,0x43,0x00,0xf0,0x00,0x40,0x10,0x1c,0x00,0x02,0x2e,0x21,0x28,0x30,0x02,
+0x7c,0x51,0xa6,0x90,0xb6,0x51,0xa2,0x90,0x0a,0x00,0x04,0x24,0xff,0x00,0xc3,0x30,
+0x04,0x20,0x44,0x00,0x2a,0x18,0x64,0x00,0xe7,0x00,0x60,0x10,0x1c,0x00,0x02,0x2e,
+0x01,0x00,0xc2,0x24,0xff,0x00,0x43,0x30,0x56,0x01,0x64,0x10,0x7c,0x51,0xa2,0xa0,
+0x68,0x15,0x65,0x25,0x80,0x10,0x10,0x00,0x21,0x10,0x45,0x00,0x60,0x45,0x44,0x8c,
+0xec,0x44,0x43,0x8c,0x21,0x30,0xc5,0x02,0x40,0x10,0x04,0x00,0x21,0x10,0x44,0x00,
+0x21,0x18,0x62,0x00,0x82,0x50,0x03,0x00,0x44,0x51,0xca,0xac,0x8c,0x65,0xa3,0x8c,
+0xff,0xff,0x02,0x34,0x07,0x00,0x62,0x10,0x21,0x20,0x00,0x02,0x21,0x20,0x00,0x02,
+0xff,0x00,0x45,0x32,0x5c,0x0d,0x00,0x0c,0x30,0x00,0xab,0xaf,0x30,0x00,0xab,0x8f,
+0x21,0x20,0x00,0x02,0x63,0x0d,0x00,0x0c,0x30,0x00,0xab,0xaf,0x10,0x00,0xa4,0x8f,
+0x01,0x00,0x42,0x38,0x04,0x00,0x03,0x24,0x0a,0x20,0x62,0x00,0x10,0x00,0xa4,0xaf,
+0x30,0x00,0xab,0x8f,0x11,0x00,0x40,0x16,0x68,0x15,0x62,0x25,0x58,0x51,0x47,0x8c,
+0x54,0x51,0x43,0x8c,0x4c,0x51,0x44,0x94,0x48,0x51,0x45,0x94,0x50,0x51,0x46,0x94,
+0x21,0x18,0x67,0x00,0x00,0x24,0x04,0x00,0x25,0xb0,0x02,0x3c,0x00,0x1c,0x03,0x00,
+0x21,0x28,0xa4,0x00,0x21,0x30,0xc3,0x00,0x6c,0x0c,0x44,0x34,0x68,0x0c,0x42,0x34,
+0x00,0x00,0x45,0xac,0x00,0x00,0x86,0xac,0x68,0x15,0x62,0x25,0x21,0x10,0x82,0x02,
+0x58,0x51,0x40,0xac,0x5c,0x51,0x40,0xac,0x60,0x51,0x40,0xac,0x48,0x51,0x40,0xac,
+0x4c,0x51,0x40,0xac,0x50,0x51,0x40,0xac,0x54,0x51,0x40,0xac,0x2c,0x00,0xa2,0x8f,
+0x28,0x00,0xa4,0x8f,0x01,0x00,0x52,0x26,0x94,0x00,0x42,0x24,0x2c,0x00,0xa2,0xaf,
+0x24,0x00,0xa2,0x8f,0x94,0x00,0x84,0x24,0x28,0x00,0xa4,0xaf,0x94,0x00,0x42,0x24,
+0x20,0x00,0xa4,0x8f,0x24,0x00,0xa2,0xaf,0x1c,0x00,0xa2,0x8f,0x94,0x00,0x84,0x24,
+0x20,0x00,0xa4,0xaf,0x94,0x00,0x42,0x24,0x18,0x00,0xa4,0x8f,0x1c,0x00,0xa2,0xaf,
+0x14,0x00,0xa2,0x8f,0x94,0x00,0x84,0x24,0x20,0x00,0x43,0x2a,0x94,0x00,0x42,0x24,
+0x94,0x00,0x31,0x26,0x94,0x00,0xd6,0x26,0x94,0x00,0xb5,0x26,0x18,0x00,0xa4,0xaf,
+0x14,0x00,0xa2,0xaf,0x94,0x00,0xde,0x27,0x94,0x00,0x73,0x26,0x94,0x00,0xf7,0x26,
+0xe5,0x00,0x60,0x10,0x94,0x00,0x94,0x26,0x78,0x51,0x22,0x8e,0x00,0x00,0x00,0x00,
+0x02,0x13,0x02,0x00,0x01,0x00,0x42,0x30,0xd3,0xff,0x40,0x10,0x25,0xb0,0x02,0x3c,
+0x21,0x10,0x42,0x02,0x60,0x01,0x44,0x90,0x60,0x51,0x23,0x8e,0x5c,0x51,0x26,0x8e,
+0xff,0x00,0x90,0x30,0x02,0x80,0x04,0x3c,0x68,0x15,0x84,0x24,0x21,0x10,0x04,0x02,
+0x73,0x44,0x44,0x90,0x56,0x44,0x45,0x90,0x44,0x51,0x27,0x8e,0x18,0x00,0x64,0x00,
+0x12,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0xc5,0x00,
+0x12,0x30,0x00,0x00,0x21,0x30,0xc3,0x00,0x2b,0x10,0xe6,0x00,0x54,0xff,0x40,0x10,
+0x23,0x10,0xe6,0x00,0xe9,0x0e,0x00,0x08,0x44,0x51,0x20,0xae,0x62,0x00,0xe0,0x10,
+0x00,0x00,0x00,0x00,0x63,0x00,0x20,0x15,0x68,0x15,0x62,0x25,0x40,0x10,0x07,0x00,
+0x21,0x10,0x47,0x00,0x82,0x10,0x02,0x00,0x2b,0x10,0x46,0x00,0x99,0xff,0x40,0x10,
+0x21,0x20,0x00,0x02,0x68,0x15,0x68,0x25,0x21,0x20,0xa8,0x02,0x21,0x30,0x90,0x00,
+0xd4,0x51,0x83,0x8c,0x01,0x00,0x05,0x24,0x04,0x10,0x05,0x02,0x99,0x51,0xc7,0x90,
+0x27,0x10,0x02,0x00,0x24,0x18,0x62,0x00,0xd4,0x51,0x83,0xac,0x09,0x00,0xe5,0x10,
+0x7c,0x51,0xc0,0xa0,0x18,0x00,0xa2,0x8f,0x21,0x38,0x00,0x00,0x21,0x20,0x48,0x00,
+0x21,0x18,0x87,0x00,0x01,0x00,0xe7,0x24,0x1d,0x00,0xe2,0x28,0xfc,0xff,0x40,0x14,
+0xb6,0x51,0x60,0xa0,0x14,0x00,0xa4,0x8f,0x68,0x15,0x63,0x25,0x21,0x50,0x60,0x00,
+0x21,0x10,0x83,0x00,0x21,0x10,0x50,0x00,0x99,0x51,0x40,0xa0,0x02,0x80,0x03,0x3c,
+0x02,0x80,0x02,0x3c,0x4c,0x91,0x49,0x24,0xd8,0x90,0x68,0x24,0x21,0x38,0x00,0x00,
+0x80,0x18,0x07,0x00,0x21,0x10,0x69,0x00,0x21,0x20,0x68,0x00,0x00,0x00,0x46,0x8c,
+0x00,0x00,0x85,0x8c,0x01,0x00,0xe7,0x24,0x21,0x18,0x6a,0x00,0x1d,0x00,0xe2,0x28,
+0xec,0x44,0x65,0xac,0xf6,0xff,0x40,0x14,0x60,0x45,0x66,0xac,0x14,0x00,0x00,0x12,
+0x68,0x15,0x63,0x25,0x7b,0x51,0x62,0x92,0xff,0xff,0x07,0x26,0x2a,0x10,0xe2,0x00,
+0x0e,0x00,0x40,0x14,0x02,0x80,0x0b,0x3c,0x68,0x15,0x62,0x25,0x21,0x10,0xc2,0x03,
+0x7b,0x51,0x45,0x90,0x74,0x51,0x44,0x8c,0x01,0x00,0x06,0x24,0x04,0x18,0xe6,0x00,
+0x24,0x10,0x83,0x00,0xb3,0x00,0x43,0x10,0x00,0x00,0x00,0x00,0xff,0xff,0xe7,0x24,
+0x2a,0x10,0xe5,0x00,0xfa,0xff,0x40,0x10,0x04,0x18,0xe6,0x00,0x68,0x15,0x63,0x25,
+0x80,0x10,0x10,0x00,0x21,0x10,0x43,0x00,0x60,0x45,0x45,0x8c,0xec,0x44,0x44,0x8c,
+0x02,0x80,0x03,0x3c,0x40,0x10,0x05,0x00,0x8e,0x7d,0x66,0x90,0x21,0x10,0x45,0x00,
+0x21,0x20,0x82,0x00,0x22,0x00,0x02,0x24,0x98,0x00,0xc2,0x10,0x82,0x50,0x04,0x00,
+0xd4,0x51,0x63,0x8e,0x01,0x00,0x02,0x24,0x04,0x10,0x02,0x02,0x25,0x18,0x62,0x00,
+0xd4,0x51,0x63,0xae,0x68,0x15,0x63,0x25,0x21,0x10,0xe3,0x02,0x44,0x51,0x4a,0xac,
+0x8c,0x65,0x64,0x8c,0xff,0xff,0x02,0x34,0x3c,0xff,0x82,0x14,0x21,0x20,0x00,0x02,
+0x39,0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0x3e,0xff,0x20,0x11,0x21,0x20,0x00,0x02,
+0x68,0x15,0x62,0x25,0x80,0x18,0x10,0x00,0x21,0x18,0x62,0x00,0x60,0x45,0x64,0x8c,
+0x00,0x00,0x00,0x00,0x2b,0x20,0x44,0x01,0x36,0xff,0x80,0x10,0x21,0x20,0x00,0x02,
+0xa2,0x0f,0x00,0x08,0x68,0x15,0x68,0x25,0x1e,0xff,0x40,0x10,0x68,0x15,0x65,0x25,
+0x21,0x20,0x30,0x02,0x99,0x51,0x83,0x90,0x01,0x00,0x02,0x24,0x63,0x00,0x62,0x10,
+0x02,0x80,0x02,0x3c,0x2c,0x00,0xa3,0x8f,0x68,0x15,0x42,0x24,0x21,0x38,0x00,0x00,
+0x21,0x20,0x62,0x00,0x21,0x18,0x87,0x00,0x01,0x00,0xe7,0x24,0x1d,0x00,0xe2,0x28,
+0xfc,0xff,0x40,0x14,0xb6,0x51,0x60,0xa0,0x28,0x00,0xa3,0x8f,0x02,0x80,0x0b,0x3c,
+0x68,0x15,0x65,0x25,0x21,0x30,0x65,0x00,0xd4,0x51,0xc2,0x8c,0x01,0x00,0x03,0x24,
+0x04,0x18,0x03,0x02,0x27,0x18,0x03,0x00,0x21,0x20,0xd0,0x00,0x24,0x10,0x43,0x00,
+0x99,0x51,0x80,0xa0,0xd4,0x51,0xc2,0xac,0x12,0x00,0x00,0x16,0x7c,0x51,0x80,0xa0,
+0x7a,0x51,0xc2,0x90,0x00,0x00,0x00,0x00,0x0e,0x00,0x40,0x10,0x01,0x00,0x07,0x24,
+0x24,0x00,0xa4,0x8f,0x01,0x00,0x06,0x24,0x21,0x10,0x85,0x00,0x7a,0x51,0x44,0x90,
+0x74,0x51,0x45,0x8c,0x04,0x18,0xe6,0x00,0x24,0x10,0xa3,0x00,0x5b,0x00,0x43,0x10,
+0x00,0x00,0x00,0x00,0x01,0x00,0xe7,0x24,0x2a,0x10,0x87,0x00,0xfa,0xff,0x40,0x10,
+0x04,0x18,0xe6,0x00,0x20,0x00,0xa2,0x8f,0x02,0x80,0x0b,0x3c,0x68,0x15,0x64,0x25,
+0x21,0x18,0x44,0x00,0x7a,0x51,0x62,0x90,0x01,0x00,0x07,0x26,0x2a,0x10,0x47,0x00,
+0x0e,0x00,0x40,0x14,0x01,0x00,0x06,0x24,0x1c,0x00,0xa3,0x8f,0x00,0x00,0x00,0x00,
+0x21,0x10,0x64,0x00,0x7a,0x51,0x45,0x90,0x74,0x51,0x44,0x8c,0x04,0x18,0xe6,0x00,
+0x24,0x10,0x83,0x00,0x42,0x00,0x43,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0xe7,0x24,
+0x2a,0x10,0xa7,0x00,0xfa,0xff,0x40,0x10,0x04,0x18,0xe6,0x00,0x02,0x80,0x02,0x3c,
+0x8e,0x7d,0x44,0x90,0x22,0x00,0x03,0x24,0xd6,0xfe,0x83,0x14,0x68,0x15,0x65,0x25,
+0xee,0xff,0x02,0x26,0xff,0x00,0x42,0x30,0x02,0x00,0x42,0x2c,0x18,0x00,0x03,0x24,
+0x25,0x0f,0x00,0x08,0x0b,0x80,0x62,0x00,0xc0,0x10,0x07,0x00,0x23,0x10,0x47,0x00,
+0xc2,0x10,0x02,0x00,0x2b,0x10,0x48,0x00,0xb6,0xfe,0x40,0x14,0x00,0x00,0x00,0x00,
+0x04,0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0x10,0x00,0xa3,0x8f,0x5c,0x00,0xbf,0x8f,
+0x58,0x00,0xbe,0x8f,0x54,0x00,0xb7,0x8f,0x50,0x00,0xb6,0x8f,0x4c,0x00,0xb5,0x8f,
+0x48,0x00,0xb4,0x8f,0x44,0x00,0xb3,0x8f,0x40,0x00,0xb2,0x8f,0x3c,0x00,0xb1,0x8f,
+0x38,0x00,0xb0,0x8f,0x25,0xb0,0x02,0x3c,0x80,0x01,0x42,0x34,0x60,0x00,0xbd,0x27,
+0x00,0x00,0x43,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x18,0x00,0x02,0x2e,
+0x0a,0x00,0x40,0x14,0x05,0x00,0x02,0x2e,0xb6,0x51,0x83,0x90,0x00,0x00,0x00,0x00,
+0x05,0x00,0x62,0x2c,0xa0,0xff,0x40,0x10,0x01,0x00,0x62,0x24,0x16,0x10,0x00,0x08,
+0xb6,0x51,0x82,0xa0,0x24,0x0f,0x00,0x08,0x99,0x51,0xa7,0xa0,0x04,0x00,0x40,0x10,
+0x00,0x00,0x00,0x00,0xb6,0x51,0x83,0x90,0x75,0x10,0x00,0x08,0x03,0x00,0x62,0x2c,
+0xb6,0x51,0x83,0x90,0x75,0x10,0x00,0x08,0x04,0x00,0x62,0x2c,0x13,0x00,0x02,0x24,
+0x67,0xff,0x02,0x16,0x68,0x15,0x63,0x25,0xf3,0x0f,0x00,0x08,0x21,0x10,0xe3,0x02,
+0xff,0x00,0xf0,0x30,0x4c,0x10,0x00,0x08,0x02,0x80,0x02,0x3c,0x35,0x10,0x00,0x08,
+0xff,0x00,0xf0,0x30,0xdf,0x0f,0x00,0x08,0xff,0x00,0xf0,0x30,0xd8,0xff,0xbd,0x27,
+0x02,0x80,0x02,0x3c,0x14,0x00,0xb1,0xaf,0x24,0x00,0xbf,0xaf,0x20,0x00,0xb4,0xaf,
+0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,0x10,0x00,0xb0,0xaf,0x68,0x15,0x45,0x24,
+0x05,0x65,0xa4,0x90,0x00,0x65,0xa3,0x8c,0xfc,0x64,0xa2,0x8c,0x21,0x88,0x64,0x00,
+0x2b,0x10,0x22,0x02,0x60,0x00,0x40,0x10,0x21,0x80,0xa0,0x00,0x02,0x80,0x14,0x3c,
+0x21,0x98,0xa0,0x00,0xa8,0x10,0x00,0x08,0x21,0x90,0xa0,0x00,0xfc,0x64,0x42,0x8e,
+0x10,0x00,0x31,0x26,0x2b,0x10,0x22,0x02,0x57,0x00,0x40,0x10,0x21,0x80,0x40,0x02,
+0x05,0x65,0x02,0x92,0xff,0xff,0x23,0x32,0x02,0x80,0x05,0x3c,0x10,0x00,0x42,0x24,
+0x25,0x28,0x65,0x00,0x2c,0x79,0x84,0x26,0x10,0x00,0x06,0x24,0x9f,0x45,0x00,0x0c,
+0x05,0x65,0x02,0xa2,0xc8,0x63,0x06,0x8e,0x00,0x00,0x00,0x00,0x42,0x24,0x06,0x00,
+0x1f,0x00,0x84,0x30,0xc0,0x10,0x04,0x00,0x21,0x10,0x44,0x00,0x80,0x10,0x02,0x00,
+0x21,0x10,0x44,0x00,0x80,0x10,0x02,0x00,0x21,0x38,0x50,0x00,0x78,0x51,0xe3,0x8c,
+0x00,0x00,0x00,0x00,0x02,0x1b,0x03,0x00,0x01,0x00,0x63,0x30,0xe3,0xff,0x60,0x10,
+0x25,0xb0,0x02,0x3c,0xc4,0x63,0x05,0x8e,0x21,0x10,0x82,0x00,0x60,0x01,0x44,0x90,
+0x82,0x1d,0x05,0x00,0x3f,0x00,0x63,0x30,0x04,0x00,0x0a,0x24,0x05,0x00,0x62,0x28,
+0x21,0x40,0x40,0x01,0x0b,0x40,0x62,0x00,0x07,0x00,0xa0,0x04,0xff,0x00,0x89,0x30,
+0x64,0x51,0xe2,0x8c,0x04,0x00,0x08,0x24,0x01,0x00,0x42,0x24,0x64,0x51,0xe2,0xac,
+0xc8,0x63,0x66,0x8e,0x00,0x00,0x00,0x00,0x02,0x13,0x06,0x00,0x1f,0x00,0x42,0x30,
+0x08,0x00,0x42,0x28,0xcd,0xff,0x40,0x10,0x00,0x00,0x00,0x00,0xc4,0x63,0x62,0x8e,
+0x00,0x00,0x00,0x00,0x3f,0x00,0x42,0x30,0xc8,0xff,0x49,0x14,0x00,0x00,0x00,0x00,
+0x29,0x00,0x00,0x11,0x01,0x00,0x02,0x24,0x2e,0x00,0x02,0x11,0x02,0x00,0x02,0x24,
+0x33,0x00,0x02,0x11,0x03,0x00,0x02,0x24,0x38,0x00,0x02,0x11,0x00,0x00,0x00,0x00,
+0x3b,0x00,0x0a,0x11,0x00,0x00,0x00,0x00,0x68,0x51,0xe2,0x8c,0x21,0x18,0x33,0x01,
+0x90,0x44,0x64,0x90,0x02,0x11,0x02,0x00,0x2b,0x10,0x44,0x00,0x3e,0x00,0x40,0x14,
+0x00,0x00,0x00,0x00,0x5c,0x51,0xe3,0x8c,0x80,0x10,0x09,0x00,0x21,0x10,0x49,0x00,
+0x01,0x00,0x63,0x24,0x21,0x10,0x53,0x00,0x5c,0x51,0xe3,0xac,0x21,0x10,0x48,0x00,
+0x34,0x43,0x44,0x90,0x44,0x51,0xe3,0x8c,0x00,0x00,0x00,0x00,0x21,0x18,0x64,0x00,
+0x44,0x51,0xe3,0xac,0xfc,0x64,0x42,0x8e,0x10,0x00,0x31,0x26,0x2b,0x10,0x22,0x02,
+0xab,0xff,0x40,0x14,0x21,0x80,0x40,0x02,0x24,0x00,0xbf,0x8f,0x20,0x00,0xb4,0x8f,
+0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,0x48,0x51,0xe2,0x8c,0x00,0x00,0x00,0x00,
+0x01,0x00,0x42,0x24,0x48,0x51,0xe2,0xac,0x01,0x00,0x02,0x24,0xd4,0xff,0x02,0x15,
+0x02,0x00,0x02,0x24,0x4c,0x51,0xe2,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,
+0x4c,0x51,0xe2,0xac,0x02,0x00,0x02,0x24,0xcf,0xff,0x02,0x15,0x03,0x00,0x02,0x24,
+0x50,0x51,0xe2,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0x50,0x51,0xe2,0xac,
+0x03,0x00,0x02,0x24,0xca,0xff,0x02,0x15,0x00,0x00,0x00,0x00,0x54,0x51,0xe2,0x8c,
+0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0xc7,0xff,0x0a,0x15,0x54,0x51,0xe2,0xac,
+0x58,0x51,0xe2,0x8c,0x21,0x18,0x33,0x01,0x01,0x00,0x42,0x24,0x58,0x51,0xe2,0xac,
+0x68,0x51,0xe2,0x8c,0x90,0x44,0x64,0x90,0x02,0x11,0x02,0x00,0x2b,0x10,0x44,0x00,
+0xc4,0xff,0x40,0x10,0x00,0x00,0x00,0x00,0x60,0x51,0xe3,0x8c,0x80,0x10,0x09,0x00,
+0x21,0x10,0x49,0x00,0x01,0x00,0x63,0x24,0x21,0x10,0x53,0x00,0x60,0x51,0xe3,0xac,
+0x21,0x10,0x48,0x00,0xc5,0x43,0x44,0x90,0x44,0x51,0xe3,0x8c,0x00,0x00,0x00,0x00,
+0x21,0x18,0x64,0x00,0xf9,0x10,0x00,0x08,0x44,0x51,0xe3,0xac,0x25,0xb0,0x02,0x3c,
+0x25,0xb0,0x05,0x3c,0x02,0x80,0x03,0x3c,0x58,0x00,0x4a,0x34,0x5c,0x00,0x4b,0x34,
+0x4c,0x00,0xa2,0x34,0x00,0x00,0x44,0x90,0x68,0x15,0x66,0x24,0xed,0x4a,0xc2,0x90,
+0x29,0xb0,0x07,0x3c,0x03,0x00,0x84,0x30,0x21,0x18,0xc0,0x00,0x0f,0x00,0x44,0x10,
+0x04,0x00,0xe8,0x34,0x07,0x00,0x80,0x14,0x58,0x0c,0xa9,0x34,0xe6,0x42,0xc2,0x90,
+0x1c,0x00,0x06,0x24,0x03,0x00,0x40,0x14,0x50,0x0c,0xa5,0x34,0x00,0x00,0xa6,0xa0,
+0x00,0x00,0x26,0xa1,0x00,0x00,0x42,0x8d,0xed,0x4a,0x64,0xa0,0x00,0x00,0xe2,0xac,
+0x00,0x00,0x62,0x8d,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xad,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x00,0x00,0x25,0xb0,0x0d,0x3c,0xe8,0xff,0xbd,0x27,0x10,0x00,0xbf,0xaf,
+0x2d,0x0a,0xa7,0x35,0xa2,0x0d,0xa2,0x35,0xa4,0x0d,0xa3,0x35,0xa6,0x0d,0xa4,0x35,
+0xa8,0x0d,0xa5,0x35,0x00,0x00,0x48,0x94,0x00,0x00,0x69,0x94,0x00,0x00,0x8a,0x94,
+0x00,0x00,0xab,0x94,0x00,0x00,0xe3,0x90,0x5b,0x0a,0xa4,0x35,0x5c,0x0a,0xa6,0x35,
+0x00,0x2e,0x03,0x00,0x03,0x2e,0x05,0x00,0x40,0x00,0xa2,0x34,0x00,0x00,0xe2,0xa0,
+0x00,0x00,0x85,0x90,0x00,0x00,0xc3,0x90,0x02,0x80,0x0e,0x3c,0x68,0x15,0xcc,0x25,
+0xff,0xff,0x22,0x31,0xff,0x00,0xa5,0x30,0xff,0xff,0x04,0x31,0x21,0x20,0x82,0x00,
+0xff,0x00,0x63,0x30,0x00,0x40,0x87,0x8d,0x00,0x2a,0x05,0x00,0xff,0xff,0x46,0x31,
+0x21,0x28,0xa3,0x00,0xff,0xff,0x62,0x31,0x21,0x20,0x86,0x00,0x21,0x20,0x82,0x00,
+0xff,0xff,0xa3,0x30,0x64,0x0c,0xa2,0x35,0x00,0x00,0x45,0xa4,0x21,0x20,0x83,0x00,
+0x0f,0x00,0xe7,0x30,0x01,0x00,0x02,0x24,0xe0,0x42,0x84,0xad,0xd8,0x42,0x88,0xa5,
+0xda,0x42,0x89,0xa5,0xdc,0x42,0x8a,0xa5,0xde,0x42,0x8b,0xa5,0x07,0x00,0xe2,0x10,
+0xe4,0x42,0x85,0xa5,0xa8,0x56,0x00,0x0c,0x00,0x00,0x00,0x00,0x10,0x00,0xbf,0x8f,
+0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,0x4c,0x00,0xa3,0x35,
+0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,0x03,0x00,0x42,0x30,0x67,0x00,0x47,0x10,
+0x68,0x15,0xc4,0x25,0xe6,0x42,0x82,0x90,0x00,0x00,0x00,0x00,0x2d,0x00,0x40,0x10,
+0x01,0x00,0x03,0x24,0x68,0x15,0xc5,0x25,0xe6,0x42,0xa3,0x90,0xff,0x00,0x02,0x24,
+0xec,0xff,0x62,0x14,0x25,0xb0,0x03,0x3c,0xc8,0x42,0xa2,0x94,0xe0,0x42,0xa6,0x8c,
+0x50,0x0c,0x63,0x34,0x00,0x00,0x64,0x90,0x2b,0x10,0xc2,0x00,0x5e,0x00,0x40,0x14,
+0x7f,0x00,0x84,0x30,0xca,0x42,0xa2,0x94,0x00,0x00,0x00,0x00,0x2b,0x10,0xc2,0x00,
+0x09,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0xcc,0x42,0xa2,0x94,0x00,0x00,0x00,0x00,
+0x2b,0x10,0xc2,0x00,0x02,0x00,0x40,0x10,0x02,0x00,0x82,0x24,0x01,0x00,0x82,0x24,
+0xff,0x00,0x44,0x30,0x68,0x15,0xc5,0x25,0xd0,0x42,0xa3,0x90,0x00,0x00,0x00,0x00,
+0x2b,0x10,0x64,0x00,0x4e,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x21,0x20,0x60,0x00,
+0x68,0x15,0xc3,0x25,0xe0,0x42,0x62,0x8c,0x00,0x00,0x00,0x00,0xe9,0x03,0x42,0x2c,
+0x02,0x00,0x40,0x14,0x25,0xb0,0x02,0x3c,0xd0,0x42,0x64,0x90,0x58,0x0c,0x43,0x34,
+0x50,0x0c,0x42,0x34,0x00,0x00,0x44,0xa0,0x00,0x00,0x64,0xa0,0x85,0x11,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x40,0x82,0x8c,0x00,0x00,0x00,0x00,0x02,0x12,0x02,0x00,
+0x0f,0x00,0x42,0x30,0xd0,0xff,0x43,0x14,0x68,0x15,0xc5,0x25,0x25,0xb0,0x02,0x3c,
+0x4c,0x00,0x42,0x34,0x00,0x00,0x43,0x90,0x00,0x00,0x00,0x00,0x03,0x00,0x63,0x30,
+0xb8,0xff,0x60,0x10,0xff,0xff,0x02,0x34,0xdc,0x63,0x83,0x8c,0x00,0x00,0x00,0x00,
+0xb4,0xff,0x62,0x10,0x00,0x00,0x00,0x00,0xe0,0x42,0x83,0x8c,0x00,0x00,0x00,0x00,
+0x65,0x00,0x62,0x2c,0x3b,0x00,0x40,0x14,0x28,0x00,0x62,0x2c,0xd2,0x42,0x83,0x90,
+0x00,0x00,0x00,0x00,0x00,0x16,0x03,0x00,0x03,0x16,0x02,0x00,0xfe,0xff,0x42,0x24,
+0xfc,0xff,0x42,0x28,0x02,0x00,0x40,0x10,0xfe,0xff,0x62,0x24,0xfc,0xff,0x02,0x24,
+0xd2,0x42,0x82,0xa0,0x68,0x15,0xc4,0x25,0xdc,0x63,0x82,0x8c,0xd2,0x42,0x83,0x90,
+0xce,0x42,0x86,0x90,0x02,0x11,0x02,0x00,0x7f,0x00,0x42,0x30,0x0a,0x00,0x45,0x24,
+0x23,0x18,0xa3,0x00,0x00,0x2e,0x03,0x00,0x03,0x2e,0x05,0x00,0xff,0x00,0xc2,0x30,
+0x2a,0x10,0x45,0x00,0x17,0x00,0x40,0x10,0x25,0xb0,0x02,0x3c,0x00,0x2e,0x06,0x00,
+0x03,0x2e,0x05,0x00,0x58,0x0c,0x43,0x34,0x50,0x0c,0x42,0x34,0x00,0x00,0x45,0xa0,
+0x00,0x00,0x65,0xa0,0x85,0x11,0x00,0x08,0x00,0x00,0x00,0x00,0xe6,0x42,0x82,0x91,
+0x00,0x00,0x00,0x00,0x97,0xff,0x40,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x02,0x24,
+0x91,0x11,0x00,0x08,0xe6,0x42,0x82,0xa1,0xac,0x11,0x00,0x08,0xff,0xff,0x82,0x24,
+0xd1,0x42,0xa3,0x90,0x00,0x00,0x00,0x00,0x2b,0x10,0x83,0x00,0xb4,0x11,0x00,0x08,
+0x0b,0x20,0x62,0x00,0xcf,0x42,0x83,0x80,0x00,0x00,0x00,0x00,0xff,0x00,0x62,0x30,
+0x2a,0x10,0xa2,0x00,0x0b,0x28,0x62,0x00,0x25,0xb0,0x02,0x3c,0x58,0x0c,0x43,0x34,
+0x50,0x0c,0x42,0x34,0x00,0x00,0x45,0xa0,0x00,0x00,0x65,0xa0,0x85,0x11,0x00,0x08,
+0x00,0x00,0x00,0x00,0xcf,0xff,0x40,0x10,0x00,0x00,0x00,0x00,0xd2,0x42,0x83,0x90,
+0x00,0x00,0x00,0x00,0x00,0x16,0x03,0x00,0x03,0x16,0x02,0x00,0x02,0x00,0x42,0x24,
+0x0d,0x00,0x42,0x28,0x03,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0xe0,0x11,0x00,0x08,
+0x0c,0x00,0x02,0x24,0xe0,0x11,0x00,0x08,0x02,0x00,0x62,0x24,0xc0,0xff,0xbd,0x27,
+0x18,0x00,0xb0,0xaf,0x25,0xb0,0x10,0x3c,0x28,0x00,0xb4,0xaf,0x24,0x00,0xb3,0xaf,
+0x1c,0x00,0xb1,0xaf,0x3c,0x00,0xbf,0xaf,0x38,0x00,0xbe,0xaf,0x34,0x00,0xb7,0xaf,
+0x30,0x00,0xb6,0xaf,0x2c,0x00,0xb5,0xaf,0x20,0x00,0xb2,0xaf,0xd8,0x00,0x06,0x36,
+0x00,0x00,0xc3,0x90,0x02,0x80,0x02,0x3c,0x68,0x15,0x54,0x24,0x2a,0xb0,0x11,0x3c,
+0xa0,0xff,0x02,0x24,0x25,0x18,0x62,0x00,0x34,0x00,0x25,0x36,0xfe,0xff,0x02,0x24,
+0xbc,0x42,0x92,0x92,0x40,0x00,0x04,0x24,0x00,0x00,0xc3,0xa0,0x00,0x00,0xa2,0xa0,
+0xa1,0x4e,0x00,0x0c,0x00,0x96,0x12,0x00,0x21,0x98,0x40,0x00,0x6b,0x00,0x60,0x12,
+0x00,0x40,0x02,0x3c,0x08,0x00,0x63,0x8e,0xb0,0x03,0x02,0x36,0x21,0x20,0x60,0x02,
+0x00,0x00,0x43,0xac,0x3a,0x45,0x00,0x0c,0x21,0xb8,0x80,0x02,0x01,0x00,0x1e,0x24,
+0x42,0x00,0x16,0x36,0x03,0x0c,0x11,0x36,0x17,0x0e,0x15,0x36,0x04,0x00,0x14,0x24,
+0x2a,0xb0,0x03,0x3c,0x06,0x00,0x63,0x34,0x00,0x00,0x62,0x94,0x00,0x00,0x00,0x00,
+0x00,0xff,0x42,0x30,0x0a,0x00,0x40,0x18,0x00,0x00,0x00,0x00,0x02,0x80,0x04,0x3c,
+0xc8,0x94,0x84,0x24,0x00,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x94,
+0x00,0x00,0x00,0x00,0x00,0xff,0x42,0x30,0xfc,0xff,0x40,0x1c,0x00,0x00,0x00,0x00,
+0x08,0x00,0x65,0x8e,0x20,0x10,0x06,0x3c,0x00,0xfe,0xc6,0x34,0x40,0x00,0x07,0x24,
+0x01,0x00,0x04,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xbe,0xaf,0x4d,0x01,0x00,0x0c,
+0x01,0x00,0x04,0x24,0x2a,0xb0,0x02,0x3c,0x05,0x00,0x42,0x34,0xff,0xff,0x03,0x24,
+0x00,0x00,0x5e,0xa0,0x00,0x00,0xc3,0xa2,0x00,0x00,0x22,0x92,0xc1,0x42,0xe5,0x92,
+0x2a,0xb0,0x04,0x3c,0x02,0x00,0x03,0x24,0x40,0x00,0x42,0x34,0x05,0x00,0x84,0x34,
+0x00,0x00,0x22,0xa2,0x00,0x00,0x83,0xa0,0xef,0xff,0x02,0x24,0x00,0x00,0xb0,0x92,
+0x64,0x00,0x04,0x24,0x00,0x00,0xa5,0xa2,0x00,0x00,0xc2,0xa2,0xb3,0x0a,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x92,0xbf,0xff,0x03,0x24,0x84,0x03,0x04,0x24,
+0x24,0x10,0x43,0x00,0x00,0x00,0x22,0xa2,0xb3,0x0a,0x00,0x0c,0xff,0x00,0x10,0x32,
+0x25,0xb0,0x02,0x3c,0xf4,0x08,0x42,0x34,0x00,0x00,0x44,0x8c,0x00,0x00,0xb0,0xa2,
+0x00,0x00,0xc0,0xa2,0x00,0x00,0x22,0x92,0xbe,0x42,0xe3,0x92,0x1f,0x00,0x85,0x30,
+0x40,0x00,0x42,0x34,0x00,0x00,0x22,0xa2,0x00,0x80,0x02,0x3c,0xdf,0x07,0x42,0x34,
+0x2b,0x18,0xa3,0x00,0x09,0x00,0x60,0x10,0x24,0x20,0x82,0x00,0xbf,0x42,0xe2,0x92,
+0x00,0x00,0x00,0x00,0x2b,0x10,0x45,0x00,0x05,0x00,0x40,0x10,0x02,0x80,0x02,0x3c,
+0x01,0x00,0x02,0x3c,0x25,0x10,0xa2,0x00,0x21,0x90,0x42,0x02,0x02,0x80,0x02,0x3c,
+0x8e,0x7d,0x43,0x90,0x22,0x00,0x02,0x24,0x1c,0x00,0x62,0x10,0x92,0x00,0x02,0x24,
+0x1b,0x00,0x62,0x10,0x02,0x80,0x03,0x3c,0xff,0xff,0x94,0x26,0xb3,0x0a,0x00,0x0c,
+0xf4,0x01,0x04,0x24,0xab,0xff,0x81,0x06,0x2a,0xb0,0x03,0x3c,0x04,0x00,0x60,0x12,
+0x25,0xb0,0x02,0x3c,0xbd,0x4e,0x00,0x0c,0x21,0x20,0x60,0x02,0x25,0xb0,0x02,0x3c,
+0xd8,0x02,0x42,0x34,0x00,0x00,0x52,0xac,0x21,0x10,0x40,0x02,0x3c,0x00,0xbf,0x8f,
+0x38,0x00,0xbe,0x8f,0x34,0x00,0xb7,0x8f,0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,
+0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,
+0x18,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x40,0x00,0xbd,0x27,0x02,0x80,0x03,0x3c,
+0x68,0x15,0x63,0x24,0xbe,0x42,0x62,0x90,0xc0,0x07,0x83,0x30,0x82,0x19,0x03,0x00,
+0x2b,0x10,0x62,0x00,0xe0,0xff,0x40,0x10,0x02,0x80,0x04,0x3c,0x68,0x15,0x84,0x24,
+0xbf,0x42,0x82,0x90,0x00,0x00,0x00,0x00,0x2b,0x10,0x43,0x00,0xda,0xff,0x40,0x10,
+0x00,0x12,0x03,0x00,0x10,0x00,0x03,0x3c,0x25,0x10,0x43,0x00,0x9a,0x12,0x00,0x08,
+0x21,0x90,0x42,0x02,0xe8,0xff,0xbd,0x27,0x10,0x00,0xb0,0xaf,0x0f,0x00,0x10,0x3c,
+0xff,0xff,0x05,0x36,0xf0,0xf8,0x06,0x34,0x14,0x00,0xbf,0xaf,0xba,0x44,0x00,0x0c,
+0x15,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0xff,0xff,0x05,0x36,
+0x56,0x30,0x06,0x24,0xba,0x44,0x00,0x0c,0x1a,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,
+0x64,0x00,0x04,0x24,0x02,0x80,0x0b,0x3c,0x68,0x15,0x64,0x25,0x04,0x43,0x83,0x90,
+0x04,0x00,0x02,0x24,0x19,0x00,0x62,0x10,0x25,0xb0,0x02,0x3c,0x14,0x43,0x8a,0x8c,
+0x18,0x43,0x88,0x8c,0x25,0xb0,0x02,0x3c,0x1c,0x0e,0x49,0x34,0x00,0x0e,0x43,0x34,
+0x04,0x0e,0x44,0x34,0x08,0x0e,0x45,0x34,0x10,0x0e,0x46,0x34,0x14,0x0e,0x47,0x34,
+0x18,0x0e,0x42,0x34,0x00,0x00,0x6a,0xac,0x00,0x00,0x8a,0xac,0x00,0x00,0xa8,0xac,
+0x00,0x00,0xca,0xac,0x00,0x00,0xea,0xac,0x00,0x00,0x4a,0xac,0x00,0x00,0x2a,0xad,
+0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,0x68,0x15,0x63,0x25,0x04,0x00,0x02,0x24,
+0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x04,0x43,0x62,0xa0,0x00,0x0e,0x42,0x34,
+0x00,0x00,0x43,0x8c,0x14,0x43,0x8a,0x8c,0x00,0x00,0x00,0x00,0xe4,0xff,0x6a,0x14,
+0x00,0x00,0x00,0x00,0xec,0x12,0x00,0x08,0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,
+0x10,0x00,0xb0,0xaf,0x0f,0x00,0x10,0x3c,0xff,0xff,0x05,0x36,0xf0,0xf8,0x06,0x34,
+0x14,0x00,0xbf,0xaf,0xba,0x44,0x00,0x0c,0x15,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,
+0x64,0x00,0x04,0x24,0xff,0xff,0x05,0x36,0x56,0x30,0x06,0x24,0xba,0x44,0x00,0x0c,
+0x1a,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x02,0x80,0x04,0x3c,
+0x68,0x15,0x83,0x24,0x04,0x43,0x65,0x90,0x21,0x70,0x60,0x00,0x10,0x10,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0x10,0x10,0x66,0x34,0x01,0x00,0x03,0x24,0x1c,0x0e,0x4d,0x34,
+0x00,0x0e,0x4a,0x34,0x04,0x0e,0x4b,0x34,0x08,0x0e,0x4c,0x34,0x10,0x0e,0x47,0x34,
+0x14,0x0e,0x48,0x34,0x0f,0x00,0xa3,0x10,0x18,0x0e,0x49,0x34,0x10,0x10,0x02,0x24,
+0x00,0x00,0x46,0xad,0x00,0x00,0x66,0xad,0x00,0x00,0x82,0xad,0x00,0x00,0xe6,0xac,
+0x00,0x00,0x06,0xad,0x00,0x00,0x26,0xad,0x00,0x00,0xa6,0xad,0x14,0x00,0xbf,0x8f,
+0x10,0x00,0xb0,0x8f,0x01,0x00,0x02,0x24,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
+0x04,0x43,0xc2,0xa1,0x00,0x00,0x44,0x8d,0x00,0x00,0x00,0x00,0xf0,0xff,0x86,0x14,
+0x10,0x10,0x02,0x24,0x23,0x13,0x00,0x08,0x00,0x00,0x00,0x00,0xe0,0xff,0xbd,0x27,
+0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x01,0x00,0x11,0x3c,0x0f,0x00,0x10,0x3c,
+0xff,0xff,0x05,0x36,0xf4,0x98,0x26,0x36,0x18,0x00,0xbf,0xaf,0xba,0x44,0x00,0x0c,
+0x15,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0xff,0xff,0x05,0x36,
+0x56,0x30,0x26,0x36,0xba,0x44,0x00,0x0c,0x1a,0x00,0x04,0x24,0x02,0x80,0x10,0x3c,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x68,0x15,0x04,0x26,0x04,0x43,0x82,0x90,
+0x00,0x00,0x00,0x00,0x0d,0x00,0x40,0x14,0x25,0xb0,0x02,0x3c,0x00,0x0e,0x42,0x34,
+0x00,0x00,0x43,0x8c,0xec,0x42,0x8f,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x6f,0x14,
+0x68,0x15,0x02,0x26,0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,
+0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x04,0x43,0x40,0xa0,0xec,0x42,0x8f,0x8c,
+0xe8,0x42,0x88,0x8c,0xf0,0x42,0x8a,0x8c,0xf4,0x42,0x8b,0x8c,0xf8,0x42,0x8c,0x8c,
+0xfc,0x42,0x8d,0x8c,0x25,0xb0,0x02,0x3c,0x00,0x43,0x8e,0x8c,0x1c,0x0e,0x49,0x34,
+0x08,0x0e,0x43,0x34,0x00,0x0e,0x44,0x34,0x04,0x0e,0x45,0x34,0x10,0x0e,0x46,0x34,
+0x14,0x0e,0x47,0x34,0x18,0x0e,0x42,0x34,0x00,0x00,0x68,0xac,0x18,0x00,0xbf,0x8f,
+0x00,0x00,0x8f,0xac,0x14,0x00,0xb1,0x8f,0x00,0x00,0xaa,0xac,0x00,0x00,0xcb,0xac,
+0x00,0x00,0xec,0xac,0x00,0x00,0x4d,0xac,0x68,0x15,0x02,0x26,0x10,0x00,0xb0,0x8f,
+0x20,0x00,0xbd,0x27,0x00,0x00,0x2e,0xad,0x08,0x00,0xe0,0x03,0x04,0x43,0x40,0xa0,
+0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x01,0x00,0x11,0x3c,
+0x0f,0x00,0x10,0x3c,0xff,0xff,0x05,0x36,0xf4,0x98,0x26,0x36,0x18,0x00,0xbf,0xaf,
+0xba,0x44,0x00,0x0c,0x15,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,
+0xff,0xff,0x05,0x36,0x56,0x30,0x26,0x36,0xba,0x44,0x00,0x0c,0x1a,0x00,0x04,0x24,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x02,0x80,0x18,0x3c,0x68,0x15,0x05,0x27,
+0x04,0x43,0xa3,0x90,0x03,0x00,0x02,0x24,0x2a,0x00,0x62,0x10,0x25,0xb0,0x02,0x3c,
+0xec,0x42,0xaf,0x8c,0x08,0x43,0xa3,0x8c,0xe8,0x42,0xa2,0x8c,0xf0,0x42,0xac,0x8c,
+0xf4,0x42,0xad,0x8c,0xf8,0x42,0xa9,0x8c,0xfc,0x42,0xaa,0x8c,0x00,0x43,0xab,0x8c,
+0x21,0x70,0x43,0x00,0xff,0xff,0x02,0x3c,0x25,0xb0,0x03,0x3c,0xff,0x00,0x42,0x34,
+0x00,0xff,0xc4,0x31,0x04,0x0e,0x65,0x34,0x10,0x0e,0x66,0x34,0x14,0x0e,0x67,0x34,
+0x18,0x0e,0x68,0x34,0x24,0x80,0xc2,0x01,0x08,0x0e,0x71,0x34,0x00,0x0e,0x62,0x34,
+0x01,0x3f,0x84,0x2c,0x1c,0x0e,0x63,0x34,0x00,0x00,0x4f,0xac,0x00,0x00,0xac,0xac,
+0x00,0x00,0xcd,0xac,0x00,0x00,0xe9,0xac,0x00,0x00,0x0a,0xad,0x00,0x00,0x6b,0xac,
+0x0a,0x00,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x2e,0xae,0x18,0x00,0xbf,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x68,0x15,0x03,0x27,0x03,0x00,0x02,0x24,
+0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x04,0x43,0x62,0xa0,0xa6,0x13,0x00,0x08,
+0x00,0x3f,0x0e,0x36,0x00,0x0e,0x42,0x34,0x00,0x00,0x43,0x8c,0xec,0x42,0xaf,0x8c,
+0x00,0x00,0x00,0x00,0xd3,0xff,0x6f,0x14,0x00,0x00,0x00,0x00,0xa7,0x13,0x00,0x08,
+0x00,0x00,0x00,0x00,0xd0,0xff,0xbd,0x27,0x18,0x00,0xb2,0xaf,0x02,0x80,0x12,0x3c,
+0x24,0x00,0xb5,0xaf,0x20,0x00,0xb4,0xaf,0x28,0x00,0xbf,0xaf,0x1c,0x00,0xb3,0xaf,
+0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x68,0x15,0x44,0x26,0x02,0x80,0x14,0x3c,
+0x00,0x40,0x85,0x8c,0xdc,0x63,0x83,0x8c,0x8e,0x7d,0x86,0x92,0x25,0xb0,0x02,0x3c,
+0x0f,0x0c,0x42,0x34,0x00,0x00,0x46,0xa0,0x02,0x19,0x03,0x00,0xf0,0xf0,0xa5,0x30,
+0x00,0x10,0x02,0x24,0x04,0x43,0x93,0x90,0x71,0x00,0xa2,0x10,0x7f,0x00,0x75,0x30,
+0x25,0xb0,0x09,0x3c,0x4c,0x00,0x23,0x35,0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,
+0x03,0x00,0x42,0x30,0x09,0x00,0x40,0x10,0x68,0x15,0x45,0x26,0x68,0x15,0x4a,0x26,
+0x00,0x40,0x42,0x8d,0x00,0x00,0x00,0x00,0x02,0x13,0x02,0x00,0x0f,0x00,0x42,0x30,
+0x33,0x00,0x40,0x10,0x00,0x0e,0x25,0x35,0x68,0x15,0x45,0x26,0x04,0x43,0xa2,0x8c,
+0x00,0x00,0x00,0x00,0x02,0x12,0x02,0x00,0x0f,0x00,0x40,0x14,0x68,0x15,0x4a,0x26,
+0x25,0xb0,0x02,0x3c,0x84,0x01,0x42,0x34,0x00,0x00,0x44,0x8c,0x0d,0x00,0x03,0x24,
+0x7e,0x00,0x83,0x10,0x3e,0x00,0x02,0x24,0x4a,0x00,0x03,0x24,0x1f,0x43,0xa2,0xa0,
+0x1c,0x43,0xa3,0xa0,0x45,0x00,0x02,0x24,0x43,0x00,0x03,0x24,0x1d,0x43,0xa2,0xa0,
+0x1e,0x43,0xa3,0xa0,0x68,0x15,0x4a,0x26,0xdc,0x63,0x4c,0x8d,0x04,0x40,0x42,0x8d,
+0x00,0x40,0x4b,0x8d,0x1e,0x43,0x4d,0x91,0x1c,0x43,0x4e,0x91,0x25,0xb0,0x09,0x3c,
+0x02,0x11,0x02,0x00,0x60,0x0c,0x27,0x35,0x02,0x19,0x0c,0x00,0x98,0x0c,0x24,0x35,
+0x00,0x00,0xe3,0xa0,0x66,0x0c,0x25,0x35,0x00,0x00,0x82,0xa0,0x67,0x0c,0x26,0x35,
+0xf0,0xf0,0x68,0x31,0x10,0x10,0x02,0x24,0x00,0x00,0xad,0xa0,0x00,0x00,0xce,0xa0,
+0x43,0x00,0x02,0x11,0xff,0xff,0x02,0x34,0x28,0x00,0xbf,0x8f,0x24,0x00,0xb5,0x8f,
+0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,
+0x00,0x00,0xa2,0x8c,0x00,0x00,0x00,0x00,0x5d,0x00,0x40,0x10,0x10,0x0e,0x28,0x35,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x08,0x0e,0x22,0x35,0x04,0x0e,0x24,0x35,0x00,0x00,0x43,0x8c,0x00,0x00,0xa5,0x8c,
+0x00,0x00,0x82,0x8c,0xe8,0x42,0x43,0xad,0xec,0x42,0x45,0xad,0xf0,0x42,0x42,0xad,
+0x14,0x0e,0x24,0x35,0x18,0x0e,0x22,0x35,0x1c,0x0e,0x25,0x35,0x00,0x00,0x08,0x8d,
+0x8e,0x7d,0x8b,0x92,0x00,0x00,0x86,0x8c,0x00,0xff,0x63,0x30,0x00,0x00,0x47,0x8c,
+0x00,0x00,0xa4,0x8c,0x9a,0x0c,0x22,0x35,0x02,0x1a,0x03,0x00,0x00,0x00,0x43,0xa0,
+0x22,0x00,0x02,0x24,0xf4,0x42,0x48,0xad,0xf8,0x42,0x46,0xad,0xfc,0x42,0x47,0xad,
+0x58,0x00,0x62,0x11,0x00,0x43,0x44,0xad,0x92,0x00,0x02,0x24,0x56,0x00,0x62,0x11,
+0x0d,0x08,0x22,0x35,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x68,0x15,0x44,0x26,0x00,0x40,0x83,0x8c,0xff,0xff,0x02,0x3c,0xff,0x0f,0x42,0x34,
+0x24,0x18,0x62,0x00,0x00,0x10,0x63,0x34,0xde,0x13,0x00,0x08,0x00,0x40,0x83,0xac,
+0x01,0x00,0x02,0x24,0x35,0x00,0x62,0x12,0x04,0x00,0x02,0x24,0x33,0x00,0x62,0x12,
+0x68,0x15,0x43,0x26,0xff,0xff,0x02,0x24,0xd0,0x13,0x00,0x08,0x04,0x43,0x62,0xa0,
+0xbd,0xff,0x82,0x11,0x02,0x12,0x0b,0x00,0x0f,0x00,0x48,0x30,0x01,0x00,0x03,0x24,
+0xb9,0xff,0x03,0x15,0x4c,0x00,0x23,0x35,0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,
+0x03,0x00,0x42,0x30,0xb4,0xff,0x40,0x10,0x03,0x00,0x02,0x24,0x5f,0x00,0x62,0x12,
+0x04,0x00,0x62,0x2a,0x45,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x64,0x00,0x60,0x12,
+0xff,0x00,0xa2,0x31,0xac,0xff,0x68,0x16,0xff,0x00,0xc2,0x31,0x2b,0x10,0xa2,0x02,
+0x52,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x1f,0x43,0x42,0x91,0x00,0x00,0x00,0x00,
+0x2b,0x10,0x55,0x00,0x44,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0x2f,0x13,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x06,0x14,0x00,0x08,0x00,0x00,0x00,0x00,0x3b,0x00,0x02,0x24,
+0x46,0x00,0x03,0x24,0x1f,0x43,0xa2,0xa0,0x1c,0x43,0xa3,0xa0,0x41,0x00,0x02,0x24,
+0x40,0x00,0x03,0x24,0x1d,0x43,0xa2,0xa0,0xf1,0x13,0x00,0x08,0x1e,0x43,0xa3,0xa0,
+0x00,0x00,0x03,0x8d,0x3f,0x3f,0x02,0x3c,0x3f,0x3f,0x42,0x34,0xa0,0xff,0x62,0x14,
+0x00,0x00,0x00,0x00,0xdf,0x13,0x00,0x08,0x68,0x15,0x45,0x26,0x0f,0x00,0x10,0x3c,
+0x01,0x00,0x11,0x3c,0xff,0xff,0x05,0x36,0xf4,0x98,0x26,0x36,0xba,0x44,0x00,0x0c,
+0x15,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0xff,0xff,0x05,0x36,
+0x56,0x30,0x26,0x36,0xba,0x44,0x00,0x0c,0x1a,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,
+0x64,0x00,0x04,0x24,0x68,0x15,0x43,0x26,0xff,0xff,0x02,0x24,0xd0,0x13,0x00,0x08,
+0x04,0x43,0x62,0xa0,0x0d,0x08,0x22,0x35,0x00,0x00,0x43,0x90,0x00,0x00,0x00,0x00,
+0x0f,0x00,0x63,0x30,0x08,0x00,0x62,0x2c,0x0f,0x00,0x63,0x38,0xa5,0xff,0x40,0x14,
+0x01,0x00,0x65,0x24,0x00,0x16,0x05,0x00,0x00,0x24,0x05,0x00,0x00,0x1a,0x05,0x00,
+0x25,0x10,0x44,0x00,0x25,0x10,0x43,0x00,0x25,0x10,0x45,0x00,0x25,0x18,0x65,0x00,
+0x18,0x43,0x43,0xad,0x35,0x14,0x00,0x08,0x14,0x43,0x42,0xad,0x04,0x00,0x02,0x24,
+0x0d,0x00,0x62,0x12,0xff,0x00,0x02,0x24,0x67,0xff,0x62,0x16,0xff,0x00,0xa2,0x31,
+0x2b,0x10,0xa2,0x02,0x1d,0x00,0x40,0x14,0xff,0x00,0xc2,0x31,0x2b,0x10,0xa2,0x02,
+0x0a,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0xfb,0x12,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x06,0x14,0x00,0x08,0x00,0x00,0x00,0x00,0x1d,0x43,0x42,0x91,0x00,0x00,0x00,0x00,
+0x2b,0x10,0x55,0x00,0xf8,0xff,0x40,0x10,0x00,0x00,0x00,0x00,0xc5,0x12,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x06,0x14,0x00,0x08,0x00,0x00,0x00,0x00,0x20,0x43,0x42,0x91,
+0x00,0x00,0x00,0x00,0x2b,0x10,0xa2,0x02,0xac,0xff,0x40,0x10,0x00,0x00,0x00,0x00,
+0x70,0x13,0x00,0x0c,0x00,0x00,0x00,0x00,0x06,0x14,0x00,0x08,0x00,0x00,0x00,0x00,
+0x2b,0x10,0xa2,0x02,0xe8,0xff,0x40,0x10,0x00,0x00,0x00,0x00,0x21,0x43,0x42,0x91,
+0x00,0x00,0x00,0x00,0x2b,0x10,0x55,0x00,0xa0,0xff,0x40,0x14,0x00,0x00,0x00,0x00,
+0x70,0x13,0x00,0x0c,0x00,0x00,0x00,0x00,0x06,0x14,0x00,0x08,0x00,0x00,0x00,0x00,
+0x02,0x80,0x08,0x3c,0x68,0x15,0x05,0x25,0xdc,0x63,0xa4,0x8c,0xe6,0x42,0xa3,0x90,
+0x02,0x11,0x04,0x00,0x1f,0x00,0x60,0x14,0x7f,0x00,0x46,0x30,0x25,0xb0,0x07,0x3c,
+0x4c,0x00,0xe2,0x34,0x00,0x00,0x43,0x90,0x00,0x00,0x00,0x00,0x19,0x00,0x60,0x10,
+0x00,0x00,0x00,0x00,0xff,0xff,0x02,0x34,0x16,0x00,0x82,0x10,0x00,0x00,0x00,0x00,
+0x00,0x08,0xe3,0x34,0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x30,
+0x12,0x00,0x40,0x10,0x4b,0x00,0xc2,0x2c,0x29,0x00,0x40,0x10,0x01,0x00,0x04,0x24,
+0xd8,0xff,0xc2,0x24,0x1e,0x00,0x42,0x2c,0x2f,0x00,0x40,0x10,0x23,0x00,0xc2,0x2c,
+0x68,0x15,0x04,0x25,0xd3,0x42,0x82,0x90,0x00,0x00,0x00,0x00,0x29,0x00,0x40,0x10,
+0x25,0xb0,0x02,0x3c,0x20,0x00,0x03,0x24,0x87,0x0c,0x42,0x34,0x00,0x00,0x43,0xa0,
+0xd3,0x42,0x80,0xa0,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x0f,0x00,0x40,0x10,
+0x01,0x00,0x04,0x24,0xd8,0xff,0xc2,0x24,0x1e,0x00,0x42,0x2c,0x2c,0x00,0x40,0x10,
+0x23,0x00,0xc2,0x2c,0x68,0x15,0x04,0x25,0xd3,0x42,0x82,0x90,0x00,0x00,0x00,0x00,
+0x26,0x00,0x40,0x10,0x25,0xb0,0x02,0x3c,0x44,0x00,0x03,0x24,0x30,0x0c,0x42,0x34,
+0x00,0x00,0x43,0xa0,0xed,0x14,0x00,0x08,0xd3,0x42,0x80,0xa0,0xd3,0x42,0xa2,0x90,
+0x00,0x00,0x00,0x00,0xef,0xff,0x44,0x10,0x30,0x0c,0xe3,0x34,0x43,0x00,0x02,0x24,
+0xd3,0x42,0xa4,0xa0,0x00,0x00,0x62,0xa0,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0xd3,0x42,0xa2,0x90,0x00,0x00,0x00,0x00,0xd5,0xff,0x44,0x10,0x87,0x0c,0xe3,0x34,
+0x10,0x00,0x02,0x24,0xd3,0x42,0xa4,0xa0,0x00,0x00,0x62,0xa0,0x06,0x15,0x00,0x08,
+0x00,0x00,0x00,0x00,0x23,0x00,0xc2,0x2c,0xda,0xff,0x40,0x10,0x00,0x00,0x00,0x00,
+0x68,0x15,0x04,0x25,0xd3,0x42,0x82,0x90,0x02,0x00,0x03,0x24,0xd5,0xff,0x43,0x10,
+0x00,0x00,0x00,0x00,0x25,0xb0,0x02,0x3c,0x87,0x0c,0x42,0x34,0xd3,0x42,0x83,0xa0,
+0x00,0x00,0x40,0xa0,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x23,0x00,0xc2,0x2c,
+0xcc,0xff,0x40,0x10,0x00,0x00,0x00,0x00,0x68,0x15,0x04,0x25,0xd3,0x42,0x82,0x90,
+0x02,0x00,0x03,0x24,0xc7,0xff,0x43,0x10,0x00,0x00,0x00,0x00,0x25,0xb0,0x02,0x3c,
+0xd3,0x42,0x83,0xa0,0x30,0x0c,0x42,0x34,0x42,0x00,0x03,0x24,0x00,0x00,0x43,0xa0,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x02,0x80,0x02,0x3c,0x68,0x15,0x45,0x24,
+0xd5,0x42,0xa3,0x90,0x02,0x00,0x02,0x24,0x03,0x00,0x62,0x10,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0xdc,0x63,0xa2,0x8c,0x25,0xb0,0x03,0x3c,
+0x0a,0x0a,0x68,0x34,0x02,0x11,0x02,0x00,0x7f,0x00,0x42,0x30,0x1a,0x00,0x44,0x2c,
+0x14,0x00,0x42,0x2c,0x01,0x0a,0x66,0x34,0x0b,0x00,0x40,0x14,0x2e,0x0a,0x67,0x34,
+0xf3,0xff,0x80,0x14,0x00,0x00,0x00,0x00,0xd4,0x42,0xa4,0x90,0x01,0x00,0x02,0x24,
+0x01,0x0a,0x67,0x34,0x0f,0x00,0x82,0x10,0x2e,0x0a,0x66,0x34,0xd4,0x42,0xa0,0xa0,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x40,0x00,0x02,0x24,0x00,0x00,0xc2,0xa0,
+0x01,0x00,0x03,0x24,0xdf,0xff,0x02,0x24,0xd4,0x42,0xa3,0xa0,0x00,0x00,0xe2,0xa0,
+0x03,0x00,0x03,0x24,0x21,0x10,0x00,0x00,0x00,0x00,0x03,0xa1,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x47,0x00,0x02,0x24,0x00,0x00,0xe2,0xa0,0xd3,0xff,0x03,0x24,
+0x83,0xff,0x02,0x24,0x00,0x00,0xc3,0xa0,0x00,0x00,0x02,0xa1,0x48,0x15,0x00,0x08,
+0xd4,0x42,0xa0,0xa0,0xd0,0xff,0xbd,0x27,0x1c,0x00,0xb1,0xaf,0x28,0x00,0xbf,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x18,0x00,0xb0,0xaf,0xff,0xff,0x11,0x24,
+0x02,0x80,0x13,0x3c,0x41,0xb0,0x02,0x3c,0x68,0x15,0x66,0x26,0x04,0x00,0x42,0x34,
+0x00,0x00,0x47,0x8c,0x00,0x4b,0xc5,0x8c,0x02,0x80,0x03,0x3c,0x96,0x7d,0x64,0x90,
+0xfc,0x4a,0xc8,0x8c,0x02,0x80,0x02,0x3c,0xb8,0x7d,0x49,0x90,0x25,0xb0,0x0a,0x3c,
+0x25,0x90,0xa7,0x00,0xb0,0x03,0x42,0x35,0x00,0x00,0x52,0xac,0x00,0x24,0x04,0x00,
+0x00,0x00,0x48,0xac,0x84,0x02,0x43,0x35,0x8c,0x02,0x45,0x35,0x01,0x00,0x02,0x24,
+0x00,0x00,0x72,0xac,0x00,0x00,0xa4,0xac,0xb9,0x04,0x22,0x11,0x00,0x4b,0xd2,0xac,
+0x68,0x15,0x66,0x26,0xfc,0x4a,0xc2,0x8c,0x00,0x00,0x00,0x00,0x24,0x28,0x52,0x00,
+0x01,0x00,0xa3,0x30,0x09,0x00,0x60,0x10,0x04,0x00,0xa2,0x30,0x00,0x4b,0xc2,0x8c,
+0x25,0xb0,0x03,0x3c,0x01,0x00,0x04,0x24,0x01,0x00,0x42,0x38,0xb0,0x03,0x63,0x34,
+0x00,0x00,0x64,0xac,0x00,0x4b,0xc2,0xac,0x04,0x00,0xa2,0x30,0x09,0x00,0x40,0x10,
+0x08,0x00,0xa2,0x30,0x00,0x4b,0xc2,0x8c,0x25,0xb0,0x03,0x3c,0x04,0x00,0x04,0x24,
+0x04,0x00,0x42,0x38,0xb0,0x03,0x63,0x34,0x00,0x00,0x64,0xac,0x00,0x4b,0xc2,0xac,
+0x08,0x00,0xa2,0x30,0x0e,0x00,0x40,0x10,0x68,0x15,0x64,0x26,0xc9,0x64,0xc2,0x90,
+0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x18,0x2a,0xb0,0x02,0x3c,0x02,0x00,0x03,0x24,
+0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0xc9,0x64,0xc0,0xa0,0x00,0x4b,0xc2,0x8c,
+0x00,0x00,0x00,0x00,0x08,0x00,0x42,0x38,0x00,0x4b,0xc2,0xac,0x68,0x15,0x64,0x26,
+0xfc,0x4a,0x82,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,0x10,0x00,0x42,0x30,
+0x0d,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0xc9,0x64,0x82,0x90,0x00,0x00,0x00,0x00,
+0x05,0x00,0x40,0x18,0x2a,0xb0,0x02,0x3c,0x02,0x00,0x03,0x24,0x01,0x00,0x42,0x34,
+0x00,0x00,0x43,0xa0,0xc9,0x64,0x80,0xa0,0x00,0x4b,0x82,0x8c,0x00,0x00,0x00,0x00,
+0x10,0x00,0x42,0x38,0x00,0x4b,0x82,0xac,0x68,0x15,0x64,0x26,0xfc,0x4a,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,0x20,0x00,0x42,0x30,0x0e,0x00,0x40,0x10,
+0x00,0x00,0x00,0x00,0xc9,0x64,0x82,0x90,0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x18,
+0x2a,0xb0,0x02,0x3c,0x02,0x00,0x03,0x24,0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,
+0xc9,0x64,0x80,0xa0,0x00,0x4b,0x82,0x8c,0x00,0x00,0x00,0x00,0x20,0x00,0x42,0x38,
+0x00,0x4b,0x82,0xac,0x68,0x15,0x64,0x26,0xfc,0x4a,0x82,0x8c,0x00,0x00,0x00,0x00,
+0x24,0x10,0x52,0x00,0x40,0x00,0x42,0x30,0x0d,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0xc9,0x64,0x82,0x90,0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x18,0x2a,0xb0,0x02,0x3c,
+0x02,0x00,0x03,0x24,0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0xc9,0x64,0x80,0xa0,
+0x00,0x4b,0x82,0x8c,0x00,0x00,0x00,0x00,0x40,0x00,0x42,0x38,0x00,0x4b,0x82,0xac,
+0x68,0x15,0x64,0x26,0xfc,0x4a,0x82,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,
+0x80,0x00,0x42,0x30,0x0e,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0xc9,0x64,0x82,0x90,
+0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x18,0x2a,0xb0,0x02,0x3c,0x02,0x00,0x03,0x24,
+0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0xc9,0x64,0x80,0xa0,0x00,0x4b,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x80,0x00,0x42,0x38,0x00,0x4b,0x82,0xac,0x68,0x15,0x64,0x26,
+0xfc,0x4a,0x82,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,0x00,0x01,0x42,0x30,
+0x0d,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0xc9,0x64,0x82,0x90,0x00,0x00,0x00,0x00,
+0x05,0x00,0x40,0x18,0x2a,0xb0,0x02,0x3c,0x02,0x00,0x03,0x24,0x01,0x00,0x42,0x34,
+0x00,0x00,0x43,0xa0,0xc9,0x64,0x80,0xa0,0x00,0x4b,0x82,0x8c,0x00,0x00,0x00,0x00,
+0x00,0x01,0x42,0x38,0x00,0x4b,0x82,0xac,0x68,0x15,0x64,0x26,0xfc,0x4a,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,0x00,0x02,0x42,0x30,0x0e,0x00,0x40,0x10,
+0x00,0x00,0x00,0x00,0xc9,0x64,0x82,0x90,0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x18,
+0x2a,0xb0,0x02,0x3c,0x02,0x00,0x03,0x24,0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,
+0xc9,0x64,0x80,0xa0,0x00,0x4b,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x02,0x42,0x38,
+0x00,0x4b,0x82,0xac,0x68,0x15,0x64,0x26,0xfc,0x4a,0x82,0x8c,0x00,0x00,0x00,0x00,
+0x24,0x10,0x52,0x00,0x00,0x04,0x42,0x30,0x0d,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0xc9,0x64,0x82,0x90,0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x18,0x2a,0xb0,0x02,0x3c,
+0x02,0x00,0x03,0x24,0x01,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0xc9,0x64,0x80,0xa0,
+0x00,0x4b,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x04,0x42,0x38,0x00,0x4b,0x82,0xac,
+0x68,0x15,0x63,0x26,0xfc,0x4a,0x62,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,
+0x00,0x08,0x42,0x30,0x3a,0x00,0x40,0x10,0x2a,0xb0,0x05,0x3c,0x00,0x00,0xa8,0x8c,
+0xff,0x00,0x02,0x24,0xff,0x00,0x04,0x31,0x31,0x00,0x82,0x10,0x00,0x80,0x02,0x31,
+0x08,0x04,0x40,0x14,0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,
+0x05,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0xc9,0x64,0x62,0x90,0x00,0x00,0x00,0x00,
+0x0b,0x00,0x40,0x18,0xff,0x00,0x02,0x24,0x08,0x64,0x62,0x90,0x20,0xb0,0x03,0x3c,
+0x00,0x12,0x02,0x00,0x21,0x10,0x43,0x00,0x0c,0x00,0x48,0x8c,0x25,0xb0,0x03,0x3c,
+0xb0,0x03,0x63,0x34,0x00,0x00,0x68,0xac,0xff,0x00,0x04,0x31,0xff,0x00,0x02,0x24,
+0x1a,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,0xc0,0x64,0x05,0x8e,
+0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,0x21,0x30,0x60,0x00,
+0x54,0x64,0x03,0xae,0x21,0x20,0x00,0x00,0x08,0x64,0x08,0xa2,0x20,0x00,0x07,0x24,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0xfc,0x4a,0x05,0x8e,0x02,0x80,0x06,0x3c,
+0x6c,0x7e,0xc4,0x8c,0xff,0xc7,0x02,0x24,0x24,0x28,0xa2,0x00,0x25,0xb0,0x02,0x3c,
+0x04,0x00,0x84,0x34,0x80,0x03,0x42,0x34,0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,
+0x00,0x00,0x65,0xac,0x6c,0x7e,0xc4,0xac,0xfc,0x4a,0x05,0xae,0x68,0x15,0x63,0x26,
+0x00,0x4b,0x62,0x8c,0x00,0x00,0x00,0x00,0x00,0x08,0x42,0x38,0x00,0x4b,0x62,0xac,
+0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,
+0x00,0x10,0x42,0x30,0x38,0x00,0x40,0x10,0x2a,0xb0,0x02,0x3c,0x08,0x00,0x43,0x34,
+0x00,0x00,0x68,0x8c,0xff,0x00,0x02,0x24,0xff,0x00,0x04,0x31,0x2c,0x00,0x82,0x10,
+0x00,0x80,0x02,0x31,0xca,0x03,0x40,0x14,0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,
+0x24,0x10,0x02,0x01,0x0b,0x00,0x40,0x10,0xff,0x00,0x02,0x24,0x10,0x64,0xa2,0x90,
+0x20,0xb0,0x03,0x3c,0x00,0x12,0x02,0x00,0x21,0x10,0x43,0x00,0x0c,0x00,0x48,0x8c,
+0x25,0xb0,0x03,0x3c,0xb0,0x03,0x63,0x34,0x00,0x00,0x68,0xac,0xff,0x00,0x04,0x31,
+0xff,0x00,0x02,0x24,0x1a,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,
+0xd8,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x21,0x30,0x60,0x00,0x6c,0x64,0x03,0xae,0x01,0x00,0x04,0x24,0x10,0x64,0x08,0xa2,
+0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0xfc,0x4a,0x05,0x8e,
+0x02,0x80,0x06,0x3c,0x6c,0x7e,0xc4,0x8c,0xff,0xc7,0x02,0x24,0x24,0x28,0xa2,0x00,
+0x25,0xb0,0x02,0x3c,0x10,0x00,0x84,0x34,0x80,0x03,0x42,0x34,0x41,0xb0,0x03,0x3c,
+0x00,0x00,0x44,0xac,0x00,0x00,0x65,0xac,0x6c,0x7e,0xc4,0xac,0xfc,0x4a,0x05,0xae,
+0x68,0x15,0x63,0x26,0x00,0x4b,0x62,0x8c,0x00,0x00,0x00,0x00,0x00,0x10,0x42,0x38,
+0x00,0x4b,0x62,0xac,0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x00,0x00,0x00,0x00,
+0x24,0x10,0x52,0x00,0x00,0x20,0x42,0x30,0x37,0x00,0x40,0x10,0x2a,0xb0,0x02,0x3c,
+0x04,0x00,0x43,0x34,0x00,0x00,0x68,0x8c,0xff,0x00,0x02,0x24,0xff,0x00,0x04,0x31,
+0xab,0x03,0x82,0x10,0x00,0x80,0x02,0x31,0x90,0x03,0x40,0x14,0x00,0x80,0x02,0x3c,
+0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x0b,0x00,0x40,0x10,0xff,0x00,0x02,0x24,
+0x0c,0x64,0xa2,0x90,0x20,0xb0,0x03,0x3c,0x00,0x12,0x02,0x00,0x21,0x10,0x43,0x00,
+0x0c,0x00,0x48,0x8c,0x25,0xb0,0x03,0x3c,0xb0,0x03,0x63,0x34,0x00,0x00,0x68,0xac,
+0xff,0x00,0x04,0x31,0xff,0x00,0x02,0x24,0x1a,0x00,0x82,0x10,0xff,0x00,0x03,0x31,
+0x68,0x15,0x70,0x26,0xcc,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,
+0x21,0x18,0x62,0x00,0x21,0x30,0x60,0x00,0x60,0x64,0x03,0xae,0x01,0x00,0x04,0x24,
+0x0c,0x64,0x08,0xa2,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0xfc,0x4a,0x05,0x8e,0x02,0x80,0x06,0x3c,0x6c,0x7e,0xc4,0x8c,0xff,0xc7,0x02,0x24,
+0x24,0x28,0xa2,0x00,0x25,0xb0,0x02,0x3c,0x20,0x00,0x84,0x34,0x80,0x03,0x42,0x34,
+0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,0x00,0x00,0x65,0xac,0x6c,0x7e,0xc4,0xac,
+0xfc,0x4a,0x05,0xae,0x68,0x15,0x63,0x26,0x00,0x4b,0x62,0x8c,0x00,0x00,0x00,0x00,
+0x00,0x20,0x42,0x38,0x00,0x4b,0x62,0xac,0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,
+0x00,0x00,0x00,0x00,0x24,0x10,0x52,0x00,0x00,0x80,0x42,0x30,0x59,0x00,0x40,0x10,
+0x2a,0xb0,0x06,0x3c,0x0c,0x00,0xc3,0x34,0x00,0x00,0x68,0x8c,0xff,0x00,0x07,0x24,
+0xff,0x00,0x04,0x31,0x78,0x03,0x87,0x10,0x00,0x80,0x02,0x31,0x24,0x00,0x40,0x14,
+0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x22,0x00,0x40,0x10,
+0xff,0x00,0x02,0x24,0x40,0x00,0xc6,0x34,0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
+0xff,0x00,0x44,0x30,0x0f,0x00,0x87,0x10,0x68,0x15,0x62,0x26,0xe8,0x63,0xa4,0xa0,
+0x00,0x00,0xc2,0x90,0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,0x09,0x00,0x83,0x10,
+0x68,0x15,0x62,0x26,0x21,0x38,0xa0,0x00,0x21,0x28,0xc0,0x00,0x00,0x00,0xa2,0x90,
+0x21,0x18,0x80,0x00,0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,0xe8,0x63,0xe3,0xa0,
+0x68,0x15,0x62,0x26,0xe8,0x63,0x43,0x90,0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,
+0x21,0x18,0x62,0x00,0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,
+0xff,0x00,0x04,0x31,0x00,0x00,0x48,0xac,0x16,0x17,0x00,0x08,0xff,0x00,0x02,0x24,
+0x00,0x00,0x62,0xac,0xff,0x00,0x02,0x24,0x24,0x00,0x82,0x10,0x68,0x15,0x70,0x26,
+0xff,0x00,0x03,0x31,0x90,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,
+0x21,0x18,0x62,0x00,0x21,0x30,0x60,0x00,0xe8,0x63,0x08,0xa2,0x24,0x64,0x03,0xae,
+0x03,0x00,0x04,0x24,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0x02,0x80,0x0a,0x3c,0x7c,0x7e,0x47,0x91,0x02,0x80,0x09,0x3c,0x6c,0x7e,0x25,0x8d,
+0xfc,0x4a,0x06,0x8e,0x01,0x00,0x08,0x3c,0x80,0xff,0x02,0x24,0x25,0x38,0xe2,0x00,
+0x00,0x80,0x03,0x35,0x80,0x00,0xa5,0x34,0x27,0x18,0x03,0x00,0x00,0x26,0x07,0x00,
+0x25,0xb0,0x02,0x3c,0x24,0x30,0xc3,0x00,0x25,0x20,0x85,0x00,0x80,0x03,0x42,0x34,
+0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,0x27,0x88,0x08,0x00,0x00,0x00,0x66,0xac,
+0x6c,0x7e,0x25,0xad,0x7c,0x7e,0x47,0xa1,0xfc,0x4a,0x06,0xae,0x68,0x15,0x63,0x26,
+0x00,0x4b,0x62,0x8c,0x00,0x00,0x00,0x00,0x00,0x80,0x42,0x38,0x00,0x4b,0x62,0xac,
+0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x01,0x00,0x03,0x3c,0x24,0x10,0x52,0x00,
+0x24,0x10,0x51,0x00,0x24,0x10,0x43,0x00,0x56,0x00,0x40,0x10,0x2a,0xb0,0x06,0x3c,
+0x10,0x00,0xc3,0x34,0x00,0x00,0x68,0x8c,0xff,0x00,0x07,0x24,0xff,0x00,0x04,0x31,
+0x23,0x03,0x87,0x10,0x25,0xb0,0x02,0x3c,0x00,0x80,0x02,0x31,0x23,0x00,0x40,0x14,
+0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x21,0x00,0x40,0x10,
+0xff,0x00,0x02,0x24,0x41,0x00,0xc6,0x34,0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
+0xff,0x00,0x44,0x30,0x0e,0x00,0x87,0x10,0x68,0x15,0x62,0x26,0xec,0x63,0xa4,0xa0,
+0x00,0x00,0xc2,0x90,0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,0x07,0x00,0x83,0x10,
+0x21,0x38,0xa0,0x00,0x21,0x28,0xc0,0x00,0x00,0x00,0xa2,0x90,0x21,0x18,0x80,0x00,
+0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,0xec,0x63,0xe3,0xa0,0x68,0x15,0x62,0x26,
+0xec,0x63,0x43,0x90,0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,0xff,0x00,0x04,0x31,
+0x00,0x00,0x48,0xac,0x75,0x17,0x00,0x08,0xff,0x00,0x02,0x24,0x00,0x00,0x62,0xac,
+0xff,0x00,0x02,0x24,0x22,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,
+0x90,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x21,0x30,0x60,0x00,0xec,0x63,0x08,0xa2,0x24,0x64,0x03,0xae,0x03,0x00,0x04,0x24,
+0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x02,0x80,0x09,0x3c,
+0x7c,0x7e,0x27,0x91,0x02,0x80,0x08,0x3c,0x6c,0x7e,0x05,0x8d,0xfc,0x4a,0x06,0x8e,
+0x01,0x00,0x02,0x3c,0x00,0x80,0x42,0x34,0x40,0x00,0xe7,0x34,0x27,0x10,0x02,0x00,
+0x24,0x30,0xc2,0x00,0x80,0x00,0xa5,0x34,0x00,0x26,0x07,0x00,0x25,0xb0,0x02,0x3c,
+0x25,0x20,0x85,0x00,0x80,0x03,0x42,0x34,0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,
+0x00,0x00,0x66,0xac,0x6c,0x7e,0x05,0xad,0x7c,0x7e,0x27,0xa1,0xfc,0x4a,0x06,0xae,
+0x68,0x15,0x62,0x26,0x00,0x4b,0x43,0x8c,0x01,0x00,0x04,0x3c,0x26,0x18,0x64,0x00,
+0x00,0x4b,0x43,0xac,0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x02,0x00,0x03,0x3c,
+0x24,0x10,0x52,0x00,0x24,0x10,0x43,0x00,0x5a,0x00,0x40,0x10,0x2a,0xb0,0x06,0x3c,
+0x14,0x00,0xc3,0x34,0x00,0x00,0x68,0x8c,0xff,0x00,0x07,0x24,0xff,0x00,0x04,0x31,
+0xcc,0x02,0x87,0x10,0x25,0xb0,0x02,0x3c,0x00,0x80,0x02,0x31,0x23,0x00,0x40,0x14,
+0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x21,0x00,0x40,0x10,
+0xff,0x00,0x02,0x24,0x42,0x00,0xc6,0x34,0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
+0xff,0x00,0x44,0x30,0x0e,0x00,0x87,0x10,0x68,0x15,0x62,0x26,0xf0,0x63,0xa4,0xa0,
+0x00,0x00,0xc2,0x90,0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,0x07,0x00,0x83,0x10,
+0x21,0x38,0xa0,0x00,0x21,0x28,0xc0,0x00,0x00,0x00,0xa2,0x90,0x21,0x18,0x80,0x00,
+0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,0xf0,0x63,0xe3,0xa0,0x68,0x15,0x62,0x26,
+0xf0,0x63,0x43,0x90,0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,0xff,0x00,0x04,0x31,
+0x00,0x00,0x48,0xac,0xd1,0x17,0x00,0x08,0xff,0x00,0x02,0x24,0x00,0x00,0x62,0xac,
+0xff,0x00,0x02,0x24,0x25,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,
+0x9c,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x21,0x30,0x60,0x00,0xf0,0x63,0x08,0xa2,0x30,0x64,0x03,0xae,0x04,0x00,0x04,0x24,
+0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x02,0x80,0x0a,0x3c,
+0x7c,0x7e,0x47,0x91,0x02,0x80,0x09,0x3c,0x6c,0x7e,0x25,0x8d,0xfc,0x4a,0x06,0x8e,
+0x06,0x00,0x02,0x3c,0x20,0x00,0xe7,0x34,0x27,0x10,0x02,0x00,0x24,0x30,0xc2,0x00,
+0x00,0x01,0xa5,0x34,0x25,0xb0,0x03,0x3c,0x04,0x00,0x02,0x3c,0x00,0x26,0x07,0x00,
+0x26,0x88,0x22,0x02,0xb0,0x03,0x68,0x34,0x25,0x20,0x85,0x00,0x80,0x03,0x63,0x34,
+0x41,0xb0,0x02,0x3c,0x00,0x00,0x64,0xac,0x00,0x00,0x46,0xac,0x6c,0x7e,0x25,0xad,
+0x7c,0x7e,0x47,0xa1,0xfc,0x4a,0x06,0xae,0x00,0x00,0x11,0xad,0x68,0x15,0x62,0x26,
+0x00,0x4b,0x43,0x8c,0x02,0x00,0x04,0x3c,0x26,0x18,0x64,0x00,0x00,0x4b,0x43,0xac,
+0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x04,0x00,0x03,0x3c,0x24,0x10,0x52,0x00,
+0x24,0x10,0x51,0x00,0x24,0x10,0x43,0x00,0x58,0x00,0x40,0x10,0x25,0xb0,0x03,0x3c,
+0xb0,0x03,0x62,0x34,0x2a,0xb0,0x09,0x3c,0x00,0x00,0x51,0xac,0x18,0x00,0x26,0x35,
+0x00,0x00,0xc8,0x8c,0xff,0x00,0x07,0x24,0xff,0x00,0x04,0x31,0x3a,0x02,0x87,0x10,
+0x04,0x00,0x02,0x24,0x00,0x80,0x02,0x31,0x23,0x00,0x40,0x14,0x00,0x80,0x02,0x3c,
+0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x21,0x00,0x40,0x10,0xff,0x00,0x02,0x24,
+0x43,0x00,0x26,0x35,0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,0xff,0x00,0x44,0x30,
+0x0e,0x00,0x87,0x10,0x68,0x15,0x62,0x26,0xf4,0x63,0xa4,0xa0,0x00,0x00,0xc2,0x90,
+0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,0x07,0x00,0x83,0x10,0x21,0x38,0xa0,0x00,
+0x21,0x28,0xc0,0x00,0x00,0x00,0xa2,0x90,0x21,0x18,0x80,0x00,0xfd,0xff,0x62,0x14,
+0xff,0x00,0x44,0x30,0xf4,0x63,0xe3,0xa0,0x68,0x15,0x62,0x26,0xf4,0x63,0x43,0x90,
+0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,0x0c,0x00,0x68,0x8c,
+0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,0xff,0x00,0x04,0x31,0x00,0x00,0x48,0xac,
+0x34,0x18,0x00,0x08,0xff,0x00,0x02,0x24,0x00,0x00,0xc2,0xac,0xff,0x00,0x02,0x24,
+0x21,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,0x9c,0x64,0x05,0x8e,
+0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,0x21,0x30,0x60,0x00,
+0xf4,0x63,0x08,0xa2,0x30,0x64,0x03,0xae,0x04,0x00,0x04,0x24,0x20,0x00,0x07,0x24,
+0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x02,0x80,0x09,0x3c,0x7c,0x7e,0x27,0x91,
+0x02,0x80,0x08,0x3c,0x6c,0x7e,0x05,0x8d,0xfc,0x4a,0x06,0x8e,0x06,0x00,0x02,0x3c,
+0x10,0x00,0xe7,0x34,0x27,0x10,0x02,0x00,0x24,0x30,0xc2,0x00,0x00,0x01,0xa5,0x34,
+0x00,0x26,0x07,0x00,0x25,0xb0,0x02,0x3c,0x25,0x20,0x85,0x00,0x80,0x03,0x42,0x34,
+0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,0x00,0x00,0x66,0xac,0x6c,0x7e,0x05,0xad,
+0x7c,0x7e,0x27,0xa1,0xfc,0x4a,0x06,0xae,0x68,0x15,0x62,0x26,0x00,0x4b,0x43,0x8c,
+0x04,0x00,0x04,0x3c,0x26,0x18,0x64,0x00,0x00,0x4b,0x43,0xac,0x68,0x15,0x65,0x26,
+0xfc,0x4a,0xa2,0x8c,0x08,0x00,0x03,0x3c,0x24,0x10,0x52,0x00,0x24,0x10,0x43,0x00,
+0x5a,0x00,0x40,0x10,0x2a,0xb0,0x06,0x3c,0x1c,0x00,0xc3,0x34,0x00,0x00,0x68,0x8c,
+0xff,0x00,0x07,0x24,0xff,0x00,0x04,0x31,0x13,0x02,0x87,0x10,0x25,0xb0,0x02,0x3c,
+0x00,0x80,0x02,0x31,0x23,0x00,0x40,0x14,0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,
+0x24,0x10,0x02,0x01,0x21,0x00,0x40,0x10,0xff,0x00,0x02,0x24,0x44,0x00,0xc6,0x34,
+0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,0xff,0x00,0x44,0x30,0x0e,0x00,0x87,0x10,
+0x68,0x15,0x62,0x26,0xf8,0x63,0xa4,0xa0,0x00,0x00,0xc2,0x90,0xff,0x00,0x83,0x30,
+0xff,0x00,0x44,0x30,0x07,0x00,0x83,0x10,0x21,0x38,0xa0,0x00,0x21,0x28,0xc0,0x00,
+0x00,0x00,0xa2,0x90,0x21,0x18,0x80,0x00,0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,
+0xf8,0x63,0xe3,0xa0,0x68,0x15,0x62,0x26,0xf8,0x63,0x43,0x90,0x20,0xb0,0x02,0x3c,
+0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,
+0xb0,0x03,0x42,0x34,0xff,0x00,0x04,0x31,0x00,0x00,0x48,0xac,0x8f,0x18,0x00,0x08,
+0xff,0x00,0x02,0x24,0x00,0x00,0x62,0xac,0xff,0x00,0x02,0x24,0x25,0x00,0x82,0x10,
+0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,0xa8,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,
+0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,0x21,0x30,0x60,0x00,0xf8,0x63,0x08,0xa2,
+0x3c,0x64,0x03,0xae,0x05,0x00,0x04,0x24,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,
+0x10,0x00,0xa0,0xaf,0x02,0x80,0x0a,0x3c,0x7c,0x7e,0x47,0x91,0x02,0x80,0x09,0x3c,
+0x6c,0x7e,0x25,0x8d,0xfc,0x4a,0x06,0x8e,0x18,0x00,0x02,0x3c,0x08,0x00,0xe7,0x34,
+0x27,0x10,0x02,0x00,0x24,0x30,0xc2,0x00,0x00,0x02,0xa5,0x34,0x25,0xb0,0x03,0x3c,
+0x10,0x00,0x02,0x3c,0x00,0x26,0x07,0x00,0x26,0x88,0x22,0x02,0xb0,0x03,0x68,0x34,
+0x25,0x20,0x85,0x00,0x80,0x03,0x63,0x34,0x41,0xb0,0x02,0x3c,0x00,0x00,0x64,0xac,
+0x00,0x00,0x46,0xac,0x6c,0x7e,0x25,0xad,0x7c,0x7e,0x47,0xa1,0xfc,0x4a,0x06,0xae,
+0x00,0x00,0x11,0xad,0x68,0x15,0x62,0x26,0x00,0x4b,0x43,0x8c,0x08,0x00,0x04,0x3c,
+0x26,0x18,0x64,0x00,0x00,0x4b,0x43,0xac,0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,
+0x10,0x00,0x03,0x3c,0x24,0x10,0x52,0x00,0x24,0x10,0x51,0x00,0x24,0x10,0x43,0x00,
+0x58,0x00,0x40,0x10,0x25,0xb0,0x06,0x3c,0xb0,0x03,0xc2,0x34,0x2a,0xb0,0x09,0x3c,
+0x00,0x00,0x51,0xac,0x20,0x00,0x23,0x35,0x00,0x00,0x68,0x8c,0xff,0x00,0x07,0x24,
+0xff,0x00,0x04,0x31,0x80,0x01,0x87,0x10,0x90,0x03,0xc2,0x34,0x00,0x80,0x02,0x31,
+0x23,0x00,0x40,0x14,0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,
+0x21,0x00,0x40,0x10,0xff,0x00,0x02,0x24,0x45,0x00,0x26,0x35,0x00,0x00,0xc2,0x90,
+0x00,0x00,0x00,0x00,0xff,0x00,0x44,0x30,0x0e,0x00,0x87,0x10,0x68,0x15,0x62,0x26,
+0x04,0x64,0xa4,0xa0,0x00,0x00,0xc2,0x90,0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,
+0x07,0x00,0x83,0x10,0x21,0x38,0xa0,0x00,0x21,0x28,0xc0,0x00,0x00,0x00,0xa2,0x90,
+0x21,0x18,0x80,0x00,0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,0x04,0x64,0xe3,0xa0,
+0x68,0x15,0x62,0x26,0x04,0x64,0x43,0x90,0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,
+0x21,0x18,0x62,0x00,0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,
+0xff,0x00,0x04,0x31,0x00,0x00,0x48,0xac,0xf2,0x18,0x00,0x08,0xff,0x00,0x02,0x24,
+0x00,0x00,0x62,0xac,0xff,0x00,0x02,0x24,0x21,0x00,0x82,0x10,0x68,0x15,0x70,0x26,
+0xff,0x00,0x03,0x31,0xa8,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,
+0x21,0x18,0x62,0x00,0x21,0x30,0x60,0x00,0x04,0x64,0x08,0xa2,0x3c,0x64,0x03,0xae,
+0x05,0x00,0x04,0x24,0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,
+0x02,0x80,0x09,0x3c,0x7c,0x7e,0x27,0x91,0x02,0x80,0x08,0x3c,0x6c,0x7e,0x05,0x8d,
+0xfc,0x4a,0x06,0x8e,0x18,0x00,0x02,0x3c,0x01,0x00,0xe7,0x34,0x27,0x10,0x02,0x00,
+0x24,0x30,0xc2,0x00,0x00,0x02,0xa5,0x34,0x00,0x26,0x07,0x00,0x25,0xb0,0x02,0x3c,
+0x25,0x20,0x85,0x00,0x80,0x03,0x42,0x34,0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,
+0x00,0x00,0x66,0xac,0x6c,0x7e,0x05,0xad,0x7c,0x7e,0x27,0xa1,0xfc,0x4a,0x06,0xae,
+0x68,0x15,0x62,0x26,0x00,0x4b,0x43,0x8c,0x10,0x00,0x04,0x3c,0x26,0x18,0x64,0x00,
+0x00,0x4b,0x43,0xac,0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x20,0x00,0x03,0x3c,
+0x24,0x10,0x52,0x00,0x24,0x10,0x43,0x00,0x5a,0x00,0x40,0x10,0x2a,0xb0,0x06,0x3c,
+0x24,0x00,0xc3,0x34,0x00,0x00,0x68,0x8c,0xff,0x00,0x07,0x24,0xff,0x00,0x04,0x31,
+0x28,0x01,0x87,0x10,0x25,0xb0,0x02,0x3c,0x00,0x80,0x02,0x31,0x23,0x00,0x40,0x14,
+0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x21,0x00,0x40,0x10,
+0xff,0x00,0x02,0x24,0x46,0x00,0xc6,0x34,0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
+0xff,0x00,0x44,0x30,0x0e,0x00,0x87,0x10,0x68,0x15,0x62,0x26,0xfc,0x63,0xa4,0xa0,
+0x00,0x00,0xc2,0x90,0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,0x07,0x00,0x83,0x10,
+0x21,0x38,0xa0,0x00,0x21,0x28,0xc0,0x00,0x00,0x00,0xa2,0x90,0x21,0x18,0x80,0x00,
+0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,0xfc,0x63,0xe3,0xa0,0x68,0x15,0x62,0x26,
+0xfc,0x63,0x43,0x90,0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,0xff,0x00,0x04,0x31,
+0x00,0x00,0x48,0xac,0x4d,0x19,0x00,0x08,0xff,0x00,0x02,0x24,0x00,0x00,0x62,0xac,
+0xff,0x00,0x02,0x24,0x25,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,
+0xb4,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x21,0x30,0x60,0x00,0xfc,0x63,0x08,0xa2,0x48,0x64,0x03,0xae,0x06,0x00,0x04,0x24,
+0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x02,0x80,0x0a,0x3c,
+0x7c,0x7e,0x47,0x91,0x02,0x80,0x09,0x3c,0x6c,0x7e,0x25,0x8d,0xfc,0x4a,0x06,0x8e,
+0x60,0x00,0x02,0x3c,0x04,0x00,0xe7,0x34,0x27,0x10,0x02,0x00,0x24,0x30,0xc2,0x00,
+0x00,0x04,0xa5,0x34,0x25,0xb0,0x03,0x3c,0x40,0x00,0x02,0x3c,0x00,0x26,0x07,0x00,
+0x26,0x88,0x22,0x02,0xb0,0x03,0x68,0x34,0x25,0x20,0x85,0x00,0x80,0x03,0x63,0x34,
+0x41,0xb0,0x02,0x3c,0x00,0x00,0x64,0xac,0x00,0x00,0x46,0xac,0x6c,0x7e,0x25,0xad,
+0x7c,0x7e,0x47,0xa1,0xfc,0x4a,0x06,0xae,0x00,0x00,0x11,0xad,0x68,0x15,0x62,0x26,
+0x00,0x4b,0x43,0x8c,0x20,0x00,0x04,0x3c,0x26,0x18,0x64,0x00,0x00,0x4b,0x43,0xac,
+0x68,0x15,0x65,0x26,0xfc,0x4a,0xa2,0x8c,0x40,0x00,0x03,0x3c,0x24,0x10,0x52,0x00,
+0x24,0x10,0x51,0x00,0x24,0x10,0x43,0x00,0x5a,0x00,0x40,0x10,0x68,0x15,0x70,0x26,
+0x25,0xb0,0x02,0x3c,0x2a,0xb0,0x07,0x3c,0xb0,0x03,0x42,0x34,0x00,0x00,0x51,0xac,
+0x28,0x00,0xe3,0x34,0x00,0x00,0x68,0x8c,0xff,0x00,0x06,0x24,0xff,0x00,0x04,0x31,
+0xc9,0x00,0x86,0x10,0x25,0xbd,0x02,0x3c,0x00,0x80,0x02,0x31,0x23,0x00,0x40,0x14,
+0x00,0x80,0x02,0x3c,0x00,0xff,0x02,0x3c,0x24,0x10,0x02,0x01,0x21,0x00,0x40,0x10,
+0xff,0x00,0x02,0x24,0x47,0x00,0xe7,0x34,0x00,0x00,0xe2,0x90,0x00,0x00,0x00,0x00,
+0xff,0x00,0x44,0x30,0x0e,0x00,0x86,0x10,0x68,0x15,0x62,0x26,0x00,0x64,0xa4,0xa0,
+0x00,0x00,0xe2,0x90,0xff,0x00,0x83,0x30,0xff,0x00,0x44,0x30,0x07,0x00,0x83,0x10,
+0x21,0x30,0xa0,0x00,0x21,0x28,0xe0,0x00,0x00,0x00,0xa2,0x90,0x21,0x18,0x80,0x00,
+0xfd,0xff,0x62,0x14,0xff,0x00,0x44,0x30,0x00,0x64,0xc3,0xa0,0x68,0x15,0x62,0x26,
+0x00,0x64,0x43,0x90,0x20,0xb0,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x0c,0x00,0x68,0x8c,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,0xff,0x00,0x04,0x31,
+0x00,0x00,0x48,0xac,0xb1,0x19,0x00,0x08,0xff,0x00,0x02,0x24,0x00,0x00,0x62,0xac,
+0xff,0x00,0x02,0x24,0x21,0x00,0x82,0x10,0x68,0x15,0x70,0x26,0xff,0x00,0x03,0x31,
+0xb4,0x64,0x05,0x8e,0x20,0x10,0x02,0x3c,0x00,0x1a,0x03,0x00,0x21,0x18,0x62,0x00,
+0x21,0x30,0x60,0x00,0x00,0x64,0x08,0xa2,0x48,0x64,0x03,0xae,0x06,0x00,0x04,0x24,
+0x20,0x00,0x07,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x02,0x80,0x09,0x3c,
+0x7c,0x7e,0x27,0x91,0x02,0x80,0x08,0x3c,0x6c,0x7e,0x05,0x8d,0xfc,0x4a,0x06,0x8e,
+0x60,0x00,0x02,0x3c,0x02,0x00,0xe7,0x34,0x27,0x10,0x02,0x00,0x24,0x30,0xc2,0x00,
+0x00,0x04,0xa5,0x34,0x00,0x26,0x07,0x00,0x25,0xb0,0x02,0x3c,0x25,0x20,0x85,0x00,
+0x80,0x03,0x42,0x34,0x41,0xb0,0x03,0x3c,0x00,0x00,0x44,0xac,0x00,0x00,0x66,0xac,
+0x6c,0x7e,0x05,0xad,0x7c,0x7e,0x27,0xa1,0xfc,0x4a,0x06,0xae,0x68,0x15,0x62,0x26,
+0x00,0x4b,0x43,0x8c,0x40,0x00,0x04,0x3c,0x26,0x18,0x64,0x00,0x00,0x4b,0x43,0xac,
+0x68,0x15,0x70,0x26,0xfc,0x4a,0x06,0x8e,0x00,0x04,0x11,0x3c,0x24,0x10,0xd2,0x00,
+0x24,0x10,0x51,0x00,0x4c,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0x24,0x28,0xd2,0x00,
+0x00,0x08,0x04,0x3c,0x24,0x10,0xa4,0x00,0x08,0x00,0x40,0x10,0x80,0x00,0x07,0x3c,
+0x00,0x4b,0x03,0x8e,0x25,0xb0,0x02,0x3c,0xb0,0x03,0x42,0x34,0x26,0x18,0x64,0x00,
+0x00,0x00,0x44,0xac,0x00,0x4b,0x03,0xae,0x80,0x00,0x07,0x3c,0x24,0x10,0xa7,0x00,
+0x21,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x4b,0x03,0x8e,0x25,0xb0,0x08,0x3c,
+0xb0,0x03,0x09,0x35,0x2a,0xb0,0x02,0x3c,0x00,0x00,0x23,0xad,0x36,0x00,0x42,0x34,
+0x00,0x00,0x43,0x90,0x23,0xb0,0x04,0x3c,0xff,0x1f,0x02,0x3c,0xc0,0x18,0x03,0x00,
+0xf0,0x07,0x63,0x30,0x5c,0x65,0x05,0x8e,0x21,0x18,0x64,0x00,0xff,0xff,0x42,0x34,
+0x24,0x18,0x62,0x00,0x59,0x00,0x65,0x10,0x60,0x65,0x03,0xae,0x02,0x80,0x05,0x3c,
+0x6c,0x7e,0xa3,0x8c,0x27,0x20,0x07,0x00,0x24,0x20,0xc4,0x00,0x00,0x08,0x63,0x34,
+0x41,0xb0,0x02,0x3c,0x00,0x00,0x23,0xad,0x00,0x00,0x44,0xac,0x6c,0x7e,0xa3,0xac,
+0xfc,0x4a,0x04,0xae,0x68,0x15,0x62,0x26,0x00,0x4b,0x43,0x8c,0x80,0x00,0x04,0x3c,
+0x26,0x18,0x64,0x00,0x00,0x4b,0x43,0xac,0x68,0x15,0x66,0x26,0xfc,0x4a,0xc3,0x8c,
+0x00,0x01,0x04,0x3c,0x24,0x28,0x72,0x00,0x24,0x10,0xa4,0x00,0x06,0x00,0x40,0x10,
+0x25,0xb0,0x02,0x3c,0x00,0x4b,0xc3,0x8c,0xb0,0x03,0x42,0x34,0x26,0x18,0x64,0x00,
+0x00,0x00,0x44,0xac,0x00,0x4b,0xc3,0xac,0x00,0x02,0x04,0x3c,0x24,0x10,0xa4,0x00,
+0x06,0x00,0x40,0x10,0x25,0xb0,0x03,0x3c,0x00,0x4b,0xc2,0x8c,0xb0,0x03,0x63,0x34,
+0x26,0x10,0x44,0x00,0x00,0x4b,0xc2,0xac,0x00,0x00,0x64,0xac,0x28,0x00,0xbf,0x8f,
+0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,0x5b,0x4e,0x00,0x0c,0x07,0x00,0x04,0x24,
+0x00,0x4b,0x03,0x8e,0xfc,0x4a,0x06,0x8e,0x25,0xb0,0x02,0x3c,0x26,0x18,0x71,0x00,
+0xb0,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0xdf,0x19,0x00,0x08,0x00,0x4b,0x03,0xae,
+0x56,0x01,0x42,0x35,0x00,0x00,0x43,0x94,0x00,0x00,0x00,0x00,0x44,0xfb,0x60,0x10,
+0x00,0x00,0x00,0x00,0x5b,0x4e,0x00,0x0c,0x07,0x00,0x04,0x24,0x7d,0x15,0x00,0x08,
+0x68,0x15,0x66,0x26,0x00,0x00,0xa2,0xac,0x48,0x16,0x00,0x08,0xff,0x00,0x02,0x24,
+0x00,0x00,0x62,0xac,0x85,0x16,0x00,0x08,0xff,0x00,0x02,0x24,0x00,0x00,0x62,0xac,
+0xc2,0x16,0x00,0x08,0xff,0x00,0x02,0x24,0x90,0x03,0x63,0x34,0x00,0x00,0x62,0xac,
+0x57,0x18,0x00,0x08,0x68,0x15,0x62,0x26,0x00,0x00,0x40,0xac,0x15,0x19,0x00,0x08,
+0x68,0x15,0x62,0x26,0x02,0x00,0x03,0x24,0x90,0x03,0x42,0x34,0x00,0x00,0x43,0xac,
+0x74,0x19,0x00,0x08,0x68,0x15,0x62,0x26,0x01,0x00,0x03,0x24,0x90,0x03,0x42,0x34,
+0x00,0x00,0x43,0xac,0xd4,0x19,0x00,0x08,0x68,0x15,0x62,0x26,0xd0,0x03,0x03,0x35,
+0x80,0x00,0x02,0x24,0x00,0x00,0x62,0xac,0x0a,0x1a,0x00,0x08,0x68,0x15,0x62,0x26,
+0x25,0xb0,0x02,0x3c,0x07,0x00,0x03,0x24,0x90,0x03,0x42,0x34,0x00,0x00,0x43,0xac,
+0x68,0x15,0x63,0x26,0x00,0x4b,0x62,0x8c,0x00,0x00,0x00,0x00,0x00,0x20,0x42,0x38,
+0xe2,0x16,0x00,0x08,0x00,0x4b,0x62,0xac,0x25,0xb0,0x02,0x3c,0x07,0x00,0x03,0x24,
+0x90,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0x68,0x15,0x63,0x26,0x00,0x4b,0x62,0x8c,
+0x00,0x00,0x00,0x00,0x00,0x80,0x42,0x38,0x40,0x17,0x00,0x08,0x00,0x4b,0x62,0xac,
+0x06,0x00,0x03,0x24,0x90,0x03,0x42,0x34,0x00,0x00,0x43,0xac,0x99,0x17,0x00,0x08,
+0x68,0x15,0x62,0x26,0x05,0x00,0x03,0x24,0x90,0x03,0x42,0x34,0x00,0x00,0x43,0xac,
+0xf8,0x17,0x00,0x08,0x68,0x15,0x62,0x26,0x03,0x00,0x03,0x24,0x90,0x03,0x42,0x34,
+0x00,0x00,0x43,0xac,0xb6,0x18,0x00,0x08,0x68,0x15,0x62,0x26,0x25,0xb0,0x0d,0x3c,
+0x00,0x80,0x02,0x3c,0x18,0x03,0xa4,0x35,0xfc,0x69,0x42,0x24,0x02,0x80,0x03,0x3c,
+0x41,0xb0,0x08,0x3c,0x00,0x00,0x82,0xac,0x68,0x15,0x6a,0x24,0x0a,0x00,0x02,0x35,
+0x00,0x00,0x44,0x94,0x0a,0x4b,0x43,0x95,0x08,0x4b,0x4b,0x95,0x25,0x18,0x64,0x00,
+0xff,0xff,0x6c,0x30,0x24,0x10,0x8b,0x01,0x02,0x00,0x42,0x30,0x4d,0x00,0x40,0x10,
+0x02,0x00,0x64,0x38,0x02,0x00,0x02,0x24,0xc0,0x03,0xa3,0x35,0x00,0x00,0x62,0xac,
+0x0a,0x4b,0x44,0xa5,0x24,0x38,0x8b,0x01,0x04,0x00,0xe2,0x30,0x0a,0x00,0x40,0x10,
+0x08,0x00,0xe2,0x30,0x0a,0x4b,0x43,0x95,0x0c,0x00,0x04,0x35,0xc0,0x03,0xa5,0x35,
+0x04,0x00,0x63,0x38,0x04,0x00,0x02,0x24,0x00,0x00,0x86,0x8c,0x00,0x00,0xa2,0xac,
+0x0a,0x4b,0x43,0xa5,0x08,0x00,0xe2,0x30,0x08,0x00,0x40,0x10,0x10,0x00,0xe2,0x30,
+0x0a,0x4b,0x42,0x95,0xc0,0x03,0xa4,0x35,0x08,0x00,0x03,0x24,0x08,0x00,0x42,0x38,
+0x00,0x00,0x83,0xac,0x0a,0x4b,0x42,0xa5,0x10,0x00,0xe2,0x30,0x08,0x00,0x40,0x10,
+0x20,0x00,0xe2,0x30,0x0a,0x4b,0x42,0x95,0xc0,0x03,0xa4,0x35,0x10,0x00,0x03,0x24,
+0x10,0x00,0x42,0x38,0x00,0x00,0x83,0xac,0x0a,0x4b,0x42,0xa5,0x20,0x00,0xe2,0x30,
+0x08,0x00,0x40,0x10,0x80,0x00,0xe2,0x30,0x0a,0x4b,0x42,0x95,0xc0,0x03,0xa4,0x35,
+0x20,0x00,0x03,0x24,0x20,0x00,0x42,0x38,0x00,0x00,0x83,0xac,0x0a,0x4b,0x42,0xa5,
+0x80,0x00,0xe2,0x30,0x15,0x00,0x40,0x10,0x24,0x10,0x8b,0x01,0x02,0x80,0x09,0x3c,
+0x0a,0x4b,0x46,0x95,0x6c,0x7e,0x25,0x8d,0x08,0x00,0x02,0x3c,0x7f,0xff,0x04,0x24,
+0x24,0x20,0x64,0x01,0x25,0x28,0xa2,0x00,0x80,0x00,0xc6,0x38,0xb0,0x03,0xa7,0x35,
+0x08,0x00,0x08,0x35,0xc0,0x03,0xa3,0x35,0x80,0x00,0x02,0x24,0x00,0x00,0x62,0xac,
+0x21,0x58,0x80,0x00,0x00,0x00,0xe5,0xac,0x0a,0x4b,0x46,0xa5,0x6c,0x7e,0x25,0xad,
+0x00,0x00,0x04,0xa5,0x08,0x4b,0x44,0xa5,0x24,0x10,0x8b,0x01,0x00,0x30,0x42,0x30,
+0x06,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x0a,0x4b,0x42,0x95,0x00,0x00,0x00,0x00,
+0x00,0x10,0x42,0x38,0x00,0x20,0x42,0x34,0x0a,0x4b,0x42,0xa5,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x95,0x1a,0x00,0x08,0x0a,0x4b,0x43,0xa5,0xf8,0xff,0xbd,0x27,
+0x04,0x00,0xb1,0xaf,0x00,0x00,0xb0,0xaf,0x00,0x40,0x02,0x40,0x00,0x68,0x08,0x40,
+0x00,0x70,0x02,0x40,0x00,0x60,0x09,0x40,0x25,0xb0,0x05,0x3c,0x00,0x80,0x02,0x3c,
+0x18,0x03,0xa3,0x34,0x7c,0x6b,0x42,0x24,0x00,0x00,0x62,0xac,0x80,0x00,0x87,0x8c,
+0x7c,0x02,0xa2,0x34,0x84,0x02,0xa3,0x34,0x88,0x02,0xa6,0x34,0x00,0x00,0x47,0xac,
+0x00,0x00,0x68,0xac,0x00,0x00,0xc9,0xac,0x74,0x00,0x83,0x8c,0x8c,0x02,0xa2,0x34,
+0x90,0x02,0xa7,0x34,0x00,0x00,0x43,0xac,0x08,0x00,0x86,0x8c,0x94,0x02,0xa8,0x34,
+0x98,0x02,0xa9,0x34,0x00,0x00,0xe6,0xac,0x0c,0x00,0x82,0x8c,0x9c,0x02,0xa6,0x34,
+0xa0,0x02,0xa7,0x34,0x00,0x00,0x02,0xad,0x10,0x00,0x83,0x8c,0xa4,0x02,0xa8,0x34,
+0xa8,0x02,0xaa,0x34,0x00,0x00,0x23,0xad,0x14,0x00,0x82,0x8c,0xac,0x02,0xa9,0x34,
+0xb0,0x02,0xab,0x34,0x00,0x00,0xc2,0xac,0x18,0x00,0x83,0x8c,0xb4,0x02,0xa6,0x34,
+0xb8,0x02,0xac,0x34,0x00,0x00,0xe3,0xac,0x1c,0x00,0x82,0x8c,0xbc,0x02,0xa7,0x34,
+0xc0,0x02,0xad,0x34,0x00,0x00,0x02,0xad,0x20,0x00,0x83,0x8c,0xc4,0x02,0xa8,0x34,
+0xc8,0x02,0xae,0x34,0x00,0x00,0x43,0xad,0x24,0x00,0x82,0x8c,0xcc,0x02,0xaa,0x34,
+0xd0,0x02,0xaf,0x34,0x00,0x00,0x22,0xad,0x28,0x00,0x83,0x8c,0xd4,0x02,0xa9,0x34,
+0xd8,0x02,0xb0,0x34,0x00,0x00,0x63,0xad,0x2c,0x00,0x82,0x8c,0x70,0x02,0xab,0x34,
+0x74,0x02,0xb1,0x34,0x00,0x00,0xc2,0xac,0x30,0x00,0x83,0x8c,0x78,0x02,0xa5,0x34,
+0x00,0x00,0x83,0xad,0x34,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xe2,0xac,
+0x38,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xad,0x3c,0x00,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xad,0x40,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,
+0x00,0x00,0xc3,0xad,0x44,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0xad,
+0x48,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xe3,0xad,0x4c,0x00,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x00,0x00,0x22,0xad,0x50,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,
+0x00,0x00,0x03,0xae,0x54,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xad,
+0x58,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0xae,0x5c,0x00,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0xac,0x42,0x1b,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0x80,0x1b,0x3c,0x10,0x6d,0x7b,0x27,0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x27,
+0x00,0x00,0x5b,0xaf,0x21,0xd8,0xa0,0x03,0x82,0xda,0x1b,0x00,0x80,0xda,0x1b,0x00,
+0x08,0x00,0x7b,0x27,0x04,0x00,0x61,0xaf,0x08,0x00,0x62,0xaf,0x0c,0x00,0x63,0xaf,
+0x10,0x00,0x64,0xaf,0x14,0x00,0x65,0xaf,0x18,0x00,0x66,0xaf,0x1c,0x00,0x67,0xaf,
+0x20,0x00,0x68,0xaf,0x24,0x00,0x69,0xaf,0x28,0x00,0x6a,0xaf,0x2c,0x00,0x6b,0xaf,
+0x30,0x00,0x6c,0xaf,0x34,0x00,0x6d,0xaf,0x38,0x00,0x6e,0xaf,0x3c,0x00,0x6f,0xaf,
+0x12,0x40,0x00,0x00,0x10,0x48,0x00,0x00,0x00,0x70,0x0a,0x40,0x40,0x00,0x70,0xaf,
+0x44,0x00,0x71,0xaf,0x48,0x00,0x72,0xaf,0x4c,0x00,0x73,0xaf,0x50,0x00,0x74,0xaf,
+0x54,0x00,0x75,0xaf,0x58,0x00,0x76,0xaf,0x5c,0x00,0x77,0xaf,0x60,0x00,0x78,0xaf,
+0x64,0x00,0x79,0xaf,0x68,0x00,0x7c,0xaf,0x6c,0x00,0x7d,0xaf,0x70,0x00,0x7e,0xaf,
+0x74,0x00,0x7f,0xaf,0x78,0x00,0x68,0xaf,0x7c,0x00,0x69,0xaf,0x80,0x00,0x6a,0xaf,
+0x00,0x68,0x1a,0x40,0x25,0xb0,0x1b,0x3c,0x1c,0x03,0x7b,0x37,0x00,0x00,0x00,0x00,
+0x00,0x00,0x7a,0xaf,0x7f,0x00,0x5b,0x33,0x30,0x00,0x60,0x13,0x00,0x00,0x00,0x00,
+0x25,0xb0,0x1b,0x3c,0x30,0x03,0x7b,0x37,0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0xaf,
+0x00,0x00,0x00,0x00,0x21,0xd8,0xa0,0x03,0x82,0xda,0x1b,0x00,0x80,0xda,0x1b,0x00,
+0x08,0x00,0x7b,0x27,0x04,0x00,0x61,0xaf,0x08,0x00,0x62,0xaf,0x0c,0x00,0x63,0xaf,
+0x10,0x00,0x64,0xaf,0x14,0x00,0x65,0xaf,0x18,0x00,0x66,0xaf,0x1c,0x00,0x67,0xaf,
+0x20,0x00,0x68,0xaf,0x24,0x00,0x69,0xaf,0x28,0x00,0x6a,0xaf,0x2c,0x00,0x6b,0xaf,
+0x30,0x00,0x6c,0xaf,0x34,0x00,0x6d,0xaf,0x38,0x00,0x6e,0xaf,0x3c,0x00,0x6f,0xaf,
+0x12,0x40,0x00,0x00,0x10,0x48,0x00,0x00,0x00,0x70,0x0a,0x40,0x40,0x00,0x70,0xaf,
+0x44,0x00,0x71,0xaf,0x48,0x00,0x72,0xaf,0x4c,0x00,0x73,0xaf,0x50,0x00,0x74,0xaf,
+0x54,0x00,0x75,0xaf,0x58,0x00,0x76,0xaf,0x5c,0x00,0x77,0xaf,0x60,0x00,0x78,0xaf,
+0x64,0x00,0x79,0xaf,0x68,0x00,0x7c,0xaf,0x6c,0x00,0x7d,0xaf,0x70,0x00,0x7e,0xaf,
+0x74,0x00,0x7f,0xaf,0x78,0x00,0x68,0xaf,0x7c,0x00,0x69,0xaf,0x80,0x00,0x6a,0xaf,
+0xdf,0x1a,0x00,0x08,0x21,0x20,0x60,0x03,0x00,0x00,0x00,0x00,0x25,0xb0,0x08,0x3c,
+0x20,0x03,0x08,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x1a,0xad,0x00,0x04,0x5b,0x33,
+0x0a,0x00,0x60,0x13,0x00,0x00,0x00,0x00,0x00,0x80,0x08,0x3c,0x74,0x55,0x08,0x25,
+0x00,0x00,0x00,0x00,0x25,0xb0,0x1b,0x3c,0x24,0x03,0x7b,0x37,0x00,0x00,0x00,0x00,
+0x00,0x00,0x68,0xaf,0x09,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x08,0x5b,0x33,
+0x25,0xb0,0x08,0x3c,0x28,0x03,0x08,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0xad,
+0x06,0x00,0x60,0x13,0x00,0x00,0x00,0x00,0x00,0x80,0x08,0x3c,0xfc,0x69,0x08,0x25,
+0x00,0x00,0x00,0x00,0x09,0xf8,0x00,0x01,0x00,0x00,0x00,0x00,0x02,0x80,0x1a,0x3c,
+0x6c,0x7e,0x5a,0x27,0x04,0x00,0x5b,0x97,0x25,0xb0,0x08,0x3c,0x30,0x03,0x08,0x35,
+0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0xad,0x18,0x00,0x60,0x13,0x00,0x00,0x00,0x00,
+0x08,0xec,0x9b,0x27,0x00,0x00,0x00,0x00,0x04,0x00,0x61,0x8f,0xfc,0x03,0x70,0x7b,
+0x7c,0x00,0x62,0x7b,0xbc,0x00,0x64,0x7b,0xfc,0x00,0x66,0x7b,0x3c,0x01,0x68,0x7b,
+0x13,0x00,0x00,0x02,0x11,0x00,0x20,0x02,0x7c,0x01,0x6a,0x7b,0xbc,0x01,0x6c,0x7b,
+0xfc,0x01,0x6e,0x7b,0x3c,0x02,0x70,0x7b,0x7c,0x02,0x72,0x7b,0xbc,0x02,0x74,0x7b,
+0xfc,0x02,0x76,0x7b,0x3c,0x03,0x78,0x7b,0x7c,0x03,0x7c,0x7b,0xbc,0x03,0x7e,0x7b,
+0x80,0x00,0x7b,0x8f,0x2f,0x1c,0x00,0x08,0x00,0x00,0x00,0x00,0x21,0xd8,0xa0,0x03,
+0x82,0xda,0x1b,0x00,0x80,0xda,0x1b,0x00,0x08,0x00,0x7b,0x27,0x08,0x00,0x5b,0xaf,
+0xfc,0xef,0x9d,0x27,0x00,0x00,0x4a,0x8f,0x00,0x00,0x00,0x00,0x21,0x00,0x40,0x11,
+0x00,0x00,0x00,0x00,0x02,0x80,0x08,0x3c,0xcc,0x7d,0x08,0x25,0x21,0x48,0x00,0x00,
+0x21,0x58,0x00,0x00,0x01,0x00,0x6b,0x25,0x1a,0x00,0x40,0x11,0x24,0x70,0x4b,0x01,
+0x14,0x00,0xc0,0x11,0x01,0x00,0x04,0x24,0x00,0x00,0x00,0x00,0x04,0x00,0x44,0xa3,
+0x26,0x50,0x4b,0x01,0x00,0x00,0x4a,0xaf,0x80,0x80,0x09,0x00,0x21,0x80,0x08,0x02,
+0x00,0x00,0x10,0x8e,0x00,0x00,0x00,0x00,0x09,0xf8,0x00,0x02,0x00,0x00,0x00,0x00,
+0x00,0x80,0x1b,0x3c,0xe8,0x6f,0x7b,0x27,0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x27,
+0x00,0x00,0x5b,0xaf,0x02,0x80,0x1a,0x3c,0x6c,0x7e,0x5a,0x27,0xe1,0xff,0x00,0x10,
+0x00,0x00,0x00,0x00,0x01,0x00,0x29,0x25,0x40,0x58,0x0b,0x00,0xf2,0x1b,0x00,0x08,
+0x00,0x00,0x00,0x00,0x02,0x80,0x1b,0x3c,0x6c,0x7e,0x7b,0x27,0x21,0x60,0x00,0x00,
+0x04,0x00,0x6c,0xa7,0x08,0x00,0x7a,0x8f,0x00,0x00,0x00,0x00,0xf8,0xff,0x5a,0x27,
+0x00,0x00,0x5a,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0x5a,0x27,0x84,0x00,0x44,0x8f,
+0x00,0x00,0x00,0x00,0xf9,0xff,0x80,0x10,0x00,0x00,0x00,0x00,0x04,0x00,0x41,0x8f,
+0xfc,0x03,0x50,0x7b,0x7c,0x00,0x42,0x7b,0xbc,0x00,0x44,0x7b,0xfc,0x00,0x46,0x7b,
+0x3c,0x01,0x48,0x7b,0x13,0x00,0x00,0x02,0x11,0x00,0x20,0x02,0x7c,0x01,0x4a,0x7b,
+0xbc,0x01,0x4c,0x7b,0xfc,0x01,0x4e,0x7b,0x3c,0x02,0x50,0x7b,0x7c,0x02,0x52,0x7b,
+0xbc,0x02,0x54,0x7b,0xfc,0x02,0x56,0x7b,0x3c,0x03,0x58,0x7b,0x7c,0x03,0x5c,0x7b,
+0xbc,0x03,0x5e,0x7b,0x80,0x00,0x5b,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0x60,0x03,
+0x10,0x00,0x00,0x42,0x00,0x60,0x05,0x40,0x42,0x28,0x05,0x00,0x40,0x28,0x05,0x00,
+0x00,0x60,0x85,0x40,0x04,0x00,0x81,0xac,0x08,0x00,0x82,0xac,0x0c,0x00,0x83,0xac,
+0x20,0x00,0x88,0xac,0x24,0x00,0x89,0xac,0x28,0x00,0x8a,0xac,0x2c,0x00,0x8b,0xac,
+0x30,0x00,0x8c,0xac,0x34,0x00,0x8d,0xac,0x38,0x00,0x8e,0xac,0x3c,0x00,0x8f,0xac,
+0x12,0x40,0x00,0x00,0x10,0x48,0x00,0x00,0x40,0x00,0x90,0xac,0x44,0x00,0x91,0xac,
+0x48,0x00,0x92,0xac,0x4c,0x00,0x93,0xac,0x50,0x00,0x94,0xac,0x54,0x00,0x95,0xac,
+0x58,0x00,0x96,0xac,0x5c,0x00,0x97,0xac,0x60,0x00,0x98,0xac,0x64,0x00,0x99,0xac,
+0x68,0x00,0x9c,0xac,0x6c,0x00,0x9d,0xac,0x70,0x00,0x9e,0xac,0x74,0x00,0x9f,0xac,
+0x78,0x00,0x88,0xac,0x7c,0x00,0x89,0xac,0x80,0x00,0x9f,0xac,0xf8,0xff,0x84,0x24,
+0x00,0x00,0x84,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x84,0x24,0x84,0x00,0x86,0x8c,
+0x00,0x00,0x00,0x00,0xf9,0xff,0xc0,0x10,0x00,0x00,0x00,0x00,0x21,0xd8,0x80,0x00,
+0x01,0x00,0xba,0x24,0x04,0x00,0x61,0x8f,0xfc,0x03,0x70,0x7b,0x7c,0x00,0x62,0x7b,
+0xbc,0x00,0x64,0x7b,0xfc,0x00,0x66,0x7b,0x3c,0x01,0x68,0x7b,0x13,0x00,0x00,0x02,
+0x11,0x00,0x20,0x02,0x7c,0x01,0x6a,0x7b,0xbc,0x01,0x6c,0x7b,0xfc,0x01,0x6e,0x7b,
+0x3c,0x02,0x70,0x7b,0x7c,0x02,0x72,0x7b,0xbc,0x02,0x74,0x7b,0xfc,0x02,0x76,0x7b,
+0x3c,0x03,0x78,0x7b,0x7c,0x03,0x7c,0x7b,0xbc,0x03,0x7e,0x7b,0x80,0x00,0x7b,0x8f,
+0x00,0x00,0x00,0x00,0x08,0x00,0x60,0x03,0x00,0x60,0x9a,0x40,0x00,0x60,0x05,0x40,
+0x42,0x28,0x05,0x00,0x40,0x28,0x05,0x00,0x00,0x60,0x85,0x40,0x04,0x00,0x81,0xac,
+0x08,0x00,0x82,0xac,0x0c,0x00,0x83,0xac,0x20,0x00,0x88,0xac,0x24,0x00,0x89,0xac,
+0x28,0x00,0x8a,0xac,0x2c,0x00,0x8b,0xac,0x30,0x00,0x8c,0xac,0x34,0x00,0x8d,0xac,
+0x38,0x00,0x8e,0xac,0x3c,0x00,0x8f,0xac,0x12,0x40,0x00,0x00,0x10,0x48,0x00,0x00,
+0x40,0x00,0x90,0xac,0x44,0x00,0x91,0xac,0x48,0x00,0x92,0xac,0x4c,0x00,0x93,0xac,
+0x50,0x00,0x94,0xac,0x54,0x00,0x94,0xac,0x58,0x00,0x96,0xac,0x5c,0x00,0x96,0xac,
+0x60,0x00,0x98,0xac,0x64,0x00,0x99,0xac,0x68,0x00,0x9c,0xac,0x6c,0x00,0x9d,0xac,
+0x70,0x00,0x9e,0xac,0x78,0x00,0x88,0xac,0x7c,0x00,0x89,0xac,0x80,0x00,0x9f,0xac,
+0x84,0x00,0x80,0xac,0xf8,0xff,0x84,0x24,0x00,0x00,0x84,0x8c,0x00,0x00,0x00,0x00,
+0x08,0x00,0x84,0x24,0x84,0x00,0x86,0x8c,0xfa,0xff,0xc0,0x10,0x00,0x00,0x00,0x00,
+0x21,0xd8,0x80,0x00,0x01,0x00,0xba,0x24,0x04,0x00,0x61,0x8f,0xfc,0x03,0x70,0x7b,
+0x7c,0x00,0x62,0x7b,0xbc,0x00,0x64,0x7b,0xfc,0x00,0x66,0x7b,0x3c,0x01,0x68,0x7b,
+0x13,0x00,0x00,0x02,0x11,0x00,0x20,0x02,0x7c,0x01,0x6a,0x7b,0xbc,0x01,0x6c,0x7b,
+0xfc,0x01,0x6e,0x7b,0x3c,0x02,0x70,0x7b,0x7c,0x02,0x72,0x7b,0xbc,0x02,0x74,0x7b,
+0xfc,0x02,0x76,0x7b,0x3c,0x03,0x78,0x7b,0x7c,0x03,0x7c,0x7b,0xbc,0x03,0x7e,0x7b,
+0x80,0x00,0x7b,0x8f,0x08,0x00,0x60,0x03,0x00,0x60,0x9a,0x40,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xc6,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x1b,0x3c,0x00,0x00,0x7b,0x27,
+0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x27,0x00,0x00,0x5b,0xaf,0x00,0x00,0x05,0x24,
+0x03,0x00,0xa4,0x24,0x00,0xa0,0x80,0x40,0x00,0xa0,0x84,0x40,0x01,0x80,0x04,0x3c,
+0x98,0x03,0x84,0x24,0x08,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x01,0x80,0x1b,0x3c,0x98,0x03,0x7b,0x27,0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x27,
+0x00,0x00,0x5b,0xaf,0x02,0x80,0x1a,0x3c,0x00,0x00,0x5a,0x27,0xfc,0x03,0x5d,0x27,
+0x02,0x80,0x1c,0x3c,0x00,0x14,0x9c,0x27,0x00,0xf0,0x08,0x3c,0x00,0x0c,0x08,0x35,
+0x00,0x60,0x88,0x40,0x02,0x80,0x04,0x3c,0x00,0x00,0x84,0x24,0xff,0x7f,0x05,0x3c,
+0xff,0xff,0xa5,0x34,0x24,0x20,0x85,0x00,0x00,0x20,0x84,0x4c,0xff,0xff,0x05,0x34,
+0x21,0x28,0xa4,0x00,0x00,0x28,0x85,0x4c,0x00,0x80,0x04,0x3c,0x00,0x00,0x84,0x24,
+0xff,0x7f,0x05,0x3c,0xff,0xff,0xa5,0x34,0x24,0x20,0x85,0x00,0x00,0x00,0x84,0x4c,
+0xff,0x7f,0x06,0x24,0x21,0x30,0xc4,0x00,0x24,0x30,0xc5,0x00,0x00,0x08,0x86,0x4c,
+0x00,0xa0,0x04,0x40,0x10,0x00,0x84,0x34,0x00,0xa0,0x84,0x40,0x01,0x80,0x1b,0x3c,
+0x24,0x04,0x7b,0x27,0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x27,0x00,0x00,0x5b,0xaf,
+0x00,0x00,0x00,0x00,0x25,0xb0,0x04,0x3c,0x44,0x00,0x84,0x34,0x00,0x00,0x85,0x84,
+0x20,0x00,0x06,0x24,0x25,0x28,0xa6,0x00,0x00,0x00,0x85,0xa4,0x01,0x80,0x1b,0x3c,
+0x54,0x04,0x7b,0x27,0x25,0xb0,0x1a,0x3c,0x18,0x03,0x5a,0x27,0x00,0x00,0x5b,0xaf,
+0x25,0xb0,0x04,0x3c,0x44,0x00,0x84,0x34,0x00,0x00,0x85,0x8c,0x00,0x00,0x00,0x00,
+0x10,0x00,0xa5,0x30,0xfc,0xff,0xa0,0x10,0x00,0x00,0x00,0x00,0xff,0x1f,0x07,0x3c,
+0xff,0xff,0xe7,0x34,0x02,0x80,0x05,0x3c,0x88,0x7d,0xa5,0x24,0xff,0xff,0xa5,0x30,
+0x40,0xb0,0x04,0x3c,0x25,0x28,0xa4,0x00,0x24,0x28,0xa7,0x00,0x21,0x30,0x00,0x00,
+0x43,0xb0,0x02,0x3c,0x00,0x80,0x04,0x3c,0x40,0x00,0x84,0x34,0x00,0x00,0x45,0xac,
+0x04,0x00,0x46,0xac,0x08,0x00,0x44,0xac,0x4e,0x58,0x00,0x08,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x09,0x00,0x02,0x24,0xff,0xff,0x42,0x24,
+0xff,0xff,0x41,0x04,0xff,0xff,0x42,0x24,0x08,0x00,0xe0,0x03,0x01,0x00,0x42,0x24,
+0x00,0x60,0x02,0x40,0x01,0x00,0x41,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x82,0xac,0x00,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,
+0x21,0x18,0x40,0x00,0x00,0x60,0x83,0x40,0x08,0x00,0xe0,0x03,0x00,0x00,0x82,0xac,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0x44,0x05,0x63,0x24,0x18,0x03,0x42,0x34,0x00,0x00,0x43,0xac,
+0x04,0x00,0x85,0x8c,0x00,0x80,0x03,0x3c,0x01,0x00,0x02,0x24,0x25,0x28,0xa3,0x00,
+0x00,0x00,0xa4,0x8c,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0x74,0x05,0x63,0x24,0x18,0x03,0x42,0x34,0x00,0x00,0x43,0xac,
+0x04,0x00,0x82,0x8c,0x02,0x00,0x83,0x94,0x00,0x80,0x07,0x3c,0x25,0x28,0x47,0x00,
+0x00,0x00,0xa2,0x8c,0x10,0x00,0x02,0x24,0x13,0x00,0x62,0x10,0x11,0x00,0x66,0x28,
+0x06,0x00,0xc0,0x10,0x20,0x00,0x02,0x24,0x08,0x00,0x02,0x24,0x17,0x00,0x62,0x10,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,0xfd,0xff,0x62,0x14,
+0x00,0x00,0x00,0x00,0x08,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xac,
+0x04,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x25,0x10,0x47,0x00,0x00,0x00,0x42,0x8c,
+0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,0x08,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,
+0x00,0x00,0xa2,0xa4,0x04,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,0x25,0x18,0x67,0x00,
+0x00,0x00,0x62,0x94,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,0x08,0x00,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0xa0,0x04,0x00,0x83,0x8c,0x00,0x00,0x00,0x00,
+0x25,0x18,0x67,0x00,0x00,0x00,0x62,0x90,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,
+0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,0x02,0x80,0x11,0x3c,0x1c,0x00,0xbf,0xaf,
+0x18,0x00,0xb2,0xaf,0x10,0x00,0xb0,0xaf,0x68,0x15,0x31,0x26,0xe4,0x64,0x30,0x96,
+0x02,0x80,0x02,0x3c,0x01,0x80,0x03,0x3c,0x25,0x80,0x02,0x02,0x25,0xb0,0x02,0x3c,
+0x38,0x06,0x63,0x24,0x18,0x03,0x42,0x34,0x60,0x00,0x04,0x26,0x80,0x00,0x05,0x26,
+0x00,0x00,0x43,0xac,0xab,0x45,0x00,0x0c,0x03,0x00,0x06,0x24,0x21,0x20,0x00,0x02,
+0x21,0x28,0x00,0x00,0x97,0x45,0x00,0x0c,0x08,0x00,0x06,0x24,0xe4,0x64,0x22,0x8e,
+0x0c,0x00,0x03,0x24,0x0c,0x00,0x43,0xae,0x08,0x00,0x42,0xae,0x12,0x00,0x02,0x24,
+0x14,0x00,0x42,0xae,0x21,0x20,0x40,0x02,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x8b,0x07,0x00,0x08,0x20,0x00,0xbd,0x27,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,
+0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,0x02,0x80,0x02,0x3c,0x21,0x48,0x80,0x00,
+0x68,0x15,0x48,0x24,0x21,0x38,0x00,0x00,0x21,0x28,0x27,0x01,0x00,0x00,0xa2,0x90,
+0x21,0x20,0xe8,0x00,0x01,0x00,0xe7,0x24,0x38,0x4c,0x82,0xa0,0x1e,0x00,0xa3,0x90,
+0x1e,0x00,0xe6,0x28,0x56,0x4c,0x83,0xa0,0x3c,0x00,0xa2,0x90,0x00,0x00,0x00,0x00,
+0x74,0x4c,0x82,0xa0,0x5a,0x00,0xa3,0x90,0xf3,0xff,0xc0,0x14,0x92,0x4c,0x83,0xa0,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,
+0x20,0xbd,0x03,0x3c,0x58,0x00,0x63,0x34,0x00,0x00,0x62,0x90,0x0f,0x27,0x07,0x24,
+0x20,0x00,0x42,0x34,0x00,0x00,0x62,0xa0,0xff,0xff,0xe7,0x24,0xff,0xff,0xe1,0x04,
+0xff,0xff,0xe7,0x24,0x62,0xbd,0x04,0x3c,0x24,0x10,0x82,0x34,0x00,0x00,0x40,0xa0,
+0x28,0x10,0x83,0x34,0x0c,0x11,0x86,0x34,0x0e,0x00,0x02,0x24,0x00,0x00,0x60,0xa0,
+0x00,0x11,0x85,0x34,0x00,0x00,0xc2,0xa0,0x00,0x00,0xa7,0x8c,0xdf,0xff,0x02,0x24,
+0x10,0x00,0x86,0x34,0x24,0x38,0xe2,0x00,0x49,0x0c,0x03,0x24,0xcf,0xff,0x02,0x24,
+0x00,0x00,0xc3,0xac,0x04,0x00,0x84,0x34,0x00,0x00,0xa7,0xac,0x24,0x38,0xe2,0x00,
+0x41,0x0c,0x02,0x24,0x00,0x00,0xa7,0xac,0x00,0x00,0x80,0xac,0x00,0x00,0xc2,0xac,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0xd0,0xff,0xbd,0x27,0x25,0xb0,0x03,0x3c,
+0x01,0x80,0x02,0x3c,0xb0,0x03,0x68,0x34,0x1c,0x00,0xb1,0xaf,0x18,0x03,0x63,0x34,
+0xd8,0xff,0x91,0x24,0xa0,0x08,0x42,0x24,0x00,0x00,0x62,0xac,0x28,0x00,0xbf,0xaf,
+0x00,0x00,0x11,0xad,0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x18,0x00,0xb0,0xaf,
+0x02,0x80,0x13,0x3c,0x00,0x00,0x23,0x96,0x68,0x15,0x73,0x26,0xff,0xff,0x32,0x32,
+0x40,0x10,0x02,0x3c,0x78,0x64,0x65,0x8e,0x25,0x90,0x42,0x02,0x02,0x80,0x10,0x3c,
+0x8c,0x96,0x10,0x26,0x20,0x00,0x42,0x26,0x00,0x00,0x03,0xad,0x20,0x00,0x06,0x24,
+0x00,0x00,0x02,0xad,0x21,0x38,0x00,0x02,0x0c,0x00,0x03,0xae,0x0a,0x00,0x04,0x24,
+0x64,0x01,0x00,0x0c,0x08,0x00,0x02,0xae,0x04,0x00,0x23,0x8e,0xff,0xe0,0x02,0x24,
+0x28,0x00,0x04,0x24,0x24,0x18,0x62,0x00,0x00,0x10,0x63,0x34,0x02,0x00,0x24,0xa2,
+0x04,0x00,0x23,0xae,0x0c,0x00,0x02,0x8e,0x0a,0x00,0x04,0x24,0xf8,0xff,0x42,0x24,
+0x4d,0x01,0x00,0x0c,0x00,0x00,0x22,0xa6,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x0c,0x00,0x07,0x8e,0x20,0x10,0x06,0x3c,
+0x21,0x28,0x40,0x02,0x20,0x00,0xe7,0x24,0x00,0xfe,0xc6,0x34,0xff,0xff,0xe7,0x30,
+0x01,0x00,0x11,0x24,0x0a,0x00,0x04,0x24,0x10,0x01,0x00,0x0c,0x10,0x00,0xb1,0xaf,
+0xd5,0x4a,0x63,0x92,0x2a,0xb0,0x10,0x3c,0x32,0x00,0x02,0x36,0x01,0x00,0x63,0x24,
+0x00,0x00,0x43,0xa0,0x4d,0x01,0x00,0x0c,0x0a,0x00,0x04,0x24,0xc9,0x64,0x62,0x92,
+0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0xc9,0x64,0x62,0xa2,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x01,0x00,0x10,0x36,0x00,0x00,0x11,0xa2,
+0x28,0x00,0xbf,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,
+0x18,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,
+0x25,0xb0,0x05,0x3c,0x01,0x80,0x03,0x3c,0x21,0x38,0x80,0x00,0x18,0x03,0xa2,0x34,
+0xe8,0x09,0x63,0x24,0x01,0x00,0x04,0x24,0x00,0x00,0x43,0xac,0x35,0x00,0xe4,0x10,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x10,0x20,0x08,0xa2,0x34,0x02,0x00,0x02,0x24,
+0x83,0x00,0xe2,0x10,0x03,0x00,0x02,0x24,0x5a,0x00,0xe2,0x10,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x02,0x80,0x03,0x3c,0x00,0x00,0x44,0x8c,
+0x68,0x15,0x66,0x24,0x70,0x08,0x02,0x24,0xe0,0x08,0x03,0x24,0x74,0x4b,0xc2,0xac,
+0x40,0x08,0x02,0x24,0x78,0x4b,0xc3,0xac,0x84,0x4b,0xc2,0xac,0x78,0x08,0x03,0x24,
+0x0c,0x08,0x02,0x24,0x88,0x4b,0xc3,0xac,0x8c,0x4b,0xc2,0xac,0x10,0x08,0x03,0x24,
+0x20,0x08,0x02,0x24,0x90,0x4b,0xc3,0xac,0x94,0x4b,0xc2,0xac,0x24,0x08,0x03,0x24,
+0x58,0x08,0x02,0x24,0x98,0x4b,0xc3,0xac,0x9c,0x4b,0xc2,0xac,0x50,0x0c,0x03,0x24,
+0x54,0x0c,0x02,0x24,0xa0,0x4b,0xc3,0xac,0xa4,0x4b,0xc2,0xac,0x14,0x0c,0x03,0x24,
+0x10,0x0c,0x02,0x24,0x60,0x08,0x05,0x24,0xa8,0x4b,0xc3,0xac,0xac,0x4b,0xc2,0xac,
+0x80,0x0c,0x03,0x24,0x84,0x0c,0x02,0x24,0x00,0x01,0x84,0x30,0xb4,0x4b,0xc2,0xac,
+0x80,0x4b,0xc5,0xac,0xb0,0x4b,0xc3,0xac,0x71,0x4b,0xc0,0xa0,0x7c,0x4b,0xc5,0xac,
+0x02,0x00,0x80,0x10,0xa0,0x08,0x02,0x24,0xb8,0x08,0x02,0x24,0x08,0x00,0xe0,0x03,
+0xb8,0x4b,0xc2,0xac,0x28,0x08,0xa2,0x34,0x02,0x80,0x03,0x3c,0x00,0x00,0x44,0x8c,
+0x68,0x15,0x66,0x24,0x70,0x08,0x02,0x24,0xe0,0x08,0x03,0x24,0x74,0x4b,0xc2,0xac,
+0x44,0x08,0x02,0x24,0x78,0x4b,0xc3,0xac,0x84,0x4b,0xc2,0xac,0x78,0x08,0x03,0x24,
+0x0c,0x08,0x02,0x24,0x88,0x4b,0xc3,0xac,0x8c,0x4b,0xc2,0xac,0x14,0x08,0x03,0x24,
+0x28,0x08,0x02,0x24,0x90,0x4b,0xc3,0xac,0x94,0x4b,0xc2,0xac,0x2c,0x08,0x03,0x24,
+0x58,0x08,0x02,0x24,0x98,0x4b,0xc3,0xac,0x9c,0x4b,0xc2,0xac,0x58,0x0c,0x03,0x24,
+0x5c,0x0c,0x02,0x24,0xa0,0x4b,0xc3,0xac,0xa4,0x4b,0xc2,0xac,0x1c,0x0c,0x03,0x24,
+0x18,0x0c,0x02,0x24,0x64,0x08,0x05,0x24,0xa8,0x4b,0xc3,0xac,0xac,0x4b,0xc2,0xac,
+0x88,0x0c,0x03,0x24,0x8c,0x0c,0x02,0x24,0x00,0x01,0x84,0x30,0xb4,0x4b,0xc2,0xac,
+0x71,0x4b,0xc7,0xa0,0x80,0x4b,0xc5,0xac,0xb0,0x4b,0xc3,0xac,0x7c,0x4b,0xc5,0xac,
+0xd6,0xff,0x80,0x10,0xa4,0x08,0x02,0x24,0xbc,0x08,0x02,0x24,0x08,0x00,0xe0,0x03,
+0xb8,0x4b,0xc2,0xac,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,0xac,0x08,0x03,0x24,
+0xb8,0x4b,0x43,0xac,0x74,0x08,0x03,0x24,0xe4,0x08,0x04,0x24,0x74,0x4b,0x43,0xac,
+0x4c,0x08,0x03,0x24,0x78,0x4b,0x44,0xac,0x84,0x4b,0x43,0xac,0x7c,0x08,0x04,0x24,
+0x0c,0x08,0x03,0x24,0x88,0x4b,0x44,0xac,0x8c,0x4b,0x43,0xac,0x1c,0x08,0x04,0x24,
+0x38,0x08,0x03,0x24,0x90,0x4b,0x44,0xac,0x94,0x4b,0x43,0xac,0x3c,0x08,0x04,0x24,
+0x5c,0x08,0x03,0x24,0x98,0x4b,0x44,0xac,0x9c,0x4b,0x43,0xac,0x68,0x0c,0x04,0x24,
+0x6c,0x0c,0x03,0x24,0xa0,0x4b,0x44,0xac,0xa4,0x4b,0x43,0xac,0x2c,0x0c,0x04,0x24,
+0x28,0x0c,0x03,0x24,0x6c,0x08,0x05,0x24,0xa8,0x4b,0x44,0xac,0xac,0x4b,0x43,0xac,
+0x98,0x0c,0x04,0x24,0x9c,0x0c,0x03,0x24,0x71,0x4b,0x47,0xa0,0x80,0x4b,0x45,0xac,
+0xb0,0x4b,0x44,0xac,0xb4,0x4b,0x43,0xac,0x08,0x00,0xe0,0x03,0x7c,0x4b,0x45,0xac,
+0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,0xa8,0x08,0x03,0x24,0xb8,0x4b,0x43,0xac,
+0x74,0x08,0x03,0x24,0xe4,0x08,0x04,0x24,0x74,0x4b,0x43,0xac,0x48,0x08,0x03,0x24,
+0x78,0x4b,0x44,0xac,0x84,0x4b,0x43,0xac,0x7c,0x08,0x04,0x24,0x0c,0x08,0x03,0x24,
+0x88,0x4b,0x44,0xac,0x8c,0x4b,0x43,0xac,0x18,0x08,0x04,0x24,0x30,0x08,0x03,0x24,
+0x90,0x4b,0x44,0xac,0x94,0x4b,0x43,0xac,0x34,0x08,0x04,0x24,0x5c,0x08,0x03,0x24,
+0x98,0x4b,0x44,0xac,0x9c,0x4b,0x43,0xac,0x60,0x0c,0x04,0x24,0x64,0x0c,0x03,0x24,
+0xa0,0x4b,0x44,0xac,0xa4,0x4b,0x43,0xac,0x24,0x0c,0x04,0x24,0x20,0x0c,0x03,0x24,
+0x68,0x08,0x05,0x24,0xa8,0x4b,0x44,0xac,0xac,0x4b,0x43,0xac,0x90,0x0c,0x04,0x24,
+0x94,0x0c,0x03,0x24,0x71,0x4b,0x47,0xa0,0x80,0x4b,0x45,0xac,0xb0,0x4b,0x44,0xac,
+0xb4,0x4b,0x43,0xac,0x08,0x00,0xe0,0x03,0x7c,0x4b,0x45,0xac,0x36,0x43,0x00,0x08,
+0x21,0x18,0x00,0x00,0x20,0x00,0x62,0x2c,0x06,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0x06,0x10,0x64,0x00,0x01,0x00,0x42,0x30,0xfa,0xff,0x40,0x10,0x01,0x00,0x63,0x24,
+0xff,0xff,0x63,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,0xd8,0xff,0xbd,0x27,
+0x25,0xb0,0x02,0x3c,0x18,0x00,0xb2,0xaf,0x21,0x90,0x82,0x00,0xff,0xff,0x02,0x24,
+0x1c,0x00,0xb3,0xaf,0x14,0x00,0xb1,0xaf,0x20,0x00,0xbf,0xaf,0x10,0x00,0xb0,0xaf,
+0x21,0x88,0xa0,0x00,0x21,0x20,0xa0,0x00,0x21,0x18,0x40,0x02,0x10,0x00,0xa2,0x10,
+0x21,0x98,0xc0,0x00,0x00,0x00,0x50,0x8e,0x31,0x43,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x04,0x10,0x53,0x00,0x27,0x18,0x11,0x00,0x25,0x18,0x62,0x00,0x24,0x18,0x70,0x00,
+0x00,0x00,0x43,0xae,0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,
+0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x28,0x00,0xbd,0x27,0x00,0x00,0x66,0xac,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,0x21,0x30,0x80,0x00,0xec,0x60,0x44,0x8c,
+0x3d,0x43,0x00,0x08,0xff,0xff,0x05,0x24,0xe0,0xff,0xbd,0x27,0x25,0xb0,0x02,0x3c,
+0x18,0x00,0xbf,0xaf,0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x21,0x20,0x82,0x00,
+0x00,0x00,0x90,0x8c,0x21,0x88,0xa0,0x00,0x31,0x43,0x00,0x0c,0x21,0x20,0xa0,0x00,
+0x24,0x80,0x11,0x02,0x06,0x10,0x50,0x00,0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0xd0,0xff,0xbd,0x27,
+0x14,0x00,0xb1,0xaf,0x02,0x80,0x11,0x3c,0x28,0x00,0xbf,0xaf,0x20,0x00,0xb4,0xaf,
+0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,0x24,0x00,0xb5,0xaf,0x10,0x00,0xb0,0xaf,
+0x68,0x15,0x31,0x26,0x98,0x4b,0x22,0x8e,0x25,0xb0,0x12,0x3c,0x24,0x08,0x53,0x36,
+0x21,0x10,0x52,0x00,0x00,0x00,0x70,0x8e,0x00,0x00,0x55,0x8c,0x7f,0x80,0x03,0x3c,
+0xff,0x7f,0x02,0x3c,0xff,0xff,0x63,0x34,0xff,0xff,0x42,0x34,0x24,0x10,0x02,0x02,
+0x24,0x18,0xa3,0x02,0xc0,0x25,0x04,0x00,0x25,0x18,0x64,0x00,0x00,0x80,0x14,0x3c,
+0x00,0x00,0x62,0xae,0x01,0x00,0x04,0x24,0x84,0x0a,0x00,0x0c,0x25,0xa8,0x74,0x00,
+0x98,0x4b,0x22,0x8e,0x25,0x80,0x14,0x02,0x01,0x00,0x04,0x24,0x21,0x10,0x52,0x00,
+0x00,0x00,0x55,0xac,0x84,0x0a,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xae,
+0x84,0x0a,0x00,0x0c,0x01,0x00,0x04,0x24,0xb8,0x4b,0x24,0x8e,0x0f,0x00,0x05,0x3c,
+0x28,0x00,0xbf,0x8f,0x24,0x00,0xb5,0x8f,0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,
+0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0xff,0xff,0xa5,0x34,
+0x68,0x43,0x00,0x08,0x30,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,
+0x02,0x80,0x11,0x3c,0x10,0x00,0xb0,0xaf,0x18,0x00,0xbf,0xaf,0x68,0x15,0x27,0x26,
+0x73,0x4b,0xe5,0x90,0x01,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,0xb0,0x0e,0x63,0x24,
+0x18,0x03,0x42,0x34,0x02,0x00,0x06,0x24,0x00,0x00,0x43,0xac,0x34,0x00,0xa6,0x10,
+0x21,0x80,0x80,0x00,0x03,0x00,0x03,0x24,0x3a,0x00,0xa3,0x10,0x2e,0x00,0x02,0x2e,
+0x10,0x00,0x02,0x2e,0x07,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0xff,0x00,0x04,0x32,
+0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x79,0x43,0x00,0x08,
+0x20,0x00,0xbd,0x27,0xfa,0xff,0xa6,0x14,0xff,0x00,0x04,0x32,0x71,0x4b,0xe4,0x90,
+0x01,0x00,0x02,0x24,0x33,0x00,0x82,0x10,0x02,0x00,0x82,0x28,0x38,0x00,0x40,0x14,
+0x00,0x00,0x00,0x00,0x38,0x00,0x85,0x10,0x68,0x15,0x22,0x26,0x2e,0x00,0x83,0x10,
+0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x24,0x68,0x43,0x00,0x0c,0xff,0xff,0x05,0x24,
+0xff,0xfc,0x06,0x3c,0xff,0xff,0xc6,0x34,0x24,0x30,0x46,0x00,0x00,0x08,0x04,0x24,
+0x3d,0x43,0x00,0x0c,0xff,0xff,0x05,0x24,0x68,0x15,0x22,0x26,0x71,0x4b,0x44,0x90,
+0x01,0x00,0x03,0x24,0x07,0x00,0x83,0x10,0x02,0x00,0x82,0x28,0x2c,0x00,0x40,0x14,
+0x02,0x00,0x02,0x24,0x2c,0x00,0x82,0x10,0x03,0x00,0x02,0x24,0xdb,0xff,0x82,0x14,
+0x00,0x00,0x00,0x00,0x68,0x15,0x22,0x26,0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x3c,
+0x3d,0x43,0x00,0x0c,0x21,0x30,0x00,0x00,0xc2,0x43,0x00,0x08,0xff,0x00,0x04,0x32,
+0x25,0x00,0x82,0x2c,0xcc,0xff,0x40,0x14,0x03,0x00,0x03,0x24,0x18,0x00,0xbf,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0xc7,0xff,0x40,0x14,0x10,0x00,0x02,0x2e,0x18,0x00,0xbf,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0x68,0x15,0x22,0x26,0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x3c,
+0x3d,0x43,0x00,0x0c,0x0f,0x00,0x06,0x24,0xd4,0x43,0x00,0x08,0x00,0x08,0x04,0x24,
+0xcc,0xff,0x80,0x14,0x68,0x15,0x22,0x26,0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x24,
+0x3d,0x43,0x00,0x0c,0x0f,0x00,0x06,0x24,0xd4,0x43,0x00,0x08,0x00,0x08,0x04,0x24,
+0xb2,0xff,0x80,0x14,0x00,0x00,0x00,0x00,0x68,0x15,0x22,0x26,0x74,0x4b,0x44,0x8c,
+0x0f,0x00,0x05,0x24,0x3d,0x43,0x00,0x0c,0x21,0x30,0x00,0x00,0xc2,0x43,0x00,0x08,
+0xff,0x00,0x04,0x32,0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,0x02,0x80,0x11,0x3c,
+0x68,0x15,0x28,0x26,0x73,0x4b,0x06,0x91,0x01,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x5c,0x10,0x63,0x24,0x18,0x03,0x42,0x34,0x02,0x00,0x07,0x24,0x18,0x00,0xb2,0xaf,
+0x10,0x00,0xb0,0xaf,0x1c,0x00,0xbf,0xaf,0x00,0x00,0x43,0xac,0x21,0x90,0xa0,0x00,
+0x39,0x00,0xc7,0x10,0xff,0x00,0x90,0x30,0x03,0x00,0x03,0x24,0x3f,0x00,0xc3,0x10,
+0x2e,0x00,0x02,0x2e,0x10,0x00,0x02,0x2e,0x0c,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0x0f,0x00,0x04,0x3c,0xff,0xff,0x84,0x34,0x24,0x20,0x44,0x02,0x00,0x15,0x10,0x00,
+0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,
+0x25,0x20,0x44,0x00,0x63,0x43,0x00,0x08,0x20,0x00,0xbd,0x27,0xf5,0xff,0xc7,0x14,
+0x0f,0x00,0x04,0x3c,0x71,0x4b,0x04,0x91,0x01,0x00,0x02,0x24,0x33,0x00,0x82,0x10,
+0x02,0x00,0x82,0x28,0x38,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0x38,0x00,0x86,0x10,
+0x68,0x15,0x22,0x26,0x2e,0x00,0x83,0x10,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x24,
+0x68,0x43,0x00,0x0c,0xff,0xff,0x05,0x24,0xff,0xfc,0x06,0x3c,0xff,0xff,0xc6,0x34,
+0x24,0x30,0x46,0x00,0x00,0x08,0x04,0x24,0x3d,0x43,0x00,0x0c,0xff,0xff,0x05,0x24,
+0x68,0x15,0x22,0x26,0x71,0x4b,0x44,0x90,0x01,0x00,0x03,0x24,0x07,0x00,0x83,0x10,
+0x02,0x00,0x82,0x28,0x2c,0x00,0x40,0x14,0x02,0x00,0x02,0x24,0x2c,0x00,0x82,0x10,
+0x03,0x00,0x02,0x24,0xd6,0xff,0x82,0x14,0x00,0x00,0x00,0x00,0x68,0x15,0x22,0x26,
+0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x3c,0x3d,0x43,0x00,0x0c,0x21,0x30,0x00,0x00,
+0x2f,0x44,0x00,0x08,0x0f,0x00,0x04,0x3c,0x25,0x00,0x02,0x2e,0xc7,0xff,0x40,0x14,
+0x03,0x00,0x03,0x24,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0xc1,0xff,0x40,0x14,
+0x00,0x00,0x00,0x00,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0x68,0x15,0x22,0x26,
+0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x3c,0x3d,0x43,0x00,0x0c,0x0f,0x00,0x06,0x24,
+0x46,0x44,0x00,0x08,0x00,0x08,0x04,0x24,0xcc,0xff,0x80,0x14,0x68,0x15,0x22,0x26,
+0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x24,0x3d,0x43,0x00,0x0c,0x0f,0x00,0x06,0x24,
+0x46,0x44,0x00,0x08,0x00,0x08,0x04,0x24,0xad,0xff,0x80,0x14,0x00,0x00,0x00,0x00,
+0x68,0x15,0x22,0x26,0x74,0x4b,0x44,0x8c,0x0f,0x00,0x05,0x24,0x3d,0x43,0x00,0x0c,
+0x21,0x30,0x00,0x00,0x2f,0x44,0x00,0x08,0x0f,0x00,0x04,0x3c,0xe8,0xff,0xbd,0x27,
+0x10,0x00,0xb0,0xaf,0x21,0x80,0x80,0x00,0x14,0x00,0xbf,0xaf,0x79,0x43,0x00,0x0c,
+0x21,0x20,0x00,0x00,0x40,0x01,0x44,0x34,0x21,0x18,0x40,0x00,0x1f,0x00,0x02,0x2e,
+0x00,0x23,0x04,0x00,0x10,0x00,0x40,0x10,0x10,0x00,0x05,0x2e,0x00,0x01,0x64,0x34,
+0x06,0x00,0xa0,0x10,0x00,0x23,0x04,0x00,0x21,0x10,0x00,0x02,0x14,0x00,0xbf,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,0x63,0x43,0x00,0x0c,
+0xf1,0xff,0x10,0x26,0x21,0x10,0x00,0x02,0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,0x63,0x43,0x00,0x0c,0xe2,0xff,0x10,0x26,
+0x21,0x10,0x00,0x02,0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
+0x18,0x00,0xbd,0x27,0x25,0xb0,0x02,0x3c,0x27,0x38,0x05,0x00,0x21,0x40,0x82,0x00,
+0xff,0xff,0x02,0x24,0x07,0x00,0xa2,0x10,0x25,0x38,0xe6,0x00,0x00,0x00,0x02,0x8d,
+0x00,0x00,0x00,0x00,0x24,0x10,0xe2,0x00,0x00,0x00,0x02,0xad,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x00,0x00,0x06,0xad,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x01,0x80,0x02,0x3c,0x25,0xb0,0x03,0x3c,0xe8,0x12,0x42,0x24,0x18,0x03,0x63,0x34,
+0xd8,0xff,0xbd,0x27,0x00,0x00,0x62,0xac,0x0f,0x00,0x02,0x3c,0x14,0x00,0xb1,0xaf,
+0xff,0xff,0x42,0x34,0x21,0x88,0xa0,0x00,0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,
+0x20,0x00,0xbf,0xaf,0x10,0x00,0xb0,0xaf,0x21,0x90,0xc0,0x00,0x21,0x28,0xc0,0x00,
+0x0a,0x00,0x22,0x12,0x21,0x98,0x80,0x00,0xac,0x43,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x21,0x20,0x20,0x02,0x31,0x43,0x00,0x0c,0x21,0x80,0x40,0x00,0x04,0x10,0x52,0x00,
+0x27,0x28,0x11,0x00,0x25,0x28,0xa2,0x00,0x24,0x28,0xb0,0x00,0xff,0x00,0x64,0x32,
+0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x17,0x44,0x00,0x08,0x28,0x00,0xbd,0x27,0x01,0x80,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0x74,0x13,0x63,0x24,0x18,0x03,0x42,0x34,0xe0,0xff,0xbd,0x27,
+0x00,0x00,0x43,0xac,0x18,0x00,0xbf,0xaf,0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,
+0xac,0x43,0x00,0x0c,0x21,0x88,0xa0,0x00,0x21,0x80,0x40,0x00,0x31,0x43,0x00,0x0c,
+0x21,0x20,0x20,0x02,0x24,0x80,0x11,0x02,0x06,0x10,0x50,0x00,0x18,0x00,0xbf,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x01,0x00,0x02,0x24,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0xc8,0xff,0xbd,0x27,0x2c,0x00,0xb1,0xaf,0xff,0xff,0x05,0x24,0x21,0x88,0x80,0x00,
+0x02,0x00,0x06,0x24,0x10,0x00,0xa4,0x27,0x34,0x00,0xbf,0xaf,0x30,0x00,0xb2,0xaf,
+0x97,0x45,0x00,0x0c,0x28,0x00,0xb0,0xaf,0x08,0x00,0x30,0x96,0x02,0x80,0x02,0x3c,
+0x21,0x28,0x00,0x00,0x25,0x80,0x02,0x02,0x21,0x20,0x00,0x02,0x97,0x45,0x00,0x0c,
+0x10,0x00,0x06,0x24,0x20,0x00,0x02,0x96,0x24,0x00,0x04,0x26,0x10,0x00,0xa5,0x27,
+0x03,0xff,0x42,0x30,0xc8,0x00,0x42,0x34,0x20,0x00,0x02,0xa6,0x9f,0x45,0x00,0x0c,
+0x06,0x00,0x06,0x24,0x25,0xb0,0x03,0x3c,0x50,0x00,0x62,0x34,0x00,0x00,0x44,0x8c,
+0x54,0x00,0x65,0x34,0x58,0x00,0x66,0x34,0x18,0x00,0xa4,0xaf,0x00,0x00,0xa2,0x8c,
+0x5c,0x00,0x63,0x34,0x2a,0x00,0x04,0x26,0x1c,0x00,0xa2,0xaf,0x00,0x00,0xc7,0x8c,
+0x18,0x00,0xa5,0x27,0x06,0x00,0x06,0x24,0x20,0x00,0xa7,0xaf,0x00,0x00,0x62,0x8c,
+0x1a,0x00,0x12,0x24,0x9f,0x45,0x00,0x0c,0x24,0x00,0xa2,0xaf,0x30,0x00,0x04,0x26,
+0x20,0x00,0xa5,0x27,0x9f,0x45,0x00,0x0c,0x06,0x00,0x06,0x24,0x13,0x00,0x03,0x24,
+0x14,0x00,0x23,0xae,0x0c,0x00,0x32,0xae,0x08,0x00,0x05,0x8e,0x04,0x00,0x04,0x8e,
+0xff,0xdf,0x02,0x3c,0x14,0x00,0x06,0x8e,0xff,0xff,0x42,0x34,0x10,0x00,0x07,0x8e,
+0xff,0xe0,0x03,0x24,0x24,0x28,0xa2,0x00,0x00,0x40,0x02,0x3c,0x24,0x20,0x83,0x00,
+0x25,0x28,0xa2,0x00,0xff,0x81,0x03,0x24,0xfe,0xff,0x02,0x3c,0x24,0x30,0xc3,0x00,
+0xff,0xff,0x42,0x34,0x00,0x12,0x84,0x34,0x00,0x80,0x03,0x3c,0x24,0x20,0x82,0x00,
+0x25,0x38,0xe3,0x00,0x00,0x26,0xc6,0x34,0x80,0x00,0xa5,0x34,0x20,0x00,0x02,0x24,
+0x00,0x00,0x12,0xa6,0x10,0x00,0x07,0xae,0x02,0x00,0x02,0xa2,0x14,0x00,0x06,0xae,
+0x04,0x00,0x04,0xae,0x08,0x00,0x05,0xae,0x34,0x00,0xbf,0x8f,0x30,0x00,0xb2,0x8f,
+0x2c,0x00,0xb1,0x8f,0x28,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,
+0x93,0x45,0x00,0x08,0xff,0x00,0xa5,0x30,0x00,0x00,0x85,0xa0,0xff,0xff,0xc6,0x24,
+0x01,0x00,0x84,0x24,0xfc,0xff,0xc0,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x05,0x00,0xc0,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x85,0xac,
+0xff,0xff,0xc6,0x24,0xfd,0xff,0xc0,0x14,0x04,0x00,0x84,0x24,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x21,0x38,0x80,0x00,0x08,0x00,0xc0,0x10,0xff,0xff,0xc3,0x24,
+0xff,0xff,0x06,0x24,0x00,0x00,0xa2,0x90,0xff,0xff,0x63,0x24,0x01,0x00,0xa5,0x24,
+0x00,0x00,0xe2,0xa0,0xfb,0xff,0x66,0x14,0x01,0x00,0xe7,0x24,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x80,0x00,0x21,0x38,0x80,0x00,0x08,0x00,0xc0,0x10,0xff,0xff,0xc3,0x24,
+0xff,0xff,0x06,0x24,0x00,0x00,0xa2,0x8c,0xff,0xff,0x63,0x24,0x04,0x00,0xa5,0x24,
+0x00,0x00,0xe2,0xac,0xfb,0xff,0x66,0x14,0x04,0x00,0xe7,0x24,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x80,0x00,0x2b,0x10,0xa4,0x00,0x0d,0x00,0x40,0x14,0xff,0xff,0x02,0x24,
+0xff,0xff,0xc6,0x24,0x08,0x00,0xc2,0x10,0x21,0x18,0x80,0x00,0xff,0xff,0x07,0x24,
+0x00,0x00,0xa2,0x90,0xff,0xff,0xc6,0x24,0x01,0x00,0xa5,0x24,0x00,0x00,0x62,0xa0,
+0xfb,0xff,0xc7,0x14,0x01,0x00,0x63,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x80,0x00,
+0x21,0x28,0xa6,0x00,0x21,0x18,0x86,0x00,0xff,0xff,0xc6,0x24,0xfa,0xff,0xc2,0x10,
+0x00,0x00,0x00,0x00,0xff,0xff,0x07,0x24,0xff,0xff,0xa5,0x24,0x00,0x00,0xa2,0x90,
+0xff,0xff,0x63,0x24,0xff,0xff,0xc6,0x24,0xfb,0xff,0xc7,0x14,0x00,0x00,0x62,0xa0,
+0x08,0x00,0xe0,0x03,0x21,0x10,0x80,0x00,0x0c,0x00,0xc0,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x82,0x90,0x00,0x00,0xa3,0x90,0x01,0x00,0x84,0x24,0x23,0x10,0x43,0x00,
+0x00,0x16,0x02,0x00,0x03,0x16,0x02,0x00,0x04,0x00,0x40,0x14,0x01,0x00,0xa5,0x24,
+0xff,0xff,0xc6,0x24,0xf6,0xff,0xc0,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x21,0x10,0xc0,0x00,0xea,0x45,0x00,0x08,0x21,0x18,0x86,0x00,0x00,0x00,0x82,0x90,
+0x00,0x00,0x00,0x00,0x04,0x00,0x45,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0x84,0x24,
+0xfa,0xff,0x83,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x80,0x00,
+0x09,0x00,0xc0,0x10,0xff,0xff,0xc3,0x24,0xff,0x00,0xa5,0x30,0xff,0xff,0x06,0x24,
+0x00,0x00,0x82,0x90,0xff,0xff,0x63,0x24,0x05,0x00,0x45,0x10,0x01,0x00,0x84,0x24,
+0xfb,0xff,0x66,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0xff,0xff,0x82,0x24,0x21,0x38,0x00,0x00,0x1f,0x00,0xc0,0x10,
+0x21,0x18,0x00,0x00,0x02,0x80,0x02,0x3c,0x80,0x95,0x4b,0x24,0x00,0x00,0x87,0x90,
+0x00,0x00,0xa3,0x90,0xff,0xff,0xc6,0x24,0x01,0x00,0x84,0x24,0x21,0x10,0xeb,0x00,
+0x16,0x00,0xe0,0x10,0x01,0x00,0xa5,0x24,0x14,0x00,0x60,0x10,0x21,0x48,0x6b,0x00,
+0x10,0x00,0xe3,0x10,0x20,0x00,0xe8,0x24,0x00,0x00,0x42,0x90,0x00,0x00,0x00,0x00,
+0x01,0x00,0x42,0x30,0x02,0x00,0x40,0x10,0x20,0x00,0x6a,0x24,0xff,0x00,0x07,0x31,
+0x00,0x00,0x22,0x91,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x30,0x02,0x00,0x40,0x10,
+0xff,0x00,0xe7,0x30,0xff,0x00,0x43,0x31,0xff,0x00,0x63,0x30,0x03,0x00,0xe3,0x14,
+0x00,0x00,0x00,0x00,0xe5,0xff,0xc0,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x23,0x10,0xe3,0x00,0x21,0x18,0x80,0x00,0x00,0x00,0xa2,0x90,0x01,0x00,0xa5,0x24,
+0x00,0x00,0x82,0xa0,0xfc,0xff,0x40,0x14,0x01,0x00,0x84,0x24,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x60,0x00,0x21,0x38,0x80,0x00,0xff,0xff,0x03,0x24,0xff,0xff,0xc6,0x24,
+0x06,0x00,0xc3,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x90,0x01,0x00,0xa5,0x24,
+0x00,0x00,0x82,0xa0,0xf9,0xff,0x40,0x14,0x01,0x00,0x84,0x24,0x08,0x00,0xe0,0x03,
+0x21,0x10,0xe0,0x00,0x00,0x00,0x82,0x80,0x39,0x46,0x00,0x08,0x21,0x18,0x80,0x00,
+0x01,0x00,0x84,0x24,0x00,0x00,0x82,0x80,0x00,0x00,0x00,0x00,0xfc,0xff,0x40,0x14,
+0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x90,0x01,0x00,0xa5,0x24,0x00,0x00,0x82,0xa0,
+0xfc,0xff,0x40,0x14,0x01,0x00,0x84,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0x12,0x00,0xc0,0x10,0x21,0x18,0x80,0x00,0x00,0x00,0x82,0x80,0x4a,0x46,0x00,0x08,
+0x00,0x00,0x00,0x00,0x01,0x00,0x84,0x24,0x00,0x00,0x82,0x80,0x00,0x00,0x00,0x00,
+0xfc,0xff,0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x90,0x01,0x00,0xa5,0x24,
+0x00,0x00,0x82,0xa0,0x05,0x00,0x40,0x10,0x01,0x00,0x84,0x24,0xff,0xff,0xc6,0x24,
+0xf9,0xff,0xc0,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xa0,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x60,0x00,0x00,0x00,0x83,0x90,0x00,0x00,0xa2,0x90,0x01,0x00,0x84,0x24,
+0x23,0x10,0x62,0x00,0x00,0x16,0x02,0x00,0x03,0x16,0x02,0x00,0x03,0x00,0x40,0x14,
+0x01,0x00,0xa5,0x24,0xf7,0xff,0x60,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x21,0x10,0x00,0x00,0x0b,0x00,0xc0,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0xa2,0x90,0x00,0x00,0x83,0x90,0xff,0xff,0xc6,0x24,0x23,0x10,0x62,0x00,
+0x00,0x16,0x02,0x00,0x03,0x16,0x02,0x00,0x03,0x00,0x40,0x14,0x01,0x00,0xa5,0x24,
+0xf5,0xff,0x60,0x14,0x01,0x00,0x84,0x24,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x00,0x00,0x83,0x80,0x00,0x2e,0x05,0x00,0x21,0x10,0x80,0x00,0x7b,0x46,0x00,0x08,
+0x03,0x2e,0x05,0x00,0x07,0x00,0x60,0x10,0x01,0x00,0x42,0x24,0x00,0x00,0x43,0x80,
+0x00,0x00,0x00,0x00,0xfb,0xff,0x65,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,0x00,0x00,0x82,0x80,
+0x87,0x46,0x00,0x08,0x21,0x18,0x80,0x00,0x01,0x00,0x63,0x24,0x00,0x00,0x62,0x80,
+0x00,0x00,0x00,0x00,0xfc,0xff,0x40,0x14,0x23,0x10,0x64,0x00,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0xe0,0xff,0xbd,0x27,0x10,0x00,0xb0,0xaf,0x21,0x80,0xa0,0x00,
+0x14,0x00,0xb1,0xaf,0x18,0x00,0xbf,0xaf,0x21,0x88,0x80,0x00,0x81,0x46,0x00,0x0c,
+0x00,0x86,0x10,0x00,0x21,0x18,0x51,0x00,0x03,0x86,0x10,0x00,0x00,0x00,0x62,0x80,
+0x00,0x00,0x00,0x00,0x0a,0x00,0x50,0x10,0x21,0x10,0x60,0x00,0xff,0xff,0x63,0x24,
+0x2b,0x10,0x71,0x00,0xf9,0xff,0x40,0x10,0x21,0x10,0x00,0x00,0x18,0x00,0xbf,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0x21,0x30,0x80,0x00,0x0d,0x00,0xa0,0x10,0xff,0xff,0xa3,0x24,
+0x00,0x00,0x82,0x80,0x00,0x00,0x00,0x00,0x09,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0xff,0xff,0x05,0x24,0xff,0xff,0x63,0x24,0x05,0x00,0x65,0x10,0x01,0x00,0xc6,0x24,
+0x00,0x00,0xc2,0x80,0x00,0x00,0x00,0x00,0xfa,0xff,0x40,0x14,0x00,0x00,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x23,0x10,0xc4,0x00,0x00,0x00,0x82,0x90,0x00,0x00,0x00,0x00,
+0x19,0x00,0x40,0x10,0x21,0x40,0x00,0x00,0x00,0x00,0xa9,0x80,0x00,0x00,0x00,0x00,
+0x17,0x00,0x20,0x11,0x21,0x30,0xa0,0x00,0x00,0x3e,0x02,0x00,0x03,0x3e,0x07,0x00,
+0x21,0x18,0x20,0x01,0x15,0x00,0xe3,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0xc6,0x24,
+0x00,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,0x00,0x1e,0x02,0x00,0x03,0x1e,0x03,0x00,
+0xf8,0xff,0x60,0x14,0x00,0x16,0x02,0x00,0x03,0x16,0x02,0x00,0x06,0x00,0x40,0x10,
+0x00,0x00,0x00,0x00,0x01,0x00,0x84,0x24,0x00,0x00,0x82,0x90,0x00,0x00,0x00,0x00,
+0xeb,0xff,0x40,0x14,0x01,0x00,0x08,0x25,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x01,
+0x00,0x00,0xa2,0x90,0xcc,0x46,0x00,0x08,0x00,0x16,0x02,0x00,0x00,0x00,0xc2,0x90,
+0xcc,0x46,0x00,0x08,0x00,0x16,0x02,0x00,0x00,0x00,0x87,0x90,0x00,0x00,0x00,0x00,
+0x14,0x00,0xe0,0x10,0x21,0x10,0x80,0x00,0x00,0x00,0xa4,0x90,0x00,0x00,0x00,0x00,
+0x00,0x1e,0x04,0x00,0x03,0x1e,0x03,0x00,0x09,0x00,0x60,0x10,0x21,0x30,0xa0,0x00,
+0x00,0x3e,0x07,0x00,0x03,0x3e,0x07,0x00,0x0b,0x00,0xe3,0x10,0x01,0x00,0xc6,0x24,
+0x00,0x00,0xc3,0x80,0x00,0x00,0x00,0x00,0xfb,0xff,0x60,0x14,0x00,0x00,0x00,0x00,
+0x01,0x00,0x42,0x24,0x00,0x00,0x47,0x90,0x00,0x00,0x00,0x00,0xf0,0xff,0xe0,0x14,
+0x00,0x00,0x00,0x00,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x18,0x00,0xbf,0xaf,
+0x21,0x80,0x80,0x00,0x1d,0x00,0x80,0x10,0x21,0x88,0xa0,0x00,0xb8,0x46,0x00,0x0c,
+0x21,0x20,0x00,0x02,0x21,0x80,0x02,0x02,0x00,0x00,0x02,0x82,0x21,0x28,0x20,0x02,
+0x21,0x20,0x00,0x02,0x22,0x00,0x40,0x10,0x21,0x18,0x00,0x00,0xdc,0x46,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x10,0x21,0x18,0x40,0x00,0x00,0x00,0x42,0x80,
+0x00,0x00,0x00,0x00,0x0a,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,
+0xa8,0x96,0x43,0xac,0x21,0x18,0x00,0x02,0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x21,0x10,0x60,0x00,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0x00,0x00,0x60,0xa0,0x0d,0x47,0x00,0x08,0x01,0x00,0x63,0x24,0x02,0x80,0x02,0x3c,
+0xa8,0x96,0x50,0x8c,0x00,0x00,0x00,0x00,0xf3,0xff,0x00,0x12,0x21,0x18,0x00,0x00,
+0xb8,0x46,0x00,0x0c,0x21,0x20,0x00,0x02,0x21,0x80,0x02,0x02,0x00,0x00,0x02,0x82,
+0x21,0x28,0x20,0x02,0x21,0x20,0x00,0x02,0xe0,0xff,0x40,0x14,0x21,0x18,0x00,0x00,
+0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x02,0x80,0x02,0x3c,
+0xa8,0x96,0x40,0xac,0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0xe0,0xff,0xbd,0x27,0x18,0x00,0xb2,0xaf,0x14,0x00,0xb1,0xaf,0x1c,0x00,0xbf,0xaf,
+0x10,0x00,0xb0,0xaf,0x00,0x00,0x90,0x8c,0x21,0x90,0x80,0x00,0x21,0x88,0xa0,0x00,
+0x21,0x18,0x00,0x00,0x0f,0x00,0x00,0x12,0x21,0x20,0x00,0x02,0xb8,0x46,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x21,0x80,0x02,0x02,0x00,0x00,0x02,0x82,0x21,0x28,0x20,0x02,
+0x21,0x20,0x00,0x02,0x07,0x00,0x40,0x10,0x21,0x18,0x00,0x00,0xdc,0x46,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x21,0x18,0x40,0x00,0x09,0x00,0x40,0x14,0x00,0x00,0x42,0xae,
+0x21,0x18,0x00,0x02,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x21,0x10,0x60,0x00,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0x00,0x00,0x42,0x80,0x00,0x00,0x00,0x00,0xf5,0xff,0x40,0x10,0x01,0x00,0x64,0x24,
+0x00,0x00,0x60,0xa0,0x46,0x47,0x00,0x08,0x00,0x00,0x44,0xae,0xd8,0xff,0xbd,0x27,
+0x14,0x00,0xb1,0xaf,0x21,0x88,0x80,0x00,0x21,0x20,0xa0,0x00,0x1c,0x00,0xb3,0xaf,
+0x18,0x00,0xb2,0xaf,0x20,0x00,0xbf,0xaf,0x10,0x00,0xb0,0xaf,0x81,0x46,0x00,0x0c,
+0x21,0x98,0xa0,0x00,0x21,0x90,0x40,0x00,0x08,0x00,0x40,0x16,0x21,0x10,0x20,0x02,
+0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,0x81,0x46,0x00,0x0c,
+0x21,0x20,0x20,0x02,0x21,0x80,0x40,0x00,0x2a,0x10,0x52,0x00,0x0a,0x00,0x40,0x14,
+0x00,0x00,0x00,0x00,0x21,0x20,0x20,0x02,0x21,0x28,0x60,0x02,0x21,0x30,0x40,0x02,
+0xd4,0x45,0x00,0x0c,0xff,0xff,0x10,0x26,0x0b,0x00,0x40,0x10,0x2a,0x18,0x12,0x02,
+0xf8,0xff,0x60,0x10,0x01,0x00,0x31,0x26,0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,
+0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,
+0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,0x62,0x47,0x00,0x08,0x21,0x10,0x20,0x02,
+0x01,0x80,0x02,0x3c,0xc0,0xff,0xbd,0x27,0x08,0x1e,0x44,0x24,0x25,0xb0,0x02,0x3c,
+0x28,0x00,0xb4,0xaf,0x02,0x80,0x03,0x3c,0x25,0xb0,0x14,0x3c,0x18,0x03,0x42,0x34,
+0x38,0x00,0xbe,0xaf,0x34,0x00,0xb7,0xaf,0x30,0x00,0xb6,0xaf,0x2c,0x00,0xb5,0xaf,
+0x24,0x00,0xb3,0xaf,0x3c,0x00,0xbf,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,
+0x18,0x00,0xb0,0xaf,0x68,0x15,0x73,0x24,0x00,0x00,0x44,0xac,0x02,0x80,0x16,0x3c,
+0x02,0x80,0x15,0x3c,0xc4,0x02,0x9e,0x36,0x64,0x03,0x97,0x36,0x01,0x80,0x04,0x3c,
+0x08,0x1e,0x82,0x24,0x18,0x03,0x83,0x36,0x00,0x00,0x62,0xac,0xa0,0x02,0x87,0x36,
+0x00,0x00,0xe4,0x8c,0xd8,0x63,0x63,0x8e,0xff,0x0f,0x02,0x3c,0xff,0xff,0x46,0x34,
+0x24,0x80,0x86,0x00,0x01,0x00,0x05,0x3c,0x01,0x00,0x63,0x24,0x2b,0x10,0xb0,0x00,
+0x07,0x00,0x40,0x10,0xd8,0x63,0x63,0xae,0xa4,0x02,0x82,0x36,0x00,0x00,0x51,0x8c,
+0x00,0xb0,0x03,0x3c,0x25,0x80,0x03,0x02,0x00,0x00,0x11,0xae,0x00,0x00,0xe0,0xac,
+0xb0,0x02,0x84,0x36,0x00,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x24,0x80,0x46,0x00,
+0x2b,0x18,0xb0,0x00,0x08,0x00,0x60,0x10,0xc0,0x02,0x82,0x36,0x00,0xb0,0x02,0x3c,
+0x25,0x80,0x02,0x02,0x00,0x00,0x11,0x8e,0xb4,0x02,0x82,0x36,0x00,0x00,0x51,0xac,
+0x00,0x00,0x80,0xac,0xc0,0x02,0x82,0x36,0x00,0x00,0x50,0x8c,0xff,0x00,0x08,0x3c,
+0xff,0xff,0x02,0x35,0x2b,0x10,0x50,0x00,0x47,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x82,0x8e,0x00,0xff,0x06,0x3c,0xac,0x02,0x84,0x36,0x01,0x00,0x45,0x24,
+0xbc,0x02,0x83,0x36,0xff,0x00,0xc2,0x34,0x00,0xfd,0x07,0x3c,0x00,0x00,0x85,0xac,
+0x00,0x00,0x70,0xac,0x24,0x18,0x02,0x02,0x07,0x00,0xe2,0x34,0x00,0x00,0x85,0x8c,
+0x52,0x03,0x62,0x10,0x25,0xb0,0x12,0x3c,0x2b,0x10,0x43,0x00,0xa2,0x00,0x40,0x14,
+0xa4,0x00,0xe2,0x34,0x00,0xf8,0x04,0x3c,0x15,0x00,0x82,0x34,0x57,0x03,0x62,0x10,
+0x2b,0x10,0x43,0x00,0xc8,0x00,0x40,0x14,0x00,0xf9,0x05,0x3c,0x00,0xf0,0x05,0x3c,
+0x20,0x00,0xa2,0x34,0x67,0x03,0x62,0x10,0x2b,0x10,0x43,0x00,0x20,0x01,0x40,0x14,
+0x10,0x00,0x82,0x34,0x70,0x03,0x65,0x10,0x2b,0x10,0xa3,0x00,0xc8,0x01,0x40,0x14,
+0x02,0x00,0xa2,0x34,0x00,0xd0,0x02,0x3c,0x2a,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,
+0xaf,0x02,0x40,0x14,0x00,0xe0,0x02,0x3c,0x00,0xc0,0x02,0x3c,0xbb,0x03,0x62,0x10,
+0xff,0x00,0x03,0x3c,0x00,0xf0,0x02,0x3c,0x24,0x30,0x02,0x02,0x18,0x00,0xc2,0x10,
+0x02,0x1d,0x10,0x00,0x00,0x70,0x05,0x3c,0x24,0x10,0x05,0x02,0x02,0x4f,0x02,0x00,
+0x0f,0x00,0x02,0x3c,0xff,0xff,0x42,0x34,0x00,0x50,0x07,0x3c,0xff,0x00,0x68,0x30,
+0xff,0x00,0x04,0x32,0x96,0x01,0xc7,0x10,0x24,0x18,0x02,0x02,0x2b,0x10,0xe6,0x00,
+0x8a,0x01,0x40,0x14,0x00,0x80,0x02,0x3c,0x00,0x20,0x02,0x3c,0x1a,0x03,0xc2,0x10,
+0x2b,0x10,0x46,0x00,0x82,0x02,0x40,0x14,0x00,0x30,0x02,0x3c,0x17,0x03,0xc0,0x10,
+0x80,0x10,0x08,0x00,0x00,0x10,0x02,0x3c,0x14,0x03,0xc2,0x10,0x80,0x10,0x08,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x00,0x00,0xe2,0x92,0x25,0xb0,0x07,0x3c,
+0xc8,0x7d,0xc2,0xa2,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0xc8,0x7d,0xc2,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x30,0x4e,0x00,0x40,0x10,
+0x02,0x80,0x03,0x3c,0x00,0x40,0x62,0x8e,0xf0,0xff,0x03,0x24,0xd7,0x42,0x60,0xa2,
+0x24,0x10,0x43,0x00,0x01,0x00,0x42,0x34,0x00,0x40,0x62,0xae,0xc8,0x7d,0xc2,0x92,
+0x00,0x00,0x00,0x00,0x02,0x00,0x42,0x30,0x3d,0x00,0x40,0x10,0x0f,0xff,0x03,0x24,
+0x00,0x40,0x62,0x8e,0x00,0x00,0x00,0x00,0x24,0x10,0x43,0x00,0x10,0x00,0x42,0x34,
+0x00,0x40,0x62,0xae,0xc8,0x7d,0xc2,0x92,0x00,0x00,0x00,0x00,0x04,0x00,0x42,0x30,
+0x30,0x00,0x40,0x10,0xff,0xf0,0x03,0x24,0x00,0x40,0x62,0x8e,0x00,0x00,0x00,0x00,
+0x24,0x10,0x43,0x00,0x00,0x01,0x42,0x34,0x25,0xb0,0x05,0x3c,0x00,0x40,0x62,0xae,
+0x4c,0x00,0xa3,0x34,0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,0x03,0x00,0x42,0x30,
+0x05,0x00,0x40,0x14,0xff,0xff,0x02,0x3c,0x00,0x40,0x63,0x8e,0xff,0x0f,0x42,0x34,
+0x24,0x18,0x62,0x00,0x00,0x40,0x63,0xae,0x00,0x7b,0xa4,0x8e,0x01,0x80,0x06,0x3c,
+0x08,0x1f,0xc2,0x24,0x18,0x03,0xa3,0x34,0x00,0x7b,0xa6,0x26,0x00,0x00,0x62,0xac,
+0x10,0x00,0x86,0x10,0x02,0x80,0x02,0x3c,0xbf,0x00,0xb2,0x34,0x68,0x15,0x51,0x24,
+0x21,0x80,0xc0,0x00,0x00,0x00,0x42,0x92,0x00,0x00,0x00,0x00,0x04,0x00,0x42,0x2c,
+0x09,0x00,0x40,0x10,0x02,0x80,0x07,0x3c,0x98,0x65,0x24,0x8e,0x8b,0x07,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x7b,0xa2,0x8e,0x00,0x00,0x00,0x00,0xf5,0xff,0x50,0x14,
+0x00,0x00,0x00,0x00,0x02,0x80,0x07,0x3c,0x08,0x08,0xe4,0x24,0x21,0x28,0x00,0x00,
+0x21,0x30,0x00,0x00,0x31,0x1c,0x00,0x0c,0x21,0x38,0x00,0x00,0x9a,0x47,0x00,0x08,
+0x01,0x80,0x04,0x3c,0x00,0x40,0x62,0x8e,0x30,0x48,0x00,0x08,0x24,0x10,0x43,0x00,
+0x00,0x40,0x62,0x8e,0x04,0x43,0x64,0x92,0x24,0x10,0x43,0x00,0x00,0x40,0x62,0xae,
+0x27,0x48,0x00,0x08,0x04,0x43,0x64,0xae,0x68,0x15,0x66,0x24,0x00,0x40,0xc2,0x8c,
+0xd7,0x42,0xc4,0x90,0xf0,0xff,0x03,0x24,0x24,0x10,0x43,0x00,0xb3,0xff,0x80,0x14,
+0x00,0x40,0xc2,0xac,0x1c,0x00,0x04,0x24,0x58,0x0c,0xe5,0x34,0x50,0x0c,0xe3,0x34,
+0x01,0x00,0x02,0x24,0xd7,0x42,0xc2,0xa0,0x00,0x00,0x64,0xa0,0x00,0x00,0xa4,0xa0,
+0x1d,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xb2,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,
+0x3f,0x00,0x40,0x14,0xaf,0x00,0xe2,0x34,0x20,0x00,0xe2,0x34,0xc0,0x02,0x62,0x10,
+0x2b,0x10,0x43,0x00,0xe3,0x00,0x40,0x14,0x29,0x00,0xe2,0x34,0x15,0x00,0xe2,0x34,
+0x0c,0x03,0x62,0x10,0x2b,0x10,0x43,0x00,0x9d,0x01,0x40,0x14,0x17,0x00,0xe2,0x34,
+0x09,0x00,0xe2,0x34,0xd8,0x03,0x62,0x10,0x2b,0x10,0x62,0x00,0x81,0x02,0x40,0x14,
+0x14,0x00,0xe2,0x34,0x64,0xff,0x62,0x14,0x00,0xf0,0x02,0x3c,0xff,0x00,0x07,0x3c,
+0x00,0xff,0xe7,0x34,0x24,0x10,0x07,0x02,0x7a,0xff,0x40,0x10,0xc0,0x02,0x82,0x36,
+0x04,0x43,0x64,0x92,0xff,0x00,0x02,0x3c,0x24,0x10,0x02,0x02,0x00,0xff,0x03,0x32,
+0x02,0x14,0x02,0x00,0x02,0x1a,0x03,0x00,0xfb,0xff,0x45,0x24,0x1c,0x43,0x62,0xa2,
+0x00,0x01,0x84,0x34,0xfb,0xff,0x66,0x24,0xc0,0x02,0x82,0x36,0x04,0x43,0x64,0xae,
+0x1d,0x43,0x65,0xa2,0x1f,0x43,0x66,0xa2,0x1e,0x43,0x63,0xa2,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x05,0x00,0xa2,0x34,0x91,0x02,0x62,0x10,
+0x2b,0x10,0x43,0x00,0x8e,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0xde,0x02,0x65,0x10,
+0x2b,0x10,0xa3,0x00,0x32,0x01,0x40,0x14,0x02,0x00,0xa2,0x34,0x17,0x00,0x82,0x34,
+0x61,0x04,0x62,0x10,0x2b,0x10,0x62,0x00,0xa9,0x03,0x40,0x14,0x18,0x00,0x82,0x34,
+0x3d,0xff,0x62,0x14,0x00,0xf0,0x02,0x3c,0x74,0x0b,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0xa8,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,0x95,0x00,0x40,0x14,0x0c,0x00,0xc2,0x34,
+0xaa,0x00,0xe2,0x34,0xdc,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,0xd9,0x00,0x40,0x14,
+0xac,0x00,0xe2,0x34,0xa6,0x00,0xe2,0x34,0x1c,0x04,0x62,0x10,0x2b,0x10,0x62,0x00,
+0x69,0x03,0x40,0x14,0xa7,0x00,0xe2,0x34,0x27,0xff,0x62,0x14,0x00,0xf0,0x02,0x3c,
+0x00,0xff,0x02,0x32,0xff,0x00,0x04,0x3c,0x02,0x8a,0x02,0x00,0x24,0x18,0x04,0x02,
+0x01,0x00,0x02,0x24,0xa6,0x04,0x22,0x12,0x02,0x1c,0x03,0x00,0x02,0x00,0x02,0x24,
+0xc9,0x04,0x22,0x12,0x03,0x00,0x02,0x24,0xdf,0x04,0x22,0x12,0x04,0x00,0x02,0x24,
+0xd1,0x04,0x22,0x12,0x08,0x00,0x02,0x24,0x2e,0x05,0x22,0x12,0x09,0x00,0x02,0x24,
+0x1e,0x05,0x22,0x12,0x0a,0x00,0x02,0x24,0x0e,0x05,0x22,0x12,0x0b,0x00,0x02,0x24,
+0xfe,0x04,0x22,0x12,0x0c,0x00,0x02,0x24,0x5e,0x05,0x22,0x12,0x0d,0x00,0x02,0x24,
+0x4e,0x05,0x22,0x12,0x0e,0x00,0x02,0x24,0x3e,0x05,0x22,0x12,0x0f,0x00,0x02,0x24,
+0x2e,0x05,0x22,0x12,0x10,0x00,0x02,0x24,0x22,0xff,0x22,0x16,0xc0,0x02,0x82,0x36,
+0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,
+0x80,0x10,0x02,0x00,0x21,0x10,0x53,0x00,0x4c,0x51,0x43,0x94,0x48,0x51,0x44,0x94,
+0x25,0xb0,0x06,0x3c,0x00,0x1c,0x03,0x00,0x21,0x20,0x83,0x00,0x00,0x00,0xc4,0xaf,
+0x58,0x51,0x45,0x8c,0x54,0x51,0x43,0x8c,0x50,0x51,0x44,0x94,0xc8,0x02,0xc6,0x34,
+0x21,0x18,0x65,0x00,0x00,0x1c,0x03,0x00,0x21,0x20,0x83,0x00,0xc0,0x02,0x82,0x36,
+0x00,0x00,0xc4,0xac,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x66,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,0xbf,0x00,0x40,0x14,0x12,0x00,0x82,0x34,
+0x00,0xf1,0x04,0x3c,0x01,0x00,0x82,0x34,0xc1,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,
+0xb7,0x01,0x40,0x14,0x02,0x00,0x82,0x34,0xe3,0xfe,0x64,0x14,0x00,0xf0,0x02,0x3c,
+0xff,0x00,0x04,0x3c,0x00,0xff,0x84,0x34,0x24,0x10,0x04,0x02,0x02,0x8a,0x02,0x00,
+0x80,0x1a,0x11,0x00,0x00,0xf4,0x63,0x24,0x94,0x00,0x82,0x36,0x00,0x00,0x51,0xa4,
+0x26,0xb0,0x04,0x3c,0x42,0x89,0x03,0x00,0x98,0x00,0x86,0x36,0xff,0x01,0x02,0x24,
+0x10,0x00,0x03,0x24,0x9a,0x00,0x85,0x36,0x00,0x00,0xa2,0xa4,0x7c,0x00,0x89,0x34,
+0x00,0x00,0xc3,0xa4,0x01,0x00,0x02,0x24,0x04,0x00,0x03,0x24,0x96,0x00,0x87,0x36,
+0x7a,0x00,0x84,0x34,0xb0,0x03,0x88,0x36,0x25,0xb0,0x06,0x3c,0x00,0x00,0xe2,0xa4,
+0x44,0x00,0xc6,0x34,0x00,0x00,0x83,0xa0,0x00,0x00,0x11,0xad,0x00,0x00,0x31,0xa5,
+0x00,0x00,0xc3,0x94,0xff,0xfd,0x02,0x24,0x24,0x18,0x62,0x00,0x00,0x00,0xc3,0xa4,
+0x00,0x00,0xc2,0x94,0x00,0x00,0x00,0x00,0x00,0x02,0x42,0x34,0x00,0x00,0xc2,0xa4,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x65,0x01,0x67,0x10,0x2b,0x10,0xe3,0x00,0xc5,0x00,0x40,0x14,0x02,0x00,0xe2,0x34,
+0x07,0x00,0xa2,0x34,0xfc,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,0xa9,0x01,0x40,0x14,
+0x20,0x00,0xa2,0x34,0xb0,0xfe,0x62,0x14,0x00,0xf0,0x02,0x3c,0xff,0x00,0x03,0x3c,
+0x00,0xff,0x63,0x34,0x24,0x10,0x03,0x02,0x02,0x3a,0x02,0x00,0x80,0x04,0xe0,0x10,
+0x02,0x80,0x04,0x3c,0x05,0x00,0x02,0x24,0xc2,0xfe,0xe2,0x14,0xc0,0x02,0x82,0x36,
+0x02,0x80,0x06,0x3c,0x8f,0x7d,0xc2,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x2e,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,0x98,0x00,0x40,0x14,0x0e,0x00,0xc2,0x34,
+0x01,0x00,0xc2,0x34,0xab,0x03,0x62,0x10,0x2b,0x10,0x43,0x00,0x48,0x01,0x40,0x14,
+0x00,0xff,0x02,0x3c,0x94,0xfe,0x66,0x14,0x00,0xf0,0x02,0x3c,0x5b,0x4e,0x00,0x0c,
+0x21,0x20,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x4c,0x02,0x62,0x10,0x2b,0x10,0x43,0x00,0xa6,0x00,0x40,0x14,
+0xa1,0x00,0xe2,0x34,0x22,0x00,0xe2,0x34,0xbd,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,
+0x88,0x01,0x40,0x14,0x00,0x20,0x02,0x3c,0x28,0x00,0xe2,0x34,0x82,0xfe,0x62,0x14,
+0x00,0xf0,0x02,0x3c,0x0f,0x00,0x04,0x3c,0xff,0xff,0x85,0x34,0x60,0x00,0x06,0x24,
+0xba,0x44,0x00,0x0c,0x24,0x00,0x04,0x24,0x84,0x0a,0x00,0x0c,0xe8,0x03,0x04,0x24,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x0f,0x00,0x06,0x3c,0x24,0x00,0x04,0x24,0xdd,0x44,0x00,0x0c,0xff,0xff,0xc5,0x34,
+0x1f,0x00,0x51,0x30,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,0x00,0x00,0xd1,0xa3,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x18,0x02,0xc2,0x10,
+0x2b,0x10,0x46,0x00,0x01,0x01,0x40,0x14,0x00,0xa0,0x02,0x3c,0x00,0x60,0x02,0x3c,
+0x04,0x00,0xc2,0x10,0x80,0x10,0x08,0x00,0x7a,0xfe,0xc5,0x14,0xc0,0x02,0x82,0x36,
+0x80,0x10,0x08,0x00,0x21,0x10,0x48,0x00,0x21,0x10,0x53,0x00,0x21,0x10,0x49,0x00,
+0xc1,0x43,0x44,0xa0,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3f,0x03,0x62,0x10,0x2b,0x10,0x62,0x00,0xb6,0x02,0x40,0x14,
+0xad,0x00,0xe2,0x34,0xc7,0x03,0x62,0x10,0xae,0x00,0xe2,0x34,0x4e,0xfe,0x62,0x14,
+0x00,0xf0,0x02,0x3c,0xff,0x00,0x02,0x3c,0x24,0x20,0x02,0x02,0x00,0xff,0x05,0x32,
+0x02,0x24,0x04,0x00,0x69,0x4f,0x00,0x0c,0x02,0x2a,0x05,0x00,0x00,0x00,0xc2,0xa3,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x4b,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,0x17,0x01,0x40,0x14,0x03,0x00,0xa2,0x34,
+0x82,0x03,0x62,0x10,0x08,0x00,0xa2,0x34,0x3b,0xfe,0x62,0x14,0x00,0xf0,0x02,0x3c,
+0x00,0xff,0x02,0x32,0x02,0x82,0x02,0x00,0xcc,0x02,0x83,0x36,0x00,0x00,0x70,0xac,
+0x12,0x04,0x00,0x12,0x01,0x00,0x02,0x24,0x9c,0x04,0x02,0x12,0x00,0x00,0x00,0x00,
+0x7a,0x42,0x00,0x0c,0x21,0x20,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x4e,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,
+0xe4,0x00,0x40,0x14,0x00,0xff,0x02,0x32,0x13,0x00,0x82,0x34,0x4c,0x03,0x62,0x10,
+0x14,0x00,0x82,0x34,0x24,0xfe,0x62,0x14,0x00,0xf0,0x02,0x3c,0xd3,0x0a,0x00,0x0c,
+0xfd,0x00,0x04,0x24,0x10,0x10,0x03,0x3c,0xa0,0x00,0x82,0x36,0x10,0x10,0x63,0x34,
+0x00,0xc0,0x07,0x3c,0x25,0xb0,0x06,0x3c,0x00,0x00,0x43,0xac,0xa4,0x00,0x84,0x36,
+0x00,0xa1,0xe7,0x34,0xa8,0x00,0xc6,0x34,0xc0,0x02,0x82,0x36,0x00,0x00,0x80,0xac,
+0x00,0x00,0xc7,0xac,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x60,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,0xf6,0x00,0x40,0x14,0x03,0x00,0xa2,0x34,
+0x4b,0x03,0x62,0x10,0x04,0x00,0xa2,0x34,0x0b,0xfe,0x62,0x14,0x00,0xf0,0x02,0x3c,
+0xf4,0x63,0x62,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x61,0x02,0x62,0x10,
+0x2b,0x10,0x62,0x00,0xfe,0x00,0x40,0x14,0x01,0x00,0x02,0x24,0x0f,0x00,0xc2,0x34,
+0x63,0x03,0x62,0x10,0x10,0x00,0xc2,0x34,0xfb,0xfd,0x62,0x14,0x00,0xf0,0x02,0x3c,
+0x00,0xff,0x03,0x32,0x00,0xff,0x02,0x34,0x9d,0x03,0x62,0x10,0xc0,0x02,0x82,0x36,
+0x8c,0x65,0x60,0xae,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x47,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,0x02,0x01,0x40,0x14,0x03,0x00,0xe2,0x34,
+0x8d,0x03,0x62,0x10,0x04,0x00,0xe2,0x34,0xeb,0xfd,0x62,0x14,0x00,0xf0,0x02,0x3c,
+0x1e,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x9b,0x01,0x62,0x10,0x2b,0x10,0x43,0x00,
+0xcf,0x00,0x40,0x14,0xa2,0x00,0xe2,0x34,0xa0,0x00,0xe2,0x34,0xde,0xfd,0x62,0x14,
+0x00,0xf0,0x02,0x3c,0x00,0x0f,0x02,0x32,0x02,0x22,0x02,0x00,0x01,0x00,0x03,0x24,
+0x3c,0x04,0x83,0x10,0x02,0x00,0x02,0x24,0x34,0x04,0x82,0x10,0x03,0x00,0x02,0x24,
+0x46,0x03,0x82,0x10,0x00,0x00,0x00,0x00,0xde,0x4f,0x00,0x0c,0x21,0x20,0x00,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x46,0x02,0x62,0x10,0x2b,0x10,0x62,0x00,0xe6,0xfd,0x40,0x14,0xc0,0x02,0x82,0x36,
+0x18,0x00,0xe2,0x34,0x45,0x03,0x62,0x10,0x19,0x00,0xe2,0x34,0xc6,0xfd,0x62,0x14,
+0x00,0xf0,0x02,0x3c,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x94,0x0e,0x83,0x36,
+0x9c,0x0e,0x82,0x36,0xa4,0x0e,0x84,0x36,0xac,0x0e,0x87,0x36,0x00,0x00,0x65,0x8c,
+0x00,0x00,0x48,0x8c,0x00,0x00,0x8a,0x8c,0x00,0x00,0xe6,0x8c,0x02,0x80,0x07,0x3c,
+0x68,0x15,0xed,0x24,0xb4,0x0e,0x82,0x36,0x00,0x00,0x47,0x8c,0x0c,0x40,0xa3,0x8d,
+0xff,0x03,0x02,0x3c,0x10,0x40,0xa4,0x8d,0x24,0x28,0xa2,0x00,0x24,0x30,0xc2,0x00,
+0xbc,0x0e,0x82,0x36,0x00,0x00,0x4b,0x8c,0x00,0xfc,0x02,0x24,0x02,0x2c,0x05,0x00,
+0x24,0x18,0x62,0x00,0x02,0x34,0x06,0x00,0x24,0x20,0x82,0x00,0xc4,0x0e,0x82,0x36,
+0x25,0x18,0x65,0x00,0x25,0x20,0x86,0x00,0x00,0x00,0x45,0x8c,0xff,0x03,0x06,0x3c,
+0xf0,0xff,0x02,0x3c,0xff,0x03,0x42,0x34,0x24,0x38,0xe6,0x00,0x82,0x39,0x07,0x00,
+0x24,0x20,0x82,0x00,0x24,0x40,0x06,0x01,0x08,0x40,0xa9,0x8d,0x25,0x20,0x87,0x00,
+0xcc,0x0e,0x8c,0x36,0xff,0x03,0x07,0x3c,0x00,0x00,0x86,0x8d,0x24,0x18,0x62,0x00,
+0x24,0x50,0x47,0x01,0x24,0x58,0x67,0x01,0x82,0x41,0x08,0x00,0xff,0x9f,0x02,0x3c,
+0x0f,0xc0,0x07,0x3c,0xff,0xff,0xe7,0x34,0xff,0xff,0x42,0x34,0x25,0x18,0x68,0x00,
+0x24,0x48,0x22,0x01,0x24,0x18,0x67,0x00,0xff,0x03,0x02,0x3c,0x24,0x20,0x87,0x00,
+0xff,0x00,0x07,0x3c,0x24,0x28,0xa2,0x00,0x24,0x30,0xc2,0x00,0x00,0x51,0x0a,0x00,
+0x00,0x20,0x02,0x3c,0x00,0x59,0x0b,0x00,0x00,0xff,0xe7,0x34,0x25,0x48,0x22,0x01,
+0x25,0x18,0x6a,0x00,0x25,0x20,0x8b,0x00,0x02,0x2c,0x05,0x00,0x02,0x34,0x06,0x00,
+0x24,0x10,0x07,0x02,0x08,0x40,0xa9,0xad,0x0c,0x40,0xa3,0xad,0x10,0x40,0xa4,0xad,
+0x14,0x40,0xa5,0xa5,0x4e,0x03,0x40,0x10,0x16,0x40,0xa6,0xa5,0xff,0x00,0x02,0x3c,
+0x24,0x10,0x02,0x02,0x02,0x14,0x02,0x00,0x02,0x1a,0x10,0x00,0xc7,0x42,0xa2,0xa1,
+0xc3,0x42,0xa3,0xa1,0xc3,0x42,0x62,0x92,0x25,0xb0,0x03,0x3c,0x61,0x0c,0x63,0x34,
+0x10,0x00,0xa4,0x27,0x00,0x00,0x62,0xa0,0x7a,0x54,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x95,0x00,0xc2,0x10,0x00,0x40,0x02,0x3c,0x09,0xff,0xc2,0x10,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x7b,0x02,0xc2,0x10,
+0x2b,0x10,0x46,0x00,0x83,0x00,0x40,0x14,0x00,0xb0,0x02,0x3c,0x00,0x90,0x02,0x3c,
+0x78,0xfd,0xc2,0x14,0xc0,0x02,0x82,0x36,0x21,0x10,0x13,0x01,0x73,0x44,0x44,0xa0,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x55,0xfd,0x62,0x14,0x00,0xf0,0x02,0x3c,0x6a,0x56,0x00,0x0c,0x21,0x20,0x00,0x02,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x07,0x00,0x42,0x34,0x4c,0xfd,0x62,0x14,0x00,0xf0,0x02,0x3c,0x5b,0x4e,0x00,0x0c,
+0x07,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x02,0x1a,0x02,0x00,0x21,0x88,0x00,0x00,0xaf,0x4a,0x00,0x08,
+0x27,0xb0,0x06,0x3c,0x01,0x00,0x31,0x26,0x00,0x01,0x22,0x2e,0x08,0x00,0x40,0x10,
+0xff,0x00,0x22,0x2e,0x00,0x00,0xc2,0x94,0x00,0x00,0x00,0x00,0xff,0x00,0x42,0x30,
+0xf8,0xff,0x43,0x14,0x08,0x00,0xc6,0x24,0x00,0x00,0xd1,0xa7,0xff,0x00,0x22,0x2e,
+0x50,0xfd,0x40,0x14,0xc0,0x02,0x82,0x36,0x12,0x87,0x02,0x3c,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x2d,0xfd,0x62,0x14,0x00,0xf0,0x02,0x3c,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xff,0x00,0x03,0x3c,0x00,0xff,0x63,0x34,
+0x24,0x10,0x03,0x02,0x02,0x82,0x02,0x00,0xcc,0x02,0x83,0x36,0x00,0x00,0x70,0xac,
+0x00,0x00,0xd1,0x8f,0x21,0x10,0x14,0x02,0x00,0x00,0x51,0xac,0x00,0x00,0x51,0x8c,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xd1,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x64,0x62,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0xf4,0x02,0x62,0x10,0xa3,0x00,0xe2,0x34,0x0f,0xfd,0x62,0x14,0x00,0xf0,0x02,0x3c,
+0xc0,0x02,0x82,0x36,0x8c,0x65,0x60,0xae,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xec,0x63,0x62,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0xe6,0x63,0x62,0xa6,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x08,0x40,0x63,0x8e,0xff,0x9f,0x07,0x3c,0xff,0xff,0xe7,0x34,
+0x02,0x2c,0x10,0x00,0x00,0x1f,0x04,0x32,0x24,0x18,0x67,0x00,0x25,0x18,0x62,0x00,
+0x02,0x8a,0x04,0x00,0x3f,0x00,0xa5,0x30,0xc0,0x02,0x82,0x36,0x08,0x40,0x63,0xae,
+0xbc,0x42,0x71,0xa2,0xc1,0x42,0x65,0xa2,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x00,0xe2,0x92,0x00,0x00,0x00,0x00,0xfa,0x00,0x42,0x30,
+0x00,0x00,0xe2,0xa2,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x00,0xe2,0x92,0x00,0x00,0x00,0x00,0xfd,0x00,0x42,0x30,
+0x00,0x00,0xe2,0xa2,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xf7,0xfc,0xc2,0x14,0xc0,0x02,0x82,0x36,0x80,0x10,0x08,0x00,
+0x21,0x10,0x53,0x00,0x60,0x45,0x43,0xac,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x80,0x10,0x08,0x00,0x21,0x10,0x48,0x00,
+0x21,0x10,0x53,0x00,0x21,0x10,0x49,0x00,0x34,0x43,0x44,0xa0,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x77,0x56,0x00,0x0c,
+0x21,0x20,0x00,0x02,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xff,0xff,0x02,0x34,0x8c,0x65,0x62,0xae,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x07,0x0b,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xf0,0x63,0x62,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x08,0x40,0x62,0x8e,0xff,0x9f,0x03,0x3c,0xff,0xff,0x63,0x34,0x24,0x10,0x43,0x00,
+0x08,0x40,0x62,0xae,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x22,0x51,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xff,0x00,0x07,0x3c,0x00,0xff,0xe7,0x34,
+0x24,0x10,0x07,0x02,0x02,0x82,0x02,0x00,0xcc,0x02,0x43,0x36,0x00,0x00,0x70,0xac,
+0x21,0x10,0x12,0x02,0x00,0x00,0x51,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xd1,0xaf,
+0x00,0x00,0x51,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xb7,0x4f,0x00,0x0c,0x00,0x00,0x00,0x00,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x21,0x88,0x00,0x00,
+0x6c,0x4b,0x00,0x08,0x27,0xb0,0x04,0x3c,0x01,0x00,0x31,0x26,0x00,0x01,0x22,0x2e,
+0x0a,0x00,0x40,0x10,0xff,0x00,0x22,0x2e,0x00,0x00,0x83,0x94,0x00,0x00,0x00,0x00,
+0xff,0xff,0x67,0x30,0xff,0x00,0xe2,0x30,0xf0,0x00,0x42,0x28,0xf6,0xff,0x40,0x14,
+0x08,0x00,0x84,0x24,0x00,0x00,0xc7,0xa7,0xff,0x00,0x22,0x2e,0x91,0xfc,0x40,0x14,
+0xc0,0x02,0x82,0x36,0x12,0x87,0x02,0x3c,0x00,0x00,0xc2,0xaf,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xe4,0x63,0x62,0x96,
+0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xa7,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x64,0x62,0x92,0x00,0x00,0x00,0x00,
+0x00,0x00,0xc2,0xaf,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0xff,0x02,0x32,0x02,0x12,0x02,0x00,0x03,0x00,0x43,0x2c,
+0x02,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x02,0x40,0x62,0xa2,0x02,0x40,0x63,0x92,
+0x90,0x0c,0x42,0x36,0x00,0x00,0x43,0xa0,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xd7,0x56,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x21,0x10,0x13,0x01,0x56,0x44,0x44,0xa0,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xff,0x00,0x03,0x3c,0x24,0x20,0x03,0x02,
+0x73,0x0e,0x00,0x0c,0x02,0x24,0x04,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x02,0x1c,0x10,0x00,0x00,0x1f,0x02,0x32,
+0x02,0x8a,0x02,0x00,0x3f,0x00,0x65,0x30,0xc1,0x42,0x65,0xa2,0xbc,0x42,0x71,0xa2,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x1f,0x12,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0x03,0x40,0x62,0x92,0x0e,0x0c,0x44,0x36,
+0x01,0x00,0x42,0x24,0xff,0x00,0x43,0x30,0x00,0x00,0x83,0xa0,0x03,0x40,0x62,0xa2,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0xff,0x02,0x32,0x02,0x3a,0x02,0x00,0x1a,0x01,0xe0,0x10,0x4f,0x00,0x82,0x36,
+0x94,0x00,0x42,0x36,0x00,0x00,0x43,0x94,0xff,0xff,0xe2,0x24,0xb0,0x03,0x45,0x36,
+0xff,0xff,0x71,0x30,0x1b,0x00,0x27,0x02,0x02,0x00,0xe0,0x14,0x00,0x00,0x00,0x00,
+0x0d,0x00,0x07,0x00,0xff,0xff,0x47,0x30,0x00,0x00,0xb1,0xac,0x80,0xff,0x02,0x24,
+0x00,0x19,0x07,0x00,0x25,0x18,0x62,0x00,0x4f,0x00,0x44,0x36,0x9e,0x00,0x46,0x36,
+0x00,0x00,0xa7,0xac,0x00,0x00,0x83,0xa0,0x25,0xb0,0x04,0x3c,0x44,0x00,0x84,0x34,
+0x12,0x88,0x00,0x00,0x80,0x12,0x11,0x00,0x00,0xfc,0x42,0x24,0x00,0x00,0xb1,0xac,
+0x00,0x00,0xd1,0xa4,0x42,0x89,0x02,0x00,0x26,0xb0,0x02,0x3c,0x7c,0x00,0x42,0x34,
+0x00,0x00,0xb1,0xac,0x00,0x00,0x51,0xa4,0x25,0xb0,0x02,0x3c,0x44,0x00,0x42,0x34,
+0x00,0x00,0x43,0x94,0xff,0xfd,0x02,0x24,0x24,0x18,0x62,0x00,0x00,0x00,0x83,0xa4,
+0x00,0x00,0x82,0x94,0x00,0x00,0x00,0x00,0x00,0x02,0x42,0x34,0x00,0x00,0x82,0xa4,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x24,0x10,0x08,0x02,0xcc,0x02,0x43,0x36,0x00,0xff,0x04,0x32,0x02,0x3c,0x02,0x00,
+0x00,0x00,0x70,0xac,0x04,0x00,0xe0,0x10,0x02,0x82,0x04,0x00,0x01,0x00,0x02,0x24,
+0x02,0x00,0xe2,0x10,0x01,0x00,0x04,0x24,0x21,0x20,0x00,0x00,0x7a,0x42,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x0f,0x00,0x06,0x3c,0x21,0x20,0x00,0x02,0xdd,0x44,0x00,0x0c,
+0xff,0xff,0xc5,0x34,0x0f,0x00,0x07,0x3c,0xff,0xff,0xe7,0x34,0x24,0x88,0x47,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xd1,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x28,0xb0,0x02,0x3c,0x00,0x00,0x43,0x90,0xff,0x00,0x02,0x24,
+0xff,0x00,0x70,0x30,0xf3,0xfb,0x02,0x12,0xc0,0x02,0x82,0x36,0x28,0xb0,0x05,0x3c,
+0xff,0x00,0x04,0x24,0xc0,0x10,0x10,0x00,0x21,0x10,0x45,0x00,0x00,0x00,0x43,0x90,
+0x00,0x00,0x00,0x00,0xff,0x00,0x70,0x30,0xfb,0xff,0x04,0x16,0xc0,0x10,0x10,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0x1f,0x02,0x32,0x02,0x1c,0x10,0x00,0x02,0x8a,0x02,0x00,0x3f,0x00,0x65,0x30,
+0xc0,0x02,0x82,0x36,0xbc,0x42,0x71,0xa2,0xc1,0x42,0x65,0xa2,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xff,0x00,0x07,0x3c,0x24,0x20,0x07,0x02,
+0x15,0x51,0x00,0x0c,0x02,0x24,0x04,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xe8,0x63,0x62,0x92,0x00,0x00,0x00,0x00,
+0x00,0x00,0xc2,0xaf,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xfc,0x63,0x62,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0x00,0xe2,0x92,0x00,0x00,0x00,0x00,0xff,0x00,0x51,0x30,0x05,0x00,0x23,0x36,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xe3,0xa2,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xc0,0x02,0x82,0x36,0xe6,0x63,0x60,0xa6,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xbd,0x56,0x00,0x0c,0x21,0x20,0x00,0x02,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x41,0x0b,0x00,0x0c,0x00,0x00,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xe2,0x92,0x00,0x00,0x00,0x00,
+0xff,0x00,0x51,0x30,0x02,0x00,0x23,0x36,0xc0,0x02,0x82,0x36,0x00,0x00,0xe3,0xa2,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,
+0xec,0x91,0x42,0x24,0x00,0x00,0x47,0x8c,0xc0,0x02,0x43,0x36,0x25,0xb0,0x0c,0x3c,
+0x08,0x40,0xe4,0x8c,0x00,0x00,0x60,0xac,0x42,0x17,0x04,0x00,0x03,0x00,0x42,0x30,
+0x60,0x00,0x40,0x14,0x03,0x0d,0x42,0x36,0x00,0x00,0x45,0x90,0x10,0x40,0xe6,0x8c,
+0xff,0x9f,0x03,0x3c,0xff,0xff,0x63,0x34,0xff,0x3f,0x02,0x3c,0x24,0x20,0x83,0x00,
+0xff,0xff,0x42,0x34,0x00,0x20,0x03,0x3c,0x24,0x58,0xc2,0x00,0x25,0x20,0x83,0x00,
+0x00,0x40,0x02,0x3c,0x70,0x00,0xa5,0x30,0x25,0x58,0x62,0x01,0x08,0x01,0xa0,0x10,
+0x08,0x40,0xe4,0xac,0x94,0x0e,0x82,0x35,0x9c,0x0e,0x83,0x35,0xa4,0x0e,0x86,0x35,
+0x00,0x00,0x45,0x8c,0xac,0x0e,0x87,0x35,0x00,0x00,0x68,0x8c,0x00,0x00,0xca,0x8c,
+0x02,0x80,0x06,0x3c,0x00,0x00,0xe4,0x8c,0x68,0x15,0xc6,0x24,0x0c,0x40,0xc3,0x8c,
+0xb4,0x0e,0x82,0x35,0x00,0x00,0x47,0x8c,0xff,0x03,0x02,0x3c,0x00,0xfc,0x06,0x24,
+0x24,0x28,0xa2,0x00,0x24,0x20,0x82,0x00,0xbc,0x0e,0x82,0x35,0x00,0x00,0x49,0x8c,
+0x02,0x2c,0x05,0x00,0x24,0x10,0x66,0x01,0x24,0x18,0x66,0x00,0x02,0x24,0x04,0x00,
+0xc4,0x0e,0x86,0x35,0x25,0x18,0x65,0x00,0x25,0x10,0x44,0x00,0x00,0x00,0xc5,0x8c,
+0xff,0x03,0x04,0x3c,0xf0,0xff,0x06,0x3c,0xff,0x03,0xc6,0x34,0x24,0x38,0xe4,0x00,
+0xcc,0x0e,0x8b,0x35,0x24,0x40,0x04,0x01,0x82,0x39,0x07,0x00,0x00,0x00,0x64,0x8d,
+0x24,0x10,0x46,0x00,0x24,0x18,0x66,0x00,0x25,0x10,0x47,0x00,0x82,0x41,0x08,0x00,
+0xff,0x03,0x07,0x3c,0x0f,0xc0,0x06,0x3c,0x24,0x50,0x47,0x01,0x24,0x48,0x27,0x01,
+0xff,0xff,0xc6,0x34,0x25,0x18,0x68,0x00,0x24,0x28,0xa7,0x00,0x24,0x20,0x87,0x00,
+0x00,0x51,0x0a,0x00,0x24,0x18,0x66,0x00,0x00,0x49,0x09,0x00,0x24,0x10,0x46,0x00,
+0x02,0x80,0x07,0x3c,0x68,0x15,0xe7,0x24,0x25,0x18,0x6a,0x00,0x25,0x10,0x49,0x00,
+0x02,0x2c,0x05,0x00,0x02,0x24,0x04,0x00,0x0c,0x40,0xe3,0xac,0x10,0x40,0xe2,0xac,
+0x14,0x40,0xe5,0xa4,0x16,0x40,0xe4,0xa4,0x02,0x80,0x02,0x3c,0x68,0x15,0x43,0x24,
+0x0c,0x40,0x62,0x8c,0x00,0x00,0x00,0x00,0xbd,0x00,0x40,0x04,0x00,0x00,0x00,0x00,
+0x00,0xff,0x02,0x32,0xc6,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x02,0x12,0x02,0x00,
+0xc3,0x42,0x62,0xa0,0x7a,0x54,0x00,0x0c,0x10,0x00,0xa4,0x27,0xc2,0x53,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x0c,0x40,0x62,0x8e,0x00,0x80,0x03,0x3c,0x25,0x10,0x43,0x00,
+0x0c,0x40,0x62,0xae,0xc3,0x42,0x62,0x92,0x25,0xb0,0x03,0x3c,0x61,0x0c,0x63,0x34,
+0x00,0x00,0x62,0xa0,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xcf,0x4e,0x00,0x0c,0x21,0x20,0x00,0x02,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x17,0x51,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x9e,0x00,0x83,0x36,0x00,0x00,0x40,0xa0,0x00,0x00,0x60,0xa4,
+0x94,0x00,0x82,0x36,0x00,0x00,0x43,0x94,0x25,0xb0,0x06,0x3c,0x44,0x00,0xc6,0x34,
+0xff,0xff,0x71,0x30,0x80,0x12,0x11,0x00,0x00,0xf8,0x42,0x24,0x42,0x89,0x02,0x00,
+0x26,0xb0,0x02,0x3c,0xb0,0x03,0x83,0x36,0x7c,0x00,0x42,0x34,0x00,0x00,0x71,0xac,
+0x00,0x00,0x51,0xa4,0x00,0x00,0xc3,0x94,0xff,0xfd,0x02,0x24,0x24,0x18,0x62,0x00,
+0x00,0x00,0xc3,0xa4,0x00,0x00,0xc2,0x94,0x00,0x00,0x00,0x00,0x00,0x02,0x42,0x34,
+0x00,0x00,0xc2,0xa4,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x5b,0x4e,0x00,0x0c,0x01,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x80,0x10,0x08,0x00,
+0x21,0x10,0x53,0x00,0xec,0x44,0x43,0xac,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xa7,0x0b,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x28,0xb0,0x11,0x3c,0x00,0x00,0x22,0x96,0xff,0x00,0x04,0x3c,0x24,0x18,0x04,0x02,
+0x02,0x24,0x03,0x00,0xff,0x00,0x42,0x30,0x0a,0x00,0x82,0x10,0xff,0x7f,0x02,0x3c,
+0x08,0x00,0x31,0x26,0x00,0x00,0x22,0x96,0xff,0xff,0x23,0x32,0xff,0x00,0x42,0x30,
+0x03,0x00,0x82,0x10,0x00,0x08,0x63,0x2c,0xf9,0xff,0x60,0x14,0x00,0x00,0x00,0x00,
+0xff,0x7f,0x02,0x3c,0xff,0xff,0x42,0x34,0x24,0x10,0x22,0x02,0x00,0x00,0xc2,0xaf,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0xf8,0x63,0x62,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xff,0x00,0x03,0x3c,
+0x24,0x10,0x03,0x02,0x00,0xff,0x04,0x32,0xcc,0x02,0x83,0x36,0x02,0x3c,0x02,0x00,
+0x00,0x00,0x70,0xac,0x04,0x00,0xe0,0x10,0x02,0x82,0x04,0x00,0x01,0x00,0x02,0x24,
+0x02,0x00,0xe2,0x10,0x01,0x00,0x04,0x24,0x21,0x20,0x00,0x00,0x7a,0x42,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x00,0xd1,0x8f,0x0f,0x00,0x06,0x3c,0xff,0xff,0xc5,0x34,
+0x21,0x20,0x00,0x02,0xba,0x44,0x00,0x0c,0x21,0x30,0x20,0x02,0x0f,0x00,0x07,0x3c,
+0x21,0x20,0x00,0x02,0xdd,0x44,0x00,0x0c,0xff,0xff,0xe5,0x34,0x00,0x00,0xc2,0xaf,
+0x21,0x88,0x40,0x00,0x25,0xb0,0x02,0x3c,0xc8,0x02,0x42,0x34,0x00,0x00,0x51,0xac,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x25,0xb0,0x06,0x3c,0xff,0x00,0x02,0x24,0x56,0x01,0xc6,0x34,0x00,0x00,0xc2,0xa4,
+0x01,0x00,0x03,0x24,0x02,0x80,0x07,0x3c,0xc0,0x02,0x82,0x36,0xb8,0x7d,0xe3,0xa0,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xde,0x4f,0x00,0x0c,
+0x03,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xde,0x4e,0x00,0x0c,0x21,0x20,0x00,0x02,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x40,0x62,0x8e,
+0xff,0x9f,0x04,0x3c,0xff,0xff,0x84,0x34,0x24,0x10,0x44,0x00,0x08,0x40,0x62,0xae,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,
+0x80,0x10,0x02,0x00,0x21,0x10,0x53,0x00,0x70,0x51,0x43,0x8c,0xc0,0x02,0x82,0x36,
+0x00,0x00,0xc3,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x7a,0x54,0x00,0x0c,0x10,0x00,0xa4,0x27,0xc3,0x42,0x62,0x92,0x25,0xb0,0x03,0x3c,
+0x61,0x0c,0x63,0x34,0x00,0x00,0x62,0xa0,0xd4,0x4c,0x00,0x08,0xc0,0x02,0x82,0x36,
+0x22,0x51,0x00,0x0c,0x10,0x40,0xeb,0xac,0xbd,0x4c,0x00,0x08,0x02,0x80,0x02,0x3c,
+0xc6,0x4c,0x00,0x08,0x12,0x00,0x02,0x24,0x1a,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0xff,0xff,0x02,0x34,0x8c,0x65,0x62,0xae,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,
+0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x53,0x00,
+0x74,0x51,0x43,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0xc3,0xaf,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,
+0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x53,0x00,
+0xd4,0x51,0x43,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0xc3,0xaf,0x00,0x00,0x40,0xac,
+0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,
+0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x02,0x80,0x06,0x3c,0x80,0x10,0x02,0x00,
+0xe0,0x66,0xc3,0x24,0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,0xc0,0x02,0x82,0x36,
+0x00,0x00,0xc4,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,
+0x12,0x00,0x02,0x24,0xc7,0x42,0xa2,0xa1,0x77,0x4a,0x00,0x08,0xc3,0x42,0xa2,0xa1,
+0x88,0x7d,0x82,0x94,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xaf,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x7a,0x42,0x00,0x0c,
+0x21,0x20,0x00,0x00,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xff,0x00,0x06,0x3c,0x00,0xff,0xc6,0x34,0x00,0x00,0xc5,0x8f,
+0x24,0x20,0x06,0x02,0xe1,0x50,0x00,0x0c,0x02,0x22,0x04,0x00,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,
+0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x02,0x80,0x07,0x3c,
+0x80,0x10,0x02,0x00,0xf0,0x66,0xe3,0x24,0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,
+0x21,0x10,0x43,0x00,0x02,0x80,0x06,0x3c,0x80,0x10,0x02,0x00,0xec,0x66,0xc3,0x24,
+0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,
+0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x02,0x80,0x04,0x3c,
+0xe8,0x66,0x83,0x24,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,
+0x21,0x10,0x43,0x00,0x02,0x80,0x07,0x3c,0x80,0x10,0x02,0x00,0xe4,0x66,0xe3,0x24,
+0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,
+0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x02,0x80,0x04,0x3c,
+0x00,0x67,0x83,0x24,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,
+0x21,0x10,0x43,0x00,0x02,0x80,0x07,0x3c,0x80,0x10,0x02,0x00,0xfc,0x66,0xe3,0x24,
+0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,
+0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,0x02,0x80,0x06,0x3c,
+0x80,0x10,0x02,0x00,0xf8,0x66,0xc3,0x24,0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,
+0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xc0,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x80,0x10,0x02,0x00,
+0x21,0x10,0x43,0x00,0x02,0x80,0x04,0x3c,0xf4,0x66,0x83,0x24,0x80,0x10,0x02,0x00,
+0x21,0x10,0x43,0x00,0x00,0x00,0x44,0x8c,0xc0,0x02,0x82,0x36,0x00,0x00,0xc4,0xaf,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0xde,0x4f,0x00,0x0c,
+0x02,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0xde,0x4f,0x00,0x0c,0x01,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,
+0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,0x00,0x00,0x00,0x00,0x7a,0x42,0x00,0x0c,
+0x01,0x00,0x04,0x24,0xc0,0x02,0x82,0x36,0x00,0x00,0x40,0xac,0x08,0x48,0x00,0x08,
+0x00,0x00,0x00,0x00,0x25,0xb0,0x05,0x3c,0x01,0x00,0x06,0x24,0x01,0x80,0x02,0x3c,
+0x04,0x30,0x86,0x00,0xf1,0x02,0xa7,0x34,0xed,0x02,0xa4,0x34,0x6c,0x39,0x42,0x24,
+0x18,0x03,0xa5,0x34,0x08,0x00,0x03,0x24,0x00,0x00,0xa2,0xac,0x00,0x00,0xe3,0xa0,
+0x00,0x00,0x80,0xa0,0x00,0x00,0x86,0xa0,0x00,0x00,0x80,0xa0,0x00,0x00,0x86,0xa0,
+0x00,0x00,0x80,0xa0,0x00,0x00,0x86,0xa0,0x00,0x00,0x80,0xa0,0x00,0x00,0x86,0xa0,
+0x00,0x00,0x80,0xa0,0x00,0x00,0xe0,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x01,0x80,0x02,0x3c,0x25,0xb0,0x03,0x3c,0xc8,0x39,0x42,0x24,0x18,0x03,0x63,0x34,
+0x00,0x00,0x62,0xac,0x00,0x00,0x83,0x90,0x30,0x00,0x02,0x24,0x05,0x00,0x62,0x10,
+0x21,0x20,0x00,0x00,0x31,0x00,0x02,0x24,0x02,0x00,0x62,0x10,0x01,0x00,0x04,0x24,
+0x07,0x00,0x04,0x24,0x5b,0x4e,0x00,0x08,0x00,0x00,0x00,0x00,0x01,0x80,0x02,0x3c,
+0x25,0xb0,0x03,0x3c,0x04,0x3a,0x42,0x24,0x18,0x03,0x63,0x34,0x02,0x80,0x04,0x3c,
+0x00,0x00,0x62,0xac,0x08,0x00,0xe0,0x03,0xc4,0x7d,0x80,0xac,0x02,0x80,0x02,0x3c,
+0x08,0x7b,0x42,0x24,0xc0,0x20,0x04,0x00,0x21,0x20,0x82,0x00,0x21,0x28,0x00,0x00,
+0x00,0x60,0x06,0x40,0x01,0x00,0xc1,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,
+0x00,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x09,0x00,0x44,0x10,0x00,0x00,0x00,0x00,
+0x04,0x00,0x43,0x8c,0x21,0x28,0x40,0x00,0x00,0x00,0x42,0x8c,0x00,0x00,0x00,0x00,
+0x00,0x00,0x62,0xac,0x04,0x00,0x43,0xac,0x00,0x00,0xa5,0xac,0x04,0x00,0xa5,0xac,
+0x00,0x60,0x86,0x40,0x08,0x00,0xe0,0x03,0x21,0x10,0xa0,0x00,0x21,0x18,0x80,0x00,
+0xe8,0xff,0xbd,0x27,0x01,0x01,0x62,0x2c,0x10,0x00,0xbf,0xaf,0x01,0x00,0x04,0x24,
+0x01,0x02,0x65,0x2c,0x0a,0x00,0x40,0x14,0x21,0x30,0x00,0x00,0x02,0x00,0x04,0x24,
+0x07,0x00,0xa0,0x14,0x01,0x08,0x62,0x2c,0x05,0x00,0x40,0x14,0x03,0x00,0x04,0x24,
+0x10,0x00,0xbf,0x8f,0x21,0x10,0xc0,0x00,0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,
+0x89,0x4e,0x00,0x0c,0x00,0x00,0x00,0x00,0x10,0x00,0xbf,0x8f,0x21,0x30,0x40,0x00,
+0x21,0x10,0xc0,0x00,0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,0x02,0x80,0x03,0x3c,
+0x20,0x7b,0x62,0x8c,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x60,0x06,0x40,
+0x01,0x00,0xc1,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x10,0x00,0x83,0x8c,
+0x02,0x80,0x02,0x3c,0x08,0x7b,0x42,0x24,0xc0,0x18,0x03,0x00,0x21,0x18,0x62,0x00,
+0x00,0x00,0x65,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x85,0xac,0x04,0x00,0xa4,0xac,
+0x00,0x00,0x64,0xac,0x04,0x00,0x83,0xac,0x00,0x60,0x86,0x40,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x02,0x24,0x04,0x00,0xff,0x00,0x84,0x30,0xc0,0x18,0x04,0x00,
+0x21,0x18,0x64,0x00,0x80,0x18,0x03,0x00,0x21,0x18,0x64,0x00,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x42,0x24,0x80,0x18,0x03,0x00,0x21,0x18,0x62,0x00,0x78,0x51,0x64,0x8c,
+0xff,0xf1,0x02,0x24,0x24,0x20,0x82,0x00,0x08,0x00,0xe0,0x03,0x78,0x51,0x64,0xac,
+0x02,0x24,0x04,0x00,0xff,0x00,0x84,0x30,0xc0,0x18,0x04,0x00,0x21,0x18,0x64,0x00,
+0x80,0x18,0x03,0x00,0x21,0x18,0x64,0x00,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,
+0x80,0x18,0x03,0x00,0x21,0x18,0x62,0x00,0x78,0x51,0x64,0x8c,0xff,0xf1,0x02,0x24,
+0x24,0x20,0x82,0x00,0x00,0x02,0x84,0x34,0x08,0x00,0xe0,0x03,0x78,0x51,0x64,0xac,
+0xe0,0xff,0xbd,0x27,0x10,0x00,0xb0,0xaf,0xc0,0x80,0x04,0x00,0x21,0x80,0x04,0x02,
+0x80,0x80,0x10,0x00,0x21,0x80,0x04,0x02,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,
+0x80,0x80,0x10,0x00,0x21,0x80,0x02,0x02,0x1c,0x00,0xbf,0xaf,0x18,0x00,0xb2,0xaf,
+0x14,0x00,0xb1,0xaf,0x78,0x51,0x05,0x8e,0xff,0x1f,0x02,0x3c,0x25,0xb0,0x12,0x3c,
+0xff,0xff,0x42,0x34,0x70,0x51,0x02,0xae,0x84,0x01,0x43,0x36,0xf8,0xff,0x02,0x24,
+0x00,0x00,0x66,0x8c,0x24,0x28,0xa2,0x00,0xff,0xfe,0x02,0x24,0x24,0x28,0xa2,0x00,
+0xff,0xef,0x03,0x24,0x24,0x28,0xa3,0x00,0x74,0x51,0x06,0xae,0x78,0x51,0x05,0xae,
+0xce,0x0d,0x00,0x0c,0x21,0x88,0x80,0x00,0x7a,0x51,0x02,0x92,0x21,0x88,0x32,0x02,
+0x1c,0x00,0xbf,0x8f,0x60,0x01,0x22,0xa2,0x18,0x00,0xb2,0x8f,0x64,0x51,0x00,0xae,
+0x48,0x51,0x00,0xae,0x4c,0x51,0x00,0xae,0x50,0x51,0x00,0xae,0x54,0x51,0x00,0xae,
+0x58,0x51,0x00,0xae,0x5c,0x51,0x00,0xae,0x60,0x51,0x00,0xae,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0xff,0x00,0xa5,0x30,
+0xc0,0x10,0x05,0x00,0x21,0x10,0x45,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x45,0x00,
+0x02,0x80,0x03,0x3c,0x68,0x15,0x63,0x24,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,
+0x78,0x51,0x43,0x8c,0x25,0xb0,0x05,0x3c,0xff,0x00,0xc6,0x30,0x21,0x30,0xc5,0x00,
+0xaf,0x01,0xc2,0x90,0x07,0x00,0x63,0x30,0x80,0x18,0x03,0x00,0x21,0x18,0x65,0x00,
+0xff,0x00,0x88,0x30,0xff,0x00,0x49,0x30,0x84,0x01,0x66,0x8c,0x21,0x50,0x00,0x00,
+0x21,0x58,0x00,0x00,0x2b,0x00,0x20,0x11,0x21,0x20,0x00,0x01,0x2b,0x00,0xc0,0x10,
+0x2b,0x10,0x09,0x01,0x21,0x28,0x00,0x00,0x3e,0x4f,0x00,0x08,0x01,0x00,0x07,0x24,
+0xff,0x00,0x65,0x30,0x1d,0x00,0xa2,0x2c,0x07,0x00,0x40,0x10,0xff,0xff,0x02,0x25,
+0x04,0x10,0xa7,0x00,0x24,0x10,0x46,0x00,0xf9,0xff,0x40,0x10,0x01,0x00,0xa3,0x24,
+0x21,0x58,0xa0,0x00,0xff,0xff,0x02,0x25,0xff,0x00,0x45,0x30,0x2b,0x18,0xab,0x00,
+0x0f,0x00,0x60,0x14,0x2b,0x10,0x49,0x01,0x01,0x00,0x04,0x24,0x04,0x10,0xa4,0x00,
+0x24,0x10,0x46,0x00,0xff,0xff,0xa7,0x24,0x04,0x00,0x40,0x10,0x01,0x00,0x43,0x25,
+0x17,0x00,0x49,0x11,0xff,0x00,0x6a,0x30,0x21,0x40,0xa0,0x00,0xff,0x00,0xe5,0x30,
+0x2b,0x10,0xab,0x00,0xf6,0xff,0x40,0x10,0x04,0x10,0xa4,0x00,0x2b,0x10,0x49,0x01,
+0x08,0x00,0x40,0x10,0x21,0x20,0x00,0x01,0x23,0x10,0x2a,0x01,0x2a,0x10,0x62,0x01,
+0x04,0x00,0x40,0x14,0x21,0x20,0x00,0x00,0x23,0x10,0x69,0x01,0x21,0x10,0x4a,0x00,
+0xff,0x00,0x44,0x30,0x08,0x00,0xe0,0x03,0x21,0x10,0x80,0x00,0xfd,0xff,0x40,0x14,
+0x21,0x20,0x00,0x00,0x23,0x10,0x09,0x01,0x5f,0x4f,0x00,0x08,0xff,0x00,0x44,0x30,
+0x21,0x20,0x00,0x01,0x08,0x00,0xe0,0x03,0x21,0x10,0x80,0x00,0xff,0x00,0x84,0x30,
+0xc0,0x10,0x04,0x00,0x21,0x10,0x44,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x44,0x00,
+0x02,0x80,0x03,0x3c,0x68,0x15,0x63,0x24,0x80,0x10,0x02,0x00,0x21,0x10,0x43,0x00,
+0x25,0xb0,0x06,0x3c,0x78,0x51,0x43,0x8c,0xff,0x00,0xa5,0x30,0x21,0x20,0x86,0x00,
+0x21,0x28,0xa6,0x00,0x60,0x01,0x82,0x90,0xaf,0x01,0xa4,0x90,0x07,0x00,0x63,0x30,
+0x80,0x18,0x03,0x00,0x21,0x18,0x66,0x00,0xff,0x00,0x48,0x30,0xff,0x00,0x89,0x30,
+0x84,0x01,0x66,0x8c,0x21,0x50,0x00,0x00,0x21,0x58,0x00,0x00,0x2b,0x00,0x20,0x11,
+0x21,0x20,0x00,0x01,0x2b,0x00,0xc0,0x10,0x2b,0x10,0x09,0x01,0x21,0x28,0x00,0x00,
+0x8c,0x4f,0x00,0x08,0x01,0x00,0x07,0x24,0xff,0x00,0x65,0x30,0x1d,0x00,0xa2,0x2c,
+0x07,0x00,0x40,0x10,0xff,0xff,0x02,0x25,0x04,0x10,0xa7,0x00,0x24,0x10,0x46,0x00,
+0xf9,0xff,0x40,0x10,0x01,0x00,0xa3,0x24,0x21,0x58,0xa0,0x00,0xff,0xff,0x02,0x25,
+0xff,0x00,0x45,0x30,0x2b,0x18,0xab,0x00,0x0f,0x00,0x60,0x14,0x2b,0x10,0x49,0x01,
+0x01,0x00,0x04,0x24,0x04,0x10,0xa4,0x00,0x24,0x10,0x46,0x00,0xff,0xff,0xa7,0x24,
+0x04,0x00,0x40,0x10,0x01,0x00,0x43,0x25,0x17,0x00,0x49,0x11,0xff,0x00,0x6a,0x30,
+0x21,0x40,0xa0,0x00,0xff,0x00,0xe5,0x30,0x2b,0x10,0xab,0x00,0xf6,0xff,0x40,0x10,
+0x04,0x10,0xa4,0x00,0x2b,0x10,0x49,0x01,0x08,0x00,0x40,0x10,0x21,0x20,0x00,0x01,
+0x23,0x10,0x2a,0x01,0x2a,0x10,0x62,0x01,0x04,0x00,0x40,0x14,0x21,0x20,0x00,0x00,
+0x23,0x10,0x69,0x01,0x21,0x10,0x4a,0x00,0xff,0x00,0x44,0x30,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x80,0x00,0xfd,0xff,0x40,0x14,0x21,0x20,0x00,0x00,0x23,0x10,0x09,0x01,
+0xad,0x4f,0x00,0x08,0xff,0x00,0x44,0x30,0x21,0x20,0x00,0x01,0x08,0x00,0xe0,0x03,
+0x21,0x10,0x80,0x00,0xe0,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,0x10,0x00,0xb0,0xaf,
+0x68,0x15,0x50,0x24,0x18,0x00,0xb2,0xaf,0x14,0x00,0xb1,0xaf,0x1c,0x00,0xbf,0xaf,
+0x21,0x88,0x00,0x00,0x21,0x90,0x00,0x02,0xee,0x4e,0x00,0x0c,0x21,0x20,0x20,0x02,
+0x7a,0x51,0x02,0x92,0x21,0x28,0x00,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x52,0x00,
+0xec,0x44,0x44,0x8c,0x60,0x45,0x43,0x8c,0x00,0x00,0x00,0x00,0x21,0x18,0x64,0x00,
+0x42,0x18,0x03,0x00,0x44,0x51,0x03,0xae,0x21,0x10,0x05,0x02,0x01,0x00,0xa5,0x24,
+0x1d,0x00,0xa3,0x28,0xb6,0x51,0x40,0xa0,0x7c,0x51,0x40,0xa0,0xfa,0xff,0x60,0x14,
+0x99,0x51,0x40,0xa0,0x01,0x00,0x31,0x26,0x20,0x00,0x22,0x2a,0xd4,0x51,0x00,0xae,
+0xe9,0xff,0x40,0x14,0x94,0x00,0x10,0x26,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,
+0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0xc8,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,0x30,0x00,0xbe,0xaf,0x28,0x00,0xb6,0xaf,
+0x68,0x15,0x46,0x24,0x34,0x00,0xbf,0xaf,0x2c,0x00,0xb7,0xaf,0x24,0x00,0xb5,0xaf,
+0x20,0x00,0xb4,0xaf,0x1c,0x00,0xb3,0xaf,0x18,0x00,0xb2,0xaf,0x14,0x00,0xb1,0xaf,
+0x10,0x00,0xb0,0xaf,0x8c,0x65,0xc2,0x8c,0xff,0x00,0x8d,0x30,0xff,0x00,0x03,0x24,
+0xff,0xff,0x42,0x38,0x21,0xf0,0x00,0x00,0xff,0xff,0x04,0x34,0x0a,0xf0,0x62,0x00,
+0x8c,0x65,0xc4,0xac,0xb0,0x00,0xa0,0x11,0x08,0x00,0x16,0x24,0x02,0x80,0x02,0x3c,
+0xb8,0x90,0x45,0x24,0x90,0x44,0xc4,0x24,0xff,0x4f,0x00,0x08,0x21,0x88,0x00,0x00,
+0x01,0x00,0x31,0x26,0x00,0x00,0x82,0xa0,0x1d,0x00,0x22,0x2a,0x0b,0x00,0x40,0x10,
+0x01,0x00,0x84,0x24,0x21,0x10,0x25,0x02,0x00,0x00,0x42,0x90,0x00,0x00,0x00,0x00,
+0xf7,0xff,0x40,0x10,0xfd,0xff,0x43,0x24,0x01,0x00,0x31,0x26,0x1d,0x00,0x22,0x2a,
+0x00,0x00,0x83,0xa0,0xf7,0xff,0x40,0x14,0x01,0x00,0x84,0x24,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x4a,0x24,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0x50,0x8e,0x6c,0x24,
+0xd8,0x8d,0x4b,0x24,0x21,0x88,0x00,0x00,0x21,0x48,0x00,0x00,0x21,0x30,0x00,0x00,
+0x21,0x40,0x2a,0x01,0x21,0x38,0x2c,0x01,0x21,0x10,0xe6,0x00,0x91,0x00,0x44,0x90,
+0x00,0x00,0x45,0x90,0x21,0x18,0x06,0x01,0x01,0x00,0xc6,0x24,0x05,0x00,0xc2,0x28,
+0xc5,0x43,0x64,0xa0,0xf8,0xff,0x40,0x14,0x34,0x43,0x65,0xa0,0x21,0x10,0x2b,0x02,
+0x1d,0x00,0x44,0x90,0x00,0x00,0x45,0x90,0x21,0x18,0x2a,0x02,0x01,0x00,0x31,0x26,
+0x1d,0x00,0x22,0x2a,0x73,0x44,0x64,0xa0,0x56,0x44,0x65,0xa0,0xeb,0xff,0x40,0x14,
+0x05,0x00,0x29,0x25,0xa6,0x00,0xa0,0x11,0x02,0x80,0x02,0x3c,0x68,0x15,0x48,0x24,
+0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0x4c,0x91,0x69,0x24,0xd8,0x90,0x47,0x24,
+0x21,0x88,0x00,0x00,0x80,0x18,0x11,0x00,0x21,0x10,0x69,0x00,0x21,0x20,0x67,0x00,
+0x00,0x00,0x46,0x8c,0x00,0x00,0x85,0x8c,0x01,0x00,0x31,0x26,0x21,0x18,0x68,0x00,
+0x04,0x00,0x22,0x2a,0xec,0x44,0x65,0xac,0xf6,0xff,0x40,0x14,0x60,0x45,0x66,0xac,
+0x02,0x80,0x02,0x3c,0x68,0x15,0x49,0x24,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,
+0x4c,0x91,0x68,0x24,0xd8,0x90,0x47,0x24,0x04,0x00,0x11,0x24,0x80,0x20,0x11,0x00,
+0x21,0x10,0x88,0x00,0x21,0x30,0x87,0x00,0x00,0x00,0x45,0x8c,0x00,0x00,0xc3,0x8c,
+0x01,0x00,0x31,0x26,0x21,0x20,0x89,0x00,0x82,0x28,0x05,0x00,0x82,0x18,0x03,0x00,
+0x1d,0x00,0x22,0x2a,0xec,0x44,0x83,0xac,0xf4,0xff,0x40,0x14,0x60,0x45,0x85,0xac,
+0x02,0x80,0x02,0x3c,0x68,0x15,0x55,0x24,0x21,0x88,0x00,0x00,0x21,0xb8,0xa0,0x02,
+0x21,0xa0,0x00,0x00,0x5a,0x50,0x00,0x08,0x21,0x90,0xa0,0x02,0x01,0x00,0x31,0x26,
+0x20,0x00,0x22,0x2a,0x94,0x00,0x52,0x26,0x38,0x00,0x40,0x10,0x94,0x00,0x94,0x26,
+0x78,0x51,0x44,0x8e,0x01,0x00,0x03,0x24,0x02,0x13,0x04,0x00,0x01,0x00,0x53,0x30,
+0xf6,0xff,0x63,0x16,0x07,0x00,0x82,0x30,0x25,0xb0,0x03,0x3c,0x80,0x10,0x02,0x00,
+0x21,0x10,0x43,0x00,0x84,0x01,0x45,0x8c,0x70,0x51,0x43,0x8e,0x21,0x20,0x20,0x02,
+0x24,0x28,0xa3,0x00,0xce,0x0d,0x00,0x0c,0x74,0x51,0x45,0xae,0x7a,0x51,0x44,0x92,
+0x5c,0x0d,0x00,0x0c,0xff,0x00,0x25,0x32,0x7a,0x51,0x50,0x92,0x00,0x00,0x00,0x00,
+0x21,0x20,0x00,0x02,0x63,0x0d,0x00,0x0c,0x80,0x80,0x10,0x00,0x21,0x80,0x17,0x02,
+0x48,0x51,0x40,0xae,0x4c,0x51,0x40,0xae,0x50,0x51,0x40,0xae,0x54,0x51,0x40,0xae,
+0x58,0x51,0x40,0xae,0x5c,0x51,0x40,0xae,0x60,0x51,0x40,0xae,0x64,0x51,0x40,0xae,
+0xec,0x44,0x04,0x8e,0x60,0x45,0x03,0x8e,0x26,0x10,0x53,0x00,0x21,0x30,0x00,0x00,
+0x21,0x18,0x64,0x00,0x42,0x18,0x03,0x00,0x04,0x00,0x04,0x24,0x0a,0xb0,0x82,0x00,
+0x44,0x51,0x43,0xae,0x21,0x20,0x95,0x02,0x21,0x10,0x86,0x00,0x01,0x00,0xc6,0x24,
+0x1d,0x00,0xc3,0x28,0xb6,0x51,0x40,0xa0,0x7c,0x51,0x40,0xa0,0xfa,0xff,0x60,0x14,
+0x99,0x51,0x40,0xa0,0x01,0x00,0x31,0x26,0x20,0x00,0x22,0x2a,0xd4,0x51,0x80,0xac,
+0x94,0x00,0x52,0x26,0xca,0xff,0x40,0x14,0x94,0x00,0x94,0x26,0x25,0xb0,0x02,0x3c,
+0x80,0x01,0x42,0x34,0x00,0x00,0x56,0xa0,0x03,0x00,0xc0,0x17,0x02,0x80,0x03,0x3c,
+0x68,0x15,0x62,0x24,0x8c,0x65,0x40,0xac,0x34,0x00,0xbf,0x8f,0x30,0x00,0xbe,0x8f,
+0x2c,0x00,0xb7,0x8f,0x28,0x00,0xb6,0x8f,0x24,0x00,0xb5,0x8f,0x20,0x00,0xb4,0x8f,
+0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,
+0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,0x02,0x80,0x02,0x3c,0xb8,0x90,0x45,0x24,
+0x90,0x44,0xc4,0x24,0x21,0x88,0x00,0x00,0x21,0x10,0x25,0x02,0x00,0x00,0x43,0x90,
+0x01,0x00,0x31,0x26,0x1d,0x00,0x22,0x2a,0x00,0x00,0x83,0xa0,0xfa,0xff,0x40,0x14,
+0x01,0x00,0x84,0x24,0x02,0x80,0x02,0x3c,0x68,0x15,0x4a,0x24,0x02,0x80,0x03,0x3c,
+0x02,0x80,0x02,0x3c,0x74,0x8f,0x6c,0x24,0x14,0x8e,0x4b,0x24,0x21,0x88,0x00,0x00,
+0x21,0x48,0x00,0x00,0x21,0x30,0x00,0x00,0x21,0x40,0x2a,0x01,0x21,0x38,0x2c,0x01,
+0x21,0x10,0xe6,0x00,0x91,0x00,0x44,0x90,0x00,0x00,0x45,0x90,0x21,0x18,0x06,0x01,
+0x01,0x00,0xc6,0x24,0x05,0x00,0xc2,0x28,0xc5,0x43,0x64,0xa0,0xf8,0xff,0x40,0x14,
+0x34,0x43,0x65,0xa0,0x21,0x10,0x2b,0x02,0x1d,0x00,0x44,0x90,0x00,0x00,0x45,0x90,
+0x21,0x18,0x2a,0x02,0x01,0x00,0x31,0x26,0x1d,0x00,0x22,0x2a,0x73,0x44,0x64,0xa0,
+0x56,0x44,0x65,0xa0,0xeb,0xff,0x40,0x14,0x05,0x00,0x29,0x25,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x49,0x24,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0x4c,0x91,0x68,0x24,
+0xd8,0x90,0x47,0x24,0x21,0x88,0x00,0x00,0x80,0x18,0x11,0x00,0x21,0x10,0x68,0x00,
+0x21,0x20,0x67,0x00,0x00,0x00,0x46,0x8c,0x00,0x00,0x85,0x8c,0x01,0x00,0x31,0x26,
+0x21,0x18,0x69,0x00,0x1d,0x00,0x22,0x2a,0xec,0x44,0x65,0xac,0xf6,0xff,0x40,0x14,
+0x60,0x45,0x66,0xac,0x4f,0x50,0x00,0x08,0x02,0x80,0x02,0x3c,0xd8,0xff,0xbd,0x27,
+0xff,0xff,0x84,0x30,0x18,0x00,0xb2,0xaf,0xf0,0x01,0x92,0x30,0x02,0x91,0x12,0x00,
+0x14,0x00,0xb1,0xaf,0xc0,0x88,0x12,0x00,0x21,0x88,0x32,0x02,0x80,0x88,0x11,0x00,
+0x21,0x88,0x32,0x02,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,0x80,0x88,0x11,0x00,
+0x21,0x88,0x22,0x02,0x20,0x00,0xbf,0xaf,0x1c,0x00,0xb3,0xaf,0x10,0x00,0xb0,0xaf,
+0x78,0x51,0x30,0x8e,0x00,0x02,0x82,0x30,0xff,0xfe,0x03,0x24,0x2b,0x10,0x02,0x00,
+0x00,0x10,0x10,0x36,0x24,0x80,0x03,0x02,0x00,0x12,0x02,0x00,0x25,0x80,0x02,0x02,
+0x70,0x51,0x25,0xae,0x78,0x51,0x30,0xae,0xa0,0x0e,0x00,0x0c,0x21,0x98,0xa0,0x00,
+0xf8,0xff,0x03,0x24,0x24,0x80,0x03,0x02,0x07,0x00,0x42,0x30,0x25,0x80,0x02,0x02,
+0x07,0x00,0x03,0x32,0x25,0xb0,0x02,0x3c,0x80,0x18,0x03,0x00,0x78,0x51,0x30,0xae,
+0x21,0x18,0x62,0x00,0x84,0x01,0x62,0x8c,0x21,0x20,0x40,0x02,0x24,0x10,0x53,0x00,
+0xce,0x0d,0x00,0x0c,0x74,0x51,0x22,0xae,0x7a,0x51,0x24,0x92,0x21,0x28,0x40,0x02,
+0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x5c,0x0d,0x00,0x08,0x28,0x00,0xbd,0x27,0xee,0x4e,0x00,0x08,
+0xff,0x00,0x84,0x30,0x02,0x80,0x02,0x3c,0x68,0x15,0x43,0x24,0x1f,0x00,0x04,0x24,
+0x78,0x51,0x62,0x8c,0xff,0xff,0x84,0x24,0x00,0x10,0x42,0x34,0x78,0x51,0x62,0xac,
+0xfb,0xff,0x81,0x04,0x94,0x00,0x63,0x24,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x78,0xff,0xbd,0x27,0x60,0x00,0xb0,0xaf,0x25,0xb0,0x10,0x3c,0x70,0x00,0xb4,0xaf,
+0xc4,0x02,0x14,0x36,0x00,0x00,0x80,0xae,0x74,0x00,0xb5,0xaf,0x6c,0x00,0xb3,0xaf,
+0x68,0x00,0xb2,0xaf,0x64,0x00,0xb1,0xaf,0x84,0x00,0xbf,0xaf,0x80,0x00,0xbe,0xaf,
+0x7c,0x00,0xb7,0xaf,0x78,0x00,0xb6,0xaf,0x04,0x00,0x02,0x36,0x04,0x0c,0x13,0x36,
+0x00,0x00,0x43,0x8c,0x00,0x00,0x62,0x8e,0x0f,0x00,0x11,0x3c,0x24,0x18,0x71,0x00,
+0x08,0x0c,0x12,0x36,0x4c,0x00,0xa2,0xaf,0x02,0xac,0x03,0x00,0x00,0x00,0x43,0x8e,
+0x00,0x00,0x00,0x00,0x50,0x00,0xa3,0xaf,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x21,0x20,0x00,0x00,0xdd,0x44,0x00,0x0c,
+0xff,0xff,0x25,0x36,0x10,0x00,0xa2,0xaf,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x7a,0x42,0x00,0x0c,
+0x01,0x00,0x04,0x24,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x21,0x20,0x00,0x00,0xdd,0x44,0x00,0x0c,0xff,0xff,0x25,0x36,
+0x14,0x00,0xa2,0xaf,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x7a,0x42,0x00,0x0c,0x21,0x20,0x00,0x00,
+0xe0,0x0e,0x05,0x36,0x00,0x00,0xad,0x8c,0xdc,0x0e,0x06,0x36,0x70,0x0e,0x07,0x36,
+0x18,0x00,0xad,0xaf,0x00,0x00,0xc2,0x8c,0x74,0x0e,0x08,0x36,0x78,0x0e,0x09,0x36,
+0x1c,0x00,0xa2,0xaf,0x00,0x00,0xe3,0x8c,0x7c,0x0e,0x0a,0x36,0x80,0x0e,0x0b,0x36,
+0x20,0x00,0xa3,0xaf,0x00,0x00,0x0d,0x8d,0x84,0x0e,0x0c,0x36,0x88,0x0e,0x17,0x36,
+0x24,0x00,0xad,0xaf,0x00,0x00,0x22,0x8d,0x8c,0x0e,0x0e,0x36,0xd0,0x0e,0x18,0x36,
+0x28,0x00,0xa2,0xaf,0x00,0x00,0x43,0x8d,0xd8,0x0e,0x11,0x36,0xd4,0x0e,0x10,0x36,
+0x2c,0x00,0xa3,0xaf,0x00,0x00,0x6d,0x8d,0xed,0x3f,0x04,0x3c,0xfb,0x92,0x84,0x34,
+0x30,0x00,0xad,0xaf,0x00,0x00,0x82,0x8d,0x25,0xb0,0x1e,0x3c,0x21,0xb0,0x00,0x00,
+0x34,0x00,0xa2,0xaf,0x00,0x00,0xe3,0x8e,0xff,0x03,0x0f,0x3c,0x38,0x00,0xa3,0xaf,
+0x00,0x00,0xcd,0x8d,0x00,0x00,0x00,0x00,0x3c,0x00,0xad,0xaf,0x00,0x00,0x02,0x8f,
+0x00,0x00,0x00,0x00,0x40,0x00,0xa2,0xaf,0x00,0x00,0x03,0x8e,0x00,0x00,0x00,0x00,
+0x44,0x00,0xa3,0xaf,0x00,0x00,0x2d,0x8e,0x00,0x00,0x00,0x00,0x48,0x00,0xad,0xaf,
+0x00,0x00,0xa4,0xac,0x00,0x00,0xc4,0xac,0x00,0x00,0xe4,0xac,0x00,0x00,0x04,0xad,
+0x00,0x00,0x24,0xad,0x00,0x00,0x44,0xad,0x00,0x00,0x64,0xad,0x00,0x00,0x84,0xad,
+0x00,0x00,0xe4,0xae,0x00,0x00,0xc4,0xad,0x00,0x00,0x04,0xaf,0x00,0x00,0x04,0xae,
+0x00,0x00,0x24,0xae,0xd0,0x51,0x00,0x08,0x00,0x00,0x00,0x00,0x7a,0x00,0xa2,0x12,
+0x00,0x10,0x03,0x3c,0xac,0x0e,0xc2,0x37,0x94,0x0e,0xc3,0x37,0x25,0xb0,0x09,0x3c,
+0x00,0x00,0x4a,0x8c,0xbc,0x0e,0x29,0x35,0x00,0x00,0x64,0x8c,0xb4,0x0e,0xc2,0x37,
+0x9c,0x0e,0xc3,0x37,0x00,0x00,0x45,0x8c,0x00,0x00,0x66,0x8c,0x00,0x00,0x27,0x8d,
+0x24,0x20,0x8f,0x00,0x00,0xd8,0x02,0x3c,0x24,0x10,0x42,0x01,0x24,0x28,0xaf,0x00,
+0x24,0x30,0xcf,0x00,0x24,0x38,0xef,0x00,0x02,0x24,0x04,0x00,0x20,0x01,0x03,0x24,
+0x01,0x00,0x42,0x2c,0x02,0x2c,0x05,0x00,0x02,0x34,0x06,0x00,0xf2,0x00,0x83,0x10,
+0x02,0x3c,0x07,0x00,0xf0,0x00,0xa3,0x10,0x20,0x00,0x03,0x24,0xee,0x00,0xc3,0x10,
+0x00,0x00,0x00,0x00,0xec,0x00,0xe3,0x10,0x01,0x00,0x08,0x24,0x80,0x00,0x03,0x24,
+0x08,0x00,0x83,0x10,0x21,0x20,0x00,0x00,0x06,0x00,0xa3,0x10,0x21,0x20,0x00,0x00,
+0xe0,0x03,0x03,0x24,0x03,0x00,0xc3,0x10,0x00,0x00,0x00,0x00,0xe5,0x00,0xe3,0x10,
+0x01,0x00,0x04,0x24,0x06,0x00,0x40,0x10,0x09,0x00,0x02,0x24,0x04,0x00,0x00,0x11,
+0x00,0x00,0x00,0x00,0x6d,0x01,0x80,0x14,0x25,0xb0,0x12,0x3c,0x09,0x00,0x02,0x24,
+0xde,0x00,0xc2,0x12,0x25,0xb0,0x04,0x3c,0x01,0x00,0xd6,0x26,0x0a,0x00,0xc2,0x2e,
+0x1d,0x01,0x40,0x10,0x00,0x00,0x00,0x00,0xc8,0xff,0xa0,0x16,0x01,0x00,0x02,0x24,
+0xa0,0x00,0x03,0x3c,0x25,0xb0,0x09,0x3c,0x30,0x54,0x62,0x34,0x04,0x0c,0x29,0x35,
+0x00,0x00,0x22,0xad,0x25,0xb0,0x0d,0x3c,0x08,0x00,0x02,0x3c,0xe4,0x00,0x42,0x34,
+0x08,0x0c,0xad,0x35,0x25,0xb0,0x09,0x3c,0x00,0x00,0xa2,0xad,0x28,0x0e,0x29,0x35,
+0x80,0x80,0x02,0x3c,0x00,0x00,0x22,0xad,0x14,0x02,0x04,0x3c,0x16,0x68,0x02,0x3c,
+0x48,0x01,0x83,0x34,0x40,0x0e,0xc5,0x37,0x44,0x0e,0xc6,0x37,0xa2,0x04,0x42,0x34,
+0x25,0xb0,0x0d,0x3c,0x00,0x00,0xa3,0xac,0x4c,0x0e,0xad,0x35,0x00,0x00,0xc2,0xac,
+0xd1,0x28,0x02,0x24,0x00,0x00,0xa2,0xad,0x14,0x02,0x03,0x3c,0x16,0x28,0x02,0x3c,
+0x4d,0x01,0x63,0x34,0x60,0x0e,0xc7,0x37,0x64,0x0e,0xc8,0x37,0xba,0x08,0x42,0x34,
+0x00,0x00,0xe3,0xac,0x25,0xb0,0x06,0x3c,0x00,0x00,0x02,0xad,0x00,0xfb,0x0d,0x3c,
+0x25,0xb0,0x09,0x3c,0x00,0xf8,0x02,0x3c,0xd1,0x28,0x07,0x24,0x6c,0x0e,0xc6,0x34,
+0x48,0x0e,0x29,0x35,0x01,0x00,0x42,0x34,0x01,0x00,0xad,0x35,0x00,0x00,0xc7,0xac,
+0x03,0x00,0x04,0x24,0x00,0x00,0x2d,0xad,0x00,0x00,0x22,0xad,0x84,0x0a,0x00,0x0c,
+0x58,0x00,0xaf,0xaf,0xa0,0x00,0x04,0x3c,0x25,0xb0,0x03,0x3c,0x25,0xb0,0x06,0x3c,
+0x25,0xb0,0x07,0x3c,0xe4,0x00,0x02,0x24,0x33,0x54,0x84,0x34,0x04,0x0c,0x63,0x34,
+0x08,0x0c,0xc6,0x34,0x28,0x0e,0xe7,0x34,0x00,0x00,0x64,0xac,0x00,0x00,0xc2,0xac,
+0x00,0x00,0xe0,0xac,0x01,0x00,0x02,0x24,0x58,0x00,0xaf,0x8f,0x8a,0xff,0xa2,0x16,
+0xac,0x0e,0xc2,0x37,0x00,0x10,0x03,0x3c,0x1f,0xdc,0x79,0x34,0x1f,0x8c,0x7f,0x34,
+0x23,0x8c,0x6d,0x34,0xa0,0x00,0x03,0x3c,0x30,0x54,0x65,0x34,0x00,0x01,0x17,0x3c,
+0x25,0xb0,0x09,0x3c,0x25,0xb0,0x03,0x3c,0x00,0x01,0xe2,0x36,0x20,0x08,0x29,0x35,
+0x20,0x08,0x63,0x34,0x00,0x00,0x30,0x8d,0x00,0x00,0x62,0xac,0x25,0xb0,0x03,0x3c,
+0x28,0x08,0x63,0x34,0x00,0x00,0x62,0xac,0x25,0xb0,0x02,0x3c,0x04,0x0c,0x42,0x34,
+0x00,0x00,0x45,0xac,0x25,0xb0,0x03,0x3c,0x08,0x00,0x02,0x3c,0xe4,0x00,0x42,0x34,
+0x08,0x0c,0x63,0x34,0x00,0x00,0x62,0xac,0x25,0xb0,0x03,0x3c,0x00,0x7c,0xf3,0x36,
+0x00,0x48,0xf4,0x36,0x30,0x0e,0xc6,0x37,0x34,0x0e,0xc7,0x37,0x80,0x80,0x02,0x3c,
+0x28,0x0e,0x63,0x34,0x00,0x00,0x62,0xac,0x00,0x00,0xd3,0xac,0x00,0x00,0xf4,0xac,
+0x14,0x02,0x06,0x3c,0x16,0x68,0x07,0x3c,0x38,0x0e,0xc8,0x37,0x40,0x0e,0xca,0x37,
+0x44,0x0e,0xcb,0x37,0x3c,0x0e,0xc9,0x37,0x02,0x01,0xc6,0x34,0xc7,0x04,0xe7,0x34,
+0x00,0x00,0x19,0xad,0x25,0xb0,0x03,0x3c,0x00,0x00,0x3f,0xad,0x00,0x00,0x46,0xad,
+0x25,0xb0,0x09,0x3c,0x00,0x00,0x67,0xad,0x25,0xb0,0x06,0x3c,0x00,0x10,0x07,0x3c,
+0x50,0x0e,0xcc,0x37,0x58,0x0e,0xce,0x37,0x5c,0x0e,0xd8,0x37,0xd1,0x28,0x02,0x24,
+0x23,0xdc,0xe7,0x34,0x4c,0x0e,0x29,0x35,0x6c,0x0e,0x63,0x34,0x54,0x0e,0xc6,0x34,
+0x00,0x00,0x22,0xad,0x00,0x00,0x62,0xac,0x14,0x02,0x09,0x3c,0x00,0x00,0x93,0xad,
+0x25,0xb0,0x02,0x3c,0x00,0x00,0xd4,0xac,0x00,0x00,0xc7,0xad,0x00,0x00,0x0d,0xaf,
+0x16,0x28,0x0d,0x3c,0x48,0x0e,0x42,0x34,0x00,0xf8,0x06,0x3c,0x02,0x01,0x29,0x35,
+0x07,0x0d,0xad,0x35,0x00,0xfb,0x03,0x3c,0x60,0x0e,0xd1,0x37,0x64,0x0e,0xd2,0x37,
+0x00,0x00,0x29,0xae,0x03,0x00,0x04,0x24,0x00,0x00,0x4d,0xae,0x00,0x00,0x43,0xac,
+0x00,0x00,0x46,0xac,0x84,0x0a,0x00,0x0c,0x58,0x00,0xaf,0xaf,0x00,0x02,0x02,0x3c,
+0x25,0xb0,0x07,0x3c,0x25,0xb0,0x09,0x3c,0xd1,0x28,0x42,0x34,0x4c,0x0e,0xe7,0x34,
+0x6c,0x0e,0x29,0x35,0x25,0xb0,0x0d,0x3c,0x00,0x00,0xe2,0xac,0x48,0x0e,0xad,0x35,
+0x00,0x00,0x22,0xad,0x00,0xf8,0x03,0x3c,0x00,0xfb,0x02,0x3c,0x00,0x00,0xa2,0xad,
+0x03,0x00,0x04,0x24,0x00,0x00,0xa3,0xad,0x84,0x0a,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x4c,0x00,0xa6,0x8f,0x25,0xb0,0x04,0x3c,0x04,0x0c,0x84,0x34,0x00,0x00,0x86,0xac,
+0x50,0x00,0xa9,0x8f,0x25,0xb0,0x07,0x3c,0x25,0xb0,0x0d,0x3c,0x00,0x01,0x10,0x32,
+0x08,0x0c,0xe7,0x34,0x28,0x0e,0xad,0x35,0x00,0x00,0xe9,0xac,0x2b,0x80,0x10,0x00,
+0x00,0x00,0xa0,0xad,0x58,0x00,0xaf,0x8f,0x17,0xff,0x00,0x16,0xac,0x0e,0xc2,0x37,
+0x25,0xb0,0x02,0x3c,0x25,0xb0,0x03,0x3c,0x20,0x08,0x42,0x34,0x28,0x08,0x63,0x34,
+0x00,0x00,0x57,0xac,0x25,0xb0,0x09,0x3c,0x00,0x00,0x77,0xac,0xac,0x0e,0xc2,0x37,
+0x94,0x0e,0xc3,0x37,0x00,0x00,0x4a,0x8c,0xbc,0x0e,0x29,0x35,0x00,0x00,0x64,0x8c,
+0xb4,0x0e,0xc2,0x37,0x9c,0x0e,0xc3,0x37,0x00,0x00,0x45,0x8c,0x00,0x00,0x66,0x8c,
+0x00,0x00,0x27,0x8d,0x24,0x20,0x8f,0x00,0x00,0xd8,0x02,0x3c,0x24,0x10,0x42,0x01,
+0x24,0x28,0xaf,0x00,0x24,0x30,0xcf,0x00,0x24,0x38,0xef,0x00,0x02,0x24,0x04,0x00,
+0x20,0x01,0x03,0x24,0x01,0x00,0x42,0x2c,0x02,0x2c,0x05,0x00,0x02,0x34,0x06,0x00,
+0x10,0xff,0x83,0x14,0x02,0x3c,0x07,0x00,0x80,0x00,0x03,0x24,0x16,0xff,0x83,0x14,
+0x21,0x40,0x00,0x00,0xc3,0x51,0x00,0x08,0x21,0x20,0x00,0x00,0xff,0xff,0x02,0x34,
+0xc4,0x02,0x84,0x34,0x00,0x00,0x82,0xac,0x94,0x0e,0xc3,0x37,0x9c,0x0e,0xc2,0x37,
+0xa4,0x0e,0xc4,0x37,0xac,0x0e,0xc7,0x37,0x00,0x00,0x66,0x8c,0x00,0x00,0x49,0x8c,
+0x00,0x00,0x8b,0x8c,0x00,0x00,0xe5,0x8c,0x02,0x80,0x07,0x3c,0x68,0x15,0xe7,0x24,
+0x0c,0x40,0xe3,0x8c,0x10,0x40,0xe4,0x8c,0xb4,0x0e,0xc2,0x37,0x00,0x00,0x47,0x8c,
+0x25,0xb0,0x0d,0x3c,0x00,0xfc,0x02,0x24,0x24,0x30,0xcf,0x00,0x24,0x28,0xaf,0x00,
+0xbc,0x0e,0xad,0x35,0x00,0x00,0xa8,0x8d,0x24,0x20,0x82,0x00,0x02,0x34,0x06,0x00,
+0x24,0x18,0x62,0x00,0x02,0x2c,0x05,0x00,0xc4,0x0e,0xca,0x37,0xcc,0x0e,0xcc,0x37,
+0xf0,0xff,0x02,0x3c,0xff,0x03,0x42,0x34,0x25,0x18,0x66,0x00,0x25,0x20,0x85,0x00,
+0x00,0x00,0x46,0x8d,0x24,0x48,0x2f,0x01,0x00,0x00,0x85,0x8d,0x24,0x38,0xef,0x00,
+0x24,0x20,0x82,0x00,0x24,0x18,0x62,0x00,0x82,0x49,0x09,0x00,0x82,0x39,0x07,0x00,
+0x0f,0xc0,0x02,0x3c,0xff,0xff,0x42,0x34,0x25,0x18,0x69,0x00,0x25,0x20,0x87,0x00,
+0x24,0x58,0x6f,0x01,0x24,0x40,0x0f,0x01,0x24,0x20,0x82,0x00,0x24,0x18,0x62,0x00,
+0x00,0x59,0x0b,0x00,0x00,0x41,0x08,0x00,0x24,0x30,0xcf,0x00,0x24,0x28,0xaf,0x00,
+0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,0x25,0x18,0x6b,0x00,0x25,0x20,0x88,0x00,
+0x02,0x34,0x06,0x00,0x02,0x2c,0x05,0x00,0x01,0x00,0xd6,0x26,0x0c,0x40,0x43,0xac,
+0x10,0x40,0x44,0xac,0x14,0x40,0x46,0xa4,0x16,0x40,0x45,0xa4,0x0a,0x00,0xc2,0x2e,
+0xe5,0xfe,0x40,0x14,0x00,0x00,0x00,0x00,0x18,0x00,0xad,0x8f,0x25,0xb0,0x02,0x3c,
+0xe0,0x0e,0x43,0x34,0x10,0x00,0xa6,0x8f,0x00,0x00,0x6d,0xac,0x1c,0x00,0xa3,0x8f,
+0xdc,0x0e,0x47,0x34,0x70,0x0e,0x48,0x34,0x00,0x00,0xe3,0xac,0x20,0x00,0xa7,0x8f,
+0x74,0x0e,0x49,0x34,0x78,0x0e,0x4a,0x34,0x00,0x00,0x07,0xad,0x24,0x00,0xad,0x8f,
+0x7c,0x0e,0x4b,0x34,0x80,0x0e,0x4c,0x34,0x00,0x00,0x2d,0xad,0x28,0x00,0xa3,0x8f,
+0x25,0xb0,0x0d,0x3c,0x84,0x0e,0xad,0x35,0x00,0x00,0x43,0xad,0x2c,0x00,0xa7,0x8f,
+0x88,0x0e,0x52,0x34,0x8c,0x0e,0x4e,0x34,0x00,0x00,0x67,0xad,0x30,0x00,0xa9,0x8f,
+0xd4,0x0e,0x51,0x34,0xd0,0x0e,0x42,0x34,0x00,0x00,0x89,0xad,0x34,0x00,0xa3,0x8f,
+0x0f,0x00,0x10,0x3c,0xff,0xff,0x05,0x36,0x00,0x00,0xa3,0xad,0x38,0x00,0xa7,0x8f,
+0x21,0x20,0x00,0x00,0x00,0x00,0x47,0xae,0x3c,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,
+0x00,0x00,0xc9,0xad,0x40,0x00,0xad,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x4d,0xac,
+0x44,0x00,0xa2,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0xae,0x48,0x00,0xa3,0x8f,
+0x00,0x00,0x00,0x00,0x00,0x00,0x43,0xae,0xba,0x44,0x00,0x0c,0x00,0x00,0x00,0x00,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x7a,0x42,0x00,0x0c,0x01,0x00,0x04,0x24,
+0x14,0x00,0xa6,0x8f,0xff,0xff,0x05,0x36,0xba,0x44,0x00,0x0c,0x21,0x20,0x00,0x00,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x84,0x00,0xbf,0x8f,0x80,0x00,0xbe,0x8f,
+0x7c,0x00,0xb7,0x8f,0x78,0x00,0xb6,0x8f,0x74,0x00,0xb5,0x8f,0x70,0x00,0xb4,0x8f,
+0x6c,0x00,0xb3,0x8f,0x68,0x00,0xb2,0x8f,0x64,0x00,0xb1,0x8f,0x60,0x00,0xb0,0x8f,
+0x21,0x20,0x00,0x00,0x7a,0x42,0x00,0x08,0x88,0x00,0xbd,0x27,0x94,0x0e,0x42,0x36,
+0x9c,0x0e,0x43,0x36,0xa4,0x0e,0x44,0x36,0xac,0x0e,0x45,0x36,0x02,0x80,0x0d,0x3c,
+0x00,0x00,0x47,0x8c,0x68,0x15,0xad,0x25,0x00,0x00,0x6a,0x8c,0x00,0x00,0x8c,0x8c,
+0x00,0x00,0xa3,0x8c,0x10,0x40,0xa4,0x8d,0xb4,0x0e,0x42,0x36,0x00,0x00,0x48,0x8c,
+0x0c,0x40,0xa5,0x8d,0x25,0xb0,0x02,0x3c,0x00,0xfc,0x13,0x24,0xbc,0x0e,0x42,0x34,
+0x24,0x18,0x6f,0x00,0x00,0x00,0x49,0x8c,0x02,0x1c,0x03,0x00,0x24,0x38,0xef,0x00,
+0x24,0x20,0x93,0x00,0xf0,0xff,0x06,0x3c,0x25,0x20,0x83,0x00,0xff,0x03,0xc6,0x34,
+0x02,0x3c,0x07,0x00,0xc4,0x0e,0x42,0x36,0x24,0x28,0xb3,0x00,0x24,0x40,0x0f,0x01,
+0xcc,0x0e,0x4b,0x36,0x25,0x28,0xa7,0x00,0x24,0x20,0x86,0x00,0x00,0x00,0x47,0x8c,
+0x24,0x50,0x4f,0x01,0x00,0x00,0x63,0x8d,0x82,0x41,0x08,0x00,0x0f,0xc0,0x02,0x3c,
+0xff,0xff,0x42,0x34,0x25,0x20,0x88,0x00,0x82,0x51,0x0a,0x00,0x24,0x28,0xa6,0x00,
+0x24,0x48,0x2f,0x01,0x24,0x88,0x82,0x00,0x25,0x28,0xaa,0x00,0x24,0x60,0x8f,0x01,
+0x00,0x49,0x09,0x00,0x25,0x88,0x29,0x02,0x24,0x28,0xa2,0x00,0x24,0x18,0x6f,0x00,
+0x00,0x61,0x0c,0x00,0x24,0x38,0xef,0x00,0x25,0x28,0xac,0x00,0x02,0x3c,0x07,0x00,
+0x02,0x1c,0x03,0x00,0x82,0x27,0x11,0x00,0x01,0x00,0x02,0x24,0x16,0x40,0xa3,0xa5,
+0x14,0x40,0xa7,0xa5,0x0c,0x40,0xa5,0xad,0x4a,0x00,0x82,0x10,0x10,0x40,0xb1,0xad,
+0x80,0x0c,0x4c,0x36,0x00,0x00,0x8a,0x8d,0x82,0x72,0x05,0x00,0xff,0x03,0xce,0x31,
+0x00,0x02,0xc3,0x31,0x25,0x10,0xd3,0x01,0x0b,0x70,0x43,0x00,0x82,0x85,0x0a,0x00,
+0x18,0x00,0xd0,0x01,0xff,0x03,0xaf,0x30,0x00,0x02,0xa3,0x30,0x25,0x10,0xf3,0x01,
+0x0b,0x78,0x43,0x00,0x02,0x75,0x11,0x00,0xff,0x03,0xce,0x31,0xc0,0xff,0x08,0x3c,
+0x25,0x18,0xd3,0x01,0x00,0x02,0xc2,0x31,0x00,0xfc,0x06,0x35,0x0b,0x70,0x62,0x00,
+0x24,0x38,0x46,0x01,0x94,0x0c,0x4a,0x36,0xff,0x0f,0x09,0x3c,0xff,0xff,0x29,0x35,
+0x88,0x0c,0x54,0x36,0x12,0x20,0x00,0x00,0x02,0x22,0x04,0x00,0x3f,0x00,0x82,0x30,
+0x18,0x00,0xf0,0x01,0x82,0x7a,0x11,0x00,0xff,0x03,0xef,0x31,0x00,0x14,0x02,0x00,
+0x25,0x38,0xe2,0x00,0x00,0x02,0xe3,0x31,0x25,0x10,0xf3,0x01,0x0b,0x78,0x43,0x00,
+0xc0,0x03,0x84,0x30,0x80,0x25,0x04,0x00,0x9c,0x0c,0x4b,0x36,0x12,0x28,0x00,0x00,
+0x02,0x2a,0x05,0x00,0xff,0x03,0xa2,0x30,0x25,0x10,0xe2,0x00,0x00,0x00,0x82,0xad,
+0x00,0x00,0x42,0x8d,0x00,0x00,0x00,0x00,0x24,0x10,0x49,0x00,0x25,0x10,0x44,0x00,
+0x00,0x00,0x42,0xad,0x00,0x00,0x8a,0x8e,0x00,0x00,0x00,0x00,0x24,0x40,0x48,0x01,
+0x82,0x85,0x08,0x00,0x18,0x00,0xd0,0x01,0x24,0x30,0x46,0x01,0x12,0x18,0x00,0x00,
+0x02,0x1a,0x03,0x00,0x3f,0x00,0x62,0x30,0x18,0x00,0xf0,0x01,0x00,0x14,0x02,0x00,
+0x25,0x30,0xc2,0x00,0xc0,0x03,0x63,0x30,0x80,0x1d,0x03,0x00,0x12,0x20,0x00,0x00,
+0x02,0x22,0x04,0x00,0xff,0x03,0x82,0x30,0x25,0x10,0xc2,0x00,0x00,0x00,0x82,0xae,
+0x00,0x00,0x62,0x8d,0x00,0x00,0x00,0x00,0x24,0x10,0x49,0x00,0x25,0x10,0x43,0x00,
+0x00,0x00,0x62,0xad,0x00,0x17,0x16,0x00,0x25,0xb0,0x03,0x3c,0xdd,0xdd,0x42,0x34,
+0xc4,0x02,0x63,0x34,0x00,0x00,0x62,0xac,0xec,0x52,0x00,0x08,0x00,0x00,0x00,0x00,
+0xe0,0xff,0xbd,0x27,0x44,0x00,0x02,0x24,0x10,0x00,0xa2,0xa3,0x49,0x00,0x03,0x24,
+0x47,0x00,0x02,0x24,0x02,0x80,0x07,0x3c,0x8c,0x97,0xe7,0x24,0x11,0x00,0xa3,0xa3,
+0x12,0x00,0xa2,0xa3,0x10,0x27,0x03,0x24,0x01,0x00,0x02,0x24,0x01,0x80,0x06,0x3c,
+0x10,0x00,0xa5,0x27,0x21,0x20,0xe0,0x00,0xe8,0x51,0xc6,0x24,0x0c,0x00,0xe3,0xac,
+0x14,0x00,0xe2,0xa0,0x18,0x00,0xbf,0xaf,0xfb,0x0c,0x00,0x0c,0x13,0x00,0xa0,0xa3,
+0x18,0x00,0xbf,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,
+0xd0,0xff,0xbd,0x27,0x25,0xb0,0x02,0x3c,0x20,0x00,0xb4,0xaf,0x1c,0x00,0xb3,0xaf,
+0x03,0x0d,0x44,0x34,0x2c,0x00,0xbf,0xaf,0x28,0x00,0xb6,0xaf,0x24,0x00,0xb5,0xaf,
+0x18,0x00,0xb2,0xaf,0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x00,0x83,0x90,
+0x42,0x00,0x45,0x34,0xff,0x00,0x73,0x30,0x70,0x00,0x74,0x32,0x29,0x00,0x80,0x16,
+0x8f,0x00,0x62,0x32,0xff,0xff,0x02,0x24,0x00,0x00,0xa2,0xa0,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x0f,0x00,0x11,0x3c,
+0x18,0x00,0x04,0x24,0xdd,0x44,0x00,0x0c,0xff,0xff,0x25,0x36,0x21,0x80,0x40,0x00,
+0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0xb3,0x0a,0x00,0x0c,
+0x64,0x00,0x04,0x24,0x00,0x80,0x06,0x36,0xff,0xff,0x25,0x36,0xba,0x44,0x00,0x0c,
+0x18,0x00,0x04,0x24,0x84,0x0a,0x00,0x0c,0x03,0x00,0x04,0x24,0x21,0x30,0xa0,0x02,
+0xff,0xff,0x25,0x36,0x5c,0x00,0x80,0x16,0x21,0x20,0x00,0x00,0x2c,0x00,0xbf,0x8f,
+0x28,0x00,0xb6,0x8f,0x24,0x00,0xb5,0x8f,0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,
+0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,0x25,0xb0,0x02,0x3c,
+0x42,0x00,0x42,0x34,0x30,0x00,0xbd,0x27,0x00,0x00,0x40,0xa0,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x00,0x00,0x82,0xa0,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x0f,0x00,0x11,0x3c,0x21,0x20,0x00,0x00,
+0xdd,0x44,0x00,0x0c,0xff,0xff,0x25,0x36,0x21,0xa8,0x40,0x00,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,
+0x7a,0x42,0x00,0x0c,0x01,0x00,0x04,0x24,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x21,0x20,0x00,0x00,0xdd,0x44,0x00,0x0c,
+0xff,0xff,0x25,0x36,0x21,0xb0,0x40,0x00,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x00,0x60,0x81,0x40,0x64,0x00,0x04,0x24,0xb3,0x0a,0x00,0x0c,0x08,0x00,0x10,0x3c,
+0xff,0xff,0x10,0x36,0x7a,0x42,0x00,0x0c,0x21,0x20,0x00,0x00,0x01,0x00,0x12,0x3c,
+0x24,0x30,0xb0,0x02,0x25,0x30,0xd2,0x00,0xff,0xff,0x25,0x36,0xba,0x44,0x00,0x0c,
+0x21,0x20,0x00,0x00,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0x24,0x80,0xd0,0x02,
+0x7a,0x42,0x00,0x0c,0x01,0x00,0x04,0x24,0x25,0x30,0x12,0x02,0xff,0xff,0x25,0x36,
+0xba,0x44,0x00,0x0c,0x21,0x20,0x00,0x00,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,
+0x7a,0x42,0x00,0x0c,0x21,0x20,0x00,0x00,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,
+0x01,0x00,0x21,0x38,0x00,0x60,0x81,0x40,0x0f,0x00,0x11,0x3c,0x18,0x00,0x04,0x24,
+0xdd,0x44,0x00,0x0c,0xff,0xff,0x25,0x36,0x21,0x80,0x40,0x00,0x00,0x60,0x01,0x40,
+0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,
+0x00,0x80,0x06,0x36,0xff,0xff,0x25,0x36,0xba,0x44,0x00,0x0c,0x18,0x00,0x04,0x24,
+0x84,0x0a,0x00,0x0c,0x03,0x00,0x04,0x24,0x21,0x30,0xa0,0x02,0xff,0xff,0x25,0x36,
+0xa6,0xff,0x80,0x12,0x21,0x20,0x00,0x00,0x25,0xb0,0x02,0x3c,0x03,0x0d,0x42,0x34,
+0x00,0x00,0x53,0xa0,0xba,0x44,0x00,0x0c,0x00,0x00,0x00,0x00,0xb3,0x0a,0x00,0x0c,
+0x64,0x00,0x04,0x24,0x7a,0x42,0x00,0x0c,0x01,0x00,0x04,0x24,0xff,0xff,0x25,0x36,
+0x21,0x30,0xc0,0x02,0xba,0x44,0x00,0x0c,0x21,0x20,0x00,0x00,0xb3,0x0a,0x00,0x0c,
+0x64,0x00,0x04,0x24,0x2c,0x00,0xbf,0x8f,0x28,0x00,0xb6,0x8f,0x24,0x00,0xb5,0x8f,
+0x20,0x00,0xb4,0x8f,0x1c,0x00,0xb3,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x21,0x20,0x00,0x00,0x7a,0x42,0x00,0x08,0x30,0x00,0xbd,0x27,
+0xd0,0xff,0xbd,0x27,0x28,0x00,0xb4,0xaf,0x02,0x80,0x14,0x3c,0x2c,0x00,0xbf,0xaf,
+0x24,0x00,0xb3,0xaf,0x20,0x00,0xb2,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,
+0x68,0x15,0x86,0x26,0x0c,0x40,0xc2,0x8c,0x00,0x00,0x00,0x00,0x82,0x17,0x02,0x00,
+0x01,0x00,0x42,0x30,0x07,0x00,0x40,0x14,0x68,0x15,0x85,0x26,0x08,0x40,0xc2,0x8c,
+0x01,0x00,0x03,0x24,0x42,0x17,0x02,0x00,0x03,0x00,0x42,0x30,0xf0,0x00,0x43,0x10,
+0x25,0xb0,0x02,0x3c,0x0c,0x40,0xa2,0x8c,0x01,0x00,0x03,0x24,0x82,0x17,0x02,0x00,
+0x01,0x00,0x44,0x30,0x0a,0x00,0x83,0x10,0x00,0x00,0x00,0x00,0x2c,0x00,0xbf,0x8f,
+0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,
+0x18,0x00,0xb0,0x8f,0x21,0x10,0x00,0x00,0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,
+0x08,0x40,0xa2,0x8c,0x00,0x00,0x00,0x00,0x42,0x17,0x02,0x00,0x03,0x00,0x42,0x30,
+0xf2,0xff,0x44,0x14,0x25,0xb0,0x02,0x3c,0x0e,0x0c,0x44,0x34,0x00,0x00,0x83,0x90,
+0x00,0x01,0x02,0x24,0xff,0x00,0x63,0x30,0x01,0x00,0x63,0x24,0x8b,0x01,0x62,0x10,
+0x00,0x00,0x00,0x00,0x00,0x00,0x83,0xa0,0x68,0x15,0x84,0x26,0x10,0x40,0x82,0x8c,
+0x01,0x00,0x03,0x24,0x82,0x17,0x02,0x00,0xa4,0x01,0x43,0x10,0x0f,0x00,0x10,0x3c,
+0xc7,0x42,0x92,0x90,0x68,0x15,0x90,0x26,0xc6,0x42,0x03,0x92,0x25,0xb0,0x11,0x3c,
+0x62,0x0c,0x22,0x36,0x00,0x00,0x52,0xa0,0x17,0x01,0x60,0x10,0x01,0x00,0x02,0x24,
+0x03,0x0d,0x23,0x36,0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,0x70,0x00,0x42,0x30,
+0x3e,0x01,0x40,0x14,0x63,0x0c,0x23,0x36,0xc4,0x42,0x02,0x96,0x00,0x00,0x00,0x00,
+0x23,0x20,0x52,0x00,0x2b,0x18,0x52,0x00,0x23,0x10,0x42,0x02,0x0a,0x10,0x83,0x00,
+0x03,0x00,0x42,0x2c,0x0b,0x01,0x40,0x10,0x00,0x00,0x00,0x00,0xc4,0x42,0x03,0x96,
+0x63,0x0c,0x22,0x36,0x00,0x00,0x43,0xa0,0x68,0x15,0x83,0x26,0xc3,0x42,0x62,0x90,
+0x08,0x40,0x66,0x8c,0xc2,0x42,0x72,0xa0,0x23,0x20,0x52,0x00,0x2b,0x38,0x42,0x02,
+0x23,0x50,0x42,0x02,0x02,0x2c,0x06,0x00,0x0b,0x50,0x87,0x00,0x3f,0x00,0xa5,0x30,
+0x3f,0x00,0xc4,0x30,0x24,0x00,0x02,0x24,0x20,0x00,0x03,0x24,0x23,0x10,0x44,0x00,
+0x2d,0x01,0x40,0x15,0x23,0x18,0x65,0x00,0x21,0x30,0x80,0x00,0x21,0x48,0xa0,0x00,
+0x02,0x80,0x0b,0x3c,0x68,0x15,0x83,0x26,0x80,0x10,0x06,0x00,0x21,0x10,0x43,0x00,
+0x0c,0x40,0x63,0x8c,0x18,0x40,0x44,0x8c,0xff,0x03,0x67,0x30,0x1b,0x01,0xe0,0x10,
+0x82,0x2d,0x04,0x00,0x00,0x02,0x62,0x30,0x04,0x00,0x40,0x10,0x18,0x00,0xe5,0x00,
+0x00,0xfc,0x02,0x24,0x25,0x38,0xe2,0x00,0x18,0x00,0xe5,0x00,0x82,0x22,0x03,0x00,
+0xff,0x03,0x84,0x30,0x00,0x02,0x83,0x30,0x12,0x10,0x00,0x00,0x02,0x12,0x02,0x00,
+0x03,0x00,0x60,0x10,0xff,0x03,0x48,0x30,0x00,0xfc,0x02,0x24,0x25,0x20,0x82,0x00,
+0x18,0x00,0x85,0x00,0x80,0x2d,0x05,0x00,0x25,0xb0,0x06,0x3c,0x80,0x0c,0xc7,0x34,
+0x94,0x0c,0xc6,0x34,0x12,0x20,0x00,0x00,0x02,0x22,0x04,0x00,0x3f,0x00,0x82,0x30,
+0x00,0x14,0x02,0x00,0x25,0x28,0xa2,0x00,0x25,0x28,0xa8,0x00,0x10,0x00,0xa5,0xaf,
+0x00,0x00,0xe5,0xac,0x00,0x00,0xc3,0x8c,0xff,0x0f,0x02,0x3c,0xc0,0x03,0x84,0x30,
+0xff,0xff,0x42,0x34,0x80,0x25,0x04,0x00,0x24,0x18,0x62,0x00,0x25,0x18,0x64,0x00,
+0x10,0x00,0xa3,0xaf,0x00,0x00,0xc3,0xac,0x68,0x15,0x83,0x26,0x08,0x40,0x62,0x8c,
+0x00,0x00,0x00,0x00,0x08,0x01,0x40,0x04,0xc0,0x28,0x09,0x00,0x21,0x28,0xa3,0x00,
+0xac,0x40,0xa3,0x90,0x25,0xb0,0x04,0x3c,0x22,0x0a,0x82,0x34,0x00,0x00,0x43,0xa0,
+0xad,0x40,0xa6,0x90,0x23,0x0a,0x82,0x34,0x24,0x0a,0x87,0x34,0x00,0x00,0x46,0xa0,
+0xae,0x40,0xa3,0x90,0x25,0x0a,0x86,0x34,0x26,0x0a,0x88,0x34,0x00,0x00,0xe3,0xa0,
+0xaf,0x40,0xa2,0x90,0x27,0x0a,0x87,0x34,0x28,0x0a,0x89,0x34,0x00,0x00,0xc2,0xa0,
+0xb0,0x40,0xa3,0x90,0x29,0x0a,0x84,0x34,0x00,0x00,0x03,0xa1,0xb1,0x40,0xa2,0x90,
+0x00,0x00,0x00,0x00,0x00,0x00,0xe2,0xa0,0xb2,0x40,0xa3,0x90,0x00,0x00,0x00,0x00,
+0x00,0x00,0x23,0xa1,0xb3,0x40,0xa2,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0xa0,
+0x8e,0x7d,0x63,0x91,0x22,0x00,0x02,0x24,0x03,0x00,0x62,0x10,0x92,0x00,0x02,0x24,
+0x62,0xff,0x62,0x14,0x00,0x00,0x00,0x00,0x68,0x15,0x82,0x26,0x08,0x40,0x43,0x8c,
+0x01,0x00,0x44,0x39,0x24,0x00,0x02,0x24,0x02,0x1a,0x03,0x00,0x3f,0x00,0x63,0x30,
+0x01,0x00,0x84,0x30,0x04,0x01,0x80,0x10,0x23,0x28,0x43,0x00,0x42,0x18,0x0a,0x00,
+0x40,0x10,0x03,0x00,0x21,0x50,0x43,0x00,0x68,0x15,0x83,0x26,0xc3,0x42,0x62,0x90,
+0x00,0x00,0x00,0x00,0x2b,0x10,0x42,0x02,0x08,0x01,0x40,0x10,0x21,0x20,0x00,0x00,
+0x2b,0x10,0x45,0x01,0x07,0x00,0x40,0x10,0x24,0x00,0x04,0x24,0x08,0x40,0x62,0x8c,
+0x00,0x00,0x00,0x00,0x02,0x12,0x02,0x00,0x3f,0x00,0x42,0x30,0x21,0x20,0x4a,0x00,
+0x68,0x15,0x83,0x26,0x80,0x10,0x04,0x00,0x10,0x40,0x66,0x8c,0x21,0x10,0x43,0x00,
+0x18,0x40,0x44,0x8c,0x82,0x3a,0x06,0x00,0xff,0x03,0xe7,0x30,0xf0,0x00,0xe0,0x10,
+0x82,0x2d,0x04,0x00,0x00,0x02,0xe2,0x30,0x04,0x00,0x40,0x10,0x18,0x00,0xe5,0x00,
+0x00,0xfc,0x02,0x24,0x25,0x38,0xe2,0x00,0x18,0x00,0xe5,0x00,0x02,0x25,0x06,0x00,
+0xff,0x03,0x84,0x30,0x00,0x02,0x83,0x30,0x12,0x10,0x00,0x00,0x02,0x12,0x02,0x00,
+0x03,0x00,0x60,0x10,0xff,0x03,0x48,0x30,0x00,0xfc,0x02,0x24,0x25,0x20,0x82,0x00,
+0x18,0x00,0x85,0x00,0x80,0x2d,0x05,0x00,0x25,0xb0,0x06,0x3c,0x88,0x0c,0xc7,0x34,
+0x9c,0x0c,0xc6,0x34,0x12,0x20,0x00,0x00,0x02,0x22,0x04,0x00,0x3f,0x00,0x82,0x30,
+0x00,0x14,0x02,0x00,0x25,0x28,0xa2,0x00,0x25,0x28,0xa8,0x00,0x10,0x00,0xa5,0xaf,
+0x00,0x00,0xe5,0xac,0x00,0x00,0xc3,0x8c,0xff,0x0f,0x02,0x3c,0xc0,0x03,0x84,0x30,
+0xff,0xff,0x42,0x34,0x80,0x25,0x04,0x00,0x24,0x18,0x62,0x00,0x25,0x18,0x64,0x00,
+0x10,0x00,0xa3,0xaf,0x00,0x00,0xc3,0xac,0x95,0x54,0x00,0x08,0x00,0x00,0x00,0x00,
+0x80,0x0c,0x42,0x34,0x00,0x00,0x43,0x8c,0xc0,0xff,0x02,0x3c,0x21,0x88,0x00,0x00,
+0x24,0x28,0x62,0x00,0xc0,0xff,0x04,0x3c,0x8a,0x55,0x00,0x08,0x18,0x40,0xc3,0x24,
+0x01,0x00,0x31,0x26,0x25,0x00,0x22,0x2e,0x0d,0x00,0x40,0x10,0x02,0x80,0x0b,0x3c,
+0x00,0x00,0x62,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x44,0x00,0xf8,0xff,0x45,0x14,
+0x04,0x00,0x63,0x24,0x08,0x40,0xc2,0x8c,0xc0,0xff,0x03,0x24,0x3f,0x00,0x24,0x32,
+0x24,0x10,0x43,0x00,0x25,0x10,0x44,0x00,0x08,0x40,0xc2,0xac,0x02,0x80,0x0b,0x3c,
+0x8e,0x7d,0x63,0x91,0x22,0x00,0x02,0x24,0x3e,0x00,0x62,0x10,0x92,0x00,0x02,0x24,
+0x3d,0x00,0x62,0x10,0x25,0xb0,0x02,0x3c,0x25,0xb0,0x02,0x3c,0x24,0x0a,0x42,0x34,
+0x00,0x00,0x44,0x8c,0x3f,0x3f,0x03,0x3c,0x3f,0x3f,0x63,0x34,0x24,0x20,0x83,0x00,
+0x02,0x80,0x02,0x3c,0x02,0x80,0x03,0x3c,0x16,0x56,0x53,0x24,0x1e,0x57,0x72,0x24,
+0x21,0x88,0x00,0x00,0xb1,0x55,0x00,0x08,0x10,0x00,0xa4,0xaf,0xd4,0x45,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x47,0x00,0x40,0x10,0x68,0x15,0x85,0x26,0x01,0x00,0x31,0x26,
+0x21,0x00,0x22,0x2e,0x17,0x00,0x40,0x10,0x68,0x15,0x84,0x26,0xc0,0x80,0x11,0x00,
+0x10,0x00,0xa4,0x27,0x21,0x28,0x13,0x02,0xd4,0x45,0x00,0x0c,0x04,0x00,0x06,0x24,
+0x21,0x28,0x12,0x02,0x10,0x00,0xa4,0x27,0xf0,0xff,0x40,0x14,0x04,0x00,0x06,0x24,
+0x68,0x15,0x85,0x26,0x08,0x40,0xa3,0x8c,0xc0,0xff,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x3f,0x00,0x24,0x32,0x24,0x18,0x62,0x00,0x00,0x24,0x04,0x00,0xff,0x7f,0x02,0x3c,
+0x25,0x18,0x64,0x00,0xff,0xff,0x42,0x34,0x24,0x18,0x62,0x00,0x08,0x40,0xa3,0xac,
+0x68,0x15,0x84,0x26,0x0c,0x40,0x83,0x8c,0x00,0x40,0x02,0x3c,0x25,0x18,0x62,0x00,
+0x25,0xb0,0x02,0x3c,0x0e,0x0c,0x42,0x34,0x0c,0x40,0x83,0xac,0x00,0x00,0x40,0xa0,
+0x8f,0x54,0x00,0x08,0x68,0x15,0x85,0x26,0xc6,0x42,0x02,0xa2,0xba,0x54,0x00,0x08,
+0xc4,0x42,0x12,0xa6,0xda,0x53,0x00,0x0c,0x00,0x00,0x00,0x00,0xc9,0x54,0x00,0x08,
+0xc4,0x42,0x12,0xa6,0x25,0xb0,0x02,0x3c,0x88,0x0c,0x42,0x34,0x00,0x00,0x44,0x8c,
+0x02,0x80,0x03,0x3c,0x68,0x15,0x66,0x24,0xc0,0xff,0x02,0x3c,0x24,0x28,0x82,0x00,
+0x21,0x88,0x00,0x00,0xc0,0xff,0x04,0x3c,0xe6,0x55,0x00,0x08,0x18,0x40,0xc3,0x24,
+0x01,0x00,0x31,0x26,0x25,0x00,0x22,0x2e,0xb8,0xff,0x40,0x10,0x25,0xb0,0x02,0x3c,
+0x00,0x00,0x62,0x8c,0x00,0x00,0x00,0x00,0x24,0x10,0x44,0x00,0xf8,0xff,0x45,0x14,
+0x04,0x00,0x63,0x24,0x08,0x40,0xc2,0x8c,0x3f,0x00,0x23,0x32,0xff,0xc0,0x04,0x24,
+0x24,0x10,0x44,0x00,0x00,0x1a,0x03,0x00,0x25,0x10,0x43,0x00,0x9c,0x55,0x00,0x08,
+0x08,0x40,0xc2,0xac,0x08,0x40,0xa3,0x8c,0xc0,0xff,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x3f,0x00,0x24,0x32,0x24,0x18,0x62,0x00,0x00,0x24,0x04,0x00,0x25,0x18,0x64,0x00,
+0x00,0x80,0x02,0x3c,0xc5,0x55,0x00,0x08,0x25,0x18,0x62,0x00,0xcc,0xff,0x02,0x24,
+0x00,0x00,0x62,0xa0,0xcd,0x54,0x00,0x08,0x68,0x15,0x83,0x26,0x25,0xb0,0x02,0x3c,
+0x94,0x0c,0x43,0x34,0x80,0x0c,0x42,0x34,0x00,0x00,0x44,0xac,0x00,0x00,0x60,0xac,
+0x0d,0x55,0x00,0x08,0x68,0x15,0x83,0x26,0x2f,0x00,0xe0,0x10,0x21,0x30,0x00,0x00,
+0x2b,0x10,0x42,0x01,0x21,0x20,0x8a,0x00,0x00,0x00,0x42,0x38,0x24,0x00,0x06,0x24,
+0x2b,0x18,0x43,0x01,0x0b,0x30,0x82,0x00,0xcd,0xfe,0x60,0x10,0x20,0x00,0x09,0x24,
+0x68,0x15,0x83,0x26,0x0a,0x40,0x62,0x94,0x02,0x80,0x0b,0x3c,0x3f,0x00,0x42,0x30,
+0xe0,0x54,0x00,0x08,0x21,0x48,0x4a,0x00,0x21,0x28,0xa3,0x00,0xb4,0x41,0xa3,0x90,
+0x25,0xb0,0x04,0x3c,0x22,0x0a,0x82,0x34,0x00,0x00,0x43,0xa0,0xb5,0x41,0xa6,0x90,
+0x23,0x0a,0x82,0x34,0x24,0x0a,0x87,0x34,0x00,0x00,0x46,0xa0,0xb6,0x41,0xa3,0x90,
+0x25,0x0a,0x86,0x34,0x26,0x0a,0x88,0x34,0x00,0x00,0xe3,0xa0,0xb7,0x41,0xa2,0x90,
+0x27,0x0a,0x87,0x34,0x28,0x0a,0x89,0x34,0x00,0x00,0xc2,0xa0,0xb8,0x41,0xa3,0x90,
+0x29,0x0a,0x84,0x34,0x00,0x00,0x03,0xa1,0xb9,0x41,0xa2,0x90,0x00,0x00,0x00,0x00,
+0x00,0x00,0xe2,0xa0,0xba,0x41,0xa3,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0xa1,
+0xbb,0x41,0xa2,0x90,0x2d,0x55,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xa0,
+0xad,0x54,0x00,0x08,0x68,0x15,0x84,0x26,0x23,0x10,0x8a,0x00,0x2b,0x18,0x44,0x01,
+0x2b,0x20,0x45,0x01,0x0b,0x30,0x43,0x00,0xa1,0xfe,0x80,0x14,0x23,0x48,0xaa,0x00,
+0xde,0x54,0x00,0x08,0x21,0x48,0x00,0x00,0xff,0xff,0x43,0x25,0x42,0x18,0x03,0x00,
+0x40,0x10,0x03,0x00,0x21,0x10,0x43,0x00,0x40,0x55,0x00,0x08,0x01,0x00,0x4a,0x24,
+0x25,0xb0,0x02,0x3c,0x9c,0x0c,0x43,0x34,0x88,0x0c,0x42,0x34,0x00,0x00,0x44,0xac,
+0x00,0x00,0x60,0xac,0x95,0x54,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x40,0x62,0x8c,
+0x00,0x00,0x00,0x00,0x02,0x12,0x02,0x00,0x3f,0x00,0x42,0x30,0x23,0x18,0x4a,0x00,
+0x2b,0x10,0x42,0x01,0x4e,0x55,0x00,0x08,0x0b,0x20,0x62,0x00,0xff,0xff,0x05,0x36,
+0x60,0x00,0x06,0x24,0xba,0x44,0x00,0x0c,0x24,0x00,0x04,0x24,0x84,0x0a,0x00,0x0c,
+0xe8,0x03,0x04,0x24,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x01,0x00,0x21,0x38,
+0x00,0x60,0x81,0x40,0x24,0x00,0x04,0x24,0xdd,0x44,0x00,0x0c,0xff,0xff,0x05,0x36,
+0x1f,0x00,0x52,0x30,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0xb3,0x0a,0x00,0x0c,0x64,0x00,0x04,0x24,0xb4,0x54,0x00,0x08,0x68,0x15,0x90,0x26,
+0x00,0xff,0x84,0x30,0x02,0x22,0x04,0x00,0x08,0x00,0x80,0x10,0x02,0x80,0x02,0x3c,
+0xff,0x00,0x02,0x24,0x04,0x00,0x82,0x10,0xcc,0xff,0x03,0x24,0x02,0x80,0x02,0x3c,
+0x08,0x00,0xe0,0x03,0x4e,0x58,0x43,0xa0,0x02,0x80,0x02,0x3c,0x08,0x00,0xe0,0x03,
+0x4e,0x58,0x44,0xa0,0x02,0x24,0x04,0x00,0xff,0x00,0x84,0x30,0xc0,0x10,0x04,0x00,
+0x21,0x10,0x44,0x00,0x80,0x10,0x02,0x00,0x21,0x10,0x44,0x00,0x02,0x80,0x03,0x3c,
+0x80,0x10,0x02,0x00,0x68,0x15,0x63,0x24,0x20,0x00,0x84,0x2c,0x09,0x00,0x80,0x10,
+0x21,0x10,0x43,0x00,0x68,0x51,0x43,0x8c,0x25,0xb0,0x02,0x3c,0xc4,0x02,0x42,0x34,
+0x02,0x19,0x03,0x00,0x7f,0x00,0x63,0x30,0x00,0x00,0x43,0xac,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,0x44,0x79,0x43,0x8c,0x25,0xb0,0x02,0x3c,
+0xc4,0x02,0x42,0x34,0x02,0x19,0x03,0x00,0x7f,0x00,0x63,0x30,0x00,0x00,0x43,0xac,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xff,0x00,0x85,0x30,0xd2,0xff,0xa3,0x24,
+0xfe,0xff,0xa2,0x24,0xda,0xff,0xa4,0x24,0x04,0x00,0x63,0x2c,0x08,0x00,0x84,0x2c,
+0x06,0x00,0x60,0x14,0xff,0x00,0x42,0x30,0xf0,0xff,0xa2,0x24,0xfc,0xff,0xa3,0x24,
+0x16,0x00,0x46,0x2c,0x03,0x00,0x80,0x10,0xff,0x00,0x62,0x30,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0xfa,0xff,0xa3,0x24,0xfc,0xff,0xc0,0x10,0x21,0x10,0xa0,0x00,
+0x08,0x00,0xe0,0x03,0xff,0x00,0x62,0x30,0x25,0xb0,0x04,0x3c,0x03,0x0d,0x85,0x34,
+0x00,0x00,0xa3,0x90,0x2d,0x0a,0x84,0x34,0xff,0x00,0x63,0x30,0x08,0x00,0x63,0x34,
+0x00,0x00,0xa3,0xa0,0x00,0x00,0xa2,0x90,0x00,0x00,0x00,0x00,0xf7,0x00,0x42,0x30,
+0x00,0x00,0xa2,0xa0,0x00,0x00,0x83,0x90,0x00,0x00,0x00,0x00,0x3f,0x00,0x63,0x30,
+0x00,0x00,0x83,0xa0,0x00,0x00,0x82,0x90,0x80,0xff,0x03,0x24,0x25,0x10,0x43,0x00,
+0x00,0x00,0x82,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x25,0xb0,0x02,0x3c,
+0xff,0x00,0x03,0x3c,0x82,0x01,0x49,0x34,0x81,0x01,0x48,0x34,0x24,0x10,0x83,0x00,
+0x02,0x3c,0x02,0x00,0x00,0xff,0x63,0x34,0x02,0x80,0x02,0x3c,0x68,0x15,0x45,0x24,
+0x02,0x32,0x04,0x00,0x01,0x00,0x02,0x24,0x24,0x20,0x83,0x00,0xc2,0x4c,0xa2,0xa0,
+0xb0,0x4c,0xa0,0xac,0xb4,0x4c,0xa0,0xac,0xb8,0x4c,0xa0,0xac,0x06,0x00,0x80,0x14,
+0xbc,0x4c,0xa0,0xac,0x00,0x00,0x02,0x91,0x00,0x00,0x23,0x91,0xc0,0x4c,0xa2,0xa0,
+0x08,0x00,0xe0,0x03,0xc1,0x4c,0xa3,0xa0,0xc1,0x4c,0xa7,0xa0,0x08,0x00,0xe0,0x03,
+0xc0,0x4c,0xa6,0xa0,0x02,0x80,0x03,0x3c,0x68,0x15,0x63,0x24,0xc1,0x4c,0x66,0x90,
+0xc0,0x4c,0x65,0x90,0x25,0xb0,0x02,0x3c,0x82,0x01,0x44,0x34,0x81,0x01,0x42,0x34,
+0x00,0x00,0x45,0xa0,0x00,0x00,0x86,0xa0,0x08,0x00,0xe0,0x03,0xc2,0x4c,0x60,0xa0,
+0x02,0x80,0x08,0x3c,0x68,0x15,0x04,0x25,0xc2,0x4c,0x82,0x90,0x00,0x00,0x00,0x00,
+0x15,0x00,0x40,0x10,0x21,0x18,0x00,0x00,0xb4,0x4c,0x82,0x8c,0xb0,0x4c,0x85,0x8c,
+0x25,0xb0,0x03,0x3c,0x40,0x11,0x02,0x00,0x2b,0x10,0xa2,0x00,0x82,0x01,0x67,0x34,
+0x0f,0x00,0x40,0x10,0x81,0x01,0x66,0x34,0xc1,0x4c,0x83,0x90,0xc0,0x4c,0x82,0x90,
+0xf0,0x00,0x63,0x30,0x1f,0x00,0x42,0x30,0x00,0x00,0xc2,0xa0,0x00,0x00,0xe3,0xa0,
+0x68,0x15,0x02,0x25,0x01,0x00,0x03,0x24,0xbc,0x4c,0x40,0xac,0xb0,0x4c,0x40,0xac,
+0xb4,0x4c,0x40,0xac,0xb8,0x4c,0x40,0xac,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
+0xb8,0x4c,0x82,0x8c,0x25,0xb0,0x03,0x3c,0x82,0x01,0x69,0x34,0x40,0x11,0x02,0x00,
+0x2b,0x10,0xa2,0x00,0x0e,0x00,0x40,0x14,0x81,0x01,0x66,0x34,0xbc,0x4c,0x82,0x8c,
+0x00,0x00,0x00,0x00,0x40,0x11,0x02,0x00,0x2b,0x10,0xa2,0x00,0x08,0x00,0x40,0x14,
+0x00,0x00,0x00,0x00,0xc1,0x4c,0x83,0x90,0xc0,0x4c,0x82,0x90,0x00,0x00,0x00,0x00,
+0x00,0x00,0xc2,0xa0,0x00,0x00,0x23,0xa1,0xf7,0x56,0x00,0x08,0x68,0x15,0x02,0x25,
+0xc1,0x4c,0x83,0x90,0xc0,0x4c,0x82,0x90,0xf0,0x00,0x63,0x30,0x7f,0x00,0x42,0x30,
+0x00,0x00,0xc2,0xa0,0x00,0x00,0x23,0xa1,0xf7,0x56,0x00,0x08,0x68,0x15,0x02,0x25,
+0x02,0x00,0x03,0x24,0x02,0x80,0x02,0x3c,0x08,0x00,0xe0,0x03,0x3d,0x58,0x43,0xa0,
+0xcc,0xff,0x03,0x24,0x02,0x80,0x02,0x3c,0x08,0x00,0xe0,0x03,0x3d,0x58,0x43,0xa0,
+0x25,0xb0,0x03,0x3c,0x33,0x02,0x65,0x34,0x00,0x11,0x04,0x00,0x00,0x00,0xa2,0xa0,
+0x30,0x02,0x63,0x34,0x00,0x00,0x65,0x8c,0x0f,0x00,0x02,0x3c,0xff,0xff,0x42,0x34,
+0x24,0x28,0xa2,0x00,0x01,0x00,0x03,0x24,0x04,0x18,0x83,0x00,0x02,0x00,0xa0,0x10,
+0x21,0x10,0x00,0x00,0xff,0xff,0x62,0x30,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0xe0,0xff,0xbd,0x27,0x14,0x00,0xb1,0xaf,0x25,0xb0,0x11,0x3c,0x18,0x00,0xb2,0xaf,
+0x4c,0x00,0x22,0x36,0x1c,0x00,0xbf,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x00,0x44,0x90,
+0x02,0x80,0x03,0x3c,0x02,0x00,0x02,0x24,0xff,0x00,0x84,0x30,0x07,0x00,0x82,0x10,
+0x68,0x15,0x72,0x24,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb2,0x8f,0x14,0x00,0xb1,0x8f,
+0x10,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0xe6,0x63,0x43,0x96,
+0x01,0x00,0x02,0x24,0xf7,0xff,0x62,0x14,0x21,0x20,0x00,0x00,0x22,0x57,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x24,0x22,0x57,0x00,0x0c,0x21,0x80,0x40,0x00,
+0x25,0x80,0x02,0x02,0x33,0x02,0x23,0x36,0x08,0x00,0x02,0x24,0xff,0xff,0x10,0x32,
+0x40,0x00,0x25,0x36,0x00,0x00,0x62,0xa0,0xea,0xff,0x00,0x16,0x00,0x00,0x00,0x00,
+0x00,0x00,0xa2,0x94,0xe4,0x63,0x43,0x96,0xff,0xdf,0x42,0x30,0x00,0x20,0x44,0x34,
+0x01,0x00,0x63,0x24,0xe4,0x63,0x43,0xa6,0x00,0x00,0xa2,0xa4,0x00,0x00,0xa4,0xa4,
+0x3f,0x57,0x00,0x08,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x18,0x03,0x42,0x34,0x80,0x5d,0x63,0x24,0x00,0x00,0x43,0xac,0x63,0x00,0x02,0x24,
+0xff,0xff,0x42,0x24,0xff,0xff,0x41,0x04,0xff,0xff,0x42,0x24,0x02,0x80,0x02,0x3c,
+0x88,0x7d,0x45,0x94,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0x8b,0x7d,0x66,0x90,
+0x98,0x7d,0x47,0x90,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0xa3,0x7d,0x69,0x90,
+0xa5,0x7d,0x4a,0x90,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0xa8,0x7d,0x6b,0x90,
+0xaa,0x7d,0x4c,0x90,0x07,0x00,0x03,0x24,0x02,0x80,0x02,0x3c,0x25,0xb0,0x04,0x3c,
+0x95,0x7d,0x43,0xa0,0xb0,0x03,0x84,0x34,0x02,0x80,0x02,0x3c,0x02,0x80,0x18,0x3c,
+0x8a,0x7d,0x08,0x93,0x00,0x00,0x85,0xac,0x96,0x7d,0x40,0xa0,0x02,0x80,0x02,0x3c,
+0x00,0x00,0x86,0xac,0x02,0x80,0x0f,0x3c,0x97,0x7d,0x40,0xa0,0x02,0x80,0x02,0x3c,
+0x00,0x00,0x87,0xac,0x68,0x15,0xee,0x25,0xb8,0x7d,0x40,0xa0,0xfd,0xff,0x02,0x24,
+0xd5,0x4a,0xc2,0xa1,0x01,0x00,0x03,0x24,0x00,0x78,0x02,0x24,0xd4,0x4a,0xc3,0xa1,
+0xd8,0x4a,0xc2,0xa5,0xff,0x07,0x03,0x24,0x0f,0x00,0x0d,0x31,0x02,0x00,0x02,0x24,
+0xda,0x4a,0xc3,0xa5,0x00,0x00,0x88,0xac,0x00,0x00,0x89,0xac,0x00,0x00,0x8a,0xac,
+0x00,0x00,0x8b,0xac,0x00,0x00,0x8c,0xac,0x17,0x00,0xa2,0x11,0x02,0x80,0x02,0x3c,
+0x8a,0x7d,0x02,0x93,0x01,0x00,0x03,0x24,0x0f,0x00,0x42,0x30,0x05,0x00,0x43,0x10,
+0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,0xca,0x7d,0x40,0xa4,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x3c,0x68,0x15,0xe4,0x25,0x02,0xbc,0x42,0x34,
+0x68,0x4b,0x82,0xac,0x15,0x15,0x03,0x3c,0x02,0x02,0x02,0x3c,0x07,0x07,0x63,0x34,
+0x64,0x4b,0x82,0xac,0x02,0x80,0x02,0x3c,0x60,0x4b,0x83,0xac,0xca,0x7d,0x40,0xa4,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x8f,0x7d,0x44,0x90,0x06,0x00,0x03,0x24,
+0x15,0x00,0x83,0x10,0x0b,0x00,0x02,0x24,0x0a,0x00,0x82,0x10,0x00,0xe0,0x02,0x3c,
+0x68,0x15,0xe4,0x25,0x00,0xb2,0x42,0x34,0x00,0x1c,0x03,0x3c,0x68,0x4b,0x82,0xac,
+0x00,0x1c,0x63,0x34,0x00,0x04,0x02,0x24,0x60,0x4b,0x83,0xac,0x9a,0x57,0x00,0x08,
+0x64,0x4b,0x82,0xac,0x00,0x80,0x02,0x3c,0x00,0xbc,0x42,0x34,0x15,0x15,0x03,0x3c,
+0x68,0x4b,0xc2,0xad,0x07,0x07,0x63,0x34,0x03,0x03,0x02,0x3c,0x60,0x4b,0xc3,0xad,
+0x9a,0x57,0x00,0x08,0x64,0x4b,0xc2,0xad,0x00,0xc0,0x02,0x3c,0x00,0xb2,0x42,0x34,
+0x1c,0x1c,0x03,0x3c,0x68,0x4b,0xc2,0xad,0x07,0x07,0x63,0x34,0x00,0x04,0x02,0x24,
+0x60,0x4b,0xc3,0xad,0x9a,0x57,0x00,0x08,0x64,0x4b,0xc2,0xad,0x25,0xb0,0x02,0x3c,
+0x4d,0x00,0x44,0x34,0xff,0x00,0x03,0x3c,0xec,0x02,0x42,0x34,0x00,0x00,0x43,0xac,
+0x00,0x00,0x80,0xa0,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0x64,0x5f,0x63,0x24,0x18,0x03,0x42,0x34,0x00,0x00,0x43,0xac,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x7f,0x00,0x02,0x3c,0xfd,0xbf,0x45,0x34,
+0x80,0x04,0x03,0x3c,0x25,0x28,0xa3,0x00,0x00,0x08,0x04,0x3c,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x42,0x24,0x25,0x28,0xa4,0x00,0x41,0xb0,0x03,0x3c,0x00,0x00,0x65,0xac,
+0x04,0x4b,0x45,0xac,0xfc,0x4a,0x45,0xac,0x08,0x00,0x63,0x34,0x86,0x00,0x05,0x24,
+0x00,0x00,0x65,0xa4,0x08,0x4b,0x45,0xa4,0x00,0x4b,0x40,0xac,0x0a,0x4b,0x40,0xa4,
+0x0c,0x4b,0x45,0xa4,0x00,0x60,0x01,0x40,0x01,0x00,0x21,0x34,0x00,0x60,0x81,0x40,
+0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xf8,0x57,0x00,0x08,0x00,0x00,0x00,0x00,
+0x42,0xb0,0x02,0x3c,0xa0,0xff,0x03,0x24,0x01,0x00,0x42,0x34,0xe8,0xff,0xbd,0x27,
+0x21,0x20,0x00,0x00,0x01,0x00,0x05,0x24,0x00,0x01,0x06,0x24,0x00,0x00,0x43,0xa0,
+0x10,0x00,0xbf,0xaf,0xc4,0x0c,0x00,0x0c,0x00,0x00,0x00,0x00,0x10,0x00,0xbf,0x8f,
+0x03,0x00,0x04,0x24,0x01,0x00,0x05,0x24,0x40,0x1f,0x06,0x24,0xc4,0x0c,0x00,0x08,
+0x18,0x00,0xbd,0x27,0xe8,0xff,0xbd,0x27,0x10,0x00,0xb0,0xaf,0x14,0x00,0xbf,0xaf,
+0x21,0x5b,0x00,0x0c,0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,0x68,0x15,0x42,0x24,
+0x48,0x01,0x03,0x24,0xe0,0x63,0x43,0xac,0xdc,0x63,0x43,0xac,0x21,0x80,0x40,0x00,
+0x1f,0x00,0x03,0x24,0xff,0xff,0x63,0x24,0xc4,0x4c,0x40,0xa4,0xc6,0x4c,0x40,0xa4,
+0xc8,0x4c,0x40,0xa4,0xca,0x4c,0x40,0xa4,0xcc,0x4c,0x40,0xa4,0xce,0x4c,0x40,0xa4,
+0xd0,0x4c,0x40,0xa4,0xd2,0x4c,0x40,0xa4,0xd4,0x4c,0x40,0xa4,0xf5,0xff,0x61,0x04,
+0x24,0x00,0x42,0x24,0x25,0xb0,0x02,0x3c,0x10,0x00,0x03,0x24,0xb0,0x03,0x42,0x34,
+0x02,0x80,0x04,0x3c,0x8c,0x58,0x84,0x24,0x00,0x00,0x43,0xac,0x21,0x28,0x00,0x00,
+0x97,0x45,0x00,0x0c,0x04,0x00,0x06,0x24,0xef,0x5b,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x71,0x5c,0x00,0x0c,0x8c,0x65,0x00,0xae,0xa7,0x5d,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x4b,0x5e,0x00,0x0c,0x00,0x00,0x00,0x00,0x02,0x80,0x03,0x3c,0x8e,0x7d,0x64,0x90,
+0x92,0x00,0x02,0x24,0x03,0x00,0x82,0x10,0x00,0x00,0x00,0x00,0xf7,0x5d,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xdd,0x5d,0x00,0x0c,0x00,0x00,0x00,0x00,0x8b,0x5c,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xe4,0x63,0x00,0xa6,0x67,0x5e,0x00,0x0c,0xe6,0x63,0x00,0xa6,
+0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,0x02,0x80,0x04,0x3c,0x02,0x80,0x05,0x3c,
+0xf8,0x7a,0x82,0x24,0x00,0x7b,0xa3,0x24,0x18,0x00,0xbd,0x27,0x04,0x00,0x42,0xac,
+0xf8,0x7a,0x82,0xac,0x00,0x7b,0xa3,0xac,0x08,0x00,0xe0,0x03,0x04,0x00,0x63,0xac,
+0xe8,0xff,0xbd,0x27,0x10,0x00,0xb0,0xaf,0x01,0x80,0x02,0x3c,0x25,0xb0,0x10,0x3c,
+0x18,0x03,0x03,0x36,0x38,0x61,0x42,0x24,0x00,0x00,0x62,0xac,0x14,0x00,0xbf,0xaf,
+0x60,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,0xd5,0x58,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x01,0x00,0x03,0x24,0x02,0x80,0x02,0x3c,0xfd,0x5a,0x00,0x0c,0xdb,0x60,0x43,0xa0,
+0xd1,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,0x32,0x41,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x0b,0x58,0x00,0x0c,0x00,0x00,0x00,0x00,0x44,0x00,0x03,0x36,0x00,0x00,0x62,0x94,
+0x00,0x00,0x00,0x00,0x40,0x00,0x42,0x34,0x00,0x00,0x62,0xa4,0xd9,0x57,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xfa,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,0xc9,0x5a,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x8e,0x5a,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x80,0x04,0x3c,
+0xb4,0x24,0x84,0x24,0xe6,0x5a,0x00,0x0c,0x01,0x00,0x05,0x24,0x01,0x80,0x04,0x3c,
+0x08,0x1e,0x84,0x24,0xe6,0x5a,0x00,0x0c,0x02,0x00,0x05,0x24,0x81,0x4e,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x80,0x04,0x3c,0x54,0x34,0x84,0x24,0xe6,0x5a,0x00,0x0c,
+0x03,0x00,0x05,0x24,0x02,0x80,0x02,0x3c,0x98,0x7d,0x43,0x90,0x43,0x00,0x04,0x36,
+0x29,0x00,0x60,0x10,0xd8,0x00,0x10,0x36,0x07,0x00,0x02,0x24,0x2b,0x00,0x62,0x10,
+0x25,0xb0,0x04,0x3c,0x10,0x02,0x86,0x34,0x43,0x00,0x85,0x34,0x03,0x00,0x02,0x24,
+0x10,0x00,0x03,0x24,0x00,0x00,0xa2,0xa0,0xd8,0x00,0x84,0x34,0x00,0x00,0xc3,0xa0,
+0x00,0x00,0x82,0x90,0x80,0xff,0x03,0x24,0x42,0xb0,0x05,0x3c,0x25,0x10,0x43,0x00,
+0x00,0x00,0x82,0xa0,0x25,0xb0,0x04,0x3c,0x44,0x00,0x84,0x34,0x00,0x00,0x82,0x94,
+0x00,0x00,0x00,0x00,0xc0,0x00,0x42,0x34,0x00,0x00,0x82,0xa4,0x00,0x00,0xa3,0x90,
+0x00,0x00,0x00,0x00,0x01,0x00,0x63,0x34,0x00,0x00,0xa3,0xa0,0xe0,0x57,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x02,0x80,0x04,0x3c,0x08,0x00,0x84,0x24,0x21,0x28,0x00,0x00,
+0x21,0x30,0x00,0x00,0x31,0x1c,0x00,0x0c,0x21,0x38,0x00,0x00,0xf8,0x57,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x14,0x00,0xbf,0x8f,0x10,0x00,0xb0,0x8f,0x01,0x00,0x02,0x24,
+0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,0x00,0x00,0x80,0xa0,0x00,0x00,0x03,0x92,
+0x80,0xff,0x02,0x24,0x25,0x18,0x62,0x00,0x00,0x00,0x03,0xa2,0x25,0xb0,0x04,0x3c,
+0x44,0x00,0x84,0x34,0x00,0x00,0x82,0x94,0x42,0xb0,0x05,0x3c,0xc0,0x00,0x42,0x34,
+0x00,0x00,0x82,0xa4,0x00,0x00,0xa3,0x90,0x00,0x00,0x00,0x00,0x01,0x00,0x63,0x34,
+0x00,0x00,0xa3,0xa0,0xe0,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,0x02,0x80,0x04,0x3c,
+0x08,0x00,0x84,0x24,0x21,0x28,0x00,0x00,0x21,0x30,0x00,0x00,0x31,0x1c,0x00,0x0c,
+0x21,0x38,0x00,0x00,0xf8,0x57,0x00,0x0c,0x00,0x00,0x00,0x00,0x14,0x00,0xbf,0x8f,
+0x10,0x00,0xb0,0x8f,0x01,0x00,0x02,0x24,0x08,0x00,0xe0,0x03,0x18,0x00,0xbd,0x27,
+0x21,0x20,0x00,0x00,0x20,0xb0,0x06,0x3c,0xff,0xff,0x05,0x34,0x21,0x18,0x86,0x00,
+0x04,0x00,0x84,0x24,0x2a,0x10,0xa4,0x00,0x00,0x00,0x60,0xac,0xfb,0xff,0x40,0x10,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xb8,0xff,0xbd,0x27,
+0x25,0xb0,0x04,0x3c,0x44,0x00,0xbf,0xaf,0x40,0x00,0xbe,0xaf,0x3c,0x00,0xb7,0xaf,
+0x38,0x00,0xb6,0xaf,0x34,0x00,0xb5,0xaf,0x30,0x00,0xb4,0xaf,0x2c,0x00,0xb3,0xaf,
+0x28,0x00,0xb2,0xaf,0x24,0x00,0xb1,0xaf,0x20,0x00,0xb0,0xaf,0x0a,0x00,0x83,0x34,
+0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,0x20,0x00,0x42,0x30,0x0c,0x00,0x40,0x10,
+0x4c,0x87,0x02,0x3c,0x00,0x00,0x62,0x90,0x00,0x00,0x00,0x00,0x10,0x00,0x42,0x30,
+0x66,0x01,0x40,0x10,0x4c,0x87,0x02,0x3c,0x54,0x00,0x83,0x34,0x50,0x00,0x82,0x34,
+0x00,0x00,0x45,0xac,0x00,0x00,0x65,0xa4,0xf9,0x58,0x00,0x08,0x02,0x80,0x03,0x3c,
+0x54,0x00,0x85,0x34,0x00,0xe0,0x42,0x34,0x50,0x00,0x84,0x34,0x12,0x01,0x03,0x24,
+0x00,0x00,0x82,0xac,0x00,0x00,0xa3,0xac,0x02,0x80,0x03,0x3c,0x68,0x15,0x62,0x24,
+0xd5,0x4a,0x43,0x90,0xda,0x4a,0x45,0x94,0x25,0xb0,0x1e,0x3c,0x1c,0x00,0xa3,0xa3,
+0x60,0x4b,0x43,0x8c,0x58,0x00,0xc6,0x37,0xff,0xff,0x04,0x24,0x10,0x00,0xa3,0xaf,
+0x64,0x4b,0x43,0x8c,0x5c,0x00,0xc7,0x37,0x60,0x00,0xc8,0x37,0x14,0x00,0xa3,0xaf,
+0x68,0x4b,0x42,0x8c,0x64,0x00,0xc9,0x37,0x8a,0x00,0xca,0x37,0x18,0x00,0xa2,0xaf,
+0x24,0x10,0x02,0x3c,0x21,0x28,0xa2,0x00,0x4c,0x81,0x02,0x3c,0x00,0xe0,0x42,0x34,
+0x00,0x00,0xc2,0xac,0x96,0x01,0x03,0x24,0x28,0x28,0x02,0x24,0x00,0x00,0xe3,0xac,
+0x89,0x00,0xcb,0x37,0x00,0x00,0x04,0xad,0x8c,0x00,0xcc,0x37,0x00,0x00,0x24,0xad,
+0x09,0x00,0x03,0x24,0x00,0x00,0x42,0xa5,0x10,0x10,0x02,0x24,0x00,0x00,0x63,0xa1,
+0x8e,0x00,0xcd,0x37,0x00,0x00,0x82,0xa5,0x0a,0x0a,0x03,0x24,0x13,0x00,0x02,0x24,
+0x90,0x00,0xce,0x37,0x00,0x00,0xa3,0xa5,0x00,0x00,0xc2,0xa1,0x25,0xb0,0x02,0x3c,
+0x40,0x00,0x03,0x24,0x91,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0x25,0xb0,0x03,0x3c,
+0x3a,0x01,0x02,0x24,0x92,0x00,0x63,0x34,0x00,0x00,0x62,0xa4,0xb5,0x00,0xd1,0x37,
+0x21,0x00,0x03,0x24,0x00,0x00,0x23,0xa2,0x10,0x00,0xa2,0x8f,0xa0,0x00,0xd2,0x37,
+0xa4,0x00,0xd3,0x37,0x00,0x00,0x42,0xae,0x14,0x00,0xa3,0x8f,0xa8,0x00,0xd4,0x37,
+0xac,0x00,0xd5,0x37,0x00,0x00,0x63,0xae,0x18,0x00,0xa2,0x8f,0x25,0xb0,0x03,0x3c,
+0xb0,0x00,0x63,0x34,0x00,0x00,0x82,0xae,0x21,0x10,0x02,0x3c,0xff,0x77,0x42,0x34,
+0x00,0x00,0xa2,0xae,0x25,0xb0,0x02,0x3c,0xd8,0x00,0x42,0x34,0x00,0x00,0x65,0xac,
+0x00,0x00,0x40,0xa0,0x1c,0x00,0xa2,0x93,0x25,0xb0,0x03,0x3c,0xb4,0x00,0x63,0x34,
+0x00,0x00,0x62,0xa0,0x25,0xb0,0x03,0x3c,0x04,0x00,0x02,0x24,0xb6,0x00,0x63,0x34,
+0x00,0x00,0x62,0xa0,0x25,0xb0,0x03,0x3c,0x0f,0x00,0x02,0x24,0xba,0x00,0x63,0x34,
+0xb9,0x00,0xdf,0x37,0x00,0x00,0xe4,0xa3,0x00,0x00,0x62,0xa4,0x25,0xb0,0x02,0x3c,
+0x1a,0x01,0x42,0x34,0x16,0x01,0xd0,0x37,0x18,0x01,0xcf,0x37,0x00,0x00,0x00,0xa6,
+0x25,0xb0,0x03,0x3c,0x00,0x00,0xe0,0xa5,0x00,0x00,0x40,0xa4,0xff,0xff,0x02,0x3c,
+0xff,0x0f,0x42,0x34,0xdc,0x00,0x63,0x34,0x00,0x00,0x62,0xac,0x2f,0x00,0x03,0x3c,
+0x25,0xb0,0x02,0x3c,0x32,0x32,0x63,0x34,0xd0,0x01,0x42,0x34,0x00,0x00,0x43,0xac,
+0x5e,0x00,0x02,0x3c,0x25,0xb0,0x03,0x3c,0x32,0x43,0x42,0x34,0xd4,0x01,0x63,0x34,
+0x00,0x00,0x62,0xac,0x08,0x00,0x03,0x3c,0x25,0xb0,0x02,0x3c,0x30,0xa5,0x63,0x34,
+0xd8,0x01,0x42,0x34,0x00,0x00,0x43,0xac,0xdc,0x01,0xc4,0x37,0x02,0x80,0x03,0x3c,
+0x49,0xa5,0x02,0x34,0x8e,0x7d,0x6d,0x90,0x00,0x00,0x82,0xac,0xc2,0x00,0x02,0x3c,
+0x1a,0x06,0x03,0x24,0x51,0x10,0x42,0x34,0xe0,0x01,0xc5,0x37,0xf4,0x01,0xc6,0x37,
+0xf8,0x01,0xc7,0x37,0x07,0x07,0x04,0x24,0x00,0x00,0xa3,0xa4,0x00,0x02,0xc8,0x37,
+0x00,0x00,0xc4,0xa4,0x26,0x00,0x03,0x24,0x00,0x00,0xe2,0xac,0x03,0x02,0xc9,0x37,
+0x04,0x00,0x02,0x24,0x00,0x00,0x03,0xa5,0x36,0x02,0xca,0x37,0x00,0x00,0x22,0xa1,
+0xc0,0x01,0x03,0x24,0x0c,0x00,0x02,0x24,0x34,0x02,0xcb,0x37,0x00,0x00,0x42,0xa1,
+0x37,0x02,0xcc,0x37,0x00,0x00,0x63,0xa5,0x03,0x00,0x02,0x24,0x22,0x00,0x03,0x24,
+0x00,0x00,0x82,0xa1,0xd6,0x00,0xa3,0x11,0x1b,0x1b,0x02,0x3c,0x13,0x13,0x02,0x3c,
+0x13,0x13,0x42,0x34,0x60,0x01,0xc3,0x37,0x64,0x01,0xc4,0x37,0x68,0x01,0xc5,0x37,
+0x7c,0x01,0xca,0x37,0x6c,0x01,0xc6,0x37,0x70,0x01,0xc7,0x37,0x74,0x01,0xc8,0x37,
+0x78,0x01,0xc9,0x37,0x00,0x00,0x62,0xac,0x00,0x00,0x82,0xac,0x02,0x80,0x03,0x3c,
+0x00,0x00,0xa2,0xac,0x00,0x00,0xc2,0xac,0x00,0x00,0xe2,0xac,0x00,0x00,0x02,0xad,
+0x00,0x00,0x22,0xad,0x00,0x00,0x42,0xad,0x8e,0x7d,0x65,0x90,0x25,0xb0,0x0c,0x3c,
+0x01,0x70,0x03,0x3c,0x80,0x01,0x82,0x35,0x08,0x5f,0x63,0x34,0x22,0x00,0x04,0x24,
+0x00,0x00,0x43,0xac,0xb5,0x00,0xa4,0x10,0x0f,0x1f,0x02,0x3c,0x92,0x00,0x02,0x24,
+0xb2,0x00,0xa2,0x10,0x0f,0x1f,0x02,0x3c,0x0f,0x10,0x02,0x3c,0x00,0xf0,0x51,0x34,
+0xf7,0x01,0x92,0x35,0x15,0xf0,0x4d,0x34,0x77,0x00,0x0e,0x24,0x84,0x01,0x87,0x35,
+0x88,0x01,0x88,0x35,0x10,0xf0,0x44,0x34,0x8c,0x01,0x85,0x35,0x05,0xf0,0x42,0x34,
+0x00,0x00,0xed,0xac,0x90,0x01,0x83,0x35,0x00,0x00,0x04,0xad,0x94,0x01,0x86,0x35,
+0x00,0x00,0xa2,0xac,0xf5,0x0f,0x02,0x24,0x00,0x00,0x71,0xac,0x25,0xb0,0x05,0x3c,
+0x00,0x00,0xc2,0xac,0x98,0x01,0x89,0x35,0x9c,0x01,0x8a,0x35,0xf0,0x0f,0x03,0x24,
+0x0d,0x00,0x02,0x24,0x00,0x00,0x23,0xad,0xa0,0x01,0x8b,0x35,0x00,0x00,0x42,0xad,
+0xa7,0x01,0xb7,0x34,0xf6,0x01,0x8c,0x35,0xff,0xff,0x02,0x24,0x00,0x00,0x6d,0xad,
+0x00,0x00,0x8e,0xa1,0x00,0x00,0x4e,0xa2,0x00,0x00,0xe2,0xa2,0x25,0xb0,0x02,0x3c,
+0xa8,0x01,0xb6,0x34,0xff,0xff,0x09,0x24,0xac,0x01,0x42,0x34,0x00,0x00,0xc9,0xae,
+0x03,0x04,0x04,0x3c,0x00,0x00,0x49,0xac,0x07,0x08,0x03,0x3c,0x25,0xb0,0x02,0x3c,
+0x01,0x02,0x84,0x34,0x05,0x06,0x63,0x34,0xb4,0x01,0xb1,0x34,0xb8,0x01,0xb2,0x34,
+0xbc,0x01,0xb3,0x34,0xb0,0x01,0x42,0x34,0x00,0x00,0x44,0xac,0x00,0x00,0x23,0xae,
+0x25,0xb0,0x02,0x3c,0x00,0x00,0x44,0xae,0x00,0x00,0x63,0xae,0x25,0xb0,0x03,0x3c,
+0x0c,0x00,0x06,0x24,0xc0,0x01,0xb4,0x34,0xc1,0x01,0xb5,0x34,0x0d,0x00,0x08,0x24,
+0xc2,0x01,0x63,0x34,0xc3,0x01,0x42,0x34,0x00,0x00,0x86,0xa2,0xc4,0x01,0xab,0x34,
+0x00,0x00,0xa6,0xa2,0xc5,0x01,0xac,0x34,0x00,0x00,0x66,0xa0,0x0e,0x00,0x07,0x24,
+0x00,0x00,0x48,0xa0,0xc6,0x01,0xaa,0x34,0xc7,0x01,0xad,0x34,0x0f,0x00,0x02,0x24,
+0x00,0x00,0x68,0xa1,0x00,0x00,0x87,0xa1,0x00,0x00,0x47,0xa1,0x00,0x00,0xa2,0xa1,
+0x57,0x01,0x02,0x3c,0x48,0x00,0xbf,0x34,0x46,0x00,0xae,0x34,0x0e,0xe2,0x42,0x34,
+0x00,0x00,0xc0,0xa5,0x4c,0x00,0xbe,0x34,0x00,0x00,0xe2,0xaf,0x4d,0x00,0xb9,0x34,
+0x80,0xff,0x02,0x24,0x00,0x00,0xc0,0xa3,0x00,0x00,0x22,0xa3,0x25,0xb0,0x02,0x3c,
+0xbc,0x00,0x03,0x24,0x40,0x00,0x42,0x34,0x00,0x00,0x43,0xa4,0x25,0xb0,0x03,0x3c,
+0x64,0x03,0xb8,0x34,0xfc,0x37,0x02,0x24,0x40,0x00,0x63,0x34,0x00,0x00,0x00,0xa3,
+0xd8,0x00,0xa7,0x34,0x00,0x00,0x62,0xa4,0x00,0x00,0xe3,0x90,0x2a,0xb0,0x04,0x3c,
+0x80,0xff,0x02,0x24,0x26,0xb0,0x06,0x3c,0x25,0x18,0x62,0x00,0x30,0x00,0x89,0x34,
+0x20,0x20,0x02,0x24,0x38,0x00,0x84,0x34,0x00,0x00,0xe3,0xa0,0x79,0x00,0xc8,0x34,
+0x00,0x00,0x82,0xa4,0x40,0x00,0x03,0x24,0x16,0x00,0x02,0x24,0x00,0x00,0x23,0xa1,
+0x94,0x00,0xaa,0x34,0x00,0x00,0x02,0xa1,0x98,0x00,0xab,0x34,0x64,0x00,0x03,0x24,
+0x22,0x00,0x02,0x24,0x00,0x00,0x43,0xa5,0x7c,0x00,0xd1,0x34,0x00,0x00,0x62,0xa5,
+0x04,0x00,0x12,0x24,0x9c,0x00,0xac,0x34,0x7a,0x00,0xc6,0x34,0x20,0x0c,0x02,0x24,
+0x0a,0x00,0x03,0x24,0x00,0x00,0xd2,0xa0,0x9a,0x00,0xad,0x34,0x00,0x00,0x22,0xa6,
+0x96,0x00,0xae,0x34,0x00,0x00,0x83,0xa1,0xff,0x03,0x02,0x24,0x02,0x00,0x03,0x24,
+0x00,0x00,0xa2,0xa5,0x00,0x00,0xc3,0xa5,0x25,0xb0,0x03,0x3c,0x20,0x00,0x02,0x24,
+0xb7,0x00,0x63,0x34,0x00,0x00,0x62,0xa0,0x25,0xb0,0x02,0x3c,0x09,0x00,0x03,0x24,
+0x89,0x00,0x42,0x34,0x00,0x00,0x43,0xa0,0x44,0x00,0xa5,0x34,0x00,0x00,0xa2,0x94,
+0x02,0x80,0x03,0x3c,0x68,0x15,0x66,0x24,0xff,0xfd,0x03,0x24,0x24,0x10,0x43,0x00,
+0x00,0x00,0xa2,0xa4,0x00,0x00,0xa3,0x94,0xd5,0x4a,0xc4,0x90,0x29,0xb0,0x02,0x3c,
+0x40,0x00,0x42,0x34,0x00,0x02,0x63,0x34,0x00,0x00,0xa3,0xa4,0x00,0x00,0x52,0xa0,
+0xd3,0x0a,0x00,0x0c,0x00,0x00,0x00,0x00,0x44,0x00,0xbf,0x8f,0x40,0x00,0xbe,0x8f,
+0x3c,0x00,0xb7,0x8f,0x38,0x00,0xb6,0x8f,0x34,0x00,0xb5,0x8f,0x30,0x00,0xb4,0x8f,
+0x2c,0x00,0xb3,0x8f,0x28,0x00,0xb2,0x8f,0x24,0x00,0xb1,0x8f,0x20,0x00,0xb0,0x8f,
+0x01,0x00,0x02,0x24,0x08,0x00,0xe0,0x03,0x48,0x00,0xbd,0x27,0x54,0x00,0x85,0x34,
+0x00,0xe0,0x42,0x34,0x50,0x00,0x84,0x34,0x12,0x01,0x03,0x24,0x00,0x00,0x82,0xac,
+0x00,0x00,0xa3,0xa4,0xf9,0x58,0x00,0x08,0x02,0x80,0x03,0x3c,0x00,0xf0,0x51,0x34,
+0xf7,0x01,0x92,0x35,0x15,0xf0,0x4d,0x34,0xad,0x59,0x00,0x08,0xff,0xff,0x0e,0x24,
+0x8b,0x59,0x00,0x08,0x1b,0x1b,0x42,0x34,0x25,0xb0,0x03,0x3c,0x25,0xb0,0x08,0x3c,
+0xfc,0x37,0x02,0x24,0x40,0x00,0x63,0x34,0x02,0x80,0x04,0x3c,0x00,0x00,0x62,0xa4,
+0x14,0x80,0x84,0x24,0xff,0x00,0x07,0x24,0xb0,0x03,0x06,0x35,0x00,0x00,0x83,0x94,
+0x00,0x00,0x00,0x00,0xff,0x00,0x62,0x30,0x21,0x18,0x68,0x00,0x0a,0x00,0x47,0x10,
+0xff,0x00,0x65,0x30,0x04,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xac,
+0x00,0x00,0xc3,0xac,0x04,0x00,0x82,0x8c,0x08,0x00,0x84,0x24,0x00,0x00,0xc2,0xac,
+0xf2,0xff,0xa7,0x14,0x00,0x00,0x00,0x00,0x25,0xb0,0x08,0x3c,0x01,0x80,0x02,0x3c,
+0x0c,0x7a,0x44,0x24,0xff,0x00,0x07,0x24,0xb0,0x03,0x06,0x35,0x00,0x00,0x83,0x94,
+0x00,0x00,0x00,0x00,0xff,0x00,0x62,0x30,0x21,0x18,0x68,0x00,0x0a,0x00,0x47,0x10,
+0xff,0x00,0x65,0x30,0x04,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0xac,
+0x00,0x00,0xc3,0xac,0x04,0x00,0x82,0x8c,0x08,0x00,0x84,0x24,0x00,0x00,0xc2,0xac,
+0xf2,0xff,0xa7,0x14,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
+0x01,0x80,0x02,0x3c,0x02,0x80,0x05,0x3c,0x10,0x6b,0x42,0x24,0x02,0x80,0x03,0x3c,
+0xcc,0x7d,0xa2,0xac,0x00,0x80,0x02,0x3c,0x6c,0x7e,0x60,0xac,0xcc,0x7d,0xa4,0x24,
+0x02,0x80,0x03,0x3c,0xc8,0x06,0x42,0x24,0x70,0x7e,0x60,0xa4,0x08,0x00,0x82,0xac,
+0x02,0x80,0x03,0x3c,0x00,0x80,0x02,0x3c,0x72,0x7e,0x60,0xa4,0x02,0x80,0x06,0x3c,
+0x08,0x0a,0x42,0x24,0x00,0x80,0x03,0x3c,0x74,0x7e,0xc7,0x24,0x14,0x00,0x82,0xac,
+0x38,0x08,0x63,0x24,0x02,0x80,0x02,0x3c,0x74,0x7e,0xc0,0xac,0x10,0x00,0x83,0xac,
+0x04,0x00,0xe0,0xac,0x7c,0x7e,0x40,0xa0,0x00,0x80,0x02,0x3c,0x88,0x19,0x42,0x24,
+0x3c,0x00,0x82,0xac,0x00,0x80,0x03,0x3c,0x00,0x80,0x02,0x3c,0x24,0x0c,0x63,0x24,
+0x78,0x0f,0x42,0x24,0x1c,0x00,0x83,0xac,0x20,0x00,0x82,0xac,0x00,0x80,0x03,0x3c,
+0x00,0x80,0x02,0x3c,0xc8,0x12,0x63,0x24,0x28,0x16,0x42,0x24,0x24,0x00,0x83,0xac,
+0x28,0x00,0x82,0xac,0x00,0x80,0x03,0x3c,0x01,0x80,0x02,0x3c,0x4c,0x1f,0x63,0x24,
+0xd0,0x04,0x42,0x24,0x2c,0x00,0x83,0xac,0x30,0x00,0x82,0xac,0x00,0x80,0x03,0x3c,
+0x00,0x80,0x02,0x3c,0xe4,0x19,0x63,0x24,0x00,0x03,0x42,0x24,0x38,0x00,0x83,0xac,
+0x08,0x00,0xe0,0x03,0x4c,0x00,0x82,0xac,0x25,0xb0,0x02,0x3c,0x08,0x00,0x42,0x34,
+0x00,0x00,0x43,0x8c,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x02,0x80,0x0e,0x3c,
+0x02,0x80,0x08,0x3c,0x02,0x80,0x02,0x3c,0x02,0x80,0x03,0x3c,0xf8,0x03,0x4d,0x24,
+0x00,0x14,0x6c,0x24,0x01,0x00,0x07,0x24,0x00,0x00,0xcb,0x25,0xff,0xff,0x0a,0x24,
+0x00,0x04,0x09,0x25,0x80,0x1a,0x07,0x00,0x21,0x10,0x6b,0x00,0x00,0x00,0x42,0xac,
+0x90,0x00,0x4a,0xac,0x00,0x04,0x04,0x8d,0x01,0x00,0xe7,0x24,0x08,0x00,0x45,0x24,
+0x21,0x18,0x6d,0x00,0x05,0x00,0xe6,0x28,0x04,0x00,0x82,0xac,0x00,0x00,0x44,0xac,
+0x04,0x00,0x49,0xac,0x00,0x04,0x02,0xad,0x8c,0x00,0x40,0xac,0x6c,0x00,0xa3,0xac,
+0xf0,0xff,0xc0,0x14,0x68,0x00,0xac,0xac,0x08,0x00,0xe0,0x03,0x00,0x00,0xc9,0xad,
+0x05,0x00,0xa2,0x2c,0x13,0x00,0x40,0x10,0xff,0xff,0x07,0x24,0x02,0x80,0x02,0x3c,
+0x80,0x1a,0x05,0x00,0x00,0x00,0x42,0x24,0x0e,0x00,0xa0,0x10,0x21,0x30,0x62,0x00,
+0x90,0x00,0xc3,0x8c,0xff,0xff,0x02,0x24,0x0a,0x00,0x62,0x14,0x00,0x00,0x00,0x00,
+0x8c,0x00,0xc2,0x8c,0x00,0x00,0x00,0x00,0x06,0x00,0x40,0x14,0x00,0x00,0x00,0x00,
+0x01,0x00,0x02,0x24,0x88,0x00,0xc4,0xac,0x8c,0x00,0xc2,0xac,0x90,0x00,0xc5,0xac,
+0x21,0x38,0xa0,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0xe0,0x00,0x25,0xb0,0x04,0x3c,
+0x01,0x80,0x02,0x3c,0x18,0x03,0x85,0x34,0xf4,0x6b,0x42,0x24,0xe0,0xff,0xbd,0x27,
+0x00,0x00,0xa2,0xac,0x1b,0x00,0x86,0x34,0xdb,0xff,0x03,0x24,0x27,0x00,0x84,0x34,
+0x07,0x00,0x02,0x24,0x14,0x00,0xb1,0xaf,0x10,0x00,0xb0,0xaf,0x00,0x00,0x83,0xa0,
+0x18,0x00,0xbf,0xaf,0x00,0x00,0xc2,0xa0,0x01,0x00,0x11,0x24,0x21,0x80,0x00,0x00,
+0x7a,0x42,0x00,0x0c,0x21,0x20,0x00,0x02,0x01,0x00,0x02,0x26,0xff,0x00,0x50,0x30,
+0x2b,0x18,0x30,0x02,0xfa,0xff,0x60,0x10,0x00,0x00,0x00,0x00,0x7a,0x42,0x00,0x0c,
+0x21,0x20,0x00,0x00,0x18,0x00,0xbf,0x8f,0x14,0x00,0xb1,0x8f,0x10,0x00,0xb0,0x8f,
+0x01,0x00,0x02,0x24,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x42,0x24,0x40,0x10,0x03,0x3c,0xff,0xff,0x44,0x30,0x25,0xc0,0x83,0x00,
+0x94,0x64,0x58,0xac,0x40,0x00,0x18,0x27,0xa0,0x64,0x58,0xac,0x40,0x00,0x18,0x27,
+0xac,0x64,0x58,0xac,0x40,0x00,0x18,0x27,0xb8,0x64,0x58,0xac,0x40,0x00,0x18,0x27,
+0xe0,0xff,0xbd,0x27,0xc4,0x64,0x58,0xac,0x40,0x00,0x18,0x27,0x1c,0x00,0xb7,0xaf,
+0x18,0x00,0xb6,0xaf,0x14,0x00,0xb5,0xaf,0x10,0x00,0xb4,0xaf,0x0c,0x00,0xb3,0xaf,
+0x08,0x00,0xb2,0xaf,0x04,0x00,0xb1,0xaf,0x00,0x00,0xb0,0xaf,0xd0,0x64,0x58,0xac,
+0xa0,0x64,0x45,0x8c,0xac,0x64,0x46,0x8c,0xb8,0x64,0x47,0x8c,0xc4,0x64,0x48,0x8c,
+0xd0,0x64,0x49,0x8c,0x40,0x00,0x18,0x27,0xdc,0x64,0x58,0xac,0x21,0x50,0x00,0x03,
+0x25,0x20,0x83,0x00,0x40,0x00,0x18,0x27,0x20,0x10,0x03,0x3c,0x90,0x64,0x44,0xac,
+0x9c,0x64,0x45,0xac,0xa8,0x64,0x46,0xac,0xb4,0x64,0x47,0xac,0xc0,0x64,0x48,0xac,
+0xcc,0x64,0x49,0xac,0x25,0xb0,0x06,0x3c,0x28,0x64,0x43,0xac,0x24,0x64,0x43,0xac,
+0x34,0x64,0x43,0xac,0x30,0x64,0x43,0xac,0x40,0x64,0x43,0xac,0x3c,0x64,0x43,0xac,
+0x4c,0x64,0x43,0xac,0x48,0x64,0x43,0xac,0xe8,0x64,0x58,0xac,0x00,0x02,0x18,0x27,
+0xd8,0x64,0x4a,0xac,0x00,0x65,0x58,0xac,0x58,0x64,0x43,0xac,0x54,0x64,0x43,0xac,
+0x64,0x64,0x43,0xac,0x60,0x64,0x43,0xac,0x70,0x64,0x43,0xac,0x6c,0x64,0x43,0xac,
+0xac,0x00,0xc4,0x34,0xb0,0x00,0xc5,0x34,0x00,0x00,0x92,0x8c,0xe8,0x64,0x50,0x8c,
+0x00,0x00,0xb3,0x8c,0x21,0x10,0x04,0x3c,0x23,0x10,0x09,0x3c,0x22,0x10,0x0c,0x3c,
+0x02,0x80,0x14,0x3c,0x02,0x80,0x15,0x3c,0x02,0x80,0x16,0x3c,0x02,0x80,0x17,0x3c,
+0x24,0x10,0x05,0x3c,0x21,0x88,0x00,0x03,0x08,0x7b,0x87,0x26,0x00,0x04,0x18,0x27,
+0x10,0x7b,0xa8,0x26,0x18,0x7b,0xca,0x26,0x20,0x7b,0xeb,0x26,0x00,0x04,0x2d,0x35,
+0x00,0x40,0x8e,0x34,0x00,0x80,0x8f,0x35,0x00,0x01,0xc6,0x34,0xe4,0x64,0x50,0xac,
+0xfc,0x64,0x51,0xac,0x64,0x65,0x4d,0xac,0x28,0x65,0x52,0xac,0x34,0x65,0x4e,0xac,
+0x58,0x65,0x4f,0xac,0x4c,0x65,0x53,0xac,0x00,0x00,0xc5,0xac,0x48,0x65,0x45,0xac,
+0x68,0x65,0x43,0xac,0x74,0x65,0x58,0xac,0x7c,0x64,0x43,0xac,0x78,0x64,0x43,0xac,
+0x06,0x65,0x40,0xa4,0x05,0x65,0x40,0xa0,0x04,0x65,0x40,0xa0,0x5c,0x65,0x49,0xac,
+0x60,0x65,0x49,0xac,0x20,0x65,0x44,0xac,0x24,0x65,0x44,0xac,0x2c,0x65,0x44,0xac,
+0x30,0x65,0x44,0xac,0x50,0x65,0x4c,0xac,0x54,0x65,0x4c,0xac,0x44,0x65,0x45,0xac,
+0x6c,0x65,0x43,0xac,0x78,0x65,0x58,0xac,0x04,0x00,0x08,0xad,0x08,0x7b,0x87,0xae,
+0x04,0x00,0x4a,0xad,0x10,0x7b,0xa8,0xae,0x04,0x00,0x6b,0xad,0x18,0x7b,0xca,0xae,
+0x20,0x7b,0xeb,0xae,0x04,0x00,0xe7,0xac,0x02,0x80,0x02,0x3c,0x00,0x14,0x43,0x24,
+0x21,0x20,0xe0,0x00,0x03,0x00,0x06,0x24,0x21,0x10,0x80,0x00,0xff,0xff,0xc6,0x24,
+0x08,0x00,0x78,0xac,0x00,0x00,0x63,0xac,0x10,0x00,0x60,0xac,0x00,0x00,0x67,0xac,
+0x21,0x20,0x60,0x00,0x04,0x00,0x62,0xac,0x00,0x00,0x43,0xac,0x00,0x01,0x18,0x27,
+0xf5,0xff,0xc1,0x04,0x18,0x00,0x63,0x24,0x02,0x80,0x02,0x3c,0x10,0x7b,0x49,0x24,
+0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0x04,0x00,0x28,0x8d,0x60,0x14,0x4b,0x24,
+0x04,0x00,0xe4,0xac,0x00,0x14,0x6a,0x24,0x01,0x00,0x07,0x24,0x21,0x28,0x00,0x00,
+0x07,0x00,0x06,0x24,0x21,0x20,0xab,0x00,0x21,0x10,0xaa,0x00,0xff,0xff,0xc6,0x24,
+0x68,0x00,0x58,0xac,0x70,0x00,0x47,0xac,0x18,0x00,0xa5,0x24,0x00,0x00,0x89,0xac,
+0x04,0x00,0x88,0xac,0x00,0x00,0x04,0xad,0x00,0x01,0x18,0x27,0xf5,0xff,0xc1,0x04,
+0x21,0x40,0x80,0x00,0x02,0x80,0x02,0x3c,0x18,0x7b,0x4a,0x24,0x02,0x80,0x03,0x3c,
+0x02,0x80,0x02,0x3c,0x04,0x00,0x45,0x8d,0x20,0x15,0x4b,0x24,0x04,0x00,0x24,0xad,
+0x02,0x00,0x07,0x24,0x00,0x14,0x69,0x24,0x21,0x20,0x00,0x00,0x01,0x00,0x06,0x24,
+0x21,0x40,0x8b,0x00,0x21,0x10,0x89,0x00,0xff,0xff,0xc6,0x24,0x28,0x01,0x58,0xac,
+0x30,0x01,0x47,0xac,0x18,0x00,0x84,0x24,0x00,0x00,0x0a,0xad,0x04,0x00,0x05,0xad,
+0x00,0x00,0xa8,0xac,0x00,0x02,0x18,0x27,0xf5,0xff,0xc1,0x04,0x21,0x28,0x00,0x01,
+0x02,0x80,0x05,0x3c,0x20,0x7b,0xa5,0x24,0x04,0x00,0xa6,0x8c,0x1c,0x00,0xb7,0x8f,
+0x18,0x00,0xb6,0x8f,0x14,0x00,0xb5,0x8f,0x10,0x00,0xb4,0x8f,0x0c,0x00,0xb3,0x8f,
+0x08,0x00,0xb2,0x8f,0x04,0x00,0xb1,0x8f,0x00,0x00,0xb0,0x8f,0x02,0x80,0x07,0x3c,
+0x02,0x80,0x03,0x3c,0x50,0x15,0xe4,0x24,0x00,0x14,0x63,0x24,0x03,0x00,0x02,0x24,
+0x20,0x00,0xbd,0x27,0x58,0x01,0x78,0xac,0x04,0x00,0x48,0xad,0x04,0x00,0xa4,0xac,
+0x60,0x01,0x62,0xac,0x50,0x15,0xe5,0xac,0x04,0x00,0x86,0xac,0x08,0x00,0xe0,0x03,
+0x00,0x00,0xc4,0xac,0xd0,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,0x20,0x00,0xb2,0xaf,
+0x02,0x80,0x03,0x3c,0x4c,0x91,0x52,0x24,0x02,0x80,0x02,0x3c,0x28,0x00,0xb4,0xaf,
+0x24,0x00,0xb3,0xaf,0x1c,0x00,0xb1,0xaf,0x18,0x00,0xb0,0xaf,0x2c,0x00,0xbf,0xaf,
+0xd8,0x90,0x73,0x24,0x68,0x15,0x50,0x24,0x21,0x88,0x00,0x00,0x02,0x80,0x14,0x3c,
+0xee,0x4e,0x00,0x0c,0x21,0x20,0x20,0x02,0x78,0x51,0x05,0x8e,0x6c,0x00,0x66,0x8e,
+0xb8,0x90,0x82,0x26,0x6c,0x00,0x43,0x8e,0x1b,0x00,0x44,0x90,0xff,0xf1,0x02,0x24,
+0x21,0x18,0x66,0x00,0x24,0x28,0xa2,0x00,0x00,0x21,0x04,0x00,0x42,0x18,0x03,0x00,
+0x00,0x02,0xa5,0x34,0x44,0x51,0x03,0xae,0x68,0x51,0x04,0xae,0x78,0x51,0x05,0xae,
+0x6c,0x51,0x04,0xae,0x21,0x30,0x00,0x00,0x21,0x10,0x06,0x02,0x01,0x00,0xc6,0x24,
+0x1d,0x00,0xc3,0x28,0x99,0x51,0x40,0xa0,0x7c,0x51,0x40,0xa0,0xfa,0xff,0x60,0x14,
+0xb6,0x51,0x40,0xa0,0x01,0x00,0x31,0x26,0x20,0x00,0x22,0x2a,0xd4,0x51,0x00,0xae,
+0xe3,0xff,0x40,0x14,0x94,0x00,0x10,0x26,0x02,0x80,0x02,0x3c,0x02,0x80,0x03,0x3c,
+0x68,0x15,0x4b,0x24,0x02,0x80,0x02,0x3c,0x4c,0x91,0x6f,0x24,0xd8,0x90,0x4d,0x24,
+0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0xb8,0x90,0x6e,0x24,0x98,0x90,0x4c,0x24,
+0x21,0x88,0x00,0x00,0x80,0x18,0x11,0x00,0x21,0x20,0x6d,0x00,0x21,0x10,0x6f,0x00,
+0x21,0x28,0x2e,0x02,0x21,0x30,0x2c,0x02,0x00,0x00,0x88,0x8c,0x00,0x00,0xa9,0x90,
+0x00,0x00,0xc7,0x90,0x00,0x00,0x4a,0x8c,0x21,0x10,0x2b,0x02,0x01,0x00,0x31,0x26,
+0x21,0x18,0x6b,0x00,0x1d,0x00,0x24,0x2a,0xec,0x44,0x68,0xac,0xca,0x44,0x47,0xa0,
+0x60,0x45,0x6a,0xac,0xef,0xff,0x80,0x14,0x90,0x44,0x49,0xa0,0x02,0x80,0x02,0x3c,
+0x68,0x15,0x4a,0x24,0x02,0x80,0x03,0x3c,0x02,0x80,0x02,0x3c,0x74,0x8f,0x6b,0x24,
+0x14,0x8e,0x4c,0x24,0x21,0x88,0x00,0x00,0x21,0x48,0x00,0x00,0x21,0x30,0x00,0x00,
+0x21,0x40,0x2a,0x01,0x21,0x38,0x2b,0x01,0x21,0x10,0xe6,0x00,0x91,0x00,0x44,0x90,
+0x00,0x00,0x45,0x90,0x21,0x18,0x06,0x01,0x01,0x00,0xc6,0x24,0x05,0x00,0xc2,0x28,
+0xc5,0x43,0x64,0xa0,0xf8,0xff,0x40,0x14,0x34,0x43,0x65,0xa0,0x21,0x10,0x2c,0x02,
+0x1d,0x00,0x44,0x90,0x00,0x00,0x45,0x90,0x21,0x18,0x2a,0x02,0x01,0x00,0x31,0x26,
+0x1d,0x00,0x22,0x2a,0x73,0x44,0x64,0xa0,0x56,0x44,0x65,0xa0,0xeb,0xff,0x40,0x14,
+0x05,0x00,0x29,0x25,0x52,0x00,0x02,0x24,0x10,0x00,0xa2,0xa3,0x41,0x00,0x03,0x24,
+0x4d,0x00,0x02,0x24,0x02,0x80,0x07,0x3c,0x1c,0x97,0xe7,0x24,0x11,0x00,0xa3,0xa3,
+0x12,0x00,0xa2,0xa3,0xe8,0x03,0x03,0x24,0x01,0x00,0x02,0x24,0x00,0x80,0x06,0x3c,
+0x10,0x00,0xa5,0x27,0x21,0x20,0xe0,0x00,0xf0,0x37,0xc6,0x24,0x0c,0x00,0xe3,0xac,
+0x14,0x00,0xe2,0xa0,0xfb,0x0c,0x00,0x0c,0x13,0x00,0xa0,0xa3,0x2c,0x00,0xbf,0x8f,
+0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,0x1c,0x00,0xb1,0x8f,
+0x18,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,
+0x02,0x80,0x02,0x3c,0x42,0x00,0x03,0x24,0x10,0x00,0xa3,0xa3,0x55,0x60,0x40,0xa0,
+0x4e,0x00,0x03,0x24,0x43,0x00,0x02,0x24,0x02,0x80,0x07,0x3c,0x54,0x97,0xe7,0x24,
+0x11,0x00,0xa2,0xa3,0x12,0x00,0xa3,0xa3,0xd0,0x07,0x02,0x24,0x01,0x00,0x03,0x24,
+0x00,0x80,0x06,0x3c,0x10,0x00,0xa5,0x27,0x21,0x20,0xe0,0x00,0xdc,0x44,0xc6,0x24,
+0x0c,0x00,0xe2,0xac,0x14,0x00,0xe3,0xa0,0x18,0x00,0xbf,0xaf,0xfb,0x0c,0x00,0x0c,
+0x13,0x00,0xa0,0xa3,0x18,0x00,0xbf,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0x48,0xfd,0xbd,0x27,0xb4,0x02,0xb3,0xaf,0x02,0x80,0x02,0x3c,
+0x02,0x80,0x13,0x3c,0x24,0x92,0x46,0x24,0x68,0x15,0x63,0x26,0xb0,0x02,0xb2,0xaf,
+0xac,0x02,0xb1,0xaf,0xa8,0x02,0xb0,0xaf,0x03,0x40,0x60,0xa0,0x21,0x38,0xa0,0x03,
+0x90,0x00,0xc8,0x24,0x00,0x00,0xc2,0x8c,0x04,0x00,0xc3,0x8c,0x08,0x00,0xc4,0x8c,
+0x0c,0x00,0xc5,0x8c,0x10,0x00,0xc6,0x24,0x00,0x00,0xe2,0xac,0x04,0x00,0xe3,0xac,
+0x08,0x00,0xe4,0xac,0x0c,0x00,0xe5,0xac,0xf6,0xff,0xc8,0x14,0x10,0x00,0xe7,0x24,
+0x00,0x00,0xc3,0x8c,0x02,0x80,0x02,0x3c,0xb8,0x92,0x58,0x24,0x00,0x00,0xe3,0xac,
+0x98,0x00,0xb9,0x27,0x00,0x01,0x12,0x27,0x01,0x00,0x02,0x93,0x05,0x00,0x03,0x93,
+0x09,0x00,0x04,0x93,0x0d,0x00,0x05,0x93,0x00,0x00,0x11,0x93,0x02,0x00,0x0d,0x93,
+0x04,0x00,0x10,0x93,0x06,0x00,0x0c,0x93,0x08,0x00,0x0f,0x93,0x0a,0x00,0x07,0x93,
+0x0c,0x00,0x0e,0x93,0x0e,0x00,0x06,0x93,0x03,0x00,0x08,0x93,0x07,0x00,0x09,0x93,
+0x0b,0x00,0x0a,0x93,0x0f,0x00,0x0b,0x93,0x00,0x12,0x02,0x00,0x00,0x1a,0x03,0x00,
+0x00,0x22,0x04,0x00,0x00,0x2a,0x05,0x00,0x25,0x10,0x51,0x00,0x25,0x18,0x70,0x00,
+0x25,0x20,0x8f,0x00,0x25,0x28,0xae,0x00,0x00,0x6c,0x0d,0x00,0x00,0x64,0x0c,0x00,
+0x00,0x3c,0x07,0x00,0x00,0x34,0x06,0x00,0x25,0x68,0xa2,0x01,0x25,0x60,0x83,0x01,
+0x25,0x38,0xe4,0x00,0x25,0x30,0xc5,0x00,0x00,0x46,0x08,0x00,0x00,0x4e,0x09,0x00,
+0x00,0x56,0x0a,0x00,0x00,0x5e,0x0b,0x00,0x25,0x40,0x0d,0x01,0x25,0x48,0x2c,0x01,
+0x25,0x50,0x47,0x01,0x25,0x58,0x66,0x01,0x10,0x00,0x18,0x27,0x00,0x00,0x28,0xaf,
+0x04,0x00,0x29,0xaf,0x08,0x00,0x2a,0xaf,0x0c,0x00,0x2b,0xaf,0xd2,0xff,0x12,0x17,
+0x10,0x00,0x39,0x27,0x01,0x00,0x02,0x93,0x05,0x00,0x03,0x93,0x00,0x00,0x09,0x93,
+0x02,0x00,0x04,0x93,0x04,0x00,0x08,0x93,0x06,0x00,0x05,0x93,0x07,0x00,0x06,0x93,
+0x03,0x00,0x07,0x93,0x00,0x12,0x02,0x00,0x00,0x1a,0x03,0x00,0x25,0x10,0x49,0x00,
+0x25,0x18,0x68,0x00,0x00,0x24,0x04,0x00,0x00,0x2c,0x05,0x00,0x25,0x20,0x82,0x00,
+0x25,0x28,0xa3,0x00,0x00,0x3e,0x07,0x00,0x00,0x36,0x06,0x00,0x02,0x80,0x02,0x3c,
+0x25,0x38,0xe4,0x00,0x25,0x30,0xc5,0x00,0xc0,0x93,0x58,0x24,0x04,0x00,0x26,0xaf,
+0x00,0x00,0x27,0xaf,0x00,0x01,0x12,0x27,0xa0,0x01,0xb9,0x27,0x01,0x00,0x02,0x93,
+0x05,0x00,0x03,0x93,0x09,0x00,0x04,0x93,0x0d,0x00,0x05,0x93,0x00,0x00,0x11,0x93,
+0x02,0x00,0x0d,0x93,0x04,0x00,0x10,0x93,0x06,0x00,0x0c,0x93,0x08,0x00,0x0f,0x93,
+0x0a,0x00,0x07,0x93,0x0c,0x00,0x0e,0x93,0x0e,0x00,0x06,0x93,0x03,0x00,0x08,0x93,
+0x07,0x00,0x09,0x93,0x0b,0x00,0x0a,0x93,0x0f,0x00,0x0b,0x93,0x00,0x12,0x02,0x00,
+0x00,0x1a,0x03,0x00,0x00,0x22,0x04,0x00,0x00,0x2a,0x05,0x00,0x25,0x10,0x51,0x00,
+0x25,0x18,0x70,0x00,0x25,0x20,0x8f,0x00,0x25,0x28,0xae,0x00,0x00,0x6c,0x0d,0x00,
+0x00,0x64,0x0c,0x00,0x00,0x3c,0x07,0x00,0x00,0x34,0x06,0x00,0x25,0x68,0xa2,0x01,
+0x25,0x60,0x83,0x01,0x25,0x38,0xe4,0x00,0x25,0x30,0xc5,0x00,0x00,0x46,0x08,0x00,
+0x00,0x4e,0x09,0x00,0x00,0x56,0x0a,0x00,0x00,0x5e,0x0b,0x00,0x25,0x40,0x0d,0x01,
+0x25,0x48,0x2c,0x01,0x25,0x50,0x47,0x01,0x25,0x58,0x66,0x01,0x10,0x00,0x18,0x27,
+0x00,0x00,0x28,0xaf,0x04,0x00,0x29,0xaf,0x08,0x00,0x2a,0xaf,0x0c,0x00,0x2b,0xaf,
+0xd2,0xff,0x12,0x17,0x10,0x00,0x39,0x27,0x01,0x00,0x02,0x93,0x05,0x00,0x03,0x93,
+0x00,0x00,0x09,0x93,0x02,0x00,0x04,0x93,0x04,0x00,0x08,0x93,0x06,0x00,0x05,0x93,
+0x07,0x00,0x06,0x93,0x03,0x00,0x07,0x93,0x00,0x12,0x02,0x00,0x00,0x1a,0x03,0x00,
+0x25,0x10,0x49,0x00,0x25,0x18,0x68,0x00,0x00,0x24,0x04,0x00,0x00,0x2c,0x05,0x00,
+0x25,0x20,0x82,0x00,0x25,0x28,0xa3,0x00,0x00,0x3e,0x07,0x00,0x00,0x36,0x06,0x00,
+0x25,0x30,0xc5,0x00,0x25,0x38,0xe4,0x00,0x02,0x80,0x02,0x3c,0x04,0x00,0x26,0xaf,
+0x00,0x00,0x27,0xaf,0x68,0x15,0x46,0x24,0x21,0x50,0x00,0x00,0x80,0x20,0x0a,0x00,
+0x21,0x10,0x9d,0x00,0x00,0x00,0x45,0x8c,0x01,0x00,0x43,0x25,0xff,0x00,0x6a,0x30,
+0x21,0x20,0x86,0x00,0x25,0x00,0x42,0x2d,0xf8,0xff,0x40,0x14,0x18,0x40,0x85,0xac,
+0x02,0x80,0x02,0x3c,0x68,0x15,0x4b,0x24,0x21,0x50,0x00,0x00,0xc0,0x10,0x0a,0x00,
+0x21,0x48,0x5d,0x00,0x21,0x38,0x00,0x00,0x21,0x40,0x4b,0x00,0x21,0x10,0x27,0x01,
+0xa0,0x01,0x46,0x90,0x98,0x00,0x45,0x90,0x01,0x00,0xe4,0x24,0x21,0x18,0x07,0x01,
+0xff,0x00,0x87,0x30,0x08,0x00,0xe2,0x2c,0xb4,0x41,0x66,0xa0,0xf7,0xff,0x40,0x14,
+0xac,0x40,0x65,0xa0,0x01,0x00,0x42,0x25,0xff,0x00,0x4a,0x30,0x21,0x00,0x43,0x2d,
+0xef,0xff,0x60,0x14,0xc0,0x10,0x0a,0x00,0x25,0xb0,0x02,0x3c,0x0a,0x00,0x42,0x34,
+0x00,0x00,0x43,0x90,0x00,0x00,0x00,0x00,0x20,0x00,0x63,0x30,0x42,0x00,0x60,0x10,
+0x68,0x15,0x64,0x26,0x33,0x00,0x02,0x24,0xc1,0x42,0x62,0xa1,0x1c,0x00,0x03,0x24,
+0x0f,0x00,0x02,0x24,0xbc,0x42,0x63,0xa1,0xbd,0x42,0x62,0xa1,0x68,0x15,0x65,0x26,
+0x08,0x40,0xa4,0x8c,0xff,0x7f,0x08,0x3c,0xff,0xff,0x08,0x35,0xc0,0xff,0x02,0x24,
+0x24,0x20,0x88,0x00,0x24,0x20,0x82,0x00,0x0c,0x00,0x84,0x34,0xff,0xc0,0x02,0x24,
+0x24,0x20,0x82,0x00,0xc0,0xff,0x02,0x3c,0xff,0xff,0x42,0x34,0x00,0x18,0x84,0x34,
+0xbf,0xff,0x03,0x3c,0x24,0x20,0x82,0x00,0xff,0xff,0x63,0x34,0x7f,0xff,0x02,0x3c,
+0x24,0x20,0x83,0x00,0xff,0xff,0x42,0x34,0x24,0x20,0x82,0x00,0x0c,0x40,0xa6,0x8c,
+0x7f,0xff,0x03,0x24,0x40,0x40,0x84,0x34,0xff,0xff,0x02,0x3c,0x24,0x20,0x83,0x00,
+0xff,0x7f,0x42,0x34,0xff,0xbf,0x03,0x3c,0x10,0x40,0xa7,0x8c,0x24,0x20,0x82,0x00,
+0xff,0xff,0x63,0x34,0xff,0x9f,0x02,0x3c,0x24,0x30,0xc3,0x00,0xff,0xff,0x42,0x34,
+0xff,0x3f,0x03,0x3c,0x24,0x20,0x82,0x00,0xff,0xff,0x63,0x34,0x12,0x00,0x02,0x24,
+0xb4,0x02,0xb3,0x8f,0xb0,0x02,0xb2,0x8f,0xac,0x02,0xb1,0x8f,0xa8,0x02,0xb0,0x8f,
+0x24,0x38,0xe3,0x00,0xc7,0x42,0xa2,0xa0,0x1f,0x00,0x03,0x24,0x01,0x00,0x02,0x24,
+0x24,0x30,0xc8,0x00,0xbe,0x42,0xa3,0xa0,0xc0,0x42,0xa2,0xa0,0xff,0x00,0x03,0x24,
+0xff,0xff,0x02,0x24,0xb8,0x02,0xbd,0x27,0x08,0x40,0xa4,0xac,0x10,0x40,0xa7,0xac,
+0x0c,0x40,0xa6,0xac,0xc2,0x42,0xa2,0xa0,0xc4,0x42,0xa3,0xa4,0xbf,0x42,0xa0,0xa0,
+0x08,0x00,0xe0,0x03,0xc6,0x42,0xa0,0xa0,0x33,0x00,0x02,0x24,0xc1,0x42,0x82,0xa0,
+0x0d,0x00,0x03,0x24,0x03,0x00,0x02,0x24,0xbc,0x42,0x83,0xa0,0x65,0x5d,0x00,0x08,
+0xbd,0x42,0x82,0xa0,0xe0,0xff,0xbd,0x27,0x02,0x80,0x07,0x3c,0x68,0x15,0xe7,0x24,
+0x18,0x00,0xbf,0xaf,0x00,0x40,0xe3,0x8c,0xf0,0xff,0x02,0x24,0x02,0x80,0x08,0x3c,
+0x24,0x18,0x62,0x00,0xff,0xf0,0x02,0x24,0x24,0x18,0x62,0x00,0x00,0x40,0xe3,0xac,
+0x1c,0x00,0x03,0x24,0x36,0x00,0x02,0x24,0xcf,0x42,0xe3,0xa0,0x20,0x00,0x03,0x24,
+0xce,0x42,0xe2,0xa0,0xd1,0x42,0xe3,0xa0,0x32,0x00,0x02,0x24,0x20,0x00,0x03,0x24,
+0xd0,0x42,0xe2,0xa0,0xc8,0x42,0xe3,0xa4,0x0a,0x00,0x02,0x24,0x00,0x02,0x03,0x24,
+0xd2,0x42,0xe2,0xa0,0xcc,0x42,0xe3,0xa4,0x00,0x01,0x02,0x24,0x49,0x00,0x03,0x24,
+0x38,0x97,0x08,0x25,0xff,0xff,0x0a,0x34,0x01,0x00,0x09,0x24,0x11,0x00,0xa3,0xa3,
+0xca,0x42,0xe2,0xa4,0xd0,0x07,0x03,0x24,0x44,0x00,0x02,0x24,0x00,0x80,0x06,0x3c,
+0x10,0x00,0xa2,0xa3,0x10,0x00,0xa5,0x27,0x47,0x00,0x02,0x24,0x21,0x20,0x00,0x01,
+0x54,0x45,0xc6,0x24,0x04,0x40,0xea,0xac,0x02,0x40,0xe9,0xa0,0x0c,0x00,0x03,0xad,
+0x14,0x00,0x09,0xa1,0xe6,0x42,0xe0,0xa0,0xdc,0x63,0xea,0xac,0xd7,0x42,0xe0,0xa0,
+0x12,0x00,0xa2,0xa3,0xfb,0x0c,0x00,0x0c,0x13,0x00,0xa0,0xa3,0x18,0x00,0xbf,0x8f,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,
+0x02,0x80,0x02,0x3c,0x50,0x00,0x03,0x24,0x10,0x00,0xa3,0xa3,0x2a,0x62,0x40,0xa0,
+0x41,0x00,0x03,0x24,0x52,0x00,0x02,0x24,0x02,0x80,0x07,0x3c,0xc4,0x97,0xe7,0x24,
+0x11,0x00,0xa2,0xa3,0x12,0x00,0xa3,0xa3,0xd0,0x07,0x02,0x24,0x01,0x00,0x03,0x24,
+0x01,0x80,0x06,0x3c,0x10,0x00,0xa5,0x27,0x21,0x20,0xe0,0x00,0x88,0x5b,0xc6,0x24,
+0x0c,0x00,0xe2,0xac,0x14,0x00,0xe3,0xa0,0x18,0x00,0xbf,0xaf,0xfb,0x0c,0x00,0x0c,
+0x13,0x00,0xa0,0xa3,0x18,0x00,0xbf,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0xd8,0xff,0xbd,0x27,0x18,0x00,0xb0,0xaf,0x02,0x80,0x10,0x3c,
+0x68,0x15,0x10,0x26,0x20,0x00,0xbf,0xaf,0x1c,0x00,0xb1,0xaf,0x00,0x40,0x09,0x8e,
+0xff,0xff,0x02,0x24,0xff,0x00,0x4b,0x30,0x0f,0xff,0x02,0x24,0x24,0x48,0x22,0x01,
+0xff,0xff,0x02,0x3c,0xff,0x0f,0x42,0x34,0x24,0x48,0x22,0x01,0x01,0x00,0x07,0x3c,
+0x47,0x00,0x02,0x24,0x3b,0x00,0x03,0x24,0x02,0x80,0x08,0x3c,0x10,0x00,0xa2,0xa3,
+0x11,0x00,0xa3,0xa3,0xe0,0x97,0x08,0x25,0x56,0x30,0xea,0x34,0xd0,0x07,0x02,0x24,
+0x01,0x00,0x03,0x24,0xf4,0x98,0xe7,0x34,0x00,0x80,0x06,0x3c,0x04,0x43,0x0b,0xae,
+0x00,0x40,0x09,0xae,0x43,0x00,0x11,0x24,0x10,0x00,0xa5,0x27,0x0c,0x43,0x07,0xae,
+0x10,0x43,0x0a,0xae,0x0c,0x00,0x02,0xad,0x14,0x00,0x03,0xa1,0x08,0x43,0x00,0xae,
+0x14,0x43,0x00,0xae,0x18,0x43,0x00,0xae,0x21,0x20,0x00,0x01,0xe4,0x4e,0xc6,0x24,
+0x12,0x00,0xb1,0xa3,0xfb,0x0c,0x00,0x0c,0x13,0x00,0xa0,0xa3,0x1e,0x00,0x02,0x24,
+0x21,0x43,0x02,0xa2,0x4a,0x00,0x03,0x24,0x45,0x00,0x02,0x24,0x1c,0x43,0x03,0xa2,
+0x1d,0x43,0x02,0xa2,0x23,0x00,0x03,0x24,0x3e,0x00,0x02,0x24,0x1e,0x43,0x11,0xa2,
+0x1f,0x43,0x02,0xa2,0x20,0x43,0x03,0xa2,0x20,0x00,0xbf,0x8f,0x1c,0x00,0xb1,0x8f,
+0x18,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,
+0x3b,0x00,0x02,0x24,0x43,0x00,0x03,0x24,0x10,0x00,0xa2,0xa3,0x11,0x00,0xa3,0xa3,
+0x36,0x00,0x02,0x24,0x02,0x80,0x03,0x3c,0x02,0x80,0x07,0x3c,0xfc,0x97,0xe7,0x24,
+0x12,0x00,0xa2,0xa3,0x3b,0x58,0x60,0xa0,0xd0,0x07,0x02,0x24,0x01,0x00,0x03,0x24,
+0x00,0x80,0x06,0x3c,0x10,0x00,0xa5,0x27,0x21,0x20,0xe0,0x00,0x20,0x53,0xc6,0x24,
+0x0c,0x00,0xe2,0xac,0x14,0x00,0xe3,0xa0,0x18,0x00,0xbf,0xaf,0xfb,0x0c,0x00,0x0c,
+0x13,0x00,0xa0,0xa3,0x18,0x00,0xbf,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0xff,0xff,0x07,0x24,0x02,0x80,0x02,0x3c,0xe0,0xff,0xbd,0x27,
+0x3d,0x58,0x47,0xa0,0x3b,0x00,0x03,0x24,0x43,0x00,0x02,0x24,0x10,0x00,0xa3,0xa3,
+0x11,0x00,0xa2,0xa3,0x36,0x00,0x03,0x24,0x16,0x00,0x02,0x24,0x02,0x80,0x08,0x3c,
+0x18,0x98,0x08,0x25,0x12,0x00,0xa3,0xa3,0x13,0x00,0xa2,0xa3,0xd0,0x07,0x03,0x24,
+0x01,0x00,0x02,0x24,0x00,0x80,0x06,0x3c,0x10,0x00,0xa5,0x27,0x21,0x20,0x00,0x01,
+0x0c,0x00,0x03,0xad,0x14,0x00,0x02,0xa1,0x18,0x00,0xbf,0xaf,0xfb,0x0c,0x00,0x0c,
+0xb8,0x54,0xc6,0x24,0x18,0x00,0xbf,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
+0x20,0x00,0xbd,0x27,0xe0,0xff,0xbd,0x27,0x02,0x80,0x02,0x3c,0x52,0x00,0x03,0x24,
+0x10,0x00,0xa3,0xa3,0x4c,0x79,0x40,0xa4,0x54,0x00,0x03,0x24,0x53,0x00,0x02,0x24,
+0x02,0x80,0x07,0x3c,0x34,0x98,0xe7,0x24,0x11,0x00,0xa2,0xa3,0x12,0x00,0xa3,0xa3,
+0xf4,0x01,0x02,0x24,0x01,0x00,0x03,0x24,0x01,0x80,0x06,0x3c,0x10,0x00,0xa5,0x27,
+0x21,0x20,0xe0,0x00,0xc8,0x5c,0xc6,0x24,0x0c,0x00,0xe2,0xac,0x14,0x00,0xe3,0xa0,
+0x18,0x00,0xbf,0xaf,0xfb,0x0c,0x00,0x0c,0x13,0x00,0xa0,0xa3,0x18,0x00,0xbf,0x8f,
+0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x78,0x0c,0x00,0x00,0x01,0x00,0x00,0x5e,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x01,0x5e,0x78,0x0c,0x00,0x00,0x01,0x00,0x02,0x5e,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x03,0x5e,0x78,0x0c,0x00,0x00,0x01,0x00,0x04,0x5d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x05,0x5b,0x78,0x0c,0x00,0x00,0x01,0x00,0x06,0x59,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x07,0x57,0x78,0x0c,0x00,0x00,0x01,0x00,0x08,0x55,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x09,0x53,0x78,0x0c,0x00,0x00,0x01,0x00,0x0a,0x51,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x0b,0x4f,0x78,0x0c,0x00,0x00,0x01,0x00,0x0c,0x4d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x0d,0x4b,0x78,0x0c,0x00,0x00,0x01,0x00,0x0e,0x49,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x0f,0x47,0x78,0x0c,0x00,0x00,0x01,0x00,0x10,0x45,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x11,0x43,0x78,0x0c,0x00,0x00,0x01,0x00,0x12,0x41,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x13,0x3f,0x78,0x0c,0x00,0x00,0x01,0x00,0x14,0x3d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x15,0x3b,0x78,0x0c,0x00,0x00,0x01,0x00,0x16,0x39,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x17,0x37,0x78,0x0c,0x00,0x00,0x01,0x00,0x18,0x35,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x19,0x33,0x78,0x0c,0x00,0x00,0x01,0x00,0x1a,0x31,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x1b,0x2f,0x78,0x0c,0x00,0x00,0x01,0x00,0x1c,0x2d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x1d,0x2b,0x78,0x0c,0x00,0x00,0x01,0x00,0x1e,0x29,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x1f,0x27,0x78,0x0c,0x00,0x00,0x01,0x00,0x20,0x25,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x21,0x23,0x78,0x0c,0x00,0x00,0x01,0x00,0x22,0x21,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x23,0x1f,0x78,0x0c,0x00,0x00,0x01,0x00,0x24,0x1d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x25,0x1b,0x78,0x0c,0x00,0x00,0x01,0x00,0x26,0x19,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x27,0x17,0x78,0x0c,0x00,0x00,0x01,0x00,0x28,0x15,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x29,0x13,0x78,0x0c,0x00,0x00,0x01,0x00,0x2a,0x11,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x2b,0x0f,0x78,0x0c,0x00,0x00,0x01,0x00,0x2c,0x0d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x2d,0x0b,0x78,0x0c,0x00,0x00,0x01,0x00,0x2e,0x09,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x2f,0x07,0x78,0x0c,0x00,0x00,0x01,0x00,0x30,0x05,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x31,0x03,0x78,0x0c,0x00,0x00,0x01,0x00,0x32,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x33,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x34,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x35,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x36,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x37,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x38,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x39,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x3a,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x3b,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x3c,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x3d,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x3e,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x3f,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x40,0x5e,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x41,0x5e,0x78,0x0c,0x00,0x00,0x01,0x00,0x42,0x5e,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x43,0x5e,0x78,0x0c,0x00,0x00,0x01,0x00,0x44,0x5d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x45,0x5b,0x78,0x0c,0x00,0x00,0x01,0x00,0x46,0x59,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x47,0x57,0x78,0x0c,0x00,0x00,0x01,0x00,0x48,0x55,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x49,0x53,0x78,0x0c,0x00,0x00,0x01,0x00,0x4a,0x51,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x4b,0x4f,0x78,0x0c,0x00,0x00,0x01,0x00,0x4c,0x4d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x4d,0x4b,0x78,0x0c,0x00,0x00,0x01,0x00,0x4e,0x49,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x4f,0x47,0x78,0x0c,0x00,0x00,0x01,0x00,0x50,0x45,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x51,0x43,0x78,0x0c,0x00,0x00,0x01,0x00,0x52,0x41,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x53,0x3f,0x78,0x0c,0x00,0x00,0x01,0x00,0x54,0x3d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x55,0x3b,0x78,0x0c,0x00,0x00,0x01,0x00,0x56,0x39,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x57,0x37,0x78,0x0c,0x00,0x00,0x01,0x00,0x58,0x35,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x59,0x33,0x78,0x0c,0x00,0x00,0x01,0x00,0x5a,0x31,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x5b,0x2f,0x78,0x0c,0x00,0x00,0x01,0x00,0x5c,0x2d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x5d,0x2b,0x78,0x0c,0x00,0x00,0x01,0x00,0x5e,0x29,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x5f,0x27,0x78,0x0c,0x00,0x00,0x01,0x00,0x60,0x25,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x61,0x23,0x78,0x0c,0x00,0x00,0x01,0x00,0x62,0x21,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x63,0x1f,0x78,0x0c,0x00,0x00,0x01,0x00,0x64,0x1d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x65,0x1b,0x78,0x0c,0x00,0x00,0x01,0x00,0x66,0x19,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x67,0x17,0x78,0x0c,0x00,0x00,0x01,0x00,0x68,0x15,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x69,0x13,0x78,0x0c,0x00,0x00,0x01,0x00,0x6a,0x11,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x6b,0x0f,0x78,0x0c,0x00,0x00,0x01,0x00,0x6c,0x0d,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x6d,0x0b,0x78,0x0c,0x00,0x00,0x01,0x00,0x6e,0x09,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x6f,0x07,0x78,0x0c,0x00,0x00,0x01,0x00,0x70,0x05,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x71,0x03,0x78,0x0c,0x00,0x00,0x01,0x00,0x72,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x73,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x74,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x75,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x76,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x77,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x78,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x79,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x7a,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x7b,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x7c,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x7d,0x01,0x78,0x0c,0x00,0x00,0x01,0x00,0x7e,0x01,0x78,0x0c,0x00,0x00,
+0x01,0x00,0x7f,0x01,0x78,0x0c,0x00,0x00,0x1e,0x00,0x00,0x30,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x01,0x30,0x78,0x0c,0x00,0x00,0x1e,0x00,0x02,0x30,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x03,0x30,0x78,0x0c,0x00,0x00,0x1e,0x00,0x04,0x30,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x05,0x30,0x78,0x0c,0x00,0x00,0x1e,0x00,0x06,0x30,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x07,0x30,0x78,0x0c,0x00,0x00,0x1e,0x00,0x08,0x3e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x09,0x40,0x78,0x0c,0x00,0x00,0x1e,0x00,0x0a,0x42,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x0b,0x44,0x78,0x0c,0x00,0x00,0x1e,0x00,0x0c,0x46,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x0d,0x48,0x78,0x0c,0x00,0x00,0x1e,0x00,0x0e,0x48,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x0f,0x4a,0x78,0x0c,0x00,0x00,0x1e,0x00,0x10,0x4a,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x11,0x4c,0x78,0x0c,0x00,0x00,0x1e,0x00,0x12,0x4c,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x13,0x4e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x14,0x50,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x15,0x50,0x78,0x0c,0x00,0x00,0x1e,0x00,0x16,0x50,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x17,0x52,0x78,0x0c,0x00,0x00,0x1e,0x00,0x18,0x52,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x19,0x52,0x78,0x0c,0x00,0x00,0x1e,0x00,0x1a,0x54,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x1b,0x54,0x78,0x0c,0x00,0x00,0x1e,0x00,0x1c,0x54,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x1d,0x56,0x78,0x0c,0x00,0x00,0x1e,0x00,0x1e,0x56,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x1f,0x56,0x78,0x0c,0x00,0x00,0x1e,0x00,0x20,0x56,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x21,0x58,0x78,0x0c,0x00,0x00,0x1e,0x00,0x22,0x58,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x23,0x58,0x78,0x0c,0x00,0x00,0x1e,0x00,0x24,0x58,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x25,0x5a,0x78,0x0c,0x00,0x00,0x1e,0x00,0x26,0x5a,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x27,0x5a,0x78,0x0c,0x00,0x00,0x1e,0x00,0x28,0x5c,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x29,0x5c,0x78,0x0c,0x00,0x00,0x1e,0x00,0x2a,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x2b,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x2c,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x2d,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x2e,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x2f,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x30,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x31,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x32,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x33,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x34,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x35,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x36,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x37,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x38,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x39,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x3a,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x3b,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x3c,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x3d,0x5e,0x78,0x0c,0x00,0x00,0x1e,0x00,0x3e,0x5e,0x78,0x0c,0x00,0x00,
+0x1e,0x00,0x3f,0x5e,0xff,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x08,0x00,0x00,
+0x00,0x00,0x04,0x03,0x04,0x08,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x08,0x00,0x00,
+0x00,0xfc,0x00,0x00,0x0c,0x08,0x00,0x00,0x0a,0x00,0x00,0x04,0x10,0x08,0x00,0x00,
+0xff,0x10,0x10,0x80,0x14,0x08,0x00,0x00,0x10,0x3d,0x0c,0x02,0x18,0x08,0x00,0x00,
+0xc5,0x03,0x00,0x00,0x1c,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x00,
+0x04,0x00,0x00,0x00,0x24,0x08,0x00,0x00,0x00,0x02,0x69,0x00,0x28,0x08,0x00,0x00,
+0x04,0x00,0x00,0x00,0x2c,0x08,0x00,0x00,0x00,0x02,0x69,0x00,0x30,0x08,0x00,0x00,
+0x04,0x00,0x00,0x00,0x34,0x08,0x00,0x00,0x00,0x02,0x69,0x00,0x38,0x08,0x00,0x00,
+0x04,0x00,0x00,0x00,0x3c,0x08,0x00,0x00,0x00,0x02,0x69,0x00,0x40,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0x44,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0x4c,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0x54,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x08,0x00,0x00,
+0x65,0xa9,0x65,0xa9,0x5c,0x08,0x00,0x00,0x65,0xa9,0x65,0xa9,0x60,0x08,0x00,0x00,
+0x30,0x01,0x7f,0x0f,0x64,0x08,0x00,0x00,0x30,0x01,0x7f,0x0f,0x68,0x08,0x00,0x00,
+0x30,0x01,0x7f,0x0f,0x6c,0x08,0x00,0x00,0x30,0x01,0x7f,0x0f,0x70,0x08,0x00,0x00,
+0x00,0x03,0x00,0x03,0x74,0x08,0x00,0x00,0x00,0x03,0x00,0x03,0x78,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0x7c,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0x94,0x08,0x00,0x00,0xfe,0xff,0xff,0xff,0x98,0x08,0x00,0x00,
+0x10,0x20,0x30,0x40,0x9c,0x08,0x00,0x00,0x50,0x60,0x70,0x00,0xb0,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0xe0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x08,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x03,0x03,0x03,0x03,0x04,0x0e,0x00,0x00,
+0x03,0x03,0x03,0x03,0x08,0x0e,0x00,0x00,0x03,0x03,0x00,0x00,0x0c,0x0e,0x00,0x00,
+0x00,0x00,0x00,0x00,0x10,0x0e,0x00,0x00,0x03,0x03,0x03,0x03,0x14,0x0e,0x00,0x00,
+0x03,0x03,0x03,0x03,0x18,0x0e,0x00,0x00,0x03,0x03,0x03,0x03,0x1c,0x0e,0x00,0x00,
+0x03,0x03,0x03,0x03,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x09,0x00,0x00,
+0x23,0x00,0x00,0x00,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x09,0x00,0x00,
+0x33,0x13,0x32,0x03,0x08,0x0a,0x00,0x00,0x00,0x86,0x88,0x8f,0x2c,0x0a,0x00,0x00,
+0x00,0x00,0x92,0x00,0x00,0x0c,0x00,0x00,0x80,0x00,0x00,0x00,0x04,0x0c,0x00,0x00,
+0x33,0x54,0x00,0x00,0x08,0x0c,0x00,0x00,0xe4,0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,
+0x6c,0x6c,0x6c,0x6c,0x10,0x0c,0x00,0x00,0x00,0x00,0x00,0x08,0x14,0x0c,0x00,0x00,
+0x00,0x01,0x00,0x40,0x18,0x0c,0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x0c,0x00,0x00,
+0x00,0x01,0x00,0x40,0x20,0x0c,0x00,0x00,0x00,0x00,0x00,0x08,0x24,0x0c,0x00,0x00,
+0x00,0x01,0x00,0x40,0x28,0x0c,0x00,0x00,0x00,0x00,0x00,0x08,0x2c,0x0c,0x00,0x00,
+0x00,0x01,0x00,0x40,0x30,0x0c,0x00,0x00,0x44,0x6a,0xe9,0x8d,0x34,0x0c,0x00,0x00,
+0xcd,0x52,0x96,0x46,0x38,0x0c,0x00,0x00,0x90,0x5a,0x01,0x48,0x3c,0x0c,0x00,0x00,
+0x64,0x97,0x97,0x1a,0x40,0x0c,0x00,0x00,0x3f,0x42,0x7c,0x1f,0x44,0x0c,0x00,0x00,
+0xb7,0x00,0x01,0x00,0x48,0x0c,0x00,0x00,0x00,0x00,0x02,0xec,0x4c,0x0c,0x00,0x00,
+0x03,0x03,0xfc,0x00,0x50,0x0c,0x00,0x00,0x1c,0x34,0x54,0x69,0x54,0x0c,0x00,0x00,
+0x94,0x00,0x3c,0x43,0x58,0x0c,0x00,0x00,0x1c,0x34,0x54,0x69,0x5c,0x0c,0x00,0x00,
+0x94,0x00,0x3c,0x43,0x60,0x0c,0x00,0x00,0x1c,0x34,0x54,0x69,0x64,0x0c,0x00,0x00,
+0x94,0x00,0x3c,0x43,0x68,0x0c,0x00,0x00,0x1c,0x34,0x54,0x69,0x6c,0x0c,0x00,0x00,
+0x94,0x00,0x3c,0x43,0x70,0x0c,0x00,0x00,0x0d,0x00,0x5a,0x2c,0x74,0x0c,0x00,0x00,
+0x1b,0x15,0x86,0x01,0x78,0x0c,0x00,0x00,0x1f,0x00,0x00,0x00,0x7c,0x0c,0x00,0x00,
+0x12,0x16,0xb9,0x00,0x80,0x0c,0x00,0x00,0x80,0x00,0x00,0x20,0x84,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x88,0x0c,0x00,0x00,0x80,0x00,0x00,0x20,0x8c,0x0c,0x00,0x00,
+0x00,0x00,0x20,0x08,0x90,0x0c,0x00,0x00,0x00,0x01,0x00,0x40,0x94,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x98,0x0c,0x00,0x00,0x00,0x01,0x00,0x40,0x9c,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xa0,0x0c,0x00,0x00,0x92,0x24,0x49,0x00,0xa4,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xa8,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xb0,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xb4,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xb8,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xbc,0x0c,0x00,0x00,
+0x92,0x24,0x49,0x00,0xc0,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xc4,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xc8,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xd0,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0xd4,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xd8,0x0c,0x00,0x00,0x27,0x24,0xb2,0x64,0xdc,0x0c,0x00,0x00,
+0x32,0x69,0x76,0x00,0xe0,0x0c,0x00,0x00,0x22,0x22,0x22,0x00,0xe4,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0xe8,0x0c,0x00,0x00,0x02,0x43,0x64,0x07,0x00,0x0d,0x00,0x00,
+0x80,0x07,0x00,0x00,0x04,0x0d,0x00,0x00,0x03,0x04,0x00,0x00,0x08,0x0d,0x00,0x00,
+0x7f,0x90,0x00,0x00,0x0c,0x0d,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x0d,0x00,0x00,
+0x99,0x99,0x69,0xa0,0x14,0x0d,0x00,0x00,0x67,0x3c,0x99,0x99,0x18,0x0d,0x00,0x00,
+0x6b,0x5b,0x8f,0x6a,0x1c,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x0d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x24,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x0d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x2c,0x0d,0x00,0x00,0x75,0x19,0x97,0xcc,0x30,0x0d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x34,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x3c,0x0d,0x00,0x00,0x93,0x72,0x02,0x00,0x40,0x0d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x44,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x0d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x50,0x0d,0x00,0x00,0x0a,0x14,0x37,0x64,0x54,0x0d,0x00,0x00,
+0x02,0xbd,0x4d,0x02,0x58,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x0d,0x00,0x00,
+0x64,0x20,0x03,0x30,0x60,0x0d,0x00,0x00,0x68,0xde,0x53,0x46,0x64,0x0d,0x00,0x00,
+0x3c,0x8a,0x51,0x00,0x68,0x0d,0x00,0x00,0x06,0x01,0x00,0x00,0xff,0x00,0x00,0x00,
+0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
+0x44,0x05,0x01,0x80,0x10,0x00,0x00,0x00,0x74,0x05,0x01,0x80,0x10,0x00,0x00,0x00,
+0xe0,0x2e,0x00,0x80,0x10,0x00,0x00,0x00,0xec,0x2e,0x00,0x80,0x10,0x00,0x00,0x00,
+0xa0,0x08,0x01,0x80,0x08,0x00,0x00,0x00,0x38,0x06,0x01,0x80,0x00,0xb7,0x00,0x00,
+0x01,0xe0,0x0e,0x00,0x02,0x4d,0x04,0x00,0x03,0x41,0x04,0x00,0x04,0xc3,0x08,0x00,
+0x05,0x72,0x0c,0x00,0x06,0xe6,0x00,0x00,0x07,0x2a,0x08,0x00,0x08,0x3f,0x00,0x00,
+0x09,0x35,0x03,0x00,0x0a,0xd4,0x09,0x00,0x0b,0xbb,0x07,0x00,0x0c,0x50,0x08,0x00,
+0x0d,0xdf,0x0c,0x00,0x0e,0x2b,0x00,0x00,0x0f,0x14,0x01,0x00,0x00,0xb7,0x01,0x00,
+0x01,0x01,0x00,0x00,0x02,0x00,0x04,0x00,0x01,0x02,0x00,0x00,0x02,0x01,0x04,0x00,
+0x01,0x03,0x00,0x00,0x02,0x02,0x04,0x00,0x01,0x04,0x00,0x00,0x02,0x03,0x04,0x00,
+0x01,0x05,0x00,0x00,0x02,0x04,0x04,0x00,0x01,0x06,0x00,0x00,0x02,0x05,0x04,0x00,
+0x01,0x07,0x00,0x00,0x02,0x08,0x04,0x00,0x01,0x08,0x00,0x00,0x02,0x09,0x04,0x00,
+0x01,0x09,0x00,0x00,0x02,0x0a,0x04,0x00,0x01,0x0a,0x00,0x00,0x02,0x0b,0x04,0x00,
+0x01,0x0b,0x00,0x00,0x02,0x02,0x05,0x00,0x01,0x0c,0x00,0x00,0x02,0x03,0x05,0x00,
+0x01,0x0d,0x00,0x00,0x02,0x04,0x05,0x00,0x01,0x0e,0x00,0x00,0x02,0x05,0x05,0x00,
+0x01,0x0f,0x00,0x00,0x02,0x40,0x05,0x00,0x01,0x10,0x00,0x00,0x02,0x41,0x05,0x00,
+0x01,0x11,0x00,0x00,0x02,0x42,0x05,0x00,0x01,0x12,0x00,0x00,0x02,0x43,0x05,0x00,
+0x01,0x13,0x00,0x00,0x02,0x44,0x05,0x00,0x01,0x14,0x00,0x00,0x02,0x45,0x05,0x00,
+0x01,0x15,0x00,0x00,0x02,0x80,0x05,0x00,0x01,0x16,0x00,0x00,0x02,0x81,0x05,0x00,
+0x01,0x17,0x00,0x00,0x02,0x82,0x05,0x00,0x01,0x18,0x00,0x00,0x02,0x83,0x05,0x00,
+0x01,0x19,0x00,0x00,0x02,0x84,0x05,0x00,0x01,0x1a,0x00,0x00,0x02,0x85,0x05,0x00,
+0x01,0x1b,0x00,0x00,0x02,0x88,0x05,0x00,0x01,0x1c,0x00,0x00,0x02,0x89,0x05,0x00,
+0x01,0x1d,0x00,0x00,0x02,0x8a,0x05,0x00,0x01,0x1e,0x00,0x00,0x02,0x8b,0x05,0x00,
+0x01,0x1f,0x00,0x00,0x02,0x43,0x06,0x00,0x01,0x20,0x00,0x00,0x02,0x44,0x06,0x00,
+0x01,0x21,0x00,0x00,0x02,0x45,0x06,0x00,0x01,0x22,0x00,0x00,0x02,0x80,0x06,0x00,
+0x01,0x23,0x00,0x00,0x02,0x81,0x06,0x00,0x01,0x24,0x00,0x00,0x02,0x82,0x06,0x00,
+0x01,0x25,0x00,0x00,0x02,0x83,0x06,0x00,0x01,0x26,0x00,0x00,0x02,0x84,0x06,0x00,
+0x01,0x27,0x00,0x00,0x02,0x85,0x06,0x00,0x01,0x28,0x00,0x00,0x02,0x88,0x06,0x00,
+0x01,0x29,0x00,0x00,0x02,0x89,0x06,0x00,0x01,0x2a,0x00,0x00,0x02,0x8a,0x06,0x00,
+0x01,0x2b,0x00,0x00,0x02,0x8b,0x06,0x00,0x01,0x2c,0x00,0x00,0x02,0x8c,0x06,0x00,
+0x01,0x2d,0x00,0x00,0x02,0x42,0x07,0x00,0x01,0x2e,0x00,0x00,0x02,0x43,0x07,0x00,
+0x01,0x2f,0x00,0x00,0x02,0x44,0x07,0x00,0x01,0x30,0x00,0x00,0x02,0x45,0x07,0x00,
+0x01,0x31,0x00,0x00,0x02,0x80,0x07,0x00,0x01,0x32,0x00,0x00,0x02,0x81,0x07,0x00,
+0x01,0x33,0x00,0x00,0x02,0x82,0x07,0x00,0x01,0x34,0x00,0x00,0x02,0x83,0x07,0x00,
+0x01,0x35,0x00,0x00,0x02,0x84,0x07,0x00,0x01,0x36,0x00,0x00,0x02,0x85,0x07,0x00,
+0x01,0x37,0x00,0x00,0x02,0x88,0x07,0x00,0x01,0x38,0x00,0x00,0x02,0x89,0x07,0x00,
+0x01,0x39,0x00,0x00,0x02,0x8a,0x07,0x00,0x01,0x3a,0x00,0x00,0x02,0x8b,0x07,0x00,
+0x01,0x3b,0x00,0x00,0x02,0x8c,0x07,0x00,0x01,0x3c,0x00,0x00,0x02,0x8d,0x07,0x00,
+0x01,0x3d,0x00,0x00,0x02,0x90,0x07,0x00,0x01,0x3e,0x00,0x00,0x02,0x91,0x07,0x00,
+0x01,0x3f,0x00,0x00,0x02,0x92,0x07,0x00,0x01,0x40,0x00,0x00,0x02,0x93,0x07,0x00,
+0x01,0x41,0x00,0x00,0x02,0x94,0x07,0x00,0x01,0x42,0x00,0x00,0x02,0x95,0x07,0x00,
+0x01,0x43,0x00,0x00,0x02,0x98,0x07,0x00,0x01,0x44,0x00,0x00,0x02,0x99,0x07,0x00,
+0x01,0x45,0x00,0x00,0x02,0x9a,0x07,0x00,0x01,0x46,0x00,0x00,0x02,0x9b,0x07,0x00,
+0x01,0x47,0x00,0x00,0x02,0x9c,0x07,0x00,0x01,0x48,0x00,0x00,0x02,0x9d,0x07,0x00,
+0x01,0x49,0x00,0x00,0x02,0xa0,0x07,0x00,0x01,0x4a,0x00,0x00,0x02,0xa1,0x07,0x00,
+0x01,0x4b,0x00,0x00,0x02,0xa2,0x07,0x00,0x01,0x4c,0x00,0x00,0x02,0xa3,0x07,0x00,
+0x01,0x4d,0x00,0x00,0x02,0xa4,0x07,0x00,0x01,0x4e,0x00,0x00,0x02,0xa5,0x07,0x00,
+0x01,0x4f,0x00,0x00,0x02,0xa8,0x07,0x00,0x01,0x50,0x00,0x00,0x02,0xa9,0x07,0x00,
+0x01,0x51,0x00,0x00,0x02,0xaa,0x03,0x00,0x01,0x52,0x00,0x00,0x02,0xab,0x03,0x00,
+0x01,0x53,0x00,0x00,0x02,0xac,0x03,0x00,0x01,0x54,0x00,0x00,0x02,0xad,0x03,0x00,
+0x01,0x55,0x00,0x00,0x02,0xb0,0x03,0x00,0x01,0x56,0x00,0x00,0x02,0xb1,0x03,0x00,
+0x01,0x57,0x00,0x00,0x02,0xb2,0x03,0x00,0x01,0x58,0x00,0x00,0x02,0xb3,0x03,0x00,
+0x01,0x59,0x00,0x00,0x02,0xb4,0x03,0x00,0x01,0x5a,0x00,0x00,0x02,0xb5,0x03,0x00,
+0x01,0x5b,0x00,0x00,0x02,0xb8,0x03,0x00,0x01,0x5c,0x00,0x00,0x02,0xb9,0x03,0x00,
+0x01,0x5d,0x00,0x00,0x02,0xba,0x03,0x00,0x01,0x5e,0x00,0x00,0x02,0xbb,0x03,0x00,
+0x01,0x5f,0x00,0x00,0x02,0xbb,0x03,0x00,0x03,0x80,0x00,0x00,0x05,0x04,0x00,0x00,
+0x00,0xb7,0x00,0x00,0xfe,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,
+0x02,0x4d,0x0c,0x00,0xfe,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x02,0x4d,0x04,0x00,
+0x00,0xbf,0x02,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0xb7,0x00,0x00,
+0x01,0xe0,0x0e,0x00,0x02,0x4d,0x04,0x00,0x03,0x41,0x04,0x00,0x04,0xc3,0x08,0x00,
+0x05,0x72,0x0c,0x00,0x06,0xe6,0x00,0x00,0x07,0x2a,0x08,0x00,0x08,0x3f,0x00,0x00,
+0x09,0x35,0x03,0x00,0x0a,0xd4,0x09,0x00,0x0b,0xbb,0x07,0x00,0x0c,0x50,0x08,0x00,
+0x0d,0xdf,0x0c,0x00,0x0e,0x2b,0x00,0x00,0x0f,0x14,0x01,0x00,0x00,0xb7,0x01,0x00,
+0x01,0x01,0x00,0x00,0x02,0x00,0x04,0x00,0x01,0x02,0x00,0x00,0x02,0x01,0x04,0x00,
+0x01,0x03,0x00,0x00,0x02,0x02,0x04,0x00,0x01,0x04,0x00,0x00,0x02,0x03,0x04,0x00,
+0x01,0x05,0x00,0x00,0x02,0x04,0x04,0x00,0x01,0x06,0x00,0x00,0x02,0x05,0x04,0x00,
+0x01,0x07,0x00,0x00,0x02,0x08,0x04,0x00,0x01,0x08,0x00,0x00,0x02,0x09,0x04,0x00,
+0x01,0x09,0x00,0x00,0x02,0x0a,0x04,0x00,0x01,0x0a,0x00,0x00,0x02,0x0b,0x04,0x00,
+0x01,0x0b,0x00,0x00,0x02,0x02,0x05,0x00,0x01,0x0c,0x00,0x00,0x02,0x03,0x05,0x00,
+0x01,0x0d,0x00,0x00,0x02,0x04,0x05,0x00,0x01,0x0e,0x00,0x00,0x02,0x05,0x05,0x00,
+0x01,0x0f,0x00,0x00,0x02,0x40,0x05,0x00,0x01,0x10,0x00,0x00,0x02,0x41,0x05,0x00,
+0x01,0x11,0x00,0x00,0x02,0x42,0x05,0x00,0x01,0x12,0x00,0x00,0x02,0x43,0x05,0x00,
+0x01,0x13,0x00,0x00,0x02,0x44,0x05,0x00,0x01,0x14,0x00,0x00,0x02,0x45,0x05,0x00,
+0x01,0x15,0x00,0x00,0x02,0x80,0x05,0x00,0x01,0x16,0x00,0x00,0x02,0x81,0x05,0x00,
+0x01,0x17,0x00,0x00,0x02,0x82,0x05,0x00,0x01,0x18,0x00,0x00,0x02,0x83,0x05,0x00,
+0x01,0x19,0x00,0x00,0x02,0x84,0x05,0x00,0x01,0x1a,0x00,0x00,0x02,0x85,0x05,0x00,
+0x01,0x1b,0x00,0x00,0x02,0x88,0x05,0x00,0x01,0x1c,0x00,0x00,0x02,0x89,0x05,0x00,
+0x01,0x1d,0x00,0x00,0x02,0x8a,0x05,0x00,0x01,0x1e,0x00,0x00,0x02,0x8b,0x05,0x00,
+0x01,0x1f,0x00,0x00,0x02,0x43,0x06,0x00,0x01,0x20,0x00,0x00,0x02,0x44,0x06,0x00,
+0x01,0x21,0x00,0x00,0x02,0x45,0x06,0x00,0x01,0x22,0x00,0x00,0x02,0x80,0x06,0x00,
+0x01,0x23,0x00,0x00,0x02,0x81,0x06,0x00,0x01,0x24,0x00,0x00,0x02,0x82,0x06,0x00,
+0x01,0x25,0x00,0x00,0x02,0x83,0x06,0x00,0x01,0x26,0x00,0x00,0x02,0x84,0x06,0x00,
+0x01,0x27,0x00,0x00,0x02,0x85,0x06,0x00,0x01,0x28,0x00,0x00,0x02,0x88,0x06,0x00,
+0x01,0x29,0x00,0x00,0x02,0x89,0x06,0x00,0x01,0x2a,0x00,0x00,0x02,0x8a,0x06,0x00,
+0x01,0x2b,0x00,0x00,0x02,0x8b,0x06,0x00,0x01,0x2c,0x00,0x00,0x02,0x8c,0x06,0x00,
+0x01,0x2d,0x00,0x00,0x02,0x42,0x07,0x00,0x01,0x2e,0x00,0x00,0x02,0x43,0x07,0x00,
+0x01,0x2f,0x00,0x00,0x02,0x44,0x07,0x00,0x01,0x30,0x00,0x00,0x02,0x45,0x07,0x00,
+0x01,0x31,0x00,0x00,0x02,0x80,0x07,0x00,0x01,0x32,0x00,0x00,0x02,0x81,0x07,0x00,
+0x01,0x33,0x00,0x00,0x02,0x82,0x07,0x00,0x01,0x34,0x00,0x00,0x02,0x83,0x07,0x00,
+0x01,0x35,0x00,0x00,0x02,0x84,0x07,0x00,0x01,0x36,0x00,0x00,0x02,0x85,0x07,0x00,
+0x01,0x37,0x00,0x00,0x02,0x88,0x07,0x00,0x01,0x38,0x00,0x00,0x02,0x89,0x07,0x00,
+0x01,0x39,0x00,0x00,0x02,0x8a,0x07,0x00,0x01,0x3a,0x00,0x00,0x02,0x8b,0x07,0x00,
+0x01,0x3b,0x00,0x00,0x02,0x8c,0x07,0x00,0x01,0x3c,0x00,0x00,0x02,0x8d,0x07,0x00,
+0x01,0x3d,0x00,0x00,0x02,0x90,0x07,0x00,0x01,0x3e,0x00,0x00,0x02,0x91,0x07,0x00,
+0x01,0x3f,0x00,0x00,0x02,0x92,0x07,0x00,0x01,0x40,0x00,0x00,0x02,0x93,0x07,0x00,
+0x01,0x41,0x00,0x00,0x02,0x94,0x07,0x00,0x01,0x42,0x00,0x00,0x02,0x95,0x07,0x00,
+0x01,0x43,0x00,0x00,0x02,0x98,0x07,0x00,0x01,0x44,0x00,0x00,0x02,0x99,0x07,0x00,
+0x01,0x45,0x00,0x00,0x02,0x9a,0x07,0x00,0x01,0x46,0x00,0x00,0x02,0x9b,0x07,0x00,
+0x01,0x47,0x00,0x00,0x02,0x9c,0x07,0x00,0x01,0x48,0x00,0x00,0x02,0x9d,0x07,0x00,
+0x01,0x49,0x00,0x00,0x02,0xa0,0x07,0x00,0x01,0x4a,0x00,0x00,0x02,0xa1,0x07,0x00,
+0x01,0x4b,0x00,0x00,0x02,0xa2,0x07,0x00,0x01,0x4c,0x00,0x00,0x02,0xa3,0x07,0x00,
+0x01,0x4d,0x00,0x00,0x02,0xa4,0x07,0x00,0x01,0x4e,0x00,0x00,0x02,0xa5,0x07,0x00,
+0x01,0x4f,0x00,0x00,0x02,0xa8,0x07,0x00,0x01,0x50,0x00,0x00,0x02,0xa9,0x07,0x00,
+0x01,0x51,0x00,0x00,0x02,0xaa,0x03,0x00,0x01,0x52,0x00,0x00,0x02,0xab,0x03,0x00,
+0x01,0x53,0x00,0x00,0x02,0xac,0x03,0x00,0x01,0x54,0x00,0x00,0x02,0xad,0x03,0x00,
+0x01,0x55,0x00,0x00,0x02,0xb0,0x03,0x00,0x01,0x56,0x00,0x00,0x02,0xb1,0x03,0x00,
+0x01,0x57,0x00,0x00,0x02,0xb2,0x03,0x00,0x01,0x58,0x00,0x00,0x02,0xb3,0x03,0x00,
+0x01,0x59,0x00,0x00,0x02,0xb4,0x03,0x00,0x01,0x5a,0x00,0x00,0x02,0xb5,0x03,0x00,
+0x01,0x5b,0x00,0x00,0x02,0xb8,0x03,0x00,0x01,0x5c,0x00,0x00,0x02,0xb9,0x03,0x00,
+0x01,0x5d,0x00,0x00,0x02,0xba,0x03,0x00,0x01,0x5e,0x00,0x00,0x02,0xbb,0x03,0x00,
+0x01,0x5f,0x00,0x00,0x02,0xbb,0x03,0x00,0x03,0x80,0x00,0x00,0x05,0x04,0x00,0x00,
+0x00,0xb7,0x00,0x00,0xfe,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,
+0x02,0x4d,0x0c,0x00,0xfe,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x02,0x4d,0x04,0x00,
+0x00,0xbf,0x02,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x0a,0x00,0x00,0x00,
+0x4f,0x6e,0x41,0x73,0x73,0x6f,0x63,0x52,0x65,0x71,0x00,0x00,0x4f,0x6e,0x41,0x73,
+0x73,0x6f,0x63,0x52,0x73,0x70,0x00,0x00,0x4f,0x6e,0x52,0x65,0x41,0x73,0x73,0x6f,
+0x63,0x52,0x65,0x71,0x00,0x00,0x00,0x00,0x4f,0x6e,0x52,0x65,0x41,0x73,0x73,0x6f,
+0x63,0x52,0x73,0x70,0x00,0x00,0x00,0x00,0x4f,0x6e,0x50,0x72,0x6f,0x62,0x65,0x52,
+0x65,0x71,0x00,0x00,0x4f,0x6e,0x50,0x72,0x6f,0x62,0x65,0x52,0x73,0x70,0x00,0x00,
+0x44,0x6f,0x52,0x65,0x73,0x65,0x72,0x76,0x65,0x64,0x00,0x00,0x44,0x6f,0x52,0x65,
+0x73,0x65,0x72,0x76,0x65,0x64,0x00,0x00,0x4f,0x6e,0x42,0x65,0x61,0x63,0x6f,0x6e,
+0x00,0x00,0x00,0x00,0x4f,0x6e,0x41,0x54,0x49,0x4d,0x00,0x00,0x4f,0x6e,0x44,0x69,
+0x73,0x61,0x73,0x73,0x6f,0x63,0x00,0x00,0x4f,0x6e,0x41,0x75,0x74,0x68,0x00,0x00,
+0x4f,0x6e,0x44,0x65,0x41,0x75,0x74,0x68,0x00,0x00,0x00,0x00,0x4f,0x6e,0x41,0x63,
+0x74,0x69,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x8b,0x01,0x80,
+0x28,0x14,0x01,0x80,0x10,0x00,0x00,0x00,0x94,0x8b,0x01,0x80,0x30,0x14,0x01,0x80,
+0x20,0x00,0x00,0x00,0xa0,0x8b,0x01,0x80,0x28,0x14,0x01,0x80,0x30,0x00,0x00,0x00,
+0xb0,0x8b,0x01,0x80,0x30,0x14,0x01,0x80,0x40,0x00,0x00,0x00,0xc0,0x8b,0x01,0x80,
+0x38,0x14,0x01,0x80,0x50,0x00,0x00,0x00,0xcc,0x8b,0x01,0x80,0x40,0x14,0x01,0x80,
+0x00,0x00,0x00,0x00,0xd8,0x8b,0x01,0x80,0xa8,0x14,0x01,0x80,0x00,0x00,0x00,0x00,
+0xe4,0x8b,0x01,0x80,0xa8,0x14,0x01,0x80,0x80,0x00,0x00,0x00,0xf0,0x8b,0x01,0x80,
+0x48,0x14,0x01,0x80,0x90,0x00,0x00,0x00,0xfc,0x8b,0x01,0x80,0x50,0x14,0x01,0x80,
+0xa0,0x00,0x00,0x00,0x04,0x8c,0x01,0x80,0x58,0x14,0x01,0x80,0xb0,0x00,0x00,0x00,
+0x10,0x8c,0x01,0x80,0x90,0x14,0x01,0x80,0xc0,0x00,0x00,0x00,0x18,0x8c,0x01,0x80,
+0x98,0x14,0x01,0x80,0xd0,0x00,0x00,0x00,0x24,0x8c,0x01,0x80,0xa0,0x14,0x01,0x80,
+0x00,0x00,0x00,0x00,0xdc,0x8c,0x01,0x80,0xdc,0x8c,0x01,0x80,0x31,0x10,0x10,0x00,
+0x00,0x30,0x00,0x00,0x31,0x20,0x10,0x00,0x00,0x30,0x00,0x00,0x31,0x28,0x10,0x00,
+0x00,0x30,0x00,0x00,0x31,0x2c,0x10,0x10,0x00,0x30,0x00,0x00,0x31,0x2f,0x10,0x10,
+0x00,0x30,0x00,0x00,0x31,0x30,0x18,0x00,0x00,0x30,0x00,0x00,0x31,0x30,0x20,0x10,
+0x00,0x30,0x00,0x00,0x22,0x20,0x18,0x08,0x00,0x20,0x00,0x00,0x22,0x21,0x14,0x08,
+0x00,0x20,0x00,0x00,0x22,0x21,0x1c,0x08,0x00,0x20,0x00,0x00,0x22,0x21,0x20,0x08,
+0x00,0x20,0x00,0x00,0x22,0x21,0x20,0x10,0x00,0x20,0x00,0x00,0x22,0x21,0x20,0x18,
+0x00,0x20,0x00,0x00,0x1a,0x19,0x18,0x10,0x00,0x18,0x00,0x00,0x12,0x11,0x10,0x08,
+0x00,0x10,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x08,0x00,0x00,0x0a,0x09,0x08,0x02,
+0x00,0x08,0x00,0x00,0x0a,0x09,0x08,0x04,0x00,0x08,0x00,0x00,0x0a,0x09,0x08,0x06,
+0x00,0x08,0x00,0x00,0x08,0x07,0x06,0x04,0x00,0x06,0x00,0x00,0x06,0x05,0x04,0x02,
+0x00,0x04,0x00,0x00,0x06,0x05,0x04,0x03,0x00,0x04,0x00,0x00,0x05,0x04,0x03,0x02,
+0x00,0x03,0x00,0x00,0x09,0x08,0x07,0x06,0x07,0x06,0x06,0x05,0x05,0x04,0x04,0x03,
+0x06,0x05,0x05,0x04,0x04,0x03,0x03,0x03,0x05,0x04,0x04,0x03,0x03,0x02,0x02,0x02,
+0x00,0x09,0x08,0x07,0x06,0x07,0x06,0x06,0x05,0x05,0x04,0x04,0x03,0x05,0x04,0x04,
+0x03,0x03,0x02,0x02,0x02,0x04,0x03,0x03,0x02,0x02,0x01,0x01,0x01,0x00,0x00,0x00,
+0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x08,0x08,0x08,0x08,
+0x20,0x20,0x20,0x20,0x08,0x08,0x08,0x08,0x08,0x20,0x20,0x20,0x30,0x08,0x08,0x08,
+0x08,0x18,0x18,0x18,0x18,0x18,0x20,0x30,0x30,0x10,0x20,0x20,0x20,0x20,0x20,0x30,
+0x30,0x08,0x10,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x08,0x08,0x08,0x08,
+0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x08,0x08,0x08,0x08,0x08,0x20,0x20,0x20,
+0x08,0x08,0x08,0x08,0x08,0x20,0x20,0x20,0x20,0x08,0x08,0x08,0x08,0x18,0x18,0x18,
+0x18,0x18,0x20,0x30,0x30,0x10,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x08,0x10,0x20,
+0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,
+0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x00,
+0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,
+0x0a,0x09,0x08,0x00,0x00,0x12,0x11,0x10,0x08,0x00,0x12,0x11,0x10,0x08,0x00,0x22,
+0x21,0x20,0x18,0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,
+0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x22,0x21,0x20,0x18,0x00,0x22,0x21,0x20,
+0x18,0x00,0x22,0x21,0x1c,0x08,0x00,0x22,0x20,0x18,0x08,0x00,0x0a,0x09,0x08,0x02,
+0x00,0x0a,0x09,0x08,0x02,0x00,0x0a,0x09,0x08,0x02,0x00,0x0a,0x09,0x08,0x02,0x00,
+0x0a,0x09,0x08,0x00,0x00,0x22,0x21,0x20,0x10,0x00,0x22,0x21,0x20,0x08,0x00,0x22,
+0x21,0x1c,0x08,0x00,0x31,0x30,0x18,0x00,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,
+0x08,0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x1a,0x19,0x18,
+0x10,0x00,0x1a,0x19,0x18,0x10,0x00,0x1a,0x19,0x18,0x10,0x00,0x1a,0x19,0x18,0x10,
+0x00,0x1a,0x19,0x18,0x10,0x00,0x22,0x21,0x20,0x08,0x00,0x31,0x2c,0x10,0x10,0x00,
+0x31,0x28,0x10,0x00,0x00,0x12,0x11,0x10,0x08,0x00,0x22,0x21,0x20,0x18,0x00,0x22,
+0x21,0x20,0x18,0x00,0x22,0x21,0x20,0x08,0x00,0x22,0x21,0x14,0x08,0x00,0x22,0x20,
+0x18,0x08,0x00,0x31,0x30,0x20,0x10,0x00,0x31,0x2c,0x10,0x10,0x00,0x0a,0x09,0x08,
+0x00,0x00,0x12,0x11,0x10,0x08,0x00,0x22,0x21,0x20,0x18,0x00,0x22,0x21,0x20,0x18,
+0x00,0x31,0x30,0x20,0x10,0x00,0x31,0x2f,0x10,0x10,0x00,0x31,0x2f,0x10,0x10,0x00,
+0x31,0x10,0x10,0x00,0x00,0x31,0x2c,0x10,0x10,0x00,0x00,0x00,0x0a,0x09,0x08,0x04,
+0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x04,0x00,
+0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,
+0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,0x00,0x12,0x11,0x10,0x08,0x00,0x12,0x11,
+0x10,0x08,0x00,0x22,0x21,0x20,0x18,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,
+0x04,0x00,0x0a,0x09,0x08,0x02,0x00,0x0a,0x09,0x08,0x00,0x00,0x0a,0x09,0x08,0x00,
+0x00,0x22,0x21,0x20,0x18,0x00,0x22,0x21,0x1c,0x08,0x00,0x22,0x21,0x14,0x08,0x00,
+0x0a,0x09,0x08,0x02,0x00,0x0a,0x09,0x08,0x02,0x00,0x0a,0x09,0x08,0x02,0x00,0x0a,
+0x09,0x08,0x02,0x00,0x0a,0x09,0x08,0x00,0x00,0x22,0x21,0x20,0x10,0x00,0x22,0x21,
+0x20,0x08,0x00,0x22,0x21,0x14,0x08,0x00,0x22,0x21,0x14,0x08,0x00,0x0a,0x09,0x08,
+0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x04,0x00,0x0a,0x09,0x08,0x04,
+0x00,0x1a,0x19,0x18,0x10,0x00,0x1a,0x19,0x18,0x10,0x00,0x1a,0x19,0x18,0x10,0x00,
+0x1a,0x19,0x18,0x10,0x00,0x1a,0x19,0x18,0x10,0x00,0x22,0x21,0x20,0x08,0x00,0x31,
+0x2c,0x10,0x10,0x00,0x31,0x28,0x10,0x00,0x00,0x12,0x11,0x10,0x08,0x00,0x22,0x21,
+0x20,0x18,0x00,0x22,0x21,0x20,0x18,0x00,0x22,0x21,0x20,0x08,0x00,0x22,0x21,0x14,
+0x08,0x00,0x22,0x20,0x18,0x08,0x00,0x31,0x30,0x20,0x10,0x00,0x31,0x2c,0x10,0x10,
+0x00,0x0a,0x09,0x08,0x00,0x00,0x12,0x11,0x10,0x08,0x00,0x22,0x21,0x20,0x18,0x00,
+0x22,0x21,0x20,0x18,0x00,0x31,0x30,0x20,0x10,0x00,0x31,0x2f,0x10,0x10,0x00,0x31,
+0x2f,0x10,0x10,0x00,0x31,0x10,0x10,0x00,0x00,0x31,0x2c,0x10,0x10,0x00,0x00,0x00,
+0x01,0x02,0x04,0x08,0x02,0x04,0x08,0x0c,0x10,0x18,0x20,0x30,0x02,0x04,0x08,0x0c,
+0x10,0x18,0x20,0x30,0x06,0x0c,0x10,0x18,0x24,0x30,0x3c,0x48,0x48,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x27,0x2c,0x19,0x1b,0x1e,0x20,
+0x23,0x29,0x2a,0x2b,0x00,0x00,0x00,0x00,0x25,0x29,0x2b,0x2e,0x2e,0x00,0x00,0x00,
+0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
+0x18,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48,0x00,0x00,0x00,
+0x60,0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0xd8,0x00,0x00,0x00,
+0x50,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,
+0x40,0x01,0x00,0x00,0x90,0x01,0x00,0x00,0xe0,0x01,0x00,0x00,0x30,0x02,0x00,0x00,
+0x2c,0x01,0x00,0x00,0x40,0x01,0x00,0x00,0xe0,0x01,0x00,0x00,0xd0,0x02,0x00,0x00,
+0x80,0x0c,0x00,0x00,0x80,0x0c,0x00,0x00,0x80,0x0c,0x00,0x00,0xa0,0x0f,0x00,0x00,
+0xa0,0x0f,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+0x08,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x18,0x00,0x00,0x00,
+0x24,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x60,0x00,0x00,0x00,
+0x6c,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x50,0x00,0x00,0x00,
+0x64,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+0x18,0x01,0x00,0x00,0x64,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
+0x68,0x01,0x00,0x00,0x40,0x06,0x00,0x00,0x40,0x06,0x00,0x00,0x40,0x06,0x00,0x00,
+0xd0,0x07,0x00,0x00,0xd0,0x07,0x00,0x00,0x2c,0x05,0x00,0x80,0x20,0x05,0x00,0x80,
+0x14,0x05,0x00,0x80,0x08,0x05,0x00,0x80,0xfc,0x04,0x00,0x80,0xf0,0x04,0x00,0x80,
+0xe4,0x04,0x00,0x80,0xd8,0x04,0x00,0x80,0xcc,0x04,0x00,0x80,0xc0,0x04,0x00,0x80,
+0x78,0x04,0x00,0x80,0x68,0x15,0x02,0x80,0xc0,0x3a,0x00,0x80,0xcc,0x3a,0x00,0x80,
+0xd8,0x3a,0x00,0x80,0xe4,0x3a,0x00,0x80,0xc0,0x3a,0x00,0x80,0xc0,0x3a,0x00,0x80,
+0xc0,0x3a,0x00,0x80,0xc0,0x3a,0x00,0x80,0xf0,0x3a,0x00,0x80,0xfc,0x3a,0x00,0x80,
+0x08,0x3b,0x00,0x80,0x14,0x3b,0x00,0x80,0x68,0x15,0x02,0x80,0xfe,0x01,0x80,0x7f,
+0xe2,0x01,0x80,0x78,0xc7,0x01,0xc0,0x71,0xae,0x01,0x80,0x6b,0x95,0x01,0x40,0x65,
+0x7f,0x01,0xc0,0x5f,0x69,0x01,0x40,0x5a,0x55,0x01,0x40,0x55,0x42,0x01,0x80,0x50,
+0x30,0x01,0x00,0x4c,0x1f,0x01,0xc0,0x47,0x0f,0x01,0xc0,0x43,0x00,0x01,0x00,0x40,
+0xf2,0x00,0x80,0x3c,0xe4,0x00,0x00,0x39,0xd7,0x00,0xc0,0x35,0xcb,0x00,0xc0,0x32,
+0xc0,0x00,0x00,0x30,0xb5,0x00,0x40,0x2d,0xab,0x00,0xc0,0x2a,0xa2,0x00,0x80,0x28,
+0x98,0x00,0x00,0x26,0x90,0x00,0x00,0x24,0x88,0x00,0x00,0x22,0x80,0x00,0x00,0x20,
+0x79,0x00,0x40,0x1e,0x72,0x00,0x80,0x1c,0x6c,0x00,0x00,0x1b,0x66,0x00,0x80,0x19,
+0x60,0x00,0x00,0x18,0x5b,0x00,0xc0,0x16,0x56,0x00,0x80,0x15,0x51,0x00,0x40,0x14,
+0x4c,0x00,0x00,0x13,0x48,0x00,0x00,0x12,0x44,0x00,0x00,0x11,0x40,0x00,0x00,0x10,
+0x36,0x35,0x2e,0x25,0x1c,0x12,0x09,0x04,0x33,0x32,0x2b,0x23,0x1a,0x11,0x08,0x04,
+0x30,0x2f,0x29,0x21,0x19,0x10,0x08,0x03,0x2d,0x2d,0x27,0x1f,0x18,0x0f,0x08,0x03,
+0x2b,0x2a,0x25,0x1e,0x16,0x0e,0x07,0x03,0x28,0x28,0x22,0x1c,0x15,0x0d,0x07,0x03,
+0x26,0x25,0x21,0x1b,0x14,0x0d,0x06,0x03,0x24,0x23,0x1f,0x19,0x13,0x0c,0x06,0x03,
+0x22,0x21,0x1d,0x18,0x11,0x0b,0x06,0x02,0x20,0x20,0x1b,0x16,0x11,0x08,0x05,0x02,
+0x1f,0x1e,0x1a,0x15,0x10,0x0a,0x05,0x02,0x1d,0x1c,0x18,0x14,0x0f,0x0a,0x05,0x02,
+0x1b,0x1a,0x17,0x13,0x0e,0x09,0x04,0x02,0x1a,0x19,0x16,0x12,0x0d,0x09,0x04,0x02,
+0x18,0x17,0x15,0x11,0x0c,0x08,0x04,0x02,0x17,0x16,0x13,0x10,0x0c,0x08,0x04,0x02,
+0x16,0x15,0x12,0x0f,0x0b,0x07,0x04,0x01,0x14,0x14,0x11,0x0e,0x0b,0x07,0x03,0x02,
+0x13,0x13,0x10,0x0d,0x0a,0x06,0x03,0x01,0x12,0x12,0x0f,0x0c,0x09,0x06,0x03,0x01,
+0x11,0x11,0x0f,0x0c,0x09,0x06,0x03,0x01,0x10,0x10,0x0e,0x0b,0x08,0x05,0x03,0x01,
+0x0f,0x0f,0x0d,0x0b,0x08,0x05,0x03,0x01,0x0e,0x0e,0x0c,0x0a,0x08,0x05,0x02,0x01,
+0x0d,0x0d,0x0c,0x0a,0x07,0x05,0x02,0x01,0x0d,0x0c,0x0b,0x09,0x07,0x04,0x02,0x01,
+0x0c,0x0c,0x0a,0x09,0x06,0x04,0x02,0x01,0x0b,0x0b,0x0a,0x08,0x06,0x04,0x02,0x01,
+0x0b,0x0a,0x09,0x08,0x06,0x04,0x02,0x01,0x0a,0x0a,0x09,0x07,0x05,0x03,0x02,0x01,
+0x0a,0x09,0x08,0x07,0x05,0x03,0x02,0x01,0x09,0x09,0x08,0x06,0x05,0x03,0x01,0x01,
+0x09,0x08,0x07,0x06,0x04,0x03,0x01,0x01,0x36,0x35,0x2e,0x1b,0x00,0x00,0x00,0x00,
+0x33,0x32,0x2b,0x19,0x00,0x00,0x00,0x00,0x30,0x2f,0x29,0x18,0x00,0x00,0x00,0x00,
+0x2d,0x2d,0x17,0x17,0x00,0x00,0x00,0x00,0x2b,0x2a,0x25,0x15,0x00,0x00,0x00,0x00,
+0x28,0x28,0x24,0x14,0x00,0x00,0x00,0x00,0x26,0x25,0x21,0x13,0x00,0x00,0x00,0x00,
+0x24,0x23,0x1f,0x12,0x00,0x00,0x00,0x00,0x22,0x21,0x1d,0x11,0x00,0x00,0x00,0x00,
+0x20,0x20,0x1b,0x10,0x00,0x00,0x00,0x00,0x1f,0x1e,0x1a,0x0f,0x00,0x00,0x00,0x00,
+0x1d,0x1c,0x18,0x0e,0x00,0x00,0x00,0x00,0x1b,0x1a,0x17,0x0e,0x00,0x00,0x00,0x00,
+0x1a,0x19,0x16,0x0d,0x00,0x00,0x00,0x00,0x18,0x17,0x15,0x0c,0x00,0x00,0x00,0x00,
+0x17,0x16,0x13,0x0b,0x00,0x00,0x00,0x00,0x16,0x15,0x12,0x0b,0x00,0x00,0x00,0x00,
+0x14,0x14,0x11,0x0a,0x00,0x00,0x00,0x00,0x13,0x13,0x10,0x0a,0x00,0x00,0x00,0x00,
+0x12,0x12,0x0f,0x09,0x00,0x00,0x00,0x00,0x11,0x11,0x0f,0x09,0x00,0x00,0x00,0x00,
+0x10,0x10,0x0e,0x08,0x00,0x00,0x00,0x00,0x0f,0x0f,0x0d,0x08,0x00,0x00,0x00,0x00,
+0x0e,0x0e,0x0c,0x07,0x00,0x00,0x00,0x00,0x0d,0x0d,0x0c,0x07,0x00,0x00,0x00,0x00,
+0x0d,0x0c,0x0b,0x06,0x00,0x00,0x00,0x00,0x0c,0x0c,0x0a,0x06,0x00,0x00,0x00,0x00,
+0x0b,0x0b,0x0a,0x06,0x00,0x00,0x00,0x00,0x0b,0x0a,0x09,0x05,0x00,0x00,0x00,0x00,
+0x0a,0x0a,0x09,0x05,0x00,0x00,0x00,0x00,0x0a,0x09,0x08,0x05,0x00,0x00,0x00,0x00,
+0x09,0x09,0x08,0x05,0x00,0x00,0x00,0x00,0x09,0x08,0x07,0x04,0x00,0x00,0x00,0x00,
+0x06,0x00,0x2a,0xb0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+0x08,0x28,0x28,0x28,0x28,0x28,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xa0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+0x04,0x04,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x41,0x41,0x41,0x41,0x41,0x41,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x10,0x10,0x10,0x10,0x10,0x10,0x42,0x42,0x42,0x42,0x42,0x42,0x02,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+0x02,0x02,0x02,0x10,0x10,0x10,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x19,0x77,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x26,0x72,0xb0,0x00,0x26,0x72,0xb0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x26,0x65,0x60,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x02,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xf2,0x30,0xb8,0xff,0xff,0xff,0xff,
+};
+
+u8 Rtl8192SUFwMainArray[MainArrayLength] = {
+0x0, };
+
+u8 Rtl8192SUFwDataArray[DataArrayLength] = {
+0x0, };
+
+u32 Rtl8192SUPHY_REG_2T2RArray[PHY_REG_2T2RArrayLength] = {
+0x01c,0x07000000,
+0x800,0x00040000,
+0x804,0x00008003,
+0x808,0x0000fc00,
+0x80c,0x0000000a,
+0x810,0x10005088,
+0x814,0x020c3d10,
+0x818,0x00200185,
+0x81c,0x00000000,
+0x820,0x01000000,
+0x824,0x00390004,
+0x828,0x01000000,
+0x82c,0x00390004,
+0x830,0x00000004,
+0x834,0x00690200,
+0x838,0x00000004,
+0x83c,0x00690200,
+0x840,0x00010000,
+0x844,0x00010000,
+0x848,0x00000000,
+0x84c,0x00000000,
+0x850,0x00000000,
+0x854,0x00000000,
+0x858,0x48484848,
+0x85c,0x65a965a9,
+0x860,0x0f7f0130,
+0x864,0x0f7f0130,
+0x868,0x0f7f0130,
+0x86c,0x0f7f0130,
+0x870,0x03000700,
+0x874,0x03000300,
+0x878,0x00020002,
+0x87c,0x004f0201,
+0x880,0xa8300ac1,
+0x884,0x00000058,
+0x888,0x00000008,
+0x88c,0x00000004,
+0x890,0x00000000,
+0x894,0xfffffffe,
+0x898,0x40302010,
+0x89c,0x00706050,
+0x8b0,0x00000000,
+0x8e0,0x00000000,
+0x8e4,0x00000000,
+0xe00,0x30333333,
+0xe04,0x2a2d2e2f,
+0xe08,0x00003232,
+0xe10,0x30333333,
+0xe14,0x2a2d2e2f,
+0xe18,0x30333333,
+0xe1c,0x2a2d2e2f,
+0xe30,0x01007c00,
+0xe34,0x01004800,
+0xe38,0x1000dc1f,
+0xe3c,0x10008c1f,
+0xe40,0x021400a0,
+0xe44,0x281600a0,
+0xe48,0xf8000001,
+0xe4c,0x00002910,
+0xe50,0x01007c00,
+0xe54,0x01004800,
+0xe58,0x1000dc1f,
+0xe5c,0x10008c1f,
+0xe60,0x021400a0,
+0xe64,0x281600a0,
+0xe6c,0x00002910,
+0xe70,0x31ed92fb,
+0xe74,0x361536fb,
+0xe78,0x361536fb,
+0xe7c,0x361536fb,
+0xe80,0x361536fb,
+0xe84,0x000d92fb,
+0xe88,0x000d92fb,
+0xe8c,0x31ed92fb,
+0xed0,0x31ed92fb,
+0xed4,0x31ed92fb,
+0xed8,0x000d92fb,
+0xedc,0x000d92fb,
+0xee0,0x000d92fb,
+0xee4,0x015e5448,
+0xee8,0x21555448,
+0x900,0x00000000,
+0x904,0x00000023,
+0x908,0x00000000,
+0x90c,0x03321333,
+0xa00,0x00d047c8,
+0xa04,0x80ff0008,
+0xa08,0x8ccd8300,
+0xa0c,0x2e62120f,
+0xa10,0x9500bb78,
+0xa14,0x11144028,
+0xa18,0x00881117,
+0xa1c,0x89140f00,
+0xa20,0x1a1b0000,
+0xa24,0x090e1317,
+0xa28,0x00000204,
+0xa2c,0x10d30000,
+0xc00,0x40071d40,
+0xc04,0x00a05633,
+0xc08,0x000000e4,
+0xc0c,0x6c6c6c6c,
+0xc10,0x08800000,
+0xc14,0x40000100,
+0xc18,0x08000000,
+0xc1c,0x40000100,
+0xc20,0x08000000,
+0xc24,0x40000100,
+0xc28,0x08000000,
+0xc2c,0x40000100,
+0xc30,0x6de9ac44,
+0xc34,0x469652cf,
+0xc38,0x49795994,
+0xc3c,0x0a979764,
+0xc40,0x1f7c403f,
+0xc44,0x000100b7,
+0xc48,0xec020000,
+0xc4c,0x007f037f,
+0xc50,0x69543420,
+0xc54,0x433c0094,
+0xc58,0x69543420,
+0xc5c,0x433c0094,
+0xc60,0x69543420,
+0xc64,0x433c0094,
+0xc68,0x69543420,
+0xc6c,0x433c0094,
+0xc70,0x2c7f000d,
+0xc74,0x0186155b,
+0xc78,0x0000001f,
+0xc7c,0x00b91612,
+0xc80,0x40000100,
+0xc84,0x20f60000,
+0xc88,0x20000080,
+0xc8c,0x20200000,
+0xc90,0x40000100,
+0xc94,0x00000000,
+0xc98,0x40000100,
+0xc9c,0x00000000,
+0xca0,0x00492492,
+0xca4,0x00000000,
+0xca8,0x00000000,
+0xcac,0x00000000,
+0xcb0,0x00000000,
+0xcb4,0x00000000,
+0xcb8,0x00000000,
+0xcbc,0x28000000,
+0xcc0,0x00000000,
+0xcc4,0x00000000,
+0xcc8,0x00000000,
+0xccc,0x00000000,
+0xcd0,0x00000000,
+0xcd4,0x00000000,
+0xcd8,0x64b22427,
+0xcdc,0x00766932,
+0xce0,0x00222222,
+0xce4,0x00000000,
+0xce8,0x37644302,
+0xcec,0x2f97d40c,
+0xd00,0x00000750,
+0xd04,0x00000403,
+0xd08,0x0000907f,
+0xd0c,0x00000001,
+0xd10,0xa0633333,
+0xd14,0x33333c63,
+0xd18,0x6a8f5b6b,
+0xd1c,0x00000000,
+0xd20,0x00000000,
+0xd24,0x00000000,
+0xd28,0x00000000,
+0xd2c,0xcc979975,
+0xd30,0x00000000,
+0xd34,0x00000000,
+0xd38,0x00000000,
+0xd3c,0x00027293,
+0xd40,0x00000000,
+0xd44,0x00000000,
+0xd48,0x00000000,
+0xd50,0x6437140a,
+0xd54,0x024dbd02,
+0xd58,0x00000000,
+0xd5c,0x30032064,
+0xd60,0x4653de68,
+0xd64,0x00518a3c,
+0xd68,0x00002101,
+0xf14,0x00000003,
+0xf4c,0x00000000,
+0xf00,0x00000300,
+};
+
+u32 Rtl8192SUPHY_REG_1T2RArray[PHY_REG_1T2RArrayLength] = {
+0x0, };
+
+u32 Rtl8192SUPHY_ChangeTo_1T1RArray[PHY_ChangeTo_1T1RArrayLength] = {
+0x844,0xffffffff,0x00010000,
+0x804,0x0000000f,0x00000001,
+0x824,0x00f0000f,0x00300004,
+0x82c,0x00f0000f,0x00100002,
+0x870,0x04000000,0x00000001,
+0x864,0x00000400,0x00000000,
+0x878,0x000f000f,0x00000002,
+0xe74,0x0f000000,0x00000002,
+0xe78,0x0f000000,0x00000002,
+0xe7c,0x0f000000,0x00000002,
+0xe80,0x0f000000,0x00000002,
+0x90c,0x000000ff,0x00000011,
+0xc04,0x000000ff,0x00000011,
+0xd04,0x0000000f,0x00000001,
+0x1f4,0xffff0000,0x00007777,
+0x234,0xf8000000,0x0000000a,
+};
+
+u32 Rtl8192SUPHY_ChangeTo_1T2RArray[PHY_ChangeTo_1T2RArrayLength] = {
+0x804,0x0000000f,0x00000003,
+0x824,0x00f0000f,0x00300004,
+0x82c,0x00f0000f,0x00300002,
+0x870,0x04000000,0x00000001,
+0x864,0x00000400,0x00000000,
+0x878,0x000f000f,0x00000002,
+0xe74,0x0f000000,0x00000002,
+0xe78,0x0f000000,0x00000002,
+0xe7c,0x0f000000,0x00000002,
+0xe80,0x0f000000,0x00000002,
+0x90c,0x000000ff,0x00000011,
+0xc04,0x000000ff,0x00000033,
+0xd04,0x0000000f,0x00000003,
+0x1f4,0xffff0000,0x00007777,
+0x234,0xf8000000,0x0000000a,
+};
+
+u32 Rtl8192SUPHY_ChangeTo_2T2RArray[PHY_ChangeTo_2T2RArrayLength] = {
+0x804,0x0000000f,0x00000003,
+0x824,0x00f0000f,0x00300004,
+0x82c,0x00f0000f,0x00300004,
+0x870,0x04000000,0x00000001,
+0x864,0x00000400,0x00000001,
+0x878,0x000f000f,0x00020002,
+0xe74,0x0f000000,0x00000006,
+0xe78,0x0f000000,0x00000006,
+0xe7c,0x0f000000,0x00000006,
+0xe80,0x0f000000,0x00000006,
+0x90c,0x000000ff,0x00000033,
+0xc04,0x000000ff,0x00000033,
+0xd04,0x0000000f,0x00000003,
+0x1f4,0xffff0000,0x0000ffff,
+0x234,0xf8000000,0x00000013,
+};
+
+u32 Rtl8192SUPHY_REG_Array_PG[PHY_REG_Array_PGLength] = {
+0xe00,0xffffffff,0x06090909,
+0xe04,0xffffffff,0x00030406,
+0xe08,0x0000ff00,0x00000000,
+0xe10,0xffffffff,0x0a0c0d0e,
+0xe14,0xffffffff,0x04070809,
+0xe18,0xffffffff,0x0a0c0d0e,
+0xe1c,0xffffffff,0x04070809,
+};
+
+u32 Rtl8192SURadioA_1T_Array[RadioA_1T_ArrayLength] = {
+0x000,0x00030159,
+0x001,0x00030250,
+0x002,0x00010000,
+0x010,0x0008000f,
+0x011,0x000231fc,
+0x010,0x000c000f,
+0x011,0x0003f9f8,
+0x010,0x0002000f,
+0x011,0x00020101,
+0x014,0x0001093e,
+0x014,0x0009093e,
+0x015,0x000198f4,
+0x017,0x000f6500,
+0x01a,0x00013056,
+0x01b,0x00060000,
+0x01c,0x00000300,
+0x01e,0x00031059,
+0x021,0x00054000,
+0x022,0x0000083c,
+0x023,0x00001558,
+0x024,0x00000060,
+0x025,0x00022583,
+0x026,0x0000f200,
+0x027,0x000eacf1,
+0x028,0x0009bd54,
+0x029,0x00004582,
+0x02a,0x00000001,
+0x02b,0x00021334,
+0x02a,0x00000000,
+0x02b,0x0000000a,
+0x02a,0x00000001,
+0x02b,0x00000808,
+0x02b,0x00053333,
+0x02c,0x0000000c,
+0x02a,0x00000002,
+0x02b,0x00000808,
+0x02b,0x0005b333,
+0x02c,0x0000000d,
+0x02a,0x00000003,
+0x02b,0x00000808,
+0x02b,0x00063333,
+0x02c,0x0000000d,
+0x02a,0x00000004,
+0x02b,0x00000808,
+0x02b,0x0006b333,
+0x02c,0x0000000d,
+0x02a,0x00000005,
+0x02b,0x00000709,
+0x02b,0x00053333,
+0x02c,0x0000000d,
+0x02a,0x00000006,
+0x02b,0x00000709,
+0x02b,0x0005b333,
+0x02c,0x0000000d,
+0x02a,0x00000007,
+0x02b,0x00000709,
+0x02b,0x00063333,
+0x02c,0x0000000d,
+0x02a,0x00000008,
+0x02b,0x00000709,
+0x02b,0x0006b333,
+0x02c,0x0000000d,
+0x02a,0x00000009,
+0x02b,0x0000060a,
+0x02b,0x00053333,
+0x02c,0x0000000d,
+0x02a,0x0000000a,
+0x02b,0x0000060a,
+0x02b,0x0005b333,
+0x02c,0x0000000d,
+0x02a,0x0000000b,
+0x02b,0x0000060a,
+0x02b,0x00063333,
+0x02c,0x0000000d,
+0x02a,0x0000000c,
+0x02b,0x0000060a,
+0x02b,0x0006b333,
+0x02c,0x0000000d,
+0x02a,0x0000000d,
+0x02b,0x0000050b,
+0x02b,0x00053333,
+0x02c,0x0000000d,
+0x02a,0x0000000e,
+0x02b,0x0000050b,
+0x02b,0x00066623,
+0x02c,0x0000001a,
+0x02a,0x000e4000,
+0x030,0x00020000,
+0x031,0x000b9631,
+0x032,0x0000130d,
+0x033,0x00000187,
+0x013,0x00019e6c,
+0x013,0x00015e94,
+0x000,0x00010159,
+0x018,0x0000f401,
+0x0fe,0x00000000,
+0x01e,0x0003105b,
+0x0fe,0x00000000,
+0x000,0x00030159,
+0x010,0x0004000f,
+0x011,0x000203f9,
+};
+
+u32 Rtl8192SURadioB_Array[RadioB_ArrayLength] = {
+0x000,0x00030159,
+0x001,0x00001041,
+0x002,0x00011000,
+0x005,0x00080fc0,
+0x007,0x000fc803,
+0x013,0x00017cb0,
+0x013,0x00011cc0,
+0x013,0x0000dc60,
+0x013,0x00008c60,
+0x013,0x00004450,
+0x013,0x00000020,
+};
+
+u32 Rtl8192SURadioA_to1T_Array[RadioA_to1T_ArrayLength] = {
+0x000,0x00000000,
+};
+
+u32 Rtl8192SURadioA_to2T_Array[RadioA_to2T_ArrayLength] = {
+0x000,0x00000000,
+};
+
+u32 Rtl8192SURadioB_GM_Array[RadioB_GM_ArrayLength] = {
+0x000,0x00030159,
+0x001,0x00001041,
+0x002,0x00011000,
+0x005,0x00080fc0,
+0x007,0x000fc803,
+0x013,0x0000bef0,
+0x013,0x00007e90,
+0x013,0x00003e30,
+};
+
+u32 Rtl8192SUMAC_2T_Array[MAC_2T_ArrayLength] = {
+0x020,0x00000035,
+0x048,0x0000000e,
+0x049,0x000000f0,
+0x04a,0x00000077,
+0x04b,0x00000083,
+0x0b5,0x00000021,
+0x0dc,0x000000ff,
+0x0dd,0x000000ff,
+0x0de,0x000000ff,
+0x0df,0x000000ff,
+0x116,0x00000000,
+0x117,0x00000000,
+0x118,0x00000000,
+0x119,0x00000000,
+0x11a,0x00000000,
+0x11b,0x00000000,
+0x11c,0x00000000,
+0x11d,0x00000000,
+0x160,0x0000000b,
+0x161,0x0000000b,
+0x162,0x0000000b,
+0x163,0x0000000b,
+0x164,0x0000000b,
+0x165,0x0000000b,
+0x166,0x0000000b,
+0x167,0x0000000b,
+0x168,0x0000000b,
+0x169,0x0000000b,
+0x16a,0x0000000b,
+0x16b,0x0000000b,
+0x16c,0x0000000b,
+0x16d,0x0000000b,
+0x16e,0x0000000b,
+0x16f,0x0000000b,
+0x170,0x0000000b,
+0x171,0x0000000b,
+0x172,0x0000000b,
+0x173,0x0000000b,
+0x174,0x0000000b,
+0x175,0x0000000b,
+0x176,0x0000000b,
+0x177,0x0000000b,
+0x178,0x0000000b,
+0x179,0x0000000b,
+0x17a,0x0000000b,
+0x17b,0x0000000b,
+0x17c,0x0000000b,
+0x17d,0x0000000b,
+0x17e,0x0000000b,
+0x17f,0x0000000b,
+0x236,0x0000000c,
+0x503,0x00000022,
+0x560,0x00000009,
+};
+
+u32 Rtl8192SUMACPHY_Array_PG[MACPHY_Array_PGLength] = {
+0x0, };
+
+u32 Rtl8192SUAGCTAB_Array[AGCTAB_ArrayLength] = {
+0xc78,0x7f000001,
+0xc78,0x7f010001,
+0xc78,0x7e020001,
+0xc78,0x7d030001,
+0xc78,0x7c040001,
+0xc78,0x7b050001,
+0xc78,0x7a060001,
+0xc78,0x79070001,
+0xc78,0x78080001,
+0xc78,0x77090001,
+0xc78,0x760a0001,
+0xc78,0x750b0001,
+0xc78,0x740c0001,
+0xc78,0x730d0001,
+0xc78,0x720e0001,
+0xc78,0x710f0001,
+0xc78,0x70100001,
+0xc78,0x6f110001,
+0xc78,0x6f120001,
+0xc78,0x6e130001,
+0xc78,0x6d140001,
+0xc78,0x6d150001,
+0xc78,0x6c160001,
+0xc78,0x6b170001,
+0xc78,0x6a180001,
+0xc78,0x6a190001,
+0xc78,0x691a0001,
+0xc78,0x681b0001,
+0xc78,0x671c0001,
+0xc78,0x661d0001,
+0xc78,0x651e0001,
+0xc78,0x641f0001,
+0xc78,0x63200001,
+0xc78,0x4c210001,
+0xc78,0x4b220001,
+0xc78,0x4a230001,
+0xc78,0x49240001,
+0xc78,0x48250001,
+0xc78,0x47260001,
+0xc78,0x46270001,
+0xc78,0x45280001,
+0xc78,0x44290001,
+0xc78,0x2c2a0001,
+0xc78,0x2b2b0001,
+0xc78,0x2a2c0001,
+0xc78,0x292d0001,
+0xc78,0x282e0001,
+0xc78,0x272f0001,
+0xc78,0x26300001,
+0xc78,0x25310001,
+0xc78,0x24320001,
+0xc78,0x23330001,
+0xc78,0x22340001,
+0xc78,0x09350001,
+0xc78,0x08360001,
+0xc78,0x07370001,
+0xc78,0x06380001,
+0xc78,0x05390001,
+0xc78,0x043a0001,
+0xc78,0x033b0001,
+0xc78,0x023c0001,
+0xc78,0x013d0001,
+0xc78,0x003e0001,
+0xc78,0x003f0001,
+0xc78,0x7f400001,
+0xc78,0x7f410001,
+0xc78,0x7e420001,
+0xc78,0x7d430001,
+0xc78,0x7c440001,
+0xc78,0x7b450001,
+0xc78,0x7a460001,
+0xc78,0x79470001,
+0xc78,0x78480001,
+0xc78,0x77490001,
+0xc78,0x764a0001,
+0xc78,0x754b0001,
+0xc78,0x744c0001,
+0xc78,0x734d0001,
+0xc78,0x724e0001,
+0xc78,0x714f0001,
+0xc78,0x70500001,
+0xc78,0x6f510001,
+0xc78,0x6f520001,
+0xc78,0x6e530001,
+0xc78,0x6d540001,
+0xc78,0x6d550001,
+0xc78,0x6c560001,
+0xc78,0x6b570001,
+0xc78,0x6a580001,
+0xc78,0x6a590001,
+0xc78,0x695a0001,
+0xc78,0x685b0001,
+0xc78,0x675c0001,
+0xc78,0x665d0001,
+0xc78,0x655e0001,
+0xc78,0x645f0001,
+0xc78,0x63600001,
+0xc78,0x4c610001,
+0xc78,0x4b620001,
+0xc78,0x4a630001,
+0xc78,0x49640001,
+0xc78,0x48650001,
+0xc78,0x47660001,
+0xc78,0x46670001,
+0xc78,0x45680001,
+0xc78,0x44690001,
+0xc78,0x2c6a0001,
+0xc78,0x2b6b0001,
+0xc78,0x2a6c0001,
+0xc78,0x296d0001,
+0xc78,0x286e0001,
+0xc78,0x276f0001,
+0xc78,0x26700001,
+0xc78,0x25710001,
+0xc78,0x24720001,
+0xc78,0x23730001,
+0xc78,0x22740001,
+0xc78,0x09750001,
+0xc78,0x08760001,
+0xc78,0x07770001,
+0xc78,0x06780001,
+0xc78,0x05790001,
+0xc78,0x047a0001,
+0xc78,0x037b0001,
+0xc78,0x027c0001,
+0xc78,0x017d0001,
+0xc78,0x007e0001,
+0xc78,0x007f0001,
+0xc78,0x3000001e,
+0xc78,0x3001001e,
+0xc78,0x3002001e,
+0xc78,0x3003001e,
+0xc78,0x3004001e,
+0xc78,0x3405001e,
+0xc78,0x3806001e,
+0xc78,0x3e07001e,
+0xc78,0x3e08001e,
+0xc78,0x4409001e,
+0xc78,0x460a001e,
+0xc78,0x480b001e,
+0xc78,0x480c001e,
+0xc78,0x4e0d001e,
+0xc78,0x560e001e,
+0xc78,0x5a0f001e,
+0xc78,0x5e10001e,
+0xc78,0x6211001e,
+0xc78,0x6c12001e,
+0xc78,0x7213001e,
+0xc78,0x7214001e,
+0xc78,0x7215001e,
+0xc78,0x7216001e,
+0xc78,0x7217001e,
+0xc78,0x7218001e,
+0xc78,0x7219001e,
+0xc78,0x721a001e,
+0xc78,0x721b001e,
+0xc78,0x721c001e,
+0xc78,0x721d001e,
+0xc78,0x721e001e,
+0xc78,0x721f001e,
+};
+
diff --git a/drivers/staging/rtl8192su/r8192SU_HWImg.h b/drivers/staging/rtl8192su/r8192SU_HWImg.h
new file mode 100644
index 000000000000..96b15252ea86
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192SU_HWImg.h
@@ -0,0 +1,44 @@
+#ifndef __INC_HAL8192SU_FW_IMG_H
+#define __INC_HAL8192SU_FW_IMG_H
+
+#include <linux/types.h>
+
+/*Created on 2009/ 3/ 6, 5:29*/
+
+#define ImgArrayLength 68368
+extern u8 Rtl8192SUFwImgArray[ImgArrayLength];
+#define MainArrayLength 1
+extern u8 Rtl8192SUFwMainArray[MainArrayLength];
+#define DataArrayLength 1
+extern u8 Rtl8192SUFwDataArray[DataArrayLength];
+#define PHY_REG_2T2RArrayLength 372
+extern u32 Rtl8192SUPHY_REG_2T2RArray[PHY_REG_2T2RArrayLength];
+#define PHY_REG_1T2RArrayLength 1
+extern u32 Rtl8192SUPHY_REG_1T2RArray[PHY_REG_1T2RArrayLength];
+#define PHY_ChangeTo_1T1RArrayLength 48
+extern u32 Rtl8192SUPHY_ChangeTo_1T1RArray[PHY_ChangeTo_1T1RArrayLength];
+#define PHY_ChangeTo_1T2RArrayLength 45
+extern u32 Rtl8192SUPHY_ChangeTo_1T2RArray[PHY_ChangeTo_1T2RArrayLength];
+#define PHY_ChangeTo_2T2RArrayLength 45
+extern u32 Rtl8192SUPHY_ChangeTo_2T2RArray[PHY_ChangeTo_2T2RArrayLength];
+#define PHY_REG_Array_PGLength 21
+extern u32 Rtl8192SUPHY_REG_Array_PG[PHY_REG_Array_PGLength];
+#define RadioA_1T_ArrayLength 202
+extern u32 Rtl8192SURadioA_1T_Array[RadioA_1T_ArrayLength];
+#define RadioB_ArrayLength 22
+extern u32 Rtl8192SURadioB_Array[RadioB_ArrayLength];
+#define RadioA_to1T_ArrayLength 2
+extern u32 Rtl8192SURadioA_to1T_Array[RadioA_to1T_ArrayLength];
+#define RadioA_to2T_ArrayLength 2
+extern u32 Rtl8192SURadioA_to2T_Array[RadioA_to2T_ArrayLength];
+#define RadioB_GM_ArrayLength 16
+extern u32 Rtl8192SURadioB_GM_Array[RadioB_GM_ArrayLength];
+#define MAC_2T_ArrayLength 106
+extern u32 Rtl8192SUMAC_2T_Array[MAC_2T_ArrayLength];
+#define MACPHY_Array_PGLength 1
+extern u32 Rtl8192SUMACPHY_Array_PG[MACPHY_Array_PGLength];
+#define AGCTAB_ArrayLength 320
+extern u32 Rtl8192SUAGCTAB_Array[AGCTAB_ArrayLength];
+
+#endif //__INC_HAL8192SU_FW_IMG_H
+
diff --git a/drivers/staging/rtl8192su/r8192S_Efuse.c b/drivers/staging/rtl8192su/r8192S_Efuse.c
new file mode 100644
index 000000000000..394ab9674359
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_Efuse.c
@@ -0,0 +1,2442 @@
+/******************************************************************************
+ *
+ * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
+ *
+ * Module: Efuse.c ( Source C File)
+ *
+ * Note: Copy from WMAC for the first version!!!!
+ *
+ *
+ * Function:
+ *
+ * Export:
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ *
+ * 09/23/2008 MHC Porting Efuse R/W API from WMAC.
+ * 11/10/2008 MHC 1. Porting from 8712 EFUSE.
+ * 2. Add description and reorganize code arch.
+ * 11/16/2008 MHC 1. Reorganize code architecture.
+ * 2. Rename for some API and change extern or static type.
+ *
+******************************************************************************/
+#include "r8192U.h"
+#include "r8192S_hw.h"
+#include "r8192S_phy.h"
+#include "r8192S_phyreg.h"
+#include "r8192S_Efuse.h"
+
+#include <linux/types.h>
+
+//typedef int INT32;
+//
+// In the future, we will always support EFUSE!!
+//
+#ifdef RTL8192SU
+/*---------------------------Define Local Constant---------------------------*/
+#define _POWERON_DELAY_
+#define _PRE_EXECUTE_READ_CMD_
+
+#define EFUSE_REPEAT_THRESHOLD_ 3
+#define EFUSE_ERROE_HANDLE 1
+
+
+// From 8712!!!!!
+typedef struct _EFUSE_MAP_A{
+ u8 offset; //0~15
+ u8 word_start; //0~3
+ u8 byte_start; //0 or 1
+ u8 byte_cnts;
+
+}EFUSE_MAP, *PEFUSE_MAP;
+
+typedef struct PG_PKT_STRUCT_A{
+ u8 offset;
+ u8 word_en;
+ u8 data[8];
+}PGPKT_STRUCT,*PPGPKT_STRUCT;
+
+typedef enum _EFUSE_DATA_ITEM{
+ EFUSE_CHIP_ID=0,
+ EFUSE_LDO_SETTING,
+ EFUSE_CLK_SETTING,
+ EFUSE_SDIO_SETTING,
+ EFUSE_CCCR,
+ EFUSE_SDIO_MODE,
+ EFUSE_OCR,
+ EFUSE_F0CIS,
+ EFUSE_F1CIS,
+ EFUSE_MAC_ADDR,
+ EFUSE_EEPROM_VER,
+ EFUSE_CHAN_PLAN,
+ EFUSE_TXPW_TAB
+} EFUSE_DATA_ITEM;
+
+struct efuse_priv
+{
+ u8 id[2];
+ u8 ldo_setting[2];
+ u8 clk_setting[2];
+ u8 cccr;
+ u8 sdio_mode;
+ u8 ocr[3];
+ u8 cis0[17];
+ u8 cis1[48];
+ u8 mac_addr[6];
+ u8 eeprom_verno;
+ u8 channel_plan;
+ u8 tx_power_b[14];
+ u8 tx_power_g[14];
+};
+
+/*---------------------------Define Local Constant---------------------------*/
+
+
+/*------------------------Define global variable-----------------------------*/
+const u8 MAX_PGPKT_SIZE = 9; //header+ 2* 4 words (BYTES)
+const u8 PGPKT_DATA_SIZE = 8; //BYTES sizeof(u8)*8
+const u32 EFUSE_MAX_SIZE = 512;
+
+
+const EFUSE_MAP RTL8712_SDIO_EFUSE_TABLE[]={
+ //offset word_s byte_start byte_cnts
+/*ID*/ {0 ,0 ,0 ,2 }, // 00~01h
+/*LDO Setting*/ {0 ,1 ,0 ,2 }, // 02~03h
+/*CLK Setting*/ {0 ,2 ,0 ,2 }, // 04~05h
+/*SDIO Setting*/ {1 ,0 ,0 ,1 }, // 08h
+/*CCCR*/ {1 ,0 ,1 ,1 }, // 09h
+/*SDIO MODE*/ {1 ,1 ,0 ,1 }, // 0Ah
+/*OCR*/ {1 ,1 ,1 ,3 }, // 0B~0Dh
+/*CCIS*/ {1 ,3 ,0 ,17 }, // 0E~1Eh 2...1
+/*F1CIS*/ {3 ,3 ,1 ,48 }, // 1F~4Eh 6...0
+/*MAC Addr*/ {10 ,0 ,0 ,6 }, // 50~55h
+/*EEPROM ver*/ {10 ,3 ,0 ,1 }, // 56h
+/*Channel plan*/ {10 ,3 ,1 ,1 }, // 57h
+/*TxPwIndex */ {11 ,0 ,0 ,28 } // 58~73h 3...4
+};
+
+/*------------------------Define global variable-----------------------------*/
+
+
+/*------------------------Define local variable------------------------------*/
+
+/*------------------------Define local variable------------------------------*/
+
+
+/*--------------------Define function prototype-----------------------*/
+//
+// From WMAC Efuse one byte R/W
+//
+extern void
+EFUSE_Initialize(struct net_device* dev);
+extern u8
+EFUSE_Read1Byte(struct net_device* dev, u16 Address);
+extern void
+EFUSE_Write1Byte(struct net_device* dev, u16 Address,u8 Value);
+
+//
+// Efuse Shadow Area operation
+//
+static void
+efuse_ShadowRead1Byte(struct net_device* dev,u16 Offset,u8 *Value);
+static void
+efuse_ShadowRead2Byte(struct net_device* dev, u16 Offset,u16 *Value );
+static void
+efuse_ShadowRead4Byte(struct net_device* dev, u16 Offset,u32 *Value );
+static void
+efuse_ShadowWrite1Byte(struct net_device* dev, u16 Offset, u8 Value);
+static void
+efuse_ShadowWrite2Byte(struct net_device* dev, u16 Offset,u16 Value);
+static void
+efuse_ShadowWrite4Byte(struct net_device* dev, u16 Offset,u32 Value);
+
+//
+// Real Efuse operation
+//
+static u8
+efuse_OneByteRead(struct net_device* dev,u16 addr,u8 *data);
+static u8
+efuse_OneByteWrite(struct net_device* dev,u16 addr, u8 data);
+
+//
+// HW setting map file operation
+//
+static void
+efuse_ReadAllMap(struct net_device* dev,u8 *Efuse);
+#ifdef TO_DO_LIST
+static void
+efuse_WriteAllMap(struct net_device* dev,u8 *eeprom,u32 eeprom_size);
+static bool
+efuse_ParsingMap(char* szStr,u32* pu4bVal,u32* pu4bMove);
+#endif
+//
+// Reald Efuse R/W or other operation API.
+//
+static u8
+efuse_PgPacketRead( struct net_device* dev,u8 offset,u8 *data);
+static u8
+efuse_PgPacketWrite(struct net_device* dev,u8 offset,u8 word_en,u8 *data);
+static void
+efuse_WordEnableDataRead( u8 word_en,u8 *sourdata,u8 *targetdata);
+static u8
+efuse_WordEnableDataWrite( struct net_device* dev, u16 efuse_addr, u8 word_en, u8 *data);
+static void
+efuse_PowerSwitch(struct net_device* dev,u8 PwrState);
+static u16
+efuse_GetCurrentSize(struct net_device* dev);
+static u8
+efuse_CalculateWordCnts(u8 word_en);
+#if 0
+static void
+efuse_ResetLoader(struct net_device* dev);
+#endif
+//
+// API for power on power off!!!
+//
+#ifdef TO_DO_LIST
+static void efuse_reg_ctrl(struct net_device* dev, u8 bPowerOn);
+#endif
+/*--------------------Define function prototype-----------------------*/
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_Initialize
+ *
+ * Overview: Copy from WMAC fot EFUSE testing setting init.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 09/23/2008 MHC Copy from WMAC.
+ *
+ *---------------------------------------------------------------------------*/
+extern void
+EFUSE_Initialize(struct net_device* dev)
+{
+ u8 Bytetemp = {0x00};
+ u8 temp = {0x00};
+
+ //Enable Digital Core Vdd : 0x2[13]=1
+ Bytetemp = read_nic_byte(dev, SYS_FUNC_EN+1);
+ temp = Bytetemp | 0x20;
+ write_nic_byte(dev, SYS_FUNC_EN+1, temp);
+
+ //EE loader to retention path1: attach 0x0[8]=0
+ Bytetemp = read_nic_byte(dev, SYS_ISO_CTRL+1);
+ temp = Bytetemp & 0xFE;
+ write_nic_byte(dev, SYS_ISO_CTRL+1, temp);
+
+
+ //Enable E-fuse use 2.5V LDO : 0x37[7]=1
+ Bytetemp = read_nic_byte(dev, EFUSE_TEST+3);
+ temp = Bytetemp | 0x80;
+ write_nic_byte(dev, EFUSE_TEST+3, temp);
+
+ //E-fuse clk switch from 500k to 40M : 0x2F8[1:0]=11b
+ write_nic_byte(dev, 0x2F8, 0x3);
+
+ //Set E-fuse program time & read time : 0x30[30:24]=1110010b
+ write_nic_byte(dev, EFUSE_CTRL+3, 0x72);
+
+} /* EFUSE_Initialize */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_Read1Byte
+ *
+ * Overview: Copy from WMAC fot EFUSE read 1 byte.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 09/23/2008 MHC Copy from WMAC.
+ *
+ *---------------------------------------------------------------------------*/
+extern u8
+EFUSE_Read1Byte(struct net_device* dev, u16 Address)
+{
+ u8 data;
+ u8 Bytetemp = {0x00};
+ u8 temp = {0x00};
+ u32 k=0;
+
+ if (Address < EFUSE_MAC_LEN) //E-fuse 512Byte
+ {
+ //Write E-fuse Register address bit0~7
+ temp = Address & 0xFF;
+ write_nic_byte(dev, EFUSE_CTRL+1, temp);
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+2);
+ //Write E-fuse Register address bit8~9
+ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
+ write_nic_byte(dev, EFUSE_CTRL+2, temp);
+
+ //Write 0x30[31]=0
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
+ temp = Bytetemp & 0x7F;
+ write_nic_byte(dev, EFUSE_CTRL+3, temp);
+
+ //Wait Write-ready (0x30[31]=1)
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
+ while(!(Bytetemp & 0x80))
+ {
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
+ k++;
+ if(k==1000)
+ {
+ k=0;
+ break;
+ }
+ }
+ data=read_nic_byte(dev, EFUSE_CTRL);
+ return data;
+ }
+ else
+ return 0xFF;
+
+} /* EFUSE_Read1Byte */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_Write1Byte
+ *
+ * Overview: Copy from WMAC fot EFUSE write 1 byte.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 09/23/2008 MHC Copy from WMAC.
+ *
+ *---------------------------------------------------------------------------*/
+extern void
+EFUSE_Write1Byte(struct net_device* dev, u16 Address,u8 Value)
+{
+ //u8 data;
+ u8 Bytetemp = {0x00};
+ u8 temp = {0x00};
+ u32 k=0;
+
+ //RT_TRACE(COMP_EFUSE, "Addr=%x Data =%x\n", Address, Value);
+
+ if( Address < EFUSE_MAC_LEN) //E-fuse 512Byte
+ {
+ write_nic_byte(dev, EFUSE_CTRL, Value);
+
+ //Write E-fuse Register address bit0~7
+ temp = Address & 0xFF;
+ write_nic_byte(dev, EFUSE_CTRL+1, temp);
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+2);
+
+ //Write E-fuse Register address bit8~9
+ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
+ write_nic_byte(dev, EFUSE_CTRL+2, temp);
+
+ //Write 0x30[31]=1
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
+ temp = Bytetemp | 0x80;
+ write_nic_byte(dev, EFUSE_CTRL+3, temp);
+
+ //Wait Write-ready (0x30[31]=0)
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
+ while(Bytetemp & 0x80)
+ {
+ Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
+ k++;
+ if(k==100)
+ {
+ k=0;
+ break;
+ }
+ }
+ }
+
+} /* EFUSE_Write1Byte */
+
+
+#ifdef EFUSE_FOR_92SU
+//
+// Description:
+// 1. Process CR93C46 Data polling cycle.
+// 2. Refered from SD1 Richard.
+//
+// Assumption:
+// 1. Boot from E-Fuse and successfully auto-load.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+void do_93c46(struct net_device* dev, u8 addorvalue)
+{
+ //u8 clear[1] = {0x0}; // cs=0 , sk=0 , di=0 , do=0
+ u8 cs[1] = {0x88}; // cs=1 , sk=0 , di=0 , do=0
+ u8 cssk[1] = {0x8c}; // cs=1 , sk=1 , di=0 , do=0
+ u8 csdi[1] = {0x8a}; // cs=1 , sk=0 , di=1 , do=0
+ u8 csskdi[1] = {0x8e}; // cs=1 , sk=1 , di=1 , do=0
+ //u8 di[1] = {0x82}; // cs=0 , sk=0 , di=1 , do=0
+ u8 count;
+
+ for(count=0 ; count<8 ; count++)
+ {
+ if((addorvalue&0x80)!=0)
+ {
+ write_nic_byte(dev, EPROM_CMD, csdi[0]);
+ write_nic_byte(dev, EPROM_CMD, csskdi[0]);
+ }
+ else
+ {
+ write_nic_byte(dev, EPROM_CMD, cs[0]);
+ write_nic_byte(dev, EPROM_CMD, cssk[0]);
+ }
+ addorvalue = addorvalue << 1;
+ }
+}
+
+
+//
+// Description:
+// Process CR93C46 Data read polling cycle.
+// Refered from SD1 Richard.
+//
+// Assumption:
+// 1. Boot from E-Fuse and successfully auto-load.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+u16 Read93C46(struct net_device* dev, u16 Reg )
+{
+
+ u8 clear[1] = {0x0}; // cs=0 , sk=0 , di=0 , do=0
+ u8 cs[1] = {0x88}; // cs=1 , sk=0 , di=0 , do=0
+ u8 cssk[1] = {0x8c}; // cs=1 , sk=1 , di=0 , do=0
+ u8 csdi[1] = {0x8a}; // cs=1 , sk=0 , di=1 , do=0
+ u8 csskdi[1] = {0x8e}; // cs=1 , sk=1 , di=1 , do=0
+ //u8 di[1] = {0x82}; // cs=0 , sk=0 , di=1 , do=0
+ u8 EepromSEL[1]={0x00};
+ u8 address;
+
+ u16 storedataF[1] = {0x0}; //93c46 data packet for 16bits
+ u8 t,data[1],storedata[1];
+
+
+ address = (u8)Reg;
+
+ // Suggested by SD1 Alex, 2008.10.20. Revised by Roger.
+ *EepromSEL= read_nic_byte(dev, EPROM_CMD);
+
+ if((*EepromSEL & 0x10) == 0x10) // select 93c46
+ {
+ address = address | 0x80;
+
+ write_nic_byte(dev, EPROM_CMD, csdi[0]);
+ write_nic_byte(dev, EPROM_CMD, csskdi[0]);
+ do_93c46(dev, address);
+ }
+
+
+ for(t=0 ; t<16 ; t++) //if read 93c46 , t=16
+ {
+ write_nic_byte(dev, EPROM_CMD, cs[0]);
+ write_nic_byte(dev, EPROM_CMD, cssk[0]);
+ *data= read_nic_byte(dev, EPROM_CMD);
+
+ if(*data & 0x8d) //original code
+ {
+ *data = *data & 0x01;
+ *storedata = *data;
+ }
+ else
+ {
+ *data = *data & 0x01 ;
+ *storedata = *data;
+ }
+ *storedataF = (*storedataF << 1 ) + *storedata;
+ }
+ write_nic_byte(dev, EPROM_CMD, cs[0]);
+ write_nic_byte(dev, EPROM_CMD, clear[0]);
+
+ return *storedataF;
+}
+
+
+//
+// Description:
+// Execute E-Fuse read byte operation.
+// Refered from SD1 Richard.
+//
+// Assumption:
+// 1. Boot from E-Fuse and successfully auto-load.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+void
+ReadEFuseByte(struct net_device* dev,u16 _offset, u8 *pbuf)
+{
+
+ //u16 indexk=0;
+ u32 value32;
+ u8 readbyte;
+ u16 retry;
+
+
+ //Write Address
+ write_nic_byte(dev, EFUSE_CTRL+1, (_offset & 0xff));
+ readbyte = read_nic_byte(dev, EFUSE_CTRL+2);
+ write_nic_byte(dev, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
+
+ //Write bit 32 0
+ readbyte = read_nic_byte(dev, EFUSE_CTRL+3);
+ write_nic_byte(dev, EFUSE_CTRL+3, (readbyte & 0x7f));
+
+ //Check bit 32 read-ready
+ retry = 0;
+ value32 = read_nic_dword(dev, EFUSE_CTRL);
+ //while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10))
+ while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000))
+ {
+ value32 = read_nic_dword(dev, EFUSE_CTRL);
+ retry++;
+ }
+ *pbuf = (u8)(value32 & 0xff);
+}
+
+
+#define EFUSE_READ_SWITCH 1
+//
+// Description:
+// 1. Execute E-Fuse read byte operation according as map offset and
+// save to E-Fuse table.
+// 2. Refered from SD1 Richard.
+//
+// Assumption:
+// 1. Boot from E-Fuse and successfully auto-load.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+void
+ReadEFuse(struct net_device* dev, u16 _offset, u16 _size_byte, u8 *pbuf)
+{
+
+ u8 efuseTbl[128];
+ u8 rtemp8[1];
+ u16 eFuse_Addr = 0;
+ u8 offset, wren;
+ u16 i, j;
+ u16 eFuseWord[16][4];// = {0xFF};//FIXLZM
+
+ for(i=0; i<16; i++)
+ for(j=0; j<4; j++)
+ eFuseWord[i][j]=0xFF;
+
+ // Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10.
+ if((_offset + _size_byte)>128)
+ {// total E-Fuse table is 128bytes
+ //RT_TRACE(COMP_EFUSE, "ReadEFuse(): Invalid offset(%#x) with read bytes(%#x)!!\n",_offset, _size_byte);
+ printk("ReadEFuse(): Invalid offset with read bytes!!\n");
+ return;
+ }
+
+ // Refresh efuse init map as all oxFF.
+ for (i = 0; i < 128; i++)
+ efuseTbl[i] = 0xFF;
+
+#if (EFUSE_READ_SWITCH == 1)
+ ReadEFuseByte(dev, eFuse_Addr, rtemp8);
+#else
+ rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr);
+#endif
+ if(*rtemp8 != 0xFF) eFuse_Addr++;
+ while((*rtemp8 != 0xFF) && (eFuse_Addr < 512)){
+ offset = ((*rtemp8 >> 4) & 0x0f);
+ if(offset <= 0x0F){
+ wren = (*rtemp8 & 0x0f);
+ for(i=0; i<4; i++){
+ if(!(wren & 0x01)){
+#if (EFUSE_READ_SWITCH == 1)
+ ReadEFuseByte(dev, eFuse_Addr, rtemp8); eFuse_Addr++;
+#else
+ rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr); eFuse_Addr++;
+#endif
+ eFuseWord[offset][i] = (*rtemp8 & 0xff);
+ if(eFuse_Addr >= 512) break;
+#if (EFUSE_READ_SWITCH == 1)
+ ReadEFuseByte(dev, eFuse_Addr, rtemp8); eFuse_Addr++;
+#else
+ rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr); eFuse_Addr++;
+#endif
+ eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00);
+ if(eFuse_Addr >= 512) break;
+ }
+ wren >>= 1;
+ }
+ }
+#if (EFUSE_READ_SWITCH == 1)
+ ReadEFuseByte(dev, eFuse_Addr, rtemp8);
+#else
+ rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr); eFuse_Addr++;
+#endif
+ if(*rtemp8 != 0xFF && (eFuse_Addr < 512)) eFuse_Addr++;
+ }
+
+ for(i=0; i<16; i++){
+ for(j=0; j<4; j++){
+ efuseTbl[(i*8)+(j*2)]=(eFuseWord[i][j] & 0xff);
+ efuseTbl[(i*8)+((j*2)+1)]=((eFuseWord[i][j] >> 8) & 0xff);
+ }
+ }
+ for(i=0; i<_size_byte; i++)
+ pbuf[i] = efuseTbl[_offset+i];
+}
+#endif // #if (EFUSE_FOR_92SU == 1)
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_ShadowRead
+ *
+ * Overview: Read from efuse init map !!!!!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/12/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+extern void
+EFUSE_ShadowRead( struct net_device* dev, u8 Type, u16 Offset, u32 *Value)
+{
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
+
+ if (Type == 1)
+ efuse_ShadowRead1Byte(dev, Offset, (u8 *)Value);
+ else if (Type == 2)
+ efuse_ShadowRead2Byte(dev, Offset, (u16 *)Value);
+ else if (Type == 4)
+ efuse_ShadowRead4Byte(dev, Offset, (u32 *)Value);
+
+} // EFUSE_ShadowRead
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_ShadowWrite
+ *
+ * Overview: Write efuse modify map for later update operation to use!!!!!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/12/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+extern void
+EFUSE_ShadowWrite( struct net_device* dev, u8 Type, u16 Offset,u32 Value)
+{
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
+
+ if (Offset >= 0x18 && Offset <= 0x1F)
+ return;
+
+ if (Type == 1)
+ efuse_ShadowWrite1Byte(dev, Offset, (u8)Value);
+ else if (Type == 2)
+ efuse_ShadowWrite2Byte(dev, Offset, (u16)Value);
+ else if (Type == 4)
+ efuse_ShadowWrite4Byte(dev, Offset, (u32)Value);
+
+} // EFUSE_ShadowWrite
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_ShadowUpdate
+ *
+ * Overview: Compare init and modify map to update Efuse!!!!!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/12/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+extern void
+EFUSE_ShadowUpdate(struct net_device* dev)
+{
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 i, offset, base = 0;
+ u8 word_en = 0x0F;
+ bool first_pg = false;
+ // For Efuse write action, we must enable LDO2.5V and 40MHZ clk.
+ efuse_PowerSwitch(dev, TRUE);
+
+ //
+ // Efuse support 16 write are with PG header packet!!!!
+ //
+ for (offset = 0; offset < 16; offset++)
+ {
+ // Offset 0x18-1F are reserved now!!!
+#ifdef RTL8192SE
+ if(priv->card_8192 == NIC_8192SE){
+ if (offset == 3)
+ continue;
+ }
+#endif
+ word_en = 0x0F;
+ base = offset * 8;
+
+ //
+ // Decide Word Enable Bit for the Efuse section
+ // One section contain 4 words = 8 bytes!!!!!
+ //
+ for (i = 0; i < 8; i++)
+ {
+ if (offset == 0 && priv->EfuseMap[EFUSE_INIT_MAP][base+i] == 0xFF)
+ {
+ first_pg = TRUE;
+ }
+
+ // 2008/12/11 MH HW autoload fail workaround for A/BCUT.
+#ifdef RTL8192SE
+ if (first_pg == TRUE && offset == 1 && (priv->card_8192 == NIC_8192SE))
+ {
+ continue;
+ }
+#endif
+
+ if (first_pg == TRUE)
+ {
+ word_en &= ~(1<<(i/2));
+ priv->EfuseMap[EFUSE_INIT_MAP][base+i] =
+ priv->EfuseMap[EFUSE_MODIFY_MAP][base+i];
+ }else
+ {
+ if ( priv->EfuseMap[EFUSE_INIT_MAP][base+i] !=
+ priv->EfuseMap[EFUSE_MODIFY_MAP][base+i])
+ {
+ word_en &= ~(EFUSE_BIT(i/2));
+ //RT_TRACE(COMP_EFUSE, "Offset=%d Addr%x %x ==> %x Word_En=%02x\n",
+ //offset, base+i, priv->EfuseMap[0][base+i], priv->EfuseMap[1][base+i],word_en);
+
+ // Update init table!!!
+ priv->EfuseMap[EFUSE_INIT_MAP][base+i] =
+ priv->EfuseMap[EFUSE_MODIFY_MAP][base+i];
+ }
+ }
+ }
+
+ //
+ // Call Efuse real write section !!!!
+ //
+ if (word_en != 0x0F)
+ {
+ u8 tmpdata[8];
+
+ //FIXLZM
+ memcpy(tmpdata, &(priv->EfuseMap[EFUSE_MODIFY_MAP][base]), 8);
+ //RT_PRINT_DATA(COMP_INIT, DBG_LOUD, ("U-EFUSE\n"), tmpdata, 8);
+ efuse_PgPacketWrite(dev,(u8)offset,word_en,tmpdata);
+ }
+
+ }
+ // 2008/12/01 MH For Efuse HW load bug workarounf method!!!!
+ // We will force write 0x10EC into address 10&11 after all Efuse content.
+ //
+#ifdef RTL8192SE
+ if (first_pg == TRUE && (priv->card_8192 == NIC_8192SE))
+ {
+ // 2008/12/11 MH Use new method to prevent HW autoload fail.
+ u8 tmpdata[8];
+
+ memcpy(tmpdata, (&priv->EfuseMap[EFUSE_MODIFY_MAP][8]), 8);
+ efuse_PgPacketWrite(dev, 1, 0x0, tmpdata);
+#if 0
+ u1Byte tmpdata[8] = {0xFF, 0xFF, 0xEC, 0x10, 0xFF, 0xFF, 0xFF, 0xFF};
+
+ efuse_PgPacketWrite(pAdapter, 1, 0xD, tmpdata);
+#endif
+ }
+#endif
+
+
+ // For warm reboot, we must resume Efuse clock to 500K.
+ efuse_PowerSwitch(dev, FALSE);
+ // 2008/12/01 MH We update shadow content again!!!!
+ EFUSE_ShadowMapUpdate(dev);
+
+} // EFUSE_ShadowUpdate
+
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_ShadowMapUpdate
+ *
+ * Overview: Transfer current EFUSE content to shadow init and modify map.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/13/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+extern void EFUSE_ShadowMapUpdate(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if (priv->AutoloadFailFlag == true){
+ memset(&(priv->EfuseMap[EFUSE_INIT_MAP][0]), 0xff, 128);
+ }else{
+ efuse_ReadAllMap(dev, &priv->EfuseMap[EFUSE_INIT_MAP][0]);
+ }
+ //PlatformMoveMemory(&priv->EfuseMap[EFUSE_MODIFY_MAP][0],
+ //&priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);//FIXLZM
+ memcpy(&priv->EfuseMap[EFUSE_MODIFY_MAP][0],
+ &priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
+
+} // EFUSE_ShadowMapUpdate
+
+extern void
+EFUSE_ForceWriteVendorId( struct net_device* dev)
+{
+ u8 tmpdata[8] = {0xFF, 0xFF, 0xEC, 0x10, 0xFF, 0xFF, 0xFF, 0xFF};
+
+ efuse_PowerSwitch(dev, TRUE);
+
+ efuse_PgPacketWrite(dev, 1, 0xD, tmpdata);
+
+ efuse_PowerSwitch(dev, FALSE);
+
+} // EFUSE_ForceWriteVendorId
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_ShadowRead1Byte
+ * efuse_ShadowRead2Byte
+ * efuse_ShadowRead4Byte
+ *
+ * Overview: Read from efuse init map by one/two/four bytes !!!!!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/12/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+efuse_ShadowRead1Byte(struct net_device* dev, u16 Offset, u8 *Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ *Value = priv->EfuseMap[EFUSE_MODIFY_MAP][Offset];
+
+} // EFUSE_ShadowRead1Byte
+
+//---------------Read Two Bytes
+static void
+efuse_ShadowRead2Byte(struct net_device* dev, u16 Offset, u16 *Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ *Value = priv->EfuseMap[EFUSE_MODIFY_MAP][Offset];
+ *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1]<<8;
+
+} // EFUSE_ShadowRead2Byte
+
+//---------------Read Four Bytes
+static void
+efuse_ShadowRead4Byte(struct net_device* dev, u16 Offset, u32 *Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ *Value = priv->EfuseMap[EFUSE_MODIFY_MAP][Offset];
+ *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1]<<8;
+ *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+2]<<16;
+ *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+3]<<24;
+
+} // efuse_ShadowRead4Byte
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_ShadowWrite1Byte
+ * efuse_ShadowWrite2Byte
+ * efuse_ShadowWrite4Byte
+ *
+ * Overview: Write efuse modify map by one/two/four byte.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/12/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+efuse_ShadowWrite1Byte(struct net_device* dev, u16 Offset, u8 Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset] = Value;
+
+} // efuse_ShadowWrite1Byte
+
+//---------------Write Two Bytes
+static void
+efuse_ShadowWrite2Byte(struct net_device* dev, u16 Offset, u16 Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset] = Value&0x00FF;
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1] = Value>>8;
+
+} // efuse_ShadowWrite1Byte
+
+//---------------Write Four Bytes
+static void
+efuse_ShadowWrite4Byte(struct net_device* dev, u16 Offset, u32 Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset] = (u8)(Value&0x000000FF);
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1] = (u8)((Value>>8)&0x0000FF);
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+2] = (u8)((Value>>16)&0x00FF);
+ priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+3] = (u8)((Value>>24)&0xFF);
+
+} // efuse_ShadowWrite1Byte
+
+
+/* 11/16/2008 MH Read one byte from real Efuse. */
+static u8
+efuse_OneByteRead(struct net_device* dev, u16 addr,u8 *data)
+{
+ u8 tmpidx = 0;
+ u8 bResult;
+
+ // -----------------e-fuse reg ctrl ---------------------------------
+ //address
+ write_nic_byte(dev, EFUSE_CTRL+1, (u8)(addr&0xff));
+ write_nic_byte(dev, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03) ) |
+ (read_nic_byte(dev, EFUSE_CTRL+2)&0xFC ));
+
+ write_nic_byte(dev, EFUSE_CTRL+3, 0x72);//read cmd
+
+ while(!(0x80 &read_nic_byte(dev, EFUSE_CTRL+3))&&(tmpidx<100))
+ {
+ tmpidx++;
+ }
+ if(tmpidx<100)
+ {
+ *data=read_nic_byte(dev, EFUSE_CTRL);
+ bResult = TRUE;
+ }
+ else
+ {
+ *data = 0xff;
+ bResult = FALSE;
+ }
+ return bResult;
+} // efuse_OneByteRead
+
+/* 11/16/2008 MH Write one byte to reald Efuse. */
+static u8
+efuse_OneByteWrite(struct net_device* dev, u16 addr, u8 data)
+{
+ u8 tmpidx = 0;
+ u8 bResult;
+
+ //RT_TRACE(COMP_EFUSE, "Addr = %x Data=%x\n", addr, data);
+
+ //return 0;
+
+ // -----------------e-fuse reg ctrl ---------------------------------
+ //address
+ write_nic_byte(dev, EFUSE_CTRL+1, (u8)(addr&0xff));
+ write_nic_byte(dev, EFUSE_CTRL+2,
+ read_nic_byte(dev, EFUSE_CTRL+2)|(u8)((addr>>8)&0x03) );
+
+ write_nic_byte(dev, EFUSE_CTRL, data);//data
+ write_nic_byte(dev, EFUSE_CTRL+3, 0xF2);//write cmd
+
+ while((0x80 & read_nic_byte(dev, EFUSE_CTRL+3)) && (tmpidx<100) ){
+ tmpidx++;
+ }
+
+ if(tmpidx<100)
+ {
+ bResult = TRUE;
+ }
+ else
+ {
+ bResult = FALSE;
+ }
+
+ return bResult;
+} // efuse_OneByteWrite
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_ReadAllMap
+ *
+ * Overview: Read All Efuse content
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/11/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+efuse_ReadAllMap(struct net_device* dev, u8 *Efuse)
+{
+ //u8 pg_data[8];
+ //u8 offset = 0;
+ //u8 tmpidx;
+ //static u8 index = 0;
+
+ //
+ // We must enable clock and LDO 2.5V otherwise, read all map will be fail!!!!
+ //
+ efuse_PowerSwitch(dev, TRUE);
+ ReadEFuse(dev, 0, 128, Efuse);
+ efuse_PowerSwitch(dev, FALSE);
+#if 0
+ // ==> Prevent efuse read error!!!
+ RT_TRACE(COMP_INIT, "efuse_ResetLoader\n");
+ efuse_ResetLoader(dev);
+
+ // Change Efuse Clock for write action to 40MHZ
+ write_nic_byte(dev, EFUSE_CLK, 0x03);
+
+ ReadEFuse(dev, 0, 128, Efuse);
+
+ // Change Efuse Clock for write action to 500K
+ write_nic_byte(dev, EFUSE_CLK, 0x02);
+#if 0 // Error !!!!!!
+ for(offset = 0;offset<16;offset++) // For 8192SE
+ {
+ PlatformFillMemory((PVOID)pg_data, 8, 0xff);
+ efuse_PgPacketRead(pAdapter,offset,pg_data);
+
+ PlatformMoveMemory((PVOID)&Efuse[offset*8], (PVOID)pg_data, 8);
+ }
+#endif
+
+ //
+ // Error Check and Reset Again!!!!
+ //
+ if (Efuse[0] != 0x29 || Efuse[1] != 0x81)
+ {
+ // SW autoload fail, we have to read again!!!
+ if (index ++ < 5)
+ {
+ RT_TRACE(COMP_INIT, "EFUSE R FAIL %d\n", index);
+ efuse_ReadAllMap(dev, Efuse);
+ // Wait a few time ???? Or need to do some setting ???
+ // When we reload driver, efuse will be OK!!
+ }
+ }
+ else
+ {
+ index = 0;
+ }
+
+ //efuse_PowerSwitch(pAdapter, FALSE);
+#endif
+} // efuse_ReadAllMap
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_WriteAllMap
+ *
+ * Overview: Write All Efuse content
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/11/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+#ifdef TO_DO_LIST
+static void
+efuse_WriteAllMap(struct net_device* dev,u8 *eeprom, u32 eeprom_size)
+{
+ unsigned char word_en = 0x00;
+
+ unsigned char tmpdata[8];
+ unsigned char offset;
+
+ // For Efuse write action, we must enable LDO2.5V and 40MHZ clk.
+ efuse_PowerSwitch(dev, TRUE);
+
+ //sdio contents
+ for(offset=0 ; offset< eeprom_size/PGPKT_DATA_SIZE ; offset++)
+ {
+ // 92S will only reserv 0x18-1F 8 bytes now. The 3rd efuse write area!
+ if (IS_HARDWARE_TYPE_8192SE(dev))
+ {
+ // Refer to
+ // 0x18-1f Reserve >0x50 Reserve for tx power
+ if (offset == 3/* || offset > 9*/)
+ continue;//word_en = 0x0F;
+ //else if (offset == 9) // 0x4c-4f Reserve
+ //word_en = 0x0C;
+ else
+ word_en = 0x00;
+ }
+ //RT_TRACE(COMP_EFUSE, ("Addr=%d size=%d Word_En=%02x\n", offset, eeprom_size, word_en));
+
+ //memcpy(tmpdata,eeprom+(offset*PGPKT_DATA_SIZE),8);
+ memcpy(tmpdata, (eeprom+(offset*PGPKT_DATA_SIZE)), 8);
+
+ //RT_PRINT_DATA(COMP_INIT, DBG_LOUD, ("EFUSE\t"), tmpdata, 8);
+
+ efuse_PgPacketWrite(dev,offset,word_en,tmpdata);
+
+
+ }
+
+ // For warm reboot, we must resume Efuse clock to 500K.
+ efuse_PowerSwitch(dev, FALSE);
+
+} // efuse_WriteAllMap
+#endif
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_PgPacketRead
+ *
+ * Overview: Receive dedicated Efuse are content. For92s, we support 16
+ * area now. It will return 8 bytes content for every area.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/16/2008 MHC Reorganize code Arch and assign as local API.
+ *
+ *---------------------------------------------------------------------------*/
+static u8
+efuse_PgPacketRead( struct net_device* dev, u8 offset, u8 *data)
+{
+ u8 ReadState = PG_STATE_HEADER;
+
+ bool bContinual = TRUE;
+ bool bDataEmpty = TRUE ;
+
+ u8 efuse_data,word_cnts=0;
+ u16 efuse_addr = 0;
+ u8 hoffset=0,hworden=0;
+ u8 tmpidx=0;
+ u8 tmpdata[8];
+
+ if(data==NULL) return FALSE;
+ if(offset>15) return FALSE;
+
+ //FIXLZM
+ //PlatformFillMemory((PVOID)data, sizeof(u8)*PGPKT_DATA_SIZE, 0xff);
+ //PlatformFillMemory((PVOID)tmpdata, sizeof(u8)*PGPKT_DATA_SIZE, 0xff);
+ memset(data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE);
+ memset(tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE);
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("efuse_PgPacketRead-1\n"), data, 8);
+
+ //efuse_reg_ctrl(pAdapter,TRUE);//power on
+ while(bContinual && (efuse_addr < EFUSE_MAX_SIZE) )
+ {
+ //------- Header Read -------------
+ if(ReadState & PG_STATE_HEADER)
+ {
+ if(efuse_OneByteRead(dev, efuse_addr ,&efuse_data)&&(efuse_data!=0xFF)){
+ hoffset = (efuse_data>>4) & 0x0F;
+ hworden = efuse_data & 0x0F;
+ word_cnts = efuse_CalculateWordCnts(hworden);
+ bDataEmpty = TRUE ;
+
+ if(hoffset==offset){
+ for(tmpidx = 0;tmpidx< word_cnts*2 ;tmpidx++){
+ if(efuse_OneByteRead(dev, efuse_addr+1+tmpidx ,&efuse_data) ){
+ tmpdata[tmpidx] = efuse_data;
+ if(efuse_data!=0xff){
+ bDataEmpty = FALSE;
+ }
+ }
+ }
+ if(bDataEmpty==FALSE){
+ ReadState = PG_STATE_DATA;
+ }else{//read next header
+ efuse_addr = efuse_addr + (word_cnts*2)+1;
+ ReadState = PG_STATE_HEADER;
+ }
+ }
+ else{//read next header
+ efuse_addr = efuse_addr + (word_cnts*2)+1;
+ ReadState = PG_STATE_HEADER;
+ }
+
+ }
+ else{
+ bContinual = FALSE ;
+ }
+ }
+ //------- Data section Read -------------
+ else if(ReadState & PG_STATE_DATA)
+ {
+ efuse_WordEnableDataRead(hworden,tmpdata,data);
+ efuse_addr = efuse_addr + (word_cnts*2)+1;
+ ReadState = PG_STATE_HEADER;
+ }
+
+ }
+ //efuse_reg_ctrl(pAdapter,FALSE);//power off
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("efuse_PgPacketRead-2\n"), data, 8);
+
+ if( (data[0]==0xff) &&(data[1]==0xff) && (data[2]==0xff) && (data[3]==0xff) &&
+ (data[4]==0xff) &&(data[5]==0xff) && (data[6]==0xff) && (data[7]==0xff))
+ return FALSE;
+ else
+ return TRUE;
+
+} // efuse_PgPacketRead
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_PgPacketWrite
+ *
+ * Overview: Send A G package for different section in real efuse area.
+ * For 92S, One PG package contain 8 bytes content and 4 word
+ * unit. PG header = 0x[bit7-4=offset][bit3-0word enable]
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/16/2008 MHC Reorganize code Arch and assign as local API.
+ *
+ *---------------------------------------------------------------------------*/
+static u8 efuse_PgPacketWrite(struct net_device* dev, u8 offset, u8 word_en,u8 *data)
+{
+ u8 WriteState = PG_STATE_HEADER;
+
+ bool bContinual = TRUE,bDataEmpty=TRUE, bResult = TRUE;
+ u16 efuse_addr = 0;
+ u8 efuse_data;
+
+ u8 pg_header = 0;
+
+ //u16 tmp_addr=0;
+ u8 tmp_word_cnts=0,target_word_cnts=0;
+ u8 tmp_header,match_word_en,tmp_word_en;
+
+ //u8 efuse_clk_ori,efuse_clk_new;
+
+ PGPKT_STRUCT target_pkt;
+ PGPKT_STRUCT tmp_pkt;
+
+ u8 originaldata[sizeof(u8)*8];
+ u8 tmpindex = 0,badworden = 0x0F;
+
+ static u32 repeat_times = 0;
+
+ if( efuse_GetCurrentSize(dev) >= EFUSE_MAX_SIZE)
+ {
+ printk("efuse_PgPacketWrite error \n");
+ return FALSE;
+ }
+
+ // Init the 8 bytes content as 0xff
+ target_pkt.offset = offset;
+ target_pkt.word_en= word_en;
+
+ //PlatformFillMemory((PVOID)target_pkt.data, sizeof(u8)*8, 0xFF);
+ memset(target_pkt.data,0xFF,sizeof(u8)*8);
+
+ efuse_WordEnableDataRead(word_en,data,target_pkt.data);
+ target_word_cnts = efuse_CalculateWordCnts(target_pkt.word_en);
+
+ //efuse_reg_ctrl(pAdapter,TRUE);//power on
+ printk("EFUSE Power ON\n");
+
+ while( bContinual && (efuse_addr < EFUSE_MAX_SIZE) )
+ {
+
+ if(WriteState==PG_STATE_HEADER)
+ {
+ bDataEmpty=TRUE;
+ badworden = 0x0F;
+ //************ so *******************
+ printk("EFUSE PG_STATE_HEADER\n");
+ if ( efuse_OneByteRead(dev, efuse_addr ,&efuse_data) &&
+ (efuse_data!=0xFF))
+ {
+ tmp_header = efuse_data;
+
+ tmp_pkt.offset = (tmp_header>>4) & 0x0F;
+ tmp_pkt.word_en = tmp_header & 0x0F;
+ tmp_word_cnts = efuse_CalculateWordCnts(tmp_pkt.word_en);
+
+ //************ so-1 *******************
+ if(tmp_pkt.offset != target_pkt.offset)
+ {
+ efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
+ #if (EFUSE_ERROE_HANDLE == 1)
+ WriteState = PG_STATE_HEADER;
+ #endif
+ }
+ else
+ {
+ //************ so-2 *******************
+ for(tmpindex=0 ; tmpindex<(tmp_word_cnts*2) ; tmpindex++)
+ {
+ if(efuse_OneByteRead(dev, (efuse_addr+1+tmpindex) ,&efuse_data)&&(efuse_data != 0xFF)){
+ bDataEmpty = FALSE;
+ }
+ }
+ //************ so-2-1 *******************
+ if(bDataEmpty == FALSE)
+ {
+ efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
+ #if (EFUSE_ERROE_HANDLE == 1)
+ WriteState=PG_STATE_HEADER;
+ #endif
+ }
+ else
+ {//************ so-2-2 *******************
+ match_word_en = 0x0F;
+ if( !( (target_pkt.word_en&BIT0)|(tmp_pkt.word_en&BIT0) ))
+ {
+ match_word_en &= (~BIT0);
+ }
+ if( !( (target_pkt.word_en&BIT1)|(tmp_pkt.word_en&BIT1) ))
+ {
+ match_word_en &= (~BIT1);
+ }
+ if( !( (target_pkt.word_en&BIT2)|(tmp_pkt.word_en&BIT2) ))
+ {
+ match_word_en &= (~BIT2);
+ }
+ if( !( (target_pkt.word_en&BIT3)|(tmp_pkt.word_en&BIT3) ))
+ {
+ match_word_en &= (~BIT3);
+ }
+
+ //************ so-2-2-A *******************
+ if((match_word_en&0x0F)!=0x0F)
+ {
+ badworden = efuse_WordEnableDataWrite(dev,efuse_addr+1, tmp_pkt.word_en ,target_pkt.data);
+
+ //************ so-2-2-A-1 *******************
+ //############################
+ if(0x0F != (badworden&0x0F))
+ {
+ u8 reorg_offset = offset;
+ u8 reorg_worden=badworden;
+ efuse_PgPacketWrite(dev,reorg_offset,reorg_worden,originaldata);
+ }
+ //############################
+
+ tmp_word_en = 0x0F;
+ if( (target_pkt.word_en&BIT0)^(match_word_en&BIT0) )
+ {
+ tmp_word_en &= (~BIT0);
+ }
+ if( (target_pkt.word_en&BIT1)^(match_word_en&BIT1) )
+ {
+ tmp_word_en &= (~BIT1);
+ }
+ if( (target_pkt.word_en&BIT2)^(match_word_en&BIT2) )
+ {
+ tmp_word_en &= (~BIT2);
+ }
+ if( (target_pkt.word_en&BIT3)^(match_word_en&BIT3) )
+ {
+ tmp_word_en &=(~BIT3);
+ }
+
+ //************ so-2-2-A-2 *******************
+ if((tmp_word_en&0x0F)!=0x0F){
+ //reorganize other pg packet
+ //efuse_addr = efuse_addr + (2*tmp_word_cnts) +1;//next pg packet addr
+ efuse_addr = efuse_GetCurrentSize(dev);
+ //===========================
+ target_pkt.offset = offset;
+ target_pkt.word_en= tmp_word_en;
+ //===========================
+ }else{
+ bContinual = FALSE;
+ }
+ #if (EFUSE_ERROE_HANDLE == 1)
+ WriteState=PG_STATE_HEADER;
+ repeat_times++;
+ if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
+ bContinual = FALSE;
+ bResult = FALSE;
+ }
+ #endif
+ }
+ else{//************ so-2-2-B *******************
+ //reorganize other pg packet
+ efuse_addr = efuse_addr + (2*tmp_word_cnts) +1;//next pg packet addr
+ //===========================
+ target_pkt.offset = offset;
+ target_pkt.word_en= target_pkt.word_en;
+ //===========================
+ #if (EFUSE_ERROE_HANDLE == 1)
+ WriteState=PG_STATE_HEADER;
+ #endif
+ }
+ }
+ }
+ printk("EFUSE PG_STATE_HEADER-1\n");
+ }
+ else //************ s1: header == oxff *******************
+ {
+ pg_header = ((target_pkt.offset << 4)&0xf0) |target_pkt.word_en;
+
+ efuse_OneByteWrite(dev,efuse_addr, pg_header);
+ efuse_OneByteRead(dev,efuse_addr, &tmp_header);
+
+ if(tmp_header == pg_header)
+ { //************ s1-1*******************
+ WriteState = PG_STATE_DATA;
+ }
+ #if (EFUSE_ERROE_HANDLE == 1)
+ else if(tmp_header == 0xFF){//************ s1-3: if Write or read func doesn't work *******************
+ //efuse_addr doesn't change
+ WriteState = PG_STATE_HEADER;
+ repeat_times++;
+ if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
+ bContinual = FALSE;
+ bResult = FALSE;
+ }
+ }
+ #endif
+ else
+ {//************ s1-2 : fixed the header procedure *******************
+ tmp_pkt.offset = (tmp_header>>4) & 0x0F;
+ tmp_pkt.word_en= tmp_header & 0x0F;
+ tmp_word_cnts = efuse_CalculateWordCnts(tmp_pkt.word_en);
+
+ //************ s1-2-A :cover the exist data *******************
+ memset(originaldata,0xff,sizeof(u8)*8);
+ //PlatformFillMemory((PVOID)originaldata, sizeof(u8)*8, 0xff);
+
+ if(efuse_PgPacketRead( dev, tmp_pkt.offset,originaldata))
+ { //check if data exist
+ //efuse_reg_ctrl(pAdapter,TRUE);//power on
+ badworden = efuse_WordEnableDataWrite(dev,efuse_addr+1,tmp_pkt.word_en,originaldata);
+ //############################
+ if(0x0F != (badworden&0x0F))
+ {
+ u8 reorg_offset = tmp_pkt.offset;
+ u8 reorg_worden=badworden;
+ efuse_PgPacketWrite(dev,reorg_offset,reorg_worden,originaldata);
+ efuse_addr = efuse_GetCurrentSize(dev);
+ }
+ //############################
+ else{
+ efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
+ }
+ }
+ //************ s1-2-B: wrong address*******************
+ else
+ {
+ efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
+ }
+
+ #if (EFUSE_ERROE_HANDLE == 1)
+ WriteState=PG_STATE_HEADER;
+ repeat_times++;
+ if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
+ bContinual = FALSE;
+ bResult = FALSE;
+ }
+ #endif
+
+ printk("EFUSE PG_STATE_HEADER-2\n");
+ }
+
+ }
+
+ }
+ //write data state
+ else if(WriteState==PG_STATE_DATA)
+ { //************ s1-1 *******************
+ printk("EFUSE PG_STATE_DATA\n");
+ badworden = 0x0f;
+ badworden = efuse_WordEnableDataWrite(dev,efuse_addr+1,target_pkt.word_en,target_pkt.data);
+ if((badworden&0x0F)==0x0F)
+ { //************ s1-1-A *******************
+ bContinual = FALSE;
+ }
+ else
+ {//reorganize other pg packet //************ s1-1-B *******************
+ efuse_addr = efuse_addr + (2*target_word_cnts) +1;//next pg packet addr
+
+ //===========================
+ target_pkt.offset = offset;
+ target_pkt.word_en= badworden;
+ target_word_cnts = efuse_CalculateWordCnts(target_pkt.word_en);
+ //===========================
+ #if (EFUSE_ERROE_HANDLE == 1)
+ WriteState=PG_STATE_HEADER;
+ repeat_times++;
+ if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
+ bContinual = FALSE;
+ bResult = FALSE;
+ }
+ #endif
+ printk("EFUSE PG_STATE_HEADER-3\n");
+ }
+ }
+ }
+
+ //efuse_reg_ctrl(pAdapter,FALSE);//power off
+
+ return TRUE;
+} // efuse_PgPacketWrite
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_WordEnableDataRead
+ *
+ * Overview: Read allowed word in current efuse section data.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/16/2008 MHC Create Version 0.
+ * 11/21/2008 MHC Fix Write bug when we only enable late word.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+efuse_WordEnableDataRead( u8 word_en,u8 *sourdata,u8 *targetdata)
+{
+ //u8 tmpindex = 0;
+
+ //DbgPrint("efuse_WordEnableDataRead word_en = %x\n", word_en);
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("sourdata\n"), sourdata, 8);
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("targetdata\n"), targetdata, 8);
+
+ if (!(word_en&BIT0))
+ {
+ targetdata[0] = sourdata[0];//sourdata[tmpindex++];
+ targetdata[1] = sourdata[1];//sourdata[tmpindex++];
+ }
+ if (!(word_en&BIT1))
+ {
+ targetdata[2] = sourdata[2];//sourdata[tmpindex++];
+ targetdata[3] = sourdata[3];//sourdata[tmpindex++];
+ }
+ if (!(word_en&BIT2))
+ {
+ targetdata[4] = sourdata[4];//sourdata[tmpindex++];
+ targetdata[5] = sourdata[5];//sourdata[tmpindex++];
+ }
+ if (!(word_en&BIT3))
+ {
+ targetdata[6] = sourdata[6];//sourdata[tmpindex++];
+ targetdata[7] = sourdata[7];//sourdata[tmpindex++];
+ }
+} // efuse_WordEnableDataRead
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_WordEnableDataWrite
+ *
+ * Overview: Write necessary word unit into current efuse section!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/16/2008 MHC Reorganize Efuse operate flow!!.
+ *
+ *---------------------------------------------------------------------------*/
+static u8
+efuse_WordEnableDataWrite( struct net_device* dev, u16 efuse_addr, u8 word_en, u8 *data)
+{
+ u16 tmpaddr = 0;
+ u16 start_addr = efuse_addr;
+ u8 badworden = 0x0F;
+ //u8 NextState;
+ u8 tmpdata[8];
+
+ memset(tmpdata,0xff,PGPKT_DATA_SIZE);
+ //PlatformFillMemory((PVOID)tmpdata, PGPKT_DATA_SIZE, 0xff);
+
+ //RT_TRACE(COMP_EFUSE, "word_en = %x efuse_addr=%x\n", word_en, efuse_addr);
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("U-EFUSE\n"), data, 8);
+
+ if(!(word_en&BIT0))
+ {
+ tmpaddr = start_addr;
+ efuse_OneByteWrite(dev,start_addr++, data[0]);
+ efuse_OneByteWrite(dev,start_addr++, data[1]);
+
+ efuse_OneByteRead(dev,tmpaddr, &tmpdata[0]);
+ efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[1]);
+ if((data[0]!=tmpdata[0])||(data[1]!=tmpdata[1])){
+ badworden &= (~BIT0);
+ }
+ }
+ if(!(word_en&BIT1))
+ {
+ tmpaddr = start_addr;
+ efuse_OneByteWrite(dev,start_addr++, data[2]);
+ efuse_OneByteWrite(dev,start_addr++, data[3]);
+
+ efuse_OneByteRead(dev,tmpaddr , &tmpdata[2]);
+ efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[3]);
+ if((data[2]!=tmpdata[2])||(data[3]!=tmpdata[3])){
+ badworden &=( ~BIT1);
+ }
+ }
+ if(!(word_en&BIT2))
+ {
+ tmpaddr = start_addr;
+ efuse_OneByteWrite(dev,start_addr++, data[4]);
+ efuse_OneByteWrite(dev,start_addr++, data[5]);
+
+ efuse_OneByteRead(dev,tmpaddr, &tmpdata[4]);
+ efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[5]);
+ if((data[4]!=tmpdata[4])||(data[5]!=tmpdata[5])){
+ badworden &=( ~BIT2);
+ }
+ }
+ if(!(word_en&BIT3))
+ {
+ tmpaddr = start_addr;
+ efuse_OneByteWrite(dev,start_addr++, data[6]);
+ efuse_OneByteWrite(dev,start_addr++, data[7]);
+
+ efuse_OneByteRead(dev,tmpaddr, &tmpdata[6]);
+ efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[7]);
+ if((data[6]!=tmpdata[6])||(data[7]!=tmpdata[7])){
+ badworden &=( ~BIT3);
+ }
+ }
+ return badworden;
+} // efuse_WordEnableDataWrite
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_PowerSwitch
+ *
+ * Overview: When we want to enable write operation, we should change to
+ * pwr on state. When we stop write, we should switch to 500k mode
+ * and disable LDO 2.5V.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/17/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+efuse_PowerSwitch(struct net_device* dev, u8 PwrState)
+{
+ u8 tempval;
+ if (PwrState == TRUE)
+ {
+ // Enable LDO 2.5V for write action
+ tempval = read_nic_byte(dev, EFUSE_TEST+3);
+ write_nic_byte(dev, EFUSE_TEST+3, (tempval | 0x80));
+
+ // Change Efuse Clock for write action to 40MHZ
+ write_nic_byte(dev, EFUSE_CLK, 0x03);
+ }
+ else
+ {
+ // Enable LDO 2.5V for write action
+ tempval = read_nic_byte(dev, EFUSE_TEST+3);
+ write_nic_byte(dev, EFUSE_TEST+3, (tempval & 0x7F));
+
+ // Change Efuse Clock for write action to 500K
+ write_nic_byte(dev, EFUSE_CLK, 0x02);
+ }
+
+} /* efuse_PowerSwitch */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_GetCurrentSize
+ *
+ * Overview: Get current efuse size!!!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/16/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static u16
+efuse_GetCurrentSize(struct net_device* dev)
+{
+ bool bContinual = TRUE;
+
+ u16 efuse_addr = 0;
+ u8 hoffset=0,hworden=0;
+ u8 efuse_data,word_cnts=0;
+
+ //efuse_reg_ctrl(pAdapter,TRUE);//power on
+
+ while ( bContinual &&
+ efuse_OneByteRead(dev, efuse_addr ,&efuse_data) &&
+ (efuse_addr < EFUSE_MAX_SIZE) )
+ {
+ if(efuse_data!=0xFF)
+ {
+ hoffset = (efuse_data>>4) & 0x0F;
+ hworden = efuse_data & 0x0F;
+ word_cnts = efuse_CalculateWordCnts(hworden);
+ //read next header
+ efuse_addr = efuse_addr + (word_cnts*2)+1;
+ }
+ else
+ {
+ bContinual = FALSE ;
+ }
+ }
+
+ //efuse_reg_ctrl(pAdapter,FALSE);//power off
+
+ return efuse_addr;
+
+} // efuse_GetCurrentSize}
+
+
+/* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */
+static u8
+efuse_CalculateWordCnts(u8 word_en)
+{
+ u8 word_cnts = 0;
+ if(!(word_en & BIT0)) word_cnts++; // 0 : write enable
+ if(!(word_en & BIT1)) word_cnts++;
+ if(!(word_en & BIT2)) word_cnts++;
+ if(!(word_en & BIT3)) word_cnts++;
+ return word_cnts;
+} // efuse_CalculateWordCnts
+
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_ResetLoader
+ *
+ * Overview: When read Efuse Fail we must reset loader!!!!
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/22/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+#if 0
+static void efuse_ResetLoader(struct net_device* dev)
+{
+ u16 tmpU2b;
+
+ //
+ // 2008/11/22 MH Sometimes, we may read efuse fail, for preventing the condition
+ // We have to reset loader.
+ //
+ tmpU2b = read_nic_word(dev, SYS_FUNC_EN);
+ write_nic_word(dev, SYS_FUNC_EN, (tmpU2b&~(BIT12)));
+ //PlatformStallExecution(10000); // How long should we delay!!!
+ mdelay(10);
+ write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|BIT12));
+ //PlatformStallExecution(10000); // How long should we delay!!!
+ mdelay(10);
+
+} // efuse_ResetLoader
+#endif
+
+/*-----------------------------------------------------------------------------
+ * Function: EFUSE_ProgramMap
+ *
+ * Overview: Read EFUSE map file and execute PG.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/10/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+ #ifdef TO_DO_LIST
+extern bool // 0=Shadow 1=Real Efuse
+EFUSE_ProgramMap(struct net_device* dev, char* pFileName,u8 TableType)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ s4Byte nLinesRead, ithLine;
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ char* szLine;
+ u32 u4bRegValue, u4RegMask;
+ u32 u4bMove;
+ u16 index = 0;
+ u16 i;
+ u8 eeprom[HWSET_MAX_SIZE_92S];
+
+ rtStatus = PlatformReadFile(
+ dev,
+ pFileName,
+ (u8*)(priv->BufOfLines),
+ MAX_LINES_HWCONFIG_TXT,
+ MAX_BYTES_LINE_HWCONFIG_TXT,
+ &nLinesRead
+ );
+
+ if(rtStatus == RT_STATUS_SUCCESS)
+ {
+ memcp(pHalData->BufOfLines3, pHalData->BufOfLines,
+ nLinesRead*MAX_BYTES_LINE_HWCONFIG_TXT);
+ pHalData->nLinesRead3 = nLinesRead;
+ }
+
+ if(rtStatus == RT_STATUS_SUCCESS)
+ {
+ printk("szEepromFile(): read %s ok\n", pFileName);
+ for(ithLine = 0; ithLine < nLinesRead; ithLine++)
+ {
+ szLine = pHalData->BufOfLines[ithLine];
+ printk("Line-%d String =%s\n", ithLine, szLine);
+
+ if(!IsCommentString(szLine))
+ {
+ // EEPROM map one line has 8 words content.
+ for (i = 0; i < 8; i++)
+ {
+ u32 j;
+
+ //GetHexValueFromString(szLine, &u4bRegValue, &u4bMove);
+ efuse_ParsingMap(szLine, &u4bRegValue, &u4bMove);
+
+ // Get next hex value as EEPROM value.
+ szLine += u4bMove;
+ //WriteEEprom(dev, (u16)(ithLine*8+i), (u16)u4bRegValue);
+ eeprom[index++] = (u8)(u4bRegValue&0xff);
+ eeprom[index++] = (u8)((u4bRegValue>>8)&0xff);
+
+ printk("Addr-%d = %x\n", (ithLine*8+i), u4bRegValue);
+ }
+ }
+
+ }
+
+ }
+ else
+ {
+ printk("szEepromFile(): Fail read%s\n", pFileName);
+ return RT_STATUS_FAILURE;
+ }
+
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("EFUSE "), eeprom, HWSET_MAX_SIZE_92S);
+
+ // Use map file to update real Efuse or shadow modify table.
+ if (TableType == 1)
+ {
+ efuse_WriteAllMap(dev, eeprom, HWSET_MAX_SIZE_92S);
+ }
+ else
+ {
+ // Modify shadow table.
+ for (i = 0; i < HWSET_MAX_SIZE_92S; i++)
+ EFUSE_ShadowWrite(dev, 1, i, (u32)eeprom[i]);
+ }
+
+ return rtStatus;
+} /* EFUSE_ProgramMap */
+
+#endif
+
+//
+// Description:
+// Return TRUE if chTmp is represent for hex digit and
+// FALSE otherwise.
+//
+//
+bool IsHexDigit( char chTmp)
+{
+ if( (chTmp >= '0' && chTmp <= '9') ||
+ (chTmp >= 'a' && chTmp <= 'f') ||
+ (chTmp >= 'A' && chTmp <= 'F') )
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+//
+// Description:
+// Translate a character to hex digit.
+//
+u32 MapCharToHexDigit(char chTmp)
+{
+ if(chTmp >= '0' && chTmp <= '9')
+ return (chTmp - '0');
+ else if(chTmp >= 'a' && chTmp <= 'f')
+ return (10 + (chTmp - 'a'));
+ else if(chTmp >= 'A' && chTmp <= 'F')
+ return (10 + (chTmp - 'A'));
+ else
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: efuse_ParsingMap
+ *
+ * Overview:
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/08/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+#ifdef TO_DO_LIST
+static bool
+efuse_ParsingMap(char* szStr,u32* pu4bVal,u32* pu4bMove)
+{
+ char* szScan = szStr;
+
+ // Check input parameter.
+ if(szStr == NULL || pu4bVal == NULL || pu4bMove == NULL)
+ {
+ //RT_TRACE(COMP_EFUSE,
+ //"eeprom_ParsingMap(): Invalid IN args! szStr: %p, pu4bVal: %p, pu4bMove: %p\n",
+ //szStr, pu4bVal, pu4bMove);
+ return FALSE;
+ }
+
+ // Initialize output.
+ *pu4bMove = 0;
+ *pu4bVal = 0;
+
+ // Skip leading space.
+ while( *szScan != '\0' &&
+ (*szScan == ' ' || *szScan == '\t') )
+ {
+ szScan++;
+ (*pu4bMove)++;
+ }
+
+ // Check if szScan is now pointer to a character for hex digit,
+ // if not, it means this is not a valid hex number.
+ if(!IsHexDigit(*szScan))
+ {
+ return FALSE;
+ }
+
+ // Parse each digit.
+ do
+ {
+ (*pu4bVal) <<= 4;
+ *pu4bVal += MapCharToHexDigit(*szScan);
+
+ szScan++;
+ (*pu4bMove)++;
+ } while(IsHexDigit(*szScan));
+
+ return TRUE;
+
+} /* efuse_ParsingMap */
+#endif
+
+//
+// Useless Section Code Now!!!!!!
+//
+// Porting from 8712 SDIO
+int efuse_one_byte_rw(struct net_device* dev, u8 bRead, u16 addr, u8 *data)
+{
+ u32 bResult;
+ //u8 efuse_ctlreg,tmpidx = 0;
+ u8 tmpidx = 0;
+ u8 tmpv8=0;
+
+ // -----------------e-fuse reg ctrl ---------------------------------
+
+ write_nic_byte(dev, EFUSE_CTRL+1, (u8)(addr&0xff)); //address
+ tmpv8 = ((u8)((addr>>8) &0x03) ) | (read_nic_byte(dev, EFUSE_CTRL+2)&0xFC );
+ write_nic_byte(dev, EFUSE_CTRL+2, tmpv8);
+
+ if(TRUE==bRead){
+
+ write_nic_byte(dev, EFUSE_CTRL+3, 0x72);//read cmd
+
+ while(!(0x80 & read_nic_byte(dev, EFUSE_CTRL+3)) && (tmpidx<100) ){
+ tmpidx++;
+ }
+ if(tmpidx<100){
+ *data=read_nic_byte(dev, EFUSE_CTRL);
+ bResult = TRUE;
+ }
+ else
+ {
+ *data = 0;
+ bResult = FALSE;
+ }
+
+ }
+ else{
+ //return 0;
+ write_nic_byte(dev, EFUSE_CTRL, *data);//data
+
+ write_nic_byte(dev, EFUSE_CTRL+3, 0xF2);//write cmd
+
+ while((0x80 & read_nic_byte(dev, EFUSE_CTRL+3)) && (tmpidx<100) ){
+ tmpidx++;
+ }
+ if(tmpidx<100)
+ {
+ *data=read_nic_byte(dev, EFUSE_CTRL);
+ bResult = TRUE;
+ }
+ else
+ {
+ *data = 0;
+ bResult = FALSE;
+ }
+
+ }
+ return bResult;
+}
+//------------------------------------------------------------------------------
+void efuse_access(struct net_device* dev, u8 bRead,u16 start_addr, u8 cnts, u8 *data)
+{
+ u8 efuse_clk_ori,efuse_clk_new;//,tmp8;
+ u32 i = 0;
+
+ if(start_addr>0x200) return;
+ //RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,
+ // ("\n ===> efuse_access [start_addr=0x%x cnts:%d dataarray:0x%08x Query Efuse].\n",start_addr,cnts,data));
+ // -----------------SYS_FUNC_EN Digital Core Vdd enable ---------------------------------
+ efuse_clk_ori = read_nic_byte(dev,SYS_FUNC_EN+1);
+ efuse_clk_new = efuse_clk_ori|0x20;
+
+ if(efuse_clk_new!= efuse_clk_ori){
+ //RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,("====write 0x10250003=====\n"));
+ write_nic_byte(dev, SYS_FUNC_EN+1, efuse_clk_new);
+ }
+#ifdef _POWERON_DELAY_
+ mdelay(10);
+#endif
+ // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
+ write_nic_byte(dev, EFUSE_TEST+3, (read_nic_byte(dev, EFUSE_TEST+3)|0x80));
+ write_nic_byte(dev, EFUSE_CLK_CTRL, (read_nic_byte(dev, EFUSE_CLK_CTRL)|0x03));
+
+#ifdef _PRE_EXECUTE_READ_CMD_
+ {
+ unsigned char tmpdata;
+ efuse_OneByteRead(dev, 0,&tmpdata);
+ }
+#endif
+
+ //-----------------e-fuse one byte read / write ------------------------------
+ for(i=0;i<cnts;i++){
+ efuse_one_byte_rw(dev,bRead, start_addr+i , data+i);
+ ////RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,("==>efuse_access addr:0x%02x value:0x%02x\n",data+i,*(data+i)));
+ }
+ // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
+ write_nic_byte(dev, EFUSE_TEST+3, read_nic_byte(dev, EFUSE_TEST+3)&0x7f);
+ write_nic_byte(dev, EFUSE_CLK_CTRL, read_nic_byte(dev, EFUSE_CLK_CTRL)&0xfd);
+
+ // -----------------SYS_FUNC_EN Digital Core Vdd disable ---------------------------------
+ if(efuse_clk_new != efuse_clk_ori) write_nic_byte(dev, 0x10250003, efuse_clk_ori);
+
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+#ifdef TO_DO_LIST
+static void efuse_reg_ctrl(struct net_device* dev, u8 bPowerOn)
+{
+ if(TRUE==bPowerOn){
+ // -----------------SYS_FUNC_EN Digital Core Vdd enable ---------------------------------
+ write_nic_byte(dev, SYS_FUNC_EN+1, read_nic_byte(dev,SYS_FUNC_EN+1)|0x20);
+#ifdef _POWERON_DELAY_
+ mdelay(10);
+#endif
+ // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
+ write_nic_byte(dev, EFUSE_TEST+4, (read_nic_byte(dev, EFUSE_TEST+4)|0x80));
+ write_nic_byte(dev, EFUSE_CLK_CTRL, (read_nic_byte(dev, EFUSE_CLK_CTRL)|0x03));
+#ifdef _PRE_EXECUTE_READ_CMD_
+ {
+ unsigned char tmpdata;
+ efuse_OneByteRead(dev, 0,&tmpdata);
+ }
+
+#endif
+ }
+ else{
+ // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
+ write_nic_byte(dev, EFUSE_TEST+4, read_nic_byte(dev, EFUSE_TEST+4)&0x7f);
+ write_nic_byte(dev, EFUSE_CLK_CTRL, read_nic_byte(dev, EFUSE_CLK_CTRL)&0xfd);
+ // -----------------SYS_FUNC_EN Digital Core Vdd disable ---------------------------------
+
+ //write_nic_byte(pAdapter, SYS_FUNC_EN+1, read_nic_byte(pAdapter,SYS_FUNC_EN+1)&0xDF);
+ }
+
+
+}
+#endif
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void efuse_read_data(struct net_device* dev,u8 efuse_read_item,u8 *data,u32 data_size)
+{
+ u8 offset, word_start,byte_start,byte_cnts;
+ u8 efusedata[EFUSE_MAC_LEN];
+ u8 *tmpdata = NULL;
+
+ u8 pg_pkt_cnts ;
+
+ u8 tmpidx;
+ u8 pg_data[8];
+ //u8 temp_value[8] = {0xff};
+
+ if(efuse_read_item> (sizeof(RTL8712_SDIO_EFUSE_TABLE)/sizeof(EFUSE_MAP))){
+ //error msg
+ return ;
+ }
+
+ offset = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].offset ;
+ word_start = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].word_start;
+ byte_start = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].byte_start;
+ byte_cnts = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].byte_cnts;
+
+ if(data_size!=byte_cnts){
+ //error msg
+ return;
+ }
+
+ pg_pkt_cnts = (byte_cnts /PGPKT_DATA_SIZE) +1;
+
+ if(pg_pkt_cnts > 1){
+ //tmpdata = _malloc(pg_pkt_cnts*PGPKT_DATA_SIZE);
+ tmpdata = efusedata;
+
+ if(tmpdata!=NULL)
+ {
+ memset(tmpdata,0xff,pg_pkt_cnts*PGPKT_DATA_SIZE);
+ //PlatformFillMemory((PVOID)pg_data, pg_pkt_cnts*PGPKT_DATA_SIZE, 0xff);
+
+ for(tmpidx=0;tmpidx<pg_pkt_cnts;tmpidx++)
+ {
+ memset(pg_data,0xff,PGPKT_DATA_SIZE);
+ //PlatformFillMemory((PVOID)pg_data, PGPKT_DATA_SIZE, 0xff);
+ if(TRUE== efuse_PgPacketRead(dev,offset+tmpidx,pg_data))
+ {
+ memcpy(tmpdata+(PGPKT_DATA_SIZE*tmpidx),pg_data,PGPKT_DATA_SIZE);
+ //PlatformMoveMemory((PVOID)(tmpdata+(PGPKT_DATA_SIZE*tmpidx)), (PVOID)pg_data, PGPKT_DATA_SIZE);
+ }
+ }
+ memcpy(data,(tmpdata+ (2*word_start)+byte_start ),data_size);
+ //PlatformMoveMemory((PVOID)data, (PVOID)(tmpdata+ (2*word_start)+byte_start ), data_size);
+ //_mfree(tmpdata, pg_pkt_cnts*PGPKT_DATA_SIZE);
+ }
+ }
+ else
+ {
+ memset(pg_data,0xff,PGPKT_DATA_SIZE);
+ //PlatformFillMemory((PVOID)pg_data, PGPKT_DATA_SIZE, 0xff);
+ if(TRUE==efuse_PgPacketRead(dev,offset,pg_data)){
+ memcpy(data,pg_data+ (2*word_start)+byte_start ,data_size);
+ //PlatformMoveMemory((PVOID)data, (PVOID)(pg_data+ (2*word_start)+byte_start), data_size);
+ }
+ }
+
+}
+//------------------------------------------------------------------------------
+//per interface doesn't alike
+void efuse_write_data(struct net_device* dev,u8 efuse_write_item,u8 *data,u32 data_size,u32 bWordUnit)
+{
+ u8 offset, word_start,byte_start,byte_cnts;
+ u8 word_en = 0x0f,word_cnts;
+ u8 pg_pkt_cnts ;
+
+ u8 tmpidx,tmpbitmask;
+ u8 pg_data[8],tmpbytes=0;
+
+ if(efuse_write_item> (sizeof(RTL8712_SDIO_EFUSE_TABLE)/sizeof(EFUSE_MAP))){
+ //error msg
+ return ;
+ }
+
+ offset = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].offset ;
+ word_start = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].word_start;
+ byte_start = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].byte_start;
+ byte_cnts = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].byte_cnts;
+
+ if(data_size > byte_cnts){
+ //error msg
+ return;
+ }
+ pg_pkt_cnts = (byte_cnts /PGPKT_DATA_SIZE) +1;
+ word_cnts = byte_cnts /2 ;
+
+ if(byte_cnts %2){
+ word_cnts+=1;
+ }
+ if((byte_start==1)||((byte_cnts%2)==1)){//situation A
+
+ if((efuse_write_item==EFUSE_F0CIS)||(efuse_write_item==EFUSE_F1CIS)){
+ memset(pg_data,0xff,PGPKT_DATA_SIZE);
+ //PlatformFillMemory((PVOID)pg_data, PGPKT_DATA_SIZE, 0xff);
+ efuse_PgPacketRead(dev,offset,pg_data);
+
+ if(efuse_write_item==EFUSE_F0CIS){
+ word_en = 0x07;
+ memcpy(pg_data+word_start*2+byte_start,data,sizeof(u8)*2);
+ //PlatformMoveMemory((PVOID)(pg_data+word_start*2+byte_start), (PVOID)data, sizeof(u8)*2);
+ efuse_PgPacketWrite(dev,offset,word_en,pg_data+(word_start*2));
+
+ word_en = 0x00;
+ efuse_PgPacketWrite(dev,(offset+1),word_en,data+2);
+
+ word_en = 0x00;
+ efuse_PgPacketRead(dev,offset+2,pg_data);
+ memcpy(pg_data,data+2+8,sizeof(u8)*7);
+ //PlatformMoveMemory((PVOID)(pg_data), (PVOID)(data+2+8), sizeof(u8)*7);
+
+ efuse_PgPacketWrite(dev,(offset+2),word_en,pg_data);
+ }
+ else if(efuse_write_item==EFUSE_F1CIS){
+ word_en = 0x07;
+ efuse_PgPacketRead(dev,offset,pg_data);
+ pg_data[7] = data[0];
+ efuse_PgPacketWrite(dev,offset,word_en,pg_data+(word_start*2));
+
+ word_en = 0x00;
+ for(tmpidx = 0 ;tmpidx<(word_cnts/4);tmpidx++){
+ efuse_PgPacketWrite(dev,(offset+1+tmpidx),word_en,data+1+(tmpidx*PGPKT_DATA_SIZE));
+ }
+ }
+
+ }
+ else{
+ memset(pg_data,0xff,PGPKT_DATA_SIZE);
+ //PlatformFillMemory((PVOID)pg_data, PGPKT_DATA_SIZE, 0xff);
+ if((efuse_write_item==EFUSE_SDIO_SETTING)||(efuse_write_item==EFUSE_CCCR)){
+ word_en = 0x0e ;
+ tmpbytes = 2;
+ }
+ else if(efuse_write_item == EFUSE_SDIO_MODE){
+ word_en = 0x0d ;
+ tmpbytes = 2;
+ }
+ else if(efuse_write_item == EFUSE_OCR){
+ word_en = 0x09 ;
+ tmpbytes = 4;
+ }
+ else if((efuse_write_item == EFUSE_EEPROM_VER)||(efuse_write_item==EFUSE_CHAN_PLAN)){
+ word_en = 0x07 ;
+ tmpbytes = 2;
+ }
+ if(bWordUnit==TRUE){
+ memcpy(pg_data+word_start*2 ,data,sizeof(u8)*tmpbytes);
+ //PlatformMoveMemory((PVOID)(pg_data+word_start*2), (PVOID)(data), sizeof(u8)*tmpbytes);
+ }
+ else{
+ efuse_PgPacketRead(dev,offset,pg_data);
+ memcpy(pg_data+(2*word_start)+byte_start,data,sizeof(u8)*byte_cnts);
+ //PlatformMoveMemory((PVOID)(pg_data+(2*word_start)+byte_start), (PVOID)(data), sizeof(u8)*byte_cnts);
+ }
+
+ efuse_PgPacketWrite(dev,offset,word_en,pg_data+(word_start*2));
+
+ }
+
+ }
+ //========================================================================
+ else if(pg_pkt_cnts>1){//situation B
+ if(word_start==0){
+ word_en = 0x00;
+ for(tmpidx = 0 ;tmpidx<(word_cnts/4);tmpidx++)
+ {
+ efuse_PgPacketWrite(dev,(offset+tmpidx),word_en,data+(tmpidx*PGPKT_DATA_SIZE));
+ }
+ word_en = 0x0f;
+ for(tmpidx= 0; tmpidx<(word_cnts%4) ; tmpidx++)
+ {
+ tmpbitmask =tmpidx;
+ word_en &= (~(EFUSE_BIT(tmpbitmask)));
+ //BIT0
+ }
+ efuse_PgPacketWrite(dev,offset+(word_cnts/4),word_en,data+((word_cnts/4)*PGPKT_DATA_SIZE));
+ }else
+ {
+
+ }
+ }
+ //========================================================================
+ else{//situation C
+ word_en = 0x0f;
+ for(tmpidx= 0; tmpidx<word_cnts ; tmpidx++)
+ {
+ tmpbitmask = word_start + tmpidx ;
+ word_en &= (~(EFUSE_BIT(tmpbitmask)));
+ }
+ efuse_PgPacketWrite(dev,offset,word_en,data);
+ }
+
+}
+//------------------------------------------------------------------------------
+
+void efuset_test_func_read(struct net_device* dev)
+{
+ u8 chipid[2];
+ u8 ocr[3];
+ u8 macaddr[6];
+ u8 txpowertable[28];
+
+ memset(chipid,0,sizeof(u8)*2);
+ efuse_read_data(dev,EFUSE_CHIP_ID,chipid,sizeof(chipid));
+
+ memset(ocr,0,sizeof(u8)*3);
+ efuse_read_data(dev,EFUSE_CCCR,ocr,sizeof(ocr));
+
+ memset(macaddr,0,sizeof(u8)*6);
+ efuse_read_data(dev,EFUSE_MAC_ADDR,macaddr,sizeof(macaddr));
+
+ memset(txpowertable,0,sizeof(u8)*28);
+ efuse_read_data(dev,EFUSE_TXPW_TAB,txpowertable,sizeof(txpowertable));
+}
+//------------------------------------------------------------------------------
+
+void efuset_test_func_write(struct net_device* dev)
+{
+ u32 bWordUnit = TRUE;
+ u8 CCCR=0x02,SDIO_SETTING = 0xFF;
+ u8 tmpdata[2];
+
+ u8 macaddr[6] = {0x00,0xe0,0x4c,0x87,0x12,0x66};
+ efuse_write_data(dev,EFUSE_MAC_ADDR,macaddr,sizeof(macaddr),bWordUnit);
+
+ bWordUnit = FALSE;
+ efuse_write_data(dev,EFUSE_CCCR,&CCCR,sizeof(u8),bWordUnit);
+
+ bWordUnit = FALSE;
+ efuse_write_data(dev,EFUSE_SDIO_SETTING,&SDIO_SETTING,sizeof(u8),bWordUnit);
+
+ bWordUnit = TRUE;
+ tmpdata[0] =SDIO_SETTING ;
+ tmpdata[1] =CCCR ;
+ efuse_write_data(dev,EFUSE_SDIO_SETTING,tmpdata,sizeof(tmpdata),bWordUnit);
+
+}
+//------------------------------------------------------------------------------
+
+
+
+
+#endif // #if (HAL_CODE_BASE == RTL8192_S)
+
+
+
+
+
+
+/* End of Efuse.c */
+
+
+
+
diff --git a/drivers/staging/rtl8192su/r8192S_Efuse.h b/drivers/staging/rtl8192su/r8192S_Efuse.h
new file mode 100644
index 000000000000..1e50153ba02c
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_Efuse.h
@@ -0,0 +1,101 @@
+/******************************************************************************
+ *
+ * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
+ *
+ * Module: Efuse.h ( Header File)
+ *
+ * Note:
+ *
+ * Function:
+ *
+ * Export:
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ *
+ * 09/23/2008 MHC Porting Efuse R/W API from WMAC.
+ * 11/10/2008 MHC Porting Efuse.h from 8712 SDIO.
+ * 1. We muse redefine the header file to fit our coding
+ * style.
+ * 2. THe API we export to other module, we must redefine
+ * for 8192S series.
+ *
+ *
+******************************************************************************/
+/* Check to see if the file has been included already. */
+
+#ifndef __INC_EFUSE_H
+#define __INC_EFUSE_H
+
+// Roger porting for 8192SU
+#define EFUSE_FOR_92SU 1
+
+/*--------------------------Define Parameters-------------------------------*/
+#define EFUSE_MAC_LEN 0x200
+
+#define EFUSE_INIT_MAP 0
+#define EFUSE_MODIFY_MAP 1
+
+#define EFUSE_CLK_CTRL EFUSE_CTRL
+#define EFUSE_BIT(x) (1 << (x))
+
+// From 8712!!!!!!!!
+#define PG_STATE_HEADER 0x01
+#define PG_STATE_WORD_0 0x02
+#define PG_STATE_WORD_1 0x04
+#define PG_STATE_WORD_2 0x08
+#define PG_STATE_WORD_3 0x10
+#define PG_STATE_DATA 0x20
+
+#define PG_SWBYTE_H 0x01
+#define PG_SWBYTE_L 0x02
+
+/*--------------------------Define Parameters-------------------------------*/
+
+
+/*------------------------------Define structure----------------------------*/
+
+/*------------------------------Define structure----------------------------*/
+
+
+/*------------------------Export global variable----------------------------*/
+/*------------------------Export global variable----------------------------*/
+
+/*------------------------Export Marco Definition---------------------------*/
+
+/*------------------------Export Marco Definition---------------------------*/
+
+
+/*--------------------------Exported Function prototype---------------------*/
+extern void
+EFUSE_Initialize(struct net_device* dev);
+extern u8
+EFUSE_Read1Byte(struct net_device* dev,u16 Address);
+extern void
+EFUSE_Write1Byte(struct net_device* dev,u16 Address,u8 Value);
+
+#ifdef EFUSE_FOR_92SU
+extern void
+ReadEFuse(struct net_device* dev,u16 _offset,u16 _size_byte,u8* pbuf);
+extern void
+ReadEFuseByte(struct net_device* dev,u16 _offset,u8 *pbuf);
+#endif // #if (EFUSE_FOR_92SU == 1)
+
+extern void
+EFUSE_ShadowRead(struct net_device* dev,unsigned char Type,unsigned short Offset,u32 *Value);
+extern void
+EFUSE_ShadowWrite(struct net_device* dev,unsigned char Type,unsigned short Offset,u32 Value);
+extern void
+EFUSE_ShadowUpdate(struct net_device* dev);
+extern void
+EFUSE_ShadowMapUpdate(struct net_device* dev);
+
+extern bool
+EFUSE_ProgramMap(struct net_device* dev,char* pFileName, u8 TableType); // 0=Shadow 1=Real Efuse
+/*--------------------------Exported Function prototype---------------------*/
+
+/* End of Efuse.h */
+
+#endif //__INC_EFUSE_H
diff --git a/drivers/staging/rtl8192su/r8192S_FwImgDTM.h b/drivers/staging/rtl8192su/r8192S_FwImgDTM.h
new file mode 100644
index 000000000000..afced75271bb
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_FwImgDTM.h
@@ -0,0 +1,3797 @@
+#ifndef HAL8192PciE_FW_IMG_DTM_H
+#define HAL8192PciE_FW_IMG_DTM_H
+
+/*Created on 2008/ 3/11, 8:34*/
+#include <linux/types.h>
+
+#define MACPHY_ArrayLengthDTM 18
+#define MACPHY_Array_PGLengthDTM 30
+#define AGCTAB_ArrayLengthDTM 384
+#define AGCTAB_ArrayLength 384
+
+#define BootArrayLengthDTM 344
+u8 Rtl8192PciEFwBootArrayDTM[BootArrayLengthDTM] = {
+0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08,
+0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01,
+0x25,0x08,0xbc,0xf0,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,
+0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b,
+0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00,
+0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01,
+0x25,0x08,0xbc,0xf0,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0,
+0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00,
+0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,
+0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,
+0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,
+0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01,
+0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24,
+0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10,
+0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
+0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10,
+0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x5f,0x84,
+0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,};
+
+#define MainArrayLengthDTM 48368
+u8 Rtl8192PciEFwMainArrayDTM[MainArrayLengthDTM] = {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x17,0x50,
+0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09,
+0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24,
+0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0,
+0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x91,0x50,0x00,0x85,0x18,0x21,
+0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00,
+0x27,0x82,0x91,0x5a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00,
+0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x91,0x50,
+0x24,0x02,0x00,0x0a,0x24,0x03,0x09,0xc4,0xa3,0x82,0x91,0x52,0x24,0x02,0x00,0x04,
+0x24,0x04,0x00,0x01,0x24,0x05,0x00,0x02,0xa7,0x83,0x91,0x66,0xa3,0x82,0x91,0x58,
+0x24,0x03,0x04,0x00,0x24,0x02,0x02,0x00,0xaf,0x83,0x91,0x6c,0xa3,0x85,0x91,0x59,
+0xa7,0x82,0x91,0x5a,0xa7,0x84,0x91,0x5c,0xaf,0x84,0x91,0x68,0xa3,0x84,0x91,0x51,
+0xa3,0x80,0x91,0x53,0xa3,0x80,0x91,0x54,0xa3,0x80,0x91,0x55,0xa3,0x84,0x91,0x56,
+0xa3,0x85,0x91,0x57,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x7c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,
+0x27,0x84,0x91,0x78,0x00,0x00,0x10,0x21,0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00,
+0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00,
+0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc0,
+0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00,
+0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00,
+0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03,
+0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11,
+0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07,
+0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10,
+0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b,
+0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20,
+0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x24,
+0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54,
+0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0xaf,0x83,0x91,0x74,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18,
+0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,0x27,0x85,0x91,0x70,0x8c,0xa3,0x00,0x00,
+0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a,
+0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01,
+0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3,
+0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40,
+0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x91,0x78,0x00,0x0a,0x20,0x0b,
+0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01,
+0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x91,0x78,0xa0,0x67,0x00,0x01,
+0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07,
+0x00,0x00,0x00,0x00,0x27,0x83,0x91,0x70,0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,0xac,0x62,0x00,0x00,0x27,0x85,0x91,0x74,
+0x27,0x82,0x91,0x70,0x00,0xc5,0x28,0x21,0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00,
+0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03,
+0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0xb7,0xac,0xa0,0x00,0x00,
+0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x91,0x8c,0x08,0x00,0x00,0xa7,
+0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0xaf,0x83,0x91,0x80,0x08,0x00,0x00,0xa7,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x10,
+0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00,
+0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03,
+0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2,
+0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09,
+0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,0x30,0x43,0x00,0x03,0x83,0x82,0x91,0x78,
+0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00,
+0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04,
+0x30,0x43,0x00,0x06,0x93,0x82,0x91,0x90,0x08,0x00,0x01,0x1f,0x00,0x43,0x10,0x21,
+0x83,0x82,0x91,0x84,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x1f,
+0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01,
+0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xe4,
+0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08,
+0x24,0x02,0x00,0x01,0xaf,0x84,0x91,0xa0,0xa3,0x82,0x91,0xb0,0xa7,0x80,0x91,0xa4,
+0xa7,0x80,0x91,0xa6,0xaf,0x80,0x91,0xa8,0xaf,0x80,0x91,0xac,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
+0x24,0x42,0x05,0x24,0x27,0xbd,0xff,0xe0,0xac,0x62,0x00,0x00,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0xaf,0xbf,0x00,0x18,0x0c,0x00,0x01,0xe3,
+0x00,0x80,0x80,0x21,0x02,0x00,0x20,0x21,0x10,0x40,0x00,0x05,0x02,0x20,0x28,0x21,
+0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x0c,0x00,0x01,0xf9,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0x58,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x05,0x80,
+0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x18,0x8f,0x90,0x91,0xa0,0x0c,0x00,0x01,0xe3,0x00,0x80,0x88,0x21,
+0x14,0x40,0x00,0x2a,0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,0x34,0x42,0x02,0x01,
+0x24,0x02,0x02,0x01,0xae,0x02,0x00,0x00,0x97,0x84,0x91,0xa4,0x97,0x82,0x91,0xa6,
+0x3c,0x03,0xb0,0x02,0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,0xa7,0x82,0x91,0xa6,
+0xa4,0x82,0x00,0x00,0x8f,0x84,0x91,0xa8,0x8f,0x82,0x91,0xa0,0x93,0x85,0x91,0x52,
+0x24,0x84,0x00,0x01,0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,0x3c,0x07,0xb0,0x06,
+0x3c,0x06,0xb0,0x03,0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,0x34,0xe7,0x80,0x18,
+0xaf,0x82,0x91,0xa0,0xaf,0x84,0x91,0xa8,0x10,0xa0,0x00,0x08,0x34,0xc6,0x01,0x08,
+0x8f,0x83,0x91,0xac,0x8f,0x84,0x91,0x6c,0x8c,0xc2,0x00,0x00,0x00,0x64,0x18,0x21,
+0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x8c,0xe2,0x00,0x00,
+0x3c,0x03,0x0f,0x00,0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,0x10,0x44,0x00,0x03,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x03,0x95,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,
+0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x6c,0xaf,0xb0,0x00,0x10,
+0x34,0x42,0x00,0x20,0x8f,0x90,0x91,0xa0,0xac,0x43,0x00,0x00,0xaf,0xb3,0x00,0x1c,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0x00,0x80,0x88,0x21,
+0x00,0xa0,0x90,0x21,0x0c,0x00,0x01,0xe3,0x00,0xc0,0x98,0x21,0x24,0x07,0x8f,0xff,
+0x14,0x40,0x00,0x19,0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,
+0x00,0x67,0x80,0x24,0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,0x00,0x47,0x80,0x24,
+0x97,0x86,0x91,0xa4,0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,0x00,0x67,0x80,0x24,
+0xae,0x13,0x00,0x00,0x8f,0x84,0x91,0xa0,0x3c,0x02,0xb0,0x02,0x97,0x85,0x91,0xa6,
+0x00,0xc2,0x30,0x21,0x8f,0x82,0x91,0xa8,0x24,0x84,0x00,0x10,0x24,0xa5,0x00,0x10,
+0x00,0x87,0x20,0x24,0x24,0x42,0x00,0x01,0xa7,0x85,0x91,0xa6,0xaf,0x84,0x91,0xa0,
+0xaf,0x82,0x91,0xa8,0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x87,0x83,0x88,0x86,
+0x93,0x82,0x80,0x11,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,
+0x93,0x83,0x88,0x87,0x24,0x02,0x00,0x01,0xa3,0x82,0x80,0x10,0xa3,0x83,0x80,0x12,
+0xa3,0x83,0x80,0x11,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x93,0x82,0x80,0x12,
+0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xf6,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xd5,
+0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,
+0xa3,0x85,0x8b,0x6b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x93,0x82,0x91,0xb0,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01,0x8f,0x82,0x91,0xa8,
+0x3c,0x05,0xb0,0x06,0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18,0x34,0x84,0x01,0x08,
+0x14,0x40,0x00,0x09,0x00,0x00,0x30,0x21,0x97,0x82,0x91,0xa4,0x8c,0x84,0x00,0x00,
+0x3c,0x03,0xb0,0x02,0x00,0x43,0x10,0x21,0xaf,0x84,0x91,0xac,0xa7,0x80,0x91,0xa6,
+0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0xc0,0x10,0x21,0x8f,0x86,0x91,0xa0,0x8f,0x82,0x91,0xa8,0x27,0xbd,0xff,0xe8,
+0xaf,0xbf,0x00,0x10,0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a,0x00,0x40,0x50,0x21,
+0x00,0x00,0x38,0x21,0x27,0x89,0x8b,0x40,0x24,0xe2,0x00,0x01,0x00,0x07,0x18,0x80,
+0x30,0x47,0x00,0xff,0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a,0x14,0x40,0xff,0xfa,
+0xac,0x60,0x00,0x00,0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6d,0x00,0x00,0x00,0x00,
+0x97,0x82,0x8b,0x46,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0x46,
+0x90,0xa3,0x00,0x15,0x97,0x82,0x8b,0x48,0x00,0x03,0x1e,0x00,0x00,0x03,0x1e,0x03,
+0x00,0x43,0x10,0x21,0xa7,0x82,0x8b,0x48,0x8c,0xa4,0x00,0x20,0x3c,0x02,0x00,0x60,
+0x3c,0x03,0x00,0x20,0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x52,0x00,0x00,0x00,0x00,
+0x14,0x80,0x00,0x45,0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0x4c,0x00,0x00,0x00,0x00,
+0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0x4c,0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0x5c,
+0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0x5c,0x25,0x42,0x00,0x01,
+0x28,0x43,0x27,0x10,0xaf,0x82,0x91,0xa8,0x10,0x60,0x00,0x09,0x24,0x02,0x00,0x04,
+0x93,0x83,0x80,0x10,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x04,
+0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x24,0x03,0x00,0x28,0xa3,0x83,0x8b,0x42,0xa3,0x82,0x8b,0x43,0x90,0xa2,0x00,0x18,
+0x93,0x83,0x8b,0x6b,0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,
+0xa7,0x82,0x8b,0x56,0xa3,0x83,0x8b,0x64,0x27,0x89,0x8b,0x40,0x24,0x05,0x8f,0xff,
+0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xe3,0x00,0x01,
+0x30,0x67,0x00,0xff,0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a,0xad,0x04,0x00,0x00,
+0x14,0x60,0xff,0xf7,0x00,0x45,0x40,0x24,0x97,0x83,0x91,0xa6,0x97,0x85,0x91,0xa4,
+0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,
+0xa7,0x83,0x91,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,
+0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,
+0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x91,0xa0,0x10,0xa2,0xff,0xd4,
+0x00,0x00,0x00,0x00,0xa3,0x80,0x80,0x10,0x0c,0x00,0x03,0x95,0x00,0x00,0x00,0x00,
+0x08,0x00,0x02,0x30,0x00,0x00,0x00,0x00,0x97,0x82,0x8b,0x4e,0x00,0x00,0x00,0x00,
+0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0x4e,0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0x60,
+0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0x60,0x08,0x00,0x02,0x28,
+0x25,0x42,0x00,0x01,0x97,0x82,0x8b,0x4a,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,
+0xa7,0x82,0x8b,0x4a,0x84,0xa3,0x00,0x06,0x8f,0x82,0x8b,0x58,0x00,0x00,0x00,0x00,
+0x00,0x43,0x10,0x21,0xaf,0x82,0x8b,0x58,0x08,0x00,0x02,0x28,0x25,0x42,0x00,0x01,
+0x97,0x82,0x8b,0x44,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x8b,0x44,
+0x08,0x00,0x02,0x10,0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x27,0xbd,0xff,0xc8,0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x09,0xf8,
+0x3c,0x03,0xb0,0x00,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xb2,0x00,0x18,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21,0xaf,0xb7,0x00,0x2c,
+0xaf,0xb6,0x00,0x28,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,0xac,0xa2,0x00,0x00,
+0x8e,0x09,0x00,0x00,0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08,0x00,0x09,0xa6,0x02,
+0x12,0x80,0x00,0x13,0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02,0x3c,0x16,0x00,0xff,
+0x3c,0x17,0xff,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x12,0x02,
+0x24,0x42,0x00,0x02,0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76,0x30,0x51,0x00,0xff,
+0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00,0x02,0x51,0x10,0x21,
+0x30,0x52,0xff,0xff,0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2,0x02,0x11,0x80,0x21,
+0x12,0xa0,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,0x8c,0x43,0x00,0x00,
+0x3c,0x04,0x0f,0x00,0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24,0x10,0x62,0x00,0x03,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x03,0x95,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x30,
+0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04,0x24,0x15,0x00,0x01,
+0x8e,0x06,0x00,0x0c,0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2,0x30,0x48,0x00,0x03,
+0x00,0x09,0x14,0x02,0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02,0x11,0x15,0x00,0x45,
+0x30,0x43,0x00,0x0f,0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26,0x00,0x00,0x00,0x00,
+0x11,0x13,0x00,0x0f,0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02,0x30,0x84,0xff,0x00,
+0x3c,0x03,0x00,0xff,0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00,0x00,0x43,0x10,0x24,
+0x00,0xa4,0x28,0x25,0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00,0x00,0xa3,0x28,0x25,
+0x0c,0x00,0x01,0x9b,0x01,0x20,0x20,0x21,0x08,0x00,0x02,0xa4,0x02,0x51,0x10,0x21,
+0x11,0x95,0x00,0x0f,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07,0x00,0x00,0x00,0x00,
+0x00,0x04,0x10,0x80,0x27,0x83,0x91,0x50,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18,
+0x08,0x00,0x02,0xcb,0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40,0x27,0x83,0x91,0x58,
+0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x02,0x08,0x00,0x02,0xcb,0x00,0x07,0x22,0x02,
+0x27,0x82,0x91,0x50,0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00,0x08,0x00,0x02,0xcb,
+0x00,0x07,0x22,0x02,0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21,0x10,0x75,0x00,0x05,
+0x00,0x80,0x38,0x21,0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00,0x00,0x00,0x38,0x21,
+0x00,0x43,0x38,0x0a,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e,0x3c,0x02,0xb0,0x03,
+0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x00,0xe2,0x10,0x21,0x8c,0x47,0x00,0x00,0x08,0x00,0x02,0xcb,0x00,0x07,0x22,0x02,
+0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00,0x08,0x00,0x02,0xca,
+0x30,0x67,0xff,0xff,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00,0x08,0x00,0x02,0xca,
+0x30,0x67,0x00,0xff,0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00,0x11,0x95,0x00,0x07,
+0x00,0x44,0x38,0x21,0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x02,0xfc,
+0x3c,0x02,0xb0,0x0a,0x08,0x00,0x03,0x01,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x03,0x05,
+0x3c,0x02,0xb0,0x0a,0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08,0x8e,0x03,0x00,0x0c,
+0x00,0x09,0x41,0x42,0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02,0x30,0x84,0xff,0x00,
+0x30,0xe7,0xff,0x00,0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00,0x00,0x03,0x56,0x02,
+0x00,0x03,0x2a,0x00,0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24,0x01,0x47,0x50,0x25,
+0x00,0x02,0x16,0x00,0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00,0x01,0x66,0x58,0x25,
+0x01,0x45,0x50,0x25,0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24,0x01,0x62,0x38,0x25,
+0x01,0x43,0x30,0x25,0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02,0x31,0x08,0x00,0x03,
+0x30,0x4c,0x00,0x03,0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02,0x00,0xe0,0x58,0x21,
+0x15,0x00,0x00,0x28,0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x06,
+0x00,0x80,0x28,0x21,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69,0x02,0x51,0x10,0x21,
+0x24,0x85,0x01,0x00,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15,0x24,0x02,0x00,0x02,
+0x11,0x82,0x00,0x0a,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00,
+0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,
+0xac,0x62,0x00,0x00,0x08,0x00,0x02,0xa4,0x02,0x51,0x10,0x21,0x00,0xa3,0x18,0x21,
+0x94,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,
+0x00,0x45,0x10,0x25,0xa4,0x62,0x00,0x00,0x08,0x00,0x02,0xa4,0x02,0x51,0x10,0x21,
+0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,
+0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x02,0xa3,
+0xa0,0x62,0x00,0x00,0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21,0x00,0x00,0x00,0x00,
+0x15,0x13,0xff,0x42,0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17,0x00,0x00,0x00,0x00,
+0x11,0x88,0x00,0x0b,0x00,0x00,0x00,0x00,0x27,0x83,0x91,0x50,0x00,0x04,0x20,0x80,
+0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,
+0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x02,0xa3,0xac,0x82,0x00,0x18,
+0x27,0x83,0x91,0x58,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21,0x94,0x82,0x00,0x02,
+0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,
+0x08,0x00,0x02,0xa3,0xa4,0x82,0x00,0x02,0x27,0x83,0x91,0x50,0x00,0x83,0x18,0x21,
+0x90,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x03,0x59,0x00,0xe6,0x28,0x24,
+0x30,0x62,0x00,0x07,0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f,0x00,0x44,0x10,0x21,
+0x11,0x93,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,
+0x8c,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x03,0x46,0x00,0xe6,0x28,0x24,
+0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x06,0x20,0x27,
+0x08,0x00,0x03,0x4f,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x08,0x00,0x03,0x7c,
+0x00,0x43,0x18,0x21,0x97,0x85,0x91,0xa4,0x3c,0x07,0xb0,0x02,0x3c,0x04,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20,0x24,0x42,0x0e,0x54,
+0x24,0x03,0xff,0x80,0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07,0x97,0x82,0x91,0xa6,
+0x97,0x85,0x91,0xa4,0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8,0x24,0x42,0x00,0x10,
+0x00,0xa2,0x10,0x21,0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08,0x30,0x84,0x0f,0xff,
+0x00,0x05,0x28,0xc2,0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25,0x00,0x87,0x20,0x21,
+0x34,0xc6,0x80,0x18,0xac,0xc5,0x00,0x00,0xaf,0x84,0x91,0xa0,0xa7,0x82,0x91,0xa4,
+0xa7,0x80,0x91,0xa6,0xaf,0x80,0x91,0xa8,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x30,0xa5,0x00,0xff,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01,0x00,0xe0,0x48,0x21,
+0x30,0xc6,0x00,0xff,0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07,0x00,0xa0,0x40,0x21,
+0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03,0x24,0x02,0x00,0x01,
+0x00,0x07,0x20,0x27,0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14,0x01,0x03,0x18,0x21,
+0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27,0x3c,0x03,0xb0,0x03,
+0x01,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,
+0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xe0,0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x01,0x03,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,
+0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa0,0x62,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07,0x00,0x04,0x22,0x00,
+0x30,0xa5,0x00,0xff,0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a,0x00,0xa2,0x40,0x21,
+0x30,0xc6,0x00,0xff,0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10,0x10,0xc2,0x00,0x14,
+0x24,0x02,0x00,0x02,0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09,0x00,0xe4,0x48,0x24,
+0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,
+0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00,
+0x91,0x02,0x00,0x00,0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24,0x00,0x43,0x10,0x24,
+0x00,0x44,0x10,0x25,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00,0x30,0xa9,0x00,0xff,
+0x27,0x83,0x91,0x50,0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01,0x00,0x07,0x50,0x27,
+0x00,0xc7,0x40,0x24,0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21,0x00,0x05,0x20,0x40,
+0x27,0x82,0x91,0x50,0x00,0x05,0x28,0x80,0x27,0x83,0x91,0x58,0x00,0x83,0x50,0x21,
+0x00,0xa2,0x20,0x21,0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27,0x11,0x22,0x00,0x07,
+0x00,0xc7,0x28,0x24,0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,
+0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18,0x95,0x42,0x00,0x02,
+0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,
+0xa5,0x42,0x00,0x02,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,
+0x00,0x48,0x10,0x25,0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00,0x00,0x04,0x32,0x02,
+0x30,0xc6,0xff,0x00,0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00,0x3c,0x05,0x00,0xff,
+0x00,0x65,0x18,0x24,0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25,0x00,0x04,0x26,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x44,0x10,0x25,0x3c,0x02,0xb0,0x02,0x34,0x42,0x00,0x08,
+0x3c,0x03,0xb0,0x02,0xaf,0x82,0x8b,0x78,0xaf,0x83,0x8b,0x7c,0xa7,0x80,0x8b,0x80,
+0xa7,0x80,0x8b,0x82,0xaf,0x80,0x8b,0x84,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x27,0xbd,0xff,0xd8,0xaf,0xbf,0x00,0x20,0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,
+0x30,0x42,0xe0,0x00,0x10,0x40,0x00,0x05,0x00,0x80,0x18,0x21,0x8f,0xbf,0x00,0x20,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x90,0x84,0x00,0x02,
+0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xfc,0x0c,0x00,0x06,0xc9,0x00,0x64,0x20,0x21,
+0x08,0x00,0x04,0x47,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb2,0x00,0x18,
+0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,
+0x8f,0x90,0x91,0xa0,0x0c,0x00,0x2b,0xd1,0x00,0x80,0x90,0x21,0x00,0x40,0x88,0x21,
+0x93,0x82,0x82,0x20,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x24,0x02,0x00,0x01,
+0xa3,0x82,0x82,0x20,0x24,0x03,0x00,0x05,0x24,0x02,0x00,0x04,0xa3,0x83,0x8b,0x73,
+0xa3,0x82,0x8b,0x72,0xa7,0x80,0x82,0x22,0x00,0x00,0x28,0x21,0x27,0x86,0x8b,0x70,
+0x00,0x05,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01,
+0x30,0x65,0xff,0xff,0xae,0x04,0x00,0x00,0x10,0xa0,0xff,0xfa,0x00,0x05,0x10,0x80,
+0x8f,0x83,0x91,0xa0,0x97,0x82,0x91,0xa6,0x24,0x05,0x8f,0xff,0x24,0x63,0x00,0x04,
+0x00,0x65,0x18,0x24,0x26,0x04,0x00,0x04,0x24,0x42,0x00,0x04,0xaf,0x83,0x91,0xa0,
+0xa7,0x82,0x91,0xa6,0x00,0x85,0x80,0x24,0x97,0x84,0x82,0x22,0x27,0x93,0x80,0x2c,
+0x02,0x40,0x28,0x21,0x00,0x93,0x20,0x21,0x0c,0x00,0x2c,0x55,0x02,0x20,0x30,0x21,
+0x97,0x87,0x82,0x22,0x24,0x02,0x00,0x52,0x00,0xf1,0x18,0x21,0xa7,0x83,0x82,0x22,
+0x82,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x06,0x00,0x60,0x38,0x21,
+0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x28,0x82,0x43,0x00,0x01,0x24,0x02,0x00,0x54,0x14,0x62,0xff,0xf8,
+0x24,0x02,0x00,0x4c,0x82,0x43,0x00,0x02,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xf4,
+0x00,0x00,0x00,0x00,0x30,0xe6,0xff,0xff,0x10,0xc0,0x00,0x0c,0x00,0x00,0x28,0x21,
+0x02,0x60,0x48,0x21,0x24,0x08,0x8f,0xff,0x00,0xa9,0x10,0x21,0x8c,0x44,0x00,0x00,
+0x24,0xa3,0x00,0x04,0x30,0x65,0xff,0xff,0x26,0x02,0x00,0x04,0x00,0xa6,0x18,0x2b,
+0xae,0x04,0x00,0x00,0x14,0x60,0xff,0xf8,0x00,0x48,0x80,0x24,0x97,0x83,0x91,0xa6,
+0x97,0x85,0x91,0xa4,0x3c,0x02,0xb0,0x02,0x00,0x67,0x18,0x21,0x00,0xa2,0x28,0x21,
+0x3c,0x04,0xb0,0x06,0xa7,0x83,0x91,0xa6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,
+0x8f,0x82,0x91,0xa0,0x8c,0x86,0x00,0x00,0x30,0xe5,0xff,0xff,0x24,0x03,0x8f,0xff,
+0x00,0x45,0x10,0x21,0x3c,0x04,0x0f,0x00,0x00,0x43,0x10,0x24,0x00,0xc4,0x30,0x24,
+0x3c,0x03,0x04,0x00,0xaf,0x82,0x91,0xa0,0x10,0xc3,0xff,0xd1,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x03,0x95,0x00,0x00,0x00,0x00,0xa3,0x80,0x82,0x20,0x08,0x00,0x04,0x88,
+0x00,0x00,0x00,0x00,0x8f,0x82,0x8b,0x7c,0x97,0x83,0x8b,0x80,0x8f,0x87,0x8b,0x78,
+0x3c,0x06,0xff,0xff,0xac,0x43,0x00,0x00,0x8f,0x82,0x8b,0x7c,0x3c,0x03,0x80,0x00,
+0x24,0xe5,0x00,0x08,0xac,0x43,0x00,0x04,0x8f,0x82,0x8b,0x7c,0x34,0xc6,0x1f,0xff,
+0x3c,0x03,0x00,0x40,0x30,0x42,0x0f,0xff,0x3c,0x04,0xb0,0x06,0x00,0x02,0x10,0xc2,
+0x00,0x43,0x10,0x25,0x00,0xa6,0x28,0x24,0x34,0x84,0x80,0x18,0x27,0xbd,0xff,0xf8,
+0xac,0x82,0x00,0x00,0xaf,0x85,0x8b,0x78,0xaf,0x87,0x8b,0x7c,0xa7,0x80,0x8b,0x80,
+0xa7,0x80,0x8b,0x82,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x8f,0x91,0x8b,0x78,
+0x00,0x80,0x80,0x21,0xaf,0xbf,0x00,0x1c,0x0c,0x00,0x05,0x78,0x00,0xa0,0x90,0x21,
+0x97,0x82,0x8b,0x80,0x36,0x10,0x12,0x00,0x26,0x2a,0x00,0x04,0x24,0x4c,0x00,0x14,
+0x2c,0x42,0x04,0x01,0x14,0x40,0x00,0x0a,0x24,0x09,0x8f,0xff,0x8f,0x82,0x80,0x18,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x80,0x18,0x8f,0xbf,0x00,0x1c,
+0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x8e,0x44,0x00,0x1c,0x86,0x47,0x00,0x06,0x97,0x86,0x8b,0x82,0x8c,0x82,0x00,0x08,
+0x00,0x07,0x3c,0x00,0x8f,0x85,0x8b,0x78,0x00,0x02,0x11,0x02,0x30,0x42,0x40,0x00,
+0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x8c,0x82,0x00,0x04,0x82,0x43,0x00,0x15,
+0x01,0x49,0x88,0x24,0x00,0x02,0x14,0xc2,0x00,0x03,0x1a,0x00,0x00,0x02,0x14,0x00,
+0x00,0x62,0x80,0x25,0xae,0x30,0x00,0x00,0x92,0x43,0x00,0x13,0x92,0x44,0x00,0x10,
+0x96,0x50,0x00,0x1a,0x00,0x03,0x1c,0x00,0x00,0x04,0x26,0x00,0x02,0x03,0x80,0x25,
+0x26,0x22,0x00,0x04,0x00,0x49,0x88,0x24,0x02,0x04,0x80,0x25,0xae,0x30,0x00,0x00,
+0x92,0x42,0x00,0x0f,0x92,0x43,0x00,0x11,0x26,0x24,0x00,0x04,0x00,0x02,0x12,0x00,
+0x00,0x89,0x88,0x24,0x00,0x62,0x80,0x25,0x02,0x07,0x80,0x25,0x26,0x22,0x00,0x04,
+0xae,0x30,0x00,0x00,0x00,0x49,0x88,0x24,0xae,0x20,0x00,0x00,0x8f,0x82,0x80,0x14,
+0x24,0xc6,0x00,0x01,0x24,0xa5,0x00,0x14,0x30,0xc8,0xff,0xff,0x3c,0x0b,0xb0,0x03,
+0x00,0xa9,0x28,0x24,0x24,0x42,0x00,0x01,0x2d,0x08,0x00,0x0a,0xaf,0x85,0x8b,0x78,
+0xa7,0x8c,0x8b,0x80,0xaf,0x82,0x80,0x14,0xa7,0x86,0x8b,0x82,0x11,0x00,0x00,0x07,
+0x35,0x6b,0x01,0x08,0x8f,0x82,0x8b,0x84,0x8d,0x63,0x00,0x00,0x24,0x42,0x04,0x00,
+0x00,0x62,0x18,0x2b,0x14,0x60,0xff,0xc1,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0xbd,
+0x00,0x00,0x00,0x00,0x08,0x00,0x04,0xf3,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,
+0xaf,0xbf,0x00,0x10,0x0c,0x00,0x05,0x78,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe0,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,
+0x8f,0x90,0x8b,0x78,0x0c,0x00,0x05,0x78,0x00,0x80,0x90,0x21,0x97,0x82,0x8b,0x80,
+0x24,0x11,0x8f,0xff,0x2c,0x42,0x04,0x01,0x14,0x40,0x00,0x06,0x26,0x03,0x00,0x04,
+0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x71,0x80,0x24,
+0xae,0x00,0x00,0x00,0x8e,0x44,0x00,0x08,0x26,0x02,0x00,0x04,0x0c,0x00,0x05,0x86,
+0x00,0x51,0x80,0x24,0x97,0x86,0x8b,0x82,0x8f,0x83,0x8b,0x78,0xae,0x02,0x00,0x00,
+0x97,0x82,0x8b,0x80,0x24,0xc6,0x00,0x01,0x8e,0x47,0x00,0x0c,0x24,0x63,0x00,0x10,
+0x30,0xc5,0xff,0xff,0x26,0x04,0x00,0x04,0x3c,0x08,0xb0,0x03,0x00,0x71,0x18,0x24,
+0x00,0x91,0x80,0x24,0x24,0x42,0x00,0x10,0x2c,0xa5,0x00,0x0a,0x35,0x08,0x01,0x08,
+0xae,0x07,0x00,0x00,0xaf,0x83,0x8b,0x78,0xa7,0x82,0x8b,0x80,0xa7,0x86,0x8b,0x82,
+0x10,0xa0,0x00,0x07,0x00,0x00,0x00,0x00,0x8f,0x82,0x8b,0x84,0x8d,0x03,0x00,0x00,
+0x24,0x42,0x04,0x00,0x00,0x62,0x18,0x2b,0x14,0x60,0xff,0xd9,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x04,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x05,0x4c,0x00,0x00,0x00,0x00,
+0x97,0x82,0x8b,0x82,0x3c,0x03,0xb0,0x03,0x14,0x40,0x00,0x09,0x34,0x63,0x01,0x08,
+0x8c,0x62,0x00,0x00,0x8f,0x83,0x8b,0x7c,0xa7,0x80,0x8b,0x80,0xaf,0x82,0x8b,0x84,
+0xac,0x60,0x00,0x00,0x8f,0x82,0x8b,0x7c,0x00,0x00,0x00,0x00,0xac,0x40,0x00,0x04,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,
+0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00,0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,
+0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25,0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x44,0x10,0x25,0x80,0x82,0x00,0x00,0x90,0x83,0x00,0x00,0x10,0x40,0x00,0x0c,
+0x00,0x80,0x28,0x21,0x24,0x62,0xff,0x9f,0x30,0x42,0x00,0xff,0x2c,0x42,0x00,0x1a,
+0x10,0x40,0x00,0x02,0x24,0x63,0xff,0xe0,0xa0,0xa3,0x00,0x00,0x24,0xa5,0x00,0x01,
+0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xf6,0x00,0x40,0x18,0x21,
+0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x80,0x82,0x00,0x00,0x90,0x83,0x00,0x00,
+0x10,0x40,0x00,0x0c,0x00,0x80,0x28,0x21,0x24,0x62,0xff,0xbf,0x30,0x42,0x00,0xff,
+0x2c,0x42,0x00,0x1a,0x10,0x40,0x00,0x02,0x24,0x63,0x00,0x20,0xa0,0xa3,0x00,0x00,
+0x24,0xa5,0x00,0x01,0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xf6,
+0x00,0x40,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x27,0xbd,0xff,0xe8,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x24,0x10,0xff,0xff,0x0c,0x00,0x29,0x11,
+0x00,0x00,0x00,0x00,0x10,0x50,0xff,0xfd,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,
+0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x27,0xbd,0xff,0xc8,0xaf,0xb3,0x00,0x1c,0x00,0x00,0x98,0x21,0xaf,0xb1,0x00,0x14,
+0x02,0x65,0x88,0x2b,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x34,0xaf,0xbe,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb4,0x00,0x20,
+0xaf,0xb2,0x00,0x18,0x00,0xa0,0xb0,0x21,0xaf,0xa4,0x00,0x38,0x00,0xc0,0xa8,0x21,
+0x12,0x20,0x00,0x17,0x00,0x80,0x80,0x21,0x24,0x17,0xff,0xff,0x24,0x1e,0x00,0x0a,
+0x0c,0x00,0x29,0x11,0x00,0x00,0x00,0x00,0x10,0x57,0x00,0x0f,0x00,0x02,0x16,0x00,
+0x00,0x02,0x26,0x03,0x10,0x9e,0x00,0x0e,0x24,0x02,0x00,0x0d,0x10,0x82,0x00,0x34,
+0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x25,0x24,0x02,0x00,0x09,0x10,0x82,0x00,0x13,
+0x00,0x00,0x90,0x21,0xa2,0x04,0x00,0x00,0x26,0x73,0x00,0x01,0x16,0xa0,0x00,0x0b,
+0x26,0x10,0x00,0x01,0x02,0x76,0x88,0x2b,0x16,0x20,0xff,0xed,0x00,0x00,0x00,0x00,
+0x7b,0xbe,0x01,0xbc,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x0c,0x00,0x29,0x04,
+0x02,0x76,0x88,0x2b,0x08,0x00,0x05,0xe6,0x00,0x00,0x00,0x00,0x24,0x14,0x00,0x20,
+0xa2,0x14,0x00,0x00,0x26,0x52,0x00,0x01,0x24,0x04,0x00,0x20,0x26,0x73,0x00,0x01,
+0x16,0xa0,0x00,0x06,0x26,0x10,0x00,0x01,0x2a,0x42,0x00,0x08,0x10,0x40,0xff,0xea,
+0x02,0x76,0x88,0x2b,0x08,0x00,0x05,0xf5,0xa2,0x14,0x00,0x00,0x0c,0x00,0x29,0x04,
+0x00,0x00,0x00,0x00,0x08,0x00,0x05,0xfb,0x2a,0x42,0x00,0x08,0x8f,0xa2,0x00,0x38,
+0x00,0x00,0x00,0x00,0x12,0x02,0xff,0xe0,0x00,0x00,0x00,0x00,0x26,0x10,0xff,0xff,
+0x12,0xa0,0xff,0xdc,0x26,0x73,0xff,0xff,0x0c,0x00,0x29,0x04,0x24,0x04,0x00,0x08,
+0x0c,0x00,0x29,0x04,0x24,0x04,0x00,0x20,0x08,0x00,0x05,0xef,0x24,0x04,0x00,0x08,
+0x08,0x00,0x05,0xe8,0xa2,0x00,0x00,0x00,0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x1e,0x00,0x10,0x60,0x00,0x16,0x00,0x00,0x30,0x21,0x24,0x07,0x00,0x20,
+0x00,0x03,0x1e,0x03,0x10,0x67,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x15,
+0x00,0x00,0x00,0x00,0x10,0x67,0x00,0x0b,0x24,0xc6,0x00,0x01,0x10,0x60,0x00,0x0a,
+0x00,0x02,0x1e,0x00,0x24,0x05,0x00,0x20,0x24,0x84,0x00,0x01,0x80,0x83,0x00,0x00,
+0x90,0x82,0x00,0x00,0x10,0x65,0x00,0x03,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xfa,
+0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,0x14,0x60,0xff,0xed,0x00,0x00,0x00,0x00,
+0x28,0xc3,0x00,0x08,0x24,0x02,0x00,0x07,0x00,0x43,0x30,0x0a,0x03,0xe0,0x00,0x08,
+0x00,0xc0,0x10,0x21,0x24,0x84,0x00,0x01,0x90,0x82,0x00,0x00,0x08,0x00,0x06,0x2a,
+0x00,0x02,0x1e,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb1,0x00,0x14,0x27,0x91,0x8b,0x88,
+0xaf,0xb0,0x00,0x10,0x24,0x06,0x00,0x20,0x00,0x80,0x80,0x21,0x00,0x00,0x28,0x21,
+0xaf,0xbf,0x00,0x18,0x0c,0x00,0x2c,0x4b,0x02,0x20,0x20,0x21,0x82,0x02,0x00,0x00,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1f,0x00,0x00,0x30,0x21,0x02,0x20,0x20,0x21,
+0x24,0x09,0x00,0x20,0x24,0x08,0x00,0x20,0x24,0x07,0x00,0x08,0xac,0x90,0x00,0x00,
+0x82,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x49,0x00,0x0a,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x08,0x24,0x03,0x00,0x20,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00,
+0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x03,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfa,
+0x00,0x00,0x00,0x00,0xa2,0x00,0x00,0x00,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00,
+0x92,0x03,0x00,0x00,0x10,0x48,0x00,0x0c,0x24,0x05,0x00,0x20,0x24,0xc6,0x00,0x01,
+0x10,0xc7,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x03,0x16,0x00,0x14,0x40,0xff,0xe7,
+0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x27,0x82,0x8b,0x88,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x26,0x10,0x00,0x01,0x82,0x02,0x00,0x00,
+0x92,0x03,0x00,0x00,0x10,0x45,0xff,0xfc,0x00,0x00,0x00,0x00,0x08,0x00,0x06,0x5c,
+0x24,0xc6,0x00,0x01,0x00,0x80,0x30,0x21,0x90,0x84,0x00,0x00,0x00,0x00,0x38,0x21,
+0x10,0x80,0x00,0x19,0x24,0xc6,0x00,0x01,0x24,0x82,0xff,0xd0,0x30,0x42,0x00,0xff,
+0x2c,0x43,0x00,0x0a,0x14,0x60,0x00,0x0c,0x00,0x07,0x19,0x00,0x24,0x83,0xff,0x9f,
+0x24,0x82,0xff,0xa9,0x24,0x88,0xff,0xc9,0x2c,0x63,0x00,0x06,0x24,0x84,0xff,0xbf,
+0x2c,0x84,0x00,0x06,0x14,0x60,0x00,0x03,0x30,0x42,0x00,0xff,0x10,0x80,0x00,0x0e,
+0x31,0x02,0x00,0xff,0x00,0x07,0x19,0x00,0x00,0x62,0x18,0x21,0x00,0x67,0x10,0x2b,
+0x14,0x40,0x00,0x07,0x00,0x00,0x20,0x21,0x90,0xc4,0x00,0x00,0x00,0x60,0x38,0x21,
+0x14,0x80,0xff,0xe9,0x24,0xc6,0x00,0x01,0xac,0xa7,0x00,0x00,0x24,0x04,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x08,0x00,0x06,0x8c,0x00,0x00,0x20,0x21,
+0x00,0x00,0x20,0x21,0x27,0x85,0x91,0xc0,0x24,0x82,0x00,0x01,0x00,0x04,0x18,0x80,
+0x30,0x44,0x00,0xff,0x00,0x65,0x18,0x21,0x2c,0x82,0x00,0x0b,0x14,0x40,0xff,0xfa,
+0xac,0x60,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x84,0x8c,0x08,
+0xaf,0x85,0x8c,0x0c,0xaf,0x86,0x8c,0x10,0xaf,0x87,0x8c,0x14,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x90,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
+0x2c,0x43,0x00,0x64,0x24,0x42,0x00,0x01,0x27,0x84,0x8b,0xa8,0xaf,0x82,0x84,0x90,
+0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0xaf,0x80,0x84,0x90,0x0c,0x00,0x06,0xf6,
+0x00,0x00,0x00,0x00,0x00,0x40,0x18,0x21,0x28,0x44,0x00,0x08,0x24,0x02,0x00,0x07,
+0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x80,0xff,0xf3,0x24,0x02,0x00,0x08,
+0x27,0x84,0x8b,0xa8,0x14,0x62,0xff,0xf0,0x00,0x00,0x00,0x00,0x0c,0x00,0x17,0xb0,
+0x00,0x00,0x00,0x00,0x27,0x84,0x8b,0xa8,0x0c,0x00,0x07,0x54,0x00,0x00,0x00,0x00,
+0x8f,0x83,0x84,0x94,0x3c,0x04,0x80,0x01,0x00,0x60,0x28,0x21,0x24,0x63,0x00,0x01,
+0xaf,0x83,0x84,0x94,0x0c,0x00,0x17,0x9d,0x24,0x84,0x04,0x88,0x08,0x00,0x06,0xaa,
+0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xbf,0x00,0x38,0x8c,0x85,0x00,0x0c,
+0x8c,0x88,0x00,0x08,0x18,0xa0,0x00,0x0e,0x00,0x00,0x30,0x21,0x24,0x87,0x00,0x08,
+0x27,0xa9,0x00,0x10,0x00,0x06,0x10,0x80,0x00,0x06,0x19,0x00,0x00,0x49,0x10,0x21,
+0x14,0xc0,0x00,0x1f,0x00,0x83,0x18,0x21,0xaf,0xa7,0x00,0x10,0x24,0xc2,0x00,0x01,
+0x30,0x46,0x00,0xff,0x00,0xc5,0x18,0x2a,0x14,0x60,0xff,0xf7,0x00,0x06,0x10,0x80,
+0x29,0x02,0x00,0x0a,0x14,0x40,0x00,0x05,0x00,0x08,0x18,0x40,0x8f,0xbf,0x00,0x38,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x00,0x68,0x18,0x21,
+0x27,0x82,0x83,0x8c,0x00,0x03,0x18,0xc0,0x00,0x62,0x18,0x21,0x8c,0x62,0x00,0x10,
+0x01,0x00,0x20,0x21,0x00,0x40,0xf8,0x09,0x27,0xa6,0x00,0x10,0x8f,0x83,0x84,0xa8,
+0x3c,0x04,0x80,0x01,0x00,0x60,0x28,0x21,0x24,0x63,0x00,0x01,0xaf,0x83,0x84,0xa8,
+0x0c,0x00,0x17,0x9d,0x24,0x84,0x04,0x9c,0x08,0x00,0x06,0xdf,0x00,0x00,0x00,0x00,
+0x08,0x00,0x06,0xd7,0xac,0x43,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb1,0x00,0x14,
+0xaf,0xbf,0x00,0x18,0x00,0x80,0x88,0x21,0x0c,0x00,0x17,0xd4,0xaf,0xb0,0x00,0x10,
+0x00,0x40,0x20,0x21,0x24,0x02,0xff,0xff,0x10,0x82,0x00,0x1f,0x24,0x03,0x00,0x06,
+0x8f,0x85,0x84,0xbc,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x0a,0x24,0x02,0x00,0x08,
+0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x3b,0x28,0x82,0x00,0x03,0x10,0x40,0x00,0x32,
+0x24,0x02,0x00,0x1b,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x13,0x24,0x03,0x00,0x08,
+0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x23,0x24,0x02,0x00,0x0d,0x10,0x82,0x00,0x18,
+0x02,0x25,0x10,0x21,0x24,0xa3,0x00,0x01,0xa0,0x44,0x00,0x00,0xaf,0x83,0x84,0xbc,
+0x18,0x60,0x00,0x08,0x24,0x02,0x00,0x43,0x82,0x23,0x00,0x00,0x00,0x00,0x00,0x00,
+0x10,0x62,0x00,0x0a,0x00,0x00,0x00,0x00,0x30,0x84,0xff,0xff,0x0c,0x00,0x17,0xd0,
+0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x06,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,
+0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x04,0x80,0x01,
+0x0c,0x00,0x17,0xb0,0x24,0x84,0x04,0xb0,0x08,0x00,0x07,0x1e,0x24,0x03,0x00,0x06,
+0xa0,0x40,0x00,0x00,0x24,0xa5,0x00,0x01,0xaf,0x85,0x84,0xbc,0x0c,0x00,0x17,0xd0,
+0x24,0x04,0x00,0x0d,0x24,0x03,0x00,0x07,0xaf,0x80,0x84,0xbc,0x08,0x00,0x07,0x1e,
+0x00,0x00,0x00,0x00,0x18,0xa0,0xff,0xeb,0x24,0xa5,0xff,0xff,0xaf,0x85,0x84,0xbc,
+0x0c,0x00,0x17,0xd0,0x24,0x04,0x00,0x08,0x0c,0x00,0x17,0xd0,0x24,0x04,0x00,0x20,
+0x08,0x00,0x07,0x1b,0x24,0x04,0x00,0x08,0x14,0x82,0xff,0xd2,0x24,0x02,0x00,0x08,
+0x0c,0x00,0x06,0x90,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0xbc,0x08,0x00,0x07,0x0c,
+0x24,0x04,0x00,0x0d,0x0c,0x00,0x2b,0xd1,0x02,0x20,0x20,0x21,0xaf,0x82,0x84,0xbc,
+0x04,0x40,0x00,0x0d,0x00,0x00,0x80,0x21,0x02,0x30,0x10,0x21,0x90,0x44,0x00,0x00,
+0x26,0x10,0x00,0x01,0x00,0x04,0x26,0x00,0x00,0x04,0x26,0x03,0x0c,0x00,0x17,0xd0,
+0x30,0x84,0xff,0xff,0x8f,0x83,0x84,0xbc,0x00,0x00,0x00,0x00,0x00,0x70,0x18,0x2a,
+0x10,0x60,0xff,0xf6,0x02,0x30,0x10,0x21,0x08,0x00,0x07,0x2e,0x24,0x03,0x00,0x06,
+0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x27,0x83,0x8b,0xe8,0x24,0x02,0x00,0x07,
+0x24,0x42,0xff,0xff,0xac,0x60,0x00,0x00,0x04,0x41,0xff,0xfd,0x24,0x63,0x00,0x04,
+0x0c,0x00,0x07,0x66,0x00,0x00,0x00,0x00,0x8f,0x84,0x8b,0xe8,0x27,0x86,0x8b,0xe8,
+0x0c,0x00,0x07,0x83,0x00,0x40,0x28,0x21,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe0,0x00,0x80,0x28,0x21,
+0x27,0x84,0x8b,0xc8,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0x0c,0x00,0x2c,0x62,
+0xaf,0xb0,0x00,0x10,0x8f,0x85,0x83,0x2c,0x27,0x84,0x8b,0xc8,0x0c,0x00,0x2c,0x26,
+0x00,0x00,0x88,0x21,0x10,0x40,0x00,0x0c,0x00,0x00,0x00,0x00,0x27,0x90,0x8b,0xe8,
+0x8f,0x85,0x83,0x2c,0x00,0x00,0x20,0x21,0xae,0x02,0x00,0x00,0x0c,0x00,0x2c,0x26,
+0x26,0x31,0x00,0x01,0x26,0x10,0x00,0x04,0x10,0x40,0x00,0x03,0x2a,0x23,0x00,0x64,
+0x14,0x60,0xff,0xf7,0x00,0x00,0x00,0x00,0x02,0x20,0x10,0x21,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd0,
+0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xbf,0x00,0x2c,
+0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,
+0x00,0xa0,0xa8,0x21,0x00,0x80,0xa0,0x21,0x00,0xc0,0xb0,0x21,0x10,0xa0,0x00,0x1d,
+0x24,0x02,0x00,0x05,0x3c,0x02,0x80,0x00,0x24,0x43,0x29,0x1c,0x8f,0x82,0x83,0x9c,
+0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x1e,0x00,0x00,0x88,0x21,0x00,0x60,0x98,0x21,
+0x00,0x00,0x90,0x21,0x27,0x90,0x83,0x9c,0x8e,0x05,0xff,0xec,0x02,0x80,0x20,0x21,
+0x0c,0x00,0x2c,0x6a,0x26,0x10,0x00,0x18,0x10,0x40,0x00,0x06,0x02,0x51,0x18,0x21,
+0x8e,0x02,0x00,0x00,0x26,0x31,0x00,0x01,0x14,0x53,0xff,0xf7,0x00,0x11,0x90,0x40,
+0x02,0x51,0x18,0x21,0x27,0x82,0x83,0x8c,0x00,0x03,0x18,0xc0,0x00,0x62,0x18,0x21,
+0x8c,0x62,0x00,0x10,0x02,0x20,0x20,0x21,0x02,0xa0,0x28,0x21,0x00,0x40,0xf8,0x09,
+0x02,0xc0,0x30,0x21,0x8f,0xbf,0x00,0x2c,0x8f,0xb6,0x00,0x28,0x7b,0xb4,0x01,0x3c,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
+0x08,0x00,0x07,0xa4,0x00,0x00,0x90,0x21,0x27,0xbd,0xff,0xc0,0xaf,0xb5,0x00,0x34,
+0xaf,0xb3,0x00,0x2c,0xaf,0xb1,0x00,0x24,0xaf,0xbf,0x00,0x38,0xaf,0xb4,0x00,0x30,
+0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,0x00,0xc0,0x98,0x21,0x30,0xa5,0x00,0xff,
+0xac,0xc0,0x00,0x00,0x24,0x15,0x00,0x0a,0x00,0x00,0x88,0x21,0x27,0xa8,0x00,0x10,
+0x00,0x91,0x18,0x21,0x80,0x62,0x00,0x00,0x26,0x27,0x00,0x01,0x10,0x40,0x00,0x0c,
+0x01,0x11,0x30,0x21,0x90,0x63,0x00,0x00,0x30,0xf1,0x00,0xff,0x2e,0x22,0x00,0x0a,
+0x14,0x40,0xff,0xf7,0xa0,0xc3,0x00,0x00,0x8f,0xbf,0x00,0x38,0x7b,0xb4,0x01,0xbc,
+0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,
+0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x23,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x1f,
+0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x1a,0x00,0x00,0x00,0x00,0x02,0x20,0x90,0x21,
+0x12,0x40,0xff,0xf1,0x00,0x00,0x88,0x21,0x27,0xb4,0x00,0x10,0x02,0x91,0x10,0x21,
+0x90,0x44,0x00,0x00,0x0c,0x00,0x08,0x0a,0x00,0x00,0x00,0x00,0x02,0x51,0x20,0x23,
+0x24,0x84,0xff,0xff,0x30,0x84,0x00,0xff,0x02,0xa0,0x28,0x21,0x0c,0x00,0x07,0xfb,
+0x00,0x40,0x80,0x21,0x02,0x02,0x00,0x18,0x8e,0x63,0x00,0x00,0x26,0x22,0x00,0x01,
+0x30,0x51,0x00,0xff,0x02,0x32,0x20,0x2b,0x00,0x00,0x80,0x12,0x00,0x70,0x18,0x21,
+0x14,0x80,0xff,0xee,0xae,0x63,0x00,0x00,0x08,0x00,0x07,0xce,0x00,0x00,0x00,0x00,
+0x80,0x82,0x00,0x00,0x08,0x00,0x07,0xce,0xae,0x62,0x00,0x00,0x08,0x00,0x07,0xdb,
+0x24,0x15,0x00,0x10,0x08,0x00,0x07,0xdb,0x24,0x15,0x00,0x0a,0x30,0x84,0x00,0xff,
+0x30,0xa5,0x00,0xff,0x24,0x06,0x00,0x01,0x10,0x80,0x00,0x09,0x00,0x00,0x10,0x21,
+0x00,0xc5,0x00,0x18,0x24,0x42,0x00,0x01,0x30,0x42,0x00,0xff,0x00,0x44,0x18,0x2b,
+0x00,0x00,0x30,0x12,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xfa,0x00,0xc5,0x00,0x18,
+0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x30,0x84,0x00,0xff,0x24,0x83,0xff,0xd0,
+0x30,0x62,0x00,0xff,0x2c,0x42,0x00,0x0a,0x14,0x40,0x00,0x06,0x00,0x00,0x00,0x00,
+0x24,0x82,0xff,0xbf,0x2c,0x42,0x00,0x06,0x14,0x40,0x00,0x02,0x24,0x83,0xff,0xc9,
+0x24,0x83,0xff,0xa9,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xc8,
+0x24,0x02,0x00,0x01,0xaf,0xbf,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,
+0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0x10,0xa2,0x00,0x3e,
+0xaf,0xb0,0x00,0x18,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08,0x24,0x05,0x00,0x01,
+0x00,0x00,0x10,0x21,0x8f,0xbf,0x00,0x30,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,
+0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8c,0xc4,0x00,0x04,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x10,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,
+0x28,0x42,0x00,0x65,0x14,0x40,0x00,0x06,0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01,
+0x0c,0x00,0x17,0xb0,0x24,0x84,0x04,0xb4,0x08,0x00,0x08,0x25,0x24,0x02,0x00,0x01,
+0x3c,0x04,0x80,0x01,0x0c,0x00,0x17,0xb0,0x24,0x84,0x04,0xc0,0x8f,0x83,0x83,0x9c,
+0x3c,0x02,0x80,0x00,0x24,0x42,0x29,0x1c,0x10,0x62,0xff,0xe5,0x00,0x40,0x90,0x21,
+0x3c,0x13,0x80,0x01,0x27,0x95,0x83,0x88,0x3c,0x14,0x80,0x01,0x27,0x90,0x83,0x8c,
+0x00,0x00,0x88,0x21,0x8e,0x03,0x00,0x08,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,
+0x10,0x62,0x00,0x08,0x26,0x64,0x04,0xcc,0x26,0x10,0x00,0x18,0x8e,0x02,0x00,0x10,
+0x00,0x00,0x00,0x00,0x14,0x52,0xff,0xf7,0x26,0x31,0x00,0x18,0x08,0x00,0x08,0x25,
+0x00,0x00,0x10,0x21,0x0c,0x00,0x17,0xb0,0x00,0x00,0x00,0x00,0x02,0x35,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x0c,0x00,0x17,0xb0,0x00,0x00,0x00,0x00,0x0c,0x00,0x17,0xb0,
+0x26,0x84,0x04,0xd0,0x8e,0x04,0x00,0x00,0x0c,0x00,0x17,0xb0,0x26,0x10,0x00,0x18,
+0x08,0x00,0x08,0x4b,0x00,0x00,0x00,0x00,0x3c,0x04,0x80,0x01,0x0c,0x00,0x17,0xb0,
+0x24,0x84,0x04,0xd4,0x3c,0x04,0x80,0x01,0x0c,0x00,0x17,0x9d,0x24,0x84,0x04,0xe4,
+0x24,0x11,0x00,0x05,0x3c,0x12,0x80,0x01,0x27,0x90,0x88,0x8e,0x86,0x05,0x00,0x00,
+0x26,0x44,0x05,0x04,0x0c,0x00,0x17,0x9d,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xfb,
+0x26,0x10,0xff,0xfe,0x08,0x00,0x08,0x25,0x00,0x00,0x10,0x21,0x27,0xbd,0xff,0xd0,
+0x28,0xa2,0x00,0x02,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x2c,
+0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0x00,0xa0,0x80,0x21,
+0x14,0x40,0x00,0x51,0x00,0xc0,0x88,0x21,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x02,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x10,0x24,0x02,0x00,0x02,0x12,0x02,0x00,0x48,
+0x24,0x05,0x00,0x01,0x8e,0x24,0x00,0x08,0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x14,
+0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x30,0x42,0x0f,0xff,0xaf,0xa2,0x00,0x14,
+0x7b,0xa4,0x00,0xbc,0x0c,0x00,0x09,0x06,0x24,0x06,0x00,0x04,0x24,0x03,0x00,0x04,
+0x10,0x43,0x00,0x2a,0x24,0x04,0x00,0x04,0x8f,0xa2,0x00,0x10,0x3c,0x04,0x80,0x01,
+0x24,0x84,0x05,0x08,0x00,0x02,0x19,0x02,0x00,0x03,0x81,0x00,0x8f,0xa3,0x00,0x14,
+0x00,0x50,0x10,0x23,0x00,0x02,0x10,0x82,0x00,0x62,0x18,0x21,0x0c,0x00,0x17,0xb0,
+0xaf,0xa3,0x00,0x14,0x3c,0x04,0x80,0x01,0x0c,0x00,0x17,0xb0,0x24,0x84,0x05,0x30,
+0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x00,0x00,0x88,0x21,
+0x3c,0x13,0x80,0x01,0x3c,0x12,0x80,0x01,0x3c,0x14,0x80,0x01,0x0c,0x00,0x29,0xa1,
+0x24,0x04,0x27,0x10,0x32,0x23,0x00,0x03,0x02,0x00,0x28,0x21,0x10,0x60,0x00,0x1c,
+0x26,0x64,0x05,0x5c,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,0x02,0x02,0x10,0x23,
+0x28,0x42,0xff,0xfd,0x10,0x40,0x00,0x10,0x26,0x44,0x05,0x68,0x0c,0x00,0x17,0xb0,
+0x26,0x10,0x00,0x04,0x8f,0xa2,0x00,0x14,0x26,0x31,0x00,0x01,0x02,0x22,0x10,0x2b,
+0x14,0x40,0xff,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x21,0x8f,0xbf,0x00,0x2c,
+0x8f,0xb4,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x80,0x10,0x21,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x8e,0x05,0x00,0x00,0x26,0x84,0x05,0x6c,
+0x0c,0x00,0x17,0x9d,0x26,0x10,0x00,0x04,0x08,0x00,0x08,0xb1,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x17,0x9d,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0xa9,0x00,0x00,0x00,0x00,
+0x08,0x00,0x08,0x87,0x24,0x02,0x00,0x01,0x0c,0x00,0x0a,0x52,0x00,0x00,0x00,0x00,
+0x08,0x00,0x08,0xb7,0x24,0x04,0x00,0x04,0x27,0xbd,0xff,0xd0,0x28,0xa2,0x00,0x03,
+0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x28,0x00,0xa0,0x88,0x21,
+0x10,0x40,0x00,0x09,0x00,0xc0,0x80,0x21,0x0c,0x00,0x0a,0x52,0x00,0x00,0x00,0x00,
+0x24,0x04,0x00,0x04,0x8f,0xbf,0x00,0x28,0x7b,0xb0,0x01,0x3c,0x00,0x80,0x10,0x21,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x02,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x02,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x14,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x1b,
+0x24,0x05,0x00,0x01,0x8e,0x04,0x00,0x0c,0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x18,
+0x8f,0xa4,0x00,0x10,0x8f,0xa5,0x00,0x18,0x0c,0x00,0x09,0x06,0x24,0x06,0x00,0x04,
+0x24,0x03,0x00,0x04,0x10,0x43,0xff,0xe7,0x24,0x04,0x00,0x04,0x8f,0xa2,0x00,0x18,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b,0x00,0x00,0x28,0x21,0x8f,0xa2,0x00,0x10,
+0x8f,0xa4,0x00,0x14,0x24,0xa5,0x00,0x01,0xac,0x44,0x00,0x00,0x8f,0xa3,0x00,0x10,
+0x8f,0xa2,0x00,0x18,0x24,0x63,0x00,0x04,0x00,0xa2,0x10,0x2b,0x14,0x40,0xff,0xf7,
+0xaf,0xa3,0x00,0x10,0x08,0x00,0x08,0xd9,0x00,0x00,0x20,0x21,0x24,0x02,0x00,0x01,
+0x08,0x00,0x08,0xec,0xaf,0xa2,0x00,0x18,0x30,0xc6,0x00,0xff,0x00,0xa6,0x00,0x18,
+0x00,0x00,0x28,0x12,0x04,0x81,0x00,0x07,0x00,0x00,0x30,0x21,0x3c,0x02,0x80,0x01,
+0x00,0x85,0x18,0x21,0x34,0x42,0x7f,0xff,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x0b,
+0x3c,0x02,0xb0,0x03,0x3c,0x02,0xaf,0xff,0x34,0x42,0xff,0xff,0x00,0x44,0x10,0x2b,
+0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x0a,0x00,0x85,0x18,0x21,0x34,0x42,0xff,0xff,
+0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0xff,0xff,
+0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x06,0x3c,0x02,0xb0,0x07,0x3c,0x02,0xb0,0x04,
+0x34,0x42,0xff,0xff,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x09,0x3c,0x02,0xb0,0x07,
+0x34,0x42,0x00,0x3f,0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x06,0x3c,0x02,0xb0,0x07,
+0x34,0x42,0xff,0xff,0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x02,0x00,0x00,0x00,0x00,
+0x24,0x06,0x00,0x01,0x14,0xc0,0x00,0x11,0x24,0x02,0x00,0x04,0x3c,0x02,0xb0,0x08,
+0x34,0x42,0x0f,0xff,0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x08,0x3c,0x02,0x4f,0xf7,
+0x00,0x85,0x20,0x21,0x34,0x42,0xf0,0x00,0x00,0x82,0x20,0x21,0x34,0x03,0xef,0xff,
+0x00,0x64,0x18,0x2b,0x14,0x60,0x00,0x02,0x00,0x00,0x00,0x00,0x24,0x06,0x00,0x02,
+0x10,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0,0x24,0x02,0x00,0x02,0xaf,0xb0,0x00,0x18,
+0xaf,0xbf,0x00,0x1c,0x10,0xa2,0x00,0x23,0x00,0xc0,0x80,0x21,0x28,0xa2,0x00,0x03,
+0x10,0x40,0x00,0x0c,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x04,
+0x00,0x00,0x18,0x21,0x0c,0x00,0x0a,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,
+0x8f,0xbf,0x00,0x1c,0x8f,0xb0,0x00,0x18,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x14,0xa2,0xff,0xf7,0x24,0x05,0x00,0x01,0x8c,0xc4,0x00,0x04,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x02,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x14,0x8f,0xa4,0x00,0x10,0x00,0x00,0x00,0x00,
+0x2c,0x82,0x00,0x0b,0x10,0x40,0xff,0xee,0x24,0x03,0x00,0x04,0x00,0x04,0x10,0x80,
+0x8f,0xa4,0x00,0x14,0x27,0x83,0x91,0xc0,0x00,0x43,0x10,0x21,0x08,0x00,0x09,0x4f,
+0xac,0x44,0x00,0x00,0x8c,0xc4,0x00,0x04,0x24,0x05,0x00,0x01,0x0c,0x00,0x07,0xb6,
+0x27,0xa6,0x00,0x10,0x8f,0xa5,0x00,0x10,0x27,0x83,0x91,0xc0,0x3c,0x04,0x80,0x01,
+0x00,0x05,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x46,0x00,0x00,0x0c,0x00,0x17,0x9d,
+0x24,0x84,0x05,0x74,0x08,0x00,0x09,0x50,0x00,0x00,0x18,0x21,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x8f,0x82,0x92,0x10,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
+0x8c,0x45,0x00,0x24,0x3c,0x04,0x80,0x01,0x0c,0x00,0x17,0x9d,0x24,0x84,0x05,0x88,
+0x8f,0x83,0x92,0x10,0x3c,0x04,0x80,0x01,0x8c,0x65,0x00,0x28,0x0c,0x00,0x17,0x9d,
+0x24,0x84,0x05,0x9c,0x8f,0x83,0x92,0x10,0x3c,0x04,0x80,0x01,0x8c,0x65,0x00,0x2c,
+0x0c,0x00,0x17,0x9d,0x24,0x84,0x05,0xb0,0x8f,0x83,0x92,0x10,0x3c,0x04,0x80,0x01,
+0x8c,0x65,0x00,0x30,0x0c,0x00,0x17,0x9d,0x24,0x84,0x05,0xc4,0x8f,0x83,0x92,0x10,
+0x3c,0x04,0x80,0x01,0x8c,0x65,0x00,0x34,0x0c,0x00,0x17,0x9d,0x24,0x84,0x05,0xd8,
+0x8f,0x83,0x92,0x10,0x3c,0x04,0x80,0x01,0x8c,0x65,0x00,0x38,0x0c,0x00,0x17,0x9d,
+0x24,0x84,0x05,0xec,0x8f,0x83,0x92,0x10,0x3c,0x04,0x80,0x01,0x8c,0x65,0x00,0x3c,
+0x0c,0x00,0x17,0x9d,0x24,0x84,0x05,0xfc,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x27,0xbd,0xff,0xb8,0x28,0xa5,0x00,0x04,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x40,
+0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,
+0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb1,0x00,0x24,0x10,0xa0,0x00,0x0b,
+0x00,0xc0,0x80,0x21,0x0c,0x00,0x0a,0x52,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,
+0x8f,0xbf,0x00,0x40,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,
+0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8c,0xc4,0x00,0x04,
+0x24,0x05,0x00,0x01,0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x10,0x8e,0x04,0x00,0x08,
+0x24,0x05,0x00,0x01,0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x14,0x8e,0x04,0x00,0x0c,
+0x24,0x05,0x00,0x01,0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x18,0x8f,0xa3,0x00,0x18,
+0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x3a,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x33,
+0x3c,0x04,0x80,0x01,0x97,0xb0,0x00,0x12,0x8f,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,
+0x02,0x02,0x10,0x2b,0x10,0x40,0xff,0xe2,0x3c,0x15,0x80,0x01,0x3c,0x02,0x80,0x01,
+0x24,0x52,0x06,0x3c,0x3c,0x14,0xb0,0x06,0x24,0x13,0x00,0x01,0x3c,0x17,0xb0,0x08,
+0x3c,0x16,0x80,0x01,0x32,0x02,0x00,0x01,0x02,0x00,0x28,0x21,0x10,0x40,0x00,0x1f,
+0x26,0xa4,0x06,0x30,0x8f,0xa3,0x00,0x18,0x00,0x10,0x10,0xc0,0x00,0x54,0x10,0x21,
+0x10,0x60,0x00,0x14,0x02,0x40,0x20,0x21,0x00,0x10,0x10,0xc0,0x00,0x57,0x10,0x21,
+0x10,0x73,0x00,0x09,0x26,0xc4,0x06,0x44,0x8f,0xa2,0x00,0x14,0x26,0x03,0x00,0x01,
+0x30,0x70,0xff,0xff,0x02,0x02,0x10,0x2b,0x14,0x40,0xff,0xee,0x00,0x00,0x00,0x00,
+0x08,0x00,0x09,0xb4,0x00,0x00,0x00,0x00,0x8c,0x51,0x00,0x00,0x00,0x00,0x00,0x00,
+0x32,0x25,0x00,0xff,0x0c,0x00,0x17,0x9d,0x00,0x00,0x00,0x00,0x08,0x00,0x09,0xe6,
+0x00,0x00,0x00,0x00,0x8c,0x51,0x00,0x00,0x0c,0x00,0x17,0x9d,0x00,0x11,0x2c,0x02,
+0x32,0x25,0x00,0xff,0x08,0x00,0x09,0xf1,0x02,0x40,0x20,0x21,0x0c,0x00,0x17,0x9d,
+0x00,0x00,0x00,0x00,0x08,0x00,0x09,0xdd,0x00,0x00,0x00,0x00,0x24,0x84,0x06,0x10,
+0x0c,0x00,0x17,0xb0,0x00,0x00,0x00,0x00,0x08,0x00,0x09,0xcd,0x00,0x00,0x00,0x00,
+0x3c,0x04,0x80,0x01,0x08,0x00,0x0a,0x00,0x24,0x84,0x06,0x50,0x00,0xa0,0x10,0x21,
+0x27,0xbd,0xff,0xd8,0x28,0x42,0x00,0x04,0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x24,
+0x00,0xc0,0x80,0x21,0x24,0x05,0x00,0x01,0x10,0x40,0x00,0x08,0x27,0xa6,0x00,0x10,
+0x0c,0x00,0x0a,0x52,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x24,
+0x8f,0xb0,0x00,0x20,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x8e,0x04,0x00,0x04,
+0x0c,0x00,0x07,0xb6,0x00,0x00,0x00,0x00,0x8e,0x04,0x00,0x08,0x24,0x05,0x00,0x01,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x14,0x8e,0x04,0x00,0x0c,0x24,0x05,0x00,0x01,
+0x0c,0x00,0x07,0xb6,0x27,0xa6,0x00,0x18,0x08,0x00,0x0a,0x13,0x24,0x02,0x00,0x01,
+0x24,0x03,0x00,0x01,0x00,0x65,0x10,0x2a,0x27,0xbd,0xff,0xd8,0x00,0xa0,0x40,0x21,
+0x10,0x40,0x00,0x0b,0x00,0xc0,0x38,0x21,0x00,0x03,0x20,0x80,0x00,0x87,0x10,0x21,
+0x8c,0x45,0x00,0x00,0x24,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x8c,0xa6,0x00,0x00,
+0x00,0x9d,0x20,0x21,0x00,0x68,0x10,0x2a,0x14,0x40,0xff,0xf7,0xac,0x86,0xff,0xfc,
+0x8f,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x0b,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x28,0x93,0xa2,0x00,0x07,0x00,0x00,0x00,0x00,0xa3,0x82,0x87,0xec,
+0x08,0x00,0x0a,0x3b,0x00,0x00,0x00,0x00,0x93,0xa2,0x00,0x07,0x00,0x00,0x00,0x00,
+0xa3,0x82,0x91,0xb0,0x08,0x00,0x0a,0x3b,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,
+0x3c,0x04,0x80,0x01,0xaf,0xbf,0x00,0x10,0x18,0xa0,0x00,0x03,0x24,0x84,0x06,0x78,
+0x0c,0x00,0x17,0xb0,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x24,0x02,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x27,0xbd,0xff,0xe8,0xaf,0xb0,0x00,0x10,
+0x00,0x80,0x80,0x21,0x3c,0x04,0x80,0x01,0xaf,0xbf,0x00,0x14,0x0c,0x00,0x17,0xb0,
+0x24,0x84,0x06,0x8c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,0x27,0x83,0x83,0x88,
+0x00,0x02,0x10,0xc0,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08,0x0c,0x00,0x17,0xb0,
+0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe8,
+0x34,0x63,0x00,0x20,0x24,0x42,0x29,0x94,0x3c,0x04,0xb0,0x03,0xaf,0xbf,0x00,0x14,
+0xac,0x62,0x00,0x00,0xaf,0xb0,0x00,0x10,0x34,0x84,0x00,0x2c,0x8c,0x83,0x00,0x00,
+0xa7,0x80,0xc2,0x40,0x00,0x03,0x12,0x02,0x00,0x03,0x2d,0x02,0x30,0x42,0x0f,0xff,
+0xa3,0x83,0xc2,0x48,0xa7,0x85,0xc2,0x4c,0xa7,0x82,0xc2,0x4a,0xa7,0x80,0xc2,0x42,
+0xa7,0x80,0xc2,0x44,0xa7,0x80,0xc2,0x46,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x05,0x00,
+0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,0x0c,0x00,0x0b,0xed,
+0x00,0x40,0x80,0x21,0x3c,0x02,0xf7,0xff,0x34,0x42,0xff,0xff,0x02,0x02,0x80,0x24,
+0x02,0x00,0x28,0x21,0x0c,0x00,0x0b,0xed,0x24,0x04,0x05,0x00,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0xb0,0x03,0x34,0x42,0x01,0x08,0x34,0x63,0x01,0x18,0x8c,0x45,0x00,0x00,
+0x8c,0x64,0x00,0x00,0x3c,0x02,0x00,0x0f,0x3c,0x03,0x00,0x4c,0x30,0x84,0x02,0x00,
+0x34,0x63,0x4b,0x40,0xaf,0x85,0xc2,0x50,0x10,0x80,0x00,0x06,0x34,0x42,0x42,0x40,
+0xaf,0x83,0xc2,0x54,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0xaf,0x82,0xc2,0x54,0x08,0x00,0x0a,0x95,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x34,0x63,0x00,0x20,
+0x24,0x42,0x2a,0x70,0x30,0x84,0x00,0xff,0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,
+0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00,
+0x10,0x80,0x00,0x1c,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x08,0x00,0x00,0x00,0x00,
+0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xa7,0x80,0xc2,0x40,
+0xa7,0x80,0xc2,0x42,0xa7,0x80,0xc2,0x44,0xa7,0x80,0xc2,0x46,0x0c,0x00,0x0b,0xfa,
+0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,
+0x0c,0x00,0x0b,0xed,0x00,0x40,0x80,0x21,0x3c,0x05,0xf7,0xff,0x34,0xa5,0xff,0xff,
+0x02,0x05,0x28,0x24,0x0c,0x00,0x0b,0xed,0x24,0x04,0x05,0x00,0x08,0x00,0x0a,0xb0,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x05,0xa0,0x24,0x04,0x05,0xa4,
+0x0c,0x00,0x0b,0xfa,0x00,0x02,0xbc,0x02,0x24,0x04,0x05,0xa8,0x00,0x02,0xb4,0x02,
+0x0c,0x00,0x0b,0xfa,0x30,0x55,0xff,0xff,0x00,0x40,0x80,0x21,0x97,0x84,0xc2,0x40,
+0x97,0x82,0xc2,0x42,0x97,0x83,0xc2,0x46,0x02,0xe4,0x20,0x23,0x02,0xa2,0x10,0x23,
+0x00,0x82,0x20,0x21,0x97,0x82,0xc2,0x44,0x32,0x14,0xff,0xff,0x02,0x83,0x18,0x23,
+0x02,0xc2,0x10,0x23,0x00,0x82,0x20,0x21,0x93,0x82,0xc2,0x48,0x00,0x83,0x20,0x21,
+0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b,0x14,0x40,0x00,0xaa,0x00,0x00,0x00,0x00,
+0x97,0x82,0xc2,0x4c,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x7f,
+0x00,0x00,0x00,0x00,0x97,0x82,0xc2,0x4a,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,
+0x10,0x40,0x00,0x3a,0x00,0x00,0x00,0x00,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x04,0x50,
+0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,0x10,0x40,0x00,0x13,
+0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x17,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,
+0x26,0x31,0x00,0x01,0x00,0x51,0x80,0x25,0x02,0x00,0x28,0x21,0x0c,0x00,0x0b,0xed,
+0x24,0x04,0x04,0x50,0x02,0x00,0x28,0x21,0x0c,0x00,0x0b,0xed,0x24,0x04,0x04,0x58,
+0x02,0x00,0x28,0x21,0x0c,0x00,0x0b,0xed,0x24,0x04,0x04,0x60,0x02,0x00,0x28,0x21,
+0x24,0x04,0x04,0x68,0x0c,0x00,0x0b,0xed,0x00,0x00,0x00,0x00,0xa7,0x97,0xc2,0x40,
+0xa7,0x95,0xc2,0x42,0xa7,0x96,0xc2,0x44,0xa7,0x94,0xc2,0x46,0x08,0x00,0x0a,0xb0,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,
+0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,
+0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
+0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x08,
+0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,
+0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x0c,0x00,0x0b,0xed,
+0x24,0x04,0x02,0x2c,0x08,0x00,0x0a,0xf7,0x24,0x02,0xff,0x80,0x0c,0x00,0x0b,0xfa,
+0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20,0x16,0x22,0xff,0xdb,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,
+0x02,0x40,0x28,0x21,0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x2c,0x0c,0x00,0x0b,0xfa,
+0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c,0x0c,0x00,0x0b,0xfa,0x00,0x02,0x9e,0x02,
+0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,
+0x14,0x60,0x00,0x1d,0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,
+0x24,0x04,0x02,0x2c,0x0c,0x00,0x0b,0xed,0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,
+0x08,0x00,0x0b,0x05,0x24,0x04,0x02,0x2c,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x08,
+0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,
+0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xee,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
+0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x08,
+0x08,0x00,0x0b,0x41,0x3c,0x02,0xff,0xff,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x08,
+0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,
+0x14,0x43,0xff,0xdf,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,
+0x3c,0x03,0x00,0x80,0x08,0x00,0x0b,0x56,0x00,0x43,0x28,0x25,0x0c,0x00,0x0b,0xfa,
+0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,
+0x10,0x40,0xff,0x9a,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x04,0x24,0x02,0xff,0x80,
+0x02,0x02,0x10,0x24,0x08,0x00,0x0a,0xf9,0x26,0x31,0x00,0x02,0x0c,0x00,0x0b,0xfa,
+0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,
+0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,
+0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x08,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x2c,
+0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,
+0x02,0x40,0x28,0x21,0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x2c,0x08,0x00,0x0b,0x70,
+0x24,0x02,0xff,0x80,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x04,0x50,0x00,0x40,0x80,0x21,
+0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x1d,0x2e,0x22,0x00,0x21,
+0x14,0x40,0xff,0x72,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x26,0x31,0xff,0xff,
+0x00,0x51,0x80,0x25,0x24,0x04,0x04,0x50,0x0c,0x00,0x0b,0xed,0x02,0x00,0x28,0x21,
+0x24,0x04,0x04,0x58,0x0c,0x00,0x0b,0xed,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x60,
+0x0c,0x00,0x0b,0xed,0x02,0x00,0x28,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x0b,0xed,
+0x24,0x04,0x04,0x68,0x24,0x02,0x00,0x20,0x16,0x22,0xff,0x60,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,
+0x34,0x42,0x3f,0xff,0x02,0x42,0x10,0x24,0x08,0x00,0x0b,0x47,0x34,0x52,0x80,0x00,
+0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,
+0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x2c,0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x58,
+0x24,0x04,0x02,0x5c,0x0c,0x00,0x0b,0xfa,0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,
+0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x20,
+0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,
+0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,
+0x0c,0x00,0x0b,0xed,0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x0b,0xed,
+0x24,0x04,0x02,0x2c,0x08,0x00,0x0b,0x94,0x2e,0x22,0x00,0x21,0x0c,0x00,0x0b,0xfa,
+0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,
+0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xec,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,
+0x0c,0x00,0x0b,0xed,0x24,0x04,0x02,0x08,0x08,0x00,0x0b,0xc4,0x3c,0x02,0xff,0xff,
+0x0c,0x00,0x0b,0xfa,0x24,0x04,0x02,0x08,0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,
+0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,0x14,0x43,0xff,0xdc,0x3c,0x03,0x00,0x80,
+0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x08,0x00,0x0b,0xdc,
+0x00,0x43,0x28,0x25,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,
+0x3c,0x02,0xb0,0x0a,0x00,0x82,0x20,0x21,0xac,0x85,0x00,0x00,0x00,0x00,0x18,0x21,
+0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x0a,0x14,0x40,0xff,0xfe,0x24,0x63,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x24,0x63,0xff,0xff,0x30,0x86,0x00,0x03,0x00,0x04,0x28,0x40,
+0x3c,0x03,0xb0,0x0a,0x00,0xa6,0x10,0x23,0x00,0x43,0x10,0x21,0x24,0x04,0xff,0xff,
+0xac,0x44,0x10,0x00,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x0a,
+0x14,0x40,0xff,0xfe,0x24,0x63,0x00,0x01,0x24,0x63,0xff,0xff,0x00,0xa6,0x18,0x23,
+0x3c,0x02,0xb0,0x0a,0x00,0x62,0x18,0x21,0x8c,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x30,0x34,
+0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03,0xac,0xa2,0x00,0x00,
+0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,
+0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08,0xa0,0x80,0x00,0x09,
+0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13,0xa0,0x80,0x00,0x49,
+0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x24,0x00,0x02,0x14,0x00,
+0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00,0xa4,0x83,0x00,0x46,
+0xa4,0x82,0x00,0x44,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xac,0x80,0x00,0x30,
+0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xac,0x80,0x00,0x3c,0x03,0xe0,0x00,0x08,
+0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x44,
+0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18,0x3c,0x02,0x80,0x00,0x24,0x42,0x30,0xc4,
+0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08,0x80,0x82,0x00,0x13,0x00,0x05,0x2c,0x00,
+0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00,0x30,0x63,0x00,0x7e,0x00,0x62,0x18,0x21,
+0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00,0x3c,0x05,0xb0,0x05,0x34,0x42,0x04,0x00,
+0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05,0x3c,0x08,0xb0,0x05,0x34,0xa5,0x04,0x20,
+0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21,0x34,0xe7,0x04,0x24,0x35,0x08,0x02,0x28,
+0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20,0xac,0xe6,0x00,0x00,0xac,0x82,0x00,0x3c,
+0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00,0x27,0xbd,0xff,0xc0,0x00,0x07,0x60,0x80,
+0x27,0x82,0xba,0x40,0xaf,0xb7,0x00,0x34,0xaf,0xb5,0x00,0x2c,0xaf,0xb3,0x00,0x24,
+0xaf,0xbf,0x00,0x3c,0xaf,0xbe,0x00,0x38,0xaf,0xb6,0x00,0x30,0xaf,0xb4,0x00,0x28,
+0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x01,0x82,0x10,0x21,
+0x8c,0x43,0x00,0x00,0x3c,0x07,0xb0,0x03,0x3c,0x02,0x80,0x00,0x94,0x71,0x00,0x14,
+0x34,0xe7,0x00,0x20,0x24,0x42,0x31,0x58,0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,
+0x34,0x63,0x01,0x28,0x90,0x67,0x00,0x00,0x00,0x11,0xa8,0xc0,0x02,0xb1,0x18,0x21,
+0x27,0x82,0x96,0x44,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,
+0x00,0x07,0x3e,0x00,0x28,0xc2,0x00,0x03,0x00,0xc0,0x98,0x21,0xaf,0xa4,0x00,0x40,
+0x00,0x05,0x6c,0x03,0x8c,0x68,0x00,0x18,0x02,0xa0,0x58,0x21,0x10,0x40,0x01,0x4f,
+0x00,0x07,0xbe,0x03,0x00,0xd7,0x10,0x07,0x30,0x57,0x00,0x01,0x01,0x71,0x10,0x21,
+0x27,0x83,0x96,0x48,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x80,0x4e,0x00,0x06,
+0x8d,0x03,0x00,0x00,0x8d,0x0f,0x00,0x04,0x8d,0x0a,0x00,0x08,0x8d,0x10,0x00,0x0c,
+0x11,0xc0,0x00,0x1c,0x00,0x00,0xa0,0x21,0x27,0x82,0xba,0x40,0x01,0x82,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,
+0x30,0x63,0x00,0x04,0x14,0x60,0x00,0x13,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x46,
+0x90,0x43,0x00,0x00,0x2a,0x64,0x00,0x04,0x10,0x80,0x01,0x26,0x30,0x65,0x00,0x01,
+0x8f,0xa3,0x00,0x40,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0x09,0x00,0x00,0x00,0x00,
+0x12,0x62,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,
+0x00,0x00,0x38,0x21,0x12,0xe0,0x00,0x03,0x38,0xf4,0x00,0x01,0x24,0x07,0x00,0x01,
+0x38,0xf4,0x00,0x01,0x01,0x71,0x10,0x21,0x00,0x02,0x38,0x80,0x27,0x83,0x96,0x50,
+0x00,0xe3,0x48,0x21,0x91,0x25,0x00,0x00,0x00,0x0f,0x11,0xc3,0x2c,0xa3,0x00,0x04,
+0x00,0x03,0xa0,0x0b,0x12,0x80,0x00,0xc7,0x30,0x52,0x00,0x01,0x93,0x88,0xc2,0x2a,
+0x00,0x0a,0x16,0x42,0x30,0x4a,0x00,0x3f,0x2d,0x06,0x00,0x0c,0x10,0xc0,0x00,0xaf,
+0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10,0x14,0x40,0x00,0x04,0x00,0x88,0x10,0x2b,
+0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04,0x00,0x88,0x10,0x2b,0x10,0x40,0x00,0x0b,
+0x01,0x71,0x10,0x21,0x27,0x85,0xc1,0x5c,0x00,0x08,0x10,0x40,0x00,0x48,0x10,0x21,
+0x00,0x45,0x10,0x21,0x90,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x18,0x2b,
+0x14,0x60,0xff,0xfa,0x00,0x08,0x10,0x40,0x01,0x71,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x96,0x48,0x00,0x43,0x10,0x21,0x31,0xc4,0x00,0x01,0x10,0x80,0x00,0x94,
+0xa0,0x48,0x00,0x07,0x24,0x0d,0x00,0x0e,0x24,0x11,0x01,0x06,0x27,0x82,0xba,0x40,
+0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x24,0x16,0x00,0x01,0x00,0x11,0xa8,0xc0,
+0x90,0x62,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,
+0x00,0x0f,0x1b,0x43,0x30,0x7e,0x00,0x01,0x00,0x0a,0x10,0x40,0x00,0x12,0x19,0xc0,
+0x00,0x5e,0x10,0x21,0x00,0x08,0x22,0x00,0x00,0x43,0x10,0x21,0x00,0x44,0x10,0x21,
+0x00,0x0d,0x1c,0x00,0x00,0x10,0x82,0x02,0x01,0x00,0x28,0x21,0x00,0x00,0x20,0x21,
+0x00,0x43,0x90,0x21,0x0c,0x00,0x01,0xdd,0x32,0x10,0x07,0xff,0x00,0x16,0x12,0x80,
+0x00,0x10,0x84,0x80,0x02,0x22,0x10,0x21,0x00,0x50,0x10,0x21,0x3c,0x03,0xc0,0x00,
+0x16,0x60,0x00,0x2b,0x00,0x43,0x80,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,
+0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x52,0x00,0x00,0x34,0x63,0x04,0x04,
+0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x01,0xac,0x70,0x00,0x00,0xa0,0x82,0x00,0x00,
+0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x8f,0xa2,0x00,0x40,
+0x30,0x86,0x00,0x01,0x90,0x43,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x63,0x18,0x26,
+0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21,0x12,0xe0,0x00,0x03,
+0x02,0xb1,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0xb1,0x10,0x21,0x27,0x83,0x96,0x48,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04,0x00,0xa0,0x30,0x21,
+0x03,0xc0,0x20,0x21,0x02,0x60,0x28,0x21,0x02,0x80,0x38,0x21,0x0c,0x00,0x00,0x70,
+0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,
+0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,
+0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x3d,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x02,
+0x12,0x62,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03,0x12,0x62,0x00,0x25,
+0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x62,0x00,0x19,0x3c,0x02,0xb0,0x05,
+0x24,0x02,0x00,0x11,0x12,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x12,
+0x16,0x62,0xff,0xcf,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05,0x34,0x42,0x04,0x20,
+0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x52,0x00,0x00,0x34,0x84,0x02,0x28,
+0xac,0x70,0x00,0x00,0x08,0x00,0x0c,0xf7,0x24,0x02,0x00,0x20,0x34,0x42,0x04,0x40,
+0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x52,0x00,0x00,0x34,0x63,0x04,0x44,
+0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x0c,0xf7,0xac,0x70,0x00,0x00,
+0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x52,0x00,0x00,
+0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80,0x08,0x00,0x0c,0xf7,
+0xac,0x70,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,
+0xac,0x52,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x08,
+0x08,0x00,0x0c,0xf7,0xac,0x70,0x00,0x00,0x34,0x42,0x04,0x10,0x3c,0x03,0xb0,0x05,
+0x3c,0x04,0xb0,0x05,0xac,0x52,0x00,0x00,0x34,0x63,0x04,0x14,0x34,0x84,0x02,0x28,
+0x24,0x02,0x00,0x04,0x08,0x00,0x0c,0xf7,0xac,0x70,0x00,0x00,0x34,0x42,0x04,0x08,
+0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x52,0x00,0x00,0x34,0x63,0x04,0x0c,
+0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x0c,0xf7,0xac,0x70,0x00,0x00,
+0x24,0x0d,0x00,0x14,0x08,0x00,0x0c,0xcf,0x24,0x11,0x01,0x02,0x30,0xa2,0x00,0x07,
+0x24,0x44,0x00,0x0c,0x00,0x88,0x18,0x2b,0x10,0x60,0x00,0x0c,0x25,0x02,0x00,0x04,
+0x27,0x85,0xc1,0x5c,0x00,0x08,0x10,0x40,0x00,0x48,0x10,0x21,0x00,0x45,0x10,0x21,
+0x90,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x18,0x2b,0x14,0x60,0xff,0xfa,
+0x00,0x08,0x10,0x40,0x2d,0x06,0x00,0x0c,0x25,0x02,0x00,0x04,0x08,0x00,0x0c,0xc6,
+0x00,0x46,0x40,0x0a,0x27,0x82,0xba,0x40,0x01,0x82,0x20,0x21,0x8c,0x86,0x00,0x00,
+0x00,0x00,0x00,0x00,0x90,0xc2,0x00,0x19,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x07,
+0x00,0x00,0x00,0x00,0x27,0x82,0x96,0x60,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x12,0x00,0x00,0x00,0x00,0x90,0xc3,0x00,0x16,
+0x27,0x82,0x96,0x48,0x00,0xe2,0x10,0x21,0x34,0x63,0x00,0x20,0x90,0x48,0x00,0x07,
+0xa0,0xc3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x16,0x42,0x30,0x4a,0x00,0x3f,
+0x90,0x83,0x00,0x16,0x24,0x0d,0x00,0x18,0x24,0x11,0x01,0x03,0x30,0x63,0x00,0xfb,
+0x24,0x16,0x00,0x01,0x24,0x15,0x08,0x18,0x08,0x00,0x0c,0xd8,0xa0,0x83,0x00,0x16,
+0x8d,0x02,0x00,0x04,0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10,0x14,0x40,0x00,0x15,
+0x30,0x6a,0x00,0x3f,0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x11,
+0x30,0x6a,0x00,0x3e,0x27,0x83,0x96,0x58,0x00,0xe3,0x18,0x21,0x80,0x64,0x00,0x00,
+0x27,0x83,0xbb,0xb8,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x05,
+0x90,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24,0x30,0x63,0x00,0x01,
+0x01,0x43,0x50,0x25,0x27,0x85,0xba,0x40,0x01,0x85,0x28,0x21,0x8c,0xa6,0x00,0x00,
+0x01,0x71,0x10,0x21,0x27,0x83,0x96,0x50,0x90,0xc4,0x00,0x16,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x30,0x84,0x00,0xdf,0x90,0x48,0x00,0x00,0xa0,0xc4,0x00,0x16,
+0x8c,0xa3,0x00,0x00,0x80,0xd6,0x00,0x12,0x90,0x62,0x00,0x16,0x08,0x00,0x0c,0xd7,
+0x30,0x42,0x00,0xfb,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xdc,0x00,0x00,0x00,0x00,
+0x8f,0xa3,0x00,0x40,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0x09,0x00,0x00,0x00,0x00,
+0x02,0x62,0x10,0x26,0x08,0x00,0x0c,0x9f,0x00,0x02,0x28,0x0b,0x24,0x02,0x00,0x10,
+0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0xaf,0x00,0x07,0x17,0x83,
+0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0xad,0x00,0x07,0x17,0x43,0x08,0x00,0x0c,0x7f,
+0x30,0x57,0x00,0x01,0x08,0x00,0x0c,0x7f,0x00,0x07,0xbf,0xc2,0x00,0x04,0x10,0x40,
+0x27,0x83,0x86,0xb0,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21,0x94,0x44,0x00,0x00,
+0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a,0x00,0x86,0x00,0x18,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x37,0x5c,
+0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12,0x00,0x04,0x22,0x42,
+0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b,0x24,0x82,0x00,0x60,
+0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x00,0x44,0x20,0x04,
+0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28,0x24,0x83,0x00,0x24,
+0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14,0x00,0x60,0x20,0x21,
+0x08,0x00,0x0d,0xee,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x37,0xf8,0x00,0x80,0x80,0x21,
+0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37,0x34,0x84,0x01,0x10,
+0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21,0x8c,0x87,0x00,0x00,
+0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f,0x34,0x42,0xf0,0x00,
+0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08,0x32,0x02,0x00,0x07,
+0x27,0x83,0x87,0x60,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,
+0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21,0x32,0x02,0x00,0x0f,
+0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x07,
+0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xba,0x90,0x00,0x43,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c,0x14,0x40,0x00,0x05,
+0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21,
+0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20,0x24,0x06,0x00,0x0e,
+0x0c,0x00,0x0d,0xd7,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04,0x24,0x02,0x00,0x10,
+0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01,0x14,0x60,0x00,0x02,
+0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff,0x00,0xc5,0x10,0x21,
+0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00,0x8f,0xbf,0x00,0x1c,
+0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c,0x32,0x02,0x00,0x07,
+0x27,0x83,0x87,0x58,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x08,0x00,0x0e,0x1c,
+0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80,0x27,0x82,0xba,0x40,
+0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb4,0x00,0x30,0xaf,0xbf,0x00,0x44,
+0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,
+0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21,0x8c,0xe6,0x00,0x00,
+0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,
+0x24,0x42,0x39,0x54,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,0xa0,0xc3,0x00,0x12,
+0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16,0xa4,0xc3,0x00,0x14,
+0x27,0x83,0x96,0x40,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16,0x8c,0xe8,0x00,0x00,
+0xaf,0xa4,0x00,0x48,0x27,0x82,0x96,0x44,0x95,0x11,0x00,0x14,0x00,0x00,0x00,0x00,
+0x00,0x11,0xa0,0xc0,0x02,0x91,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x82,0x10,0x21,
+0x8c,0x53,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06,0x8e,0x65,0x00,0x08,
+0x8e,0x66,0x00,0x04,0x8e,0x67,0x00,0x04,0x00,0x05,0x1c,0x82,0x00,0x06,0x31,0x42,
+0x27,0x82,0x96,0x50,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01,0x00,0x82,0x20,0x21,
+0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18,0xaf,0xa6,0x00,0x1c,
+0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06,0x14,0xe0,0x00,0x42,
+0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3f,
+0x02,0x91,0x10,0x21,0x93,0x90,0xc2,0x29,0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c,
+0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40,0x00,0x43,0x10,0x21,
+0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04,0x02,0x91,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0x00,0x80,0x80,0x21,
+0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,
+0x0c,0x00,0x0d,0xd7,0x02,0xa0,0x30,0x21,0x02,0x91,0x18,0x21,0x00,0x03,0x88,0x80,
+0x00,0x40,0x90,0x21,0x27,0x82,0x96,0x60,0x02,0x22,0x10,0x21,0x8c,0x44,0x00,0x00,
+0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,0x00,0x04,0x25,0xc2,
+0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40,0x03,0xc4,0x20,0x24,
+0x14,0x80,0x00,0x10,0x02,0x63,0x38,0x21,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48,
+0x27,0x82,0x96,0x48,0x02,0x22,0x10,0x21,0x02,0xa0,0x28,0x21,0xa4,0x52,0x00,0x04,
+0x0c,0x00,0x0c,0x56,0x00,0xc0,0x38,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,
+0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c,0x8f,0xa6,0x00,0x18,0x02,0x00,0x20,0x21,
+0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0d,0xfe,0xaf,0xa0,0x00,0x14,
+0x08,0x00,0x0e,0xba,0x02,0x42,0x90,0x21,0x02,0x91,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,0x08,0x00,0x0e,0xa6,
+0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8,0xaf,0xb1,0x00,0x24,0x8f,0xb1,0x00,0x5c,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x3b,0x64,
+0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38,0xaf,0xb5,0x00,0x34,
+0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c,0x8f,0xb5,0x00,0x58,0xaf,0xbf,0x00,0x44,
+0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,0x00,0xe0,0xb0,0x21,
+0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21,0x00,0x00,0xb8,0x21,0x16,0x20,0x00,0x2b,
+0x00,0x00,0xa0,0x21,0x27,0x85,0xba,0x40,0x00,0x07,0x10,0x80,0x00,0x45,0x10,0x21,
+0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80,0x00,0x65,0x18,0x21,0x92,0x62,0x00,0x16,
+0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x2d,0x00,0x00,0x00,0x00,
+0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x28,
+0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x18,
+0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x14,
+0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0f,
+0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05,0x34,0x63,0x01,0x44,0x34,0xa5,0x02,0x52,
+0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00,0x8f,0xa3,0x00,0x4c,0x00,0x00,0x00,0x00,
+0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x04,0x30,0xc6,0xff,0xff,
+0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09,0x24,0x05,0x00,0x14,0x02,0x20,0x10,0x21,
+0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,
+0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x0c,0x00,0x0c,0x31,
+0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01,0x08,0x00,0x0f,0x1b,0xa3,0xc2,0x00,0x11,
+0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x17,0x00,0xc0,0x88,0x21,
+0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21,0x12,0x20,0xff,0xed,0x02,0x20,0x10,0x21,
+0x27,0x83,0xba,0x40,0x00,0x17,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28,0x80,0x86,0x00,0x12,0x8c,0x62,0x00,0x00,
+0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03,0x00,0x46,0x10,0x21,0x8f,0xa6,0x00,0x4c,
+0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21,0x0c,0x00,0x0c,0x56,0xac,0x62,0x00,0x00,
+0x08,0x00,0x0f,0x1b,0xaf,0xd1,0x00,0x40,0x96,0x74,0x00,0x1a,0x08,0x00,0x0f,0x2e,
+0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x50,0x00,0x00,
+0x02,0x60,0x20,0x21,0x0c,0x00,0x23,0x25,0x02,0x00,0x28,0x21,0x30,0x42,0x00,0xff,
+0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x23,0x25,0xaf,0xa2,0x00,0x18,
+0x30,0x50,0x00,0xff,0x8f,0xa2,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0xc3,
+0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01,0x96,0x63,0x00,0x14,
+0x96,0x44,0x00,0x14,0x27,0x85,0x96,0x40,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0,0x8c,0x46,0x00,0x08,
+0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x00,0x06,0x17,0x02,
+0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xac,0x00,0x03,0x17,0x02,
+0x10,0x44,0x00,0xab,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b,0x24,0x11,0x00,0x02,
+0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x45,
+0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbc,0x00,0x00,0x00,0x00,0x96,0x49,0x00,0x14,
+0x27,0x82,0x96,0x44,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0,0x01,0x49,0x18,0x21,
+0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00,
+0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42,
+0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,0x14,0x40,0x00,0x2c,
+0x30,0x87,0x00,0x01,0x27,0x83,0x96,0x58,0x01,0x03,0x18,0x21,0x80,0x64,0x00,0x00,
+0x27,0x83,0xba,0xe0,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x45,0x00,0x00,
+0x00,0x00,0x00,0x00,0x2c,0xa3,0x00,0x0c,0x14,0x60,0x00,0x07,0x01,0x49,0x10,0x21,
+0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0xa2,0x10,0x21,
+0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x50,
+0x00,0x43,0x10,0x21,0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08,
+0x12,0x02,0x00,0x0a,0x24,0x02,0x00,0x01,0x02,0x40,0x20,0x21,0x0c,0x00,0x23,0xa1,
+0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,
+0x02,0x02,0x10,0x25,0x08,0x00,0x0f,0x2e,0xa2,0x42,0x00,0x16,0x02,0x40,0x20,0x21,
+0x0c,0x00,0x23,0x52,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0f,0xa6,0x30,0x54,0xff,0xff,
+0x27,0x82,0x96,0x50,0x01,0x02,0x10,0x21,0x90,0x45,0x00,0x00,0x08,0x00,0x0f,0x9f,
+0xa0,0x45,0x00,0x03,0x96,0x69,0x00,0x14,0x02,0xc0,0xb8,0x21,0x24,0x0b,0x00,0x01,
+0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21,0x00,0x03,0x40,0x80,0x00,0x40,0x50,0x21,
+0x27,0x82,0x96,0x44,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00,
+0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42,
+0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,0x10,0x40,0x00,0x0d,
+0x30,0x87,0x00,0x01,0x27,0x82,0x96,0x58,0x01,0x02,0x10,0x21,0x80,0x43,0x00,0x00,
+0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xbb,0xb0,0x00,0x43,0x10,0x21,
+0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x3a,0x00,0x00,0x00,0x00,0x01,0x49,0x10,0x21,
+0x00,0x02,0x20,0x80,0x27,0x85,0x96,0x50,0x00,0x85,0x10,0x21,0x80,0x43,0x00,0x05,
+0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x2d,0x01,0x49,0x10,0x21,0x27,0x83,0x96,0x58,
+0x00,0x83,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xba,0xe0,0x00,0x04,0x11,0x00,
+0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x90,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xa3,0x00,0x0c,
+0x14,0x60,0x00,0x07,0x01,0x49,0x10,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,
+0x00,0x02,0x11,0x00,0x00,0xa2,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0xa0,0x45,0x00,0x03,
+0xa0,0x45,0x00,0x00,0x8f,0xa3,0x00,0x18,0x24,0x02,0x00,0x08,0x10,0x62,0x00,0x0b,
+0x02,0x60,0x20,0x21,0x24,0x02,0x00,0x01,0x0c,0x00,0x23,0xa1,0xaf,0xa2,0x00,0x10,
+0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff,0x92,0x62,0x00,0x16,0x00,0x00,0x00,0x00,
+0x00,0x62,0x10,0x25,0x08,0x00,0x0f,0x2e,0xa2,0x62,0x00,0x16,0x0c,0x00,0x23,0x52,
+0xaf,0xa0,0x00,0x10,0x08,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,
+0x00,0x45,0x10,0x21,0x90,0x45,0x00,0x00,0x08,0x00,0x0f,0xf9,0xa0,0x45,0x00,0x03,
+0x27,0x85,0x96,0x50,0x08,0x00,0x10,0x0b,0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,
+0x00,0x62,0x18,0x26,0x08,0x00,0x0f,0x6a,0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x57,
+0x24,0x02,0x00,0x01,0x08,0x00,0x0f,0x6f,0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0,0x24,0x42,0x40,0x6c,0x34,0x63,0x00,0x20,
+0x3c,0x05,0xb0,0x05,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,
+0xaf,0xbf,0x00,0x28,0xaf,0xb0,0x00,0x18,0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,
+0x90,0xa2,0x00,0x00,0x00,0x80,0x90,0x21,0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,
+0x24,0x02,0x00,0x10,0x12,0x22,0x00,0xcf,0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,
+0x12,0x22,0x00,0xc1,0x24,0x02,0x00,0x12,0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,
+0x14,0x60,0x00,0xad,0xae,0x43,0x00,0x40,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,
+0x8c,0x44,0x00,0x00,0x3c,0x03,0x00,0x02,0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,
+0x00,0x10,0x14,0x43,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x92,0x00,0x00,0x00,0x00,0x93,0x83,0x91,0x51,
+0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,
+0x00,0x10,0x11,0xc3,0x14,0x40,0x00,0x86,0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,
+0x02,0x00,0x10,0x21,0x26,0x22,0x00,0x01,0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,
+0x14,0x60,0xff,0xdb,0x24,0x03,0x00,0x02,0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,
+0x2a,0x62,0x00,0x03,0x10,0x40,0x00,0x58,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,
+0x12,0x62,0x00,0x4b,0x02,0x40,0x20,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,
+0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,
+0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,
+0x24,0x02,0x00,0x07,0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,
+0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,
+0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,
+0x16,0x00,0xff,0xec,0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,
+0x24,0x02,0x00,0x05,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,
+0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,
+0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,
+0x16,0x00,0xff,0xdc,0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,
+0x24,0x02,0x00,0x03,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,
+0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,
+0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,
+0x16,0x00,0xff,0xcc,0x02,0x00,0x10,0x21,0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,
+0x24,0x02,0x00,0x02,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,
+0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,
+0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,0x08,0x00,0x10,0x61,0x30,0x42,0x00,0xff,
+0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,
+0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,
+0x08,0x00,0x10,0x5a,0xae,0x42,0x00,0x24,0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,
+0x24,0x02,0x00,0x08,0x16,0x62,0xff,0xa8,0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,
+0x8e,0x42,0x00,0x30,0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,
+0x0c,0x00,0x0e,0xd9,0xaf,0xa2,0x00,0x14,0x08,0x00,0x10,0x5a,0xae,0x42,0x00,0x30,
+0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,
+0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,
+0x08,0x00,0x10,0x5a,0xae,0x42,0x00,0x2c,0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,
+0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,
+0x0c,0x00,0x0e,0xd9,0xaf,0xa3,0x00,0x14,0x08,0x00,0x10,0x5a,0xae,0x42,0x00,0x28,
+0x0c,0x00,0x01,0x60,0x24,0x04,0x00,0x01,0x08,0x00,0x10,0x4b,0x00,0x00,0x00,0x00,
+0x8f,0x84,0xba,0x80,0xae,0x40,0x00,0x34,0x94,0x85,0x00,0x14,0x0c,0x00,0x1f,0xdd,
+0x00,0x00,0x00,0x00,0x93,0x83,0x91,0x51,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,
+0x10,0x40,0xff,0x69,0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x60,0x00,0x00,0x20,0x21,
+0x08,0x00,0x10,0x43,0x00,0x00,0x00,0x00,0x02,0x40,0x20,0x21,0x0c,0x00,0x0e,0x55,
+0x02,0x20,0x28,0x21,0x08,0x00,0x10,0x37,0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,
+0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x4a,0x00,0x00,0x00,0x00,0x8f,0x82,0xba,0x88,
+0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,
+0x08,0x00,0x10,0x34,0xae,0x43,0x00,0x3c,0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,
+0x14,0x40,0xff,0x3d,0x24,0x02,0x00,0x12,0x8f,0x82,0xba,0x84,0x00,0x00,0x00,0x00,
+0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x10,0x34,
+0xae,0x43,0x00,0x38,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,
+0x24,0x02,0x00,0x11,0x8f,0x82,0xba,0x80,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x10,0x34,0xae,0x43,0x00,0x34,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,
+0x24,0x42,0x44,0x20,0x3c,0x08,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,
+0x35,0x08,0x01,0x00,0xaf,0xbf,0x00,0x18,0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,
+0x00,0xa0,0x48,0x21,0x24,0x11,0x00,0x0a,0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,
+0x00,0x45,0x88,0x0a,0x30,0x63,0x00,0x01,0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,
+0x00,0x11,0x40,0x40,0x02,0x20,0x40,0x21,0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,
+0x01,0x20,0x20,0x21,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x96,0x48,0x00,0x43,0x10,0x21,0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,
+0x10,0xe0,0x00,0x06,0x02,0x23,0x80,0x21,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x0d,0xd7,
+0x00,0x00,0x00,0x00,0x02,0x11,0x18,0x21,0x08,0x00,0x11,0x2a,0x00,0x62,0x80,0x21,
+0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,
+0xaf,0xb2,0x00,0x18,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,
+0x84,0x82,0x00,0x0c,0x3c,0x06,0xb0,0x03,0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,
+0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x27,0x82,0x96,0x44,0x00,0x62,0x10,0x21,
+0x8c,0x53,0x00,0x18,0x3c,0x02,0x80,0x00,0x24,0x42,0x44,0xd0,0xac,0xc2,0x00,0x00,
+0x8e,0x70,0x00,0x08,0x27,0x82,0x96,0x48,0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,
+0x00,0x10,0x86,0x43,0x32,0x10,0x00,0x01,0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,
+0x00,0xa0,0xa0,0x21,0x02,0x20,0x28,0x21,0x0c,0x00,0x11,0x08,0x00,0x80,0xa8,0x21,
+0x02,0x20,0x20,0x21,0x02,0x00,0x28,0x21,0x24,0x06,0x00,0x14,0x0c,0x00,0x0d,0xd7,
+0x00,0x40,0x90,0x21,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x40,0x94,0x64,0x00,0x00,
+0x3c,0x0a,0xb0,0x09,0x3c,0x0b,0xb0,0x09,0x00,0x04,0x21,0x40,0x00,0x82,0x28,0x23,
+0x35,0x4a,0x01,0x10,0x35,0x6b,0x01,0x14,0x3c,0x0c,0xb0,0x09,0x3c,0x08,0xb0,0x09,
+0x3c,0x06,0xb0,0x09,0x00,0x44,0x10,0x2b,0x01,0x40,0x48,0x21,0x35,0x8c,0x01,0x20,
+0x01,0x60,0x38,0x21,0x35,0x08,0x01,0x24,0x34,0xc6,0x01,0x02,0x10,0x40,0x00,0x02,
+0x02,0x45,0x18,0x2b,0x00,0xa3,0x90,0x0b,0x86,0xa3,0x00,0x0c,0x27,0x84,0x96,0x50,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,
+0x80,0x43,0x00,0x06,0xa4,0xd2,0x00,0x00,0x24,0x64,0x00,0x03,0x28,0x62,0x00,0x00,
+0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x00,0x03,0x18,0x80,0x12,0x80,0x00,0x11,
+0x02,0x63,0x28,0x21,0x8c,0xa2,0x00,0x0c,0x8c,0xa3,0x00,0x08,0x00,0x02,0x14,0x00,
+0x00,0x03,0x1c,0x02,0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8c,0xa3,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x03,0x1c,0x02,0xa4,0xe3,0x00,0x00,0x8f,0xbf,0x00,0x28,
+0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x30,0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x42,0x00,0x00,
+0x8c,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0xa5,0x64,0x00,0x00,0x78,0xa2,0x00,0x7c,
+0x00,0x00,0x00,0x00,0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21,
+0xad,0x83,0x00,0x00,0x8c,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02,
+0x08,0x00,0x11,0x87,0xa5,0x02,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c,
+0x00,0x80,0x90,0x21,0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,
+0x00,0x04,0x20,0x80,0x27,0x82,0x96,0x44,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18,
+0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x46,0x78,0x27,0x83,0x96,0x48,
+0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07,
+0x34,0x42,0x01,0x00,0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04,
+0x24,0x02,0x00,0x10,0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43,
+0x30,0x84,0x00,0x01,0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40,
+0x02,0x00,0x10,0x21,0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x0d,0xd7,
+0x30,0x50,0x00,0xff,0x86,0x44,0x00,0x0c,0x27,0x85,0x96,0x50,0x3c,0x06,0xb0,0x09,
+0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,
+0x80,0x64,0x00,0x06,0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03,
+0x28,0x83,0x00,0x00,0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80,
+0xa4,0xc2,0x00,0x00,0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09,
+0x34,0x42,0x01,0x10,0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09,
+0x34,0x42,0x01,0x14,0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08,
+0x3c,0x06,0xb0,0x09,0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21,
+0x34,0xc6,0x01,0x20,0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09,
+0x34,0xa5,0x01,0x24,0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a,
+0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04,
+0x30,0x42,0xff,0xff,0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x96,0x58,
+0x8f,0xbf,0x00,0x1c,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,
+0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,
+0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x48,0x04,
+0x00,0x05,0x2c,0x43,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,
+0x10,0xa0,0x00,0x05,0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0xaf,0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x47,
+0x00,0x00,0x10,0x21,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x9c,0x2a,0x02,0x00,0x09,
+0x10,0x40,0x00,0x84,0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x74,
+0x2a,0x02,0x00,0x03,0x10,0x40,0x00,0x64,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,
+0x12,0x02,0x00,0x55,0x00,0x00,0x00,0x00,0x82,0x22,0x00,0x11,0x92,0x27,0x00,0x11,
+0x10,0x40,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a,0x24,0x02,0x00,0x12,
+0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xba,0x40,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x83,0x00,0x14,
+0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x40,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03,0xa2,0x23,0x00,0x10,
+0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff,0x27,0x83,0xba,0x40,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x82,0x23,0x00,0x12,
+0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x30,0x42,0x00,0x01,
+0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18,0xa2,0x23,0x00,0x12,
+0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01,0x96,0x23,0x00,0x0c,
+0x27,0x84,0x96,0x50,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,0x3c,0x02,0xb0,0x00,
+0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00,0x90,0x62,0x00,0x04,
+0xa2,0x20,0x00,0x15,0xa3,0x80,0x92,0x15,0x24,0x02,0x00,0x01,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x11,0x9e,
+0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x12,0x49,0x00,0x07,0x16,0x00,
+0x0c,0x00,0x11,0x34,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c,0x27,0x84,0x96,0x48,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x20,0x21,
+0x90,0x85,0x00,0x07,0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0xa2,0x25,0x00,0x13,
+0x90,0x83,0x00,0x07,0x08,0x00,0x12,0x61,0xa0,0x43,0x00,0x02,0x92,0x26,0x00,0x0a,
+0x08,0x00,0x12,0x2a,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24,0x00,0x00,0x00,0x00,
+0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07,0xa2,0x22,0x00,0x0a,
+0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x12,0x22,0xa2,0x22,0x00,0x04,
+0x08,0x00,0x12,0x7b,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9f,0x24,0x02,0x00,0x01,
+0x8e,0x23,0x00,0x2c,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x07,0xa2,0x24,0x00,0x08,
+0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f,0xae,0x20,0x00,0x2c,
+0x08,0x00,0x12,0x22,0xa2,0x22,0x00,0x06,0x08,0x00,0x12,0x8a,0xa2,0x20,0x00,0x0a,
+0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01,0x10,0x44,0x00,0x07,
+0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2b,
+0xae,0x20,0x00,0x28,0x08,0x00,0x12,0x22,0xa2,0x22,0x00,0x05,0x08,0x00,0x12,0x96,
+0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x10,0x2a,0x02,0x00,0x41,0x10,0x40,0x00,0x08,
+0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7f,0x24,0x02,0x00,0x12,
+0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x12,0x22,0xae,0x20,0x00,0x3c,
+0x16,0x02,0xff,0x79,0x24,0x02,0x00,0x10,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,
+0x08,0x00,0x12,0x22,0xae,0x20,0x00,0x34,0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,
+0xa2,0x22,0x00,0x08,0x08,0x00,0x12,0x22,0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,
+0x24,0x02,0x00,0x03,0x24,0x03,0x00,0x01,0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,
+0x24,0x02,0x00,0x02,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,
+0x08,0x00,0x12,0x22,0xa2,0x22,0x00,0x07,0x08,0x00,0x12,0xba,0xa2,0x24,0x00,0x0a,
+0x8f,0x84,0xba,0x80,0xae,0x20,0x00,0x34,0x94,0x85,0x00,0x14,0x0c,0x00,0x1f,0xdd,
+0x32,0x10,0x00,0xff,0x08,0x00,0x12,0x13,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x24,0x42,0x4b,0x1c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,
+0x80,0xa2,0x00,0x15,0x3c,0x06,0xb0,0x05,0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,
+0x83,0x83,0x92,0x15,0x00,0x00,0x00,0x00,0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,
+0xac,0x82,0x00,0x28,0x8c,0x82,0x00,0x2c,0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,
+0x00,0x02,0x18,0x43,0x30,0x63,0x00,0x01,0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,
+0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,
+0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd8,0x34,0x63,0x00,0x20,0x24,0x42,0x4b,0xac,
+0xac,0x62,0x00,0x00,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,
+0x90,0xa6,0x00,0x0a,0x27,0x83,0xba,0x40,0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,
+0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,
+0x10,0xa0,0x00,0x04,0xa2,0x20,0x00,0x15,0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xd9,
+0x00,0x00,0x00,0x00,0x82,0x22,0x00,0x12,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,
+0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x12,0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x96,0x60,0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0xdf,0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,
+0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x45,0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,
+0x92,0x08,0x00,0x04,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,
+0x92,0x07,0x00,0x0a,0xa2,0x02,0x00,0x17,0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,
+0x30,0x42,0x00,0xe4,0x10,0x60,0x00,0x03,0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,
+0xa2,0x02,0x00,0x16,0x11,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,
+0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,
+0x00,0x00,0x00,0x00,0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x96,0x02,0x00,0x00,0x08,0x00,0x13,0x36,
+0xa6,0x02,0x00,0x14,0x92,0x07,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,
+0x00,0x00,0x00,0x00,0x08,0x00,0x13,0x22,0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,
+0x96,0x05,0x00,0x06,0x27,0x86,0x96,0x40,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,
+0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,
+0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,
+0x3c,0x03,0x80,0x00,0x00,0xc3,0x20,0x24,0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,
+0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,
+0x00,0xa6,0x18,0x2b,0x08,0x00,0x13,0x22,0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,
+0x00,0xa6,0x18,0x2b,0x08,0x00,0x13,0x56,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,
+0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,
+0x00,0x00,0x00,0x00,0x08,0x00,0x13,0x1c,0xa2,0x20,0x00,0x07,0x08,0x00,0x13,0x1c,
+0xa2,0x20,0x00,0x06,0x08,0x00,0x13,0x1c,0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x68,0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x48,
+0x3c,0x02,0xb0,0x09,0x92,0x25,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,
+0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x3a,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,
+0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,
+0x96,0x26,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,
+0x27,0x83,0x96,0x44,0x00,0xa3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,
+0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,
+0x00,0x00,0x00,0x00,0x93,0x82,0x91,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,
+0x14,0x40,0x00,0x0a,0x24,0x05,0x00,0x24,0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,
+0x0c,0x00,0x1f,0xdd,0x02,0x00,0x20,0x21,0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,
+0x30,0x42,0x00,0xe7,0x08,0x00,0x13,0x13,0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,
+0x00,0x00,0x28,0x12,0x27,0x82,0x96,0x40,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,
+0x3c,0x04,0x00,0x80,0x96,0x26,0x00,0x0c,0x08,0x00,0x13,0x93,0x00,0x06,0x2c,0x00,
+0x27,0x83,0x96,0x50,0x27,0x82,0x96,0x58,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,
+0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05,0x00,0x00,0x30,0x21,0x0c,0x00,0x25,0xc4,
+0x24,0x07,0x00,0x01,0x96,0x26,0x00,0x0c,0x08,0x00,0x13,0x8d,0x00,0x00,0x00,0x00,
+0x14,0x40,0xff,0xce,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
+0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x13,0x7c,0x00,0xa2,0x10,0x07,
+0x86,0x26,0x00,0x0c,0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78,
+0x94,0x47,0x00,0x00,0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21,
+0x3c,0x04,0xb0,0x09,0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x96,0x44,
+0x00,0x02,0x10,0x80,0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18,
+0xae,0x25,0x00,0x20,0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21,
+0x0c,0x00,0x13,0xe2,0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c,
+0x8e,0x27,0x00,0x20,0x02,0x20,0x20,0x21,0x0c,0x00,0x20,0xdf,0xaf,0xa2,0x00,0x10,
+0x08,0x00,0x13,0x13,0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x13,0x13,
+0xa2,0x22,0x00,0x09,0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00,
+0x08,0x00,0x13,0x13,0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24,
+0x00,0x80,0x70,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x4f,0x88,
+0xf1,0x43,0x00,0x06,0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21,
+0xac,0x82,0x00,0x00,0x27,0x85,0x96,0x50,0x27,0x82,0x96,0x4f,0x27,0xbd,0xff,0xf8,
+0x00,0x62,0x60,0x21,0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc,
+0x00,0x00,0x78,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00,
+0x80,0x48,0x00,0x04,0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x96,0x44,
+0xa3,0xa7,0x00,0x00,0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff,
+0x00,0x48,0x40,0x0b,0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06,
+0x30,0x63,0x00,0x08,0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00,
+0x27,0x82,0x96,0x58,0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50,
+0x30,0xe5,0x00,0xff,0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24,
+0x90,0x49,0x00,0x00,0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04,
+0x10,0xa2,0x00,0x9d,0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c,
+0x10,0x40,0x00,0x02,0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff,
+0x00,0x04,0x10,0x40,0x27,0x83,0xc1,0x5c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21,
+0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00,
+0x10,0x60,0x00,0x02,0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00,
+0x91,0x65,0x00,0x00,0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b,
+0x10,0x40,0x00,0x0e,0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21,
+0x30,0xa2,0x00,0x0f,0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21,
+0x27,0x83,0xc1,0x5c,0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x05,0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xba,0xe8,
+0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c,
+0x14,0x60,0x00,0x06,0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,
+0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x14,0x43,
+0xa1,0x82,0x00,0x00,0x8f,0x8d,0x87,0xf0,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21,
+0x00,0x06,0x74,0x82,0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03,
+0x00,0xe0,0x10,0x21,0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff,
+0xa3,0xa2,0x00,0x00,0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00,
+0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23,
+0x00,0x64,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xba,0xe8,
+0x00,0x44,0x10,0x21,0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00,
+0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x44,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,
+0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,
+0x14,0x60,0x00,0x33,0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23,0x27,0x83,0xbb,0xb8,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00,
+0x00,0x64,0xc0,0x24,0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f,
+0x10,0x40,0x00,0x0f,0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x96,0x40,
+0x00,0x44,0x10,0x21,0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41,
+0x14,0x60,0x00,0x04,0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00,
+0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21,
+0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21,
+0x24,0x42,0x00,0x04,0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21,
+0x90,0x43,0x00,0x00,0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b,
+0x14,0x60,0xff,0xad,0x30,0xe2,0x00,0xff,0x08,0x00,0x14,0x30,0x00,0x00,0x00,0x00,
+0x08,0x00,0x14,0x91,0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00,
+0x10,0x40,0xff,0x73,0x00,0x00,0x00,0x00,0x08,0x00,0x14,0x1e,0x00,0x00,0x00,0x00,
+0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00,
+0x08,0x00,0x13,0xfe,0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x34,0x63,0x00,0x20,0x24,0x42,0x53,0x28,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,
+0x27,0xbd,0xff,0xc0,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,
+0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c,
+0xaf,0xbe,0x00,0x38,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c,
+0x27,0x93,0x96,0x44,0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00,
+0x34,0xa5,0x00,0x20,0x24,0x42,0x53,0x40,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08,
+0x27,0x95,0x96,0x50,0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21,
+0x90,0x71,0x00,0x00,0x0c,0x00,0x13,0xe2,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21,
+0x00,0x10,0x14,0x42,0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82,
+0x02,0x80,0x28,0x21,0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c,
+0x30,0x50,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x55,0x10,0x21,0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21,
+0x8c,0xc7,0x00,0x18,0x27,0x83,0x96,0x40,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04,
+0x84,0x46,0x00,0x06,0x00,0x03,0x19,0x42,0x0c,0x00,0x0d,0xd7,0x30,0x73,0x00,0x01,
+0x00,0x40,0x88,0x21,0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10,
+0x02,0x00,0x30,0x21,0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0,
+0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x27,0x82,0x96,0x48,0x00,0x62,0x18,0x21,
+0xa4,0x71,0x00,0x04,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,
+0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,
+0x86,0xc3,0x00,0x0c,0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06,
+0x00,0x00,0x00,0x00,0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21,
+0x00,0x07,0x38,0x43,0x00,0x07,0x38,0x40,0x0c,0x00,0x0d,0xfe,0x03,0xc7,0x38,0x21,
+0x08,0x00,0x15,0x11,0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x27,0xbd,0xff,0xd0,0x34,0x63,0x00,0x20,0x24,0x42,0x54,0xc8,0xaf,0xb2,0x00,0x20,
+0xac,0x62,0x00,0x00,0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,
+0xaf,0xb0,0x00,0x18,0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04,
+0x94,0x45,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0xba,0x40,0x00,0x62,0x18,0x21,
+0x30,0xa6,0xff,0xff,0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc8,0x00,0xff,
+0x00,0x06,0x32,0x02,0xa4,0x86,0x00,0x44,0xa4,0x88,0x00,0x46,0x82,0x22,0x00,0x12,
+0x00,0x80,0x90,0x21,0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a,
+0x10,0x40,0x00,0x14,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x96,0x60,0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12,
+0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16,
+0x8f,0xbf,0x00,0x28,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x30,0x0c,0x00,0x14,0xca,0x00,0x00,0x00,0x00,0x08,0x00,0x15,0x60,
+0x00,0x00,0x00,0x00,0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x65,0x00,0x00,0x28,0x21,
+0x84,0x83,0x00,0x0c,0x27,0x84,0x96,0x50,0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x48,0x00,0x43,0x18,0x21,
+0x80,0x65,0x00,0x06,0x00,0x44,0x10,0x21,0x80,0x49,0x00,0x05,0x38,0xa5,0x00,0x00,
+0x80,0x4a,0x00,0x04,0x15,0x20,0x00,0x27,0x01,0x05,0x30,0x0b,0x15,0x40,0x00,0x11,
+0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa8,0x00,0xff,
+0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x45,0x2d,0x02,0x00,0x10,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x01,0x02,0x10,0x04,
+0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x27,0x84,0x96,0x50,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,
+0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x28,0x21,0x94,0xa2,0x00,0x00,
+0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06,0x00,0x02,0x24,0x03,
+0x30,0x82,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21,0x34,0x82,0x08,0x00,
+0xa4,0xa2,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,
+0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00,0x82,0x42,0x00,0x10,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x86,0x43,0x00,0x0c,
+0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04,0x92,0x23,0x00,0x16,
+0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x15,0x65,0xa2,0x23,0x00,0x16,
+0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x05,
+0x86,0x45,0x00,0x0c,0x0c,0x00,0x23,0x1c,0x02,0x20,0x20,0x21,0x10,0x40,0x00,0x5a,
+0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,
+0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,
+0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08,
+0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33,0x24,0x02,0x00,0x01,
+0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0c,
+0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x08,0x00,0x15,0x60,
+0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x15,0x60,0xa6,0x22,0x00,0x14,
+0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0x15,0xde,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,
+0x27,0x86,0x96,0x40,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,
+0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,
+0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,
+0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,
+0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,
+0x08,0x00,0x15,0xde,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,
+0x08,0x00,0x16,0x01,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,
+0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca,0x00,0x00,0x00,0x00,
+0x08,0x00,0x15,0xd9,0xa2,0x40,0x00,0x07,0x08,0x00,0x15,0xd9,0xa2,0x40,0x00,0x06,
+0x08,0x00,0x15,0xd9,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,
+0x08,0x00,0x15,0xd0,0x00,0xa2,0x10,0x07,0x0c,0x00,0x14,0xd0,0x02,0x40,0x20,0x21,
+0x08,0x00,0x15,0x60,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,
+0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x98,0x2c,0xc2,0x00,0x10,
+0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,
+0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,
+0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x7f,
+0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c,0x27,0x93,0x96,0x44,
+0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,
+0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64,0x00,0x00,0x00,0x00,
+0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18,0x93,0x82,0x91,0x51,
+0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42,0x14,0x40,0x00,0x4d,
+0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1f,0xdd,
+0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14,0x30,0xc5,0xff,0xff,
+0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b,
+0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x62,0x00,0x04,
+0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x1f,0xdd,0x30,0x50,0x00,0x01,
+0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff,0x92,0x22,0x00,0x04,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,
+0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,
+0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x15,0x5f,0x30,0x42,0x00,0xc3,
+0x96,0x22,0x00,0x00,0x08,0x00,0x16,0x75,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x70,
+0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff,0x00,0x05,0x18,0xc0,
+0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x27,0x84,0x96,0x40,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80,0x8c,0x45,0x00,0x08,
+0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00,0x00,0xa2,0x38,0x24,
+0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,
+0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x16,0x70,
+0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x16,0x94,
+0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06,0x00,0x00,0x28,0x12,
+0x27,0x82,0x96,0x40,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x00,0x00,0x20,0x21,
+0x96,0x47,0x00,0x0c,0x08,0x00,0x16,0x52,0x00,0x07,0x2c,0x00,0x27,0x83,0x96,0x50,
+0x27,0x82,0x96,0x58,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,
+0x90,0x65,0x00,0x05,0x24,0x07,0x00,0x01,0x0c,0x00,0x25,0xc4,0x00,0x00,0x30,0x21,
+0x96,0x47,0x00,0x0c,0x08,0x00,0x16,0x45,0x00,0x07,0x1c,0x00,0x10,0xa2,0x00,0x09,
+0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x7e,
+0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x36,0xa2,0x40,0x00,0x07,0x08,0x00,0x16,0x36,
+0xa2,0x40,0x00,0x06,0x08,0x00,0x16,0x36,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0x72,
+0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,
+0x24,0x02,0x00,0x80,0x08,0x00,0x16,0x2d,0x00,0xa2,0x10,0x07,0x14,0x40,0xfe,0xc4,
+0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
+0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x15,0x88,0x00,0xa2,0x10,0x07,
+0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x44,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18,
+0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x13,0xe2,0x00,0x00,0x00,0x00,
+0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21,0x00,0x00,0x38,0x21,
+0x0c,0x00,0x20,0xdf,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00,0x14,0x60,0xfe,0x7c,
+0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x40,
+0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04,0x00,0x00,0x00,0x00,
+0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a,0xa2,0x22,0x00,0x17,
+0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10,0x00,0x00,0x00,0x00,
+0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x16,
+0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03,0xa2,0x22,0x00,0x16,
+0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x61,0x00,0x00,0x00,0x00,
+0x92,0x22,0x00,0x16,0x08,0x00,0x15,0x5f,0x34,0x42,0x00,0x02,0x96,0x22,0x00,0x00,
+0x08,0x00,0x16,0xf7,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a,0x00,0x00,0x00,0x00,
+0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xf0,0xa2,0x20,0x00,0x17,
+0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x96,0x40,0x00,0x04,0x18,0xc0,
+0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,
+0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,
+0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,
+0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,
+0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x16,0xf0,0xa2,0x23,0x00,0x17,
+0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x17,0x1f,0x00,0x00,0x00,0x00,
+0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03,
+0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xea,0xa2,0x40,0x00,0x07,
+0x08,0x00,0x16,0xea,0xa2,0x40,0x00,0x06,0x08,0x00,0x16,0xea,0xa2,0x40,0x00,0x05,
+0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0xa2,0x18,0x24,
+0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02,0x24,0x02,0x00,0x01,
+0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xfd,
+0x00,0xa4,0x10,0x2b,0x08,0x00,0x17,0x3a,0x00,0x00,0x00,0x00,0x30,0x82,0xff,0xff,
+0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x96,0x50,0x00,0x03,0x18,0x80,
+0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00,0x3c,0x03,0xb0,0x00,
+0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08,0x00,0x43,0x10,0x21,
+0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00,0xaf,0xbf,0x00,0x1c,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x14,0x40,0x00,0x41,
+0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03,0x8e,0x10,0x00,0x00,
+0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03,0x32,0x02,0x00,0x20,
+0x08,0x00,0x17,0x60,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x06,
+0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x67,0x00,0xff,
+0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x96,0x20,0x00,0x40,0x30,0x21,
+0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01,0x24,0x42,0x00,0x02,
+0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a,0xa4,0xa2,0x00,0x08,
+0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xba,0x40,0x24,0x11,0x00,0x12,
+0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x1d,0x55,0x00,0x00,0x00,0x00,
+0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24,0x3c,0x01,0xb0,0x03,
+0x0c,0x00,0x18,0x18,0xac,0x30,0x00,0x00,0x08,0x00,0x17,0x60,0x00,0x00,0x00,0x00,
+0x8f,0x85,0x96,0x20,0x08,0x00,0x17,0x76,0x00,0x00,0x00,0x00,0x24,0x02,0xff,0x95,
+0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30,0x3c,0x01,0xb0,0x03,
+0xac,0x30,0x00,0x00,0x0c,0x00,0x17,0xe1,0xac,0x60,0x00,0x00,0x08,0x00,0x17,0x60,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50,0x08,0x00,0x17,0x60,
+0xac,0x46,0x00,0x00,0xaf,0xa7,0x00,0x0c,0xaf,0xa4,0x00,0x00,0xaf,0xa5,0x00,0x04,
+0xaf,0xa6,0x00,0x08,0x27,0xbd,0xfe,0xe8,0x00,0x80,0x28,0x21,0x27,0xa6,0x01,0x1c,
+0x27,0xa4,0x00,0x10,0xaf,0xbf,0x01,0x14,0x0c,0x00,0x29,0xa9,0xaf,0xb0,0x01,0x10,
+0x00,0x40,0x80,0x21,0x0c,0x00,0x17,0xb0,0x27,0xa4,0x00,0x10,0x02,0x00,0x10,0x21,
+0x8f,0xbf,0x01,0x14,0x8f,0xb0,0x01,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x01,0x18,
+0x93,0x83,0x87,0xec,0x27,0xbd,0xff,0xe8,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
+0x14,0x60,0x00,0x14,0x00,0x80,0x80,0x21,0x80,0x82,0x00,0x00,0x90,0x84,0x00,0x00,
+0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x00,0x04,0x26,0x00,0x00,0x04,0x26,0x03,
+0x30,0x84,0xff,0xff,0x0c,0x00,0x17,0xd0,0x26,0x10,0x00,0x01,0x92,0x03,0x00,0x00,
+0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xf8,0x00,0x60,0x20,0x21,0x08,0x00,0x17,0xba,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x14,0x43,0xff,0xef,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x04,0x52,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0xba,0x00,0x00,0x00,0x00,
+0x30,0x84,0xff,0xff,0x48,0x84,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x0c,0x00,0x29,0x11,0x00,0x00,0x00,0x00,
+0x8f,0xbf,0x00,0x10,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,
+0x24,0x02,0x00,0x01,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x5f,0x84,0x3c,0x0b,0xb0,0x03,
+0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00,0x3c,0x09,0x80,0x01,
+0x25,0x29,0x0b,0x2c,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,
+0x25,0x4a,0x5f,0xac,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0xb0,0x06,
+0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,
+0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00,0x24,0x01,0x00,0x01,
+0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x5f,0xe8,
+0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03,0x8c,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00,0xac,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x60,0x14,0x3c,0x0b,0xb0,0x03,
+0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00,0x3c,0x03,0x80,0x01,
+0x24,0x63,0x0b,0x2c,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00,0x00,0x00,0x00,0x00,
+0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x43,0x08,0x2a,
+0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0x80,0x00,0x25,0x4a,0x60,0x60,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
+0x3c,0x02,0x80,0x01,0x24,0x42,0x0b,0x30,0x3c,0x03,0x80,0x01,0x24,0x63,0x42,0x50,
+0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08,0xac,0x40,0x00,0x0c,
+0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0x80,0x00,0x25,0x4a,0x60,0xa0,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
+0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x92,0x20,0x00,0x00,0x00,0x00,
+0x27,0x9d,0x96,0x08,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x60,0xc4,0x3c,0x0b,0xb0,0x03,
+0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00,0x00,0x00,0x00,0x00,
+0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x1a,0x4d,
+0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03,0x00,0x04,0x30,0x40,
+0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0,0x24,0x03,0xff,0xff,
+0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00,0xaf,0xbf,0x00,0x18,
+0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x10,0x00,
+0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23,0x3c,0x03,0xb0,0x0a,
+0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x18,0x95,0x02,0x20,0x20,0x21,
+0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,
+0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff,0xaf,0xb3,0x00,0x1c,
+0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x00,0xc0,0x98,0x21,
+0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x10,0x40,
+0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23,0x3c,0x03,0xb0,0x0a,
+0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21,0x24,0x05,0x00,0x01,
+0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd,0x3c,0x02,0xb0,0x0a,
+0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00,0x0c,0x00,0x18,0x95,
+0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24,0x00,0x53,0x10,0x04,
+0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01,0x8e,0x22,0x10,0x00,
+0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23,0x3c,0x04,0xb0,0x0a,
+0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01,0x8c,0x62,0x10,0x00,
+0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x18,0x83,
+0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06,0x30,0x42,0x00,0x01,
+0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x20,
+0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,
+0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x80,0x21,0x00,0xa0,0x88,0x21,
+0x00,0xc0,0x90,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0xc0,
+0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,
+0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x03,0x82,0x02,0x00,0x13,0x00,0x11,0x24,0x00,
+0x3c,0x03,0xc0,0x00,0x00,0x02,0x12,0x00,0x00,0x44,0x10,0x21,0x3c,0x04,0xb0,0x05,
+0x24,0x42,0x00,0x09,0x34,0x84,0x04,0x20,0x34,0x63,0x04,0x00,0x3c,0x05,0xb0,0x05,
+0x3c,0x06,0xb0,0x05,0xac,0x82,0x00,0x00,0x24,0x07,0x00,0x01,0x02,0x43,0x18,0x21,
+0x34,0xa5,0x04,0x24,0x34,0xc6,0x02,0x28,0x24,0x02,0x00,0x20,0xac,0xa3,0x00,0x00,
+0xae,0x07,0x00,0x3c,0xa0,0xc2,0x00,0x00,0xa2,0x07,0x00,0x11,0x3c,0x02,0xb0,0x05,
+0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0xc0,
+0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x01,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,
+0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x01,0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,
+0xac,0x82,0x00,0x0c,0xa0,0x80,0x00,0x50,0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,
+0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x14,0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,
+0xa4,0x80,0x00,0x20,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,
+0xa0,0x80,0x00,0x30,0xa0,0x80,0x00,0x31,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,
+0xa0,0x80,0x00,0x3c,0xac,0x82,0x00,0x10,0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,
+0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x4c,0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,
+0x8c,0x83,0x00,0x00,0x3c,0x02,0x12,0x00,0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,
+0x34,0xa5,0x00,0x8b,0x24,0x02,0xff,0x80,0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,
+0xa0,0xa2,0x00,0x00,0x3c,0x04,0xb0,0x03,0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,
+0x3c,0x05,0xb0,0x01,0x3c,0x06,0x45,0x67,0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,
+0x34,0xa5,0x00,0x04,0x34,0xc6,0x89,0xaa,0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,
+0x3c,0x0b,0xb0,0x09,0x3c,0x07,0x01,0x23,0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,
+0xac,0x20,0x00,0x00,0x27,0xbd,0xff,0xe0,0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,
+0x3c,0x01,0xb0,0x09,0xac,0x26,0x00,0x00,0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,
+0x35,0x8c,0x00,0x0c,0x24,0x02,0xcd,0xef,0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,
+0x3c,0x0e,0xb0,0x09,0xad,0x67,0x00,0x00,0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,
+0xaf,0xb6,0x00,0x18,0xaf,0xb5,0x00,0x14,0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,
+0xaf,0xb2,0x00,0x08,0xaf,0xb1,0x00,0x04,0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,
+0x35,0x08,0x01,0x22,0x35,0xce,0x00,0x14,0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,
+0x3c,0x09,0x89,0xab,0x3c,0x10,0xb0,0x09,0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,
+0x3c,0x13,0xb0,0x09,0x3c,0x14,0xb0,0x09,0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,
+0x3c,0x17,0xb0,0x09,0xad,0xa8,0x00,0x00,0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,
+0x35,0xef,0x00,0x18,0x35,0x29,0xcd,0xee,0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,
+0x36,0x52,0x00,0x24,0x36,0x73,0x00,0x28,0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,
+0x36,0xd6,0x00,0x34,0x36,0xf7,0x00,0x38,0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,
+0xa6,0x02,0x00,0x00,0xae,0x23,0x00,0x00,0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,
+0x8f,0xb1,0x00,0x04,0xae,0x63,0x00,0x00,0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,
+0x8f,0xb3,0x00,0x0c,0xae,0xa3,0x00,0x00,0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,
+0x8f,0xb5,0x00,0x14,0xae,0xe3,0x00,0x00,0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,
+0x37,0x18,0x00,0x3c,0xa7,0x03,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x65,0x50,
+0xac,0x62,0x00,0x00,0x8c,0x83,0x00,0x34,0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,
+0x14,0x40,0x00,0xed,0x00,0x80,0x28,0x21,0x8c,0x84,0x00,0x08,0x24,0x02,0x00,0x03,
+0x10,0x82,0x00,0xe0,0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x2c,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x38,0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xc6,
+0xac,0xa2,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0xc5,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0x82,0x00,0xb3,0x00,0x00,0x00,0x00,0x8c,0xa6,0x00,0x04,
+0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0xa9,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x61,0x00,0x16,
+0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x10,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0b,0x00,0x00,0x00,0x00,
+0x80,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,
+0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,
+0x03,0xe0,0x00,0x08,0xa0,0xa3,0x00,0x50,0x80,0xa2,0x00,0x31,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,0x8c,0x43,0x00,0x00,
+0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00,0x00,0x64,0x18,0x24,0x10,0x62,0x00,0x03,
+0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x00,0x8c,0xa2,0x00,0x40,
+0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x09,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,
+0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24,0x14,0x60,0xff,0xf2,0x24,0x02,0x00,0x10,
+0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x8c,0xa3,0x00,0x0c,
+0x00,0x00,0x00,0x00,0xac,0xa3,0x00,0x10,0x3c,0x02,0xb0,0x03,0x90,0x42,0x02,0x01,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0xac,0xa2,0x00,0x0c,0x90,0xa3,0x00,0x0f,
+0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03,0x08,0x00,0x19,0x9d,0xa0,0x23,0x02,0x01,
+0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80,0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03,0x10,0x60,0x00,0x15,0xa0,0xa4,0x00,0x44,
+0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x03,
+0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x0c,
+0xac,0xa3,0x00,0x00,0x24,0x03,0x00,0x04,0xac,0xa2,0x00,0x10,0x03,0xe0,0x00,0x08,
+0xac,0xa3,0x00,0x0c,0x24,0x02,0x00,0x0d,0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x04,
+0x24,0x02,0x00,0x06,0xac,0xa3,0x00,0x10,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x0c,
+0x8c,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x09,0x24,0x02,0x00,0x01,
+0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05,0xac,0xa2,0x00,0x14,0x24,0x02,0x00,0x01,
+0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x14,0x8c,0xa3,0x00,0x38,
+0x24,0x04,0x00,0x01,0x10,0x64,0x00,0x2d,0x24,0x02,0x00,0x02,0x10,0x60,0x00,0x19,
+0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x10,0x24,0x02,0x00,0x04,0x10,0x62,0x00,0x04,
+0x00,0x00,0x00,0x00,0xac,0xa0,0x00,0x38,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x00,
+0x10,0xc4,0x00,0x07,0x24,0x02,0x00,0x03,0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,
+0x00,0x02,0x18,0x0b,0xac,0xa3,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x38,
+0x08,0x00,0x19,0xfe,0xac,0xa2,0x00,0x00,0x10,0xc4,0x00,0x02,0x24,0x02,0x00,0x03,
+0x24,0x02,0x00,0x0c,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,
+0xac,0xa2,0x00,0x38,0x10,0xc4,0x00,0x0e,0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x06,
+0xac,0xa2,0x00,0x18,0x24,0x02,0x00,0x02,0xac,0xa2,0x00,0x00,0xac,0xa0,0x00,0x18,
+0x08,0x00,0x1a,0x07,0x24,0x02,0x00,0x01,0x08,0x00,0x1a,0x14,0xac,0xa0,0x00,0x00,
+0x24,0x02,0x00,0x03,0x08,0x00,0x1a,0x14,0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x0b,
+0xac,0xa2,0x00,0x38,0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x00,0x80,0xa2,0x00,0x30,
+0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x55,0x24,0x02,0x00,0x04,0x08,0x00,0x19,0x9d,
+0x00,0x00,0x00,0x00,0x84,0xa2,0x00,0x20,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x75,
+0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,
+0x14,0x40,0xff,0x42,0xa4,0xa3,0x00,0x20,0x08,0x00,0x19,0x9d,0x24,0x02,0x00,0x06,
+0x8c,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x66,0x24,0x02,0x00,0x05,
+0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x32,0xac,0xa2,0x00,0x1c,0x08,0x00,0x19,0x9d,
+0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x56,0x24,0x02,0x00,0x06,
+0x08,0x00,0x19,0x62,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x0a,0x03,0xe0,0x00,0x08,
+0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,
+0x27,0x91,0x90,0xf8,0x27,0x90,0x8e,0x38,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,
+0x0c,0x00,0x28,0x9e,0xaf,0xb2,0x00,0x18,0x0c,0x00,0x06,0x90,0x00,0x00,0x00,0x00,
+0xaf,0x91,0x92,0x10,0xaf,0x90,0x96,0x20,0x48,0x02,0x00,0x00,0x0c,0x00,0x18,0xf2,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x1c,0x9b,0x02,0x00,0x20,0x21,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0x3a,0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0x83,0x96,0x24,
+0x0c,0x00,0x00,0x34,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0xfd,0x00,0x00,0x00,0x00,
+0x27,0x84,0x8c,0x78,0x0c,0x00,0x2c,0x78,0x00,0x00,0x00,0x00,0x0c,0x00,0x25,0x71,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x0c,0x0d,0x02,0x20,0x20,0x21,0x0c,0x00,0x01,0x39,
+0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0x20,0x0c,0x00,0x18,0xdb,0x00,0x00,0x00,0x00,
+0x27,0x82,0x91,0x2c,0xaf,0x82,0x8c,0x60,0x0c,0x00,0x00,0x5f,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,0x3c,0x05,0xb0,0x09,
+0x8c,0x66,0x00,0x00,0x34,0x84,0x01,0x68,0x24,0x02,0xd1,0x10,0x34,0xa5,0x01,0x40,
+0x24,0x03,0x00,0x0a,0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,0x3c,0x04,0xb0,0x03,
+0x8c,0x82,0x00,0x00,0xaf,0x86,0x8c,0x18,0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00,
+0x0c,0x00,0x06,0xa1,0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05,0x0c,0x00,0x28,0xb6,
+0x34,0x84,0x00,0x04,0x8f,0x83,0x8c,0x20,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x11,
+0x10,0x40,0xff,0xf7,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,0x24,0x63,0x09,0x08,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,
+0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0x20,0x0c,0x00,0x19,0x54,0x00,0x00,0x00,0x00,
+0x8f,0x82,0x8c,0x54,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x8c,0x54,
+0x08,0x00,0x1a,0x88,0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0x78,0x0c,0x00,0x2d,0xe5,
+0x00,0x00,0x00,0x00,0xa3,0x82,0x8c,0x51,0xaf,0x80,0x8c,0x20,0x08,0x00,0x1a,0x9c,
+0x00,0x00,0x00,0x00,0x27,0x84,0x8e,0x38,0x0c,0x00,0x1d,0xe0,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x8c,0x20,
+0xaf,0x80,0x8c,0x24,0x08,0x00,0x1a,0x9c,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8c,0x4c,
+0x14,0x40,0x00,0x1e,0x24,0x02,0x00,0x01,0x8f,0x84,0x8c,0x28,0x00,0x00,0x00,0x00,
+0x10,0x82,0x00,0x1d,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8c,0x34,0x14,0x40,0x00,0x13,
+0x24,0x02,0x00,0x01,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x3c,0x02,0xb0,0x05,
+0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x03,0xaf,0x82,0x8c,0x24,0xaf,0x83,0x8c,0x20,
+0x08,0x00,0x1a,0x9c,0x00,0x00,0x00,0x00,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,
+0xa7,0x83,0x8c,0x40,0x14,0x40,0xff,0xf3,0x24,0x02,0x00,0x01,0xaf,0x82,0x8c,0x24,
+0x08,0x00,0x1a,0xa6,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x8c,0x3c,
+0x14,0x40,0xff,0xf6,0x24,0x02,0x00,0x01,0x08,0x00,0x1a,0xbe,0x3c,0x03,0xb0,0x09,
+0x27,0x84,0x8e,0x38,0x0c,0x00,0x1f,0x44,0x00,0x00,0x00,0x00,0x83,0x82,0x8c,0x50,
+0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xed,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,
+0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,
+0xaf,0x82,0x8c,0x4c,0x14,0x40,0xff,0xe5,0x24,0x02,0x00,0x02,0x8f,0x84,0x8c,0x28,
+0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x12,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x05,
+0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x02,0xaf,0x82,0x8c,0x24,0x08,0x00,0x1a,0xcb,
+0x24,0x03,0x00,0x04,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x8c,0x40,
+0x14,0x40,0xff,0xf4,0x00,0x00,0x00,0x00,0x08,0x00,0x1a,0xd7,0x24,0x02,0x00,0x02,
+0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0xaf,0x82,0x8c,0x3c,0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,
+0x08,0x00,0x1a,0xf7,0x24,0x02,0x00,0x02,0x27,0x84,0x90,0xf8,0x0c,0x00,0x10,0x1b,
+0x00,0x00,0x00,0x00,0x8f,0x83,0x8c,0x24,0xaf,0x82,0x8c,0x3c,0x38,0x64,0x00,0x02,
+0x00,0x04,0x18,0x0a,0xaf,0x83,0x8c,0x24,0x14,0x40,0x00,0x08,0x24,0x02,0x00,0x05,
+0x8f,0x82,0x91,0x38,0xaf,0x80,0x8c,0x20,0x10,0x40,0xff,0x7d,0x24,0x04,0x00,0x01,
+0xaf,0x84,0x8c,0x28,0x08,0x00,0x1a,0x9c,0x00,0x00,0x00,0x00,0xaf,0x82,0x8c,0x20,
+0x08,0x00,0x1a,0x9c,0x00,0x00,0x00,0x00,0x83,0x82,0x8c,0x70,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20,0xaf,0x82,0x8c,0x3c,0x8f,0x85,0x8c,0x3c,
+0x27,0x84,0x90,0xf8,0x0c,0x00,0x12,0x01,0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,
+0xa3,0x82,0x8c,0x50,0xaf,0x80,0x8c,0x3c,0x10,0x60,0xff,0x73,0x3c,0x02,0xb0,0x05,
+0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,
+0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x8c,0x40,0x10,0x40,0xff,0xe7,
+0x24,0x02,0x00,0x06,0x24,0x04,0x00,0x02,0xaf,0x84,0x8c,0x28,0x08,0x00,0x1a,0xa6,
+0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0x20,0x27,0x85,0x90,0xf8,0x0c,0x00,0x12,0xc7,
+0x00,0x00,0x00,0x00,0x8f,0x82,0x8c,0x44,0xaf,0x80,0x8c,0x4c,0x14,0x40,0x00,0x18,
+0x00,0x40,0x18,0x21,0x8f,0x82,0x8c,0x48,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x14,
+0x24,0x02,0x00,0x02,0x8f,0x83,0x8c,0x28,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,
+0x24,0x02,0x00,0x01,0x8f,0x83,0x8c,0x24,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x02,
+0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x06,0xaf,0x82,0x8c,0x20,0x08,0x00,0x1b,0x20,
+0x24,0x04,0x00,0x03,0x3c,0x02,0x40,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05,
+0xac,0x22,0x00,0x00,0xaf,0x80,0x8c,0x20,0x08,0x00,0x1b,0x20,0x24,0x04,0x00,0x03,
+0x10,0x60,0x00,0x10,0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0x20,0x27,0x85,0x90,0xf8,
+0x0c,0x00,0x12,0xeb,0x00,0x00,0x00,0x00,0x8f,0x83,0x8c,0x24,0x24,0x02,0x00,0x01,
+0xa3,0x80,0x8c,0x50,0xaf,0x80,0x8c,0x28,0x10,0x62,0x00,0x02,0x24,0x02,0x00,0x03,
+0x24,0x02,0x00,0x04,0xaf,0x82,0x8c,0x20,0xaf,0x80,0x8c,0x44,0x08,0x00,0x1a,0x9c,
+0x00,0x00,0x00,0x00,0x83,0x82,0x8c,0x70,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04,
+0x00,0x00,0x00,0x00,0x27,0x84,0x90,0xf8,0x0c,0x00,0x15,0x32,0x00,0x00,0x00,0x00,
+0x8f,0x82,0x8c,0x24,0xa3,0x80,0x8c,0x50,0xaf,0x80,0x8c,0x20,0xaf,0x80,0x8c,0x28,
+0x14,0x40,0x00,0x02,0x24,0x02,0x00,0x02,0xaf,0x82,0x8c,0x24,0xaf,0x80,0x8c,0x48,
+0x08,0x00,0x1a,0x9c,0x00,0x00,0x00,0x00,0x27,0x84,0x8c,0x20,0x27,0x85,0x90,0xf8,
+0x0c,0x00,0x12,0xeb,0x00,0x00,0x00,0x00,0x8f,0x82,0x8c,0x24,0xa3,0x80,0x8c,0x50,
+0xaf,0x80,0x8c,0x20,0xaf,0x80,0x8c,0x28,0x14,0x40,0xff,0x11,0x24,0x02,0x00,0x02,
+0xaf,0x82,0x8c,0x24,0x08,0x00,0x1a,0x9c,0x00,0x00,0x00,0x00,0x27,0x84,0x90,0xf8,
+0x0c,0x00,0x15,0x32,0x00,0x00,0x00,0x00,0x08,0x00,0x1b,0x86,0x00,0x00,0x00,0x00,
+0x27,0x84,0x8c,0x78,0x0c,0x00,0x2e,0x70,0x00,0x00,0x00,0x00,0x08,0x00,0x1a,0xa5,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x27,0x0a,0x00,0x00,0x00,0x00,0x93,0x82,0x92,0x14,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x2b,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,
+0x8c,0x44,0x00,0x00,0x8f,0x83,0xc2,0x50,0x8f,0x82,0xc2,0x54,0x00,0x83,0x18,0x23,
+0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x23,0x3c,0x02,0xb0,0x03,0x24,0x04,0x05,0xa0,
+0x34,0x42,0x01,0x18,0x8c,0x42,0x00,0x00,0x0c,0x00,0x0b,0xfa,0x00,0x00,0x00,0x00,
+0x24,0x04,0x05,0xa4,0x0c,0x00,0x0b,0xfa,0x00,0x02,0x84,0x02,0x30,0x51,0xff,0xff,
+0x24,0x04,0x05,0xa8,0x00,0x02,0x94,0x02,0x0c,0x00,0x0b,0xfa,0x3a,0x10,0xff,0xff,
+0x3a,0x31,0xff,0xff,0x30,0x42,0xff,0xff,0x2e,0x10,0x00,0x01,0x2e,0x31,0x00,0x01,
+0x3a,0x52,0xff,0xff,0x02,0x11,0x80,0x25,0x2e,0x52,0x00,0x01,0x38,0x42,0xff,0xff,
+0x02,0x12,0x80,0x25,0x2c,0x42,0x00,0x01,0x02,0x02,0x80,0x25,0x16,0x00,0x00,0x02,
+0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x0a,0x9c,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0xaf,0x83,0xc2,0x50,0x0c,0x00,0x01,0xcb,0x00,0x00,0x00,0x00,0xaf,0x80,0x8c,0x20,
+0xaf,0x80,0x8c,0x54,0x08,0x00,0x1a,0x88,0x00,0x00,0x00,0x00,0x27,0x90,0xba,0x40,
+0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x10,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x1d,0x55,
+0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6,0x26,0x10,0x00,0x04,
+0x08,0x00,0x1a,0xa6,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,
+0x8c,0x44,0x00,0x00,0x8f,0x82,0x8c,0x18,0x00,0x04,0x19,0xc2,0x00,0x02,0x11,0xc2,
+0x10,0x62,0xfe,0xc1,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02,0x90,0x43,0x00,0x00,
+0x3c,0x12,0xb0,0x05,0xaf,0x84,0x8c,0x18,0x30,0x63,0x00,0xff,0x00,0x03,0x11,0x40,
+0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x99,0x00,
+0x00,0x00,0x88,0x21,0x36,0x52,0x02,0x2c,0x27,0x90,0xba,0x40,0x8e,0x04,0x00,0x00,
+0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x03,
+0x10,0x40,0x00,0x06,0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,
+0x8f,0x85,0x8c,0x18,0x0c,0x00,0x22,0xc6,0x02,0x60,0x30,0x21,0x8e,0x42,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x14,0x40,0xfe,0xa3,0x00,0x00,0x00,0x00,
+0x26,0x31,0x00,0x01,0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec,0x26,0x10,0x00,0x04,
+0x08,0x00,0x1a,0xa6,0x00,0x00,0x00,0x00,0x8f,0x84,0x8c,0x2c,0x27,0x85,0x90,0xf8,
+0x0c,0x00,0x1c,0x2e,0x00,0x00,0x00,0x00,0x8f,0x83,0x8c,0x2c,0x24,0x02,0x00,0x04,
+0x14,0x62,0xfe,0x95,0x24,0x02,0x00,0x05,0x08,0x00,0x1b,0x23,0x00,0x00,0x00,0x00,
+0x27,0x84,0x90,0xf8,0x0c,0x00,0x27,0x2e,0x00,0x00,0x00,0x00,0x08,0x00,0x1a,0xcb,
+0x24,0x03,0x00,0x05,0x8f,0x82,0x91,0x2c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,
+0x00,0x00,0x00,0x00,0x8f,0x84,0xba,0x80,0xaf,0x80,0x91,0x2c,0x94,0x85,0x00,0x14,
+0x0c,0x00,0x1f,0xdd,0x00,0x00,0x00,0x00,0x93,0x82,0x91,0x51,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x60,
+0x00,0x00,0x20,0x21,0x8f,0x84,0xba,0x80,0x0c,0x00,0x1d,0x55,0x00,0x00,0x00,0x00,
+0x08,0x00,0x1a,0xa6,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0,0x3c,0x06,0xb0,0x03,
+0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x34,0xc6,0x00,0x5f,0xaf,0xbf,0x00,0x18,
+0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x5d,0x34,0x63,0x00,0x01,
+0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01,0xa0,0xc3,0x00,0x00,0x00,0x80,0x80,0x21,
+0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21,0x35,0x29,0x00,0x5e,0x00,0xe0,0x40,0x21,
+0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00,0x91,0x03,0x00,0x00,0x30,0x42,0x00,0x01,
+0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c,0x24,0x05,0x0f,0x00,0x24,0x02,0x00,0x06,
+0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f,0x3c,0x02,0xb0,0x03,0x34,0x42,0x02,0x00,
+0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x0f,
+0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x0f,
+0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x0f,
+0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x0f,
+0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x02,
+0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x02,
+0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x02,
+0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,0x24,0x06,0x00,0x02,
+0x08,0x00,0x1c,0x4f,0x3c,0x02,0xb0,0x03,0x24,0x04,0x08,0x8c,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04,0x24,0x05,0x00,0x0f,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,0x0c,0x00,0x18,0x5b,
+0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30,0x24,0x06,0x00,0x03,0x0c,0x00,0x18,0x5b,
+0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21,0x24,0x05,0x00,0x14,0x0c,0x00,0x18,0xa0,
+0x24,0x06,0x01,0x07,0x08,0x00,0x1c,0x4f,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x72,0x6c,
+0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xb8,
+0x8c,0x83,0x00,0x00,0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21,
+0xa7,0x82,0x96,0x30,0x27,0x88,0x96,0x40,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08,
+0x30,0xc2,0xff,0xff,0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21,
+0x00,0x60,0x30,0x21,0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21,
+0x00,0x87,0x20,0x21,0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4,
+0xa4,0x43,0x00,0x00,0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x34,0x42,0x07,0xf8,
+0x3c,0x04,0xb0,0x08,0xac,0x43,0x00,0x00,0xa7,0x83,0xba,0x1c,0x24,0x06,0x01,0x00,
+0x34,0x84,0x08,0x00,0x24,0xc2,0x00,0x01,0x28,0x43,0x02,0x00,0xac,0x82,0x00,0x00,
+0x00,0x40,0x30,0x21,0x14,0x60,0xff,0xfb,0x24,0x84,0x00,0x08,0x25,0xc2,0x00,0x0c,
+0x24,0x0a,0x00,0x02,0x3c,0x06,0xb0,0x03,0xaf,0x82,0xba,0x40,0x34,0xc6,0x00,0x64,
+0xa0,0x4a,0x00,0x18,0x94,0xc5,0x00,0x00,0x8f,0x82,0xba,0x40,0x25,0xc4,0x00,0x30,
+0x24,0x08,0x00,0x03,0x3c,0x03,0xb0,0x03,0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,
+0xaf,0x84,0xba,0x44,0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xba,0x44,
+0x25,0xc4,0x00,0x54,0x25,0xc7,0x00,0x78,0xa0,0x45,0x00,0x21,0xaf,0x84,0xba,0x48,
+0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xba,0x48,0x25,0xc8,0x00,0x9c,
+0x24,0x09,0x00,0x01,0xa0,0x45,0x00,0x21,0xaf,0x87,0xba,0x4c,0xa0,0xea,0x00,0x18,
+0x94,0xc4,0x00,0x00,0x8f,0x82,0xba,0x4c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,
+0xa0,0x44,0x00,0x21,0xaf,0x88,0xba,0x50,0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,
+0x8f,0x82,0xba,0x50,0x25,0xc4,0x00,0xc0,0x25,0xc6,0x00,0xe4,0xa0,0x45,0x00,0x21,
+0xaf,0x84,0xba,0x54,0xa0,0x89,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xba,0x54,
+0x3c,0x04,0xb0,0x03,0x34,0x84,0x00,0x60,0xa0,0x45,0x00,0x21,0xaf,0x86,0xba,0x58,
+0xa0,0xc0,0x00,0x18,0x94,0x85,0x00,0x00,0x8f,0x82,0xba,0x58,0x25,0xc3,0x01,0x08,
+0x25,0xc6,0x01,0x2c,0xa0,0x45,0x00,0x21,0xaf,0x83,0xba,0x5c,0xa0,0x60,0x00,0x18,
+0x94,0x87,0x00,0x00,0x8f,0x82,0xba,0x5c,0x25,0xc5,0x01,0x50,0x25,0xc4,0x01,0x74,
+0xa0,0x47,0x00,0x21,0x25,0xc8,0x01,0x98,0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,
+0x25,0xcb,0x02,0x04,0x25,0xcc,0x02,0x28,0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,
+0x3c,0x03,0xb0,0x03,0xaf,0x86,0xba,0x60,0x34,0x63,0x00,0x38,0xa0,0xc0,0x00,0x18,
+0xaf,0x85,0xba,0x64,0xa0,0xa0,0x00,0x18,0xaf,0x84,0xba,0x68,0xa0,0x80,0x00,0x18,
+0xaf,0x88,0xba,0x6c,0xa1,0x00,0x00,0x18,0xaf,0x89,0xba,0x70,0xa1,0x20,0x00,0x18,
+0xaf,0x8a,0xba,0x74,0xa1,0x40,0x00,0x18,0xaf,0x8b,0xba,0x78,0xa1,0x60,0x00,0x18,
+0xaf,0x8c,0xba,0x7c,0xa1,0x80,0x00,0x18,0xaf,0x8d,0xba,0x80,0xa1,0xa2,0x00,0x18,
+0x94,0x64,0x00,0x00,0x8f,0x82,0xba,0x80,0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,
+0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x11,0xaf,0x85,0xba,0x84,0x34,0x63,0x00,0x6e,
+0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xba,0x84,0x25,0xc5,0x02,0x94,
+0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x12,0xaf,0x85,0xba,0x88,
+0x34,0x63,0x00,0x6c,0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xba,0x88,
+0x24,0x05,0xff,0xff,0x24,0x07,0x00,0x01,0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,
+0x27,0x84,0xba,0x40,0x8c,0x82,0x00,0x00,0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,
+0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x00,0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,
+0x8c,0x82,0x00,0x00,0xa4,0x65,0x00,0x06,0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,
+0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x0c,0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,
+0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,
+0xa4,0x45,0x00,0x14,0xa0,0x67,0x00,0x17,0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,
+0xa0,0x40,0x00,0x20,0x04,0xc1,0xff,0xe7,0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,
+0x24,0x63,0x75,0x54,0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x10,0x00,0x80,0x60,0x21,
+0x10,0x40,0x00,0x56,0x00,0x00,0x70,0x21,0x97,0x82,0x96,0x30,0x94,0x8a,0x00,0x0c,
+0x27,0x87,0x96,0x40,0x00,0x02,0x40,0xc0,0x01,0x02,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x47,0x10,0x21,0x90,0x8b,0x00,0x18,0xa4,0x4a,0x00,0x00,0x94,0x83,0x00,0x0e,
+0x39,0x64,0x00,0x10,0x2c,0x84,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x34,0x85,0x00,0x02,0x39,0x63,0x00,0x11,0x00,0x83,0x28,0x0b,0x34,0xa3,0x00,0x08,
+0x39,0x64,0x00,0x12,0x00,0x02,0x10,0x80,0x00,0xa4,0x18,0x0b,0x00,0x47,0x10,0x21,
+0x94,0x49,0x00,0x04,0x34,0x64,0x00,0x20,0x00,0x6b,0x20,0x0b,0x34,0x83,0x00,0x40,
+0x39,0x62,0x00,0x01,0x00,0x82,0x18,0x0b,0x00,0x09,0x30,0xc0,0x34,0x64,0x00,0x80,
+0x00,0xc9,0x28,0x21,0x39,0x62,0x00,0x02,0x00,0x60,0x68,0x21,0x00,0x82,0x68,0x0a,
+0x00,0x05,0x28,0x80,0x3c,0x02,0xb0,0x08,0x00,0xa7,0x28,0x21,0x00,0xc2,0x30,0x21,
+0x01,0x02,0x40,0x21,0x34,0x03,0xff,0xff,0x35,0xa4,0x01,0x00,0x39,0x62,0x00,0x03,
+0x2d,0x67,0x00,0x13,0xad,0x0a,0x00,0x00,0xa4,0xa3,0x00,0x00,0xac,0xc3,0x00,0x00,
+0xa7,0x89,0x96,0x30,0x10,0xe0,0x00,0x0f,0x00,0x82,0x68,0x0a,0x3c,0x03,0x80,0x01,
+0x00,0x0b,0x10,0x80,0x24,0x63,0x09,0x4c,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x34,0x63,0x00,0x60,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x00,
+0x00,0x02,0x74,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x44,0x00,0x00,
+0x93,0x83,0x96,0x24,0x91,0x82,0x00,0x21,0x01,0xc4,0x20,0x21,0x91,0x85,0x00,0x10,
+0x00,0x04,0x24,0x00,0x00,0x62,0x18,0x21,0x00,0x04,0x74,0x03,0x00,0x6e,0x18,0x23,
+0x00,0x65,0x10,0x2a,0x00,0xa2,0x18,0x0a,0x00,0x0d,0x24,0x00,0x3c,0x02,0xb0,0x06,
+0x24,0x05,0xff,0xff,0x00,0x64,0x18,0x25,0x34,0x42,0x80,0x20,0xac,0x43,0x00,0x00,
+0xa5,0x85,0x00,0x0e,0xa1,0x80,0x00,0x10,0xa5,0x85,0x00,0x0c,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x08,0x00,0x1d,0x99,0x34,0x63,0x00,0x62,
+0x3c,0x03,0xb0,0x03,0x08,0x00,0x1d,0x99,0x34,0x63,0x00,0x64,0x3c,0x03,0xb0,0x03,
+0x08,0x00,0x1d,0x99,0x34,0x63,0x00,0x66,0x3c,0x03,0xb0,0x03,0x08,0x00,0x1d,0x99,
+0x34,0x63,0x00,0x38,0x3c,0x03,0xb0,0x03,0x08,0x00,0x1d,0x99,0x34,0x63,0x00,0x6e,
+0x3c,0x03,0xb0,0x03,0x08,0x00,0x1d,0x99,0x34,0x63,0x00,0x6c,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x77,0x1c,0x00,0x05,0x28,0x40,
+0xac,0x62,0x00,0x00,0x00,0xa6,0x28,0x21,0x2c,0xe2,0x00,0x10,0x14,0x80,0x00,0x06,
+0x00,0x00,0x18,0x21,0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xe0,0x18,0x21,
+0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x24,0x02,0x00,0x20,0x10,0xe2,0x00,0x06,
+0x2c,0xe4,0x00,0x10,0x24,0xa2,0x00,0x01,0x10,0x80,0xff,0xf9,0x00,0x02,0x11,0x00,
+0x08,0x00,0x1d,0xd4,0x00,0x47,0x18,0x21,0x08,0x00,0x1d,0xd4,0x24,0xa3,0x00,0x50,
+0x27,0xbd,0xff,0xc0,0xaf,0xb7,0x00,0x34,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,
+0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x3c,0xaf,0xbe,0x00,0x38,
+0xaf,0xb6,0x00,0x30,0xaf,0xb3,0x00,0x24,0xaf,0xb0,0x00,0x18,0x84,0x85,0x00,0x08,
+0x00,0x80,0x90,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x34,0x84,0x00,0x20,
+0x24,0x42,0x77,0x80,0x3c,0x03,0xb0,0x06,0x00,0x05,0x28,0x80,0xac,0x82,0x00,0x00,
+0x00,0xa3,0x28,0x21,0x3c,0x04,0xb0,0x06,0x8c,0xa3,0x00,0x00,0x34,0x84,0x80,0x24,
+0x8c,0xa6,0x00,0x00,0x8c,0x82,0x00,0x00,0x30,0x71,0xff,0xff,0x00,0x11,0x2a,0x00,
+0x34,0x42,0x01,0x00,0x3c,0x03,0xb0,0x00,0xac,0x82,0x00,0x00,0x00,0xa3,0x40,0x21,
+0x8d,0x1e,0x00,0x00,0x8d,0x13,0x00,0x04,0x96,0x44,0x00,0x08,0x00,0x11,0xa0,0xc0,
+0x02,0x91,0x10,0x21,0x00,0x02,0x38,0x80,0x00,0x13,0x12,0x02,0x30,0x42,0x00,0x1f,
+0x24,0x84,0x00,0x02,0x27,0x83,0x96,0x50,0xa6,0x42,0x00,0x06,0x30,0x84,0x01,0xff,
+0x24,0x02,0x00,0x10,0x00,0xe3,0x18,0x21,0xa6,0x44,0x00,0x08,0x8d,0x10,0x00,0x08,
+0xa0,0x62,0x00,0x06,0x86,0x44,0x00,0x06,0x27,0x82,0x96,0x44,0x00,0xe2,0x10,0x21,
+0xac,0x48,0x00,0x18,0x24,0x02,0x00,0x13,0x00,0x06,0xbc,0x02,0x10,0x82,0x00,0xe6,
+0x00,0x00,0xa8,0x21,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,0xa6,0x40,0x00,0x02,
+0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x45,0x00,0x00,
+0x00,0x10,0x1b,0xc2,0x00,0x04,0x20,0x82,0x27,0x82,0x96,0x40,0x00,0xe2,0x10,0x21,
+0x30,0x84,0x00,0x01,0x30,0x63,0x00,0x01,0xac,0x45,0x00,0x08,0x10,0x60,0x00,0xbc,
+0xaf,0xa4,0x00,0x10,0x00,0x10,0x16,0x82,0x30,0x46,0x00,0x01,0x00,0x10,0x12,0x02,
+0x00,0x10,0x19,0xc2,0x00,0x10,0x26,0x02,0x00,0x10,0x2e,0x42,0x30,0x47,0x00,0x7f,
+0x24,0x02,0x00,0x01,0x30,0x76,0x00,0x01,0x30,0x84,0x00,0x01,0x10,0xc2,0x00,0xa7,
+0x30,0xa3,0x00,0x01,0x0c,0x00,0x1d,0xc7,0x00,0x60,0x28,0x21,0x00,0x40,0xa8,0x21,
+0x02,0x91,0x10,0x21,0x00,0x02,0x10,0x80,0x2e,0xa4,0x00,0x54,0x27,0x85,0x96,0x50,
+0x27,0x83,0x96,0x48,0x00,0x04,0xa8,0x0a,0x00,0x45,0x28,0x21,0x26,0xc4,0x00,0x02,
+0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x06,0xa0,0x55,0x00,0x07,0xa0,0xb5,0x00,0x02,
+0xa0,0xb5,0x00,0x01,0x00,0x10,0x14,0x82,0x00,0x10,0x1d,0xc2,0x30,0x48,0x00,0x01,
+0x00,0x13,0x15,0x82,0x00,0x13,0x21,0x82,0x30,0x63,0x00,0x01,0x00,0x10,0x2c,0x02,
+0x00,0x10,0x34,0x42,0x30,0x49,0x00,0x03,0x24,0x02,0x00,0x01,0xa6,0x5e,0x00,0x04,
+0xa6,0x43,0x00,0x00,0x30,0x8a,0x00,0x01,0x32,0x73,0x00,0x07,0x30,0xa5,0x00,0x01,
+0x30,0xc6,0x00,0x01,0x11,0x02,0x00,0x77,0x32,0x07,0x00,0x7f,0x15,0x40,0x00,0x03,
+0x00,0x00,0x00,0x00,0x15,0x20,0x00,0x68,0x24,0x02,0x00,0x01,0x96,0x42,0x00,0x04,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,0xa6,0x42,0x00,0x04,0x00,0xa0,0x20,0x21,
+0x00,0xc0,0x28,0x21,0x0c,0x00,0x1d,0xc7,0x01,0x00,0x30,0x21,0x02,0x91,0x18,0x21,
+0x00,0x03,0x38,0x80,0x2e,0xa5,0x00,0x54,0x27,0x84,0x96,0x50,0x00,0xe4,0x20,0x21,
+0x00,0x05,0x10,0x0a,0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,
+0x96,0x45,0x00,0x04,0x27,0x82,0x96,0x40,0x00,0xe2,0x10,0x21,0xa4,0x45,0x00,0x06,
+0x27,0x83,0x96,0x44,0x00,0xe3,0x18,0x21,0x92,0x45,0x00,0x01,0x8c,0x66,0x00,0x18,
+0x27,0x82,0x96,0x60,0x00,0xe2,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x85,0x00,0x07,
+0x94,0xc3,0x00,0x10,0x24,0x02,0x00,0x04,0x30,0x63,0x00,0x0f,0x10,0x62,0x00,0x42,
+0x24,0xc6,0x00,0x10,0x94,0xc3,0x00,0x16,0x27,0x88,0x96,0x58,0x00,0xe8,0x10,0x21,
+0xa4,0x43,0x00,0x02,0x94,0xc2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,
+0x14,0x40,0x00,0x30,0x02,0x91,0x20,0x21,0x94,0xc2,0x00,0x00,0x24,0x03,0x00,0xa4,
+0x30,0x42,0x00,0xff,0x10,0x43,0x00,0x2b,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x00,
+0x24,0x03,0x00,0x88,0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x20,0x02,0x91,0x18,0x21,
+0x27,0x84,0x96,0x60,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00,
+0x3c,0x04,0x00,0x80,0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x00,0x17,0x10,0xc0,
+0x00,0x57,0x10,0x21,0x27,0x84,0x96,0x40,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,
+0x94,0x45,0x00,0x00,0x02,0x91,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x64,0x20,0x21,
+0x24,0x02,0xff,0xff,0x00,0x68,0x18,0x21,0xa0,0x73,0x00,0x00,0xa4,0x82,0x00,0x02,
+0xa4,0x97,0x00,0x04,0xae,0x51,0x02,0xb8,0xa6,0x45,0x00,0x0a,0x7b,0xbe,0x01,0xfc,
+0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,
+0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x94,0xc2,0x00,0x18,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xdd,0x02,0x91,0x18,0x21,
+0x02,0x91,0x20,0x21,0x27,0x82,0x96,0x60,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21,
+0x8c,0x83,0x00,0x00,0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24,
+0x08,0x00,0x1e,0x97,0xac,0x83,0x00,0x00,0x27,0x88,0x96,0x58,0x00,0xe8,0x10,0x21,
+0x08,0x00,0x1e,0x81,0xa4,0x40,0x00,0x02,0x11,0x22,0x00,0x07,0x00,0x00,0x00,0x00,
+0x2d,0x22,0x00,0x02,0x14,0x40,0xff,0x9a,0x00,0xa0,0x20,0x21,0x96,0x42,0x00,0x04,
+0x08,0x00,0x1e,0x5e,0x24,0x42,0x00,0x0c,0x96,0x42,0x00,0x04,0x08,0x00,0x1e,0x5e,
+0x24,0x42,0x00,0x08,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x48,0xff,0x87,
+0x02,0x91,0x18,0x21,0x27,0x82,0x96,0x44,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,
+0x8c,0x64,0x00,0x18,0x3c,0x02,0xff,0xfb,0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,
+0xac,0x82,0x00,0x08,0x08,0x00,0x1e,0x57,0x00,0x00,0x40,0x21,0x8f,0xa2,0x00,0x10,
+0x00,0x00,0x00,0x00,0x14,0x46,0xff,0x57,0x3c,0x02,0xfb,0xff,0x34,0x42,0xff,0xff,
+0x02,0x02,0x10,0x24,0xad,0x02,0x00,0x08,0x08,0x00,0x1e,0x35,0x00,0x00,0x30,0x21,
+0x93,0x88,0xc1,0x54,0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82,0x27,0x82,0x96,0x48,
+0x2d,0x05,0x00,0x0c,0x00,0xe2,0x48,0x21,0x30,0x63,0x00,0x01,0x30,0x86,0x00,0x01,
+0x14,0xa0,0x00,0x06,0x01,0x00,0x38,0x21,0x00,0x03,0x10,0x40,0x00,0x46,0x10,0x21,
+0x00,0x02,0x11,0x00,0x01,0x02,0x10,0x21,0x24,0x47,0x00,0x04,0x02,0x91,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x84,0x96,0x50,0x27,0x83,0x96,0x48,0x00,0x44,0x20,0x21,
+0x00,0x43,0x10,0x21,0xa1,0x27,0x00,0x07,0xa0,0x40,0x00,0x06,0xa0,0x80,0x00,0x02,
+0x08,0x00,0x1e,0x45,0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01,0xa6,0x42,0x00,0x02,
+0x0c,0x00,0x04,0x40,0x01,0x00,0x20,0x21,0x08,0x00,0x1e,0xa7,0x00,0x00,0x00,0x00,
+0x30,0xa7,0xff,0xff,0x00,0x07,0x18,0xc0,0x00,0x67,0x18,0x21,0x3c,0x06,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x24,0x42,0x7c,0x10,0x27,0x85,0x96,0x50,0x00,0x03,0x18,0x80,
+0x34,0xc6,0x00,0x20,0x00,0x65,0x18,0x21,0xac,0xc2,0x00,0x00,0x80,0x62,0x00,0x07,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x29,0x00,0x80,0x28,0x21,0x90,0x82,0x00,0x16,
+0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01,0x14,0x60,0x00,0x02,
+0xa0,0x82,0x00,0x16,0xa0,0x80,0x00,0x17,0x90,0xa2,0x00,0x04,0x3c,0x03,0xb0,0x03,
+0x27,0x86,0x96,0x40,0x14,0x40,0x00,0x06,0x34,0x63,0x00,0x20,0x24,0x02,0x00,0x01,
+0xa0,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,0x03,0xe0,0x00,0x08,0xa4,0xa7,0x00,0x00,
+0x94,0xa4,0x00,0x02,0x3c,0x02,0x80,0x01,0x24,0x42,0x93,0x34,0xac,0x62,0x00,0x00,
+0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,
+0x94,0x62,0x00,0x04,0xa4,0x67,0x00,0x02,0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,
+0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x00,0x83,0x20,0x21,
+0xa4,0x47,0x00,0x00,0xac,0x87,0x00,0x00,0x90,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,
+0x24,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x04,0x90,0x82,0x00,0x16,
+0x24,0x85,0x00,0x06,0x34,0x42,0x00,0x01,0x30,0x43,0x00,0x02,0x14,0x60,0xff,0xda,
+0xa0,0x82,0x00,0x16,0x24,0x02,0x00,0x01,0x08,0x00,0x1f,0x1a,0xa0,0x82,0x00,0x17,
+0x27,0xbd,0xff,0xe8,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x00,0x80,0x80,0x21,
+0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
+0x24,0x42,0x7d,0x10,0x10,0x80,0x00,0x38,0xac,0x62,0x00,0x00,0x8e,0x04,0x02,0xb8,
+0x0c,0x00,0x02,0x7e,0x00,0x00,0x00,0x00,0x97,0x88,0x96,0x30,0x96,0x0c,0x02,0xba,
+0x3c,0x04,0xb0,0x08,0x00,0x08,0x30,0xc0,0x00,0xc4,0x10,0x21,0xac,0x4c,0x00,0x00,
+0x8e,0x03,0x02,0xb8,0x27,0x89,0x96,0x40,0x34,0x0b,0xff,0xff,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,0x94,0x4a,0x00,0x04,
+0x00,0xc8,0x30,0x21,0x00,0x06,0x30,0x80,0x00,0x0a,0x28,0xc0,0x00,0xa4,0x20,0x21,
+0xac,0x8b,0x00,0x00,0x8e,0x02,0x02,0xb8,0x27,0x84,0x96,0x50,0x00,0xaa,0x28,0x21,
+0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,0x27,0x82,0x96,0x44,
+0x00,0x62,0x10,0x21,0x8c,0x47,0x00,0x18,0x00,0x64,0x18,0x21,0x80,0x68,0x00,0x06,
+0x8c,0xe4,0x00,0x00,0x00,0x05,0x28,0x80,0x3c,0x03,0xb0,0x06,0x30,0x84,0xff,0xff,
+0x00,0x88,0x20,0x21,0x30,0x82,0x00,0xff,0x00,0x02,0x10,0x2b,0x00,0x04,0x22,0x02,
+0x00,0x82,0x20,0x21,0x3c,0x02,0x00,0x04,0x00,0xa9,0x28,0x21,0x00,0x82,0x20,0x25,
+0x00,0xc9,0x30,0x21,0x34,0x63,0x80,0x20,0xa4,0xcc,0x00,0x00,0xac,0x64,0x00,0x00,
+0xa4,0xab,0x00,0x00,0xa7,0x8a,0x96,0x30,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x86,0x03,0x00,0x06,0x27,0x82,0xba,0x40,
+0x96,0x05,0x02,0xba,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,
+0x0c,0x00,0x1f,0x04,0x00,0x00,0x00,0x00,0x08,0x00,0x1f,0x82,0x00,0x00,0x00,0x00,
+0x94,0x88,0x00,0x00,0x00,0x80,0x58,0x21,0x27,0x8a,0x96,0x40,0x00,0x08,0x18,0xc0,
+0x00,0x68,0x18,0x21,0x3c,0x04,0xb0,0x03,0x00,0x03,0x18,0x80,0x3c,0x02,0x80,0x00,
+0x00,0x6a,0x18,0x21,0x34,0x84,0x00,0x20,0x24,0x42,0x7e,0x40,0x30,0xa5,0xff,0xff,
+0xac,0x82,0x00,0x00,0x94,0x67,0x00,0x02,0x11,0x05,0x00,0x35,0x24,0x04,0x00,0x01,
+0x91,0x66,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x86,0x10,0x2a,0x10,0x40,0x00,0x10,
+0x00,0xc0,0x48,0x21,0x3c,0x0d,0xb0,0x03,0x01,0x40,0x60,0x21,0x35,0xad,0x00,0x20,
+0x10,0xe5,0x00,0x0d,0x24,0x84,0x00,0x01,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,
+0x00,0x02,0x10,0x80,0x01,0x20,0x30,0x21,0x00,0x4a,0x10,0x21,0x00,0x86,0x18,0x2a,
+0x00,0xe0,0x40,0x21,0x94,0x47,0x00,0x02,0x14,0x60,0xff,0xf5,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,0x00,0x08,0x20,0xc0,0x00,0x88,0x20,0x21,
+0x24,0xc2,0xff,0xff,0x00,0x04,0x20,0x80,0xa1,0x62,0x00,0x04,0x00,0x8c,0x20,0x21,
+0x94,0x83,0x00,0x04,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x4c,0x10,0x21,0x00,0x03,0x28,0xc0,0x94,0x46,0x00,0x02,0x00,0xa3,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x6c,0x18,0x21,0xa4,0x66,0x00,0x00,0xa4,0x86,0x00,0x02,
+0x95,0x64,0x00,0x02,0x3c,0x03,0xb0,0x08,0x3c,0x02,0x80,0x01,0x00,0xa3,0x28,0x21,
+0x24,0x42,0x93,0x34,0xad,0xa2,0x00,0x00,0x10,0x87,0x00,0x03,0xac,0xa6,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x08,0x00,0x1f,0xd0,0xa5,0x68,0x00,0x02,
+0x91,0x62,0x00,0x04,0xa5,0x67,0x00,0x00,0x24,0x42,0xff,0xff,0x30,0x43,0x00,0xff,
+0x14,0x60,0xff,0xf7,0xa1,0x62,0x00,0x04,0x24,0x02,0xff,0xff,0x08,0x00,0x1f,0xd0,
+0xa5,0x62,0x00,0x02,0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21,0x27,0xbd,0xff,0xd8,
+0x00,0x06,0x30,0x80,0x27,0x82,0x96,0x44,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10,0x00,0xc2,0x10,0x21,
+0x8c,0x47,0x00,0x18,0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,
+0x34,0xa5,0x00,0x20,0x24,0x42,0x7f,0x74,0xac,0xa2,0x00,0x00,0x27,0x83,0x96,0x50,
+0x00,0xc3,0x30,0x21,0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06,0x00,0x80,0x88,0x21,
+0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x10,0x60,0x00,0x02,
+0x00,0x02,0x12,0x02,0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff,0x01,0x12,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x50,0x00,0x43,0x10,0x21,0x80,0x44,0x00,0x07,
+0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06,0x32,0x50,0xff,0xff,
+0x02,0x20,0x20,0x21,0x0c,0x00,0x1f,0x90,0x02,0x00,0x28,0x21,0x92,0x22,0x00,0x10,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08,0x3c,0x09,0x80,0x01,
+0x27,0x88,0x96,0x40,0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0,0x00,0x90,0x20,0x21,
+0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,
+0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x48,0x10,0x21,0x00,0xa3,0x28,0x21,0x25,0x26,0x93,0x34,0x34,0x03,0xff,0xff,
+0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,
+0xac,0xa3,0x00,0x00,0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a,0xa6,0x32,0x00,0x0e,
+0x02,0x62,0x10,0x21,0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10,0x92,0x22,0x00,0x16,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16,0x92,0x22,0x00,0x04,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x16,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x20,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x96,0x22,0x00,0x0e,0x27,0x88,0x96,0x40,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,
+0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x06,0xb0,0x03,
+0x3c,0x09,0x80,0x01,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0xa3,0x28,0x21,0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20,0x25,0x23,0x93,0x34,
+0xac,0xc3,0x00,0x00,0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00,0x08,0x00,0x20,0x0e,
+0xa4,0x90,0x00,0x02,0x08,0x00,0x20,0x05,0x32,0x50,0xff,0xff,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x01,0x24,0x42,0x81,0x3c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,
+0x90,0x82,0x00,0x04,0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21,0x30,0xa8,0xff,0xff,
+0x00,0x4a,0x20,0x23,0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff,0x30,0xee,0xff,0xff,
+0x11,0x09,0x00,0x73,0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0,0x00,0x08,0x10,0xc0,
+0x00,0x48,0x10,0x21,0x03,0x0e,0x20,0x21,0x27,0x8d,0x96,0x40,0x00,0x04,0x20,0x80,
+0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21,0x94,0x86,0x00,0x02,
+0x94,0x43,0x00,0x04,0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02,0x00,0x03,0x28,0xc0,
+0x00,0xa3,0x18,0x21,0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08,0x00,0x03,0x18,0x80,
+0x00,0xa2,0x28,0x21,0x00,0x6d,0x18,0x21,0x27,0x22,0x93,0x34,0x3c,0x01,0xb0,0x03,
+0xac,0x22,0x00,0x20,0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57,0xac,0xa6,0x00,0x00,
+0x01,0xe0,0x30,0x21,0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21,0x01,0x40,0x38,0x21,
+0x27,0x8b,0x96,0x44,0x27,0x8a,0x96,0x50,0x00,0x06,0x40,0xc0,0x01,0x06,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x6a,0x18,0x21,
+0x80,0x65,0x00,0x06,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0xff,0xff,
+0x00,0x45,0x10,0x21,0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02,0x01,0x22,0x18,0x21,
+0x24,0x62,0x00,0x01,0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff,0x30,0x69,0x00,0xff,
+0x01,0x06,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x24,0xe7,0xff,0xff,
+0x94,0x46,0x00,0x02,0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0,0x91,0x82,0x00,0x10,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03,0xa5,0x8f,0x00,0x0c,
+0x03,0x0e,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,
+0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21,0x27,0x26,0x93,0x34,
+0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,
+0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10,0x91,0x83,0x00,0x04,
+0xa5,0x8e,0x00,0x0e,0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05,0xa1,0x82,0x00,0x10,
+0x91,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa1,0x82,0x00,0x16,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e,0x3c,0x03,0xb0,0x08,
+0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,
+0x94,0x82,0x00,0x04,0x34,0xc6,0x00,0x20,0x27,0x27,0x93,0x34,0x00,0x02,0x28,0xc0,
+0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x4d,0x10,0x21,
+0xac,0xc7,0x00,0x00,0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00,0xac,0xaf,0x00,0x00,
+0x08,0x00,0x20,0x9d,0x03,0x0e,0x20,0x21,0x08,0x00,0x20,0x78,0xa5,0x88,0x00,0x02,
+0x00,0x0e,0xc0,0xc0,0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x8d,0x96,0x40,
+0x00,0x4d,0x10,0x21,0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff,0x14,0x80,0x00,0x05,
+0xa5,0x83,0x00,0x00,0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01,0x08,0x00,0x20,0x78,
+0xa5,0x82,0x00,0x02,0x08,0x00,0x20,0x78,0x3c,0x19,0x80,0x01,0x3c,0x08,0xb0,0x03,
+0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0x80,0x24,0x42,0x83,0x7c,0x35,0x08,0x00,0x20,
+0xaf,0xb2,0x00,0x60,0xaf,0xb1,0x00,0x5c,0xaf,0xbf,0x00,0x7c,0xaf,0xbe,0x00,0x78,
+0xaf,0xb7,0x00,0x74,0xaf,0xb6,0x00,0x70,0xaf,0xb5,0x00,0x6c,0xaf,0xb4,0x00,0x68,
+0xaf,0xb3,0x00,0x64,0xaf,0xb0,0x00,0x58,0xad,0x02,0x00,0x00,0xaf,0xa4,0x00,0x80,
+0x90,0x83,0x00,0x0a,0x27,0x82,0xba,0x40,0xaf,0xa6,0x00,0x88,0x00,0x03,0x18,0x80,
+0x00,0x62,0x18,0x21,0x8c,0x7e,0x00,0x00,0xaf,0xa7,0x00,0x8c,0x27,0x86,0x96,0x44,
+0x97,0xc3,0x00,0x14,0x30,0xb1,0xff,0xff,0x00,0x03,0x20,0xc0,0xaf,0xa3,0x00,0x1c,
+0x00,0x83,0x18,0x21,0xaf,0xa4,0x00,0x50,0x00,0x03,0x18,0x80,0x27,0x84,0x96,0x50,
+0x00,0x64,0x20,0x21,0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21,0x8c,0x66,0x00,0x18,
+0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2,0x00,0x04,0x1c,0x82,
+0x00,0x04,0x24,0x42,0x30,0x63,0x00,0x01,0x00,0xc2,0x38,0x21,0x30,0x84,0x00,0x01,
+0x24,0x02,0x00,0x01,0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34,0xaf,0xa4,0x00,0x38,
+0xaf,0xa0,0x00,0x40,0xaf,0xa0,0x00,0x44,0xaf,0xa2,0x00,0x20,0x83,0xc3,0x00,0x12,
+0x8f,0xb2,0x00,0x1c,0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xa2,0xaf,0xa3,0x00,0x28,
+0x00,0x10,0x10,0x82,0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11,0xaf,0xa0,0x00,0x30,
+0x8f,0xa4,0x00,0x90,0x27,0x82,0x86,0xb0,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x21,
+0x24,0xa2,0x00,0x06,0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00,0x00,0x45,0x10,0x04,
+0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,
+0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,0x30,0x42,0xff,0xfc,0xaf,0xa2,0x00,0x30,
+0x8f,0xa3,0x00,0x1c,0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff,0xaf,0xa0,0x00,0x2c,
+0xaf,0xa2,0x00,0x48,0xaf,0xa3,0x00,0x4c,0x00,0x60,0xb0,0x21,0x00,0x00,0xb8,0x21,
+0x18,0x80,0x00,0x3b,0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02,0xaf,0xb1,0x00,0x54,
+0x00,0x80,0xa8,0x21,0x00,0x12,0xa0,0xc0,0x02,0x92,0x10,0x21,0x00,0x02,0x80,0x80,
+0x27,0x85,0x96,0x40,0x02,0x05,0x18,0x21,0x94,0x63,0x00,0x02,0x02,0x40,0x20,0x21,
+0x00,0x00,0x28,0x21,0x0c,0x00,0x17,0x43,0xaf,0xa3,0x00,0x18,0x90,0x42,0x00,0x00,
+0x24,0x03,0x00,0x08,0x30,0x42,0x00,0x0c,0x10,0x43,0x01,0x5c,0x24,0x04,0x00,0x01,
+0x24,0x02,0x00,0x01,0x10,0x82,0x01,0x3b,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x04,
+0x02,0x92,0x20,0x21,0x94,0x66,0x00,0x00,0x00,0x04,0x20,0x80,0x27,0x82,0x96,0x48,
+0x00,0x82,0x10,0x21,0x27,0x83,0x96,0x50,0x80,0x45,0x00,0x06,0x00,0x83,0x20,0x21,
+0x30,0xd0,0xff,0xff,0x80,0x91,0x00,0x05,0x80,0x93,0x00,0x04,0x8f,0xa4,0x00,0x80,
+0x32,0x03,0x00,0xff,0x00,0x10,0x12,0x03,0x38,0xa5,0x00,0x00,0x00,0x60,0x80,0x21,
+0x00,0x45,0x80,0x0a,0xa4,0x82,0x00,0x44,0x12,0x20,0x01,0x1c,0xa4,0x83,0x00,0x46,
+0x02,0x71,0x10,0x21,0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xbb,0x02,0x92,0x10,0x21,
+0x93,0x82,0x91,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0xae,
+0x02,0x92,0x28,0x21,0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,0x02,0x40,0xb0,0x21,
+0x26,0xb5,0xff,0xff,0x8f,0xb2,0x00,0x18,0x16,0xa0,0xff,0xca,0x00,0x00,0x00,0x00,
+0x16,0xe0,0x00,0x9e,0x02,0xc0,0x38,0x21,0x8f,0xa5,0x00,0x90,0x00,0x00,0x00,0x00,
+0x2c,0xa2,0x00,0x10,0x10,0x40,0x00,0x2e,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x24,
+0x00,0x00,0x00,0x00,0x18,0x40,0x00,0x2a,0x24,0x03,0x00,0x01,0x97,0xd2,0x00,0x14,
+0xa3,0xc3,0x00,0x12,0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21,0x00,0x02,0x80,0x80,
+0x27,0x82,0x96,0x50,0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06,0x27,0x84,0x96,0x44,
+0x02,0x04,0x20,0x21,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,
+0x8c,0x85,0x00,0x18,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0x00,0xa3,0x38,0x21,
+0x8f,0xa3,0x00,0x3c,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0d,0x00,0x00,0x00,0x00,
+0x27,0x82,0x96,0x40,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x24,0x02,0x00,0x01,
+0xa7,0xc3,0x00,0x1a,0x7b,0xbe,0x03,0xfc,0x7b,0xb6,0x03,0xbc,0x7b,0xb4,0x03,0x7c,
+0x7b,0xb2,0x03,0x3c,0x7b,0xb0,0x02,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x80,
+0x8f,0xa4,0x00,0x90,0x8f,0xa5,0x00,0x38,0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,
+0x0c,0x00,0x0d,0xfe,0xaf,0xa0,0x00,0x14,0x08,0x00,0x21,0x94,0x00,0x00,0x00,0x00,
+0x8f,0xa4,0x00,0x44,0x8f,0xa3,0x00,0x24,0x8f,0xa5,0x00,0x2c,0x30,0x82,0x00,0x03,
+0xa3,0xc3,0x00,0x12,0x00,0x02,0x10,0x23,0x8f,0xa4,0x00,0x80,0x30,0x42,0x00,0x03,
+0x00,0xa2,0x10,0x23,0xa7,0xc2,0x00,0x1a,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x96,0x44,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0x00,0x18,0x00,0x00,0x00,0x00,
+0x8f,0xa5,0x00,0x50,0x8f,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0xa2,0x18,0x21,
+0x00,0x03,0x18,0x80,0x27,0x82,0x96,0x58,0x00,0x62,0x18,0x21,0x90,0x65,0x00,0x00,
+0x27,0x83,0xba,0xe0,0x00,0x05,0x11,0x00,0x00,0x45,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x45,0x10,0x23,0x00,0x02,0x30,0x80,0x00,0xc3,0x38,0x21,0x90,0xe4,0x00,0x00,
+0x24,0x02,0x00,0x1b,0x10,0x82,0x00,0x0e,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x24,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x04,0x00,0xa0,0x20,0x21,0x8f,0xa2,0x00,0x24,
+0x08,0x00,0x21,0x99,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x21,0x00,0x00,0x28,0x21,
+0x0c,0x00,0x25,0xc4,0x00,0x00,0x38,0x21,0x08,0x00,0x21,0xd7,0x00,0x00,0x00,0x00,
+0x27,0x82,0xbb,0xc0,0x00,0xc2,0x20,0x21,0x94,0x83,0x00,0x00,0x24,0x02,0x00,0x05,
+0x10,0x43,0x00,0x25,0x24,0x62,0x00,0x01,0xa4,0x82,0x00,0x00,0x8f,0xa3,0x00,0x24,
+0x8f,0xa4,0x00,0x28,0x00,0x00,0x00,0x00,0x10,0x64,0xff,0xec,0x00,0x00,0x00,0x00,
+0x10,0x60,0xff,0xea,0x00,0x00,0x00,0x00,0x27,0x82,0xbb,0xb8,0x00,0xc2,0x20,0x21,
+0x90,0x83,0x00,0x06,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x03,
+0x24,0x62,0x00,0x01,0xa0,0x82,0x00,0x06,0x00,0x40,0x18,0x21,0x30,0x63,0x00,0xff,
+0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x09,0x00,0x00,0x00,0x00,0x27,0x84,0xba,0xe4,
+0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x23,
+0x24,0x42,0xff,0xc0,0x08,0x00,0x21,0xd7,0xac,0xe2,0x00,0xd0,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00,0x27,0x84,0xba,0xe4,0x00,0xc4,0x10,0x21,
+0x08,0x00,0x21,0xfc,0xac,0x43,0x00,0xe0,0x27,0x83,0xbb,0xb8,0x00,0xc3,0x18,0x21,
+0x90,0x62,0x00,0x06,0x00,0x00,0x00,0x00,0x2c,0x42,0x00,0x02,0x10,0x40,0xff,0xc7,
+0xa4,0x80,0x00,0x00,0x08,0x00,0x21,0xd7,0xa0,0x60,0x00,0x06,0x8f,0xa5,0x00,0x48,
+0x8f,0xa6,0x00,0x4c,0x03,0xc0,0x20,0x21,0x0c,0x00,0x20,0x4f,0xaf,0xb7,0x00,0x10,
+0x08,0x00,0x21,0x76,0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80,0x27,0x82,0x96,0x40,
+0x00,0xa2,0x28,0x21,0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x49,0x00,0x00,0x00,0x00,
+0x08,0x00,0x21,0x6e,0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80,0x27,0x83,0x96,0x50,
+0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01,0x03,0xc0,0x20,0x21,0x02,0x40,0x28,0x21,
+0x0c,0x00,0x23,0x1c,0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x45,0x00,0x00,0x00,0x00,
+0x16,0xe0,0x00,0x4b,0x02,0xc0,0x38,0x21,0x8f,0xa5,0x00,0x24,0x8f,0xb6,0x00,0x18,
+0x8f,0xa3,0x00,0x20,0x24,0xa5,0x00,0x01,0x24,0x02,0x00,0x01,0xaf,0xb2,0x00,0x48,
+0xaf,0xb6,0x00,0x4c,0x10,0x62,0x00,0x40,0xaf,0xa5,0x00,0x24,0x27,0x82,0x96,0x40,
+0x02,0x02,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa5,0x00,0x30,0xaf,0xa0,0x00,0x20,
+0xaf,0xa2,0x00,0x44,0x8f,0xa4,0x00,0x44,0x30,0x42,0x00,0x03,0x00,0x02,0x10,0x23,
+0x30,0x42,0x00,0x03,0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff,
+0x00,0x45,0x18,0x2b,0x10,0x60,0x00,0x29,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x2c,
+0x00,0xa2,0x10,0x23,0x00,0x85,0x18,0x21,0x30,0x63,0xff,0xff,0x30,0x45,0xff,0xff,
+0xaf,0xa3,0x00,0x2c,0x02,0x92,0x30,0x21,0x00,0x06,0x30,0x80,0x27,0x82,0x96,0x44,
+0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18,0x3c,0x04,0x80,0xff,0x34,0x84,0xff,0xff,
+0x8c,0xe3,0x00,0x04,0x3c,0x02,0x7f,0x00,0x00,0x05,0x2d,0x40,0x00,0xa2,0x28,0x24,
+0x00,0x64,0x18,0x24,0x00,0x65,0x18,0x25,0xac,0xe3,0x00,0x04,0x8f,0xa3,0x00,0x90,
+0x27,0x82,0x96,0x50,0x00,0xc2,0x10,0x21,0xa0,0x43,0x00,0x00,0x8c,0xe4,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x04,0x27,0xc2,0x10,0x80,0xff,0x0d,0xaf,0xa4,0x00,0x3c,
+0x80,0x42,0x00,0x06,0x8f,0xa4,0x00,0x40,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0xe2,0x38,0x21,
+0xa4,0xe4,0x00,0x00,0x08,0x00,0x21,0x71,0x26,0xb5,0xff,0xff,0x8f,0xa5,0x00,0x2c,
+0x00,0x00,0x00,0x00,0x00,0xa2,0x10,0x21,0x30,0x42,0xff,0xff,0xaf,0xa2,0x00,0x2c,
+0x08,0x00,0x22,0x4d,0x00,0x00,0x28,0x21,0x08,0x00,0x22,0x37,0xa7,0xd2,0x00,0x14,
+0x8f,0xa5,0x00,0x48,0x8f,0xa6,0x00,0x4c,0x03,0xc0,0x20,0x21,0x0c,0x00,0x20,0x4f,
+0xaf,0xb7,0x00,0x10,0x08,0x00,0x22,0x2e,0x00,0x00,0xb8,0x21,0x02,0x40,0x20,0x21,
+0x0c,0x00,0x17,0x43,0x00,0x00,0x28,0x21,0x00,0x40,0x18,0x21,0x94,0x42,0x00,0x00,
+0x00,0x00,0x00,0x00,0x34,0x42,0x08,0x00,0xa4,0x62,0x00,0x00,0x08,0x00,0x21,0x65,
+0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21,0x00,0x03,0x80,0x80,0x27,0x82,0x96,0x44,
+0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x10,0x60,0x00,0x0a,0x24,0x06,0x00,0x01,
+0x93,0x82,0x91,0x51,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x10,0x40,0xfe,0xd5,
+0x00,0x00,0x00,0x00,0x27,0x85,0x96,0x40,0x02,0x05,0x28,0x21,0x08,0x00,0x22,0x1e,
+0x3c,0x04,0x00,0x80,0x27,0x83,0x96,0x58,0x27,0x82,0x96,0x50,0x02,0x03,0x18,0x21,
+0x02,0x02,0x10,0x21,0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05,0x0c,0x00,0x25,0xc4,
+0x00,0x00,0x38,0x21,0x08,0x00,0x22,0x94,0x00,0x00,0x00,0x00,0x27,0x82,0x96,0x58,
+0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x02,0x8f,0xa2,0x00,0x54,0x00,0x03,0x19,0x02,
+0x00,0x62,0x18,0x23,0x30,0x63,0x0f,0xff,0x28,0x62,0x00,0x20,0x10,0x40,0x00,0x06,
+0x28,0x62,0x00,0x40,0x8f,0xa4,0x00,0x88,0x00,0x00,0x00,0x00,0x00,0x64,0x10,0x06,
+0x08,0x00,0x21,0x4c,0x30,0x44,0x00,0x01,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,
+0x8f,0xa5,0x00,0x8c,0x08,0x00,0x22,0xb4,0x00,0x65,0x10,0x06,0x08,0x00,0x21,0x4c,
+0x00,0x00,0x20,0x21,0x8f,0xa4,0x00,0x90,0x8f,0xa5,0x00,0x38,0x8f,0xa6,0x00,0x34,
+0xaf,0xa0,0x00,0x10,0x0c,0x00,0x0d,0xfe,0xaf,0xa2,0x00,0x14,0x30,0x42,0xff,0xff,
+0x08,0x00,0x21,0x1c,0xaf,0xa2,0x00,0x40,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,
+0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20,0x24,0x63,0x8b,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,
+0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45,0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c,0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,
+0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,
+0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,
+0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,
+0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,
+0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00,0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,
+0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01,0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,
+0x08,0x00,0x22,0xf0,0xa6,0x03,0x00,0x14,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,
+0x27,0x86,0x96,0x40,0x00,0x04,0x10,0xc0,0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,
+0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,
+0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x0c,0x00,0x17,0x34,
+0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff,0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,
+0x96,0x02,0x00,0x06,0x08,0x00,0x22,0xf0,0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,
+0x08,0x00,0x22,0xf0,0xa6,0x02,0x00,0x14,0x96,0x05,0x00,0x00,0x0c,0x00,0x23,0x1c,
+0x02,0x00,0x20,0x21,0x08,0x00,0x22,0xd7,0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,
+0x0c,0x00,0x23,0x1c,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xd3,0x00,0x40,0x88,0x21,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x8c,0x70,
+0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00,0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,
+0x24,0x42,0x8c,0x94,0xac,0x62,0x00,0x00,0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,
+0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21,0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00,0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,
+0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00,0x94,0xc8,0x00,0x00,0x27,0x83,0x96,0x40,
+0x93,0x85,0x91,0x50,0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08,0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,
+0x01,0x44,0x18,0x23,0x8f,0x82,0x91,0x68,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,
+0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,
+0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,
+0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08,0x08,0x00,0x23,0x48,0xa4,0xc2,0x00,0x14,
+0x08,0x00,0x23,0x48,0x00,0x00,0x18,0x21,0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,
+0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,
+0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,
+0x3c,0x02,0x80,0x01,0x3c,0x04,0xb0,0x03,0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,
+0x24,0x42,0x8d,0x48,0x02,0xb1,0x48,0x21,0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,
+0x24,0x03,0x00,0x01,0x27,0x82,0x96,0x50,0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,
+0x27,0x84,0x96,0x44,0x01,0x24,0x20,0x21,0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,
+0x27,0x83,0x96,0x60,0x01,0x23,0x48,0x21,0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,
+0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04,0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,
+0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2,0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,
+0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40,0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,
+0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21,0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,
+0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21,0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,
+0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21,0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,
+0x27,0x90,0x96,0x40,0x02,0x30,0x80,0x21,0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,
+0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21,0xa6,0x83,0x00,0x1a,0x27,0x82,0x96,0x48,
+0x0c,0x00,0x0d,0xd7,0x02,0x22,0x88,0x21,0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,
+0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,
+0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,
+0xaf,0xa9,0x00,0x10,0x0c,0x00,0x0d,0xfe,0xaf,0xa0,0x00,0x14,0x08,0x00,0x23,0x86,
+0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0,0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,
+0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,
+0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28,0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,
+0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03,0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,
+0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21,0x3c,0x02,0x80,0x01,0x00,0x03,0x48,0x80,
+0x24,0x42,0x8e,0x84,0x00,0x80,0x98,0x21,0x27,0x84,0x96,0x50,0x01,0x24,0x20,0x21,
+0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00,0x80,0x83,0x00,0x06,0x27,0x82,0x96,0x44,
+0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,
+0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,
+0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10,0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,
+0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21,0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,
+0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21,0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,
+0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21,0x27,0x83,0x96,0x58,0x01,0x23,0x18,0x21,
+0x80,0x64,0x00,0x00,0x27,0x83,0xbb,0xb0,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
+0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,
+0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80,0x24,0x04,0x00,0x01,0x27,0x83,0x96,0x60,
+0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,
+0x02,0xa0,0x20,0x21,0x27,0x82,0x96,0x40,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,
+0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a,0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,
+0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,
+0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x0d,0xfe,0xaf,0xa0,0x00,0x14,
+0x08,0x00,0x23,0xed,0x00,0x00,0x00,0x00,0x27,0x83,0x96,0x60,0x01,0x23,0x18,0x21,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,
+0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf,0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,
+0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d,0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,
+0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21,0x27,0x82,0x86,0xb0,0x00,0x15,0x18,0x40,
+0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00,0x24,0xa2,0x00,0x06,0x00,0x54,0x10,0x04,
+0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,
+0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,
+0x27,0x83,0x96,0x50,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,
+0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,
+0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f,0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,
+0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20,0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,
+0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,
+0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x04,0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,
+0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef,0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,
+0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,
+0x24,0x0e,0x00,0x04,0x24,0x62,0xff,0xf3,0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x02,
+0x24,0x03,0x00,0x01,0x00,0x62,0x70,0x0a,0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,
+0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d,0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,
+0x27,0x99,0x96,0x40,0x01,0xf2,0xc0,0x23,0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,
+0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04,0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21,0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,
+0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23,0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,
+0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff,0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,
+0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23,0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,
+0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40,0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,
+0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00,0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,
+0x00,0x02,0x30,0x80,0x27,0x82,0x96,0x44,0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,
+0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x40,0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,
+0x00,0x83,0x20,0x24,0x27,0x83,0x96,0x50,0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,
+0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04,0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,
+0xa0,0xb5,0x00,0x03,0x27,0x84,0x96,0x60,0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,
+0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2,0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,
+0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a,0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,
+0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01,0x27,0x84,0x96,0x40,0x00,0xc4,0x18,0x21,
+0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02,0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,
+0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23,0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,
+0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0,0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,
+0x02,0x03,0x80,0x21,0x27,0x82,0x96,0x48,0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,
+0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21,0x01,0x60,0x88,0x21,0x0c,0x00,0x0d,0xd7,
+0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21,0xa6,0x02,0x00,0x04,0x08,0x00,0x23,0xf3,
+0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b,0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,
+0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6,0x01,0x71,0x18,0x21,0x08,0x00,0x24,0x69,
+0x25,0x22,0x00,0x01,0x08,0x00,0x24,0x98,0x32,0xcc,0x00,0x03,0x08,0x00,0x24,0x98,
+0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,
+0x0c,0x00,0x0d,0xfe,0xaf,0xb4,0x00,0x14,0x92,0x67,0x00,0x04,0x08,0x00,0x24,0x0b,
+0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff,0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,
+0x00,0x04,0x20,0x80,0x27,0x82,0x96,0x40,0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,
+0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21,0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,
+0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,
+0x27,0x88,0x96,0x40,0x00,0x06,0x30,0x80,0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,
+0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21,0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,
+0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20,0x24,0x42,0x93,0x34,0xac,0xe2,0x00,0x00,
+0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,
+0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x27,0x89,0x96,0x40,
+0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,0x97,0x83,0x96,0x30,0x94,0x4a,0x00,0x04,
+0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0,0x00,0x0a,0x40,0xc0,0x00,0xe3,0x18,0x21,
+0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21,0x01,0x02,0x40,0x21,0x00,0x03,0x18,0x80,
+0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x01,0x00,0xa9,0x28,0x21,
+0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20,0x34,0x09,0xff,0xff,0x24,0x42,0x93,0x90,
+0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00,0xac,0xe4,0x00,0x00,0xa4,0xa9,0x00,0x00,
+0xad,0x09,0x00,0x00,0xa7,0x8a,0x96,0x30,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x94,0x10,
+0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x01,0x10,0x8c,0x82,0x00,0x00,
+0x97,0x83,0x87,0xf4,0x30,0x42,0xff,0xff,0x10,0x62,0x00,0x16,0x24,0x0a,0x00,0x01,
+0xa7,0x82,0x87,0xf4,0xaf,0x80,0xba,0x90,0x00,0x40,0x28,0x21,0x24,0x06,0x00,0x01,
+0x27,0x84,0xba,0x94,0x25,0x43,0xff,0xff,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,
+0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x8c,0x83,0xff,0xfc,0x00,0x00,0x00,0x00,
+0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x38,0x42,0x00,0x00,0x01,0x42,0x18,0x0a,
+0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14,0xac,0x83,0x00,0x00,0x14,0x40,0xff,0xf1,
+0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03,0x00,0x00,0x50,0x21,0x3c,0x0c,0x80,0x00,
+0x27,0x89,0xba,0xe0,0x35,0x6b,0x01,0x20,0x8d,0x68,0x00,0x00,0x8d,0x23,0x00,0x04,
+0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2,0x11,0x03,0x00,0x37,0xa1,0x22,0x00,0xdc,
+0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6,0x01,0x20,0x30,0x21,0x00,0x00,0x38,0x21,
+0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21,0x00,0xa8,0x10,0x06,0x30,0x42,0x00,0x01,
+0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a,0x90,0x82,0x00,0x07,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff,0xa0,0x82,0x00,0x08,0x90,0x82,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x08,
+0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40,0x00,0x43,0x10,0x21,0x00,0x46,0x10,0x21,
+0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x07,
+0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04,0x00,0x00,0x00,0x00,0xa0,0xc5,0x00,0xd5,
+0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08,0xa0,0xc5,0x00,0xd6,0x24,0xa5,0x00,0x01,
+0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0,0x24,0x84,0x00,0x03,0x90,0xc4,0x00,0xd5,
+0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b,0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,
+0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08,0x90,0xc2,0x00,0xd5,0x24,0xa5,0x00,0x01,
+0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0xa4,0x10,0x2b,
+0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x08,
+0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04,0x14,0x40,0xff,0xbf,0x25,0x29,0x00,0xec,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x05,0x08,0x00,0x25,0x3f,
+0xa0,0x82,0x00,0x08,0x97,0x84,0x91,0x5a,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,
+0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,0x24,0x42,0x95,0xc4,0xaf,0xbf,0x00,0x10,
+0xac,0x62,0x00,0x00,0x00,0x04,0x20,0x42,0x00,0x00,0x40,0x21,0x27,0x8f,0xba,0xe4,
+0x00,0x00,0x50,0x21,0x00,0x00,0x58,0x21,0x27,0x98,0xbb,0xc4,0x27,0x99,0xbb,0xc0,
+0x27,0x8e,0xbb,0xbe,0x27,0x8c,0xba,0xe8,0x27,0x8d,0xbb,0x40,0x27,0x89,0xbb,0xb8,
+0x00,0x0a,0x18,0x80,0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x44,0x00,0x58,
+0x00,0x6e,0x28,0x21,0x00,0x78,0x10,0x21,0xa1,0x20,0xff,0xfc,0xad,0x20,0x00,0x00,
+0xa1,0x20,0x00,0x04,0xa1,0x20,0x00,0x05,0xad,0x20,0xff,0xf8,0x00,0x79,0x18,0x21,
+0x24,0x06,0x00,0x01,0x24,0xc6,0xff,0xff,0xa0,0xa0,0x00,0x00,0xa4,0x60,0x00,0x00,
+0xac,0x40,0x00,0x00,0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9,
+0x24,0xa5,0x00,0x01,0x00,0x0a,0x10,0x80,0x00,0x4d,0x28,0x21,0x00,0x00,0x30,0x21,
+0x00,0x4c,0x18,0x21,0x27,0x87,0x87,0xf8,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04,
+0xac,0xa2,0x00,0x00,0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01,
+0x28,0xc2,0x00,0x1c,0xa0,0x60,0x00,0x02,0x24,0xa5,0x00,0x04,0x14,0x40,0xff,0xf6,
+0x24,0x63,0x00,0x03,0x25,0x08,0x00,0x01,0x29,0x02,0x00,0x08,0x25,0x4a,0x00,0x3b,
+0x25,0x29,0x00,0xec,0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x87,0xf4,
+0x00,0x00,0x40,0x21,0x27,0x83,0xba,0x90,0xac,0x68,0x00,0x00,0x25,0x08,0x00,0x01,
+0x29,0x02,0x00,0x0c,0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x25,0x04,
+0x00,0x00,0x00,0x00,0x27,0x83,0xba,0xe0,0x24,0x08,0x00,0x07,0x90,0x62,0x00,0xd6,
+0x25,0x08,0xff,0xff,0xa0,0x62,0x00,0x00,0x05,0x01,0xff,0xfc,0x24,0x63,0x00,0xec,
+0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xba,0xe0,0x00,0x43,0x40,0x21,
+0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x84,0x00,0x20,0x24,0x42,0x97,0x10,
+0x30,0xc6,0x00,0xff,0xac,0x82,0x00,0x00,0x30,0xa5,0x00,0xff,0x30,0xe7,0x00,0xff,
+0x10,0xc0,0x00,0x41,0x25,0x0f,0x00,0xd0,0x91,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+0x24,0x62,0xff,0xee,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x31,0x30,0x63,0x00,0xff,
+0x24,0x02,0x00,0x1a,0x10,0x62,0x00,0x2e,0x24,0x02,0x00,0x1b,0x10,0x62,0x00,0x2c,
+0x24,0x02,0x00,0x11,0x10,0x62,0x00,0x1e,0x24,0x02,0x00,0x18,0x10,0x62,0x00,0x1c,
+0x24,0x02,0x00,0x19,0x10,0x62,0x00,0x1a,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x06,
+0x24,0x02,0x00,0x01,0x8d,0x02,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,
+0x03,0xe0,0x00,0x08,0xad,0x02,0x00,0xd0,0x10,0xa2,0x00,0x0e,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x04,
+0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,0x08,0x00,0x25,0xec,0x24,0x42,0xff,0xe0,
+0x8d,0x02,0x00,0xd0,0x08,0x00,0x25,0xec,0x24,0x42,0xff,0xf8,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,0x08,0x00,0x25,0xec,0x24,0x42,0x00,0x01,
+0x10,0xa0,0xff,0xe8,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xfa,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xf5,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xed,
+0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,0x08,0x00,0x25,0xec,0x24,0x42,0xff,0xe8,
+0x10,0xa0,0xff,0xf0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xeb,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,
+0x08,0x00,0x25,0xec,0x24,0x42,0xff,0xd0,0x91,0x06,0x00,0x00,0x91,0x03,0x00,0xd4,
+0x25,0x0d,0x00,0x5c,0x30,0xc4,0x00,0xff,0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,
+0x00,0x04,0x50,0x80,0x01,0x02,0x58,0x21,0x01,0x0a,0x48,0x21,0x00,0xc0,0x60,0x21,
+0x25,0x78,0x00,0x08,0x10,0x60,0x00,0x36,0x25,0x2e,0x00,0x60,0x10,0xa0,0x00,0x25,
+0x00,0x00,0x00,0x00,0x91,0x02,0x00,0xdd,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,
+0x00,0x00,0x00,0x00,0x27,0x86,0x87,0xf8,0x01,0x46,0x10,0x21,0x8c,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0xad,0x23,0x00,0x60,0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0x40,0x60,0x21,0xa1,0x02,0x00,0x00,0x31,0x82,0x00,0xff,0x00,0x02,0x10,0x80,
+0x00,0x46,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,
+0xad,0xa3,0x00,0x00,0x91,0x04,0x00,0x00,0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,
+0x00,0x86,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x05,0x28,0x40,0x00,0x88,0x20,0x21,
+0x00,0x03,0x32,0x80,0x00,0xa6,0x10,0x2b,0x00,0xc2,0x28,0x0a,0xac,0x85,0x00,0x60,
+0x03,0xe0,0x00,0x08,0xa1,0x00,0x00,0xd4,0x27,0x86,0x87,0xf8,0x08,0x00,0x26,0x32,
+0xa1,0x00,0x00,0xdd,0x27,0x82,0x88,0x68,0x8d,0x03,0x00,0xd8,0x00,0x82,0x10,0x21,
+0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01,0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0xab,
+0xad,0x03,0x00,0xd8,0x8d,0x22,0x00,0x60,0xa1,0x00,0x00,0xd4,0x00,0x02,0x1f,0xc2,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x03,0xe0,0x00,0x08,0xad,0x02,0x00,0x5c,
+0x10,0xe0,0x00,0x14,0x24,0xc2,0xff,0xee,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0xa4,
+0x24,0x02,0x00,0x1a,0x10,0x82,0x00,0xa2,0x24,0x02,0x00,0x1b,0x10,0x82,0x00,0xa0,
+0x24,0x02,0x00,0x11,0x10,0x82,0x00,0x92,0x24,0x02,0x00,0x18,0x10,0x82,0x00,0x90,
+0x24,0x02,0x00,0x19,0x10,0x82,0x00,0x8e,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x7c,
+0x24,0x02,0x00,0x01,0x8d,0x02,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,
+0xad,0x02,0x00,0xd0,0x8d,0xe3,0x00,0x00,0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x43,0x10,0x21,0xad,0xa2,0x00,0x00,0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,
+0x8d,0xc4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x4d,
+0x24,0x02,0x00,0x1b,0x93,0x05,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x21,
+0x00,0x00,0x00,0x00,0x91,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05,
+0x24,0x02,0x00,0x01,0xa1,0x05,0x00,0x00,0xa1,0x02,0x00,0xd4,0x03,0xe0,0x00,0x08,
+0xad,0x00,0x00,0xd8,0x91,0x02,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05,
+0x00,0x00,0x00,0x00,0xa1,0x03,0x00,0xd4,0xad,0x00,0x00,0xd8,0x03,0xe0,0x00,0x08,
+0xa1,0x03,0x00,0xdd,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43,
+0xad,0xa2,0x00,0x00,0x91,0x03,0x00,0x00,0x27,0x82,0x87,0xf8,0x8d,0xc5,0x00,0x00,
+0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40,
+0x00,0x04,0x32,0x80,0x00,0xa6,0x10,0x2b,0x00,0xc2,0x28,0x0a,0x08,0x00,0x26,0x44,
+0xad,0xc5,0x00,0x00,0x91,0x02,0x00,0xde,0x00,0x00,0x00,0x00,0x2c,0x42,0x00,0x02,
+0x14,0x40,0xff,0xdc,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43,
+0xad,0xa2,0x00,0x00,0x91,0x03,0x00,0x00,0x27,0x82,0x87,0xf8,0x8d,0xc5,0x00,0x00,
+0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40,
+0x3c,0x03,0xb0,0x03,0x00,0x04,0x32,0x80,0x00,0xa6,0x10,0x2b,0x00,0xc2,0x28,0x0a,
+0xad,0xc5,0x00,0x00,0x34,0x63,0x01,0x08,0x8c,0x64,0x00,0x00,0x8d,0x03,0x00,0xe4,
+0x00,0x00,0x00,0x00,0x00,0x64,0x10,0x2b,0x14,0x40,0x00,0x03,0x00,0x83,0x28,0x23,
+0x00,0x83,0x10,0x23,0x24,0x45,0xff,0xff,0x3c,0x02,0x00,0x98,0x34,0x42,0x96,0x80,
+0x00,0x45,0x10,0x2b,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa5,0x00,0x00,0xe0,
+0x03,0xe0,0x00,0x08,0xa1,0x00,0x00,0xde,0x24,0x02,0x00,0x03,0x03,0xe0,0x00,0x08,
+0xa1,0x02,0x00,0xde,0x97,0x82,0x91,0x5c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a,
+0x10,0x40,0xff,0x32,0x00,0x00,0x00,0x00,0x91,0x02,0x00,0xdd,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x15,0x00,0x00,0x00,0x00,0x91,0x03,0x00,0x00,0x27,0x82,0x87,0xf8,
+0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x68,0x18,0x21,
+0xac,0x64,0x00,0x60,0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80,
+0x01,0x02,0x10,0x21,0x24,0x4e,0x00,0x60,0xa1,0x05,0x00,0x00,0x8d,0xc2,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,
+0x03,0xe0,0x00,0x08,0xad,0xa2,0x00,0x00,0x08,0x00,0x26,0xdb,0xa1,0x00,0x00,0xdd,
+0x10,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x85,
+0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,
+0x08,0x00,0x26,0x6c,0x24,0x42,0xff,0xe0,0x8d,0x02,0x00,0xd0,0x08,0x00,0x26,0x6c,
+0x24,0x42,0xff,0xf8,0x8d,0x02,0x00,0xd0,0x08,0x00,0x26,0x6c,0x24,0x42,0x00,0x01,
+0x10,0xa0,0xff,0x74,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xfa,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x73,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xef,
+0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,0x08,0x00,0x26,0x6c,0x24,0x42,0xff,0xe8,
+0x10,0xa0,0xff,0xf0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x69,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe8,0x00,0x00,0x00,0x00,0x8d,0x02,0x00,0xd0,
+0x08,0x00,0x26,0x6c,0x24,0x42,0xff,0xd0,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,
+0xaf,0xbf,0x00,0x14,0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x8c,0x50,0x00,0x00,
+0x00,0x00,0x00,0x00,0x32,0x03,0x00,0x01,0x14,0x60,0x00,0x14,0x00,0x00,0x00,0x00,
+0x32,0x02,0x01,0x00,0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,
+0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x01,0xa3,0x82,0x92,0x14,0x8f,0xbf,0x00,0x14,
+0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x0a,0x65,
+0x00,0x00,0x00,0x00,0x26,0x02,0xff,0x00,0xa3,0x80,0x92,0x14,0x3c,0x01,0xb0,0x03,
+0xac,0x22,0x01,0x18,0x08,0x00,0x27,0x18,0x32,0x02,0x08,0x00,0x0c,0x00,0x25,0x71,
+0x00,0x00,0x00,0x00,0x26,0x02,0xff,0xff,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,
+0x08,0x00,0x27,0x15,0x32,0x02,0x01,0x00,0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0xd0,0xaf,0xbf,0x00,0x18,0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,
+0x24,0x07,0x0f,0xff,0x00,0x03,0x33,0x02,0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,
+0x30,0x69,0x0f,0xff,0x00,0x62,0x18,0x24,0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,
+0x10,0x60,0x00,0x08,0x31,0x08,0x00,0xff,0x01,0x00,0x30,0x21,0x0c,0x00,0x27,0x4b,
+0xaf,0xa9,0x00,0x10,0x8f,0xbf,0x00,0x18,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x0c,0x00,0x27,0xae,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x34,0x63,0x00,0xd4,0x08,0x00,0x27,0x41,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xd8,
+0xaf,0xb0,0x00,0x10,0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,0xaf,0xb4,0x00,0x20,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x24,0xaf,0xb3,0x00,0x1c,
+0x30,0xb1,0x00,0xff,0x8f,0xb4,0x00,0x38,0x14,0x40,0x00,0x07,0x00,0x80,0x90,0x21,
+0x8f,0xbf,0x00,0x24,0x8f,0xb4,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14,
+0x0c,0x00,0x18,0xa0,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x46,0x02,0x40,0x20,0x21,
+0x02,0x00,0x90,0x21,0x00,0x14,0x1c,0x00,0x32,0x42,0x00,0x3f,0x24,0x04,0x00,0x50,
+0x0c,0x00,0x01,0x31,0x00,0x62,0x80,0x25,0x24,0x03,0x00,0x01,0x12,0x23,0x00,0x3a,
+0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x34,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x2f,
+0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x28,0x02,0x00,0x30,0x21,0x16,0x60,0xff,0xe4,
+0x00,0x00,0x00,0x00,0x16,0x40,0x00,0x1f,0x02,0x80,0x80,0x21,0x0c,0x00,0x01,0x31,
+0x24,0x04,0x00,0x50,0x24,0x03,0x00,0x01,0x12,0x23,0x00,0x16,0x2a,0x22,0x00,0x02,
+0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,
+0x16,0x22,0xff,0xd7,0x32,0x06,0x0e,0xbf,0x00,0x06,0x34,0x00,0x24,0x04,0x08,0x4c,
+0x0c,0x00,0x18,0x5b,0x24,0x05,0xff,0xff,0x08,0x00,0x27,0x58,0x00,0x00,0x00,0x00,
+0x32,0x06,0x0e,0xbf,0x00,0x06,0x34,0x00,0x08,0x00,0x27,0x84,0x24,0x04,0x08,0x48,
+0x16,0x20,0xff,0xcb,0x32,0x06,0x0e,0xbf,0x00,0x06,0x34,0x00,0x08,0x00,0x27,0x84,
+0x24,0x04,0x08,0x40,0x32,0x06,0x0e,0xbf,0x00,0x06,0x34,0x00,0x08,0x00,0x27,0x84,
+0x24,0x04,0x08,0x44,0x02,0x20,0x20,0x21,0x0c,0x00,0x28,0x46,0x00,0x00,0x28,0x21,
+0x08,0x00,0x27,0x77,0x00,0x40,0x80,0x21,0x24,0x04,0x08,0x4c,0x0c,0x00,0x18,0x5b,
+0x24,0x05,0xff,0xff,0x08,0x00,0x27,0x73,0x00,0x00,0x00,0x00,0x02,0x00,0x30,0x21,
+0x08,0x00,0x27,0x9b,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xd0,0x02,0x00,0x30,0x21,
+0x08,0x00,0x27,0x9b,0x24,0x04,0x08,0x40,0x02,0x00,0x30,0x21,0x08,0x00,0x27,0x9b,
+0x24,0x04,0x08,0x44,0x02,0x00,0x30,0x21,0x0c,0x00,0x27,0xf5,0x02,0x20,0x28,0x21,
+0x08,0x00,0x27,0x65,0x00,0x40,0x90,0x21,0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,
+0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,
+0xaf,0xb2,0x00,0x18,0x00,0xc0,0x80,0x21,0x30,0xb1,0x00,0xff,0x00,0x80,0x98,0x21,
+0x14,0x40,0x00,0x07,0x00,0x00,0x18,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x2e,0x12,0x00,0x10,0x24,0x05,0x00,0x14,0x0c,0x00,0x18,0xa0,0x24,0x06,0x01,0x07,
+0x12,0x40,0x00,0x2a,0x02,0x00,0x10,0x21,0x30,0x45,0x00,0x3f,0x0c,0x00,0x28,0x46,
+0x02,0x20,0x20,0x21,0x12,0x40,0x00,0x03,0x00,0x40,0x98,0x21,0x08,0x00,0x27,0xba,
+0x02,0x60,0x18,0x21,0x02,0x20,0x20,0x21,0x0c,0x00,0x28,0x46,0x00,0x00,0x28,0x21,
+0x24,0x04,0x00,0x50,0x0c,0x00,0x01,0x31,0x00,0x40,0x80,0x21,0x24,0x03,0x00,0x01,
+0x12,0x23,0x00,0x16,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02,
+0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,0x16,0x22,0xff,0xf0,0x32,0x06,0x0e,0xbf,
+0x00,0x06,0x34,0x00,0x24,0x04,0x08,0x4c,0x0c,0x00,0x18,0x5b,0x24,0x05,0xff,0xff,
+0x08,0x00,0x27,0xba,0x02,0x60,0x18,0x21,0x32,0x06,0x0e,0xbf,0x00,0x06,0x34,0x00,
+0x08,0x00,0x27,0xde,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe4,0x32,0x06,0x0e,0xbf,
+0x00,0x06,0x34,0x00,0x08,0x00,0x27,0xde,0x24,0x04,0x08,0x40,0x32,0x06,0x0e,0xbf,
+0x00,0x06,0x34,0x00,0x08,0x00,0x27,0xde,0x24,0x04,0x08,0x44,0x02,0x60,0x20,0x21,
+0x02,0x00,0x30,0x21,0x0c,0x00,0x27,0xf5,0x02,0x20,0x28,0x21,0x08,0x00,0x27,0xc7,
+0x30,0x45,0x00,0x3f,0x27,0xbd,0xff,0xe0,0xaf,0xb0,0x00,0x10,0x30,0xb0,0x00,0xff,
+0x02,0x00,0x20,0x21,0x00,0x00,0x28,0x21,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x1c,
+0x00,0xc0,0x88,0x21,0x0c,0x00,0x28,0x46,0xaf,0xb2,0x00,0x18,0x00,0x40,0x18,0x21,
+0x2e,0x22,0x00,0x1f,0x10,0x40,0x00,0x26,0x2e,0x22,0x00,0x10,0x10,0x40,0x00,0x07,
+0x34,0x62,0x01,0x00,0x02,0x20,0x10,0x21,0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x00,0x50,
+0x0c,0x00,0x01,0x31,0x00,0x02,0x94,0x00,0x24,0x03,0x00,0x01,0x12,0x03,0x00,0x15,
+0x2a,0x02,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02,0x12,0x02,0x00,0x0a,
+0x24,0x02,0x00,0x03,0x12,0x02,0x00,0x03,0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x05,
+0x26,0x31,0xff,0xf1,0x24,0x04,0x08,0x4c,0x0c,0x00,0x18,0x5b,0x24,0x05,0xff,0xff,
+0x08,0x00,0x28,0x05,0x26,0x31,0xff,0xf1,0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x1a,
+0x24,0x04,0x08,0x48,0x16,0x00,0xff,0xf5,0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x1a,
+0x24,0x04,0x08,0x40,0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x1a,0x24,0x04,0x08,0x44,
+0x34,0x62,0x01,0x40,0x24,0x04,0x00,0x50,0x0c,0x00,0x01,0x31,0x00,0x02,0x94,0x00,
+0x24,0x03,0x00,0x01,0x12,0x03,0x00,0x15,0x2a,0x02,0x00,0x02,0x14,0x40,0x00,0x0f,
+0x24,0x02,0x00,0x02,0x12,0x02,0x00,0x0a,0x24,0x02,0x00,0x03,0x12,0x02,0x00,0x03,
+0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x05,0x26,0x31,0xff,0xe2,0x24,0x04,0x08,0x4c,
+0x0c,0x00,0x18,0x5b,0x24,0x05,0xff,0xff,0x08,0x00,0x28,0x05,0x26,0x31,0xff,0xe2,
+0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x38,0x24,0x04,0x08,0x48,0x16,0x00,0xff,0xf5,
+0x02,0x40,0x30,0x21,0x08,0x00,0x28,0x38,0x24,0x04,0x08,0x40,0x02,0x40,0x30,0x21,
+0x08,0x00,0x28,0x38,0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe0,0x00,0x80,0x10,0x21,
+0x24,0x04,0x00,0x50,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,
+0x00,0xa0,0x88,0x21,0x0c,0x00,0x01,0x31,0x30,0x50,0x00,0xff,0x24,0x03,0x00,0x01,
+0x12,0x03,0x00,0x3e,0x02,0x20,0x30,0x21,0x2a,0x02,0x00,0x02,0x14,0x40,0x00,0x2a,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x12,0x02,0x00,0x19,0x24,0x04,0x08,0x34,
+0x24,0x02,0x00,0x03,0x12,0x02,0x00,0x05,0x24,0x04,0x08,0x3c,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x18,0x5b,
+0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x18,0x5b,
+0x00,0x00,0x30,0x21,0x3c,0x05,0x80,0x00,0x24,0x06,0x00,0x01,0x0c,0x00,0x18,0x5b,
+0x24,0x04,0x08,0x3c,0x0c,0x00,0x01,0x31,0x24,0x04,0x00,0x28,0x24,0x04,0x08,0xac,
+0x0c,0x00,0x18,0x3d,0x24,0x05,0x0f,0xff,0x08,0x00,0x28,0x5b,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x18,0x5b,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00,
+0x0c,0x00,0x18,0x5b,0x00,0x00,0x30,0x21,0x3c,0x05,0x80,0x00,0x24,0x06,0x00,0x01,
+0x0c,0x00,0x18,0x5b,0x24,0x04,0x08,0x34,0x0c,0x00,0x01,0x31,0x24,0x04,0x00,0x28,
+0x08,0x00,0x28,0x6c,0x24,0x04,0x08,0xa8,0x16,0x00,0xff,0xdc,0x02,0x20,0x30,0x21,
+0x24,0x04,0x08,0x24,0x0c,0x00,0x18,0x5b,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x24,
+0x3c,0x05,0x80,0x00,0x0c,0x00,0x18,0x5b,0x00,0x00,0x30,0x21,0x3c,0x05,0x80,0x00,
+0x24,0x06,0x00,0x01,0x0c,0x00,0x18,0x5b,0x24,0x04,0x08,0x24,0x0c,0x00,0x01,0x31,
+0x24,0x04,0x00,0x28,0x08,0x00,0x28,0x6c,0x24,0x04,0x08,0xa0,0x24,0x04,0x08,0x2c,
+0x0c,0x00,0x18,0x5b,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00,
+0x0c,0x00,0x18,0x5b,0x00,0x00,0x30,0x21,0x3c,0x05,0x80,0x00,0x24,0x06,0x00,0x01,
+0x0c,0x00,0x18,0x5b,0x24,0x04,0x08,0x2c,0x0c,0x00,0x01,0x31,0x24,0x04,0x00,0x28,
+0x08,0x00,0x28,0x6c,0x24,0x04,0x08,0xa4,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
+0x0c,0x00,0x29,0x4c,0x00,0x00,0x00,0x00,0x0c,0x00,0x29,0x4e,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x29,0x75,0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x05,0x34,0x84,0x00,0x04,
+0x0c,0x00,0x29,0x55,0x34,0x05,0x9c,0x40,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x97,0x82,0x88,0x90,0x00,0x00,0x00,0x00,
+0x2c,0x43,0x00,0x64,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x90,0x14,0x60,0x00,0x28,
+0x00,0x80,0x30,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0x20,0x00,0xa7,0x80,0x88,0x90,
+0x00,0x43,0x10,0x24,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00,
+0x3c,0x03,0x80,0x00,0x00,0x43,0x10,0x25,0x97,0x83,0x88,0x84,0xac,0x82,0x00,0x00,
+0x8c,0x85,0x00,0x00,0x24,0x63,0x00,0x01,0x3c,0x02,0x40,0x64,0x34,0x42,0x64,0x00,
+0x00,0x03,0x24,0x00,0x00,0xa2,0x28,0x25,0x00,0x04,0x24,0x03,0x24,0x02,0x00,0x64,
+0xac,0xc5,0x00,0x00,0xa7,0x83,0x88,0x84,0x10,0x82,0x00,0x2b,0x00,0x00,0x00,0x00,
+0x87,0x82,0x88,0x86,0x24,0x03,0x00,0x3c,0x10,0x43,0x00,0x21,0x00,0x00,0x00,0x00,
+0x87,0x82,0x88,0x88,0x00,0x00,0x00,0x00,0x10,0x43,0x00,0x17,0x00,0x00,0x00,0x00,
+0x87,0x83,0x88,0x8a,0x24,0x02,0x00,0x18,0x10,0x62,0x00,0x0d,0x00,0x00,0x00,0x00,
+0x87,0x83,0x88,0x8c,0x24,0x02,0x01,0x6d,0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x8e,0xa7,0x80,0x88,0x8c,
+0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x8e,0x08,0x00,0x28,0xe4,0x00,0x00,0x00,0x00,
+0x97,0x82,0x88,0x8c,0xa7,0x80,0x88,0x8a,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x8c,
+0x08,0x00,0x28,0xe0,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x8a,0xa7,0x80,0x88,0x88,
+0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x8a,0x08,0x00,0x28,0xdc,0x00,0x00,0x00,0x00,
+0x97,0x82,0x88,0x88,0xa7,0x80,0x88,0x86,0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x88,
+0x08,0x00,0x28,0xd8,0x00,0x00,0x00,0x00,0x97,0x82,0x88,0x86,0xa7,0x80,0x88,0x84,
+0x24,0x42,0x00,0x01,0xa7,0x82,0x88,0x86,0x08,0x00,0x28,0xd4,0x00,0x00,0x00,0x00,
+0x00,0x04,0x24,0x00,0x3c,0x03,0xb0,0x07,0x00,0x04,0x24,0x03,0x34,0x63,0x00,0x28,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x40,0x10,0x40,0xff,0xfc,
+0x00,0x00,0x00,0x00,0x3c,0x01,0xb0,0x07,0xa0,0x24,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x10,0x21,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x28,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x10,0x60,0x00,0x06,0x24,0x02,0xff,0xff,
+0x3c,0x02,0xb0,0x07,0x90,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x16,0x00,
+0x00,0x02,0x16,0x03,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe0,
+0xaf,0xb0,0x00,0x10,0x3c,0x10,0x04,0xc4,0x00,0x04,0x11,0x00,0x36,0x10,0xb4,0x00,
+0x02,0x02,0x00,0x1b,0xaf,0xb1,0x00,0x14,0x3c,0x11,0xb0,0x07,0x36,0x31,0x00,0x18,
+0x24,0x04,0x00,0x0a,0xaf,0xbf,0x00,0x18,0x14,0x40,0x00,0x02,0x00,0x00,0x00,0x00,
+0x00,0x07,0x00,0x0d,0x00,0x00,0x80,0x12,0x0c,0x00,0x29,0xa1,0x00,0x00,0x00,0x00,
+0x92,0x22,0x00,0x00,0x24,0x03,0xff,0x80,0x24,0x04,0x00,0x0a,0x00,0x43,0x10,0x25,
+0x0c,0x00,0x29,0xa1,0xa2,0x22,0x00,0x00,0x24,0x04,0x00,0x0a,0x3c,0x01,0xb0,0x07,
+0xa0,0x30,0x00,0x00,0x0c,0x00,0x29,0xa1,0x00,0x10,0x82,0x03,0x3c,0x02,0xb0,0x07,
+0x34,0x42,0x00,0x08,0xa0,0x50,0x00,0x00,0x0c,0x00,0x29,0xa1,0x24,0x04,0x00,0x0a,
+0x92,0x22,0x00,0x00,0x8f,0xbf,0x00,0x18,0x8f,0xb0,0x00,0x10,0x30,0x42,0x00,0x7f,
+0xa2,0x22,0x00,0x00,0x8f,0xb1,0x00,0x14,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x58,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x07,0xa4,0x03,0xe0,0x00,0x08,
+0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xf8,0x00,0x80,0x38,0x21,0x00,0xa0,0x30,0x21,
+0x00,0x00,0x18,0x21,0x00,0x63,0x00,0x18,0x00,0x00,0x10,0x12,0x00,0xc2,0x10,0x2b,
+0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x2c,0x62,0x01,0x00,
+0x14,0x40,0xff,0xf9,0x00,0x63,0x00,0x18,0x24,0x63,0xff,0xff,0x00,0x63,0x00,0x18,
+0x30,0x63,0x00,0xff,0x8c,0xe4,0x00,0x00,0x00,0x03,0x2a,0x00,0x00,0x03,0x1c,0x00,
+0x00,0x00,0x10,0x12,0x00,0xc2,0x10,0x23,0x30,0x42,0x00,0xff,0x00,0x45,0x10,0x21,
+0x00,0x43,0x10,0x21,0x00,0x82,0x20,0x25,0xac,0xe4,0x00,0x00,0x8c,0xe2,0x00,0x00,
+0x3c,0x03,0x40,0x00,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x08,0x27,0xbd,0xff,0xe0,0xaf,0xbf,0x00,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00,0x3c,0x06,0xb0,0x03,
+0x34,0xc6,0x00,0x08,0x34,0x42,0x40,0x00,0xac,0x82,0x00,0x00,0x8c,0x83,0x00,0x00,
+0x24,0x02,0xcf,0xff,0x3c,0x11,0xb0,0x07,0x00,0x62,0x18,0x24,0xac,0x83,0x00,0x00,
+0x8c,0xc5,0x00,0x00,0x3c,0x02,0x00,0xff,0x24,0x04,0x00,0x0a,0x00,0xa2,0x28,0x25,
+0xac,0xc5,0x00,0x00,0x0c,0x00,0x29,0xa1,0x36,0x31,0x00,0x18,0x24,0x02,0xff,0x83,
+0x3c,0x04,0x00,0x01,0xa2,0x22,0x00,0x00,0x0c,0x00,0x29,0x1f,0x34,0x84,0xc2,0x00,
+0x0c,0x00,0x29,0xa1,0x24,0x04,0x00,0x0a,0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x00,
+0x24,0x04,0x00,0x0a,0x0c,0x00,0x29,0xa1,0x3c,0x10,0xb0,0x07,0x36,0x10,0x00,0x10,
+0x24,0x02,0x00,0x06,0xa2,0x02,0x00,0x00,0x0c,0x00,0x29,0xa1,0x24,0x04,0x00,0x0a,
+0xa2,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01,
+0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xb5,0x00,0x34,0xaf,0xb2,0x00,0x28,
+0xaf,0xb0,0x00,0x20,0xaf,0xbf,0x00,0x38,0xaf,0xb4,0x00,0x30,0xaf,0xb3,0x00,0x2c,
+0xaf,0xb1,0x00,0x24,0xaf,0xa5,0x00,0x44,0x90,0xa7,0x00,0x00,0x00,0x80,0xa8,0x21,
+0x00,0xc0,0x90,0x21,0x00,0x07,0x1e,0x00,0x10,0x60,0x00,0x0f,0x00,0x80,0x80,0x21,
+0x00,0x03,0x1e,0x03,0x24,0x02,0x00,0x25,0x10,0x62,0x00,0x13,0x00,0x00,0x88,0x21,
+0xa2,0x07,0x00,0x00,0x8f,0xa5,0x00,0x44,0x26,0x10,0x00,0x01,0x24,0xa5,0x00,0x01,
+0xaf,0xa5,0x00,0x44,0x90,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x1e,0x00,
+0x14,0x60,0xff,0xf3,0x00,0x00,0x00,0x00,0x02,0x15,0x10,0x23,0xa2,0x00,0x00,0x00,
+0x8f,0xbf,0x00,0x38,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x24,0xa5,0x00,0x01,0xaf,0xa5,0x00,0x44,
+0x80,0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x63,0xff,0xe0,0x2c,0x62,0x00,0x11,
+0x10,0x40,0x00,0x11,0x00,0xa0,0x38,0x21,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,
+0x24,0x63,0x09,0x98,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x29,0xce,0x36,0x31,0x00,0x10,
+0x08,0x00,0x29,0xce,0x36,0x31,0x00,0x08,0x08,0x00,0x29,0xce,0x36,0x31,0x00,0x20,
+0x08,0x00,0x29,0xce,0x36,0x31,0x00,0x04,0x90,0xe4,0x00,0x00,0x3c,0x02,0x80,0x01,
+0x24,0x42,0x02,0x14,0x00,0x44,0x10,0x21,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x63,0x00,0x04,0x14,0x60,0x00,0xfd,0x24,0x14,0xff,0xff,0x00,0x04,0x16,0x00,
+0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x2a,0x10,0x43,0x00,0xee,0x26,0x42,0x00,0x03,
+0x80,0xa3,0x00,0x00,0x24,0x02,0x00,0x2e,0x10,0x62,0x00,0xcc,0x24,0x08,0xff,0xff,
+0x80,0xa3,0x00,0x00,0x24,0x02,0x00,0x68,0x10,0x62,0x00,0xc4,0x24,0x06,0xff,0xff,
+0x24,0x02,0x00,0x6c,0x10,0x62,0x00,0xc1,0x24,0x02,0x00,0x4c,0x10,0x62,0x00,0xbf,
+0x24,0x02,0x00,0x5a,0x10,0x62,0x00,0xbd,0x00,0x00,0x00,0x00,0x80,0xa3,0x00,0x00,
+0x00,0x00,0x00,0x00,0x24,0x63,0xff,0xdb,0x2c,0x62,0x00,0x54,0x10,0x40,0x00,0xaa,
+0x24,0x09,0x00,0x0a,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,0x24,0x63,0x09,0xdc,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,
+0x00,0x00,0x00,0x00,0x32,0x22,0x00,0x10,0x14,0x40,0x00,0x09,0x24,0x02,0xff,0xfc,
+0x26,0x94,0xff,0xff,0x1a,0x80,0x00,0x05,0x24,0x02,0x00,0x20,0x26,0x94,0xff,0xff,
+0xa2,0x02,0x00,0x00,0x1e,0x80,0xff,0xfd,0x26,0x10,0x00,0x01,0x24,0x02,0xff,0xfc,
+0x26,0x44,0x00,0x03,0x00,0x82,0x90,0x24,0x92,0x42,0x00,0x03,0x26,0x94,0xff,0xff,
+0x26,0x52,0x00,0x04,0xa2,0x02,0x00,0x00,0x1a,0x80,0x00,0x06,0x26,0x10,0x00,0x01,
+0x24,0x02,0x00,0x20,0x26,0x94,0xff,0xff,0xa2,0x02,0x00,0x00,0x1e,0x80,0xff,0xfd,
+0x26,0x10,0x00,0x01,0x8f,0xa5,0x00,0x44,0x08,0x00,0x29,0xc0,0x24,0xa5,0x00,0x01,
+0x24,0x02,0x00,0x25,0x08,0x00,0x29,0xbd,0xa2,0x02,0x00,0x00,0x36,0x31,0x00,0x40,
+0x24,0x09,0x00,0x10,0x24,0x02,0x00,0x4c,0x10,0xc2,0x00,0x2a,0x24,0x02,0x00,0x6c,
+0x10,0xc2,0x00,0x05,0x24,0x02,0x00,0x5a,0x10,0xc2,0x00,0x1f,0x24,0x02,0x00,0x68,
+0x10,0xc2,0x00,0x13,0x24,0x02,0xff,0xfc,0x24,0x02,0xff,0xfc,0x26,0x43,0x00,0x03,
+0x00,0x62,0x90,0x24,0x32,0x22,0x00,0x02,0x8e,0x47,0x00,0x00,0x00,0x00,0x30,0x21,
+0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x00,0xe0,0x10,0x21,0x00,0x02,0x37,0xc3,
+0x02,0x00,0x20,0x21,0xaf,0xa9,0x00,0x10,0xaf,0xb4,0x00,0x14,0xaf,0xa8,0x00,0x18,
+0x0c,0x00,0x2b,0x0e,0xaf,0xb1,0x00,0x1c,0x08,0x00,0x2a,0x29,0x00,0x40,0x80,0x21,
+0x26,0x43,0x00,0x03,0x00,0x62,0x90,0x24,0x32,0x22,0x00,0x02,0x96,0x47,0x00,0x02,
+0x00,0x00,0x30,0x21,0x10,0x40,0xff,0xf2,0x26,0x52,0x00,0x04,0x00,0x07,0x14,0x00,
+0x08,0x00,0x2a,0x43,0x00,0x02,0x3c,0x03,0x26,0x42,0x00,0x03,0x24,0x03,0xff,0xfc,
+0x00,0x43,0x90,0x24,0x8e,0x47,0x00,0x00,0x00,0x00,0x30,0x21,0x08,0x00,0x2a,0x44,
+0x26,0x52,0x00,0x04,0x26,0x42,0x00,0x07,0x24,0x03,0xff,0xf8,0x00,0x43,0x90,0x24,
+0x8e,0x46,0x00,0x00,0x8e,0x47,0x00,0x04,0x08,0x00,0x2a,0x44,0x26,0x52,0x00,0x08,
+0x08,0x00,0x2a,0x31,0x36,0x31,0x00,0x02,0x26,0x44,0x00,0x03,0x24,0x02,0xff,0xfc,
+0x00,0x82,0x90,0x24,0x8e,0x44,0x00,0x00,0x02,0x15,0x10,0x23,0x26,0x52,0x00,0x04,
+0x08,0x00,0x29,0xbf,0xac,0x82,0x00,0x00,0x08,0x00,0x2a,0x31,0x24,0x09,0x00,0x08,
+0x24,0x02,0xff,0xff,0x12,0x82,0x00,0x11,0x00,0x00,0x00,0x00,0x26,0x43,0x00,0x03,
+0x24,0x02,0xff,0xfc,0x00,0x62,0x90,0x24,0x8e,0x47,0x00,0x00,0x02,0x00,0x20,0x21,
+0x24,0x02,0x00,0x10,0x00,0x00,0x30,0x21,0xaf,0xa2,0x00,0x10,0xaf,0xb4,0x00,0x14,
+0xaf,0xa8,0x00,0x18,0x0c,0x00,0x2b,0x0e,0xaf,0xb1,0x00,0x1c,0x8f,0xa5,0x00,0x44,
+0x00,0x40,0x80,0x21,0x08,0x00,0x29,0xbf,0x26,0x52,0x00,0x04,0x24,0x14,0x00,0x08,
+0x08,0x00,0x2a,0x73,0x36,0x31,0x00,0x01,0x26,0x42,0x00,0x03,0x24,0x03,0xff,0xfc,
+0x00,0x43,0x90,0x24,0x8e,0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x60,0x00,0x23,
+0x26,0x52,0x00,0x04,0x02,0x60,0x20,0x21,0x0c,0x00,0x2b,0xdc,0x01,0x00,0x28,0x21,
+0x00,0x40,0x20,0x21,0x32,0x22,0x00,0x10,0x14,0x40,0x00,0x09,0x00,0x94,0x10,0x2a,
+0x10,0x40,0x00,0x07,0x26,0x94,0xff,0xff,0x24,0x03,0x00,0x20,0x00,0x94,0x10,0x2a,
+0xa2,0x03,0x00,0x00,0x26,0x94,0xff,0xff,0x14,0x40,0xff,0xfc,0x26,0x10,0x00,0x01,
+0x18,0x80,0x00,0x07,0x00,0x80,0x18,0x21,0x92,0x62,0x00,0x00,0x24,0x63,0xff,0xff,
+0x26,0x73,0x00,0x01,0xa2,0x02,0x00,0x00,0x14,0x60,0xff,0xfb,0x26,0x10,0x00,0x01,
+0x00,0x94,0x10,0x2a,0x10,0x40,0xff,0x83,0x26,0x94,0xff,0xff,0x24,0x03,0x00,0x20,
+0x00,0x94,0x10,0x2a,0xa2,0x03,0x00,0x00,0x26,0x94,0xff,0xff,0x14,0x40,0xff,0xfc,
+0x26,0x10,0x00,0x01,0x08,0x00,0x2a,0x29,0x00,0x00,0x00,0x00,0x3c,0x02,0x80,0x01,
+0x08,0x00,0x2a,0x8d,0x24,0x53,0x08,0x84,0x24,0x02,0x00,0x25,0xa2,0x02,0x00,0x00,
+0x8f,0xa5,0x00,0x44,0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x00,0x90,0xa3,0x00,0x00,
+0x10,0x40,0x00,0x03,0x26,0x10,0x00,0x01,0x08,0x00,0x29,0xbd,0xa2,0x03,0x00,0x00,
+0x24,0xa5,0xff,0xff,0x08,0x00,0x29,0xbf,0xaf,0xa5,0x00,0x44,0x80,0xa6,0x00,0x00,
+0x24,0xa5,0x00,0x01,0x08,0x00,0x2a,0x03,0xaf,0xa5,0x00,0x44,0x24,0xa5,0x00,0x01,
+0xaf,0xa5,0x00,0x44,0x90,0xa4,0x00,0x00,0x3c,0x02,0x80,0x01,0x24,0x42,0x02,0x14,
+0x00,0x44,0x10,0x21,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04,
+0x14,0x60,0x00,0x0f,0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x2a,
+0x10,0x43,0x00,0x04,0x26,0x42,0x00,0x03,0x29,0x02,0x00,0x00,0x08,0x00,0x29,0xf8,
+0x00,0x02,0x40,0x0b,0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24,0x24,0xa5,0x00,0x01,
+0x8e,0x48,0x00,0x00,0xaf,0xa5,0x00,0x44,0x08,0x00,0x2a,0xd2,0x26,0x52,0x00,0x04,
+0x0c,0x00,0x2a,0xf2,0x27,0xa4,0x00,0x44,0x8f,0xa5,0x00,0x44,0x08,0x00,0x2a,0xd2,
+0x00,0x40,0x40,0x21,0x24,0x03,0xff,0xfc,0x00,0x43,0x90,0x24,0x8e,0x54,0x00,0x00,
+0x24,0xe5,0x00,0x01,0xaf,0xa5,0x00,0x44,0x06,0x81,0xff,0x0d,0x26,0x52,0x00,0x04,
+0x00,0x14,0xa0,0x23,0x08,0x00,0x29,0xf4,0x36,0x31,0x00,0x10,0x0c,0x00,0x2a,0xf2,
+0x27,0xa4,0x00,0x44,0x8f,0xa5,0x00,0x44,0x08,0x00,0x29,0xf4,0x00,0x40,0xa0,0x21,
+0x08,0x00,0x29,0xce,0x36,0x31,0x00,0x01,0x8c,0x86,0x00,0x00,0x3c,0x02,0x80,0x01,
+0x00,0x80,0x48,0x21,0x90,0xc3,0x00,0x00,0x24,0x44,0x02,0x14,0x00,0x64,0x18,0x21,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x04,0x10,0x40,0x00,0x10,
+0x00,0x00,0x38,0x21,0x00,0x80,0x40,0x21,0x24,0xc2,0x00,0x01,0x80,0xc5,0x00,0x00,
+0xad,0x22,0x00,0x00,0x90,0x43,0x00,0x00,0x00,0x40,0x30,0x21,0x00,0x07,0x10,0x80,
+0x00,0x68,0x18,0x21,0x90,0x64,0x00,0x00,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x40,
+0x00,0x45,0x10,0x21,0x30,0x84,0x00,0x04,0x14,0x80,0xff,0xf3,0x24,0x47,0xff,0xd0,
+0x03,0xe0,0x00,0x08,0x00,0xe0,0x10,0x21,0x27,0xbd,0xff,0x98,0xaf,0xb2,0x00,0x50,
+0x8f,0xb2,0x00,0x84,0x3c,0x02,0x80,0x01,0xaf,0xb4,0x00,0x58,0x32,0x43,0x00,0x40,
+0xaf,0xb1,0x00,0x4c,0xaf,0xb0,0x00,0x48,0xaf,0xb7,0x00,0x64,0xaf,0xb6,0x00,0x60,
+0xaf,0xb5,0x00,0x5c,0xaf,0xb3,0x00,0x54,0x00,0x80,0x68,0x21,0x00,0xc0,0x70,0x21,
+0x00,0xe0,0x78,0x21,0x8f,0xb0,0x00,0x78,0x8f,0xb8,0x00,0x7c,0x8f,0xb1,0x00,0x80,
+0x10,0x60,0x00,0x03,0x24,0x54,0x08,0x8c,0x3c,0x02,0x80,0x01,0x24,0x54,0x08,0xb4,
+0x32,0x42,0x00,0x10,0x10,0x40,0x00,0x04,0x26,0x02,0xff,0xfe,0x24,0x02,0xff,0xfe,
+0x02,0x42,0x90,0x24,0x26,0x02,0xff,0xfe,0x2c,0x42,0x00,0x23,0x10,0x40,0x00,0x5d,
+0x00,0x00,0x18,0x21,0x32,0x42,0x00,0x01,0x24,0x15,0x00,0x30,0x24,0x03,0x00,0x20,
+0x32,0x44,0x00,0x02,0x00,0x62,0xa8,0x0a,0x10,0x80,0x00,0x07,0x00,0x00,0xb8,0x21,
+0x05,0xc0,0x00,0x96,0x32,0x42,0x00,0x04,0x10,0x40,0x00,0x90,0x32,0x42,0x00,0x08,
+0x24,0x17,0x00,0x2b,0x27,0x18,0xff,0xff,0x32,0x56,0x00,0x20,0x12,0xc0,0x00,0x07,
+0x01,0xcf,0x10,0x25,0x24,0x02,0x00,0x10,0x12,0x02,0x00,0x86,0x27,0x03,0xff,0xff,
+0x3a,0x02,0x00,0x08,0x00,0x62,0xc0,0x0a,0x01,0xcf,0x10,0x25,0x14,0x40,0x00,0x55,
+0x00,0x00,0xc8,0x21,0x24,0x02,0x00,0x30,0x24,0x19,0x00,0x01,0xa3,0xa2,0x00,0x00,
+0x02,0x39,0x10,0x2a,0x03,0x22,0x88,0x0b,0x32,0x43,0x00,0x11,0x14,0x60,0x00,0x0a,
+0x03,0x11,0xc0,0x23,0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x07,0x27,0x18,0xff,0xff,
+0x24,0x03,0x00,0x20,0x03,0x00,0x10,0x21,0xa1,0xa3,0x00,0x00,0x27,0x18,0xff,0xff,
+0x1c,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,0x12,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,
+0xa1,0xb7,0x00,0x00,0x25,0xad,0x00,0x01,0x12,0xc0,0x00,0x07,0x32,0x42,0x00,0x10,
+0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x38,0x24,0x02,0x00,0x10,0x12,0x02,0x00,0x30,
+0x24,0x02,0x00,0x30,0x32,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,0x03,0x31,0x10,0x2a,
+0x03,0x00,0x10,0x21,0x18,0x40,0x00,0x06,0x27,0x18,0xff,0xff,0x03,0x00,0x10,0x21,
+0xa1,0xb5,0x00,0x00,0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,
+0x03,0x31,0x10,0x2a,0x10,0x40,0x00,0x07,0x26,0x31,0xff,0xff,0x24,0x03,0x00,0x30,
+0x03,0x31,0x10,0x2a,0xa1,0xa3,0x00,0x00,0x26,0x31,0xff,0xff,0x14,0x40,0xff,0xfc,
+0x25,0xad,0x00,0x01,0x03,0x20,0x10,0x21,0x18,0x40,0x00,0x08,0x27,0x39,0xff,0xff,
+0x03,0xb9,0x10,0x21,0x90,0x43,0x00,0x00,0x03,0x20,0x20,0x21,0x27,0x39,0xff,0xff,
+0xa1,0xa3,0x00,0x00,0x1c,0x80,0xff,0xfa,0x25,0xad,0x00,0x01,0x03,0x00,0x10,0x21,
+0x18,0x40,0x00,0x07,0x27,0x18,0xff,0xff,0x24,0x03,0x00,0x20,0x03,0x00,0x10,0x21,
+0xa1,0xa3,0x00,0x00,0x27,0x18,0xff,0xff,0x1c,0x40,0xff,0xfc,0x25,0xad,0x00,0x01,
+0x01,0xa0,0x18,0x21,0x7b,0xb6,0x03,0x3c,0x7b,0xb4,0x02,0xfc,0x7b,0xb2,0x02,0xbc,
+0x7b,0xb0,0x02,0x7c,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x68,
+0xa1,0xa2,0x00,0x00,0x92,0x83,0x00,0x21,0x25,0xad,0x00,0x01,0xa1,0xa3,0x00,0x00,
+0x08,0x00,0x2b,0x61,0x25,0xad,0x00,0x01,0x24,0x02,0x00,0x30,0x08,0x00,0x2b,0x94,
+0xa1,0xa2,0x00,0x00,0x01,0xcf,0x10,0x25,0x10,0x40,0xff,0xad,0x00,0x00,0x60,0x21,
+0x00,0x0e,0x18,0x02,0x03,0x3d,0x98,0x21,0x00,0x60,0x20,0x21,0x01,0xe0,0x38,0x21,
+0x10,0x60,0x00,0x04,0x27,0x39,0x00,0x01,0x00,0x70,0x00,0x1b,0x00,0x00,0x20,0x12,
+0x00,0x00,0x18,0x10,0x00,0x80,0x48,0x21,0x00,0xe0,0x30,0x21,0x01,0x80,0x70,0x21,
+0x01,0x80,0x28,0x21,0x10,0x00,0x00,0x06,0x24,0x04,0x00,0x21,0x00,0x03,0x08,0x40,
+0x00,0x03,0x2f,0xc2,0x00,0x22,0x18,0x25,0x00,0x06,0x30,0x40,0x00,0x0e,0x70,0x40,
+0x14,0xa0,0x00,0x02,0x00,0x70,0x10,0x2b,0x14,0x40,0x00,0x03,0x24,0x84,0xff,0xff,
+0x00,0x70,0x18,0x23,0x25,0xce,0x00,0x01,0x14,0x80,0xff,0xf4,0x00,0x06,0x17,0xc2,
+0x02,0x83,0x18,0x21,0x01,0xc0,0x38,0x21,0x00,0x00,0x50,0x21,0x00,0x09,0x20,0x00,
+0x00,0x00,0x28,0x21,0x90,0x66,0x00,0x00,0x00,0x8a,0x70,0x25,0x00,0xa7,0x78,0x25,
+0x01,0xcf,0x10,0x25,0x14,0x40,0xff,0xda,0xa2,0x66,0x00,0x00,0x08,0x00,0x2b,0x49,
+0x02,0x39,0x10,0x2a,0x08,0x00,0x2b,0x42,0x27,0x18,0xff,0xfe,0x10,0x40,0xff,0x73,
+0x32,0x56,0x00,0x20,0x08,0x00,0x2b,0x39,0x24,0x17,0x00,0x20,0x00,0x0f,0x78,0x23,
+0x00,0x0e,0x70,0x23,0x00,0x0f,0x10,0x2b,0x01,0xc2,0x70,0x23,0x08,0x00,0x2b,0x39,
+0x24,0x17,0x00,0x2d,0x80,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x06,
+0x00,0x80,0x18,0x21,0x24,0x63,0x00,0x01,0x80,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x64,0x10,0x23,
+0x24,0xa5,0xff,0xff,0x24,0x02,0xff,0xff,0x10,0xa2,0x00,0x0d,0x00,0x80,0x18,0x21,
+0x80,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09,0x00,0x00,0x00,0x00,
+0x24,0x06,0xff,0xff,0x24,0xa5,0xff,0xff,0x10,0xa6,0x00,0x05,0x24,0x63,0x00,0x01,
+0x80,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x64,0x10,0x23,0x80,0x82,0x00,0x00,0x90,0x88,0x00,0x00,
+0x10,0x40,0x00,0x17,0x00,0x00,0x48,0x21,0x90,0xa3,0x00,0x00,0x00,0xa0,0x30,0x21,
+0x10,0x60,0x00,0x0b,0x00,0x60,0x38,0x21,0x00,0x08,0x16,0x00,0x00,0x02,0x46,0x03,
+0x00,0x07,0x16,0x00,0x00,0x02,0x16,0x03,0x11,0x02,0x00,0x05,0x24,0xc6,0x00,0x01,
+0x90,0xc3,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0xf9,0x00,0x60,0x38,0x21,
+0x00,0x03,0x16,0x00,0x10,0x40,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x84,0x00,0x01,
+0x90,0x82,0x00,0x00,0x25,0x29,0x00,0x01,0x14,0x40,0xff,0xeb,0x00,0x40,0x40,0x21,
+0x03,0xe0,0x00,0x08,0x01,0x20,0x10,0x21,0x80,0x82,0x00,0x00,0x90,0x87,0x00,0x00,
+0x10,0x40,0x00,0x17,0x00,0x00,0x18,0x21,0x90,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x1e,0x00,0x10,0x60,0x00,0x0c,0x00,0xa0,0x30,0x21,0x00,0x07,0x16,0x00,
+0x00,0x02,0x3e,0x03,0x00,0x03,0x16,0x03,0x10,0xe2,0x00,0x0d,0x00,0x80,0x18,0x21,
+0x24,0xc6,0x00,0x01,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00,
+0x14,0x60,0xff,0xf9,0x00,0x03,0x16,0x03,0x24,0x84,0x00,0x01,0x90,0x82,0x00,0x00,
+0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xec,0x00,0x40,0x38,0x21,0x00,0x00,0x18,0x21,
+0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0,0xaf,0xb0,0x00,0x10,
+0x8f,0x90,0xc2,0x58,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0x00,0x84,0x80,0x0b,
+0x00,0x00,0x30,0x21,0x12,0x00,0x00,0x0a,0x00,0xa0,0x88,0x21,0x0c,0x00,0x2b,0xee,
+0x02,0x00,0x20,0x21,0x02,0x02,0x80,0x21,0x82,0x02,0x00,0x00,0x02,0x20,0x28,0x21,
+0x02,0x00,0x20,0x21,0x14,0x40,0x00,0x07,0x00,0x00,0x30,0x21,0xaf,0x80,0xc2,0x58,
+0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x0c,0x00,0x2c,0x0a,0x00,0x00,0x00,0x00,0x00,0x40,0x18,0x21,
+0x10,0x40,0x00,0x07,0x02,0x00,0x30,0x21,0x80,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0xa0,0x60,0x00,0x00,0x24,0x63,0x00,0x01,
+0xaf,0x83,0xc2,0x58,0x08,0x00,0x2c,0x38,0x00,0x00,0x00,0x00,0x24,0xc6,0xff,0xff,
+0x24,0x02,0xff,0xff,0x10,0xc2,0x00,0x05,0x00,0x80,0x18,0x21,0x24,0xc6,0xff,0xff,
+0xa0,0x65,0x00,0x00,0x14,0xc2,0xff,0xfd,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,
+0x00,0x80,0x10,0x21,0x24,0xc6,0xff,0xff,0x24,0x02,0xff,0xff,0x10,0xc2,0x00,0x08,
+0x00,0x80,0x18,0x21,0x24,0x07,0xff,0xff,0x90,0xa2,0x00,0x00,0x24,0xc6,0xff,0xff,
+0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x00,0x14,0xc7,0xff,0xfb,0x24,0x63,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x00,0x80,0x18,0x21,0x90,0xa2,0x00,0x00,
+0x24,0xa5,0x00,0x01,0xa0,0x82,0x00,0x00,0x14,0x40,0xff,0xfc,0x24,0x84,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x90,0x83,0x00,0x00,0x90,0xa2,0x00,0x00,
+0x24,0x84,0x00,0x01,0x00,0x62,0x10,0x23,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,
+0x14,0x40,0x00,0x03,0x24,0xa5,0x00,0x01,0x14,0x60,0xff,0xf7,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,
+0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0xa5,0x00,0x20,0x24,0x42,0xb1,0xe0,
+0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x20,0xac,0x82,0x00,0x64,
+0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60,0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,
+0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c,0xac,0x80,0x00,0x50,0xac,0x80,0x00,0x54,
+0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58,0xa0,0x80,0x00,0x5c,0x24,0x42,0xb2,0xb0,
+0x24,0x83,0x00,0x68,0x24,0x05,0x00,0x0f,0x24,0xa5,0xff,0xff,0xac,0x62,0x00,0x00,
+0x04,0xa1,0xff,0xfd,0x24,0x63,0x00,0x04,0x3c,0x02,0x80,0x01,0x3c,0x03,0x80,0x01,
+0x24,0x42,0xb3,0xe0,0x24,0x63,0xb4,0x44,0xac,0x82,0x00,0x78,0xac,0x83,0x00,0x84,
+0x3c,0x02,0x80,0x01,0x3c,0x03,0x80,0x01,0x24,0x42,0xb5,0x6c,0x24,0x63,0xb4,0xd8,
+0xac,0x82,0x00,0x88,0xac,0x83,0x00,0x98,0x3c,0x02,0x80,0x01,0x3c,0x03,0x80,0x01,
+0x24,0x42,0xb6,0x14,0x24,0x63,0xb6,0xd4,0xac,0x82,0x00,0xa0,0xac,0x83,0x00,0xa4,
+0xa0,0x80,0x01,0xba,0xac,0x80,0x01,0xa8,0xac,0x80,0x01,0xac,0xac,0x80,0x01,0xb0,
+0xac,0x80,0x01,0xb4,0xa0,0x80,0x01,0xb8,0x03,0xe0,0x00,0x08,0xa0,0x80,0x01,0xb9,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0xb2,0xb0,
+0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,
+0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,0x24,0x42,0xb2,0xc8,0xaf,0xb0,0x00,0x10,
+0xac,0x62,0x00,0x00,0xaf,0xbf,0x00,0x14,0x8c,0x83,0x00,0x10,0x8f,0x82,0x91,0xe8,
+0x00,0x80,0x80,0x21,0x3c,0x04,0x80,0x01,0x30,0x46,0x00,0x01,0x10,0x60,0x00,0x11,
+0x24,0x84,0x08,0xdc,0x8e,0x02,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,
+0x00,0x00,0x00,0x00,0x8e,0x05,0x00,0x10,0x8e,0x03,0x00,0x14,0x8e,0x02,0x00,0x04,
+0x00,0xa3,0x28,0x21,0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,
+0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff,
+0xae,0x02,0x00,0x04,0x14,0xc0,0x00,0x0a,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x00,
+0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,
+0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x8e,0x05,0x00,0x10,0x8e,0x07,0x00,0x04,0x8e,0x06,0x00,0x14,0x0c,0x00,0x17,0x9d,
+0x00,0x00,0x00,0x00,0x08,0x00,0x2c,0xd4,0xae,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0xb3,0x8c,0xac,0x62,0x00,0x00,
+0x8c,0x86,0x00,0x04,0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21,
+0x8c,0x45,0x00,0x00,0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff,
+0x30,0x42,0x00,0xff,0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14,
+0xac,0x85,0x00,0x40,0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08,
+0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,
+0x24,0x63,0xb3,0xe0,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,
+0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21,
+0xae,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,
+0xae,0x00,0x00,0x0c,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x2c,0xe3,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x05,
+0xae,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
+0x34,0x42,0x00,0x20,0x24,0x63,0xb4,0x44,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
+0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16,
+0x00,0x80,0x80,0x21,0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44,
+0x00,0x62,0x18,0x21,0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50,
+0x30,0xa3,0x00,0xff,0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f,
+0x30,0x42,0x00,0x03,0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c,
+0xae,0x03,0x00,0x30,0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x2c,0xe3,0x00,0x00,0x00,0x00,
+0x08,0x00,0x2d,0x1d,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,
+0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xb4,0xd8,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40,
+0x83,0x85,0x92,0x15,0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02,
+0xae,0x04,0x00,0x14,0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04,
+0xae,0x03,0x00,0x3c,0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01,
+0x24,0x02,0x00,0x01,0xa3,0x86,0x92,0x15,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,
+0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x2d,0x11,
+0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x42,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xb5,0x6c,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03,
+0x8c,0x42,0x00,0x00,0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x92,0x15,
+0x92,0x05,0x00,0x41,0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2,
+0x00,0x03,0x1e,0x02,0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21,
+0xae,0x03,0x00,0x18,0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03,
+0x24,0x02,0x00,0x01,0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x92,0x15,
+0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x2d,0x11,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x67,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
+0x34,0x42,0x00,0x20,0x24,0x63,0xb6,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
+0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x21,
+0x00,0x80,0x80,0x21,0x8e,0x05,0x00,0x04,0x8e,0x04,0x00,0x44,0x3c,0x03,0x80,0x00,
+0x34,0x63,0x00,0x10,0x3c,0x02,0xb0,0x01,0x00,0xa2,0x28,0x21,0x00,0x83,0x20,0x25,
+0xac,0xa4,0x00,0x04,0x8e,0x03,0x01,0xac,0x8e,0x08,0x00,0x04,0x3c,0x07,0xb0,0x03,
+0x24,0x66,0x00,0x01,0x28,0xc5,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xc5,0x10,0x0a,
+0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xc2,0x30,0x23,
+0x00,0x70,0x18,0x21,0xae,0x06,0x01,0xac,0x34,0xe7,0x00,0x30,0xac,0x68,0x00,0xa8,
+0x8c,0xe2,0x00,0x00,0x02,0x00,0x20,0x21,0x24,0x42,0x00,0x01,0x0c,0x00,0x2c,0xb2,
+0xac,0xe2,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x2d,0x5b,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0x91,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
+0x34,0x42,0x00,0x20,0x24,0x63,0xb6,0xd4,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
+0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x21,
+0x00,0x80,0x80,0x21,0x8e,0x05,0x00,0x04,0x8e,0x04,0x00,0x44,0x3c,0x03,0x80,0x00,
+0x34,0x63,0x00,0x10,0x3c,0x02,0xb0,0x01,0x00,0xa2,0x28,0x21,0x00,0x83,0x20,0x25,
+0xac,0xa4,0x00,0x04,0x8e,0x03,0x01,0xac,0x8e,0x08,0x00,0x04,0x3c,0x07,0xb0,0x03,
+0x24,0x66,0x00,0x01,0x28,0xc5,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xc5,0x10,0x0a,
+0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xc2,0x30,0x23,
+0x00,0x70,0x18,0x21,0xae,0x06,0x01,0xac,0x34,0xe7,0x00,0x30,0xac,0x68,0x00,0xa8,
+0x8c,0xe2,0x00,0x00,0x02,0x00,0x20,0x21,0x24,0x42,0x00,0x01,0x0c,0x00,0x2c,0xb2,
+0xac,0xe2,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x2d,0x5b,0x00,0x00,0x00,0x00,0x08,0x00,0x2d,0xc1,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,
+0x24,0x63,0xb7,0x94,0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0x3c,0x02,0x80,0x01,
+0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,0x00,0x80,0x80,0x21,
+0x24,0x51,0xb2,0xb0,0x3c,0x03,0xb0,0x09,0x34,0x63,0x00,0x06,0x8e,0x07,0x00,0x04,
+0x90,0x62,0x00,0x00,0x00,0x07,0x22,0x02,0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40,
+0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,
+0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff,0x10,0x44,0x00,0x5f,0x00,0x00,0x40,0x21,
+0x3c,0x02,0xb0,0x01,0x00,0xe2,0x10,0x21,0x8c,0x44,0x00,0x04,0x3c,0x03,0x7c,0x00,
+0x34,0x63,0x00,0xf0,0x00,0x83,0x18,0x24,0xae,0x04,0x00,0x44,0x8c,0x44,0x00,0x00,
+0x10,0x60,0x00,0x60,0x00,0x00,0x48,0x21,0x24,0xe2,0x01,0x00,0x30,0x45,0x3f,0xff,
+0x3c,0x03,0xb0,0x01,0xae,0x05,0x00,0x04,0x00,0xa3,0x18,0x21,0x8c,0x64,0x00,0x04,
+0x3c,0x02,0x7c,0x00,0x34,0x42,0x00,0xf0,0x00,0x82,0x30,0x24,0xae,0x04,0x00,0x44,
+0x25,0x08,0x00,0x01,0x24,0x02,0x00,0x40,0x00,0xa0,0x38,0x21,0x8c,0x64,0x00,0x00,
+0x11,0x02,0x00,0x30,0x24,0x09,0x00,0x01,0x3c,0x02,0xff,0xff,0x14,0xc0,0xff,0xee,
+0x00,0x82,0x18,0x24,0x3c,0x02,0x28,0x38,0x14,0x62,0xff,0xec,0x24,0xe2,0x01,0x00,
+0x24,0x02,0x00,0x01,0x11,0x22,0x00,0x2e,0x3c,0x03,0xb0,0x09,0x8e,0x02,0x00,0x44,
+0x8e,0x04,0x00,0x60,0x00,0x02,0x1e,0x42,0x00,0x02,0x12,0x02,0x30,0x42,0x00,0x0f,
+0x30,0x63,0x00,0x01,0xae,0x02,0x00,0x00,0x10,0x44,0x00,0x1a,0xae,0x03,0x00,0x58,
+0x8e,0x02,0x00,0x64,0x8e,0x04,0x00,0x58,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x05,
+0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,
+0xae,0x00,0x00,0x0c,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x80,
+0x00,0x50,0x10,0x21,0x8c,0x42,0x00,0x68,0x00,0x00,0x00,0x00,0x10,0x51,0x00,0x06,
+0x00,0x00,0x00,0x00,0x00,0x40,0xf8,0x09,0x02,0x00,0x20,0x21,0x8e,0x04,0x00,0x58,
+0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x60,0x08,0x00,0x2d,0xf1,
+0xae,0x04,0x00,0x64,0x8e,0x02,0x00,0x64,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xe5,
+0x00,0x00,0x00,0x00,0x7a,0x02,0x0d,0x7c,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,
+0x00,0x43,0x10,0x26,0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x34,0x63,0x00,0x06,0x8e,0x04,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x04,0x22,0x02,
+0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,
+0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,
+0x14,0x89,0xff,0xc6,0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+0x2c,0x62,0x00,0x03,0x14,0x40,0x00,0x05,0x24,0x02,0x00,0x0d,0x10,0x62,0x00,0x03,
+0x24,0x02,0x00,0x01,0x08,0x00,0x2e,0x49,0xa2,0x02,0x00,0x5c,0x08,0x00,0x2e,0x49,
+0xa2,0x00,0x00,0x5c,0x3c,0x02,0xff,0xff,0x00,0x82,0x10,0x24,0x3c,0x03,0x28,0x38,
+0x14,0x43,0xff,0x9d,0x24,0x02,0x00,0x01,0x08,0x00,0x2e,0x21,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0xb9,0xc0,
+0xac,0x62,0x00,0x00,0x8c,0x83,0x01,0xa8,0x3c,0x05,0xb0,0x06,0x34,0xa5,0x80,0x18,
+0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0xa8,0x3c,0x03,0x00,0x80,
+0x00,0x02,0x10,0xc2,0x00,0x02,0x12,0x00,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x00,
+0x8c,0x83,0x01,0xa8,0x8c,0x82,0x01,0xac,0x24,0x66,0x00,0x01,0x28,0xc5,0x00,0x00,
+0x24,0x63,0x00,0x40,0x00,0xc5,0x18,0x0a,0x00,0x03,0x19,0x83,0x00,0x03,0x19,0x80,
+0x00,0xc3,0x30,0x23,0x00,0xc2,0x10,0x26,0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,
+0xac,0x86,0x01,0xa8,0x90,0x87,0x00,0x00,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,
+0x24,0x48,0x02,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x01,0x07,0x18,0x21,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,0x10,0x40,0x00,0x0a,
+0x00,0x00,0x80,0x21,0x24,0x84,0x00,0x01,0x90,0x87,0x00,0x00,0x00,0x00,0x00,0x00,
+0x01,0x07,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,
+0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00,0x02,0x16,0x03,
+0x24,0x03,0x00,0x2d,0x10,0x43,0x00,0x0f,0x00,0x00,0x00,0x00,0x0c,0x00,0x2e,0xb8,
+0x00,0x00,0x00,0x00,0x00,0x40,0x18,0x21,0x00,0x02,0x10,0x23,0x04,0x61,0x00,0x05,
+0x00,0x70,0x10,0x0a,0x16,0x00,0x00,0x03,0x3c,0x02,0x80,0x00,0x3c,0x02,0x7f,0xff,
+0x34,0x42,0xff,0xff,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x24,0x10,0xff,0xff,0x08,0x00,0x2e,0xa7,0x24,0x84,0x00,0x01,
+0x00,0x80,0x38,0x21,0x90,0x84,0x00,0x00,0x3c,0x02,0x80,0x01,0x24,0x48,0x02,0x14,
+0x01,0x04,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x20,
+0x10,0x40,0x00,0x0a,0x00,0x00,0x50,0x21,0x24,0xe7,0x00,0x01,0x90,0xe4,0x00,0x00,
+0x00,0x00,0x00,0x00,0x01,0x04,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x20,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x04,0x16,0x00,
+0x00,0x02,0x16,0x03,0x38,0x42,0x00,0x2b,0x24,0xe3,0x00,0x01,0x24,0x04,0x00,0x10,
+0x10,0xc4,0x00,0x38,0x00,0x62,0x38,0x0a,0x90,0xe4,0x00,0x00,0x14,0xc0,0x00,0x07,
+0x00,0x80,0x18,0x21,0x00,0x04,0x16,0x00,0x00,0x02,0x16,0x03,0x24,0x03,0x00,0x30,
+0x10,0x43,0x00,0x25,0x24,0x06,0x00,0x0a,0x00,0x80,0x18,0x21,0x00,0x03,0x16,0x00,
+0x10,0x40,0x00,0x1a,0x30,0x64,0x00,0xff,0x24,0x82,0xff,0xa9,0x2c,0x83,0x00,0x61,
+0x30,0x48,0x00,0xff,0x10,0x60,0x00,0x09,0x2c,0x89,0x00,0x41,0x24,0x82,0xff,0xc9,
+0x30,0x48,0x00,0xff,0x11,0x20,0x00,0x05,0x2c,0x83,0x00,0x3a,0x24,0x82,0xff,0xd0,
+0x14,0x60,0x00,0x02,0x30,0x48,0x00,0xff,0x24,0x08,0x00,0xff,0x01,0x06,0x10,0x2a,
+0x10,0x40,0x00,0x0a,0x01,0x46,0x00,0x18,0x24,0xe7,0x00,0x01,0x00,0x00,0x18,0x12,
+0x00,0x6a,0x10,0x2b,0x14,0x40,0x00,0x0a,0x00,0x68,0x50,0x21,0x80,0xe2,0x00,0x00,
+0x90,0xe3,0x00,0x00,0x14,0x40,0xff,0xe8,0x30,0x64,0x00,0xff,0x10,0xa0,0x00,0x02,
+0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x03,0xe0,0x00,0x08,0x01,0x40,0x10,0x21,
+0x03,0xe0,0x00,0x08,0x24,0x02,0xff,0xff,0x24,0x06,0x00,0x08,0x80,0xe3,0x00,0x01,
+0x24,0x02,0x00,0x78,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x58,0x14,0x62,0xff,0xd7,
+0x00,0x80,0x18,0x21,0x24,0xe7,0x00,0x02,0x90,0xe4,0x00,0x00,0x08,0x00,0x2e,0xda,
+0x24,0x06,0x00,0x10,0x80,0xe3,0x00,0x00,0x24,0x02,0x00,0x30,0x90,0xe4,0x00,0x00,
+0x10,0x62,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x2e,0xd3,0x00,0x00,0x00,0x00,
+0x3c,0x04,0xb0,0x03,0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01,0x34,0xc6,0x00,0x18,
+0x34,0x84,0x00,0x20,0x24,0x42,0xbc,0x40,0x24,0x03,0xff,0x83,0xac,0x82,0x00,0x00,
+0xa0,0xc3,0x00,0x00,0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8,0x3c,0x03,0xb0,0x07,
+0x24,0x02,0xff,0x82,0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00,0x90,0x64,0x00,0x00,
+0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01,0xa0,0x40,0x00,0x00,
+0x90,0x43,0x00,0x00,0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07,0xa3,0xa3,0x00,0x00,
+0xa0,0xc2,0x00,0x00,0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10,0x24,0x02,0x00,0x06,
+0x3c,0x03,0xb0,0x07,0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38,0xa0,0xa2,0x00,0x00,
+0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20,0xa3,0xa4,0x00,0x00,
+0xa0,0xa0,0x00,0x00,0x90,0xa3,0x00,0x00,0xaf,0x82,0xc2,0x5c,0xa3,0xa3,0x00,0x00,
+0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,
+};
+
+#define DataArrayLengthDTM 2860
+u8 Rtl8192PciEFwDataArrayDTM[DataArrayLengthDTM] = {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x0d,0x5b,0x43,
+0x4d,0x50,0x4b,0x5d,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x28,0x28,0x28,
+0x28,0x28,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+0x08,0x08,0x08,0x08,0xa0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x10,0x10,0x10,0x10,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x10,0x10,
+0x10,0x10,0x10,0x10,0x10,0x41,0x41,0x41,0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,
+0x10,0x10,0x10,0x10,0x10,0x42,0x42,0x42,0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,
+0x10,0x10,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0xa0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x10,0x10,0x10,0x10,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x02,0x02,0x02,0x02,
+0x02,0x02,0x02,0x02,0x20,0x09,0x0d,0x0a,0x00,0x00,0x00,0x00,0x80,0x01,0x03,0x14,
+0x00,0x00,0x00,0x00,0x43,0x6e,0x73,0x64,0x31,0x00,0x00,0x00,0x68,0x65,0x6c,0x70,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x34,0x00,0x00,0x77,0x34,0x00,0x00,
+0x64,0x62,0x67,0x00,0x72,0x61,0x63,0x74,0x72,0x6c,0x00,0x00,0x73,0x79,0x73,0x64,
+0x00,0x00,0x00,0x00,0x73,0x79,0x73,0x63,0x74,0x72,0x6c,0x00,0x74,0x78,0x74,0x62,
+0x6c,0x00,0x00,0x00,0x70,0x72,0x61,0x6e,0x67,0x65,0x00,0x00,0x64,0x6d,0x00,0x00,
+0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x00,0x00,0x80,0x01,0x03,0x2c,0x80,0x01,0x03,0x34,
+0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x20,0x5c,
+0x80,0x01,0x03,0x38,0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,
+0x00,0x00,0x00,0x00,0x80,0x00,0x21,0xbc,0x80,0x01,0x03,0x3c,0x80,0x01,0x03,0x34,
+0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x23,0x38,
+0x80,0x01,0x03,0x40,0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,
+0x00,0x00,0x00,0x00,0x80,0x00,0x25,0x04,0x80,0x01,0x03,0x44,0x80,0x01,0x03,0x34,
+0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x25,0xdc,
+0x80,0x01,0x03,0x4c,0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,
+0x00,0x00,0x00,0x00,0x80,0x00,0x25,0xe4,0x80,0x01,0x03,0x54,0x80,0x01,0x03,0x34,
+0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x26,0x88,
+0x80,0x01,0x03,0x5c,0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,
+0x00,0x00,0x00,0x00,0x80,0x00,0x26,0x90,0x80,0x01,0x03,0x64,0x80,0x01,0x03,0x34,
+0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x28,0x1c,
+0x80,0x01,0x03,0x6c,0x80,0x01,0x03,0x34,0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x01,
+0x00,0x00,0x00,0x00,0x80,0x00,0x28,0x90,0x80,0x01,0x03,0x70,0x80,0x01,0x03,0x34,
+0x80,0x01,0x03,0x34,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x01,0x80,0x00,0x29,0x1c,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x0d,0x52,0x54,0x4c,0x38,0x31,0x39,
+0x58,0x2d,0x25,0x64,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x54,0x4c,0x38,
+0x31,0x39,0x58,0x2d,0x25,0x64,0x3e,0x0a,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x2a,0x00,0x00,0x00,0x0a,0x0d,0x45,0x72,0x72,0x20,0x44,0x49,0x52,0x00,0x00,0x00,
+0x0a,0x0d,0x44,0x42,0x47,0x20,0x43,0x4d,0x44,0x73,0x3a,0x00,0x0a,0x0d,0x5b,0x00,
+0x5d,0x2d,0x00,0x00,0x0a,0x0d,0x3c,0x31,0x2e,0x43,0x4d,0x4e,0x3e,0x20,0x3c,0x32,
+0x2e,0x3f,0x3e,0x00,0x0a,0x0d,0x20,0x79,0x65,0x61,0x72,0x2d,0x64,0x61,0x79,0x2d,
+0x68,0x6f,0x75,0x72,0x2d,0x6d,0x69,0x6e,0x2d,0x73,0x65,0x63,0x2d,0x31,0x30,0x6d,
+0x73,0x3d,0x00,0x00,0x25,0x64,0x2d,0x00,0x0a,0x0d,0x09,0x20,0x20,0x20,0x20,0x20,
+0x30,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x34,0x20,0x20,0x20,0x20,0x20,
+0x20,0x20,0x30,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x43,0x00,0x00,0x00,
+0x0a,0x0d,0x09,0x20,0x20,0x20,0x20,0x20,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,
+0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,
+0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x3d,0x00,0x0d,0x0a,0x20,0x30,
+0x78,0x25,0x30,0x38,0x58,0x20,0x20,0x00,0x09,0x00,0x00,0x00,0x25,0x30,0x38,0x58,
+0x20,0x00,0x00,0x00,0x0a,0x0d,0x44,0x62,0x67,0x5f,0x46,0x6c,0x61,0x67,0x25,0x64,
+0x3d,0x30,0x78,0x25,0x30,0x38,0x78,0x00,0x0a,0x0d,0x20,0x76,0x6f,0x71,0x74,0x78,
+0x72,0x65,0x71,0x20,0x3d,0x20,0x25,0x64,0x00,0x00,0x00,0x00,0x0a,0x0d,0x20,0x76,
+0x69,0x71,0x74,0x78,0x72,0x65,0x71,0x20,0x3d,0x20,0x25,0x64,0x00,0x00,0x00,0x00,
+0x0a,0x0d,0x20,0x62,0x65,0x71,0x74,0x78,0x72,0x65,0x71,0x20,0x3d,0x20,0x25,0x64,
+0x00,0x00,0x00,0x00,0x0a,0x0d,0x20,0x62,0x6b,0x71,0x74,0x78,0x72,0x65,0x71,0x20,
+0x3d,0x20,0x25,0x64,0x00,0x00,0x00,0x00,0x0a,0x0d,0x20,0x62,0x63,0x6e,0x71,0x74,
+0x78,0x72,0x65,0x71,0x20,0x3d,0x20,0x25,0x64,0x00,0x00,0x00,0x0a,0x0d,0x20,0x68,
+0x71,0x74,0x78,0x72,0x65,0x71,0x20,0x3d,0x20,0x25,0x64,0x00,0x0a,0x0d,0x20,0x6d,
+0x67,0x71,0x74,0x78,0x72,0x65,0x71,0x20,0x3d,0x20,0x25,0x64,0x00,0x00,0x00,0x00,
+0x0a,0x0d,0x54,0x58,0x4c,0x4c,0x54,0x09,0x09,0x4e,0x45,0x58,0x54,0x20,0x20,0x20,
+0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4e,0x45,0x58,0x54,0x0a,0x0d,0x00,
+0x0a,0x0d,0x20,0x50,0x61,0x67,0x65,0x25,0x33,0x64,0x09,0x00,0x25,0x34,0x64,0x20,
+0x20,0x20,0x20,0x00,0x25,0x34,0x64,0x20,0x20,0x20,0x20,0x09,0x00,0x00,0x00,0x00,
+0x0a,0x0d,0x54,0x58,0x4f,0x51,0x54,0x09,0x09,0x48,0x65,0x61,0x64,0x20,0x20,0x20,
+0x20,0x54,0x61,0x69,0x6c,0x20,0x20,0x20,0x20,0x48,0x65,0x61,0x64,0x20,0x20,0x20,
+0x20,0x54,0x61,0x69,0x6c,0x0a,0x0d,0x00,0x0a,0x0d,0x55,0x6e,0x6b,0x6e,0x6f,0x77,
+0x20,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x00,0x00,0x00,0x00,0x0a,0x0d,0x45,0x72,
+0x72,0x20,0x41,0x72,0x67,0x0a,0x0d,0x55,0x53,0x41,0x47,0x45,0x3a,0x00,0x00,0x00,
+0x10,0x00,0x08,0x00,0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4,
+0x00,0xab,0x00,0x72,0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,
+0x02,0x76,0x01,0x3b,0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f,
+0x01,0x3b,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20,
+0x01,0x2f,0x00,0x98,0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e,
+0x00,0x98,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f,
+0x02,0x39,0x01,0x1c,0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39,
+0x01,0x1c,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c,
+0x01,0x11,0x00,0x89,0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b,
+0x00,0x89,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e,
+0x02,0xab,0x02,0xab,0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08,
+0x04,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x54,0x4c,0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c,
+0x5f,0x64,0x61,0x74,0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00,
+0x41,0x64,0x45,0x4c,0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00,
+0x00,0x00,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78,
+0x63,0x43,0x6f,0x64,0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x42,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x4f,0x76,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x80,0x01,0x11,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,
+0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x50,
+0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20,
+0x00,0x00,0x01,0x80,0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xd0,
+0x00,0x00,0x01,0x30,0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x70,0x00,0x00,0x03,0x40,
+0x00,0x00,0x03,0xa0,0x00,0x00,0x04,0x10,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0xa0,
+0x00,0x00,0x02,0x70,0x00,0x00,0x03,0x40,0x00,0x00,0x04,0xe0,0x00,0x00,0x06,0x80,
+0x00,0x00,0x07,0x50,0x00,0x00,0x07,0xf8,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
+0x02,0x02,0x02,0x02,0x01,0x01,0x02,0x02,0x04,0x05,0x06,0x06,0x02,0x02,0x04,0x06,
+0x07,0x09,0x0a,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x3c,0x4e,0x55,0x4c,0x4c,0x3e,0x00,0x00,0x30,0x31,0x32,0x33,
+0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,
+0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,
+0x00,0x00,0x00,0x00,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,
+0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,
+0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x00,0x00,0x00,0x00,0x5b,0x52,0x58,0x5d,
+0x20,0x70,0x6b,0x74,0x5f,0x6c,0x65,0x6e,0x3d,0x25,0x64,0x20,0x6f,0x66,0x66,0x73,
+0x65,0x74,0x3d,0x25,0x64,0x20,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x64,0x64,0x72,
+0x3d,0x25,0x30,0x38,0x78,0x0a,0x0d,0x00,0x80,0x00,0x6a,0x64,0x80,0x00,0x6a,0x88,
+0x80,0x00,0x6a,0xa4,0x80,0x00,0x6b,0x90,0x80,0x00,0x6c,0x48,0x80,0x00,0x6c,0x98,
+0x80,0x00,0x6d,0x04,0x80,0x00,0x6e,0x08,0x80,0x00,0x6e,0x3c,0x80,0x00,0x6e,0x50,
+0x80,0x00,0x6e,0x64,0x80,0x00,0x6f,0x3c,0x80,0x00,0x6f,0x78,0x80,0x00,0x70,0x28,
+0x80,0x00,0x70,0x50,0x80,0x00,0x6a,0x20,0x80,0x00,0x70,0x64,0x80,0x00,0x76,0x5c,
+0x80,0x00,0x76,0xd4,0x80,0x00,0x76,0xe0,0x80,0x00,0x76,0xec,0x80,0x00,0x76,0x74,
+0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,
+0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,
+0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,0x80,0x00,0x76,0x74,0x80,0x00,0x76,0xf8,
+0x80,0x00,0x77,0x04,0x80,0x00,0x77,0x10,0x80,0x00,0xa7,0x80,0x80,0x00,0xa7,0x98,
+0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x88,0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x98,
+0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x98,
+0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x90,0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x78,
+0x80,0x00,0xa7,0x98,0x80,0x00,0xa7,0x98,0x80,0x00,0xab,0xc0,0x80,0x00,0xa8,0xb0,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xa8,0xbc,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xa8,0x44,0x80,0x00,0xa9,0x90,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xa9,0x90,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xa9,0x98,0x80,0x00,0xa9,0xb8,0x80,0x00,0xa9,0xc0,0x80,0x00,0xaa,0xc8,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0x18,0x80,0x00,0xaa,0xc8,0x80,0x00,0xa8,0xc4,
+0x80,0x00,0xaa,0xc8,0x80,0x00,0xaa,0xc8,0x80,0x00,0xa8,0xc0,};
+
+#define PHY_REGArrayLengthDTM 1
+u32 Rtl8192PciEPHY_REGArrayDTM[PHY_REGArrayLengthDTM] = {
+0x0, };
+
+#define PHY_REG_1T2RArrayLengthDTM 296
+u32 Rtl8192PciEPHY_REG_1T2RArrayDTM[PHY_REG_1T2RArrayLengthDTM] = {
+0x800,0x00000000,
+0x804,0x00000001,
+0x808,0x0000fc00,
+0x80c,0x0000001c,
+0x810,0x801010aa,
+0x814,0x008514d0,
+0x818,0x00000040,
+0x81c,0x00000000,
+0x820,0x00000004,
+0x824,0x00690000,
+0x828,0x00000004,
+0x82c,0x00e90000,
+0x830,0x00000004,
+0x834,0x00690000,
+0x838,0x00000004,
+0x83c,0x00e90000,
+0x840,0x00000000,
+0x844,0x00000000,
+0x848,0x00000000,
+0x84c,0x00000000,
+0x850,0x00000000,
+0x854,0x00000000,
+0x858,0x65a965a9,
+0x85c,0x65a965a9,
+0x860,0x001f0010,
+0x864,0x007f0010,
+0x868,0x001f0010,
+0x86c,0x007f0010,
+0x870,0x0f100f70,
+0x874,0x0f100f70,
+0x878,0x00000000,
+0x87c,0x00000000,
+0x880,0x6870e36c,
+0x884,0xe3573600,
+0x888,0x4260c340,
+0x88c,0x0000ff00,
+0x890,0x00000000,
+0x894,0xfffffffe,
+0x898,0x40302010,
+0x89c,0x00706050,
+0x8b0,0x00000000,
+0x8e0,0x00000000,
+0x8e4,0x00000000,
+0x900,0x00000000,
+0x904,0x00000023,
+0x908,0x00000000,
+0x90c,0x31121311,
+0xa00,0x00d0c7d8,
+0xa04,0x811f0008,
+0xa08,0x80cd8300,
+0xa0c,0x2e62740f,
+0xa10,0x95009b78,
+0xa14,0x11145008,
+0xa18,0x00881117,
+0xa1c,0x89140fa0,
+0xa20,0x1a1b0000,
+0xa24,0x090e1317,
+0xa28,0x00000204,
+0xa2c,0x00000000,
+0xc00,0x00000040,
+0xc04,0x00005411,
+0xc08,0x000000e4,
+0xc0c,0x6c6c6c6c,
+0xc10,0x08800000,
+0xc14,0x40000100,
+0xc18,0x08000000,
+0xc1c,0x40000100,
+0xc20,0x08000000,
+0xc24,0x40000100,
+0xc28,0x08000000,
+0xc2c,0x40000100,
+0xc30,0x6de98a44,
+0xc34,0x469652cd,
+0xc38,0x49475996,
+0xc3c,0x0a9a9764,
+0xc40,0x1f7c423f,
+0xc44,0x000100b7,
+0xc48,0xec020000,
+0xc4c,0x00000300,
+0xc50,0x69543430,
+0xc54,0x433c0094,
+0xc58,0x69543430,
+0xc5c,0x433c0094,
+0xc60,0x69543430,
+0xc64,0x433c0094,
+0xc68,0x69543430,
+0xc6c,0x433c0094,
+0xc70,0x2c7f000d,
+0xc74,0x0186175b,
+0xc78,0x0000001f,
+0xc7c,0x00b91612,
+0xc80,0x40000100,
+0xc84,0x20000000,
+0xc88,0x40000100,
+0xc8c,0x08000000,
+0xc90,0x40000100,
+0xc94,0x00000000,
+0xc98,0x40000100,
+0xc9c,0x00000000,
+0xca0,0x00492492,
+0xca4,0x00000000,
+0xca8,0x00000000,
+0xcac,0x00000000,
+0xcb0,0x00000000,
+0xcb4,0x00000000,
+0xcb8,0x00000000,
+0xcbc,0x00492492,
+0xcc0,0x00000000,
+0xcc4,0x00000000,
+0xcc8,0x00000000,
+0xccc,0x00000000,
+0xcd0,0x00000000,
+0xcd4,0x00000000,
+0xcd8,0x64b22427,
+0xcdc,0x00766932,
+0xce0,0x00222222,
+0xd00,0x00000740,
+0xd04,0x00000401,
+0xd08,0x0000907f,
+0xd0c,0x00000001,
+0xd10,0xa0633333,
+0xd14,0x33333c63,
+0xd18,0x6a8f5b6b,
+0xd1c,0x00000000,
+0xd20,0x00000000,
+0xd24,0x00000000,
+0xd28,0x00000000,
+0xd2c,0xcc979975,
+0xd30,0x00000000,
+0xd34,0x00000000,
+0xd38,0x00000000,
+0xd3c,0x00027293,
+0xd40,0x00000000,
+0xd44,0x00000000,
+0xd48,0x00000000,
+0xd4c,0x00000000,
+0xd50,0x6437140a,
+0xd54,0x024dbd02,
+0xd58,0x00000000,
+0xd5c,0x2d432064,
+0xe00,0x161a1a1a,
+0xe04,0x12121416,
+0xe08,0x00001800,
+0xe0c,0x00000000,
+0xe10,0x161a1a1a,
+0xe14,0x12121416,
+0xe18,0x161a1a1a,
+0xe1c,0x12121416,
+};
+
+#define RadioA_ArrayLengthDTM 246
+u32 Rtl8192PciERadioA_ArrayDTM[RadioA_ArrayLengthDTM] = {
+0x019,0x00000003,
+0x000,0x000000bf,
+0x001,0x00000ee0,
+0x002,0x0000004c,
+0x003,0x000007f1,
+0x004,0x00000975,
+0x005,0x00000c58,
+0x006,0x00000ae6,
+0x007,0x000000ca,
+0x008,0x00000e1c,
+0x009,0x000007f0,
+0x00a,0x000009d0,
+0x00b,0x000001ba,
+0x00c,0x00000240,
+0x00e,0x00000020,
+0x00f,0x00000ff0,
+0x012,0x00000806,
+0x014,0x000005ab,
+0x015,0x00000f80,
+0x016,0x00000020,
+0x017,0x00000597,
+0x018,0x0000050a,
+0x01a,0x00000e00,
+0x01b,0x00000f5e,
+0x01c,0x00000008,
+0x01d,0x00000607,
+0x01e,0x000006cc,
+0x01f,0x00000000,
+0x020,0x00000096,
+0x01f,0x00000001,
+0x020,0x00000076,
+0x01f,0x00000002,
+0x020,0x00000056,
+0x01f,0x00000003,
+0x020,0x00000036,
+0x01f,0x00000004,
+0x020,0x00000016,
+0x01f,0x00000005,
+0x020,0x000001f6,
+0x01f,0x00000006,
+0x020,0x000001d6,
+0x01f,0x00000007,
+0x020,0x000001b6,
+0x01f,0x00000008,
+0x020,0x00000196,
+0x01f,0x00000009,
+0x020,0x00000176,
+0x01f,0x0000000a,
+0x020,0x000000f7,
+0x01f,0x0000000b,
+0x020,0x000000d7,
+0x01f,0x0000000c,
+0x020,0x000000b7,
+0x01f,0x0000000d,
+0x020,0x00000097,
+0x01f,0x0000000e,
+0x020,0x00000077,
+0x01f,0x0000000f,
+0x020,0x00000057,
+0x01f,0x00000010,
+0x020,0x00000037,
+0x01f,0x00000011,
+0x020,0x000000fb,
+0x01f,0x00000012,
+0x020,0x000000db,
+0x01f,0x00000013,
+0x020,0x000000bb,
+0x01f,0x00000014,
+0x020,0x000000ff,
+0x01f,0x00000015,
+0x020,0x000000e3,
+0x01f,0x00000016,
+0x020,0x000000c3,
+0x01f,0x00000017,
+0x020,0x000000a3,
+0x01f,0x00000018,
+0x020,0x00000083,
+0x01f,0x00000019,
+0x020,0x00000063,
+0x01f,0x0000001a,
+0x020,0x00000043,
+0x01f,0x0000001b,
+0x020,0x00000023,
+0x01f,0x0000001c,
+0x020,0x00000003,
+0x01f,0x0000001d,
+0x020,0x000001e3,
+0x01f,0x0000001e,
+0x020,0x000001c3,
+0x01f,0x0000001f,
+0x020,0x000001a3,
+0x01f,0x00000020,
+0x020,0x00000183,
+0x01f,0x00000021,
+0x020,0x00000163,
+0x01f,0x00000022,
+0x020,0x00000143,
+0x01f,0x00000023,
+0x020,0x00000123,
+0x01f,0x00000024,
+0x020,0x00000103,
+0x023,0x00000203,
+0x024,0x00000200,
+0x00b,0x000001ba,
+0x02c,0x000003d7,
+0x02d,0x00000ff0,
+0x000,0x00000037,
+0x004,0x00000160,
+0x007,0x00000080,
+0x002,0x0000088d,
+0x0fe,0x00000000,
+0x0fe,0x00000000,
+0x016,0x00000200,
+0x016,0x00000380,
+0x016,0x00000020,
+0x016,0x000001a0,
+0x000,0x000000bf,
+0x00d,0x0000001f,
+0x00d,0x00000c9f,
+0x002,0x0000004d,
+0x000,0x00000cbf,
+0x004,0x00000975,
+0x007,0x00000700,
+};
+
+#define RadioB_ArrayLengthDTM 78
+u32 Rtl8192PciERadioB_ArrayDTM[RadioB_ArrayLengthDTM] = {
+0x019,0x00000003,
+0x000,0x000000bf,
+0x001,0x000006e0,
+0x002,0x0000004c,
+0x003,0x000007f1,
+0x004,0x00000975,
+0x005,0x00000c58,
+0x006,0x00000ae6,
+0x007,0x000000ca,
+0x008,0x00000e1c,
+0x000,0x000000b7,
+0x00a,0x00000850,
+0x000,0x000000bf,
+0x00b,0x000001ba,
+0x00c,0x00000240,
+0x00e,0x00000020,
+0x015,0x00000f80,
+0x016,0x00000020,
+0x017,0x00000597,
+0x018,0x0000050a,
+0x01a,0x00000e00,
+0x01b,0x00000f5e,
+0x01d,0x00000607,
+0x01e,0x000006cc,
+0x00b,0x000001ba,
+0x023,0x00000203,
+0x024,0x00000200,
+0x000,0x00000037,
+0x004,0x00000160,
+0x016,0x00000200,
+0x016,0x00000380,
+0x016,0x00000020,
+0x016,0x000001a0,
+0x00d,0x00000ccc,
+0x000,0x000000bf,
+0x002,0x0000004d,
+0x000,0x00000cbf,
+0x004,0x00000975,
+0x007,0x00000700,
+};
+
+#define RadioC_ArrayLengthDTM 1
+u32 Rtl8192PciERadioC_ArrayDTM[RadioC_ArrayLengthDTM] = {
+0x0, };
+
+#define RadioD_ArrayLengthDTM 1
+u32 Rtl8192PciERadioD_ArrayDTM[RadioD_ArrayLengthDTM] = {
+0x0, };
+
+u32 Rtl8192PciEMACPHY_ArrayDTM[] = {
+0x03c,0xffff0000,0x00000f0f,
+0x340,0xffffffff,0x161a1a1a,
+0x344,0xffffffff,0x12121416,
+0x348,0x0000ffff,0x00001818,
+0x12c,0xffffffff,0x04000802,
+0x318,0x00000fff,0x00000100,
+};
+
+u32 Rtl8192PciEMACPHY_Array_PGDTM[] = {
+0x03c,0xffff0000,0x00000f0f,
+0xe00,0xffffffff,0x06090909,
+0xe04,0xffffffff,0x00030306,
+0xe08,0x0000ff00,0x00000000,
+0xe10,0xffffffff,0x050b0b0e,
+0xe14,0xffffffff,0x00030305,
+0xe18,0xffffffff,0x050b0b0e,
+0xe1c,0xffffffff,0x00030305,
+0x12c,0xffffffff,0x04000802,
+0x318,0x00000fff,0x00000800,
+};
+
+u32 Rtl8192PciEAGCTAB_ArrayDTM[AGCTAB_ArrayLength] = {
+0xc78,0x7d000001,
+0xc78,0x7d010001,
+0xc78,0x7d020001,
+0xc78,0x7d030001,
+0xc78,0x7d040001,
+0xc78,0x7d050001,
+0xc78,0x7c060001,
+0xc78,0x7b070001,
+0xc78,0x7a080001,
+0xc78,0x79090001,
+0xc78,0x780a0001,
+0xc78,0x770b0001,
+0xc78,0x760c0001,
+0xc78,0x750d0001,
+0xc78,0x740e0001,
+0xc78,0x730f0001,
+0xc78,0x72100001,
+0xc78,0x71110001,
+0xc78,0x70120001,
+0xc78,0x6f130001,
+0xc78,0x6e140001,
+0xc78,0x6d150001,
+0xc78,0x6c160001,
+0xc78,0x6b170001,
+0xc78,0x6a180001,
+0xc78,0x69190001,
+0xc78,0x681a0001,
+0xc78,0x671b0001,
+0xc78,0x661c0001,
+0xc78,0x651d0001,
+0xc78,0x641e0001,
+0xc78,0x491f0001,
+0xc78,0x48200001,
+0xc78,0x47210001,
+0xc78,0x46220001,
+0xc78,0x45230001,
+0xc78,0x44240001,
+0xc78,0x43250001,
+0xc78,0x28260001,
+0xc78,0x27270001,
+0xc78,0x26280001,
+0xc78,0x25290001,
+0xc78,0x242a0001,
+0xc78,0x232b0001,
+0xc78,0x222c0001,
+0xc78,0x212d0001,
+0xc78,0x202e0001,
+0xc78,0x0a2f0001,
+0xc78,0x08300001,
+0xc78,0x06310001,
+0xc78,0x05320001,
+0xc78,0x04330001,
+0xc78,0x03340001,
+0xc78,0x02350001,
+0xc78,0x01360001,
+0xc78,0x00370001,
+0xc78,0x00380001,
+0xc78,0x00390001,
+0xc78,0x003a0001,
+0xc78,0x003b0001,
+0xc78,0x003c0001,
+0xc78,0x003d0001,
+0xc78,0x003e0001,
+0xc78,0x003f0001,
+0xc78,0x7d400001,
+0xc78,0x7d410001,
+0xc78,0x7d420001,
+0xc78,0x7d430001,
+0xc78,0x7d440001,
+0xc78,0x7d450001,
+0xc78,0x7c460001,
+0xc78,0x7b470001,
+0xc78,0x7a480001,
+0xc78,0x79490001,
+0xc78,0x784a0001,
+0xc78,0x774b0001,
+0xc78,0x764c0001,
+0xc78,0x754d0001,
+0xc78,0x744e0001,
+0xc78,0x734f0001,
+0xc78,0x72500001,
+0xc78,0x71510001,
+0xc78,0x70520001,
+0xc78,0x6f530001,
+0xc78,0x6e540001,
+0xc78,0x6d550001,
+0xc78,0x6c560001,
+0xc78,0x6b570001,
+0xc78,0x6a580001,
+0xc78,0x69590001,
+0xc78,0x685a0001,
+0xc78,0x675b0001,
+0xc78,0x665c0001,
+0xc78,0x655d0001,
+0xc78,0x645e0001,
+0xc78,0x495f0001,
+0xc78,0x48600001,
+0xc78,0x47610001,
+0xc78,0x46620001,
+0xc78,0x45630001,
+0xc78,0x44640001,
+0xc78,0x43650001,
+0xc78,0x28660001,
+0xc78,0x27670001,
+0xc78,0x26680001,
+0xc78,0x25690001,
+0xc78,0x246a0001,
+0xc78,0x236b0001,
+0xc78,0x226c0001,
+0xc78,0x216d0001,
+0xc78,0x206e0001,
+0xc78,0x0a6f0001,
+0xc78,0x08700001,
+0xc78,0x06710001,
+0xc78,0x05720001,
+0xc78,0x04730001,
+0xc78,0x03740001,
+0xc78,0x02750001,
+0xc78,0x01760001,
+0xc78,0x00770001,
+0xc78,0x00780001,
+0xc78,0x00790001,
+0xc78,0x007a0001,
+0xc78,0x007b0001,
+0xc78,0x007c0001,
+0xc78,0x007d0001,
+0xc78,0x007e0001,
+0xc78,0x007f0001,
+0xc78,0x2e00001e,
+0xc78,0x2e01001e,
+0xc78,0x2e02001e,
+0xc78,0x2e03001e,
+0xc78,0x2e04001e,
+0xc78,0x2e05001e,
+0xc78,0x3006001e,
+0xc78,0x3407001e,
+0xc78,0x3908001e,
+0xc78,0x3c09001e,
+0xc78,0x3f0a001e,
+0xc78,0x420b001e,
+0xc78,0x440c001e,
+0xc78,0x450d001e,
+0xc78,0x460e001e,
+0xc78,0x460f001e,
+0xc78,0x4710001e,
+0xc78,0x4811001e,
+0xc78,0x4912001e,
+0xc78,0x4a13001e,
+0xc78,0x4b14001e,
+0xc78,0x4b15001e,
+0xc78,0x4c16001e,
+0xc78,0x4d17001e,
+0xc78,0x4e18001e,
+0xc78,0x4f19001e,
+0xc78,0x4f1a001e,
+0xc78,0x501b001e,
+0xc78,0x511c001e,
+0xc78,0x521d001e,
+0xc78,0x521e001e,
+0xc78,0x531f001e,
+0xc78,0x5320001e,
+0xc78,0x5421001e,
+0xc78,0x5522001e,
+0xc78,0x5523001e,
+0xc78,0x5624001e,
+0xc78,0x5725001e,
+0xc78,0x5726001e,
+0xc78,0x5827001e,
+0xc78,0x5828001e,
+0xc78,0x5929001e,
+0xc78,0x592a001e,
+0xc78,0x5a2b001e,
+0xc78,0x5b2c001e,
+0xc78,0x5c2d001e,
+0xc78,0x5c2e001e,
+0xc78,0x5d2f001e,
+0xc78,0x5e30001e,
+0xc78,0x5f31001e,
+0xc78,0x6032001e,
+0xc78,0x6033001e,
+0xc78,0x6134001e,
+0xc78,0x6235001e,
+0xc78,0x6336001e,
+0xc78,0x6437001e,
+0xc78,0x6438001e,
+0xc78,0x6539001e,
+0xc78,0x663a001e,
+0xc78,0x673b001e,
+0xc78,0x673c001e,
+0xc78,0x683d001e,
+0xc78,0x693e001e,
+0xc78,0x6a3f001e,
+};
+
+#endif //__INC_HAL8192PciE_FW_IMG_DTM_H
diff --git a/drivers/staging/rtl8192su/r8192S_firmware.c b/drivers/staging/rtl8192su/r8192S_firmware.c
new file mode 100644
index 000000000000..b3d69b33acba
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_firmware.c
@@ -0,0 +1,1023 @@
+/**************************************************************************************************
+ * Procedure: Init boot code/firmware code/data session
+ *
+ * Description: This routine will intialize firmware. If any error occurs during the initialization
+ * process, the routine shall terminate immediately and return fail.
+ * NIC driver should call NdisOpenFile only from MiniportInitialize.
+ *
+ * Arguments: The pointer of the adapter
+
+ * Returns:
+ * NDIS_STATUS_FAILURE - the following initialization process should be terminated
+ * NDIS_STATUS_SUCCESS - if firmware initialization process success
+**************************************************************************************************/
+//#include "ieee80211.h"
+#if defined(RTL8192SE)||defined(RTL8192SU)
+#include "r8192U.h"
+#include "r8192S_firmware.h"
+#include <linux/unistd.h>
+
+#ifdef RTL8192SU
+#include "r8192S_hw.h"
+#include "r8192SU_HWImg.h"
+//#include "r8192S_FwImgDTM.h"
+#else
+//#include "r8192U_hw.h"
+#include "r8192xU_firmware_img.h"
+#endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#include <linux/firmware.h>
+#endif
+
+#define byte(x,n) ( (x >> (8 * n)) & 0xff )
+
+//
+// Description: This routine will intialize firmware. If any error occurs during the initialization
+// process, the routine shall terminate immediately and return fail.
+//
+// Arguments: The pointer of the adapter
+// Code address (Virtual address, should fill descriptor with physical address)
+// Code size
+// Created by Roger, 2008.04.10.
+//
+bool FirmwareDownloadCode(struct net_device *dev, u8 * code_virtual_address,u32 buffer_len)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = true;
+ u16 frag_threshold = MAX_FIRMWARE_CODE_SIZE; //Fragmentation might be required in 90/92 but not in 92S
+ u16 frag_length, frag_offset = 0;
+ struct sk_buff *skb;
+ unsigned char *seg_ptr;
+ cb_desc *tcb_desc;
+ u8 bLastIniPkt = 0;
+ u16 ExtraDescOffset = 0;
+
+#ifdef RTL8192SE
+ fw_SetRQPN(dev); // For 92SE only
+#endif
+
+ RT_TRACE(COMP_FIRMWARE, "--->FirmwareDownloadCode()\n" );
+
+ //MAX_TRANSMIT_BUFFER_SIZE
+ if(buffer_len >= MAX_FIRMWARE_CODE_SIZE-USB_HWDESC_HEADER_LEN)
+ {
+ RT_TRACE(COMP_ERR, "Size over MAX_FIRMWARE_CODE_SIZE! \n");
+ goto cmdsend_downloadcode_fail;
+ }
+
+ ExtraDescOffset = USB_HWDESC_HEADER_LEN;
+
+ do {
+ if((buffer_len-frag_offset) > frag_threshold)
+ {
+ frag_length = frag_threshold + ExtraDescOffset;
+ }
+ else
+ {
+ frag_length = (u16)(buffer_len - frag_offset + ExtraDescOffset);
+ bLastIniPkt = 1;
+ }
+
+ /* Allocate skb buffer to contain firmware info and tx descriptor info. */
+ skb = dev_alloc_skb(frag_length);
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
+ tcb_desc->bLastIniPkt = bLastIniPkt;
+
+ skb_reserve(skb, ExtraDescOffset);
+ seg_ptr = (u8 *)skb_put(skb, (u32)(frag_length-ExtraDescOffset));
+ memcpy(seg_ptr, code_virtual_address+frag_offset, (u32)(frag_length-ExtraDescOffset));
+
+ tcb_desc->txbuf_size= frag_length;
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) )
+ {
+ RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ }
+ else
+ {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ frag_offset += (frag_length - ExtraDescOffset);
+
+ }while(frag_offset < buffer_len);
+
+ return rt_status ;
+
+
+cmdsend_downloadcode_fail:
+ rt_status = false;
+ RT_TRACE(COMP_ERR, "CmdSendDownloadCode fail !!\n");
+ return rt_status;
+
+}
+
+#ifdef RTL8192SE
+static void fw_SetRQPN(struct net_device *dev)
+{
+ // Only for 92SE HW bug, we have to set RAPN before every FW download
+ // We can remove the code later.
+ write_nic_dword(dev, RQPN, 0xffffffff);
+ write_nic_dword(dev, RQPN+4, 0xffffffff);
+ write_nic_byte(dev, RQPN+8, 0xff);
+ write_nic_byte(dev, RQPN+0xB, 0x80);
+ //#if ((HAL_CODE_BASE == RTL8192_S) && (PLATFORM != PLATFORM_WINDOWS_USB))
+
+} /* fw_SetRQPN */
+#endif
+
+RT_STATUS
+FirmwareEnableCPU(struct net_device *dev)
+{
+
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ u8 tmpU1b, CPUStatus = 0;
+ u16 tmpU2b;
+ u32 iCheckTime = 200;
+
+ RT_TRACE(COMP_FIRMWARE, "-->FirmwareEnableCPU()\n" );
+#ifdef RTL8192SE
+ fw_SetRQPN(dev); // For 92SE only
+#endif
+ // Enable CPU.
+ tmpU1b = read_nic_byte(dev, SYS_CLKR);
+ write_nic_byte(dev, SYS_CLKR, (tmpU1b|SYS_CPU_CLKSEL)); //AFE source
+
+ tmpU2b = read_nic_word(dev, SYS_FUNC_EN);
+ write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|FEN_CPUEN));
+
+ //Polling IMEM Ready after CPU has refilled.
+ do
+ {
+ CPUStatus = read_nic_byte(dev, TCR);
+ if(CPUStatus& IMEM_RDY)
+ {
+ RT_TRACE(COMP_FIRMWARE, "IMEM Ready after CPU has refilled.\n");
+ break;
+ }
+
+ //usleep(100);
+ udelay(100);
+ }while(iCheckTime--);
+
+ if(!(CPUStatus & IMEM_RDY))
+ return RT_STATUS_FAILURE;
+
+ RT_TRACE(COMP_FIRMWARE, "<--FirmwareEnableCPU(): rtStatus(%#x)\n", rtStatus);
+ return rtStatus;
+}
+
+FIRMWARE_8192S_STATUS
+FirmwareGetNextStatus(FIRMWARE_8192S_STATUS FWCurrentStatus)
+{
+ FIRMWARE_8192S_STATUS NextFWStatus = 0;
+
+ switch(FWCurrentStatus)
+ {
+ case FW_STATUS_INIT:
+ NextFWStatus = FW_STATUS_LOAD_IMEM;
+ break;
+
+ case FW_STATUS_LOAD_IMEM:
+ NextFWStatus = FW_STATUS_LOAD_EMEM;
+ break;
+
+ case FW_STATUS_LOAD_EMEM:
+ NextFWStatus = FW_STATUS_LOAD_DMEM;
+ break;
+
+ case FW_STATUS_LOAD_DMEM:
+ NextFWStatus = FW_STATUS_READY;
+ break;
+
+ default:
+ RT_TRACE(COMP_ERR,"Invalid FW Status(%#x)!!\n", FWCurrentStatus);
+ break;
+ }
+ return NextFWStatus;
+}
+
+bool
+FirmwareCheckReady(struct net_device *dev, u8 LoadFWStatus)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ rt_firmware *pFirmware = priv->pFirmware;
+ int PollingCnt = 1000;
+ //u8 tmpU1b, CPUStatus = 0;
+ u8 CPUStatus = 0;
+ u32 tmpU4b;
+ //bool bOrgIMREnable;
+
+ RT_TRACE(COMP_FIRMWARE, "--->FirmwareCheckReady(): LoadStaus(%d),", LoadFWStatus);
+
+ pFirmware->FWStatus = (FIRMWARE_8192S_STATUS)LoadFWStatus;
+ if( LoadFWStatus == FW_STATUS_LOAD_IMEM)
+ {
+ do
+ {//Polling IMEM code done.
+ CPUStatus = read_nic_byte(dev, TCR);
+ if(CPUStatus& IMEM_CODE_DONE)
+ break;
+
+ udelay(5);
+ }while(PollingCnt--);
+ if(!(CPUStatus & IMEM_CHK_RPT) || PollingCnt <= 0)
+ {
+ RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\r\n", CPUStatus);
+ return false;
+ }
+ }
+ else if( LoadFWStatus == FW_STATUS_LOAD_EMEM)
+ {//Check Put Code OK and Turn On CPU
+ do
+ {//Polling EMEM code done.
+ CPUStatus = read_nic_byte(dev, TCR);
+ if(CPUStatus& EMEM_CODE_DONE)
+ break;
+
+ udelay(5);
+ }while(PollingCnt--);
+ if(!(CPUStatus & EMEM_CHK_RPT))
+ {
+ RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\r\n", CPUStatus);
+ return false;
+ }
+
+ // Turn On CPU
+ rtStatus = FirmwareEnableCPU(dev);
+ if(rtStatus != RT_STATUS_SUCCESS)
+ {
+ RT_TRACE(COMP_ERR, "Enable CPU fail ! \n" );
+ return false;
+ }
+ }
+ else if( LoadFWStatus == FW_STATUS_LOAD_DMEM)
+ {
+ do
+ {//Polling DMEM code done
+ CPUStatus = read_nic_byte(dev, TCR);
+ if(CPUStatus& DMEM_CODE_DONE)
+ break;
+
+ udelay(5);
+ }while(PollingCnt--);
+
+ if(!(CPUStatus & DMEM_CODE_DONE))
+ {
+ RT_TRACE(COMP_ERR, "Polling DMEM code done fail ! CPUStatus(%#x)\n", CPUStatus);
+ return false;
+ }
+
+ RT_TRACE(COMP_FIRMWARE, "DMEM code download success, CPUStatus(%#x)\n", CPUStatus);
+
+// PollingCnt = 100; // Set polling cycle to 10ms.
+ PollingCnt = 10000; // Set polling cycle to 10ms.
+
+ do
+ {//Polling Load Firmware ready
+ CPUStatus = read_nic_byte(dev, TCR);
+ if(CPUStatus & FWRDY)
+ break;
+
+ udelay(100);
+ }while(PollingCnt--);
+
+ RT_TRACE(COMP_FIRMWARE, "Polling Load Firmware ready, CPUStatus(%x)\n", CPUStatus);
+
+ //if(!(CPUStatus & LOAD_FW_READY))
+ //if((CPUStatus & LOAD_FW_READY) != 0xff)
+ if((CPUStatus & LOAD_FW_READY) != LOAD_FW_READY)
+ {
+ RT_TRACE(COMP_ERR, "Polling Load Firmware ready fail ! CPUStatus(%x)\n", CPUStatus);
+ return false;
+ }
+
+ //
+ // <Roger_Notes> USB interface will update reserved followings parameters later!!
+ // 2008.08.28.
+ //
+#ifdef RTL8192SE
+ //write_nic_dword(dev, RQPN, 0x10101010);
+ //write_nic_byte(dev, 0xAB, 0x80);
+#endif
+
+ //
+ // <Roger_Notes> If right here, we can set TCR/RCR to desired value
+ // and config MAC lookback mode to normal mode. 2008.08.28.
+ //
+ tmpU4b = read_nic_dword(dev,TCR);
+ write_nic_dword(dev, TCR, (tmpU4b&(~TCR_ICV)));
+
+ tmpU4b = read_nic_dword(dev, RCR);
+ write_nic_dword(dev, RCR,
+ (tmpU4b|RCR_APPFCS|RCR_APP_ICV|RCR_APP_MIC));
+
+ RT_TRACE(COMP_FIRMWARE, "FirmwareCheckReady(): Current RCR settings(%#x)\n", tmpU4b);
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION) ||defined (RTL8192SU_ASIC_VERIFICATION))
+#ifdef NOT_YET //YJ,TMP
+ priv->TransmitConfig = read_nic_dword(dev, TCR);
+ RT_TRACE(COMP_FIRMWARE, "FirmwareCheckReady(): Current TCR settings(%x)\n", priv->TransmitConfig);
+ pHalData->FwRsvdTxPageCfg = read_nic_byte(dev, FW_RSVD_PG_CRTL);
+#endif
+#endif
+
+ // Set to normal mode.
+ write_nic_byte(dev, LBKMD_SEL, LBK_NORMAL);
+
+ }
+
+ RT_TRACE(COMP_FIRMWARE, "<---FirmwareCheckReady(): LoadFWStatus(%d), rtStatus(%x)\n", LoadFWStatus, rtStatus);
+ return (rtStatus == RT_STATUS_SUCCESS) ? true:false;
+}
+
+//
+// Description: This routine is to update the RF types in FW header partially.
+//
+// Created by Roger, 2008.12.24.
+//
+u8 FirmwareHeaderMapRfType(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ switch(priv->rf_type)
+ {
+ case RF_1T1R: return 0x11;
+ case RF_1T2R: return 0x12;
+ case RF_2T2R: return 0x22;
+ case RF_2T2R_GREEN: return 0x92;
+ default:
+ RT_TRACE(COMP_INIT, "Unknown RF type(%x)\n",priv->rf_type);
+ break;
+ }
+ return 0x22;
+}
+
+
+//
+// Description: This routine is to update the private parts in FW header partially.
+//
+// Created by Roger, 2008.12.18.
+//
+void FirmwareHeaderPriveUpdate(struct net_device *dev, PRT_8192S_FIRMWARE_PRIV pFwPriv)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#ifdef RTL8192SU
+ // Update USB endpoint number for RQPN settings.
+ pFwPriv->usb_ep_num = priv->EEPROMUsbEndPointNumber; // endpoint number: 4, 6 and 11.
+ RT_TRACE(COMP_INIT, "FirmwarePriveUpdate(): usb_ep_num(%#x)\n", pFwPriv->usb_ep_num);
+#endif
+
+ // Update RF types for RATR settings.
+ pFwPriv->rf_config = FirmwareHeaderMapRfType(dev);
+}
+
+
+
+bool FirmwareDownload92S(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rtStatus = true;
+ const char *pFwImageFileName[1] = {"RTL8192SU/rtl8192sfw.bin"};
+ u8 *pucMappedFile = NULL;
+ u32 ulFileLength, ulInitStep = 0;
+ u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE;
+ rt_firmware *pFirmware = priv->pFirmware;
+ u8 FwStatus = FW_STATUS_INIT;
+ PRT_8192S_FIRMWARE_HDR pFwHdr = NULL;
+ PRT_8192S_FIRMWARE_PRIV pFwPriv = NULL;
+ int rc;
+ const struct firmware *fw_entry;
+ u32 file_length = 0;
+
+ pFirmware->FWStatus = FW_STATUS_INIT;
+
+ RT_TRACE(COMP_FIRMWARE, " --->FirmwareDownload92S()\n");
+
+ //3//
+ //3 //<1> Open Image file, and map file to contineous memory if open file success.
+ //3 // or read image file from array. Default load from BIN file
+ //3//
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ priv->firmware_source = FW_SOURCE_HEADER_FILE;
+#else
+ priv->firmware_source = FW_SOURCE_IMG_FILE;// We should decided by Reg.
+#endif
+
+ switch( priv->firmware_source )
+ {
+ case FW_SOURCE_IMG_FILE:
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ if(pFirmware->szFwTmpBufferLen == 0)
+ {
+
+ rc = request_firmware(&fw_entry, pFwImageFileName[ulInitStep],&priv->udev->dev);//===>1
+ if(rc < 0 ) {
+ RT_TRACE(COMP_ERR, "request firmware fail!\n");
+ goto DownloadFirmware_Fail;
+ }
+
+ if(fw_entry->size > sizeof(pFirmware->szFwTmpBuffer))
+ {
+ RT_TRACE(COMP_ERR, "img file size exceed the container buffer fail!\n");
+ release_firmware(fw_entry);
+ goto DownloadFirmware_Fail;
+ }
+
+ memcpy(pFirmware->szFwTmpBuffer,fw_entry->data,fw_entry->size);
+ pFirmware->szFwTmpBufferLen = fw_entry->size;
+ release_firmware(fw_entry);
+
+ pucMappedFile = pFirmware->szFwTmpBuffer;
+ file_length = pFirmware->szFwTmpBufferLen;
+
+ //Retrieve FW header.
+ pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile;
+ pFwHdr = pFirmware->pFwHeader;
+ RT_TRACE(COMP_FIRMWARE,"signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", \
+ pFwHdr->Signature, pFwHdr->Version, pFwHdr->DMEMSize, \
+ pFwHdr->IMG_IMEM_SIZE, pFwHdr->IMG_SRAM_SIZE);
+ pFirmware->FirmwareVersion = byte(pFwHdr->Version ,0);
+ if ((pFwHdr->IMG_IMEM_SIZE==0) || (pFwHdr->IMG_IMEM_SIZE > sizeof(pFirmware->FwIMEM)))
+ {
+ RT_TRACE(COMP_ERR, "%s: memory for data image is less than IMEM required\n",\
+ __FUNCTION__);
+ goto DownloadFirmware_Fail;
+ } else {
+ pucMappedFile+=FwHdrSize;
+
+ //Retrieve IMEM image.
+ memcpy(pFirmware->FwIMEM, pucMappedFile, pFwHdr->IMG_IMEM_SIZE);
+ pFirmware->FwIMEMLen = pFwHdr->IMG_IMEM_SIZE;
+ }
+
+ if (pFwHdr->IMG_SRAM_SIZE > sizeof(pFirmware->FwEMEM))
+ {
+ RT_TRACE(COMP_ERR, "%s: memory for data image is less than EMEM required\n",\
+ __FUNCTION__);
+ goto DownloadFirmware_Fail;
+ } else {
+ pucMappedFile += pFirmware->FwIMEMLen;
+
+ /* Retriecve EMEM image */
+ memcpy(pFirmware->FwEMEM, pucMappedFile, pFwHdr->IMG_SRAM_SIZE);//===>6
+ pFirmware->FwEMEMLen = pFwHdr->IMG_SRAM_SIZE;
+ }
+
+
+ }
+#endif
+ break;
+
+ case FW_SOURCE_HEADER_FILE:
+#if 1
+#define Rtl819XFwImageArray Rtl8192SUFwImgArray
+ //2008.11.10 Add by tynli.
+ pucMappedFile = Rtl819XFwImageArray;
+ ulFileLength = ImgArrayLength;
+
+ RT_TRACE(COMP_INIT,"Fw download from header.\n");
+ /* Retrieve FW header*/
+ pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile;
+ pFwHdr = pFirmware->pFwHeader;
+ RT_TRACE(COMP_FIRMWARE,"signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", \
+ pFwHdr->Signature, pFwHdr->Version, pFwHdr->DMEMSize, \
+ pFwHdr->IMG_IMEM_SIZE, pFwHdr->IMG_SRAM_SIZE);
+ pFirmware->FirmwareVersion = byte(pFwHdr->Version ,0);
+
+ if ((pFwHdr->IMG_IMEM_SIZE==0) || (pFwHdr->IMG_IMEM_SIZE > sizeof(pFirmware->FwIMEM)))
+ {
+ printk("FirmwareDownload92S(): memory for data image is less than IMEM required\n");
+ goto DownloadFirmware_Fail;
+ } else {
+ pucMappedFile+=FwHdrSize;
+ //Retrieve IMEM image.
+ memcpy(pFirmware->FwIMEM, pucMappedFile, pFwHdr->IMG_IMEM_SIZE);
+ pFirmware->FwIMEMLen = pFwHdr->IMG_IMEM_SIZE;
+ }
+
+ if (pFwHdr->IMG_SRAM_SIZE > sizeof(pFirmware->FwEMEM))
+ {
+ printk(" FirmwareDownload92S(): memory for data image is less than EMEM required\n");
+ goto DownloadFirmware_Fail;
+ } else {
+ pucMappedFile+= pFirmware->FwIMEMLen;
+
+ //Retriecve EMEM image.
+ memcpy(pFirmware->FwEMEM, pucMappedFile, pFwHdr->IMG_SRAM_SIZE);
+ pFirmware->FwEMEMLen = pFwHdr->IMG_SRAM_SIZE;
+ }
+#endif
+ break;
+ default:
+ break;
+ }
+
+ FwStatus = FirmwareGetNextStatus(pFirmware->FWStatus);
+ while(FwStatus!= FW_STATUS_READY)
+ {
+ // Image buffer redirection.
+ switch(FwStatus)
+ {
+ case FW_STATUS_LOAD_IMEM:
+ pucMappedFile = pFirmware->FwIMEM;
+ ulFileLength = pFirmware->FwIMEMLen;
+ break;
+
+ case FW_STATUS_LOAD_EMEM:
+ pucMappedFile = pFirmware->FwEMEM;
+ ulFileLength = pFirmware->FwEMEMLen;
+ break;
+
+ case FW_STATUS_LOAD_DMEM:
+ /* <Roger_Notes> Partial update the content of header private. 2008.12.18 */
+ pFwHdr = pFirmware->pFwHeader;
+ pFwPriv = (PRT_8192S_FIRMWARE_PRIV)&pFwHdr->FWPriv;
+ FirmwareHeaderPriveUpdate(dev, pFwPriv);
+ pucMappedFile = (u8*)(pFirmware->pFwHeader)+RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE;
+ ulFileLength = FwHdrSize-RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE;
+ break;
+
+ default:
+ RT_TRACE(COMP_ERR, "Unexpected Download step!!\n");
+ goto DownloadFirmware_Fail;
+ break;
+ }
+
+ //3//
+ //3// <2> Download image file
+ //3 //
+ rtStatus = FirmwareDownloadCode(dev, pucMappedFile, ulFileLength);
+
+ if(rtStatus != true)
+ {
+ RT_TRACE(COMP_ERR, "FirmwareDownloadCode() fail ! \n" );
+ goto DownloadFirmware_Fail;
+ }
+
+ //3//
+ //3// <3> Check whether load FW process is ready
+ //3 //
+ rtStatus = FirmwareCheckReady(dev, FwStatus);
+
+ if(rtStatus != true)
+ {
+ RT_TRACE(COMP_ERR, "FirmwareDownloadCode() fail ! \n");
+ goto DownloadFirmware_Fail;
+ }
+
+ FwStatus = FirmwareGetNextStatus(pFirmware->FWStatus);
+ }
+
+ RT_TRACE(COMP_FIRMWARE, "Firmware Download Success!!\n");
+ return rtStatus;
+
+ DownloadFirmware_Fail:
+ RT_TRACE(COMP_ERR, "Firmware Download Fail!!%x\n",read_nic_word(dev, TCR));
+ rtStatus = false;
+ return rtStatus;
+}
+#else
+void firmware_init_param(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ rt_firmware *pfirmware = priv->pFirmware;
+
+ pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE);
+}
+
+/*
+ * segment the img and use the ptr and length to remember info on each segment
+ *
+ */
+bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = true;
+ //u16 frag_threshold;
+ u16 frag_length, frag_offset = 0;
+ //u16 total_size;
+ int i;
+
+ //rt_firmware *pfirmware = priv->pFirmware;
+ struct sk_buff *skb;
+ unsigned char *seg_ptr;
+ cb_desc *tcb_desc;
+ u8 bLastIniPkt;
+#ifdef RTL8192SE
+ fw_SetRQPN(dev); // For 92SE only
+#endif
+
+#ifndef RTL8192SU
+ if(buffer_len >= 64000-USB_HWDESC_HEADER_LEN)
+ {
+ return rt_status;
+ }
+ firmware_init_param(dev);
+ //Fragmentation might be required
+ frag_threshold = pfirmware->cmdpacket_frag_thresold;
+#endif
+
+ do {
+#ifndef RTL8192SU
+ if((buffer_len - frag_offset) > frag_threshold) {
+ frag_length = frag_threshold ;
+ bLastIniPkt = 0;
+
+ } else
+#endif
+ {
+ frag_length = buffer_len - frag_offset;
+ bLastIniPkt = 1;
+
+ }
+
+ /* Allocate skb buffer to contain firmware info and tx descriptor info
+ * add 4 to avoid packet appending overflow.
+ * */
+ #ifdef RTL8192U
+ skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4);
+ #else
+ skb = dev_alloc_skb(frag_length + 4);
+ #endif
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
+ tcb_desc->bLastIniPkt = bLastIniPkt;
+
+ #ifdef RTL8192U
+ skb_reserve(skb, USB_HWDESC_HEADER_LEN);
+ #endif
+ seg_ptr = skb->data;
+ /*
+ * Transform from little endian to big endian
+ * and pending zero
+ */
+ for(i=0 ; i < frag_length; i+=4) {
+ *seg_ptr++ = ((i+0)<frag_length)?code_virtual_address[i+3]:0;
+ *seg_ptr++ = ((i+1)<frag_length)?code_virtual_address[i+2]:0;
+ *seg_ptr++ = ((i+2)<frag_length)?code_virtual_address[i+1]:0;
+ *seg_ptr++ = ((i+3)<frag_length)?code_virtual_address[i+0]:0;
+ }
+ tcb_desc->txbuf_size= (u16)i;
+ skb_put(skb, i);
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) ) {
+ RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ code_virtual_address += frag_length;
+ frag_offset += frag_length;
+
+ }while(frag_offset < buffer_len);
+
+ return rt_status;
+
+#if 0
+cmdsend_downloadcode_fail:
+ rt_status = false;
+ RT_TRACE(COMP_ERR, "CmdSendDownloadCode fail !!\n");
+ return rt_status;
+#endif
+}
+
+bool
+fwSendNullPacket(
+ struct net_device *dev,
+ u32 Length
+)
+{
+ bool rtStatus = true;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct sk_buff *skb;
+ cb_desc *tcb_desc;
+ unsigned char *ptr_buf;
+ bool bLastInitPacket = false;
+
+ //PlatformAcquireSpinLock(dev, RT_TX_SPINLOCK);
+
+ //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ)
+ skb = dev_alloc_skb(Length+ 4);
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
+ tcb_desc->bLastIniPkt = bLastInitPacket;
+ ptr_buf = skb_put(skb, Length);
+ memset(ptr_buf,0,Length);
+ tcb_desc->txbuf_size= (u16)Length;
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) ) {
+ RT_TRACE(COMP_FIRMWARE,"===================NULL packet==================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ //PlatformReleaseSpinLock(dev, RT_TX_SPINLOCK);
+ return rtStatus;
+}
+
+//-----------------------------------------------------------------------------
+// Procedure: Check whether main code is download OK. If OK, turn on CPU
+//
+// Description: CPU register locates in different page against general register.
+// Switch to CPU register in the begin and switch back before return
+//
+//
+// Arguments: The pointer of the dev
+//
+// Returns:
+// NDIS_STATUS_FAILURE - the following initialization process should be terminated
+// NDIS_STATUS_SUCCESS - if firmware initialization process success
+//-----------------------------------------------------------------------------
+bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
+{
+ bool rt_status = true;
+ int check_putcodeOK_time = 200000, check_bootOk_time = 200000;
+ u32 CPU_status = 0;
+
+ /* Check whether put code OK */
+ do {
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+
+ if(CPU_status&CPU_GEN_PUT_CODE_OK)
+ break;
+
+ }while(check_putcodeOK_time--);
+
+ if(!(CPU_status&CPU_GEN_PUT_CODE_OK)) {
+ RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n");
+ goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
+ } else {
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n");
+ }
+
+ /* Turn On CPU */
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+ write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff));
+ mdelay(1000);
+
+ /* Check whether CPU boot OK */
+ do {
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+
+ if(CPU_status&CPU_GEN_BOOT_RDY)
+ break;
+ }while(check_bootOk_time--);
+
+ if(!(CPU_status&CPU_GEN_BOOT_RDY)) {
+ goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
+ } else {
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n");
+ }
+
+ return rt_status;
+
+CPUCheckMainCodeOKAndTurnOnCPU_Fail:
+ RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__);
+ rt_status = FALSE;
+ return rt_status;
+}
+
+bool CPUcheck_firmware_ready(struct net_device *dev)
+{
+
+ bool rt_status = true;
+ int check_time = 200000;
+ u32 CPU_status = 0;
+
+ /* Check Firmware Ready */
+ do {
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+
+ if(CPU_status&CPU_GEN_FIRM_RDY)
+ break;
+
+ }while(check_time--);
+
+ if(!(CPU_status&CPU_GEN_FIRM_RDY))
+ goto CPUCheckFirmwareReady_Fail;
+ else
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Firmware ready!\n");
+
+ return rt_status;
+
+CPUCheckFirmwareReady_Fail:
+ RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__);
+ rt_status = false;
+ return rt_status;
+
+}
+
+bool init_firmware(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = TRUE;
+
+ u8 *firmware_img_buf[3] = { &rtl8190_fwboot_array[0],
+ &rtl8190_fwmain_array[0],
+ &rtl8190_fwdata_array[0]};
+
+ u32 firmware_img_len[3] = { sizeof(rtl8190_fwboot_array),
+ sizeof(rtl8190_fwmain_array),
+ sizeof(rtl8190_fwdata_array)};
+ u32 file_length = 0;
+ u8 *mapped_file = NULL;
+ u32 init_step = 0;
+ opt_rst_type_e rst_opt = OPT_SYSTEM_RESET;
+ firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT;
+
+ rt_firmware *pfirmware = priv->pFirmware;
+ const struct firmware *fw_entry;
+ const char *fw_name[3] = { "RTL8192U/boot.img",
+ "RTL8192U/main.img",
+ "RTL8192U/data.img"};
+ int rc;
+
+ RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n");
+
+ if (pfirmware->firmware_status == FW_STATUS_0_INIT ) {
+ /* it is called by reset */
+ rst_opt = OPT_SYSTEM_RESET;
+ starting_state = FW_INIT_STEP0_BOOT;
+ // TODO: system reset
+
+ }else if(pfirmware->firmware_status == FW_STATUS_5_READY) {
+ /* it is called by Initialize */
+ rst_opt = OPT_FIRMWARE_RESET;
+ starting_state = FW_INIT_STEP2_DATA;
+ }else {
+ RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n");
+ }
+
+ /*
+ * Download boot, main, and data image for System reset.
+ * Download data image for firmware reseta
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ priv->firmware_source = FW_SOURCE_HEADER_FILE;
+#else
+ priv->firmware_source = FW_SOURCE_IMG_FILE;
+#endif
+ for(init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) {
+ /*
+ * Open Image file, and map file to contineous memory if open file success.
+ * or read image file from array. Default load from IMG file
+ */
+ if(rst_opt == OPT_SYSTEM_RESET) {
+ switch(priv->firmware_source) {
+ case FW_SOURCE_IMG_FILE:
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ rc = request_firmware(&fw_entry, fw_name[init_step],&priv->udev->dev);
+ if(rc < 0 ) {
+ RT_TRACE(COMP_ERR, "request firmware fail!\n");
+ goto download_firmware_fail;
+ }
+
+ if(fw_entry->size > sizeof(pfirmware->firmware_buf)) {
+ RT_TRACE(COMP_ERR, "img file size exceed the container buffer fail!\n");
+ goto download_firmware_fail;
+ }
+
+ if(init_step != FW_INIT_STEP1_MAIN) {
+ memcpy(pfirmware->firmware_buf,fw_entry->data,fw_entry->size);
+ mapped_file = pfirmware->firmware_buf;
+ file_length = fw_entry->size;
+ } else {
+ #ifdef RTL8190P
+ memcpy(pfirmware->firmware_buf,fw_entry->data,fw_entry->size);
+ mapped_file = pfirmware->firmware_buf;
+ file_length = fw_entry->size;
+ #else
+ memset(pfirmware->firmware_buf,0,128);
+ memcpy(&pfirmware->firmware_buf[128],fw_entry->data,fw_entry->size);
+ mapped_file = pfirmware->firmware_buf;
+ file_length = fw_entry->size + 128;
+ #endif
+ }
+ pfirmware->firmware_buf_size = file_length;
+ #endif
+ break;
+
+ case FW_SOURCE_HEADER_FILE:
+ mapped_file = firmware_img_buf[init_step];
+ file_length = firmware_img_len[init_step];
+ if(init_step == FW_INIT_STEP2_DATA) {
+ memcpy(pfirmware->firmware_buf, mapped_file, file_length);
+ pfirmware->firmware_buf_size = file_length;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+
+ }else if(rst_opt == OPT_FIRMWARE_RESET ) {
+ /* we only need to download data.img here */
+ mapped_file = pfirmware->firmware_buf;
+ file_length = pfirmware->firmware_buf_size;
+ }
+
+ /* Download image file */
+ /* The firmware download process is just as following,
+ * 1. that is each packet will be segmented and inserted to the wait queue.
+ * 2. each packet segment will be put in the skb_buff packet.
+ * 3. each skb_buff packet data content will already include the firmware info
+ * and Tx descriptor info
+ * */
+ rt_status = fw_download_code(dev,mapped_file,file_length);
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ if(rst_opt == OPT_SYSTEM_RESET) {
+ release_firmware(fw_entry);
+ }
+ #endif
+
+ if(rt_status != TRUE) {
+ goto download_firmware_fail;
+ }
+
+ switch(init_step) {
+ case FW_INIT_STEP0_BOOT:
+ /* Download boot
+ * initialize command descriptor.
+ * will set polling bit when firmware code is also configured
+ */
+ pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE;
+#ifdef RTL8190P
+ // To initialize IMEM, CPU move code from 0x80000080, hence, we send 0x80 byte packet
+ rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET);
+ if(rt_status != true)
+ {
+ RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n");
+ goto download_firmware_fail;
+ }
+#endif
+ //mdelay(1000);
+ /*
+ * To initialize IMEM, CPU move code from 0x80000080,
+ * hence, we send 0x80 byte packet
+ */
+ break;
+
+ case FW_INIT_STEP1_MAIN:
+ /* Download firmware code. Wait until Boot Ready and Turn on CPU */
+ pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE;
+
+ /* Check Put Code OK and Turn On CPU */
+ rt_status = CPUcheck_maincodeok_turnonCPU(dev);
+ if(rt_status != TRUE) {
+ RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n");
+ goto download_firmware_fail;
+ }
+
+ pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU;
+ break;
+
+ case FW_INIT_STEP2_DATA:
+ /* download initial data code */
+ pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE;
+ mdelay(1);
+
+ rt_status = CPUcheck_firmware_ready(dev);
+ if(rt_status != TRUE) {
+ RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status);
+ goto download_firmware_fail;
+ }
+
+ /* wait until data code is initialized ready.*/
+ pfirmware->firmware_status = FW_STATUS_5_READY;
+ break;
+ }
+ }
+
+ RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n");
+ //assert(pfirmware->firmware_status == FW_STATUS_5_READY, ("Firmware Download Fail\n"));
+
+ return rt_status;
+
+download_firmware_fail:
+ RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__);
+ rt_status = FALSE;
+ return rt_status;
+
+}
+#endif
+
diff --git a/drivers/staging/rtl8192su/r8192S_firmware.h b/drivers/staging/rtl8192su/r8192S_firmware.h
new file mode 100644
index 000000000000..047f8ae44740
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_firmware.h
@@ -0,0 +1,212 @@
+#ifndef __INC_FIRMWARE_H
+#define __INC_FIRMWARE_H
+
+
+//#define RTL8190_CPU_START_OFFSET 0x80
+/* TODO: this definition is TBD */
+//#define USB_HWDESC_HEADER_LEN 0
+
+/* It should be double word alignment */
+//#if DEV_BUS_TYPE==PCI_INTERFACE
+//#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) 4*(v/4) - 8
+//#else
+//#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN)
+//#endif
+
+//typedef enum _firmware_init_step{
+// FW_INIT_STEP0_BOOT = 0,
+// FW_INIT_STEP1_MAIN = 1,
+// FW_INIT_STEP2_DATA = 2,
+//}firmware_init_step_e;
+
+//typedef enum _DESC_PACKET_TYPE{
+// DESC_PACKET_TYPE_INIT = 0,
+// DESC_PACKET_TYPE_NORMAL = 1,
+//}DESC_PACKET_TYPE;
+#define RTL8192S_FW_PKT_FRAG_SIZE 0xFF00 // 64K
+
+
+#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
+#define MAX_FIRMWARE_CODE_SIZE 0xFF00 // Firmware Local buffer size.
+#define RTL8190_CPU_START_OFFSET 0x80
+
+#ifdef RTL8192SE
+//It should be double word alignment
+#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) 4*(v/4) - 8
+#else
+#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN)
+#endif
+
+//typedef enum _DESC_PACKET_TYPE{
+// DESC_PACKET_TYPE_INIT = 0,
+// DESC_PACKET_TYPE_NORMAL = 1,
+//}DESC_PACKET_TYPE;
+
+// Forward declaration.
+//typedef struct _ADAPTER ADAPTER, *PADAPTER;
+#ifdef RTL8192S
+typedef enum _firmware_init_step{
+ FW_INIT_STEP0_IMEM = 0,
+ FW_INIT_STEP1_MAIN = 1,
+ FW_INIT_STEP2_DATA = 2,
+}firmware_init_step_e;
+#else
+typedef enum _firmware_init_step{
+ FW_INIT_STEP0_BOOT = 0,
+ FW_INIT_STEP1_MAIN = 1,
+ FW_INIT_STEP2_DATA = 2,
+}firmware_init_step_e;
+#endif
+
+/* due to rtl8192 firmware */
+typedef enum _desc_packet_type_e{
+ DESC_PACKET_TYPE_INIT = 0,
+ DESC_PACKET_TYPE_NORMAL = 1,
+}desc_packet_type_e;
+
+typedef enum _firmware_source{
+ FW_SOURCE_IMG_FILE = 0,
+ FW_SOURCE_HEADER_FILE = 1,
+}firmware_source_e, *pfirmware_source_e;
+
+
+typedef enum _opt_rst_type{
+ OPT_SYSTEM_RESET = 0,
+ OPT_FIRMWARE_RESET = 1,
+}opt_rst_type_e;
+
+/*typedef enum _FIRMWARE_STATUS{
+ FW_STATUS_0_INIT = 0,
+ FW_STATUS_1_MOVE_BOOT_CODE = 1,
+ FW_STATUS_2_MOVE_MAIN_CODE = 2,
+ FW_STATUS_3_TURNON_CPU = 3,
+ FW_STATUS_4_MOVE_DATA_CODE = 4,
+ FW_STATUS_5_READY = 5,
+}FIRMWARE_STATUS;
+*/
+//--------------------------------------------------------------------------------
+// RTL8192S Firmware related, Revised by Roger, 2008.12.18.
+//--------------------------------------------------------------------------------
+typedef struct _RT_8192S_FIRMWARE_PRIV { //8-bytes alignment required
+
+ //--- long word 0 ----
+ u8 signature_0; //0x12: CE product, 0x92: IT product
+ u8 signature_1; //0x87: CE product, 0x81: IT product
+ u8 hci_sel; //0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP, 0x12: 72S-U, 03:SDIO
+ u8 chip_version; //the same value as reigster value
+ u8 customer_ID_0; //customer ID low byte
+ u8 customer_ID_1; //customer ID high byte
+ u8 rf_config; //0x11: 1T1R, 0x12: 1T2R, 0x92: 1T2R turbo, 0x22: 2T2R
+ u8 usb_ep_num; // 4: 4EP, 6: 6EP, 11: 11EP
+
+ //--- long word 1 ----
+ u8 regulatory_class_0; //regulatory class bit map 0
+ u8 regulatory_class_1; //regulatory class bit map 1
+ u8 regulatory_class_2; //regulatory class bit map 2
+ u8 regulatory_class_3; //regulatory class bit map 3
+ u8 rfintfs; // 0:SWSI, 1:HWSI, 2:HWPI
+ u8 def_nettype;
+ u8 rsvd010;
+ u8 rsvd011;
+
+
+ //--- long word 2 ----
+ u8 lbk_mode; //0x00: normal, 0x03: MACLBK, 0x01: PHYLBK
+ u8 mp_mode; // 1: for MP use, 0: for normal driver (to be discussed)
+ u8 rsvd020;
+ u8 rsvd021;
+ u8 rsvd022;
+ u8 rsvd023;
+ u8 rsvd024;
+ u8 rsvd025;
+
+ //--- long word 3 ----
+ u8 qos_en; // QoS enable
+ u8 bw_40MHz_en; // 40MHz BW enable
+ u8 AMSDU2AMPDU_en; // 4181 convert AMSDU to AMPDU, 0: disable
+ u8 AMPDU_en; // 11n AMPDU enable
+ u8 rate_control_offload;//FW offloads, 0: driver handles
+ u8 aggregation_offload; // FW offloads, 0: driver handles
+ u8 rsvd030;
+ u8 rsvd031;
+
+
+ //--- long word 4 ----
+ unsigned char beacon_offload; // 1. FW offloads, 0: driver handles
+ unsigned char MLME_offload; // 2. FW offloads, 0: driver handles
+ unsigned char hwpc_offload; // 3. FW offloads, 0: driver handles
+ unsigned char tcp_checksum_offload; // 4. FW offloads, 0: driver handles
+ unsigned char tcp_offload; // 5. FW offloads, 0: driver handles
+ unsigned char ps_control_offload; // 6. FW offloads, 0: driver handles
+ unsigned char WWLAN_offload; // 7. FW offloads, 0: driver handles
+ unsigned char rsvd040;
+
+ //--- long word 5 ----
+ u8 tcp_tx_frame_len_L; //tcp tx packet length low byte
+ u8 tcp_tx_frame_len_H; //tcp tx packet length high byte
+ u8 tcp_rx_frame_len_L; //tcp rx packet length low byte
+ u8 tcp_rx_frame_len_H; //tcp rx packet length high byte
+ u8 rsvd050;
+ u8 rsvd051;
+ u8 rsvd052;
+ u8 rsvd053;
+}RT_8192S_FIRMWARE_PRIV, *PRT_8192S_FIRMWARE_PRIV;
+
+typedef struct _RT_8192S_FIRMWARE_HDR {//8-byte alinment required
+
+ //--- LONG WORD 0 ----
+ u16 Signature;
+ u16 Version; //0x8000 ~ 0x8FFF for FPGA version, 0x0000 ~ 0x7FFF for ASIC version,
+ u32 DMEMSize; //define the size of boot loader
+
+
+ //--- LONG WORD 1 ----
+ u32 IMG_IMEM_SIZE; //define the size of FW in IMEM
+ u32 IMG_SRAM_SIZE; //define the size of FW in SRAM
+
+ //--- LONG WORD 2 ----
+ u32 FW_PRIV_SIZE; //define the size of DMEM variable
+ u32 Rsvd0;
+
+ //--- LONG WORD 3 ----
+ u32 Rsvd1;
+ u32 Rsvd2;
+
+ RT_8192S_FIRMWARE_PRIV FWPriv;
+
+}RT_8192S_FIRMWARE_HDR, *PRT_8192S_FIRMWARE_HDR;
+
+#define RT_8192S_FIRMWARE_HDR_SIZE 80
+#define RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE 32
+
+typedef enum _FIRMWARE_8192S_STATUS{
+ FW_STATUS_INIT = 0,
+ FW_STATUS_LOAD_IMEM = 1,
+ FW_STATUS_LOAD_EMEM = 2,
+ FW_STATUS_LOAD_DMEM = 3,
+ FW_STATUS_READY = 4,
+}FIRMWARE_8192S_STATUS;
+
+#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
+
+typedef struct _rt_firmware{
+ firmware_source_e eFWSource;
+ PRT_8192S_FIRMWARE_HDR pFwHeader;
+ FIRMWARE_8192S_STATUS FWStatus;
+ u16 FirmwareVersion;
+ u8 FwIMEM[RTL8190_MAX_FIRMWARE_CODE_SIZE];
+ u8 FwEMEM[RTL8190_MAX_FIRMWARE_CODE_SIZE];
+ u32 FwIMEMLen;
+ u32 FwEMEMLen;
+ u8 szFwTmpBuffer[164000];
+ u32 szFwTmpBufferLen;
+ u16 CmdPacketFragThresold;
+}rt_firmware, *prt_firmware;
+
+//typedef struct _RT_FIRMWARE_INFO_8192SU{
+// u8 szInfo[16];
+//}RT_FIRMWARE_INFO_8192SU, *PRT_FIRMWARE_INFO_8192SU;
+bool FirmwareDownload92S(struct net_device *dev);
+
+#endif
+
diff --git a/drivers/staging/rtl8192su/r8192S_hw.h b/drivers/staging/rtl8192su/r8192S_hw.h
new file mode 100644
index 000000000000..7a3d850de0bf
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_hw.h
@@ -0,0 +1,1677 @@
+/*****************************************************************************
+ * Copyright(c) 2008, RealTEK Technology Inc. All Right Reserved.
+ *
+ * Module: __INC_HAL8192SEREG_H
+ *
+ *
+ * Note: 1. Define Mac register address and corresponding bit mask map
+ * 2. CCX register
+ * 3. Backward compatible register with useless address.
+ * 4. Define 92SU required register address and definition.
+ *
+ *
+ * Export: Constants, macro, functions(API), global variables(None).
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
+ * 2. Reorganize code architecture.
+ *
+ *****************************************************************************/
+#ifndef R8192S_HW
+#define R8192S_HW
+
+typedef enum _VERSION_8192S{
+ VERSION_8192S_ACUT,
+ VERSION_8192S_BCUT,
+ VERSION_8192S_CCUT
+}VERSION_8192S,*PVERSION_8192S;
+
+//#ifdef RTL8192SU
+typedef enum _VERSION_8192SUsb{
+ VERSION_8192SU_A, //A-Cut
+ VERSION_8192SU_B, //B-Cut
+ VERSION_8192SU_C, //C-Cut
+}VERSION_8192SUsb, *PVERSION_8192SUsb;
+//#else
+typedef enum _VERSION_819xU{
+ VERSION_819xU_A, // A-cut
+ VERSION_819xU_B, // B-cut
+ VERSION_819xU_C,// C-cut
+}VERSION_819xU,*PVERSION_819xU;
+//#endif
+
+/* 2007/11/15 MH Define different RF type. */
+typedef enum _RT_RF_TYPE_DEFINITION
+{
+ RF_1T2R = 0,
+ RF_2T4R,
+ RF_2T2R,
+#ifdef RTL8192SU
+ RF_1T1R,
+ RF_2T2R_GREEN,
+#endif
+ //RF_3T3R,
+ //RF_3T4R,
+ //RF_4T4R,
+ RF_819X_MAX_TYPE
+}RT_RF_TYPE_DEF_E;
+
+typedef enum _BaseBand_Config_Type{
+ BaseBand_Config_PHY_REG = 0, //Radio Path A
+ BaseBand_Config_AGC_TAB = 1, //Radio Path B
+}BaseBand_Config_Type, *PBaseBand_Config_Type;
+
+#if 0
+typedef enum _RT_RF_TYPE_819xU{
+ RF_TYPE_MIN = 0,
+ RF_8225,
+ RF_8256,
+ RF_8258,
+ RF_PSEUDO_11N = 4,
+}RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
+#endif
+
+#define RTL8187_REQT_READ 0xc0
+#define RTL8187_REQT_WRITE 0x40
+#define RTL8187_REQ_GET_REGS 0x05
+#define RTL8187_REQ_SET_REGS 0x05
+
+#define MAX_TX_URB 5
+#define MAX_RX_URB 16
+
+#define R8180_MAX_RETRY 255
+//#define MAX_RX_NORMAL_URB 3
+//#define MAX_RX_COMMAND_URB 2
+#define RX_URB_SIZE 9100
+
+#define BB_ANTATTEN_CHAN14 0x0c
+#define BB_ANTENNA_B 0x40
+
+#define BB_HOST_BANG (1<<30)
+#define BB_HOST_BANG_EN (1<<2)
+#define BB_HOST_BANG_CLK (1<<1)
+#define BB_HOST_BANG_RW (1<<3)
+#define BB_HOST_BANG_DATA 1
+
+
+//============================================================
+// 8192S Regsiter bit
+//============================================================
+#define BB_GLOBAL_RESET_BIT 0x1
+
+#define CR_RST 0x10
+#define CR_RE 0x08
+#define CR_TE 0x04
+#define CR_MulRW 0x01
+
+#define MAC_FILTER_MASK ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<5) | \
+ (1<<12) | (1<<18) | (1<<19) | (1<<20) | (1<<21) | (1<<22) | (1<<23))
+
+#define RX_FIFO_THRESHOLD_MASK ((1<<13) | (1<<14) | (1<<15))
+#define RX_FIFO_THRESHOLD_SHIFT 13
+#define RX_FIFO_THRESHOLD_128 3
+#define RX_FIFO_THRESHOLD_256 4
+#define RX_FIFO_THRESHOLD_512 5
+#define RX_FIFO_THRESHOLD_1024 6
+#define RX_FIFO_THRESHOLD_NONE 7
+
+#define MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10))
+
+//----------------------------------------------------------------------------
+// 8190 CPU General Register (offset 0x100, 4 byte)
+//----------------------------------------------------------------------------
+#define CPU_CCK_LOOPBACK 0x00030000
+#define CPU_GEN_SYSTEM_RESET 0x00000001
+#define CPU_GEN_FIRMWARE_RESET 0x00000008
+#define CPU_GEN_BOOT_RDY 0x00000010
+#define CPU_GEN_FIRM_RDY 0x00000020
+#define CPU_GEN_PUT_CODE_OK 0x00000080
+#define CPU_GEN_BB_RST 0x00000100
+#define CPU_GEN_PWR_STB_CPU 0x00000004
+#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19
+#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1
+//----------------------------------------------------------------------------
+////
+//// 8190 AcmHwCtrl bits (offset 0x171, 1 byte)
+////----------------------------------------------------------------------------
+#define MSR_LINK_MASK ((1<<0)|(1<<1))
+#define MSR_LINK_MANAGED 2
+#define MSR_LINK_NONE 0
+#define MSR_LINK_SHIFT 0
+#define MSR_LINK_ADHOC 1
+#define MSR_LINK_MASTER 3
+#define MSR_LINK_ENEDCA (1<<4)
+
+
+//#define Cmd9346CR_9356SEL (1<<4)
+#define EPROM_CMD_RESERVED_MASK (1<<5)
+#define EPROM_CMD_OPERATING_MODE_SHIFT 6
+#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6))
+#define EPROM_CMD_CONFIG 0x3
+#define EPROM_CMD_NORMAL 0
+#define EPROM_CMD_LOAD 1
+#define EPROM_CMD_PROGRAM 2
+#define EPROM_CS_SHIFT 3
+#define EPROM_CK_SHIFT 2
+#define EPROM_W_SHIFT 1
+#define EPROM_R_SHIFT 0
+
+//#define MAC0 0x000,
+//#define MAC1 0x001,
+//#define MAC2 0x002,
+//#define MAC3 0x003,
+//#define MAC4 0x004,
+//#define MAC5 0x005,
+
+//============================================================
+// 8192S Regsiter offset definition
+//============================================================
+
+//
+// MAC register 0x0 - 0x5xx
+// 1. System configuration registers.
+// 2. Command Control Registers
+// 3. MACID Setting Registers
+// 4. Timing Control Registers
+// 5. FIFO Control Registers
+// 6. Adaptive Control Registers
+// 7. EDCA Setting Registers
+// 8. WMAC, BA and CCX related Register.
+// 9. Security Control Registers
+// 10. Power Save Control Registers
+// 11. General Purpose Registers
+// 12. Host Interrupt Status Registers
+// 13. Test Mode and Debug Control Registers
+// 14. PCIE config register
+//
+
+
+//
+// 1. System Configuration Registers (Offset: 0x0000 - 0x003F)
+//
+#define SYS_ISO_CTRL 0x0000 // System Isolation Interface Control.
+#define SYS_FUNC_EN 0x0002 // System Function Enable.
+#define PMC_FSM 0x0004 // Power Sequence Control.
+#define SYS_CLKR 0x0008 // System Clock.
+#define EPROM_CMD 0x000A // 93C46/93C56 Command Register. (win CR93C46)
+#define EE_VPD 0x000C // EEPROM VPD Data.
+#define AFE_MISC 0x0010 // AFE Misc.
+#define SPS0_CTRL 0x0011 // Switching Power Supply 0 Control.
+#define SPS1_CTRL 0x0018 // Switching Power Supply 1 Control.
+#define RF_CTRL 0x001F // RF Block Control.
+#define LDOA15_CTRL 0x0020 // V15 Digital LDO Control.
+#define LDOV12D_CTRL 0x0021 // V12 Digital LDO Control.
+#define LDOHCI12_CTRL 0x0022 // V12 Digital LDO Control.
+#define LDO_USB_SDIO 0x0023 // LDO USB Control.
+#define LPLDO_CTRL 0x0024 // Low Power LDO Control.
+#define AFE_XTAL_CTRL 0x0026 // AFE Crystal Control.
+#define AFE_PLL_CTRL 0x0028 // System Function Enable.
+#define EFUSE_CTRL 0x0030 // E-Fuse Control.
+#define EFUSE_TEST 0x0034 // E-Fuse Test.
+#define PWR_DATA 0x0038 // Power on date.
+#define DBG_PORT 0x003A // MAC debug port select
+#define DPS_TIMER 0x003C // Deep Power Save Timer Register.
+#define RCLK_MON 0x003E // Retention Clock Monitor.
+
+//
+// 2. Command Control Registers (Offset: 0x0040 - 0x004F)
+//
+#define CMDR 0x0040 // MAC Command Register.
+#define TXPAUSE 0x0042 // Transmission Pause Register.
+#define LBKMD_SEL 0x0043 // Loopback Mode Select Register.
+#define TCR 0x0044 // Transmit Configuration Register
+#define RCR 0x0048 // Receive Configuration Register
+#define MSR 0x004C // Media Status register
+#define SYSF_CFG 0x004D // System Function Configuration.
+#define RX_PKY_LIMIT 0x004E // RX packet length limit
+#define MBIDCTRL 0x004F // MBSSID Control.
+
+//
+// 3. MACID Setting Registers (Offset: 0x0050 - 0x007F)
+//
+#define MACIDR 0x0050 // MAC ID Register, Offset 0x0050-0x0055
+#define MACIDR0 0x0050 // MAC ID Register, Offset 0x0050-0x0053
+#define MACIDR4 0x0054 // MAC ID Register, Offset 0x0054-0x0055
+#define BSSIDR 0x0058 // BSSID Register, Offset 0x0058-0x005D
+#define HWVID 0x005E // HW Version ID.
+#define MAR 0x0060 // Multicase Address.
+#define MBIDCAMCONTENT 0x0068 // MBSSID CAM Content.
+#define MBIDCAMCFG 0x0070 // MBSSID CAM Configuration.
+#define BUILDTIME 0x0074 // Build Time Register.
+#define BUILDUSER 0x0078 // Build User Register.
+
+// Redifine MACID register, to compatible prior ICs.
+#define IDR0 MACIDR0
+#define IDR4 MACIDR4
+
+//
+// 4. Timing Control Registers (Offset: 0x0080 - 0x009F)
+//
+#define TSFR 0x0080 // Timing Sync Function Timer Register.
+#define SLOT_TIME 0x0089 // Slot Time Register, in us.
+#define USTIME 0x008A // EDCA/TSF clock unit time us unit.
+#define SIFS_CCK 0x008C // SIFS for CCK, in us.
+#define SIFS_OFDM 0x008E // SIFS for OFDM, in us.
+#define PIFS_TIME 0x0090 // PIFS time register.
+#define ACK_TIMEOUT 0x0091 // Ack Timeout Register
+#define EIFSTR 0x0092 // EIFS time regiser.
+#define BCN_INTERVAL 0x0094 // Beacon Interval, in TU.
+#define ATIMWND 0x0096 // ATIM Window width, in TU.
+#define BCN_DRV_EARLY_INT 0x0098 // Driver Early Interrupt.
+#define BCN_DMATIME 0x009A // Beacon DMA and ATIM INT Time.
+#define BCN_ERR_THRESH 0x009C // Beacon Error Threshold.
+#define MLT 0x009D // MSDU Lifetime.
+#define RSVD_MAC_TUNE_US 0x009E // MAC Internal USE.
+
+//
+// 5. FIFO Control Registers (Offset: 0x00A0 - 0x015F)
+//
+#define RQPN 0x00A0
+#define RQPN1 0x00A0 // Reserved Queue Page Number for BK
+#define RQPN2 0x00A1 // Reserved Queue Page Number for BE
+#define RQPN3 0x00A2 // Reserved Queue Page Number for VI
+#define RQPN4 0x00A3 // Reserved Queue Page Number for VO
+#define RQPN5 0x00A4 // Reserved Queue Page Number for HCCA
+#define RQPN6 0x00A5 // Reserved Queue Page Number for CMD
+#define RQPN7 0x00A6 // Reserved Queue Page Number for MGNT
+#define RQPN8 0x00A7 // Reserved Queue Page Number for HIGH
+#define RQPN9 0x00A8 // Reserved Queue Page Number for Beacon
+#define RQPN10 0x00A9 // Reserved Queue Page Number for Public
+#define LD_RQPN 0x00AB //
+#define RXFF_BNDY 0x00AC //
+#define RXRPT_BNDY 0x00B0 //
+#define TXPKTBUF_PGBNDY 0x00B4 //
+#define PBP 0x00B5 //
+#define RXDRVINFO_SZ 0x00B6 //
+#define TXFF_STATUS 0x00B7 //
+#define RXFF_STATUS 0x00B8 //
+#define TXFF_EMPTY_TH 0x00B9 //
+#define SDIO_RX_BLKSZ 0x00BC //
+#define RXDMA 0x00BD //
+#define RXPKT_NUM 0x00BE //
+#define C2HCMD_UDT_SIZE 0x00C0 //
+#define C2HCMD_UDT_ADDR 0x00C2 //
+#define FIFOPAGE1 0x00C4 // Available public queue page number
+#define FIFOPAGE2 0x00C8 //
+#define FIFOPAGE3 0x00CC //
+#define FIFOPAGE4 0x00D0 //
+#define FIFOPAGE5 0x00D4 //
+#define FW_RSVD_PG_CRTL 0x00D8 //
+#define RXDMA_AGG_PG_TH 0x00D9 //
+#define TXRPTFF_RDPTR 0x00E0 //
+#define TXRPTFF_WTPTR 0x00E4 //
+#define C2HFF_RDPTR 0x00E8 //FIFO Read pointer register.
+#define C2HFF_WTPTR 0x00EC //FIFO Write pointer register.
+#define RXFF0_RDPTR 0x00F0 //
+#define RXFF0_WTPTR 0x00F4 //
+#define RXFF1_RDPTR 0x00F8 //
+#define RXFF1_WTPTR 0x00FC //
+#define RXRPT0_RDPTR 0x0100 //
+#define RXRPT0_WTPTR 0x0104 //
+#define RXRPT1_RDPTR 0x0108 //
+#define RXRPT1_WTPTR 0x010C //
+#define RX0_UDT_SIZE 0x0110 //
+#define RX1PKTNUM 0x0114 //
+#define RXFILTERMAP 0x0116 //
+#define RXFILTERMAP_GP1 0x0118 //
+#define RXFILTERMAP_GP2 0x011A //
+#define RXFILTERMAP_GP3 0x011C //
+#define BCNQ_CTRL 0x0120 //
+#define MGTQ_CTRL 0x0124 //
+#define HIQ_CTRL 0x0128 //
+#define VOTID7_CTRL 0x012c //
+#define VOTID6_CTRL 0x0130 //
+#define VITID5_CTRL 0x0134 //
+#define VITID4_CTRL 0x0138 //
+#define BETID3_CTRL 0x013c //
+#define BETID0_CTRL 0x0140 //
+#define BKTID2_CTRL 0x0144 //
+#define BKTID1_CTRL 0x0148 //
+#define CMDQ_CTRL 0x014c //
+#define TXPKT_NUM_CTRL 0x0150 //
+#define TXQ_PGADD 0x0152 //
+#define TXFF_PG_NUM 0x0154 //
+#define TRXDMA_STATUS 0x0156 //
+
+//
+// 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF)
+//
+#define INIMCS_SEL 0x0160 // Init MCSrate for 32 MACID 0x160-17f
+#define TX_RATE_REG INIMCS_SEL //Current Tx rate register
+#define INIRTSMCS_SEL 0x0180 // Init RTSMCSrate
+#define RRSR 0x0181 // Response rate setting.
+#define ARFR0 0x0184 // Auto Rate Fallback 0 Register.
+#define ARFR1 0x0188 //
+#define ARFR2 0x018C //
+#define ARFR3 0x0190 //
+#define ARFR4 0x0194 //
+#define ARFR5 0x0198 //
+#define ARFR6 0x019C //
+#define ARFR7 0x01A0 //
+#define AGGLEN_LMT_H 0x01A7 // Aggregation Length Limit for High-MCS
+#define AGGLEN_LMT_L 0x01A8 // Aggregation Length Limit for Low-MCS.
+#define DARFRC 0x01B0 // Data Auto Rate Fallback Retry Count.
+#define RARFRC 0x01B8 // Response Auto Rate Fallback Count.
+#define MCS_TXAGC 0x01C0
+#define CCK_TXAGC 0x01C8
+
+//
+// 7. EDCA Setting Registers (Offset: 0x01D0 - 0x01FF)
+//
+#define EDCAPARA_VO 0x01D0 // EDCA Parameter Register for VO queue.
+#define EDCAPARA_VI 0x01D4 // EDCA Parameter Register for VI queue.
+#define EDCAPARA_BE 0x01D8 // EDCA Parameter Register for BE queue.
+#define EDCAPARA_BK 0x01DC // EDCA Parameter Register for BK queue.
+#define BCNTCFG 0x01E0 // Beacon Time Configuration Register.
+#define CWRR 0x01E2 // Contention Window Report Register.
+#define ACMAVG 0x01E4 // ACM Average Register.
+#define AcmHwCtrl 0x01E7
+#define VO_ADMTM 0x01E8 // Admission Time Register.
+#define VI_ADMTM 0x01EC
+#define BE_ADMTM 0x01F0
+#define RETRY_LIMIT 0x01F4 // Retry Limit Registers[15:8]-short, [7:0]-long
+#define SG_RATE 0x01F6 // Max MCS Rate Available Register, which we Set the hightst SG rate.
+
+//
+// 8. WMAC, BA and CCX related Register. (Offset: 0x0200 - 0x023F)
+//
+#define NAV_CTRL 0x0200
+#define BW_OPMODE 0x0203
+#define BACAMCMD 0x0204
+#define BACAMCONTENT 0x0208 // Block ACK CAM R/W Register.
+
+// Roger had defined the 0x2xx register WMAC definition
+#define LBDLY 0x0210 // Loopback Delay Register.
+#define FWDLY 0x0211 // FW Delay Register.
+#define HWPC_RX_CTRL 0x0218 // HW Packet Conversion RX Control Reg
+#define MQIR 0x0220 // Mesh Qos Type Indication Register.
+#define MAIR 0x0222 // Mesh ACK.
+#define MSIR 0x0224 // Mesh HW Security Requirement Indication Reg
+#define CLM_RESULT 0x0227 // CCA Busy Fraction(Channel Load)
+#define NHM_RPI_CNT 0x0228 // Noise Histogram Measurement (NHM) RPI Report.
+#define RXERR_RPT 0x0230 // Rx Error Report.
+#define NAV_PROT_LEN 0x0234 // NAV Protection Length.
+#define CFEND_TH 0x0236 // CF-End Threshold.
+#define AMPDU_MIN_SPACE 0x0237 // AMPDU Min Space.
+#define TXOP_STALL_CTRL 0x0238
+
+//
+// 9. Security Control Registers (Offset: 0x0240 - 0x025F)
+//
+#define RWCAM 0x0240 //IN 8190 Data Sheet is called CAMcmd
+#define WCAMI 0x0244 // Software write CAM input content
+#define RCAMO 0x0248 // Software read/write CAM config
+#define CAMDBG 0x024C
+#define SECR 0x0250 //Security Configuration Register
+
+//
+// 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF)
+//
+#define WOW_CTRL 0x0260 //Wake On WLAN Control.
+#define PSSTATUS 0x0261 // Power Save Status.
+#define PSSWITCH 0x0262 // Power Save Switch.
+#define MIMOPS_WAIT_PERIOD 0x0263
+#define LPNAV_CTRL 0x0264
+#define WFM0 0x0270 // Wakeup Frame Mask.
+#define WFM1 0x0280 //
+#define WFM2 0x0290 //
+#define WFM3 0x02A0 //
+#define WFM4 0x02B0 //
+#define WFM5 0x02C0 // FW Control register.
+#define WFCRC 0x02D0 // Wakeup Frame CRC.
+#define RPWM 0x02DC // Host Request Power Mode.
+#define CPWM 0x02DD // Current Power Mode.
+#define FW_RPT_REG 0x02c4
+
+//
+// 11. General Purpose Registers (Offset: 0x02E0 - 0x02FF)
+//
+#define PSTIME 0x02E0 // Power Save Timer Register
+#define TIMER0 0x02E4 //
+#define TIMER1 0x02E8 //
+#define GPIO_CTRL 0x02EC // GPIO Control Register
+#define GPIO_IN 0x02EC // GPIO pins input value
+#define GPIO_OUT 0x02ED // GPIO pins output value
+#define GPIO_IO_SEL 0x02EE // GPIO pins output enable when a bit is set to "1"; otherwise, input is configured.
+#define GPIO_MOD 0x02EF //
+#define GPIO_INTCTRL 0x02F0 // GPIO Interrupt Control Register[7:0]
+#define MAC_PINMUX_CFG 0x02F1 // MAC PINMUX Configuration Reg[7:0]
+#define LEDCFG 0x02F2 // System PINMUX Configuration Reg[7:0]
+#define PHY_REG 0x02F3 // RPT: PHY REG Access Report Reg[7:0]
+#define PHY_REG_DATA 0x02F4 // PHY REG Read DATA Register [31:0]
+#define EFUSE_CLK 0x02F8 // CTRL: E-FUSE Clock Control Reg[7:0]
+//#define GPIO_INTCTRL 0x02F9 // GPIO Interrupt Control Register[7:0]
+
+//
+// 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F)
+//
+#define IMR 0x0300 // Interrupt Mask Register
+#define ISR 0x0308 // Interrupt Status Register
+
+//
+// 13. Test Mode and Debug Control Registers (Offset: 0x0310 - 0x034F)
+//
+#define DBG_PORT_SWITCH 0x003A
+#define BIST 0x0310 // Bist reg definition
+#define DBS 0x0314 // Debug Select ???
+#define CPUINST 0x0318 // CPU Instruction Read Register
+#define CPUCAUSE 0x031C // CPU Cause Register
+#define LBUS_ERR_ADDR 0x0320 // Lexra Bus Error Address Register
+#define LBUS_ERR_CMD 0x0324 // Lexra Bus Error Command Register
+#define LBUS_ERR_DATA_L 0x0328 // Lexra Bus Error Data Low DW Register
+#define LBUS_ERR_DATA_H 0x032C //
+#define LX_EXCEPTION_ADDR 0x0330 // Lexra Bus Exception Address Register
+#define WDG_CTRL 0x0334 // Watch Dog Control Register
+#define INTMTU 0x0338 // Interrupt Mitigation Time Unit Reg
+#define INTM 0x033A // Interrupt Mitigation Register
+#define FDLOCKTURN0 0x033C // FW/DRV Lock Turn 0 Register
+#define FDLOCKTURN1 0x033D // FW/DRV Lock Turn 1 Register
+#define TRXPKTBUF_DBG_DATA 0x0340 // TRX Packet Buffer Debug Data Register
+#define TRXPKTBUF_DBG_CTRL 0x0348 // TRX Packet Buffer Debug Control Reg
+#define DPLL 0x034A // DPLL Monitor Register [15:0]
+#define CBUS_ERR_ADDR 0x0350 // CPU Bus Error Address Register
+#define CBUS_ERR_CMD 0x0354 // CPU Bus Error Command Register
+#define CBUS_ERR_DATA_L 0x0358 // CPU Bus Error Data Low DW Register
+#define CBUS_ERR_DATA_H 0x035C //
+#define USB_SIE_INTF_ADDR 0x0360 // USB SIE Access Interface Address Reg
+#define USB_SIE_INTF_WD 0x0361 // USB SIE Access Interface WData Reg
+#define USB_SIE_INTF_RD 0x0362 // USB SIE Access Interface RData Reg
+#define USB_SIE_INTF_CTRL 0x0363 // USB SIE Access Interface Control Reg
+
+// Boundary is 0x37F
+
+//
+// 14. PCIE config register (Offset 0x500-)
+//
+#define TPPoll 0x0500 // Transmit Polling
+#define PM_CTRL 0x0502 // PCIE power management control Register
+#define PCIF 0x0503 // PCI Function Register 0x0009h~0x000bh
+
+#define THPDA 0x0514 // Transmit High Priority Desc Addr
+#define TMDA 0x0518 // Transmit Management Desc Addr
+#define TCDA 0x051C // Transmit Command Desc Addr
+#define HDA 0x0520 // HCCA Desc Addr
+#define TVODA 0x0524 // Transmit VO Desc Addr
+#define TVIDA 0x0528 // Transmit VI Desc Addr
+#define TBEDA 0x052C // Transmit BE Desc Addr
+#define TBKDA 0x0530 // Transmit BK Desc Addr
+#define TBDA 0x0534 // Transmit Beacon Desc Addr
+#define RCDA 0x0538 // Receive Command Desc Addr
+#define RDSA 0x053C // Receive Desc Starting Addr
+#define DBI_WDATA 0x0540 // DBI write data Register
+#define DBI_RDATA 0x0544 // DBI read data Register
+#define DBI_CTRL 0x0548 // PCIE DBI control Register
+#define MDIO_DATA 0x0550 // PCIE MDIO data Register
+#define MDIO_CTRL 0x0554 // PCIE MDIO control Register
+#define PCI_RPWM 0x0561 // PCIE RPWM register
+#define PCI_CPWM 0x0563 // Current Power Mode.
+
+//
+// Config register (Offset 0x800-)
+//
+#define PHY_CCA 0x803 // CCA related register
+
+//============================================================================
+// 8192S USB specific Regsiter Offset and Content definition,
+// 2008.08.28, added by Roger.
+//============================================================================
+// Rx Aggregation time-out reg.
+#define USB_RX_AGG_TIMEOUT 0xFE5B
+
+// Firware reserved Tx page control.
+#define FW_OFFLOAD_EN BIT7
+
+// Min Spacing related settings.
+#define MAX_MSS_DENSITY 0x13
+#define MAX_MSS_DENSITY_2T 0x13
+#define MAX_MSS_DENSITY_1T 0x0A
+
+// Rx DMA Control related settings
+#define RXDMA_AGG_EN BIT7
+
+// USB Rx Aggregation TimeOut settings
+#define RXDMA_AGG_TIMEOUT_DISABLE 0x00
+#define RXDMA_AGG_TIMEOUT_17MS 0x01
+#define RXDMA_AGG_TIMEOUT_17_2_MS 0x02
+#define RXDMA_AGG_TIMEOUT_17_4_MS 0x04
+#define RXDMA_AGG_TIMEOUT_17_10_MS 0x0A
+// USB RPWM register
+#define USB_RPWM 0xFE58
+
+//FIXLZM SVN_BRACH NOT MOD HERE, IF MOD RX IS LITTLE LOW
+//#if ((HAL_CODE_BASE == RTL8192_S) && (DEV_BUS_TYPE==PCI_INTERFACE))
+//#define RPWM PCI_RPWM
+//#elif ((HAL_CODE_BASE == RTL8192_S) && (DEV_BUS_TYPE==USB_INTERFACE))
+//#define RPWM USB_RPWM
+//#endif
+
+
+//============================================================================
+// 8190 Regsiter offset definition
+//============================================================================
+#if 1 // Delete the register later
+#define AFR 0x010 // AutoLoad Function Register
+#define BCN_TCFG 0x062 // Beacon Time Configuration
+#define RATR0 0x320 // Rate Adaptive Table register1
+#endif
+// TODO: Remove unused register, We must declare backward compatiable
+//Undefined register set in 8192S. 0x320/350 DW is useless
+#define UnusedRegister 0x0320
+#define PSR UnusedRegister // Page Select Register
+//Security Related
+#define DCAM UnusedRegister // Debug CAM Interface
+//PHY Configuration related
+#define BBAddr UnusedRegister // Phy register address register
+#define PhyDataR UnusedRegister // Phy register data read
+#define UFWP UnusedRegister
+
+
+//============================================================================
+// 8192S Regsiter Bit and Content definition
+//============================================================================
+
+//
+// 1. System Configuration Registers (Offset: 0x0000 - 0x003F)
+//
+//----------------------------------------------------------------------------
+// 8192S SYS_ISO_CTRL bits (Offset 0x0, 16bit)
+//----------------------------------------------------------------------------
+#define ISO_MD2PP BIT0 // MACTOP/BB/PCIe Digital to Power On.
+#define ISO_PA2PCIE BIT3 // PCIe Analog 1.2V to PCIe 3.3V
+#define ISO_PLL2MD BIT4 // AFE PLL to MACTOP/BB/PCIe Digital.
+#define ISO_PWC_DV2RP BIT11 // Digital Vdd to Retention Path
+#define ISO_PWC_RV2RP BIT12 // LPLDOR12 to Retenrion Path, 1: isolation, 0: attach.
+
+//----------------------------------------------------------------------------
+// 8192S SYS_FUNC_EN bits (Offset 0x2, 16bit)
+//----------------------------------------------------------------------------
+#define FEN_MREGEN BIT15 // MAC I/O Registers Enable.
+#define FEN_DCORE BIT11 // Enable Core Digital.
+#define FEN_CPUEN BIT10 // Enable CPU Core Digital.
+// 8192S PMC_FSM bits (Offset 0x4, 32bit)
+//----------------------------------------------------------------------------
+#define PAD_HWPD_IDN BIT22 // HWPDN PAD status Indicator
+
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+// 8192S SYS_CLKR bits (Offset 0x8, 16bit)
+//----------------------------------------------------------------------------
+#define SYS_CLKSEL_80M BIT0 // System Clock 80MHz
+#define SYS_PS_CLKSEL BIT1 //System power save clock select.
+#define SYS_CPU_CLKSEL BIT2 // System Clock select, 1: AFE source, 0: System clock(L-Bus)
+#define SYS_MAC_CLK_EN BIT11 // MAC Clock Enable.
+#define SYS_SWHW_SEL BIT14 // Load done, control path seitch.
+#define SYS_FWHW_SEL BIT15 // Sleep exit, control path swith.
+
+
+//----------------------------------------------------------------------------
+// 8192S Cmd9346CR bits (Offset 0xA, 16bit)
+//----------------------------------------------------------------------------
+#define CmdEEPROM_En BIT5 // EEPROM enable when set 1
+#define CmdEERPOMSEL BIT4 // System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346
+#define Cmd9346CR_9356SEL BIT4
+#define AutoLoadEEPROM (CmdEEPROM_En|CmdEERPOMSEL)
+#define AutoLoadEFUSE CmdEEPROM_En
+
+
+//----------------------------------------------------------------------------
+// 8192S AFE_MISC bits AFE Misc (Offset 0x10, 8bits)
+//----------------------------------------------------------------------------
+#define AFE_MBEN BIT1 // Enable AFE Macro Block's Mbias.
+#define AFE_BGEN BIT0 // Enable AFE Macro Block's Bandgap.
+
+//----------------------------------------------------------------------------
+// 8192S SPS1_CTRL bits (Offset 0x18-1E, 56bits)
+//----------------------------------------------------------------------------
+#define SPS1_SWEN BIT1 // Enable vsps18 SW Macro Block.
+#define SPS1_LDEN BIT0 // Enable VSPS12 LDO Macro block.
+
+//----------------------------------------------------------------------------
+// 8192S RF_CTRL bits (Offset 0x1F, 8bits)
+//----------------------------------------------------------------------------
+#define RF_EN BIT0 // Enable RF module.
+#define RF_RSTB BIT1 // Reset RF module.
+#define RF_SDMRSTB BIT2 // Reset RF SDM module.
+
+//----------------------------------------------------------------------------
+// 8192S LDOA15_CTRL bits (Offset 0x20, 8bits)
+//----------------------------------------------------------------------------
+#define LDA15_EN BIT0 // Enable LDOA15 Macro Block
+
+//----------------------------------------------------------------------------
+// 8192S LDOV12D_CTRL bits (Offset 0x21, 8bits)
+//----------------------------------------------------------------------------
+#define LDV12_EN BIT0 // Enable LDOVD12 Macro Block
+#define LDV12_SDBY BIT1 // LDOVD12 standby mode
+
+//----------------------------------------------------------------------------
+// 8192S AFE_XTAL_CTRL bits AFE Crystal Control. (Offset 0x26,16bits)
+//----------------------------------------------------------------------------
+#define XTAL_GATE_AFE BIT10
+// Gated Control. 1: AFE Clock source gated, 0: Clock enable.
+
+//----------------------------------------------------------------------------
+// 8192S AFE_PLL_CTRL bits System Function Enable (Offset 0x28,64bits)
+//----------------------------------------------------------------------------
+#define APLL_EN BIT0 // Enable AFE PLL Macro Block.
+
+// Find which card bus type
+#define AFR_CardBEn BIT0
+#define AFR_CLKRUN_SEL BIT1
+#define AFR_FuncRegEn BIT2
+
+//
+// 2. Command Control Registers (Offset: 0x0040 - 0x004F)
+//
+//----------------------------------------------------------------------------
+// 8192S (CMD) command register bits (Offset 0x40, 16 bits)
+//----------------------------------------------------------------------------
+#define APSDOFF_STATUS BIT15 //
+#define APSDOFF BIT14 //
+#define BBRSTn BIT13 //Enable OFDM/CCK
+#define BB_GLB_RSTn BIT12 //Enable BB
+#define SCHEDULE_EN BIT10 //Enable MAC scheduler
+#define MACRXEN BIT9 //
+#define MACTXEN BIT8 //
+#define DDMA_EN BIT7 //FW off load function enable
+#define FW2HW_EN BIT6 //MAC every module reset as below
+#define RXDMA_EN BIT5 //
+#define TXDMA_EN BIT4 //
+#define HCI_RXDMA_EN BIT3 //
+#define HCI_TXDMA_EN BIT2 //
+
+//----------------------------------------------------------------------------
+// 8192S (TXPAUSE) transmission pause (Offset 0x42, 8 bits)
+//----------------------------------------------------------------------------
+#define StopHCCA BIT6
+#define StopHigh BIT5
+#define StopMgt BIT4
+#define StopVO BIT3
+#define StopVI BIT2
+#define StopBE BIT1
+#define StopBK BIT0
+
+//----------------------------------------------------------------------------
+// 8192S (LBKMD) LoopBack Mode Select (Offset 0x43, 8 bits)
+//----------------------------------------------------------------------------
+//
+// [3] no buffer, 1: no delay, 0: delay; [2] dmalbk, [1] no_txphy, [0] diglbk.
+// 0000: Normal
+// 1011: MAC loopback (involving CPU)
+// 0011: MAC Delay Loopback
+// 0001: PHY loopback (not yet implemented)
+// 0111: DMA loopback (only uses TxPktBuffer and DMA engine)
+// All other combinations are reserved.
+// Default: 0000b.
+//
+#define LBK_NORMAL 0x00
+#define LBK_MAC_LB (BIT0|BIT1|BIT3)
+#define LBK_MAC_DLB (BIT0|BIT1)
+#define LBK_DMA_LB (BIT0|BIT1|BIT2)
+
+//----------------------------------------------------------------------------
+// 8192S (TCR) transmission Configuration Register (Offset 0x44, 32 bits)
+//----------------------------------------------------------------------------
+#define TCP_OFDL_EN BIT25 //For CE packet conversion
+#define HWPC_TX_EN BIT24 //""
+#define TXDMAPRE2FULL BIT23 //TXDMA enable pre2full sync
+#define DISCW BIT20 //CW disable
+#define TCRICV BIT19 //Append ICV or not
+#define CfendForm BIT17 //AP mode
+#define TCRCRC BIT16 //Append CRC32
+#define FAKE_IMEM_EN BIT15 //
+#define TSFRST BIT9 //
+#define TSFEN BIT8 //
+// For TCR FW download ready --> write by FW Bit0-7 must all one
+#define FWALLRDY (BIT0|BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7)
+#define FWRDY BIT7
+#define BASECHG BIT6
+#define IMEM BIT5
+#define DMEM_CODE_DONE BIT4
+#define EXT_IMEM_CHK_RPT BIT3
+#define EXT_IMEM_CODE_DONE BIT2
+#define IMEM_CHK_RPT BIT1
+#define IMEM_CODE_DONE BIT0
+// Copy fomr 92SU definition
+#define IMEM_CODE_DONE BIT0
+#define IMEM_CHK_RPT BIT1
+#define EMEM_CODE_DONE BIT2
+#define EMEM_CHK_RPT BIT3
+#define DMEM_CODE_DONE BIT4
+#define IMEM_RDY BIT5
+#define BASECHG BIT6
+#define FWRDY BIT7
+#define LOAD_FW_READY (IMEM_CODE_DONE|IMEM_CHK_RPT|EMEM_CODE_DONE|\
+ EMEM_CHK_RPT|DMEM_CODE_DONE|IMEM_RDY|BASECHG|\
+ FWRDY)
+#define TCR_TSFEN BIT8 // TSF function on or off.
+#define TCR_TSFRST BIT9 // Reset TSF function to zero.
+#define TCR_FAKE_IMEM_EN BIT15
+#define TCR_CRC BIT16
+#define TCR_ICV BIT19 // Integrity Check Value.
+#define TCR_DISCW BIT20 // Disable Contention Windows Backoff.
+#define TCR_HWPC_TX_EN BIT24
+#define TCR_TCP_OFDL_EN BIT25
+#define TXDMA_INIT_VALUE (IMEM_CHK_RPT|EXT_IMEM_CHK_RPT)
+//----------------------------------------------------------------------------
+// 8192S (RCR) Receive Configuration Register (Offset 0x48, 32 bits)
+//----------------------------------------------------------------------------
+#define RCR_APPFCS BIT31 //WMAC append FCS after pauload
+#define RCR_DIS_ENC_2BYTE BIT30 //HW encrypt 2 or 1 byte mode
+#define RCR_DIS_AES_2BYTE BIT29 //
+#define RCR_HTC_LOC_CTRL BIT28 //MFC<--HTC=1 MFC-->HTC=0
+#define RCR_ENMBID BIT27 //Enable Multiple BssId.
+#define RCR_RX_TCPOFDL_EN BIT26 //
+#define RCR_APP_PHYST_RXFF BIT25 //
+#define RCR_APP_PHYST_STAFF BIT24 //
+#define RCR_CBSSID BIT23 //Accept BSSID match packet
+#define RCR_APWRMGT BIT22 //Accept power management packet
+#define RCR_ADD3 BIT21 //Accept address 3 match packet
+#define RCR_AMF BIT20 //Accept management type frame
+#define RCR_ACF BIT19 //Accept control type frame
+#define RCR_ADF BIT18 //Accept data type frame
+#define RCR_APP_MIC BIT17 //
+#define RCR_APP_ICV BIT16 //
+#define RCR_RXFTH BIT13 //Rx FIFO Threshold Bot 13 - 15
+#define RCR_AICV BIT12 //Accept ICV error packet
+#define RCR_RXDESC_LK_EN BIT11 //Accept to update rx desc length
+#define RCR_APP_BA_SSN BIT6 //Accept BA SSN
+#define RCR_ACRC32 BIT5 //Accept CRC32 error packet
+#define RCR_RXSHFT_EN BIT4 //Accept broadcast packet
+#define RCR_AB BIT3 //Accept broadcast packet
+#define RCR_AM BIT2 //Accept multicast packet
+#define RCR_APM BIT1 //Accept physical match packet
+#define RCR_AAP BIT0 //Accept all unicast packet
+#define RCR_MXDMA_OFFSET 8
+#define RCR_FIFO_OFFSET 13
+
+//in 92U FIXLZM
+//#ifdef RTL8192U
+#define RCR_ONLYERLPKT BIT31 // Early Receiving based on Packet Size.
+#define RCR_ENCS2 BIT30 // Enable Carrier Sense Detection Method 2
+#define RCR_ENCS1 BIT29 // Enable Carrier Sense Detection Method 1
+#define RCR_ACKTXBW (BIT24|BIT25) // TXBW Setting of ACK frames
+//#endif
+//----------------------------------------------------------------------------
+// 8192S (MSR) Media Status Register (Offset 0x4C, 8 bits)
+//----------------------------------------------------------------------------
+/*
+Network Type
+00: No link
+01: Link in ad hoc network
+10: Link in infrastructure network
+11: AP mode
+Default: 00b.
+*/
+#define MSR_NOLINK 0x00
+#define MSR_ADHOC 0x01
+#define MSR_INFRA 0x02
+#define MSR_AP 0x03
+
+//----------------------------------------------------------------------------
+// 8192S (SYSF_CFG) system Fucntion Config Reg (Offset 0x4D, 8 bits)
+//----------------------------------------------------------------------------
+#define ENUART BIT7
+#define ENJTAG BIT3
+#define BTMODE (BIT2|BIT1)
+#define ENBT BIT0
+
+//----------------------------------------------------------------------------
+// 8192S (MBIDCTRL) MBSSID Control Register (Offset 0x4F, 8 bits)
+//----------------------------------------------------------------------------
+#define ENMBID BIT7
+#define BCNUM (BIT6|BIT5|BIT4)
+
+//
+// 3. MACID Setting Registers (Offset: 0x0050 - 0x007F)
+//
+
+//
+// 4. Timing Control Registers (Offset: 0x0080 - 0x009F)
+//
+//----------------------------------------------------------------------------
+// 8192S (USTIME) US Time Tunning Register (Offset 0x8A, 16 bits)
+//----------------------------------------------------------------------------
+#define USTIME_EDCA 0xFF00
+#define USTIME_TSF 0x00FF
+
+//----------------------------------------------------------------------------
+// 8192S (SIFS_CCK/OFDM) US Time Tunning Register (Offset 0x8C/8E,16 bits)
+//----------------------------------------------------------------------------
+#define SIFS_TRX 0xFF00
+#define SIFS_CTX 0x00FF
+
+//----------------------------------------------------------------------------
+// 8192S (DRVERLYINT) Driver Early Interrupt Reg (Offset 0x98, 16bit)
+//----------------------------------------------------------------------------
+#define ENSWBCN BIT15
+#define DRVERLY_TU 0x0FF0
+#define DRVERLY_US 0x000F
+#define BCN_TCFG_CW_SHIFT 8
+#define BCN_TCFG_IFS 0
+
+//
+// 5. FIFO Control Registers (Offset: 0x00A0 - 0x015F)
+//
+
+//
+// 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF)
+//
+//----------------------------------------------------------------------------
+// 8192S Response Rate Set Register (offset 0x181, 24bits)
+//----------------------------------------------------------------------------
+#define RRSR_RSC_OFFSET 21
+#define RRSR_SHORT_OFFSET 23
+#define RRSR_RSC_BW_40M 0x600000
+#define RRSR_RSC_UPSUBCHNL 0x400000
+#define RRSR_RSC_LOWSUBCHNL 0x200000
+#define RRSR_SHORT 0x800000
+#define RRSR_1M BIT0
+#define RRSR_2M BIT1
+#define RRSR_5_5M BIT2
+#define RRSR_11M BIT3
+#define RRSR_6M BIT4
+#define RRSR_9M BIT5
+#define RRSR_12M BIT6
+#define RRSR_18M BIT7
+#define RRSR_24M BIT8
+#define RRSR_36M BIT9
+#define RRSR_48M BIT10
+#define RRSR_54M BIT11
+#define RRSR_MCS0 BIT12
+#define RRSR_MCS1 BIT13
+#define RRSR_MCS2 BIT14
+#define RRSR_MCS3 BIT15
+#define RRSR_MCS4 BIT16
+#define RRSR_MCS5 BIT17
+#define RRSR_MCS6 BIT18
+#define RRSR_MCS7 BIT19
+#define BRSR_AckShortPmb BIT23
+
+#define RRSR_RSC_UPSUBCHANL 0x200000
+// CCK ACK: use Short Preamble or not
+
+//----------------------------------------------------------------------------
+// 8192S Rate Definition
+//----------------------------------------------------------------------------
+//CCK
+#define RATR_1M 0x00000001
+#define RATR_2M 0x00000002
+#define RATR_55M 0x00000004
+#define RATR_11M 0x00000008
+//OFDM
+#define RATR_6M 0x00000010
+#define RATR_9M 0x00000020
+#define RATR_12M 0x00000040
+#define RATR_18M 0x00000080
+#define RATR_24M 0x00000100
+#define RATR_36M 0x00000200
+#define RATR_48M 0x00000400
+#define RATR_54M 0x00000800
+//MCS 1 Spatial Stream
+#define RATR_MCS0 0x00001000
+#define RATR_MCS1 0x00002000
+#define RATR_MCS2 0x00004000
+#define RATR_MCS3 0x00008000
+#define RATR_MCS4 0x00010000
+#define RATR_MCS5 0x00020000
+#define RATR_MCS6 0x00040000
+#define RATR_MCS7 0x00080000
+//MCS 2 Spatial Stream
+#define RATR_MCS8 0x00100000
+#define RATR_MCS9 0x00200000
+#define RATR_MCS10 0x00400000
+#define RATR_MCS11 0x00800000
+#define RATR_MCS12 0x01000000
+#define RATR_MCS13 0x02000000
+#define RATR_MCS14 0x04000000
+#define RATR_MCS15 0x08000000
+// ALL CCK Rate
+#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M
+#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M|\
+ RATR_36M|RATR_48M|RATR_54M
+#define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 |\
+ RATR_MCS4|RATR_MCS5|RATR_MCS6 |RATR_MCS7
+#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11|\
+ RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15
+
+//
+// 7. EDCA Setting Registers (Offset: 0x01D0 - 0x01FF)
+//
+//----------------------------------------------------------------------------
+// 8192S EDCA Setting (offset 0x1D0-1DF, 4DW VO/VI/BE/BK)
+//----------------------------------------------------------------------------
+#define AC_PARAM_TXOP_LIMIT_OFFSET 16
+#define AC_PARAM_ECW_MAX_OFFSET 12
+#define AC_PARAM_ECW_MIN_OFFSET 8
+#define AC_PARAM_AIFS_OFFSET 0
+
+//----------------------------------------------------------------------------
+// 8192S AcmHwCtrl bits (offset 0x1E7, 1 byte)
+//----------------------------------------------------------------------------
+#define AcmHw_HwEn BIT0
+#define AcmHw_BeqEn BIT1
+#define AcmHw_ViqEn BIT2
+#define AcmHw_VoqEn BIT3
+#define AcmHw_BeqStatus BIT4
+#define AcmHw_ViqStatus BIT5
+#define AcmHw_VoqStatus BIT6
+
+//----------------------------------------------------------------------------
+// 8192S Retry Limit (Offset 0x1F4, 16bit)
+//----------------------------------------------------------------------------
+#define RETRY_LIMIT_SHORT_SHIFT 8
+#define RETRY_LIMIT_LONG_SHIFT 0
+
+//
+// 8. WMAC, BA and CCX related Register. (Offset: 0x0200 - 0x023F)
+//
+//----------------------------------------------------------------------------
+// 8192S NAV_CTRL bits (Offset 0x200, 24bit)
+//----------------------------------------------------------------------------
+#define NAV_UPPER_EN BIT16
+#define NAV_UPPER 0xFF00
+#define NAV_RTSRST 0xFF
+//----------------------------------------------------------------------------
+// 8192S BW_OPMODE bits (Offset 0x203, 8bit)
+//----------------------------------------------------------------------------
+#define BW_OPMODE_20MHZ BIT2
+#define BW_OPMODE_5G BIT1
+#define BW_OPMODE_11J BIT0
+//----------------------------------------------------------------------------
+// 8192S BW_OPMODE bits (Offset 0x230, 4 Byte)
+//----------------------------------------------------------------------------
+#define RXERR_RPT_RST BIT27 // Write "one" to set the counter to zero.
+// RXERR_RPT_SEL
+#define RXERR_OFDM_PPDU 0
+#define RXERR_OFDM_FALSE_ALARM 1
+#define RXERR_OFDM_MPDU_OK 2
+#define RXERR_OFDM_MPDU_FAIL 3
+#define RXERR_CCK_PPDU 4
+#define RXERR_CCK_FALSE_ALARM 5
+#define RXERR_CCK_MPDU_OK 6
+#define RXERR_CCK_MPDU_FAIL 7
+#define RXERR_HT_PPDU 8
+#define RXERR_HT_FALSE_ALARM 9
+#define RXERR_HT_MPDU_TOTAL 10
+#define RXERR_HT_MPDU_OK 11
+#define RXERR_HT_MPDU_FAIL 12
+#define RXERR_RX_FULL_DROP 15
+
+//
+// 9. Security Control Registers (Offset: 0x0240 - 0x025F)
+//
+//----------------------------------------------------------------------------
+// 8192S RWCAM CAM Command Register (offset 0x240, 4 byte)
+//----------------------------------------------------------------------------
+#define CAM_CM_SecCAMPolling BIT31 //Security CAM Polling
+#define CAM_CM_SecCAMClr BIT30 //Clear all bits in CAM
+#define CAM_CM_SecCAMWE BIT16 //Security CAM enable
+#define CAM_ADDR 0xFF //CAM Address Offset
+
+//----------------------------------------------------------------------------
+// 8192S CAMDBG Debug CAM Register (offset 0x24C, 4 byte)
+//----------------------------------------------------------------------------
+#define Dbg_CAM_TXSecCAMInfo BIT31 //Retrieve lastest Tx Info
+#define Dbg_CAM_SecKeyFound BIT30 //Security KEY Found
+
+
+//----------------------------------------------------------------------------
+// 8192S SECR Security Configuration Register (offset 0x250, 1 byte)
+//----------------------------------------------------------------------------
+#define SCR_TxUseDK BIT0 //Force Tx Use Default Key
+#define SCR_RxUseDK BIT1 //Force Rx Use Default Key
+#define SCR_TxEncEnable BIT2 //Enable Tx Encryption
+#define SCR_RxDecEnable BIT3 //Enable Rx Decryption
+#define SCR_SKByA2 BIT4 //Search kEY BY A2
+#define SCR_NoSKMC BIT5 //No Key Search Multicast
+//----------------------------------------------------------------------------
+// 8192S CAM Config Setting (offset 0x250, 1 byte)
+//----------------------------------------------------------------------------
+#define CAM_VALID BIT15
+#define CAM_NOTVALID 0x0000
+#define CAM_USEDK BIT5
+
+#define CAM_NONE 0x0
+#define CAM_WEP40 0x01
+#define CAM_TKIP 0x02
+#define CAM_AES 0x04
+#define CAM_WEP104 0x05
+
+#define TOTAL_CAM_ENTRY 32
+
+#define CAM_CONFIG_USEDK TRUE
+#define CAM_CONFIG_NO_USEDK FALSE
+
+#define CAM_WRITE BIT16
+#define CAM_READ 0x00000000
+#define CAM_POLLINIG BIT31
+
+#define SCR_UseDK 0x01
+#define SCR_TxSecEnable 0x02
+#define SCR_RxSecEnable 0x04
+
+//
+// 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF)
+//
+#define WOW_PMEN BIT0 // Power management Enable.
+#define WOW_WOMEN BIT1 // WoW function on or off.
+#define WOW_MAGIC BIT2 // Magic packet
+#define WOW_UWF BIT3 // Unicast Wakeup frame.
+
+//
+// 11. General Purpose Registers (Offset: 0x02E0 - 0x02FF)
+// 8192S GPIO Config Setting (offset 0x2F1, 1 byte)
+//----------------------------------------------------------------------------
+#define GPIOMUX_EN BIT3 // When this bit is set to "1", GPIO PINs will switch to MAC GPIO Function
+#define GPIOSEL_GPIO 0 // UART or JTAG or pure GPIO
+#define GPIOSEL_PHYDBG 1 // PHYDBG
+#define GPIOSEL_BT 2 // BT_coex
+#define GPIOSEL_WLANDBG 3 // WLANDBG
+#define GPIOSEL_GPIO_MASK ~(BIT0|BIT1)
+
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+// PHY REG Access Report Register definition
+//----------------------------------------------------------------------------
+#define HST_RDBUSY BIT0
+#define CPU_WTBUSY BIT1
+
+//
+// 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F)
+//
+//----------------------------------------------------------------------------
+// 8190 IMR/ISR bits (offset 0xfd, 8bits)
+//----------------------------------------------------------------------------
+#define IMR8190_DISABLED 0x0
+
+// IMR DW1 Bit 0-31
+#define IMR_CPUERR BIT5 // CPU error interrupt
+#define IMR_ATIMEND BIT4 // ATIM Window End Interrupt
+#define IMR_TBDOK BIT3 // Transmit Beacon OK Interrupt
+#define IMR_TBDER BIT2 // Transmit Beacon Error Interrupt
+#define IMR_BCNDMAINT8 BIT1 // Beacon DMA Interrupt 8
+#define IMR_BCNDMAINT7 BIT0 // Beacon DMA Interrupt 7
+// IMR DW0 Bit 0-31
+
+#define IMR_BCNDMAINT6 BIT31 // Beacon DMA Interrupt 6
+#define IMR_BCNDMAINT5 BIT30 // Beacon DMA Interrupt 5
+#define IMR_BCNDMAINT4 BIT29 // Beacon DMA Interrupt 4
+#define IMR_BCNDMAINT3 BIT28 // Beacon DMA Interrupt 3
+#define IMR_BCNDMAINT2 BIT27 // Beacon DMA Interrupt 2
+#define IMR_BCNDMAINT1 BIT26 // Beacon DMA Interrupt 1
+#define IMR_BCNDOK8 BIT25 // Beacon Queue DMA OK Interrup 8
+#define IMR_BCNDOK7 BIT24 // Beacon Queue DMA OK Interrup 7
+#define IMR_BCNDOK6 BIT23 // Beacon Queue DMA OK Interrup 6
+#define IMR_BCNDOK5 BIT22 // Beacon Queue DMA OK Interrup 5
+#define IMR_BCNDOK4 BIT21 // Beacon Queue DMA OK Interrup 4
+#define IMR_BCNDOK3 BIT20 // Beacon Queue DMA OK Interrup 3
+#define IMR_BCNDOK2 BIT19 // Beacon Queue DMA OK Interrup 2
+#define IMR_BCNDOK1 BIT18 // Beacon Queue DMA OK Interrup 1
+#define IMR_TIMEOUT2 BIT17 // Timeout interrupt 2
+#define IMR_TIMEOUT1 BIT16 // Timeout interrupt 1
+#define IMR_TXFOVW BIT15 // Transmit FIFO Overflow
+#define IMR_PSTIMEOUT BIT14 // Power save time out interrupt
+#define IMR_BcnInt BIT13 // Beacon DMA Interrupt 0
+#define IMR_RXFOVW BIT12 // Receive FIFO Overflow
+#define IMR_RDU BIT11 // Receive Descriptor Unavailable
+#define IMR_RXCMDOK BIT10 // Receive Command Packet OK
+#define IMR_BDOK BIT9 // Beacon Queue DMA OK Interrup
+#define IMR_HIGHDOK BIT8 // High Queue DMA OK Interrupt
+#define IMR_COMDOK BIT7 // Command Queue DMA OK Interrupt
+#define IMR_MGNTDOK BIT6 // Management Queue DMA OK Interrupt
+#define IMR_HCCADOK BIT5 // HCCA Queue DMA OK Interrupt
+#define IMR_BKDOK BIT4 // AC_BK DMA OK Interrupt
+#define IMR_BEDOK BIT3 // AC_BE DMA OK Interrupt
+#define IMR_VIDOK BIT2 // AC_VI DMA OK Interrupt
+#define IMR_VODOK BIT1 // AC_VO DMA Interrupt
+#define IMR_ROK BIT0 // Receive DMA OK Interrupt
+
+//
+// 13. Test Mode and Debug Control Registers (Offset: 0x0310 - 0x034F)
+//
+
+//
+// 14. PCIE config register (Offset 0x500-)
+//
+//----------------------------------------------------------------------------
+// 8190 TPPool bits (offset 0xd9, 2 byte)
+//----------------------------------------------------------------------------
+#define TPPoll_BKQ BIT0 // BK queue polling
+#define TPPoll_BEQ BIT1 // BE queue polling
+#define TPPoll_VIQ BIT2 // VI queue polling
+#define TPPoll_VOQ BIT3 // VO queue polling
+#define TPPoll_BQ BIT4 // Beacon queue polling
+#define TPPoll_CQ BIT5 // Command queue polling
+#define TPPoll_MQ BIT6 // Management queue polling
+#define TPPoll_HQ BIT7 // High queue polling
+#define TPPoll_HCCAQ BIT8 // HCCA queue polling
+#define TPPoll_StopBK BIT9 // Stop BK queue
+#define TPPoll_StopBE BIT10 // Stop BE queue
+#define TPPoll_StopVI BIT11 // Stop VI queue
+#define TPPoll_StopVO BIT12 // Stop VO queue
+#define TPPoll_StopMgt BIT13 // Stop Mgnt queue
+#define TPPoll_StopHigh BIT14 // Stop High queue
+#define TPPoll_StopHCCA BIT15 // Stop HCCA queue
+#define TPPoll_SHIFT 8 // Queue ID mapping
+
+//----------------------------------------------------------------------------
+// 8192S PCIF (Offset 0x500, 32bit)
+//----------------------------------------------------------------------------
+#define MXDMA2_16bytes 0x000
+#define MXDMA2_32bytes 0x001
+#define MXDMA2_64bytes 0x010
+#define MXDMA2_128bytes 0x011
+#define MXDMA2_256bytes 0x100
+#define MXDMA2_512bytes 0x101
+#define MXDMA2_1024bytes 0x110
+#define MXDMA2_NoLimit 0x7
+
+#define MULRW_SHIFT 3
+#define MXDMA2_RX_SHIFT 4
+#define MXDMA2_TX_SHIFT 0
+
+//----------------------------------------------------------------------------
+// 8190 CCX_COMMAND_REG Setting (offset 0x25A, 1 byte)
+//----------------------------------------------------------------------------
+#define CCX_CMD_CLM_ENABLE BIT0 // Enable Channel Load
+#define CCX_CMD_NHM_ENABLE BIT1 // Enable Noise Histogram
+#define CCX_CMD_FUNCTION_ENABLE BIT8
+// CCX function (Channel Load/RPI/Noise Histogram).
+#define CCX_CMD_IGNORE_CCA BIT9
+// Treat CCA period as IDLE time for NHM.
+#define CCX_CMD_IGNORE_TXON BIT10
+// Treat TXON period as IDLE time for NHM.
+#define CCX_CLM_RESULT_READY BIT16
+// 1: Indicate the result of Channel Load is ready.
+#define CCX_NHM_RESULT_READY BIT16
+// 1: Indicate the result of Noise histogram is ready.
+#define CCX_CMD_RESET 0x0
+// Clear all the result of CCX measurement and disable the CCX function.
+
+
+//----------------------------------------------------------------------------
+// 8192S EFUSE
+//----------------------------------------------------------------------------
+//#define HWSET_MAX_SIZE_92S 128
+
+
+//----------------------------------------------------------------------------
+// 8192S EEPROM/EFUSE share register definition.
+//----------------------------------------------------------------------------
+
+#ifdef RTL8192SE
+//
+// 2008/11/05 MH Redefine EEPROM address for 8192SE
+// 92SE/SU EEPROM definition seems not the same!!!!!!
+// EEPROM MAP REgister Definition!!!! Please refer to 8192SE EEPROM V0.5 2008/10/21
+// Update to 8192SE EEPROM V0.6 2008/11/11
+//
+#define RTL8190_EEPROM_ID 0x8129 // 0-1
+#define EEPROM_HPON 0x02 // LDO settings.2-5
+#define EEPROM_CLK 0x06 // Clock settings.6-7
+#define EEPROM_TESTR 0x08 // SE Test mode.8
+
+#define EEPROM_VID 0x0A // SE Vendor ID.A-B
+#define EEPROM_DID 0x0C // SE Device ID. C-D
+#define EEPROM_SVID 0x0E // SE Vendor ID.E-F
+#define EEPROM_SMID 0x10 // SE PCI Subsystem ID. 10-11
+
+#define EEPROM_MAC_ADDR 0x12 // SEMAC Address. 12-17
+#define EEPROM_NODE_ADDRESS_BYTE_0 0x12 // MAC address.
+
+#define EEPROM_PwDiff 0x54 // Difference of gain index between legacy and high throughput OFDM.
+
+//
+// 0x20 - 4B EPHY parameter!!!
+//
+//
+#define EEPROM_TxPowerBase 0x50 // Tx Power of serving station.
+#define EEPROM_TxPwIndex_CCK_24G 0x5D // 0x50~0x5D Range = 0~0x24//FIXLZM
+#define EEPROM_TxPwIndex_OFDM_24G 0x6B // 0x5E~0x6B Range = 0~0x24//FIXLZM
+#define EEPROM_TX_PWR_INDEX_RANGE 28 // CCK and OFDM 14 channel
+
+
+// 2009/01/21 MH Add for SD3 requirement
+#define EEPROM_TX_PWR_HT20_DIFF 0x62// HT20 Tx Power Index Difference
+#define DEFAULT_HT20_TXPWR_DIFF 2 // HT20<->40 default Tx Power Index Difference
+#define EEPROM_TX_PWR_OFDM_DIFF 0x65// OFDM Tx Power Index Difference
+#define EEPROM_TX_PWR_BAND_EDGE 0x67// TX Power offset at band-edge channel
+#define TX_PWR_BAND_EDGE_CHK 0x6D// Check if band-edge scheme is enabled
+
+// Oly old EEPROM format support the definition=============================
+//
+#define EEPROM_TxPwIndex_CCK_24G 0x5D // 0x50~0x5D Range = 0~0x24
+#define EEPROM_TxPwIndex_OFDM_24G 0x6B // 0x5E~0x6B Range = 0~0x24
+#define EEPROM_HT2T_CH1_A 0x6c //HT 2T path A channel 1 Power Index.
+#define EEPROM_HT2T_CH7_A 0x6d //HT 2T path A channel 7 Power Index.
+#define EEPROM_HT2T_CH13_A 0x6e //HT 2T path A channel 13 Power Index.
+#define EEPROM_HT2T_CH1_B 0x6f //HT 2T path B channel 1 Power Index.
+#define EEPROM_HT2T_CH7_B 0x70 //HT 2T path B channel 7 Power Index.
+#define EEPROM_HT2T_CH13_B 0x71 //HT 2T path B channel 13 Power Index.
+//
+#define EEPROM_TSSI_A 0x74 //TSSI value of path A.
+#define EEPROM_TSSI_B 0x75 //TSSI value of path B.
+//
+#define EEPROM_RFInd_PowerDiff 0x76
+#define EEPROM_Default_LegacyHTTxPowerDiff 0x3
+//
+#define EEPROM_ThermalMeter 0x77 // Thermal meter default value.
+#define EEPROM_CrystalCap 0x79 // Crystal Cap.
+#define EEPROM_ChannelPlan 0x7B // Map of supported channels.
+#define EEPROM_Version 0x7C // The EEPROM content version
+#define EEPROM_CustomID 0x7A
+#define EEPROM_BoardType 0x7E
+// 0: 2x2 Green RTL8192GE miniCard (QFN68)
+// 1: 1x2 RTL8191SE miniCard (QFN64)
+// 2: 2x2 RTL8192SE miniCard (QFN68)
+// 3: 1x2 RTL8191SR minicCard(QFN64)
+
+//
+// Default Value for EEPROM or EFUSE!!!
+//
+#define EEPROM_Default_TSSI 0x0
+#define EEPROM_Default_TxPowerDiff 0x0
+#define EEPROM_Default_CrystalCap 0x5
+#define EEPROM_Default_BoardType 0x02 // Default: 2X2, RTL8192SE(QFPN68)
+#define EEPROM_Default_TxPower 0x1010
+#define EEPROM_Default_HT2T_TxPwr 0x10
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+#define EEPROM_Default_TxPowerBase 0x0
+#define EEPROM_Default_ThermalMeter 0x12
+#define EEPROM_Default_PwDiff 0x4
+#else
+#define EEPROM_Default_LegacyHTTxPowerDiff 0x3
+#define EEPROM_Default_ThermalMeter 0x12
+#define EEPROM_Default_AntTxPowerDiff 0x0
+#define EEPROM_Default_TxPwDiff_CrystalCap 0x5
+#define EEPROM_Default_TxPowerLevel 0x22
+#endif
+
+#define EEPROM_CHANNEL_PLAN_FCC 0x0
+#define EEPROM_CHANNEL_PLAN_IC 0x1
+#define EEPROM_CHANNEL_PLAN_ETSI 0x2
+#define EEPROM_CHANNEL_PLAN_SPAIN 0x3
+#define EEPROM_CHANNEL_PLAN_FRANCE 0x4
+#define EEPROM_CHANNEL_PLAN_MKK 0x5
+#define EEPROM_CHANNEL_PLAN_MKK1 0x6
+#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7
+#define EEPROM_CHANNEL_PLAN_TELEC 0x8
+#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMAIN 0x9
+#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA
+#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80
+
+
+#define EEPROM_CID_DEFAULT 0x0
+#define EEPROM_CID_TOSHIBA 0x4
+#else
+//----------------------------------------------------------------------------
+// 8192S EEROM and Compatible E-Fuse definition. Added by Roger, 2008.10.21.
+//----------------------------------------------------------------------------
+#define RTL8190_EEPROM_ID 0x8129
+#define EEPROM_HPON 0x02 // LDO settings.
+#define EEPROM_VID 0x08 // USB Vendor ID.
+#define EEPROM_PID 0x0A // USB Product ID.
+#define EEPROM_USB_OPTIONAL 0x0C // For optional function.
+#define EEPROM_USB_PHY_PARA1 0x0D // For fine tune USB PHY.
+#define EEPROM_NODE_ADDRESS_BYTE_0 0x12 // MAC address.
+#define EEPROM_TxPowerDiff 0x1F
+
+#define EEPROM_Version 0x50
+#define EEPROM_ChannelPlan 0x51 // Map of supported channels.
+#define EEPROM_CustomID 0x52
+#define EEPROM_SubCustomID 0x53 // Reserved for customer use.
+
+
+ // <Roger_Notes> The followin are for different version of EEPROM contents purpose. 2008.11.22.
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+#define EEPROM_PwDiff 0x54 // Difference of gain index between legacy and high throughput OFDM.
+#define EEPROM_ThermalMeter 0x55 // Thermal meter default value.
+#define EEPROM_Reserved 0x56 // Reserved.
+#define EEPROM_CrystalCap 0x57 // Crystal Cap.
+#define EEPROM_TxPowerBase 0x58 // Tx Power of serving station.
+#define EEPROM_TxPwIndex_CCK_24G 0x59 // 0x59~0x66
+#define EEPROM_TxPwIndex_OFDM_24G 0x67 // 0x67~0x74
+#define EEPROM_TSSI_A 0x75 //TSSI value of path A.
+#define EEPROM_TSSI_B 0x76 //TSSI value of path B.
+#define EEPROM_TxPwTkMode 0x77 //Tx Power tracking mode.
+#define EEPROM_HT2T_CH1_A 0x78 //HT 2T path A channel 1 Power Index.
+#define EEPROM_HT2T_CH7_A 0x79 //HT 2T path A channel 7 Power Index.
+#define EEPROM_HT2T_CH13_A 0x7a //HT 2T path A channel 13 Power Index.
+#define EEPROM_HT2T_CH1_B 0x7b //HT 2T path B channel 1 Power Index.
+#define EEPROM_HT2T_CH7_B 0x7c //HT 2T path B channel 7 Power Index.
+#define EEPROM_HT2T_CH13_B 0x7d //HT 2T path B channel 13 Power Index.
+#define EEPROM_BoardType 0x7e //0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU
+#else
+#define EEPROM_BoardType 0x54 //0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU
+#define EEPROM_TxPwIndex 0x55 //0x55-0x66, Tx Power index.
+#define EEPROM_PwDiff 0x67 // Difference of gain index between legacy and high throughput OFDM.
+#define EEPROM_ThermalMeter 0x68 // Thermal meter default value.
+#define EEPROM_CrystalCap 0x69 // Crystal Cap.
+#define EEPROM_TxPowerBase 0x6a // Tx Power of serving station.
+#define EEPROM_TSSI_A 0x6b //TSSI value of path A.
+#define EEPROM_TSSI_B 0x6c //TSSI value of path B.
+#define EEPROM_TxPwTkMode 0x6d //Tx Power tracking mode.
+//#define EEPROM_Reserved 0x6e //0x6e-0x7f, reserved.
+
+// 2009/02/09 Cosa Add for SD3 requirement
+#define EEPROM_TX_PWR_HT20_DIFF 0x6e// HT20 Tx Power Index Difference
+#define DEFAULT_HT20_TXPWR_DIFF 2 // HT20<->40 default Tx Power Index Difference
+#define EEPROM_TX_PWR_OFDM_DIFF 0x71// OFDM Tx Power Index Difference
+#define EEPROM_TX_PWR_BAND_EDGE 0x73// TX Power offset at band-edge channel
+#define TX_PWR_BAND_EDGE_CHK 0x79// Check if band-edge scheme is enabled
+#endif
+#define EEPROM_Default_LegacyHTTxPowerDiff 0x3
+#define EEPROM_USB_Default_OPTIONAL_FUNC 0x8
+#define EEPROM_USB_Default_PHY_PARAM 0x0
+#define EEPROM_Default_TSSI 0x0
+#define EEPROM_Default_TxPwrTkMode 0x0
+#define EEPROM_Default_TxPowerDiff 0x0
+#define EEPROM_Default_TxPowerBase 0x0
+#define EEPROM_Default_ThermalMeter 0x7
+#define EEPROM_Default_PwDiff 0x4
+#define EEPROM_Default_CrystalCap 0x5
+#define EEPROM_Default_TxPower 0x1010
+#define EEPROM_Default_BoardType 0x02 // Default: 2X2, RTL8192SU(QFPN68)
+#define EEPROM_Default_HT2T_TxPwr 0x10
+#define EEPROM_USB_SN BIT0
+#define EEPROM_USB_REMOTE_WAKEUP BIT1
+#define EEPROM_USB_DEVICE_PWR BIT2
+#define EEPROM_EP_NUMBER (BIT3|BIT4)
+
+#define EEPROM_CHANNEL_PLAN_FCC 0x0
+#define EEPROM_CHANNEL_PLAN_IC 0x1
+#define EEPROM_CHANNEL_PLAN_ETSI 0x2
+#define EEPROM_CHANNEL_PLAN_SPAIN 0x3
+#define EEPROM_CHANNEL_PLAN_FRANCE 0x4
+#define EEPROM_CHANNEL_PLAN_MKK 0x5
+#define EEPROM_CHANNEL_PLAN_MKK1 0x6
+#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7
+#define EEPROM_CHANNEL_PLAN_TELEC 0x8
+#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMAIN 0x9
+#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA
+#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80
+
+#define EEPROM_CID_DEFAULT 0x0
+#define EEPROM_CID_ALPHA 0x1
+#define EEPROM_CID_CAMEO 0X8
+#define EEPROM_CID_SITECOM 0x9
+
+//#define EEPROM_CID_RUNTOP 0x2
+//#define EEPROM_CID_Senao 0x3
+//#define EEPROM_CID_TOSHIBA 0x4
+//#define EEPROM_CID_NetCore 0x5
+#define EEPROM_CID_WHQL 0xFE // added by chiyoko for dtm, 20090108
+#endif
+
+//-----------------------------------------------------------------
+// 0x2c0 FW Command Control register definition, added by Roger, 2008.11.27.
+//-----------------------------------------------------------------
+#define FW_DIG_DISABLE 0xfd00cc00
+#define FW_DIG_ENABLE 0xfd000000
+#define FW_DIG_HALT 0xfd000001
+#define FW_DIG_RESUME 0xfd000002
+#define FW_HIGH_PWR_DISABLE 0xfd000008
+#define FW_HIGH_PWR_ENABLE 0xfd000009
+#define FW_TXPWR_TRACK_ENABLE 0xfd000017
+#define FW_TXPWR_TRACK_DISABLE 0xfd000018
+#define FW_RA_RESET 0xfd0000af
+#define FW_RA_ACTIVE 0xfd0000a6
+#define FW_RA_REFRESH 0xfd0000a0
+#define FW_RA_ENABLE_BG 0xfd0000ac
+#define FW_IQK_ENABLE 0xf0000020
+#define FW_IQK_SUCCESS 0x0000dddd
+#define FW_IQK_FAIL 0x0000ffff
+#define FW_OP_FAILURE 0xffffffff
+#define FW_DM_DISABLE 0xfd00aa00
+#define FW_BB_RESET_ENABLE 0xff00000d
+#define FW_BB_RESET_DISABLE 0xff00000e
+#if 0
+//----------------------------------------------------------------------------
+// 8190 EEROM
+//----------------------------------------------------------------------------
+#define RTL8190_EEPROM_ID 0x8129
+//#define EEPROM_NODE_ADDRESS_BYTE_0 0x0C
+
+#define EEPROM_RFInd_PowerDiff 0x28
+#define EEPROM_ThermalMeter 0x29
+#define EEPROM_TxPwDiff_CrystalCap 0x2A //0x2A~0x2B
+#define EEPROM_TxPwIndex_CCK 0x2C //0x2C~0x39
+#define EEPROM_TxPwIndex_OFDM_24G 0x3A //0x3A~0x47
+#define EEPROM_TxPwIndex_OFDM_5G 0x34 //0x34~0x7B
+
+//The following definition is for eeprom 93c56......modified 20080220
+#define EEPROM_C56_CrystalCap 0x17 //0x17
+#define EEPROM_C56_RfA_CCK_Chnl1_TxPwIndex 0x80 //0x80
+#define EEPROM_C56_RfA_HT_OFDM_TxPwIndex 0x81 //0x81~0x83
+#define EEPROM_C56_RfC_CCK_Chnl1_TxPwIndex 0xbc //0xb8
+#define EEPROM_C56_RfC_HT_OFDM_TxPwIndex 0xb9 //0xb9~0xbb
+#define EEPROM_Customer_ID 0x7B //0x7B:CustomerID
+#define EEPROM_ICVersion_ChannelPlan 0x7C //0x7C:ChnlPlan,
+ //0x7D:IC_Ver
+#define EEPROM_CRC 0x7E //0x7E~0x7F
+
+#define EEPROM_Default_LegacyHTTxPowerDiff 0x4
+#define EEPROM_Default_ThermalMeter 0x77
+#define EEPROM_Default_AntTxPowerDiff 0x0
+#define EEPROM_Default_TxPwDiff_CrystalCap 0x5
+#define EEPROM_Default_TxPower 0x1010
+#define EEPROM_Default_TxPowerLevel 0x10
+
+//
+// Define Different EEPROM type for customer
+//
+#define EEPROM_CID_DEFAULT 0x0
+#define EEPROM_CID_CAMEO 0x1
+#define EEPROM_CID_RUNTOP 0x2
+#define EEPROM_CID_Senao 0x3
+#define EEPROM_CID_TOSHIBA 0x4
+#define EEPROM_CID_NetCore 0x5
+#define EEPROM_CID_Nettronix 0x6
+#define EEPROM_CID_Pronet 0x7
+
+#endif
+
+//
+//--------------92SU require delete or move to other place later
+//
+
+
+
+//
+//
+// 2008/08/06 MH For share the same 92S source/header files, we copy some
+// definition to pass 92SU compiler. But we must delete thm later.
+//
+//
+
+//============================================================================
+// 819xUsb Regsiter offset definition
+//============================================================================
+
+//2 define it temp!!!
+#define RFPC 0x5F // Rx FIFO Packet Count
+#define RCR_9356SEL BIT6
+#define TCR_LRL_OFFSET 0
+#define TCR_SRL_OFFSET 8
+#define TCR_MXDMA_OFFSET 21
+#define TCR_MXDMA_2048 7
+#define TCR_SAT BIT24 // Enable Rate depedent ack timeout timer
+#define RCR_MXDMA_OFFSET 8
+#define RCR_FIFO_OFFSET 13
+#define RCR_OnlyErlPkt BIT31 // Rx Early mode is performed for packet size greater than 1536
+#define CWR 0xDC // Contention window register
+#define RetryCTR 0xDE // Retry Count register
+
+
+// For backward compatible for 9xUSB
+#define LED1Cfg UnusedRegister // LED1 Configuration Register
+#define LED0Cfg UnusedRegister // LED0 Configuration Register
+#define GPI UnusedRegister // LED0 Configuration Register
+#define BRSR UnusedRegister // LED0 Configuration Register
+#define CPU_GEN UnusedRegister // LED0 Configuration Register
+#define SIFS UnusedRegister // LED0 Configuration Register
+
+//----------------------------------------------------------------------------
+// 8190 CPU General Register (offset 0x100, 4 byte)
+//----------------------------------------------------------------------------
+//#define CPU_CCK_LOOPBACK 0x00030000
+#define CPU_GEN_SYSTEM_RESET 0x00000001
+//#define CPU_GEN_FIRMWARE_RESET 0x00000008
+//#define CPU_GEN_BOOT_RDY 0x00000010
+//#define CPU_GEN_FIRM_RDY 0x00000020
+//#define CPU_GEN_PUT_CODE_OK 0x00000080
+//#define CPU_GEN_BB_RST 0x00000100
+//#define CPU_GEN_PWR_STB_CPU 0x00000004
+//#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19
+//#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1
+
+//----------------------------------------------------------------------------
+// 8192S EEROM
+//----------------------------------------------------------------------------
+
+//#define RTL8190_EEPROM_ID 0x8129
+//#define EEPROM_VID 0x08
+//#define EEPROM_PID 0x0A
+//#define EEPROM_USB_OPTIONAL 0x0C
+//#define EEPROM_NODE_ADDRESS_BYTE_0 0x12
+//
+//#define EEPROM_TxPowerDiff 0x1F
+//#define EEPROM_ThermalMeter 0x20
+//#define EEPROM_PwDiff 0x21 //0x21
+//#define EEPROM_CrystalCap 0x22 //0x22
+//
+//#define EEPROM_TxPwIndex_CCK 0x23 //0x23
+//#define EEPROM_TxPwIndex_OFDM_24G 0x24 //0x24~0x26
+#define EEPROM_TxPwIndex_CCK_V1 0x29 //0x29~0x2B
+#define EEPROM_TxPwIndex_OFDM_24G_V1 0x2C //0x2C~0x2E
+#define EEPROM_TxPwIndex_Ver 0x27 //0x27
+//
+//#define EEPROM_Default_TxPowerDiff 0x0
+//#define EEPROM_Default_ThermalMeter 0x7
+//#define EEPROM_Default_PwDiff 0x4
+//#define EEPROM_Default_CrystalCap 0x5
+//#define EEPROM_Default_TxPower 0x1010
+//#define EEPROM_Customer_ID 0x7B //0x7B:CustomerID
+//#define EEPROM_Version 0x50 // 0x50
+//#define EEPROM_CustomID 0x52
+//#define EEPROM_ChannelPlan 0x7c //0x7C
+//#define EEPROM_IC_VER 0x7d //0x7D
+//#define EEPROM_CRC 0x7e //0x7E~0x7F
+//
+//
+//#define EEPROM_CID_DEFAULT 0x0
+//#define EEPROM_CID_CAMEO 0x1
+//#define EEPROM_CID_RUNTOP 0x2
+//#define EEPROM_CID_Senao 0x3
+//#define EEPROM_CID_TOSHIBA 0x4 // Toshiba setting, Merge by Jacken, 2008/01/31
+//#define EEPROM_CID_NetCore 0x5
+
+
+//
+//--------------92SU require delete or move to other place later
+//
+
+//============================================================
+// CCX Related Register
+//============================================================
+#define CCX_COMMAND_REG 0x890
+// CCX Measurement Command Register. 4 Bytes.
+// Bit[0]: R_CLM_En, 1=enable, 0=disable. Enable or disable "Channel Load
+// Measurement (CLM)".
+// Bit[1]: R_NHM_En, 1=enable, 0=disable. Enable or disalbe "Noise Histogram
+// Measurement (NHM)".
+// Bit[2~7]: Reserved
+// Bit[8]: R_CCX_En: 1=enable, 0=disable. Enable or disable CCX function.
+// Note: After clearing this bit, all the result of all NHM_Result and CLM_
+// Result are cleared concurrently.
+// Bit[9]: R_Ignore_CCA: 1=enable, 0=disable. Enable means that treat CCA
+// period as idle time for NHM.
+// Bit[10]: R_Ignore_TXON: 1=enable, 0=disable. Enable means that treat TXON
+// period as idle time for NHM.
+// Bit[11~31]: Reserved.
+#define CLM_PERIOD_REG 0x894
+// CCX Measurement Period Register, in unit of 4us. 2 Bytes.
+#define NHM_PERIOD_REG 0x896
+// Noise Histogram Measurement Period Register, in unit of 4us. 2Bytes.
+#define NHM_THRESHOLD0 0x898 // Noise Histogram Meashorement0
+#define NHM_THRESHOLD1 0x899 // Noise Histogram Meashorement1
+#define NHM_THRESHOLD2 0x89A // Noise Histogram Meashorement2
+#define NHM_THRESHOLD3 0x89B // Noise Histogram Meashorement3
+#define NHM_THRESHOLD4 0x89C // Noise Histogram Meashorement4
+#define NHM_THRESHOLD5 0x89D // Noise Histogram Meashorement5
+#define NHM_THRESHOLD6 0x89E // Noise Histogram Meashorement6
+#define CLM_RESULT_REG 0x8D0
+// Channel Load result register. 4 Bytes.
+// Bit[0~15]: Total measured duration of CLM. The CCA busy fraction is caculate
+// by CLM_RESULT_REG/CLM_PERIOD_REG.
+// Bit[16]: Indicate the CLM result is ready.
+// Bit[17~31]: Reserved.
+#define NHM_RESULT_REG 0x8D4
+// Noise Histogram result register. 4 Bytes.
+// Bit[0~15]: Total measured duration of NHM. If R_Ignore_CCA=1 or
+// R_Ignore_TXON=1, this value will be less than NHM_PERIOD_REG.
+// Bit[16]: Indicate the NHM result is ready.
+// Bit[17~31]: Reserved.
+#define NHM_RPI_COUNTER0 0x8D8
+// NHM RPI counter0, the fraction of signal strength < NHM_THRESHOLD0.
+#define NHM_RPI_COUNTER1 0x8D9
+// NHM RPI counter1, the fraction of signal stren in NHM_THRESH0, NHM_THRESH1
+#define NHM_RPI_COUNTER2 0x8DA
+// NHM RPI counter2, the fraction of signal stren in NHM_THRESH2, NHM_THRESH3
+#define NHM_RPI_COUNTER3 0x8DB
+// NHM RPI counter3, the fraction of signal stren in NHM_THRESH4, NHM_THRESH5
+#define NHM_RPI_COUNTER4 0x8DC
+// NHM RPI counter4, the fraction of signal stren in NHM_THRESH6, NHM_THRESH7
+#define NHM_RPI_COUNTER5 0x8DD
+// NHM RPI counter5, the fraction of signal stren in NHM_THRESH8, NHM_THRESH9
+#define NHM_RPI_COUNTER6 0x8DE
+// NHM RPI counter6, the fraction of signal stren in NHM_THRESH10, NHM_THRESH11
+#define NHM_RPI_COUNTER7 0x8DF
+// NHM RPI counter7, the fraction of signal stren in NHM_THRESH12, NHM_THRESH13
+
+#define HAL_RETRY_LIMIT_INFRA 48
+#define HAL_RETRY_LIMIT_AP_ADHOC 7
+
+// HW Readio OFF switch (GPIO BIT)
+#define HAL_8192S_HW_GPIO_OFF_BIT BIT3
+#define HAL_8192S_HW_GPIO_OFF_MASK 0xF7
+#define HAL_8192S_HW_GPIO_WPS_BIT BIT4
+
+#endif //R8192S_HW
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/drivers/staging/rtl8192su/r8192S_phy.c b/drivers/staging/rtl8192su/r8192S_phy.c
new file mode 100644
index 000000000000..99a4051a8458
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_phy.c
@@ -0,0 +1,5028 @@
+/******************************************************************************
+
+ (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
+
+ Module: hal8192sphy.c
+
+ Note: Merge 92SE/SU PHY config as below
+ 1. BB register R/W API
+ 2. RF register R/W API
+ 3. Initial BB/RF/MAC config by reading BB/MAC/RF txt.
+ 3. Power setting API
+ 4. Channel switch API
+ 5. Initial gain switch API.
+ 6. Other BB/MAC/RF API.
+
+ Function: PHY: Extern function, phy: local function
+
+ Export: PHY_FunctionName
+
+ Abbrev: NONE
+
+ History:
+ Data Who Remark
+ 08/08/2008 MHC 1. Port from 9x series phycfg.c
+ 2. Reorganize code arch and ad description.
+ 3. Collect similar function.
+ 4. Seperate extern/local API.
+ 08/12/2008 MHC We must merge or move USB PHY relative function later.
+ 10/07/2008 MHC Add IQ calibration for PHY.(Only 1T2R mode now!!!)
+ 11/06/2008 MHC Add TX Power index PG file to config in 0xExx register
+ area to map with EEPROM/EFUSE tx pwr index.
+
+******************************************************************************/
+#include "r8192U.h"
+#include "r8192U_dm.h"
+#include "r8192S_rtl6052.h"
+
+#ifdef RTL8192SU
+#include "r8192S_hw.h"
+#include "r8192S_phy.h"
+#include "r8192S_phyreg.h"
+#include "r8192SU_HWImg.h"
+//#include "r8192S_FwImgDTM.h"
+#else
+#include "r8192U_hw.h"
+#include "r819xU_phy.h"
+#include "r819xU_phyreg.h"
+#endif
+
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+
+/*---------------------------Define Local Constant---------------------------*/
+/* Channel switch:The size of command tables for switch channel*/
+#define MAX_PRECMD_CNT 16
+#define MAX_RFDEPENDCMD_CNT 16
+#define MAX_POSTCMD_CNT 16
+#define MAX_DOZE_WAITING_TIMES_9x 64
+
+/*------------------------Define local variable------------------------------*/
+// 2004-05-11
+#ifndef RTL8192SU
+static u32 RF_CHANNEL_TABLE_ZEBRA[]={
+ 0,
+ 0x085c,//2412 1
+ 0x08dc,//2417 2
+ 0x095c,//2422 3
+ 0x09dc,//2427 4
+ 0x0a5c,//2432 5
+ 0x0adc,//2437 6
+ 0x0b5c,//2442 7
+ 0x0bdc,//2447 8
+ 0x0c5c,//2452 9
+ 0x0cdc,//2457 10
+ 0x0d5c,//2462 11
+ 0x0ddc,//2467 12
+ 0x0e5c,//2472 13
+ //0x0f5c,//2484
+ 0x0f72,//2484 //20040810
+};
+#endif
+
+static u32
+phy_CalculateBitShift(u32 BitMask);
+static RT_STATUS
+phy_ConfigMACWithHeaderFile(struct net_device* dev);
+static void
+phy_InitBBRFRegisterDefinition(struct net_device* dev);
+static RT_STATUS
+phy_BB8192S_Config_ParaFile(struct net_device* dev);
+static RT_STATUS
+phy_ConfigBBWithHeaderFile(struct net_device* dev,u8 ConfigType);
+static bool
+phy_SetRFPowerState8192SU(struct net_device* dev,RT_RF_POWER_STATE eRFPowerState);
+void
+SetBWModeCallback8192SUsbWorkItem(struct net_device *dev);
+void
+SetBWModeCallback8192SUsbWorkItem(struct net_device *dev);
+void
+SwChnlCallback8192SUsbWorkItem(struct net_device *dev );
+static void
+phy_FinishSwChnlNow(struct net_device* dev,u8 channel);
+static bool
+phy_SwChnlStepByStep(
+ struct net_device* dev,
+ u8 channel,
+ u8 *stage,
+ u8 *step,
+ u32 *delay
+ );
+static RT_STATUS
+phy_ConfigBBWithPgHeaderFile(struct net_device* dev,u8 ConfigType);
+#ifdef RTL8192SE
+static u32 phy_FwRFSerialRead( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset);
+static u32 phy_RFSerialRead(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset);
+static void phy_FwRFSerialWrite( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data);
+static void phy_RFSerialWrite( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data);
+#endif
+static long phy_TxPwrIdxToDbm( struct net_device* dev, WIRELESS_MODE WirelessMode, u8 TxPwrIdx);
+static u8 phy_DbmToTxPwrIdx( struct net_device* dev, WIRELESS_MODE WirelessMode, long PowerInDbm);
+void phy_SetFwCmdIOCallback(struct net_device* dev);
+
+//#if ((HAL_CODE_BASE == RTL8192_S) && (DEV_BUS_TYPE==USB_INTERFACE))
+#ifdef RTL8192SU
+//
+// Description:
+// Base Band read by 4181 to make sure that operation could be done in unlimited cycle.
+//
+// Assumption:
+// - Only use on RTL8192S USB interface.
+// - PASSIVE LEVEL
+//
+// Created by Roger, 2008.09.06.
+//
+//use in phy only
+u32 phy_QueryUsbBBReg(struct net_device* dev, u32 RegAddr)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 ReturnValue = 0xffffffff;
+ u8 PollingCnt = 50;
+ u8 BBWaitCounter = 0;
+
+
+ //
+ // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
+ // We have to make sure that previous BB I/O has been done.
+ // 2008.08.20.
+ //
+ while(priv->bChangeBBInProgress)
+ {
+ BBWaitCounter ++;
+ RT_TRACE(COMP_RF, "phy_QueryUsbBBReg(): Wait 1 ms (%d times)...\n", BBWaitCounter);
+ msleep(1); // 1 ms
+
+ // Wait too long, return FALSE to avoid to be stuck here.
+ if((BBWaitCounter > 100) )//||RT_USB_CANNOT_IO(Adapter))
+ {
+ RT_TRACE(COMP_RF, "phy_QueryUsbBBReg(): (%d) Wait too logn to query BB!!\n", BBWaitCounter);
+ return ReturnValue;
+ }
+ }
+
+ priv->bChangeBBInProgress = true;
+
+ read_nic_dword(dev, RegAddr);
+
+ do
+ {// Make sure that access could be done.
+ if((read_nic_byte(dev, PHY_REG)&HST_RDBUSY) == 0)
+ break;
+ }while( --PollingCnt );
+
+ if(PollingCnt == 0)
+ {
+ RT_TRACE(COMP_RF, "Fail!!!phy_QueryUsbBBReg(): RegAddr(%#x) = %#x\n", RegAddr, ReturnValue);
+ }
+ else
+ {
+ // Data FW read back.
+ ReturnValue = read_nic_dword(dev, PHY_REG_DATA);
+ RT_TRACE(COMP_RF, "phy_QueryUsbBBReg(): RegAddr(%#x) = %#x, PollingCnt(%d)\n", RegAddr, ReturnValue, PollingCnt);
+ }
+
+ priv->bChangeBBInProgress = false;
+
+ return ReturnValue;
+}
+
+
+
+//
+// Description:
+// Base Band wrote by 4181 to make sure that operation could be done in unlimited cycle.
+//
+// Assumption:
+// - Only use on RTL8192S USB interface.
+// - PASSIVE LEVEL
+//
+// Created by Roger, 2008.09.06.
+//
+//use in phy only
+void
+phy_SetUsbBBReg(struct net_device* dev,u32 RegAddr,u32 Data)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 BBWaitCounter = 0;
+
+ RT_TRACE(COMP_RF, "phy_SetUsbBBReg(): RegAddr(%#x) <= %#x\n", RegAddr, Data);
+
+ //
+ // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
+ // We have to make sure that previous BB I/O has been done.
+ // 2008.08.20.
+ //
+ while(priv->bChangeBBInProgress)
+ {
+ BBWaitCounter ++;
+ RT_TRACE(COMP_RF, "phy_SetUsbBBReg(): Wait 1 ms (%d times)...\n", BBWaitCounter);
+ msleep(1); // 1 ms
+
+ if((BBWaitCounter > 100))// || RT_USB_CANNOT_IO(Adapter))
+ {
+ RT_TRACE(COMP_RF, "phy_SetUsbBBReg(): (%d) Wait too logn to query BB!!\n", BBWaitCounter);
+ return;
+ }
+ }
+
+ priv->bChangeBBInProgress = true;
+ //printk("**************%s: RegAddr:%x Data:%x\n", __FUNCTION__,RegAddr, Data);
+ write_nic_dword(dev, RegAddr, Data);
+
+ priv->bChangeBBInProgress = false;
+}
+
+
+
+//
+// Description:
+// RF read by 4181 to make sure that operation could be done in unlimited cycle.
+//
+// Assumption:
+// - Only use on RTL8192S USB interface.
+// - PASSIVE LEVEL
+// - RT_RF_OPERATE_SPINLOCK is acquired and keep on holding to the end.FIXLZM
+//
+// Created by Roger, 2008.09.06.
+//
+//use in phy only
+u32 phy_QueryUsbRFReg( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //u32 value = 0, ReturnValue = 0;
+ u32 ReturnValue = 0;
+ //u32 tmplong,tmplong2;
+ u8 PollingCnt = 50;
+ u8 RFWaitCounter = 0;
+
+
+ //
+ // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
+ // We have to make sure that previous RF I/O has been done.
+ // 2008.08.20.
+ //
+ while(priv->bChangeRFInProgress)
+ {
+ //PlatformReleaseSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+ //spin_lock_irqsave(&priv->rf_lock, flags); //LZM,090318
+ down(&priv->rf_sem);
+
+ RFWaitCounter ++;
+ RT_TRACE(COMP_RF, "phy_QueryUsbRFReg(): Wait 1 ms (%d times)...\n", RFWaitCounter);
+ msleep(1); // 1 ms
+
+ if((RFWaitCounter > 100)) //|| RT_USB_CANNOT_IO(Adapter))
+ {
+ RT_TRACE(COMP_RF, "phy_QueryUsbRFReg(): (%d) Wait too logn to query BB!!\n", RFWaitCounter);
+ return 0xffffffff;
+ }
+ else
+ {
+ //PlatformAcquireSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+ }
+ }
+
+ priv->bChangeRFInProgress = true;
+ //PlatformReleaseSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+
+
+ Offset &= 0x3f; //RF_Offset= 0x00~0x3F
+
+ write_nic_dword(dev, RF_BB_CMD_ADDR, 0xF0000002|
+ (Offset<<8)| //RF_Offset= 0x00~0x3F
+ (eRFPath<<16)); //RF_Path = 0(A) or 1(B)
+
+ do
+ {// Make sure that access could be done.
+ if(read_nic_dword(dev, RF_BB_CMD_ADDR) == 0)
+ break;
+ }while( --PollingCnt );
+
+ // Data FW read back.
+ ReturnValue = read_nic_dword(dev, RF_BB_CMD_DATA);
+
+ //PlatformAcquireSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+ //spin_unlock_irqrestore(&priv->rf_lock, flags); //LZM,090318
+ up(&priv->rf_sem);
+ priv->bChangeRFInProgress = false;
+
+ RT_TRACE(COMP_RF, "phy_QueryUsbRFReg(): eRFPath(%d), Offset(%#x) = %#x\n", eRFPath, Offset, ReturnValue);
+
+ return ReturnValue;
+
+}
+
+
+//
+// Description:
+// RF wrote by 4181 to make sure that operation could be done in unlimited cycle.
+//
+// Assumption:
+// - Only use on RTL8192S USB interface.
+// - PASSIVE LEVEL
+// - RT_RF_OPERATE_SPINLOCK is acquired and keep on holding to the end.FIXLZM
+//
+// Created by Roger, 2008.09.06.
+//
+//use in phy only
+void phy_SetUsbRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 RegAddr,u32 Data)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 PollingCnt = 50;
+ u8 RFWaitCounter = 0;
+
+
+ //
+ // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
+ // We have to make sure that previous BB I/O has been done.
+ // 2008.08.20.
+ //
+ while(priv->bChangeRFInProgress)
+ {
+ //PlatformReleaseSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+ //spin_lock_irqsave(&priv->rf_lock, flags); //LZM,090318
+ down(&priv->rf_sem);
+
+ RFWaitCounter ++;
+ RT_TRACE(COMP_RF, "phy_SetUsbRFReg(): Wait 1 ms (%d times)...\n", RFWaitCounter);
+ msleep(1); // 1 ms
+
+ if((RFWaitCounter > 100))// || RT_USB_CANNOT_IO(Adapter))
+ {
+ RT_TRACE(COMP_RF, "phy_SetUsbRFReg(): (%d) Wait too logn to query BB!!\n", RFWaitCounter);
+ return;
+ }
+ else
+ {
+ //PlatformAcquireSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+ }
+ }
+
+ priv->bChangeRFInProgress = true;
+ //PlatformReleaseSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+
+
+ RegAddr &= 0x3f; //RF_Offset= 0x00~0x3F
+
+ write_nic_dword(dev, RF_BB_CMD_DATA, Data);
+ write_nic_dword(dev, RF_BB_CMD_ADDR, 0xF0000003|
+ (RegAddr<<8)| //RF_Offset= 0x00~0x3F
+ (eRFPath<<16)); //RF_Path = 0(A) or 1(B)
+
+ do
+ {// Make sure that access could be done.
+ if(read_nic_dword(dev, RF_BB_CMD_ADDR) == 0)
+ break;
+ }while( --PollingCnt );
+
+ if(PollingCnt == 0)
+ {
+ RT_TRACE(COMP_RF, "phy_SetUsbRFReg(): Set RegAddr(%#x) = %#x Fail!!!\n", RegAddr, Data);
+ }
+
+ //PlatformAcquireSpinLock(Adapter, RT_RF_OPERATE_SPINLOCK);
+ //spin_unlock_irqrestore(&priv->rf_lock, flags); //LZM,090318
+ up(&priv->rf_sem);
+ priv->bChangeRFInProgress = false;
+
+}
+
+#endif
+
+/*---------------------Define local function prototype-----------------------*/
+
+
+/*----------------------------Function Body----------------------------------*/
+//
+// 1. BB register R/W API
+//
+/**
+* Function: PHY_QueryBBReg
+*
+* OverView: Read "sepcific bits" from BB register
+*
+* Input:
+* PADAPTER Adapter,
+* u32 RegAddr, //The target address to be readback
+* u32 BitMask //The target bit position in the target address
+* //to be readback
+* Output: None
+* Return: u32 Data //The readback register value
+* Note: This function is equal to "GetRegSetting" in PHY programming guide
+*/
+//use phy dm core 8225 8256 6052
+//u32 PHY_QueryBBReg(struct net_device* dev,u32 RegAddr, u32 BitMask)
+u32 rtl8192_QueryBBReg(struct net_device* dev, u32 RegAddr, u32 BitMask)
+{
+
+ u32 ReturnValue = 0, OriginalValue, BitShift;
+
+#if (DISABLE_BB_RF == 1)
+ return 0;
+#endif
+
+ RT_TRACE(COMP_RF, "--->PHY_QueryBBReg(): RegAddr(%#x), BitMask(%#x)\n", RegAddr, BitMask);
+
+ //
+ // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
+ // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
+ // infinite cycle.
+ // 2008.09.06.
+ //
+//#if ((HAL_CODE_BASE == RTL8192_S) && (DEV_BUS_TYPE==USB_INTERFACE))
+#ifdef RTL8192SU
+ if(IS_BB_REG_OFFSET_92S(RegAddr))
+ {
+ //if(RT_USB_CANNOT_IO(Adapter)) return FALSE;
+
+ if((RegAddr & 0x03) != 0)
+ {
+ printk("%s: Not DWORD alignment!!\n", __FUNCTION__);
+ return 0;
+ }
+
+ OriginalValue = phy_QueryUsbBBReg(dev, RegAddr);
+ }
+ else
+#endif
+ {
+ OriginalValue = read_nic_dword(dev, RegAddr);
+ }
+
+ BitShift = phy_CalculateBitShift(BitMask);
+ ReturnValue = (OriginalValue & BitMask) >> BitShift;
+
+ //RTPRINT(FPHY, PHY_BBR, ("BBR MASK=0x%x Addr[0x%x]=0x%x\n", BitMask, RegAddr, OriginalValue));
+ RT_TRACE(COMP_RF, "<---PHY_QueryBBReg(): RegAddr(%#x), BitMask(%#x), OriginalValue(%#x)\n", RegAddr, BitMask, OriginalValue);
+ return (ReturnValue);
+}
+
+/**
+* Function: PHY_SetBBReg
+*
+* OverView: Write "Specific bits" to BB register (page 8~)
+*
+* Input:
+* PADAPTER Adapter,
+* u32 RegAddr, //The target address to be modified
+* u32 BitMask //The target bit position in the target address
+* //to be modified
+* u32 Data //The new register value in the target bit position
+* //of the target address
+*
+* Output: None
+* Return: None
+* Note: This function is equal to "PutRegSetting" in PHY programming guide
+*/
+//use phy dm core 8225 8256
+//void PHY_SetBBReg(struct net_device* dev,u32 RegAddr, u32 BitMask, u32 Data )
+void rtl8192_setBBreg(struct net_device* dev, u32 RegAddr, u32 BitMask, u32 Data)
+{
+ u32 OriginalValue, BitShift, NewValue;
+
+#if (DISABLE_BB_RF == 1)
+ return;
+#endif
+
+ RT_TRACE(COMP_RF, "--->PHY_SetBBReg(): RegAddr(%#x), BitMask(%#x), Data(%#x)\n", RegAddr, BitMask, Data);
+
+ //
+ // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
+ // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
+ // infinite cycle.
+ // 2008.09.06.
+ //
+//#if ((HAL_CODE_BASE == RTL8192_S) && (DEV_BUS_TYPE==USB_INTERFACE))
+#ifdef RTL8192SU
+ if(IS_BB_REG_OFFSET_92S(RegAddr))
+ {
+ if((RegAddr & 0x03) != 0)
+ {
+ printk("%s: Not DWORD alignment!!\n", __FUNCTION__);
+ return;
+ }
+
+ if(BitMask!= bMaskDWord)
+ {//if not "double word" write
+ OriginalValue = phy_QueryUsbBBReg(dev, RegAddr);
+ BitShift = phy_CalculateBitShift(BitMask);
+ NewValue = (((OriginalValue) & (~BitMask))|(Data << BitShift));
+ phy_SetUsbBBReg(dev, RegAddr, NewValue);
+ }else
+ phy_SetUsbBBReg(dev, RegAddr, Data);
+ }
+ else
+#endif
+ {
+ if(BitMask!= bMaskDWord)
+ {//if not "double word" write
+ OriginalValue = read_nic_dword(dev, RegAddr);
+ BitShift = phy_CalculateBitShift(BitMask);
+ NewValue = (((OriginalValue) & (~BitMask)) | (Data << BitShift));
+ write_nic_dword(dev, RegAddr, NewValue);
+ }else
+ write_nic_dword(dev, RegAddr, Data);
+ }
+
+ //RT_TRACE(COMP_RF, "<---PHY_SetBBReg(): RegAddr(%#x), BitMask(%#x), Data(%#x)\n", RegAddr, BitMask, Data);
+
+ return;
+}
+
+
+//
+// 2. RF register R/W API
+//
+/**
+* Function: PHY_QueryRFReg
+*
+* OverView: Query "Specific bits" to RF register (page 8~)
+*
+* Input:
+* PADAPTER Adapter,
+* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
+* u32 RegAddr, //The target address to be read
+* u32 BitMask //The target bit position in the target address
+* //to be read
+*
+* Output: None
+* Return: u32 Readback value
+* Note: This function is equal to "GetRFRegSetting" in PHY programming guide
+*/
+//in dm 8256 and phy
+//u32 PHY_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask)
+u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask)
+{
+ u32 Original_Value, Readback_Value, BitShift;//, flags;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+#if (DISABLE_BB_RF == 1)
+ return 0;
+#endif
+
+ RT_TRACE(COMP_RF, "--->PHY_QueryRFReg(): RegAddr(%#x), eRFPath(%#x), BitMask(%#x)\n", RegAddr, eRFPath,BitMask);
+
+ if (!((priv->rf_pathmap >> eRFPath) & 0x1))
+ {
+ printk("EEEEEError: rfpath off! rf_pathmap=%x eRFPath=%x\n", priv->rf_pathmap, eRFPath);
+ return 0;
+ }
+
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ {
+ printk("EEEEEError: not legal rfpath! eRFPath=%x\n", eRFPath);
+ return 0;
+ }
+
+ /* 2008/01/17 MH We get and release spin lock when reading RF register. */
+ //PlatformAcquireSpinLock(dev, RT_RF_OPERATE_SPINLOCK);FIXLZM
+ //spin_lock_irqsave(&priv->rf_lock, flags); //YJ,test,090113
+ down(&priv->rf_sem);
+ //
+ // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
+ // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
+ // infinite cycle.
+ // 2008.09.06.
+ //
+//#if (HAL_CODE_BASE == RTL8192_S && DEV_BUS_TYPE==USB_INTERFACE)
+#ifdef RTL8192SU
+ //if(RT_USB_CANNOT_IO(Adapter)) return FALSE;
+ Original_Value = phy_QueryUsbRFReg(dev, eRFPath, RegAddr);
+#else
+ if (priv->Rf_Mode == RF_OP_By_FW)
+ {
+ Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr);
+ }
+ else
+ {
+ Original_Value = phy_RFSerialRead(dev, eRFPath, RegAddr);
+ }
+#endif
+
+ BitShift = phy_CalculateBitShift(BitMask);
+ Readback_Value = (Original_Value & BitMask) >> BitShift;
+ //spin_unlock_irqrestore(&priv->rf_lock, flags); //YJ,test,090113
+ up(&priv->rf_sem);
+ //PlatformReleaseSpinLock(dev, RT_RF_OPERATE_SPINLOCK);
+
+ //RTPRINT(FPHY, PHY_RFR, ("RFR-%d MASK=0x%x Addr[0x%x]=0x%x\n", eRFPath, BitMask, RegAddr, Original_Value));
+
+ return (Readback_Value);
+}
+
+/**
+* Function: PHY_SetRFReg
+*
+* OverView: Write "Specific bits" to RF register (page 8~)
+*
+* Input:
+* PADAPTER Adapter,
+* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
+* u32 RegAddr, //The target address to be modified
+* u32 BitMask //The target bit position in the target address
+* //to be modified
+* u32 Data //The new register Data in the target bit position
+* //of the target address
+*
+* Output: None
+* Return: None
+* Note: This function is equal to "PutRFRegSetting" in PHY programming guide
+*/
+//use phy 8225 8256
+//void PHY_SetRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask,u32 Data )
+void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 Original_Value, BitShift, New_Value;//, flags;
+#if (DISABLE_BB_RF == 1)
+ return;
+#endif
+
+ RT_TRACE(COMP_RF, "--->PHY_SetRFReg(): RegAddr(%#x), BitMask(%#x), Data(%#x), eRFPath(%#x)\n",
+ RegAddr, BitMask, Data, eRFPath);
+
+ if (!((priv->rf_pathmap >> eRFPath) & 0x1))
+ {
+ printk("EEEEEError: rfpath off! rf_pathmap=%x eRFPath=%x\n", priv->rf_pathmap, eRFPath);
+ return ;
+ }
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ {
+ printk("EEEEEError: not legal rfpath! eRFPath=%x\n", eRFPath);
+ return;
+ }
+
+ /* 2008/01/17 MH We get and release spin lock when writing RF register. */
+ //PlatformAcquireSpinLock(dev, RT_RF_OPERATE_SPINLOCK);
+ //spin_lock_irqsave(&priv->rf_lock, flags); //YJ,test,090113
+ down(&priv->rf_sem);
+ //
+ // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
+ // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
+ // infinite cycle.
+ // 2008.09.06.
+ //
+//#if (HAL_CODE_BASE == RTL8192_S && DEV_BUS_TYPE==USB_INTERFACE)
+#ifdef RTL8192SU
+ //if(RT_USB_CANNOT_IO(Adapter)) return;
+
+ if (BitMask != bRFRegOffsetMask) // RF data is 12 bits only
+ {
+ Original_Value = phy_QueryUsbRFReg(dev, eRFPath, RegAddr);
+ BitShift = phy_CalculateBitShift(BitMask);
+ New_Value = (((Original_Value)&(~BitMask))|(Data<< BitShift));
+ phy_SetUsbRFReg(dev, eRFPath, RegAddr, New_Value);
+ }
+ else
+ phy_SetUsbRFReg(dev, eRFPath, RegAddr, Data);
+#else
+ if (priv->Rf_Mode == RF_OP_By_FW)
+ {
+ //DbgPrint("eRFPath-%d Addr[%02x] = %08x\n", eRFPath, RegAddr, Data);
+ if (BitMask != bRFRegOffsetMask) // RF data is 12 bits only
+ {
+ Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr);
+ BitShift = phy_CalculateBitShift(BitMask);
+ New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift));
+
+ phy_FwRFSerialWrite(dev, eRFPath, RegAddr, New_Value);
+ }
+ else
+ phy_FwRFSerialWrite(dev, eRFPath, RegAddr, Data);
+ }
+ else
+ {
+ //DbgPrint("eRFPath-%d Addr[%02x] = %08x\n", eRFPath, RegAddr, Data);
+ if (BitMask != bRFRegOffsetMask) // RF data is 12 bits only
+ {
+ Original_Value = phy_RFSerialRead(dev, eRFPath, RegAddr);
+ BitShift = phy_CalculateBitShift(BitMask);
+ New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift));
+
+ phy_RFSerialWrite(dev, eRFPath, RegAddr, New_Value);
+ }
+ else
+ phy_RFSerialWrite(dev, eRFPath, RegAddr, Data);
+
+ }
+#endif
+ //PlatformReleaseSpinLock(dev, RT_RF_OPERATE_SPINLOCK);
+ //spin_unlock_irqrestore(&priv->rf_lock, flags); //YJ,test,090113
+ up(&priv->rf_sem);
+ //RTPRINT(FPHY, PHY_RFW, ("RFW-%d MASK=0x%x Addr[0x%x]=0x%x\n", eRFPath, BitMask, RegAddr, Data));
+ RT_TRACE(COMP_RF, "<---PHY_SetRFReg(): RegAddr(%#x), BitMask(%#x), Data(%#x), eRFPath(%#x)\n",
+ RegAddr, BitMask, Data, eRFPath);
+
+}
+
+#ifdef RTL8192SE
+/*-----------------------------------------------------------------------------
+ * Function: phy_FwRFSerialRead()
+ *
+ * Overview: We support firmware to execute RF-R/W.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 01/21/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+//use in phy only
+static u32
+phy_FwRFSerialRead(
+ struct net_device* dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset )
+{
+ u32 retValue = 0;
+ //u32 Data = 0;
+ //u8 time = 0;
+#if 0
+ //DbgPrint("FW RF CTRL\n\r");
+ /* 2007/11/02 MH Firmware RF Write control. By Francis' suggestion, we can
+ not execute the scheme in the initial step. Otherwise, RF-R/W will waste
+ much time. This is only for site survey. */
+ // 1. Read operation need not insert data. bit 0-11
+ //Data &= bMask12Bits;
+ // 2. Write RF register address. Bit 12-19
+ Data |= ((Offset&0xFF)<<12);
+ // 3. Write RF path. bit 20-21
+ Data |= ((eRFPath&0x3)<<20);
+ // 4. Set RF read indicator. bit 22=0
+ //Data |= 0x00000;
+ // 5. Trigger Fw to operate the command. bit 31
+ Data |= 0x80000000;
+ // 6. We can not execute read operation if bit 31 is 1.
+ while (PlatformIORead4Byte(dev, QPNR)&0x80000000)
+ {
+ // If FW can not finish RF-R/W for more than ?? times. We must reset FW.
+ if (time++ < 100)
+ {
+ //DbgPrint("FW not finish RF-R Time=%d\n\r", time);
+ delay_us(10);
+ }
+ else
+ break;
+ }
+ // 7. Execute read operation.
+ PlatformIOWrite4Byte(dev, QPNR, Data);
+ // 8. Check if firmawre send back RF content.
+ while (PlatformIORead4Byte(dev, QPNR)&0x80000000)
+ {
+ // If FW can not finish RF-R/W for more than ?? times. We must reset FW.
+ if (time++ < 100)
+ {
+ //DbgPrint("FW not finish RF-W Time=%d\n\r", time);
+ delay_us(10);
+ }
+ else
+ return (0);
+ }
+ retValue = PlatformIORead4Byte(dev, RF_DATA);
+#endif
+ return (retValue);
+
+} /* phy_FwRFSerialRead */
+
+/*-----------------------------------------------------------------------------
+ * Function: phy_FwRFSerialWrite()
+ *
+ * Overview: We support firmware to execute RF-R/W.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 01/21/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+//use in phy only
+static void
+phy_FwRFSerialWrite(
+ struct net_device* dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u32 Data )
+{
+#if 0
+ u8 time = 0;
+ DbgPrint("N FW RF CTRL RF-%d OF%02x DATA=%03x\n\r", eRFPath, Offset, Data);
+ /* 2007/11/02 MH Firmware RF Write control. By Francis' suggestion, we can
+ not execute the scheme in the initial step. Otherwise, RF-R/W will waste
+ much time. This is only for site survey. */
+
+ // 1. Set driver write bit and 12 bit data. bit 0-11
+ //Data &= bMask12Bits; // Done by uper layer.
+ // 2. Write RF register address. bit 12-19
+ Data |= ((Offset&0xFF)<<12);
+ // 3. Write RF path. bit 20-21
+ Data |= ((eRFPath&0x3)<<20);
+ // 4. Set RF write indicator. bit 22=1
+ Data |= 0x400000;
+ // 5. Trigger Fw to operate the command. bit 31=1
+ Data |= 0x80000000;
+
+ // 6. Write operation. We can not write if bit 31 is 1.
+ while (PlatformIORead4Byte(dev, QPNR)&0x80000000)
+ {
+ // If FW can not finish RF-R/W for more than ?? times. We must reset FW.
+ if (time++ < 100)
+ {
+ //DbgPrint("FW not finish RF-W Time=%d\n\r", time);
+ delay_us(10);
+ }
+ else
+ break;
+ }
+ // 7. No matter check bit. We always force the write. Because FW will
+ // not accept the command.
+ PlatformIOWrite4Byte(dev, QPNR, Data);
+ /* 2007/11/02 MH Acoording to test, we must delay 20us to wait firmware
+ to finish RF write operation. */
+ /* 2008/01/17 MH We support delay in firmware side now. */
+ //delay_us(20);
+#endif
+} /* phy_FwRFSerialWrite */
+
+/**
+* Function: phy_RFSerialRead
+*
+* OverView: Read regster from RF chips
+*
+* Input:
+* PADAPTER Adapter,
+* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
+* u32 Offset, //The target address to be read
+*
+* Output: None
+* Return: u32 reback value
+* Note: Threre are three types of serial operations:
+* 1. Software serial write
+* 2. Hardware LSSI-Low Speed Serial Interface
+* 3. Hardware HSSI-High speed
+* serial write. Driver need to implement (1) and (2).
+* This function is equal to the combination of RF_ReadReg() and RFLSSIRead()
+*/
+//use in phy only
+static u32 phy_RFSerialRead(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset)
+{
+
+ u32 retValue = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath];
+ u32 NewOffset;
+ u8 RfPiEnable=0;
+
+
+ //
+ // Make sure RF register offset is correct
+ //
+ Offset &= 0x3f;
+
+ //
+ // Switch page for 8256 RF IC
+ //
+ if( priv->rf_chip == RF_8256 ||
+ priv->rf_chip == RF_8225 ||
+ priv->rf_chip == RF_6052)
+ {
+ //analog to digital off, for protection
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0);// 0x88c[11:8]
+
+ if(Offset>=31)
+ {
+ priv->RFReadPageCnt[2]++;//cosa add for debug
+ priv->RfReg0Value[eRFPath] |= 0x140;
+
+ // Switch to Reg_Mode2 for Reg31~45
+ rtl8192_setBBreg(dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16) );
+
+ // Modified Offset
+ NewOffset = Offset - 30;
+
+ }else if(Offset>=16)
+ {
+ priv->RFReadPageCnt[1]++;//cosa add for debug
+ priv->RfReg0Value[eRFPath] |= 0x100;
+ priv->RfReg0Value[eRFPath] &= (~0x40);
+
+ // Switch to Reg_Mode1 for Reg16~30
+ rtl8192_setBBreg(dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16) );
+
+ // Modified Offset
+ NewOffset = Offset - 15;
+ }
+ else
+ {
+ priv->RFReadPageCnt[0]++;//cosa add for debug
+ NewOffset = Offset;
+ }
+ }
+ else
+ NewOffset = Offset;
+
+ //
+ // Put desired read address to LSSI control register
+ //
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset);
+
+ //
+ // Issue a posedge trigger
+ //
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0);
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1);
+
+ // TODO: we should not delay such a long time. Ask help from SD3
+ mdelay(1);
+
+ retValue = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData);
+
+ // Switch back to Reg_Mode0;
+ if( priv->rf_chip == RF_8256 ||
+ priv->rf_chip == RF_8225 ||
+ priv->rf_chip == RF_0222D)
+ {
+ if (Offset >= 0x10)
+ {
+ priv->RfReg0Value[eRFPath] &= 0xebf;
+
+ rtl8192_setBBreg(
+ dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16) );
+ }
+
+ //analog to digital on
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf);// 0x88c[11:8]
+ }
+
+ return retValue;
+}
+
+
+
+/**
+* Function: phy_RFSerialWrite
+*
+* OverView: Write data to RF register (page 8~)
+*
+* Input:
+* PADAPTER Adapter,
+* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
+* u32 Offset, //The target address to be read
+* u32 Data //The new register Data in the target bit position
+* //of the target to be read
+*
+* Output: None
+* Return: None
+* Note: Threre are three types of serial operations:
+* 1. Software serial write
+* 2. Hardware LSSI-Low Speed Serial Interface
+* 3. Hardware HSSI-High speed
+* serial write. Driver need to implement (1) and (2).
+* This function is equal to the combination of RF_ReadReg() and RFLSSIRead()
+ *
+ * Note: For RF8256 only
+ * The total count of RTL8256(Zebra4) register is around 36 bit it only employs
+ * 4-bit RF address. RTL8256 uses "register mode control bit" (Reg00[12], Reg00[10])
+ * to access register address bigger than 0xf. See "Appendix-4 in PHY Configuration
+ * programming guide" for more details.
+ * Thus, we define a sub-finction for RTL8526 register address conversion
+ * ===========================================================
+ * Register Mode RegCTL[1] RegCTL[0] Note
+ * (Reg00[12]) (Reg00[10])
+ * ===========================================================
+ * Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf)
+ * ------------------------------------------------------------------
+ * Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf)
+ * ------------------------------------------------------------------
+ * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf)
+ * ------------------------------------------------------------------
+*/
+////use in phy only
+static void
+phy_RFSerialWrite(
+ struct net_device* dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u32 Data
+ )
+{
+ u32 DataAndAddr = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath];
+ u32 NewOffset;
+
+ Offset &= 0x3f;
+
+ // Shadow Update
+ PHY_RFShadowWrite(dev, eRFPath, Offset, Data);
+
+
+ // Switch page for 8256 RF IC
+ if( priv->rf_chip == RF_8256 ||
+ priv->rf_chip == RF_8225 ||
+ priv->rf_chip == RF_0222D)
+ {
+ //analog to digital off, for protection
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0);// 0x88c[11:8]
+
+ if(Offset>=31)
+ {
+ priv->RFWritePageCnt[2]++;//cosa add for debug
+ priv->RfReg0Value[eRFPath] |= 0x140;
+
+ rtl8192_setBBreg(dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16) );
+
+ NewOffset = Offset - 30;
+
+ }else if(Offset>=16)
+ {
+ priv->RFWritePageCnt[1]++;//cosa add for debug
+ priv->RfReg0Value[eRFPath] |= 0x100;
+ priv->RfReg0Value[eRFPath] &= (~0x40);
+
+
+ rtl8192_setBBreg(dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16) );
+
+ NewOffset = Offset - 15;
+ }
+ else
+ {
+ priv->RFWritePageCnt[0]++;//cosa add for debug
+ NewOffset = Offset;
+ }
+ }
+ else
+ NewOffset = Offset;
+
+ //
+ // Put write addr in [5:0] and write data in [31:16]
+ //
+ DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+
+ //
+ // Write Operation
+ //
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
+
+
+ if(Offset==0x0)
+ priv->RfReg0Value[eRFPath] = Data;
+
+ // Switch back to Reg_Mode0;
+ if( priv->rf_chip == RF_8256 ||
+ priv->rf_chip == RF_8225 ||
+ priv->rf_chip == RF_0222D)
+ {
+ if (Offset >= 0x10)
+ {
+ if(Offset != 0)
+ {
+ priv->RfReg0Value[eRFPath] &= 0xebf;
+ rtl8192_setBBreg(
+ dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16) );
+ }
+ }
+ //analog to digital on
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0xf);// 0x88c[11:8]
+ }
+
+}
+#else
+/**
+* Function: phy_RFSerialRead
+*
+* OverView: Read regster from RF chips
+*
+* Input:
+* PADAPTER Adapter,
+* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
+* u4Byte Offset, //The target address to be read
+*
+* Output: None
+* Return: u4Byte reback value
+* Note: Threre are three types of serial operations:
+* 1. Software serial write
+* 2. Hardware LSSI-Low Speed Serial Interface
+* 3. Hardware HSSI-High speed
+* serial write. Driver need to implement (1) and (2).
+* This function is equal to the combination of RF_ReadReg() and RFLSSIRead()
+*/
+#if 0
+static u32
+phy_RFSerialRead(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset)
+{
+
+ u32 retValue = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath];
+ u32 NewOffset;
+ //u32 value = 0;
+ u32 tmplong,tmplong2;
+ u32 RfPiEnable=0;
+#if 0
+ if(pHalData->RFChipID == RF_8225 && Offset > 0x24) //36 valid regs
+ return retValue;
+ if(pHalData->RFChipID == RF_8256 && Offset > 0x2D) //45 valid regs
+ return retValue;
+#endif
+ //
+ // Make sure RF register offset is correct
+ //
+ Offset &= 0x3f;
+
+ //
+ // Switch page for 8256 RF IC
+ //
+ NewOffset = Offset;
+
+ // For 92S LSSI Read RFLSSIRead
+ // For RF A/B write 0x824/82c(does not work in the future)
+ // We must use 0x824 for RF A and B to execute read trigger
+ tmplong = rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter2, bMaskDWord);
+ tmplong2 = rtl8192_QueryBBReg(dev, pPhyReg->rfHSSIPara2, bMaskDWord);
+ tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; //T65 RF
+
+ rtl8192_setBBreg(dev, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong&(~bLSSIReadEdge));
+ mdelay(1);
+
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2);
+ mdelay(1);
+
+ rtl8192_setBBreg(dev, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong|bLSSIReadEdge);
+ mdelay(1);
+
+ if(eRFPath == RF90_PATH_A)
+ RfPiEnable = (u8)rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter1, BIT8);
+ else if(eRFPath == RF90_PATH_B)
+ RfPiEnable = (u8)rtl8192_QueryBBReg(dev, rFPGA0_XB_HSSIParameter1, BIT8);
+
+ if(RfPiEnable)
+ { // Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF
+ retValue = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBackPi, bLSSIReadBackData);
+ //DbgPrint("Readback from RF-PI : 0x%x\n", retValue);
+ }
+ else
+ { //Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF
+ retValue = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData);
+ //DbgPrint("Readback from RF-SI : 0x%x\n", retValue);
+ }
+ //RTPRINT(FPHY, PHY_RFR, ("RFR-%d Addr[0x%x]=0x%x\n", eRFPath, pPhyReg->rfLSSIReadBack, retValue));
+
+ return retValue;
+
+}
+4
+
+
+/**
+* Function: phy_RFSerialWrite
+*
+* OverView: Write data to RF register (page 8~)
+*
+* Input:
+* PADAPTER Adapter,
+* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
+* u4Byte Offset, //The target address to be read
+* u4Byte Data //The new register Data in the target bit position
+* //of the target to be read
+*
+* Output: None
+* Return: None
+* Note: Threre are three types of serial operations:
+* 1. Software serial write
+* 2. Hardware LSSI-Low Speed Serial Interface
+* 3. Hardware HSSI-High speed
+* serial write. Driver need to implement (1) and (2).
+* This function is equal to the combination of RF_ReadReg() and RFLSSIRead()
+ *
+ * Note: For RF8256 only
+ * The total count of RTL8256(Zebra4) register is around 36 bit it only employs
+ * 4-bit RF address. RTL8256 uses "register mode control bit" (Reg00[12], Reg00[10])
+ * to access register address bigger than 0xf. See "Appendix-4 in PHY Configuration
+ * programming guide" for more details.
+ * Thus, we define a sub-finction for RTL8526 register address conversion
+ * ===========================================================
+ * Register Mode RegCTL[1] RegCTL[0] Note
+ * (Reg00[12]) (Reg00[10])
+ * ===========================================================
+ * Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf)
+ * ------------------------------------------------------------------
+ * Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf)
+ * ------------------------------------------------------------------
+ * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf)
+ * ------------------------------------------------------------------
+ *
+ * 2008/09/02 MH Add 92S RF definition
+ *
+ *
+ *
+*/
+static void
+phy_RFSerialWrite(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 Offset,u32 Data)
+{
+ u32 DataAndAddr = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath];
+ u32 NewOffset;
+
+#if 0
+ //<Roger_TODO> We should check valid regs for RF_6052 case.
+ if(pHalData->RFChipID == RF_8225 && Offset > 0x24) //36 valid regs
+ return;
+ if(pHalData->RFChipID == RF_8256 && Offset > 0x2D) //45 valid regs
+ return;
+#endif
+
+ Offset &= 0x3f;
+
+ //
+ // Shadow Update
+ //
+ PHY_RFShadowWrite(dev, eRFPath, Offset, Data);
+
+ //
+ // Switch page for 8256 RF IC
+ //
+ NewOffset = Offset;
+
+ //
+ // Put write addr in [5:0] and write data in [31:16]
+ //
+ //DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+ DataAndAddr = ((NewOffset<<20) | (Data&0x000fffff)) & 0x0fffffff; // T65 RF
+
+ //
+ // Write Operation
+ //
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
+ //RTPRINT(FPHY, PHY_RFW, ("RFW-%d Addr[0x%x]=0x%x\n", eRFPath, pPhyReg->rf3wireOffset, DataAndAddr));
+
+}
+#endif
+#endif
+
+/**
+* Function: phy_CalculateBitShift
+*
+* OverView: Get shifted position of the BitMask
+*
+* Input:
+* u32 BitMask,
+*
+* Output: none
+* Return: u32 Return the shift bit bit position of the mask
+*/
+//use in phy only
+static u32 phy_CalculateBitShift(u32 BitMask)
+{
+ u32 i;
+
+ for(i=0; i<=31; i++)
+ {
+ if ( ((BitMask>>i) & 0x1 ) == 1)
+ break;
+ }
+
+ return (i);
+}
+
+
+//
+// 3. Initial MAC/BB/RF config by reading MAC/BB/RF txt.
+//
+/*-----------------------------------------------------------------------------
+ * Function: PHY_MACConfig8192S
+ *
+ * Overview: Condig MAC by header file or parameter file.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 08/12/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+//adapter_start
+extern bool PHY_MACConfig8192S(struct net_device* dev)
+{
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+
+ //
+ // Config MAC
+ //
+#if RTL8190_Download_Firmware_From_Header
+ rtStatus = phy_ConfigMACWithHeaderFile(dev);
+#else
+ // Not make sure EEPROM, add later
+ RT_TRACE(COMP_INIT, "Read MACREG.txt\n");
+ //rtStatus = phy_ConfigMACWithParaFile(dev, RTL819X_PHY_MACREG);// lzm del it temp
+#endif
+ return (rtStatus == RT_STATUS_SUCCESS) ? true:false;
+
+}
+
+//adapter_start
+extern bool
+PHY_BBConfig8192S(struct net_device* dev)
+{
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+
+ u8 PathMap = 0, index = 0, rf_num = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ phy_InitBBRFRegisterDefinition(dev);
+
+ //
+ // Config BB and AGC
+ //
+ //switch( Adapter->MgntInfo.bRegHwParaFile )
+ //{
+ // case 0:
+ // phy_BB8190_Config_HardCode(dev);
+ // break;
+
+ // case 1:
+ rtStatus = phy_BB8192S_Config_ParaFile(dev);
+ // break;
+
+ // case 2:
+ // Partial Modify.
+ // phy_BB8190_Config_HardCode(dev);
+ // phy_BB8192S_Config_ParaFile(dev);
+ // break;
+
+ // default:
+ // phy_BB8190_Config_HardCode(dev);
+ // break;
+ //}
+ PathMap = (u8)(rtl8192_QueryBBReg(dev, rFPGA0_TxInfo, 0xf) |
+ rtl8192_QueryBBReg(dev, rOFDM0_TRxPathEnable, 0xf));
+ priv->rf_pathmap = PathMap;
+ for(index = 0; index<4; index++)
+ {
+ if((PathMap>>index)&0x1)
+ rf_num++;
+ }
+
+ if((priv->rf_type==RF_1T1R && rf_num!=1) ||
+ (priv->rf_type==RF_1T2R && rf_num!=2) ||
+ (priv->rf_type==RF_2T2R && rf_num!=2) ||
+ (priv->rf_type==RF_2T2R_GREEN && rf_num!=2) ||
+ (priv->rf_type==RF_2T4R && rf_num!=4))
+ {
+ RT_TRACE( COMP_INIT, "PHY_BBConfig8192S: RF_Type(%x) does not match RF_Num(%x)!!\n", priv->rf_type, rf_num);
+ }
+ return (rtStatus == RT_STATUS_SUCCESS) ? 1:0;
+}
+
+//adapter_start
+extern bool
+PHY_RFConfig8192S(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+
+ //Set priv->rf_chip = RF_8225 to do real PHY FPGA initilization
+
+ //<Roger_EXP> We assign RF type here temporally. 2008.09.12.
+ priv->rf_chip = RF_6052;
+
+ //
+ // RF config
+ //
+ switch(priv->rf_chip)
+ {
+ case RF_8225:
+ case RF_6052:
+ rtStatus = PHY_RF6052_Config(dev);
+ break;
+
+ case RF_8256:
+ //rtStatus = PHY_RF8256_Config(dev);
+ break;
+
+ case RF_8258:
+ break;
+
+ case RF_PSEUDO_11N:
+ //rtStatus = PHY_RF8225_Config(dev);
+ break;
+ default:
+ break;
+ }
+
+ return (rtStatus == RT_STATUS_SUCCESS) ? 1:0;
+}
+
+
+// Joseph test: new initialize order!!
+// Test only!! This part need to be re-organized.
+// Now it is just for 8256.
+//use in phy only
+#ifdef TO_DO_LIST
+static RT_STATUS
+phy_BB8190_Config_HardCode(struct net_device* dev)
+{
+ //RT_ASSERT(FALSE, ("This function is not implement yet!! \n"));
+ return RT_STATUS_SUCCESS;
+}
+#endif
+
+/*-----------------------------------------------------------------------------
+ * Function: phy_SetBBtoDiffRFWithHeaderFile()
+ *
+ * Overview: This function
+ *
+ *
+ * Input: PADAPTER Adapter
+ * u1Byte ConfigType 0 => PHY_CONFIG
+ *
+ * Output: NONE
+ *
+ * Return: RT_STATUS_SUCCESS: configuration file exist
+ * When Who Remark
+ * 2008/11/10 tynli
+ * use in phy only
+ *---------------------------------------------------------------------------*/
+static RT_STATUS
+phy_SetBBtoDiffRFWithHeaderFile(struct net_device* dev, u8 ConfigType)
+{
+ int i;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32* Rtl819XPHY_REGArraytoXTXR_Table;
+ u16 PHY_REGArraytoXTXRLen;
+
+//#if (HAL_CODE_BASE != RTL8192_S)
+
+ if(priv->rf_type == RF_1T1R)
+ {
+ Rtl819XPHY_REGArraytoXTXR_Table = Rtl819XPHY_REG_to1T1R_Array;
+ PHY_REGArraytoXTXRLen = PHY_ChangeTo_1T1RArrayLength;
+ }
+ else if(priv->rf_type == RF_1T2R)
+ {
+ Rtl819XPHY_REGArraytoXTXR_Table = Rtl819XPHY_REG_to1T2R_Array;
+ PHY_REGArraytoXTXRLen = PHY_ChangeTo_1T2RArrayLength;
+ }
+ //else if(priv->rf_type == RF_2T2R || priv->rf_type == RF_2T2R_GREEN)
+ //{
+ // Rtl819XPHY_REGArraytoXTXR_Table = Rtl819XPHY_REG_to2T2R_Array;
+ // PHY_REGArraytoXTXRLen = PHY_ChangeTo_2T2RArrayLength;
+ //}
+ else
+ {
+ return RT_STATUS_FAILURE;
+ }
+
+ if(ConfigType == BaseBand_Config_PHY_REG)
+ {
+ for(i=0;i<PHY_REGArraytoXTXRLen;i=i+3)
+ {
+ if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfe)
+ mdelay(50);
+ else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfd)
+ mdelay(5);
+ else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfc)
+ mdelay(1);
+ else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfb)
+ udelay(50);
+ else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfa)
+ udelay(5);
+ else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xf9)
+ udelay(1);
+ rtl8192_setBBreg(dev, Rtl819XPHY_REGArraytoXTXR_Table[i], Rtl819XPHY_REGArraytoXTXR_Table[i+1], Rtl819XPHY_REGArraytoXTXR_Table[i+2]);
+ //RT_TRACE(COMP_SEND,
+ //"The Rtl819XPHY_REGArraytoXTXR_Table[0] is %lx Rtl819XPHY_REGArraytoXTXR_Table[1] is %lx Rtl819XPHY_REGArraytoXTXR_Table[2] is %lx \n",
+ //Rtl819XPHY_REGArraytoXTXR_Table[i],Rtl819XPHY_REGArraytoXTXR_Table[i+1], Rtl819XPHY_REGArraytoXTXR_Table[i+2]);
+ }
+ }
+ else {
+ RT_TRACE(COMP_SEND, "phy_SetBBtoDiffRFWithHeaderFile(): ConfigType != BaseBand_Config_PHY_REG\n");
+ }
+//#endif // #if (HAL_CODE_BASE != RTL8192_S)
+ return RT_STATUS_SUCCESS;
+}
+
+
+//use in phy only
+static RT_STATUS
+phy_BB8192S_Config_ParaFile(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ //u8 u2RegValue;
+ //u16 u4RegValue;
+ //char szBBRegFile[] = RTL819X_PHY_REG;
+ //char szBBRegFile1T2R[] = RTL819X_PHY_REG_1T2R;
+ //char szBBRegPgFile[] = RTL819X_PHY_REG_PG;
+ //char szAGCTableFile[] = RTL819X_AGC_TAB;
+ //char szBBRegto1T1RFile[] = RTL819X_PHY_REG_to1T1R;
+ //char szBBRegto1T2RFile[] = RTL819X_PHY_REG_to1T2R;
+
+ RT_TRACE(COMP_INIT, "==>phy_BB8192S_Config_ParaFile\n");
+
+ //
+ // 1. Read PHY_REG.TXT BB INIT!!
+ // We will seperate as 1T1R/1T2R/1T2R_GREEN/2T2R
+ //
+#if RTL8190_Download_Firmware_From_Header
+ if (priv->rf_type == RF_1T2R || priv->rf_type == RF_2T2R ||
+ priv->rf_type == RF_1T1R ||priv->rf_type == RF_2T2R_GREEN)
+ {
+ rtStatus = phy_ConfigBBWithHeaderFile(dev,BaseBand_Config_PHY_REG);
+ if(priv->rf_type != RF_2T2R && priv->rf_type != RF_2T2R_GREEN)
+ {//2008.11.10 Added by tynli. The default PHY_REG.txt we read is for 2T2R,
+ //so we should reconfig BB reg with the right PHY parameters.
+ rtStatus = phy_SetBBtoDiffRFWithHeaderFile(dev,BaseBand_Config_PHY_REG);
+ }
+ }else
+ rtStatus = RT_STATUS_FAILURE;
+#else
+ RT_TRACE(COMP_INIT, "RF_Type == %d\n", priv->rf_type);
+ // No matter what kind of RF we always read PHY_REG.txt. We must copy different
+ // type of parameter files to phy_reg.txt at first.
+ if (priv->rf_type == RF_1T2R || priv->rf_type == RF_2T2R ||
+ priv->rf_type == RF_1T1R ||priv->rf_type == RF_2T2R_GREEN)
+ {
+ rtStatus = phy_ConfigBBWithParaFile(dev, (char* )&szBBRegFile);
+ if(priv->rf_type != RF_2T2R && priv->rf_type != RF_2T2R_GREEN)
+ {//2008.11.10 Added by tynli. The default PHY_REG.txt we read is for 2T2R,
+ //so we should reconfig BB reg with the right PHY parameters.
+ if(priv->rf_type == RF_1T1R)
+ rtStatus = phy_SetBBtoDiffRFWithParaFile(dev, (char* )&szBBRegto1T1RFile);
+ else if(priv->rf_type == RF_1T2R)
+ rtStatus = phy_SetBBtoDiffRFWithParaFile(dev, (char* )&szBBRegto1T2RFile);
+ }
+
+ }else
+ rtStatus = RT_STATUS_FAILURE;
+#endif
+
+ if(rtStatus != RT_STATUS_SUCCESS){
+ RT_TRACE(COMP_INIT, "phy_BB8192S_Config_ParaFile():Write BB Reg Fail!!");
+ goto phy_BB8190_Config_ParaFile_Fail;
+ }
+
+ //
+ // 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt
+ //
+ if (priv->AutoloadFailFlag == false)
+ {
+#if RTL8190_Download_Firmware_From_Header
+ rtStatus = phy_ConfigBBWithPgHeaderFile(dev,BaseBand_Config_PHY_REG);
+#else
+ rtStatus = phy_ConfigBBWithPgParaFile(dev, (char* )&szBBRegPgFile);
+#endif
+ }
+ if(rtStatus != RT_STATUS_SUCCESS){
+ RT_TRACE(COMP_INIT, "phy_BB8192S_Config_ParaFile():BB_PG Reg Fail!!");
+ goto phy_BB8190_Config_ParaFile_Fail;
+ }
+
+ //
+ // 3. BB AGC table Initialization
+ //
+#if RTL8190_Download_Firmware_From_Header
+ rtStatus = phy_ConfigBBWithHeaderFile(dev,BaseBand_Config_AGC_TAB);
+#else
+ RT_TRACE(COMP_INIT, "phy_BB8192S_Config_ParaFile AGC_TAB.txt\n");
+ rtStatus = phy_ConfigBBWithParaFile(Adapter, (char* )&szAGCTableFile);
+#endif
+
+ if(rtStatus != RT_STATUS_SUCCESS){
+ printk( "phy_BB8192S_Config_ParaFile():AGC Table Fail\n");
+ goto phy_BB8190_Config_ParaFile_Fail;
+ }
+
+
+#if 0 // 2008/08/18 MH Disable for 92SE
+ if(pHalData->VersionID > VERSION_8190_BD)
+ {
+ //if(pHalData->RF_Type == RF_2T4R)
+ //{
+ // Antenna gain offset from B/C/D to A
+ u4RegValue = ( pHalData->AntennaTxPwDiff[2]<<8 |
+ pHalData->AntennaTxPwDiff[1]<<4 |
+ pHalData->AntennaTxPwDiff[0]);
+ //}
+ //else
+ //u4RegValue = 0;
+
+ PHY_SetBBReg(dev, rFPGA0_TxGainStage,
+ (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue);
+
+ // CrystalCap
+ // Simulate 8192???
+ u4RegValue = pHalData->CrystalCap;
+ PHY_SetBBReg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, u4RegValue);
+ // Simulate 8190??
+ //u4RegValue = ((pHalData->CrystalCap & 0xc)>>2); // bit2~3 of crystal cap
+ //PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, bXtalCap23, u4RegValue);
+
+ }
+#endif
+
+ // Check if the CCK HighPower is turned ON.
+ // This is used to calculate PWDB.
+ priv->bCckHighPower = (bool)(rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter2, 0x200));
+
+
+phy_BB8190_Config_ParaFile_Fail:
+ return rtStatus;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: phy_ConfigMACWithHeaderFile()
+ *
+ * Overview: This function read BB parameters from Header file we gen, and do register
+ * Read/Write
+ *
+ * Input: PADAPTER Adapter
+ * char* pFileName
+ *
+ * Output: NONE
+ *
+ * Return: RT_STATUS_SUCCESS: configuration file exist
+ *
+ * Note: The format of MACPHY_REG.txt is different from PHY and RF.
+ * [Register][Mask][Value]
+ *---------------------------------------------------------------------------*/
+//use in phy only
+static RT_STATUS
+phy_ConfigMACWithHeaderFile(struct net_device* dev)
+{
+ u32 i = 0;
+ u32 ArrayLength = 0;
+ u32* ptrArray;
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+
+//#if (HAL_CODE_BASE != RTL8192_S)
+ /*if(Adapter->bInHctTest)
+ {
+ RT_TRACE(COMP_INIT, DBG_LOUD, ("Rtl819XMACPHY_ArrayDTM\n"));
+ ArrayLength = MACPHY_ArrayLengthDTM;
+ ptrArray = Rtl819XMACPHY_ArrayDTM;
+ }
+ else if(pHalData->bTXPowerDataReadFromEEPORM)
+ {
+// RT_TRACE(COMP_INIT, DBG_LOUD, ("Rtl819XMACPHY_Array_PG\n"));
+// ArrayLength = MACPHY_Array_PGLength;
+// ptrArray = Rtl819XMACPHY_Array_PG;
+
+ }else*/
+ { //2008.11.06 Modified by tynli.
+ RT_TRACE(COMP_INIT, "Read Rtl819XMACPHY_Array\n");
+ ArrayLength = MAC_2T_ArrayLength;
+ ptrArray = Rtl819XMAC_Array;
+ }
+
+ /*for(i = 0 ;i < ArrayLength;i=i+3){
+ RT_TRACE(COMP_SEND, DBG_LOUD, ("The Rtl819XMACPHY_Array[0] is %lx Rtl819XMACPHY_Array[1] is %lx Rtl819XMACPHY_Array[2] is %lx\n",ptrArray[i], ptrArray[i+1], ptrArray[i+2]));
+ if(ptrArray[i] == 0x318)
+ {
+ ptrArray[i+2] = 0x00000800;
+ //DbgPrint("ptrArray[i], ptrArray[i+1], ptrArray[i+2] = %x, %x, %x\n",
+ // ptrArray[i], ptrArray[i+1], ptrArray[i+2]);
+ }
+ PHY_SetBBReg(Adapter, ptrArray[i], ptrArray[i+1], ptrArray[i+2]);
+ }*/
+ for(i = 0 ;i < ArrayLength;i=i+2){ // Add by tynli for 2 column
+ write_nic_byte(dev, ptrArray[i], (u8)ptrArray[i+1]);
+ }
+//#endif
+ return RT_STATUS_SUCCESS;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: phy_ConfigBBWithHeaderFile()
+ *
+ * Overview: This function read BB parameters from general file format, and do register
+ * Read/Write
+ *
+ * Input: PADAPTER Adapter
+ * u8 ConfigType 0 => PHY_CONFIG
+ * 1 =>AGC_TAB
+ *
+ * Output: NONE
+ *
+ * Return: RT_STATUS_SUCCESS: configuration file exist
+ *
+ *---------------------------------------------------------------------------*/
+//use in phy only
+static RT_STATUS
+phy_ConfigBBWithHeaderFile(struct net_device* dev,u8 ConfigType)
+{
+ int i;
+ //u8 ArrayLength;
+ u32* Rtl819XPHY_REGArray_Table;
+ u32* Rtl819XAGCTAB_Array_Table;
+ u16 PHY_REGArrayLen, AGCTAB_ArrayLen;
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+//#if (HAL_CODE_BASE != RTL8192_S)
+ /*if(Adapter->bInHctTest)
+ {
+
+ AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM;
+ Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM;
+
+ if(pHalData->RF_Type == RF_2T4R)
+ {
+ PHY_REGArrayLen = PHY_REGArrayLengthDTM;
+ Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArrayDTM;
+ }
+ else if (pHalData->RF_Type == RF_1T2R)
+ {
+ PHY_REGArrayLen = PHY_REG_1T2RArrayLengthDTM;
+ Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArrayDTM;
+ }
+
+ }
+ else
+ */
+ //{
+ //
+ // 2008.11.06 Modified by tynli.
+ //
+ AGCTAB_ArrayLen = AGCTAB_ArrayLength;
+ Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array;
+ PHY_REGArrayLen = PHY_REG_2T2RArrayLength; // Default RF_type: 2T2R
+ Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_Array;
+ //}
+
+ if(ConfigType == BaseBand_Config_PHY_REG)
+ {
+ for(i=0;i<PHY_REGArrayLen;i=i+2)
+ {
+ if (Rtl819XPHY_REGArray_Table[i] == 0xfe)
+ mdelay(50);
+ else if (Rtl819XPHY_REGArray_Table[i] == 0xfd)
+ mdelay(5);
+ else if (Rtl819XPHY_REGArray_Table[i] == 0xfc)
+ mdelay(1);
+ else if (Rtl819XPHY_REGArray_Table[i] == 0xfb)
+ udelay(50);
+ else if (Rtl819XPHY_REGArray_Table[i] == 0xfa)
+ udelay(5);
+ else if (Rtl819XPHY_REGArray_Table[i] == 0xf9)
+ udelay(1);
+ rtl8192_setBBreg(dev, Rtl819XPHY_REGArray_Table[i], bMaskDWord, Rtl819XPHY_REGArray_Table[i+1]);
+ //RT_TRACE(COMP_SEND, "The Rtl819XPHY_REGArray_Table[0] is %lx Rtl819XPHY_REGArray[1] is %lx \n",Rtl819XPHY_REGArray_Table[i], Rtl819XPHY_REGArray_Table[i+1]);
+
+ }
+ }
+ else if(ConfigType == BaseBand_Config_AGC_TAB){
+ for(i=0;i<AGCTAB_ArrayLen;i=i+2)
+ {
+ rtl8192_setBBreg(dev, Rtl819XAGCTAB_Array_Table[i], bMaskDWord, Rtl819XAGCTAB_Array_Table[i+1]);
+ }
+ }
+//#endif // #if (HAL_CODE_BASE != RTL8192_S)
+ return RT_STATUS_SUCCESS;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: phy_ConfigBBWithPgHeaderFile
+ *
+ * Overview: Config PHY_REG_PG array
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/06/2008 MHC Add later!!!!!!.. Please modify for new files!!!!
+ * 11/10/2008 tynli Modify to mew files.
+ //use in phy only
+ *---------------------------------------------------------------------------*/
+static RT_STATUS
+phy_ConfigBBWithPgHeaderFile(struct net_device* dev,u8 ConfigType)
+{
+ int i;
+ //u8 ArrayLength;
+ u32* Rtl819XPHY_REGArray_Table_PG;
+ u16 PHY_REGArrayPGLen;
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+//#if (HAL_CODE_BASE != RTL8192_S)
+ // Default: pHalData->RF_Type = RF_2T2R.
+
+ PHY_REGArrayPGLen = PHY_REG_Array_PGLength;
+ Rtl819XPHY_REGArray_Table_PG = Rtl819XPHY_REG_Array_PG;
+
+ if(ConfigType == BaseBand_Config_PHY_REG)
+ {
+ for(i=0;i<PHY_REGArrayPGLen;i=i+3)
+ {
+ if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfe)
+ mdelay(50);
+ else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfd)
+ mdelay(5);
+ else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfc)
+ mdelay(1);
+ else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfb)
+ udelay(50);
+ else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfa)
+ udelay(5);
+ else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xf9)
+ udelay(1);
+ rtl8192_setBBreg(dev, Rtl819XPHY_REGArray_Table_PG[i], Rtl819XPHY_REGArray_Table_PG[i+1], Rtl819XPHY_REGArray_Table_PG[i+2]);
+ //RT_TRACE(COMP_SEND, "The Rtl819XPHY_REGArray_Table_PG[0] is %lx Rtl819XPHY_REGArray_Table_PG[1] is %lx \n",
+ // Rtl819XPHY_REGArray_Table_PG[i], Rtl819XPHY_REGArray_Table_PG[i+1]);
+ }
+ }else{
+ RT_TRACE(COMP_SEND, "phy_ConfigBBWithPgHeaderFile(): ConfigType != BaseBand_Config_PHY_REG\n");
+ }
+ return RT_STATUS_SUCCESS;
+
+} /* phy_ConfigBBWithPgHeaderFile */
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_ConfigRFWithHeaderFile()
+ *
+ * Overview: This function read RF parameters from general file format, and do RF 3-wire
+ *
+ * Input: PADAPTER Adapter
+ * char* pFileName
+ * RF90_RADIO_PATH_E eRFPath
+ *
+ * Output: NONE
+ *
+ * Return: RT_STATUS_SUCCESS: configuration file exist
+ *
+ * Note: Delay may be required for RF configuration
+ *---------------------------------------------------------------------------*/
+//in 8256 phy_RF8256_Config_ParaFile only
+//RT_STATUS PHY_ConfigRFWithHeaderFile(struct net_device* dev,RF90_RADIO_PATH_E eRFPath)
+u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int i;
+ //u32* pRFArray;
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ u32 *Rtl819XRadioA_Array_Table;
+ u32 *Rtl819XRadioB_Array_Table;
+ //u32* Rtl819XRadioC_Array_Table;
+ //u32* Rtl819XRadioD_Array_Table;
+ u16 RadioA_ArrayLen,RadioB_ArrayLen;
+
+ { //2008.11.06 Modified by tynli
+ RadioA_ArrayLen = RadioA_1T_ArrayLength;
+ Rtl819XRadioA_Array_Table=Rtl819XRadioA_Array;
+ Rtl819XRadioB_Array_Table=Rtl819XRadioB_Array;
+ RadioB_ArrayLen = RadioB_ArrayLength;
+ }
+
+ if( priv->rf_type == RF_2T2R_GREEN )
+ {
+ Rtl819XRadioB_Array_Table = Rtl819XRadioB_GM_Array;
+ RadioB_ArrayLen = RadioB_GM_ArrayLength;
+ }
+ else
+ {
+ Rtl819XRadioB_Array_Table = Rtl819XRadioB_Array;
+ RadioB_ArrayLen = RadioB_ArrayLength;
+ }
+
+ rtStatus = RT_STATUS_SUCCESS;
+
+ // When initialization, we want the delay function(mdelay(), delay_us()
+ // ==> actually we call PlatformStallExecution()) to do NdisStallExecution()
+ // [busy wait] instead of NdisMSleep(). So we acquire RT_INITIAL_SPINLOCK
+ // to run at Dispatch level to achive it.
+ //cosa PlatformAcquireSpinLock(Adapter, RT_INITIAL_SPINLOCK);
+
+ switch(eRFPath){
+ case RF90_PATH_A:
+ for(i = 0;i<RadioA_ArrayLen; i=i+2){
+ if(Rtl819XRadioA_Array_Table[i] == 0xfe)
+ { // Deay specific ms. Only RF configuration require delay.
+//#if (DEV_BUS_TYPE == USB_INTERFACE)
+#ifdef RTL8192SU
+ mdelay(1000);
+#else
+ mdelay(50);
+#endif
+ }
+ else if (Rtl819XRadioA_Array_Table[i] == 0xfd)
+ mdelay(5);
+ else if (Rtl819XRadioA_Array_Table[i] == 0xfc)
+ mdelay(1);
+ else if (Rtl819XRadioA_Array_Table[i] == 0xfb)
+ udelay(50);
+ //PlatformStallExecution(50);
+ else if (Rtl819XRadioA_Array_Table[i] == 0xfa)
+ udelay(5);
+ else if (Rtl819XRadioA_Array_Table[i] == 0xf9)
+ udelay(1);
+ else
+ {
+ rtl8192_phy_SetRFReg(dev, eRFPath, Rtl819XRadioA_Array_Table[i], bRFRegOffsetMask, Rtl819XRadioA_Array_Table[i+1]);
+ }
+ }
+ break;
+ case RF90_PATH_B:
+ for(i = 0;i<RadioB_ArrayLen; i=i+2){
+ if(Rtl819XRadioB_Array_Table[i] == 0xfe)
+ { // Deay specific ms. Only RF configuration require delay.
+//#if (DEV_BUS_TYPE == USB_INTERFACE)
+#ifdef RTL8192SU
+ mdelay(1000);
+#else
+ mdelay(50);
+#endif
+ }
+ else if (Rtl819XRadioB_Array_Table[i] == 0xfd)
+ mdelay(5);
+ else if (Rtl819XRadioB_Array_Table[i] == 0xfc)
+ mdelay(1);
+ else if (Rtl819XRadioB_Array_Table[i] == 0xfb)
+ udelay(50);
+ else if (Rtl819XRadioB_Array_Table[i] == 0xfa)
+ udelay(5);
+ else if (Rtl819XRadioB_Array_Table[i] == 0xf9)
+ udelay(1);
+ else
+ {
+ rtl8192_phy_SetRFReg(dev, eRFPath, Rtl819XRadioB_Array_Table[i], bRFRegOffsetMask, Rtl819XRadioB_Array_Table[i+1]);
+ }
+ }
+ break;
+ case RF90_PATH_C:
+ break;
+ case RF90_PATH_D:
+ break;
+ default:
+ break;
+ }
+
+ return rtStatus;
+
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_CheckBBAndRFOK()
+ *
+ * Overview: This function is write register and then readback to make sure whether
+ * BB[PHY0, PHY1], RF[Patha, path b, path c, path d] is Ok
+ *
+ * Input: PADAPTER Adapter
+ * HW90_BLOCK_E CheckBlock
+ * RF90_RADIO_PATH_E eRFPath // it is used only when CheckBlock is HW90_BLOCK_RF
+ *
+ * Output: NONE
+ *
+ * Return: RT_STATUS_SUCCESS: PHY is OK
+ *
+ * Note: This function may be removed in the ASIC
+ *---------------------------------------------------------------------------*/
+//in 8256 phy_RF8256_Config_HardCode
+//but we don't use it temp
+RT_STATUS
+PHY_CheckBBAndRFOK(
+ struct net_device* dev,
+ HW90_BLOCK_E CheckBlock,
+ RF90_RADIO_PATH_E eRFPath
+ )
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ u32 i, CheckTimes = 4,ulRegRead = 0;
+ u32 WriteAddr[4];
+ u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f};
+
+ // Initialize register address offset to be checked
+ WriteAddr[HW90_BLOCK_MAC] = 0x100;
+ WriteAddr[HW90_BLOCK_PHY0] = 0x900;
+ WriteAddr[HW90_BLOCK_PHY1] = 0x800;
+ WriteAddr[HW90_BLOCK_RF] = 0x3;
+
+ for(i=0 ; i < CheckTimes ; i++)
+ {
+
+ //
+ // Write Data to register and readback
+ //
+ switch(CheckBlock)
+ {
+ case HW90_BLOCK_MAC:
+ //RT_ASSERT(FALSE, ("PHY_CheckBBRFOK(): Never Write 0x100 here!"));
+ RT_TRACE(COMP_INIT, "PHY_CheckBBRFOK(): Never Write 0x100 here!\n");
+ break;
+
+ case HW90_BLOCK_PHY0:
+ case HW90_BLOCK_PHY1:
+ write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]);
+ ulRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]);
+ break;
+
+ case HW90_BLOCK_RF:
+ // When initialization, we want the delay function(mdelay(), delay_us()
+ // ==> actually we call PlatformStallExecution()) to do NdisStallExecution()
+ // [busy wait] instead of NdisMSleep(). So we acquire RT_INITIAL_SPINLOCK
+ // to run at Dispatch level to achive it.
+ //cosa PlatformAcquireSpinLock(dev, RT_INITIAL_SPINLOCK);
+ WriteData[i] &= 0xfff;
+ rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bRFRegOffsetMask, WriteData[i]);
+ // TODO: we should not delay for such a long time. Ask SD3
+ mdelay(10);
+ ulRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord);
+ mdelay(10);
+ //cosa PlatformReleaseSpinLock(dev, RT_INITIAL_SPINLOCK);
+ break;
+
+ default:
+ rtStatus = RT_STATUS_FAILURE;
+ break;
+ }
+
+
+ //
+ // Check whether readback data is correct
+ //
+ if(ulRegRead != WriteData[i])
+ {
+ //RT_TRACE(COMP_FPGA, ("ulRegRead: %x, WriteData: %x \n", ulRegRead, WriteData[i]));
+ RT_TRACE(COMP_ERR, "read back error(read:%x, write:%x)\n", ulRegRead, WriteData[i]);
+ rtStatus = RT_STATUS_FAILURE;
+ break;
+ }
+ }
+
+ return rtStatus;
+}
+
+//no use temp in windows driver
+#ifdef TO_DO_LIST
+void
+PHY_SetRFPowerState8192SUsb(
+ struct net_device* dev,
+ RF_POWER_STATE RFPowerState
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool WaitShutDown = FALSE;
+ u32 DWordContent;
+ //RF90_RADIO_PATH_E eRFPath;
+ u8 eRFPath;
+ BB_REGISTER_DEFINITION_T *pPhyReg;
+
+ if(priv->SetRFPowerStateInProgress == TRUE)
+ return;
+
+ priv->SetRFPowerStateInProgress = TRUE;
+
+ // TODO: Emily, 2006.11.21, we should rewrite this function
+
+ if(RFPowerState==RF_SHUT_DOWN)
+ {
+ RFPowerState=RF_OFF;
+ WaitShutDown=TRUE;
+ }
+
+
+ priv->RFPowerState = RFPowerState;
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+ case RF_6052:
+ switch( RFPowerState )
+ {
+ case RF_ON:
+ break;
+
+ case RF_SLEEP:
+ break;
+
+ case RF_OFF:
+ break;
+ }
+ break;
+
+ case RF_8256:
+ switch( RFPowerState )
+ {
+ case RF_ON:
+ break;
+
+ case RF_SLEEP:
+ break;
+
+ case RF_OFF:
+ for(eRFPath=(RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath < RF90_PATH_MAX; eRFPath++)
+ {
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ continue;
+
+ pPhyReg = &priv->PHYRegDef[eRFPath];
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, bRFSI_RFENV);
+ rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0);
+ }
+ break;
+ }
+ break;
+
+ case RF_8258:
+ break;
+ }// switch( priv->rf_chip )
+
+ priv->SetRFPowerStateInProgress = FALSE;
+}
+#endif
+
+#ifdef RTL8192U
+//no use temp in windows driver
+void
+PHY_UpdateInitialGain(
+ struct net_device* dev
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //unsigned char *IGTable;
+ //u8 DIG_CurrentInitialGain = 4;
+
+ switch(priv->rf_chip)
+ {
+ case RF_8225:
+ break;
+ case RF_8256:
+ break;
+ case RF_8258:
+ break;
+ case RF_PSEUDO_11N:
+ break;
+ case RF_6052:
+ break;
+ default:
+ RT_TRACE(COMP_DBG, "PHY_UpdateInitialGain(): unknown rf_chip: %#X\n", priv->rf_chip);
+ break;
+ }
+}
+#endif
+
+//YJ,modified,090107
+void PHY_GetHWRegOriginalValue(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // read tx power offset
+ // Simulate 8192
+ priv->MCSTxPowerLevelOriginalOffset[0] =
+ rtl8192_QueryBBReg(dev, rTxAGC_Rate18_06, bMaskDWord);
+ priv->MCSTxPowerLevelOriginalOffset[1] =
+ rtl8192_QueryBBReg(dev, rTxAGC_Rate54_24, bMaskDWord);
+ priv->MCSTxPowerLevelOriginalOffset[2] =
+ rtl8192_QueryBBReg(dev, rTxAGC_Mcs03_Mcs00, bMaskDWord);
+ priv->MCSTxPowerLevelOriginalOffset[3] =
+ rtl8192_QueryBBReg(dev, rTxAGC_Mcs07_Mcs04, bMaskDWord);
+ priv->MCSTxPowerLevelOriginalOffset[4] =
+ rtl8192_QueryBBReg(dev, rTxAGC_Mcs11_Mcs08, bMaskDWord);
+ priv->MCSTxPowerLevelOriginalOffset[5] =
+ rtl8192_QueryBBReg(dev, rTxAGC_Mcs15_Mcs12, bMaskDWord);
+
+ // Read CCK offset
+ priv->MCSTxPowerLevelOriginalOffset[6] =
+ rtl8192_QueryBBReg(dev, rTxAGC_CCK_Mcs32, bMaskDWord);
+ RT_TRACE(COMP_INIT, "Legacy OFDM =%08x/%08x HT_OFDM=%08x/%08x/%08x/%08x\n",
+ priv->MCSTxPowerLevelOriginalOffset[0], priv->MCSTxPowerLevelOriginalOffset[1] ,
+ priv->MCSTxPowerLevelOriginalOffset[2], priv->MCSTxPowerLevelOriginalOffset[3] ,
+ priv->MCSTxPowerLevelOriginalOffset[4], priv->MCSTxPowerLevelOriginalOffset[5] );
+
+ // read rx initial gain
+ priv->DefaultInitialGain[0] = rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bMaskByte0);
+ priv->DefaultInitialGain[1] = rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bMaskByte0);
+ priv->DefaultInitialGain[2] = rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bMaskByte0);
+ priv->DefaultInitialGain[3] = rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bMaskByte0);
+ RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n",
+ priv->DefaultInitialGain[0], priv->DefaultInitialGain[1],
+ priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]);
+
+ // read framesync
+ priv->framesync = rtl8192_QueryBBReg(dev, rOFDM0_RxDetector3, bMaskByte0);
+ priv->framesyncC34 = rtl8192_QueryBBReg(dev, rOFDM0_RxDetector2, bMaskDWord);
+ RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n",
+ rOFDM0_RxDetector3, priv->framesync);
+}
+//YJ,modified,090107,end
+
+
+
+/**
+* Function: phy_InitBBRFRegisterDefinition
+*
+* OverView: Initialize Register definition offset for Radio Path A/B/C/D
+*
+* Input:
+* PADAPTER Adapter,
+*
+* Output: None
+* Return: None
+* Note: The initialization value is constant and it should never be changes
+*/
+//use in phy only
+static void phy_InitBBRFRegisterDefinition( struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // RF Interface Sowrtware Control
+ priv->PHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 LSBs if read 32-bit from 0x870
+ priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872)
+ priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 LSBs if read 32-bit from 0x874
+ priv->PHYRegDef[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876)
+
+ // RF Interface Readback Value
+ priv->PHYRegDef[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; // 16 LSBs if read 32-bit from 0x8E0
+ priv->PHYRegDef[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2)
+ priv->PHYRegDef[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 LSBs if read 32-bit from 0x8E4
+ priv->PHYRegDef[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6)
+
+ // RF Interface Output (and Enable)
+ priv->PHYRegDef[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x860
+ priv->PHYRegDef[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x864
+ priv->PHYRegDef[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x868
+ priv->PHYRegDef[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x86C
+
+ // RF Interface (Output and) Enable
+ priv->PHYRegDef[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862)
+ priv->PHYRegDef[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866)
+ priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86A (16-bit for 0x86A)
+ priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86C (16-bit for 0x86E)
+
+ //Addr of LSSI. Wirte RF register by driver
+ priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; //LSSI Parameter
+ priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter;
+ priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter;
+ priv->PHYRegDef[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter;
+
+ // RF parameter
+ priv->PHYRegDef[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; //BB Band Select
+ priv->PHYRegDef[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter;
+ priv->PHYRegDef[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter;
+ priv->PHYRegDef[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter;
+
+ // Tx AGC Gain Stage (same for all path. Should we remove this?)
+ priv->PHYRegDef[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+ priv->PHYRegDef[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+ priv->PHYRegDef[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+ priv->PHYRegDef[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+
+ // Tranceiver A~D HSSI Parameter-1
+ priv->PHYRegDef[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; //wire control parameter1
+ priv->PHYRegDef[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; //wire control parameter1
+ priv->PHYRegDef[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; //wire control parameter1
+ priv->PHYRegDef[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; //wire control parameter1
+
+ // Tranceiver A~D HSSI Parameter-2
+ priv->PHYRegDef[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; //wire control parameter2
+ priv->PHYRegDef[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; //wire control parameter2
+ priv->PHYRegDef[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; //wire control parameter2
+ priv->PHYRegDef[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; //wire control parameter1
+
+ // RF switch Control
+ priv->PHYRegDef[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; //TR/Ant switch control
+ priv->PHYRegDef[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl;
+ priv->PHYRegDef[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl;
+ priv->PHYRegDef[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl;
+
+ // AGC control 1
+ priv->PHYRegDef[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1;
+ priv->PHYRegDef[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1;
+ priv->PHYRegDef[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1;
+ priv->PHYRegDef[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1;
+
+ // AGC control 2
+ priv->PHYRegDef[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2;
+ priv->PHYRegDef[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2;
+ priv->PHYRegDef[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2;
+ priv->PHYRegDef[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2;
+
+ // RX AFE control 1
+ priv->PHYRegDef[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance;
+
+ // RX AFE control 1
+ priv->PHYRegDef[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE;
+ priv->PHYRegDef[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE;
+ priv->PHYRegDef[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE;
+ priv->PHYRegDef[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE;
+
+ // Tx AFE control 1
+ priv->PHYRegDef[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance;
+
+ // Tx AFE control 2
+ priv->PHYRegDef[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE;
+ priv->PHYRegDef[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE;
+ priv->PHYRegDef[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE;
+ priv->PHYRegDef[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE;
+
+ // Tranceiver LSSI Readback SI mode
+ priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack;
+ priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack;
+ priv->PHYRegDef[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack;
+ priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack;
+
+ // Tranceiver LSSI Readback PI mode
+ priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback;
+ priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback;
+ //pHalData->PHYRegDef[RF90_PATH_C].rfLSSIReadBackPi = rFPGA0_XC_LSSIReadBack;
+ //pHalData->PHYRegDef[RF90_PATH_D].rfLSSIReadBackPi = rFPGA0_XD_LSSIReadBack;
+
+}
+
+
+//
+// Description: Change RF power state.
+//
+// Assumption: This function must be executed in re-schdulable context,
+// ie. PASSIVE_LEVEL.
+//
+// 050823, by rcnjko.
+//not understand it seem's use in init
+//SetHwReg8192SUsb--->HalFunc.SetHwRegHandler
+bool PHY_SetRFPowerState(struct net_device* dev, RT_RF_POWER_STATE eRFPowerState)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool bResult = FALSE;
+
+ RT_TRACE(COMP_RF, "---------> PHY_SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState);
+
+ if(eRFPowerState == priv->ieee80211->eRFPowerState)
+ {
+ RT_TRACE(COMP_RF, "<--------- PHY_SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState);
+ return bResult;
+ }
+
+ bResult = phy_SetRFPowerState8192SU(dev, eRFPowerState);
+
+ RT_TRACE(COMP_RF, "<--------- PHY_SetRFPowerState(): bResult(%d)\n", bResult);
+
+ return bResult;
+}
+
+//use in phy only
+static bool phy_SetRFPowerState8192SU(struct net_device* dev,RT_RF_POWER_STATE eRFPowerState)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool bResult = TRUE;
+ //u8 eRFPath;
+ //u8 i, QueueID;
+ u8 u1bTmp;
+
+ if(priv->SetRFPowerStateInProgress == TRUE)
+ return FALSE;
+
+ priv->SetRFPowerStateInProgress = TRUE;
+
+ switch(priv->rf_chip )
+ {
+ default:
+ switch( eRFPowerState )
+ {
+ case eRfOn:
+ write_nic_dword(dev, WFM5, FW_BB_RESET_ENABLE);
+ write_nic_word(dev, CMDR, 0x37FC);
+ write_nic_byte(dev, PHY_CCA, 0x3);
+ write_nic_byte(dev, TXPAUSE, 0x00);
+ write_nic_byte(dev, SPS1_CTRL, 0x64);
+ break;
+
+ //
+ // In current solution, RFSleep=RFOff in order to save power under 802.11 power save.
+ // By Bruce, 2008-01-16.
+ //
+ case eRfSleep:
+ case eRfOff:
+ if (priv->ieee80211->eRFPowerState == eRfSleep || priv->ieee80211->eRFPowerState == eRfOff)
+ break;
+#ifdef NOT_YET
+ // Make sure BusyQueue is empty befor turn off RFE pwoer.
+ for(QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; )
+ {
+ if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID]))
+ {
+ QueueID++;
+ continue;
+ }
+ else
+ {
+ RT_TRACE(COMP_POWER, "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID);
+ udelay(10);
+ i++;
+ }
+
+ if(i >= MAX_DOZE_WAITING_TIMES_9x)
+ {
+ RT_TRACE(COMP_POWER, "\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID);
+ break;
+ }
+ }
+#endif
+ //
+ //RF Off/Sleep sequence. Designed/tested from SD4 Scott, SD1 Grent and Jonbon.
+ // Added by Bruce, 2008-11-22.
+ //
+ //==================================================================
+ // (0) Disable FW BB reset checking
+ write_nic_dword(dev, WFM5, FW_BB_RESET_DISABLE);
+
+ // (1) Switching Power Supply Register : Disable LD12 & SW12 (for IT)
+ u1bTmp = read_nic_byte(dev, LDOV12D_CTRL);
+ u1bTmp |= BIT0;
+ write_nic_byte(dev, LDOV12D_CTRL, u1bTmp);
+
+ write_nic_byte(dev, SPS1_CTRL, 0x0);
+ write_nic_byte(dev, TXPAUSE, 0xFF);
+
+ // (2) MAC Tx/Rx enable, BB enable, CCK/OFDM enable
+ write_nic_word(dev, CMDR, 0x77FC);
+ write_nic_byte(dev, PHY_CCA, 0x0);
+ udelay(100);
+
+ write_nic_word(dev, CMDR, 0x37FC);
+ udelay(10);
+
+ write_nic_word(dev, CMDR, 0x77FC);
+ udelay(10);
+
+ // (3) Reset BB TRX blocks
+ write_nic_word(dev, CMDR, 0x57FC);
+ break;
+
+ default:
+ bResult = FALSE;
+ //RT_ASSERT(FALSE, ("phy_SetRFPowerState8192SU(): unknow state to set: 0x%X!!!\n", eRFPowerState));
+ break;
+ }
+ break;
+
+ }
+ priv->ieee80211->eRFPowerState = eRFPowerState;
+#ifdef TO_DO_LIST
+ if(bResult)
+ {
+ // Update current RF state variable.
+ priv->ieee80211->eRFPowerState = eRFPowerState;
+
+ switch(priv->rf_chip )
+ {
+ case RF_8256:
+ switch(priv->ieee80211->eRFPowerState)
+ {
+ case eRfOff:
+ //
+ //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015
+ //
+ if(pMgntInfo->RfOffReason==RF_CHANGE_BY_IPS )
+ {
+ dev->HalFunc.LedControlHandler(dev,LED_CTL_NO_LINK);
+ }
+ else
+ {
+ // Turn off LED if RF is not ON.
+ dev->HalFunc.LedControlHandler(dev, LED_CTL_POWER_OFF);
+ }
+ break;
+
+ case eRfOn:
+ // Turn on RF we are still linked, which might happen when
+ // we quickly turn off and on HW RF. 2006.05.12, by rcnjko.
+ if( pMgntInfo->bMediaConnect == TRUE )
+ {
+ dev->HalFunc.LedControlHandler(dev, LED_CTL_LINK);
+ }
+ else
+ {
+ // Turn off LED if RF is not ON.
+ dev->HalFunc.LedControlHandler(dev, LED_CTL_NO_LINK);
+ }
+ break;
+
+ default:
+ // do nothing.
+ break;
+ }// Switch RF state
+
+ break;
+
+ default:
+ RT_TRACE(COMP_RF, "phy_SetRFPowerState8192SU(): Unknown RF type\n");
+ break;
+ }// Switch rf_chip
+ }
+#endif
+ priv->SetRFPowerStateInProgress = FALSE;
+
+ return bResult;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: GetTxPowerLevel8190()
+ *
+ * Overview: This function is export to "common" moudule
+ *
+ * Input: PADAPTER Adapter
+ * psByte Power Level
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ *---------------------------------------------------------------------------*/
+ // no use temp
+ void
+PHY_GetTxPowerLevel8192S(
+ struct net_device* dev,
+ long* powerlevel
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 TxPwrLevel = 0;
+ long TxPwrDbm;
+ //
+ // Because the Tx power indexes are different, we report the maximum of them to
+ // meet the CCX TPC request. By Bruce, 2008-01-31.
+ //
+
+ // CCK
+ TxPwrLevel = priv->CurrentCckTxPwrIdx;
+ TxPwrDbm = phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_B, TxPwrLevel);
+
+ // Legacy OFDM
+ TxPwrLevel = priv->CurrentOfdm24GTxPwrIdx + priv->LegacyHTTxPowerDiff;
+
+ // Compare with Legacy OFDM Tx power.
+ if(phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_G, TxPwrLevel) > TxPwrDbm)
+ TxPwrDbm = phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_G, TxPwrLevel);
+
+ // HT OFDM
+ TxPwrLevel = priv->CurrentOfdm24GTxPwrIdx;
+
+ // Compare with HT OFDM Tx power.
+ if(phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_N_24G, TxPwrLevel) > TxPwrDbm)
+ TxPwrDbm = phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_N_24G, TxPwrLevel);
+
+ *powerlevel = TxPwrDbm;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: SetTxPowerLevel8190()
+ *
+ * Overview: This function is export to "HalCommon" moudule
+ *
+ * Input: PADAPTER Adapter
+ * u1Byte channel
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ * 2008/11/04 MHC We remove EEPROM_93C56.
+ * We need to move CCX relative code to independet file.
+* 2009/01/21 MHC Support new EEPROM format from SD3 requirement.
+ *---------------------------------------------------------------------------*/
+ void PHY_SetTxPowerLevel8192S(struct net_device* dev, u8 channel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(dev);
+ u8 powerlevel = (u8)EEPROM_Default_TxPower, powerlevelOFDM24G = 0x10;
+ s8 ant_pwr_diff = 0;
+ u32 u4RegValue;
+ u8 index = (channel -1);
+ // 2009/01/22 MH Add for new EEPROM format from SD3
+ u8 pwrdiff[2] = {0};
+ u8 ht20pwr[2] = {0}, ht40pwr[2] = {0};
+ u8 rfpath = 0, rfpathnum = 2;
+
+ if(priv->bTXPowerDataReadFromEEPORM == FALSE)
+ return;
+
+ //
+ // Read predefined TX power index in EEPROM
+ //
+// if(priv->epromtype == EPROM_93c46)
+ {
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ powerlevel = priv->TxPowerLevelCCK[index];
+ powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[index];
+#else
+ //
+ // Mainly we use RF-A Tx Power to write the Tx Power registers, but the RF-B Tx
+ // Power must be calculated by the antenna diff.
+ // So we have to rewrite Antenna gain offset register here.
+ // Please refer to BB register 0x80c
+ // 1. For CCK.
+ // 2. For OFDM 1T or 2T
+ //
+
+ // 1. CCK
+ powerlevel = priv->RfTxPwrLevelCck[0][index];
+
+ if (priv->rf_type == RF_1T2R || priv->rf_type == RF_1T1R)
+ {
+ // Read HT 40 OFDM TX power
+ powerlevelOFDM24G = priv->RfTxPwrLevelOfdm1T[0][index];
+ // RF B HT OFDM pwr-RFA HT OFDM pwr
+ // Only one RF we need not to decide B <-> A pwr diff
+
+ // Legacy<->HT pwr diff, we only care about path A.
+
+ // We only assume 1T as RF path A
+ rfpathnum = 1;
+ ht20pwr[0] = ht40pwr[0] = priv->RfTxPwrLevelOfdm1T[0][index];
+ }
+ else if (priv->rf_type == RF_2T2R)
+ {
+ // Read HT 40 OFDM TX power
+ powerlevelOFDM24G = priv->RfTxPwrLevelOfdm2T[0][index];
+ // RF B HT OFDM pwr-RFA HT OFDM pwr
+ ant_pwr_diff = priv->RfTxPwrLevelOfdm2T[1][index] -
+ priv->RfTxPwrLevelOfdm2T[0][index];
+ // RF B (HT OFDM pwr+legacy-ht-diff) -(RFA HT OFDM pwr+legacy-ht-diff)
+ // We can not handle Path B&A HT/Legacy pwr diff for 92S now.
+
+ //RTPRINT(FPHY, PHY_TXPWR, ("CH-%d HT40 A/B Pwr index = %x/%x(%d/%d)\n",
+ //channel, priv->RfTxPwrLevelOfdm2T[0][index],
+ //priv->RfTxPwrLevelOfdm2T[1][index],
+ //priv->RfTxPwrLevelOfdm2T[0][index],
+ //priv->RfTxPwrLevelOfdm2T[1][index]));
+
+ ht20pwr[0] = ht40pwr[0] = priv->RfTxPwrLevelOfdm2T[0][index];
+ ht20pwr[1] = ht40pwr[1] = priv->RfTxPwrLevelOfdm2T[1][index];
+ }
+
+ //
+ // 2009/01/21 MH Support new EEPROM format from SD3 requirement
+ // 2009/02/10 Cosa, Here is only for reg B/C/D to A gain diff.
+ //
+ if (priv->EEPROMVersion == 2) // Defined by SD1 Jong
+ {
+ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+ {
+ for (rfpath = 0; rfpath < rfpathnum; rfpath++)
+ {
+ // HT 20<->40 pwr diff
+ pwrdiff[rfpath] = priv->TxPwrHt20Diff[rfpath][index];
+
+ // Calculate Antenna pwr diff
+ if (pwrdiff[rfpath] < 8) // 0~+7
+ {
+ #if 0//cosa, it doesn't need to add the offset here
+ if (rfpath == 0)
+ powerlevelOFDM24G += pwrdiff[rfpath];
+ #endif
+ ht20pwr[rfpath] += pwrdiff[rfpath];
+ }
+ else // index8-15=-8~-1
+ {
+ #if 0//cosa, it doesn't need to add the offset here
+ if (rfpath == 0)
+ powerlevelOFDM24G -= (15-pwrdiff[rfpath]);
+ #endif
+ ht20pwr[rfpath] -= (15-pwrdiff[rfpath]);
+ }
+ }
+
+ // RF B HT OFDM pwr-RFA HT OFDM pwr
+ if (priv->rf_type == RF_2T2R)
+ ant_pwr_diff = ht20pwr[1] - ht20pwr[0];
+
+ //RTPRINT(FPHY, PHY_TXPWR,
+ //("HT20 to HT40 pwrdiff[A/B]=%d/%d, ant_pwr_diff=%d(B-A=%d-%d)\n",
+ //pwrdiff[0], pwrdiff[1], ant_pwr_diff, ht20pwr[1], ht20pwr[0]));
+ }
+
+ // Band Edge scheme is enabled for FCC mode
+ if (priv->TxPwrbandEdgeFlag == 1/* && pHalData->ChannelPlan == 0*/)
+ {
+ for (rfpath = 0; rfpath < rfpathnum; rfpath++)
+ {
+ pwrdiff[rfpath] = 0;
+ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ {
+ if (channel <= 3)
+ pwrdiff[rfpath] = priv->TxPwrbandEdgeHt40[rfpath][0];
+ else if (channel >= 9)
+ pwrdiff[rfpath] = priv->TxPwrbandEdgeHt40[rfpath][1];
+ else
+ pwrdiff[rfpath] = 0;
+
+ ht40pwr[rfpath] -= pwrdiff[rfpath];
+ }
+ else if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+ {
+ if (channel == 1)
+ pwrdiff[rfpath] = priv->TxPwrbandEdgeHt20[rfpath][0];
+ else if (channel >= 11)
+ pwrdiff[rfpath] = priv->TxPwrbandEdgeHt20[rfpath][1];
+ else
+ pwrdiff[rfpath] = 0;
+
+ ht20pwr[rfpath] -= pwrdiff[rfpath];
+ }
+ #if 0//cosa, it doesn't need to add the offset here
+ if (rfpath == 0)
+ powerlevelOFDM24G -= pwrdiff[rfpath];
+ #endif
+ }
+
+ if (priv->rf_type == RF_2T2R)
+ {
+ // HT 20/40 must decide if they need to minus BD pwr offset
+ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ ant_pwr_diff = ht40pwr[1] - ht40pwr[0];
+ else
+ ant_pwr_diff = ht20pwr[1] - ht20pwr[0];
+ }
+ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+ {
+ if (channel <= 1 || channel >= 11)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR,
+ //("HT20 Band-edge pwrdiff[A/B]=%d/%d, ant_pwr_diff=%d(B-A=%d-%d)\n",
+ //pwrdiff[0], pwrdiff[1], ant_pwr_diff, ht20pwr[1], ht20pwr[0]));
+ }
+ }
+ else
+ {
+ if (channel <= 3 || channel >= 9)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR,
+ //("HT40 Band-edge pwrdiff[A/B]=%d/%d, ant_pwr_diff=%d(B-A=%d-%d)\n",
+ //pwrdiff[0], pwrdiff[1], ant_pwr_diff, ht40pwr[1], ht40pwr[0]));
+ }
+ }
+ }
+#if 0//cosa, useless
+ // Read HT/Legacy OFDM diff
+ legacy_ant_pwr_diff= pHalData->TxPwrLegacyHtDiff[RF90_PATH_A][index];
+#endif
+ }
+
+ //Cosa added for protection, the reg rFPGA0_TxGainStage
+ // range is from 7~-8, index = 0x0~0xf
+ if(ant_pwr_diff > 7)
+ ant_pwr_diff = 7;
+ if(ant_pwr_diff < -8)
+ ant_pwr_diff = -8;
+
+ //RTPRINT(FPHY, PHY_TXPWR,
+ //("CCK/HT Power index = %x/%x(%d/%d), ant_pwr_diff=%d\n",
+ //powerlevel, powerlevelOFDM24G, powerlevel, powerlevelOFDM24G, ant_pwr_diff));
+
+ ant_pwr_diff &= 0xf;
+
+ // Antenna TX power difference
+ priv->AntennaTxPwDiff[2] = 0;// RF-D, don't care
+ priv->AntennaTxPwDiff[1] = 0;// RF-C, don't care
+ priv->AntennaTxPwDiff[0] = (u8)(ant_pwr_diff); // RF-B
+
+ // Antenna gain offset from B/C/D to A
+ u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 |
+ priv->AntennaTxPwDiff[1]<<4 |
+ priv->AntennaTxPwDiff[0] );
+
+ // Notify Tx power difference for B/C/D to A!!!
+ rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue);
+#endif
+ }
+
+ //
+ // CCX 2 S31, AP control of client transmit power:
+ // 1. We shall not exceed Cell Power Limit as possible as we can.
+ // 2. Tolerance is +/- 5dB.
+ // 3. 802.11h Power Contraint takes higher precedence over CCX Cell Power Limit.
+ //
+ // TODO:
+ // 1. 802.11h power contraint
+ //
+ // 071011, by rcnjko.
+ //
+#ifdef TODO //WB, 11h has not implemented now.
+ if( priv->ieee80211->iw_mode != IW_MODE_INFRA && priv->bWithCcxCellPwr &&
+ channel == priv->ieee80211->current_network.channel)// & priv->ieee80211->mAssoc )
+ {
+ u8 CckCellPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_B, priv->CcxCellPwr);
+ u8 LegacyOfdmCellPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_G, priv->CcxCellPwr);
+ u8 OfdmCellPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_N_24G, priv->CcxCellPwr);
+
+ RT_TRACE(COMP_TXAGC,
+ ("CCX Cell Limit: %d dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n",
+ priv->CcxCellPwr, CckCellPwrIdx, LegacyOfdmCellPwrIdx, OfdmCellPwrIdx));
+ RT_TRACE(COMP_TXAGC,
+ ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n",
+ channel, powerlevel, powerlevelOFDM24G + priv->LegacyHTTxPowerDiff, powerlevelOFDM24G));
+
+ // CCK
+ if(powerlevel > CckCellPwrIdx)
+ powerlevel = CckCellPwrIdx;
+ // Legacy OFDM, HT OFDM
+ if(powerlevelOFDM24G + priv->LegacyHTTxPowerDiff > LegacyOfdmCellPwrIdx)
+ {
+ if((OfdmCellPwrIdx - priv->LegacyHTTxPowerDiff) > 0)
+ {
+ powerlevelOFDM24G = OfdmCellPwrIdx - priv->LegacyHTTxPowerDiff;
+ }
+ else
+ {
+ powerlevelOFDM24G = 0;
+ }
+ }
+
+ RT_TRACE(COMP_TXAGC,
+ ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n",
+ powerlevel, powerlevelOFDM24G + priv->LegacyHTTxPowerDiff, powerlevelOFDM24G));
+ }
+#endif
+
+ priv->CurrentCckTxPwrIdx = powerlevel;
+ priv->CurrentOfdm24GTxPwrIdx = powerlevelOFDM24G;
+
+ switch(priv->rf_chip)
+ {
+ case RF_8225:
+ //PHY_SetRF8225CckTxPower(dev, powerlevel);
+ //PHY_SetRF8225OfdmTxPower(dev, powerlevelOFDM24G);
+ break;
+
+ case RF_8256:
+#if 0
+ PHY_SetRF8256CCKTxPower(dev, powerlevel);
+ PHY_SetRF8256OFDMTxPower(dev, powerlevelOFDM24G);
+#endif
+ break;
+
+ case RF_6052:
+ PHY_RF6052SetCckTxPower(dev, powerlevel);
+ PHY_RF6052SetOFDMTxPower(dev, powerlevelOFDM24G);
+ break;
+
+ case RF_8258:
+ break;
+ default:
+ break;
+ }
+
+}
+
+//
+// Description:
+// Update transmit power level of all channel supported.
+//
+// TODO:
+// A mode.
+// By Bruce, 2008-02-04.
+// no use temp
+bool PHY_UpdateTxPowerDbm8192S(struct net_device* dev, long powerInDbm)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 idx;
+ u8 rf_path;
+
+ // TODO: A mode Tx power.
+ u8 CckTxPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_B, powerInDbm);
+ u8 OfdmTxPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_N_24G, powerInDbm);
+
+ if(OfdmTxPwrIdx - priv->LegacyHTTxPowerDiff > 0)
+ OfdmTxPwrIdx -= priv->LegacyHTTxPowerDiff;
+ else
+ OfdmTxPwrIdx = 0;
+
+ for(idx = 0; idx < 14; idx++)
+ {
+ priv->TxPowerLevelCCK[idx] = CckTxPwrIdx;
+ priv->TxPowerLevelCCK_A[idx] = CckTxPwrIdx;
+ priv->TxPowerLevelCCK_C[idx] = CckTxPwrIdx;
+ priv->TxPowerLevelOFDM24G[idx] = OfdmTxPwrIdx;
+ priv->TxPowerLevelOFDM24G_A[idx] = OfdmTxPwrIdx;
+ priv->TxPowerLevelOFDM24G_C[idx] = OfdmTxPwrIdx;
+
+ for (rf_path = 0; rf_path < 2; rf_path++)
+ {
+ priv->RfTxPwrLevelCck[rf_path][idx] = CckTxPwrIdx;
+ priv->RfTxPwrLevelOfdm1T[rf_path][idx] = \
+ priv->RfTxPwrLevelOfdm2T[rf_path][idx] = OfdmTxPwrIdx;
+ }
+ }
+
+ PHY_SetTxPowerLevel8192S(dev, priv->chan);
+
+ return TRUE;
+}
+
+/*
+ Description:
+ When beacon interval is changed, the values of the
+ hw registers should be modified.
+ By tynli, 2008.10.24.
+
+*/
+
+extern void PHY_SetBeaconHwReg( struct net_device* dev, u16 BeaconInterval)
+{
+ u32 NewBeaconNum;
+
+ NewBeaconNum = BeaconInterval *32 - 64;
+ //PlatformEFIOWrite4Byte(Adapter, WFM3+4, NewBeaconNum);
+ //PlatformEFIOWrite4Byte(Adapter, WFM3, 0xB026007C);
+ write_nic_dword(dev, WFM3+4, NewBeaconNum);
+ write_nic_dword(dev, WFM3, 0xB026007C);
+}
+
+//
+// Description:
+// Map dBm into Tx power index according to
+// current HW model, for example, RF and PA, and
+// current wireless mode.
+// By Bruce, 2008-01-29.
+// use in phy only
+static u8 phy_DbmToTxPwrIdx(
+ struct net_device* dev,
+ WIRELESS_MODE WirelessMode,
+ long PowerInDbm
+ )
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 TxPwrIdx = 0;
+ long Offset = 0;
+
+
+ //
+ // Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to
+ // 3dbm, and OFDM HT equals to 0dbm repectively.
+ // Note:
+ // The mapping may be different by different NICs. Do not use this formula for what needs accurate result.
+ // By Bruce, 2008-01-29.
+ //
+ switch(WirelessMode)
+ {
+ case WIRELESS_MODE_B:
+ Offset = -7;
+ break;
+
+ case WIRELESS_MODE_G:
+ case WIRELESS_MODE_N_24G:
+ Offset = -8;
+ break;
+ default:
+ break;
+ }
+
+ if((PowerInDbm - Offset) > 0)
+ {
+ TxPwrIdx = (u8)((PowerInDbm - Offset) * 2);
+ }
+ else
+ {
+ TxPwrIdx = 0;
+ }
+
+ // Tx Power Index is too large.
+ if(TxPwrIdx > MAX_TXPWR_IDX_NMODE_92S)
+ TxPwrIdx = MAX_TXPWR_IDX_NMODE_92S;
+
+ return TxPwrIdx;
+}
+//
+// Description:
+// Map Tx power index into dBm according to
+// current HW model, for example, RF and PA, and
+// current wireless mode.
+// By Bruce, 2008-01-29.
+// use in phy only
+static long phy_TxPwrIdxToDbm(
+ struct net_device* dev,
+ WIRELESS_MODE WirelessMode,
+ u8 TxPwrIdx
+ )
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ long Offset = 0;
+ long PwrOutDbm = 0;
+
+ //
+ // Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to
+ // 3dbm, and OFDM HT equals to 0dbm repectively.
+ // Note:
+ // The mapping may be different by different NICs. Do not use this formula for what needs accurate result.
+ // By Bruce, 2008-01-29.
+ //
+ switch(WirelessMode)
+ {
+ case WIRELESS_MODE_B:
+ Offset = -7;
+ break;
+
+ case WIRELESS_MODE_G:
+ case WIRELESS_MODE_N_24G:
+ Offset = -8;
+ break;
+ default:
+ break;
+ }
+
+ PwrOutDbm = TxPwrIdx / 2 + Offset; // Discard the decimal part.
+
+ return PwrOutDbm;
+}
+
+#ifdef TO_DO_LIST
+extern VOID
+PHY_ScanOperationBackup8192S(
+ IN PADAPTER Adapter,
+ IN u1Byte Operation
+ )
+{
+
+ HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
+ PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
+ u4Byte BitMask;
+ u1Byte initial_gain;
+
+
+
+
+#if(RTL8192S_DISABLE_FW_DM == 0)
+
+ if(!Adapter->bDriverStopped)
+ {
+ switch(Operation)
+ {
+ case SCAN_OPT_BACKUP:
+ //
+ // <Roger_Notes> We halt FW DIG and disable high ppower both two DMs here
+ // and resume both two DMs while scan complete.
+ // 2008.11.27.
+ //
+ Adapter->HalFunc.SetFwCmdHandler(Adapter, FW_CMD_PAUSE_DM_BY_SCAN);
+ break;
+
+ case SCAN_OPT_RESTORE:
+ //
+ // <Roger_Notes> We resume DIG and enable high power both two DMs here and
+ // recover earlier DIG settings.
+ // 2008.11.27.
+ //
+ Adapter->HalFunc.SetFwCmdHandler(Adapter, FW_CMD_RESUME_DM_BY_SCAN);
+ break;
+
+ default:
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Unknown Scan Backup Operation. \n"));
+ break;
+ }
+ }
+#endif
+}
+#endif
+
+//nouse temp
+void PHY_InitialGain8192S(struct net_device* dev,u8 Operation )
+{
+
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ //u32 BitMask;
+ //u8 initial_gain;
+
+#if 0 // For 8192s test disable
+ if(!dev->bDriverStopped)
+ {
+ switch(Operation)
+ {
+ case IG_Backup:
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("IG_Backup, backup the initial gain.\n"));
+ initial_gain = priv->DefaultInitialGain[0];
+ BitMask = bMaskByte0;
+ if(DM_DigTable.Dig_Algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ PHY_SetMacReg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
+ pMgntInfo->InitGain_Backup.XAAGCCore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask);
+ pMgntInfo->InitGain_Backup.XBAGCCore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask);
+ pMgntInfo->InitGain_Backup.XCAGCCore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask);
+ pMgntInfo->InitGain_Backup.XDAGCCore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask);
+ BitMask = bMaskByte2;
+ pMgntInfo->InitGain_Backup.CCA = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask);
+
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan InitialGainBackup 0xc50 is %x\n",pMgntInfo->InitGain_Backup.XAAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan InitialGainBackup 0xc58 is %x\n",pMgntInfo->InitGain_Backup.XBAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan InitialGainBackup 0xc60 is %x\n",pMgntInfo->InitGain_Backup.XCAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan InitialGainBackup 0xc68 is %x\n",pMgntInfo->InitGain_Backup.XDAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan InitialGainBackup 0xa0a is %x\n",pMgntInfo->InitGain_Backup.CCA));
+
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Write scan initial gain = 0x%x \n", initial_gain));
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
+ break;
+ case IG_Restore:
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("IG_Restore, restore the initial gain.\n"));
+ BitMask = 0x7f; //Bit0~ Bit6
+ if(DM_DigTable.Dig_Algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ PHY_SetMacReg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
+
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)pMgntInfo->InitGain_Backup.XAAGCCore1);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)pMgntInfo->InitGain_Backup.XBAGCCore1);
+ rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)pMgntInfo->InitGain_Backup.XCAGCCore1);
+ rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)pMgntInfo->InitGain_Backup.XDAGCCore1);
+ BitMask = (BIT22|BIT23);
+ rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)pMgntInfo->InitGain_Backup.CCA);
+
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan BBInitialGainRestore 0xc50 is %x\n",pMgntInfo->InitGain_Backup.XAAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan BBInitialGainRestore 0xc58 is %x\n",pMgntInfo->InitGain_Backup.XBAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan BBInitialGainRestore 0xc60 is %x\n",pMgntInfo->InitGain_Backup.XCAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan BBInitialGainRestore 0xc68 is %x\n",pMgntInfo->InitGain_Backup.XDAGCCore1));
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Scan BBInitialGainRestore 0xa0a is %x\n",pMgntInfo->InitGain_Backup.CCA));
+
+ if(DM_DigTable.Dig_Algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ PHY_SetMacReg(dev, UFWP, bMaskByte1, 0x1); // FW DIG ON
+ break;
+ default:
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("Unknown IG Operation. \n"));
+ break;
+ }
+ }
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: SetBWModeCallback8190Pci()
+ *
+ * Overview: Timer callback function for SetSetBWMode
+ *
+ * Input: PRT_TIMER pTimer
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Note: (1) We do not take j mode into consideration now
+ * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run
+ * concurrently?
+ *---------------------------------------------------------------------------*/
+// use in phy only (in win it's timer)
+void PHY_SetBWModeCallback8192S(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 regBwOpMode;
+
+ //return;
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //u32 NowL, NowH;
+ //u8Byte BeginTime, EndTime;
+ u8 regRRSR_RSC;
+
+ RT_TRACE(COMP_SWBW, "==>SetBWModeCallback8190Pci() Switch to %s bandwidth\n", \
+ priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz");
+
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SetBWModeInProgress= FALSE;
+ return;
+ }
+
+ if(!priv->up)
+ return;
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //NowL = read_nic_dword(dev, TSFR);
+ //NowH = read_nic_dword(dev, TSFR+4);
+ //BeginTime = ((u8Byte)NowH << 32) + NowL;
+
+ //3//
+ //3//<1>Set MAC register
+ //3//
+ regBwOpMode = read_nic_byte(dev, BW_OPMODE);
+ regRRSR_RSC = read_nic_byte(dev, RRSR+2);
+
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ //if(priv->card_8192_version >= VERSION_8192S_BCUT)
+ // write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x58);
+
+ regBwOpMode |= BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ break;
+
+ case HT_CHANNEL_WIDTH_20_40:
+ //if(priv->card_8192_version >= VERSION_8192S_BCUT)
+ // write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x18);
+
+ regBwOpMode &= ~BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ regRRSR_RSC = (regRRSR_RSC&0x90) |(priv->nCur40MhzPrimeSC<<5);
+ write_nic_byte(dev, RRSR+2, regRRSR_RSC);
+ break;
+
+ default:
+ RT_TRACE(COMP_DBG, "SetBWModeCallback8190Pci():\
+ unknown Bandwidth: %#X\n",priv->CurrentChannelBW);
+ break;
+ }
+
+ //3//
+ //3//<2>Set PHY related register
+ //3//
+ switch(priv->CurrentChannelBW)
+ {
+ /* 20 MHz channel*/
+ case HT_CHANNEL_WIDTH_20:
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
+
+ // Correct the tx power for CCK rate in 40M. Suggest by YN, 20071207
+ // It is set in Tx descriptor for 8192x series
+ //write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000);
+ //write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317);
+ //write_nic_dword(dev, rCCK0_DebugPort, 0x00000204);
+ #if 0 //LZM 090219
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskDWord, 0x1a1b0000);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, 0x090e1317);
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskDWord, 0x00000204);
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00300000, 3);
+ #endif
+
+ if (priv->card_8192_version >= VERSION_8192S_BCUT)
+ write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x58);
+
+
+ break;
+
+ /* 40 MHz channel*/
+ case HT_CHANNEL_WIDTH_20_40:
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
+
+ // Correct the tx power for CCK rate in 40M. Suggest by YN, 20071207
+ //write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000);
+ //write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e);
+ //write_nic_dword(dev, rCCK0_DebugPort, 0x00000409);
+ #if 0 //LZM 090219
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskDWord, 0x35360000);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, 0x121c252e);
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskDWord, 0x00000409);
+ #endif
+
+ // Set Control channel to upper or lower. These settings are required only for 40MHz
+ rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
+ rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
+
+ //rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00300000, 3);
+ if (priv->card_8192_version >= VERSION_8192S_BCUT)
+ write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x18);
+
+ break;
+
+ default:
+ RT_TRACE(COMP_DBG, "SetBWModeCallback8190Pci(): unknown Bandwidth: %#X\n"\
+ ,priv->CurrentChannelBW);
+ break;
+
+ }
+ //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //NowL = read_nic_dword(dev, TSFR);
+ //NowH = read_nic_dword(dev, TSFR+4);
+ //EndTime = ((u8Byte)NowH << 32) + NowL;
+ //RT_TRACE(COMP_SCAN, DBG_LOUD, ("SetBWModeCallback8190Pci: time of SetBWMode = %I64d us!\n", (EndTime - BeginTime)));
+
+ //3<3>Set RF related register
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+ //PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8256:
+ // Please implement this function in Hal8190PciPhy8256.c
+ //PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8258:
+ // Please implement this function in Hal8190PciPhy8258.c
+ // PHY_SetRF8258Bandwidth();
+ break;
+
+ case RF_PSEUDO_11N:
+ // Do Nothing
+ break;
+
+ case RF_6052:
+ PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW);
+ break;
+ default:
+ printk("Unknown rf_chip: %d\n", priv->rf_chip);
+ break;
+ }
+
+ priv->SetBWModeInProgress= FALSE;
+
+ RT_TRACE(COMP_SWBW, "<==SetBWModeCallback8190Pci() \n" );
+}
+
+
+ /*-----------------------------------------------------------------------------
+ * Function: SetBWMode8190Pci()
+ *
+ * Overview: This function is export to "HalCommon" moudule
+ *
+ * Input: PADAPTER Adapter
+ * HT_CHANNEL_WIDTH Bandwidth //20M or 40M
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Note: We do not take j mode into consideration now
+ *---------------------------------------------------------------------------*/
+//extern void PHY_SetBWMode8192S( struct net_device* dev,
+// HT_CHANNEL_WIDTH Bandwidth, // 20M or 40M
+// HT_EXTCHNL_OFFSET Offset // Upper, Lower, or Don't care
+void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ HT_CHANNEL_WIDTH tmpBW = priv->CurrentChannelBW;
+
+
+ // Modified it for 20/40 mhz switch by guangan 070531
+
+ //return;
+
+ //if(priv->SwChnlInProgress)
+// if(pMgntInfo->bScanInProgress)
+// {
+// RT_TRACE(COMP_SCAN, DBG_LOUD, ("SetBWMode8190Pci() %s Exit because bScanInProgress!\n",
+// Bandwidth == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz"));
+// return;
+// }
+
+// if(priv->SetBWModeInProgress)
+// {
+// // Modified it for 20/40 mhz switch by guangan 070531
+// RT_TRACE(COMP_SCAN, DBG_LOUD, ("SetBWMode8190Pci() %s cancel last timer because SetBWModeInProgress!\n",
+// Bandwidth == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz"));
+// PlatformCancelTimer(dev, &priv->SetBWModeTimer);
+// //return;
+// }
+
+ if(priv->SetBWModeInProgress)
+ return;
+
+ priv->SetBWModeInProgress= TRUE;
+
+ priv->CurrentChannelBW = Bandwidth;
+
+ if(Offset==HT_EXTCHNL_OFFSET_LOWER)
+ priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER;
+ else if(Offset==HT_EXTCHNL_OFFSET_UPPER)
+ priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER;
+ else
+ priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
+
+#if 0
+ if(!priv->bDriverStopped)
+ {
+#ifdef USE_WORKITEM
+ PlatformScheduleWorkItem(&(priv->SetBWModeWorkItem));//SetBWModeCallback8192SUsbWorkItem
+#else
+ PlatformSetTimer(dev, &(priv->SetBWModeTimer), 0);//PHY_SetBWModeCallback8192S
+#endif
+ }
+#endif
+ if((priv->up) )// && !(RT_CANNOT_IO(Adapter) && Adapter->bInSetPower) )
+ {
+#ifdef RTL8192SE
+ PHY_SetBWModeCallback8192S(dev);
+#elif defined(RTL8192SU)
+ SetBWModeCallback8192SUsbWorkItem(dev);
+#endif
+ }
+ else
+ {
+ RT_TRACE(COMP_SCAN, "PHY_SetBWMode8192S() SetBWModeInProgress FALSE driver sleep or unload\n");
+ priv->SetBWModeInProgress= FALSE;
+ priv->CurrentChannelBW = tmpBW;
+ }
+}
+
+// use in phy only (in win it's timer)
+void PHY_SwChnlCallback8192S(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 delay;
+ //bool ret;
+
+ RT_TRACE(COMP_CH, "==>SwChnlCallback8190Pci(), switch to channel %d\n", priv->chan);
+
+ if(!priv->up)
+ return;
+
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SwChnlInProgress=FALSE;
+ return; //return immediately if it is peudo-phy
+ }
+
+ do{
+ if(!priv->SwChnlInProgress)
+ break;
+
+ //if(!phy_SwChnlStepByStep(dev, priv->CurrentChannel, &priv->SwChnlStage, &priv->SwChnlStep, &delay))
+ if(!phy_SwChnlStepByStep(dev, priv->chan, &priv->SwChnlStage, &priv->SwChnlStep, &delay))
+ {
+ if(delay>0)
+ {
+ mdelay(delay);
+ //PlatformSetTimer(dev, &priv->SwChnlTimer, delay);
+ //mod_timer(&priv->SwChnlTimer, jiffies + MSECS(delay));
+ //==>PHY_SwChnlCallback8192S(dev); for 92se
+ //==>SwChnlCallback8192SUsb(dev) for 92su
+ }
+ else
+ continue;
+ }
+ else
+ {
+ priv->SwChnlInProgress=FALSE;
+ break;
+ }
+ }while(true);
+}
+
+// Call after initialization
+//extern void PHY_SwChnl8192S(struct net_device* dev, u8 channel)
+u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //u8 tmpchannel =channel;
+ //bool bResult = false;
+
+ if(!priv->up)
+ return false;
+
+ if(priv->SwChnlInProgress)
+ return false;
+
+ if(priv->SetBWModeInProgress)
+ return false;
+
+ //--------------------------------------------
+ switch(priv->ieee80211->mode)
+ {
+ case WIRELESS_MODE_A:
+ case WIRELESS_MODE_N_5G:
+ if (channel<=14){
+ RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14");
+ return false;
+ }
+ break;
+
+ case WIRELESS_MODE_B:
+ if (channel>14){
+ RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14");
+ return false;
+ }
+ break;
+
+ case WIRELESS_MODE_G:
+ case WIRELESS_MODE_N_24G:
+ if (channel>14){
+ RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14");
+ return false;
+ }
+ break;
+
+ default:
+ ;//RT_TRACE(COMP_ERR, "Invalid WirelessMode(%#x)!!\n", priv->ieee80211->mode);
+ break;
+ }
+ //--------------------------------------------
+
+ priv->SwChnlInProgress = TRUE;
+ if( channel == 0)
+ channel = 1;
+
+ priv->chan=channel;
+
+ priv->SwChnlStage=0;
+ priv->SwChnlStep=0;
+
+ if((priv->up))// && !(RT_CANNOT_IO(Adapter) && Adapter->bInSetPower))
+ {
+#ifdef RTL8192SE
+ PHY_SwChnlCallback8192S(dev);
+#elif defined(RTL8192SU)
+ SwChnlCallback8192SUsbWorkItem(dev);
+#endif
+#ifdef TO_DO_LIST
+ if(bResult)
+ {
+ RT_TRACE(COMP_SCAN, "PHY_SwChnl8192S SwChnlInProgress TRUE schdule workitem done\n");
+ }
+ else
+ {
+ RT_TRACE(COMP_SCAN, "PHY_SwChnl8192S SwChnlInProgress FALSE schdule workitem error\n");
+ priv->SwChnlInProgress = false;
+ priv->CurrentChannel = tmpchannel;
+ }
+#endif
+ }
+ else
+ {
+ RT_TRACE(COMP_SCAN, "PHY_SwChnl8192S SwChnlInProgress FALSE driver sleep or unload\n");
+ priv->SwChnlInProgress = false;
+ //priv->CurrentChannel = tmpchannel;
+ }
+ return true;
+}
+
+
+//
+// Description:
+// Switch channel synchronously. Called by SwChnlByDelayHandler.
+//
+// Implemented by Bruce, 2008-02-14.
+// The following procedure is operted according to SwChanlCallback8190Pci().
+// However, this procedure is performed synchronously which should be running under
+// passive level.
+//
+//not understant it
+void PHY_SwChnlPhy8192S( // Only called during initialize
+ struct net_device* dev,
+ u8 channel
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ RT_TRACE(COMP_SCAN, "==>PHY_SwChnlPhy8192S(), switch to channel %d.\n", priv->chan);
+
+#ifdef TO_DO_LIST
+ // Cannot IO.
+ if(RT_CANNOT_IO(dev))
+ return;
+#endif
+
+ // Channel Switching is in progress.
+ if(priv->SwChnlInProgress)
+ return;
+
+ //return immediately if it is peudo-phy
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SwChnlInProgress=FALSE;
+ return;
+ }
+
+ priv->SwChnlInProgress = TRUE;
+ if( channel == 0)
+ channel = 1;
+
+ priv->chan=channel;
+
+ priv->SwChnlStage = 0;
+ priv->SwChnlStep = 0;
+
+ phy_FinishSwChnlNow(dev,channel);
+
+ priv->SwChnlInProgress = FALSE;
+}
+
+// use in phy only
+static bool
+phy_SetSwChnlCmdArray(
+ SwChnlCmd* CmdTable,
+ u32 CmdTableIdx,
+ u32 CmdTableSz,
+ SwChnlCmdID CmdID,
+ u32 Para1,
+ u32 Para2,
+ u32 msDelay
+ )
+{
+ SwChnlCmd* pCmd;
+
+ if(CmdTable == NULL)
+ {
+ //RT_ASSERT(FALSE, ("phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"));
+ return FALSE;
+ }
+ if(CmdTableIdx >= CmdTableSz)
+ {
+ //RT_ASSERT(FALSE,
+ // ("phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n",
+ //CmdTableIdx, CmdTableSz));
+ return FALSE;
+ }
+
+ pCmd = CmdTable + CmdTableIdx;
+ pCmd->CmdID = CmdID;
+ pCmd->Para1 = Para1;
+ pCmd->Para2 = Para2;
+ pCmd->msDelay = msDelay;
+
+ return TRUE;
+}
+
+// use in phy only
+static bool
+phy_SwChnlStepByStep(
+ struct net_device* dev,
+ u8 channel,
+ u8 *stage,
+ u8 *step,
+ u32 *delay
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //PCHANNEL_ACCESS_SETTING pChnlAccessSetting;
+ SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT];
+ u32 PreCommonCmdCnt;
+ SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT];
+ u32 PostCommonCmdCnt;
+ SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
+ u32 RfDependCmdCnt;
+ SwChnlCmd *CurrentCmd = NULL;
+ u8 eRFPath;
+
+ //RT_ASSERT((dev != NULL), ("Adapter should not be NULL\n"));
+ //RT_ASSERT(IsLegalChannel(dev, channel), ("illegal channel: %d\n", channel));
+ RT_TRACE(COMP_CH, "===========>%s(), channel:%d, stage:%d, step:%d\n", __FUNCTION__, channel, *stage, *step);
+ //RT_ASSERT((pHalData != NULL), ("pHalData should not be NULL\n"));
+#ifdef ENABLE_DOT11D
+ if (!IsLegalChannel(priv->ieee80211, channel))
+ {
+ RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel);
+ return true; //return true to tell upper caller function this channel setting is finished! Or it will in while loop.
+ }
+#endif
+
+ //pChnlAccessSetting = &Adapter->MgntInfo.Info8185.ChannelAccessSetting;
+ //RT_ASSERT((pChnlAccessSetting != NULL), ("pChnlAccessSetting should not be NULL\n"));
+
+ //for(eRFPath = RF90_PATH_A; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ //for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ //{
+ // <1> Fill up pre common command.
+ PreCommonCmdCnt = 0;
+ phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT,
+ CmdID_SetTxPowerLevel, 0, 0, 0);
+ phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT,
+ CmdID_End, 0, 0, 0);
+
+ // <2> Fill up post common command.
+ PostCommonCmdCnt = 0;
+
+ phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT,
+ CmdID_End, 0, 0, 0);
+
+ // <3> Fill up RF dependent command.
+ RfDependCmdCnt = 0;
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+ if (channel < 1 || channel > 14)
+ RT_TRACE(COMP_ERR, "illegal channel for zebra:%d\n", channel);
+ //RT_ASSERT((channel >= 1 && channel <= 14), ("illegal channel for Zebra: %d\n", channel));
+ // 2008/09/04 MH Change channel.
+ phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_RF_WriteReg, rRfChannel, channel, 10);
+ phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_End, 0, 0, 0);
+ break;
+
+ case RF_8256:
+ if (channel < 1 || channel > 14)
+ RT_TRACE(COMP_ERR, "illegal channel for zebra:%d\n", channel);
+ // TEST!! This is not the table for 8256!!
+ //RT_ASSERT((channel >= 1 && channel <= 14), ("illegal channel for Zebra: %d\n", channel));
+ phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_RF_WriteReg, rRfChannel, channel, 10);
+ phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_End, 0, 0, 0);
+ break;
+
+ case RF_6052:
+ if (channel < 1 || channel > 14)
+ RT_TRACE(COMP_ERR, "illegal channel for zebra:%d\n", channel);
+ phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_RF_WriteReg, RF_CHNLBW, channel, 10);
+ phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_End, 0, 0, 0);
+ break;
+
+ case RF_8258:
+ break;
+
+ default:
+ //RT_ASSERT(FALSE, ("Unknown rf_chip: %d\n", priv->rf_chip));
+ return FALSE;
+ break;
+ }
+
+
+ do{
+ switch(*stage)
+ {
+ case 0:
+ CurrentCmd=&PreCommonCmd[*step];
+ break;
+ case 1:
+ CurrentCmd=&RfDependCmd[*step];
+ break;
+ case 2:
+ CurrentCmd=&PostCommonCmd[*step];
+ break;
+ }
+
+ if(CurrentCmd->CmdID==CmdID_End)
+ {
+ if((*stage)==2)
+ {
+ return TRUE;
+ }
+ else
+ {
+ (*stage)++;
+ (*step)=0;
+ continue;
+ }
+ }
+
+ switch(CurrentCmd->CmdID)
+ {
+ case CmdID_SetTxPowerLevel:
+ //if(priv->card_8192_version > VERSION_8190_BD)
+ PHY_SetTxPowerLevel8192S(dev,channel);
+ break;
+ case CmdID_WritePortUlong:
+ write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2);
+ break;
+ case CmdID_WritePortUshort:
+ write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2);
+ break;
+ case CmdID_WritePortUchar:
+ write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2);
+ break;
+ case CmdID_RF_WriteReg: // Only modify channel for the register now !!!!!
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+#if (defined RTL8192SE ||defined RTL8192SU )
+ // For new T65 RF 0222d register 0x18 bit 0-9 = channel number.
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, 0x1f, (CurrentCmd->Para2));
+ //printk("====>%x, %x, read_back:%x\n", CurrentCmd->Para2,CurrentCmd->Para1, rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, 0x1f));
+#else
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, bRFRegOffsetMask, ((CurrentCmd->Para2)<<7));
+#endif
+ }
+ break;
+ default:
+ break;
+ }
+
+ break;
+ }while(TRUE);
+ //cosa }/*for(Number of RF paths)*/
+
+ (*delay)=CurrentCmd->msDelay;
+ (*step)++;
+ RT_TRACE(COMP_CH, "<===========%s(), channel:%d, stage:%d, step:%d\n", __FUNCTION__, channel, *stage, *step);
+ return FALSE;
+}
+
+//called PHY_SwChnlPhy8192S, SwChnlCallback8192SUsbWorkItem
+// use in phy only
+static void
+phy_FinishSwChnlNow( // We should not call this function directly
+ struct net_device* dev,
+ u8 channel
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 delay;
+
+ while(!phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay))
+ {
+ if(delay>0)
+ mdelay(delay);
+ if(!priv->up)
+ break;
+ }
+}
+
+
+/*-----------------------------------------------------------------------------
+ * Function: PHYCheckIsLegalRfPath8190Pci()
+ *
+ * Overview: Check different RF type to execute legal judgement. If RF Path is illegal
+ * We will return false.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/15/2007 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+ //called by rtl8192_phy_QueryRFReg, rtl8192_phy_SetRFReg, PHY_SetRFPowerState8192SUsb
+//extern bool
+//PHY_CheckIsLegalRfPath8192S(
+// struct net_device* dev,
+// u32 eRFPath)
+u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath)
+{
+// struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rtValue = TRUE;
+
+ // NOt check RF Path now.!
+#if 0
+ if (priv->rf_type == RF_1T2R && eRFPath != RF90_PATH_A)
+ {
+ rtValue = FALSE;
+ }
+ if (priv->rf_type == RF_1T2R && eRFPath != RF90_PATH_A)
+ {
+
+ }
+#endif
+ return rtValue;
+
+} /* PHY_CheckIsLegalRfPath8192S */
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_IQCalibrate8192S()
+ *
+ * Overview: After all MAC/PHY/RF is configued. We must execute IQ calibration
+ * to improve RF EVM!!?
+ *
+ * Input: IN PADAPTER pAdapter
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 10/07/2008 MHC Create. Document from SD3 RFSI Jenyu.
+ *
+ *---------------------------------------------------------------------------*/
+ //called by InitializeAdapter8192SE
+void
+PHY_IQCalibrate( struct net_device* dev)
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 i, reg;
+ u32 old_value;
+ long X, Y, TX0[4];
+ u32 TXA[4];
+
+ // 1. Check QFN68 or 64 92S (Read from EEPROM)
+
+ //
+ // 2. QFN 68
+ //
+ // For 1T2R IQK only now !!!
+ for (i = 0; i < 10; i++)
+ {
+ // IQK
+ rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05430);
+ //PlatformStallExecution(5);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000800e4);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x80800000);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe40, bMaskDWord, 0x02140148);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe44, bMaskDWord, 0x681604a2);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe4c, bMaskDWord, 0x000028d1);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe60, bMaskDWord, 0x0214014d);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe64, bMaskDWord, 0x281608ba);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe6c, bMaskDWord, 0x000028d1);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xfb000001);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xf8000001);
+ udelay(2000);
+ rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05433);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000000e4);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x0);
+
+
+ reg = rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord);
+
+ // Readback IQK value and rewrite
+ if (!(reg&(BIT27|BIT28|BIT30|BIT31)))
+ {
+ old_value = (rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord) & 0x3FF);
+
+ // Calibrate init gain for A path for TX0
+ X = (rtl8192_QueryBBReg(dev, 0xe94, bMaskDWord) & 0x03FF0000)>>16;
+ TXA[RF90_PATH_A] = (X * old_value)/0x100;
+ reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
+ reg = (reg & 0xFFFFFC00) | (u32)TXA[RF90_PATH_A];
+ rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate init gain for C path for TX0
+ Y = ( rtl8192_QueryBBReg(dev, 0xe9C, bMaskDWord) & 0x03FF0000)>>16;
+ TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
+ reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
+ reg = (reg & 0xffc0ffff) |((u32) (TX0[RF90_PATH_C]&0x3F)<<16);
+ rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
+ reg = rtl8192_QueryBBReg(dev, 0xc94, bMaskDWord);
+ reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
+ rtl8192_setBBreg(dev, 0xc94, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate RX A and B for RX0
+ reg = rtl8192_QueryBBReg(dev, 0xc14, bMaskDWord);
+ X = (rtl8192_QueryBBReg(dev, 0xea4, bMaskDWord) & 0x03FF0000)>>16;
+ reg = (reg & 0xFFFFFC00) |X;
+ rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
+ Y = (rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord) & 0x003F0000)>>16;
+ reg = (reg & 0xFFFF03FF) |Y<<10;
+ rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
+ udelay(5);
+ old_value = (rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord) & 0x3FF);
+
+ // Calibrate init gain for A path for TX1 !!!!!!
+ X = (rtl8192_QueryBBReg(dev, 0xeb4, bMaskDWord) & 0x03FF0000)>>16;
+ reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
+ TXA[RF90_PATH_A] = (X * old_value) / 0x100;
+ reg = (reg & 0xFFFFFC00) | TXA[RF90_PATH_A];
+ rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate init gain for C path for TX1
+ Y = (rtl8192_QueryBBReg(dev, 0xebc, bMaskDWord)& 0x03FF0000)>>16;
+ TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
+ reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
+ reg = (reg & 0xffc0ffff) |( (TX0[RF90_PATH_C]&0x3F)<<16);
+ rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
+ reg = rtl8192_QueryBBReg(dev, 0xc9c, bMaskDWord);
+ reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
+ rtl8192_setBBreg(dev, 0xc9c, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate RX A and B for RX1
+ reg = rtl8192_QueryBBReg(dev, 0xc1c, bMaskDWord);
+ X = (rtl8192_QueryBBReg(dev, 0xec4, bMaskDWord) & 0x03FF0000)>>16;
+ reg = (reg & 0xFFFFFC00) |X;
+ rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
+
+ Y = (rtl8192_QueryBBReg(dev, 0xecc, bMaskDWord) & 0x003F0000)>>16;
+ reg = (reg & 0xFFFF03FF) |Y<<10;
+ rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
+ udelay(5);
+
+ RT_TRACE(COMP_INIT, "PHY_IQCalibrate OK\n");
+ break;
+ }
+
+ }
+
+
+ //
+ // 3. QFN64. Not enabled now !!! We must use different gain table for 1T2R.
+ //
+
+
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_IQCalibrateBcut()
+ *
+ * Overview: After all MAC/PHY/RF is configued. We must execute IQ calibration
+ * to improve RF EVM!!?
+ *
+ * Input: IN PADAPTER pAdapter
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/18/2008 MHC Create. Document from SD3 RFSI Jenyu.
+ * 92S B-cut QFN 68 pin IQ calibration procedure.doc
+ *
+ *---------------------------------------------------------------------------*/
+extern void PHY_IQCalibrateBcut(struct net_device* dev)
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ //PMGNT_INFO pMgntInfo = &pAdapter->MgntInfo;
+ u32 i, reg;
+ u32 old_value;
+ long X, Y, TX0[4];
+ u32 TXA[4];
+ u32 calibrate_set[13] = {0};
+ u32 load_value[13];
+ u8 RfPiEnable=0;
+
+ // 0. Check QFN68 or 64 92S (Read from EEPROM/EFUSE)
+
+ //
+ // 1. Save e70~ee0 register setting, and load calibration setting
+ //
+ /*
+ 0xee0[31:0]=0x3fed92fb;
+ 0xedc[31:0] =0x3fed92fb;
+ 0xe70[31:0] =0x3fed92fb;
+ 0xe74[31:0] =0x3fed92fb;
+ 0xe78[31:0] =0x3fed92fb;
+ 0xe7c[31:0]= 0x3fed92fb;
+ 0xe80[31:0]= 0x3fed92fb;
+ 0xe84[31:0]= 0x3fed92fb;
+ 0xe88[31:0]= 0x3fed92fb;
+ 0xe8c[31:0]= 0x3fed92fb;
+ 0xed0[31:0]= 0x3fed92fb;
+ 0xed4[31:0]= 0x3fed92fb;
+ 0xed8[31:0]= 0x3fed92fb;
+ */
+ calibrate_set [0] = 0xee0;
+ calibrate_set [1] = 0xedc;
+ calibrate_set [2] = 0xe70;
+ calibrate_set [3] = 0xe74;
+ calibrate_set [4] = 0xe78;
+ calibrate_set [5] = 0xe7c;
+ calibrate_set [6] = 0xe80;
+ calibrate_set [7] = 0xe84;
+ calibrate_set [8] = 0xe88;
+ calibrate_set [9] = 0xe8c;
+ calibrate_set [10] = 0xed0;
+ calibrate_set [11] = 0xed4;
+ calibrate_set [12] = 0xed8;
+ //RT_TRACE(COMP_INIT, DBG_LOUD, ("Save e70~ee0 register setting\n"));
+ for (i = 0; i < 13; i++)
+ {
+ load_value[i] = rtl8192_QueryBBReg(dev, calibrate_set[i], bMaskDWord);
+ rtl8192_setBBreg(dev, calibrate_set[i], bMaskDWord, 0x3fed92fb);
+
+ }
+
+ RfPiEnable = (u8)rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter1, BIT8);
+
+ //
+ // 2. QFN 68
+ //
+ // For 1T2R IQK only now !!!
+ for (i = 0; i < 10; i++)
+ {
+ RT_TRACE(COMP_INIT, "IQK -%d\n", i);
+ //BB switch to PI mode. If default is PI mode, ignoring 2 commands below.
+ if (!RfPiEnable) //if original is SI mode, then switch to PI mode.
+ {
+ //DbgPrint("IQK Switch to PI mode\n");
+ rtl8192_setBBreg(dev, 0x820, bMaskDWord, 0x01000100);
+ rtl8192_setBBreg(dev, 0x828, bMaskDWord, 0x01000100);
+ }
+
+ // IQK
+ // 2. IQ calibration & LO leakage calibration
+ rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05430);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000800e4);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x80800000);
+ udelay(5);
+ //path-A IQ K and LO K gain setting
+ rtl8192_setBBreg(dev, 0xe40, bMaskDWord, 0x02140102);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe44, bMaskDWord, 0x681604c2);
+ udelay(5);
+ //set LO calibration
+ rtl8192_setBBreg(dev, 0xe4c, bMaskDWord, 0x000028d1);
+ udelay(5);
+ //path-B IQ K and LO K gain setting
+ rtl8192_setBBreg(dev, 0xe60, bMaskDWord, 0x02140102);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe64, bMaskDWord, 0x28160d05);
+ udelay(5);
+ //K idac_I & IQ
+ rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xfb000000);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xf8000000);
+ udelay(5);
+
+ // delay 2ms
+ udelay(2000);
+
+ //idac_Q setting
+ rtl8192_setBBreg(dev, 0xe6c, bMaskDWord, 0x020028d1);
+ udelay(5);
+ //K idac_Q & IQ
+ rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xfb000000);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xf8000000);
+
+ // delay 2ms
+ udelay(2000);
+
+ rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05433);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000000e4);
+ udelay(5);
+ rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x0);
+
+ if (!RfPiEnable) //if original is SI mode, then switch to PI mode.
+ {
+ //DbgPrint("IQK Switch back to SI mode\n");
+ rtl8192_setBBreg(dev, 0x820, bMaskDWord, 0x01000000);
+ rtl8192_setBBreg(dev, 0x828, bMaskDWord, 0x01000000);
+ }
+
+
+ reg = rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord);
+
+ // 3. check fail bit, and fill BB IQ matrix
+ // Readback IQK value and rewrite
+ if (!(reg&(BIT27|BIT28|BIT30|BIT31)))
+ {
+ old_value = (rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord) & 0x3FF);
+
+ // Calibrate init gain for A path for TX0
+ X = (rtl8192_QueryBBReg(dev, 0xe94, bMaskDWord) & 0x03FF0000)>>16;
+ TXA[RF90_PATH_A] = (X * old_value)/0x100;
+ reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
+ reg = (reg & 0xFFFFFC00) | (u32)TXA[RF90_PATH_A];
+ rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate init gain for C path for TX0
+ Y = ( rtl8192_QueryBBReg(dev, 0xe9C, bMaskDWord) & 0x03FF0000)>>16;
+ TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
+ reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
+ reg = (reg & 0xffc0ffff) |((u32) (TX0[RF90_PATH_C]&0x3F)<<16);
+ rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
+ reg = rtl8192_QueryBBReg(dev, 0xc94, bMaskDWord);
+ reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
+ rtl8192_setBBreg(dev, 0xc94, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate RX A and B for RX0
+ reg = rtl8192_QueryBBReg(dev, 0xc14, bMaskDWord);
+ X = (rtl8192_QueryBBReg(dev, 0xea4, bMaskDWord) & 0x03FF0000)>>16;
+ reg = (reg & 0xFFFFFC00) |X;
+ rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
+ Y = (rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord) & 0x003F0000)>>16;
+ reg = (reg & 0xFFFF03FF) |Y<<10;
+ rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
+ udelay(5);
+ old_value = (rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord) & 0x3FF);
+
+ // Calibrate init gain for A path for TX1 !!!!!!
+ X = (rtl8192_QueryBBReg(dev, 0xeb4, bMaskDWord) & 0x03FF0000)>>16;
+ reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
+ TXA[RF90_PATH_A] = (X * old_value) / 0x100;
+ reg = (reg & 0xFFFFFC00) | TXA[RF90_PATH_A];
+ rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate init gain for C path for TX1
+ Y = (rtl8192_QueryBBReg(dev, 0xebc, bMaskDWord)& 0x03FF0000)>>16;
+ TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
+ reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
+ reg = (reg & 0xffc0ffff) |( (TX0[RF90_PATH_C]&0x3F)<<16);
+ rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
+ reg = rtl8192_QueryBBReg(dev, 0xc9c, bMaskDWord);
+ reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
+ rtl8192_setBBreg(dev, 0xc9c, bMaskDWord, reg);
+ udelay(5);
+
+ // Calibrate RX A and B for RX1
+ reg = rtl8192_QueryBBReg(dev, 0xc1c, bMaskDWord);
+ X = (rtl8192_QueryBBReg(dev, 0xec4, bMaskDWord) & 0x03FF0000)>>16;
+ reg = (reg & 0xFFFFFC00) |X;
+ rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
+
+ Y = (rtl8192_QueryBBReg(dev, 0xecc, bMaskDWord) & 0x003F0000)>>16;
+ reg = (reg & 0xFFFF03FF) |Y<<10;
+ rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
+ udelay(5);
+
+ RT_TRACE(COMP_INIT, "PHY_IQCalibrate OK\n");
+ break;
+ }
+
+ }
+
+ //
+ // 4. Reload e70~ee0 register setting.
+ //
+ //RT_TRACE(COMP_INIT, DBG_LOUD, ("Reload e70~ee0 register setting.\n"));
+ for (i = 0; i < 13; i++)
+ rtl8192_setBBreg(dev, calibrate_set[i], bMaskDWord, load_value[i]);
+
+
+ //
+ // 3. QFN64. Not enabled now !!! We must use different gain table for 1T2R.
+ //
+
+
+
+} // PHY_IQCalibrateBcut
+
+
+//
+// Move from phycfg.c to gen.c to be code independent later
+//
+//-------------------------Move to other DIR later----------------------------*/
+//#if (DEV_BUS_TYPE == USB_INTERFACE)
+#ifdef RTL8192SU
+
+// use in phy only (in win it's timer)
+void SwChnlCallback8192SUsb(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 delay;
+// bool ret;
+
+ RT_TRACE(COMP_SCAN, "==>SwChnlCallback8190Pci(), switch to channel\
+ %d\n", priv->chan);
+
+
+ if(!priv->up)
+ return;
+
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SwChnlInProgress=FALSE;
+ return; //return immediately if it is peudo-phy
+ }
+
+ do{
+ if(!priv->SwChnlInProgress)
+ break;
+
+ if(!phy_SwChnlStepByStep(dev, priv->chan, &priv->SwChnlStage, &priv->SwChnlStep, &delay))
+ {
+ if(delay>0)
+ {
+ //PlatformSetTimer(dev, &priv->SwChnlTimer, delay);
+
+ }
+ else
+ continue;
+ }
+ else
+ {
+ priv->SwChnlInProgress=FALSE;
+ }
+ break;
+ }while(TRUE);
+}
+
+
+//
+// Callback routine of the work item for switch channel.
+//
+// use in phy only (in win it's work)
+void SwChnlCallback8192SUsbWorkItem(struct net_device *dev )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ RT_TRACE(COMP_TRACE, "==> SwChnlCallback8192SUsbWorkItem()\n");
+#ifdef TO_DO_LIST
+ if(pAdapter->bInSetPower && RT_USB_CANNOT_IO(pAdapter))
+ {
+ RT_TRACE(COMP_SCAN, DBG_LOUD, ("<== SwChnlCallback8192SUsbWorkItem() SwChnlInProgress FALSE driver sleep or unload\n"));
+
+ pHalData->SwChnlInProgress = FALSE;
+ return;
+ }
+#endif
+ phy_FinishSwChnlNow(dev, priv->chan);
+ priv->SwChnlInProgress = FALSE;
+
+ RT_TRACE(COMP_TRACE, "<== SwChnlCallback8192SUsbWorkItem()\n");
+}
+
+
+/*-----------------------------------------------------------------------------
+ * Function: SetBWModeCallback8192SUsb()
+ *
+ * Overview: Timer callback function for SetSetBWMode
+ *
+ * Input: PRT_TIMER pTimer
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Note: (1) We do not take j mode into consideration now
+ * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run
+ * concurrently?
+ *---------------------------------------------------------------------------*/
+//====>//rtl8192_SetBWMode
+// use in phy only (in win it's timer)
+void SetBWModeCallback8192SUsb(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 regBwOpMode;
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //u32 NowL, NowH;
+ //u8Byte BeginTime, EndTime;
+ u8 regRRSR_RSC;
+
+ RT_TRACE(COMP_SCAN, "==>SetBWModeCallback8190Pci() Switch to %s bandwidth\n", \
+ priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz");
+
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SetBWModeInProgress= FALSE;
+ return;
+ }
+
+ if(!priv->up)
+ return;
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //NowL = read_nic_dword(dev, TSFR);
+ //NowH = read_nic_dword(dev, TSFR+4);
+ //BeginTime = ((u8Byte)NowH << 32) + NowL;
+
+ //3<1>Set MAC register
+ regBwOpMode = read_nic_byte(dev, BW_OPMODE);
+ regRRSR_RSC = read_nic_byte(dev, RRSR+2);
+
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ regBwOpMode |= BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ break;
+
+ case HT_CHANNEL_WIDTH_20_40:
+ regBwOpMode &= ~BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+
+ regRRSR_RSC = (regRRSR_RSC&0x90) |(priv->nCur40MhzPrimeSC<<5);
+ write_nic_byte(dev, RRSR+2, regRRSR_RSC);
+ break;
+
+ default:
+ RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci():\
+ unknown Bandwidth: %#X\n",priv->CurrentChannelBW);
+ break;
+ }
+
+ //3 <2>Set PHY related register
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
+ #if 0 //LZM090219
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00300000, 3);
+
+ // Correct the tx power for CCK rate in 20M. Suggest by YN, 20071207
+ //write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000);
+ //write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317);
+ //write_nic_dword(dev, rCCK0_DebugPort, 0x00000204);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskDWord, 0x1a1b0000);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, 0x090e1317);
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskDWord, 0x00000204);
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00300000, 3);
+ #endif
+
+ if (priv->card_8192_version >= VERSION_8192S_BCUT)
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);
+
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
+ rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
+ rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
+
+ // Correct the tx power for CCK rate in 40M. Suggest by YN, 20071207
+ //PHY_SetBBReg(Adapter, rCCK0_TxFilter1, bMaskDWord, 0x35360000);
+ //PHY_SetBBReg(Adapter, rCCK0_TxFilter2, bMaskDWord, 0x121c252e);
+ //PHY_SetBBReg(Adapter, rCCK0_DebugPort, bMaskDWord, 0x00000409);
+ //PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter1, bADClkPhase, 0);
+
+ if (priv->card_8192_version >= VERSION_8192S_BCUT)
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18);
+
+ break;
+ default:
+ RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci(): unknown Bandwidth: %#X\n"\
+ ,priv->CurrentChannelBW);
+ break;
+
+ }
+ //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //NowL = read_nic_dword(dev, TSFR);
+ //NowH = read_nic_dword(dev, TSFR+4);
+ //EndTime = ((u8Byte)NowH << 32) + NowL;
+ //RT_TRACE(COMP_SCAN, DBG_LOUD, ("SetBWModeCallback8190Pci: time of SetBWMode = %I64d us!\n", (EndTime - BeginTime)));
+
+#if 1
+ //3<3>Set RF related register
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+ PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8256:
+ // Please implement this function in Hal8190PciPhy8256.c
+ //PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_6052:
+ PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8258:
+ // Please implement this function in Hal8190PciPhy8258.c
+ // PHY_SetRF8258Bandwidth();
+ break;
+
+ case RF_PSEUDO_11N:
+ // Do Nothing
+ break;
+
+ default:
+ //RT_ASSERT(FALSE, ("Unknown rf_chip: %d\n", priv->rf_chip));
+ break;
+ }
+#endif
+ priv->SetBWModeInProgress= FALSE;
+
+ RT_TRACE(COMP_SCAN, "<==SetBWMode8190Pci()" );
+}
+
+//
+// Callback routine of the work item for set bandwidth mode.
+//
+// use in phy only (in win it's work)
+void SetBWModeCallback8192SUsbWorkItem(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 regBwOpMode;
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //u32 NowL, NowH;
+ //u8Byte BeginTime, EndTime;
+ u8 regRRSR_RSC;
+
+ RT_TRACE(COMP_SCAN, "==>SetBWModeCallback8192SUsbWorkItem() Switch to %s bandwidth\n", \
+ priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz");
+
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SetBWModeInProgress= FALSE;
+ return;
+ }
+
+ if(!priv->up)
+ return;
+
+ // Added it for 20/40 mhz switch time evaluation by guangan 070531
+ //NowL = read_nic_dword(dev, TSFR);
+ //NowH = read_nic_dword(dev, TSFR+4);
+ //BeginTime = ((u8Byte)NowH << 32) + NowL;
+
+ //3<1>Set MAC register
+ regBwOpMode = read_nic_byte(dev, BW_OPMODE);
+ regRRSR_RSC = read_nic_byte(dev, RRSR+2);
+
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ regBwOpMode |= BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ break;
+
+ case HT_CHANNEL_WIDTH_20_40:
+ regBwOpMode &= ~BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ regRRSR_RSC = (regRRSR_RSC&0x90) |(priv->nCur40MhzPrimeSC<<5);
+ write_nic_byte(dev, RRSR+2, regRRSR_RSC);
+
+ break;
+
+ default:
+ RT_TRACE(COMP_DBG, "SetBWModeCallback8192SUsbWorkItem():\
+ unknown Bandwidth: %#X\n",priv->CurrentChannelBW);
+ break;
+ }
+
+ //3 <2>Set PHY related register
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
+
+ #if 0 //LZM 090219
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bADClkPhase, 1);
+
+ // Correct the tx power for CCK rate in 20M. Suggest by YN, 20071207
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskDWord, 0x1a1b0000);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, 0x090e1317);
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskDWord, 0x00000204);
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1);
+ #endif
+
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);
+
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
+ #if 0 //LZM 090219
+ rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
+
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bADClkPhase, 0);
+
+ rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
+ // Correct the tx power for CCK rate in 40M. Suggest by YN, 20071207
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskDWord, 0x35360000);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, 0x121c252e);
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskDWord, 0x00000409);
+ #endif
+
+ // Set Control channel to upper or lower. These settings are required only for 40MHz
+ rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
+ rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
+
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18);
+
+ break;
+
+
+ default:
+ RT_TRACE(COMP_DBG, "SetBWModeCallback8192SUsbWorkItem(): unknown Bandwidth: %#X\n"\
+ ,priv->CurrentChannelBW);
+ break;
+
+ }
+ //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315
+
+ //3<3>Set RF related register
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+ PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8256:
+ // Please implement this function in Hal8190PciPhy8256.c
+ //PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_6052:
+ PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8258:
+ // Please implement this function in Hal8190PciPhy8258.c
+ // PHY_SetRF8258Bandwidth();
+ break;
+
+ case RF_PSEUDO_11N:
+ // Do Nothing
+ break;
+
+ default:
+ //RT_ASSERT(FALSE, ("Unknown rf_chip: %d\n", priv->rf_chip));
+ break;
+ }
+
+ priv->SetBWModeInProgress= FALSE;
+
+ RT_TRACE(COMP_SCAN, "<==SetBWModeCallback8192SUsbWorkItem()" );
+}
+
+//--------------------------Move to oter DIR later-------------------------------*/
+#ifdef RTL8192SU
+void InitialGain8192S(struct net_device *dev, u8 Operation)
+{
+#ifdef TO_DO_LIST
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+
+}
+#endif
+
+void InitialGain819xUsb(struct net_device *dev, u8 Operation)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->InitialGainOperateType = Operation;
+
+ if(priv->up)
+ {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->initialgain_operate_wq,0);
+ #else
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->initialgain_operate_wq);
+ #else
+ queue_work(priv->priv_wq,&priv->initialgain_operate_wq);
+ #endif
+ #endif
+ }
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void InitialGainOperateWorkItemCallBack(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct r8192_priv *priv = container_of(dwork,struct r8192_priv,initialgain_operate_wq);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+extern void InitialGainOperateWorkItemCallBack(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+#define SCAN_RX_INITIAL_GAIN 0x17
+#define POWER_DETECTION_TH 0x08
+ u32 BitMask;
+ u8 initial_gain;
+ u8 Operation;
+
+ Operation = priv->InitialGainOperateType;
+
+ switch(Operation)
+ {
+ case IG_Backup:
+ RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n");
+ initial_gain = SCAN_RX_INITIAL_GAIN;//priv->DefaultInitialGain[0];//
+ BitMask = bMaskByte0;
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
+ priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask);
+ priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask);
+ priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask);
+ priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask);
+ BitMask = bMaskByte2;
+ priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask);
+
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca);
+
+ RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain);
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
+ RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH);
+ write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH);
+ break;
+ case IG_Restore:
+ RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n");
+ BitMask = 0x7f; //Bit0~ Bit6
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
+
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1);
+ BitMask = bMaskByte2;
+ rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca);
+
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca);
+
+ PHY_SetTxPowerLevel8192S(dev,priv->ieee80211->current_network.channel);
+
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // FW DIG ON
+ break;
+ default:
+ RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n");
+ break;
+ }
+}
+
+#endif // #if (DEV_BUS_TYPE == USB_INTERFACE)
+
+//-----------------------------------------------------------------------------
+// Description:
+// Schedule workitem to send specific CMD IO to FW.
+// Added by Roger, 2008.12.03.
+//
+//-----------------------------------------------------------------------------
+bool HalSetFwCmd8192S(struct net_device* dev, FW_CMD_IO_TYPE FwCmdIO)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 FwCmdWaitCounter = 0;
+
+ u16 FwCmdWaitLimit = 1000;
+
+ //if(IS_HARDWARE_TYPE_8192SU(Adapter) && Adapter->bInHctTest)
+ if(priv->bInHctTest)
+ return true;
+
+ RT_TRACE(COMP_CMD, "-->HalSetFwCmd8192S(): Set FW Cmd(%x), SetFwCmdInProgress(%d)\n", (u32)FwCmdIO, priv->SetFwCmdInProgress);
+
+ // Will be done by high power respectively.
+ if(FwCmdIO==FW_CMD_DIG_HALT || FwCmdIO==FW_CMD_DIG_RESUME)
+ {
+ RT_TRACE(COMP_CMD, "<--HalSetFwCmd8192S(): Set FW Cmd(%x)\n", (u32)FwCmdIO);
+ return false;
+ }
+
+#if 1
+ while(priv->SetFwCmdInProgress && FwCmdWaitCounter<FwCmdWaitLimit)
+ {
+ //if(RT_USB_CANNOT_IO(Adapter))
+ //{
+ // RT_TRACE(COMP_CMD, DBG_WARNING, ("HalSetFwCmd8192S(): USB can NOT IO!!\n"));
+ // return FALSE;
+ //}
+
+ RT_TRACE(COMP_CMD, "HalSetFwCmd8192S(): previous workitem not finish!!\n");
+ return false;
+ FwCmdWaitCounter ++;
+ RT_TRACE(COMP_CMD, "HalSetFwCmd8192S(): Wait 10 ms (%d times)...\n", FwCmdWaitCounter);
+ udelay(100);
+ }
+
+ if(FwCmdWaitCounter == FwCmdWaitLimit)
+ {
+ //RT_ASSERT(FALSE, ("SetFwCmdIOWorkItemCallback(): Wait too logn to set FW CMD\n"));
+ RT_TRACE(COMP_CMD, "HalSetFwCmd8192S(): Wait too logn to set FW CMD\n");
+ //return false;
+ }
+#endif
+ if (priv->SetFwCmdInProgress)
+ {
+ RT_TRACE(COMP_ERR, "<--HalSetFwCmd8192S(): Set FW Cmd(%#x)\n", FwCmdIO);
+ return false;
+ }
+ priv->SetFwCmdInProgress = TRUE;
+ priv->CurrentFwCmdIO = FwCmdIO; // Update current FW Cmd for callback use.
+
+ phy_SetFwCmdIOCallback(dev);
+ return true;
+}
+void ChkFwCmdIoDone(struct net_device* dev)
+{
+ u16 PollingCnt = 1000;
+ u32 tmpValue;
+
+ do
+ {// Make sure that CMD IO has be accepted by FW.
+#ifdef TO_DO_LIST
+ if(RT_USB_CANNOT_IO(Adapter))
+ {
+ RT_TRACE(COMP_CMD, "ChkFwCmdIoDone(): USB can NOT IO!!\n");
+ return;
+ }
+#endif
+ udelay(10); // sleep 20us
+ tmpValue = read_nic_dword(dev, WFM5);
+ if(tmpValue == 0)
+ {
+ RT_TRACE(COMP_CMD, "[FW CMD] Set FW Cmd success!!\n");
+ break;
+ }
+ else
+ {
+ RT_TRACE(COMP_CMD, "[FW CMD] Polling FW Cmd PollingCnt(%d)!!\n", PollingCnt);
+ }
+ }while( --PollingCnt );
+
+ if(PollingCnt == 0)
+ {
+ RT_TRACE(COMP_ERR, "[FW CMD] Set FW Cmd fail!!\n");
+ }
+}
+// Callback routine of the timer callback for FW Cmd IO.
+//
+// Description:
+// This routine will send specific CMD IO to FW and check whether it is done.
+//
+void phy_SetFwCmdIOCallback(struct net_device* dev)
+{
+ //struct net_device* dev = (struct net_device*) data;
+ u32 input;
+ static u32 ScanRegister;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ if(!priv->up)
+ {
+ RT_TRACE(COMP_CMD, "SetFwCmdIOTimerCallback(): driver is going to unload\n");
+ return;
+ }
+
+ RT_TRACE(COMP_CMD, "--->SetFwCmdIOTimerCallback(): Cmd(%#x), SetFwCmdInProgress(%d)\n", priv->CurrentFwCmdIO, priv->SetFwCmdInProgress);
+
+ switch(priv->CurrentFwCmdIO)
+ {
+ case FW_CMD_HIGH_PWR_ENABLE:
+ if((priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)==0)
+ write_nic_dword(dev, WFM5, FW_HIGH_PWR_ENABLE);
+ break;
+
+ case FW_CMD_HIGH_PWR_DISABLE:
+ write_nic_dword(dev, WFM5, FW_HIGH_PWR_DISABLE);
+ break;
+
+ case FW_CMD_DIG_RESUME:
+ write_nic_dword(dev, WFM5, FW_DIG_RESUME);
+ break;
+
+ case FW_CMD_DIG_HALT:
+ write_nic_dword(dev, WFM5, FW_DIG_HALT);
+ break;
+
+ //
+ // <Roger_Notes> The following FW CMD IO was combined into single operation
+ // (i.e., to prevent number of system workitem out of resource!!).
+ // 2008.12.04.
+ //
+ case FW_CMD_RESUME_DM_BY_SCAN:
+ RT_TRACE(COMP_CMD, "[FW CMD] Set HIGHPWR enable and DIG resume!!\n");
+ if((priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)==0)
+ {
+ write_nic_dword(dev, WFM5, FW_HIGH_PWR_ENABLE); //break;
+ ChkFwCmdIoDone(dev);
+ }
+ write_nic_dword(dev, WFM5, FW_DIG_RESUME);
+ break;
+
+ case FW_CMD_PAUSE_DM_BY_SCAN:
+ RT_TRACE(COMP_CMD, "[FW CMD] Set HIGHPWR disable and DIG halt!!\n");
+ write_nic_dword(dev, WFM5, FW_HIGH_PWR_DISABLE); //break;
+ ChkFwCmdIoDone(dev);
+ write_nic_dword(dev, WFM5, FW_DIG_HALT);
+ break;
+
+ //
+ // <Roger_Notes> The following FW CMD IO should be checked
+ // (i.e., workitem schedule timing issue!!).
+ // 2008.12.04.
+ //
+ case FW_CMD_DIG_DISABLE:
+ RT_TRACE(COMP_CMD, "[FW CMD] Set DIG disable!!\n");
+ write_nic_dword(dev, WFM5, FW_DIG_DISABLE);
+ break;
+
+ case FW_CMD_DIG_ENABLE:
+ RT_TRACE(COMP_CMD, "[FW CMD] Set DIG enable!!\n");
+ write_nic_dword(dev, WFM5, FW_DIG_ENABLE);
+ break;
+
+ case FW_CMD_RA_RESET:
+ write_nic_dword(dev, WFM5, FW_RA_RESET);
+ break;
+
+ case FW_CMD_RA_ACTIVE:
+ write_nic_dword(dev, WFM5, FW_RA_ACTIVE);
+ break;
+
+ case FW_CMD_RA_REFRESH_N:
+ RT_TRACE(COMP_CMD, "[FW CMD] Set RA refresh!! N\n");
+ if(priv->ieee80211->pHTInfo->IOTRaFunc & HT_IOT_RAFUNC_DISABLE_ALL)
+ input = FW_RA_REFRESH;
+ else
+ input = FW_RA_REFRESH | (priv->ieee80211->pHTInfo->IOTRaFunc << 8);
+ write_nic_dword(dev, WFM5, input);
+ break;
+ case FW_CMD_RA_REFRESH_BG:
+ RT_TRACE(COMP_CMD, "[FW CMD] Set RA refresh!! B/G\n");
+ write_nic_dword(dev, WFM5, FW_RA_REFRESH);
+ ChkFwCmdIoDone(dev);
+ write_nic_dword(dev, WFM5, FW_RA_ENABLE_BG);
+ break;
+
+ case FW_CMD_IQK_ENABLE:
+ write_nic_dword(dev, WFM5, FW_IQK_ENABLE);
+ break;
+
+ case FW_CMD_TXPWR_TRACK_ENABLE:
+ write_nic_dword(dev, WFM5, FW_TXPWR_TRACK_ENABLE);
+ break;
+
+ case FW_CMD_TXPWR_TRACK_DISABLE:
+ write_nic_dword(dev, WFM5, FW_TXPWR_TRACK_DISABLE);
+ break;
+
+ default:
+ RT_TRACE(COMP_CMD,"Unknown FW Cmd IO(%#x)\n", priv->CurrentFwCmdIO);
+ break;
+ }
+
+ ChkFwCmdIoDone(dev);
+
+ switch(priv->CurrentFwCmdIO)
+ {
+ case FW_CMD_HIGH_PWR_DISABLE:
+ //if(pMgntInfo->bTurboScan)
+ {
+ //Lower initial gain
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, 0x17);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, 0x17);
+ // CCA threshold
+ rtl8192_setBBreg(dev, rCCK0_CCA, bMaskByte2, 0x40);
+ // Disable OFDM Part
+ rtl8192_setBBreg(dev, rOFDM0_TRMuxPar, bMaskByte2, 0x1);
+ ScanRegister = rtl8192_QueryBBReg(dev, rOFDM0_RxDetector1,bMaskDWord);
+ rtl8192_setBBreg(dev, rOFDM0_RxDetector1, 0xf, 0xf);
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x0);
+ }
+ break;
+
+ case FW_CMD_HIGH_PWR_ENABLE:
+ //if(pMgntInfo->bTurboScan)
+ {
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, 0x36);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, 0x36);
+
+ // CCA threshold
+ rtl8192_setBBreg(dev, rCCK0_CCA, bMaskByte2, 0x83);
+ // Enable OFDM Part
+ rtl8192_setBBreg(dev, rOFDM0_TRMuxPar, bMaskByte2, 0x0);
+
+ //LZM ADD because sometimes there is no FW_CMD_HIGH_PWR_DISABLE, this value will be 0.
+ if(ScanRegister != 0){
+ rtl8192_setBBreg(dev, rOFDM0_RxDetector1, bMaskDWord, ScanRegister);
+ }
+
+ if(priv->rf_type == RF_1T2R || priv->rf_type == RF_2T2R)
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x3);
+ else
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x1);
+ }
+ break;
+ }
+
+ priv->SetFwCmdInProgress = false;// Clear FW CMD operation flag.
+ RT_TRACE(COMP_CMD, "<---SetFwCmdIOWorkItemCallback()\n");
+
+}
+
diff --git a/drivers/staging/rtl8192su/r8192S_phy.h b/drivers/staging/rtl8192su/r8192S_phy.h
new file mode 100644
index 000000000000..580a7c6a7609
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_phy.h
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * Copyright(c) 2008, RealTEK Technology Inc. All Right Reserved.
+ *
+ * Module: __INC_HAL8192SPHYCFG_H
+ *
+ *
+ * Note:
+ *
+ *
+ * Export: Constants, macro, functions(API), global variables(None).
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
+ * 2. Reorganize code architecture.
+ *
+ *****************************************************************************/
+ /* Check to see if the file has been included already. */
+#ifndef _R8192S_PHY_H
+#define _R8192S_PHY_H
+
+
+/*--------------------------Define Parameters-------------------------------*/
+#define LOOP_LIMIT 5
+#define MAX_STALL_TIME 50 //us
+#define AntennaDiversityValue 0x80 //(dev->bSoftwareAntennaDiversity ? 0x00:0x80)
+#define MAX_TXPWR_IDX_NMODE_92S 63
+
+//#define delay_ms(_t) PlatformStallExecution(1000*(_t))
+//#define delay_us(_t) PlatformStallExecution(_t)
+
+/* Channel switch:The size of command tables for switch channel*/
+#define MAX_PRECMD_CNT 16
+#define MAX_RFDEPENDCMD_CNT 16
+#define MAX_POSTCMD_CNT 16
+
+
+/*------------------------------Define structure----------------------------*/
+typedef enum _SwChnlCmdID{
+ CmdID_End,
+ CmdID_SetTxPowerLevel,
+ CmdID_BBRegWrite10,
+ CmdID_WritePortUlong,
+ CmdID_WritePortUshort,
+ CmdID_WritePortUchar,
+ CmdID_RF_WriteReg,
+}SwChnlCmdID;
+
+
+/* 1. Switch channel related */
+typedef struct _SwChnlCmd{
+ SwChnlCmdID CmdID;
+ u32 Para1;
+ u32 Para2;
+ u32 msDelay;
+}__attribute__ ((packed)) SwChnlCmd;
+
+extern u32 rtl819XMACPHY_Array_PG[];
+extern u32 rtl819XPHY_REG_1T2RArray[];
+extern u32 rtl819XAGCTAB_Array[];
+extern u32 rtl819XRadioA_Array[];
+extern u32 rtl819XRadioB_Array[];
+extern u32 rtl819XRadioC_Array[];
+extern u32 rtl819XRadioD_Array[];
+
+typedef enum _HW90_BLOCK{
+ HW90_BLOCK_MAC = 0,
+ HW90_BLOCK_PHY0 = 1,
+ HW90_BLOCK_PHY1 = 2,
+ HW90_BLOCK_RF = 3,
+ HW90_BLOCK_MAXIMUM = 4, // Never use this
+}HW90_BLOCK_E, *PHW90_BLOCK_E;
+
+typedef enum _RF90_RADIO_PATH{
+ RF90_PATH_A = 0, //Radio Path A
+ RF90_PATH_B = 1, //Radio Path B
+ RF90_PATH_C = 2, //Radio Path C
+ RF90_PATH_D = 3, //Radio Path D
+ RF90_PATH_MAX = 4, //Max RF number 90 support
+}RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E;
+
+#define bMaskByte0 0xff
+#define bMaskByte1 0xff00
+#define bMaskByte2 0xff0000
+#define bMaskByte3 0xff000000
+#define bMaskHWord 0xffff0000
+#define bMaskLWord 0x0000ffff
+#define bMaskDWord 0xffffffff
+
+typedef enum _VERSION_8190{
+ // RTL8190
+ VERSION_8190_BD=0x3,
+ VERSION_8190_BE
+}VERSION_8190,*PVERSION_8190;
+
+//
+// BB and RF register read/write
+//
+
+extern u32 rtl8192_QueryBBReg(struct net_device* dev,u32 RegAddr, u32 BitMask);
+extern void rtl8192_setBBreg(struct net_device* dev,u32 RegAddr, u32 BitMask,u32 Data);
+extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask);
+extern void rtl8192_phy_SetRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath, u32 RegAddr,u32 BitMask,u32 Data);
+
+bool rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath);
+
+
+/* MAC/BB/RF HAL config */
+extern bool PHY_MACConfig8192S(struct net_device* dev);
+extern bool PHY_BBConfig8192S(struct net_device* dev);
+extern bool PHY_RFConfig8192S(struct net_device* dev);
+
+extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev,RF90_RADIO_PATH_E eRFPath);
+extern void rtl8192_SetBWMode(struct net_device* dev,HT_CHANNEL_WIDTH ChnlWidth,HT_EXTCHNL_OFFSET Offset );
+extern u8 rtl8192_phy_SwChnl(struct net_device* dev,u8 channel);
+extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev,u32 eRFPath );
+extern void rtl8192_BBConfig(struct net_device* dev);
+extern void PHY_IQCalibrateBcut(struct net_device* dev);
+extern void PHY_IQCalibrate(struct net_device* dev);
+extern void PHY_GetHWRegOriginalValue(struct net_device* dev);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void InitialGainOperateWorkItemCallBack(struct work_struct *work);
+#else
+extern void InitialGainOperateWorkItemCallBack(struct net_device *dev);
+#endif
+void PHY_SetTxPowerLevel8192S(struct net_device* dev, u8 channel);
+void PHY_InitialGain8192S(struct net_device* dev,u8 Operation );
+
+/*--------------------------Exported Function prototype---------------------*/
+bool HalSetFwCmd8192S(struct net_device* dev, FW_CMD_IO_TYPE FwCmdIO);
+extern void PHY_SetBeaconHwReg( struct net_device* dev, u16 BeaconInterval);
+void ChkFwCmdIoDone(struct net_device* dev);
+
+#endif // __INC_HAL8192SPHYCFG_H
+
diff --git a/drivers/staging/rtl8192su/r8192S_phyreg.h b/drivers/staging/rtl8192su/r8192S_phyreg.h
new file mode 100644
index 000000000000..96c7cfa92542
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_phyreg.h
@@ -0,0 +1,1033 @@
+/*****************************************************************************
+ * Copyright(c) 2008, RealTEK Technology Inc. All Right Reserved.
+ *
+ * Module: __INC_HAL8192SPHYREG_H
+ *
+ *
+ * Note: 1. Define PMAC/BB register map
+ * 2. Define RF register map
+ * 3. PMAC/BB register bit mask.
+ * 4. RF reg bit mask.
+ * 5. Other BB/RF relative definition.
+ *
+ *
+ * Export: Constants, macro, functions(API), global variables(None).
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
+ * 2. Reorganize code architecture.
+ * 09/25/2008 MH 1. Add RL6052 register definition
+ *
+ *****************************************************************************/
+#ifndef __INC_HAL8192SPHYREG_H
+#define __INC_HAL8192SPHYREG_H
+
+
+/*--------------------------Define Parameters-------------------------------*/
+
+//============================================================
+// 8192S Regsiter offset definition
+//============================================================
+
+//
+// BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF
+// 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
+// 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00
+// 3. RF register 0x00-2E
+// 4. Bit Mask for BB/RF register
+// 5. Other defintion for BB/RF R/W
+//
+
+
+//
+// 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
+// 1. Page1(0x100)
+//
+#define rPMAC_Reset 0x100
+#define rPMAC_TxStart 0x104
+#define rPMAC_TxLegacySIG 0x108
+#define rPMAC_TxHTSIG1 0x10c
+#define rPMAC_TxHTSIG2 0x110
+#define rPMAC_PHYDebug 0x114
+#define rPMAC_TxPacketNum 0x118
+#define rPMAC_TxIdle 0x11c
+#define rPMAC_TxMACHeader0 0x120
+#define rPMAC_TxMACHeader1 0x124
+#define rPMAC_TxMACHeader2 0x128
+#define rPMAC_TxMACHeader3 0x12c
+#define rPMAC_TxMACHeader4 0x130
+#define rPMAC_TxMACHeader5 0x134
+#define rPMAC_TxDataType 0x138
+#define rPMAC_TxRandomSeed 0x13c
+#define rPMAC_CCKPLCPPreamble 0x140
+#define rPMAC_CCKPLCPHeader 0x144
+#define rPMAC_CCKCRC16 0x148
+#define rPMAC_OFDMRxCRC32OK 0x170
+#define rPMAC_OFDMRxCRC32Er 0x174
+#define rPMAC_OFDMRxParityEr 0x178
+#define rPMAC_OFDMRxCRC8Er 0x17c
+#define rPMAC_CCKCRxRC16Er 0x180
+#define rPMAC_CCKCRxRC32Er 0x184
+#define rPMAC_CCKCRxRC32OK 0x188
+#define rPMAC_TxStatus 0x18c
+
+//
+// 2. Page2(0x200)
+//
+// The following two definition are only used for USB interface.
+#define RF_BB_CMD_ADDR 0x02c0 // RF/BB read/write command address.
+#define RF_BB_CMD_DATA 0x02c4 // RF/BB read/write command data.
+
+//
+// 3. Page8(0x800)
+//
+#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC // RF BW Setting??
+
+#define rFPGA0_TxInfo 0x804 // Status report??
+#define rFPGA0_PSDFunction 0x808
+
+#define rFPGA0_TxGainStage 0x80c // Set TX PWR init gain?
+
+#define rFPGA0_RFTiming1 0x810 // Useless now
+#define rFPGA0_RFTiming2 0x814
+//#define rFPGA0_XC_RFTiming 0x818
+//#define rFPGA0_XD_RFTiming 0x81c
+
+#define rFPGA0_XA_HSSIParameter1 0x820 // RF 3 wire register
+#define rFPGA0_XA_HSSIParameter2 0x824
+#define rFPGA0_XB_HSSIParameter1 0x828
+#define rFPGA0_XB_HSSIParameter2 0x82c
+#define rFPGA0_XC_HSSIParameter1 0x830
+#define rFPGA0_XC_HSSIParameter2 0x834
+#define rFPGA0_XD_HSSIParameter1 0x838
+#define rFPGA0_XD_HSSIParameter2 0x83c
+#define rFPGA0_XA_LSSIParameter 0x840
+#define rFPGA0_XB_LSSIParameter 0x844
+#define rFPGA0_XC_LSSIParameter 0x848
+#define rFPGA0_XD_LSSIParameter 0x84c
+
+#define rFPGA0_RFWakeUpParameter 0x850 // Useless now
+#define rFPGA0_RFSleepUpParameter 0x854
+
+#define rFPGA0_XAB_SwitchControl 0x858 // RF Channel switch
+#define rFPGA0_XCD_SwitchControl 0x85c
+
+#define rFPGA0_XA_RFInterfaceOE 0x860 // RF Channel switch
+#define rFPGA0_XB_RFInterfaceOE 0x864
+#define rFPGA0_XC_RFInterfaceOE 0x868
+#define rFPGA0_XD_RFInterfaceOE 0x86c
+
+#define rFPGA0_XAB_RFInterfaceSW 0x870 // RF Interface Software Control
+#define rFPGA0_XCD_RFInterfaceSW 0x874
+
+#define rFPGA0_XAB_RFParameter 0x878 // RF Parameter
+#define rFPGA0_XCD_RFParameter 0x87c
+
+#define rFPGA0_AnalogParameter1 0x880 // Crystal cap setting RF-R/W protection for parameter4??
+#define rFPGA0_AnalogParameter2 0x884
+#define rFPGA0_AnalogParameter3 0x888 // Useless now
+#define rFPGA0_AnalogParameter4 0x88c
+
+#define rFPGA0_XA_LSSIReadBack 0x8a0 // Tranceiver LSSI Readback
+#define rFPGA0_XB_LSSIReadBack 0x8a4
+#define rFPGA0_XC_LSSIReadBack 0x8a8
+#define rFPGA0_XD_LSSIReadBack 0x8ac
+
+#define rFPGA0_PSDReport 0x8b4 // Useless now
+#define TransceiverA_HSPI_Readback 0x8b8 // Transceiver A HSPI Readback
+#define TransceiverB_HSPI_Readback 0x8bc // Transceiver B HSPI Readback
+#define rFPGA0_XAB_RFInterfaceRB 0x8e0 // Useless now // RF Interface Readback Value
+#define rFPGA0_XCD_RFInterfaceRB 0x8e4 // Useless now
+
+//
+// 4. Page9(0x900)
+//
+#define rFPGA1_RFMOD 0x900 //RF mode & OFDM TxSC // RF BW Setting??
+
+#define rFPGA1_TxBlock 0x904 // Useless now
+#define rFPGA1_DebugSelect 0x908 // Useless now
+#define rFPGA1_TxInfo 0x90c // Useless now // Status report??
+
+//
+// 5. PageA(0xA00)
+//
+// Set Control channel to upper or lower. These settings are required only for 40MHz
+#define rCCK0_System 0xa00
+
+#define rCCK0_AFESetting 0xa04 // Disable init gain now // Select RX path by RSSI
+#define rCCK0_CCA 0xa08 // Disable init gain now // Init gain
+
+#define rCCK0_RxAGC1 0xa0c //AGC default value, saturation level // Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now. Not the same as 90 series
+#define rCCK0_RxAGC2 0xa10 //AGC & DAGC
+
+#define rCCK0_RxHP 0xa14
+
+#define rCCK0_DSPParameter1 0xa18 //Timing recovery & Channel estimation threshold
+#define rCCK0_DSPParameter2 0xa1c //SQ threshold
+
+#define rCCK0_TxFilter1 0xa20
+#define rCCK0_TxFilter2 0xa24
+#define rCCK0_DebugPort 0xa28 //debug port and Tx filter3
+#define rCCK0_FalseAlarmReport 0xa2c //0xa2d useless now 0xa30-a4f channel report
+#define rCCK0_TRSSIReport 0xa50
+#define rCCK0_RxReport 0xa54 //0xa57
+#define rCCK0_FACounterLower 0xa5c //0xa5b
+#define rCCK0_FACounterUpper 0xa58 //0xa5c
+
+//
+// 6. PageC(0xC00)
+//
+#define rOFDM0_LSTF 0xc00
+
+#define rOFDM0_TRxPathEnable 0xc04
+#define rOFDM0_TRMuxPar 0xc08
+#define rOFDM0_TRSWIsolation 0xc0c
+
+#define rOFDM0_XARxAFE 0xc10 //RxIQ DC offset, Rx digital filter, DC notch filter
+#define rOFDM0_XARxIQImbalance 0xc14 //RxIQ imblance matrix
+#define rOFDM0_XBRxAFE 0xc18
+#define rOFDM0_XBRxIQImbalance 0xc1c
+#define rOFDM0_XCRxAFE 0xc20
+#define rOFDM0_XCRxIQImbalance 0xc24
+#define rOFDM0_XDRxAFE 0xc28
+#define rOFDM0_XDRxIQImbalance 0xc2c
+
+#define rOFDM0_RxDetector1 0xc30 //PD,BW & SBD // DM tune init gain
+#define rOFDM0_RxDetector2 0xc34 //SBD & Fame Sync.
+#define rOFDM0_RxDetector3 0xc38 //Frame Sync.
+#define rOFDM0_RxDetector4 0xc3c //PD, SBD, Frame Sync & Short-GI
+
+#define rOFDM0_RxDSP 0xc40 //Rx Sync Path
+#define rOFDM0_CFOandDAGC 0xc44 //CFO & DAGC
+#define rOFDM0_CCADropThreshold 0xc48 //CCA Drop threshold
+#define rOFDM0_ECCAThreshold 0xc4c // energy CCA
+
+#define rOFDM0_XAAGCCore1 0xc50 // DIG
+#define rOFDM0_XAAGCCore2 0xc54
+#define rOFDM0_XBAGCCore1 0xc58
+#define rOFDM0_XBAGCCore2 0xc5c
+#define rOFDM0_XCAGCCore1 0xc60
+#define rOFDM0_XCAGCCore2 0xc64
+#define rOFDM0_XDAGCCore1 0xc68
+#define rOFDM0_XDAGCCore2 0xc6c
+
+#define rOFDM0_AGCParameter1 0xc70
+#define rOFDM0_AGCParameter2 0xc74
+#define rOFDM0_AGCRSSITable 0xc78
+#define rOFDM0_HTSTFAGC 0xc7c
+
+#define rOFDM0_XATxIQImbalance 0xc80 // TX PWR TRACK and DIG
+#define rOFDM0_XATxAFE 0xc84
+#define rOFDM0_XBTxIQImbalance 0xc88
+#define rOFDM0_XBTxAFE 0xc8c
+#define rOFDM0_XCTxIQImbalance 0xc90
+#define rOFDM0_XCTxAFE 0xc94
+#define rOFDM0_XDTxIQImbalance 0xc98
+#define rOFDM0_XDTxAFE 0xc9c
+
+#define rOFDM0_RxHPParameter 0xce0
+#define rOFDM0_TxPseudoNoiseWgt 0xce4
+#define rOFDM0_FrameSync 0xcf0
+#define rOFDM0_DFSReport 0xcf4
+#define rOFDM0_TxCoeff1 0xca4
+#define rOFDM0_TxCoeff2 0xca8
+#define rOFDM0_TxCoeff3 0xcac
+#define rOFDM0_TxCoeff4 0xcb0
+#define rOFDM0_TxCoeff5 0xcb4
+#define rOFDM0_TxCoeff6 0xcb8
+
+
+//
+// 7. PageD(0xD00)
+//
+#define rOFDM1_LSTF 0xd00
+#define rOFDM1_TRxPathEnable 0xd04
+#define rOFDM1_CFO 0xd08 // No setting now
+#define rOFDM1_CSI1 0xd10
+#define rOFDM1_SBD 0xd14
+#define rOFDM1_CSI2 0xd18
+#define rOFDM1_CFOTracking 0xd2c
+#define rOFDM1_TRxMesaure1 0xd34
+#define rOFDM1_IntfDet 0xd3c
+#define rOFDM1_PseudoNoiseStateAB 0xd50
+#define rOFDM1_PseudoNoiseStateCD 0xd54
+#define rOFDM1_RxPseudoNoiseWgt 0xd58
+
+#define rOFDM_PHYCounter1 0xda0 //cca, parity fail
+#define rOFDM_PHYCounter2 0xda4 //rate illegal, crc8 fail
+#define rOFDM_PHYCounter3 0xda8 //MCS not support
+#define rOFDM_ShortCFOAB 0xdac // No setting now
+#define rOFDM_ShortCFOCD 0xdb0
+#define rOFDM_LongCFOAB 0xdb4
+#define rOFDM_LongCFOCD 0xdb8
+#define rOFDM_TailCFOAB 0xdbc
+#define rOFDM_TailCFOCD 0xdc0
+#define rOFDM_PWMeasure1 0xdc4
+#define rOFDM_PWMeasure2 0xdc8
+#define rOFDM_BWReport 0xdcc
+#define rOFDM_AGCReport 0xdd0
+#define rOFDM_RxSNR 0xdd4
+#define rOFDM_RxEVMCSI 0xdd8
+#define rOFDM_SIGReport 0xddc
+
+
+//
+// 8. PageE(0xE00)
+//
+#define rTxAGC_Rate18_06 0xe00
+#define rTxAGC_Rate54_24 0xe04
+#define rTxAGC_CCK_Mcs32 0xe08
+#define rTxAGC_Mcs03_Mcs00 0xe10
+#define rTxAGC_Mcs07_Mcs04 0xe14
+#define rTxAGC_Mcs11_Mcs08 0xe18
+#define rTxAGC_Mcs15_Mcs12 0xe1c
+
+//
+// 7. RF Register 0x00-0x2E (RF 8256)
+// RF-0222D 0x00-3F
+//
+//Zebra1
+#define rZebra1_HSSIEnable 0x0 // Useless now
+#define rZebra1_TRxEnable1 0x1
+#define rZebra1_TRxEnable2 0x2
+#define rZebra1_AGC 0x4
+#define rZebra1_ChargePump 0x5
+//#if (RTL92SE_FPGA_VERIFY == 1)
+#define rZebra1_Channel 0x7 // RF channel switch
+//#else
+
+//#endif
+#define rZebra1_TxGain 0x8 // Useless now
+#define rZebra1_TxLPF 0x9
+#define rZebra1_RxLPF 0xb
+#define rZebra1_RxHPFCorner 0xc
+
+//Zebra4
+#define rGlobalCtrl 0 // Useless now
+#define rRTL8256_TxLPF 19
+#define rRTL8256_RxLPF 11
+
+//RTL8258
+#define rRTL8258_TxLPF 0x11 // Useless now
+#define rRTL8258_RxLPF 0x13
+#define rRTL8258_RSSILPF 0xa
+
+//
+// RL6052 Register definition
+//
+#define RF_AC 0x00 //
+
+#define RF_IQADJ_G1 0x01 //
+#define RF_IQADJ_G2 0x02 //
+#define RF_POW_TRSW 0x05 //
+
+#define RF_GAIN_RX 0x06 //
+#define RF_GAIN_TX 0x07 //
+
+#define RF_TXM_IDAC 0x08 //
+#define RF_BS_IQGEN 0x0F //
+
+#define RF_MODE1 0x10 //
+#define RF_MODE2 0x11 //
+
+#define RF_RX_AGC_HP 0x12 //
+#define RF_TX_AGC 0x13 //
+#define RF_BIAS 0x14 //
+#define RF_IPA 0x15 //
+#define RF_POW_ABILITY 0x17 //
+#define RF_MODE_AG 0x18 //
+#define rRfChannel 0x18 // RF channel and BW switch
+#define RF_CHNLBW 0x18 // RF channel and BW switch
+#define RF_TOP 0x19 //
+
+#define RF_RX_G1 0x1A //
+#define RF_RX_G2 0x1B //
+
+#define RF_RX_BB2 0x1C //
+#define RF_RX_BB1 0x1D //
+
+#define RF_RCK1 0x1E //
+#define RF_RCK2 0x1F //
+
+#define RF_TX_G1 0x20 //
+#define RF_TX_G2 0x21 //
+#define RF_TX_G3 0x22 //
+
+#define RF_TX_BB1 0x23 //
+
+#define RF_T_METER 0x24 //
+
+#define RF_SYN_G1 0x25 // RF TX Power control
+#define RF_SYN_G2 0x26 // RF TX Power control
+#define RF_SYN_G3 0x27 // RF TX Power control
+#define RF_SYN_G4 0x28 // RF TX Power control
+#define RF_SYN_G5 0x29 // RF TX Power control
+#define RF_SYN_G6 0x2A // RF TX Power control
+#define RF_SYN_G7 0x2B // RF TX Power control
+#define RF_SYN_G8 0x2C // RF TX Power control
+
+#define RF_RCK_OS 0x30 // RF TX PA control
+
+#define RF_TXPA_G1 0x31 // RF TX PA control
+#define RF_TXPA_G2 0x32 // RF TX PA control
+#define RF_TXPA_G3 0x33 // RF TX PA control
+
+//
+//Bit Mask
+//
+// 1. Page1(0x100)
+#define bBBResetB 0x100 // Useless now?
+#define bGlobalResetB 0x200
+#define bOFDMTxStart 0x4
+#define bCCKTxStart 0x8
+#define bCRC32Debug 0x100
+#define bPMACLoopback 0x10
+#define bTxLSIG 0xffffff
+#define bOFDMTxRate 0xf
+#define bOFDMTxReserved 0x10
+#define bOFDMTxLength 0x1ffe0
+#define bOFDMTxParity 0x20000
+#define bTxHTSIG1 0xffffff
+#define bTxHTMCSRate 0x7f
+#define bTxHTBW 0x80
+#define bTxHTLength 0xffff00
+#define bTxHTSIG2 0xffffff
+#define bTxHTSmoothing 0x1
+#define bTxHTSounding 0x2
+#define bTxHTReserved 0x4
+#define bTxHTAggreation 0x8
+#define bTxHTSTBC 0x30
+#define bTxHTAdvanceCoding 0x40
+#define bTxHTShortGI 0x80
+#define bTxHTNumberHT_LTF 0x300
+#define bTxHTCRC8 0x3fc00
+#define bCounterReset 0x10000
+#define bNumOfOFDMTx 0xffff
+#define bNumOfCCKTx 0xffff0000
+#define bTxIdleInterval 0xffff
+#define bOFDMService 0xffff0000
+#define bTxMACHeader 0xffffffff
+#define bTxDataInit 0xff
+#define bTxHTMode 0x100
+#define bTxDataType 0x30000
+#define bTxRandomSeed 0xffffffff
+#define bCCKTxPreamble 0x1
+#define bCCKTxSFD 0xffff0000
+#define bCCKTxSIG 0xff
+#define bCCKTxService 0xff00
+#define bCCKLengthExt 0x8000
+#define bCCKTxLength 0xffff0000
+#define bCCKTxCRC16 0xffff
+#define bCCKTxStatus 0x1
+#define bOFDMTxStatus 0x2
+
+#define IS_BB_REG_OFFSET_92S(_Offset) ((_Offset >= 0x800) && (_Offset <= 0xfff))
+
+// 2. Page8(0x800)
+#define bRFMOD 0x1 // Reg 0x800 rFPGA0_RFMOD
+#define bJapanMode 0x2
+#define bCCKTxSC 0x30
+#define bCCKEn 0x1000000
+#define bOFDMEn 0x2000000
+
+#define bOFDMRxADCPhase 0x10000 // Useless now
+#define bOFDMTxDACPhase 0x40000
+#define bXATxAGC 0x3f
+
+#define bXBTxAGC 0xf00 // Reg 80c rFPGA0_TxGainStage
+#define bXCTxAGC 0xf000
+#define bXDTxAGC 0xf0000
+
+#define bPAStart 0xf0000000 // Useless now
+#define bTRStart 0x00f00000
+#define bRFStart 0x0000f000
+#define bBBStart 0x000000f0
+#define bBBCCKStart 0x0000000f
+#define bPAEnd 0xf //Reg0x814
+#define bTREnd 0x0f000000
+#define bRFEnd 0x000f0000
+#define bCCAMask 0x000000f0 //T2R
+#define bR2RCCAMask 0x00000f00
+#define bHSSI_R2TDelay 0xf8000000
+#define bHSSI_T2RDelay 0xf80000
+#define bContTxHSSI 0x400 //chane gain at continue Tx
+#define bIGFromCCK 0x200
+#define bAGCAddress 0x3f
+#define bRxHPTx 0x7000
+#define bRxHPT2R 0x38000
+#define bRxHPCCKIni 0xc0000
+#define bAGCTxCode 0xc00000
+#define bAGCRxCode 0x300000
+
+#define b3WireDataLength 0x800 // Reg 0x820~84f rFPGA0_XA_HSSIParameter1
+#define b3WireAddressLength 0x400
+
+#define b3WireRFPowerDown 0x1 // Useless now
+//#define bHWSISelect 0x8
+#define b5GPAPEPolarity 0x40000000
+#define b2GPAPEPolarity 0x80000000
+#define bRFSW_TxDefaultAnt 0x3
+#define bRFSW_TxOptionAnt 0x30
+#define bRFSW_RxDefaultAnt 0x300
+#define bRFSW_RxOptionAnt 0x3000
+#define bRFSI_3WireData 0x1
+#define bRFSI_3WireClock 0x2
+#define bRFSI_3WireLoad 0x4
+#define bRFSI_3WireRW 0x8
+#define bRFSI_3Wire 0xf
+
+#define bRFSI_RFENV 0x10 // Reg 0x870 rFPGA0_XAB_RFInterfaceSW
+
+#define bRFSI_TRSW 0x20 // Useless now
+#define bRFSI_TRSWB 0x40
+#define bRFSI_ANTSW 0x100
+#define bRFSI_ANTSWB 0x200
+#define bRFSI_PAPE 0x400
+#define bRFSI_PAPE5G 0x800
+#define bBandSelect 0x1
+#define bHTSIG2_GI 0x80
+#define bHTSIG2_Smoothing 0x01
+#define bHTSIG2_Sounding 0x02
+#define bHTSIG2_Aggreaton 0x08
+#define bHTSIG2_STBC 0x30
+#define bHTSIG2_AdvCoding 0x40
+#define bHTSIG2_NumOfHTLTF 0x300
+#define bHTSIG2_CRC8 0x3fc
+#define bHTSIG1_MCS 0x7f
+#define bHTSIG1_BandWidth 0x80
+#define bHTSIG1_HTLength 0xffff
+#define bLSIG_Rate 0xf
+#define bLSIG_Reserved 0x10
+#define bLSIG_Length 0x1fffe
+#define bLSIG_Parity 0x20
+#define bCCKRxPhase 0x4
+#define bLSSIReadAddress 0x7f800000 // T65 RF
+#define bLSSIReadEdge 0x80000000 //LSSI "Read" edge signal
+#define bLSSIReadBackData 0xfffff // T65 RF
+#define bLSSIReadOKFlag 0x1000 // Useless now
+#define bCCKSampleRate 0x8 //0: 44MHz, 1:88MHz
+#define bRegulator0Standby 0x1
+#define bRegulatorPLLStandby 0x2
+#define bRegulator1Standby 0x4
+#define bPLLPowerUp 0x8
+#define bDPLLPowerUp 0x10
+#define bDA10PowerUp 0x20
+#define bAD7PowerUp 0x200
+#define bDA6PowerUp 0x2000
+#define bXtalPowerUp 0x4000
+#define b40MDClkPowerUP 0x8000
+#define bDA6DebugMode 0x20000
+#define bDA6Swing 0x380000
+
+#define bADClkPhase 0x4000000 // Reg 0x880 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ
+
+#define b80MClkDelay 0x18000000 // Useless
+#define bAFEWatchDogEnable 0x20000000
+
+#define bXtalCap01 0xc0000000 // Reg 0x884 rFPGA0_AnalogParameter2 Crystal cap
+#define bXtalCap23 0x3
+#define bXtalCap92x 0x0f000000
+#define bXtalCap 0x0f000000
+
+#define bIntDifClkEnable 0x400 // Useless
+#define bExtSigClkEnable 0x800
+#define bBandgapMbiasPowerUp 0x10000
+#define bAD11SHGain 0xc0000
+#define bAD11InputRange 0x700000
+#define bAD11OPCurrent 0x3800000
+#define bIPathLoopback 0x4000000
+#define bQPathLoopback 0x8000000
+#define bAFELoopback 0x10000000
+#define bDA10Swing 0x7e0
+#define bDA10Reverse 0x800
+#define bDAClkSource 0x1000
+#define bAD7InputRange 0x6000
+#define bAD7Gain 0x38000
+#define bAD7OutputCMMode 0x40000
+#define bAD7InputCMMode 0x380000
+#define bAD7Current 0xc00000
+#define bRegulatorAdjust 0x7000000
+#define bAD11PowerUpAtTx 0x1
+#define bDA10PSAtTx 0x10
+#define bAD11PowerUpAtRx 0x100
+#define bDA10PSAtRx 0x1000
+#define bCCKRxAGCFormat 0x200
+#define bPSDFFTSamplepPoint 0xc000
+#define bPSDAverageNum 0x3000
+#define bIQPathControl 0xc00
+#define bPSDFreq 0x3ff
+#define bPSDAntennaPath 0x30
+#define bPSDIQSwitch 0x40
+#define bPSDRxTrigger 0x400000
+#define bPSDTxTrigger 0x80000000
+#define bPSDSineToneScale 0x7f000000
+#define bPSDReport 0xffff
+
+// 3. Page9(0x900)
+#define bOFDMTxSC 0x30000000 // Useless
+#define bCCKTxOn 0x1
+#define bOFDMTxOn 0x2
+#define bDebugPage 0xfff //reset debug page and also HWord, LWord
+#define bDebugItem 0xff //reset debug page and LWord
+#define bAntL 0x10
+#define bAntNonHT 0x100
+#define bAntHT1 0x1000
+#define bAntHT2 0x10000
+#define bAntHT1S1 0x100000
+#define bAntNonHTS1 0x1000000
+
+// 4. PageA(0xA00)
+#define bCCKBBMode 0x3 // Useless
+#define bCCKTxPowerSaving 0x80
+#define bCCKRxPowerSaving 0x40
+
+#define bCCKSideBand 0x10 // Reg 0xa00 rCCK0_System 20/40 switch
+
+#define bCCKScramble 0x8 // Useless
+#define bCCKAntDiversity 0x8000
+#define bCCKCarrierRecovery 0x4000
+#define bCCKTxRate 0x3000
+#define bCCKDCCancel 0x0800
+#define bCCKISICancel 0x0400
+#define bCCKMatchFilter 0x0200
+#define bCCKEqualizer 0x0100
+#define bCCKPreambleDetect 0x800000
+#define bCCKFastFalseCCA 0x400000
+#define bCCKChEstStart 0x300000
+#define bCCKCCACount 0x080000
+#define bCCKcs_lim 0x070000
+#define bCCKBistMode 0x80000000
+#define bCCKCCAMask 0x40000000
+#define bCCKTxDACPhase 0x4
+#define bCCKRxADCPhase 0x20000000 //r_rx_clk
+#define bCCKr_cp_mode0 0x0100
+#define bCCKTxDCOffset 0xf0
+#define bCCKRxDCOffset 0xf
+#define bCCKCCAMode 0xc000
+#define bCCKFalseCS_lim 0x3f00
+#define bCCKCS_ratio 0xc00000
+#define bCCKCorgBit_sel 0x300000
+#define bCCKPD_lim 0x0f0000
+#define bCCKNewCCA 0x80000000
+#define bCCKRxHPofIG 0x8000
+#define bCCKRxIG 0x7f00
+#define bCCKLNAPolarity 0x800000
+#define bCCKRx1stGain 0x7f0000
+#define bCCKRFExtend 0x20000000 //CCK Rx Iinital gain polarity
+#define bCCKRxAGCSatLevel 0x1f000000
+#define bCCKRxAGCSatCount 0xe0
+#define bCCKRxRFSettle 0x1f //AGCsamp_dly
+#define bCCKFixedRxAGC 0x8000
+//#define bCCKRxAGCFormat 0x4000 //remove to HSSI register 0x824
+#define bCCKAntennaPolarity 0x2000
+#define bCCKTxFilterType 0x0c00
+#define bCCKRxAGCReportType 0x0300
+#define bCCKRxDAGCEn 0x80000000
+#define bCCKRxDAGCPeriod 0x20000000
+#define bCCKRxDAGCSatLevel 0x1f000000
+#define bCCKTimingRecovery 0x800000
+#define bCCKTxC0 0x3f0000
+#define bCCKTxC1 0x3f000000
+#define bCCKTxC2 0x3f
+#define bCCKTxC3 0x3f00
+#define bCCKTxC4 0x3f0000
+#define bCCKTxC5 0x3f000000
+#define bCCKTxC6 0x3f
+#define bCCKTxC7 0x3f00
+#define bCCKDebugPort 0xff0000
+#define bCCKDACDebug 0x0f000000
+#define bCCKFalseAlarmEnable 0x8000
+#define bCCKFalseAlarmRead 0x4000
+#define bCCKTRSSI 0x7f
+#define bCCKRxAGCReport 0xfe
+#define bCCKRxReport_AntSel 0x80000000
+#define bCCKRxReport_MFOff 0x40000000
+#define bCCKRxRxReport_SQLoss 0x20000000
+#define bCCKRxReport_Pktloss 0x10000000
+#define bCCKRxReport_Lockedbit 0x08000000
+#define bCCKRxReport_RateError 0x04000000
+#define bCCKRxReport_RxRate 0x03000000
+#define bCCKRxFACounterLower 0xff
+#define bCCKRxFACounterUpper 0xff000000
+#define bCCKRxHPAGCStart 0xe000
+#define bCCKRxHPAGCFinal 0x1c00
+#define bCCKRxFalseAlarmEnable 0x8000
+#define bCCKFACounterFreeze 0x4000
+#define bCCKTxPathSel 0x10000000
+#define bCCKDefaultRxPath 0xc000000
+#define bCCKOptionRxPath 0x3000000
+
+// 5. PageC(0xC00)
+#define bNumOfSTF 0x3 // Useless
+#define bShift_L 0xc0
+#define bGI_TH 0xc
+#define bRxPathA 0x1
+#define bRxPathB 0x2
+#define bRxPathC 0x4
+#define bRxPathD 0x8
+#define bTxPathA 0x1
+#define bTxPathB 0x2
+#define bTxPathC 0x4
+#define bTxPathD 0x8
+#define bTRSSIFreq 0x200
+#define bADCBackoff 0x3000
+#define bDFIRBackoff 0xc000
+#define bTRSSILatchPhase 0x10000
+#define bRxIDCOffset 0xff
+#define bRxQDCOffset 0xff00
+#define bRxDFIRMode 0x1800000
+#define bRxDCNFType 0xe000000
+#define bRXIQImb_A 0x3ff
+#define bRXIQImb_B 0xfc00
+#define bRXIQImb_C 0x3f0000
+#define bRXIQImb_D 0xffc00000
+#define bDC_dc_Notch 0x60000
+#define bRxNBINotch 0x1f000000
+#define bPD_TH 0xf
+#define bPD_TH_Opt2 0xc000
+#define bPWED_TH 0x700
+#define bIfMF_Win_L 0x800
+#define bPD_Option 0x1000
+#define bMF_Win_L 0xe000
+#define bBW_Search_L 0x30000
+#define bwin_enh_L 0xc0000
+#define bBW_TH 0x700000
+#define bED_TH2 0x3800000
+#define bBW_option 0x4000000
+#define bRatio_TH 0x18000000
+#define bWindow_L 0xe0000000
+#define bSBD_Option 0x1
+#define bFrame_TH 0x1c
+#define bFS_Option 0x60
+#define bDC_Slope_check 0x80
+#define bFGuard_Counter_DC_L 0xe00
+#define bFrame_Weight_Short 0x7000
+#define bSub_Tune 0xe00000
+#define bFrame_DC_Length 0xe000000
+#define bSBD_start_offset 0x30000000
+#define bFrame_TH_2 0x7
+#define bFrame_GI2_TH 0x38
+#define bGI2_Sync_en 0x40
+#define bSarch_Short_Early 0x300
+#define bSarch_Short_Late 0xc00
+#define bSarch_GI2_Late 0x70000
+#define bCFOAntSum 0x1
+#define bCFOAcc 0x2
+#define bCFOStartOffset 0xc
+#define bCFOLookBack 0x70
+#define bCFOSumWeight 0x80
+#define bDAGCEnable 0x10000
+#define bTXIQImb_A 0x3ff
+#define bTXIQImb_B 0xfc00
+#define bTXIQImb_C 0x3f0000
+#define bTXIQImb_D 0xffc00000
+#define bTxIDCOffset 0xff
+#define bTxQDCOffset 0xff00
+#define bTxDFIRMode 0x10000
+#define bTxPesudoNoiseOn 0x4000000
+#define bTxPesudoNoise_A 0xff
+#define bTxPesudoNoise_B 0xff00
+#define bTxPesudoNoise_C 0xff0000
+#define bTxPesudoNoise_D 0xff000000
+#define bCCADropOption 0x20000
+#define bCCADropThres 0xfff00000
+#define bEDCCA_H 0xf
+#define bEDCCA_L 0xf0
+#define bLambda_ED 0x300
+#define bRxInitialGain 0x7f
+#define bRxAntDivEn 0x80
+#define bRxAGCAddressForLNA 0x7f00
+#define bRxHighPowerFlow 0x8000
+#define bRxAGCFreezeThres 0xc0000
+#define bRxFreezeStep_AGC1 0x300000
+#define bRxFreezeStep_AGC2 0xc00000
+#define bRxFreezeStep_AGC3 0x3000000
+#define bRxFreezeStep_AGC0 0xc000000
+#define bRxRssi_Cmp_En 0x10000000
+#define bRxQuickAGCEn 0x20000000
+#define bRxAGCFreezeThresMode 0x40000000
+#define bRxOverFlowCheckType 0x80000000
+#define bRxAGCShift 0x7f
+#define bTRSW_Tri_Only 0x80
+#define bPowerThres 0x300
+#define bRxAGCEn 0x1
+#define bRxAGCTogetherEn 0x2
+#define bRxAGCMin 0x4
+#define bRxHP_Ini 0x7
+#define bRxHP_TRLNA 0x70
+#define bRxHP_RSSI 0x700
+#define bRxHP_BBP1 0x7000
+#define bRxHP_BBP2 0x70000
+#define bRxHP_BBP3 0x700000
+#define bRSSI_H 0x7f0000 //the threshold for high power
+#define bRSSI_Gen 0x7f000000 //the threshold for ant diversity
+#define bRxSettle_TRSW 0x7
+#define bRxSettle_LNA 0x38
+#define bRxSettle_RSSI 0x1c0
+#define bRxSettle_BBP 0xe00
+#define bRxSettle_RxHP 0x7000
+#define bRxSettle_AntSW_RSSI 0x38000
+#define bRxSettle_AntSW 0xc0000
+#define bRxProcessTime_DAGC 0x300000
+#define bRxSettle_HSSI 0x400000
+#define bRxProcessTime_BBPPW 0x800000
+#define bRxAntennaPowerShift 0x3000000
+#define bRSSITableSelect 0xc000000
+#define bRxHP_Final 0x7000000
+#define bRxHTSettle_BBP 0x7
+#define bRxHTSettle_HSSI 0x8
+#define bRxHTSettle_RxHP 0x70
+#define bRxHTSettle_BBPPW 0x80
+#define bRxHTSettle_Idle 0x300
+#define bRxHTSettle_Reserved 0x1c00
+#define bRxHTRxHPEn 0x8000
+#define bRxHTAGCFreezeThres 0x30000
+#define bRxHTAGCTogetherEn 0x40000
+#define bRxHTAGCMin 0x80000
+#define bRxHTAGCEn 0x100000
+#define bRxHTDAGCEn 0x200000
+#define bRxHTRxHP_BBP 0x1c00000
+#define bRxHTRxHP_Final 0xe0000000
+#define bRxPWRatioTH 0x3
+#define bRxPWRatioEn 0x4
+#define bRxMFHold 0x3800
+#define bRxPD_Delay_TH1 0x38
+#define bRxPD_Delay_TH2 0x1c0
+#define bRxPD_DC_COUNT_MAX 0x600
+//#define bRxMF_Hold 0x3800
+#define bRxPD_Delay_TH 0x8000
+#define bRxProcess_Delay 0xf0000
+#define bRxSearchrange_GI2_Early 0x700000
+#define bRxFrame_Guard_Counter_L 0x3800000
+#define bRxSGI_Guard_L 0xc000000
+#define bRxSGI_Search_L 0x30000000
+#define bRxSGI_TH 0xc0000000
+#define bDFSCnt0 0xff
+#define bDFSCnt1 0xff00
+#define bDFSFlag 0xf0000
+#define bMFWeightSum 0x300000
+#define bMinIdxTH 0x7f000000
+#define bDAFormat 0x40000
+#define bTxChEmuEnable 0x01000000
+#define bTRSWIsolation_A 0x7f
+#define bTRSWIsolation_B 0x7f00
+#define bTRSWIsolation_C 0x7f0000
+#define bTRSWIsolation_D 0x7f000000
+#define bExtLNAGain 0x7c00
+
+// 6. PageE(0xE00)
+#define bSTBCEn 0x4 // Useless
+#define bAntennaMapping 0x10
+#define bNss 0x20
+#define bCFOAntSumD 0x200
+#define bPHYCounterReset 0x8000000
+#define bCFOReportGet 0x4000000
+#define bOFDMContinueTx 0x10000000
+#define bOFDMSingleCarrier 0x20000000
+#define bOFDMSingleTone 0x40000000
+//#define bRxPath1 0x01
+//#define bRxPath2 0x02
+//#define bRxPath3 0x04
+//#define bRxPath4 0x08
+//#define bTxPath1 0x10
+//#define bTxPath2 0x20
+#define bHTDetect 0x100
+#define bCFOEn 0x10000
+#define bCFOValue 0xfff00000
+#define bSigTone_Re 0x3f
+#define bSigTone_Im 0x7f00
+#define bCounter_CCA 0xffff
+#define bCounter_ParityFail 0xffff0000
+#define bCounter_RateIllegal 0xffff
+#define bCounter_CRC8Fail 0xffff0000
+#define bCounter_MCSNoSupport 0xffff
+#define bCounter_FastSync 0xffff
+#define bShortCFO 0xfff
+#define bShortCFOTLength 12 //total
+#define bShortCFOFLength 11 //fraction
+#define bLongCFO 0x7ff
+#define bLongCFOTLength 11
+#define bLongCFOFLength 11
+#define bTailCFO 0x1fff
+#define bTailCFOTLength 13
+#define bTailCFOFLength 12
+#define bmax_en_pwdB 0xffff
+#define bCC_power_dB 0xffff0000
+#define bnoise_pwdB 0xffff
+#define bPowerMeasTLength 10
+#define bPowerMeasFLength 3
+#define bRx_HT_BW 0x1
+#define bRxSC 0x6
+#define bRx_HT 0x8
+#define bNB_intf_det_on 0x1
+#define bIntf_win_len_cfg 0x30
+#define bNB_Intf_TH_cfg 0x1c0
+#define bRFGain 0x3f
+#define bTableSel 0x40
+#define bTRSW 0x80
+#define bRxSNR_A 0xff
+#define bRxSNR_B 0xff00
+#define bRxSNR_C 0xff0000
+#define bRxSNR_D 0xff000000
+#define bSNREVMTLength 8
+#define bSNREVMFLength 1
+#define bCSI1st 0xff
+#define bCSI2nd 0xff00
+#define bRxEVM1st 0xff0000
+#define bRxEVM2nd 0xff000000
+#define bSIGEVM 0xff
+#define bPWDB 0xff00
+#define bSGIEN 0x10000
+
+#define bSFactorQAM1 0xf // Useless
+#define bSFactorQAM2 0xf0
+#define bSFactorQAM3 0xf00
+#define bSFactorQAM4 0xf000
+#define bSFactorQAM5 0xf0000
+#define bSFactorQAM6 0xf0000
+#define bSFactorQAM7 0xf00000
+#define bSFactorQAM8 0xf000000
+#define bSFactorQAM9 0xf0000000
+#define bCSIScheme 0x100000
+
+#define bNoiseLvlTopSet 0x3 // Useless
+#define bChSmooth 0x4
+#define bChSmoothCfg1 0x38
+#define bChSmoothCfg2 0x1c0
+#define bChSmoothCfg3 0xe00
+#define bChSmoothCfg4 0x7000
+#define bMRCMode 0x800000
+#define bTHEVMCfg 0x7000000
+
+#define bLoopFitType 0x1 // Useless
+#define bUpdCFO 0x40
+#define bUpdCFOOffData 0x80
+#define bAdvUpdCFO 0x100
+#define bAdvTimeCtrl 0x800
+#define bUpdClko 0x1000
+#define bFC 0x6000
+#define bTrackingMode 0x8000
+#define bPhCmpEnable 0x10000
+#define bUpdClkoLTF 0x20000
+#define bComChCFO 0x40000
+#define bCSIEstiMode 0x80000
+#define bAdvUpdEqz 0x100000
+#define bUChCfg 0x7000000
+#define bUpdEqz 0x8000000
+
+#define bTxAGCRate18_06 0x7f7f7f7f // Useless
+#define bTxAGCRate54_24 0x7f7f7f7f
+#define bTxAGCRateMCS32 0x7f
+#define bTxAGCRateCCK 0x7f00
+#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f
+#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f
+#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f
+#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f
+
+//Rx Pseduo noise
+#define bRxPesudoNoiseOn 0x20000000 // Useless
+#define bRxPesudoNoise_A 0xff
+#define bRxPesudoNoise_B 0xff00
+#define bRxPesudoNoise_C 0xff0000
+#define bRxPesudoNoise_D 0xff000000
+#define bPesudoNoiseState_A 0xffff
+#define bPesudoNoiseState_B 0xffff0000
+#define bPesudoNoiseState_C 0xffff
+#define bPesudoNoiseState_D 0xffff0000
+
+//7. RF Register
+//Zebra1
+#define bZebra1_HSSIEnable 0x8 // Useless
+#define bZebra1_TRxControl 0xc00
+#define bZebra1_TRxGainSetting 0x07f
+#define bZebra1_RxCorner 0xc00
+#define bZebra1_TxChargePump 0x38
+#define bZebra1_RxChargePump 0x7
+#define bZebra1_ChannelNum 0xf80
+#define bZebra1_TxLPFBW 0x400
+#define bZebra1_RxLPFBW 0x600
+
+//Zebra4
+#define bRTL8256RegModeCtrl1 0x100 // Useless
+#define bRTL8256RegModeCtrl0 0x40
+#define bRTL8256_TxLPFBW 0x18
+#define bRTL8256_RxLPFBW 0x600
+
+//RTL8258
+#define bRTL8258_TxLPFBW 0xc // Useless
+#define bRTL8258_RxLPFBW 0xc00
+#define bRTL8258_RSSILPFBW 0xc0
+
+
+//
+// Other Definition
+//
+
+//byte endable for sb_write
+#define bByte0 0x1 // Useless
+#define bByte1 0x2
+#define bByte2 0x4
+#define bByte3 0x8
+#define bWord0 0x3
+#define bWord1 0xc
+#define bDWord 0xf
+
+//for PutRegsetting & GetRegSetting BitMask
+#define bMaskByte0 0xff // Reg 0xc50 rOFDM0_XAAGCCore~0xC6f
+#define bMaskByte1 0xff00
+#define bMaskByte2 0xff0000
+#define bMaskByte3 0xff000000
+#define bMaskHWord 0xffff0000
+#define bMaskLWord 0x0000ffff
+#define bMaskDWord 0xffffffff
+
+//for PutRFRegsetting & GetRFRegSetting BitMask
+#define bMask12Bits 0xfffff // RF Reg mask bits
+#define bMask20Bits 0xfffff // RF Reg mask bits T65 RF
+#define bRFRegOffsetMask 0xfffff
+
+#define bEnable 0x1 // Useless
+#define bDisable 0x0
+
+#define LeftAntenna 0x0 // Useless
+#define RightAntenna 0x1
+
+#define tCheckTxStatus 500 //500ms // Useless
+#define tUpdateRxCounter 100 //100ms
+
+#define rateCCK 0 // Useless
+#define rateOFDM 1
+#define rateHT 2
+
+//define Register-End
+#define bPMAC_End 0x1ff // Useless
+#define bFPGAPHY0_End 0x8ff
+#define bFPGAPHY1_End 0x9ff
+#define bCCKPHY0_End 0xaff
+#define bOFDMPHY0_End 0xcff
+#define bOFDMPHY1_End 0xdff
+
+//define max debug item in each debug page
+//#define bMaxItem_FPGA_PHY0 0x9
+//#define bMaxItem_FPGA_PHY1 0x3
+//#define bMaxItem_PHY_11B 0x16
+//#define bMaxItem_OFDM_PHY0 0x29
+//#define bMaxItem_OFDM_PHY1 0x0
+
+#define bPMACControl 0x0 // Useless
+#define bWMACControl 0x1
+#define bWNICControl 0x2
+
+#define PathA 0x0 // Useless
+#define PathB 0x1
+#define PathC 0x2
+#define PathD 0x3
+
+/*--------------------------Define Parameters-------------------------------*/
+
+
+#endif //__INC_HAL8192SPHYREG_H
+
diff --git a/drivers/staging/rtl8192su/r8192S_rtl6052.c b/drivers/staging/rtl8192su/r8192S_rtl6052.c
new file mode 100644
index 000000000000..71caf81a6e10
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_rtl6052.c
@@ -0,0 +1,946 @@
+/******************************************************************************
+ *
+ * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
+ *
+ * Module: HalRf6052.c ( Source C File)
+ *
+ * Note: Provide RF 6052 series relative API.
+ *
+ * Function:
+ *
+ * Export:
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ *
+ * 09/25/2008 MHC Create initial version.
+ * 11/05/2008 MHC Add API for tw power setting.
+ *
+ *
+******************************************************************************/
+#include "r8192U.h"
+#include "r8192S_rtl6052.h"
+
+#ifdef RTL8192SU
+#include "r8192S_hw.h"
+#include "r8192S_phyreg.h"
+#include "r8192S_phy.h"
+#else
+#include "r8192U_hw.h"
+#include "r819xU_phyreg.h"
+#include "r819xU_phy.h"
+#endif
+
+
+/*---------------------------Define Local Constant---------------------------*/
+// Define local structure for debug!!!!!
+typedef struct RF_Shadow_Compare_Map {
+ // Shadow register value
+ u32 Value;
+ // Compare or not flag
+ u8 Compare;
+ // Record If it had ever modified unpredicted
+ u8 ErrorOrNot;
+ // Recorver Flag
+ u8 Recorver;
+ //
+ u8 Driver_Write;
+}RF_SHADOW_T;
+/*---------------------------Define Local Constant---------------------------*/
+
+
+/*------------------------Define global variable-----------------------------*/
+/*------------------------Define global variable-----------------------------*/
+
+
+
+
+/*---------------------Define local function prototype-----------------------*/
+void phy_RF6052_Config_HardCode(struct net_device* dev);
+
+RT_STATUS phy_RF6052_Config_ParaFile(struct net_device* dev);
+/*---------------------Define local function prototype-----------------------*/
+
+/*------------------------Define function prototype--------------------------*/
+extern void RF_ChangeTxPath(struct net_device* dev, u16 DataRate);
+
+/*------------------------Define function prototype--------------------------*/
+
+/*------------------------Define local variable------------------------------*/
+// 2008/11/20 MH For Debug only, RF
+static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];// = {{0}};//FIXLZM
+/*------------------------Define local variable------------------------------*/
+
+/*------------------------Define function prototype--------------------------*/
+/*-----------------------------------------------------------------------------
+ * Function: RF_ChangeTxPath
+ *
+ * Overview: For RL6052, we must change some RF settign for 1T or 2T.
+ *
+ * Input: u16 DataRate // 0x80-8f, 0x90-9f
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 09/25/2008 MHC Create Version 0.
+ * Firmwaer support the utility later.
+ *
+ *---------------------------------------------------------------------------*/
+extern void RF_ChangeTxPath(struct net_device* dev, u16 DataRate)
+{
+// We do not support gain table change inACUT now !!!! Delete later !!!
+#if 0//(RTL92SE_FPGA_VERIFY == 0)
+ static u1Byte RF_Path_Type = 2; // 1 = 1T 2= 2T
+ static u4Byte tx_gain_tbl1[6]
+ = {0x17f50, 0x11f40, 0x0cf30, 0x08720, 0x04310, 0x00100};
+ static u4Byte tx_gain_tbl2[6]
+ = {0x15ea0, 0x10e90, 0x0c680, 0x08250, 0x04040, 0x00030};
+ u1Byte i;
+
+ if (RF_Path_Type == 2 && (DataRate&0xF) <= 0x7)
+ {
+ // Set TX SYNC power G2G3 loop filter
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TXPA_G2, bMask20Bits, 0x0f000);
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TXPA_G3, bMask20Bits, 0xeacf1);
+
+ // Change TX AGC gain table
+ for (i = 0; i < 6; i++)
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TX_AGC, bMask20Bits, tx_gain_tbl1[i]);
+
+ // Set PA to high value
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TXPA_G2, bMask20Bits, 0x01e39);
+ }
+ else if (RF_Path_Type == 1 && (DataRate&0xF) >= 0x8)
+ {
+ // Set TX SYNC power G2G3 loop filter
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TXPA_G2, bMask20Bits, 0x04440);
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TXPA_G3, bMask20Bits, 0xea4f1);
+
+ // Change TX AGC gain table
+ for (i = 0; i < 6; i++)
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TX_AGC, bMask20Bits, tx_gain_tbl2[i]);
+
+ // Set PA low gain
+ PHY_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ RF_TXPA_G2, bMask20Bits, 0x01e19);
+ }
+#endif
+
+} /* RF_ChangeTxPath */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_RF6052SetBandwidth()
+ *
+ * Overview: This function is called by SetBWModeCallback8190Pci() only
+ *
+ * Input: PADAPTER Adapter
+ * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Note: For RF type 0222D
+ *---------------------------------------------------------------------------*/
+void PHY_RF6052SetBandwidth(struct net_device* dev, HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
+{
+ //u8 eRFPath;
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+
+
+ //if (priv->card_8192 == NIC_8192SE)
+#ifdef RTL8192SU //YJ,test,090113
+ {
+ switch(Bandwidth)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ //if (priv->card_8192_version >= VERSION_8192S_BCUT)
+ // rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);
+
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x01);
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ //if (priv->card_8192_version >= VERSION_8192S_BCUT)
+ // rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18);
+
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x00);
+ break;
+ default:
+ RT_TRACE(COMP_DBG, "PHY_SetRF6052Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth);
+ break;
+ }
+ }
+// else
+#else
+ {
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+ switch(Bandwidth)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ //PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x01);
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ //PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x00);
+ break;
+ default:
+ RT_TRACE(COMP_DBG, "PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth );
+ break;
+
+ }
+ }
+ }
+#endif
+}
+
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_RF6052SetCckTxPower
+ *
+ * Overview:
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/05/2008 MHC Simulate 8192series..
+ *
+ *---------------------------------------------------------------------------*/
+extern void PHY_RF6052SetCckTxPower(struct net_device* dev, u8 powerlevel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 TxAGC=0;
+
+ if(priv->ieee80211->scanning == 1)
+ TxAGC = 0x3f;
+ else if(priv->bDynamicTxLowPower == true)//cosa 04282008 for cck long range
+ TxAGC = 0x22;
+ else
+ TxAGC = powerlevel;
+
+ //cosa add for lenovo, to pass the safety spec, don't increase power index for different rates.
+ if(priv->bIgnoreDiffRateTxPowerOffset)
+ TxAGC = powerlevel;
+
+ if(TxAGC > RF6052_MAX_TX_PWR)
+ TxAGC = RF6052_MAX_TX_PWR;
+
+ //printk("CCK PWR= %x\n", TxAGC);
+ rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
+
+} /* PHY_RF6052SetCckTxPower */
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_RF6052SetOFDMTxPower
+ *
+ * Overview: For legacy and HY OFDM, we must read EEPROM TX power index for
+ * different channel and read original value in TX power register area from
+ * 0xe00. We increase offset and original value to be correct tx pwr.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/05/2008 MHC Simulate 8192 series method.
+* 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to
+ * A/B pwr difference or legacy/HT pwr diff.
+ * 2. We concern with path B legacy/HT OFDM difference.
+ * 01/22/2009 MHC Support new EPRO format from SD3.
+ *---------------------------------------------------------------------------*/
+ #if 1
+extern void PHY_RF6052SetOFDMTxPower(struct net_device* dev, u8 powerlevel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 writeVal, powerBase0, powerBase1;
+ u8 index = 0;
+ u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
+ //u8 byte0, byte1, byte2, byte3;
+ u8 Channel = priv->ieee80211->current_network.channel;
+ u8 rfa_pwr[4];
+ u8 rfa_lower_bound = 0, rfa_upper_bound = 0 /*, rfa_htpwr, rfa_legacypwr*/;
+ u8 i;
+ u8 rf_pwr_diff = 0;
+ u8 Legacy_pwrdiff=0, HT20_pwrdiff=0, BandEdge_Pwrdiff=0;
+ u8 ofdm_bandedge_chnl_low=0, ofdm_bandedge_chnl_high=0;
+
+
+ // We only care about the path A for legacy.
+ if (priv->EEPROMVersion != 2)
+ powerBase0 = powerlevel + (priv->LegacyHTTxPowerDiff & 0xf);
+ else if (priv->EEPROMVersion == 2) // Defined by SD1 Jong
+ {
+ //
+ // 2009/01/21 MH Support new EEPROM format from SD3 requirement
+ //
+ Legacy_pwrdiff = priv->TxPwrLegacyHtDiff[RF90_PATH_A][Channel-1];
+ // For legacy OFDM, tx pwr always > HT OFDM pwr. We do not care Path B
+ // legacy OFDM pwr diff. NO BB register to notify HW.
+ powerBase0 = powerlevel + Legacy_pwrdiff;
+ //RTPRINT(FPHY, PHY_TXPWR, (" [LagacyToHT40 pwr diff = %d]\n", Legacy_pwrdiff));
+
+ // Band Edge scheme is enabled for FCC mode
+ if (priv->TxPwrbandEdgeFlag == 1/* && pHalData->ChannelPlan == 0*/)
+ {
+ ofdm_bandedge_chnl_low = 1;
+ ofdm_bandedge_chnl_high = 11;
+ #if 0//cosa, Todo: check ofdm 40MHz, when lower and duplicate, the bandedge chnl low=3, high=9
+ if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ { // Is it the same with the document?
+ if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
+ else if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER;
+ else
+ pHalData->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
+ }
+ #endif
+ BandEdge_Pwrdiff = 0;
+ if (Channel <= ofdm_bandedge_chnl_low)
+ BandEdge_Pwrdiff = priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][0];
+ else if (Channel >= ofdm_bandedge_chnl_high)
+ {
+ BandEdge_Pwrdiff = priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][1];
+ }
+ powerBase0 -= BandEdge_Pwrdiff;
+ if (Channel <= ofdm_bandedge_chnl_low || Channel >= ofdm_bandedge_chnl_high)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR, (" [OFDM band-edge channel = %d, pwr diff = %d]\n",
+ //Channel, BandEdge_Pwrdiff));
+ }
+ }
+ //RTPRINT(FPHY, PHY_TXPWR, (" [OFDM power base index = 0x%x]\n", powerBase0));
+ }
+ powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
+
+ //MCS rates
+ if(priv->EEPROMVersion == 2)
+ {
+ //Cosa add for new EEPROM content. 02102009
+
+ //Check HT20 to HT40 diff
+ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+ {
+ // HT 20<->40 pwr diff
+ HT20_pwrdiff = priv->TxPwrHt20Diff[RF90_PATH_A][Channel-1];
+
+ // Calculate Antenna pwr diff
+ if (HT20_pwrdiff < 8) // 0~+7
+ powerlevel += HT20_pwrdiff;
+ else // index8-15=-8~-1
+ powerlevel -= (16-HT20_pwrdiff);
+
+ //RTPRINT(FPHY, PHY_TXPWR, (" [HT20 to HT40 pwrdiff = %d]\n", HT20_pwrdiff));
+ //RTPRINT(FPHY, PHY_TXPWR, (" [MCS power base index = 0x%x]\n", powerlevel));
+ }
+
+ // Band Edge scheme is enabled for FCC mode
+ if (priv->TxPwrbandEdgeFlag == 1/* && pHalData->ChannelPlan == 0*/)
+ {
+ BandEdge_Pwrdiff = 0;
+ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ {
+ if (Channel <= 3)
+ BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt40[RF90_PATH_A][0];
+ else if (Channel >= 9)
+ BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt40[RF90_PATH_A][1];
+ if (Channel <= 3 || Channel >= 9)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR, (" [HT40 band-edge channel = %d, pwr diff = %d]\n",
+ //Channel, BandEdge_Pwrdiff));
+ }
+ }
+ else if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+ {
+ if (Channel <= 1)
+ BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt20[RF90_PATH_A][0];
+ else if (Channel >= 11)
+ BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt20[RF90_PATH_A][1];
+ if (Channel <= 1 || Channel >= 11)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR, (" [HT20 band-edge channel = %d, pwr diff = %d]\n",
+ //Channel, BandEdge_Pwrdiff));
+ }
+ }
+ powerlevel -= BandEdge_Pwrdiff;
+ //RTPRINT(FPHY, PHY_TXPWR, (" [MCS power base index = 0x%x]\n", powerlevel));
+ }
+ }
+ powerBase1 = powerlevel;
+ powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
+
+ //RTPRINT(FPHY, PHY_TXPWR, (" [Legacy/HT power index= %x/%x]\n", powerBase0, powerBase1));
+
+ for(index=0; index<6; index++)
+ {
+ //
+ // Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate
+ //
+ //cosa add for lenovo, to pass the safety spec, don't increase power index for different rates.
+ if(priv->bIgnoreDiffRateTxPowerOffset)
+ writeVal = ((index<2)?powerBase0:powerBase1);
+ else
+ writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1);
+
+ //RTPRINT(FPHY, PHY_TXPWR, ("Reg 0x%x, Original=%x writeVal=%x\n",
+ //RegOffset[index], priv->MCSTxPowerLevelOriginalOffset[index], writeVal));
+
+ //
+ // If path A and Path B coexist, we must limit Path A tx power.
+ // Protect Path B pwr over or under flow. We need to calculate upper and
+ // lower bound of path A tx power.
+ //
+ if (priv->rf_type == RF_2T2R)
+ {
+ #if 0//cosa, we have only one AntennaTxPwDiff
+ // HT OFDM
+ if (index > 1)
+ {
+ rf_pwr_diff = pHalData->AntennaTxPwDiff[0];
+ }
+ // Legacy OFDM
+ else
+ {
+ rf_pwr_diff = pHalData->AntTxPwDiffLegacy[0];
+ }
+ #endif
+ rf_pwr_diff = priv->AntennaTxPwDiff[0];
+ //RTPRINT(FPHY, PHY_TXPWR, ("2T2R RF-B to RF-A PWR DIFF=%d\n", rf_pwr_diff));
+
+ if (rf_pwr_diff >= 8) // Diff=-8~-1
+ { // Prevent underflow!!
+ rfa_lower_bound = 0x10-rf_pwr_diff;
+ //RTPRINT(FPHY, PHY_TXPWR, ("rfa_lower_bound= %d\n", rfa_lower_bound));
+ }
+ else if (rf_pwr_diff >= 0) // Diff = 0-7
+ {
+ rfa_upper_bound = RF6052_MAX_TX_PWR-rf_pwr_diff;
+ //RTPRINT(FPHY, PHY_TXPWR, ("rfa_upper_bound= %d\n", rfa_upper_bound));
+ }
+ }
+
+ for (i= 0; i <4; i++)
+ {
+ rfa_pwr[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8));
+ if (rfa_pwr[i] > RF6052_MAX_TX_PWR)
+ rfa_pwr[i] = RF6052_MAX_TX_PWR;
+
+ //
+ // If path A and Path B coexist, we must limit Path A tx power.
+ // Protect Path B pwr over or under flow. We need to calculate upper and
+ // lower bound of path A tx power.
+ //
+ if (priv->rf_type == RF_2T2R)
+ {
+ if (rf_pwr_diff >= 8) // Diff=-8~-1
+ { // Prevent underflow!!
+ if (rfa_pwr[i] <rfa_lower_bound)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR, ("Underflow"));
+ rfa_pwr[i] = rfa_lower_bound;
+ }
+ }
+ else if (rf_pwr_diff >= 1) // Diff = 0-7
+ { // Prevent overflow
+ if (rfa_pwr[i] > rfa_upper_bound)
+ {
+ //RTPRINT(FPHY, PHY_TXPWR, ("Overflow"));
+ rfa_pwr[i] = rfa_upper_bound;
+ }
+ }
+ //RTPRINT(FPHY, PHY_TXPWR, ("rfa_pwr[%d]=%x\n", i, rfa_pwr[i]));
+ }
+
+ }
+
+ //
+ // Add description: PWDB > threshold!!!High power issue!!
+ // We must decrease tx power !! Why is the value ???
+ //
+ if(priv->bDynamicTxHighPower == TRUE)
+ {
+ // For MCS rate
+ if(index > 1)
+ {
+ writeVal = 0x03030303;
+ }
+ // For Legacy rate
+ else
+ {
+ writeVal = (rfa_pwr[3]<<24) | (rfa_pwr[2]<<16) |(rfa_pwr[1]<<8) |rfa_pwr[0];
+ }
+ //RTPRINT(FPHY, PHY_TXPWR, ("HighPower=%08x\n", writeVal));
+ }
+ else
+ {
+ writeVal = (rfa_pwr[3]<<24) | (rfa_pwr[2]<<16) |(rfa_pwr[1]<<8) |rfa_pwr[0];
+ //RTPRINT(FPHY, PHY_TXPWR, ("NormalPower=%08x\n", writeVal));
+ }
+
+ //
+ // Write different rate set tx power index.
+ //
+ //if (DCMD_Test_Flag == 0)
+ rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
+ }
+
+} /* PHY_RF6052SetOFDMTxPower */
+#else
+extern void PHY_RF6052SetOFDMTxPower(struct net_device* dev, u8 powerlevel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 writeVal, powerBase0, powerBase1;
+ u8 index = 0;
+ u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
+ u8 byte0, byte1, byte2, byte3;
+ u8 channel = priv->ieee80211->current_network.channel;
+
+ //Legacy OFDM rates
+ powerBase0 = powerlevel + (priv->LegacyHTTxPowerDiff & 0xf);
+ powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
+
+ //MCS rates HT OFDM
+ powerBase1 = powerlevel;
+ powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
+
+ //printk("Legacy/HT PWR= %x/%x\n", powerBase0, powerBase1);
+
+ for(index=0; index<6; index++)
+ {
+ //
+ // Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate
+ //
+ writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1);
+
+ //printk("Index = %d Original=%x writeVal=%x\n", index, priv->MCSTxPowerLevelOriginalOffset[index], writeVal);
+
+ byte0 = (u8)(writeVal & 0x7f);
+ byte1 = (u8)((writeVal & 0x7f00)>>8);
+ byte2 = (u8)((writeVal & 0x7f0000)>>16);
+ byte3 = (u8)((writeVal & 0x7f000000)>>24);
+
+ // Max power index = 0x3F Range = 0-0x3F
+ if(byte0 > RF6052_MAX_TX_PWR)
+ byte0 = RF6052_MAX_TX_PWR;
+ if(byte1 > RF6052_MAX_TX_PWR)
+ byte1 = RF6052_MAX_TX_PWR;
+ if(byte2 > RF6052_MAX_TX_PWR)
+ byte2 = RF6052_MAX_TX_PWR;
+ if(byte3 > RF6052_MAX_TX_PWR)
+ byte3 = RF6052_MAX_TX_PWR;
+
+ //
+ // Add description: PWDB > threshold!!!High power issue!!
+ // We must decrease tx power !! Why is the value ???
+ //
+ if(priv->bDynamicTxHighPower == true)
+ {
+ // For MCS rate
+ if(index > 1)
+ {
+ writeVal = 0x03030303;
+ }
+ // For Legacy rate
+ else
+ {
+ writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
+ }
+ }
+ else
+ {
+ writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
+ }
+
+ //
+ // Write different rate set tx power index.
+ //
+ rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
+ }
+
+} /* PHY_RF6052SetOFDMTxPower */
+#endif
+
+RT_STATUS PHY_RF6052_Config(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ //RF90_RADIO_PATH_E eRFPath;
+ //BB_REGISTER_DEFINITION_T *pPhyReg;
+ //u32 OrgStoreRFIntSW[RF90_PATH_D+1];
+
+ //
+ // Initialize general global value
+ //
+ // TODO: Extend RF_PATH_C and RF_PATH_D in the future
+ if(priv->rf_type == RF_1T1R)
+ priv->NumTotalRFPath = 1;
+ else
+ priv->NumTotalRFPath = 2;
+
+ //
+ // Config BB and RF
+ //
+// switch( priv->bRegHwParaFile )
+// {
+// case 0:
+// phy_RF6052_Config_HardCode(dev);
+// break;
+
+// case 1:
+ rtStatus = phy_RF6052_Config_ParaFile(dev);
+// break;
+
+// case 2:
+ // Partial Modify.
+// phy_RF6052_Config_HardCode(dev);
+// phy_RF6052_Config_ParaFile(dev);
+// break;
+
+// default:
+// phy_RF6052_Config_HardCode(dev);
+// break;
+// }
+ return rtStatus;
+
+}
+
+void phy_RF6052_Config_HardCode(struct net_device* dev)
+{
+
+ // Set Default Bandwidth to 20M
+ //Adapter->HalFunc .SetBWModeHandler(Adapter, HT_CHANNEL_WIDTH_20);
+
+ // TODO: Set Default Channel to channel one for RTL8225
+
+}
+
+RT_STATUS phy_RF6052_Config_ParaFile(struct net_device* dev)
+{
+ u32 u4RegValue = 0;
+ //static s1Byte szRadioAFile[] = RTL819X_PHY_RADIO_A;
+ //static s1Byte szRadioBFile[] = RTL819X_PHY_RADIO_B;
+ //static s1Byte szRadioBGMFile[] = RTL819X_PHY_RADIO_B_GM;
+ u8 eRFPath;
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ BB_REGISTER_DEFINITION_T *pPhyReg;
+ //u8 eCheckItem;
+
+
+ //3//-----------------------------------------------------------------
+ //3// <2> Initialize RF
+ //3//-----------------------------------------------------------------
+ //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+
+ pPhyReg = &priv->PHYRegDef[eRFPath];
+
+ /*----Store original RFENV control type----*/
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ case RF90_PATH_C:
+ u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
+ break;
+ case RF90_PATH_B :
+ case RF90_PATH_D:
+ u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
+ break;
+ }
+
+ /*----Set RF_ENV enable----*/
+ rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
+
+ /*----Set RF_ENV output high----*/
+ rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
+
+ /* Set bit number of Address and Data for RF register */
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255
+
+
+ /*----Initialize RF fom connfiguration file----*/
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+#if RTL8190_Download_Firmware_From_Header
+ rtStatus= rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+#else
+ rtStatus = PHY_ConfigRFWithParaFile(Adapter, (char* )&szRadioAFile, (RF90_RADIO_PATH_E)eRFPath);
+#endif
+ break;
+ case RF90_PATH_B:
+#if RTL8190_Download_Firmware_From_Header
+ rtStatus= rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+#else
+ if(priv->rf_type == RF_2T2R_GREEN)
+ rtStatus = PHY_ConfigRFWithParaFile(Adapter, (ps1Byte)&szRadioBGMFile, (RF90_RADIO_PATH_E)eRFPath);
+ else
+ rtStatus = PHY_ConfigRFWithParaFile(Adapter, (char* )&szRadioBFile, (RF90_RADIO_PATH_E)eRFPath);
+#endif
+ break;
+ case RF90_PATH_C:
+ break;
+ case RF90_PATH_D:
+ break;
+ }
+
+ /*----Restore RFENV control type----*/;
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ case RF90_PATH_C:
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
+ break;
+ case RF90_PATH_B :
+ case RF90_PATH_D:
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
+ break;
+ }
+
+ if(rtStatus != RT_STATUS_SUCCESS){
+ printk("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath);
+ goto phy_RF6052_Config_ParaFile_Fail;
+ }
+
+ }
+
+ RT_TRACE(COMP_INIT, "<---phy_RF6052_Config_ParaFile()\n");
+ return rtStatus;
+
+phy_RF6052_Config_ParaFile_Fail:
+ return rtStatus;
+}
+
+
+//
+// ==> RF shadow Operation API Code Section!!!
+//
+/*-----------------------------------------------------------------------------
+ * Function: PHY_RFShadowRead
+ * PHY_RFShadowWrite
+ * PHY_RFShadowCompare
+ * PHY_RFShadowRecorver
+ * PHY_RFShadowCompareAll
+ * PHY_RFShadowRecorverAll
+ * PHY_RFShadowCompareFlagSet
+ * PHY_RFShadowRecorverFlagSet
+ *
+ * Overview: When we set RF register, we must write shadow at first.
+ * When we are running, we must compare shadow abd locate error addr.
+ * Decide to recorver or not.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 11/20/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+extern u32 PHY_RFShadowRead(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset)
+{
+ return RF_Shadow[eRFPath][Offset].Value;
+
+} /* PHY_RFShadowRead */
+
+
+extern void PHY_RFShadowWrite(
+ struct net_device * dev,
+ u32 eRFPath,
+ u32 Offset,
+ u32 Data)
+{
+ //RF_Shadow[eRFPath][Offset].Value = (Data & bMask20Bits);
+ RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
+ RF_Shadow[eRFPath][Offset].Driver_Write = true;
+
+} /* PHY_RFShadowWrite */
+
+
+extern void PHY_RFShadowCompare(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset)
+{
+ u32 reg;
+
+ // Check if we need to check the register
+ if (RF_Shadow[eRFPath][Offset].Compare == true)
+ {
+ reg = rtl8192_phy_QueryRFReg(dev, eRFPath, Offset, bRFRegOffsetMask);
+ // Compare shadow and real rf register for 20bits!!
+ if (RF_Shadow[eRFPath][Offset].Value != reg)
+ {
+ // Locate error position.
+ RF_Shadow[eRFPath][Offset].ErrorOrNot = true;
+ RT_TRACE(COMP_INIT, "PHY_RFShadowCompare RF-%d Addr%02xErr = %05x", eRFPath, Offset, reg);
+ }
+ }
+
+} /* PHY_RFShadowCompare */
+
+extern void PHY_RFShadowRecorver(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset)
+{
+ // Check if the address is error
+ if (RF_Shadow[eRFPath][Offset].ErrorOrNot == true)
+ {
+ // Check if we need to recorver the register.
+ if (RF_Shadow[eRFPath][Offset].Recorver == true)
+ {
+ rtl8192_phy_SetRFReg(dev, eRFPath, Offset, bRFRegOffsetMask, RF_Shadow[eRFPath][Offset].Value);
+ RT_TRACE(COMP_INIT, "PHY_RFShadowRecorver RF-%d Addr%02x=%05x",
+ eRFPath, Offset, RF_Shadow[eRFPath][Offset].Value);
+ }
+ }
+
+} /* PHY_RFShadowRecorver */
+
+
+extern void PHY_RFShadowCompareAll(struct net_device * dev)
+{
+ u32 eRFPath;
+ u32 Offset;
+
+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
+ {
+ for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
+ {
+ PHY_RFShadowCompare(dev, (RF90_RADIO_PATH_E)eRFPath, Offset);
+ }
+ }
+
+} /* PHY_RFShadowCompareAll */
+
+
+extern void PHY_RFShadowRecorverAll(struct net_device * dev)
+{
+ u32 eRFPath;
+ u32 Offset;
+
+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
+ {
+ for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
+ {
+ PHY_RFShadowRecorver(dev, (RF90_RADIO_PATH_E)eRFPath, Offset);
+ }
+ }
+
+} /* PHY_RFShadowRecorverAll */
+
+
+extern void PHY_RFShadowCompareFlagSet(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u8 Type)
+{
+ // Set True or False!!!
+ RF_Shadow[eRFPath][Offset].Compare = Type;
+
+} /* PHY_RFShadowCompareFlagSet */
+
+
+extern void PHY_RFShadowRecorverFlagSet(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u8 Type)
+{
+ // Set True or False!!!
+ RF_Shadow[eRFPath][Offset].Recorver= Type;
+
+} /* PHY_RFShadowRecorverFlagSet */
+
+
+extern void PHY_RFShadowCompareFlagSetAll(struct net_device * dev)
+{
+ u32 eRFPath;
+ u32 Offset;
+
+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
+ {
+ for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
+ {
+ // 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!!
+ if (Offset != 0x26 && Offset != 0x27)
+ PHY_RFShadowCompareFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, FALSE);
+ else
+ PHY_RFShadowCompareFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, TRUE);
+ }
+ }
+
+} /* PHY_RFShadowCompareFlagSetAll */
+
+
+extern void PHY_RFShadowRecorverFlagSetAll(struct net_device * dev)
+{
+ u32 eRFPath;
+ u32 Offset;
+
+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
+ {
+ for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
+ {
+ // 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!!
+ if (Offset != 0x26 && Offset != 0x27)
+ PHY_RFShadowRecorverFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, FALSE);
+ else
+ PHY_RFShadowRecorverFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, TRUE);
+ }
+ }
+
+} /* PHY_RFShadowCompareFlagSetAll */
+
+
+
+extern void PHY_RFShadowRefresh(struct net_device * dev)
+{
+ u32 eRFPath;
+ u32 Offset;
+
+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
+ {
+ for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
+ {
+ RF_Shadow[eRFPath][Offset].Value = 0;
+ RF_Shadow[eRFPath][Offset].Compare = false;
+ RF_Shadow[eRFPath][Offset].Recorver = false;
+ RF_Shadow[eRFPath][Offset].ErrorOrNot = false;
+ RF_Shadow[eRFPath][Offset].Driver_Write = false;
+ }
+ }
+
+} /* PHY_RFShadowRead */
+
+/* End of HalRf6052.c */
diff --git a/drivers/staging/rtl8192su/r8192S_rtl6052.h b/drivers/staging/rtl8192su/r8192S_rtl6052.h
new file mode 100644
index 000000000000..916603ceaae0
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_rtl6052.h
@@ -0,0 +1,134 @@
+/******************************************************************************
+ *
+ * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
+ *
+ * Module: HalRf.h ( Header File)
+ *
+ * Note: Collect every HAL RF type exter API or constant.
+ *
+ * Function:
+ *
+ * Export:
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ *
+ * 09/25/2008 MHC Create initial version.
+ *
+ *
+******************************************************************************/
+/* Check to see if the file has been included already. */
+
+
+/*--------------------------Define Parameters-------------------------------*/
+
+//
+// For RF 6052 Series
+//
+#define RF6052_MAX_TX_PWR 0x3F
+#define RF6052_MAX_REG 0x3F
+#define RF6052_MAX_PATH 4
+/*--------------------------Define Parameters-------------------------------*/
+
+
+/*------------------------------Define structure----------------------------*/
+
+/*------------------------------Define structure----------------------------*/
+
+
+/*------------------------Export global variable----------------------------*/
+/*------------------------Export global variable----------------------------*/
+
+/*------------------------Export Marco Definition---------------------------*/
+
+/*------------------------Export Marco Definition---------------------------*/
+
+
+/*--------------------------Exported Function prototype---------------------*/
+//======================================================
+#if 1
+// Function prototypes for HalPhy8225.c
+//1======================================================
+extern void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); //20M or 40M;
+extern void PHY_SetRF8225Bandwidth( struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
+extern bool PHY_RF8225_Config(struct net_device* dev );
+extern void phy_RF8225_Config_HardCode(struct net_device* dev);
+extern bool phy_RF8225_Config_ParaFile(struct net_device* dev);
+extern void PHY_SetRF8225CckTxPower(struct net_device* dev ,u8 powerlevel);
+extern void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel);
+extern void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel);
+extern void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel);
+
+//1======================================================
+// Function prototypes for HalPhy8256.c
+//1======================================================
+extern void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
+extern void PHY_RF8256_Config(struct net_device* dev);
+extern void phy_RF8256_Config_ParaFile(struct net_device* dev);
+extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel);
+extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel);
+#endif
+
+//
+// RF RL6052 Series API
+//
+extern void RF_ChangeTxPath(struct net_device * dev, u16 DataRate);
+extern void PHY_RF6052SetBandwidth(struct net_device * dev,HT_CHANNEL_WIDTH Bandwidth);
+extern void PHY_RF6052SetCckTxPower(struct net_device * dev, u8 powerlevel);
+extern void PHY_RF6052SetOFDMTxPower(struct net_device * dev, u8 powerlevel);
+extern RT_STATUS PHY_RF6052_Config(struct net_device * dev);
+extern void PHY_RFShadowRefresh( struct net_device * dev);
+extern void PHY_RFShadowWrite( struct net_device* dev, u32 eRFPath, u32 Offset, u32 Data);
+#if 0
+//
+// RF Shadow operation relative API
+//
+extern u32
+PHY_RFShadowRead(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset);
+extern void
+PHY_RFShadowCompare(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset);
+extern void
+PHY_RFShadowRecorver(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset);
+extern void
+PHY_RFShadowCompareAll(
+ struct net_device * dev);
+extern void
+PHY_RFShadowRecorverAll(
+ struct net_device * dev);
+extern void
+PHY_RFShadowCompareFlagSet(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u8 Type);
+extern void
+PHY_RFShadowRecorverFlagSet(
+ struct net_device * dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u8 Type);
+extern void
+PHY_RFShadowCompareFlagSetAll(
+ struct net_device * dev);
+extern void
+PHY_RFShadowRecorverFlagSetAll(
+ struct net_device * dev);
+extern void
+PHY_RFShadowRefresh(
+ struct net_device * dev);
+#endif
+/*--------------------------Exported Function prototype---------------------*/
+
+
+/* End of HalRf.h */
diff --git a/drivers/staging/rtl8192su/r8192S_rtl8225.c b/drivers/staging/rtl8192su/r8192S_rtl8225.c
new file mode 100644
index 000000000000..09465df2def6
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_rtl8225.c
@@ -0,0 +1,292 @@
+
+#include "r8192U.h"
+#include "r8192S_hw.h"
+#include "r8192S_phyreg.h"
+#include "r8192S_phy.h"
+#include "r8192S_rtl8225.h"
+
+/*---------------------Define local function prototype-----------------------*/
+void phy_RF8225_Config_HardCode(struct net_device* dev );
+bool phy_RF8225_Config_ParaFile(struct net_device* dev );
+/*---------------------Define local function prototype-----------------------*/
+void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel)
+{
+
+}
+
+
+
+void PHY_SetRF8225CckTxPower( struct net_device* dev , u8 powerlevel)
+{
+
+}
+
+
+// TODO: The following RF 022D related function should be removed to HalPhy0222D.c.
+void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel)
+{
+ //TODO: We should set RF TxPower for RF 0222D here!!
+}
+
+
+
+void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel)
+{
+ //TODO: We should set RF TxPower for RF 0222D here!!
+}
+
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_SetRF0222DBandwidth()
+ *
+ * Overview: This function is called by SetBWModeCallback8190Pci() only
+ *
+ * Input: PADAPTER Adapter
+ * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Note: For RF type 0222D
+ *---------------------------------------------------------------------------*/
+ //just in phy
+void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
+{
+ u8 eRFPath;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+
+ //if (IS_HARDWARE_TYPE_8192S(dev))
+ if (1)
+ {
+#ifndef RTL92SE_FPGA_VERIFY
+ switch(Bandwidth)
+ {
+ case HT_CHANNEL_WIDTH_20:
+#ifdef FIB_MODIFICATION
+ write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x58);
+#endif
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x01);
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+#ifdef FIB_MODIFICATION
+ write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x18);
+#endif
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x00);
+ break;
+ default:
+ ;//RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
+ break;
+ }
+#endif
+ }
+ else
+ {
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+ switch(Bandwidth)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ //rtl8192_phy_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x01);
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ //rtl8192_phy_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x00);
+ break;
+ default:
+ ;//RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
+ break;
+
+ }
+ }
+ }
+
+}
+
+// TODO: Aabove RF 022D related function should be removed to HalPhy0222D.c.
+
+/*-----------------------------------------------------------------------------
+ * Function: PHY_SetRF8225Bandwidth()
+ *
+ * Overview: This function is called by SetBWModeCallback8190Pci() only
+ *
+ * Input: PADAPTER Adapter
+ * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Note: 8225(zebra1) support 20M only
+ *---------------------------------------------------------------------------*/
+ //just in phy
+void PHY_SetRF8225Bandwidth(struct net_device* dev ,HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
+{
+ u8 eRFPath;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+ switch(Bandwidth)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ // TODO: Update the parameters here
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci():8225 does not support 40M mode\n");
+ break;
+ default:
+ RT_TRACE(COMP_DBG, "PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth );
+ break;
+
+ }
+ }
+
+}
+
+//just in phy
+bool PHY_RF8225_Config(struct net_device* dev )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rtStatus = true;
+ //RF90_RADIO_PATH_E eRFPath;
+ //BB_REGISTER_DEFINITION_T *pPhyReg;
+ //u32 OrgStoreRFIntSW[RF90_PATH_D+1];
+
+ //
+ // Initialize general global value
+ //
+ // TODO: Extend RF_PATH_C and RF_PATH_D in the future
+ priv->NumTotalRFPath = 2;
+
+ //
+ // Config BB and RF
+ //
+ //switch( Adapter->MgntInfo.bRegHwParaFile )
+ //{
+ // case 0:
+ // phy_RF8225_Config_HardCode(dev);
+ // break;
+
+ // case 1:
+ // rtStatus = phy_RF8225_Config_ParaFile(dev);
+ // break;
+
+ // case 2:
+ // Partial Modify.
+ phy_RF8225_Config_HardCode(dev);
+ phy_RF8225_Config_ParaFile(dev);
+ // break;
+
+ // default:
+ // phy_RF8225_Config_HardCode(dev);
+ // break;
+ //}
+ return rtStatus;
+
+}
+
+//just in 8225
+void phy_RF8225_Config_HardCode(struct net_device* dev)
+{
+
+ // Set Default Bandwidth to 20M
+ //Adapter->HalFunc .SetBWModeHandler(Adapter, HT_CHANNEL_WIDTH_20);
+
+ // TODO: Set Default Channel to channel one for RTL8225
+
+}
+
+//just in 8225
+bool phy_RF8225_Config_ParaFile(struct net_device* dev)
+{
+ u32 u4RegValue = 0;
+ //static char szRadioAFile[] = RTL819X_PHY_RADIO_A;
+ //static char szRadioBFile[] = RTL819X_PHY_RADIO_B;
+ u8 eRFPath;
+ bool rtStatus = true;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ BB_REGISTER_DEFINITION_T *pPhyReg;
+ //u8 eCheckItem;
+
+#if 1
+ //3//-----------------------------------------------------------------
+ //3// <2> Initialize RF
+ //3//-----------------------------------------------------------------
+ //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ {
+
+ pPhyReg = &priv->PHYRegDef[eRFPath];
+
+ /*----Store original RFENV control type----*/
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ case RF90_PATH_C:
+ u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
+ break;
+ case RF90_PATH_B :
+ case RF90_PATH_D:
+ u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
+ break;
+ }
+
+ /*----Set RF_ENV enable----*/
+ rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
+
+ /*----Set RF_ENV output high----*/
+ rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
+
+ /* Set bit number of Address and Data for RF register */
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255
+
+
+ /*----Initialize RF fom connfiguration file----*/
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ //rtStatus = PHY_ConfigRFWithParaFile(dev, (char* )&szRadioAFile, (RF90_RADIO_PATH_E)eRFPath);
+ rtStatus = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+ break;
+ case RF90_PATH_B:
+ //rtStatus = PHY_ConfigRFWithParaFile(dev, (char* )&szRadioBFile, (RF90_RADIO_PATH_E)eRFPath);
+ rtStatus = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
+ break;
+ case RF90_PATH_C:
+ break;
+ case RF90_PATH_D:
+ break;
+ }
+
+ /*----Restore RFENV control type----*/;
+ switch(eRFPath)
+ {
+ case RF90_PATH_A:
+ case RF90_PATH_C:
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
+ break;
+ case RF90_PATH_B :
+ case RF90_PATH_D:
+ rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
+ break;
+ }
+
+ if(rtStatus == false){
+ //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF8225_Config_ParaFile():Radio[%d] Fail!!", eRFPath));
+ goto phy_RF8225_Config_ParaFile_Fail;
+ }
+
+ }
+
+ //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF8225_Config_ParaFile()\n"));
+ return rtStatus;
+
+phy_RF8225_Config_ParaFile_Fail:
+#endif
+ return rtStatus;
+}
+
+
diff --git a/drivers/staging/rtl8192su/r8192S_rtl8225.h b/drivers/staging/rtl8192su/r8192S_rtl8225.h
new file mode 100644
index 000000000000..8a647284af35
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192S_rtl8225.h
@@ -0,0 +1,30 @@
+/*
+ This is part of the rtl8180-sa2400 driver
+ released under the GPL (See file COPYING for details).
+ Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
+
+ This files contains programming code for the rtl8256
+ radio frontend.
+
+ *Many* thanks to Realtek Corp. for their great support!
+
+*/
+
+#ifndef RTL8225H
+#define RTL8225H
+
+#ifdef RTL8190P
+#define RTL819X_TOTAL_RF_PATH 4 //for 90P
+#else
+#define RTL819X_TOTAL_RF_PATH 2 //for 8192U
+#endif
+extern void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); //20M or 40M;
+extern void PHY_SetRF8225Bandwidth( struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
+extern bool PHY_RF8225_Config(struct net_device* dev );
+extern void phy_RF8225_Config_HardCode(struct net_device* dev);
+extern bool phy_RF8225_Config_ParaFile(struct net_device* dev);
+extern void PHY_SetRF8225CckTxPower(struct net_device* dev ,u8 powerlevel);
+extern void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel);
+extern void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel);
+extern void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel);
+#endif
diff --git a/drivers/staging/rtl8192su/r8192U.h b/drivers/staging/rtl8192su/r8192U.h
new file mode 100644
index 000000000000..a2365587b1c7
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U.h
@@ -0,0 +1,2112 @@
+/*
+ This is part of rtl8187 OpenSource driver.
+ Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+ Parts of this driver are based on the GPL part of the
+ official realtek driver
+
+ Parts of this driver are based on the rtl8192 driver skeleton
+ from Patric Schenke & Andres Salomon
+
+ Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
+
+ We want to tanks the Authors of those projects and the Ndiswrapper
+ project Authors.
+*/
+
+#ifndef R819xU_H
+#define R819xU_H
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+//#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/netdevice.h>
+//#include <linux/pci.h>
+#include <linux/usb.h>
+#include <linux/etherdevice.h>
+#include <linux/delay.h>
+#include <linux/rtnetlink.h> //for rtnl_lock()
+#include <linux/wireless.h>
+#include <linux/timer.h>
+#include <linux/proc_fs.h> // Necessary because we use the proc fs
+#include <linux/if_arp.h>
+#include <linux/random.h>
+#include <linux/version.h>
+#include <asm/io.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+#include <asm/semaphore.h>
+#endif
+#include "ieee80211.h"
+
+#ifdef RTL8192SU
+#include "r8192S_firmware.h"
+#else
+#include "r819xU_firmware.h"
+#endif
+
+//#define RTL8192U
+#define RTL819xU_MODULE_NAME "rtl819xU"
+//added for HW security, john.0629
+#define FALSE 0
+#define TRUE 1
+#define MAX_KEY_LEN 61
+#define KEY_BUF_SIZE 5
+
+#define BIT0 0x00000001
+#define BIT1 0x00000002
+#define BIT2 0x00000004
+#define BIT3 0x00000008
+#define BIT4 0x00000010
+#define BIT5 0x00000020
+#define BIT6 0x00000040
+#define BIT7 0x00000080
+#define BIT8 0x00000100
+#define BIT9 0x00000200
+#define BIT10 0x00000400
+#define BIT11 0x00000800
+#define BIT12 0x00001000
+#define BIT13 0x00002000
+#define BIT14 0x00004000
+#define BIT15 0x00008000
+#define BIT16 0x00010000
+#define BIT17 0x00020000
+#define BIT18 0x00040000
+#define BIT19 0x00080000
+#define BIT20 0x00100000
+#define BIT21 0x00200000
+#define BIT22 0x00400000
+#define BIT23 0x00800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+
+// Rx smooth factor
+#define Rx_Smooth_Factor 20
+#if 0 //we need to use RT_TRACE instead DMESG as RT_TRACE will clearly show debug level wb.
+#define DMESG(x,a...) printk(KERN_INFO RTL819xU_MODULE_NAME ": " x "\n", ## a)
+#define DMESGW(x,a...) printk(KERN_WARNING RTL819xU_MODULE_NAME ": WW:" x "\n", ## a)
+#define DMESGE(x,a...) printk(KERN_WARNING RTL819xU_MODULE_NAME ": EE:" x "\n", ## a)
+#else
+#define DMESG(x,a...)
+#define DMESGW(x,a...)
+#define DMESGE(x,a...)
+extern u32 rt_global_debug_component;
+#define RT_TRACE(component, x, args...) \
+do { if(rt_global_debug_component & component) \
+ printk(KERN_DEBUG RTL819xU_MODULE_NAME ":" x "\n" , \
+ ##args);\
+}while(0);
+//----------------------------------------------------------------------
+//// Get 8192SU Rx descriptor. Added by Roger, 2008.04.15.
+////----------------------------------------------------------------------
+#define RX_DESC_SIZE 24
+#define RX_DRV_INFO_SIZE_UNIT 8
+
+#define IS_UNDER_11N_AES_MODE(_ieee) ((_ieee->pHTInfo->bCurrentHTSupport==TRUE) &&\
+ (_ieee->pairwise_key_type==KEY_TYPE_CCMP))
+
+#define COMP_TRACE BIT0 // For function call tracing.
+#define COMP_DBG BIT1 // Only for temporary debug message.
+#define COMP_INIT BIT2 // during driver initialization / halt / reset.
+
+
+#define COMP_RECV BIT3 // Reveive part data path.
+#define COMP_SEND BIT4 // Send part path.
+#define COMP_IO BIT5 // I/O Related. Added by Annie, 2006-03-02.
+#define COMP_POWER BIT6 // 802.11 Power Save mode or System/Device Power state related.
+#define COMP_EPROM BIT7 // 802.11 link related: join/start BSS, leave BSS.
+#define COMP_SWBW BIT8 // For bandwidth switch.
+#define COMP_POWER_TRACKING BIT9 //FOR 8190 TX POWER TRACKING
+#define COMP_TURBO BIT10 // For Turbo Mode related. By Annie, 2005-10-21.
+#define COMP_QOS BIT11 // For QoS.
+#define COMP_RATE BIT12 // For Rate Adaptive mechanism, 2006.07.02, by rcnjko.
+#define COMP_LPS BIT13 // For Radio Measurement.
+#define COMP_DIG BIT14 // For DIG, 2006.09.25, by rcnjko.
+#define COMP_PHY BIT15
+#define COMP_CH BIT16 //channel setting debug
+#define COMP_TXAGC BIT17 // For Tx power, 060928, by rcnjko.
+#define COMP_HIPWR BIT18 // For High Power Mechanism, 060928, by rcnjko.
+#define COMP_HALDM BIT19 // For HW Dynamic Mechanism, 061010, by rcnjko.
+#define COMP_SEC BIT20 // Event handling
+#define COMP_LED BIT21 // For LED.
+#define COMP_RF BIT22 // For RF.
+//1!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#define COMP_RXDESC BIT23 // Show Rx desc information for SD3 debug. Added by Annie, 2006-07-15.
+//1//1Attention Please!!!<11n or 8190 specific code should be put below this line>
+//1!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+#define COMP_FIRMWARE BIT24 //for firmware downloading
+#define COMP_HT BIT25 // For 802.11n HT related information. by Emily 2006-8-11
+#define COMP_AMSDU BIT26 // For A-MSDU Debugging
+
+#define COMP_SCAN BIT27
+#define COMP_CMD BIT28
+#define COMP_DOWN BIT29 //for rm driver module
+#define COMP_RESET BIT30 //for silent reset
+#define COMP_ERR BIT31 //for error out, always on
+#endif
+
+#define RTL819x_DEBUG
+#ifdef RTL819x_DEBUG
+#define assert(expr) \
+ if (!(expr)) { \
+ printk( "Assertion failed! %s,%s,%s,line=%d\n", \
+ #expr,__FILE__,__FUNCTION__,__LINE__); \
+ }
+//wb added to debug out data buf
+//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
+#define RT_DEBUG_DATA(level, data, datalen) \
+ do{ if ((rt_global_debug_component & (level)) == (level)) \
+ { \
+ int i; \
+ u8* pdata = (u8*) data; \
+ printk(KERN_DEBUG RTL819xU_MODULE_NAME ": %s()\n", __FUNCTION__); \
+ for(i=0; i<(int)(datalen); i++) \
+ { \
+ printk("%2x ", pdata[i]); \
+ if ((i+1)%16 == 0) printk("\n"); \
+ } \
+ printk("\n"); \
+ } \
+ } while (0)
+#else
+#define assert(expr) do {} while (0)
+#define RT_DEBUG_DATA(level, data, datalen) do {} while(0)
+#endif /* RTL8169_DEBUG */
+
+//#ifdef RTL8192SU
+ //2TODO: We should define 8192S firmware related macro settings here!!
+ #define RTL819X_DEFAULT_RF_TYPE RF_1T2R
+ #define RTL819X_TOTAL_RF_PATH 2
+
+ //#define Rtl819XFwBootArray Rtl8192UsbFwBootArray
+ //#define Rtl819XFwMainArray Rtl8192UsbFwMainArray
+ //#define Rtl819XFwDataArray Rtl8192UsbFwDataArray
+
+ #define Rtl819XMACPHY_Array_PG Rtl8192UsbMACPHY_Array_PG
+ #define Rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array
+ #define Rtl819XPHY_REGArray Rtl8192UsbPHY_REGArray
+ #define Rtl819XPHY_REG_1T2RArray Rtl8192UsbPHY_REG_1T2RArray
+ //#define Rtl819XRadioA_Array Rtl8192UsbRadioA_Array
+ //#define Rtl819XRadioB_Array Rtl8192UsbRadioB_Array
+ #define Rtl819XRadioC_Array Rtl8192UsbRadioC_Array
+ #define Rtl819XRadioD_Array Rtl8192UsbRadioD_Array
+
+ //2008.11.06 Add.
+ #define Rtl819XFwImageArray Rtl8192SUFwImgArray
+ #define Rtl819XMAC_Array Rtl8192SUMAC_2T_Array
+ #define Rtl819XAGCTAB_Array Rtl8192SUAGCTAB_Array
+ #define Rtl819XPHY_REG_Array Rtl8192SUPHY_REG_2T2RArray
+ #define Rtl819XPHY_REG_to1T1R_Array Rtl8192SUPHY_ChangeTo_1T1RArray
+ #define Rtl819XPHY_REG_to1T2R_Array Rtl8192SUPHY_ChangeTo_1T2RArray
+ #define Rtl819XPHY_REG_to2T2R_Array Rtl8192SUPHY_ChangeTo_2T2RArray
+ #define Rtl819XPHY_REG_Array_PG Rtl8192SUPHY_REG_Array_PG
+ #define Rtl819XRadioA_Array Rtl8192SURadioA_1T_Array
+ #define Rtl819XRadioB_Array Rtl8192SURadioB_Array
+ #define Rtl819XRadioB_GM_Array Rtl8192SURadioB_GM_Array
+ #define Rtl819XRadioA_to1T_Array Rtl8192SURadioA_to1T_Array
+ #define Rtl819XRadioA_to2T_Array Rtl8192SURadioA_to2T_Array
+//#endif
+
+//
+// Queue Select Value in TxDesc
+//
+#define QSLT_BK 0x1
+#define QSLT_BE 0x0
+#define QSLT_VI 0x4
+#define QSLT_VO 0x6
+#define QSLT_BEACON 0x10
+#define QSLT_HIGH 0x11
+#define QSLT_MGNT 0x12
+#define QSLT_CMD 0x13
+
+#define DESC90_RATE1M 0x00
+#define DESC90_RATE2M 0x01
+#define DESC90_RATE5_5M 0x02
+#define DESC90_RATE11M 0x03
+#define DESC90_RATE6M 0x04
+#define DESC90_RATE9M 0x05
+#define DESC90_RATE12M 0x06
+#define DESC90_RATE18M 0x07
+#define DESC90_RATE24M 0x08
+#define DESC90_RATE36M 0x09
+#define DESC90_RATE48M 0x0a
+#define DESC90_RATE54M 0x0b
+#define DESC90_RATEMCS0 0x00
+#define DESC90_RATEMCS1 0x01
+#define DESC90_RATEMCS2 0x02
+#define DESC90_RATEMCS3 0x03
+#define DESC90_RATEMCS4 0x04
+#define DESC90_RATEMCS5 0x05
+#define DESC90_RATEMCS6 0x06
+#define DESC90_RATEMCS7 0x07
+#define DESC90_RATEMCS8 0x08
+#define DESC90_RATEMCS9 0x09
+#define DESC90_RATEMCS10 0x0a
+#define DESC90_RATEMCS11 0x0b
+#define DESC90_RATEMCS12 0x0c
+#define DESC90_RATEMCS13 0x0d
+#define DESC90_RATEMCS14 0x0e
+#define DESC90_RATEMCS15 0x0f
+#define DESC90_RATEMCS32 0x20
+
+//#ifdef RTL8192SU
+// CCK Rates, TxHT = 0
+#define DESC92S_RATE1M 0x00
+#define DESC92S_RATE2M 0x01
+#define DESC92S_RATE5_5M 0x02
+#define DESC92S_RATE11M 0x03
+
+// OFDM Rates, TxHT = 0
+#define DESC92S_RATE6M 0x04
+#define DESC92S_RATE9M 0x05
+#define DESC92S_RATE12M 0x06
+#define DESC92S_RATE18M 0x07
+#define DESC92S_RATE24M 0x08
+#define DESC92S_RATE36M 0x09
+#define DESC92S_RATE48M 0x0a
+#define DESC92S_RATE54M 0x0b
+
+// MCS Rates, TxHT = 1
+#define DESC92S_RATEMCS0 0x0c
+#define DESC92S_RATEMCS1 0x0d
+#define DESC92S_RATEMCS2 0x0e
+#define DESC92S_RATEMCS3 0x0f
+#define DESC92S_RATEMCS4 0x10
+#define DESC92S_RATEMCS5 0x11
+#define DESC92S_RATEMCS6 0x12
+#define DESC92S_RATEMCS7 0x13
+#define DESC92S_RATEMCS8 0x14
+#define DESC92S_RATEMCS9 0x15
+#define DESC92S_RATEMCS10 0x16
+#define DESC92S_RATEMCS11 0x17
+#define DESC92S_RATEMCS12 0x18
+#define DESC92S_RATEMCS13 0x19
+#define DESC92S_RATEMCS14 0x1a
+#define DESC92S_RATEMCS15 0x1b
+#define DESC92S_RATEMCS15_SG 0x1c
+#define DESC92S_RATEMCS32 0x20
+//#endif
+
+#define RTL819X_DEFAULT_RF_TYPE RF_1T2R
+
+#define IEEE80211_WATCH_DOG_TIME 2000
+#define PHY_Beacon_RSSI_SLID_WIN_MAX 10
+//for txpowertracking by amy
+#define OFDM_Table_Length 19
+#define CCK_Table_length 12
+
+#ifdef RTL8192SU
+//
+//Tx Descriptor for RLT8192SU(Normal mode)
+//
+typedef struct _tx_desc_819x_usb {
+ // DWORD 0
+ u16 PktSize;//:16;
+ u8 Offset;//:8;
+ u8 Type:2; // Reserved for MAC header Frame Type subfield.
+ u8 LastSeg:1;
+ u8 FirstSeg:1;
+ u8 LINIP:1;
+ u8 AMSDU:1;
+ u8 GF:1;
+ u8 OWN:1;
+
+ // DWORD 1
+ u8 MacID:5;
+ u8 MoreData:1;
+ u8 MOREFRAG:1;
+ u8 PIFS:1;
+ u8 QueueSelect:5;
+ u8 AckPolicy:2;
+ u8 NoACM:1;
+ u8 NonQos:1;
+ u8 KeyID:2;
+ u8 OUI:1;
+ u8 PktType:1;
+ u8 EnDescID:1;
+ u8 SecType:2;
+ u8 HTC:1; //padding0
+ u8 WDS:1; //padding1
+ u8 PktOffset:5; //padding_len (hw)
+ u8 HWPC:1;
+
+ // DWORD 2
+ u32 DataRetryLmt:6;
+ u32 RetryLmtEn:1;
+ u32 TSFL:5;
+ u32 RTSRC:6; // Reserved for HW RTS Retry Count.
+ u32 DATARC:6; // Reserved for HW DATA Retry Count.
+ u32 Rsvd1:5;
+ u32 AllowAggregation:1;
+ u32 BK:1; //Aggregation break.
+ u32 OwnMAC:1;
+
+ // DWORD 3
+ u8 NextHeadPage;//:8;
+ u8 TailPage;//:8;
+ u16 Seq:12;
+ u16 Frag:4;
+
+ // DWORD 4
+ u32 RTSRate:6;
+ u32 DisRTSFB:1;
+ u32 RTSRateFBLmt:4;
+ u32 CTS2Self:1;
+ u32 RTSEn:1;
+ u32 RaBRSRID:3; //Rate adaptive BRSR ID.
+ u32 TxHT:1;
+ u32 TxShort:1;//for data
+ u32 TxBandwidth:1;
+ u32 TxSubCarrier:2;
+ u32 STBC:2;
+ u32 RD:1;
+ u32 RTSHT:1;
+ u32 RTSShort:1;
+ u32 RTSBW:1;
+ u32 RTSSubcarrier:2;
+ u32 RTSSTBC:2;
+ u32 USERATE:1;
+ // DWORD 5
+ u32 PktID:9;
+ u32 TxRate:6;
+ u32 DISFB:1;
+ u32 DataRateFBLmt:5;
+ u32 TxAGC:11;
+
+ // DWORD 6
+ u16 IPChkSum;//:16;
+ u16 TCPChkSum;//:16;
+
+ // DWORD 7
+ //u16 TxBuffSize;//:16;//pcie
+ u16 TxBufferSize;
+ u16 IPHdrOffset:8;
+ u16 Rsvd2:7;
+ u16 TCPEn:1;
+}tx_desc_819x_usb, *ptx_desc_819x_usb;
+typedef struct _tx_status_desc_8192s_usb{
+
+ //DWORD 0
+ u8 TxRate:6;
+ u8 Rsvd1:1;
+ u8 BandWidth:1;
+ u8 RTSRate:6;
+ u8 AGGLS:1;
+ u8 AGG:1;
+ u8 RTSRC:6;
+ u8 DataRC:6;
+ u8 FailCause:2;
+ u8 TxOK:1;
+ u8 Own:1;
+
+ //DWORD 1
+ u16 Seq:12;
+ u8 QueueSel:5;
+ u8 MACID:5;
+ u8 PwrMgt:1;
+ u8 MoreData:1;
+ u8 Rsvd2;
+
+ //DWORD 2
+ u8 RxAGC1;
+ u8 RxAGC2;
+ u8 RxAGC3;
+ u8 RxAGC4;
+}tx_status_desc_8192s_usb, *ptx_status_desc_8192s_usb;
+#else
+/* for rtl819x */
+typedef struct _tx_desc_819x_usb {
+ //DWORD 0
+ u16 PktSize;
+ u8 Offset;
+ u8 Reserved0:3;
+ u8 CmdInit:1;
+ u8 LastSeg:1;
+ u8 FirstSeg:1;
+ u8 LINIP:1;
+ u8 OWN:1;
+
+ //DWORD 1
+ u8 TxFWInfoSize;
+ u8 RATid:3;
+ u8 DISFB:1;
+ u8 USERATE:1;
+ u8 MOREFRAG:1;
+ u8 NoEnc:1;
+ u8 PIFS:1;
+ u8 QueueSelect:5;
+ u8 NoACM:1;
+ u8 Reserved1:2;
+ u8 SecCAMID:5;
+ u8 SecDescAssign:1;
+ u8 SecType:2;
+
+ //DWORD 2
+ u16 TxBufferSize;
+ //u16 Reserved2;
+ u8 ResvForPaddingLen:7;
+ u8 Reserved3:1;
+ u8 Reserved4;
+
+ //DWORD 3, 4, 5
+ u32 Reserved5;
+ u32 Reserved6;
+ u32 Reserved7;
+}tx_desc_819x_usb, *ptx_desc_819x_usb;
+#endif
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+typedef struct _tx_desc_819x_usb_aggr_subframe {
+ //DWORD 0
+ u16 PktSize;
+ u8 Offset;
+ u8 TxFWInfoSize;
+
+ //DWORD 1
+ u8 RATid:3;
+ u8 DISFB:1;
+ u8 USERATE:1;
+ u8 MOREFRAG:1;
+ u8 NoEnc:1;
+ u8 PIFS:1;
+ u8 QueueSelect:5;
+ u8 NoACM:1;
+ u8 Reserved1:2;
+ u8 SecCAMID:5;
+ u8 SecDescAssign:1;
+ u8 SecType:2;
+ u8 PacketID:7;
+ u8 OWN:1;
+}tx_desc_819x_usb_aggr_subframe, *ptx_desc_819x_usb_aggr_subframe;
+#endif
+
+
+#ifdef RTL8192SU
+//
+//Tx Descriptor for RLT8192SU(Load FW mode)
+//
+typedef struct _tx_desc_cmd_819x_usb{
+ // DWORD 0
+ u16 PktSize;
+ u8 Offset;
+ u8 Rsvd0:4;
+ u8 LINIP:1;
+ u8 Rsvd1:2;
+ u8 OWN:1;
+
+ // DWORD 1, 2, 3, 4, 5, 6 are all reserved.
+ u32 Rsvd2;
+ u32 Rsvd3;
+ u32 Rsvd4;
+ u32 Rsvd5;
+ u32 Rsvd6;
+ u32 Rsvd7;
+
+ // DWORD 7
+ u16 TxBuffSize;//pcie
+ u16 Rsvd8;
+}tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb;
+//
+//H2C Command for RLT8192SU(Host TxCmd)
+//
+typedef struct _tx_h2c_desc_cmd_8192s_usb{
+ // DWORD 0
+ u32 PktSize:16;
+ u32 Offset:8;
+ u32 Rsvd0:7;
+ u32 OWN:1;
+
+ // DWORD 1
+ u32 Rsvd1:8;
+ u32 QSEL:5;
+ u32 Rsvd2:19;
+
+ // DWORD 2
+ u32 Rsvd3;
+
+ // DWORD 3
+ u32 NextHeadPage:8;
+ u32 TailPage:8;
+ u32 Rsvd4:16;
+
+ // DWORD 4, 5, 6, 7
+ u32 Rsvd5;
+ u32 Rsvd6;
+ u32 Rsvd7;
+ u32 Rsvd8;
+}tx_h2c_desc_cmd_8192s_usb, *ptx_h2c_desc_cmd_8192s_usb;
+
+
+typedef struct _tx_h2c_cmd_hdr_8192s_usb{
+ // DWORD 0
+ u32 CmdLen:16;
+ u32 ElementID:8;
+ u32 CmdSeq:8;
+
+ // DWORD 1
+ u32 Rsvd0;
+}tx_h2c_cmd_hdr_8192s_usb, *ptx_h2c_cmd_hdr_8192s_usb;
+#else
+typedef struct _tx_desc_cmd_819x_usb {
+ //DWORD 0
+ u16 Reserved0;
+ u8 Reserved1;
+ u8 Reserved2:3;
+ u8 CmdInit:1;
+ u8 LastSeg:1;
+ u8 FirstSeg:1;
+ u8 LINIP:1;
+ u8 OWN:1;
+
+ //DOWRD 1
+ //u32 Reserved3;
+ u8 TxFWInfoSize;
+ u8 Reserved3;
+ u8 QueueSelect;
+ u8 Reserved4;
+
+ //DOWRD 2
+ u16 TxBufferSize;
+ u16 Reserved5;
+
+ //DWORD 3,4,5
+ //u32 TxBufferAddr;
+ //u32 NextDescAddress;
+ u32 Reserved6;
+ u32 Reserved7;
+ u32 Reserved8;
+}tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb;
+#endif
+
+#ifdef RTL8192SU
+typedef struct _tx_fwinfo_819x_usb{
+ //DWORD 0
+ u8 TxRate:7;
+ u8 CtsEnable:1;
+ u8 RtsRate:7;
+ u8 RtsEnable:1;
+ u8 TxHT:1;
+ u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS
+ u8 TxBandwidth:1; // This is used for HT MCS rate only.
+ u8 TxSubCarrier:2; // This is used for legacy OFDM rate only.
+ u8 STBC:2;
+ u8 AllowAggregation:1;
+ u8 RtsHT:1; //Interpre RtsRate field as high throughput data rate
+ u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS
+ u8 RtsBandwidth:1; // This is used for HT MCS rate only.
+ u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only.
+ u8 RtsSTBC:2;
+ u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration
+
+ //DWORD 1
+ u32 RxMF:2;
+ u32 RxAMD:3;
+ u32 Reserved1:3;
+ u32 TxAGCOffSet:4;//TxAGCOffset:4;
+ u32 TxAGCSign:1;
+ u32 Tx_INFO_RSVD:6;
+ u32 PacketID:13;
+}tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb;
+#else
+typedef struct _tx_fwinfo_819x_usb {
+ //DOWRD 0
+ u8 TxRate:7;
+ u8 CtsEnable:1;
+ u8 RtsRate:7;
+ u8 RtsEnable:1;
+ u8 TxHT:1;
+ u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS
+ u8 TxBandwidth:1; // This is used for HT MCS rate only.
+ u8 TxSubCarrier:2; // This is used for legacy OFDM rate only.
+ u8 STBC:2;
+ u8 AllowAggregation:1;
+ u8 RtsHT:1; //Interpre RtsRate field as high throughput data rate
+ u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS
+ u8 RtsBandwidth:1; // This is used for HT MCS rate only.
+ u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only.
+ u8 RtsSTBC:2;
+ u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration
+
+ //DWORD 1
+ u32 RxMF:2;
+ u32 RxAMD:3;
+ u32 TxPerPktInfoFeedback:1;//1 indicate Tx info gathtered by firmware and returned by Rx Cmd
+ u32 Reserved1:2;
+ u32 TxAGCOffSet:4;
+ u32 TxAGCSign:1;
+ u32 Tx_INFO_RSVD:6;
+ u32 PacketID:13;
+ //u32 Reserved;
+}tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb;
+#endif
+
+typedef struct rtl8192_rx_info {
+ struct urb *urb;
+ struct net_device *dev;
+ u8 out_pipe;
+}rtl8192_rx_info ;
+
+#ifdef RTL8192SU
+//typedef struct _RX_DESC_STATUS_8192SU{
+typedef struct rx_desc_819x_usb{
+ //DWORD 0
+ u16 Length:14;
+ u16 CRC32:1;
+ u16 ICV:1;
+ u8 RxDrvInfoSize:4;
+ u8 Security:3;
+ u8 Qos:1;
+ u8 Shift:2;
+ u8 PHYStatus:1;
+ u8 SWDec:1;
+ u8 LastSeg:1;
+ u8 FirstSeg:1;
+ u8 EOR:1;
+ u8 Own:1;
+
+ //DWORD 1
+ u16 MACID:5;
+ u16 TID:4;
+ u16 HwRsvd:5;
+ u16 PAGGR:1;
+ u16 FAGGR:1;
+ u8 A1_FIT:4;
+ u8 A2_FIT:4;
+ u8 PAM:1;
+ u8 PWR:1;
+ u8 MoreData:1;
+ u8 MoreFrag:1;
+ u8 Type:2;
+ u8 MC:1;
+ u8 BC:1;
+
+ //DWORD 2
+ u16 Seq:12;
+ u16 Frag:4;
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ u8 UsbAggPktNum;//:8;
+#else
+ u8 NextPktLen;//:8;
+#endif
+ u8 Rsvd0:6;
+ u8 NextIND:1;
+ u8 Rsvd1:1;
+
+ //DWORD 3
+ u8 RxMCS:6;
+ u8 RxHT:1;
+ u8 AMSDU:1;
+ u8 SPLCP:1;
+ u8 BW:1;
+ u8 HTC:1;
+ u8 TCPChkRpt:1;
+ u8 IPChkRpt:1;
+ u8 TCPChkValID:1;
+ u8 HwPCErr:1;
+ u8 HwPCInd:1;
+ u16 IV0;//:16;
+
+ //DWORD 4
+ u32 IV1;
+
+ //DWORD 5
+ u32 TSFL;
+//}RX_DESC_STATUS_8192SU, *PRX_DESC_STATUS_8192SU;
+}rx_desc_819x_usb, *prx_desc_819x_usb;
+#else
+typedef struct rx_desc_819x_usb{
+ //DOWRD 0
+ u16 Length:14;
+ u16 CRC32:1;
+ u16 ICV:1;
+ u8 RxDrvInfoSize;
+ u8 Shift:2;
+ u8 PHYStatus:1;
+ u8 SWDec:1;
+ //u8 LastSeg:1;
+ //u8 FirstSeg:1;
+ //u8 EOR:1;
+ //u8 OWN:1;
+ u8 Reserved1:4;
+
+ //DWORD 1
+ u32 Reserved2;
+
+ //DWORD 2
+ //u32 Reserved3;
+
+ //DWORD 3
+ //u32 BufferAddress;
+
+}rx_desc_819x_usb, *prx_desc_819x_usb;
+#endif
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+typedef struct _rx_desc_819x_usb_aggr_subframe{
+ //DOWRD 0
+ u16 Length:14;
+ u16 CRC32:1;
+ u16 ICV:1;
+ u8 Offset;
+ u8 RxDrvInfoSize;
+ //DOWRD 1
+ u8 Shift:2;
+ u8 PHYStatus:1;
+ u8 SWDec:1;
+ u8 Reserved1:4;
+ u8 Reserved2;
+ u16 Reserved3;
+ //DWORD 2
+ //u4Byte Reserved3;
+ //DWORD 3
+ //u4Byte BufferAddress;
+}rx_desc_819x_usb_aggr_subframe, *prx_desc_819x_usb_aggr_subframe;
+#endif
+
+#ifdef RTL8192SU
+//
+// Driver info are written to the begining of the RxBuffer
+//
+//typedef struct _RX_DRIVER_INFO_8192S{
+typedef struct rx_drvinfo_819x_usb{
+ //
+ // Driver info contain PHY status and other variabel size info
+ // PHY Status content as below
+ //
+
+ //DWORD 0
+ /*u4Byte gain_0:7;
+ u4Byte trsw_0:1;
+ u4Byte gain_1:7;
+ u4Byte trsw_1:1;
+ u4Byte gain_2:7;
+ u4Byte trsw_2:1;
+ u4Byte gain_3:7;
+ u4Byte trsw_3:1; */
+ u8 gain_trsw[4];
+
+ //DWORD 1
+ /*u4Byte pwdb_all:8;
+ u4Byte cfosho_0:8;
+ u4Byte cfosho_1:8;
+ u4Byte cfosho_2:8;*/
+ u8 pwdb_all;
+ u8 cfosho[4];
+
+ //DWORD 2
+ /*u4Byte cfosho_3:8;
+ u4Byte cfotail_0:8;
+ u4Byte cfotail_1:8;
+ u4Byte cfotail_2:8;*/
+ u8 cfotail[4];
+
+ //DWORD 3
+ /*u4Byte cfotail_3:8;
+ u4Byte rxevm_0:8;
+ u4Byte rxevm_1:8;
+ u4Byte rxsnr_0:8;*/
+ char rxevm[2];
+ char rxsnr[4];
+
+ //DWORD 4
+ /*u4Byte rxsnr_1:8;
+ u4Byte rxsnr_2:8;
+ u4Byte rxsnr_3:8;
+ u4Byte pdsnr_0:8;*/
+ u8 pdsnr[2];
+
+ //DWORD 5
+ /*u4Byte pdsnr_1:8;
+ u4Byte csi_current_0:8;
+ u4Byte csi_current_1:8;
+ u4Byte csi_target_0:8;*/
+ u8 csi_current[2];
+ u8 csi_target[2];
+
+ //DWORD 6
+ /*u4Byte csi_target_1:8;
+ u4Byte sigevm:8;
+ u4Byte max_ex_pwr:8;
+ u4Byte ex_intf_flag:1;
+ u4Byte sgi_en:1;
+ u4Byte rxsc:2;
+ u4Byte reserve:4;*/
+ u8 sigevm;
+ u8 max_ex_pwr;
+ u8 ex_intf_flag:1;
+ u8 sgi_en:1;
+ u8 rxsc:2;
+ u8 reserve:4;
+
+}rx_drvinfo_819x_usb, *prx_drvinfo_819x_usb;
+#else
+typedef struct rx_drvinfo_819x_usb{
+ //DWORD 0
+ u16 Reserved1:12;
+ u16 PartAggr:1;
+ u16 FirstAGGR:1;
+ u16 Reserved2:2;
+
+ u8 RxRate:7;
+ u8 RxHT:1;
+
+ u8 BW:1;
+ u8 SPLCP:1;
+ u8 Reserved3:2;
+ u8 PAM:1;
+ u8 Mcast:1;
+ u8 Bcast:1;
+ u8 Reserved4:1;
+
+ //DWORD 1
+ u32 TSFL;
+
+}rx_drvinfo_819x_usb, *prx_drvinfo_819x_usb;
+#endif
+
+ #define HWSET_MAX_SIZE_92S 128
+#ifdef RTL8192SU
+ #define MAX_802_11_HEADER_LENGTH 40
+ #define MAX_PKT_AGG_NUM 256
+ #define TX_PACKET_SHIFT_BYTES USB_HWDESC_HEADER_LEN
+#else
+ #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE)
+ #define MAX_PKT_AGG_NUM 64
+ #define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
+#endif
+
+#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */
+#define MAX_FIRMWARE_INFORMATION_SIZE 32 /*2006/04/30 by Emily forRTL8190*/
+//#define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE)
+#define ENCRYPTION_MAX_OVERHEAD 128
+#define USB_HWDESC_HEADER_LEN sizeof(tx_desc_819x_usb)
+//#define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
+#define MAX_FRAGMENT_COUNT 8
+#ifdef RTL8192U
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+#define MAX_TRANSMIT_BUFFER_SIZE 32000
+#else
+#define MAX_TRANSMIT_BUFFER_SIZE 8000
+#endif
+#else
+#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT)
+#endif
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+#define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb))
+#endif
+#define scrclng 4 // octets for crc32 (FCS, ICV)
+
+typedef enum rf_optype
+{
+ RF_OP_By_SW_3wire = 0,
+ RF_OP_By_FW,
+ RF_OP_MAX
+}rf_op_type;
+/* 8190 Loopback Mode definition */
+typedef enum _rtl819xUsb_loopback{
+ RTL819xU_NO_LOOPBACK = 0,
+ RTL819xU_MAC_LOOPBACK = 1,
+ RTL819xU_DMA_LOOPBACK = 2,
+ RTL819xU_CCK_LOOPBACK = 3,
+}rtl819xUsb_loopback_e;
+
+/* for rtl819x */
+typedef enum _RT_STATUS{
+ RT_STATUS_SUCCESS = 0,
+ RT_STATUS_FAILURE = 1,
+ RT_STATUS_PENDING = 2,
+ RT_STATUS_RESOURCE = 3
+}RT_STATUS,*PRT_STATUS;
+
+//#ifdef RTL8192SU
+typedef enum _RTL8192SUSB_LOOPBACK{
+ RTL8192SU_NO_LOOPBACK = 0,
+ RTL8192SU_MAC_LOOPBACK = 1,
+ RTL8192SU_DMA_LOOPBACK = 2,
+ RTL8192SU_CCK_LOOPBACK = 3,
+}RTL8192SUSB_LOOPBACK_E;
+//#endif
+
+
+#if 0
+/* due to rtl8192 firmware */
+typedef enum _desc_packet_type_e{
+ DESC_PACKET_TYPE_INIT = 0,
+ DESC_PACKET_TYPE_NORMAL = 1,
+}desc_packet_type_e;
+
+typedef enum _firmware_source{
+ FW_SOURCE_IMG_FILE = 0,
+ FW_SOURCE_HEADER_FILE = 1, //from header file
+}firmware_source_e, *pfirmware_source_e;
+
+typedef enum _firmware_status{
+ FW_STATUS_0_INIT = 0,
+ FW_STATUS_1_MOVE_BOOT_CODE = 1,
+ FW_STATUS_2_MOVE_MAIN_CODE = 2,
+ FW_STATUS_3_TURNON_CPU = 3,
+ FW_STATUS_4_MOVE_DATA_CODE = 4,
+ FW_STATUS_5_READY = 5,
+}firmware_status_e;
+
+typedef struct _rt_firmare_seg_container {
+ u16 seg_size;
+ u8 *seg_ptr;
+}fw_seg_container, *pfw_seg_container;
+
+#ifdef RTL8192SU
+//--------------------------------------------------------------------------------
+// 8192S Firmware related
+//--------------------------------------------------------------------------------
+typedef struct _RT_8192S_FIRMWARE_PRIV { //8-bytes alignment required
+
+ //--- LONG WORD 0 ----
+ u32 RegulatoryClass;
+ u32 Rfintfs;
+
+ //--- LONG WORD 1 ----
+ u32 ChipVer;
+ u32 HCISel;
+
+ //--- LONG WORD 2 ----
+ u32 IBKMode;
+ u32 Rsvd00;
+
+ //--- LONG WORD 3 ----
+ u32 Rsvd01;
+ u8 Qos_En; // QoS enable
+ u8 En40MHz; // 40MHz BW enable
+ u8 AMSDU2AMPDU_En; //14181 convert AMSDU to AMPDU, 0: disable
+ u8 AMPDU_En; //111n AMPDU/AMSDU enable
+
+ //--- LONG WORD 4 ----
+ u8 rate_control_offload;//FW offloads, 0: driver handles
+ u8 aggregation_offload; // FW offloads, 0: driver handles
+ u8 beacon_offload; //FW offloads, 0: driver handles
+ u8 MLME_offload; // FW offloads, 0: driver handles
+ u8 hwpc_offload; // FW offloads, 0: driver handles
+ u8 tcp_checksum_offload; //FW offloads, 0: driver handles
+ u8 tcp_offload; //FW offloads, 0: driver handles
+ u8 ps_control_offload; //FW offloads, 0: driver handles
+
+ //--- LONG WORD 5 ----
+ u8 WWLAN_Offload; // FW offloads, 0: driver handles
+ u8 MPMode; // normal mode, 0: MP mode;
+ u16 Version; //0x8000 ~ 0x8FFF for FPGA version, 0x0000 ~ 0x7FFF for ASIC version,
+ u16 Signature; //0x12: 8712, 0x92: 8192S
+ u16 Rsvd11;
+
+// u32 rsvd1;
+// u32 wireless_band; //no A-band exists in 8712
+}RT_8192S_FIRMWARE_PRIV, *PRT_8192S_FIRMWARE_PRIV;
+
+typedef struct _RT_8192S_FIRMWARE_HDR {//8-byte alinment required
+
+ //--- LONG WORD 0 ----
+ u16 Signature;
+ u16 Version; //0x8000 ~ 0x8FFF for FPGA version, 0x0000 ~ 0x7FFF for ASIC version,
+ u32 DMEMSize; //define the size of boot loader
+
+
+ //--- LONG WORD 1 ----
+ u32 IMG_IMEM_SIZE; //define the size of FW in IMEM
+ u32 IMG_SRAM_SIZE; //define the size of FW in SRAM
+
+ //--- LONG WORD 2 ----
+ u32 FW_PRIV_SIZE; //define the size of DMEM variable
+ u32 Rsvd0;
+
+ //--- LONG WORD 3 ----
+ u32 Rsvd1;
+ u32 Rsvd2;
+
+ RT_8192S_FIRMWARE_PRIV FWPriv;
+
+}RT_8192S_FIRMWARE_HDR, *PRT_8192S_FIRMWARE_HDR;
+
+#define RT_8192S_FIRMWARE_HDR_SIZE 80
+
+typedef enum _FIRMWARE_8192S_STATUS{
+ FW_STATUS_INIT = 0,
+ FW_STATUS_LOAD_IMEM = 1,
+ FW_STATUS_LOAD_EMEM = 2,
+ FW_STATUS_LOAD_DMEM = 3,
+ FW_STATUS_READY = 4,
+}FIRMWARE_8192S_STATUS;
+
+#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
+
+typedef struct _rt_firmware{
+ firmware_source_e eFWSource;
+ PRT_8192S_FIRMWARE_HDR pFwHeader;
+ FIRMWARE_8192S_STATUS FWStatus;
+ u8 FwIMEM[64000];
+ u8 FwEMEM[64000];
+ u32 FwIMEMLen;
+ u32 FwEMEMLen;
+ u8 szFwTmpBuffer[164000];
+ u16 CmdPacketFragThresold;
+ //firmware_status_e firmware_status;//in 92u temp FIXLZM
+ //u16 cmdpacket_frag_thresold;//in 92u temp FIXLZM
+ //u8 firmware_buf[RTL8190_MAX_FIRMWARE_CODE_SIZE];//in 92u temp FIXLZM
+ //u16 firmware_buf_size;//in 92u temp FIXLZM
+
+}rt_firmware, *prt_firmware;
+#else
+typedef struct _rt_firmware{
+ firmware_status_e firmware_status;
+ u16 cmdpacket_frag_thresold;
+#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
+#define MAX_FW_INIT_STEP 3
+ u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE];
+ u16 firmware_buf_size[MAX_FW_INIT_STEP];
+}rt_firmware, *prt_firmware;
+#endif
+typedef struct _rt_firmware_info_819xUsb{
+ u8 sz_info[16];
+}rt_firmware_info_819xUsb, *prt_firmware_info_819xUsb;
+#endif
+
+//+by amy 080507
+#define MAX_RECEIVE_BUFFER_SIZE 9100 // Add this to 9100 bytes to receive A-MSDU from RT-AP
+
+
+/* Firmware Queue Layout */
+#define NUM_OF_FIRMWARE_QUEUE 10
+#define NUM_OF_PAGES_IN_FW 0x100
+
+#ifdef USE_ONE_PIPE
+#define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x000
+#define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x000
+#define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x0ff
+#define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x000
+#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
+#define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x0
+#define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x00
+#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
+#define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x0
+#define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x00
+#else
+
+#define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x020
+#define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x020
+#define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x040
+#define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x040
+#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
+#define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x4
+#define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x20
+#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
+#define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x4
+#define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x18
+
+#endif
+
+#define APPLIED_RESERVED_QUEUE_IN_FW 0x80000000
+#define RSVD_FW_QUEUE_PAGE_BK_SHIFT 0x00
+#define RSVD_FW_QUEUE_PAGE_BE_SHIFT 0x08
+#define RSVD_FW_QUEUE_PAGE_VI_SHIFT 0x10
+#define RSVD_FW_QUEUE_PAGE_VO_SHIFT 0x18
+#define RSVD_FW_QUEUE_PAGE_MGNT_SHIFT 0x10
+#define RSVD_FW_QUEUE_PAGE_CMD_SHIFT 0x08
+#define RSVD_FW_QUEUE_PAGE_BCN_SHIFT 0x00
+#define RSVD_FW_QUEUE_PAGE_PUB_SHIFT 0x08
+//=================================================================
+//=================================================================
+
+#define EPROM_93c46 0
+#define EPROM_93c56 1
+
+#define DEFAULT_FRAG_THRESHOLD 2342U
+#define MIN_FRAG_THRESHOLD 256U
+#define DEFAULT_BEACONINTERVAL 0x64U
+#define DEFAULT_BEACON_ESSID "Rtl819xU"
+
+#define DEFAULT_SSID ""
+#define DEFAULT_RETRY_RTS 7
+#define DEFAULT_RETRY_DATA 7
+#define PRISM_HDR_SIZE 64
+
+#define PHY_RSSI_SLID_WIN_MAX 100
+
+
+typedef enum _WIRELESS_MODE {
+ WIRELESS_MODE_UNKNOWN = 0x00,
+ WIRELESS_MODE_A = 0x01,
+ WIRELESS_MODE_B = 0x02,
+ WIRELESS_MODE_G = 0x04,
+ WIRELESS_MODE_AUTO = 0x08,
+ WIRELESS_MODE_N_24G = 0x10,
+ WIRELESS_MODE_N_5G = 0x20
+} WIRELESS_MODE;
+
+
+#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
+
+typedef struct buffer
+{
+ struct buffer *next;
+ u32 *buf;
+
+} buffer;
+
+typedef struct rtl_reg_debug{
+ unsigned int cmd;
+ struct {
+ unsigned char type;
+ unsigned char addr;
+ unsigned char page;
+ unsigned char length;
+ } head;
+ unsigned char buf[0xff];
+}rtl_reg_debug;
+
+
+
+
+
+#if 0
+
+typedef struct tx_pendingbuf
+{
+ struct ieee80211_txb *txb;
+ short ispending;
+ short descfrag;
+} tx_pendigbuf;
+
+#endif
+
+typedef struct _rt_9x_tx_rate_history {
+ u32 cck[4];
+ u32 ofdm[8];
+ // HT_MCS[0][]: BW=0 SG=0
+ // HT_MCS[1][]: BW=1 SG=0
+ // HT_MCS[2][]: BW=0 SG=1
+ // HT_MCS[3][]: BW=1 SG=1
+ u32 ht_mcs[4][16];
+}rt_tx_rahis_t, *prt_tx_rahis_t;
+typedef struct _RT_SMOOTH_DATA_4RF {
+ char elements[4][100];//array to store values
+ u32 index; //index to current array to store
+ u32 TotalNum; //num of valid elements
+ u32 TotalVal[4]; //sum of valid elements
+}RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF;
+
+#define MAX_8192U_RX_SIZE 8192 // This maybe changed for D-cut larger aggregation size
+//stats seems messed up, clean it ASAP
+typedef struct Stats
+{
+ unsigned long txrdu;
+// unsigned long rxrdu;
+ //unsigned long rxnolast;
+ //unsigned long rxnodata;
+// unsigned long rxreset;
+// unsigned long rxnopointer;
+ unsigned long rxok;
+ unsigned long rxframgment;
+ unsigned long rxcmdpkt[4]; //08/05/08 amy rx cmd element txfeedback/bcn report/cfg set/query
+ unsigned long rxurberr;
+ unsigned long rxstaterr;
+ unsigned long received_rate_histogram[4][32]; //0: Total, 1:OK, 2:CRC, 3:ICV, 2007 07 03 cosa
+ unsigned long received_preamble_GI[2][32]; //0: Long preamble/GI, 1:Short preamble/GI
+ unsigned long rx_AMPDUsize_histogram[5]; // level: (<4K), (4K~8K), (8K~16K), (16K~32K), (32K~64K)
+ unsigned long rx_AMPDUnum_histogram[5]; // level: (<5), (5~10), (10~20), (20~40), (>40)
+ unsigned long numpacket_matchbssid; // debug use only.
+ unsigned long numpacket_toself; // debug use only.
+ unsigned long num_process_phyinfo; // debug use only.
+ unsigned long numqry_phystatus;
+ unsigned long numqry_phystatusCCK;
+ unsigned long numqry_phystatusHT;
+ unsigned long received_bwtype[5]; //0: 20M, 1: funn40M, 2: upper20M, 3: lower20M, 4: duplicate
+ unsigned long txnperr;
+ unsigned long txnpdrop;
+ unsigned long txresumed;
+// unsigned long rxerr;
+// unsigned long rxoverflow;
+// unsigned long rxint;
+ unsigned long txnpokint;
+// unsigned long txhpokint;
+// unsigned long txhperr;
+// unsigned long ints;
+// unsigned long shints;
+ unsigned long txoverflow;
+// unsigned long rxdmafail;
+// unsigned long txbeacon;
+// unsigned long txbeaconerr;
+ unsigned long txlpokint;
+ unsigned long txlpdrop;
+ unsigned long txlperr;
+ unsigned long txbeokint;
+ unsigned long txbedrop;
+ unsigned long txbeerr;
+ unsigned long txbkokint;
+ unsigned long txbkdrop;
+ unsigned long txbkerr;
+ unsigned long txviokint;
+ unsigned long txvidrop;
+ unsigned long txvierr;
+ unsigned long txvookint;
+ unsigned long txvodrop;
+ unsigned long txvoerr;
+ unsigned long txbeaconokint;
+ unsigned long txbeacondrop;
+ unsigned long txbeaconerr;
+ unsigned long txmanageokint;
+ unsigned long txmanagedrop;
+ unsigned long txmanageerr;
+ unsigned long txdatapkt;
+ unsigned long txfeedback;
+ unsigned long txfeedbackok;
+
+ unsigned long txoktotal;
+ unsigned long txokbytestotal;
+ unsigned long txokinperiod;
+ unsigned long txmulticast;
+ unsigned long txbytesmulticast;
+ unsigned long txbroadcast;
+ unsigned long txbytesbroadcast;
+ unsigned long txunicast;
+ unsigned long txbytesunicast;
+
+ unsigned long rxoktotal;
+ unsigned long rxbytesunicast;
+ unsigned long txfeedbackfail;
+ unsigned long txerrtotal;
+ unsigned long txerrbytestotal;
+ unsigned long txerrmulticast;
+ unsigned long txerrbroadcast;
+ unsigned long txerrunicast;
+ unsigned long txretrycount;
+ unsigned long txfeedbackretry;
+ u8 last_packet_rate;
+ unsigned long slide_signal_strength[100];
+ unsigned long slide_evm[100];
+ unsigned long slide_rssi_total; // For recording sliding window's RSSI value
+ unsigned long slide_evm_total; // For recording sliding window's EVM value
+ long signal_strength; // Transformed, in dbm. Beautified signal strength for UI, not correct.
+ long signal_quality;
+ long last_signal_strength_inpercent;
+ long recv_signal_power; // Correct smoothed ss in Dbm, only used in driver to report real power now.
+ u8 rx_rssi_percentage[4];
+ u8 rx_evm_percentage[2];
+ long rxSNRdB[4];
+ rt_tx_rahis_t txrate;
+ u32 Slide_Beacon_pwdb[100]; //cosa add for beacon rssi
+ u32 Slide_Beacon_Total; //cosa add for beacon rssi
+ RT_SMOOTH_DATA_4RF cck_adc_pwdb;
+
+ u32 CurrentShowTxate;
+} Stats;
+
+
+// Bandwidth Offset
+#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
+#define HAL_PRIME_CHNL_OFFSET_LOWER 1
+#define HAL_PRIME_CHNL_OFFSET_UPPER 2
+
+//+by amy 080507
+
+typedef struct ChnlAccessSetting {
+ u16 SIFS_Timer;
+ u16 DIFS_Timer;
+ u16 SlotTimeTimer;
+ u16 EIFS_Timer;
+ u16 CWminIndex;
+ u16 CWmaxIndex;
+}*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING;
+
+typedef struct _BB_REGISTER_DEFINITION{
+ u32 rfintfs; // set software control: // 0x870~0x877[8 bytes]
+ u32 rfintfi; // readback data: // 0x8e0~0x8e7[8 bytes]
+ u32 rfintfo; // output data: // 0x860~0x86f [16 bytes]
+ u32 rfintfe; // output enable: // 0x860~0x86f [16 bytes]
+ u32 rf3wireOffset; // LSSI data: // 0x840~0x84f [16 bytes]
+ u32 rfLSSI_Select; // BB Band Select: // 0x878~0x87f [8 bytes]
+ u32 rfTxGainStage; // Tx gain stage: // 0x80c~0x80f [4 bytes]
+ u32 rfHSSIPara1; // wire parameter control1 : // 0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes]
+ u32 rfHSSIPara2; // wire parameter control2 : // 0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes]
+ u32 rfSwitchControl; //Tx Rx antenna control : // 0x858~0x85f [16 bytes]
+ u32 rfAGCControl1; //AGC parameter control1 : // 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes]
+ u32 rfAGCControl2; //AGC parameter control2 : // 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes]
+ u32 rfRxIQImbalance; //OFDM Rx IQ imbalance matrix : // 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes]
+ u32 rfRxAFE; //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : // 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes]
+ u32 rfTxIQImbalance; //OFDM Tx IQ imbalance matrix // 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes]
+ u32 rfTxAFE; //Tx IQ DC Offset and Tx DFIR type // 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes]
+ u32 rfLSSIReadBack; //LSSI RF readback data // 0x8a0~0x8af [16 bytes]
+ u32 rfLSSIReadBackPi; //LSSI RF readback data PI mode 0x8b8-8bc for Path A and B
+}BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T;
+
+typedef enum _RT_RF_TYPE_819xU{
+ RF_TYPE_MIN = 0,
+ RF_8225,
+ RF_8256,
+ RF_8258,
+ RF_6052=4, // 4 11b/g/n RF
+ RF_PSEUDO_11N = 5,
+}RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
+
+//#ifdef RTL8192SU
+typedef enum _RF_POWER_STATE{
+ RF_ON,
+ RF_SLEEP,
+ RF_OFF,
+ RF_SHUT_DOWN,
+}RF_POWER_STATE, *PRF_POWER_STATE;
+//#endif
+
+typedef struct _rate_adaptive
+{
+ u8 rate_adaptive_disabled;
+ u8 ratr_state;
+ u16 reserve;
+
+ u32 high_rssi_thresh_for_ra;
+ u32 high2low_rssi_thresh_for_ra;
+ u8 low2high_rssi_thresh_for_ra40M;
+ u32 low_rssi_thresh_for_ra40M;
+ u8 low2high_rssi_thresh_for_ra20M;
+ u32 low_rssi_thresh_for_ra20M;
+ u32 upper_rssi_threshold_ratr;
+ u32 middle_rssi_threshold_ratr;
+ u32 low_rssi_threshold_ratr;
+ u32 low_rssi_threshold_ratr_40M;
+ u32 low_rssi_threshold_ratr_20M;
+ u8 ping_rssi_enable; //cosa add for test
+ u32 ping_rssi_ratr; //cosa add for test
+ u32 ping_rssi_thresh_for_ra;//cosa add for test
+ u32 last_ratr;
+
+} rate_adaptive, *prate_adaptive;
+
+#define TxBBGainTableLength 37
+#define CCKTxBBGainTableLength 23
+
+typedef struct _txbbgain_struct
+{
+ long txbb_iq_amplifygain;
+ u32 txbbgain_value;
+} txbbgain_struct, *ptxbbgain_struct;
+
+typedef struct _ccktxbbgain_struct
+{
+ //The Value is from a22 to a29 one Byte one time is much Safer
+ u8 ccktxbb_valuearray[8];
+} ccktxbbgain_struct,*pccktxbbgain_struct;
+
+
+typedef struct _init_gain
+{
+ u8 xaagccore1;
+ u8 xbagccore1;
+ u8 xcagccore1;
+ u8 xdagccore1;
+ u8 cca;
+
+} init_gain, *pinit_gain;
+//by amy 0606
+
+typedef struct _phy_ofdm_rx_status_report_819xusb
+{
+ u8 trsw_gain_X[4];
+ u8 pwdb_all;
+ u8 cfosho_X[4];
+ u8 cfotail_X[4];
+ u8 rxevm_X[2];
+ u8 rxsnr_X[4];
+ u8 pdsnr_X[2];
+ u8 csi_current_X[2];
+ u8 csi_target_X[2];
+ u8 sigevm;
+ u8 max_ex_pwr;
+ u8 sgi_en;
+ u8 rxsc_sgien_exflg;
+}phy_sts_ofdm_819xusb_t;
+
+typedef struct _phy_cck_rx_status_report_819xusb
+{
+ /* For CCK rate descriptor. This is a unsigned 8:1 variable. LSB bit presend
+ 0.5. And MSB 7 bts presend a signed value. Range from -64~+63.5. */
+ u8 adc_pwdb_X[4];
+ u8 sq_rpt;
+ u8 cck_agc_rpt;
+}phy_sts_cck_819xusb_t;
+
+
+typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag{
+ u8 reserved:4;
+ u8 rxsc:2;
+ u8 sgi_en:1;
+ u8 ex_intf_flag:1;
+}phy_ofdm_rx_status_rxsc_sgien_exintfflag;
+
+typedef enum _RT_CUSTOMER_ID
+{
+ RT_CID_DEFAULT = 0,
+ RT_CID_8187_ALPHA0 = 1,
+ RT_CID_8187_SERCOMM_PS = 2,
+ RT_CID_8187_HW_LED = 3,
+ RT_CID_8187_NETGEAR = 4,
+ RT_CID_WHQL = 5,
+ RT_CID_819x_CAMEO = 6,
+ RT_CID_819x_RUNTOP = 7,
+ RT_CID_819x_Senao = 8,
+ RT_CID_TOSHIBA = 9, // Merge by Jacken, 2008/01/31.
+ RT_CID_819x_Netcore = 10,
+ RT_CID_Nettronix = 11,
+ RT_CID_DLINK = 12,
+ RT_CID_PRONET = 13,
+}RT_CUSTOMER_ID, *PRT_CUSTOMER_ID;
+
+//================================================================================
+// LED customization.
+//================================================================================
+
+typedef enum _LED_STRATEGY_8190{
+ SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option.
+ SW_LED_MODE1, // SW control for PCI Express
+ SW_LED_MODE2, // SW control for Cameo.
+ SW_LED_MODE3, // SW contorl for RunTop.
+ SW_LED_MODE4, // SW control for Netcore
+ HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes)
+}LED_STRATEGY_8190, *PLED_STRATEGY_8190;
+
+typedef enum _RESET_TYPE {
+ RESET_TYPE_NORESET = 0x00,
+ RESET_TYPE_NORMAL = 0x01,
+ RESET_TYPE_SILENT = 0x02
+} RESET_TYPE;
+
+/* The simple tx command OP code. */
+typedef enum _tag_TxCmd_Config_Index{
+ TXCMD_TXRA_HISTORY_CTRL = 0xFF900000,
+ TXCMD_RESET_TX_PKT_BUFF = 0xFF900001,
+ TXCMD_RESET_RX_PKT_BUFF = 0xFF900002,
+ TXCMD_SET_TX_DURATION = 0xFF900003,
+ TXCMD_SET_RX_RSSI = 0xFF900004,
+ TXCMD_SET_TX_PWR_TRACKING = 0xFF900005,
+ TXCMD_XXXX_CTRL,
+}DCMD_TXCMD_OP;
+
+typedef enum{
+ NIC_8192U = 1,
+ NIC_8190P = 2,
+ NIC_8192E = 3,
+ NIC_8192SE = 4,
+ NIC_8192SU = 5,
+ } nic_t;
+
+//definded by WB. Ready to fill handlers for different NIC types.
+//add handle here when necessary.
+struct rtl819x_ops{
+ nic_t nic_type;
+ void (* rtl819x_read_eeprom_info)(struct net_device *dev);
+ short (* rtl819x_tx)(struct net_device *dev, struct sk_buff* skb);
+ short (* rtl819x_tx_cmd)(struct net_device *dev, struct sk_buff *skb);
+ void (* rtl819x_rx_nomal)(struct sk_buff* skb);
+ void (* rtl819x_rx_cmd)(struct sk_buff *skb);
+ bool (* rtl819x_adapter_start)(struct net_device *dev);
+ void (* rtl819x_link_change)(struct net_device *dev);
+ void (* rtl819x_initial_gain)(struct net_device *dev,u8 Operation);
+ void (* rtl819x_query_rxdesc_status)(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe);
+};
+
+typedef struct r8192_priv
+{
+ struct rtl819x_ops* ops;
+ struct usb_device *udev;
+ //added for maintain info from eeprom
+ short epromtype;
+ u16 eeprom_vid;
+ u16 eeprom_pid;
+ u8 eeprom_CustomerID;
+ u8 eeprom_SubCustomerID;
+ u8 eeprom_ChannelPlan;
+ RT_CUSTOMER_ID CustomerID;
+ LED_STRATEGY_8190 LedStrategy;
+ u8 txqueue_to_outpipemap[9];
+ u8 RtOutPipes[16];
+ u8 RtInPipes[16];
+ u8 ep_in_num;
+ u8 ep_out_num;
+ u8 ep_num;
+ int irq;
+ struct ieee80211_device *ieee80211;
+
+ short card_8192; /* O: rtl8192, 1:rtl8185 V B/C, 2:rtl8185 V D */
+ u8 card_8192_version; /* if TCR reports card V B/C this discriminates */
+// short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
+ short enable_gpio0;
+ enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type;
+ short hw_plcp_len;
+ short plcp_preamble_mode;
+
+ spinlock_t irq_lock;
+// spinlock_t irq_th_lock;
+ spinlock_t tx_lock;
+ spinlock_t ps_lock;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
+ struct semaphore mutex;
+#else
+ struct mutex mutex;
+#endif
+ spinlock_t rf_lock; //used to lock rf write operation added by wb
+
+ u16 irq_mask;
+// short irq_enabled;
+// struct net_device *dev; //comment this out.
+ short chan;
+ short sens;
+ short max_sens;
+
+
+ // u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
+// u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
+// u8 cck_txpwr_base;
+// u8 ofdm_txpwr_base;
+// u8 challow[15]; //channels from 1 to 14, 0 not used
+ short up;
+ short crcmon; //if 1 allow bad crc frame reception in monitor mode
+// short prism_hdr;
+
+// struct timer_list scan_timer;
+ /*short scanpending;
+ short stopscan;*/
+// spinlock_t scan_lock;
+// u8 active_probe;
+ //u8 active_scan_num;
+ struct semaphore wx_sem;
+ struct semaphore rf_sem; //used to lock rf write operation added by wb, modified by david
+// short hw_wep;
+
+// short digphy;
+// short antb;
+// short diversity;
+// u8 cs_treshold;
+// short rcr_csense;
+ u8 rf_type; //0 means 1T2R, 1 means 2T4R
+ RT_RF_TYPE_819xU rf_chip;
+
+// u32 key0[4];
+ short (*rf_set_sens)(struct net_device *dev,short sens);
+ u8 (*rf_set_chan)(struct net_device *dev,u8 ch);
+ void (*rf_close)(struct net_device *dev);
+ void (*rf_init)(struct net_device *dev);
+ //short rate;
+ short promisc;
+ /*stats*/
+ struct Stats stats;
+ struct iw_statistics wstats;
+ struct proc_dir_entry *dir_dev;
+
+ /*RX stuff*/
+// u32 *rxring;
+// u32 *rxringtail;
+// dma_addr_t rxringdma;
+ struct urb **rx_urb;
+ struct urb **rx_cmd_urb;
+
+/* modified by davad for Rx process */
+ struct sk_buff_head rx_queue;
+ struct sk_buff_head skb_queue;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+ struct tq_struct qos_activate;
+#else
+ struct work_struct qos_activate;
+#endif
+ short tx_urb_index;
+ atomic_t tx_pending[0x10];//UART_PRIORITY+1
+
+
+ struct tasklet_struct irq_rx_tasklet;
+ struct urb *rxurb_task;
+
+ //2 Tx Related variables
+ u16 ShortRetryLimit;
+ u16 LongRetryLimit;
+ u32 TransmitConfig;
+ u8 RegCWinMin; // For turbo mode CW adaptive. Added by Annie, 2005-10-27.
+
+ u32 LastRxDescTSFHigh;
+ u32 LastRxDescTSFLow;
+
+
+ //2 Rx Related variables
+ u16 EarlyRxThreshold;
+ u32 ReceiveConfig;
+ u8 AcmControl;
+
+ u8 RFProgType;
+
+ u8 retry_data;
+ u8 retry_rts;
+ u16 rts;
+
+ struct ChnlAccessSetting ChannelAccessSetting;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct work_struct reset_wq;
+#else
+ struct tq_struct reset_wq;
+#endif
+
+/**********************************************************/
+ //for rtl819xUsb
+ u16 basic_rate;
+ u8 short_preamble;
+ u8 slot_time;
+ bool bDcut;
+ bool bCurrentRxAggrEnable;
+ u8 Rf_Mode; //add for Firmware RF -R/W switch
+ prt_firmware pFirmware;
+ rtl819xUsb_loopback_e LoopbackMode;
+ firmware_source_e firmware_source;
+ bool usb_error;
+
+ u16 EEPROMTxPowerDiff;
+ u8 EEPROMThermalMeter;
+ u8 EEPROMPwDiff;
+ u8 EEPROMCrystalCap;
+ u8 EEPROM_Def_Ver;
+ u8 EEPROMTxPowerLevelCCK;// CCK channel 1~14
+ u8 EEPROMTxPowerLevelCCK_V1[3];
+ u8 EEPROMTxPowerLevelOFDM24G[3]; // OFDM 2.4G channel 1~14
+ u8 EEPROMTxPowerLevelOFDM5G[24]; // OFDM 5G
+
+//RTL8192SU
+ bool bDmDisableProtect;
+ bool bIgnoreDiffRateTxPowerOffset;
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ u8 EEPROMTxPowerLevelCCK24G[14]; // CCK 2.4G channel 1~14
+ //u8 EEPROMTxPowerLevelOFDM24G[14]; // OFDM 2.4G channel 1~14
+ //u8 EEPROMTxPowerLevelOFDM5G[24]; // OFDM 5G
+#else
+ // For EEPROM TX Power Index like 8190 series
+ u8 EEPROMRfACCKChnl1TxPwLevel[3]; //RF-A CCK Tx Power Level at channel 7
+ u8 EEPROMRfAOfdmChnlTxPwLevel[3];//RF-A CCK Tx Power Level at [0],[1],[2] = channel 1,7,13
+ u8 EEPROMRfCCCKChnl1TxPwLevel[3]; //RF-C CCK Tx Power Level at channel 7
+ u8 EEPROMRfCOfdmChnlTxPwLevel[3];//RF-C CCK Tx Power Level at [0],[1],[2] = channel 1,7,13
+
+ // F92S new definition
+ //RF-A&B CCK/OFDM Tx Power Level at three channel are [1-3] [4-9] [10-14]
+ u8 RfCckChnlAreaTxPwr[2][3];
+ u8 RfOfdmChnlAreaTxPwr1T[2][3];
+ u8 RfOfdmChnlAreaTxPwr2T[2][3];
+#endif
+
+ // Add For EEPROM Efuse switch and Efuse Shadow map Setting
+ bool EepromOrEfuse;
+ bool bBootFromEfuse; // system boot form EFUSE
+ u8 EfuseMap[2][HWSET_MAX_SIZE_92S];
+
+ u8 EEPROMUsbOption;
+ u8 EEPROMUsbPhyParam[5];
+ u8 EEPROMTxPwrBase;
+ u8 EEPROMBoardType;
+ bool bBootFromEEPROM; // system boot from EEPROM
+ u8 EEPROMTSSI_A;
+ u8 EEPROMTSSI_B;
+ u8 EEPROMHT2T_TxPwr[6]; // For channel 1, 7 and 13 on path A/B.
+ u8 EEPROMTxPwrTkMode;
+
+ u8 bTXPowerDataReadFromEEPORM;
+
+ u8 EEPROMVersion;
+ u8 EEPROMUsbEndPointNumber;
+
+ bool AutoloadFailFlag;
+ u8 RfTxPwrLevelCck[2][14];
+ u8 RfTxPwrLevelOfdm1T[2][14];
+ u8 RfTxPwrLevelOfdm2T[2][14];
+ // 2009/01/20 MH Add for new EEPROM format.
+ u8 TxPwrHt20Diff[2][14]; // HT 20<->40 Pwr diff
+ u8 TxPwrLegacyHtDiff[2][14]; // For HT<->legacy pwr diff
+ u8 TxPwrbandEdgeHt40[2][2]; // Band edge for HY 40MHZlow/up channel
+ u8 TxPwrbandEdgeHt20[2][2]; // Band edge for HY 40MHZ low/up channel
+ u8 TxPwrbandEdgeLegacyOfdm[2][2]; // Band edge for legacy ofdm low/up channel
+ u8 TxPwrbandEdgeFlag; // Band edge enable flag
+
+ // L1 and L2 high power threshold.
+ u8 MidHighPwrTHR_L1;
+ u8 MidHighPwrTHR_L2;
+ u8 TxPwrSafetyFlag; // for Tx power safety spec
+//RTL8192SU
+
+/*PHY related*/
+ BB_REGISTER_DEFINITION_T PHYRegDef[4]; //Radio A/B/C/D
+ // Read/write are allow for following hardware information variables
+#ifdef RTL8192SU
+ u32 MCSTxPowerLevelOriginalOffset[7];//FIXLZM
+#else
+ u32 MCSTxPowerLevelOriginalOffset[6];
+#endif
+ u32 CCKTxPowerLevelOriginalOffset;
+ u8 TxPowerLevelCCK[14]; // CCK channel 1~14
+ u8 TxPowerLevelOFDM24G[14]; // OFDM 2.4G channel 1~14
+ u8 TxPowerLevelOFDM5G[14]; // OFDM 5G
+ u32 Pwr_Track;
+ u8 TxPowerDiff;
+ u8 AntennaTxPwDiff[2]; // Antenna gain offset, index 0 for B, 1 for C, and 2 for D
+ u8 CrystalCap; // CrystalCap.
+ u8 ThermalMeter[2]; // ThermalMeter, index 0 for RFIC0, and 1 for RFIC1
+
+ u8 CckPwEnl;
+ // Use to calculate PWBD.
+ u8 bCckHighPower;
+ long undecorated_smoothed_pwdb;
+
+ //for set channel
+ u8 SwChnlInProgress;
+ u8 SwChnlStage;
+ u8 SwChnlStep;
+ u8 SetBWModeInProgress;
+ HT_CHANNEL_WIDTH CurrentChannelBW;
+ u8 ChannelPlan;
+ u8 pwrGroupCnt;
+ // 8190 40MHz mode
+ //
+ u8 nCur40MhzPrimeSC; // Control channel sub-carrier
+ // Joseph test for shorten RF configuration time.
+ // We save RF reg0 in this variable to reduce RF reading.
+ //
+ u32 RfReg0Value[4];
+ u8 NumTotalRFPath;
+ bool brfpath_rxenable[4];
+ //RF set related
+ bool SetRFPowerStateInProgress;
+//+by amy 080507
+ struct timer_list watch_dog_timer;
+
+//+by amy 080515 for dynamic mechenism
+ //Add by amy Tx Power Control for Near/Far Range 2008/05/15
+ bool bdynamic_txpower; //bDynamicTxPower
+ bool bDynamicTxHighPower; // Tx high power state
+ bool bDynamicTxLowPower; // Tx low power state
+ bool bLastDTPFlag_High;
+ bool bLastDTPFlag_Low;
+
+ bool bstore_last_dtpflag;
+ bool bstart_txctrl_bydtp; //Define to discriminate on High power State or on sitesuvey to change Tx gain index
+ //Add by amy for Rate Adaptive
+ rate_adaptive rate_adaptive;
+ //Add by amy for TX power tracking
+ //2008/05/15 Mars OPEN/CLOSE TX POWER TRACKING
+ txbbgain_struct txbbgain_table[TxBBGainTableLength];
+ u8 EEPROMTxPowerTrackEnable;
+ u8 txpower_count;//For 6 sec do tracking again
+ bool btxpower_trackingInit;
+ u8 OFDM_index;
+ u8 CCK_index;
+ //2007/09/10 Mars Add CCK TX Power Tracking
+ ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength];
+ ccktxbbgain_struct cck_txbbgain_ch14_table[CCKTxBBGainTableLength];
+ u8 rfa_txpowertrackingindex;
+ u8 rfa_txpowertrackingindex_real;
+ u8 rfa_txpowertracking_default;
+ u8 rfc_txpowertrackingindex;
+ u8 rfc_txpowertrackingindex_real;
+
+ s8 cck_present_attentuation;
+ u8 cck_present_attentuation_20Mdefault;
+ u8 cck_present_attentuation_40Mdefault;
+ char cck_present_attentuation_difference;
+ bool btxpower_tracking;
+ bool bcck_in_ch14;
+ bool btxpowerdata_readfromEEPORM;
+ u16 TSSI_13dBm;
+ //For Backup Initial Gain
+ init_gain initgain_backup;
+ u8 DefaultInitialGain[4];
+ // For EDCA Turbo mode, Added by amy 080515.
+ bool bis_any_nonbepkts;
+ bool bcurrent_turbo_EDCA;
+ bool bis_cur_rdlstate;
+ struct timer_list fsync_timer;
+ bool bfsync_processing; // 500ms Fsync timer is active or not
+ u32 rate_record;
+ u32 rateCountDiffRecord;
+ u32 ContiuneDiffCount;
+ bool bswitch_fsync;
+
+ u8 framesync;
+ u32 framesyncC34;
+ u8 framesyncMonitor;
+ //Added by amy 080516 for RX related
+ u16 nrxAMPDU_size;
+ u8 nrxAMPDU_aggr_num;
+
+ //by amy for gpio
+ bool bHwRadioOff;
+
+ //by amy for reset_count
+ u32 reset_count;
+ bool bpbc_pressed;
+ //by amy for debug
+ u32 txpower_checkcnt;
+ u32 txpower_tracking_callback_cnt;
+ u8 thermal_read_val[40];
+ u8 thermal_readback_index;
+ u32 ccktxpower_adjustcnt_not_ch14;
+ u32 ccktxpower_adjustcnt_ch14;
+ u8 tx_fwinfo_force_subcarriermode;
+ u8 tx_fwinfo_force_subcarrierval;
+ //by amy for silent reset
+ RESET_TYPE ResetProgress;
+ bool bForcedSilentReset;
+ bool bDisableNormalResetCheck;
+ u16 TxCounter;
+ u16 RxCounter;
+ int IrpPendingCount;
+ bool bResetInProgress;
+ bool force_reset;
+ u8 InitialGainOperateType;
+
+ u16 SifsTime;
+
+ //define work item by amy 080526
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ struct delayed_work update_beacon_wq;
+ struct delayed_work watch_dog_wq;
+ struct delayed_work txpower_tracking_wq;
+ struct delayed_work rfpath_check_wq;
+ struct delayed_work gpio_change_rf_wq;
+ struct delayed_work initialgain_operate_wq;
+#else
+ struct work_struct update_beacon_wq;
+ struct work_struct watch_dog_wq;
+ struct work_struct txpower_tracking_wq;
+ struct work_struct rfpath_check_wq;
+ struct work_struct gpio_change_rf_wq;
+ struct work_struct initialgain_operate_wq;
+#endif
+ struct workqueue_struct *priv_wq;
+#else
+ /* used for periodly scan */
+ struct tq_struct update_beacon_wq;
+ struct tq_struct txpower_tracking_wq;
+ struct tq_struct rfpath_check_wq;
+ struct tq_struct watch_dog_wq;
+ struct tq_struct gpio_change_rf_wq;
+ struct tq_struct initialgain_operate_wq;
+#endif
+//#ifdef RTL8192SU
+ //lzm add for 8192S
+ u32 IntrMask;
+ // RF and BB access related synchronization flags.
+ bool bChangeBBInProgress; // BaseBand RW is still in progress.
+ bool bChangeRFInProgress; // RF RW is still in progress.
+
+ u32 CCKTxPowerAdjustCntCh14; //debug only
+ u32 CCKTxPowerAdjustCntNotCh14; //debug only
+ u32 TXPowerTrackingCallbackCnt; //debug only
+ u32 TxPowerCheckCnt; //debug only
+ u32 RFWritePageCnt[3]; //debug only
+ u32 RFReadPageCnt[3]; //debug only
+ u8 ThermalReadBackIndex; //debug only
+ u8 ThermalReadVal[40]; //debug only
+
+ // For HCT test, 2005.07.15, by rcnjko.
+ // not realize true, just define it, set it 0 default, because some func use it
+ bool bInHctTest;
+
+ // The current Tx Power Level
+ u8 CurrentCckTxPwrIdx;
+ u8 CurrentOfdm24GTxPwrIdx;
+
+ // For pass 92S common phycfg.c compiler
+ u8 TxPowerLevelCCK_A[14]; // RF-A, CCK channel 1~14
+ u8 TxPowerLevelOFDM24G_A[14]; // RF-A, OFDM 2.4G channel 1~14
+ u8 TxPowerLevelCCK_C[14]; // RF-C, CCK channel 1~14
+ u8 TxPowerLevelOFDM24G_C[14]; // RF-C, OFDM 2.4G channel 1~14
+ u8 LegacyHTTxPowerDiff; // Legacy to HT rate power diff
+ char RF_C_TxPwDiff; // Antenna gain offset, rf-c to rf-a
+
+ bool bRFSiOrPi;//0=si, 1=pi.
+ //lzm add for 8192S
+
+ bool SetFwCmdInProgress; //is set FW CMD in Progress? 92S only
+ u8 CurrentFwCmdIO;
+
+ u8 MinSpaceCfg;
+
+ u16 rf_pathmap;
+//#endif
+
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ bool bCurrentRxAggrEnable;
+ bool bForcedUsbRxAggr;
+ u32 ForcedUsbRxAggrInfo;
+ u32 LastUsbRxAggrInfoSetting;
+ u32 RegUsbRxAggrInfo;
+#endif
+
+
+
+}r8192_priv;
+
+// for rtl8187
+// now mirging to rtl8187B
+/*
+typedef enum{
+ LOW_PRIORITY = 0x02,
+ NORM_PRIORITY
+ } priority_t;
+*/
+//for rtl8187B
+typedef enum{
+ BULK_PRIORITY = 0x01,
+ //RSVD0,
+ //RSVD1,
+ LOW_PRIORITY,
+ NORM_PRIORITY,
+ VO_PRIORITY,
+ VI_PRIORITY, //0x05
+ BE_PRIORITY,
+ BK_PRIORITY,
+ RSVD2,
+ RSVD3,
+ BEACON_PRIORITY, //0x0A
+ HIGH_PRIORITY,
+ MANAGE_PRIORITY,
+ RSVD4,
+ RSVD5,
+ UART_PRIORITY //0x0F
+} priority_t;
+
+#if 0
+typedef enum{
+ NIC_8192U = 1,
+ NIC_8190P = 2,
+ NIC_8192E = 3,
+ NIC_8192SE = 4,
+ NIC_8192SU = 5,
+ } nic_t;
+#endif
+
+#if 0 //defined in Qos.h
+//typedef u32 AC_CODING;
+#define AC0_BE 0 // ACI: 0x00 // Best Effort
+#define AC1_BK 1 // ACI: 0x01 // Background
+#define AC2_VI 2 // ACI: 0x10 // Video
+#define AC3_VO 3 // ACI: 0x11 // Voice
+#define AC_MAX 4 // Max: define total number; Should not to be used as a real enum.
+
+//
+// ECWmin/ECWmax field.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
+//
+typedef union _ECW{
+ u8 charData;
+ struct
+ {
+ u8 ECWmin:4;
+ u8 ECWmax:4;
+ }f; // Field
+}ECW, *PECW;
+
+//
+// ACI/AIFSN Field.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
+//
+typedef union _ACI_AIFSN{
+ u8 charData;
+
+ struct
+ {
+ u8 AIFSN:4;
+ u8 ACM:1;
+ u8 ACI:2;
+ u8 Reserved:1;
+ }f; // Field
+}ACI_AIFSN, *PACI_AIFSN;
+
+//
+// AC Parameters Record Format.
+// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
+//
+typedef union _AC_PARAM{
+ u32 longData;
+ u8 charData[4];
+
+ struct
+ {
+ ACI_AIFSN AciAifsn;
+ ECW Ecw;
+ u16 TXOPLimit;
+ }f; // Field
+}AC_PARAM, *PAC_PARAM;
+
+#endif
+#ifdef JOHN_HWSEC
+struct ssid_thread {
+ struct net_device *dev;
+ u8 name[IW_ESSID_MAX_SIZE + 1];
+};
+#endif
+
+#ifdef RTL8192SU
+short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
+short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb);
+bool FirmwareDownload92S(struct net_device *dev);
+#else
+short rtl8192_tx(struct net_device *dev, struct sk_buff* skb);
+bool init_firmware(struct net_device *dev);
+#endif
+
+short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
+short rtl8192_tx(struct net_device *dev, struct sk_buff* skb);
+
+u32 read_cam(struct net_device *dev, u8 addr);
+void write_cam(struct net_device *dev, u8 addr, u32 data);
+
+u8 read_nic_byte(struct net_device *dev, int x);
+u8 read_nic_byte_E(struct net_device *dev, int x);
+u32 read_nic_dword(struct net_device *dev, int x);
+u16 read_nic_word(struct net_device *dev, int x) ;
+void write_nic_byte(struct net_device *dev, int x,u8 y);
+void write_nic_byte_E(struct net_device *dev, int x,u8 y);
+void write_nic_word(struct net_device *dev, int x,u16 y);
+void write_nic_dword(struct net_device *dev, int x,u32 y);
+void force_pci_posting(struct net_device *dev);
+
+void rtl8192_rtx_disable(struct net_device *);
+void rtl8192_rx_enable(struct net_device *);
+void rtl8192_tx_enable(struct net_device *);
+
+void rtl8192_disassociate(struct net_device *dev);
+//void fix_rx_fifo(struct net_device *dev);
+void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a);
+
+void rtl8192_set_anaparam(struct net_device *dev,u32 a);
+void rtl8185_set_anaparam2(struct net_device *dev,u32 a);
+void rtl8192_update_msr(struct net_device *dev);
+int rtl8192_down(struct net_device *dev);
+int rtl8192_up(struct net_device *dev);
+void rtl8192_commit(struct net_device *dev);
+void rtl8192_set_chan(struct net_device *dev,short ch);
+void write_phy(struct net_device *dev, u8 adr, u8 data);
+void write_phy_cck(struct net_device *dev, u8 adr, u32 data);
+void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data);
+void rtl8185_tx_antenna(struct net_device *dev, u8 ant);
+void rtl8192_set_rxconf(struct net_device *dev);
+//short check_nic_enough_desc(struct net_device *dev, priority_t priority);
+extern void rtl819xusb_beacon_tx(struct net_device *dev,u16 tx_rate);
+void CamResetAllEntry(struct net_device* dev);
+void EnableHWSecurityConfig8192(struct net_device *dev);
+void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent );
+short rtl8192_is_tx_queue_empty(struct net_device *dev);
+
+#endif
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
new file mode 100644
index 000000000000..f1423d714496
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_core.c
@@ -0,0 +1,12460 @@
+/******************************************************************************
+ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192U
+ *
+ * Based on the r8187 driver, which is:
+ * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ * Jerry chuang <wlanfae@realtek.com>
+ */
+
+#ifndef CONFIG_FORCE_HARD_FLOAT
+double __floatsidf (int i) { return i; }
+unsigned int __fixunsdfsi (double d) { return d; }
+double __adddf3(double a, double b) { return a+b; }
+double __addsf3(float a, float b) { return a+b; }
+double __subdf3(double a, double b) { return a-b; }
+double __extendsfdf2(float a) {return a;}
+#endif
+
+#undef LOOP_TEST
+#undef DUMP_RX
+#undef DUMP_TX
+#undef DEBUG_TX_DESC2
+#undef RX_DONT_PASS_UL
+#undef DEBUG_EPROM
+#undef DEBUG_RX_VERBOSE
+#undef DUMMY_RX
+#undef DEBUG_ZERO_RX
+#undef DEBUG_RX_SKB
+#undef DEBUG_TX_FRAG
+#undef DEBUG_RX_FRAG
+#undef DEBUG_TX_FILLDESC
+#undef DEBUG_TX
+#undef DEBUG_IRQ
+#undef DEBUG_RX
+#undef DEBUG_RXALLOC
+#undef DEBUG_REGISTERS
+#undef DEBUG_RING
+#undef DEBUG_IRQ_TASKLET
+#undef DEBUG_TX_ALLOC
+#undef DEBUG_TX_DESC
+
+#define CONFIG_RTL8192_IO_MAP
+
+#ifdef RTL8192SU
+#include <asm/uaccess.h>
+#include "r8192U.h"
+//#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */
+#include "r8180_93cx6.h" /* Card EEPROM */
+#include "r8192U_wx.h"
+
+#include "r8192S_rtl8225.h"
+#include "r8192S_hw.h"
+#include "r8192S_phy.h"
+#include "r8192S_phyreg.h"
+#include "r8192S_Efuse.h"
+
+#include "r819xU_cmdpkt.h"
+#include "r8192U_dm.h"
+//#include "r8192xU_phyreg.h"
+#include <linux/usb.h>
+// FIXME: check if 2.6.7 is ok
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
+#define usb_kill_urb usb_unlink_urb
+#endif
+
+#ifdef CONFIG_RTL8192_PM
+#include "r8192U_pm.h"
+#endif
+
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+
+#else
+
+#include <asm/uaccess.h>
+#include "r8192U_hw.h"
+#include "r8192U.h"
+#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */
+#include "r8180_93cx6.h" /* Card EEPROM */
+#include "r8192U_wx.h"
+#include "r819xU_phy.h" //added by WB 4.30.2008
+#include "r819xU_phyreg.h"
+#include "r819xU_cmdpkt.h"
+#include "r8192U_dm.h"
+//#include "r8192xU_phyreg.h"
+#include <linux/usb.h>
+// FIXME: check if 2.6.7 is ok
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
+#define usb_kill_urb usb_unlink_urb
+#endif
+
+#ifdef CONFIG_RTL8192_PM
+#include "r8192U_pm.h"
+#endif
+
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+
+#endif
+
+
+#ifdef RTL8192SU
+u32 rt_global_debug_component = \
+// COMP_TRACE |
+// COMP_DBG |
+// COMP_INIT |
+// COMP_RECV |
+// COMP_SEND |
+// COMP_IO |
+ COMP_POWER |
+// COMP_EPROM |
+ COMP_SWBW |
+ COMP_POWER_TRACKING |
+ COMP_TURBO |
+ COMP_QOS |
+// COMP_RATE |
+// COMP_RM |
+ COMP_DIG |
+// COMP_EFUSE |
+// COMP_CH |
+// COMP_TXAGC |
+ COMP_HIPWR |
+// COMP_HALDM |
+ COMP_SEC |
+ COMP_LED |
+// COMP_RF |
+// COMP_RXDESC |
+ COMP_FIRMWARE |
+ COMP_HT |
+ COMP_AMSDU |
+ COMP_SCAN |
+// COMP_CMD |
+ COMP_DOWN |
+ COMP_RESET |
+ COMP_ERR; //always open err flags on
+#else
+//set here to open your trace code. //WB
+u32 rt_global_debug_component = \
+ // COMP_INIT |
+// COMP_DBG |
+ // COMP_EPROM |
+// COMP_PHY |
+ // COMP_RF |
+// COMP_FIRMWARE |
+// COMP_CH |
+ // COMP_POWER_TRACKING |
+// COMP_RATE |
+ // COMP_TXAGC |
+ // COMP_TRACE |
+ COMP_DOWN |
+ // COMP_RECV |
+ // COMP_SWBW |
+ COMP_SEC |
+ // COMP_RESET |
+ // COMP_SEND |
+ // COMP_EVENTS |
+ COMP_ERR ; //always open err flags on
+#endif
+
+#define TOTAL_CAM_ENTRY 32
+#define CAM_CONTENT_COUNT 8
+
+static struct usb_device_id rtl8192_usb_id_tbl[] = {
+ /* Realtek */
+ {USB_DEVICE(0x0bda, 0x8192)},
+ {USB_DEVICE(0x0bda, 0x8709)},
+ /* Corega */
+ {USB_DEVICE(0x07aa, 0x0043)},
+ /* Belkin */
+ {USB_DEVICE(0x050d, 0x805E)},
+ /* Sitecom */
+ {USB_DEVICE(0x0df6, 0x0031)},
+ /* EnGenius */
+ {USB_DEVICE(0x1740, 0x9201)},
+ /* Dlink */
+ {USB_DEVICE(0x2001, 0x3301)},
+ /* Zinwell */
+ {USB_DEVICE(0x5a57, 0x0290)},
+ //92SU
+ {USB_DEVICE(0x0bda, 0x8172)},
+ {}
+};
+
+MODULE_LICENSE("GPL");
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+MODULE_VERSION("V 1.1");
+#endif
+MODULE_DEVICE_TABLE(usb, rtl8192_usb_id_tbl);
+MODULE_DESCRIPTION("Linux driver for Realtek RTL8192 USB WiFi cards");
+
+static char* ifname = "wlan%d";
+#if 0
+static int hwseqnum = 0;
+static int hwwep = 0;
+#endif
+static int hwwep = 1; //default use hw. set 0 to use software security
+static int channels = 0x3fff;
+
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)
+module_param(ifname, charp, S_IRUGO|S_IWUSR );
+//module_param(hwseqnum,int, S_IRUGO|S_IWUSR);
+module_param(hwwep,int, S_IRUGO|S_IWUSR);
+module_param(channels,int, S_IRUGO|S_IWUSR);
+#else
+MODULE_PARM(ifname, "s");
+//MODULE_PARM(hwseqnum,"i");
+MODULE_PARM(hwwep,"i");
+MODULE_PARM(channels,"i");
+#endif
+
+MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default");
+//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
+MODULE_PARM_DESC(hwwep," Try to use hardware security support. ");
+MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
+ const struct usb_device_id *id);
+static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf);
+#else
+static void *__devinit rtl8192_usb_probe(struct usb_device *udev,unsigned int ifnum,
+ const struct usb_device_id *id);
+static void __devexit rtl8192_usb_disconnect(struct usb_device *udev, void *ptr);
+#endif
+
+
+static struct usb_driver rtl8192_usb_driver = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
+ .owner = THIS_MODULE,
+#endif
+ .name = RTL819xU_MODULE_NAME, /* Driver name */
+ .id_table = rtl8192_usb_id_tbl, /* PCI_ID table */
+ .probe = rtl8192_usb_probe, /* probe fn */
+ .disconnect = rtl8192_usb_disconnect, /* remove fn */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
+#ifdef CONFIG_RTL8192_PM
+ .suspend = rtl8192U_suspend, /* PM suspend fn */
+ .resume = rtl8192U_resume, /* PM resume fn */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
+ .reset_resume = rtl8192U_resume, /* PM reset resume fn */
+#endif
+#else
+ .suspend = NULL, /* PM suspend fn */
+ .resume = NULL, /* PM resume fn */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
+ .reset_resume = NULL, /* PM reset resume fn */
+#endif
+#endif
+#endif
+};
+
+
+#ifdef RTL8192SU
+static void rtl8192SU_read_eeprom_info(struct net_device *dev);
+short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb);
+void rtl8192SU_rx_nomal(struct sk_buff* skb);
+void rtl8192SU_rx_cmd(struct sk_buff *skb);
+bool rtl8192SU_adapter_start(struct net_device *dev);
+short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
+void rtl8192SU_link_change(struct net_device *dev);
+void InitialGain8192S(struct net_device *dev,u8 Operation);
+void rtl8192SU_query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe);
+
+struct rtl819x_ops rtl8192su_ops = {
+ .nic_type = NIC_8192SU,
+ .rtl819x_read_eeprom_info = rtl8192SU_read_eeprom_info,
+ .rtl819x_tx = rtl8192SU_tx,
+ .rtl819x_tx_cmd = rtl8192SU_tx_cmd,
+ .rtl819x_rx_nomal = rtl8192SU_rx_nomal,
+ .rtl819x_rx_cmd = rtl8192SU_rx_cmd,
+ .rtl819x_adapter_start = rtl8192SU_adapter_start,
+ .rtl819x_link_change = rtl8192SU_link_change,
+ .rtl819x_initial_gain = InitialGain8192S,
+ .rtl819x_query_rxdesc_status = rtl8192SU_query_rxdesc_status,
+};
+#else
+static void rtl8192_read_eeprom_info(struct net_device *dev);
+short rtl8192_tx(struct net_device *dev, struct sk_buff* skb);
+void rtl8192_rx_nomal(struct sk_buff* skb);
+void rtl8192_rx_cmd(struct sk_buff *skb);
+bool rtl8192_adapter_start(struct net_device *dev);
+short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
+void rtl8192_link_change(struct net_device *dev);
+void InitialGain819xUsb(struct net_device *dev,u8 Operation);
+void query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe);
+
+struct rtl819x_ops rtl8192u_ops = {
+ .nic_type = NIC_8192U,
+ .rtl819x_read_eeprom_info = rtl8192_read_eeprom_info,
+ .rtl819x_tx = rtl8192_tx,
+ .rtl819x_tx_cmd = rtl819xU_tx_cmd,
+ .rtl819x_rx_nomal = rtl8192_rx_nomal,
+ .rtl819x_rx_cmd = rtl8192_rx_cmd,
+ .rtl819x_adapter_start = rtl8192_adapter_start,
+ .rtl819x_link_change = rtl8192_link_change,
+ .rtl819x_initial_gain = InitialGain819xUsb,
+ .rtl819x_query_rxdesc_status = query_rxdesc_status,
+};
+#endif
+
+#ifdef ENABLE_DOT11D
+
+typedef struct _CHANNEL_LIST
+{
+ u8 Channel[32];
+ u8 Len;
+}CHANNEL_LIST, *PCHANNEL_LIST;
+
+static CHANNEL_LIST ChannelPlan[] = {
+ {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC
+ {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI.
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI.
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel.
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC
+ {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626
+};
+
+static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
+{
+ int i, max_chan=-1, min_chan=-1;
+ struct ieee80211_device* ieee = priv->ieee80211;
+ switch (channel_plan)
+ {
+ case COUNTRY_CODE_FCC:
+ case COUNTRY_CODE_IC:
+ case COUNTRY_CODE_ETSI:
+ case COUNTRY_CODE_SPAIN:
+ case COUNTRY_CODE_FRANCE:
+ case COUNTRY_CODE_MKK:
+ case COUNTRY_CODE_MKK1:
+ case COUNTRY_CODE_ISRAEL:
+ case COUNTRY_CODE_TELEC:
+ case COUNTRY_CODE_MIC:
+ {
+ Dot11d_Init(ieee);
+ ieee->bGlobalDomain = false;
+ //acturally 8225 & 8256 rf chip only support B,G,24N mode
+ if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256) || (priv->rf_chip == RF_6052))
+ {
+ min_chan = 1;
+ max_chan = 14;
+ }
+ else
+ {
+ RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __FUNCTION__);
+ }
+ if (ChannelPlan[channel_plan].Len != 0){
+ // Clear old channel map
+ memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map));
+ // Set new channel map
+ for (i=0;i<ChannelPlan[channel_plan].Len;i++)
+ {
+ if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
+ break;
+ GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
+ }
+ }
+ break;
+ }
+ case COUNTRY_CODE_GLOBAL_DOMAIN:
+ {
+ GET_DOT11D_INFO(ieee)->bEnabled = 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings.
+ Dot11d_Reset(ieee);
+ ieee->bGlobalDomain = true;
+ break;
+ }
+ default:
+ break;
+ }
+ return;
+}
+#endif
+
+#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
+
+#ifdef RTL8192SU
+#define rx_hal_is_cck_rate(_pDesc)\
+ ((_pDesc->RxMCS == DESC92S_RATE1M ||\
+ _pDesc->RxMCS == DESC92S_RATE2M ||\
+ _pDesc->RxMCS == DESC92S_RATE5_5M ||\
+ _pDesc->RxMCS == DESC92S_RATE11M) &&\
+ !_pDesc->RxHT)
+
+#define tx_hal_is_cck_rate(_DataRate)\
+ ( _DataRate == MGN_1M ||\
+ _DataRate == MGN_2M ||\
+ _DataRate == MGN_5_5M ||\
+ _DataRate == MGN_11M )
+
+#else
+#define rx_hal_is_cck_rate(_pdrvinfo)\
+ ((_pdrvinfo->RxRate == DESC90_RATE1M ||\
+ _pdrvinfo->RxRate == DESC90_RATE2M ||\
+ _pdrvinfo->RxRate == DESC90_RATE5_5M ||\
+ _pdrvinfo->RxRate == DESC90_RATE11M) &&\
+ !_pdrvinfo->RxHT)
+#endif
+
+
+
+void CamResetAllEntry(struct net_device *dev)
+{
+#if 1
+ u32 ulcommand = 0;
+ //2004/02/11 In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA associate to AP.
+ // However, ResetKey is called on OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest
+ // In this condition, Cam can not be reset because upper layer will not set this static key again.
+ //if(Adapter->EncAlgorithm == WEP_Encryption)
+ // return;
+//debug
+ //DbgPrint("========================================\n");
+ //DbgPrint(" Call ResetAllEntry \n");
+ //DbgPrint("========================================\n\n");
+ ulcommand |= BIT31|BIT30;
+ write_nic_dword(dev, RWCAM, ulcommand);
+#else
+ for(ucIndex=0;ucIndex<TOTAL_CAM_ENTRY;ucIndex++)
+ CAM_mark_invalid(dev, ucIndex);
+ for(ucIndex=0;ucIndex<TOTAL_CAM_ENTRY;ucIndex++)
+ CAM_empty_entry(dev, ucIndex);
+#endif
+
+}
+
+
+void write_cam(struct net_device *dev, u8 addr, u32 data)
+{
+ write_nic_dword(dev, WCAMI, data);
+ write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff) );
+}
+
+u32 read_cam(struct net_device *dev, u8 addr)
+{
+ write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff) );
+ return read_nic_dword(dev, 0xa8);
+}
+
+void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
+{
+ int status;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
+ indx|0xfe00, 0, &data, 1, HZ / 2);
+
+ if (status < 0)
+ {
+ printk("write_nic_byte_E TimeOut! status:%d\n", status);
+ }
+}
+
+u8 read_nic_byte_E(struct net_device *dev, int indx)
+{
+ int status;
+ u8 data;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
+ indx|0xfe00, 0, &data, 1, HZ / 2);
+
+ if (status < 0)
+ {
+ printk("read_nic_byte_E TimeOut! status:%d\n", status);
+ }
+
+ return data;
+}
+//as 92U has extend page from 4 to 16, so modify functions below.
+void write_nic_byte(struct net_device *dev, int indx, u8 data)
+{
+ int status;
+
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
+#ifdef RTL8192SU
+ indx, 0, &data, 1, HZ / 2);
+#else
+ (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 1, HZ / 2);
+#endif
+
+ if (status < 0)
+ {
+ printk("write_nic_byte TimeOut! status:%d\n", status);
+ }
+
+
+}
+
+
+void write_nic_word(struct net_device *dev, int indx, u16 data)
+{
+
+ int status;
+
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
+#ifdef RTL8192SU
+ indx, 0, &data, 2, HZ / 2);
+#else
+ (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 2, HZ / 2);
+#endif
+
+ if (status < 0)
+ {
+ printk("write_nic_word TimeOut! status:%d\n", status);
+ }
+
+}
+
+
+void write_nic_dword(struct net_device *dev, int indx, u32 data)
+{
+
+ int status;
+
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
+#ifdef RTL8192SU
+ indx, 0, &data, 4, HZ / 2);
+#else
+ (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 4, HZ / 2);
+#endif
+
+
+ if (status < 0)
+ {
+ printk("write_nic_dword TimeOut! status:%d\n", status);
+ }
+
+}
+
+
+
+u8 read_nic_byte(struct net_device *dev, int indx)
+{
+ u8 data;
+ int status;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
+#ifdef RTL8192SU
+ indx, 0, &data, 1, HZ / 2);
+#else
+ (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 1, HZ / 2);
+#endif
+
+ if (status < 0)
+ {
+ printk("read_nic_byte TimeOut! status:%d\n", status);
+ }
+
+ return data;
+}
+
+
+
+u16 read_nic_word(struct net_device *dev, int indx)
+{
+ u16 data;
+ int status;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
+#ifdef RTL8192SU
+ indx, 0, &data, 2, HZ / 2);
+#else
+ (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 2, HZ / 2);
+#endif
+
+ if (status < 0)
+ {
+ printk("read_nic_word TimeOut! status:%d\n", status);
+ }
+
+
+ return data;
+}
+
+u16 read_nic_word_E(struct net_device *dev, int indx)
+{
+ u16 data;
+ int status;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
+ indx|0xfe00, 0, &data, 2, HZ / 2);
+
+ if (status < 0)
+ {
+ printk("read_nic_word TimeOut! status:%d\n", status);
+ }
+
+
+ return data;
+}
+
+u32 read_nic_dword(struct net_device *dev, int indx)
+{
+ u32 data;
+ int status;
+// int result;
+
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct usb_device *udev = priv->udev;
+
+ status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
+#ifdef RTL8192SU
+ indx, 0, &data, 4, HZ / 2);
+#else
+ (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 4, HZ / 2);
+#endif
+// if(0 != result) {
+// printk(KERN_WARNING "read size of data = %d\, date = %d\n", result, data);
+// }
+
+ if (status < 0)
+ {
+ printk("read_nic_dword TimeOut! status:%d\n", status);
+ if(status == -ENODEV) {
+ priv->usb_error = true;
+ }
+ }
+
+
+
+ return data;
+}
+
+
+//u8 read_phy_cck(struct net_device *dev, u8 adr);
+//u8 read_phy_ofdm(struct net_device *dev, u8 adr);
+/* this might still called in what was the PHY rtl8185/rtl8192 common code
+ * plans are to possibilty turn it again in one common code...
+ */
+inline void force_pci_posting(struct net_device *dev)
+{
+}
+
+
+static struct net_device_stats *rtl8192_stats(struct net_device *dev);
+void rtl8192_commit(struct net_device *dev);
+//void rtl8192_restart(struct net_device *dev);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void rtl8192_restart(struct work_struct *work);
+//void rtl8192_rq_tx_ack(struct work_struct *work);
+#else
+ void rtl8192_restart(struct net_device *dev);
+// //void rtl8192_rq_tx_ack(struct net_device *dev);
+ #endif
+
+void watch_dog_timer_callback(unsigned long data);
+
+/****************************************************************************
+ -----------------------------PROCFS STUFF-------------------------
+*****************************************************************************/
+
+static struct proc_dir_entry *rtl8192_proc = NULL;
+
+
+
+static int proc_get_stats_ap(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct ieee80211_device *ieee = priv->ieee80211;
+ struct ieee80211_network *target;
+
+ int len = 0;
+
+ list_for_each_entry(target, &ieee->network_list, list) {
+
+ len += snprintf(page + len, count - len,
+ "%s ", target->ssid);
+
+ if(target->wpa_ie_len>0 || target->rsn_ie_len>0){
+ len += snprintf(page + len, count - len,
+ "WPA\n");
+ }
+ else{
+ len += snprintf(page + len, count - len,
+ "non_WPA\n");
+ }
+
+ }
+
+ *eof = 1;
+ return len;
+}
+
+#ifdef RTL8192SU
+static int proc_get_registers(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0,page1,page2;
+
+ int max=0xff;
+ page0 = 0x000;
+ page1 = 0x100;
+ page2 = 0x800;
+
+ /* This dump the current register page */
+ if(!IS_BB_REG_OFFSET_92S(page0)){
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2.2x ",read_nic_byte(dev,(page0|n)));
+ }
+ }else{
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+
+}
+static int proc_get_registers_1(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0x100;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2.2x ",read_nic_byte(dev,(page0|n)));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+
+}
+static int proc_get_registers_2(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0x200;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2.2x ",read_nic_byte(dev,(page0|n)));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+
+}
+static int proc_get_registers_8(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0x800;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+
+ }
+static int proc_get_registers_9(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0x900;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+}
+static int proc_get_registers_a(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0xa00;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+}
+static int proc_get_registers_b(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0xb00;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+ }
+static int proc_get_registers_c(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0xc00;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+}
+static int proc_get_registers_d(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0xd00;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+}
+static int proc_get_registers_e(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n,page0;
+
+ int max=0xff;
+ page0 = 0xe00;
+
+ /* This dump the current register page */
+ len += snprintf(page + len, count - len,
+ "\n####################page %x##################\n ", (page0>>8));
+ for(n=0;n<=max;)
+ {
+ len += snprintf(page + len, count - len, "\nD: %2x > ",n);
+ for(i=0;i<4 && n<=max;n+=4,i++)
+ len += snprintf(page + len, count - len,
+ "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
+ }
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+}
+#else
+static int proc_get_registers(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n;
+
+ int max=0xff;
+
+ /* This dump the current register page */
+len += snprintf(page + len, count - len,
+ "\n####################page 0##################\n ");
+
+ for(n=0;n<=max;)
+ {
+ //printk( "\nD: %2x> ", n);
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2x ",read_nic_byte(dev,0x000|n));
+
+ // printk("%2x ",read_nic_byte(dev,n));
+ }
+#if 1
+len += snprintf(page + len, count - len,
+ "\n####################page 1##################\n ");
+ for(n=0;n<=max;)
+ {
+ //printk( "\nD: %2x> ", n);
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2x ",read_nic_byte(dev,0x100|n));
+
+ // printk("%2x ",read_nic_byte(dev,n));
+ }
+len += snprintf(page + len, count - len,
+ "\n####################page 3##################\n ");
+ for(n=0;n<=max;)
+ {
+ //printk( "\nD: %2x> ", n);
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2x ",read_nic_byte(dev,0x300|n));
+
+ // printk("%2x ",read_nic_byte(dev,n));
+ }
+
+#endif
+
+ len += snprintf(page + len, count - len,"\n");
+ *eof = 1;
+ return len;
+
+}
+#endif
+
+#if 0
+static int proc_get_cck_reg(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n;
+
+ int max = 0x5F;
+
+ /* This dump the current register page */
+ for(n=0;n<=max;)
+ {
+ //printk( "\nD: %2x> ", n);
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2x ",read_phy_cck(dev,n));
+
+ // printk("%2x ",read_nic_byte(dev,n));
+ }
+ len += snprintf(page + len, count - len,"\n");
+
+
+ *eof = 1;
+ return len;
+}
+
+#endif
+
+#if 0
+static int proc_get_ofdm_reg(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+ int i,n;
+
+ //int max=0xff;
+ int max = 0x40;
+
+ /* This dump the current register page */
+ for(n=0;n<=max;)
+ {
+ //printk( "\nD: %2x> ", n);
+ len += snprintf(page + len, count - len,
+ "\nD: %2x > ",n);
+
+ for(i=0;i<16 && n<=max;i++,n++)
+ len += snprintf(page + len, count - len,
+ "%2x ",read_phy_ofdm(dev,n));
+
+ // printk("%2x ",read_nic_byte(dev,n));
+ }
+ len += snprintf(page + len, count - len,"\n");
+
+
+
+ *eof = 1;
+ return len;
+}
+
+#endif
+
+#if 0
+static int proc_get_stats_hw(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+
+ len += snprintf(page + len, count - len,
+ "NIC int: %lu\n"
+ "Total int: %lu\n",
+ priv->stats.ints,
+ priv->stats.shints);
+
+ *eof = 1;
+ return len;
+}
+#endif
+
+static int proc_get_stats_tx(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+
+ len += snprintf(page + len, count - len,
+ "TX VI priority ok int: %lu\n"
+ "TX VI priority error int: %lu\n"
+ "TX VO priority ok int: %lu\n"
+ "TX VO priority error int: %lu\n"
+ "TX BE priority ok int: %lu\n"
+ "TX BE priority error int: %lu\n"
+ "TX BK priority ok int: %lu\n"
+ "TX BK priority error int: %lu\n"
+ "TX MANAGE priority ok int: %lu\n"
+ "TX MANAGE priority error int: %lu\n"
+ "TX BEACON priority ok int: %lu\n"
+ "TX BEACON priority error int: %lu\n"
+// "TX high priority ok int: %lu\n"
+// "TX high priority failed error int: %lu\n"
+ "TX queue resume: %lu\n"
+ "TX queue stopped?: %d\n"
+ "TX fifo overflow: %lu\n"
+// "TX beacon: %lu\n"
+ "TX VI queue: %d\n"
+ "TX VO queue: %d\n"
+ "TX BE queue: %d\n"
+ "TX BK queue: %d\n"
+// "TX HW queue: %d\n"
+ "TX VI dropped: %lu\n"
+ "TX VO dropped: %lu\n"
+ "TX BE dropped: %lu\n"
+ "TX BK dropped: %lu\n"
+ "TX total data packets %lu\n",
+// "TX beacon aborted: %lu\n",
+ priv->stats.txviokint,
+ priv->stats.txvierr,
+ priv->stats.txvookint,
+ priv->stats.txvoerr,
+ priv->stats.txbeokint,
+ priv->stats.txbeerr,
+ priv->stats.txbkokint,
+ priv->stats.txbkerr,
+ priv->stats.txmanageokint,
+ priv->stats.txmanageerr,
+ priv->stats.txbeaconokint,
+ priv->stats.txbeaconerr,
+// priv->stats.txhpokint,
+// priv->stats.txhperr,
+ priv->stats.txresumed,
+ netif_queue_stopped(dev),
+ priv->stats.txoverflow,
+// priv->stats.txbeacon,
+ atomic_read(&(priv->tx_pending[VI_PRIORITY])),
+ atomic_read(&(priv->tx_pending[VO_PRIORITY])),
+ atomic_read(&(priv->tx_pending[BE_PRIORITY])),
+ atomic_read(&(priv->tx_pending[BK_PRIORITY])),
+// read_nic_byte(dev, TXFIFOCOUNT),
+ priv->stats.txvidrop,
+ priv->stats.txvodrop,
+ priv->stats.txbedrop,
+ priv->stats.txbkdrop,
+ priv->stats.txdatapkt
+// priv->stats.txbeaconerr
+ );
+
+ *eof = 1;
+ return len;
+}
+
+
+
+static int proc_get_stats_rx(char *page, char **start,
+ off_t offset, int count,
+ int *eof, void *data)
+{
+ struct net_device *dev = data;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ int len = 0;
+
+ len += snprintf(page + len, count - len,
+ "RX packets: %lu\n"
+ "RX urb status error: %lu\n"
+ "RX invalid urb error: %lu\n",
+ priv->stats.rxoktotal,
+ priv->stats.rxstaterr,
+ priv->stats.rxurberr);
+
+ *eof = 1;
+ return len;
+}
+#if 0
+#if WIRELESS_EXT >= 12 && WIRELESS_EXT < 17
+
+static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ return &priv->wstats;
+}
+#endif
+#endif
+void rtl8192_proc_module_init(void)
+{
+ RT_TRACE(COMP_INIT, "Initializing proc filesystem");
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ rtl8192_proc=create_proc_entry(RTL819xU_MODULE_NAME, S_IFDIR, proc_net);
+#else
+ rtl8192_proc=create_proc_entry(RTL819xU_MODULE_NAME, S_IFDIR, init_net.proc_net);
+#endif
+}
+
+
+void rtl8192_proc_module_remove(void)
+{
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
+ remove_proc_entry(RTL819xU_MODULE_NAME, proc_net);
+#else
+ remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net);
+#endif
+}
+
+
+void rtl8192_proc_remove_one(struct net_device *dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+
+ if (priv->dir_dev) {
+ // remove_proc_entry("stats-hw", priv->dir_dev);
+ remove_proc_entry("stats-tx", priv->dir_dev);
+ remove_proc_entry("stats-rx", priv->dir_dev);
+ // remove_proc_entry("stats-ieee", priv->dir_dev);
+ remove_proc_entry("stats-ap", priv->dir_dev);
+ remove_proc_entry("registers", priv->dir_dev);
+ remove_proc_entry("registers-1", priv->dir_dev);
+ remove_proc_entry("registers-2", priv->dir_dev);
+ remove_proc_entry("registers-8", priv->dir_dev);
+ remove_proc_entry("registers-9", priv->dir_dev);
+ remove_proc_entry("registers-a", priv->dir_dev);
+ remove_proc_entry("registers-b", priv->dir_dev);
+ remove_proc_entry("registers-c", priv->dir_dev);
+ remove_proc_entry("registers-d", priv->dir_dev);
+ remove_proc_entry("registers-e", priv->dir_dev);
+ // remove_proc_entry("cck-registers",priv->dir_dev);
+ // remove_proc_entry("ofdm-registers",priv->dir_dev);
+ //remove_proc_entry(dev->name, rtl8192_proc);
+ remove_proc_entry("wlan0", rtl8192_proc);
+ priv->dir_dev = NULL;
+ }
+}
+
+
+void rtl8192_proc_init_one(struct net_device *dev)
+{
+ struct proc_dir_entry *e;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ priv->dir_dev = create_proc_entry(dev->name,
+ S_IFDIR | S_IRUGO | S_IXUGO,
+ rtl8192_proc);
+ if (!priv->dir_dev) {
+ RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
+ dev->name);
+ return;
+ }
+ #if 0
+ e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_stats_hw, dev);
+
+ if (!e) {
+ DMESGE("Unable to initialize "
+ "/proc/net/rtl8192/%s/stats-hw\n",
+ dev->name);
+ }
+ #endif
+ e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_stats_rx, dev);
+
+ if (!e) {
+ RT_TRACE(COMP_ERR,"Unable to initialize "
+ "/proc/net/rtl8192/%s/stats-rx\n",
+ dev->name);
+ }
+
+
+ e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_stats_tx, dev);
+
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/stats-tx\n",
+ dev->name);
+ }
+ #if 0
+ e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_stats_ieee, dev);
+
+ if (!e) {
+ DMESGE("Unable to initialize "
+ "/proc/net/rtl8192/%s/stats-ieee\n",
+ dev->name);
+ }
+
+ #endif
+
+ e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_stats_ap, dev);
+
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/stats-ap\n",
+ dev->name);
+ }
+
+ e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers\n",
+ dev->name);
+ }
+#ifdef RTL8192SU
+ e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_1, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-1\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_2, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-2\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_8, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-8\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_9, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-9\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_a, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-a\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_b, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-b\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_c, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-c\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_d, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-d\n",
+ dev->name);
+ }
+ e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_registers_e, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/registers-e\n",
+ dev->name);
+ }
+#endif
+#if 0
+ e = create_proc_read_entry("cck-registers", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_cck_reg, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/cck-registers\n",
+ dev->name);
+ }
+
+ e = create_proc_read_entry("ofdm-registers", S_IFREG | S_IRUGO,
+ priv->dir_dev, proc_get_ofdm_reg, dev);
+ if (!e) {
+ RT_TRACE(COMP_ERR, "Unable to initialize "
+ "/proc/net/rtl8192/%s/ofdm-registers\n",
+ dev->name);
+ }
+#endif
+}
+/****************************************************************************
+ -----------------------------MISC STUFF-------------------------
+*****************************************************************************/
+
+/* this is only for debugging */
+void print_buffer(u32 *buffer, int len)
+{
+ int i;
+ u8 *buf =(u8*)buffer;
+
+ printk("ASCII BUFFER DUMP (len: %x):\n",len);
+
+ for(i=0;i<len;i++)
+ printk("%c",buf[i]);
+
+ printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
+
+ for(i=0;i<len;i++)
+ printk("%x",buf[i]);
+
+ printk("\n");
+}
+
+//short check_nic_enough_desc(struct net_device *dev, priority_t priority)
+short check_nic_enough_desc(struct net_device *dev,int queue_index)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int used = atomic_read(&priv->tx_pending[queue_index]);
+
+ return (used < MAX_TX_URB);
+}
+
+void tx_timeout(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //rtl8192_commit(dev);
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ schedule_work(&priv->reset_wq);
+#else
+ schedule_task(&priv->reset_wq);
+#endif
+ //DMESG("TXTIMEOUT");
+}
+
+
+/* this is only for debug */
+void dump_eprom(struct net_device *dev)
+{
+ int i;
+ for(i=0; i<63; i++)
+ RT_TRACE(COMP_EPROM, "EEPROM addr %x : %x", i, eprom_read(dev,i));
+}
+
+/* this is only for debug */
+void rtl8192_dump_reg(struct net_device *dev)
+{
+ int i;
+ int n;
+ int max=0x1ff;
+
+ RT_TRACE(COMP_PHY, "Dumping NIC register map");
+
+ for(n=0;n<=max;)
+ {
+ printk( "\nD: %2x> ", n);
+ for(i=0;i<16 && n<=max;i++,n++)
+ printk("%2x ",read_nic_byte(dev,n));
+ }
+ printk("\n");
+}
+
+/****************************************************************************
+ ------------------------------HW STUFF---------------------------
+*****************************************************************************/
+
+#if 0
+void rtl8192_irq_enable(struct net_device *dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ //priv->irq_enabled = 1;
+/*
+ write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
+ INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
+ INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
+ INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
+*/
+ write_nic_word(dev,INTA_MASK, priv->irq_mask);
+}
+
+
+void rtl8192_irq_disable(struct net_device *dev)
+{
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ write_nic_word(dev,INTA_MASK,0);
+ force_pci_posting(dev);
+// priv->irq_enabled = 0;
+}
+#endif
+
+void rtl8192_set_mode(struct net_device *dev,int mode)
+{
+ u8 ecmd;
+ ecmd=read_nic_byte(dev, EPROM_CMD);
+ ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK;
+ ecmd=ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT);
+ ecmd=ecmd &~ (1<<EPROM_CS_SHIFT);
+ ecmd=ecmd &~ (1<<EPROM_CK_SHIFT);
+ write_nic_byte(dev, EPROM_CMD, ecmd);
+}
+
+
+void rtl8192_update_msr(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 msr;
+
+ msr = read_nic_byte(dev, MSR);
+ msr &= ~ MSR_LINK_MASK;
+
+ /* do not change in link_state != WLAN_LINK_ASSOCIATED.
+ * msr must be updated if the state is ASSOCIATING.
+ * this is intentional and make sense for ad-hoc and
+ * master (see the create BSS/IBSS func)
+ */
+ if (priv->ieee80211->state == IEEE80211_LINKED){
+
+ if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
+ msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
+ else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
+ else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
+ msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
+
+ }else
+ msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
+
+ write_nic_byte(dev, MSR, msr);
+}
+
+void rtl8192_set_chan(struct net_device *dev,short ch)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+// u32 tx;
+ RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __FUNCTION__, ch);
+ //printk("=====>%s()====ch:%d\n", __FUNCTION__, ch);
+ priv->chan=ch;
+ #if 0
+ if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
+ priv->ieee80211->iw_mode == IW_MODE_MASTER){
+
+ priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
+ priv->ieee80211->master_chan = ch;
+ rtl8192_update_beacon_ch(dev);
+ }
+ #endif
+
+ /* this hack should avoid frame TX during channel setting*/
+
+
+// tx = read_nic_dword(dev,TX_CONF);
+// tx &= ~TX_LOOPBACK_MASK;
+
+#ifndef LOOP_TEST
+// write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
+
+ //need to implement rf set channel here WB
+
+ if (priv->rf_set_chan)
+ priv->rf_set_chan(dev,priv->chan);
+ mdelay(10);
+// write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
+#endif
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+static void rtl8192_rx_isr(struct urb *urb, struct pt_regs *regs);
+#else
+static void rtl8192_rx_isr(struct urb *urb);
+#endif
+//static void rtl8192_rx_isr(struct urb *rx_urb);
+
+u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats)
+{
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ if (pstats->bisrxaggrsubframe)
+ return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize
+ + pstats->RxBufShift + 8);
+ else
+#endif
+ return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize
+ + pstats->RxBufShift);
+
+}
+static int rtl8192_rx_initiate(struct net_device*dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct urb *entry;
+ struct sk_buff *skb;
+ struct rtl8192_rx_info *info;
+
+ /* nomal packet rx procedure */
+ while (skb_queue_len(&priv->rx_queue) < MAX_RX_URB) {
+ skb = __dev_alloc_skb(RX_URB_SIZE, GFP_KERNEL);
+ if (!skb)
+ break;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ entry = usb_alloc_urb(0, GFP_KERNEL);
+#else
+ entry = usb_alloc_urb(0);
+#endif
+ if (!entry) {
+ kfree_skb(skb);
+ break;
+ }
+// printk("nomal packet IN request!\n");
+ usb_fill_bulk_urb(entry, priv->udev,
+ usb_rcvbulkpipe(priv->udev, 3), skb->tail,
+ RX_URB_SIZE, rtl8192_rx_isr, skb);
+ info = (struct rtl8192_rx_info *) skb->cb;
+ info->urb = entry;
+ info->dev = dev;
+ info->out_pipe = 3; //denote rx normal packet queue
+ skb_queue_tail(&priv->rx_queue, skb);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ usb_submit_urb(entry, GFP_KERNEL);
+#else
+ usb_submit_urb(entry);
+#endif
+ }
+
+ /* command packet rx procedure */
+ while (skb_queue_len(&priv->rx_queue) < MAX_RX_URB + 3) {
+// printk("command packet IN request!\n");
+ skb = __dev_alloc_skb(RX_URB_SIZE ,GFP_KERNEL);
+ if (!skb)
+ break;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ entry = usb_alloc_urb(0, GFP_KERNEL);
+#else
+ entry = usb_alloc_urb(0);
+#endif
+ if (!entry) {
+ kfree_skb(skb);
+ break;
+ }
+ usb_fill_bulk_urb(entry, priv->udev,
+ usb_rcvbulkpipe(priv->udev, 9), skb->tail,
+ RX_URB_SIZE, rtl8192_rx_isr, skb);
+ info = (struct rtl8192_rx_info *) skb->cb;
+ info->urb = entry;
+ info->dev = dev;
+ info->out_pipe = 9; //denote rx cmd packet queue
+ skb_queue_tail(&priv->rx_queue, skb);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ usb_submit_urb(entry, GFP_KERNEL);
+#else
+ usb_submit_urb(entry);
+#endif
+ }
+
+ return 0;
+}
+
+void rtl8192_set_rxconf(struct net_device *dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ u32 rxconf;
+
+ rxconf=read_nic_dword(dev,RCR);
+ rxconf = rxconf &~ MAC_FILTER_MASK;
+ rxconf = rxconf | RCR_AMF;
+ rxconf = rxconf | RCR_ADF;
+ rxconf = rxconf | RCR_AB;
+ rxconf = rxconf | RCR_AM;
+ //rxconf = rxconf | RCR_ACF;
+
+ if (dev->flags & IFF_PROMISC) {DMESG ("NIC in promisc mode");}
+
+ if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
+ dev->flags & IFF_PROMISC){
+ rxconf = rxconf | RCR_AAP;
+ } /*else if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
+ rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
+ rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
+ }*/else{
+ rxconf = rxconf | RCR_APM;
+ rxconf = rxconf | RCR_CBSSID;
+ }
+
+
+ if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
+ rxconf = rxconf | RCR_AICV;
+ rxconf = rxconf | RCR_APWRMGT;
+ }
+
+ if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
+ rxconf = rxconf | RCR_ACRC32;
+
+
+ rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
+ rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
+ rxconf = rxconf &~ MAX_RX_DMA_MASK;
+ rxconf = rxconf | ((u32)7<<RCR_MXDMA_OFFSET);
+
+// rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
+ rxconf = rxconf | RCR_ONLYERLPKT;
+
+// rxconf = rxconf &~ RCR_CS_MASK;
+// rxconf = rxconf | (1<<RCR_CS_SHIFT);
+
+ write_nic_dword(dev, RCR, rxconf);
+
+ #ifdef DEBUG_RX
+ DMESG("rxconf: %x %x",rxconf ,read_nic_dword(dev,RCR));
+ #endif
+}
+//wait to be removed
+void rtl8192_rx_enable(struct net_device *dev)
+{
+ //u8 cmd;
+
+ //struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ rtl8192_rx_initiate(dev);
+
+// rtl8192_set_rxconf(dev);
+#if 0
+ if(NIC_8187 == priv->card_8187) {
+ cmd=read_nic_byte(dev,CMD);
+ write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
+ }
+ else {
+ //write_nic_dword(dev, RX_CONF, priv->ReceiveConfig);
+ }
+#endif
+}
+
+
+void rtl8192_tx_enable(struct net_device *dev)
+{
+#if 0
+ u8 cmd;
+ u8 byte;
+ u32 txconf;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ //test loopback
+ // priv->TransmitConfig |= (TX_LOOPBACK_BASEBAND<<TX_LOOPBACK_SHIFT);
+ if(NIC_8187B == priv->card_8187){
+ write_nic_dword(dev, TX_CONF, priv->TransmitConfig);
+ byte = read_nic_byte(dev, MSR);
+ byte |= MSR_LINK_ENEDCA;
+ write_nic_byte(dev, MSR, byte);
+ } else {
+ byte = read_nic_byte(dev,CW_CONF);
+ byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
+ byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
+ write_nic_byte(dev, CW_CONF, byte);
+
+ byte = read_nic_byte(dev, TX_AGC_CTL);
+ byte &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
+ byte &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
+ byte &= ~(1<<TX_AGC_CTL_FEEDBACK_ANT);
+ write_nic_byte(dev, TX_AGC_CTL, byte);
+
+ txconf= read_nic_dword(dev,TX_CONF);
+
+
+ txconf = txconf &~ TX_LOOPBACK_MASK;
+
+#ifndef LOOP_TEST
+ txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
+#else
+ txconf = txconf | (TX_LOOPBACK_BASEBAND<<TX_LOOPBACK_SHIFT);
+#endif
+ txconf = txconf &~ TCR_SRL_MASK;
+ txconf = txconf &~ TCR_LRL_MASK;
+
+ txconf = txconf | (priv->retry_data<<TX_LRLRETRY_SHIFT); // long
+ txconf = txconf | (priv->retry_rts<<TX_SRLRETRY_SHIFT); // short
+
+ txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
+
+ txconf = txconf &~ TCR_MXDMA_MASK;
+ txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
+
+ txconf = txconf | TCR_DISReqQsize;
+ txconf = txconf | TCR_DISCW;
+ txconf = txconf &~ TCR_SWPLCPLEN;
+
+ txconf=txconf | (1<<TX_NOICV_SHIFT);
+
+ write_nic_dword(dev,TX_CONF,txconf);
+
+#ifdef DEBUG_TX
+ DMESG("txconf: %x %x",txconf,read_nic_dword(dev,TX_CONF));
+#endif
+
+ cmd=read_nic_byte(dev,CMD);
+ write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
+ }
+#endif
+}
+
+#if 0
+void rtl8192_beacon_tx_enable(struct net_device *dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
+ rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
+}
+
+
+void rtl8192_
+_disable(struct net_device *dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
+ rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
+}
+
+#endif
+
+
+void rtl8192_rtx_disable(struct net_device *dev)
+{
+ u8 cmd;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct sk_buff *skb;
+ struct rtl8192_rx_info *info;
+
+ cmd=read_nic_byte(dev,CMDR);
+ write_nic_byte(dev, CMDR, cmd &~ \
+ (CR_TE|CR_RE));
+ force_pci_posting(dev);
+ mdelay(10);
+
+ while ((skb = __skb_dequeue(&priv->rx_queue))) {
+ info = (struct rtl8192_rx_info *) skb->cb;
+ if (!info->urb)
+ continue;
+
+ usb_kill_urb(info->urb);
+ kfree_skb(skb);
+ }
+
+ if (skb_queue_len(&priv->skb_queue)) {
+ printk(KERN_WARNING "skb_queue not empty\n");
+ }
+
+ skb_queue_purge(&priv->skb_queue);
+ return;
+}
+
+
+int alloc_tx_beacon_desc_ring(struct net_device *dev, int count)
+{
+ #if 0
+ int i;
+ u32 *tmp;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
+ sizeof(u32)*8*count,
+ &priv->txbeaconringdma);
+ if (!priv->txbeaconring) return -1;
+ for (tmp=priv->txbeaconring,i=0;i<count;i++){
+ *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
+ /*
+ *(tmp+2) = (u32)dma_tmp;
+ *(tmp+3) = bufsize;
+ */
+ if(i+1<count)
+ *(tmp+4) = (u32)priv->txbeaconringdma+((i+1)*8*4);
+ else
+ *(tmp+4) = (u32)priv->txbeaconringdma;
+
+ tmp=tmp+8;
+ }
+ #endif
+ return 0;
+}
+
+#if 0
+void rtl8192_reset(struct net_device *dev)
+{
+
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+ //u8 cr;
+
+
+ /* make sure the analog power is on before
+ * reset, otherwise reset may fail
+ */
+#if 0
+ if(NIC_8187 == priv->card_8187) {
+ rtl8192_set_anaparam(dev, RTL8225_ANAPARAM_ON);
+ rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
+ rtl8192_irq_disable(dev);
+ mdelay(200);
+ write_nic_byte_E(dev,0x18,0x10);
+ write_nic_byte_E(dev,0x18,0x11);
+ write_nic_byte_E(dev,0x18,0x00);
+ mdelay(200);
+ }
+#endif
+ printk("=====>reset?\n");
+#if 0
+ cr=read_nic_byte(dev,CMD);
+ cr = cr & 2;
+ cr = cr | (1<<CMD_RST_SHIFT);
+ write_nic_byte(dev,CMD,cr);
+
+ force_pci_posting(dev);
+
+ mdelay(200);
+
+ if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
+ RT_TRACE(COMP_ERR, "Card reset timeout!\n");
+ else
+ RT_TRACE(COMP_DOWN, "Card successfully reset\n");
+#endif
+#if 0
+ if(NIC_8187 == priv->card_8187) {
+
+ printk("This is RTL8187 Reset procedure\n");
+ rtl8192_set_mode(dev,EPROM_CMD_LOAD);
+ force_pci_posting(dev);
+ mdelay(200);
+
+ /* after the eeprom load cycle, make sure we have
+ * correct anaparams
+ */
+ rtl8192_set_anaparam(dev, RTL8225_ANAPARAM_ON);
+ rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
+ }
+ else
+#endif
+ printk("This is RTL8187B Reset procedure\n");
+
+}
+#endif
+inline u16 ieeerate2rtlrate(int rate)
+{
+ switch(rate){
+ case 10:
+ return 0;
+ case 20:
+ return 1;
+ case 55:
+ return 2;
+ case 110:
+ return 3;
+ case 60:
+ return 4;
+ case 90:
+ return 5;
+ case 120:
+ return 6;
+ case 180:
+ return 7;
+ case 240:
+ return 8;
+ case 360:
+ return 9;
+ case 480:
+ return 10;
+ case 540:
+ return 11;
+ default:
+ return 3;
+
+ }
+}
+static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
+inline u16 rtl8192_rate2rate(short rate)
+{
+ if (rate >11) return 0;
+ return rtl_rate[rate];
+}
+
+
+/* The protype of rx_isr has changed since one verion of Linux Kernel */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+static void rtl8192_rx_isr(struct urb *urb, struct pt_regs *regs)
+#else
+static void rtl8192_rx_isr(struct urb *urb)
+#endif
+{
+ struct sk_buff *skb = (struct sk_buff *) urb->context;
+ struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev = info->dev;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int out_pipe = info->out_pipe;
+ int err;
+ if(!priv->up)
+ return;
+ if (unlikely(urb->status)) {
+ info->urb = NULL;
+ priv->stats.rxstaterr++;
+ priv->ieee80211->stats.rx_errors++;
+ usb_free_urb(urb);
+ // printk("%s():rx status err\n",__FUNCTION__);
+ return;
+ }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+ skb_unlink(skb, &priv->rx_queue);
+#else
+ /*
+ * __skb_unlink before linux2.6.14 does not use spinlock to protect list head.
+ * add spinlock function manually. john,2008/12/03
+ */
+ {
+ unsigned long flags;
+ spin_lock_irqsave(&(priv->rx_queue.lock), flags);
+ __skb_unlink(skb,&priv->rx_queue);
+ spin_unlock_irqrestore(&(priv->rx_queue.lock), flags);
+ }
+#endif
+ skb_put(skb, urb->actual_length);
+
+ skb_queue_tail(&priv->skb_queue, skb);
+ tasklet_schedule(&priv->irq_rx_tasklet);
+
+ skb = dev_alloc_skb(RX_URB_SIZE);
+ if (unlikely(!skb)) {
+ usb_free_urb(urb);
+ printk("%s():can,t alloc skb\n",__FUNCTION__);
+ /* TODO check rx queue length and refill *somewhere* */
+ return;
+ }
+
+ usb_fill_bulk_urb(urb, priv->udev,
+ usb_rcvbulkpipe(priv->udev, out_pipe), skb->tail,
+ RX_URB_SIZE, rtl8192_rx_isr, skb);
+
+ info = (struct rtl8192_rx_info *) skb->cb;
+ info->urb = urb;
+ info->dev = dev;
+ info->out_pipe = out_pipe;
+
+ urb->transfer_buffer = skb->tail;
+ urb->context = skb;
+ skb_queue_tail(&priv->rx_queue, skb);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ err = usb_submit_urb(urb, GFP_ATOMIC);
+#else
+ err = usb_submit_urb(urb);
+#endif
+ if(err && err != EPERM)
+ printk("can not submit rxurb, err is %x,URB status is %x\n",err,urb->status);
+}
+
+u32
+rtl819xusb_rx_command_packet(
+ struct net_device *dev,
+ struct ieee80211_rx_stats *pstats
+ )
+{
+ u32 status;
+
+ //RT_TRACE(COMP_RECV, DBG_TRACE, ("---> RxCommandPacketHandle819xUsb()\n"));
+
+ status = cmpk_message_handle_rx(dev, pstats);
+ if (status)
+ {
+ DMESG("rxcommandpackethandle819xusb: It is a command packet\n");
+ }
+ else
+ {
+ //RT_TRACE(COMP_RECV, DBG_TRACE, ("RxCommandPacketHandle819xUsb: It is not a command packet\n"));
+ }
+
+ //RT_TRACE(COMP_RECV, DBG_TRACE, ("<--- RxCommandPacketHandle819xUsb()\n"));
+ return status;
+}
+
+#if 0
+void rtl8192_tx_queues_stop(struct net_device *dev)
+{
+ //struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
+ dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
+ dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
+ dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
+
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ write_nic_byte(dev,TX_DMA_POLLING,dma_poll_mask);
+ rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
+}
+#endif
+
+void rtl8192_data_hard_stop(struct net_device *dev)
+{
+ //FIXME !!
+ #if 0
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
+ rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
+ #endif
+}
+
+
+void rtl8192_data_hard_resume(struct net_device *dev)
+{
+ // FIXME !!
+ #if 0
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
+ rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
+ #endif
+}
+
+/* this function TX data frames when the ieee80211 stack requires this.
+ * It checks also if we need to stop the ieee tx queue, eventually do it
+ */
+void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ int ret;
+ unsigned long flags;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 queue_index = tcb_desc->queue_index;
+
+ /* shall not be referred by command packet */
+ assert(queue_index != TXCMD_QUEUE);
+
+ spin_lock_irqsave(&priv->tx_lock,flags);
+
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+// tcb_desc->RATRIndex = 7;
+// tcb_desc->bTxDisableRateFallBack = 1;
+// tcb_desc->bTxUseDriverAssingedRate = 1;
+ tcb_desc->bTxEnableFwCalcDur = 1;
+ skb_push(skb, priv->ieee80211->tx_headroom);
+ ret = priv->ops->rtl819x_tx(dev, skb);
+
+ //priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
+ //priv->ieee80211->stats.tx_packets++;
+
+ spin_unlock_irqrestore(&priv->tx_lock,flags);
+
+// return ret;
+ return;
+}
+
+/* This is a rough attempt to TX a frame
+ * This is called by the ieee 80211 stack to TX management frames.
+ * If the ring is full packet are dropped (for data frame the queue
+ * is stopped before this can happen).
+ */
+int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ int ret;
+ unsigned long flags;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 queue_index = tcb_desc->queue_index;
+
+
+ spin_lock_irqsave(&priv->tx_lock,flags);
+
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ if(queue_index == TXCMD_QUEUE) {
+ skb_push(skb, USB_HWDESC_HEADER_LEN);
+ priv->ops->rtl819x_tx_cmd(dev, skb);
+ ret = 1;
+ spin_unlock_irqrestore(&priv->tx_lock,flags);
+ return ret;
+ } else {
+ skb_push(skb, priv->ieee80211->tx_headroom);
+ ret = priv->ops->rtl819x_tx(dev, skb);
+ }
+
+ spin_unlock_irqrestore(&priv->tx_lock,flags);
+
+ return ret;
+}
+
+
+void rtl8192_try_wake_queue(struct net_device *dev, int pri);
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+u16 DrvAggr_PaddingAdd(struct net_device *dev, struct sk_buff *skb)
+{
+ u16 PaddingNum = 256 - ((skb->len + TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES) % 256);
+ return (PaddingNum&0xff);
+}
+
+u8 MRateToHwRate8190Pci(u8 rate);
+u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc);
+u8 MapHwQueueToFirmwareQueue(u8 QueueID);
+struct sk_buff *DrvAggr_Aggregation(struct net_device *dev, struct ieee80211_drv_agg_txb *pSendList)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ struct ieee80211_device *ieee = netdev_priv(dev);
+#else
+ struct ieee80211_device *ieee = (struct ieee80211_device *)dev->priv;
+#endif
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ cb_desc *tcb_desc = NULL;
+ u8 i;
+ u32 TotalLength;
+ struct sk_buff *skb;
+ struct sk_buff *agg_skb;
+ tx_desc_819x_usb_aggr_subframe *tx_agg_desc = NULL;
+ tx_fwinfo_819x_usb *tx_fwinfo = NULL;
+
+ //
+ // Local variable initialization.
+ //
+ /* first skb initialization */
+ skb = pSendList->tx_agg_frames[0];
+ TotalLength = skb->len;
+
+ /* Get the total aggregation length including the padding space and
+ * sub frame header.
+ */
+ for(i = 1; i < pSendList->nr_drv_agg_frames; i++) {
+ TotalLength += DrvAggr_PaddingAdd(dev, skb);
+ skb = pSendList->tx_agg_frames[i];
+ TotalLength += (skb->len + TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES);
+ }
+
+ /* allocate skb to contain the aggregated packets */
+ agg_skb = dev_alloc_skb(TotalLength + ieee->tx_headroom);
+ memset(agg_skb->data, 0, agg_skb->len);
+ skb_reserve(agg_skb, ieee->tx_headroom);
+
+// RT_DEBUG_DATA(COMP_SEND, skb->cb, sizeof(skb->cb));
+ /* reserve info for first subframe Tx descriptor to be set in the tx function */
+ skb = pSendList->tx_agg_frames[0];
+ tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->drv_agg_enable = 1;
+ tcb_desc->pkt_size = skb->len;
+ tcb_desc->DrvAggrNum = pSendList->nr_drv_agg_frames;
+ printk("DrvAggNum = %d\n", tcb_desc->DrvAggrNum);
+// RT_DEBUG_DATA(COMP_SEND, skb->cb, sizeof(skb->cb));
+// printk("========>skb->data ======> \n");
+// RT_DEBUG_DATA(COMP_SEND, skb->data, skb->len);
+ memcpy(agg_skb->cb, skb->cb, sizeof(skb->cb));
+ memcpy(skb_put(agg_skb,skb->len),skb->data,skb->len);
+
+ for(i = 1; i < pSendList->nr_drv_agg_frames; i++) {
+ /* push the next sub frame to be 256 byte aline */
+ skb_put(agg_skb,DrvAggr_PaddingAdd(dev,skb));
+
+ /* Subframe drv Tx descriptor and firmware info setting */
+ skb = pSendList->tx_agg_frames[i];
+ tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tx_agg_desc = (tx_desc_819x_usb_aggr_subframe *)agg_skb->tail;
+ tx_fwinfo = (tx_fwinfo_819x_usb *)(agg_skb->tail + sizeof(tx_desc_819x_usb_aggr_subframe));
+
+ memset(tx_fwinfo,0,sizeof(tx_fwinfo_819x_usb));
+ /* DWORD 0 */
+ tx_fwinfo->TxHT = (tcb_desc->data_rate&0x80)?1:0;
+ tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
+ tx_fwinfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
+ tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, tcb_desc);
+ if(tcb_desc->bAMPDUEnable) {//AMPDU enabled
+ tx_fwinfo->AllowAggregation = 1;
+ /* DWORD 1 */
+ tx_fwinfo->RxMF = tcb_desc->ampdu_factor;
+ tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity
+ } else {
+ tx_fwinfo->AllowAggregation = 0;
+ /* DWORD 1 */
+ tx_fwinfo->RxMF = 0;
+ tx_fwinfo->RxAMD = 0;
+ }
+
+ /* Protection mode related */
+ tx_fwinfo->RtsEnable = (tcb_desc->bRTSEnable)?1:0;
+ tx_fwinfo->CtsEnable = (tcb_desc->bCTSEnable)?1:0;
+ tx_fwinfo->RtsSTBC = (tcb_desc->bRTSSTBC)?1:0;
+ tx_fwinfo->RtsHT = (tcb_desc->rts_rate&0x80)?1:0;
+ tx_fwinfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate);
+ tx_fwinfo->RtsSubcarrier = (tx_fwinfo->RtsHT==0)?(tcb_desc->RTSSC):0;
+ tx_fwinfo->RtsBandwidth = (tx_fwinfo->RtsHT==1)?((tcb_desc->bRTSBW)?1:0):0;
+ tx_fwinfo->RtsShort = (tx_fwinfo->RtsHT==0)?(tcb_desc->bRTSUseShortPreamble?1:0):\
+ (tcb_desc->bRTSUseShortGI?1:0);
+
+ /* Set Bandwidth and sub-channel settings. */
+ if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ {
+ if(tcb_desc->bPacketBW) {
+ tx_fwinfo->TxBandwidth = 1;
+ tx_fwinfo->TxSubCarrier = 0; //By SD3's Jerry suggestion, use duplicated mode
+ } else {
+ tx_fwinfo->TxBandwidth = 0;
+ tx_fwinfo->TxSubCarrier = priv->nCur40MhzPrimeSC;
+ }
+ } else {
+ tx_fwinfo->TxBandwidth = 0;
+ tx_fwinfo->TxSubCarrier = 0;
+ }
+
+ /* Fill Tx descriptor */
+ memset(tx_agg_desc, 0, sizeof(tx_desc_819x_usb_aggr_subframe));
+ /* DWORD 0 */
+ //tx_agg_desc->LINIP = 0;
+ //tx_agg_desc->CmdInit = 1;
+ tx_agg_desc->Offset = sizeof(tx_fwinfo_819x_usb) + 8;
+ /* already raw data, need not to substract header length */
+ tx_agg_desc->PktSize = skb->len & 0xffff;
+
+ /*DWORD 1*/
+ tx_agg_desc->SecCAMID= 0;
+ tx_agg_desc->RATid = tcb_desc->RATRIndex;
+#if 0
+ /* Fill security related */
+ if( pTcb->bEncrypt && !Adapter->MgntInfo.SecurityInfo.SWTxEncryptFlag)
+ {
+ EncAlg = SecGetEncryptionOverhead(
+ Adapter,
+ &EncryptionMPDUHeadOverhead,
+ &EncryptionMPDUTailOverhead,
+ NULL,
+ NULL,
+ FALSE,
+ FALSE);
+ //2004/07/22, kcwu, EncryptionMPDUHeadOverhead has been added in previous code
+ //MPDUOverhead = EncryptionMPDUHeadOverhead + EncryptionMPDUTailOverhead;
+ MPDUOverhead = EncryptionMPDUTailOverhead;
+ tx_agg_desc->NoEnc = 0;
+ RT_TRACE(COMP_SEC, DBG_LOUD, ("******We in the loop SecCAMID is %d SecDescAssign is %d The Sec is %d********\n",tx_agg_desc->SecCAMID,tx_agg_desc->SecDescAssign,EncAlg));
+ //CamDumpAll(Adapter);
+ }
+ else
+#endif
+ {
+ //MPDUOverhead = 0;
+ tx_agg_desc->NoEnc = 1;
+ }
+#if 0
+ switch(EncAlg){
+ case NO_Encryption:
+ tx_agg_desc->SecType = 0x0;
+ break;
+ case WEP40_Encryption:
+ case WEP104_Encryption:
+ tx_agg_desc->SecType = 0x1;
+ break;
+ case TKIP_Encryption:
+ tx_agg_desc->SecType = 0x2;
+ break;
+ case AESCCMP_Encryption:
+ tx_agg_desc->SecType = 0x3;
+ break;
+ default:
+ tx_agg_desc->SecType = 0x0;
+ break;
+ }
+#else
+ tx_agg_desc->SecType = 0x0;
+#endif
+
+ if (tcb_desc->bHwSec) {
+ switch (priv->ieee80211->pairwise_key_type)
+ {
+ case KEY_TYPE_WEP40:
+ case KEY_TYPE_WEP104:
+ tx_agg_desc->SecType = 0x1;
+ tx_agg_desc->NoEnc = 0;
+ break;
+ case KEY_TYPE_TKIP:
+ tx_agg_desc->SecType = 0x2;
+ tx_agg_desc->NoEnc = 0;
+ break;
+ case KEY_TYPE_CCMP:
+ tx_agg_desc->SecType = 0x3;
+ tx_agg_desc->NoEnc = 0;
+ break;
+ case KEY_TYPE_NA:
+ tx_agg_desc->SecType = 0x0;
+ tx_agg_desc->NoEnc = 1;
+ break;
+ }
+ }
+
+ tx_agg_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index);
+ tx_agg_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb);
+
+ tx_agg_desc->DISFB = tcb_desc->bTxDisableRateFallBack;
+ tx_agg_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate;
+
+ tx_agg_desc->OWN = 1;
+
+ //DWORD 2
+ /* According windows driver, it seems that there no need to fill this field */
+ //tx_agg_desc->TxBufferSize= (u32)(skb->len - USB_HWDESC_HEADER_LEN);
+
+ /* to fill next packet */
+ skb_put(agg_skb,TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES);
+ memcpy(skb_put(agg_skb,skb->len),skb->data,skb->len);
+ }
+
+ for(i = 0; i < pSendList->nr_drv_agg_frames; i++) {
+ dev_kfree_skb_any(pSendList->tx_agg_frames[i]);
+ }
+
+ return agg_skb;
+}
+
+/* NOTE:
+ This function return a list of PTCB which is proper to be aggregate with the input TCB.
+ If no proper TCB is found to do aggregation, SendList will only contain the input TCB.
+*/
+u8 DrvAggr_GetAggregatibleList(struct net_device *dev, struct sk_buff *skb,
+ struct ieee80211_drv_agg_txb *pSendList)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ struct ieee80211_device *ieee = netdev_priv(dev);
+#else
+ struct ieee80211_device *ieee = (struct ieee80211_device *)dev->priv;
+#endif
+ PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
+ u16 nMaxAggrNum = pHTInfo->UsbTxAggrNum;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 QueueID = tcb_desc->queue_index;
+
+ do {
+ pSendList->tx_agg_frames[pSendList->nr_drv_agg_frames++] = skb;
+ if(pSendList->nr_drv_agg_frames >= nMaxAggrNum) {
+ break;
+ }
+
+ } while((skb = skb_dequeue(&ieee->skb_drv_aggQ[QueueID])));
+
+ RT_TRACE(COMP_AMSDU, "DrvAggr_GetAggregatibleList, nAggrTcbNum = %d \n", pSendList->nr_drv_agg_frames);
+ return pSendList->nr_drv_agg_frames;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+static void rtl8192_tx_isr(struct urb *tx_urb, struct pt_regs *reg)
+#else
+static void rtl8192_tx_isr(struct urb *tx_urb)
+#endif
+{
+ struct sk_buff *skb = (struct sk_buff*)tx_urb->context;
+ struct net_device *dev = NULL;
+ struct r8192_priv *priv = NULL;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 queue_index = tcb_desc->queue_index;
+// bool bToSend0Byte;
+// u16 BufLen = skb->len;
+
+ memcpy(&dev,(struct net_device*)(skb->cb),sizeof(struct net_device*));
+ priv = ieee80211_priv(dev);
+
+ if(tcb_desc->queue_index != TXCMD_QUEUE) {
+ if(tx_urb->status == 0) {
+ // dev->trans_start = jiffies;
+ // As act as station mode, destion shall be unicast address.
+ //priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
+ //priv->ieee80211->stats.tx_packets++;
+ priv->stats.txoktotal++;
+ priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++;
+ priv->stats.txbytesunicast += (skb->len - priv->ieee80211->tx_headroom);
+ } else {
+ priv->ieee80211->stats.tx_errors++;
+ //priv->stats.txmanageerr++;
+ /* TODO */
+ }
+ }
+
+ /* free skb and tx_urb */
+ if(skb != NULL) {
+ dev_kfree_skb_any(skb);
+ usb_free_urb(tx_urb);
+ atomic_dec(&priv->tx_pending[queue_index]);
+ }
+
+#if 0 //we need to send zero byte packet just after 512 byte(64 byte)packet is transmitted, or we will halt. It will greatly reduced available page in FW, and ruin our throughput. WB 2008.08.27
+ if(BufLen > 0 && ((BufLen % 512 == 0)||(BufLen % 64 == 0))) {
+ bToSend0Byte = true;
+ }
+
+ bToSend0Byte = false;
+ //
+ // Note that, we at most handle 1 MPDU to send here, either
+ // fragment or MPDU in wait queue.
+ //
+ if(!bToSend0Byte)
+#endif
+ {
+ //
+ // Handle HW Beacon:
+ // We had transfer our beacon frame to host controler at this moment.
+ //
+#if 0
+ if(tcb_desc->tx_queue == BEACON_QUEUE)
+ {
+ priv->bSendingBeacon = FALSE;
+ }
+#endif
+ //
+ // Caution:
+ // Handling the wait queue of command packets.
+ // For Tx command packets, we must not do TCB fragment because it is not handled right now.
+ // We must cut the packets to match the size of TX_CMD_PKT before we send it.
+ //
+ if (queue_index == MGNT_QUEUE){
+ if (priv->ieee80211->ack_tx_to_ieee){
+ if (rtl8192_is_tx_queue_empty(dev)){
+ priv->ieee80211->ack_tx_to_ieee = 0;
+ ieee80211_ps_tx_ack(priv->ieee80211, 1);
+ }
+ }
+ }
+ /* Handle MPDU in wait queue. */
+ if(queue_index != BEACON_QUEUE) {
+ /* Don't send data frame during scanning.*/
+ if((skb_queue_len(&priv->ieee80211->skb_waitQ[queue_index]) != 0)&&\
+ (!(priv->ieee80211->queue_stop))) {
+ if(NULL != (skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]))))
+ priv->ieee80211->softmac_hard_start_xmit(skb, dev);
+
+ return; //modified by david to avoid further processing AMSDU
+ }
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ else if ((skb_queue_len(&priv->ieee80211->skb_drv_aggQ[queue_index])!= 0)&&\
+ (!(priv->ieee80211->queue_stop))) {
+ // Tx Driver Aggregation process
+ /* The driver will aggregation the packets according to the following stets
+ * 1. check whether there's tx irq available, for it's a completion return
+ * function, it should contain enough tx irq;
+ * 2. check pakcet type;
+ * 3. intialize sendlist, check whether the to-be send packet no greater than 1
+ * 4. aggregation the packets, and fill firmware info and tx desc to it, etc.
+ * 5. check whehter the packet could be sent, otherwise just insert to wait head
+ * */
+ skb = skb_dequeue(&priv->ieee80211->skb_drv_aggQ[queue_index]);
+ if(!check_nic_enough_desc(dev, queue_index)) {
+ skb_queue_head(&(priv->ieee80211->skb_drv_aggQ[queue_index]), skb);
+ return;
+ }
+
+ {
+ /*TODO*/
+ /*
+ u8* pHeader = skb->data;
+
+ if(IsMgntQosData(pHeader) ||
+ IsMgntQData_Ack(pHeader) ||
+ IsMgntQData_Poll(pHeader) ||
+ IsMgntQData_Poll_Ack(pHeader)
+ )
+ */
+ {
+ struct ieee80211_drv_agg_txb SendList;
+
+ memset(&SendList, 0, sizeof(struct ieee80211_drv_agg_txb));
+ if(DrvAggr_GetAggregatibleList(dev, skb, &SendList) > 1) {
+ skb = DrvAggr_Aggregation(dev, &SendList);
+
+#if 0
+ printk("=============>to send aggregated packet!\n");
+ RT_DEBUG_DATA(COMP_SEND, skb->cb, sizeof(skb->cb));
+ printk("\n=================skb->len = %d\n", skb->len);
+ RT_DEBUG_DATA(COMP_SEND, skb->data, skb->len);
+#endif
+ }
+ }
+ priv->ieee80211->softmac_hard_start_xmit(skb, dev);
+ }
+ }
+#endif
+ }
+ }
+
+#if 0
+ else
+ {
+ RT_TRACE( COMP_SEND,"HalUsbOutComplete(%d): bToSend0Byte.\n", PipeIndex);
+
+ //
+ // In this case, we don't return skb now.
+ // It will be returned when the 0-byte request completed.
+ //
+
+ //
+ // Bulk out an 0-byte padding transfer.
+ //
+ HalUsbOut0Byte(pAdapter, PipeIndex, skb);
+ }
+
+#endif
+}
+
+void rtl8192_beacon_stop(struct net_device *dev)
+{
+ u8 msr, msrm, msr2;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ msr = read_nic_byte(dev, MSR);
+ msrm = msr & MSR_LINK_MASK;
+ msr2 = msr & ~MSR_LINK_MASK;
+
+ if(NIC_8192U == priv->card_8192) {
+ usb_kill_urb(priv->rx_urb[MAX_RX_URB]);
+ }
+ if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
+ (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
+ write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
+ write_nic_byte(dev, MSR, msr);
+ }
+}
+
+void rtl8192_config_rate(struct net_device* dev, u16* rate_config)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_network *net;
+ u8 i=0, basic_rate = 0;
+ net = & priv->ieee80211->current_network;
+
+ for (i=0; i<net->rates_len; i++)
+ {
+ basic_rate = net->rates[i]&0x7f;
+ switch(basic_rate)
+ {
+ case MGN_1M: *rate_config |= RRSR_1M; break;
+ case MGN_2M: *rate_config |= RRSR_2M; break;
+ case MGN_5_5M: *rate_config |= RRSR_5_5M; break;
+ case MGN_11M: *rate_config |= RRSR_11M; break;
+ case MGN_6M: *rate_config |= RRSR_6M; break;
+ case MGN_9M: *rate_config |= RRSR_9M; break;
+ case MGN_12M: *rate_config |= RRSR_12M; break;
+ case MGN_18M: *rate_config |= RRSR_18M; break;
+ case MGN_24M: *rate_config |= RRSR_24M; break;
+ case MGN_36M: *rate_config |= RRSR_36M; break;
+ case MGN_48M: *rate_config |= RRSR_48M; break;
+ case MGN_54M: *rate_config |= RRSR_54M; break;
+ }
+ }
+ for (i=0; i<net->rates_ex_len; i++)
+ {
+ basic_rate = net->rates_ex[i]&0x7f;
+ switch(basic_rate)
+ {
+ case MGN_1M: *rate_config |= RRSR_1M; break;
+ case MGN_2M: *rate_config |= RRSR_2M; break;
+ case MGN_5_5M: *rate_config |= RRSR_5_5M; break;
+ case MGN_11M: *rate_config |= RRSR_11M; break;
+ case MGN_6M: *rate_config |= RRSR_6M; break;
+ case MGN_9M: *rate_config |= RRSR_9M; break;
+ case MGN_12M: *rate_config |= RRSR_12M; break;
+ case MGN_18M: *rate_config |= RRSR_18M; break;
+ case MGN_24M: *rate_config |= RRSR_24M; break;
+ case MGN_36M: *rate_config |= RRSR_36M; break;
+ case MGN_48M: *rate_config |= RRSR_48M; break;
+ case MGN_54M: *rate_config |= RRSR_54M; break;
+ }
+ }
+}
+
+
+#define SHORT_SLOT_TIME 9
+#define NON_SHORT_SLOT_TIME 20
+
+void rtl8192_update_cap(struct net_device* dev, u16 cap)
+{
+ //u32 tmp = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_network *net = &priv->ieee80211->current_network;
+ priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE;
+
+ //LZM MOD 090303 HW_VAR_ACK_PREAMBLE
+#ifdef RTL8192SU
+ if(0)
+ {
+ u8 tmp = 0;
+ tmp = ((priv->nCur40MhzPrimeSC) << 5);
+ if (priv->short_preamble)
+ tmp |= 0x80;
+ write_nic_byte(dev, RRSR+2, tmp);
+ }
+#else
+ {
+ u32 tmp = 0;
+ tmp = priv->basic_rate;
+ if (priv->short_preamble)
+ tmp |= BRSR_AckShortPmb;
+ write_nic_dword(dev, RRSR, tmp);
+ }
+#endif
+
+ if (net->mode & (IEEE_G|IEEE_N_24G))
+ {
+ u8 slot_time = 0;
+ if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
+ {//short slot time
+ slot_time = SHORT_SLOT_TIME;
+ }
+ else //long slot time
+ slot_time = NON_SHORT_SLOT_TIME;
+ priv->slot_time = slot_time;
+ write_nic_byte(dev, SLOT_TIME, slot_time);
+ }
+
+}
+void rtl8192_net_update(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_network *net;
+ u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf;
+ u16 rate_config = 0;
+ net = & priv->ieee80211->current_network;
+
+ rtl8192_config_rate(dev, &rate_config);
+ priv->basic_rate = rate_config &= 0x15f;
+
+ write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]);
+ write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]);
+ //for(i=0;i<ETH_ALEN;i++)
+ // write_nic_byte(dev,BSSID+i,net->bssid[i]);
+
+ rtl8192_update_msr(dev);
+// rtl8192_update_cap(dev, net->capability);
+ if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ {
+ write_nic_word(dev, ATIMWND, 2);
+ write_nic_word(dev, BCN_DMATIME, 1023);
+ write_nic_word(dev, BCN_INTERVAL, net->beacon_interval);
+// write_nic_word(dev, BcnIntTime, 100);
+ write_nic_word(dev, BCN_DRV_EARLY_INT, 1);
+ write_nic_byte(dev, BCN_ERR_THRESH, 100);
+ BcnTimeCfg |= (BcnCW<<BCN_TCFG_CW_SHIFT);
+ // TODO: BcnIFS may required to be changed on ASIC
+ BcnTimeCfg |= BcnIFS<<BCN_TCFG_IFS;
+
+ write_nic_word(dev, BCN_TCFG, BcnTimeCfg);
+ }
+
+
+
+}
+
+//temporary hw beacon is not used any more.
+//open it when necessary
+#if 1
+void rtl819xusb_beacon_tx(struct net_device *dev,u16 tx_rate)
+{
+
+#if 0
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct sk_buff *skb;
+ int i = 0;
+ //u8 cr;
+
+ rtl8192_net_update(dev);
+
+ skb = ieee80211_get_beacon(priv->ieee80211);
+ if(!skb){
+ DMESG("not enought memory for allocating beacon");
+ return;
+ }
+
+
+ write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7));
+
+ i=0;
+ //while(!read_nic_byte(dev,BQREQ & (1<<7)))
+ while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 )
+ {
+ msleep_interruptible_rtl(HZ/2);
+ if(i++ > 10){
+ DMESGW("get stuck to wait HW beacon to be ready");
+ return ;
+ }
+ }
+ skb->cb[0] = NORM_PRIORITY;
+ skb->cb[1] = 0; //morefragment = 0
+ skb->cb[2] = ieeerate2rtlrate(tx_rate);
+
+ rtl8192_tx(dev,skb);
+
+#endif
+}
+#endif
+inline u8 rtl8192_IsWirelessBMode(u16 rate)
+{
+ if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
+ return 1;
+ else return 0;
+}
+
+u16 N_DBPSOfRate(u16 DataRate);
+
+u16 ComputeTxTime(
+ u16 FrameLength,
+ u16 DataRate,
+ u8 bManagementFrame,
+ u8 bShortPreamble
+)
+{
+ u16 FrameTime;
+ u16 N_DBPS;
+ u16 Ceiling;
+
+ if( rtl8192_IsWirelessBMode(DataRate) )
+ {
+ if( bManagementFrame || !bShortPreamble || DataRate == 10 )
+ { // long preamble
+ FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10)));
+ }
+ else
+ { // Short preamble
+ FrameTime = (u16)(72+24+(FrameLength*8/(DataRate/10)));
+ }
+ if( ( FrameLength*8 % (DataRate/10) ) != 0 ) //Get the Ceilling
+ FrameTime ++;
+ } else { //802.11g DSSS-OFDM PLCP length field calculation.
+ N_DBPS = N_DBPSOfRate(DataRate);
+ Ceiling = (16 + 8*FrameLength + 6) / N_DBPS
+ + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0);
+ FrameTime = (u16)(16 + 4 + 4*Ceiling + 6);
+ }
+ return FrameTime;
+}
+
+u16 N_DBPSOfRate(u16 DataRate)
+{
+ u16 N_DBPS = 24;
+
+ switch(DataRate)
+ {
+ case 60:
+ N_DBPS = 24;
+ break;
+
+ case 90:
+ N_DBPS = 36;
+ break;
+
+ case 120:
+ N_DBPS = 48;
+ break;
+
+ case 180:
+ N_DBPS = 72;
+ break;
+
+ case 240:
+ N_DBPS = 96;
+ break;
+
+ case 360:
+ N_DBPS = 144;
+ break;
+
+ case 480:
+ N_DBPS = 192;
+ break;
+
+ case 540:
+ N_DBPS = 216;
+ break;
+
+ default:
+ break;
+ }
+
+ return N_DBPS;
+}
+
+void rtl819xU_cmd_isr(struct urb *tx_cmd_urb, struct pt_regs *regs)
+{
+#if 0
+ struct net_device *dev = (struct net_device*)tx_cmd_urb->context;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int last_init_packet = 0;
+ u8 *ptr_cmd_buf;
+ u16 cmd_buf_len;
+
+ if(tx_cmd_urb->status != 0) {
+ priv->pFirmware.firmware_seg_index = 0; //only begin transter, should it can be set to 1
+ }
+
+ /* Free the urb and the corresponding buf for common Tx cmd packet, or
+ * last segment of each firmware img.
+ */
+ if((priv->pFirmware.firmware_seg_index == 0) ||(priv->pFirmware.firmware_seg_index == priv->pFirmware.firmware_seg_maxnum)) {
+ priv->pFirmware.firmware_seg_index = 0;//only begin transter, should it can be set to 1
+ } else {
+ /* prepare for last transfer */
+ /* update some infomation for */
+ /* last segment of the firmware img need indicate to device */
+ priv->pFirmware.firmware_seg_index++;
+ if(priv->pFirmware.firmware_seg_index == priv->pFirmware.firmware_seg_maxnum) {
+ last_init_packet = 1;
+ }
+
+ cmd_buf_len = priv->pFirmware.firmware_seg_container[priv->pFirmware.firmware_seg_index-1].seg_size;
+ ptr_cmd_buf = priv->pFfirmware.firmware_seg_container[priv->pFfirmware.firmware_seg_index-1].seg_ptr;
+ rtl819xU_tx_cmd(dev, ptr_cmd_buf, cmd_buf_len, last_init_packet, DESC_PACKET_TYPE_INIT);
+ }
+
+ kfree(tx_cmd_urb->transfer_buffer);
+#endif
+ usb_free_urb(tx_cmd_urb);
+}
+
+unsigned int txqueue2outpipe(struct r8192_priv* priv,unsigned int tx_queue) {
+
+ if(tx_queue >= 9)
+ {
+ RT_TRACE(COMP_ERR,"%s():Unknown queue ID!!!\n",__FUNCTION__);
+ return 0x04;
+ }
+ return priv->txqueue_to_outpipemap[tx_queue];
+}
+
+#ifdef RTL8192SU
+short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int status;
+ struct urb *tx_urb;
+ unsigned int idx_pipe;
+ tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 queue_index = tcb_desc->queue_index;
+ u32 PktSize = 0;
+
+ //printk("\n %s::::::::::::::::::::::queue_index = %d\n",__FUNCTION__, queue_index);
+ atomic_inc(&priv->tx_pending[queue_index]);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
+#else
+ tx_urb = usb_alloc_urb(0);
+#endif
+ if(!tx_urb){
+ dev_kfree_skb(skb);
+ return -ENOMEM;
+ }
+
+ memset(pdesc, 0, USB_HWDESC_HEADER_LEN);
+
+ /* Tx descriptor ought to be set according to the skb->cb */
+ pdesc->LINIP = tcb_desc->bLastIniPkt;
+ PktSize = (u16)(skb->len - USB_HWDESC_HEADER_LEN);
+ pdesc->PktSize = PktSize;
+ //printk("PKTSize = %d %x\n",pdesc->PktSize,pdesc->PktSize);
+ //----------------------------------------------------------------------------
+ // Fill up USB_OUT_CONTEXT.
+ //----------------------------------------------------------------------------
+ // Get index to out pipe from specified QueueID.
+ idx_pipe = txqueue2outpipe(priv,queue_index);
+ //printk("=============>%s queue_index:%d, outpipe:%d\n", __func__,queue_index,priv->RtOutPipes[idx_pipe]);
+
+#ifdef JOHN_DUMP_TXDESC
+ int i;
+ printk("Len = %d\n", skb->len);
+ for (i = 0; i < 8; i++)
+ printk("%2.2x ", *((u8*)skb->data+i));
+ printk("\n");
+#endif
+
+ usb_fill_bulk_urb(tx_urb,
+ priv->udev,
+ usb_sndbulkpipe(priv->udev,priv->RtOutPipes[idx_pipe]),
+ skb->data,
+ skb->len,
+ rtl8192_tx_isr,
+ skb);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ status = usb_submit_urb(tx_urb, GFP_ATOMIC);
+#else
+ status = usb_submit_urb(tx_urb);
+#endif
+
+ if (!status){
+ return 0;
+ }else{
+ printk("Error TX CMD URB, error %d",
+ status);
+ return -1;
+ }
+}
+#else
+short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //u8 *tx;
+ int status;
+ struct urb *tx_urb;
+ //int urb_buf_len;
+ unsigned int idx_pipe;
+ tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data;
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ u8 queue_index = tcb_desc->queue_index;
+
+ //printk("\n %s::queue_index = %d\n",__FUNCTION__, queue_index);
+ atomic_inc(&priv->tx_pending[queue_index]);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
+#else
+ tx_urb = usb_alloc_urb(0);
+#endif
+ if(!tx_urb){
+ dev_kfree_skb(skb);
+ return -ENOMEM;
+ }
+
+ memset(pdesc, 0, USB_HWDESC_HEADER_LEN);
+ /* Tx descriptor ought to be set according to the skb->cb */
+ pdesc->FirstSeg = 1;//bFirstSeg;
+ pdesc->LastSeg = 1;//bLastSeg;
+ pdesc->CmdInit = tcb_desc->bCmdOrInit;
+ pdesc->TxBufferSize = tcb_desc->txbuf_size;
+ pdesc->OWN = 1;
+ pdesc->LINIP = tcb_desc->bLastIniPkt;
+
+ //----------------------------------------------------------------------------
+ // Fill up USB_OUT_CONTEXT.
+ //----------------------------------------------------------------------------
+ // Get index to out pipe from specified QueueID.
+#ifndef USE_ONE_PIPE
+ idx_pipe = txqueue2outpipe(priv,queue_index);
+#else
+ idx_pipe = 0x04;
+#endif
+#ifdef JOHN_DUMP_TXDESC
+ int i;
+ printk("<Tx descriptor>--rate %x---",rate);
+ for (i = 0; i < 8; i++)
+ printk("%8x ", tx[i]);
+ printk("\n");
+#endif
+ usb_fill_bulk_urb(tx_urb,priv->udev, usb_sndbulkpipe(priv->udev,idx_pipe), \
+ skb->data, skb->len, rtl8192_tx_isr, skb);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ status = usb_submit_urb(tx_urb, GFP_ATOMIC);
+#else
+ status = usb_submit_urb(tx_urb);
+#endif
+
+ if (!status){
+ return 0;
+ }else{
+ DMESGE("Error TX CMD URB, error %d",
+ status);
+ return -1;
+ }
+}
+#endif
+
+/*
+ * Mapping Software/Hardware descriptor queue id to "Queue Select Field"
+ * in TxFwInfo data structure
+ * 2006.10.30 by Emily
+ *
+ * \param QUEUEID Software Queue
+*/
+u8 MapHwQueueToFirmwareQueue(u8 QueueID)
+{
+ u8 QueueSelect = 0x0; //defualt set to
+
+ switch(QueueID) {
+ case BE_QUEUE:
+ QueueSelect = QSLT_BE; //or QSelect = pTcb->priority;
+ break;
+
+ case BK_QUEUE:
+ QueueSelect = QSLT_BK; //or QSelect = pTcb->priority;
+ break;
+
+ case VO_QUEUE:
+ QueueSelect = QSLT_VO; //or QSelect = pTcb->priority;
+ break;
+
+ case VI_QUEUE:
+ QueueSelect = QSLT_VI; //or QSelect = pTcb->priority;
+ break;
+ case MGNT_QUEUE:
+ QueueSelect = QSLT_MGNT;
+ break;
+
+ case BEACON_QUEUE:
+ QueueSelect = QSLT_BEACON;
+ break;
+
+ // TODO: 2006.10.30 mark other queue selection until we verify it is OK
+ // TODO: Remove Assertions
+//#if (RTL819X_FPGA_VER & RTL819X_FPGA_GUANGAN_070502)
+ case TXCMD_QUEUE:
+ QueueSelect = QSLT_CMD;
+ break;
+//#endif
+ case HIGH_QUEUE:
+ QueueSelect = QSLT_HIGH;
+ break;
+
+ default:
+ RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID);
+ break;
+ }
+ return QueueSelect;
+}
+
+#ifdef RTL8192SU
+u8 MRateToHwRate8190Pci(u8 rate)
+{
+ u8 ret = DESC92S_RATE1M;
+
+ switch(rate)
+ {
+ // CCK and OFDM non-HT rates
+ case MGN_1M: ret = DESC92S_RATE1M; break;
+ case MGN_2M: ret = DESC92S_RATE2M; break;
+ case MGN_5_5M: ret = DESC92S_RATE5_5M; break;
+ case MGN_11M: ret = DESC92S_RATE11M; break;
+ case MGN_6M: ret = DESC92S_RATE6M; break;
+ case MGN_9M: ret = DESC92S_RATE9M; break;
+ case MGN_12M: ret = DESC92S_RATE12M; break;
+ case MGN_18M: ret = DESC92S_RATE18M; break;
+ case MGN_24M: ret = DESC92S_RATE24M; break;
+ case MGN_36M: ret = DESC92S_RATE36M; break;
+ case MGN_48M: ret = DESC92S_RATE48M; break;
+ case MGN_54M: ret = DESC92S_RATE54M; break;
+
+ // HT rates since here
+ case MGN_MCS0: ret = DESC92S_RATEMCS0; break;
+ case MGN_MCS1: ret = DESC92S_RATEMCS1; break;
+ case MGN_MCS2: ret = DESC92S_RATEMCS2; break;
+ case MGN_MCS3: ret = DESC92S_RATEMCS3; break;
+ case MGN_MCS4: ret = DESC92S_RATEMCS4; break;
+ case MGN_MCS5: ret = DESC92S_RATEMCS5; break;
+ case MGN_MCS6: ret = DESC92S_RATEMCS6; break;
+ case MGN_MCS7: ret = DESC92S_RATEMCS7; break;
+ case MGN_MCS8: ret = DESC92S_RATEMCS8; break;
+ case MGN_MCS9: ret = DESC92S_RATEMCS9; break;
+ case MGN_MCS10: ret = DESC92S_RATEMCS10; break;
+ case MGN_MCS11: ret = DESC92S_RATEMCS11; break;
+ case MGN_MCS12: ret = DESC92S_RATEMCS12; break;
+ case MGN_MCS13: ret = DESC92S_RATEMCS13; break;
+ case MGN_MCS14: ret = DESC92S_RATEMCS14; break;
+ case MGN_MCS15: ret = DESC92S_RATEMCS15; break;
+
+ // Set the highest SG rate
+ case MGN_MCS0_SG:
+ case MGN_MCS1_SG:
+ case MGN_MCS2_SG:
+ case MGN_MCS3_SG:
+ case MGN_MCS4_SG:
+ case MGN_MCS5_SG:
+ case MGN_MCS6_SG:
+ case MGN_MCS7_SG:
+ case MGN_MCS8_SG:
+ case MGN_MCS9_SG:
+ case MGN_MCS10_SG:
+ case MGN_MCS11_SG:
+ case MGN_MCS12_SG:
+ case MGN_MCS13_SG:
+ case MGN_MCS14_SG:
+ case MGN_MCS15_SG:
+ {
+ ret = DESC92S_RATEMCS15_SG;
+ break;
+ }
+
+ default: break;
+ }
+ return ret;
+}
+#else
+u8 MRateToHwRate8190Pci(u8 rate)
+{
+ u8 ret = DESC90_RATE1M;
+
+ switch(rate) {
+ case MGN_1M: ret = DESC90_RATE1M; break;
+ case MGN_2M: ret = DESC90_RATE2M; break;
+ case MGN_5_5M: ret = DESC90_RATE5_5M; break;
+ case MGN_11M: ret = DESC90_RATE11M; break;
+ case MGN_6M: ret = DESC90_RATE6M; break;
+ case MGN_9M: ret = DESC90_RATE9M; break;
+ case MGN_12M: ret = DESC90_RATE12M; break;
+ case MGN_18M: ret = DESC90_RATE18M; break;
+ case MGN_24M: ret = DESC90_RATE24M; break;
+ case MGN_36M: ret = DESC90_RATE36M; break;
+ case MGN_48M: ret = DESC90_RATE48M; break;
+ case MGN_54M: ret = DESC90_RATE54M; break;
+
+ // HT rate since here
+ case MGN_MCS0: ret = DESC90_RATEMCS0; break;
+ case MGN_MCS1: ret = DESC90_RATEMCS1; break;
+ case MGN_MCS2: ret = DESC90_RATEMCS2; break;
+ case MGN_MCS3: ret = DESC90_RATEMCS3; break;
+ case MGN_MCS4: ret = DESC90_RATEMCS4; break;
+ case MGN_MCS5: ret = DESC90_RATEMCS5; break;
+ case MGN_MCS6: ret = DESC90_RATEMCS6; break;
+ case MGN_MCS7: ret = DESC90_RATEMCS7; break;
+ case MGN_MCS8: ret = DESC90_RATEMCS8; break;
+ case MGN_MCS9: ret = DESC90_RATEMCS9; break;
+ case MGN_MCS10: ret = DESC90_RATEMCS10; break;
+ case MGN_MCS11: ret = DESC90_RATEMCS11; break;
+ case MGN_MCS12: ret = DESC90_RATEMCS12; break;
+ case MGN_MCS13: ret = DESC90_RATEMCS13; break;
+ case MGN_MCS14: ret = DESC90_RATEMCS14; break;
+ case MGN_MCS15: ret = DESC90_RATEMCS15; break;
+ case (0x80|0x20): ret = DESC90_RATEMCS32; break;
+
+ default: break;
+ }
+ return ret;
+}
+#endif
+
+u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
+{
+ u8 tmp_Short;
+
+ tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0);
+
+ if(TxHT==1 && TxRate != DESC90_RATEMCS15)
+ tmp_Short = 0;
+
+ return tmp_Short;
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+static void tx_zero_isr(struct urb *tx_urb, struct pt_regs *reg)
+#else
+static void tx_zero_isr(struct urb *tx_urb)
+#endif
+{
+ return;
+}
+
+
+#ifdef RTL8192SU
+/*
+ * The tx procedure is just as following, skb->cb will contain all the following
+ *information: * priority, morefrag, rate, &dev.
+ * */
+ // <Note> Buffer format for 8192S Usb bulk out:
+//
+// --------------------------------------------------
+// | 8192S Usb Tx Desc | 802_11_MAC_header | data |
+// --------------------------------------------------
+// | 32 bytes | 24 bytes |0-2318 bytes|
+// --------------------------------------------------
+// |<------------ BufferLen ------------------------->|
+
+short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
+ //tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);//92su del
+ struct usb_device *udev = priv->udev;
+ int pend;
+ int status;
+ struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
+ //int urb_len;
+ unsigned int idx_pipe;
+ u16 MPDUOverhead = 0;
+ //RT_DEBUG_DATA(COMP_SEND, tcb_desc, sizeof(cb_desc));
+
+#if 0
+ /* Added by Annie for filling Len_Adjust field. 2005-12-14. */
+ RT_ENC_ALG EncAlg = NO_Encryption;
+#endif
+
+
+ pend = atomic_read(&priv->tx_pending[tcb_desc->queue_index]);
+ /* we are locked here so the two atomic_read and inc are executed
+ * without interleaves * !!! For debug purpose */
+ if( pend > MAX_TX_URB){
+ switch (tcb_desc->queue_index) {
+ case VO_PRIORITY:
+ priv->stats.txvodrop++;
+ break;
+ case VI_PRIORITY:
+ priv->stats.txvidrop++;
+ break;
+ case BE_PRIORITY:
+ priv->stats.txbedrop++;
+ break;
+ default://BK_PRIORITY
+ priv->stats.txbkdrop++;
+ break;
+ }
+ printk("To discard skb packet!\n");
+ dev_kfree_skb_any(skb);
+ return -1;
+ }
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
+#else
+ tx_urb = usb_alloc_urb(0);
+#endif
+ if(!tx_urb){
+ dev_kfree_skb_any(skb);
+ return -ENOMEM;
+ }
+
+ memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
+
+
+#if RTL8192SU_FPGA_UNSPECIFIED_NETWORK
+ if(IsQoSDataFrame(skb->data))
+ {
+ tcb_desc->bAMPDUEnable = TRUE;
+ tx_desc->NonQos = 0;
+ }
+ else
+ tcb_desc->bAMPDUEnable = FALSE;
+
+ tcb_desc->bPacketBW = TRUE;
+ priv->CurrentChannelBW = HT_CHANNEL_WIDTH_20_40;
+#endif
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ tx_desc->NonQos = (IsQoSDataFrame(skb->data)==TRUE)? 0:1;
+#endif
+
+ /* Fill Tx descriptor */
+ //memset(tx_fwinfo,0,sizeof(tx_fwinfo_819x_usb));
+
+ // This part can just fill to the first descriptor of the frame.
+ /* DWORD 0 */
+ tx_desc->TxHT = (tcb_desc->data_rate&0x80)?1:0;
+
+#ifdef RTL8192SU_DISABLE_CCK_RATE
+ if(tx_hal_is_cck_rate(tcb_desc->data_rate))
+ tcb_desc->data_rate = MGN_6M;
+#endif
+
+ tx_desc->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
+ //tx_desc->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
+ tx_desc->TxShort = QueryIsShort(tx_desc->TxHT, tx_desc->TxRate, tcb_desc);
+
+
+ // Aggregation related
+ if(tcb_desc->bAMPDUEnable) {//AMPDU enabled
+ tx_desc->AllowAggregation = 1;
+ /* DWORD 1 */
+ //tx_fwinfo->RxMF = tcb_desc->ampdu_factor;
+ //tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity
+ } else {
+ tx_desc->AllowAggregation = 0;
+ /* DWORD 1 */
+ //tx_fwinfo->RxMF = 0;
+ //tx_fwinfo->RxAMD = 0;
+ }
+
+ //
+ // <Roger_Notes> For AMPDU case, we must insert SSN into TX_DESC,
+ // FW according as this SSN to do necessary packet retry.
+ // 2008.06.06.
+ //
+ {
+ u8 *pSeq;
+ u16 Temp;
+ //pSeq = (u8 *)(VirtualAddress+USB_HWDESC_HEADER_LEN + FRAME_OFFSET_SEQUENCE);
+ pSeq = (u8 *)(skb->data+USB_HWDESC_HEADER_LEN + 22);
+ Temp = pSeq[0];
+ Temp <<= 12;
+ Temp |= (*(u16 *)pSeq)>>4;
+ tx_desc->Seq = Temp;
+ }
+
+ /* Protection mode related */
+ tx_desc->RTSEn = (tcb_desc->bRTSEnable)?1:0;
+ tx_desc->CTS2Self = (tcb_desc->bCTSEnable)?1:0;
+ tx_desc->RTSSTBC = (tcb_desc->bRTSSTBC)?1:0;
+ tx_desc->RTSHT = (tcb_desc->rts_rate&0x80)?1:0;
+ tx_desc->RTSRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate);
+ tx_desc->RTSSubcarrier = (tx_desc->RTSHT==0)?(tcb_desc->RTSSC):0;
+ tx_desc->RTSBW = (tx_desc->RTSHT==1)?((tcb_desc->bRTSBW)?1:0):0;
+ tx_desc->RTSShort = (tx_desc->RTSHT==0)?(tcb_desc->bRTSUseShortPreamble?1:0):\
+ (tcb_desc->bRTSUseShortGI?1:0);
+ //LZM 090219
+ tx_desc->DisRTSFB = 0;
+ tx_desc->RTSRateFBLmt = 0xf;
+
+ // <Roger_EXP> 2008.09.22. We disable RTS rate fallback temporarily.
+ //tx_desc->DisRTSFB = 0x01;
+
+ /* Set Bandwidth and sub-channel settings. */
+ if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ {
+ if(tcb_desc->bPacketBW) {
+ tx_desc->TxBandwidth = 1;
+ tx_desc->TxSubCarrier = 0; //By SD3's Jerry suggestion, use duplicated mode
+ } else {
+ tx_desc->TxBandwidth = 0;
+ tx_desc->TxSubCarrier = priv->nCur40MhzPrimeSC;
+ }
+ } else {
+ tx_desc->TxBandwidth = 0;
+ tx_desc->TxSubCarrier = 0;
+ }
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if (tcb_desc->drv_agg_enable)
+ {
+ //tx_desc->Tx_INFO_RSVD = (tcb_desc->DrvAggrNum & 0x1f) << 1; //92su del
+ }
+#endif
+
+ //memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
+ /* DWORD 0 */
+ tx_desc->LINIP = 0;
+ //tx_desc->CmdInit = 1; //92su del
+ tx_desc->Offset = USB_HWDESC_HEADER_LEN;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if (tcb_desc->drv_agg_enable) {
+ tx_desc->PktSize = tcb_desc->pkt_size;//FIXLZM
+ } else
+#endif
+ {
+ tx_desc->PktSize = (skb->len - USB_HWDESC_HEADER_LEN) & 0xffff;
+ }
+
+ /*DWORD 1*/
+ //tx_desc->SecCAMID= 0;//92su del
+ tx_desc->RaBRSRID= tcb_desc->RATRIndex;
+//#ifdef RTL8192S_PREPARE_FOR_NORMAL_RELEASE
+#if 0//LZM 090219
+ tx_desc->RaBRSRID= 1;
+#endif
+
+#if 0
+ /* Fill security related */
+ if( pTcb->bEncrypt && !Adapter->MgntInfo.SecurityInfo.SWTxEncryptFlag)
+ {
+ EncAlg = SecGetEncryptionOverhead(
+ Adapter,
+ &EncryptionMPDUHeadOverhead,
+ &EncryptionMPDUTailOverhead,
+ NULL,
+ NULL,
+ FALSE,
+ FALSE);
+ //2004/07/22, kcwu, EncryptionMPDUHeadOverhead has been added in previous code
+ //MPDUOverhead = EncryptionMPDUHeadOverhead + EncryptionMPDUTailOverhead;
+ MPDUOverhead = EncryptionMPDUTailOverhead;
+ tx_desc->NoEnc = 0;
+ RT_TRACE(COMP_SEC, DBG_LOUD, ("******We in the loop SecCAMID is %d SecDescAssign is %d The Sec is %d********\n",tx_desc->SecCAMID,tx_desc->SecDescAssign,EncAlg));
+ //CamDumpAll(Adapter);
+ }
+ else
+#endif
+ {
+ MPDUOverhead = 0;
+ //tx_desc->NoEnc = 1;//92su del
+ }
+#if 0
+ switch(EncAlg){
+ case NO_Encryption:
+ tx_desc->SecType = 0x0;
+ break;
+ case WEP40_Encryption:
+ case WEP104_Encryption:
+ tx_desc->SecType = 0x1;
+ break;
+ case TKIP_Encryption:
+ tx_desc->SecType = 0x2;
+ break;
+ case AESCCMP_Encryption:
+ tx_desc->SecType = 0x3;
+ break;
+ default:
+ tx_desc->SecType = 0x0;
+ break;
+ }
+#else
+ tx_desc->SecType = 0x0;
+#endif
+ if (tcb_desc->bHwSec)
+ {
+ switch (priv->ieee80211->pairwise_key_type)
+ {
+ case KEY_TYPE_WEP40:
+ case KEY_TYPE_WEP104:
+ tx_desc->SecType = 0x1;
+ //tx_desc->NoEnc = 0;//92su del
+ break;
+ case KEY_TYPE_TKIP:
+ tx_desc->SecType = 0x2;
+ //tx_desc->NoEnc = 0;//92su del
+ break;
+ case KEY_TYPE_CCMP:
+ tx_desc->SecType = 0x3;
+ //tx_desc->NoEnc = 0;//92su del
+ break;
+ case KEY_TYPE_NA:
+ tx_desc->SecType = 0x0;
+ //tx_desc->NoEnc = 1;//92su del
+ break;
+ default:
+ tx_desc->SecType = 0x0;
+ //tx_desc->NoEnc = 1;//92su del
+ break;
+ }
+ }
+
+ //tx_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb);//92su del
+
+
+ tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate;
+ tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack;
+ tx_desc->DataRateFBLmt = 0x1F;// Alwasy enable all rate fallback range
+
+ tx_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index);
+
+
+ /* Fill fields that are required to be initialized in all of the descriptors */
+ //DWORD 0
+#if 0
+ tx_desc->FirstSeg = (tcb_desc->bFirstSeg)? 1:0;
+ tx_desc->LastSeg = (tcb_desc->bLastSeg)?1:0;
+#else
+ tx_desc->FirstSeg = 1;
+ tx_desc->LastSeg = 1;
+#endif
+ tx_desc->OWN = 1;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if (tcb_desc->drv_agg_enable) {
+ tx_desc->TxBufferSize = tcb_desc->pkt_size + sizeof(tx_fwinfo_819x_usb);
+ } else
+#endif
+ {
+ //DWORD 2
+ //tx_desc->TxBufferSize = (u32)(skb->len - USB_HWDESC_HEADER_LEN);
+ tx_desc->TxBufferSize = (u32)(skb->len);//92su mod FIXLZM
+ }
+
+#if 0
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(1)TxFillDescriptor8192SUsb(): DataRate(%#x)\n", pTcb->DataRate));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(2)TxFillDescriptor8192SUsb(): bTxUseDriverAssingedRate(%#x)\n", pTcb->bTxUseDriverAssingedRate));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(3)TxFillDescriptor8192SUsb(): bAMPDUEnable(%d)\n", pTcb->bAMPDUEnable));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(4)TxFillDescriptor8192SUsb(): bRTSEnable(%d)\n", pTcb->bRTSEnable));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(5)TxFillDescriptor8192SUsb(): RTSRate(%#x)\n", pTcb->RTSRate));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(6)TxFillDescriptor8192SUsb(): bCTSEnable(%d)\n", pTcb->bCTSEnable));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(7)TxFillDescriptor8192SUsb(): bUseShortGI(%d)\n", pTcb->bUseShortGI));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(8)TxFillDescriptor8192SUsb(): bPacketBW(%d)\n", pTcb->bPacketBW));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(9)TxFillDescriptor8192SUsb(): CurrentChannelBW(%d)\n", pHalData->CurrentChannelBW));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(10)TxFillDescriptor8192SUsb(): bTxDisableRateFallBack(%d)\n", pTcb->bTxDisableRateFallBack));
+ RT_TRACE(COMP_FPGA, DBG_LOUD, ("(11)TxFillDescriptor8192SUsb(): RATRIndex(%d)\n", pTcb->RATRIndex));
+#endif
+
+ /* Get index to out pipe from specified QueueID */
+ idx_pipe = txqueue2outpipe(priv,tcb_desc->queue_index);
+ //printk("=============>%s queue_index:%d, outpipe:%d\n", __func__,tcb_desc->queue_index,priv->RtOutPipes[idx_pipe]);
+
+ //RT_DEBUG_DATA(COMP_SEND,tx_fwinfo,sizeof(tx_fwinfo_819x_usb));
+ //RT_DEBUG_DATA(COMP_SEND,tx_desc,sizeof(tx_desc_819x_usb));
+
+ /* To submit bulk urb */
+ usb_fill_bulk_urb(tx_urb,
+ udev,
+ usb_sndbulkpipe(udev,priv->RtOutPipes[idx_pipe]),
+ skb->data,
+ skb->len, rtl8192_tx_isr, skb);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ status = usb_submit_urb(tx_urb, GFP_ATOMIC);
+#else
+ status = usb_submit_urb(tx_urb);
+#endif
+ if (!status){
+//we need to send 0 byte packet whenever 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has been transmitted. Otherwise, it will be halt to wait for another packet. WB. 2008.08.27
+ bool bSend0Byte = false;
+ u8 zero = 0;
+ if(udev->speed == USB_SPEED_HIGH)
+ {
+ if (skb->len > 0 && skb->len % 512 == 0)
+ bSend0Byte = true;
+ }
+ else
+ {
+ if (skb->len > 0 && skb->len % 64 == 0)
+ bSend0Byte = true;
+ }
+ if (bSend0Byte)
+ {
+#if 1
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ tx_urb_zero = usb_alloc_urb(0,GFP_ATOMIC);
+#else
+ tx_urb_zero = usb_alloc_urb(0);
+#endif
+ if(!tx_urb_zero){
+ RT_TRACE(COMP_ERR, "can't alloc urb for zero byte\n");
+ return -ENOMEM;
+ }
+ usb_fill_bulk_urb(tx_urb_zero,udev,
+ usb_sndbulkpipe(udev,idx_pipe), &zero,
+ 0, tx_zero_isr, dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
+#else
+ status = usb_submit_urb(tx_urb_zero);
+#endif
+ if (status){
+ RT_TRACE(COMP_ERR, "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status);
+ return -1;
+ }
+#endif
+ }
+ dev->trans_start = jiffies;
+ atomic_inc(&priv->tx_pending[tcb_desc->queue_index]);
+ return 0;
+ }else{
+ RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+ status);
+ return -1;
+ }
+}
+#else
+
+/*
+ * The tx procedure is just as following,
+ * skb->cb will contain all the following information,
+ * priority, morefrag, rate, &dev.
+ * */
+short rtl8192_tx(struct net_device *dev, struct sk_buff* skb)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
+ tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
+ struct usb_device *udev = priv->udev;
+ int pend;
+ int status;
+ struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
+ //int urb_len;
+ unsigned int idx_pipe;
+// RT_DEBUG_DATA(COMP_SEND, tcb_desc, sizeof(cb_desc));
+#if 0
+ /* Added by Annie for filling Len_Adjust field. 2005-12-14. */
+ RT_ENC_ALG EncAlg = NO_Encryption;
+#endif
+// printk("=============> %s\n", __FUNCTION__);
+ pend = atomic_read(&priv->tx_pending[tcb_desc->queue_index]);
+ /* we are locked here so the two atomic_read and inc are executed
+ * without interleaves
+ * !!! For debug purpose
+ */
+ if( pend > MAX_TX_URB){
+#if 0
+ switch (tcb_desc->queue_index) {
+ case VO_PRIORITY:
+ priv->stats.txvodrop++;
+ break;
+ case VI_PRIORITY:
+ priv->stats.txvidrop++;
+ break;
+ case BE_PRIORITY:
+ priv->stats.txbedrop++;
+ break;
+ default://BK_PRIORITY
+ priv->stats.txbkdrop++;
+ break;
+ }
+#endif
+ printk("To discard skb packet!\n");
+ dev_kfree_skb_any(skb);
+ return -1;
+ }
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
+#else
+ tx_urb = usb_alloc_urb(0);
+#endif
+ if(!tx_urb){
+ dev_kfree_skb_any(skb);
+ return -ENOMEM;
+ }
+
+ /* Fill Tx firmware info */
+ memset(tx_fwinfo,0,sizeof(tx_fwinfo_819x_usb));
+ /* DWORD 0 */
+ tx_fwinfo->TxHT = (tcb_desc->data_rate&0x80)?1:0;
+ tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
+ tx_fwinfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
+ tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, tcb_desc);
+ if(tcb_desc->bAMPDUEnable) {//AMPDU enabled
+ tx_fwinfo->AllowAggregation = 1;
+ /* DWORD 1 */
+ tx_fwinfo->RxMF = tcb_desc->ampdu_factor;
+ tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity
+ } else {
+ tx_fwinfo->AllowAggregation = 0;
+ /* DWORD 1 */
+ tx_fwinfo->RxMF = 0;
+ tx_fwinfo->RxAMD = 0;
+ }
+
+ /* Protection mode related */
+ tx_fwinfo->RtsEnable = (tcb_desc->bRTSEnable)?1:0;
+ tx_fwinfo->CtsEnable = (tcb_desc->bCTSEnable)?1:0;
+ tx_fwinfo->RtsSTBC = (tcb_desc->bRTSSTBC)?1:0;
+ tx_fwinfo->RtsHT = (tcb_desc->rts_rate&0x80)?1:0;
+ tx_fwinfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate);
+ tx_fwinfo->RtsSubcarrier = (tx_fwinfo->RtsHT==0)?(tcb_desc->RTSSC):0;
+ tx_fwinfo->RtsBandwidth = (tx_fwinfo->RtsHT==1)?((tcb_desc->bRTSBW)?1:0):0;
+ tx_fwinfo->RtsShort = (tx_fwinfo->RtsHT==0)?(tcb_desc->bRTSUseShortPreamble?1:0):\
+ (tcb_desc->bRTSUseShortGI?1:0);
+
+ /* Set Bandwidth and sub-channel settings. */
+ if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
+ {
+ if(tcb_desc->bPacketBW) {
+ tx_fwinfo->TxBandwidth = 1;
+ tx_fwinfo->TxSubCarrier = 0; //By SD3's Jerry suggestion, use duplicated mode
+ } else {
+ tx_fwinfo->TxBandwidth = 0;
+ tx_fwinfo->TxSubCarrier = priv->nCur40MhzPrimeSC;
+ }
+ } else {
+ tx_fwinfo->TxBandwidth = 0;
+ tx_fwinfo->TxSubCarrier = 0;
+ }
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if (tcb_desc->drv_agg_enable)
+ {
+ tx_fwinfo->Tx_INFO_RSVD = (tcb_desc->DrvAggrNum & 0x1f) << 1;
+ }
+#endif
+ /* Fill Tx descriptor */
+ memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
+ /* DWORD 0 */
+ tx_desc->LINIP = 0;
+ tx_desc->CmdInit = 1;
+ tx_desc->Offset = sizeof(tx_fwinfo_819x_usb) + 8;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if (tcb_desc->drv_agg_enable) {
+ tx_desc->PktSize = tcb_desc->pkt_size;
+ } else
+#endif
+ {
+ tx_desc->PktSize = (skb->len - TX_PACKET_SHIFT_BYTES) & 0xffff;
+ }
+
+ /*DWORD 1*/
+ tx_desc->SecCAMID= 0;
+ tx_desc->RATid = tcb_desc->RATRIndex;
+#if 0
+ /* Fill security related */
+ if( pTcb->bEncrypt && !Adapter->MgntInfo.SecurityInfo.SWTxEncryptFlag)
+ {
+ EncAlg = SecGetEncryptionOverhead(
+ Adapter,
+ &EncryptionMPDUHeadOverhead,
+ &EncryptionMPDUTailOverhead,
+ NULL,
+ NULL,
+ FALSE,
+ FALSE);
+ //2004/07/22, kcwu, EncryptionMPDUHeadOverhead has been added in previous code
+ //MPDUOverhead = EncryptionMPDUHeadOverhead + EncryptionMPDUTailOverhead;
+ MPDUOverhead = EncryptionMPDUTailOverhead;
+ tx_desc->NoEnc = 0;
+ RT_TRACE(COMP_SEC, DBG_LOUD, ("******We in the loop SecCAMID is %d SecDescAssign is %d The Sec is %d********\n",tx_desc->SecCAMID,tx_desc->SecDescAssign,EncAlg));
+ //CamDumpAll(Adapter);
+ }
+ else
+#endif
+ {
+ //MPDUOverhead = 0;
+ tx_desc->NoEnc = 1;
+ }
+#if 0
+ switch(EncAlg){
+ case NO_Encryption:
+ tx_desc->SecType = 0x0;
+ break;
+ case WEP40_Encryption:
+ case WEP104_Encryption:
+ tx_desc->SecType = 0x1;
+ break;
+ case TKIP_Encryption:
+ tx_desc->SecType = 0x2;
+ break;
+ case AESCCMP_Encryption:
+ tx_desc->SecType = 0x3;
+ break;
+ default:
+ tx_desc->SecType = 0x0;
+ break;
+ }
+#else
+ tx_desc->SecType = 0x0;
+#endif
+ if (tcb_desc->bHwSec)
+ {
+ switch (priv->ieee80211->pairwise_key_type)
+ {
+ case KEY_TYPE_WEP40:
+ case KEY_TYPE_WEP104:
+ tx_desc->SecType = 0x1;
+ tx_desc->NoEnc = 0;
+ break;
+ case KEY_TYPE_TKIP:
+ tx_desc->SecType = 0x2;
+ tx_desc->NoEnc = 0;
+ break;
+ case KEY_TYPE_CCMP:
+ tx_desc->SecType = 0x3;
+ tx_desc->NoEnc = 0;
+ break;
+ case KEY_TYPE_NA:
+ tx_desc->SecType = 0x0;
+ tx_desc->NoEnc = 1;
+ break;
+ }
+ }
+
+ tx_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index);
+ tx_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb);
+
+ tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack;
+ tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate;
+
+ /* Fill fields that are required to be initialized in all of the descriptors */
+ //DWORD 0
+#if 0
+ tx_desc->FirstSeg = (tcb_desc->bFirstSeg)? 1:0;
+ tx_desc->LastSeg = (tcb_desc->bLastSeg)?1:0;
+#else
+ tx_desc->FirstSeg = 1;
+ tx_desc->LastSeg = 1;
+#endif
+ tx_desc->OWN = 1;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if (tcb_desc->drv_agg_enable) {
+ tx_desc->TxBufferSize = tcb_desc->pkt_size + sizeof(tx_fwinfo_819x_usb);
+ } else
+#endif
+ {
+ //DWORD 2
+ tx_desc->TxBufferSize = (u32)(skb->len - USB_HWDESC_HEADER_LEN);
+ }
+ /* Get index to out pipe from specified QueueID */
+#ifndef USE_ONE_PIPE
+ idx_pipe = txqueue2outpipe(priv,tcb_desc->queue_index);
+#else
+ idx_pipe = 0x5;
+#endif
+
+ //RT_DEBUG_DATA(COMP_SEND,tx_fwinfo,sizeof(tx_fwinfo_819x_usb));
+ //RT_DEBUG_DATA(COMP_SEND,tx_desc,sizeof(tx_desc_819x_usb));
+
+ /* To submit bulk urb */
+ usb_fill_bulk_urb(tx_urb,udev,
+ usb_sndbulkpipe(udev,idx_pipe), skb->data,
+ skb->len, rtl8192_tx_isr, skb);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ status = usb_submit_urb(tx_urb, GFP_ATOMIC);
+#else
+ status = usb_submit_urb(tx_urb);
+#endif
+ if (!status){
+//we need to send 0 byte packet whenever 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has been transmitted. Otherwise, it will be halt to wait for another packet. WB. 2008.08.27
+ bool bSend0Byte = false;
+ u8 zero = 0;
+ if(udev->speed == USB_SPEED_HIGH)
+ {
+ if (skb->len > 0 && skb->len % 512 == 0)
+ bSend0Byte = true;
+ }
+ else
+ {
+ if (skb->len > 0 && skb->len % 64 == 0)
+ bSend0Byte = true;
+ }
+ if (bSend0Byte)
+ {
+#if 1
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ tx_urb_zero = usb_alloc_urb(0,GFP_ATOMIC);
+#else
+ tx_urb_zero = usb_alloc_urb(0);
+#endif
+ if(!tx_urb_zero){
+ RT_TRACE(COMP_ERR, "can't alloc urb for zero byte\n");
+ return -ENOMEM;
+ }
+ usb_fill_bulk_urb(tx_urb_zero,udev,
+ usb_sndbulkpipe(udev,idx_pipe), &zero,
+ 0, tx_zero_isr, dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
+#else
+ status = usb_submit_urb(tx_urb_zero);
+#endif
+ if (status){
+ RT_TRACE(COMP_ERR, "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status);
+ return -1;
+ }
+#endif
+ }
+ dev->trans_start = jiffies;
+ atomic_inc(&priv->tx_pending[tcb_desc->queue_index]);
+ return 0;
+ }else{
+ RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+ status);
+ return -1;
+ }
+}
+#endif
+
+#if 0
+void rtl8192_set_rate(struct net_device *dev)
+{
+ int i;
+ u16 word;
+ int basic_rate,min_rr_rate,max_rr_rate;
+
+// struct r8192_priv *priv = ieee80211_priv(dev);
+
+ //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
+// priv->ieee80211->state == IEEE80211_LINKED){
+ basic_rate = ieeerate2rtlrate(240);
+ min_rr_rate = ieeerate2rtlrate(60);
+ max_rr_rate = ieeerate2rtlrate(240);
+
+//
+// }else{
+// basic_rate = ieeerate2rtlrate(20);
+// min_rr_rate = ieeerate2rtlrate(10);
+// max_rr_rate = ieeerate2rtlrate(110);
+// }
+
+ write_nic_byte(dev, RESP_RATE,
+ max_rr_rate<<MAX_RESP_RATE_SHIFT| min_rr_rate<<MIN_RESP_RATE_SHIFT);
+
+ //word = read_nic_word(dev, BRSR);
+ word = read_nic_word(dev, BRSR_8187);
+ word &= ~BRSR_MBR_8185;
+
+
+ for(i=0;i<=basic_rate;i++)
+ word |= (1<<i);
+
+ //write_nic_word(dev, BRSR, word);
+ write_nic_word(dev, BRSR_8187, word);
+ //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
+}
+#endif
+
+
+#ifdef RTL8192SU
+void rtl8192SU_net_update(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ struct ieee80211_network *net = &priv->ieee80211->current_network;
+ //u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf;
+ u16 rate_config = 0;
+ u32 regTmp = 0;
+ u8 rateIndex = 0;
+ u8 retrylimit = 0x30;
+ u16 cap = net->capability;
+
+ priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE;
+
+//HW_VAR_BASIC_RATE
+ //update Basic rate: RR, BRSR
+ rtl8192_config_rate(dev, &rate_config); //HalSetBrateCfg
+
+#ifdef RTL8192SU_DISABLE_CCK_RATE
+ priv->basic_rate = rate_config = rate_config & 0x150; // Disable CCK 11M, 5.5M, 2M, and 1M rates.
+#else
+ priv->basic_rate = rate_config = rate_config & 0x15f;
+#endif
+
+ // Set RRSR rate table.
+ write_nic_byte(dev, RRSR, rate_config&0xff);
+ write_nic_byte(dev, RRSR+1, (rate_config>>8)&0xff);
+
+ // Set RTS initial rate
+ while(rate_config > 0x1)
+ {
+ rate_config = (rate_config>> 1);
+ rateIndex++;
+ }
+ write_nic_byte(dev, INIRTSMCS_SEL, rateIndex);
+//HW_VAR_BASIC_RATE
+
+ //set ack preample
+ regTmp = (priv->nCur40MhzPrimeSC) << 5;
+ if (priv->short_preamble)
+ regTmp |= 0x80;
+ write_nic_byte(dev, RRSR+2, regTmp);
+
+ write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]);
+ write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]);
+
+ write_nic_word(dev, BCN_INTERVAL, net->beacon_interval);
+ //2008.10.24 added by tynli for beacon changed.
+ PHY_SetBeaconHwReg( dev, net->beacon_interval);
+
+ rtl8192_update_cap(dev, cap);
+
+ if (ieee->iw_mode == IW_MODE_ADHOC){
+ retrylimit = 7;
+ //we should enable ibss interrupt here, but disable it temporarily
+ if (0){
+ priv->irq_mask |= (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
+ //rtl8192_irq_disable(dev);
+ //rtl8192_irq_enable(dev);
+ }
+ }
+ else{
+ if (0){
+ priv->irq_mask &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
+ //rtl8192_irq_disable(dev);
+ //rtl8192_irq_enable(dev);
+ }
+ }
+
+ priv->ShortRetryLimit = priv->LongRetryLimit = retrylimit;
+
+ write_nic_word(dev, RETRY_LIMIT,
+ retrylimit << RETRY_LIMIT_SHORT_SHIFT | \
+ retrylimit << RETRY_LIMIT_LONG_SHIFT);
+}
+
+void rtl8192SU_update_ratr_table(struct net_device* dev)
+{
+ struct r8192_priv* priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ u8* pMcsRate = ieee->dot11HTOperationalRateSet;
+ //struct ieee80211_network *net = &ieee->current_network;
+ u32 ratr_value = 0;
+
+ u8 rate_index = 0;
+ int WirelessMode = ieee->mode;
+ u8 MimoPs = ieee->pHTInfo->PeerMimoPs;
+
+ u8 bNMode = 0;
+
+ rtl8192_config_rate(dev, (u16*)(&ratr_value));
+ ratr_value |= (*(u16*)(pMcsRate)) << 12;
+
+ //switch (ieee->mode)
+ switch (WirelessMode)
+ {
+ case IEEE_A:
+ ratr_value &= 0x00000FF0;
+ break;
+ case IEEE_B:
+ ratr_value &= 0x0000000D;
+ break;
+ case IEEE_G:
+ ratr_value &= 0x00000FF5;
+ break;
+ case IEEE_N_24G:
+ case IEEE_N_5G:
+ {
+ bNMode = 1;
+
+ if (MimoPs == 0) //MIMO_PS_STATIC
+ {
+ ratr_value &= 0x0007F005;
+ }
+ else
+ { // MCS rate only => for 11N mode.
+ u32 ratr_mask;
+
+ // 1T2R or 1T1R, Spatial Stream 2 should be disabled
+ if ( priv->rf_type == RF_1T2R ||
+ priv->rf_type == RF_1T1R ||
+ (ieee->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_TX_2SS) )
+ ratr_mask = 0x000ff005;
+ else
+ ratr_mask = 0x0f0ff005;
+
+ if((ieee->pHTInfo->bCurTxBW40MHz) &&
+ !(ieee->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_TX_40_MHZ))
+ ratr_mask |= 0x00000010; // Set 6MBps
+
+ // Select rates for rate adaptive mechanism.
+ ratr_value &= ratr_mask;
+ }
+ }
+ break;
+ default:
+ if(0)
+ {
+ if(priv->rf_type == RF_1T2R) // 1T2R, Spatial Stream 2 should be disabled
+ {
+ ratr_value &= 0x000ff0f5;
+ }
+ else
+ {
+ ratr_value &= 0x0f0ff0f5;
+ }
+ }
+ //printk("====>%s(), mode is not correct:%x\n", __FUNCTION__, ieee->mode);
+ break;
+ }
+
+#ifdef RTL8192SU_DISABLE_CCK_RATE
+ ratr_value &= 0x0FFFFFF0;
+#else
+ ratr_value &= 0x0FFFFFFF;
+#endif
+
+ // Get MAX MCS available.
+ if ( (bNMode && ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_SHORT_GI)==0)) &&
+ ((ieee->pHTInfo->bCurBW40MHz && ieee->pHTInfo->bCurShortGI40MHz) ||
+ (!ieee->pHTInfo->bCurBW40MHz && ieee->pHTInfo->bCurShortGI20MHz)))
+ {
+ u8 shortGI_rate = 0;
+ u32 tmp_ratr_value = 0;
+ ratr_value |= 0x10000000;//???
+ tmp_ratr_value = (ratr_value>>12);
+ for(shortGI_rate=15; shortGI_rate>0; shortGI_rate--)
+ {
+ if((1<<shortGI_rate) & tmp_ratr_value)
+ break;
+ }
+ shortGI_rate = (shortGI_rate<<12)|(shortGI_rate<<8)|(shortGI_rate<<4)|(shortGI_rate);
+ write_nic_byte(dev, SG_RATE, shortGI_rate);
+ //printk("==>SG_RATE:%x\n", read_nic_byte(dev, SG_RATE));
+ }
+ write_nic_dword(dev, ARFR0+rate_index*4, ratr_value);
+ printk("=============>ARFR0+rate_index*4:%#x\n", ratr_value);
+
+ //2 UFWP
+ if (ratr_value & 0xfffff000){
+ //printk("===>set to N mode\n");
+ HalSetFwCmd8192S(dev, FW_CMD_RA_REFRESH_N);
+ }
+ else {
+ //printk("===>set to B/G mode\n");
+ HalSetFwCmd8192S(dev, FW_CMD_RA_REFRESH_BG);
+ }
+}
+
+void rtl8192SU_link_change(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ //unsigned long flags;
+ u32 reg = 0;
+
+ printk("=====>%s 1\n", __func__);
+ reg = read_nic_dword(dev, RCR);
+
+ if (ieee->state == IEEE80211_LINKED)
+ {
+
+ rtl8192SU_net_update(dev);
+ rtl8192SU_update_ratr_table(dev);
+ ieee->SetFwCmdHandler(dev, FW_CMD_HIGH_PWR_ENABLE);
+ priv->ReceiveConfig = reg |= RCR_CBSSID;
+
+ }else{
+ priv->ReceiveConfig = reg &= ~RCR_CBSSID;
+
+ }
+
+ write_nic_dword(dev, RCR, reg);
+ rtl8192_update_msr(dev);
+
+ printk("<=====%s 2\n", __func__);
+}
+#else
+extern void rtl8192_update_ratr_table(struct net_device* dev);
+void rtl8192_link_change(struct net_device *dev)
+{
+// int i;
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ //write_nic_word(dev, BCN_INTR_ITV, net->beacon_interval);
+ if (ieee->state == IEEE80211_LINKED)
+ {
+ rtl8192_net_update(dev);
+ rtl8192_update_ratr_table(dev);
+#if 1
+ //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08
+ if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type))
+ EnableHWSecurityConfig8192(dev);
+#endif
+ }
+ /*update timing params*/
+// RT_TRACE(COMP_CH, "========>%s(), chan:%d\n", __FUNCTION__, priv->chan);
+// rtl8192_set_chan(dev, priv->chan);
+ if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC)
+ {
+ u32 reg = 0;
+ reg = read_nic_dword(dev, RCR);
+ if (priv->ieee80211->state == IEEE80211_LINKED)
+ priv->ReceiveConfig = reg |= RCR_CBSSID;
+ else
+ priv->ReceiveConfig = reg &= ~RCR_CBSSID;
+ write_nic_dword(dev, RCR, reg);
+ }
+
+// rtl8192_set_rxconf(dev);
+}
+#endif
+
+static struct ieee80211_qos_parameters def_qos_parameters = {
+ {3,3,3,3},/* cw_min */
+ {7,7,7,7},/* cw_max */
+ {2,2,2,2},/* aifs */
+ {0,0,0,0},/* flags */
+ {0,0,0,0} /* tx_op_limit */
+};
+
+
+#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
+void rtl8192_update_beacon(struct work_struct * work)
+{
+ struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+void rtl8192_update_beacon(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+ struct ieee80211_device* ieee = priv->ieee80211;
+ struct ieee80211_network* net = &ieee->current_network;
+
+ if (ieee->pHTInfo->bCurrentHTSupport)
+ HTUpdateSelfAndPeerSetting(ieee, net);
+ ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime;
+ // Joseph test for turbo mode with AP
+ ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode;
+ rtl8192_update_cap(dev, net->capability);
+}
+/*
+* background support to run QoS activate functionality
+*/
+int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO};
+#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
+void rtl8192_qos_activate(struct work_struct * work)
+{
+ struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+void rtl8192_qos_activate(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+ struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
+ u8 mode = priv->ieee80211->current_network.mode;
+ //u32 size = sizeof(struct ieee80211_qos_parameters);
+ u8 u1bAIFS;
+ u32 u4bAcParam;
+ int i;
+
+ if (priv == NULL)
+ return;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
+ down(&priv->mutex);
+#else
+ mutex_lock(&priv->mutex);
+#endif
+ if(priv->ieee80211->state != IEEE80211_LINKED)
+ goto success;
+ RT_TRACE(COMP_QOS,"qos active process with associate response received\n");
+ /* It better set slot time at first */
+ /* For we just support b/g mode at present, let the slot time at 9/20 selection */
+ /* update the ac parameter to related registers */
+ for(i = 0; i < QOS_QUEUE_NUM; i++) {
+ //Mode G/A: slotTimeTimer = 9; Mode B: 20
+ u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime;
+ u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)|
+ (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)|
+ (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)|
+ ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
+
+ write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);
+ //write_nic_dword(dev, WDCAPARA_ADD[i], 0x005e4322);
+ }
+
+success:
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
+ up(&priv->mutex);
+#else
+ mutex_unlock(&priv->mutex);
+#endif
+}
+
+static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
+ int active_network,
+ struct ieee80211_network *network)
+{
+ int ret = 0;
+ u32 size = sizeof(struct ieee80211_qos_parameters);
+
+ if(priv->ieee80211->state !=IEEE80211_LINKED)
+ return ret;
+
+ if ((priv->ieee80211->iw_mode != IW_MODE_INFRA))
+ return ret;
+
+ if (network->flags & NETWORK_HAS_QOS_MASK) {
+ if (active_network &&
+ (network->flags & NETWORK_HAS_QOS_PARAMETERS))
+ network->qos_data.active = network->qos_data.supported;
+
+ if ((network->qos_data.active == 1) && (active_network == 1) &&
+ (network->flags & NETWORK_HAS_QOS_PARAMETERS) &&
+ (network->qos_data.old_param_count !=
+ network->qos_data.param_count)) {
+ network->qos_data.old_param_count =
+ network->qos_data.param_count;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(priv->priv_wq, &priv->qos_activate);
+#else
+ schedule_task(&priv->qos_activate);
+#endif
+ RT_TRACE (COMP_QOS, "QoS parameters change call "
+ "qos_activate\n");
+ }
+ } else {
+ memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
+ &def_qos_parameters, size);
+
+ if ((network->qos_data.active == 1) && (active_network == 1)) {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(priv->priv_wq, &priv->qos_activate);
+#else
+ schedule_task(&priv->qos_activate);
+#endif
+ RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n");
+ }
+ network->qos_data.active = 0;
+ network->qos_data.supported = 0;
+ }
+
+ return 0;
+}
+
+/* handle manage frame frame beacon and probe response */
+static int rtl8192_handle_beacon(struct net_device * dev,
+ struct ieee80211_beacon * beacon,
+ struct ieee80211_network * network)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ rtl8192_qos_handle_probe_response(priv,1,network);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0);
+#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->update_beacon_wq);
+#else
+ queue_work(priv->priv_wq, &priv->update_beacon_wq);
+#endif
+
+#endif
+ return 0;
+
+}
+
+/*
+* handling the beaconing responses. if we get different QoS setting
+* off the network from the associated setting, adjust the QoS
+* setting
+*/
+static int rtl8192_qos_association_resp(struct r8192_priv *priv,
+ struct ieee80211_network *network)
+{
+ int ret = 0;
+ unsigned long flags;
+ u32 size = sizeof(struct ieee80211_qos_parameters);
+ int set_qos_param = 0;
+
+ if ((priv == NULL) || (network == NULL))
+ return ret;
+
+ if(priv->ieee80211->state !=IEEE80211_LINKED)
+ return ret;
+
+ if ((priv->ieee80211->iw_mode != IW_MODE_INFRA))
+ return ret;
+
+ spin_lock_irqsave(&priv->ieee80211->lock, flags);
+ if(network->flags & NETWORK_HAS_QOS_PARAMETERS) {
+ memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
+ &network->qos_data.parameters,\
+ sizeof(struct ieee80211_qos_parameters));
+ priv->ieee80211->current_network.qos_data.active = 1;
+#if 0
+ if((priv->ieee80211->current_network.qos_data.param_count != \
+ network->qos_data.param_count))
+#endif
+ {
+ set_qos_param = 1;
+ /* update qos parameter for current network */
+ priv->ieee80211->current_network.qos_data.old_param_count = \
+ priv->ieee80211->current_network.qos_data.param_count;
+ priv->ieee80211->current_network.qos_data.param_count = \
+ network->qos_data.param_count;
+ }
+ } else {
+ memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
+ &def_qos_parameters, size);
+ priv->ieee80211->current_network.qos_data.active = 0;
+ priv->ieee80211->current_network.qos_data.supported = 0;
+ set_qos_param = 1;
+ }
+
+ spin_unlock_irqrestore(&priv->ieee80211->lock, flags);
+
+ RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n",__FUNCTION__,network->flags ,priv->ieee80211->current_network.qos_data.active);
+ if (set_qos_param == 1)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(priv->priv_wq, &priv->qos_activate);
+#else
+ schedule_task(&priv->qos_activate);
+#endif
+
+
+ return ret;
+}
+
+
+static int rtl8192_handle_assoc_response(struct net_device *dev,
+ struct ieee80211_assoc_response_frame *resp,
+ struct ieee80211_network *network)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ rtl8192_qos_association_resp(priv, network);
+ return 0;
+}
+
+
+void rtl8192_update_ratr_table(struct net_device* dev)
+ // POCTET_STRING posLegacyRate,
+ // u8* pMcsRate)
+ // PRT_WLAN_STA pEntry)
+{
+ struct r8192_priv* priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ u8* pMcsRate = ieee->dot11HTOperationalRateSet;
+ //struct ieee80211_network *net = &ieee->current_network;
+ u32 ratr_value = 0;
+ u8 rate_index = 0;
+ rtl8192_config_rate(dev, (u16*)(&ratr_value));
+ ratr_value |= (*(u16*)(pMcsRate)) << 12;
+// switch (net->mode)
+ switch (ieee->mode)
+ {
+ case IEEE_A:
+ ratr_value &= 0x00000FF0;
+ break;
+ case IEEE_B:
+ ratr_value &= 0x0000000F;
+ break;
+ case IEEE_G:
+ ratr_value &= 0x00000FF7;
+ break;
+ case IEEE_N_24G:
+ case IEEE_N_5G:
+ if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC
+ ratr_value &= 0x0007F007;
+ else{
+ if (priv->rf_type == RF_1T2R)
+ ratr_value &= 0x000FF007;
+ else
+ ratr_value &= 0x0F81F007;
+ }
+ break;
+ default:
+ break;
+ }
+ ratr_value &= 0x0FFFFFFF;
+ if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){
+ ratr_value |= 0x80000000;
+ }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){
+ ratr_value |= 0x80000000;
+ }
+ write_nic_dword(dev, RATR0+rate_index*4, ratr_value);
+ write_nic_byte(dev, UFWP, 1);
+}
+
+static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04};
+static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04};
+bool GetNmodeSupportBySecCfg8192(struct net_device*dev)
+{
+#if 1
+ struct r8192_priv* priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ struct ieee80211_network * network = &ieee->current_network;
+ int wpa_ie_len= ieee->wpa_ie_len;
+ struct ieee80211_crypt_data* crypt;
+ int encrypt;
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ return TRUE;
+#endif
+
+ crypt = ieee->crypt[ieee->tx_keyidx];
+ //we use connecting AP's capability instead of only security config on our driver to distinguish whether it should use N mode or G mode
+ encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) || (ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name,"WEP")));
+
+ /* simply judge */
+ if(encrypt && (wpa_ie_len == 0)) {
+ /* wep encryption, no N mode setting */
+ return false;
+// } else if((wpa_ie_len != 0)&&(memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) {
+ } else if((wpa_ie_len != 0)) {
+ /* parse pairwise key type */
+ //if((pairwisekey = WEP40)||(pairwisekey = WEP104)||(pairwisekey = TKIP))
+ if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4))))
+ return true;
+ else
+ return false;
+ } else {
+ return true;
+ }
+
+#if 0
+ //In here we discuss with SD4 David. He think we still can send TKIP in broadcast group key in MCS rate.
+ //We can't force in G mode if Pairwie key is AES and group key is TKIP
+ if((pSecInfo->GroupEncAlgorithm == WEP104_Encryption) || (pSecInfo->GroupEncAlgorithm == WEP40_Encryption) ||
+ (pSecInfo->PairwiseEncAlgorithm == WEP104_Encryption) ||
+ (pSecInfo->PairwiseEncAlgorithm == WEP40_Encryption) || (pSecInfo->PairwiseEncAlgorithm == TKIP_Encryption))
+ {
+ return false;
+ }
+ else
+ return true;
+#endif
+ return true;
+#endif
+}
+
+bool GetHalfNmodeSupportByAPs819xUsb(struct net_device* dev)
+{
+ bool Reval;
+ struct r8192_priv* priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+
+// Added by Roger, 2008.08.29.
+#ifdef RTL8192SU
+ return false;
+#endif
+
+ if(ieee->bHalfWirelessN24GMode == true)
+ Reval = true;
+ else
+ Reval = false;
+
+ return Reval;
+}
+
+void rtl8192_refresh_supportrate(struct r8192_priv* priv)
+{
+ struct ieee80211_device* ieee = priv->ieee80211;
+ //we donot consider set support rate for ABG mode, only HT MCS rate is set here.
+ if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G)
+ {
+ memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16);
+ //RT_DEBUG_DATA(COMP_INIT, ieee->RegHTSuppRateSet, 16);
+ //RT_DEBUG_DATA(COMP_INIT, ieee->Regdot11HTOperationalRateSet, 16);
+ }
+ else
+ memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
+ return;
+}
+
+u8 rtl8192_getSupportedWireleeMode(struct net_device*dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 ret = 0;
+ switch(priv->rf_chip)
+ {
+ case RF_8225:
+ case RF_8256:
+ case RF_PSEUDO_11N:
+ case RF_6052:
+ ret = (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B);
+ break;
+ case RF_8258:
+ ret = (WIRELESS_MODE_A|WIRELESS_MODE_N_5G);
+ break;
+ default:
+ ret = WIRELESS_MODE_B;
+ break;
+ }
+ return ret;
+}
+void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev);
+
+#if 1
+ if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0))
+ {
+ if(bSupportMode & WIRELESS_MODE_N_24G)
+ {
+ wireless_mode = WIRELESS_MODE_N_24G;
+ }
+ else if(bSupportMode & WIRELESS_MODE_N_5G)
+ {
+ wireless_mode = WIRELESS_MODE_N_5G;
+ }
+ else if((bSupportMode & WIRELESS_MODE_A))
+ {
+ wireless_mode = WIRELESS_MODE_A;
+ }
+ else if((bSupportMode & WIRELESS_MODE_G))
+ {
+ wireless_mode = WIRELESS_MODE_G;
+ }
+ else if((bSupportMode & WIRELESS_MODE_B))
+ {
+ wireless_mode = WIRELESS_MODE_B;
+ }
+ else{
+ RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode);
+ wireless_mode = WIRELESS_MODE_B;
+ }
+ }
+#ifdef TO_DO_LIST //// TODO: this function doesn't work well at this time, we shoud wait for FPGA
+ ActUpdateChannelAccessSetting( pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting );
+#endif
+#ifdef RTL8192SU
+ //LZM 090306 usb crash here, mark it temp
+ //write_nic_word(dev, SIFS_OFDM, 0x0e0e);
+#endif
+ priv->ieee80211->mode = wireless_mode;
+
+ if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G))
+ priv->ieee80211->pHTInfo->bEnableHT = 1;
+ else
+ priv->ieee80211->pHTInfo->bEnableHT = 0;
+ RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode);
+ rtl8192_refresh_supportrate(priv);
+#endif
+
+}
+
+
+short rtl8192_is_tx_queue_empty(struct net_device *dev)
+{
+ int i=0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //struct ieee80211_device* ieee = priv->ieee80211;
+ for (i=0; i<=MGNT_QUEUE; i++)
+ {
+ if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) )
+ continue;
+ if (atomic_read(&priv->tx_pending[i]))
+ {
+ printk("===>tx queue is not empty:%d, %d\n", i, atomic_read(&priv->tx_pending[i]));
+ return 0;
+ }
+ }
+ return 1;
+}
+#if 0
+void rtl8192_rq_tx_ack(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ priv->ieee80211->ack_tx_to_ieee = 1;
+}
+#endif
+void rtl8192_hw_sleep_down(struct net_device *dev)
+{
+ RT_TRACE(COMP_POWER, "%s()============>come to sleep down\n", __FUNCTION__);
+#ifdef TODO
+// MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
+#endif
+}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void rtl8192_hw_sleep_wq (struct work_struct *work)
+{
+// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
+// struct ieee80211_device * ieee = (struct ieee80211_device*)
+// container_of(work, struct ieee80211_device, watch_dog_wq);
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);
+ struct net_device *dev = ieee->dev;
+#else
+void rtl8192_hw_sleep_wq(struct net_device* dev)
+{
+#endif
+ //printk("=========>%s()\n", __FUNCTION__);
+ rtl8192_hw_sleep_down(dev);
+}
+// printk("dev is %d\n",dev);
+// printk("&*&(^*(&(&=========>%s()\n", __FUNCTION__);
+void rtl8192_hw_wakeup(struct net_device* dev)
+{
+// u32 flags = 0;
+
+// spin_lock_irqsave(&priv->ps_lock,flags);
+ RT_TRACE(COMP_POWER, "%s()============>come to wake up\n", __FUNCTION__);
+#ifdef TODO
+// MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
+#endif
+ //FIXME: will we send package stored while nic is sleep?
+// spin_unlock_irqrestore(&priv->ps_lock,flags);
+}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void rtl8192_hw_wakeup_wq (struct work_struct *work)
+{
+// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
+// struct ieee80211_device * ieee = (struct ieee80211_device*)
+// container_of(work, struct ieee80211_device, watch_dog_wq);
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);
+ struct net_device *dev = ieee->dev;
+#else
+void rtl8192_hw_wakeup_wq(struct net_device* dev)
+{
+#endif
+ rtl8192_hw_wakeup(dev);
+
+}
+
+#define MIN_SLEEP_TIME 50
+#define MAX_SLEEP_TIME 10000
+void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ u32 rb = jiffies;
+ unsigned long flags;
+
+ spin_lock_irqsave(&priv->ps_lock,flags);
+
+ /* Writing HW register with 0 equals to disable
+ * the timer, that is not really what we want
+ */
+ tl -= MSECS(4+16+7);
+
+ //if(tl == 0) tl = 1;
+
+ /* FIXME HACK FIXME HACK */
+// force_pci_posting(dev);
+ //mdelay(1);
+
+// rb = read_nic_dword(dev, TSFTR);
+
+ /* If the interval in witch we are requested to sleep is too
+ * short then give up and remain awake
+ */
+ if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME))
+ ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) {
+ spin_unlock_irqrestore(&priv->ps_lock,flags);
+ printk("too short to sleep\n");
+ return;
+ }
+
+// write_nic_dword(dev, TimerInt, tl);
+// rb = read_nic_dword(dev, TSFTR);
+ {
+ u32 tmp = (tl>rb)?(tl-rb):(rb-tl);
+ // if (tl<rb)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->ieee80211->hw_wakeup_wq);
+#else
+ queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); //as tl may be less than rb
+#endif
+ }
+ /* if we suspect the TimerInt is gone beyond tl
+ * while setting it, then give up
+ */
+#if 1
+ if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))||
+ ((tl < rb) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))) {
+ printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME));
+ spin_unlock_irqrestore(&priv->ps_lock,flags);
+ return;
+ }
+#endif
+// if(priv->rf_sleep)
+// priv->rf_sleep(dev);
+
+ //printk("<=========%s()\n", __FUNCTION__);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->ieee80211->hw_sleep_wq);
+#else
+ queue_delayed_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq,0);
+#endif
+ spin_unlock_irqrestore(&priv->ps_lock,flags);
+}
+//init priv variables here. only non_zero value should be initialized here.
+static void rtl8192_init_priv_variable(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 i;
+ priv->card_8192 = NIC_8192U;
+ priv->chan = 1; //set to channel 1
+ priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO
+ priv->ieee80211->iw_mode = IW_MODE_INFRA;
+ priv->ieee80211->ieee_up=0;
+ priv->retry_rts = DEFAULT_RETRY_RTS;
+ priv->retry_data = DEFAULT_RETRY_DATA;
+ priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD;
+ priv->ieee80211->rate = 110; //11 mbps
+ priv->ieee80211->short_slot = 1;
+ priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
+ priv->CckPwEnl = 6;
+ //for silent reset
+ priv->IrpPendingCount = 1;
+ priv->ResetProgress = RESET_TYPE_NORESET;
+ priv->bForcedSilentReset = 0;
+ priv->bDisableNormalResetCheck = false;
+ priv->force_reset = false;
+
+ priv->ieee80211->FwRWRF = 0; //we don't use FW read/write RF until stable firmware is available.
+ priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
+ priv->ieee80211->iw_mode = IW_MODE_INFRA;
+ priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
+ IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
+ IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
+ IEEE_SOFTMAC_BEACONS;//added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE;
+
+ priv->ieee80211->active_scan = 1;
+ priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
+ priv->ieee80211->host_encrypt = 1;
+ priv->ieee80211->host_decrypt = 1;
+ priv->ieee80211->start_send_beacons = NULL;//rtl819xusb_beacon_tx;//-by amy 080604
+ priv->ieee80211->stop_send_beacons = NULL;//rtl8192_beacon_stop;//-by amy 080604
+ priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit;
+ priv->ieee80211->set_chan = rtl8192_set_chan;
+ priv->ieee80211->link_change = priv->ops->rtl819x_link_change;
+ priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit;
+ priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop;
+ priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume;
+ priv->ieee80211->init_wmmparam_flag = 0;
+ priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
+ priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc;
+ priv->ieee80211->tx_headroom = TX_PACKET_SHIFT_BYTES;
+ priv->ieee80211->qos_support = 1;
+
+ //added by WB
+// priv->ieee80211->SwChnlByTimerHandler = rtl8192_phy_SwChnl;
+ priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode;
+ priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response;
+ priv->ieee80211->handle_beacon = rtl8192_handle_beacon;
+ //for LPS
+ priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup;
+// priv->ieee80211->ps_request_tx_ack = rtl8192_rq_tx_ack;
+ priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep;
+ priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty;
+ //added by david
+ priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8192;
+ priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xUsb;
+ priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode;
+ //added by amy
+ priv->ieee80211->InitialGainHandler = priv->ops->rtl819x_initial_gain;
+ priv->card_type = USB;
+
+#ifdef RTL8192SU
+//1 RTL8192SU/
+ priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
+ priv->ieee80211->SetFwCmdHandler = HalSetFwCmd8192S;
+ priv->bRFSiOrPi = 0;//o=si,1=pi;
+ //lzm add
+ priv->bInHctTest = false;
+
+ priv->MidHighPwrTHR_L1 = 0x3B;
+ priv->MidHighPwrTHR_L2 = 0x40;
+
+ if(priv->bInHctTest)
+ {
+ priv->ShortRetryLimit = HAL_RETRY_LIMIT_AP_ADHOC;
+ priv->LongRetryLimit = HAL_RETRY_LIMIT_AP_ADHOC;
+ }
+ else
+ {
+ priv->ShortRetryLimit = HAL_RETRY_LIMIT_INFRA;
+ priv->LongRetryLimit = HAL_RETRY_LIMIT_INFRA;
+ }
+
+ priv->SetFwCmdInProgress = false; //is set FW CMD in Progress? 92S only
+ priv->CurrentFwCmdIO = 0;
+
+ priv->MinSpaceCfg = 0;
+
+ priv->EarlyRxThreshold = 7;
+ priv->enable_gpio0 = 0;
+ priv->TransmitConfig =
+ ((u32)TCR_MXDMA_2048<<TCR_MXDMA_OFFSET) | // Max DMA Burst Size per Tx DMA Burst, 7: reservied.
+ (priv->ShortRetryLimit<<TCR_SRL_OFFSET) | // Short retry limit
+ (priv->LongRetryLimit<<TCR_LRL_OFFSET) | // Long retry limit
+ (false ? TCR_SAT : 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
+ if(priv->bInHctTest)
+ priv->ReceiveConfig = //priv->CSMethod |
+ RCR_AMF | RCR_ADF | //RCR_AAP | //accept management/data
+ RCR_ACF |RCR_APPFCS| //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
+ RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC
+ RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet
+ RCR_APP_PHYST_STAFF | RCR_APP_PHYST_RXFF | // Accept PHY status
+ ((u32)7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
+ (priv->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold.
+ (priv->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt:0);
+ else
+ priv->ReceiveConfig = //priv->CSMethod |
+ RCR_AMF | RCR_ADF | RCR_AB |
+ RCR_AM | RCR_APM |RCR_AAP |RCR_ADD3|RCR_APP_ICV|
+ RCR_APP_PHYST_STAFF | RCR_APP_PHYST_RXFF | // Accept PHY status
+ RCR_APP_MIC | RCR_APPFCS;
+
+ // <Roger_EXP> 2008.06.16.
+ priv->IntrMask = (u16)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | \
+ IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | \
+ IMR_BDOK | IMR_RXCMDOK | /*IMR_TIMEOUT0 |*/ IMR_RDU | IMR_RXFOVW | \
+ IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
+
+//1 End
+
+#else
+
+#ifdef TO_DO_LIST
+ if(Adapter->bInHctTest)
+ {
+ pHalData->ShortRetryLimit = 7;
+ pHalData->LongRetryLimit = 7;
+ }
+#endif
+ {
+ priv->ShortRetryLimit = 0x30;
+ priv->LongRetryLimit = 0x30;
+ }
+ priv->EarlyRxThreshold = 7;
+ priv->enable_gpio0 = 0;
+ priv->TransmitConfig =
+ // TCR_DurProcMode | //for RTL8185B, duration setting by HW
+ //? TCR_DISReqQsize |
+ (TCR_MXDMA_2048<<TCR_MXDMA_OFFSET)| // Max DMA Burst Size per Tx DMA Burst, 7: reservied.
+ (priv->ShortRetryLimit<<TCR_SRL_OFFSET)| // Short retry limit
+ (priv->LongRetryLimit<<TCR_LRL_OFFSET) | // Long retry limit
+ (false ? TCR_SAT: 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
+#ifdef TO_DO_LIST
+ if(Adapter->bInHctTest)
+ pHalData->ReceiveConfig = pHalData->CSMethod |
+ RCR_AMF | RCR_ADF | //RCR_AAP | //accept management/data
+ //guangan200710
+ RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
+ RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC
+ RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet
+ ((u32)7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
+ (pHalData->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold.
+ (pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt:0);
+ else
+
+#endif
+ priv->ReceiveConfig =
+ RCR_AMF | RCR_ADF | //accept management/data
+ RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
+ RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC
+ //RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet
+ ((u32)7<<RCR_MXDMA_OFFSET)| // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
+ (priv->EarlyRxThreshold<<RX_FIFO_THRESHOLD_SHIFT) | // Rx FIFO Threshold, 7: No Rx threshold.
+ (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT:0);
+#endif
+
+ priv->AcmControl = 0;
+ priv->pFirmware = (rt_firmware*)vmalloc(sizeof(rt_firmware));
+ if (priv->pFirmware)
+ memset(priv->pFirmware, 0, sizeof(rt_firmware));
+
+ /* rx related queue */
+ skb_queue_head_init(&priv->rx_queue);
+ skb_queue_head_init(&priv->skb_queue);
+
+ /* Tx related queue */
+ for(i = 0; i < MAX_QUEUE_SIZE; i++) {
+ skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]);
+ }
+ for(i = 0; i < MAX_QUEUE_SIZE; i++) {
+ skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]);
+ }
+ for(i = 0; i < MAX_QUEUE_SIZE; i++) {
+ skb_queue_head_init(&priv->ieee80211->skb_drv_aggQ [i]);
+ }
+ priv->rf_set_chan = rtl8192_phy_SwChnl;
+}
+
+//init lock here
+static void rtl8192_init_priv_lock(struct r8192_priv* priv)
+{
+ spin_lock_init(&priv->tx_lock);
+ spin_lock_init(&priv->irq_lock);//added by thomas
+ //spin_lock_init(&priv->rf_lock);//use rf_sem, or will crash in some OS.
+ sema_init(&priv->wx_sem,1);
+ sema_init(&priv->rf_sem,1);
+ spin_lock_init(&priv->ps_lock);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
+ sema_init(&priv->mutex, 1);
+#else
+ mutex_init(&priv->mutex);
+#endif
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void rtl819x_watchdog_wqcallback(struct work_struct *work);
+#else
+extern void rtl819x_watchdog_wqcallback(struct net_device *dev);
+#endif
+
+void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
+//init tasklet and wait_queue here. only 2.6 above kernel is considered
+#define DRV_NAME "wlan0"
+static void rtl8192_init_priv_task(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#ifdef PF_SYNCTHREAD
+ priv->priv_wq = create_workqueue(DRV_NAME,0);
+#else
+ priv->priv_wq = create_workqueue(DRV_NAME);
+#endif
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+ INIT_WORK(&priv->reset_wq, rtl8192_restart);
+
+ //INIT_DELAYED_WORK(&priv->watch_dog_wq, hal_dm_watchdog);
+ INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback);
+ INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback);
+// INIT_DELAYED_WORK(&priv->gpio_change_rf_wq, dm_gpio_change_rf_callback);
+ INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback);
+ INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon);
+ INIT_DELAYED_WORK(&priv->initialgain_operate_wq, InitialGainOperateWorkItemCallBack);
+ //INIT_WORK(&priv->SwChnlWorkItem, rtl8192_SwChnl_WorkItem);
+ //INIT_WORK(&priv->SetBWModeWorkItem, rtl8192_SetBWModeWorkItem);
+ INIT_WORK(&priv->qos_activate, rtl8192_qos_activate);
+ INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq);
+ INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq);
+
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+ tq_init(&priv->reset_wq, (void*)rtl8192_restart, dev);
+ tq_init(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev);
+ tq_init(&priv->txpower_tracking_wq, (void*)dm_txpower_trackingcallback, dev);
+ tq_init(&priv->rfpath_check_wq, (void*)dm_rf_pathcheck_workitemcallback, dev);
+ tq_init(&priv->update_beacon_wq, (void*)rtl8192_update_beacon, dev);
+ //tq_init(&priv->SwChnlWorkItem, (void*) rtl8192_SwChnl_WorkItem, dev);
+ //tq_init(&priv->SetBWModeWorkItem, (void*)rtl8192_SetBWModeWorkItem, dev);
+ tq_init(&priv->qos_activate, (void *)rtl8192_qos_activate, dev);
+ tq_init(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev);
+ tq_init(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev);
+
+#else
+ INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8192_restart,dev);
+ //INIT_WORK(&priv->watch_dog_wq, (void(*)(void*)) hal_dm_watchdog,dev);
+ INIT_WORK(&priv->watch_dog_wq, (void(*)(void*)) rtl819x_watchdog_wqcallback,dev);
+ INIT_WORK(&priv->txpower_tracking_wq, (void(*)(void*)) dm_txpower_trackingcallback,dev);
+// INIT_WORK(&priv->gpio_change_rf_wq, (void(*)(void*)) dm_gpio_change_rf_callback,dev);
+ INIT_WORK(&priv->rfpath_check_wq, (void(*)(void*)) dm_rf_pathcheck_workitemcallback,dev);
+ INIT_WORK(&priv->update_beacon_wq, (void(*)(void*))rtl8192_update_beacon,dev);
+ INIT_WORK(&priv->initialgain_operate_wq, (void(*)(void*))InitialGainOperateWorkItemCallBack,dev);
+ //INIT_WORK(&priv->SwChnlWorkItem, (void(*)(void*)) rtl8192_SwChnl_WorkItem, dev);
+ //INIT_WORK(&priv->SetBWModeWorkItem, (void(*)(void*)) rtl8192_SetBWModeWorkItem, dev);
+ INIT_WORK(&priv->qos_activate, (void(*)(void *))rtl8192_qos_activate, dev);
+ INIT_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev);
+ INIT_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev);
+#endif
+#endif
+
+ tasklet_init(&priv->irq_rx_tasklet,
+ (void(*)(unsigned long))rtl8192_irq_rx_tasklet,
+ (unsigned long)priv);
+}
+
+static void rtl8192_get_eeprom_size(struct net_device* dev)
+{
+ u16 curCR = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_TRACE(COMP_EPROM, "===========>%s()\n", __FUNCTION__);
+ curCR = read_nic_word_E(dev,EPROM_CMD);
+ RT_TRACE(COMP_EPROM, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
+ //whether need I consider BIT5?
+ priv->epromtype = (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
+ RT_TRACE(COMP_EPROM, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype);
+}
+
+//used to swap endian. as ntohl & htonl are not neccessary to swap endian, so use this instead.
+static inline u16 endian_swap(u16* data)
+{
+ u16 tmp = *data;
+ *data = (tmp >> 8) | (tmp << 8);
+ return *data;
+}
+
+#ifdef RTL8192SU
+u8 rtl8192SU_UsbOptionToEndPointNumber(u8 UsbOption)
+{
+ u8 nEndPoint = 0;
+ switch(UsbOption)
+ {
+ case 0:
+ nEndPoint = 6;
+ break;
+ case 1:
+ nEndPoint = 11;
+ break;
+ case 2:
+ nEndPoint = 4;
+ break;
+ default:
+ RT_TRACE(COMP_INIT, "UsbOptionToEndPointNumber(): Invalid UsbOption(%#x)\n", UsbOption);
+ break;
+ }
+ return nEndPoint;
+}
+
+u8 rtl8192SU_BoardTypeToRFtype(struct net_device* dev, u8 Boardtype)
+{
+ u8 RFtype = RF_1T2R;
+
+ switch(Boardtype)
+ {
+ case 0:
+ RFtype = RF_1T1R;
+ break;
+ case 1:
+ RFtype = RF_1T2R;
+ break;
+ case 2:
+ RFtype = RF_2T2R;
+ break;
+ case 3:
+ RFtype = RF_2T2R_GREEN;
+ break;
+ default:
+ break;
+ }
+
+ return RFtype;
+}
+
+//
+// Description:
+// Config HW adapter information into initial value.
+//
+// Assumption:
+// 1. After Auto load fail(i.e, check CR9346 fail)
+//
+// Created by Roger, 2008.10.21.
+//
+void
+rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //u16 i,usValue;
+ //u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
+ u8 rf_path, index; // For EEPROM/EFUSE After V0.6_1117
+ int i;
+
+ RT_TRACE(COMP_INIT, "====> ConfigAdapterInfo8192SForAutoLoadFail\n");
+
+ write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
+ //PlatformStallExecution(10000);
+ mdelay(10);
+ write_nic_byte(dev, PMC_FSM, 0x02); // Enable Loader Data Keep
+
+ //RT_ASSERT(priv->AutoloadFailFlag==TRUE, ("ReadAdapterInfo8192SEEPROM(): AutoloadFailFlag !=TRUE\n"));
+
+ // Initialize IC Version && Channel Plan
+ priv->eeprom_vid = 0;
+ priv->eeprom_pid = 0;
+ priv->card_8192_version = 0;
+ priv->eeprom_ChannelPlan = 0;
+ priv->eeprom_CustomerID = 0;
+ priv->eeprom_SubCustomerID = 0;
+ priv->bIgnoreDiffRateTxPowerOffset = false;
+
+ RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
+ RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
+ RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
+ RT_TRACE(COMP_INIT, "IgnoreDiffRateTxPowerOffset = %d\n", priv->bIgnoreDiffRateTxPowerOffset);
+
+
+
+ priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
+ RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
+
+ for(i=0; i<5; i++)
+ priv->EEPROMUsbPhyParam[i] = EEPROM_USB_Default_PHY_PARAM;
+
+ //RT_PRINT_DATA(COMP_INIT|COMP_EFUSE, DBG_LOUD, ("EFUSE USB PHY Param: \n"), priv->EEPROMUsbPhyParam, 5);
+
+ {
+ //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
+ static u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
+ u8 i;
+
+ //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
+
+ for(i = 0; i < 6; i++)
+ dev->dev_addr[i] = sMacAddr[i];
+ }
+ //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
+ write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
+ write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
+
+ RT_TRACE(COMP_INIT, "ReadAdapterInfo8192SEFuse(), Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
+ dev->dev_addr[0], dev->dev_addr[1],
+ dev->dev_addr[2], dev->dev_addr[3],
+ dev->dev_addr[4], dev->dev_addr[5]);
+
+ priv->EEPROMBoardType = EEPROM_Default_BoardType;
+ priv->rf_type = RF_1T2R; //RF_2T2R
+ priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff;
+ priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+ priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+ priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
+ priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
+ priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
+ priv->EEPROMTxPwrTkMode = EEPROM_Default_TxPwrTkMode;
+
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ for(i=0; i<6; i++)
+ {
+ priv->EEPROMHT2T_TxPwr[i] = EEPROM_Default_HT2T_TxPwr;
+ }
+
+ for(i=0; i<14; i++)
+ {
+ priv->EEPROMTxPowerLevelCCK24G[i] = (u8)(EEPROM_Default_TxPower & 0xff);
+ priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)(EEPROM_Default_TxPower & 0xff);
+ }
+
+ //
+ // Update HAL variables.
+ //
+ memcpy( priv->TxPowerLevelOFDM24G, priv->EEPROMTxPowerLevelOFDM24G, 14);
+ memcpy( priv->TxPowerLevelCCK, priv->EEPROMTxPowerLevelCCK24G, 14);
+ //RT_PRINT_DATA(COMP_INIT|COMP_EFUSE, DBG_LOUD, ("HAL CCK 2.4G TxPwr: \n"), priv->TxPowerLevelCCK, 14);
+ //RT_PRINT_DATA(COMP_INIT|COMP_EFUSE, DBG_LOUD, ("HAL OFDM 2.4G TxPwr: \n"), priv->TxPowerLevelOFDM24G, 14);
+#else
+
+ for (rf_path = 0; rf_path < 2; rf_path++)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ // Read CCK RF A & B Tx power
+ priv->RfCckChnlAreaTxPwr[rf_path][i] =
+ priv->RfOfdmChnlAreaTxPwr1T[rf_path][i] =
+ priv->RfOfdmChnlAreaTxPwr2T[rf_path][i] =
+ (u8)(EEPROM_Default_TxPower & 0xff);
+ }
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ //RT_TRACE((COMP_EFUSE), "CCK RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
+ //priv->RfCckChnlAreaTxPwr[rf_path][i]);
+ //RT_TRACE((COMP_EFUSE), "OFDM-1T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
+ //priv->RfOfdmChnlAreaTxPwr1T[rf_path][i]);
+ //RT_TRACE((COMP_EFUSE), "OFDM-2T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
+ //priv->RfOfdmChnlAreaTxPwr2T[rf_path][i]);
+ }
+
+ // Assign dedicated channel tx power
+ for(i=0; i<14; i++) // channel 1~3 use the same Tx Power Level.
+ {
+ if (i < 3) // Cjanel 1-3
+ index = 0;
+ else if (i < 9) // Channel 4-9
+ index = 1;
+ else // Channel 10-14
+ index = 2;
+
+ // Record A & B CCK /OFDM - 1T/2T Channel area tx power
+ priv->RfTxPwrLevelCck[rf_path][i] =
+ priv->RfCckChnlAreaTxPwr[rf_path][index];
+ priv->RfTxPwrLevelOfdm1T[rf_path][i] =
+ priv->RfOfdmChnlAreaTxPwr1T[rf_path][index];
+ priv->RfTxPwrLevelOfdm2T[rf_path][i] =
+ priv->RfOfdmChnlAreaTxPwr2T[rf_path][index];
+ }
+
+ for(i=0; i<14; i++)
+ {
+ //RT_TRACE((COMP_EFUSE), "Rf-%d TxPwr CH-%d CCK OFDM_1T OFDM_2T= 0x%x/0x%x/0x%x\n",
+ //rf_path, i, priv->RfTxPwrLevelCck[0][i],
+ //priv->RfTxPwrLevelOfdm1T[0][i] ,
+ //priv->RfTxPwrLevelOfdm2T[0][i] );
+ }
+#endif
+
+ //
+ // Update remained HAL variables.
+ //
+ priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
+ priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff;//new
+ priv->TxPowerDiff = priv->EEPROMTxPowerDiff;
+ //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit0~3
+ //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit4~7
+ priv->CrystalCap = priv->EEPROMCrystalCap; // CrystalCap, bit12~15
+ priv->ThermalMeter[0] = priv->EEPROMThermalMeter;// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+ priv->LedStrategy = SW_LED_MODE0;
+
+ init_rate_adaptive(dev);
+
+ RT_TRACE(COMP_INIT, "<==== ConfigAdapterInfo8192SForAutoLoadFail\n");
+
+}
+
+#if 0
+static void rtl8192SU_ReadAdapterInfo8192SEEPROM(struct net_device* dev)
+{
+ u16 EEPROMId = 0;
+ u8 bLoad_From_EEPOM = false;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 tmpValue = 0;
+ u8 tmpBuffer[30];
+ int i;
+
+ RT_TRACE(COMP_EPROM, "===========>%s()\n", __FUNCTION__);
+
+
+ write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
+ udelay(10000);
+ write_nic_byte(dev, PMC_FSM, 0x02); // Enable Loader Data Keep
+
+
+ EEPROMId = eprom_read(dev, 0); //first read EEPROM ID out;
+ RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", EEPROMId);
+
+ if (EEPROMId != RTL8190_EEPROM_ID)
+ {
+ priv->AutoloadFailFlag = true;
+ RT_TRACE(COMP_ERR, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", EEPROMId, RTL8190_EEPROM_ID);
+ }
+ else
+ {
+ priv->AutoloadFailFlag = false;
+ bLoad_From_EEPOM = true;
+ }
+
+ if (bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (EEPROM_VID>>1));
+ priv->eeprom_vid = endian_swap(&tmpValue);
+ priv->eeprom_pid = eprom_read(dev, (EEPROM_PID>>1));
+
+ // Version ID, Channel plan
+ tmpValue = eprom_read(dev, (EEPROM_Version>>1));
+ //pHalData->card_8192_version = (VERSION_8192S)((usValue&0x00ff));
+ priv->eeprom_ChannelPlan =(tmpValue&0xff00)>>8;
+ priv->bTXPowerDataReadFromEEPORM = true;
+
+ // Customer ID, 0x00 and 0xff are reserved for Realtek.
+ tmpValue = eprom_read(dev, (u16)(EEPROM_CustomID>>1)) ;
+ priv->eeprom_CustomerID = (u8)( tmpValue & 0xff);
+ priv->eeprom_SubCustomerID = (u8)((tmpValue & 0xff00)>>8);
+ }
+ else
+ {
+ priv->eeprom_vid = 0;
+ priv->eeprom_pid = 0;
+ //priv->card_8192_version = VERSION_8192SU_A;
+ priv->eeprom_ChannelPlan = 0;
+ priv->eeprom_CustomerID = 0;
+ priv->eeprom_SubCustomerID = 0;
+ }
+ RT_TRACE(COMP_EPROM, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID, priv->eeprom_ChannelPlan);
+ //set channelplan from eeprom
+ priv->ChannelPlan = priv->eeprom_ChannelPlan;// FIXLZM
+
+ RT_TRACE(COMP_INIT, "EEPROMId = 0x%4x\n", EEPROMId);
+ RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
+ RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
+ //RT_TRACE(COMP_INIT, DBG_LOUD, ("EEPROM Version ID: 0x%2x\n", pHalData->VersionID));
+ RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
+
+ // Read USB optional function.
+ if(bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (EEPROM_USB_OPTIONAL>>1));
+ priv->EEPROMUsbOption = (u8)(tmpValue&0xff);
+ }
+ else
+ {
+ priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
+ }
+
+ RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
+
+
+ if (bLoad_From_EEPOM)
+ {
+ int i;
+ for (i=0; i<6; i+=2)
+ {
+ u16 tmp = 0;
+ tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i)>>1));
+ *(u16*)(&dev->dev_addr[i]) = tmp;
+ }
+ }
+ else
+ {
+ //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
+ static u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
+ u8 i;
+
+ //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
+
+ for(i = 0; i < 6; i++)
+ dev->dev_addr[i] = sMacAddr[i];
+
+ //memcpy(dev->dev_addr, sMacAddr, 6);
+ //should I set IDR0 here?
+ }
+ write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
+ write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
+ RT_TRACE(COMP_EPROM, "MAC addr:"MAC_FMT"\n", MAC_ARG(dev->dev_addr));
+
+ priv->rf_type = RTL819X_DEFAULT_RF_TYPE; //default 1T2R
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ priv->rf_chip = RF_6052;
+ priv->rf_type = RTL819X_DEFAULT_RF_TYPE;
+ //priv->card_8192_version = VERSION_8192SU_A; //Over write for temporally experiment. 2008.10.16. By Roger.
+#else
+ priv->rf_chip = RF_8256;
+#endif
+
+ {
+#if 0
+ if(bLoad_From_EEPOM)
+ {
+ tempval = (ReadEEprom(Adapter, (EEPROM_RFInd_PowerDiff>>1))) & 0xff;
+ if (tempval&0x80) //RF-indication, bit[7]
+ pHalData->RF_Type = RF_1T2R;
+ else
+ pHalData->RF_Type = RF_2T4R;
+ }
+#endif
+
+ priv->EEPROMTxPowerDiff = EEPROM_Default_TxPowerDiff;
+ RT_TRACE(COMP_INIT, "TxPowerDiff = %#x\n", priv->EEPROMTxPowerDiff);
+
+
+ //
+ // Read antenna tx power offset of B/C/D to A from EEPROM
+ // and read ThermalMeter from EEPROM
+ //
+ if(bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (EEPROM_PwDiff>>1));
+ priv->EEPROMPwDiff = tmpValue&0x00ff;
+ priv->EEPROMThermalMeter = (tmpValue&0xff00)>>8;
+ }
+ else
+ {
+ priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
+ priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+ }
+ RT_TRACE(COMP_INIT, "PwDiff = %#x\n", priv->EEPROMPwDiff);
+ RT_TRACE(COMP_INIT, "ThermalMeter = %#x\n", priv->EEPROMThermalMeter);
+
+ priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
+
+
+ // Read CrystalCap from EEPROM
+ if(bLoad_From_EEPOM)
+ {
+ priv->EEPROMCrystalCap =(u8) (((eprom_read(dev, (EEPROM_CrystalCap>>1)))&0xf000)>>12);
+ }
+ else
+ {
+ priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+ }
+ RT_TRACE(COMP_INIT, "CrystalCap = %#x\n", priv->EEPROMCrystalCap);
+
+
+ //if(pHalData->EEPROM_Def_Ver == 0) // old eeprom definition
+ {
+
+ //
+ // Get Tx Power Base.//===>
+ //
+ if(bLoad_From_EEPOM)
+ {
+ priv->EEPROMTxPwrBase =(u8) ((eprom_read(dev, (EEPROM_TxPowerBase>>1)))&0xff);
+ }
+ else
+ {
+ priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
+ }
+
+ RT_TRACE(COMP_INIT, "TxPwrBase = %#x\n", priv->EEPROMTxPwrBase);
+
+ //
+ // Get CustomerID(Boad Type)
+ // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
+ // Others: Reserved. Default is 0x2: RTL8192SU.
+ //
+ if(bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (u16) (EEPROM_BoardType>>1));
+ priv->EEPROMBoardType = (u8)(tmpValue&0xff);
+ }
+ else
+ {
+ priv->EEPROMBoardType = EEPROM_Default_BoardType;
+ }
+
+ RT_TRACE(COMP_INIT, "BoardType = %#x\n", priv->EEPROMBoardType);
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+
+ //
+ // Buffer TxPwIdx(i.e., from offset 0x58~0x75, total 30Bytes)
+ //
+ if(bLoad_From_EEPOM)
+ {
+ for(i = 0; i < 30; i += 2)
+ {
+ tmpValue = eprom_read(dev, (u16) ((EEPROM_TxPowerBase+i)>>1));
+ *((u16 *)(&tmpBuffer[i])) = tmpValue;
+ }
+ }
+
+ //
+ // Update CCK, OFDM Tx Power Index from above buffer.
+ //
+ if(bLoad_From_EEPOM)
+ {
+ for(i=0; i<14; i++)
+ {
+ priv->EEPROMTxPowerLevelCCK24G[i] = (u8)tmpBuffer[i+1];
+ priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)tmpBuffer[i+15];
+ }
+
+ }
+ else
+ {
+ for(i=0; i<14; i++)
+ {
+ priv->EEPROMTxPowerLevelCCK24G[i] = (u8)(EEPROM_Default_TxPower & 0xff);
+ priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)(EEPROM_Default_TxPower & 0xff);
+ }
+ }
+
+ for(i=0; i<14; i++)
+ {
+ RT_TRACE(COMP_INIT, "CCK 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK24G[i]);
+ RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]);
+ }
+#else
+ // Please add code in the section!!!!
+ // And merge tx power difference section.
+#endif
+
+ //
+ // Get TSSI value for each path.
+ //
+ if(bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (u16) ((EEPROM_TSSI_A)>>1));
+ priv->EEPROMTSSI_A = (u8)((tmpValue&0xff00)>>8);
+ }
+ else
+ { // Default setting for Empty EEPROM
+ priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
+ }
+
+ if(bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (u16) ((EEPROM_TSSI_B)>>1));
+ priv->EEPROMTSSI_B = (u8)(tmpValue&0xff);
+ priv->EEPROMTxPwrTkMode = (u8)((tmpValue&0xff00)>>8);
+ }
+ else
+ { // Default setting for Empty EEPROM
+ priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
+ priv->EEPROMTxPwrTkMode = EEPROM_Default_TxPwrTkMode;
+ }
+
+ RT_TRACE(COMP_INIT, "TSSI_A = %#x, TSSI_B = %#x\n", priv->EEPROMTSSI_A, priv->EEPROMTSSI_B);
+ RT_TRACE(COMP_INIT, "TxPwrTkMod = %#x\n", priv->EEPROMTxPwrTkMode);
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ //
+ // Get HT 2T Path A and B Power Index.
+ //
+ if(bLoad_From_EEPOM)
+ {
+ for(i = 0; i < 6; i += 2)
+ {
+ tmpValue = eprom_read(dev, (u16) ((EEPROM_HT2T_CH1_A+i)>>1));
+ *((u16*)(&priv->EEPROMHT2T_TxPwr[i])) = tmpValue;
+ }
+ }
+ else
+ { // Default setting for Empty EEPROM
+ for(i=0; i<6; i++)
+ {
+ priv->EEPROMHT2T_TxPwr[i] = EEPROM_Default_HT2T_TxPwr;
+ }
+ }
+
+ for(i=0; i<6; i++)
+ {
+ RT_TRACE(COMP_INIT, "EEPROMHT2T_TxPwr, Index %d = 0x%02x\n", i, priv->EEPROMHT2T_TxPwr[i]);
+ }
+#else
+
+#endif
+ }
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ //
+ // Update HAL variables.
+ //
+ for(i=0; i<14; i++)
+ {
+ priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i];
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK24G[i];
+ }
+#else
+
+#endif
+ priv->TxPowerDiff = priv->EEPROMPwDiff;
+ // Antenna B gain offset to antenna A, bit0~3
+ priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
+ // Antenna C gain offset to antenna A, bit4~7
+ priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);
+ // CrystalCap, bit12~15
+ priv->CrystalCap = priv->EEPROMCrystalCap;
+ // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+ // 92U does not enable TX power tracking.
+ priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
+ }
+
+ priv->LedStrategy = SW_LED_MODE0;
+
+ if(priv->rf_type == RF_1T2R)
+ {
+ RT_TRACE(COMP_EPROM, "\n1T2R config\n");
+ }
+ else
+ {
+ RT_TRACE(COMP_EPROM, "\n2T4R config\n");
+ }
+
+ // 2008/01/16 MH We can only know RF type in the function. So we have to init
+ // DIG RATR table again.
+ init_rate_adaptive(dev);
+ //we need init DIG RATR table here again.
+
+ RT_TRACE(COMP_EPROM, "<===========%s()\n", __FUNCTION__);
+ return;
+}
+
+//
+// Description:
+// 1. Read HW adapter information by E-Fuse.
+// 2. Refered from SD1 Richard.
+//
+// Assumption:
+// 1. Boot from E-Fuse and CR9346 regiser has verified.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+void
+rtl8192SU_ReadAdapterInfo8192SEFuse(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 i,usValue;
+ u16 EEPROMId;
+ u8 readbyte;
+ u8 OFDMTxPwr[14];
+ u8 CCKTxPwr[14];
+ u8 HT2T_TxPwr[6];
+ u8 UsbPhyParam[5];
+ u8 hwinfo[HWSET_MAX_SIZE_92S];
+
+
+ RT_TRACE(COMP_INIT, "====> ReadAdapterInfo8192SEFuse\n");
+
+ //
+ // <Roger_Notes> We set Isolation signals from Loader and reset EEPROM after system resuming
+ // from suspend mode.
+ // 2008.10.21.
+ //
+ write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
+ //PlatformStallExecution(10000);
+ mdelay(10);
+ write_nic_byte(dev, SYS_FUNC_EN+1, 0x40);
+ write_nic_byte(dev, SYS_FUNC_EN+1, 0x50);
+
+ readbyte = read_nic_byte(dev, EFUSE_TEST+3);
+ write_nic_byte(dev, EFUSE_TEST+3, (readbyte | 0x80));
+ write_nic_byte(dev, EFUSE_TEST+3, 0x72);
+ write_nic_byte(dev, EFUSE_CLK, 0x03);
+
+ //
+ // Dump EFUSe at init time for later use
+ //
+ // Read EFUSE real map to shadow!!
+ EFUSE_ShadowMapUpdate(dev);
+
+ memcpy(hwinfo, (void*)&priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
+ //RT_PRINT_DATA(COMP_INIT, DBG_LOUD, ("MAP \n"), hwinfo, HWSET_MAX_SIZE_92S);
+
+ //
+ // <Roger_Notes> Event though CR9346 regiser can verify whether Autoload is success or not, but we still
+ // double check ID codes for 92S here(e.g., due to HW GPIO polling fail issue).
+ // 2008.10.21.
+ //
+ ReadEFuse(dev, 0, 2, (unsigned char*) &EEPROMId);
+
+ if( EEPROMId != RTL8190_EEPROM_ID )
+ {
+ RT_TRACE(COMP_INIT, "EEPROM ID(%#x) is invalid!!\n", EEPROMId);
+ priv->AutoloadFailFlag=true;
+ }
+ else
+ {
+ priv->AutoloadFailFlag=false;
+ }
+
+ // Read IC Version && Channel Plan
+ if(!priv->AutoloadFailFlag)
+ {
+
+ // VID, PID
+ ReadEFuse(dev, EEPROM_VID, 2, (unsigned char*) &priv->eeprom_vid);
+ ReadEFuse(dev, EEPROM_PID, 2, (unsigned char*) &priv->eeprom_pid);
+
+ // Version ID, Channel plan
+ ReadEFuse(dev, EEPROM_Version, 2, (unsigned char*) &usValue);
+ //pHalData->VersionID = (VERSION_8192S)(usValue&0x00ff);
+ priv->eeprom_ChannelPlan = (usValue&0xff00>>8);
+ priv->bTXPowerDataReadFromEEPORM = true;
+
+ // Customer ID, 0x00 and 0xff are reserved for Realtek.
+ ReadEFuse(dev, EEPROM_CustomID, 2, (unsigned char*) &usValue);
+ priv->eeprom_CustomerID = (u8)( usValue & 0xff);
+ priv->eeprom_SubCustomerID = (u8)((usValue & 0xff00)>>8);
+ }
+ else
+ {
+ priv->eeprom_vid = 0;
+ priv->eeprom_pid = 0;
+ priv->eeprom_ChannelPlan = 0;
+ priv->eeprom_CustomerID = 0;
+ priv->eeprom_SubCustomerID = 0;
+ }
+
+ RT_TRACE(COMP_INIT, "EEPROM Id = 0x%4x\n", EEPROMId);
+ RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
+ RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
+ //RT_TRACE(COMP_INIT, DBG_LOUD, ("EEPROM Version ID: 0x%2x\n", pHalData->VersionID));
+ RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
+
+
+ // Read USB optional function.
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_USB_OPTIONAL, 1, (unsigned char*) &priv->EEPROMUsbOption);
+ }
+ else
+ {
+ priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
+ }
+
+ RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
+
+
+ // Read USB PHY parameters.
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_USB_PHY_PARA1, 5, (unsigned char*)UsbPhyParam);
+ for(i=0; i<5; i++)
+ {
+ priv->EEPROMUsbPhyParam[i] = UsbPhyParam[i];
+ RT_TRACE(COMP_INIT, "USB Param = index(%d) = %#x\n", i, priv->EEPROMUsbPhyParam[i]);
+ }
+ }
+ else
+ {
+ for(i=0; i<5; i++)
+ {
+ priv->EEPROMUsbPhyParam[i] = EEPROM_USB_Default_PHY_PARAM;
+ RT_TRACE(COMP_INIT, "USB Param = index(%d) = %#x\n", i, priv->EEPROMUsbPhyParam[i]);
+ }
+ }
+
+
+ //Read Permanent MAC address
+ if(!priv->AutoloadFailFlag)
+ {
+ u8 macaddr[6] = {0x00, 0xe1, 0x86, 0x4c, 0x92, 0x00};
+
+ ReadEFuse(dev, EEPROM_NODE_ADDRESS_BYTE_0, 6, (unsigned char*)macaddr);
+ for(i=0; i<6; i++)
+ dev->dev_addr[i] = macaddr[i];
+ }
+ else
+ {//Auto load fail
+
+ //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
+ static u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
+ u8 i;
+
+ //if(!Adapter->bInHctTest)
+ //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
+
+ for(i = 0; i < 6; i++)
+ dev->dev_addr[i] = sMacAddr[i];
+ }
+
+ //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
+ write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
+ write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
+
+ RT_TRACE(COMP_INIT, "ReadAdapterInfo8192SEFuse(), Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
+ dev->dev_addr[0], dev->dev_addr[1],
+ dev->dev_addr[2], dev->dev_addr[3],
+ dev->dev_addr[4], dev->dev_addr[5]);
+
+ // 2007/11/15 MH For RTL8192USB we assign as 1T2R now.
+ priv->rf_type = RTL819X_DEFAULT_RF_TYPE; // default : 1T2R
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ priv->rf_chip = RF_6052;
+ priv->rf_type = RTL819X_DEFAULT_RF_TYPE;
+#else
+ priv->rf_chip = RF_8256;
+#endif
+
+ {
+ //
+ // Read antenna tx power offset of B/C/D to A from EEPROM
+ // and read ThermalMeter from EEPROM
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_PwDiff, 2, (unsigned char*) &usValue);
+ priv->EEPROMPwDiff = usValue&0x00ff;
+ priv->EEPROMThermalMeter = (usValue&0xff00)>>8;
+ }
+ else
+ {
+ priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
+ priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+ }
+
+ RT_TRACE(COMP_INIT, "PwDiff = %#x\n", priv->EEPROMPwDiff);
+ RT_TRACE(COMP_INIT, "ThermalMeter = %#x\n", priv->EEPROMThermalMeter);
+
+ priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
+
+ //
+ // Read Tx Power gain offset of legacy OFDM to HT rate.
+ // Read CrystalCap from EEPROM
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_CrystalCap, 1, (unsigned char*) &usValue);
+ priv->EEPROMCrystalCap = (u8)((usValue&0xf0)>>4);
+ }
+ else
+ {
+ priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+ }
+
+ RT_TRACE(COMP_INIT, "CrystalCap = %#x\n", priv->EEPROMCrystalCap);
+
+ priv->EEPROMTxPowerDiff = EEPROM_Default_TxPowerDiff;
+ RT_TRACE(COMP_INIT, "TxPowerDiff = %d\n", priv->EEPROMTxPowerDiff);
+
+
+ //
+ // Get Tx Power Base.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_TxPowerBase, 1, (unsigned char*) &priv->EEPROMTxPwrBase );
+ }
+ else
+ {
+ priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
+ }
+
+ RT_TRACE(COMP_INIT, "TxPwrBase = %#x\n", priv->EEPROMTxPwrBase);
+
+ //
+ // Get CustomerID(Boad Type)
+ // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
+ // Others: Reserved. Default is 0x2: RTL8192SU.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_BoardType, 1, (unsigned char*) &priv->EEPROMBoardType );
+ }
+ else
+ {
+ priv->EEPROMBoardType = EEPROM_Default_BoardType;
+ }
+
+ RT_TRACE(COMP_INIT, "BoardType = %#x\n", priv->EEPROMBoardType);
+
+ //if(pHalData->EEPROM_Def_Ver == 0)
+ {
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ //
+ // Get CCK Tx Power Index.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_TxPwIndex_CCK_24G, 14, (unsigned char*)CCKTxPwr);
+ for(i=0; i<14; i++)
+ {
+ RT_TRACE(COMP_INIT, "CCK 2.4G Tx Power Level, Index %d = 0x%02x\n", i, CCKTxPwr[i]);
+ priv->EEPROMTxPowerLevelCCK24G[i] = CCKTxPwr[i];
+ }
+ }
+ else
+ { // Default setting for Empty EEPROM
+ for(i=0; i<14; i++)
+ priv->EEPROMTxPowerLevelCCK24G[i] = (u8)(EEPROM_Default_TxPower & 0xff);
+ }
+
+ //
+ // Get OFDM Tx Power Index.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_TxPwIndex_OFDM_24G, 14, (unsigned char*)OFDMTxPwr);
+ for(i=0; i<14; i++)
+ {
+ RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, OFDMTxPwr[i]);
+ priv->EEPROMTxPowerLevelOFDM24G[i] = OFDMTxPwr[i];
+ }
+ }
+ else
+ { // Default setting for Empty EEPROM
+ usValue = 0x10;
+ for(i=0; i<14; i++)
+ priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)usValue;
+ }
+#else
+ // Please add code in the section!!!!
+ // And merge tx power difference section.
+#endif
+
+ //
+ // Get TSSI value for each path.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_TSSI_A, 2, (unsigned char*)&usValue);
+ priv->EEPROMTSSI_A = (u8)(usValue&0xff);
+ priv->EEPROMTSSI_B = (u8)((usValue&0xff00)>>8);
+ }
+ else
+ { // Default setting for Empty EEPROM
+ priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
+ priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
+ }
+
+ RT_TRACE(COMP_INIT, "TSSI_A = %#x, TSSI_B = %#x\n",
+ priv->EEPROMTSSI_A, priv->EEPROMTSSI_B);
+
+ //
+ // Get Tx Power tracking mode.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_TxPwTkMode, 1, (unsigned char*)&priv->EEPROMTxPwrTkMode);
+ }
+ else
+ { // Default setting for Empty EEPROM
+ priv->EEPROMTxPwrTkMode = EEPROM_Default_TxPwrTkMode;
+ }
+
+ RT_TRACE(COMP_INIT, "TxPwrTkMod = %#x\n", priv->EEPROMTxPwrTkMode);
+
+
+ // TODO: The following HT 2T Path A and B Power Index should be updated.!! Added by Roger, 2008.20.23.
+
+ //
+ // Get HT 2T Path A and B Power Index.
+ //
+ if(!priv->AutoloadFailFlag)
+ {
+ ReadEFuse(dev, EEPROM_HT2T_CH1_A, 6, (unsigned char*)HT2T_TxPwr);
+ for(i=0; i<6; i++)
+ {
+ priv->EEPROMHT2T_TxPwr[i] = HT2T_TxPwr[i];
+ }
+ }
+ else
+ { // Default setting for Empty EEPROM
+ for(i=0; i<6; i++)
+ {
+ priv->EEPROMHT2T_TxPwr[i] = EEPROM_Default_HT2T_TxPwr;
+ }
+ }
+
+ for(i=0; i<6; i++)
+ {
+ RT_TRACE(COMP_INIT, "EEPROMHT2T_TxPwr, Index %d = 0x%02x\n",
+ i, priv->EEPROMHT2T_TxPwr[i]);
+ }
+ }
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+ //
+ // Update HAL variables.
+ //
+ for(i=0; i<14; i++)
+ {
+ priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i];
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK24G[i];
+ }
+#else
+
+#endif
+ priv->TxPowerDiff = priv->EEPROMPwDiff;
+ // Antenna B gain offset to antenna A, bit0~3
+ priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
+ // Antenna C gain offset to antenna A, bit4~7
+ priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);
+ // CrystalCap, bit12~15
+ priv->CrystalCap = priv->EEPROMCrystalCap;
+ // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+ // 92U does not enable TX power tracking.
+ priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
+ }
+
+ priv->LedStrategy = SW_LED_MODE0;
+
+ init_rate_adaptive(dev);
+
+ RT_TRACE(COMP_INIT, "<==== ReadAdapterInfo8192SEFuse\n");
+
+}
+#endif
+
+//
+// Description:
+// Read HW adapter information by E-Fuse or EEPROM according CR9346 reported.
+//
+// Assumption:
+// 1. CR9346 regiser has verified.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+void
+rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 i,usValue;
+ u8 tmpU1b, tempval;
+ u16 EEPROMId;
+ u8 hwinfo[HWSET_MAX_SIZE_92S];
+ u8 rf_path, index; // For EEPROM/EFUSE After V0.6_1117
+
+
+ RT_TRACE(COMP_INIT, "====> ReadAdapterInfo8192SUsb\n");
+
+ //
+ // <Roger_Note> The following operation are prevent Efuse leakage by turn on 2.5V.
+ // 2008.11.25.
+ //
+ tmpU1b = read_nic_byte(dev, EFUSE_TEST+3);
+ write_nic_byte(dev, EFUSE_TEST+3, tmpU1b|0x80);
+ //PlatformStallExecution(1000);
+ mdelay(10);
+ write_nic_byte(dev, EFUSE_TEST+3, (tmpU1b&(~BIT7)));
+
+ // Retrieve Chip version.
+ priv->card_8192_version = (VERSION_8192S)((read_nic_dword(dev, PMC_FSM)>>16)&0xF);
+ RT_TRACE(COMP_INIT, "Chip Version ID: 0x%2x\n", priv->card_8192_version);
+
+ switch(priv->card_8192_version)
+ {
+ case 0:
+ RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_ACUT.\n");
+ break;
+ case 1:
+ RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_BCUT.\n");
+ break;
+ case 2:
+ RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_CCUT.\n");
+ break;
+ default:
+ RT_TRACE(COMP_INIT, "Unknown Chip Version!!\n");
+ priv->card_8192_version = VERSION_8192S_BCUT;
+ break;
+ }
+
+ //if (IS_BOOT_FROM_EEPROM(Adapter))
+ if(priv->EepromOrEfuse)
+ { // Read frin EEPROM
+ write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
+ //PlatformStallExecution(10000);
+ mdelay(10);
+ write_nic_byte(dev, PMC_FSM, 0x02); // Enable Loader Data Keep
+ // Read all Content from EEPROM or EFUSE.
+ for(i = 0; i < HWSET_MAX_SIZE_92S; i += 2)
+ {
+ usValue = eprom_read(dev, (u16) (i>>1));
+ *((u16*)(&hwinfo[i])) = usValue;
+ }
+ }
+ else if (!(priv->EepromOrEfuse))
+ { // Read from EFUSE
+
+ //
+ // <Roger_Notes> We set Isolation signals from Loader and reset EEPROM after system resuming
+ // from suspend mode.
+ // 2008.10.21.
+ //
+ //PlatformEFIOWrite1Byte(Adapter, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
+ //PlatformStallExecution(10000);
+ //PlatformEFIOWrite1Byte(Adapter, SYS_FUNC_EN+1, 0x40);
+ //PlatformEFIOWrite1Byte(Adapter, SYS_FUNC_EN+1, 0x50);
+
+ //tmpU1b = PlatformEFIORead1Byte(Adapter, EFUSE_TEST+3);
+ //PlatformEFIOWrite1Byte(Adapter, EFUSE_TEST+3, (tmpU1b | 0x80));
+ //PlatformEFIOWrite1Byte(Adapter, EFUSE_TEST+3, 0x72);
+ //PlatformEFIOWrite1Byte(Adapter, EFUSE_CLK, 0x03);
+
+ // Read EFUSE real map to shadow.
+ EFUSE_ShadowMapUpdate(dev);
+ memcpy(hwinfo, &priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
+ }
+ else
+ {
+ RT_TRACE(COMP_INIT, "ReadAdapterInfo8192SUsb(): Invalid boot type!!\n");
+ }
+
+ //YJ,test,090106
+ //dump_buf(hwinfo,HWSET_MAX_SIZE_92S);
+ //
+ // <Roger_Notes> The following are EFUSE/EEPROM independent operations!!
+ //
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("MAP: \n"), hwinfo, HWSET_MAX_SIZE_92S);
+
+ //
+ // <Roger_Notes> Event though CR9346 regiser can verify whether Autoload is success or not, but we still
+ // double check ID codes for 92S here(e.g., due to HW GPIO polling fail issue).
+ // 2008.10.21.
+ //
+ EEPROMId = *((u16 *)&hwinfo[0]);
+
+ if( EEPROMId != RTL8190_EEPROM_ID )
+ {
+ RT_TRACE(COMP_INIT, "ID(%#x) is invalid!!\n", EEPROMId);
+ priv->bTXPowerDataReadFromEEPORM = FALSE;
+ priv->AutoloadFailFlag=TRUE;
+ }
+ else
+ {
+ priv->AutoloadFailFlag=FALSE;
+#if RTL8192SU_USE_PARAM_TXPWR
+ priv->bTXPowerDataReadFromEEPORM = FALSE;
+#else
+ priv->bTXPowerDataReadFromEEPORM = TRUE;
+#endif
+
+ }
+ // Read IC Version && Channel Plan
+ if(!priv->AutoloadFailFlag)
+ {
+ // VID, PID
+ priv->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
+ priv->eeprom_pid = *(u16 *)&hwinfo[EEPROM_PID];
+ priv->bIgnoreDiffRateTxPowerOffset = false; //cosa for test
+
+
+ // EEPROM Version ID, Channel plan
+ priv->EEPROMVersion = *(u8 *)&hwinfo[EEPROM_Version];
+ priv->eeprom_ChannelPlan = *(u8 *)&hwinfo[EEPROM_ChannelPlan];
+
+ // Customer ID, 0x00 and 0xff are reserved for Realtek.
+ priv->eeprom_CustomerID = *(u8 *)&hwinfo[EEPROM_CustomID];
+ priv->eeprom_SubCustomerID = *(u8 *)&hwinfo[EEPROM_SubCustomID];
+ }
+ else
+ {
+ //priv->eeprom_vid = 0;
+ //priv->eeprom_pid = 0;
+ //priv->EEPROMVersion = 0;
+ //priv->eeprom_ChannelPlan = 0;
+ //priv->eeprom_CustomerID = 0;
+ //priv->eeprom_SubCustomerID = 0;
+
+ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev);
+ return;
+ }
+
+
+ RT_TRACE(COMP_INIT, "EEPROM Id = 0x%4x\n", EEPROMId);
+ RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
+ RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
+ RT_TRACE(COMP_INIT, "EEPROM Version ID: 0x%2x\n", priv->EEPROMVersion);
+ RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID);
+ RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
+ RT_TRACE(COMP_INIT, "bIgnoreDiffRateTxPowerOffset = %d\n", priv->bIgnoreDiffRateTxPowerOffset);
+
+
+ // Read USB optional function.
+ if(!priv->AutoloadFailFlag)
+ {
+ priv->EEPROMUsbOption = *(u8 *)&hwinfo[EEPROM_USB_OPTIONAL];
+ }
+ else
+ {
+ priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
+ }
+
+
+ priv->EEPROMUsbEndPointNumber = rtl8192SU_UsbOptionToEndPointNumber((priv->EEPROMUsbOption&EEPROM_EP_NUMBER)>>3);
+
+ RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
+ RT_TRACE(COMP_INIT, "EndPoint Number = %#x\n", priv->EEPROMUsbEndPointNumber);
+
+#ifdef TO_DO_LIST
+ //
+ // Decide CustomerID according to VID/DID or EEPROM
+ //
+ switch(pHalData->EEPROMCustomerID)
+ {
+ case EEPROM_CID_ALPHA:
+ pMgntInfo->CustomerID = RT_CID_819x_ALPHA;
+ break;
+
+ case EEPROM_CID_CAMEO:
+ pMgntInfo->CustomerID = RT_CID_819x_CAMEO;
+ break;
+
+ case EEPROM_CID_SITECOM:
+ pMgntInfo->CustomerID = RT_CID_819x_Sitecom;
+ RT_TRACE(COMP_INIT, DBG_LOUD, ("CustomerID = 0x%4x\n", pMgntInfo->CustomerID));
+
+ break;
+
+ case EEPROM_CID_WHQL:
+ Adapter->bInHctTest = TRUE;
+
+ pMgntInfo->bSupportTurboMode = FALSE;
+ pMgntInfo->bAutoTurboBy8186 = FALSE;
+
+ pMgntInfo->PowerSaveControl.bInactivePs = FALSE;
+ pMgntInfo->PowerSaveControl.bIPSModeBackup = FALSE;
+ pMgntInfo->PowerSaveControl.bLeisurePs = FALSE;
+ pMgntInfo->keepAliveLevel = 0;
+ break;
+
+ default:
+ pMgntInfo->CustomerID = RT_CID_DEFAULT;
+ break;
+
+ }
+
+ //
+ // Led mode
+ //
+ switch(pMgntInfo->CustomerID)
+ {
+ case RT_CID_DEFAULT:
+ case RT_CID_819x_ALPHA:
+ pHalData->LedStrategy = SW_LED_MODE1;
+ pHalData->bRegUseLed = TRUE;
+ pHalData->SwLed1.bLedOn = TRUE;
+ break;
+ case RT_CID_819x_CAMEO:
+ pHalData->LedStrategy = SW_LED_MODE1;
+ pHalData->bRegUseLed = TRUE;
+ break;
+
+ case RT_CID_819x_Sitecom:
+ pHalData->LedStrategy = SW_LED_MODE2;
+ pHalData->bRegUseLed = TRUE;
+ break;
+
+ default:
+ pHalData->LedStrategy = SW_LED_MODE0;
+ break;
+ }
+#endif
+
+ // Read USB PHY parameters.
+ for(i=0; i<5; i++)
+ priv->EEPROMUsbPhyParam[i] = *(u8 *)&hwinfo[EEPROM_USB_PHY_PARA1+i];
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("USB PHY Param: \n"), pHalData->EEPROMUsbPhyParam, 5);
+
+
+ //Read Permanent MAC address
+ for(i=0; i<6; i++)
+ dev->dev_addr[i] = *(u8 *)&hwinfo[EEPROM_NODE_ADDRESS_BYTE_0+i];
+
+ //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
+ write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
+ write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
+
+ RT_TRACE(COMP_INIT, "ReadAdapterInfo8192SEFuse(), Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
+ dev->dev_addr[0], dev->dev_addr[1],
+ dev->dev_addr[2], dev->dev_addr[3],
+ dev->dev_addr[4], dev->dev_addr[5]);
+
+ //
+ // Get CustomerID(Boad Type)
+ // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
+ // Others: Reserved. Default is 0x2: RTL8192SU.
+ //
+ //if(!priv->AutoloadFailFlag)
+ //{
+ priv->EEPROMBoardType = *(u8 *)&hwinfo[EEPROM_BoardType];
+ priv->rf_type = rtl8192SU_BoardTypeToRFtype(dev, priv->EEPROMBoardType);
+ //}
+ //else
+ //{
+ // priv->EEPROMBoardType = EEPROM_Default_BoardType;
+ // priv->rf_type = RF_1T2R;
+ //}
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ priv->rf_chip = RF_6052;
+#else
+ priv->rf_chip = RF_8256;
+#endif
+
+ priv->rf_chip = RF_6052;//lzm test
+ RT_TRACE(COMP_INIT, "BoardType = 0x%2x\n", priv->EEPROMBoardType);
+ RT_TRACE(COMP_INIT, "RF_Type = 0x%2x\n", priv->rf_type);
+
+ //
+ // Read antenna tx power offset of B/C/D to A from EEPROM
+ // and read ThermalMeter from EEPROM
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ priv->EEPROMTxPowerDiff = *(u8 *)&hwinfo[EEPROM_PwDiff];
+ priv->EEPROMThermalMeter = *(u8 *)&hwinfo[EEPROM_ThermalMeter];
+ }
+ //else
+ //{
+ // priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff;
+ // priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+ //}
+
+ RT_TRACE(COMP_INIT, "PwDiff = %#x\n", priv->EEPROMTxPowerDiff);
+ RT_TRACE(COMP_INIT, "ThermalMeter = %#x\n", priv->EEPROMThermalMeter);
+
+ //
+ // Read Tx Power gain offset of legacy OFDM to HT rate.
+ // Read CrystalCap from EEPROM
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ priv->EEPROMCrystalCap = *(u8 *)&hwinfo[EEPROM_CrystalCap];
+ }
+ //else
+ //{
+ // priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+ //}
+
+ RT_TRACE(COMP_INIT, "CrystalCap = %#x\n", priv->EEPROMCrystalCap);
+
+ //
+ // Get Tx Power Base.
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ priv->EEPROMTxPwrBase = *(u8 *)&hwinfo[EEPROM_TxPowerBase];
+ }
+ //else
+ //{
+ // priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
+ //}
+
+ RT_TRACE(COMP_INIT, "TxPwrBase = %#x\n", priv->EEPROMTxPwrBase);
+
+
+ //
+ // Get TSSI value for each path.
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ priv->EEPROMTSSI_A = *(u8 *)&hwinfo[EEPROM_TSSI_A];
+ priv->EEPROMTSSI_B = *(u8 *)&hwinfo[EEPROM_TSSI_B];
+ }
+ //else
+ //{ // Default setting for Empty EEPROM
+ // priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
+ // priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
+ //}
+
+ RT_TRACE(COMP_INIT, "TSSI_A = %#x, TSSI_B = %#x\n", priv->EEPROMTSSI_A, priv->EEPROMTSSI_B);
+
+ //
+ // Get Tx Power tracking mode.
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ priv->EEPROMTxPwrTkMode = *(u8 *)&hwinfo[EEPROM_TxPwTkMode];
+ }
+
+ RT_TRACE(COMP_INIT, "TxPwrTkMod = %#x\n", priv->EEPROMTxPwrTkMode);
+
+
+#ifdef EEPROM_OLD_FORMAT_SUPPORT
+
+ //
+ // <Roger_Notes> The following settings are EFUSE version dependence.
+ // So we need to adjust reading offset.
+ // 2008.11.22.
+ //
+ {
+ //
+ // Get HT 2T Path A and B Power Index.
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ for(i=0; i<6; i++)
+ {
+ priv->EEPROMHT2T_TxPwr[i] = *(u8 *)&hwinfo[EEPROM_HT2T_CH1_A+i];
+ }
+ }
+
+ //RT_PRINT_DATA(COMP_EFUSE, "HT2T TxPwr: \n"), pHalData->EEPROMHT2T_TxPwr, 6);
+
+ //
+ // Get CCK and OFDM Tx Power Index.
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ for(i=0; i<14; i++)
+ {
+ priv->EEPROMTxPowerLevelCCK24G[i] = *(u8 *)&hwinfo[EEPROM_TxPwIndex_CCK_24G+i];
+ priv->EEPROMTxPowerLevelOFDM24G[i] = *(u8 *)&hwinfo[EEPROM_TxPwIndex_OFDM_24G+i];
+ }
+ }
+
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("CCK 2.4G TxPwr: \n"), pHalData->EEPROMTxPowerLevelCCK24G, 14);
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("OFDM 2.4G TxPwr: \n"), pHalData->EEPROMTxPowerLevelOFDM24G, 14);
+
+ //
+ // Update HAL variables.
+ //
+ memcpy( priv->TxPowerLevelOFDM24G, priv->EEPROMTxPowerLevelOFDM24G, 14);
+ memcpy( priv->TxPowerLevelCCK, priv->EEPROMTxPowerLevelCCK24G, 14);
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("HAL CCK 2.4G TxPwr: \n"), pHalData->TxPowerLevelCCK, 14);
+ //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("HAL OFDM 2.4G TxPwr: \n"), pHalData->TxPowerLevelOFDM24G, 14);
+
+ }
+#else // Support new version of EFUSE content, 2008.11.22.
+ {
+ //
+ // Buffer TxPwIdx(i.e., from offset 0x55~0x66, total 18Bytes)
+ // Update CCK, OFDM (1T/2T)Tx Power Index from above buffer.
+ //
+
+ //
+ // Get Tx Power Level by Channel
+ //
+ //if(!priv->AutoloadFailFlag)
+ {
+ // Read Tx power of Channel 1 ~ 14 from EFUSE.
+ // 92S suupport RF A & B
+ for (rf_path = 0; rf_path < 2; rf_path++)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ // Read CCK RF A & B Tx power
+ priv->RfCckChnlAreaTxPwr[rf_path][i] =
+ hwinfo[EEPROM_TxPwIndex+rf_path*3+i];
+
+ // Read OFDM RF A & B Tx power for 1T
+ priv->RfOfdmChnlAreaTxPwr1T[rf_path][i] =
+ hwinfo[EEPROM_TxPwIndex+6+rf_path*3+i];
+
+ // Read OFDM RF A & B Tx power for 2T
+ priv->RfOfdmChnlAreaTxPwr2T[rf_path][i] =
+ hwinfo[EEPROM_TxPwIndex+12+rf_path*3+i];
+ }
+ }
+
+ }
+//
+ // Update Tx Power HAL variables.
+//
+ for (rf_path = 0; rf_path < 2; rf_path++)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ RT_TRACE((COMP_INIT), "CCK RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
+ priv->RfCckChnlAreaTxPwr[rf_path][i]);
+ RT_TRACE((COMP_INIT), "OFDM-1T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
+ priv->RfOfdmChnlAreaTxPwr1T[rf_path][i]);
+ RT_TRACE((COMP_INIT), "OFDM-2T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i, priv->RfOfdmChnlAreaTxPwr2T[rf_path][i]);
+ }
+
+ // Assign dedicated channel tx power
+ for(i=0; i<14; i++) // channel 1~3 use the same Tx Power Level.
+ {
+ if (i < 3) // Cjanel 1-3
+ index = 0;
+ else if (i < 9) // Channel 4-9
+ index = 1;
+ else // Channel 10-14
+ index = 2;
+
+ // Record A & B CCK /OFDM - 1T/2T Channel area tx power
+ priv->RfTxPwrLevelCck[rf_path][i] =
+ priv->RfCckChnlAreaTxPwr[rf_path][index];
+ priv->RfTxPwrLevelOfdm1T[rf_path][i] =
+ priv->RfOfdmChnlAreaTxPwr1T[rf_path][index];
+ priv->RfTxPwrLevelOfdm2T[rf_path][i] =
+ priv->RfOfdmChnlAreaTxPwr2T[rf_path][index];
+ if (rf_path == 0)
+ {
+ priv->TxPowerLevelOFDM24G[i] = priv->RfTxPwrLevelOfdm1T[rf_path][i] ;
+ priv->TxPowerLevelCCK[i] = priv->RfTxPwrLevelCck[rf_path][i];
+ }
+ }
+
+ for(i=0; i<14; i++)
+ {
+ RT_TRACE((COMP_INIT),
+ "Rf-%d TxPwr CH-%d CCK OFDM_1T OFDM_2T= 0x%x/0x%x/0x%x\n",
+ rf_path, i, priv->RfTxPwrLevelCck[rf_path][i],
+ priv->RfTxPwrLevelOfdm1T[rf_path][i] ,
+ priv->RfTxPwrLevelOfdm2T[rf_path][i] );
+ }
+ }
+ }
+
+ //
+ // 2009/02/09 Cosa add for new EEPROM format
+ //
+ for(i=0; i<14; i++) // channel 1~3 use the same Tx Power Level.
+ {
+ // Read tx power difference between HT OFDM 20/40 MHZ
+ if (i < 3) // Cjanel 1-3
+ index = 0;
+ else if (i < 9) // Channel 4-9
+ index = 1;
+ else // Channel 10-14
+ index = 2;
+
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_HT20_DIFF+index])&0xff;
+ priv->TxPwrHt20Diff[RF90_PATH_A][i] = (tempval&0xF);
+ priv->TxPwrHt20Diff[RF90_PATH_B][i] = ((tempval>>4)&0xF);
+
+ // Read OFDM<->HT tx power diff
+ if (i < 3) // Cjanel 1-3
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF])&0xff;
+ else if (i < 9) // Channel 4-9
+ tempval = (*(u8 *)&hwinfo[EEPROM_PwDiff])&0xff;
+ else // Channel 10-14
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF+1])&0xff;
+
+ //cosa tempval = (*(u1Byte *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF+index])&0xff;
+ priv->TxPwrLegacyHtDiff[RF90_PATH_A][i] = (tempval&0xF);
+ priv->TxPwrLegacyHtDiff[RF90_PATH_B][i] = ((tempval>>4)&0xF);
+
+ //
+ // Read Band Edge tx power offset and check if user enable the ability
+ //
+ // HT 40 band edge channel
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE])&0xff;
+ priv->TxPwrbandEdgeHt40[RF90_PATH_A][0] = (tempval&0xF); // Band edge low channel
+ priv->TxPwrbandEdgeHt40[RF90_PATH_A][1] = ((tempval>>4)&0xF); // Band edge high channel
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+1])&0xff;
+ priv->TxPwrbandEdgeHt40[RF90_PATH_B][0] = (tempval&0xF); // Band edge low channel
+ priv->TxPwrbandEdgeHt40[RF90_PATH_B][1] = ((tempval>>4)&0xF); // Band edge high channel
+ // HT 20 band edge channel
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+2])&0xff;
+ priv->TxPwrbandEdgeHt20[RF90_PATH_A][0] = (tempval&0xF); // Band edge low channel
+ priv->TxPwrbandEdgeHt20[RF90_PATH_A][1] = ((tempval>>4)&0xF); // Band edge high channel
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+3])&0xff;
+ priv->TxPwrbandEdgeHt20[RF90_PATH_B][0] = (tempval&0xF); // Band edge low channel
+ priv->TxPwrbandEdgeHt20[RF90_PATH_B][1] = ((tempval>>4)&0xF); // Band edge high channel
+ // OFDM band edge channel
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+4])&0xff;
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][0] = (tempval&0xF); // Band edge low channel
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][1] = ((tempval>>4)&0xF); // Band edge high channel
+ tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+5])&0xff;
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][0] = (tempval&0xF); // Band edge low channel
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][1] = ((tempval>>4)&0xF); // Band edge high channel
+
+ priv->TxPwrbandEdgeFlag = (*(u8 *)&hwinfo[TX_PWR_BAND_EDGE_CHK]);
+ }
+
+ for(i=0; i<14; i++)
+ RT_TRACE(COMP_INIT, "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, priv->TxPwrHt20Diff[RF90_PATH_A][i]);
+ for(i=0; i<14; i++)
+ RT_TRACE(COMP_INIT, "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, priv->TxPwrLegacyHtDiff[RF90_PATH_A][i]);
+ for(i=0; i<14; i++)
+ RT_TRACE(COMP_INIT, "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, priv->TxPwrHt20Diff[RF90_PATH_B][i]);
+ for(i=0; i<14; i++)
+ RT_TRACE(COMP_INIT, "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, priv->TxPwrLegacyHtDiff[RF90_PATH_B][i]);
+ RT_TRACE(COMP_INIT, "RF-A HT40 band-edge low/high power diff = 0x%x/0x%x\n",
+ priv->TxPwrbandEdgeHt40[RF90_PATH_A][0],
+ priv->TxPwrbandEdgeHt40[RF90_PATH_A][1]);
+ RT_TRACE((COMP_INIT&COMP_DBG), "RF-B HT40 band-edge low/high power diff = 0x%x/0x%x\n",
+ priv->TxPwrbandEdgeHt40[RF90_PATH_B][0],
+ priv->TxPwrbandEdgeHt40[RF90_PATH_B][1]);
+
+ RT_TRACE((COMP_INIT&COMP_DBG), "RF-A HT20 band-edge low/high power diff = 0x%x/0x%x\n",
+ priv->TxPwrbandEdgeHt20[RF90_PATH_A][0],
+ priv->TxPwrbandEdgeHt20[RF90_PATH_A][1]);
+ RT_TRACE((COMP_INIT&COMP_DBG), "RF-B HT20 band-edge low/high power diff = 0x%x/0x%x\n",
+ priv->TxPwrbandEdgeHt20[RF90_PATH_B][0],
+ priv->TxPwrbandEdgeHt20[RF90_PATH_B][1]);
+
+ RT_TRACE((COMP_INIT&COMP_DBG), "RF-A OFDM band-edge low/high power diff = 0x%x/0x%x\n",
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][0],
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][1]);
+ RT_TRACE((COMP_INIT&COMP_DBG), "RF-B OFDM band-edge low/high power diff = 0x%x/0x%x\n",
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][0],
+ priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][1]);
+ RT_TRACE((COMP_INIT&COMP_DBG), "Band-edge enable flag = %d\n", priv->TxPwrbandEdgeFlag);
+#endif
+
+ //
+ // Update remained HAL variables.
+ //
+ priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
+ priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff;
+ priv->TxPowerDiff = priv->EEPROMTxPowerDiff;
+ //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit[3:0]
+ //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit[7:4]
+ priv->CrystalCap = priv->EEPROMCrystalCap; // CrystalCap, bit[15:12]
+ priv->ThermalMeter[0] = (priv->EEPROMThermalMeter&0x1f);// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+ priv->LedStrategy = SW_LED_MODE0;
+
+ init_rate_adaptive(dev);
+
+ RT_TRACE(COMP_INIT, "<==== ReadAdapterInfo8192SUsb\n");
+
+ //return RT_STATUS_SUCCESS;
+}
+
+
+//
+// Description:
+// Read HW adapter information by E-Fuse or EEPROM according CR9346 reported.
+//
+// Assumption:
+// 1. CR9346 regiser has verified.
+// 2. PASSIVE_LEVEL (USB interface)
+//
+// Created by Roger, 2008.10.21.
+//
+static void rtl8192SU_read_eeprom_info(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 tmpU1b;
+
+ RT_TRACE(COMP_INIT, "====> ReadAdapterInfo8192SUsb\n");
+
+ // Retrieve Chip version.
+ priv->card_8192_version = (VERSION_8192S)((read_nic_dword(dev, PMC_FSM)>>16)&0xF);
+ RT_TRACE(COMP_INIT, "Chip Version ID: 0x%2x\n", priv->card_8192_version);
+
+ tmpU1b = read_nic_byte(dev, EPROM_CMD);//CR9346
+
+ // To check system boot selection.
+ if (tmpU1b & CmdEERPOMSEL)
+ {
+ RT_TRACE(COMP_INIT, "Boot from EEPROM\n");
+ priv->EepromOrEfuse = TRUE;
+ }
+ else
+ {
+ RT_TRACE(COMP_INIT, "Boot from EFUSE\n");
+ priv->EepromOrEfuse = FALSE;
+ }
+
+ // To check autoload success or not.
+ if (tmpU1b & CmdEEPROM_En)
+ {
+ RT_TRACE(COMP_INIT, "Autoload OK!!\n");
+ priv->AutoloadFailFlag=FALSE;
+ rtl8192SU_ReadAdapterInfo8192SUsb(dev);//eeprom or e-fuse
+ }
+ else
+ { // Auto load fail.
+ RT_TRACE(COMP_INIT, "AutoLoad Fail reported from CR9346!!\n");
+ priv->AutoloadFailFlag=TRUE;
+ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev);
+
+ //if (IS_BOOT_FROM_EFUSE(Adapter))
+ if(!priv->EepromOrEfuse)
+ {
+ RT_TRACE(COMP_INIT, "Update shadow map for EFuse future use!!\n");
+ EFUSE_ShadowMapUpdate(dev);
+ }
+ }
+#ifdef TO_DO_LIST
+ if((priv->RegChannelPlan >= RT_CHANNEL_DOMAIN_MAX) || (pHalData->EEPROMChannelPlan & EEPROM_CHANNEL_PLAN_BY_HW_MASK))
+ {
+ pMgntInfo->ChannelPlan = HalMapChannelPlan8192S(Adapter, (pHalData->EEPROMChannelPlan & (~(EEPROM_CHANNEL_PLAN_BY_HW_MASK))));
+ pMgntInfo->bChnlPlanFromHW = (pHalData->EEPROMChannelPlan & EEPROM_CHANNEL_PLAN_BY_HW_MASK) ? TRUE : FALSE; // User cannot change channel plan.
+ }
+ else
+ {
+ pMgntInfo->ChannelPlan = (RT_CHANNEL_DOMAIN)pMgntInfo->RegChannelPlan;
+ }
+
+ switch(pMgntInfo->ChannelPlan)
+ {
+ case RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN:
+ {
+ PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(pMgntInfo);
+
+ pDot11dInfo->bEnabled = TRUE;
+ }
+ RT_TRACE(COMP_INIT, DBG_LOUD, ("ReadAdapterInfo8187(): Enable dot11d when RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN!\n"));
+ break;
+ }
+
+ RT_TRACE(COMP_INIT, DBG_LOUD, ("RegChannelPlan(%d) EEPROMChannelPlan(%d)", pMgntInfo->RegChannelPlan, pHalData->EEPROMChannelPlan));
+ RT_TRACE(COMP_INIT, DBG_LOUD, ("ChannelPlan = %d\n" , pMgntInfo->ChannelPlan));
+
+ RT_TRACE(COMP_INIT, DBG_LOUD, ("<==== ReadAdapterInfo8192S\n"));
+#endif
+
+ RT_TRACE(COMP_INIT, "<==== ReadAdapterInfo8192SUsb\n");
+
+ //return RT_STATUS_SUCCESS;
+}
+#else
+static void rtl8192_read_eeprom_info(struct net_device* dev)
+{
+ u16 wEPROM_ID = 0;
+ u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x02};
+ u8 bLoad_From_EEPOM = false;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 tmpValue = 0;
+ RT_TRACE(COMP_EPROM, "===========>%s()\n", __FUNCTION__);
+ wEPROM_ID = eprom_read(dev, 0); //first read EEPROM ID out;
+ RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", wEPROM_ID);
+
+ if (wEPROM_ID != RTL8190_EEPROM_ID)
+ {
+ RT_TRACE(COMP_ERR, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", wEPROM_ID, RTL8190_EEPROM_ID);
+ }
+ else
+ bLoad_From_EEPOM = true;
+
+ if (bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (EEPROM_VID>>1));
+ priv->eeprom_vid = endian_swap(&tmpValue);
+ priv->eeprom_pid = eprom_read(dev, (EEPROM_PID>>1));
+ tmpValue = eprom_read(dev, (EEPROM_ChannelPlan>>1));
+ priv->eeprom_ChannelPlan =((tmpValue&0xff00)>>8);
+ priv->btxpowerdata_readfromEEPORM = true;
+ priv->eeprom_CustomerID = eprom_read(dev, (EEPROM_Customer_ID>>1)) >>8;
+ }
+ else
+ {
+ priv->eeprom_vid = 0;
+ priv->eeprom_pid = 0;
+ priv->card_8192_version = VERSION_819xU_B;
+ priv->eeprom_ChannelPlan = 0;
+ priv->eeprom_CustomerID = 0;
+ }
+ RT_TRACE(COMP_EPROM, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID, priv->eeprom_ChannelPlan);
+ //set channelplan from eeprom
+ priv->ChannelPlan = priv->eeprom_ChannelPlan;
+ if (bLoad_From_EEPOM)
+ {
+ int i;
+ for (i=0; i<6; i+=2)
+ {
+ u16 tmp = 0;
+ tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i)>>1));
+ *(u16*)(&dev->dev_addr[i]) = tmp;
+ }
+ }
+ else
+ {
+ memcpy(dev->dev_addr, bMac_Tmp_Addr, 6);
+ //should I set IDR0 here?
+ }
+ RT_TRACE(COMP_EPROM, "MAC addr:"MAC_FMT"\n", MAC_ARG(dev->dev_addr));
+ priv->rf_type = RTL819X_DEFAULT_RF_TYPE; //default 1T2R
+ priv->rf_chip = RF_8256;
+
+ if (priv->card_8192_version == (u8)VERSION_819xU_A)
+ {
+ //read Tx power gain offset of legacy OFDM to HT rate
+ if (bLoad_From_EEPOM)
+ priv->EEPROMTxPowerDiff = (eprom_read(dev, (EEPROM_TxPowerDiff>>1))&0xff00) >> 8;
+ else
+ priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower;
+ RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff);
+ //read ThermalMeter from EEPROM
+ if (bLoad_From_EEPOM)
+ priv->EEPROMThermalMeter = (u8)(eprom_read(dev, (EEPROM_ThermalMeter>>1))&0x00ff);
+ else
+ priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+ RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter);
+ //vivi, for tx power track
+ priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
+ //read antenna tx power offset of B/C/D to A from EEPROM
+ if (bLoad_From_EEPOM)
+ priv->EEPROMPwDiff = (eprom_read(dev, (EEPROM_PwDiff>>1))&0x0f00)>>8;
+ else
+ priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
+ RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff);
+ // Read CrystalCap from EEPROM
+ if (bLoad_From_EEPOM)
+ priv->EEPROMCrystalCap = (eprom_read(dev, (EEPROM_CrystalCap>>1))&0x0f);
+ else
+ priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+ RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap);
+ //get per-channel Tx power level
+ if (bLoad_From_EEPOM)
+ priv->EEPROM_Def_Ver = (eprom_read(dev, (EEPROM_TxPwIndex_Ver>>1))&0xff00)>>8;
+ else
+ priv->EEPROM_Def_Ver = 1;
+ RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver);
+ if (priv->EEPROM_Def_Ver == 0) //old eeprom definition
+ {
+ int i;
+ if (bLoad_From_EEPOM)
+ priv->EEPROMTxPowerLevelCCK = (eprom_read(dev, (EEPROM_TxPwIndex_CCK>>1))&0xff) >> 8;
+ else
+ priv->EEPROMTxPowerLevelCCK = 0x10;
+ RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
+ for (i=0; i<3; i++)
+ {
+ if (bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G+i)>>1);
+ if (((EEPROM_TxPwIndex_OFDM_24G+i) % 2) == 0)
+ tmpValue = tmpValue & 0x00ff;
+ else
+ tmpValue = (tmpValue & 0xff00) >> 8;
+ }
+ else
+ tmpValue = 0x10;
+ priv->EEPROMTxPowerLevelOFDM24G[i] = (u8) tmpValue;
+ RT_TRACE(COMP_EPROM, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK);
+ }
+ }//end if EEPROM_DEF_VER == 0
+ else if (priv->EEPROM_Def_Ver == 1)
+ {
+ if (bLoad_From_EEPOM)
+ {
+ tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1>>1));
+ tmpValue = (tmpValue & 0xff00) >> 8;
+ }
+ else
+ tmpValue = 0x10;
+ priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)tmpValue;
+
+ if (bLoad_From_EEPOM)
+ tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2)>>1);
+ else
+ tmpValue = 0x1010;
+ *((u16*)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = tmpValue;
+ if (bLoad_From_EEPOM)
+ tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1>>1));
+ else
+ tmpValue = 0x1010;
+ *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[0])) = tmpValue;
+ if (bLoad_From_EEPOM)
+ tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1+2)>>1);
+ else
+ tmpValue = 0x10;
+ priv->EEPROMTxPowerLevelOFDM24G[2] = (u8)tmpValue;
+ }//endif EEPROM_Def_Ver == 1
+
+ //update HAL variables
+ //
+ {
+ int i;
+ for (i=0; i<14; i++)
+ {
+ if (i<=3)
+ priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[0];
+ else if (i>=4 && i<=9)
+ priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[1];
+ else
+ priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[2];
+ }
+
+ for (i=0; i<14; i++)
+ {
+ if (priv->EEPROM_Def_Ver == 0)
+ {
+ if (i<=3)
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelOFDM24G[0] + (priv->EEPROMTxPowerLevelCCK - priv->EEPROMTxPowerLevelOFDM24G[1]);
+ else if (i>=4 && i<=9)
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK;
+ else
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelOFDM24G[2] + (priv->EEPROMTxPowerLevelCCK - priv->EEPROMTxPowerLevelOFDM24G[1]);
+ }
+ else if (priv->EEPROM_Def_Ver == 1)
+ {
+ if (i<=3)
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[0];
+ else if (i>=4 && i<=9)
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[1];
+ else
+ priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[2];
+ }
+ }
+ }//end update HAL variables
+ priv->TxPowerDiff = priv->EEPROMPwDiff;
+// Antenna B gain offset to antenna A, bit0~3
+ priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
+ // Antenna C gain offset to antenna A, bit4~7
+ priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);
+ // CrystalCap, bit12~15
+ priv->CrystalCap = priv->EEPROMCrystalCap;
+ // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+ // 92U does not enable TX power tracking.
+ priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
+ }//end if VersionID == VERSION_819xU_A
+
+//added by vivi, for dlink led, 20080416
+ switch(priv->eeprom_CustomerID)
+ {
+ case EEPROM_CID_RUNTOP:
+ priv->CustomerID = RT_CID_819x_RUNTOP;
+ break;
+
+ case EEPROM_CID_DLINK:
+ priv->CustomerID = RT_CID_DLINK;
+ break;
+
+ default:
+ priv->CustomerID = RT_CID_DEFAULT;
+ break;
+
+ }
+
+ switch(priv->CustomerID)
+ {
+ case RT_CID_819x_RUNTOP:
+ priv->LedStrategy = SW_LED_MODE2;
+ break;
+
+ case RT_CID_DLINK:
+ priv->LedStrategy = SW_LED_MODE4;
+ break;
+
+ default:
+ priv->LedStrategy = SW_LED_MODE0;
+ break;
+
+ }
+
+
+ if(priv->rf_type == RF_1T2R)
+ {
+ RT_TRACE(COMP_EPROM, "\n1T2R config\n");
+ }
+ else
+ {
+ RT_TRACE(COMP_EPROM, "\n2T4R config\n");
+ }
+
+ // 2008/01/16 MH We can only know RF type in the function. So we have to init
+ // DIG RATR table again.
+ init_rate_adaptive(dev);
+ //we need init DIG RATR table here again.
+
+ RT_TRACE(COMP_EPROM, "<===========%s()\n", __FUNCTION__);
+ return;
+}
+#endif
+
+short rtl8192_get_channel_map(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#ifdef ENABLE_DOT11D
+ if(priv->ChannelPlan > COUNTRY_CODE_GLOBAL_DOMAIN){
+ printk("rtl8180_init:Error channel plan! Set to default.\n");
+ priv->ChannelPlan= 0;
+ }
+ RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan);
+
+ rtl819x_set_channel_map(priv->ChannelPlan, priv);
+#else
+ int ch,i;
+ //Set Default Channel Plan
+ if(!channels){
+ DMESG("No channels, aborting");
+ return -1;
+ }
+ ch=channels;
+ priv->ChannelPlan= 0;//hikaru
+ // set channels 1..14 allowed in given locale
+ for (i=1; i<=14; i++) {
+ (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
+ ch >>= 1;
+ }
+#endif
+ return 0;
+}
+
+short rtl8192_init(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+#ifndef RTL8192SU
+ memset(&(priv->stats),0,sizeof(struct Stats));
+ memset(priv->txqueue_to_outpipemap,0,9);
+#ifdef PIPE12
+ {
+ int i=0;
+ u8 queuetopipe[]={3,2,1,0,4,8,7,6,5};
+ memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
+/* for(i=0;i<9;i++)
+ printk("%d ",priv->txqueue_to_outpipemap[i]);
+ printk("\n");*/
+ }
+#else
+ {
+ u8 queuetopipe[]={3,2,1,0,4,4,0,4,4};
+ memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
+/* for(i=0;i<9;i++)
+ printk("%d ",priv->txqueue_to_outpipemap[i]);
+ printk("\n");*/
+ }
+#endif
+#endif
+ rtl8192_init_priv_variable(dev);
+ rtl8192_init_priv_lock(priv);
+ rtl8192_init_priv_task(dev);
+ rtl8192_get_eeprom_size(dev);
+ priv->ops->rtl819x_read_eeprom_info(dev);
+ rtl8192_get_channel_map(dev);
+ init_hal_dm(dev);
+ init_timer(&priv->watch_dog_timer);
+ priv->watch_dog_timer.data = (unsigned long)dev;
+ priv->watch_dog_timer.function = watch_dog_timer_callback;
+
+ //rtl8192_adapter_start(dev);
+#ifdef DEBUG_EPROM
+ dump_eprom(dev);
+#endif
+ return 0;
+}
+
+/******************************************************************************
+ *function: This function actually only set RRSR, RATR and BW_OPMODE registers
+ * not to do all the hw config as its name says
+ * input: net_device dev
+ * output: none
+ * return: none
+ * notice: This part need to modified according to the rate set we filtered
+ * ****************************************************************************/
+void rtl8192_hwconfig(struct net_device* dev)
+{
+ u32 regRATR = 0, regRRSR = 0;
+ u8 regBwOpMode = 0, regTmp = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+// Set RRSR, RATR, and BW_OPMODE registers
+ //
+ switch(priv->ieee80211->mode)
+ {
+ case WIRELESS_MODE_B:
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK;
+ regRRSR = RATE_ALL_CCK;
+ break;
+ case WIRELESS_MODE_A:
+ regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_OFDM_AG;
+ regRRSR = RATE_ALL_OFDM_AG;
+ break;
+ case WIRELESS_MODE_G:
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ break;
+ case WIRELESS_MODE_AUTO:
+#ifdef TO_DO_LIST
+ if (Adapter->bInHctTest)
+ {
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ }
+ else
+#endif
+ {
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ }
+ break;
+ case WIRELESS_MODE_N_24G:
+ // It support CCK rate by default.
+ // CCK rate will be filtered out only when associated AP does not support it.
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ break;
+ case WIRELESS_MODE_N_5G:
+ regBwOpMode = BW_OPMODE_5G;
+ regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+ regRRSR = RATE_ALL_OFDM_AG;
+ break;
+ }
+
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ {
+ u32 ratr_value = 0;
+ ratr_value = regRATR;
+ if (priv->rf_type == RF_1T2R)
+ {
+ ratr_value &= ~(RATE_ALL_OFDM_2SS);
+ }
+ write_nic_dword(dev, RATR0, ratr_value);
+ write_nic_byte(dev, UFWP, 1);
+ }
+ regTmp = read_nic_byte(dev, 0x313);
+ regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff);
+ write_nic_dword(dev, RRSR, regRRSR);
+
+ //
+ // Set Retry Limit here
+ //
+ write_nic_word(dev, RETRY_LIMIT,
+ priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \
+ priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT);
+ // Set Contention Window here
+
+ // Set Tx AGC
+
+ // Set Tx Antenna including Feedback control
+
+ // Set Auto Rate fallback control
+
+
+}
+
+#ifdef RTL8192SU
+#ifdef USB_RX_AGGREGATION_SUPPORT
+u8 rtl8192SU_MapRxPageSizeToIdx(u16 RxPktSize )
+{
+ switch(RxPktSize)
+ {
+ case 64: return 0; break;
+ case 128 : return 1; break;
+ case 256: return 2; break;
+ case 512: return 3; break;
+ case 1024: return 4; break;
+ default: return 0; // We use 64bytes in defult.
+ }
+}
+#endif
+
+//
+// Description:
+// Initial HW relted registers.
+//
+// Assumption:
+// Config RTL8192S USB MAC, we should config MAC before download FW.
+//
+// 2008.09.03, Added by Roger.
+//
+static void rtl8192SU_MacConfigBeforeFwDownloadASIC(struct net_device *dev)
+{
+ u8 tmpU1b;// i;
+// u16 tmpU2b;
+// u32 tmpU4b;
+ u8 PollingCnt = 20;
+
+ RT_TRACE(COMP_INIT, "--->MacConfigBeforeFwDownloadASIC()\n");
+
+ //2MAC Initialization for power on sequence, Revised by Roger. 2008.09.03.
+
+ //
+ //<Roger_Notes> Set control path switch to HW control and reset Digital Core, CPU Core and
+ // MAC I/O to solve FW download fail when system from resume sate.
+ // 2008.11.04.
+ //
+ tmpU1b = read_nic_byte(dev, SYS_CLKR+1);
+ if(tmpU1b & 0x80)
+ {
+ tmpU1b &= 0x3f;
+ write_nic_byte(dev, SYS_CLKR+1, tmpU1b);
+ }
+ // Clear FW RPWM for FW control LPS. by tynli. 2009.02.23
+ write_nic_byte(dev, RPWM, 0x0);
+
+ tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
+ tmpU1b &= 0x73;
+ write_nic_byte(dev, SYS_FUNC_EN+1, tmpU1b);
+ udelay(1000);
+
+ //Revised POS, suggested by SD1 Alex, 2008.09.27.
+ write_nic_byte(dev, SPS0_CTRL+1, 0x53);
+ write_nic_byte(dev, SPS0_CTRL, 0x57);
+
+ //Enable AFE Macro Block's Bandgap adn Enable AFE Macro Block's Mbias
+ tmpU1b = read_nic_byte(dev, AFE_MISC);
+ write_nic_byte(dev, AFE_MISC, (tmpU1b|AFE_BGEN|AFE_MBEN));
+
+ //Enable PLL Power (LDOA15V)
+ tmpU1b = read_nic_byte(dev, LDOA15_CTRL);
+ write_nic_byte(dev, LDOA15_CTRL, (tmpU1b|LDA15_EN));
+
+ //Enable LDOV12D block
+ tmpU1b = read_nic_byte(dev, LDOV12D_CTRL);
+ write_nic_byte(dev, LDOV12D_CTRL, (tmpU1b|LDV12_EN));
+
+ //mpU1b = read_nic_byte(Adapter, SPS1_CTRL);
+ //write_nic_byte(dev, SPS1_CTRL, (tmpU1b|SPS1_LDEN));
+
+ //PlatformSleepUs(2000);
+
+ //Enable Switch Regulator Block
+ //tmpU1b = read_nic_byte(Adapter, SPS1_CTRL);
+ //write_nic_byte(dev, SPS1_CTRL, (tmpU1b|SPS1_SWEN));
+
+ //write_nic_dword(Adapter, SPS1_CTRL, 0x00a7b267);
+
+ tmpU1b = read_nic_byte(dev, SYS_ISO_CTRL+1);
+ write_nic_byte(dev, SYS_ISO_CTRL+1, (tmpU1b|0x08));
+
+ //Engineer Packet CP test Enable
+ tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
+ write_nic_byte(dev, SYS_FUNC_EN+1, (tmpU1b|0x20));
+
+ //Support 64k IMEM, suggested by SD1 Alex.
+ tmpU1b = read_nic_byte(dev, SYS_ISO_CTRL+1);
+ write_nic_byte(dev, SYS_ISO_CTRL+1, (tmpU1b& 0x68));
+
+ //Enable AFE clock
+ tmpU1b = read_nic_byte(dev, AFE_XTAL_CTRL+1);
+ write_nic_byte(dev, AFE_XTAL_CTRL+1, (tmpU1b& 0xfb));
+
+ //Enable AFE PLL Macro Block
+ tmpU1b = read_nic_byte(dev, AFE_PLL_CTRL);
+ write_nic_byte(dev, AFE_PLL_CTRL, (tmpU1b|0x11));
+
+ //Attatch AFE PLL to MACTOP/BB/PCIe Digital
+ tmpU1b = read_nic_byte(dev, SYS_ISO_CTRL);
+ write_nic_byte(dev, SYS_ISO_CTRL, (tmpU1b&0xEE));
+
+ // Switch to 40M clock
+ write_nic_byte(dev, SYS_CLKR, 0x00);
+
+ //SSC Disable
+ tmpU1b = read_nic_byte(dev, SYS_CLKR);
+ //write_nic_byte(dev, SYS_CLKR, (tmpU1b&0x5f));
+ write_nic_byte(dev, SYS_CLKR, (tmpU1b|0xa0));
+
+ //Enable MAC clock
+ tmpU1b = read_nic_byte(dev, SYS_CLKR+1);
+ write_nic_byte(dev, SYS_CLKR+1, (tmpU1b|0x18));
+
+ //Revised POS, suggested by SD1 Alex, 2008.09.27.
+ write_nic_byte(dev, PMC_FSM, 0x02);
+
+ //Enable Core digital and enable IOREG R/W
+ tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
+ write_nic_byte(dev, SYS_FUNC_EN+1, (tmpU1b|0x08));
+
+ //Enable REG_EN
+ tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
+ write_nic_byte(dev, SYS_FUNC_EN+1, (tmpU1b|0x80));
+
+ //Switch the control path to FW
+ tmpU1b = read_nic_byte(dev, SYS_CLKR+1);
+ write_nic_byte(dev, SYS_CLKR+1, (tmpU1b|0x80)& 0xBF);
+
+ write_nic_byte(dev, CMDR, 0xFC);
+ write_nic_byte(dev, CMDR+1, 0x37);
+
+ //Fix the RX FIFO issue(usb error), 970410
+ tmpU1b = read_nic_byte_E(dev, 0x5c);
+ write_nic_byte_E(dev, 0x5c, (tmpU1b|BIT7));
+
+ //For power save, used this in the bit file after 970621
+ tmpU1b = read_nic_byte(dev, SYS_CLKR);
+ write_nic_byte(dev, SYS_CLKR, tmpU1b&(~SYS_CPU_CLKSEL));
+
+ // Revised for 8051 ROM code wrong operation. Added by Roger. 2008.10.16.
+ write_nic_byte_E(dev, 0x1c, 0x80);
+
+ //
+ // <Roger_EXP> To make sure that TxDMA can ready to download FW.
+ // We should reset TxDMA if IMEM RPT was not ready.
+ // Suggested by SD1 Alex. 2008.10.23.
+ //
+ do
+ {
+ tmpU1b = read_nic_byte(dev, TCR);
+ if((tmpU1b & TXDMA_INIT_VALUE) == TXDMA_INIT_VALUE)
+ break;
+ //PlatformStallExecution(5);
+ udelay(5);
+ }while(PollingCnt--); // Delay 1ms
+
+ if(PollingCnt <= 0 )
+ {
+ RT_TRACE(COMP_INIT, "MacConfigBeforeFwDownloadASIC(): Polling TXDMA_INIT_VALUE timeout!! Current TCR(%#x)\n", tmpU1b);
+ tmpU1b = read_nic_byte(dev, CMDR);
+ write_nic_byte(dev, CMDR, tmpU1b&(~TXDMA_EN));
+ udelay(2);
+ write_nic_byte(dev, CMDR, tmpU1b|TXDMA_EN);// Reset TxDMA
+ }
+
+
+ RT_TRACE(COMP_INIT, "<---MacConfigBeforeFwDownloadASIC()\n");
+}
+#ifdef USB_RX_AGGREGATION_SUPPORT
+void rtl8192SU_HalUsbRxAggr8192SUsb(struct net_device *dev, bool Value)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;;
+
+
+ //
+ // <Roger_Notes> We decrease Rx page aggregated threshold in B/G mode.
+ // 2008.10.29
+ //
+ if(priv->ieee80211->mode == WIRELESS_MODE_B || priv->ieee80211->mode == WIRELESS_MODE_G)
+ {// Overwrite current settings to disable Rx Aggregation.
+ Value = false;
+ }
+
+ // Alway set Rx Aggregation to Disable if current platform is Win2K USB 1.1, by Emily
+ //if(PLATFORM_LIMITED_RX_BUF_SIZE(Adapter))
+ // Value = FALSE;
+
+ // Always set Rx Aggregation to Disable if connected AP is Realtek AP, by Joseph
+ //if(pHTInfo->bCurrentRT2RTAggregation)
+ // Value = FALSE;
+
+ // The RX aggregation may be enabled/disabled dynamically according current traffic stream.
+ //Enable Rx aggregation if downlink traffic is busier than uplink traffic. by Guangan
+ if(priv->bCurrentRxAggrEnable != Value)
+ {
+ priv->bCurrentRxAggrEnable = Value;
+ //Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_USB_RX_AGGR, (pu1Byte)&pHalData->bCurrentRxAggrEnable);
+ {
+ //u8 Setting = ((pu1Byte)(val))[0];
+ u8 Setting = priv->bCurrentRxAggrEnable
+ u32 ulValue;
+
+ if(Setting==0)
+ {
+ //
+ // <Roger_Notes> Reduce aggregated page threshold to 0x01 and set minimal threshold 0x0a.
+ // i.e., disable Rx aggregation.
+ //
+ ulValue = 0x0001000a;
+ }
+ else
+ {
+ //PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
+
+ if (priv->bForcedUsbRxAggr)
+ {// Using forced settings.
+ ulValue = priv->ForcedUsbRxAggrInfo;
+ }
+ else
+ {// Using default settings.
+
+ ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
+ (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
+ }
+ }
+
+ write_nic_byte(dev, RXDMA_AGG_PG_TH, (u8)((ulValue&0xff0000)>>16));
+ write_nic_byte_E(dev, USB_RX_AGG_TIMEOUT, (u8)(ulValue&0xff));
+
+ priv->LastUsbRxAggrInfoSetting = ulValue;
+
+ RT_TRACE(COMP_HT|COMP_RECV, "Set HW_VAR_USB_RX_AGGR: ulValue(%#x)\n", ulValue);
+ }
+ RT_TRACE(COMP_RECV, "HalUsbRxAggr8192SUsb() : Set RxAggregation to %s\n", Value?"ON":"OFF");
+ }
+
+}
+#endif
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+void rtl8192SU_HalUsbRxAggr8192SUsb(struct net_device *dev, bool Value)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;;
+
+
+ //
+ // <Roger_Notes> We decrease Rx page aggregated threshold in B/G mode.
+ // 2008.10.29
+ //
+ if((priv->ieee80211->mode & WIRELESS_MODE_B) || (priv->ieee80211->mode & WIRELESS_MODE_G))
+ {// Overwrite current settings to disable Rx Aggregation.
+ Value = false;
+ }
+
+ // Alway set Rx Aggregation to Disable if current platform is Win2K USB 1.1, by Emily
+ //if(PLATFORM_LIMITED_RX_BUF_SIZE(Adapter))
+ // Value = FALSE;
+
+ // Always set Rx Aggregation to Disable if connected AP is Realtek AP, by Joseph
+ //if(pHTInfo->bCurrentRT2RTAggregation)
+ // Value = FALSE;
+
+ // The RX aggregation may be enabled/disabled dynamically according current traffic stream.
+ //Enable Rx aggregation if downlink traffic is busier than uplink traffic. by Guangan
+ if(priv->bCurrentRxAggrEnable != Value)
+ {
+ priv->bCurrentRxAggrEnable = Value;
+ //Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_USB_RX_AGGR, (pu1Byte)&pHalData->bCurrentRxAggrEnable);
+ {
+ //u8 Setting = ((pu1Byte)(val))[0];
+ u8 Setting = priv->bCurrentRxAggrEnable
+ u32 ulValue;
+
+ if(Setting==0)
+ {
+ //
+ // <Roger_Notes> Reduce aggregated page threshold to 0x01 and set minimal threshold 0x0a.
+ // i.e., disable Rx aggregation.
+ //
+ ulValue = 0x0001000a;
+ }
+ else
+ {
+ //PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
+
+ if (priv->bForcedUsbRxAggr)
+ {// Using forced settings.
+ ulValue = priv->ForcedUsbRxAggrInfo;
+ }
+ else
+ {// Using default settings.
+
+ ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
+ (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
+ }
+ }
+
+ write_nic_byte(dev, RXDMA_AGG_PG_TH, (u8)((ulValue&0xff0000)>>16));
+ write_nic_byte_E(dev, USB_RX_AGG_TIMEOUT, (u8)(ulValue&0xff));
+
+ priv->LastUsbRxAggrInfoSetting = ulValue;
+
+ RT_TRACE(COMP_HT|COMP_RECV, "Set HW_VAR_USB_RX_AGGR: ulValue(%#x)\n", ulValue);
+ }
+ RT_TRACE(COMP_RECV, "HalUsbRxAggr8192SUsb() : Set RxAggregation to %s\n", Value?"ON":"OFF");
+ }
+
+}
+
+u8 rtl8192SU_MapRxPageSizeToIdx(u16 RxPktSize )
+{
+ switch(RxPktSize)
+ {
+ case 64: return 0; break;
+ case 128 : return 1; break;
+ case 256: return 2; break;
+ case 512: return 3; break;
+ case 1024: return 4; break;
+ default: return 0; // We use 64bytes in defult.
+ }
+}
+#endif
+
+#if 0
+static void rtl8192SU_SetHwRegAmpduMinSpace(struct net_device *dev, u8 MinSpaceCfg)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ u8 MinSpacingToSet;
+ u8 SecMinSpace;
+
+#ifdef RTL8192S_PREPARE_FOR_NORMAL_RELEASE
+ MinSpacingToSet = MinSpaceCfg;
+ if(MinSpacingToSet <= 7)
+ {
+ switch(ieee->pairwise_key_type)
+ {
+ case KEY_TYPE_NA: SecMinSpace = 0; break;
+ case KEY_TYPE_CCMP:
+ case KEY_TYPE_WEP40:
+ case KEY_TYPE_WEP104:
+ case KEY_TYPE_TKIP: SecMinSpace = 6; break;
+ default: SecMinSpace = 7; break;
+ }
+
+ if(MinSpacingToSet < SecMinSpace)
+ MinSpacingToSet = SecMinSpace;
+ priv->MinSpaceCfg = ((priv->MinSpaceCfg&0xf8) |MinSpacingToSet);
+ RT_TRACE(COMP_SEC, "Set AMPDU_MIN_SPACE: %x\n", priv->MinSpaceCfg);
+ write_nic_byte(dev, AMPDU_MIN_SPACE, priv->MinSpaceCfg);
+ }
+
+#else
+ MinSpacingToSet = MinSpaceCfg;
+ MinSpacingToSet &= 0x07; // We only care about bit[2:0]
+ priv->MinSpaceCfg |= MinSpacingToSet;
+ RT_TRACE(COMP_SEC, "Set AMPDU_MIN_SPACE: %x\n", priv->MinSpaceCfg);
+ write_nic_byte(dev, AMPDU_MIN_SPACE, priv->MinSpaceCfg);//FIXLZM
+#endif
+}
+#endif
+
+//
+// Description:
+// Initial HW relted registers.
+//
+// Assumption:
+// 1. This function is only invoked at driver intialization once.
+// 2. PASSIVE LEVEL.
+//
+// 2008.06.10, Added by Roger.
+//
+static void rtl8192SU_MacConfigAfterFwDownload(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ //PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ //u8 tmpU1b, RxPageCfg, i;
+ u16 tmpU2b;
+ u8 tmpU1b;//, i;
+
+
+ RT_TRACE(COMP_INIT, "--->MacConfigAfterFwDownload()\n");
+
+ // Enable Tx/Rx
+ tmpU2b = (BBRSTn|BB_GLB_RSTn|SCHEDULE_EN|MACRXEN|MACTXEN|DDMA_EN|
+ FW2HW_EN|RXDMA_EN|TXDMA_EN|HCI_RXDMA_EN|HCI_TXDMA_EN); //3
+ //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_COMMAND, &tmpU1b );
+ write_nic_word(dev, CMDR, tmpU2b); //LZM REGISTER COM 090305
+
+ // Loopback mode or not
+ priv->LoopbackMode = RTL8192SU_NO_LOOPBACK; // Set no loopback as default.
+ if(priv->LoopbackMode == RTL8192SU_NO_LOOPBACK)
+ tmpU1b = LBK_NORMAL;
+ else if (priv->LoopbackMode == RTL8192SU_MAC_LOOPBACK )
+ tmpU1b = LBK_MAC_DLB;
+ else
+ RT_TRACE(COMP_INIT, "Serious error: wrong loopback mode setting\n");
+
+ //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_LBK_MODE, &tmpU1b);
+ write_nic_byte(dev, LBKMD_SEL, tmpU1b);
+
+ // Set RCR
+ write_nic_dword(dev, RCR, priv->ReceiveConfig);
+ RT_TRACE(COMP_INIT, "MacConfigAfterFwDownload(): Current RCR settings(%#x)\n", priv->ReceiveConfig);
+
+
+ // Set RQPN
+ //
+ // <Roger_Notes> 2008.08.18.
+ // 6 endpoints:
+ // (1) Page number on CMDQ is 0x03.
+ // (2) Page number on BCNQ, HQ and MGTQ is 0.
+ // (3) Page number on BKQ, BEQ, VIQ and VOQ are 0x07.
+ // (4) Page number on PUBQ is 0xdd
+ //
+ // 11 endpoints:
+ // (1) Page number on CMDQ is 0x00.
+ // (2) Page number on BCNQ is 0x02, HQ and MGTQ are 0x03.
+ // (3) Page number on BKQ, BEQ, VIQ and VOQ are 0x07.
+ // (4) Page number on PUBQ is 0xd8
+ //
+ //write_nic_dword(Adapter, 0xa0, 0x07070707); //BKQ, BEQ, VIQ and VOQ
+ //write_nic_byte(dev, 0xa4, 0x00); // HCCAQ
+#if 0 //LZM 090219
+#ifdef USE_SIX_USB_ENDPOINT
+ //write_nic_dword(Adapter, 0xa5, 0x00000003); //CMDQ, MGTQ, HQ and BCNQ
+ //write_nic_byte(dev, 0xa9, 0xdd); // PUBQ
+ tmpU1b = read_nic_byte(dev, 0xab); // RQPN
+ write_nic_byte(dev, 0xab, tmpU1b|BIT7|BIT6);// reduce to 6 endpoints.
+#else
+ write_nic_dword(dev, 0xa5, 0x02030300); //CMDQ, MGTQ, HQ and BCNQ
+ write_nic_byte(dev, 0xa9, 0xd8); // PUBQ
+ tmpU1b = read_nic_byte(dev, 0xab); // RQPN
+ write_nic_byte(dev, 0xab, (tmpU1b&(~BIT6))|BIT7); // Disable reduced endpoint.
+#endif
+#endif
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ // Size of Tx/Rx packet buffer.
+ tmpU1b = read_nic_byte(dev, PBP);
+ RxPageCfg = rtl8192SU_MapRxPageSizeToIdx(priv->ieee80211->pHTInfo.UsbRxPageSize);
+ write_nic_byte(dev, PBP, tmpU1b|RxPageCfg); // Set page size of Rx packet buffer to 128 bytes.
+ tmpU1b = read_nic_byte(dev, RXDMA);
+
+ write_nic_byte(dev, RXDMA, tmpU1b|RXDMA_AGG_EN); // Rx aggregation enable.
+ //PlatformIOWrite1Byte(Adapter, RXDMA_AGG_PG_TH, 0x14); // Set page size of RxDMA aggregation threshold, default: 20.
+ //write_nic_byte(dev, RXDMA_AGG_PG_TH, 0x40); // By Scott's suggestion, 2008.09.30.//92su del
+ //write_nic_byte(dev, USB_RX_AGG_TIMEOUT, RXDMA_AGG_TIMEOUT_17_4_MS); // Set aggregation time-out to 17ms/4.
+ rtl8192SU_HalUsbRxAggr8192SUsb(dev, true);
+#endif
+
+ // Fix the RX FIFO issue(USB error), Rivesed by Roger, 2008-06-14
+ tmpU1b = read_nic_byte_E(dev, 0x5C);
+ write_nic_byte_E(dev, 0x5C, tmpU1b|BIT7);
+
+ //
+ // Revise USB PHY to solve the issue of Rx payload error, Rivesed by Roger, 2008-04-10
+ // Suggest by SD1 Alex.
+ //
+ // <Roger_Notes> The following operation are ONLY for USB PHY test chip.
+ // 2008.10.07.
+ //
+#if RTL8192SU_USB_PHY_TEST
+ write_nic_byte(dev, 0x41,0xf4);
+ write_nic_byte(dev, 0x40,0x00);
+ write_nic_byte(dev, 0x42,0x00);
+ write_nic_byte(dev, 0x42,0x01);
+ write_nic_byte(dev, 0x40,0x0f);
+ write_nic_byte(dev, 0x42,0x00);
+ write_nic_byte(dev, 0x42,0x01);
+#endif
+
+#if 0 //LZM 090219
+ //
+ // Suggested by SD1 Alex, 2008-06-14.
+ //
+ write_nic_byte(dev, TXOP_STALL_CTRL, 0x80);//NAV
+
+
+ //
+ // Set Data Auto Rate Fallback Retry Count register.
+ //
+ write_nic_dword(dev, DARFRC, 0x04010000);
+ write_nic_dword(dev, DARFRC+4, 0x09070605);
+ write_nic_dword(dev, RARFRC, 0x04010000);
+ write_nic_dword(dev, RARFRC+4, 0x09070605);
+
+ // Set Data Auto Rate Fallback Reg. Added by Roger, 2008.09.22.
+ for (i = 0; i < 8; i++)
+#ifdef RTL8192SU_DISABLE_CCK_RATE
+ write_nic_dword(dev, ARFR0+i*4, 0x1f0ff0f0);
+#else
+ write_nic_dword(dev, ARFR0+i*4, 0x1f0ffff0);
+#endif
+
+ //
+ // Set driver info, we only accept PHY status now.
+ //
+ //write_nic_byte(dev, RXDRVINFO_SZ, 4);
+
+ //
+ // Aggregation length limit. Revised by Roger. 2008.09.22.
+ //
+ write_nic_dword(dev, AGGLEN_LMT_L, 0x66666666); // Long GI
+ write_nic_byte(dev, AGGLEN_LMT_H, 0x06); // Set AMPDU length to 12Kbytes for ShortGI case.
+
+ //
+ // For Min Spacing configuration.
+ //
+ //Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_AMPDU_MIN_SPACE, (u8*)(&Adapter->MgntInfo.MinSpaceCfg));
+ rtl8192SU_SetHwRegAmpduMinSpace(dev,priv->MinSpaceCfg);
+#endif
+
+ // For EFUSE init configuration.
+ //if (IS_BOOT_FROM_EFUSE(Adapter)) // We may R/W EFUSE in EFUSE mode
+ if (priv->bBootFromEfuse)
+ {
+ u8 tempval;
+
+ tempval = read_nic_byte(dev, SYS_ISO_CTRL+1);
+ tempval &= 0xFE;
+ write_nic_byte(dev, SYS_ISO_CTRL+1, tempval);
+
+ // Enable LDO 2.5V for write action
+ //tempval = read_nic_byte(Adapter, EFUSE_TEST+3);
+ //write_nic_byte(Adapter, EFUSE_TEST+3, (tempval | 0x80));
+
+ // Change Efuse Clock for write action
+ //write_nic_byte(Adapter, EFUSE_CLK, 0x03);
+
+ // Change Program timing
+ write_nic_byte(dev, EFUSE_CTRL+3, 0x72);
+ //printk("!!!!!!!!!!!!!!!!!!!!!%s: write 0x33 with 0x72\n",__FUNCTION__);
+ RT_TRACE(COMP_INIT, "EFUSE CONFIG OK\n");
+ }
+
+
+ RT_TRACE(COMP_INIT, "<---MacConfigAfterFwDownload()\n");
+}
+
+void rtl8192SU_HwConfigureRTL8192SUsb(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 regBwOpMode = 0;
+ u32 regRATR = 0, regRRSR = 0;
+ u8 regTmp = 0;
+ u32 i = 0;
+
+ //1 This part need to modified according to the rate set we filtered!!
+ //
+ // Set RRSR, RATR, and BW_OPMODE registers
+ //
+ switch(priv->ieee80211->mode)
+ {
+ case WIRELESS_MODE_B:
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK;
+ regRRSR = RATE_ALL_CCK;
+ break;
+ case WIRELESS_MODE_A:
+ regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_OFDM_AG;
+ regRRSR = RATE_ALL_OFDM_AG;
+ break;
+ case WIRELESS_MODE_G:
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ break;
+ case WIRELESS_MODE_AUTO:
+ if (priv->bInHctTest)
+ {
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ }
+ else
+ {
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ }
+ break;
+ case WIRELESS_MODE_N_24G:
+ // It support CCK rate by default.
+ // CCK rate will be filtered out only when associated AP does not support it.
+ regBwOpMode = BW_OPMODE_20MHZ;
+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
+ break;
+ case WIRELESS_MODE_N_5G:
+ regBwOpMode = BW_OPMODE_5G;
+ regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+ regRRSR = RATE_ALL_OFDM_AG;
+ break;
+ }
+
+ //
+ // <Roger_Notes> We disable CCK response rate until FIB CCK rate IC's back.
+ // 2008.09.23.
+ //
+ regTmp = read_nic_byte(dev, INIRTSMCS_SEL);
+#ifdef RTL8192SU_DISABLE_CCK_RATE
+ regRRSR = ((regRRSR & 0x000ffff0)<<8) | regTmp;
+#else
+ regRRSR = ((regRRSR & 0x000fffff)<<8) | regTmp;
+#endif
+
+ //
+ // Update SIFS timing.
+ //
+ //priv->SifsTime = 0x0e0e0a0a;
+ //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_SIFS, (pu1Byte)&pHalData->SifsTime);
+ { u8 val[4] = {0x0e, 0x0e, 0x0a, 0x0a};
+ // SIFS for CCK Data ACK
+ write_nic_byte(dev, SIFS_CCK, val[0]);
+ // SIFS for CCK consecutive tx like CTS data!
+ write_nic_byte(dev, SIFS_CCK+1, val[1]);
+
+ // SIFS for OFDM Data ACK
+ write_nic_byte(dev, SIFS_OFDM, val[2]);
+ // SIFS for OFDM consecutive tx like CTS data!
+ write_nic_byte(dev, SIFS_OFDM+1, val[3]);
+ }
+
+ write_nic_dword(dev, INIRTSMCS_SEL, regRRSR);
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+
+ //
+ // Suggested by SD1 Alex, 2008-06-14.
+ //
+ //PlatformEFIOWrite1Byte(Adapter, TXOP_STALL_CTRL, 0x80);//NAV to protect all TXOP.
+
+ //
+ // Set Data Auto Rate Fallback Retry Count register.
+ //
+ write_nic_dword(dev, DARFRC, 0x02010000);
+ write_nic_dword(dev, DARFRC+4, 0x06050403);
+ write_nic_dword(dev, RARFRC, 0x02010000);
+ write_nic_dword(dev, RARFRC+4, 0x06050403);
+
+ // Set Data Auto Rate Fallback Reg. Added by Roger, 2008.09.22.
+ for (i = 0; i < 8; i++)
+#ifdef RTL8192SU_DISABLE_CCK_RATE
+ write_nic_dword(dev, ARFR0+i*4, 0x1f0ff0f0);
+#else
+ write_nic_dword(dev, ARFR0+i*4, 0x1f0ffff0);
+#endif
+
+ //
+ // Aggregation length limit. Revised by Roger. 2008.09.22.
+ //
+ write_nic_byte(dev, AGGLEN_LMT_H, 0x0f); // Set AMPDU length to 12Kbytes for ShortGI case.
+ write_nic_dword(dev, AGGLEN_LMT_L, 0xddd77442); // Long GI
+ write_nic_dword(dev, AGGLEN_LMT_L+4, 0xfffdd772);
+
+ // Set NAV protection length
+ write_nic_word(dev, NAV_PROT_LEN, 0x0080);
+
+ // Set TXOP stall control for several queue/HI/BCN/MGT/
+ write_nic_byte(dev, TXOP_STALL_CTRL, 0x00); // NAV Protect next packet.
+
+ // Set MSDU lifetime.
+ write_nic_byte(dev, MLT, 0x8f);
+
+ // Set CCK/OFDM SIFS
+ write_nic_word(dev, SIFS_CCK, 0x0a0a); // CCK SIFS shall always be 10us.
+ write_nic_word(dev, SIFS_OFDM, 0x0e0e);
+
+ write_nic_byte(dev, ACK_TIMEOUT, 0x40);
+
+ // CF-END Threshold
+ write_nic_byte(dev, CFEND_TH, 0xFF);
+
+ //
+ // For Min Spacing configuration.
+ //
+ switch(priv->rf_type)
+ {
+ case RF_1T2R:
+ case RF_1T1R:
+ RT_TRACE(COMP_INIT, "Initializeadapter: RF_Type%s\n", (priv->rf_type==RF_1T1R? "(1T1R)":"(1T2R)"));
+ priv->MinSpaceCfg = (MAX_MSS_DENSITY_1T<<3);
+ break;
+ case RF_2T2R:
+ case RF_2T2R_GREEN:
+ RT_TRACE(COMP_INIT, "Initializeadapter:RF_Type(2T2R)\n");
+ priv->MinSpaceCfg = (MAX_MSS_DENSITY_2T<<3);
+ break;
+ }
+ write_nic_byte(dev, AMPDU_MIN_SPACE, priv->MinSpaceCfg);
+
+ //LZM 090219
+ //
+ // For Min Spacing configuration.
+ //
+ //priv->MinSpaceCfg = 0x00;
+ //rtl8192SU_SetHwRegAmpduMinSpace(dev, priv->MinSpaceCfg);
+}
+
+#endif
+
+#ifdef RTL8192SU
+// Description: Initial HW relted registers.
+//
+// Assumption: This function is only invoked at driver intialization once.
+//
+// 2008.06.10, Added by Roger.
+bool rtl8192SU_adapter_start(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //u32 dwRegRead = 0;
+ //bool init_status = true;
+ //u32 ulRegRead;
+ bool rtStatus = true;
+ //u8 PipeIndex;
+ //u8 eRFPath, tmpU1b;
+ u8 fw_download_times = 1;
+
+
+ RT_TRACE(COMP_INIT, "--->InitializeAdapter8192SUsb()\n");
+
+ //pHalData->bGPIOChangeRF = FALSE;
+
+
+ //
+ // <Roger_Notes> 2008.06.15.
+ //
+ // Initialization Steps on RTL8192SU:
+ // a. MAC initialization prior to sending down firmware code.
+ // b. Download firmware code step by step(i.e., IMEM, EMEM, DMEM).
+ // c. MAC configuration after firmware has been download successfully.
+ // d. Initialize BB related configurations.
+ // e. Initialize RF related configurations.
+ // f. Start to BulkIn transfer.
+ //
+
+ //
+ //a. MAC initialization prior to send down firmware code.
+ //
+start:
+ rtl8192SU_MacConfigBeforeFwDownloadASIC(dev);
+
+ //
+ //b. Download firmware code step by step(i.e., IMEM, EMEM, DMEM).
+ //
+ rtStatus = FirmwareDownload92S(dev);
+ if(rtStatus != true)
+ {
+ if(fw_download_times == 1){
+ RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Download Firmware failed once, Download again!!\n");
+ fw_download_times = fw_download_times + 1;
+ goto start;
+ }else{
+ RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Download Firmware failed twice, end!!\n");
+ goto end;
+ }
+ }
+ //
+ //c. MAC configuration after firmware has been download successfully.
+ //
+ rtl8192SU_MacConfigAfterFwDownload(dev);
+
+#if (RTL8192S_DISABLE_FW_DM == 1)
+ write_nic_dword(dev, WFM5, FW_DM_DISABLE);
+#endif
+ //priv->bLbusEnable = TRUE;
+ //if(priv->RegRfOff == TRUE)
+ // priv->eRFPowerState = eRfOff;
+
+ // Save target channel
+ // <Roger_Notes> Current Channel will be updated again later.
+ //priv->CurrentChannel = Channel;
+ rtStatus = PHY_MACConfig8192S(dev);//===>ok
+ if(rtStatus != true)
+ {
+ RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Fail to configure MAC!!\n");
+ goto end;
+ }
+ if (1){
+ int i;
+ for (i=0; i<4; i++)
+ write_nic_dword(dev,WDCAPARA_ADD[i], 0x5e4322);
+ write_nic_byte(dev,AcmHwCtrl, 0x01);
+ }
+
+
+ //
+ //d. Initialize BB related configurations.
+ //
+
+ rtStatus = PHY_BBConfig8192S(dev);//===>ok
+ if(rtStatus != true)
+ {
+ RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Fail to configure BB!!\n");
+ goto end;
+ }
+
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);//===>ok
+
+ //
+ // e. Initialize RF related configurations.
+ //
+ // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W.
+ priv->Rf_Mode = RF_OP_By_SW_3wire;
+
+ // For RF test only from Scott's suggestion
+ //write_nic_byte(dev, 0x27, 0xDB);
+ //write_nic_byte(dev, 0x1B, 0x07);
+
+
+ write_nic_byte(dev, AFE_XTAL_CTRL+1, 0xDB);
+
+ // <Roger_Notes> The following IOs are configured for each RF modules.
+ // Enable RF module and reset RF and SDM module. 2008.11.17.
+ if(priv->card_8192_version == VERSION_8192S_ACUT)
+ write_nic_byte(dev, SPS1_CTRL+3, (u8)(RF_EN|RF_RSTB|RF_SDMRSTB)); // Fix A-Cut bug.
+ else
+ write_nic_byte(dev, RF_CTRL, (u8)(RF_EN|RF_RSTB|RF_SDMRSTB));
+
+ rtStatus = PHY_RFConfig8192S(dev);//===>ok
+ if(rtStatus != true)
+ {
+ RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Fail to configure RF!!\n");
+ goto end;
+ }
+
+
+ // Set CCK and OFDM Block "ON"
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
+
+ //
+ // Turn off Radio B while RF type is 1T1R by SD3 Wilsion's request.
+ // Revised by Roger, 2008.12.18.
+ //
+ if(priv->rf_type == RF_1T1R)
+ {
+ // This is needed for PHY_REG after 20081219
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, 0xff000000, 0x03);
+ // This is needed for PHY_REG before 20081219
+ //PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, bMaskByte0, 0x11);
+ }
+
+#if (RTL8192SU_DISABLE_IQK==0)
+ // For 1T2R IQK only currently.
+ if (priv->card_8192_version == VERSION_8192S_BCUT)
+ {
+ PHY_IQCalibrateBcut(dev);
+ }
+ else if (priv->card_8192_version == VERSION_8192S_ACUT)
+ {
+ PHY_IQCalibrate(dev);
+ }
+#endif
+
+ //LZM 090219
+ // Set CCK and OFDM Block "ON"
+ //rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
+ //rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
+
+
+ //3//Get hardware version, do it in read eeprom?
+ //GetHardwareVersion819xUsb(Adapter);
+
+ //3//
+ //3 //Set Hardware
+ //3//
+ rtl8192SU_HwConfigureRTL8192SUsb(dev);//==>ok
+
+ //
+ // <Roger_Notes> We set MAC address here if autoload was failed before,
+ // otherwise IDR0 will NOT contain any value.
+ //
+ write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
+ write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
+ if(!priv->bInHctTest)
+ {
+ if(priv->ResetProgress == RESET_TYPE_NORESET)
+ {
+ //RT_TRACE(COMP_MLME, DBG_LOUD, ("Initializeadapter8192SUsb():RegWirelessMode(%#x) \n", Adapter->RegWirelessMode));
+ //Adapter->HalFunc.SetWirelessModeHandler(Adapter, Adapter->RegWirelessMode);
+ rtl8192_SetWirelessMode(dev, priv->ieee80211->mode);//===>ok
+ }
+ }
+ else
+ {
+ priv->ieee80211->mode = WIRELESS_MODE_G;
+ rtl8192_SetWirelessMode(dev, WIRELESS_MODE_G);
+ }
+
+ //Security related.
+ //-----------------------------------------------------------------------------
+ // Set up security related. 070106, by rcnjko:
+ // 1. Clear all H/W keys.
+ // 2. Enable H/W encryption/decryption.
+ //-----------------------------------------------------------------------------
+ //CamResetAllEntry(Adapter);
+ //Adapter->HalFunc.EnableHWSecCfgHandler(Adapter);
+
+ //SecClearAllKeys(Adapter);
+ CamResetAllEntry(dev);
+ //SecInit(Adapter);
+ {
+ u8 SECR_value = 0x0;
+ SECR_value |= SCR_TxEncEnable;
+ SECR_value |= SCR_RxDecEnable;
+ SECR_value |= SCR_NoSKMC;
+ write_nic_byte(dev, SECR, SECR_value);
+ }
+
+#if 0
+
+ if(pHalData->VersionID == VERSION_8192SU_A)
+ {
+ // cosa add for tx power level initialization.
+ GetTxPowerOriginalOffset(Adapter);
+ SetTxPowerLevel819xUsb(Adapter, Channel);
+ }
+#endif
+
+
+#ifdef TO_DO_LIST
+
+ //PHY_UpdateInitialGain(dev);
+
+ if(priv->RegRfOff == true)
+ { // User disable RF via registry.
+ u8 eRFPath = 0;
+
+ RT_TRACE((COMP_INIT|COMP_RF), "InitializeAdapter8192SUsb(): Turn off RF for RegRfOff ----------\n");
+ MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW);
+ // Those action will be discard in MgntActSet_RF_State because off the same state
+ for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
+ rtl8192_setBBreg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+ }
+ else if(priv->RfOffReason > RF_CHANGE_BY_PS)
+ { // H/W or S/W RF OFF before sleep.
+ RT_TRACE((COMP_INIT|COMP_RF), "InitializeAdapter8192SUsb(): Turn off RF for RfOffReason(%d) ----------\n", priv->RfOffReason);
+ MgntActSet_RF_State(dev, eRfOff, priv->RfOffReason);
+ }
+ else
+ {
+ priv->eRFPowerState = eRfOn;
+ priv->RfOffReason = 0;
+ RT_TRACE((COMP_INIT|COMP_RF), "InitializeAdapter8192SUsb(): RF is on ----------\n");
+ }
+
+#endif
+
+
+//
+// f. Start to BulkIn transfer.
+//
+#ifdef TO_DO_LIST
+
+#ifndef UNDER_VISTA
+ {
+ u8 i;
+ PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
+
+ for(PipeIndex=0; PipeIndex < MAX_RX_QUEUE; PipeIndex++)
+ {
+ if (PipeIndex == 0)
+ {
+ for(i=0; i<32; i++)
+ HalUsbInMpdu(Adapter, PipeIndex);
+ }
+ else
+ {
+ //HalUsbInMpdu(Adapter, PipeIndex);
+ //HalUsbInMpdu(Adapter, PipeIndex);
+ //HalUsbInMpdu(Adapter, PipeIndex);
+ }
+ }
+ PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
+ }
+#else
+ // Joseph add to 819X code base for Vista USB platform.
+ // This part may need to be add to Hal819xU code base. too.
+ PlatformUsbEnableInPipes(Adapter);
+#endif
+
+ RT_TRACE(COMP_INIT, "HighestOperaRate = %x\n", Adapter->MgntInfo.HighestOperaRate);
+
+ PlatformStartWorkItem( &(pHalData->RtUsbCheckForHangWorkItem) );
+
+ //
+ // <Roger_EXP> The following configurations are for ASIC verification temporally.
+ // 2008.07.10.
+ //
+
+#endif
+
+ //
+ // Read EEPROM TX power index and PHY_REG_PG.txt to capture correct
+ // TX power index for different rate set.
+ //
+ //if(priv->card_8192_version >= VERSION_8192S_ACUT)
+ {
+ // Get original hw reg values
+ PHY_GetHWRegOriginalValue(dev);
+
+ // Write correct tx power index//FIXLZM
+ PHY_SetTxPowerLevel8192S(dev, priv->chan);
+ }
+
+ {
+ u8 tmpU1b = 0;
+ // EEPROM R/W workaround
+ tmpU1b = read_nic_byte(dev, MAC_PINMUX_CFG);
+ write_nic_byte(dev, MAC_PINMUX_CFG, tmpU1b&(~GPIOMUX_EN));
+ }
+
+//
+//<Roger_Notes> 2008.08.19.
+// We return status here for temporal FPGA verification, 2008.08.19.
+
+#ifdef RTL8192SU_FW_IQK
+ write_nic_dword(dev, WFM5, FW_IQK_ENABLE);
+ ChkFwCmdIoDone(dev);
+#endif
+
+ //
+ // <Roger_Notes> We enable high power mechanism after NIC initialized.
+ // 2008.11.27.
+ //
+ write_nic_dword(dev, WFM5, FW_RA_RESET);
+ ChkFwCmdIoDone(dev);
+ write_nic_dword(dev, WFM5, FW_RA_ACTIVE);
+ ChkFwCmdIoDone(dev);
+ write_nic_dword(dev, WFM5, FW_RA_REFRESH);
+ ChkFwCmdIoDone(dev);
+ write_nic_dword(dev, WFM5, FW_BB_RESET_ENABLE);
+
+// <Roger_Notes> We return status here for temporal FPGA verification. 2008.05.12.
+//
+#if RTL8192SU_FPGA_UNSPECIFIED_NETWORK
+ //
+ // To send specific number of packets to verify MAC Lookback mode.
+ //
+ //SendRandomTxPkt(Adapter, 0); // Burst mode for verification.
+ //rtStatus = RT_STATUS_FAILURE;
+ rtStatus = true;
+ goto end;
+#endif
+
+// The following IO was for FPGA verification purpose. Added by Roger, 2008.09.11.
+#if 0
+ // 2008/08/19 MH From SD1 Jong, we must write some register for true PHY/MAC FPGA.
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x30);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x30);
+
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+
+ //write_nic_dword(Adapter, RCR, 0x817FF02F);
+
+ write_nic_dword(Adapter, rTxAGC_Mcs15_Mcs12, 0x06060606);
+#endif
+end:
+return rtStatus;
+}
+
+#else
+
+//InitializeAdapter and PhyCfg
+bool rtl8192_adapter_start(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 dwRegRead = 0;
+ bool init_status = true;
+ RT_TRACE(COMP_INIT, "====>%s()\n", __FUNCTION__);
+ priv->Rf_Mode = RF_OP_By_SW_3wire;
+ //for ASIC power on sequence
+ write_nic_byte_E(dev, 0x5f, 0x80);
+ mdelay(50);
+ write_nic_byte_E(dev, 0x5f, 0xf0);
+ write_nic_byte_E(dev, 0x5d, 0x00);
+ write_nic_byte_E(dev, 0x5e, 0x80);
+ write_nic_byte(dev, 0x17, 0x37);
+ mdelay(10);
+//#ifdef TO_DO_LIST
+ priv->pFirmware->firmware_status = FW_STATUS_0_INIT;
+ //config CPUReset Register
+ //Firmware Reset or not?
+ dwRegRead = read_nic_dword(dev, CPU_GEN);
+ if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT)
+ dwRegRead |= CPU_GEN_SYSTEM_RESET; //do nothing here?
+ else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
+ dwRegRead |= CPU_GEN_FIRMWARE_RESET;
+ else
+ RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__, priv->pFirmware->firmware_status);
+
+ write_nic_dword(dev, CPU_GEN, dwRegRead);
+ //mdelay(30);
+ //config BB.
+ rtl8192_BBConfig(dev);
+
+#if 1
+ //Loopback mode or not
+ priv->LoopbackMode = RTL819xU_NO_LOOPBACK;
+// priv->LoopbackMode = RTL819xU_MAC_LOOPBACK;
+
+ dwRegRead = read_nic_dword(dev, CPU_GEN);
+ if (priv->LoopbackMode == RTL819xU_NO_LOOPBACK)
+ dwRegRead = ((dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET);
+ else if (priv->LoopbackMode == RTL819xU_MAC_LOOPBACK)
+ dwRegRead |= CPU_CCK_LOOPBACK;
+ else
+ RT_TRACE(COMP_ERR, "Serious error in %s(): wrong loopback mode setting(%d)\n", __FUNCTION__, priv->LoopbackMode);
+
+ write_nic_dword(dev, CPU_GEN, dwRegRead);
+
+ //after reset cpu, we need wait for a seconds to write in register.
+ udelay(500);
+
+ //xiong add for new bitfile:usb suspend reset pin set to 1. //do we need?
+ write_nic_byte_E(dev, 0x5f, (read_nic_byte_E(dev, 0x5f)|0x20));
+
+ //Set Hardware
+ rtl8192_hwconfig(dev);
+
+ //turn on Tx/Rx
+ write_nic_byte(dev, CMDR, CR_RE|CR_TE);
+
+ //set IDR0 here
+ write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]);
+ write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]);
+
+ //set RCR
+ write_nic_dword(dev, RCR, priv->ReceiveConfig);
+
+ //Initialize Number of Reserved Pages in Firmware Queue
+ write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\
+ NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \
+ NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \
+ NUM_OF_PAGE_IN_FW_QUEUE_VO <<RSVD_FW_QUEUE_PAGE_VO_SHIFT);
+ write_nic_dword(dev, RQPN2, NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT |\
+ NUM_OF_PAGE_IN_FW_QUEUE_CMD << RSVD_FW_QUEUE_PAGE_CMD_SHIFT);
+ write_nic_dword(dev, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW| \
+ NUM_OF_PAGE_IN_FW_QUEUE_BCN<<RSVD_FW_QUEUE_PAGE_BCN_SHIFT
+// | NUM_OF_PAGE_IN_FW_QUEUE_PUB<<RSVD_FW_QUEUE_PAGE_PUB_SHIFT
+ );
+ write_nic_dword(dev, RATR0+4*7, (RATE_ALL_OFDM_AG | RATE_ALL_CCK));
+
+ //Set AckTimeout
+ // TODO: (it value is only for FPGA version). need to be changed!!2006.12.18, by Emily
+ write_nic_byte(dev, ACK_TIMEOUT, 0x30);
+
+// RT_TRACE(COMP_INIT, "%s():priv->ResetProgress is %d\n", __FUNCTION__,priv->ResetProgress);
+ if(priv->ResetProgress == RESET_TYPE_NORESET)
+ rtl8192_SetWirelessMode(dev, priv->ieee80211->mode);
+ if(priv->ResetProgress == RESET_TYPE_NORESET){
+ CamResetAllEntry(dev);
+ {
+ u8 SECR_value = 0x0;
+ SECR_value |= SCR_TxEncEnable;
+ SECR_value |= SCR_RxDecEnable;
+ SECR_value |= SCR_NoSKMC;
+ write_nic_byte(dev, SECR, SECR_value);
+ }
+ }
+
+ //Beacon related
+ write_nic_word(dev, ATIMWND, 2);
+ write_nic_word(dev, BCN_INTERVAL, 100);
+
+ {
+#define DEFAULT_EDCA 0x005e4332
+ int i;
+ for (i=0; i<QOS_QUEUE_NUM; i++)
+ write_nic_dword(dev, WDCAPARA_ADD[i], DEFAULT_EDCA);
+ }
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ //3 For usb rx firmware aggregation control
+ if(priv->ResetProgress == RESET_TYPE_NORESET)
+ {
+ u32 ulValue;
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
+ (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
+ /*
+ * If usb rx firmware aggregation is enabled,
+ * when anyone of three threshold conditions above is reached,
+ * firmware will send aggregated packet to driver.
+ */
+ write_nic_dword(dev, 0x1a8, ulValue);
+ priv->bCurrentRxAggrEnable = true;
+ }
+#endif
+
+ rtl8192_phy_configmac(dev);
+
+ if (priv->card_8192_version == (u8) VERSION_819xU_A)
+ {
+ rtl8192_phy_getTxPower(dev);
+ rtl8192_phy_setTxPower(dev, priv->chan);
+ }
+
+
+ priv->usb_error = false;
+ //Firmware download
+ init_status = init_firmware(dev);
+ if(!init_status)
+ {
+ RT_TRACE(COMP_ERR,"ERR!!! %s(): Firmware download is failed\n", __FUNCTION__);
+ return init_status;
+ }
+ RT_TRACE(COMP_INIT, "%s():after firmware download\n", __FUNCTION__);
+ //
+#ifdef TO_DO_LIST
+if(Adapter->ResetProgress == RESET_TYPE_NORESET)
+ {
+ if(pMgntInfo->RegRfOff == TRUE)
+ { // User disable RF via registry.
+ RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
+ MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
+ // Those action will be discard in MgntActSet_RF_State because off the same state
+ for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+ }
+ else if(pMgntInfo->RfOffReason > RF_CHANGE_BY_PS)
+ { // H/W or S/W RF OFF before sleep.
+ RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", pMgntInfo->RfOffReason));
+ MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
+ }
+ else
+ {
+ pHalData->eRFPowerState = eRfOn;
+ pMgntInfo->RfOffReason = 0;
+ RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): RF is on ----------\n"));
+ }
+ }
+ else
+ {
+ if(pHalData->eRFPowerState == eRfOff)
+ {
+ MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
+ // Those action will be discard in MgntActSet_RF_State because off the same state
+ for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+ }
+ }
+#endif
+ //config RF.
+ if(priv->ResetProgress == RESET_TYPE_NORESET){
+ rtl8192_phy_RFConfig(dev);
+ RT_TRACE(COMP_INIT, "%s():after phy RF config\n", __FUNCTION__);
+ }
+
+
+ if(priv->ieee80211->FwRWRF)
+ // We can force firmware to do RF-R/W
+ priv->Rf_Mode = RF_OP_By_FW;
+ else
+ priv->Rf_Mode = RF_OP_By_SW_3wire;
+
+
+ rtl8192_phy_updateInitGain(dev);
+ /*--set CCK and OFDM Block "ON"--*/
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
+
+ if(priv->ResetProgress == RESET_TYPE_NORESET)
+ {
+ //if D or C cut
+ u8 tmpvalue = read_nic_byte(dev, 0x301);
+ if(tmpvalue ==0x03)
+ {
+ priv->bDcut = TRUE;
+ RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
+ }
+ else
+ {
+ priv->bDcut = FALSE;
+ RT_TRACE(COMP_POWER_TRACKING, "C-cut\n");
+ }
+ dm_initialize_txpower_tracking(dev);
+
+ if(priv->bDcut == TRUE)
+ {
+ u32 i, TempCCk;
+ u32 tmpRegA= rtl8192_QueryBBReg(dev,rOFDM0_XATxIQImbalance,bMaskDWord);
+ // u32 tmpRegC= rtl8192_QueryBBReg(dev,rOFDM0_XCTxIQImbalance,bMaskDWord);
+ for(i = 0; i<TxBBGainTableLength; i++)
+ {
+ if(tmpRegA == priv->txbbgain_table[i].txbbgain_value)
+ {
+ priv->rfa_txpowertrackingindex= (u8)i;
+ priv->rfa_txpowertrackingindex_real= (u8)i;
+ priv->rfa_txpowertracking_default= priv->rfa_txpowertrackingindex;
+ break;
+ }
+ }
+
+ TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2);
+
+ for(i=0 ; i<CCKTxBBGainTableLength ; i++)
+ {
+
+ if(TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0])
+ {
+ priv->cck_present_attentuation_20Mdefault=(u8) i;
+ break;
+ }
+ }
+ priv->cck_present_attentuation_40Mdefault= 0;
+ priv->cck_present_attentuation_difference= 0;
+ priv->cck_present_attentuation = priv->cck_present_attentuation_20Mdefault;
+
+ // pMgntInfo->bTXPowerTracking = FALSE;//TEMPLY DISABLE
+ }
+ }
+ write_nic_byte(dev, 0x87, 0x0);
+
+
+#endif
+ return init_status;
+}
+
+#endif
+/* this configures registers for beacon tx and enables it via
+ * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might
+ * be used to stop beacon transmission
+ */
+#if 0
+void rtl8192_start_tx_beacon(struct net_device *dev)
+{
+ int i;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ u16 word;
+ DMESG("Enabling beacon TX");
+ //write_nic_byte(dev, TX_CONF,0xe6);// TX_CONF
+ //rtl8192_init_beacon(dev);
+ //set_nic_txring(dev);
+// rtl8192_prepare_beacon(dev);
+ rtl8192_irq_disable(dev);
+// rtl8192_beacon_tx_enable(dev);
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ //write_nic_byte(dev,0x9d,0x20); //DMA Poll
+ //write_nic_word(dev,0x7a,0);
+ //write_nic_word(dev,0x7a,0x8000);
+
+
+ word = read_nic_word(dev, BcnItv);
+ word &= ~BcnItv_BcnItv; // clear Bcn_Itv
+ write_nic_word(dev, BcnItv, word);
+
+ write_nic_word(dev, AtimWnd,
+ read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd);
+
+ word = read_nic_word(dev, BCN_INTR_ITV);
+ word &= ~BCN_INTR_ITV_MASK;
+
+ //word |= priv->ieee80211->beacon_interval *
+ // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
+ // FIXME:FIXME check if correct ^^ worked with 0x3e8;
+
+ write_nic_word(dev, BCN_INTR_ITV, word);
+
+ //write_nic_word(dev,0x2e,0xe002);
+ //write_nic_dword(dev,0x30,0xb8c7832e);
+ for(i=0; i<ETH_ALEN; i++)
+ write_nic_byte(dev, BSSID+i, priv->ieee80211->beacon_cell_ssid[i]);
+
+// rtl8192_update_msr(dev);
+
+
+ //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
+
+ rtl8192_set_mode(dev, EPROM_CMD_NORMAL);
+
+ rtl8192_irq_enable(dev);
+
+ /* VV !!!!!!!!!! VV*/
+ /*
+ rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
+ write_nic_byte(dev,0x9d,0x00);
+ rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
+*/
+}
+#endif
+/***************************************************************************
+ -------------------------------NET STUFF---------------------------
+***************************************************************************/
+
+static struct net_device_stats *rtl8192_stats(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ return &priv->ieee80211->stats;
+}
+
+bool
+HalTxCheckStuck819xUsb(
+ struct net_device *dev
+ )
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 RegTxCounter = read_nic_word(dev, 0x128);
+ bool bStuck = FALSE;
+ RT_TRACE(COMP_RESET,"%s():RegTxCounter is %d,TxCounter is %d\n",__FUNCTION__,RegTxCounter,priv->TxCounter);
+ if(priv->TxCounter==RegTxCounter)
+ bStuck = TRUE;
+
+ priv->TxCounter = RegTxCounter;
+
+ return bStuck;
+}
+
+/*
+* <Assumption: RT_TX_SPINLOCK is acquired.>
+* First added: 2006.11.19 by emily
+*/
+RESET_TYPE
+TxCheckStuck(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 QueueID;
+// PRT_TCB pTcb;
+// u8 ResetThreshold;
+ bool bCheckFwTxCnt = false;
+ //unsigned long flags;
+
+ //
+ // Decide Stuch threshold according to current power save mode
+ //
+
+// RT_TRACE(COMP_RESET, " ==> TxCheckStuck()\n");
+// PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
+// spin_lock_irqsave(&priv->ieee80211->lock,flags);
+ for (QueueID = 0; QueueID<=BEACON_QUEUE;QueueID ++)
+ {
+ if(QueueID == TXCMD_QUEUE)
+ continue;
+#if 1
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_drv_aggQ[QueueID]) == 0))
+#else
+ if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
+#endif
+ continue;
+#endif
+
+ bCheckFwTxCnt = true;
+ }
+// PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
+// spin_unlock_irqrestore(&priv->ieee80211->lock,flags);
+// RT_TRACE(COMP_RESET,"bCheckFwTxCnt is %d\n",bCheckFwTxCnt);
+#if 1
+ if(bCheckFwTxCnt)
+ {
+ if(HalTxCheckStuck819xUsb(dev))
+ {
+ RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n");
+ return RESET_TYPE_SILENT;
+ }
+ }
+#endif
+ return RESET_TYPE_NORESET;
+}
+
+bool
+HalRxCheckStuck819xUsb(struct net_device *dev)
+{
+ u16 RegRxCounter = read_nic_word(dev, 0x130);
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool bStuck = FALSE;
+//#ifdef RTL8192SU
+
+//#else
+ static u8 rx_chk_cnt = 0;
+ RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n",__FUNCTION__,RegRxCounter,priv->RxCounter);
+ // If rssi is small, we should check rx for long time because of bad rx.
+ // or maybe it will continuous silent reset every 2 seconds.
+ rx_chk_cnt++;
+ if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5))
+ {
+ rx_chk_cnt = 0; //high rssi, check rx stuck right now.
+ }
+ else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) &&
+ ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) ||
+ (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) )
+ {
+ if(rx_chk_cnt < 2)
+ {
+ return bStuck;
+ }
+ else
+ {
+ rx_chk_cnt = 0;
+ }
+ }
+ else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb<RateAdaptiveTH_Low_40M) ||
+ (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb<RateAdaptiveTH_Low_20M)) &&
+ priv->undecorated_smoothed_pwdb >= VeryLowRSSI)
+ {
+ if(rx_chk_cnt < 4)
+ {
+ //DbgPrint("RSSI < %d && RSSI >= %d, no check this time \n", RateAdaptiveTH_Low, VeryLowRSSI);
+ return bStuck;
+ }
+ else
+ {
+ rx_chk_cnt = 0;
+ //DbgPrint("RSSI < %d && RSSI >= %d, check this time \n", RateAdaptiveTH_Low, VeryLowRSSI);
+ }
+ }
+ else
+ {
+ if(rx_chk_cnt < 8)
+ {
+ //DbgPrint("RSSI <= %d, no check this time \n", VeryLowRSSI);
+ return bStuck;
+ }
+ else
+ {
+ rx_chk_cnt = 0;
+ //DbgPrint("RSSI <= %d, check this time \n", VeryLowRSSI);
+ }
+ }
+//#endif
+
+ if(priv->RxCounter==RegRxCounter)
+ bStuck = TRUE;
+
+ priv->RxCounter = RegRxCounter;
+
+ return bStuck;
+}
+
+RESET_TYPE
+RxCheckStuck(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //int i;
+ bool bRxCheck = FALSE;
+
+// RT_TRACE(COMP_RESET," ==> RxCheckStuck()\n");
+ //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
+
+ if(priv->IrpPendingCount > 1)
+ bRxCheck = TRUE;
+ //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
+
+// RT_TRACE(COMP_RESET,"bRxCheck is %d \n",bRxCheck);
+ if(bRxCheck)
+ {
+ if(HalRxCheckStuck819xUsb(dev))
+ {
+ RT_TRACE(COMP_RESET, "RxStuck Condition\n");
+ return RESET_TYPE_SILENT;
+ }
+ }
+ return RESET_TYPE_NORESET;
+}
+
+
+/**
+* This function is called by Checkforhang to check whether we should ask OS to reset driver
+*
+* \param pAdapter The adapter context for this miniport
+*
+* Note:NIC with USB interface sholud not call this function because we cannot scan descriptor
+* to judge whether there is tx stuck.
+* Note: This function may be required to be rewrite for Vista OS.
+* <<<Assumption: Tx spinlock has been acquired >>>
+*
+* 8185 and 8185b does not implement this function. This is added by Emily at 2006.11.24
+*/
+RESET_TYPE
+rtl819x_ifcheck_resetornot(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RESET_TYPE TxResetType = RESET_TYPE_NORESET;
+ RESET_TYPE RxResetType = RESET_TYPE_NORESET;
+ RT_RF_POWER_STATE rfState;
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ return RESET_TYPE_NORESET;
+#endif
+
+ rfState = priv->ieee80211->eRFPowerState;
+
+ TxResetType = TxCheckStuck(dev);
+#if 1
+ if( rfState != eRfOff ||
+ /*ADAPTER_TEST_STATUS_FLAG(Adapter, ADAPTER_STATUS_FW_DOWNLOAD_FAILURE)) &&*/
+ (priv->ieee80211->iw_mode != IW_MODE_ADHOC))
+ {
+ // If driver is in the status of firmware download failure , driver skips RF initialization and RF is
+ // in turned off state. Driver should check whether Rx stuck and do silent reset. And
+ // if driver is in firmware download failure status, driver should initialize RF in the following
+ // silent reset procedure Emily, 2008.01.21
+
+ // Driver should not check RX stuck in IBSS mode because it is required to
+ // set Check BSSID in order to send beacon, however, if check BSSID is
+ // set, STA cannot hear any packet a all. Emily, 2008.04.12
+ RxResetType = RxCheckStuck(dev);
+ }
+#endif
+ if(TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL)
+ return RESET_TYPE_NORMAL;
+ else if(TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT){
+ RT_TRACE(COMP_RESET,"%s():silent reset\n",__FUNCTION__);
+ return RESET_TYPE_SILENT;
+ }
+ else
+ return RESET_TYPE_NORESET;
+
+}
+
+void rtl8192_cancel_deferred_work(struct r8192_priv* priv);
+int _rtl8192_up(struct net_device *dev);
+int rtl8192_close(struct net_device *dev);
+
+
+
+void
+CamRestoreAllEntry( struct net_device *dev)
+{
+ u8 EntryId = 0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8* MacAddr = priv->ieee80211->current_network.bssid;
+
+ static u8 CAM_CONST_ADDR[4][6] = {
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
+ static u8 CAM_CONST_BROAD[] =
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+ RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n");
+
+
+ if ((priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP40)||
+ (priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP104))
+ {
+
+ for(EntryId=0; EntryId<4; EntryId++)
+ {
+ {
+ MacAddr = CAM_CONST_ADDR[EntryId];
+ setKey(dev,
+ EntryId ,
+ EntryId,
+ priv->ieee80211->pairwise_key_type,
+ MacAddr,
+ 0,
+ NULL);
+ }
+ }
+
+ }
+ else if(priv->ieee80211->pairwise_key_type == KEY_TYPE_TKIP)
+ {
+
+ {
+ if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ setKey(dev,
+ 4,
+ 0,
+ priv->ieee80211->pairwise_key_type,
+ (u8*)dev->dev_addr,
+ 0,
+ NULL);
+ else
+ setKey(dev,
+ 4,
+ 0,
+ priv->ieee80211->pairwise_key_type,
+ MacAddr,
+ 0,
+ NULL);
+ }
+ }
+ else if(priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP)
+ {
+
+ {
+ if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ setKey(dev,
+ 4,
+ 0,
+ priv->ieee80211->pairwise_key_type,
+ (u8*)dev->dev_addr,
+ 0,
+ NULL);
+ else
+ setKey(dev,
+ 4,
+ 0,
+ priv->ieee80211->pairwise_key_type,
+ MacAddr,
+ 0,
+ NULL);
+ }
+ }
+
+
+
+ if(priv->ieee80211->group_key_type == KEY_TYPE_TKIP)
+ {
+ MacAddr = CAM_CONST_BROAD;
+ for(EntryId=1 ; EntryId<4 ; EntryId++)
+ {
+ {
+ setKey(dev,
+ EntryId,
+ EntryId,
+ priv->ieee80211->group_key_type,
+ MacAddr,
+ 0,
+ NULL);
+ }
+ }
+ if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ setKey(dev,
+ 0,
+ 0,
+ priv->ieee80211->group_key_type,
+ CAM_CONST_ADDR[0],
+ 0,
+ NULL);
+ }
+ else if(priv->ieee80211->group_key_type == KEY_TYPE_CCMP)
+ {
+ MacAddr = CAM_CONST_BROAD;
+ for(EntryId=1; EntryId<4 ; EntryId++)
+ {
+ {
+ setKey(dev,
+ EntryId ,
+ EntryId,
+ priv->ieee80211->group_key_type,
+ MacAddr,
+ 0,
+ NULL);
+ }
+ }
+
+ if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ setKey(dev,
+ 0 ,
+ 0,
+ priv->ieee80211->group_key_type,
+ CAM_CONST_ADDR[0],
+ 0,
+ NULL);
+ }
+}
+//////////////////////////////////////////////////////////////
+// This function is used to fix Tx/Rx stop bug temporarily.
+// This function will do "system reset" to NIC when Tx or Rx is stuck.
+// The method checking Tx/Rx stuck of this function is supported by FW,
+// which reports Tx and Rx counter to register 0x128 and 0x130.
+//////////////////////////////////////////////////////////////
+void
+rtl819x_ifsilentreset(struct net_device *dev)
+{
+ //OCTET_STRING asocpdu;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 reset_times = 0;
+ int reset_status = 0;
+ struct ieee80211_device *ieee = priv->ieee80211;
+
+
+ // 2007.07.20. If we need to check CCK stop, please uncomment this line.
+ //bStuck = Adapter->HalFunc.CheckHWStopHandler(Adapter);
+
+ if(priv->ResetProgress==RESET_TYPE_NORESET)
+ {
+RESET_START:
+
+ RT_TRACE(COMP_RESET,"=========>Reset progress!! \n");
+
+ // Set the variable for reset.
+ priv->ResetProgress = RESET_TYPE_SILENT;
+// rtl8192_close(dev);
+#if 1
+ down(&priv->wx_sem);
+ if(priv->up == 0)
+ {
+ RT_TRACE(COMP_ERR,"%s():the driver is not up! return\n",__FUNCTION__);
+ up(&priv->wx_sem);
+ return ;
+ }
+ priv->up = 0;
+ RT_TRACE(COMP_RESET,"%s():======>start to down the driver\n",__FUNCTION__);
+// if(!netif_queue_stopped(dev))
+// netif_stop_queue(dev);
+
+ rtl8192_rtx_disable(dev);
+ rtl8192_cancel_deferred_work(priv);
+ deinit_hal_dm(dev);
+ del_timer_sync(&priv->watch_dog_timer);
+
+ ieee->sync_scan_hurryup = 1;
+ if(ieee->state == IEEE80211_LINKED)
+ {
+ down(&ieee->wx_sem);
+ printk("ieee->state is IEEE80211_LINKED\n");
+ ieee80211_stop_send_beacons(priv->ieee80211);
+ del_timer_sync(&ieee->associate_timer);
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ cancel_delayed_work(&ieee->associate_retry_wq);
+ #endif
+ ieee80211_stop_scan(ieee);
+ netif_carrier_off(dev);
+ up(&ieee->wx_sem);
+ }
+ else{
+ printk("ieee->state is NOT LINKED\n");
+ ieee80211_softmac_stop_protocol(priv->ieee80211); }
+ up(&priv->wx_sem);
+ RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__FUNCTION__);
+ //rtl8192_irq_disable(dev);
+ RT_TRACE(COMP_RESET,"%s():===========>start to up the driver\n",__FUNCTION__);
+ reset_status = _rtl8192_up(dev);
+
+ RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__FUNCTION__);
+ if(reset_status == -EAGAIN)
+ {
+ if(reset_times < 3)
+ {
+ reset_times++;
+ goto RESET_START;
+ }
+ else
+ {
+ RT_TRACE(COMP_ERR," ERR!!! %s(): Reset Failed!!\n", __FUNCTION__);
+ }
+ }
+#endif
+ ieee->is_silent_reset = 1;
+#if 1
+ EnableHWSecurityConfig8192(dev);
+#if 1
+ if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA)
+ {
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+
+#if 1
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(ieee->wq, &ieee->associate_complete_wq);
+#else
+ schedule_task(&ieee->associate_complete_wq);
+#endif
+#endif
+
+ }
+ else if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_ADHOC)
+ {
+ ieee->set_chan(ieee->dev, ieee->current_network.channel);
+ ieee->link_change(ieee->dev);
+
+ // notify_wx_assoc_event(ieee);
+
+ ieee80211_start_send_beacons(ieee);
+
+ if (ieee->data_hard_resume)
+ ieee->data_hard_resume(ieee->dev);
+ netif_carrier_on(ieee->dev);
+ }
+#endif
+
+ CamRestoreAllEntry(dev);
+
+ priv->ResetProgress = RESET_TYPE_NORESET;
+ priv->reset_count++;
+
+ priv->bForcedSilentReset =false;
+ priv->bResetInProgress = false;
+
+ // For test --> force write UFWP.
+ write_nic_byte(dev, UFWP, 1);
+ RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count);
+#endif
+ }
+}
+
+void CAM_read_entry(
+ struct net_device *dev,
+ u32 iIndex
+)
+{
+ u32 target_command=0;
+ u32 target_content=0;
+ u8 entry_i=0;
+ u32 ulStatus;
+ s32 i=100;
+// printk("=======>start read CAM\n");
+ for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++)
+ {
+ // polling bit, and No Write enable, and address
+ target_command= entry_i+CAM_CONTENT_COUNT*iIndex;
+ target_command= target_command | BIT31;
+
+ //Check polling bit is clear
+// mdelay(1);
+#if 1
+ while((i--)>=0)
+ {
+ ulStatus = read_nic_dword(dev, RWCAM);
+ if(ulStatus & BIT31){
+ continue;
+ }
+ else{
+ break;
+ }
+ }
+#endif
+ write_nic_dword(dev, RWCAM, target_command);
+ RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command);
+ // printk("CAM_read_entry(): WRITE A0: %lx \n",target_command);
+ target_content = read_nic_dword(dev, RCAMO);
+ RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content);
+ // printk("CAM_read_entry(): WRITE A8: %lx \n",target_content);
+ }
+ printk("\n");
+}
+
+void rtl819x_update_rxcounts(
+ struct r8192_priv *priv,
+ u32* TotalRxBcnNum,
+ u32* TotalRxDataNum
+)
+{
+ u16 SlotIndex;
+ u8 i;
+
+ *TotalRxBcnNum = 0;
+ *TotalRxDataNum = 0;
+
+ SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum);
+ priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
+ priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
+ for( i=0; i<priv->ieee80211->LinkDetectInfo.SlotNum; i++ ){
+ *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i];
+ *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i];
+ }
+}
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void rtl819x_watchdog_wqcallback(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+extern void rtl819x_watchdog_wqcallback(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+ struct ieee80211_device* ieee = priv->ieee80211;
+ RESET_TYPE ResetType = RESET_TYPE_NORESET;
+ static u8 check_reset_cnt=0;
+ bool bBusyTraffic = false;
+
+ if(!priv->up)
+ return;
+ hal_dm_watchdog(dev);
+
+ {//to get busy traffic condition
+ if(ieee->state == IEEE80211_LINKED)
+ {
+ //windows mod 666 to 100.
+ //if( ieee->LinkDetectInfo.NumRxOkInPeriod> 666 ||
+ // ieee->LinkDetectInfo.NumTxOkInPeriod> 666 ) {
+ if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 ||
+ ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) {
+ bBusyTraffic = true;
+ }
+ ieee->LinkDetectInfo.NumRxOkInPeriod = 0;
+ ieee->LinkDetectInfo.NumTxOkInPeriod = 0;
+ ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
+ }
+ }
+ //added by amy for AP roaming
+ {
+ if(priv->ieee80211->state == IEEE80211_LINKED && priv->ieee80211->iw_mode == IW_MODE_INFRA)
+ {
+ u32 TotalRxBcnNum = 0;
+ u32 TotalRxDataNum = 0;
+
+ rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
+ if((TotalRxBcnNum+TotalRxDataNum) == 0)
+ {
+ #ifdef TODO
+ if(rfState == eRfOff)
+ RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__);
+ #endif
+ printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__);
+ // Dot11d_Reset(dev);
+ priv->ieee80211->state = IEEE80211_ASSOCIATING;
+ notify_wx_assoc_event(priv->ieee80211);
+ RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid);
+ ieee->is_roaming = true;
+ priv->ieee80211->link_change(dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
+#else
+ schedule_task(&priv->ieee80211->associate_procedure_wq);
+#endif
+
+ }
+ }
+ priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod=0;
+ priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod=0;
+ }
+// CAM_read_entry(dev,4);
+ //check if reset the driver
+ if(check_reset_cnt++ >= 3 && !ieee->is_roaming)
+ {
+ ResetType = rtl819x_ifcheck_resetornot(dev);
+ check_reset_cnt = 3;
+ //DbgPrint("Start to check silent reset\n");
+ }
+ // RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType);
+#if 1
+ if( (priv->force_reset) || (priv->ResetProgress==RESET_TYPE_NORESET &&
+ (priv->bForcedSilentReset ||
+ (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT)))) // This is control by OID set in Pomelo
+ {
+ RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType);
+ rtl819x_ifsilentreset(dev);
+ }
+#endif
+ priv->force_reset = false;
+ priv->bForcedSilentReset = false;
+ priv->bResetInProgress = false;
+ RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n");
+
+}
+
+void watch_dog_timer_callback(unsigned long data)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *) data);
+ //printk("===============>watch_dog timer\n");
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq, 0);
+#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->watch_dog_wq);
+#else
+ queue_work(priv->priv_wq,&priv->watch_dog_wq);
+#endif
+#endif
+ mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
+#if 0
+ priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME);
+ add_timer(&priv->watch_dog_timer);
+#endif
+}
+int _rtl8192_up(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //int i;
+ int init_status = 0;
+ priv->up=1;
+ priv->ieee80211->ieee_up=1;
+ RT_TRACE(COMP_INIT, "Bringing up iface");
+ init_status = priv->ops->rtl819x_adapter_start(dev);
+ if(!init_status)
+ {
+ RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n", __FUNCTION__);
+ priv->up=priv->ieee80211->ieee_up = 0;
+ return -EAGAIN;
+ }
+ RT_TRACE(COMP_INIT, "start adapter finished\n");
+ rtl8192_rx_enable(dev);
+// rtl8192_tx_enable(dev);
+ if(priv->ieee80211->state != IEEE80211_LINKED)
+ ieee80211_softmac_start_protocol(priv->ieee80211);
+ ieee80211_reset_queue(priv->ieee80211);
+ watch_dog_timer_callback((unsigned long) dev);
+ if(!netif_queue_stopped(dev))
+ netif_start_queue(dev);
+ else
+ netif_wake_queue(dev);
+
+ /*
+ * Make sure that drop_unencrypted is initialized as "0"
+ * No packets will be sent in non-security mode if we had set drop_unencrypted.
+ * ex, After kill wpa_supplicant process, make the driver up again.
+ * drop_unencrypted remains as "1", which is set by wpa_supplicant. 2008/12/04.john
+ */
+ priv->ieee80211->drop_unencrypted = 0;
+
+ return 0;
+}
+
+
+int rtl8192_open(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int ret;
+ down(&priv->wx_sem);
+ ret = rtl8192_up(dev);
+ up(&priv->wx_sem);
+ return ret;
+
+}
+
+
+int rtl8192_up(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if (priv->up == 1) return -1;
+
+ return _rtl8192_up(dev);
+}
+
+
+int rtl8192_close(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int ret;
+
+ down(&priv->wx_sem);
+
+ ret = rtl8192_down(dev);
+
+ up(&priv->wx_sem);
+
+ return ret;
+
+}
+
+int rtl8192_down(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int i;
+
+ if (priv->up == 0) return -1;
+
+ priv->up=0;
+ priv->ieee80211->ieee_up = 0;
+ RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__);
+/* FIXME */
+ if (!netif_queue_stopped(dev))
+ netif_stop_queue(dev);
+
+ rtl8192_rtx_disable(dev);
+ //rtl8192_irq_disable(dev);
+
+ /* Tx related queue release */
+ for(i = 0; i < MAX_QUEUE_SIZE; i++) {
+ skb_queue_purge(&priv->ieee80211->skb_waitQ [i]);
+ }
+ for(i = 0; i < MAX_QUEUE_SIZE; i++) {
+ skb_queue_purge(&priv->ieee80211->skb_aggQ [i]);
+ }
+
+ for(i = 0; i < MAX_QUEUE_SIZE; i++) {
+ skb_queue_purge(&priv->ieee80211->skb_drv_aggQ [i]);
+ }
+
+ //as cancel_delayed_work will del work->timer, so if work is not definedas struct delayed_work, it will corrupt
+// flush_scheduled_work();
+ rtl8192_cancel_deferred_work(priv);
+ deinit_hal_dm(dev);
+ del_timer_sync(&priv->watch_dog_timer);
+
+
+ ieee80211_softmac_stop_protocol(priv->ieee80211);
+ memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list));
+ RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__);
+
+ return 0;
+}
+
+
+void rtl8192_commit(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int reset_status = 0;
+ //u8 reset_times = 0;
+ if (priv->up == 0) return ;
+ priv->up = 0;
+
+ rtl8192_cancel_deferred_work(priv);
+ del_timer_sync(&priv->watch_dog_timer);
+ //cancel_delayed_work(&priv->SwChnlWorkItem);
+
+ ieee80211_softmac_stop_protocol(priv->ieee80211);
+
+ //rtl8192_irq_disable(dev);
+ rtl8192_rtx_disable(dev);
+ reset_status = _rtl8192_up(dev);
+
+}
+
+/*
+void rtl8192_restart(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+*/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+void rtl8192_restart(struct work_struct *work)
+{
+ struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+void rtl8192_restart(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+
+ down(&priv->wx_sem);
+
+ rtl8192_commit(dev);
+
+ up(&priv->wx_sem);
+}
+
+static void r8192_set_multicast(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ short promisc;
+
+ //down(&priv->wx_sem);
+
+ /* FIXME FIXME */
+
+ promisc = (dev->flags & IFF_PROMISC) ? 1:0;
+
+ if (promisc != priv->promisc)
+ // rtl8192_commit(dev);
+
+ priv->promisc = promisc;
+
+ //schedule_work(&priv->reset_wq);
+ //up(&priv->wx_sem);
+}
+
+
+int r8192_set_mac_adr(struct net_device *dev, void *mac)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct sockaddr *addr = mac;
+
+ down(&priv->wx_sem);
+
+ memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ schedule_work(&priv->reset_wq);
+#else
+ schedule_task(&priv->reset_wq);
+#endif
+ up(&priv->wx_sem);
+
+ return 0;
+}
+
+/* based on ipw2200 driver */
+int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct iwreq *wrq = (struct iwreq *)rq;
+ int ret=-1;
+ struct ieee80211_device *ieee = priv->ieee80211;
+ u32 key[4];
+ u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
+ u8 zero_addr[6] = {0};
+ struct iw_point *p = &wrq->u.data;
+ struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer;
+
+ down(&priv->wx_sem);
+
+
+ if (p->length < sizeof(struct ieee_param) || !p->pointer){
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ipw = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
+ if (ipw == NULL){
+ ret = -ENOMEM;
+ goto out;
+ }
+ if (copy_from_user(ipw, p->pointer, p->length)) {
+ kfree(ipw);
+ ret = -EFAULT;
+ goto out;
+ }
+
+ switch (cmd) {
+ case RTL_IOCTL_WPA_SUPPLICANT:
+ //parse here for HW security
+ if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION)
+ {
+ if (ipw->u.crypt.set_tx)
+ {
+ if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
+ ieee->pairwise_key_type = KEY_TYPE_CCMP;
+ else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
+ ieee->pairwise_key_type = KEY_TYPE_TKIP;
+ else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
+ {
+ if (ipw->u.crypt.key_len == 13)
+ ieee->pairwise_key_type = KEY_TYPE_WEP104;
+ else if (ipw->u.crypt.key_len == 5)
+ ieee->pairwise_key_type = KEY_TYPE_WEP40;
+ }
+ else
+ ieee->pairwise_key_type = KEY_TYPE_NA;
+
+ if (ieee->pairwise_key_type)
+ {
+ // FIXME:these two lines below just to fix ipw interface bug, that is, it will never set mode down to driver. So treat it as ADHOC mode, if no association procedure. WB. 2009.02.04
+ if (memcmp(ieee->ap_mac_addr, zero_addr, 6) == 0)
+ ieee->iw_mode = IW_MODE_ADHOC;
+ memcpy((u8*)key, ipw->u.crypt.key, 16);
+ EnableHWSecurityConfig8192(dev);
+ //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching!
+ //added by WB.
+ setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
+ if (ieee->iw_mode == IW_MODE_ADHOC)
+ setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
+ }
+ }
+ else //if (ipw->u.crypt.idx) //group key use idx > 0
+ {
+ memcpy((u8*)key, ipw->u.crypt.key, 16);
+ if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
+ ieee->group_key_type= KEY_TYPE_CCMP;
+ else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
+ ieee->group_key_type = KEY_TYPE_TKIP;
+ else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
+ {
+ if (ipw->u.crypt.key_len == 13)
+ ieee->group_key_type = KEY_TYPE_WEP104;
+ else if (ipw->u.crypt.key_len == 5)
+ ieee->group_key_type = KEY_TYPE_WEP40;
+ }
+ else
+ ieee->group_key_type = KEY_TYPE_NA;
+
+ if (ieee->group_key_type)
+ {
+ setKey( dev,
+ ipw->u.crypt.idx,
+ ipw->u.crypt.idx, //KeyIndex
+ ieee->group_key_type, //KeyType
+ broadcast_addr, //MacAddr
+ 0, //DefaultKey
+ key); //KeyContent
+ }
+ }
+ }
+#ifdef JOHN_HWSEC_DEBUG
+ //john's test 0711
+ printk("@@ wrq->u pointer = ");
+ for(i=0;i<wrq->u.data.length;i++){
+ if(i%10==0) printk("\n");
+ printk( "%8x|", ((u32*)wrq->u.data.pointer)[i] );
+ }
+ printk("\n");
+#endif /*JOHN_HWSEC_DEBUG*/
+ ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
+ break;
+
+ default:
+ ret = -EOPNOTSUPP;
+ break;
+ }
+ kfree(ipw);
+ ipw = NULL;
+out:
+ up(&priv->wx_sem);
+ return ret;
+}
+
+#ifdef RTL8192SU
+u8 rtl8192SU_HwRateToMRate(bool bIsHT, u8 rate,bool bFirstAMPDU)
+{
+
+ u8 ret_rate = 0x02;
+
+ if( bFirstAMPDU )
+ {
+ if(!bIsHT)
+ {
+ switch(rate)
+ {
+
+ case DESC92S_RATE1M: ret_rate = MGN_1M; break;
+ case DESC92S_RATE2M: ret_rate = MGN_2M; break;
+ case DESC92S_RATE5_5M: ret_rate = MGN_5_5M; break;
+ case DESC92S_RATE11M: ret_rate = MGN_11M; break;
+ case DESC92S_RATE6M: ret_rate = MGN_6M; break;
+ case DESC92S_RATE9M: ret_rate = MGN_9M; break;
+ case DESC92S_RATE12M: ret_rate = MGN_12M; break;
+ case DESC92S_RATE18M: ret_rate = MGN_18M; break;
+ case DESC92S_RATE24M: ret_rate = MGN_24M; break;
+ case DESC92S_RATE36M: ret_rate = MGN_36M; break;
+ case DESC92S_RATE48M: ret_rate = MGN_48M; break;
+ case DESC92S_RATE54M: ret_rate = MGN_54M; break;
+
+ default:
+ RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+ break;
+ }
+ }
+ else
+ {
+ switch(rate)
+ {
+
+ case DESC92S_RATEMCS0: ret_rate = MGN_MCS0; break;
+ case DESC92S_RATEMCS1: ret_rate = MGN_MCS1; break;
+ case DESC92S_RATEMCS2: ret_rate = MGN_MCS2; break;
+ case DESC92S_RATEMCS3: ret_rate = MGN_MCS3; break;
+ case DESC92S_RATEMCS4: ret_rate = MGN_MCS4; break;
+ case DESC92S_RATEMCS5: ret_rate = MGN_MCS5; break;
+ case DESC92S_RATEMCS6: ret_rate = MGN_MCS6; break;
+ case DESC92S_RATEMCS7: ret_rate = MGN_MCS7; break;
+ case DESC92S_RATEMCS8: ret_rate = MGN_MCS8; break;
+ case DESC92S_RATEMCS9: ret_rate = MGN_MCS9; break;
+ case DESC92S_RATEMCS10: ret_rate = MGN_MCS10; break;
+ case DESC92S_RATEMCS11: ret_rate = MGN_MCS11; break;
+ case DESC92S_RATEMCS12: ret_rate = MGN_MCS12; break;
+ case DESC92S_RATEMCS13: ret_rate = MGN_MCS13; break;
+ case DESC92S_RATEMCS14: ret_rate = MGN_MCS14; break;
+ case DESC92S_RATEMCS15: ret_rate = MGN_MCS15; break;
+ case DESC92S_RATEMCS32: ret_rate = (0x80|0x20); break;
+
+ default:
+ RT_TRACE(COMP_RECV, "HwRateToMRate92S(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT );
+ break;
+ }
+
+ }
+ }
+ else
+ {
+ switch(rate)
+ {
+
+ case DESC92S_RATE1M: ret_rate = MGN_1M; break;
+ case DESC92S_RATE2M: ret_rate = MGN_2M; break;
+ case DESC92S_RATE5_5M: ret_rate = MGN_5_5M; break;
+ case DESC92S_RATE11M: ret_rate = MGN_11M; break;
+ case DESC92S_RATE6M: ret_rate = MGN_6M; break;
+ case DESC92S_RATE9M: ret_rate = MGN_9M; break;
+ case DESC92S_RATE12M: ret_rate = MGN_12M; break;
+ case DESC92S_RATE18M: ret_rate = MGN_18M; break;
+ case DESC92S_RATE24M: ret_rate = MGN_24M; break;
+ case DESC92S_RATE36M: ret_rate = MGN_36M; break;
+ case DESC92S_RATE48M: ret_rate = MGN_48M; break;
+ case DESC92S_RATE54M: ret_rate = MGN_54M; break;
+ case DESC92S_RATEMCS0: ret_rate = MGN_MCS0; break;
+ case DESC92S_RATEMCS1: ret_rate = MGN_MCS1; break;
+ case DESC92S_RATEMCS2: ret_rate = MGN_MCS2; break;
+ case DESC92S_RATEMCS3: ret_rate = MGN_MCS3; break;
+ case DESC92S_RATEMCS4: ret_rate = MGN_MCS4; break;
+ case DESC92S_RATEMCS5: ret_rate = MGN_MCS5; break;
+ case DESC92S_RATEMCS6: ret_rate = MGN_MCS6; break;
+ case DESC92S_RATEMCS7: ret_rate = MGN_MCS7; break;
+ case DESC92S_RATEMCS8: ret_rate = MGN_MCS8; break;
+ case DESC92S_RATEMCS9: ret_rate = MGN_MCS9; break;
+ case DESC92S_RATEMCS10: ret_rate = MGN_MCS10; break;
+ case DESC92S_RATEMCS11: ret_rate = MGN_MCS11; break;
+ case DESC92S_RATEMCS12: ret_rate = MGN_MCS12; break;
+ case DESC92S_RATEMCS13: ret_rate = MGN_MCS13; break;
+ case DESC92S_RATEMCS14: ret_rate = MGN_MCS14; break;
+ case DESC92S_RATEMCS15: ret_rate = MGN_MCS15; break;
+ case DESC92S_RATEMCS32: ret_rate = (0x80|0x20); break;
+
+ default:
+ RT_TRACE(COMP_RECV, "HwRateToMRate92S(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT );
+ break;
+ }
+ }
+ return ret_rate;
+}
+#endif
+
+u8 HwRateToMRate90(bool bIsHT, u8 rate)
+{
+ u8 ret_rate = 0xff;
+
+ if(!bIsHT) {
+ switch(rate) {
+ case DESC90_RATE1M: ret_rate = MGN_1M; break;
+ case DESC90_RATE2M: ret_rate = MGN_2M; break;
+ case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break;
+ case DESC90_RATE11M: ret_rate = MGN_11M; break;
+ case DESC90_RATE6M: ret_rate = MGN_6M; break;
+ case DESC90_RATE9M: ret_rate = MGN_9M; break;
+ case DESC90_RATE12M: ret_rate = MGN_12M; break;
+ case DESC90_RATE18M: ret_rate = MGN_18M; break;
+ case DESC90_RATE24M: ret_rate = MGN_24M; break;
+ case DESC90_RATE36M: ret_rate = MGN_36M; break;
+ case DESC90_RATE48M: ret_rate = MGN_48M; break;
+ case DESC90_RATE54M: ret_rate = MGN_54M; break;
+
+ default:
+ ret_rate = 0xff;
+ RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+ break;
+ }
+
+ } else {
+ switch(rate) {
+ case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break;
+ case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break;
+ case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break;
+ case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break;
+ case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break;
+ case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break;
+ case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break;
+ case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break;
+ case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break;
+ case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break;
+ case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break;
+ case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break;
+ case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break;
+ case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break;
+ case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break;
+ case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break;
+ case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break;
+
+ default:
+ ret_rate = 0xff;
+ RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT);
+ break;
+ }
+ }
+
+ return ret_rate;
+}
+
+/**
+ * Function: UpdateRxPktTimeStamp
+ * Overview: Recored down the TSF time stamp when receiving a packet
+ *
+ * Input:
+ * PADAPTER Adapter
+ * PRT_RFD pRfd,
+ *
+ * Output:
+ * PRT_RFD pRfd
+ * (pRfd->Status.TimeStampHigh is updated)
+ * (pRfd->Status.TimeStampLow is updated)
+ * Return:
+ * None
+ */
+void UpdateRxPktTimeStamp8190 (struct net_device *dev, struct ieee80211_rx_stats *stats)
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ if(stats->bIsAMPDU && !stats->bFirstMPDU) {
+ stats->mac_time[0] = priv->LastRxDescTSFLow;
+ stats->mac_time[1] = priv->LastRxDescTSFHigh;
+ } else {
+ priv->LastRxDescTSFLow = stats->mac_time[0];
+ priv->LastRxDescTSFHigh = stats->mac_time[1];
+ }
+}
+
+//by amy 080606
+
+long rtl819x_translate_todbm(u8 signal_strength_index )// 0-100 index.
+{
+ long signal_power; // in dBm.
+
+ // Translate to dBm (x=0.5y-95).
+ signal_power = (long)((signal_strength_index + 1) >> 1);
+ signal_power -= 95;
+
+ return signal_power;
+}
+
+
+/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to
+ be a local static. Otherwise, it may increase when we return from S3/S4. The
+ value will be kept in memory or disk. We must delcare the value in adapter
+ and it will be reinitialized when return from S3/S4. */
+void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats)
+{
+ bool bcheck = false;
+ u8 rfpath;
+ u32 nspatial_stream, tmp_val;
+ //u8 i;
+ static u32 slide_rssi_index=0, slide_rssi_statistics=0;
+ static u32 slide_evm_index=0, slide_evm_statistics=0;
+ static u32 last_rssi=0, last_evm=0;
+
+ static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0;
+ static u32 last_beacon_adc_pwdb=0;
+
+ struct ieee80211_hdr_3addr *hdr;
+ u16 sc ;
+ unsigned int frag,seq;
+ hdr = (struct ieee80211_hdr_3addr *)buffer;
+ sc = le16_to_cpu(hdr->seq_ctl);
+ frag = WLAN_GET_SEQ_FRAG(sc);
+ seq = WLAN_GET_SEQ_SEQ(sc);
+ //cosa add 04292008 to record the sequence number
+ pcurrent_stats->Seq_Num = seq;
+ //
+ // Check whether we should take the previous packet into accounting
+ //
+ if(!pprevious_stats->bIsAMPDU)
+ {
+ // if previous packet is not aggregated packet
+ bcheck = true;
+ }else
+ {
+ #if 0
+ // if previous packet is aggregated packet, and current packet
+ // (1) is not AMPDU
+ // (2) is the first packet of one AMPDU
+ // that means the previous packet is the last one aggregated packet
+ if( !pcurrent_stats->bIsAMPDU || pcurrent_stats->bFirstMPDU)
+ bcheck = true;
+ #endif
+ }
+
+
+ if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX)
+ {
+ slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX;
+ last_rssi = priv->stats.slide_signal_strength[slide_rssi_index];
+ priv->stats.slide_rssi_total -= last_rssi;
+ }
+ priv->stats.slide_rssi_total += pprevious_stats->SignalStrength;
+
+ priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength;
+ if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
+ slide_rssi_index = 0;
+
+ // <1> Showed on UI for user, in dbm
+ tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics;
+ priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val);
+ pcurrent_stats->rssi = priv->stats.signal_strength;
+ //
+ // If the previous packet does not match the criteria, neglect it
+ //
+ if(!pprevious_stats->bPacketMatchBSSID)
+ {
+ if(!pprevious_stats->bToSelfBA)
+ return;
+ }
+
+ if(!bcheck)
+ return;
+
+
+ //rtl8190_process_cck_rxpathsel(priv,pprevious_stats);//only rtl8190 supported
+
+ //
+ // Check RSSI
+ //
+ priv->stats.num_process_phyinfo++;
+
+ /* record the general signal strength to the sliding window. */
+
+
+ // <2> Showed on UI for engineering
+ // hardware does not provide rssi information for each rf path in CCK
+ if(!pprevious_stats->bIsCCK && (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA))
+ {
+ for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++)
+ {
+ if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, rfpath))
+ continue;
+
+ //Fixed by Jacken 2008-03-20
+ if(priv->stats.rx_rssi_percentage[rfpath] == 0)
+ {
+ priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath];
+ //DbgPrint("MIMO RSSI initialize \n");
+ }
+ if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath])
+ {
+ priv->stats.rx_rssi_percentage[rfpath] =
+ ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) +
+ (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor);
+ priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1;
+ }
+ else
+ {
+ priv->stats.rx_rssi_percentage[rfpath] =
+ ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) +
+ (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor);
+ }
+ RT_TRACE(COMP_DBG,"priv->stats.rx_rssi_percentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] );
+ }
+ }
+
+
+ //
+ // Check PWDB.
+ //
+ RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
+ pprevious_stats->bIsCCK? "CCK": "OFDM",
+ pprevious_stats->RxPWDBAll);
+
+ if(pprevious_stats->bPacketBeacon)
+ {
+/* record the beacon pwdb to the sliding window. */
+ if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX)
+ {
+ slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
+ last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
+ priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
+ //DbgPrint("slide_beacon_adc_pwdb_index = %d, last_beacon_adc_pwdb = %d, Adapter->RxStats.Slide_Beacon_Total = %d\n",
+ // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total);
+ }
+ priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll;
+ priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll;
+ //DbgPrint("slide_beacon_adc_pwdb_index = %d, pPreviousRfd->Status.RxPWDBAll = %d\n", slide_beacon_adc_pwdb_index, pPreviousRfd->Status.RxPWDBAll);
+ slide_beacon_adc_pwdb_index++;
+ if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
+ slide_beacon_adc_pwdb_index = 0;
+ pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics;
+ if(pprevious_stats->RxPWDBAll >= 3)
+ pprevious_stats->RxPWDBAll -= 3;
+ }
+
+ RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
+ pprevious_stats->bIsCCK? "CCK": "OFDM",
+ pprevious_stats->RxPWDBAll);
+
+
+ if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA)
+ {
+ if(priv->undecorated_smoothed_pwdb < 0) // initialize
+ {
+ priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll;
+ //DbgPrint("First pwdb initialize \n");
+ }
+#if 1
+ if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb)
+ {
+ priv->undecorated_smoothed_pwdb =
+ ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) +
+ (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor);
+ priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1;
+ }
+ else
+ {
+ priv->undecorated_smoothed_pwdb =
+ ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) +
+ (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor);
+ }
+#else
+ //Fixed by Jacken 2008-03-20
+ if(pPreviousRfd->Status.RxPWDBAll > (u32)pHalData->UndecoratedSmoothedPWDB)
+ {
+ pHalData->UndecoratedSmoothedPWDB =
+ ( ((pHalData->UndecoratedSmoothedPWDB)* 5) + (pPreviousRfd->Status.RxPWDBAll)) / 6;
+ pHalData->UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB + 1;
+ }
+ else
+ {
+ pHalData->UndecoratedSmoothedPWDB =
+ ( ((pHalData->UndecoratedSmoothedPWDB)* 5) + (pPreviousRfd->Status.RxPWDBAll)) / 6;
+ }
+#endif
+
+ }
+
+ //
+ // Check EVM
+ //
+ /* record the general EVM to the sliding window. */
+ if(pprevious_stats->SignalQuality == 0)
+ {
+ }
+ else
+ {
+ if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){
+ if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){
+ slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
+ last_evm = priv->stats.slide_evm[slide_evm_index];
+ priv->stats.slide_evm_total -= last_evm;
+ }
+
+ priv->stats.slide_evm_total += pprevious_stats->SignalQuality;
+
+ priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality;
+ if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
+ slide_evm_index = 0;
+
+ // <1> Showed on UI for user, in percentage.
+ tmp_val = priv->stats.slide_evm_total/slide_evm_statistics;
+ priv->stats.signal_quality = tmp_val;
+ //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality.
+ priv->stats.last_signal_strength_inpercent = tmp_val;
+ }
+
+ // <2> Showed on UI for engineering
+ if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA)
+ {
+ for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream
+ {
+ if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1)
+ {
+ if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize
+ {
+ priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream];
+ }
+ priv->stats.rx_evm_percentage[nspatial_stream] =
+ ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) +
+ (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor);
+ }
+ }
+ }
+ }
+
+
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: rtl819x_query_rxpwrpercentage()
+ *
+ * Overview:
+ *
+ * Input: char antpower
+ *
+ * Output: NONE
+ *
+ * Return: 0-100 percentage
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/26/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static u8 rtl819x_query_rxpwrpercentage(
+ char antpower
+ )
+{
+ if ((antpower <= -100) || (antpower >= 20))
+ {
+ return 0;
+ }
+ else if (antpower >= 0)
+ {
+ return 100;
+ }
+ else
+ {
+ return (100+antpower);
+ }
+
+} /* QueryRxPwrPercentage */
+
+static u8
+rtl819x_evm_dbtopercentage(
+ char value
+ )
+{
+ char ret_val;
+
+ ret_val = value;
+
+ if(ret_val >= 0)
+ ret_val = 0;
+ if(ret_val <= -33)
+ ret_val = -33;
+ ret_val = 0 - ret_val;
+ ret_val*=3;
+ if(ret_val == 99)
+ ret_val = 100;
+ return(ret_val);
+}
+//
+// Description:
+// We want good-looking for signal strength/quality
+// 2007/7/19 01:09, by cosa.
+//
+long
+rtl819x_signal_scale_mapping(
+ long currsig
+ )
+{
+ long retsig;
+
+ // Step 1. Scale mapping.
+ if(currsig >= 61 && currsig <= 100)
+ {
+ retsig = 90 + ((currsig - 60) / 4);
+ }
+ else if(currsig >= 41 && currsig <= 60)
+ {
+ retsig = 78 + ((currsig - 40) / 2);
+ }
+ else if(currsig >= 31 && currsig <= 40)
+ {
+ retsig = 66 + (currsig - 30);
+ }
+ else if(currsig >= 21 && currsig <= 30)
+ {
+ retsig = 54 + (currsig - 20);
+ }
+ else if(currsig >= 5 && currsig <= 20)
+ {
+ retsig = 42 + (((currsig - 5) * 2) / 3);
+ }
+ else if(currsig == 4)
+ {
+ retsig = 36;
+ }
+ else if(currsig == 3)
+ {
+ retsig = 27;
+ }
+ else if(currsig == 2)
+ {
+ retsig = 18;
+ }
+ else if(currsig == 1)
+ {
+ retsig = 9;
+ }
+ else
+ {
+ retsig = currsig;
+ }
+
+ return retsig;
+}
+
+#ifdef RTL8192SU
+/*-----------------------------------------------------------------------------
+ * Function: QueryRxPhyStatus8192S()
+ *
+ * Overview:
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 06/01/2007 MHC Create Version 0.
+ * 06/05/2007 MHC Accordign to HW's new data sheet, we add CCK and OFDM
+ * descriptor definition.
+ * 07/04/2007 MHC According to Jerry and Bryant's document. We read
+ * ir_isolation and ext_lna for RF's init value and use
+ * to compensate RSSI after receiving packets.
+ * 09/10/2008 MHC Modify name and PHY status field for 92SE.
+ * 09/19/2008 MHC Add CCK/OFDM SS/SQ for 92S series.
+ *
+ *---------------------------------------------------------------------------*/
+static void rtl8192SU_query_rxphystatus(
+ struct r8192_priv * priv,
+ struct ieee80211_rx_stats * pstats,
+ rx_desc_819x_usb *pDesc,
+ rx_drvinfo_819x_usb * pdrvinfo,
+ struct ieee80211_rx_stats * precord_stats,
+ bool bpacket_match_bssid,
+ bool bpacket_toself,
+ bool bPacketBeacon,
+ bool bToSelfBA
+ )
+{
+ //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status);
+ //PHY_STS_CCK_8192S_T *pCck_buf;
+ phy_sts_cck_819xusb_t * pcck_buf;
+ phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc;
+ //u8 *prxpkt;
+ //u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
+ u8 i, max_spatial_stream, rxsc_sgien_exflg;
+ char rx_pwr[4], rx_pwr_all=0;
+ //long rx_avg_pwr = 0;
+ //char rx_snrX, rx_evmX;
+ u8 evm, pwdb_all;
+ u32 RSSI, total_rssi=0;//, total_evm=0;
+// long signal_strength_index = 0;
+ u8 is_cck_rate=0;
+ u8 rf_rx_num = 0;
+
+
+
+ priv->stats.numqry_phystatus++;
+
+ is_cck_rate = rx_hal_is_cck_rate(pDesc);
+
+ // Record it for next packet processing
+ memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats));
+ pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
+ pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself;
+ pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo);
+ pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon;
+ pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA;
+
+#ifndef RTL8192SU
+ phy_sts_ofdm_819xusb_t* pofdm_buf = NULL;
+ prxpkt = (u8*)pdrvinfo;
+
+ /* Move pointer to the 16th bytes. Phy status start address. */
+ prxpkt += sizeof(rx_drvinfo_819x_usb);
+
+ /* Initial the cck and ofdm buffer pointer */
+ pcck_buf = (phy_sts_cck_819xusb_t *)prxpkt;
+ pofdm_buf = (phy_sts_ofdm_819xusb_t *)prxpkt;
+#endif
+
+ pstats->RxMIMOSignalQuality[0] = -1;
+ pstats->RxMIMOSignalQuality[1] = -1;
+ precord_stats->RxMIMOSignalQuality[0] = -1;
+ precord_stats->RxMIMOSignalQuality[1] = -1;
+
+ if(is_cck_rate)
+ {
+ u8 report;//, tmp_pwdb;
+ //char cck_adc_pwdb[4];
+
+ // CCK Driver info Structure is not the same as OFDM packet.
+ pcck_buf = (phy_sts_cck_819xusb_t *)pdrvinfo;
+
+ //
+ // (1)Hardware does not provide RSSI for CCK
+ //
+
+ //
+ // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
+ //
+
+ priv->stats.numqry_phystatusCCK++;
+
+ if(!priv->bCckHighPower)
+ {
+ report = pcck_buf->cck_agc_rpt & 0xc0;
+ report = report>>6;
+ switch(report)
+ {
+ //Fixed by Jacken from Bryant 2008-03-20
+ //Original value is -38 , -26 , -14 , -2
+ //Fixed value is -35 , -23 , -11 , 6
+ case 0x3:
+ rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ case 0x2:
+ rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ case 0x1:
+ rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ case 0x0:
+ rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e);//6->8
+ break;
+ }
+ }
+ else
+ {
+ report = pdrvinfo->cfosho[0] & 0x60;
+ report = report>>5;
+ switch(report)
+ {
+ case 0x3:
+ rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
+ break;
+ case 0x2:
+ rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1);
+ break;
+ case 0x1:
+ rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
+ break;
+ case 0x0:
+ rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;//6->-8
+ break;
+ }
+ }
+
+ pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all);//check it
+ pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all;
+ //pstats->RecvSignalPower = pwdb_all;
+ pstats->RecvSignalPower = rx_pwr_all;
+
+ //
+ // (3) Get Signal Quality (EVM)
+ //
+ //if(bpacket_match_bssid)
+ {
+ u8 sq;
+
+ if(pstats->RxPWDBAll > 40)
+ {
+ sq = 100;
+ }else
+ {
+ sq = pcck_buf->sq_rpt;
+
+ if(pcck_buf->sq_rpt > 64)
+ sq = 0;
+ else if (pcck_buf->sq_rpt < 20)
+ sq = 100;
+ else
+ sq = ((64-sq) * 100) / 44;
+ }
+ pstats->SignalQuality = precord_stats->SignalQuality = sq;
+ pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq;
+ pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1;
+ }
+ }
+ else
+ {
+ priv->stats.numqry_phystatusHT++;
+
+ // 2008/09/19 MH For 92S debug, RX RF path always enable!!
+ priv->brfpath_rxenable[0] = priv->brfpath_rxenable[1] = TRUE;
+
+ //
+ // (1)Get RSSI for HT rate
+ //
+ //for(i=RF90_PATH_A; i<priv->NumTotalRFPath; i++)
+ for(i=RF90_PATH_A; i<RF90_PATH_MAX; i++)
+ {
+ // 2008/01/30 MH we will judge RF RX path now.
+ if (priv->brfpath_rxenable[i])
+ rf_rx_num++;
+ //else
+ // continue;
+
+ //if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i))
+ // continue;
+
+ //Fixed by Jacken from Bryant 2008-03-20
+ //Original value is 106
+ //rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106;
+ rx_pwr[i] = ((pdrvinfo->gain_trsw[i]&0x3F)*2) - 110;
+
+ /* Translate DBM to percentage. */
+ RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); //check ok
+ total_rssi += RSSI;
+ RT_TRACE(COMP_RF, "RF-%d RXPWR=%x RSSI=%d\n", i, rx_pwr[i], RSSI);
+
+ //Get Rx snr value in DB
+ //tmp_rxsnr = pofdm_buf->rxsnr_X[i];
+ //rx_snrX = (char)(tmp_rxsnr);
+ //rx_snrX /= 2;
+ //priv->stats.rxSNRdB[i] = (long)rx_snrX;
+ priv->stats.rxSNRdB[i] = (long)(pdrvinfo->rxsnr[i]/2);
+
+ /* Translate DBM to percentage. */
+ //RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]);
+ //total_rssi += RSSI;
+
+ /* Record Signal Strength for next packet */
+ //if(bpacket_match_bssid)
+ {
+ pstats->RxMIMOSignalStrength[i] =(u8) RSSI;
+ precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI;
+ }
+ }
+
+
+ //
+ // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
+ //
+ //Fixed by Jacken from Bryant 2008-03-20
+ //Original value is 106
+ //rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106;
+ rx_pwr_all = (((pdrvinfo->pwdb_all ) >> 1 )& 0x7f) -106;
+ pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all);
+
+ pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all;
+ pstats->RxPower = precord_stats->RxPower = rx_pwr_all;
+ pstats->RecvSignalPower = rx_pwr_all;
+
+ //
+ // (3)EVM of HT rate
+ //
+ //if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 &&
+ // pdrvinfo->RxRate<=DESC90_RATEMCS15)
+ if(pDesc->RxHT && pDesc->RxMCS>=DESC92S_RATEMCS8 &&
+ pDesc->RxMCS<=DESC92S_RATEMCS15)
+ max_spatial_stream = 2; //both spatial stream make sense
+ else
+ max_spatial_stream = 1; //only spatial stream 1 makes sense
+
+ for(i=0; i<max_spatial_stream; i++)
+ {
+ //tmp_rxevm = pofdm_buf->rxevm_X[i];
+ //rx_evmX = (char)(tmp_rxevm);
+
+ // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
+ // fill most significant bit to "zero" when doing shifting operation which may change a negative
+ // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
+ //rx_evmX /= 2; //dbm
+
+ //evm = rtl819x_evm_dbtopercentage(rx_evmX);
+ evm = rtl819x_evm_dbtopercentage( (pdrvinfo->rxevm[i] /*/ 2*/)); //dbm
+ RT_TRACE(COMP_RF, "RXRATE=%x RXEVM=%x EVM=%s%d\n", pDesc->RxMCS, pdrvinfo->rxevm[i], "%", evm);
+#if 0
+ EVM = SignalScaleMapping(EVM);//make it good looking, from 0~100//=====>from here
+#endif
+
+ //if(bpacket_match_bssid)
+ {
+ if(i==0) // Fill value in RFD, Get the first spatial stream only
+ pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff);
+ pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff);
+ }
+ }
+
+
+ /* record rx statistics for debug */
+ //rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg;
+ prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg;
+ //if(pdrvinfo->BW) //40M channel
+ if(pDesc->BW) //40M channel
+ priv->stats.received_bwtype[1+pdrvinfo->rxsc]++;
+ else //20M channel
+ priv->stats.received_bwtype[0]++;
+ }
+
+ //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
+ //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
+ if(is_cck_rate)
+ {
+ pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL;//check ok
+
+ }
+ else
+ {
+ //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u8)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u8)(total_rssi/=RF90_PATH_MAX);
+ // We can judge RX path number now.
+ if (rf_rx_num != 0)
+ pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num)));
+ }
+}/* QueryRxPhyStatus8192S */
+#else
+static void rtl8192_query_rxphystatus(
+ struct r8192_priv * priv,
+ struct ieee80211_rx_stats * pstats,
+ rx_drvinfo_819x_usb * pdrvinfo,
+ struct ieee80211_rx_stats * precord_stats,
+ bool bpacket_match_bssid,
+ bool bpacket_toself,
+ bool bPacketBeacon,
+ bool bToSelfBA
+ )
+{
+ //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status);
+ phy_sts_ofdm_819xusb_t* pofdm_buf;
+ phy_sts_cck_819xusb_t * pcck_buf;
+ phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc;
+ u8 *prxpkt;
+ u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
+ char rx_pwr[4], rx_pwr_all=0;
+ //long rx_avg_pwr = 0;
+ char rx_snrX, rx_evmX;
+ u8 evm, pwdb_all;
+ u32 RSSI, total_rssi=0;//, total_evm=0;
+// long signal_strength_index = 0;
+ u8 is_cck_rate=0;
+ u8 rf_rx_num = 0;
+
+
+ priv->stats.numqry_phystatus++;
+
+ is_cck_rate = rx_hal_is_cck_rate(pdrvinfo);
+
+ // Record it for next packet processing
+ memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats));
+ pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
+ pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself;
+ pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo);
+ pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon;
+ pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA;
+
+ prxpkt = (u8*)pdrvinfo;
+
+ /* Move pointer to the 16th bytes. Phy status start address. */
+ prxpkt += sizeof(rx_drvinfo_819x_usb);
+
+ /* Initial the cck and ofdm buffer pointer */
+ pcck_buf = (phy_sts_cck_819xusb_t *)prxpkt;
+ pofdm_buf = (phy_sts_ofdm_819xusb_t *)prxpkt;
+
+ pstats->RxMIMOSignalQuality[0] = -1;
+ pstats->RxMIMOSignalQuality[1] = -1;
+ precord_stats->RxMIMOSignalQuality[0] = -1;
+ precord_stats->RxMIMOSignalQuality[1] = -1;
+
+ if(is_cck_rate)
+ {
+ //
+ // (1)Hardware does not provide RSSI for CCK
+ //
+
+ //
+ // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
+ //
+ u8 report;//, cck_agc_rpt;
+
+ priv->stats.numqry_phystatusCCK++;
+
+ if(!priv->bCckHighPower)
+ {
+ report = pcck_buf->cck_agc_rpt & 0xc0;
+ report = report>>6;
+ switch(report)
+ {
+ //Fixed by Jacken from Bryant 2008-03-20
+ //Original value is -38 , -26 , -14 , -2
+ //Fixed value is -35 , -23 , -11 , 6
+ case 0x3:
+ rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ case 0x2:
+ rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ case 0x1:
+ rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ case 0x0:
+ rx_pwr_all = 6 - (pcck_buf->cck_agc_rpt & 0x3e);
+ break;
+ }
+ }
+ else
+ {
+ report = pcck_buf->cck_agc_rpt & 0x60;
+ report = report>>5;
+ switch(report)
+ {
+ case 0x3:
+ rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
+ break;
+ case 0x2:
+ rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1);
+ break;
+ case 0x1:
+ rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
+ break;
+ case 0x0:
+ rx_pwr_all = 6 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
+ break;
+ }
+ }
+
+ pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all);
+ pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all;
+ pstats->RecvSignalPower = pwdb_all;
+
+ //
+ // (3) Get Signal Quality (EVM)
+ //
+ //if(bpacket_match_bssid)
+ {
+ u8 sq;
+
+ if(pstats->RxPWDBAll > 40)
+ {
+ sq = 100;
+ }else
+ {
+ sq = pcck_buf->sq_rpt;
+
+ if(pcck_buf->sq_rpt > 64)
+ sq = 0;
+ else if (pcck_buf->sq_rpt < 20)
+ sq = 100;
+ else
+ sq = ((64-sq) * 100) / 44;
+ }
+ pstats->SignalQuality = precord_stats->SignalQuality = sq;
+ pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq;
+ pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1;
+ }
+ }
+ else
+ {
+ priv->stats.numqry_phystatusHT++;
+ //
+ // (1)Get RSSI for HT rate
+ //
+ for(i=RF90_PATH_A; i<priv->NumTotalRFPath; i++)
+ {
+ // 2008/01/30 MH we will judge RF RX path now.
+ if (priv->brfpath_rxenable[i])
+ rf_rx_num++;
+ else
+ continue;
+
+ if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i))
+ continue;
+
+ //Fixed by Jacken from Bryant 2008-03-20
+ //Original value is 106
+ rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106;
+
+ //Get Rx snr value in DB
+ tmp_rxsnr = pofdm_buf->rxsnr_X[i];
+ rx_snrX = (char)(tmp_rxsnr);
+ //rx_snrX >>= 1;;
+ rx_snrX /= 2;
+ priv->stats.rxSNRdB[i] = (long)rx_snrX;
+
+ /* Translate DBM to percentage. */
+ RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]);
+ total_rssi += RSSI;
+
+ /* Record Signal Strength for next packet */
+ //if(bpacket_match_bssid)
+ {
+ pstats->RxMIMOSignalStrength[i] =(u8) RSSI;
+ precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI;
+ }
+ }
+
+
+ //
+ // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
+ //
+ //Fixed by Jacken from Bryant 2008-03-20
+ //Original value is 106
+ rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106;
+ pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all);
+
+ pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all;
+ pstats->RxPower = precord_stats->RxPower = rx_pwr_all;
+
+ //
+ // (3)EVM of HT rate
+ //
+ if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 &&
+ pdrvinfo->RxRate<=DESC90_RATEMCS15)
+ max_spatial_stream = 2; //both spatial stream make sense
+ else
+ max_spatial_stream = 1; //only spatial stream 1 makes sense
+
+ for(i=0; i<max_spatial_stream; i++)
+ {
+ tmp_rxevm = pofdm_buf->rxevm_X[i];
+ rx_evmX = (char)(tmp_rxevm);
+
+ // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
+ // fill most significant bit to "zero" when doing shifting operation which may change a negative
+ // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
+ rx_evmX /= 2; //dbm
+
+ evm = rtl819x_evm_dbtopercentage(rx_evmX);
+#if 0
+ EVM = SignalScaleMapping(EVM);//make it good looking, from 0~100
+#endif
+ //if(bpacket_match_bssid)
+ {
+ if(i==0) // Fill value in RFD, Get the first spatial stream only
+ pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff);
+ pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff);
+ }
+ }
+
+
+ /* record rx statistics for debug */
+ rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg;
+ prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg;
+ if(pdrvinfo->BW) //40M channel
+ priv->stats.received_bwtype[1+prxsc->rxsc]++;
+ else //20M channel
+ priv->stats.received_bwtype[0]++;
+ }
+
+ //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
+ //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
+ if(is_cck_rate)
+ {
+ pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL;
+
+ }
+ else
+ {
+ //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u8)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u8)(total_rssi/=RF90_PATH_MAX);
+ // We can judge RX path number now.
+ if (rf_rx_num != 0)
+ pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num)));
+ }
+} /* QueryRxPhyStatus8190Pci */
+#endif
+
+void
+rtl8192_record_rxdesc_forlateruse(
+ struct ieee80211_rx_stats * psrc_stats,
+ struct ieee80211_rx_stats * ptarget_stats
+)
+{
+ ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU;
+ ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU;
+ ptarget_stats->Seq_Num = psrc_stats->Seq_Num;
+}
+
+#ifdef RTL8192SU
+static void rtl8192SU_query_rxphystatus(
+ struct r8192_priv * priv,
+ struct ieee80211_rx_stats * pstats,
+ rx_desc_819x_usb *pDesc,
+ rx_drvinfo_819x_usb * pdrvinfo,
+ struct ieee80211_rx_stats * precord_stats,
+ bool bpacket_match_bssid,
+ bool bpacket_toself,
+ bool bPacketBeacon,
+ bool bToSelfBA
+ );
+void rtl8192SU_TranslateRxSignalStuff(struct sk_buff *skb,
+ struct ieee80211_rx_stats * pstats,
+ rx_desc_819x_usb *pDesc,
+ rx_drvinfo_819x_usb *pdrvinfo)
+{
+ // TODO: We must only check packet for current MAC address. Not finish
+ rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev=info->dev;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ bool bpacket_match_bssid, bpacket_toself;
+ bool bPacketBeacon=FALSE, bToSelfBA=FALSE;
+ static struct ieee80211_rx_stats previous_stats;
+ struct ieee80211_hdr_3addr *hdr;//by amy
+ u16 fc,type;
+
+ // Get Signal Quality for only RX data queue (but not command queue)
+
+ u8* tmp_buf;
+ //u16 tmp_buf_len = 0;
+ u8 *praddr;
+
+ /* Get MAC frame start address. */
+ tmp_buf = (u8*)skb->data;// + get_rxpacket_shiftbytes_819xusb(pstats);
+
+ hdr = (struct ieee80211_hdr_3addr *)tmp_buf;
+ fc = le16_to_cpu(hdr->frame_ctl);
+ type = WLAN_FC_GET_TYPE(fc);
+ praddr = hdr->addr1;
+
+ /* Check if the received packet is acceptabe. */
+ bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) &&
+ (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3))
+ && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV));
+ bpacket_toself = bpacket_match_bssid & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
+
+#if 1//cosa
+ if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON)
+ {
+ bPacketBeacon = true;
+ //DbgPrint("Beacon 2, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
+ }
+ if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK)
+ {
+ if((eqMacAddr(praddr,dev->dev_addr)))
+ bToSelfBA = true;
+ //DbgPrint("BlockAck, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
+ }
+
+#endif
+
+
+ if(bpacket_match_bssid)
+ {
+ priv->stats.numpacket_matchbssid++;
+ }
+ if(bpacket_toself){
+ priv->stats.numpacket_toself++;
+ }
+ //
+ // Process PHY information for previous packet (RSSI/PWDB/EVM)
+ //
+ // Because phy information is contained in the last packet of AMPDU only, so driver
+ // should process phy information of previous packet
+ rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats);
+ rtl8192SU_query_rxphystatus(priv, pstats, pDesc, pdrvinfo, &previous_stats, bpacket_match_bssid,bpacket_toself,bPacketBeacon,bToSelfBA);
+ rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats);
+
+}
+#else
+void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
+ struct ieee80211_rx_stats * pstats,
+ rx_drvinfo_819x_usb *pdrvinfo)
+{
+ // TODO: We must only check packet for current MAC address. Not finish
+ rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev=info->dev;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ bool bpacket_match_bssid, bpacket_toself;
+ bool bPacketBeacon=FALSE, bToSelfBA=FALSE;
+ static struct ieee80211_rx_stats previous_stats;
+ struct ieee80211_hdr_3addr *hdr;//by amy
+ u16 fc,type;
+
+ // Get Signal Quality for only RX data queue (but not command queue)
+
+ u8* tmp_buf;
+ //u16 tmp_buf_len = 0;
+ u8 *praddr;
+
+ /* Get MAC frame start address. */
+ tmp_buf = (u8*)skb->data;// + get_rxpacket_shiftbytes_819xusb(pstats);
+
+ hdr = (struct ieee80211_hdr_3addr *)tmp_buf;
+ fc = le16_to_cpu(hdr->frame_ctl);
+ type = WLAN_FC_GET_TYPE(fc);
+ praddr = hdr->addr1;
+
+ /* Check if the received packet is acceptabe. */
+ bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) &&
+ (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3))
+ && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV));
+ bpacket_toself = bpacket_match_bssid & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
+
+#if 1//cosa
+ if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON)
+ {
+ bPacketBeacon = true;
+ //DbgPrint("Beacon 2, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
+ }
+ if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK)
+ {
+ if((eqMacAddr(praddr,dev->dev_addr)))
+ bToSelfBA = true;
+ //DbgPrint("BlockAck, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
+ }
+
+#endif
+
+
+ if(bpacket_match_bssid)
+ {
+ priv->stats.numpacket_matchbssid++;
+ }
+ if(bpacket_toself){
+ priv->stats.numpacket_toself++;
+ }
+ //
+ // Process PHY information for previous packet (RSSI/PWDB/EVM)
+ //
+ // Because phy information is contained in the last packet of AMPDU only, so driver
+ // should process phy information of previous packet
+ rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats);
+ rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats, bpacket_match_bssid,bpacket_toself,bPacketBeacon,bToSelfBA);
+ rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats);
+
+}
+#endif
+
+/**
+* Function: UpdateReceivedRateHistogramStatistics
+* Overview: Recored down the received data rate
+*
+* Input:
+* struct net_device *dev
+* struct ieee80211_rx_stats *stats
+*
+* Output:
+*
+* (priv->stats.ReceivedRateHistogram[] is updated)
+* Return:
+* None
+*/
+void
+UpdateReceivedRateHistogramStatistics8190(
+ struct net_device *dev,
+ struct ieee80211_rx_stats *stats
+ )
+{
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV
+ u32 rateIndex;
+ u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI
+
+
+ if(stats->bCRC)
+ rcvType = 2;
+ else if(stats->bICV)
+ rcvType = 3;
+
+ if(stats->bShortPreamble)
+ preamble_guardinterval = 1;// short
+ else
+ preamble_guardinterval = 0;// long
+
+ switch(stats->rate)
+ {
+ //
+ // CCK rate
+ //
+ case MGN_1M: rateIndex = 0; break;
+ case MGN_2M: rateIndex = 1; break;
+ case MGN_5_5M: rateIndex = 2; break;
+ case MGN_11M: rateIndex = 3; break;
+ //
+ // Legacy OFDM rate
+ //
+ case MGN_6M: rateIndex = 4; break;
+ case MGN_9M: rateIndex = 5; break;
+ case MGN_12M: rateIndex = 6; break;
+ case MGN_18M: rateIndex = 7; break;
+ case MGN_24M: rateIndex = 8; break;
+ case MGN_36M: rateIndex = 9; break;
+ case MGN_48M: rateIndex = 10; break;
+ case MGN_54M: rateIndex = 11; break;
+ //
+ // 11n High throughput rate
+ //
+ case MGN_MCS0: rateIndex = 12; break;
+ case MGN_MCS1: rateIndex = 13; break;
+ case MGN_MCS2: rateIndex = 14; break;
+ case MGN_MCS3: rateIndex = 15; break;
+ case MGN_MCS4: rateIndex = 16; break;
+ case MGN_MCS5: rateIndex = 17; break;
+ case MGN_MCS6: rateIndex = 18; break;
+ case MGN_MCS7: rateIndex = 19; break;
+ case MGN_MCS8: rateIndex = 20; break;
+ case MGN_MCS9: rateIndex = 21; break;
+ case MGN_MCS10: rateIndex = 22; break;
+ case MGN_MCS11: rateIndex = 23; break;
+ case MGN_MCS12: rateIndex = 24; break;
+ case MGN_MCS13: rateIndex = 25; break;
+ case MGN_MCS14: rateIndex = 26; break;
+ case MGN_MCS15: rateIndex = 27; break;
+ default: rateIndex = 28; break;
+ }
+ priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++;
+ priv->stats.received_rate_histogram[0][rateIndex]++; //total
+ priv->stats.received_rate_histogram[rcvType][rateIndex]++;
+}
+
+#ifdef RTL8192SU
+void rtl8192SU_query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe)
+{
+ rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev=info->dev;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ //rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+ rx_drvinfo_819x_usb *driver_info = NULL;
+
+ //PRT_RFD_STATUS pRtRfdStatus = &pRfd->Status;
+ //PHAL_DATA_8192SUSB pHalData = GET_HAL_DATA(Adapter);
+ //pu1Byte pDesc = (pu1Byte)pDescIn;
+ //PRX_DRIVER_INFO_8192S pDrvInfo;
+
+#ifdef USB_RX_AGGREGATION_SUPPORT//FIXLZM
+ //if (bIsRxAggrSubframe)
+ rx_desc_819x_usb_aggr_subframe *desc = (rx_desc_819x_usb_aggr_subframe *)skb->data;
+ else
+#endif
+ rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+
+ if(0)
+ {
+ int m = 0;
+ printk("========================");
+ for(m=0; m<skb->len; m++){
+ if((m%32) == 0)
+ printk("\n");
+ printk("%2x ",((u8*)skb->data)[m]);
+ }
+ printk("\n========================\n");
+
+ }
+
+
+ //
+ //Get Rx Descriptor Raw Information
+ //
+ stats->Length = desc->Length ;
+ stats->RxDrvInfoSize = desc->RxDrvInfoSize*RX_DRV_INFO_SIZE_UNIT;
+ stats->RxBufShift = (desc->Shift)&0x03;
+ stats->bICV = desc->ICV;
+ stats->bCRC = desc->CRC32;
+ stats->bHwError = stats->bCRC|stats->bICV;
+ stats->Decrypted = !desc->SWDec;//RTL8190 set this bit to indicate that Hw does not decrypt packet
+ stats->bIsAMPDU = (desc->AMSDU==1);
+ stats->bFirstMPDU = (desc->PAGGR==1) && (desc->FAGGR==1);
+ stats->bShortPreamble = desc->SPLCP;
+ stats->RxIs40MHzPacket = (desc->BW==1);
+ stats->TimeStampLow = desc->TSFL;
+
+ if((desc->FAGGR==1) || (desc->PAGGR==1))
+ {// Rx A-MPDU
+ RT_TRACE(COMP_RXDESC, "FirstAGGR = %d, PartAggr = %d\n", desc->FAGGR, desc->PAGGR);
+ }
+//YJ,test,090310
+if(stats->bHwError)
+{
+ if(stats->bICV)
+ printk("%s: Receive ICV error!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__);
+ if(stats->bCRC)
+ printk("%s: Receive CRC error!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__);
+}
+
+ if(IS_UNDER_11N_AES_MODE(priv->ieee80211))
+ {
+ // Always received ICV error packets in AES mode.
+ // This fixed HW later MIC write bug.
+ if(stats->bICV && !stats->bCRC)
+ {
+ stats->bICV = FALSE;
+ stats->bHwError = FALSE;
+ }
+ }
+
+ // Transform HwRate to MRate
+ if(!stats->bHwError)
+ //stats->DataRate = HwRateToMRate(
+ // (BOOLEAN)GET_RX_DESC_RXHT(pDesc),
+ // (u1Byte)GET_RX_DESC_RXMCS(pDesc),
+ // (BOOLEAN)GET_RX_DESC_PAGGR(pDesc));
+ stats->rate = rtl8192SU_HwRateToMRate(desc->RxHT, desc->RxMCS, desc->PAGGR);
+ else
+ stats->rate = MGN_1M;
+
+ //
+ // Collect Rx rate/AMPDU/TSFL
+ //
+ //UpdateRxdRateHistogramStatistics8192S(Adapter, pRfd);
+ //UpdateRxAMPDUHistogramStatistics8192S(Adapter, pRfd);
+ //UpdateRxPktTimeStamp8192S(Adapter, pRfd);
+ UpdateReceivedRateHistogramStatistics8190(dev, stats);
+ //UpdateRxAMPDUHistogramStatistics8192S(dev, stats); //FIXLZM
+ UpdateRxPktTimeStamp8190(dev, stats);
+
+ //
+ // Get PHY Status and RSVD parts.
+ // <Roger_Notes> It only appears on last aggregated packet.
+ //
+ if (desc->PHYStatus)
+ {
+ //driver_info = (rx_drvinfo_819x_usb *)(skb->data + RX_DESC_SIZE + stats->RxBufShift);
+ driver_info = (rx_drvinfo_819x_usb *)(skb->data + sizeof(rx_desc_819x_usb) + \
+ stats->RxBufShift);
+ if(0)
+ {
+ int m = 0;
+ printk("========================\n");
+ printk("RX_DESC_SIZE:%d, RxBufShift:%d, RxDrvInfoSize:%d\n",
+ RX_DESC_SIZE, stats->RxBufShift, stats->RxDrvInfoSize);
+ for(m=0; m<32; m++){
+ printk("%2x ",((u8*)driver_info)[m]);
+ }
+ printk("\n========================\n");
+
+ }
+
+ }
+
+ //YJ,add,090107
+ skb_pull(skb, sizeof(rx_desc_819x_usb));
+ //YJ,add,090107,end
+
+ //
+ // Get Total offset of MPDU Frame Body
+ //
+ if((stats->RxBufShift + stats->RxDrvInfoSize) > 0)
+ {
+ stats->bShift = 1;
+ //YJ,add,090107
+ skb_pull(skb, stats->RxBufShift + stats->RxDrvInfoSize);
+ //YJ,add,090107,end
+ }
+
+ //
+ // Get PHY Status and RSVD parts.
+ // <Roger_Notes> It only appears on last aggregated packet.
+ //
+ if (desc->PHYStatus)
+ {
+ rtl8192SU_TranslateRxSignalStuff(skb, stats, desc, driver_info);
+ }
+}
+#else
+void query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe)
+{
+ rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev=info->dev;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ //rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+ rx_drvinfo_819x_usb *driver_info = NULL;
+
+ //
+ //Get Rx Descriptor Information
+ //
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ if (bIsRxAggrSubframe)
+ {
+ rx_desc_819x_usb_aggr_subframe *desc = (rx_desc_819x_usb_aggr_subframe *)skb->data;
+ stats->Length = desc->Length ;
+ stats->RxDrvInfoSize = desc->RxDrvInfoSize;
+ stats->RxBufShift = 0; //RxBufShift = 2 in RxDesc, but usb didn't shift bytes in fact.
+ stats->bICV = desc->ICV;
+ stats->bCRC = desc->CRC32;
+ stats->bHwError = stats->bCRC|stats->bICV;
+ stats->Decrypted = !desc->SWDec;//RTL8190 set this bit to indicate that Hw does not decrypt packet
+ } else
+#endif
+ {
+ rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+
+ stats->Length = desc->Length;
+ stats->RxDrvInfoSize = desc->RxDrvInfoSize;
+ stats->RxBufShift = 0;//desc->Shift&0x03;
+ stats->bICV = desc->ICV;
+ stats->bCRC = desc->CRC32;
+ stats->bHwError = stats->bCRC|stats->bICV;
+ //RTL8190 set this bit to indicate that Hw does not decrypt packet
+ stats->Decrypted = !desc->SWDec;
+ }
+
+ if((priv->ieee80211->pHTInfo->bCurrentHTSupport == true) && (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP))
+ {
+ stats->bHwError = false;
+ }
+ else
+ {
+ stats->bHwError = stats->bCRC|stats->bICV;
+ }
+
+ if(stats->Length < 24 || stats->Length > MAX_8192U_RX_SIZE)
+ stats->bHwError |= 1;
+ //
+ //Get Driver Info
+ //
+ // TODO: Need to verify it on FGPA platform
+ //Driver info are written to the RxBuffer following rx desc
+ if (stats->RxDrvInfoSize != 0) {
+ driver_info = (rx_drvinfo_819x_usb *)(skb->data + sizeof(rx_desc_819x_usb) + \
+ stats->RxBufShift);
+ /* unit: 0.5M */
+ /* TODO */
+ if(!stats->bHwError){
+ u8 ret_rate;
+ ret_rate = HwRateToMRate90(driver_info->RxHT, driver_info->RxRate);
+ if(ret_rate == 0xff)
+ {
+ // Abnormal Case: Receive CRC OK packet with Rx descriptor indicating non supported rate.
+ // Special Error Handling here, 2008.05.16, by Emily
+
+ stats->bHwError = 1;
+ stats->rate = MGN_1M; //Set 1M rate by default
+ }else
+ {
+ stats->rate = ret_rate;
+ }
+ }
+ else
+ stats->rate = 0x02;
+
+ stats->bShortPreamble = driver_info->SPLCP;
+
+
+ UpdateReceivedRateHistogramStatistics8190(dev, stats);
+
+ stats->bIsAMPDU = (driver_info->PartAggr==1);
+ stats->bFirstMPDU = (driver_info->PartAggr==1) && (driver_info->FirstAGGR==1);
+#if 0
+ // TODO: it is debug only. It should be disabled in released driver. 2007.1.12 by Joseph
+ UpdateRxAMPDUHistogramStatistics8190(Adapter, pRfd);
+#endif
+ stats->TimeStampLow = driver_info->TSFL;
+ // xiong mask it, 070514
+ //pRfd->Status.TimeStampHigh = PlatformEFIORead4Byte(Adapter, TSFR+4);
+ // stats->TimeStampHigh = read_nic_dword(dev, TSFR+4);
+
+ UpdateRxPktTimeStamp8190(dev, stats);
+
+ //
+ // Rx A-MPDU
+ //
+ if(driver_info->FirstAGGR==1 || driver_info->PartAggr == 1)
+ RT_TRACE(COMP_RXDESC, "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n",
+ driver_info->FirstAGGR, driver_info->PartAggr);
+
+ }
+
+ skb_pull(skb,sizeof(rx_desc_819x_usb));
+ //
+ // Get Total offset of MPDU Frame Body
+ //
+ if((stats->RxBufShift + stats->RxDrvInfoSize) > 0) {
+ stats->bShift = 1;
+ skb_pull(skb,stats->RxBufShift + stats->RxDrvInfoSize);
+ }
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ /* for the rx aggregated sub frame, the redundant space truelly contained in the packet */
+ if(bIsRxAggrSubframe) {
+ skb_pull(skb, 8);
+ }
+#endif
+ /* for debug 2008.5.29 */
+#if 0
+ {
+ int i;
+ printk("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+ for(i = 0; i < skb->len; i++) {
+ if(i % 10 == 0) printk("\n");
+ printk("%02x ", skb->data[i]);
+ }
+ printk("\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
+ }
+#endif
+
+ //added by vivi, for MP, 20080108
+ stats->RxIs40MHzPacket = driver_info->BW;
+ if(stats->RxDrvInfoSize != 0)
+ TranslateRxSignalStuff819xUsb(skb, stats, driver_info);
+
+}
+#endif
+
+#ifdef RTL8192SU
+#if 0
+/*-----------------------------------------------------------------------------
+ * Function: UpdateRxAMPDUHistogramStatistics8192S
+ *
+ * Overview: Recored down the received A-MPDU aggregation size and pkt number
+ *
+ * Input: Adapter
+ *
+ * Output: Adapter
+ * (Adapter->RxStats.RxAMPDUSizeHistogram[] is updated)
+ * (Adapter->RxStats.RxAMPDUNumHistogram[] is updated)
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 09/18/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+UpdateRxAMPDUHistogramStatistics8192S(
+ struct net_device *dev,
+ struct ieee80211_rx_stats *stats
+ )
+{
+ //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
+ u8 size_index;
+ u8 num_index;
+ u16 update_size = 0;
+ u8 update_num = 0;
+
+ if(stats->bIsAMPDU)
+ {
+ if(stats->bFirstMPDU)
+ {
+ if(stats->nRxAMPDU_Size!=0 && stats->nRxAMPDU_AggrNum!=0)
+ {
+ update_size = stats->nRxAMPDU_Size;
+ update_num = stats->nRxAMPDU_AggrNum;
+ }
+ stats->nRxAMPDU_Size = stats->Length;
+ stats->nRxAMPDU_AggrNum = 1;
+ }
+ else
+ {
+ stats->nRxAMPDU_Size += stats->Length;
+ stats->nRxAMPDU_AggrNum++;
+ }
+ }
+ else
+ {
+ if(stats->nRxAMPDU_Size!=0 && stats->nRxAMPDU_AggrNum!=0)
+ {
+ update_size = stats->nRxAMPDU_Size;
+ update_num = stats->nRxAMPDU_AggrNum;
+ }
+ stats->nRxAMPDU_Size = 0;
+ stats->nRxAMPDU_AggrNum = 0;
+ }
+
+ if(update_size!=0 && update_num!= 0)
+ {
+ if(update_size < 4096)
+ size_index = 0;
+ else if(update_size < 8192)
+ size_index = 1;
+ else if(update_size < 16384)
+ size_index = 2;
+ else if(update_size < 32768)
+ size_index = 3;
+ else if(update_size < 65536)
+ size_index = 4;
+ else
+ {
+ RT_TRACE(COMP_RXDESC,
+ ("UpdateRxAMPDUHistogramStatistics8192S(): A-MPDU too large\n");
+ }
+
+ Adapter->RxStats.RxAMPDUSizeHistogram[size_index]++;
+
+ if(update_num < 5)
+ num_index = 0;
+ else if(update_num < 10)
+ num_index = 1;
+ else if(update_num < 20)
+ num_index = 2;
+ else if(update_num < 40)
+ num_index = 3;
+ else
+ num_index = 4;
+
+ Adapter->RxStats.RxAMPDUNumHistogram[num_index]++;
+ }
+} // UpdateRxAMPDUHistogramStatistics8192S
+#endif
+
+#endif
+
+
+#ifdef RTL8192SU
+//
+// Description:
+// The strarting address of wireless lan header will shift 1 or 2 or 3 or "more" bytes for the following reason :
+// (1) QoS control : shift 2 bytes
+// (2) Mesh Network : shift 1 or 3 bytes
+// (3) RxDriverInfo occupies the front parts of Rx Packets buffer(shift units is in 8Bytes)
+//
+// It is because Lextra CPU used by 8186 or 865x series assert exception if the statrting address
+// of IP header is not double word alignment.
+// This features is supported in 818xb and 8190 only, but not 818x.
+//
+// parameter: PRT_RFD, Pointer of Reeceive frame descriptor which is initialized according to
+// Rx Descriptor
+// return value: unsigned int, number of total shifted bytes
+//
+// Notes: 2008/06/28, created by Roger
+//
+u32 GetRxPacketShiftBytes8192SU(struct ieee80211_rx_stats *Status, bool bIsRxAggrSubframe)
+{
+ //PRT_RFD_STATUS pRtRfdStatus = &pRfd->Status;
+
+ return (sizeof(rx_desc_819x_usb) + Status->RxDrvInfoSize + Status->RxBufShift);
+}
+
+void rtl8192SU_rx_nomal(struct sk_buff* skb)
+{
+ rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev=info->dev;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct ieee80211_rx_stats stats = {
+ .signal = 0,
+ .noise = -98,
+ .rate = 0,
+ // .mac_time = jiffies,
+ .freq = IEEE80211_24GHZ_BAND,
+ };
+ u32 rx_pkt_len = 0;
+ struct ieee80211_hdr_1addr *ieee80211_hdr = NULL;
+ bool unicast_packet = false;
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ struct sk_buff *agg_skb = NULL;
+ u32 TotalLength = 0;//Total packet length for all aggregated packets.
+ u32 TempDWord = 0;
+ u32 PacketLength = 0;// Per-packet length include size of RxDesc.
+ u32 PacketOccupiedLendth = 0;
+ u8 TempByte = 0;
+ u32 PacketShiftBytes = 0;
+ rx_desc_819x_usb_aggr_subframe *RxDescr = NULL;
+ u8 PaddingBytes = 0;
+ //add just for testing
+ u8 testing;
+
+ u8 TotalAggPkt = 0;
+ PRT_HIGH_THROUGHPUT pHTInfo =priv-> ieee80211->pHTInfo;
+ u16 RxPageSize = pHTInfo->UsbRxPageSize;
+
+ stats->nTotalAggPkt = 0;
+ //stats->bIsRxAggrSubframe = FALSE;
+
+#endif
+ //printk("**********skb->len = %d\n", skb->len);
+ /* 20 is for ps-poll */
+ if((skb->len >=(20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+
+ /* first packet should not contain Rx aggregation header */
+ rtl8192SU_query_rxdesc_status(skb, &stats, false);
+ /* TODO */
+
+ /* hardware related info */
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ TotalAggPkt = stats->nTotalAggPkt;
+ PacketLength = stats->Length + GetRxPacketShiftBytes8192SU(&stats, false);
+
+ agg_skb = skb;
+ skb = dev_alloc_skb(PacketLength);
+ memcpy(skb_put(skb,PacketLength),agg_skb->data,PacketLength);
+#endif
+ priv->stats.rxoktotal++; //YJ,test,090108
+
+ /* Process the MPDU recevied */
+ skb_trim(skb, skb->len - 4/*sCrcLng*/);//FIXLZM
+
+ rx_pkt_len = skb->len;
+ ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
+ unicast_packet = false;
+ if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
+ //TODO
+ }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
+ //TODO
+ }else {
+ /* unicast packet */
+ unicast_packet = true;
+ }
+
+ if(!ieee80211_rx(priv->ieee80211,skb, &stats)) {
+ dev_kfree_skb_any(skb);
+ } else {
+ // priv->stats.rxoktotal++; //YJ,test,090108
+ if(unicast_packet) {
+ priv->stats.rxbytesunicast += rx_pkt_len;
+ }
+ }
+
+ //up is firs pkt, follow is next and next
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ //
+ // The following operations are for processing Rx aggregated packets.
+ //
+ if(TotalAggPkt>0)
+ TotalAggPkt--;
+
+ while ( TotalAggPkt>0 )
+ {// More aggregated packets need to process.
+
+ u8 tmpCRC = 0, tmpICV = 0;
+
+ //Page size must align to multiple of 128-Bytes.
+ if((PacketLength%RxPageSize) != 0)
+ //PacketLength = ((PacketLength/RxPageSize)+1)*RxPageSize;
+ PacketLength = ((PacketLength>>7)+1)*RxPageSize; // RxPageSize is 128bytes as default.
+
+ // Current total packet occupied length in this buffer.
+ PacketOccupiedLendth += PacketLength;
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ //if(PacketOccupiedLendth>pContext->BufLenUsed)
+ if(PacketOccupiedLendth>skb->len)
+ {
+ RT_TRACE(COMP_RECV, "(1)HalUsbInMpduComplete8192SUsb(): pRtRfdStatus->Length(%#x)!!\n", stats->Length);
+ RT_TRACE(COMP_RECV, "(1)HalUsbInMpduComplete8192SUsb(): Invalid PacketOccupiedLendth(%#x)!!, BufLenUsed(%#x)\n", PacketOccupiedLendth, stats->BufLenUsed);
+ break;
+ }
+#endif
+
+ skb_pull(agg_skb, PacketLength);
+
+ //
+ // Process the MPDU recevied.
+ //
+ //RT_TRACE(COMP_RECV,"%s:aggred pkt,total_len = %d\n",__FUNCTION__,agg_skb->len);
+ RxDescr = (rx_desc_819x_usb_aggr_subframe *)(agg_skb->data);
+
+#if 0//92SU del
+ tmpCRC = RxDescr->CRC32;
+ tmpICV = RxDescr->ICV;
+ memcpy(agg_skb->data, &agg_skb->data[44], 2);
+ RxDescr->CRC32 = tmpCRC;
+ RxDescr->ICV = tmpICV;
+#endif
+ memset(&stats, 0, sizeof(struct ieee80211_rx_stats));
+ stats.signal = 0;
+ stats.noise = -98;
+ stats.rate = 0;
+ stats.freq = IEEE80211_24GHZ_BAND;
+
+ rtl8192SU_query_rxdesc_status(agg_skb, &stats, true);
+ //PacketLength = stats.Length;
+ PacketLength = stats.Length + GetRxPacketShiftBytes8192SU(&stats, true);
+
+#if (defined (RTL8192SU_FPGA_2MAC_VERIFICATION)||defined (RTL8192SU_ASIC_VERIFICATION))
+ if((PacketOccupiedLendth+PacketLength)>skb->len)
+ {
+ RT_TRACE(COMP_RECV, "(2)HalUsbInMpduComplete8192SUsb(): Invalid PacketOccupiedLendth(%#x)+PacketLength(%#x)!!, BufLenUsed(%#x)\n",
+ PacketOccupiedLendth, PacketLength, pContext->BufLenUsed);
+ break;
+ }
+#endif
+
+ if(PacketLength > agg_skb->len) {
+ break;
+ }
+
+ /* Process the MPDU recevied */
+ skb = dev_alloc_skb(PacketLength);
+ memcpy(skb_put(skb,PacketLength),agg_skb->data, PacketLength);
+ skb_trim(skb, skb->len - 4/*sCrcLng*/);
+
+ rx_pkt_len = skb->len;
+ ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
+ unicast_packet = false;
+ if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
+ //TODO
+ }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
+ //TODO
+ }else {
+ /* unicast packet */
+ unicast_packet = true;
+ }
+ if(!ieee80211_rx(priv->ieee80211,skb, &stats)) {
+ dev_kfree_skb_any(skb);
+ } else {
+ priv->stats.rxoktotal++;
+ if(unicast_packet) {
+ priv->stats.rxbytesunicast += rx_pkt_len;
+ }
+ }
+
+ TotalAggPkt--;
+
+ skb_pull(agg_skb, TempDWord);
+ }
+
+ dev_kfree_skb(agg_skb);
+#endif
+ }
+ else
+ {
+ priv->stats.rxurberr++;
+ printk("actual_length:%d\n", skb->len);
+ dev_kfree_skb_any(skb);
+ }
+
+}
+#else
+u32 GetRxPacketShiftBytes819xUsb(struct ieee80211_rx_stats *Status, bool bIsRxAggrSubframe)
+{
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ if (bIsRxAggrSubframe)
+ return (sizeof(rx_desc_819x_usb) + Status->RxDrvInfoSize
+ + Status->RxBufShift + 8);
+ else
+#endif
+ return (sizeof(rx_desc_819x_usb) + Status->RxDrvInfoSize
+ + Status->RxBufShift);
+}
+
+void rtl8192_rx_nomal(struct sk_buff* skb)
+{
+ rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev=info->dev;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct ieee80211_rx_stats stats = {
+ .signal = 0,
+ .noise = -98,
+ .rate = 0,
+ // .mac_time = jiffies,
+ .freq = IEEE80211_24GHZ_BAND,
+ };
+ u32 rx_pkt_len = 0;
+ struct ieee80211_hdr_1addr *ieee80211_hdr = NULL;
+ bool unicast_packet = false;
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ struct sk_buff *agg_skb = NULL;
+ u32 TotalLength = 0;
+ u32 TempDWord = 0;
+ u32 PacketLength = 0;
+ u32 PacketOccupiedLendth = 0;
+ u8 TempByte = 0;
+ u32 PacketShiftBytes = 0;
+ rx_desc_819x_usb_aggr_subframe *RxDescr = NULL;
+ u8 PaddingBytes = 0;
+ //add just for testing
+ u8 testing;
+
+#endif
+
+ /* 20 is for ps-poll */
+ if((skb->len >=(20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ TempByte = *(skb->data + sizeof(rx_desc_819x_usb));
+#endif
+ /* first packet should not contain Rx aggregation header */
+ query_rxdesc_status(skb, &stats, false);
+ /* TODO */
+ /* hardware related info */
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ if (TempByte & BIT0) {
+ agg_skb = skb;
+ //TotalLength = agg_skb->len - 4; /*sCrcLng*/
+ TotalLength = stats.Length - 4; /*sCrcLng*/
+ //RT_TRACE(COMP_RECV, "%s:first aggregated packet!Length=%d\n",__FUNCTION__,TotalLength);
+ /* though the head pointer has passed this position */
+ TempDWord = *(u32 *)(agg_skb->data - 4);
+ PacketLength = (u16)(TempDWord & 0x3FFF); /*sCrcLng*/
+ skb = dev_alloc_skb(PacketLength);
+ memcpy(skb_put(skb,PacketLength),agg_skb->data,PacketLength);
+ PacketShiftBytes = GetRxPacketShiftBytes819xUsb(&stats, false);
+ }
+#endif
+ /* Process the MPDU recevied */
+ skb_trim(skb, skb->len - 4/*sCrcLng*/);
+
+ rx_pkt_len = skb->len;
+ ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
+ unicast_packet = false;
+ if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
+ //TODO
+ }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
+ //TODO
+ }else {
+ /* unicast packet */
+ unicast_packet = true;
+ }
+
+ if(!ieee80211_rx(priv->ieee80211,skb, &stats)) {
+ dev_kfree_skb_any(skb);
+ } else {
+ priv->stats.rxoktotal++;
+ if(unicast_packet) {
+ priv->stats.rxbytesunicast += rx_pkt_len;
+ }
+ }
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ testing = 1;
+ // (PipeIndex == 0) && (TempByte & BIT0) => TotalLength > 0.
+ if (TotalLength > 0) {
+ PacketOccupiedLendth = PacketLength + (PacketShiftBytes + 8);
+ if ((PacketOccupiedLendth & 0xFF) != 0)
+ PacketOccupiedLendth = (PacketOccupiedLendth & 0xFFFFFF00) + 256;
+ PacketOccupiedLendth -= 8;
+ TempDWord = PacketOccupiedLendth - PacketShiftBytes; /*- PacketLength */
+ if (agg_skb->len > TempDWord)
+ skb_pull(agg_skb, TempDWord);
+ else
+ agg_skb->len = 0;
+
+ while (agg_skb->len>=GetRxPacketShiftBytes819xUsb(&stats, true)) {
+ u8 tmpCRC = 0, tmpICV = 0;
+ //RT_TRACE(COMP_RECV,"%s:aggred pkt,total_len = %d\n",__FUNCTION__,agg_skb->len);
+ RxDescr = (rx_desc_819x_usb_aggr_subframe *)(agg_skb->data);
+ tmpCRC = RxDescr->CRC32;
+ tmpICV = RxDescr->ICV;
+ memcpy(agg_skb->data, &agg_skb->data[44], 2);
+ RxDescr->CRC32 = tmpCRC;
+ RxDescr->ICV = tmpICV;
+
+ memset(&stats, 0, sizeof(struct ieee80211_rx_stats));
+ stats.signal = 0;
+ stats.noise = -98;
+ stats.rate = 0;
+ stats.freq = IEEE80211_24GHZ_BAND;
+ query_rxdesc_status(agg_skb, &stats, true);
+ PacketLength = stats.Length;
+
+ if(PacketLength > agg_skb->len) {
+ break;
+ }
+ /* Process the MPDU recevied */
+ skb = dev_alloc_skb(PacketLength);
+ memcpy(skb_put(skb,PacketLength),agg_skb->data, PacketLength);
+ skb_trim(skb, skb->len - 4/*sCrcLng*/);
+
+ rx_pkt_len = skb->len;
+ ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
+ unicast_packet = false;
+ if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
+ //TODO
+ }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
+ //TODO
+ }else {
+ /* unicast packet */
+ unicast_packet = true;
+ }
+ if(!ieee80211_rx(priv->ieee80211,skb, &stats)) {
+ dev_kfree_skb_any(skb);
+ } else {
+ priv->stats.rxoktotal++;
+ if(unicast_packet) {
+ priv->stats.rxbytesunicast += rx_pkt_len;
+ }
+ }
+ /* should trim the packet which has been copied to target skb */
+ skb_pull(agg_skb, PacketLength);
+ PacketShiftBytes = GetRxPacketShiftBytes819xUsb(&stats, true);
+ PacketOccupiedLendth = PacketLength + PacketShiftBytes;
+ if ((PacketOccupiedLendth & 0xFF) != 0) {
+ PaddingBytes = 256 - (PacketOccupiedLendth & 0xFF);
+ if (agg_skb->len > PaddingBytes)
+ skb_pull(agg_skb, PaddingBytes);
+ else
+ agg_skb->len = 0;
+ }
+ }
+ dev_kfree_skb(agg_skb);
+ }
+#endif
+ } else {
+ priv->stats.rxurberr++;
+ printk("actual_length:%d\n", skb->len);
+ dev_kfree_skb_any(skb);
+ }
+
+}
+
+#endif
+
+void
+rtl819xusb_process_received_packet(
+ struct net_device *dev,
+ struct ieee80211_rx_stats *pstats
+ )
+{
+// bool bfreerfd=false, bqueued=false;
+ u8* frame;
+ u16 frame_len=0;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+// u8 index = 0;
+// u8 TID = 0;
+ //u16 seqnum = 0;
+ //PRX_TS_RECORD pts = NULL;
+
+ // Get shifted bytes of Starting address of 802.11 header. 2006.09.28, by Emily
+ //porting by amy 080508
+ pstats->virtual_address += get_rxpacket_shiftbytes_819xusb(pstats);
+ frame = pstats->virtual_address;
+ frame_len = pstats->packetlength;
+#ifdef TODO // by amy about HCT
+ if(!Adapter->bInHctTest)
+ CountRxErrStatistics(Adapter, pRfd);
+#endif
+ {
+ #ifdef ENABLE_PS //by amy for adding ps function in future
+ RT_RF_POWER_STATE rtState;
+ // When RF is off, we should not count the packet for hw/sw synchronize
+ // reason, ie. there may be a duration while sw switch is changed and hw
+ // switch is being changed. 2006.12.04, by shien chang.
+ Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (u8* )(&rtState));
+ if (rtState == eRfOff)
+ {
+ return;
+ }
+ #endif
+ priv->stats.rxframgment++;
+
+ }
+#ifdef TODO
+ RmMonitorSignalStrength(Adapter, pRfd);
+#endif
+ /* 2007/01/16 MH Add RX command packet handle here. */
+ /* 2007/03/01 MH We have to release RFD and return if rx pkt is cmd pkt. */
+ if (rtl819xusb_rx_command_packet(dev, pstats))
+ {
+ return;
+ }
+
+#ifdef SW_CRC_CHECK
+ SwCrcCheck();
+#endif
+
+
+}
+
+void query_rx_cmdpkt_desc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats)
+{
+// rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+// struct net_device *dev=info->dev;
+// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+// rx_drvinfo_819x_usb *driver_info;
+
+ //
+ //Get Rx Descriptor Information
+ //
+ stats->virtual_address = (u8*)skb->data;
+ stats->Length = desc->Length;
+ stats->RxDrvInfoSize = 0;
+ stats->RxBufShift = 0;
+ stats->packetlength = stats->Length-scrclng;
+ stats->fraglength = stats->packetlength;
+ stats->fragoffset = 0;
+ stats->ntotalfrag = 1;
+}
+
+#ifdef RTL8192SU
+void rtl8192SU_rx_cmd(struct sk_buff *skb)
+{
+ struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev = info->dev;
+
+ /* TODO */
+ struct ieee80211_rx_stats stats = {
+ .signal = 0,
+ .noise = -98,
+ .rate = 0,
+ // .mac_time = jiffies,
+ .freq = IEEE80211_24GHZ_BAND,
+ };
+
+ //
+ // Check buffer length to determine if this is a valid MPDU.
+ //
+ if( (skb->len >= sizeof(rx_desc_819x_usb)) && (skb->len <= RX_URB_SIZE) )//&&
+ //(pHalData->SwChnlInProgress == FALSE))
+ {
+ //
+ // Collection information in Rx descriptor.
+ //
+#if 0
+ pRxDesc = pContext->Buffer;
+
+ pRfd->Buffer.VirtualAddress = pContext->Buffer; // 061109, rcnjko, for multi-platform consideration..
+
+ pRtRfdStatus->Length = (u2Byte)GET_RX_DESC_PKT_LEN(pRxDesc);
+ pRtRfdStatus->RxDrvInfoSize = 0;
+ pRtRfdStatus->RxBufShift = 0;
+
+ pRfd->PacketLength = pRfd->Status.Length - sCrcLng;
+ pRfd->FragLength = pRfd->PacketLength;
+ pRfd->FragOffset = 0;
+ pRfd->nTotalFrag = 1;
+ pRfd->queue_id = PipeIndex;
+#endif
+ query_rx_cmdpkt_desc_status(skb,&stats);
+ // this is to be done by amy 080508 prfd->queue_id = 1;
+
+ //
+ // Process the MPDU recevied.
+ //
+ rtl819xusb_process_received_packet(dev,&stats);
+
+ dev_kfree_skb_any(skb);
+ }
+ else
+ {
+ //RTInsertTailListWithCnt(&pAdapter->RfdIdleQueue, &pRfd->List, &pAdapter->NumIdleRfd);
+ //RT_ASSERT(pAdapter->NumIdleRfd <= pAdapter->NumRfd, ("HalUsbInCommandComplete8192SUsb(): Adapter->NumIdleRfd(%d)\n", pAdapter->NumIdleRfd));
+ //RT_TRACE(COMP_RECV, DBG_LOUD, ("HalUsbInCommandComplete8192SUsb(): NOT enough Resources!! BufLenUsed(%d), NumIdleRfd(%d)\n",
+ //pContext->BufLenUsed, pAdapter->NumIdleRfd));
+ }
+
+ //
+ // Reuse USB_IN_CONTEXT since we had finished processing the
+ // buffer in USB_IN_CONTEXT.
+ //
+ //HalUsbReturnInContext(pAdapter, pContext);
+
+ //
+ // Issue another bulk IN transfer.
+ //
+ //HalUsbInMpdu(pAdapter, PipeIndex);
+
+ RT_TRACE(COMP_RECV, "<--- HalUsbInCommandComplete8192SUsb()\n");
+
+}
+#else
+void rtl8192_rx_cmd(struct sk_buff *skb)
+{
+ struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
+ struct net_device *dev = info->dev;
+ //int ret;
+// struct urb *rx_urb = info->urb;
+ /* TODO */
+ struct ieee80211_rx_stats stats = {
+ .signal = 0,
+ .noise = -98,
+ .rate = 0,
+ // .mac_time = jiffies,
+ .freq = IEEE80211_24GHZ_BAND,
+ };
+
+ if((skb->len >=(20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE))
+ {
+
+ query_rx_cmdpkt_desc_status(skb,&stats);
+ // this is to be done by amy 080508 prfd->queue_id = 1;
+
+
+ //
+ // Process the command packet received.
+ //
+
+ rtl819xusb_process_received_packet(dev,&stats);
+
+ dev_kfree_skb_any(skb);
+ }
+ else
+ ;
+
+
+#if 0
+ desc = (u32*)(skb->data);
+ cmd = (desc[0] >> 30) & 0x03;
+
+ if(cmd == 0x00) {//beacon interrupt
+ //send beacon packet
+ skb = ieee80211_get_beacon(priv->ieee80211);
+
+ if(!skb){
+ DMESG("not enought memory for allocating beacon");
+ return;
+ }
+ skb->cb[0] = BEACON_PRIORITY;
+ skb->cb[1] = 0;
+ skb->cb[2] = ieeerate2rtlrate(priv->ieee80211->basic_rate);
+ ret = rtl8192_tx(dev, skb);
+
+ if( ret != 0 ){
+ printk(KERN_ALERT "tx beacon packet error : %d !\n", ret);
+ }
+ dev_kfree_skb_any(skb);
+ } else {//0x00
+ //{ log the device information
+ // At present, It is not implemented just now.
+ //}
+ }
+#endif
+}
+#endif
+
+void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
+{
+ struct sk_buff *skb;
+ struct rtl8192_rx_info *info;
+
+ while (NULL != (skb = skb_dequeue(&priv->skb_queue))) {
+ info = (struct rtl8192_rx_info *)skb->cb;
+ switch (info->out_pipe) {
+ /* Nomal packet pipe */
+ case 3:
+ //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe);
+ priv->IrpPendingCount--;
+ priv->ops->rtl819x_rx_nomal(skb);
+ break;
+
+ /* Command packet pipe */
+ case 9:
+ RT_TRACE(COMP_RECV, "command in-pipe index(%d)\n",\
+ info->out_pipe);
+ priv->ops->rtl819x_rx_cmd(skb);
+ break;
+
+ default: /* should never get here! */
+ RT_TRACE(COMP_ERR, "Unknown in-pipe index(%d)\n",\
+ info->out_pipe);
+ dev_kfree_skb(skb);
+ break;
+
+ }
+ }
+}
+
+
+
+/****************************************************************************
+ ---------------------------- USB_STUFF---------------------------
+*****************************************************************************/
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+//LZM Merge from windows HalUsbSetQueuePipeMapping8192SUsb 090319
+static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface *intf, struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *endpoint;
+ u8 i = 0;
+
+ priv->ep_in_num = 0;
+ priv->ep_out_num = 0;
+ memset(priv->RtOutPipes,0,16);
+ memset(priv->RtInPipes,0,16);
+
+#ifndef USE_ONE_PIPE
+ iface_desc = intf->cur_altsetting;
+ priv->ep_num = iface_desc->desc.bNumEndpoints;
+
+ for (i = 0; i < priv->ep_num; ++i) {
+ endpoint = &iface_desc->endpoint[i].desc;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
+ if (usb_endpoint_is_bulk_in(endpoint)) {
+ priv->RtInPipes[priv->ep_in_num] = usb_endpoint_num(endpoint);
+ priv->ep_in_num ++;
+ //printk("in_endpoint_idx = %d\n", usb_endpoint_num(endpoint));
+ } else if (usb_endpoint_is_bulk_out(endpoint)) {
+ priv->RtOutPipes[priv->ep_out_num] = usb_endpoint_num(endpoint);
+ priv->ep_out_num ++;
+ //printk("out_endpoint_idx = %d\n", usb_endpoint_num(endpoint));
+ }
+#else
+ if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) {
+ /* we found a bulk in endpoint */
+ priv->RtInPipes[priv->ep_in_num] = (endpoint->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ priv->ep_in_num ++;
+ } else if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) {
+ /* We found bulk out endpoint */
+ priv->RtOutPipes[priv->ep_out_num] = endpoint->bEndpointAddress;
+ priv->ep_out_num ++;
+ }
+#endif
+ }
+ {
+ memset(priv->txqueue_to_outpipemap,0,9);
+ if (priv->ep_num == 6) {
+ // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
+ u8 queuetopipe[] = {3, 2, 1, 0, 4, 4, 4, 4, 4};
+
+ memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
+ } else if (priv->ep_num == 4) {
+ // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
+ u8 queuetopipe[] = {1, 1, 0, 0, 2, 2, 2, 2, 2};
+
+ memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
+ } else if (priv->ep_num > 9) {
+ // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
+ u8 queuetopipe[] = {3, 2, 1, 0, 4, 8, 7, 6, 5};
+
+ memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
+ } else {//use sigle pipe
+ // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
+ u8 queuetopipe[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+ memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
+ }
+ }
+ printk("==>ep_num:%d, in_ep_num:%d, out_ep_num:%d\n", priv->ep_num, priv->ep_in_num, priv->ep_out_num);
+
+ printk("==>RtInPipes:");
+ for(i=0; i < priv->ep_in_num; i++)
+ printk("%d ", priv->RtInPipes[i]);
+ printk("\n");
+
+ printk("==>RtOutPipes:");
+ for(i=0; i < priv->ep_out_num; i++)
+ printk("%d ", priv->RtOutPipes[i]);
+ printk("\n");
+
+ printk("==>txqueue_to_outpipemap for BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON:\n");
+ for(i=0; i < 9; i++)
+ printk("%d ", priv->txqueue_to_outpipemap[i]);
+ printk("\n");
+#else
+ {
+ memset(priv->txqueue_to_outpipemap,0,9);
+ memset(priv->RtOutPipes,4,16);//all use endpoint 4 for out
+ }
+#endif
+
+ return;
+}
+#endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
+#else
+static void * __devinit rtl8192_usb_probe(struct usb_device *udev,
+ unsigned int ifnum,
+ const struct usb_device_id *id)
+#endif
+{
+// unsigned long ioaddr = 0;
+ struct net_device *dev = NULL;
+ struct r8192_priv *priv= NULL;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct usb_device *udev = interface_to_usbdev(intf);
+#endif
+ RT_TRACE(COMP_INIT, "Oops: i'm coming\n");
+
+ dev = alloc_ieee80211(sizeof(struct r8192_priv));
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+ SET_MODULE_OWNER(dev);
+#endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ usb_set_intfdata(intf, dev);
+ SET_NETDEV_DEV(dev, &intf->dev);
+#endif
+ priv = ieee80211_priv(dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ priv->ieee80211 = netdev_priv(dev);
+#else
+ priv->ieee80211 = (struct net_device *)dev->priv;
+#endif
+ priv->udev=udev;
+
+#ifdef RTL8192SU
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ HalUsbSetQueuePipeMapping8192SUsb(intf, dev);
+#else//use one pipe
+ {
+ memset(priv->txqueue_to_outpipemap,0,9);
+ memset(priv->RtOutPipes,4,16);//all use endpoint 4 for out
+ }
+#endif
+#endif
+
+#ifdef RTL8192SU
+ //printk("===============>NIC 8192SU\n");
+ priv->ops = &rtl8192su_ops;
+#else
+ //printk("===============>NIC 8192U\n");
+ priv->ops = &rtl8192u_ops;
+#endif
+
+ dev->open = rtl8192_open;
+ dev->stop = rtl8192_close;
+ //dev->hard_start_xmit = rtl8192_8023_hard_start_xmit;
+ dev->tx_timeout = tx_timeout;
+ //dev->wireless_handlers = &r8192_wx_handlers_def;
+ dev->do_ioctl = rtl8192_ioctl;
+ dev->set_multicast_list = r8192_set_multicast;
+ dev->set_mac_address = r8192_set_mac_adr;
+ dev->get_stats = rtl8192_stats;
+
+ //DMESG("Oops: i'm coming\n");
+#if WIRELESS_EXT >= 12
+#if WIRELESS_EXT < 17
+ dev->get_wireless_stats = r8192_get_wireless_stats;
+#endif
+ dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def;
+#endif
+ dev->type=ARPHRD_ETHER;
+
+ dev->watchdog_timeo = HZ*3; //modified by john, 0805
+
+ if (dev_alloc_name(dev, ifname) < 0){
+ RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n");
+ ifname = "wlan%d";
+ dev_alloc_name(dev, ifname);
+ }
+
+ RT_TRACE(COMP_INIT, "Driver probe completed1\n");
+#if 1
+ if(rtl8192_init(dev)!=0){
+ RT_TRACE(COMP_ERR, "Initialization failed");
+ goto fail;
+ }
+#endif
+ netif_carrier_off(dev);
+ netif_stop_queue(dev);
+
+ register_netdev(dev);
+ RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name);
+ rtl8192_proc_init_one(dev);
+
+
+ RT_TRACE(COMP_INIT, "Driver probe completed\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ return dev;
+#else
+ return 0;
+#endif
+
+
+fail:
+ free_ieee80211(dev);
+
+ RT_TRACE(COMP_ERR, "wlan driver load failed\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ return NULL;
+#else
+ return -ENODEV;
+#endif
+
+}
+
+//detach all the work and timer structure declared or inititialize in r8192U_init function.
+void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ cancel_work_sync(&priv->reset_wq);
+ cancel_work_sync(&priv->qos_activate);
+ cancel_delayed_work(&priv->watch_dog_wq);
+ cancel_delayed_work(&priv->update_beacon_wq);
+ cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq);
+ cancel_delayed_work(&priv->ieee80211->hw_sleep_wq);
+ //cancel_work_sync(&priv->SetBWModeWorkItem);
+ //cancel_work_sync(&priv->SwChnlWorkItem);
+#else
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ cancel_delayed_work(&priv->reset_wq);
+ cancel_delayed_work(&priv->qos_activate);
+ cancel_delayed_work(&priv->watch_dog_wq);
+ cancel_delayed_work(&priv->update_beacon_wq);
+ cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq);
+ cancel_delayed_work(&priv->ieee80211->hw_sleep_wq);
+
+ //cancel_delayed_work(&priv->SetBWModeWorkItem);
+ //cancel_delayed_work(&priv->SwChnlWorkItem);
+#endif
+#endif
+
+}
+
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf)
+#else
+static void __devexit rtl8192_usb_disconnect(struct usb_device *udev, void *ptr)
+#endif
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct net_device *dev = usb_get_intfdata(intf);
+#else
+ struct net_device *dev = (struct net_device *)ptr;
+#endif
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ if(dev){
+
+ unregister_netdev(dev);
+
+ RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n");
+ rtl8192_proc_remove_one(dev);
+
+ rtl8192_down(dev);
+ if (priv->pFirmware)
+ {
+ vfree(priv->pFirmware);
+ priv->pFirmware = NULL;
+ }
+ // priv->rf_close(dev);
+// rtl8192_SetRFPowerState(dev, eRfOff);
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+ destroy_workqueue(priv->priv_wq);
+#endif
+ //rtl8192_irq_disable(dev);
+ //rtl8192_reset(dev);
+ mdelay(10);
+
+ }
+ free_ieee80211(dev);
+ RT_TRACE(COMP_DOWN, "wlan driver removed\n");
+}
+
+static int __init rtl8192_usb_module_init(void)
+{
+ printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n");
+ printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n");
+ RT_TRACE(COMP_INIT, "Initializing module");
+ RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT);
+ rtl8192_proc_module_init();
+ return usb_register(&rtl8192_usb_driver);
+}
+
+
+static void __exit rtl8192_usb_module_exit(void)
+{
+ usb_deregister(&rtl8192_usb_driver);
+
+ RT_TRACE(COMP_DOWN, "Exiting");
+ rtl8192_proc_module_remove();
+}
+
+
+void rtl8192_try_wake_queue(struct net_device *dev, int pri)
+{
+ unsigned long flags;
+ short enough_desc;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+
+ spin_lock_irqsave(&priv->tx_lock,flags);
+ enough_desc = check_nic_enough_desc(dev,pri);
+ spin_unlock_irqrestore(&priv->tx_lock,flags);
+
+ if(enough_desc)
+ ieee80211_wake_queue(priv->ieee80211);
+}
+
+#if 0
+void DisableHWSecurityConfig8192SUsb(struct net_device *dev)
+{
+ u8 SECR_value = 0x0;
+ write_nic_byte(dev, SECR, SECR_value);//SECR_value | SCR_UseDK );
+}
+#endif
+
+void EnableHWSecurityConfig8192(struct net_device *dev)
+{
+ u8 SECR_value = 0x0;
+ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+
+ SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
+#if 1
+ if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2))
+ {
+ SECR_value |= SCR_RxUseDK;
+ SECR_value |= SCR_TxUseDK;
+ }
+ else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP)))
+ {
+ SECR_value |= SCR_RxUseDK;
+ SECR_value |= SCR_TxUseDK;
+ }
+#endif
+ //add HWSec active enable here.
+//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4
+
+ ieee->hwsec_active = 1;
+
+ if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off
+ {
+ ieee->hwsec_active = 0;
+ SECR_value &= ~SCR_RxDecEnable;
+ }
+
+ RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, \
+ ieee->hwsec_active, ieee->pairwise_key_type, SECR_value);
+ {
+ write_nic_byte(dev, SECR, SECR_value);//SECR_value | SCR_UseDK );
+ }
+}
+
+
+void setKey( struct net_device *dev,
+ u8 EntryNo,
+ u8 KeyIndex,
+ u16 KeyType,
+ u8 *MacAddr,
+ u8 DefaultKey,
+ u32 *KeyContent )
+{
+ u32 TargetCommand = 0;
+ u32 TargetContent = 0;
+ u16 usConfig = 0;
+ u8 i;
+ if (EntryNo >= TOTAL_CAM_ENTRY)
+ RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n");
+
+ RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr"MAC_FMT"\n", dev,EntryNo, KeyIndex, KeyType, MAC_ARG(MacAddr));
+
+ if (DefaultKey)
+ usConfig |= BIT15 | (KeyType<<2);
+ else
+ usConfig |= BIT15 | (KeyType<<2) | KeyIndex;
+// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex;
+
+
+ for(i=0 ; i<CAM_CONTENT_COUNT; i++){
+ TargetCommand = i+CAM_CONTENT_COUNT*EntryNo;
+ TargetCommand |= BIT31|BIT16;
+
+ if(i==0){//MAC|Config
+ TargetContent = (u32)(*(MacAddr+0)) << 16|
+ (u32)(*(MacAddr+1)) << 24|
+ (u32)usConfig;
+
+ write_nic_dword(dev, WCAMI, TargetContent);
+ write_nic_dword(dev, RWCAM, TargetCommand);
+ // printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo));
+ }
+ else if(i==1){//MAC
+ TargetContent = (u32)(*(MacAddr+2)) |
+ (u32)(*(MacAddr+3)) << 8|
+ (u32)(*(MacAddr+4)) << 16|
+ (u32)(*(MacAddr+5)) << 24;
+ write_nic_dword(dev, WCAMI, TargetContent);
+ write_nic_dword(dev, RWCAM, TargetCommand);
+ }
+ else {
+ //Key Material
+ if(KeyContent !=NULL){
+ write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) );
+ write_nic_dword(dev, RWCAM, TargetCommand);
+ }
+ }
+ }
+
+}
+
+/***************************************************************************
+ ------------------- module init / exit stubs ----------------
+****************************************************************************/
+module_init(rtl8192_usb_module_init);
+module_exit(rtl8192_usb_module_exit);
diff --git a/drivers/staging/rtl8192su/r8192U_dm.c b/drivers/staging/rtl8192su/r8192U_dm.c
new file mode 100644
index 000000000000..304274b886ea
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_dm.c
@@ -0,0 +1,4521 @@
+/*++
+Copyright-c Realtek Semiconductor Corp. All rights reserved.
+
+Module Name:
+ r8192U_dm.c
+
+Abstract:
+ HW dynamic mechanism.
+
+Major Change History:
+ When Who What
+ ---------- --------------- -------------------------------
+ 2008-05-14 amy create version 0 porting from windows code.
+
+--*/
+
+
+#ifdef RTL8192SU
+#include "r8192U.h"
+#include "r8192U_dm.h"
+//#include "r8190_rtl8256.h"
+#include "r819xU_cmdpkt.h"
+#include "r8192S_hw.h"
+#include "r8192S_phy.h"
+#include "r8192S_phyreg.h"
+#else
+#include "r8192U.h"
+#include "r8192U_dm.h"
+#include "r8192U_hw.h"
+#include "r819xU_phy.h"
+#include "r819xU_phyreg.h"
+#include "r8190_rtl8256.h"
+#include "r819xU_cmdpkt.h"
+#endif
+
+/*---------------------------Define Local Constant---------------------------*/
+//
+// Indicate different AP vendor for IOT issue.
+//
+#if 0
+typedef enum _HT_IOT_PEER
+{
+ HT_IOT_PEER_UNKNOWN = 0,
+ HT_IOT_PEER_REALTEK = 1,
+ HT_IOT_PEER_BROADCOM = 2,
+ HT_IOT_PEER_RALINK = 3,
+ HT_IOT_PEER_ATHEROS = 4,
+ HT_IOT_PEER_CISCO = 5,
+ HT_IOT_PEER_MAX = 6
+}HT_IOT_PEER_E, *PHTIOT_PEER_E;
+#endif
+#if 1
+#ifdef RTL8192SU
+ static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
+ // UNKNOWN REALTEK_90 /*REALTEK_92SE*/ BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP
+ { 0xa44f, 0x5ea44f, 0x5ea44f, 0xa44f, 0xa44f, 0xa44f, 0xa630, 0xa42b, 0x5e4322, 0x5e4322};
+ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
+ // UNKNOWN REALTEK /*REALTEK_92SE*/ BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP
+ { 0x5ea44f, 0xa44f, 0x5ea44f, 0x5e4322, 0x5ea422, 0x5e4322, 0x3ea44f, 0x5ea42b, 0x5e4322, 0x5e4322};
+
+#else
+
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
+ { 0x5e4322, 0x5e4322, 0x5ea44f, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
+ { 0x5e4322, 0xa44f, 0x5ea44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f};
+
+#endif
+#endif
+
+#define RTK_UL_EDCA 0xa44f
+#define RTK_DL_EDCA 0x5e4322
+/*---------------------------Define Local Constant---------------------------*/
+
+
+/*------------------------Define global variable-----------------------------*/
+// Debug variable ?
+dig_t dm_digtable;
+// Store current shoftware write register content for MAC PHY.
+u8 dm_shadow[16][256] = {{0}};
+// For Dynamic Rx Path Selection by Signal Strength
+DRxPathSel DM_RxPathSelTable;
+/*------------------------Define global variable-----------------------------*/
+
+
+/*------------------------Define local variable------------------------------*/
+/*------------------------Define local variable------------------------------*/
+
+
+/*--------------------Define export function prototype-----------------------*/
+#ifdef TO_DO_LIST
+static void dm_CheckProtection(struct net_device *dev);
+#endif
+extern void init_hal_dm(struct net_device *dev);
+extern void deinit_hal_dm(struct net_device *dev);
+
+extern void hal_dm_watchdog(struct net_device *dev);
+
+
+extern void init_rate_adaptive(struct net_device *dev);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_txpower_trackingcallback(struct work_struct *work);
+#else
+extern void dm_txpower_trackingcallback(struct net_device *dev);
+#endif
+
+extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14);
+extern void dm_restore_dynamic_mechanism_state(struct net_device *dev);
+extern void dm_backup_dynamic_mechanism_state(struct net_device *dev);
+extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
+ u32 dm_type,
+ u32 dm_value);
+extern void DM_ChangeFsyncSetting(struct net_device *dev,
+ s32 DM_Type,
+ s32 DM_Value);
+extern void dm_force_tx_fw_info(struct net_device *dev,
+ u32 force_type,
+ u32 force_value);
+extern void dm_init_edca_turbo(struct net_device *dev);
+extern void dm_rf_operation_test_callback(unsigned long data);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
+#else
+extern void dm_rf_pathcheck_workitemcallback(struct net_device *dev);
+#endif
+extern void dm_fsync_timer_callback(unsigned long data);
+#if 0
+extern bool dm_check_lbus_status(struct net_device *dev);
+#endif
+extern void dm_check_fsync(struct net_device *dev);
+extern void dm_shadow_init(struct net_device *dev);
+
+
+/*--------------------Define export function prototype-----------------------*/
+
+
+/*---------------------Define local function prototype-----------------------*/
+// DM --> Rate Adaptive
+static void dm_check_rate_adaptive(struct net_device *dev);
+
+// DM --> Bandwidth switch
+static void dm_init_bandwidth_autoswitch(struct net_device *dev);
+static void dm_bandwidth_autoswitch( struct net_device *dev);
+
+// DM --> TX power control
+//static void dm_initialize_txpower_tracking(struct net_device *dev);
+
+static void dm_check_txpower_tracking(struct net_device *dev);
+
+
+
+//static void dm_txpower_reset_recovery(struct net_device *dev);
+
+
+// DM --> BB init gain restore
+#ifndef RTL8192U
+static void dm_bb_initialgain_restore(struct net_device *dev);
+
+
+// DM --> BB init gain backup
+static void dm_bb_initialgain_backup(struct net_device *dev);
+#endif
+// DM --> Dynamic Init Gain by RSSI
+static void dm_dig_init(struct net_device *dev);
+static void dm_ctrl_initgain_byrssi(struct net_device *dev);
+static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
+static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev);
+static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev);
+static void dm_initial_gain(struct net_device *dev);
+static void dm_pd_th(struct net_device *dev);
+static void dm_cs_ratio(struct net_device *dev);
+
+static void dm_init_ctstoself(struct net_device *dev);
+// DM --> EDCA turboe mode control
+static void dm_check_edca_turbo(struct net_device *dev);
+
+// DM --> HW RF control
+static void dm_check_rfctrl_gpio(struct net_device *dev);
+
+#ifndef RTL8190P
+//static void dm_gpio_change_rf(struct net_device *dev);
+#endif
+// DM --> Check PBC
+static void dm_check_pbc_gpio(struct net_device *dev);
+
+
+// DM --> Check current RX RF path state
+static void dm_check_rx_path_selection(struct net_device *dev);
+static void dm_init_rxpath_selection(struct net_device *dev);
+static void dm_rxpath_sel_byrssi(struct net_device *dev);
+
+
+// DM --> Fsync for broadcom ap
+static void dm_init_fsync(struct net_device *dev);
+static void dm_deInit_fsync(struct net_device *dev);
+
+//Added by vivi, 20080522
+static void dm_check_txrateandretrycount(struct net_device *dev);
+
+/*---------------------Define local function prototype-----------------------*/
+
+/*---------------------Define of Tx Power Control For Near/Far Range --------*/ //Add by Jacken 2008/02/18
+static void dm_init_dynamic_txpower(struct net_device *dev);
+static void dm_dynamic_txpower(struct net_device *dev);
+
+
+// DM --> For rate adaptive and DIG, we must send RSSI to firmware
+static void dm_send_rssi_tofw(struct net_device *dev);
+static void dm_ctstoself(struct net_device *dev);
+/*---------------------------Define function prototype------------------------*/
+//================================================================================
+// HW Dynamic mechanism interface.
+//================================================================================
+#ifdef RTL8192SU
+static void dm_CheckAggrPolicy(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ //u8 QueueId;
+ //PRT_TCB pTcb;
+ bool bAmsduEnable = false;
+
+ static u8 lastTxOkCnt = 0;
+ static u8 lastRxOkCnt = 0;
+ u8 curTxOkCnt = 0;
+ u8 curRxOkCnt = 0;
+
+ // Determine if A-MSDU policy.
+ if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_HYBRID_AGGREGATION)
+ {
+ if(read_nic_byte(dev, INIMCS_SEL) > DESC92S_RATE54M)
+ bAmsduEnable = true;
+ }
+ else if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
+ {
+ if(read_nic_byte(dev, INIMCS_SEL) > DESC92S_RATE54M)
+ {
+ curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
+ curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
+
+ if(curRxOkCnt <= 4*curTxOkCnt)
+ bAmsduEnable = true;
+ }
+ }
+ else
+ {
+ // Do not need to switch aggregation policy.
+ return;
+ }
+
+ // Switch A-MSDU
+ if(bAmsduEnable && !pHTInfo->bCurrent_AMSDU_Support)
+ {
+ pHTInfo->bCurrent_AMSDU_Support = true;
+ }
+ else if(!bAmsduEnable && pHTInfo->bCurrent_AMSDU_Support)
+ {
+#ifdef TO_DO_LIST
+ //PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
+ for(QueueId = 0; QueueId < MAX_TX_QUEUE; QueueId++)
+ {
+ while(!RTIsListEmpty(&dev->TcbAggrQueue[QueueId]))
+ {
+ pTcb = (PRT_TCB)RTRemoveHeadList(&dev->TcbAggrQueue[QueueId]);
+ dev->TcbCountInAggrQueue[QueueId]--;
+ PreTransmitTCB(dev, pTcb);
+ }
+ }
+ //PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
+ pHTInfo->bCurrent_AMSDU_Support = false;
+#endif
+ }
+
+ // Determine A-MPDU policy
+ if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
+ {
+ if(!bAmsduEnable)
+ pHTInfo->bCurrentAMPDUEnable = true;
+ }
+
+ // Update local static variables.
+ lastTxOkCnt = priv->stats.txbytesunicast;
+ lastRxOkCnt = priv->stats.rxbytesunicast;
+}
+#endif
+//
+// Description:
+// Prepare SW resource for HW dynamic mechanism.
+//
+// Assumption:
+// This function is only invoked at driver intialization once.
+//
+//
+extern void
+init_hal_dm(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // Undecorated Smoothed Signal Strength, it can utilized to dynamic mechanism.
+ priv->undecorated_smoothed_pwdb = -1;
+
+ //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
+ dm_init_dynamic_txpower(dev);
+ init_rate_adaptive(dev);
+#ifdef RTL8192SU
+ dm_initialize_txpower_tracking(dev);
+#else
+ //dm_initialize_txpower_tracking(dev);
+#endif
+ dm_dig_init(dev);
+ dm_init_edca_turbo(dev);
+ dm_init_bandwidth_autoswitch(dev);
+ dm_init_fsync(dev);
+ dm_init_rxpath_selection(dev);
+ dm_init_ctstoself(dev);
+
+} // InitHalDm
+
+extern void deinit_hal_dm(struct net_device *dev)
+{
+
+ dm_deInit_fsync(dev);
+
+}
+
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+void dm_CheckRxAggregation(struct net_device *dev) {
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ static unsigned long lastTxOkCnt = 0;
+ static unsigned long lastRxOkCnt = 0;
+ unsigned long curTxOkCnt = 0;
+ unsigned long curRxOkCnt = 0;
+
+/*
+ if (pHalData->bForcedUsbRxAggr) {
+ if (pHalData->ForcedUsbRxAggrInfo == 0) {
+ if (pHalData->bCurrentRxAggrEnable) {
+ Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, FALSE);
+ }
+ } else {
+ if (!pHalData->bCurrentRxAggrEnable || (pHalData->ForcedUsbRxAggrInfo != pHalData->LastUsbRxAggrInfoSetting)) {
+ Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, TRUE);
+ }
+ }
+ return;
+ }
+
+*/
+#ifdef RTL8192SU
+ if (priv->bForcedUsbRxAggr) {
+ if (priv->ForcedUsbRxAggrInfo == 0) {
+ if (priv->bCurrentRxAggrEnable) {
+ //Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, FALSE);
+ write_nic_dword(dev, 0x1a8, 0);
+ priv->bCurrentRxAggrEnable = false;
+ }
+ } else {
+ if (!priv->bCurrentRxAggrEnable || (priv->ForcedUsbRxAggrInfo != priv->LastUsbRxAggrInfoSetting)) {
+ u32 ulValue;
+ ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
+ (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
+ /*
+ * If usb rx firmware aggregation is enabled,
+ * when anyone of three threshold conditions above is reached,
+ * firmware will send aggregated packet to driver.
+ */
+ write_nic_dword(dev, 0x1a8, ulValue);
+ priv->bCurrentRxAggrEnable = true;
+ }
+ }
+ return;
+ }
+
+ if((priv->ieee80211->mode & WIRELESS_MODE_B) || (priv->ieee80211->mode & WIRELESS_MODE_G))
+ {
+ if (priv->bCurrentRxAggrEnable)
+ {
+ RT_TRACE(COMP_RECV, "dm_CheckRxAggregation() : Disable Rx Aggregation!!\n");
+ write_nic_dword(dev, 0x1a8, 0);
+ priv->bCurrentRxAggrEnable = false;
+ return;
+ }
+ }
+#endif
+
+ curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
+ curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
+
+ if((curTxOkCnt + curRxOkCnt) < 15000000) {
+ return;
+ }
+
+ if(curTxOkCnt > 4*curRxOkCnt) {
+ if (priv->bCurrentRxAggrEnable) {
+ write_nic_dword(dev, 0x1a8, 0);
+ priv->bCurrentRxAggrEnable = false;
+ }
+ }else{
+ if (!priv->bCurrentRxAggrEnable && !pHTInfo->bCurrentRT2RTAggregation) {
+ u32 ulValue;
+ ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
+ (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
+ /*
+ * If usb rx firmware aggregation is enabled,
+ * when anyone of three threshold conditions above is reached,
+ * firmware will send aggregated packet to driver.
+ */
+ write_nic_dword(dev, 0x1a8, ulValue);
+ priv->bCurrentRxAggrEnable = true;
+ }
+ }
+
+ lastTxOkCnt = priv->stats.txbytesunicast;
+ lastRxOkCnt = priv->stats.rxbytesunicast;
+} // dm_CheckEdcaTurbo
+#endif
+
+
+#ifdef RTL8192SU
+//#if 0
+extern void hal_dm_watchdog(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if(priv->bInHctTest)
+ return;
+
+
+ dm_check_rfctrl_gpio(dev);
+
+ // Add by hpfan 2008-03-11
+ dm_check_pbc_gpio(dev);
+ dm_check_txrateandretrycount(dev); //moved by tynli
+ dm_check_edca_turbo(dev);
+
+ dm_CheckAggrPolicy(dev);
+
+#ifdef TO_DO_LIST
+ dm_CheckProtection(dev);
+#endif
+
+ // ====================================================
+ // If any dynamic mechanism is ready, put it above this return;
+ // ====================================================
+ //if (IS_HARDWARE_TYPE_8192S(dev))
+ return;
+
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ dm_CheckRxAggregation(dev);
+#endif
+#ifdef TO_DO_LIST
+ if(Adapter->MgntInfo.mActingAsAp)
+ {
+ AP_dm_CheckRateAdaptive(dev);
+ //return;
+ }
+ else
+#endif
+ {
+ dm_check_rate_adaptive(dev);
+ }
+ dm_dynamic_txpower(dev);
+
+ dm_check_txpower_tracking(dev);
+ dm_ctrl_initgain_byrssi(dev);//LZM TMP 090302
+
+ dm_bandwidth_autoswitch(dev);
+
+ dm_check_rx_path_selection(dev);//LZM TMP 090302
+ dm_check_fsync(dev);
+
+ dm_send_rssi_tofw(dev);
+
+ dm_ctstoself(dev);
+
+} //HalDmWatchDog
+#else
+extern void hal_dm_watchdog(struct net_device *dev)
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+
+ //static u8 previous_bssid[6] ={0};
+
+ /*Add by amy 2008/05/15 ,porting from windows code.*/
+ dm_check_rate_adaptive(dev);
+ dm_dynamic_txpower(dev);
+ dm_check_txrateandretrycount(dev);
+ dm_check_txpower_tracking(dev);
+ dm_ctrl_initgain_byrssi(dev);
+ dm_check_edca_turbo(dev);
+ dm_bandwidth_autoswitch(dev);
+ dm_check_rfctrl_gpio(dev);
+ dm_check_rx_path_selection(dev);
+ dm_check_fsync(dev);
+
+ // Add by amy 2008-05-15 porting from windows code.
+ dm_check_pbc_gpio(dev);
+ dm_send_rssi_tofw(dev);
+ dm_ctstoself(dev);
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ dm_CheckRxAggregation(dev);
+#endif
+} //HalDmWatchDog
+#endif
+
+/*
+ * Decide Rate Adaptive Set according to distance (signal strength)
+ * 01/11/2008 MHC Modify input arguments and RATR table level.
+ * 01/16/2008 MHC RF_Type is assigned in ReadAdapterInfo(). We must call
+ * the function after making sure RF_Type.
+ */
+extern void init_rate_adaptive(struct net_device * dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive;
+
+ pra->ratr_state = DM_RATR_STA_MAX;
+ pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High;
+ pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5;
+ pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5;
+
+ pra->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5;
+ pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M;
+ pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M;
+
+ if(priv->CustomerID == RT_CID_819x_Netcore)
+ pra->ping_rssi_enable = 1;
+ else
+ pra->ping_rssi_enable = 0;
+ pra->ping_rssi_thresh_for_ra = 15;
+
+
+ if (priv->rf_type == RF_2T4R)
+ {
+ // 07/10/08 MH Modify for RA smooth scheme.
+ /* 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.*/
+ pra->upper_rssi_threshold_ratr = 0x8f0f0000;
+ pra->middle_rssi_threshold_ratr = 0x8f0ff000;
+ pra->low_rssi_threshold_ratr = 0x8f0ff001;
+ pra->low_rssi_threshold_ratr_40M = 0x8f0ff005;
+ pra->low_rssi_threshold_ratr_20M = 0x8f0ff001;
+ pra->ping_rssi_ratr = 0x0000000d;//cosa add for test
+ }
+ else if (priv->rf_type == RF_1T2R)
+ {
+ pra->upper_rssi_threshold_ratr = 0x000f0000;
+ pra->middle_rssi_threshold_ratr = 0x000ff000;
+ pra->low_rssi_threshold_ratr = 0x000ff001;
+ pra->low_rssi_threshold_ratr_40M = 0x000ff005;
+ pra->low_rssi_threshold_ratr_20M = 0x000ff001;
+ pra->ping_rssi_ratr = 0x0000000d;//cosa add for test
+ }
+
+} // InitRateAdaptive
+
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_check_rate_adaptive()
+ *
+ * Overview:
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/26/08 amy Create version 0 proting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void dm_check_rate_adaptive(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive;
+ u32 currentRATR, targetRATR = 0;
+ u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0;
+ bool bshort_gi_enabled = false;
+ static u8 ping_rssi_state=0;
+
+
+ if(!priv->up)
+ {
+ RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n");
+ return;
+ }
+
+ if(pra->rate_adaptive_disabled)//this variable is set by ioctl.
+ return;
+
+ // TODO: Only 11n mode is implemented currently,
+ if( !(priv->ieee80211->mode == WIRELESS_MODE_N_24G ||
+ priv->ieee80211->mode == WIRELESS_MODE_N_5G))
+ return;
+
+ if( priv->ieee80211->state == IEEE80211_LINKED )
+ {
+ // RT_TRACE(COMP_RATE, "dm_CheckRateAdaptive(): \t");
+
+ //
+ // Check whether Short GI is enabled
+ //
+ bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) ||
+ (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz);
+
+
+ pra->upper_rssi_threshold_ratr =
+ (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
+
+ pra->middle_rssi_threshold_ratr =
+ (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
+
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ pra->low_rssi_threshold_ratr =
+ (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
+ }
+ else
+ {
+ pra->low_rssi_threshold_ratr =
+ (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
+ }
+ //cosa add for test
+ pra->ping_rssi_ratr =
+ (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
+
+ /* 2007/10/08 MH We support RA smooth scheme now. When it is the first
+ time to link with AP. We will not change upper/lower threshold. If
+ STA stay in high or low level, we must change two different threshold
+ to prevent jumping frequently. */
+ if (pra->ratr_state == DM_RATR_STA_HIGH)
+ {
+ HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra;
+ LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
+ (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M);
+ }
+ else if (pra->ratr_state == DM_RATR_STA_LOW)
+ {
+ HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+ LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
+ (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M);
+ }
+ else
+ {
+ HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+ LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
+ (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M);
+ }
+
+ //DbgPrint("[DM] THresh H/L=%d/%d\n\r", RATR.HighRSSIThreshForRA, RATR.LowRSSIThreshForRA);
+ if(priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA)
+ {
+ //DbgPrint("[DM] RSSI=%d STA=HIGH\n\r", pHalData->UndecoratedSmoothedPWDB);
+ pra->ratr_state = DM_RATR_STA_HIGH;
+ targetRATR = pra->upper_rssi_threshold_ratr;
+ }else if(priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA)
+ {
+ //DbgPrint("[DM] RSSI=%d STA=Middle\n\r", pHalData->UndecoratedSmoothedPWDB);
+ pra->ratr_state = DM_RATR_STA_MIDDLE;
+ targetRATR = pra->middle_rssi_threshold_ratr;
+ }else
+ {
+ //DbgPrint("[DM] RSSI=%d STA=LOW\n\r", pHalData->UndecoratedSmoothedPWDB);
+ pra->ratr_state = DM_RATR_STA_LOW;
+ targetRATR = pra->low_rssi_threshold_ratr;
+ }
+
+ //cosa add for test
+ if(pra->ping_rssi_enable)
+ {
+ //pHalData->UndecoratedSmoothedPWDB = 19;
+ if(priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5))
+ {
+ if( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) ||
+ ping_rssi_state )
+ {
+ //DbgPrint("TestRSSI = %d, set RATR to 0x%x \n", pHalData->UndecoratedSmoothedPWDB, pRA->TestRSSIRATR);
+ pra->ratr_state = DM_RATR_STA_LOW;
+ targetRATR = pra->ping_rssi_ratr;
+ ping_rssi_state = 1;
+ }
+ //else
+ // DbgPrint("TestRSSI is between the range. \n");
+ }
+ else
+ {
+ //DbgPrint("TestRSSI Recover to 0x%x \n", targetRATR);
+ ping_rssi_state = 0;
+ }
+ }
+
+ // 2008.04.01
+#if 1
+ // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
+ if(priv->ieee80211->GetHalfNmodeSupportByAPsHandler(dev))
+ targetRATR &= 0xf00fffff;
+#endif
+
+ //
+ // Check whether updating of RATR0 is required
+ //
+ currentRATR = read_nic_dword(dev, RATR0);
+ if( targetRATR != currentRATR )
+ {
+ u32 ratr_value;
+ ratr_value = targetRATR;
+ RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR);
+ if(priv->rf_type == RF_1T2R)
+ {
+ ratr_value &= ~(RATE_ALL_OFDM_2SS);
+ }
+ write_nic_dword(dev, RATR0, ratr_value);
+ write_nic_byte(dev, UFWP, 1);
+
+ pra->last_ratr = targetRATR;
+ }
+
+ }
+ else
+ {
+ pra->ratr_state = DM_RATR_STA_MAX;
+ }
+
+} // dm_CheckRateAdaptive
+
+
+static void dm_init_bandwidth_autoswitch(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH;
+ priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW;
+ priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false;
+ priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable = false;
+
+} // dm_init_bandwidth_autoswitch
+
+
+static void dm_bandwidth_autoswitch(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable){
+ return;
+ }else{
+ if(priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz == false){//If send packets in 40 Mhz in 20/40
+ if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
+ priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = true;
+ }else{//in force send packets in 20 Mhz in 20/40
+ if(priv->undecorated_smoothed_pwdb >= priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz)
+ priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false;
+
+ }
+ }
+} // dm_BandwidthAutoSwitch
+
+//OFDM default at 0db, index=6.
+static u32 OFDMSwingTable[OFDM_Table_Length] = {
+ 0x7f8001fe, // 0, +6db
+ 0x71c001c7, // 1, +5db
+ 0x65400195, // 2, +4db
+ 0x5a400169, // 3, +3db
+ 0x50800142, // 4, +2db
+ 0x47c0011f, // 5, +1db
+ 0x40000100, // 6, +0db ===> default, upper for higher temprature, lower for low temprature
+ 0x390000e4, // 7, -1db
+ 0x32c000cb, // 8, -2db
+ 0x2d4000b5, // 9, -3db
+ 0x288000a2, // 10, -4db
+ 0x24000090, // 11, -5db
+ 0x20000080, // 12, -6db
+ 0x1c800072, // 13, -7db
+ 0x19800066, // 14, -8db
+ 0x26c0005b, // 15, -9db
+ 0x24400051, // 16, -10db
+ 0x12000048, // 17, -11db
+ 0x10000040 // 18, -12db
+};
+
+static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = {
+ {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, // 0, +0db ===> CCK40M default
+ {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 1, -1db
+ {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 2, -2db
+ {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 3, -3db
+ {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 4, -4db
+ {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 5, -5db
+ {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 6, -6db ===> CCK20M default
+ {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 7, -7db
+ {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 8, -8db
+ {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 9, -9db
+ {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 10, -10db
+ {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} // 11, -11db
+};
+
+static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = {
+ {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, // 0, +0db ===> CCK40M default
+ {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 1, -1db
+ {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 2, -2db
+ {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 3, -3db
+ {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 4, -4db
+ {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 5, -5db
+ {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 6, -6db ===> CCK20M default
+ {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 7, -7db
+ {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 8, -8db
+ {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 9, -9db
+ {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 10, -10db
+ {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} // 11, -11db
+};
+
+static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool bHighpowerstate, viviflag = FALSE;
+ DCMD_TXCMD_T tx_cmd;
+ u8 powerlevelOFDM24G;
+ int i =0, j = 0, k = 0;
+ u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0};
+ u32 Value;
+ u8 Pwr_Flag;
+ u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0;
+ //RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+#ifdef RTL8192U
+ bool rtStatus = true;
+#endif
+ u32 delta=0;
+
+ write_nic_byte(dev, 0x1ba, 0);
+
+ priv->ieee80211->bdynamic_txpower_enable = false;
+ bHighpowerstate = priv->bDynamicTxHighPower;
+
+ powerlevelOFDM24G = (u8)(priv->Pwr_Track>>24);
+ RF_Type = priv->rf_type;
+ Value = (RF_Type<<8) | powerlevelOFDM24G;
+
+ RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G);
+
+ for(j = 0; j<=30; j++)
+{ //fill tx_cmd
+
+ tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING;
+ tx_cmd.Length = 4;
+ tx_cmd.Value = Value;
+#ifdef RTL8192U
+ rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12);
+ if (rtStatus == false)
+ {
+ RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n");
+ }
+#else
+ cmpk_message_handle_tx(dev, (u8*)&tx_cmd,
+ DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T));
+#endif
+ mdelay(1);
+ //DbgPrint("hi, vivi, strange\n");
+ for(i = 0;i <= 30; i++)
+ {
+ Pwr_Flag = read_nic_byte(dev, 0x1ba);
+
+ if (Pwr_Flag == 0)
+ {
+ mdelay(1);
+ continue;
+ }
+#ifdef RTL8190P
+ Avg_TSSI_Meas = read_nic_word(dev, 0x1bc);
+#else
+ Avg_TSSI_Meas = read_nic_word(dev, 0x13c);
+#endif
+ if(Avg_TSSI_Meas == 0)
+ {
+ write_nic_byte(dev, 0x1ba, 0);
+ break;
+ }
+
+ for(k = 0;k < 5; k++)
+ {
+#ifdef RTL8190P
+ tmp_report[k] = read_nic_byte(dev, 0x1d8+k);
+#else
+ if(k !=4)
+ tmp_report[k] = read_nic_byte(dev, 0x134+k);
+ else
+ tmp_report[k] = read_nic_byte(dev, 0x13e);
+#endif
+ RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]);
+ }
+
+ //check if the report value is right
+ for(k = 0;k < 5; k++)
+ {
+ if(tmp_report[k] <= 20)
+ {
+ viviflag =TRUE;
+ break;
+ }
+ }
+ if(viviflag ==TRUE)
+ {
+ write_nic_byte(dev, 0x1ba, 0);
+ viviflag = FALSE;
+ RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n");
+ for(k = 0;k < 5; k++)
+ tmp_report[k] = 0;
+ break;
+ }
+
+ for(k = 0;k < 5; k++)
+ {
+ Avg_TSSI_Meas_from_driver += tmp_report[k];
+ }
+
+ Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5;
+ RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver);
+ TSSI_13dBm = priv->TSSI_13dBm;
+ RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm);
+
+ //if(abs(Avg_TSSI_Meas_from_driver - TSSI_13dBm) <= E_FOR_TX_POWER_TRACK)
+ // For MacOS-compatible
+ if(Avg_TSSI_Meas_from_driver > TSSI_13dBm)
+ delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm;
+ else
+ delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver;
+
+ if(delta <= E_FOR_TX_POWER_TRACK)
+ {
+ priv->ieee80211->bdynamic_txpower_enable = TRUE;
+ write_nic_byte(dev, 0x1ba, 0);
+ RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n");
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real);
+#ifdef RTL8190P
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex);
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real);
+#endif
+ RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation_difference = %d\n", priv->cck_present_attentuation_difference);
+ RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation = %d\n", priv->cck_present_attentuation);
+ return;
+ }
+ else
+ {
+ if(Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK)
+ {
+ if((priv->rfa_txpowertrackingindex > 0)
+#ifdef RTL8190P
+ &&(priv->rfc_txpowertrackingindex > 0)
+#endif
+ )
+ {
+ priv->rfa_txpowertrackingindex--;
+ if(priv->rfa_txpowertrackingindex_real > 4)
+ {
+ priv->rfa_txpowertrackingindex_real--;
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
+ }
+#ifdef RTL8190P
+ priv->rfc_txpowertrackingindex--;
+ if(priv->rfc_txpowertrackingindex_real > 4)
+ {
+ priv->rfc_txpowertrackingindex_real--;
+ rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
+ }
+#endif
+ }
+ }
+ else
+ {
+ if((priv->rfa_txpowertrackingindex < 36)
+#ifdef RTL8190P
+ &&(priv->rfc_txpowertrackingindex < 36)
+#endif
+ )
+ {
+ priv->rfa_txpowertrackingindex++;
+ priv->rfa_txpowertrackingindex_real++;
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
+
+#ifdef RTL8190P
+ priv->rfc_txpowertrackingindex++;
+ priv->rfc_txpowertrackingindex_real++;
+ rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
+#endif
+ }
+ }
+ priv->cck_present_attentuation_difference
+ = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default;
+
+ if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+ priv->cck_present_attentuation
+ = priv->cck_present_attentuation_20Mdefault + priv->cck_present_attentuation_difference;
+ else
+ priv->cck_present_attentuation
+ = priv->cck_present_attentuation_40Mdefault + priv->cck_present_attentuation_difference;
+
+ if(priv->cck_present_attentuation > -1&&priv->cck_present_attentuation <23)
+ {
+ if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = TRUE;
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = FALSE;
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ else
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real);
+#ifdef RTL8190P
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex);
+ RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real);
+#endif
+ RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation_difference = %d\n", priv->cck_present_attentuation_difference);
+ RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation = %d\n", priv->cck_present_attentuation);
+
+ if (priv->cck_present_attentuation_difference <= -12||priv->cck_present_attentuation_difference >= 24)
+ {
+ priv->ieee80211->bdynamic_txpower_enable = TRUE;
+ write_nic_byte(dev, 0x1ba, 0);
+ RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
+ return;
+ }
+
+
+ }
+ write_nic_byte(dev, 0x1ba, 0);
+ Avg_TSSI_Meas_from_driver = 0;
+ for(k = 0;k < 5; k++)
+ tmp_report[k] = 0;
+ break;
+ }
+}
+ priv->ieee80211->bdynamic_txpower_enable = TRUE;
+ write_nic_byte(dev, 0x1ba, 0);
+}
+
+static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
+{
+#define ThermalMeterVal 9
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 tmpRegA, TempCCk;
+ u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval;
+ int i =0, CCKSwingNeedUpdate=0;
+
+ if(!priv->btxpower_trackingInit)
+ {
+ //Query OFDM default setting
+ tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
+ for(i=0; i<OFDM_Table_Length; i++) //find the index
+ {
+ if(tmpRegA == OFDMSwingTable[i])
+ {
+ priv->OFDM_index= (u8)i;
+ RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n",
+ rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index);
+ }
+ }
+
+ //Query CCK default setting From 0xa22
+ TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2);
+ for(i=0 ; i<CCK_Table_length ; i++)
+ {
+ if(TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0])
+ {
+ priv->CCK_index =(u8) i;
+ RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n",
+ rCCK0_TxFilter1, TempCCk, priv->CCK_index);
+ break;
+ }
+ }
+ priv->btxpower_trackingInit = TRUE;
+ //pHalData->TXPowercount = 0;
+ return;
+ }
+
+ //==========================
+ // this is only for test, should be masked
+#if 0
+{
+ //UINT32 eRFPath;
+ //UINT32 start_rf, end_rf;
+ UINT32 curr_addr;
+ //UINT32 reg_addr;
+ //UINT32 reg_addr_end;
+ UINT32 reg_value;
+ //start_rf = RF90_PATH_A;
+ //end_rf = RF90_PATH_B;//RF90_PATH_MAX;
+ //reg_addr = 0x0;
+ //reg_addr_end = 0x2F;
+
+ for (curr_addr = 0; curr_addr < 0x2d; curr_addr++)
+ {
+ reg_value = PHY_QueryRFReg( Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A,
+ curr_addr, bMaskDWord);
+ }
+
+ pHalData->TXPowercount = 0;
+ return;
+}
+#endif
+ //==========================
+
+ // read and filter out unreasonable value
+ tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078); // 0x12: RF Reg[10:7]
+ RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA);
+ if(tmpRegA < 3 || tmpRegA > 13)
+ return;
+ if(tmpRegA >= 12) // if over 12, TP will be bad when high temprature
+ tmpRegA = 12;
+ RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA);
+ priv->ThermalMeter[0] = ThermalMeterVal; //We use fixed value by Bryant's suggestion
+ priv->ThermalMeter[1] = ThermalMeterVal; //We use fixed value by Bryant's suggestion
+
+ //Get current RF-A temprature index
+ if(priv->ThermalMeter[0] >= (u8)tmpRegA) //lower temprature
+ {
+ tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA);
+ tmpCCK40Mindex = tmpCCK20Mindex - 6;
+ if(tmpOFDMindex >= OFDM_Table_Length)
+ tmpOFDMindex = OFDM_Table_Length-1;
+ if(tmpCCK20Mindex >= CCK_Table_length)
+ tmpCCK20Mindex = CCK_Table_length-1;
+ if(tmpCCK40Mindex >= CCK_Table_length)
+ tmpCCK40Mindex = CCK_Table_length-1;
+ }
+ else
+ {
+ tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]);
+ if(tmpval >= 6) // higher temprature
+ tmpOFDMindex = tmpCCK20Mindex = 0; // max to +6dB
+ else
+ tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval;
+ tmpCCK40Mindex = 0;
+ }
+ //DbgPrint("%ddb, tmpOFDMindex = %d, tmpCCK20Mindex = %d, tmpCCK40Mindex = %d",
+ //((u1Byte)tmpRegA - pHalData->ThermalMeter[0]),
+ //tmpOFDMindex, tmpCCK20Mindex, tmpCCK40Mindex);
+ if(priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) //40M
+ tmpCCKindex = tmpCCK40Mindex;
+ else
+ tmpCCKindex = tmpCCK20Mindex;
+
+ if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = TRUE;
+ CCKSwingNeedUpdate = 1;
+ }
+ else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = FALSE;
+ CCKSwingNeedUpdate = 1;
+ }
+
+ if(priv->CCK_index != tmpCCKindex)
+ {
+ priv->CCK_index = tmpCCKindex;
+ CCKSwingNeedUpdate = 1;
+ }
+
+ if(CCKSwingNeedUpdate)
+ {
+ //DbgPrint("Update CCK Swing, CCK_index = %d\n", pHalData->CCK_index);
+ dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+ }
+ if(priv->OFDM_index != tmpOFDMindex)
+ {
+ priv->OFDM_index = tmpOFDMindex;
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index]);
+ RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n",
+ priv->OFDM_index, OFDMSwingTable[priv->OFDM_index]);
+ }
+ priv->txpower_count = 0;
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_txpower_trackingcallback(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct r8192_priv *priv = container_of(dwork,struct r8192_priv,txpower_tracking_wq);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+extern void dm_txpower_trackingcallback(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+
+#ifdef RTL8190P
+ dm_TXPowerTrackingCallback_TSSI(dev);
+#else
+ if(priv->bDcut == TRUE)
+ dm_TXPowerTrackingCallback_TSSI(dev);
+ else
+ dm_TXPowerTrackingCallback_ThermalMeter(dev);
+#endif
+}
+
+
+static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ //Initial the Tx BB index and mapping value
+ priv->txbbgain_table[0].txbb_iq_amplifygain = 12;
+ priv->txbbgain_table[0].txbbgain_value=0x7f8001fe;
+ priv->txbbgain_table[1].txbb_iq_amplifygain = 11;
+ priv->txbbgain_table[1].txbbgain_value=0x788001e2;
+ priv->txbbgain_table[2].txbb_iq_amplifygain = 10;
+ priv->txbbgain_table[2].txbbgain_value=0x71c001c7;
+ priv->txbbgain_table[3].txbb_iq_amplifygain = 9;
+ priv->txbbgain_table[3].txbbgain_value=0x6b8001ae;
+ priv->txbbgain_table[4].txbb_iq_amplifygain = 8;
+ priv->txbbgain_table[4].txbbgain_value=0x65400195;
+ priv->txbbgain_table[5].txbb_iq_amplifygain = 7;
+ priv->txbbgain_table[5].txbbgain_value=0x5fc0017f;
+ priv->txbbgain_table[6].txbb_iq_amplifygain = 6;
+ priv->txbbgain_table[6].txbbgain_value=0x5a400169;
+ priv->txbbgain_table[7].txbb_iq_amplifygain = 5;
+ priv->txbbgain_table[7].txbbgain_value=0x55400155;
+ priv->txbbgain_table[8].txbb_iq_amplifygain = 4;
+ priv->txbbgain_table[8].txbbgain_value=0x50800142;
+ priv->txbbgain_table[9].txbb_iq_amplifygain = 3;
+ priv->txbbgain_table[9].txbbgain_value=0x4c000130;
+ priv->txbbgain_table[10].txbb_iq_amplifygain = 2;
+ priv->txbbgain_table[10].txbbgain_value=0x47c0011f;
+ priv->txbbgain_table[11].txbb_iq_amplifygain = 1;
+ priv->txbbgain_table[11].txbbgain_value=0x43c0010f;
+ priv->txbbgain_table[12].txbb_iq_amplifygain = 0;
+ priv->txbbgain_table[12].txbbgain_value=0x40000100;
+ priv->txbbgain_table[13].txbb_iq_amplifygain = -1;
+ priv->txbbgain_table[13].txbbgain_value=0x3c8000f2;
+ priv->txbbgain_table[14].txbb_iq_amplifygain = -2;
+ priv->txbbgain_table[14].txbbgain_value=0x390000e4;
+ priv->txbbgain_table[15].txbb_iq_amplifygain = -3;
+ priv->txbbgain_table[15].txbbgain_value=0x35c000d7;
+ priv->txbbgain_table[16].txbb_iq_amplifygain = -4;
+ priv->txbbgain_table[16].txbbgain_value=0x32c000cb;
+ priv->txbbgain_table[17].txbb_iq_amplifygain = -5;
+ priv->txbbgain_table[17].txbbgain_value=0x300000c0;
+ priv->txbbgain_table[18].txbb_iq_amplifygain = -6;
+ priv->txbbgain_table[18].txbbgain_value=0x2d4000b5;
+ priv->txbbgain_table[19].txbb_iq_amplifygain = -7;
+ priv->txbbgain_table[19].txbbgain_value=0x2ac000ab;
+ priv->txbbgain_table[20].txbb_iq_amplifygain = -8;
+ priv->txbbgain_table[20].txbbgain_value=0x288000a2;
+ priv->txbbgain_table[21].txbb_iq_amplifygain = -9;
+ priv->txbbgain_table[21].txbbgain_value=0x26000098;
+ priv->txbbgain_table[22].txbb_iq_amplifygain = -10;
+ priv->txbbgain_table[22].txbbgain_value=0x24000090;
+ priv->txbbgain_table[23].txbb_iq_amplifygain = -11;
+ priv->txbbgain_table[23].txbbgain_value=0x22000088;
+ priv->txbbgain_table[24].txbb_iq_amplifygain = -12;
+ priv->txbbgain_table[24].txbbgain_value=0x20000080;
+ priv->txbbgain_table[25].txbb_iq_amplifygain = -13;
+ priv->txbbgain_table[25].txbbgain_value=0x1a00006c;
+ priv->txbbgain_table[26].txbb_iq_amplifygain = -14;
+ priv->txbbgain_table[26].txbbgain_value=0x1c800072;
+ priv->txbbgain_table[27].txbb_iq_amplifygain = -15;
+ priv->txbbgain_table[27].txbbgain_value=0x18000060;
+ priv->txbbgain_table[28].txbb_iq_amplifygain = -16;
+ priv->txbbgain_table[28].txbbgain_value=0x19800066;
+ priv->txbbgain_table[29].txbb_iq_amplifygain = -17;
+ priv->txbbgain_table[29].txbbgain_value=0x15800056;
+ priv->txbbgain_table[30].txbb_iq_amplifygain = -18;
+ priv->txbbgain_table[30].txbbgain_value=0x26c0005b;
+ priv->txbbgain_table[31].txbb_iq_amplifygain = -19;
+ priv->txbbgain_table[31].txbbgain_value=0x14400051;
+ priv->txbbgain_table[32].txbb_iq_amplifygain = -20;
+ priv->txbbgain_table[32].txbbgain_value=0x24400051;
+ priv->txbbgain_table[33].txbb_iq_amplifygain = -21;
+ priv->txbbgain_table[33].txbbgain_value=0x1300004c;
+ priv->txbbgain_table[34].txbb_iq_amplifygain = -22;
+ priv->txbbgain_table[34].txbbgain_value=0x12000048;
+ priv->txbbgain_table[35].txbb_iq_amplifygain = -23;
+ priv->txbbgain_table[35].txbbgain_value=0x11000044;
+ priv->txbbgain_table[36].txbb_iq_amplifygain = -24;
+ priv->txbbgain_table[36].txbbgain_value=0x10000040;
+
+ //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
+ //This Table is for CH1~CH13
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[2] = 0x2e;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[3] = 0x25;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[4] = 0x1c;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[5] = 0x12;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[6] = 0x09;
+ priv->cck_txbbgain_table[0].ccktxbb_valuearray[7] = 0x04;
+
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[0] = 0x33;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[1] = 0x32;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[2] = 0x2b;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[3] = 0x23;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[4] = 0x1a;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[5] = 0x11;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[6] = 0x08;
+ priv->cck_txbbgain_table[1].ccktxbb_valuearray[7] = 0x04;
+
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[0] = 0x30;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[1] = 0x2f;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[2] = 0x29;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[3] = 0x21;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[4] = 0x19;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[5] = 0x10;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[6] = 0x08;
+ priv->cck_txbbgain_table[2].ccktxbb_valuearray[7] = 0x03;
+
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[0] = 0x2d;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[1] = 0x2d;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[2] = 0x27;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[3] = 0x1f;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[4] = 0x18;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[5] = 0x0f;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[6] = 0x08;
+ priv->cck_txbbgain_table[3].ccktxbb_valuearray[7] = 0x03;
+
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[0] = 0x2b;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[1] = 0x2a;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[2] = 0x25;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[3] = 0x1e;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[4] = 0x16;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[5] = 0x0e;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[6] = 0x07;
+ priv->cck_txbbgain_table[4].ccktxbb_valuearray[7] = 0x03;
+
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[0] = 0x28;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[1] = 0x28;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[2] = 0x22;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[3] = 0x1c;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[4] = 0x15;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[5] = 0x0d;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[6] = 0x07;
+ priv->cck_txbbgain_table[5].ccktxbb_valuearray[7] = 0x03;
+
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[0] = 0x26;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[1] = 0x25;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[2] = 0x21;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[3] = 0x1b;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[4] = 0x14;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[5] = 0x0d;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[6] = 0x06;
+ priv->cck_txbbgain_table[6].ccktxbb_valuearray[7] = 0x03;
+
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[0] = 0x24;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[1] = 0x23;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[2] = 0x1f;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[3] = 0x19;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[4] = 0x13;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[5] = 0x0c;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[6] = 0x06;
+ priv->cck_txbbgain_table[7].ccktxbb_valuearray[7] = 0x03;
+
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[0] = 0x22;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[1] = 0x21;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[2] = 0x1d;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[3] = 0x18;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[4] = 0x11;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[5] = 0x0b;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[6] = 0x06;
+ priv->cck_txbbgain_table[8].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[0] = 0x20;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[1] = 0x20;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[2] = 0x1b;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[3] = 0x16;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[4] = 0x11;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[5] = 0x08;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[6] = 0x05;
+ priv->cck_txbbgain_table[9].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[0] = 0x1f;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[1] = 0x1e;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[2] = 0x1a;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[3] = 0x15;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[4] = 0x10;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[5] = 0x0a;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[6] = 0x05;
+ priv->cck_txbbgain_table[10].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[0] = 0x1d;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[1] = 0x1c;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[2] = 0x18;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[3] = 0x14;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[4] = 0x0f;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[5] = 0x0a;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[6] = 0x05;
+ priv->cck_txbbgain_table[11].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[0] = 0x1b;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[1] = 0x1a;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[2] = 0x17;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[3] = 0x13;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[4] = 0x0e;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[5] = 0x09;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[6] = 0x04;
+ priv->cck_txbbgain_table[12].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[0] = 0x1a;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[1] = 0x19;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[2] = 0x16;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[3] = 0x12;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[4] = 0x0d;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[5] = 0x09;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[6] = 0x04;
+ priv->cck_txbbgain_table[13].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[0] = 0x18;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[1] = 0x17;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[2] = 0x15;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[3] = 0x11;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[4] = 0x0c;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[5] = 0x08;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[6] = 0x04;
+ priv->cck_txbbgain_table[14].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[0] = 0x17;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[1] = 0x16;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[2] = 0x13;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[3] = 0x10;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[4] = 0x0c;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[5] = 0x08;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[6] = 0x04;
+ priv->cck_txbbgain_table[15].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[0] = 0x16;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[1] = 0x15;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[2] = 0x12;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[3] = 0x0f;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[4] = 0x0b;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[5] = 0x07;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[6] = 0x04;
+ priv->cck_txbbgain_table[16].ccktxbb_valuearray[7] = 0x01;
+
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[0] = 0x14;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[1] = 0x14;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[2] = 0x11;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[3] = 0x0e;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[4] = 0x0b;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[5] = 0x07;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[6] = 0x03;
+ priv->cck_txbbgain_table[17].ccktxbb_valuearray[7] = 0x02;
+
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[0] = 0x13;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[1] = 0x13;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[2] = 0x10;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[3] = 0x0d;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[4] = 0x0a;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[5] = 0x06;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[6] = 0x03;
+ priv->cck_txbbgain_table[18].ccktxbb_valuearray[7] = 0x01;
+
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[0] = 0x12;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[1] = 0x12;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[2] = 0x0f;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[3] = 0x0c;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[4] = 0x09;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[5] = 0x06;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[6] = 0x03;
+ priv->cck_txbbgain_table[19].ccktxbb_valuearray[7] = 0x01;
+
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[0] = 0x11;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[1] = 0x11;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[2] = 0x0f;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[3] = 0x0c;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[4] = 0x09;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[5] = 0x06;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[6] = 0x03;
+ priv->cck_txbbgain_table[20].ccktxbb_valuearray[7] = 0x01;
+
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[0] = 0x10;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[1] = 0x10;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[2] = 0x0e;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[3] = 0x0b;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[4] = 0x08;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[5] = 0x05;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[6] = 0x03;
+ priv->cck_txbbgain_table[21].ccktxbb_valuearray[7] = 0x01;
+
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[0] = 0x0f;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[1] = 0x0f;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[2] = 0x0d;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[3] = 0x0b;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[4] = 0x08;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[5] = 0x05;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03;
+ priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01;
+
+ //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
+ //This Table is for CH14
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[1] = 0x35;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[2] = 0x2e;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[3] = 0x1b;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[0] = 0x33;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[1] = 0x32;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[2] = 0x2b;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[3] = 0x19;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[0] = 0x30;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[1] = 0x2f;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[2] = 0x29;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[3] = 0x18;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[0] = 0x2d;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[1] = 0x2d;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[2] = 0x27;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[3] = 0x17;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[0] = 0x2b;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[1] = 0x2a;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[2] = 0x25;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[3] = 0x15;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[0] = 0x28;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[1] = 0x28;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[2] = 0x22;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[3] = 0x14;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[0] = 0x26;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[1] = 0x25;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[2] = 0x21;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[3] = 0x13;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[0] = 0x24;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[1] = 0x23;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[2] = 0x1f;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[3] = 0x12;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[0] = 0x22;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[1] = 0x21;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[2] = 0x1d;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[3] = 0x11;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[0] = 0x20;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[1] = 0x20;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[2] = 0x1b;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[3] = 0x10;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[0] = 0x1f;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[1] = 0x1e;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[2] = 0x1a;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[3] = 0x0f;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[0] = 0x1d;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[1] = 0x1c;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[2] = 0x18;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[3] = 0x0e;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[0] = 0x1b;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[1] = 0x1a;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[2] = 0x17;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[3] = 0x0e;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[0] = 0x1a;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[1] = 0x19;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[2] = 0x16;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[3] = 0x0d;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[0] = 0x18;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[1] = 0x17;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[2] = 0x15;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[3] = 0x0c;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[0] = 0x17;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[1] = 0x16;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[2] = 0x13;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[3] = 0x0b;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[0] = 0x16;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[1] = 0x15;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[2] = 0x12;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[3] = 0x0b;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[0] = 0x14;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[1] = 0x14;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[2] = 0x11;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[3] = 0x0a;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[0] = 0x13;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[1] = 0x13;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[2] = 0x10;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[3] = 0x0a;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[0] = 0x12;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[1] = 0x12;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[2] = 0x0f;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[3] = 0x09;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[0] = 0x11;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[1] = 0x11;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[2] = 0x0f;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[3] = 0x09;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[0] = 0x10;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[1] = 0x10;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[2] = 0x0e;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[3] = 0x08;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[7] = 0x00;
+
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[0] = 0x0f;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[1] = 0x0f;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[2] = 0x0d;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[3] = 0x08;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[4] = 0x00;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[5] = 0x00;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00;
+ priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00;
+
+ priv->btxpower_tracking = TRUE;
+ priv->txpower_count = 0;
+ priv->btxpower_trackingInit = FALSE;
+
+}
+
+#ifndef RTL8192SU
+static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // Tx Power tracking by Theremal Meter require Firmware R/W 3-wire. This mechanism
+ // can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w
+ // 3-wire by driver cause RF goes into wrong state.
+ if(priv->ieee80211->FwRWRF)
+ priv->btxpower_tracking = TRUE;
+ else
+ priv->btxpower_tracking = FALSE;
+ priv->txpower_count = 0;
+ priv->btxpower_trackingInit = FALSE;
+}
+#endif
+
+void dm_initialize_txpower_tracking(struct net_device *dev)
+{
+#if (defined RTL8190P)
+ dm_InitializeTXPowerTracking_TSSI(dev);
+#elif (defined RTL8192SU)
+ // 2009/01/12 MH Enable for 92S series channel 1-14 CCK tx pwer setting for MP.
+ //
+ dm_InitializeTXPowerTracking_TSSI(dev);
+#else
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ if(priv->bDcut == TRUE)
+ dm_InitializeTXPowerTracking_TSSI(dev);
+ else
+ dm_InitializeTXPowerTracking_ThermalMeter(dev);
+#endif
+}// dm_InitializeTXPowerTracking
+
+
+static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ static u32 tx_power_track_counter = 0;
+
+ if(!priv->btxpower_tracking)
+ return;
+ else
+ {
+ if((tx_power_track_counter % 30 == 0)&&(tx_power_track_counter != 0))
+ {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0);
+ #else
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->txpower_tracking_wq);
+ #else
+ queue_work(priv->priv_wq,&priv->txpower_tracking_wq);
+ #endif
+ #endif
+ }
+ tx_power_track_counter++;
+ }
+
+}
+
+
+static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ static u8 TM_Trigger=0;
+#if 0
+ u1Byte i;
+ u4Byte tmpRegA;
+ for(i=0; i<50; i++)
+ {
+ tmpRegA = PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x12, 0x078); // 0x12: RF Reg[10:7]
+ PHY_SetRFReg(Adapter, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
+ //delay_us(100);
+ PHY_SetRFReg(Adapter, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
+ //delay_us(100);
+ }
+ DbgPrint("Trigger and readback ThermalMeter, write RF reg0x2 = 0x4d to 0x4f for 50 times\n");
+#else
+ //DbgPrint("dm_CheckTXPowerTracking() \n");
+ if(!priv->btxpower_tracking)
+ return;
+ else
+ {
+ if(priv->txpower_count <= 2)
+ {
+ priv->txpower_count++;
+ return;
+ }
+ }
+
+ if(!TM_Trigger)
+ {
+ //Attention!! You have to wirte all 12bits data to RF, or it may cause RF to crash
+ //actually write reg0x02 bit1=0, then bit1=1.
+ //DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n");
+#ifdef RTL8192SU
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4d);
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4f);
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4d);
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4f);
+#else
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
+ rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
+#endif
+ TM_Trigger = 1;
+ return;
+ }
+ else
+ {
+ //DbgPrint("Schedule TxPowerTrackingWorkItem\n");
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0);
+ #else
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->txpower_tracking_wq);
+ #else
+ queue_work(priv->priv_wq,&priv->txpower_tracking_wq);
+ #endif
+ #endif
+ TM_Trigger = 0;
+ }
+#endif
+}
+
+
+static void dm_check_txpower_tracking(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //static u32 tx_power_track_counter = 0;
+
+#ifdef RTL8190P
+ dm_CheckTXPowerTracking_TSSI(dev);
+#else
+ if(priv->bDcut == TRUE)
+ dm_CheckTXPowerTracking_TSSI(dev);
+ else
+ dm_CheckTXPowerTracking_ThermalMeter(dev);
+#endif
+
+} // dm_CheckTXPowerTracking
+
+
+static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14)
+{
+ u32 TempVal;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //Write 0xa22 0xa23
+ TempVal = 0;
+ if(!bInCH14){
+ //Write 0xa22 0xa23
+ TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
+ //Write 0xa24 ~ 0xa27
+ TempVal = 0;
+ TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) +
+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16 )+
+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal);
+ //Write 0xa28 0xa29
+ TempVal = 0;
+ TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
+ }
+ else
+ {
+ TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
+ //Write 0xa24 ~ 0xa27
+ TempVal = 0;
+ TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) +
+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16 )+
+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal);
+ //Write 0xa28 0xa29
+ TempVal = 0;
+ TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
+ }
+
+
+}
+
+static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14)
+{
+ u32 TempVal;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ TempVal = 0;
+ if(!bInCH14)
+ {
+ //Write 0xa22 0xa23
+ TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ;
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
+ rCCK0_TxFilter1, TempVal);
+ //Write 0xa24 ~ 0xa27
+ TempVal = 0;
+ TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
+ rCCK0_TxFilter2, TempVal);
+ //Write 0xa28 0xa29
+ TempVal = 0;
+ TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
+ rCCK0_DebugPort, TempVal);
+ }
+ else
+ {
+// priv->CCKTxPowerAdjustCntNotCh14++; //cosa add for debug.
+ //Write 0xa22 0xa23
+ TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] +
+ (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
+ rCCK0_TxFilter1, TempVal);
+ //Write 0xa24 ~ 0xa27
+ TempVal = 0;
+ TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] +
+ (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
+ (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+
+ (CCKSwingTable_Ch14[priv->CCK_index][5]<<24);
+ rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
+ rCCK0_TxFilter2, TempVal);
+ //Write 0xa28 0xa29
+ TempVal = 0;
+ TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] +
+ (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
+
+ rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n",
+ rCCK0_DebugPort, TempVal);
+ }
+}
+
+
+
+extern void dm_cck_txpower_adjust(
+ struct net_device *dev,
+ bool binch14
+)
+{ // dm_CCKTxPowerAdjust
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#ifdef RTL8190P
+ dm_CCKTxPowerAdjust_TSSI(dev, binch14);
+#else
+ if(priv->bDcut == TRUE)
+ dm_CCKTxPowerAdjust_TSSI(dev, binch14);
+ else
+ dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14);
+#endif
+}
+
+
+#ifndef RTL8192U
+static void dm_txpower_reset_recovery(
+ struct net_device *dev
+)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n");
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->cck_present_attentuation);
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+
+ rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex);
+ RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain);
+
+} // dm_TXPowerResetRecovery
+
+extern void dm_restore_dynamic_mechanism_state(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 reg_ratr = priv->rate_adaptive.last_ratr;
+
+ if(!priv->up)
+ {
+ RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
+ return;
+ }
+
+ //
+ // Restore previous state for rate adaptive
+ //
+ if(priv->rate_adaptive.rate_adaptive_disabled)
+ return;
+ // TODO: Only 11n mode is implemented currently,
+ if( !(priv->ieee80211->mode==WIRELESS_MODE_N_24G ||
+ priv->ieee80211->mode==WIRELESS_MODE_N_5G))
+ return;
+ {
+ /* 2007/11/15 MH Copy from 8190PCI. */
+ u32 ratr_value;
+ ratr_value = reg_ratr;
+ if(priv->rf_type == RF_1T2R) // 1T2R, Spatial Stream 2 should be disabled
+ {
+ ratr_value &=~ (RATE_ALL_OFDM_2SS);
+ //DbgPrint("HW_VAR_TATR_0 from 0x%x ==> 0x%x\n", ((pu4Byte)(val))[0], ratr_value);
+ }
+ //DbgPrint("set HW_VAR_TATR_0 = 0x%x\n", ratr_value);
+ //cosa PlatformEFIOWrite4Byte(Adapter, RATR0, ((pu4Byte)(val))[0]);
+ write_nic_dword(dev, RATR0, ratr_value);
+ write_nic_byte(dev, UFWP, 1);
+#if 0 // Disable old code.
+ u1Byte index;
+ u4Byte input_value;
+ index = (u1Byte)((((pu4Byte)(val))[0]) >> 28);
+ input_value = (((pu4Byte)(val))[0]) & 0x0fffffff;
+ // TODO: Correct it. Emily 2007.01.11
+ PlatformEFIOWrite4Byte(Adapter, RATR0+index*4, input_value);
+#endif
+ }
+ //Resore TX Power Tracking Index
+ if(priv->btxpower_trackingInit && priv->btxpower_tracking){
+ dm_txpower_reset_recovery(dev);
+ }
+
+ //
+ //Restore BB Initial Gain
+ //
+ dm_bb_initialgain_restore(dev);
+
+} // DM_RestoreDynamicMechanismState
+
+static void dm_bb_initialgain_restore(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 bit_mask = 0x7f; //Bit0~ Bit6
+
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
+ return;
+
+ //Disable Initial Gain
+ //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1);
+ bit_mask = bMaskByte2;
+ rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca);
+
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca);
+ //Enable Initial Gain
+ //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x100);
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite.
+
+} // dm_BBInitialGainRestore
+
+
+extern void dm_backup_dynamic_mechanism_state(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // Fsync to avoid reset
+ priv->bswitch_fsync = false;
+ priv->bfsync_processing = false;
+ //Backup BB InitialGain
+ dm_bb_initialgain_backup(dev);
+
+} // DM_BackupDynamicMechanismState
+
+
+static void dm_bb_initialgain_backup(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 bit_mask = bMaskByte0; //Bit0~ Bit6
+
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
+ return;
+
+ //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
+ priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bit_mask);
+ priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bit_mask);
+ priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bit_mask);
+ priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bit_mask);
+ bit_mask = bMaskByte2;
+ priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask);
+
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca);
+
+} // dm_BBInitialGainBakcup
+
+#endif
+/*-----------------------------------------------------------------------------
+ * Function: dm_change_dynamic_initgain_thresh()
+ *
+ * Overview:
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/29/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
+ u32 dm_type,
+ u32 dm_value)
+{
+#ifdef RTL8192SU
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ if(dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
+ priv->MidHighPwrTHR_L2 = (u8)dm_value;
+ else if(dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW)
+ priv->MidHighPwrTHR_L1 = (u8)dm_value;
+ return;
+#endif
+ if (dm_type == DIG_TYPE_THRESH_HIGH)
+ {
+ dm_digtable.rssi_high_thresh = dm_value;
+ }
+ else if (dm_type == DIG_TYPE_THRESH_LOW)
+ {
+ dm_digtable.rssi_low_thresh = dm_value;
+ }
+ else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
+ {
+ dm_digtable.rssi_high_power_highthresh = dm_value;
+ }
+ else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
+ {
+ dm_digtable.rssi_high_power_highthresh = dm_value;
+ }
+ else if (dm_type == DIG_TYPE_ENABLE)
+ {
+ dm_digtable.dig_state = DM_STA_DIG_MAX;
+ dm_digtable.dig_enable_flag = true;
+ }
+ else if (dm_type == DIG_TYPE_DISABLE)
+ {
+ dm_digtable.dig_state = DM_STA_DIG_MAX;
+ dm_digtable.dig_enable_flag = false;
+ }
+ else if (dm_type == DIG_TYPE_DBG_MODE)
+ {
+ if(dm_value >= DM_DBG_MAX)
+ dm_value = DM_DBG_OFF;
+ dm_digtable.dbg_mode = (u8)dm_value;
+ }
+ else if (dm_type == DIG_TYPE_RSSI)
+ {
+ if(dm_value > 100)
+ dm_value = 30;
+ dm_digtable.rssi_val = (long)dm_value;
+ }
+ else if (dm_type == DIG_TYPE_ALGORITHM)
+ {
+ if (dm_value >= DIG_ALGO_MAX)
+ dm_value = DIG_ALGO_BY_FALSE_ALARM;
+ if(dm_digtable.dig_algorithm != (u8)dm_value)
+ dm_digtable.dig_algorithm_switch = 1;
+ dm_digtable.dig_algorithm = (u8)dm_value;
+ }
+ else if (dm_type == DIG_TYPE_BACKOFF)
+ {
+ if(dm_value > 30)
+ dm_value = 30;
+ dm_digtable.backoff_val = (u8)dm_value;
+ }
+ else if(dm_type == DIG_TYPE_RX_GAIN_MIN)
+ {
+ if(dm_value == 0)
+ dm_value = 0x1;
+ dm_digtable.rx_gain_range_min = (u8)dm_value;
+ }
+ else if(dm_type == DIG_TYPE_RX_GAIN_MAX)
+ {
+ if(dm_value > 0x50)
+ dm_value = 0x50;
+ dm_digtable.rx_gain_range_max = (u8)dm_value;
+ }
+} /* DM_ChangeDynamicInitGainThresh */
+extern void
+dm_change_fsync_setting(
+ struct net_device *dev,
+ s32 DM_Type,
+ s32 DM_Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if (DM_Type == 0) // monitor 0xc38 register
+ {
+ if(DM_Value > 1)
+ DM_Value = 1;
+ priv->framesyncMonitor = (u8)DM_Value;
+ //DbgPrint("pHalData->framesyncMonitor = %d", pHalData->framesyncMonitor);
+ }
+}
+
+extern void
+dm_change_rxpath_selection_setting(
+ struct net_device *dev,
+ s32 DM_Type,
+ s32 DM_Value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive);
+
+
+ if(DM_Type == 0)
+ {
+ if(DM_Value > 1)
+ DM_Value = 1;
+ DM_RxPathSelTable.Enable = (u8)DM_Value;
+ }
+ else if(DM_Type == 1)
+ {
+ if(DM_Value > 1)
+ DM_Value = 1;
+ DM_RxPathSelTable.DbgMode = (u8)DM_Value;
+ }
+ else if(DM_Type == 2)
+ {
+ if(DM_Value > 40)
+ DM_Value = 40;
+ DM_RxPathSelTable.SS_TH_low = (u8)DM_Value;
+ }
+ else if(DM_Type == 3)
+ {
+ if(DM_Value > 25)
+ DM_Value = 25;
+ DM_RxPathSelTable.diff_TH = (u8)DM_Value;
+ }
+ else if(DM_Type == 4)
+ {
+ if(DM_Value >= CCK_Rx_Version_MAX)
+ DM_Value = CCK_Rx_Version_1;
+ DM_RxPathSelTable.cck_method= (u8)DM_Value;
+ }
+ else if(DM_Type == 10)
+ {
+ if(DM_Value > 100)
+ DM_Value = 50;
+ DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value;
+ }
+ else if(DM_Type == 11)
+ {
+ if(DM_Value > 100)
+ DM_Value = 50;
+ DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value;
+ }
+ else if(DM_Type == 12)
+ {
+ if(DM_Value > 100)
+ DM_Value = 50;
+ DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value;
+ }
+ else if(DM_Type == 13)
+ {
+ if(DM_Value > 100)
+ DM_Value = 50;
+ DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value;
+ }
+ else if(DM_Type == 20)
+ {
+ if(DM_Value > 1)
+ DM_Value = 1;
+ pRA->ping_rssi_enable = (u8)DM_Value;
+ }
+ else if(DM_Type == 21)
+ {
+ if(DM_Value > 30)
+ DM_Value = 30;
+ pRA->ping_rssi_thresh_for_ra = DM_Value;
+ }
+}
+
+#if 0
+extern void dm_force_tx_fw_info(struct net_device *dev,
+ u32 force_type,
+ u32 force_value)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if (force_type == 0) // don't force TxSC
+ {
+ //DbgPrint("Set Force SubCarrier Off\n");
+ priv->tx_fwinfo_force_subcarriermode = 0;
+ }
+ else if(force_type == 1) //force
+ {
+ //DbgPrint("Set Force SubCarrier On\n");
+ priv->tx_fwinfo_force_subcarriermode = 1;
+ if(force_value > 3)
+ force_value = 3;
+ priv->tx_fwinfo_force_subcarrierval = (u8)force_value;
+ }
+}
+#endif
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_dig_init()
+ *
+ * Overview: Set DIG scheme init value.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/15/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void dm_dig_init(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ /* 2007/10/05 MH Disable DIG scheme now. Not tested. */
+ dm_digtable.dig_enable_flag = true;
+ dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI;
+ dm_digtable.dbg_mode = DM_DBG_OFF; //off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig
+ dm_digtable.dig_algorithm_switch = 0;
+
+ /* 2007/10/04 MH Define init gain threshol. */
+ dm_digtable.dig_state = DM_STA_DIG_MAX;
+ dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
+ dm_digtable.initialgain_lowerbound_state = false;
+
+ dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW;
+ dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH;
+
+ dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW;
+ dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH;
+
+ dm_digtable.rssi_val = 50; //for new dig debug rssi value
+ dm_digtable.backoff_val = DM_DIG_BACKOFF;
+ dm_digtable.rx_gain_range_max = DM_DIG_MAX;
+ if(priv->CustomerID == RT_CID_819x_Netcore)
+ dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore;
+ else
+ dm_digtable.rx_gain_range_min = DM_DIG_MIN;
+
+} /* dm_dig_init */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_ctrl_initgain_byrssi()
+ *
+ * Overview: Driver must monitor RSSI and notify firmware to change initial
+ * gain according to different threshold. BB team provide the
+ * suggested solution.
+ *
+ * Input: struct net_device *dev
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/27/2008 amy Create Version 0 porting from windows code.
+ *---------------------------------------------------------------------------*/
+static void dm_ctrl_initgain_byrssi(struct net_device *dev)
+{
+
+ if (dm_digtable.dig_enable_flag == false)
+ return;
+
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev);
+ else if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
+ dm_ctrl_initgain_byrssi_by_driverrssi(dev);
+// ;
+ else
+ return;
+}
+
+
+static void dm_ctrl_initgain_byrssi_by_driverrssi(
+ struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 i;
+ static u8 fw_dig=0;
+
+ if (dm_digtable.dig_enable_flag == false)
+ return;
+
+ //DbgPrint("Dig by Sw Rssi \n");
+ if(dm_digtable.dig_algorithm_switch) // if swithed algorithm, we have to disable FW Dig.
+ fw_dig = 0;
+ if(fw_dig <= 3) // execute several times to make sure the FW Dig is disabled
+ {// FW DIG Off
+ for(i=0; i<3; i++)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
+ fw_dig++;
+ dm_digtable.dig_state = DM_STA_DIG_OFF; //fw dig off.
+ }
+
+ if(priv->ieee80211->state == IEEE80211_LINKED)
+ dm_digtable.cur_connect_state = DIG_CONNECT;
+ else
+ dm_digtable.cur_connect_state = DIG_DISCONNECT;
+
+ //DbgPrint("DM_DigTable.PreConnectState = %d, DM_DigTable.CurConnectState = %d \n",
+ //DM_DigTable.PreConnectState, DM_DigTable.CurConnectState);
+
+ if(dm_digtable.dbg_mode == DM_DBG_OFF)
+ dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb;
+ //DbgPrint("DM_DigTable.Rssi_val = %d \n", DM_DigTable.Rssi_val);
+ dm_initial_gain(dev);
+ dm_pd_th(dev);
+ dm_cs_ratio(dev);
+ if(dm_digtable.dig_algorithm_switch)
+ dm_digtable.dig_algorithm_switch = 0;
+ dm_digtable.pre_connect_state = dm_digtable.cur_connect_state;
+
+} /* dm_CtrlInitGainByRssi */
+
+static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
+ struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ static u32 reset_cnt = 0;
+ u8 i;
+
+ if (dm_digtable.dig_enable_flag == false)
+ return;
+
+ if(dm_digtable.dig_algorithm_switch)
+ {
+ dm_digtable.dig_state = DM_STA_DIG_MAX;
+ // Fw DIG On.
+ for(i=0; i<3; i++)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite.
+ dm_digtable.dig_algorithm_switch = 0;
+ }
+
+ if (priv->ieee80211->state != IEEE80211_LINKED)
+ return;
+
+ // For smooth, we can not change DIG state.
+ if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) &&
+ (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh))
+ {
+ return;
+ }
+ //DbgPrint("Dig by Fw False Alarm\n");
+ //if (DM_DigTable.Dig_State == DM_STA_DIG_OFF)
+ /*DbgPrint("DIG Check\n\r RSSI=%d LOW=%d HIGH=%d STATE=%d",
+ pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh,
+ DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/
+ /* 1. When RSSI decrease, We have to judge if it is smaller than a treshold
+ and then execute below step. */
+ if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh))
+ {
+ /* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters
+ will be reset to init value. We must prevent the condition. */
+ if (dm_digtable.dig_state == DM_STA_DIG_OFF &&
+ (priv->reset_count == reset_cnt))
+ {
+ return;
+ }
+ else
+ {
+ reset_cnt = priv->reset_count;
+ }
+
+ // If DIG is off, DIG high power state must reset.
+ dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
+ dm_digtable.dig_state = DM_STA_DIG_OFF;
+
+ // 1.1 DIG Off.
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
+
+ // 1.2 Set initial gain.
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x17);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x17);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x17);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17);
+
+ // 1.3 Lower PD_TH for OFDM.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
+ // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
+#ifdef RTL8192SU
+ rtl8192_setBBreg(dev, (rOFDM0_XATxAFE+3), bMaskByte0, 0x00);
+#else
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00);
+ #endif
+#endif
+ /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40);
+ */
+ //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
+
+
+ //else
+ //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x40);
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+
+ // 1.4 Lower CS ratio for CCK.
+ write_nic_byte(dev, 0xa0a, 0x08);
+
+ // 1.5 Higher EDCCA.
+ //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x325);
+ return;
+
+ }
+
+ /* 2. When RSSI increase, We have to judge if it is larger than a treshold
+ and then execute below step. */
+ if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) )
+ {
+ u8 reset_flag = 0;
+
+ if (dm_digtable.dig_state == DM_STA_DIG_ON &&
+ (priv->reset_count == reset_cnt))
+ {
+ dm_ctrl_initgain_byrssi_highpwr(dev);
+ return;
+ }
+ else
+ {
+ if (priv->reset_count != reset_cnt)
+ reset_flag = 1;
+
+ reset_cnt = priv->reset_count;
+ }
+
+ dm_digtable.dig_state = DM_STA_DIG_ON;
+ //DbgPrint("DIG ON\n\r");
+
+ // 2.1 Set initial gain.
+ // 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment.
+ if (reset_flag == 1)
+ {
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c);
+ }
+ else
+ {
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20);
+ }
+
+ // 2.2 Higher PD_TH for OFDM.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
+ // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
+ #endif
+ /*
+ else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ */
+ //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
+
+ //else
+ //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x42);
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
+
+ // 2.3 Higher CS ratio for CCK.
+ write_nic_byte(dev, 0xa0a, 0xcd);
+
+ // 2.4 Lower EDCCA.
+ /* 2008/01/11 MH 90/92 series are the same. */
+ //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346);
+
+ // 2.5 DIG On.
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite.
+
+ }
+
+ dm_ctrl_initgain_byrssi_highpwr(dev);
+
+} /* dm_CtrlInitGainByRssi */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_ctrl_initgain_byrssi_highpwr()
+ *
+ * Overview:
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/28/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void dm_ctrl_initgain_byrssi_highpwr(
+ struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ static u32 reset_cnt_highpwr = 0;
+
+ // For smooth, we can not change high power DIG state in the range.
+ if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) &&
+ (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh))
+ {
+ return;
+ }
+
+ /* 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if
+ it is larger than a treshold and then execute below step. */
+ // 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue.
+ if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh)
+ {
+ if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON &&
+ (priv->reset_count == reset_cnt_highpwr))
+ return;
+ else
+ dm_digtable.dig_highpwr_state = DM_STA_DIG_ON;
+
+ // 3.1 Higher PD_TH for OFDM for high power state.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+#ifdef RTL8192SU
+ rtl8192_setBBreg(dev, (rOFDM0_XATxAFE+3), bMaskByte0, 0x10);
+#else
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10);
+ #endif
+#endif
+ /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
+ */
+
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x43);
+ }
+ else
+ {
+ if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&&
+ (priv->reset_count == reset_cnt_highpwr))
+ return;
+ else
+ dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF;
+
+ if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh &&
+ priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)
+ {
+ // 3.2 Recover PD_TH for OFDM for normal power region.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
+ #endif
+ /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ */
+
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
+ }
+ }
+
+ reset_cnt_highpwr = priv->reset_count;
+
+} /* dm_CtrlInitGainByRssiHighPwr */
+
+
+static void dm_initial_gain(
+ struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 initial_gain=0;
+ static u8 initialized=0, force_write=0;
+ static u32 reset_cnt=0;
+
+ if(dm_digtable.dig_algorithm_switch)
+ {
+ initialized = 0;
+ reset_cnt = 0;
+ }
+
+ if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state)
+ {
+ if(dm_digtable.cur_connect_state == DIG_CONNECT)
+ {
+ if((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max)
+ dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max;
+ else if((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min)
+ dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min;
+ else
+ dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val;
+ }
+ else //current state is disconnected
+ {
+ if(dm_digtable.cur_ig_value == 0)
+ dm_digtable.cur_ig_value = priv->DefaultInitialGain[0];
+ else
+ dm_digtable.cur_ig_value = dm_digtable.pre_ig_value;
+ }
+ }
+ else // disconnected -> connected or connected -> disconnected
+ {
+ dm_digtable.cur_ig_value = priv->DefaultInitialGain[0];
+ dm_digtable.pre_ig_value = 0;
+ }
+ //DbgPrint("DM_DigTable.CurIGValue = 0x%x, DM_DigTable.PreIGValue = 0x%x\n", DM_DigTable.CurIGValue, DM_DigTable.PreIGValue);
+
+ // if silent reset happened, we should rewrite the values back
+ if(priv->reset_count != reset_cnt)
+ {
+ force_write = 1;
+ reset_cnt = priv->reset_count;
+ }
+
+ if(dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1))
+ force_write = 1;
+
+ {
+ if((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value)
+ || !initialized || force_write)
+ {
+ initial_gain = (u8)dm_digtable.cur_ig_value;
+ //DbgPrint("Write initial gain = 0x%x\n", initial_gain);
+ // Set initial gain.
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
+ dm_digtable.pre_ig_value = dm_digtable.cur_ig_value;
+ initialized = 1;
+ force_write = 0;
+ }
+ }
+}
+
+static void dm_pd_th(
+ struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ static u8 initialized=0, force_write=0;
+ static u32 reset_cnt = 0;
+
+ if(dm_digtable.dig_algorithm_switch)
+ {
+ initialized = 0;
+ reset_cnt = 0;
+ }
+
+ if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state)
+ {
+ if(dm_digtable.cur_connect_state == DIG_CONNECT)
+ {
+ if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh)
+ dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER;
+ else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh))
+ dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
+ else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) &&
+ (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh))
+ dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER;
+ else
+ dm_digtable.curpd_thstate = dm_digtable.prepd_thstate;
+ }
+ else
+ {
+ dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
+ }
+ }
+ else // disconnected -> connected or connected -> disconnected
+ {
+ dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
+ }
+
+ // if silent reset happened, we should rewrite the values back
+ if(priv->reset_count != reset_cnt)
+ {
+ force_write = 1;
+ reset_cnt = priv->reset_count;
+ }
+
+ {
+ if((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) ||
+ (initialized<=3) || force_write)
+ {
+ //DbgPrint("Write PD_TH state = %d\n", DM_DigTable.CurPD_THState);
+ if(dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER)
+ {
+ // Lower PD_TH for OFDM.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
+ // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
+#ifdef RTL8192SU
+ rtl8192_setBBreg(dev, (rOFDM0_XATxAFE+3), bMaskByte0, 0x00);
+#else
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00);
+ #endif
+#endif
+ /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
+ */
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ }
+ else if(dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER)
+ {
+ // Higher PD_TH for OFDM.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
+ // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
+ #endif
+ /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
+ */
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
+ }
+ else if(dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER)
+ {
+ // Higher PD_TH for OFDM for high power state.
+ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+ {
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
+ #else
+ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10);
+ #endif
+ /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
+ */
+ }
+ else
+ write_nic_byte(dev, rOFDM0_RxDetector1, 0x43);
+ }
+ dm_digtable.prepd_thstate = dm_digtable.curpd_thstate;
+ if(initialized <= 3)
+ initialized++;
+ force_write = 0;
+ }
+ }
+}
+
+static void dm_cs_ratio(
+ struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ static u8 initialized=0,force_write=0;
+ static u32 reset_cnt = 0;
+
+ if(dm_digtable.dig_algorithm_switch)
+ {
+ initialized = 0;
+ reset_cnt = 0;
+ }
+
+ if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state)
+ {
+ if(dm_digtable.cur_connect_state == DIG_CONNECT)
+ {
+ if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh))
+ dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
+ else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) )
+ dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER;
+ else
+ dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state;
+ }
+ else
+ {
+ dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
+ }
+ }
+ else // disconnected -> connected or connected -> disconnected
+ {
+ dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
+ }
+
+ // if silent reset happened, we should rewrite the values back
+ if(priv->reset_count != reset_cnt)
+ {
+ force_write = 1;
+ reset_cnt = priv->reset_count;
+ }
+
+
+ {
+ if((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) ||
+ !initialized || force_write)
+ {
+ //DbgPrint("Write CS_ratio state = %d\n", DM_DigTable.CurCS_ratioState);
+ if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER)
+ {
+ // Lower CS ratio for CCK.
+ write_nic_byte(dev, 0xa0a, 0x08);
+ }
+ else if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER)
+ {
+ // Higher CS ratio for CCK.
+ write_nic_byte(dev, 0xa0a, 0xcd);
+ }
+ dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state;
+ initialized = 1;
+ force_write = 0;
+ }
+ }
+}
+
+extern void dm_init_edca_turbo(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->bcurrent_turbo_EDCA = false;
+ priv->ieee80211->bis_any_nonbepkts = false;
+ priv->bis_cur_rdlstate = false;
+} // dm_init_edca_turbo
+
+#if 1
+static void dm_check_edca_turbo(
+ struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ //PSTA_QOS pStaQos = pMgntInfo->pStaQos;
+
+ // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo.
+ static unsigned long lastTxOkCnt = 0;
+ static unsigned long lastRxOkCnt = 0;
+ unsigned long curTxOkCnt = 0;
+ unsigned long curRxOkCnt = 0;
+
+ //
+ // Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters
+ // should follow the settings from QAP. By Bruce, 2007-12-07.
+ //
+ #if 1
+ if(priv->ieee80211->state != IEEE80211_LINKED)
+ goto dm_CheckEdcaTurbo_EXIT;
+ #endif
+ // We do not turn on EDCA turbo mode for some AP that has IOT issue
+ if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO)
+ goto dm_CheckEdcaTurbo_EXIT;
+
+ {
+ u8* peername[11] = {"unknown", "realtek", "realtek_92se", "broadcom", "ralink", "atheros", "cisco", "marvell", "92u_softap", "self_softap"};
+ static int wb_tmp = 0;
+ if (wb_tmp == 0){
+ printk("%s():iot peer is %#x:%s, bssid:"MAC_FMT"\n",__FUNCTION__,pHTInfo->IOTPeer,peername[pHTInfo->IOTPeer], MAC_ARG(priv->ieee80211->current_network.bssid));
+ wb_tmp = 1;
+ }
+ }
+ // Check the status for current condition.
+ if(!priv->ieee80211->bis_any_nonbepkts)
+ {
+ curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
+ curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
+#ifdef RTL8192SU
+ // Modify EDCA parameters selection bias
+ // For some APs, use downlink EDCA parameters for uplink+downlink
+ if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX)
+ {
+ if(curTxOkCnt > 4*curRxOkCnt)
+ {
+ if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
+ {
+ write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]);
+ priv->bis_cur_rdlstate = false;
+ }
+ }
+ else
+ {
+ if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
+ {
+ write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]);
+ priv->bis_cur_rdlstate = true;
+ }
+ }
+ priv->bcurrent_turbo_EDCA = true;
+ }
+ else
+ {
+ if(curRxOkCnt > 4*curTxOkCnt)
+ {
+ if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
+ {
+ write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]);
+ priv->bis_cur_rdlstate = true;
+ }
+ }
+ else
+ {
+ if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
+ {
+ write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]);
+ priv->bis_cur_rdlstate = false;
+ }
+ }
+ priv->bcurrent_turbo_EDCA = true;
+ }
+#else
+ // For RT-AP, we needs to turn it on when Rx>Tx
+ if(curRxOkCnt > 4*curTxOkCnt)
+ {
+ //printk("%s():curRxOkCnt > 4*curTxOkCnt\n");
+ if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
+ {
+ write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]);
+ priv->bis_cur_rdlstate = true;
+ }
+ }
+ else
+ {
+
+ //printk("%s():curRxOkCnt < 4*curTxOkCnt\n");
+ if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
+ {
+ write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]);
+ priv->bis_cur_rdlstate = false;
+ }
+
+ }
+
+ priv->bcurrent_turbo_EDCA = true;
+#endif
+ }
+ else
+ {
+ //
+ // Turn Off EDCA turbo here.
+ // Restore original EDCA according to the declaration of AP.
+ //
+ if(priv->bcurrent_turbo_EDCA)
+ {
+
+ {
+ u8 u1bAIFS;
+ u32 u4bAcParam;
+ struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
+ u8 mode = priv->ieee80211->mode;
+
+ // For Each time updating EDCA parameter, reset EDCA turbo mode status.
+ dm_init_edca_turbo(dev);
+ u1bAIFS = qos_parameters->aifs[0] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime;
+ u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[0]))<< AC_PARAM_TXOP_LIMIT_OFFSET)|
+ (((u32)(qos_parameters->cw_max[0]))<< AC_PARAM_ECW_MAX_OFFSET)|
+ (((u32)(qos_parameters->cw_min[0]))<< AC_PARAM_ECW_MIN_OFFSET)|
+ ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
+ //write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);
+ write_nic_dword(dev, EDCAPARA_BE, u4bAcParam);
+
+ // Check ACM bit.
+ // If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13.
+ {
+ // TODO: Modified this part and try to set acm control in only 1 IO processing!!
+
+ PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]);
+ u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl );
+ if( pAciAifsn->f.ACM )
+ { // ACM bit is 1.
+ AcmCtrl |= AcmHw_BeqEn;
+ }
+ else
+ { // ACM bit is 0.
+ AcmCtrl &= (~AcmHw_BeqEn);
+ }
+
+ RT_TRACE( COMP_QOS,"SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ) ;
+ write_nic_byte(dev, AcmHwCtrl, AcmCtrl );
+ }
+ }
+ priv->bcurrent_turbo_EDCA = false;
+ }
+ }
+
+
+dm_CheckEdcaTurbo_EXIT:
+ // Set variables for next time.
+ priv->ieee80211->bis_any_nonbepkts = false;
+ lastTxOkCnt = priv->stats.txbytesunicast;
+ lastRxOkCnt = priv->stats.rxbytesunicast;
+} // dm_CheckEdcaTurbo
+#endif
+
+extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+
+ if (DM_Type == 0) // CTS to self disable/enable
+ {
+ if(DM_Value > 1)
+ DM_Value = 1;
+ priv->ieee80211->bCTSToSelfEnable = (bool)DM_Value;
+ //DbgPrint("pMgntInfo->bCTSToSelfEnable = %d\n", pMgntInfo->bCTSToSelfEnable);
+ }
+ else if(DM_Type == 1) //CTS to self Th
+ {
+ if(DM_Value >= 50)
+ DM_Value = 50;
+ priv->ieee80211->CTSToSelfTH = (u8)DM_Value;
+ //DbgPrint("pMgntInfo->CTSToSelfTH = %d\n", pMgntInfo->CTSToSelfTH);
+ }
+}
+
+static void dm_init_ctstoself(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+
+ priv->ieee80211->bCTSToSelfEnable = TRUE;
+ priv->ieee80211->CTSToSelfTH = CTSToSelfTHVal;
+}
+
+static void dm_ctstoself(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
+ static unsigned long lastTxOkCnt = 0;
+ static unsigned long lastRxOkCnt = 0;
+ unsigned long curTxOkCnt = 0;
+ unsigned long curRxOkCnt = 0;
+
+ if(priv->ieee80211->bCTSToSelfEnable != TRUE)
+ {
+ pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
+ return;
+ }
+ /*
+ 1. Uplink
+ 2. Linksys350/Linksys300N
+ 3. <50 disable, >55 enable
+ */
+
+ if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
+ {
+ curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
+ curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
+ if(curRxOkCnt > 4*curTxOkCnt) //downlink, disable CTS to self
+ {
+ pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
+ //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled -- downlink\n");
+ }
+ else //uplink
+ {
+ #if 1
+ pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
+ #else
+ if(priv->undecorated_smoothed_pwdb < priv->ieee80211->CTSToSelfTH) // disable CTS to self
+ {
+ pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
+ //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled\n");
+ }
+ else if(priv->undecorated_smoothed_pwdb >= (priv->ieee80211->CTSToSelfTH+5)) // enable CTS to self
+ {
+ pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
+ //DbgPrint("dm_CTSToSelf() ==> CTS to self enabled\n");
+ }
+ #endif
+ }
+
+ lastTxOkCnt = priv->stats.txbytesunicast;
+ lastRxOkCnt = priv->stats.rxbytesunicast;
+ }
+}
+
+
+#if 0
+/*-----------------------------------------------------------------------------
+ * Function: dm_rf_operation_test_callback()
+ *
+ * Overview: Only for RF operation test now.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/29/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+extern void dm_rf_operation_test_callback(unsigned long dev)
+{
+// struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
+ u8 erfpath;
+
+
+ for(erfpath=0; erfpath<4; erfpath++)
+ {
+ //DbgPrint("Set RF-%d\n\r", eRFPath);
+ //PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7);
+ udelay(100);
+ }
+
+ {
+ //PlatformSetPeriodicTimer(Adapter, &pHalData->RfTest1Timer, 500);
+ }
+
+ // For test
+ {
+ //u8 i;
+ //PlatformSetPeriodicTimer(Adapter, &pHalData->RfTest1Timer, 500);
+#if 0
+ for(i=0; i<50; i++)
+ {
+ // Write Test
+ PHY_SetRFReg(Adapter, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
+ //delay_us(100);
+ PHY_SetRFReg(Adapter, RF90_PATH_A, 0x02, bMask12Bits, 0x4f);
+ //delay_us(100);
+ PHY_SetRFReg(Adapter, RF90_PATH_C, 0x02, bMask12Bits, 0x4d);
+ //delay_us(100);
+ PHY_SetRFReg(Adapter, RF90_PATH_C, 0x02, bMask12Bits, 0x4f);
+ //delay_us(100);
+
+#if 0
+ // Read test
+ PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x02, bMask12Bits);
+ //delay_us(100);
+ PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x02, bMask12Bits);
+ //delay_us(100);
+ PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x12, bMask12Bits);
+ //delay_us(100);
+ PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x12, bMask12Bits);
+ //delay_us(100);
+ PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x21, bMask12Bits);
+ //delay_us(100);
+ PHY_QueryRFReg(Adapter, RF90_PATH_A, 0x21, bMask12Bits);
+ //delay_us(100);
+#endif
+ }
+#endif
+ }
+
+} /* DM_RfOperationTestCallBack */
+#endif
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_check_rfctrl_gpio()
+ *
+ * Overview: Copy 8187B template for 9xseries.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/28/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+#if 1
+static void dm_check_rfctrl_gpio(struct net_device * dev)
+{
+ //struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // Walk around for DTM test, we will not enable HW - radio on/off because r/w
+ // page 1 register before Lextra bus is enabled cause system fails when resuming
+ // from S4. 20080218, Emily
+
+ // Stop to execute workitem to prevent S3/S4 bug.
+#ifdef RTL8190P
+ return;
+#endif
+#ifdef RTL8192U
+ return;
+#endif
+#ifdef RTL8192SU
+ return;
+#endif
+#ifdef RTL8192E
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->gpio_change_rf_wq,0);
+ #else
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->gpio_change_rf_wq);
+ #else
+ queue_work(priv->priv_wq,&priv->gpio_change_rf_wq);
+ #endif
+ #endif
+#endif
+
+} /* dm_CheckRfCtrlGPIO */
+
+#endif
+/*-----------------------------------------------------------------------------
+ * Function: dm_check_pbc_gpio()
+ *
+ * Overview: Check if PBC button is pressed.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/28/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void dm_check_pbc_gpio(struct net_device *dev)
+{
+#ifdef RTL8192U
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 tmp1byte;
+
+
+ tmp1byte = read_nic_byte(dev,GPI);
+ if(tmp1byte == 0xff)
+ return;
+
+ if (tmp1byte&BIT6 || tmp1byte&BIT0)
+ {
+ // Here we only set bPbcPressed to TRUE
+ // After trigger PBC, the variable will be set to FALSE
+ RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n");
+ priv->bpbc_pressed = true;
+ }
+#endif
+#ifdef RTL8192SU
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 tmp1byte;
+
+ write_nic_byte(dev, MAC_PINMUX_CFG, (GPIOMUX_EN | GPIOSEL_GPIO));
+
+ tmp1byte = read_nic_byte(dev, GPIO_IO_SEL);
+ tmp1byte &= ~(HAL_8192S_HW_GPIO_WPS_BIT);
+ write_nic_byte(dev, GPIO_IO_SEL, tmp1byte);
+
+ tmp1byte = read_nic_byte(dev, GPIO_IN);
+
+ RT_TRACE(COMP_IO, "CheckPbcGPIO - %x\n", tmp1byte);
+
+ // Add by hpfan 2008.07.07 to fix read GPIO error from S3
+ if (tmp1byte == 0xff)
+ return ;
+
+ if (tmp1byte&HAL_8192S_HW_GPIO_WPS_BIT)
+ {
+ // Here we only set bPbcPressed to TRUE
+ // After trigger PBC, the variable will be set to FALSE
+ RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n");
+ priv->bpbc_pressed = true;
+ }
+
+#endif
+
+
+}
+
+#ifdef RTL8192E
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_GPIOChangeRF
+ * Overview: PCI will not support workitem call back HW radio on-off control.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 02/21/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_gpio_change_rf_callback(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct r8192_priv *priv = container_of(dwork,struct r8192_priv,gpio_change_rf_wq);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+extern void dm_gpio_change_rf_callback(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+ u8 tmp1byte;
+ RT_RF_POWER_STATE eRfPowerStateToSet;
+ bool bActuallySet = false;
+
+ do{
+ bActuallySet=false;
+
+ if(!priv->up)
+ {
+ RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF),"dm_gpio_change_rf_callback(): Callback function breaks out!!\n");
+ }
+ else
+ {
+ // 0x108 GPIO input register is read only
+ //set 0x108 B1= 1: RF-ON; 0: RF-OFF.
+ tmp1byte = read_nic_byte(dev,GPI);
+
+ eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff;
+
+ if( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn))
+ {
+ RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n");
+
+ priv->bHwRadioOff = false;
+ bActuallySet = true;
+ }
+ else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff))
+ {
+ RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n");
+ priv->bHwRadioOff = true;
+ bActuallySet = true;
+ }
+
+ if(bActuallySet)
+ {
+ #ifdef TO_DO
+ MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW);
+ //DrvIFIndicateCurrentPhyStatus(pAdapter);
+ #endif
+ }
+ else
+ {
+ msleep(2000);
+ }
+
+ }
+ }while(TRUE)
+
+} /* dm_GPIOChangeRF */
+
+#endif
+/*-----------------------------------------------------------------------------
+ * Function: DM_RFPathCheckWorkItemCallBack()
+ *
+ * Overview: Check if Current RF RX path is enabled
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 01/30/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct r8192_priv *priv = container_of(dwork,struct r8192_priv,rfpath_check_wq);
+ struct net_device *dev =priv->ieee80211->dev;
+#else
+extern void dm_rf_pathcheck_workitemcallback(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+ //bool bactually_set = false;
+ u8 rfpath = 0, i;
+
+
+ /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will
+ always be the same. We only read 0xc04 now. */
+ rfpath = read_nic_byte(dev, 0xc04);
+
+ // Check Bit 0-3, it means if RF A-D is enabled.
+ for (i = 0; i < RF90_PATH_MAX; i++)
+ {
+ if (rfpath & (0x01<<i))
+ priv->brfpath_rxenable[i] = 1;
+ else
+ priv->brfpath_rxenable[i] = 0;
+ }
+ if(!DM_RxPathSelTable.Enable)
+ return;
+
+ dm_rxpath_sel_byrssi(dev);
+} /* DM_RFPathCheckWorkItemCallBack */
+
+static void dm_init_rxpath_selection(struct net_device * dev)
+{
+ u8 i;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ DM_RxPathSelTable.Enable = 1; //default enabled
+ DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low;
+ DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH;
+ if(priv->CustomerID == RT_CID_819x_Netcore)
+ DM_RxPathSelTable.cck_method = CCK_Rx_Version_2;
+ else
+ DM_RxPathSelTable.cck_method = CCK_Rx_Version_1;
+ DM_RxPathSelTable.DbgMode = DM_DBG_OFF;
+ DM_RxPathSelTable.disabledRF = 0;
+ for(i=0; i<4; i++)
+ {
+ DM_RxPathSelTable.rf_rssi[i] = 50;
+ DM_RxPathSelTable.cck_pwdb_sta[i] = -64;
+ DM_RxPathSelTable.rf_enable_rssi_th[i] = 100;
+ }
+}
+
+static void dm_rxpath_sel_byrssi(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0;
+ u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0;
+ u8 cck_default_Rx=0x2; //RF-C
+ u8 cck_optional_Rx=0x3;//RF-D
+ long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0;
+ u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0;
+ u8 cur_rf_rssi;
+ long cur_cck_pwdb;
+ static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0;
+ u8 update_cck_rx_path;
+
+ if(priv->rf_type != RF_2T4R)
+ return;
+
+ if(!cck_Rx_Path_initialized)
+ {
+ DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf);
+ cck_Rx_Path_initialized = 1;
+ }
+
+ DM_RxPathSelTable.disabledRF = 0xf;
+ DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04));
+
+ if(priv->ieee80211->mode == WIRELESS_MODE_B)
+ {
+ DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; //pure B mode, fixed cck version2
+ //DbgPrint("Pure B mode, use cck rx version2 \n");
+ }
+
+ //decide max/sec/min rssi index
+ for (i=0; i<RF90_PATH_MAX; i++)
+ {
+ if(!DM_RxPathSelTable.DbgMode)
+ DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i];
+
+ if(priv->brfpath_rxenable[i])
+ {
+ rf_num++;
+ cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i];
+
+ if(rf_num == 1) // find first enabled rf path and the rssi values
+ { //initialize, set all rssi index to the same one
+ max_rssi_index = min_rssi_index = sec_rssi_index = i;
+ tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi;
+ }
+ else if(rf_num == 2)
+ { // we pick up the max index first, and let sec and min to be the same one
+ if(cur_rf_rssi >= tmp_max_rssi)
+ {
+ tmp_max_rssi = cur_rf_rssi;
+ max_rssi_index = i;
+ }
+ else
+ {
+ tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi;
+ sec_rssi_index = min_rssi_index = i;
+ }
+ }
+ else
+ {
+ if(cur_rf_rssi > tmp_max_rssi)
+ {
+ tmp_sec_rssi = tmp_max_rssi;
+ sec_rssi_index = max_rssi_index;
+ tmp_max_rssi = cur_rf_rssi;
+ max_rssi_index = i;
+ }
+ else if(cur_rf_rssi == tmp_max_rssi)
+ { // let sec and min point to the different index
+ tmp_sec_rssi = cur_rf_rssi;
+ sec_rssi_index = i;
+ }
+ else if((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi))
+ {
+ tmp_sec_rssi = cur_rf_rssi;
+ sec_rssi_index = i;
+ }
+ else if(cur_rf_rssi == tmp_sec_rssi)
+ {
+ if(tmp_sec_rssi == tmp_min_rssi)
+ { // let sec and min point to the different index
+ tmp_sec_rssi = cur_rf_rssi;
+ sec_rssi_index = i;
+ }
+ else
+ {
+ // This case we don't need to set any index
+ }
+ }
+ else if((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi))
+ {
+ // This case we don't need to set any index
+ }
+ else if(cur_rf_rssi == tmp_min_rssi)
+ {
+ if(tmp_sec_rssi == tmp_min_rssi)
+ { // let sec and min point to the different index
+ tmp_min_rssi = cur_rf_rssi;
+ min_rssi_index = i;
+ }
+ else
+ {
+ // This case we don't need to set any index
+ }
+ }
+ else if(cur_rf_rssi < tmp_min_rssi)
+ {
+ tmp_min_rssi = cur_rf_rssi;
+ min_rssi_index = i;
+ }
+ }
+ }
+ }
+
+ rf_num = 0;
+ // decide max/sec/min cck pwdb index
+ if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_2)
+ {
+ for (i=0; i<RF90_PATH_MAX; i++)
+ {
+ if(priv->brfpath_rxenable[i])
+ {
+ rf_num++;
+ cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i];
+
+ if(rf_num == 1) // find first enabled rf path and the rssi values
+ { //initialize, set all rssi index to the same one
+ cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i;
+ tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb;
+ }
+ else if(rf_num == 2)
+ { // we pick up the max index first, and let sec and min to be the same one
+ if(cur_cck_pwdb >= tmp_cck_max_pwdb)
+ {
+ tmp_cck_max_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_max_index = i;
+ }
+ else
+ {
+ tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i;
+ }
+ }
+ else
+ {
+ if(cur_cck_pwdb > tmp_cck_max_pwdb)
+ {
+ tmp_cck_sec_pwdb = tmp_cck_max_pwdb;
+ cck_rx_ver2_sec_index = cck_rx_ver2_max_index;
+ tmp_cck_max_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_max_index = i;
+ }
+ else if(cur_cck_pwdb == tmp_cck_max_pwdb)
+ { // let sec and min point to the different index
+ tmp_cck_sec_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_sec_index = i;
+ }
+ else if((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb))
+ {
+ tmp_cck_sec_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_sec_index = i;
+ }
+ else if(cur_cck_pwdb == tmp_cck_sec_pwdb)
+ {
+ if(tmp_cck_sec_pwdb == tmp_cck_min_pwdb)
+ { // let sec and min point to the different index
+ tmp_cck_sec_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_sec_index = i;
+ }
+ else
+ {
+ // This case we don't need to set any index
+ }
+ }
+ else if((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb))
+ {
+ // This case we don't need to set any index
+ }
+ else if(cur_cck_pwdb == tmp_cck_min_pwdb)
+ {
+ if(tmp_cck_sec_pwdb == tmp_cck_min_pwdb)
+ { // let sec and min point to the different index
+ tmp_cck_min_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_min_index = i;
+ }
+ else
+ {
+ // This case we don't need to set any index
+ }
+ }
+ else if(cur_cck_pwdb < tmp_cck_min_pwdb)
+ {
+ tmp_cck_min_pwdb = cur_cck_pwdb;
+ cck_rx_ver2_min_index = i;
+ }
+ }
+
+ }
+ }
+ }
+
+
+ // Set CCK Rx path
+ // reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path.
+ update_cck_rx_path = 0;
+ if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_2)
+ {
+ cck_default_Rx = cck_rx_ver2_max_index;
+ cck_optional_Rx = cck_rx_ver2_sec_index;
+ if(tmp_cck_max_pwdb != -64)
+ update_cck_rx_path = 1;
+ }
+
+ if(tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2)
+ {
+ if((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH)
+ {
+ //record the enabled rssi threshold
+ DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5;
+ //disable the BB Rx path, OFDM
+ rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<<min_rssi_index, 0x0); // 0xc04[3:0]
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1<<min_rssi_index, 0x0); // 0xd04[3:0]
+ disabled_rf_cnt++;
+ }
+ if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_1)
+ {
+ cck_default_Rx = max_rssi_index;
+ cck_optional_Rx = sec_rssi_index;
+ if(tmp_max_rssi)
+ update_cck_rx_path = 1;
+ }
+ }
+
+ if(update_cck_rx_path)
+ {
+ DM_RxPathSelTable.cck_Rx_path = (cck_default_Rx<<2)|(cck_optional_Rx);
+ rtl8192_setBBreg(dev, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_Rx_path);
+ }
+
+ if(DM_RxPathSelTable.disabledRF)
+ {
+ for(i=0; i<4; i++)
+ {
+ if((DM_RxPathSelTable.disabledRF>>i) & 0x1) //disabled rf
+ {
+ if(tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i])
+ {
+ //enable the BB Rx path
+ //DbgPrint("RF-%d is enabled. \n", 0x1<<i);
+ rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<<i, 0x1); // 0xc04[3:0]
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1<<i, 0x1); // 0xd04[3:0]
+ DM_RxPathSelTable.rf_enable_rssi_th[i] = 100;
+ disabled_rf_cnt--;
+ }
+ }
+ }
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_check_rx_path_selection()
+ *
+ * Overview: Call a workitem to check current RXRF path and Rx Path selection by RSSI.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/28/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void dm_check_rx_path_selection(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->rfpath_check_wq,0);
+#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->rfpath_check_wq);
+#else
+ queue_work(priv->priv_wq,&priv->rfpath_check_wq);
+#endif
+#endif
+} /* dm_CheckRxRFPath */
+
+
+static void dm_init_fsync (struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->ieee80211->fsync_time_interval = 500;
+ priv->ieee80211->fsync_rate_bitmap = 0x0f000800;
+ priv->ieee80211->fsync_rssi_threshold = 30;
+#ifdef RTL8190P
+ priv->ieee80211->bfsync_enable = true;
+#else
+ priv->ieee80211->bfsync_enable = false;
+#endif
+ priv->ieee80211->fsync_multiple_timeinterval = 3;
+ priv->ieee80211->fsync_firstdiff_ratethreshold= 100;
+ priv->ieee80211->fsync_seconddiff_ratethreshold= 200;
+ priv->ieee80211->fsync_state = Default_Fsync;
+ priv->framesyncMonitor = 1; // current default 0xc38 monitor on
+
+ init_timer(&priv->fsync_timer);
+ priv->fsync_timer.data = (unsigned long)dev;
+ priv->fsync_timer.function = dm_fsync_timer_callback;
+}
+
+
+static void dm_deInit_fsync(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ del_timer_sync(&priv->fsync_timer);
+}
+
+extern void dm_fsync_timer_callback(unsigned long data)
+{
+ struct net_device *dev = (struct net_device *)data;
+ struct r8192_priv *priv = ieee80211_priv((struct net_device *)data);
+ u32 rate_index, rate_count = 0, rate_count_diff=0;
+ bool bSwitchFromCountDiff = false;
+ bool bDoubleTimeInterval = false;
+
+ if( priv->ieee80211->state == IEEE80211_LINKED &&
+ priv->ieee80211->bfsync_enable &&
+ (priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC))
+ {
+ // Count rate 54, MCS [7], [12, 13, 14, 15]
+ u32 rate_bitmap;
+ for(rate_index = 0; rate_index <= 27; rate_index++)
+ {
+ rate_bitmap = 1 << rate_index;
+ if(priv->ieee80211->fsync_rate_bitmap & rate_bitmap)
+ rate_count+= priv->stats.received_rate_histogram[1][rate_index];
+ }
+
+ if(rate_count < priv->rate_record)
+ rate_count_diff = 0xffffffff - rate_count + priv->rate_record;
+ else
+ rate_count_diff = rate_count - priv->rate_record;
+ if(rate_count_diff < priv->rateCountDiffRecord)
+ {
+
+ u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff;
+ // Contiune count
+ if(DiffNum >= priv->ieee80211->fsync_seconddiff_ratethreshold)
+ priv->ContiuneDiffCount++;
+ else
+ priv->ContiuneDiffCount = 0;
+
+ // Contiune count over
+ if(priv->ContiuneDiffCount >=2)
+ {
+ bSwitchFromCountDiff = true;
+ priv->ContiuneDiffCount = 0;
+ }
+ }
+ else
+ {
+ // Stop contiune count
+ priv->ContiuneDiffCount = 0;
+ }
+
+ //If Count diff <= FsyncRateCountThreshold
+ if(rate_count_diff <= priv->ieee80211->fsync_firstdiff_ratethreshold)
+ {
+ bSwitchFromCountDiff = true;
+ priv->ContiuneDiffCount = 0;
+ }
+ priv->rate_record = rate_count;
+ priv->rateCountDiffRecord = rate_count_diff;
+ RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync);
+ // if we never receive those mcs rate and rssi > 30 % then switch fsyn
+ if(priv->undecorated_smoothed_pwdb > priv->ieee80211->fsync_rssi_threshold && bSwitchFromCountDiff)
+ {
+ bDoubleTimeInterval = true;
+ priv->bswitch_fsync = !priv->bswitch_fsync;
+ if(priv->bswitch_fsync)
+ {
+ #ifdef RTL8190P
+ write_nic_byte(dev, 0xC36, 0x00);
+ #else
+ write_nic_byte(dev,0xC36, 0x1c);
+ #endif
+ write_nic_byte(dev, 0xC3e, 0x90);
+ }
+ else
+ {
+ #ifdef RTL8190P
+ write_nic_byte(dev, 0xC36, 0x40);
+ #else
+ write_nic_byte(dev, 0xC36, 0x5c);
+ #endif
+ write_nic_byte(dev, 0xC3e, 0x96);
+ }
+ }
+ else if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->fsync_rssi_threshold)
+ {
+ if(priv->bswitch_fsync)
+ {
+ priv->bswitch_fsync = false;
+ #ifdef RTL8190P
+ write_nic_byte(dev, 0xC36, 0x40);
+ #else
+ write_nic_byte(dev, 0xC36, 0x5c);
+ #endif
+ write_nic_byte(dev, 0xC3e, 0x96);
+ }
+ }
+ if(bDoubleTimeInterval){
+ if(timer_pending(&priv->fsync_timer))
+ del_timer_sync(&priv->fsync_timer);
+ priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval*priv->ieee80211->fsync_multiple_timeinterval);
+ add_timer(&priv->fsync_timer);
+ }
+ else{
+ if(timer_pending(&priv->fsync_timer))
+ del_timer_sync(&priv->fsync_timer);
+ priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval);
+ add_timer(&priv->fsync_timer);
+ }
+ }
+ else
+ {
+ // Let Register return to default value;
+ if(priv->bswitch_fsync)
+ {
+ priv->bswitch_fsync = false;
+ #ifdef RTL8190P
+ write_nic_byte(dev, 0xC36, 0x40);
+ #else
+ write_nic_byte(dev, 0xC36, 0x5c);
+ #endif
+ write_nic_byte(dev, 0xC3e, 0x96);
+ }
+ priv->ContiuneDiffCount = 0;
+#ifdef RTL8192SU
+ rtl8192_setBBreg(dev, rOFDM0_RxDetector2, bMaskDWord, 0x164052cd);
+#else
+ #ifdef RTL8190P
+ write_nic_dword(dev, rOFDM0_RxDetector2, 0x164052cd);
+ #else
+ write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
+ #endif
+#endif
+ }
+ RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount);
+ RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync);
+}
+
+static void dm_StartHWFsync(struct net_device *dev)
+{
+ RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__);
+ write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf);
+ write_nic_byte(dev, 0xc3b, 0x41);
+}
+
+static void dm_EndSWFsync(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__);
+ del_timer_sync(&(priv->fsync_timer));
+
+ // Let Register return to default value;
+ if(priv->bswitch_fsync)
+ {
+ priv->bswitch_fsync = false;
+
+ #ifdef RTL8190P
+ write_nic_byte(dev, 0xC36, 0x40);
+ #else
+ write_nic_byte(dev, 0xC36, 0x5c);
+ #endif
+
+ write_nic_byte(dev, 0xC3e, 0x96);
+ }
+
+ priv->ContiuneDiffCount = 0;
+#ifndef RTL8190P
+ write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
+#endif
+
+}
+
+static void dm_StartSWFsync(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 rateIndex;
+ u32 rateBitmap;
+
+ RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
+ // Initial rate record to zero, start to record.
+ priv->rate_record = 0;
+ // Initial contiune diff count to zero, start to record.
+ priv->ContiuneDiffCount = 0;
+ priv->rateCountDiffRecord = 0;
+ priv->bswitch_fsync = false;
+
+ if(priv->ieee80211->mode == WIRELESS_MODE_N_24G)
+ {
+ priv->ieee80211->fsync_firstdiff_ratethreshold= 600;
+ priv->ieee80211->fsync_seconddiff_ratethreshold = 0xffff;
+ }
+ else
+ {
+ priv->ieee80211->fsync_firstdiff_ratethreshold= 200;
+ priv->ieee80211->fsync_seconddiff_ratethreshold = 200;
+ }
+ for(rateIndex = 0; rateIndex <= 27; rateIndex++)
+ {
+ rateBitmap = 1 << rateIndex;
+ if(priv->ieee80211->fsync_rate_bitmap & rateBitmap)
+ priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex];
+ }
+ if(timer_pending(&priv->fsync_timer))
+ del_timer_sync(&priv->fsync_timer);
+ priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval);
+ add_timer(&priv->fsync_timer);
+
+#ifndef RTL8190P
+ write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd);
+#endif
+
+}
+
+static void dm_EndHWFsync(struct net_device *dev)
+{
+ RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
+ write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
+ write_nic_byte(dev, 0xc3b, 0x49);
+
+}
+
+void dm_check_fsync(struct net_device *dev)
+{
+#define RegC38_Default 0
+#define RegC38_NonFsync_Other_AP 1
+#define RegC38_Fsync_AP_BCM 2
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //u32 framesyncC34;
+ static u8 reg_c38_State=RegC38_Default;
+ static u32 reset_cnt=0;
+
+ RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->ieee80211->fsync_rssi_threshold, priv->ieee80211->fsync_time_interval, priv->ieee80211->fsync_multiple_timeinterval);
+ RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->ieee80211->fsync_rate_bitmap, priv->ieee80211->fsync_firstdiff_ratethreshold, priv->ieee80211->fsync_seconddiff_ratethreshold);
+
+ if( priv->ieee80211->state == IEEE80211_LINKED &&
+ (priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC))
+ {
+ if(priv->ieee80211->bfsync_enable == 0)
+ {
+ switch(priv->ieee80211->fsync_state)
+ {
+ case Default_Fsync:
+ dm_StartHWFsync(dev);
+ priv->ieee80211->fsync_state = HW_Fsync;
+ break;
+ case SW_Fsync:
+ dm_EndSWFsync(dev);
+ dm_StartHWFsync(dev);
+ priv->ieee80211->fsync_state = HW_Fsync;
+ break;
+ case HW_Fsync:
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch(priv->ieee80211->fsync_state)
+ {
+ case Default_Fsync:
+ dm_StartSWFsync(dev);
+ priv->ieee80211->fsync_state = SW_Fsync;
+ break;
+ case HW_Fsync:
+ dm_EndHWFsync(dev);
+ dm_StartSWFsync(dev);
+ priv->ieee80211->fsync_state = SW_Fsync;
+ break;
+ case SW_Fsync:
+ default:
+ break;
+
+ }
+ }
+ if(priv->framesyncMonitor)
+ {
+ if(reg_c38_State != RegC38_Fsync_AP_BCM)
+ { //For broadcom AP we write different default value
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector3, 0x15);
+ #else
+ write_nic_byte(dev, rOFDM0_RxDetector3, 0x95);
+ #endif
+
+ reg_c38_State = RegC38_Fsync_AP_BCM;
+ }
+ }
+ }
+ else
+ {
+ switch(priv->ieee80211->fsync_state)
+ {
+ case HW_Fsync:
+ dm_EndHWFsync(dev);
+ priv->ieee80211->fsync_state = Default_Fsync;
+ break;
+ case SW_Fsync:
+ dm_EndSWFsync(dev);
+ priv->ieee80211->fsync_state = Default_Fsync;
+ break;
+ case Default_Fsync:
+ default:
+ break;
+ }
+
+ if(priv->framesyncMonitor)
+ {
+ if(priv->ieee80211->state == IEEE80211_LINKED)
+ {
+ if(priv->undecorated_smoothed_pwdb <= RegC38_TH)
+ {
+ if(reg_c38_State != RegC38_NonFsync_Other_AP)
+ {
+ #ifdef RTL8190P
+ write_nic_byte(dev, rOFDM0_RxDetector3, 0x10);
+ #else
+ write_nic_byte(dev, rOFDM0_RxDetector3, 0x90);
+ #endif
+
+ reg_c38_State = RegC38_NonFsync_Other_AP;
+ #if 0//cosa
+ if (Adapter->HardwareType == HARDWARE_TYPE_RTL8190P)
+ DbgPrint("Fsync is idle, rssi<=35, write 0xc38 = 0x%x \n", 0x10);
+ else
+ DbgPrint("Fsync is idle, rssi<=35, write 0xc38 = 0x%x \n", 0x90);
+ #endif
+ }
+ }
+ else if(priv->undecorated_smoothed_pwdb >= (RegC38_TH+5))
+ {
+ if(reg_c38_State)
+ {
+ write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
+ reg_c38_State = RegC38_Default;
+ //DbgPrint("Fsync is idle, rssi>=40, write 0xc38 = 0x%x \n", pHalData->framesync);
+ }
+ }
+ }
+ else
+ {
+ if(reg_c38_State)
+ {
+ write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
+ reg_c38_State = RegC38_Default;
+ //DbgPrint("Fsync is idle, not connected, write 0xc38 = 0x%x \n", pHalData->framesync);
+ }
+ }
+ }
+ }
+ if(priv->framesyncMonitor)
+ {
+ if(priv->reset_count != reset_cnt)
+ { //After silent reset, the reg_c38_State will be returned to default value
+ write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
+ reg_c38_State = RegC38_Default;
+ reset_cnt = priv->reset_count;
+ //DbgPrint("reg_c38_State = 0 for silent reset. \n");
+ }
+ }
+ else
+ {
+ if(reg_c38_State)
+ {
+ write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
+ reg_c38_State = RegC38_Default;
+ //DbgPrint("framesync no monitor, write 0xc38 = 0x%x \n", pHalData->framesync);
+ }
+ }
+}
+
+#if 0
+/*-----------------------------------------------------------------------------
+ * Function: DM_CheckLBusStatus()
+ *
+ * Overview: For 9x series, we must make sure LBUS is active for IO.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 02/22/2008 MHC Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+extern s1Byte DM_CheckLBusStatus(IN PADAPTER Adapter)
+{
+ PMGNT_INFO pMgntInfo=&Adapter->MgntInfo;
+
+#if (HAL_CODE_BASE & RTL819X)
+
+#if (HAL_CODE_BASE == RTL8192)
+
+#if( DEV_BUS_TYPE==PCI_INTERFACE)
+ //return (pMgntInfo->bLbusEnable); // For debug only
+ return TRUE;
+#endif
+
+#if( DEV_BUS_TYPE==USB_INTERFACE)
+ return TRUE;
+#endif
+
+#endif // #if (HAL_CODE_BASE == RTL8192)
+
+#if (HAL_CODE_BASE == RTL8190)
+ return TRUE;
+#endif // #if (HAL_CODE_BASE == RTL8190)
+
+#endif // #if (HAL_CODE_BASE & RTL819X)
+} /* DM_CheckLBusStatus */
+
+#endif
+
+/*-----------------------------------------------------------------------------
+ * Function: dm_shadow_init()
+ *
+ * Overview: Store all NIC MAC/BB register content.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/29/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+extern void dm_shadow_init(struct net_device *dev)
+{
+ u8 page;
+ u16 offset;
+
+ for (page = 0; page < 5; page++)
+ for (offset = 0; offset < 256; offset++)
+ {
+ dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
+ //DbgPrint("P-%d/O-%02x=%02x\r\n", page, offset, DM_Shadow[page][offset]);
+ }
+
+ for (page = 8; page < 11; page++)
+ for (offset = 0; offset < 256; offset++)
+ dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
+
+ for (page = 12; page < 15; page++)
+ for (offset = 0; offset < 256; offset++)
+ dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
+
+} /* dm_shadow_init */
+
+/*---------------------------Define function prototype------------------------*/
+/*-----------------------------------------------------------------------------
+ * Function: DM_DynamicTxPower()
+ *
+ * Overview: Detect Signal strength to control TX Registry
+ Tx Power Control For Near/Far Range
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 03/06/2008 Jacken Create Version 0.
+ *
+ *---------------------------------------------------------------------------*/
+static void dm_init_dynamic_txpower(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
+ priv->ieee80211->bdynamic_txpower_enable = true; //Default to enable Tx Power Control
+ priv->bLastDTPFlag_High = false;
+ priv->bLastDTPFlag_Low = false;
+ priv->bDynamicTxHighPower = false;
+ priv->bDynamicTxLowPower = false;
+}
+
+static void dm_dynamic_txpower(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ unsigned int txhipower_threshhold=0;
+ unsigned int txlowpower_threshold=0;
+ if(priv->ieee80211->bdynamic_txpower_enable != true)
+ {
+ priv->bDynamicTxHighPower = false;
+ priv->bDynamicTxLowPower = false;
+ return;
+ }
+ //printk("priv->ieee80211->current_network.unknown_cap_exist is %d ,priv->ieee80211->current_network.broadcom_cap_exist is %d\n",priv->ieee80211->current_network.unknown_cap_exist,priv->ieee80211->current_network.broadcom_cap_exist);
+ if((priv->ieee80211->current_network.atheros_cap_exist ) && (priv->ieee80211->mode == IEEE_G)){
+ txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH;
+ txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW;
+ }
+ else
+ {
+ txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH;
+ txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW;
+ }
+
+// printk("=======>%s(): txhipower_threshhold is %d,txlowpower_threshold is %d\n",__FUNCTION__,txhipower_threshhold,txlowpower_threshold);
+ RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb);
+
+ if(priv->ieee80211->state == IEEE80211_LINKED)
+ {
+ if(priv->undecorated_smoothed_pwdb >= txhipower_threshhold)
+ {
+ priv->bDynamicTxHighPower = true;
+ priv->bDynamicTxLowPower = false;
+ }
+ else
+ {
+ // high power state check
+ if(priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true)
+ {
+ priv->bDynamicTxHighPower = false;
+ }
+ // low power state check
+ if(priv->undecorated_smoothed_pwdb < 35)
+ {
+ priv->bDynamicTxLowPower = true;
+ }
+ else if(priv->undecorated_smoothed_pwdb >= 40)
+ {
+ priv->bDynamicTxLowPower = false;
+ }
+ }
+ }
+ else
+ {
+ //pHalData->bTXPowerCtrlforNearFarRange = !pHalData->bTXPowerCtrlforNearFarRange;
+ priv->bDynamicTxHighPower = false;
+ priv->bDynamicTxLowPower = false;
+ }
+
+ if( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) ||
+ (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) )
+ {
+ RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190() channel = %d \n" , priv->ieee80211->current_network.channel);
+#ifndef RTL8192SU
+#if defined(RTL8190P) || defined(RTL8192E)
+ SetTxPowerLevel8190(Adapter,pHalData->CurrentChannel);
+#endif
+
+#ifdef RTL8192U
+ rtl8192_phy_setTxPower(dev,priv->ieee80211->current_network.channel);
+ //pHalData->bStartTxCtrlByTPCNFR = FALSE; //Clear th flag of Set TX Power from Sitesurvey
+#endif
+#endif
+ }
+ priv->bLastDTPFlag_High = priv->bDynamicTxHighPower;
+ priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower;
+
+} /* dm_dynamic_txpower */
+
+//added by vivi, for read tx rate and retrycount
+static void dm_check_txrateandretrycount(struct net_device * dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ //for 11n tx rate
+// priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
+#ifdef RTL8192SU
+ ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, TX_RATE_REG);
+#else
+ ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
+#endif
+ //printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);
+ //for initial tx rate
+// priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);
+ ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg);
+ //for tx tx retry count
+// priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
+ ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
+}
+
+static void dm_send_rssi_tofw(struct net_device *dev)
+{
+#ifndef RTL8192SU
+ DCMD_TXCMD_T tx_cmd;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ // If we test chariot, we should stop the TX command ?
+ // Because 92E will always silent reset when we send tx command. We use register
+ // 0x1e0(byte) to botify driver.
+ write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb);
+ return;
+#if 1
+ tx_cmd.Op = TXCMD_SET_RX_RSSI;
+ tx_cmd.Length = 4;
+ tx_cmd.Value = priv->undecorated_smoothed_pwdb;
+
+ cmpk_message_handle_tx(dev, (u8*)&tx_cmd,
+ DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T));
+#endif
+#endif
+}
+
+#ifdef TO_DO_LIST
+static void
+dm_CheckProtection(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ //PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
+ u8 CurRate;
+
+ if(priv->ieee80211->pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_FORCED_CTS2SELF))
+ {
+ CurRate = read_nic_byte(dev, INIMCS_SEL);
+ if(CurRate <= DESC92S_RATE11M)
+ priv->bDmDisableProtect = true;
+ else
+ priv->bDmDisableProtect = fasle;
+ }
+}
+#endif
+
+/*---------------------------Define function prototype------------------------*/
+
diff --git a/drivers/staging/rtl8192su/r8192U_dm.h b/drivers/staging/rtl8192su/r8192U_dm.h
new file mode 100644
index 000000000000..1e05d7579882
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_dm.h
@@ -0,0 +1,309 @@
+/*****************************************************************************
+ * Copyright(c) 2007, RealTEK Technology Inc. All Right Reserved.
+ *
+ * Module: Hal819xUsbDM.h (RTL8192 Header H File)
+ *
+ *
+ * Note: For dynamic control definition constant structure.
+ *
+ *
+ * Export:
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ * 10/04/2007 MHC Create initial version.
+ *
+ *****************************************************************************/
+ /* Check to see if the file has been included already. */
+#ifndef __R8192UDM_H__
+#define __R8192UDM_H__
+
+
+/*--------------------------Define Parameters-------------------------------*/
+#define DM_DIG_THRESH_HIGH 40
+#define DM_DIG_THRESH_LOW 35
+
+#define DM_DIG_HIGH_PWR_THRESH_HIGH 75
+#define DM_DIG_HIGH_PWR_THRESH_LOW 70
+
+#define BW_AUTO_SWITCH_HIGH_LOW 25
+#define BW_AUTO_SWITCH_LOW_HIGH 30
+
+#define DM_check_fsync_time_interval 500
+
+
+#define DM_DIG_BACKOFF 12
+#define DM_DIG_MAX 0x36
+#define DM_DIG_MIN 0x1c
+#define DM_DIG_MIN_Netcore 0x12
+
+#define RxPathSelection_SS_TH_low 30
+#define RxPathSelection_diff_TH 18
+
+#define RateAdaptiveTH_High 50
+#define RateAdaptiveTH_Low_20M 30
+#define RateAdaptiveTH_Low_40M 10
+#define VeryLowRSSI 15
+#define CTSToSelfTHVal 30
+
+//defined by vivi, for tx power track
+#define E_FOR_TX_POWER_TRACK 300
+//Dynamic Tx Power Control Threshold
+#define TX_POWER_NEAR_FIELD_THRESH_HIGH 68
+#define TX_POWER_NEAR_FIELD_THRESH_LOW 62
+//added by amy for atheros AP
+#define TX_POWER_ATHEROAP_THRESH_HIGH 78
+#define TX_POWER_ATHEROAP_THRESH_LOW 72
+
+//defined by vivi, for showing on UI
+#define Current_Tx_Rate_Reg 0x1b8
+#define Initial_Tx_Rate_Reg 0x1b9
+#define Tx_Retry_Count_Reg 0x1ac
+#define RegC38_TH 20
+#if 0
+//----------------------------------------------------------------------------
+// 8190 Rate Adaptive Table Register (offset 0x320, 4 byte)
+//----------------------------------------------------------------------------
+
+//CCK
+#define RATR_1M 0x00000001
+#define RATR_2M 0x00000002
+#define RATR_55M 0x00000004
+#define RATR_11M 0x00000008
+//OFDM
+#define RATR_6M 0x00000010
+#define RATR_9M 0x00000020
+#define RATR_12M 0x00000040
+#define RATR_18M 0x00000080
+#define RATR_24M 0x00000100
+#define RATR_36M 0x00000200
+#define RATR_48M 0x00000400
+#define RATR_54M 0x00000800
+//MCS 1 Spatial Stream
+#define RATR_MCS0 0x00001000
+#define RATR_MCS1 0x00002000
+#define RATR_MCS2 0x00004000
+#define RATR_MCS3 0x00008000
+#define RATR_MCS4 0x00010000
+#define RATR_MCS5 0x00020000
+#define RATR_MCS6 0x00040000
+#define RATR_MCS7 0x00080000
+//MCS 2 Spatial Stream
+#define RATR_MCS8 0x00100000
+#define RATR_MCS9 0x00200000
+#define RATR_MCS10 0x00400000
+#define RATR_MCS11 0x00800000
+#define RATR_MCS12 0x01000000
+#define RATR_MCS13 0x02000000
+#define RATR_MCS14 0x04000000
+#define RATR_MCS15 0x08000000
+// ALL CCK Rate
+#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M
+#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M\
+ |RATR_36M|RATR_48M|RATR_54M
+#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11| \
+ RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15
+#endif
+/*--------------------------Define Parameters-------------------------------*/
+
+
+/*------------------------------Define structure----------------------------*/
+/* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
+typedef struct _dynamic_initial_gain_threshold_
+{
+ u8 dig_enable_flag;
+ u8 dig_algorithm;
+ u8 dbg_mode;
+ u8 dig_algorithm_switch;
+
+ long rssi_low_thresh;
+ long rssi_high_thresh;
+
+ long rssi_high_power_lowthresh;
+ long rssi_high_power_highthresh;
+
+ u8 dig_state;
+ u8 dig_highpwr_state;
+ u8 cur_connect_state;
+ u8 pre_connect_state;
+
+ u8 curpd_thstate;
+ u8 prepd_thstate;
+ u8 curcs_ratio_state;
+ u8 precs_ratio_state;
+
+ u32 pre_ig_value;
+ u32 cur_ig_value;
+
+ u8 backoff_val;
+ u8 rx_gain_range_max;
+ u8 rx_gain_range_min;
+ bool initialgain_lowerbound_state;
+
+ long rssi_val;
+}dig_t;
+
+typedef enum tag_dynamic_init_gain_state_definition
+{
+ DM_STA_DIG_OFF = 0,
+ DM_STA_DIG_ON,
+ DM_STA_DIG_MAX
+}dm_dig_sta_e;
+
+
+/* 2007/10/08 MH Define RATR state. */
+typedef enum tag_dynamic_ratr_state_definition
+{
+ DM_RATR_STA_HIGH = 0,
+ DM_RATR_STA_MIDDLE = 1,
+ DM_RATR_STA_LOW = 2,
+ DM_RATR_STA_MAX
+}dm_ratr_sta_e;
+
+/* 2007/10/11 MH Define DIG operation type. */
+typedef enum tag_dynamic_init_gain_operation_type_definition
+{
+ DIG_TYPE_THRESH_HIGH = 0,
+ DIG_TYPE_THRESH_LOW = 1,
+ DIG_TYPE_THRESH_HIGHPWR_HIGH = 2,
+ DIG_TYPE_THRESH_HIGHPWR_LOW = 3,
+ DIG_TYPE_DBG_MODE = 4,
+ DIG_TYPE_RSSI = 5,
+ DIG_TYPE_ALGORITHM = 6,
+ DIG_TYPE_BACKOFF = 7,
+ DIG_TYPE_PWDB_FACTOR = 8,
+ DIG_TYPE_RX_GAIN_MIN = 9,
+ DIG_TYPE_RX_GAIN_MAX = 10,
+ DIG_TYPE_ENABLE = 20,
+ DIG_TYPE_DISABLE = 30,
+ DIG_OP_TYPE_MAX
+}dm_dig_op_e;
+
+typedef enum tag_dig_algorithm_definition
+{
+ DIG_ALGO_BY_FALSE_ALARM = 0,
+ DIG_ALGO_BY_RSSI = 1,
+ DIG_ALGO_MAX
+}dm_dig_alg_e;
+
+typedef enum tag_dig_dbgmode_definition
+{
+ DIG_DBG_OFF = 0,
+ DIG_DBG_ON = 1,
+ DIG_DBG_MAX
+}dm_dig_dbg_e;
+
+typedef enum tag_dig_connect_definition
+{
+ DIG_DISCONNECT = 0,
+ DIG_CONNECT = 1,
+ DIG_CONNECT_MAX
+}dm_dig_connect_e;
+
+typedef enum tag_dig_packetdetection_threshold_definition
+{
+ DIG_PD_AT_LOW_POWER = 0,
+ DIG_PD_AT_NORMAL_POWER = 1,
+ DIG_PD_AT_HIGH_POWER = 2,
+ DIG_PD_MAX
+}dm_dig_pd_th_e;
+
+typedef enum tag_dig_cck_cs_ratio_state_definition
+{
+ DIG_CS_RATIO_LOWER = 0,
+ DIG_CS_RATIO_HIGHER = 1,
+ DIG_CS_MAX
+}dm_dig_cs_ratio_e;
+typedef struct _Dynamic_Rx_Path_Selection_
+{
+ u8 Enable;
+ u8 DbgMode;
+ u8 cck_method;
+ u8 cck_Rx_path;
+
+ u8 SS_TH_low;
+ u8 diff_TH;
+ u8 disabledRF;
+ u8 reserved;
+
+ u8 rf_rssi[4];
+ u8 rf_enable_rssi_th[4];
+ long cck_pwdb_sta[4];
+}DRxPathSel;
+
+typedef enum tag_CCK_Rx_Path_Method_Definition
+{
+ CCK_Rx_Version_1 = 0,
+ CCK_Rx_Version_2= 1,
+ CCK_Rx_Version_MAX
+}DM_CCK_Rx_Path_Method;
+
+typedef enum tag_DM_DbgMode_Definition
+{
+ DM_DBG_OFF = 0,
+ DM_DBG_ON = 1,
+ DM_DBG_MAX
+}DM_DBG_E;
+
+typedef struct tag_Tx_Config_Cmd_Format
+{
+ u32 Op; /* Command packet type. */
+ u32 Length; /* Command packet length. */
+ u32 Value;
+}DCMD_TXCMD_T, *PDCMD_TXCMD_T;
+/*------------------------------Define structure----------------------------*/
+
+
+/*------------------------Export global variable----------------------------*/
+extern dig_t dm_digtable;
+extern u8 dm_shadow[16][256];
+extern DRxPathSel DM_RxPathSelTable;
+/*------------------------Export global variable----------------------------*/
+
+
+/*------------------------Export Marco Definition---------------------------*/
+
+/*------------------------Export Marco Definition---------------------------*/
+
+
+/*--------------------------Exported Function prototype---------------------*/
+extern void init_hal_dm(struct net_device *dev);
+extern void deinit_hal_dm(struct net_device *dev);
+
+extern void hal_dm_watchdog(struct net_device *dev);
+
+extern void init_rate_adaptive(struct net_device *dev);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_txpower_trackingcallback(struct work_struct *work);
+#else
+extern void dm_txpower_trackingcallback(struct net_device *dev);
+#endif
+extern void dm_restore_dynamic_mechanism_state(struct net_device *dev);
+extern void dm_backup_dynamic_mechanism_state(struct net_device *dev);
+extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
+ u32 dm_type, u32 dm_value);
+extern void dm_force_tx_fw_info(struct net_device *dev,u32 force_type, u32 force_value);
+extern void dm_init_edca_turbo(struct net_device *dev);
+extern void dm_rf_operation_test_callback(unsigned long data);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
+#else
+extern void dm_rf_pathcheck_workitemcallback(struct net_device *dev);
+#endif
+extern void dm_fsync_timer_callback(unsigned long data);
+extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14);
+#if 0
+extern char dm_check_lbus_status(IN PADAPTER Adapter);
+#endif
+extern void dm_shadow_init(struct net_device *dev);
+extern void dm_initialize_txpower_tracking(struct net_device *dev);
+/*--------------------------Exported Function prototype---------------------*/
+
+
+#endif /*__R8192UDM_H__ */
+
+
+/* End of r8192U_dm.h */
+
diff --git a/drivers/staging/rtl8192su/r8192U_hw.h b/drivers/staging/rtl8192su/r8192U_hw.h
new file mode 100644
index 000000000000..f2500e654a79
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_hw.h
@@ -0,0 +1,746 @@
+/*
+ This is part of rtl8187 OpenSource driver.
+ Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+ Parts of this driver are based on the GPL part of the
+ official Realtek driver.
+ Parts of this driver are based on the rtl8180 driver skeleton
+ from Patric Schenke & Andres Salomon.
+ Parts of this driver are based on the Intel Pro Wireless
+ 2100 GPL driver.
+
+ We want to tanks the Authors of those projects
+ and the Ndiswrapper project Authors.
+*/
+
+/* Mariusz Matuszek added full registers definition with Realtek's name */
+
+/* this file contains register definitions for the rtl8187 MAC controller */
+#ifndef R8192_HW
+#define R8192_HW
+
+typedef enum _VERSION_819xU{
+ VERSION_819xU_A, // A-cut
+ VERSION_819xU_B, // B-cut
+ VERSION_819xU_C,// C-cut
+}VERSION_819xU,*PVERSION_819xU;
+//added for different RF type
+typedef enum _RT_RF_TYPE_DEF
+{
+ RF_1T2R = 0,
+ RF_2T4R,
+
+ RF_819X_MAX_TYPE
+}RT_RF_TYPE_DEF;
+
+
+typedef enum _BaseBand_Config_Type{
+ BaseBand_Config_PHY_REG = 0, //Radio Path A
+ BaseBand_Config_AGC_TAB = 1, //Radio Path B
+}BaseBand_Config_Type, *PBaseBand_Config_Type;
+#if 0
+typedef enum _RT_RF_TYPE_819xU{
+ RF_TYPE_MIN = 0,
+ RF_8225,
+ RF_8256,
+ RF_8258,
+ RF_PSEUDO_11N = 4,
+}RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
+#endif
+#define RTL8187_REQT_READ 0xc0
+#define RTL8187_REQT_WRITE 0x40
+#define RTL8187_REQ_GET_REGS 0x05
+#define RTL8187_REQ_SET_REGS 0x05
+
+#define MAX_TX_URB 16 //less URB will cause 2.4.31 crash, need to fix it further
+#define MAX_RX_URB 16
+
+#define R8180_MAX_RETRY 255
+//#define MAX_RX_NORMAL_URB 3
+//#define MAX_RX_COMMAND_URB 2
+#define RX_URB_SIZE 9100
+
+#define BB_ANTATTEN_CHAN14 0x0c
+#define BB_ANTENNA_B 0x40
+
+#define BB_HOST_BANG (1<<30)
+#define BB_HOST_BANG_EN (1<<2)
+#define BB_HOST_BANG_CLK (1<<1)
+#define BB_HOST_BANG_RW (1<<3)
+#define BB_HOST_BANG_DATA 1
+
+//#if (RTL819X_FPGA_VER & RTL819X_FPGA_VIVI_070920)
+#define AFR 0x010
+#define AFR_CardBEn (1<<0)
+#define AFR_CLKRUN_SEL (1<<1)
+#define AFR_FuncRegEn (1<<2)
+#define RTL8190_EEPROM_ID 0x8129
+#define EEPROM_VID 0x02
+#define EEPROM_PID 0x04
+#define EEPROM_NODE_ADDRESS_BYTE_0 0x0C
+
+#define EEPROM_TxPowerDiff 0x1F
+#define EEPROM_ThermalMeter 0x20
+#define EEPROM_PwDiff 0x21 //0x21
+#define EEPROM_CrystalCap 0x22 //0x22
+
+#define EEPROM_TxPwIndex_CCK 0x23 //0x23
+#define EEPROM_TxPwIndex_OFDM_24G 0x24 //0x24~0x26
+#define EEPROM_TxPwIndex_CCK_V1 0x29 //0x29~0x2B
+#define EEPROM_TxPwIndex_OFDM_24G_V1 0x2C //0x2C~0x2E
+#define EEPROM_TxPwIndex_Ver 0x27 //0x27
+
+#define EEPROM_Default_TxPowerDiff 0x0
+#define EEPROM_Default_ThermalMeter 0x7
+#define EEPROM_Default_PwDiff 0x4
+#define EEPROM_Default_CrystalCap 0x5
+#define EEPROM_Default_TxPower 0x1010
+#define EEPROM_Customer_ID 0x7B //0x7B:CustomerID
+#define EEPROM_ChannelPlan 0x16 //0x7C
+#define EEPROM_IC_VER 0x7d //0x7D
+#define EEPROM_CRC 0x7e //0x7E~0x7F
+
+#define EEPROM_CID_DEFAULT 0x0
+#define EEPROM_CID_CAMEO 0x1
+#define EEPROM_CID_RUNTOP 0x2
+#define EEPROM_CID_Senao 0x3
+#define EEPROM_CID_TOSHIBA 0x4 // Toshiba setting, Merge by Jacken, 2008/01/31
+#define EEPROM_CID_NetCore 0x5
+#define EEPROM_CID_Nettronix 0x6
+#define EEPROM_CID_Pronet 0x7
+#define EEPROM_CID_DLINK 0x8
+
+#define AC_PARAM_TXOP_LIMIT_OFFSET 16
+#define AC_PARAM_ECW_MAX_OFFSET 12
+#define AC_PARAM_ECW_MIN_OFFSET 8
+#define AC_PARAM_AIFS_OFFSET 0
+
+//#endif
+enum _RTL8192Usb_HW {
+
+ PCIF = 0x009, // PCI Function Register 0x0009h~0x000bh
+#define BB_GLOBAL_RESET_BIT 0x1
+ BB_GLOBAL_RESET = 0x020, // BasebandGlobal Reset Register
+ BSSIDR = 0x02E, // BSSID Register
+ CMDR = 0x037, // Command register
+#define CR_RST 0x10
+#define CR_RE 0x08
+#define CR_TE 0x04
+#define CR_MulRW 0x01
+ SIFS = 0x03E, // SIFS register
+ TCR = 0x040, // Transmit Configuration Register
+
+#define TCR_MXDMA_2048 7
+#define TCR_LRL_OFFSET 0
+#define TCR_SRL_OFFSET 8
+#define TCR_MXDMA_OFFSET 21
+#define TCR_SAT BIT24 // Enable Rate depedent ack timeout timer
+ RCR = 0x044, // Receive Configuration Register
+#define MAC_FILTER_MASK ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<5) | \
+ (1<<12) | (1<<18) | (1<<19) | (1<<20) | (1<<21) | (1<<22) | (1<<23))
+#define RX_FIFO_THRESHOLD_MASK ((1<<13) | (1<<14) | (1<<15))
+#define RX_FIFO_THRESHOLD_SHIFT 13
+#define RX_FIFO_THRESHOLD_128 3
+#define RX_FIFO_THRESHOLD_256 4
+#define RX_FIFO_THRESHOLD_512 5
+#define RX_FIFO_THRESHOLD_1024 6
+#define RX_FIFO_THRESHOLD_NONE 7
+#define MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10))
+#define RCR_MXDMA_OFFSET 8
+#define RCR_FIFO_OFFSET 13
+#define RCR_ONLYERLPKT BIT31 // Early Receiving based on Packet Size.
+#define RCR_ENCS2 BIT30 // Enable Carrier Sense Detection Method 2
+#define RCR_ENCS1 BIT29 // Enable Carrier Sense Detection Method 1
+#define RCR_ENMBID BIT27 // Enable Multiple BssId.
+#define RCR_ACKTXBW (BIT24|BIT25) // TXBW Setting of ACK frames
+#define RCR_CBSSID BIT23 // Accept BSSID match packet
+#define RCR_APWRMGT BIT22 // Accept power management packet
+#define RCR_ADD3 BIT21 // Accept address 3 match packet
+#define RCR_AMF BIT20 // Accept management type frame
+#define RCR_ACF BIT19 // Accept control type frame
+#define RCR_ADF BIT18 // Accept data type frame
+#define RCR_RXFTH BIT13 // Rx FIFO Threshold
+#define RCR_AICV BIT12 // Accept ICV error packet
+#define RCR_ACRC32 BIT5 // Accept CRC32 error packet
+#define RCR_AB BIT3 // Accept broadcast packet
+#define RCR_AM BIT2 // Accept multicast packet
+#define RCR_APM BIT1 // Accept physical match packet
+#define RCR_AAP BIT0 // Accept all unicast packet
+ SLOT_TIME = 0x049, // Slot Time Register
+ ACK_TIMEOUT = 0x04c, // Ack Timeout Register
+ PIFS_TIME = 0x04d, // PIFS time
+ USTIME = 0x04e, // Microsecond Tuning Register, Sets the microsecond time unit used by MAC clock.
+ EDCAPARA_BE = 0x050, // EDCA Parameter of AC BE
+ EDCAPARA_BK = 0x054, // EDCA Parameter of AC BK
+ EDCAPARA_VO = 0x058, // EDCA Parameter of AC VO
+ EDCAPARA_VI = 0x05C, // EDCA Parameter of AC VI
+ RFPC = 0x05F, // Rx FIFO Packet Count
+ CWRR = 0x060, // Contention Window Report Register
+ BCN_TCFG = 0x062, // Beacon Time Configuration
+#define BCN_TCFG_CW_SHIFT 8
+#define BCN_TCFG_IFS 0
+ BCN_INTERVAL = 0x070, // Beacon Interval (TU)
+ ATIMWND = 0x072, // ATIM Window Size (TU)
+ BCN_DRV_EARLY_INT = 0x074, // Driver Early Interrupt Time (TU). Time to send interrupt to notify to change beacon content before TBTT
+ BCN_DMATIME = 0x076, // Beacon DMA and ATIM interrupt time (US). Indicates the time before TBTT to perform beacon queue DMA
+ BCN_ERR_THRESH = 0x078, // Beacon Error Threshold
+ RWCAM = 0x0A0, //IN 8190 Data Sheet is called CAMcmd
+ WCAMI = 0x0A4, // Software write CAM input content
+ RCAMO = 0x0A8, // Software read/write CAM config
+ SECR = 0x0B0, //Security Configuration Register
+#define SCR_TxUseDK BIT0 //Force Tx Use Default Key
+#define SCR_RxUseDK BIT1 //Force Rx Use Default Key
+#define SCR_TxEncEnable BIT2 //Enable Tx Encryption
+#define SCR_RxDecEnable BIT3 //Enable Rx Decryption
+#define SCR_SKByA2 BIT4 //Search kEY BY A2
+#define SCR_NoSKMC BIT5 //No Key Search for Multicast
+#define SCR_UseDK 0x01
+#define SCR_TxSecEnable 0x02
+#define SCR_RxSecEnable 0x04
+ TPPoll = 0x0fd, // Transmit priority polling register
+ PSR = 0x0ff, // Page Select Register
+#define CPU_CCK_LOOPBACK 0x00030000
+#define CPU_GEN_SYSTEM_RESET 0x00000001
+#define CPU_GEN_FIRMWARE_RESET 0x00000008
+#define CPU_GEN_BOOT_RDY 0x00000010
+#define CPU_GEN_FIRM_RDY 0x00000020
+#define CPU_GEN_PUT_CODE_OK 0x00000080
+#define CPU_GEN_BB_RST 0x00000100
+#define CPU_GEN_PWR_STB_CPU 0x00000004
+#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19
+#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1
+
+//----------------------------------------------------------------------------
+// 8190 CPU General Register (offset 0x100, 4 byte)
+//----------------------------------------------------------------------------
+#define CPU_CCK_LOOPBACK 0x00030000
+#define CPU_GEN_SYSTEM_RESET 0x00000001
+#define CPU_GEN_FIRMWARE_RESET 0x00000008
+#define CPU_GEN_BOOT_RDY 0x00000010
+#define CPU_GEN_FIRM_RDY 0x00000020
+#define CPU_GEN_PUT_CODE_OK 0x00000080
+#define CPU_GEN_BB_RST 0x00000100
+#define CPU_GEN_PWR_STB_CPU 0x00000004
+#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19
+#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1
+ CPU_GEN = 0x100, // CPU Reset Register
+ LED1Cfg = 0x154,// LED1 Configuration Register
+ LED0Cfg = 0x155,// LED0 Configuration Register
+
+ AcmAvg = 0x170, // ACM Average Period Register
+ AcmHwCtrl = 0x171, // ACM Hardware Control Register
+//----------------------------------------------------------------------------
+////
+//// 8190 AcmHwCtrl bits (offset 0x171, 1 byte)
+////----------------------------------------------------------------------------
+//
+#define AcmHw_HwEn BIT0
+#define AcmHw_BeqEn BIT1
+#define AcmHw_ViqEn BIT2
+#define AcmHw_VoqEn BIT3
+#define AcmHw_BeqStatus BIT4
+#define AcmHw_ViqStatus BIT5
+#define AcmHw_VoqStatus BIT6
+
+ AcmFwCtrl = 0x172, // ACM Firmware Control Register
+ AES_11N_FIX = 0x173,
+ VOAdmTime = 0x174, // VO Queue Admitted Time Register
+ VIAdmTime = 0x178, // VI Queue Admitted Time Register
+ BEAdmTime = 0x17C, // BE Queue Admitted Time Register
+ RQPN1 = 0x180, // Reserved Queue Page Number , Vo Vi, Be, Bk
+ RQPN2 = 0x184, // Reserved Queue Page Number, HCCA, Cmd, Mgnt, High
+ RQPN3 = 0x188, // Reserved Queue Page Number, Bcn, Public,
+// QPRR = 0x1E0, // Queue Page Report per TID
+ QPNR = 0x1D0, //0x1F0, // Queue Packet Number report per TID
+ BQDA = 0x200, // Beacon Queue Descriptor Address
+ HQDA = 0x204, // High Priority Queue Descriptor Address
+ CQDA = 0x208, // Command Queue Descriptor Address
+ MQDA = 0x20C, // Management Queue Descriptor Address
+ HCCAQDA = 0x210, // HCCA Queue Descriptor Address
+ VOQDA = 0x214, // VO Queue Descriptor Address
+ VIQDA = 0x218, // VI Queue Descriptor Address
+ BEQDA = 0x21C, // BE Queue Descriptor Address
+ BKQDA = 0x220, // BK Queue Descriptor Address
+ RCQDA = 0x224, // Receive command Queue Descriptor Address
+ RDQDA = 0x228, // Receive Queue Descriptor Start Address
+
+ MAR0 = 0x240, // Multicast filter.
+ MAR4 = 0x244,
+
+ CCX_PERIOD = 0x250, // CCX Measurement Period Register, in unit of TU.
+ CLM_RESULT = 0x251, // CCA Busy fraction register.
+ NHM_PERIOD = 0x252, // NHM Measurement Period register, in unit of TU.
+
+ NHM_THRESHOLD0 = 0x253, // Noise Histogram Meashorement0.
+ NHM_THRESHOLD1 = 0x254, // Noise Histogram Meashorement1.
+ NHM_THRESHOLD2 = 0x255, // Noise Histogram Meashorement2.
+ NHM_THRESHOLD3 = 0x256, // Noise Histogram Meashorement3.
+ NHM_THRESHOLD4 = 0x257, // Noise Histogram Meashorement4.
+ NHM_THRESHOLD5 = 0x258, // Noise Histogram Meashorement5.
+ NHM_THRESHOLD6 = 0x259, // Noise Histogram Meashorement6
+
+ MCTRL = 0x25A, // Measurement Control
+
+ NHM_RPI_COUNTER0 = 0x264, // Noise Histogram RPI counter0, the fraction of signal strength < NHM_THRESHOLD0.
+ NHM_RPI_COUNTER1 = 0x265, // Noise Histogram RPI counter1, the fraction of signal strength in (NHM_THRESHOLD0, NHM_THRESHOLD1].
+ NHM_RPI_COUNTER2 = 0x266, // Noise Histogram RPI counter2, the fraction of signal strength in (NHM_THRESHOLD1, NHM_THRESHOLD2].
+ NHM_RPI_COUNTER3 = 0x267, // Noise Histogram RPI counter3, the fraction of signal strength in (NHM_THRESHOLD2, NHM_THRESHOLD3].
+ NHM_RPI_COUNTER4 = 0x268, // Noise Histogram RPI counter4, the fraction of signal strength in (NHM_THRESHOLD3, NHM_THRESHOLD4].
+ NHM_RPI_COUNTER5 = 0x269, // Noise Histogram RPI counter5, the fraction of signal strength in (NHM_THRESHOLD4, NHM_THRESHOLD5].
+ NHM_RPI_COUNTER6 = 0x26A, // Noise Histogram RPI counter6, the fraction of signal strength in (NHM_THRESHOLD5, NHM_THRESHOLD6].
+ NHM_RPI_COUNTER7 = 0x26B, // Noise Histogram RPI counter7, the fraction of signal strength in (NHM_THRESHOLD6, NHM_THRESHOLD7].
+#define BW_OPMODE_11J BIT0
+#define BW_OPMODE_5G BIT1
+#define BW_OPMODE_20MHZ BIT2
+ BW_OPMODE = 0x300, // Bandwidth operation mode
+ MSR = 0x303, // Media Status register
+#define MSR_LINK_MASK ((1<<0)|(1<<1))
+#define MSR_LINK_MANAGED 2
+#define MSR_LINK_NONE 0
+#define MSR_LINK_SHIFT 0
+#define MSR_LINK_ADHOC 1
+#define MSR_LINK_MASTER 3
+#define MSR_LINK_ENEDCA (1<<4)
+ RETRY_LIMIT = 0x304, // Retry Limit [15:8]-short, [7:0]-long
+#define RETRY_LIMIT_SHORT_SHIFT 8
+#define RETRY_LIMIT_LONG_SHIFT 0
+ TSFR = 0x308,
+ RRSR = 0x310, // Response Rate Set
+#define RRSR_RSC_OFFSET 21
+#define RRSR_SHORT_OFFSET 23
+#define RRSR_RSC_DUPLICATE 0x600000
+#define RRSR_RSC_LOWSUBCHNL 0x400000
+#define RRSR_RSC_UPSUBCHANL 0x200000
+#define RRSR_SHORT 0x800000
+#define RRSR_1M BIT0
+#define RRSR_2M BIT1
+#define RRSR_5_5M BIT2
+#define RRSR_11M BIT3
+#define RRSR_6M BIT4
+#define RRSR_9M BIT5
+#define RRSR_12M BIT6
+#define RRSR_18M BIT7
+#define RRSR_24M BIT8
+#define RRSR_36M BIT9
+#define RRSR_48M BIT10
+#define RRSR_54M BIT11
+#define RRSR_MCS0 BIT12
+#define RRSR_MCS1 BIT13
+#define RRSR_MCS2 BIT14
+#define RRSR_MCS3 BIT15
+#define RRSR_MCS4 BIT16
+#define RRSR_MCS5 BIT17
+#define RRSR_MCS6 BIT18
+#define RRSR_MCS7 BIT19
+#define BRSR_AckShortPmb BIT23 // CCK ACK: use Short Preamble or not.
+ RATR0 = 0x320, // Rate Adaptive Table register1
+ UFWP = 0x318,
+ DRIVER_RSSI = 0x32c, // Driver tell Firmware current RSSI
+//----------------------------------------------------------------------------
+// 8190 Rate Adaptive Table Register (offset 0x320, 4 byte)
+//----------------------------------------------------------------------------
+//CCK
+#define RATR_1M 0x00000001
+#define RATR_2M 0x00000002
+#define RATR_55M 0x00000004
+#define RATR_11M 0x00000008
+//OFDM
+#define RATR_6M 0x00000010
+#define RATR_9M 0x00000020
+#define RATR_12M 0x00000040
+#define RATR_18M 0x00000080
+#define RATR_24M 0x00000100
+#define RATR_36M 0x00000200
+#define RATR_48M 0x00000400
+#define RATR_54M 0x00000800
+//MCS 1 Spatial Stream
+#define RATR_MCS0 0x00001000
+#define RATR_MCS1 0x00002000
+#define RATR_MCS2 0x00004000
+#define RATR_MCS3 0x00008000
+#define RATR_MCS4 0x00010000
+#define RATR_MCS5 0x00020000
+#define RATR_MCS6 0x00040000
+#define RATR_MCS7 0x00080000
+//MCS 2 Spatial Stream
+#define RATR_MCS8 0x00100000
+#define RATR_MCS9 0x00200000
+#define RATR_MCS10 0x00400000
+#define RATR_MCS11 0x00800000
+#define RATR_MCS12 0x01000000
+#define RATR_MCS13 0x02000000
+#define RATR_MCS14 0x04000000
+#define RATR_MCS15 0x08000000
+// ALL CCK Rate
+#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M
+#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M\
+ |RATR_36M|RATR_48M|RATR_54M
+#define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 | \
+ RATR_MCS4|RATR_MCS5|RATR_MCS6|RATR_MCS7
+#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11| \
+ RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15
+
+ MCS_TXAGC = 0x340, // MCS AGC
+ CCK_TXAGC = 0x348, // CCK AGC
+// ISR = 0x350, // Interrupt Status Register
+// IMR = 0x354, // Interrupt Mask Register
+// IMR_POLL = 0x360,
+ MacBlkCtrl = 0x403, // Mac block on/off control register
+
+ EPROM_CMD = 0xfe58,
+#define Cmd9346CR_9356SEL (1<<4)
+#define EPROM_CMD_RESERVED_MASK (1<<5)
+#define EPROM_CMD_OPERATING_MODE_SHIFT 6
+#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6))
+#define EPROM_CMD_CONFIG 0x3
+#define EPROM_CMD_NORMAL 0
+#define EPROM_CMD_LOAD 1
+#define EPROM_CMD_PROGRAM 2
+#define EPROM_CS_SHIFT 3
+#define EPROM_CK_SHIFT 2
+#define EPROM_W_SHIFT 1
+#define EPROM_R_SHIFT 0
+ MAC0 = 0x000,
+ MAC1 = 0x001,
+ MAC2 = 0x002,
+ MAC3 = 0x003,
+ MAC4 = 0x004,
+ MAC5 = 0x005,
+
+#if 0
+/* 0x0006 - 0x0007 - reserved */
+ RXFIFOCOUNT = 0x010,
+ TXFIFOCOUNT = 0x012,
+ BQREQ = 0x013,
+/* 0x0010 - 0x0017 - reserved */
+ TSFTR = 0x018,
+ TLPDA = 0x020,
+ TNPDA = 0x024,
+ THPDA = 0x028,
+ BSSID = 0x02E,
+ RESP_RATE = 0x034,
+ CMD = 0x037,
+#define CMD_RST_SHIFT 4
+#define CMD_RESERVED_MASK ((1<<1) | (1<<5) | (1<<6) | (1<<7))
+#define CMD_RX_ENABLE_SHIFT 3
+#define CMD_TX_ENABLE_SHIFT 2
+#define CR_RST ((1<< 4))
+#define CR_RE ((1<< 3))
+#define CR_TE ((1<< 2))
+#define CR_MulRW ((1<< 0))
+
+ INTA_MASK = 0x03c,
+ INTA = 0x03e,
+#define INTA_TXOVERFLOW (1<<15)
+#define INTA_TIMEOUT (1<<14)
+#define INTA_BEACONTIMEOUT (1<<13)
+#define INTA_ATIM (1<<12)
+#define INTA_BEACONDESCERR (1<<11)
+#define INTA_BEACONDESCOK (1<<10)
+#define INTA_HIPRIORITYDESCERR (1<<9)
+#define INTA_HIPRIORITYDESCOK (1<<8)
+#define INTA_NORMPRIORITYDESCERR (1<<7)
+#define INTA_NORMPRIORITYDESCOK (1<<6)
+#define INTA_RXOVERFLOW (1<<5)
+#define INTA_RXDESCERR (1<<4)
+#define INTA_LOWPRIORITYDESCERR (1<<3)
+#define INTA_LOWPRIORITYDESCOK (1<<2)
+#define INTA_RXCRCERR (1<<1)
+#define INTA_RXOK (1)
+ TX_CONF = 0x040,
+#define TX_CONF_HEADER_AUTOICREMENT_SHIFT 30
+#define TX_LOOPBACK_SHIFT 17
+#define TX_LOOPBACK_MAC 1
+#define TX_LOOPBACK_BASEBAND 2
+#define TX_LOOPBACK_NONE 0
+#define TX_LOOPBACK_CONTINUE 3
+#define TX_LOOPBACK_MASK ((1<<17)|(1<<18))
+#define TX_LRLRETRY_SHIFT 0
+#define TX_SRLRETRY_SHIFT 8
+#define TX_NOICV_SHIFT 19
+#define TX_NOCRC_SHIFT 16
+#define TCR_DurProcMode ((1<<30))
+#define TCR_DISReqQsize ((1<<28))
+#define TCR_HWVERID_MASK ((1<<27)|(1<<26)|(1<<25))
+#define TCR_HWVERID_SHIFT 25
+#define TCR_SWPLCPLEN ((1<<24))
+#define TCR_PLCP_LEN TCR_SAT // rtl8180
+#define TCR_MXDMA_MASK ((1<<23)|(1<<22)|(1<<21))
+#define TCR_MXDMA_1024 6
+#define TCR_MXDMA_2048 7
+#define TCR_MXDMA_SHIFT 21
+#define TCR_DISCW ((1<<20))
+#define TCR_ICV ((1<<19))
+#define TCR_LBK ((1<<18)|(1<<17))
+#define TCR_LBK1 ((1<<18))
+#define TCR_LBK0 ((1<<17))
+#define TCR_CRC ((1<<16))
+#define TCR_SRL_MASK ((1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8))
+#define TCR_LRL_MASK ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7))
+#define TCR_PROBE_NOTIMESTAMP_SHIFT 29 //rtl8185
+ RX_CONF = 0x044,
+#define MAC_FILTER_MASK ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<5) | \
+(1<<12) | (1<<18) | (1<<19) | (1<<20) | (1<<21) | (1<<22) | (1<<23))
+#define RX_CHECK_BSSID_SHIFT 23
+#define ACCEPT_PWR_FRAME_SHIFT 22
+#define ACCEPT_MNG_FRAME_SHIFT 20
+#define ACCEPT_CTL_FRAME_SHIFT 19
+#define ACCEPT_DATA_FRAME_SHIFT 18
+#define ACCEPT_ICVERR_FRAME_SHIFT 12
+#define ACCEPT_CRCERR_FRAME_SHIFT 5
+#define ACCEPT_BCAST_FRAME_SHIFT 3
+#define ACCEPT_MCAST_FRAME_SHIFT 2
+#define ACCEPT_ALLMAC_FRAME_SHIFT 0
+#define ACCEPT_NICMAC_FRAME_SHIFT 1
+#define RX_FIFO_THRESHOLD_MASK ((1<<13) | (1<<14) | (1<<15))
+#define RX_FIFO_THRESHOLD_SHIFT 13
+#define RX_FIFO_THRESHOLD_128 3
+#define RX_FIFO_THRESHOLD_256 4
+#define RX_FIFO_THRESHOLD_512 5
+#define RX_FIFO_THRESHOLD_1024 6
+#define RX_FIFO_THRESHOLD_NONE 7
+#define RX_AUTORESETPHY_SHIFT 28
+#define MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10))
+#define MAX_RX_DMA_2048 7
+#define MAX_RX_DMA_1024 6
+#define MAX_RX_DMA_SHIFT 10
+#define RCR_ONLYERLPKT ((1<<31))
+#define RCR_CS_SHIFT 29
+#define RCR_CS_MASK ((1<<30) | (1<<29))
+#define RCR_ENMARP ((1<<28))
+#define RCR_CBSSID ((1<<23))
+#define RCR_APWRMGT ((1<<22))
+#define RCR_ADD3 ((1<<21))
+#define RCR_AMF ((1<<20))
+#define RCR_ACF ((1<<19))
+#define RCR_ADF ((1<<18))
+#define RCR_RXFTH ((1<<15)|(1<<14)|(1<<13))
+#define RCR_RXFTH2 ((1<<15))
+#define RCR_RXFTH1 ((1<<14))
+#define RCR_RXFTH0 ((1<<13))
+#define RCR_AICV ((1<<12))
+#define RCR_MXDMA ((1<<10)|(1<< 9)|(1<< 8))
+#define RCR_MXDMA2 ((1<<10))
+#define RCR_MXDMA1 ((1<< 9))
+#define RCR_MXDMA0 ((1<< 8))
+#define RCR_9356SEL ((1<< 6))
+#define RCR_ACRC32 ((1<< 5))
+#define RCR_AB ((1<< 3))
+#define RCR_AM ((1<< 2))
+#define RCR_APM ((1<< 1))
+#define RCR_AAP ((1<< 0))
+ INT_TIMEOUT = 0x048,
+ TX_BEACON_RING_ADDR = 0x04c,
+ EPROM_CMD = 0x58,
+#define EPROM_CMD_RESERVED_MASK ((1<<5)|(1<<4))
+#define EPROM_CMD_OPERATING_MODE_SHIFT 6
+#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6))
+#define EPROM_CMD_CONFIG 0x3
+#define EPROM_CMD_NORMAL 0
+#define EPROM_CMD_LOAD 1
+#define EPROM_CMD_PROGRAM 2
+#define EPROM_CS_SHIFT 3
+#define EPROM_CK_SHIFT 2
+#define EPROM_W_SHIFT 1
+#define EPROM_R_SHIFT 0
+ CONFIG0 = 0x051,
+#define CONFIG0_WEP104 ((1<<6))
+#define CONFIG0_LEDGPO_En ((1<<4))
+#define CONFIG0_Aux_Status ((1<<3))
+#define CONFIG0_GL ((1<<1)|(1<<0))
+#define CONFIG0_GL1 ((1<<1))
+#define CONFIG0_GL0 ((1<<0))
+ CONFIG1 = 0x052,
+#define CONFIG1_LEDS ((1<<7)|(1<<6))
+#define CONFIG1_LEDS1 ((1<<7))
+#define CONFIG1_LEDS0 ((1<<6))
+#define CONFIG1_LWACT ((1<<4))
+#define CONFIG1_MEMMAP ((1<<3))
+#define CONFIG1_IOMAP ((1<<2))
+#define CONFIG1_VPD ((1<<1))
+#define CONFIG1_PMEn ((1<<0))
+ CONFIG2 = 0x053,
+#define CONFIG2_LCK ((1<<7))
+#define CONFIG2_ANT ((1<<6))
+#define CONFIG2_DPS ((1<<3))
+#define CONFIG2_PAPE_sign ((1<<2))
+#define CONFIG2_PAPE_time ((1<<1)|(1<<0))
+#define CONFIG2_PAPE_time1 ((1<<1))
+#define CONFIG2_PAPE_time0 ((1<<0))
+ ANA_PARAM = 0x054,
+ CONFIG3 = 0x059,
+#define CONFIG3_GNTSel ((1<<7))
+#define CONFIG3_PARM_En ((1<<6))
+#define CONFIG3_Magic ((1<<5))
+#define CONFIG3_CardB_En ((1<<3))
+#define CONFIG3_CLKRUN_En ((1<<2))
+#define CONFIG3_FuncRegEn ((1<<1))
+#define CONFIG3_FBtbEn ((1<<0))
+#define CONFIG3_CLKRUN_SHIFT 2
+#define CONFIG3_ANAPARAM_W_SHIFT 6
+ CONFIG4 = 0x05a,
+#define CONFIG4_VCOPDN ((1<<7))
+#define CONFIG4_PWROFF ((1<<6))
+#define CONFIG4_PWRMGT ((1<<5))
+#define CONFIG4_LWPME ((1<<4))
+#define CONFIG4_LWPTN ((1<<2))
+#define CONFIG4_RFTYPE ((1<<1)|(1<<0))
+#define CONFIG4_RFTYPE1 ((1<<1))
+#define CONFIG4_RFTYPE0 ((1<<0))
+ TESTR = 0x05b,
+#define TFPC_AC 0x05C
+
+#define SCR 0x05F
+ PGSELECT = 0x05e,
+#define PGSELECT_PG_SHIFT 0
+ SECURITY = 0x05f,
+#define SECURITY_WEP_TX_ENABLE_SHIFT 1
+#define SECURITY_WEP_RX_ENABLE_SHIFT 0
+#define SECURITY_ENCRYP_104 1
+#define SECURITY_ENCRYP_SHIFT 4
+#define SECURITY_ENCRYP_MASK ((1<<4)|(1<<5))
+ ANA_PARAM2 = 0x060,
+ BEACON_INTERVAL = 0x070,
+#define BEACON_INTERVAL_MASK ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)| \
+(1<<6)|(1<<7)|(1<<8)|(1<<9))
+ ATIM_WND = 0x072,
+#define ATIM_WND_MASK (0x01FF)
+ BCN_INTR_ITV = 0x074,
+#define BCN_INTR_ITV_MASK (0x01FF)
+ ATIM_INTR_ITV = 0x076,
+#define ATIM_INTR_ITV_MASK (0x01FF)
+ AckTimeOutReg = 0x079, //ACK timeout register, in unit of 4 us.
+ PHY_ADR = 0x07c,
+ PHY_READ = 0x07e,
+ RFPinsOutput = 0x080,
+ RFPinsEnable = 0x082,
+
+//Page 0
+ RFPinsSelect = 0x084,
+#define SW_CONTROL_GPIO 0x400
+ RFPinsInput = 0x086,
+ RF_PARA = 0x088,
+ RF_TIMING = 0x08c,
+ GP_ENABLE = 0x090,
+ GPIO = 0x091,
+ TX_AGC_CTL = 0x09c,
+#define TX_AGC_CTL_PER_PACKET_TXAGC 0x01
+#define TX_AGC_CTL_PERPACKET_GAIN_SHIFT 0
+#define TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT 1
+#define TX_AGC_CTL_FEEDBACK_ANT 2
+#define TXAGC_CTL_PER_PACKET_ANT_SEL 0x02
+ OFDM_TXAGC = 0x09e,
+ ANTSEL = 0x09f,
+ WPA_CONFIG = 0x0b0,
+ SIFS = 0x0b4,
+ DIFS = 0x0b5,
+ SLOT = 0x0b6,
+ CW_CONF = 0x0bc,
+#define CW_CONF_PERPACKET_RETRY_LIMIT 0x02
+#define CW_CONF_PERPACKET_CW 0x01
+#define CW_CONF_PERPACKET_RETRY_SHIFT 1
+#define CW_CONF_PERPACKET_CW_SHIFT 0
+ CW_VAL = 0x0bd,
+ RATE_FALLBACK = 0x0be,
+#define MAX_RESP_RATE_SHIFT 4
+#define MIN_RESP_RATE_SHIFT 0
+#define RATE_FALLBACK_CTL_ENABLE 0x80
+#define RATE_FALLBACK_CTL_AUTO_STEP0 0x00
+ ACM_CONTROL = 0x0BF, // ACM Control Registe
+//----------------------------------------------------------------------------
+// 8187B ACM_CONTROL bits (Offset 0xBF, 1 Byte)
+//----------------------------------------------------------------------------
+#define VOQ_ACM_EN (0x01 << 7) //BIT7
+#define VIQ_ACM_EN (0x01 << 6) //BIT6
+#define BEQ_ACM_EN (0x01 << 5) //BIT5
+#define ACM_HW_EN (0x01 << 4) //BIT4
+#define TXOPSEL (0x01 << 3) //BIT3
+#define VOQ_ACM_CTL (0x01 << 2) //BIT2 // Set to 1 when AC_VO used time reaches or exceeds the admitted time
+#define VIQ_ACM_CTL (0x01 << 1) //BIT1 // Set to 1 when AC_VI used time reaches or exceeds the admitted time
+#define BEQ_ACM_CTL (0x01 << 0) //BIT0 // Set to 1 when AC_BE used time reaches or exceeds the admitted time
+ CONFIG5 = 0x0D8,
+#define CONFIG5_TX_FIFO_OK ((1<<7))
+#define CONFIG5_RX_FIFO_OK ((1<<6))
+#define CONFIG5_CALON ((1<<5))
+#define CONFIG5_EACPI ((1<<2))
+#define CONFIG5_LANWake ((1<<1))
+#define CONFIG5_PME_STS ((1<<0))
+ TX_DMA_POLLING = 0x0d9,
+#define TX_DMA_POLLING_BEACON_SHIFT 7
+#define TX_DMA_POLLING_HIPRIORITY_SHIFT 6
+#define TX_DMA_POLLING_NORMPRIORITY_SHIFT 5
+#define TX_DMA_POLLING_LOWPRIORITY_SHIFT 4
+#define TX_DMA_STOP_BEACON_SHIFT 3
+#define TX_DMA_STOP_HIPRIORITY_SHIFT 2
+#define TX_DMA_STOP_NORMPRIORITY_SHIFT 1
+#define TX_DMA_STOP_LOWPRIORITY_SHIFT 0
+ CWR = 0x0DC,
+ RetryCTR = 0x0DE,
+ INT_MIG = 0x0E2, // Interrupt Migration (0xE2 ~ 0xE3)
+ TID_AC_MAP = 0x0E8, // TID to AC Mapping Register
+ ANA_PARAM3 = 0x0EE,
+
+
+//page 1
+ Wakeup0 = 0x084,
+ Wakeup1 = 0x08C,
+ Wakeup2LD = 0x094,
+ Wakeup2HD = 0x09C,
+ Wakeup3LD = 0x0A4,
+ Wakeup3HD = 0x0AC,
+ Wakeup4LD = 0x0B4,
+ Wakeup4HD = 0x0BC,
+ CRC0 = 0x0C4,
+ CRC1 = 0x0C6,
+ CRC2 = 0x0C8,
+ CRC3 = 0x0CA,
+ CRC4 = 0x0CC,
+/* 0x00CE - 0x00D3 - reserved */
+
+ RFSW_CTRL = 0x272, // 0x272-0x273.
+
+//Reg Diff between rtl8187 and rtl8187B
+/**************************************************************************/
+ BRSR_8187 = 0x02C,
+ BRSR_8187B = 0x034,
+#define BRSR_BPLCP ((1<< 8))
+#define BRSR_MBR ((1<< 1)|(1<< 0))
+#define BRSR_MBR_8185 ((1<< 11)|(1<< 10)|(1<< 9)|(1<< 8)|(1<< 7)|(1<< 6)|(1<< 5)|(1<< 4)|(1<< 3)|(1<< 2)|(1<< 1)|(1<< 0))
+#define BRSR_MBR0 ((1<< 0))
+#define BRSR_MBR1 ((1<< 1))
+
+/**************************************************************************/
+ EIFS_8187 = 0x035,
+ EIFS_8187B = 0x02D,
+
+/**************************************************************************/
+ FER = 0x0F0,
+ FEMR = 0x0F4,
+ FPSR = 0x0F8,
+ FFER = 0x0FC,
+
+ AC_VO_PARAM = 0x0F0, // AC_VO Parameters Record
+ AC_VI_PARAM = 0x0F4, // AC_VI Parameters Record
+ AC_BE_PARAM = 0x0F8, // AC_BE Parameters Record
+ AC_BK_PARAM = 0x0FC, // AC_BK Parameters Record
+ TALLY_SEL = 0x0fc,
+//----------------------------------------------------------------------------
+// 8187B AC_XX_PARAM bits
+//----------------------------------------------------------------------------
+#define AC_PARAM_TXOP_LIMIT_OFFSET 16
+#define AC_PARAM_ECW_MAX_OFFSET 12
+#define AC_PARAM_ECW_MIN_OFFSET 8
+#define AC_PARAM_AIFS_OFFSET 0
+
+#endif
+};
+//----------------------------------------------------------------------------
+// 818xB AnaParm & AnaParm2 Register
+//----------------------------------------------------------------------------
+//#define ANAPARM_ASIC_ON 0x45090658
+//#define ANAPARM2_ASIC_ON 0x727f3f52
+#define GPI 0x108
+#define GPO 0x109
+#define GPE 0x10a
+#endif
diff --git a/drivers/staging/rtl8192su/r8192U_pm.c b/drivers/staging/rtl8192su/r8192U_pm.c
new file mode 100644
index 000000000000..92c95aa36638
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_pm.c
@@ -0,0 +1,77 @@
+/*
+ Power management interface routines.
+ Written by Mariusz Matuszek.
+ This code is currently just a placeholder for later work and
+ does not do anything useful.
+
+ This is part of rtl8180 OpenSource driver.
+ Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+*/
+
+#ifdef CONFIG_RTL8192_PM
+#include "r8192U.h"
+#include "r8192U_pm.h"
+
+/*****************************************************************************/
+int rtl8192U_save_state (struct pci_dev *dev, u32 state)
+{
+ printk(KERN_NOTICE "r8192U save state call (state %u).\n", state);
+ return(-EAGAIN);
+}
+
+int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct net_device *dev = usb_get_intfdata(intf);
+#else
+ //struct net_device *dev = (struct net_device *)ptr;
+#endif
+ RT_TRACE(COMP_POWER, "============> r8192U suspend call.\n");
+
+ if(dev) {
+ if (!netif_running(dev)) {
+ printk(KERN_WARNING "netif not running, go out suspend function\n");
+ return 0;
+ }
+
+ dev->stop(dev);
+ mdelay(10);
+
+ netif_device_detach(dev);
+ }
+
+ return 0;
+}
+
+int rtl8192U_resume (struct usb_interface *intf)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct net_device *dev = usb_get_intfdata(intf);
+#else
+ //struct net_device *dev = (struct net_device *)ptr;
+#endif
+
+ RT_TRACE(COMP_POWER, "================>r8192U resume call.");
+
+ if(dev) {
+ if (!netif_running(dev)){
+ printk(KERN_WARNING "netif not running, go out resume function\n");
+ return 0;
+ }
+
+ netif_device_attach(dev);
+ dev->open(dev);
+ }
+
+ return 0;
+}
+
+int rtl8192U_enable_wake (struct pci_dev *dev, u32 state, int enable)
+{
+ printk(KERN_NOTICE "r8192U enable wake call (state %u, enable %d).\n",
+ state, enable);
+ return(-EAGAIN);
+}
+
+#endif //CONFIG_RTL8192_PM
diff --git a/drivers/staging/rtl8192su/r8192U_pm.h b/drivers/staging/rtl8192su/r8192U_pm.h
new file mode 100644
index 000000000000..ab025d64f5e2
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_pm.h
@@ -0,0 +1,27 @@
+/*
+ Power management interface routines.
+ Written by Mariusz Matuszek.
+ This code is currently just a placeholder for later work and
+ does not do anything useful.
+
+ This is part of rtl8180 OpenSource driver.
+ Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+*/
+
+#ifdef CONFIG_RTL8192_PM
+
+#ifndef R8192_PM_H
+#define R8192_PM_H
+
+#include <linux/types.h>
+#include <linux/usb.h>
+
+int rtl8192U_save_tate (struct pci_dev *dev, u32 state);
+int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state);
+int rtl8192U_resume (struct usb_interface *intf);
+int rtl8192U_enable_wake (struct pci_dev *dev, u32 state, int enable);
+
+#endif //R8192U_PM_H
+#endif // CONFIG_RTL8192_PM
diff --git a/drivers/staging/rtl8192su/r8192U_wx.c b/drivers/staging/rtl8192su/r8192U_wx.c
new file mode 100644
index 000000000000..f9eafb16dbb7
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_wx.c
@@ -0,0 +1,1350 @@
+/*
+ This file contains wireless extension handlers.
+
+ This is part of rtl8180 OpenSource driver.
+ Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+ Parts of this driver are based on the GPL part
+ of the official realtek driver.
+
+ Parts of this driver are based on the rtl8180 driver skeleton
+ from Patric Schenke & Andres Salomon.
+
+ Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
+
+ We want to tanks the Authors of those projects and the Ndiswrapper
+ project Authors.
+*/
+
+#ifdef RTL8192SU
+#include <linux/string.h>
+#include "r8192U.h"
+#include "r8192S_hw.h"
+#else
+#include <linux/string.h>
+#include "r8192U.h"
+#include "r8192U_hw.h"
+#endif
+
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+
+#define RATE_COUNT 12
+u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
+ 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000};
+
+
+#ifndef ENETDOWN
+#define ENETDOWN 1
+#endif
+
+static int r8192_wx_get_freq(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b);
+}
+
+
+#if 0
+
+static int r8192_wx_set_beaconinterval(struct net_device *dev, struct iw_request_info *aa,
+ union iwreq_data *wrqu, char *b)
+{
+ int *parms = (int *)b;
+ int bi = parms[0];
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+ DMESG("setting beacon interval to %x",bi);
+
+ priv->ieee80211->beacon_interval=bi;
+ rtl8180_commit(dev);
+ up(&priv->wx_sem);
+
+ return 0;
+}
+
+
+static int r8192_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv=ieee80211_priv(dev);
+ int *parms = (int *)extra;
+
+ priv->ieee80211->force_associate = (parms[0] > 0);
+
+
+ return 0;
+}
+
+#endif
+static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct r8192_priv *priv=ieee80211_priv(dev);
+
+ return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b);
+}
+
+
+
+static int r8192_wx_get_rate(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra);
+}
+
+
+
+static int r8192_wx_set_rate(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra);
+
+ up(&priv->wx_sem);
+
+ return ret;
+}
+
+
+static int r8192_wx_set_rts(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_rts(priv->ieee80211,info,wrqu,extra);
+
+ up(&priv->wx_sem);
+
+ return ret;
+}
+
+static int r8192_wx_get_rts(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ return ieee80211_wx_get_rts(priv->ieee80211,info,wrqu,extra);
+}
+
+static int r8192_wx_set_power(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_power(priv->ieee80211,info,wrqu,extra);
+
+ up(&priv->wx_sem);
+
+ return ret;
+}
+
+static int r8192_wx_get_power(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ return ieee80211_wx_get_power(priv->ieee80211,info,wrqu,extra);
+}
+
+#ifdef JOHN_IOCTL
+u16 read_rtl8225(struct net_device *dev, u8 addr);
+void write_rtl8225(struct net_device *dev, u8 adr, u16 data);
+u32 john_read_rtl8225(struct net_device *dev, u8 adr);
+void _write_rtl8225(struct net_device *dev, u8 adr, u16 data);
+
+static int r8192_wx_read_regs(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 addr;
+ u16 data1;
+
+ down(&priv->wx_sem);
+
+
+ get_user(addr,(u8*)wrqu->data.pointer);
+ data1 = read_rtl8225(dev, addr);
+ wrqu->data.length = data1;
+
+ up(&priv->wx_sem);
+ return 0;
+
+}
+
+static int r8192_wx_write_regs(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 addr;
+
+ down(&priv->wx_sem);
+
+ get_user(addr, (u8*)wrqu->data.pointer);
+ write_rtl8225(dev, addr, wrqu->data.length);
+
+ up(&priv->wx_sem);
+ return 0;
+
+}
+
+void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data);
+u8 rtl8187_read_phy(struct net_device *dev,u8 adr, u32 data);
+
+static int r8192_wx_read_bb(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 databb;
+#if 0
+ int i;
+ for(i=0;i<12;i++) printk("%8x\n", read_cam(dev, i) );
+#endif
+
+ down(&priv->wx_sem);
+
+ databb = rtl8187_read_phy(dev, (u8)wrqu->data.length, 0x00000000);
+ wrqu->data.length = databb;
+
+ up(&priv->wx_sem);
+ return 0;
+}
+
+void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data);
+static int r8192_wx_write_bb(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 databb;
+
+ down(&priv->wx_sem);
+
+ get_user(databb, (u8*)wrqu->data.pointer);
+ rtl8187_write_phy(dev, wrqu->data.length, databb);
+
+ up(&priv->wx_sem);
+ return 0;
+
+}
+
+
+static int r8192_wx_write_nicb(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 addr;
+
+ down(&priv->wx_sem);
+
+ get_user(addr, (u32*)wrqu->data.pointer);
+ write_nic_byte(dev, addr, wrqu->data.length);
+
+ up(&priv->wx_sem);
+ return 0;
+
+}
+static int r8192_wx_read_nicb(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 addr;
+ u16 data1;
+
+ down(&priv->wx_sem);
+
+ get_user(addr,(u32*)wrqu->data.pointer);
+ data1 = read_nic_byte(dev, addr);
+ wrqu->data.length = data1;
+
+ up(&priv->wx_sem);
+ return 0;
+}
+
+static int r8192_wx_get_ap_status(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device *ieee = priv->ieee80211;
+ struct ieee80211_network *target;
+ int name_len;
+
+ down(&priv->wx_sem);
+
+ //count the length of input ssid
+ for(name_len=0 ; ((char*)wrqu->data.pointer)[name_len]!='\0' ; name_len++);
+
+ //search for the correspoding info which is received
+ list_for_each_entry(target, &ieee->network_list, list) {
+ if ( (target->ssid_len == name_len) &&
+ (strncmp(target->ssid, (char*)wrqu->data.pointer, name_len)==0)){
+ if(target->wpa_ie_len>0 || target->rsn_ie_len>0 )
+ //set flags=1 to indicate this ap is WPA
+ wrqu->data.flags = 1;
+ else wrqu->data.flags = 0;
+
+
+ break;
+ }
+ }
+
+ up(&priv->wx_sem);
+ return 0;
+}
+
+
+
+#endif
+#if 0
+static int r8192_wx_null(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ return 0;
+}
+#endif
+static int r8192_wx_force_reset(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+
+ printk("%s(): force reset ! extra is %d\n",__FUNCTION__, *extra);
+ priv->force_reset = *extra;
+ up(&priv->wx_sem);
+ return 0;
+
+}
+
+#ifdef RTL8192SU
+static int r8191su_wx_get_firm_version(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 firmware_version;
+
+ down(&priv->wx_sem);
+ firmware_version = priv->pFirmware->FirmwareVersion;
+ wrqu->value = firmware_version;
+ wrqu->fixed = 1;
+
+ up(&priv->wx_sem);
+ return 0;
+}
+#endif
+
+
+
+static int r8192_wx_set_rawtx(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int ret;
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
+
+ up(&priv->wx_sem);
+
+ return ret;
+
+}
+
+static int r8192_wx_set_crcmon(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int *parms = (int *)extra;
+ int enable = (parms[0] > 0);
+ short prev = priv->crcmon;
+
+ down(&priv->wx_sem);
+
+ if(enable)
+ priv->crcmon=1;
+ else
+ priv->crcmon=0;
+
+ DMESG("bad CRC in monitor mode are %s",
+ priv->crcmon ? "accepted" : "rejected");
+
+ if(prev != priv->crcmon && priv->up){
+ //rtl8180_down(dev);
+ //rtl8180_up(dev);
+ }
+
+ up(&priv->wx_sem);
+
+ return 0;
+}
+
+static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int ret;
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b);
+
+ rtl8192_set_rxconf(dev);
+
+ up(&priv->wx_sem);
+ return ret;
+}
+
+struct iw_range_with_scan_capa
+{
+ /* Informative stuff (to choose between different interface) */
+ __u32 throughput; /* To give an idea... */
+ /* In theory this value should be the maximum benchmarked
+ * TCP/IP throughput, because with most of these devices the
+ * bit rate is meaningless (overhead an co) to estimate how
+ * fast the connection will go and pick the fastest one.
+ * I suggest people to play with Netperf or any benchmark...
+ */
+
+ /* NWID (or domain id) */
+ __u32 min_nwid; /* Minimal NWID we are able to set */
+ __u32 max_nwid; /* Maximal NWID we are able to set */
+
+ /* Old Frequency (backward compat - moved lower ) */
+ __u16 old_num_channels;
+ __u8 old_num_frequency;
+
+ /* Scan capabilities */
+ __u8 scan_capa;
+};
+static int rtl8180_wx_get_range(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_range *range = (struct iw_range *)extra;
+ struct iw_range_with_scan_capa* tmp = (struct iw_range_with_scan_capa*)range;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 val;
+ int i;
+
+ wrqu->data.length = sizeof(*range);
+ memset(range, 0, sizeof(*range));
+
+ /* Let's try to keep this struct in the same order as in
+ * linux/include/wireless.h
+ */
+
+ /* TODO: See what values we can set, and remove the ones we can't
+ * set, or fill them with some default data.
+ */
+
+ /* ~5 Mb/s real (802.11b) */
+ range->throughput = 5 * 1000 * 1000;
+
+ // TODO: Not used in 802.11b?
+// range->min_nwid; /* Minimal NWID we are able to set */
+ // TODO: Not used in 802.11b?
+// range->max_nwid; /* Maximal NWID we are able to set */
+
+ /* Old Frequency (backward compat - moved lower ) */
+// range->old_num_channels;
+// range->old_num_frequency;
+// range->old_freq[6]; /* Filler to keep "version" at the same offset */
+ if(priv->rf_set_sens != NULL)
+ range->sensitivity = priv->max_sens; /* signal level threshold range */
+
+ range->max_qual.qual = 100;
+ /* TODO: Find real max RSSI and stick here */
+ range->max_qual.level = 0;
+ range->max_qual.noise = -98;
+ range->max_qual.updated = 7; /* Updated all three */
+
+ range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
+ /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
+ range->avg_qual.level = 20 + -98;
+ range->avg_qual.noise = 0;
+ range->avg_qual.updated = 7; /* Updated all three */
+
+ range->num_bitrates = RATE_COUNT;
+
+ for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
+ range->bitrate[i] = rtl8180_rates[i];
+ }
+
+ range->min_frag = MIN_FRAG_THRESHOLD;
+ range->max_frag = MAX_FRAG_THRESHOLD;
+
+ range->min_pmp=0;
+ range->max_pmp = 5000000;
+ range->min_pmt = 0;
+ range->max_pmt = 65535*1000;
+ range->pmp_flags = IW_POWER_PERIOD;
+ range->pmt_flags = IW_POWER_TIMEOUT;
+ range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
+
+ range->we_version_compiled = WIRELESS_EXT;
+ range->we_version_source = 16;
+
+// range->retry_capa; /* What retry options are supported */
+// range->retry_flags; /* How to decode max/min retry limit */
+// range->r_time_flags; /* How to decode max/min retry life */
+// range->min_retry; /* Minimal number of retries */
+// range->max_retry; /* Maximal number of retries */
+// range->min_r_time; /* Minimal retry lifetime */
+// range->max_r_time; /* Maximal retry lifetime */
+
+
+ for (i = 0, val = 0; i < 14; i++) {
+
+ // Include only legal frequencies for some countries
+#ifdef ENABLE_DOT11D
+ if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i+1]) {
+#else
+ if ((priv->ieee80211->channel_map)[i+1]) {
+#endif
+ range->freq[val].i = i + 1;
+ range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
+ range->freq[val].e = 1;
+ val++;
+ } else {
+ // FIXME: do we need to set anything for channels
+ // we don't use ?
+ }
+
+ if (val == IW_MAX_FREQUENCIES)
+ break;
+ }
+ range->num_frequency = val;
+ range->num_channels = val;
+#if WIRELESS_EXT > 17
+ range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2|
+ IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP;
+#endif
+ tmp->scan_capa = 0x01;
+ return 0;
+}
+
+
+static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ int ret = 0;
+
+ if(!priv->up) return -ENETDOWN;
+
+ if (priv->ieee80211->LinkDetectInfo.bBusyTraffic == true)
+ return -EAGAIN;
+#if WIRELESS_EXT > 17
+ if (wrqu->data.flags & IW_SCAN_THIS_ESSID)
+ {
+ struct iw_scan_req* req = (struct iw_scan_req*)b;
+ if (req->essid_len)
+ {
+ //printk("==**&*&*&**===>scan set ssid:%s\n", req->essid);
+ ieee->current_network.ssid_len = req->essid_len;
+ memcpy(ieee->current_network.ssid, req->essid, req->essid_len);
+ //printk("=====>network ssid:%s\n", ieee->current_network.ssid);
+ }
+ }
+#endif
+
+ down(&priv->wx_sem);
+ if(priv->ieee80211->state != IEEE80211_LINKED){
+ priv->ieee80211->scanning = 0;
+ ieee80211_softmac_scan_syncro(priv->ieee80211);
+ ret = 0;
+ }
+ else
+ ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b);
+ up(&priv->wx_sem);
+ return ret;
+}
+
+
+static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if(!priv->up) return -ENETDOWN;
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b);
+
+ up(&priv->wx_sem);
+
+ return ret;
+}
+
+static int r8192_wx_set_essid(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int ret;
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b);
+
+ up(&priv->wx_sem);
+
+ return ret;
+}
+
+
+
+
+static int r8192_wx_get_essid(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
+
+ up(&priv->wx_sem);
+
+ return ret;
+}
+
+
+static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
+
+ up(&priv->wx_sem);
+ return ret;
+}
+
+static int r8192_wx_get_name(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
+}
+
+
+static int r8192_wx_set_frag(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if (wrqu->frag.disabled)
+ priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
+ else {
+ if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
+ wrqu->frag.value > MAX_FRAG_THRESHOLD)
+ return -EINVAL;
+
+ priv->ieee80211->fts = wrqu->frag.value & ~0x1;
+ }
+
+ return 0;
+}
+
+
+static int r8192_wx_get_frag(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ wrqu->frag.value = priv->ieee80211->fts;
+ wrqu->frag.fixed = 0; /* no auto select */
+ wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
+
+ return 0;
+}
+
+
+static int r8192_wx_set_wap(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra)
+{
+
+ int ret;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+// struct sockaddr *temp = (struct sockaddr *)awrq;
+ down(&priv->wx_sem);
+
+ ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra);
+
+ up(&priv->wx_sem);
+
+ return ret;
+
+}
+
+
+static int r8192_wx_get_wap(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra);
+}
+
+
+static int r8192_wx_get_enc(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
+}
+
+static int r8192_wx_set_enc(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *key)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device *ieee = priv->ieee80211;
+ int ret;
+
+ //u32 TargetContent;
+ u32 hwkey[4]={0,0,0,0};
+ u8 mask=0xff;
+ u32 key_idx=0;
+ //u8 broadcast_addr[6] ={ 0xff,0xff,0xff,0xff,0xff,0xff};
+ u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00},
+ {0x00,0x00,0x00,0x00,0x00,0x01},
+ {0x00,0x00,0x00,0x00,0x00,0x02},
+ {0x00,0x00,0x00,0x00,0x00,0x03} };
+ int i;
+
+ if(!priv->up) return -ENETDOWN;
+
+ down(&priv->wx_sem);
+
+ RT_TRACE(COMP_SEC, "Setting SW wep key");
+ ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key);
+
+ up(&priv->wx_sem);
+
+
+
+ //sometimes, the length is zero while we do not type key value
+ if(wrqu->encoding.length!=0){
+
+ for(i=0 ; i<4 ; i++){
+ hwkey[i] |= key[4*i+0]&mask;
+ if(i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00;
+ if(i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00;
+ hwkey[i] |= (key[4*i+1]&mask)<<8;
+ hwkey[i] |= (key[4*i+2]&mask)<<16;
+ hwkey[i] |= (key[4*i+3]&mask)<<24;
+ }
+
+ #define CONF_WEP40 0x4
+ #define CONF_WEP104 0x14
+
+ switch(wrqu->encoding.flags & IW_ENCODE_INDEX){
+ case 0: key_idx = ieee->tx_keyidx; break;
+ case 1: key_idx = 0; break;
+ case 2: key_idx = 1; break;
+ case 3: key_idx = 2; break;
+ case 4: key_idx = 3; break;
+ default: break;
+ }
+
+ if(wrqu->encoding.length==0x5){
+ ieee->pairwise_key_type = KEY_TYPE_WEP40;
+ EnableHWSecurityConfig8192(dev);
+
+ setKey( dev,
+ key_idx, //EntryNo
+ key_idx, //KeyIndex
+ KEY_TYPE_WEP40, //KeyType
+ zero_addr[key_idx],
+ 0, //DefaultKey
+ hwkey); //KeyContent
+
+ }
+
+ else if(wrqu->encoding.length==0xd){
+ ieee->pairwise_key_type = KEY_TYPE_WEP104;
+ EnableHWSecurityConfig8192(dev);
+
+ setKey( dev,
+ key_idx, //EntryNo
+ key_idx, //KeyIndex
+ KEY_TYPE_WEP104, //KeyType
+ zero_addr[key_idx],
+ 0, //DefaultKey
+ hwkey); //KeyContent
+
+ }
+ else printk("wrong type in WEP, not WEP40 and WEP104\n");
+
+ }
+
+ return ret;
+}
+
+
+static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
+ iwreq_data *wrqu, char *p){
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int *parms=(int*)p;
+ int mode=parms[0];
+
+ priv->ieee80211->active_scan = mode;
+
+ return 1;
+}
+
+
+
+static int r8192_wx_set_retry(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int err = 0;
+
+ down(&priv->wx_sem);
+
+ if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
+ wrqu->retry.disabled){
+ err = -EINVAL;
+ goto exit;
+ }
+ if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){
+ err = -EINVAL;
+ goto exit;
+ }
+
+ if(wrqu->retry.value > R8180_MAX_RETRY){
+ err= -EINVAL;
+ goto exit;
+ }
+ if (wrqu->retry.flags & IW_RETRY_MAX) {
+ priv->retry_rts = wrqu->retry.value;
+ DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
+
+ }else {
+ priv->retry_data = wrqu->retry.value;
+ DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
+ }
+
+ /* FIXME !
+ * We might try to write directly the TX config register
+ * or to restart just the (R)TX process.
+ * I'm unsure if whole reset is really needed
+ */
+
+ rtl8192_commit(dev);
+ /*
+ if(priv->up){
+ rtl8180_rtx_disable(dev);
+ rtl8180_rx_enable(dev);
+ rtl8180_tx_enable(dev);
+
+ }
+ */
+exit:
+ up(&priv->wx_sem);
+
+ return err;
+}
+
+static int r8192_wx_get_retry(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+
+ wrqu->retry.disabled = 0; /* can't be disabled */
+
+ if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
+ IW_RETRY_LIFETIME)
+ return -EINVAL;
+
+ if (wrqu->retry.flags & IW_RETRY_MAX) {
+ wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+ wrqu->retry.value = priv->retry_rts;
+ } else {
+ wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
+ wrqu->retry.value = priv->retry_data;
+ }
+ //printk("returning %d",wrqu->retry.value);
+
+
+ return 0;
+}
+
+static int r8192_wx_get_sens(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ if(priv->rf_set_sens == NULL)
+ return -1; /* we have not this support for this radio */
+ wrqu->sens.value = priv->sens;
+ return 0;
+}
+
+
+static int r8192_wx_set_sens(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ short err = 0;
+ down(&priv->wx_sem);
+ //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value);
+ if(priv->rf_set_sens == NULL) {
+ err= -1; /* we have not this support for this radio */
+ goto exit;
+ }
+ if(priv->rf_set_sens(dev, wrqu->sens.value) == 0)
+ priv->sens = wrqu->sens.value;
+ else
+ err= -EINVAL;
+
+exit:
+ up(&priv->wx_sem);
+
+ return err;
+}
+
+#if (WIRELESS_EXT >= 18)
+#if 0
+static int r8192_wx_get_enc_ext(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int ret = 0;
+ ret = ieee80211_wx_get_encode_ext(priv->ieee80211, info, wrqu, extra);
+ return ret;
+}
+#endif
+//hw security need to reorganized.
+static int r8192_wx_set_enc_ext(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret=0;
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ //printk("===>%s()\n", __FUNCTION__);
+
+
+ down(&priv->wx_sem);
+ ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra);
+
+ {
+ u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
+ u8 zero[6] = {0};
+ u32 key[4] = {0};
+ struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
+ struct iw_point *encoding = &wrqu->encoding;
+#if 0
+ static u8 CAM_CONST_ADDR[4][6] = {
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
+#endif
+ u8 idx = 0, alg = 0, group = 0;
+ if ((encoding->flags & IW_ENCODE_DISABLED) ||
+ ext->alg == IW_ENCODE_ALG_NONE) //none is not allowed to use hwsec WB 2008.07.01
+ {
+ ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA;
+ CamResetAllEntry(dev);
+ goto end_hw_sec;
+ }
+ alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; // as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4;
+ idx = encoding->flags & IW_ENCODE_INDEX;
+ if (idx)
+ idx --;
+ group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
+
+ if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40))
+ {
+ if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) )
+ alg = KEY_TYPE_WEP104;
+ ieee->pairwise_key_type = alg;
+ EnableHWSecurityConfig8192(dev);
+ }
+ memcpy((u8*)key, ext->key, 16); //we only get 16 bytes key.why? WB 2008.7.1
+
+ if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) )
+ {
+
+ setKey( dev,
+ idx,//EntryNo
+ idx, //KeyIndex
+ alg, //KeyType
+ zero, //MacAddr
+ 0, //DefaultKey
+ key); //KeyContent
+ }
+ else if (group)
+ {
+ ieee->group_key_type = alg;
+ setKey( dev,
+ idx,//EntryNo
+ idx, //KeyIndex
+ alg, //KeyType
+ broadcast_addr, //MacAddr
+ 0, //DefaultKey
+ key); //KeyContent
+ }
+ else //pairwise key
+ {
+ setKey( dev,
+ 4,//EntryNo
+ idx, //KeyIndex
+ alg, //KeyType
+ (u8*)ieee->ap_mac_addr, //MacAddr
+ 0, //DefaultKey
+ key); //KeyContent
+ }
+
+
+ }
+
+end_hw_sec:
+
+ up(&priv->wx_sem);
+#endif
+ return ret;
+
+}
+static int r8192_wx_set_auth(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *data, char *extra)
+{
+ int ret=0;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ //printk("====>%s()\n", __FUNCTION__);
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ down(&priv->wx_sem);
+ ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra);
+ up(&priv->wx_sem);
+#endif
+ return ret;
+}
+
+static int r8192_wx_set_mlme(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ //printk("====>%s()\n", __FUNCTION__);
+
+ int ret=0;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ down(&priv->wx_sem);
+ ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra);
+
+ up(&priv->wx_sem);
+#endif
+ return ret;
+}
+#endif
+static int r8192_wx_set_gen_ie(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *data, char *extra)
+{
+ //printk("====>%s(), len:%d\n", __FUNCTION__, data->length);
+ int ret=0;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ down(&priv->wx_sem);
+#if 1
+ ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length);
+#endif
+ up(&priv->wx_sem);
+ //printk("<======%s(), ret:%d\n", __FUNCTION__, ret);
+#endif
+ return ret;
+
+
+}
+
+static int dummy(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu,char *b)
+{
+ return -1;
+}
+
+
+static iw_handler r8192_wx_handlers[] =
+{
+ NULL, /* SIOCSIWCOMMIT */
+ r8192_wx_get_name, /* SIOCGIWNAME */
+ dummy, /* SIOCSIWNWID */
+ dummy, /* SIOCGIWNWID */
+ r8192_wx_set_freq, /* SIOCSIWFREQ */
+ r8192_wx_get_freq, /* SIOCGIWFREQ */
+ r8192_wx_set_mode, /* SIOCSIWMODE */
+ r8192_wx_get_mode, /* SIOCGIWMODE */
+ r8192_wx_set_sens, /* SIOCSIWSENS */
+ r8192_wx_get_sens, /* SIOCGIWSENS */
+ NULL, /* SIOCSIWRANGE */
+ rtl8180_wx_get_range, /* SIOCGIWRANGE */
+ NULL, /* SIOCSIWPRIV */
+ NULL, /* SIOCGIWPRIV */
+ NULL, /* SIOCSIWSTATS */
+ NULL, /* SIOCGIWSTATS */
+ dummy, /* SIOCSIWSPY */
+ dummy, /* SIOCGIWSPY */
+ NULL, /* SIOCGIWTHRSPY */
+ NULL, /* SIOCWIWTHRSPY */
+ r8192_wx_set_wap, /* SIOCSIWAP */
+ r8192_wx_get_wap, /* SIOCGIWAP */
+#if (WIRELESS_EXT >= 18)
+ r8192_wx_set_mlme, /* MLME-- */
+#else
+ NULL,
+#endif
+ dummy, /* SIOCGIWAPLIST -- depricated */
+ r8192_wx_set_scan, /* SIOCSIWSCAN */
+ r8192_wx_get_scan, /* SIOCGIWSCAN */
+ r8192_wx_set_essid, /* SIOCSIWESSID */
+ r8192_wx_get_essid, /* SIOCGIWESSID */
+ dummy, /* SIOCSIWNICKN */
+ dummy, /* SIOCGIWNICKN */
+ NULL, /* -- hole -- */
+ NULL, /* -- hole -- */
+ r8192_wx_set_rate, /* SIOCSIWRATE */
+ r8192_wx_get_rate, /* SIOCGIWRATE */
+ r8192_wx_set_rts, /* SIOCSIWRTS */
+ r8192_wx_get_rts, /* SIOCGIWRTS */
+ r8192_wx_set_frag, /* SIOCSIWFRAG */
+ r8192_wx_get_frag, /* SIOCGIWFRAG */
+ dummy, /* SIOCSIWTXPOW */
+ dummy, /* SIOCGIWTXPOW */
+ r8192_wx_set_retry, /* SIOCSIWRETRY */
+ r8192_wx_get_retry, /* SIOCGIWRETRY */
+ r8192_wx_set_enc, /* SIOCSIWENCODE */
+ r8192_wx_get_enc, /* SIOCGIWENCODE */
+ r8192_wx_set_power, /* SIOCSIWPOWER */
+ r8192_wx_get_power, /* SIOCGIWPOWER */
+ NULL, /*---hole---*/
+ NULL, /*---hole---*/
+ r8192_wx_set_gen_ie,//NULL, /* SIOCSIWGENIE */
+ NULL, /* SIOCSIWGENIE */
+
+#if (WIRELESS_EXT >= 18)
+ r8192_wx_set_auth,//NULL, /* SIOCSIWAUTH */
+ NULL,//r8192_wx_get_auth,//NULL, /* SIOCSIWAUTH */
+ r8192_wx_set_enc_ext, /* SIOCSIWENCODEEXT */
+ NULL,//r8192_wx_get_enc_ext,//NULL, /* SIOCSIWENCODEEXT */
+#else
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+#endif
+ NULL, /* SIOCSIWPMKSA */
+ NULL, /*---hole---*/
+
+};
+
+
+static const struct iw_priv_args r8192_private_args[] = {
+
+ {
+ SIOCIWFIRSTPRIV + 0x0,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
+ },
+
+ {
+ SIOCIWFIRSTPRIV + 0x1,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
+
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x2,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
+ }
+#ifdef JOHN_IOCTL
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x3,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "readRF"
+ }
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x4,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "writeRF"
+ }
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x5,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "readBB"
+ }
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x6,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "writeBB"
+ }
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x7,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "readnicb"
+ }
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x8,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "writenicb"
+ }
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x9,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo"
+ }
+
+#endif
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x3,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
+ }
+
+#ifdef RTL8192SU
+ ,
+ {
+ SIOCIWFIRSTPRIV + 0x5,
+ IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
+ "firm_ver"
+ }
+#endif
+};
+
+
+static iw_handler r8192_private_handler[] = {
+// r8192_wx_set_monitor, /* SIOCIWFIRSTPRIV */
+ r8192_wx_set_crcmon, /*SIOCIWSECONDPRIV*/
+// r8192_wx_set_forceassociate,
+// r8192_wx_set_beaconinterval,
+// r8192_wx_set_monitor_type,
+ r8192_wx_set_scan_type,
+ r8192_wx_set_rawtx,
+#ifdef JOHN_IOCTL
+ r8192_wx_read_regs,
+ r8192_wx_write_regs,
+ r8192_wx_read_bb,
+ r8192_wx_write_bb,
+ r8192_wx_read_nicb,
+ r8192_wx_write_nicb,
+ r8192_wx_get_ap_status,
+#endif
+ r8192_wx_force_reset,
+ (iw_handler)NULL,
+#ifdef RTL8192SU
+ (iw_handler)r8191su_wx_get_firm_version,
+#endif
+};
+
+//#if WIRELESS_EXT >= 17
+struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device* ieee = priv->ieee80211;
+ struct iw_statistics* wstats = &priv->wstats;
+ int tmp_level = 0;
+ int tmp_qual = 0;
+ int tmp_noise = 0;
+ if(ieee->state < IEEE80211_LINKED)
+ {
+ wstats->qual.qual = 0;
+ wstats->qual.level = 0;
+ wstats->qual.noise = 0;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14))
+ wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
+#else
+ wstats->qual.updated = 0x0f;
+#endif
+ return wstats;
+ }
+
+ tmp_level = (&ieee->current_network)->stats.rssi;
+ tmp_qual = (&ieee->current_network)->stats.signal;
+ tmp_noise = (&ieee->current_network)->stats.noise;
+ //printk("level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise);
+
+ wstats->qual.level = tmp_level;
+ wstats->qual.qual = tmp_qual;
+ wstats->qual.noise = tmp_noise;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14))
+ wstats->qual.updated = IW_QUAL_ALL_UPDATED| IW_QUAL_DBM;
+#else
+ wstats->qual.updated = 0x0f;
+#endif
+ return wstats;
+}
+//#endif
+
+
+struct iw_handler_def r8192_wx_handlers_def={
+ .standard = r8192_wx_handlers,
+ .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler),
+ .private = r8192_private_handler,
+ .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler),
+ .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args),
+#if WIRELESS_EXT >= 17
+ .get_wireless_stats = r8192_get_wireless_stats,
+#endif
+ .private_args = (struct iw_priv_args *)r8192_private_args,
+};
diff --git a/drivers/staging/rtl8192su/r8192U_wx.h b/drivers/staging/rtl8192su/r8192U_wx.h
new file mode 100644
index 000000000000..b2f7a571b1c8
--- /dev/null
+++ b/drivers/staging/rtl8192su/r8192U_wx.h
@@ -0,0 +1,23 @@
+/*
+ This is part of rtl8180 OpenSource driver - v 0.3
+ Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
+ Released under the terms of GPL (General Public Licence)
+
+ Parts of this driver are based on the GPL part of the official realtek driver
+ Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
+ Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
+
+ We want to tanks the Authors of such projects and the Ndiswrapper project Authors.
+*/
+
+/* this file (will) contains wireless extension handlers*/
+
+#ifndef R8180_WX_H
+#define R8180_WX_H
+//#include <linux/wireless.h>
+//#include "ieee80211.h"
+extern struct iw_handler_def r8192_wx_handlers_def;
+/* Enable the rtl819x_core.c to share this function, david 2008.9.22 */
+extern struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev);
+
+#endif
diff --git a/drivers/staging/rtl8192su/r819xU_HTGen.h b/drivers/staging/rtl8192su/r819xU_HTGen.h
new file mode 100644
index 000000000000..7a60480c4b8e
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_HTGen.h
@@ -0,0 +1,22 @@
+//
+// IOT Action for different AP
+//
+typedef enum _HT_IOT_ACTION{
+ HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001,
+ HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002,
+ HT_IOT_ACT_DECLARE_MCS13 = 0x00000004,
+ HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000008,
+ HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000010,
+ HT_IOT_ACT_CDD_FSYNC = 0x00000020,
+ HT_IOT_ACT_PURE_N_MODE = 0x00000040,
+
+ //LZM ADD 090224
+ HT_IOT_ACT_EDCA_BIAS_ON_RX = 0x00004000,
+ HT_IOT_ACT_HYBRID_AGGREGATION = 0x00010000,
+ HT_IOT_ACT_AMSDU_ENABLE = 0x00000800,
+ HT_IOT_ACT_DISABLE_SHORT_GI = 0x00020000,
+ HT_IOT_ACT_DISABLE_HIGH_POWER = 0x00040000,
+ HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000,
+ HT_IOT_ACT_DISABLE_TX_40_MHZ = 0x00080000,
+}HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
+
diff --git a/drivers/staging/rtl8192su/r819xU_HTType.h b/drivers/staging/rtl8192su/r819xU_HTType.h
new file mode 100644
index 000000000000..2994aa0876ad
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_HTType.h
@@ -0,0 +1,392 @@
+#ifndef _R819XU_HTTYPE_H_
+#define _R819XU_HTTYPE_H_
+
+
+//------------------------------------------------------------
+// The HT Capability element is present in beacons, association request,
+// reassociation request and probe response frames
+//------------------------------------------------------------
+
+//
+// Operation mode value
+//
+#define HT_OPMODE_NO_PROTECT 0
+#define HT_OPMODE_OPTIONAL 1
+#define HT_OPMODE_40MHZ_PROTECT 2
+#define HT_OPMODE_MIXED 3
+
+//
+// MIMO Power Save Setings
+//
+#define MIMO_PS_STATIC 0
+#define MIMO_PS_DYNAMIC 1
+#define MIMO_PS_NOLIMIT 3
+
+
+//
+// There should be 128 bits to cover all of the MCS rates. However, since
+// 8190 does not support too much rates, one integer is quite enough.
+//
+
+#define sHTCLng 4
+
+
+#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff
+#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00
+#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP
+
+
+typedef enum _HT_MCS_RATE{
+ HT_MCS0 = 0x00000001,
+ HT_MCS1 = 0x00000002,
+ HT_MCS2 = 0x00000004,
+ HT_MCS3 = 0x00000008,
+ HT_MCS4 = 0x00000010,
+ HT_MCS5 = 0x00000020,
+ HT_MCS6 = 0x00000040,
+ HT_MCS7 = 0x00000080,
+ HT_MCS8 = 0x00000100,
+ HT_MCS9 = 0x00000200,
+ HT_MCS10 = 0x00000400,
+ HT_MCS11 = 0x00000800,
+ HT_MCS12 = 0x00001000,
+ HT_MCS13 = 0x00002000,
+ HT_MCS14 = 0x00004000,
+ HT_MCS15 = 0x00008000,
+ // Do not define MCS32 here although 8190 support MCS32
+}HT_MCS_RATE,*PHT_MCS_RATE;
+
+//
+// Represent Channel Width in HT Capabilities
+//
+typedef enum _HT_CHANNEL_WIDTH{
+ HT_CHANNEL_WIDTH_20 = 0,
+ HT_CHANNEL_WIDTH_20_40 = 1,
+}HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH;
+
+//
+// Represent Extention Channel Offset in HT Capabilities
+// This is available only in 40Mhz mode.
+//
+typedef enum _HT_EXTCHNL_OFFSET{
+ HT_EXTCHNL_OFFSET_NO_EXT = 0,
+ HT_EXTCHNL_OFFSET_UPPER = 1,
+ HT_EXTCHNL_OFFSET_NO_DEF = 2,
+ HT_EXTCHNL_OFFSET_LOWER = 3,
+}HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET;
+
+typedef enum _CHNLOP{
+ CHNLOP_NONE = 0, // No Action now
+ CHNLOP_SCAN = 1, // Scan in progress
+ CHNLOP_SWBW = 2, // Bandwidth switching in progress
+ CHNLOP_SWCHNL = 3, // Software Channel switching in progress
+} CHNLOP, *PCHNLOP;
+
+// Determine if the Channel Operation is in progress
+#define CHHLOP_IN_PROGRESS(_pHTInfo) \
+ ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
+
+
+typedef enum _HT_ACTION{
+ ACT_RECOMMAND_WIDTH = 0,
+ ACT_MIMO_PWR_SAVE = 1,
+ ACT_PSMP = 2,
+ ACT_SET_PCO_PHASE = 3,
+ ACT_MIMO_CHL_MEASURE = 4,
+ ACT_RECIPROCITY_CORRECT = 5,
+ ACT_MIMO_CSI_MATRICS = 6,
+ ACT_MIMO_NOCOMPR_STEER = 7,
+ ACT_MIMO_COMPR_STEER = 8,
+ ACT_ANTENNA_SELECT = 9,
+} HT_ACTION, *PHT_ACTION;
+
+
+/* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */
+typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{
+ SC_MODE_DUPLICATE = 0,
+ SC_MODE_LOWER = 1,
+ SC_MODE_UPPER = 2,
+ SC_MODE_FULL40MHZ = 3,
+}HT_BW40_SC_E;
+
+typedef struct _HT_CAPABILITY_ELE{
+
+ //HT capability info
+ u8 AdvCoding:1;
+ u8 ChlWidth:1;
+ u8 MimoPwrSave:2;
+ u8 GreenField:1;
+ u8 ShortGI20Mhz:1;
+ u8 ShortGI40Mhz:1;
+ u8 TxSTBC:1;
+ u8 RxSTBC:2;
+ u8 DelayBA:1;
+ u8 MaxAMSDUSize:1;
+ u8 DssCCk:1;
+ u8 PSMP:1;
+ u8 Rsvd1:1;
+ u8 LSigTxopProtect:1;
+
+ //MAC HT parameters info
+ u8 MaxRxAMPDUFactor:2;
+ u8 MPDUDensity:3;
+ u8 Rsvd2:3;
+
+ //Supported MCS set
+ u8 MCS[16];
+
+
+ //Extended HT Capability Info
+ u16 ExtHTCapInfo;
+
+ //TXBF Capabilities
+ u8 TxBFCap[4];
+
+ //Antenna Selection Capabilities
+ u8 ASCap;
+
+}__attribute__((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE;
+
+//------------------------------------------------------------
+// The HT Information element is present in beacons
+// Only AP is required to include this element
+//------------------------------------------------------------
+
+typedef struct _HT_INFORMATION_ELE{
+ u8 ControlChl;
+
+ u8 ExtChlOffset:2;
+ u8 RecommemdedTxWidth:1;
+ u8 RIFS:1;
+ u8 PSMPAccessOnly:1;
+ u8 SrvIntGranularity:3;
+
+ u8 OptMode:2;
+ u8 NonGFDevPresent:1;
+ u8 Revd1:5;
+ u8 Revd2:8;
+
+ u8 Rsvd3:6;
+ u8 DualBeacon:1;
+ u8 DualCTSProtect:1;
+
+ u8 SecondaryBeacon:1;
+ u8 LSigTxopProtectFull:1;
+ u8 PcoActive:1;
+ u8 PcoPhase:1;
+ u8 Rsvd4:4;
+
+ u8 BasicMSC[16];
+}__attribute__((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE;
+
+//
+// MIMO Power Save control field.
+// This is appear in MIMO Power Save Action Frame
+//
+typedef struct _MIMOPS_CTRL{
+ u8 MimoPsEnable:1;
+ u8 MimoPsMode:1;
+ u8 Reserved:6;
+} MIMOPS_CTRL, *PMIMOPS_CTRL;
+
+typedef enum _HT_SPEC_VER{
+ HT_SPEC_VER_IEEE = 0,
+ HT_SPEC_VER_EWC = 1,
+}HT_SPEC_VER, *PHT_SPEC_VER;
+
+typedef enum _HT_AGGRE_MODE_E{
+ HT_AGG_AUTO = 0,
+ HT_AGG_FORCE_ENABLE = 1,
+ HT_AGG_FORCE_DISABLE = 2,
+}HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E;
+
+//------------------------------------------------------------
+// The Data structure is used to keep HT related variables when card is
+// configured as non-AP STA mode. **Note** Current_xxx should be set
+// to default value in HTInitializeHTInfo()
+//------------------------------------------------------------
+
+typedef struct _RT_HIGH_THROUGHPUT{
+// DECLARE_RT_OBJECT(_RT_HIGH_THROUGHPUT);
+ u8 bEnableHT;
+ u8 bCurrentHTSupport;
+
+ u8 bRegBW40MHz; // Tx 40MHz channel capablity
+ u8 bCurBW40MHz; // Tx 40MHz channel capability
+
+ u8 bRegShortGI40MHz; // Tx Short GI for 40Mhz
+ u8 bCurShortGI40MHz; // Tx Short GI for 40MHz
+
+ u8 bRegShortGI20MHz; // Tx Short GI for 20MHz
+ u8 bCurShortGI20MHz; // Tx Short GI for 20MHz
+
+ u8 bRegSuppCCK; // Tx CCK rate capability
+ u8 bCurSuppCCK; // Tx CCK rate capability
+
+ // 802.11n spec version for "peer"
+ HT_SPEC_VER ePeerHTSpecVer;
+
+
+ // HT related information for "Self"
+ HT_CAPABILITY_ELE SelfHTCap; // This is HT cap element sent to peer STA, which also indicate HT Rx capabilities.
+ HT_INFORMATION_ELE SelfHTInfo; // This is HT info element sent to peer STA, which also indicate HT Rx capabilities.
+
+ // HT related information for "Peer"
+ u8 PeerHTCapBuf[32];
+ u8 PeerHTInfoBuf[32];
+
+
+ // A-MSDU related
+ u8 bAMSDU_Support; // This indicates Tx A-MSDU capability
+ u16 nAMSDU_MaxSize; // This indicates Tx A-MSDU capability
+ u8 bCurrent_AMSDU_Support; // This indicates Tx A-MSDU capability
+ u16 nCurrent_AMSDU_MaxSize; // This indicates Tx A-MSDU capability
+
+
+ // AMPDU related <2006.08.10 Emily>
+ u8 bAMPDUEnable; // This indicate Tx A-MPDU capability
+ u8 bCurrentAMPDUEnable; // This indicate Tx A-MPDU capability
+ u8 AMPDU_Factor; // This indicate Tx A-MPDU capability
+ u8 CurrentAMPDUFactor; // This indicate Tx A-MPDU capability
+ u8 MPDU_Density; // This indicate Tx A-MPDU capability
+ u8 CurrentMPDUDensity; // This indicate Tx A-MPDU capability
+
+ // Forced A-MPDU enable
+ HT_AGGRE_MODE_E ForcedAMPDUMode;
+ u8 ForcedAMPDUFactor;
+ u8 ForcedMPDUDensity;
+
+ // Forced A-MSDU enable
+ HT_AGGRE_MODE_E ForcedAMSDUMode;
+ u16 ForcedAMSDUMaxSize;
+
+ u8 bForcedShortGI;
+
+ u8 CurrentOpMode;
+
+ // MIMO PS related
+ u8 SelfMimoPs;
+ u8 PeerMimoPs;
+
+ // 40MHz Channel Offset settings.
+ HT_EXTCHNL_OFFSET CurSTAExtChnlOffset;
+ u8 bCurTxBW40MHz; // If we use 40 MHz to Tx
+ u8 PeerBandwidth;
+
+ // For Bandwidth Switching
+ u8 bSwBwInProgress;
+ CHNLOP ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15.
+ u8 SwBwStep;
+ //RT_TIMER SwBwTimer;
+ struct timer_list SwBwTimer;
+
+ // For Realtek proprietary A-MPDU factor for aggregation
+ u8 bRegRT2RTAggregation;
+ u8 bCurrentRT2RTAggregation;
+ u8 bCurrentRT2RTLongSlotTime;
+ u8 szRT2RTAggBuffer[10];
+
+ // Rx Reorder control
+ u8 bRegRxReorderEnable;
+ u8 bCurRxReorderEnable;
+ u8 RxReorderWinSize;
+ u8 RxReorderPendingTime;
+ u16 RxReorderDropCounter;
+
+#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
+ u8 UsbTxAggrNum;
+#endif
+#ifdef USB_RX_AGGREGATION_SUPPORT
+ u8 UsbRxFwAggrEn;
+ u8 UsbRxFwAggrPageNum;
+ u8 UsbRxFwAggrPacketNum;
+ u8 UsbRxFwAggrTimeout;
+#endif
+
+ // Add for Broadcom(Linksys) IOT. Joseph
+ u8 bIsPeerBcm;
+
+ // For IOT issue.
+ u32 IOTAction;
+}RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT;
+
+
+//------------------------------------------------------------
+// The Data structure is used to keep HT related variable for "each Sta"
+// when card is configured as "AP mode"
+//------------------------------------------------------------
+
+typedef struct _RT_HTINFO_STA_ENTRY{
+ u8 bEnableHT;
+
+ u8 bSupportCck;
+
+ u16 AMSDU_MaxSize;
+
+ u8 AMPDU_Factor;
+ u8 MPDU_Density;
+
+ u8 HTHighestOperaRate;
+
+ u8 bBw40MHz;
+
+ u8 MimoPs;
+
+ u8 McsRateSet[16];
+
+
+}RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY;
+
+
+
+
+
+//------------------------------------------------------------
+// The Data structure is used to keep HT related variable for "each AP"
+// when card is configured as "STA mode"
+//------------------------------------------------------------
+
+typedef struct _BSS_HT{
+
+ u8 bdSupportHT;
+
+ // HT related elements
+ u8 bdHTCapBuf[32];
+ u16 bdHTCapLen;
+ u8 bdHTInfoBuf[32];
+ u16 bdHTInfoLen;
+
+ HT_SPEC_VER bdHTSpecVer;
+ //HT_CAPABILITY_ELE bdHTCapEle;
+ //HT_INFORMATION_ELE bdHTInfoEle;
+
+ u8 bdRT2RTAggregation;
+ u8 bdRT2RTLongSlotTime;
+ bool bdHT1R;
+}BSS_HT, *PBSS_HT;
+
+typedef struct _MIMO_RSSI{
+ u32 EnableAntenna;
+ u32 AntennaA;
+ u32 AntennaB;
+ u32 AntennaC;
+ u32 AntennaD;
+ u32 Average;
+}MIMO_RSSI, *PMIMO_RSSI;
+
+typedef struct _MIMO_EVM{
+ u32 EVM1;
+ u32 EVM2;
+}MIMO_EVM, *PMIMO_EVM;
+
+typedef struct _FALSE_ALARM_STATISTICS{
+ u32 Cnt_Parity_Fail;
+ u32 Cnt_Rate_Illegal;
+ u32 Cnt_Crc8_fail;
+ u32 Cnt_all;
+}FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS;
+
+
+
+#endif //__INC_HTTYPE_H
+
diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.c b/drivers/staging/rtl8192su/r819xU_cmdpkt.c
new file mode 100644
index 000000000000..c1149c6f77bc
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_cmdpkt.c
@@ -0,0 +1,826 @@
+/******************************************************************************
+
+ (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
+
+ Module: r819xusb_cmdpkt.c (RTL8190 TX/RX command packet handler Source C File)
+
+ Note: The module is responsible for handling TX and RX command packet.
+ 1. TX : Send set and query configuration command packet.
+ 2. RX : Receive tx feedback, beacon state, query configuration
+ command packet.
+
+ Function:
+
+ Export:
+
+ Abbrev:
+
+ History:
+ Data Who Remark
+
+ 05/06/2008 amy Create initial version porting from windows driver.
+
+******************************************************************************/
+#include "r8192U.h"
+#include "r819xU_cmdpkt.h"
+/*---------------------------Define Local Constant---------------------------*/
+/* Debug constant*/
+#define CMPK_DEBOUNCE_CNT 1
+/* 2007/10/24 MH Add for printing a range of data. */
+#define CMPK_PRINT(Address)\
+{\
+ unsigned char i;\
+ u32 temp[10];\
+ \
+ memcpy(temp, Address, 40);\
+ for (i = 0; i <40; i+=4)\
+ printk("\r\n %08x", temp[i]);\
+}\
+/*---------------------------Define functions---------------------------------*/
+
+bool
+SendTxCommandPacket(
+ struct net_device *dev,
+ void* pData,
+ u32 DataLen
+ )
+{
+ bool rtStatus = true;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct sk_buff *skb;
+ cb_desc *tcb_desc;
+ unsigned char *ptr_buf;
+ //bool bLastInitPacket = false;
+
+ //PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
+
+ //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ)
+ skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4);
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL;
+ tcb_desc->bLastIniPkt = 0;
+ skb_reserve(skb, USB_HWDESC_HEADER_LEN);
+ ptr_buf = skb_put(skb, DataLen);
+ memset(ptr_buf,0,DataLen);
+ memcpy(ptr_buf,pData,DataLen);
+ tcb_desc->txbuf_size= (u16)DataLen;
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) ) {
+ RT_TRACE(COMP_FIRMWARE,"===================NULL packet==================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ //PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
+ return rtStatus;
+}
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_message_handle_tx()
+ *
+ * Overview: Driver internal module can call the API to send message to
+ * firmware side. For example, you can send a debug command packet.
+ * Or you can send a request for FW to modify RLX4181 LBUS HW bank.
+ * Otherwise, you can change MAC/PHT/RF register by firmware at
+ * run time. We do not support message more than one segment now.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/06/2008 amy porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+ extern bool cmpk_message_handle_tx(
+ struct net_device *dev,
+ u8* codevirtualaddress,
+ u32 packettype,
+ u32 buffer_len)
+{
+
+ bool rt_status = true;
+#ifdef RTL8192SU
+ return rt_status;
+#else
+#ifdef RTL8192U
+ return rt_status;
+#else
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 frag_threshold;
+ u16 frag_length, frag_offset = 0;
+ //u16 total_size;
+ //int i;
+
+ rt_firmware *pfirmware = priv->pFirmware;
+ struct sk_buff *skb;
+ unsigned char *seg_ptr;
+ cb_desc *tcb_desc;
+ u8 bLastIniPkt;
+
+ firmware_init_param(dev);
+ //Fragmentation might be required
+ frag_threshold = pfirmware->cmdpacket_frag_thresold;
+ do {
+ if((buffer_len - frag_offset) > frag_threshold) {
+ frag_length = frag_threshold ;
+ bLastIniPkt = 0;
+
+ } else {
+ frag_length = buffer_len - frag_offset;
+ bLastIniPkt = 1;
+
+ }
+
+ /* Allocate skb buffer to contain firmware info and tx descriptor info
+ * add 4 to avoid packet appending overflow.
+ * */
+ #ifdef RTL8192U
+ skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4);
+ #else
+ skb = dev_alloc_skb(frag_length + 4);
+ #endif
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = packettype;
+ tcb_desc->bLastIniPkt = bLastIniPkt;
+
+ #ifdef RTL8192U
+ skb_reserve(skb, USB_HWDESC_HEADER_LEN);
+ #endif
+
+ seg_ptr = skb_put(skb, buffer_len);
+ /*
+ * Transform from little endian to big endian
+ * and pending zero
+ */
+ memcpy(seg_ptr,codevirtualaddress,buffer_len);
+ tcb_desc->txbuf_size= (u16)buffer_len;
+
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) ) {
+ RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ codevirtualaddress += frag_length;
+ frag_offset += frag_length;
+
+ }while(frag_offset < buffer_len);
+
+ return rt_status;
+
+
+#endif
+#endif
+} /* CMPK_Message_Handle_Tx */
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_counttxstatistic()
+ *
+ * Overview:
+ *
+ * Input: PADAPTER pAdapter - .
+ * CMPK_TXFB_T *psTx_FB - .
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/12/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+cmpk_count_txstatistic(
+ struct net_device *dev,
+ cmpk_txfb_t *pstx_fb)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#ifdef ENABLE_PS
+ RT_RF_POWER_STATE rtState;
+
+ pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState));
+
+ // When RF is off, we should not count the packet for hw/sw synchronize
+ // reason, ie. there may be a duration while sw switch is changed and hw
+ // switch is being changed. 2006.12.04, by shien chang.
+ if (rtState == eRfOff)
+ {
+ return;
+ }
+#endif
+
+#ifdef TODO
+ if(pAdapter->bInHctTest)
+ return;
+#endif
+ /* We can not know the packet length and transmit type: broadcast or uni
+ or multicast. So the relative statistics must be collected in tx
+ feedback info. */
+ if (pstx_fb->tok)
+ {
+ priv->stats.txfeedbackok++;
+ priv->stats.txoktotal++;
+ priv->stats.txokbytestotal += pstx_fb->pkt_length;
+ priv->stats.txokinperiod++;
+
+ /* We can not make sure broadcast/multicast or unicast mode. */
+ if (pstx_fb->pkt_type == PACKET_MULTICAST)
+ {
+ priv->stats.txmulticast++;
+ priv->stats.txbytesmulticast += pstx_fb->pkt_length;
+ }
+ else if (pstx_fb->pkt_type == PACKET_BROADCAST)
+ {
+ priv->stats.txbroadcast++;
+ priv->stats.txbytesbroadcast += pstx_fb->pkt_length;
+ }
+ else
+ {
+ priv->stats.txunicast++;
+ priv->stats.txbytesunicast += pstx_fb->pkt_length;
+ }
+ }
+ else
+ {
+ priv->stats.txfeedbackfail++;
+ priv->stats.txerrtotal++;
+ priv->stats.txerrbytestotal += pstx_fb->pkt_length;
+
+ /* We can not make sure broadcast/multicast or unicast mode. */
+ if (pstx_fb->pkt_type == PACKET_MULTICAST)
+ {
+ priv->stats.txerrmulticast++;
+ }
+ else if (pstx_fb->pkt_type == PACKET_BROADCAST)
+ {
+ priv->stats.txerrbroadcast++;
+ }
+ else
+ {
+ priv->stats.txerrunicast++;
+ }
+ }
+
+ priv->stats.txretrycount += pstx_fb->retry_cnt;
+ priv->stats.txfeedbackretry += pstx_fb->retry_cnt;
+
+} /* cmpk_CountTxStatistic */
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_handle_tx_feedback()
+ *
+ * Overview: The function is responsible for extract the message inside TX
+ * feedbck message from firmware. It will contain dedicated info in
+ * ws-06-0063-rtl8190-command-packet-specification. Please
+ * refer to chapter "TX Feedback Element". We have to read 20 bytes
+ * in the command packet.
+ *
+ * Input: struct net_device * dev
+ * u8 * pmsg - Msg Ptr of the command packet.
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/08/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+cmpk_handle_tx_feedback(
+ struct net_device *dev,
+ u8 * pmsg)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ cmpk_txfb_t rx_tx_fb; /* */
+
+ priv->stats.txfeedback++;
+
+ /* 0. Display received message. */
+ //cmpk_Display_Message(CMPK_RX_TX_FB_SIZE, pMsg);
+
+ /* 1. Extract TX feedback info from RFD to temp structure buffer. */
+ /* It seems that FW use big endian(MIPS) and DRV use little endian in
+ windows OS. So we have to read the content byte by byte or transfer
+ endian type before copy the message copy. */
+#if 0 // The TX FEEDBACK packet element address
+ //rx_tx_fb.Element_ID = pMsg[0];
+ //rx_tx_fb.Length = pMsg[1];
+ rx_tx_fb.TOK = pMsg[2]>>7;
+ rx_tx_fb.Fail_Reason = (pMsg[2] & 0x70) >> 4;
+ rx_tx_fb.TID = (pMsg[2] & 0x0F);
+ rx_tx_fb.Qos_Pkt = pMsg[3] >> 7;
+ rx_tx_fb.Bandwidth = (pMsg[3] & 0x40) >> 6;
+ rx_tx_fb.Retry_Cnt = pMsg[5];
+ rx_tx_fb.Pkt_ID = (pMsg[6] << 8) | pMsg[7];
+ rx_tx_fb.Seq_Num = (pMsg[8] << 8) | pMsg[9];
+ rx_tx_fb.S_Rate = pMsg[10];
+ rx_tx_fb.F_Rate = pMsg[11];
+ rx_tx_fb.S_RTS_Rate = pMsg[12];
+ rx_tx_fb.F_RTS_Rate = pMsg[13];
+ rx_tx_fb.pkt_length = (pMsg[14] << 8) | pMsg[15];
+#endif
+ /* 2007/07/05 MH Use pointer to transfer structure memory. */
+ //memcpy((UINT8 *)&rx_tx_fb, pMsg, sizeof(CMPK_TXFB_T));
+ memcpy((u8*)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t));
+ /* 2. Use tx feedback info to count TX statistics. */
+ cmpk_count_txstatistic(dev, &rx_tx_fb);
+#if 0
+ /* 2007/07/11 MH Assign current operate rate. */
+ if (pAdapter->RegWirelessMode == WIRELESS_MODE_A ||
+ pAdapter->RegWirelessMode == WIRELESS_MODE_B ||
+ pAdapter->RegWirelessMode == WIRELESS_MODE_G)
+ {
+ pMgntInfo->CurrentOperaRate = (rx_tx_fb.F_Rate & 0x7F);
+ }
+ else if (pAdapter->RegWirelessMode == WIRELESS_MODE_N_24G ||
+ pAdapter->RegWirelessMode == WIRELESS_MODE_N_5G)
+ {
+ pMgntInfo->HTCurrentOperaRate = (rx_tx_fb.F_Rate & 0x8F);
+ }
+#endif
+ /* 2007/01/17 MH Comment previous method for TX statistic function. */
+ /* Collect info TX feedback packet to fill TCB. */
+ /* We can not know the packet length and transmit type: broadcast or uni
+ or multicast. */
+ //CountTxStatistics( pAdapter, &tcb );
+
+} /* cmpk_Handle_Tx_Feedback */
+
+void
+cmdpkt_beacontimerinterrupt_819xusb(
+ struct net_device *dev
+)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u16 tx_rate;
+ {
+ //
+ // 070117, rcnjko: 87B have to S/W beacon for DTM encryption_cmn.
+ //
+ if(priv->ieee80211->current_network.mode == IEEE_A ||
+ priv->ieee80211->current_network.mode == IEEE_N_5G ||
+ (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK)))
+ {
+ tx_rate = 60;
+ DMESG("send beacon frame tx rate is 6Mbpm\n");
+ }
+ else
+ {
+ tx_rate =10;
+ DMESG("send beacon frame tx rate is 1Mbpm\n");
+ }
+
+ rtl819xusb_beacon_tx(dev,tx_rate); // HW Beacon
+
+ }
+
+}
+
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_handle_interrupt_status()
+ *
+ * Overview: The function is responsible for extract the message from
+ * firmware. It will contain dedicated info in
+ * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc.
+ * Please refer to chapter "Interrupt Status Element".
+ *
+ * Input: struct net_device *dev,
+ * u8* pmsg - Message Pointer of the command packet.
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/12/2008 amy Add this for rtl8192 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+cmpk_handle_interrupt_status(
+ struct net_device *dev,
+ u8* pmsg)
+{
+ cmpk_intr_sta_t rx_intr_status; /* */
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ DMESG("---> cmpk_Handle_Interrupt_Status()\n");
+
+ /* 0. Display received message. */
+ //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg);
+
+ /* 1. Extract TX feedback info from RFD to temp structure buffer. */
+ /* It seems that FW use big endian(MIPS) and DRV use little endian in
+ windows OS. So we have to read the content byte by byte or transfer
+ endian type before copy the message copy. */
+ //rx_bcn_state.Element_ID = pMsg[0];
+ //rx_bcn_state.Length = pMsg[1];
+ rx_intr_status.length = pmsg[1];
+ if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2))
+ {
+ DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n");
+ return;
+ }
+
+
+ // Statistics of beacon for ad-hoc mode.
+ if( priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+ {
+ //2 maybe need endian transform?
+ rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4));
+ //rx_intr_status.InterruptStatus = N2H4BYTE(*((UINT32 *)(pMsg + 4)));
+
+ DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status);
+
+ if (rx_intr_status.interrupt_status & ISR_TxBcnOk)
+ {
+ priv->ieee80211->bibsscoordinator = true;
+ priv->stats.txbeaconokint++;
+ }
+ else if (rx_intr_status.interrupt_status & ISR_TxBcnErr)
+ {
+ priv->ieee80211->bibsscoordinator = false;
+ priv->stats.txbeaconerr++;
+ }
+
+ if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr)
+ {
+ cmdpkt_beacontimerinterrupt_819xusb(dev);
+ }
+
+ }
+
+ // Other informations in interrupt status we need?
+
+
+ DMESG("<---- cmpk_handle_interrupt_status()\n");
+
+} /* cmpk_handle_interrupt_status */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_handle_query_config_rx()
+ *
+ * Overview: The function is responsible for extract the message from
+ * firmware. It will contain dedicated info in
+ * ws-06-0063-rtl8190-command-packet-specification. Please
+ * refer to chapter "Beacon State Element".
+ *
+ * Input: u8 * pmsg - Message Pointer of the command packet.
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/12/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+cmpk_handle_query_config_rx(
+ struct net_device *dev,
+ u8* pmsg)
+{
+ cmpk_query_cfg_t rx_query_cfg; /* */
+
+ /* 0. Display received message. */
+ //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg);
+
+ /* 1. Extract TX feedback info from RFD to temp structure buffer. */
+ /* It seems that FW use big endian(MIPS) and DRV use little endian in
+ windows OS. So we have to read the content byte by byte or transfer
+ endian type before copy the message copy. */
+ //rx_query_cfg.Element_ID = pMsg[0];
+ //rx_query_cfg.Length = pMsg[1];
+ rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31;
+ rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5;
+ rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3;
+ rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0;
+ rx_query_cfg.cfg_offset = pmsg[7];
+ rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) |
+ (pmsg[10] << 8) | (pmsg[11] << 0);
+ rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) |
+ (pmsg[14] << 8) | (pmsg[15] << 0);
+
+} /* cmpk_Handle_Query_Config_Rx */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_count_tx_status()
+ *
+ * Overview: Count aggregated tx status from firmwar of one type rx command
+ * packet element id = RX_TX_STATUS.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/12/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void cmpk_count_tx_status( struct net_device *dev,
+ cmpk_tx_status_t *pstx_status)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+#ifdef ENABLE_PS
+
+ RT_RF_POWER_STATE rtstate;
+
+ pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState));
+
+ // When RF is off, we should not count the packet for hw/sw synchronize
+ // reason, ie. there may be a duration while sw switch is changed and hw
+ // switch is being changed. 2006.12.04, by shien chang.
+ if (rtState == eRfOff)
+ {
+ return;
+ }
+#endif
+
+ priv->stats.txfeedbackok += pstx_status->txok;
+ priv->stats.txoktotal += pstx_status->txok;
+
+ priv->stats.txfeedbackfail += pstx_status->txfail;
+ priv->stats.txerrtotal += pstx_status->txfail;
+
+ priv->stats.txretrycount += pstx_status->txretry;
+ priv->stats.txfeedbackretry += pstx_status->txretry;
+
+ //pAdapter->TxStats.NumTxOkBytesTotal += psTx_FB->pkt_length;
+ //pAdapter->TxStats.NumTxErrBytesTotal += psTx_FB->pkt_length;
+ //pAdapter->MgntInfo.LinkDetectInfo.NumTxOkInPeriod++;
+
+ priv->stats.txmulticast += pstx_status->txmcok;
+ priv->stats.txbroadcast += pstx_status->txbcok;
+ priv->stats.txunicast += pstx_status->txucok;
+
+ priv->stats.txerrmulticast += pstx_status->txmcfail;
+ priv->stats.txerrbroadcast += pstx_status->txbcfail;
+ priv->stats.txerrunicast += pstx_status->txucfail;
+
+ priv->stats.txbytesmulticast += pstx_status->txmclength;
+ priv->stats.txbytesbroadcast += pstx_status->txbclength;
+ priv->stats.txbytesunicast += pstx_status->txuclength;
+
+ priv->stats.last_packet_rate = pstx_status->rate;
+} /* cmpk_CountTxStatus */
+
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_handle_tx_status()
+ *
+ * Overview: Firmware add a new tx feedback status to reduce rx command
+ * packet buffer operation load.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/12/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+cmpk_handle_tx_status(
+ struct net_device *dev,
+ u8* pmsg)
+{
+ cmpk_tx_status_t rx_tx_sts; /* */
+
+ memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(cmpk_tx_status_t));
+ /* 2. Use tx feedback info to count TX statistics. */
+ cmpk_count_tx_status(dev, &rx_tx_sts);
+
+} /* cmpk_Handle_Tx_Status */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_handle_tx_rate_history()
+ *
+ * Overview: Firmware add a new tx rate history
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/12/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+static void
+cmpk_handle_tx_rate_history(
+ struct net_device *dev,
+ u8* pmsg)
+{
+ cmpk_tx_rahis_t *ptxrate;
+// RT_RF_POWER_STATE rtState;
+ u8 i, j;
+ u16 length = sizeof(cmpk_tx_rahis_t);
+ u32 *ptemp;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+
+#ifdef ENABLE_PS
+ pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState));
+
+ // When RF is off, we should not count the packet for hw/sw synchronize
+ // reason, ie. there may be a duration while sw switch is changed and hw
+ // switch is being changed. 2006.12.04, by shien chang.
+ if (rtState == eRfOff)
+ {
+ return;
+ }
+#endif
+
+ ptemp = (u32 *)pmsg;
+
+ //
+ // Do endian transfer to word alignment(16 bits) for windows system.
+ // You must do different endian transfer for linux and MAC OS
+ //
+ for (i = 0; i < (length/4); i++)
+ {
+ u16 temp1, temp2;
+
+ temp1 = ptemp[i]&0x0000FFFF;
+ temp2 = ptemp[i]>>16;
+ ptemp[i] = (temp1<<16)|temp2;
+ }
+
+ ptxrate = (cmpk_tx_rahis_t *)pmsg;
+
+ if (ptxrate == NULL )
+ {
+ return;
+ }
+
+ for (i = 0; i < 16; i++)
+ {
+ // Collect CCK rate packet num
+ if (i < 4)
+ priv->stats.txrate.cck[i] += ptxrate->cck[i];
+
+ // Collect OFDM rate packet num
+ if (i< 8)
+ priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i];
+
+ for (j = 0; j < 4; j++)
+ priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i];
+ }
+
+} /* cmpk_Handle_Tx_Rate_History */
+
+
+/*-----------------------------------------------------------------------------
+ * Function: cmpk_message_handle_rx()
+ *
+ * Overview: In the function, we will capture different RX command packet
+ * info. Every RX command packet element has different message
+ * length and meaning in content. We only support three type of RX
+ * command packet now. Please refer to document
+ * ws-06-0063-rtl8190-command-packet-specification.
+ *
+ * Input: NONE
+ *
+ * Output: NONE
+ *
+ * Return: NONE
+ *
+ * Revised History:
+ * When Who Remark
+ * 05/06/2008 amy Create Version 0 porting from windows code.
+ *
+ *---------------------------------------------------------------------------*/
+extern u32
+cmpk_message_handle_rx(
+ struct net_device *dev,
+ struct ieee80211_rx_stats *pstats)
+{
+// u32 debug_level = DBG_LOUD;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ int total_length;
+ u8 cmd_length, exe_cnt = 0;
+ u8 element_id;
+ u8 *pcmd_buff;
+
+ /* 0. Check inpt arguments. If is is a command queue message or pointer is
+ null. */
+ if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL))
+ {
+ /* Print error message. */
+ /*RT_TRACE(COMP_SEND, DebugLevel,
+ ("\n\r[CMPK]-->Err queue id or pointer"));*/
+ return 0; /* This is not a command packet. */
+ }
+
+ /* 1. Read received command packet message length from RFD. */
+ total_length = pstats->Length;
+
+ /* 2. Read virtual address from RFD. */
+ pcmd_buff = pstats->virtual_address;
+
+ /* 3. Read command pakcet element id and length. */
+ element_id = pcmd_buff[0];
+ /*RT_TRACE(COMP_SEND, DebugLevel,
+ ("\n\r[CMPK]-->element ID=%d Len=%d", element_id, total_length));*/
+
+ /* 4. Check every received command packet conent according to different
+ element type. Because FW may aggregate RX command packet to minimize
+ transmit time between DRV and FW.*/
+ // Add a counter to prevent to locked in the loop too long
+ while (total_length > 0 || exe_cnt++ >100)
+ {
+ /* 2007/01/17 MH We support aggregation of different cmd in the same packet. */
+ element_id = pcmd_buff[0];
+
+ switch(element_id)
+ {
+ case RX_TX_FEEDBACK:
+ cmpk_handle_tx_feedback (dev, pcmd_buff);
+ cmd_length = CMPK_RX_TX_FB_SIZE;
+ break;
+
+ case RX_INTERRUPT_STATUS:
+ cmpk_handle_interrupt_status(dev, pcmd_buff);
+ cmd_length = sizeof(cmpk_intr_sta_t);
+ break;
+
+ case BOTH_QUERY_CONFIG:
+ cmpk_handle_query_config_rx(dev, pcmd_buff);
+ cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE;
+ break;
+
+ case RX_TX_STATUS:
+ cmpk_handle_tx_status(dev, pcmd_buff);
+ cmd_length = CMPK_RX_TX_STS_SIZE;
+ break;
+
+ case RX_TX_PER_PKT_FEEDBACK:
+ // You must at lease add a switch case element here,
+ // Otherwise, we will jump to default case.
+ //DbgPrint("CCX Test\r\n");
+ cmd_length = CMPK_RX_TX_FB_SIZE;
+ break;
+
+ case RX_TX_RATE_HISTORY:
+ //DbgPrint(" rx tx rate history\r\n");
+ cmpk_handle_tx_rate_history(dev, pcmd_buff);
+ cmd_length = CMPK_TX_RAHIS_SIZE;
+ break;
+
+ default:
+
+ RT_TRACE(COMP_ERR, "---->cmpk_message_handle_rx():unknow CMD Element\n");
+ return 1; /* This is a command packet. */
+ }
+ // 2007/01/22 MH Display received rx command packet info.
+ //cmpk_Display_Message(cmd_length, pcmd_buff);
+
+ // 2007/01/22 MH Add to display tx statistic.
+ //cmpk_DisplayTxStatistic(pAdapter);
+
+ /* 2007/03/09 MH Collect sidderent cmd element pkt num. */
+ priv->stats.rxcmdpkt[element_id]++;
+
+ total_length -= cmd_length;
+ pcmd_buff += cmd_length;
+ } /* while (total_length > 0) */
+ return 1; /* This is a command packet. */
+
+} /* CMPK_Message_Handle_Rx */
diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.h b/drivers/staging/rtl8192su/r819xU_cmdpkt.h
new file mode 100644
index 000000000000..f67af6cfd201
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_cmdpkt.h
@@ -0,0 +1,219 @@
+#ifndef R819XUSB_CMDPKT_H
+#define R819XUSB_CMDPKT_H
+/* Different command packet have dedicated message length and definition. */
+#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) //20
+#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) //16
+#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) //16
+#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t)//
+#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t)//
+#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t)
+
+/* 2008/05/08 amy For USB constant. */
+#define ISR_TxBcnOk BIT27 // Transmit Beacon OK
+#define ISR_TxBcnErr BIT26 // Transmit Beacon Error
+#define ISR_BcnTimerIntr BIT13 // Beacon Timer Interrupt
+
+#if 0
+/* Define packet type. */
+typedef enum tag_packet_type
+{
+ PACKET_BROADCAST,
+ PACKET_MULTICAST,
+ PACKET_UNICAST,
+ PACKET_TYPE_MAX
+}cmpk_pkt_type_e;
+#endif
+
+/* Define element ID of command packet. */
+
+/*------------------------------Define structure----------------------------*/
+/* Define different command packet structure. */
+/* 1. RX side: TX feedback packet. */
+typedef struct tag_cmd_pkt_tx_feedback
+{
+ // DWORD 0
+ u8 element_id; /* Command packet type. */
+ u8 length; /* Command packet length. */
+ /* 2007/07/05 MH Change tx feedback info field. */
+ /*------TX Feedback Info Field */
+ u8 TID:4; /* */
+ u8 fail_reason:3; /* */
+ u8 tok:1; /* Transmit ok. */
+ u8 reserve1:4; /* */
+ u8 pkt_type:2; /* */
+ u8 bandwidth:1; /* */
+ u8 qos_pkt:1; /* */
+
+ // DWORD 1
+ u8 reserve2; /* */
+ /*------TX Feedback Info Field */
+ u8 retry_cnt; /* */
+ u16 pkt_id; /* */
+
+ // DWORD 3
+ u16 seq_num; /* */
+ u8 s_rate; /* Start rate. */
+ u8 f_rate; /* Final rate. */
+
+ // DWORD 4
+ u8 s_rts_rate; /* */
+ u8 f_rts_rate; /* */
+ u16 pkt_length; /* */
+
+ // DWORD 5
+ u16 reserve3; /* */
+ u16 duration; /* */
+}cmpk_txfb_t;
+
+/* 2. RX side: Interrupt status packet. It includes Beacon State,
+ Beacon Timer Interrupt and other useful informations in MAC ISR Reg. */
+typedef struct tag_cmd_pkt_interrupt_status
+{
+ u8 element_id; /* Command packet type. */
+ u8 length; /* Command packet length. */
+ u16 reserve;
+ u32 interrupt_status; /* Interrupt Status. */
+}cmpk_intr_sta_t;
+
+
+/* 3. TX side: Set configuration packet. */
+typedef struct tag_cmd_pkt_set_configuration
+{
+ u8 element_id; /* Command packet type. */
+ u8 length; /* Command packet length. */
+ u16 reserve1; /* */
+ u8 cfg_reserve1:3;
+ u8 cfg_size:2; /* Configuration info. */
+ u8 cfg_type:2; /* Configuration info. */
+ u8 cfg_action:1; /* Configuration info. */
+ u8 cfg_reserve2; /* Configuration info. */
+ u8 cfg_page:4; /* Configuration info. */
+ u8 cfg_reserve3:4; /* Configuration info. */
+ u8 cfg_offset; /* Configuration info. */
+ u32 value; /* */
+ u32 mask; /* */
+}cmpk_set_cfg_t;
+
+/* 4. Both side : TX/RX query configuraton packet. The query structure is the
+ same as set configuration. */
+#define cmpk_query_cfg_t cmpk_set_cfg_t
+
+/* 5. Multi packet feedback status. */
+typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007
+{
+ // For endian transfer --> Driver will not the same as firmware structure.
+ // DW 0
+ u16 reserve1;
+ u8 length; // Command packet length
+ u8 element_id; // Command packet type
+
+ // DW 1
+ u16 txfail; // Tx Fail count
+ u16 txok; // Tx ok count
+
+ // DW 2
+ u16 txmcok; // tx multicast
+ u16 txretry; // Tx Retry count
+
+ // DW 3
+ u16 txucok; // tx unicast
+ u16 txbcok; // tx broadcast
+
+ // DW 4
+ u16 txbcfail; //
+ u16 txmcfail; //
+
+ // DW 5
+ u16 reserve2; //
+ u16 txucfail; //
+
+ // DW 6-8
+ u32 txmclength;
+ u32 txbclength;
+ u32 txuclength;
+
+ // DW 9
+ u16 reserve3_23;
+ u8 reserve3_1;
+ u8 rate;
+}__attribute__((packed)) cmpk_tx_status_t;
+
+/* 6. Debug feedback message. */
+/* 2007/10/23 MH Define RX debug message */
+typedef struct tag_rx_debug_message_feedback
+{
+ // For endian transfer --> for driver
+ // DW 0
+ u16 reserve1;
+ u8 length; // Command packet length
+ u8 element_id; // Command packet type
+
+ // DW 1-??
+ // Variable debug message.
+
+}cmpk_rx_dbginfo_t;
+
+/* 2008/03/20 MH Define transmit rate history. For big endian format. */
+typedef struct tag_tx_rate_history
+{
+ // For endian transfer --> for driver
+ // DW 0
+ u8 element_id; // Command packet type
+ u8 length; // Command packet length
+ u16 reserved1;
+
+ // DW 1-2 CCK rate counter
+ u16 cck[4];
+
+ // DW 3-6
+ u16 ofdm[8];
+
+ // DW 7-14
+ //UINT16 MCS_BW0_SG0[16];
+
+ // DW 15-22
+ //UINT16 MCS_BW1_SG0[16];
+
+ // DW 23-30
+ //UINT16 MCS_BW0_SG1[16];
+
+ // DW 31-38
+ //UINT16 MCS_BW1_SG1[16];
+
+ // DW 7-14 BW=0 SG=0
+ // DW 15-22 BW=1 SG=0
+ // DW 23-30 BW=0 SG=1
+ // DW 31-38 BW=1 SG=1
+ u16 ht_mcs[4][16];
+
+}__attribute__((packed)) cmpk_tx_rahis_t;
+
+typedef enum tag_command_packet_directories
+{
+ RX_TX_FEEDBACK = 0,
+ RX_INTERRUPT_STATUS = 1,
+ TX_SET_CONFIG = 2,
+ BOTH_QUERY_CONFIG = 3,
+ RX_TX_STATUS = 4,
+ RX_DBGINFO_FEEDBACK = 5,
+ RX_TX_PER_PKT_FEEDBACK = 6,
+ RX_TX_RATE_HISTORY = 7,
+ RX_CMD_ELE_MAX
+}cmpk_element_e;
+
+#if 0
+typedef enum _rt_status{
+ RT_STATUS_SUCCESS,
+ RT_STATUS_FAILURE,
+ RT_STATUS_PENDING,
+ RT_STATUS_RESOURCE
+}rt_status,*prt_status;
+#endif
+
+extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len);
+
+extern u32 cmpk_message_handle_rx(struct net_device *dev, struct ieee80211_rx_stats * pstats);
+extern bool SendTxCommandPacket( struct net_device *dev, void* pData, u32 DataLen);
+
+
+#endif
diff --git a/drivers/staging/rtl8192su/r819xU_firmware.c b/drivers/staging/rtl8192su/r819xU_firmware.c
new file mode 100644
index 000000000000..219f71e8cda7
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_firmware.c
@@ -0,0 +1,707 @@
+/**************************************************************************************************
+ * Procedure: Init boot code/firmware code/data session
+ *
+ * Description: This routine will intialize firmware. If any error occurs during the initialization
+ * process, the routine shall terminate immediately and return fail.
+ * NIC driver should call NdisOpenFile only from MiniportInitialize.
+ *
+ * Arguments: The pointer of the adapter
+
+ * Returns:
+ * NDIS_STATUS_FAILURE - the following initialization process should be terminated
+ * NDIS_STATUS_SUCCESS - if firmware initialization process success
+**************************************************************************************************/
+//#include "ieee80211.h"
+#include "r8192U.h"
+#include "r8192U_hw.h"
+#include "r819xU_firmware_img.h"
+#include "r819xU_firmware.h"
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+#include <linux/firmware.h>
+#endif
+void firmware_init_param(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ rt_firmware *pfirmware = priv->pFirmware;
+
+ pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE);
+}
+
+/*
+ * segment the img and use the ptr and length to remember info on each segment
+ *
+ */
+bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = true;
+ u16 frag_threshold;
+ u16 frag_length, frag_offset = 0;
+ //u16 total_size;
+ int i;
+
+ rt_firmware *pfirmware = priv->pFirmware;
+ struct sk_buff *skb;
+ unsigned char *seg_ptr;
+ cb_desc *tcb_desc;
+ u8 bLastIniPkt;
+
+ firmware_init_param(dev);
+ //Fragmentation might be required
+ frag_threshold = pfirmware->cmdpacket_frag_thresold;
+ do {
+ if((buffer_len - frag_offset) > frag_threshold) {
+ frag_length = frag_threshold ;
+ bLastIniPkt = 0;
+
+ } else {
+ frag_length = buffer_len - frag_offset;
+ bLastIniPkt = 1;
+
+ }
+
+ /* Allocate skb buffer to contain firmware info and tx descriptor info
+ * add 4 to avoid packet appending overflow.
+ * */
+ #ifdef RTL8192U
+ skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4);
+ #else
+ skb = dev_alloc_skb(frag_length + 4);
+ #endif
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
+ tcb_desc->bLastIniPkt = bLastIniPkt;
+
+ #ifdef RTL8192U
+ skb_reserve(skb, USB_HWDESC_HEADER_LEN);
+ #endif
+ seg_ptr = skb->data;
+ /*
+ * Transform from little endian to big endian
+ * and pending zero
+ */
+ for(i=0 ; i < frag_length; i+=4) {
+ *seg_ptr++ = ((i+0)<frag_length)?code_virtual_address[i+3]:0;
+ *seg_ptr++ = ((i+1)<frag_length)?code_virtual_address[i+2]:0;
+ *seg_ptr++ = ((i+2)<frag_length)?code_virtual_address[i+1]:0;
+ *seg_ptr++ = ((i+3)<frag_length)?code_virtual_address[i+0]:0;
+ }
+ tcb_desc->txbuf_size= (u16)i;
+ skb_put(skb, i);
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) ) {
+ RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ code_virtual_address += frag_length;
+ frag_offset += frag_length;
+
+ }while(frag_offset < buffer_len);
+
+ return rt_status;
+
+#if 0
+cmdsend_downloadcode_fail:
+ rt_status = false;
+ RT_TRACE(COMP_ERR, "CmdSendDownloadCode fail !!\n");
+ return rt_status;
+#endif
+}
+
+bool
+fwSendNullPacket(
+ struct net_device *dev,
+ u32 Length
+)
+{
+ bool rtStatus = true;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ struct sk_buff *skb;
+ cb_desc *tcb_desc;
+ unsigned char *ptr_buf;
+ bool bLastInitPacket = false;
+
+ //PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
+
+ //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ)
+ skb = dev_alloc_skb(Length+ 4);
+ memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+ tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
+ tcb_desc->queue_index = TXCMD_QUEUE;
+ tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
+ tcb_desc->bLastIniPkt = bLastInitPacket;
+ ptr_buf = skb_put(skb, Length);
+ memset(ptr_buf,0,Length);
+ tcb_desc->txbuf_size= (u16)Length;
+
+ if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)||
+ (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\
+ (priv->ieee80211->queue_stop) ) {
+ RT_TRACE(COMP_FIRMWARE,"===================NULL packet==================================> tx full!\n");
+ skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
+ } else {
+ priv->ieee80211->softmac_hard_start_xmit(skb,dev);
+ }
+
+ //PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
+ return rtStatus;
+}
+
+#if 0
+/*
+ * Procedure : Download code into IMEM or DMEM
+ * Description: This routine will intialize firmware. If any error occurs during the initialization
+ * process, the routine shall terminate immediately and return fail.
+ * The routine copy virtual address get from opening of file into shared memory
+ * allocated during initialization. If code size larger than a conitneous shared
+ * memory may contain, the code should be divided into several section.
+ * !!!NOTES This finction should only be called during MPInitialization because
+ * A NIC driver should call NdisOpenFile only from MiniportInitialize.
+ * Arguments : The pointer of the adapter
+ * Code address (Virtual address, should fill descriptor with physical address)
+ * Code size
+ * Returns :
+ * RT_STATUS_FAILURE - the following initialization process should be terminated
+ * RT_STATUS_SUCCESS - if firmware initialization process success
+ */
+bool fwsend_download_code(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ rt_firmware *pfirmware = (rt_firmware*)(&priv->firmware);
+
+ bool rt_status = true;
+ u16 length = 0;
+ u16 offset = 0;
+ u16 frag_threhold;
+ bool last_init_packet = false;
+ u32 check_txcmdwait_queueemptytime = 100000;
+ u16 cmd_buf_len;
+ u8 *ptr_cmd_buf;
+
+ /* reset to 0 for first segment of img download */
+ pfirmware->firmware_seg_index = 1;
+
+ if(pfirmware->firmware_seg_index == pfirmware->firmware_seg_maxnum) {
+ last_init_packet = 1;
+ }
+
+ cmd_buf_len = pfirmware->firmware_seg_container[pfirmware->firmware_seg_index-1].seg_size;
+ ptr_cmd_buf = pfirmware->firmware_seg_container[pfirmware->firmware_seg_index-1].seg_ptr;
+ rtl819xU_tx_cmd(dev, ptr_cmd_buf, cmd_buf_len, last_init_packet, DESC_PACKET_TYPE_INIT);
+
+ rt_status = true;
+ return rt_status;
+}
+#endif
+
+//-----------------------------------------------------------------------------
+// Procedure: Check whether main code is download OK. If OK, turn on CPU
+//
+// Description: CPU register locates in different page against general register.
+// Switch to CPU register in the begin and switch back before return
+//
+//
+// Arguments: The pointer of the adapter
+//
+// Returns:
+// NDIS_STATUS_FAILURE - the following initialization process should be terminated
+// NDIS_STATUS_SUCCESS - if firmware initialization process success
+//-----------------------------------------------------------------------------
+bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = true;
+ int check_putcodeOK_time = 200000, check_bootOk_time = 200000;
+ u32 CPU_status = 0;
+
+ /* Check whether put code OK */
+ do {
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+
+ if((CPU_status&CPU_GEN_PUT_CODE_OK) || (priv->usb_error==true))
+ break;
+
+ }while(check_putcodeOK_time--);
+
+ if(!(CPU_status&CPU_GEN_PUT_CODE_OK)) {
+ RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n");
+ goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
+ } else {
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n");
+ }
+
+ /* Turn On CPU */
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+ write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff));
+ mdelay(1000);
+
+ /* Check whether CPU boot OK */
+ do {
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+
+ if((CPU_status&CPU_GEN_BOOT_RDY)||(priv->usb_error == true))
+ break;
+ }while(check_bootOk_time--);
+
+ if(!(CPU_status&CPU_GEN_BOOT_RDY)) {
+ goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
+ } else {
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n");
+ }
+
+ return rt_status;
+
+CPUCheckMainCodeOKAndTurnOnCPU_Fail:
+ RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__);
+ rt_status = FALSE;
+ return rt_status;
+}
+
+bool CPUcheck_firmware_ready(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = true;
+ int check_time = 200000;
+ u32 CPU_status = 0;
+
+ /* Check Firmware Ready */
+ do {
+ CPU_status = read_nic_dword(dev, CPU_GEN);
+
+ if((CPU_status&CPU_GEN_FIRM_RDY)||(priv->usb_error == true))
+ break;
+
+ }while(check_time--);
+
+ if(!(CPU_status&CPU_GEN_FIRM_RDY))
+ goto CPUCheckFirmwareReady_Fail;
+ else
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Firmware ready!\n");
+
+ return rt_status;
+
+CPUCheckFirmwareReady_Fail:
+ RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__);
+ rt_status = false;
+ return rt_status;
+
+}
+
+bool init_firmware(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ bool rt_status = TRUE;
+
+ u8 *firmware_img_buf[3] = { &rtl8190_fwboot_array[0],
+ &rtl8190_fwmain_array[0],
+ &rtl8190_fwdata_array[0]};
+
+ u32 firmware_img_len[3] = { sizeof(rtl8190_fwboot_array),
+ sizeof(rtl8190_fwmain_array),
+ sizeof(rtl8190_fwdata_array)};
+ u32 file_length = 0;
+ u8 *mapped_file = NULL;
+ u32 init_step = 0;
+ opt_rst_type_e rst_opt = OPT_SYSTEM_RESET;
+ firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT;
+
+ rt_firmware *pfirmware = priv->pFirmware;
+ const struct firmware *fw_entry;
+ const char *fw_name[3] = { "RTL8192U/boot.img",
+ "RTL8192U/main.img",
+ "RTL8192U/data.img"};
+ int rc;
+
+ RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n");
+
+ if (pfirmware->firmware_status == FW_STATUS_0_INIT ) {
+ /* it is called by reset */
+ rst_opt = OPT_SYSTEM_RESET;
+ starting_state = FW_INIT_STEP0_BOOT;
+ // TODO: system reset
+
+ }else if(pfirmware->firmware_status == FW_STATUS_5_READY) {
+ /* it is called by Initialize */
+ rst_opt = OPT_FIRMWARE_RESET;
+ starting_state = FW_INIT_STEP2_DATA;
+ }else {
+ RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n");
+ }
+
+ /*
+ * Download boot, main, and data image for System reset.
+ * Download data image for firmware reseta
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ priv->firmware_source = FW_SOURCE_HEADER_FILE;
+#else
+ priv->firmware_source = FW_SOURCE_IMG_FILE;
+#endif
+ for(init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) {
+ /*
+ * Open Image file, and map file to contineous memory if open file success.
+ * or read image file from array. Default load from IMG file
+ */
+ if(rst_opt == OPT_SYSTEM_RESET) {
+ switch(priv->firmware_source) {
+ case FW_SOURCE_IMG_FILE:
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ if(pfirmware->firmware_buf_size[init_step] == 0) {
+ rc = request_firmware(&fw_entry, fw_name[init_step],&priv->udev->dev);
+ if(rc < 0 ) {
+ RT_TRACE(COMP_ERR, "request firmware fail!\n");
+ goto download_firmware_fail;
+ }
+
+ if(fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) {
+ //RT_TRACE(COMP_ERR, "img file size exceed the container buffer fail!\n");
+ RT_TRACE(COMP_FIRMWARE, "img file size exceed the container buffer fail!, entry_size = %d, buf_size = %d\n",fw_entry->size,sizeof(pfirmware->firmware_buf[init_step]));
+
+ goto download_firmware_fail;
+ }
+
+ if(init_step != FW_INIT_STEP1_MAIN) {
+ memcpy(pfirmware->firmware_buf[init_step],fw_entry->data,fw_entry->size);
+ pfirmware->firmware_buf_size[init_step] = fw_entry->size;
+ } else {
+#ifdef RTL8190P
+ memcpy(pfirmware->firmware_buf[init_step],fw_entry->data,fw_entry->size);
+ pfirmware->firmware_buf_size[init_step] = fw_entry->size;
+#else
+ memset(pfirmware->firmware_buf[init_step],0,128);
+ memcpy(&pfirmware->firmware_buf[init_step][128],fw_entry->data,fw_entry->size);
+ mapped_file = pfirmware->firmware_buf[init_step];
+ pfirmware->firmware_buf_size[init_step] = fw_entry->size+128;
+#endif
+ }
+ //pfirmware->firmware_buf_size = file_length;
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+ if(rst_opt == OPT_SYSTEM_RESET) {
+ release_firmware(fw_entry);
+ }
+#endif
+ }
+ mapped_file = pfirmware->firmware_buf[init_step];
+ file_length = pfirmware->firmware_buf_size[init_step];
+#endif
+
+ break;
+
+ case FW_SOURCE_HEADER_FILE:
+ mapped_file = firmware_img_buf[init_step];
+ file_length = firmware_img_len[init_step];
+ if(init_step == FW_INIT_STEP2_DATA) {
+ memcpy(pfirmware->firmware_buf[init_step], mapped_file, file_length);
+ pfirmware->firmware_buf_size[init_step] = file_length;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+
+ }else if(rst_opt == OPT_FIRMWARE_RESET ) {
+ /* we only need to download data.img here */
+ mapped_file = pfirmware->firmware_buf[init_step];
+ file_length = pfirmware->firmware_buf_size[init_step];
+ }
+
+ /* Download image file */
+ /* The firmware download process is just as following,
+ * 1. that is each packet will be segmented and inserted to the wait queue.
+ * 2. each packet segment will be put in the skb_buff packet.
+ * 3. each skb_buff packet data content will already include the firmware info
+ * and Tx descriptor info
+ * */
+ rt_status = fw_download_code(dev,mapped_file,file_length);
+
+ if(rt_status != TRUE) {
+ goto download_firmware_fail;
+ }
+
+ switch(init_step) {
+ case FW_INIT_STEP0_BOOT:
+ /* Download boot
+ * initialize command descriptor.
+ * will set polling bit when firmware code is also configured
+ */
+ pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE;
+#ifdef RTL8190P
+ // To initialize IMEM, CPU move code from 0x80000080, hence, we send 0x80 byte packet
+ rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET);
+ if(rt_status != true)
+ {
+ RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n");
+ goto download_firmware_fail;
+ }
+#endif
+ //mdelay(1000);
+ /*
+ * To initialize IMEM, CPU move code from 0x80000080,
+ * hence, we send 0x80 byte packet
+ */
+ break;
+
+ case FW_INIT_STEP1_MAIN:
+ /* Download firmware code. Wait until Boot Ready and Turn on CPU */
+ pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE;
+
+ /* Check Put Code OK and Turn On CPU */
+ rt_status = CPUcheck_maincodeok_turnonCPU(dev);
+ if(rt_status != TRUE) {
+ RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n");
+ goto download_firmware_fail;
+ }
+
+ pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU;
+ break;
+
+ case FW_INIT_STEP2_DATA:
+ /* download initial data code */
+ pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE;
+ mdelay(1);
+
+ rt_status = CPUcheck_firmware_ready(dev);
+ if(rt_status != TRUE) {
+ RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status);
+ goto download_firmware_fail;
+ }
+
+ /* wait until data code is initialized ready.*/
+ pfirmware->firmware_status = FW_STATUS_5_READY;
+ break;
+ }
+ }
+
+ RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n");
+ //assert(pfirmware->firmware_status == FW_STATUS_5_READY, ("Firmware Download Fail\n"));
+
+ return rt_status;
+
+download_firmware_fail:
+ RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__);
+ rt_status = FALSE;
+ return rt_status;
+
+}
+
+#if 0
+/*
+ * Procedure: (1) Transform firmware code from little endian to big endian if required.
+ * (2) Number of bytes in Firmware downloading should be multiple
+ * of 4 bytes. If length is not multiple of 4 bytes, appending of zeros is required
+ *
+ */
+void CmdAppendZeroAndEndianTransform(
+ u1Byte *pDst,
+ u1Byte *pSrc,
+ u2Byte *pLength)
+{
+
+ u2Byte ulAppendBytes = 0, i;
+ u2Byte ulLength = *pLength;
+
+//test only
+ //memset(pDst, 0xcc, 12);
+
+
+ /* Transform from little endian to big endian */
+//#if DEV_BUS_TYPE==PCI_INTERFACE
+#if 0
+ for( i=0 ; i<(*pLength) ; i+=4)
+ {
+ if((i+3) < (*pLength)) pDst[i+0] = pSrc[i+3];
+ if((i+2) < (*pLength)) pDst[i+1] = pSrc[i+2];
+ if((i+1) < (*pLength)) pDst[i+2] = pSrc[i+1];
+ if((i+0) < (*pLength)) pDst[i+3] = pSrc[i+0];
+ }
+#else
+ pDst += USB_HWDESC_HEADER_LEN;
+ ulLength -= USB_HWDESC_HEADER_LEN;
+
+ for( i=0 ; i<ulLength ; i+=4) {
+ if((i+3) < ulLength) pDst[i+0] = pSrc[i+3];
+ if((i+2) < ulLength) pDst[i+1] = pSrc[i+2];
+ if((i+1) < ulLength) pDst[i+2] = pSrc[i+1];
+ if((i+0) < ulLength) pDst[i+3] = pSrc[i+0];
+
+ }
+#endif
+
+ //1(2) Append Zero
+ if( ((*pLength) % 4) >0)
+ {
+ ulAppendBytes = 4-((*pLength) % 4);
+
+ for(i=0 ; i<ulAppendBytes; i++)
+ pDst[ 4*((*pLength)/4) + i ] = 0x0;
+
+ *pLength += ulAppendBytes;
+ }
+}
+#endif
+
+#if 0
+RT_STATUS
+CmdSendPacket(
+ PADAPTER Adapter,
+ PRT_TCB pTcb,
+ PRT_TX_LOCAL_BUFFER pBuf,
+ u4Byte BufferLen,
+ u4Byte PacketType,
+ BOOLEAN bLastInitPacket
+ )
+{
+ s2Byte i;
+ u1Byte QueueID;
+ u2Byte firstDesc,curDesc = 0;
+ u2Byte FragIndex=0, FragBufferIndex=0;
+
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+
+ CmdInitTCB(Adapter, pTcb, pBuf, BufferLen);
+
+
+ if(CmdCheckFragment(Adapter, pTcb, pBuf))
+ CmdFragmentTCB(Adapter, pTcb);
+ else
+ pTcb->FragLength[0] = (u2Byte)pTcb->BufferList[0].Length;
+
+ QueueID=pTcb->SpecifiedQueueID;
+#if DEV_BUS_TYPE!=USB_INTERFACE
+ firstDesc=curDesc=Adapter->NextTxDescToFill[QueueID];
+#endif
+
+#if DEV_BUS_TYPE!=USB_INTERFACE
+ if(VacancyTxDescNum(Adapter, QueueID) > pTcb->BufferCount)
+#else
+ if(PlatformIsTxQueueAvailable(Adapter, QueueID, pTcb->BufferCount) &&
+ RTIsListEmpty(&Adapter->TcbWaitQueue[QueueID]))
+#endif
+ {
+ pTcb->nDescUsed=0;
+
+ for(i=0 ; i<pTcb->BufferCount ; i++)
+ {
+ Adapter->HalFunc.TxFillCmdDescHandler(
+ Adapter,
+ pTcb,
+ QueueID, //QueueIndex
+ curDesc, //index
+ FragBufferIndex==0, //bFirstSeg
+ FragBufferIndex==(pTcb->FragBufCount[FragIndex]-1), //bLastSeg
+ pTcb->BufferList[i].VirtualAddress, //VirtualAddress
+ pTcb->BufferList[i].PhysicalAddressLow, //PhyAddressLow
+ pTcb->BufferList[i].Length, //BufferLen
+ i!=0, //bSetOwnBit
+ (i==(pTcb->BufferCount-1)) && bLastInitPacket, //bLastInitPacket
+ PacketType, //DescPacketType
+ pTcb->FragLength[FragIndex] //PktLen
+ );
+
+ if(FragBufferIndex==(pTcb->FragBufCount[FragIndex]-1))
+ { // Last segment of the fragment.
+ pTcb->nFragSent++;
+ }
+
+ FragBufferIndex++;
+ if(FragBufferIndex==pTcb->FragBufCount[FragIndex])
+ {
+ FragIndex++;
+ FragBufferIndex=0;
+ }
+
+#if DEV_BUS_TYPE!=USB_INTERFACE
+ curDesc=(curDesc+1)%Adapter->NumTxDesc[QueueID];
+#endif
+ pTcb->nDescUsed++;
+ }
+
+#if DEV_BUS_TYPE!=USB_INTERFACE
+ RTInsertTailList(&Adapter->TcbBusyQueue[QueueID], &pTcb->List);
+ IncrementTxDescToFill(Adapter, QueueID, pTcb->nDescUsed);
+ Adapter->HalFunc.SetTxDescOWNHandler(Adapter, QueueID, firstDesc);
+ // TODO: should call poll use QueueID
+ Adapter->HalFunc.TxPollingHandler(Adapter, TXCMD_QUEUE);
+#endif
+ }
+ else
+#if DEV_BUS_TYPE!=USB_INTERFACE
+ goto CmdSendPacket_Fail;
+#else
+ {
+ pTcb->bLastInitPacket = bLastInitPacket;
+ RTInsertTailList(&Adapter->TcbWaitQueue[pTcb->SpecifiedQueueID], &pTcb->List);
+ }
+#endif
+
+ return rtStatus;
+
+#if DEV_BUS_TYPE!=USB_INTERFACE
+CmdSendPacket_Fail:
+ rtStatus = RT_STATUS_FAILURE;
+ return rtStatus;
+#endif
+
+}
+#endif
+
+
+
+
+#if 0
+RT_STATUS
+FWSendNullPacket(
+ IN PADAPTER Adapter,
+ IN u4Byte Length
+)
+{
+ RT_STATUS rtStatus = RT_STATUS_SUCCESS;
+
+
+ PRT_TCB pTcb;
+ PRT_TX_LOCAL_BUFFER pBuf;
+ BOOLEAN bLastInitPacket = FALSE;
+
+ PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
+
+#if DEV_BUS_TYPE==USB_INTERFACE
+ Length += USB_HWDESC_HEADER_LEN;
+#endif
+
+ //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ)
+ if(MgntGetBuffer(Adapter, &pTcb, &pBuf))
+ {
+ PlatformZeroMemory(pBuf->Buffer.VirtualAddress, Length);
+ rtStatus = CmdSendPacket(Adapter, pTcb, pBuf, Length, DESC_PACKET_TYPE_INIT, bLastInitPacket); //0 : always set LastInitPacket to zero
+//#if HAL_CODE_BASE != RTL8190HW
+// // TODO: for test only
+// ReturnTCB(Adapter, pTcb, RT_STATUS_SUCCESS);
+//#endif
+ if(rtStatus == RT_STATUS_FAILURE)
+ goto CmdSendNullPacket_Fail;
+ }else
+ goto CmdSendNullPacket_Fail;
+
+ PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
+ return rtStatus;
+
+
+CmdSendNullPacket_Fail:
+ PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
+ rtStatus = RT_STATUS_FAILURE;
+ RT_ASSERT(rtStatus == RT_STATUS_SUCCESS, ("CmdSendDownloadCode fail !!\n"));
+ return rtStatus;
+}
+#endif
+
+
diff --git a/drivers/staging/rtl8192su/r819xU_firmware.h b/drivers/staging/rtl8192su/r819xU_firmware.h
new file mode 100644
index 000000000000..10801be014e0
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_firmware.h
@@ -0,0 +1,106 @@
+#ifndef __INC_FIRMWARE_H
+#define __INC_FIRMWARE_H
+
+#define RTL8190_CPU_START_OFFSET 0x80
+/* TODO: this definition is TBD */
+//#define USB_HWDESC_HEADER_LEN 0
+
+/* It should be double word alignment */
+//#if DEV_BUS_TYPE==PCI_INTERFACE
+//#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) 4*(v/4) - 8
+//#else
+#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN)
+//#endif
+
+typedef enum _firmware_init_step{
+ FW_INIT_STEP0_BOOT = 0,
+ FW_INIT_STEP1_MAIN = 1,
+ FW_INIT_STEP2_DATA = 2,
+}firmware_init_step_e;
+
+typedef enum _opt_rst_type{
+ OPT_SYSTEM_RESET = 0,
+ OPT_FIRMWARE_RESET = 1,
+}opt_rst_type_e;
+
+/* due to rtl8192 firmware */
+typedef enum _desc_packet_type_e{
+ DESC_PACKET_TYPE_INIT = 0,
+ DESC_PACKET_TYPE_NORMAL = 1,
+}desc_packet_type_e;
+
+typedef enum _firmware_source{
+ FW_SOURCE_IMG_FILE = 0,
+ FW_SOURCE_HEADER_FILE = 1, //from header file
+}firmware_source_e, *pfirmware_source_e;
+
+typedef enum _firmware_status{
+ FW_STATUS_0_INIT = 0,
+ FW_STATUS_1_MOVE_BOOT_CODE = 1,
+ FW_STATUS_2_MOVE_MAIN_CODE = 2,
+ FW_STATUS_3_TURNON_CPU = 3,
+ FW_STATUS_4_MOVE_DATA_CODE = 4,
+ FW_STATUS_5_READY = 5,
+}firmware_status_e;
+
+typedef struct _rt_firmare_seg_container {
+ u16 seg_size;
+ u8 *seg_ptr;
+}fw_seg_container, *pfw_seg_container;
+
+#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
+#define MAX_FW_INIT_STEP 3
+typedef struct _rt_firmware{
+ firmware_status_e firmware_status;
+ u16 cmdpacket_frag_thresold;
+ u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE];
+ u16 firmware_buf_size[MAX_FW_INIT_STEP];
+}rt_firmware, *prt_firmware;
+
+typedef struct _rt_firmware_info_819xUsb{
+ u8 sz_info[16];
+}rt_firmware_info_819xUsb, *prt_firmware_info_819xUsb;
+
+#if 0
+/* CPU related */
+RT_STATUS
+CPUCheckMainCodeOKAndTurnOnCPU(
+ IN PADAPTER Adapter
+ );
+
+RT_STATUS
+CPUCheckFirmwareReady(
+ IN PADAPTER Adapter
+ );
+
+/* Firmware related */
+VOID
+FWInitializeParameters(
+ IN PADAPTER Adapter
+ );
+
+RT_STATUS
+FWSendDownloadCode(
+ IN PADAPTER Adapter,
+ IN pu1Byte CodeVirtualAddrress,
+ IN u4Byte BufferLen
+ );
+
+RT_STATUS
+FWSendNullPacket(
+ IN PADAPTER Adapter,
+ IN u4Byte Length
+ );
+
+RT_STATUS
+CmdSendPacket(
+ PADAPTER Adapter,
+ PRT_TCB pTcb,
+ PRT_TX_LOCAL_BUFFER pBuf,
+ u4Byte BufferLen,
+ u4Byte PacketType,
+ BOOLEAN bLastInitPacket
+ );
+#endif
+#endif
+
diff --git a/drivers/staging/rtl8192su/r819xU_firmware_img.c b/drivers/staging/rtl8192su/r819xU_firmware_img.c
new file mode 100644
index 000000000000..29b656d7d82b
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_firmware_img.c
@@ -0,0 +1,3447 @@
+/*Created on 2008/ 7/16, 5:31*/
+#include <linux/types.h>
+
+u8 rtl8190_fwboot_array[] = {
+0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08,
+0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01,
+0x25,0x08,0xb0,0x50,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,
+0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b,
+0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00,
+0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01,
+0x25,0x08,0xb0,0x50,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0,
+0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00,
+0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00,
+0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,
+0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,
+0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01,
+0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24,
+0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10,
+0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
+0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10,
+0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x4b,0x84,
+0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,};
+
+u8 rtl8190_fwmain_array[] = {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x12,0x94,
+0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09,
+0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24,
+0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0,
+0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x8b,0x60,0x00,0x85,0x18,0x21,
+0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00,
+0x27,0x82,0x8b,0x6a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00,
+0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x8b,0x60,
+0x24,0x02,0x09,0xc4,0x24,0x03,0x01,0x00,0xa7,0x82,0x8b,0x76,0x24,0x02,0x04,0x00,
+0xaf,0x83,0x8b,0x78,0xaf,0x82,0x8b,0x7c,0x24,0x03,0x00,0x0a,0x24,0x02,0x00,0x04,
+0x24,0x05,0x00,0x02,0x24,0x04,0x00,0x01,0xa3,0x83,0x8b,0x62,0xa3,0x82,0x8b,0x68,
+0x24,0x03,0x00,0x01,0x24,0x02,0x02,0x00,0xa3,0x84,0x8b,0x66,0xa3,0x85,0x8b,0x69,
+0xa7,0x82,0x8b,0x6a,0xa7,0x83,0x8b,0x6c,0xa3,0x84,0x8b,0x61,0xa3,0x80,0x8b,0x63,
+0xa3,0x80,0x8b,0x64,0xa3,0x80,0x8b,0x65,0xa3,0x85,0x8b,0x67,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x84,
+0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x27,0x84,0x8b,0x88,0x00,0x00,0x10,0x21,
+0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,
+0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00,0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc8,0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,
+0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00,0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,
+0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00,0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,
+0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03,0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,
+0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11,0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,
+0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,
+0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,
+0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b,0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,
+0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20,0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,
+0x08,0x00,0x00,0x96,0x34,0x42,0x01,0x24,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x96,
+0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0x84,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18,0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,
+0x27,0x85,0x8b,0x80,0x8c,0xa3,0x00,0x00,0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,
+0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a,0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,
+0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01,0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,
+0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3,0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,
+0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,
+0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40,0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x8b,0x88,0x00,0x0a,0x20,0x0b,0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,
+0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,
+0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,
+0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01,0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,
+0x27,0x82,0x8b,0x88,0xa0,0x67,0x00,0x01,0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,
+0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x80,
+0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,
+0xac,0x62,0x00,0x00,0x27,0x85,0x8b,0x84,0x27,0x82,0x8b,0x80,0x00,0xc5,0x28,0x21,
+0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00,0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,
+0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x08,0x00,0x00,0xb9,0xac,0xa0,0x00,0x00,0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0xaf,0x83,0x8b,0x9c,0x08,0x00,0x00,0xa9,0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0x90,
+0x08,0x00,0x00,0xa9,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x18,0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,
+0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00,0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,
+0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03,0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,
+0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2,0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,
+0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09,0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,
+0x30,0x43,0x00,0x03,0x83,0x82,0x8b,0x88,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04,0x30,0x43,0x00,0x06,0x93,0x82,0x8b,0xa0,
+0x08,0x00,0x01,0x21,0x00,0x43,0x10,0x21,0x83,0x82,0x8b,0x94,0x00,0x00,0x00,0x00,
+0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x21,0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,
+0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01,0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xec,0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,
+0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01,0xaf,0x84,0x8b,0xb0,
+0xa3,0x82,0x8b,0xc0,0xa7,0x80,0x8b,0xb4,0xa7,0x80,0x8b,0xb6,0xaf,0x80,0x8b,0xb8,
+0xaf,0x80,0x8b,0xbc,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x05,0x2c,0x3c,0x04,0xb0,0x03,
+0xac,0x62,0x00,0x00,0x34,0x84,0x00,0xac,0x80,0xa2,0x00,0x15,0x8c,0x83,0x00,0x00,
+0x27,0xbd,0xff,0xf0,0x00,0x43,0x10,0x21,0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x10,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,
+0x24,0x63,0x05,0x64,0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,0x8f,0x90,0x8b,0xb0,0x0c,0x00,0x02,0x9a,
+0x00,0x80,0x88,0x21,0x14,0x40,0x00,0x2a,0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,
+0x34,0x42,0x02,0x01,0x24,0x02,0x02,0x01,0xae,0x02,0x00,0x00,0x97,0x84,0x8b,0xb4,
+0x97,0x82,0x8b,0xb6,0x3c,0x03,0xb0,0x02,0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,
+0xa7,0x82,0x8b,0xb6,0xa4,0x82,0x00,0x00,0x8f,0x84,0x8b,0xb8,0x8f,0x82,0x8b,0xb0,
+0x93,0x85,0x8b,0x62,0x24,0x84,0x00,0x01,0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,
+0x3c,0x07,0xb0,0x06,0x3c,0x06,0xb0,0x03,0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,
+0x34,0xe7,0x80,0x18,0xaf,0x82,0x8b,0xb0,0xaf,0x84,0x8b,0xb8,0x10,0xa0,0x00,0x08,
+0x34,0xc6,0x01,0x08,0x8f,0x83,0x8b,0xbc,0x8f,0x84,0x8b,0x7c,0x8c,0xc2,0x00,0x00,
+0x00,0x64,0x18,0x21,0x00,0x43,0x10,0x2b,0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,
+0x8c,0xe2,0x00,0x00,0x3c,0x03,0x0f,0x00,0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,
+0x10,0x44,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x98,0x00,0x00,0x00,0x00,
+0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x27,0xbd,0xff,0xd8,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x50,
+0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20,0x8f,0x90,0x8b,0xb0,0xac,0x43,0x00,0x00,
+0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,
+0x00,0x80,0x88,0x21,0x00,0xa0,0x90,0x21,0x0c,0x00,0x02,0x9a,0x00,0xc0,0x98,0x21,
+0x24,0x07,0x8f,0xff,0x14,0x40,0x00,0x19,0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,
+0xae,0x02,0x00,0x00,0x00,0x67,0x80,0x24,0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,
+0x00,0x47,0x80,0x24,0x97,0x86,0x8b,0xb4,0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,
+0x00,0x67,0x80,0x24,0xae,0x13,0x00,0x00,0x8f,0x84,0x8b,0xb0,0x3c,0x02,0xb0,0x02,
+0x97,0x85,0x8b,0xb6,0x00,0xc2,0x30,0x21,0x8f,0x82,0x8b,0xb8,0x24,0x84,0x00,0x10,
+0x24,0xa5,0x00,0x10,0x00,0x87,0x20,0x24,0x24,0x42,0x00,0x01,0xa7,0x85,0x8b,0xb6,
+0xaf,0x84,0x8b,0xb0,0xaf,0x82,0x8b,0xb8,0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,
+0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x14,0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x02,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfc,0x00,0x82,0x28,0x21,0x8c,0xa4,0x00,0x00,
+0x3c,0x02,0x00,0x70,0x8c,0xa6,0x00,0x08,0x00,0x82,0x10,0x21,0x2c,0x43,0x00,0x06,
+0x10,0x60,0x00,0x09,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80,0x24,0x63,0x01,0xe8,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,
+0x00,0x00,0x00,0x00,0xaf,0x86,0x80,0x14,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x8c,0xa4,0x00,0x00,0x0c,0x00,0x17,0xb3,
+0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xde,0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0xaa,
+0x00,0xc0,0x20,0x21,0x08,0x00,0x01,0xde,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x80,0x18,0x3c,0x03,0x00,0x0f,
+0x34,0x63,0x42,0x40,0x00,0x43,0x10,0x21,0x00,0x82,0x20,0x2b,0x10,0x80,0x00,0x09,
+0x24,0x03,0x00,0x05,0x8f,0x82,0x83,0x30,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,
+0xaf,0x82,0x83,0x30,0x10,0x43,0x00,0x03,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x8c,0x63,0x01,0x08,0x24,0x02,0x00,0x01,
+0xa3,0x82,0x80,0x11,0xaf,0x80,0x83,0x30,0xaf,0x83,0x80,0x18,0x08,0x00,0x01,0xfb,
+0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff,0x14,0x80,0x00,0x2f,0x00,0x00,0x00,0x00,
+0x8f,0x82,0x80,0x14,0xa3,0x85,0x83,0x63,0x10,0x40,0x00,0x2b,0x2c,0xa2,0x00,0x04,
+0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xfc,0x2c,0x42,0x00,0x08,
+0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xf0,0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x6c,
+0x00,0x44,0x10,0x21,0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,
+0x03,0xe0,0x00,0x08,0xa4,0x43,0x00,0x00,0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,
+0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xe0,0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x06,
+0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xd0,0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x09,
+0x24,0xa2,0xff,0xc0,0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x6c,0x00,0x44,0x10,0x21,
+0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,
+0xa4,0x43,0xff,0xf8,0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x07,0x00,0x05,0x10,0x40,
+0x27,0x84,0x83,0x6c,0x00,0x44,0x10,0x21,0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,
+0x24,0x63,0x00,0x01,0xa4,0x43,0xff,0xf8,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x8f,0x86,0x8b,0xb0,0x8f,0x82,0x80,0x14,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
+0x10,0x40,0x00,0x2a,0x00,0xc0,0x38,0x21,0x24,0x02,0x00,0x07,0x24,0x03,0xff,0x9c,
+0xa3,0x82,0x83,0x6b,0xa3,0x83,0x83,0x6a,0x27,0x8a,0x83,0x68,0x00,0x00,0x20,0x21,
+0x24,0x09,0x8f,0xff,0x00,0x04,0x10,0x80,0x00,0x4a,0x28,0x21,0x8c,0xa2,0x00,0x00,
+0x24,0xe3,0x00,0x04,0x24,0x88,0x00,0x01,0xac,0xe2,0x00,0x00,0x10,0x80,0x00,0x02,
+0x00,0x69,0x38,0x24,0xac,0xa0,0x00,0x00,0x31,0x04,0x00,0xff,0x2c,0x82,0x00,0x27,
+0x14,0x40,0xff,0xf5,0x00,0x04,0x10,0x80,0x97,0x83,0x8b,0xb6,0x97,0x85,0x8b,0xb4,
+0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x9c,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,
+0xa7,0x83,0x8b,0xb6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,
+0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x9c,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,
+0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xb0,0x10,0xa2,0x00,0x03,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x98,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x8f,0x86,0x8b,0xb0,
+0x27,0xbd,0xff,0xc8,0x24,0x02,0x00,0x08,0x24,0x03,0x00,0x20,0xaf,0xbf,0x00,0x30,
+0xa3,0xa2,0x00,0x13,0xa3,0xa3,0x00,0x12,0xa7,0xa4,0x00,0x10,0x00,0xc0,0x28,0x21,
+0x27,0xa9,0x00,0x10,0x00,0x00,0x38,0x21,0x24,0x08,0x8f,0xff,0x00,0x07,0x10,0x80,
+0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,
+0x24,0xa2,0x00,0x04,0x2c,0xe3,0x00,0x08,0xac,0xa4,0x00,0x00,0x14,0x60,0xff,0xf7,
+0x00,0x48,0x28,0x24,0x97,0x83,0x8b,0xb6,0x97,0x85,0x8b,0xb4,0x3c,0x02,0xb0,0x02,
+0x24,0x63,0x00,0x20,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xb6,
+0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,
+0x24,0xc6,0x00,0x20,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,
+0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xb0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x04,0x98,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x30,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x93,0x82,0x8b,0xc0,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01,0x8f,0x82,0x8b,0xb8,0x3c,0x05,0xb0,0x06,
+0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18,0x34,0x84,0x01,0x08,0x14,0x40,0x00,0x09,
+0x00,0x00,0x30,0x21,0x97,0x82,0x8b,0xb4,0x8c,0x84,0x00,0x00,0x3c,0x03,0xb0,0x02,
+0x00,0x43,0x10,0x21,0xaf,0x84,0x8b,0xbc,0xa7,0x80,0x8b,0xb6,0xac,0x40,0x00,0x00,
+0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,
+0x8f,0x86,0x8b,0xb0,0x8f,0x82,0x8b,0xb8,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
+0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a,0x00,0x40,0x50,0x21,0x00,0x00,0x38,0x21,
+0x27,0x89,0x83,0x38,0x24,0xe2,0x00,0x01,0x00,0x07,0x18,0x80,0x30,0x47,0x00,0xff,
+0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a,0x14,0x40,0xff,0xfa,0xac,0x60,0x00,0x00,
+0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6f,0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x3e,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x3e,0x90,0xa3,0x00,0x15,
+0x97,0x82,0x83,0x40,0x00,0x03,0x1e,0x00,0x00,0x03,0x1e,0x03,0x00,0x43,0x10,0x21,
+0xa7,0x82,0x83,0x40,0x8c,0xa4,0x00,0x20,0x3c,0x02,0x00,0x60,0x3c,0x03,0x00,0x20,
+0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x54,0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x47,
+0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x44,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,
+0xa7,0x82,0x83,0x44,0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x54,0x00,0x00,0x00,0x00,
+0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x54,0x25,0x42,0x00,0x01,0x28,0x43,0x27,0x10,
+0xaf,0x82,0x8b,0xb8,0x10,0x60,0x00,0x09,0x24,0x02,0x00,0x04,0x93,0x83,0x80,0x11,
+0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x10,
+0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x24,0x03,0x00,0x28,
+0xa3,0x83,0x83,0x3a,0xa3,0x82,0x83,0x3b,0x90,0xa2,0x00,0x18,0x93,0x83,0x83,0x63,
+0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,0xa7,0x82,0x83,0x4e,
+0xa3,0x83,0x83,0x5c,0x27,0x89,0x83,0x38,0x24,0x05,0x8f,0xff,0x00,0x07,0x10,0x80,
+0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,
+0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a,0xad,0x04,0x00,0x00,0x14,0x60,0xff,0xf7,
+0x00,0x45,0x40,0x24,0x97,0x83,0x8b,0xb6,0x97,0x85,0x8b,0xb4,0x3c,0x02,0xb0,0x02,
+0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xb6,
+0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,
+0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,
+0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xb0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x04,0x98,0x00,0x00,0x00,0x00,0x0c,0x00,0x02,0x38,0x00,0x00,0x00,0x00,
+0xa3,0x80,0x80,0x11,0x08,0x00,0x02,0xe7,0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x46,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x46,0x84,0xa3,0x00,0x06,
+0x8f,0x82,0x83,0x58,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x58,
+0x08,0x00,0x02,0xdf,0x25,0x42,0x00,0x01,0x97,0x82,0x83,0x42,0x00,0x00,0x00,0x00,
+0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x42,0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x50,
+0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x50,0x08,0x00,0x02,0xdf,
+0x25,0x42,0x00,0x01,0x97,0x82,0x83,0x3c,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,
+0xa7,0x82,0x83,0x3c,0x08,0x00,0x02,0xc7,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd0,
+0xaf,0xbf,0x00,0x28,0x8c,0xa3,0x00,0x20,0x8f,0x8a,0x8b,0xb0,0x3c,0x02,0x00,0x10,
+0x00,0x62,0x10,0x24,0x00,0xa0,0x38,0x21,0x01,0x40,0x48,0x21,0x10,0x40,0x00,0x3d,
+0x00,0x80,0x28,0x21,0x8c,0xe4,0x00,0x1c,0x34,0xa5,0x12,0x06,0xaf,0xa5,0x00,0x10,
+0x8c,0x82,0x00,0x08,0x00,0x03,0x1c,0x42,0x30,0x63,0x00,0x30,0x00,0x02,0x13,0x02,
+0x30,0x42,0x00,0x40,0x00,0x43,0x10,0x25,0x90,0xe6,0x00,0x10,0x90,0xe4,0x00,0x13,
+0x94,0xe8,0x00,0x0c,0x94,0xe3,0x00,0x1a,0x00,0x02,0x16,0x00,0x90,0xe7,0x00,0x12,
+0x00,0xa2,0x28,0x25,0x24,0x02,0x12,0x34,0xa7,0xa2,0x00,0x1c,0x24,0x02,0x56,0x78,
+0xaf,0xa5,0x00,0x10,0xa3,0xa6,0x00,0x18,0xa3,0xa7,0x00,0x1f,0xa7,0xa3,0x00,0x1a,
+0xa3,0xa4,0x00,0x19,0xa7,0xa8,0x00,0x20,0xa7,0xa2,0x00,0x22,0x00,0x00,0x28,0x21,
+0x27,0xa7,0x00,0x10,0x24,0x06,0x8f,0xff,0x00,0x05,0x10,0x80,0x00,0x47,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01,0x30,0x65,0x00,0xff,0x25,0x22,0x00,0x04,
+0x2c,0xa3,0x00,0x05,0xad,0x24,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x46,0x48,0x24,
+0x97,0x83,0x8b,0xb6,0x97,0x85,0x8b,0xb4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x14,
+0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xb6,0x34,0x84,0x80,0x18,
+0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x25,0x46,0x00,0x14,
+0x3c,0x03,0x0f,0x00,0x00,0xc2,0x50,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,
+0xaf,0x8a,0x8b,0xb0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x98,
+0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x28,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x30,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,
+0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x0e,0x04,0x3c,0x03,0xb0,0x00,
+0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,
+0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,0xac,0xa2,0x00,0x00,0x8e,0x09,0x00,0x00,
+0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08,0x00,0x09,0xa6,0x02,0x12,0x80,0x00,0x13,
+0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02,0x3c,0x16,0x00,0xff,0x3c,0x17,0xff,0x00,
+0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x12,0x02,0x24,0x42,0x00,0x02,
+0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76,0x30,0x51,0x00,0xff,0x24,0x02,0x00,0x03,
+0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00,0x02,0x51,0x10,0x21,0x30,0x52,0xff,0xff,
+0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2,0x02,0x11,0x80,0x21,0x12,0xa0,0x00,0x0a,
+0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,0x8c,0x43,0x00,0x00,0x3c,0x04,0x0f,0x00,
+0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24,0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x04,0x98,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,
+0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04,0x24,0x15,0x00,0x01,0x8e,0x06,0x00,0x0c,
+0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2,0x30,0x48,0x00,0x03,0x00,0x09,0x14,0x02,
+0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02,0x11,0x15,0x00,0x45,0x30,0x43,0x00,0x0f,
+0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26,0x00,0x00,0x00,0x00,0x11,0x13,0x00,0x0f,
+0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02,0x30,0x84,0xff,0x00,0x3c,0x03,0x00,0xff,
+0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00,0x00,0x43,0x10,0x24,0x00,0xa4,0x28,0x25,
+0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00,0x00,0xa3,0x28,0x25,0x0c,0x00,0x01,0x94,
+0x01,0x20,0x20,0x21,0x08,0x00,0x03,0xa7,0x02,0x51,0x10,0x21,0x11,0x95,0x00,0x0f,
+0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x80,
+0x27,0x83,0x8b,0x60,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18,0x08,0x00,0x03,0xce,
+0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40,0x27,0x83,0x8b,0x68,0x00,0x43,0x10,0x21,
+0x94,0x47,0x00,0x02,0x08,0x00,0x03,0xce,0x00,0x07,0x22,0x02,0x27,0x82,0x8b,0x60,
+0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00,0x08,0x00,0x03,0xce,0x00,0x07,0x22,0x02,
+0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21,0x10,0x75,0x00,0x05,0x00,0x80,0x38,0x21,
+0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00,0x00,0x00,0x38,0x21,0x00,0x43,0x38,0x0a,
+0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e,0x3c,0x02,0xb0,0x03,0x24,0x02,0x00,0x02,
+0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,
+0x8c,0x47,0x00,0x00,0x08,0x00,0x03,0xce,0x00,0x07,0x22,0x02,0x3c,0x02,0xb0,0x03,
+0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00,0x08,0x00,0x03,0xcd,0x30,0x67,0xff,0xff,
+0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00,0x08,0x00,0x03,0xcd,0x30,0x67,0x00,0xff,
+0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00,0x11,0x95,0x00,0x07,0x00,0x44,0x38,0x21,
+0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x03,0xff,0x3c,0x02,0xb0,0x0a,
+0x08,0x00,0x04,0x04,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x04,0x08,0x3c,0x02,0xb0,0x0a,
+0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08,0x8e,0x03,0x00,0x0c,0x00,0x09,0x41,0x42,
+0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02,0x30,0x84,0xff,0x00,0x30,0xe7,0xff,0x00,
+0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00,0x00,0x03,0x56,0x02,0x00,0x03,0x2a,0x00,
+0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24,0x01,0x47,0x50,0x25,0x00,0x02,0x16,0x00,
+0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00,0x01,0x66,0x58,0x25,0x01,0x45,0x50,0x25,
+0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24,0x01,0x62,0x38,0x25,0x01,0x43,0x30,0x25,
+0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02,0x31,0x08,0x00,0x03,0x30,0x4c,0x00,0x03,
+0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02,0x00,0xe0,0x58,0x21,0x15,0x00,0x00,0x28,
+0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x06,0x00,0x80,0x28,0x21,
+0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69,0x02,0x51,0x10,0x21,0x24,0x85,0x01,0x00,
+0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15,0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x0a,
+0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,
+0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xac,0x62,0x00,0x00,
+0x08,0x00,0x03,0xa7,0x02,0x51,0x10,0x21,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,
+0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,
+0xa4,0x62,0x00,0x00,0x08,0x00,0x03,0xa7,0x02,0x51,0x10,0x21,0x3c,0x03,0xb0,0x03,
+0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,
+0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa6,0xa0,0x62,0x00,0x00,
+0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21,0x00,0x00,0x00,0x00,0x15,0x13,0xff,0x42,
+0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x0b,
+0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x60,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,
+0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,
+0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa6,0xac,0x82,0x00,0x18,0x27,0x83,0x8b,0x68,
+0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21,0x94,0x82,0x00,0x02,0x00,0x06,0x18,0x27,
+0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa6,
+0xa4,0x82,0x00,0x02,0x27,0x83,0x8b,0x60,0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x00,
+0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x5c,0x00,0xe6,0x28,0x24,0x30,0x62,0x00,0x07,
+0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f,0x00,0x44,0x10,0x21,0x11,0x93,0x00,0x07,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x8c,0x62,0x00,0x00,
+0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x49,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,
+0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x52,
+0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x08,0x00,0x04,0x7f,0x00,0x43,0x18,0x21,
+0x97,0x85,0x8b,0xb4,0x3c,0x07,0xb0,0x02,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20,0x24,0x42,0x12,0x60,0x24,0x03,0xff,0x80,
+0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07,0x97,0x82,0x8b,0xb6,0x97,0x85,0x8b,0xb4,
+0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8,0x24,0x42,0x00,0x10,0x00,0xa2,0x10,0x21,
+0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08,0x30,0x84,0x0f,0xff,0x00,0x05,0x28,0xc2,
+0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25,0x00,0x87,0x20,0x21,0x34,0xc6,0x80,0x18,
+0xac,0xc5,0x00,0x00,0xaf,0x84,0x8b,0xb0,0xa7,0x82,0x8b,0xb4,0xa7,0x80,0x8b,0xb6,
+0xaf,0x80,0x8b,0xb8,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,
+0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01,0x00,0xe0,0x48,0x21,0x30,0xc6,0x00,0xff,
+0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07,0x00,0xa0,0x40,0x21,0x24,0x02,0x00,0x03,
+0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03,0x24,0x02,0x00,0x01,0x00,0x07,0x20,0x27,
+0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14,0x01,0x03,0x18,0x21,0x24,0x02,0x00,0x02,
+0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27,0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,
+0x08,0x00,0x04,0xe3,0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,
+0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,
+0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa0,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07,0x00,0x04,0x22,0x00,0x30,0xa5,0x00,0xff,
+0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a,0x00,0xa2,0x40,0x21,0x30,0xc6,0x00,0xff,
+0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10,0x10,0xc2,0x00,0x14,0x24,0x02,0x00,0x02,
+0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09,0x00,0xe4,0x48,0x24,0x3c,0x03,0xb0,0x0a,
+0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,
+0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x0a,
+0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,
+0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00,0x91,0x02,0x00,0x00,
+0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24,0x00,0x43,0x10,0x24,0x00,0x44,0x10,0x25,
+0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00,0x30,0xa9,0x00,0xff,0x27,0x83,0x8b,0x60,
+0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01,0x00,0x07,0x50,0x27,0x00,0xc7,0x40,0x24,
+0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21,0x00,0x05,0x20,0x40,0x27,0x82,0x8b,0x60,
+0x00,0x05,0x28,0x80,0x27,0x83,0x8b,0x68,0x00,0x83,0x50,0x21,0x00,0xa2,0x20,0x21,
+0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27,0x11,0x22,0x00,0x07,0x00,0xc7,0x28,0x24,
+0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,
+0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18,0x95,0x42,0x00,0x02,0x00,0x00,0x00,0x00,
+0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa5,0x42,0x00,0x02,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x48,0x10,0x25,
+0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00,0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,
+0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00,0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,
+0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25,0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x44,0x10,0x25,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe8,
+0x34,0x63,0x00,0x20,0x24,0x42,0x14,0xe4,0x3c,0x04,0xb0,0x03,0xaf,0xbf,0x00,0x14,
+0xac,0x62,0x00,0x00,0xaf,0xb0,0x00,0x10,0x34,0x84,0x00,0x2c,0x8c,0x83,0x00,0x00,
+0xa7,0x80,0xbb,0xf0,0x00,0x03,0x12,0x02,0x00,0x03,0x2d,0x02,0x30,0x42,0x0f,0xff,
+0xa3,0x83,0xbb,0xf8,0xa7,0x85,0xbb,0xfc,0xa7,0x82,0xbb,0xfa,0xa7,0x80,0xbb,0xf2,
+0xa7,0x80,0xbb,0xf4,0xa7,0x80,0xbb,0xf6,0x0c,0x00,0x06,0xce,0x24,0x04,0x05,0x00,
+0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xc1,
+0x00,0x40,0x80,0x21,0x3c,0x02,0xf7,0xff,0x34,0x42,0xff,0xff,0x02,0x02,0x80,0x24,
+0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xc1,0x24,0x04,0x05,0x00,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0xb0,0x03,0x34,0x42,0x01,0x08,0x34,0x63,0x01,0x18,0x8c,0x45,0x00,0x00,
+0x8c,0x64,0x00,0x00,0x3c,0x02,0x00,0x0f,0x3c,0x03,0x00,0x4c,0x30,0x84,0x02,0x00,
+0x34,0x63,0x4b,0x40,0xaf,0x85,0xbc,0x00,0x10,0x80,0x00,0x06,0x34,0x42,0x42,0x40,
+0xaf,0x83,0xbc,0x04,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0xaf,0x82,0xbc,0x04,0x08,0x00,0x05,0x69,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x34,0x63,0x00,0x20,
+0x24,0x42,0x15,0xc0,0x30,0x84,0x00,0xff,0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,
+0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00,
+0x10,0x80,0x00,0x1c,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x08,0x00,0x00,0x00,0x00,
+0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xa7,0x80,0xbb,0xf0,
+0xa7,0x80,0xbb,0xf2,0xa7,0x80,0xbb,0xf4,0xa7,0x80,0xbb,0xf6,0x0c,0x00,0x06,0xce,
+0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,
+0x0c,0x00,0x06,0xc1,0x00,0x40,0x80,0x21,0x3c,0x05,0xf7,0xff,0x34,0xa5,0xff,0xff,
+0x02,0x05,0x28,0x24,0x0c,0x00,0x06,0xc1,0x24,0x04,0x05,0x00,0x08,0x00,0x05,0x84,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xce,0x24,0x04,0x05,0xa0,0x24,0x04,0x05,0xa4,
+0x0c,0x00,0x06,0xce,0x00,0x02,0xbc,0x02,0x24,0x04,0x05,0xa8,0x00,0x02,0xb4,0x02,
+0x0c,0x00,0x06,0xce,0x30,0x55,0xff,0xff,0x00,0x40,0x80,0x21,0x97,0x84,0xbb,0xf0,
+0x97,0x82,0xbb,0xf2,0x97,0x83,0xbb,0xf6,0x02,0xe4,0x20,0x23,0x02,0xa2,0x10,0x23,
+0x00,0x82,0x20,0x21,0x97,0x82,0xbb,0xf4,0x32,0x14,0xff,0xff,0x02,0x83,0x18,0x23,
+0x02,0xc2,0x10,0x23,0x00,0x82,0x20,0x21,0x93,0x82,0xbb,0xf8,0x00,0x83,0x20,0x21,
+0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b,0x14,0x40,0x00,0xaa,0x00,0x00,0x00,0x00,
+0x97,0x82,0xbb,0xfc,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x7f,
+0x00,0x00,0x00,0x00,0x97,0x82,0xbb,0xfa,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,
+0x10,0x40,0x00,0x3a,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xce,0x24,0x04,0x04,0x50,
+0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,0x10,0x40,0x00,0x13,
+0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x17,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,
+0x26,0x31,0x00,0x01,0x00,0x51,0x80,0x25,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xc1,
+0x24,0x04,0x04,0x50,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xc1,0x24,0x04,0x04,0x58,
+0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xc1,0x24,0x04,0x04,0x60,0x02,0x00,0x28,0x21,
+0x24,0x04,0x04,0x68,0x0c,0x00,0x06,0xc1,0x00,0x00,0x00,0x00,0xa7,0x97,0xbb,0xf0,
+0xa7,0x95,0xbb,0xf2,0xa7,0x96,0xbb,0xf4,0xa7,0x94,0xbb,0xf6,0x08,0x00,0x05,0x84,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,
+0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,
+0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
+0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x08,
+0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,
+0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xc1,
+0x24,0x04,0x02,0x2c,0x08,0x00,0x05,0xcb,0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xce,
+0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20,0x16,0x22,0xff,0xdb,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,
+0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xce,
+0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c,0x0c,0x00,0x06,0xce,0x00,0x02,0x9e,0x02,
+0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,
+0x14,0x60,0x00,0x1d,0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,
+0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xc1,0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,
+0x08,0x00,0x05,0xd9,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x08,
+0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,
+0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xee,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,
+0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x08,
+0x08,0x00,0x06,0x15,0x3c,0x02,0xff,0xff,0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x08,
+0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,
+0x14,0x43,0xff,0xdf,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,
+0x3c,0x03,0x00,0x80,0x08,0x00,0x06,0x2a,0x00,0x43,0x28,0x25,0x0c,0x00,0x06,0xce,
+0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,
+0x10,0x40,0xff,0x9a,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x04,0x24,0x02,0xff,0x80,
+0x02,0x02,0x10,0x24,0x08,0x00,0x05,0xcd,0x26,0x31,0x00,0x02,0x0c,0x00,0x06,0xce,
+0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,
+0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,
+0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x08,0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x2c,
+0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,
+0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x44,
+0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xce,0x24,0x04,0x04,0x50,0x00,0x40,0x80,0x21,
+0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x1d,0x2e,0x22,0x00,0x21,
+0x14,0x40,0xff,0x72,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x26,0x31,0xff,0xff,
+0x00,0x51,0x80,0x25,0x24,0x04,0x04,0x50,0x0c,0x00,0x06,0xc1,0x02,0x00,0x28,0x21,
+0x24,0x04,0x04,0x58,0x0c,0x00,0x06,0xc1,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x60,
+0x0c,0x00,0x06,0xc1,0x02,0x00,0x28,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xc1,
+0x24,0x04,0x04,0x68,0x24,0x02,0x00,0x20,0x16,0x22,0xff,0x60,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,
+0x34,0x42,0x3f,0xff,0x02,0x42,0x10,0x24,0x08,0x00,0x06,0x1b,0x34,0x52,0x80,0x00,
+0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,
+0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x58,
+0x24,0x04,0x02,0x5c,0x0c,0x00,0x06,0xce,0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,
+0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x20,
+0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,
+0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,
+0x0c,0x00,0x06,0xc1,0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xc1,
+0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x68,0x2e,0x22,0x00,0x21,0x0c,0x00,0x06,0xce,
+0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,
+0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xec,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,
+0x0c,0x00,0x06,0xc1,0x24,0x04,0x02,0x08,0x08,0x00,0x06,0x98,0x3c,0x02,0xff,0xff,
+0x0c,0x00,0x06,0xce,0x24,0x04,0x02,0x08,0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,
+0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,0x14,0x43,0xff,0xdc,0x3c,0x03,0x00,0x80,
+0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x08,0x00,0x06,0xb0,
+0x00,0x43,0x28,0x25,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,
+0x3c,0x02,0xb0,0x0a,0x00,0x82,0x20,0x21,0xac,0x85,0x00,0x00,0x00,0x00,0x18,0x21,
+0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x0a,0x14,0x40,0xff,0xfe,0x24,0x63,0x00,0x01,
+0x03,0xe0,0x00,0x08,0x24,0x63,0xff,0xff,0x30,0x86,0x00,0x03,0x00,0x04,0x28,0x40,
+0x3c,0x03,0xb0,0x0a,0x00,0xa6,0x10,0x23,0x00,0x43,0x10,0x21,0x24,0x04,0xff,0xff,
+0xac,0x44,0x10,0x00,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x0a,
+0x14,0x40,0xff,0xfe,0x24,0x63,0x00,0x01,0x24,0x63,0xff,0xff,0x00,0xa6,0x18,0x23,
+0x3c,0x02,0xb0,0x0a,0x00,0x62,0x18,0x21,0x8c,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x1b,0x84,
+0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03,0xac,0xa2,0x00,0x00,
+0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,
+0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08,0xa0,0x80,0x00,0x09,
+0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13,0xa0,0x80,0x00,0x49,
+0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xa0,0x80,0x00,0x4e,0x00,0x02,0x14,0x00,
+0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00,0xa4,0x82,0x00,0x44,
+0xa4,0x83,0x00,0x46,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,
+0xac,0x80,0x00,0x30,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xac,0x80,0x00,0x3c,
+0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c,0x3c,0x07,0xb0,0x03,
+0x34,0xe7,0x00,0x20,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x8f,0xf4,0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18,0x3c,0x02,0x80,0x00,
+0x24,0x42,0x1c,0x18,0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08,0x80,0x82,0x00,0x13,
+0x00,0x05,0x2c,0x00,0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00,0x30,0x63,0x00,0x7e,
+0x00,0x62,0x18,0x21,0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00,0x3c,0x05,0xb0,0x05,
+0x34,0x42,0x04,0x00,0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05,0x3c,0x08,0xb0,0x05,
+0x34,0xa5,0x04,0x20,0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21,0x34,0xe7,0x04,0x24,
+0x35,0x08,0x02,0x28,0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20,0xac,0xe6,0x00,0x00,
+0xac,0x82,0x00,0x3c,0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00,0x27,0xbd,0xff,0xa8,
+0x00,0x07,0x60,0x80,0x27,0x82,0xb3,0xf0,0xaf,0xbe,0x00,0x50,0xaf,0xb7,0x00,0x4c,
+0xaf,0xb5,0x00,0x44,0xaf,0xb4,0x00,0x40,0xaf,0xbf,0x00,0x54,0xaf,0xb6,0x00,0x48,
+0xaf,0xb3,0x00,0x3c,0xaf,0xb2,0x00,0x38,0xaf,0xb1,0x00,0x34,0xaf,0xb0,0x00,0x30,
+0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0xe0,0x70,0x21,0x3c,0x02,0x80,0x00,
+0x94,0x73,0x00,0x14,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,0x24,0x42,0x1c,0xac,
+0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,0x34,0x63,0x01,0x28,0x90,0x67,0x00,0x00,
+0x00,0x13,0xa8,0xc0,0x02,0xb3,0x18,0x21,0x27,0x82,0x8f,0xf4,0x00,0x03,0x18,0x80,
+0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,0x00,0x07,0x3e,0x00,0x28,0xc2,0x00,0x03,
+0x00,0xc0,0xa0,0x21,0x00,0x80,0x78,0x21,0x00,0x05,0xbc,0x03,0x8c,0x68,0x00,0x18,
+0x02,0xa0,0x58,0x21,0x10,0x40,0x01,0x81,0x00,0x07,0xf6,0x03,0x00,0xde,0x10,0x07,
+0x30,0x5e,0x00,0x01,0x01,0x73,0x10,0x21,0x27,0x83,0x8f,0xf8,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x80,0x4d,0x00,0x06,0x8d,0x03,0x00,0x00,0x8d,0x02,0x00,0x04,
+0x8d,0x0a,0x00,0x08,0x8d,0x03,0x00,0x0c,0xaf,0xa2,0x00,0x20,0x11,0xa0,0x01,0x71,
+0xaf,0xa3,0x00,0x18,0x27,0x82,0xb3,0xf0,0x01,0x82,0x10,0x21,0x8c,0x44,0x00,0x00,
+0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04,
+0x14,0x60,0x00,0x12,0x00,0x00,0xb0,0x21,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x46,
+0x90,0x43,0x00,0x00,0x2a,0x84,0x00,0x04,0x10,0x80,0x01,0x56,0x30,0x65,0x00,0x01,
+0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x82,0x00,0x02,0x00,0x00,0x00,0x00,
+0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,0x00,0x00,0x38,0x21,0x13,0xc0,0x00,0x03,
+0x38,0xf6,0x00,0x01,0x24,0x07,0x00,0x01,0x38,0xf6,0x00,0x01,0x01,0x73,0x10,0x21,
+0x00,0x02,0x30,0x80,0x27,0x83,0x90,0x00,0x00,0xc3,0x48,0x21,0x91,0x25,0x00,0x00,
+0x8f,0xa4,0x00,0x20,0x2c,0xa3,0x00,0x04,0x00,0x04,0x11,0xc3,0x30,0x42,0x00,0x01,
+0x00,0x03,0xb0,0x0b,0x12,0xc0,0x00,0xd8,0xaf,0xa2,0x00,0x24,0x93,0x90,0xbb,0xda,
+0x00,0x0a,0x16,0x42,0x30,0x52,0x00,0x3f,0x2e,0x06,0x00,0x0c,0x10,0xc0,0x00,0xc0,
+0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10,0x14,0x40,0x00,0x04,0x00,0x90,0x10,0x2b,
+0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04,0x00,0x90,0x10,0x2b,0x10,0x40,0x00,0x0b,
+0x01,0x73,0x10,0x21,0x27,0x85,0xbb,0x0c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,
+0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b,
+0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x01,0x73,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x8f,0xf8,0x00,0x43,0x10,0x21,0x31,0xa4,0x00,0x01,0x10,0x80,0x00,0xa5,
+0xa0,0x50,0x00,0x07,0x3c,0x04,0xb0,0x05,0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01,
+0x3c,0x03,0x80,0x00,0xa1,0xe2,0x00,0x4e,0xac,0x83,0x00,0x00,0x8c,0x85,0x00,0x00,
+0x3c,0x02,0x00,0xf0,0x3c,0x03,0x40,0xf0,0x34,0x42,0xf0,0x00,0x34,0x63,0xf0,0x00,
+0x24,0x17,0x00,0x0e,0x24,0x13,0x01,0x06,0xac,0x82,0x00,0x00,0xac,0x83,0x00,0x00,
+0x27,0x82,0xb3,0xf0,0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x24,0x05,0x00,0x01,
+0xaf,0xa5,0x00,0x1c,0x90,0x62,0x00,0x16,0x00,0x13,0xa8,0xc0,0x32,0x51,0x00,0x02,
+0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,0x8f,0xa3,0x00,0x20,0x8f,0xa4,0x00,0x18,
+0x00,0x03,0x13,0x43,0x00,0x04,0x1a,0x02,0x30,0x47,0x00,0x01,0x12,0x20,0x00,0x04,
+0x30,0x64,0x07,0xff,0x2e,0x03,0x00,0x04,0x32,0x42,0x00,0x33,0x00,0x43,0x90,0x0b,
+0x8f,0xa5,0x00,0x24,0x8f,0xa6,0x00,0x1c,0x00,0x12,0x10,0x40,0x00,0x05,0x19,0xc0,
+0x00,0x47,0x10,0x21,0x00,0x06,0x2a,0x80,0x00,0x43,0x10,0x21,0x00,0x10,0x32,0x00,
+0x00,0x04,0x24,0x80,0x02,0x65,0x28,0x21,0x00,0xa4,0x28,0x21,0x00,0x46,0x10,0x21,
+0x00,0x17,0x1c,0x00,0x3c,0x04,0xc0,0x00,0x00,0x43,0x30,0x21,0x16,0x80,0x00,0x29,
+0x00,0xa4,0x28,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,0x3c,0x03,0xb0,0x05,
+0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x04,0x34,0x84,0x02,0x28,
+0x24,0x02,0x00,0x01,0xac,0x65,0x00,0x00,0xa0,0x82,0x00,0x00,0x3c,0x02,0xb0,0x09,
+0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x91,0xe3,0x00,0x09,0x30,0x86,0x00,0x01,
+0x02,0x83,0x18,0x26,0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21,
+0x13,0xc0,0x00,0x03,0x02,0xb3,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0xb3,0x10,0x21,
+0x27,0x83,0x8f,0xf8,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04,
+0x00,0xa0,0x30,0x21,0x00,0xe0,0x20,0x21,0x02,0x80,0x28,0x21,0x02,0xc0,0x38,0x21,
+0x0c,0x00,0x00,0x72,0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x02,0xbc,0x7b,0xb6,0x02,0x7c,
+0x7b,0xb4,0x02,0x3c,0x7b,0xb2,0x01,0xfc,0x7b,0xb0,0x01,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x58,0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x3d,0x3c,0x02,0xb0,0x05,
+0x24,0x02,0x00,0x02,0x12,0x82,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03,
+0x12,0x82,0x00,0x25,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x82,0x00,0x19,
+0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x11,0x12,0x82,0x00,0x0d,0x3c,0x02,0xb0,0x05,
+0x24,0x02,0x00,0x12,0x16,0x82,0xff,0xd1,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05,
+0x34,0x42,0x04,0x20,0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x46,0x00,0x00,
+0x34,0x84,0x02,0x28,0xac,0x65,0x00,0x00,0x08,0x00,0x07,0xe2,0x24,0x02,0x00,0x20,
+0x34,0x42,0x04,0x40,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,
+0x34,0x63,0x04,0x44,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x07,0xe2,
+0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,
+0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80,
+0x08,0x00,0x07,0xe2,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05,
+0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28,
+0x24,0x02,0x00,0x08,0x08,0x00,0x07,0xe2,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x10,
+0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x14,
+0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x04,0x08,0x00,0x07,0xe2,0xac,0x65,0x00,0x00,
+0x34,0x42,0x04,0x08,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,
+0x34,0x63,0x04,0x0c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x07,0xe2,
+0xac,0x65,0x00,0x00,0x24,0x17,0x00,0x14,0x08,0x00,0x07,0xb4,0x24,0x13,0x01,0x02,
+0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x0c,0x00,0x90,0x18,0x2b,0x10,0x60,0x00,0x0c,
+0x26,0x02,0x00,0x04,0x27,0x85,0xbb,0x0c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21,
+0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b,
+0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x2e,0x06,0x00,0x0c,0x26,0x02,0x00,0x04,
+0x08,0x00,0x07,0x9e,0x00,0x46,0x80,0x0a,0x27,0x82,0xb3,0xf0,0x01,0x82,0x20,0x21,
+0x8c,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0xe2,0x00,0x19,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x10,0x00,0xc2,0x10,0x21,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x14,0x00,0x00,0x00,0x00,
+0x90,0xe3,0x00,0x16,0x27,0x82,0x8f,0xf8,0x00,0xc2,0x10,0x21,0x34,0x63,0x00,0x20,
+0x90,0x50,0x00,0x07,0xa0,0xe3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x1e,0x42,
+0x24,0x06,0x00,0x01,0x90,0x82,0x00,0x16,0x30,0x71,0x00,0x02,0x30,0x72,0x00,0x3f,
+0x30,0x42,0x00,0xfb,0x24,0x17,0x00,0x18,0x24,0x13,0x01,0x03,0x24,0x15,0x08,0x18,
+0xaf,0xa6,0x00,0x1c,0x08,0x00,0x07,0xbe,0xa0,0x82,0x00,0x16,0x8d,0x02,0x00,0x04,
+0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10,0x14,0x40,0x00,0x15,0x30,0x72,0x00,0x3f,
+0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x11,0x30,0x72,0x00,0x3e,
+0x27,0x83,0x90,0x08,0x00,0xc3,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x68,
+0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x05,0x90,0x43,0x00,0x04,
+0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24,0x30,0x63,0x00,0x01,0x02,0x43,0x90,0x25,
+0x27,0x85,0xb3,0xf0,0x01,0x85,0x28,0x21,0x8c,0xa6,0x00,0x00,0x01,0x73,0x10,0x21,
+0x27,0x83,0x90,0x00,0x90,0xc4,0x00,0x16,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
+0x30,0x84,0x00,0xdf,0x90,0x50,0x00,0x00,0xa0,0xc4,0x00,0x16,0x80,0xc6,0x00,0x12,
+0x8c,0xa3,0x00,0x00,0x2d,0xc4,0x00,0x02,0xaf,0xa6,0x00,0x1c,0x90,0x62,0x00,0x16,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfb,0x14,0x80,0x00,0x06,0xa0,0x62,0x00,0x16,
+0x24,0x02,0x00,0x06,0x11,0xc2,0x00,0x03,0x24,0x02,0x00,0x04,0x15,0xc2,0xff,0x0e,
+0x32,0x51,0x00,0x02,0x32,0x51,0x00,0x02,0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x0f,
+0x00,0x11,0x18,0x2b,0x32,0x02,0x00,0x0f,0x34,0x42,0x00,0x10,0x00,0x03,0x19,0x00,
+0x00,0x43,0x18,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xb8,0xa0,0x43,0x00,0x00,
+0x00,0x00,0x20,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x02,0x05,0xaf,0xaf,0x00,0x28,
+0x8f,0xaf,0x00,0x28,0x08,0x00,0x07,0xbe,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0xb9,
+0x32,0x03,0x00,0xff,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xaa,0x00,0x00,0x00,0x00,
+0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x82,0x10,0x26,0x08,0x00,0x07,0x75,
+0x00,0x02,0x28,0x0b,0x08,0x00,0x07,0x7b,0x00,0x00,0xb0,0x21,0x24,0x02,0x00,0x10,
+0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0x7d,0x00,0x07,0x17,0x83,
+0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0x7b,0x00,0x07,0x17,0x43,0x08,0x00,0x07,0x55,
+0x30,0x5e,0x00,0x01,0x08,0x00,0x07,0x55,0x00,0x07,0xf7,0xc2,0x00,0x04,0x10,0x40,
+0x27,0x83,0x80,0x1c,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21,0x94,0x44,0x00,0x00,
+0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a,0x00,0x86,0x00,0x18,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x23,0x7c,
+0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12,0x00,0x04,0x22,0x42,
+0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b,0x24,0x82,0x00,0x60,
+0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x00,0x44,0x20,0x04,
+0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28,0x24,0x83,0x00,0x24,
+0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14,0x00,0x60,0x20,0x21,
+0x08,0x00,0x08,0xf6,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x24,0x18,0x00,0x80,0x80,0x21,
+0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37,0x34,0x84,0x01,0x10,
+0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21,0x8c,0x87,0x00,0x00,
+0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f,0x34,0x42,0xf0,0x00,
+0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08,0x32,0x02,0x00,0x07,
+0x27,0x83,0x80,0xcc,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,
+0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21,0x32,0x02,0x00,0x0f,
+0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x07,
+0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xb4,0x40,0x00,0x43,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c,0x14,0x40,0x00,0x05,
+0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21,
+0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20,0x24,0x06,0x00,0x0e,
+0x0c,0x00,0x08,0xdf,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04,0x24,0x02,0x00,0x10,
+0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01,0x14,0x60,0x00,0x02,
+0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff,0x00,0xc5,0x10,0x21,
+0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00,0x8f,0xbf,0x00,0x1c,
+0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c,0x32,0x02,0x00,0x07,
+0x27,0x83,0x80,0xc4,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x08,0x00,0x09,0x24,
+0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80,0x27,0x82,0xb3,0xf0,
+0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb3,0x00,0x2c,0xaf,0xbf,0x00,0x44,
+0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xb2,0x00,0x28,
+0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21,0x8c,0xe6,0x00,0x00,
+0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,
+0x24,0x42,0x25,0x74,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,0xa0,0xc3,0x00,0x12,
+0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16,0xa4,0xc3,0x00,0x14,
+0x27,0x83,0x8f,0xf0,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16,0x8c,0xe8,0x00,0x00,
+0xaf,0xa4,0x00,0x48,0x27,0x82,0x8f,0xf4,0x95,0x11,0x00,0x14,0x00,0x00,0x00,0x00,
+0x00,0x11,0x98,0xc0,0x02,0x71,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x82,0x10,0x21,
+0x8c,0x52,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06,0x8e,0x45,0x00,0x08,
+0x8e,0x46,0x00,0x04,0x8e,0x47,0x00,0x04,0x00,0x05,0x1c,0x82,0x00,0x06,0x31,0x42,
+0x27,0x82,0x90,0x00,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01,0x00,0x82,0x20,0x21,
+0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18,0xaf,0xa6,0x00,0x1c,
+0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06,0x14,0xe0,0x00,0x47,
+0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x44,
+0x02,0x71,0x10,0x21,0x93,0x90,0xbb,0xd9,0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c,
+0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40,0x00,0x43,0x10,0x21,
+0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04,0x02,0x71,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x00,0x80,0x80,0x21,
+0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,
+0x0c,0x00,0x08,0xdf,0x02,0xa0,0x30,0x21,0x02,0x71,0x18,0x21,0x00,0x03,0x88,0x80,
+0x00,0x40,0xa0,0x21,0x27,0x82,0x90,0x10,0x02,0x22,0x10,0x21,0x8c,0x44,0x00,0x00,
+0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,0x00,0x04,0x25,0xc2,
+0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40,0x03,0xc4,0x20,0x24,
+0x14,0x80,0x00,0x15,0x02,0x43,0x38,0x21,0x3c,0x08,0xb0,0x03,0x35,0x08,0x00,0x28,
+0x8d,0x03,0x00,0x00,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48,0x27,0x82,0x8f,0xf8,
+0x02,0x22,0x10,0x21,0x24,0x63,0x00,0x01,0x02,0xa0,0x28,0x21,0xa4,0x54,0x00,0x04,
+0x00,0xc0,0x38,0x21,0x0c,0x00,0x07,0x2b,0xad,0x03,0x00,0x00,0x7b,0xbe,0x02,0x3c,
+0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c,0x8f,0xa6,0x00,0x18,
+0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0x06,
+0xaf,0xa0,0x00,0x14,0x08,0x00,0x09,0xc2,0x02,0x82,0xa0,0x21,0x02,0x71,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,
+0x08,0x00,0x09,0xae,0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8,0xaf,0xb1,0x00,0x24,
+0x8f,0xb1,0x00,0x5c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
+0x24,0x42,0x27,0x98,0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38,
+0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c,0x8f,0xb5,0x00,0x58,
+0xaf,0xbf,0x00,0x44,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20,
+0x00,0xe0,0xb0,0x21,0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21,0x00,0x00,0xb8,0x21,
+0x16,0x20,0x00,0x2b,0x00,0x00,0xa0,0x21,0x27,0x85,0xb3,0xf0,0x00,0x07,0x10,0x80,
+0x00,0x45,0x10,0x21,0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80,0x00,0x65,0x18,0x21,
+0x92,0x62,0x00,0x16,0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x2d,
+0x00,0x00,0x00,0x00,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03,
+0x14,0x40,0x00,0x28,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x18,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x14,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x0f,0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05,0x34,0x63,0x01,0x44,
+0x34,0xa5,0x02,0x52,0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00,0x8f,0xa3,0x00,0x4c,
+0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x04,
+0x30,0xc6,0xff,0xff,0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09,0x24,0x05,0x00,0x14,
+0x02,0x20,0x10,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,
+0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,
+0x0c,0x00,0x07,0x06,0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x28,
+0xa3,0xc2,0x00,0x11,0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x17,
+0x00,0xc0,0x88,0x21,0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21,0x12,0x20,0xff,0xed,
+0x02,0x20,0x10,0x21,0x27,0x83,0xb3,0xf0,0x00,0x17,0x10,0x80,0x00,0x43,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28,0x80,0x86,0x00,0x12,
+0x8c,0x62,0x00,0x00,0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03,0x00,0x46,0x10,0x21,
+0x8f,0xa6,0x00,0x4c,0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21,0x0c,0x00,0x07,0x2b,
+0xac,0x62,0x00,0x00,0x08,0x00,0x0a,0x28,0xaf,0xd1,0x00,0x40,0x96,0x74,0x00,0x1a,
+0x08,0x00,0x0a,0x3b,0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,
+0x8c,0x50,0x00,0x00,0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x11,0x02,0x00,0x28,0x21,
+0x30,0x42,0x00,0xff,0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x11,
+0xaf,0xa2,0x00,0x18,0x8f,0xa4,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0xed,
+0x30,0x50,0x00,0xff,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01,0x96,0x63,0x00,0x14,
+0x96,0x44,0x00,0x14,0x27,0x85,0x8f,0xf0,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0,0x8c,0x46,0x00,0x08,
+0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x00,0x06,0x17,0x02,
+0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xd6,0x00,0x03,0x17,0x02,
+0x10,0x44,0x00,0xd5,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b,0x24,0x11,0x00,0x02,
+0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x5a,
+0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbd,0x00,0x00,0x00,0x00,0x96,0x49,0x00,0x14,
+0x27,0x82,0x8f,0xf4,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0,0x01,0x49,0x18,0x21,
+0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00,
+0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42,
+0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,0x14,0x40,0x00,0x41,
+0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x08,0x01,0x02,0x10,0x21,0x80,0x44,0x00,0x00,
+0x27,0x82,0xb5,0x68,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,
+0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05,
+0x27,0x84,0xb4,0x90,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2b,
+0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00,
+0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xb9,
+0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,
+0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,
+0x27,0x83,0x90,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21,
+0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x0b,
+0x24,0x02,0x00,0x01,0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x8d,
+0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,
+0x02,0x02,0x10,0x25,0x08,0x00,0x0a,0x3b,0xa2,0x42,0x00,0x16,0x00,0x60,0x28,0x21,
+0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x3e,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0a,0xbe,
+0x30,0x54,0xff,0xff,0x08,0x00,0x0a,0xa6,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd,
+0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0a,0xa6,
+0x24,0x42,0x00,0x04,0x27,0x82,0x90,0x00,0x01,0x02,0x10,0x21,0x90,0x43,0x00,0x00,
+0x08,0x00,0x0a,0xb6,0xa0,0x43,0x00,0x03,0x96,0x69,0x00,0x14,0x02,0xc0,0xb8,0x21,
+0x24,0x0b,0x00,0x01,0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21,0x00,0x03,0x40,0x80,
+0x00,0x40,0x50,0x21,0x27,0x82,0x8f,0xf4,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,
+0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,
+0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,
+0x10,0x40,0x00,0x0d,0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x08,0x01,0x02,0x10,0x21,
+0x80,0x43,0x00,0x00,0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00,0x00,0x43,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xb5,0x60,
+0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x4f,0x00,0x00,0x00,0x00,
+0x01,0x49,0x10,0x21,0x00,0x02,0x20,0x80,0x27,0x85,0x90,0x00,0x00,0x85,0x10,0x21,
+0x80,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x42,0x01,0x49,0x10,0x21,
+0x27,0x82,0x90,0x08,0x00,0x82,0x10,0x21,0x80,0x44,0x00,0x00,0x27,0x82,0xb5,0x68,
+0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x23,
+0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05,0x27,0x84,0xb4,0x90,
+0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2c,0x2c,0x64,0x00,0x0c,
+0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,
+0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xb9,0x14,0x80,0x00,0x06,
+0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,
+0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,0x27,0x83,0x90,0x00,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21,0xa0,0x45,0x00,0x03,
+0xa0,0x45,0x00,0x00,0x8f,0xa4,0x00,0x18,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x0c,
+0x00,0x60,0x28,0x21,0x24,0x02,0x00,0x01,0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x8d,
+0xaf,0xa2,0x00,0x10,0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff,0x92,0x62,0x00,0x16,
+0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x25,0x08,0x00,0x0a,0x3b,0xa2,0x62,0x00,0x16,
+0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x3e,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0b,0x2d,
+0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0x15,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd,
+0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0b,0x15,
+0x24,0x42,0x00,0x04,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x90,0x43,0x00,0x00,
+0x08,0x00,0x0b,0x25,0xa0,0x43,0x00,0x03,0x27,0x85,0x90,0x00,0x08,0x00,0x0b,0x41,
+0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,0x00,0x62,0x18,0x26,0x08,0x00,0x0a,0x76,
+0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x2d,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x7b,
+0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0,
+0x24,0x42,0x2d,0x44,0x34,0x63,0x00,0x20,0x3c,0x05,0xb0,0x05,0xaf,0xb3,0x00,0x24,
+0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x28,0xaf,0xb0,0x00,0x18,
+0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,0x90,0xa2,0x00,0x00,0x00,0x80,0x90,0x21,
+0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,0x24,0x02,0x00,0x10,0x12,0x22,0x00,0xcf,
+0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,0x12,0x22,0x00,0xc1,0x24,0x02,0x00,0x12,
+0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0xad,0xae,0x43,0x00,0x40,
+0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x44,0x00,0x00,0x3c,0x03,0x00,0x02,
+0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,0x00,0x10,0x14,0x43,0x10,0x40,0x00,0x05,
+0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x92,
+0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x61,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,
+0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,0x00,0x10,0x11,0xc3,0x14,0x40,0x00,0x86,
+0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,0x02,0x00,0x10,0x21,0x26,0x22,0x00,0x01,
+0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,0x14,0x60,0xff,0xdb,0x24,0x03,0x00,0x02,
+0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,0x2a,0x62,0x00,0x03,0x10,0x40,0x00,0x58,
+0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x4b,0x02,0x40,0x20,0x21,
+0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x28,
+0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
+0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x02,0x40,0x20,0x21,
+0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xe6,
+0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
+0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xec,0x02,0x00,0x10,0x21,
+0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x24,0x02,0x00,0x05,0x02,0x40,0x20,0x21,
+0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xe6,
+0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
+0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xdc,0x02,0x00,0x10,0x21,
+0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x24,0x02,0x00,0x03,0x02,0x40,0x20,0x21,
+0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xe6,
+0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
+0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xcc,0x02,0x00,0x10,0x21,
+0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,0x24,0x02,0x00,0x02,0x02,0x40,0x20,0x21,
+0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xe6,
+0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c,
+0x08,0x00,0x0b,0x97,0x30,0x42,0x00,0xff,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,
+0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,
+0x0c,0x00,0x09,0xe6,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x90,0xae,0x42,0x00,0x24,
+0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x08,0x16,0x62,0xff,0xa8,
+0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,0x8e,0x42,0x00,0x30,0x24,0x05,0x00,0x03,
+0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,0x0c,0x00,0x09,0xe6,0xaf,0xa2,0x00,0x14,
+0x08,0x00,0x0b,0x90,0xae,0x42,0x00,0x30,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,
+0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,
+0x0c,0x00,0x09,0xe6,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x90,0xae,0x42,0x00,0x2c,
+0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01,
+0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xe6,0xaf,0xa3,0x00,0x14,
+0x08,0x00,0x0b,0x90,0xae,0x42,0x00,0x28,0x0c,0x00,0x01,0x59,0x24,0x04,0x00,0x01,
+0x08,0x00,0x0b,0x81,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x30,0xae,0x40,0x00,0x34,
+0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x84,0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x61,
+0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0xff,0x69,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x01,0x59,0x00,0x00,0x20,0x21,0x08,0x00,0x0b,0x79,0x00,0x00,0x00,0x00,
+0x02,0x40,0x20,0x21,0x0c,0x00,0x09,0x5d,0x02,0x20,0x28,0x21,0x08,0x00,0x0b,0x6d,
+0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x4a,
+0x00,0x00,0x00,0x00,0x8f,0x82,0xb4,0x38,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6a,0xae,0x43,0x00,0x3c,
+0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3d,0x24,0x02,0x00,0x12,
+0x8f,0x82,0xb4,0x34,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,
+0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6a,0xae,0x43,0x00,0x38,0x8e,0x42,0x00,0x34,
+0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,0x24,0x02,0x00,0x11,0x8f,0x82,0xb4,0x30,
+0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,
+0x08,0x00,0x0b,0x6a,0xae,0x43,0x00,0x34,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,0x24,0x42,0x30,0xf8,0x3c,0x08,0xb0,0x03,
+0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,0x35,0x08,0x01,0x00,0xaf,0xbf,0x00,0x18,
+0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,0x00,0xa0,0x48,0x21,0x24,0x11,0x00,0x0a,
+0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,0x00,0x45,0x88,0x0a,0x30,0x63,0x00,0x01,
+0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,0x00,0x11,0x40,0x40,0x02,0x20,0x40,0x21,
+0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,0x01,0x20,0x20,0x21,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x8f,0xf8,0x00,0x43,0x10,0x21,
+0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,0x10,0xe0,0x00,0x06,0x02,0x23,0x80,0x21,
+0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x0c,0x00,0x08,0xdf,0x00,0x00,0x00,0x00,0x02,0x11,0x18,0x21,
+0x08,0x00,0x0c,0x60,0x00,0x62,0x80,0x21,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,
+0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb5,0x00,0x24,
+0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x84,0x82,0x00,0x0c,0x3c,0x06,0xb0,0x03,
+0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,
+0x27,0x82,0x8f,0xf4,0x00,0x62,0x10,0x21,0x8c,0x55,0x00,0x18,0x3c,0x02,0x80,0x00,
+0x24,0x42,0x31,0xa8,0xac,0xc2,0x00,0x00,0x8e,0xb0,0x00,0x08,0x27,0x82,0x8f,0xf8,
+0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,0x00,0x10,0x86,0x43,0x32,0x10,0x00,0x01,
+0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,0x00,0xa0,0x98,0x21,0x02,0x20,0x28,0x21,
+0x0c,0x00,0x0c,0x3e,0x00,0x80,0x90,0x21,0x02,0x20,0x20,0x21,0x02,0x00,0x28,0x21,
+0x24,0x06,0x00,0x14,0x0c,0x00,0x08,0xdf,0x00,0x40,0xa0,0x21,0x86,0x43,0x00,0x0c,
+0x3c,0x09,0xb0,0x09,0x3c,0x08,0xb0,0x09,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x80,0x43,0x00,0x06,
+0x3c,0x07,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x28,0x62,0x00,0x00,0x24,0x64,0x00,0x03,
+0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x3c,0x02,0xb0,0x09,0x00,0x03,0x18,0x80,
+0x34,0x42,0x01,0x02,0x35,0x29,0x01,0x10,0x35,0x08,0x01,0x14,0x34,0xe7,0x01,0x20,
+0x34,0xa5,0x01,0x24,0xa4,0x54,0x00,0x00,0x12,0x60,0x00,0x11,0x02,0xa3,0xa8,0x21,
+0x8e,0xa2,0x00,0x0c,0x8e,0xa3,0x00,0x08,0x00,0x02,0x14,0x00,0x00,0x03,0x1c,0x02,
+0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8e,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x00,0x03,0x1c,0x02,0xa5,0x03,0x00,0x00,0x8f,0xbf,0x00,0x28,0x7b,0xb4,0x01,0x3c,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
+0x8e,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x22,0x00,0x00,0x8e,0xa4,0x00,0x08,
+0x00,0x00,0x00,0x00,0xa5,0x04,0x00,0x00,0x7a,0xa2,0x00,0x7c,0x00,0x00,0x00,0x00,
+0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21,0xac,0xe3,0x00,0x00,
+0x8e,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02,0x08,0x00,0x0c,0xb2,
+0xa4,0xa2,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c,0x00,0x80,0x90,0x21,
+0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,
+0x27,0x82,0x8f,0xf4,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18,0x3c,0x02,0x80,0x00,
+0x34,0xa5,0x00,0x20,0x24,0x42,0x33,0x24,0x27,0x83,0x8f,0xf8,0xac,0xa2,0x00,0x00,
+0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07,0x34,0x42,0x01,0x00,
+0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04,0x24,0x02,0x00,0x10,
+0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43,0x30,0x84,0x00,0x01,
+0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40,0x02,0x00,0x10,0x21,
+0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x08,0xdf,0x30,0x50,0x00,0xff,
+0x86,0x44,0x00,0x0c,0x27,0x85,0x90,0x00,0x3c,0x06,0xb0,0x09,0x00,0x04,0x18,0xc0,
+0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x80,0x64,0x00,0x06,
+0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03,0x28,0x83,0x00,0x00,
+0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80,0xa4,0xc2,0x00,0x00,
+0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x10,
+0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x14,
+0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08,0x3c,0x06,0xb0,0x09,
+0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21,0x34,0xc6,0x01,0x20,
+0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x24,
+0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a,0x3c,0x03,0xb0,0x09,
+0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff,
+0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x90,0x08,0x8f,0xbf,0x00,0x1c,
+0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
+0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x3c,0x05,0xb0,0x09,
+0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0xaf,0xb0,0x00,0x10,
+0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x34,0xb0,0x00,0x05,0x2c,0x43,
+0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,0x10,0xa0,0x00,0x05,
+0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0xb6,
+0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x4c,0x00,0x00,0x10,0x21,
+0x24,0x02,0x00,0x08,0x12,0x02,0x00,0xa3,0x2a,0x02,0x00,0x09,0x10,0x40,0x00,0x89,
+0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x79,0x2a,0x02,0x00,0x03,
+0x10,0x40,0x00,0x69,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x02,0x00,0x5a,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08,0x3c,0x03,0x80,0x00,
+0xa2,0x20,0x00,0x4e,0xac,0x43,0x00,0x00,0x82,0x24,0x00,0x11,0x92,0x27,0x00,0x11,
+0x10,0x80,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a,0x24,0x02,0x00,0x12,
+0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xb3,0xf0,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x83,0x00,0x14,
+0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x40,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03,0xa2,0x23,0x00,0x10,
+0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff,0x27,0x83,0xb3,0xf0,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x82,0x23,0x00,0x12,
+0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x30,0x42,0x00,0x01,
+0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18,0xa2,0x23,0x00,0x12,
+0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01,0x96,0x23,0x00,0x0c,
+0x27,0x84,0x90,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,0x3c,0x02,0xb0,0x00,
+0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00,0x90,0x62,0x00,0x04,
+0xa2,0x20,0x00,0x15,0xa3,0x80,0x8b,0xc4,0x24,0x02,0x00,0x01,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x0c,0xc9,
+0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x0d,0x79,0x00,0x07,0x16,0x00,
+0x0c,0x00,0x0c,0x6a,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c,0x27,0x84,0x8f,0xf8,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x20,0x21,
+0x90,0x85,0x00,0x07,0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0xa2,0x25,0x00,0x13,
+0x90,0x83,0x00,0x07,0x08,0x00,0x0d,0x91,0xa0,0x43,0x00,0x02,0x92,0x26,0x00,0x0a,
+0x08,0x00,0x0d,0x5a,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24,0x00,0x00,0x00,0x00,
+0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07,0xa2,0x22,0x00,0x0a,
+0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x0d,0x4d,0xa2,0x22,0x00,0x04,
+0x08,0x00,0x0d,0xab,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9b,0x3c,0x02,0xb0,0x05,
+0x8e,0x23,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x07,0xa2,0x24,0x00,0x08,
+0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f,0xae,0x20,0x00,0x2c,
+0x08,0x00,0x0d,0x4d,0xa2,0x22,0x00,0x06,0x08,0x00,0x0d,0xba,0xa2,0x20,0x00,0x0a,
+0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01,0x10,0x44,0x00,0x07,
+0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2b,
+0xae,0x20,0x00,0x28,0x08,0x00,0x0d,0x4d,0xa2,0x22,0x00,0x05,0x08,0x00,0x0d,0xc6,
+0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x12,0x2a,0x02,0x00,0x41,0x10,0x40,0x00,0x09,
+0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7b,0x3c,0x02,0xb0,0x05,
+0x24,0x02,0x00,0x12,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x4d,
+0xae,0x20,0x00,0x3c,0x16,0x02,0xff,0x74,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,
+0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x4d,0xae,0x20,0x00,0x34,
+0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x4d,
+0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,0x24,0x02,0x00,0x03,0x24,0x03,0x00,0x01,
+0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,0x24,0x02,0x00,0x02,0xa2,0x22,0x00,0x0a,
+0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,0x08,0x00,0x0d,0x4d,0xa2,0x22,0x00,0x07,
+0x08,0x00,0x0d,0xec,0xa2,0x24,0x00,0x0a,0x8f,0x84,0xb4,0x30,0xae,0x20,0x00,0x34,
+0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x84,0x32,0x10,0x00,0xff,0x08,0x00,0x0d,0x3e,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x37,0xe4,
+0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x80,0xa2,0x00,0x15,0x3c,0x06,0xb0,0x05,
+0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,0x83,0x83,0x8b,0xc4,0x00,0x00,0x00,0x00,
+0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,
+0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x28,0x8c,0x82,0x00,0x2c,
+0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,0x00,0x02,0x18,0x43,0x30,0x63,0x00,0x01,
+0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08,
+0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,
+0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08,
+0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd8,
+0x34,0x63,0x00,0x20,0x24,0x42,0x38,0x74,0xac,0x62,0x00,0x00,0xaf,0xb1,0x00,0x1c,
+0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,0x90,0xa6,0x00,0x0a,0x27,0x83,0xb3,0xf0,
+0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,
+0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,0x10,0xa0,0x00,0x04,0xa2,0x20,0x00,0x15,
+0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xda,0x00,0x00,0x00,0x00,0x82,0x22,0x00,0x12,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x12,
+0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,
+0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0xdf,
+0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,
+0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x45,
+0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,0x92,0x08,0x00,0x04,0x00,0x00,0x00,0x00,
+0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,0x92,0x07,0x00,0x0a,0xa2,0x02,0x00,0x17,
+0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xe4,0x10,0x60,0x00,0x03,
+0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x11,0x00,0x00,0x05,
+0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,
+0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x08,
+0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x02,0x00,0x14,
+0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x96,0x02,0x00,0x00,0x08,0x00,0x0e,0x68,0xa6,0x02,0x00,0x14,0x92,0x07,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x54,
+0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x8f,0xf0,
+0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,
+0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,
+0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xc3,0x20,0x24,
+0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,
+0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x54,
+0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x88,
+0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,
+0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x4e,
+0xa2,0x20,0x00,0x07,0x08,0x00,0x0e,0x4e,0xa2,0x20,0x00,0x06,0x08,0x00,0x0e,0x4e,
+0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x69,
+0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x49,0x3c,0x02,0xb0,0x09,0x92,0x25,0x00,0x08,
+0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x3b,
+0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
+0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,
+0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,0x96,0x26,0x00,0x0c,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,0x27,0x83,0x8f,0xf4,0x00,0xa3,0x18,0x21,
+0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,0x24,0x07,0x00,0x01,0x93,0x82,0x8b,0x61,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x0a,0x24,0x05,0x00,0x24,
+0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x84,0x02,0x00,0x20,0x21,
+0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,0x30,0x42,0x00,0xe7,0x08,0x00,0x0e,0x45,
+0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,0x00,0x00,0x28,0x12,0x27,0x82,0x8f,0xf0,
+0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x4b,0x3c,0x04,0x00,0x80,0x96,0x26,0x00,0x0c,
+0x08,0x00,0x0e,0xc5,0x00,0x06,0x2c,0x00,0x27,0x83,0x90,0x00,0x27,0x82,0x90,0x08,
+0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05,
+0x93,0x82,0x80,0x10,0x00,0x00,0x30,0x21,0x0c,0x00,0x21,0xf5,0xaf,0xa2,0x00,0x10,
+0x96,0x26,0x00,0x0c,0x08,0x00,0x0e,0xbf,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xcd,
+0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,
+0x24,0x02,0x00,0x80,0x08,0x00,0x0e,0xae,0x00,0xa2,0x10,0x07,0x86,0x26,0x00,0x0c,
+0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78,0x94,0x47,0x00,0x00,
+0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21,0x3c,0x04,0xb0,0x09,
+0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x8f,0xf4,0x00,0x02,0x10,0x80,
+0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18,0xae,0x25,0x00,0x20,
+0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21,0x0c,0x00,0x0f,0x15,
+0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c,0x8e,0x27,0x00,0x20,
+0x02,0x20,0x20,0x21,0x0c,0x00,0x1c,0x86,0xaf,0xa2,0x00,0x10,0x08,0x00,0x0e,0x45,
+0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x0e,0x45,0xa2,0x22,0x00,0x09,
+0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00,0x08,0x00,0x0e,0x45,
+0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24,0x00,0x80,0x70,0x21,
+0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x3c,0x54,0xf1,0x43,0x00,0x06,
+0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21,0xac,0x82,0x00,0x00,
+0x27,0x85,0x90,0x00,0x27,0x82,0x8f,0xff,0x27,0xbd,0xff,0xf8,0x00,0x62,0x60,0x21,
+0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc,0x00,0x00,0x78,0x21,
+0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00,0x80,0x48,0x00,0x04,
+0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x8f,0xf4,0xa3,0xa7,0x00,0x00,
+0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff,0x00,0x48,0x40,0x0b,
+0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06,0x30,0x63,0x00,0x08,
+0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00,0x27,0x82,0x90,0x08,
+0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50,0x30,0xe5,0x00,0xff,
+0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24,0x90,0x49,0x00,0x00,
+0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04,0x10,0xa2,0x00,0x9d,
+0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c,0x10,0x40,0x00,0x02,
+0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff,0x00,0x04,0x10,0x40,
+0x27,0x83,0xbb,0x0c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21,0x90,0x47,0x00,0x00,
+0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00,0x10,0x60,0x00,0x02,
+0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00,0x91,0x65,0x00,0x00,
+0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b,0x10,0x40,0x00,0x0e,
+0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21,0x30,0xa2,0x00,0x0f,
+0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21,0x27,0x83,0xbb,0x0c,
+0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,
+0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xb4,0x98,0x00,0x43,0x10,0x21,
+0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c,0x14,0x60,0x00,0x06,
+0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,
+0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x0f,0x76,0xa1,0x82,0x00,0x00,
+0x8f,0x8d,0x81,0x5c,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21,0x00,0x06,0x74,0x82,
+0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0xe0,0x10,0x21,
+0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff,0xa3,0xa2,0x00,0x00,
+0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23,0x00,0x64,0x18,0x21,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xb4,0x98,0x00,0x44,0x10,0x21,
+0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00,0x00,0x0a,0x1c,0x00,
+0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x8f,0xf4,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,
+0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0x00,0x33,
+0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,
+0x00,0x49,0x10,0x23,0x27,0x83,0xb5,0x68,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
+0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x64,0xc0,0x24,
+0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f,0x10,0x40,0x00,0x0f,
+0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x8f,0xf0,0x00,0x44,0x10,0x21,
+0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41,0x14,0x60,0x00,0x04,
+0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00,0x30,0xe2,0x00,0xff,
+0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21,0x00,0x18,0x10,0x40,
+0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21,0x24,0x42,0x00,0x04,
+0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00,
+0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b,0x14,0x60,0xff,0xad,
+0x30,0xe2,0x00,0xff,0x08,0x00,0x0f,0x63,0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0xc4,
+0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x73,
+0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0x51,0x00,0x00,0x00,0x00,0x00,0x0a,0x1c,0x00,
+0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00,0x08,0x00,0x0f,0x31,
+0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
+0x24,0x42,0x3f,0xf4,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,
+0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,
+0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c,0xaf,0xbe,0x00,0x38,
+0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c,0x27,0x93,0x8f,0xf4,
+0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80,
+0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,
+0x24,0x42,0x40,0x0c,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08,0x27,0x95,0x90,0x00,
+0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21,0x90,0x71,0x00,0x00,
+0x0c,0x00,0x0f,0x15,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21,0x00,0x10,0x14,0x42,
+0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82,0x02,0x80,0x28,0x21,
+0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c,0x30,0x50,0x00,0x01,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,
+0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21,0x8c,0xc7,0x00,0x18,
+0x27,0x83,0x8f,0xf0,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04,0x84,0x46,0x00,0x06,
+0x00,0x03,0x19,0x42,0x0c,0x00,0x08,0xdf,0x30,0x73,0x00,0x01,0x00,0x40,0x88,0x21,
+0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10,0x02,0x00,0x30,0x21,
+0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,
+0x00,0x03,0x18,0x80,0x27,0x82,0x8f,0xf8,0x00,0x62,0x18,0x21,0xa4,0x71,0x00,0x04,
+0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,
+0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x86,0xc3,0x00,0x0c,
+0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06,0x00,0x00,0x00,0x00,
+0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21,0x00,0x07,0x38,0x43,
+0x00,0x07,0x38,0x40,0x0c,0x00,0x09,0x06,0x03,0xc7,0x38,0x21,0x08,0x00,0x10,0x44,
+0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0,
+0x34,0x63,0x00,0x20,0x24,0x42,0x41,0x94,0xaf,0xb2,0x00,0x20,0xac,0x62,0x00,0x00,
+0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,
+0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04,0x94,0x45,0x00,0x00,
+0x00,0x03,0x18,0x80,0x27,0x82,0xb3,0xf0,0x00,0x62,0x18,0x21,0x30,0xa6,0xff,0xff,
+0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc9,0x00,0xff,0x00,0x06,0x32,0x02,
+0xa4,0x86,0x00,0x44,0xa4,0x89,0x00,0x46,0x82,0x22,0x00,0x12,0x00,0x80,0x90,0x21,
+0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a,0x10,0x40,0x00,0x14,
+0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,
+0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12,0x92,0x22,0x00,0x16,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x28,
+0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,
+0x0c,0x00,0x0f,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x93,0x00,0x00,0x00,0x00,
+0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x76,0x00,0x00,0x28,0x21,0x94,0x87,0x00,0x0c,
+0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x21,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03,
+0x00,0x07,0x24,0x00,0x00,0x04,0x24,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,
+0x00,0x04,0x28,0xc0,0x00,0xa4,0x28,0x21,0x27,0x82,0x90,0x10,0x00,0x03,0x18,0x80,
+0x00,0x62,0x18,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x8f,0xf8,0x00,0xa2,0x10,0x21,
+0x8c,0x68,0x00,0x00,0x80,0x44,0x00,0x06,0x27,0x82,0x90,0x00,0x00,0x08,0x1d,0x02,
+0x00,0xa2,0x28,0x21,0x38,0x84,0x00,0x00,0x30,0x63,0x00,0x01,0x01,0x24,0x30,0x0b,
+0x80,0xaa,0x00,0x04,0x80,0xa9,0x00,0x05,0x10,0x60,0x00,0x02,0x00,0x08,0x14,0x02,
+0x30,0x46,0x00,0x0f,0x15,0x20,0x00,0x28,0x01,0x49,0x10,0x21,0x15,0x40,0x00,0x11,
+0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa8,0x00,0xff,
+0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x46,0x2d,0x02,0x00,0x10,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x01,0x02,0x10,0x04,
+0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c,0x00,0x00,0x00,0x00,
+0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x27,0x84,0x90,0x00,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,
+0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x20,0x21,0x94,0x82,0x00,0x00,
+0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06,0x00,0x02,0x3c,0x03,
+0x30,0xe2,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21,0x34,0xe2,0x08,0x00,
+0xa4,0x82,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03,
+0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00,0x82,0x42,0x00,0x10,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x86,0x43,0x00,0x0c,
+0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04,0x92,0x23,0x00,0x16,
+0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x10,0x98,0xa2,0x23,0x00,0x16,
+0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x05,
+0x86,0x45,0x00,0x0c,0x0c,0x00,0x1f,0x08,0x02,0x20,0x20,0x21,0x10,0x40,0x00,0x5a,
+0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,
+0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,
+0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08,
+0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33,0x24,0x02,0x00,0x01,
+0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0c,
+0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x08,0x00,0x10,0x93,
+0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x10,0x93,0xa6,0x22,0x00,0x14,
+0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,
+0x08,0x00,0x11,0x22,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,
+0x27,0x86,0x8f,0xf0,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,
+0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,
+0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,
+0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,
+0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,
+0x08,0x00,0x11,0x22,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,
+0x08,0x00,0x11,0x45,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,
+0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca,0x00,0x00,0x00,0x00,
+0x08,0x00,0x11,0x1d,0xa2,0x40,0x00,0x07,0x08,0x00,0x11,0x1d,0xa2,0x40,0x00,0x06,
+0x08,0x00,0x11,0x1d,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe,0x3c,0x04,0xb0,0x05,
+0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,
+0x08,0x00,0x11,0x14,0x00,0xa2,0x10,0x07,0x0c,0x00,0x10,0x03,0x02,0x40,0x20,0x21,
+0x08,0x00,0x10,0x93,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,
+0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x99,0x2c,0xc2,0x00,0x10,
+0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,
+0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,
+0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x80,
+0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c,0x27,0x93,0x8f,0xf4,
+0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,
+0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64,0x00,0x00,0x30,0x21,
+0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18,0x93,0x82,0x8b,0x61,
+0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42,0x14,0x40,0x00,0x4d,
+0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x84,
+0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14,0x30,0xc5,0xff,0xff,
+0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b,
+0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x62,0x00,0x04,
+0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x1b,0x84,0x30,0x50,0x00,0x01,
+0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff,0x92,0x22,0x00,0x04,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,
+0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,
+0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x92,0x30,0x42,0x00,0xc3,
+0x96,0x22,0x00,0x00,0x08,0x00,0x11,0xb9,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0xb4,
+0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff,0x00,0x05,0x18,0xc0,
+0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x27,0x84,0x8f,0xf0,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80,0x8c,0x45,0x00,0x08,
+0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00,0x00,0xa2,0x38,0x24,
+0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,
+0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xb4,
+0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xd8,
+0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06,0x00,0x00,0x28,0x12,
+0x27,0x82,0x8f,0xf0,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x4b,0x00,0x00,0x20,0x21,
+0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x96,0x00,0x07,0x2c,0x00,0x27,0x83,0x90,0x00,
+0x27,0x82,0x90,0x08,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,
+0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x24,0x07,0x00,0x01,0x0c,0x00,0x21,0xf5,
+0xaf,0xa2,0x00,0x10,0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x89,0x00,0x07,0x1c,0x00,
+0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,
+0x14,0xa2,0xff,0x7d,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0x7a,0xa2,0x40,0x00,0x07,
+0x08,0x00,0x11,0x7a,0xa2,0x40,0x00,0x06,0x08,0x00,0x11,0x7a,0xa2,0x40,0x00,0x05,
+0x14,0x40,0xff,0x71,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
+0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x11,0x71,0x00,0xa2,0x10,0x07,
+0x14,0x40,0xfe,0xc3,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,
+0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x10,0xcc,0x00,0xa2,0x10,0x07,
+0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x8f,0xf4,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18,
+0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x0f,0x15,0x00,0x00,0x00,0x00,
+0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21,0x00,0x00,0x38,0x21,
+0x0c,0x00,0x1c,0x86,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00,0x14,0x60,0xfe,0x6b,
+0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x40,
+0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04,0x00,0x00,0x00,0x00,
+0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a,0xa2,0x22,0x00,0x17,
+0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10,0x00,0x00,0x00,0x00,
+0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x16,
+0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03,0xa2,0x22,0x00,0x16,
+0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x50,0x00,0x00,0x00,0x00,
+0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x92,0x34,0x42,0x00,0x02,0x96,0x22,0x00,0x00,
+0x08,0x00,0x12,0x3b,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a,0x00,0x00,0x00,0x00,
+0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x34,0xa2,0x20,0x00,0x17,
+0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x8f,0xf0,0x00,0x04,0x18,0xc0,
+0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,
+0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,
+0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,
+0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,
+0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x34,0xa2,0x23,0x00,0x17,
+0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x63,0x00,0x00,0x00,0x00,
+0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03,
+0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x2e,0xa2,0x40,0x00,0x07,
+0x08,0x00,0x12,0x2e,0xa2,0x40,0x00,0x06,0x08,0x00,0x12,0x2e,0xa2,0x40,0x00,0x05,
+0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0xa2,0x18,0x24,
+0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02,0x24,0x02,0x00,0x01,
+0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xfd,
+0x00,0xa4,0x10,0x2b,0x08,0x00,0x12,0x7e,0x00,0x00,0x00,0x00,0x30,0x82,0xff,0xff,
+0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x90,0x00,0x00,0x03,0x18,0x80,
+0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00,0x3c,0x03,0xb0,0x00,
+0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08,0x00,0x43,0x10,0x21,
+0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00,0xaf,0xbf,0x00,0x1c,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x14,0x40,0x00,0x41,
+0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03,0x8e,0x10,0x00,0x00,
+0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03,0x32,0x02,0x00,0x20,
+0x08,0x00,0x12,0xa4,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x06,
+0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x67,0x00,0xff,
+0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x8f,0xd0,0x00,0x40,0x30,0x21,
+0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01,0x24,0x42,0x00,0x02,
+0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a,0xa4,0xa2,0x00,0x08,
+0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xb3,0xf0,0x24,0x11,0x00,0x12,
+0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x20,0xd0,0x00,0x00,0x00,0x00,
+0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24,0x3c,0x01,0xb0,0x03,
+0x0c,0x00,0x13,0x18,0xac,0x30,0x00,0x00,0x08,0x00,0x12,0xa4,0x00,0x00,0x00,0x00,
+0x8f,0x85,0x8f,0xd0,0x08,0x00,0x12,0xba,0x00,0x00,0x00,0x00,0x24,0x02,0xff,0x95,
+0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30,0x3c,0x01,0xb0,0x03,
+0xac,0x30,0x00,0x00,0x0c,0x00,0x12,0xe1,0xac,0x60,0x00,0x00,0x08,0x00,0x12,0xa4,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50,0x08,0x00,0x12,0xa4,
+0xac,0x46,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0x84,0x3c,0x0b,0xb0,0x03,
+0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00,0x3c,0x09,0x80,0x01,
+0x25,0x29,0x03,0x1c,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,
+0x25,0x4a,0x4b,0xac,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0xb0,0x06,
+0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,
+0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00,0x24,0x01,0x00,0x01,
+0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0xe8,
+0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03,0x8c,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00,0xac,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x14,0x3c,0x0b,0xb0,0x03,
+0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00,0x3c,0x03,0x80,0x01,
+0x24,0x63,0x03,0x1c,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00,0x00,0x00,0x00,0x00,
+0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x43,0x08,0x2a,
+0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0x18,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x60,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
+0x3c,0x02,0x80,0x01,0x24,0x42,0x03,0x20,0x3c,0x03,0x80,0x01,0x24,0x63,0x3f,0x14,
+0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08,0xac,0x40,0x00,0x0c,
+0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,
+0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xa0,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,
+0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x8b,0xd0,0x00,0x00,0x00,0x00,
+0x27,0x9d,0x8f,0xb8,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xc4,0x3c,0x0b,0xb0,0x03,
+0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00,0x00,0x00,0x00,0x00,
+0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x15,0x65,
+0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03,0x00,0x04,0x30,0x40,
+0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0,0x24,0x03,0xff,0xff,
+0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00,0xaf,0xbf,0x00,0x18,
+0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x10,0x00,
+0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23,0x3c,0x03,0xb0,0x0a,
+0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x13,0x95,0x02,0x20,0x20,0x21,
+0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,
+0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff,0xaf,0xb3,0x00,0x1c,
+0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x00,0xc0,0x98,0x21,
+0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x10,0x40,
+0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23,0x3c,0x03,0xb0,0x0a,
+0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21,0x24,0x05,0x00,0x01,
+0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd,0x3c,0x02,0xb0,0x0a,
+0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00,0x0c,0x00,0x13,0x95,
+0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24,0x00,0x53,0x10,0x04,
+0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01,0x8e,0x22,0x10,0x00,
+0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23,0x3c,0x04,0xb0,0x0a,
+0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01,0x8c,0x62,0x10,0x00,
+0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x13,0x83,
+0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06,0x30,0x42,0x00,0x01,
+0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x20,
+0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,
+0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x90,0x21,0x00,0xa0,0x80,0x21,
+0x00,0xc0,0x88,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0xc0,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x03,0x3c,0x02,0xc0,0x00,0x00,0x10,0x1c,0x00,
+0x34,0x42,0x04,0x00,0x3c,0x04,0xb0,0x05,0x3c,0x05,0xb0,0x05,0x24,0x63,0x16,0x09,
+0x02,0x22,0x10,0x21,0x34,0x84,0x04,0x20,0x34,0xa5,0x04,0x24,0x3c,0x06,0xb0,0x05,
+0xac,0x83,0x00,0x00,0x24,0x07,0x00,0x01,0xac,0xa2,0x00,0x00,0x34,0xc6,0x02,0x28,
+0x24,0x02,0x00,0x20,0xae,0x47,0x00,0x3c,0x24,0x04,0x08,0x24,0xa0,0xc2,0x00,0x00,
+0x3c,0x05,0x00,0xc0,0xa2,0x47,0x00,0x11,0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x01,
+0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x01,
+0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,0xac,0x82,0x00,0x0c,0xa0,0x80,0x00,0x50,
+0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x14,
+0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,0xa4,0x80,0x00,0x20,0xac,0x80,0x00,0x24,
+0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xa0,0x80,0x00,0x30,0xa0,0x80,0x00,0x31,
+0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xa0,0x80,0x00,0x3c,0xac,0x82,0x00,0x10,
+0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x4c,
+0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,0x8c,0x83,0x00,0x00,0x3c,0x02,0x12,0x00,
+0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,0x34,0xa5,0x00,0x8b,0x24,0x02,0xff,0x80,
+0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x00,0x3c,0x04,0xb0,0x03,
+0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,0x3c,0x05,0xb0,0x01,0x3c,0x06,0x45,0x67,
+0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,0x34,0xa5,0x00,0x04,0x34,0xc6,0x89,0xaa,
+0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,0x3c,0x0b,0xb0,0x09,0x3c,0x07,0x01,0x23,
+0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,0xac,0x20,0x00,0x00,0x27,0xbd,0xff,0xe0,
+0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,0x3c,0x01,0xb0,0x09,0xac,0x26,0x00,0x00,
+0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,0x35,0x8c,0x00,0x0c,0x24,0x02,0xcd,0xef,
+0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,0x3c,0x0e,0xb0,0x09,0xad,0x67,0x00,0x00,
+0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,0xaf,0xb6,0x00,0x18,0xaf,0xb5,0x00,0x14,
+0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,0xaf,0xb2,0x00,0x08,0xaf,0xb1,0x00,0x04,
+0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,0x35,0x08,0x01,0x22,0x35,0xce,0x00,0x14,
+0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,0x3c,0x09,0x89,0xab,0x3c,0x10,0xb0,0x09,
+0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,0x3c,0x13,0xb0,0x09,0x3c,0x14,0xb0,0x09,
+0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,0x3c,0x17,0xb0,0x09,0xad,0xa8,0x00,0x00,
+0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,0x35,0xef,0x00,0x18,0x35,0x29,0xcd,0xee,
+0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,0x36,0x52,0x00,0x24,0x36,0x73,0x00,0x28,
+0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,0x36,0xd6,0x00,0x34,0x36,0xf7,0x00,0x38,
+0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,0xa6,0x02,0x00,0x00,0xae,0x23,0x00,0x00,
+0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,0x8f,0xb1,0x00,0x04,0xae,0x63,0x00,0x00,
+0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,0x8f,0xb3,0x00,0x0c,0xae,0xa3,0x00,0x00,
+0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,0x8f,0xb5,0x00,0x14,0xae,0xe3,0x00,0x00,
+0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,0x37,0x18,0x00,0x3c,0xa7,0x03,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x34,0x63,0x00,0x20,0x24,0x42,0x51,0x38,0xac,0x62,0x00,0x00,0x8c,0x83,0x00,0x34,
+0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,0x14,0x40,0x01,0x0b,0x00,0x80,0x30,0x21,
+0x8c,0x84,0x00,0x08,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0xfe,0x00,0x00,0x00,0x00,
+0x8c,0xc2,0x00,0x2c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x47,0x24,0x02,0x00,0x06,
+0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xe4,0xac,0xc2,0x00,0x2c,0x24,0x02,0x00,0x01,
+0x10,0x82,0x00,0xe3,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0xd1,
+0x00,0x00,0x00,0x00,0x8c,0xc7,0x00,0x04,0x24,0x02,0x00,0x02,0x10,0xe2,0x00,0xc7,
+0x00,0x00,0x00,0x00,0x8c,0xc2,0x00,0x14,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x09,
+0x24,0x02,0x00,0x01,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05,0xac,0xc2,0x00,0x14,
+0x24,0x02,0x00,0x01,0xac,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xc0,0x00,0x14,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x04,0x61,0x00,0x16,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x10,0x3c,0x02,0xb0,0x05,
+0x34,0x42,0x02,0x42,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0b,
+0x00,0x00,0x00,0x00,0x80,0xc2,0x00,0x50,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x07,
+0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01,
+0xac,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xc3,0x00,0x50,0x80,0xc2,0x00,0x31,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,
+0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00,0x00,0x64,0x18,0x24,
+0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08,0xac,0xc2,0x00,0x00,
+0x8c,0xc2,0x00,0x40,0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x10,0x60,0x00,0x09,0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,
+0x8c,0x43,0x00,0x00,0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24,0x14,0x60,0xff,0xf2,
+0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,
+0x8c,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00,0xac,0xc3,0x00,0x10,0x3c,0x02,0xb0,0x03,
+0x90,0x42,0x02,0x01,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0xac,0xc2,0x00,0x0c,
+0x90,0xc3,0x00,0x0f,0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03,0x08,0x00,0x14,0xa6,
+0xa0,0x23,0x02,0x01,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80,0x90,0x44,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03,0x10,0x60,0x00,0x15,
+0xa0,0xc4,0x00,0x44,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x02,
+0x10,0x62,0x00,0x03,0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x8c,0xc2,0x00,0x0c,0xac,0xc3,0x00,0x00,0x24,0x03,0x00,0x04,0xac,0xc2,0x00,0x10,
+0x03,0xe0,0x00,0x08,0xac,0xc3,0x00,0x0c,0x24,0x02,0x00,0x0d,0xac,0xc2,0x00,0x00,
+0x24,0x03,0x00,0x04,0x24,0x02,0x00,0x06,0xac,0xc3,0x00,0x10,0x03,0xe0,0x00,0x08,
+0xac,0xc2,0x00,0x0c,0x8c,0xc3,0x00,0x38,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x06,
+0x10,0x40,0x00,0x2e,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,0x24,0x63,0x02,0x00,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x06,0x24,0x02,0x00,0x03,
+0x8c,0xa2,0x02,0xbc,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x06,0x3c,0x03,0xb0,0x06,
+0x24,0x02,0x00,0x02,0xac,0xc2,0x00,0x00,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,
+0xac,0xc2,0x00,0x38,0x34,0x63,0x80,0x24,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05,0xac,0xc2,0x00,0x18,0x24,0x02,0x00,0x02,
+0xac,0xc2,0x00,0x00,0x08,0x00,0x14,0xfa,0xac,0xc0,0x00,0x18,0x08,0x00,0x14,0xfa,
+0xac,0xc0,0x00,0x00,0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x0b,0xac,0xc2,0x00,0x38,
+0x03,0xe0,0x00,0x08,0xac,0xc3,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x05,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x0c,0xac,0xc2,0x00,0x00,0x08,0x00,0x14,0xfb,
+0x24,0x02,0x00,0x04,0x08,0x00,0x15,0x12,0x24,0x02,0x00,0x03,0xac,0xc0,0x00,0x38,
+0x03,0xe0,0x00,0x08,0xac,0xc0,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x05,
+0x24,0x02,0x00,0x03,0x80,0xc2,0x00,0x30,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x08,
+0x24,0x02,0x00,0x04,0xac,0xc2,0x00,0x00,0x93,0x82,0x86,0x3c,0x00,0x00,0x00,0x00,
+0x14,0x40,0xff,0xd6,0x24,0x02,0x00,0x05,0x03,0xe0,0x00,0x08,0xac,0xc0,0x00,0x38,
+0x08,0x00,0x15,0x22,0xac,0xc0,0x00,0x00,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18,
+0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00,0x00,0x64,0x18,0x24,
+0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x08,0x00,0x15,0x26,0xac,0xc2,0x00,0x00,
+0x24,0x02,0x00,0x05,0x08,0x00,0x15,0x18,0xac,0xc2,0x00,0x38,0x80,0xc2,0x00,0x30,
+0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x37,0x24,0x02,0x00,0x04,0x08,0x00,0x14,0xa6,
+0x00,0x00,0x00,0x00,0x84,0xc2,0x00,0x20,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x66,
+0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,
+0x14,0x40,0xff,0x24,0xa4,0xc3,0x00,0x20,0x08,0x00,0x14,0xa6,0x24,0x02,0x00,0x06,
+0x8c,0xc2,0x00,0x1c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x57,0x24,0x02,0x00,0x05,
+0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x14,0xac,0xc2,0x00,0x1c,0x08,0x00,0x14,0xa6,
+0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x47,0x24,0x02,0x00,0x06,
+0x08,0x00,0x14,0x5c,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x0a,0x03,0xe0,0x00,0x08,
+0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10,0x27,0x90,0x86,0x48,
+0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0x0c,0x00,0x2b,0xe8,
+0xaf,0xb1,0x00,0x14,0xaf,0x90,0x8f,0xd0,0x48,0x02,0x00,0x00,0x0c,0x00,0x13,0xec,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x4e,0x02,0x00,0x20,0x21,0x0c,0x00,0x00,0x34,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0xf7,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x68,
+0x0c,0x00,0x27,0xc1,0x00,0x00,0x00,0x00,0x93,0x84,0x80,0x10,0x0c,0x00,0x21,0x9a,
+0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x08,0x0c,0x00,0x06,0xe1,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x01,0x3b,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x10,0x0c,0x00,0x13,0xd5,
+0x00,0x00,0x00,0x00,0x27,0x82,0x89,0x3c,0xaf,0x82,0x84,0x50,0x0c,0x00,0x00,0x61,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,
+0x3c,0x05,0xb0,0x09,0x8c,0x66,0x00,0x00,0x34,0x84,0x01,0x68,0x24,0x02,0xc8,0x80,
+0x34,0xa5,0x01,0x40,0x24,0x03,0x00,0x0a,0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,
+0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00,0x8f,0x87,0x84,0x10,0xaf,0x86,0x84,0x08,
+0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x58,
+0x8c,0x43,0x00,0x00,0x2c,0xe4,0x00,0x11,0x34,0x63,0x01,0x00,0xac,0x43,0x00,0x00,
+0x10,0x80,0xff,0xfa,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x00,0x07,0x10,0x80,
+0x24,0x63,0x02,0x18,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x68,0x0c,0x00,0x26,0xe5,
+0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x10,0x27,0x85,0x86,0x48,0x0c,0x00,0x14,0x4e,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x07,0x3c,0x03,0xb0,0x06,
+0x90,0x44,0x00,0x00,0x34,0x63,0x80,0x18,0x8c,0x65,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0xec,0x3c,0x03,0xb0,0x03,0x30,0x86,0x00,0xff,0xa0,0x46,0x00,0x00,
+0x00,0x05,0x2f,0x02,0x34,0x63,0x00,0xed,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x2c,
+0xa0,0x65,0x00,0x00,0xa3,0x80,0x81,0x58,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01,
+0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x87,0x84,0x10,0x8f,0x82,0x84,0x44,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x44,0x08,0x00,0x15,0x9b,
+0x3c,0x02,0xb0,0x03,0x8f,0x87,0x84,0x10,0x00,0x00,0x00,0x00,0x24,0xe2,0xff,0xfc,
+0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,0x3c,0x03,0xb0,0x06,0x93,0x82,0x86,0x3c,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x07,0x34,0x63,0x80,0x18,0x27,0x84,0x84,0x68,
+0x0c,0x00,0x27,0x75,0x00,0x00,0x00,0x00,0x8f,0x87,0x84,0x10,0x3c,0x03,0xb0,0x06,
+0x34,0x63,0x80,0x18,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,
+0x10,0x40,0xff,0xe6,0x00,0x00,0x00,0x00,0x8f,0x82,0xbc,0x10,0x8f,0x84,0xbc,0x18,
+0x3c,0x05,0xb0,0x01,0x00,0x45,0x10,0x21,0xac,0x44,0x00,0x00,0x8f,0x83,0xbc,0x10,
+0x8f,0x82,0xbc,0x14,0x00,0x65,0x18,0x21,0x08,0x00,0x15,0xc7,0xac,0x62,0x00,0x04,
+0x14,0xa0,0xff,0xd4,0x3c,0x02,0xb0,0x03,0x93,0x83,0x81,0x58,0x34,0x42,0x00,0xee,
+0x24,0x63,0x00,0x01,0x30,0x64,0x00,0xff,0x2c,0x84,0x00,0xf1,0xa0,0x43,0x00,0x00,
+0xa3,0x83,0x81,0x58,0x14,0x80,0xff,0xcc,0x00,0x00,0x00,0x00,0xaf,0x86,0x84,0x24,
+0xa3,0x86,0x86,0x23,0x08,0x00,0x15,0xc1,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x68,
+0x0c,0x00,0x29,0x6e,0x00,0x00,0x00,0x00,0xa3,0x82,0x84,0x41,0x8f,0x82,0x84,0x44,
+0xaf,0x80,0x84,0x10,0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x44,0x08,0x00,0x15,0x9a,
+0x00,0x00,0x38,0x21,0x27,0x84,0x86,0x48,0x0c,0x00,0x19,0x19,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x84,0x10,
+0xaf,0x80,0x84,0x14,0x08,0x00,0x15,0xc6,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x3c,
+0x14,0x40,0x00,0x20,0x24,0x02,0x00,0x01,0x8f,0x84,0x84,0x18,0x00,0x00,0x00,0x00,
+0x10,0x82,0x00,0x20,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x24,0x14,0x40,0x00,0x15,
+0x24,0x02,0x00,0x01,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x00,0x00,0x00,0x00,
+0x24,0x07,0x00,0x03,0x24,0x02,0x00,0x01,0xaf,0x82,0x84,0x14,0xaf,0x87,0x84,0x10,
+0x08,0x00,0x15,0xc6,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,
+0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,
+0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x30,0x14,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0xaf,0x82,0x84,0x14,0xaf,0x80,0x84,0x10,0x08,0x00,0x15,0xc6,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x2c,0x14,0x40,0xff,0xf5,
+0x24,0x02,0x00,0x01,0x08,0x00,0x16,0x1a,0x3c,0x03,0xb0,0x09,0x27,0x84,0x86,0x48,
+0x0c,0x00,0x1a,0xde,0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x40,0x00,0x00,0x00,0x00,
+0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x3c,
+0x14,0x40,0xff,0xe4,0x24,0x02,0x00,0x02,0x8f,0x84,0x84,0x18,0x24,0x02,0x00,0x01,
+0x10,0x82,0x00,0x12,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x04,0x00,0x00,0x00,0x00,
+0x24,0x07,0x00,0x04,0x08,0x00,0x16,0x26,0x24,0x02,0x00,0x02,0x3c,0x02,0xb0,0x05,
+0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,
+0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x30,0x14,0x40,0xff,0xf4,
+0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x35,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,
+0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,
+0xaf,0x82,0x84,0x2c,0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x56,
+0x24,0x02,0x00,0x02,0x27,0x84,0x89,0x08,0x0c,0x00,0x0b,0x51,0x00,0x00,0x00,0x00,
+0x8f,0x83,0x84,0x14,0xaf,0x82,0x84,0x2c,0x38,0x64,0x00,0x02,0x00,0x04,0x18,0x0a,
+0xaf,0x83,0x84,0x14,0x14,0x40,0xff,0xad,0x24,0x07,0x00,0x05,0x8f,0x82,0x89,0x48,
+0xaf,0x80,0x84,0x10,0x10,0x40,0x00,0x02,0x24,0x04,0x00,0x01,0xaf,0x84,0x84,0x18,
+0x93,0x82,0x89,0x56,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x43,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08,0x8c,0x43,0x00,0x00,0x3c,0x04,0x20,0x00,
+0x00,0x64,0x18,0x24,0x10,0x60,0xff,0x3c,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0xa0,0x8c,0x43,0x00,0x00,0x3c,0x04,0x80,0x00,0xaf,0x80,0x89,0x30,
+0x24,0x63,0x00,0x01,0xac,0x43,0x00,0x00,0x3c,0x01,0xb0,0x05,0xac,0x24,0x00,0x08,
+0xaf,0x80,0x89,0x2c,0xaf,0x80,0x89,0x34,0xaf,0x80,0x89,0x38,0xaf,0x80,0x89,0x44,
+0xaf,0x80,0x89,0x3c,0x08,0x00,0x15,0xc6,0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x60,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20,0xaf,0x82,0x84,0x2c,
+0x8f,0x85,0x84,0x2c,0x27,0x84,0x89,0x08,0x0c,0x00,0x0d,0x2c,0x00,0x00,0x00,0x00,
+0x00,0x02,0x1e,0x00,0xa3,0x82,0x84,0x40,0xaf,0x80,0x84,0x2c,0x10,0x60,0xff,0x8e,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,
+0xa7,0x83,0x84,0x30,0x10,0x40,0x00,0x04,0x24,0x04,0x00,0x02,0xaf,0x84,0x84,0x18,
+0x08,0x00,0x16,0x36,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x27,0x24,0x07,0x00,0x06,
+0x27,0x84,0x84,0x10,0x27,0x85,0x89,0x08,0x0c,0x00,0x0d,0xf9,0x00,0x00,0x00,0x00,
+0x8f,0x82,0x84,0x34,0xaf,0x80,0x84,0x3c,0x14,0x40,0x00,0x19,0x00,0x40,0x18,0x21,
+0x8f,0x82,0x84,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x02,
+0x8f,0x83,0x84,0x18,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x0b,0x3c,0x02,0x40,0x00,
+0x8f,0x83,0x84,0x14,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x02,0x24,0x07,0x00,0x03,
+0x24,0x07,0x00,0x06,0xaf,0x87,0x84,0x10,0x24,0x04,0x00,0x03,0xaf,0x84,0x84,0x18,
+0x08,0x00,0x15,0xc6,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05,
+0xac,0x22,0x00,0x00,0xaf,0x80,0x84,0x10,0x08,0x00,0x16,0xcf,0x24,0x04,0x00,0x03,
+0x10,0x60,0x00,0x10,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x10,0x27,0x85,0x89,0x08,
+0x0c,0x00,0x0e,0x1d,0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x14,0x24,0x02,0x00,0x01,
+0xa3,0x80,0x84,0x40,0xaf,0x80,0x84,0x18,0x10,0x62,0x00,0x02,0x24,0x07,0x00,0x03,
+0x24,0x07,0x00,0x04,0xaf,0x87,0x84,0x10,0xaf,0x80,0x84,0x34,0x08,0x00,0x15,0xc6,
+0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x60,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04,
+0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x08,0x0c,0x00,0x10,0x65,0x00,0x00,0x00,0x00,
+0x8f,0x82,0x84,0x14,0xa3,0x80,0x84,0x40,0xaf,0x80,0x84,0x10,0xaf,0x80,0x84,0x18,
+0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x14,
+0xaf,0x80,0x84,0x38,0x08,0x00,0x15,0xc6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x10,
+0x27,0x85,0x89,0x08,0x0c,0x00,0x0e,0x1d,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x14,
+0xa3,0x80,0x84,0x40,0xaf,0x80,0x84,0x10,0xaf,0x80,0x84,0x18,0x14,0x40,0xfe,0xc2,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x14,0x08,0x00,0x15,0xc6,
+0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x08,0x0c,0x00,0x10,0x65,0x00,0x00,0x00,0x00,
+0x08,0x00,0x16,0xff,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x68,0x0c,0x00,0x2a,0x96,
+0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xfe,0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x66,
+0x00,0x00,0x00,0x00,0x0c,0x00,0x27,0x56,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x40,
+0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x68,0x0c,0x00,0x27,0x64,0x00,0x00,0x00,0x00,
+0x93,0x83,0xbc,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x2b,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x83,0xbc,0x00,0x8f,0x82,0xbc,0x04,
+0x00,0x83,0x18,0x23,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x23,0x3c,0x02,0xb0,0x03,
+0x24,0x04,0x05,0xa0,0x34,0x42,0x01,0x18,0x8c,0x42,0x00,0x00,0x0c,0x00,0x06,0xce,
+0x00,0x00,0x00,0x00,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xce,0x00,0x02,0x84,0x02,
+0x30,0x51,0xff,0xff,0x24,0x04,0x05,0xa8,0x00,0x02,0x94,0x02,0x0c,0x00,0x06,0xce,
+0x3a,0x10,0xff,0xff,0x3a,0x31,0xff,0xff,0x30,0x42,0xff,0xff,0x2e,0x10,0x00,0x01,
+0x2e,0x31,0x00,0x01,0x3a,0x52,0xff,0xff,0x02,0x11,0x80,0x25,0x2e,0x52,0x00,0x01,
+0x38,0x42,0xff,0xff,0x02,0x12,0x80,0x25,0x2c,0x42,0x00,0x01,0x02,0x02,0x80,0x25,
+0x16,0x00,0x00,0x02,0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x05,0x70,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0xaf,0x83,0xbc,0x00,0x0c,0x00,0x01,0xeb,0x00,0x00,0x00,0x00,
+0xaf,0x80,0x84,0x10,0xaf,0x80,0x84,0x44,0x08,0x00,0x15,0x9a,0x00,0x00,0x38,0x21,
+0x27,0x90,0xb3,0xf0,0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
+0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x20,0xd0,0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6,
+0x26,0x10,0x00,0x04,0xaf,0x80,0x84,0x10,0x08,0x00,0x15,0xc7,0x00,0x00,0x38,0x21,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x84,0x08,
+0x00,0x04,0x19,0xc2,0x00,0x02,0x11,0xc2,0x10,0x62,0xff,0xf6,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02,0x90,0x43,0x00,0x00,0x3c,0x12,0xb0,0x05,
+0xaf,0x84,0x84,0x08,0x30,0x63,0x00,0xff,0x00,0x03,0x11,0x40,0x00,0x43,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x99,0x00,0x00,0x00,0x88,0x21,
+0x36,0x52,0x02,0x2c,0x27,0x90,0xb3,0xf0,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
+0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x03,0x10,0x40,0x00,0x06,
+0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x08,
+0x0c,0x00,0x1e,0xb2,0x02,0x60,0x30,0x21,0x8e,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xff,0x14,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x26,0x31,0x00,0x01,
+0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec,0x26,0x10,0x00,0x04,0x08,0x00,0x17,0x5d,
+0x00,0x00,0x00,0x00,0x8f,0x84,0x84,0x1c,0x27,0x85,0x89,0x08,0x0c,0x00,0x17,0xd3,
+0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x1c,0x24,0x02,0x00,0x04,0x14,0x62,0xfe,0xa2,
+0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x27,0x24,0x07,0x00,0x05,0x27,0x84,0x89,0x08,
+0x0c,0x00,0x24,0x8d,0x00,0x00,0x00,0x00,0x24,0x07,0x00,0x05,0xaf,0x87,0x84,0x10,
+0x08,0x00,0x15,0xc7,0x00,0x00,0x00,0x00,0x8f,0x82,0x89,0x3c,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x30,0xaf,0x80,0x89,0x3c,
+0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x84,0x00,0x00,0x00,0x00,0x93,0x82,0x8b,0x61,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x01,0x59,0x00,0x00,0x20,0x21,0x8f,0x84,0xb4,0x30,0x0c,0x00,0x20,0xd0,
+0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x5d,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x90,
+0x27,0xbd,0xff,0xe8,0x00,0x80,0x18,0x21,0x34,0x42,0x00,0x01,0x27,0x84,0x89,0x08,
+0x10,0x62,0x00,0x05,0xaf,0xbf,0x00,0x10,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x06,0xe1,0x00,0x00,0x00,0x00,
+0x27,0x84,0x86,0x48,0x0c,0x00,0x18,0x4e,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x10,
+0x0c,0x00,0x13,0xd5,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0xba,0x00,0x00,0x00,0x00,
+0x8f,0x82,0x89,0x48,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x18,0x21,
+0x8f,0x82,0x84,0x18,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00,
+0x24,0x03,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x27,0xbd,0xff,0xe0,
+0x3c,0x06,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x34,0xc6,0x00,0x5f,
+0xaf,0xbf,0x00,0x18,0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x5d,
+0x34,0x63,0x00,0x01,0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01,0xa0,0xc3,0x00,0x00,
+0x00,0x80,0x80,0x21,0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21,0x35,0x29,0x00,0x5e,
+0x00,0xe0,0x40,0x21,0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00,0x91,0x03,0x00,0x00,
+0x30,0x42,0x00,0x01,0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfa,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c,0x24,0x05,0x0f,0x00,
+0x24,0x02,0x00,0x06,0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x02,0x00,0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x0f,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5b,
+0x24,0x06,0x00,0x02,0x08,0x00,0x17,0xf4,0x3c,0x02,0xb0,0x03,0x24,0x04,0x08,0x8c,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04,0x24,0x05,0x00,0x0f,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30,0x24,0x06,0x00,0x03,
+0x0c,0x00,0x13,0x5b,0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21,0x24,0x05,0x00,0x14,
+0x0c,0x00,0x13,0xa0,0x24,0x06,0x01,0x07,0x08,0x00,0x17,0xf4,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x02,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x81,0x59,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x81,0x59,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x61,0x38,0x3c,0x04,0xb0,0x03,
+0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xbc,0xad,0xc0,0x02,0xb8,
+0x8c,0x83,0x00,0x00,0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21,
+0xa7,0x82,0x8f,0xe0,0x27,0x88,0x8f,0xf0,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08,
+0x30,0xc2,0xff,0xff,0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21,
+0x00,0x60,0x30,0x21,0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21,
+0x00,0x87,0x20,0x21,0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4,
+0xa4,0x43,0x00,0x00,0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x25,0xc4,0x00,0x0c,
+0x24,0x0a,0x00,0x02,0x34,0x42,0x07,0xf8,0x3c,0x06,0xb0,0x03,0xa7,0x83,0xb3,0xcc,
+0xac,0x43,0x00,0x00,0xaf,0x84,0xb3,0xf0,0x34,0xc6,0x00,0x64,0xa0,0x8a,0x00,0x18,
+0x94,0xc5,0x00,0x00,0x8f,0x82,0xb3,0xf0,0x25,0xc4,0x00,0x30,0x24,0x08,0x00,0x03,
+0x3c,0x03,0xb0,0x03,0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,0xaf,0x84,0xb3,0xf4,
+0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb3,0xf4,0x25,0xc4,0x00,0x54,
+0x25,0xc7,0x00,0x78,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb3,0xf8,0xa0,0x88,0x00,0x18,
+0x94,0x65,0x00,0x00,0x8f,0x82,0xb3,0xf8,0x25,0xc8,0x00,0x9c,0x24,0x09,0x00,0x01,
+0xa0,0x45,0x00,0x21,0xaf,0x87,0xb3,0xfc,0xa0,0xea,0x00,0x18,0x94,0xc4,0x00,0x00,
+0x8f,0x82,0xb3,0xfc,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,0xa0,0x44,0x00,0x21,
+0xaf,0x88,0xb4,0x00,0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x00,
+0x25,0xc4,0x00,0xc0,0x3c,0x06,0xb0,0x03,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x04,
+0xa0,0x89,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x04,0x25,0xc4,0x00,0xe4,
+0x34,0xc6,0x00,0x60,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x08,0xa0,0x80,0x00,0x18,
+0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x08,0x25,0xc3,0x01,0x08,0x25,0xc7,0x01,0x2c,
+0xa0,0x45,0x00,0x21,0xaf,0x83,0xb4,0x0c,0xa0,0x60,0x00,0x18,0x94,0xc8,0x00,0x00,
+0x8f,0x82,0xb4,0x0c,0x25,0xc4,0x01,0x50,0x25,0xc5,0x01,0x74,0xa0,0x48,0x00,0x21,
+0x25,0xc6,0x01,0x98,0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,0x25,0xcb,0x02,0x04,
+0x25,0xcc,0x02,0x28,0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,
+0xaf,0x87,0xb4,0x10,0x34,0x63,0x00,0x38,0xa0,0xe0,0x00,0x18,0xaf,0x84,0xb4,0x14,
+0xa0,0x80,0x00,0x18,0xaf,0x85,0xb4,0x18,0xa0,0xa0,0x00,0x18,0xaf,0x86,0xb4,0x1c,
+0xa0,0xc0,0x00,0x18,0xaf,0x89,0xb4,0x20,0xa1,0x20,0x00,0x18,0xaf,0x8a,0xb4,0x24,
+0xa1,0x40,0x00,0x18,0xaf,0x8b,0xb4,0x28,0xa1,0x60,0x00,0x18,0xaf,0x8c,0xb4,0x2c,
+0xa1,0x80,0x00,0x18,0xaf,0x8d,0xb4,0x30,0xa1,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,
+0x8f,0x82,0xb4,0x30,0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21,
+0x24,0x02,0x00,0x11,0xaf,0x85,0xb4,0x34,0x34,0x63,0x00,0x6e,0xa0,0xa2,0x00,0x18,
+0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x34,0x25,0xc5,0x02,0x94,0x3c,0x03,0xb0,0x03,
+0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x12,0xaf,0x85,0xb4,0x38,0x34,0x63,0x00,0x6c,
+0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x38,0x24,0x05,0xff,0xff,
+0x24,0x07,0x00,0x01,0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,0x27,0x84,0xb3,0xf0,
+0x8c,0x82,0x00,0x00,0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,0x8c,0x83,0x00,0x00,
+0xa4,0x45,0x00,0x00,0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,0x8c,0x82,0x00,0x00,
+0xa4,0x65,0x00,0x06,0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,0x8c,0x83,0x00,0x00,
+0xa4,0x45,0x00,0x0c,0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,0x8c,0x82,0x00,0x00,
+0x00,0x00,0x00,0x00,0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x14,
+0xa0,0x67,0x00,0x17,0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,0xa0,0x40,0x00,0x20,
+0x04,0xc1,0xff,0xe7,0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x64,0x00,
+0x00,0x05,0x28,0x40,0xac,0x62,0x00,0x00,0x00,0xa6,0x28,0x21,0x2c,0xe2,0x00,0x10,
+0x14,0x80,0x00,0x06,0x00,0x00,0x18,0x21,0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00,
+0x00,0xe0,0x18,0x21,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x24,0x02,0x00,0x20,
+0x10,0xe2,0x00,0x06,0x2c,0xe4,0x00,0x10,0x24,0xa2,0x00,0x01,0x10,0x80,0xff,0xf9,
+0x00,0x02,0x11,0x00,0x08,0x00,0x19,0x0d,0x00,0x47,0x18,0x21,0x08,0x00,0x19,0x0d,
+0x24,0xa3,0x00,0x50,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,
+0x34,0x63,0x00,0x20,0x24,0x42,0x64,0x64,0xaf,0xb2,0x00,0x18,0xaf,0xbf,0x00,0x34,
+0xaf,0xbe,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,
+0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,
+0xac,0x62,0x00,0x00,0x8c,0x86,0x02,0xbc,0x00,0x80,0x90,0x21,0x14,0xc0,0x01,0x66,
+0x00,0xc0,0x38,0x21,0x84,0x82,0x00,0x08,0x3c,0x03,0xb0,0x06,0x94,0x84,0x00,0x08,
+0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x45,0x00,0x00,0x8c,0x43,0x00,0x00,
+0x24,0x84,0x00,0x02,0x30,0x84,0x01,0xff,0x30,0xb1,0xff,0xff,0x00,0x03,0x44,0x02,
+0xa6,0x44,0x00,0x08,0x14,0xe0,0x00,0x08,0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x01,0x00,0xac,0x62,0x00,0x00,
+0x8e,0x46,0x02,0xbc,0x00,0x00,0x00,0x00,0x14,0xc0,0x01,0x4c,0x00,0x11,0x98,0xc0,
+0x00,0x11,0x3a,0x00,0x3c,0x04,0xb0,0x00,0x00,0xe4,0x20,0x21,0x8c,0x83,0x00,0x0c,
+0x00,0x11,0x98,0xc0,0x02,0x71,0x10,0x21,0x00,0x03,0x1b,0x82,0x30,0x63,0x00,0x1f,
+0x00,0x02,0x10,0x80,0x27,0x9e,0x8f,0xf4,0x00,0x5e,0x10,0x21,0x00,0x60,0x30,0x21,
+0xac,0x44,0x00,0x18,0xae,0x43,0x02,0xbc,0x14,0xc0,0x00,0x10,0x3c,0x02,0xb0,0x00,
+0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,0x27,0x84,0x8f,0xf0,0x00,0x02,0x10,0x80,
+0x00,0x44,0x10,0x21,0x94,0x45,0x00,0x00,0x02,0x71,0x18,0x21,0x00,0x03,0x18,0x80,
+0x00,0x64,0x18,0x21,0x24,0x02,0xff,0xff,0xa4,0x62,0x00,0x02,0xa4,0x68,0x00,0x04,
+0xae,0x51,0x02,0xb8,0xa6,0x45,0x00,0x0a,0x3c,0x02,0xb0,0x00,0x00,0xe2,0x40,0x21,
+0x8d,0x16,0x00,0x00,0x8d,0x14,0x00,0x04,0x02,0x71,0x10,0x21,0x00,0x02,0x38,0x80,
+0x00,0x14,0x1a,0x02,0x27,0x84,0x90,0x00,0x30,0x63,0x00,0x1f,0x24,0x02,0x00,0x10,
+0x00,0xe4,0x20,0x21,0xa6,0x43,0x00,0x06,0x8d,0x10,0x00,0x08,0xa0,0x82,0x00,0x06,
+0x86,0x45,0x00,0x06,0x00,0xfe,0x10,0x21,0x24,0x03,0x00,0x13,0x10,0xa3,0x01,0x15,
+0xac,0x48,0x00,0x18,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00,0xa6,0x40,0x00,0x02,
+0x3c,0x02,0xb0,0x03,0x90,0x64,0x00,0x00,0x34,0x42,0x01,0x08,0x8c,0x45,0x00,0x00,
+0x00,0x10,0x1b,0xc2,0x27,0x82,0x8f,0xf0,0x00,0x04,0x20,0x82,0x00,0xe2,0x10,0x21,
+0x30,0x63,0x00,0x01,0xac,0x45,0x00,0x08,0x10,0x60,0x00,0xec,0x30,0x97,0x00,0x01,
+0x00,0x10,0x16,0x82,0x30,0x46,0x00,0x01,0x00,0x10,0x12,0x02,0x00,0x10,0x19,0xc2,
+0x00,0x10,0x26,0x02,0x00,0x10,0x2e,0x42,0x30,0x47,0x00,0x7f,0x24,0x02,0x00,0x01,
+0x30,0x75,0x00,0x01,0x30,0x84,0x00,0x01,0x10,0xc2,0x00,0xd9,0x30,0xa3,0x00,0x01,
+0x0c,0x00,0x19,0x00,0x00,0x60,0x28,0x21,0x02,0x71,0x18,0x21,0x00,0x03,0x18,0x80,
+0x2c,0x46,0x00,0x54,0x27,0x85,0x90,0x00,0x27,0x84,0x8f,0xf8,0x00,0x06,0x10,0x0a,
+0x00,0x65,0x28,0x21,0x26,0xa6,0x00,0x02,0x00,0x64,0x18,0x21,0xa0,0xa2,0x00,0x02,
+0xa0,0x66,0x00,0x06,0xa0,0x62,0x00,0x07,0xa0,0xa2,0x00,0x01,0x02,0x71,0x20,0x21,
+0x00,0x04,0x20,0x80,0x00,0x9e,0x60,0x21,0x8d,0x85,0x00,0x18,0x00,0x10,0x15,0xc2,
+0x30,0x42,0x00,0x01,0x8c,0xa3,0x00,0x0c,0xa6,0x42,0x00,0x00,0x27,0x82,0x90,0x10,
+0x00,0x82,0x50,0x21,0xa6,0x56,0x00,0x04,0x8d,0x45,0x00,0x00,0x00,0x03,0x19,0x42,
+0x3c,0x02,0xff,0xef,0x34,0x42,0xff,0xff,0x30,0x63,0x00,0x01,0x00,0xa2,0x48,0x24,
+0x00,0x03,0x1d,0x00,0x01,0x23,0x48,0x25,0x00,0x09,0x15,0x02,0x26,0xc5,0x00,0x10,
+0x00,0x14,0x19,0x82,0x00,0x14,0x25,0x82,0x00,0x10,0x34,0x02,0x00,0x10,0x3c,0x42,
+0x00,0x10,0x44,0x82,0x30,0x42,0x00,0x01,0x30,0xb5,0xff,0xff,0x30,0xce,0x00,0x01,
+0x30,0xe5,0x00,0x01,0x30,0x6d,0x00,0x01,0x30,0x8b,0x00,0x03,0x32,0x94,0x00,0x07,
+0x31,0x06,0x00,0x01,0xad,0x49,0x00,0x00,0x10,0x40,0x00,0x0b,0x32,0x07,0x00,0x7f,
+0x8d,0x84,0x00,0x18,0x3c,0x03,0xff,0xf0,0x34,0x63,0xff,0xff,0x8c,0x82,0x00,0x0c,
+0x01,0x23,0x18,0x24,0x00,0x02,0x13,0x82,0x30,0x42,0x00,0x0f,0x00,0x02,0x14,0x00,
+0x00,0x62,0x18,0x25,0xad,0x43,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x90,
+0x00,0x00,0x00,0x00,0x15,0xa0,0x00,0x03,0x00,0x00,0x00,0x00,0x15,0x60,0x00,0x81,
+0x24,0x02,0x00,0x01,0x96,0x42,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,
+0xa6,0x42,0x00,0x04,0x0c,0x00,0x19,0x00,0x01,0xc0,0x20,0x21,0x02,0x71,0x18,0x21,
+0x00,0x03,0x38,0x80,0x2c,0x45,0x00,0x54,0x27,0x84,0x90,0x00,0x00,0xe4,0x20,0x21,
+0x00,0x05,0x10,0x0a,0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05,
+0x96,0x45,0x00,0x04,0x27,0x82,0x8f,0xf0,0x00,0xe2,0x10,0x21,0xa4,0x45,0x00,0x06,
+0x00,0xfe,0x18,0x21,0x92,0x45,0x00,0x01,0x8c,0x66,0x00,0x18,0x27,0x82,0x90,0x10,
+0x00,0xe2,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x85,0x00,0x07,0x94,0xc3,0x00,0x10,
+0x24,0x02,0x00,0x04,0x30,0x63,0x00,0x0f,0x10,0x62,0x00,0x5e,0x24,0xc6,0x00,0x10,
+0x94,0xc3,0x00,0x16,0x27,0x85,0x90,0x08,0x00,0xe5,0x10,0x21,0xa4,0x43,0x00,0x02,
+0x94,0xc2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x4c,
+0x02,0x71,0x20,0x21,0x94,0xc2,0x00,0x00,0x24,0x03,0x00,0xa4,0x30,0x42,0x00,0xff,
+0x10,0x43,0x00,0x47,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x00,0x24,0x03,0x00,0x88,
+0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x3c,0x02,0x71,0x18,0x21,0x27,0x84,0x90,0x10,
+0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00,0x3c,0x04,0x00,0x80,
+0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x45,0x10,0x21,0xa0,0x54,0x00,0x00,0x92,0x43,0x02,0xbf,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x00,0xc3,0xa0,0x43,0x00,0x00,0x8e,0x4b,0x02,0xbc,0x00,0x00,0x00,0x00,
+0x11,0x60,0x00,0x1c,0x32,0xa2,0x00,0xff,0x00,0x15,0x1a,0x02,0x30,0x64,0xff,0xff,
+0x38,0x42,0x00,0x00,0x24,0x65,0x00,0x01,0x00,0x82,0x28,0x0a,0x02,0x20,0x30,0x21,
+0x10,0xa0,0x00,0x12,0x00,0x00,0x38,0x21,0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x8f,0xf0,0x00,0x43,0x20,0x21,0x24,0xa9,0xff,0xff,0x3c,0x0a,0xb0,0x08,
+0x24,0x0c,0xff,0xff,0x00,0x06,0x10,0xc0,0x00,0x4a,0x10,0x21,0x8c,0x43,0x00,0x00,
+0x24,0xe8,0x00,0x01,0x10,0xe9,0x00,0x0f,0x30,0x63,0x00,0xff,0x31,0x07,0xff,0xff,
+0x00,0xe5,0x10,0x2b,0x14,0x40,0xff,0xf7,0x00,0x60,0x30,0x21,0x25,0x62,0xff,0xff,
+0xae,0x42,0x02,0xbc,0x7b,0xbe,0x01,0xbc,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x38,0xa4,0x86,0x00,0x04,0xa4,0x8c,0x00,0x02,0xae,0x51,0x02,0xb8,
+0x08,0x00,0x1a,0x2f,0xa6,0x43,0x00,0x0a,0x94,0xc2,0x00,0x18,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xc1,0x02,0x71,0x18,0x21,0x02,0x71,0x20,0x21,
+0x27,0x82,0x90,0x10,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21,0x8c,0x83,0x00,0x00,
+0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24,0x08,0x00,0x1a,0x0e,
+0xac,0x83,0x00,0x00,0x27,0x85,0x90,0x08,0x00,0xe5,0x10,0x21,0x08,0x00,0x19,0xf8,
+0xa4,0x40,0x00,0x02,0x11,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x2d,0x62,0x00,0x02,
+0x14,0x40,0xff,0x80,0x00,0x00,0x00,0x00,0x96,0x42,0x00,0x04,0x08,0x00,0x19,0xd8,
+0x24,0x42,0x00,0x0c,0x96,0x42,0x00,0x04,0x08,0x00,0x19,0xd8,0x24,0x42,0x00,0x08,
+0x16,0xe6,0xff,0x70,0x3c,0x02,0xff,0xfb,0x8d,0x83,0x00,0x18,0x34,0x42,0xff,0xff,
+0x02,0x02,0x10,0x24,0xac,0x62,0x00,0x08,0x08,0x00,0x19,0xd1,0x00,0x00,0x30,0x21,
+0x16,0xe6,0xff,0x27,0x3c,0x02,0xfb,0xff,0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,
+0xad,0x02,0x00,0x08,0x08,0x00,0x19,0x90,0x00,0x00,0x30,0x21,0x93,0x88,0xbb,0x04,
+0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82,0x27,0x82,0x8f,0xf8,0x2d,0x05,0x00,0x0c,
+0x00,0xe2,0x48,0x21,0x30,0x63,0x00,0x01,0x30,0x86,0x00,0x01,0x14,0xa0,0x00,0x06,
+0x01,0x00,0x38,0x21,0x00,0x03,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,
+0x01,0x02,0x10,0x21,0x24,0x47,0x00,0x04,0x02,0x71,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x84,0x90,0x00,0x27,0x83,0x8f,0xf8,0x00,0x44,0x20,0x21,0x00,0x43,0x10,0x21,
+0xa1,0x27,0x00,0x07,0xa0,0x40,0x00,0x06,0xa0,0x80,0x00,0x02,0x08,0x00,0x19,0x9f,
+0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01,0xa6,0x42,0x00,0x02,0x0c,0x00,0x01,0xc4,
+0x01,0x00,0x20,0x21,0x08,0x00,0x1a,0x35,0x00,0x00,0x00,0x00,0x27,0x9e,0x8f,0xf4,
+0x08,0x00,0x19,0x52,0x00,0x11,0x3a,0x00,0x94,0x91,0x00,0x0a,0x08,0x00,0x19,0x39,
+0x00,0x00,0x00,0x00,0x30,0xa9,0xff,0xff,0x00,0x09,0x18,0xc0,0x00,0x69,0x18,0x21,
+0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6a,0x54,0x00,0x03,0x18,0x80,
+0x34,0xc6,0x00,0x20,0x27,0x85,0x90,0x00,0xac,0xc2,0x00,0x00,0x00,0x65,0x18,0x21,
+0x80,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x32,0x24,0x88,0x00,0x06,
+0x90,0x82,0x00,0x16,0x00,0x80,0x40,0x21,0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01,
+0x14,0x60,0x00,0x02,0xa0,0x82,0x00,0x16,0xa0,0x80,0x00,0x17,0x95,0x03,0x00,0x02,
+0x00,0x00,0x00,0x00,0x10,0x69,0x00,0x22,0x3c,0x02,0x34,0x34,0x91,0x02,0x00,0x04,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x06,0x00,0x03,0x20,0xc0,0x24,0x02,0x00,0x01,
+0xa1,0x02,0x00,0x04,0xa5,0x09,0x00,0x02,0x03,0xe0,0x00,0x08,0xa5,0x09,0x00,0x00,
+0x00,0x83,0x20,0x21,0x27,0x87,0x8f,0xf0,0x00,0x04,0x20,0x80,0x00,0x87,0x20,0x21,
+0x94,0x83,0x00,0x04,0x3c,0x02,0xb0,0x08,0x3c,0x06,0xb0,0x03,0x00,0x03,0x28,0xc0,
+0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21,0x3c,0x02,0x80,0x01,
+0x24,0x42,0x82,0xe4,0x00,0x67,0x18,0x21,0x34,0xc6,0x00,0x20,0xac,0xc2,0x00,0x00,
+0xa4,0x69,0x00,0x00,0xa4,0x89,0x00,0x02,0xac,0xa9,0x00,0x00,0x91,0x02,0x00,0x04,
+0xa5,0x09,0x00,0x02,0x24,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x04,
+0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xb0,0x34,0x42,0x34,0x34,0x03,0xe0,0x00,0x08,
+0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x01,
+0x30,0x43,0x00,0x02,0x14,0x60,0xff,0xd1,0xa0,0x82,0x00,0x16,0x24,0x02,0x00,0x01,
+0x08,0x00,0x1a,0xab,0xa0,0x82,0x00,0x17,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,
+0x00,0x80,0x38,0x21,0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x3c,0x0a,0xb0,0x06,0x34,0x63,0x00,0x20,0x24,0x42,0x6b,0x78,0x3c,0x0b,0xb0,0x08,
+0x27,0x89,0x8f,0xf0,0x34,0x0c,0xff,0xff,0x35,0x4a,0x80,0x20,0x10,0x80,0x00,0x30,
+0xac,0x62,0x00,0x00,0x97,0x82,0x8f,0xe0,0x94,0xe6,0x02,0xba,0x00,0x02,0x18,0xc0,
+0x00,0x6b,0x28,0x21,0xac,0xa6,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x00,0x62,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x49,0x10,0x21,0x94,0x48,0x00,0x04,0x00,0x69,0x18,0x21,0xa4,0x66,0x00,0x00,
+0x00,0x08,0x28,0xc0,0x00,0xab,0x10,0x21,0xac,0x4c,0x00,0x00,0x8c,0xe4,0x02,0xb8,
+0x27,0x82,0x8f,0xf4,0x00,0xa8,0x28,0x21,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x46,0x00,0x18,0x27,0x84,0x90,0x00,
+0x00,0x64,0x18,0x21,0x8c,0xc2,0x00,0x00,0x80,0x67,0x00,0x06,0x00,0x05,0x28,0x80,
+0x30,0x42,0xff,0xff,0x00,0x47,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,
+0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x3c,0x04,0x00,0x04,0x00,0xa9,0x28,0x21,
+0x00,0x44,0x10,0x25,0xa4,0xac,0x00,0x00,0xad,0x42,0x00,0x00,0xa7,0x88,0x8f,0xe0,
+0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x84,0xe3,0x00,0x06,0x27,0x82,0xb3,0xf0,0x94,0xe5,0x02,0xba,0x00,0x03,0x18,0x80,
+0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x0c,0x00,0x1a,0x95,0x00,0x00,0x00,0x00,
+0x08,0x00,0x1b,0x18,0x00,0x00,0x00,0x00,0x94,0x88,0x00,0x00,0x00,0x80,0x58,0x21,
+0x27,0x8a,0x8f,0xf0,0x00,0x08,0x18,0xc0,0x00,0x68,0x18,0x21,0x3c,0x04,0xb0,0x03,
+0x00,0x03,0x18,0x80,0x3c,0x02,0x80,0x00,0x00,0x6a,0x18,0x21,0x34,0x84,0x00,0x20,
+0x24,0x42,0x6c,0x98,0x30,0xa5,0xff,0xff,0xac,0x82,0x00,0x00,0x94,0x67,0x00,0x02,
+0x11,0x05,0x00,0x35,0x24,0x04,0x00,0x01,0x91,0x66,0x00,0x04,0x00,0x00,0x00,0x00,
+0x00,0x86,0x10,0x2a,0x10,0x40,0x00,0x10,0x00,0xc0,0x48,0x21,0x3c,0x0d,0xb0,0x03,
+0x01,0x40,0x60,0x21,0x35,0xad,0x00,0x20,0x10,0xe5,0x00,0x0d,0x24,0x84,0x00,0x01,
+0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x01,0x20,0x30,0x21,
+0x00,0x4a,0x10,0x21,0x00,0x86,0x18,0x2a,0x00,0xe0,0x40,0x21,0x94,0x47,0x00,0x02,
+0x14,0x60,0xff,0xf5,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,
+0x00,0x08,0x20,0xc0,0x00,0x88,0x20,0x21,0x24,0xc2,0xff,0xff,0x00,0x04,0x20,0x80,
+0xa1,0x62,0x00,0x04,0x00,0x8c,0x20,0x21,0x94,0x83,0x00,0x04,0x00,0x07,0x10,0xc0,
+0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21,0x00,0x03,0x28,0xc0,
+0x94,0x46,0x00,0x02,0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6c,0x18,0x21,
+0xa4,0x66,0x00,0x00,0xa4,0x86,0x00,0x02,0x95,0x64,0x00,0x02,0x3c,0x03,0xb0,0x08,
+0x3c,0x02,0x80,0x01,0x00,0xa3,0x28,0x21,0x24,0x42,0x82,0xe4,0xad,0xa2,0x00,0x00,
+0x10,0x87,0x00,0x03,0xac,0xa6,0x00,0x00,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,
+0x08,0x00,0x1b,0x66,0xa5,0x68,0x00,0x02,0x91,0x62,0x00,0x04,0xa5,0x67,0x00,0x00,
+0x24,0x42,0xff,0xff,0x30,0x43,0x00,0xff,0x14,0x60,0x00,0x03,0xa1,0x62,0x00,0x04,
+0x24,0x02,0xff,0xff,0xa5,0x62,0x00,0x02,0x91,0x65,0x00,0x04,0x00,0x00,0x00,0x00,
+0x10,0xa0,0xff,0xf1,0x00,0x00,0x00,0x00,0x95,0x66,0x00,0x00,0x34,0x02,0xff,0xff,
+0x14,0xc2,0xff,0xed,0x3c,0x03,0xb0,0x03,0x95,0x64,0x00,0x02,0x3c,0x02,0xee,0xee,
+0x00,0xa2,0x10,0x25,0x34,0x63,0x00,0xbc,0xac,0x62,0x00,0x00,0x10,0x86,0xff,0xe6,
+0xa1,0x60,0x00,0x04,0x24,0x02,0xff,0xff,0x08,0x00,0x1b,0x66,0xa5,0x62,0x00,0x02,
+0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21,0x27,0xbd,0xff,0xd8,0x00,0x06,0x30,0x80,
+0x27,0x82,0x8f,0xf4,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,
+0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10,0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18,
+0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,
+0x24,0x42,0x6e,0x10,0xac,0xa2,0x00,0x00,0x27,0x83,0x90,0x00,0x00,0xc3,0x30,0x21,
+0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06,0x00,0x80,0x88,0x21,0x30,0x42,0xff,0xff,
+0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff,0x10,0x60,0x00,0x02,0x00,0x02,0x12,0x02,
+0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff,0x01,0x12,0x10,0x21,0x00,0x02,0x10,0x80,
+0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x80,0x44,0x00,0x07,0x00,0x00,0x00,0x00,
+0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06,0x32,0x50,0xff,0xff,0x02,0x20,0x20,0x21,
+0x0c,0x00,0x1b,0x26,0x02,0x00,0x28,0x21,0x92,0x22,0x00,0x10,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08,0x3c,0x09,0x80,0x01,0x27,0x88,0x8f,0xf0,
+0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0,0x00,0x90,0x20,0x21,0x00,0x04,0x20,0x80,
+0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,
+0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x48,0x10,0x21,
+0x00,0xa3,0x28,0x21,0x25,0x26,0x82,0xe4,0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,
+0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,
+0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a,0xa6,0x32,0x00,0x0e,0x02,0x62,0x10,0x21,
+0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10,0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x96,0x22,0x00,0x0e,
+0x27,0x88,0x8f,0xf0,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,
+0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x06,0xb0,0x03,0x3c,0x09,0x80,0x01,
+0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,
+0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20,0x25,0x23,0x82,0xe4,0xac,0xc3,0x00,0x00,
+0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00,0x08,0x00,0x1b,0xb5,0xa4,0x90,0x00,0x02,
+0x08,0x00,0x1b,0xac,0x32,0x50,0xff,0xff,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x24,0x42,0x6f,0xd8,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x04,
+0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21,0x30,0xa8,0xff,0xff,0x00,0x4a,0x20,0x23,
+0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff,0x30,0xee,0xff,0xff,0x11,0x09,0x00,0x73,
+0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0,0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,
+0x03,0x0e,0x20,0x21,0x27,0x8d,0x8f,0xf0,0x00,0x04,0x20,0x80,0x00,0x02,0x10,0x80,
+0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21,0x94,0x86,0x00,0x02,0x94,0x43,0x00,0x04,
+0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02,0x00,0x03,0x28,0xc0,0x00,0xa3,0x18,0x21,
+0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21,
+0x00,0x6d,0x18,0x21,0x27,0x22,0x82,0xe4,0x3c,0x01,0xb0,0x03,0xac,0x22,0x00,0x20,
+0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57,0xac,0xa6,0x00,0x00,0x01,0xe0,0x30,0x21,
+0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21,0x01,0x40,0x38,0x21,0x27,0x8b,0x8f,0xf4,
+0x27,0x8a,0x90,0x00,0x00,0x06,0x40,0xc0,0x01,0x06,0x18,0x21,0x00,0x03,0x18,0x80,
+0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x6a,0x18,0x21,0x80,0x65,0x00,0x06,
+0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,
+0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02,0x01,0x22,0x18,0x21,0x24,0x62,0x00,0x01,
+0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff,0x30,0x69,0x00,0xff,0x01,0x06,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x24,0xe7,0xff,0xff,0x94,0x46,0x00,0x02,
+0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0,0x91,0x82,0x00,0x10,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03,0xa5,0x8f,0x00,0x0c,0x03,0x0e,0x20,0x21,
+0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,
+0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21,0x27,0x26,0x82,0xe4,0x34,0x03,0xff,0xff,
+0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,
+0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10,0x91,0x83,0x00,0x04,0xa5,0x8e,0x00,0x0e,
+0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05,0xa1,0x82,0x00,0x10,0x91,0x82,0x00,0x16,
+0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa1,0x82,0x00,0x16,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e,0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,
+0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,
+0x34,0xc6,0x00,0x20,0x27,0x27,0x82,0xe4,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x4d,0x10,0x21,0xac,0xc7,0x00,0x00,
+0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00,0xac,0xaf,0x00,0x00,0x08,0x00,0x1c,0x44,
+0x03,0x0e,0x20,0x21,0x08,0x00,0x1c,0x1f,0xa5,0x88,0x00,0x02,0x00,0x0e,0xc0,0xc0,
+0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x8d,0x8f,0xf0,0x00,0x4d,0x10,0x21,
+0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff,0x14,0x80,0x00,0x05,0xa5,0x83,0x00,0x00,
+0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01,0x08,0x00,0x1c,0x1f,0xa5,0x82,0x00,0x02,
+0x08,0x00,0x1c,0x1f,0x3c,0x19,0x80,0x01,0x3c,0x08,0xb0,0x03,0x3c,0x02,0x80,0x00,
+0x27,0xbd,0xff,0x78,0x35,0x08,0x00,0x20,0x24,0x42,0x72,0x18,0xaf,0xb2,0x00,0x68,
+0xaf,0xb1,0x00,0x64,0xaf,0xb0,0x00,0x60,0xad,0x02,0x00,0x00,0xaf,0xbf,0x00,0x84,
+0xaf,0xbe,0x00,0x80,0xaf,0xb7,0x00,0x7c,0xaf,0xb6,0x00,0x78,0xaf,0xb5,0x00,0x74,
+0xaf,0xb4,0x00,0x70,0xaf,0xb3,0x00,0x6c,0xaf,0xa4,0x00,0x88,0x90,0x83,0x00,0x0a,
+0x27,0x82,0xb3,0xf0,0xaf,0xa6,0x00,0x90,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,
+0x8c,0x63,0x00,0x00,0xaf,0xa7,0x00,0x94,0x27,0x86,0x8f,0xf4,0xaf,0xa3,0x00,0x1c,
+0x94,0x63,0x00,0x14,0x30,0xb1,0xff,0xff,0x24,0x08,0x00,0x01,0x00,0x03,0x20,0xc0,
+0xaf,0xa3,0x00,0x18,0x00,0x83,0x18,0x21,0xaf,0xa4,0x00,0x54,0x00,0x03,0x18,0x80,
+0x27,0x84,0x90,0x00,0x00,0x64,0x20,0x21,0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21,
+0x8c,0x66,0x00,0x18,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2,
+0x00,0x04,0x1c,0x82,0x00,0xc2,0x38,0x21,0x00,0x04,0x24,0x42,0x8f,0xa2,0x00,0x1c,
+0x30,0x63,0x00,0x01,0x30,0x84,0x00,0x01,0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34,
+0xaf,0xa4,0x00,0x38,0xaf,0xa0,0x00,0x40,0xaf,0xa0,0x00,0x44,0xaf,0xa0,0x00,0x50,
+0xaf,0xa8,0x00,0x20,0x80,0x42,0x00,0x12,0x8f,0xb2,0x00,0x18,0xaf,0xa2,0x00,0x28,
+0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xe4,0x00,0x60,0x30,0x21,0x00,0x10,0x10,0x82,
+0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11,0xaf,0xa0,0x00,0x30,0x8f,0xa4,0x00,0x98,
+0x27,0x82,0x80,0x1c,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x21,0x24,0xa2,0x00,0x06,
+0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00,0x00,0x45,0x10,0x04,0x00,0x44,0x00,0x1a,
+0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,
+0x24,0x42,0x00,0x20,0x30,0x42,0xff,0xfc,0xaf,0xa2,0x00,0x30,0x8f,0xa3,0x00,0x18,
+0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff,0xaf,0xa0,0x00,0x2c,0xaf,0xa2,0x00,0x48,
+0xaf,0xa3,0x00,0x4c,0x00,0x60,0xf0,0x21,0x00,0x00,0xb8,0x21,0x18,0x80,0x00,0x48,
+0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02,0xaf,0xb1,0x00,0x58,0x00,0x80,0xa8,0x21,
+0x00,0x12,0x10,0xc0,0x00,0x52,0x18,0x21,0x00,0x03,0x80,0x80,0x27,0x85,0x8f,0xf0,
+0x02,0x40,0x20,0x21,0x00,0x40,0xa0,0x21,0x02,0x05,0x10,0x21,0x94,0x56,0x00,0x02,
+0x0c,0x00,0x12,0x87,0x00,0x00,0x28,0x21,0x90,0x42,0x00,0x00,0x24,0x03,0x00,0x08,
+0x30,0x42,0x00,0x0c,0x10,0x43,0x01,0x9e,0x24,0x04,0x00,0x01,0x24,0x02,0x00,0x01,
+0x10,0x82,0x01,0x7c,0x3c,0x02,0xb0,0x03,0x8f,0xa6,0x00,0x88,0x34,0x42,0x01,0x04,
+0x84,0xc5,0x00,0x0c,0x02,0x92,0x18,0x21,0x94,0x46,0x00,0x00,0x00,0x05,0x20,0xc0,
+0x00,0x85,0x20,0x21,0x00,0x03,0x18,0x80,0x27,0x82,0x90,0x00,0x27,0x85,0x8f,0xf8,
+0x00,0x65,0x28,0x21,0x00,0x62,0x18,0x21,0x80,0x71,0x00,0x05,0x80,0x73,0x00,0x04,
+0x8f,0xa3,0x00,0x88,0x30,0xd0,0xff,0xff,0x00,0x10,0x3a,0x03,0x32,0x08,0x00,0xff,
+0x27,0x82,0x90,0x10,0x00,0x04,0x20,0x80,0x80,0xa6,0x00,0x06,0x00,0x82,0x20,0x21,
+0xa4,0x67,0x00,0x44,0xa4,0x68,0x00,0x46,0x8c,0x84,0x00,0x00,0x38,0xc6,0x00,0x00,
+0x01,0x00,0x80,0x21,0x00,0x04,0x15,0x02,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x03,
+0x00,0xe6,0x80,0x0a,0x00,0x04,0x14,0x02,0x30,0x50,0x00,0x0f,0x12,0x20,0x01,0x50,
+0x02,0x40,0x20,0x21,0x02,0x71,0x10,0x21,0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xed,
+0x02,0x92,0x10,0x21,0x93,0x82,0x8b,0x61,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,
+0x14,0x40,0x00,0xe0,0x02,0x92,0x28,0x21,0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,
+0x02,0x40,0xf0,0x21,0x26,0xb5,0xff,0xff,0x16,0xa0,0xff,0xbd,0x02,0xc0,0x90,0x21,
+0x16,0xe0,0x00,0xd0,0x00,0x00,0x00,0x00,0x8f,0xa3,0x00,0x98,0x00,0x00,0x00,0x00,
+0x2c,0x62,0x00,0x10,0x10,0x40,0x00,0x2e,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x24,
+0x00,0x00,0x00,0x00,0x18,0x80,0x00,0x2a,0x24,0x03,0x00,0x01,0x8f,0xa5,0x00,0x1c,
+0x27,0x84,0x8f,0xf4,0x94,0xb2,0x00,0x14,0xa0,0xa3,0x00,0x12,0x8f,0xa6,0x00,0x3c,
+0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21,0x00,0x02,0x80,0x80,0x27,0x82,0x90,0x00,
+0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06,0x02,0x04,0x20,0x21,0x8c,0x85,0x00,0x18,
+0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,
+0x00,0x03,0x18,0x40,0x14,0xc0,0x00,0x0e,0x00,0xa3,0x38,0x21,0x27,0x82,0x8f,0xf0,
+0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x8f,0xa8,0x00,0x1c,0x24,0x02,0x00,0x01,
+0xa5,0x03,0x00,0x1a,0x7b,0xbe,0x04,0x3c,0x7b,0xb6,0x03,0xfc,0x7b,0xb4,0x03,0xbc,
+0x7b,0xb2,0x03,0x7c,0x7b,0xb0,0x03,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x88,
+0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,
+0x0c,0x00,0x09,0x06,0xaf,0xa0,0x00,0x14,0x08,0x00,0x1d,0x4b,0x00,0x00,0x00,0x00,
+0x8f,0xa3,0x00,0x44,0x93,0x82,0x81,0x59,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x61,
+0x30,0x69,0x00,0x03,0x8f,0xa4,0x00,0x24,0x8f,0xa5,0x00,0x28,0x00,0x00,0x00,0x00,
+0x00,0x85,0x10,0x2a,0x10,0x40,0x00,0x8f,0x00,0x00,0x00,0x00,0x8f,0xa6,0x00,0x1c,
+0x00,0x00,0x00,0x00,0x90,0xc4,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,
+0x00,0xa3,0x10,0x2a,0x10,0x40,0x00,0x87,0x00,0x00,0x00,0x00,0x8f,0xa8,0x00,0x24,
+0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x83,0x00,0x65,0x10,0x23,0x00,0xa8,0x18,0x23,
+0x00,0x62,0x10,0x2a,0x14,0x40,0x00,0x7d,0x30,0x63,0x00,0xff,0x00,0x85,0x10,0x23,
+0x30,0x42,0x00,0xff,0xaf,0xa2,0x00,0x50,0x8f,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x73,0x00,0x00,0xa8,0x21,0x27,0x8c,0x8f,0xf0,0x3c,0x0b,0x80,0xff,
+0x24,0x10,0x00,0x04,0x27,0x91,0x8f,0xf4,0x35,0x6b,0xff,0xff,0x3c,0x0d,0x7f,0x00,
+0x27,0x8e,0x90,0x00,0x01,0x80,0x78,0x21,0x00,0x12,0x30,0xc0,0x00,0xd2,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa3,0x00,0x2c,
+0x8f,0xa4,0x00,0x30,0xaf,0xa2,0x00,0x44,0x8f,0xa5,0x00,0x44,0x30,0x49,0x00,0x03,
+0x02,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x00,0xa2,0x10,0x21,0x8f,0xa8,0x00,0x30,
+0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff,0x00,0x64,0x38,0x21,0x01,0x02,0x28,0x23,
+0x00,0x62,0x18,0x21,0x00,0x48,0x10,0x2b,0x10,0x40,0x00,0x52,0x00,0x00,0x20,0x21,
+0x30,0xe7,0xff,0xff,0x30,0xa4,0xff,0xff,0xaf,0xa7,0x00,0x2c,0x00,0xd2,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x51,0x18,0x21,0x8c,0x65,0x00,0x18,0x00,0x04,0x25,0x40,
+0x00,0x8d,0x20,0x24,0x8c,0xa8,0x00,0x04,0x00,0x4e,0x18,0x21,0x00,0x4f,0x50,0x21,
+0x01,0x0b,0x40,0x24,0x01,0x04,0x40,0x25,0xac,0xa8,0x00,0x04,0x8f,0xa4,0x00,0x98,
+0x8f,0xa2,0x00,0x50,0x26,0xb5,0x00,0x01,0xa0,0x64,0x00,0x00,0x8c,0xa4,0x00,0x08,
+0x00,0x00,0x00,0x00,0x04,0x81,0x00,0x0c,0x02,0xa2,0x30,0x2a,0x80,0x62,0x00,0x06,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0xa2,0x38,0x21,0x8f,0xa5,0x00,0x40,
+0x00,0x00,0x00,0x00,0xa4,0xe5,0x00,0x00,0x95,0x52,0x00,0x02,0x14,0xc0,0xff,0xc7,
+0x00,0x12,0x30,0xc0,0x8f,0xa4,0x00,0x24,0x8f,0xa5,0x00,0x50,0x8f,0xa6,0x00,0x1c,
+0x8f,0xa3,0x00,0x2c,0x00,0x85,0x80,0x21,0xa0,0xd0,0x00,0x12,0x00,0x09,0x10,0x23,
+0x30,0x42,0x00,0x03,0x8f,0xa8,0x00,0x88,0x00,0x62,0x10,0x23,0xa4,0xc2,0x00,0x1a,
+0x85,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x80,0x27,0x83,0x8f,0xf4,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,
+0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,
+0x14,0x60,0xff,0x74,0x02,0x00,0x10,0x21,0x8f,0xa3,0x00,0x54,0x8f,0xa4,0x00,0x18,
+0x8f,0xa5,0x00,0x24,0x00,0x64,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x08,
+0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x10,0xa0,0x00,0x03,0x00,0x00,0x30,0x21,
+0x08,0x00,0x1d,0x51,0x02,0x00,0x10,0x21,0x93,0x82,0x80,0x10,0x00,0x00,0x28,0x21,
+0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0xf5,0xaf,0xa2,0x00,0x10,0x08,0x00,0x1d,0x51,
+0x02,0x00,0x10,0x21,0x30,0x63,0xff,0xff,0x08,0x00,0x1d,0xa3,0xaf,0xa3,0x00,0x2c,
+0x8f,0xa8,0x00,0x44,0x08,0x00,0x1d,0xc5,0x31,0x09,0x00,0x03,0x08,0x00,0x1d,0x7e,
+0xaf,0xa3,0x00,0x50,0x8f,0xa6,0x00,0x44,0xaf,0xa0,0x00,0x50,0x08,0x00,0x1d,0xc5,
+0x30,0xc9,0x00,0x03,0x8f,0xa5,0x00,0x48,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,
+0x03,0xc0,0x38,0x21,0x0c,0x00,0x1b,0xf6,0xaf,0xb7,0x00,0x10,0x08,0x00,0x1d,0x2e,
+0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80,0x27,0x82,0x8f,0xf0,0x00,0xa2,0x28,0x21,
+0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x4b,0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0x27,
+0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80,0x27,0x83,0x90,0x00,0x8f,0xa4,0x00,0x1c,
+0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01,0x02,0x40,0x28,0x21,0x0c,0x00,0x1f,0x08,
+0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x13,0x00,0x00,0x00,0x00,0x16,0xe0,0x00,0x4d,
+0x03,0xc0,0x38,0x21,0x8f,0xa4,0x00,0x24,0x8f,0xa5,0x00,0x20,0x24,0x02,0x00,0x01,
+0x24,0x84,0x00,0x01,0xaf,0xb2,0x00,0x48,0xaf,0xb6,0x00,0x4c,0x02,0xc0,0xf0,0x21,
+0x10,0xa2,0x00,0x41,0xaf,0xa4,0x00,0x24,0x27,0x82,0x8f,0xf0,0x02,0x02,0x10,0x21,
+0x94,0x42,0x00,0x06,0x8f,0xa4,0x00,0x30,0xaf,0xa0,0x00,0x20,0xaf,0xa2,0x00,0x44,
+0x30,0x49,0x00,0x03,0x8f,0xa8,0x00,0x44,0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,
+0x01,0x02,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff,0x00,0x44,0x18,0x2b,
+0x10,0x60,0x00,0x2b,0x00,0x00,0x00,0x00,0x8f,0xa5,0x00,0x2c,0x00,0x82,0x10,0x23,
+0x00,0xa4,0x18,0x21,0x30,0x63,0xff,0xff,0x30,0x44,0xff,0xff,0xaf,0xa3,0x00,0x2c,
+0x02,0x92,0x28,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x8f,0xf4,0x00,0xa2,0x10,0x21,
+0x8c,0x46,0x00,0x18,0x3c,0x03,0x80,0xff,0x3c,0x02,0x7f,0x00,0x8c,0xc8,0x00,0x04,
+0x00,0x04,0x25,0x40,0x34,0x63,0xff,0xff,0x00,0x82,0x20,0x24,0x01,0x03,0x40,0x24,
+0x01,0x04,0x40,0x25,0xac,0xc8,0x00,0x04,0x8f,0xa8,0x00,0x98,0x27,0x82,0x90,0x00,
+0x00,0xa2,0x10,0x21,0xa0,0x48,0x00,0x00,0x8c,0xc4,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0x04,0x27,0xc2,0x10,0x80,0xfe,0xdb,0xaf,0xa4,0x00,0x3c,0x80,0x42,0x00,0x06,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0xc2,0x38,0x21,0x8f,0xa2,0x00,0x40,
+0x00,0x00,0x00,0x00,0xa4,0xe2,0x00,0x00,0x08,0x00,0x1d,0x2a,0x26,0xb5,0xff,0xff,
+0x8f,0xa6,0x00,0x2c,0x00,0x00,0x20,0x21,0x00,0xc2,0x10,0x21,0x30,0x42,0xff,0xff,
+0x08,0x00,0x1e,0x38,0xaf,0xa2,0x00,0x2c,0x8f,0xa6,0x00,0x1c,0x08,0x00,0x1e,0x22,
+0xa4,0xd2,0x00,0x14,0x8f,0xa5,0x00,0x48,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,
+0x0c,0x00,0x1b,0xf6,0xaf,0xb7,0x00,0x10,0x08,0x00,0x1e,0x19,0x00,0x00,0xb8,0x21,
+0x0c,0x00,0x12,0x87,0x00,0x00,0x28,0x21,0x00,0x40,0x18,0x21,0x94,0x42,0x00,0x00,
+0x00,0x00,0x00,0x00,0x34,0x42,0x08,0x00,0xa4,0x62,0x00,0x00,0x08,0x00,0x1d,0x1e,
+0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21,0x00,0x03,0x80,0x80,0x27,0x82,0x8f,0xf4,
+0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,
+0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x10,0x60,0x00,0x09,0x24,0x06,0x00,0x01,
+0x93,0x82,0x8b,0x61,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x10,0x40,0xfe,0xa2,
+0x3c,0x04,0x00,0x80,0x27,0x85,0x8f,0xf0,0x08,0x00,0x1e,0x09,0x02,0x05,0x28,0x21,
+0x27,0x83,0x90,0x08,0x27,0x82,0x90,0x00,0x02,0x03,0x18,0x21,0x02,0x02,0x10,0x21,
+0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05,0x93,0x83,0x80,0x10,0x00,0x00,0x38,0x21,
+0x0c,0x00,0x21,0xf5,0xaf,0xa3,0x00,0x10,0x08,0x00,0x1e,0x80,0x00,0x00,0x00,0x00,
+0x27,0x82,0x90,0x08,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x02,0x8f,0xa6,0x00,0x58,
+0x00,0x03,0x19,0x02,0x00,0x66,0x18,0x23,0x30,0x63,0x0f,0xff,0x28,0x62,0x00,0x20,
+0x10,0x40,0x00,0x06,0x28,0x62,0x00,0x40,0x8f,0xa8,0x00,0x90,0x00,0x00,0x00,0x00,
+0x00,0x68,0x10,0x06,0x08,0x00,0x1c,0xf7,0x30,0x44,0x00,0x01,0x10,0x40,0x00,0x04,
+0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x94,0x08,0x00,0x1e,0xa1,0x00,0x64,0x10,0x06,
+0x08,0x00,0x1c,0xf7,0x00,0x00,0x20,0x21,0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,
+0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x06,0xaf,0xa8,0x00,0x14,0x30,0x42,0xff,0xff,
+0x08,0x00,0x1c,0xc7,0xaf,0xa2,0x00,0x40,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,
+0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20,0x24,0x63,0x7a,0xc8,0xaf,0xb1,0x00,0x14,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,
+0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45,0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,
+0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c,0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,
+0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,
+0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,
+0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,
+0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,
+0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00,0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,
+0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01,0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,
+0x08,0x00,0x1e,0xdc,0xa6,0x03,0x00,0x14,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,
+0x27,0x86,0x8f,0xf0,0x00,0x04,0x10,0xc0,0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,
+0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,
+0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x0c,0x00,0x12,0x78,
+0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff,0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,
+0x96,0x02,0x00,0x06,0x08,0x00,0x1e,0xdc,0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,
+0x08,0x00,0x1e,0xdc,0xa6,0x02,0x00,0x14,0x96,0x05,0x00,0x00,0x0c,0x00,0x1f,0x08,
+0x02,0x00,0x20,0x21,0x08,0x00,0x1e,0xc3,0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,
+0x0c,0x00,0x1f,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x1e,0xbf,0x00,0x40,0x88,0x21,
+0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x7c,0x20,
+0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00,0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,
+0x24,0x42,0x7c,0x44,0xac,0x62,0x00,0x00,0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,
+0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21,0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00,0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,
+0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00,0x94,0xc8,0x00,0x00,0x27,0x83,0x8f,0xf0,
+0x93,0x85,0x8b,0x60,0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08,0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,
+0x01,0x44,0x18,0x23,0x8f,0x82,0x8b,0x78,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,
+0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,
+0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21,0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,
+0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08,0x08,0x00,0x1f,0x34,0xa4,0xc2,0x00,0x14,
+0x08,0x00,0x1f,0x34,0x00,0x00,0x18,0x21,0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,
+0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,
+0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,
+0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,
+0x24,0x42,0x7c,0xf8,0x02,0xb1,0x48,0x21,0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,
+0x24,0x03,0x00,0x01,0x27,0x82,0x90,0x00,0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,
+0x27,0x84,0x8f,0xf4,0x01,0x24,0x20,0x21,0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,
+0x27,0x83,0x90,0x10,0x01,0x23,0x48,0x21,0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,
+0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04,0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,
+0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2,0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,
+0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40,0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,
+0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21,0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,
+0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21,0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,
+0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21,0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,
+0x27,0x90,0x8f,0xf0,0x02,0x30,0x80,0x21,0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,
+0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21,0xa6,0x83,0x00,0x1a,0x27,0x82,0x8f,0xf8,
+0x0c,0x00,0x08,0xdf,0x02,0x22,0x88,0x21,0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,
+0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,
+0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,
+0xaf,0xa9,0x00,0x10,0x0c,0x00,0x09,0x06,0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0x72,
+0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0,0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,
+0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,
+0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28,0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,
+0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03,0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,
+0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21,0x3c,0x02,0x80,0x00,0x00,0x03,0x48,0x80,
+0x24,0x42,0x7e,0x34,0x00,0x80,0x98,0x21,0x27,0x84,0x90,0x00,0x01,0x24,0x20,0x21,
+0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00,0x80,0x83,0x00,0x06,0x27,0x82,0x8f,0xf4,
+0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,
+0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,
+0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10,0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,
+0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21,0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,
+0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21,0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,
+0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21,0x27,0x83,0x90,0x08,0x01,0x23,0x18,0x21,
+0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x60,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,
+0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,
+0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80,0x24,0x04,0x00,0x01,0x27,0x83,0x90,0x10,
+0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,
+0x02,0xa0,0x20,0x21,0x27,0x82,0x8f,0xf0,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,
+0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a,0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,
+0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,
+0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x06,0xaf,0xa0,0x00,0x14,
+0x08,0x00,0x1f,0xd9,0x00,0x00,0x00,0x00,0x27,0x83,0x90,0x10,0x01,0x23,0x18,0x21,
+0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,
+0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf,0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,
+0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d,0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,
+0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21,0x27,0x82,0x80,0x1c,0x00,0x15,0x18,0x40,
+0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00,0x24,0xa2,0x00,0x06,0x00,0x54,0x10,0x04,
+0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,
+0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,
+0x27,0x83,0x90,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,
+0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,
+0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f,0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,
+0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20,0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,
+0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,
+0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x08,0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,
+0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef,0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,
+0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,
+0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xf3,0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x04,
+0x24,0x03,0x00,0x02,0x00,0x62,0x70,0x0a,0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,
+0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d,0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,
+0x27,0x99,0x8f,0xf0,0x01,0xf2,0xc0,0x23,0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,
+0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04,0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,
+0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21,0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,
+0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23,0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,
+0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff,0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,
+0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23,0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,
+0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40,0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,
+0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00,0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,
+0x00,0x02,0x30,0x80,0x27,0x82,0x8f,0xf4,0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,
+0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x40,0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,
+0x00,0x83,0x20,0x24,0x27,0x83,0x90,0x00,0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,
+0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04,0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,
+0xa0,0xb5,0x00,0x03,0x27,0x84,0x90,0x10,0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,
+0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2,0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,
+0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a,0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,
+0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,
+0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40,0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,
+0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01,0x27,0x84,0x8f,0xf0,0x00,0xc4,0x18,0x21,
+0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02,0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,
+0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23,0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,
+0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0,0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,
+0x02,0x03,0x80,0x21,0x27,0x82,0x8f,0xf8,0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,
+0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21,0x01,0x60,0x88,0x21,0x0c,0x00,0x08,0xdf,
+0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21,0xa6,0x02,0x00,0x04,0x08,0x00,0x1f,0xdf,
+0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b,0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,
+0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6,0x01,0x71,0x18,0x21,0x08,0x00,0x20,0x55,
+0x25,0x22,0x00,0x01,0x08,0x00,0x20,0x84,0x32,0xcc,0x00,0x03,0x08,0x00,0x20,0x84,
+0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,
+0x0c,0x00,0x09,0x06,0xaf,0xb4,0x00,0x14,0x92,0x67,0x00,0x04,0x08,0x00,0x1f,0xf7,
+0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff,0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,
+0x00,0x04,0x20,0x80,0x27,0x82,0x8f,0xf0,0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,
+0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21,0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,
+0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,
+0x27,0x88,0x8f,0xf0,0x00,0x06,0x30,0x80,0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,
+0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21,0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,
+0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20,0x24,0x42,0x82,0xe4,0xac,0xe2,0x00,0x00,
+0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0x83,0x40,
+0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x10,0x3c,0x08,0xb0,0x03,0x3c,0x09,0xb0,0x06,
+0x27,0x87,0x8f,0xf0,0x3c,0x0d,0xb0,0x08,0x34,0x0e,0xff,0xff,0x35,0x08,0x00,0x62,
+0x00,0x80,0x30,0x21,0x24,0x0c,0xff,0xff,0x10,0x40,0x00,0x2c,0x35,0x29,0x80,0x20,
+0x97,0x82,0x8f,0xe0,0x94,0x85,0x00,0x0c,0x3c,0x0b,0xb0,0x03,0x00,0x02,0x18,0xc0,
+0x00,0x62,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0xa4,0x45,0x00,0x00,
+0x94,0x84,0x00,0x0e,0x00,0x6d,0x18,0x21,0xac,0x65,0x00,0x00,0x00,0x04,0x10,0xc0,
+0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x94,0x45,0x00,0x04,
+0x3c,0x0a,0x77,0x77,0x35,0x6b,0x00,0xb4,0x00,0x05,0x10,0xc0,0x00,0x45,0x18,0x21,
+0x00,0x03,0x18,0x80,0x00,0x67,0x18,0x21,0x00,0x4d,0x10,0x21,0xac,0x4e,0x00,0x00,
+0xa4,0x6e,0x00,0x00,0x95,0x04,0x00,0x00,0x90,0xc3,0x00,0x10,0x24,0x02,0x00,0xff,
+0x00,0x44,0x10,0x23,0x00,0x43,0x10,0x2a,0xa7,0x85,0x8f,0xe0,0x10,0x40,0x00,0x04,
+0x35,0x4a,0x88,0x88,0xad,0x6a,0x00,0x00,0x90,0xc3,0x00,0x10,0x00,0x00,0x00,0x00,
+0x30,0x63,0x00,0xff,0x3c,0x02,0x00,0x40,0x00,0x62,0x18,0x25,0xad,0x23,0x00,0x00,
+0xa4,0xcc,0x00,0x0e,0xa4,0xcc,0x00,0x0c,0xa0,0xc0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,
+0x27,0x89,0x8f,0xf0,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21,0x97,0x83,0x8f,0xe0,
+0x94,0x4a,0x00,0x04,0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0,0x00,0x0a,0x40,0xc0,
+0x00,0xe3,0x18,0x21,0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21,0x01,0x02,0x40,0x21,
+0x00,0x03,0x18,0x80,0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x01,
+0x00,0xa9,0x28,0x21,0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20,0x34,0x09,0xff,0xff,
+0x24,0x42,0x84,0x34,0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00,0xac,0xe4,0x00,0x00,
+0xa4,0xa9,0x00,0x00,0xad,0x09,0x00,0x00,0xa7,0x8a,0x8f,0xe0,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,
+0x24,0x42,0x84,0xb4,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x01,0x10,
+0x8c,0x82,0x00,0x00,0x97,0x83,0x81,0x60,0x30,0x42,0xff,0xff,0x10,0x62,0x00,0x16,
+0x24,0x0a,0x00,0x01,0xa7,0x82,0x81,0x60,0xaf,0x80,0xb4,0x40,0x00,0x40,0x28,0x21,
+0x24,0x06,0x00,0x01,0x27,0x84,0xb4,0x44,0x25,0x43,0xff,0xff,0x00,0x66,0x10,0x04,
+0x00,0xa2,0x10,0x24,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x8c,0x83,0xff,0xfc,
+0x00,0x00,0x00,0x00,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x38,0x42,0x00,0x00,
+0x01,0x42,0x18,0x0a,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14,0xac,0x83,0x00,0x00,
+0x14,0x40,0xff,0xf1,0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03,0x00,0x00,0x50,0x21,
+0x3c,0x0c,0x80,0x00,0x27,0x89,0xb4,0x90,0x35,0x6b,0x01,0x20,0x8d,0x68,0x00,0x00,
+0x8d,0x23,0x00,0x04,0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2,0x11,0x03,0x00,0x37,
+0xa1,0x22,0x00,0xdc,0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6,0x01,0x20,0x30,0x21,
+0x00,0x00,0x38,0x21,0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21,0x00,0xa8,0x10,0x06,
+0x30,0x42,0x00,0x01,0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a,0x90,0x82,0x00,0x07,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff,0xa0,0x82,0x00,0x08,
+0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09,0x00,0x00,0x00,0x00,
+0x90,0x83,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40,0x00,0x43,0x10,0x21,
+0x00,0x46,0x10,0x21,0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04,0x00,0x00,0x00,0x00,
+0xa0,0xc5,0x00,0xd5,0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08,0xa0,0xc5,0x00,0xd6,
+0x24,0xa5,0x00,0x01,0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0,0x24,0x84,0x00,0x03,
+0x90,0xc4,0x00,0xd5,0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b,0x10,0x40,0x00,0x0b,
+0x00,0x00,0x00,0x00,0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08,0x90,0xc2,0x00,0xd5,
+0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5,0x00,0x00,0x00,0x00,
+0x00,0xa4,0x10,0x2b,0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03,0x25,0x4a,0x00,0x01,
+0x2d,0x42,0x00,0x08,0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04,0x14,0x40,0xff,0xbf,
+0x25,0x29,0x00,0xec,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x05,
+0x08,0x00,0x21,0x68,0xa0,0x82,0x00,0x08,0x97,0x85,0x8b,0x6a,0x3c,0x03,0xb0,0x03,
+0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,0x24,0x42,0x86,0x68,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00,0x30,0x90,0x00,0xff,
+0x00,0x05,0x28,0x42,0x00,0x00,0x48,0x21,0x27,0x8f,0xb4,0x94,0x00,0x00,0x50,0x21,
+0x00,0x00,0x58,0x21,0x27,0x98,0xb5,0x74,0x27,0x99,0xb5,0x70,0x27,0x8e,0xb5,0x6e,
+0x27,0x8c,0xb4,0x98,0x27,0x8d,0xb4,0xf0,0x27,0x88,0xb5,0x68,0x00,0x0a,0x18,0x80,
+0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x45,0x00,0x58,0x00,0x6e,0x20,0x21,
+0x00,0x78,0x10,0x21,0xa1,0x00,0xff,0xfc,0xad,0x00,0x00,0x00,0xa1,0x00,0x00,0x04,
+0xa1,0x00,0x00,0x05,0xad,0x00,0xff,0xf8,0x00,0x79,0x18,0x21,0x24,0x06,0x00,0x01,
+0x24,0xc6,0xff,0xff,0xa0,0x80,0x00,0x00,0xa4,0x60,0x00,0x00,0xac,0x40,0x00,0x00,
+0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9,0x24,0x84,0x00,0x01,
+0x00,0x0a,0x10,0x80,0x00,0x4d,0x20,0x21,0x00,0x00,0x30,0x21,0x00,0x4c,0x18,0x21,
+0x27,0x87,0x81,0x64,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04,0xac,0x82,0x00,0x00,
+0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01,0x28,0xc2,0x00,0x1c,
+0xa0,0x60,0x00,0x02,0x24,0x84,0x00,0x04,0x14,0x40,0xff,0xf6,0x24,0x63,0x00,0x03,
+0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x08,0x25,0x4a,0x00,0x3b,0x25,0x08,0x00,0xec,
+0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x81,0x60,0x00,0x00,0x48,0x21,
+0x27,0x83,0xb4,0x40,0xac,0x69,0x00,0x00,0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x0c,
+0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x21,0x2d,0x00,0x00,0x00,0x00,
+0x2e,0x04,0x00,0x14,0x27,0x83,0xb4,0x90,0x24,0x09,0x00,0x07,0x10,0x80,0x00,0x0a,
+0x00,0x00,0x00,0x00,0x90,0x62,0x00,0xd5,0x25,0x29,0xff,0xff,0xa0,0x62,0x00,0x00,
+0x05,0x21,0xff,0xfa,0x24,0x63,0x00,0xec,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x90,0x62,0x00,0xd6,0x08,0x00,0x21,0xeb,
+0x25,0x29,0xff,0xff,0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,
+0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xb4,0x90,
+0x00,0x43,0x60,0x21,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x84,0x00,0x20,
+0x24,0x42,0x87,0xd4,0x30,0xc6,0x00,0xff,0x93,0xa9,0x00,0x13,0x30,0xa5,0x00,0xff,
+0x30,0xe7,0x00,0xff,0xac,0x82,0x00,0x00,0x10,0xc0,0x00,0xeb,0x25,0x8f,0x00,0xd0,
+0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xfc,0x2c,0x43,0x00,0x18,
+0x10,0x60,0x00,0xcf,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80,0x24,0x63,0x02,0x5c,
+0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,
+0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x2d,0x10,0x40,0x00,0x14,0x00,0x00,0x00,0x00,
+0x10,0xa0,0x00,0x0f,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x09,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,
+0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xd0,0x03,0xe0,0x00,0x08,
+0xad,0x82,0x00,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,0x24,0x42,0xff,0xe0,
+0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,0x24,0x42,0x00,0x01,0x10,0xa0,0x00,0x0f,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xf9,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x07,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,
+0x14,0xa2,0xff,0xf0,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,
+0x24,0x42,0xff,0xe8,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,
+0x08,0x00,0x22,0x23,0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xfc,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0xa2,0xff,0xf4,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xef,0x00,0x00,0x00,0x00,
+0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,0x24,0x42,0xff,0xf8,0x2d,0x22,0x00,0x19,
+0x14,0x40,0xff,0xde,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xec,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0xa2,0xff,0xe4,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,
+0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,0x24,0x42,0xff,0xf0,0x2d,0x22,0x00,0x1b,
+0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdc,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc6,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x14,0xa2,0xff,0xce,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,
+0x24,0x42,0xff,0xf4,0x2d,0x22,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,
+0x10,0xa0,0xff,0xce,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc9,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x34,
+0x24,0x02,0x00,0x03,0x2d,0x22,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,
+0x10,0xa0,0xff,0xaf,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xbd,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xda,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,
+0x14,0xa2,0xff,0x9f,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x25,0x00,0x00,0x00,0x00,
+0x2d,0x22,0x00,0x25,0x10,0x40,0xff,0xc8,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa0,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x97,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x80,
+0x24,0x02,0x00,0x03,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,0x24,0x42,0xff,0xfc,
+0x2d,0x22,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa3,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x9b,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xa8,
+0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0x23,0x24,0x42,0xff,0xfa,
+0x10,0xa0,0xff,0x96,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x80,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x8e,0x00,0x00,0x00,0x00,
+0x08,0x00,0x22,0x48,0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x17,0x14,0x40,0xff,0x9e,
+0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x97,0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x19,
+0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x84,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6e,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0xa2,0xff,0x7c,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x89,0x00,0x00,0x00,0x00,
+0x08,0x00,0x22,0x25,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xb4,0x2d,0x22,0x00,0x1b,
+0x2d,0x22,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x73,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5d,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x6b,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x88,
+0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x25,0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x23,
+0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x4e,0x00,0x00,0x00,0x00,
+0x08,0x00,0x22,0x4c,0x2d,0x22,0x00,0x25,0x08,0x00,0x22,0x85,0x2d,0x22,0x00,0x27,
+0x10,0xa0,0xff,0x5e,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x48,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x56,0x24,0x02,0x00,0x03,
+0x14,0xa2,0xff,0x63,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x91,0x00,0x00,0x00,0x00,
+0x2d,0x22,0x00,0x27,0x14,0x40,0xff,0x8e,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x3e,
+0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x29,0x14,0x40,0xff,0x89,0x00,0x00,0x00,0x00,
+0x08,0x00,0x22,0x2b,0x00,0x00,0x00,0x00,0x91,0x86,0x00,0x00,0x91,0x83,0x00,0xd4,
+0x25,0x8d,0x00,0x5c,0x30,0xc4,0x00,0xff,0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,
+0x00,0x04,0x50,0x80,0x01,0x82,0x58,0x21,0x01,0x8a,0x40,0x21,0x25,0x78,0x00,0x08,
+0x10,0x60,0x00,0x37,0x25,0x0e,0x00,0x60,0x2c,0xa2,0x00,0x03,0x14,0x40,0x00,0x25,
+0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,
+0x00,0x00,0x00,0x00,0x27,0x87,0x81,0x64,0x01,0x47,0x10,0x21,0x8c,0x43,0x00,0x00,
+0x00,0x00,0x00,0x00,0xad,0x03,0x00,0x60,0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,
+0x00,0x40,0x30,0x21,0xa1,0x82,0x00,0x00,0x30,0xc2,0x00,0xff,0x00,0x02,0x10,0x80,
+0x00,0x47,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,
+0xad,0xa3,0x00,0x00,0x91,0x84,0x00,0x00,0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,
+0x00,0x87,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x05,0x28,0x40,0x00,0x8c,0x20,0x21,
+0x00,0x03,0x18,0x80,0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0xac,0x85,0x00,0x60,
+0x03,0xe0,0x00,0x08,0xa1,0x80,0x00,0xd4,0x27,0x87,0x81,0x64,0x08,0x00,0x23,0x0e,
+0xa1,0x80,0x00,0xdd,0x27,0x82,0x81,0xd4,0x8d,0x83,0x00,0xd8,0x00,0x82,0x10,0x21,
+0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01,0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0x0d,
+0xad,0x83,0x00,0xd8,0x8d,0x02,0x00,0x60,0xa1,0x80,0x00,0xd4,0x00,0x02,0x1f,0xc2,
+0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x03,0xe0,0x00,0x08,0xad,0x82,0x00,0x5c,
+0x10,0xe0,0x00,0x1a,0x24,0x83,0xff,0xfc,0x2c,0x62,0x00,0x18,0x10,0x40,0x01,0x18,
+0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01,0x24,0x63,0x02,0xbc,0x00,0x43,0x10,0x21,
+0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,
+0x2d,0x22,0x00,0x2d,0x10,0x40,0x00,0x5f,0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x5a,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x54,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x51,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,
+0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xd0,0xad,0x82,0x00,0xd0,0x8d,0xe3,0x00,0x00,
+0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xad,0xa2,0x00,0x00,
+0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,0x8d,0xc4,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00,0x93,0x05,0x00,0x01,
+0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05,0x24,0x02,0x00,0x01,
+0xa1,0x85,0x00,0x00,0xa1,0x82,0x00,0xd4,0x03,0xe0,0x00,0x08,0xad,0x80,0x00,0xd8,
+0x91,0x82,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05,0x00,0x00,0x00,0x00,
+0xa1,0x83,0x00,0xd4,0xad,0x80,0x00,0xd8,0x03,0xe0,0x00,0x08,0xa1,0x83,0x00,0xdd,
+0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43,0xad,0xa2,0x00,0x00,
+0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64,0x8d,0xc5,0x00,0x00,0x00,0x03,0x18,0x80,
+0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40,0x00,0x04,0x18,0x80,
+0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0x08,0x00,0x23,0x20,0xad,0xc5,0x00,0x00,
+0x97,0x82,0x8b,0x6c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a,0x10,0x40,0xfe,0xb9,
+0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x15,
+0x00,0x00,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64,0x00,0x03,0x18,0x80,
+0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x6c,0x18,0x21,0xac,0x64,0x00,0x60,
+0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80,0x01,0x82,0x10,0x21,
+0x24,0x4e,0x00,0x60,0xa1,0x85,0x00,0x00,0x8d,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x03,0xe0,0x00,0x08,
+0xad,0xa2,0x00,0x00,0x08,0x00,0x23,0x92,0xa1,0x80,0x00,0xdd,0x8d,0x82,0x00,0xd0,
+0x08,0x00,0x23,0x4e,0x24,0x42,0xff,0xe0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,
+0x24,0x42,0x00,0x01,0x10,0xa0,0x00,0x0d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,
+0x10,0xa2,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xa7,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xf0,0x00,0x00,0x00,0x00,
+0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,0x24,0x42,0xff,0xe8,0x8d,0x82,0x00,0xd0,
+0x08,0x00,0x23,0x4e,0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xfc,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe8,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0xa2,0xff,0x96,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,
+0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,0x24,0x42,0xff,0xf8,0x2d,0x22,0x00,0x19,
+0x14,0x40,0xff,0xe0,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xec,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd8,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0xa2,0xff,0x86,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,
+0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,0x24,0x42,0xff,0xf0,0x2d,0x22,0x00,0x1b,
+0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdc,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc8,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x14,0xa2,0xff,0xd0,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,
+0x24,0x42,0xff,0xf4,0x2d,0x22,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,
+0x10,0xa0,0xff,0xce,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6b,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xaa,
+0x24,0x02,0x00,0x03,0x2d,0x22,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,
+0x10,0xa0,0xff,0xb1,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5f,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xda,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,
+0x14,0xa2,0xff,0x56,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x9b,0x00,0x00,0x00,0x00,
+0x2d,0x22,0x00,0x25,0x10,0x40,0xff,0xc8,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa2,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x99,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xf4,
+0x24,0x02,0x00,0x03,0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,0x24,0x42,0xff,0xfc,
+0x2d,0x22,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa3,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8f,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x3d,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xa8,
+0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x23,0x4e,0x24,0x42,0xff,0xfa,
+0x10,0xa0,0xff,0x96,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x82,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x30,0x00,0x00,0x00,0x00,
+0x08,0x00,0x23,0xbc,0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x17,0x14,0x40,0xff,0x9e,
+0x00,0x00,0x00,0x00,0x08,0x00,0x24,0x0b,0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x19,
+0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x84,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0xa2,0xff,0x1e,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x89,0x00,0x00,0x00,0x00,
+0x08,0x00,0x23,0x9b,0x00,0x00,0x00,0x00,0x08,0x00,0x24,0x28,0x2d,0x22,0x00,0x1b,
+0x2d,0x22,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x73,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5f,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x0d,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x88,
+0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x9b,0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x23,
+0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xc2,0x00,0x00,0x00,0x00,
+0x08,0x00,0x23,0xc0,0x2d,0x22,0x00,0x25,0x08,0x00,0x23,0xf9,0x2d,0x22,0x00,0x27,
+0x10,0xa0,0xff,0x5e,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x4a,
+0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xfe,0xf8,0x24,0x02,0x00,0x03,
+0x14,0xa2,0xff,0x63,0x00,0x00,0x00,0x00,0x08,0x00,0x24,0x05,0x00,0x00,0x00,0x00,
+0x2d,0x22,0x00,0x27,0x14,0x40,0xff,0x8e,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xb2,
+0x00,0x00,0x00,0x00,0x2d,0x22,0x00,0x29,0x14,0x40,0xff,0x89,0x00,0x00,0x00,0x00,
+0x08,0x00,0x23,0xa1,0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,
+0xaf,0xbf,0x00,0x14,0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x3c,0x03,0xb0,0x03,
+0x8c,0x50,0x00,0x00,0x34,0x63,0x01,0x2c,0x90,0x62,0x00,0x00,0x32,0x05,0x00,0x01,
+0xa3,0x82,0x80,0x10,0x14,0xa0,0x00,0x14,0x30,0x44,0x00,0xff,0x32,0x02,0x01,0x00,
+0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x10,0x40,0x00,0x02,
+0x24,0x02,0x00,0x01,0xa3,0x82,0xbc,0x08,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x05,0x39,0x00,0x00,0x00,0x00,
+0x26,0x02,0xff,0x00,0xa3,0x80,0xbc,0x08,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,
+0x08,0x00,0x24,0x77,0x32,0x02,0x08,0x00,0x0c,0x00,0x21,0x9a,0x00,0x00,0x00,0x00,
+0x26,0x02,0xff,0xff,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x74,
+0x32,0x02,0x01,0x00,0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,
+0xaf,0xbf,0x00,0x18,0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,0x24,0x07,0x0f,0xff,
+0x00,0x03,0x33,0x02,0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,0x30,0x69,0x0f,0xff,
+0x00,0x62,0x18,0x24,0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,0x10,0x60,0x00,0x08,
+0x31,0x08,0x00,0xff,0x01,0x00,0x30,0x21,0x0c,0x00,0x25,0x38,0xaf,0xa9,0x00,0x10,
+0x8f,0xbf,0x00,0x18,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,
+0x0c,0x00,0x25,0x8a,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xd4,
+0x08,0x00,0x24,0xa0,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,0xaf,0xb6,0x00,0x30,
+0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x3c,
+0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,
+0xaf,0xb2,0x00,0x20,0x0c,0x00,0x17,0xc8,0x00,0x80,0x80,0x21,0x00,0x00,0xb0,0x21,
+0x00,0x00,0x88,0x21,0x10,0x40,0x00,0x12,0x00,0x00,0x98,0x21,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x24,0x05,0x00,0x01,0x34,0x42,0x00,0xbc,
+0x34,0x63,0x00,0xbb,0x34,0x84,0x00,0xba,0xa4,0x40,0x00,0x00,0xa0,0x65,0x00,0x00,
+0xa0,0x85,0x00,0x00,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,
+0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x47,0x90,0x44,0x00,0x00,0x00,0x10,0x1a,0x02,
+0x3c,0x15,0xfd,0xff,0x30,0x84,0x00,0xff,0xa0,0x50,0x00,0x00,0x30,0x74,0x00,0x0f,
+0xaf,0xa4,0x00,0x10,0x00,0x00,0x90,0x21,0x3c,0x17,0x02,0x00,0x36,0xb5,0xff,0xff,
+0x3c,0x1e,0xb0,0x03,0x0c,0x00,0x06,0xce,0x24,0x04,0x04,0x00,0x00,0x57,0x10,0x25,
+0x00,0x40,0x28,0x21,0x0c,0x00,0x06,0xc1,0x24,0x04,0x04,0x00,0x00,0x00,0x80,0x21,
+0x0c,0x00,0x26,0x52,0x00,0x00,0x00,0x00,0x26,0x03,0x00,0x01,0x30,0x70,0x00,0xff,
+0x10,0x40,0x00,0x47,0x2e,0x03,0x00,0x02,0x14,0x60,0xff,0xf9,0x00,0x00,0x00,0x00,
+0x0c,0x00,0x06,0xce,0x24,0x04,0x04,0x00,0x00,0x55,0x10,0x24,0x00,0x40,0x28,0x21,
+0x0c,0x00,0x06,0xc1,0x24,0x04,0x04,0x00,0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x38,
+0x00,0x00,0x00,0x00,0x12,0x80,0x00,0x36,0x00,0x00,0x00,0x00,0x32,0x22,0x00,0x60,
+0x32,0x23,0x0c,0x00,0x00,0x03,0x1a,0x02,0x3c,0x05,0x00,0x60,0x00,0x02,0x11,0x42,
+0x02,0x25,0x20,0x24,0x00,0x43,0x10,0x25,0x3c,0x03,0x04,0x00,0x02,0x23,0x28,0x24,
+0x00,0x04,0x24,0x42,0x00,0x44,0x10,0x25,0x00,0x05,0x2d,0x02,0x00,0x45,0x88,0x25,
+0x12,0x20,0x00,0x05,0x26,0x42,0x00,0x01,0x26,0xc2,0x00,0x01,0x30,0x56,0x00,0xff,
+0x02,0x71,0x98,0x21,0x26,0x42,0x00,0x01,0x02,0x5e,0x20,0x21,0x30,0x52,0x00,0xff,
+0x2e,0x43,0x00,0x05,0xa0,0x91,0x00,0xd8,0x14,0x60,0xff,0xce,0x3c,0x02,0xb0,0x03,
+0x8f,0xa5,0x00,0x10,0x34,0x42,0x01,0x47,0xa0,0x45,0x00,0x00,0x12,0x60,0x00,0x0e,
+0x3c,0x02,0xb0,0x03,0x12,0xc0,0x00,0x0d,0x34,0x42,0x00,0xbc,0x00,0x13,0x10,0x40,
+0x00,0x53,0x10,0x21,0x00,0x02,0x10,0xc0,0x00,0x53,0x10,0x21,0x00,0x02,0x98,0x80,
+0x02,0x76,0x00,0x1b,0x16,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,
+0x00,0x00,0x98,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xbc,0x3c,0x03,0xb0,0x03,
+0x3c,0x04,0xb0,0x03,0xa4,0x53,0x00,0x00,0x34,0x63,0x00,0xbb,0x34,0x84,0x00,0xba,
+0x24,0x02,0x00,0x01,0xa0,0x60,0x00,0x00,0x08,0x00,0x24,0xc5,0xa0,0x82,0x00,0x00,
+0x0c,0x00,0x06,0xce,0x24,0x04,0x04,0xfc,0x08,0x00,0x24,0xf3,0x00,0x40,0x88,0x21,
+0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xbc,0x3c,0x04,0xb0,0x03,0x3c,0x05,0xb0,0x03,
+0xa4,0x60,0x00,0x00,0x34,0x84,0x00,0xbb,0x34,0xa5,0x00,0xba,0x24,0x02,0x00,0x02,
+0x24,0x03,0x00,0x01,0xa0,0x82,0x00,0x00,0x08,0x00,0x24,0xc5,0xa0,0xa3,0x00,0x00,
+0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10,0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,
+0x30,0xb1,0x00,0xff,0x14,0x40,0x00,0x06,0x00,0x80,0x90,0x21,0x8f,0xbf,0x00,0x20,
+0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa0,0x24,0x06,0x01,0x07,
+0x12,0x60,0x00,0x38,0x02,0x00,0x30,0x21,0x8f,0xa2,0x00,0x38,0x30,0xc3,0x00,0x3f,
+0x3c,0x04,0xb0,0x09,0x00,0x02,0x14,0x00,0x00,0x43,0x30,0x25,0x34,0x84,0x01,0x60,
+0x90,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x24,0x02,0x00,0x01,
+0x12,0x22,0x00,0x2a,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x24,0x24,0x02,0x00,0x02,
+0x12,0x22,0x00,0x20,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x19,0x00,0x00,0x00,0x00,
+0x16,0x60,0xff,0xe2,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x13,0x2a,0x22,0x00,0x02,
+0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,
+0x16,0x22,0xff,0xda,0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,
+0x0c,0x00,0x13,0x5b,0x3c,0x06,0x0c,0xb8,0x08,0x00,0x25,0x43,0x00,0x00,0x00,0x00,
+0x08,0x00,0x25,0x6b,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xd0,0x00,0x00,0x00,0x00,
+0x08,0x00,0x25,0x6b,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x6b,0x24,0x04,0x08,0x44,
+0x24,0x04,0x08,0x4c,0x0c,0x00,0x13,0x5b,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x60,
+0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x79,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe0,
+0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x79,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x79,
+0x24,0x04,0x08,0x44,0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0xca,0x02,0x20,0x28,0x21,
+0x08,0x00,0x25,0x4e,0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,
+0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,
+0xaf,0xb3,0x00,0x1c,0x00,0xc0,0x80,0x21,0x30,0xb1,0x00,0xff,0x00,0x80,0x90,0x21,
+0x14,0x40,0x00,0x07,0x00,0x00,0x18,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,
+0x2e,0x13,0x00,0x10,0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa0,0x24,0x06,0x01,0x07,
+0x12,0x60,0x00,0x24,0x02,0x00,0x30,0x21,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x30,0xc5,0x00,0x3f,
+0x0c,0x00,0x26,0x07,0x02,0x20,0x20,0x21,0x16,0x60,0x00,0x0a,0x00,0x40,0x80,0x21,
+0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x15,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,
+0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x0b,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x03,
+0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x96,0x02,0x00,0x18,0x21,0x24,0x04,0x08,0x4c,
+0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5b,0x3c,0x06,0x0c,0xb8,0x08,0x00,0x25,0x96,
+0x02,0x00,0x18,0x21,0x08,0x00,0x25,0xb8,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xf5,
+0x00,0x00,0x00,0x00,0x08,0x00,0x25,0xb8,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0xb8,
+0x24,0x04,0x08,0x44,0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0xca,0x02,0x20,0x28,0x21,
+0x08,0x00,0x25,0xa2,0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xe8,0x2c,0xc2,0x00,0x1f,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0x00,0xc0,0x80,0x21,0x14,0x40,0x00,0x1d,
+0x30,0xa5,0x00,0xff,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x18,0x28,0xa2,0x00,0x02,
+0x14,0x40,0x00,0x12,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0e,0x24,0x02,0x00,0x03,
+0x10,0xa2,0x00,0x07,0x24,0x04,0x08,0x4c,0x26,0x10,0xff,0xe2,0x02,0x00,0x10,0x21,
+0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5b,0x3c,0x06,0x0d,0xf8,0x08,0x00,0x25,0xdb,
+0x26,0x10,0xff,0xe2,0x08,0x00,0x25,0xe0,0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf2,
+0x24,0x04,0x08,0x40,0x08,0x00,0x25,0xe1,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0xe0,
+0x24,0x04,0x08,0x44,0x2c,0xc2,0x00,0x10,0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x01,
+0x10,0xa2,0x00,0x14,0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x0e,0x24,0x02,0x00,0x02,
+0x10,0xa2,0x00,0x0a,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x03,0x24,0x04,0x08,0x4c,
+0x08,0x00,0x25,0xdb,0x26,0x10,0xff,0xf1,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5b,
+0x3c,0x06,0x0d,0xb8,0x08,0x00,0x25,0xdb,0x26,0x10,0xff,0xf1,0x08,0x00,0x25,0xfa,
+0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf6,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0xfb,
+0x24,0x05,0xff,0xff,0x08,0x00,0x25,0xfa,0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe8,
+0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x39,0xaf,0xbf,0x00,0x10,
+0x28,0x82,0x00,0x02,0x14,0x40,0x00,0x27,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,
+0x10,0x82,0x00,0x17,0x00,0xa0,0x30,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x05,
+0x24,0x04,0x08,0x3c,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x13,0x5b,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,
+0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5b,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x3c,
+0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x01,0x24,0x04,0x08,0xac,
+0x0c,0x00,0x13,0x3d,0x24,0x05,0x0f,0xff,0x08,0x00,0x26,0x15,0x00,0x00,0x00,0x00,
+0x24,0x04,0x08,0x34,0x0c,0x00,0x13,0x5b,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,
+0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5b,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x34,
+0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x01,0x08,0x00,0x26,0x24,
+0x24,0x04,0x08,0xa8,0x14,0x80,0xff,0xdf,0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x24,
+0x0c,0x00,0x13,0x5b,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,
+0x0c,0x00,0x13,0x5b,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,
+0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x01,0x08,0x00,0x26,0x24,0x24,0x04,0x08,0xa0,
+0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x2c,0x0c,0x00,0x13,0x5b,0x3c,0x05,0x3f,0x00,
+0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5b,0x00,0x00,0x30,0x21,
+0x24,0x04,0x08,0x2c,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5b,0x24,0x06,0x00,0x01,
+0x08,0x00,0x26,0x24,0x24,0x04,0x08,0xa4,0x3c,0x05,0x00,0x14,0x3c,0x02,0xb0,0x05,
+0x34,0x42,0x04,0x20,0x3c,0x06,0xc0,0x00,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,
+0x34,0xa5,0x17,0x09,0xac,0x45,0x00,0x00,0x34,0xc6,0x05,0x07,0x34,0x63,0x04,0x24,
+0x34,0x84,0x02,0x28,0x3c,0x07,0xb0,0x05,0x24,0x02,0x00,0x20,0xac,0x66,0x00,0x00,
+0x34,0xe7,0x04,0x50,0xa0,0x82,0x00,0x00,0x90,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x42,0x00,0x03,0x10,0x40,0xff,0xfc,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x93,0x85,0x81,0xf1,0x24,0x02,0x00,0x01,0x14,0xa2,0x00,0x51,
+0x00,0x80,0x40,0x21,0x8c,0x89,0x00,0x04,0x3c,0x03,0xb0,0x01,0x01,0x23,0x30,0x21,
+0x8c,0xc2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x08,0x10,0x45,0x00,0x59,
+0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38,0x24,0x03,0x00,0xb4,0x30,0x44,0x00,0xff,
+0x10,0x83,0x00,0x61,0x24,0x02,0x00,0xc4,0x10,0x82,0x00,0x54,0x24,0x02,0x00,0x94,
+0x10,0x82,0x00,0x45,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38,0x00,0x00,0x00,0x00,
+0x30,0x47,0xff,0xff,0x30,0xe3,0x40,0xff,0x24,0x02,0x40,0x88,0x14,0x62,0x00,0x39,
+0x30,0xe3,0x03,0x00,0x24,0x02,0x03,0x00,0x10,0x62,0x00,0x38,0x00,0x00,0x00,0x00,
+0x94,0xc2,0x00,0x56,0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,0x30,0xe2,0x00,0x80,
+0x14,0x40,0x00,0x30,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21,0x94,0xc3,0x00,0x60,
+0x24,0x02,0x00,0x08,0x14,0x43,0x00,0x3b,0x00,0x00,0x00,0x00,0x90,0xc2,0x00,0x62,
+0x24,0x03,0x00,0x04,0x00,0x02,0x39,0x02,0x10,0xe3,0x00,0x15,0x24,0x02,0x00,0x06,
+0x14,0xe2,0x00,0x34,0x00,0x00,0x00,0x00,0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x66,
+0x27,0x82,0x89,0x58,0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,
+0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,
+0x24,0x42,0x00,0x5e,0x24,0x03,0xc0,0x00,0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,
+0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,0x08,0x00,0x26,0xcd,0xad,0x07,0x00,0x10,
+0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x64,0x27,0x82,0x89,0x58,0x00,0x05,0x28,0x80,
+0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,
+0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x36,0x3c,0x03,0xff,0xff,
+0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,
+0xad,0x07,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x50,
+0x08,0x00,0x26,0x8b,0x30,0x47,0xff,0xff,0x8d,0x04,0x01,0xac,0x27,0x83,0x89,0x58,
+0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,
+0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x2e,0xac,0x82,0x00,0x00,0x24,0x03,0x00,0x2e,
+0xad,0x03,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x04,0x01,0xac,
+0x27,0x83,0x89,0x58,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,
+0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x0e,0x24,0x03,0x00,0x0e,
+0x08,0x00,0x26,0xcc,0xac,0x82,0x00,0x00,0x8d,0x04,0x01,0xac,0x27,0x83,0x89,0x58,
+0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,
+0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x14,0x24,0x03,0x00,0x14,0x08,0x00,0x26,0xcc,
+0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xc6,0x00,0xff,
+0x00,0x06,0x48,0x40,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x8b,0xbc,0x20,
+0x27,0x83,0xbc,0x26,0x00,0x4b,0x40,0x21,0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x00,
+0x30,0xa2,0x3f,0xff,0x10,0xe2,0x00,0x29,0x30,0x8a,0xff,0xff,0x95,0x02,0x00,0x02,
+0x24,0x03,0x00,0x01,0x00,0x02,0x11,0x82,0x30,0x42,0x00,0x01,0x10,0x43,0x00,0x18,
+0x00,0x00,0x00,0x00,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4b,0x30,0x21,
+0x94,0xc4,0x00,0x02,0x27,0x83,0xbc,0x26,0x27,0x85,0xbc,0x24,0x00,0x45,0x28,0x21,
+0x30,0x84,0xff,0xdf,0x00,0x43,0x10,0x21,0xa4,0xc4,0x00,0x02,0xa4,0x40,0x00,0x00,
+0xa4,0xa0,0x00,0x00,0x94,0xc3,0x00,0x02,0x3c,0x04,0xb0,0x01,0x01,0x44,0x20,0x21,
+0x30,0x63,0xff,0xbf,0xa4,0xc3,0x00,0x02,0xa0,0xc0,0x00,0x00,0x8c,0x82,0x00,0x04,
+0x24,0x03,0xf0,0xff,0x00,0x43,0x10,0x24,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x04,
+0x24,0x02,0xc0,0x00,0x91,0x04,0x00,0x01,0x00,0xa2,0x10,0x24,0x00,0x47,0x28,0x25,
+0x3c,0x03,0xb0,0x01,0x24,0x02,0x00,0x02,0x14,0x82,0xff,0xe2,0x01,0x43,0x18,0x21,
+0xac,0x65,0x00,0x00,0x08,0x00,0x26,0xfa,0x01,0x26,0x10,0x21,0x08,0x00,0x26,0xfa,
+0x01,0x26,0x10,0x21,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01,0x14,0x62,0x00,0x0d,
+0x3c,0x02,0xb0,0x01,0x8c,0x84,0x00,0x04,0x3c,0x06,0xb0,0x09,0x00,0x82,0x20,0x21,
+0x8c,0x85,0x00,0x08,0x8c,0x83,0x00,0x04,0x3c,0x02,0x01,0x00,0x34,0xc6,0x01,0x00,
+0x00,0x62,0x18,0x24,0x14,0x60,0x00,0x05,0x30,0xa5,0x20,0x00,0x24,0x02,0x00,0x06,
+0xa0,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x09,
+0x10,0xa0,0xff,0xfc,0x34,0x63,0x01,0x00,0x24,0x02,0x00,0x0e,0x08,0x00,0x27,0x2d,
+0xa0,0x62,0x00,0x00,0x3c,0x02,0xb0,0x01,0x30,0xa5,0xff,0xff,0x00,0xa2,0x28,0x21,
+0x8c,0xa3,0x00,0x00,0x3c,0x02,0x10,0x00,0x00,0x80,0x30,0x21,0x00,0x62,0x18,0x24,
+0x8c,0xa2,0x00,0x04,0x10,0x60,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x80,0x00,
+0x10,0x40,0x00,0x13,0x00,0x00,0x00,0x00,0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,
+0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,
+0x93,0x83,0x81,0xf0,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,
+0x24,0x63,0xff,0xff,0xac,0xc4,0x01,0xa8,0xa3,0x83,0x81,0xf0,0x8c,0xc4,0x01,0xac,
+0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x26,0x00,0x02,0x10,0x2b,
+0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,
+0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x04,
+0x00,0x00,0x00,0x00,0xa3,0x80,0x81,0xf1,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0xa3,0x82,0x81,0xf1,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa8,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x62,0x00,0xff,0x00,0x03,0x2e,0x02,0x00,0x02,0x39,0x80,0x2c,0xa2,0x00,0x02,
+0x00,0x03,0x34,0x02,0x10,0x40,0x00,0x05,0x00,0x03,0x1a,0x02,0xa4,0x87,0x01,0xd8,
+0xa0,0x85,0x01,0xd4,0xa0,0x86,0x01,0xd5,0xa0,0x83,0x01,0xd6,0x03,0xe0,0x00,0x08,
+0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x3c,0x05,0xb0,0x01,0x00,0x80,0x50,0x21,
+0x00,0x45,0x10,0x21,0x8c,0x43,0x00,0x04,0x24,0x02,0x00,0x05,0x00,0x03,0x1a,0x02,
+0x30,0x69,0x00,0x0f,0x11,0x22,0x00,0x0b,0x24,0x02,0x00,0x07,0x11,0x22,0x00,0x09,
+0x24,0x02,0x00,0x0a,0x11,0x22,0x00,0x07,0x24,0x02,0x00,0x0b,0x11,0x22,0x00,0x05,
+0x24,0x02,0x00,0x01,0x93,0x83,0x81,0xf0,0x3c,0x04,0xb0,0x06,0x10,0x62,0x00,0x03,
+0x34,0x84,0x80,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,
+0x8d,0x43,0x01,0xa8,0x27,0x82,0x89,0x58,0x00,0x03,0x18,0x80,0x00,0x6a,0x20,0x21,
+0x8c,0x87,0x00,0xa8,0x00,0x62,0x18,0x21,0x8c,0x68,0x00,0x00,0x00,0xe5,0x28,0x21,
+0x8c,0xa9,0x00,0x00,0x3c,0x02,0xff,0xff,0x27,0x83,0x8a,0x58,0x01,0x22,0x10,0x24,
+0x00,0x48,0x10,0x25,0xac,0xa2,0x00,0x00,0x8d,0x44,0x01,0xa8,0x00,0x07,0x30,0xc2,
+0x3c,0x02,0x00,0x80,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x00,0x06,0x32,0x00,
+0x8c,0xa9,0x00,0x04,0x00,0xc2,0x30,0x25,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,
+0x01,0x22,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04,0xaf,0x87,0xbc,0x10,
+0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x82,0xbc,0x18,0x8c,0xa3,0x00,0x04,
+0x3c,0x01,0xb0,0x07,0xac,0x26,0x80,0x18,0x8d,0x42,0x01,0xa8,0xaf,0x83,0xbc,0x14,
+0x93,0x85,0x81,0xf0,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,
+0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0xa5,0xff,0xff,
+0x00,0x82,0x20,0x23,0xad,0x44,0x01,0xa8,0xa3,0x85,0x81,0xf0,0x08,0x00,0x27,0x89,
+0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01,0x24,0x42,0x9f,0x04,
+0x34,0xa5,0x00,0x20,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x20,
+0xac,0x82,0x00,0x64,0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60,0x00,0x80,0x38,0x21,
+0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c,
+0xac,0x80,0x00,0x50,0xac,0x80,0x00,0x54,0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58,
+0xa0,0x80,0x00,0x5c,0x24,0x83,0x00,0x68,0x24,0x42,0xa0,0x14,0x24,0x04,0x00,0x0f,
+0x24,0x84,0xff,0xff,0xac,0x62,0x00,0x00,0x04,0x81,0xff,0xfd,0x24,0x63,0x00,0x04,
+0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa8,0xac,0xe0,0x01,0xa8,0xac,0xe0,0x01,0xac,
+0xac,0xe0,0x01,0xb0,0xac,0xe0,0x01,0xb4,0xa0,0xe0,0x01,0xb8,0xa0,0xe0,0x01,0xb9,
+0xa0,0xe0,0x01,0xba,0xa0,0xe0,0x01,0xc0,0xa0,0xe0,0x01,0xc1,0xac,0xe0,0x01,0xc4,
+0xac,0xe0,0x01,0xc8,0xac,0xe0,0x01,0xcc,0xac,0xe0,0x01,0xd0,0x8c,0x44,0x00,0x00,
+0x3c,0x02,0x80,0x01,0x24,0x42,0xa0,0xfc,0x30,0x83,0x00,0xff,0x00,0x03,0x19,0x80,
+0xa4,0xe3,0x01,0xd8,0xac,0xe2,0x00,0x78,0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,
+0x24,0x63,0xa2,0x88,0x24,0x42,0xa1,0xf4,0xac,0xe3,0x00,0x88,0xac,0xe2,0x00,0x98,
+0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,0x00,0x04,0x2e,0x03,0x00,0x04,0x34,0x03,
+0x24,0x63,0xa3,0x30,0x00,0x04,0x22,0x03,0x24,0x42,0xa4,0x74,0xac,0xe3,0x00,0xa0,
+0xac,0xe2,0x00,0xa4,0xa0,0xe5,0x01,0xd4,0xa0,0xe6,0x01,0xd5,0x03,0xe0,0x00,0x08,
+0xa0,0xe4,0x01,0xd6,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,
+0x24,0x42,0xa0,0x14,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x2c,0xac,0x43,0x00,0x00,
+0x8c,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x00,0x80,0x28,0x21,
+0x8c,0x82,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,
+0x8c,0x84,0x00,0x10,0x8c,0xa3,0x00,0x14,0x8c,0xa2,0x00,0x04,0x00,0x83,0x20,0x21,
+0x00,0x44,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02,
+0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff,0xac,0xa2,0x00,0x04,
+0xac,0xa0,0x00,0x00,0xac,0xa0,0x00,0x4c,0xac,0xa0,0x00,0x50,0xac,0xa0,0x00,0x54,
+0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,
+0x34,0x63,0x00,0x20,0x24,0x42,0xa0,0xa8,0xac,0x62,0x00,0x00,0x8c,0x86,0x00,0x04,
+0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21,0x8c,0x45,0x00,0x00,
+0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff,0x30,0x42,0x00,0xff,
+0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14,0xac,0x85,0x00,0x40,
+0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08,0x3c,0x02,0xb0,0x03,
+0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0xfc,
+0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c,
+0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21,0xae,0x00,0x00,0x00,
+0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,
+0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x0c,0x00,0x28,0x2a,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x4c,0xae,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,
+0x24,0x63,0xa1,0x60,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,
+0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21,
+0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44,0x00,0x62,0x18,0x21,
+0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50,0x30,0xa3,0x00,0xff,
+0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f,0x30,0x42,0x00,0x03,
+0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c,0xae,0x03,0x00,0x30,
+0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x2a,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x64,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
+0x34,0x42,0x00,0x20,0x24,0x63,0xa1,0xf4,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
+0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16,
+0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40,0x83,0x85,0x8b,0xc4,
+0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02,0xae,0x04,0x00,0x14,
+0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04,0xae,0x03,0x00,0x3c,
+0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01,0x24,0x02,0x00,0x01,
+0xa3,0x86,0x8b,0xc4,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x58,0x00,0x00,0x00,0x00,
+0x08,0x00,0x28,0x89,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,
+0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa2,0x88,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00,
+0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03,0x8c,0x42,0x00,0x00,
+0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x8b,0xc4,0x92,0x05,0x00,0x41,
+0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2,0x00,0x03,0x1e,0x02,
+0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21,0xae,0x03,0x00,0x18,
+0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03,0x24,0x02,0x00,0x01,
+0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x8b,0xc4,0x8f,0xbf,0x00,0x14,
+0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,
+0x0c,0x00,0x28,0x58,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0xae,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,
+0x24,0x63,0xa3,0x30,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,
+0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x42,0x00,0x80,0x80,0x21,
+0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,0x3c,0x08,0xb0,0x01,
+0x34,0x42,0x00,0x10,0x00,0x88,0x20,0x21,0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04,
+0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x27,0x89,0x89,0x58,0x00,0x48,0x10,0x21,
+0x8c,0x45,0x00,0x00,0x00,0x03,0x18,0x80,0x00,0x69,0x18,0x21,0xac,0x65,0x00,0x00,
+0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x27,0x87,0x8a,0x58,0x00,0x48,0x10,0x21,
+0x8c,0x45,0x00,0x04,0x00,0x03,0x18,0x80,0x00,0x67,0x18,0x21,0xac,0x65,0x00,0x00,
+0x8e,0x02,0x01,0xac,0x8e,0x06,0x00,0x04,0x02,0x00,0x20,0x21,0x00,0x02,0x10,0x80,
+0x00,0x47,0x38,0x21,0x94,0xe3,0x00,0x02,0x00,0x49,0x10,0x21,0x90,0x45,0x00,0x00,
+0x00,0x03,0x1a,0x00,0x00,0xc8,0x30,0x21,0x00,0xa3,0x28,0x25,0x0c,0x00,0x26,0x69,
+0xa4,0xc5,0x00,0x2e,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,
+0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,
+0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,
+0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,
+0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0,0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,
+0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x81,0xf0,0x0c,0x00,0x28,0x0b,
+0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0xa2,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0xd8,
+0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,
+0x34,0x42,0x00,0x20,0x24,0x63,0xa4,0x74,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,
+0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x42,
+0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,
+0x3c,0x08,0xb0,0x01,0x34,0x42,0x00,0x10,0x00,0x88,0x20,0x21,0x00,0x62,0x18,0x25,
+0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x27,0x89,0x89,0x58,
+0x00,0x48,0x10,0x21,0x8c,0x45,0x00,0x00,0x00,0x03,0x18,0x80,0x00,0x69,0x18,0x21,
+0xac,0x65,0x00,0x00,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x27,0x87,0x8a,0x58,
+0x00,0x48,0x10,0x21,0x8c,0x45,0x00,0x04,0x00,0x03,0x18,0x80,0x00,0x67,0x18,0x21,
+0xac,0x65,0x00,0x00,0x8e,0x02,0x01,0xac,0x8e,0x06,0x00,0x04,0x02,0x00,0x20,0x21,
+0x00,0x02,0x10,0x80,0x00,0x47,0x38,0x21,0x94,0xe3,0x00,0x02,0x00,0x49,0x10,0x21,
+0x90,0x45,0x00,0x00,0x00,0x03,0x1a,0x00,0x00,0xc8,0x30,0x21,0x00,0xa3,0x28,0x25,
+0x0c,0x00,0x26,0x69,0xa4,0xc5,0x00,0x2e,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,
+0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,
+0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,
+0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,
+0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0,0x02,0x00,0x20,0x21,
+0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x81,0xf0,
+0x0c,0x00,0x28,0x0b,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0xa2,0x00,0x00,0x00,0x00,
+0x08,0x00,0x29,0x29,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,
+0x27,0xbd,0xff,0xd8,0x34,0x42,0x00,0x20,0x24,0x63,0xa5,0xb8,0xaf,0xb2,0x00,0x18,
+0xac,0x43,0x00,0x00,0x3c,0x12,0xb0,0x03,0x3c,0x02,0x80,0x01,0xaf,0xb4,0x00,0x20,
+0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x24,
+0x00,0x80,0x80,0x21,0x24,0x54,0xa0,0x14,0x00,0x00,0x88,0x21,0x3c,0x13,0xb0,0x01,
+0x36,0x52,0x00,0xef,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x06,0x90,0x43,0x00,0x00,
+0x8e,0x04,0x00,0x04,0x92,0x02,0x01,0xbb,0x30,0x69,0x00,0xff,0x00,0x04,0x42,0x02,
+0x10,0x40,0x00,0x1e,0x00,0x00,0x38,0x21,0x8e,0x03,0x01,0xa8,0x3c,0x06,0x28,0x38,
+0x34,0xc6,0x00,0x20,0x24,0x64,0x00,0x3d,0x28,0x82,0x00,0x00,0x24,0x63,0x00,0x7c,
+0x00,0x82,0x18,0x0a,0x00,0x03,0x19,0x83,0x00,0x03,0x19,0x80,0x00,0x83,0x20,0x23,
+0x00,0x04,0x10,0x80,0x00,0x50,0x10,0x21,0x8c,0x45,0x00,0xa8,0xae,0x04,0x01,0xac,
+0xae,0x04,0x01,0xa8,0x00,0xb3,0x18,0x21,0xae,0x05,0x00,0x04,0xac,0x66,0x00,0x00,
+0x8e,0x02,0x00,0x04,0x3c,0x03,0x80,0x00,0x34,0x63,0x4e,0x00,0x00,0x53,0x10,0x21,
+0xac,0x43,0x00,0x04,0xa2,0x00,0x01,0xbb,0x93,0x83,0x81,0xf7,0x00,0x00,0x00,0x00,
+0x24,0x62,0x00,0x01,0xa3,0x82,0x81,0xf7,0xa2,0x43,0x00,0x00,0x01,0x28,0x10,0x23,
+0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a,
+0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff,0x10,0x44,0x00,0x6b,
+0x3c,0x02,0xb0,0x01,0x8e,0x03,0x00,0x04,0x3c,0x04,0x7c,0x00,0x00,0x62,0x18,0x21,
+0x8c,0x65,0x00,0x04,0x34,0x84,0x00,0xf0,0x00,0x00,0x30,0x21,0xae,0x05,0x00,0x44,
+0x00,0xa4,0x20,0x24,0x8c,0x63,0x00,0x00,0x10,0x80,0x00,0x6b,0x3c,0x02,0xff,0xff,
+0x3c,0x09,0xb0,0x03,0x3c,0x05,0x7c,0x00,0x35,0x29,0x00,0x99,0x3c,0x0a,0xb0,0x01,
+0x24,0x08,0x00,0x40,0x34,0xa5,0x00,0xf0,0x3c,0x0b,0xff,0xff,0x3c,0x0c,0x28,0x38,
+0x16,0x20,0x00,0x06,0x24,0xe7,0x00,0x01,0x93,0x82,0x81,0xf6,0x24,0x11,0x00,0x01,
+0x24,0x42,0x00,0x01,0xa1,0x22,0x00,0x00,0xa3,0x82,0x81,0xf6,0x8e,0x02,0x00,0x04,
+0x24,0x06,0x00,0x01,0x24,0x42,0x01,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04,
+0x00,0x4a,0x10,0x21,0x8c,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x44,
+0x00,0x65,0x20,0x24,0x8c,0x43,0x00,0x00,0x10,0xe8,0x00,0x2d,0x00,0x00,0x00,0x00,
+0x14,0x80,0xff,0xeb,0x00,0x6b,0x10,0x24,0x14,0x4c,0xff,0xe9,0x24,0x02,0x00,0x01,
+0x10,0xc2,0x00,0x30,0x3c,0x03,0xb0,0x09,0x8e,0x02,0x00,0x44,0x8e,0x04,0x00,0x60,
+0x00,0x02,0x1e,0x42,0x00,0x02,0x12,0x02,0x30,0x42,0x00,0x0f,0x30,0x63,0x00,0x01,
+0xae,0x02,0x00,0x00,0x10,0x44,0x00,0x1a,0xae,0x03,0x00,0x58,0x8e,0x02,0x00,0x64,
+0x8e,0x04,0x00,0x58,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x05,0x00,0x00,0x00,0x00,
+0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,
+0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x80,0x00,0x50,0x10,0x21,
+0x8c,0x42,0x00,0x68,0x00,0x00,0x00,0x00,0x10,0x54,0x00,0x06,0x00,0x00,0x00,0x00,
+0x00,0x40,0xf8,0x09,0x02,0x00,0x20,0x21,0x8e,0x04,0x00,0x58,0x8e,0x03,0x00,0x00,
+0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x60,0x08,0x00,0x29,0x81,0xae,0x04,0x00,0x64,
+0x8e,0x02,0x00,0x64,0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xe5,0x00,0x00,0x00,0x00,
+0x7a,0x02,0x0d,0x7c,0x8f,0xbf,0x00,0x24,0x8f,0xb4,0x00,0x20,0x7b,0xb2,0x00,0xfc,
+0x7b,0xb0,0x00,0xbc,0x00,0x43,0x10,0x26,0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x28,0x8e,0x04,0x00,0x04,0x34,0x63,0x00,0x06,0x90,0x62,0x00,0x00,
+0x00,0x04,0x42,0x02,0x00,0x48,0x10,0x23,0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,
+0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,
+0x00,0x82,0x20,0x23,0x14,0x86,0xff,0xc4,0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,
+0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x03,0x14,0x40,0x00,0x05,0x24,0x02,0x00,0x0d,
+0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x01,0x08,0x00,0x2a,0x04,0xa2,0x02,0x00,0x5c,
+0x08,0x00,0x2a,0x04,0xa2,0x00,0x00,0x5c,0x00,0x62,0x10,0x24,0x3c,0x03,0x28,0x38,
+0x14,0x43,0xff,0x93,0x24,0x02,0x00,0x01,0x08,0x00,0x29,0xdc,0x00,0x00,0x00,0x00,
+0x3c,0x02,0xb0,0x01,0x00,0xa2,0x40,0x21,0x00,0xa0,0x48,0x21,0x8d,0x05,0x00,0x00,
+0x24,0x02,0xc0,0x00,0x00,0x09,0x38,0xc2,0x00,0xa2,0x28,0x24,0x24,0xc2,0xff,0xff,
+0x00,0x07,0x3a,0x00,0x3c,0x0a,0xb0,0x06,0x3c,0x03,0x00,0x80,0x00,0xa6,0x28,0x25,
+0x2c,0x42,0x1f,0xff,0x00,0xe3,0x38,0x25,0x35,0x4a,0x80,0x18,0x10,0x40,0x00,0x0e,
+0xad,0x05,0x00,0x00,0xaf,0x89,0xbc,0x10,0x8d,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
+0xaf,0x82,0xbc,0x18,0x8d,0x03,0x00,0x04,0xad,0x47,0x00,0x00,0xaf,0x83,0xbc,0x14,
+0xac,0x80,0x01,0xd0,0xac,0x80,0x01,0xc4,0xa0,0x80,0x01,0xc0,0xa0,0x80,0x01,0xc1,
+0xac,0x80,0x01,0xc8,0xac,0x80,0x01,0xcc,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,
+0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x8c,0x83,0x01,0xc4,0x00,0x80,0x38,0x21,
+0x90,0x84,0x01,0xc0,0x00,0x03,0x18,0x80,0x00,0x67,0x18,0x21,0x8c,0x65,0x00,0xa8,
+0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xa2,0x10,0x21,0x8c,0x42,0x00,0x00,
+0x10,0x83,0x00,0x18,0x00,0x02,0x14,0x02,0x8c,0xe9,0x01,0xcc,0x8c,0xea,0x01,0xc8,
+0x30,0x46,0x00,0xff,0x01,0x2a,0x18,0x21,0x30,0x64,0x00,0xff,0x00,0x03,0x1a,0x02,
+0x24,0x62,0x00,0x01,0x14,0x80,0x00,0x02,0x30,0x48,0x00,0xff,0x30,0x68,0x00,0xff,
+0x90,0xe2,0x01,0xc1,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x23,0x00,0x02,0x12,0x00,
+0x00,0x49,0x10,0x21,0x00,0x4a,0x10,0x21,0x00,0x46,0x30,0x23,0x0c,0x00,0x2a,0x2c,
+0x00,0xe0,0x20,0x21,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x8c,0xe6,0x01,0xc8,0x08,0x00,0x2a,0x6b,0x00,0x00,0x00,0x00,
+0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x14,0xaf,0xb0,0x00,0x10,0x8c,0x82,0x01,0xc4,
+0x90,0x87,0x01,0xc1,0x00,0x80,0x80,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,
+0x8c,0x48,0x00,0xa8,0x3c,0x02,0xb0,0x01,0x00,0x07,0x3a,0x00,0x01,0x02,0x10,0x21,
+0x8c,0x43,0x00,0x00,0x00,0xe5,0x38,0x21,0x00,0xe6,0x38,0x21,0x00,0x03,0x1c,0x02,
+0x30,0x63,0x00,0xff,0x00,0xe3,0x38,0x23,0x01,0x00,0x28,0x21,0x0c,0x00,0x2a,0x2c,
+0x00,0xe0,0x30,0x21,0x8e,0x02,0x01,0xa8,0x8f,0xbf,0x00,0x14,0x24,0x44,0x00,0x01,
+0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,
+0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0xae,0x04,0x01,0xa8,0x8f,0xb0,0x00,0x10,
+0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,
+0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xaa,0x58,0xaf,0xb0,0x00,0x10,
+0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x90,0x82,0x01,0xd4,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x6a,0x00,0x80,0x80,0x21,0x90,0x82,0x01,0xc0,0x00,0x00,0x00,0x00,
+0x14,0x40,0x00,0x61,0x00,0x00,0x00,0x00,0x8c,0x83,0x01,0xa8,0x8c,0x82,0x01,0xac,
+0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x22,0x00,0x00,0x28,0x21,0x93,0x82,0x81,0xf1,
+0x00,0x03,0x30,0x80,0x00,0xc4,0x18,0x21,0x24,0x04,0x00,0x01,0x8c,0x67,0x00,0xa8,
+0x10,0x44,0x00,0x20,0x3c,0x04,0xb0,0x01,0xaf,0x87,0xbc,0x10,0x00,0xe4,0x20,0x21,
+0x8c,0x86,0x00,0x00,0x00,0x07,0x18,0xc2,0x3c,0x02,0x00,0x80,0xaf,0x86,0xbc,0x18,
+0x8c,0x86,0x00,0x04,0x00,0x03,0x1a,0x00,0x3c,0x05,0xb0,0x06,0x00,0x62,0x18,0x25,
+0x34,0xa5,0x80,0x18,0xac,0xa3,0x00,0x00,0x8e,0x02,0x01,0xa8,0x8e,0x09,0x01,0xac,
+0xaf,0x86,0xbc,0x14,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,
+0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,
+0x00,0x80,0x30,0x21,0xae,0x04,0x01,0xa8,0x00,0xc9,0x10,0x26,0x00,0x02,0x28,0x2b,
+0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x00,0xa0,0x10,0x21,0x03,0xe0,0x00,0x08,
+0x27,0xbd,0x00,0x18,0x93,0x82,0x81,0xf0,0x00,0x00,0x00,0x00,0x2c,0x42,0x00,0x02,
+0x14,0x40,0xff,0xf7,0x00,0x00,0x28,0x21,0x3c,0x05,0xb0,0x01,0x00,0xe5,0x28,0x21,
+0x27,0x83,0x89,0x58,0x00,0xc3,0x18,0x21,0x8c,0xa6,0x00,0x00,0x8c,0x64,0x00,0x00,
+0x24,0x02,0xc0,0x00,0x00,0xc2,0x10,0x24,0x00,0x44,0x10,0x25,0xac,0xa2,0x00,0x00,
+0x8e,0x03,0x01,0xa8,0x27,0x84,0x8a,0x58,0x8c,0xa6,0x00,0x04,0x00,0x03,0x18,0x80,
+0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0x07,0x20,0xc2,
+0x00,0xc2,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04,0xaf,0x87,0xbc,0x10,
+0x8c,0xa6,0x00,0x00,0x3c,0x02,0x00,0x80,0x00,0x04,0x22,0x00,0x3c,0x03,0xb0,0x06,
+0xaf,0x86,0xbc,0x18,0x00,0x82,0x20,0x25,0x34,0x63,0x80,0x18,0x8c,0xa6,0x00,0x04,
+0xac,0x64,0x00,0x00,0x8e,0x02,0x01,0xa8,0xaf,0x86,0xbc,0x14,0x24,0x44,0x00,0x01,
+0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x93,0x83,0x81,0xf0,
+0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x24,0x63,0xff,0xff,
+0xae,0x04,0x01,0xa8,0xa3,0x83,0x81,0xf0,0x8e,0x04,0x01,0xac,0x8e,0x02,0x01,0xa8,
+0x08,0x00,0x2a,0xcb,0x00,0x44,0x10,0x26,0x0c,0x00,0x2a,0x4c,0x00,0x00,0x00,0x00,
+0x7a,0x02,0x0d,0x7c,0x08,0x00,0x2a,0xcb,0x00,0x43,0x10,0x26,0x8c,0x86,0x01,0xa8,
+0x8c,0x89,0x01,0xac,0x00,0x00,0x00,0x00,0x10,0xc9,0x00,0xb4,0x00,0xc0,0x68,0x21,
+0x00,0x06,0x10,0x80,0x27,0x83,0x89,0x58,0x00,0x43,0x18,0x21,0x00,0x44,0x10,0x21,
+0x8c,0x47,0x00,0xa8,0x94,0x65,0x00,0x02,0x3c,0x02,0xb0,0x01,0x00,0xe2,0x10,0x21,
+0x30,0xa5,0x3f,0xff,0xa4,0x45,0x00,0x2c,0x90,0x8a,0x01,0xc0,0x00,0x00,0x00,0x00,
+0x11,0x40,0x00,0x0c,0x00,0x07,0x32,0x02,0x8c,0x83,0x01,0xc4,0x90,0x85,0x01,0xc1,
+0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0xa8,0x00,0x00,0x00,0x00,
+0x00,0x02,0x12,0x02,0x00,0x45,0x10,0x21,0x30,0x42,0x00,0x3f,0x14,0xc2,0xff,0xde,
+0x00,0x00,0x00,0x00,0x3c,0x04,0xb0,0x01,0x00,0xe4,0x40,0x21,0x8d,0x06,0x00,0x00,
+0x00,0x0d,0x28,0x80,0x00,0x06,0x14,0x02,0x30,0x4b,0x00,0xff,0x00,0xeb,0x70,0x21,
+0x01,0xc4,0x20,0x21,0x90,0x83,0x00,0x00,0x27,0x82,0x89,0x58,0x00,0xa2,0x28,0x21,
+0x8c,0xa4,0x00,0x00,0x00,0x03,0x18,0x82,0x30,0x63,0x00,0x03,0x2c,0x62,0x00,0x02,
+0x14,0x40,0x00,0x66,0x30,0x8c,0x3f,0xff,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x61,
+0x2d,0x82,0x08,0x00,0x15,0x40,0x00,0x36,0x01,0x6c,0x10,0x21,0x01,0x6c,0x18,0x21,
+0x30,0x62,0x00,0xff,0x00,0x02,0x10,0x2b,0x00,0x03,0x1a,0x02,0x3c,0x04,0xb0,0x01,
+0x00,0x62,0x18,0x21,0x00,0xe4,0x20,0x21,0x24,0x02,0x00,0x01,0xa2,0x03,0x01,0xc1,
+0xa0,0x82,0x00,0x08,0x8e,0x06,0x01,0xa8,0x3c,0x03,0xb0,0x00,0x34,0x63,0xff,0xf4,
+0x24,0xc5,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0xc2,0x00,0x40,0x00,0xa4,0x10,0x0a,
+0x01,0xc3,0x18,0x21,0xa4,0x6c,0x00,0x00,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,
+0x92,0x04,0x01,0xc0,0x00,0xa2,0x38,0x23,0x3c,0x03,0xb0,0x03,0xae,0x0b,0x01,0xcc,
+0xae,0x0c,0x01,0xc8,0xae,0x06,0x01,0xc4,0xae,0x07,0x01,0xa8,0x34,0x63,0x01,0x08,
+0x92,0x05,0x01,0xd6,0x8c,0x66,0x00,0x00,0x24,0x84,0x00,0x01,0x30,0x82,0x00,0xff,
+0x00,0x45,0x10,0x2b,0xae,0x06,0x01,0xd0,0x10,0x40,0x00,0x07,0xa2,0x04,0x01,0xc0,
+0x92,0x02,0x01,0xd5,0x92,0x03,0x01,0xc1,0x24,0x42,0xff,0xfc,0x00,0x62,0x18,0x2a,
+0x14,0x60,0x00,0x08,0x00,0x00,0x00,0x00,0x02,0x00,0x20,0x21,0x0c,0x00,0x2a,0x4c,
+0x00,0x00,0x00,0x00,0x8e,0x09,0x01,0xac,0x8e,0x06,0x01,0xa8,0x08,0x00,0x2a,0xcb,
+0x00,0xc9,0x10,0x26,0x8e,0x09,0x01,0xac,0x08,0x00,0x2a,0xca,0x00,0xe0,0x30,0x21,
+0x30,0x43,0x00,0xff,0x92,0x07,0x01,0xc1,0x00,0x02,0x12,0x02,0x30,0x44,0x00,0xff,
+0x38,0x63,0x00,0x00,0x24,0x46,0x00,0x01,0x92,0x05,0x01,0xd5,0x00,0x83,0x30,0x0a,
+0x00,0xc7,0x18,0x21,0x00,0xa3,0x10,0x2a,0x14,0x40,0xff,0xeb,0x00,0x00,0x00,0x00,
+0x24,0xa2,0xff,0xfc,0x00,0x62,0x10,0x2a,0x10,0x40,0x00,0x07,0x01,0x80,0x28,0x21,
+0x92,0x03,0x01,0xd6,0x25,0x42,0x00,0x01,0x00,0x43,0x10,0x2a,0x14,0x40,0x00,0x07,
+0x25,0xa4,0x00,0x01,0x01,0x80,0x28,0x21,0x01,0x60,0x30,0x21,0x0c,0x00,0x2a,0x74,
+0x02,0x00,0x20,0x21,0x08,0x00,0x2b,0x6d,0x00,0x00,0x00,0x00,0x28,0x83,0x00,0x00,
+0x25,0xa2,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,
+0x00,0x82,0x20,0x23,0x00,0xc7,0x18,0x21,0x25,0x42,0x00,0x01,0x00,0x80,0x30,0x21,
+0xa2,0x03,0x01,0xc1,0xae,0x0b,0x01,0xcc,0xae,0x0c,0x01,0xc8,0x08,0x00,0x2a,0xc9,
+0xa2,0x02,0x01,0xc0,0x14,0x40,0xff,0x9f,0x00,0x00,0x00,0x00,0x15,0x40,0x00,0x14,
+0x24,0x02,0xc0,0x00,0x00,0xc2,0x10,0x24,0x00,0x4c,0x10,0x25,0xad,0x02,0x00,0x00,
+0xaf,0x87,0xbc,0x10,0x8d,0x05,0x00,0x00,0x00,0x07,0x18,0xc2,0x3c,0x02,0x00,0x80,
+0x00,0x03,0x1a,0x00,0x3c,0x04,0xb0,0x06,0xaf,0x85,0xbc,0x18,0x00,0x62,0x18,0x25,
+0x34,0x84,0x80,0x18,0x8d,0x05,0x00,0x04,0xac,0x83,0x00,0x00,0x8e,0x02,0x01,0xa8,
+0x8e,0x09,0x01,0xac,0xaf,0x85,0xbc,0x14,0x08,0x00,0x2a,0xc2,0x24,0x44,0x00,0x01,
+0x01,0x6c,0x10,0x21,0x30,0x45,0x00,0xff,0x92,0x04,0x01,0xc1,0x00,0x02,0x12,0x02,
+0x30,0x46,0x00,0xff,0x38,0xa5,0x00,0x00,0x24,0x42,0x00,0x01,0x92,0x03,0x01,0xd5,
+0x00,0xc5,0x10,0x0a,0x00,0x82,0x20,0x21,0x00,0x64,0x18,0x2a,0x10,0x60,0xff,0xca,
+0x01,0x80,0x28,0x21,0x08,0x00,0x2b,0x6b,0x02,0x00,0x20,0x21,0x90,0x87,0x01,0xc0,
+0x00,0x00,0x00,0x00,0x10,0xe0,0xff,0x06,0x00,0x00,0x28,0x21,0x3c,0x02,0xb0,0x03,
+0x34,0x42,0x01,0x08,0x94,0x83,0x01,0xd8,0x8c,0x88,0x01,0xd0,0x8c,0x45,0x00,0x00,
+0x01,0x03,0x18,0x21,0x00,0xa3,0x10,0x2b,0x10,0x40,0x00,0x0b,0x2c,0xe2,0x00,0x02,
+0x00,0xa8,0x10,0x2b,0x10,0x40,0xfe,0xf9,0x00,0xc9,0x10,0x26,0x3c,0x02,0x80,0x00,
+0x00,0x62,0x18,0x21,0x00,0xa2,0x10,0x21,0x00,0x43,0x10,0x2b,0x14,0x40,0xfe,0xf3,
+0x00,0xc9,0x10,0x26,0x2c,0xe2,0x00,0x02,0x10,0x40,0xff,0x90,0x00,0x00,0x00,0x00,
+0x24,0x02,0x00,0x01,0x14,0xe2,0xfe,0xed,0x00,0xc9,0x10,0x26,0x3c,0x03,0xb0,0x06,
+0x34,0x63,0x80,0x18,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,
+0x14,0x40,0xfe,0xe5,0x00,0x00,0x00,0x00,0x08,0x00,0x2b,0x6b,0x00,0x00,0x00,0x00,
+0x3c,0x04,0xb0,0x03,0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01,0x34,0xc6,0x00,0x18,
+0x34,0x84,0x00,0x20,0x24,0x42,0xaf,0xa0,0x24,0x03,0xff,0x83,0xac,0x82,0x00,0x00,
+0xa0,0xc3,0x00,0x00,0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8,0x3c,0x03,0xb0,0x07,
+0x24,0x02,0xff,0x82,0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00,0x90,0x64,0x00,0x00,
+0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01,0xa0,0x40,0x00,0x00,
+0x90,0x43,0x00,0x00,0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07,0xa3,0xa3,0x00,0x00,
+0xa0,0xc2,0x00,0x00,0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10,0x24,0x02,0x00,0x06,
+0x3c,0x03,0xb0,0x07,0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38,0xa0,0xa2,0x00,0x00,
+0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20,0xa3,0xa4,0x00,0x00,
+0xa0,0xa0,0x00,0x00,0x90,0xa3,0x00,0x00,0xaf,0x82,0xbf,0x20,0xa3,0xa3,0x00,0x00,
+0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x08,
+};
+
+u8 rtl8190_fwdata_array[] ={
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,
+0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4,0x00,0xab,0x00,0x72,
+0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x02,0x76,0x01,0x3b,
+0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f,0x01,0x3b,0x00,0x9e,
+0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20,0x01,0x2f,0x00,0x98,
+0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e,0x00,0x98,0x00,0x4c,
+0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f,0x02,0x39,0x01,0x1c,
+0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39,0x01,0x1c,0x00,0x8e,
+0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c,0x01,0x11,0x00,0x89,
+0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b,0x00,0x89,0x00,0x44,
+0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e,0x02,0xab,0x02,0xab,
+0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08,0x04,0x06,0x07,0x08,
+0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x4c,
+0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c,0x5f,0x64,0x61,0x74,
+0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x64,0x45,0x4c,
+0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00,0x00,0x00,0x00,0x00,
+0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64,
+0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x70,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4f,0x76,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x0b,0x53,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x2c,
+0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x60,
+0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20,0x00,0x00,0x01,0x80,
+0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x9c,
+0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0,0x00,0x00,0x01,0xd4,
+0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,
+0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x6f,0x00,0x00,0x03,0x40,0x00,0x00,0x03,0xa8,
+0x00,0x00,0x04,0x10,0x01,0x01,0x01,0x02,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,
+0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x02,0x03,0x03,0x04,0x05,0x06,0x07,0x08,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x07,0x74,0x80,0x00,0x07,0x88,
+0x80,0x00,0x07,0x88,0x80,0x00,0x07,0x78,0x80,0x00,0x07,0x78,0x80,0x00,0x07,0x9c,
+0x80,0x00,0x53,0xc4,0x80,0x00,0x54,0x24,0x80,0x00,0x54,0x38,0x80,0x00,0x54,0x5c,
+0x80,0x00,0x54,0x68,0x80,0x00,0x54,0xa8,0x80,0x00,0x56,0xa8,0x80,0x00,0x57,0xec,
+0x80,0x00,0x58,0x14,0x80,0x00,0x59,0x0c,0x80,0x00,0x59,0xc4,0x80,0x00,0x5a,0x6c,
+0x80,0x00,0x5a,0xe0,0x80,0x00,0x5b,0xec,0x80,0x00,0x5c,0x24,0x80,0x00,0x5c,0x38,
+0x80,0x00,0x5c,0x4c,0x80,0x00,0x5d,0x40,0x80,0x00,0x5d,0x80,0x80,0x00,0x5e,0x34,
+0x80,0x00,0x5e,0x5c,0x80,0x00,0x56,0x68,0x80,0x00,0x5e,0x78,0x80,0x00,0x88,0xf8,
+0x80,0x00,0x88,0xf8,0x80,0x00,0x88,0xf8,0x80,0x00,0x89,0x2c,0x80,0x00,0x89,0x6c,
+0x80,0x00,0x89,0xa4,0x80,0x00,0x89,0xd4,0x80,0x00,0x8a,0x10,0x80,0x00,0x8a,0x50,
+0x80,0x00,0x8a,0xb8,0x80,0x00,0x8a,0xcc,0x80,0x00,0x8b,0x08,0x80,0x00,0x8b,0x10,
+0x80,0x00,0x8b,0x4c,0x80,0x00,0x8b,0x60,0x80,0x00,0x8b,0x68,0x80,0x00,0x8b,0x70,
+0x80,0x00,0x8b,0x70,0x80,0x00,0x8b,0x70,0x80,0x00,0x8b,0x70,0x80,0x00,0x8a,0x90,
+0x80,0x00,0x8b,0xa0,0x80,0x00,0x8b,0xb4,0x80,0x00,0x88,0x54,0x80,0x00,0x8e,0xc8,
+0x80,0x00,0x8e,0xc8,0x80,0x00,0x8e,0xc8,0x80,0x00,0x8e,0xfc,0x80,0x00,0x8f,0x3c,
+0x80,0x00,0x8f,0x74,0x80,0x00,0x8f,0xa4,0x80,0x00,0x8f,0xe0,0x80,0x00,0x90,0x20,
+0x80,0x00,0x90,0x88,0x80,0x00,0x90,0x9c,0x80,0x00,0x90,0xd8,0x80,0x00,0x90,0xe0,
+0x80,0x00,0x91,0x1c,0x80,0x00,0x91,0x30,0x80,0x00,0x91,0x38,0x80,0x00,0x91,0x40,
+0x80,0x00,0x91,0x40,0x80,0x00,0x91,0x40,0x80,0x00,0x91,0x40,0x80,0x00,0x90,0x60,
+0x80,0x00,0x91,0x70,0x80,0x00,0x91,0x84,0x80,0x00,0x8d,0x00,};
+
+u32 Rtl8192UsbPHY_REGArray[] = {
+0x0, };
+
+u32 Rtl8192UsbPHY_REG_1T2RArray[] = {
+0x800,0x00000000,
+0x804,0x00000001,
+0x808,0x0000fc00,
+0x80c,0x0000001c,
+0x810,0x801010aa,
+0x814,0x008514d0,
+0x818,0x00000040,
+0x81c,0x00000000,
+0x820,0x00000004,
+0x824,0x00690000,
+0x828,0x00000004,
+0x82c,0x00e90000,
+0x830,0x00000004,
+0x834,0x00690000,
+0x838,0x00000004,
+0x83c,0x00e90000,
+0x840,0x00000000,
+0x844,0x00000000,
+0x848,0x00000000,
+0x84c,0x00000000,
+0x850,0x00000000,
+0x854,0x00000000,
+0x858,0x65a965a9,
+0x85c,0x65a965a9,
+0x860,0x001f0010,
+0x864,0x007f0010,
+0x868,0x001f0010,
+0x86c,0x007f0010,
+0x870,0x0f100f70,
+0x874,0x0f100f70,
+0x878,0x00000000,
+0x87c,0x00000000,
+0x880,0x6870e36c,
+0x884,0xe3573600,
+0x888,0x4260c340,
+0x88c,0x0000ff00,
+0x890,0x00000000,
+0x894,0xfffffffe,
+0x898,0x4c42382f,
+0x89c,0x00656056,
+0x8b0,0x00000000,
+0x8e0,0x00000000,
+0x8e4,0x00000000,
+0x900,0x00000000,
+0x904,0x00000023,
+0x908,0x00000000,
+0x90c,0x31121311,
+0xa00,0x00d0c7d8,
+0xa04,0x811f0008,
+0xa08,0x80cd8300,
+0xa0c,0x2e62740f,
+0xa10,0x95009b78,
+0xa14,0x11145008,
+0xa18,0x00881117,
+0xa1c,0x89140fa0,
+0xa20,0x1a1b0000,
+0xa24,0x090e1317,
+0xa28,0x00000204,
+0xa2c,0x00000000,
+0xc00,0x00000040,
+0xc04,0x00005433,
+0xc08,0x000000e4,
+0xc0c,0x6c6c6c6c,
+0xc10,0x08800000,
+0xc14,0x40000100,
+0xc18,0x08000000,
+0xc1c,0x40000100,
+0xc20,0x08000000,
+0xc24,0x40000100,
+0xc28,0x08000000,
+0xc2c,0x40000100,
+0xc30,0x6de9ac44,
+0xc34,0x465c52cd,
+0xc38,0x497f5994,
+0xc3c,0x0a969764,
+0xc40,0x1f7c403f,
+0xc44,0x000100b7,
+0xc48,0xec020000,
+0xc4c,0x00000300,
+0xc50,0x69543420,
+0xc54,0x433c0094,
+0xc58,0x69543420,
+0xc5c,0x433c0094,
+0xc60,0x69543420,
+0xc64,0x433c0094,
+0xc68,0x69543420,
+0xc6c,0x433c0094,
+0xc70,0x2c7f000d,
+0xc74,0x0186175b,
+0xc78,0x0000001f,
+0xc7c,0x00b91612,
+0xc80,0x40000100,
+0xc84,0x20000000,
+0xc88,0x40000100,
+0xc8c,0x20200000,
+0xc90,0x40000100,
+0xc94,0x00000000,
+0xc98,0x40000100,
+0xc9c,0x00000000,
+0xca0,0x00492492,
+0xca4,0x00000000,
+0xca8,0x00000000,
+0xcac,0x00000000,
+0xcb0,0x00000000,
+0xcb4,0x00000000,
+0xcb8,0x00000000,
+0xcbc,0x00492492,
+0xcc0,0x00000000,
+0xcc4,0x00000000,
+0xcc8,0x00000000,
+0xccc,0x00000000,
+0xcd0,0x00000000,
+0xcd4,0x00000000,
+0xcd8,0x64b22427,
+0xcdc,0x00766932,
+0xce0,0x00222222,
+0xd00,0x00000750,
+0xd04,0x00000403,
+0xd08,0x0000907f,
+0xd0c,0x00000001,
+0xd10,0xa0633333,
+0xd14,0x33333c63,
+0xd18,0x6a8f5b6b,
+0xd1c,0x00000000,
+0xd20,0x00000000,
+0xd24,0x00000000,
+0xd28,0x00000000,
+0xd2c,0xcc979975,
+0xd30,0x00000000,
+0xd34,0x00000000,
+0xd38,0x00000000,
+0xd3c,0x00027293,
+0xd40,0x00000000,
+0xd44,0x00000000,
+0xd48,0x00000000,
+0xd4c,0x00000000,
+0xd50,0x6437140a,
+0xd54,0x024dbd02,
+0xd58,0x00000000,
+0xd5c,0x04032064,
+0xe00,0x161a1a1a,
+0xe04,0x12121416,
+0xe08,0x00001800,
+0xe0c,0x00000000,
+0xe10,0x161a1a1a,
+0xe14,0x12121416,
+0xe18,0x161a1a1a,
+0xe1c,0x12121416,
+};
+
+u32 Rtl8192UsbRadioA_Array[] = {
+0x019,0x00000003,
+0x000,0x000000bf,
+0x001,0x00000ee0,
+0x002,0x0000004c,
+0x003,0x000007f1,
+0x004,0x00000975,
+0x005,0x00000c58,
+0x006,0x00000ae6,
+0x007,0x000000ca,
+0x008,0x00000e1c,
+0x009,0x000007f0,
+0x00a,0x000009d0,
+0x00b,0x000001ba,
+0x00c,0x00000240,
+0x00e,0x00000020,
+0x00f,0x00000990,
+0x012,0x00000806,
+0x014,0x000005ab,
+0x015,0x00000f80,
+0x016,0x00000020,
+0x017,0x00000597,
+0x018,0x0000050a,
+0x01a,0x00000f80,
+0x01b,0x00000f5e,
+0x01c,0x00000008,
+0x01d,0x00000607,
+0x01e,0x000006cc,
+0x01f,0x00000000,
+0x020,0x000001a5,
+0x01f,0x00000001,
+0x020,0x00000165,
+0x01f,0x00000002,
+0x020,0x000000c6,
+0x01f,0x00000003,
+0x020,0x00000086,
+0x01f,0x00000004,
+0x020,0x00000046,
+0x01f,0x00000005,
+0x020,0x000001e6,
+0x01f,0x00000006,
+0x020,0x000001a6,
+0x01f,0x00000007,
+0x020,0x00000166,
+0x01f,0x00000008,
+0x020,0x000000c7,
+0x01f,0x00000009,
+0x020,0x00000087,
+0x01f,0x0000000a,
+0x020,0x000000f7,
+0x01f,0x0000000b,
+0x020,0x000000d7,
+0x01f,0x0000000c,
+0x020,0x000000b7,
+0x01f,0x0000000d,
+0x020,0x00000097,
+0x01f,0x0000000e,
+0x020,0x00000077,
+0x01f,0x0000000f,
+0x020,0x00000057,
+0x01f,0x00000010,
+0x020,0x00000037,
+0x01f,0x00000011,
+0x020,0x000000fb,
+0x01f,0x00000012,
+0x020,0x000000db,
+0x01f,0x00000013,
+0x020,0x000000bb,
+0x01f,0x00000014,
+0x020,0x000000ff,
+0x01f,0x00000015,
+0x020,0x000000e3,
+0x01f,0x00000016,
+0x020,0x000000c3,
+0x01f,0x00000017,
+0x020,0x000000a3,
+0x01f,0x00000018,
+0x020,0x00000083,
+0x01f,0x00000019,
+0x020,0x00000063,
+0x01f,0x0000001a,
+0x020,0x00000043,
+0x01f,0x0000001b,
+0x020,0x00000023,
+0x01f,0x0000001c,
+0x020,0x00000003,
+0x01f,0x0000001d,
+0x020,0x000001e3,
+0x01f,0x0000001e,
+0x020,0x000001c3,
+0x01f,0x0000001f,
+0x020,0x000001a3,
+0x01f,0x00000020,
+0x020,0x00000183,
+0x01f,0x00000021,
+0x020,0x00000163,
+0x01f,0x00000022,
+0x020,0x00000143,
+0x01f,0x00000023,
+0x020,0x00000123,
+0x01f,0x00000024,
+0x020,0x00000103,
+0x023,0x00000203,
+0x024,0x00000200,
+0x00b,0x000001ba,
+0x02c,0x000003d7,
+0x02d,0x00000ff0,
+0x000,0x00000037,
+0x004,0x00000160,
+0x007,0x00000080,
+0x002,0x0000088d,
+0x0fe,0x00000000,
+0x0fe,0x00000000,
+0x016,0x00000200,
+0x016,0x00000380,
+0x016,0x00000020,
+0x016,0x000001a0,
+0x000,0x000000bf,
+0x00d,0x0000001f,
+0x00d,0x00000c9f,
+0x002,0x0000004d,
+0x000,0x00000cbf,
+0x004,0x00000975,
+0x007,0x00000700,
+};
+
+u32 Rtl8192UsbRadioB_Array[] = {
+0x019,0x00000003,
+0x000,0x000000bf,
+0x001,0x000006e0,
+0x002,0x0000004c,
+0x003,0x000007f1,
+0x004,0x00000975,
+0x005,0x00000c58,
+0x006,0x00000ae6,
+0x007,0x000000ca,
+0x008,0x00000e1c,
+0x000,0x000000b7,
+0x00a,0x00000850,
+0x000,0x000000bf,
+0x00b,0x000001ba,
+0x00c,0x00000240,
+0x00e,0x00000020,
+0x015,0x00000f80,
+0x016,0x00000020,
+0x017,0x00000597,
+0x018,0x0000050a,
+0x01a,0x00000e00,
+0x01b,0x00000f5e,
+0x01d,0x00000607,
+0x01e,0x000006cc,
+0x00b,0x000001ba,
+0x023,0x00000203,
+0x024,0x00000200,
+0x000,0x00000037,
+0x004,0x00000160,
+0x016,0x00000200,
+0x016,0x00000380,
+0x016,0x00000020,
+0x016,0x000001a0,
+0x00d,0x00000ccc,
+0x000,0x000000bf,
+0x002,0x0000004d,
+0x000,0x00000cbf,
+0x004,0x00000975,
+0x007,0x00000700,
+};
+
+u32 Rtl8192UsbRadioC_Array[] = {
+0x0, };
+
+u32 Rtl8192UsbRadioD_Array[] = {
+0x0, };
+
+u32 Rtl8192UsbMACPHY_Array[] = {
+0x03c,0xffff0000,0x00000f0f,
+0x340,0xffffffff,0x161a1a1a,
+0x344,0xffffffff,0x12121416,
+0x348,0x0000ffff,0x00001818,
+0x12c,0xffffffff,0x04000802,
+0x318,0x00000fff,0x00000100,
+};
+
+u32 Rtl8192UsbMACPHY_Array_PG[] = {
+0x03c,0xffff0000,0x00000f0f,
+0xe00,0xffffffff,0x06090909,
+0xe04,0xffffffff,0x00030306,
+0xe08,0x0000ff00,0x00000000,
+0xe10,0xffffffff,0x0a0c0d0f,
+0xe14,0xffffffff,0x06070809,
+0xe18,0xffffffff,0x0a0c0d0f,
+0xe1c,0xffffffff,0x06070809,
+0x12c,0xffffffff,0x04000802,
+0x318,0x00000fff,0x00000800,
+};
+
+u32 Rtl8192UsbAGCTAB_Array[] = {
+0xc78,0x7d000001,
+0xc78,0x7d010001,
+0xc78,0x7d020001,
+0xc78,0x7d030001,
+0xc78,0x7d040001,
+0xc78,0x7d050001,
+0xc78,0x7c060001,
+0xc78,0x7b070001,
+0xc78,0x7a080001,
+0xc78,0x79090001,
+0xc78,0x780a0001,
+0xc78,0x770b0001,
+0xc78,0x760c0001,
+0xc78,0x750d0001,
+0xc78,0x740e0001,
+0xc78,0x730f0001,
+0xc78,0x72100001,
+0xc78,0x71110001,
+0xc78,0x70120001,
+0xc78,0x6f130001,
+0xc78,0x6e140001,
+0xc78,0x6d150001,
+0xc78,0x6c160001,
+0xc78,0x6b170001,
+0xc78,0x6a180001,
+0xc78,0x69190001,
+0xc78,0x681a0001,
+0xc78,0x671b0001,
+0xc78,0x661c0001,
+0xc78,0x651d0001,
+0xc78,0x641e0001,
+0xc78,0x491f0001,
+0xc78,0x48200001,
+0xc78,0x47210001,
+0xc78,0x46220001,
+0xc78,0x45230001,
+0xc78,0x44240001,
+0xc78,0x43250001,
+0xc78,0x28260001,
+0xc78,0x27270001,
+0xc78,0x26280001,
+0xc78,0x25290001,
+0xc78,0x242a0001,
+0xc78,0x232b0001,
+0xc78,0x222c0001,
+0xc78,0x212d0001,
+0xc78,0x202e0001,
+0xc78,0x0a2f0001,
+0xc78,0x08300001,
+0xc78,0x06310001,
+0xc78,0x05320001,
+0xc78,0x04330001,
+0xc78,0x03340001,
+0xc78,0x02350001,
+0xc78,0x01360001,
+0xc78,0x00370001,
+0xc78,0x00380001,
+0xc78,0x00390001,
+0xc78,0x003a0001,
+0xc78,0x003b0001,
+0xc78,0x003c0001,
+0xc78,0x003d0001,
+0xc78,0x003e0001,
+0xc78,0x003f0001,
+0xc78,0x7d400001,
+0xc78,0x7d410001,
+0xc78,0x7d420001,
+0xc78,0x7d430001,
+0xc78,0x7d440001,
+0xc78,0x7d450001,
+0xc78,0x7c460001,
+0xc78,0x7b470001,
+0xc78,0x7a480001,
+0xc78,0x79490001,
+0xc78,0x784a0001,
+0xc78,0x774b0001,
+0xc78,0x764c0001,
+0xc78,0x754d0001,
+0xc78,0x744e0001,
+0xc78,0x734f0001,
+0xc78,0x72500001,
+0xc78,0x71510001,
+0xc78,0x70520001,
+0xc78,0x6f530001,
+0xc78,0x6e540001,
+0xc78,0x6d550001,
+0xc78,0x6c560001,
+0xc78,0x6b570001,
+0xc78,0x6a580001,
+0xc78,0x69590001,
+0xc78,0x685a0001,
+0xc78,0x675b0001,
+0xc78,0x665c0001,
+0xc78,0x655d0001,
+0xc78,0x645e0001,
+0xc78,0x495f0001,
+0xc78,0x48600001,
+0xc78,0x47610001,
+0xc78,0x46620001,
+0xc78,0x45630001,
+0xc78,0x44640001,
+0xc78,0x43650001,
+0xc78,0x28660001,
+0xc78,0x27670001,
+0xc78,0x26680001,
+0xc78,0x25690001,
+0xc78,0x246a0001,
+0xc78,0x236b0001,
+0xc78,0x226c0001,
+0xc78,0x216d0001,
+0xc78,0x206e0001,
+0xc78,0x0a6f0001,
+0xc78,0x08700001,
+0xc78,0x06710001,
+0xc78,0x05720001,
+0xc78,0x04730001,
+0xc78,0x03740001,
+0xc78,0x02750001,
+0xc78,0x01760001,
+0xc78,0x00770001,
+0xc78,0x00780001,
+0xc78,0x00790001,
+0xc78,0x007a0001,
+0xc78,0x007b0001,
+0xc78,0x007c0001,
+0xc78,0x007d0001,
+0xc78,0x007e0001,
+0xc78,0x007f0001,
+0xc78,0x2e00001e,
+0xc78,0x2e01001e,
+0xc78,0x2e02001e,
+0xc78,0x2e03001e,
+0xc78,0x2e04001e,
+0xc78,0x2e05001e,
+0xc78,0x3006001e,
+0xc78,0x3407001e,
+0xc78,0x3908001e,
+0xc78,0x3c09001e,
+0xc78,0x3f0a001e,
+0xc78,0x420b001e,
+0xc78,0x440c001e,
+0xc78,0x450d001e,
+0xc78,0x460e001e,
+0xc78,0x460f001e,
+0xc78,0x4710001e,
+0xc78,0x4811001e,
+0xc78,0x4912001e,
+0xc78,0x4a13001e,
+0xc78,0x4b14001e,
+0xc78,0x4b15001e,
+0xc78,0x4c16001e,
+0xc78,0x4d17001e,
+0xc78,0x4e18001e,
+0xc78,0x4f19001e,
+0xc78,0x4f1a001e,
+0xc78,0x501b001e,
+0xc78,0x511c001e,
+0xc78,0x521d001e,
+0xc78,0x521e001e,
+0xc78,0x531f001e,
+0xc78,0x5320001e,
+0xc78,0x5421001e,
+0xc78,0x5522001e,
+0xc78,0x5523001e,
+0xc78,0x5624001e,
+0xc78,0x5725001e,
+0xc78,0x5726001e,
+0xc78,0x5827001e,
+0xc78,0x5828001e,
+0xc78,0x5929001e,
+0xc78,0x592a001e,
+0xc78,0x5a2b001e,
+0xc78,0x5b2c001e,
+0xc78,0x5c2d001e,
+0xc78,0x5c2e001e,
+0xc78,0x5d2f001e,
+0xc78,0x5e30001e,
+0xc78,0x5f31001e,
+0xc78,0x6032001e,
+0xc78,0x6033001e,
+0xc78,0x6134001e,
+0xc78,0x6235001e,
+0xc78,0x6336001e,
+0xc78,0x6437001e,
+0xc78,0x6438001e,
+0xc78,0x6539001e,
+0xc78,0x663a001e,
+0xc78,0x673b001e,
+0xc78,0x673c001e,
+0xc78,0x683d001e,
+0xc78,0x693e001e,
+0xc78,0x6a3f001e,
+};
diff --git a/drivers/staging/rtl8192su/r819xU_firmware_img.h b/drivers/staging/rtl8192su/r819xU_firmware_img.h
new file mode 100644
index 000000000000..d9d9515a1e61
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_firmware_img.h
@@ -0,0 +1,35 @@
+#ifndef IMG_H
+#define IMG_H
+
+#define BOOT_ARR_LEN 344
+#define MAIN_ARR_LEN 45136
+#define DATA_ARR_LEN 796
+#define MACPHY_Array_PGLength 30
+#define PHY_REG_1T2RArrayLength 296
+#define AGCTAB_ArrayLength 384
+#define MACPHY_ArrayLength 18
+
+#define RadioA_ArrayLength 246
+#define RadioB_ArrayLength 78
+#define RadioC_ArrayLength 1
+#define RadioD_ArrayLength 1
+#define PHY_REGArrayLength 1
+
+
+extern u8 rtl8190_fwboot_array[BOOT_ARR_LEN];
+extern u8 rtl8190_fwmain_array[MAIN_ARR_LEN];
+extern u8 rtl8190_fwdata_array[DATA_ARR_LEN];
+
+extern u32 Rtl8192UsbPHY_REGArray[];
+extern u32 Rtl8192UsbPHY_REG_1T2RArray[];
+extern u32 Rtl8192UsbRadioA_Array[];
+extern u32 Rtl8192UsbRadioB_Array[];
+extern u32 Rtl8192UsbRadioC_Array[];
+extern u32 Rtl8192UsbRadioD_Array[];
+extern u32 Rtl8192UsbMACPHY_Array[];
+extern u32 Rtl8192UsbMACPHY_Array_PG[];
+extern u32 Rtl8192UsbAGCTAB_Array[];
+
+
+
+#endif
diff --git a/drivers/staging/rtl8192su/r819xU_phy.c b/drivers/staging/rtl8192su/r819xU_phy.c
new file mode 100644
index 000000000000..00497d313f9b
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_phy.c
@@ -0,0 +1,1826 @@
+#include "r8192U.h"
+#include "r8192U_hw.h"
+#include "r819xU_phy.h"
+#include "r819xU_phyreg.h"
+#include "r8190_rtl8256.h"
+#include "r8192U_dm.h"
+#include "r819xU_firmware_img.h"
+
+#ifdef ENABLE_DOT11D
+#include "dot11d.h"
+#endif
+static u32 RF_CHANNEL_TABLE_ZEBRA[] = {
+ 0,
+ 0x085c, //2412 1
+ 0x08dc, //2417 2
+ 0x095c, //2422 3
+ 0x09dc, //2427 4
+ 0x0a5c, //2432 5
+ 0x0adc, //2437 6
+ 0x0b5c, //2442 7
+ 0x0bdc, //2447 8
+ 0x0c5c, //2452 9
+ 0x0cdc, //2457 10
+ 0x0d5c, //2462 11
+ 0x0ddc, //2467 12
+ 0x0e5c, //2472 13
+ 0x0f72, //2484
+};
+
+
+#define rtl819XPHY_REG_1T2RArray Rtl8192UsbPHY_REG_1T2RArray
+#define rtl819XMACPHY_Array_PG Rtl8192UsbMACPHY_Array_PG
+#define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array
+#define rtl819XRadioA_Array Rtl8192UsbRadioA_Array
+#define rtl819XRadioB_Array Rtl8192UsbRadioB_Array
+#define rtl819XRadioC_Array Rtl8192UsbRadioC_Array
+#define rtl819XRadioD_Array Rtl8192UsbRadioD_Array
+#define rtl819XAGCTAB_Array Rtl8192UsbAGCTAB_Array
+
+/******************************************************************************
+ *function: This function read BB parameters from Header file we gen,
+ * and do register read/write
+ * input: u32 dwBitMask //taget bit pos in the addr to be modified
+ * output: none
+ * return: u32 return the shift bit bit position of the mask
+ * ****************************************************************************/
+u32 rtl8192_CalculateBitShift(u32 dwBitMask)
+{
+ u32 i;
+ for (i=0; i<=31; i++)
+ {
+ if (((dwBitMask>>i)&0x1) == 1)
+ break;
+ }
+ return i;
+}
+/******************************************************************************
+ *function: This function check different RF type to execute legal judgement. If RF Path is illegal, we will return false.
+ * input: none
+ * output: none
+ * return: 0(illegal, false), 1(legal,true)
+ * ***************************************************************************/
+u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath)
+{
+ u8 ret = 1;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ if (priv->rf_type == RF_2T4R)
+ ret = 0;
+ else if (priv->rf_type == RF_1T2R)
+ {
+ if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B)
+ ret = 1;
+ else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D)
+ ret = 0;
+ }
+ return ret;
+}
+/******************************************************************************
+ *function: This function set specific bits to BB register
+ * input: net_device dev
+ * u32 dwRegAddr //target addr to be modified
+ * u32 dwBitMask //taget bit pos in the addr to be modified
+ * u32 dwData //value to be write
+ * output: none
+ * return: none
+ * notice:
+ * ****************************************************************************/
+void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData)
+{
+
+ u32 OriginalValue, BitShift, NewValue;
+
+ if(dwBitMask!= bMaskDWord)
+ {//if not "double word" write
+ OriginalValue = read_nic_dword(dev, dwRegAddr);
+ BitShift = rtl8192_CalculateBitShift(dwBitMask);
+ NewValue = (((OriginalValue) & (~dwBitMask)) | (dwData << BitShift));
+ write_nic_dword(dev, dwRegAddr, NewValue);
+ }else
+ write_nic_dword(dev, dwRegAddr, dwData);
+ return;
+}
+/******************************************************************************
+ *function: This function reads specific bits from BB register
+ * input: net_device dev
+ * u32 dwRegAddr //target addr to be readback
+ * u32 dwBitMask //taget bit pos in the addr to be readback
+ * output: none
+ * return: u32 Data //the readback register value
+ * notice:
+ * ****************************************************************************/
+u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask)
+{
+ u32 Ret = 0, OriginalValue, BitShift;
+
+ OriginalValue = read_nic_dword(dev, dwRegAddr);
+ BitShift = rtl8192_CalculateBitShift(dwBitMask);
+ Ret =(OriginalValue & dwBitMask) >> BitShift;
+
+ return (Ret);
+}
+static u32 phy_FwRFSerialRead( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset );
+
+static void phy_FwRFSerialWrite( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data);
+
+/******************************************************************************
+ *function: This function read register from RF chip
+ * input: net_device dev
+ * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
+ * u32 Offset //target address to be read
+ * output: none
+ * return: u32 readback value
+ * notice: There are three types of serial operations:(1) Software serial write.(2)Hardware LSSI-Low Speed Serial Interface.(3)Hardware HSSI-High speed serial write. Driver here need to implement (1) and (2)---need more spec for this information.
+ * ****************************************************************************/
+u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 ret = 0;
+ u32 NewOffset = 0;
+ BB_REGISTER_DEFINITION_T* pPhyReg = &priv->PHYRegDef[eRFPath];
+ rtl8192_setBBreg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData, 0);
+ //make sure RF register offset is correct
+ Offset &= 0x3f;
+
+ //switch page for 8256 RF IC
+ if (priv->rf_chip == RF_8256)
+ {
+ if (Offset >= 31)
+ {
+ priv->RfReg0Value[eRFPath] |= 0x140;
+ //Switch to Reg_Mode2 for Reg 31-45
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) );
+ //modify offset
+ NewOffset = Offset -30;
+ }
+ else if (Offset >= 16)
+ {
+ priv->RfReg0Value[eRFPath] |= 0x100;
+ priv->RfReg0Value[eRFPath] &= (~0x40);
+ //Switch to Reg_Mode 1 for Reg16-30
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) );
+
+ NewOffset = Offset - 15;
+ }
+ else
+ NewOffset = Offset;
+ }
+ else
+ {
+ RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n");
+ NewOffset = Offset;
+ }
+ //put desired read addr to LSSI control Register
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset);
+ //Issue a posedge trigger
+ //
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0);
+ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1);
+
+
+ // TODO: we should not delay such a long time. Ask help from SD3
+ msleep(1);
+
+ ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData);
+
+
+ // Switch back to Reg_Mode0;
+ if(priv->rf_chip == RF_8256)
+ {
+ priv->RfReg0Value[eRFPath] &= 0xebf;
+
+ rtl8192_setBBreg(
+ dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16));
+ }
+
+ return ret;
+
+}
+
+/******************************************************************************
+ *function: This function write data to RF register
+ * input: net_device dev
+ * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
+ * u32 Offset //target address to be written
+ * u32 Data //The new register data to be written
+ * output: none
+ * return: none
+ * notice: For RF8256 only.
+ ===========================================================
+ *Reg Mode RegCTL[1] RegCTL[0] Note
+ * (Reg00[12]) (Reg00[10])
+ *===========================================================
+ *Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf)
+ *------------------------------------------------------------------
+ *Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf)
+ *------------------------------------------------------------------
+ * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf)
+ *------------------------------------------------------------------
+ * ****************************************************************************/
+void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 DataAndAddr = 0, NewOffset = 0;
+ BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath];
+
+ Offset &= 0x3f;
+ //spin_lock_irqsave(&priv->rf_lock, flags);
+// down(&priv->rf_sem);
+ if (priv->rf_chip == RF_8256)
+ {
+
+ if (Offset >= 31)
+ {
+ priv->RfReg0Value[eRFPath] |= 0x140;
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16));
+ NewOffset = Offset - 30;
+ }
+ else if (Offset >= 16)
+ {
+ priv->RfReg0Value[eRFPath] |= 0x100;
+ priv->RfReg0Value[eRFPath] &= (~0x40);
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16));
+ NewOffset = Offset - 15;
+ }
+ else
+ NewOffset = Offset;
+ }
+ else
+ {
+ RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n");
+ NewOffset = Offset;
+ }
+
+ // Put write addr in [5:0] and write data in [31:16]
+ DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+
+ // Write Operation
+ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
+
+
+ if(Offset==0x0)
+ priv->RfReg0Value[eRFPath] = Data;
+
+ // Switch back to Reg_Mode0;
+ if(priv->rf_chip == RF_8256)
+ {
+ if(Offset != 0)
+ {
+ priv->RfReg0Value[eRFPath] &= 0xebf;
+ rtl8192_setBBreg(
+ dev,
+ pPhyReg->rf3wireOffset,
+ bMaskDWord,
+ (priv->RfReg0Value[eRFPath] << 16));
+ }
+ }
+ //spin_unlock_irqrestore(&priv->rf_lock, flags);
+// up(&priv->rf_sem);
+ return;
+}
+
+/******************************************************************************
+ *function: This function set specific bits to RF register
+ * input: net_device dev
+ * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
+ * u32 RegAddr //target addr to be modified
+ * u32 BitMask //taget bit pos in the addr to be modified
+ * u32 Data //value to be write
+ * output: none
+ * return: none
+ * notice:
+ * ****************************************************************************/
+void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 Original_Value, BitShift, New_Value;
+// u8 time = 0;
+
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ return;
+
+ if (priv->Rf_Mode == RF_OP_By_FW)
+ {
+ if (BitMask != bMask12Bits) // RF data is 12 bits only
+ {
+ Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr);
+ BitShift = rtl8192_CalculateBitShift(BitMask);
+ New_Value = ((Original_Value) & (~BitMask)) | (Data<< BitShift);
+
+ phy_FwRFSerialWrite(dev, eRFPath, RegAddr, New_Value);
+ }else
+ phy_FwRFSerialWrite(dev, eRFPath, RegAddr, Data);
+
+ udelay(200);
+
+ }
+ else
+ {
+ if (BitMask != bMask12Bits) // RF data is 12 bits only
+ {
+ Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr);
+ BitShift = rtl8192_CalculateBitShift(BitMask);
+ New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift));
+
+ rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, New_Value);
+ }else
+ rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, Data);
+ }
+ return;
+}
+
+/******************************************************************************
+ *function: This function reads specific bits from RF register
+ * input: net_device dev
+ * u32 RegAddr //target addr to be readback
+ * u32 BitMask //taget bit pos in the addr to be readback
+ * output: none
+ * return: u32 Data //the readback register value
+ * notice:
+ * ****************************************************************************/
+u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask)
+{
+ u32 Original_Value, Readback_Value, BitShift;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+
+ if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+ return 0;
+ if (priv->Rf_Mode == RF_OP_By_FW)
+ {
+ Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr);
+ BitShift = rtl8192_CalculateBitShift(BitMask);
+ Readback_Value = (Original_Value & BitMask) >> BitShift;
+ udelay(200);
+ return (Readback_Value);
+ }
+ else
+ {
+ Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr);
+ BitShift = rtl8192_CalculateBitShift(BitMask);
+ Readback_Value = (Original_Value & BitMask) >> BitShift;
+ return (Readback_Value);
+ }
+}
+/******************************************************************************
+ *function: We support firmware to execute RF-R/W.
+ * input: dev
+ * output: none
+ * return: none
+ * notice:
+ * ***************************************************************************/
+static u32
+phy_FwRFSerialRead(
+ struct net_device* dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset )
+{
+ u32 retValue = 0;
+ u32 Data = 0;
+ u8 time = 0;
+ //DbgPrint("FW RF CTRL\n\r");
+ /* 2007/11/02 MH Firmware RF Write control. By Francis' suggestion, we can
+ not execute the scheme in the initial step. Otherwise, RF-R/W will waste
+ much time. This is only for site survey. */
+ // 1. Read operation need not insert data. bit 0-11
+ //Data &= bMask12Bits;
+ // 2. Write RF register address. Bit 12-19
+ Data |= ((Offset&0xFF)<<12);
+ // 3. Write RF path. bit 20-21
+ Data |= ((eRFPath&0x3)<<20);
+ // 4. Set RF read indicator. bit 22=0
+ //Data |= 0x00000;
+ // 5. Trigger Fw to operate the command. bit 31
+ Data |= 0x80000000;
+ // 6. We can not execute read operation if bit 31 is 1.
+ while (read_nic_dword(dev, QPNR)&0x80000000)
+ {
+ // If FW can not finish RF-R/W for more than ?? times. We must reset FW.
+ if (time++ < 100)
+ {
+ //DbgPrint("FW not finish RF-R Time=%d\n\r", time);
+ udelay(10);
+ }
+ else
+ break;
+ }
+ // 7. Execute read operation.
+ write_nic_dword(dev, QPNR, Data);
+ // 8. Check if firmawre send back RF content.
+ while (read_nic_dword(dev, QPNR)&0x80000000)
+ {
+ // If FW can not finish RF-R/W for more than ?? times. We must reset FW.
+ if (time++ < 100)
+ {
+ //DbgPrint("FW not finish RF-W Time=%d\n\r", time);
+ udelay(10);
+ }
+ else
+ return (0);
+ }
+ retValue = read_nic_dword(dev, RF_DATA);
+
+ return (retValue);
+
+} /* phy_FwRFSerialRead */
+
+/******************************************************************************
+ *function: We support firmware to execute RF-R/W.
+ * input: dev
+ * output: none
+ * return: none
+ * notice:
+ * ***************************************************************************/
+static void
+phy_FwRFSerialWrite(
+ struct net_device* dev,
+ RF90_RADIO_PATH_E eRFPath,
+ u32 Offset,
+ u32 Data )
+{
+ u8 time = 0;
+
+ //DbgPrint("N FW RF CTRL RF-%d OF%02x DATA=%03x\n\r", eRFPath, Offset, Data);
+ /* 2007/11/02 MH Firmware RF Write control. By Francis' suggestion, we can
+ not execute the scheme in the initial step. Otherwise, RF-R/W will waste
+ much time. This is only for site survey. */
+
+ // 1. Set driver write bit and 12 bit data. bit 0-11
+ //Data &= bMask12Bits; // Done by uper layer.
+ // 2. Write RF register address. bit 12-19
+ Data |= ((Offset&0xFF)<<12);
+ // 3. Write RF path. bit 20-21
+ Data |= ((eRFPath&0x3)<<20);
+ // 4. Set RF write indicator. bit 22=1
+ Data |= 0x400000;
+ // 5. Trigger Fw to operate the command. bit 31=1
+ Data |= 0x80000000;
+
+ // 6. Write operation. We can not write if bit 31 is 1.
+ while (read_nic_dword(dev, QPNR)&0x80000000)
+ {
+ // If FW can not finish RF-R/W for more than ?? times. We must reset FW.
+ if (time++ < 100)
+ {
+ //DbgPrint("FW not finish RF-W Time=%d\n\r", time);
+ udelay(10);
+ }
+ else
+ break;
+ }
+ // 7. No matter check bit. We always force the write. Because FW will
+ // not accept the command.
+ write_nic_dword(dev, QPNR, Data);
+ /* 2007/11/02 MH Acoording to test, we must delay 20us to wait firmware
+ to finish RF write operation. */
+ /* 2008/01/17 MH We support delay in firmware side now. */
+ //delay_us(20);
+
+} /* phy_FwRFSerialWrite */
+
+
+/******************************************************************************
+ *function: This function read BB parameters from Header file we gen,
+ * and do register read/write
+ * input: dev
+ * output: none
+ * return: none
+ * notice: BB parameters may change all the time, so please make
+ * sure it has been synced with the newest.
+ * ***************************************************************************/
+void rtl8192_phy_configmac(struct net_device* dev)
+{
+ u32 dwArrayLen = 0, i;
+ u32* pdwArray = NULL;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if(priv->btxpowerdata_readfromEEPORM)
+ {
+ RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n");
+ dwArrayLen = MACPHY_Array_PGLength;
+ pdwArray = rtl819XMACPHY_Array_PG;
+
+ }
+ else
+ {
+ RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array\n");
+ dwArrayLen = MACPHY_ArrayLength;
+ pdwArray = rtl819XMACPHY_Array;
+ }
+ for(i = 0; i<dwArrayLen; i=i+3){
+ if(pdwArray[i] == 0x318)
+ {
+ pdwArray[i+2] = 0x00000800;
+ //DbgPrint("ptrArray[i], ptrArray[i+1], ptrArray[i+2] = %x, %x, %x\n",
+ // ptrArray[i], ptrArray[i+1], ptrArray[i+2]);
+ }
+
+ RT_TRACE(COMP_DBG, "The Rtl8190MACPHY_Array[0] is %x Rtl8190MACPHY_Array[1] is %x Rtl8190MACPHY_Array[2] is %x\n",
+ pdwArray[i], pdwArray[i+1], pdwArray[i+2]);
+ rtl8192_setBBreg(dev, pdwArray[i], pdwArray[i+1], pdwArray[i+2]);
+ }
+ return;
+
+}
+
+/******************************************************************************
+ *function: This function do dirty work
+ * input: dev
+ * output: none
+ * return: none
+ * notice: BB parameters may change all the time, so please make
+ * sure it has been synced with the newest.
+ * ***************************************************************************/
+
+void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType)
+{
+ u32 i;
+
+#ifdef TO_DO_LIST
+ u32 *rtl8192PhyRegArrayTable = NULL, *rtl8192AgcTabArrayTable = NULL;
+ if(Adapter->bInHctTest)
+ {
+ PHY_REGArrayLen = PHY_REGArrayLengthDTM;
+ AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM;
+ Rtl8190PHY_REGArray_Table = Rtl819XPHY_REGArrayDTM;
+ Rtl8190AGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM;
+ }
+#endif
+ if (ConfigType == BaseBand_Config_PHY_REG)
+ {
+ for (i=0; i<PHY_REG_1T2RArrayLength; i+=2)
+ {
+ rtl8192_setBBreg(dev, rtl819XPHY_REG_1T2RArray[i], bMaskDWord, rtl819XPHY_REG_1T2RArray[i+1]);
+ RT_TRACE(COMP_DBG, "i: %x, The Rtl819xUsbPHY_REGArray[0] is %x Rtl819xUsbPHY_REGArray[1] is %x \n",i, rtl819XPHY_REG_1T2RArray[i], rtl819XPHY_REG_1T2RArray[i+1]);
+ }
+ }
+ else if (ConfigType == BaseBand_Config_AGC_TAB)
+ {
+ for (i=0; i<AGCTAB_ArrayLength; i+=2)
+ {
+ rtl8192_setBBreg(dev, rtl819XAGCTAB_Array[i], bMaskDWord, rtl819XAGCTAB_Array[i+1]);
+ RT_TRACE(COMP_DBG, "i:%x, The rtl819XAGCTAB_Array[0] is %x rtl819XAGCTAB_Array[1] is %x \n",i, rtl819XAGCTAB_Array[i], rtl819XAGCTAB_Array[i+1]);
+ }
+ }
+ return;
+
+
+}
+/******************************************************************************
+ *function: This function initialize Register definition offset for Radio Path
+ * A/B/C/D
+ * input: net_device dev
+ * output: none
+ * return: none
+ * notice: Initialization value here is constant and it should never be changed
+ * ***************************************************************************/
+void rtl8192_InitBBRFRegDef(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+// RF Interface Sowrtware Control
+ priv->PHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 LSBs if read 32-bit from 0x870
+ priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872)
+ priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 LSBs if read 32-bit from 0x874
+ priv->PHYRegDef[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876)
+
+ // RF Interface Readback Value
+ priv->PHYRegDef[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; // 16 LSBs if read 32-bit from 0x8E0
+ priv->PHYRegDef[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2)
+ priv->PHYRegDef[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 LSBs if read 32-bit from 0x8E4
+ priv->PHYRegDef[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6)
+
+ // RF Interface Output (and Enable)
+ priv->PHYRegDef[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x860
+ priv->PHYRegDef[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x864
+ priv->PHYRegDef[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x868
+ priv->PHYRegDef[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x86C
+
+ // RF Interface (Output and) Enable
+ priv->PHYRegDef[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862)
+ priv->PHYRegDef[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866)
+ priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86A (16-bit for 0x86A)
+ priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86C (16-bit for 0x86E)
+
+ //Addr of LSSI. Wirte RF register by driver
+ priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; //LSSI Parameter
+ priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter;
+ priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter;
+ priv->PHYRegDef[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter;
+
+ // RF parameter
+ priv->PHYRegDef[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; //BB Band Select
+ priv->PHYRegDef[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter;
+ priv->PHYRegDef[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter;
+ priv->PHYRegDef[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter;
+
+ // Tx AGC Gain Stage (same for all path. Should we remove this?)
+ priv->PHYRegDef[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+ priv->PHYRegDef[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+ priv->PHYRegDef[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+ priv->PHYRegDef[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
+
+ // Tranceiver A~D HSSI Parameter-1
+ priv->PHYRegDef[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; //wire control parameter1
+ priv->PHYRegDef[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; //wire control parameter1
+ priv->PHYRegDef[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; //wire control parameter1
+ priv->PHYRegDef[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; //wire control parameter1
+
+ // Tranceiver A~D HSSI Parameter-2
+ priv->PHYRegDef[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; //wire control parameter2
+ priv->PHYRegDef[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; //wire control parameter2
+ priv->PHYRegDef[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; //wire control parameter2
+ priv->PHYRegDef[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; //wire control parameter1
+
+ // RF switch Control
+ priv->PHYRegDef[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; //TR/Ant switch control
+ priv->PHYRegDef[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl;
+ priv->PHYRegDef[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl;
+ priv->PHYRegDef[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl;
+
+ // AGC control 1
+ priv->PHYRegDef[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1;
+ priv->PHYRegDef[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1;
+ priv->PHYRegDef[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1;
+ priv->PHYRegDef[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1;
+
+ // AGC control 2
+ priv->PHYRegDef[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2;
+ priv->PHYRegDef[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2;
+ priv->PHYRegDef[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2;
+ priv->PHYRegDef[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2;
+
+ // RX AFE control 1
+ priv->PHYRegDef[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance;
+
+ // RX AFE control 1
+ priv->PHYRegDef[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE;
+ priv->PHYRegDef[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE;
+ priv->PHYRegDef[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE;
+ priv->PHYRegDef[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE;
+
+ // Tx AFE control 1
+ priv->PHYRegDef[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance;
+ priv->PHYRegDef[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance;
+
+ // Tx AFE control 2
+ priv->PHYRegDef[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE;
+ priv->PHYRegDef[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE;
+ priv->PHYRegDef[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE;
+ priv->PHYRegDef[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE;
+
+ // Tranceiver LSSI Readback
+ priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack;
+ priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack;
+ priv->PHYRegDef[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack;
+ priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack;
+
+}
+/******************************************************************************
+ *function: This function is to write register and then readback to make sure whether BB and RF is OK
+ * input: net_device dev
+ * HW90_BLOCK_E CheckBlock
+ * RF90_RADIO_PATH_E eRFPath //only used when checkblock is HW90_BLOCK_RF
+ * output: none
+ * return: return whether BB and RF is ok(0:OK; 1:Fail)
+ * notice: This function may be removed in the ASIC
+ * ***************************************************************************/
+u8 rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath)
+{
+// struct r8192_priv *priv = ieee80211_priv(dev);
+// BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath];
+ u8 ret = 0;
+ u32 i, CheckTimes = 4, dwRegRead = 0;
+ u32 WriteAddr[4];
+ u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f};
+ // Initialize register address offset to be checked
+ WriteAddr[HW90_BLOCK_MAC] = 0x100;
+ WriteAddr[HW90_BLOCK_PHY0] = 0x900;
+ WriteAddr[HW90_BLOCK_PHY1] = 0x800;
+ WriteAddr[HW90_BLOCK_RF] = 0x3;
+ RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __FUNCTION__, CheckBlock);
+ for(i=0 ; i < CheckTimes ; i++)
+ {
+
+ //
+ // Write Data to register and readback
+ //
+ switch(CheckBlock)
+ {
+ case HW90_BLOCK_MAC:
+ RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write 0x100 here!");
+ break;
+
+ case HW90_BLOCK_PHY0:
+ case HW90_BLOCK_PHY1:
+ write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]);
+ dwRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]);
+ break;
+
+ case HW90_BLOCK_RF:
+ WriteData[i] &= 0xfff;
+ rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]);
+ // TODO: we should not delay for such a long time. Ask SD3
+ msleep(1);
+ dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits);
+ msleep(1);
+ break;
+
+ default:
+ ret = 1;
+ break;
+ }
+
+
+ //
+ // Check whether readback data is correct
+ //
+ if(dwRegRead != WriteData[i])
+ {
+ RT_TRACE((COMP_PHY|COMP_ERR), "====>error=====dwRegRead: %x, WriteData: %x \n", dwRegRead, WriteData[i]);
+ ret = 1;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+
+/******************************************************************************
+ *function: This function initialize BB&RF
+ * input: net_device dev
+ * output: none
+ * return: none
+ * notice: Initialization value may change all the time, so please make
+ * sure it has been synced with the newest.
+ * ***************************************************************************/
+void rtl8192_BB_Config_ParaFile(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 bRegValue = 0, eCheckItem = 0, rtStatus = 0;
+ u32 dwRegValue = 0;
+ /**************************************
+ //<1>Initialize BaseBand
+ **************************************/
+
+ /*--set BB Global Reset--*/
+ bRegValue = read_nic_byte(dev, BB_GLOBAL_RESET);
+ write_nic_byte(dev, BB_GLOBAL_RESET,(bRegValue|BB_GLOBAL_RESET_BIT));
+ mdelay(50);
+ /*---set BB reset Active---*/
+ dwRegValue = read_nic_dword(dev, CPU_GEN);
+ write_nic_dword(dev, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST)));
+
+ /*----Ckeck FPGAPHY0 and PHY1 board is OK----*/
+ // TODO: this function should be removed on ASIC , Emily 2007.2.2
+ for(eCheckItem=(HW90_BLOCK_E)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++)
+ {
+ rtStatus = rtl8192_phy_checkBBAndRF(dev, (HW90_BLOCK_E)eCheckItem, (RF90_RADIO_PATH_E)0); //don't care RF path
+ if(rtStatus != 0)
+ {
+ RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1);
+ return ;
+ }
+ }
+ /*---- Set CCK and OFDM Block "OFF"----*/
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn|bOFDMEn, 0x0);
+ /*----BB Register Initilazation----*/
+ //==m==>Set PHY REG From Header<==m==
+ rtl8192_phyConfigBB(dev, BaseBand_Config_PHY_REG);
+
+ /*----Set BB reset de-Active----*/
+ dwRegValue = read_nic_dword(dev, CPU_GEN);
+ write_nic_dword(dev, CPU_GEN, (dwRegValue|CPU_GEN_BB_RST));
+
+ /*----BB AGC table Initialization----*/
+ //==m==>Set PHY REG From Header<==m==
+ rtl8192_phyConfigBB(dev, BaseBand_Config_AGC_TAB);
+
+ /*----Enable XSTAL ----*/
+ write_nic_byte_E(dev, 0x5e, 0x00);
+ if (priv->card_8192_version == (u8)VERSION_819xU_A)
+ {
+ //Antenna gain offset from B/C/D to A
+ dwRegValue = (priv->AntennaTxPwDiff[1]<<4 | priv->AntennaTxPwDiff[0]);
+ rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC), dwRegValue);
+
+ //XSTALLCap
+ dwRegValue = priv->CrystalCap & 0xf;
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap, dwRegValue);
+ }
+
+ // Check if the CCK HighPower is turned ON.
+ // This is used to calculate PWDB.
+ priv->bCckHighPower = (u8)(rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter2, 0x200));
+ return;
+}
+/******************************************************************************
+ *function: This function initialize BB&RF
+ * input: net_device dev
+ * output: none
+ * return: none
+ * notice: Initialization value may change all the time, so please make
+ * sure it has been synced with the newest.
+ * ***************************************************************************/
+void rtl8192_BBConfig(struct net_device* dev)
+{
+ rtl8192_InitBBRFRegDef(dev);
+ //config BB&RF. As hardCode based initialization has not been well
+ //implemented, so use file first.FIXME:should implement it for hardcode?
+ rtl8192_BB_Config_ParaFile(dev);
+ return;
+}
+
+/******************************************************************************
+ *function: This function obtains the initialization value of Tx power Level offset
+ * input: net_device dev
+ * output: none
+ * return: none
+ * ***************************************************************************/
+void rtl8192_phy_getTxPower(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ priv->MCSTxPowerLevelOriginalOffset[0] =
+ read_nic_dword(dev, rTxAGC_Rate18_06);
+ priv->MCSTxPowerLevelOriginalOffset[1] =
+ read_nic_dword(dev, rTxAGC_Rate54_24);
+ priv->MCSTxPowerLevelOriginalOffset[2] =
+ read_nic_dword(dev, rTxAGC_Mcs03_Mcs00);
+ priv->MCSTxPowerLevelOriginalOffset[3] =
+ read_nic_dword(dev, rTxAGC_Mcs07_Mcs04);
+ priv->MCSTxPowerLevelOriginalOffset[4] =
+ read_nic_dword(dev, rTxAGC_Mcs11_Mcs08);
+ priv->MCSTxPowerLevelOriginalOffset[5] =
+ read_nic_dword(dev, rTxAGC_Mcs15_Mcs12);
+
+ // read rx initial gain
+ priv->DefaultInitialGain[0] = read_nic_byte(dev, rOFDM0_XAAGCCore1);
+ priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1);
+ priv->DefaultInitialGain[2] = read_nic_byte(dev, rOFDM0_XCAGCCore1);
+ priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1);
+ RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n",
+ priv->DefaultInitialGain[0], priv->DefaultInitialGain[1],
+ priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]);
+
+ // read framesync
+ priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3);
+ priv->framesyncC34 = read_nic_byte(dev, rOFDM0_RxDetector2);
+ RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n",
+ rOFDM0_RxDetector3, priv->framesync);
+
+ // read SIFS (save the value read fome MACPHY_REG.txt)
+ priv->SifsTime = read_nic_word(dev, SIFS);
+
+ return;
+}
+
+/******************************************************************************
+ *function: This function obtains the initialization value of Tx power Level offset
+ * input: net_device dev
+ * output: none
+ * return: none
+ * ***************************************************************************/
+void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 powerlevel = priv->TxPowerLevelCCK[channel-1];
+ u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1];
+
+ switch(priv->rf_chip)
+ {
+ case RF_8256:
+ PHY_SetRF8256CCKTxPower(dev, powerlevel); //need further implement
+ PHY_SetRF8256OFDMTxPower(dev, powerlevelOFDM24G);
+ break;
+ default:
+// case RF_8225:
+// case RF_8258:
+ RT_TRACE((COMP_PHY|COMP_ERR), "error RF chipID(8225 or 8258) in function %s()\n", __FUNCTION__);
+ break;
+ }
+ return;
+}
+
+/******************************************************************************
+ *function: This function check Rf chip to do RF config
+ * input: net_device dev
+ * output: none
+ * return: only 8256 is supported
+ * ***************************************************************************/
+void rtl8192_phy_RFConfig(struct net_device* dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ switch(priv->rf_chip)
+ {
+ case RF_8256:
+ PHY_RF8256_Config(dev);
+ break;
+ // case RF_8225:
+ // case RF_8258:
+ default:
+ RT_TRACE(COMP_ERR, "error chip id\n");
+ break;
+ }
+ return;
+}
+
+/******************************************************************************
+ *function: This function update Initial gain
+ * input: net_device dev
+ * output: none
+ * return: As Windows has not implemented this, wait for complement
+ * ***************************************************************************/
+void rtl8192_phy_updateInitGain(struct net_device* dev)
+{
+ return;
+}
+
+/******************************************************************************
+ *function: This function read RF parameters from general head file, and do RF 3-wire
+ * input: net_device dev
+ * output: none
+ * return: return code show if RF configuration is successful(0:pass, 1:fail)
+ * Note: Delay may be required for RF configuration
+ * ***************************************************************************/
+u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath)
+{
+
+ int i;
+ //u32* pRFArray;
+ u8 ret = 0;
+
+ switch(eRFPath){
+ case RF90_PATH_A:
+ for(i = 0;i<RadioA_ArrayLength; i=i+2){
+
+ if(rtl819XRadioA_Array[i] == 0xfe){
+ mdelay(100);
+ continue;
+ }
+ rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioA_Array[i], bMask12Bits, rtl819XRadioA_Array[i+1]);
+ mdelay(1);
+
+ }
+ break;
+ case RF90_PATH_B:
+ for(i = 0;i<RadioB_ArrayLength; i=i+2){
+
+ if(rtl819XRadioB_Array[i] == 0xfe){
+ mdelay(100);
+ continue;
+ }
+ rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioB_Array[i], bMask12Bits, rtl819XRadioB_Array[i+1]);
+ mdelay(1);
+
+ }
+ break;
+ case RF90_PATH_C:
+ for(i = 0;i<RadioC_ArrayLength; i=i+2){
+
+ if(rtl819XRadioC_Array[i] == 0xfe){
+ mdelay(100);
+ continue;
+ }
+ rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioC_Array[i], bMask12Bits, rtl819XRadioC_Array[i+1]);
+ mdelay(1);
+
+ }
+ break;
+ case RF90_PATH_D:
+ for(i = 0;i<RadioD_ArrayLength; i=i+2){
+
+ if(rtl819XRadioD_Array[i] == 0xfe){
+ mdelay(100);
+ continue;
+ }
+ rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioD_Array[i], bMask12Bits, rtl819XRadioD_Array[i+1]);
+ mdelay(1);
+
+ }
+ break;
+ default:
+ break;
+ }
+
+ return ret;;
+
+}
+/******************************************************************************
+ *function: This function set Tx Power of the channel
+ * input: struct net_device *dev
+ * u8 channel
+ * output: none
+ * return: none
+ * Note:
+ * ***************************************************************************/
+void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 powerlevel = priv->TxPowerLevelCCK[channel-1];
+ u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1];
+
+ switch(priv->rf_chip)
+ {
+ case RF_8225:
+#ifdef TO_DO_LIST
+ PHY_SetRF8225CckTxPower(Adapter, powerlevel);
+ PHY_SetRF8225OfdmTxPower(Adapter, powerlevelOFDM24G);
+#endif
+ break;
+
+ case RF_8256:
+ PHY_SetRF8256CCKTxPower(dev, powerlevel);
+ PHY_SetRF8256OFDMTxPower(dev, powerlevelOFDM24G);
+ break;
+
+ case RF_8258:
+ break;
+ default:
+ RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n");
+ break;
+ }
+ return;
+}
+
+/******************************************************************************
+ *function: This function set RF state on or off
+ * input: struct net_device *dev
+ * RT_RF_POWER_STATE eRFPowerState //Power State to set
+ * output: none
+ * return: none
+ * Note:
+ * ***************************************************************************/
+bool rtl8192_SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState)
+{
+ bool bResult = true;
+// u8 eRFPath;
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if(eRFPowerState == priv->ieee80211->eRFPowerState)
+ return false;
+
+ if(priv->SetRFPowerStateInProgress == true)
+ return false;
+
+ priv->SetRFPowerStateInProgress = true;
+
+ switch(priv->rf_chip)
+ {
+ case RF_8256:
+ switch( eRFPowerState )
+ {
+ case eRfOn:
+#if 0
+ rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); // 0x860[4]
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); // 0x88c[4]
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x3); // 0x880[6:5]
+ rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0x3); // 0xc04[3:0]
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x3); // 0xd04[3:0]
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0x7000, 0x3); // 0x884[14:12]
+ // for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ // PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x2);
+
+ //SwChnl(Adapter->ChannelID);
+#endif
+ //RF-A, RF-B
+ //enable RF-Chip A/B
+ rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); // 0x860[4]
+ //analog to digital on
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3);// 0x88c[9:8]
+ //digital to analog on
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x3); // 0x880[4:3]
+ //rx antenna on
+ rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, 0x3);// 0xc04[1:0]
+ //rx antenna on
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, 0x3);// 0xd04[1:0]
+ //analog to digital part2 on
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x3); // 0x880[6:5]
+
+ break;
+
+ case eRfSleep:
+
+ break;
+
+ case eRfOff:
+#if 0
+ rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); // 0x860[4]
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x0); // 0x88c[4]
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x0); // 0x880[6:5]
+ rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0); // 0xc04[3:0]
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0); // 0xd04[3:0]
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0x7000, 0x0); // 0x884[14:12]
+ // for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+ // PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+#endif
+ //RF-A, RF-B
+ //disable RF-Chip A/B
+ rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); // 0x860[4]
+ //analog to digital off, for power save
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0);// 0x88c[11:8]
+ //digital to analog off, for power save
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x0); // 0x880[4:3]
+ //rx antenna off
+ rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0xf, 0x0);// 0xc04[3:0]
+ //rx antenna off
+ rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0xf, 0x0);// 0xd04[3:0]
+ //analog to digital part2 off, for power save
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x0); // 0x880[6:5]
+
+ break;
+
+ default:
+ bResult = false;
+ RT_TRACE(COMP_ERR, "SetRFPowerState819xUsb(): unknow state to set: 0x%X!!!\n", eRFPowerState);
+ break;
+ }
+ break;
+ default:
+ RT_TRACE(COMP_ERR, "Not support rf_chip(%x)\n", priv->rf_chip);
+ break;
+ }
+#ifdef TO_DO_LIST
+ if(bResult)
+ {
+ // Update current RF state variable.
+ pHalData->eRFPowerState = eRFPowerState;
+ switch(pHalData->RFChipID )
+ {
+ case RF_8256:
+ switch(pHalData->eRFPowerState)
+ {
+ case eRfOff:
+ //
+ //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015
+ //
+ if(pMgntInfo->RfOffReason==RF_CHANGE_BY_IPS )
+ {
+ Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK);
+ }
+ else
+ {
+ // Turn off LED if RF is not ON.
+ Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF);
+ }
+ break;
+
+ case eRfOn:
+ // Turn on RF we are still linked, which might happen when
+ // we quickly turn off and on HW RF. 2006.05.12, by rcnjko.
+ if( pMgntInfo->bMediaConnect == TRUE )
+ {
+ Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK);
+ }
+ else
+ {
+ // Turn off LED if RF is not ON.
+ Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK);
+ }
+ break;
+
+ default:
+ // do nothing.
+ break;
+ }// Switch RF state
+ break;
+
+ default:
+ RT_TRACE(COMP_RF, DBG_LOUD, ("SetRFPowerState8190(): Unknown RF type\n"));
+ break;
+ }
+
+ }
+#endif
+ priv->SetRFPowerStateInProgress = false;
+
+ return bResult;
+}
+
+/****************************************************************************************
+ *function: This function set command table variable(struct SwChnlCmd).
+ * input: SwChnlCmd* CmdTable //table to be set.
+ * u32 CmdTableIdx //variable index in table to be set
+ * u32 CmdTableSz //table size.
+ * SwChnlCmdID CmdID //command ID to set.
+ * u32 Para1
+ * u32 Para2
+ * u32 msDelay
+ * output:
+ * return: true if finished, false otherwise
+ * Note:
+ * ************************************************************************************/
+u8 rtl8192_phy_SetSwChnlCmdArray(
+ SwChnlCmd* CmdTable,
+ u32 CmdTableIdx,
+ u32 CmdTableSz,
+ SwChnlCmdID CmdID,
+ u32 Para1,
+ u32 Para2,
+ u32 msDelay
+ )
+{
+ SwChnlCmd* pCmd;
+
+ if(CmdTable == NULL)
+ {
+ RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n");
+ return false;
+ }
+ if(CmdTableIdx >= CmdTableSz)
+ {
+ RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n",
+ CmdTableIdx, CmdTableSz);
+ return false;
+ }
+
+ pCmd = CmdTable + CmdTableIdx;
+ pCmd->CmdID = CmdID;
+ pCmd->Para1 = Para1;
+ pCmd->Para2 = Para2;
+ pCmd->msDelay = msDelay;
+
+ return true;
+}
+/******************************************************************************
+ *function: This function set channel step by step
+ * input: struct net_device *dev
+ * u8 channel
+ * u8* stage //3 stages
+ * u8* step //
+ * u32* delay //whether need to delay
+ * output: store new stage, step and delay for next step(combine with function above)
+ * return: true if finished, false otherwise
+ * Note: Wait for simpler function to replace it //wb
+ * ***************************************************************************/
+u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u8* step, u32* delay)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+// PCHANNEL_ACCESS_SETTING pChnlAccessSetting;
+ SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT];
+ u32 PreCommonCmdCnt;
+ SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT];
+ u32 PostCommonCmdCnt;
+ SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
+ u32 RfDependCmdCnt;
+ SwChnlCmd *CurrentCmd = NULL;
+ //RF90_RADIO_PATH_E eRFPath;
+ u8 eRFPath;
+// u32 RfRetVal;
+// u8 RetryCnt;
+
+ RT_TRACE(COMP_CH, "====>%s()====stage:%d, step:%d, channel:%d\n", __FUNCTION__, *stage, *step, channel);
+// RT_ASSERT(IsLegalChannel(Adapter, channel), ("illegal channel: %d\n", channel));
+#ifdef ENABLE_DOT11D
+ if (!IsLegalChannel(priv->ieee80211, channel))
+ {
+ RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel);
+ return true; //return true to tell upper caller function this channel setting is finished! Or it will in while loop.
+ }
+#endif
+//FIXME:need to check whether channel is legal or not here.WB
+
+
+ //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
+// for(eRFPath = 0; eRFPath <RF90_PATH_MAX; eRFPath++)
+// {
+// if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
+// continue;
+ // <1> Fill up pre common command.
+ PreCommonCmdCnt = 0;
+ rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT,
+ CmdID_SetTxPowerLevel, 0, 0, 0);
+ rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT,
+ CmdID_End, 0, 0, 0);
+
+ // <2> Fill up post common command.
+ PostCommonCmdCnt = 0;
+
+ rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT,
+ CmdID_End, 0, 0, 0);
+
+ // <3> Fill up RF dependent command.
+ RfDependCmdCnt = 0;
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+ if (!(channel >= 1 && channel <= 14))
+ {
+ RT_TRACE(COMP_ERR, "illegal channel for Zebra 8225: %d\n", channel);
+ return true;
+ }
+ rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10);
+ rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_End, 0, 0, 0);
+ break;
+
+ case RF_8256:
+ // TEST!! This is not the table for 8256!!
+ if (!(channel >= 1 && channel <= 14))
+ {
+ RT_TRACE(COMP_ERR, "illegal channel for Zebra 8256: %d\n", channel);
+ return true;
+ }
+ rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_RF_WriteReg, rZebra1_Channel, channel, 10);
+ rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
+ CmdID_End, 0, 0, 0);
+ break;
+
+ case RF_8258:
+ break;
+
+ default:
+ RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip);
+ return true;
+ break;
+ }
+
+
+ do{
+ switch(*stage)
+ {
+ case 0:
+ CurrentCmd=&PreCommonCmd[*step];
+ break;
+ case 1:
+ CurrentCmd=&RfDependCmd[*step];
+ break;
+ case 2:
+ CurrentCmd=&PostCommonCmd[*step];
+ break;
+ }
+
+ if(CurrentCmd->CmdID==CmdID_End)
+ {
+ if((*stage)==2)
+ {
+ (*delay)=CurrentCmd->msDelay;
+ return true;
+ }
+ else
+ {
+ (*stage)++;
+ (*step)=0;
+ continue;
+ }
+ }
+
+ switch(CurrentCmd->CmdID)
+ {
+ case CmdID_SetTxPowerLevel:
+ if(priv->card_8192_version == (u8)VERSION_819xU_A) //xiong: consider it later!
+ rtl8192_SetTxPowerLevel(dev,channel);
+ break;
+ case CmdID_WritePortUlong:
+ write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2);
+ break;
+ case CmdID_WritePortUshort:
+ write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2);
+ break;
+ case CmdID_WritePortUchar:
+ write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2);
+ break;
+ case CmdID_RF_WriteReg:
+ for(eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++)
+ {
+ rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, bZebra1_ChannelNum, CurrentCmd->Para2);
+ }
+ break;
+ default:
+ break;
+ }
+
+ break;
+ }while(true);
+// }/*for(Number of RF paths)*/
+
+ (*delay)=CurrentCmd->msDelay;
+ (*step)++;
+ return false;
+}
+
+/******************************************************************************
+ *function: This function does acturally set channel work
+ * input: struct net_device *dev
+ * u8 channel
+ * output: none
+ * return: noin
+ * Note: We should not call this function directly
+ * ***************************************************************************/
+void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u32 delay = 0;
+
+ while(!rtl8192_phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay))
+ {
+ // if(delay>0)
+ // msleep(delay);//or mdelay? need further consideration
+ if(!priv->up)
+ break;
+ }
+}
+/******************************************************************************
+ *function: Callback routine of the work item for switch channel.
+ * input:
+ *
+ * output: none
+ * return: noin
+ * ***************************************************************************/
+void rtl8192_SwChnl_WorkItem(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ RT_TRACE(COMP_CH, "==> SwChnlCallback819xUsbWorkItem(), chan:%d\n", priv->chan);
+
+
+ rtl8192_phy_FinishSwChnlNow(dev , priv->chan);
+
+ RT_TRACE(COMP_CH, "<== SwChnlCallback819xUsbWorkItem()\n");
+}
+
+/******************************************************************************
+ *function: This function scheduled actural workitem to set channel
+ * input: net_device dev
+ * u8 channel //channel to set
+ * output: none
+ * return: return code show if workitem is scheduled(1:pass, 0:fail)
+ * Note: Delay may be required for RF configuration
+ * ***************************************************************************/
+u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ RT_TRACE(COMP_CH, "=====>%s(), SwChnlInProgress:%d\n", __FUNCTION__, priv->SwChnlInProgress);
+ if(!priv->up)
+ return false;
+ if(priv->SwChnlInProgress)
+ return false;
+
+// if(pHalData->SetBWModeInProgress)
+// return;
+if (0) //to test current channel from RF reg 0x7.
+{
+ u8 eRFPath;
+ for(eRFPath = 0; eRFPath < 2; eRFPath++){
+ printk("====>set channel:%x\n",rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x7, bZebra1_ChannelNum));
+ udelay(10);
+ }
+}
+ //--------------------------------------------
+ switch(priv->ieee80211->mode)
+ {
+ case WIRELESS_MODE_A:
+ case WIRELESS_MODE_N_5G:
+ if (channel<=14){
+ RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14");
+ return false;
+ }
+ break;
+ case WIRELESS_MODE_B:
+ if (channel>14){
+ RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14");
+ return false;
+ }
+ break;
+ case WIRELESS_MODE_G:
+ case WIRELESS_MODE_N_24G:
+ if (channel>14){
+ RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14");
+ return false;
+ }
+ break;
+ }
+ //--------------------------------------------
+
+ priv->SwChnlInProgress = true;
+ if(channel == 0)
+ channel = 1;
+
+ priv->chan=channel;
+
+ priv->SwChnlStage=0;
+ priv->SwChnlStep=0;
+// schedule_work(&(priv->SwChnlWorkItem));
+// rtl8192_SwChnl_WorkItem(dev);
+ if(priv->up) {
+// queue_work(priv->priv_wq,&(priv->SwChnlWorkItem));
+ rtl8192_SwChnl_WorkItem(dev);
+ }
+
+ priv->SwChnlInProgress = false;
+ return true;
+}
+
+
+//
+/******************************************************************************
+ *function: Callback routine of the work item for set bandwidth mode.
+ * input: struct net_device *dev
+ * HT_CHANNEL_WIDTH Bandwidth //20M or 40M
+ * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care
+ * output: none
+ * return: none
+ * Note: I doubt whether SetBWModeInProgress flag is necessary as we can
+ * test whether current work in the queue or not.//do I?
+ * ***************************************************************************/
+void rtl8192_SetBWModeWorkItem(struct net_device *dev)
+{
+
+ struct r8192_priv *priv = ieee80211_priv(dev);
+ u8 regBwOpMode;
+
+ RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", \
+ priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz")
+
+
+ if(priv->rf_chip == RF_PSEUDO_11N)
+ {
+ priv->SetBWModeInProgress= false;
+ return;
+ }
+
+ //<1>Set MAC register
+ regBwOpMode = read_nic_byte(dev, BW_OPMODE);
+
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ regBwOpMode |= BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ break;
+
+ case HT_CHANNEL_WIDTH_20_40:
+ regBwOpMode &= ~BW_OPMODE_20MHZ;
+ // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
+ write_nic_byte(dev, BW_OPMODE, regBwOpMode);
+ break;
+
+ default:
+ RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",priv->CurrentChannelBW);
+ break;
+ }
+
+ //<2>Set PHY related register
+ switch(priv->CurrentChannelBW)
+ {
+ case HT_CHANNEL_WIDTH_20:
+ // Add by Vivi 20071119
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1);
+
+ // Correct the tx power for CCK rate in 20M. Suggest by YN, 20071207
+#if 0
+ write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000);
+ write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317);
+ write_nic_dword(dev, rCCK0_DebugPort, 0x00000204);
+#endif
+ priv->cck_present_attentuation =
+ priv->cck_present_attentuation_20Mdefault + priv->cck_present_attentuation_difference;
+
+ if(priv->cck_present_attentuation > 22)
+ priv->cck_present_attentuation= 22;
+ if(priv->cck_present_attentuation< 0)
+ priv->cck_present_attentuation = 0;
+ RT_TRACE(COMP_INIT, "20M, pHalData->CCKPresentAttentuation = %d\n", priv->cck_present_attentuation);
+
+ if(priv->chan == 14 && !priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = TRUE;
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ else if(priv->chan != 14 && priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = FALSE;
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ else
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+
+ break;
+ case HT_CHANNEL_WIDTH_20_40:
+ // Add by Vivi 20071119
+ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
+ rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
+ rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
+ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0);
+ rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
+#if 0
+ // Correct the tx power for CCK rate in 40M. Suggest by YN, 20071207
+ write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000);
+ write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e);
+ write_nic_dword(dev, rCCK0_DebugPort, 0x00000409);
+#endif
+ priv->cck_present_attentuation =
+ priv->cck_present_attentuation_40Mdefault + priv->cck_present_attentuation_difference;
+
+ if(priv->cck_present_attentuation > 22)
+ priv->cck_present_attentuation = 22;
+ if(priv->cck_present_attentuation < 0)
+ priv->cck_present_attentuation = 0;
+
+ RT_TRACE(COMP_INIT, "40M, pHalData->CCKPresentAttentuation = %d\n", priv->cck_present_attentuation);
+ if(priv->chan == 14 && !priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = true;
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ else if(priv->chan!= 14 && priv->bcck_in_ch14)
+ {
+ priv->bcck_in_ch14 = false;
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+ }
+ else
+ dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
+
+ break;
+ default:
+ RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW);
+ break;
+
+ }
+ //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315
+
+#if 1
+ //<3>Set RF related register
+ switch( priv->rf_chip )
+ {
+ case RF_8225:
+#ifdef TO_DO_LIST
+ PHY_SetRF8225Bandwidth(Adapter, pHalData->CurrentChannelBW);
+#endif
+ break;
+
+ case RF_8256:
+ PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW);
+ break;
+
+ case RF_8258:
+ // PHY_SetRF8258Bandwidth();
+ break;
+
+ case RF_PSEUDO_11N:
+ // Do Nothing
+ break;
+
+ default:
+ RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip);
+ break;
+ }
+#endif
+ priv->SetBWModeInProgress= false;
+
+ RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb(), %d", atomic_read(&(priv->ieee80211->atm_swbw)) );
+}
+
+/******************************************************************************
+ *function: This function schedules bandwith switch work.
+ * input: struct net_device *dev
+ * HT_CHANNEL_WIDTH Bandwidth //20M or 40M
+ * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care
+ * output: none
+ * return: none
+ * Note: I doubt whether SetBWModeInProgress flag is necessary as we can
+ * test whether current work in the queue or not.//do I?
+ * ***************************************************************************/
+void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ if(priv->SetBWModeInProgress)
+ return;
+ priv->SetBWModeInProgress= true;
+
+ priv->CurrentChannelBW = Bandwidth;
+
+ if(Offset==HT_EXTCHNL_OFFSET_LOWER)
+ priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER;
+ else if(Offset==HT_EXTCHNL_OFFSET_UPPER)
+ priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER;
+ else
+ priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
+
+ //queue_work(priv->priv_wq, &(priv->SetBWModeWorkItem));
+ // schedule_work(&(priv->SetBWModeWorkItem));
+ rtl8192_SetBWModeWorkItem(dev);
+
+}
+
+void InitialGain819xUsb(struct net_device *dev, u8 Operation)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+
+ priv->InitialGainOperateType = Operation;
+
+ if(priv->up)
+ {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ queue_delayed_work(priv->priv_wq,&priv->initialgain_operate_wq,0);
+ #else
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ schedule_task(&priv->initialgain_operate_wq);
+ #else
+ queue_work(priv->priv_wq,&priv->initialgain_operate_wq);
+ #endif
+ #endif
+ }
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void InitialGainOperateWorkItemCallBack(struct work_struct *work)
+{
+ struct delayed_work *dwork = container_of(work,struct delayed_work,work);
+ struct r8192_priv *priv = container_of(dwork,struct r8192_priv,initialgain_operate_wq);
+ struct net_device *dev = priv->ieee80211->dev;
+#else
+extern void InitialGainOperateWorkItemCallBack(struct net_device *dev)
+{
+ struct r8192_priv *priv = ieee80211_priv(dev);
+#endif
+#define SCAN_RX_INITIAL_GAIN 0x17
+#define POWER_DETECTION_TH 0x08
+ u32 BitMask;
+ u8 initial_gain;
+ u8 Operation;
+
+ Operation = priv->InitialGainOperateType;
+
+ switch(Operation)
+ {
+ case IG_Backup:
+ RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n");
+ initial_gain = SCAN_RX_INITIAL_GAIN;//priv->DefaultInitialGain[0];//
+ BitMask = bMaskByte0;
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
+ priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask);
+ priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask);
+ priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask);
+ priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask);
+ BitMask = bMaskByte2;
+ priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask);
+
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca);
+
+ RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain);
+ write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
+ write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
+ RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH);
+ write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH);
+ break;
+ case IG_Restore:
+ RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n");
+ BitMask = 0x7f; //Bit0~ Bit6
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
+
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1);
+ BitMask = bMaskByte2;
+ rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca);
+
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca);
+
+#ifdef RTL8190P
+ SetTxPowerLevel8190(Adapter,priv->CurrentChannel);
+#endif
+#ifdef RTL8192E
+ SetTxPowerLevel8190(Adapter,priv->CurrentChannel);
+#endif
+//#ifdef RTL8192U
+ rtl8192_phy_setTxPower(dev,priv->ieee80211->current_network.channel);
+//#endif
+
+ if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
+ rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // FW DIG ON
+ break;
+ default:
+ RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n");
+ break;
+ }
+}
+
diff --git a/drivers/staging/rtl8192su/r819xU_phy.h b/drivers/staging/rtl8192su/r819xU_phy.h
new file mode 100644
index 000000000000..c165ac1265d9
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_phy.h
@@ -0,0 +1,94 @@
+#ifndef _R819XU_PHY_H
+#define _R819XU_PHY_H
+
+/* Channel switch:The size of command tables for switch channel*/
+#define MAX_PRECMD_CNT 16
+#define MAX_RFDEPENDCMD_CNT 16
+#define MAX_POSTCMD_CNT 16
+
+typedef enum _SwChnlCmdID{
+ CmdID_End,
+ CmdID_SetTxPowerLevel,
+ CmdID_BBRegWrite10,
+ CmdID_WritePortUlong,
+ CmdID_WritePortUshort,
+ CmdID_WritePortUchar,
+ CmdID_RF_WriteReg,
+}SwChnlCmdID;
+
+/*--------------------------------Define structure--------------------------------*/
+/* 1. Switch channel related */
+typedef struct _SwChnlCmd{
+ SwChnlCmdID CmdID;
+ u32 Para1;
+ u32 Para2;
+ u32 msDelay;
+}__attribute__ ((packed)) SwChnlCmd;
+
+extern u32 rtl819XMACPHY_Array_PG[];
+extern u32 rtl819XPHY_REG_1T2RArray[];
+extern u32 rtl819XAGCTAB_Array[];
+extern u32 rtl819XRadioA_Array[];
+extern u32 rtl819XRadioB_Array[];
+extern u32 rtl819XRadioC_Array[];
+extern u32 rtl819XRadioD_Array[];
+
+typedef enum _HW90_BLOCK{
+ HW90_BLOCK_MAC = 0,
+ HW90_BLOCK_PHY0 = 1,
+ HW90_BLOCK_PHY1 = 2,
+ HW90_BLOCK_RF = 3,
+ HW90_BLOCK_MAXIMUM = 4, // Never use this
+}HW90_BLOCK_E, *PHW90_BLOCK_E;
+
+typedef enum _RF90_RADIO_PATH{
+ RF90_PATH_A = 0, //Radio Path A
+ RF90_PATH_B = 1, //Radio Path B
+ RF90_PATH_C = 2, //Radio Path C
+ RF90_PATH_D = 3, //Radio Path D
+ RF90_PATH_MAX //Max RF number 92 support
+}RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E;
+
+#define bMaskByte0 0xff
+#define bMaskByte1 0xff00
+#define bMaskByte2 0xff0000
+#define bMaskByte3 0xff000000
+#define bMaskHWord 0xffff0000
+#define bMaskLWord 0x0000ffff
+#define bMaskDWord 0xffffffff
+
+//extern u32 rtl8192_CalculateBitShift(u32 dwBitMask);
+extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath);
+extern void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData);
+extern u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask);
+//extern u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset);
+//extern void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset, u32 Data);
+extern void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data);
+extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask);
+extern void rtl8192_phy_configmac(struct net_device* dev);
+extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType);
+//extern void rtl8192_InitBBRFRegDef(struct net_device* dev);
+extern u8 rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath);
+//extern void rtl8192_BB_Config_ParaFile(struct net_device* dev);
+extern void rtl8192_BBConfig(struct net_device* dev);
+extern void rtl8192_phy_getTxPower(struct net_device* dev);
+extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel);
+extern void rtl8192_phy_RFConfig(struct net_device* dev);
+extern void rtl8192_phy_updateInitGain(struct net_device* dev);
+extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath);
+
+extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel);
+extern void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
+extern void rtl8192_SwChnl_WorkItem(struct net_device *dev);
+void rtl8192_SetBWModeWorkItem(struct net_device *dev);
+extern bool rtl8192_SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState);
+//added by amy
+extern void InitialGain819xUsb(struct net_device *dev, u8 Operation);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+extern void InitialGainOperateWorkItemCallBack(struct work_struct *work);
+#else
+extern void InitialGainOperateWorkItemCallBack(struct net_device *dev);
+#endif
+
+#endif
diff --git a/drivers/staging/rtl8192su/r819xU_phyreg.h b/drivers/staging/rtl8192su/r819xU_phyreg.h
new file mode 100644
index 000000000000..b62f1a6fb1eb
--- /dev/null
+++ b/drivers/staging/rtl8192su/r819xU_phyreg.h
@@ -0,0 +1,871 @@
+#ifndef _R819XU_PHYREG_H
+#define _R819XU_PHYREG_H
+
+
+#define RF_DATA 0x1d4 // FW will write RF data in the register.
+
+//Register //duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
+//page 1
+#define rPMAC_Reset 0x100
+#define rPMAC_TxStart 0x104
+#define rPMAC_TxLegacySIG 0x108
+#define rPMAC_TxHTSIG1 0x10c
+#define rPMAC_TxHTSIG2 0x110
+#define rPMAC_PHYDebug 0x114
+#define rPMAC_TxPacketNum 0x118
+#define rPMAC_TxIdle 0x11c
+#define rPMAC_TxMACHeader0 0x120
+#define rPMAC_TxMACHeader1 0x124
+#define rPMAC_TxMACHeader2 0x128
+#define rPMAC_TxMACHeader3 0x12c
+#define rPMAC_TxMACHeader4 0x130
+#define rPMAC_TxMACHeader5 0x134
+#define rPMAC_TxDataType 0x138
+#define rPMAC_TxRandomSeed 0x13c
+#define rPMAC_CCKPLCPPreamble 0x140
+#define rPMAC_CCKPLCPHeader 0x144
+#define rPMAC_CCKCRC16 0x148
+#define rPMAC_OFDMRxCRC32OK 0x170
+#define rPMAC_OFDMRxCRC32Er 0x174
+#define rPMAC_OFDMRxParityEr 0x178
+#define rPMAC_OFDMRxCRC8Er 0x17c
+#define rPMAC_CCKCRxRC16Er 0x180
+#define rPMAC_CCKCRxRC32Er 0x184
+#define rPMAC_CCKCRxRC32OK 0x188
+#define rPMAC_TxStatus 0x18c
+
+//page8
+#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC
+#define rFPGA0_TxInfo 0x804
+#define rFPGA0_PSDFunction 0x808
+#define rFPGA0_TxGainStage 0x80c
+#define rFPGA0_RFTiming1 0x810
+#define rFPGA0_RFTiming2 0x814
+//#define rFPGA0_XC_RFTiming 0x818
+//#define rFPGA0_XD_RFTiming 0x81c
+#define rFPGA0_XA_HSSIParameter1 0x820
+#define rFPGA0_XA_HSSIParameter2 0x824
+#define rFPGA0_XB_HSSIParameter1 0x828
+#define rFPGA0_XB_HSSIParameter2 0x82c
+#define rFPGA0_XC_HSSIParameter1 0x830
+#define rFPGA0_XC_HSSIParameter2 0x834
+#define rFPGA0_XD_HSSIParameter1 0x838
+#define rFPGA0_XD_HSSIParameter2 0x83c
+#define rFPGA0_XA_LSSIParameter 0x840
+#define rFPGA0_XB_LSSIParameter 0x844
+#define rFPGA0_XC_LSSIParameter 0x848
+#define rFPGA0_XD_LSSIParameter 0x84c
+#define rFPGA0_RFWakeUpParameter 0x850
+#define rFPGA0_RFSleepUpParameter 0x854
+#define rFPGA0_XAB_SwitchControl 0x858
+#define rFPGA0_XCD_SwitchControl 0x85c
+#define rFPGA0_XA_RFInterfaceOE 0x860
+#define rFPGA0_XB_RFInterfaceOE 0x864
+#define rFPGA0_XC_RFInterfaceOE 0x868
+#define rFPGA0_XD_RFInterfaceOE 0x86c
+#define rFPGA0_XAB_RFInterfaceSW 0x870
+#define rFPGA0_XCD_RFInterfaceSW 0x874
+#define rFPGA0_XAB_RFParameter 0x878
+#define rFPGA0_XCD_RFParameter 0x87c
+#define rFPGA0_AnalogParameter1 0x880
+#define rFPGA0_AnalogParameter2 0x884
+#define rFPGA0_AnalogParameter3 0x888
+#define rFPGA0_AnalogParameter4 0x88c
+#define rFPGA0_XA_LSSIReadBack 0x8a0
+#define rFPGA0_XB_LSSIReadBack 0x8a4
+#define rFPGA0_XC_LSSIReadBack 0x8a8
+#define rFPGA0_XD_LSSIReadBack 0x8ac
+#define rFPGA0_PSDReport 0x8b4
+#define rFPGA0_XAB_RFInterfaceRB 0x8e0
+#define rFPGA0_XCD_RFInterfaceRB 0x8e4
+
+//page 9
+#define rFPGA1_RFMOD 0x900 //RF mode & OFDM TxSC
+#define rFPGA1_TxBlock 0x904
+#define rFPGA1_DebugSelect 0x908
+#define rFPGA1_TxInfo 0x90c
+
+//page a
+#define rCCK0_System 0xa00
+#define rCCK0_AFESetting 0xa04
+#define rCCK0_CCA 0xa08
+#define rCCK0_RxAGC1 0xa0c //AGC default value, saturation level
+#define rCCK0_RxAGC2 0xa10 //AGC & DAGC
+#define rCCK0_RxHP 0xa14
+#define rCCK0_DSPParameter1 0xa18 //Timing recovery & Channel estimation threshold
+#define rCCK0_DSPParameter2 0xa1c //SQ threshold
+#define rCCK0_TxFilter1 0xa20
+#define rCCK0_TxFilter2 0xa24
+#define rCCK0_DebugPort 0xa28 //debug port and Tx filter3
+#define rCCK0_FalseAlarmReport 0xa2c //0xa2d
+#define rCCK0_TRSSIReport 0xa50
+#define rCCK0_RxReport 0xa54 //0xa57
+#define rCCK0_FACounterLower 0xa5c //0xa5b
+#define rCCK0_FACounterUpper 0xa58 //0xa5c
+
+//page c
+#define rOFDM0_LSTF 0xc00
+#define rOFDM0_TRxPathEnable 0xc04
+#define rOFDM0_TRMuxPar 0xc08
+#define rOFDM0_TRSWIsolation 0xc0c
+#define rOFDM0_XARxAFE 0xc10 //RxIQ DC offset, Rx digital filter, DC notch filter
+#define rOFDM0_XARxIQImbalance 0xc14 //RxIQ imblance matrix
+#define rOFDM0_XBRxAFE 0xc18
+#define rOFDM0_XBRxIQImbalance 0xc1c
+#define rOFDM0_XCRxAFE 0xc20
+#define rOFDM0_XCRxIQImbalance 0xc24
+#define rOFDM0_XDRxAFE 0xc28
+#define rOFDM0_XDRxIQImbalance 0xc2c
+#define rOFDM0_RxDetector1 0xc30 //PD,BW & SBD
+#define rOFDM0_RxDetector2 0xc34 //SBD & Fame Sync.
+#define rOFDM0_RxDetector3 0xc38 //Frame Sync.
+#define rOFDM0_RxDetector4 0xc3c //PD, SBD, Frame Sync & Short-GI
+#define rOFDM0_RxDSP 0xc40 //Rx Sync Path
+#define rOFDM0_CFOandDAGC 0xc44 //CFO & DAGC
+#define rOFDM0_CCADropThreshold 0xc48 //CCA Drop threshold
+#define rOFDM0_ECCAThreshold 0xc4c // energy CCA
+#define rOFDM0_XAAGCCore1 0xc50
+#define rOFDM0_XAAGCCore2 0xc54
+#define rOFDM0_XBAGCCore1 0xc58
+#define rOFDM0_XBAGCCore2 0xc5c
+#define rOFDM0_XCAGCCore1 0xc60
+#define rOFDM0_XCAGCCore2 0xc64
+#define rOFDM0_XDAGCCore1 0xc68
+#define rOFDM0_XDAGCCore2 0xc6c
+#define rOFDM0_AGCParameter1 0xc70
+#define rOFDM0_AGCParameter2 0xc74
+#define rOFDM0_AGCRSSITable 0xc78
+#define rOFDM0_HTSTFAGC 0xc7c
+#define rOFDM0_XATxIQImbalance 0xc80
+#define rOFDM0_XATxAFE 0xc84
+#define rOFDM0_XBTxIQImbalance 0xc88
+#define rOFDM0_XBTxAFE 0xc8c
+#define rOFDM0_XCTxIQImbalance 0xc90
+#define rOFDM0_XCTxAFE 0xc94
+#define rOFDM0_XDTxIQImbalance 0xc98
+#define rOFDM0_XDTxAFE 0xc9c
+#define rOFDM0_RxHPParameter 0xce0
+#define rOFDM0_TxPseudoNoiseWgt 0xce4
+#define rOFDM0_FrameSync 0xcf0
+#define rOFDM0_DFSReport 0xcf4
+#define rOFDM0_TxCoeff1 0xca4
+#define rOFDM0_TxCoeff2 0xca8
+#define rOFDM0_TxCoeff3 0xcac
+#define rOFDM0_TxCoeff4 0xcb0
+#define rOFDM0_TxCoeff5 0xcb4
+#define rOFDM0_TxCoeff6 0xcb8
+
+
+//page d
+#define rOFDM1_LSTF 0xd00
+#define rOFDM1_TRxPathEnable 0xd04
+#define rOFDM1_CFO 0xd08
+#define rOFDM1_CSI1 0xd10
+#define rOFDM1_SBD 0xd14
+#define rOFDM1_CSI2 0xd18
+#define rOFDM1_CFOTracking 0xd2c
+#define rOFDM1_TRxMesaure1 0xd34
+#define rOFDM1_IntfDet 0xd3c
+#define rOFDM1_PseudoNoiseStateAB 0xd50
+#define rOFDM1_PseudoNoiseStateCD 0xd54
+#define rOFDM1_RxPseudoNoiseWgt 0xd58
+#define rOFDM_PHYCounter1 0xda0 //cca, parity fail
+#define rOFDM_PHYCounter2 0xda4 //rate illegal, crc8 fail
+#define rOFDM_PHYCounter3 0xda8 //MCS not support
+#define rOFDM_ShortCFOAB 0xdac
+#define rOFDM_ShortCFOCD 0xdb0
+#define rOFDM_LongCFOAB 0xdb4
+#define rOFDM_LongCFOCD 0xdb8
+#define rOFDM_TailCFOAB 0xdbc
+#define rOFDM_TailCFOCD 0xdc0
+#define rOFDM_PWMeasure1 0xdc4
+#define rOFDM_PWMeasure2 0xdc8
+#define rOFDM_BWReport 0xdcc
+#define rOFDM_AGCReport 0xdd0
+#define rOFDM_RxSNR 0xdd4
+#define rOFDM_RxEVMCSI 0xdd8
+#define rOFDM_SIGReport 0xddc
+
+//page e
+#define rTxAGC_Rate18_06 0xe00
+#define rTxAGC_Rate54_24 0xe04
+#define rTxAGC_CCK_Mcs32 0xe08
+#define rTxAGC_Mcs03_Mcs00 0xe10
+#define rTxAGC_Mcs07_Mcs04 0xe14
+#define rTxAGC_Mcs11_Mcs08 0xe18
+#define rTxAGC_Mcs15_Mcs12 0xe1c
+
+
+//RF
+//Zebra1
+#define rZebra1_HSSIEnable 0x0
+#define rZebra1_TRxEnable1 0x1
+#define rZebra1_TRxEnable2 0x2
+#define rZebra1_AGC 0x4
+#define rZebra1_ChargePump 0x5
+#define rZebra1_Channel 0x7
+#define rZebra1_TxGain 0x8
+#define rZebra1_TxLPF 0x9
+#define rZebra1_RxLPF 0xb
+#define rZebra1_RxHPFCorner 0xc
+
+//Zebra4
+#define rGlobalCtrl 0
+#define rRTL8256_TxLPF 19
+#define rRTL8256_RxLPF 11
+
+//RTL8258
+#define rRTL8258_TxLPF 0x11
+#define rRTL8258_RxLPF 0x13
+#define rRTL8258_RSSILPF 0xa
+
+//Bit Mask
+//page-1
+#define bBBResetB 0x100
+#define bGlobalResetB 0x200
+#define bOFDMTxStart 0x4
+#define bCCKTxStart 0x8
+#define bCRC32Debug 0x100
+#define bPMACLoopback 0x10
+#define bTxLSIG 0xffffff
+#define bOFDMTxRate 0xf
+#define bOFDMTxReserved 0x10
+#define bOFDMTxLength 0x1ffe0
+#define bOFDMTxParity 0x20000
+#define bTxHTSIG1 0xffffff
+#define bTxHTMCSRate 0x7f
+#define bTxHTBW 0x80
+#define bTxHTLength 0xffff00
+#define bTxHTSIG2 0xffffff
+#define bTxHTSmoothing 0x1
+#define bTxHTSounding 0x2
+#define bTxHTReserved 0x4
+#define bTxHTAggreation 0x8
+#define bTxHTSTBC 0x30
+#define bTxHTAdvanceCoding 0x40
+#define bTxHTShortGI 0x80
+#define bTxHTNumberHT_LTF 0x300
+#define bTxHTCRC8 0x3fc00
+#define bCounterReset 0x10000
+#define bNumOfOFDMTx 0xffff
+#define bNumOfCCKTx 0xffff0000
+#define bTxIdleInterval 0xffff
+#define bOFDMService 0xffff0000
+#define bTxMACHeader 0xffffffff
+#define bTxDataInit 0xff
+#define bTxHTMode 0x100
+#define bTxDataType 0x30000
+#define bTxRandomSeed 0xffffffff
+#define bCCKTxPreamble 0x1
+#define bCCKTxSFD 0xffff0000
+#define bCCKTxSIG 0xff
+#define bCCKTxService 0xff00
+#define bCCKLengthExt 0x8000
+#define bCCKTxLength 0xffff0000
+#define bCCKTxCRC16 0xffff
+#define bCCKTxStatus 0x1
+#define bOFDMTxStatus 0x2
+
+//page-8
+#define bRFMOD 0x1
+#define bJapanMode 0x2
+#define bCCKTxSC 0x30
+#define bCCKEn 0x1000000
+#define bOFDMEn 0x2000000
+#define bOFDMRxADCPhase 0x10000
+#define bOFDMTxDACPhase 0x40000
+#define bXATxAGC 0x3f
+#define bXBTxAGC 0xf00
+#define bXCTxAGC 0xf000
+#define bXDTxAGC 0xf0000
+#define bPAStart 0xf0000000
+#define bTRStart 0x00f00000
+#define bRFStart 0x0000f000
+#define bBBStart 0x000000f0
+#define bBBCCKStart 0x0000000f
+#define bPAEnd 0xf //Reg0x814
+#define bTREnd 0x0f000000
+#define bRFEnd 0x000f0000
+#define bCCAMask 0x000000f0 //T2R
+#define bR2RCCAMask 0x00000f00
+#define bHSSI_R2TDelay 0xf8000000
+#define bHSSI_T2RDelay 0xf80000
+#define bContTxHSSI 0x400 //chane gain at continue Tx
+#define bIGFromCCK 0x200
+#define bAGCAddress 0x3f
+#define bRxHPTx 0x7000
+#define bRxHPT2R 0x38000
+#define bRxHPCCKIni 0xc0000
+#define bAGCTxCode 0xc00000
+#define bAGCRxCode 0x300000
+#define b3WireDataLength 0x800
+#define b3WireAddressLength 0x400
+#define b3WireRFPowerDown 0x1
+//#define bHWSISelect 0x8
+#define b5GPAPEPolarity 0x40000000
+#define b2GPAPEPolarity 0x80000000
+#define bRFSW_TxDefaultAnt 0x3
+#define bRFSW_TxOptionAnt 0x30
+#define bRFSW_RxDefaultAnt 0x300
+#define bRFSW_RxOptionAnt 0x3000
+#define bRFSI_3WireData 0x1
+#define bRFSI_3WireClock 0x2
+#define bRFSI_3WireLoad 0x4
+#define bRFSI_3WireRW 0x8
+#define bRFSI_3Wire 0xf //3-wire total control
+#define bRFSI_RFENV 0x10
+#define bRFSI_TRSW 0x20
+#define bRFSI_TRSWB 0x40
+#define bRFSI_ANTSW 0x100
+#define bRFSI_ANTSWB 0x200
+#define bRFSI_PAPE 0x400
+#define bRFSI_PAPE5G 0x800
+#define bBandSelect 0x1
+#define bHTSIG2_GI 0x80
+#define bHTSIG2_Smoothing 0x01
+#define bHTSIG2_Sounding 0x02
+#define bHTSIG2_Aggreaton 0x08
+#define bHTSIG2_STBC 0x30
+#define bHTSIG2_AdvCoding 0x40
+#define bHTSIG2_NumOfHTLTF 0x300
+#define bHTSIG2_CRC8 0x3fc
+#define bHTSIG1_MCS 0x7f
+#define bHTSIG1_BandWidth 0x80
+#define bHTSIG1_HTLength 0xffff
+#define bLSIG_Rate 0xf
+#define bLSIG_Reserved 0x10
+#define bLSIG_Length 0x1fffe
+#define bLSIG_Parity 0x20
+#define bCCKRxPhase 0x4
+#define bLSSIReadAddress 0x3f000000 //LSSI "Read" Address
+#define bLSSIReadEdge 0x80000000 //LSSI "Read" edge signal
+#define bLSSIReadBackData 0xfff
+#define bLSSIReadOKFlag 0x1000
+#define bCCKSampleRate 0x8 //0: 44MHz, 1:88MHz
+
+#define bRegulator0Standby 0x1
+#define bRegulatorPLLStandby 0x2
+#define bRegulator1Standby 0x4
+#define bPLLPowerUp 0x8
+#define bDPLLPowerUp 0x10
+#define bDA10PowerUp 0x20
+#define bAD7PowerUp 0x200
+#define bDA6PowerUp 0x2000
+#define bXtalPowerUp 0x4000
+#define b40MDClkPowerUP 0x8000
+#define bDA6DebugMode 0x20000
+#define bDA6Swing 0x380000
+#define bADClkPhase 0x4000000
+#define b80MClkDelay 0x18000000
+#define bAFEWatchDogEnable 0x20000000
+#define bXtalCap 0x0f000000
+#define bIntDifClkEnable 0x400
+#define bExtSigClkEnable 0x800
+#define bBandgapMbiasPowerUp 0x10000
+#define bAD11SHGain 0xc0000
+#define bAD11InputRange 0x700000
+#define bAD11OPCurrent 0x3800000
+#define bIPathLoopback 0x4000000
+#define bQPathLoopback 0x8000000
+#define bAFELoopback 0x10000000
+#define bDA10Swing 0x7e0
+#define bDA10Reverse 0x800
+#define bDAClkSource 0x1000
+#define bAD7InputRange 0x6000
+#define bAD7Gain 0x38000
+#define bAD7OutputCMMode 0x40000
+#define bAD7InputCMMode 0x380000
+#define bAD7Current 0xc00000
+#define bRegulatorAdjust 0x7000000
+#define bAD11PowerUpAtTx 0x1
+#define bDA10PSAtTx 0x10
+#define bAD11PowerUpAtRx 0x100
+#define bDA10PSAtRx 0x1000
+
+#define bCCKRxAGCFormat 0x200
+
+#define bPSDFFTSamplepPoint 0xc000
+#define bPSDAverageNum 0x3000
+#define bIQPathControl 0xc00
+#define bPSDFreq 0x3ff
+#define bPSDAntennaPath 0x30
+#define bPSDIQSwitch 0x40
+#define bPSDRxTrigger 0x400000
+#define bPSDTxTrigger 0x80000000
+#define bPSDSineToneScale 0x7f000000
+#define bPSDReport 0xffff
+
+//page-9
+#define bOFDMTxSC 0x30000000
+#define bCCKTxOn 0x1
+#define bOFDMTxOn 0x2
+#define bDebugPage 0xfff //reset debug page and also HWord, LWord
+#define bDebugItem 0xff //reset debug page and LWord
+#define bAntL 0x10
+#define bAntNonHT 0x100
+#define bAntHT1 0x1000
+#define bAntHT2 0x10000
+#define bAntHT1S1 0x100000
+#define bAntNonHTS1 0x1000000
+
+//page-a
+#define bCCKBBMode 0x3
+#define bCCKTxPowerSaving 0x80
+#define bCCKRxPowerSaving 0x40
+#define bCCKSideBand 0x10
+#define bCCKScramble 0x8
+#define bCCKAntDiversity 0x8000
+#define bCCKCarrierRecovery 0x4000
+#define bCCKTxRate 0x3000
+#define bCCKDCCancel 0x0800
+#define bCCKISICancel 0x0400
+#define bCCKMatchFilter 0x0200
+#define bCCKEqualizer 0x0100
+#define bCCKPreambleDetect 0x800000
+#define bCCKFastFalseCCA 0x400000
+#define bCCKChEstStart 0x300000
+#define bCCKCCACount 0x080000
+#define bCCKcs_lim 0x070000
+#define bCCKBistMode 0x80000000
+#define bCCKCCAMask 0x40000000
+#define bCCKTxDACPhase 0x4
+#define bCCKRxADCPhase 0x20000000 //r_rx_clk
+#define bCCKr_cp_mode0 0x0100
+#define bCCKTxDCOffset 0xf0
+#define bCCKRxDCOffset 0xf
+#define bCCKCCAMode 0xc000
+#define bCCKFalseCS_lim 0x3f00
+#define bCCKCS_ratio 0xc00000
+#define bCCKCorgBit_sel 0x300000
+#define bCCKPD_lim 0x0f0000
+#define bCCKNewCCA 0x80000000
+#define bCCKRxHPofIG 0x8000
+#define bCCKRxIG 0x7f00
+#define bCCKLNAPolarity 0x800000
+#define bCCKRx1stGain 0x7f0000
+#define bCCKRFExtend 0x20000000 //CCK Rx Iinital gain polarity
+#define bCCKRxAGCSatLevel 0x1f000000
+#define bCCKRxAGCSatCount 0xe0
+#define bCCKRxRFSettle 0x1f //AGCsamp_dly
+#define bCCKFixedRxAGC 0x8000
+//#define bCCKRxAGCFormat 0x4000 //remove to HSSI register 0x824
+#define bCCKAntennaPolarity 0x2000
+#define bCCKTxFilterType 0x0c00
+#define bCCKRxAGCReportType 0x0300
+#define bCCKRxDAGCEn 0x80000000
+#define bCCKRxDAGCPeriod 0x20000000
+#define bCCKRxDAGCSatLevel 0x1f000000
+#define bCCKTimingRecovery 0x800000
+#define bCCKTxC0 0x3f0000
+#define bCCKTxC1 0x3f000000
+#define bCCKTxC2 0x3f
+#define bCCKTxC3 0x3f00
+#define bCCKTxC4 0x3f0000
+#define bCCKTxC5 0x3f000000
+#define bCCKTxC6 0x3f
+#define bCCKTxC7 0x3f00
+#define bCCKDebugPort 0xff0000
+#define bCCKDACDebug 0x0f000000
+#define bCCKFalseAlarmEnable 0x8000
+#define bCCKFalseAlarmRead 0x4000
+#define bCCKTRSSI 0x7f
+#define bCCKRxAGCReport 0xfe
+#define bCCKRxReport_AntSel 0x80000000
+#define bCCKRxReport_MFOff 0x40000000
+#define bCCKRxRxReport_SQLoss 0x20000000
+#define bCCKRxReport_Pktloss 0x10000000
+#define bCCKRxReport_Lockedbit 0x08000000
+#define bCCKRxReport_RateError 0x04000000
+#define bCCKRxReport_RxRate 0x03000000
+#define bCCKRxFACounterLower 0xff
+#define bCCKRxFACounterUpper 0xff000000
+#define bCCKRxHPAGCStart 0xe000
+#define bCCKRxHPAGCFinal 0x1c00
+
+#define bCCKRxFalseAlarmEnable 0x8000
+#define bCCKFACounterFreeze 0x4000
+
+#define bCCKTxPathSel 0x10000000
+#define bCCKDefaultRxPath 0xc000000
+#define bCCKOptionRxPath 0x3000000
+
+//page c
+#define bNumOfSTF 0x3
+#define bShift_L 0xc0
+#define bGI_TH 0xc
+#define bRxPathA 0x1
+#define bRxPathB 0x2
+#define bRxPathC 0x4
+#define bRxPathD 0x8
+#define bTxPathA 0x1
+#define bTxPathB 0x2
+#define bTxPathC 0x4
+#define bTxPathD 0x8
+#define bTRSSIFreq 0x200
+#define bADCBackoff 0x3000
+#define bDFIRBackoff 0xc000
+#define bTRSSILatchPhase 0x10000
+#define bRxIDCOffset 0xff
+#define bRxQDCOffset 0xff00
+#define bRxDFIRMode 0x1800000
+#define bRxDCNFType 0xe000000
+#define bRXIQImb_A 0x3ff
+#define bRXIQImb_B 0xfc00
+#define bRXIQImb_C 0x3f0000
+#define bRXIQImb_D 0xffc00000
+#define bDC_dc_Notch 0x60000
+#define bRxNBINotch 0x1f000000
+#define bPD_TH 0xf
+#define bPD_TH_Opt2 0xc000
+#define bPWED_TH 0x700
+#define bIfMF_Win_L 0x800
+#define bPD_Option 0x1000
+#define bMF_Win_L 0xe000
+#define bBW_Search_L 0x30000
+#define bwin_enh_L 0xc0000
+#define bBW_TH 0x700000
+#define bED_TH2 0x3800000
+#define bBW_option 0x4000000
+#define bRatio_TH 0x18000000
+#define bWindow_L 0xe0000000
+#define bSBD_Option 0x1
+#define bFrame_TH 0x1c
+#define bFS_Option 0x60
+#define bDC_Slope_check 0x80
+#define bFGuard_Counter_DC_L 0xe00
+#define bFrame_Weight_Short 0x7000
+#define bSub_Tune 0xe00000
+#define bFrame_DC_Length 0xe000000
+#define bSBD_start_offset 0x30000000
+#define bFrame_TH_2 0x7
+#define bFrame_GI2_TH 0x38
+#define bGI2_Sync_en 0x40
+#define bSarch_Short_Early 0x300
+#define bSarch_Short_Late 0xc00
+#define bSarch_GI2_Late 0x70000
+#define bCFOAntSum 0x1
+#define bCFOAcc 0x2
+#define bCFOStartOffset 0xc
+#define bCFOLookBack 0x70
+#define bCFOSumWeight 0x80
+#define bDAGCEnable 0x10000
+#define bTXIQImb_A 0x3ff
+#define bTXIQImb_B 0xfc00
+#define bTXIQImb_C 0x3f0000
+#define bTXIQImb_D 0xffc00000
+#define bTxIDCOffset 0xff
+#define bTxQDCOffset 0xff00
+#define bTxDFIRMode 0x10000
+#define bTxPesudoNoiseOn 0x4000000
+#define bTxPesudoNoise_A 0xff
+#define bTxPesudoNoise_B 0xff00
+#define bTxPesudoNoise_C 0xff0000
+#define bTxPesudoNoise_D 0xff000000
+#define bCCADropOption 0x20000
+#define bCCADropThres 0xfff00000
+#define bEDCCA_H 0xf
+#define bEDCCA_L 0xf0
+#define bLambda_ED 0x300
+#define bRxInitialGain 0x7f
+#define bRxAntDivEn 0x80
+#define bRxAGCAddressForLNA 0x7f00
+#define bRxHighPowerFlow 0x8000
+#define bRxAGCFreezeThres 0xc0000
+#define bRxFreezeStep_AGC1 0x300000
+#define bRxFreezeStep_AGC2 0xc00000
+#define bRxFreezeStep_AGC3 0x3000000
+#define bRxFreezeStep_AGC0 0xc000000
+#define bRxRssi_Cmp_En 0x10000000
+#define bRxQuickAGCEn 0x20000000
+#define bRxAGCFreezeThresMode 0x40000000
+#define bRxOverFlowCheckType 0x80000000
+#define bRxAGCShift 0x7f
+#define bTRSW_Tri_Only 0x80
+#define bPowerThres 0x300
+#define bRxAGCEn 0x1
+#define bRxAGCTogetherEn 0x2
+#define bRxAGCMin 0x4
+#define bRxHP_Ini 0x7
+#define bRxHP_TRLNA 0x70
+#define bRxHP_RSSI 0x700
+#define bRxHP_BBP1 0x7000
+#define bRxHP_BBP2 0x70000
+#define bRxHP_BBP3 0x700000
+#define bRSSI_H 0x7f0000 //the threshold for high power
+#define bRSSI_Gen 0x7f000000 //the threshold for ant diversity
+#define bRxSettle_TRSW 0x7
+#define bRxSettle_LNA 0x38
+#define bRxSettle_RSSI 0x1c0
+#define bRxSettle_BBP 0xe00
+#define bRxSettle_RxHP 0x7000
+#define bRxSettle_AntSW_RSSI 0x38000
+#define bRxSettle_AntSW 0xc0000
+#define bRxProcessTime_DAGC 0x300000
+#define bRxSettle_HSSI 0x400000
+#define bRxProcessTime_BBPPW 0x800000
+#define bRxAntennaPowerShift 0x3000000
+#define bRSSITableSelect 0xc000000
+#define bRxHP_Final 0x7000000
+#define bRxHTSettle_BBP 0x7
+#define bRxHTSettle_HSSI 0x8
+#define bRxHTSettle_RxHP 0x70
+#define bRxHTSettle_BBPPW 0x80
+#define bRxHTSettle_Idle 0x300
+#define bRxHTSettle_Reserved 0x1c00
+#define bRxHTRxHPEn 0x8000
+#define bRxHTAGCFreezeThres 0x30000
+#define bRxHTAGCTogetherEn 0x40000
+#define bRxHTAGCMin 0x80000
+#define bRxHTAGCEn 0x100000
+#define bRxHTDAGCEn 0x200000
+#define bRxHTRxHP_BBP 0x1c00000
+#define bRxHTRxHP_Final 0xe0000000
+#define bRxPWRatioTH 0x3
+#define bRxPWRatioEn 0x4
+#define bRxMFHold 0x3800
+#define bRxPD_Delay_TH1 0x38
+#define bRxPD_Delay_TH2 0x1c0
+#define bRxPD_DC_COUNT_MAX 0x600
+//#define bRxMF_Hold 0x3800
+#define bRxPD_Delay_TH 0x8000
+#define bRxProcess_Delay 0xf0000
+#define bRxSearchrange_GI2_Early 0x700000
+#define bRxFrame_Guard_Counter_L 0x3800000
+#define bRxSGI_Guard_L 0xc000000
+#define bRxSGI_Search_L 0x30000000
+#define bRxSGI_TH 0xc0000000
+#define bDFSCnt0 0xff
+#define bDFSCnt1 0xff00
+#define bDFSFlag 0xf0000
+
+#define bMFWeightSum 0x300000
+#define bMinIdxTH 0x7f000000
+
+#define bDAFormat 0x40000
+
+#define bTxChEmuEnable 0x01000000
+
+#define bTRSWIsolation_A 0x7f
+#define bTRSWIsolation_B 0x7f00
+#define bTRSWIsolation_C 0x7f0000
+#define bTRSWIsolation_D 0x7f000000
+
+#define bExtLNAGain 0x7c00
+
+//page d
+#define bSTBCEn 0x4
+#define bAntennaMapping 0x10
+#define bNss 0x20
+#define bCFOAntSumD 0x200
+#define bPHYCounterReset 0x8000000
+#define bCFOReportGet 0x4000000
+#define bOFDMContinueTx 0x10000000
+#define bOFDMSingleCarrier 0x20000000
+#define bOFDMSingleTone 0x40000000
+//#define bRxPath1 0x01
+//#define bRxPath2 0x02
+//#define bRxPath3 0x04
+//#define bRxPath4 0x08
+//#define bTxPath1 0x10
+//#define bTxPath2 0x20
+#define bHTDetect 0x100
+#define bCFOEn 0x10000
+#define bCFOValue 0xfff00000
+#define bSigTone_Re 0x3f
+#define bSigTone_Im 0x7f00
+#define bCounter_CCA 0xffff
+#define bCounter_ParityFail 0xffff0000
+#define bCounter_RateIllegal 0xffff
+#define bCounter_CRC8Fail 0xffff0000
+#define bCounter_MCSNoSupport 0xffff
+#define bCounter_FastSync 0xffff
+#define bShortCFO 0xfff
+#define bShortCFOTLength 12 //total
+#define bShortCFOFLength 11 //fraction
+#define bLongCFO 0x7ff
+#define bLongCFOTLength 11
+#define bLongCFOFLength 11
+#define bTailCFO 0x1fff
+#define bTailCFOTLength 13
+#define bTailCFOFLength 12
+
+#define bmax_en_pwdB 0xffff
+#define bCC_power_dB 0xffff0000
+#define bnoise_pwdB 0xffff
+#define bPowerMeasTLength 10
+#define bPowerMeasFLength 3
+#define bRx_HT_BW 0x1
+#define bRxSC 0x6
+#define bRx_HT 0x8
+
+#define bNB_intf_det_on 0x1
+#define bIntf_win_len_cfg 0x30
+#define bNB_Intf_TH_cfg 0x1c0
+
+#define bRFGain 0x3f
+#define bTableSel 0x40
+#define bTRSW 0x80
+
+#define bRxSNR_A 0xff
+#define bRxSNR_B 0xff00
+#define bRxSNR_C 0xff0000
+#define bRxSNR_D 0xff000000
+#define bSNREVMTLength 8
+#define bSNREVMFLength 1
+
+#define bCSI1st 0xff
+#define bCSI2nd 0xff00
+#define bRxEVM1st 0xff0000
+#define bRxEVM2nd 0xff000000
+
+#define bSIGEVM 0xff
+#define bPWDB 0xff00
+#define bSGIEN 0x10000
+
+#define bSFactorQAM1 0xf
+#define bSFactorQAM2 0xf0
+#define bSFactorQAM3 0xf00
+#define bSFactorQAM4 0xf000
+#define bSFactorQAM5 0xf0000
+#define bSFactorQAM6 0xf0000
+#define bSFactorQAM7 0xf00000
+#define bSFactorQAM8 0xf000000
+#define bSFactorQAM9 0xf0000000
+#define bCSIScheme 0x100000
+
+#define bNoiseLvlTopSet 0x3
+#define bChSmooth 0x4
+#define bChSmoothCfg1 0x38
+#define bChSmoothCfg2 0x1c0
+#define bChSmoothCfg3 0xe00
+#define bChSmoothCfg4 0x7000
+#define bMRCMode 0x800000
+#define bTHEVMCfg 0x7000000
+
+#define bLoopFitType 0x1
+#define bUpdCFO 0x40
+#define bUpdCFOOffData 0x80
+#define bAdvUpdCFO 0x100
+#define bAdvTimeCtrl 0x800
+#define bUpdClko 0x1000
+#define bFC 0x6000
+#define bTrackingMode 0x8000
+#define bPhCmpEnable 0x10000
+#define bUpdClkoLTF 0x20000
+#define bComChCFO 0x40000
+#define bCSIEstiMode 0x80000
+#define bAdvUpdEqz 0x100000
+#define bUChCfg 0x7000000
+#define bUpdEqz 0x8000000
+
+//page e
+#define bTxAGCRate18_06 0x7f7f7f7f
+#define bTxAGCRate54_24 0x7f7f7f7f
+#define bTxAGCRateMCS32 0x7f
+#define bTxAGCRateCCK 0x7f00
+#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f
+#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f
+#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f
+#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f
+
+
+//Rx Pseduo noise
+#define bRxPesudoNoiseOn 0x20000000
+#define bRxPesudoNoise_A 0xff
+#define bRxPesudoNoise_B 0xff00
+#define bRxPesudoNoise_C 0xff0000
+#define bRxPesudoNoise_D 0xff000000
+#define bPesudoNoiseState_A 0xffff
+#define bPesudoNoiseState_B 0xffff0000
+#define bPesudoNoiseState_C 0xffff
+#define bPesudoNoiseState_D 0xffff0000
+
+//RF
+//Zebra1
+#define bZebra1_HSSIEnable 0x8
+#define bZebra1_TRxControl 0xc00
+#define bZebra1_TRxGainSetting 0x07f
+#define bZebra1_RxCorner 0xc00
+#define bZebra1_TxChargePump 0x38
+#define bZebra1_RxChargePump 0x7
+#define bZebra1_ChannelNum 0xf80
+#define bZebra1_TxLPFBW 0x400
+#define bZebra1_RxLPFBW 0x600
+
+//Zebra4
+#define bRTL8256RegModeCtrl1 0x100
+#define bRTL8256RegModeCtrl0 0x40
+#define bRTL8256_TxLPFBW 0x18
+#define bRTL8256_RxLPFBW 0x600
+
+//RTL8258
+#define bRTL8258_TxLPFBW 0xc
+#define bRTL8258_RxLPFBW 0xc00
+#define bRTL8258_RSSILPFBW 0xc0
+
+//byte endable for sb_write
+#define bByte0 0x1
+#define bByte1 0x2
+#define bByte2 0x4
+#define bByte3 0x8
+#define bWord0 0x3
+#define bWord1 0xc
+#define bDWord 0xf
+
+//for PutRegsetting & GetRegSetting BitMask
+#define bMaskByte0 0xff
+#define bMaskByte1 0xff00
+#define bMaskByte2 0xff0000
+#define bMaskByte3 0xff000000
+#define bMaskHWord 0xffff0000
+#define bMaskLWord 0x0000ffff
+#define bMaskDWord 0xffffffff
+
+//for PutRFRegsetting & GetRFRegSetting BitMask
+#define bMask12Bits 0xfff
+
+#define bEnable 0x1
+#define bDisable 0x0
+
+#define LeftAntenna 0x0
+#define RightAntenna 0x1
+
+#define tCheckTxStatus 500 //500ms
+#define tUpdateRxCounter 100 //100ms
+
+#define rateCCK 0
+#define rateOFDM 1
+#define rateHT 2
+
+//define Register-End
+#define bPMAC_End 0x1ff
+#define bFPGAPHY0_End 0x8ff
+#define bFPGAPHY1_End 0x9ff
+#define bCCKPHY0_End 0xaff
+#define bOFDMPHY0_End 0xcff
+#define bOFDMPHY1_End 0xdff
+
+//define max debug item in each debug page
+//#define bMaxItem_FPGA_PHY0 0x9
+//#define bMaxItem_FPGA_PHY1 0x3
+//#define bMaxItem_PHY_11B 0x16
+//#define bMaxItem_OFDM_PHY0 0x29
+//#define bMaxItem_OFDM_PHY1 0x0
+
+#define bPMACControl 0x0
+#define bWMACControl 0x1
+#define bWNICControl 0x2
+
+#define PathA 0x0
+#define PathB 0x1
+#define PathC 0x2
+#define PathD 0x3
+
+#define rRTL8256RxMixerPole 0xb
+#define bZebraRxMixerPole 0x6
+#define rRTL8256TxBBOPBias 0x9
+#define bRTL8256TxBBOPBias 0x400
+#define rRTL8256TxBBBW 19
+#define bRTL8256TxBBBW 0x18
+
+#endif //__INC_HAL8190PCIPHYREG_H
diff --git a/drivers/staging/serqt_usb/serqt_usb.c b/drivers/staging/serqt_usb/serqt_usb.c
index 234f332fc82f..27f78bddad68 100644
--- a/drivers/staging/serqt_usb/serqt_usb.c
+++ b/drivers/staging/serqt_usb/serqt_usb.c
@@ -12,7 +12,6 @@
#include <linux/usb.h>
#include <linux/wait.h>
#include <linux/types.h>
-#include <linux/version.h>
#include <linux/uaccess.h>
/* Use our own dbg macro */
diff --git a/drivers/staging/stlc45xx/stlc45xx.c b/drivers/staging/stlc45xx/stlc45xx.c
index 3eced5520c56..cfdaac9b747e 100644
--- a/drivers/staging/stlc45xx/stlc45xx.c
+++ b/drivers/staging/stlc45xx/stlc45xx.c
@@ -1787,7 +1787,6 @@ static int stlc45xx_tx_pspoll(struct stlc45xx *stlc, bool powersave)
int payload_len, padding, i;
struct s_lm_data_out *data;
struct txbuffer *entry;
- DECLARE_MAC_BUF(mac);
struct sk_buff *skb;
char *payload;
u16 fc;
@@ -1813,8 +1812,8 @@ static int stlc45xx_tx_pspoll(struct stlc45xx *stlc, bool powersave)
memcpy(pspoll->addr1, stlc->bssid, ETH_ALEN);
memcpy(pspoll->addr2, stlc->mac_addr, ETH_ALEN);
- stlc45xx_debug(DEBUG_PSM, "sending PS-Poll frame to %s (powersave %d, "
- "fc 0x%x, aid %d)", print_mac(mac, pspoll->addr1),
+ stlc45xx_debug(DEBUG_PSM, "sending PS-Poll frame to %pM (powersave %d, "
+ "fc 0x%x, aid %d)", pspoll->addr1,
powersave, fc, stlc->aid);
spin_lock_bh(&stlc->tx_lock);
@@ -1903,7 +1902,6 @@ static int stlc45xx_tx_nullfunc(struct stlc45xx *stlc, bool powersave)
int payload_len, padding, i;
struct s_lm_data_out *data;
struct txbuffer *entry;
- DECLARE_MAC_BUF(mac);
struct sk_buff *skb;
char *payload;
u16 fc;
@@ -1928,9 +1926,8 @@ static int stlc45xx_tx_nullfunc(struct stlc45xx *stlc, bool powersave)
memcpy(nullfunc->addr2, stlc->mac_addr, ETH_ALEN);
memcpy(nullfunc->addr3, stlc->bssid, ETH_ALEN);
- stlc45xx_debug(DEBUG_PSM, "sending Null frame to %s (powersave %d, "
- "fc 0x%x)",
- print_mac(mac, nullfunc->addr1), powersave, fc);
+ stlc45xx_debug(DEBUG_PSM, "sending Null frame to %pM (powersave %d, "
+ "fc 0x%x)", nullfunc->addr1, powersave, fc);
spin_lock_bh(&stlc->tx_lock);
diff --git a/drivers/staging/sxg/sxg.c b/drivers/staging/sxg/sxg.c
index 076b3f7d39eb..f7306da7d3b6 100644
--- a/drivers/staging/sxg/sxg.c
+++ b/drivers/staging/sxg/sxg.c
@@ -355,7 +355,7 @@ void sxg_remove_msix_isr(struct adapter_t *adapter)
for(i=0; i< adapter->nr_msix_entries;i++)
{
vector = adapter->msi_entries[i].vector;
- DBG_ERROR("%s : Freeing IRQ vector#%d\n",__FUNCTION__,vector);
+ DBG_ERROR("%s : Freeing IRQ vector#%d\n",__func__,vector);
free_irq(vector,netdev);
}
}
@@ -852,7 +852,7 @@ static inline int sxg_read_config(struct adapter_t *adapter)
* Get out of here
*/
printk(KERN_ERR"%s : Could not allocate memory for reading \
- EEPROM\n", __FUNCTION__);
+ EEPROM\n", __func__);
return -ENOMEM;
}
@@ -887,7 +887,7 @@ static inline int sxg_read_config(struct adapter_t *adapter)
case SXG_CFG_LOAD_ERROR:
default: /* Fix default handler later */
printk(KERN_WARNING"%s : We could not read the config \
- word. Status = %ld\n", __FUNCTION__, status);
+ word. Status = %ld\n", __func__, status);
break;
}
pci_free_consistent(adapter->pcidev, sizeof(struct sw_cfg_data), data,
@@ -996,7 +996,7 @@ static int sxg_entry_probe(struct pci_dev *pcidev,
adapter->asictype = SAHARA_REV_B;
} else {
ASSERT(0);
- DBG_ERROR("%s Unexpected revision ID %x\n", __FUNCTION__, revision_id);
+ DBG_ERROR("%s Unexpected revision ID %x\n", __func__, revision_id);
goto err_out_exit_sxg_probe;
}
adapter->netdev = netdev;
@@ -1176,9 +1176,9 @@ static int sxg_entry_probe(struct pci_dev *pcidev,
smp_processor_id());
pci_disable_device(pcidev);
- DBG_ERROR("sxg: %s deallocate device\n", __FUNCTION__);
+ DBG_ERROR("sxg: %s deallocate device\n", __func__);
kfree(netdev);
- printk("Exit %s, Sxg driver loading failed..\n", __FUNCTION__);
+ printk("Exit %s, Sxg driver loading failed..\n", __func__);
return -ENODEV;
}
@@ -2191,10 +2191,10 @@ static int sxg_entry_open(struct net_device *dev)
/*
* The microcode expects it to be downloaded on every open.
*/
- DBG_ERROR("sxg: %s ENTER sxg_download_microcode\n", __FUNCTION__);
+ DBG_ERROR("sxg: %s ENTER sxg_download_microcode\n", __func__);
if (sxg_download_microcode(adapter, SXG_UCODE_SYSTEM)) {
DBG_ERROR("sxg: %s ENTER sxg_adapter_set_hwaddr\n",
- __FUNCTION__);
+ __func__);
sxg_read_config(adapter);
} else {
adapter->state = ADAPT_FAIL;
@@ -2307,14 +2307,14 @@ static void __devexit sxg_entry_remove(struct pci_dev *pcidev)
mmio_start = pci_resource_start(pcidev, 0);
mmio_len = pci_resource_len(pcidev, 0);
- DBG_ERROR("sxg: %s rel_region(0) start[%x] len[%x]\n", __FUNCTION__,
+ DBG_ERROR("sxg: %s rel_region(0) start[%x] len[%x]\n", __func__,
mmio_start, mmio_len);
release_mem_region(mmio_start, mmio_len);
mmio_start = pci_resource_start(pcidev, 2);
mmio_len = pci_resource_len(pcidev, 2);
- DBG_ERROR("sxg: %s rel_region(2) start[%x] len[%x]\n", __FUNCTION__,
+ DBG_ERROR("sxg: %s rel_region(2) start[%x] len[%x]\n", __func__,
mmio_start, mmio_len);
release_mem_region(mmio_start, mmio_len);
@@ -2400,7 +2400,7 @@ static int sxg_entry_halt(struct net_device *dev)
atomic_set(&adapter->pending_allocations, 0);
adapter->intrregistered = 0;
sxg_remove_isr(adapter);
- DBG_ERROR("sxg: %s (%s) EXIT\n", __FUNCTION__, dev->name);
+ DBG_ERROR("sxg: %s (%s) EXIT\n", __func__, dev->name);
return (STATUS_SUCCESS);
}
@@ -2454,7 +2454,7 @@ static int sxg_send_packets(struct sk_buff *skb, struct net_device *dev)
u32 status = STATUS_SUCCESS;
/*
- * DBG_ERROR("sxg: %s ENTER sxg_send_packets skb[%p]\n", __FUNCTION__,
+ * DBG_ERROR("sxg: %s ENTER sxg_send_packets skb[%p]\n", __func__,
* skb);
*/
@@ -3405,7 +3405,7 @@ static int sxg_read_mdio_reg(struct adapter_t *adapter,
SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "WrtMDIO",
adapter, 0, 0, 0);
- DBG_ERROR("ENTER %s\n", __FUNCTION__);
+ DBG_ERROR("ENTER %s\n", __func__);
/* Ensure values don't exceed field width */
DevAddr &= 0x001F; /* 5-bit field */
@@ -3441,7 +3441,7 @@ static int sxg_read_mdio_reg(struct adapter_t *adapter,
udelay(100); /* Timeout in 100us units */
READ_REG(HwRegs->MacAmiimIndicator, ValueRead);
if (--Timeout == 0) {
- DBG_ERROR("EXIT %s with STATUS_FAILURE 1\n", __FUNCTION__);
+ DBG_ERROR("EXIT %s with STATUS_FAILURE 1\n", __func__);
return (STATUS_FAILURE);
}
@@ -3462,7 +3462,7 @@ static int sxg_read_mdio_reg(struct adapter_t *adapter,
udelay(100); /* Timeout in 100us units */
READ_REG(HwRegs->MacAmiimIndicator, ValueRead);
if (--Timeout == 0) {
- DBG_ERROR("EXIT %s with STATUS_FAILURE 2\n", __FUNCTION__);
+ DBG_ERROR("EXIT %s with STATUS_FAILURE 2\n", __func__);
return (STATUS_FAILURE);
}
@@ -3472,7 +3472,7 @@ static int sxg_read_mdio_reg(struct adapter_t *adapter,
READ_REG(HwRegs->MacAmiimField, *pValue);
*pValue &= 0xFFFF; /* data is in the lower 16 bits */
- DBG_ERROR("EXIT %s\n", __FUNCTION__);
+ DBG_ERROR("EXIT %s\n", __func__);
return (STATUS_SUCCESS);
}
@@ -3545,7 +3545,7 @@ static void sxg_mcast_set_mask(struct adapter_t *adapter)
{
struct sxg_ucode_regs *sxg_regs = adapter->UcodeRegs;
- DBG_ERROR("%s ENTER (%s) MacFilter[%x] mask[%llx]\n", __FUNCTION__,
+ DBG_ERROR("%s ENTER (%s) MacFilter[%x] mask[%llx]\n", __func__,
adapter->netdev->name, (unsigned int)adapter->MacFilter,
adapter->MulticastMask);
@@ -4055,7 +4055,7 @@ static int sxg_adapter_set_hwaddr(struct adapter_t *adapter)
* sxg_dbg_macaddrs(adapter);
*/
/* DBG_ERROR ("%s AFTER copying from config.macinfo into currmacaddr\n",
- * __FUNCTION__);
+ * __func__);
*/
/* sxg_dbg_macaddrs(adapter); */
@@ -4066,7 +4066,7 @@ static int sxg_adapter_set_hwaddr(struct adapter_t *adapter)
printk("sxg: Dev is Null\n");
}
- DBG_ERROR("%s ENTER (%s)\n", __FUNCTION__, adapter->netdev->name);
+ DBG_ERROR("%s ENTER (%s)\n", __func__, adapter->netdev->name);
if (netif_running(dev)) {
return -EBUSY;
diff --git a/drivers/staging/sxg/sxg_ethtool.c b/drivers/staging/sxg/sxg_ethtool.c
index 97f765d1250f..ad89cb829b85 100644
--- a/drivers/staging/sxg/sxg_ethtool.c
+++ b/drivers/staging/sxg/sxg_ethtool.c
@@ -278,7 +278,7 @@ static int sxg_nic_get_eeprom(struct net_device *netdev,
* Get out of here
*/
printk(KERN_ERR"%s : Could not allocate memory for reading \
- EEPROM\n", __FUNCTION__);
+ EEPROM\n", __func__);
return -ENOMEM;
}
diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h
new file mode 100644
index 000000000000..b4bbb8d3c243
--- /dev/null
+++ b/drivers/staging/vt6655/80211hdr.h
@@ -0,0 +1,357 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: 80211hdr.h
+ *
+ * Purpose: Defines the macros, types, and functions for dealing
+ * with 802.11 MAC headers.
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Apr 8, 2002
+ *
+ */
+
+
+
+#ifndef __80211HDR_H__
+#define __80211HDR_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+// bit type
+#define BIT0 0x00000001
+#define BIT1 0x00000002
+#define BIT2 0x00000004
+#define BIT3 0x00000008
+#define BIT4 0x00000010
+#define BIT5 0x00000020
+#define BIT6 0x00000040
+#define BIT7 0x00000080
+#define BIT8 0x00000100
+#define BIT9 0x00000200
+#define BIT10 0x00000400
+#define BIT11 0x00000800
+#define BIT12 0x00001000
+#define BIT13 0x00002000
+#define BIT14 0x00004000
+#define BIT15 0x00008000
+#define BIT16 0x00010000
+#define BIT17 0x00020000
+#define BIT18 0x00040000
+#define BIT19 0x00080000
+#define BIT20 0x00100000
+#define BIT21 0x00200000
+#define BIT22 0x00400000
+#define BIT23 0x00800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+
+// 802.11 frame related, defined as 802.11 spec
+#define WLAN_ADDR_LEN 6
+#define WLAN_CRC_LEN 4
+#define WLAN_CRC32_LEN 4
+#define WLAN_FCS_LEN 4
+#define WLAN_BSSID_LEN 6
+#define WLAN_BSS_TS_LEN 8
+#define WLAN_HDR_ADDR2_LEN 16
+#define WLAN_HDR_ADDR3_LEN 24
+#define WLAN_HDR_ADDR4_LEN 30
+#define WLAN_IEHDR_LEN 2
+#define WLAN_SSID_MAXLEN 32
+//#define WLAN_RATES_MAXLEN 255
+#define WLAN_RATES_MAXLEN 16
+#define WLAN_RATES_MAXLEN_11B 4
+#define WLAN_RSN_MAXLEN 32
+#define WLAN_DATA_MAXLEN 2312
+#define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
+
+
+#define WLAN_BEACON_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0)
+#define WLAN_NULLDATA_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0)
+#define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2)
+#define WLAN_ASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_ASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_REASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_REASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_PROBEREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_PROBERESP_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_AUTHEN_FR_MAXLEN WLAN_A3FR_MAXLEN
+#define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2)
+
+
+#define WLAN_WEP_NKEYS 4
+#define WLAN_WEP40_KEYLEN 5
+#define WLAN_WEP104_KEYLEN 13
+#define WLAN_WEP232_KEYLEN 29
+//#define WLAN_WEPMAX_KEYLEN 29
+#define WLAN_WEPMAX_KEYLEN 32
+#define WLAN_CHALLENGE_IE_MAXLEN 255
+#define WLAN_CHALLENGE_IE_LEN 130
+#define WLAN_CHALLENGE_LEN 128
+#define WLAN_WEP_IV_LEN 4
+#define WLAN_WEP_ICV_LEN 4
+#define WLAN_FRAGS_MAX 16
+
+// Frame Type
+#define WLAN_TYPE_MGR 0x00
+#define WLAN_TYPE_CTL 0x01
+#define WLAN_TYPE_DATA 0x02
+
+#define WLAN_FTYPE_MGMT 0x00
+#define WLAN_FTYPE_CTL 0x01
+#define WLAN_FTYPE_DATA 0x02
+
+
+// Frame Subtypes
+#define WLAN_FSTYPE_ASSOCREQ 0x00
+#define WLAN_FSTYPE_ASSOCRESP 0x01
+#define WLAN_FSTYPE_REASSOCREQ 0x02
+#define WLAN_FSTYPE_REASSOCRESP 0x03
+#define WLAN_FSTYPE_PROBEREQ 0x04
+#define WLAN_FSTYPE_PROBERESP 0x05
+#define WLAN_FSTYPE_BEACON 0x08
+#define WLAN_FSTYPE_ATIM 0x09
+#define WLAN_FSTYPE_DISASSOC 0x0a
+#define WLAN_FSTYPE_AUTHEN 0x0b
+#define WLAN_FSTYPE_DEAUTHEN 0x0c
+#define WLAN_FSTYPE_ACTION 0x0d
+
+// Control
+#define WLAN_FSTYPE_PSPOLL 0x0a
+#define WLAN_FSTYPE_RTS 0x0b
+#define WLAN_FSTYPE_CTS 0x0c
+#define WLAN_FSTYPE_ACK 0x0d
+#define WLAN_FSTYPE_CFEND 0x0e
+#define WLAN_FSTYPE_CFENDCFACK 0x0f
+
+// Data
+#define WLAN_FSTYPE_DATAONLY 0x00
+#define WLAN_FSTYPE_DATA_CFACK 0x01
+#define WLAN_FSTYPE_DATA_CFPOLL 0x02
+#define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
+#define WLAN_FSTYPE_NULL 0x04
+#define WLAN_FSTYPE_CFACK 0x05
+#define WLAN_FSTYPE_CFPOLL 0x06
+#define WLAN_FSTYPE_CFACK_CFPOLL 0x07
+
+
+#ifdef __BIG_ENDIAN
+
+// GET & SET Frame Control bit
+#define WLAN_GET_FC_PRVER(n) ((((WORD)(n) >> 8) & (BIT0 | BIT1))
+#define WLAN_GET_FC_FTYPE(n) ((((WORD)(n) >> 8) & (BIT2 | BIT3)) >> 2)
+#define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
+#define WLAN_GET_FC_TODS(n) ((((WORD)(n) << 8) & (BIT8)) >> 8)
+#define WLAN_GET_FC_FROMDS(n) ((((WORD)(n) << 8) & (BIT9)) >> 9)
+#define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n) << 8) & (BIT10)) >> 10)
+#define WLAN_GET_FC_RETRY(n) ((((WORD)(n) << 8) & (BIT11)) >> 11)
+#define WLAN_GET_FC_PWRMGT(n) ((((WORD)(n) << 8) & (BIT12)) >> 12)
+#define WLAN_GET_FC_MOREDATA(n) ((((WORD)(n) << 8) & (BIT13)) >> 13)
+#define WLAN_GET_FC_ISWEP(n) ((((WORD)(n) << 8) & (BIT14)) >> 14)
+#define WLAN_GET_FC_ORDER(n) ((((WORD)(n) << 8) & (BIT15)) >> 15)
+
+// Sequence Field bit
+#define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3))
+#define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
+
+
+// Capability Field bit
+#define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0)
+#define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1)
+#define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2)
+#define WLAN_GET_CAP_INFO_CFPOLLREQ(n) ((((n) >> 8) & BIT3) >> 3)
+#define WLAN_GET_CAP_INFO_PRIVACY(n) ((((n) >> 8) & BIT4) >> 4)
+#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5)
+#define WLAN_GET_CAP_INFO_PBCC(n) ((((n) >> 8) & BIT6) >> 6)
+#define WLAN_GET_CAP_INFO_AGILITY(n) ((((n) >> 8) & BIT7) >> 7)
+#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) ((((n)) & BIT8) >> 10)
+#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n)) & BIT10) >> 10)
+#define WLAN_GET_CAP_INFO_DSSSOFDM(n) ((((n)) & BIT13) >> 13)
+#define WLAN_GET_CAP_INFO_GRPACK(n) ((((n)) & BIT14) >> 14)
+
+
+#else
+
+// GET & SET Frame Control bit
+#define WLAN_GET_FC_PRVER(n) (((WORD)(n)) & (BIT0 | BIT1))
+#define WLAN_GET_FC_FTYPE(n) ((((WORD)(n)) & (BIT2 | BIT3)) >> 2)
+#define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
+#define WLAN_GET_FC_TODS(n) ((((WORD)(n)) & (BIT8)) >> 8)
+#define WLAN_GET_FC_FROMDS(n) ((((WORD)(n)) & (BIT9)) >> 9)
+#define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n)) & (BIT10)) >> 10)
+#define WLAN_GET_FC_RETRY(n) ((((WORD)(n)) & (BIT11)) >> 11)
+#define WLAN_GET_FC_PWRMGT(n) ((((WORD)(n)) & (BIT12)) >> 12)
+#define WLAN_GET_FC_MOREDATA(n) ((((WORD)(n)) & (BIT13)) >> 13)
+#define WLAN_GET_FC_ISWEP(n) ((((WORD)(n)) & (BIT14)) >> 14)
+#define WLAN_GET_FC_ORDER(n) ((((WORD)(n)) & (BIT15)) >> 15)
+
+
+// Sequence Field bit
+#define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n)) & (BIT0|BIT1|BIT2|BIT3))
+#define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
+
+
+// Capability Field bit
+#define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0)
+#define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1)
+#define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2)
+#define WLAN_GET_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3)
+#define WLAN_GET_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4)
+#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5)
+#define WLAN_GET_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6)
+#define WLAN_GET_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7)
+#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) (((n) & BIT8) >> 10)
+#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10)
+#define WLAN_GET_CAP_INFO_DSSSOFDM(n) (((n) & BIT13) >> 13)
+#define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14)
+
+
+#endif //#ifdef __BIG_ENDIAN
+
+
+#define WLAN_SET_CAP_INFO_ESS(n) (n)
+#define WLAN_SET_CAP_INFO_IBSS(n) ((n) << 1)
+#define WLAN_SET_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
+#define WLAN_SET_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
+#define WLAN_SET_CAP_INFO_PRIVACY(n) ((n) << 4)
+#define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5)
+#define WLAN_SET_CAP_INFO_SPECTRUMMNG(n) ((n) << 8)
+#define WLAN_SET_CAP_INFO_PBCC(n) ((n) << 6)
+#define WLAN_SET_CAP_INFO_AGILITY(n) ((n) << 7)
+#define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10)
+#define WLAN_SET_CAP_INFO_DSSSOFDM(n) ((n) << 13)
+#define WLAN_SET_CAP_INFO_GRPACK(n) ((n) << 14)
+
+
+#define WLAN_SET_FC_PRVER(n) ((WORD)(n))
+#define WLAN_SET_FC_FTYPE(n) (((WORD)(n)) << 2)
+#define WLAN_SET_FC_FSTYPE(n) (((WORD)(n)) << 4)
+#define WLAN_SET_FC_TODS(n) (((WORD)(n)) << 8)
+#define WLAN_SET_FC_FROMDS(n) (((WORD)(n)) << 9)
+#define WLAN_SET_FC_MOREFRAG(n) (((WORD)(n)) << 10)
+#define WLAN_SET_FC_RETRY(n) (((WORD)(n)) << 11)
+#define WLAN_SET_FC_PWRMGT(n) (((WORD)(n)) << 12)
+#define WLAN_SET_FC_MOREDATA(n) (((WORD)(n)) << 13)
+#define WLAN_SET_FC_ISWEP(n) (((WORD)(n)) << 14)
+#define WLAN_SET_FC_ORDER(n) (((WORD)(n)) << 15)
+
+#define WLAN_SET_SEQ_FRGNUM(n) ((WORD)(n))
+#define WLAN_SET_SEQ_SEQNUM(n) (((WORD)(n)) << 4)
+
+// ERP Field bit
+
+#define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0)
+#define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1)
+#define WLAN_GET_ERP_BARKER_MODE(n) (((n) & BIT2) >> 2)
+
+#define WLAN_SET_ERP_NONERP_PRESENT(n) (n)
+#define WLAN_SET_ERP_USE_PROTECTION(n) ((n) << 1)
+#define WLAN_SET_ERP_BARKER_MODE(n) ((n) << 2)
+
+
+
+// Support & Basic Rates field
+#define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7)
+#define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7)
+
+// TIM field
+#define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0)
+#define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1)
+
+// 3-Addr & 4-Addr
+#define WLAN_HDR_A3_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR3_LEN)
+#define WLAN_HDR_A4_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR4_LEN)
+
+// IEEE ADDR
+#define IEEE_ADDR_UNIVERSAL 0x02
+#define IEEE_ADDR_GROUP 0x01
+
+typedef struct {
+ BYTE abyAddr[6];
+} IEEE_ADDR, *PIEEE_ADDR;
+
+// 802.11 Header Format
+
+typedef struct tagWLAN_80211HDR_A2 {
+
+ WORD wFrameCtl;
+ WORD wDurationID;
+ BYTE abyAddr1[WLAN_ADDR_LEN];
+ BYTE abyAddr2[WLAN_ADDR_LEN];
+
+}__attribute__ ((__packed__))
+WLAN_80211HDR_A2, *PWLAN_80211HDR_A2;
+
+typedef struct tagWLAN_80211HDR_A3 {
+
+ WORD wFrameCtl;
+ WORD wDurationID;
+ BYTE abyAddr1[WLAN_ADDR_LEN];
+ BYTE abyAddr2[WLAN_ADDR_LEN];
+ BYTE abyAddr3[WLAN_ADDR_LEN];
+ WORD wSeqCtl;
+
+}__attribute__ ((__packed__))
+WLAN_80211HDR_A3, *PWLAN_80211HDR_A3;
+
+typedef struct tagWLAN_80211HDR_A4 {
+
+ WORD wFrameCtl;
+ WORD wDurationID;
+ BYTE abyAddr1[WLAN_ADDR_LEN];
+ BYTE abyAddr2[WLAN_ADDR_LEN];
+ BYTE abyAddr3[WLAN_ADDR_LEN];
+ WORD wSeqCtl;
+ BYTE abyAddr4[WLAN_ADDR_LEN];
+
+}__attribute__ ((__packed__))
+WLAN_80211HDR_A4, *PWLAN_80211HDR_A4;
+
+
+typedef union tagUWLAN_80211HDR {
+
+ WLAN_80211HDR_A2 sA2;
+ WLAN_80211HDR_A3 sA3;
+ WLAN_80211HDR_A4 sA4;
+
+} UWLAN_80211HDR, *PUWLAN_80211HDR;
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+#endif // __80211HDR_H__
+
+
diff --git a/drivers/staging/vt6655/80211mgr.c b/drivers/staging/vt6655/80211mgr.c
new file mode 100644
index 000000000000..84745fb6b035
--- /dev/null
+++ b/drivers/staging/vt6655/80211mgr.c
@@ -0,0 +1,1050 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: 80211mgr.c
+ *
+ * Purpose: Handles the 802.11 managment support functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2002
+ *
+ * Functions:
+ * vMgrEncodeBeacon - Encode the Beacon frame
+ * vMgrDecodeBeacon - Decode the Beacon frame
+ * vMgrEncodeIBSSATIM - Encode the IBSS ATIM frame
+ * vMgrDecodeIBSSATIM - Decode the IBSS ATIM frame
+ * vMgrEncodeDisassociation - Encode the Disassociation frame
+ * vMgrDecodeDisassociation - Decode the Disassociation frame
+ * vMgrEncodeAssocRequest - Encode the Association request frame
+ * vMgrDecodeAssocRequest - Decode the Association request frame
+ * vMgrEncodeAssocResponse - Encode the Association response frame
+ * vMgrDecodeAssocResponse - Decode the Association response frame
+ * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame
+ * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame
+ * vMgrEncodeProbeRequest - Encode the Probe request frame
+ * vMgrDecodeProbeRequest - Decode the Probe request frame
+ * vMgrEncodeProbeResponse - Encode the Probe response frame
+ * vMgrDecodeProbeResponse - Decode the Probe response frame
+ * vMgrEncodeAuthen - Encode the Authentication frame
+ * vMgrDecodeAuthen - Decode the Authentication frame
+ * vMgrEncodeDeauthen - Encode the DeAuthentication frame
+ * vMgrDecodeDeauthen - Decode the DeAuthentication frame
+ * vMgrEncodeReassocResponse - Encode the Reassociation response frame
+ * vMgrDecodeReassocResponse - Decode the Reassociation response frame
+ *
+ * Revision History:
+ *
+ */
+
+
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WPA_H__)
+#include "wpa.h"
+#endif
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Functions --------------------------*/
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Beacon frame body offset
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeBeacon(
+ IN PWLAN_FR_BEACON pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_BEACON_OFF_TS);
+ pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_BEACON_OFF_BCN_INT);
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_BEACON_OFF_CAPINFO);
+
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
+
+ return;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Decode Beacon frame body offset
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrDecodeBeacon(
+ IN PWLAN_FR_BEACON pFrame
+ )
+{
+ PWLAN_IE pItem;
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_BEACON_OFF_TS);
+ pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_BEACON_OFF_BCN_INT);
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_BEACON_OFF_CAPINFO);
+
+ // Information elements
+ pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
+ + WLAN_BEACON_OFF_SSID);
+ while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ){
+
+ switch (pItem->byElementID) {
+ case WLAN_EID_SSID:
+ if (pFrame->pSSID == NULL)
+ pFrame->pSSID = (PWLAN_IE_SSID)pItem;
+ break;
+ case WLAN_EID_SUPP_RATES:
+ if (pFrame->pSuppRates == NULL)
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+ case WLAN_EID_FH_PARMS:
+ //pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem;
+ break;
+ case WLAN_EID_DS_PARMS:
+ if (pFrame->pDSParms == NULL)
+ pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
+ break;
+ case WLAN_EID_CF_PARMS:
+ if (pFrame->pCFParms == NULL)
+ pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
+ break;
+ case WLAN_EID_IBSS_PARMS:
+ if (pFrame->pIBSSParms == NULL)
+ pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
+ break;
+ case WLAN_EID_TIM:
+ if (pFrame->pTIM == NULL)
+ pFrame->pTIM = (PWLAN_IE_TIM)pItem;
+ break;
+
+ case WLAN_EID_RSN:
+ if (pFrame->pRSN == NULL) {
+ pFrame->pRSN = (PWLAN_IE_RSN)pItem;
+ }
+ break;
+ case WLAN_EID_RSN_WPA:
+ if (pFrame->pRSNWPA == NULL) {
+ if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
+ pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
+ }
+ break;
+
+ case WLAN_EID_ERP:
+ if (pFrame->pERP == NULL)
+ pFrame->pERP = (PWLAN_IE_ERP)pItem;
+ break;
+ case WLAN_EID_EXTSUPP_RATES:
+ if (pFrame->pExtSuppRates == NULL)
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ case WLAN_EID_COUNTRY: //7
+ if (pFrame->pIE_Country == NULL)
+ pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
+ break;
+
+ case WLAN_EID_PWR_CONSTRAINT: //32
+ if (pFrame->pIE_PowerConstraint == NULL)
+ pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
+ break;
+
+ case WLAN_EID_CH_SWITCH: //37
+ if (pFrame->pIE_CHSW == NULL)
+ pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
+ break;
+
+ case WLAN_EID_QUIET: //40
+ if (pFrame->pIE_Quiet == NULL)
+ pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
+ break;
+
+ case WLAN_EID_IBSS_DFS:
+ if (pFrame->pIE_IBSSDFS == NULL)
+ pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
+ break;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
+ break;
+
+ }
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+ }
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode IBSS ATIM
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrEncodeIBSSATIM(
+ IN PWLAN_FR_IBSSATIM pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+ pFrame->len = WLAN_HDR_ADDR3_LEN;
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode IBSS ATIM
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeIBSSATIM(
+ IN PWLAN_FR_IBSSATIM pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Disassociation
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeDisassociation(
+ IN PWLAN_FR_DISASSOC pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+
+ // Fixed Fields
+ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_DISASSOC_OFF_REASON);
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode Disassociation
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeDisassociation(
+ IN PWLAN_FR_DISASSOC pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_DISASSOC_OFF_REASON);
+
+ return;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Encode Association Request
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrEncodeAssocRequest(
+ IN PWLAN_FR_ASSOCREQ pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCREQ_OFF_CAP_INFO);
+ pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCREQ_OFF_LISTEN_INT);
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description: (AP)
+ * Decode Association Request
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeAssocRequest(
+ IN PWLAN_FR_ASSOCREQ pFrame
+ )
+{
+ PWLAN_IE pItem;
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCREQ_OFF_CAP_INFO);
+ pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCREQ_OFF_LISTEN_INT);
+
+ // Information elements
+ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCREQ_OFF_SSID);
+
+ while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
+ switch (pItem->byElementID){
+ case WLAN_EID_SSID:
+ if (pFrame->pSSID == NULL)
+ pFrame->pSSID = (PWLAN_IE_SSID)pItem;
+ break;
+ case WLAN_EID_SUPP_RATES:
+ if (pFrame->pSuppRates == NULL)
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ case WLAN_EID_RSN:
+ if (pFrame->pRSN == NULL) {
+ pFrame->pRSN = (PWLAN_IE_RSN)pItem;
+ }
+ break;
+ case WLAN_EID_RSN_WPA:
+ if (pFrame->pRSNWPA == NULL) {
+ if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
+ pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
+ }
+ break;
+ case WLAN_EID_EXTSUPP_RATES:
+ if (pFrame->pExtSuppRates == NULL)
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
+ pItem->byElementID);
+ break;
+ }
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+ }
+ return;
+}
+
+/*+
+ *
+ * Routine Description: (AP)
+ * Encode Association Response
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeAssocResponse(
+ IN PWLAN_FR_ASSOCRESP pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_CAP_INFO);
+ pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_STATUS);
+ pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_AID);
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
+ + sizeof(*(pFrame->pwAid));
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode Association Response
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeAssocResponse(
+ IN PWLAN_FR_ASSOCRESP pFrame
+ )
+{
+ PWLAN_IE pItem;
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_CAP_INFO);
+ pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_STATUS);
+ pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_AID);
+
+ // Information elements
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_ASSOCRESP_OFF_SUPP_RATES);
+
+ pItem = (PWLAN_IE)(pFrame->pSuppRates);
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+
+ if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
+ }
+ else {
+ pFrame->pExtSuppRates = NULL;
+ }
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Reassociation Request
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeReassocRequest(
+ IN PWLAN_FR_REASSOCREQ pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_CAP_INFO);
+ pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_LISTEN_INT);
+ pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_CURR_AP);
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description: (AP)
+ * Decode Reassociation Request
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrDecodeReassocRequest(
+ IN PWLAN_FR_REASSOCREQ pFrame
+ )
+{
+ PWLAN_IE pItem;
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_CAP_INFO);
+ pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_LISTEN_INT);
+ pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_CURR_AP);
+
+ // Information elements
+ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCREQ_OFF_SSID);
+
+ while(((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
+
+ switch (pItem->byElementID){
+ case WLAN_EID_SSID:
+ if (pFrame->pSSID == NULL)
+ pFrame->pSSID = (PWLAN_IE_SSID)pItem;
+ break;
+ case WLAN_EID_SUPP_RATES:
+ if (pFrame->pSuppRates == NULL)
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ case WLAN_EID_RSN:
+ if (pFrame->pRSN == NULL) {
+ pFrame->pRSN = (PWLAN_IE_RSN)pItem;
+ }
+ break;
+ case WLAN_EID_RSN_WPA:
+ if (pFrame->pRSNWPA == NULL) {
+ if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
+ pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
+ }
+ break;
+
+ case WLAN_EID_EXTSUPP_RATES:
+ if (pFrame->pExtSuppRates == NULL)
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
+ pItem->byElementID);
+ break;
+ }
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+ }
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Probe Request
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrEncodeProbeRequest(
+ IN PWLAN_FR_PROBEREQ pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+ pFrame->len = WLAN_HDR_ADDR3_LEN;
+ return;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Decode Probe Request
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeProbeRequest(
+ IN PWLAN_FR_PROBEREQ pFrame
+ )
+{
+ PWLAN_IE pItem;
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Information elements
+ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
+
+ while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) {
+
+ switch (pItem->byElementID) {
+ case WLAN_EID_SSID:
+ if (pFrame->pSSID == NULL)
+ pFrame->pSSID = (PWLAN_IE_SSID)pItem;
+ break;
+
+ case WLAN_EID_SUPP_RATES:
+ if (pFrame->pSuppRates == NULL)
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ case WLAN_EID_EXTSUPP_RATES:
+ if (pFrame->pExtSuppRates == NULL)
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
+ break;
+ }
+
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+ }
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Probe Response
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrEncodeProbeResponse(
+ IN PWLAN_FR_PROBERESP pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_TS);
+ pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_BCN_INT);
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_CAP_INFO);
+
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
+ sizeof(*(pFrame->pwCapInfo));
+
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode Probe Response
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeProbeResponse(
+ IN PWLAN_FR_PROBERESP pFrame
+ )
+{
+ PWLAN_IE pItem;
+// BYTE byCheckEID = 0;
+
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_TS);
+ pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_BCN_INT);
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_CAP_INFO);
+
+ // Information elements
+ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_PROBERESP_OFF_SSID);
+
+ while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) {
+ /*
+ if (pItem->byElementID < byCheckEID)
+ break;
+ else
+ byCheckEID = pItem->byElementID;
+*/
+ switch (pItem->byElementID) {
+ case WLAN_EID_SSID:
+ if (pFrame->pSSID == NULL)
+ pFrame->pSSID = (PWLAN_IE_SSID)pItem;
+ break;
+ case WLAN_EID_SUPP_RATES:
+ if (pFrame->pSuppRates == NULL)
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+ case WLAN_EID_FH_PARMS:
+ break;
+ case WLAN_EID_DS_PARMS:
+ if (pFrame->pDSParms == NULL)
+ pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
+ break;
+ case WLAN_EID_CF_PARMS:
+ if (pFrame->pCFParms == NULL)
+ pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
+ break;
+ case WLAN_EID_IBSS_PARMS:
+ if (pFrame->pIBSSParms == NULL)
+ pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
+ break;
+
+ case WLAN_EID_RSN:
+ if (pFrame->pRSN == NULL) {
+ pFrame->pRSN = (PWLAN_IE_RSN)pItem;
+ }
+ break;
+ case WLAN_EID_RSN_WPA:
+ if (pFrame->pRSNWPA == NULL) {
+ if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
+ pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
+ }
+ break;
+ case WLAN_EID_ERP:
+ if (pFrame->pERP == NULL)
+ pFrame->pERP = (PWLAN_IE_ERP)pItem;
+ break;
+ case WLAN_EID_EXTSUPP_RATES:
+ if (pFrame->pExtSuppRates == NULL)
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ break;
+
+ case WLAN_EID_COUNTRY: //7
+ if (pFrame->pIE_Country == NULL)
+ pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
+ break;
+
+ case WLAN_EID_PWR_CONSTRAINT: //32
+ if (pFrame->pIE_PowerConstraint == NULL)
+ pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
+ break;
+
+ case WLAN_EID_CH_SWITCH: //37
+ if (pFrame->pIE_CHSW == NULL)
+ pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
+ break;
+
+ case WLAN_EID_QUIET: //40
+ if (pFrame->pIE_Quiet == NULL)
+ pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
+ break;
+
+ case WLAN_EID_IBSS_DFS:
+ if (pFrame->pIE_IBSSDFS == NULL)
+ pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
+ break;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
+ break;
+ }
+
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+ }
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Authentication frame
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeAuthen(
+ IN PWLAN_FR_AUTHEN pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_AUTH_ALG);
+ pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_AUTH_SEQ);
+ pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_STATUS);
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode Authentication
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeAuthen(
+ IN PWLAN_FR_AUTHEN pFrame
+ )
+{
+ PWLAN_IE pItem;
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_AUTH_ALG);
+ pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_AUTH_SEQ);
+ pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_STATUS);
+
+ // Information elements
+ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_AUTHEN_OFF_CHALLENGE);
+
+ if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) {
+ pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
+ }
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Encode Authentication
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeDeauthen(
+ IN PWLAN_FR_DEAUTHEN pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_DEAUTHEN_OFF_REASON);
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode Deauthentication
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDecodeDeauthen(
+ IN PWLAN_FR_DEAUTHEN pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_DEAUTHEN_OFF_REASON);
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description: (AP)
+ * Encode Reassociation Response
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrEncodeReassocResponse(
+ IN PWLAN_FR_REASSOCRESP pFrame
+ )
+{
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_CAP_INFO);
+ pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_STATUS);
+ pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_AID);
+
+ pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Decode Reassociation Response
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrDecodeReassocResponse(
+ IN PWLAN_FR_REASSOCRESP pFrame
+ )
+{
+ PWLAN_IE pItem;
+
+ pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
+
+ // Fixed Fields
+ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_CAP_INFO);
+ pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_STATUS);
+ pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_AID);
+
+ //Information elements
+ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
+ + WLAN_REASSOCRESP_OFF_SUPP_RATES);
+
+ pItem = (PWLAN_IE)(pFrame->pSuppRates);
+ pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
+
+ if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
+ pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
+ }
+ return;
+}
diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h
new file mode 100644
index 000000000000..dc54a65edab5
--- /dev/null
+++ b/drivers/staging/vt6655/80211mgr.h
@@ -0,0 +1,832 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: 80211mgr.h
+ *
+ * Purpose: Defines the macros, types, and functions for dealing
+ * with 802.11 managment frames.
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2002
+ *
+ */
+
+
+#ifndef __80211MGR_H__
+#define __80211MGR_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define WLAN_MIN_ARRAY 1
+
+// Information Element ID value
+#define WLAN_EID_SSID 0
+#define WLAN_EID_SUPP_RATES 1
+#define WLAN_EID_FH_PARMS 2
+#define WLAN_EID_DS_PARMS 3
+#define WLAN_EID_CF_PARMS 4
+#define WLAN_EID_TIM 5
+#define WLAN_EID_IBSS_PARMS 6
+#define WLAN_EID_COUNTRY 7
+#define WLAN_EID_CHALLENGE 16
+#define WLAN_EID_PWR_CONSTRAINT 32
+#define WLAN_EID_PWR_CAPABILITY 33
+#define WLAN_EID_TPC_REQ 34
+#define WLAN_EID_TPC_REP 35
+#define WLAN_EID_SUPP_CH 36
+#define WLAN_EID_CH_SWITCH 37
+#define WLAN_EID_MEASURE_REQ 38
+#define WLAN_EID_MEASURE_REP 39
+#define WLAN_EID_QUIET 40
+#define WLAN_EID_IBSS_DFS 41
+#define WLAN_EID_ERP 42
+// reference 802.11i 7.3.2 table 20
+#define WLAN_EID_RSN 48
+#define WLAN_EID_EXTSUPP_RATES 50
+// reference WiFi WPA spec.
+#define WLAN_EID_RSN_WPA 221
+
+
+#define WLAN_EID_ERP_NONERP_PRESENT 0x01
+#define WLAN_EID_ERP_USE_PROTECTION 0x02
+#define WLAN_EID_ERP_BARKER_MODE 0x04
+
+// Reason Codes
+#define WLAN_MGMT_REASON_RSVD 0
+#define WLAN_MGMT_REASON_UNSPEC 1
+#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2
+#define WLAN_MGMT_REASON_DEAUTH_LEAVING 3
+#define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4
+#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5
+#define WLAN_MGMT_REASON_CLASS2_NONAUTH 6
+#define WLAN_MGMT_REASON_CLASS3_NONASSOC 7
+#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8
+#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9
+#define WLAN_MGMT_REASON_DISASSOC_PWR_CAP_UNACCEPT 10
+#define WLAN_MGMT_REASON_DISASSOC_SUPP_CH_UNACCEPT 11
+#define WLAN_MGMT_REASON_INVALID_IE 13
+#define WLAN_MGMT_REASON_MIC_FAILURE 14
+#define WLAN_MGMT_REASON_4WAY_HANDSHAKE_TIMEOUT 15
+#define WLAN_MGMT_REASON_GRPKEY_UPDATE_TIMEOUT 16
+#define WLAN_MGMT_REASON_4WAY_INFO_DIFFERENT 17
+#define WLAN_MGMT_REASON_MULTCAST_CIPHER_INVALID 18
+#define WLAN_MGMT_REASON_UNCAST_CIPHER_INVALID 19
+#define WLAN_MGMT_REASON_AKMP_INVALID 20
+#define WLAN_MGMT_REASON_RSNE_UNSUPPORTED 21
+#define WLAN_MGMT_REASON_RSNE_CAP_INVALID 22
+#define WLAN_MGMT_REASON_80211X_AUTH_FAILED 23
+
+// Status Codes
+#define WLAN_MGMT_STATUS_SUCCESS 0
+#define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1
+#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10
+#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11
+#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12
+#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13
+#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14
+#define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15
+#define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16
+#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17
+#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18
+#define WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE 19
+#define WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC 20
+#define WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY 21
+
+// reference 802.11h 7.3.1.9
+//
+#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SPECTRUM_MNG 22
+#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_PWR_CAP 23
+#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SUPP_CH 24
+//
+// reference 802.11g 7.3.1.9
+//
+#define WLAN_MGMT_STATUS_SHORTSLOTTIME_UNSUPPORTED 25
+#define WLAN_MGMT_STATUS_DSSSOFDM_UNSUPPORTED 26
+//
+// reference 802.11i 7.3.1.9 table 19
+//
+#define WLAN_MGMT_STATUS_INVALID_IE 40
+#define WLAN_MGMT_STATUS_GROUP_CIPHER_INVALID 41
+#define WLAN_MGMT_STATUS_PAIRWISE_CIPHER_INVALID 42
+#define WLAN_MGMT_STATUS_AKMP_INVALID 43
+#define WLAN_MGMT_STATUS_UNSUPPORT_RSN_IE_VER 44
+#define WLAN_MGMT_STATUS_INVALID_RSN_IE_CAP 45
+#define WLAN_MGMT_STATUS_CIPHER_REJECT 46
+
+
+
+// Auth Algorithm
+#define WLAN_AUTH_ALG_OPENSYSTEM 0
+#define WLAN_AUTH_ALG_SHAREDKEY 1
+
+
+
+// Management Frame Field Offsets
+// Note: Not all fields are listed because of variable lengths.
+// Note: These offsets are from the start of the frame data
+
+#define WLAN_BEACON_OFF_TS 0
+#define WLAN_BEACON_OFF_BCN_INT 8
+#define WLAN_BEACON_OFF_CAPINFO 10
+#define WLAN_BEACON_OFF_SSID 12
+
+#define WLAN_DISASSOC_OFF_REASON 0
+
+#define WLAN_ASSOCREQ_OFF_CAP_INFO 0
+#define WLAN_ASSOCREQ_OFF_LISTEN_INT 2
+#define WLAN_ASSOCREQ_OFF_SSID 4
+
+#define WLAN_ASSOCRESP_OFF_CAP_INFO 0
+#define WLAN_ASSOCRESP_OFF_STATUS 2
+#define WLAN_ASSOCRESP_OFF_AID 4
+#define WLAN_ASSOCRESP_OFF_SUPP_RATES 6
+
+#define WLAN_REASSOCREQ_OFF_CAP_INFO 0
+#define WLAN_REASSOCREQ_OFF_LISTEN_INT 2
+#define WLAN_REASSOCREQ_OFF_CURR_AP 4
+#define WLAN_REASSOCREQ_OFF_SSID 10
+
+#define WLAN_REASSOCRESP_OFF_CAP_INFO 0
+#define WLAN_REASSOCRESP_OFF_STATUS 2
+#define WLAN_REASSOCRESP_OFF_AID 4
+#define WLAN_REASSOCRESP_OFF_SUPP_RATES 6
+
+#define WLAN_PROBEREQ_OFF_SSID 0
+
+#define WLAN_PROBERESP_OFF_TS 0
+#define WLAN_PROBERESP_OFF_BCN_INT 8
+#define WLAN_PROBERESP_OFF_CAP_INFO 10
+#define WLAN_PROBERESP_OFF_SSID 12
+
+#define WLAN_AUTHEN_OFF_AUTH_ALG 0
+#define WLAN_AUTHEN_OFF_AUTH_SEQ 2
+#define WLAN_AUTHEN_OFF_STATUS 4
+#define WLAN_AUTHEN_OFF_CHALLENGE 6
+
+#define WLAN_DEAUTHEN_OFF_REASON 0
+
+
+//
+// Cipher Suite Selectors defiened in 802.11i
+//
+#define WLAN_11i_CSS_USE_GROUP 0
+#define WLAN_11i_CSS_WEP40 1
+#define WLAN_11i_CSS_TKIP 2
+#define WLAN_11i_CSS_CCMP 4
+#define WLAN_11i_CSS_WEP104 5
+#define WLAN_11i_CSS_UNKNOWN 255
+
+//
+// Authentication and Key Management Suite Selectors defined in 802.11i
+//
+#define WLAN_11i_AKMSS_802_1X 1
+#define WLAN_11i_AKMSS_PSK 2
+#define WLAN_11i_AKMSS_UNKNOWN 255
+
+// Measurement type definitions reference ieee 802.11h Table 20b
+#define MEASURE_TYPE_BASIC 0
+#define MEASURE_TYPE_CCA 1
+#define MEASURE_TYPE_RPI 2
+
+// Measurement request mode definitions reference ieee 802.11h Figure 46h
+#define MEASURE_MODE_ENABLE 0x02
+#define MEASURE_MODE_REQ 0x04
+#define MEASURE_MODE_REP 0x08
+
+// Measurement report mode definitions reference ieee 802.11h Figure 46m
+#define MEASURE_MODE_LATE 0x01
+#define MEASURE_MODE_INCAPABLE 0x02
+#define MEASURE_MODE_REFUSED 0x04
+
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+
+// Information Element Types
+
+#pragma pack(1)
+typedef struct tagWLAN_IE {
+ BYTE byElementID;
+ BYTE len;
+}__attribute__ ((__packed__))
+WLAN_IE, *PWLAN_IE;
+
+
+// Service Set Identity (SSID)
+#pragma pack(1)
+typedef struct tagWLAN_IE_SSID {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abySSID[1];
+}__attribute__ ((__packed__))
+WLAN_IE_SSID, *PWLAN_IE_SSID;
+
+
+// Supported Rates
+#pragma pack(1)
+typedef struct tagWLAN_IE_SUPP_RATES {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abyRates[1];
+}__attribute__ ((__packed__))
+WLAN_IE_SUPP_RATES, *PWLAN_IE_SUPP_RATES;
+
+
+
+// FH Parameter Set
+#pragma pack(1)
+typedef struct _WLAN_IE_FH_PARMS {
+ BYTE byElementID;
+ BYTE len;
+ WORD wDwellTime;
+ BYTE byHopSet;
+ BYTE byHopPattern;
+ BYTE byHopIndex;
+} WLAN_IE_FH_PARMS, *PWLAN_IE_FH_PARMS;
+
+
+// DS Parameter Set
+#pragma pack(1)
+typedef struct tagWLAN_IE_DS_PARMS {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byCurrChannel;
+}__attribute__ ((__packed__))
+WLAN_IE_DS_PARMS, *PWLAN_IE_DS_PARMS;
+
+
+// CF Parameter Set
+#pragma pack(1)
+typedef struct tagWLAN_IE_CF_PARMS {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byCFPCount;
+ BYTE byCFPPeriod;
+ WORD wCFPMaxDuration;
+ WORD wCFPDurRemaining;
+}__attribute__ ((__packed__))
+WLAN_IE_CF_PARMS, *PWLAN_IE_CF_PARMS;
+
+
+// TIM
+#pragma pack(1)
+typedef struct tagWLAN_IE_TIM {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byDTIMCount;
+ BYTE byDTIMPeriod;
+ BYTE byBitMapCtl;
+ BYTE byVirtBitMap[1];
+}__attribute__ ((__packed__))
+WLAN_IE_TIM, *PWLAN_IE_TIM;
+
+
+// IBSS Parameter Set
+#pragma pack(1)
+typedef struct tagWLAN_IE_IBSS_PARMS {
+ BYTE byElementID;
+ BYTE len;
+ WORD wATIMWindow;
+}__attribute__ ((__packed__))
+WLAN_IE_IBSS_PARMS, *PWLAN_IE_IBSS_PARMS;
+
+
+// Challenge Text
+#pragma pack(1)
+typedef struct tagWLAN_IE_CHALLENGE {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abyChallenge[1];
+}__attribute__ ((__packed__))
+WLAN_IE_CHALLENGE, *PWLAN_IE_CHALLENGE;
+
+
+#pragma pack(1)
+typedef struct tagWLAN_IE_RSN_EXT {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abyOUI[4];
+ WORD wVersion;
+ BYTE abyMulticast[4];
+ WORD wPKCount;
+ struct {
+ BYTE abyOUI[4];
+ } PKSList[1]; // the rest is variable so need to
+ // overlay ieauth structure
+} WLAN_IE_RSN_EXT, *PWLAN_IE_RSN_EXT;
+
+#pragma pack(1)
+typedef struct tagWLAN_IE_RSN_AUTH {
+ WORD wAuthCount;
+ struct {
+ BYTE abyOUI[4];
+ } AuthKSList[1];
+} WLAN_IE_RSN_AUTH, *PWLAN_IE_RSN_AUTH;
+
+// RSN Identity
+#pragma pack(1)
+typedef struct tagWLAN_IE_RSN {
+ BYTE byElementID;
+ BYTE len;
+ WORD wVersion;
+ BYTE abyRSN[WLAN_MIN_ARRAY];
+} WLAN_IE_RSN, *PWLAN_IE_RSN;
+
+
+// ERP
+#pragma pack(1)
+typedef struct tagWLAN_IE_ERP {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byContext;
+}__attribute__ ((__packed__))
+WLAN_IE_ERP, *PWLAN_IE_ERP;
+
+
+#pragma pack(1)
+typedef struct _MEASEURE_REQ {
+ BYTE byChannel;
+ BYTE abyStartTime[8];
+ BYTE abyDuration[2];
+} MEASEURE_REQ, *PMEASEURE_REQ,
+ MEASEURE_REQ_BASIC, *PMEASEURE_REQ_BASIC,
+ MEASEURE_REQ_CCA, *PMEASEURE_REQ_CCA,
+ MEASEURE_REQ_RPI, *PMEASEURE_REQ_RPI;
+
+typedef struct _MEASEURE_REP_BASIC {
+ BYTE byChannel;
+ BYTE abyStartTime[8];
+ BYTE abyDuration[2];
+ BYTE byMap;
+} MEASEURE_REP_BASIC, *PMEASEURE_REP_BASIC;
+
+typedef struct _MEASEURE_REP_CCA {
+ BYTE byChannel;
+ BYTE abyStartTime[8];
+ BYTE abyDuration[2];
+ BYTE byCCABusyFraction;
+} MEASEURE_REP_CCA, *PMEASEURE_REP_CCA;
+
+typedef struct _MEASEURE_REP_RPI {
+ BYTE byChannel;
+ BYTE abyStartTime[8];
+ BYTE abyDuration[2];
+ BYTE abyRPIdensity[8];
+} MEASEURE_REP_RPI, *PMEASEURE_REP_RPI;
+
+typedef union _MEASEURE_REP {
+
+ MEASEURE_REP_BASIC sBasic;
+ MEASEURE_REP_CCA sCCA;
+ MEASEURE_REP_RPI sRPI;
+
+} MEASEURE_REP, *PMEASEURE_REP;
+
+typedef struct _WLAN_IE_MEASURE_REQ {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byToken;
+ BYTE byMode;
+ BYTE byType;
+ MEASEURE_REQ sReq;
+} WLAN_IE_MEASURE_REQ, *PWLAN_IE_MEASURE_REQ;
+
+typedef struct _WLAN_IE_MEASURE_REP {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byToken;
+ BYTE byMode;
+ BYTE byType;
+ MEASEURE_REP sRep;
+} WLAN_IE_MEASURE_REP, *PWLAN_IE_MEASURE_REP;
+
+typedef struct _WLAN_IE_CH_SW {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byMode;
+ BYTE byChannel;
+ BYTE byCount;
+} WLAN_IE_CH_SW, *PWLAN_IE_CH_SW;
+
+typedef struct _WLAN_IE_QUIET {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byQuietCount;
+ BYTE byQuietPeriod;
+ BYTE abyQuietDuration[2];
+ BYTE abyQuietOffset[2];
+} WLAN_IE_QUIET, *PWLAN_IE_QUIET;
+
+typedef struct _WLAN_IE_COUNTRY {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abyCountryString[3];
+ BYTE abyCountryInfo[3];
+} WLAN_IE_COUNTRY, *PWLAN_IE_COUNTRY;
+
+typedef struct _WLAN_IE_PW_CONST {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byPower;
+} WLAN_IE_PW_CONST, *PWLAN_IE_PW_CONST;
+
+typedef struct _WLAN_IE_PW_CAP {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byMinPower;
+ BYTE byMaxPower;
+} WLAN_IE_PW_CAP, *PWLAN_IE_PW_CAP;
+
+typedef struct _WLAN_IE_SUPP_CH {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abyChannelTuple[2];
+} WLAN_IE_SUPP_CH, *PWLAN_IE_SUPP_CH;
+
+typedef struct _WLAN_IE_TPC_REQ {
+ BYTE byElementID;
+ BYTE len;
+} WLAN_IE_TPC_REQ, *PWLAN_IE_TPC_REQ;
+
+typedef struct _WLAN_IE_TPC_REP {
+ BYTE byElementID;
+ BYTE len;
+ BYTE byTxPower;
+ BYTE byLinkMargin;
+} WLAN_IE_TPC_REP, *PWLAN_IE_TPC_REP;
+
+
+typedef struct _WLAN_IE_IBSS_DFS {
+ BYTE byElementID;
+ BYTE len;
+ BYTE abyDFSOwner[6];
+ BYTE byDFSRecovery;
+ BYTE abyChannelMap[2];
+} WLAN_IE_IBSS_DFS, *PWLAN_IE_IBSS_DFS;
+
+#pragma pack()
+
+
+
+// Frame Types
+// prototype structure, all mgmt frame types will start with these members
+typedef struct tagWLAN_FR_MGMT {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+
+} WLAN_FR_MGMT, *PWLAN_FR_MGMT;
+
+// Beacon frame
+typedef struct tagWLAN_FR_BEACON {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ // fixed fields
+ PQWORD pqwTimestamp;
+ PWORD pwBeaconInterval;
+ PWORD pwCapInfo;
+ /*-- info elements ----------*/
+ PWLAN_IE_SSID pSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates;
+// PWLAN_IE_FH_PARMS pFHParms;
+ PWLAN_IE_DS_PARMS pDSParms;
+ PWLAN_IE_CF_PARMS pCFParms;
+ PWLAN_IE_TIM pTIM;
+ PWLAN_IE_IBSS_PARMS pIBSSParms;
+ PWLAN_IE_RSN pRSN;
+ PWLAN_IE_RSN_EXT pRSNWPA;
+ PWLAN_IE_ERP pERP;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+ PWLAN_IE_COUNTRY pIE_Country;
+ PWLAN_IE_PW_CONST pIE_PowerConstraint;
+ PWLAN_IE_CH_SW pIE_CHSW;
+ PWLAN_IE_IBSS_DFS pIE_IBSSDFS;
+ PWLAN_IE_QUIET pIE_Quiet;
+
+} WLAN_FR_BEACON, *PWLAN_FR_BEACON;
+
+
+// IBSS ATIM frame
+typedef struct tagWLAN_FR_IBSSATIM {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+
+ // fixed fields
+ // info elements
+ // this frame type has a null body
+
+} WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM;
+
+// Disassociation
+typedef struct tagWLAN_FR_DISASSOC {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PWORD pwReason;
+ /*-- info elements ----------*/
+
+} WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC;
+
+// Association Request
+typedef struct tagWLAN_FR_ASSOCREQ {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PWORD pwCapInfo;
+ PWORD pwListenInterval;
+ /*-- info elements ----------*/
+ PWLAN_IE_SSID pSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_RSN pRSN;
+ PWLAN_IE_RSN_EXT pRSNWPA;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+ PWLAN_IE_PW_CAP pCurrPowerCap;
+ PWLAN_IE_SUPP_CH pCurrSuppCh;
+
+} WLAN_FR_ASSOCREQ, *PWLAN_FR_ASSOCREQ;
+
+// Association Response
+typedef struct tagWLAN_FR_ASSOCRESP {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PWORD pwCapInfo;
+ PWORD pwStatus;
+ PWORD pwAid;
+ /*-- info elements ----------*/
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+
+} WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP;
+
+// Reassociation Request
+typedef struct tagWLAN_FR_REASSOCREQ {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+
+ /*-- fixed fields -----------*/
+ PWORD pwCapInfo;
+ PWORD pwListenInterval;
+ PIEEE_ADDR pAddrCurrAP;
+
+ /*-- info elements ----------*/
+ PWLAN_IE_SSID pSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_RSN pRSN;
+ PWLAN_IE_RSN_EXT pRSNWPA;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+
+} WLAN_FR_REASSOCREQ, *PWLAN_FR_REASSOCREQ;
+
+// Reassociation Response
+typedef struct tagWLAN_FR_REASSOCRESP {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PWORD pwCapInfo;
+ PWORD pwStatus;
+ PWORD pwAid;
+ /*-- info elements ----------*/
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+
+} WLAN_FR_REASSOCRESP, *PWLAN_FR_REASSOCRESP;
+
+// Probe Request
+typedef struct tagWLAN_FR_PROBEREQ {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ /*-- info elements ----------*/
+ PWLAN_IE_SSID pSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+
+} WLAN_FR_PROBEREQ, *PWLAN_FR_PROBEREQ;
+
+// Probe Response
+typedef struct tagWLAN_FR_PROBERESP {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PQWORD pqwTimestamp;
+ PWORD pwBeaconInterval;
+ PWORD pwCapInfo;
+ /*-- info elements ----------*/
+ PWLAN_IE_SSID pSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_DS_PARMS pDSParms;
+ PWLAN_IE_CF_PARMS pCFParms;
+ PWLAN_IE_IBSS_PARMS pIBSSParms;
+ PWLAN_IE_RSN pRSN;
+ PWLAN_IE_RSN_EXT pRSNWPA;
+ PWLAN_IE_ERP pERP;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
+ PWLAN_IE_COUNTRY pIE_Country;
+ PWLAN_IE_PW_CONST pIE_PowerConstraint;
+ PWLAN_IE_CH_SW pIE_CHSW;
+ PWLAN_IE_IBSS_DFS pIE_IBSSDFS;
+ PWLAN_IE_QUIET pIE_Quiet;
+
+} WLAN_FR_PROBERESP, *PWLAN_FR_PROBERESP;
+
+// Authentication
+typedef struct tagWLAN_FR_AUTHEN {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PWORD pwAuthAlgorithm;
+ PWORD pwAuthSequence;
+ PWORD pwStatus;
+ /*-- info elements ----------*/
+ PWLAN_IE_CHALLENGE pChallenge;
+
+} WLAN_FR_AUTHEN, *PWLAN_FR_AUTHEN;
+
+// Deauthenication
+typedef struct tagWLAN_FR_DEAUTHEN {
+
+ UINT uType;
+ UINT len;
+ PBYTE pBuf;
+ PUWLAN_80211HDR pHdr;
+ /*-- fixed fields -----------*/
+ PWORD pwReason;
+
+ /*-- info elements ----------*/
+
+} WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN;
+
+/*--------------------- Export Functions --------------------------*/
+VOID
+vMgrEncodeBeacon(
+ IN PWLAN_FR_BEACON pFrame
+ );
+
+VOID
+vMgrDecodeBeacon(
+ IN PWLAN_FR_BEACON pFrame
+ );
+
+VOID
+vMgrEncodeIBSSATIM(
+ IN PWLAN_FR_IBSSATIM pFrame
+ );
+
+VOID
+vMgrDecodeIBSSATIM(
+ IN PWLAN_FR_IBSSATIM pFrame
+ );
+
+VOID
+vMgrEncodeDisassociation(
+ IN PWLAN_FR_DISASSOC pFrame
+ );
+
+VOID
+vMgrDecodeDisassociation(
+ IN PWLAN_FR_DISASSOC pFrame
+ );
+
+VOID
+vMgrEncodeAssocRequest(
+ IN PWLAN_FR_ASSOCREQ pFrame
+ );
+
+VOID
+vMgrDecodeAssocRequest(
+ IN PWLAN_FR_ASSOCREQ pFrame
+ );
+
+VOID
+vMgrEncodeAssocResponse(
+ IN PWLAN_FR_ASSOCRESP pFrame
+ );
+
+VOID
+vMgrDecodeAssocResponse(
+ IN PWLAN_FR_ASSOCRESP pFrame
+ );
+
+VOID
+vMgrEncodeReassocRequest(
+ IN PWLAN_FR_REASSOCREQ pFrame
+ );
+
+VOID
+vMgrDecodeReassocRequest(
+ IN PWLAN_FR_REASSOCREQ pFrame
+ );
+
+VOID
+vMgrEncodeProbeRequest(
+ IN PWLAN_FR_PROBEREQ pFrame
+ );
+
+VOID
+vMgrDecodeProbeRequest(
+ IN PWLAN_FR_PROBEREQ pFrame
+ );
+
+VOID
+vMgrEncodeProbeResponse(
+ IN PWLAN_FR_PROBERESP pFrame
+ );
+
+VOID
+vMgrDecodeProbeResponse(
+ IN PWLAN_FR_PROBERESP pFrame
+ );
+
+VOID
+vMgrEncodeAuthen(
+ IN PWLAN_FR_AUTHEN pFrame
+ );
+
+VOID
+vMgrDecodeAuthen(
+ IN PWLAN_FR_AUTHEN pFrame
+ );
+
+VOID
+vMgrEncodeDeauthen(
+ IN PWLAN_FR_DEAUTHEN pFrame
+ );
+
+VOID
+vMgrDecodeDeauthen(
+ IN PWLAN_FR_DEAUTHEN pFrame
+ );
+
+VOID
+vMgrEncodeReassocResponse(
+ IN PWLAN_FR_REASSOCRESP pFrame
+ );
+
+VOID
+vMgrDecodeReassocResponse(
+ IN PWLAN_FR_REASSOCRESP pFrame
+ );
+
+#endif// __80211MGR_H__
diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c
new file mode 100644
index 000000000000..5f25b8e88bd9
--- /dev/null
+++ b/drivers/staging/vt6655/IEEE11h.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: IEEE11h.c
+ *
+ * Purpose:
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ * Author: Yiching Chen
+ *
+ * Date: Mar. 31, 2005
+ *
+ */
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__IEEE11h_H__)
+#include "IEEE11h.h"
+#endif
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+
+#pragma pack(1)
+
+typedef struct _WLAN_FRAME_ACTION {
+ WLAN_80211HDR_A3 Header;
+ BYTE byCategory;
+ BYTE byAction;
+ BYTE abyVars[1];
+} WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION;
+
+typedef struct _WLAN_FRAME_MSRREQ {
+ WLAN_80211HDR_A3 Header;
+ BYTE byCategory;
+ BYTE byAction;
+ BYTE byDialogToken;
+ WLAN_IE_MEASURE_REQ sMSRReqEIDs[1];
+} WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ;
+
+typedef struct _WLAN_FRAME_MSRREP {
+ WLAN_80211HDR_A3 Header;
+ BYTE byCategory;
+ BYTE byAction;
+ BYTE byDialogToken;
+ WLAN_IE_MEASURE_REP sMSRRepEIDs[1];
+} WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP;
+
+typedef struct _WLAN_FRAME_TPCREQ {
+ WLAN_80211HDR_A3 Header;
+ BYTE byCategory;
+ BYTE byAction;
+ BYTE byDialogToken;
+ WLAN_IE_TPC_REQ sTPCReqEIDs;
+} WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ;
+
+typedef struct _WLAN_FRAME_TPCREP {
+ WLAN_80211HDR_A3 Header;
+ BYTE byCategory;
+ BYTE byAction;
+ BYTE byDialogToken;
+ WLAN_IE_TPC_REP sTPCRepEIDs;
+} WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP;
+
+#pragma pack()
+
+// action field reference ieee 802.11h Table 20e
+#define ACTION_MSRREQ 0
+#define ACTION_MSRREP 1
+#define ACTION_TPCREQ 2
+#define ACTION_TPCREP 3
+#define ACTION_CHSW 4
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+static BOOL s_bRxMSRReq(PSMgmtObject pMgmt, PWLAN_FRAME_MSRREQ pMSRReq, UINT uLength)
+{
+ UINT uNumOfEIDs = 0;
+ BOOL bResult = TRUE;
+
+ if (uLength <= WLAN_A3FR_MAXLEN) {
+ MEMvCopy(pMgmt->abyCurrentMSRReq, pMSRReq, uLength);
+ }
+ uNumOfEIDs = ((uLength - OFFSET(WLAN_FRAME_MSRREQ, sMSRReqEIDs))/ (sizeof(WLAN_IE_MEASURE_REQ)));
+ pMgmt->pCurrMeasureEIDRep = &(((PWLAN_FRAME_MSRREP) (pMgmt->abyCurrentMSRRep))->sMSRRepEIDs[0]);
+ pMgmt->uLengthOfRepEIDs = 0;
+ bResult = CARDbStartMeasure(pMgmt->pAdapter,
+ ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->sMSRReqEIDs,
+ uNumOfEIDs
+ );
+ return (bResult);
+}
+
+
+static BOOL s_bRxTPCReq(PSMgmtObject pMgmt, PWLAN_FRAME_TPCREQ pTPCReq, BYTE byRate, BYTE byRSSI)
+{
+ PWLAN_FRAME_TPCREP pFrame;
+ PSTxMgmtPacket pTxPacket = NULL;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+
+ pFrame = (PWLAN_FRAME_TPCREP)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+
+ pFrame->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
+ );
+
+ MEMvCopy( pFrame->Header.abyAddr1, pTPCReq->Header.abyAddr2, WLAN_ADDR_LEN);
+ MEMvCopy( pFrame->Header.abyAddr2, CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
+ MEMvCopy( pFrame->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ pFrame->byCategory = 0;
+ pFrame->byAction = 3;
+ pFrame->byDialogToken = ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->byDialogToken;
+
+ pFrame->sTPCRepEIDs.byElementID = WLAN_EID_TPC_REP;
+ pFrame->sTPCRepEIDs.len = 2;
+ pFrame->sTPCRepEIDs.byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
+ switch (byRate) {
+ case RATE_54M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 65 - byRSSI;
+ break;
+ case RATE_48M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 66 - byRSSI;
+ break;
+ case RATE_36M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 70 - byRSSI;
+ break;
+ case RATE_24M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 74 - byRSSI;
+ break;
+ case RATE_18M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 77 - byRSSI;
+ break;
+ case RATE_12M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 79 - byRSSI;
+ break;
+ case RATE_9M:
+ pFrame->sTPCRepEIDs.byLinkMargin = 81 - byRSSI;
+ break;
+ case RATE_6M:
+ default:
+ pFrame->sTPCRepEIDs.byLinkMargin = 82 - byRSSI;
+ break;
+ }
+
+ pTxPacket->cbMPDULen = sizeof(WLAN_FRAME_TPCREP);
+ pTxPacket->cbPayloadLen = sizeof(WLAN_FRAME_TPCREP) - WLAN_HDR_ADDR3_LEN;
+ if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
+ return (FALSE);
+ return (TRUE);
+// return (CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, sizeof(WLAN_FRAME_TPCREP)));
+
+}
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*+
+ *
+ * Description:
+ * Handles action management frames.
+ *
+ * Parameters:
+ * In:
+ * pMgmt - Management Object structure
+ * pRxPacket - Received packet
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+-*/
+BOOL
+IEEE11hbMgrRxAction (
+ IN PVOID pMgmtHandle,
+ IN PVOID pRxPacket
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
+ PWLAN_FRAME_ACTION pAction = NULL;
+ UINT uLength = 0;
+ PWLAN_IE_CH_SW pChannelSwitch = NULL;
+
+
+ // decode the frame
+ uLength = ((PSRxMgmtPacket)pRxPacket)->cbMPDULen;
+ if (uLength > WLAN_A3FR_MAXLEN) {
+ return (FALSE);
+ }
+
+
+ pAction = (PWLAN_FRAME_ACTION) (((PSRxMgmtPacket)pRxPacket)->p80211Header);
+
+ if (pAction->byCategory == 0) {
+ switch (pAction->byAction) {
+ case ACTION_MSRREQ:
+ return (s_bRxMSRReq(pMgmt, (PWLAN_FRAME_MSRREQ) pAction, uLength));
+ break;
+ case ACTION_MSRREP:
+ break;
+ case ACTION_TPCREQ:
+ return (s_bRxTPCReq(pMgmt,
+ (PWLAN_FRAME_TPCREQ) pAction,
+ ((PSRxMgmtPacket)pRxPacket)->byRxRate,
+ (BYTE) ((PSRxMgmtPacket)pRxPacket)->uRSSI));
+ break;
+ case ACTION_TPCREP:
+ break;
+ case ACTION_CHSW:
+ pChannelSwitch = (PWLAN_IE_CH_SW) (pAction->abyVars);
+ if ((pChannelSwitch->byElementID == WLAN_EID_CH_SWITCH) &&
+ (pChannelSwitch->len == 3)) {
+ // valid element id
+ CARDbChannelSwitch( pMgmt->pAdapter,
+ pChannelSwitch->byMode,
+ CARDbyGetChannelMapping(pMgmt->pAdapter, pChannelSwitch->byChannel, pMgmt->eCurrentPHYMode),
+ pChannelSwitch->byCount
+ );
+ }
+ break;
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Action = %d\n", pAction->byAction);
+ break;
+ }
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown Category = %d\n", pAction->byCategory);
+ pAction->byCategory |= 0x80;
+
+ //return (CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, uLength));
+ return (TRUE);
+ }
+ return (TRUE);
+}
+
+
+BOOL IEEE11hbMSRRepTx (
+ IN PVOID pMgmtHandle
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
+ PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP) (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket));
+ UINT uLength = 0;
+ PSTxMgmtPacket pTxPacket = NULL;
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+
+
+ pMSRRep->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
+ );
+
+ MEMvCopy( pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN);
+ MEMvCopy( pMSRRep->Header.abyAddr2, CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
+ MEMvCopy( pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ pMSRRep->byCategory = 0;
+ pMSRRep->byAction = 1;
+ pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ) (pMgmt->abyCurrentMSRReq))->byDialogToken;
+
+ uLength = pMgmt->uLengthOfRepEIDs + OFFSET(WLAN_FRAME_MSRREP, sMSRRepEIDs);
+
+ pTxPacket->cbMPDULen = uLength;
+ pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN;
+ if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
+ return (FALSE);
+ return (TRUE);
+// return (CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, uLength));
+
+}
+
diff --git a/drivers/staging/vt6655/IEEE11h.h b/drivers/staging/vt6655/IEEE11h.h
new file mode 100644
index 000000000000..22bcaf1f6817
--- /dev/null
+++ b/drivers/staging/vt6655/IEEE11h.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: IEEE11h.h
+ *
+ * Purpose: Defines the macros, types, and functions for dealing
+ * with IEEE 802.11h.
+ *
+ * Author: Yiching Chen
+ *
+ * Date: Mar. 31, 2005
+ *
+ */
+
+#ifndef __IEEE11h_H__
+#define __IEEE11h_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+BOOL IEEE11hbMSRRepTx (
+ IN PVOID pMgmtHandle
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __IEEE11h_H__
diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile
new file mode 100644
index 000000000000..be44423c117b
--- /dev/null
+++ b/drivers/staging/vt6655/Makefile
@@ -0,0 +1,218 @@
+#
+# Build options:
+# PRIV_OBJ := 1 for object version
+#
+
+IO_MAP := 0
+HOSTAP := 1
+PRIV_OBJ := 0
+
+
+
+#KSP : = 0
+KSP := /lib/modules/$(shell uname -r)/build \
+# /usr/src/linux-$(shell uname -r) \
+# /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
+# /usr/src/kernel-headers-$(shell uname -r) \
+# /usr/src/kernel-source-$(shell uname -r) \
+# /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
+# /usr/src/linux /home/plice
+
+#test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
+
+#KSP := $(foreach dir, $(KSP), $(test_dir))
+
+
+KSRC := $(firstword $(KSP))
+
+#ifeq (,$(KSRC))
+# $( error Linux kernel source not found)
+#endif
+
+# check kernel version
+KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
+KERVER2=$(shell uname -r | cut -d. -f2)
+
+ifeq ($(KVER), 2.6)
+# 2.6 kernel
+TARGET = viawget.ko
+
+else
+TARGET = viawget.o
+
+endif
+
+INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
+ifeq (,$(INSTDIR))
+ ifeq (,$(KERVER2))
+ ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
+ INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
+ else
+ INSTDIR := /lib/modules/$(shell uname -r)/net
+ endif
+ else
+ ifneq ($(KERVER2),2)
+ INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
+ else
+ INSTDIR := /lib/modules/$(shell uname -r)/net
+ endif
+ endif
+endif
+
+
+SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
+ wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \
+ srom.c mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \
+ tkip.c michael.c wroute.c rf.c iwctl.c wpactl.c aes_ccmp.c \
+ vntwifi.c IEEE11h.c
+
+ifeq ($(IO_MAP), 1)
+ EXTRA_CFLAGS += -DIO_MAP
+endif
+
+ifeq ($(HOSTAP), 1)
+ EXTRA_CFLAGS += -DHOSTAP
+endif
+
+ifeq ($(PRIV_OBJ), 1)
+ EXTRA_CFLAGS += -DPRIVATE_OBJ
+endif
+
+EXTRA_CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
+
+EXTRA_CFLAGS += -I$(PWD)/include -I$(PWD)/solomon
+
+# build rule
+ifeq ($(KVER), 2.6)
+# 2.6 kernel
+
+ifndef KERNEL_CONF
+KERNEL_CONF= $(KSRC)/.config
+endif
+
+include ${KERNEL_CONF}
+
+obj-m += viawget.o
+
+viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
+ wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
+ mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
+ michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \
+ vntwifi.o IEEE11h.o
+
+.c.o:
+ $(CC) $(CFLAGS) -o $@ $<
+
+default:
+ make -C $(KSRC) SUBDIRS=$(shell pwd) modules
+
+else
+
+# 2.2/2.4 kernel
+OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
+ wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
+ mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
+ michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \
+ vntwifi.o IEEE11h.o
+
+VERSION_FILE := $(KSRC)/include/linux/version.h
+CONFIG_FILE := $(KSRC)/include/linux/config.h
+
+
+ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+endif
+
+ifeq (,$(wildcard $(CONFIG_FILE)))
+ $(error Linux kernel source not configured - missing config.h)
+endif
+
+ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
+ CC := kgcc gcc cc
+else
+ CC := gcc cc
+endif
+
+test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
+CC := $(foreach cc, $(CC), $(test_cc))
+CC := $(firstword $(CC))
+
+EXTRA_CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
+EXTRA_CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer -fno-strict-aliasing
+EXTRA_CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
+ echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h")
+
+.SILENT: $(TARGET) clean
+
+
+# look for SMP in config.h
+SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
+ grep CONFIG_SMP | awk '{ print $$3 }')
+
+ifneq ($(SMP),1)
+ SMP := 0
+endif
+
+
+ifeq ($(SMP), 1)
+ EXTRA_CFLAGS += -D__SMP__
+endif
+
+
+ifeq ($(PRIV_OBJ), 1)
+ EXTRA_CFLAGS += -DPRIVATE_OBJ
+ TARGET = x86g_up.o
+
+ifeq ($(SMP), 1)
+ TARGET = x86g_smp.o
+endif
+
+endif
+
+
+# check x86_64
+SUBARCH := $(shell uname -m)
+ifeq ($(SUBARCH),x86_64)
+ EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone
+endif
+
+
+$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
+ $(LD) -r $^ -o $@
+ echo; echo
+ echo "**************************************************"
+ echo "Build options:"
+ echo " VERSION $(KVER)"
+ echo -n " SMP "
+ if [ "$(SMP)" = "1" ]; \
+ then echo "Enabled"; else echo "Disabled"; fi
+
+
+
+endif # ifeq ($(KVER),2.6)
+
+
+ifeq ($(KVER), 2.6)
+install: default
+else
+install: clean $(TARGET)
+endif
+ mkdir -p $(MOD_ROOT)$(INSTDIR)
+ install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
+
+ifeq (,$(MOD_ROOT))
+ /sbin/depmod -a || true
+else
+ /sbin/depmod -b $(MOD_ROOT) -a || true
+endif
+
+
+uninstall:
+ rm -f $(INSTDIR)/$(TARGET)
+ /sbin/depmod -a
+
+clean:
+ rm -f $(TARGET) $(SRC:.c=.o) *.o *~
+ rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o
+
+-include .depend.mak
diff --git a/drivers/staging/vt6655/Makefile.arm b/drivers/staging/vt6655/Makefile.arm
new file mode 100644
index 000000000000..2d2ccaded6ac
--- /dev/null
+++ b/drivers/staging/vt6655/Makefile.arm
@@ -0,0 +1,181 @@
+#
+#
+# Build options:
+# PRIV_OBJ := 1 for object version
+# BIG_ENDIAN := 1 for big-endian mode
+#
+# arm-linux-tools chain are located at:
+# /usr/local/bin/arm-linux-gcc
+# /usr/local/bin/arm-linux-ld
+#
+
+IO_MAP := 0
+HOSTAP := 1
+PRIV_OBJ := 1
+BIG_ENDIAN := 1
+
+test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
+KSP := $(foreach dir, $(KSP), $(test_dir))
+
+KSRC := $(firstword $(KSP))
+
+#ifeq (,$(KSRC))
+# $(error Linux kernel source not found)
+#endif
+
+# check kernel version
+KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
+KERVER2=$(shell uname -r | cut -d. -f2)
+
+ifeq ($(KVER), 2.6)
+# 2.6 kernel
+TARGET = viawget.ko
+
+else
+TARGET = viawget.o
+
+endif
+
+INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
+ifeq (,$(INSTDIR))
+ ifeq (,$(KERVER2))
+ ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
+ INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
+ else
+ INSTDIR := /lib/modules/$(shell uname -r)/net
+ endif
+ else
+ ifneq ($(KERVER2),2)
+ INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
+ else
+ INSTDIR := /lib/modules/$(shell uname -r)/net
+ endif
+ endif
+endif
+
+
+SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
+ wcmd.c wmgr.c bssdb.c rxtx.c dpc.c power.c datarate.c srom.c \
+ mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c tkip.c \
+ michael.c wroute.c rf.c iwctl.c wpactl.c wpa2.c aes_ccmp.c
+
+ifeq ($(IO_MAP), 1)
+ CFLAGS += -DIO_MAP
+endif
+
+ifeq ($(HOSTAP), 1)
+ CFLAGS += -DHOSTAP
+endif
+
+ifeq ($(PRIV_OBJ), 1)
+ CFLAGS += -DPRIVATE_OBJ
+endif
+
+ifeq ($(BIG_ENDIAN), 1)
+ CFLAGS += -D__BIG_ENDIAN
+ CFLAGS += -mbig-endian
+ LDOPTS += -EB
+else
+ CFLAGS += -mlittle-endian
+ LDOPTS += -EL
+endif
+
+CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
+
+
+# build rule
+ifeq ($(KVER), 2.6)
+# 2.6 kernel
+
+ifndef KERNEL_CONF
+KERNEL_CONF= $(KSRC)/.config
+endif
+
+include ${KERNEL_CONF}
+
+obj-m += viawget.o
+
+viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
+ wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
+ mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
+ michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
+
+.c.o:
+ $(CC) $(CFLAGS) -o $@ $<
+
+default:
+ make -C $(KSRC) SUBDIRS=$(shell pwd) modules
+
+else
+
+# 2.2/2.4 kernel
+OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
+ wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
+ mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
+ michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o
+
+
+CC := /usr/local/bin/arm-linux-gcc
+LD := /usr/local/bin/arm-linux-ld
+
+CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
+#CFLAGS += -Wstrict-prototypes -fomit-frame-pointer
+COPTS+= -march=armv4 -fno-strict-aliasing -fno-common
+#COPTS+= -mapcs-32 -mtune=xscale -mshort-load-bytes -msoft-float -mfp=2
+#COPTS+= -mthumb -mcpu=arm9 -ffunction-sections -fdata-sections
+
+
+.SILENT: $(TARGET) clean
+
+
+
+ifeq ($(PRIV_OBJ), 1)
+
+ifeq ($(BIG_ENDIAN), 1)
+ TARGET = arm_be_g.o
+else
+ TARGET = arm_le_g.o
+endif
+
+endif
+
+
+
+$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
+ $(LD) $(LDOPTS) -r $^ -o $@
+ echo
+ echo "***********************************"
+ echo "Build options:"
+ echo " VERSION $(KVER)"
+ echo -n " SMP "
+ if [ "$(SMP)" = "1" ]; \
+ then echo "Enabled"; else echo "Disabled"; fi
+
+
+endif # ifeq ($(KVER),2.6)
+
+
+ifeq ($(KVER), 2.6)
+install: default
+else
+install: clean $(TARGET)
+endif
+ mkdir -p $(MOD_ROOT)$(INSTDIR)
+ install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
+
+ifeq (,$(MOD_ROOT))
+ /sbin/depmod -a || true
+else
+ /sbin/depmod -b $(MOD_ROOT) -a || true
+endif
+
+
+uninstall:
+ rm -f $(INSTDIR)/$(TARGET)
+ /sbin/depmod -a
+
+clean:
+ rm -f $(TARGET) $(SRC:.c=.o) *~
+ rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o
+
+-include .depend.mak
diff --git a/drivers/staging/vt6655/Makefile.x86 b/drivers/staging/vt6655/Makefile.x86
new file mode 100644
index 000000000000..69082f09ba73
--- /dev/null
+++ b/drivers/staging/vt6655/Makefile.x86
@@ -0,0 +1,209 @@
+#
+# Build options:
+# PRIV_OBJ := 1 for object version
+#
+
+IO_MAP := 0
+HOSTAP := 1
+PRIV_OBJ := 1
+
+KSP := /lib/modules/$(shell uname -r)/build \
+ /usr/src/linux-$(shell uname -r) \
+ /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
+ /usr/src/kernel-headers-$(shell uname -r) \
+ /usr/src/kernel-source-$(shell uname -r) \
+ /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
+ /usr/src/linux
+
+test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
+KSP := $(foreach dir, $(KSP), $(test_dir))
+
+KSRC := $(firstword $(KSP))
+
+ifeq (,$(KSRC))
+ $(error Linux kernel source not found)
+endif
+
+# check kernel version
+KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
+KERVER2=$(shell uname -r | cut -d. -f2)
+
+ifeq ($(KVER), 2.6)
+# 2.6 kernel
+TARGET = viawget.ko
+
+else
+TARGET = viawget.o
+
+endif
+
+INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
+ifeq (,$(INSTDIR))
+ ifeq (,$(KERVER2))
+ ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
+ INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
+ else
+ INSTDIR := /lib/modules/$(shell uname -r)/net
+ endif
+ else
+ ifneq ($(KERVER2),2)
+ INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
+ else
+ INSTDIR := /lib/modules/$(shell uname -r)/net
+ endif
+ endif
+endif
+
+
+SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
+ wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \
+ srom.c mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \
+ tkip.c michael.c wroute.c rf.c iwctl.c wpactl.c aes_ccmp.c
+
+ifeq ($(IO_MAP), 1)
+ CFLAGS += -DIO_MAP
+endif
+
+ifeq ($(HOSTAP), 1)
+ CFLAGS += -DHOSTAP
+endif
+
+ifeq ($(PRIV_OBJ), 1)
+ CFLAGS += -DPRIVATE_OBJ
+endif
+
+CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
+
+
+# build rule
+ifeq ($(KVER), 2.6)
+# 2.6 kernel
+
+ifndef KERNEL_CONF
+KERNEL_CONF= $(KSRC)/.config
+endif
+
+include ${KERNEL_CONF}
+
+obj-m += viawget.o
+
+viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
+ wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
+ mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
+ michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
+
+.c.o:
+ $(CC) $(CFLAGS) -o $@ $<
+
+default:
+ make -C $(KSRC) SUBDIRS=$(shell pwd) modules
+
+else
+
+# 2.2/2.4 kernel
+OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
+ wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
+ mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
+ michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
+
+VERSION_FILE := $(KSRC)/include/linux/version.h
+CONFIG_FILE := $(KSRC)/include/linux/config.h
+
+
+ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+endif
+
+ifeq (,$(wildcard $(CONFIG_FILE)))
+ $(error Linux kernel source not configured - missing config.h)
+endif
+
+ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
+ CC := kgcc gcc cc
+else
+ CC := gcc cc
+endif
+
+test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
+CC := $(foreach cc, $(CC), $(test_cc))
+CC := $(firstword $(CC))
+
+CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
+CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer
+CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
+ echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h")
+
+.SILENT: $(TARGET) clean
+
+
+# look for SMP in config.h
+SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
+ grep CONFIG_SMP | awk '{ print $$3 }')
+
+ifneq ($(SMP),1)
+ SMP := 0
+endif
+
+
+ifeq ($(SMP), 1)
+ CFLAGS += -D__SMP__
+endif
+
+
+ifeq ($(PRIV_OBJ), 1)
+ CFLAGS += -DPRIVATE_OBJ
+ TARGET = x86g_up.o
+
+ifeq ($(SMP), 1)
+ TARGET = x86g_smp.o
+endif
+
+endif
+
+
+# check x86_64
+SUBARCH := $(shell uname -m)
+ifeq ($(SUBARCH),x86_64)
+ CFLAGS += -mcmodel=kernel -mno-red-zone
+endif
+
+
+$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
+ $(LD) -r $^ -o $@
+ echo; echo
+ echo "**************************************************"
+ echo "Build options:"
+ echo " VERSION $(KVER)"
+ echo -n " SMP "
+ if [ "$(SMP)" = "1" ]; \
+ then echo "Enabled"; else echo "Disabled"; fi
+
+
+
+endif # ifeq ($(KVER),2.6)
+
+
+ifeq ($(KVER), 2.6)
+install: default
+else
+install: clean $(TARGET)
+endif
+ mkdir -p $(MOD_ROOT)$(INSTDIR)
+ install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
+
+ifeq (,$(MOD_ROOT))
+ /sbin/depmod -a || true
+else
+ /sbin/depmod -b $(MOD_ROOT) -a || true
+endif
+
+
+uninstall:
+ rm -f $(INSTDIR)/$(TARGET)
+ /sbin/depmod -a
+
+clean:
+ rm -f $(TARGET) $(SRC:.c=.o) *~
+ rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o
+
+-include .depend.mak
diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c
new file mode 100644
index 000000000000..59cc018d48a2
--- /dev/null
+++ b/drivers/staging/vt6655/aes_ccmp.c
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: aes_ccmp.c
+ *
+ * Purpose: AES_CCMP decryption
+ *
+ * Author: Warren Hsu
+ *
+ * Date: Feb 15, 2005
+ *
+ * Functions:
+ * AESbGenCCMP - Parsing RX-packet
+ *
+ *
+ * Revision History:
+ *
+ */
+
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*
+ * SBOX Table
+ */
+
+BYTE sbox_table[256] =
+{
+0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
+};
+
+BYTE dot2_table[256] = {
+0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
+0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
+0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
+0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
+0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
+0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
+0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
+0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe,
+0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05,
+0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25,
+0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45,
+0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65,
+0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85,
+0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5,
+0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5,
+0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5
+};
+
+BYTE dot3_table[256] = {
+0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11,
+0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21,
+0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71,
+0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41,
+0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1,
+0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1,
+0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1,
+0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81,
+0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a,
+0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba,
+0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea,
+0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda,
+0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a,
+0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a,
+0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a,
+0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a
+};
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+void xor_128(BYTE *a, BYTE *b, BYTE *out)
+{
+PDWORD dwPtrA = (PDWORD) a;
+PDWORD dwPtrB = (PDWORD) b;
+PDWORD dwPtrOut =(PDWORD) out;
+
+ (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
+ (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
+ (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
+ (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
+}
+
+
+void xor_32(BYTE *a, BYTE *b, BYTE *out)
+{
+PDWORD dwPtrA = (PDWORD) a;
+PDWORD dwPtrB = (PDWORD) b;
+PDWORD dwPtrOut =(PDWORD) out;
+
+ (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++);
+}
+
+void AddRoundKey(BYTE *key, int round)
+{
+BYTE sbox_key[4];
+BYTE rcon_table[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36};
+
+ sbox_key[0] = sbox_table[key[13]];
+ sbox_key[1] = sbox_table[key[14]];
+ sbox_key[2] = sbox_table[key[15]];
+ sbox_key[3] = sbox_table[key[12]];
+
+ key[0] = key[0] ^ rcon_table[round];
+ xor_32(&key[0], sbox_key, &key[0]);
+
+ xor_32(&key[4], &key[0], &key[4]);
+ xor_32(&key[8], &key[4], &key[8]);
+ xor_32(&key[12], &key[8], &key[12]);
+}
+
+void SubBytes(BYTE *in, BYTE *out)
+{
+int i;
+
+ for (i=0; i< 16; i++)
+ {
+ out[i] = sbox_table[in[i]];
+ }
+}
+
+void ShiftRows(BYTE *in, BYTE *out)
+{
+ out[0] = in[0];
+ out[1] = in[5];
+ out[2] = in[10];
+ out[3] = in[15];
+ out[4] = in[4];
+ out[5] = in[9];
+ out[6] = in[14];
+ out[7] = in[3];
+ out[8] = in[8];
+ out[9] = in[13];
+ out[10] = in[2];
+ out[11] = in[7];
+ out[12] = in[12];
+ out[13] = in[1];
+ out[14] = in[6];
+ out[15] = in[11];
+}
+
+void MixColumns(BYTE *in, BYTE *out)
+{
+
+ out[0] = dot2_table[in[0]] ^ dot3_table[in[1]] ^ in[2] ^ in[3];
+ out[1] = in[0] ^ dot2_table[in[1]] ^ dot3_table[in[2]] ^ in[3];
+ out[2] = in[0] ^ in[1] ^ dot2_table[in[2]] ^ dot3_table[in[3]];
+ out[3] = dot3_table[in[0]] ^ in[1] ^ in[2] ^ dot2_table[in[3]];
+}
+
+
+void AESv128(BYTE *key, BYTE *data, BYTE *ciphertext)
+{
+int i;
+int round;
+BYTE TmpdataA[16];
+BYTE TmpdataB[16];
+BYTE abyRoundKey[16];
+
+ for(i=0; i<16; i++)
+ abyRoundKey[i] = key[i];
+
+ for (round = 0; round < 11; round++)
+ {
+ if (round == 0)
+ {
+ xor_128(abyRoundKey, data, ciphertext);
+ AddRoundKey(abyRoundKey, round);
+ }
+ else if (round == 10)
+ {
+ SubBytes(ciphertext, TmpdataA);
+ ShiftRows(TmpdataA, TmpdataB);
+ xor_128(TmpdataB, abyRoundKey, ciphertext);
+ }
+ else // round 1 ~ 9
+ {
+ SubBytes(ciphertext, TmpdataA);
+ ShiftRows(TmpdataA, TmpdataB);
+ MixColumns(&TmpdataB[0], &TmpdataA[0]);
+ MixColumns(&TmpdataB[4], &TmpdataA[4]);
+ MixColumns(&TmpdataB[8], &TmpdataA[8]);
+ MixColumns(&TmpdataB[12], &TmpdataA[12]);
+ xor_128(TmpdataA, abyRoundKey, ciphertext);
+ AddRoundKey(abyRoundKey, round);
+ }
+ }
+
+}
+
+/*
+ * Description: AES decryption
+ *
+ * Parameters:
+ * In:
+ * pbyRxKey - The key used to decrypt
+ * pbyFrame - Starting address of packet header
+ * wFrameSize - Total packet size including CRC
+ * Out:
+ * none
+ *
+ * Return Value: MIC compare result
+ *
+ */
+BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize)
+{
+BYTE abyNonce[13];
+BYTE MIC_IV[16];
+BYTE MIC_HDR1[16];
+BYTE MIC_HDR2[16];
+BYTE abyMIC[16];
+BYTE abyCTRPLD[16];
+BYTE abyTmp[16];
+BYTE abyPlainText[16];
+BYTE abyLastCipher[16];
+
+PS802_11Header pMACHeader = (PS802_11Header) pbyFrame;
+PBYTE pbyIV;
+PBYTE pbyPayload;
+WORD wHLen = 22;
+WORD wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN;//8 is IV, 8 is MIC, 4 is CRC
+BOOL bA4 = FALSE;
+BYTE byTmp;
+WORD wCnt;
+int ii,jj,kk;
+
+
+ pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
+ if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
+ WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) {
+ bA4 = TRUE;
+ pbyIV += 6; // 6 is 802.11 address4
+ wHLen += 6;
+ wPayloadSize -= 6;
+ }
+ pbyPayload = pbyIV + 8; //IV-length
+
+ abyNonce[0] = 0x00; //now is 0, if Qos here will be priority
+ MEMvCopy(&(abyNonce[1]), pMACHeader->abyAddr2, U_ETHER_ADDR_LEN);
+ abyNonce[7] = pbyIV[7];
+ abyNonce[8] = pbyIV[6];
+ abyNonce[9] = pbyIV[5];
+ abyNonce[10] = pbyIV[4];
+ abyNonce[11] = pbyIV[1];
+ abyNonce[12] = pbyIV[0];
+
+ //MIC_IV
+ MIC_IV[0] = 0x59;
+ MEMvCopy(&(MIC_IV[1]), &(abyNonce[0]), 13);
+ MIC_IV[14] = (BYTE)(wPayloadSize >> 8);
+ MIC_IV[15] = (BYTE)(wPayloadSize & 0xff);
+
+ //MIC_HDR1
+ MIC_HDR1[0] = (BYTE)(wHLen >> 8);
+ MIC_HDR1[1] = (BYTE)(wHLen & 0xff);
+ byTmp = (BYTE)(pMACHeader->wFrameCtl & 0xff);
+ MIC_HDR1[2] = byTmp & 0x8f;
+ byTmp = (BYTE)(pMACHeader->wFrameCtl >> 8);
+ byTmp &= 0x87;
+ MIC_HDR1[3] = byTmp | 0x40;
+ MEMvCopy(&(MIC_HDR1[4]), pMACHeader->abyAddr1, U_ETHER_ADDR_LEN);
+ MEMvCopy(&(MIC_HDR1[10]), pMACHeader->abyAddr2, U_ETHER_ADDR_LEN);
+
+ //MIC_HDR2
+ MEMvCopy(&(MIC_HDR2[0]), pMACHeader->abyAddr3, U_ETHER_ADDR_LEN);
+ byTmp = (BYTE)(pMACHeader->wSeqCtl & 0xff);
+ MIC_HDR2[6] = byTmp & 0x0f;
+ MIC_HDR2[7] = 0;
+ if ( bA4 ) {
+ MEMvCopy(&(MIC_HDR2[8]), pMACHeader->abyAddr4, U_ETHER_ADDR_LEN);
+ } else {
+ MIC_HDR2[8] = 0x00;
+ MIC_HDR2[9] = 0x00;
+ MIC_HDR2[10] = 0x00;
+ MIC_HDR2[11] = 0x00;
+ MIC_HDR2[12] = 0x00;
+ MIC_HDR2[13] = 0x00;
+ }
+ MIC_HDR2[14] = 0x00;
+ MIC_HDR2[15] = 0x00;
+
+ //CCMP
+ AESv128(pbyRxKey,MIC_IV,abyMIC);
+ for ( kk=0; kk<16; kk++ ) {
+ abyTmp[kk] = MIC_HDR1[kk] ^ abyMIC[kk];
+ }
+ AESv128(pbyRxKey,abyTmp,abyMIC);
+ for ( kk=0; kk<16; kk++ ) {
+ abyTmp[kk] = MIC_HDR2[kk] ^ abyMIC[kk];
+ }
+ AESv128(pbyRxKey,abyTmp,abyMIC);
+
+ wCnt = 1;
+ abyCTRPLD[0] = 0x01;
+ MEMvCopy(&(abyCTRPLD[1]), &(abyNonce[0]), 13);
+
+ for(jj=wPayloadSize; jj>16; jj=jj-16) {
+
+ abyCTRPLD[14] = (BYTE) (wCnt >> 8);
+ abyCTRPLD[15] = (BYTE) (wCnt & 0xff);
+
+ AESv128(pbyRxKey,abyCTRPLD,abyTmp);
+
+ for ( kk=0; kk<16; kk++ ) {
+ abyPlainText[kk] = abyTmp[kk] ^ pbyPayload[kk];
+ }
+ for ( kk=0; kk<16; kk++ ) {
+ abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk];
+ }
+ AESv128(pbyRxKey,abyTmp,abyMIC);
+
+ MEMvCopy(pbyPayload, abyPlainText, 16);
+ wCnt++;
+ pbyPayload += 16;
+ } //for wPayloadSize
+
+ //last payload
+ MEMvCopy(&(abyLastCipher[0]), pbyPayload, jj);
+ for ( ii=jj; ii<16; ii++ ) {
+ abyLastCipher[ii] = 0x00;
+ }
+
+ abyCTRPLD[14] = (BYTE) (wCnt >> 8);
+ abyCTRPLD[15] = (BYTE) (wCnt & 0xff);
+
+ AESv128(pbyRxKey,abyCTRPLD,abyTmp);
+ for ( kk=0; kk<16; kk++ ) {
+ abyPlainText[kk] = abyTmp[kk] ^ abyLastCipher[kk];
+ }
+ MEMvCopy(pbyPayload, abyPlainText, jj);
+ pbyPayload += jj;
+
+ //for MIC calculation
+ for ( ii=jj; ii<16; ii++ ) {
+ abyPlainText[ii] = 0x00;
+ }
+ for ( kk=0; kk<16; kk++ ) {
+ abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk];
+ }
+ AESv128(pbyRxKey,abyTmp,abyMIC);
+
+ //=>above is the calculate MIC
+ //--------------------------------------------
+
+ wCnt = 0;
+ abyCTRPLD[14] = (BYTE) (wCnt >> 8);
+ abyCTRPLD[15] = (BYTE) (wCnt & 0xff);
+ AESv128(pbyRxKey,abyCTRPLD,abyTmp);
+ for ( kk=0; kk<8; kk++ ) {
+ abyTmp[kk] = abyTmp[kk] ^ pbyPayload[kk];
+ }
+ //=>above is the dec-MIC from packet
+ //--------------------------------------------
+
+ if ( MEMEqualMemory(abyMIC,abyTmp,8) ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+
+}
diff --git a/drivers/staging/vt6655/aes_ccmp.h b/drivers/staging/vt6655/aes_ccmp.h
new file mode 100644
index 000000000000..2b1920f28609
--- /dev/null
+++ b/drivers/staging/vt6655/aes_ccmp.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: aes_ccmp.h
+ *
+ * Purpose: AES_CCMP Decryption
+ *
+ * Author: Warren Hsu
+ *
+ * Date: Feb 15, 2005
+ *
+ */
+
+#ifndef __AES_H__
+#define __AES_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize);
+
+#endif //__AES_H__
diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c
new file mode 100644
index 000000000000..bc6db8699539
--- /dev/null
+++ b/drivers/staging/vt6655/baseband.c
@@ -0,0 +1,2990 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: baseband.c
+ *
+ * Purpose: Implement functions to access baseband
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: Aug.22, 2002
+ *
+ * Functions:
+ * BBuGetFrameTime - Calculate data frame transmitting time
+ * BBvCaculateParameter - Caculate PhyLength, PhyService and Phy Signal parameter for baseband Tx
+ * BBbReadEmbeded - Embeded read baseband register via MAC
+ * BBbWriteEmbeded - Embeded write baseband register via MAC
+ * BBbIsRegBitsOn - Test if baseband register bits on
+ * BBbIsRegBitsOff - Test if baseband register bits off
+ * BBbVT3253Init - VIA VT3253 baseband chip init code
+ * BBvReadAllRegs - Read All Baseband Registers
+ * BBvLoopbackOn - Turn on BaseBand Loopback mode
+ * BBvLoopbackOff - Turn off BaseBand Loopback mode
+ *
+ * Revision History:
+ * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
+ * 08-07-2003 Bryan YC Fan: Add MAXIM2827/2825 and RFMD2959 support.
+ * 08-26-2003 Kyle Hsu : Modify BBuGetFrameTime() and BBvCaculateParameter().
+ * cancel the setting of MAC_REG_SOFTPWRCTL on BBbVT3253Init().
+ * Add the comments.
+ * 09-01-2003 Bryan YC Fan: RF & BB tables updated.
+ * Modified BBvLoopbackOn & BBvLoopbackOff().
+ */
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__SROM_H__)
+#include "srom.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+//#define PLICE_DEBUG
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+
+
+#define CB_VT3253_INIT_FOR_RFMD 446
+BYTE byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
+ {0x00, 0x30},
+ {0x01, 0x00},
+ {0x02, 0x00},
+ {0x03, 0x00},
+ {0x04, 0x00},
+ {0x05, 0x00},
+ {0x06, 0x00},
+ {0x07, 0x00},
+ {0x08, 0x70},
+ {0x09, 0x45},
+ {0x0a, 0x2a},
+ {0x0b, 0x76},
+ {0x0c, 0x00},
+ {0x0d, 0x01},
+ {0x0e, 0x80},
+ {0x0f, 0x00},
+ {0x10, 0x00},
+ {0x11, 0x00},
+ {0x12, 0x00},
+ {0x13, 0x00},
+ {0x14, 0x00},
+ {0x15, 0x00},
+ {0x16, 0x00},
+ {0x17, 0x00},
+ {0x18, 0x00},
+ {0x19, 0x00},
+ {0x1a, 0x00},
+ {0x1b, 0x9d},
+ {0x1c, 0x05},
+ {0x1d, 0x00},
+ {0x1e, 0x00},
+ {0x1f, 0x00},
+ {0x20, 0x00},
+ {0x21, 0x00},
+ {0x22, 0x00},
+ {0x23, 0x00},
+ {0x24, 0x00},
+ {0x25, 0x4a},
+ {0x26, 0x00},
+ {0x27, 0x00},
+ {0x28, 0x00},
+ {0x29, 0x00},
+ {0x2a, 0x00},
+ {0x2b, 0x00},
+ {0x2c, 0x00},
+ {0x2d, 0xa8},
+ {0x2e, 0x1a},
+ {0x2f, 0x0c},
+ {0x30, 0x26},
+ {0x31, 0x5b},
+ {0x32, 0x00},
+ {0x33, 0x00},
+ {0x34, 0x00},
+ {0x35, 0x00},
+ {0x36, 0xaa},
+ {0x37, 0xaa},
+ {0x38, 0xff},
+ {0x39, 0xff},
+ {0x3a, 0x00},
+ {0x3b, 0x00},
+ {0x3c, 0x00},
+ {0x3d, 0x0d},
+ {0x3e, 0x51},
+ {0x3f, 0x04},
+ {0x40, 0x00},
+ {0x41, 0x08},
+ {0x42, 0x00},
+ {0x43, 0x08},
+ {0x44, 0x06},
+ {0x45, 0x14},
+ {0x46, 0x05},
+ {0x47, 0x08},
+ {0x48, 0x00},
+ {0x49, 0x00},
+ {0x4a, 0x00},
+ {0x4b, 0x00},
+ {0x4c, 0x09},
+ {0x4d, 0x80},
+ {0x4e, 0x00},
+ {0x4f, 0xc5},
+ {0x50, 0x14},
+ {0x51, 0x19},
+ {0x52, 0x00},
+ {0x53, 0x00},
+ {0x54, 0x00},
+ {0x55, 0x00},
+ {0x56, 0x00},
+ {0x57, 0x00},
+ {0x58, 0x00},
+ {0x59, 0xb0},
+ {0x5a, 0x00},
+ {0x5b, 0x00},
+ {0x5c, 0x00},
+ {0x5d, 0x00},
+ {0x5e, 0x00},
+ {0x5f, 0x00},
+ {0x60, 0x44},
+ {0x61, 0x04},
+ {0x62, 0x00},
+ {0x63, 0x00},
+ {0x64, 0x00},
+ {0x65, 0x00},
+ {0x66, 0x04},
+ {0x67, 0xb7},
+ {0x68, 0x00},
+ {0x69, 0x00},
+ {0x6a, 0x00},
+ {0x6b, 0x00},
+ {0x6c, 0x00},
+ {0x6d, 0x03},
+ {0x6e, 0x01},
+ {0x6f, 0x00},
+ {0x70, 0x00},
+ {0x71, 0x00},
+ {0x72, 0x00},
+ {0x73, 0x00},
+ {0x74, 0x00},
+ {0x75, 0x00},
+ {0x76, 0x00},
+ {0x77, 0x00},
+ {0x78, 0x00},
+ {0x79, 0x00},
+ {0x7a, 0x00},
+ {0x7b, 0x00},
+ {0x7c, 0x00},
+ {0x7d, 0x00},
+ {0x7e, 0x00},
+ {0x7f, 0x00},
+ {0x80, 0x0b},
+ {0x81, 0x00},
+ {0x82, 0x3c},
+ {0x83, 0x00},
+ {0x84, 0x00},
+ {0x85, 0x00},
+ {0x86, 0x00},
+ {0x87, 0x00},
+ {0x88, 0x08},
+ {0x89, 0x00},
+ {0x8a, 0x08},
+ {0x8b, 0xa6},
+ {0x8c, 0x84},
+ {0x8d, 0x47},
+ {0x8e, 0xbb},
+ {0x8f, 0x02},
+ {0x90, 0x21},
+ {0x91, 0x0c},
+ {0x92, 0x04},
+ {0x93, 0x22},
+ {0x94, 0x00},
+ {0x95, 0x00},
+ {0x96, 0x00},
+ {0x97, 0xeb},
+ {0x98, 0x00},
+ {0x99, 0x00},
+ {0x9a, 0x00},
+ {0x9b, 0x00},
+ {0x9c, 0x00},
+ {0x9d, 0x00},
+ {0x9e, 0x00},
+ {0x9f, 0x00},
+ {0xa0, 0x00},
+ {0xa1, 0x00},
+ {0xa2, 0x00},
+ {0xa3, 0x00},
+ {0xa4, 0x00},
+ {0xa5, 0x00},
+ {0xa6, 0x10},
+ {0xa7, 0x04},
+ {0xa8, 0x10},
+ {0xa9, 0x00},
+ {0xaa, 0x8f},
+ {0xab, 0x00},
+ {0xac, 0x00},
+ {0xad, 0x00},
+ {0xae, 0x00},
+ {0xaf, 0x80},
+ {0xb0, 0x38},
+ {0xb1, 0x00},
+ {0xb2, 0x00},
+ {0xb3, 0x00},
+ {0xb4, 0xee},
+ {0xb5, 0xff},
+ {0xb6, 0x10},
+ {0xb7, 0x00},
+ {0xb8, 0x00},
+ {0xb9, 0x00},
+ {0xba, 0x00},
+ {0xbb, 0x03},
+ {0xbc, 0x00},
+ {0xbd, 0x00},
+ {0xbe, 0x00},
+ {0xbf, 0x00},
+ {0xc0, 0x10},
+ {0xc1, 0x10},
+ {0xc2, 0x18},
+ {0xc3, 0x20},
+ {0xc4, 0x10},
+ {0xc5, 0x00},
+ {0xc6, 0x22},
+ {0xc7, 0x14},
+ {0xc8, 0x0f},
+ {0xc9, 0x08},
+ {0xca, 0xa4},
+ {0xcb, 0xa7},
+ {0xcc, 0x3c},
+ {0xcd, 0x10},
+ {0xce, 0x20},
+ {0xcf, 0x00},
+ {0xd0, 0x00},
+ {0xd1, 0x10},
+ {0xd2, 0x00},
+ {0xd3, 0x00},
+ {0xd4, 0x10},
+ {0xd5, 0x33},
+ {0xd6, 0x70},
+ {0xd7, 0x01},
+ {0xd8, 0x00},
+ {0xd9, 0x00},
+ {0xda, 0x00},
+ {0xdb, 0x00},
+ {0xdc, 0x00},
+ {0xdd, 0x00},
+ {0xde, 0x00},
+ {0xdf, 0x00},
+ {0xe0, 0x00},
+ {0xe1, 0x00},
+ {0xe2, 0xcc},
+ {0xe3, 0x04},
+ {0xe4, 0x08},
+ {0xe5, 0x10},
+ {0xe6, 0x00},
+ {0xe7, 0x0e},
+ {0xe8, 0x88},
+ {0xe9, 0xd4},
+ {0xea, 0x05},
+ {0xeb, 0xf0},
+ {0xec, 0x79},
+ {0xed, 0x0f},
+ {0xee, 0x04},
+ {0xef, 0x04},
+ {0xf0, 0x00},
+ {0xf1, 0x00},
+ {0xf2, 0x00},
+ {0xf3, 0x00},
+ {0xf4, 0x00},
+ {0xf5, 0x00},
+ {0xf6, 0x00},
+ {0xf7, 0x00},
+ {0xf8, 0x00},
+ {0xf9, 0x00},
+ {0xF0, 0x00},
+ {0xF1, 0xF8},
+ {0xF0, 0x80},
+ {0xF0, 0x00},
+ {0xF1, 0xF4},
+ {0xF0, 0x81},
+ {0xF0, 0x01},
+ {0xF1, 0xF0},
+ {0xF0, 0x82},
+ {0xF0, 0x02},
+ {0xF1, 0xEC},
+ {0xF0, 0x83},
+ {0xF0, 0x03},
+ {0xF1, 0xE8},
+ {0xF0, 0x84},
+ {0xF0, 0x04},
+ {0xF1, 0xE4},
+ {0xF0, 0x85},
+ {0xF0, 0x05},
+ {0xF1, 0xE0},
+ {0xF0, 0x86},
+ {0xF0, 0x06},
+ {0xF1, 0xDC},
+ {0xF0, 0x87},
+ {0xF0, 0x07},
+ {0xF1, 0xD8},
+ {0xF0, 0x88},
+ {0xF0, 0x08},
+ {0xF1, 0xD4},
+ {0xF0, 0x89},
+ {0xF0, 0x09},
+ {0xF1, 0xD0},
+ {0xF0, 0x8A},
+ {0xF0, 0x0A},
+ {0xF1, 0xCC},
+ {0xF0, 0x8B},
+ {0xF0, 0x0B},
+ {0xF1, 0xC8},
+ {0xF0, 0x8C},
+ {0xF0, 0x0C},
+ {0xF1, 0xC4},
+ {0xF0, 0x8D},
+ {0xF0, 0x0D},
+ {0xF1, 0xC0},
+ {0xF0, 0x8E},
+ {0xF0, 0x0E},
+ {0xF1, 0xBC},
+ {0xF0, 0x8F},
+ {0xF0, 0x0F},
+ {0xF1, 0xB8},
+ {0xF0, 0x90},
+ {0xF0, 0x10},
+ {0xF1, 0xB4},
+ {0xF0, 0x91},
+ {0xF0, 0x11},
+ {0xF1, 0xB0},
+ {0xF0, 0x92},
+ {0xF0, 0x12},
+ {0xF1, 0xAC},
+ {0xF0, 0x93},
+ {0xF0, 0x13},
+ {0xF1, 0xA8},
+ {0xF0, 0x94},
+ {0xF0, 0x14},
+ {0xF1, 0xA4},
+ {0xF0, 0x95},
+ {0xF0, 0x15},
+ {0xF1, 0xA0},
+ {0xF0, 0x96},
+ {0xF0, 0x16},
+ {0xF1, 0x9C},
+ {0xF0, 0x97},
+ {0xF0, 0x17},
+ {0xF1, 0x98},
+ {0xF0, 0x98},
+ {0xF0, 0x18},
+ {0xF1, 0x94},
+ {0xF0, 0x99},
+ {0xF0, 0x19},
+ {0xF1, 0x90},
+ {0xF0, 0x9A},
+ {0xF0, 0x1A},
+ {0xF1, 0x8C},
+ {0xF0, 0x9B},
+ {0xF0, 0x1B},
+ {0xF1, 0x88},
+ {0xF0, 0x9C},
+ {0xF0, 0x1C},
+ {0xF1, 0x84},
+ {0xF0, 0x9D},
+ {0xF0, 0x1D},
+ {0xF1, 0x80},
+ {0xF0, 0x9E},
+ {0xF0, 0x1E},
+ {0xF1, 0x7C},
+ {0xF0, 0x9F},
+ {0xF0, 0x1F},
+ {0xF1, 0x78},
+ {0xF0, 0xA0},
+ {0xF0, 0x20},
+ {0xF1, 0x74},
+ {0xF0, 0xA1},
+ {0xF0, 0x21},
+ {0xF1, 0x70},
+ {0xF0, 0xA2},
+ {0xF0, 0x22},
+ {0xF1, 0x6C},
+ {0xF0, 0xA3},
+ {0xF0, 0x23},
+ {0xF1, 0x68},
+ {0xF0, 0xA4},
+ {0xF0, 0x24},
+ {0xF1, 0x64},
+ {0xF0, 0xA5},
+ {0xF0, 0x25},
+ {0xF1, 0x60},
+ {0xF0, 0xA6},
+ {0xF0, 0x26},
+ {0xF1, 0x5C},
+ {0xF0, 0xA7},
+ {0xF0, 0x27},
+ {0xF1, 0x58},
+ {0xF0, 0xA8},
+ {0xF0, 0x28},
+ {0xF1, 0x54},
+ {0xF0, 0xA9},
+ {0xF0, 0x29},
+ {0xF1, 0x50},
+ {0xF0, 0xAA},
+ {0xF0, 0x2A},
+ {0xF1, 0x4C},
+ {0xF0, 0xAB},
+ {0xF0, 0x2B},
+ {0xF1, 0x48},
+ {0xF0, 0xAC},
+ {0xF0, 0x2C},
+ {0xF1, 0x44},
+ {0xF0, 0xAD},
+ {0xF0, 0x2D},
+ {0xF1, 0x40},
+ {0xF0, 0xAE},
+ {0xF0, 0x2E},
+ {0xF1, 0x3C},
+ {0xF0, 0xAF},
+ {0xF0, 0x2F},
+ {0xF1, 0x38},
+ {0xF0, 0xB0},
+ {0xF0, 0x30},
+ {0xF1, 0x34},
+ {0xF0, 0xB1},
+ {0xF0, 0x31},
+ {0xF1, 0x30},
+ {0xF0, 0xB2},
+ {0xF0, 0x32},
+ {0xF1, 0x2C},
+ {0xF0, 0xB3},
+ {0xF0, 0x33},
+ {0xF1, 0x28},
+ {0xF0, 0xB4},
+ {0xF0, 0x34},
+ {0xF1, 0x24},
+ {0xF0, 0xB5},
+ {0xF0, 0x35},
+ {0xF1, 0x20},
+ {0xF0, 0xB6},
+ {0xF0, 0x36},
+ {0xF1, 0x1C},
+ {0xF0, 0xB7},
+ {0xF0, 0x37},
+ {0xF1, 0x18},
+ {0xF0, 0xB8},
+ {0xF0, 0x38},
+ {0xF1, 0x14},
+ {0xF0, 0xB9},
+ {0xF0, 0x39},
+ {0xF1, 0x10},
+ {0xF0, 0xBA},
+ {0xF0, 0x3A},
+ {0xF1, 0x0C},
+ {0xF0, 0xBB},
+ {0xF0, 0x3B},
+ {0xF1, 0x08},
+ {0xF0, 0x00},
+ {0xF0, 0x3C},
+ {0xF1, 0x04},
+ {0xF0, 0xBD},
+ {0xF0, 0x3D},
+ {0xF1, 0x00},
+ {0xF0, 0xBE},
+ {0xF0, 0x3E},
+ {0xF1, 0x00},
+ {0xF0, 0xBF},
+ {0xF0, 0x3F},
+ {0xF1, 0x00},
+ {0xF0, 0xC0},
+ {0xF0, 0x00},
+};
+
+#define CB_VT3253B0_INIT_FOR_RFMD 256
+BYTE byVT3253B0_RFMD[CB_VT3253B0_INIT_FOR_RFMD][2] = {
+ {0x00, 0x31},
+ {0x01, 0x00},
+ {0x02, 0x00},
+ {0x03, 0x00},
+ {0x04, 0x00},
+ {0x05, 0x81},
+ {0x06, 0x00},
+ {0x07, 0x00},
+ {0x08, 0x38},
+ {0x09, 0x45},
+ {0x0a, 0x2a},
+ {0x0b, 0x76},
+ {0x0c, 0x00},
+ {0x0d, 0x00},
+ {0x0e, 0x80},
+ {0x0f, 0x00},
+ {0x10, 0x00},
+ {0x11, 0x00},
+ {0x12, 0x00},
+ {0x13, 0x00},
+ {0x14, 0x00},
+ {0x15, 0x00},
+ {0x16, 0x00},
+ {0x17, 0x00},
+ {0x18, 0x00},
+ {0x19, 0x00},
+ {0x1a, 0x00},
+ {0x1b, 0x8e},
+ {0x1c, 0x06},
+ {0x1d, 0x00},
+ {0x1e, 0x00},
+ {0x1f, 0x00},
+ {0x20, 0x00},
+ {0x21, 0x00},
+ {0x22, 0x00},
+ {0x23, 0x00},
+ {0x24, 0x00},
+ {0x25, 0x4a},
+ {0x26, 0x00},
+ {0x27, 0x00},
+ {0x28, 0x00},
+ {0x29, 0x00},
+ {0x2a, 0x00},
+ {0x2b, 0x00},
+ {0x2c, 0x00},
+ {0x2d, 0x34},
+ {0x2e, 0x18},
+ {0x2f, 0x0c},
+ {0x30, 0x26},
+ {0x31, 0x5b},
+ {0x32, 0x00},
+ {0x33, 0x00},
+ {0x34, 0x00},
+ {0x35, 0x00},
+ {0x36, 0xaa},
+ {0x37, 0xaa},
+ {0x38, 0xff},
+ {0x39, 0xff},
+ {0x3a, 0xf8},
+ {0x3b, 0x00},
+ {0x3c, 0x00},
+ {0x3d, 0x09},
+ {0x3e, 0x0d},
+ {0x3f, 0x04},
+ {0x40, 0x00},
+ {0x41, 0x08},
+ {0x42, 0x00},
+ {0x43, 0x08},
+ {0x44, 0x08},
+ {0x45, 0x14},
+ {0x46, 0x05},
+ {0x47, 0x08},
+ {0x48, 0x00},
+ {0x49, 0x00},
+ {0x4a, 0x00},
+ {0x4b, 0x00},
+ {0x4c, 0x09},
+ {0x4d, 0x80},
+ {0x4e, 0x00},
+ {0x4f, 0xc5},
+ {0x50, 0x14},
+ {0x51, 0x19},
+ {0x52, 0x00},
+ {0x53, 0x00},
+ {0x54, 0x00},
+ {0x55, 0x00},
+ {0x56, 0x00},
+ {0x57, 0x00},
+ {0x58, 0x00},
+ {0x59, 0xb0},
+ {0x5a, 0x00},
+ {0x5b, 0x00},
+ {0x5c, 0x00},
+ {0x5d, 0x00},
+ {0x5e, 0x00},
+ {0x5f, 0x00},
+ {0x60, 0x39},
+ {0x61, 0x83},
+ {0x62, 0x00},
+ {0x63, 0x00},
+ {0x64, 0x00},
+ {0x65, 0x00},
+ {0x66, 0xc0},
+ {0x67, 0x49},
+ {0x68, 0x00},
+ {0x69, 0x00},
+ {0x6a, 0x00},
+ {0x6b, 0x00},
+ {0x6c, 0x00},
+ {0x6d, 0x03},
+ {0x6e, 0x01},
+ {0x6f, 0x00},
+ {0x70, 0x00},
+ {0x71, 0x00},
+ {0x72, 0x00},
+ {0x73, 0x00},
+ {0x74, 0x00},
+ {0x75, 0x00},
+ {0x76, 0x00},
+ {0x77, 0x00},
+ {0x78, 0x00},
+ {0x79, 0x00},
+ {0x7a, 0x00},
+ {0x7b, 0x00},
+ {0x7c, 0x00},
+ {0x7d, 0x00},
+ {0x7e, 0x00},
+ {0x7f, 0x00},
+ {0x80, 0x89},
+ {0x81, 0x00},
+ {0x82, 0x0e},
+ {0x83, 0x00},
+ {0x84, 0x00},
+ {0x85, 0x00},
+ {0x86, 0x00},
+ {0x87, 0x00},
+ {0x88, 0x08},
+ {0x89, 0x00},
+ {0x8a, 0x0e},
+ {0x8b, 0xa7},
+ {0x8c, 0x88},
+ {0x8d, 0x47},
+ {0x8e, 0xaa},
+ {0x8f, 0x02},
+ {0x90, 0x23},
+ {0x91, 0x0c},
+ {0x92, 0x06},
+ {0x93, 0x08},
+ {0x94, 0x00},
+ {0x95, 0x00},
+ {0x96, 0x00},
+ {0x97, 0xeb},
+ {0x98, 0x00},
+ {0x99, 0x00},
+ {0x9a, 0x00},
+ {0x9b, 0x00},
+ {0x9c, 0x00},
+ {0x9d, 0x00},
+ {0x9e, 0x00},
+ {0x9f, 0x00},
+ {0xa0, 0x00},
+ {0xa1, 0x00},
+ {0xa2, 0x00},
+ {0xa3, 0xcd},
+ {0xa4, 0x07},
+ {0xa5, 0x33},
+ {0xa6, 0x18},
+ {0xa7, 0x00},
+ {0xa8, 0x18},
+ {0xa9, 0x00},
+ {0xaa, 0x28},
+ {0xab, 0x00},
+ {0xac, 0x00},
+ {0xad, 0x00},
+ {0xae, 0x00},
+ {0xaf, 0x18},
+ {0xb0, 0x38},
+ {0xb1, 0x30},
+ {0xb2, 0x00},
+ {0xb3, 0x00},
+ {0xb4, 0x00},
+ {0xb5, 0x00},
+ {0xb6, 0x84},
+ {0xb7, 0xfd},
+ {0xb8, 0x00},
+ {0xb9, 0x00},
+ {0xba, 0x00},
+ {0xbb, 0x03},
+ {0xbc, 0x00},
+ {0xbd, 0x00},
+ {0xbe, 0x00},
+ {0xbf, 0x00},
+ {0xc0, 0x10},
+ {0xc1, 0x20},
+ {0xc2, 0x18},
+ {0xc3, 0x20},
+ {0xc4, 0x10},
+ {0xc5, 0x2c},
+ {0xc6, 0x1e},
+ {0xc7, 0x10},
+ {0xc8, 0x12},
+ {0xc9, 0x01},
+ {0xca, 0x6f},
+ {0xcb, 0xa7},
+ {0xcc, 0x3c},
+ {0xcd, 0x10},
+ {0xce, 0x00},
+ {0xcf, 0x22},
+ {0xd0, 0x00},
+ {0xd1, 0x10},
+ {0xd2, 0x00},
+ {0xd3, 0x00},
+ {0xd4, 0x10},
+ {0xd5, 0x33},
+ {0xd6, 0x80},
+ {0xd7, 0x21},
+ {0xd8, 0x00},
+ {0xd9, 0x00},
+ {0xda, 0x00},
+ {0xdb, 0x00},
+ {0xdc, 0x00},
+ {0xdd, 0x00},
+ {0xde, 0x00},
+ {0xdf, 0x00},
+ {0xe0, 0x00},
+ {0xe1, 0xB3},
+ {0xe2, 0x00},
+ {0xe3, 0x00},
+ {0xe4, 0x00},
+ {0xe5, 0x10},
+ {0xe6, 0x00},
+ {0xe7, 0x18},
+ {0xe8, 0x08},
+ {0xe9, 0xd4},
+ {0xea, 0x00},
+ {0xeb, 0xff},
+ {0xec, 0x79},
+ {0xed, 0x10},
+ {0xee, 0x30},
+ {0xef, 0x02},
+ {0xf0, 0x00},
+ {0xf1, 0x09},
+ {0xf2, 0x00},
+ {0xf3, 0x00},
+ {0xf4, 0x00},
+ {0xf5, 0x00},
+ {0xf6, 0x00},
+ {0xf7, 0x00},
+ {0xf8, 0x00},
+ {0xf9, 0x00},
+ {0xfa, 0x00},
+ {0xfb, 0x00},
+ {0xfc, 0x00},
+ {0xfd, 0x00},
+ {0xfe, 0x00},
+ {0xff, 0x00},
+};
+
+#define CB_VT3253B0_AGC_FOR_RFMD2959 195
+// For RFMD2959
+BYTE byVT3253B0_AGC4_RFMD2959[CB_VT3253B0_AGC_FOR_RFMD2959][2] = {
+ {0xF0, 0x00},
+ {0xF1, 0x3E},
+ {0xF0, 0x80},
+ {0xF0, 0x00},
+ {0xF1, 0x3E},
+ {0xF0, 0x81},
+ {0xF0, 0x01},
+ {0xF1, 0x3E},
+ {0xF0, 0x82},
+ {0xF0, 0x02},
+ {0xF1, 0x3E},
+ {0xF0, 0x83},
+ {0xF0, 0x03},
+ {0xF1, 0x3B},
+ {0xF0, 0x84},
+ {0xF0, 0x04},
+ {0xF1, 0x39},
+ {0xF0, 0x85},
+ {0xF0, 0x05},
+ {0xF1, 0x38},
+ {0xF0, 0x86},
+ {0xF0, 0x06},
+ {0xF1, 0x37},
+ {0xF0, 0x87},
+ {0xF0, 0x07},
+ {0xF1, 0x36},
+ {0xF0, 0x88},
+ {0xF0, 0x08},
+ {0xF1, 0x35},
+ {0xF0, 0x89},
+ {0xF0, 0x09},
+ {0xF1, 0x35},
+ {0xF0, 0x8A},
+ {0xF0, 0x0A},
+ {0xF1, 0x34},
+ {0xF0, 0x8B},
+ {0xF0, 0x0B},
+ {0xF1, 0x34},
+ {0xF0, 0x8C},
+ {0xF0, 0x0C},
+ {0xF1, 0x33},
+ {0xF0, 0x8D},
+ {0xF0, 0x0D},
+ {0xF1, 0x32},
+ {0xF0, 0x8E},
+ {0xF0, 0x0E},
+ {0xF1, 0x31},
+ {0xF0, 0x8F},
+ {0xF0, 0x0F},
+ {0xF1, 0x30},
+ {0xF0, 0x90},
+ {0xF0, 0x10},
+ {0xF1, 0x2F},
+ {0xF0, 0x91},
+ {0xF0, 0x11},
+ {0xF1, 0x2F},
+ {0xF0, 0x92},
+ {0xF0, 0x12},
+ {0xF1, 0x2E},
+ {0xF0, 0x93},
+ {0xF0, 0x13},
+ {0xF1, 0x2D},
+ {0xF0, 0x94},
+ {0xF0, 0x14},
+ {0xF1, 0x2C},
+ {0xF0, 0x95},
+ {0xF0, 0x15},
+ {0xF1, 0x2B},
+ {0xF0, 0x96},
+ {0xF0, 0x16},
+ {0xF1, 0x2B},
+ {0xF0, 0x97},
+ {0xF0, 0x17},
+ {0xF1, 0x2A},
+ {0xF0, 0x98},
+ {0xF0, 0x18},
+ {0xF1, 0x29},
+ {0xF0, 0x99},
+ {0xF0, 0x19},
+ {0xF1, 0x28},
+ {0xF0, 0x9A},
+ {0xF0, 0x1A},
+ {0xF1, 0x27},
+ {0xF0, 0x9B},
+ {0xF0, 0x1B},
+ {0xF1, 0x26},
+ {0xF0, 0x9C},
+ {0xF0, 0x1C},
+ {0xF1, 0x25},
+ {0xF0, 0x9D},
+ {0xF0, 0x1D},
+ {0xF1, 0x24},
+ {0xF0, 0x9E},
+ {0xF0, 0x1E},
+ {0xF1, 0x24},
+ {0xF0, 0x9F},
+ {0xF0, 0x1F},
+ {0xF1, 0x23},
+ {0xF0, 0xA0},
+ {0xF0, 0x20},
+ {0xF1, 0x22},
+ {0xF0, 0xA1},
+ {0xF0, 0x21},
+ {0xF1, 0x21},
+ {0xF0, 0xA2},
+ {0xF0, 0x22},
+ {0xF1, 0x20},
+ {0xF0, 0xA3},
+ {0xF0, 0x23},
+ {0xF1, 0x20},
+ {0xF0, 0xA4},
+ {0xF0, 0x24},
+ {0xF1, 0x1F},
+ {0xF0, 0xA5},
+ {0xF0, 0x25},
+ {0xF1, 0x1E},
+ {0xF0, 0xA6},
+ {0xF0, 0x26},
+ {0xF1, 0x1D},
+ {0xF0, 0xA7},
+ {0xF0, 0x27},
+ {0xF1, 0x1C},
+ {0xF0, 0xA8},
+ {0xF0, 0x28},
+ {0xF1, 0x1B},
+ {0xF0, 0xA9},
+ {0xF0, 0x29},
+ {0xF1, 0x1B},
+ {0xF0, 0xAA},
+ {0xF0, 0x2A},
+ {0xF1, 0x1A},
+ {0xF0, 0xAB},
+ {0xF0, 0x2B},
+ {0xF1, 0x1A},
+ {0xF0, 0xAC},
+ {0xF0, 0x2C},
+ {0xF1, 0x19},
+ {0xF0, 0xAD},
+ {0xF0, 0x2D},
+ {0xF1, 0x18},
+ {0xF0, 0xAE},
+ {0xF0, 0x2E},
+ {0xF1, 0x17},
+ {0xF0, 0xAF},
+ {0xF0, 0x2F},
+ {0xF1, 0x16},
+ {0xF0, 0xB0},
+ {0xF0, 0x30},
+ {0xF1, 0x15},
+ {0xF0, 0xB1},
+ {0xF0, 0x31},
+ {0xF1, 0x15},
+ {0xF0, 0xB2},
+ {0xF0, 0x32},
+ {0xF1, 0x15},
+ {0xF0, 0xB3},
+ {0xF0, 0x33},
+ {0xF1, 0x14},
+ {0xF0, 0xB4},
+ {0xF0, 0x34},
+ {0xF1, 0x13},
+ {0xF0, 0xB5},
+ {0xF0, 0x35},
+ {0xF1, 0x12},
+ {0xF0, 0xB6},
+ {0xF0, 0x36},
+ {0xF1, 0x11},
+ {0xF0, 0xB7},
+ {0xF0, 0x37},
+ {0xF1, 0x10},
+ {0xF0, 0xB8},
+ {0xF0, 0x38},
+ {0xF1, 0x0F},
+ {0xF0, 0xB9},
+ {0xF0, 0x39},
+ {0xF1, 0x0E},
+ {0xF0, 0xBA},
+ {0xF0, 0x3A},
+ {0xF1, 0x0D},
+ {0xF0, 0xBB},
+ {0xF0, 0x3B},
+ {0xF1, 0x0C},
+ {0xF0, 0xBC},
+ {0xF0, 0x3C},
+ {0xF1, 0x0B},
+ {0xF0, 0xBD},
+ {0xF0, 0x3D},
+ {0xF1, 0x0B},
+ {0xF0, 0xBE},
+ {0xF0, 0x3E},
+ {0xF1, 0x0A},
+ {0xF0, 0xBF},
+ {0xF0, 0x3F},
+ {0xF1, 0x09},
+ {0xF0, 0x00},
+};
+
+#define CB_VT3253B0_INIT_FOR_AIROHA2230 256
+// For AIROHA
+BYTE byVT3253B0_AIROHA2230[CB_VT3253B0_INIT_FOR_AIROHA2230][2] = {
+ {0x00, 0x31},
+ {0x01, 0x00},
+ {0x02, 0x00},
+ {0x03, 0x00},
+ {0x04, 0x00},
+ {0x05, 0x80},
+ {0x06, 0x00},
+ {0x07, 0x00},
+ {0x08, 0x70},
+ {0x09, 0x41},
+ {0x0a, 0x2A},
+ {0x0b, 0x76},
+ {0x0c, 0x00},
+ {0x0d, 0x00},
+ {0x0e, 0x80},
+ {0x0f, 0x00},
+ {0x10, 0x00},
+ {0x11, 0x00},
+ {0x12, 0x00},
+ {0x13, 0x00},
+ {0x14, 0x00},
+ {0x15, 0x00},
+ {0x16, 0x00},
+ {0x17, 0x00},
+ {0x18, 0x00},
+ {0x19, 0x00},
+ {0x1a, 0x00},
+ {0x1b, 0x8f},
+ {0x1c, 0x09},
+ {0x1d, 0x00},
+ {0x1e, 0x00},
+ {0x1f, 0x00},
+ {0x20, 0x00},
+ {0x21, 0x00},
+ {0x22, 0x00},
+ {0x23, 0x00},
+ {0x24, 0x00},
+ {0x25, 0x4a},
+ {0x26, 0x00},
+ {0x27, 0x00},
+ {0x28, 0x00},
+ {0x29, 0x00},
+ {0x2a, 0x00},
+ {0x2b, 0x00},
+ {0x2c, 0x00},
+ {0x2d, 0x4a},
+ {0x2e, 0x00},
+ {0x2f, 0x0a},
+ {0x30, 0x26},
+ {0x31, 0x5b},
+ {0x32, 0x00},
+ {0x33, 0x00},
+ {0x34, 0x00},
+ {0x35, 0x00},
+ {0x36, 0xaa},
+ {0x37, 0xaa},
+ {0x38, 0xff},
+ {0x39, 0xff},
+ {0x3a, 0x79},
+ {0x3b, 0x00},
+ {0x3c, 0x00},
+ {0x3d, 0x0b},
+ {0x3e, 0x48},
+ {0x3f, 0x04},
+ {0x40, 0x00},
+ {0x41, 0x08},
+ {0x42, 0x00},
+ {0x43, 0x08},
+ {0x44, 0x08},
+ {0x45, 0x14},
+ {0x46, 0x05},
+ {0x47, 0x09},
+ {0x48, 0x00},
+ {0x49, 0x00},
+ {0x4a, 0x00},
+ {0x4b, 0x00},
+ {0x4c, 0x09},
+ {0x4d, 0x73},
+ {0x4e, 0x00},
+ {0x4f, 0xc5},
+ {0x50, 0x15},
+ {0x51, 0x19},
+ {0x52, 0x00},
+ {0x53, 0x00},
+ {0x54, 0x00},
+ {0x55, 0x00},
+ {0x56, 0x00},
+ {0x57, 0x00},
+ {0x58, 0x00},
+ {0x59, 0xb0},
+ {0x5a, 0x00},
+ {0x5b, 0x00},
+ {0x5c, 0x00},
+ {0x5d, 0x00},
+ {0x5e, 0x00},
+ {0x5f, 0x00},
+ {0x60, 0xe4},
+ {0x61, 0x80},
+ {0x62, 0x00},
+ {0x63, 0x00},
+ {0x64, 0x00},
+ {0x65, 0x00},
+ {0x66, 0x98},
+ {0x67, 0x0a},
+ {0x68, 0x00},
+ {0x69, 0x00},
+ {0x6a, 0x00},
+ {0x6b, 0x00},
+ //{0x6c, 0x80},
+ {0x6c, 0x00}, //RobertYu:20050125, request by JJSue
+ {0x6d, 0x03},
+ {0x6e, 0x01},
+ {0x6f, 0x00},
+ {0x70, 0x00},
+ {0x71, 0x00},
+ {0x72, 0x00},
+ {0x73, 0x00},
+ {0x74, 0x00},
+ {0x75, 0x00},
+ {0x76, 0x00},
+ {0x77, 0x00},
+ {0x78, 0x00},
+ {0x79, 0x00},
+ {0x7a, 0x00},
+ {0x7b, 0x00},
+ {0x7c, 0x00},
+ {0x7d, 0x00},
+ {0x7e, 0x00},
+ {0x7f, 0x00},
+ {0x80, 0x8c},
+ {0x81, 0x01},
+ {0x82, 0x09},
+ {0x83, 0x00},
+ {0x84, 0x00},
+ {0x85, 0x00},
+ {0x86, 0x00},
+ {0x87, 0x00},
+ {0x88, 0x08},
+ {0x89, 0x00},
+ {0x8a, 0x0f},
+ {0x8b, 0xb7},
+ {0x8c, 0x88},
+ {0x8d, 0x47},
+ {0x8e, 0xaa},
+ {0x8f, 0x02},
+ {0x90, 0x22},
+ {0x91, 0x00},
+ {0x92, 0x00},
+ {0x93, 0x00},
+ {0x94, 0x00},
+ {0x95, 0x00},
+ {0x96, 0x00},
+ {0x97, 0xeb},
+ {0x98, 0x00},
+ {0x99, 0x00},
+ {0x9a, 0x00},
+ {0x9b, 0x00},
+ {0x9c, 0x00},
+ {0x9d, 0x00},
+ {0x9e, 0x00},
+ {0x9f, 0x01},
+ {0xa0, 0x00},
+ {0xa1, 0x00},
+ {0xa2, 0x00},
+ {0xa3, 0x00},
+ {0xa4, 0x00},
+ {0xa5, 0x00},
+ {0xa6, 0x10},
+ {0xa7, 0x00},
+ {0xa8, 0x18},
+ {0xa9, 0x00},
+ {0xaa, 0x00},
+ {0xab, 0x00},
+ {0xac, 0x00},
+ {0xad, 0x00},
+ {0xae, 0x00},
+ {0xaf, 0x18},
+ {0xb0, 0x38},
+ {0xb1, 0x30},
+ {0xb2, 0x00},
+ {0xb3, 0x00},
+ {0xb4, 0xff},
+ {0xb5, 0x0f},
+ {0xb6, 0xe4},
+ {0xb7, 0xe2},
+ {0xb8, 0x00},
+ {0xb9, 0x00},
+ {0xba, 0x00},
+ {0xbb, 0x03},
+ {0xbc, 0x01},
+ {0xbd, 0x00},
+ {0xbe, 0x00},
+ {0xbf, 0x00},
+ {0xc0, 0x18},
+ {0xc1, 0x20},
+ {0xc2, 0x07},
+ {0xc3, 0x18},
+ {0xc4, 0xff},
+ {0xc5, 0x2c},
+ {0xc6, 0x0c},
+ {0xc7, 0x0a},
+ {0xc8, 0x0e},
+ {0xc9, 0x01},
+ {0xca, 0x68},
+ {0xcb, 0xa7},
+ {0xcc, 0x3c},
+ {0xcd, 0x10},
+ {0xce, 0x00},
+ {0xcf, 0x25},
+ {0xd0, 0x40},
+ {0xd1, 0x12},
+ {0xd2, 0x00},
+ {0xd3, 0x00},
+ {0xd4, 0x10},
+ {0xd5, 0x28},
+ {0xd6, 0x80},
+ {0xd7, 0x2A},
+ {0xd8, 0x00},
+ {0xd9, 0x00},
+ {0xda, 0x00},
+ {0xdb, 0x00},
+ {0xdc, 0x00},
+ {0xdd, 0x00},
+ {0xde, 0x00},
+ {0xdf, 0x00},
+ {0xe0, 0x00},
+ {0xe1, 0xB3},
+ {0xe2, 0x00},
+ {0xe3, 0x00},
+ {0xe4, 0x00},
+ {0xe5, 0x10},
+ {0xe6, 0x00},
+ {0xe7, 0x1C},
+ {0xe8, 0x00},
+ {0xe9, 0xf4},
+ {0xea, 0x00},
+ {0xeb, 0xff},
+ {0xec, 0x79},
+ {0xed, 0x20},
+ {0xee, 0x30},
+ {0xef, 0x01},
+ {0xf0, 0x00},
+ {0xf1, 0x3e},
+ {0xf2, 0x00},
+ {0xf3, 0x00},
+ {0xf4, 0x00},
+ {0xf5, 0x00},
+ {0xf6, 0x00},
+ {0xf7, 0x00},
+ {0xf8, 0x00},
+ {0xf9, 0x00},
+ {0xfa, 0x00},
+ {0xfb, 0x00},
+ {0xfc, 0x00},
+ {0xfd, 0x00},
+ {0xfe, 0x00},
+ {0xff, 0x00},
+};
+
+
+
+#define CB_VT3253B0_INIT_FOR_UW2451 256
+//For UW2451
+BYTE byVT3253B0_UW2451[CB_VT3253B0_INIT_FOR_UW2451][2] = {
+ {0x00, 0x31},
+ {0x01, 0x00},
+ {0x02, 0x00},
+ {0x03, 0x00},
+ {0x04, 0x00},
+ {0x05, 0x81},
+ {0x06, 0x00},
+ {0x07, 0x00},
+ {0x08, 0x38},
+ {0x09, 0x45},
+ {0x0a, 0x28},
+ {0x0b, 0x76},
+ {0x0c, 0x00},
+ {0x0d, 0x00},
+ {0x0e, 0x80},
+ {0x0f, 0x00},
+ {0x10, 0x00},
+ {0x11, 0x00},
+ {0x12, 0x00},
+ {0x13, 0x00},
+ {0x14, 0x00},
+ {0x15, 0x00},
+ {0x16, 0x00},
+ {0x17, 0x00},
+ {0x18, 0x00},
+ {0x19, 0x00},
+ {0x1a, 0x00},
+ {0x1b, 0x8f},
+ {0x1c, 0x0f},
+ {0x1d, 0x00},
+ {0x1e, 0x00},
+ {0x1f, 0x00},
+ {0x20, 0x00},
+ {0x21, 0x00},
+ {0x22, 0x00},
+ {0x23, 0x00},
+ {0x24, 0x00},
+ {0x25, 0x4a},
+ {0x26, 0x00},
+ {0x27, 0x00},
+ {0x28, 0x00},
+ {0x29, 0x00},
+ {0x2a, 0x00},
+ {0x2b, 0x00},
+ {0x2c, 0x00},
+ {0x2d, 0x18},
+ {0x2e, 0x00},
+ {0x2f, 0x0a},
+ {0x30, 0x26},
+ {0x31, 0x5b},
+ {0x32, 0x00},
+ {0x33, 0x00},
+ {0x34, 0x00},
+ {0x35, 0x00},
+ {0x36, 0xaa},
+ {0x37, 0xaa},
+ {0x38, 0xff},
+ {0x39, 0xff},
+ {0x3a, 0x00},
+ {0x3b, 0x00},
+ {0x3c, 0x00},
+ {0x3d, 0x03},
+ {0x3e, 0x1d},
+ {0x3f, 0x04},
+ {0x40, 0x00},
+ {0x41, 0x08},
+ {0x42, 0x00},
+ {0x43, 0x08},
+ {0x44, 0x08},
+ {0x45, 0x14},
+ {0x46, 0x05},
+ {0x47, 0x09},
+ {0x48, 0x00},
+ {0x49, 0x00},
+ {0x4a, 0x00},
+ {0x4b, 0x00},
+ {0x4c, 0x09},
+ {0x4d, 0x90},
+ {0x4e, 0x00},
+ {0x4f, 0xc5},
+ {0x50, 0x15},
+ {0x51, 0x19},
+ {0x52, 0x00},
+ {0x53, 0x00},
+ {0x54, 0x00},
+ {0x55, 0x00},
+ {0x56, 0x00},
+ {0x57, 0x00},
+ {0x58, 0x00},
+ {0x59, 0xb0},
+ {0x5a, 0x00},
+ {0x5b, 0x00},
+ {0x5c, 0x00},
+ {0x5d, 0x00},
+ {0x5e, 0x00},
+ {0x5f, 0x00},
+ {0x60, 0xb3},
+ {0x61, 0x81},
+ {0x62, 0x00},
+ {0x63, 0x00},
+ {0x64, 0x00},
+ {0x65, 0x00},
+ {0x66, 0x57},
+ {0x67, 0x6c},
+ {0x68, 0x00},
+ {0x69, 0x00},
+ {0x6a, 0x00},
+ {0x6b, 0x00},
+ //{0x6c, 0x80},
+ {0x6c, 0x00}, //RobertYu:20050125, request by JJSue
+ {0x6d, 0x03},
+ {0x6e, 0x01},
+ {0x6f, 0x00},
+ {0x70, 0x00},
+ {0x71, 0x00},
+ {0x72, 0x00},
+ {0x73, 0x00},
+ {0x74, 0x00},
+ {0x75, 0x00},
+ {0x76, 0x00},
+ {0x77, 0x00},
+ {0x78, 0x00},
+ {0x79, 0x00},
+ {0x7a, 0x00},
+ {0x7b, 0x00},
+ {0x7c, 0x00},
+ {0x7d, 0x00},
+ {0x7e, 0x00},
+ {0x7f, 0x00},
+ {0x80, 0x8c},
+ {0x81, 0x00},
+ {0x82, 0x0e},
+ {0x83, 0x00},
+ {0x84, 0x00},
+ {0x85, 0x00},
+ {0x86, 0x00},
+ {0x87, 0x00},
+ {0x88, 0x08},
+ {0x89, 0x00},
+ {0x8a, 0x0e},
+ {0x8b, 0xa7},
+ {0x8c, 0x88},
+ {0x8d, 0x47},
+ {0x8e, 0xaa},
+ {0x8f, 0x02},
+ {0x90, 0x00},
+ {0x91, 0x00},
+ {0x92, 0x00},
+ {0x93, 0x00},
+ {0x94, 0x00},
+ {0x95, 0x00},
+ {0x96, 0x00},
+ {0x97, 0xe3},
+ {0x98, 0x00},
+ {0x99, 0x00},
+ {0x9a, 0x00},
+ {0x9b, 0x00},
+ {0x9c, 0x00},
+ {0x9d, 0x00},
+ {0x9e, 0x00},
+ {0x9f, 0x00},
+ {0xa0, 0x00},
+ {0xa1, 0x00},
+ {0xa2, 0x00},
+ {0xa3, 0x00},
+ {0xa4, 0x00},
+ {0xa5, 0x00},
+ {0xa6, 0x10},
+ {0xa7, 0x00},
+ {0xa8, 0x18},
+ {0xa9, 0x00},
+ {0xaa, 0x00},
+ {0xab, 0x00},
+ {0xac, 0x00},
+ {0xad, 0x00},
+ {0xae, 0x00},
+ {0xaf, 0x18},
+ {0xb0, 0x18},
+ {0xb1, 0x30},
+ {0xb2, 0x00},
+ {0xb3, 0x00},
+ {0xb4, 0x00},
+ {0xb5, 0x00},
+ {0xb6, 0x00},
+ {0xb7, 0x00},
+ {0xb8, 0x00},
+ {0xb9, 0x00},
+ {0xba, 0x00},
+ {0xbb, 0x03},
+ {0xbc, 0x01},
+ {0xbd, 0x00},
+ {0xbe, 0x00},
+ {0xbf, 0x00},
+ {0xc0, 0x10},
+ {0xc1, 0x20},
+ {0xc2, 0x00},
+ {0xc3, 0x20},
+ {0xc4, 0x00},
+ {0xc5, 0x2c},
+ {0xc6, 0x1c},
+ {0xc7, 0x10},
+ {0xc8, 0x10},
+ {0xc9, 0x01},
+ {0xca, 0x68},
+ {0xcb, 0xa7},
+ {0xcc, 0x3c},
+ {0xcd, 0x09},
+ {0xce, 0x00},
+ {0xcf, 0x20},
+ {0xd0, 0x40},
+ {0xd1, 0x10},
+ {0xd2, 0x00},
+ {0xd3, 0x00},
+ {0xd4, 0x20},
+ {0xd5, 0x28},
+ {0xd6, 0xa0},
+ {0xd7, 0x2a},
+ {0xd8, 0x00},
+ {0xd9, 0x00},
+ {0xda, 0x00},
+ {0xdb, 0x00},
+ {0xdc, 0x00},
+ {0xdd, 0x00},
+ {0xde, 0x00},
+ {0xdf, 0x00},
+ {0xe0, 0x00},
+ {0xe1, 0xd3},
+ {0xe2, 0xc0},
+ {0xe3, 0x00},
+ {0xe4, 0x00},
+ {0xe5, 0x10},
+ {0xe6, 0x00},
+ {0xe7, 0x12},
+ {0xe8, 0x12},
+ {0xe9, 0x34},
+ {0xea, 0x00},
+ {0xeb, 0xff},
+ {0xec, 0x79},
+ {0xed, 0x20},
+ {0xee, 0x30},
+ {0xef, 0x01},
+ {0xf0, 0x00},
+ {0xf1, 0x3e},
+ {0xf2, 0x00},
+ {0xf3, 0x00},
+ {0xf4, 0x00},
+ {0xf5, 0x00},
+ {0xf6, 0x00},
+ {0xf7, 0x00},
+ {0xf8, 0x00},
+ {0xf9, 0x00},
+ {0xfa, 0x00},
+ {0xfb, 0x00},
+ {0xfc, 0x00},
+ {0xfd, 0x00},
+ {0xfe, 0x00},
+ {0xff, 0x00},
+};
+
+#define CB_VT3253B0_AGC 193
+// For AIROHA
+BYTE byVT3253B0_AGC[CB_VT3253B0_AGC][2] = {
+ {0xF0, 0x00},
+ {0xF1, 0x00},
+ {0xF0, 0x80},
+ {0xF0, 0x01},
+ {0xF1, 0x00},
+ {0xF0, 0x81},
+ {0xF0, 0x02},
+ {0xF1, 0x02},
+ {0xF0, 0x82},
+ {0xF0, 0x03},
+ {0xF1, 0x04},
+ {0xF0, 0x83},
+ {0xF0, 0x03},
+ {0xF1, 0x04},
+ {0xF0, 0x84},
+ {0xF0, 0x04},
+ {0xF1, 0x06},
+ {0xF0, 0x85},
+ {0xF0, 0x05},
+ {0xF1, 0x06},
+ {0xF0, 0x86},
+ {0xF0, 0x06},
+ {0xF1, 0x06},
+ {0xF0, 0x87},
+ {0xF0, 0x07},
+ {0xF1, 0x08},
+ {0xF0, 0x88},
+ {0xF0, 0x08},
+ {0xF1, 0x08},
+ {0xF0, 0x89},
+ {0xF0, 0x09},
+ {0xF1, 0x0A},
+ {0xF0, 0x8A},
+ {0xF0, 0x0A},
+ {0xF1, 0x0A},
+ {0xF0, 0x8B},
+ {0xF0, 0x0B},
+ {0xF1, 0x0C},
+ {0xF0, 0x8C},
+ {0xF0, 0x0C},
+ {0xF1, 0x0C},
+ {0xF0, 0x8D},
+ {0xF0, 0x0D},
+ {0xF1, 0x0E},
+ {0xF0, 0x8E},
+ {0xF0, 0x0E},
+ {0xF1, 0x0E},
+ {0xF0, 0x8F},
+ {0xF0, 0x0F},
+ {0xF1, 0x10},
+ {0xF0, 0x90},
+ {0xF0, 0x10},
+ {0xF1, 0x10},
+ {0xF0, 0x91},
+ {0xF0, 0x11},
+ {0xF1, 0x12},
+ {0xF0, 0x92},
+ {0xF0, 0x12},
+ {0xF1, 0x12},
+ {0xF0, 0x93},
+ {0xF0, 0x13},
+ {0xF1, 0x14},
+ {0xF0, 0x94},
+ {0xF0, 0x14},
+ {0xF1, 0x14},
+ {0xF0, 0x95},
+ {0xF0, 0x15},
+ {0xF1, 0x16},
+ {0xF0, 0x96},
+ {0xF0, 0x16},
+ {0xF1, 0x16},
+ {0xF0, 0x97},
+ {0xF0, 0x17},
+ {0xF1, 0x18},
+ {0xF0, 0x98},
+ {0xF0, 0x18},
+ {0xF1, 0x18},
+ {0xF0, 0x99},
+ {0xF0, 0x19},
+ {0xF1, 0x1A},
+ {0xF0, 0x9A},
+ {0xF0, 0x1A},
+ {0xF1, 0x1A},
+ {0xF0, 0x9B},
+ {0xF0, 0x1B},
+ {0xF1, 0x1C},
+ {0xF0, 0x9C},
+ {0xF0, 0x1C},
+ {0xF1, 0x1C},
+ {0xF0, 0x9D},
+ {0xF0, 0x1D},
+ {0xF1, 0x1E},
+ {0xF0, 0x9E},
+ {0xF0, 0x1E},
+ {0xF1, 0x1E},
+ {0xF0, 0x9F},
+ {0xF0, 0x1F},
+ {0xF1, 0x20},
+ {0xF0, 0xA0},
+ {0xF0, 0x20},
+ {0xF1, 0x20},
+ {0xF0, 0xA1},
+ {0xF0, 0x21},
+ {0xF1, 0x22},
+ {0xF0, 0xA2},
+ {0xF0, 0x22},
+ {0xF1, 0x22},
+ {0xF0, 0xA3},
+ {0xF0, 0x23},
+ {0xF1, 0x24},
+ {0xF0, 0xA4},
+ {0xF0, 0x24},
+ {0xF1, 0x24},
+ {0xF0, 0xA5},
+ {0xF0, 0x25},
+ {0xF1, 0x26},
+ {0xF0, 0xA6},
+ {0xF0, 0x26},
+ {0xF1, 0x26},
+ {0xF0, 0xA7},
+ {0xF0, 0x27},
+ {0xF1, 0x28},
+ {0xF0, 0xA8},
+ {0xF0, 0x28},
+ {0xF1, 0x28},
+ {0xF0, 0xA9},
+ {0xF0, 0x29},
+ {0xF1, 0x2A},
+ {0xF0, 0xAA},
+ {0xF0, 0x2A},
+ {0xF1, 0x2A},
+ {0xF0, 0xAB},
+ {0xF0, 0x2B},
+ {0xF1, 0x2C},
+ {0xF0, 0xAC},
+ {0xF0, 0x2C},
+ {0xF1, 0x2C},
+ {0xF0, 0xAD},
+ {0xF0, 0x2D},
+ {0xF1, 0x2E},
+ {0xF0, 0xAE},
+ {0xF0, 0x2E},
+ {0xF1, 0x2E},
+ {0xF0, 0xAF},
+ {0xF0, 0x2F},
+ {0xF1, 0x30},
+ {0xF0, 0xB0},
+ {0xF0, 0x30},
+ {0xF1, 0x30},
+ {0xF0, 0xB1},
+ {0xF0, 0x31},
+ {0xF1, 0x32},
+ {0xF0, 0xB2},
+ {0xF0, 0x32},
+ {0xF1, 0x32},
+ {0xF0, 0xB3},
+ {0xF0, 0x33},
+ {0xF1, 0x34},
+ {0xF0, 0xB4},
+ {0xF0, 0x34},
+ {0xF1, 0x34},
+ {0xF0, 0xB5},
+ {0xF0, 0x35},
+ {0xF1, 0x36},
+ {0xF0, 0xB6},
+ {0xF0, 0x36},
+ {0xF1, 0x36},
+ {0xF0, 0xB7},
+ {0xF0, 0x37},
+ {0xF1, 0x38},
+ {0xF0, 0xB8},
+ {0xF0, 0x38},
+ {0xF1, 0x38},
+ {0xF0, 0xB9},
+ {0xF0, 0x39},
+ {0xF1, 0x3A},
+ {0xF0, 0xBA},
+ {0xF0, 0x3A},
+ {0xF1, 0x3A},
+ {0xF0, 0xBB},
+ {0xF0, 0x3B},
+ {0xF1, 0x3C},
+ {0xF0, 0xBC},
+ {0xF0, 0x3C},
+ {0xF1, 0x3C},
+ {0xF0, 0xBD},
+ {0xF0, 0x3D},
+ {0xF1, 0x3E},
+ {0xF0, 0xBE},
+ {0xF0, 0x3E},
+ {0xF1, 0x3E},
+ {0xF0, 0xBF},
+ {0xF0, 0x00},
+};
+
+const WORD awcFrameTime[MAX_RATE] =
+{10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
+
+
+/*--------------------- Static Functions --------------------------*/
+
+static
+ULONG
+s_ulGetRatio(PSDevice pDevice);
+
+static
+VOID
+s_vChangeAntenna(
+ IN PSDevice pDevice
+ );
+
+static
+VOID
+s_vChangeAntenna (
+ IN PSDevice pDevice
+ )
+{
+
+#ifdef PLICE_DEBUG
+ //printk("Enter s_vChangeAntenna:original RxMode is %d,TxMode is %d\n",pDevice->byRxAntennaMode,pDevice->byTxAntennaMode);
+#endif
+ if ( pDevice->dwRxAntennaSel == 0) {
+ pDevice->dwRxAntennaSel=1;
+ if (pDevice->bTxRxAntInv == TRUE)
+ BBvSetRxAntennaMode(pDevice->PortOffset, ANT_A);
+ else
+ BBvSetRxAntennaMode(pDevice->PortOffset, ANT_B);
+ } else {
+ pDevice->dwRxAntennaSel=0;
+ if (pDevice->bTxRxAntInv == TRUE)
+ BBvSetRxAntennaMode(pDevice->PortOffset, ANT_B);
+ else
+ BBvSetRxAntennaMode(pDevice->PortOffset, ANT_A);
+ }
+ if ( pDevice->dwTxAntennaSel == 0) {
+ pDevice->dwTxAntennaSel=1;
+ BBvSetTxAntennaMode(pDevice->PortOffset, ANT_B);
+ } else {
+ pDevice->dwTxAntennaSel=0;
+ BBvSetTxAntennaMode(pDevice->PortOffset, ANT_A);
+ }
+}
+
+
+/*--------------------- Export Variables --------------------------*/
+/*
+ * Description: Calculate data frame transmitting time
+ *
+ * Parameters:
+ * In:
+ * byPreambleType - Preamble Type
+ * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
+ * cbFrameLength - Baseband Type
+ * wRate - Tx Rate
+ * Out:
+ *
+ * Return Value: FrameTime
+ *
+ */
+UINT
+BBuGetFrameTime (
+ IN BYTE byPreambleType,
+ IN BYTE byPktType,
+ IN UINT cbFrameLength,
+ IN WORD wRate
+ )
+{
+ UINT uFrameTime;
+ UINT uPreamble;
+ UINT uTmp;
+ UINT uRateIdx = (UINT)wRate;
+ UINT uRate = 0;
+
+
+ if (uRateIdx > RATE_54M) {
+ return 0;
+ }
+
+ uRate = (UINT)awcFrameTime[uRateIdx];
+
+ if (uRateIdx <= 3) { //CCK mode
+
+ if (byPreambleType == 1) {//Short
+ uPreamble = 96;
+ } else {
+ uPreamble = 192;
+ }
+ uFrameTime = (cbFrameLength * 80) / uRate; //?????
+ uTmp = (uFrameTime * uRate) / 80;
+ if (cbFrameLength != uTmp) {
+ uFrameTime ++;
+ }
+
+ return (uPreamble + uFrameTime);
+ }
+ else {
+ uFrameTime = (cbFrameLength * 8 + 22) / uRate; //????????
+ uTmp = ((uFrameTime * uRate) - 22) / 8;
+ if(cbFrameLength != uTmp) {
+ uFrameTime ++;
+ }
+ uFrameTime = uFrameTime * 4; //???????
+ if(byPktType != PK_TYPE_11A) {
+ uFrameTime += 6; //??????
+ }
+ return (20 + uFrameTime); //??????
+ }
+}
+
+/*
+ * Description: Caculate Length, Service, and Signal fields of Phy for Tx
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * cbFrameLength - Tx Frame Length
+ * wRate - Tx Rate
+ * Out:
+ * pwPhyLen - pointer to Phy Length field
+ * pbyPhySrv - pointer to Phy Service field
+ * pbyPhySgn - pointer to Phy Signal field
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvCaculateParameter (
+ IN PSDevice pDevice,
+ IN UINT cbFrameLength,
+ IN WORD wRate,
+ IN BYTE byPacketType,
+ OUT PWORD pwPhyLen,
+ OUT PBYTE pbyPhySrv,
+ OUT PBYTE pbyPhySgn
+ )
+{
+ UINT cbBitCount;
+ UINT cbUsCount = 0;
+ UINT cbTmp;
+ BOOL bExtBit;
+ BYTE byPreambleType = pDevice->byPreambleType;
+ BOOL bCCK = pDevice->bCCK;
+
+ cbBitCount = cbFrameLength * 8;
+ bExtBit = FALSE;
+
+ switch (wRate) {
+ case RATE_1M :
+ cbUsCount = cbBitCount;
+ *pbyPhySgn = 0x00;
+ break;
+
+ case RATE_2M :
+ cbUsCount = cbBitCount / 2;
+ if (byPreambleType == 1)
+ *pbyPhySgn = 0x09;
+ else // long preamble
+ *pbyPhySgn = 0x01;
+ break;
+
+ case RATE_5M :
+ if (bCCK == FALSE)
+ cbBitCount ++;
+ cbUsCount = (cbBitCount * 10) / 55;
+ cbTmp = (cbUsCount * 55) / 10;
+ if (cbTmp != cbBitCount)
+ cbUsCount ++;
+ if (byPreambleType == 1)
+ *pbyPhySgn = 0x0a;
+ else // long preamble
+ *pbyPhySgn = 0x02;
+ break;
+
+ case RATE_11M :
+
+ if (bCCK == FALSE)
+ cbBitCount ++;
+ cbUsCount = cbBitCount / 11;
+ cbTmp = cbUsCount * 11;
+ if (cbTmp != cbBitCount) {
+ cbUsCount ++;
+ if ((cbBitCount - cbTmp) <= 3)
+ bExtBit = TRUE;
+ }
+ if (byPreambleType == 1)
+ *pbyPhySgn = 0x0b;
+ else // long preamble
+ *pbyPhySgn = 0x03;
+ break;
+
+ case RATE_6M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9B; //1001 1011
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8B; //1000 1011
+ }
+ break;
+
+ case RATE_9M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9F; //1001 1111
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8F; //1000 1111
+ }
+ break;
+
+ case RATE_12M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9A; //1001 1010
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8A; //1000 1010
+ }
+ break;
+
+ case RATE_18M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9E; //1001 1110
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8E; //1000 1110
+ }
+ break;
+
+ case RATE_24M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x99; //1001 1001
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x89; //1000 1001
+ }
+ break;
+
+ case RATE_36M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9D; //1001 1101
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8D; //1000 1101
+ }
+ break;
+
+ case RATE_48M :
+ if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x98; //1001 1000
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x88; //1000 1000
+ }
+ break;
+
+ case RATE_54M :
+ if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9C; //1001 1100
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8C; //1000 1100
+ }
+ break;
+
+ default :
+ if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
+ *pbyPhySgn = 0x9C; //1001 1100
+ }
+ else {//11g, 2.4GHZ
+ *pbyPhySgn = 0x8C; //1000 1100
+ }
+ break;
+ }
+
+ if (byPacketType == PK_TYPE_11B) {
+ *pbyPhySrv = 0x00;
+ if (bExtBit)
+ *pbyPhySrv = *pbyPhySrv | 0x80;
+ *pwPhyLen = (WORD)cbUsCount;
+ }
+ else {
+ *pbyPhySrv = 0x00;
+ *pwPhyLen = (WORD)cbFrameLength;
+ }
+}
+
+/*
+ * Description: Read a byte from BASEBAND, by embeded programming
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byBBAddr - address of register in Baseband
+ * Out:
+ * pbyData - data read
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL BBbReadEmbeded (DWORD_PTR dwIoBase, BYTE byBBAddr, PBYTE pbyData)
+{
+ WORD ww;
+ BYTE byValue;
+
+ // BB reg offset
+ VNSvOutPortB(dwIoBase + MAC_REG_BBREGADR, byBBAddr);
+
+ // turn on REGR
+ MACvRegBitsOn(dwIoBase, MAC_REG_BBREGCTL, BBREGCTL_REGR);
+ // W_MAX_TIMEOUT is the timeout period
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_BBREGCTL, &byValue);
+ if (BITbIsBitOn(byValue, BBREGCTL_DONE))
+ break;
+ }
+
+ // get BB data
+ VNSvInPortB(dwIoBase + MAC_REG_BBREGDATA, pbyData);
+
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x30);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x30)\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*
+ * Description: Write a Byte to BASEBAND, by embeded programming
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byBBAddr - address of register in Baseband
+ * byData - data to write
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL BBbWriteEmbeded (DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byData)
+{
+ WORD ww;
+ BYTE byValue;
+
+ // BB reg offset
+ VNSvOutPortB(dwIoBase + MAC_REG_BBREGADR, byBBAddr);
+ // set BB data
+ VNSvOutPortB(dwIoBase + MAC_REG_BBREGDATA, byData);
+
+ // turn on BBREGCTL_REGW
+ MACvRegBitsOn(dwIoBase, MAC_REG_BBREGCTL, BBREGCTL_REGW);
+ // W_MAX_TIMEOUT is the timeout period
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_BBREGCTL, &byValue);
+ if (BITbIsBitOn(byValue, BBREGCTL_DONE))
+ break;
+ }
+
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x31);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x31)\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*
+ * Description: Test if all bits are set for the Baseband register
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byBBAddr - address of register in Baseband
+ * byTestBits - TestBits
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all TestBits are set; FALSE otherwise.
+ *
+ */
+BOOL BBbIsRegBitsOn (DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byTestBits)
+{
+ BYTE byOrgData;
+
+ BBbReadEmbeded(dwIoBase, byBBAddr, &byOrgData);
+ return BITbIsAllBitsOn(byOrgData, byTestBits);
+}
+
+
+/*
+ * Description: Test if all bits are clear for the Baseband register
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byBBAddr - address of register in Baseband
+ * byTestBits - TestBits
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all TestBits are clear; FALSE otherwise.
+ *
+ */
+BOOL BBbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byTestBits)
+{
+ BYTE byOrgData;
+
+ BBbReadEmbeded(dwIoBase, byBBAddr, &byOrgData);
+ return BITbIsAllBitsOff(byOrgData, byTestBits);
+}
+
+/*
+ * Description: VIA VT3253 Baseband chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byRevId - Revision ID
+ * byRFType - RF type
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+BOOL BBbVT3253Init (PSDevice pDevice)
+{
+ BOOL bResult = TRUE;
+ int ii;
+ DWORD_PTR dwIoBase = pDevice->PortOffset;
+ BYTE byRFType = pDevice->byRFType;
+ BYTE byLocalID = pDevice->byLocalID;
+
+ if (byRFType == RF_RFMD2959) {
+ if (byLocalID <= REV_ID_VT3253_A1) {
+ for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253InitTab_RFMD[ii][0],byVT3253InitTab_RFMD[ii][1]);
+ }
+ } else {
+ for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_RFMD[ii][0],byVT3253B0_RFMD[ii][1]);
+ }
+ for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AGC4_RFMD2959[ii][0],byVT3253B0_AGC4_RFMD2959[ii][1]);
+ }
+ VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23);
+ MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0);
+ }
+ pDevice->abyBBVGA[0] = 0x18;
+ pDevice->abyBBVGA[1] = 0x0A;
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ pDevice->ldBmThreshold[0] = -70;
+ pDevice->ldBmThreshold[1] = -50;
+ pDevice->ldBmThreshold[2] = 0;
+ pDevice->ldBmThreshold[3] = 0;
+ } else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S) ) {
+ for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AIROHA2230[ii][0],byVT3253B0_AIROHA2230[ii][1]);
+ }
+ for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AGC[ii][0],byVT3253B0_AGC[ii][1]);
+ }
+ pDevice->abyBBVGA[0] = 0x1C;
+ pDevice->abyBBVGA[1] = 0x10;
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ pDevice->ldBmThreshold[0] = -70;
+ pDevice->ldBmThreshold[1] = -48;
+ pDevice->ldBmThreshold[2] = 0;
+ pDevice->ldBmThreshold[3] = 0;
+ } else if (byRFType == RF_UW2451) {
+ for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_UW2451[ii][0],byVT3253B0_UW2451[ii][1]);
+ }
+ for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AGC[ii][0],byVT3253B0_AGC[ii][1]);
+ }
+ VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23);
+ MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0);
+
+ pDevice->abyBBVGA[0] = 0x14;
+ pDevice->abyBBVGA[1] = 0x0A;
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ pDevice->ldBmThreshold[0] = -60;
+ pDevice->ldBmThreshold[1] = -50;
+ pDevice->ldBmThreshold[2] = 0;
+ pDevice->ldBmThreshold[3] = 0;
+ } else if (byRFType == RF_UW2452) {
+ for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_UW2451[ii][0],byVT3253B0_UW2451[ii][1]);
+ }
+ // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
+ //bResult &= BBbWriteEmbeded(dwIoBase,0x09,0x41);
+ // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
+ //bResult &= BBbWriteEmbeded(dwIoBase,0x0a,0x28);
+ // Select VC1/VC2, CR215 = 0x02->0x06
+ bResult &= BBbWriteEmbeded(dwIoBase,0xd7,0x06);
+
+ //{{RobertYu:20050125, request by Jack
+ bResult &= BBbWriteEmbeded(dwIoBase,0x90,0x20);
+ bResult &= BBbWriteEmbeded(dwIoBase,0x97,0xeb);
+ //}}
+
+ //{{RobertYu:20050221, request by Jack
+ bResult &= BBbWriteEmbeded(dwIoBase,0xa6,0x00);
+ bResult &= BBbWriteEmbeded(dwIoBase,0xa8,0x30);
+ //}}
+ bResult &= BBbWriteEmbeded(dwIoBase,0xb0,0x58);
+
+ for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AGC[ii][0],byVT3253B0_AGC[ii][1]);
+ }
+ //VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); // RobertYu: 20050104, 20050131 disable PA_Delay
+ //MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); // RobertYu: 20050104, 20050131 disable PA_Delay
+
+ pDevice->abyBBVGA[0] = 0x14;
+ pDevice->abyBBVGA[1] = 0x0A;
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ pDevice->ldBmThreshold[0] = -60;
+ pDevice->ldBmThreshold[1] = -50;
+ pDevice->ldBmThreshold[2] = 0;
+ pDevice->ldBmThreshold[3] = 0;
+ //}} RobertYu
+
+ } else if (byRFType == RF_VT3226) {
+ for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AIROHA2230[ii][0],byVT3253B0_AIROHA2230[ii][1]);
+ }
+ for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AGC[ii][0],byVT3253B0_AGC[ii][1]);
+ }
+ pDevice->abyBBVGA[0] = 0x1C;
+ pDevice->abyBBVGA[1] = 0x10;
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ pDevice->ldBmThreshold[0] = -70;
+ pDevice->ldBmThreshold[1] = -48;
+ pDevice->ldBmThreshold[2] = 0;
+ pDevice->ldBmThreshold[3] = 0;
+ // Fix VT3226 DFC system timing issue
+ MACvSetRFLE_LatchBase(dwIoBase);
+ //{{ RobertYu: 20050104
+ } else if (byRFType == RF_AIROHA7230) {
+ for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AIROHA2230[ii][0],byVT3253B0_AIROHA2230[ii][1]);
+ }
+
+ //{{ RobertYu:20050223, request by JerryChung
+ // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
+ //bResult &= BBbWriteEmbeded(dwIoBase,0x09,0x41);
+ // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
+ //bResult &= BBbWriteEmbeded(dwIoBase,0x0a,0x28);
+ // Select VC1/VC2, CR215 = 0x02->0x06
+ bResult &= BBbWriteEmbeded(dwIoBase,0xd7,0x06);
+ //}}
+
+ for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
+ bResult &= BBbWriteEmbeded(dwIoBase,byVT3253B0_AGC[ii][0],byVT3253B0_AGC[ii][1]);
+ }
+ pDevice->abyBBVGA[0] = 0x1C;
+ pDevice->abyBBVGA[1] = 0x10;
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ pDevice->ldBmThreshold[0] = -70;
+ pDevice->ldBmThreshold[1] = -48;
+ pDevice->ldBmThreshold[2] = 0;
+ pDevice->ldBmThreshold[3] = 0;
+ //}} RobertYu
+ } else {
+ // No VGA Table now
+ pDevice->bUpdateBBVGA = FALSE;
+ pDevice->abyBBVGA[0] = 0x1C;
+ }
+
+ if (byLocalID > REV_ID_VT3253_A1) {
+ BBbWriteEmbeded(dwIoBase, 0x04, 0x7F);
+ BBbWriteEmbeded(dwIoBase, 0x0D, 0x01);
+ }
+
+ return bResult;
+}
+
+
+
+/*
+ * Description: Read All Baseband Registers
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * pbyBBRegs - Point to struct that stores Baseband Registers
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID BBvReadAllRegs (DWORD_PTR dwIoBase, PBYTE pbyBBRegs)
+{
+ int ii;
+ BYTE byBase = 1;
+ for (ii = 0; ii < BB_MAX_CONTEXT_SIZE; ii++) {
+ BBbReadEmbeded(dwIoBase, (BYTE)(ii*byBase), pbyBBRegs);
+ pbyBBRegs += byBase;
+ }
+}
+
+/*
+ * Description: Turn on BaseBand Loopback mode
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * bCCK - If CCK is set
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+
+void BBvLoopbackOn (PSDevice pDevice)
+{
+ BYTE byData;
+ DWORD_PTR dwIoBase = pDevice->PortOffset;
+
+ //CR C9 = 0x00
+ BBbReadEmbeded(dwIoBase, 0xC9, &pDevice->byBBCRc9);//CR201
+ BBbWriteEmbeded(dwIoBase, 0xC9, 0);
+ BBbReadEmbeded(dwIoBase, 0x4D, &pDevice->byBBCR4d);//CR77
+ BBbWriteEmbeded(dwIoBase, 0x4D, 0x90);
+
+ //CR 88 = 0x02(CCK), 0x03(OFDM)
+ BBbReadEmbeded(dwIoBase, 0x88, &pDevice->byBBCR88);//CR136
+
+ if (pDevice->uConnectionRate <= RATE_11M) { //CCK
+ // Enable internal digital loopback: CR33 |= 0000 0001
+ BBbReadEmbeded(dwIoBase, 0x21, &byData);//CR33
+ BBbWriteEmbeded(dwIoBase, 0x21, (BYTE)(byData | 0x01));//CR33
+ // CR154 = 0x00
+ BBbWriteEmbeded(dwIoBase, 0x9A, 0); //CR154
+
+ BBbWriteEmbeded(dwIoBase, 0x88, 0x02);//CR239
+ }
+ else { //OFDM
+ // Enable internal digital loopback:CR154 |= 0000 0001
+ BBbReadEmbeded(dwIoBase, 0x9A, &byData);//CR154
+ BBbWriteEmbeded(dwIoBase, 0x9A, (BYTE)(byData | 0x01));//CR154
+ // CR33 = 0x00
+ BBbWriteEmbeded(dwIoBase, 0x21, 0); //CR33
+
+ BBbWriteEmbeded(dwIoBase, 0x88, 0x03);//CR239
+ }
+
+ //CR14 = 0x00
+ BBbWriteEmbeded(dwIoBase, 0x0E, 0);//CR14
+
+ // Disable TX_IQUN
+ BBbReadEmbeded(pDevice->PortOffset, 0x09, &pDevice->byBBCR09);
+ BBbWriteEmbeded(pDevice->PortOffset, 0x09, (BYTE)(pDevice->byBBCR09 & 0xDE));
+}
+
+/*
+ * Description: Turn off BaseBand Loopback mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void BBvLoopbackOff (PSDevice pDevice)
+{
+ BYTE byData;
+ DWORD_PTR dwIoBase = pDevice->PortOffset;
+
+ BBbWriteEmbeded(dwIoBase, 0xC9, pDevice->byBBCRc9);//CR201
+ BBbWriteEmbeded(dwIoBase, 0x88, pDevice->byBBCR88);//CR136
+ BBbWriteEmbeded(dwIoBase, 0x09, pDevice->byBBCR09);//CR136
+ BBbWriteEmbeded(dwIoBase, 0x4D, pDevice->byBBCR4d);//CR77
+
+ if (pDevice->uConnectionRate <= RATE_11M) { // CCK
+ // Set the CR33 Bit2 to disable internal Loopback.
+ BBbReadEmbeded(dwIoBase, 0x21, &byData);//CR33
+ BBbWriteEmbeded(dwIoBase, 0x21, (BYTE)(byData & 0xFE));//CR33
+ }
+ else { // OFDM
+ BBbReadEmbeded(dwIoBase, 0x9A, &byData);//CR154
+ BBbWriteEmbeded(dwIoBase, 0x9A, (BYTE)(byData & 0xFE));//CR154
+ }
+ BBbReadEmbeded(dwIoBase, 0x0E, &byData);//CR14
+ BBbWriteEmbeded(dwIoBase, 0x0E, (BYTE)(byData | 0x80));//CR14
+
+}
+
+
+
+/*
+ * Description: Set ShortSlotTime mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSetShortSlotTime (PSDevice pDevice)
+{
+ BYTE byBBRxConf=0;
+ BYTE byBBVGA=0;
+
+ BBbReadEmbeded(pDevice->PortOffset, 0x0A, &byBBRxConf);//CR10
+
+ if (pDevice->bShortSlotTime) {
+ byBBRxConf &= 0xDF;//1101 1111
+ } else {
+ byBBRxConf |= 0x20;//0010 0000
+ }
+
+ // patch for 3253B0 Baseband with Cardbus module
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byBBVGA);
+ if (byBBVGA == pDevice->abyBBVGA[0]) {
+ byBBRxConf |= 0x20;//0010 0000
+ }
+
+ BBbWriteEmbeded(pDevice->PortOffset, 0x0A, byBBRxConf);//CR10
+
+}
+
+VOID BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData)
+{
+ BYTE byBBRxConf=0;
+
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, byData);
+
+ BBbReadEmbeded(pDevice->PortOffset, 0x0A, &byBBRxConf);//CR10
+ // patch for 3253B0 Baseband with Cardbus module
+ if (byData == pDevice->abyBBVGA[0]) {
+ byBBRxConf |= 0x20;//0010 0000
+ } else if (pDevice->bShortSlotTime) {
+ byBBRxConf &= 0xDF;//1101 1111
+ } else {
+ byBBRxConf |= 0x20;//0010 0000
+ }
+ pDevice->byBBVGACurrent = byData;
+ BBbWriteEmbeded(pDevice->PortOffset, 0x0A, byBBRxConf);//CR10
+}
+
+
+/*
+ * Description: Baseband SoftwareReset
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSoftwareReset (DWORD_PTR dwIoBase)
+{
+ BBbWriteEmbeded(dwIoBase, 0x50, 0x40);
+ BBbWriteEmbeded(dwIoBase, 0x50, 0);
+ BBbWriteEmbeded(dwIoBase, 0x9C, 0x01);
+ BBbWriteEmbeded(dwIoBase, 0x9C, 0);
+}
+
+/*
+ * Description: Baseband Power Save Mode ON
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvPowerSaveModeON (DWORD_PTR dwIoBase)
+{
+ BYTE byOrgData;
+
+ BBbReadEmbeded(dwIoBase, 0x0D, &byOrgData);
+ byOrgData |= BIT0;
+ BBbWriteEmbeded(dwIoBase, 0x0D, byOrgData);
+}
+
+/*
+ * Description: Baseband Power Save Mode OFF
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvPowerSaveModeOFF (DWORD_PTR dwIoBase)
+{
+ BYTE byOrgData;
+
+ BBbReadEmbeded(dwIoBase, 0x0D, &byOrgData);
+ byOrgData &= ~(BIT0);
+ BBbWriteEmbeded(dwIoBase, 0x0D, byOrgData);
+}
+
+/*
+ * Description: Set Tx Antenna mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * byAntennaMode - Antenna Mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+VOID
+BBvSetTxAntennaMode (DWORD_PTR dwIoBase, BYTE byAntennaMode)
+{
+ BYTE byBBTxConf;
+
+#ifdef PLICE_DEBUG
+ //printk("Enter BBvSetTxAntennaMode\n");
+#endif
+ BBbReadEmbeded(dwIoBase, 0x09, &byBBTxConf);//CR09
+ if (byAntennaMode == ANT_DIVERSITY) {
+ // bit 1 is diversity
+ byBBTxConf |= 0x02;
+ } else if (byAntennaMode == ANT_A) {
+ // bit 2 is ANTSEL
+ byBBTxConf &= 0xF9; // 1111 1001
+ } else if (byAntennaMode == ANT_B) {
+#ifdef PLICE_DEBUG
+ //printk("BBvSetTxAntennaMode:ANT_B\n");
+#endif
+ byBBTxConf &= 0xFD; // 1111 1101
+ byBBTxConf |= 0x04;
+ }
+ BBbWriteEmbeded(dwIoBase, 0x09, byBBTxConf);//CR09
+}
+
+
+
+
+/*
+ * Description: Set Rx Antenna mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * byAntennaMode - Antenna Mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+VOID
+BBvSetRxAntennaMode (DWORD_PTR dwIoBase, BYTE byAntennaMode)
+{
+ BYTE byBBRxConf;
+
+ BBbReadEmbeded(dwIoBase, 0x0A, &byBBRxConf);//CR10
+ if (byAntennaMode == ANT_DIVERSITY) {
+ byBBRxConf |= 0x01;
+
+ } else if (byAntennaMode == ANT_A) {
+ byBBRxConf &= 0xFC; // 1111 1100
+ } else if (byAntennaMode == ANT_B) {
+ byBBRxConf &= 0xFE; // 1111 1110
+ byBBRxConf |= 0x02;
+ }
+ BBbWriteEmbeded(dwIoBase, 0x0A, byBBRxConf);//CR10
+}
+
+
+/*
+ * Description: BBvSetDeepSleep
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSetDeepSleep (DWORD_PTR dwIoBase, BYTE byLocalID)
+{
+ BBbWriteEmbeded(dwIoBase, 0x0C, 0x17);//CR12
+ BBbWriteEmbeded(dwIoBase, 0x0D, 0xB9);//CR13
+}
+
+VOID
+BBvExitDeepSleep (DWORD_PTR dwIoBase, BYTE byLocalID)
+{
+ BBbWriteEmbeded(dwIoBase, 0x0C, 0x00);//CR12
+ BBbWriteEmbeded(dwIoBase, 0x0D, 0x01);//CR13
+}
+
+
+
+static
+ULONG
+s_ulGetRatio (PSDevice pDevice)
+{
+ULONG ulRatio = 0;
+ULONG ulMaxPacket;
+ULONG ulPacketNum;
+
+ //This is a thousand-ratio
+ ulMaxPacket = pDevice->uNumSQ3[RATE_54M];
+ if ( pDevice->uNumSQ3[RATE_54M] != 0 ) {
+ ulPacketNum = pDevice->uNumSQ3[RATE_54M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_54M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_54M;
+ }
+ if ( pDevice->uNumSQ3[RATE_48M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_48M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_48M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_48M];
+ }
+ if ( pDevice->uNumSQ3[RATE_36M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
+ pDevice->uNumSQ3[RATE_36M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_36M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_36M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_36M];
+ }
+ if ( pDevice->uNumSQ3[RATE_24M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
+ pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_24M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_24M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_24M];
+ }
+ if ( pDevice->uNumSQ3[RATE_18M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
+ pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] +
+ pDevice->uNumSQ3[RATE_18M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_18M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_18M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_18M];
+ }
+ if ( pDevice->uNumSQ3[RATE_12M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
+ pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] +
+ pDevice->uNumSQ3[RATE_18M] + pDevice->uNumSQ3[RATE_12M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_12M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_12M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_12M];
+ }
+ if ( pDevice->uNumSQ3[RATE_11M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
+ pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] -
+ pDevice->uNumSQ3[RATE_6M] - pDevice->uNumSQ3[RATE_9M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_11M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_11M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_11M];
+ }
+ if ( pDevice->uNumSQ3[RATE_9M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
+ pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] -
+ pDevice->uNumSQ3[RATE_6M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_9M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_9M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_9M];
+ }
+ if ( pDevice->uNumSQ3[RATE_6M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
+ pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_6M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_6M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_6M];
+ }
+ if ( pDevice->uNumSQ3[RATE_5M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
+ pDevice->uNumSQ3[RATE_2M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_5M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_55M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_5M];
+ }
+ if ( pDevice->uNumSQ3[RATE_2M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_2M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_2M;
+ ulMaxPacket = pDevice->uNumSQ3[RATE_2M];
+ }
+ if ( pDevice->uNumSQ3[RATE_1M] > ulMaxPacket ) {
+ ulPacketNum = pDevice->uDiversityCnt;
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ //ulRatio = (pDevice->uNumSQ3[RATE_1M] * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_1M;
+ }
+
+ return ulRatio;
+}
+
+
+VOID
+BBvClearAntDivSQ3Value (PSDevice pDevice)
+{
+ UINT ii;
+
+ pDevice->uDiversityCnt = 0;
+ for (ii = 0; ii < MAX_RATE; ii++) {
+ pDevice->uNumSQ3[ii] = 0;
+ }
+}
+
+
+/*
+ * Description: Antenna Diversity
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * byRSR - RSR from received packet
+ * bySQ3 - SQ3 value from received packet
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+VOID
+BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3)
+{
+
+ if ((byRxRate >= MAX_RATE) || (pDevice->wAntDiversityMaxRate >= MAX_RATE)) {
+ return;
+ }
+ pDevice->uDiversityCnt++;
+ // DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
+
+ pDevice->uNumSQ3[byRxRate]++;
+
+ if (pDevice->byAntennaState == 0) {
+
+ if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",
+ (int)pDevice->ulDiversityNValue, (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate]);
+
+ if (pDevice->uNumSQ3[pDevice->wAntDiversityMaxRate] < pDevice->uDiversityCnt/2) {
+
+ pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, rate = [%08x]\n", (int)pDevice->ulRatio_State0);
+
+ if ( pDevice->byTMax == 0 )
+ return;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1.[%08x], uNumSQ3[%d]=%d, %d\n",
+ (int)pDevice->ulRatio_State0, (int)pDevice->wAntDiversityMaxRate,
+ (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], (int)pDevice->uDiversityCnt);
+#ifdef PLICE_DEBUG
+ //printk("BBvAntennaDiversity1:call s_vChangeAntenna\n");
+#endif
+ s_vChangeAntenna(pDevice);
+ pDevice->byAntennaState = 1;
+ del_timer(&pDevice->TimerSQ3Tmax3);
+ del_timer(&pDevice->TimerSQ3Tmax2);
+ pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax1);
+
+ } else {
+
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax3);
+ }
+ BBvClearAntDivSQ3Value(pDevice);
+
+ }
+ } else { //byAntennaState == 1
+
+ if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
+
+ del_timer(&pDevice->TimerSQ3Tmax1);
+
+ pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RX:SQ3_State1, rate0 = %08x,rate1 = %08x\n",
+ (int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
+
+ if (pDevice->ulRatio_State1 < pDevice->ulRatio_State0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2.[%08x][%08x], uNumSQ3[%d]=%d, %d\n",
+ (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1,
+ (int)pDevice->wAntDiversityMaxRate,
+ (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], (int)pDevice->uDiversityCnt);
+#ifdef PLICE_DEBUG
+ //printk("BBvAntennaDiversity2:call s_vChangeAntenna\n");
+#endif
+ s_vChangeAntenna(pDevice);
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
+ pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax3);
+ add_timer(&pDevice->TimerSQ3Tmax2);
+ }
+ pDevice->byAntennaState = 0;
+ BBvClearAntDivSQ3Value(pDevice);
+ }
+ } //byAntennaState
+}
+
+/*+
+ *
+ * Description:
+ * Timer for SQ3 antenna diversity
+ *
+ * Parameters:
+ * In:
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+
+VOID
+TimerSQ3CallBack (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
+
+
+ spin_lock_irq(&pDevice->lock);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"3.[%08x][%08x], %d\n",(int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1, (int)pDevice->uDiversityCnt);
+#ifdef PLICE_DEBUG
+ //printk("TimerSQ3CallBack1:call s_vChangeAntenna\n");
+#endif
+
+ s_vChangeAntenna(pDevice);
+ pDevice->byAntennaState = 0;
+ BBvClearAntDivSQ3Value(pDevice);
+
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
+ pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax3);
+ add_timer(&pDevice->TimerSQ3Tmax2);
+
+ spin_unlock_irq(&pDevice->lock);
+
+ return;
+}
+
+
+/*+
+ *
+ * Description:
+ * Timer for SQ3 antenna diversity
+ *
+ * Parameters:
+ * In:
+ * pvSysSpec1
+ * hDeviceContext - Pointer to the adapter
+ * pvSysSpec2
+ * pvSysSpec3
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+
+VOID
+TimerState1CallBack (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerState1CallBack...");
+
+ spin_lock_irq(&pDevice->lock);
+ if (pDevice->uDiversityCnt < pDevice->ulDiversityMValue/100) {
+#ifdef PLICE_DEBUG
+ //printk("TimerSQ3CallBack2:call s_vChangeAntenna\n");
+#endif
+
+ s_vChangeAntenna(pDevice);
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
+ pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax3);
+ add_timer(&pDevice->TimerSQ3Tmax2);
+ } else {
+ pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",
+ (int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
+
+ if ( pDevice->ulRatio_State1 < pDevice->ulRatio_State0 ) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2.[%08x][%08x], uNumSQ3[%d]=%d, %d\n",
+ (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1,
+ (int)pDevice->wAntDiversityMaxRate,
+ (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], (int)pDevice->uDiversityCnt);
+#ifdef PLICE_DEBUG
+ //printk("TimerSQ3CallBack3:call s_vChangeAntenna\n");
+#endif
+
+ s_vChangeAntenna(pDevice);
+
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
+ pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax3);
+ add_timer(&pDevice->TimerSQ3Tmax2);
+ }
+ }
+ pDevice->byAntennaState = 0;
+ BBvClearAntDivSQ3Value(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+
+ return;
+}
+
diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h
new file mode 100644
index 000000000000..09cf4f961ac2
--- /dev/null
+++ b/drivers/staging/vt6655/baseband.h
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: baseband.h
+ *
+ * Purpose: Implement functions to access baseband
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jun. 5, 2002
+ *
+ */
+
+
+#ifndef __BASEBAND_H__
+#define __BASEBAND_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+//
+// Registers in the BASEBAND
+//
+#define BB_MAX_CONTEXT_SIZE 256
+
+
+//
+// Baseband RF pair definition in eeprom (Bits 6..0)
+//
+
+/*
+#define RATE_1M 0
+#define RATE_2M 1
+#define RATE_5M 2
+#define RATE_11M 3
+#define RATE_6M 4
+#define RATE_9M 5
+#define RATE_12M 6
+#define RATE_18M 7
+#define RATE_24M 8
+#define RATE_36M 9
+#define RATE_48M 10
+#define RATE_54M 11
+#define RATE_AUTO 12
+#define MAX_RATE 12
+
+
+//0:11A 1:11B 2:11G
+#define BB_TYPE_11A 0
+#define BB_TYPE_11B 1
+#define BB_TYPE_11G 2
+
+//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
+#define PK_TYPE_11A 0
+#define PK_TYPE_11B 1
+#define PK_TYPE_11GB 2
+#define PK_TYPE_11GA 3
+*/
+
+
+#define PREAMBLE_LONG 0
+#define PREAMBLE_SHORT 1
+
+
+#define F5G 0
+#define F2_4G 1
+
+#define TOP_RATE_54M 0x80000000
+#define TOP_RATE_48M 0x40000000
+#define TOP_RATE_36M 0x20000000
+#define TOP_RATE_24M 0x10000000
+#define TOP_RATE_18M 0x08000000
+#define TOP_RATE_12M 0x04000000
+#define TOP_RATE_11M 0x02000000
+#define TOP_RATE_9M 0x01000000
+#define TOP_RATE_6M 0x00800000
+#define TOP_RATE_55M 0x00400000
+#define TOP_RATE_2M 0x00200000
+#define TOP_RATE_1M 0x00100000
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+
+
+#define BBvClearFOE(dwIoBase) \
+{ \
+ BBbWriteEmbeded(dwIoBase, 0xB1, 0); \
+}
+
+#define BBvSetFOE(dwIoBase) \
+{ \
+ BBbWriteEmbeded(dwIoBase, 0xB1, 0x0C); \
+}
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+UINT
+BBuGetFrameTime(
+ IN BYTE byPreambleType,
+ IN BYTE byPktType,
+ IN UINT cbFrameLength,
+ IN WORD wRate
+ );
+
+VOID
+BBvCaculateParameter (
+ IN PSDevice pDevice,
+ IN UINT cbFrameLength,
+ IN WORD wRate,
+ IN BYTE byPacketType,
+ OUT PWORD pwPhyLen,
+ OUT PBYTE pbyPhySrv,
+ OUT PBYTE pbyPhySgn
+ );
+
+BOOL BBbReadEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, PBYTE pbyData);
+BOOL BBbWriteEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byData);
+
+VOID BBvReadAllRegs(DWORD_PTR dwIoBase, PBYTE pbyBBRegs);
+void BBvLoopbackOn(PSDevice pDevice);
+void BBvLoopbackOff(PSDevice pDevice);
+void BBvSetShortSlotTime(PSDevice pDevice);
+BOOL BBbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byTestBits);
+BOOL BBbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byTestBits);
+VOID BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData);
+
+// VT3253 Baseband
+BOOL BBbVT3253Init(PSDevice pDevice);
+VOID BBvSoftwareReset(DWORD_PTR dwIoBase);
+VOID BBvPowerSaveModeON(DWORD_PTR dwIoBase);
+VOID BBvPowerSaveModeOFF(DWORD_PTR dwIoBase);
+VOID BBvSetTxAntennaMode(DWORD_PTR dwIoBase, BYTE byAntennaMode);
+VOID BBvSetRxAntennaMode(DWORD_PTR dwIoBase, BYTE byAntennaMode);
+VOID BBvSetDeepSleep(DWORD_PTR dwIoBase, BYTE byLocalID);
+VOID BBvExitDeepSleep(DWORD_PTR dwIoBase, BYTE byLocalID);
+
+// timer for antenna diversity
+VOID
+TimerSQ3CallBack(
+ IN HANDLE hDeviceContext
+ );
+VOID
+TimerState1CallBack(
+ IN HANDLE hDeviceContext
+ );
+
+void BBvAntennaDiversity(PSDevice pDevice, BYTE byRxRate, BYTE bySQ3);
+VOID
+BBvClearAntDivSQ3Value (PSDevice pDevice);
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __BASEBAND_H__
+
+
+
diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c
new file mode 100644
index 000000000000..4bac7b694452
--- /dev/null
+++ b/drivers/staging/vt6655/bssdb.c
@@ -0,0 +1,1791 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: bssdb.c
+ *
+ * Purpose: Handles the Basic Service Set & Node Database functions
+ *
+ * Functions:
+ * BSSpSearchBSSList - Search known BSS list for Desire SSID or BSSID
+ * BSSvClearBSSList - Clear BSS List
+ * BSSbInsertToBSSList - Insert a BSS set into known BSS list
+ * BSSbUpdateToBSSList - Update BSS set in known BSS list
+ * BSSDBbIsSTAInNodeDB - Search Node DB table to find the index of matched DstAddr
+ * BSSvCreateOneNode - Allocate an Node for Node DB
+ * BSSvUpdateAPNode - Update AP Node content in Index 0 of KnownNodeDB
+ * BSSvSecondCallBack - One second timer callback function to update Node DB info & AP link status
+ * BSSvUpdateNodeTxCounter - Update Tx attemps, Tx failure counter in Node DB for auto-fall back rate control
+ *
+ * Revision History:
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 17, 2002
+ *
+ */
+
+
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif//chester
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__DESC_H__)
+#include "desc.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__WPA_H__)
+#include "wpa.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__WPA2_H__)
+#include "wpa2.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+//DavidWang
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+
+//#define PLICE_DEBUG
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+
+
+
+const WORD awHWRetry0[5][5] = {
+ {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
+ {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
+ {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
+ {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
+ {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
+ };
+const WORD awHWRetry1[5][5] = {
+ {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
+ {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
+ {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
+ {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
+ {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
+ };
+
+
+
+/*--------------------- Static Functions --------------------------*/
+
+VOID s_vCheckSensitivity(
+ IN HANDLE hDeviceContext
+ );
+
+#ifdef Calcu_LinkQual
+VOID s_uCalculateLinkQual(
+ IN HANDLE hDeviceContext
+ );
+#endif
+
+
+VOID s_vCheckPreEDThreshold(
+ IN HANDLE hDeviceContext
+ );
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Search known BSS list for Desire SSID or BSSID.
+ *
+ * Return Value:
+ * PTR to KnownBSS or NULL
+ *
+-*/
+
+PKnownBSS
+BSSpSearchBSSList(
+ IN HANDLE hDeviceContext,
+ IN PBYTE pbyDesireBSSID,
+ IN PBYTE pbyDesireSSID,
+ IN CARD_PHY_TYPE ePhyType
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PBYTE pbyBSSID = NULL;
+ PWLAN_IE_SSID pSSID = NULL;
+ PKnownBSS pCurrBSS = NULL;
+ PKnownBSS pSelect = NULL;
+BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
+ UINT ii = 0;
+// UINT jj = 0; //DavidWang
+ if (pbyDesireBSSID != NULL) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n",
+ *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2),
+ *(pbyDesireBSSID+3),*(pbyDesireBSSID+4),*(pbyDesireBSSID+5));
+ if ((!IS_BROADCAST_ADDRESS(pbyDesireBSSID)) &&
+ (memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)) {
+ pbyBSSID = pbyDesireBSSID;
+ }
+ }
+ if (pbyDesireSSID != NULL) {
+ if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0) {
+ pSSID = (PWLAN_IE_SSID) pbyDesireSSID;
+ }
+ }
+
+ if (pbyBSSID != NULL) {
+ // match BSSID first
+ for (ii = 0; ii <MAX_BSS_NUM; ii++) {
+ pCurrBSS = &(pMgmt->sBSSList[ii]);
+if(pDevice->bLinkPass==FALSE) pCurrBSS->bSelected = FALSE;
+ if ((pCurrBSS->bActive) &&
+ (pCurrBSS->bSelected == FALSE)) {
+ if (IS_ETH_ADDRESS_EQUAL(pCurrBSS->abyBSSID, pbyBSSID)) {
+ if (pSSID != NULL) {
+ // compare ssid
+ if (MEMEqualMemory(pSSID->abySSID,
+ ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
+ pSSID->len)) {
+ if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
+ ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
+ ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
+ ) {
+ pCurrBSS->bSelected = TRUE;
+ return(pCurrBSS);
+ }
+ }
+ } else {
+ if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
+ ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
+ ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
+ ) {
+ pCurrBSS->bSelected = TRUE;
+ return(pCurrBSS);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // ignore BSSID
+ for (ii = 0; ii <MAX_BSS_NUM; ii++) {
+ pCurrBSS = &(pMgmt->sBSSList[ii]);
+ //2007-0721-01<Add>by MikeLiu
+ pCurrBSS->bSelected = FALSE;
+ if (pCurrBSS->bActive) {
+
+ if (pSSID != NULL) {
+ // matched SSID
+ if (!MEMEqualMemory(pSSID->abySSID,
+ ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
+ pSSID->len) ||
+ (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) {
+ // SSID not match skip this BSS
+ continue;
+ }
+ }
+ if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ||
+ ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo))
+ ) {
+ // Type not match skip this BSS
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSS type mismatch.... Config[%d] BSS[0x%04x]\n", pMgmt->eConfigMode, pCurrBSS->wCapInfo);
+ continue;
+ }
+
+ if (ePhyType != PHY_TYPE_AUTO) {
+ if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) ||
+ ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) {
+ // PhyType not match skip this BSS
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType, pCurrBSS->eNetworkTypeInUse);
+ continue;
+ }
+ }
+/*
+ if (pMgmt->eAuthenMode < WMAC_AUTH_WPA) {
+ if (pCurrBSS->bWPAValid == TRUE) {
+ // WPA AP will reject connection of station without WPA enable.
+ continue;
+ }
+ } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
+ if (pCurrBSS->bWPAValid == FALSE) {
+ // station with WPA enable can't join NonWPA AP.
+ continue;
+ }
+ } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
+ if (pCurrBSS->bWPA2Valid == FALSE) {
+ // station with WPA2 enable can't join NonWPA2 AP.
+ continue;
+ }
+ }
+*/
+ if (pSelect == NULL) {
+ pSelect = pCurrBSS;
+ } else {
+ // compare RSSI, select signal strong one
+ if (pCurrBSS->uRSSI < pSelect->uRSSI) {
+ pSelect = pCurrBSS;
+ }
+ }
+ }
+ }
+ if (pSelect != NULL) {
+ pSelect->bSelected = TRUE;
+/*
+ if (pDevice->bRoaming == FALSE) {
+ // Einsn Add @20070907
+ ZERO_MEMORY(pbyDesireSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ MEMvCopy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ;
+ }*/
+
+ return(pSelect);
+ }
+ }
+ return(NULL);
+
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Clear BSS List
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+BSSvClearBSSList(
+ IN HANDLE hDeviceContext,
+ IN BOOL bKeepCurrBSSID
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT ii;
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (bKeepCurrBSSID) {
+ if (pMgmt->sBSSList[ii].bActive &&
+ IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyCurrBSSID)) {
+ // bKeepCurrBSSID = FALSE;
+ continue;
+ }
+ }
+
+ if ((pMgmt->sBSSList[ii].bActive) && (pMgmt->sBSSList[ii].uClearCount < BSS_CLEAR_COUNT)) {
+ pMgmt->sBSSList[ii].uClearCount ++;
+ continue;
+ }
+
+ pMgmt->sBSSList[ii].bActive = FALSE;
+ memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS));
+ }
+ BSSvClearAnyBSSJoinRecord(pDevice);
+
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * search BSS list by BSSID & SSID if matched
+ *
+ * Return Value:
+ * TRUE if found.
+ *
+-*/
+PKnownBSS
+BSSpAddrIsInBSSList(
+ IN HANDLE hDeviceContext,
+ IN PBYTE abyBSSID,
+ IN PWLAN_IE_SSID pSSID
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PKnownBSS pBSSList = NULL;
+ UINT ii;
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pBSSList = &(pMgmt->sBSSList[ii]);
+ if (pBSSList->bActive) {
+ if (IS_ETH_ADDRESS_EQUAL(pBSSList->abyBSSID, abyBSSID)) {
+// if (pSSID == NULL)
+// return pBSSList;
+ if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len){
+ if (memcmp(pSSID->abySSID,
+ ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
+ pSSID->len) == 0)
+ return pBSSList;
+ }
+ }
+ }
+ }
+
+ return NULL;
+};
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Insert a BSS set into known BSS list
+ *
+ * Return Value:
+ * TRUE if success.
+ *
+-*/
+
+BOOL
+BSSbInsertToBSSList (
+ IN HANDLE hDeviceContext,
+ IN PBYTE abyBSSIDAddr,
+ IN QWORD qwTimestamp,
+ IN WORD wBeaconInterval,
+ IN WORD wCapInfo,
+ IN BYTE byCurrChannel,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pSuppRates,
+ IN PWLAN_IE_SUPP_RATES pExtSuppRates,
+ IN PERPObject psERP,
+ IN PWLAN_IE_RSN pRSN,
+ IN PWLAN_IE_RSN_EXT pRSNWPA,
+ IN PWLAN_IE_COUNTRY pIE_Country,
+ IN PWLAN_IE_QUIET pIE_Quiet,
+ IN UINT uIELength,
+ IN PBYTE pbyIEs,
+ IN HANDLE pRxPacketContext
+ )
+{
+
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
+ PKnownBSS pBSSList = NULL;
+ UINT ii;
+ BOOL bParsingQuiet = FALSE;
+ PWLAN_IE_QUIET pQuiet = NULL;
+
+
+
+ pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]);
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]);
+ if (!pBSSList->bActive)
+ break;
+ }
+
+ if (ii == MAX_BSS_NUM){
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Get free KnowBSS node failed.\n");
+ return FALSE;
+ }
+ // save the BSS info
+ pBSSList->bActive = TRUE;
+ memcpy( pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN);
+ HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp));
+ LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp));
+ pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
+ pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
+ pBSSList->uClearCount = 0;
+
+ if (pSSID->len > WLAN_SSID_MAXLEN)
+ pSSID->len = WLAN_SSID_MAXLEN;
+ memcpy( pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
+
+ pBSSList->uChannel = byCurrChannel;
+
+ if (pSuppRates->len > WLAN_RATES_MAXLEN)
+ pSuppRates->len = WLAN_RATES_MAXLEN;
+ memcpy( pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN);
+
+ if (pExtSuppRates != NULL) {
+ if (pExtSuppRates->len > WLAN_RATES_MAXLEN)
+ pExtSuppRates->len = WLAN_RATES_MAXLEN;
+ memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbInsertToBSSList: pExtSuppRates->len = %d\n", pExtSuppRates->len);
+
+ } else {
+ memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
+ }
+ pBSSList->sERP.byERP = psERP->byERP;
+ pBSSList->sERP.bERPExist = psERP->bERPExist;
+
+ // Check if BSS is 802.11a/b/g
+ if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
+ pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
+ } else {
+ if (pBSSList->sERP.bERPExist == TRUE) {
+ pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
+ } else {
+ pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
+ }
+ }
+
+ pBSSList->byRxRate = pRxPacket->byRxRate;
+ pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
+ pBSSList->uRSSI = pRxPacket->uRSSI;
+ pBSSList->bySQ = pRxPacket->bySQ;
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ // assoc with BSS
+ if (pBSSList == pMgmt->pCurrBSS) {
+ bParsingQuiet = TRUE;
+ }
+ }
+
+ WPA_ClearRSN(pBSSList);
+
+ if (pRSNWPA != NULL) {
+ UINT uLen = pRSNWPA->len + 2;
+
+ if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) {
+ pBSSList->wWPALen = uLen;
+ memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
+ WPA_ParseRSN(pBSSList, pRSNWPA);
+ }
+ }
+
+ WPA2_ClearRSN(pBSSList);
+
+ if (pRSN != NULL) {
+ UINT uLen = pRSN->len + 2;
+ if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) {
+ pBSSList->wRSNLen = uLen;
+ memcpy(pBSSList->byRSNIE, pRSN, uLen);
+ WPA2vParseRSN(pBSSList, pRSN);
+ }
+ }
+
+ if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pBSSList->bWPA2Valid == TRUE)) {
+
+ PSKeyItem pTransmitKey = NULL;
+ BOOL bIs802_1x = FALSE;
+
+ for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii ++) {
+ if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) {
+ bIs802_1x = TRUE;
+ break;
+ }
+ }
+ if ((bIs802_1x == TRUE) && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) &&
+ (MEMEqualMemory(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) {
+
+ bAdd_PMKID_Candidate((HANDLE)pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj);
+
+ if ((pDevice->bLinkPass == TRUE) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE) ||
+ (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == TRUE)) {
+ pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList;
+ pDevice->gsPMKIDCandidate.Version = 1;
+
+ }
+
+ }
+ }
+ }
+
+ if (pDevice->bUpdateBBVGA) {
+ // Moniter if RSSI is too strong.
+ pBSSList->byRSSIStatCnt = 0;
+ RFvRSSITodBm(pDevice, (BYTE)(pRxPacket->uRSSI), &pBSSList->ldBmMAX);
+ pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX;
+ for (ii = 1; ii < RSSI_STAT_COUNT; ii++)
+ pBSSList->ldBmAverage[ii] = 0;
+ }
+
+ if ((pIE_Country != NULL) &&
+ (pMgmt->b11hEnable == TRUE)) {
+ CARDvSetCountryInfo(pMgmt->pAdapter,
+ pBSSList->eNetworkTypeInUse,
+ pIE_Country);
+ }
+
+
+
+ if ((bParsingQuiet == TRUE) && (pIE_Quiet != NULL)) {
+ if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
+ (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
+ // valid EID
+ if (pQuiet == NULL) {
+ pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
+ CARDbSetQuiet( pMgmt->pAdapter,
+ TRUE,
+ pQuiet->byQuietCount,
+ pQuiet->byQuietPeriod,
+ *((PWORD)pQuiet->abyQuietDuration),
+ *((PWORD)pQuiet->abyQuietOffset)
+ );
+ } else {
+ pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
+ CARDbSetQuiet( pMgmt->pAdapter,
+ FALSE,
+ pQuiet->byQuietCount,
+ pQuiet->byQuietPeriod,
+ *((PWORD)pQuiet->abyQuietDuration),
+ *((PWORD)pQuiet->abyQuietOffset)
+ );
+ }
+ }
+ }
+
+ if ((bParsingQuiet == TRUE) &&
+ (pQuiet != NULL)) {
+ CARDbStartQuiet(pMgmt->pAdapter);
+ }
+
+ pBSSList->uIELength = uIELength;
+ if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
+ pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
+ MEMvCopy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
+
+ return TRUE;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Update BSS set in known BSS list
+ *
+ * Return Value:
+ * TRUE if success.
+ *
+-*/
+// TODO: input structure modify
+
+BOOL
+BSSbUpdateToBSSList (
+ IN HANDLE hDeviceContext,
+ IN QWORD qwTimestamp,
+ IN WORD wBeaconInterval,
+ IN WORD wCapInfo,
+ IN BYTE byCurrChannel,
+ IN BOOL bChannelHit,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pSuppRates,
+ IN PWLAN_IE_SUPP_RATES pExtSuppRates,
+ IN PERPObject psERP,
+ IN PWLAN_IE_RSN pRSN,
+ IN PWLAN_IE_RSN_EXT pRSNWPA,
+ IN PWLAN_IE_COUNTRY pIE_Country,
+ IN PWLAN_IE_QUIET pIE_Quiet,
+ IN PKnownBSS pBSSList,
+ IN UINT uIELength,
+ IN PBYTE pbyIEs,
+ IN HANDLE pRxPacketContext
+ )
+{
+ int ii;
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
+ LONG ldBm;
+ BOOL bParsingQuiet = FALSE;
+ PWLAN_IE_QUIET pQuiet = NULL;
+
+
+
+ if (pBSSList == NULL)
+ return FALSE;
+
+ HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp));
+ LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp));
+ pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
+ pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
+ pBSSList->uClearCount = 0;
+ pBSSList->uChannel = byCurrChannel;
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbUpdateToBSSList: pBSSList->uChannel: %d\n", pBSSList->uChannel);
+
+ if (pSSID->len > WLAN_SSID_MAXLEN)
+ pSSID->len = WLAN_SSID_MAXLEN;
+
+ if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0))
+ memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
+ memcpy(pBSSList->abySuppRates, pSuppRates,pSuppRates->len + WLAN_IEHDR_LEN);
+
+ if (pExtSuppRates != NULL) {
+ memcpy(pBSSList->abyExtSuppRates, pExtSuppRates,pExtSuppRates->len + WLAN_IEHDR_LEN);
+ } else {
+ memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
+ }
+ pBSSList->sERP.byERP = psERP->byERP;
+ pBSSList->sERP.bERPExist = psERP->bERPExist;
+
+ // Check if BSS is 802.11a/b/g
+ if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
+ pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
+ } else {
+ if (pBSSList->sERP.bERPExist == TRUE) {
+ pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
+ } else {
+ pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
+ }
+ }
+
+ pBSSList->byRxRate = pRxPacket->byRxRate;
+ pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
+ if(bChannelHit)
+ pBSSList->uRSSI = pRxPacket->uRSSI;
+ pBSSList->bySQ = pRxPacket->bySQ;
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ // assoc with BSS
+ if (pBSSList == pMgmt->pCurrBSS) {
+ bParsingQuiet = TRUE;
+ }
+ }
+
+ WPA_ClearRSN(pBSSList); //mike update
+
+ if (pRSNWPA != NULL) {
+ UINT uLen = pRSNWPA->len + 2;
+ if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) {
+ pBSSList->wWPALen = uLen;
+ memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
+ WPA_ParseRSN(pBSSList, pRSNWPA);
+ }
+ }
+
+ WPA2_ClearRSN(pBSSList); //mike update
+
+ if (pRSN != NULL) {
+ UINT uLen = pRSN->len + 2;
+ if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) {
+ pBSSList->wRSNLen = uLen;
+ memcpy(pBSSList->byRSNIE, pRSN, uLen);
+ WPA2vParseRSN(pBSSList, pRSN);
+ }
+ }
+
+ if (pRxPacket->uRSSI != 0) {
+ RFvRSSITodBm(pDevice, (BYTE)(pRxPacket->uRSSI), &ldBm);
+ // Moniter if RSSI is too strong.
+ pBSSList->byRSSIStatCnt++;
+ pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT;
+ pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm;
+ for(ii=0;ii<RSSI_STAT_COUNT;ii++) {
+ if (pBSSList->ldBmAverage[ii] != 0) {
+ pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm);
+ }
+ }
+ }
+
+ if ((pIE_Country != NULL) &&
+ (pMgmt->b11hEnable == TRUE)) {
+ CARDvSetCountryInfo(pMgmt->pAdapter,
+ pBSSList->eNetworkTypeInUse,
+ pIE_Country);
+ }
+
+ if ((bParsingQuiet == TRUE) && (pIE_Quiet != NULL)) {
+ if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
+ (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
+ // valid EID
+ if (pQuiet == NULL) {
+ pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
+ CARDbSetQuiet( pMgmt->pAdapter,
+ TRUE,
+ pQuiet->byQuietCount,
+ pQuiet->byQuietPeriod,
+ *((PWORD)pQuiet->abyQuietDuration),
+ *((PWORD)pQuiet->abyQuietOffset)
+ );
+ } else {
+ pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
+ CARDbSetQuiet( pMgmt->pAdapter,
+ FALSE,
+ pQuiet->byQuietCount,
+ pQuiet->byQuietPeriod,
+ *((PWORD)pQuiet->abyQuietDuration),
+ *((PWORD)pQuiet->abyQuietOffset)
+ );
+ }
+ }
+ }
+
+ if ((bParsingQuiet == TRUE) &&
+ (pQuiet != NULL)) {
+ CARDbStartQuiet(pMgmt->pAdapter);
+ }
+
+ pBSSList->uIELength = uIELength;
+ if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
+ pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
+ memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
+
+ return TRUE;
+}
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Search Node DB table to find the index of matched DstAddr
+ *
+ * Return Value:
+ * None
+ *
+-*/
+
+BOOL
+BSSDBbIsSTAInNodeDB(
+ IN PVOID pMgmtObject,
+ IN PBYTE abyDstAddr,
+ OUT PUINT puNodeIndex
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+ UINT ii;
+
+ // Index = 0 reserved for AP Node
+ for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
+ if (pMgmt->sNodeDBTable[ii].bActive) {
+ if (IS_ETH_ADDRESS_EQUAL(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) {
+ *puNodeIndex = ii;
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+};
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Find an empty node and allocated; if no empty found,
+ * instand used of most inactive one.
+ *
+ * Return Value:
+ * None
+ *
+-*/
+VOID
+BSSvCreateOneNode(
+ IN HANDLE hDeviceContext,
+ OUT PUINT puNodeIndex
+ )
+{
+
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT ii;
+ UINT BigestCount = 0;
+ UINT SelectIndex;
+ struct sk_buff *skb;
+ // Index = 0 reserved for AP Node (In STA mode)
+ // Index = 0 reserved for Broadcast/MultiCast (In AP mode)
+ SelectIndex = 1;
+ for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
+ if (pMgmt->sNodeDBTable[ii].bActive) {
+ if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) {
+ BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount;
+ SelectIndex = ii;
+ }
+ }
+ else {
+ break;
+ }
+ }
+
+ // if not found replace uInActiveCount is largest one.
+ if ( ii == (MAX_NODE_NUM + 1)) {
+ *puNodeIndex = SelectIndex;
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Replace inactive node = %d\n", SelectIndex);
+ // clear ps buffer
+ if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) {
+ while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL)
+ dev_kfree_skb(skb);
+ }
+ }
+ else {
+ *puNodeIndex = ii;
+ }
+
+ memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB));
+ pMgmt->sNodeDBTable[*puNodeIndex].bActive = TRUE;
+ pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND;
+ // for AP mode PS queue
+ skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue);
+ pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0;
+ pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create node index = %d\n", ii);
+ return;
+};
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Remove Node by NodeIndex
+ *
+ *
+ * Return Value:
+ * None
+ *
+-*/
+VOID
+BSSvRemoveOneNode(
+ IN HANDLE hDeviceContext,
+ IN UINT uNodeIndex
+ )
+{
+
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ struct sk_buff *skb;
+
+
+ while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL)
+ dev_kfree_skb(skb);
+ // clear context
+ memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB));
+ // clear tx bit map
+ pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7];
+
+ return;
+};
+/*+
+ *
+ * Routine Description:
+ * Update AP Node content in Index 0 of KnownNodeDB
+ *
+ *
+ * Return Value:
+ * None
+ *
+-*/
+
+VOID
+BSSvUpdateAPNode(
+ IN HANDLE hDeviceContext,
+ IN PWORD pwCapInfo,
+ IN PWLAN_IE_SUPP_RATES pSuppRates,
+ IN PWLAN_IE_SUPP_RATES pExtSuppRates
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uRateLen = WLAN_RATES_MAXLEN;
+
+ memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
+
+ pMgmt->sNodeDBTable[0].bActive = TRUE;
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ uRateLen = WLAN_RATES_MAXLEN_11B;
+ }
+ pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ uRateLen);
+ pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
+ uRateLen);
+ RATEvParseMaxRate((PVOID) pDevice,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
+ TRUE,
+ &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[0].wSuppRate),
+ &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
+ );
+ memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
+ pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate;
+ pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo);
+ pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
+#ifdef PLICE_DEBUG
+ printk("BSSvUpdateAPNode:MaxSuppRate is %d\n",pMgmt->sNodeDBTable[0].wMaxSuppRate);
+#endif
+ // Auto rate fallback function initiation.
+ // RATEbInit(pDevice);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->sNodeDBTable[0].wTxDataRate = %d \n", pMgmt->sNodeDBTable[0].wTxDataRate);
+
+};
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Add Multicast Node content in Index 0 of KnownNodeDB
+ *
+ *
+ * Return Value:
+ * None
+ *
+-*/
+
+
+VOID
+BSSvAddMulticastNode(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+ if (!pDevice->bEnableHostWEP)
+ memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
+ memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN);
+ pMgmt->sNodeDBTable[0].bActive = TRUE;
+ pMgmt->sNodeDBTable[0].bPSEnable = FALSE;
+ skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue);
+ RATEvParseMaxRate((PVOID) pDevice,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
+ TRUE,
+ &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[0].wSuppRate),
+ &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
+ );
+ pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate;
+#ifdef PLICE_DEBUG
+ printk("BSSvAddMultiCastNode:pMgmt->sNodeDBTable[0].wTxDataRate is %d\n",pMgmt->sNodeDBTable[0].wTxDataRate);
+#endif
+ pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
+
+};
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ *
+ *
+ * Second call back function to update Node DB info & AP link status
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+ //2008-4-14 <add> by chester for led issue
+ #ifdef FOR_LED_ON_NOTEBOOK
+BOOL cc=FALSE;
+UINT status;
+#endif
+VOID
+BSSvSecondCallBack(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT ii;
+ PWLAN_IE_SSID pItemSSID, pCurrSSID;
+ UINT uSleepySTACnt = 0;
+ UINT uNonShortSlotSTACnt = 0;
+ UINT uLongPreambleSTACnt = 0;
+viawget_wpa_header* wpahdr;
+
+ spin_lock_irq(&pDevice->lock);
+
+ pDevice->uAssocCount = 0;
+
+ pDevice->byERPFlag &=
+ ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
+ //2008-4-14 <add> by chester for led issue
+#ifdef FOR_LED_ON_NOTEBOOK
+MACvGPIOIn(pDevice->PortOffset, &pDevice->byGPIO);
+if (((BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA)&&(pDevice->bHWRadioOff == FALSE))||(BITbIsBitOn(pDevice->byGPIO,GPIO0_DATA)&&(pDevice->bHWRadioOff == TRUE)))&&(cc==FALSE)){
+cc=TRUE;
+}
+else if(cc==TRUE){
+
+if(pDevice->bHWRadioOff == TRUE){
+ if (BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA))
+//||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
+{if(status==1) goto start;
+status=1;
+CARDbRadioPowerOff(pDevice);
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ //netif_stop_queue(pDevice->dev);
+ pDevice->bLinkPass = FALSE;
+
+}
+ if (BITbIsBitOn(pDevice->byGPIO,GPIO0_DATA))
+//||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
+{if(status==2) goto start;
+status=2;
+CARDbRadioPowerOn(pDevice);
+} }
+else{
+ if (BITbIsBitOn(pDevice->byGPIO,GPIO0_DATA))
+//||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
+{if(status==3) goto start;
+status=3;
+CARDbRadioPowerOff(pDevice);
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ //netif_stop_queue(pDevice->dev);
+ pDevice->bLinkPass = FALSE;
+
+}
+ if (BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA))
+//||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
+{if(status==4) goto start;
+status=4;
+CARDbRadioPowerOn(pDevice);
+} }
+}
+start:
+#endif
+
+
+ if (pDevice->wUseProtectCntDown > 0) {
+ pDevice->wUseProtectCntDown --;
+ }
+ else {
+ // disable protect mode
+ pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));
+ }
+
+{
+ pDevice->byReAssocCount++;
+ if((pDevice->byReAssocCount > 10) && (pDevice->bLinkPass != TRUE)) { //10 sec timeout
+ printk("Re-association timeout!!!\n");
+ pDevice->byReAssocCount = 0;
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disassociated)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ }
+ else if(pDevice->bLinkPass == TRUE)
+ pDevice->byReAssocCount = 0;
+}
+
+#ifdef Calcu_LinkQual
+ s_uCalculateLinkQual((HANDLE)pDevice);
+#endif
+
+ for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
+
+ if (pMgmt->sNodeDBTable[ii].bActive) {
+
+ // Increase in-activity counter
+ pMgmt->sNodeDBTable[ii].uInActiveCount++;
+
+ if (ii > 0) {
+ if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) {
+ BSSvRemoveOneNode(pDevice, ii);
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO
+ "Inactive timeout [%d] sec, STA index = [%d] remove\n", MAX_INACTIVE_COUNT, ii);
+ continue;
+ }
+
+ if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) {
+
+ pDevice->uAssocCount++;
+
+ // check if Non ERP exist
+ if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) {
+ if (!pMgmt->sNodeDBTable[ii].bShortPreamble) {
+ pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
+ uLongPreambleSTACnt ++;
+ }
+ if (!pMgmt->sNodeDBTable[ii].bERPExist) {
+ pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
+ pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
+ }
+ if (!pMgmt->sNodeDBTable[ii].bShortSlotTime)
+ uNonShortSlotSTACnt++;
+ }
+ }
+
+ // check if any STA in PS mode
+ if (pMgmt->sNodeDBTable[ii].bPSEnable)
+ uSleepySTACnt++;
+
+
+ }
+
+ // Rate fallback check
+
+ if (!pDevice->bFixRate) {
+/*
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (ii == 0))
+ RATEvTxRateFallBack(pDevice, &(pMgmt->sNodeDBTable[ii]));
+*/
+ if (ii > 0) {
+ // ii = 0 for multicast node (AP & Adhoc)
+ RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii]));
+ }
+ else {
+ // ii = 0 reserved for unicast AP node (Infra STA)
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)
+#ifdef PLICE_DEBUG
+ printk("SecondCallback:Before:TxDataRate is %d\n",pMgmt->sNodeDBTable[0].wTxDataRate);
+#endif
+ RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii]));
+#ifdef PLICE_DEBUG
+ printk("SecondCallback:After:TxDataRate is %d\n",pMgmt->sNodeDBTable[0].wTxDataRate);
+#endif
+
+ }
+
+ }
+
+ // check if pending PS queue
+ if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index= %d, Queue = %d pending \n",
+ ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
+ if ((ii >0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) {
+ BSSvRemoveOneNode(pDevice, ii);
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Pending many queues PS STA Index = %d remove \n", ii);
+ continue;
+ }
+ }
+ }
+
+ }
+
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->eCurrentPHYType == PHY_TYPE_11G)) {
+
+ // on/off protect mode
+ if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) {
+ if (!pDevice->bProtectMode) {
+ MACvEnableProtectMD(pDevice->PortOffset);
+ pDevice->bProtectMode = TRUE;
+ }
+ }
+ else {
+ if (pDevice->bProtectMode) {
+ MACvDisableProtectMD(pDevice->PortOffset);
+ pDevice->bProtectMode = FALSE;
+ }
+ }
+ // on/off short slot time
+
+ if (uNonShortSlotSTACnt > 0) {
+ if (pDevice->bShortSlotTime) {
+ pDevice->bShortSlotTime = FALSE;
+ BBvSetShortSlotTime(pDevice);
+ vUpdateIFS((PVOID)pDevice);
+ }
+ }
+ else {
+ if (!pDevice->bShortSlotTime) {
+ pDevice->bShortSlotTime = TRUE;
+ BBvSetShortSlotTime(pDevice);
+ vUpdateIFS((PVOID)pDevice);
+ }
+ }
+
+ // on/off barker long preamble mode
+
+ if (uLongPreambleSTACnt > 0) {
+ if (!pDevice->bBarkerPreambleMd) {
+ MACvEnableBarkerPreambleMd(pDevice->PortOffset);
+ pDevice->bBarkerPreambleMd = TRUE;
+ }
+ }
+ else {
+ if (pDevice->bBarkerPreambleMd) {
+ MACvDisableBarkerPreambleMd(pDevice->PortOffset);
+ pDevice->bBarkerPreambleMd = FALSE;
+ }
+ }
+
+ }
+
+
+ // Check if any STA in PS mode, enable DTIM multicast deliver
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (uSleepySTACnt > 0)
+ pMgmt->sNodeDBTable[0].bPSEnable = TRUE;
+ else
+ pMgmt->sNodeDBTable[0].bPSEnable = FALSE;
+ }
+
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+//printk("pCurrSSID=%s\n",pCurrSSID->abySSID);
+ if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
+
+ if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS
+ // DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Callback inactive Count = [%d]\n", pMgmt->sNodeDBTable[0].uInActiveCount);
+ //if (pDevice->bUpdateBBVGA) {
+ // s_vCheckSensitivity((HANDLE) pDevice);
+ //}
+ if (pDevice->bUpdateBBVGA) {
+ // s_vCheckSensitivity((HANDLE) pDevice);
+ s_vCheckPreEDThreshold((HANDLE)pDevice);
+ }
+ if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) &&
+ (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0]) ) {
+ pDevice->byBBVGANew = pDevice->abyBBVGA[0];
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
+ }
+
+
+ if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) {
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ netif_stop_queue(pDevice->dev);
+ pDevice->bLinkPass = FALSE;
+ pDevice->bRoaming = TRUE;
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
+ if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ wpahdr->type = VIAWGET_DISASSOC_MSG;
+ wpahdr->resp_ie_len = 0;
+ wpahdr->req_ie_len = 0;
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header));
+ pDevice->skb->dev = pDevice->wpadev;
+//2008-4-3 modify by Chester for wpa
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ pDevice->skb->mac_header = pDevice->skb->data;
+#else
+ pDevice->skb->mac.raw = pDevice->skb->data;
+#endif
+ pDevice->skb->pkt_type = PACKET_HOST;
+ pDevice->skb->protocol = htons(ETH_P_802_2);
+ memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
+ netif_rx(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ };
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disassociated)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ }
+ }
+ else if (pItemSSID->len != 0) {
+ if (pDevice->uAutoReConnectTime < 10) {
+ pDevice->uAutoReConnectTime++;
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //network manager support need not do Roaming scan???
+ if(pDevice->bWPASuppWextEnabled ==TRUE)
+ pDevice->uAutoReConnectTime = 0;
+ #endif
+
+ }
+ else {
+ //mike use old encryption status for wpa reauthen
+ if(pDevice->bWPADEVUp)
+ pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming ...\n");
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
+ pDevice->uAutoReConnectTime = 0;
+ }
+ }
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ // if adhoc started which essid is NULL string, rescaning.
+ if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) {
+ if (pDevice->uAutoReConnectTime < 10) {
+ pDevice->uAutoReConnectTime++;
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Adhoc re-scaning ...\n");
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+ pDevice->uAutoReConnectTime = 0;
+ };
+ }
+ if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
+ if (pDevice->bUpdateBBVGA) {
+ //s_vCheckSensitivity((HANDLE) pDevice);
+ s_vCheckPreEDThreshold((HANDLE)pDevice);
+ }
+ if (pMgmt->sNodeDBTable[0].uInActiveCount >=ADHOC_LOST_BEACON_COUNT) {
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost other STA beacon [%d] sec, started !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+ pMgmt->eCurrState = WMAC_STATE_STARTED;
+ netif_stop_queue(pDevice->dev);
+ pDevice->bLinkPass = FALSE;
+ }
+ }
+ }
+
+ spin_unlock_irq(&pDevice->lock);
+
+ pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);
+ add_timer(&pMgmt->sTimerSecondCallback);
+ return;
+}
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ *
+ *
+ * Update Tx attemps, Tx failure counter in Node DB
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+
+
+
+VOID
+BSSvUpdateNodeTxCounter(
+ IN HANDLE hDeviceContext,
+ IN BYTE byTsr0,
+ IN BYTE byTsr1,
+ IN PBYTE pbyBuffer,
+ IN UINT uFIFOHeaderSize
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uNodeIndex = 0;
+ BYTE byTxRetry = (byTsr0 & TSR0_NCR);
+ PSTxBufHead pTxBufHead;
+ PS802_11Header pMACHeader;
+ WORD wRate;
+ WORD wFallBackRate = RATE_1M;
+ BYTE byFallBack;
+ UINT ii;
+// UINT txRetryTemp;
+//PLICE_DEBUG->
+ //txRetryTemp = byTxRetry;
+ //if (txRetryTemp== 8)
+ //txRetryTemp -=3;
+//PLICE_DEBUG <-
+ pTxBufHead = (PSTxBufHead) pbyBuffer;
+ if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_0) {
+ byFallBack = AUTO_FB_0;
+ } else if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_1) {
+ byFallBack = AUTO_FB_1;
+ } else {
+ byFallBack = AUTO_FB_NONE;
+ }
+ wRate = pTxBufHead->wReserved; //?wRate
+ //printk("BSSvUpdateNodeTxCounter:byTxRetry is %d\n",byTxRetry);
+
+//printk("BSSvUpdateNodeTx:wRate is %d,byFallback is %d\n",wRate,byFallBack);
+//#ifdef PLICE_DEBUG
+ //printk("BSSvUpdateNodeTx: wRate is %d\n",wRate);
+////#endif
+ // Only Unicast using support rates
+ if (pTxBufHead->wFIFOCtl & FIFOCTL_NEEDACK) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wRate %04X, byTsr0 %02X, byTsr1 %02X\n", wRate, byTsr0, byTsr1);
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
+ pMgmt->sNodeDBTable[0].uTxAttempts += 1;
+ if ((byTsr1 & TSR1_TERR) == 0) {
+ // transmit success, TxAttempts at least plus one
+ pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++;
+ if ( (byFallBack == AUTO_FB_NONE) ||
+ (wRate < RATE_18M) ) {
+ wFallBackRate = wRate;
+ } else if (byFallBack == AUTO_FB_0) {
+//PLICE_DEBUG
+ if (byTxRetry < 5)
+ //if (txRetryTemp < 5)
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
+ //wFallBackRate = awHWRetry0[wRate-RATE_12M][byTxRetry];
+ //wFallBackRate = awHWRetry0[wRate-RATE_18M][txRetryTemp] +1;
+ else
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
+ //wFallBackRate = awHWRetry0[wRate-RATE_12M][4];
+ } else if (byFallBack == AUTO_FB_1) {
+ if (byTxRetry < 5)
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
+ else
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
+ }
+ pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++;
+ } else {
+ pMgmt->sNodeDBTable[0].uTxFailures ++;
+ }
+ pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry;
+ if (byTxRetry != 0) {
+ pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE]+=byTxRetry;
+ if ( (byFallBack == AUTO_FB_NONE) ||
+ (wRate < RATE_18M) ) {
+ pMgmt->sNodeDBTable[0].uTxFail[wRate]+=byTxRetry;
+ } else if (byFallBack == AUTO_FB_0) {
+//PLICE_DEBUG
+ for(ii=0;ii<byTxRetry;ii++)
+ //for (ii=0;ii<txRetryTemp;ii++)
+ {
+ if (ii < 5)
+ {
+
+//PLICE_DEBUG
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
+ //printk(" II is %d:BSSvUpdateNodeTx:wFallBackRate is %d\n",ii,wFallBackRate);
+ //wFallBackRate = awHWRetry0[wRate-RATE_12M][ii];
+ }
+ else
+ {
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
+ //printk("ii is %d BSSvUpdateNodeTx:wFallBackRate is %d\n",ii,wFallBackRate);
+ //wFallBackRate = awHWRetry0[wRate-RATE_12M][4];
+ }
+ pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
+ }
+ } else if (byFallBack == AUTO_FB_1) {
+ for(ii=0;ii<byTxRetry;ii++) {
+ if (ii < 5)
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
+ else
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
+ pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
+ }
+ }
+ }
+ };
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
+
+ pMACHeader = (PS802_11Header)(pbyBuffer + uFIFOHeaderSize);
+
+ if (BSSDBbIsSTAInNodeDB((HANDLE)pMgmt, &(pMACHeader->abyAddr1[0]), &uNodeIndex)){
+ pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1;
+ if ((byTsr1 & TSR1_TERR) == 0) {
+ // transmit success, TxAttempts at least plus one
+ pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
+ if ( (byFallBack == AUTO_FB_NONE) ||
+ (wRate < RATE_18M) ) {
+ wFallBackRate = wRate;
+ } else if (byFallBack == AUTO_FB_0) {
+ if (byTxRetry < 5)
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
+ else
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
+ } else if (byFallBack == AUTO_FB_1) {
+ if (byTxRetry < 5)
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
+ else
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
+ }
+ pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++;
+ } else {
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFailures ++;
+ }
+ pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry;
+ if (byTxRetry != 0) {
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE]+=byTxRetry;
+ if ( (byFallBack == AUTO_FB_NONE) ||
+ (wRate < RATE_18M) ) {
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate]+=byTxRetry;
+ } else if (byFallBack == AUTO_FB_0) {
+ for(ii=0;ii<byTxRetry;ii++) {
+ if (ii < 5)
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
+ else
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
+ }
+ } else if (byFallBack == AUTO_FB_1) {
+ for(ii=0;ii<byTxRetry;ii++) {
+ if (ii < 5)
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
+ else
+ wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
+ }
+ }
+ }
+ };
+ }
+ };
+
+ return;
+
+}
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Clear Nodes & skb in DB Table
+ *
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - The adapter context.
+ * uStartIndex - starting index
+ * Out:
+ * none
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+BSSvClearNodeDBTable(
+ IN HANDLE hDeviceContext,
+ IN UINT uStartIndex
+ )
+
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ struct sk_buff *skb;
+ UINT ii;
+
+ for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) {
+ if (pMgmt->sNodeDBTable[ii].bActive) {
+ // check if sTxPSQueue has been initial
+ if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) {
+ while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS skb != NULL %d\n", ii);
+ dev_kfree_skb(skb);
+ }
+ }
+ memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB));
+ }
+ }
+
+ return;
+};
+
+
+VOID s_vCheckSensitivity(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PKnownBSS pBSSList = NULL;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int ii;
+
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1) && (pDevice->byRFType == RF_RFMD2959) &&
+ (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
+ return;
+ }
+
+ if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
+ ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
+ pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
+ if (pBSSList != NULL) {
+ // Updata BB Reg if RSSI is too strong.
+ LONG LocalldBmAverage = 0;
+ LONG uNumofdBm = 0;
+ for (ii = 0; ii < RSSI_STAT_COUNT; ii++) {
+ if (pBSSList->ldBmAverage[ii] != 0) {
+ uNumofdBm ++;
+ LocalldBmAverage += pBSSList->ldBmAverage[ii];
+ }
+ }
+ if (uNumofdBm > 0) {
+ LocalldBmAverage = LocalldBmAverage/uNumofdBm;
+ for (ii=0;ii<BB_VGA_LEVEL;ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LocalldBmAverage:%ld, %ld %02x\n", LocalldBmAverage, pDevice->ldBmThreshold[ii], pDevice->abyBBVGA[ii]);
+ if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) {
+ pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
+ break;
+ }
+ }
+ if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
+ pDevice->uBBVGADiffCount++;
+ if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD)
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
+ } else {
+ pDevice->uBBVGADiffCount = 0;
+ }
+ }
+ }
+ }
+}
+
+
+VOID
+BSSvClearAnyBSSJoinRecord (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT ii;
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pMgmt->sBSSList[ii].bSelected = FALSE;
+ }
+ return;
+}
+
+#ifdef Calcu_LinkQual
+VOID s_uCalculateLinkQual(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ ULONG TxOkRatio, TxCnt;
+ ULONG RxOkRatio,RxCnt;
+ ULONG RssiRatio;
+ long ldBm;
+
+TxCnt = pDevice->scStatistic.TxNoRetryOkCount +
+ pDevice->scStatistic.TxRetryOkCount +
+ pDevice->scStatistic.TxFailCount;
+RxCnt = pDevice->scStatistic.RxFcsErrCnt +
+ pDevice->scStatistic.RxOkCnt;
+TxOkRatio = (TxCnt < 6) ? 4000:((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt);
+RxOkRatio = (RxCnt < 6) ? 2000:((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt);
+//decide link quality
+if(pDevice->bLinkPass !=TRUE)
+{
+ // printk("s_uCalculateLinkQual-->Link disconnect and Poor quality**\n");
+ pDevice->scStatistic.LinkQuality = 0;
+ pDevice->scStatistic.SignalStren = 0;
+}
+else
+{
+ RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
+ if(-ldBm < 50) {
+ RssiRatio = 4000;
+ }
+ else if(-ldBm > 90) {
+ RssiRatio = 0;
+ }
+ else {
+ RssiRatio = (40-(-ldBm-50))*4000/40;
+ }
+ pDevice->scStatistic.SignalStren = RssiRatio/40;
+ pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100;
+}
+ pDevice->scStatistic.RxFcsErrCnt = 0;
+ pDevice->scStatistic.RxOkCnt = 0;
+ pDevice->scStatistic.TxFailCount = 0;
+ pDevice->scStatistic.TxNoRetryOkCount = 0;
+ pDevice->scStatistic.TxRetryOkCount = 0;
+ return;
+}
+#endif
+
+VOID s_vCheckPreEDThreshold(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PKnownBSS pBSSList = NULL;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
+ ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
+ pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
+ if (pBSSList != NULL) {
+ pDevice->byBBPreEDRSSI = (BYTE) (~(pBSSList->ldBmAverRange) + 1);
+ //BBvUpdatePreEDThreshold(pDevice, FALSE);
+ }
+ }
+ return;
+}
diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h
new file mode 100644
index 000000000000..d35616d4883d
--- /dev/null
+++ b/drivers/staging/vt6655/bssdb.h
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: bssdb.h
+ *
+ * Purpose: Handles the Basic Service Set & Node Database functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 16, 2002
+ *
+ */
+
+#ifndef __BSSDB_H__
+#define __BSSDB_H__
+
+//#if !defined(__DEVICE_H__)
+//#include "device.h"
+//#endif
+#include <linux/skbuff.h>
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define MAX_NODE_NUM 64
+#define MAX_BSS_NUM 42
+#define LOST_BEACON_COUNT 10 // 10 sec, XP defined
+#define MAX_PS_TX_BUF 32 // sta max power saving tx buf
+#define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
+#define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
+
+#define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
+#define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
+#define BSS_CLEAR_COUNT 1
+
+#define RSSI_STAT_COUNT 10
+#define MAX_CHECK_RSSI_COUNT 8
+
+// STA dwflags
+#define WLAN_STA_AUTH BIT0
+#define WLAN_STA_ASSOC BIT1
+#define WLAN_STA_PS BIT2
+#define WLAN_STA_TIM BIT3
+// permanent; do not remove entry on expiration
+#define WLAN_STA_PERM BIT4
+// If 802.1X is used, this flag is
+// controlling whether STA is authorized to
+// send and receive non-IEEE 802.1X frames
+#define WLAN_STA_AUTHORIZED BIT5
+
+#define MAX_RATE 12
+
+#define MAX_WPA_IE_LEN 64
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+//
+// IEEE 802.11 Structures and definitions
+//
+
+typedef enum _NDIS_802_11_NETWORK_TYPE
+{
+ Ndis802_11FH,
+ Ndis802_11DS,
+ Ndis802_11OFDM5,
+ Ndis802_11OFDM24,
+ Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
+} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
+
+
+typedef struct tagSERPObject {
+ BOOL bERPExist;
+ BYTE byERP;
+} ERPObject, DEF* PERPObject;
+
+
+typedef struct tagSRSNCapObject {
+ BOOL bRSNCapExist;
+ WORD wRSNCap;
+} SRSNCapObject, DEF* PSRSNCapObject;
+
+// BSS info(AP)
+#pragma pack(1)
+typedef struct tagKnownBSS {
+ // BSS info
+ BOOL bActive;
+ BYTE abyBSSID[WLAN_BSSID_LEN];
+ UINT uChannel;
+ BYTE abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ BYTE abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ UINT uRSSI;
+ BYTE bySQ;
+ WORD wBeaconInterval;
+ WORD wCapInfo;
+ BYTE abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ BYTE byRxRate;
+// WORD wATIMWindow;
+ BYTE byRSSIStatCnt;
+ LONG ldBmMAX;
+ LONG ldBmAverage[RSSI_STAT_COUNT];
+ LONG ldBmAverRange;
+ //For any BSSID selection improvment
+ BOOL bSelected;
+
+ //++ WPA informations
+ BOOL bWPAValid;
+ BYTE byGKType;
+ BYTE abyPKType[4];
+ WORD wPKCount;
+ BYTE abyAuthType[4];
+ WORD wAuthCount;
+ BYTE byDefaultK_as_PK;
+ BYTE byReplayIdx;
+ //--
+
+ //++ WPA2 informations
+ BOOL bWPA2Valid;
+ BYTE byCSSGK;
+ WORD wCSSPKCount;
+ BYTE abyCSSPK[4];
+ WORD wAKMSSAuthCount;
+ BYTE abyAKMSSAuthType[4];
+
+ //++ wpactl
+ BYTE byWPAIE[MAX_WPA_IE_LEN];
+ BYTE byRSNIE[MAX_WPA_IE_LEN];
+ WORD wWPALen;
+ WORD wRSNLen;
+
+ // Clear count
+ UINT uClearCount;
+// BYTE abyIEs[WLAN_BEACON_FR_MAXLEN];
+ UINT uIELength;
+ QWORD qwBSSTimestamp;
+ QWORD qwLocalTSF; // local TSF timer
+
+// NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
+ CARD_PHY_TYPE eNetworkTypeInUse;
+
+ ERPObject sERP;
+ SRSNCapObject sRSNCapObj;
+ BYTE abyIEs[1024]; // don't move this field !!
+
+}__attribute__ ((__packed__))
+KnownBSS , DEF* PKnownBSS;
+
+//2006-1116-01,<Add> by NomadZhao
+#pragma pack()
+
+typedef enum tagNODE_STATE {
+ NODE_FREE,
+ NODE_AGED,
+ NODE_KNOWN,
+ NODE_AUTH,
+ NODE_ASSOC
+} NODE_STATE, *PNODE_STATE;
+
+
+// STA node info
+typedef struct tagKnownNodeDB {
+ // STA info
+ BOOL bActive;
+ BYTE abyMACAddr[WLAN_ADDR_LEN];
+ BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
+ BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
+ WORD wTxDataRate;
+ BOOL bShortPreamble;
+ BOOL bERPExist;
+ BOOL bShortSlotTime;
+ UINT uInActiveCount;
+ WORD wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
+ WORD wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
+ WORD wSuppRate;
+ BYTE byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
+ BYTE byTopCCKBasicRate; //Records the highest basic rate in CCK mode
+
+ // For AP mode
+ struct sk_buff_head sTxPSQueue;
+ WORD wCapInfo;
+ WORD wListenInterval;
+ WORD wAID;
+ NODE_STATE eNodeState;
+ BOOL bPSEnable;
+ BOOL bRxPSPoll;
+ BYTE byAuthSequence;
+ ULONG ulLastRxJiffer;
+ BYTE bySuppRate;
+ DWORD dwFlags;
+ WORD wEnQueueCnt;
+
+ BOOL bOnFly;
+ ULONGLONG KeyRSC;
+ BYTE byKeyIndex;
+ DWORD dwKeyIndex;
+ BYTE byCipherSuite;
+ DWORD dwTSC47_16;
+ WORD wTSC15_0;
+ UINT uWepKeyLength;
+ BYTE abyWepKey[WLAN_WEPMAX_KEYLEN];
+ //
+ // Auto rate fallback vars
+ BOOL bIsInFallback;
+ UINT uAverageRSSI;
+ UINT uRateRecoveryTimeout;
+ UINT uRatePollTimeout;
+ UINT uTxFailures;
+ UINT uTxAttempts;
+
+ UINT uTxRetry;
+ UINT uFailureRatio;
+ UINT uRetryRatio;
+ UINT uTxOk[MAX_RATE+1];
+ UINT uTxFail[MAX_RATE+1];
+ UINT uTimeCount;
+
+} KnownNodeDB, DEF* PKnownNodeDB;
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+PKnownBSS
+BSSpSearchBSSList(
+ IN HANDLE hDeviceContext,
+ IN PBYTE pbyDesireBSSID,
+ IN PBYTE pbyDesireSSID,
+ IN CARD_PHY_TYPE ePhyType
+ );
+
+PKnownBSS
+BSSpAddrIsInBSSList(
+ IN HANDLE hDeviceContext,
+ IN PBYTE abyBSSID,
+ IN PWLAN_IE_SSID pSSID
+ );
+
+VOID
+BSSvClearBSSList(
+ IN HANDLE hDeviceContext,
+ IN BOOL bKeepCurrBSSID
+ );
+
+BOOL
+BSSbInsertToBSSList(
+ IN HANDLE hDeviceContext,
+ IN PBYTE abyBSSIDAddr,
+ IN QWORD qwTimestamp,
+ IN WORD wBeaconInterval,
+ IN WORD wCapInfo,
+ IN BYTE byCurrChannel,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pSuppRates,
+ IN PWLAN_IE_SUPP_RATES pExtSuppRates,
+ IN PERPObject psERP,
+ IN PWLAN_IE_RSN pRSN,
+ IN PWLAN_IE_RSN_EXT pRSNWPA,
+ IN PWLAN_IE_COUNTRY pIE_Country,
+ IN PWLAN_IE_QUIET pIE_Quiet,
+ IN UINT uIELength,
+ IN PBYTE pbyIEs,
+ IN HANDLE pRxPacketContext
+ );
+
+
+BOOL
+BSSbUpdateToBSSList(
+ IN HANDLE hDeviceContext,
+ IN QWORD qwTimestamp,
+ IN WORD wBeaconInterval,
+ IN WORD wCapInfo,
+ IN BYTE byCurrChannel,
+ IN BOOL bChannelHit,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pSuppRates,
+ IN PWLAN_IE_SUPP_RATES pExtSuppRates,
+ IN PERPObject psERP,
+ IN PWLAN_IE_RSN pRSN,
+ IN PWLAN_IE_RSN_EXT pRSNWPA,
+ IN PWLAN_IE_COUNTRY pIE_Country,
+ IN PWLAN_IE_QUIET pIE_Quiet,
+ IN PKnownBSS pBSSList,
+ IN UINT uIELength,
+ IN PBYTE pbyIEs,
+ IN HANDLE pRxPacketContext
+ );
+
+
+BOOL
+BSSDBbIsSTAInNodeDB(
+ IN HANDLE hDeviceContext,
+ IN PBYTE abyDstAddr,
+ OUT PUINT puNodeIndex
+ );
+
+VOID
+BSSvCreateOneNode(
+ IN HANDLE hDeviceContext,
+ OUT PUINT puNodeIndex
+ );
+
+VOID
+BSSvUpdateAPNode(
+ IN HANDLE hDeviceContext,
+ IN PWORD pwCapInfo,
+ IN PWLAN_IE_SUPP_RATES pItemRates,
+ IN PWLAN_IE_SUPP_RATES pExtSuppRates
+ );
+
+
+VOID
+BSSvSecondCallBack(
+ IN HANDLE hDeviceContext
+ );
+
+VOID
+BSSvUpdateNodeTxCounter(
+ IN HANDLE hDeviceContext,
+ IN BYTE byTsr0,
+ IN BYTE byTsr1,
+ IN PBYTE pbyBuffer,
+ IN UINT uFIFOHeaderSize
+ );
+
+VOID
+BSSvRemoveOneNode(
+ IN HANDLE hDeviceContext,
+ IN UINT uNodeIndex
+ );
+
+VOID
+BSSvAddMulticastNode(
+ IN HANDLE hDeviceContext
+ );
+
+
+VOID
+BSSvClearNodeDBTable(
+ IN HANDLE hDeviceContext,
+ IN UINT uStartIndex
+ );
+
+VOID
+BSSvClearAnyBSSJoinRecord(
+ IN HANDLE hDeviceContext
+ );
+
+#endif //__BSSDB_H__
diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
new file mode 100644
index 000000000000..723f44e0bbae
--- /dev/null
+++ b/drivers/staging/vt6655/card.c
@@ -0,0 +1,3126 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: card.c
+ * Purpose: Provide functions to setup NIC operation mode
+ * Functions:
+ * s_vSafeResetTx - Rest Tx
+ * CARDvSetRSPINF - Set RSPINF
+ * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS
+ * CARDvUpdateBasicTopRate - Update BasicTopRate
+ * CARDbAddBasicRate - Add to BasicRateSet
+ * CARDbSetBasicRate - Set Basic Tx Rate
+ * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet
+ * CARDvSetLoopbackMode - Set Loopback mode
+ * CARDbSoftwareReset - Sortware reset NIC
+ * CARDqGetTSFOffset - Caculate TSFOffset
+ * CARDbGetCurrentTSF - Read Current NIC TSF counter
+ * CARDqGetNextTBTT - Caculate Next Beacon TSF counter
+ * CARDvSetFirstNextTBTT - Set NIC Beacon time
+ * CARDvUpdateNextTBTT - Sync. NIC Beacon time
+ * CARDbRadioPowerOff - Turn Off NIC Radio Power
+ * CARDbRadioPowerOn - Turn On NIC Radio Power
+ * CARDbSetWEPMode - Set NIC Wep mode
+ * CARDbSetTxPower - Set NIC tx power
+ *
+ * Revision History:
+ * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
+ * 08-26-2003 Kyle Hsu: Modify the defination type of dwIoBase.
+ * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
+ *
+ */
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__DESC_H__)
+#include "desc.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__VNTWIFI_H__)
+#include "vntwifi.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__KEY_H__)
+#include "key.h"
+#endif
+#if !defined(__RC4_H__)
+#include "rc4.h"
+#endif
+#if !defined(__COUNTRY_H__)
+#include "country.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+#define C_SIFS_A 16 // micro sec.
+#define C_SIFS_BG 10
+
+#define C_EIFS 80 // micro sec.
+
+
+#define C_SLOT_SHORT 9 // micro sec.
+#define C_SLOT_LONG 20
+
+#define C_CWMIN_A 15 // slot time
+#define C_CWMIN_B 31
+
+#define C_CWMAX 1023 // slot time
+
+#define CARD_MAX_CHANNEL_TBL 56
+
+#define WAIT_BEACON_TX_DOWN_TMO 3 // Times
+
+typedef struct tagSChannelTblElement {
+ BYTE byChannelNumber;
+ UINT uFrequency;
+ BOOL bValid;
+ BYTE byMAP;
+}SChannelTblElement, DEF* PSChannelTblElement;
+
+ //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
+static BYTE abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
+ //6M, 9M, 12M, 48M
+static BYTE abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
+ //6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M
+static BYTE abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+ //1M, 2M, 5M, 11M,
+static BYTE abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+
+const WORD cwRXBCNTSFOff[MAX_RATE] =
+{17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
+
+static SChannelTblElement sChannelTbl[CARD_MAX_CHANNEL_TBL+1] =
+{
+ {0, 0, FALSE, 0},
+ {1, 2412, TRUE, 0},
+ {2, 2417, TRUE, 0},
+ {3, 2422, TRUE, 0},
+ {4, 2427, TRUE, 0},
+ {5, 2432, TRUE, 0},
+ {6, 2437, TRUE, 0},
+ {7, 2442, TRUE, 0},
+ {8, 2447, TRUE, 0},
+ {9, 2452, TRUE, 0},
+ {10, 2457, TRUE, 0},
+ {11, 2462, TRUE, 0},
+ {12, 2467, TRUE, 0},
+ {13, 2472, TRUE, 0},
+ {14, 2484, TRUE, 0},
+ {183, 4915, TRUE, 0},
+ {184, 4920, TRUE, 0},
+ {185, 4925, TRUE, 0},
+ {187, 4935, TRUE, 0},
+ {188, 4940, TRUE, 0},
+ {189, 4945, TRUE, 0},
+ {192, 4960, TRUE, 0},
+ {196, 4980, TRUE, 0},
+ {7, 5035, TRUE, 0},
+ {8, 5040, TRUE, 0},
+ {9, 5045, TRUE, 0},
+ {11, 5055, TRUE, 0},
+ {12, 5060, TRUE, 0},
+ {16, 5080, TRUE, 0},
+ {34, 5170, TRUE, 0},
+ {36, 5180, TRUE, 0},
+ {38, 5190, TRUE, 0},
+ {40, 5200, TRUE, 0},
+ {42, 5210, TRUE, 0},
+ {44, 5220, TRUE, 0},
+ {46, 5230, TRUE, 0},
+ {48, 5240, TRUE, 0},
+ {52, 5260, TRUE, 0},
+ {56, 5280, TRUE, 0},
+ {60, 5300, TRUE, 0},
+ {64, 5320, TRUE, 0},
+ {100, 5500, TRUE, 0},
+ {104, 5520, TRUE, 0},
+ {108, 5540, TRUE, 0},
+ {112, 5560, TRUE, 0},
+ {116, 5580, TRUE, 0},
+ {120, 5600, TRUE, 0},
+ {124, 5620, TRUE, 0},
+ {128, 5640, TRUE, 0},
+ {132, 5660, TRUE, 0},
+ {136, 5680, TRUE, 0},
+ {140, 5700, TRUE, 0},
+ {149, 5745, TRUE, 0},
+ {153, 5765, TRUE, 0},
+ {157, 5785, TRUE, 0},
+ {161, 5805, TRUE, 0},
+ {165, 5825, TRUE, 0}
+};
+
+
+/************************************************************************
+ * The Radar regulation rules for each country
+ ************************************************************************/
+SCountryTable ChannelRuleTab[CCODE_MAX+1] =
+{
+/************************************************************************
+ * This table is based on Athero driver rules
+ ************************************************************************/
+/* Country Available channels, ended with 0 */
+/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */
+{CCODE_FCC, {'U','S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_TELEC, {'J','P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 23, 0, 0, 23, 0, 23, 23, 0, 23, 0, 0, 23, 23, 23, 0, 23, 0, 23, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ETSI, {'E','U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_RESV3, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESV4, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESV5, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESV6, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESV7, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESV8, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESV9, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESVa, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESVb, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESVc, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESVd, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RESVe, {' ',' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ALLBAND, {' ',' '}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ALBANIA, {'A','L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ALGERIA, {'D','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ARGENTINA, {'A','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0} },
+{CCODE_ARMENIA, {'A','M'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_AUSTRALIA, {'A','U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_AUSTRIA, {'A','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 15, 0, 15, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_AZERBAIJAN, {'A','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_BAHRAIN, {'B','H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_BELARUS, {'B','Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_BELGIUM, {'B','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_BELIZE, {'B','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_BOLIVIA, {'B','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_BRAZIL, {'B','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_BRUNEI_DARUSSALAM, {'B','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_BULGARIA, {'B','G'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0} },
+{CCODE_CANADA, {'C','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_CHILE, {'C','L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17} },
+{CCODE_CHINA, {'C','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_COLOMBIA, {'C','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_COSTA_RICA, {'C','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_CROATIA, {'H','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_CYPRUS, {'C','Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_CZECH, {'C','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_DENMARK, {'D','K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_DOMINICAN_REPUBLIC, {'D','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_ECUADOR, {'E','C'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_EGYPT, {'E','G'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_EL_SALVADOR, {'S','V'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ESTONIA, {'E','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_FINLAND, {'F','I'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_FRANCE, {'F','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_GERMANY, {'D','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_GREECE, {'G','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_GEORGIA, {'G','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_GUATEMALA, {'G','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_HONDURAS, {'H','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_HONG_KONG, {'H','K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_HUNGARY, {'H','U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ICELAND, {'I','S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_INDIA, {'I','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_INDONESIA, {'I','D'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_IRAN, {'I','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_IRELAND, {'I','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_ITALY, {'I','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_ISRAEL, {'I','L'}, { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_JAPAN, {'J','P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_JORDAN, {'J','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_KAZAKHSTAN, {'K','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_KUWAIT, {'K','W'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_LATVIA, {'L','V'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_LEBANON, {'L','B'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_LEICHTENSTEIN, {'L','I'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_LITHUANIA, {'L','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_LUXEMBURG, {'L','U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_MACAU, {'M','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_MACEDONIA, {'M','K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_MALTA, {'M','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} },
+{CCODE_MALAYSIA, {'M','Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_MEXICO, {'M','X'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_MONACO, {'M','C'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_MOROCCO, {'M','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_NETHERLANDS, {'N','L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_NEW_ZEALAND, {'N','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_NORTH_KOREA, {'K','P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} },
+{CCODE_NORWAY, {'N','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_OMAN, {'O','M'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_PAKISTAN, {'P','K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_PANAMA, {'P','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_PERU, {'P','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_PHILIPPINES, {'P','H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_POLAND, {'P','L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_PORTUGAL, {'P','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_PUERTO_RICO, {'P','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_QATAR, {'Q','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ROMANIA, {'R','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_RUSSIA, {'R','U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_SAUDI_ARABIA, {'S','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_SINGAPORE, {'S','G'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20} },
+{CCODE_SLOVAKIA, {'S','K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} },
+{CCODE_SLOVENIA, {'S','I'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_SOUTH_AFRICA, {'Z','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_SOUTH_KOREA, {'K','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} },
+{CCODE_SPAIN, {'E','S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} },
+{CCODE_SWEDEN, {'S','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_SWITZERLAND, {'C','H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_SYRIA, {'S','Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_TAIWAN, {'T','W'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0} },
+{CCODE_THAILAND, {'T','H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} },
+{CCODE_TRINIDAD_TOBAGO, {'T','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_TUNISIA, {'T','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_TURKEY, {'T','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_UK, {'G','B'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
+{CCODE_UKRAINE, {'U','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_UNITED_ARAB_EMIRATES, {'A','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_UNITED_STATES, {'U','S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
+ , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
+{CCODE_URUGUAY, {'U','Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} },
+{CCODE_UZBEKISTAN, {'U','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_VENEZUELA, {'V','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
+ , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} },
+{CCODE_VIETNAM, {'V','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_YEMEN, {'Y','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_ZIMBABWE, {'Z','W'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_JAPAN_W52_W53, {'J','J'}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
+{CCODE_MAX, {'U','N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
+ , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }
+/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */
+};
+
+
+/*--------------------- Static Functions --------------------------*/
+
+static
+VOID
+s_vCaculateOFDMRParameter(
+ IN BYTE byRate,
+ IN CARD_PHY_TYPE ePHYType,
+ OUT PBYTE pbyTxRate,
+ OUT PBYTE pbyRsvTime
+ );
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*--------------------- Export function -------------------------*/
+/************************************************************************
+ * Country Channel Valid
+ * Input: CountryCode, ChannelNum
+ * ChanneIndex is defined as VT3253 MAC channel:
+ * 1 = 2.4G channel 1
+ * 2 = 2.4G channel 2
+ * ...
+ * 14 = 2.4G channel 14
+ * 15 = 4.9G channel 183
+ * 16 = 4.9G channel 184
+ * .....
+ * Output: TRUE if the specified 5GHz band is allowed to be used.
+ False otherwise.
+// 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+
+// 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+// 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
+ ************************************************************************/
+//2008-8-4 <add> by chester
+BOOL
+ChannelValid(UINT CountryCode, UINT ChannelIndex)
+{
+ BOOL bValid;
+
+ bValid = FALSE;
+ /*
+ * If Channel Index is invalid, return invalid
+ */
+ if ((ChannelIndex > CB_MAX_CHANNEL) ||
+ (ChannelIndex == 0))
+ {
+ bValid = FALSE;
+ goto exit;
+ }
+
+ bValid = sChannelTbl[ChannelIndex].bValid;
+
+exit:
+ return (bValid);
+
+} /* end ChannelValid */
+
+
+/*
+ * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
+ *
+ * Parameters:
+ * In:
+ * wRate - Tx Rate
+ * byPktType - Tx Packet type
+ * Out:
+ * pbyTxRate - pointer to RSPINF TxRate field
+ * pbyRsvTime - pointer to RSPINF RsvTime field
+ *
+ * Return Value: none
+ *
+ */
+static
+VOID
+s_vCaculateOFDMRParameter (
+ IN BYTE byRate,
+ IN CARD_PHY_TYPE ePHYType,
+ OUT PBYTE pbyTxRate,
+ OUT PBYTE pbyRsvTime
+ )
+{
+ switch (byRate) {
+ case RATE_6M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9B;
+ *pbyRsvTime = 44;
+ }
+ else {
+ *pbyTxRate = 0x8B;
+ *pbyRsvTime = 50;
+ }
+ break;
+
+ case RATE_9M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9F;
+ *pbyRsvTime = 36;
+ }
+ else {
+ *pbyTxRate = 0x8F;
+ *pbyRsvTime = 42;
+ }
+ break;
+
+ case RATE_12M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9A;
+ *pbyRsvTime = 32;
+ }
+ else {
+ *pbyTxRate = 0x8A;
+ *pbyRsvTime = 38;
+ }
+ break;
+
+ case RATE_18M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9E;
+ *pbyRsvTime = 28;
+ }
+ else {
+ *pbyTxRate = 0x8E;
+ *pbyRsvTime = 34;
+ }
+ break;
+
+ case RATE_36M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9D;
+ *pbyRsvTime = 24;
+ }
+ else {
+ *pbyTxRate = 0x8D;
+ *pbyRsvTime = 30;
+ }
+ break;
+
+ case RATE_48M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x98;
+ *pbyRsvTime = 24;
+ }
+ else {
+ *pbyTxRate = 0x88;
+ *pbyRsvTime = 30;
+ }
+ break;
+
+ case RATE_54M :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9C;
+ *pbyRsvTime = 24;
+ }
+ else {
+ *pbyTxRate = 0x8C;
+ *pbyRsvTime = 30;
+ }
+ break;
+
+ case RATE_24M :
+ default :
+ if (ePHYType == PHY_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x99;
+ *pbyRsvTime = 28;
+ }
+ else {
+ *pbyTxRate = 0x89;
+ *pbyRsvTime = 34;
+ }
+ break;
+ }
+}
+
+
+
+/*
+ * Description: Set RSPINF
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+ */
+static
+VOID
+s_vSetRSPINF (PSDevice pDevice, CARD_PHY_TYPE ePHYType, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
+{
+ BYTE byServ = 0, bySignal = 0; // For CCK
+ WORD wLen = 0;
+ BYTE byTxRate = 0, byRsvTime = 0; // For OFDM
+
+ //Set to Page1
+ MACvSelectPage1(pDevice->PortOffset);
+
+ //RSPINF_b_1
+ BBvCaculateParameter(pDevice,
+ 14,
+ VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ ///RSPINF_b_2
+ BBvCaculateParameter(pDevice,
+ 14,
+ VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ //RSPINF_b_5
+ BBvCaculateParameter(pDevice,
+ 14,
+ VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ //RSPINF_b_11
+ BBvCaculateParameter(pDevice,
+ 14,
+ VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ //RSPINF_a_6
+ s_vCaculateOFDMRParameter(RATE_6M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_9
+ s_vCaculateOFDMRParameter(RATE_9M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_12
+ s_vCaculateOFDMRParameter(RATE_12M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_18
+ s_vCaculateOFDMRParameter(RATE_18M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_24
+ s_vCaculateOFDMRParameter(RATE_24M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_36
+ s_vCaculateOFDMRParameter(
+ VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_48
+ s_vCaculateOFDMRParameter(
+ VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_54
+ s_vCaculateOFDMRParameter(
+ VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_72
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
+ //Set to Page0
+ MACvSelectPage0(pDevice->PortOffset);
+}
+
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+BYTE CARDbyGetChannelMapping (PVOID pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType)
+{
+ UINT ii;
+
+ if ((ePhyType == PHY_TYPE_11B) || (ePhyType == PHY_TYPE_11G)) {
+ return (byChannelNumber);
+ }
+
+ for(ii = (CB_MAX_CHANNEL_24G + 1); ii <= CB_MAX_CHANNEL; ) {
+ if (sChannelTbl[ii].byChannelNumber == byChannelNumber) {
+ return ((BYTE) ii);
+ }
+ ii++;
+ }
+ return (0);
+}
+
+
+BYTE CARDbyGetChannelNumber (PVOID pDeviceHandler, BYTE byChannelIndex)
+{
+// PSDevice pDevice = (PSDevice) pDeviceHandler;
+ return(sChannelTbl[byChannelIndex].byChannelNumber);
+}
+
+/*
+ * Description: Set NIC media channel
+ *
+ * Parameters:
+ * In:
+ * pDeviceHandler - The adapter to be set
+ * uConnectionChannel - Channel to be set
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL CARDbSetChannel (PVOID pDeviceHandler, UINT uConnectionChannel)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BOOL bResult = TRUE;
+
+
+ if (pDevice->byCurrentCh == uConnectionChannel) {
+ return bResult;
+ }
+
+ if (sChannelTbl[uConnectionChannel].bValid == FALSE) {
+ return (FALSE);
+ }
+
+ if ((uConnectionChannel > CB_MAX_CHANNEL_24G) &&
+ (pDevice->eCurrentPHYType != PHY_TYPE_11A)) {
+ CARDbSetPhyParameter(pDevice, PHY_TYPE_11A, 0, 0, NULL, NULL);
+ } else if ((uConnectionChannel <= CB_MAX_CHANNEL_24G) &&
+ (pDevice->eCurrentPHYType == PHY_TYPE_11A)) {
+ CARDbSetPhyParameter(pDevice, PHY_TYPE_11G, 0, 0, NULL, NULL);
+ }
+ // clear NAV
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
+
+ //{{ RobertYu: 20041202
+ //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
+
+ if ( pDevice->byRFType == RF_AIROHA7230 )
+ {
+ RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (BYTE)uConnectionChannel);
+ }
+ //}} RobertYu
+
+
+ pDevice->byCurrentCh = (BYTE)uConnectionChannel;
+ bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (BYTE)uConnectionChannel);
+
+ // Init Synthesizer Table
+ if (pDevice->bEnablePSMode == TRUE)
+ RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel);
+
+
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDbSetMediaChannel: %d\n", (BYTE)uConnectionChannel);
+ BBvSoftwareReset(pDevice->PortOffset);
+
+ if (pDevice->byLocalID > REV_ID_VT3253_B1) {
+ // set HW default power register
+ MACvSelectPage1(pDevice->PortOffset);
+ RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr);
+ RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWROFDM, pDevice->byCurPwr);
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+#ifdef PLICE_DEBUG
+ //printk("Func:CARDbSetChannel:call RFbSetPower:11B\n");
+#endif
+ RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
+ } else {
+#ifdef PLICE_DEBUG
+ //printk("Func:CARDbSetChannel:call RFbSetPower\n");
+#endif
+ RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
+ }
+
+ return(bResult);
+}
+
+
+
+/*
+ * Description: Card Send packet function
+ *
+ * Parameters:
+ * In:
+ * pDeviceHandler - The adapter to be set
+ * pPacket - Packet buffer pointer
+ * ePktType - Packet type
+ * uLength - Packet length
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+/*
+BOOL CARDbSendPacket (PVOID pDeviceHandler, PVOID pPacket, CARD_PKT_TYPE ePktType, UINT uLength)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ if (ePktType == PKT_TYPE_802_11_MNG) {
+ return TXbTD0Send(pDevice, pPacket, uLength);
+ } else if (ePktType == PKT_TYPE_802_11_BCN) {
+ return TXbBeaconSend(pDevice, pPacket, uLength);
+ } if (ePktType == PKT_TYPE_802_11_DATA) {
+ return TXbTD1Send(pDevice, pPacket, uLength);
+ }
+
+ return (TRUE);
+}
+*/
+
+
+/*
+ * Description: Get Card short preamble option value
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if short preamble; otherwise FALSE
+ *
+ */
+BOOL CARDbIsShortPreamble (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ if (pDevice->byPreambleType == 0) {
+ return(FALSE);
+ }
+ return(TRUE);
+}
+
+/*
+ * Description: Get Card short slot time option value
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if short slot time; otherwise FALSE
+ *
+ */
+BOOL CARDbIsShorSlotTime (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ return(pDevice->bShortSlotTime);
+}
+
+
+/*
+ * Description: Update IFS
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+ */
+BOOL CARDbSetPhyParameter (PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType, WORD wCapInfo, BYTE byERPField, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BYTE byCWMaxMin = 0;
+ BYTE bySlot = 0;
+ BYTE bySIFS = 0;
+ BYTE byDIFS = 0;
+ BYTE byData;
+// PWLAN_IE_SUPP_RATES pRates = NULL;
+ PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs;
+ PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs;
+
+
+ //Set SIFS, DIFS, EIFS, SlotTime, CwMin
+ if (ePHYType == PHY_TYPE_11A) {
+ if (pSupportRates == NULL) {
+ pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA;
+ }
+ if (pDevice->byRFType == RF_AIROHA7230) {
+ // AL7230 use single PAPE and connect to PAPE_2.4G
+ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
+ pDevice->abyBBVGA[0] = 0x20;
+ pDevice->abyBBVGA[2] = 0x10;
+ pDevice->abyBBVGA[3] = 0x10;
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
+ if (byData == 0x1C) {
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
+ }
+ } else if (pDevice->byRFType == RF_UW2452) {
+ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
+ pDevice->abyBBVGA[0] = 0x18;
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
+ if (byData == 0x14) {
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0x57);
+ }
+ } else {
+ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
+ }
+ BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x03);
+ bySlot = C_SLOT_SHORT;
+ bySIFS = C_SIFS_A;
+ byDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
+ byCWMaxMin = 0xA4;
+ } else if (ePHYType == PHY_TYPE_11B) {
+ if (pSupportRates == NULL) {
+ pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB;
+ }
+ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B);
+ if (pDevice->byRFType == RF_AIROHA7230) {
+ pDevice->abyBBVGA[0] = 0x1C;
+ pDevice->abyBBVGA[2] = 0x00;
+ pDevice->abyBBVGA[3] = 0x00;
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
+ if (byData == 0x20) {
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
+ }
+ } else if (pDevice->byRFType == RF_UW2452) {
+ pDevice->abyBBVGA[0] = 0x14;
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
+ if (byData == 0x18) {
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0xD3);
+ }
+ }
+ BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x02);
+ bySlot = C_SLOT_LONG;
+ bySIFS = C_SIFS_BG;
+ byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
+ byCWMaxMin = 0xA5;
+ } else {// PK_TYPE_11GA & PK_TYPE_11GB
+ if (pSupportRates == NULL) {
+ pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG;
+ pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG;
+ }
+ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
+ if (pDevice->byRFType == RF_AIROHA7230) {
+ pDevice->abyBBVGA[0] = 0x1C;
+ pDevice->abyBBVGA[2] = 0x00;
+ pDevice->abyBBVGA[3] = 0x00;
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
+ if (byData == 0x20) {
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
+ }
+ } else if (pDevice->byRFType == RF_UW2452) {
+ pDevice->abyBBVGA[0] = 0x14;
+ BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
+ if (byData == 0x18) {
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
+ BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0xD3);
+ }
+ }
+ BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x08);
+ bySIFS = C_SIFS_BG;
+ if(VNTWIFIbIsShortSlotTime(wCapInfo)) {
+ bySlot = C_SLOT_SHORT;
+ byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT;
+ } else {
+ bySlot = C_SLOT_LONG;
+ byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
+ }
+ if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) {
+ byCWMaxMin = 0xA4;
+ } else {
+ byCWMaxMin = 0xA5;
+ }
+ if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) {
+ pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField);
+ if (pDevice->bProtectMode) {
+ MACvEnableProtectMD(pDevice->PortOffset);
+ } else {
+ MACvDisableProtectMD(pDevice->PortOffset);
+ }
+ }
+ if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) {
+ pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField);
+ if (pDevice->bBarkerPreambleMd) {
+ MACvEnableBarkerPreambleMd(pDevice->PortOffset);
+ } else {
+ MACvDisableBarkerPreambleMd(pDevice->PortOffset);
+ }
+ }
+ }
+
+ if (pDevice->byRFType == RF_RFMD2959) {
+ // bcs TX_PE will reserve 3 us
+ // hardware's processing time here is 2 us.
+ bySIFS -= 3;
+ byDIFS -= 3;
+ //{{ RobertYu: 20041202
+ //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
+ //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us.
+ }
+
+ if (pDevice->bySIFS != bySIFS) {
+ pDevice->bySIFS = bySIFS;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, pDevice->bySIFS);
+ }
+ if (pDevice->byDIFS != byDIFS) {
+ pDevice->byDIFS = byDIFS;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, pDevice->byDIFS);
+ }
+ if (pDevice->byEIFS != C_EIFS) {
+ pDevice->byEIFS = C_EIFS;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, pDevice->byEIFS);
+ }
+ if (pDevice->bySlot != bySlot) {
+ pDevice->bySlot = bySlot;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot);
+ if (pDevice->bySlot == C_SLOT_SHORT) {
+ pDevice->bShortSlotTime = TRUE;
+ } else {
+ pDevice->bShortSlotTime = FALSE;
+ }
+ BBvSetShortSlotTime(pDevice);
+ }
+ if (pDevice->byCWMaxMin != byCWMaxMin) {
+ pDevice->byCWMaxMin = byCWMaxMin;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin);
+ }
+ if (VNTWIFIbIsShortPreamble(wCapInfo)) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ } else {
+ pDevice->byPreambleType = 0;
+ }
+ s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates);
+ pDevice->eCurrentPHYType = ePHYType;
+ // set for NDIS OID_802_11SUPPORTED_RATES
+ return (TRUE);
+}
+
+/*
+ * Description: Sync. TSF counter to BSS
+ * Get TSF offset and write to HW
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be sync.
+ * byRxRate - data rate of receive beacon
+ * qwBSSTimestamp - Rx BCN's TSF
+ * qwLocalTSF - Local TSF
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+BOOL CARDbUpdateTSF (PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ QWORD qwTSFOffset;
+
+ HIDWORD(qwTSFOffset) = 0;
+ LODWORD(qwTSFOffset) = 0;
+
+ if ((HIDWORD(qwBSSTimestamp) != HIDWORD(qwLocalTSF)) ||
+ (LODWORD(qwBSSTimestamp) != LODWORD(qwLocalTSF))) {
+ qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
+ // adjust TSF
+ // HW's TSF add TSF Offset reg
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, LODWORD(qwTSFOffset));
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, HIDWORD(qwTSFOffset));
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN);
+ }
+ return(TRUE);
+}
+
+
+/*
+ * Description: Set NIC TSF counter for first Beacon time
+ * Get NEXTTBTT from adjusted TSF and Beacon Interval
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set.
+ * wBeaconInterval - Beacon Interval
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeed; otherwise FALSE
+ *
+ */
+BOOL CARDbSetBeaconPeriod (PVOID pDeviceHandler, WORD wBeaconInterval)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT uBeaconInterval = 0;
+ UINT uLowNextTBTT = 0;
+ UINT uHighRemain = 0;
+ UINT uLowRemain = 0;
+ QWORD qwNextTBTT;
+
+ HIDWORD(qwNextTBTT) = 0;
+ LODWORD(qwNextTBTT) = 0;
+ CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); //Get Local TSF counter
+ uBeaconInterval = wBeaconInterval * 1024;
+ // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
+ uLowNextTBTT = (LODWORD(qwNextTBTT) >> 10) << 10;
+ uLowRemain = (uLowNextTBTT) % uBeaconInterval;
+ // high dword (mod) bcn
+ uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwNextTBTT))
+ % uBeaconInterval;
+ uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
+ uLowRemain = uBeaconInterval - uLowRemain;
+
+ // check if carry when add one beacon interval
+ if ((~uLowNextTBTT) < uLowRemain) {
+ HIDWORD(qwNextTBTT) ++ ;
+ }
+ LODWORD(qwNextTBTT) = uLowNextTBTT + uLowRemain;
+
+ // set HW beacon interval
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval);
+ pDevice->wBeaconInterval = wBeaconInterval;
+ // Set NextTBTT
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT));
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT));
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
+
+ return(TRUE);
+}
+
+
+
+/*
+ * Description: Card Stop Hardware Tx
+ *
+ * Parameters:
+ * In:
+ * pDeviceHandler - The adapter to be set
+ * ePktType - Packet type to stop
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all data packet complete; otherwise FALSE.
+ *
+ */
+BOOL CARDbStopTxPacket (PVOID pDeviceHandler, CARD_PKT_TYPE ePktType)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+
+ if (ePktType == PKT_TYPE_802_11_ALL) {
+ pDevice->bStopBeacon = TRUE;
+ pDevice->bStopTx0Pkt = TRUE;
+ pDevice->bStopDataPkt = TRUE;
+ } else if (ePktType == PKT_TYPE_802_11_BCN) {
+ pDevice->bStopBeacon = TRUE;
+ } else if (ePktType == PKT_TYPE_802_11_MNG) {
+ pDevice->bStopTx0Pkt = TRUE;
+ } else if (ePktType == PKT_TYPE_802_11_DATA) {
+ pDevice->bStopDataPkt = TRUE;
+ }
+
+ if (pDevice->bStopBeacon == TRUE) {
+ if (pDevice->bIsBeaconBufReadySet == TRUE) {
+ if (pDevice->cbBeaconBufReadySetCnt < WAIT_BEACON_TX_DOWN_TMO) {
+ pDevice->cbBeaconBufReadySetCnt ++;
+ return(FALSE);
+ }
+ }
+ pDevice->bIsBeaconBufReadySet = FALSE;
+ pDevice->cbBeaconBufReadySetCnt = 0;
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+ // wait all TD0 complete
+ if (pDevice->bStopTx0Pkt == TRUE) {
+ if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
+ return(FALSE);
+ }
+ }
+ // wait all Data TD complete
+ if (pDevice->bStopDataPkt == TRUE) {
+ if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
+ return(FALSE);
+ }
+ }
+
+ return(TRUE);
+}
+
+
+/*
+ * Description: Card Start Hardware Tx
+ *
+ * Parameters:
+ * In:
+ * pDeviceHandler - The adapter to be set
+ * ePktType - Packet type to start
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; FALSE if failed.
+ *
+ */
+BOOL CARDbStartTxPacket (PVOID pDeviceHandler, CARD_PKT_TYPE ePktType)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+
+ if (ePktType == PKT_TYPE_802_11_ALL) {
+ pDevice->bStopBeacon = FALSE;
+ pDevice->bStopTx0Pkt = FALSE;
+ pDevice->bStopDataPkt = FALSE;
+ } else if (ePktType == PKT_TYPE_802_11_BCN) {
+ pDevice->bStopBeacon = FALSE;
+ } else if (ePktType == PKT_TYPE_802_11_MNG) {
+ pDevice->bStopTx0Pkt = FALSE;
+ } else if (ePktType == PKT_TYPE_802_11_DATA) {
+ pDevice->bStopDataPkt = FALSE;
+ }
+
+ if ((pDevice->bStopBeacon == FALSE) &&
+ (pDevice->bBeaconBufReady == TRUE) &&
+ (pDevice->eOPMode == OP_MODE_ADHOC)) {
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+
+ return(TRUE);
+}
+
+
+
+/*
+ * Description: Card Set BSSID value
+ *
+ * Parameters:
+ * In:
+ * pDeviceHandler - The adapter to be set
+ * pbyBSSID - pointer to BSSID field
+ * bAdhoc - flag to indicate IBSS
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; FALSE if failed.
+ *
+ */
+BOOL CARDbSetBSSID(PVOID pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID);
+ MEMvCopy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN);
+ if (eOPMode == OP_MODE_ADHOC) {
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
+ } else {
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
+ }
+ if (eOPMode == OP_MODE_AP) {
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
+ } else {
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
+ }
+ if (eOPMode == OP_MODE_UNKNOWN) {
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
+ pDevice->bBSSIDFilter = FALSE;
+ pDevice->byRxMode &= ~RCR_BSSID;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
+ } else {
+ if (IS_NULL_ADDRESS(pDevice->abyBSSID) == FALSE) {
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
+ pDevice->bBSSIDFilter = TRUE;
+ pDevice->byRxMode |= RCR_BSSID;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: rx_mode = %x\n", pDevice->byRxMode );
+ }
+ // Adopt BSS state in Adapter Device Object
+ pDevice->eOPMode = eOPMode;
+ return(TRUE);
+}
+
+
+/*
+ * Description: Card indicate status
+ *
+ * Parameters:
+ * In:
+ * pDeviceHandler - The adapter to be set
+ * eStatus - Status
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; FALSE if failed.
+ *
+ */
+
+
+
+
+/*
+ * Description: Save Assoc info. contain in assoc. response frame
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wCapabilityInfo - Capability information
+ * wStatus - Status code
+ * wAID - Assoc. ID
+ * uLen - Length of IEs
+ * pbyIEs - pointer to IEs
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeed; otherwise FALSE
+ *
+ */
+BOOL CARDbSetTxDataRate(
+ PVOID pDeviceHandler,
+ WORD wDataRate
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ pDevice->wCurrentRate = wDataRate;
+ return(TRUE);
+}
+
+/*+
+ *
+ * Routine Description:
+ * Consider to power down when no more packets to tx or rx.
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if power down success; otherwise FALSE
+ *
+-*/
+BOOL
+CARDbPowerDown(
+ PVOID pDeviceHandler
+ )
+{
+ PSDevice pDevice = (PSDevice)pDeviceHandler;
+ UINT uIdx;
+
+ // check if already in Doze mode
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
+ return TRUE;
+
+ // Froce PSEN on
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
+
+ // check if all TD are empty,
+
+ for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
+ if (pDevice->iTDUsed[uIdx] != 0)
+ return FALSE;
+ }
+
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Go to Doze ZZZZZZZZZZZZZZZ\n");
+ return TRUE;
+}
+
+/*
+ * Description: Turn off Radio power
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be turned off
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL CARDbRadioPowerOff (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BOOL bResult = TRUE;
+
+ if (pDevice->bRadioOff == TRUE)
+ return TRUE;
+
+
+ switch (pDevice->byRFType) {
+
+ case RF_RFMD2959:
+ MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
+ MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
+ break;
+
+ case RF_AIROHA:
+ case RF_AL2230S:
+ case RF_AIROHA7230: //RobertYu:20050104
+ MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2);
+ MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
+ break;
+
+ }
+
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
+
+ BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
+
+ pDevice->bRadioOff = TRUE;
+ //2007-0409-03,<Add> by chester
+printk("chester power off\n");
+MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
+ return bResult;
+}
+
+
+/*
+ * Description: Turn on Radio power
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be turned on
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL CARDbRadioPowerOn (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BOOL bResult = TRUE;
+printk("chester power on\n");
+ if (pDevice->bRadioControlOff == TRUE){
+if (pDevice->bHWRadioOff == TRUE) printk("chester bHWRadioOff\n");
+if (pDevice->bRadioControlOff == TRUE) printk("chester bRadioControlOff\n");
+ return FALSE;}
+
+ if (pDevice->bRadioOff == FALSE)
+ {
+printk("chester pbRadioOff\n");
+return TRUE;}
+
+ BBvExitDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
+
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
+
+ switch (pDevice->byRFType) {
+
+ case RF_RFMD2959:
+ MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
+ MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
+ break;
+
+ case RF_AIROHA:
+ case RF_AL2230S:
+ case RF_AIROHA7230: //RobertYu:20050104
+ MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 |
+ SOFTPWRCTL_SWPE3));
+ break;
+
+ }
+
+ pDevice->bRadioOff = FALSE;
+// 2007-0409-03,<Add> by chester
+printk("chester power on\n");
+MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
+ return bResult;
+}
+
+
+
+BOOL CARDbRemoveKey (PVOID pDeviceHandler, PBYTE pbyBSSID)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset);
+ return (TRUE);
+}
+
+
+/*
+ *
+ * Description:
+ * Add BSSID in PMKID Candidate list.
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * pbyBSSID - BSSID address for adding
+ * wRSNCap - BSS's RSN capability
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+CARDbAdd_PMKID_Candidate (
+ IN PVOID pDeviceHandler,
+ IN PBYTE pbyBSSID,
+ IN BOOL bRSNCapExist,
+ IN WORD wRSNCap
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ PPMKID_CANDIDATE pCandidateList;
+ UINT ii = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
+
+ if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFlush_PMKID_Candidate: 3\n");
+ ZERO_MEMORY(&pDevice->gsPMKIDCandidate, sizeof(SPMKIDCandidateEvent));
+ }
+
+ for (ii = 0; ii < 6; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02X ", *(pbyBSSID + ii));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+
+ // Update Old Candidate
+ for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
+ pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
+ if (MEMEqualMemory(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN)) {
+ if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
+ pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
+ } else {
+ pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
+ }
+ return TRUE;
+ }
+ }
+
+ // New Candidate
+ pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
+ if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
+ pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
+ } else {
+ pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
+ }
+ MEMvCopy(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN);
+ pDevice->gsPMKIDCandidate.NumCandidates++;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
+ return TRUE;
+}
+
+PVOID
+CARDpGetCurrentAddress (
+ IN PVOID pDeviceHandler
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ return (pDevice->abyCurrentNetAddr);
+}
+
+
+
+VOID CARDvInitChannelTable (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BOOL bMultiBand = FALSE;
+ UINT ii;
+
+ for(ii=1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
+ sChannelTbl[ii].bValid = FALSE;
+ }
+
+ switch (pDevice->byRFType) {
+ case RF_RFMD2959 :
+ case RF_AIROHA :
+ case RF_AL2230S:
+ case RF_UW2451 :
+ case RF_VT3226 :
+ // printk("chester-false\n");
+ bMultiBand = FALSE;
+ break;
+ case RF_AIROHA7230 :
+ case RF_UW2452 :
+ case RF_NOTHING :
+ default :
+ bMultiBand = TRUE;
+ break;
+ }
+
+ if ((pDevice->dwDiagRefCount != 0) ||
+ (pDevice->b11hEnable == TRUE)) {
+ if (bMultiBand == TRUE) {
+ for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
+ sChannelTbl[ii+1].bValid = TRUE;
+ pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
+ pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
+ }
+ for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
+ pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
+ pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
+ }
+ } else {
+ for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
+//2008-8-4 <add> by chester
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
+ sChannelTbl[ii+1].bValid = TRUE;
+ pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
+ pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
+ }
+ }
+ }
+ } else if (pDevice->byZoneType <= CCODE_MAX) {
+ if (bMultiBand == TRUE) {
+ for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
+ sChannelTbl[ii+1].bValid = TRUE;
+ pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
+ pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
+ }
+ }
+ } else {
+ for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
+ sChannelTbl[ii+1].bValid = TRUE;
+ pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
+ pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
+ }
+ }
+ }
+ }
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO"Zone=[%d][%c][%c]!!\n",pDevice->byZoneType,ChannelRuleTab[pDevice->byZoneType].chCountryCode[0],ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]);
+ for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
+ if (pDevice->abyRegPwr[ii+1] == 0) {
+ pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
+ }
+ if (pDevice->abyLocalPwr[ii+1] == 0) {
+ pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
+ }
+ }
+}
+
+
+
+/*
+ *
+ * Description:
+ * Start Spectrum Measure defined in 802.11h
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+CARDbStartMeasure (
+ IN PVOID pDeviceHandler,
+ IN PVOID pvMeasureEIDs,
+ IN UINT uNumOfMeasureEIDs
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ PWLAN_IE_MEASURE_REQ pEID = (PWLAN_IE_MEASURE_REQ) pvMeasureEIDs;
+ QWORD qwCurrTSF;
+ QWORD qwStartTSF;
+ BOOL bExpired = TRUE;
+ WORD wDuration = 0;
+
+ if ((pEID == NULL) ||
+ (uNumOfMeasureEIDs == 0)) {
+ return (TRUE);
+ }
+ CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
+ if (pDevice->bMeasureInProgress == TRUE) {
+ pDevice->bMeasureInProgress = FALSE;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR);
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4);
+ // clear measure control
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
+ MACvSelectPage0(pDevice->PortOffset);
+ CARDbSetChannel(pDevice, pDevice->byOrgChannel);
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+ pDevice->uNumOfMeasureEIDs = uNumOfMeasureEIDs;
+
+ do {
+ pDevice->pCurrMeasureEID = pEID;
+ pEID++;
+ pDevice->uNumOfMeasureEIDs--;
+
+ if (pDevice->byLocalID > REV_ID_VT3253_B1) {
+ HIDWORD(qwStartTSF) = HIDWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime)));
+ LODWORD(qwStartTSF) = LODWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime)));
+ wDuration = *((PWORD) (pDevice->pCurrMeasureEID->sReq.abyDuration));
+ wDuration += 1; // 1 TU for channel switching
+
+ if ((LODWORD(qwStartTSF) == 0) && (HIDWORD(qwStartTSF) == 0)) {
+ // start imediately by setting start TSF == current TSF + 2 TU
+ LODWORD(qwStartTSF) = LODWORD(qwCurrTSF) + 2048;
+ HIDWORD(qwStartTSF) = HIDWORD(qwCurrTSF);
+ if (LODWORD(qwCurrTSF) > LODWORD(qwStartTSF)) {
+ HIDWORD(qwStartTSF)++;
+ }
+ bExpired = FALSE;
+ break;
+ } else {
+ // start at setting start TSF - 1TU(for channel switching)
+ if (LODWORD(qwStartTSF) < 1024) {
+ HIDWORD(qwStartTSF)--;
+ }
+ LODWORD(qwStartTSF) -= 1024;
+ }
+
+ if ((HIDWORD(qwCurrTSF) < HIDWORD(qwStartTSF)) ||
+ ((HIDWORD(qwCurrTSF) == HIDWORD(qwStartTSF)) &&
+ (LODWORD(qwCurrTSF) < LODWORD(qwStartTSF)))
+ ) {
+ bExpired = FALSE;
+ break;
+ }
+ VNTWIFIbMeasureReport( pDevice->pMgmt,
+ FALSE,
+ pDevice->pCurrMeasureEID,
+ MEASURE_MODE_LATE,
+ pDevice->byBasicMap,
+ pDevice->byCCAFraction,
+ pDevice->abyRPIs
+ );
+ } else {
+ // hardware do not support measure
+ VNTWIFIbMeasureReport( pDevice->pMgmt,
+ FALSE,
+ pDevice->pCurrMeasureEID,
+ MEASURE_MODE_INCAPABLE,
+ pDevice->byBasicMap,
+ pDevice->byCCAFraction,
+ pDevice->abyRPIs
+ );
+ }
+ } while (pDevice->uNumOfMeasureEIDs != 0);
+
+ if (bExpired == FALSE) {
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART, LODWORD(qwStartTSF));
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART + 4, HIDWORD(qwStartTSF));
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_MSRDURATION, wDuration);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
+ MACvSelectPage0(pDevice->PortOffset);
+ } else {
+ // all measure start time expired we should complete action
+ VNTWIFIbMeasureReport( pDevice->pMgmt,
+ TRUE,
+ NULL,
+ 0,
+ pDevice->byBasicMap,
+ pDevice->byCCAFraction,
+ pDevice->abyRPIs
+ );
+ }
+ return (TRUE);
+}
+
+
+/*
+ *
+ * Description:
+ * Do Channel Switch defined in 802.11h
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+CARDbChannelSwitch (
+ IN PVOID pDeviceHandler,
+ IN BYTE byMode,
+ IN BYTE byNewChannel,
+ IN BYTE byCount
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BOOL bResult = TRUE;
+
+ if (byCount == 0) {
+ bResult = CARDbSetChannel(pDevice, byNewChannel);
+ VNTWIFIbChannelSwitch(pDevice->pMgmt, byNewChannel);
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
+ MACvSelectPage0(pDevice->PortOffset);
+ return(bResult);
+ }
+ pDevice->byChannelSwitchCount = byCount;
+ pDevice->byNewChannel = byNewChannel;
+ pDevice->bChannelSwitch = TRUE;
+ if (byMode == 1) {
+ bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
+ }
+ return (bResult);
+}
+
+
+/*
+ *
+ * Description:
+ * Handle Quiet EID defined in 802.11h
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+CARDbSetQuiet (
+ IN PVOID pDeviceHandler,
+ IN BOOL bResetQuiet,
+ IN BYTE byQuietCount,
+ IN BYTE byQuietPeriod,
+ IN WORD wQuietDuration,
+ IN WORD wQuietOffset
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii = 0;
+
+ if (bResetQuiet == TRUE) {
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
+ for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
+ pDevice->sQuiet[ii].bEnable = FALSE;
+ }
+ pDevice->uQuietEnqueue = 0;
+ pDevice->bEnableFirstQuiet = FALSE;
+ pDevice->bQuietEnable = FALSE;
+ pDevice->byQuietStartCount = byQuietCount;
+ }
+ if (pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable == FALSE) {
+ pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable = TRUE;
+ pDevice->sQuiet[pDevice->uQuietEnqueue].byPeriod = byQuietPeriod;
+ pDevice->sQuiet[pDevice->uQuietEnqueue].wDuration = wQuietDuration;
+ pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime = (DWORD) byQuietCount;
+ pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime *= pDevice->wBeaconInterval;
+ pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset;
+ pDevice->uQuietEnqueue++;
+ pDevice->uQuietEnqueue %= MAX_QUIET_COUNT;
+ if (pDevice->byQuietStartCount < byQuietCount) {
+ pDevice->byQuietStartCount = byQuietCount;
+ }
+ } else {
+ // we can not handle Quiet EID more
+ }
+ return (TRUE);
+}
+
+
+/*
+ *
+ * Description:
+ * Do Quiet, It will called by either ISR (after start) or VNTWIFI (before start) so do not need SPINLOCK
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+CARDbStartQuiet (
+ IN PVOID pDeviceHandler
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii = 0;
+ DWORD dwStartTime = 0xFFFFFFFF;
+ UINT uCurrentQuietIndex = 0;
+ DWORD dwNextTime = 0;
+ DWORD dwGap = 0;
+ DWORD dwDuration = 0;
+
+ for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
+ if ((pDevice->sQuiet[ii].bEnable == TRUE) &&
+ (dwStartTime > pDevice->sQuiet[ii].dwStartTime)) {
+ dwStartTime = pDevice->sQuiet[ii].dwStartTime;
+ uCurrentQuietIndex = ii;
+ }
+ }
+ if (dwStartTime == 0xFFFFFFFF) {
+ // no more quiet
+ pDevice->bQuietEnable = FALSE;
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
+ } else {
+ if (pDevice->bQuietEnable == FALSE) {
+ // first quiet
+ pDevice->byQuietStartCount--;
+ dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
+ dwNextTime %= pDevice->wBeaconInterval;
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETINIT, (WORD) dwNextTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (WORD) pDevice->sQuiet[uCurrentQuietIndex].wDuration);
+ if (pDevice->byQuietStartCount == 0) {
+ pDevice->bEnableFirstQuiet = FALSE;
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
+ } else {
+ pDevice->bEnableFirstQuiet = TRUE;
+ }
+ MACvSelectPage0(pDevice->PortOffset);
+ } else {
+ if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) {
+ // overlap with previous Quiet
+ dwGap = pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
+ if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) {
+ // return FALSE to indicate next quiet expired, should call this function again
+ return (FALSE);
+ }
+ dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap;
+ dwGap = 0;
+ } else {
+ dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime;
+ dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration;
+ }
+ // set GAP and Next duration
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (WORD) dwGap);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (WORD) dwDuration);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_QUIETRPT);
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+ pDevice->bQuietEnable = TRUE;
+ pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
+ pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration;
+ if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) {
+ // not period disable current quiet element
+ pDevice->sQuiet[uCurrentQuietIndex].bEnable = FALSE;
+ } else {
+ // set next period start time
+ dwNextTime = (DWORD) pDevice->sQuiet[uCurrentQuietIndex].byPeriod;
+ dwNextTime *= pDevice->wBeaconInterval;
+ pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime;
+ }
+ if (pDevice->dwCurrentQuietEndTime > 0x80010000) {
+ // decreament all time to avoid wrap around
+ for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
+ if (pDevice->sQuiet[ii].bEnable == TRUE) {
+ pDevice->sQuiet[ii].dwStartTime -= 0x80000000;
+ }
+ }
+ pDevice->dwCurrentQuietEndTime -= 0x80000000;
+ }
+ }
+ return (TRUE);
+}
+
+
+/*
+ *
+ * Description:
+ * Set Channel Info of Country
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+CARDvSetCountryInfo (
+ IN PVOID pDeviceHandler,
+ IN CARD_PHY_TYPE ePHYType,
+ IN PVOID pIE
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii = 0;
+ UINT uu = 0;
+ UINT step = 0;
+ UINT uNumOfCountryInfo = 0;
+ BYTE byCh = 0;
+ PWLAN_IE_COUNTRY pIE_Country = (PWLAN_IE_COUNTRY) pIE;
+
+
+ uNumOfCountryInfo = (pIE_Country->len - 3);
+ uNumOfCountryInfo /= 3;
+
+ if (ePHYType == PHY_TYPE_11A) {
+ pDevice->bCountryInfo5G = TRUE;
+ for(ii=CB_MAX_CHANNEL_24G+1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
+ sChannelTbl[ii].bValid = FALSE;
+ }
+ step = 4;
+ } else {
+ pDevice->bCountryInfo24G = TRUE;
+ for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
+ sChannelTbl[ii].bValid = FALSE;
+ }
+ step = 1;
+ }
+ pDevice->abyCountryCode[0] = pIE_Country->abyCountryString[0];
+ pDevice->abyCountryCode[1] = pIE_Country->abyCountryString[1];
+ pDevice->abyCountryCode[2] = pIE_Country->abyCountryString[2];
+
+ for(ii=0;ii<uNumOfCountryInfo;ii++) {
+ for(uu=0;uu<pIE_Country->abyCountryInfo[ii*3+1];uu++) {
+ byCh = CARDbyGetChannelMapping(pDevice, (BYTE)(pIE_Country->abyCountryInfo[ii*3]+step*uu), ePHYType);
+ sChannelTbl[byCh].bValid = TRUE;
+ pDevice->abyRegPwr[byCh] = pIE_Country->abyCountryInfo[ii*3+2];
+ }
+ }
+}
+
+/*
+ *
+ * Description:
+ * Set Local Power Constraint
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+CARDvSetPowerConstraint (
+ IN PVOID pDeviceHandler,
+ IN BYTE byChannel,
+ IN I8 byPower
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ if (byChannel > CB_MAX_CHANNEL_24G) {
+ if (pDevice->bCountryInfo5G == TRUE) {
+ pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
+ }
+ } else {
+ if (pDevice->bCountryInfo24G == TRUE) {
+ pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
+ }
+ }
+}
+
+
+/*
+ *
+ * Description:
+ * Set Local Power Constraint
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+CARDvGetPowerCapability (
+ IN PVOID pDeviceHandler,
+ OUT PBYTE pbyMinPower,
+ OUT PBYTE pbyMaxPower
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BYTE byDec = 0;
+
+ *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh];
+ byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh];
+ if (pDevice->byRFType == RF_UW2452) {
+ byDec *= 3;
+ byDec >>= 1;
+ } else {
+ byDec <<= 1;
+ }
+ *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec;
+}
+
+
+/*
+ *
+ * Description:
+ * Set Support Channels IE defined in 802.11h
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BYTE
+CARDbySetSupportChannels (
+ IN PVOID pDeviceHandler,
+ IN OUT PBYTE pbyIEs
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii;
+ BYTE byCount;
+ PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs;
+ PBYTE pbyChTupple;
+ BYTE byLen = 0;
+
+
+ pIE->byElementID = WLAN_EID_SUPP_CH;
+ pIE->len = 0;
+ pbyChTupple = pIE->abyChannelTuple;
+ byLen = 2;
+ // lower band
+ byCount = 0;
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == TRUE) {
+ for (ii=28;ii<36;ii+=2) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
+ byCount++;
+ }
+ }
+ *pbyChTupple++ = 34;
+ *pbyChTupple++ = byCount;
+ byLen += 2;
+ } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[29] == TRUE) {
+ for (ii=29;ii<36;ii+=2) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
+ byCount++;
+ }
+ }
+ *pbyChTupple++ = 36;
+ *pbyChTupple++ = byCount;
+ byLen += 2;
+ }
+ // middle band
+ byCount = 0;
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == TRUE) {
+ for (ii=36;ii<40;ii++) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
+ byCount++;
+ }
+ }
+ *pbyChTupple++ = 52;
+ *pbyChTupple++ = byCount;
+ byLen += 2;
+ }
+ // higher band
+ byCount = 0;
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == TRUE) {
+ for (ii=40;ii<51;ii++) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
+ byCount++;
+ }
+ }
+ *pbyChTupple++ = 100;
+ *pbyChTupple++ = byCount;
+ byLen += 2;
+ } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == TRUE) {
+ for (ii=51;ii<56;ii++) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
+ byCount++;
+ }
+ }
+ *pbyChTupple++ = 149;
+ *pbyChTupple++ = byCount;
+ byLen += 2;
+ }
+ pIE->len += (byLen - 2);
+ return (byLen);
+}
+
+
+/*
+ *
+ * Description:
+ * Get Current Tx Power
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+I8
+CARDbyGetTransmitPower (
+ IN PVOID pDeviceHandler
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ return (pDevice->byCurPwrdBm);
+}
+
+
+BOOL
+CARDbChannelGetList (
+ IN UINT uCountryCodeIdx,
+ OUT PBYTE pbyChannelTable
+ )
+{
+ if (uCountryCodeIdx >= CCODE_MAX) {
+ return (FALSE);
+ }
+ MEMvCopy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL);
+ return (TRUE);
+}
+
+
+VOID
+CARDvSetCountryIE(
+ IN PVOID pDeviceHandler,
+ IN PVOID pIE
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii;
+ PWLAN_IE_COUNTRY pIECountry = (PWLAN_IE_COUNTRY) pIE;
+
+ pIECountry->byElementID = WLAN_EID_COUNTRY;
+ pIECountry->len = 0;
+ pIECountry->abyCountryString[0] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[0];
+ pIECountry->abyCountryString[1] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[1];
+ pIECountry->abyCountryString[2] = ' ';
+ for (ii = CB_MAX_CHANNEL_24G; ii < CB_MAX_CHANNEL; ii++ ) {
+ if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
+ pIECountry->abyCountryInfo[pIECountry->len++] = sChannelTbl[ii+1].byChannelNumber;
+ pIECountry->abyCountryInfo[pIECountry->len++] = 1;
+ pIECountry->abyCountryInfo[pIECountry->len++] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
+ }
+ }
+ pIECountry->len += 3;
+}
+
+
+BOOL
+CARDbGetChannelMapInfo(
+ IN PVOID pDeviceHandler,
+ IN UINT uChannelIndex,
+ OUT PBYTE pbyChannelNumber,
+ OUT PBYTE pbyMap
+ )
+{
+// PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ if (uChannelIndex > CB_MAX_CHANNEL) {
+ return FALSE;
+ }
+ *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber;
+ *pbyMap = sChannelTbl[uChannelIndex].byMAP;
+ return sChannelTbl[uChannelIndex].bValid;
+}
+
+
+VOID
+CARDvSetChannelMapInfo(
+ IN PVOID pDeviceHandler,
+ IN UINT uChannelIndex,
+ IN BYTE byMap
+ )
+{
+// PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ if (uChannelIndex > CB_MAX_CHANNEL) {
+ return;
+ }
+ sChannelTbl[uChannelIndex].byMAP |= byMap;
+}
+
+
+VOID
+CARDvClearChannelMapInfo(
+ IN PVOID pDeviceHandler
+ )
+{
+// PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii = 0;
+
+ for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) {
+ sChannelTbl[ii].byMAP = 0;
+ }
+}
+
+
+BYTE
+CARDbyAutoChannelSelect(
+ IN PVOID pDeviceHandler,
+ CARD_PHY_TYPE ePHYType
+ )
+{
+// PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii = 0;
+ BYTE byOptionChannel = 0;
+ INT aiWeight[CB_MAX_CHANNEL_24G+1] = {-1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+
+ if (ePHYType == PHY_TYPE_11A) {
+ for(ii=CB_MAX_CHANNEL_24G+1;ii<=CB_MAX_CHANNEL;ii++) {
+ if (sChannelTbl[ii].bValid == TRUE) {
+ if (byOptionChannel == 0) {
+ byOptionChannel = (BYTE) ii;
+ }
+ if (sChannelTbl[ii].byMAP == 0) {
+ return ((BYTE) ii);
+ } else if (BITbIsBitOff(sChannelTbl[ii].byMAP, 0x08)) {
+ byOptionChannel = (BYTE) ii;
+ }
+ }
+ }
+ } else {
+ byOptionChannel = 0;
+ for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
+ if (sChannelTbl[ii].bValid == TRUE) {
+ if (sChannelTbl[ii].byMAP == 0) {
+ aiWeight[ii] += 100;
+ } else if (BITbIsBitOn(sChannelTbl[ii].byMAP, 0x01)) {
+ if (ii > 3) {
+ aiWeight[ii-3] -= 10;
+ }
+ if (ii > 2) {
+ aiWeight[ii-2] -= 20;
+ }
+ if (ii > 1) {
+ aiWeight[ii-1] -= 40;
+ }
+ aiWeight[ii] -= 80;
+ if (ii < CB_MAX_CHANNEL_24G) {
+ aiWeight[ii+1] -= 40;
+ }
+ if (ii < (CB_MAX_CHANNEL_24G - 1)) {
+ aiWeight[ii+2] -= 20;
+ }
+ if (ii < (CB_MAX_CHANNEL_24G - 2)) {
+ aiWeight[ii+3] -= 10;
+ }
+ }
+ }
+ }
+ for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
+ if ((sChannelTbl[ii].bValid == TRUE) &&
+ (aiWeight[ii] > aiWeight[byOptionChannel])) {
+ byOptionChannel = (BYTE) ii;
+ }
+ }
+ }
+ return (byOptionChannel);
+}
+
+
+
+//xxx
+VOID
+CARDvSafeResetTx (
+ IN PVOID pDeviceHandler
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT uu;
+ PSTxDesc pCurrTD;
+
+ // initialize TD index
+ pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]);
+ pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]);
+
+ for (uu = 0; uu < TYPE_MAXTD; uu ++)
+ pDevice->iTDUsed[uu] = 0;
+
+ for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) {
+ pCurrTD = &(pDevice->apTD0Rings[uu]);
+ pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
+ // init all Tx Packet pointer to NULL
+ }
+ for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) {
+ pCurrTD = &(pDevice->apTD1Rings[uu]);
+ pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
+ // init all Tx Packet pointer to NULL
+ }
+
+ // set MAC TD pointer
+ MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset,
+ (pDevice->td0_pool_dma));
+
+ MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset,
+ (pDevice->td1_pool_dma));
+
+ // set MAC Beacon TX pointer
+ MACvSetCurrBCNTxDescAddr(pDevice->PortOffset,
+ (pDevice->tx_beacon_dma));
+
+}
+
+
+
+/*+
+ *
+ * Description:
+ * Reset Rx
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+CARDvSafeResetRx (
+ IN PVOID pDeviceHandler
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT uu;
+ PSRxDesc pDesc;
+
+
+
+ // initialize RD index
+ pDevice->pCurrRD[0]=&(pDevice->aRD0Ring[0]);
+ pDevice->pCurrRD[1]=&(pDevice->aRD1Ring[0]);
+
+ // init state, all RD is chip's
+ for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) {
+ pDesc =&(pDevice->aRD0Ring[uu]);
+ pDesc->m_rd0RD0.wResCount = (WORD)(pDevice->rx_buf_sz);
+ pDesc->m_rd0RD0.f1Owner=OWNED_BY_NIC;
+ pDesc->m_rd1RD1.wReqCount = (WORD)(pDevice->rx_buf_sz);
+ }
+
+ // init state, all RD is chip's
+ for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) {
+ pDesc =&(pDevice->aRD1Ring[uu]);
+ pDesc->m_rd0RD0.wResCount = (WORD)(pDevice->rx_buf_sz);
+ pDesc->m_rd0RD0.f1Owner=OWNED_BY_NIC;
+ pDesc->m_rd1RD1.wReqCount = (WORD)(pDevice->rx_buf_sz);
+ }
+
+ pDevice->cbDFCB = CB_MAX_RX_FRAG;
+ pDevice->cbFreeDFCB = pDevice->cbDFCB;
+
+ // set perPkt mode
+ MACvRx0PerPktMode(pDevice->PortOffset);
+ MACvRx1PerPktMode(pDevice->PortOffset);
+ // set MAC RD pointer
+ MACvSetCurrRx0DescAddr(pDevice->PortOffset,
+ pDevice->rd0_pool_dma);
+
+ MACvSetCurrRx1DescAddr(pDevice->PortOffset,
+ pDevice->rd1_pool_dma);
+}
+
+
+
+
+/*
+ * Description: Get response Control frame rate in CCK mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wRateIdx - Receiving data rate
+ * Out:
+ * none
+ *
+ * Return Value: response Control frame rate
+ *
+ */
+WORD CARDwGetCCKControlRate(PVOID pDeviceHandler, WORD wRateIdx)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ui = (UINT)wRateIdx;
+
+ while (ui > RATE_1M) {
+ if (pDevice->wBasicRate & ((WORD)1 << ui)) {
+ return (WORD)ui;
+ }
+ ui --;
+ }
+ return (WORD)RATE_1M;
+}
+
+/*
+ * Description: Get response Control frame rate in OFDM mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wRateIdx - Receiving data rate
+ * Out:
+ * none
+ *
+ * Return Value: response Control frame rate
+ *
+ */
+WORD CARDwGetOFDMControlRate (PVOID pDeviceHandler, WORD wRateIdx)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ui = (UINT)wRateIdx;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);
+
+ if (!CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
+ if (wRateIdx > RATE_24M)
+ wRateIdx = RATE_24M;
+ return wRateIdx;
+ }
+ while (ui > RATE_11M) {
+ if (pDevice->wBasicRate & ((WORD)1 << ui)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate : %d\n", ui);
+ return (WORD)ui;
+ }
+ ui --;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate: 6M\n");
+ return (WORD)RATE_24M;
+}
+
+
+/*
+ * Description: Set RSPINF
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+ */
+void CARDvSetRSPINF (PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BYTE byServ = 0x00, bySignal = 0x00; //For CCK
+ WORD wLen = 0x0000;
+ BYTE byTxRate, byRsvTime; //For OFDM
+
+ //Set to Page1
+ MACvSelectPage1(pDevice->PortOffset);
+
+ //RSPINF_b_1
+ BBvCaculateParameter(pDevice,
+ 14,
+ CARDwGetCCKControlRate((PVOID)pDevice, RATE_1M),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ ///RSPINF_b_2
+ BBvCaculateParameter(pDevice,
+ 14,
+ CARDwGetCCKControlRate((PVOID)pDevice, RATE_2M),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ //RSPINF_b_5
+ BBvCaculateParameter(pDevice,
+ 14,
+ CARDwGetCCKControlRate((PVOID)pDevice, RATE_5M),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ //RSPINF_b_11
+ BBvCaculateParameter(pDevice,
+ 14,
+ CARDwGetCCKControlRate((PVOID)pDevice, RATE_11M),
+ PK_TYPE_11B,
+ &wLen,
+ &byServ,
+ &bySignal
+ );
+
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
+ //RSPINF_a_6
+ s_vCaculateOFDMRParameter(RATE_6M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_9
+ s_vCaculateOFDMRParameter(RATE_9M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_12
+ s_vCaculateOFDMRParameter(RATE_12M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_18
+ s_vCaculateOFDMRParameter(RATE_18M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_24
+ s_vCaculateOFDMRParameter(RATE_24M,
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_36
+ s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_36M),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_48
+ s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_48M),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
+ //RSPINF_a_54
+ s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
+
+ //RSPINF_a_72
+ s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
+ ePHYType,
+ &byTxRate,
+ &byRsvTime);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
+ //Set to Page0
+ MACvSelectPage0(pDevice->PortOffset);
+}
+
+/*
+ * Description: Update IFS
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+ */
+void vUpdateIFS (PVOID pDeviceHandler)
+{
+ //Set SIFS, DIFS, EIFS, SlotTime, CwMin
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ BYTE byMaxMin = 0;
+ if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
+ pDevice->uSlot = C_SLOT_SHORT;
+ pDevice->uSIFS = C_SIFS_A;
+ pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
+ pDevice->uCwMin = C_CWMIN_A;
+ byMaxMin = 4;
+ }
+ else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b
+ pDevice->uSlot = C_SLOT_LONG;
+ pDevice->uSIFS = C_SIFS_BG;
+ pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
+ pDevice->uCwMin = C_CWMIN_B;
+ byMaxMin = 5;
+ }
+ else { // PK_TYPE_11GA & PK_TYPE_11GB
+ pDevice->uSIFS = C_SIFS_BG;
+ if (pDevice->bShortSlotTime) {
+ pDevice->uSlot = C_SLOT_SHORT;
+ } else {
+ pDevice->uSlot = C_SLOT_LONG;
+ }
+ pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
+ if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M
+ pDevice->uCwMin = C_CWMIN_A;
+ byMaxMin = 4;
+ }
+ else {
+ pDevice->uCwMin = C_CWMIN_B;
+ byMaxMin = 5;
+ }
+ }
+
+ pDevice->uCwMax = C_CWMAX;
+ pDevice->uEIFS = C_EIFS;
+ if (pDevice->byRFType == RF_RFMD2959) {
+ // bcs TX_PE will reserve 3 us
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (BYTE)(pDevice->uSIFS - 3));
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (BYTE)(pDevice->uDIFS - 3));
+ } else {
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (BYTE)pDevice->uSIFS);
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (BYTE)pDevice->uDIFS);
+ }
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (BYTE)pDevice->uEIFS);
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (BYTE)pDevice->uSlot);
+ byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (BYTE)byMaxMin);
+}
+
+void CARDvUpdateBasicTopRate (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BYTE byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
+ BYTE ii;
+
+ //Determines the highest basic rate.
+ for (ii = RATE_54M; ii >= RATE_6M; ii --) {
+ if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
+ byTopOFDM = ii;
+ break;
+ }
+ pDevice->byTopOFDMBasicRate = byTopOFDM;
+
+ for (ii = RATE_11M;; ii --) {
+ if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
+ byTopCCK = ii;
+ break;
+ if (ii == RATE_1M)
+ break;
+ }
+ pDevice->byTopCCKBasicRate = byTopCCK;
+}
+
+
+/*
+ * Description: Set NIC Tx Basic Rate
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wBasicRate - Basic Rate to be set
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL CARDbAddBasicRate (PVOID pDeviceHandler, WORD wRateIdx)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ WORD wRate = (WORD)(1<<wRateIdx);
+
+ pDevice->wBasicRate |= wRate;
+
+ //Determines the highest basic rate.
+ CARDvUpdateBasicTopRate((PVOID)pDevice);
+
+ return(TRUE);
+}
+
+BOOL CARDbIsOFDMinBasicRate (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ int ii;
+
+ for (ii = RATE_54M; ii >= RATE_6M; ii --) {
+ if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BYTE CARDbyGetPktType (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
+ return (BYTE)pDevice->byBBType;
+ }
+ else if (CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
+ return PK_TYPE_11GA;
+ }
+ else {
+ return PK_TYPE_11GB;
+ }
+}
+
+/*
+ * Description: Set NIC Loopback mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wLoopbackMode - Loopback mode to be set
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void CARDvSetLoopbackMode (DWORD_PTR dwIoBase, WORD wLoopbackMode)
+{
+ switch(wLoopbackMode) {
+ case CARD_LB_NONE:
+ case CARD_LB_MAC:
+ case CARD_LB_PHY:
+ break;
+ default:
+ ASSERT(FALSE);
+ break;
+ }
+ // set MAC loopback
+ MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode));
+ // set Baseband loopback
+}
+
+
+/*
+ * Description: Software Reset NIC
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be reset
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+BOOL CARDbSoftwareReset (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ // reset MAC
+ if (!MACbSafeSoftwareReset(pDevice->PortOffset))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+/*
+ * Description: Caculate TSF offset of two TSF input
+ * Get TSF Offset from RxBCN's TSF and local TSF
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be sync.
+ * qwTSF1 - Rx BCN's TSF
+ * qwTSF2 - Local TSF
+ * Out:
+ * none
+ *
+ * Return Value: TSF Offset value
+ *
+ */
+QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2)
+{
+ QWORD qwTSFOffset;
+ WORD wRxBcnTSFOffst= 0;;
+
+ HIDWORD(qwTSFOffset) = 0;
+ LODWORD(qwTSFOffset) = 0;
+ wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE];
+ (qwTSF2).u.dwLowDword += (DWORD)(wRxBcnTSFOffst);
+ if ((qwTSF2).u.dwLowDword < (DWORD)(wRxBcnTSFOffst)) {
+ (qwTSF2).u.dwHighDword++;
+ }
+ LODWORD(qwTSFOffset) = LODWORD(qwTSF1) - LODWORD(qwTSF2);
+ if (LODWORD(qwTSF1) < LODWORD(qwTSF2)) {
+ // if borrow needed
+ HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2) - 1 ;
+ }
+ else {
+ HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2);
+ };
+ return (qwTSFOffset);
+}
+
+
+/*
+ * Description: Read NIC TSF counter
+ * Get local TSF counter
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be read
+ * Out:
+ * qwCurrTSF - Current TSF counter
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL CARDbGetCurrentTSF (DWORD_PTR dwIoBase, PQWORD pqwCurrTSF)
+{
+ WORD ww;
+ BYTE byData;
+
+ MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_TFTCTL, &byData);
+ if (BITbIsBitOff(byData, TFTCTL_TSFCNTRRD))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT)
+ return(FALSE);
+ VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR, &LODWORD(*pqwCurrTSF));
+ VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR + 4, &HIDWORD(*pqwCurrTSF));
+
+ return(TRUE);
+}
+
+
+/*
+ * Description: Read NIC TSF counter
+ * Get NEXTTBTT from adjusted TSF and Beacon Interval
+ *
+ * Parameters:
+ * In:
+ * qwTSF - Current TSF counter
+ * wbeaconInterval - Beacon Interval
+ * Out:
+ * qwCurrTSF - Current TSF counter
+ *
+ * Return Value: TSF value of next Beacon
+ *
+ */
+QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
+{
+
+ UINT uLowNextTBTT;
+ UINT uHighRemain, uLowRemain;
+ UINT uBeaconInterval;
+
+ uBeaconInterval = wBeaconInterval * 1024;
+ // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
+ uLowNextTBTT = (LODWORD(qwTSF) >> 10) << 10;
+ // low dword (mod) bcn
+ uLowRemain = (uLowNextTBTT) % uBeaconInterval;
+// uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * HIDWORD(qwTSF))
+// % uBeaconInterval;
+ // high dword (mod) bcn
+ uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwTSF))
+ % uBeaconInterval;
+ uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
+ uLowRemain = uBeaconInterval - uLowRemain;
+
+ // check if carry when add one beacon interval
+ if ((~uLowNextTBTT) < uLowRemain)
+ HIDWORD(qwTSF) ++ ;
+
+ LODWORD(qwTSF) = uLowNextTBTT + uLowRemain;
+
+ return (qwTSF);
+}
+
+
+/*
+ * Description: Set NIC TSF counter for first Beacon time
+ * Get NEXTTBTT from adjusted TSF and Beacon Interval
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - IO Base
+ * wBeaconInterval - Beacon Interval
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void CARDvSetFirstNextTBTT (DWORD_PTR dwIoBase, WORD wBeaconInterval)
+{
+
+ QWORD qwNextTBTT;
+
+ HIDWORD(qwNextTBTT) = 0;
+ LODWORD(qwNextTBTT) = 0;
+ CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter
+ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
+ // Set NextTBTT
+ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT));
+ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT));
+ MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:First Next TBTT[%8xh:%8xh] \n", HIDWORD(qwNextTBTT), LODWORD(qwNextTBTT));
+ return;
+}
+
+
+/*
+ * Description: Sync NIC TSF counter for Beacon time
+ * Get NEXTTBTT and write to HW
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * qwTSF - Current TSF counter
+ * wBeaconInterval - Beacon Interval
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void CARDvUpdateNextTBTT (DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval)
+{
+
+ qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
+ // Set NextTBTT
+ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwTSF));
+ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwTSF));
+ MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(UINT)HIDWORD(qwTSF), (UINT)LODWORD(qwTSF));
+
+ return;
+}
+
+
+
+
+
+
+
diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h
new file mode 100644
index 000000000000..bb292e14b0b3
--- /dev/null
+++ b/drivers/staging/vt6655/card.h
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: card.h
+ *
+ * Purpose: Provide functions to setup NIC operation mode
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+
+#ifndef __CARD_H__
+#define __CARD_H__
+
+//#if !defined(__DEVICE_H__)
+//#include "device.h"
+//#endif
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+//
+// Loopback mode
+//
+// LOBYTE is MAC LB mode, HIBYTE is MII LB mode
+#define CARD_LB_NONE MAKEWORD(MAC_LB_NONE, 0)
+#define CARD_LB_MAC MAKEWORD(MAC_LB_INTERNAL, 0) // PHY must ISO, avoid MAC loopback packet go out
+#define CARD_LB_PHY MAKEWORD(MAC_LB_EXT, 0)
+
+
+#define DEFAULT_MSDU_LIFETIME 512 // ms
+#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us
+
+#define DEFAULT_MGN_LIFETIME 8 // ms
+#define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us
+
+#define CB_MAX_CHANNEL_24G 14
+#define CB_MAX_CHANNEL_5G 42 //[20050104] add channel9(5045MHz), 41==>42
+#define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G)
+
+typedef enum _CARD_PHY_TYPE {
+ PHY_TYPE_AUTO,
+ PHY_TYPE_11B,
+ PHY_TYPE_11G,
+ PHY_TYPE_11A
+} CARD_PHY_TYPE, *PCARD_PHY_TYPE;
+
+typedef enum _CARD_PKT_TYPE {
+ PKT_TYPE_802_11_BCN,
+ PKT_TYPE_802_11_MNG,
+ PKT_TYPE_802_11_DATA,
+ PKT_TYPE_802_11_ALL
+} CARD_PKT_TYPE, *PCARD_PKT_TYPE;
+
+typedef enum _CARD_STATUS_TYPE {
+ CARD_STATUS_MEDIA_CONNECT,
+ CARD_STATUS_MEDIA_DISCONNECT,
+ CARD_STATUS_PMKID
+} CARD_STATUS_TYPE, *PCARD_STATUS_TYPE;
+
+typedef enum _CARD_OP_MODE {
+ OP_MODE_INFRASTRUCTURE,
+ OP_MODE_ADHOC,
+ OP_MODE_AP,
+ OP_MODE_UNKNOWN
+} CARD_OP_MODE, *PCARD_OP_MODE;
+
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+BOOL ChannelValid(UINT CountryCode, UINT ChannelIndex);
+void CARDvSetRSPINF(PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType);
+void vUpdateIFS(PVOID pDeviceHandler);
+void CARDvUpdateBasicTopRate(PVOID pDeviceHandler);
+BOOL CARDbAddBasicRate(PVOID pDeviceHandler, WORD wRateIdx);
+BOOL CARDbIsOFDMinBasicRate(PVOID pDeviceHandler);
+void CARDvSetLoopbackMode(DWORD_PTR dwIoBase, WORD wLoopbackMode);
+BOOL CARDbSoftwareReset(PVOID pDeviceHandler);
+void CARDvSetFirstNextTBTT(DWORD_PTR dwIoBase, WORD wBeaconInterval);
+void CARDvUpdateNextTBTT(DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval);
+BOOL CARDbGetCurrentTSF(DWORD_PTR dwIoBase, PQWORD pqwCurrTSF);
+QWORD CARDqGetNextTBTT(QWORD qwTSF, WORD wBeaconInterval);
+QWORD CARDqGetTSFOffset(BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2);
+BOOL CARDbSetTxPower(PVOID pDeviceHandler, ULONG ulTxPower);
+BYTE CARDbyGetPktType(PVOID pDeviceHandler);
+VOID CARDvSafeResetTx(PVOID pDeviceHandler);
+VOID CARDvSafeResetRx(PVOID pDeviceHandler);
+
+//xxx
+BOOL CARDbRadioPowerOff(PVOID pDeviceHandler);
+BOOL CARDbRadioPowerOn(PVOID pDeviceHandler);
+BOOL CARDbSetChannel(PVOID pDeviceHandler, UINT uConnectionChannel);
+//BOOL CARDbSendPacket(PVOID pDeviceHandler, PVOID pPacket, CARD_PKT_TYPE ePktType, UINT uLength);
+BOOL CARDbIsShortPreamble(PVOID pDeviceHandler);
+BOOL CARDbIsShorSlotTime(PVOID pDeviceHandler);
+BOOL CARDbSetPhyParameter(PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType, WORD wCapInfo, BYTE byERPField, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs);
+BOOL CARDbUpdateTSF(PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF);
+BOOL CARDbStopTxPacket(PVOID pDeviceHandler, CARD_PKT_TYPE ePktType);
+BOOL CARDbStartTxPacket(PVOID pDeviceHandler, CARD_PKT_TYPE ePktType);
+BOOL CARDbSetBeaconPeriod(PVOID pDeviceHandler, WORD wBeaconInterval);
+BOOL CARDbSetBSSID(PVOID pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode);
+
+BOOL
+CARDbPowerDown(
+ PVOID pDeviceHandler
+ );
+
+BOOL CARDbSetTxDataRate(
+ PVOID pDeviceHandler,
+ WORD wDataRate
+ );
+
+
+BOOL CARDbRemoveKey (PVOID pDeviceHandler, PBYTE pbyBSSID);
+
+BOOL
+CARDbAdd_PMKID_Candidate (
+ IN PVOID pDeviceHandler,
+ IN PBYTE pbyBSSID,
+ IN BOOL bRSNCapExist,
+ IN WORD wRSNCap
+ );
+
+PVOID
+CARDpGetCurrentAddress (
+ IN PVOID pDeviceHandler
+ );
+
+
+VOID CARDvInitChannelTable(PVOID pDeviceHandler);
+BYTE CARDbyGetChannelMapping(PVOID pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType);
+
+BOOL
+CARDbStartMeasure (
+ IN PVOID pDeviceHandler,
+ IN PVOID pvMeasureEIDs,
+ IN UINT uNumOfMeasureEIDs
+ );
+
+BOOL
+CARDbChannelSwitch (
+ IN PVOID pDeviceHandler,
+ IN BYTE byMode,
+ IN BYTE byNewChannel,
+ IN BYTE byCount
+ );
+
+BOOL
+CARDbSetQuiet (
+ IN PVOID pDeviceHandler,
+ IN BOOL bResetQuiet,
+ IN BYTE byQuietCount,
+ IN BYTE byQuietPeriod,
+ IN WORD wQuietDuration,
+ IN WORD wQuietOffset
+ );
+
+BOOL
+CARDbStartQuiet (
+ IN PVOID pDeviceHandler
+ );
+
+VOID
+CARDvSetCountryInfo (
+ IN PVOID pDeviceHandler,
+ IN CARD_PHY_TYPE ePHYType,
+ IN PVOID pIE
+ );
+
+VOID
+CARDvSetPowerConstraint (
+ IN PVOID pDeviceHandler,
+ IN BYTE byChannel,
+ IN I8 byPower
+ );
+
+VOID
+CARDvGetPowerCapability (
+ IN PVOID pDeviceHandler,
+ OUT PBYTE pbyMinPower,
+ OUT PBYTE pbyMaxPower
+ );
+
+BYTE
+CARDbySetSupportChannels (
+ IN PVOID pDeviceHandler,
+ IN OUT PBYTE pbyIEs
+ );
+
+I8
+CARDbyGetTransmitPower (
+ IN PVOID pDeviceHandler
+ );
+
+BOOL
+CARDbChannelGetList (
+ IN UINT uCountryCodeIdx,
+ OUT PBYTE pbyChannelTable
+ );
+
+VOID
+CARDvSetCountryIE(
+ IN PVOID pDeviceHandler,
+ IN PVOID pIE
+ );
+
+BOOL
+CARDbGetChannelMapInfo(
+ IN PVOID pDeviceHandler,
+ IN UINT uChannelIndex,
+ OUT PBYTE pbyChannelNumber,
+ OUT PBYTE pbyMap
+ );
+
+VOID
+CARDvSetChannelMapInfo(
+ IN PVOID pDeviceHandler,
+ IN UINT uChannelIndex,
+ IN BYTE byMap
+ );
+
+VOID
+CARDvClearChannelMapInfo(
+ IN PVOID pDeviceHandler
+ );
+
+BYTE
+CARDbyAutoChannelSelect(
+ IN PVOID pDeviceHandler,
+ CARD_PHY_TYPE ePHYType
+ );
+
+BYTE CARDbyGetChannelNumber(PVOID pDeviceHandler, BYTE byChannelIndex);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __CARD_H__
+
+
+
diff --git a/drivers/staging/vt6655/country.h b/drivers/staging/vt6655/country.h
new file mode 100644
index 000000000000..65d1e52916ce
--- /dev/null
+++ b/drivers/staging/vt6655/country.h
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: country.h
+ *
+ * Purpose: Country Code information
+ *
+ * Author: Lucas Lin
+ *
+ * Date: Dec 23, 2004
+ *
+ */
+
+#ifndef __COUNTRY_H__
+#define __COUNTRY_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+/************************************************************************
+ * The definition here should be complied with the INF country order
+ * Please check with VNWL.inf/VNWL64.inf/VNWL*.inf
+ ************************************************************************/
+typedef enum _COUNTRY_CODE {
+ CCODE_FCC = 0,
+ CCODE_TELEC,
+ CCODE_ETSI,
+ CCODE_RESV3,
+ CCODE_RESV4,
+ CCODE_RESV5,
+ CCODE_RESV6,
+ CCODE_RESV7,
+ CCODE_RESV8,
+ CCODE_RESV9,
+ CCODE_RESVa,
+ CCODE_RESVb,
+ CCODE_RESVc,
+ CCODE_RESVd,
+ CCODE_RESVe,
+ CCODE_ALLBAND,
+ CCODE_ALBANIA,
+ CCODE_ALGERIA,
+ CCODE_ARGENTINA,
+ CCODE_ARMENIA,
+ CCODE_AUSTRALIA,
+ CCODE_AUSTRIA,
+ CCODE_AZERBAIJAN,
+ CCODE_BAHRAIN,
+ CCODE_BELARUS,
+ CCODE_BELGIUM,
+ CCODE_BELIZE,
+ CCODE_BOLIVIA,
+ CCODE_BRAZIL,
+ CCODE_BRUNEI_DARUSSALAM,
+ CCODE_BULGARIA,
+ CCODE_CANADA,
+ CCODE_CHILE,
+ CCODE_CHINA,
+ CCODE_COLOMBIA,
+ CCODE_COSTA_RICA,
+ CCODE_CROATIA,
+ CCODE_CYPRUS,
+ CCODE_CZECH,
+ CCODE_DENMARK,
+ CCODE_DOMINICAN_REPUBLIC,
+ CCODE_ECUADOR,
+ CCODE_EGYPT,
+ CCODE_EL_SALVADOR,
+ CCODE_ESTONIA,
+ CCODE_FINLAND,
+ CCODE_FRANCE,
+ CCODE_GERMANY,
+ CCODE_GREECE,
+ CCODE_GEORGIA,
+ CCODE_GUATEMALA,
+ CCODE_HONDURAS,
+ CCODE_HONG_KONG,
+ CCODE_HUNGARY,
+ CCODE_ICELAND,
+ CCODE_INDIA,
+ CCODE_INDONESIA,
+ CCODE_IRAN,
+ CCODE_IRELAND,
+ CCODE_ITALY,
+ CCODE_ISRAEL,
+ CCODE_JAPAN,
+ CCODE_JORDAN,
+ CCODE_KAZAKHSTAN,
+ CCODE_KUWAIT,
+ CCODE_LATVIA,
+ CCODE_LEBANON,
+ CCODE_LEICHTENSTEIN,
+ CCODE_LITHUANIA,
+ CCODE_LUXEMBURG,
+ CCODE_MACAU,
+ CCODE_MACEDONIA,
+ CCODE_MALTA,
+ CCODE_MALAYSIA,
+ CCODE_MEXICO,
+ CCODE_MONACO,
+ CCODE_MOROCCO,
+ CCODE_NETHERLANDS,
+ CCODE_NEW_ZEALAND,
+ CCODE_NORTH_KOREA,
+ CCODE_NORWAY,
+ CCODE_OMAN,
+ CCODE_PAKISTAN,
+ CCODE_PANAMA,
+ CCODE_PERU,
+ CCODE_PHILIPPINES,
+ CCODE_POLAND,
+ CCODE_PORTUGAL,
+ CCODE_PUERTO_RICO,
+ CCODE_QATAR,
+ CCODE_ROMANIA,
+ CCODE_RUSSIA,
+ CCODE_SAUDI_ARABIA,
+ CCODE_SINGAPORE,
+ CCODE_SLOVAKIA,
+ CCODE_SLOVENIA,
+ CCODE_SOUTH_AFRICA,
+ CCODE_SOUTH_KOREA,
+ CCODE_SPAIN,
+ CCODE_SWEDEN,
+ CCODE_SWITZERLAND,
+ CCODE_SYRIA,
+ CCODE_TAIWAN,
+ CCODE_THAILAND,
+ CCODE_TRINIDAD_TOBAGO,
+ CCODE_TUNISIA,
+ CCODE_TURKEY,
+ CCODE_UK,
+ CCODE_UKRAINE,
+ CCODE_UNITED_ARAB_EMIRATES,
+ CCODE_UNITED_STATES,
+ CCODE_URUGUAY,
+ CCODE_UZBEKISTAN,
+ CCODE_VENEZUELA,
+ CCODE_VIETNAM,
+ CCODE_YEMEN,
+ CCODE_ZIMBABWE,
+ CCODE_JAPAN_W52_W53,
+ CCODE_MAX
+} COUNTRY_CODE;
+
+typedef struct tagSCountryTable
+{
+ BYTE byChannelCountryCode; /* The country code */
+ CHAR chCountryCode[2];
+ BYTE bChannelIdxList[CB_MAX_CHANNEL]; /* Available channels Index */
+ BYTE byPower[CB_MAX_CHANNEL];
+} SCountryTable, DEF* PSCountryTable;
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+extern SCountryTable ChannelRuleTab[CCODE_MAX+1];
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+/************************************************************************
+ * Function prototype
+ ************************************************************************/
+#endif /* __COUNTRY_H__ */
diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c
new file mode 100644
index 000000000000..f58f9636be2d
--- /dev/null
+++ b/drivers/staging/vt6655/datarate.c
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: datarate.c
+ *
+ * Purpose: Handles the auto fallback & data rates functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 17, 2002
+ *
+ * Functions:
+ * RATEvParseMaxRate - Parsing the highest basic & support rate in rate field of frame
+ * RATEvTxRateFallBack - Rate fallback Algorithm Implementaion
+ * RATEuSetIE- Set rate IE field.
+ *
+ * Revision History:
+ *
+ */
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__SROM_H__)
+#include "srom.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+
+ extern WORD TxRate_iwconfig; //2008-5-8 <add> by chester
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+const BYTE acbyIERate[MAX_RATE] =
+{0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+
+#define AUTORATE_TXOK_CNT 0x0400
+#define AUTORATE_TXFAIL_CNT 0x0064
+#define AUTORATE_TIMEOUT 10
+
+/*--------------------- Static Functions --------------------------*/
+
+VOID s_vResetCounter (
+ IN PKnownNodeDB psNodeDBTable
+ );
+
+
+
+VOID
+s_vResetCounter (
+ IN PKnownNodeDB psNodeDBTable
+ )
+{
+ BYTE ii;
+
+ // clear statistic counter for auto_rate
+ for(ii=0;ii<=MAX_RATE;ii++) {
+ psNodeDBTable->uTxOk[ii] = 0;
+ psNodeDBTable->uTxFail[ii] = 0;
+ }
+}
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*+
+ *
+ * Description:
+ * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE
+ *
+ * Parameters:
+ * In:
+ * BYTE - Rate value in SuppRates IE or ExtSuppRates IE
+ * Out:
+ * none
+ *
+ * Return Value: RateIdx
+ *
+-*/
+BYTE
+DATARATEbyGetRateIdx (
+ IN BYTE byRate
+ )
+{
+ BYTE ii;
+
+ //Erase basicRate flag.
+ byRate = byRate & 0x7F;//0111 1111
+
+ for (ii = 0; ii < MAX_RATE; ii ++) {
+ if (acbyIERate[ii] == byRate)
+ return ii;
+ }
+ return 0;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Rate fallback Algorithm Implementaion
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * psNodeDBTable - Pointer to Node Data Base
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+#define AUTORATE_TXCNT_THRESHOLD 20
+#define AUTORATE_INC_THRESHOLD 30
+
+
+
+
+/*+
+ *
+ * Description:
+ * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE
+ *
+ * Parameters:
+ * In:
+ * BYTE - Rate value in SuppRates IE or ExtSuppRates IE
+ * Out:
+ * none
+ *
+ * Return Value: RateIdx
+ *
+-*/
+WORD
+wGetRateIdx(
+ IN BYTE byRate
+ )
+{
+ WORD ii;
+
+ //Erase basicRate flag.
+ byRate = byRate & 0x7F;//0111 1111
+
+ for (ii = 0; ii < MAX_RATE; ii ++) {
+ if (acbyIERate[ii] == byRate)
+ return ii;
+ }
+ return 0;
+}
+
+/*+
+ *
+ * Description:
+ * Parsing the highest basic & support rate in rate field of frame.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * pItemRates - Pointer to Rate field defined in 802.11 spec.
+ * pItemExtRates - Pointer to Extended Rate field defined in 802.11 spec.
+ * Out:
+ * pwMaxBasicRate - Maximum Basic Rate
+ * pwMaxSuppRate - Maximum Supported Rate
+ * pbyTopCCKRate - Maximum Basic Rate in CCK mode
+ * pbyTopOFDMRate - Maximum Basic Rate in OFDM mode
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+RATEvParseMaxRate (
+ IN PVOID pDeviceHandler,
+ IN PWLAN_IE_SUPP_RATES pItemRates,
+ IN PWLAN_IE_SUPP_RATES pItemExtRates,
+ IN BOOL bUpdateBasicRate,
+ OUT PWORD pwMaxBasicRate,
+ OUT PWORD pwMaxSuppRate,
+ OUT PWORD pwSuppRate,
+ OUT PBYTE pbyTopCCKRate,
+ OUT PBYTE pbyTopOFDMRate
+ )
+{
+PSDevice pDevice = (PSDevice) pDeviceHandler;
+UINT ii;
+BYTE byHighSuppRate = 0;
+BYTE byRate = 0;
+WORD wOldBasicRate = pDevice->wBasicRate;
+UINT uRateLen;
+
+
+ if (pItemRates == NULL)
+ return;
+
+ *pwSuppRate = 0;
+ uRateLen = pItemRates->len;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen);
+ if (pDevice->eCurrentPHYType != PHY_TYPE_11B) {
+ if (uRateLen > WLAN_RATES_MAXLEN)
+ uRateLen = WLAN_RATES_MAXLEN;
+ } else {
+ if (uRateLen > WLAN_RATES_MAXLEN_11B)
+ uRateLen = WLAN_RATES_MAXLEN_11B;
+ }
+
+ for (ii = 0; ii < uRateLen; ii++) {
+ byRate = (BYTE)(pItemRates->abyRates[ii]);
+ if (WLAN_MGMT_IS_BASICRATE(byRate) &&
+ (bUpdateBasicRate == TRUE)) {
+ // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate
+ CARDbAddBasicRate((PVOID)pDevice, wGetRateIdx(byRate));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate));
+ }
+ byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
+ if (byHighSuppRate == 0)
+ byHighSuppRate = byRate;
+ if (byRate > byHighSuppRate)
+ byHighSuppRate = byRate;
+ *pwSuppRate |= (1<<wGetRateIdx(byRate));
+ }
+ if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) &&
+ (pDevice->eCurrentPHYType != PHY_TYPE_11B)) {
+
+ UINT uExtRateLen = pItemExtRates->len;
+
+ if (uExtRateLen > WLAN_RATES_MAXLEN)
+ uExtRateLen = WLAN_RATES_MAXLEN;
+
+ for (ii = 0; ii < uExtRateLen ; ii++) {
+ byRate = (BYTE)(pItemExtRates->abyRates[ii]);
+ // select highest basic rate
+ if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) {
+ // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate
+ CARDbAddBasicRate((PVOID)pDevice, wGetRateIdx(byRate));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate));
+ }
+ byRate = (BYTE)(pItemExtRates->abyRates[ii]&0x7F);
+ if (byHighSuppRate == 0)
+ byHighSuppRate = byRate;
+ if (byRate > byHighSuppRate)
+ byHighSuppRate = byRate;
+ *pwSuppRate |= (1<<wGetRateIdx(byRate));
+ //DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", wGetRateIdx(byRate), byRate));
+ }
+ } //if(pItemExtRates != NULL)
+
+ if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
+ pDevice->byPacketType = PK_TYPE_11GA;
+ }
+
+ *pbyTopCCKRate = pDevice->byTopCCKBasicRate;
+ *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate;
+ *pwMaxSuppRate = wGetRateIdx(byHighSuppRate);
+ if ((pDevice->byPacketType==PK_TYPE_11B) || (pDevice->byPacketType==PK_TYPE_11GB))
+ *pwMaxBasicRate = pDevice->byTopCCKBasicRate;
+ else
+ *pwMaxBasicRate = pDevice->byTopOFDMBasicRate;
+ if (wOldBasicRate != pDevice->wBasicRate)
+ CARDvSetRSPINF((PVOID)pDevice, pDevice->eCurrentPHYType);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Exit ParseMaxRate\n");
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Rate fallback Algorithm Implementaion
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * psNodeDBTable - Pointer to Node Data Base
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+#define AUTORATE_TXCNT_THRESHOLD 20
+#define AUTORATE_INC_THRESHOLD 30
+
+VOID
+RATEvTxRateFallBack (
+ IN PVOID pDeviceHandler,
+ IN PKnownNodeDB psNodeDBTable
+ )
+{
+PSDevice pDevice = (PSDevice) pDeviceHandler;
+WORD wIdxDownRate = 0;
+UINT ii;
+//DWORD dwRateTable[MAX_RATE] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54};
+BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE};
+DWORD dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540};
+DWORD dwThroughput = 0;
+WORD wIdxUpRate = 0;
+DWORD dwTxDiff = 0;
+
+ if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) {
+ // Don't do Fallback when scanning Channel
+ return;
+ }
+
+ psNodeDBTable->uTimeCount ++;
+
+ if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE])
+ dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE];
+
+ if ((psNodeDBTable->uTxOk[MAX_RATE] < AUTORATE_TXOK_CNT) &&
+ (dwTxDiff < AUTORATE_TXFAIL_CNT) &&
+ (psNodeDBTable->uTimeCount < AUTORATE_TIMEOUT)) {
+ return;
+ }
+
+ if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) {
+ psNodeDBTable->uTimeCount = 0;
+ }
+
+
+ for(ii=0;ii<MAX_RATE;ii++) {
+ if (psNodeDBTable->wSuppRate & (0x0001<<ii)) {
+ if (bAutoRate[ii] == TRUE) {
+ wIdxUpRate = (WORD) ii;
+ }
+ } else {
+ bAutoRate[ii] = FALSE;
+ }
+ }
+
+ for(ii=0;ii<=psNodeDBTable->wTxDataRate;ii++) {
+ if ( (psNodeDBTable->uTxOk[ii] != 0) ||
+ (psNodeDBTable->uTxFail[ii] != 0) ) {
+ dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii];
+ if (ii < RATE_11M) {
+ psNodeDBTable->uTxFail[ii] *= 4;
+ }
+ dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]);
+ }
+// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate %d,Ok: %d, Fail:%d, Throughput:%d\n",
+// ii, psNodeDBTable->uTxOk[ii], psNodeDBTable->uTxFail[ii], dwThroughputTbl[ii]);
+ }
+ dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate];
+
+ wIdxDownRate = psNodeDBTable->wTxDataRate;
+ for(ii = psNodeDBTable->wTxDataRate; ii > 0;) {
+ ii--;
+ if ( (dwThroughputTbl[ii] > dwThroughput) &&
+ (bAutoRate[ii]==TRUE) ) {
+ dwThroughput = dwThroughputTbl[ii];
+ wIdxDownRate = (WORD) ii;
+ }
+ }
+ psNodeDBTable->wTxDataRate = wIdxDownRate;
+ if (psNodeDBTable->uTxOk[MAX_RATE]) {
+ if (psNodeDBTable->uTxOk[MAX_RATE] >
+ (psNodeDBTable->uTxFail[MAX_RATE] * 4) ) {
+ psNodeDBTable->wTxDataRate = wIdxUpRate;
+ }
+ }else { // adhoc, if uTxOk =0 & uTxFail = 0
+ if (psNodeDBTable->uTxFail[MAX_RATE] == 0)
+ psNodeDBTable->wTxDataRate = wIdxUpRate;
+ }
+//2008-5-8 <add> by chester
+TxRate_iwconfig=psNodeDBTable->wTxDataRate;
+ s_vResetCounter(psNodeDBTable);
+// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate: %d, U:%d, D:%d\n", psNodeDBTable->wTxDataRate, wIdxUpRate, wIdxDownRate);
+
+ return;
+
+}
+
+/*+
+ *
+ * Description:
+ * This routine is used to assemble available Rate IE.
+ *
+ * Parameters:
+ * In:
+ * pDevice
+ * Out:
+ *
+ * Return Value: None
+ *
+-*/
+BYTE
+RATEuSetIE (
+ IN PWLAN_IE_SUPP_RATES pSrcRates,
+ IN PWLAN_IE_SUPP_RATES pDstRates,
+ IN UINT uRateLen
+ )
+{
+ UINT ii, uu, uRateCnt = 0;
+
+ if ((pSrcRates == NULL) || (pDstRates == NULL))
+ return 0;
+
+ if (pSrcRates->len == 0)
+ return 0;
+
+ for (ii = 0; ii < uRateLen; ii++) {
+ for (uu = 0; uu < pSrcRates->len; uu++) {
+ if ((pSrcRates->abyRates[uu] & 0x7F) == acbyIERate[ii]) {
+ pDstRates->abyRates[uRateCnt ++] = pSrcRates->abyRates[uu];
+ break;
+ }
+ }
+ }
+ return (BYTE)uRateCnt;
+}
+
diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h
new file mode 100644
index 000000000000..5096f3df4993
--- /dev/null
+++ b/drivers/staging/vt6655/datarate.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: datarate.h
+ *
+ * Purpose: Handles the auto fallback & data rates functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 16, 2002
+ *
+ */
+#ifndef __DATARATE_H__
+#define __DATARATE_H__
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define FALLBACK_PKT_COLLECT_TR_H 50 // pkts
+#define FALLBACK_PKT_COLLECT_TR_L 10 // pkts
+#define FALLBACK_POLL_SECOND 5 // 5 sec
+#define FALLBACK_RECOVER_SECOND 30 // 30 sec
+#define FALLBACK_THRESHOLD 15 // percent
+#define UPGRADE_THRESHOLD 5 // percent
+#define UPGRADE_CNT_THRD 3 // times
+#define RETRY_TIMES_THRD_H 2 // times
+#define RETRY_TIMES_THRD_L 1 // times
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+VOID
+RATEvParseMaxRate(
+ IN PVOID pDeviceHandler,
+ IN PWLAN_IE_SUPP_RATES pItemRates,
+ IN PWLAN_IE_SUPP_RATES pItemExtRates,
+ IN BOOL bUpdateBasicRate,
+ OUT PWORD pwMaxBasicRate,
+ OUT PWORD pwMaxSuppRate,
+ OUT PWORD pwSuppRate,
+ OUT PBYTE pbyTopCCKRate,
+ OUT PBYTE pbyTopOFDMRate
+ );
+
+VOID
+RATEvTxRateFallBack(
+ IN PVOID pDeviceHandler,
+ IN PKnownNodeDB psNodeDBTable
+ );
+
+BYTE
+RATEuSetIE(
+ IN PWLAN_IE_SUPP_RATES pSrcRates,
+ IN PWLAN_IE_SUPP_RATES pDstRates,
+ IN UINT uRateLen
+ );
+
+WORD
+wGetRateIdx(
+ IN BYTE byRate
+ );
+
+
+BYTE
+DATARATEbyGetRateIdx(
+ IN BYTE byRate
+ );
+
+
+#endif //__DATARATE_H__
diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h
new file mode 100644
index 000000000000..c0fc1d3b0a2e
--- /dev/null
+++ b/drivers/staging/vt6655/desc.h
@@ -0,0 +1,697 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: desc.h
+ *
+ * Purpose:The header file of descriptor
+ *
+ * Revision History:
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+
+#ifndef __DESC_H__
+#define __DESC_H__
+
+#include <linux/types.h>
+#include <linux/mm.h>
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+// #ifdef PRIVATE_OBJ
+//#if !defined(__DEVICE_MODULE_H)
+//#include "device_module.h"
+//#endif
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define B_OWNED_BY_CHIP 1 //
+#define B_OWNED_BY_HOST 0 //
+
+//
+// Bits in the RSR register
+//
+#define RSR_ADDRBROAD 0x80 // 1000 0000
+#define RSR_ADDRMULTI 0x40 // 0100 0000
+#define RSR_ADDRUNI 0x00 // 0000 0000
+#define RSR_IVLDTYP 0x20 // 0010 0000 , invalid packet type
+#define RSR_IVLDLEN 0x10 // 0001 0000 , invalid len (> 2312 byte)
+#define RSR_BSSIDOK 0x08 // 0000 1000
+#define RSR_CRCOK 0x04 // 0000 0100
+#define RSR_BCNSSIDOK 0x02 // 0000 0010
+#define RSR_ADDROK 0x01 // 0000 0001
+
+//
+// Bits in the new RSR register
+//
+#define NEWRSR_DECRYPTOK 0x10 // 0001 0000
+#define NEWRSR_CFPIND 0x08 // 0000 1000
+#define NEWRSR_HWUTSF 0x04 // 0000 0100
+#define NEWRSR_BCNHITAID 0x02 // 0000 0010
+#define NEWRSR_BCNHITAID0 0x01 // 0000 0001
+
+//
+// Bits in the TSR0 register
+//
+#define TSR0_PWRSTS1_2 0xC0 // 1100 0000
+#define TSR0_PWRSTS7 0x20 // 0010 0000
+#define TSR0_NCR 0x1F // 0001 1111
+
+//
+// Bits in the TSR1 register
+//
+#define TSR1_TERR 0x80 // 1000 0000
+#define TSR1_PWRSTS4_6 0x70 // 0111 0000
+#define TSR1_RETRYTMO 0x08 // 0000 1000
+#define TSR1_TMO 0x04 // 0000 0100
+#define TSR1_PWRSTS3 0x02 // 0000 0010
+#define ACK_DATA 0x01 // 0000 0000
+
+//
+// Bits in the TCR register
+//
+#define EDMSDU 0x04 // 0000 0100 end of sdu
+#define TCR_EDP 0x02 // 0000 0010 end of packet
+#define TCR_STP 0x01 // 0000 0001 start of packet
+
+// max transmit or receive buffer size
+#define CB_MAX_BUF_SIZE 2900U // max buffer size
+ // NOTE: must be multiple of 4
+#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE // max Tx buffer size
+#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE // max Rx buffer size when not use Multi-RD
+
+#define CB_BEACON_BUF_SIZE 512U // default beacon buffer size
+
+#define CB_MAX_RX_DESC 128 // max # of descriptor
+#define CB_MIN_RX_DESC 16 // min # of rx descriptor
+#define CB_MAX_TX_DESC 64 // max # of descriptor
+#define CB_MIN_TX_DESC 16 // min # of tx descriptor
+
+#define CB_MAX_RECEIVED_PACKETS 16 // max # of received packets at one time
+ // limit our receive routine to indicating
+ // this many at a time for 2 reasons:
+ // 1. driver flow control to protocol layer
+ // 2. limit the time used in ISR routine
+
+#define CB_EXTRA_RD_NUM 32 // default # of Extra RD
+#define CB_RD_NUM 32 // default # of RD
+#define CB_TD_NUM 32 // default # of TD
+
+
+// max number of physical segments
+// in a single NDIS packet. Above this threshold, the packet
+// is copied into a single physically contiguous buffer
+#define CB_MAX_SEGMENT 4
+
+#define CB_MIN_MAP_REG_NUM 4
+#define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
+
+#define CB_PROTOCOL_RESERVED_SECTION 16
+
+
+// if retrys excess 15 times , tx will abort, and
+// if tx fifo underflow, tx will fail
+// we should try to resend it
+#define CB_MAX_TX_ABORT_RETRY 3
+
+#ifdef __BIG_ENDIAN
+
+// WMAC definition FIFO Control
+#define FIFOCTL_AUTO_FB_1 0x0010 // 0001 0000 0000 0000
+#define FIFOCTL_AUTO_FB_0 0x0008 // 0000 1000 0000 0000
+#define FIFOCTL_GRPACK 0x0004 // 0000 0100 0000 0000
+#define FIFOCTL_11GA 0x0003 // 0000 0011 0000 0000
+#define FIFOCTL_11GB 0x0002 // 0000 0010 0000 0000
+#define FIFOCTL_11B 0x0001 // 0000 0001 0000 0000
+#define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
+#define FIFOCTL_RTS 0x8000 // 0000 0000 1000 0000
+#define FIFOCTL_ISDMA0 0x4000 // 0000 0000 0100 0000
+#define FIFOCTL_GENINT 0x2000 // 0000 0000 0010 0000
+#define FIFOCTL_TMOEN 0x1000 // 0000 0000 0001 0000
+#define FIFOCTL_LRETRY 0x0800 // 0000 0000 0000 1000
+#define FIFOCTL_CRCDIS 0x0400 // 0000 0000 0000 0100
+#define FIFOCTL_NEEDACK 0x0200 // 0000 0000 0000 0010
+#define FIFOCTL_LHEAD 0x0100 // 0000 0000 0000 0001
+
+//WMAC definition Frag Control
+#define FRAGCTL_AES 0x0003 // 0000 0011 0000 0000
+#define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000
+#define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000
+#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
+//#define FRAGCTL_AC3 0x0C00 // 0000 0000 0000 1100
+//#define FRAGCTL_AC2 0x0800 // 0000 0000 0000 1000
+//#define FRAGCTL_AC1 0x0400 // 0000 0000 0000 0100
+//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
+#define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011
+#define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010
+#define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001
+#define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
+
+#else
+
+#define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000
+#define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000
+#define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000
+#define FIFOCTL_11GA 0x0300 // 0000 0011 0000 0000
+#define FIFOCTL_11GB 0x0200 // 0000 0010 0000 0000
+#define FIFOCTL_11B 0x0100 // 0000 0001 0000 0000
+#define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
+#define FIFOCTL_RTS 0x0080 // 0000 0000 1000 0000
+#define FIFOCTL_ISDMA0 0x0040 // 0000 0000 0100 0000
+#define FIFOCTL_GENINT 0x0020 // 0000 0000 0010 0000
+#define FIFOCTL_TMOEN 0x0010 // 0000 0000 0001 0000
+#define FIFOCTL_LRETRY 0x0008 // 0000 0000 0000 1000
+#define FIFOCTL_CRCDIS 0x0004 // 0000 0000 0000 0100
+#define FIFOCTL_NEEDACK 0x0002 // 0000 0000 0000 0010
+#define FIFOCTL_LHEAD 0x0001 // 0000 0000 0000 0001
+
+//WMAC definition Frag Control
+#define FRAGCTL_AES 0x0300 // 0000 0011 0000 0000
+#define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
+#define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
+#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
+//#define FRAGCTL_AC3 0x000C // 0000 0000 0000 1100
+//#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000
+//#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100
+//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
+#define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
+#define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
+#define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
+#define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
+
+#endif // #ifdef __BIG_ENDIAN
+
+//#define TYPE_AC0DMA 0
+//#define TYPE_TXDMA0 1
+#define TYPE_TXDMA0 0
+#define TYPE_AC0DMA 1
+#define TYPE_ATIMDMA 2
+#define TYPE_SYNCDMA 3
+#define TYPE_MAXTD 2
+
+#define TYPE_BEACONDMA 4
+
+#define TYPE_RXDMA0 0
+#define TYPE_RXDMA1 1
+#define TYPE_MAXRD 2
+
+
+
+// TD_INFO flags control bit
+#define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
+#define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
+#define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
+//#define TD_FLAGS_NETIF_SKB 0x04
+
+/*--------------------- Export Types ------------------------------*/
+
+// ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
+// Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
+// may link to older skb that leads error.
+
+typedef struct tagDEVICE_RD_INFO {
+ struct sk_buff* skb;
+#ifdef PRIVATE_OBJ
+ ref_sk_buff ref_skb;
+#endif
+ dma_addr_t skb_dma;
+ dma_addr_t curr_desc;
+} DEVICE_RD_INFO, *PDEVICE_RD_INFO;
+
+/*
+static inline PDEVICE_RD_INFO alloc_rd_info(void) {
+ PDEVICE_RD_INFO ptr;
+ if ((ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC)) == NULL)
+ return NULL;
+ else {
+ memset(ptr,0,sizeof(DEVICE_RD_INFO));
+ return ptr;
+ }
+}
+*/
+
+/*
+typedef struct tagRDES0 {
+ WORD wResCount;
+ WORD wf1Owner ;
+// WORD f15Reserved : 15;
+// WORD f1Owner : 1;
+} __attribute__ ((__packed__))
+SRDES0;
+*/
+
+#ifdef __BIG_ENDIAN
+
+typedef struct tagRDES0 {
+ volatile WORD wResCount;
+ union {
+ volatile U16 f15Reserved;
+ struct {
+ volatile U8 f8Reserved1;
+ volatile U8 f1Owner:1;
+ volatile U8 f7Reserved:7;
+ } __attribute__ ((__packed__));
+ } __attribute__ ((__packed__));
+} __attribute__ ((__packed__))
+SRDES0, *PSRDES0;
+
+#else
+
+typedef struct tagRDES0 {
+ WORD wResCount;
+ WORD f15Reserved : 15;
+ WORD f1Owner : 1;
+} __attribute__ ((__packed__))
+SRDES0;
+
+
+#endif
+
+typedef struct tagRDES1 {
+ WORD wReqCount;
+ WORD wReserved;
+} __attribute__ ((__packed__))
+SRDES1;
+
+//
+// Rx descriptor
+//
+typedef struct tagSRxDesc {
+ volatile SRDES0 m_rd0RD0;
+ volatile SRDES1 m_rd1RD1;
+ volatile U32 buff_addr;
+ volatile U32 next_desc;
+ struct tagSRxDesc *next;//4 bytes
+ volatile PDEVICE_RD_INFO pRDInfo;//4 bytes
+ volatile U32 Reserved[2];//8 bytes
+} __attribute__ ((__packed__))
+SRxDesc, DEF* PSRxDesc;
+typedef const SRxDesc DEF* PCSRxDesc;
+
+#ifdef __BIG_ENDIAN
+
+/*
+typedef struct tagTDES0 {
+ volatile BYTE byTSR0;
+ volatile BYTE byTSR1;
+ volatile WORD wOwner_Txtime;
+// volatile WORD f15Txtime : 15;
+// volatile WORD f1Owner:1;
+} __attribute__ ((__packed__))
+STDES0;
+*/
+
+typedef struct tagTDES0 {
+ volatile BYTE byTSR0;
+ volatile BYTE byTSR1;
+ union {
+ volatile U16 f15Txtime;
+ struct {
+ volatile U8 f8Reserved1;
+ volatile U8 f1Owner:1;
+ volatile U8 f7Reserved:7;
+ } __attribute__ ((__packed__));
+ } __attribute__ ((__packed__));
+} __attribute__ ((__packed__))
+STDES0, PSTDES0;
+
+#else
+
+typedef struct tagTDES0 {
+ volatile BYTE byTSR0;
+ volatile BYTE byTSR1;
+ volatile WORD f15Txtime : 15;
+ volatile WORD f1Owner:1;
+} __attribute__ ((__packed__))
+STDES0;
+
+#endif
+
+
+typedef struct tagTDES1 {
+ volatile WORD wReqCount;
+ volatile BYTE byTCR;
+ volatile BYTE byReserved;
+} __attribute__ ((__packed__))
+STDES1;
+
+
+typedef struct tagDEVICE_TD_INFO{
+ struct sk_buff* skb;
+ PBYTE buf;
+ dma_addr_t skb_dma;
+ dma_addr_t buf_dma;
+ dma_addr_t curr_desc;
+ DWORD dwReqCount;
+ DWORD dwHeaderLength;
+ BYTE byFlags;
+} DEVICE_TD_INFO, *PDEVICE_TD_INFO;
+
+/*
+static inline PDEVICE_TD_INFO alloc_td_info(void) {
+ PDEVICE_TD_INFO ptr;
+ if ((ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC))==NULL)
+ return NULL;
+ else {
+ memset(ptr,0,sizeof(DEVICE_TD_INFO));
+ return ptr;
+ }
+}
+*/
+
+//
+// transmit descriptor
+//
+typedef struct tagSTxDesc {
+ volatile STDES0 m_td0TD0;
+ volatile STDES1 m_td1TD1;
+ volatile U32 buff_addr;
+ volatile U32 next_desc;
+ struct tagSTxDesc* next; //4 bytes
+ volatile PDEVICE_TD_INFO pTDInfo;//4 bytes
+ volatile U32 Reserved[2];//8 bytes
+} __attribute__ ((__packed__))
+STxDesc, DEF* PSTxDesc;
+typedef const STxDesc DEF* PCSTxDesc;
+
+
+typedef struct tagSTxSyncDesc {
+ volatile STDES0 m_td0TD0;
+ volatile STDES1 m_td1TD1;
+ volatile DWORD buff_addr; // pointer to logical buffer
+ volatile DWORD next_desc; // pointer to next logical descriptor
+ volatile WORD m_wFIFOCtl;
+ volatile WORD m_wTimeStamp;
+ struct tagSTxSyncDesc* next; //4 bytes
+ volatile PDEVICE_TD_INFO pTDInfo;//4 bytes
+ volatile DWORD m_dwReserved2;
+} __attribute__ ((__packed__))
+STxSyncDesc, DEF* PSTxSyncDesc;
+typedef const STxSyncDesc DEF* PCSTxSyncDesc;
+
+
+//
+// RsvTime buffer header
+//
+typedef struct tagSRrvTime_gRTS {
+ WORD wRTSTxRrvTime_ba;
+ WORD wRTSTxRrvTime_aa;
+ WORD wRTSTxRrvTime_bb;
+ WORD wReserved;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+}__attribute__ ((__packed__))
+SRrvTime_gRTS, DEF* PSRrvTime_gRTS;
+typedef const SRrvTime_gRTS DEF* PCSRrvTime_gRTS;
+
+typedef struct tagSRrvTime_gCTS {
+ WORD wCTSTxRrvTime_ba;
+ WORD wReserved;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+}__attribute__ ((__packed__))
+SRrvTime_gCTS, DEF* PSRrvTime_gCTS;
+typedef const SRrvTime_gCTS DEF* PCSRrvTime_gCTS;
+
+typedef struct tagSRrvTime_ab {
+ WORD wRTSTxRrvTime;
+ WORD wTxRrvTime;
+}__attribute__ ((__packed__))
+SRrvTime_ab, DEF* PSRrvTime_ab;
+typedef const SRrvTime_ab DEF* PCSRrvTime_ab;
+
+typedef struct tagSRrvTime_atim {
+ WORD wCTSTxRrvTime_ba;
+ WORD wTxRrvTime_a;
+}__attribute__ ((__packed__))
+SRrvTime_atim, DEF* PSRrvTime_atim;
+typedef const SRrvTime_atim DEF* PCSRrvTime_atim;
+
+//
+// RTS buffer header
+//
+typedef struct tagSRTSData {
+ WORD wFrameControl;
+ WORD wDurationID;
+ BYTE abyRA[U_ETHER_ADDR_LEN];
+ BYTE abyTA[U_ETHER_ADDR_LEN];
+}__attribute__ ((__packed__))
+SRTSData, DEF* PSRTSData;
+typedef const SRTSData DEF* PCSRTSData;
+
+typedef struct tagSRTS_g {
+ BYTE bySignalField_b;
+ BYTE byServiceField_b;
+ WORD wTransmitLength_b;
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_ba;
+ WORD wDuration_aa;
+ WORD wDuration_bb;
+ WORD wReserved;
+ SRTSData Data;
+}__attribute__ ((__packed__))
+SRTS_g, DEF* PSRTS_g;
+typedef const SRTS_g DEF* PCSRTS_g;
+
+
+typedef struct tagSRTS_g_FB {
+ BYTE bySignalField_b;
+ BYTE byServiceField_b;
+ WORD wTransmitLength_b;
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_ba;
+ WORD wDuration_aa;
+ WORD wDuration_bb;
+ WORD wReserved;
+ WORD wRTSDuration_ba_f0;
+ WORD wRTSDuration_aa_f0;
+ WORD wRTSDuration_ba_f1;
+ WORD wRTSDuration_aa_f1;
+ SRTSData Data;
+}__attribute__ ((__packed__))
+SRTS_g_FB, DEF* PSRTS_g_FB;
+typedef const SRTS_g_FB DEF* PCSRTS_g_FB;
+
+
+typedef struct tagSRTS_ab {
+ BYTE bySignalField;
+ BYTE byServiceField;
+ WORD wTransmitLength;
+ WORD wDuration;
+ WORD wReserved;
+ SRTSData Data;
+}__attribute__ ((__packed__))
+SRTS_ab, DEF* PSRTS_ab;
+typedef const SRTS_ab DEF* PCSRTS_ab;
+
+
+typedef struct tagSRTS_a_FB {
+ BYTE bySignalField;
+ BYTE byServiceField;
+ WORD wTransmitLength;
+ WORD wDuration;
+ WORD wReserved;
+ WORD wRTSDuration_f0;
+ WORD wRTSDuration_f1;
+ SRTSData Data;
+}__attribute__ ((__packed__))
+SRTS_a_FB, DEF* PSRTS_a_FB;
+typedef const SRTS_a_FB DEF* PCSRTS_a_FB;
+
+
+//
+// CTS buffer header
+//
+typedef struct tagSCTSData {
+ WORD wFrameControl;
+ WORD wDurationID;
+ BYTE abyRA[U_ETHER_ADDR_LEN];
+ WORD wReserved;
+}__attribute__ ((__packed__))
+SCTSData, DEF* PSCTSData;
+
+typedef struct tagSCTS {
+ BYTE bySignalField_b;
+ BYTE byServiceField_b;
+ WORD wTransmitLength_b;
+ WORD wDuration_ba;
+ WORD wReserved;
+ SCTSData Data;
+}__attribute__ ((__packed__))
+SCTS, DEF* PSCTS;
+typedef const SCTS DEF* PCSCTS;
+
+typedef struct tagSCTS_FB {
+ BYTE bySignalField_b;
+ BYTE byServiceField_b;
+ WORD wTransmitLength_b;
+ WORD wDuration_ba;
+ WORD wReserved;
+ WORD wCTSDuration_ba_f0;
+ WORD wCTSDuration_ba_f1;
+ SCTSData Data;
+}__attribute__ ((__packed__))
+SCTS_FB, DEF* PSCTS_FB;
+typedef const SCTS_FB DEF* PCSCTS_FB;
+
+
+//
+// Tx FIFO header
+//
+typedef struct tagSTxBufHead {
+ DWORD adwTxKey[4];
+ WORD wFIFOCtl;
+ WORD wTimeStamp;
+ WORD wFragCtl;
+ BYTE byTxPower;
+ BYTE wReserved;
+}__attribute__ ((__packed__))
+STxBufHead, DEF* PSTxBufHead;
+typedef const STxBufHead DEF* PCSTxBufHead;
+
+typedef struct tagSTxShortBufHead {
+ WORD wFIFOCtl;
+ WORD wTimeStamp;
+}__attribute__ ((__packed__))
+STxShortBufHead, DEF* PSTxShortBufHead;
+typedef const STxShortBufHead DEF* PCSTxShortBufHead;
+
+//
+// Tx data header
+//
+typedef struct tagSTxDataHead_g {
+ BYTE bySignalField_b;
+ BYTE byServiceField_b;
+ WORD wTransmitLength_b;
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_b;
+ WORD wDuration_a;
+ WORD wTimeStampOff_b;
+ WORD wTimeStampOff_a;
+}__attribute__ ((__packed__))
+STxDataHead_g, DEF* PSTxDataHead_g;
+typedef const STxDataHead_g DEF* PCSTxDataHead_g;
+
+typedef struct tagSTxDataHead_g_FB {
+ BYTE bySignalField_b;
+ BYTE byServiceField_b;
+ WORD wTransmitLength_b;
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_b;
+ WORD wDuration_a;
+ WORD wDuration_a_f0;
+ WORD wDuration_a_f1;
+ WORD wTimeStampOff_b;
+ WORD wTimeStampOff_a;
+}__attribute__ ((__packed__))
+STxDataHead_g_FB, DEF* PSTxDataHead_g_FB;
+typedef const STxDataHead_g_FB DEF* PCSTxDataHead_g_FB;
+
+
+typedef struct tagSTxDataHead_ab {
+ BYTE bySignalField;
+ BYTE byServiceField;
+ WORD wTransmitLength;
+ WORD wDuration;
+ WORD wTimeStampOff;
+}__attribute__ ((__packed__))
+STxDataHead_ab, DEF* PSTxDataHead_ab;
+typedef const STxDataHead_ab DEF* PCSTxDataHead_ab;
+
+
+typedef struct tagSTxDataHead_a_FB {
+ BYTE bySignalField;
+ BYTE byServiceField;
+ WORD wTransmitLength;
+ WORD wDuration;
+ WORD wTimeStampOff;
+ WORD wDuration_f0;
+ WORD wDuration_f1;
+}__attribute__ ((__packed__))
+STxDataHead_a_FB, DEF* PSTxDataHead_a_FB;
+typedef const STxDataHead_a_FB DEF* PCSTxDataHead_a_FB;
+
+//
+// MICHDR data header
+//
+typedef struct tagSMICHDRHead {
+ DWORD adwHDR0[4];
+ DWORD adwHDR1[4];
+ DWORD adwHDR2[4];
+}__attribute__ ((__packed__))
+SMICHDRHead, DEF* PSMICHDRHead;
+typedef const SMICHDRHead DEF* PCSMICHDRHead;
+
+typedef struct tagSBEACONCtl {
+ DWORD BufReady : 1;
+ DWORD TSF : 15;
+ DWORD BufLen : 11;
+ DWORD Reserved : 5;
+}__attribute__ ((__packed__))
+SBEACONCtl;
+
+
+typedef struct tagSSecretKey {
+ DWORD dwLowDword;
+ BYTE byHighByte;
+}__attribute__ ((__packed__))
+SSecretKey;
+
+typedef struct tagSKeyEntry {
+ BYTE abyAddrHi[2];
+ WORD wKCTL;
+ BYTE abyAddrLo[4];
+ DWORD dwKey0[4];
+ DWORD dwKey1[4];
+ DWORD dwKey2[4];
+ DWORD dwKey3[4];
+ DWORD dwKey4[4];
+}__attribute__ ((__packed__))
+SKeyEntry;
+/*--------------------- Export Macros ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+
+#endif // __DESC_H__
+
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
new file mode 100644
index 000000000000..264d1bb2ff79
--- /dev/null
+++ b/drivers/staging/vt6655/device.h
@@ -0,0 +1,1063 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: device.h
+ *
+ * Purpose: MAC Data structure
+ *
+ * Author: Tevin Chen
+ *
+ * Date: Mar 17, 1997
+ *
+ */
+
+#ifndef __DEVICE_H__
+#define __DEVICE_H__
+
+#ifdef MODULE
+#ifdef MODVERSIONS
+#include <linux/modversions.h>
+#endif /* MODVERSIONS */
+#include <linux/module.h>
+#endif /* MODULE */
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/version.h>
+#include <linux/string.h>
+#include <linux/wait.h>
+#include <linux/if_arp.h>
+#include <linux/sched.h>
+#include <asm/io.h>
+#include <linux/if.h>
+//#include <linux/config.h>
+#include <asm/uaccess.h>
+#include <linux/proc_fs.h>
+#include <linux/inetdevice.h>
+#include <linux/reboot.h>
+#ifdef SIOCETHTOOL
+#define DEVICE_ETHTOOL_IOCTL_SUPPORT
+#include <linux/ethtool.h>
+#else
+#undef DEVICE_ETHTOOL_IOCTL_SUPPORT
+#endif
+/* Include Wireless Extension definition and check version - Jean II */
+#include <linux/wireless.h>
+#if WIRELESS_EXT > 12
+#include <net/iw_handler.h> // New driver API
+#endif /* WIRELESS_EXT > 12 */
+
+//2008-0409-07, <Add> by Einsn Liu
+#if WIRELESS_EXT > 17
+#ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#endif
+#endif
+//2008-4-14<add> by chester for led issue
+//#define FOR_LED_ON_NOTEBOOK
+//
+
+
+
+// device specific
+//
+#if !defined(_KCOMPAT_H)
+#include "kcompat.h"
+#endif
+
+#if !defined(__DEVICE_CONFIG_H)
+#include "device_cfg.h"
+#endif
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__MIB_H__)
+#include "mib.h"
+#endif
+#if !defined(__SROM_H__)
+#include "srom.h"
+#endif
+#if !defined(__RC4_H__)
+#include "rc4.h"
+#endif
+#if !defined(__TPCI_H__)
+#include "tpci.h"
+#endif
+#if !defined(__DESC_H__)
+#include "desc.h"
+#endif
+
+#if !defined(__KEY_H__)
+#include "key.h"
+#endif
+
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+
+//PLICE_DEBUG->
+//#define THREAD
+
+//#define TASK_LET
+//PLICE_DEBUG<-
+
+// #ifdef PRIVATE_OBJ
+//#if !defined(__DEVICE_MODULE_H)
+//#include "device_module.h"
+//#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define MAC_MAX_CONTEXT_REG (256+128)
+
+#define MAX_MULTICAST_ADDRESS_NUM 32
+#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * U_ETHER_ADDR_LEN)
+
+
+//#define OP_MODE_INFRASTRUCTURE 0
+//#define OP_MODE_ADHOC 1
+//#define OP_MODE_AP 2
+
+#define DUPLICATE_RX_CACHE_LENGTH 5
+
+#define NUM_KEY_ENTRY 11
+
+#define TX_WEP_NONE 0
+#define TX_WEP_OTF 1
+#define TX_WEP_SW 2
+#define TX_WEP_SWOTP 3
+#define TX_WEP_OTPSW 4
+#define TX_WEP_SW232 5
+
+#define KEYSEL_WEP40 0
+#define KEYSEL_WEP104 1
+#define KEYSEL_TKIP 2
+#define KEYSEL_CCMP 3
+
+
+
+#define AUTO_FB_NONE 0
+#define AUTO_FB_0 1
+#define AUTO_FB_1 2
+
+#define FB_RATE0 0
+#define FB_RATE1 1
+
+// Antenna Mode
+#define ANT_A 0
+#define ANT_B 1
+#define ANT_DIVERSITY 2
+#define ANT_RXD_TXA 3
+#define ANT_RXD_TXB 4
+#define ANT_UNKNOWN 0xFF
+
+#define MAXCHECKHANGCNT 4
+
+#define BB_VGA_LEVEL 4
+#define BB_VGA_CHANGE_THRESHOLD 16
+
+
+#ifndef RUN_AT
+#define RUN_AT(x) (jiffies+(x))
+#endif
+
+// DMA related
+#define RESERV_AC0DMA 4
+
+
+// BUILD OBJ mode
+#ifdef PRIVATE_OBJ
+
+#undef dev_kfree_skb
+#undef dev_kfree_skb_irq
+#undef dev_alloc_skb
+#undef kfree
+#undef del_timer
+#undef init_timer
+#undef add_timer
+#undef kmalloc
+#undef netif_stop_queue
+#undef netif_start_queue
+#undef netif_wake_queue
+#undef netif_queue_stopped
+#undef netif_rx
+#undef netif_running
+#undef udelay
+#undef mdelay
+#undef eth_type_trans
+#undef skb_put
+#undef HZ
+#undef RUN_AT
+#undef pci_alloc_consistent
+#undef pci_free_consistent
+#undef register_netdevice
+#undef register_netdev
+#undef unregister_netdevice
+#undef unregister_netdev
+#undef skb_queue_head_init
+#undef skb_queue_tail
+#undef skb_queue_empty
+#undef free_irq
+#undef copy_from_user
+#undef copy_to_user
+#undef spin_lock_init
+#undef pci_map_single
+#undef pci_unmap_single
+
+// redefine kernel dependent fucntion
+#define dev_kfree_skb ref_dev_kfree_skb
+#define dev_kfree_skb_irq ref_dev_kfree_skb_irq
+#define dev_alloc_skb ref_dev_alloc_skb
+#define kfree ref_kfree
+#define del_timer ref_del_timer
+#define init_timer ref_init_timer
+#define add_timer ref_add_timer
+#define kmalloc ref_kmalloc
+#define netif_stop_queue ref_netif_stop_queue
+#define netif_start_queue ref_netif_start_queue
+#define netif_wake_queue ref_netif_wake_queue
+#define netif_queue_stopped ref_netif_queue_stopped
+#define netif_rx ref_netif_rx
+#define netif_running ref_netif_running
+#define udelay ref_udelay
+#define mdelay ref_mdelay
+#define get_jiffies() ref_get_jiffies()
+#define RUN_AT(x) (get_jiffies()+(x))
+#define HZ ref_HZ_tick()
+#define eth_type_trans ref_eth_type_trans
+#define skb_put ref_skb_put
+#define skb_queue_head_init ref_skb_queue_head_init
+#define skb_queue_tail ref_skb_queue_tail
+#define skb_queue_empty ref_skb_queue_empty
+
+#define pci_alloc_consistent ref_pci_alloc_consistent
+#define pci_free_consistent ref_pci_free_consistent
+#define register_netdevice ref_register_netdevice
+#define register_netdev ref_register_netdev
+#define unregister_netdevice ref_unregister_netdevice
+#define unregister_netdev ref_unregister_netdev
+
+#define free_irq ref_free_irq
+#define copy_from_user ref_copy_from_user
+#define copy_to_user ref_copy_to_user
+#define spin_lock_init ref_spin_lock_init
+#define pci_map_single ref_pci_map_single
+#define pci_unmap_single ref_pci_unmap_single
+#endif
+
+
+#ifdef PRIVATE_OBJ
+#undef printk
+#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) do {} while (0);}
+//#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
+#else
+#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
+#endif
+
+
+#define AVAIL_TD(p,q) ((p)->sOpts.nTxDescs[(q)]-((p)->iTDUsed[(q)]))
+
+//PLICE_DEBUG ->
+#define NUM 64
+//PLICE_DEUBG <-
+
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+//0:11A 1:11B 2:11G
+typedef enum _VIA_BB_TYPE
+{
+ BB_TYPE_11A=0,
+ BB_TYPE_11B,
+ BB_TYPE_11G
+} VIA_BB_TYPE, *PVIA_BB_TYPE;
+
+//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
+typedef enum _VIA_PKT_TYPE
+{
+ PK_TYPE_11A=0,
+ PK_TYPE_11B,
+ PK_TYPE_11GB,
+ PK_TYPE_11GA
+} VIA_PKT_TYPE, *PVIA_PKT_TYPE;
+
+
+typedef enum __device_msg_level {
+ MSG_LEVEL_ERR=0, //Errors that will cause abnormal operation.
+ MSG_LEVEL_NOTICE=1, //Some errors need users to be notified.
+ MSG_LEVEL_INFO=2, //Normal message.
+ MSG_LEVEL_VERBOSE=3, //Will report all trival errors.
+ MSG_LEVEL_DEBUG=4 //Only for debug purpose.
+} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
+
+typedef enum __device_init_type {
+ DEVICE_INIT_COLD=0, // cold init
+ DEVICE_INIT_RESET, // reset init or Dx to D0 power remain init
+ DEVICE_INIT_DXPL // Dx to D0 power lost init
+} DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE;
+
+
+//++ NDIS related
+
+#define MAX_BSSIDINFO_4_PMKID 16
+#define MAX_PMKIDLIST 5
+//Flags for PMKID Candidate list structure
+#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
+
+// PMKID Structures
+typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
+
+
+typedef enum _NDIS_802_11_WEP_STATUS
+{
+ Ndis802_11WEPEnabled,
+ Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
+ Ndis802_11WEPDisabled,
+ Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
+ Ndis802_11WEPKeyAbsent,
+ Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
+ Ndis802_11WEPNotSupported,
+ Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
+ Ndis802_11Encryption2Enabled,
+ Ndis802_11Encryption2KeyAbsent,
+ Ndis802_11Encryption3Enabled,
+ Ndis802_11Encryption3KeyAbsent
+} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
+ NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
+
+
+typedef enum _NDIS_802_11_STATUS_TYPE
+{
+ Ndis802_11StatusType_Authentication,
+ Ndis802_11StatusType_MediaStreamMode,
+ Ndis802_11StatusType_PMKID_CandidateList,
+ Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
+} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
+
+//Added new types for PMKID Candidate lists.
+typedef struct _PMKID_CANDIDATE {
+ NDIS_802_11_MAC_ADDRESS BSSID;
+ ULONG Flags;
+} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
+
+
+typedef struct _BSSID_INFO
+{
+ NDIS_802_11_MAC_ADDRESS BSSID;
+ NDIS_802_11_PMKID_VALUE PMKID;
+} BSSID_INFO, *PBSSID_INFO;
+
+typedef struct tagSPMKID {
+ ULONG Length;
+ ULONG BSSIDInfoCount;
+ BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
+} SPMKID, *PSPMKID;
+
+typedef struct tagSPMKIDCandidateEvent {
+ NDIS_802_11_STATUS_TYPE StatusType;
+ ULONG Version; // Version of the structure
+ ULONG NumCandidates; // No. of pmkid candidates
+ PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
+} SPMKIDCandidateEvent, DEF* PSPMKIDCandidateEvent;
+
+
+//--
+
+//++ 802.11h related
+#define MAX_QUIET_COUNT 8
+
+typedef struct tagSQuietControl {
+ BOOL bEnable;
+ DWORD dwStartTime;
+ BYTE byPeriod;
+ WORD wDuration;
+} SQuietControl, DEF* PSQuietControl;
+
+//--
+typedef struct __chip_info_tbl{
+ CHIP_TYPE chip_id;
+ char* name;
+ int io_size;
+ int nTxQueue;
+ U32 flags;
+} CHIP_INFO, *PCHIP_INFO;
+
+
+typedef enum {
+ OWNED_BY_HOST=0,
+ OWNED_BY_NIC=1
+} DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
+
+
+// The receive duplicate detection cache entry
+typedef struct tagSCacheEntry{
+ WORD wFmSequence;
+ BYTE abyAddr2[U_ETHER_ADDR_LEN];
+} SCacheEntry, *PSCacheEntry;
+
+
+typedef struct tagSCache{
+/* The receive cache is updated circularly. The next entry to be written is
+ * indexed by the "InPtr".
+*/
+ UINT uInPtr; // Place to use next
+ SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
+} SCache, *PSCache;
+
+#define CB_MAX_RX_FRAG 64
+// DeFragment Control Block, used for collecting fragments prior to reassembly
+typedef struct tagSDeFragControlBlock
+{
+ WORD wSequence;
+ WORD wFragNum;
+ BYTE abyAddr2[U_ETHER_ADDR_LEN];
+ UINT uLifetime;
+ struct sk_buff* skb;
+#ifdef PRIVATE_OBJ
+ ref_sk_buff ref_skb;
+#endif
+ PBYTE pbyRxBuffer;
+ UINT cbFrameLength;
+ BOOL bInUse;
+} SDeFragControlBlock, DEF* PSDeFragControlBlock;
+
+
+
+
+//flags for options
+#define DEVICE_FLAGS_IP_ALIGN 0x00000001UL
+#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL
+#define DEVICE_FLAGS_OP_MODE 0x00000004UL
+#define DEVICE_FLAGS_PS_MODE 0x00000008UL
+#define DEVICE_FLAGS_80211h_MODE 0x00000010UL
+#define DEVICE_FLAGS_DiversityANT 0x00000020UL
+
+//flags for driver status
+#define DEVICE_FLAGS_OPENED 0x00010000UL
+#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL
+//flags for capbilities
+#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL
+#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL
+#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL
+
+//flags for MII status
+#define DEVICE_LINK_FAIL 0x00000001UL
+#define DEVICE_SPEED_10 0x00000002UL
+#define DEVICE_SPEED_100 0x00000004UL
+#define DEVICE_SPEED_1000 0x00000008UL
+#define DEVICE_DUPLEX_FULL 0x00000010UL
+#define DEVICE_AUTONEG_ENABLE 0x00000020UL
+#define DEVICE_FORCED_BY_EEPROM 0x00000040UL
+//for device_set_media_duplex
+#define DEVICE_LINK_CHANGE 0x00000001UL
+
+
+//PLICE_DEBUG->
+
+
+typedef struct _RxManagementQueue
+{
+ int packet_num;
+ int head,tail;
+ PSRxMgmtPacket Q[NUM];
+} RxManagementQueue,*PSRxManagementQueue;
+
+
+
+//PLICE_DEBUG<-
+
+
+typedef struct __device_opt {
+ int nRxDescs0; //Number of RX descriptors0
+ int nRxDescs1; //Number of RX descriptors1
+ int nTxDescs[2]; //Number of TX descriptors 0, 1
+ int int_works; //interrupt limits
+ int rts_thresh; //rts threshold
+ int frag_thresh;
+ int data_rate;
+ int channel_num;
+ int short_retry;
+ int long_retry;
+ int bbp_type;
+ U32 flags;
+} OPTIONS, *POPTIONS;
+
+
+typedef struct __device_info {
+ struct __device_info* next;
+ struct __device_info* prev;
+
+ struct pci_dev* pcid;
+
+#if CONFIG_PM
+ u32 pci_state[16];
+#endif
+
+// netdev
+ struct net_device* dev;
+ struct net_device* next_module;
+ struct net_device_stats stats;
+
+//dma addr, rx/tx pool
+ dma_addr_t pool_dma;
+ dma_addr_t rd0_pool_dma;
+ dma_addr_t rd1_pool_dma;
+
+ dma_addr_t td0_pool_dma;
+ dma_addr_t td1_pool_dma;
+
+ dma_addr_t tx_bufs_dma0;
+ dma_addr_t tx_bufs_dma1;
+ dma_addr_t tx_beacon_dma;
+
+ PBYTE tx0_bufs;
+ PBYTE tx1_bufs;
+ PBYTE tx_beacon_bufs;
+
+ CHIP_TYPE chip_id;
+
+ U32 PortOffset;
+ DWORD dwIsr;
+ U32 memaddr;
+ U32 ioaddr;
+ U32 io_size;
+
+ BYTE byRevId;
+ WORD SubSystemID;
+ WORD SubVendorID;
+
+ int nTxQueues;
+ volatile int iTDUsed[TYPE_MAXTD];
+
+ volatile PSTxDesc apCurrTD[TYPE_MAXTD];
+ volatile PSTxDesc apTailTD[TYPE_MAXTD];
+
+ volatile PSTxDesc apTD0Rings;
+ volatile PSTxDesc apTD1Rings;
+
+ volatile PSRxDesc aRD0Ring;
+ volatile PSRxDesc aRD1Ring;
+ volatile PSRxDesc pCurrRD[TYPE_MAXRD];
+ SCache sDupRxCache;
+
+ SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG];
+ UINT cbDFCB;
+ UINT cbFreeDFCB;
+ UINT uCurrentDFCBIdx;
+
+ OPTIONS sOpts;
+
+ U32 flags;
+
+ U32 rx_buf_sz;
+ int multicast_limit;
+ BYTE byRxMode;
+
+ spinlock_t lock;
+//PLICE_DEBUG->
+ struct tasklet_struct RxMngWorkItem;
+ RxManagementQueue rxManeQueue;
+//PLICE_DEBUG<-
+//PLICE_DEBUG ->
+ pid_t MLMEThr_pid;
+ struct completion notify;
+ struct semaphore mlme_semaphore;
+//PLICE_DEBUG <-
+
+
+ U32 rx_bytes;
+
+ // Version control
+ BYTE byLocalID;
+ BYTE byRFType;
+
+ BYTE byMaxPwrLevel;
+ BYTE byZoneType;
+ BOOL bZoneRegExist;
+ BYTE byOriginalZonetype;
+ BYTE abyMacContext[MAC_MAX_CONTEXT_REG];
+ BOOL bLinkPass; // link status: OK or fail
+ BYTE abyCurrentNetAddr[U_ETHER_ADDR_LEN];
+
+ // Adapter statistics
+ SStatCounter scStatistic;
+ // 802.11 counter
+ SDot11Counters s802_11Counter;
+
+
+ // 802.11 management
+ PSMgmtObject pMgmt;
+ SMgmtObject sMgmtObj;
+
+ // 802.11 MAC specific
+ UINT uCurrRSSI;
+ BYTE byCurrSQ;
+
+ DWORD dwTxAntennaSel;
+ DWORD dwRxAntennaSel;
+ BYTE byAntennaCount;
+ BYTE byRxAntennaMode;
+ BYTE byTxAntennaMode;
+ BOOL bTxRxAntInv;
+
+ PBYTE pbyTmpBuff;
+ UINT uSIFS; //Current SIFS
+ UINT uDIFS; //Current DIFS
+ UINT uEIFS; //Current EIFS
+ UINT uSlot; //Current SlotTime
+ UINT uCwMin; //Current CwMin
+ UINT uCwMax; //CwMax is fixed on 1023.
+ // PHY parameter
+ BYTE bySIFS;
+ BYTE byDIFS;
+ BYTE byEIFS;
+ BYTE bySlot;
+ BYTE byCWMaxMin;
+ CARD_PHY_TYPE eCurrentPHYType;
+
+
+ VIA_BB_TYPE byBBType; //0: 11A, 1:11B, 2:11G
+ VIA_PKT_TYPE byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
+ WORD wBasicRate;
+ BYTE byACKRate;
+ BYTE byTopOFDMBasicRate;
+ BYTE byTopCCKBasicRate;
+
+ BYTE byMinChannel;
+ BYTE byMaxChannel;
+ UINT uConnectionRate;
+
+ BYTE byPreambleType;
+ BYTE byShortPreamble;
+
+ WORD wCurrentRate;
+ WORD wRTSThreshold;
+ WORD wFragmentationThreshold;
+ BYTE byShortRetryLimit;
+ BYTE byLongRetryLimit;
+ CARD_OP_MODE eOPMode;
+ BYTE byOpMode;
+ BOOL bBSSIDFilter;
+ WORD wMaxTransmitMSDULifetime;
+ BYTE abyBSSID[U_ETHER_ADDR_LEN];
+ BYTE abyDesireBSSID[U_ETHER_ADDR_LEN];
+ WORD wCTSDuration; // update while speed change
+ WORD wACKDuration; // update while speed change
+ WORD wRTSTransmitLen; // update while speed change
+ BYTE byRTSServiceField; // update while speed change
+ BYTE byRTSSignalField; // update while speed change
+
+ DWORD dwMaxReceiveLifetime; // dot11MaxReceiveLifetime
+
+ BOOL bCCK;
+ BOOL bEncryptionEnable;
+ BOOL bLongHeader;
+ BOOL bShortSlotTime;
+ BOOL bProtectMode;
+ BOOL bNonERPPresent;
+ BOOL bBarkerPreambleMd;
+
+ BYTE byERPFlag;
+ WORD wUseProtectCntDown;
+
+ BOOL bRadioControlOff;
+ BOOL bRadioOff;
+ BOOL bEnablePSMode;
+ WORD wListenInterval;
+ BOOL bPWBitOn;
+ WMAC_POWER_MODE ePSMode;
+
+
+ // GPIO Radio Control
+ BYTE byRadioCtl;
+ BYTE byGPIO;
+ BOOL bHWRadioOff;
+ BOOL bPrvActive4RadioOFF;
+ BOOL bGPIOBlockRead;
+
+ // Beacon releated
+ WORD wSeqCounter;
+ WORD wBCNBufLen;
+ BOOL bBeaconBufReady;
+ BOOL bBeaconSent;
+ BOOL bIsBeaconBufReadySet;
+ UINT cbBeaconBufReadySetCnt;
+ BOOL bFixRate;
+ BYTE byCurrentCh;
+ UINT uScanTime;
+
+ CMD_STATE eCommandState;
+
+ CMD_CODE eCommand;
+ BOOL bBeaconTx;
+
+ BOOL bStopBeacon;
+ BOOL bStopDataPkt;
+ BOOL bStopTx0Pkt;
+ UINT uAutoReConnectTime;
+
+ // 802.11 counter
+
+ CMD_ITEM eCmdQueue[CMD_Q_SIZE];
+ UINT uCmdDequeueIdx;
+ UINT uCmdEnqueueIdx;
+ UINT cbFreeCmdQueue;
+ BOOL bCmdRunning;
+ BOOL bCmdClear;
+
+
+
+ BOOL bRoaming;
+ //WOW
+ BYTE abyIPAddr[4];
+
+ ULONG ulTxPower;
+ NDIS_802_11_WEP_STATUS eEncryptionStatus;
+ BOOL bTransmitKey;
+//2007-0925-01<Add>by MikeLiu
+//mike add :save old Encryption
+ NDIS_802_11_WEP_STATUS eOldEncryptionStatus;
+ SKeyManagement sKey;
+ DWORD dwIVCounter;
+
+ QWORD qwPacketNumber; //For CCMP and TKIP as TSC(6 bytes)
+ UINT uCurrentWEPMode;
+
+ RC4Ext SBox;
+ BYTE abyPRNG[WLAN_WEPMAX_KEYLEN+3];
+
+ BYTE byKeyIndex;
+ UINT uKeyLength;
+ BYTE abyKey[WLAN_WEP232_KEYLEN];
+
+ BOOL bAES;
+ BYTE byCntMeasure;
+
+ // for AP mode
+ UINT uAssocCount;
+ BOOL bMoreData;
+
+ // QoS
+ BOOL bGrpAckPolicy;
+
+ // for OID_802_11_ASSOCIATION_INFORMATION
+ BOOL bAssocInfoSet;
+
+
+ BYTE byAutoFBCtrl;
+
+ BOOL bTxMICFail;
+ BOOL bRxMICFail;
+
+
+ UINT uRATEIdx;
+
+
+ // For Update BaseBand VGA Gain Offset
+ BOOL bUpdateBBVGA;
+ UINT uBBVGADiffCount;
+ BYTE byBBVGANew;
+ BYTE byBBVGACurrent;
+ BYTE abyBBVGA[BB_VGA_LEVEL];
+ LONG ldBmThreshold[BB_VGA_LEVEL];
+
+ BYTE byBBPreEDRSSI;
+ BYTE byBBPreEDIndex;
+
+ BOOL bRadioCmd;
+ DWORD dwDiagRefCount;
+
+ // For FOE Tuning
+ BYTE byFOETuning;
+
+ // For Auto Power Tunning
+
+ BYTE byAutoPwrTunning;
+ SHORT sPSetPointCCK;
+ SHORT sPSetPointOFDMG;
+ SHORT sPSetPointOFDMA;
+ LONG lPFormulaOffset;
+ SHORT sPThreshold;
+ CHAR cAdjustStep;
+ CHAR cMinTxAGC;
+
+ // For RF Power table
+ BYTE byCCKPwr;
+ BYTE byOFDMPwrG;
+ BYTE byCurPwr;
+ I8 byCurPwrdBm;
+ BYTE abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
+ BYTE abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
+ I8 abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
+ I8 abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
+ I8 abyRegPwr[CB_MAX_CHANNEL+1];
+ I8 abyLocalPwr[CB_MAX_CHANNEL+1];
+
+
+ // BaseBand Loopback Use
+ BYTE byBBCR4d;
+ BYTE byBBCRc9;
+ BYTE byBBCR88;
+ BYTE byBBCR09;
+
+ // command timer
+ struct timer_list sTimerCommand;
+#ifdef TxInSleep
+ struct timer_list sTimerTxData;
+ ULONG nTxDataTimeCout;
+ BOOL fTxDataInSleep;
+ BOOL IsTxDataTrigger;
+#endif
+
+#ifdef WPA_SM_Transtatus
+ BOOL fWPA_Authened; //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
+#endif
+ BYTE byReAssocCount; //mike add:re-association retry times!
+ BYTE byLinkWaitCount;
+
+
+ BYTE abyNodeName[17];
+
+ BOOL bDiversityRegCtlON;
+ BOOL bDiversityEnable;
+ ULONG ulDiversityNValue;
+ ULONG ulDiversityMValue;
+ BYTE byTMax;
+ BYTE byTMax2;
+ BYTE byTMax3;
+ ULONG ulSQ3TH;
+
+// ANT diversity
+ ULONG uDiversityCnt;
+ BYTE byAntennaState;
+ ULONG ulRatio_State0;
+ ULONG ulRatio_State1;
+
+ //SQ3 functions for antenna diversity
+ struct timer_list TimerSQ3Tmax1;
+ struct timer_list TimerSQ3Tmax2;
+ struct timer_list TimerSQ3Tmax3;
+
+
+ ULONG uNumSQ3[MAX_RATE];
+ WORD wAntDiversityMaxRate;
+
+
+ SEthernetHeader sTxEthHeader;
+ SEthernetHeader sRxEthHeader;
+ BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN];
+ BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN];
+ BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN];
+ BYTE abyEEPROM[EEP_MAX_CONTEXT_SIZE]; //DWORD alignment
+ // Pre-Authentication & PMK cache
+ SPMKID gsPMKID;
+ SPMKIDCandidateEvent gsPMKIDCandidate;
+
+
+ // for 802.11h
+ BOOL b11hEnable;
+ BYTE abyCountryCode[3];
+ // for 802.11h DFS
+ UINT uNumOfMeasureEIDs;
+ PWLAN_IE_MEASURE_REQ pCurrMeasureEID;
+ BOOL bMeasureInProgress;
+ BYTE byOrgChannel;
+ BYTE byOrgRCR;
+ DWORD dwOrgMAR0;
+ DWORD dwOrgMAR4;
+ BYTE byBasicMap;
+ BYTE byCCAFraction;
+ BYTE abyRPIs[8];
+ DWORD dwRPIs[8];
+ BOOL bChannelSwitch;
+ BYTE byNewChannel;
+ BYTE byChannelSwitchCount;
+ BOOL bQuietEnable;
+ BOOL bEnableFirstQuiet;
+ BYTE byQuietStartCount;
+ UINT uQuietEnqueue;
+ DWORD dwCurrentQuietEndTime;
+ SQuietControl sQuiet[MAX_QUIET_COUNT];
+ // for 802.11h TPC
+ BOOL bCountryInfo5G;
+ BOOL bCountryInfo24G;
+
+ WORD wBeaconInterval;
+
+ //WPA supplicant deamon
+ struct net_device *wpadev;
+ BOOL bWPADEVUp;
+ struct sk_buff *skb;
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+/*
+ BOOL bwextstep0;
+ BOOL bwextstep1;
+ BOOL bwextstep2;
+ BOOL bwextstep3;
+ */
+ UINT bwextcount;
+ BOOL bWPASuppWextEnabled;
+#endif
+
+ //--
+#ifdef HOSTAP
+ // user space daemon: hostapd, is used for HOSTAP
+ BOOL bEnableHostapd;
+ BOOL bEnable8021x;
+ BOOL bEnableHostWEP;
+ struct net_device *apdev;
+ int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
+#endif
+ UINT uChannel;
+ BOOL bMACSuspend;
+
+#ifdef WIRELESS_EXT
+ struct iw_statistics wstats; // wireless stats
+#endif /* WIRELESS_EXT */
+ BOOL bCommit;
+
+} DEVICE_INFO, *PSDevice;
+
+
+//PLICE_DEBUG->
+
+
+ inline static VOID EnQueue (PSDevice pDevice,PSRxMgmtPacket pRxMgmtPacket)
+{
+ //printk("Enter EnQueue:tail is %d\n",pDevice->rxManeQueue.tail);
+ if ((pDevice->rxManeQueue.tail+1) % NUM == pDevice->rxManeQueue.head)
+ {
+ //printk("Queue is Full,tail is %d\n",pDevice->rxManeQueue.tail);
+ return ;
+ }
+ else
+ {
+ pDevice->rxManeQueue.tail = (pDevice->rxManeQueue.tail+1)% NUM;
+ pDevice->rxManeQueue.Q[pDevice->rxManeQueue.tail] = pRxMgmtPacket;
+ pDevice->rxManeQueue.packet_num++;
+ //printk("packet num is %d\n",pDevice->rxManeQueue.packet_num);
+ }
+}
+
+
+
+
+ inline static PSRxMgmtPacket DeQueue (PSDevice pDevice)
+{
+ PSRxMgmtPacket pRxMgmtPacket;
+ if (pDevice->rxManeQueue.tail == pDevice->rxManeQueue.head)
+ {
+ printk("Queue is Empty\n");
+ return NULL;
+ }
+ else
+ {
+ int x;
+ //x=pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
+ pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
+ x = pDevice->rxManeQueue.head;
+ //printk("Enter DeQueue:head is %d\n",x);
+ pRxMgmtPacket = pDevice->rxManeQueue.Q[x];
+ pDevice->rxManeQueue.packet_num--;
+ return pRxMgmtPacket;
+ }
+}
+
+VOID InitRxManagementQueue(PSDevice pDevice);
+
+
+
+//PLICE_DEBUG<-
+
+
+
+
+
+
+inline static BOOL device_get_ip(PSDevice pInfo) {
+ struct in_device* in_dev=(struct in_device*) pInfo->dev->ip_ptr;
+ struct in_ifaddr* ifa;
+
+ if (in_dev!=NULL) {
+ ifa=(struct in_ifaddr*) in_dev->ifa_list;
+ if (ifa!=NULL) {
+ memcpy(pInfo->abyIPAddr,&ifa->ifa_address,4);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+
+static inline PDEVICE_RD_INFO alloc_rd_info(void) {
+ PDEVICE_RD_INFO ptr;
+ if ((ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC)) == NULL)
+ return NULL;
+ else {
+ memset(ptr,0,sizeof(DEVICE_RD_INFO));
+ return ptr;
+ }
+}
+
+static inline PDEVICE_TD_INFO alloc_td_info(void) {
+ PDEVICE_TD_INFO ptr;
+ if ((ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC))==NULL)
+ return NULL;
+ else {
+ memset(ptr,0,sizeof(DEVICE_TD_INFO));
+ return ptr;
+ }
+}
+
+/*--------------------- Export Functions --------------------------*/
+
+BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex);
+BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
+int Config_FileOperation(PSDevice pDevice,BOOL fwrite,unsigned char *Parameter);
+#endif
+
+
diff --git a/drivers/staging/vt6655/device_cfg.h b/drivers/staging/vt6655/device_cfg.h
new file mode 100644
index 000000000000..1cbb4440b46f
--- /dev/null
+++ b/drivers/staging/vt6655/device_cfg.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: device_cfg.h
+ *
+ * Purpose: Driver configuration header
+ * Author: Lyndon Chen
+ *
+ * Date: Dec 17, 2002
+ *
+ */
+#ifndef __DEVICE_CONFIG_H
+#define __DEVICE_CONFIG_H
+
+//#include <linux/config.h>
+#include <linux/types.h>
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+typedef __u8 UINT8, *PUINT8;
+typedef __u16 UINT16, *PUINT16;
+typedef __u32 UINT32, *PUINT32;
+
+
+#ifndef VOID
+#define VOID void
+#endif
+
+#ifndef CONST
+#define CONST const
+#endif
+
+#ifndef STATIC
+#define STATIC static
+#endif
+
+#ifndef DEF
+#define DEF
+#endif
+
+#ifndef IN
+#define IN
+#endif
+
+#ifndef OUT
+#define OUT
+#endif
+
+typedef
+struct _version {
+ UINT8 major;
+ UINT8 minor;
+ UINT8 build;
+} version_t, *pversion_t;
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+
+#ifndef TRUE
+#define TRUE (!(FALSE))
+#endif
+
+#define VID_TABLE_SIZE 64
+#define MCAST_TABLE_SIZE 64
+#define MCAM_SIZE 32
+#define VCAM_SIZE 32
+#define TX_QUEUE_NO 8
+
+#define DEVICE_NAME "vt6655"
+#define DEVICE_FULL_DRV_NAM "VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver"
+
+#ifndef MAJOR_VERSION
+#define MAJOR_VERSION 1
+#endif
+
+#ifndef MINOR_VERSION
+#define MINOR_VERSION 17
+#endif
+
+#ifndef DEVICE_VERSION
+#define DEVICE_VERSION "1.19.12"
+#endif
+//config file
+#include <linux/fs.h>
+#include <linux/fcntl.h>
+#ifndef CONFIG_PATH
+#define CONFIG_PATH "/etc/vntconfiguration.dat"
+#endif
+
+//Max: 2378=2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
+#define PKT_BUF_SZ 2390
+
+
+#define MALLOC(x,y) kmalloc((x),(y))
+#define FREE(x) kfree((x))
+#define MAX_UINTS 8
+#define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1}
+
+
+
+typedef enum _chip_type{
+ VT3253=1
+} CHIP_TYPE, *PCHIP_TYPE;
+
+
+
+#ifdef VIAWET_DEBUG
+#define ASSERT(x) { \
+ if (!(x)) { \
+ printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\
+ __FUNCTION__, __LINE__);\
+ *(int*) 0=0;\
+ }\
+}
+#define DBG_PORT80(value) outb(value, 0x80)
+#else
+#define ASSERT(x)
+#define DBG_PORT80(value)
+#endif
+
+
+#endif
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
new file mode 100644
index 000000000000..d8f7f4f7bac4
--- /dev/null
+++ b/drivers/staging/vt6655/device_main.c
@@ -0,0 +1,4159 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: device_main.c
+ *
+ * Purpose: driver entry for initial, open, close, tx and rx.
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Jan 8, 2003
+ *
+ * Functions:
+ *
+ * device_found1 - module initial (insmod) driver entry
+ * device_remove1 - module remove entry
+ * device_init_info - device structure resource allocation function
+ * device_free_info - device structure resource free function
+ * device_get_pci_info - get allocated pci io/mem resource
+ * device_print_info - print out resource
+ * device_open - allocate dma/descripter resource & initial mac/bbp function
+ * device_xmit - asynchrous data tx function
+ * device_intr - interrupt handle function
+ * device_set_multi - set mac filter
+ * device_ioctl - ioctl entry
+ * device_close - shutdown mac/bbp & free dma/descripter resource
+ * device_rx_srv - rx service function
+ * device_receive_frame - rx data function
+ * device_alloc_rx_buf - rx buffer pre-allocated function
+ * device_alloc_frag_buf - rx fragement pre-allocated function
+ * device_free_tx_buf - free tx buffer function
+ * device_free_frag_buf- free de-fragement buffer
+ * device_dma0_tx_80211- tx 802.11 frame via dma0
+ * device_dma0_xmit- tx PS bufferred frame via dma0
+ * device_init_rd0_ring- initial rd dma0 ring
+ * device_init_rd1_ring- initial rd dma1 ring
+ * device_init_td0_ring- initial tx dma0 ring buffer
+ * device_init_td1_ring- initial tx dma1 ring buffer
+ * device_init_registers- initial MAC & BBP & RF internal registers.
+ * device_init_rings- initial tx/rx ring buffer
+ * device_init_defrag_cb- initial & allocate de-fragement buffer.
+ * device_free_rings- free all allocated ring buffer
+ * device_tx_srv- tx interrupt service function
+ *
+ * Revision History:
+ */
+#undef __NO_VERSION__
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__WCTL_H__)
+#include "wctl.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#if !defined(__TCRC_H__)
+#include "tcrc.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__WROUTE_H__)
+#include "wroute.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__WPACTL_H__)
+#include "wpactl.h"
+#endif
+#if !defined(__IOCTL_H__)
+#include "ioctl.h"
+#endif
+#if !defined(__IWCTL_H__)
+#include "iwctl.h"
+#endif
+#if !defined(__DPC_H__)
+#include "dpc.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+
+#include <linux/delay.h>
+#include <linux/kthread.h>
+// #ifdef PRIVATE_OBJ
+//#if !defined(__DEVICE_EXP_H)
+//#include "device_exp.h"
+//#endif
+//#if !defined(__DEVICE_MODULE_H)
+//#include "device_module.h"
+//#endif
+
+
+// #endif
+//#define DEBUG
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel = MSG_LEVEL_INFO;
+
+//#define PLICE_DEBUG
+//
+// Define module options
+//
+#ifndef PRIVATE_OBJ
+MODULE_AUTHOR("VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver");
+#endif
+
+//PLICE_DEBUG ->
+ static int mlme_kill;
+ //static struct task_struct * mlme_task;
+//PLICE_DEBUG <-
+
+#define DEVICE_PARAM(N,D)
+/*
+ static const int N[MAX_UINTS]=OPTION_DEFAULT;\
+ MODULE_PARM(N, "1-" __MODULE_STRING(MAX_UINTS) "i");\
+ MODULE_PARM_DESC(N, D);
+*/
+
+#define RX_DESC_MIN0 16
+#define RX_DESC_MAX0 128
+#define RX_DESC_DEF0 32
+DEVICE_PARAM(RxDescriptors0,"Number of receive descriptors0");
+
+#define RX_DESC_MIN1 16
+#define RX_DESC_MAX1 128
+#define RX_DESC_DEF1 32
+DEVICE_PARAM(RxDescriptors1,"Number of receive descriptors1");
+
+#define TX_DESC_MIN0 16
+#define TX_DESC_MAX0 128
+#define TX_DESC_DEF0 32
+DEVICE_PARAM(TxDescriptors0,"Number of transmit descriptors0");
+
+#define TX_DESC_MIN1 16
+#define TX_DESC_MAX1 128
+#define TX_DESC_DEF1 64
+DEVICE_PARAM(TxDescriptors1,"Number of transmit descriptors1");
+
+
+#define IP_ALIG_DEF 0
+/* IP_byte_align[] is used for IP header DWORD byte aligned
+ 0: indicate the IP header won't be DWORD byte aligned.(Default) .
+ 1: indicate the IP header will be DWORD byte aligned.
+ In some enviroment, the IP header should be DWORD byte aligned,
+ or the packet will be droped when we receive it. (eg: IPVS)
+*/
+DEVICE_PARAM(IP_byte_align,"Enable IP header dword aligned");
+
+
+#define INT_WORKS_DEF 20
+#define INT_WORKS_MIN 10
+#define INT_WORKS_MAX 64
+
+DEVICE_PARAM(int_works,"Number of packets per interrupt services");
+
+#define CHANNEL_MIN 1
+#define CHANNEL_MAX 14
+#define CHANNEL_DEF 6
+
+DEVICE_PARAM(Channel, "Channel number");
+
+
+/* PreambleType[] is the preamble length used for transmit.
+ 0: indicate allows long preamble type
+ 1: indicate allows short preamble type
+*/
+
+#define PREAMBLE_TYPE_DEF 1
+
+DEVICE_PARAM(PreambleType, "Preamble Type");
+
+
+#define RTS_THRESH_MIN 512
+#define RTS_THRESH_MAX 2347
+#define RTS_THRESH_DEF 2347
+
+DEVICE_PARAM(RTSThreshold, "RTS threshold");
+
+
+#define FRAG_THRESH_MIN 256
+#define FRAG_THRESH_MAX 2346
+#define FRAG_THRESH_DEF 2346
+
+DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
+
+
+#define DATA_RATE_MIN 0
+#define DATA_RATE_MAX 13
+#define DATA_RATE_DEF 13
+/* datarate[] index
+ 0: indicate 1 Mbps 0x02
+ 1: indicate 2 Mbps 0x04
+ 2: indicate 5.5 Mbps 0x0B
+ 3: indicate 11 Mbps 0x16
+ 4: indicate 6 Mbps 0x0c
+ 5: indicate 9 Mbps 0x12
+ 6: indicate 12 Mbps 0x18
+ 7: indicate 18 Mbps 0x24
+ 8: indicate 24 Mbps 0x30
+ 9: indicate 36 Mbps 0x48
+ 10: indicate 48 Mbps 0x60
+ 11: indicate 54 Mbps 0x6c
+ 12: indicate 72 Mbps 0x90
+ 13: indicate auto rate
+*/
+
+DEVICE_PARAM(ConnectionRate, "Connection data rate");
+
+#define OP_MODE_DEF 0
+
+DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
+
+/* OpMode[] is used for transmit.
+ 0: indicate infrastruct mode used
+ 1: indicate adhoc mode used
+ 2: indicate AP mode used
+*/
+
+
+/* PSMode[]
+ 0: indicate disable power saving mode
+ 1: indicate enable power saving mode
+*/
+
+#define PS_MODE_DEF 0
+
+DEVICE_PARAM(PSMode, "Power saving mode");
+
+
+#define SHORT_RETRY_MIN 0
+#define SHORT_RETRY_MAX 31
+#define SHORT_RETRY_DEF 8
+
+
+DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
+
+#define LONG_RETRY_MIN 0
+#define LONG_RETRY_MAX 15
+#define LONG_RETRY_DEF 4
+
+
+DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
+
+
+/* BasebandType[] baseband type selected
+ 0: indicate 802.11a type
+ 1: indicate 802.11b type
+ 2: indicate 802.11g type
+*/
+#define BBP_TYPE_MIN 0
+#define BBP_TYPE_MAX 2
+#define BBP_TYPE_DEF 2
+
+DEVICE_PARAM(BasebandType, "baseband type");
+
+
+
+/* 80211hEnable[]
+ 0: indicate disable 802.11h
+ 1: indicate enable 802.11h
+*/
+
+#define X80211h_MODE_DEF 0
+
+DEVICE_PARAM(b80211hEnable, "802.11h mode");
+
+/* 80211hEnable[]
+ 0: indicate disable 802.11h
+ 1: indicate enable 802.11h
+*/
+
+#define DIVERSITY_ANT_DEF 0
+
+DEVICE_PARAM(bDiversityANTEnable, "ANT diversity mode");
+
+
+//
+// Static vars definitions
+//
+
+
+#ifndef PRIVATE_OBJ
+static int device_nics =0;
+static PSDevice pDevice_Infos =NULL;
+static struct net_device *root_device_dev = NULL;
+
+static CHIP_INFO chip_info_table[]= {
+ { VT3253, "VIA Networking Solomon-A/B/G Wireless LAN Adapter ",
+ 256, 1, DEVICE_FLAGS_IP_ALIGN|DEVICE_FLAGS_TX_ALIGN },
+ {0,NULL}
+};
+
+static struct pci_device_id device_id_table[] __devinitdata = {
+{ 0x1106, 0x3253, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (int)&chip_info_table[0]},
+{ 0, }
+};
+#endif
+
+/*--------------------- Static Functions --------------------------*/
+
+#ifndef PRIVATE_OBJ
+
+static int device_found1(struct pci_dev *pcid, const struct pci_device_id *ent);
+static BOOL device_init_info(struct pci_dev* pcid, PSDevice* ppDevice, PCHIP_INFO);
+static void device_free_info(PSDevice pDevice);
+static BOOL device_get_pci_info(PSDevice, struct pci_dev* pcid);
+static void device_print_info(PSDevice pDevice);
+static struct net_device_stats *device_get_stats(struct net_device *dev);
+static void device_init_diversity_timer(PSDevice pDevice);
+static int device_open(struct net_device *dev);
+static int device_xmit(struct sk_buff *skb, struct net_device *dev);
+static irqreturn_t device_intr(int irq, void*dev_instance);
+static void device_set_multi(struct net_device *dev);
+static int device_close(struct net_device *dev);
+static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
+#ifdef CONFIG_PM
+static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
+static int viawget_suspend(struct pci_dev *pcid, u32 state);
+static int viawget_resume(struct pci_dev *pcid);
+struct notifier_block device_notifier = {
+ notifier_call: device_notify_reboot,
+ next: NULL,
+ priority: 0
+};
+#endif
+#endif
+
+#endif // #ifndef PRIVATE_OBJ
+
+static void device_init_rd0_ring(PSDevice pDevice);
+static void device_init_rd1_ring(PSDevice pDevice);
+static void device_init_defrag_cb(PSDevice pDevice);
+static void device_init_td0_ring(PSDevice pDevice);
+static void device_init_td1_ring(PSDevice pDevice);
+
+#ifndef PRIVATE_OBJ
+static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
+#endif
+//2008-0714<Add>by Mike Liu
+static BOOL device_release_WPADEV(PSDevice pDevice);
+
+static int ethtool_ioctl(struct net_device *dev, void *useraddr);
+static int device_rx_srv(PSDevice pDevice, UINT uIdx);
+static int device_tx_srv(PSDevice pDevice, UINT uIdx);
+static BOOL device_alloc_rx_buf(PSDevice pDevice, PSRxDesc pDesc);
+static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType);
+static void device_free_tx_buf(PSDevice pDevice, PSTxDesc pDesc);
+static void device_free_td0_ring(PSDevice pDevice);
+static void device_free_td1_ring(PSDevice pDevice);
+static void device_free_rd0_ring(PSDevice pDevice);
+static void device_free_rd1_ring(PSDevice pDevice);
+static void device_free_rings(PSDevice pDevice);
+static void device_free_frag_buf(PSDevice pDevice);
+static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source);
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifndef PRIVATE_OBJ
+
+static char* get_chip_name(int chip_id) {
+ int i;
+ for (i=0;chip_info_table[i].name!=NULL;i++)
+ if (chip_info_table[i].chip_id==chip_id)
+ break;
+ return chip_info_table[i].name;
+}
+
+static void __devexit device_remove1(struct pci_dev *pcid)
+{
+ PSDevice pDevice=pci_get_drvdata(pcid);
+
+ if (pDevice==NULL)
+ return;
+ device_free_info(pDevice);
+
+}
+
+#endif
+/*
+static void
+device_set_int_opt(int *opt, int val, int min, int max, int def,char* name,char* devname) {
+ if (val==-1)
+ *opt=def;
+ else if (val<min || val>max) {
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n" ,
+ devname,name, min,max);
+ *opt=def;
+ } else {
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n",
+ devname, name, val);
+ *opt=val;
+ }
+}
+
+static void
+device_set_bool_opt(PU32 opt, int val,BOOL def,U32 flag, char* name,char* devname) {
+ (*opt)&=(~flag);
+ if (val==-1)
+ *opt|=(def ? flag : 0);
+ else if (val<0 || val>1) {
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_NOTICE
+ "%s: the value of parameter %s is invalid, the valid range is (0-1)\n",devname,name);
+ *opt|=(def ? flag : 0);
+ } else {
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: set parameter %s to %s\n",
+ devname,name , val ? "TRUE" : "FALSE");
+ *opt|=(val ? flag : 0);
+ }
+}
+*/
+static void
+device_get_options(PSDevice pDevice, int index, char* devname) {
+
+ POPTIONS pOpts = &(pDevice->sOpts);
+ pOpts->nRxDescs0=RX_DESC_DEF0;
+ pOpts->nRxDescs1=RX_DESC_DEF1;
+ pOpts->nTxDescs[0]=TX_DESC_DEF0;
+ pOpts->nTxDescs[1]=TX_DESC_DEF1;
+pOpts->flags|=DEVICE_FLAGS_IP_ALIGN;
+ pOpts->int_works=INT_WORKS_DEF;
+ pOpts->rts_thresh=RTS_THRESH_DEF;
+ pOpts->frag_thresh=FRAG_THRESH_DEF;
+ pOpts->data_rate=DATA_RATE_DEF;
+ pOpts->channel_num=CHANNEL_DEF;
+
+pOpts->flags|=DEVICE_FLAGS_PREAMBLE_TYPE;
+pOpts->flags|=DEVICE_FLAGS_OP_MODE;
+//pOpts->flags|=DEVICE_FLAGS_PS_MODE;
+ pOpts->short_retry=SHORT_RETRY_DEF;
+ pOpts->long_retry=LONG_RETRY_DEF;
+ pOpts->bbp_type=BBP_TYPE_DEF;
+pOpts->flags|=DEVICE_FLAGS_80211h_MODE;
+pOpts->flags|=DEVICE_FLAGS_DiversityANT;
+
+
+}
+
+static void
+device_set_options(PSDevice pDevice) {
+
+ BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+ BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+
+
+ memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN);
+ memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN);
+ memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN);
+
+ pDevice->uChannel = pDevice->sOpts.channel_num;
+ pDevice->wRTSThreshold = pDevice->sOpts.rts_thresh;
+ pDevice->wFragmentationThreshold = pDevice->sOpts.frag_thresh;
+ pDevice->byShortRetryLimit = pDevice->sOpts.short_retry;
+ pDevice->byLongRetryLimit = pDevice->sOpts.long_retry;
+ pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
+ pDevice->byShortPreamble = (pDevice->sOpts.flags & DEVICE_FLAGS_PREAMBLE_TYPE) ? 1 : 0;
+ pDevice->byOpMode = (pDevice->sOpts.flags & DEVICE_FLAGS_OP_MODE) ? 1 : 0;
+ pDevice->ePSMode = (pDevice->sOpts.flags & DEVICE_FLAGS_PS_MODE) ? 1 : 0;
+ pDevice->b11hEnable = (pDevice->sOpts.flags & DEVICE_FLAGS_80211h_MODE) ? 1 : 0;
+ pDevice->bDiversityRegCtlON = (pDevice->sOpts.flags & DEVICE_FLAGS_DiversityANT) ? 1 : 0;
+ pDevice->uConnectionRate = pDevice->sOpts.data_rate;
+ if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = TRUE;
+ pDevice->byBBType = pDevice->sOpts.bbp_type;
+ pDevice->byPacketType = pDevice->byBBType;
+
+//PLICE_DEBUG->
+ pDevice->byAutoFBCtrl = AUTO_FB_0;
+ //pDevice->byAutoFBCtrl = AUTO_FB_1;
+//PLICE_DEBUG<-
+pDevice->bUpdateBBVGA = TRUE;
+ pDevice->byFOETuning = 0;
+ pDevice->wCTSDuration = 0;
+ pDevice->byPreambleType = 0;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" uChannel= %d\n",(INT)pDevice->uChannel);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byOpMode= %d\n",(INT)pDevice->byOpMode);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" ePSMode= %d\n",(INT)pDevice->ePSMode);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" wRTSThreshold= %d\n",(INT)pDevice->wRTSThreshold);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byShortRetryLimit= %d\n",(INT)pDevice->byShortRetryLimit);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byLongRetryLimit= %d\n",(INT)pDevice->byLongRetryLimit);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byPreambleType= %d\n",(INT)pDevice->byPreambleType);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byShortPreamble= %d\n",(INT)pDevice->byShortPreamble);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" uConnectionRate= %d\n",(INT)pDevice->uConnectionRate);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byBBType= %d\n",(INT)pDevice->byBBType);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->b11hEnable= %d\n",(INT)pDevice->b11hEnable);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->bDiversityRegCtlON= %d\n",(INT)pDevice->bDiversityRegCtlON);
+}
+
+static VOID s_vCompleteCurrentMeasure (IN PSDevice pDevice, IN BYTE byResult)
+{
+ UINT ii;
+ DWORD dwDuration = 0;
+ BYTE byRPI0 = 0;
+
+ for(ii=1;ii<8;ii++) {
+ pDevice->dwRPIs[ii] *= 255;
+ dwDuration |= *((PWORD) (pDevice->pCurrMeasureEID->sReq.abyDuration));
+ dwDuration <<= 10;
+ pDevice->dwRPIs[ii] /= dwDuration;
+ pDevice->abyRPIs[ii] = (BYTE) pDevice->dwRPIs[ii];
+ byRPI0 += pDevice->abyRPIs[ii];
+ }
+ pDevice->abyRPIs[0] = (0xFF - byRPI0);
+
+ if (pDevice->uNumOfMeasureEIDs == 0) {
+ VNTWIFIbMeasureReport( pDevice->pMgmt,
+ TRUE,
+ pDevice->pCurrMeasureEID,
+ byResult,
+ pDevice->byBasicMap,
+ pDevice->byCCAFraction,
+ pDevice->abyRPIs
+ );
+ } else {
+ VNTWIFIbMeasureReport( pDevice->pMgmt,
+ FALSE,
+ pDevice->pCurrMeasureEID,
+ byResult,
+ pDevice->byBasicMap,
+ pDevice->byCCAFraction,
+ pDevice->abyRPIs
+ );
+ CARDbStartMeasure (pDevice, pDevice->pCurrMeasureEID++, pDevice->uNumOfMeasureEIDs);
+ }
+
+}
+
+
+
+//
+// Initialiation of MAC & BBP registers
+//
+
+static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType)
+{
+ UINT ii;
+ BYTE byValue;
+ BYTE byValue1;
+ BYTE byCCKPwrdBm = 0;
+ BYTE byOFDMPwrdBm = 0;
+ INT zonetype=0;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ MACbShutdown(pDevice->PortOffset);
+ BBvSoftwareReset(pDevice->PortOffset);
+
+ if ((InitType == DEVICE_INIT_COLD) ||
+ (InitType == DEVICE_INIT_DXPL)) {
+ // Do MACbSoftwareReset in MACvInitialize
+ MACbSoftwareReset(pDevice->PortOffset);
+ // force CCK
+ pDevice->bCCK = TRUE;
+ pDevice->bAES = FALSE;
+ pDevice->bProtectMode = FALSE; //Only used in 11g type, sync with ERP IE
+ pDevice->bNonERPPresent = FALSE;
+ pDevice->bBarkerPreambleMd = FALSE;
+ pDevice->wCurrentRate = RATE_1M;
+ pDevice->byTopOFDMBasicRate = RATE_24M;
+ pDevice->byTopCCKBasicRate = RATE_1M;
+
+ pDevice->byRevId = 0; //Target to IF pin while programming to RF chip.
+
+ // init MAC
+ MACvInitialize(pDevice->PortOffset);
+
+ // Get Local ID
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_LOCALID, &(pDevice->byLocalID));
+
+ spin_lock_irq(&pDevice->lock);
+ SROMvReadAllContents(pDevice->PortOffset,pDevice->abyEEPROM);
+
+ spin_unlock_irq(&pDevice->lock);
+
+ // Get Channel range
+
+ pDevice->byMinChannel = 1;
+ pDevice->byMaxChannel = CB_MAX_CHANNEL;
+
+ // Get Antena
+ byValue = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ANTENNA);
+ if (byValue & EEP_ANTINV)
+ pDevice->bTxRxAntInv = TRUE;
+ else
+ pDevice->bTxRxAntInv = FALSE;
+#ifdef PLICE_DEBUG
+ //printk("init_register:TxRxAntInv is %d,byValue is %d\n",pDevice->bTxRxAntInv,byValue);
+#endif
+
+ byValue &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
+ if (byValue == 0) // if not set default is All
+ byValue = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
+#ifdef PLICE_DEBUG
+ //printk("init_register:byValue is %d\n",byValue);
+#endif
+ pDevice->ulDiversityNValue = 100*260;//100*SROMbyReadEmbedded(pDevice->PortOffset, 0x51);
+ pDevice->ulDiversityMValue = 100*16;//SROMbyReadEmbedded(pDevice->PortOffset, 0x52);
+ pDevice->byTMax = 1;//SROMbyReadEmbedded(pDevice->PortOffset, 0x53);
+ pDevice->byTMax2 = 4;//SROMbyReadEmbedded(pDevice->PortOffset, 0x54);
+ pDevice->ulSQ3TH = 0;//(ULONG) SROMbyReadEmbedded(pDevice->PortOffset, 0x55);
+ pDevice->byTMax3 = 64;//SROMbyReadEmbedded(pDevice->PortOffset, 0x56);
+
+ if (byValue == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
+ pDevice->byAntennaCount = 2;
+ pDevice->byTxAntennaMode = ANT_B;
+ pDevice->dwTxAntennaSel = 1;
+ pDevice->dwRxAntennaSel = 1;
+ if (pDevice->bTxRxAntInv == TRUE)
+ pDevice->byRxAntennaMode = ANT_A;
+ else
+ pDevice->byRxAntennaMode = ANT_B;
+ // chester for antenna
+byValue1 = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ANTENNA);
+ // if (pDevice->bDiversityRegCtlON)
+ if((byValue1&0x08)==0)
+ pDevice->bDiversityEnable = FALSE;//SROMbyReadEmbedded(pDevice->PortOffset, 0x50);
+ else
+ pDevice->bDiversityEnable = TRUE;
+#ifdef PLICE_DEBUG
+ //printk("aux |main antenna: RxAntennaMode is %d\n",pDevice->byRxAntennaMode);
+#endif
+ } else {
+ pDevice->bDiversityEnable = FALSE;
+ pDevice->byAntennaCount = 1;
+ pDevice->dwTxAntennaSel = 0;
+ pDevice->dwRxAntennaSel = 0;
+ if (byValue & EEP_ANTENNA_AUX) {
+ pDevice->byTxAntennaMode = ANT_A;
+ if (pDevice->bTxRxAntInv == TRUE)
+ pDevice->byRxAntennaMode = ANT_B;
+ else
+ pDevice->byRxAntennaMode = ANT_A;
+ } else {
+ pDevice->byTxAntennaMode = ANT_B;
+ if (pDevice->bTxRxAntInv == TRUE)
+ pDevice->byRxAntennaMode = ANT_A;
+ else
+ pDevice->byRxAntennaMode = ANT_B;
+ }
+ }
+#ifdef PLICE_DEBUG
+ //printk("init registers: TxAntennaMode is %d\n",pDevice->byTxAntennaMode);
+#endif
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bDiversityEnable=[%d],NValue=[%d],MValue=[%d],TMax=[%d],TMax2=[%d]\n",
+ pDevice->bDiversityEnable,(int)pDevice->ulDiversityNValue,(int)pDevice->ulDiversityMValue,pDevice->byTMax,pDevice->byTMax2);
+
+//#ifdef ZoneType_DefaultSetting
+//2008-8-4 <add> by chester
+//zonetype initial
+ pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
+ if((zonetype=Config_FileOperation(pDevice,FALSE,NULL)) >= 0) { //read zonetype file ok!
+ if ((zonetype == 0)&&
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA
+ pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
+ pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n");
+ }
+ else if((zonetype == 1)&&
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){ //for Japan
+ pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
+ pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
+ }
+ else if((zonetype == 2)&&
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){ //for Europe
+ pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
+ pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n");
+ }
+
+else
+{
+ if(zonetype!=pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
+ printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",zonetype,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
+ else
+ printk("Read Zonetype file sucess,use default zonetype setting[%02x]\n",zonetype);
+ }
+ }
+ else
+ printk("Read Zonetype file fail,use default zonetype setting[%02x]\n",SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ZONETYPE));
+
+ // Get RFType
+ pDevice->byRFType = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RFTYPE);
+
+ if ((pDevice->byRFType & RF_EMU) != 0) {
+ // force change RevID for VT3253 emu
+ pDevice->byRevId = 0x80;
+ }
+
+ pDevice->byRFType &= RF_MASK;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRFType = %x\n", pDevice->byRFType);
+
+ if (pDevice->bZoneRegExist == FALSE) {
+ pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byZoneType = %x\n", pDevice->byZoneType);
+
+ //Init RF module
+ RFbInit(pDevice);
+
+ //Get Desire Power Value
+ pDevice->byCurPwr = 0xFF;
+ pDevice->byCCKPwr = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_CCK);
+ pDevice->byOFDMPwrG = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_OFDMG);
+ //byCCKPwrdBm = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_CCK_PWR_dBm);
+
+ //byOFDMPwrdBm = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_OFDM_PWR_dBm);
+//printk("CCKPwrdBm is 0x%x,byOFDMPwrdBm is 0x%x\n",byCCKPwrdBm,byOFDMPwrdBm);
+ // Load power Table
+
+
+ for (ii=0;ii<CB_MAX_CHANNEL_24G;ii++) {
+ pDevice->abyCCKPwrTbl[ii+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_CCK_PWR_TBL));
+ if (pDevice->abyCCKPwrTbl[ii+1] == 0) {
+ pDevice->abyCCKPwrTbl[ii+1] = pDevice->byCCKPwr;
+ }
+ pDevice->abyOFDMPwrTbl[ii+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDM_PWR_TBL));
+ if (pDevice->abyOFDMPwrTbl[ii+1] == 0) {
+ pDevice->abyOFDMPwrTbl[ii+1] = pDevice->byOFDMPwrG;
+ }
+ pDevice->abyCCKDefaultPwr[ii+1] = byCCKPwrdBm;
+ pDevice->abyOFDMDefaultPwr[ii+1] = byOFDMPwrdBm;
+ }
+ //2008-8-4 <add> by chester
+ //recover 12,13 ,14channel for EUROPE by 11 channel
+ if(((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) ||
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe))&&
+ (pDevice->byOriginalZonetype == ZoneType_USA)) {
+ for(ii=11;ii<14;ii++) {
+ pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
+ pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
+
+ }
+ }
+
+
+ // Load OFDM A Power Table
+ for (ii=0;ii<CB_MAX_CHANNEL_5G;ii++) { //RobertYu:20041224, bug using CB_MAX_CHANNEL
+ pDevice->abyOFDMPwrTbl[ii+CB_MAX_CHANNEL_24G+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDMA_PWR_TBL));
+ pDevice->abyOFDMDefaultPwr[ii+CB_MAX_CHANNEL_24G+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDMA_PWR_dBm));
+ }
+ CARDvInitChannelTable((PVOID)pDevice);
+
+
+ if (pDevice->byLocalID > REV_ID_VT3253_B1) {
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_MSRCTL + 1, (MSRCTL1_TXPWR | MSRCTL1_CSAPAREN));
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+
+
+ // use relative tx timeout and 802.11i D4
+ MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_CFG, (CFG_TKIPOPT | CFG_NOTXTIMEOUT));
+
+ // set performance parameter by registry
+ MACvSetShortRetryLimit(pDevice->PortOffset, pDevice->byShortRetryLimit);
+ MACvSetLongRetryLimit(pDevice->PortOffset, pDevice->byLongRetryLimit);
+
+ // reset TSF counter
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
+ // enable TSF counter
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
+
+ // initialize BBP registers
+ BBbVT3253Init(pDevice);
+
+ if (pDevice->bUpdateBBVGA) {
+ pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
+ pDevice->byBBVGANew = pDevice->byBBVGACurrent;
+ BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
+ }
+#ifdef PLICE_DEBUG
+ //printk("init registers:RxAntennaMode is %x,TxAntennaMode is %x\n",pDevice->byRxAntennaMode,pDevice->byTxAntennaMode);
+#endif
+ BBvSetRxAntennaMode(pDevice->PortOffset, pDevice->byRxAntennaMode);
+ BBvSetTxAntennaMode(pDevice->PortOffset, pDevice->byTxAntennaMode);
+
+ pDevice->byCurrentCh = 0;
+
+ //pDevice->NetworkType = Ndis802_11Automode;
+ // Set BB and packet type at the same time.
+ // Set Short Slot Time, xIFS, and RSPINF.
+ if (pDevice->uConnectionRate == RATE_AUTO) {
+ pDevice->wCurrentRate = RATE_54M;
+ } else {
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+
+ // default G Mode
+ VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_11G);
+ VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_AUTO);
+
+ pDevice->bRadioOff = FALSE;
+
+ pDevice->byRadioCtl = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RADIOCTL);
+ pDevice->bHWRadioOff = FALSE;
+
+ if (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) {
+ // Get GPIO
+ MACvGPIOIn(pDevice->PortOffset, &pDevice->byGPIO);
+//2008-4-14 <add> by chester for led issue
+ #ifdef FOR_LED_ON_NOTEBOOK
+if (BITbIsBitOn(pDevice->byGPIO,GPIO0_DATA)){pDevice->bHWRadioOff = TRUE;}
+if (BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA)){pDevice->bHWRadioOff = FALSE;}
+
+ }
+ if ( (pDevice->bRadioControlOff == TRUE)) {
+ CARDbRadioPowerOff(pDevice);
+ }
+else CARDbRadioPowerOn(pDevice);
+#else
+ if ((BITbIsBitOn(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOff(pDevice->byRadioCtl, EEP_RADIOCTL_INV)) ||
+ (BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV))) {
+ pDevice->bHWRadioOff = TRUE;
+ }
+ }
+ if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
+ CARDbRadioPowerOff(pDevice);
+ }
+
+#endif
+ }
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ // get Permanent network address
+ SROMvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %02x-%02x-%02x=%02x-%02x-%02x\n",
+ pDevice->abyCurrentNetAddr[0],
+ pDevice->abyCurrentNetAddr[1],
+ pDevice->abyCurrentNetAddr[2],
+ pDevice->abyCurrentNetAddr[3],
+ pDevice->abyCurrentNetAddr[4],
+ pDevice->abyCurrentNetAddr[5]);
+
+
+ // reset Tx pointer
+ CARDvSafeResetRx(pDevice);
+ // reset Rx pointer
+ CARDvSafeResetTx(pDevice);
+
+ if (pDevice->byLocalID <= REV_ID_VT3253_A1) {
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_WPAERR);
+ }
+
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+
+ // Turn On Rx DMA
+ MACvReceive0(pDevice->PortOffset);
+ MACvReceive1(pDevice->PortOffset);
+
+ // start the adapter
+ MACvStart(pDevice->PortOffset);
+
+ netif_stop_queue(pDevice->dev);
+
+
+}
+
+
+
+static VOID device_init_diversity_timer(PSDevice pDevice) {
+
+ init_timer(&pDevice->TimerSQ3Tmax1);
+ pDevice->TimerSQ3Tmax1.data = (ULONG)pDevice;
+ pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
+ pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
+
+ init_timer(&pDevice->TimerSQ3Tmax2);
+ pDevice->TimerSQ3Tmax2.data = (ULONG)pDevice;
+ pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
+ pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
+
+ init_timer(&pDevice->TimerSQ3Tmax3);
+ pDevice->TimerSQ3Tmax3.data = (ULONG)pDevice;
+ pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerState1CallBack;
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
+
+ return;
+}
+
+
+static BOOL device_release_WPADEV(PSDevice pDevice)
+{
+ viawget_wpa_header *wpahdr;
+ int ii=0;
+ // wait_queue_head_t Set_wait;
+ //send device close to wpa_supplicnat layer
+ if (pDevice->bWPADEVUp==TRUE) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ wpahdr->type = VIAWGET_DEVICECLOSE_MSG;
+ wpahdr->resp_ie_len = 0;
+ wpahdr->req_ie_len = 0;
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header));
+ pDevice->skb->dev = pDevice->wpadev;
+//2008-4-3 modify by Chester for wpa
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ pDevice->skb->mac_header = pDevice->skb->data;
+#else
+ pDevice->skb->mac.raw = pDevice->skb->data;
+#endif
+ pDevice->skb->pkt_type = PACKET_HOST;
+ pDevice->skb->protocol = htons(ETH_P_802_2);
+ memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
+ netif_rx(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+
+ //wait release WPADEV
+ // init_waitqueue_head(&Set_wait);
+ // wait_event_timeout(Set_wait, ((pDevice->wpadev==NULL)&&(pDevice->skb == NULL)),5*HZ); //1s wait
+ while((pDevice->bWPADEVUp==TRUE)) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout (HZ/20); //wait 50ms
+ ii++;
+ if(ii>20)
+ break;
+ }
+ };
+ return TRUE;
+}
+
+
+#ifndef PRIVATE_OBJ
+
+static int
+device_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
+{
+ static BOOL bFirst = TRUE;
+ struct net_device* dev = NULL;
+ PCHIP_INFO pChip_info = (PCHIP_INFO)ent->driver_data;
+ PSDevice pDevice;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ int rc;
+#endif
+//#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ // BYTE fake_mac[U_ETHER_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};//fake MAC address
+//#endif
+ if (device_nics ++>= MAX_UINTS) {
+ printk(KERN_NOTICE DEVICE_NAME ": already found %d NICs\n", device_nics);
+ return -ENODEV;
+ }
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ dev = alloc_etherdev(0);
+#else
+ dev = init_etherdev(dev, 0);
+#endif
+
+ if (dev == NULL) {
+ printk(KERN_ERR DEVICE_NAME ": allocate net device failed \n");
+ return -ENODEV;
+ }
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ // Chain it all together
+ // SET_MODULE_OWNER(dev);
+ SET_NETDEV_DEV(dev, &pcid->dev);
+#endif
+
+ if (bFirst) {
+ printk(KERN_NOTICE "%s Ver. %s\n",DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
+ printk(KERN_NOTICE "Copyright (c) 2003 VIA Networking Technologies, Inc.\n");
+ bFirst=FALSE;
+ }
+
+ if (!device_init_info(pcid, &pDevice, pChip_info)) {
+ return -ENOMEM;
+ }
+ pDevice->dev = dev;
+ pDevice->next_module = root_device_dev;
+ root_device_dev = dev;
+ dev->priv = pDevice;
+ dev->irq = pcid->irq;
+
+ if (pci_enable_device(pcid)) {
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+#ifdef DEBUG
+ printk("Before get pci_info memaddr is %x\n",pDevice->memaddr);
+#endif
+ if (device_get_pci_info(pDevice,pcid) == FALSE) {
+ printk(KERN_ERR DEVICE_NAME ": Failed to find PCI device.\n");
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+
+#if 1
+
+#ifdef DEBUG
+
+ //pci_read_config_byte(pcid, PCI_BASE_ADDRESS_0, &pDevice->byRevId);
+ printk("after get pci_info memaddr is %x, io addr is %x,io_size is %d\n",pDevice->memaddr,pDevice->ioaddr,pDevice->io_size);
+ {
+ int i;
+ U32 bar,len;
+ u32 address[] = {
+ PCI_BASE_ADDRESS_0,
+ PCI_BASE_ADDRESS_1,
+ PCI_BASE_ADDRESS_2,
+ PCI_BASE_ADDRESS_3,
+ PCI_BASE_ADDRESS_4,
+ PCI_BASE_ADDRESS_5,
+ 0};
+ for (i=0;address[i];i++)
+ {
+ //pci_write_config_dword(pcid,address[i], 0xFFFFFFFF);
+ pci_read_config_dword(pcid, address[i], &bar);
+ printk("bar %d is %x\n",i,bar);
+ if (!bar)
+ {
+ printk("bar %d not implemented\n",i);
+ continue;
+ }
+ if (bar & PCI_BASE_ADDRESS_SPACE_IO) {
+ /* This is IO */
+
+ len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF);
+ len = len & ~(len - 1);
+
+ printk("IO space: len in IO %x, BAR %d\n", len, i);
+ }
+ else
+ {
+ len = bar & 0xFFFFFFF0;
+ len = ~len + 1;
+
+ printk("len in MEM %x, BAR %d\n", len, i);
+ }
+ }
+ }
+#endif
+
+
+#endif
+
+#ifdef DEBUG
+ //return 0 ;
+#endif
+ pDevice->PortOffset = (DWORD)ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size);
+ //pDevice->PortOffset = (DWORD)ioremap(pDevice->ioaddr & PCI_BASE_ADDRESS_IO_MASK, pDevice->io_size);
+
+ if(pDevice->PortOffset == 0) {
+ printk(KERN_ERR DEVICE_NAME ": Failed to IO remapping ..\n");
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+
+
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ rc = pci_request_regions(pcid, DEVICE_NAME);
+ if (rc) {
+ printk(KERN_ERR DEVICE_NAME ": Failed to find PCI device\n");
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+#else
+ if (check_region(pDevice->ioaddr, pDevice->io_size)) {
+ printk(KERN_ERR DEVICE_NAME ": Failed to find PCI device\n");
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+ request_region(pDevice->ioaddr, pDevice->io_size, DEVICE_NAME);
+#endif
+
+ dev->base_addr = pDevice->ioaddr;
+#ifdef PLICE_DEBUG
+ BYTE value;
+
+ VNSvInPortB(pDevice->PortOffset+0x4F, &value);
+ printk("Before write: value is %x\n",value);
+ //VNSvInPortB(pDevice->PortOffset+0x3F, 0x00);
+ VNSvOutPortB(pDevice->PortOffset,value);
+ VNSvInPortB(pDevice->PortOffset+0x4F, &value);
+ printk("After write: value is %x\n",value);
+#endif
+
+
+
+#ifdef IO_MAP
+ pDevice->PortOffset = pDevice->ioaddr;
+#endif
+ // do reset
+ if (!MACbSoftwareReset(pDevice->PortOffset)) {
+ printk(KERN_ERR DEVICE_NAME ": Failed to access MAC hardware..\n");
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+ // initial to reload eeprom
+ MACvInitialize(pDevice->PortOffset);
+ MACvReadEtherAddress(pDevice->PortOffset, dev->dev_addr);
+
+ device_get_options(pDevice, device_nics-1, dev->name);
+ device_set_options(pDevice);
+ //Mask out the options cannot be set to the chip
+ pDevice->sOpts.flags &= pChip_info->flags;
+
+ //Enable the chip specified capbilities
+ pDevice->flags = pDevice->sOpts.flags | (pChip_info->flags & 0xFF000000UL);
+ pDevice->tx_80211 = device_dma0_tx_80211;
+ pDevice->sMgmtObj.pAdapter = (PVOID)pDevice;
+ pDevice->pMgmt = &(pDevice->sMgmtObj);
+
+ dev->irq = pcid->irq;
+ dev->open = device_open;
+ dev->hard_start_xmit = device_xmit;
+ dev->stop = device_close;
+ dev->get_stats = device_get_stats;
+ dev->set_multicast_list = device_set_multi;
+ dev->do_ioctl = device_ioctl;
+
+#ifdef WIRELESS_EXT
+//Einsn Modify for ubuntu-7.04
+// dev->wireless_handlers->get_wireless_stats = iwctl_get_wireless_stats;
+#if WIRELESS_EXT > 12
+ dev->wireless_handlers = (struct iw_handler_def *)&iwctl_handler_def;
+// netdev->wireless_handlers = NULL;
+#endif /* WIRELESS_EXT > 12 */
+#endif /* WIRELESS_EXT */
+
+ // #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ // memcpy(pDevice->dev->dev_addr, fake_mac, U_ETHER_ADDR_LEN); //use fake mac address
+ // #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ rc = register_netdev(dev);
+ if (rc)
+ {
+ printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
+ device_free_info(pDevice);
+ return -ENODEV;
+ }
+#endif
+//2008-07-21-01<Add>by MikeLiu
+//register wpadev
+ if(wpa_set_wpadev(pDevice, 1)!=0) {
+ printk("Fail to Register WPADEV?\n");
+ unregister_netdev(pDevice->dev);
+ free_netdev(dev);
+ kfree(pDevice);
+ }
+ device_print_info(pDevice);
+ pci_set_drvdata(pcid, pDevice);
+ return 0;
+
+}
+
+static void device_print_info(PSDevice pDevice)
+{
+ struct net_device* dev=pDevice->dev;
+
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: %s\n",dev->name, get_chip_name(pDevice->chip_id));
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
+ dev->name,
+ dev->dev_addr[0],dev->dev_addr[1],dev->dev_addr[2],
+ dev->dev_addr[3],dev->dev_addr[4],dev->dev_addr[5]);
+#ifdef IO_MAP
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO" IO=0x%lx ",(ULONG) pDevice->ioaddr);
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO" IRQ=%d \n", pDevice->dev->irq);
+#else
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO" IO=0x%lx Mem=0x%lx ",(ULONG) pDevice->ioaddr,(ULONG) pDevice->PortOffset);
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO" IRQ=%d \n", pDevice->dev->irq);
+#endif
+
+}
+
+static BOOL device_init_info(struct pci_dev* pcid, PSDevice* ppDevice,
+ PCHIP_INFO pChip_info) {
+
+ PSDevice p;
+
+ *ppDevice = kmalloc(sizeof(DEVICE_INFO),GFP_ATOMIC);
+
+ if (*ppDevice == NULL)
+ return FALSE;
+
+ memset(*ppDevice,0,sizeof(DEVICE_INFO));
+
+ if (pDevice_Infos == NULL) {
+ pDevice_Infos =*ppDevice;
+ }
+ else {
+ for (p=pDevice_Infos;p->next!=NULL;p=p->next)
+ do {} while (0);
+ p->next = *ppDevice;
+ (*ppDevice)->prev = p;
+ }
+
+ (*ppDevice)->pcid = pcid;
+ (*ppDevice)->chip_id = pChip_info->chip_id;
+ (*ppDevice)->io_size = pChip_info->io_size;
+ (*ppDevice)->nTxQueues = pChip_info->nTxQueue;
+ (*ppDevice)->multicast_limit =32;
+
+ spin_lock_init(&((*ppDevice)->lock));
+
+ return TRUE;
+}
+
+static BOOL device_get_pci_info(PSDevice pDevice, struct pci_dev* pcid) {
+
+ U16 pci_cmd;
+ U8 b;
+ UINT cis_addr;
+#ifdef PLICE_DEBUG
+ BYTE pci_config[256];
+ BYTE value =0x00;
+ int ii,j;
+ U16 max_lat=0x0000;
+ memset(pci_config,0x00,256);
+#endif
+
+ pci_read_config_byte(pcid, PCI_REVISION_ID, &pDevice->byRevId);
+ pci_read_config_word(pcid, PCI_SUBSYSTEM_ID,&pDevice->SubSystemID);
+ pci_read_config_word(pcid, PCI_SUBSYSTEM_VENDOR_ID, &pDevice->SubVendorID);
+ pci_read_config_word(pcid, PCI_COMMAND, (u16 *) & (pci_cmd));
+
+ pci_set_master(pcid);
+
+ pDevice->memaddr = pci_resource_start(pcid,0);
+ pDevice->ioaddr = pci_resource_start(pcid,1);
+
+#ifdef DEBUG
+// pDevice->ioaddr = pci_resource_start(pcid, 0);
+// pDevice->memaddr = pci_resource_start(pcid,1);
+#endif
+
+ cis_addr = pci_resource_start(pcid,2);
+
+ pDevice->pcid = pcid;
+
+ pci_read_config_byte(pcid, PCI_REG_COMMAND, &b);
+ pci_write_config_byte(pcid, PCI_REG_COMMAND, (b|COMMAND_BUSM));
+
+#ifdef PLICE_DEBUG
+ //pci_read_config_word(pcid,PCI_REG_MAX_LAT,&max_lat);
+ //printk("max lat is %x,SubSystemID is %x\n",max_lat,pDevice->SubSystemID);
+ //for (ii=0;ii<0xFF;ii++)
+ //pci_read_config_word(pcid,PCI_REG_MAX_LAT,&max_lat);
+ //max_lat = 0x20;
+ //pci_write_config_word(pcid,PCI_REG_MAX_LAT,max_lat);
+ //pci_read_config_word(pcid,PCI_REG_MAX_LAT,&max_lat);
+ //printk("max lat is %x\n",max_lat);
+
+ for (ii=0;ii<0xFF;ii++)
+ {
+ pci_read_config_byte(pcid,ii,&value);
+ pci_config[ii] = value;
+ }
+ for (ii=0,j=1;ii<0x100;ii++,j++)
+ {
+ if (j %16 == 0)
+ {
+ printk("%x:",pci_config[ii]);
+ printk("\n");
+ }
+ else
+ {
+ printk("%x:",pci_config[ii]);
+ }
+ }
+#endif
+ return TRUE;
+}
+
+static void device_free_info(PSDevice pDevice) {
+ PSDevice ptr;
+ struct net_device* dev=pDevice->dev;
+
+ ASSERT(pDevice);
+//2008-0714-01<Add>by chester
+device_release_WPADEV(pDevice);
+
+//2008-07-21-01<Add>by MikeLiu
+//unregister wpadev
+ if(wpa_set_wpadev(pDevice, 0)!=0)
+ printk("unregister wpadev fail?\n");
+
+ if (pDevice_Infos==NULL)
+ return;
+
+ for (ptr=pDevice_Infos;ptr && (ptr!=pDevice);ptr=ptr->next)
+ do {} while (0);
+
+ if (ptr==pDevice) {
+ if (ptr==pDevice_Infos)
+ pDevice_Infos=ptr->next;
+ else
+ ptr->prev->next=ptr->next;
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_ERR, KERN_ERR "info struct not found\n");
+ return;
+ }
+#ifdef HOSTAP
+ if (dev)
+ hostap_set_hostapd(pDevice, 0, 0);
+#endif
+ if (dev)
+ unregister_netdev(dev);
+
+ if (pDevice->PortOffset)
+ iounmap((PVOID)pDevice->PortOffset);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ if (pDevice->pcid)
+ pci_release_regions(pDevice->pcid);
+ if (dev)
+ free_netdev(dev);
+#else
+ if (pDevice->ioaddr)
+ release_region(pDevice->ioaddr,pDevice->io_size);
+ if (dev)
+ kfree(dev);
+#endif
+
+ if (pDevice->pcid) {
+ pci_set_drvdata(pDevice->pcid,NULL);
+ }
+ kfree(pDevice);
+
+}
+#endif// ifndef PRIVATE_OBJ
+
+static BOOL device_init_rings(PSDevice pDevice) {
+ void* vir_pool;
+
+
+ /*allocate all RD/TD rings a single pool*/
+ vir_pool = pci_alloc_consistent(pDevice->pcid,
+ pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
+ pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
+ pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
+ pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc),
+ &pDevice->pool_dma);
+
+ if (vir_pool == NULL) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate desc dma memory failed\n", pDevice->dev->name);
+ return FALSE;
+ }
+
+ memset(vir_pool, 0,
+ pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
+ pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
+ pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
+ pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc)
+ );
+
+ pDevice->aRD0Ring = vir_pool;
+ pDevice->aRD1Ring = vir_pool +
+ pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc);
+
+
+ pDevice->rd0_pool_dma = pDevice->pool_dma;
+ pDevice->rd1_pool_dma = pDevice->rd0_pool_dma +
+ pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc);
+
+ pDevice->tx0_bufs = pci_alloc_consistent(pDevice->pcid,
+ pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
+ pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
+ CB_BEACON_BUF_SIZE +
+ CB_MAX_BUF_SIZE,
+ &pDevice->tx_bufs_dma0);
+
+ if (pDevice->tx0_bufs == NULL) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: allocate buf dma memory failed\n", pDevice->dev->name);
+ pci_free_consistent(pDevice->pcid,
+ pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
+ pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
+ pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
+ pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc),
+ vir_pool, pDevice->pool_dma
+ );
+ return FALSE;
+ }
+
+ memset(pDevice->tx0_bufs, 0,
+ pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
+ pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
+ CB_BEACON_BUF_SIZE +
+ CB_MAX_BUF_SIZE
+ );
+
+ pDevice->td0_pool_dma = pDevice->rd1_pool_dma +
+ pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc);
+
+ pDevice->td1_pool_dma = pDevice->td0_pool_dma +
+ pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc);
+
+
+ // vir_pool: pvoid type
+ pDevice->apTD0Rings = vir_pool
+ + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc)
+ + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc);
+
+ pDevice->apTD1Rings = vir_pool
+ + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc)
+ + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc)
+ + pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc);
+
+
+ pDevice->tx1_bufs = pDevice->tx0_bufs +
+ pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ;
+
+
+ pDevice->tx_beacon_bufs = pDevice->tx1_bufs +
+ pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ;
+
+ pDevice->pbyTmpBuff = pDevice->tx_beacon_bufs +
+ CB_BEACON_BUF_SIZE;
+
+ pDevice->tx_bufs_dma1 = pDevice->tx_bufs_dma0 +
+ pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ;
+
+
+ pDevice->tx_beacon_dma = pDevice->tx_bufs_dma1 +
+ pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ;
+
+
+ return TRUE;
+}
+
+static void device_free_rings(PSDevice pDevice) {
+
+ pci_free_consistent(pDevice->pcid,
+ pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
+ pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
+ pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
+ pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc)
+ ,
+ pDevice->aRD0Ring, pDevice->pool_dma
+ );
+
+ if (pDevice->tx0_bufs)
+ pci_free_consistent(pDevice->pcid,
+ pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
+ pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
+ CB_BEACON_BUF_SIZE +
+ CB_MAX_BUF_SIZE,
+ pDevice->tx0_bufs, pDevice->tx_bufs_dma0
+ );
+}
+
+static void device_init_rd0_ring(PSDevice pDevice) {
+ int i;
+ dma_addr_t curr = pDevice->rd0_pool_dma;
+ PSRxDesc pDesc;
+
+ /* Init the RD0 ring entries */
+ for (i = 0; i < pDevice->sOpts.nRxDescs0; i ++, curr += sizeof(SRxDesc)) {
+ pDesc = &(pDevice->aRD0Ring[i]);
+ pDesc->pRDInfo = alloc_rd_info();
+ ASSERT(pDesc->pRDInfo);
+ if (!device_alloc_rx_buf(pDevice, pDesc)) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc rx bufs\n",
+ pDevice->dev->name);
+ }
+ pDesc->next = &(pDevice->aRD0Ring[(i+1) % pDevice->sOpts.nRxDescs0]);
+ pDesc->pRDInfo->curr_desc = cpu_to_le32(curr);
+ pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc));
+ }
+
+ pDevice->aRD0Ring[i-1].next_desc = cpu_to_le32(pDevice->rd0_pool_dma);
+ pDevice->pCurrRD[0] = &(pDevice->aRD0Ring[0]);
+}
+
+
+static void device_init_rd1_ring(PSDevice pDevice) {
+ int i;
+ dma_addr_t curr = pDevice->rd1_pool_dma;
+ PSRxDesc pDesc;
+
+ /* Init the RD1 ring entries */
+ for (i = 0; i < pDevice->sOpts.nRxDescs1; i ++, curr += sizeof(SRxDesc)) {
+ pDesc = &(pDevice->aRD1Ring[i]);
+ pDesc->pRDInfo = alloc_rd_info();
+ ASSERT(pDesc->pRDInfo);
+ if (!device_alloc_rx_buf(pDevice, pDesc)) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc rx bufs\n",
+ pDevice->dev->name);
+ }
+ pDesc->next = &(pDevice->aRD1Ring[(i+1) % pDevice->sOpts.nRxDescs1]);
+ pDesc->pRDInfo->curr_desc = cpu_to_le32(curr);
+ pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc));
+ }
+
+ pDevice->aRD1Ring[i-1].next_desc = cpu_to_le32(pDevice->rd1_pool_dma);
+ pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]);
+}
+
+
+static void device_init_defrag_cb(PSDevice pDevice) {
+ int i;
+ PSDeFragControlBlock pDeF;
+
+ /* Init the fragment ctl entries */
+ for (i = 0; i < CB_MAX_RX_FRAG; i++) {
+ pDeF = &(pDevice->sRxDFCB[i]);
+ if (!device_alloc_frag_buf(pDevice, pDeF)) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
+ pDevice->dev->name);
+ };
+ }
+ pDevice->cbDFCB = CB_MAX_RX_FRAG;
+ pDevice->cbFreeDFCB = pDevice->cbDFCB;
+}
+
+
+
+
+static void device_free_rd0_ring(PSDevice pDevice) {
+ int i;
+
+ for (i = 0; i < pDevice->sOpts.nRxDescs0; i++) {
+ PSRxDesc pDesc =&(pDevice->aRD0Ring[i]);
+ PDEVICE_RD_INFO pRDInfo =pDesc->pRDInfo;
+
+ pci_unmap_single(pDevice->pcid,pRDInfo->skb_dma,
+ pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+
+ dev_kfree_skb(pRDInfo->skb);
+
+ kfree((PVOID)pDesc->pRDInfo);
+ }
+
+}
+
+static void device_free_rd1_ring(PSDevice pDevice) {
+ int i;
+
+
+ for (i = 0; i < pDevice->sOpts.nRxDescs1; i++) {
+ PSRxDesc pDesc=&(pDevice->aRD1Ring[i]);
+ PDEVICE_RD_INFO pRDInfo=pDesc->pRDInfo;
+
+ pci_unmap_single(pDevice->pcid,pRDInfo->skb_dma,
+ pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+
+ dev_kfree_skb(pRDInfo->skb);
+
+ kfree((PVOID)pDesc->pRDInfo);
+ }
+
+}
+
+static void device_free_frag_buf(PSDevice pDevice) {
+ PSDeFragControlBlock pDeF;
+ int i;
+
+ for (i = 0; i < CB_MAX_RX_FRAG; i++) {
+
+ pDeF = &(pDevice->sRxDFCB[i]);
+
+ if (pDeF->skb)
+ dev_kfree_skb(pDeF->skb);
+
+ }
+
+}
+
+static void device_init_td0_ring(PSDevice pDevice) {
+ int i;
+ dma_addr_t curr;
+ PSTxDesc pDesc;
+
+ curr = pDevice->td0_pool_dma;
+ for (i = 0; i < pDevice->sOpts.nTxDescs[0]; i++, curr += sizeof(STxDesc)) {
+ pDesc = &(pDevice->apTD0Rings[i]);
+ pDesc->pTDInfo = alloc_td_info();
+ ASSERT(pDesc->pTDInfo);
+ if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) {
+ pDesc->pTDInfo->buf = pDevice->tx0_bufs + (i)*PKT_BUF_SZ;
+ pDesc->pTDInfo->buf_dma = pDevice->tx_bufs_dma0 + (i)*PKT_BUF_SZ;
+ }
+ pDesc->next =&(pDevice->apTD0Rings[(i+1) % pDevice->sOpts.nTxDescs[0]]);
+ pDesc->pTDInfo->curr_desc = cpu_to_le32(curr);
+ pDesc->next_desc = cpu_to_le32(curr+sizeof(STxDesc));
+ }
+
+ pDevice->apTD0Rings[i-1].next_desc = cpu_to_le32(pDevice->td0_pool_dma);
+ pDevice->apTailTD[0] = pDevice->apCurrTD[0] =&(pDevice->apTD0Rings[0]);
+
+}
+
+static void device_init_td1_ring(PSDevice pDevice) {
+ int i;
+ dma_addr_t curr;
+ PSTxDesc pDesc;
+
+ /* Init the TD ring entries */
+ curr=pDevice->td1_pool_dma;
+ for (i = 0; i < pDevice->sOpts.nTxDescs[1]; i++, curr+=sizeof(STxDesc)) {
+ pDesc=&(pDevice->apTD1Rings[i]);
+ pDesc->pTDInfo = alloc_td_info();
+ ASSERT(pDesc->pTDInfo);
+ if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) {
+ pDesc->pTDInfo->buf=pDevice->tx1_bufs+(i)*PKT_BUF_SZ;
+ pDesc->pTDInfo->buf_dma=pDevice->tx_bufs_dma1+(i)*PKT_BUF_SZ;
+ }
+ pDesc->next=&(pDevice->apTD1Rings[(i+1) % pDevice->sOpts.nTxDescs[1]]);
+ pDesc->pTDInfo->curr_desc = cpu_to_le32(curr);
+ pDesc->next_desc = cpu_to_le32(curr+sizeof(STxDesc));
+ }
+
+ pDevice->apTD1Rings[i-1].next_desc = cpu_to_le32(pDevice->td1_pool_dma);
+ pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]);
+}
+
+
+
+static void device_free_td0_ring(PSDevice pDevice) {
+ int i;
+ for (i = 0; i < pDevice->sOpts.nTxDescs[0]; i++) {
+ PSTxDesc pDesc=&(pDevice->apTD0Rings[i]);
+ PDEVICE_TD_INFO pTDInfo=pDesc->pTDInfo;
+
+ if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
+ pci_unmap_single(pDevice->pcid,pTDInfo->skb_dma,
+ pTDInfo->skb->len, PCI_DMA_TODEVICE);
+
+ if (pTDInfo->skb)
+ dev_kfree_skb(pTDInfo->skb);
+
+ kfree((PVOID)pDesc->pTDInfo);
+ }
+}
+
+static void device_free_td1_ring(PSDevice pDevice) {
+ int i;
+
+ for (i = 0; i < pDevice->sOpts.nTxDescs[1]; i++) {
+ PSTxDesc pDesc=&(pDevice->apTD1Rings[i]);
+ PDEVICE_TD_INFO pTDInfo=pDesc->pTDInfo;
+
+ if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
+ pci_unmap_single(pDevice->pcid, pTDInfo->skb_dma,
+ pTDInfo->skb->len, PCI_DMA_TODEVICE);
+
+ if (pTDInfo->skb)
+ dev_kfree_skb(pTDInfo->skb);
+
+ kfree((PVOID)pDesc->pTDInfo);
+ }
+
+}
+
+
+
+/*-----------------------------------------------------------------*/
+
+static int device_rx_srv(PSDevice pDevice, UINT uIdx) {
+ PSRxDesc pRD;
+ int works = 0;
+
+
+ for (pRD = pDevice->pCurrRD[uIdx];
+ pRD->m_rd0RD0.f1Owner == OWNED_BY_HOST;
+ pRD = pRD->next) {
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->pCurrRD = %x, works = %d\n", pRD, works);
+ if (works++>15)
+ break;
+ if (device_receive_frame(pDevice, pRD)) {
+ if (!device_alloc_rx_buf(pDevice,pRD)) {
+ DEVICE_PRT(MSG_LEVEL_ERR, KERN_ERR
+ "%s: can not allocate rx buf\n", pDevice->dev->name);
+ break;
+ }
+ }
+ pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC;
+#ifdef PRIVATE_OBJ
+ ref_set_rx_jiffies(pDevice->dev);
+#else
+ pDevice->dev->last_rx = jiffies;
+#endif
+ }
+
+ pDevice->pCurrRD[uIdx]=pRD;
+
+ return works;
+}
+
+
+static BOOL device_alloc_rx_buf(PSDevice pDevice, PSRxDesc pRD) {
+
+ PDEVICE_RD_INFO pRDInfo=pRD->pRDInfo;
+
+#ifdef PRIVATE_OBJ
+
+ pRDInfo->skb=dev_alloc_skb(pDevice->rx_buf_sz);
+ if (pRDInfo->skb==NULL)
+ return FALSE;
+ ref_skb_remap(pDevice->dev, &(pRDInfo->ref_skb), pRDInfo->skb);
+ pRDInfo->skb_dma = pci_map_single(pDevice->pcid, pRDInfo->ref_skb.tail, pDevice->rx_buf_sz,
+ PCI_DMA_FROMDEVICE);
+#else
+
+ pRDInfo->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+#ifdef PLICE_DEBUG
+ //printk("device_alloc_rx_buf:skb is %x\n",pRDInfo->skb);
+#endif
+ if (pRDInfo->skb==NULL)
+ return FALSE;
+ ASSERT(pRDInfo->skb);
+ pRDInfo->skb->dev = pDevice->dev;
+ pRDInfo->skb_dma = pci_map_single(pDevice->pcid, pRDInfo->skb->tail, pDevice->rx_buf_sz,
+ PCI_DMA_FROMDEVICE);
+#endif
+ *((PU32) &(pRD->m_rd0RD0)) = 0;
+
+ pRD->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz);
+ pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC;
+ pRD->m_rd1RD1.wReqCount = cpu_to_le16(pDevice->rx_buf_sz);
+ pRD->buff_addr = cpu_to_le32(pRDInfo->skb_dma);
+
+ return TRUE;
+}
+
+
+
+BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) {
+
+#ifdef PRIVATE_OBJ
+
+ pDeF->skb=dev_alloc_skb(pDevice->rx_buf_sz);
+ if (pDeF->skb==NULL)
+ return FALSE;
+ ref_skb_remap(pDevice->dev, &(pDeF->ref_skb), pDeF->skb);
+
+#else
+ pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ if (pDeF->skb == NULL)
+ return FALSE;
+ ASSERT(pDeF->skb);
+ pDeF->skb->dev = pDevice->dev;
+#endif
+
+ return TRUE;
+}
+
+
+
+static int device_tx_srv(PSDevice pDevice, UINT uIdx) {
+ PSTxDesc pTD;
+ BOOL bFull=FALSE;
+ int works = 0;
+ BYTE byTsr0;
+ BYTE byTsr1;
+ UINT uFrameSize, uFIFOHeaderSize;
+ PSTxBufHead pTxBufHead;
+ struct net_device_stats* pStats = &pDevice->stats;
+ struct sk_buff* skb;
+ UINT uNodeIndex;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+#ifdef PRIVATE_OBJ
+ ref_sk_buff ref_skb;
+#endif
+
+
+ for (pTD = pDevice->apTailTD[uIdx]; pDevice->iTDUsed[uIdx] >0; pTD = pTD->next) {
+
+ if (pTD->m_td0TD0.f1Owner == OWNED_BY_NIC)
+ break;
+ if (works++>15)
+ break;
+
+ byTsr0 = pTD->m_td0TD0.byTSR0;
+ byTsr1 = pTD->m_td0TD0.byTSR1;
+
+ //Only the status of first TD in the chain is correct
+ if (pTD->m_td1TD1.byTCR & TCR_STP) {
+
+ if ((pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) {
+ uFIFOHeaderSize = pTD->pTDInfo->dwHeaderLength;
+ uFrameSize = pTD->pTDInfo->dwReqCount - uFIFOHeaderSize;
+ pTxBufHead = (PSTxBufHead) (pTD->pTDInfo->buf);
+#ifdef PRIVATE_OBJ
+ ref_skb_remap(pDevice->dev, &ref_skb, pTD->pTDInfo->skb);
+#endif
+ // Update the statistics based on the Transmit status
+ // now, we DO'NT check TSR0_CDH
+
+ STAvUpdateTDStatCounter(&pDevice->scStatistic,
+ byTsr0, byTsr1,
+ (PBYTE)(pTD->pTDInfo->buf + uFIFOHeaderSize),
+ uFrameSize, uIdx);
+
+
+ BSSvUpdateNodeTxCounter(pDevice,
+ byTsr0, byTsr1,
+ (PBYTE)(pTD->pTDInfo->buf),
+ uFIFOHeaderSize
+ );
+
+ if (BITbIsBitOff(byTsr1, TSR1_TERR)) {
+ if (byTsr0 != 0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] OK but has error. tsr1[%02X] tsr0[%02X].\n",
+ (INT)uIdx, byTsr1, byTsr0);
+ }
+ if ((pTxBufHead->wFragCtl & FRAGCTL_ENDFRAG) != FRAGCTL_NONFRAG) {
+ pDevice->s802_11Counter.TransmittedFragmentCount ++;
+ }
+ pStats->tx_packets++;
+#ifdef PRIVATE_OBJ
+ pStats->tx_bytes += *(ref_skb.len);
+#else
+ pStats->tx_bytes += pTD->pTDInfo->skb->len;
+#endif
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] dropped & tsr1[%02X] tsr0[%02X].\n",
+ (INT)uIdx, byTsr1, byTsr0);
+ pStats->tx_errors++;
+ pStats->tx_dropped++;
+ }
+ }
+
+ if ((pTD->pTDInfo->byFlags & TD_FLAGS_PRIV_SKB) != 0) {
+ if (pDevice->bEnableHostapd) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "tx call back netif.. \n");
+#ifdef PRIVATE_OBJ
+ ref_skb_remap(pDevice->apdev, &(ref_skb), pTD->pTDInfo->skb);
+ ref_skb.mac.raw = ref_skb.data;
+ *(ref_skb.pkt_type) = PACKET_OTHERHOST;
+ //*(ref_skb.protocol) = htons(ETH_P_802_2);
+ memset(ref_skb.cb, 0, sizeof(ref_skb.cb));
+ netif_rx(ref_skb.skb);
+#else
+ skb = pTD->pTDInfo->skb;
+ skb->dev = pDevice->apdev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ skb->mac_header = skb->data;
+#else
+ skb->mac.raw = skb->data;
+#endif
+ skb->pkt_type = PACKET_OTHERHOST;
+ //skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb);
+#endif
+ }
+ }
+
+ if (BITbIsBitOn(byTsr1, TSR1_TERR)) {
+ if ((pTD->pTDInfo->byFlags & TD_FLAGS_PRIV_SKB) != 0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X].\n",
+ (INT)uIdx, byTsr1, byTsr0);
+ }
+
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X].\n",
+// (INT)uIdx, byTsr1, byTsr0);
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
+ (pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)) {
+ WORD wAID;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+
+ skb = pTD->pTDInfo->skb;
+ if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data), &uNodeIndex)) {
+ if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) {
+ skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb);
+ pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++;
+ // set tx map
+ wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID;
+ pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7];
+ pTD->pTDInfo->byFlags &= ~(TD_FLAGS_NETIF_SKB);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "tx_srv:tx fail re-queue sta index= %d, QueCnt= %d\n"
+ ,(INT)uNodeIndex, pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt);
+ pStats->tx_errors--;
+ pStats->tx_dropped--;
+ }
+ }
+ }
+ }
+ device_free_tx_buf(pDevice,pTD);
+ pDevice->iTDUsed[uIdx]--;
+ }
+ }
+
+
+ if (uIdx == TYPE_AC0DMA) {
+ // RESERV_AC0DMA reserved for relay
+
+ if (AVAIL_TD(pDevice, uIdx) < RESERV_AC0DMA) {
+ bFull = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " AC0DMA is Full = %d\n", pDevice->iTDUsed[uIdx]);
+ }
+ if (netif_queue_stopped(pDevice->dev) && (bFull==FALSE)){
+ netif_wake_queue(pDevice->dev);
+ }
+ }
+
+
+ pDevice->apTailTD[uIdx] = pTD;
+
+ return works;
+}
+
+
+static void device_error(PSDevice pDevice, WORD status) {
+
+ if (status & ISR_FETALERR) {
+ DEVICE_PRT(MSG_LEVEL_ERR, KERN_ERR
+ "%s: Hardware fatal error.\n",
+ pDevice->dev->name);
+ netif_stop_queue(pDevice->dev);
+ del_timer(&pDevice->sTimerCommand);
+ del_timer(&(pDevice->pMgmt->sTimerSecondCallback));
+ pDevice->bCmdRunning = FALSE;
+ MACbShutdown(pDevice->PortOffset);
+ return;
+ }
+
+}
+
+static void device_free_tx_buf(PSDevice pDevice, PSTxDesc pDesc) {
+ PDEVICE_TD_INFO pTDInfo=pDesc->pTDInfo;
+ struct sk_buff* skb=pTDInfo->skb;
+
+ // pre-allocated buf_dma can't be unmapped.
+ if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma)) {
+ pci_unmap_single(pDevice->pcid,pTDInfo->skb_dma,skb->len,
+ PCI_DMA_TODEVICE);
+ }
+
+ if ((pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0)
+ dev_kfree_skb_irq(skb);
+
+ pTDInfo->skb_dma = 0;
+ pTDInfo->skb = 0;
+ pTDInfo->byFlags = 0;
+}
+
+
+
+//PLICE_DEBUG ->
+VOID InitRxManagementQueue(PSDevice pDevice)
+{
+ pDevice->rxManeQueue.packet_num = 0;
+ pDevice->rxManeQueue.head = pDevice->rxManeQueue.tail = 0;
+}
+//PLICE_DEBUG<-
+
+
+
+
+
+//PLICE_DEBUG ->
+INT MlmeThread(
+ void * Context)
+{
+ PSDevice pDevice = (PSDevice) Context;
+ PSRxMgmtPacket pRxMgmtPacket;
+ // int i ;
+ //complete(&pDevice->notify);
+//printk("Enter MngWorkItem,Queue packet num is %d\n",pDevice->rxManeQueue.packet_num);
+
+ //printk("Enter MlmeThread,packet _num is %d\n",pDevice->rxManeQueue.packet_num);
+ //i = 0;
+#if 1
+ while (1)
+ {
+
+ //printk("DDDD\n");
+ //down(&pDevice->mlme_semaphore);
+ // pRxMgmtPacket = DeQueue(pDevice);
+#if 1
+ spin_lock_irq(&pDevice->lock);
+ while(pDevice->rxManeQueue.packet_num != 0)
+ {
+ pRxMgmtPacket = DeQueue(pDevice);
+ //pDevice;
+ //DequeueManageObject(pDevice->FirstRecvMngList, pDevice->LastRecvMngList);
+ vMgrRxManagePacket(pDevice, pDevice->pMgmt, pRxMgmtPacket);
+ //printk("packet_num is %d\n",pDevice->rxManeQueue.packet_num);
+
+ }
+ spin_unlock_irq(&pDevice->lock);
+ if (mlme_kill == 0)
+ break;
+ //udelay(200);
+#endif
+ //printk("Before schedule thread jiffies is %x\n",jiffies);
+ schedule();
+ //printk("after schedule thread jiffies is %x\n",jiffies);
+ if (mlme_kill == 0)
+ break;
+ //printk("i is %d\n",i);
+ }
+
+#endif
+ return 0;
+
+}
+
+
+#ifdef PRIVATE_OBJ
+
+int __device_open(HANDLE pExDevice) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+#else
+
+static int device_open(struct net_device *dev) {
+ PSDevice pDevice=(PSDevice) dev->priv;
+ int i;
+#endif
+ pDevice->rx_buf_sz = PKT_BUF_SZ;
+ if (!device_init_rings(pDevice)) {
+ return -ENOMEM;
+ }
+//2008-5-13 <add> by chester
+#ifndef PRIVATE_OBJ
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
+ i=request_irq(pDevice->pcid->irq, &device_intr, IRQF_SHARED, dev->name, dev);
+#else
+ i=request_irq(pDevice->pcid->irq, &device_intr, (unsigned long)SA_SHIRQ, dev->name, dev);
+#endif
+ if (i)
+ return i;
+#endif
+ //printk("DEBUG1\n");
+#ifdef WPA_SM_Transtatus
+ extern SWPAResult wpa_Result;
+ memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
+ wpa_Result.proto = 0;
+ wpa_Result.key_mgmt = 0;
+ wpa_Result.eap_type = 0;
+ wpa_Result.authenticated = FALSE;
+ pDevice->fWPA_Authened = FALSE;
+#endif
+DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "call device init rd0 ring\n");
+device_init_rd0_ring(pDevice);
+ device_init_rd1_ring(pDevice);
+ device_init_defrag_cb(pDevice);
+ device_init_td0_ring(pDevice);
+ device_init_td1_ring(pDevice);
+// VNTWIFIvSet11h(pDevice->pMgmt, pDevice->b11hEnable);
+
+
+ if (pDevice->bDiversityRegCtlON) {
+ device_init_diversity_timer(pDevice);
+ }
+ vMgrObjectInit(pDevice);
+ vMgrTimerInit(pDevice);
+
+//PLICE_DEBUG->
+#ifdef TASK_LET
+ tasklet_init (&pDevice->RxMngWorkItem,(void *)MngWorkItem,(unsigned long )pDevice);
+#endif
+#ifdef THREAD
+ InitRxManagementQueue(pDevice);
+ mlme_kill = 0;
+ mlme_task = kthread_run(MlmeThread,(void *) pDevice, "MLME");
+ if (IS_ERR(mlme_task)) {
+ printk("thread create fail\n");
+ return -1;
+ }
+
+ mlme_kill = 1;
+#endif
+
+
+
+#if 0
+ pDevice->MLMEThr_pid = kernel_thread(MlmeThread, pDevice, CLONE_VM);
+ if (pDevice->MLMEThr_pid <0 )
+ {
+ printk("unable start thread MlmeThread\n");
+ return -1;
+ }
+#endif
+
+ //printk("thread id is %d\n",pDevice->MLMEThr_pid);
+ //printk("Create thread time is %x\n",jiffies);
+ //wait_for_completion(&pDevice->notify);
+
+
+
+
+ // if (( SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RADIOCTL)&0x06)==0x04)
+ // return -ENOMEM;
+DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "call device_init_registers\n");
+ device_init_registers(pDevice, DEVICE_INIT_COLD);
+ MACvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr);
+ memcpy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
+#ifdef PRIVATE_OBJ
+ __device_set_multi(pExDevice);
+#else
+ device_set_multi(pDevice->dev);
+#endif
+
+ // Init for Key Management
+ KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
+ add_timer(&(pDevice->pMgmt->sTimerSecondCallback));
+
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ /*
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ */
+ pDevice->bwextcount=0;
+ pDevice->bWPASuppWextEnabled = FALSE;
+#endif
+ pDevice->byReAssocCount = 0;
+ pDevice->bWPADEVUp = FALSE;
+ // Patch: if WEP key already set by iwconfig but device not yet open
+ if ((pDevice->bEncryptionEnable == TRUE) && (pDevice->bTransmitKey == TRUE)) {
+ KeybSetDefaultKey(&(pDevice->sKey),
+ (DWORD)(pDevice->byKeyIndex | (1 << 31)),
+ pDevice->uKeyLength,
+ NULL,
+ pDevice->abyKey,
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID
+ );
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ }
+
+//printk("DEBUG2\n");
+
+
+DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "call MACvIntEnable\n");
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+
+ if (pDevice->pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+ }
+ else {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SSID, NULL);
+ }
+ pDevice->flags |=DEVICE_FLAGS_OPENED;
+
+#ifndef PRIVATE_OBJ
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ MOD_INC_USE_COUNT;
+#endif
+#endif
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open success.. \n");
+ return 0;
+}
+
+
+#ifdef PRIVATE_OBJ
+
+int __device_close(HANDLE pExDevice) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ struct net_device *dev = pDevice_info->dev;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+#else
+static int device_close(struct net_device *dev) {
+ PSDevice pDevice=(PSDevice) dev->priv;
+#endif
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ //PLICE_DEBUG->
+#ifdef THREAD
+ mlme_kill = 0;
+#endif
+//PLICE_DEBUG<-
+//2007-1121-02<Add>by EinsnLiu
+ if (pDevice->bLinkPass) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+ mdelay(30);
+ }
+#ifdef TxInSleep
+ del_timer(&pDevice->sTimerTxData);
+#endif
+ del_timer(&pDevice->sTimerCommand);
+ del_timer(&pMgmt->sTimerSecondCallback);
+ if (pDevice->bDiversityRegCtlON) {
+ del_timer(&pDevice->TimerSQ3Tmax1);
+ del_timer(&pDevice->TimerSQ3Tmax2);
+ del_timer(&pDevice->TimerSQ3Tmax3);
+ }
+
+#ifdef TASK_LET
+ tasklet_kill(&pDevice->RxMngWorkItem);
+#endif
+ netif_stop_queue(dev);
+ pDevice->bCmdRunning = FALSE;
+ MACbShutdown(pDevice->PortOffset);
+ MACbSoftwareReset(pDevice->PortOffset);
+ CARDbRadioPowerOff(pDevice);
+
+ pDevice->bLinkPass = FALSE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ device_free_td0_ring(pDevice);
+ device_free_td1_ring(pDevice);
+ device_free_rd0_ring(pDevice);
+ device_free_rd1_ring(pDevice);
+ device_free_frag_buf(pDevice);
+ device_free_rings(pDevice);
+ BSSvClearNodeDBTable(pDevice, 0);
+ free_irq(dev->irq, dev);
+ pDevice->flags &=(~DEVICE_FLAGS_OPENED);
+ //2008-0714-01<Add>by chester
+device_release_WPADEV(pDevice);
+//PLICE_DEBUG->
+ //tasklet_kill(&pDevice->RxMngWorkItem);
+//PLICE_DEBUG<-
+#ifndef PRIVATE_OBJ
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ MOD_DEC_USE_COUNT;
+#endif
+#endif
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close.. \n");
+ return 0;
+}
+
+#ifdef PRIVATE_OBJ
+
+int __device_dma0_tx_80211(HANDLE pExDevice, struct sk_buff *skb) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+ ref_sk_buff ref_skb;
+
+#else
+
+
+static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) {
+ PSDevice pDevice=dev->priv;
+#endif
+ PBYTE pbMPDU;
+ UINT cbMPDULen = 0;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_tx_80211\n");
+ spin_lock_irq(&pDevice->lock);
+
+ if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_tx_80211, td0 <=0\n");
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+
+ if (pDevice->bStopTx0Pkt == TRUE) {
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ };
+
+#ifdef PRIVATE_OBJ
+ ref_skb_remap(pDevice->dev, &ref_skb, skb);
+ cbMPDULen = *(ref_skb.len);
+ pbMPDU = ref_skb.data;
+#else
+ cbMPDULen = skb->len;
+ pbMPDU = skb->data;
+#endif
+
+ vDMA0_tx_80211(pDevice, skb, pbMPDU, cbMPDULen);
+
+ spin_unlock_irq(&pDevice->lock);
+
+ return 0;
+
+}
+
+
+
+BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex) {
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSTxDesc pHeadTD, pLastTD;
+ UINT cbFrameBodySize;
+ UINT uMACfragNum;
+ BYTE byPktTyp;
+ BOOL bNeedEncryption = FALSE;
+ PSKeyItem pTransmitKey = NULL;
+ UINT cbHeaderSize;
+ UINT ii;
+ SKeyItem STempKey;
+// BYTE byKeyIndex = 0;
+#ifdef PRIVATE_OBJ
+ ref_sk_buff ref_skb;
+#endif
+
+
+ if (pDevice->bStopTx0Pkt == TRUE) {
+ dev_kfree_skb_irq(skb);
+ return FALSE;
+ };
+
+ if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) {
+ dev_kfree_skb_irq(skb);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_xmit, td0 <=0\n");
+ return FALSE;
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (pDevice->uAssocCount == 0) {
+ dev_kfree_skb_irq(skb);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_xmit, assocCount = 0\n");
+ return FALSE;
+ }
+ }
+
+#ifdef PRIVATE_OBJ
+ ref_skb_remap(pDevice->dev, &(ref_skb), skb);
+#endif
+ pHeadTD = pDevice->apCurrTD[TYPE_TXDMA0];
+
+ pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
+
+#ifdef PRIVATE_OBJ
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(ref_skb.data), U_HEADER_LEN);
+ cbFrameBodySize = *(ref_skb.len) - U_HEADER_LEN;
+
+#else
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), U_HEADER_LEN);
+ cbFrameBodySize = skb->len - U_HEADER_LEN;
+#endif
+
+ // 802.1H
+ if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
+ cbFrameBodySize += 8;
+ }
+ uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
+
+ if ( uMACfragNum > AVAIL_TD(pDevice, TYPE_TXDMA0)) {
+ dev_kfree_skb_irq(skb);
+ return FALSE;
+ }
+ byPktTyp = (BYTE)pDevice->byPacketType;
+
+
+ if (pDevice->bFixRate) {
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ if (pDevice->uConnectionRate >= RATE_11M) {
+ pDevice->wCurrentRate = RATE_11M;
+ } else {
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ } else {
+ if (pDevice->uConnectionRate >= RATE_54M)
+ pDevice->wCurrentRate = RATE_54M;
+ else
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ }
+ else {
+ pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
+ }
+
+ //preamble type
+ if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ }
+ else {
+ pDevice->byPreambleType = PREAMBLE_LONG;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dma0: pDevice->wCurrentRate = %d \n", pDevice->wCurrentRate);
+
+
+ if (pDevice->wCurrentRate <= RATE_11M) {
+ byPktTyp = PK_TYPE_11B;
+ } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
+ byPktTyp = PK_TYPE_11A;
+ } else {
+ if (pDevice->bProtectMode == TRUE) {
+ byPktTyp = PK_TYPE_11GB;
+ } else {
+ byPktTyp = PK_TYPE_11GA;
+ }
+ }
+
+ if (pDevice->bEncryptionEnable == TRUE)
+ bNeedEncryption = TRUE;
+
+ if (pDevice->bEnableHostWEP) {
+ pTransmitKey = &STempKey;
+ pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
+ pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
+ pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
+ pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
+ pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
+ memcpy(pTransmitKey->abyKey,
+ &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
+ pTransmitKey->uKeyLength
+ );
+ }
+ vGenerateFIFOHeader(pDevice, byPktTyp, pDevice->pbyTmpBuff, bNeedEncryption,
+ cbFrameBodySize, TYPE_TXDMA0, pHeadTD,
+ &pDevice->sTxEthHeader, (PBYTE)skb->data, pTransmitKey, uNodeIndex,
+ &uMACfragNum,
+ &cbHeaderSize
+ );
+
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
+ // Disable PS
+ MACbPSWakeup(pDevice->PortOffset);
+ }
+
+ pDevice->bPWBitOn = FALSE;
+
+ pLastTD = pHeadTD;
+ for (ii = 0; ii < uMACfragNum; ii++) {
+ // Poll Transmit the adapter
+ wmb();
+ pHeadTD->m_td0TD0.f1Owner=OWNED_BY_NIC;
+ wmb();
+ if (ii == (uMACfragNum - 1))
+ pLastTD = pHeadTD;
+ pHeadTD = pHeadTD->next;
+ }
+
+ // Save the information needed by the tx interrupt handler
+ // to complete the Send request
+ pLastTD->pTDInfo->skb = skb;
+ pLastTD->pTDInfo->byFlags = 0;
+ pLastTD->pTDInfo->byFlags |= TD_FLAGS_NETIF_SKB;
+
+ pDevice->apCurrTD[TYPE_TXDMA0] = pHeadTD;
+
+ MACvTransmit0(pDevice->PortOffset);
+
+
+ return TRUE;
+}
+
+//TYPE_AC0DMA data tx
+#ifdef PRIVATE_OBJ
+
+int __device_xmit(HANDLE pExDevice, struct sk_buff *skb) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+ struct net_device *dev = pDevice_info->dev;
+ ref_sk_buff ref_skb;
+
+#else
+static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
+ PSDevice pDevice=dev->priv;
+
+#endif
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSTxDesc pHeadTD, pLastTD;
+ UINT uNodeIndex = 0;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ WORD wAID;
+ UINT uMACfragNum = 1;
+ UINT cbFrameBodySize;
+ BYTE byPktTyp;
+ UINT cbHeaderSize;
+ BOOL bNeedEncryption = FALSE;
+ PSKeyItem pTransmitKey = NULL;
+ SKeyItem STempKey;
+ UINT ii;
+ BOOL bTKIP_UseGTK = FALSE;
+ BOOL bNeedDeAuth = FALSE;
+ PBYTE pbyBSSID;
+ BOOL bNodeExist = FALSE;
+
+
+
+ spin_lock_irq(&pDevice->lock);
+ if (pDevice->bLinkPass == FALSE) {
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+
+ if (pDevice->bStopDataPkt) {
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+
+#ifdef PRIVATE_OBJ
+ ref_skb_remap(pDevice->dev, &ref_skb, skb);
+#endif
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (pDevice->uAssocCount == 0) {
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+#ifdef PRIVATE_OBJ
+ if (IS_MULTICAST_ADDRESS((PBYTE)(ref_skb.data))) {
+#else
+ if (IS_MULTICAST_ADDRESS((PBYTE)(skb->data))) {
+#endif
+ uNodeIndex = 0;
+ bNodeExist = TRUE;
+ if (pMgmt->sNodeDBTable[0].bPSEnable) {
+#ifdef PRIVATE_OBJ
+ skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), ref_skb.skb);
+#else
+ skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb);
+#endif
+ pMgmt->sNodeDBTable[0].wEnQueueCnt++;
+ // set tx map
+ pMgmt->abyPSTxMap[0] |= byMask[0];
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+}else {
+#ifdef PRIVATE_OBJ
+ if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(ref_skb.data), &uNodeIndex)) {
+#else
+ if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data), &uNodeIndex)) {
+#endif
+ if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) {
+#ifdef PRIVATE_OBJ
+ skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, ref_skb.skb);
+#else
+ skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb);
+#endif
+ pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++;
+ // set tx map
+ wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID;
+ pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7];
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set:pMgmt->abyPSTxMap[%d]= %d\n",
+ (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+
+ if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+
+ }else {
+ pDevice->byPreambleType = PREAMBLE_LONG;
+ }
+ bNodeExist = TRUE;
+
+ }
+ }
+
+ if (bNodeExist == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Unknown STA not found in node DB \n");
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+ }
+
+ pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
+
+ pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
+
+
+#ifdef PRIVATE_OBJ
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(ref_skb.data), U_HEADER_LEN);
+ cbFrameBodySize = *(ref_skb.len) - U_HEADER_LEN;
+#else
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), U_HEADER_LEN);
+ cbFrameBodySize = skb->len - U_HEADER_LEN;
+#endif
+ // 802.1H
+ if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
+ cbFrameBodySize += 8;
+ }
+
+
+ if (pDevice->bEncryptionEnable == TRUE) {
+ bNeedEncryption = TRUE;
+ // get Transmit key
+ do {
+ if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ pbyBSSID = pDevice->abyBSSID;
+ // get pairwise key
+ if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == FALSE) {
+ // get group key
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == TRUE) {
+ bTKIP_UseGTK = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
+ break;
+ }
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get PTK.\n");
+ break;
+ }
+ }else if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+
+ pbyBSSID = pDevice->sTxEthHeader.abyDstAddr; //TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS Serach Key: \n");
+ for (ii = 0; ii< 6; ii++)
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"%x \n", *(pbyBSSID+ii));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"\n");
+
+ // get pairwise key
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE)
+ break;
+ }
+ // get group key
+ pbyBSSID = pDevice->abyBroadcastAddr;
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) {
+ pTransmitKey = NULL;
+ if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS and KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode);
+ }
+ else
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"NOT IBSS and KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode);
+ } else {
+ bTKIP_UseGTK = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
+ }
+ } while(FALSE);
+ }
+
+ if (pDevice->bEnableHostWEP) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"acdma0: STA index %d\n", uNodeIndex);
+ if (pDevice->bEncryptionEnable == TRUE) {
+ pTransmitKey = &STempKey;
+ pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
+ pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
+ pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
+ pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
+ pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
+ memcpy(pTransmitKey->abyKey,
+ &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
+ pTransmitKey->uKeyLength
+ );
+ }
+ }
+
+ uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
+
+ if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA)) {
+ DEVICE_PRT(MSG_LEVEL_ERR, KERN_DEBUG "uMACfragNum > AVAIL_TD(TYPE_AC0DMA) = %d\n", uMACfragNum);
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+
+ if (pTransmitKey != NULL) {
+ if ((pTransmitKey->byCipherSuite == KEY_CTL_WEP) &&
+ (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN)) {
+ uMACfragNum = 1; //WEP256 doesn't support fragment
+ }
+ }
+
+ byPktTyp = (BYTE)pDevice->byPacketType;
+
+ if (pDevice->bFixRate) {
+#ifdef PLICE_DEBUG
+ printk("Fix Rate: PhyType is %d,ConnectionRate is %d\n",pDevice->eCurrentPHYType,pDevice->uConnectionRate);
+#endif
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ if (pDevice->uConnectionRate >= RATE_11M) {
+ pDevice->wCurrentRate = RATE_11M;
+ } else {
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ } else {
+ if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
+ (pDevice->uConnectionRate <= RATE_6M)) {
+ pDevice->wCurrentRate = RATE_6M;
+ } else {
+ if (pDevice->uConnectionRate >= RATE_54M)
+ pDevice->wCurrentRate = RATE_54M;
+ else
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+
+ }
+ }
+ pDevice->byACKRate = (BYTE) pDevice->wCurrentRate;
+ pDevice->byTopCCKBasicRate = RATE_1M;
+ pDevice->byTopOFDMBasicRate = RATE_6M;
+ }
+ else {
+ //auto rate
+ if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
+ if (pDevice->eCurrentPHYType != PHY_TYPE_11A) {
+ pDevice->wCurrentRate = RATE_1M;
+ pDevice->byACKRate = RATE_1M;
+ pDevice->byTopCCKBasicRate = RATE_1M;
+ pDevice->byTopOFDMBasicRate = RATE_6M;
+ } else {
+ pDevice->wCurrentRate = RATE_6M;
+ pDevice->byACKRate = RATE_6M;
+ pDevice->byTopCCKBasicRate = RATE_1M;
+ pDevice->byTopOFDMBasicRate = RATE_6M;
+ }
+ }
+ else {
+ VNTWIFIvGetTxRate( pDevice->pMgmt,
+ pDevice->sTxEthHeader.abyDstAddr,
+ &(pDevice->wCurrentRate),
+ &(pDevice->byACKRate),
+ &(pDevice->byTopCCKBasicRate),
+ &(pDevice->byTopOFDMBasicRate));
+
+#if 0
+printk("auto rate:Rate : %d,AckRate:%d,TopCCKRate:%d,TopOFDMRate:%d\n",
+pDevice->wCurrentRate,pDevice->byACKRate,
+pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate);
+
+#endif
+
+#if 0
+
+ pDevice->wCurrentRate = 11;
+ pDevice->byACKRate = 8;
+ pDevice->byTopCCKBasicRate = 3;
+ pDevice->byTopOFDMBasicRate = 8;
+#endif
+
+
+ }
+ }
+
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "acdma0: pDevice->wCurrentRate = %d \n", pDevice->wCurrentRate);
+
+ if (pDevice->wCurrentRate <= RATE_11M) {
+ byPktTyp = PK_TYPE_11B;
+ } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
+ byPktTyp = PK_TYPE_11A;
+ } else {
+ if (pDevice->bProtectMode == TRUE) {
+ byPktTyp = PK_TYPE_11GB;
+ } else {
+ byPktTyp = PK_TYPE_11GA;
+ }
+ }
+
+//#ifdef PLICE_DEBUG
+// printk("FIX RATE:CurrentRate is %d");
+//#endif
+
+ if (bNeedEncryption == TRUE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType));
+ if ((pDevice->sTxEthHeader.wType) == TYPE_PKT_802_1x) {
+ bNeedEncryption = FALSE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType));
+ if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ if (pTransmitKey == NULL) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Don't Find TX KEY\n");
+ }
+ else {
+ if (bTKIP_UseGTK == TRUE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"error: KEY is GTK!!~~\n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex);
+ bNeedEncryption = TRUE;
+ }
+ }
+ }
+
+ if (pDevice->byCntMeasure == 2) {
+ bNeedDeAuth = TRUE;
+ pDevice->s802_11Counter.TKIPCounterMeasuresInvoked++;
+ }
+
+ if (pDevice->bEnableHostWEP) {
+ if ((uNodeIndex != 0) &&
+ (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex);
+ bNeedEncryption = TRUE;
+ }
+ }
+ }
+ else {
+ if (pTransmitKey == NULL) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n");
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+ }
+ }
+
+
+#ifdef PRIVATE_OBJ
+ vGenerateFIFOHeader(pDevice, byPktTyp, pDevice->pbyTmpBuff, bNeedEncryption,
+ cbFrameBodySize, TYPE_AC0DMA, pHeadTD,
+ &pDevice->sTxEthHeader, (PBYTE)ref_skb.data, pTransmitKey, uNodeIndex,
+ &uMACfragNum,
+ &cbHeaderSize
+ );
+#else
+#ifdef PLICE_DEBUG
+ //if (skb->len == 98)
+ //{
+ // printk("ping:len is %d\n");
+ //}
+#endif
+ vGenerateFIFOHeader(pDevice, byPktTyp, pDevice->pbyTmpBuff, bNeedEncryption,
+ cbFrameBodySize, TYPE_AC0DMA, pHeadTD,
+ &pDevice->sTxEthHeader, (PBYTE)skb->data, pTransmitKey, uNodeIndex,
+ &uMACfragNum,
+ &cbHeaderSize
+ );
+#endif
+
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
+ // Disable PS
+ MACbPSWakeup(pDevice->PortOffset);
+ }
+ pDevice->bPWBitOn = FALSE;
+
+ pLastTD = pHeadTD;
+ for (ii = 0; ii < uMACfragNum; ii++) {
+ // Poll Transmit the adapter
+ wmb();
+ pHeadTD->m_td0TD0.f1Owner=OWNED_BY_NIC;
+ wmb();
+ if (ii == uMACfragNum - 1)
+ pLastTD = pHeadTD;
+ pHeadTD = pHeadTD->next;
+ }
+
+ // Save the information needed by the tx interrupt handler
+ // to complete the Send request
+#ifdef PRIVATE_OBJ
+ pLastTD->pTDInfo->skb = ref_skb.skb;
+#else
+ pLastTD->pTDInfo->skb = skb;
+#endif
+ pLastTD->pTDInfo->byFlags = 0;
+ pLastTD->pTDInfo->byFlags |= TD_FLAGS_NETIF_SKB;
+#ifdef TxInSleep
+ pDevice->nTxDataTimeCout=0; //2008-8-21 chester <add> for send null packet
+ #endif
+ if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 1) {
+ netif_stop_queue(dev);
+ }
+
+ pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
+//#ifdef PLICE_DEBUG
+ if (pDevice->bFixRate)
+ {
+ printk("FixRate:Rate is %d,TxPower is %d\n",pDevice->wCurrentRate,pDevice->byCurPwr);
+ }
+ else
+ {
+ //printk("Auto Rate:Rate is %d,TxPower is %d\n",pDevice->wCurrentRate,pDevice->byCurPwr);
+ }
+//#endif
+
+{
+ BYTE Protocol_Version; //802.1x Authentication
+ BYTE Packet_Type; //802.1x Authentication
+ BYTE Descriptor_type;
+ WORD Key_info;
+BOOL bTxeapol_key = FALSE;
+ Protocol_Version = skb->data[U_HEADER_LEN];
+ Packet_Type = skb->data[U_HEADER_LEN+1];
+ Descriptor_type = skb->data[U_HEADER_LEN+1+1+2];
+ Key_info = (skb->data[U_HEADER_LEN+1+1+2+1] << 8)|(skb->data[U_HEADER_LEN+1+1+2+2]);
+ if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
+ if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
+ (Packet_Type==3)) { //802.1x OR eapol-key challenge frame transfer
+ bTxeapol_key = TRUE;
+ if((Descriptor_type==254)||(Descriptor_type==2)) { //WPA or RSN
+ if(!(Key_info & BIT3) && //group-key challenge
+ (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key
+ pDevice->fWPA_Authened = TRUE;
+ if(Descriptor_type==254)
+ printk("WPA ");
+ else
+ printk("WPA2 ");
+ printk("Authentication completed!!\n");
+ }
+ }
+ }
+ }
+}
+
+ MACvTransmitAC0(pDevice->PortOffset);
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "acdma0:pDevice->apCurrTD= %p\n", pHeadTD);
+
+#ifdef PRIVATE_OBJ
+ ref_set_tx_jiffies(pDevice->dev);
+#else
+ dev->trans_start = jiffies;
+#endif
+
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+
+}
+
+#ifdef PRIVATE_OBJ
+
+int __device_intr(int irq, HANDLE pExDevice, struct pt_regs *regs) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+
+#else
+static irqreturn_t device_intr(int irq, void *dev_instance) {
+ struct net_device* dev=dev_instance;
+ PSDevice pDevice=(PSDevice) dev->priv;
+#endif
+
+ int max_count=0;
+ DWORD dwMIBCounter=0;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ BYTE byOrgPageSel=0;
+ int handled = 0;
+ BYTE byData = 0;
+ int ii= 0;
+// BYTE byRSSI;
+
+
+ MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+
+ if (pDevice->dwIsr == 0)
+ return IRQ_RETVAL(handled);
+
+ if (pDevice->dwIsr == 0xffffffff) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dwIsr = 0xffff\n");
+ return IRQ_RETVAL(handled);
+ }
+ /*
+ // 2008-05-21 <mark> by Richardtai, we can't read RSSI here, because no packet bound with RSSI
+
+ if ((BITbIsBitOn(pDevice->dwIsr, ISR_RXDMA0)) &&
+ (pDevice->byLocalID != REV_ID_VT3253_B0) &&
+ (pDevice->bBSSIDFilter == TRUE)) {
+ // update RSSI
+ //BBbReadEmbeded(pDevice->PortOffset, 0x3E, &byRSSI);
+ //pDevice->uCurrRSSI = byRSSI;
+ }
+ */
+
+ handled = 1;
+ MACvIntDisable(pDevice->PortOffset);
+ spin_lock_irq(&pDevice->lock);
+
+ //Make sure current page is 0
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
+ if (byOrgPageSel == 1) {
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+ else
+ byOrgPageSel = 0;
+
+ MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter);
+ // TBD....
+ // Must do this after doing rx/tx, cause ISR bit is slow
+ // than RD/TD write back
+ // update ISR counter
+ STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic , dwMIBCounter);
+ while (pDevice->dwIsr != 0) {
+
+ STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr);
+ MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr);
+
+ if (pDevice->dwIsr & ISR_FETALERR){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " ISR_FETALERR \n");
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0);
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
+ device_error(pDevice, pDevice->dwIsr);
+ }
+
+ if (pDevice->byLocalID > REV_ID_VT3253_B1) {
+
+ if (BITbIsBitOn(pDevice->dwIsr, ISR_MEASURESTART)) {
+ // 802.11h measure start
+ pDevice->byOrgChannel = pDevice->byCurrentCh;
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byOrgRCR));
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, (RCR_RXALLTYPE | RCR_UNICAST | RCR_BROADCAST | RCR_MULTICAST | RCR_WPAERR));
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR0, &(pDevice->dwOrgMAR0));
+ VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR4, &(pDevice->dwOrgMAR4));
+ MACvSelectPage0(pDevice->PortOffset);
+ //xxxx
+ // WCMDbFlushCommandQueue(pDevice->pMgmt, TRUE);
+ if (CARDbSetChannel(pDevice, pDevice->pCurrMeasureEID->sReq.byChannel) == TRUE) {
+ pDevice->bMeasureInProgress = TRUE;
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_READY);
+ MACvSelectPage0(pDevice->PortOffset);
+ pDevice->byBasicMap = 0;
+ pDevice->byCCAFraction = 0;
+ for(ii=0;ii<8;ii++) {
+ pDevice->dwRPIs[ii] = 0;
+ }
+ } else {
+ // can not measure because set channel fail
+ // WCMDbResetCommandQueue(pDevice->pMgmt);
+ // clear measure control
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
+ s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_INCAPABLE);
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+ }
+ if (BITbIsBitOn(pDevice->dwIsr, ISR_MEASUREEND)) {
+ // 802.11h measure end
+ pDevice->bMeasureInProgress = FALSE;
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR);
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4);
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_MSRBBSTS, &byData);
+ pDevice->byBasicMap |= (byData >> 4);
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_CCAFRACTION, &pDevice->byCCAFraction);
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_MSRCTL, &byData);
+ // clear measure control
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
+ MACvSelectPage0(pDevice->PortOffset);
+ CARDbSetChannel(pDevice, pDevice->byOrgChannel);
+ // WCMDbResetCommandQueue(pDevice->pMgmt);
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
+ MACvSelectPage0(pDevice->PortOffset);
+ if (BITbIsBitOn(byData, MSRCTL_FINISH)) {
+ // measure success
+ s_vCompleteCurrentMeasure(pDevice, 0);
+ } else {
+ // can not measure because not ready before end of measure time
+ s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_LATE);
+ }
+ }
+ if (BITbIsBitOn(pDevice->dwIsr, ISR_QUIETSTART)) {
+ do {
+ ;
+ } while (CARDbStartQuiet(pDevice) == FALSE);
+ }
+ }
+
+ if (pDevice->dwIsr & ISR_TBTT) {
+ if (pDevice->bEnableFirstQuiet == TRUE) {
+ pDevice->byQuietStartCount--;
+ if (pDevice->byQuietStartCount == 0) {
+ pDevice->bEnableFirstQuiet = FALSE;
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
+ MACvSelectPage0(pDevice->PortOffset);
+ }
+ }
+ if ((pDevice->bChannelSwitch == TRUE) &&
+ (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE)) {
+ pDevice->byChannelSwitchCount--;
+ if (pDevice->byChannelSwitchCount == 0) {
+ pDevice->bChannelSwitch = FALSE;
+ CARDbSetChannel(pDevice, pDevice->byNewChannel);
+ VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel);
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
+ MACvSelectPage0(pDevice->PortOffset);
+ CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL);
+
+ }
+ }
+ if (pDevice->eOPMode == OP_MODE_ADHOC) {
+ //pDevice->bBeaconSent = FALSE;
+ } else {
+ if ((pDevice->bUpdateBBVGA) && (pDevice->bLinkPass == TRUE) && (pDevice->uCurrRSSI != 0)) {
+ LONG ldBm;
+
+ RFvRSSITodBm(pDevice, (BYTE) pDevice->uCurrRSSI, &ldBm);
+ for (ii=0;ii<BB_VGA_LEVEL;ii++) {
+ if (ldBm < pDevice->ldBmThreshold[ii]) {
+ pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
+ break;
+ }
+ }
+ if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
+ pDevice->uBBVGADiffCount++;
+ if (pDevice->uBBVGADiffCount == 1) {
+ // first VGA diff gain
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
+ (int)ldBm, pDevice->byBBVGANew, pDevice->byBBVGACurrent, (int)pDevice->uBBVGADiffCount);
+ }
+ if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n",
+ (int)ldBm, pDevice->byBBVGANew, pDevice->byBBVGACurrent, (int)pDevice->uBBVGADiffCount);
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
+ }
+ } else {
+ pDevice->uBBVGADiffCount = 1;
+ }
+ }
+ }
+
+ pDevice->bBeaconSent = FALSE;
+ if (pDevice->bEnablePSMode) {
+ PSbIsNextTBTTWakeUp((HANDLE)pDevice);
+ };
+
+ if ((pDevice->eOPMode == OP_MODE_AP) ||
+ (pDevice->eOPMode == OP_MODE_ADHOC)) {
+
+ MACvOneShotTimer1MicroSec(pDevice->PortOffset,
+ (pMgmt->wIBSSBeaconPeriod - MAKE_BEACON_RESERVED) << 10);
+ }
+
+ if (pDevice->eOPMode == OP_MODE_ADHOC && pDevice->pMgmt->wCurrATIMWindow > 0) {
+ // todo adhoc PS mode
+ };
+
+ }
+
+ if (pDevice->dwIsr & ISR_BNTX) {
+
+ if (pDevice->eOPMode == OP_MODE_ADHOC) {
+ pDevice->bIsBeaconBufReadySet = FALSE;
+ pDevice->cbBeaconBufReadySetCnt = 0;
+ };
+
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ if(pMgmt->byDTIMCount > 0) {
+ pMgmt->byDTIMCount --;
+ pMgmt->sNodeDBTable[0].bRxPSPoll = FALSE;
+ }
+ else {
+ if(pMgmt->byDTIMCount == 0) {
+ // check if mutltcast tx bufferring
+ pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
+ pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE;
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
+ }
+ }
+ }
+ pDevice->bBeaconSent = TRUE;
+
+ if (pDevice->bChannelSwitch == TRUE) {
+ pDevice->byChannelSwitchCount--;
+ if (pDevice->byChannelSwitchCount == 0) {
+ pDevice->bChannelSwitch = FALSE;
+ CARDbSetChannel(pDevice, pDevice->byNewChannel);
+ VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel);
+ MACvSelectPage1(pDevice->PortOffset);
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
+ MACvSelectPage0(pDevice->PortOffset);
+ //VNTWIFIbSendBeacon(pDevice->pMgmt);
+ CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL);
+ }
+ }
+
+ }
+
+ if (pDevice->dwIsr & ISR_RXDMA0) {
+ max_count += device_rx_srv(pDevice, TYPE_RXDMA0);
+ }
+ if (pDevice->dwIsr & ISR_RXDMA1) {
+ max_count += device_rx_srv(pDevice, TYPE_RXDMA1);
+ }
+ if (pDevice->dwIsr & ISR_TXDMA0){
+ max_count += device_tx_srv(pDevice, TYPE_TXDMA0);
+ }
+ if (pDevice->dwIsr & ISR_AC0DMA){
+ max_count += device_tx_srv(pDevice, TYPE_AC0DMA);
+ }
+ if (pDevice->dwIsr & ISR_SOFTTIMER) {
+
+ }
+ if (pDevice->dwIsr & ISR_SOFTTIMER1) {
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ if (pDevice->bShortSlotTime)
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
+ else
+ pMgmt->wCurrCapInfo &= ~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1));
+ }
+ bMgrPrepareBeaconToSend(pDevice, pMgmt);
+ pDevice->byCntMeasure = 0;
+ }
+
+ MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+
+ MACvReceive0(pDevice->PortOffset);
+ MACvReceive1(pDevice->PortOffset);
+
+ if (max_count>pDevice->sOpts.int_works)
+ break;
+ }
+
+ if (byOrgPageSel == 1) {
+ MACvSelectPage1(pDevice->PortOffset);
+ }
+
+ spin_unlock_irq(&pDevice->lock);
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+
+ return IRQ_RETVAL(handled);
+}
+
+
+static unsigned const ethernet_polynomial = 0x04c11db7U;
+static inline u32 ether_crc(int length, unsigned char *data)
+{
+ int crc = -1;
+
+ while(--length >= 0) {
+ unsigned char current_octet = *data++;
+ int bit;
+ for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
+ crc = (crc << 1) ^
+ ((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0);
+ }
+ }
+ return crc;
+}
+
+//2008-8-4 <add> by chester
+static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source)
+{
+ UCHAR buf1[100];
+ int source_len = strlen(source);
+
+ memset(buf1,0,100);
+ strcat(buf1, string);
+ strcat(buf1, "=");
+ source+=strlen(buf1);
+
+ memcpy(dest,source,source_len-strlen(buf1));
+ return TRUE;
+}
+
+int Config_FileOperation(PSDevice pDevice,BOOL fwrite,unsigned char *Parameter) {
+ UCHAR *config_path=CONFIG_PATH;
+ UCHAR *buffer=NULL;
+ UCHAR tmpbuffer[20];
+ struct file *filp=NULL;
+ mm_segment_t old_fs = get_fs();
+ //int oldfsuid=0,oldfsgid=0;
+ int result=0;
+
+ set_fs (KERNEL_DS);
+
+ /* Can't do this anymore, so we rely on correct filesystem permissions:
+ //Make sure a caller can read or write power as root
+ oldfsuid=current->cred->fsuid;
+ oldfsgid=current->cred->fsgid;
+ current->cred->fsuid = 0;
+ current->cred->fsgid = 0;
+ */
+
+ //open file
+ filp = filp_open(config_path, O_RDWR, 0);
+ if (IS_ERR(filp)) {
+ printk("Config_FileOperation:open file fail?\n");
+ result=-1;
+ goto error2;
+ }
+
+ if(!(filp->f_op) || !(filp->f_op->read) ||!(filp->f_op->write)) {
+ printk("file %s cann't readable or writable?\n",config_path);
+ result = -1;
+ goto error1;
+ }
+
+buffer = (UCHAR *)kmalloc(1024, GFP_KERNEL);
+if(buffer==NULL) {
+ printk("alllocate mem for file fail?\n");
+ result = -1;
+ goto error1;
+}
+
+if(filp->f_op->read(filp, buffer, 1024, &filp->f_pos)<0) {
+ printk("read file error?\n");
+ result = -1;
+ goto error1;
+}
+
+if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer)!=TRUE) {
+ printk("get parameter error?\n");
+ result = -1;
+ goto error1;
+}
+
+if(memcmp(tmpbuffer,"USA",3)==0) {
+ result=ZoneType_USA;
+}
+else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
+ result=ZoneType_Japan;
+}
+else if(memcmp(tmpbuffer,"EUROPE",5)==0) {
+ result=ZoneType_Europe;
+}
+else {
+ result = -1;
+ printk("Unknown Zonetype[%s]?\n",tmpbuffer);
+}
+
+error1:
+ if(buffer)
+ kfree(buffer);
+
+ if(filp_close(filp,NULL))
+ printk("Config_FileOperation:close file fail\n");
+
+error2:
+ set_fs (old_fs);
+
+ /*
+ current->cred->fsuid=oldfsuid;
+ current->cred->fsgid=oldfsgid;
+ */
+
+ return result;
+}
+
+
+#ifdef PRIVATE_OBJ
+
+void __device_set_multi(HANDLE pExDevice) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ ref_net_device *dev = &(pDevice_info->ref_dev);
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+#else
+
+static void device_set_multi(struct net_device *dev) {
+ PSDevice pDevice = (PSDevice) dev->priv;
+#endif
+
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ u32 mc_filter[2];
+ int i;
+ struct dev_mc_list *mclist;
+
+
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
+
+#ifdef PRIVATE_OBJ
+ if (*(dev->flags) & IFF_PROMISC) { /* Set promiscuous. */
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: Promiscuous mode enabled.\n", pDevice->dev->name);
+
+#else
+ if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
+#endif
+ /* Unconditionally log net taps. */
+ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
+ }
+#ifdef PRIVATE_OBJ
+ else if ((*(dev->mc_count) > pDevice->multicast_limit)
+ || (*(dev->flags) & IFF_ALLMULTI)) {
+#else
+ else if ((dev->mc_count > pDevice->multicast_limit)
+ || (dev->flags & IFF_ALLMULTI)) {
+#endif
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, 0xffffffff);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0 + 4, 0xffffffff);
+ MACvSelectPage0(pDevice->PortOffset);
+ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
+ }
+ else {
+ memset(mc_filter, 0, sizeof(mc_filter));
+#ifdef PRIVATE_OBJ
+ for (i = 0, mclist = dev->mc_list; mclist && i < *(dev->mc_count);
+ i++, mclist = mclist->next) {
+#else
+ for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
+ i++, mclist = mclist->next) {
+#endif
+ int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
+ mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
+ }
+ MACvSelectPage1(pDevice->PortOffset);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, mc_filter[0]);
+ VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0 + 4, mc_filter[1]);
+ MACvSelectPage0(pDevice->PortOffset);
+ pDevice->byRxMode &= ~(RCR_UNICAST);
+ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
+ }
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ // If AP mode, don't enable RCR_UNICAST. Since hw only compare addr1 with local mac.
+ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
+ pDevice->byRxMode &= ~(RCR_UNICAST);
+ }
+
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byRxMode);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode = %x\n", pDevice->byRxMode );
+}
+
+
+#ifdef PRIVATE_OBJ
+
+struct net_device_stats *__device_get_stats(HANDLE pExDevice) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+#else
+static struct net_device_stats *device_get_stats(struct net_device *dev) {
+ PSDevice pDevice=(PSDevice) dev->priv;
+#endif
+
+ return &pDevice->stats;
+}
+
+
+#ifdef PRIVATE_OBJ
+
+int __device_ioctl(HANDLE pExDevice, struct ifreq *rq, int cmd) {
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ struct net_device *dev = pDevice_info->dev;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+#else
+
+static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
+ PSDevice pDevice = (PSDevice)dev->priv;
+#endif
+
+#ifdef WIRELESS_EXT
+ struct iwreq *wrq = (struct iwreq *) rq;
+ int rc =0;
+#endif
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSCmdRequest pReq;
+
+
+ if (pMgmt == NULL) {
+ rc = -EFAULT;
+ return rc;
+ }
+
+ switch(cmd) {
+
+#ifdef WIRELESS_EXT
+//#if WIRELESS_EXT < 13
+
+ case SIOCGIWNAME:
+ rc = iwctl_giwname(dev, NULL, (char *)&(wrq->u.name), NULL);
+ break;
+
+ case SIOCGIWNWID: //0x8b03 support
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ rc = iwctl_giwnwid(dev, NULL, &(wrq->u.nwid), NULL);
+ #else
+ rc = -EOPNOTSUPP;
+ #endif
+ break;
+
+ // Set frequency/channel
+ case SIOCSIWFREQ:
+ rc = iwctl_siwfreq(dev, NULL, &(wrq->u.freq), NULL);
+ break;
+
+ // Get frequency/channel
+ case SIOCGIWFREQ:
+ rc = iwctl_giwfreq(dev, NULL, &(wrq->u.freq), NULL);
+ break;
+
+ // Set desired network name (ESSID)
+ case SIOCSIWESSID:
+
+ {
+ char essid[IW_ESSID_MAX_SIZE+1];
+ if (wrq->u.essid.length > IW_ESSID_MAX_SIZE) {
+ rc = -E2BIG;
+ break;
+ }
+ if (copy_from_user(essid, wrq->u.essid.pointer,
+ wrq->u.essid.length)) {
+ rc = -EFAULT;
+ break;
+ }
+ rc = iwctl_siwessid(dev, NULL,
+ &(wrq->u.essid), essid);
+ }
+ break;
+
+
+ // Get current network name (ESSID)
+ case SIOCGIWESSID:
+
+ {
+ char essid[IW_ESSID_MAX_SIZE+1];
+ if (wrq->u.essid.pointer)
+ rc = iwctl_giwessid(dev, NULL,
+ &(wrq->u.essid), essid);
+ if (copy_to_user(wrq->u.essid.pointer,
+ essid,
+ wrq->u.essid.length) )
+ rc = -EFAULT;
+ }
+ break;
+
+ case SIOCSIWAP:
+
+ rc = iwctl_siwap(dev, NULL, &(wrq->u.ap_addr), NULL);
+ break;
+
+
+ // Get current Access Point (BSSID)
+ case SIOCGIWAP:
+ rc = iwctl_giwap(dev, NULL, &(wrq->u.ap_addr), NULL);
+ break;
+
+
+ // Set desired station name
+ case SIOCSIWNICKN:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWNICKN \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ // Get current station name
+ case SIOCGIWNICKN:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWNICKN \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ // Set the desired bit-rate
+ case SIOCSIWRATE:
+ rc = iwctl_siwrate(dev, NULL, &(wrq->u.bitrate), NULL);
+ break;
+
+ // Get the current bit-rate
+ case SIOCGIWRATE:
+
+ rc = iwctl_giwrate(dev, NULL, &(wrq->u.bitrate), NULL);
+ break;
+
+ // Set the desired RTS threshold
+ case SIOCSIWRTS:
+
+ rc = iwctl_siwrts(dev, NULL, &(wrq->u.rts), NULL);
+ break;
+
+ // Get the current RTS threshold
+ case SIOCGIWRTS:
+
+ rc = iwctl_giwrts(dev, NULL, &(wrq->u.rts), NULL);
+ break;
+
+ // Set the desired fragmentation threshold
+ case SIOCSIWFRAG:
+
+ rc = iwctl_siwfrag(dev, NULL, &(wrq->u.frag), NULL);
+ break;
+
+ // Get the current fragmentation threshold
+ case SIOCGIWFRAG:
+
+ rc = iwctl_giwfrag(dev, NULL, &(wrq->u.frag), NULL);
+ break;
+
+ // Set mode of operation
+ case SIOCSIWMODE:
+ rc = iwctl_siwmode(dev, NULL, &(wrq->u.mode), NULL);
+ break;
+
+ // Get mode of operation
+ case SIOCGIWMODE:
+ rc = iwctl_giwmode(dev, NULL, &(wrq->u.mode), NULL);
+ break;
+
+ // Set WEP keys and mode
+ case SIOCSIWENCODE:
+ {
+ char abyKey[WLAN_WEP232_KEYLEN];
+
+ if (wrq->u.encoding.pointer) {
+
+
+ if (wrq->u.encoding.length > WLAN_WEP232_KEYLEN) {
+ rc = -E2BIG;
+ break;
+ }
+ memset(abyKey, 0, WLAN_WEP232_KEYLEN);
+ if (copy_from_user(abyKey,
+ wrq->u.encoding.pointer,
+ wrq->u.encoding.length)) {
+ rc = -EFAULT;
+ break;
+ }
+ } else if (wrq->u.encoding.length != 0) {
+ rc = -EINVAL;
+ break;
+ }
+ rc = iwctl_siwencode(dev, NULL, &(wrq->u.encoding), abyKey);
+ }
+ break;
+
+ // Get the WEP keys and mode
+ case SIOCGIWENCODE:
+
+ if (!capable(CAP_NET_ADMIN)) {
+ rc = -EPERM;
+ break;
+ }
+ {
+ char abyKey[WLAN_WEP232_KEYLEN];
+
+ rc = iwctl_giwencode(dev, NULL, &(wrq->u.encoding), abyKey);
+ if (rc != 0) break;
+ if (wrq->u.encoding.pointer) {
+ if (copy_to_user(wrq->u.encoding.pointer,
+ abyKey,
+ wrq->u.encoding.length))
+ rc = -EFAULT;
+ }
+ }
+ break;
+
+#if WIRELESS_EXT > 9
+ // Get the current Tx-Power
+ case SIOCGIWTXPOW:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ case SIOCSIWTXPOW:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+#endif // WIRELESS_EXT > 9
+
+#if WIRELESS_EXT > 10
+ case SIOCSIWRETRY:
+
+ rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL);
+ break;
+
+ case SIOCGIWRETRY:
+
+ rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL);
+ break;
+
+#endif // WIRELESS_EXT > 10
+
+ // Get range of parameters
+ case SIOCGIWRANGE:
+
+ {
+ struct iw_range range;
+
+ rc = iwctl_giwrange(dev, NULL, &(wrq->u.data), (char *) &range);
+ if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range)))
+ rc = -EFAULT;
+ }
+
+ break;
+
+ case SIOCGIWPOWER:
+
+ rc = iwctl_giwpower(dev, NULL, &(wrq->u.power), NULL);
+ break;
+
+
+ case SIOCSIWPOWER:
+
+ rc = iwctl_siwpower(dev, NULL, &(wrq->u.power), NULL);
+ break;
+
+
+ case SIOCGIWSENS:
+
+ rc = iwctl_giwsens(dev, NULL, &(wrq->u.sens), NULL);
+ break;
+
+ case SIOCSIWSENS:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSENS \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ case SIOCGIWAPLIST:
+ {
+ char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))];
+
+ if (wrq->u.data.pointer) {
+ rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer);
+ if (rc == 0) {
+ if (copy_to_user(wrq->u.data.pointer,
+ buffer,
+ (wrq->u.data.length * (sizeof(struct sockaddr) + sizeof(struct iw_quality)))
+ ))
+ rc = -EFAULT;
+ }
+ }
+ }
+ break;
+
+
+#ifdef WIRELESS_SPY
+ // Set the spy list
+ case SIOCSIWSPY:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ // Get the spy list
+ case SIOCGIWSPY:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+#endif // WIRELESS_SPY
+
+ case SIOCGIWPRIV:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPRIV \n");
+ rc = -EOPNOTSUPP;
+/*
+ if(wrq->u.data.pointer) {
+ wrq->u.data.length = sizeof(iwctl_private_args) / sizeof( iwctl_private_args[0]);
+
+ if(copy_to_user(wrq->u.data.pointer,
+ (u_char *) iwctl_private_args,
+ sizeof(iwctl_private_args)))
+ rc = -EFAULT;
+ }
+*/
+ break;
+
+
+//#endif // WIRELESS_EXT < 13
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ case SIOCSIWAUTH:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
+ rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL);
+ break;
+
+ case SIOCGIWAUTH:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAUTH \n");
+ rc = iwctl_giwauth(dev, NULL, &(wrq->u.param), NULL);
+ break;
+
+ case SIOCSIWGENIE:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWGENIE \n");
+ rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
+ break;
+
+ case SIOCGIWGENIE:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWGENIE \n");
+ rc = iwctl_giwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
+ break;
+
+ case SIOCSIWENCODEEXT:
+ {
+ char extra[sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1];
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODEEXT \n");
+ if(wrq->u.encoding.pointer){
+ memset(extra, 0, sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1);
+ if(wrq->u.encoding.length > (sizeof(struct iw_encode_ext)+ MAX_KEY_LEN)){
+ rc = -E2BIG;
+ break;
+ }
+ if(copy_from_user(extra, wrq->u.encoding.pointer,wrq->u.encoding.length)){
+ rc = -EFAULT;
+ break;
+ }
+ }else if(wrq->u.encoding.length != 0){
+ rc = -EINVAL;
+ break;
+ }
+ rc = iwctl_siwencodeext(dev, NULL, &(wrq->u.encoding), extra);
+ }
+ break;
+
+ case SIOCGIWENCODEEXT:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODEEXT \n");
+ rc = iwctl_giwencodeext(dev, NULL, &(wrq->u.encoding), NULL);
+ break;
+
+ case SIOCSIWMLME:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMLME \n");
+ rc = iwctl_siwmlme(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
+ break;
+
+#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+//End Add -- //2008-0409-07, <Add> by Einsn Liu
+
+#endif // WIRELESS_EXT
+
+ case IOCTL_CMD_TEST:
+
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EFAULT;
+ break;
+ } else {
+ rc = 0;
+ }
+ pReq = (PSCmdRequest)rq;
+ pReq->wResult = MAGIC_CODE;
+ break;
+
+ case IOCTL_CMD_SET:
+
+ #ifdef SndEvt_ToAPI
+ if((((PSCmdRequest)rq)->wCmdCode !=WLAN_CMD_SET_EVT) &&
+ !(pDevice->flags & DEVICE_FLAGS_OPENED))
+ #else
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED) &&
+ (((PSCmdRequest)rq)->wCmdCode !=WLAN_CMD_SET_WPA))
+ #endif
+ {
+ rc = -EFAULT;
+ break;
+ } else {
+ rc = 0;
+ }
+
+ if (test_and_set_bit( 0, (void*)&(pMgmt->uCmdBusy))) {
+ return -EBUSY;
+ }
+ rc = private_ioctl(pDevice, rq);
+ clear_bit( 0, (void*)&(pMgmt->uCmdBusy));
+ break;
+
+ case IOCTL_CMD_HOSTAPD:
+
+
+#if WIRELESS_EXT > 8
+ rc = hostap_ioctl(pDevice, &wrq->u.data);
+#else // WIRELESS_EXT > 8
+ rc = hostap_ioctl(pDevice, (struct iw_point *) &wrq->u.data);
+#endif // WIRELESS_EXT > 8
+ break;
+
+ case IOCTL_CMD_WPA:
+
+#if WIRELESS_EXT > 8
+ rc = wpa_ioctl(pDevice, &wrq->u.data);
+#else // WIRELESS_EXT > 8
+ rc = wpa_ioctl(pDevice, (struct iw_point *) &wrq->u.data);
+#endif // WIRELESS_EXT > 8
+ break;
+
+ case SIOCETHTOOL:
+ return ethtool_ioctl(dev, (void *) rq->ifr_data);
+ // All other calls are currently unsupported
+
+ default:
+ rc = -EOPNOTSUPP;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Ioctl command not support..%x\n", cmd);
+
+
+ }
+
+ if (pDevice->bCommit) {
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ netif_stop_queue(pDevice->dev);
+ spin_lock_irq(&pDevice->lock);
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+ spin_unlock_irq(&pDevice->lock);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n");
+ spin_lock_irq(&pDevice->lock);
+ pDevice->bLinkPass = FALSE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ netif_stop_queue(pDevice->dev);
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ if(pDevice->bWPASuppWextEnabled !=TRUE)
+ #endif
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+ spin_unlock_irq(&pDevice->lock);
+ }
+ pDevice->bCommit = FALSE;
+ }
+
+ return rc;
+}
+
+
+static int ethtool_ioctl(struct net_device *dev, void *useraddr)
+{
+ u32 ethcmd;
+
+ if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
+ return -EFAULT;
+
+ switch (ethcmd) {
+ case ETHTOOL_GDRVINFO: {
+ struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
+ strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);
+ strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);
+ if (copy_to_user(useraddr, &info, sizeof(info)))
+ return -EFAULT;
+ return 0;
+ }
+
+ }
+
+ return -EOPNOTSUPP;
+}
+
+/*------------------------------------------------------------------*/
+#ifndef PRIVATE_OBJ
+
+MODULE_DEVICE_TABLE(pci, device_id_table);
+
+static struct pci_driver device_driver = {
+ name: DEVICE_NAME,
+ id_table: device_id_table,
+ probe: device_found1,
+ remove: device_remove1,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
+#ifdef CONFIG_PM
+ suspend: viawget_suspend,
+ resume: viawget_resume,
+#endif
+#endif
+};
+
+static int __init device_init_module(void)
+{
+ int ret;
+
+
+// ret=pci_module_init(&device_driver);
+ //ret = pcie_port_service_register(&device_driver);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ ret = pci_register_driver(&device_driver);
+#else
+ ret = pci_module_init(&device_driver);
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
+#ifdef CONFIG_PM
+ if(ret >= 0)
+ register_reboot_notifier(&device_notifier);
+#endif
+#endif
+
+ return ret;
+}
+
+static void __exit device_cleanup_module(void)
+{
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
+#ifdef CONFIG_PM
+ unregister_reboot_notifier(&device_notifier);
+#endif
+#endif
+ pci_unregister_driver(&device_driver);
+
+}
+
+module_init(device_init_module);
+module_exit(device_cleanup_module);
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
+#ifdef CONFIG_PM
+static int
+device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
+{
+ struct pci_dev *pdev = NULL;
+ switch(event) {
+ case SYS_DOWN:
+ case SYS_HALT:
+ case SYS_POWER_OFF:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ while ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
+#else
+ pci_for_each_dev(pdev) {
+#endif
+ if(pci_dev_driver(pdev) == &device_driver) {
+ if (pci_get_drvdata(pdev))
+ viawget_suspend(pdev, 3);
+ }
+ }
+ }
+ return NOTIFY_DONE;
+}
+
+static int
+viawget_suspend(struct pci_dev *pcid, u32 state)
+{
+ int power_status; // to silence the compiler
+
+ PSDevice pDevice=pci_get_drvdata(pcid);
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+ netif_stop_queue(pDevice->dev);
+ spin_lock_irq(&pDevice->lock);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ pci_save_state(pcid);
+#else
+ pci_save_state(pcid, pDevice->pci_state);
+#endif
+ del_timer(&pDevice->sTimerCommand);
+ del_timer(&pMgmt->sTimerSecondCallback);
+ pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
+ pDevice->uCmdDequeueIdx = 0;
+ pDevice->uCmdEnqueueIdx = 0;
+ pDevice->bCmdRunning = FALSE;
+ MACbShutdown(pDevice->PortOffset);
+ MACvSaveContext(pDevice->PortOffset, pDevice->abyMacContext);
+ pDevice->bLinkPass = FALSE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pci_disable_device(pcid);
+ power_status = pci_set_power_state(pcid, state);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+}
+
+static int
+viawget_resume(struct pci_dev *pcid)
+{
+ PSDevice pDevice=pci_get_drvdata(pcid);
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int power_status; // to silence the compiler
+
+
+ power_status = pci_set_power_state(pcid, 0);
+ power_status = pci_enable_wake(pcid, 0, 0);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ pci_restore_state(pcid);
+#else
+ pci_restore_state(pcid, pDevice->pci_state);
+#endif
+ if (netif_running(pDevice->dev)) {
+ spin_lock_irq(&pDevice->lock);
+ MACvRestoreContext(pDevice->PortOffset, pDevice->abyMacContext);
+ device_init_registers(pDevice, DEVICE_INIT_DXPL);
+ if (pMgmt->sNodeDBTable[0].bActive == TRUE) { // Assoc with BSS
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ pDevice->bLinkPass = FALSE;
+ if(pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ // In Adhoc, BSS state set back to started.
+ pMgmt->eCurrState = WMAC_STATE_STARTED;
+ }
+ else {
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ }
+ }
+ init_timer(&pMgmt->sTimerSecondCallback);
+ init_timer(&pDevice->sTimerCommand);
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+ spin_unlock_irq(&pDevice->lock);
+ }
+ return 0;
+}
+
+#endif
+#endif
+
+#endif //#ifndef PRIVATE_OBJ
+
+#ifdef PRIVATE_OBJ
+
+
+int __device_hw_reset(HANDLE pExDevice){
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+
+ return MACbSoftwareReset(pDevice_info->port_offset);
+}
+
+
+int __device_hw_init(HANDLE pExDevice){
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice;
+
+
+ pDevice = (PSDevice)kmalloc(sizeof(DEVICE_INFO), (int)GFP_ATOMIC);
+ if (pDevice == NULL)
+ return FALSE;
+
+ memset(pDevice, 0, sizeof(DEVICE_INFO));
+ pDevice_info->pWDevice = pDevice;
+ pDevice->PortOffset = pDevice_info->port_offset;
+ pDevice->dev = pDevice_info->dev;
+ pDevice->pcid = pDevice_info->pcid;
+ pDevice->chip_id = pDevice_info->chip_id;
+ pDevice->memaddr = pDevice_info->mem_addr;
+ pDevice->ioaddr = pDevice_info->io_addr;
+ pDevice->io_size = pDevice_info->io_size;
+ pDevice->nTxQueues = pDevice_info->nTxQueues;
+ pDevice->multicast_limit = pDevice_info->multicast_limit;
+ pDevice->sMgmtObj.pAdapter = (PVOID)pDevice;
+ pDevice->pMgmt = &(pDevice->sMgmtObj);
+ MACvInitialize(pDevice->PortOffset);
+ device_get_options(pDevice, 0 , pDevice_info->dev->name);
+ device_set_options(pDevice);
+ pDevice->sOpts.flags &= pDevice_info->flags;
+ pDevice->flags = pDevice->sOpts.flags | (pDevice_info->flags & 0xFF000000UL);
+ spin_lock_init(&(pDevice->lock));
+
+ return TRUE;
+}
+
+
+void __device_read_mac(HANDLE pExDevice, PBYTE dev_addr){
+ PSDevice_info pDevice_info = (PSDevice_info)pExDevice;
+ PSDevice pDevice = (PSDevice)(pDevice_info->pWDevice);
+
+ MACvReadEtherAddress(pDevice->PortOffset, dev_addr);
+ return;
+}
+
+
+#endif
+
+
diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c
new file mode 100644
index 000000000000..05366b9754f0
--- /dev/null
+++ b/drivers/staging/vt6655/dpc.c
@@ -0,0 +1,1688 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: dpc.c
+ *
+ * Purpose: handle dpc rx functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 20, 2003
+ *
+ * Functions:
+ * device_receive_frame - Rcv 802.11 frame function
+ * s_bAPModeRxCtl- AP Rcv frame filer Ctl.
+ * s_bAPModeRxData- AP Rcv data frame handle
+ * s_bHandleRxEncryption- Rcv decrypted data via on-fly
+ * s_bHostWepRxEncryption- Rcv encrypted data via host
+ * s_byGetRateIdx- get rate index
+ * s_vGetDASA- get data offset
+ * s_vProcessRxMACHeader- Rcv 802.11 and translate to 802.3
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__MICHAEL_H__)
+#include "michael.h"
+#endif
+#if !defined(__TKIP_H__)
+#include "tkip.h"
+#endif
+#if !defined(__TCRC_H__)
+#include "tcrc.h"
+#endif
+#if !defined(__WCTL_H__)
+#include "wctl.h"
+#endif
+#if !defined(__WROUTE_H__)
+#include "wroute.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+#if !defined(__AES_H__)
+#include "aes_ccmp.h"
+#endif
+
+//#define PLICE_DEBUG
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+const BYTE acbyRxRate[MAX_RATE] =
+{2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
+
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+static BYTE s_byGetRateIdx(IN BYTE byRate);
+
+
+static
+VOID
+s_vGetDASA(
+ IN PBYTE pbyRxBufferAddr,
+ OUT PUINT pcbHeaderSize,
+ OUT PSEthernetHeader psEthHeader
+ );
+
+static
+VOID
+s_vProcessRxMACHeader (
+ IN PSDevice pDevice,
+ IN PBYTE pbyRxBufferAddr,
+ IN UINT cbPacketSize,
+ IN BOOL bIsWEP,
+ IN BOOL bExtIV,
+ OUT PUINT pcbHeadSize
+ );
+
+static BOOL s_bAPModeRxCtl(
+ IN PSDevice pDevice,
+ IN PBYTE pbyFrame,
+ IN INT iSANodeIndex
+ );
+
+#ifdef PRIVATE_OBJ
+
+static BOOL s_bAPModeRxData (
+ IN PSDevice pDevice,
+ IN ref_sk_buff* skb,
+ IN UINT FrameSize,
+ IN UINT cbHeaderOffset,
+ IN INT iSANodeIndex,
+ IN INT iDANodeIndex
+ );
+#else
+
+static BOOL s_bAPModeRxData (
+ IN PSDevice pDevice,
+ IN struct sk_buff* skb,
+ IN UINT FrameSize,
+ IN UINT cbHeaderOffset,
+ IN INT iSANodeIndex,
+ IN INT iDANodeIndex
+ );
+#endif
+
+
+static BOOL s_bHandleRxEncryption(
+ IN PSDevice pDevice,
+ IN PBYTE pbyFrame,
+ IN UINT FrameSize,
+ IN PBYTE pbyRsr,
+ OUT PBYTE pbyNewRsr,
+ OUT PSKeyItem *pKeyOut,
+ OUT PBOOL pbExtIV,
+ OUT PWORD pwRxTSC15_0,
+ OUT PDWORD pdwRxTSC47_16
+ );
+
+static BOOL s_bHostWepRxEncryption(
+
+ IN PSDevice pDevice,
+ IN PBYTE pbyFrame,
+ IN UINT FrameSize,
+ IN PBYTE pbyRsr,
+ IN BOOL bOnFly,
+ IN PSKeyItem pKey,
+ OUT PBYTE pbyNewRsr,
+ OUT PBOOL pbExtIV,
+ OUT PWORD pwRxTSC15_0,
+ OUT PDWORD pdwRxTSC47_16
+
+ );
+
+/*--------------------- Export Variables --------------------------*/
+
+/*+
+ *
+ * Description:
+ * Translate Rcv 802.11 header to 802.3 header with Rx buffer
+ *
+ * Parameters:
+ * In:
+ * pDevice
+ * dwRxBufferAddr - Address of Rcv Buffer
+ * cbPacketSize - Rcv Packet size
+ * bIsWEP - If Rcv with WEP
+ * Out:
+ * pcbHeaderSize - 802.11 header size
+ *
+ * Return Value: None
+ *
+-*/
+static
+VOID
+s_vProcessRxMACHeader (
+ IN PSDevice pDevice,
+ IN PBYTE pbyRxBufferAddr,
+ IN UINT cbPacketSize,
+ IN BOOL bIsWEP,
+ IN BOOL bExtIV,
+ OUT PUINT pcbHeadSize
+ )
+{
+ PBYTE pbyRxBuffer;
+ UINT cbHeaderSize = 0;
+ PWORD pwType;
+ PS802_11Header pMACHeader;
+ int ii;
+
+
+ pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
+
+ s_vGetDASA((PBYTE)pMACHeader, &cbHeaderSize, &pDevice->sRxEthHeader);
+
+ if (bIsWEP) {
+ if (bExtIV) {
+ // strip IV&ExtIV , add 8 byte
+ cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 8);
+ } else {
+ // strip IV , add 4 byte
+ cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 4);
+ }
+ }
+ else {
+ cbHeaderSize += WLAN_HDR_ADDR3_LEN;
+ };
+
+ pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize);
+ if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) {
+ cbHeaderSize += 6;
+ }
+ else if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) {
+ cbHeaderSize += 6;
+ pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
+ if ((*pwType!= TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) {
+ }
+ else {
+ cbHeaderSize -= 8;
+ pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
+ if (bIsWEP) {
+ if (bExtIV) {
+ *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV
+ } else {
+ *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV
+ }
+ }
+ else {
+ *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN);
+ }
+ }
+ }
+ else {
+ cbHeaderSize -= 2;
+ pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
+ if (bIsWEP) {
+ if (bExtIV) {
+ *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV
+ } else {
+ *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV
+ }
+ }
+ else {
+ *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN);
+ }
+ }
+
+ cbHeaderSize -= (U_ETHER_ADDR_LEN * 2);
+ pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize);
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++)
+ *pbyRxBuffer++ = pDevice->sRxEthHeader.abyDstAddr[ii];
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++)
+ *pbyRxBuffer++ = pDevice->sRxEthHeader.abySrcAddr[ii];
+
+ *pcbHeadSize = cbHeaderSize;
+}
+
+
+
+
+static BYTE s_byGetRateIdx (IN BYTE byRate)
+{
+ BYTE byRateIdx;
+
+ for (byRateIdx = 0; byRateIdx <MAX_RATE ; byRateIdx++) {
+ if (acbyRxRate[byRateIdx%MAX_RATE] == byRate)
+ return byRateIdx;
+ }
+ return 0;
+}
+
+
+static
+VOID
+s_vGetDASA (
+ IN PBYTE pbyRxBufferAddr,
+ OUT PUINT pcbHeaderSize,
+ OUT PSEthernetHeader psEthHeader
+ )
+{
+ UINT cbHeaderSize = 0;
+ PS802_11Header pMACHeader;
+ int ii;
+
+ pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
+
+ if ((pMACHeader->wFrameCtl & FC_TODS) == 0) {
+ if (pMACHeader->wFrameCtl & FC_FROMDS) {
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
+ psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
+ psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii];
+ }
+ }
+ else {
+ // IBSS mode
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
+ psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
+ psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
+ }
+ }
+ }
+ else {
+ // Is AP mode..
+ if (pMACHeader->wFrameCtl & FC_FROMDS) {
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
+ psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
+ psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr4[ii];
+ cbHeaderSize += 6;
+ }
+ }
+ else {
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
+ psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
+ psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
+ }
+ }
+ };
+ *pcbHeaderSize = cbHeaderSize;
+}
+
+
+
+
+//PLICE_DEBUG ->
+
+VOID MngWorkItem(PVOID Context)
+{
+ PSRxMgmtPacket pRxMgmtPacket;
+ PSDevice pDevice = (PSDevice) Context;
+ //printk("Enter MngWorkItem,Queue packet num is %d\n",pDevice->rxManeQueue.packet_num);
+ spin_lock_irq(&pDevice->lock);
+ while(pDevice->rxManeQueue.packet_num != 0)
+ {
+ pRxMgmtPacket = DeQueue(pDevice);
+ vMgrRxManagePacket(pDevice, pDevice->pMgmt, pRxMgmtPacket);
+ }
+ spin_unlock_irq(&pDevice->lock);
+}
+
+
+//PLICE_DEBUG<-
+
+
+
+BOOL
+device_receive_frame (
+ IN PSDevice pDevice,
+ IN PSRxDesc pCurrRD
+ )
+{
+
+ PDEVICE_RD_INFO pRDInfo = pCurrRD->pRDInfo;
+#ifdef PLICE_DEBUG
+ //printk("device_receive_frame:pCurrRD is %x,pRDInfo is %x\n",pCurrRD,pCurrRD->pRDInfo);
+#endif
+ struct net_device_stats* pStats=&pDevice->stats;
+#ifdef PRIVATE_OBJ
+ ref_sk_buff* skb;
+#else
+ struct sk_buff* skb;
+#endif
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSRxMgmtPacket pRxPacket = &(pDevice->pMgmt->sRxPacket);
+ PS802_11Header p802_11Header;
+ PBYTE pbyRsr;
+ PBYTE pbyNewRsr;
+ PBYTE pbyRSSI;
+ PQWORD pqwTSFTime;
+ PWORD pwFrameSize;
+ PBYTE pbyFrame;
+ BOOL bDeFragRx = FALSE;
+ BOOL bIsWEP = FALSE;
+ UINT cbHeaderOffset;
+ UINT FrameSize;
+ WORD wEtherType = 0;
+ INT iSANodeIndex = -1;
+ INT iDANodeIndex = -1;
+ UINT ii;
+ UINT cbIVOffset;
+ BOOL bExtIV = FALSE;
+ PBYTE pbyRxSts;
+ PBYTE pbyRxRate;
+ PBYTE pbySQ;
+ UINT cbHeaderSize;
+ PSKeyItem pKey = NULL;
+ WORD wRxTSC15_0 = 0;
+ DWORD dwRxTSC47_16 = 0;
+ SKeyItem STempKey;
+ // 802.11h RPI
+ DWORD dwDuration = 0;
+ LONG ldBm = 0;
+ LONG ldBmThreshold = 0;
+ PS802_11Header pMACHeader;
+ BOOL bRxeapol_key = FALSE;
+
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- device_receive_frame---\n");
+#ifdef PRIVATE_OBJ
+ skb = &(pRDInfo->ref_skb);
+#else
+
+ skb = pRDInfo->skb;
+#endif
+
+
+//PLICE_DEBUG->
+#if 1
+ pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma,
+ pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+#endif
+//PLICE_DEBUG<-
+ pwFrameSize = (PWORD)(skb->data + 2);
+ FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount);
+
+ // Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
+ // Min (ACK): 10HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
+ if ((FrameSize > 2364)||(FrameSize <= 32)) {
+ // Frame Size error drop this packet.
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 1 \n");
+ return FALSE;
+ }
+
+ pbyRxSts = (PBYTE) (skb->data);
+ pbyRxRate = (PBYTE) (skb->data + 1);
+ pbyRsr = (PBYTE) (skb->data + FrameSize - 1);
+ pbyRSSI = (PBYTE) (skb->data + FrameSize - 2);
+ pbyNewRsr = (PBYTE) (skb->data + FrameSize - 3);
+ pbySQ = (PBYTE) (skb->data + FrameSize - 4);
+ pqwTSFTime = (PQWORD) (skb->data + FrameSize - 12);
+ pbyFrame = (PBYTE)(skb->data + 4);
+
+ // get packet size
+ FrameSize = cpu_to_le16(*pwFrameSize);
+
+ if ((FrameSize > 2346)|(FrameSize < 14)) { // Max: 2312Payload + 30HD +4CRC
+ // Min: 14 bytes ACK
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 2 \n");
+ return FALSE;
+ }
+//PLICE_DEBUG->
+#if 1
+ // update receive statistic counter
+ STAvUpdateRDStatCounter(&pDevice->scStatistic,
+ *pbyRsr,
+ *pbyNewRsr,
+ *pbyRxRate,
+ pbyFrame,
+ FrameSize);
+
+#endif
+
+ pMACHeader=(PS802_11Header)((PBYTE) (skb->data)+8);
+//PLICE_DEBUG<-
+ if (pDevice->bMeasureInProgress == TRUE) {
+ if ((*pbyRsr & RSR_CRCOK) != 0) {
+ pDevice->byBasicMap |= 0x01;
+ }
+ dwDuration = (FrameSize << 4);
+ dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE];
+ if (*pbyRxRate <= RATE_11M) {
+ if (BITbIsBitOn(*pbyRxSts, 0x01)) {
+ // long preamble
+ dwDuration += 192;
+ } else {
+ // short preamble
+ dwDuration += 96;
+ }
+ } else {
+ dwDuration += 16;
+ }
+ RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm);
+ ldBmThreshold = -57;
+ for (ii = 7; ii > 0;) {
+ if (ldBm > ldBmThreshold) {
+ break;
+ }
+ ldBmThreshold -= 5;
+ ii--;
+ }
+ pDevice->dwRPIs[ii] += dwDuration;
+ return FALSE;
+ }
+
+ if (!IS_MULTICAST_ADDRESS(pbyFrame) && !IS_BROADCAST_ADDRESS(pbyFrame)) {
+ if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) (skb->data + 4))) {
+ pDevice->s802_11Counter.FrameDuplicateCount++;
+ return FALSE;
+ }
+ }
+
+
+ // Use for TKIP MIC
+ s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader);
+
+ // filter packet send from myself
+ if (IS_ETH_ADDRESS_EQUAL((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr))
+ return FALSE;
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
+ if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
+ p802_11Header = (PS802_11Header) (pbyFrame);
+ // get SA NodeIndex
+ if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(p802_11Header->abyAddr2), &iSANodeIndex)) {
+#ifdef PRIVATE_OBJ
+ pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = get_jiffies();
+#else
+ pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies;
+#endif
+ pMgmt->sNodeDBTable[iSANodeIndex].uInActiveCount = 0;
+ }
+ }
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) == TRUE) {
+ return FALSE;
+ }
+ }
+ if (IS_FC_WEP(pbyFrame)) {
+ BOOL bRxDecryOK = FALSE;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rx WEP pkt\n");
+ bIsWEP = TRUE;
+ if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) {
+ pKey = &STempKey;
+ pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite;
+ pKey->dwKeyIndex = pMgmt->sNodeDBTable[iSANodeIndex].dwKeyIndex;
+ pKey->uKeyLength = pMgmt->sNodeDBTable[iSANodeIndex].uWepKeyLength;
+ pKey->dwTSC47_16 = pMgmt->sNodeDBTable[iSANodeIndex].dwTSC47_16;
+ pKey->wTSC15_0 = pMgmt->sNodeDBTable[iSANodeIndex].wTSC15_0;
+ memcpy(pKey->abyKey,
+ &pMgmt->sNodeDBTable[iSANodeIndex].abyWepKey[0],
+ pKey->uKeyLength
+ );
+
+ bRxDecryOK = s_bHostWepRxEncryption(pDevice,
+ pbyFrame,
+ FrameSize,
+ pbyRsr,
+ pMgmt->sNodeDBTable[iSANodeIndex].bOnFly,
+ pKey,
+ pbyNewRsr,
+ &bExtIV,
+ &wRxTSC15_0,
+ &dwRxTSC47_16);
+ } else {
+ bRxDecryOK = s_bHandleRxEncryption(pDevice,
+ pbyFrame,
+ FrameSize,
+ pbyRsr,
+ pbyNewRsr,
+ &pKey,
+ &bExtIV,
+ &wRxTSC15_0,
+ &dwRxTSC47_16);
+ }
+
+ if (bRxDecryOK) {
+ if ((*pbyNewRsr & NEWRSR_DECRYPTOK) == 0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV Fail\n");
+ if ( (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
+ (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
+ (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) ||
+ (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
+ (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
+
+ if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
+ pDevice->s802_11Counter.TKIPICVErrors++;
+ } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) {
+ pDevice->s802_11Counter.CCMPDecryptErrors++;
+ } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_WEP)) {
+// pDevice->s802_11Counter.WEPICVErrorCount.QuadPart++;
+ }
+ }
+ return FALSE;
+ }
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WEP Func Fail\n");
+ return FALSE;
+ }
+ if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP))
+ FrameSize -= 8; // Message Integrity Code
+ else
+ FrameSize -= 4; // 4 is ICV
+ }
+
+
+ //
+ // RX OK
+ //
+ //remove the CRC length
+ FrameSize -= U_CRC_LEN;
+
+ if ((BITbIsAllBitsOff(*pbyRsr, (RSR_ADDRBROAD | RSR_ADDRMULTI))) && // unicast address
+ (IS_FRAGMENT_PKT((skb->data+4)))
+ ) {
+ // defragment
+ bDeFragRx = WCTLbHandleFragment(pDevice, (PS802_11Header) (skb->data+4), FrameSize, bIsWEP, bExtIV);
+ pDevice->s802_11Counter.ReceivedFragmentCount++;
+ if (bDeFragRx) {
+ // defrag complete
+#ifdef PRIVATE_OBJ
+ skb = &(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].ref_skb);
+#else
+ skb = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb;
+#endif
+ FrameSize = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength;
+
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+
+// Management & Control frame Handle
+ if ((IS_TYPE_DATA((skb->data+4))) == FALSE) {
+ // Handle Control & Manage Frame
+
+ if (IS_TYPE_MGMT((skb->data+4))) {
+ PBYTE pbyData1;
+ PBYTE pbyData2;
+
+ pRxPacket->p80211Header = (PUWLAN_80211HDR)(skb->data+4);
+ pRxPacket->cbMPDULen = FrameSize;
+ pRxPacket->uRSSI = *pbyRSSI;
+ pRxPacket->bySQ = *pbySQ;
+ HIDWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(HIDWORD(*pqwTSFTime));
+ LODWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(LODWORD(*pqwTSFTime));
+ if (bIsWEP) {
+ // strip IV
+ pbyData1 = WLAN_HDR_A3_DATA_PTR(skb->data+4);
+ pbyData2 = WLAN_HDR_A3_DATA_PTR(skb->data+4) + 4;
+ for (ii = 0; ii < (FrameSize - 4); ii++) {
+ *pbyData1 = *pbyData2;
+ pbyData1++;
+ pbyData2++;
+ }
+ }
+ pRxPacket->byRxRate = s_byGetRateIdx(*pbyRxRate);
+ pRxPacket->byRxChannel = (*pbyRxSts) >> 2;
+//PLICE_DEBUG->
+//EnQueue(pDevice,pRxPacket);
+
+#ifdef THREAD
+ EnQueue(pDevice,pRxPacket);
+
+ //printk("enque time is %x\n",jiffies);
+ //up(&pDevice->mlme_semaphore);
+ //Enque (pDevice->FirstRecvMngList,pDevice->LastRecvMngList,pMgmt);
+#else
+
+#ifdef TASK_LET
+ EnQueue(pDevice,pRxPacket);
+ tasklet_schedule(&pDevice->RxMngWorkItem);
+#else
+//printk("RxMan\n");
+ vMgrRxManagePacket((HANDLE)pDevice, pDevice->pMgmt, pRxPacket);
+ //tasklet_schedule(&pDevice->RxMngWorkItem);
+#endif
+
+#endif
+//PLICE_DEBUG<-
+ //vMgrRxManagePacket((HANDLE)pDevice, pDevice->pMgmt, pRxPacket);
+ // hostap Deamon handle 802.11 management
+ if (pDevice->bEnableHostapd) {
+ skb->dev = pDevice->apdev;
+#ifdef PRIVATE_OBJ
+ ref_skb_add_offset(skb->skb, 4);
+ ref_skb_set_dev(pDevice->apdev, skb->skb);
+ skb_put(skb->skb, FrameSize);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ skb->mac_header = skb->data;
+#else
+ skb->mac.raw = skb->data;
+#endif
+ *(skb->pkt_type) = PACKET_OTHERHOST;
+ *(skb->protocol) = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb->skb);
+#else
+ skb->data += 4;
+ skb->tail += 4;
+ skb_put(skb, FrameSize);
+#if LINUX_VERSION_CODE > KERNEL_VERSION (2,6,21)
+ skb->mac_header = skb->data;
+#else
+ skb->mac.raw = skb->data;
+#endif
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb);
+#endif
+ return TRUE;
+ }
+ }
+ else {
+ // Control Frame
+ };
+ return FALSE;
+ }
+ else {
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ //In AP mode, hw only check addr1(BSSID or RA) if equal to local MAC.
+ if (BITbIsBitOff(*pbyRsr, RSR_BSSIDOK)) {
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+ }
+ else {
+ // discard DATA packet while not associate || BSSID error
+ if ((pDevice->bLinkPass == FALSE) ||
+ BITbIsBitOff(*pbyRsr, RSR_BSSIDOK)) {
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+
+ //mike add:station mode check eapol-key challenge--->
+ {
+ BYTE Protocol_Version; //802.1x Authentication
+ BYTE Packet_Type; //802.1x Authentication
+ if (bIsWEP)
+ cbIVOffset = 8;
+ else
+ cbIVOffset = 0;
+ wEtherType = (skb->data[cbIVOffset + 8 + 24 + 6] << 8) |
+ skb->data[cbIVOffset + 8 + 24 + 6 + 1];
+ Protocol_Version = skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1];
+ Packet_Type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1];
+ if (wEtherType == ETH_P_PAE) { //Protocol Type in LLC-Header
+ if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
+ (Packet_Type==3)) { //802.1x OR eapol-key challenge frame receive
+ bRxeapol_key = TRUE;
+ }
+ }
+ }
+ //mike add:station mode check eapol-key challenge<---
+ }
+ }
+
+// Data frame Handle
+
+ if (pDevice->bEnablePSMode) {
+ if (IS_FC_MOREDATA((skb->data+4))) {
+ if (BITbIsBitOn(*pbyRsr, RSR_ADDROK)) {
+ //PSbSendPSPOLL((PSDevice)pDevice);
+ }
+ }
+ else {
+ if (pDevice->pMgmt->bInTIMWake == TRUE) {
+ pDevice->pMgmt->bInTIMWake = FALSE;
+ }
+ }
+ };
+
+ // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps
+ if (pDevice->bDiversityEnable && (FrameSize>50) &&
+ (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) &&
+ (pDevice->bLinkPass == TRUE)) {
+ //printk("device_receive_frame: RxRate is %d\n",*pbyRxRate);
+ BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0);
+ }
+
+
+ if (pDevice->byLocalID != REV_ID_VT3253_B1) {
+ pDevice->uCurrRSSI = *pbyRSSI;
+ }
+ pDevice->byCurrSQ = *pbySQ;
+
+ if ((*pbyRSSI != 0) &&
+ (pMgmt->pCurrBSS!=NULL)) {
+ RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm);
+ // Moniter if RSSI is too strong.
+ pMgmt->pCurrBSS->byRSSIStatCnt++;
+ pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT;
+ pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm;
+ for(ii=0;ii<RSSI_STAT_COUNT;ii++) {
+ if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0) {
+ pMgmt->pCurrBSS->ldBmMAX = max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm);
+ }
+ }
+ }
+
+ // -----------------------------------------------
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnable8021x == TRUE)){
+ BYTE abyMacHdr[24];
+
+ // Only 802.1x packet incoming allowed
+ if (bIsWEP)
+ cbIVOffset = 8;
+ else
+ cbIVOffset = 0;
+ wEtherType = (skb->data[cbIVOffset + 4 + 24 + 6] << 8) |
+ skb->data[cbIVOffset + 4 + 24 + 6 + 1];
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wEtherType = %04x \n", wEtherType);
+ if (wEtherType == ETH_P_PAE) {
+ skb->dev = pDevice->apdev;
+
+ if (bIsWEP == TRUE) {
+ // strip IV header(8)
+ memcpy(&abyMacHdr[0], (skb->data + 4), 24);
+ memcpy((skb->data + 4 + cbIVOffset), &abyMacHdr[0], 24);
+ }
+#ifdef PRIVATE_OBJ
+ ref_skb_add_offset(skb->skb, (cbIVOffset + 4));
+ ref_skb_set_dev(pDevice->apdev, skb->skb);
+ skb_put(skb->skb, FrameSize);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ skb->mac_header = skb->data;
+#else
+ skb->mac.raw = skb->data;
+#endif
+ *(skb->pkt_type) = PACKET_OTHERHOST;
+ *(skb->protocol) = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb->skb);
+#else
+ skb->data += (cbIVOffset + 4);
+ skb->tail += (cbIVOffset + 4);
+ skb_put(skb, FrameSize);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ skb->mac_header = skb->data;
+#else
+ skb->mac.raw = skb->data;
+#endif
+
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb);
+#endif
+ return TRUE;
+
+}
+ // check if 802.1x authorized
+ if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED))
+ return FALSE;
+ }
+
+
+ if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
+ if (bIsWEP) {
+ FrameSize -= 8; //MIC
+ }
+ }
+
+ //--------------------------------------------------------------------------------
+ // Soft MIC
+ if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
+ if (bIsWEP) {
+ PDWORD pdwMIC_L;
+ PDWORD pdwMIC_R;
+ DWORD dwMIC_Priority;
+ DWORD dwMICKey0 = 0, dwMICKey1 = 0;
+ DWORD dwLocalMIC_L = 0;
+ DWORD dwLocalMIC_R = 0;
+ viawget_wpa_header *wpahdr;
+
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[24]));
+ dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[28]));
+ }
+ else {
+ if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+ dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[16]));
+ dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[20]));
+ } else if ((pKey->dwKeyIndex & BIT28) == 0) {
+ dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[16]));
+ dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[20]));
+ } else {
+ dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[24]));
+ dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[28]));
+ }
+ }
+
+ MIC_vInit(dwMICKey0, dwMICKey1);
+ MIC_vAppend((PBYTE)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12);
+ dwMIC_Priority = 0;
+ MIC_vAppend((PBYTE)&dwMIC_Priority, 4);
+ // 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV.
+ MIC_vAppend((PBYTE)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8),
+ FrameSize - WLAN_HDR_ADDR3_LEN - 8);
+ MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R);
+ MIC_vUnInit();
+
+ pdwMIC_L = (PDWORD)(skb->data + 4 + FrameSize);
+ pdwMIC_R = (PDWORD)(skb->data + 4 + FrameSize + 4);
+ //DBG_PRN_GRP12(("RxL: %lx, RxR: %lx\n", *pdwMIC_L, *pdwMIC_R));
+ //DBG_PRN_GRP12(("LocalL: %lx, LocalR: %lx\n", dwLocalMIC_L, dwLocalMIC_R));
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwMICKey0= %lx,dwMICKey1= %lx \n", dwMICKey0, dwMICKey1);
+
+
+ if ((cpu_to_le32(*pdwMIC_L) != dwLocalMIC_L) || (cpu_to_le32(*pdwMIC_R) != dwLocalMIC_R) ||
+ (pDevice->bRxMICFail == TRUE)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC comparison is fail!\n");
+ pDevice->bRxMICFail = FALSE;
+ //pDevice->s802_11Counter.TKIPLocalMICFailures.QuadPart++;
+ pDevice->s802_11Counter.TKIPLocalMICFailures++;
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+
+//2008-0409-07, <Add> by Einsn Liu
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //send event to wpa_supplicant
+ //if(pDevice->bWPADevEnable == TRUE)
+ {
+ union iwreq_data wrqu;
+ struct iw_michaelmicfailure ev;
+ int keyidx = pbyFrame[cbHeaderSize+3] >> 6; //top two-bits
+ memset(&ev, 0, sizeof(ev));
+ ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
+ (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) {
+ ev.flags |= IW_MICFAILURE_PAIRWISE;
+ } else {
+ ev.flags |= IW_MICFAILURE_GROUP;
+ }
+
+ ev.src_addr.sa_family = ARPHRD_ETHER;
+ memcpy(ev.src_addr.sa_data, pMACHeader->abyAddr2, ETH_ALEN);
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = sizeof(ev);
+ wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev);
+
+ }
+ #endif
+ if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
+ (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) {
+ //s802_11_Status.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
+ wpahdr->type = VIAWGET_PTK_MIC_MSG;
+ } else {
+ //s802_11_Status.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR;
+ wpahdr->type = VIAWGET_GTK_MIC_MSG;
+ }
+ wpahdr->resp_ie_len = 0;
+ wpahdr->req_ie_len = 0;
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header));
+ pDevice->skb->dev = pDevice->wpadev;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ pDevice->skb->mac_header = pDevice->skb->data;
+#else
+ pDevice->skb->mac.raw=pDevice->skb->data;
+#endif
+ pDevice->skb->pkt_type = PACKET_HOST;
+ pDevice->skb->protocol = htons(ETH_P_802_2);
+ memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
+ netif_rx(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ };
+
+ return FALSE;
+
+ }
+ }
+ } //---end of SOFT MIC-----------------------------------------------------------------------
+
+ // ++++++++++ Reply Counter Check +++++++++++++
+
+ if ((pKey != NULL) && ((pKey->byCipherSuite == KEY_CTL_TKIP) ||
+ (pKey->byCipherSuite == KEY_CTL_CCMP))) {
+ if (bIsWEP) {
+ WORD wLocalTSC15_0 = 0;
+ DWORD dwLocalTSC47_16 = 0;
+ ULONGLONG RSC = 0;
+ // endian issues
+ RSC = *((ULONGLONG *) &(pKey->KeyRSC));
+ wLocalTSC15_0 = (WORD) RSC;
+ dwLocalTSC47_16 = (DWORD) (RSC>>16);
+
+ RSC = dwRxTSC47_16;
+ RSC <<= 16;
+ RSC += wRxTSC15_0;
+ MEMvCopy(&(pKey->KeyRSC), &RSC, sizeof(QWORD));
+
+ if ( (pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) {
+ // check RSC
+ if ( (wRxTSC15_0 < wLocalTSC15_0) &&
+ (dwRxTSC47_16 <= dwLocalTSC47_16) &&
+ !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC is illegal~~!\n ");
+ if (pKey->byCipherSuite == KEY_CTL_TKIP)
+ //pDevice->s802_11Counter.TKIPReplays.QuadPart++;
+ pDevice->s802_11Counter.TKIPReplays++;
+ else
+ //pDevice->s802_11Counter.CCMPReplays.QuadPart++;
+ pDevice->s802_11Counter.CCMPReplays++;
+
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+ }
+ }
+ } // ----- End of Reply Counter Check --------------------------
+
+
+
+ if ((pKey != NULL) && (bIsWEP)) {
+// pDevice->s802_11Counter.DecryptSuccessCount.QuadPart++;
+ }
+
+
+ s_vProcessRxMACHeader(pDevice, (PBYTE)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset);
+ FrameSize -= cbHeaderOffset;
+ cbHeaderOffset += 4; // 4 is Rcv buffer header
+
+ // Null data, framesize = 14
+ if (FrameSize < 15)
+ return FALSE;
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (s_bAPModeRxData(pDevice,
+ skb,
+ FrameSize,
+ cbHeaderOffset,
+ iSANodeIndex,
+ iDANodeIndex
+ ) == FALSE) {
+
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+
+// if(pDevice->bRxMICFail == FALSE) {
+// for (ii =0; ii < 100; ii++)
+// printk(" %02x", *(skb->data + ii));
+// printk("\n");
+// }
+
+ }
+
+#ifdef PRIVATE_OBJ
+ ref_skb_add_offset(skb->skb, cbHeaderOffset);
+ skb_put(skb->skb, FrameSize);
+ *(skb->protocol)=eth_type_trans(skb->skb, skb->dev);
+
+#else
+ skb->data += cbHeaderOffset;
+ skb->tail += cbHeaderOffset;
+ skb_put(skb, FrameSize);
+ skb->protocol=eth_type_trans(skb, skb->dev);
+#endif
+
+
+ //drop frame not met IEEE 802.3
+/*
+ if (pDevice->flags & DEVICE_FLAGS_VAL_PKT_LEN) {
+#ifdef PRIVATE_OBJ
+ if ((*(skb->protocol)==htons(ETH_P_802_3)) &&
+ (*(skb->len)!=htons(skb->mac.ethernet->h_proto))) {
+#else
+ if ((skb->protocol==htons(ETH_P_802_3)) &&
+ (skb->len!=htons(skb->mac.ethernet->h_proto))) {
+#endif
+ pStats->rx_length_errors++;
+ pStats->rx_dropped++;
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+ }
+*/
+
+#ifdef PRIVATE_OBJ
+ *(skb->ip_summed)=CHECKSUM_NONE;
+ pStats->rx_bytes +=*(skb->len);
+ pStats->rx_packets++;
+ netif_rx(skb->skb);
+#else
+ skb->ip_summed=CHECKSUM_NONE;
+ pStats->rx_bytes +=skb->len;
+ pStats->rx_packets++;
+ netif_rx(skb);
+#endif
+
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+static BOOL s_bAPModeRxCtl (
+ IN PSDevice pDevice,
+ IN PBYTE pbyFrame,
+ IN INT iSANodeIndex
+ )
+{
+ PS802_11Header p802_11Header;
+ CMD_STATUS Status;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+
+ if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
+
+ p802_11Header = (PS802_11Header) (pbyFrame);
+ if (!IS_TYPE_MGMT(pbyFrame)) {
+
+ // Data & PS-Poll packet
+ // check frame class
+ if (iSANodeIndex > 0) {
+ // frame class 3 fliter & checking
+ if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ (PBYTE)(p802_11Header->abyAddr2),
+ (WLAN_MGMT_REASON_CLASS2_NONAUTH),
+ &Status
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n");
+ return TRUE;
+ };
+ if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) {
+ // send deassoc notification
+ // reason = (7) class 3 received from nonassoc sta
+ vMgrDisassocBeginSta(pDevice,
+ pMgmt,
+ (PBYTE)(p802_11Header->abyAddr2),
+ (WLAN_MGMT_REASON_CLASS3_NONASSOC),
+ &Status
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n");
+ return TRUE;
+ };
+
+ if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) {
+ // delcare received ps-poll event
+ if (IS_CTL_PSPOLL(pbyFrame)) {
+ pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE;
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 1\n");
+ }
+ else {
+ // check Data PS state
+ // if PW bit off, send out all PS bufferring packets.
+ if (!IS_FC_POWERMGT(pbyFrame)) {
+ pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = FALSE;
+ pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE;
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 2\n");
+ }
+ }
+ }
+ else {
+ if (IS_FC_POWERMGT(pbyFrame)) {
+ pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = TRUE;
+ // Once if STA in PS state, enable multicast bufferring
+ pMgmt->sNodeDBTable[0].bPSEnable = TRUE;
+ }
+ else {
+ // clear all pending PS frame.
+ if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) {
+ pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = FALSE;
+ pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE;
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 3\n");
+
+ }
+ }
+ }
+ }
+ else {
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ (PBYTE)(p802_11Header->abyAddr2),
+ (WLAN_MGMT_REASON_CLASS2_NONAUTH),
+ &Status
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%02x-%02x-%02x=%02x-%02x-%02x \n",
+ p802_11Header->abyAddr3[0],
+ p802_11Header->abyAddr3[1],
+ p802_11Header->abyAddr3[2],
+ p802_11Header->abyAddr3[3],
+ p802_11Header->abyAddr3[4],
+ p802_11Header->abyAddr3[5]
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%02x-%02x-%02x=%02x-%02x-%02x \n",
+ p802_11Header->abyAddr2[0],
+ p802_11Header->abyAddr2[1],
+ p802_11Header->abyAddr2[2],
+ p802_11Header->abyAddr2[3],
+ p802_11Header->abyAddr2[4],
+ p802_11Header->abyAddr2[5]
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%02x-%02x-%02x=%02x-%02x-%02x \n",
+ p802_11Header->abyAddr1[0],
+ p802_11Header->abyAddr1[1],
+ p802_11Header->abyAddr1[2],
+ p802_11Header->abyAddr1[3],
+ p802_11Header->abyAddr1[4],
+ p802_11Header->abyAddr1[5]
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: wFrameCtl= %x\n", p802_11Header->wFrameCtl );
+ VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc:pDevice->byRxMode = %x\n", pDevice->byRxMode );
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+
+}
+
+static BOOL s_bHandleRxEncryption (
+ IN PSDevice pDevice,
+ IN PBYTE pbyFrame,
+ IN UINT FrameSize,
+ IN PBYTE pbyRsr,
+ OUT PBYTE pbyNewRsr,
+ OUT PSKeyItem *pKeyOut,
+ OUT PBOOL pbExtIV,
+ OUT PWORD pwRxTSC15_0,
+ OUT PDWORD pdwRxTSC47_16
+ )
+{
+ UINT PayloadLen = FrameSize;
+ PBYTE pbyIV;
+ BYTE byKeyIdx;
+ PSKeyItem pKey = NULL;
+ BYTE byDecMode = KEY_CTL_WEP;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+
+ *pwRxTSC15_0 = 0;
+ *pdwRxTSC47_16 = 0;
+
+ pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
+ if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
+ WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) {
+ pbyIV += 6; // 6 is 802.11 address4
+ PayloadLen -= 6;
+ }
+ byKeyIdx = (*(pbyIV+3) & 0xc0);
+ byKeyIdx >>= 6;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx);
+
+ if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
+ if (((*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) &&
+ (pDevice->pMgmt->byCSSPK != KEY_CTL_NONE)) {
+ // unicast pkt use pairwise key
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"unicast pkt\n");
+ if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == TRUE) {
+ if (pDevice->pMgmt->byCSSPK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pDevice->pMgmt->byCSSPK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"unicast pkt: %d, %p\n", byDecMode, pKey);
+ } else {
+ // use group key
+ KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, byKeyIdx, &pKey);
+ if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"group pkt: %d, %d, %p\n", byKeyIdx, byDecMode, pKey);
+ }
+ }
+ // our WEP only support Default Key
+ if (pKey == NULL) {
+ // use default group key
+ KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, byKeyIdx, &pKey);
+ if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+ }
+ *pKeyOut = pKey;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode);
+
+ if (pKey == NULL) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey == NULL\n");
+ if (byDecMode == KEY_CTL_WEP) {
+// pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++;
+ } else if (pDevice->bLinkPass == TRUE) {
+// pDevice->s802_11Counter.DecryptFailureCount.QuadPart++;
+ }
+ return FALSE;
+ }
+ if (byDecMode != pKey->byCipherSuite) {
+ if (byDecMode == KEY_CTL_WEP) {
+// pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++;
+ } else if (pDevice->bLinkPass == TRUE) {
+// pDevice->s802_11Counter.DecryptFailureCount.QuadPart++;
+ }
+ *pKeyOut = NULL;
+ return FALSE;
+ }
+ if (byDecMode == KEY_CTL_WEP) {
+ // handle WEP
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
+ (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == TRUE)) {
+ // Software WEP
+ // 1. 3253A
+ // 2. WEP 256
+
+ PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc
+ MEMvCopy(pDevice->abyPRNG, pbyIV, 3);
+ MEMvCopy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength);
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3);
+ rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen);
+
+ if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) {
+ *pbyNewRsr |= NEWRSR_DECRYPTOK;
+ }
+ }
+ } else if ((byDecMode == KEY_CTL_TKIP) ||
+ (byDecMode == KEY_CTL_CCMP)) {
+ // TKIP/AES
+
+ PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
+ *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16);
+ if (byDecMode == KEY_CTL_TKIP) {
+ *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
+ } else {
+ *pwRxTSC15_0 = cpu_to_le16(*(PWORD)pbyIV);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0);
+
+ if ((byDecMode == KEY_CTL_TKIP) &&
+ (pDevice->byLocalID <= REV_ID_VT3253_A1)) {
+ // Software TKIP
+ // 1. 3253 A
+ PS802_11Header pMACHeader = (PS802_11Header) (pbyFrame);
+ TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG);
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
+ rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen);
+ if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) {
+ *pbyNewRsr |= NEWRSR_DECRYPTOK;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n");
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen);
+ }
+ }
+ }// end of TKIP/AES
+
+ if ((*(pbyIV+3) & 0x20) != 0)
+ *pbExtIV = TRUE;
+ return TRUE;
+}
+
+
+static BOOL s_bHostWepRxEncryption (
+ IN PSDevice pDevice,
+ IN PBYTE pbyFrame,
+ IN UINT FrameSize,
+ IN PBYTE pbyRsr,
+ IN BOOL bOnFly,
+ IN PSKeyItem pKey,
+ OUT PBYTE pbyNewRsr,
+ OUT PBOOL pbExtIV,
+ OUT PWORD pwRxTSC15_0,
+ OUT PDWORD pdwRxTSC47_16
+ )
+{
+ UINT PayloadLen = FrameSize;
+ PBYTE pbyIV;
+ BYTE byKeyIdx;
+ BYTE byDecMode = KEY_CTL_WEP;
+ PS802_11Header pMACHeader;
+
+
+
+ *pwRxTSC15_0 = 0;
+ *pdwRxTSC47_16 = 0;
+
+ pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
+ if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
+ WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) {
+ pbyIV += 6; // 6 is 802.11 address4
+ PayloadLen -= 6;
+ }
+ byKeyIdx = (*(pbyIV+3) & 0xc0);
+ byKeyIdx >>= 6;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx);
+
+
+ if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode);
+
+ if (byDecMode != pKey->byCipherSuite) {
+ if (byDecMode == KEY_CTL_WEP) {
+// pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++;
+ } else if (pDevice->bLinkPass == TRUE) {
+// pDevice->s802_11Counter.DecryptFailureCount.QuadPart++;
+ }
+ return FALSE;
+ }
+
+ if (byDecMode == KEY_CTL_WEP) {
+ // handle WEP
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byDecMode == KEY_CTL_WEP \n");
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
+ (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == TRUE) ||
+ (bOnFly == FALSE)) {
+ // Software WEP
+ // 1. 3253A
+ // 2. WEP 256
+ // 3. NotOnFly
+
+ PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc
+ MEMvCopy(pDevice->abyPRNG, pbyIV, 3);
+ MEMvCopy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength);
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3);
+ rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen);
+
+ if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) {
+ *pbyNewRsr |= NEWRSR_DECRYPTOK;
+ }
+ }
+ } else if ((byDecMode == KEY_CTL_TKIP) ||
+ (byDecMode == KEY_CTL_CCMP)) {
+ // TKIP/AES
+
+ PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
+ *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16);
+
+ if (byDecMode == KEY_CTL_TKIP) {
+ *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
+ } else {
+ *pwRxTSC15_0 = cpu_to_le16(*(PWORD)pbyIV);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0);
+
+ if (byDecMode == KEY_CTL_TKIP) {
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (bOnFly == FALSE)) {
+ // Software TKIP
+ // 1. 3253 A
+ // 2. NotOnFly
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_TKIP \n");
+ pMACHeader = (PS802_11Header) (pbyFrame);
+ TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG);
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
+ rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen);
+ if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) {
+ *pbyNewRsr |= NEWRSR_DECRYPTOK;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n");
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen);
+ }
+ }
+ }
+
+ if (byDecMode == KEY_CTL_CCMP) {
+ if (bOnFly == FALSE) {
+ // Software CCMP
+ // NotOnFly
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_CCMP\n");
+ if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) {
+ *pbyNewRsr |= NEWRSR_DECRYPTOK;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC compare OK!\n");
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC fail!\n");
+ }
+ }
+ }
+
+ }// end of TKIP/AES
+
+ if ((*(pbyIV+3) & 0x20) != 0)
+ *pbExtIV = TRUE;
+ return TRUE;
+}
+
+
+
+
+#ifdef PRIVATE_OBJ
+
+static BOOL s_bAPModeRxData (
+ IN PSDevice pDevice,
+ IN ref_sk_buff* skb,
+ IN UINT FrameSize,
+ IN UINT cbHeaderOffset,
+ IN INT iSANodeIndex,
+ IN INT iDANodeIndex
+ )
+
+#else
+
+static BOOL s_bAPModeRxData (
+ IN PSDevice pDevice,
+ IN struct sk_buff* skb,
+ IN UINT FrameSize,
+ IN UINT cbHeaderOffset,
+ IN INT iSANodeIndex,
+ IN INT iDANodeIndex
+ )
+#endif
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ BOOL bRelayAndForward = FALSE;
+ BOOL bRelayOnly = FALSE;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ WORD wAID;
+#ifdef PRIVATE_OBJ
+ struct sk_buff* tmp_skb;
+ ref_sk_buff s_ref_skb;
+ ref_sk_buff* skbcpy = &s_ref_skb;
+#else
+ struct sk_buff* skbcpy = NULL;
+#endif
+
+
+
+ if (FrameSize > CB_MAX_BUF_SIZE)
+ return FALSE;
+ // check DA
+ if(IS_MULTICAST_ADDRESS((PBYTE)(skb->data+cbHeaderOffset))) {
+ if (pMgmt->sNodeDBTable[0].bPSEnable) {
+
+#ifdef PRIVATE_OBJ
+ tmp_skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ skbcpy = &s_ref_skb;
+ ref_skb_remap(pDevice->dev, skbcpy, tmp_skb);
+#else
+ skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz);
+#endif
+ // if any node in PS mode, buffer packet until DTIM.
+ if (skbcpy == NULL) {
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "relay multicast no skb available \n");
+ }
+ else {
+ skbcpy->dev = pDevice->dev;
+#ifdef PRIVATE_OBJ
+ *(skbcpy->len) = FrameSize;
+ memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize);
+ skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy->skb);
+#else
+ skbcpy->len = FrameSize;
+ memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize);
+ skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy);
+#endif
+ pMgmt->sNodeDBTable[0].wEnQueueCnt++;
+ // set tx map
+ pMgmt->abyPSTxMap[0] |= byMask[0];
+ }
+ }
+ else {
+ bRelayAndForward = TRUE;
+ }
+ }
+ else {
+ // check if relay
+ if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data+cbHeaderOffset), &iDANodeIndex)) {
+ if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) {
+ if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) {
+ // queue this skb until next PS tx, and then release.
+
+#ifdef PRIVATE_OBJ
+ ref_skb_add_offset(skb->skb, cbHeaderOffset);
+ skb_put(skb->skb, FrameSize);
+ skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb->skb);
+#else
+ skb->data += cbHeaderOffset;
+ skb->tail += cbHeaderOffset;
+ skb_put(skb, FrameSize);
+ skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb);
+#endif
+ pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++;
+ wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID;
+ pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7];
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n",
+ iDANodeIndex, (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]);
+ return TRUE;
+ }
+ else {
+ bRelayOnly = TRUE;
+ }
+ }
+ };
+ }
+
+ if (bRelayOnly || bRelayAndForward) {
+ // relay this packet right now
+ if (bRelayAndForward)
+ iDANodeIndex = 0;
+
+ if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) {
+ ROUTEbRelay(pDevice, (PBYTE)(skb->data + cbHeaderOffset), FrameSize, (UINT)iDANodeIndex);
+ }
+
+ if (bRelayOnly)
+ return FALSE;
+ }
+ // none associate, don't forward
+ if (pDevice->uAssocCount == 0)
+ return FALSE;
+
+ return TRUE;
+}
+
diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h
new file mode 100644
index 000000000000..68447c44dc2f
--- /dev/null
+++ b/drivers/staging/vt6655/dpc.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: whdr.h
+ *
+ * Purpose:
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jun. 27, 2002
+ *
+ */
+
+
+#ifndef __DPC_H__
+#define __DPC_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+BOOL
+device_receive_frame (
+ IN PSDevice pDevice,
+ IN PSRxDesc pCurrRD
+ );
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+VOID MngWorkItem(PVOID Context);
+#endif // __RXTX_H__
+
+
+
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
new file mode 100644
index 000000000000..134de869cb80
--- /dev/null
+++ b/drivers/staging/vt6655/hostap.c
@@ -0,0 +1,907 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: hostap.c
+ *
+ * Purpose: handle hostap deamon ioctl input/out functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Oct. 20, 2003
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__WPACTL_H__)
+#include "wpactl.h"
+#endif
+#if !defined(__KEY_H__)
+#include "key.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+
+
+#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024
+#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0
+#define HOSTAP_CRYPT_FLAG_PERMANENT BIT1
+#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
+#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
+#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
+#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
+#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
+#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+/*--------------------- Static Functions --------------------------*/
+
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*
+ * Description:
+ * register net_device (AP) for hostap deamon
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * rtnl_locked -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
+{
+ struct net_device *dev = pDevice->dev;
+ int ret;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
+
+#ifdef PRIVATE_OBJ
+ pDevice->apdev = ref_init_apdev(dev);
+
+ if (pDevice->apdev == NULL)
+ return -ENOMEM;
+
+ if (rtnl_locked)
+ ret = register_netdevice(pDevice->apdev);
+ else
+ ret = register_netdev(pDevice->apdev);
+ if (ret) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n",
+ dev->name);
+ return -1;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n",
+ dev->name, pDevice->apdev->name);
+
+#else
+ pDevice->apdev = (struct net_device *)kmalloc(sizeof(struct net_device), GFP_KERNEL);
+ if (pDevice->apdev == NULL)
+ return -ENOMEM;
+ memset(pDevice->apdev, 0, sizeof(struct net_device));
+
+ pDevice->apdev->priv = pDevice;
+ memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
+ pDevice->apdev->hard_start_xmit = pDevice->tx_80211;
+ pDevice->apdev->type = ARPHRD_IEEE80211;
+
+ pDevice->apdev->base_addr = dev->base_addr;
+ pDevice->apdev->irq = dev->irq;
+ pDevice->apdev->mem_start = dev->mem_start;
+ pDevice->apdev->mem_end = dev->mem_end;
+ sprintf(pDevice->apdev->name, "%sap", dev->name);
+ if (rtnl_locked)
+ ret = register_netdevice(pDevice->apdev);
+ else
+ ret = register_netdev(pDevice->apdev);
+ if (ret) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n",
+ dev->name);
+ return -1;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n",
+ dev->name, pDevice->apdev->name);
+
+ KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
+#endif
+
+ return 0;
+}
+
+/*
+ * Description:
+ * unregister net_device(AP)
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * rtnl_locked -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked)
+{
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: disabling hostapd mode\n", pDevice->dev->name);
+
+ if (pDevice->apdev && pDevice->apdev->name && pDevice->apdev->name[0]) {
+ if (rtnl_locked)
+ unregister_netdevice(pDevice->apdev);
+ else
+ unregister_netdev(pDevice->apdev);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
+ pDevice->dev->name, pDevice->apdev->name);
+ }
+ kfree(pDevice->apdev);
+ pDevice->apdev = NULL;
+ pDevice->bEnable8021x = FALSE;
+ pDevice->bEnableHostWEP = FALSE;
+ pDevice->bEncryptionEnable = FALSE;
+
+//4.2007-0118-03,<Add> by EinsnLiu
+//execute some clear work
+pDevice->pMgmt->byCSSPK=KEY_CTL_NONE;
+pDevice->pMgmt->byCSSGK=KEY_CTL_NONE;
+KeyvInitTable(&pDevice->sKey,pDevice->PortOffset);
+
+ return 0;
+}
+
+
+/*
+ * Description:
+ * Set enable/disable hostapd mode
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * rtnl_locked -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked)
+{
+ if (val < 0 || val > 1)
+ return -EINVAL;
+
+ if (pDevice->bEnableHostapd == val)
+ return 0;
+
+ pDevice->bEnableHostapd = val;
+
+ if (val)
+ return hostap_enable_hostapd(pDevice, rtnl_locked);
+ else
+ return hostap_disable_hostapd(pDevice, rtnl_locked);
+}
+
+
+/*
+ * Description:
+ * remove station function supported for hostap deamon
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+static int hostap_remove_sta(PSDevice pDevice,
+ struct viawget_hostapd_param *param)
+{
+ UINT uNodeIndex;
+
+
+ if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex)) {
+ BSSvRemoveOneNode(pDevice, uNodeIndex);
+ }
+ else {
+ return -ENOENT;
+ }
+ return 0;
+}
+
+/*
+ * Description:
+ * add a station from hostap deamon
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+static int hostap_add_sta(PSDevice pDevice,
+ struct viawget_hostapd_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uNodeIndex;
+
+
+ if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
+ BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex);
+ }
+ memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN);
+ pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
+ pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability;
+// TODO listenInterval
+// pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1;
+ pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = FALSE;
+ pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates;
+
+ // set max tx rate
+ pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
+ // set max basic rate
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate = RATE_2M;
+ // Todo: check sta preamble, if ap can't support, set status code
+ pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
+ WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt->sNodeDBTable[uNodeIndex].wCapInfo);
+
+ pMgmt->sNodeDBTable[uNodeIndex].wAID = (WORD)param->u.add_sta.aid;
+#ifdef PRIVATE_OBJ
+ pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = get_jiffies();
+#else
+ pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies;
+#endif
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Add STA AID= %d \n", pMgmt->sNodeDBTable[uNodeIndex].wAID);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
+ param->sta_addr[0],
+ param->sta_addr[1],
+ param->sta_addr[2],
+ param->sta_addr[3],
+ param->sta_addr[4],
+ param->sta_addr[5]
+ ) ;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Max Support rate = %d \n",
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * get station info
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int hostap_get_info_sta(PSDevice pDevice,
+ struct viawget_hostapd_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uNodeIndex;
+
+ if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
+#ifdef PRIVATE_OBJ
+ param->u.get_info_sta.inactive_sec =
+ (get_jiffies() - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ;
+#else
+ param->u.get_info_sta.inactive_sec =
+ (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ;
+#endif
+ //param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts;
+ }
+ else {
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
+/*
+ * Description:
+ * reset txexec
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ * TURE, FALSE
+ *
+ * Return Value:
+ *
+ */
+/*
+static int hostap_reset_txexc_sta(PSDevice pDevice,
+ struct viawget_hostapd_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uNodeIndex;
+
+ if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
+ pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0;
+ }
+ else {
+ return -ENOENT;
+ }
+
+ return 0;
+}
+*/
+
+/*
+ * Description:
+ * set station flag
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+static int hostap_set_flags_sta(PSDevice pDevice,
+ struct viawget_hostapd_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uNodeIndex;
+
+ if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
+ pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or;
+ pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x \n",
+ (UINT)pMgmt->sNodeDBTable[uNodeIndex].dwFlags);
+ }
+ else {
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Description:
+ * set generic element (wpa ie)
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+static int hostap_set_generic_element(PSDevice pDevice,
+ struct viawget_hostapd_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+
+
+ memcpy( pMgmt->abyWPAIE,
+ param->u.generic_elem.data,
+ param->u.generic_elem.len
+ );
+
+ pMgmt->wWPAIELen = param->u.generic_elem.len;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen);
+
+ // disable wpa
+ if (pMgmt->wWPAIELen == 0) {
+ pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " No WPAIE, Disable WPA \n");
+ } else {
+ // enable wpa
+ if ((pMgmt->abyWPAIE[0] == WLAN_EID_RSN_WPA) ||
+ (pMgmt->abyWPAIE[0] == WLAN_EID_RSN)) {
+ pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set WPAIE enable WPA\n");
+ } else
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/*
+ * Description:
+ * flush station nodes table.
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static void hostap_flush_sta(PSDevice pDevice)
+{
+ // reserved node index =0 for multicast node.
+ BSSvClearNodeDBTable(pDevice, 1);
+ pDevice->uAssocCount = 0;
+
+ return;
+}
+
+/*
+ * Description:
+ * set each stations encryption key
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+static int hostap_set_encryption(PSDevice pDevice,
+ struct viawget_hostapd_param *param,
+ int param_len)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ DWORD dwKeyIndex = 0;
+ BYTE abyKey[MAX_KEY_LEN];
+ BYTE abySeq[MAX_KEY_LEN];
+ NDIS_802_11_KEY_RSC KeyRSC;
+ BYTE byKeyDecMode = KEY_CTL_WEP;
+ int ret = 0;
+ int iNodeIndex = -1;
+ int ii;
+ BOOL bKeyTableFull = FALSE;
+ WORD wKeyCtl = 0;
+
+
+ param->u.crypt.err = 0;
+/*
+ if (param_len !=
+ (int) ((char *) param->u.crypt.key - (char *) param) +
+ param->u.crypt.key_len)
+ return -EINVAL;
+*/
+
+ if (param->u.crypt.alg > WPA_ALG_CCMP)
+ return -EINVAL;
+
+
+ if ((param->u.crypt.idx > 3) || (param->u.crypt.key_len > MAX_KEY_LEN)) {
+ param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n");
+ return -EINVAL;
+ }
+
+ if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+ param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+ param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+ if (param->u.crypt.idx >= MAX_GROUP_KEY)
+ return -EINVAL;
+ iNodeIndex = 0;
+
+ } else {
+ if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == FALSE) {
+ param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
+ return -EINVAL;
+ }
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: sta_index %d \n", iNodeIndex);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: alg %d \n", param->u.crypt.alg);
+
+ if (param->u.crypt.alg == WPA_ALG_NONE) {
+
+ if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly == TRUE) {
+ if (KeybRemoveKey(&(pDevice->sKey),
+ param->sta_addr,
+ pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex,
+ pDevice->PortOffset) == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybRemoveKey fail \n");
+ }
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
+ }
+ pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = 0;
+ memset(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
+ 0,
+ MAX_KEY_LEN
+ );
+
+ return ret;
+ }
+
+ memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len);
+ // copy to node key tbl
+ pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = param->u.crypt.idx;
+ pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = param->u.crypt.key_len;
+ memcpy(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
+ param->u.crypt.key,
+ param->u.crypt.key_len
+ );
+
+ dwKeyIndex = (DWORD)(param->u.crypt.idx);
+ if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) {
+ pDevice->byKeyIndex = (BYTE)dwKeyIndex;
+ pDevice->bTransmitKey = TRUE;
+ dwKeyIndex |= (1 << 31);
+ }
+
+ if (param->u.crypt.alg == WPA_ALG_WEP) {
+
+ if ((pDevice->bEnable8021x == FALSE) || (iNodeIndex == 0)) {
+ KeybSetDefaultKey(&(pDevice->sKey),
+ dwKeyIndex & ~(BIT30 | USE_KEYRSC),
+ param->u.crypt.key_len,
+ NULL,
+ abyKey,
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID);
+
+ } else {
+ // 8021x enable, individual key
+ dwKeyIndex |= (1 << 30); // set pairwise key
+ if (KeybSetKey(&(pDevice->sKey),
+ &param->sta_addr[0],
+ dwKeyIndex & ~(USE_KEYRSC),
+ param->u.crypt.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID) == TRUE) {
+
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
+
+ } else {
+ // Key Table Full
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
+ bKeyTableFull = TRUE;
+ }
+ }
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ pDevice->bEncryptionEnable = TRUE;
+ pMgmt->byCSSPK = KEY_CTL_WEP;
+ pMgmt->byCSSGK = KEY_CTL_WEP;
+ pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP;
+ pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex;
+ return ret;
+ }
+
+ if (param->u.crypt.seq) {
+ memcpy(&abySeq, param->u.crypt.seq, 8);
+ for (ii = 0 ; ii < 8 ; ii++) {
+ KeyRSC |= (abySeq[ii] << (ii * 8));
+ }
+ dwKeyIndex |= 1 << 29;
+ pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC;
+ }
+
+ if (param->u.crypt.alg == WPA_ALG_TKIP) {
+ if (param->u.crypt.key_len != MAX_KEY_LEN)
+ return -EINVAL;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
+ byKeyDecMode = KEY_CTL_TKIP;
+ pMgmt->byCSSPK = KEY_CTL_TKIP;
+ pMgmt->byCSSGK = KEY_CTL_TKIP;
+ }
+
+ if (param->u.crypt.alg == WPA_ALG_CCMP) {
+ if ((param->u.crypt.key_len != AES_KEY_LEN) ||
+ (pDevice->byLocalID <= REV_ID_VT3253_A1))
+ return -EINVAL;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
+ byKeyDecMode = KEY_CTL_CCMP;
+ pMgmt->byCSSPK = KEY_CTL_CCMP;
+ pMgmt->byCSSGK = KEY_CTL_CCMP;
+ }
+
+
+ if (iNodeIndex == 0) {
+ KeybSetDefaultKey(&(pDevice->sKey),
+ dwKeyIndex,
+ param->u.crypt.key_len,
+ (PQWORD) &(KeyRSC),
+ abyKey,
+ byKeyDecMode,
+ pDevice->PortOffset,
+ pDevice->byLocalID);
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
+
+ } else {
+ dwKeyIndex |= (1 << 30); // set pairwise key
+ if (KeybSetKey(&(pDevice->sKey),
+ &param->sta_addr[0],
+ dwKeyIndex,
+ param->u.crypt.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode,
+ pDevice->PortOffset,
+ pDevice->byLocalID) == TRUE) {
+
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
+
+ } else {
+ // Key Table Full
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
+ bKeyTableFull = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Key Table Full\n");
+ }
+
+ }
+
+ if (bKeyTableFull == TRUE) {
+ wKeyCtl &= 0x7F00; // clear all key control filed
+ wKeyCtl |= (byKeyDecMode << 4);
+ wKeyCtl |= (byKeyDecMode);
+ wKeyCtl |= 0x0044; // use group key for all address
+ wKeyCtl |= 0x4000; // disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int
+ MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID);
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set key sta_index= %d \n", iNodeIndex);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " tx_index=%d len=%d \n", param->u.crypt.idx,
+ param->u.crypt.key_len );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n",
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[1],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[2],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[3],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[4]
+ );
+
+ // set wep key
+ pDevice->bEncryptionEnable = TRUE;
+ pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode;
+ pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex;
+ pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0;
+ pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0;
+
+ return ret;
+}
+
+
+
+/*
+ * Description:
+ * get each stations encryption key
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+static int hostap_get_encryption(PSDevice pDevice,
+ struct viawget_hostapd_param *param,
+ int param_len)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int ret = 0;
+ int ii;
+ int iNodeIndex =0;
+
+
+ param->u.crypt.err = 0;
+
+ if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+ param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+ param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+ iNodeIndex = 0;
+ } else {
+ if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == FALSE) {
+ param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
+ return -EINVAL;
+ }
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: %d\n", iNodeIndex);
+ memset(param->u.crypt.seq, 0, 8);
+ for (ii = 0 ; ii < 8 ; ii++) {
+ param->u.crypt.seq[ii] = (BYTE)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8);
+ }
+
+ return ret;
+}
+
+
+/*
+ * Description:
+ * hostap_ioctl main function supported for hostap deamon.
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * iw_point -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+int hostap_ioctl(PSDevice pDevice, struct iw_point *p)
+{
+ struct viawget_hostapd_param *param;
+ int ret = 0;
+ int ap_ioctl = 0;
+
+ if (p->length < sizeof(struct viawget_hostapd_param) ||
+ p->length > VIAWGET_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
+ return -EINVAL;
+
+ param = (struct viawget_hostapd_param *) kmalloc((int)p->length, (int)GFP_KERNEL);
+ if (param == NULL)
+ return -ENOMEM;
+
+ if (copy_from_user(param, p->pointer, p->length)) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ switch (param->cmd) {
+ case VIAWGET_HOSTAPD_SET_ENCRYPTION:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ENCRYPTION \n");
+ spin_lock_irq(&pDevice->lock);
+ ret = hostap_set_encryption(pDevice, param, p->length);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+ case VIAWGET_HOSTAPD_GET_ENCRYPTION:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_ENCRYPTION \n");
+ spin_lock_irq(&pDevice->lock);
+ ret = hostap_get_encryption(pDevice, param, p->length);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+ case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n");
+ return -EOPNOTSUPP;
+ break;
+ case VIAWGET_HOSTAPD_FLUSH:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_FLUSH \n");
+ spin_lock_irq(&pDevice->lock);
+ hostap_flush_sta(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+ case VIAWGET_HOSTAPD_ADD_STA:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_ADD_STA \n");
+ spin_lock_irq(&pDevice->lock);
+ ret = hostap_add_sta(pDevice, param);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+ case VIAWGET_HOSTAPD_REMOVE_STA:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_REMOVE_STA \n");
+ spin_lock_irq(&pDevice->lock);
+ ret = hostap_remove_sta(pDevice, param);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+ case VIAWGET_HOSTAPD_GET_INFO_STA:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_INFO_STA \n");
+ ret = hostap_get_info_sta(pDevice, param);
+ ap_ioctl = 1;
+ break;
+/*
+ case VIAWGET_HOSTAPD_RESET_TXEXC_STA:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n");
+ ret = hostap_reset_txexc_sta(pDevice, param);
+ break;
+*/
+ case VIAWGET_HOSTAPD_SET_FLAGS_STA:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
+ ret = hostap_set_flags_sta(pDevice, param);
+ break;
+
+ case VIAWGET_HOSTAPD_MLME:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n");
+ return -EOPNOTSUPP;
+
+ case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n");
+ ret = hostap_set_generic_element(pDevice, param);
+ break;
+
+ case VIAWGET_HOSTAPD_SCAN_REQ:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ \n");
+ return -EOPNOTSUPP;
+
+ case VIAWGET_HOSTAPD_STA_CLEAR_STATS:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_STA_CLEAR_STATS \n");
+ return -EOPNOTSUPP;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_ioctl: unknown cmd=%d\n",
+ (int)param->cmd);
+ return -EOPNOTSUPP;
+ break;
+ }
+
+
+ if ((ret == 0) && ap_ioctl) {
+ if (copy_to_user(p->pointer, param, p->length)) {
+ ret = -EFAULT;
+ goto out;
+ }
+ }
+
+ out:
+ if (param != NULL)
+ kfree(param);
+
+ return ret;
+}
+
diff --git a/drivers/staging/vt6655/hostap.h b/drivers/staging/vt6655/hostap.h
new file mode 100644
index 000000000000..1fcb2f0788b3
--- /dev/null
+++ b/drivers/staging/vt6655/hostap.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: hostap.h
+ *
+ * Purpose:
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 21, 2003
+ *
+ */
+
+
+#ifndef __HOSTAP_H__
+#define __HOSTAP_H__
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#if WIRELESS_EXT < 9
+struct iw_point {
+ caddr_t pointer;
+ __u16 length;
+ __u16 flags;
+};
+#endif /* WIRELESS_EXT < 9 */
+
+#define WLAN_RATE_1M BIT0
+#define WLAN_RATE_2M BIT1
+#define WLAN_RATE_5M5 BIT2
+#define WLAN_RATE_11M BIT3
+#define WLAN_RATE_6M BIT4
+#define WLAN_RATE_9M BIT5
+#define WLAN_RATE_12M BIT6
+#define WLAN_RATE_18M BIT7
+#define WLAN_RATE_24M BIT8
+#define WLAN_RATE_36M BIT9
+#define WLAN_RATE_48M BIT10
+#define WLAN_RATE_54M BIT11
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+#ifndef ETH_P_PAE
+#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
+#endif /* ETH_P_PAE */
+
+#ifndef ARPHRD_IEEE80211
+#define ARPHRD_IEEE80211 801
+#endif
+
+int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked);
+int hostap_ioctl(PSDevice pDevice, struct iw_point *p);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __HOSTAP_H__
+
+
+
diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h
new file mode 100644
index 000000000000..ada9ee999767
--- /dev/null
+++ b/drivers/staging/vt6655/iocmd.h
@@ -0,0 +1,481 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: iocmd.h
+ *
+ * Purpose: Handles the viawget ioctl private interface functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2002
+ *
+ */
+
+#ifndef __IOCMD_H__
+#define __IOCMD_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#if !defined(DEF)
+#define DEF
+#endif
+
+//typedef int BOOL;
+//typedef uint32_t u32;
+//typedef uint16_t u16;
+//typedef uint8_t u8;
+
+
+// ioctl Command code
+#define MAGIC_CODE 0x3142
+#define IOCTL_CMD_TEST (SIOCDEVPRIVATE + 0)
+#define IOCTL_CMD_SET (SIOCDEVPRIVATE + 1)
+#define IOCTL_CMD_HOSTAPD (SIOCDEVPRIVATE + 2)
+#define IOCTL_CMD_WPA (SIOCDEVPRIVATE + 3)
+
+
+typedef enum tagWMAC_CMD {
+
+ WLAN_CMD_BSS_SCAN,
+ WLAN_CMD_BSS_JOIN,
+ WLAN_CMD_DISASSOC,
+ WLAN_CMD_SET_WEP,
+ WLAN_CMD_GET_LINK,
+ WLAN_CMD_GET_LISTLEN,
+ WLAN_CMD_GET_LIST,
+ WLAN_CMD_GET_MIB,
+ WLAN_CMD_GET_STAT,
+ WLAN_CMD_STOP_MAC,
+ WLAN_CMD_START_MAC,
+ WLAN_CMD_AP_START,
+ WLAN_CMD_SET_HOSTAPD,
+ WLAN_CMD_SET_HOSTAPD_STA,
+ WLAN_CMD_SET_802_1X,
+ WLAN_CMD_SET_HOST_WEP,
+ WLAN_CMD_SET_WPA,
+ WLAN_CMD_GET_NODE_CNT,
+ WLAN_CMD_ZONETYPE_SET,
+ WLAN_CMD_GET_NODE_LIST
+
+} WMAC_CMD, DEF* PWMAC_CMD;
+
+ typedef enum tagWZONETYPE {
+ ZoneType_USA=0,
+ ZoneType_Japan=1,
+ ZoneType_Europe=2
+}WZONETYPE;
+
+#define ADHOC 0
+#define INFRA 1
+#define BOTH 2
+#define AP 3
+
+#define ADHOC_STARTED 1
+#define ADHOC_JOINTED 2
+
+
+#define PHY80211a 0
+#define PHY80211b 1
+#define PHY80211g 2
+
+#define SSID_ID 0
+#define SSID_MAXLEN 32
+#define BSSID_LEN 6
+#define WEP_NKEYS 4
+#define WEP_KEYMAXLEN 29
+#define WEP_40BIT_LEN 5
+#define WEP_104BIT_LEN 13
+#define WEP_232BIT_LEN 16
+
+
+// Ioctl interface structure
+// Command structure
+//
+#pragma pack(1)
+typedef struct tagSCmdRequest {
+ U8 name[16];
+ void *data;
+ U16 wResult;
+ U16 wCmdCode;
+} SCmdRequest, *PSCmdRequest;
+
+
+//
+// Scan
+//
+
+typedef struct tagSCmdScan {
+
+ U8 ssid[SSID_MAXLEN + 2];
+
+} SCmdScan, *PSCmdScan;
+
+
+//
+// BSS Join
+//
+
+typedef struct tagSCmdBSSJoin {
+
+ U16 wBSSType;
+ U16 wBBPType;
+ U8 ssid[SSID_MAXLEN + 2];
+ U32 uChannel;
+ BOOL bPSEnable;
+ BOOL bShareKeyAuth;
+
+} SCmdBSSJoin, *PSCmdBSSJoin;
+
+typedef struct tagSCmdZoneTypeSet {
+
+ BOOL bWrite;
+ WZONETYPE ZoneType;
+
+} SCmdZoneTypeSet, *PSCmdZoneTypeSet;
+
+#ifdef WPA_SM_Transtatus
+typedef struct tagSWPAResult {
+ char ifname[100];
+ U8 proto;
+ U8 key_mgmt;
+ U8 eap_type;
+ BOOL authenticated;
+} SWPAResult, *PSWPAResult;
+#endif
+
+
+typedef struct tagSCmdStartAP {
+
+ U16 wBSSType;
+ U16 wBBPType;
+ U8 ssid[SSID_MAXLEN + 2];
+ U32 uChannel;
+ U32 uBeaconInt;
+ BOOL bShareKeyAuth;
+ U8 byBasicRate;
+
+} SCmdStartAP, *PSCmdStartAP;
+
+
+typedef struct tagSCmdSetWEP {
+
+ BOOL bEnableWep;
+ U8 byKeyIndex;
+ U8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN];
+ BOOL bWepKeyAvailable[WEP_NKEYS];
+ U32 auWepKeyLength[WEP_NKEYS];
+
+} SCmdSetWEP, *PSCmdSetWEP;
+
+
+
+typedef struct tagSBSSIDItem {
+
+ U32 uChannel;
+ U8 abyBSSID[BSSID_LEN];
+ U8 abySSID[SSID_MAXLEN + 1];
+ //2006-1116-01,<Modify> by NomadZhao
+ //U16 wBeaconInterval;
+ //U16 wCapInfo;
+ //U8 byNetType;
+ U8 byNetType;
+ U16 wBeaconInterval;
+ U16 wCapInfo; // for address of byNetType at align 4
+
+ BOOL bWEPOn;
+ U32 uRSSI;
+
+} SBSSIDItem;
+
+
+typedef struct tagSBSSIDList {
+
+ U32 uItem;
+ SBSSIDItem sBSSIDList[0];
+} SBSSIDList, *PSBSSIDList;
+
+
+typedef struct tagSCmdLinkStatus {
+
+ BOOL bLink;
+ U16 wBSSType;
+ U8 byState;
+ U8 abyBSSID[BSSID_LEN];
+ U8 abySSID[SSID_MAXLEN + 2];
+ U32 uChannel;
+ U32 uLinkRate;
+
+} SCmdLinkStatus, *PSCmdLinkStatus;
+
+//
+// 802.11 counter
+//
+typedef struct tagSDot11MIBCount {
+ U32 TransmittedFragmentCount;
+ U32 MulticastTransmittedFrameCount;
+ U32 FailedCount;
+ U32 RetryCount;
+ U32 MultipleRetryCount;
+ U32 RTSSuccessCount;
+ U32 RTSFailureCount;
+ U32 ACKFailureCount;
+ U32 FrameDuplicateCount;
+ U32 ReceivedFragmentCount;
+ U32 MulticastReceivedFrameCount;
+ U32 FCSErrorCount;
+} SDot11MIBCount, DEF* PSDot11MIBCount;
+
+
+
+//
+// statistic counter
+//
+typedef struct tagSStatMIBCount {
+ //
+ // ISR status count
+ //
+ U32 dwIsrTx0OK;
+ U32 dwIsrTx1OK;
+ U32 dwIsrBeaconTxOK;
+ U32 dwIsrRxOK;
+ U32 dwIsrTBTTInt;
+ U32 dwIsrSTIMERInt;
+ U32 dwIsrUnrecoverableError;
+ U32 dwIsrSoftInterrupt;
+ U32 dwIsrRxNoBuf;
+ /////////////////////////////////////
+
+ U32 dwIsrUnknown; // unknown interrupt count
+
+ // RSR status count
+ //
+ U32 dwRsrFrmAlgnErr;
+ U32 dwRsrErr;
+ U32 dwRsrCRCErr;
+ U32 dwRsrCRCOk;
+ U32 dwRsrBSSIDOk;
+ U32 dwRsrADDROk;
+ U32 dwRsrICVOk;
+ U32 dwNewRsrShortPreamble;
+ U32 dwRsrLong;
+ U32 dwRsrRunt;
+
+ U32 dwRsrRxControl;
+ U32 dwRsrRxData;
+ U32 dwRsrRxManage;
+
+ U32 dwRsrRxPacket;
+ U32 dwRsrRxOctet;
+ U32 dwRsrBroadcast;
+ U32 dwRsrMulticast;
+ U32 dwRsrDirected;
+ // 64-bit OID
+ U32 ullRsrOK;
+
+ // for some optional OIDs (64 bits) and DMI support
+ U32 ullRxBroadcastBytes;
+ U32 ullRxMulticastBytes;
+ U32 ullRxDirectedBytes;
+ U32 ullRxBroadcastFrames;
+ U32 ullRxMulticastFrames;
+ U32 ullRxDirectedFrames;
+
+ U32 dwRsrRxFragment;
+ U32 dwRsrRxFrmLen64;
+ U32 dwRsrRxFrmLen65_127;
+ U32 dwRsrRxFrmLen128_255;
+ U32 dwRsrRxFrmLen256_511;
+ U32 dwRsrRxFrmLen512_1023;
+ U32 dwRsrRxFrmLen1024_1518;
+
+ // TSR0,1 status count
+ //
+ U32 dwTsrTotalRetry[2]; // total collision retry count
+ U32 dwTsrOnceRetry[2]; // this packet only occur one collision
+ U32 dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision
+ U32 dwTsrRetry[2]; // this packet has ever occur collision,
+ // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
+ U32 dwTsrACKData[2];
+ U32 dwTsrErr[2];
+ U32 dwAllTsrOK[2];
+ U32 dwTsrRetryTimeout[2];
+ U32 dwTsrTransmitTimeout[2];
+
+ U32 dwTsrTxPacket[2];
+ U32 dwTsrTxOctet[2];
+ U32 dwTsrBroadcast[2];
+ U32 dwTsrMulticast[2];
+ U32 dwTsrDirected[2];
+
+ // RD/TD count
+ U32 dwCntRxFrmLength;
+ U32 dwCntTxBufLength;
+
+ U8 abyCntRxPattern[16];
+ U8 abyCntTxPattern[16];
+
+ // Software check....
+ U32 dwCntRxDataErr; // rx buffer data software compare CRC err count
+ U32 dwCntDecryptErr; // rx buffer data software compare CRC err count
+ U32 dwCntRxICVErr; // rx buffer data software compare CRC err count
+ U32 idxRxErrorDesc; // index for rx data error RD
+
+ // 64-bit OID
+ U32 ullTsrOK[2];
+
+ // for some optional OIDs (64 bits) and DMI support
+ U32 ullTxBroadcastFrames[2];
+ U32 ullTxMulticastFrames[2];
+ U32 ullTxDirectedFrames[2];
+ U32 ullTxBroadcastBytes[2];
+ U32 ullTxMulticastBytes[2];
+ U32 ullTxDirectedBytes[2];
+} SStatMIBCount, DEF* PSStatMIBCount;
+
+
+typedef struct tagSNodeItem {
+ // STA info
+ U16 wAID;
+ U8 abyMACAddr[6];
+ U16 wTxDataRate;
+ U16 wInActiveCount;
+ U16 wEnQueueCnt;
+ U16 wFlags;
+ BOOL bPWBitOn;
+ U8 byKeyIndex;
+ U16 wWepKeyLength;
+ U8 abyWepKey[WEP_KEYMAXLEN];
+ // Auto rate fallback vars
+ BOOL bIsInFallback;
+ U32 uTxFailures;
+ U32 uTxAttempts;
+ U16 wFailureRatio;
+
+} SNodeItem;
+
+
+typedef struct tagSNodeList {
+
+ U32 uItem;
+ SNodeItem sNodeList[0];
+
+} SNodeList, *PSNodeList;
+
+
+
+typedef struct tagSCmdValue {
+
+ U32 dwValue;
+
+} SCmdValue, *PSCmdValue;
+
+
+//
+// hostapd & viawget ioctl related
+//
+
+
+// VIAGWET_IOCTL_HOSTAPD ioctl() cmd:
+enum {
+ VIAWGET_HOSTAPD_FLUSH = 1,
+ VIAWGET_HOSTAPD_ADD_STA = 2,
+ VIAWGET_HOSTAPD_REMOVE_STA = 3,
+ VIAWGET_HOSTAPD_GET_INFO_STA = 4,
+ VIAWGET_HOSTAPD_SET_ENCRYPTION = 5,
+ VIAWGET_HOSTAPD_GET_ENCRYPTION = 6,
+ VIAWGET_HOSTAPD_SET_FLAGS_STA = 7,
+ VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8,
+ VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9,
+ VIAWGET_HOSTAPD_MLME = 10,
+ VIAWGET_HOSTAPD_SCAN_REQ = 11,
+ VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12,
+};
+
+
+#define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
+((int) (&((struct viawget_hostapd_param *) 0)->u.generic_elem.data))
+
+// Maximum length for algorithm names (-1 for nul termination) used in ioctl()
+
+
+
+struct viawget_hostapd_param {
+ U32 cmd;
+ U8 sta_addr[6];
+ union {
+ struct {
+ U16 aid;
+ U16 capability;
+ U8 tx_supp_rates;
+ } add_sta;
+ struct {
+ U32 inactive_sec;
+ } get_info_sta;
+ struct {
+ U8 alg;
+ U32 flags;
+ U32 err;
+ U8 idx;
+ U8 seq[8];
+ U16 key_len;
+ U8 key[0];
+ } crypt;
+ struct {
+ U32 flags_and;
+ U32 flags_or;
+ } set_flags_sta;
+ struct {
+ U16 rid;
+ U16 len;
+ U8 data[0];
+ } rid;
+ struct {
+ U8 len;
+ U8 data[0];
+ } generic_elem;
+ struct {
+ U16 cmd;
+ U16 reason_code;
+ } mlme;
+ struct {
+ U8 ssid_len;
+ U8 ssid[32];
+ } scan_req;
+ } u;
+};
+
+//2006-1116-01,<Add> by NomadZhao
+#pragma pack()
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+#endif //__IOCMD_H__
diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c
new file mode 100644
index 000000000000..4869107a2bca
--- /dev/null
+++ b/drivers/staging/vt6655/ioctl.c
@@ -0,0 +1,775 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: ioctl.c
+ *
+ * Purpose: private ioctl functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Auguest 20, 2003
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__IOCTL_H__)
+#include "ioctl.h"
+#endif
+#if !defined(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__WPACTL_H__)
+#include "wpactl.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+/*--------------------- Static Functions --------------------------*/
+
+#ifdef WPA_SM_Transtatus
+ SWPAResult wpa_Result;
+#endif
+
+
+/*--------------------- Export Variables --------------------------*/
+
+int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
+
+ PSCmdRequest pReq = (PSCmdRequest)rq;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int result = 0;
+ PWLAN_IE_SSID pItemSSID;
+ SCmdBSSJoin sJoinCmd;
+ SCmdZoneTypeSet sZoneTypeCmd;
+ SCmdScan sScanCmd;
+ SCmdStartAP sStartAPCmd;
+ SCmdSetWEP sWEPCmd;
+ SCmdValue sValue;
+ SBSSIDList sList;
+ SNodeList sNodeList;
+ PSBSSIDList pList;
+ PSNodeList pNodeList;
+ UINT cbListCount;
+ PKnownBSS pBSS;
+ PKnownNodeDB pNode;
+ UINT ii, jj;
+ SCmdLinkStatus sLinkStatus;
+ BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
+ BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ DWORD dwKeyIndex= 0;
+ BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ LONG ldBm;
+
+
+ pReq->wResult = 0;
+
+ switch(pReq->wCmdCode) {
+
+ case WLAN_CMD_BSS_SCAN:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin \n");
+ if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
+ result = -EFAULT;
+ break;
+ };
+
+ pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
+ if (pItemSSID->len != 0) {
+ memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
+ }
+
+ if (pDevice->bMACSuspend == TRUE) {
+ if (pDevice->bRadioOff == TRUE)
+ CARDbRadioPowerOn(pDevice);
+ vMgrTimerInit(pDevice);
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+ add_timer(&pMgmt->sTimerSecondCallback);
+ pDevice->bMACSuspend = FALSE;
+ }
+ spin_lock_irq(&pDevice->lock);
+ if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
+ BSSvClearBSSList((HANDLE)pDevice, FALSE);
+ else
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+
+ if (pItemSSID->len != 0)
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
+ else
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+
+ case WLAN_CMD_ZONETYPE_SET:
+ //mike add :cann't support.
+ result=-EOPNOTSUPP;
+ break;
+
+ if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
+ result = -EFAULT;
+ break;
+ };
+
+ if(sZoneTypeCmd.bWrite==TRUE) {
+ //////write zonetype
+ if(sZoneTypeCmd.ZoneType == ZoneType_USA) {
+ //set to USA
+ printk("set_ZoneType:USA\n");
+ }
+ else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) {
+ //set to Japan
+ printk("set_ZoneType:Japan\n");
+ }
+ else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) {
+ //set to Europe
+ printk("set_ZoneType:Europe\n");
+ }
+ }
+ else {
+ ///////read zonetype
+ BYTE zonetype=0;
+
+
+ if(zonetype == 0x00) { //USA
+ sZoneTypeCmd.ZoneType = ZoneType_USA;
+ }
+ else if(zonetype == 0x01) { //Japan
+ sZoneTypeCmd.ZoneType = ZoneType_Japan;
+ }
+ else if(zonetype == 0x02) { //Europe
+ sZoneTypeCmd.ZoneType = ZoneType_Europe;
+ }
+ else { //Unknow ZoneType
+ printk("Error:ZoneType[%x] Unknown ???\n",zonetype);
+ result = -EFAULT;
+ break;
+ }
+ if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
+ result = -EFAULT;
+ break;
+ };
+ }
+
+ break;
+
+ case WLAN_CMD_BSS_JOIN:
+
+ if (pDevice->bMACSuspend == TRUE) {
+ if (pDevice->bRadioOff == TRUE)
+ CARDbRadioPowerOn(pDevice);
+ vMgrTimerInit(pDevice);
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+ add_timer(&pMgmt->sTimerSecondCallback);
+ pDevice->bMACSuspend = FALSE;
+ }
+
+ if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
+ result = -EFAULT;
+ break;
+ };
+
+ pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
+ if (sJoinCmd.wBSSType == ADHOC) {
+ pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
+ }
+ else {
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
+ }
+ if (sJoinCmd.bPSEnable == TRUE) {
+ pDevice->ePSMode = WMAC_POWER_FAST;
+// pDevice->ePSMode = WMAC_POWER_MAX;
+ pMgmt->wListenInterval = 2;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
+ }
+ else {
+ pDevice->ePSMode = WMAC_POWER_CAM;
+ pMgmt->wListenInterval = 1;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n");
+ }
+
+ if (sJoinCmd.bShareKeyAuth == TRUE){
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
+ }
+ else {
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
+ }
+ pDevice->uChannel = sJoinCmd.uChannel;
+ netif_stop_queue(pDevice->dev);
+ spin_lock_irq(&pDevice->lock);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+
+ case WLAN_CMD_SET_WEP:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n");
+ memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP));
+ if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
+ result = -EFAULT;
+ break;
+ };
+ if (sWEPCmd.bEnableWep != TRUE) {
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ MACvDisableDefaultKey(pDevice->PortOffset);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable. \n");
+ break;
+ }
+
+ for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) {
+ if (sWEPCmd.bWepKeyAvailable[ii]) {
+ if (ii == sWEPCmd.byKeyIndex)
+ //2006-1123-02,<Modify> by EinsnLiu
+ //Evaluate the "dwKeyIndex" error
+ // dwKeyIndex |= (1 << 31);
+ dwKeyIndex =ii|(1 << 31);
+ else
+ dwKeyIndex = ii;
+
+ KeybSetDefaultKey(&(pDevice->sKey),
+ dwKeyIndex,
+ sWEPCmd.auWepKeyLength[ii],
+ NULL,
+ (PBYTE)&sWEPCmd.abyWepKey[ii][0],
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID);
+ }
+ }
+ pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
+ pDevice->bTransmitKey = TRUE;
+ pDevice->bEncryptionEnable = TRUE;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+
+ break;
+
+ case WLAN_CMD_GET_LINK:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n");
+
+ memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
+ sLinkStatus.wBSSType = ADHOC;
+ else
+ sLinkStatus.wBSSType = INFRA;
+
+ if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
+ sLinkStatus.byState = ADHOC_JOINTED;
+ else
+ sLinkStatus.byState = ADHOC_STARTED;
+
+ sLinkStatus.uChannel = pMgmt->uCurrChannel;
+ if (pDevice->bLinkPass == TRUE) {
+ sLinkStatus.bLink = TRUE;
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
+ memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n");
+ }
+ else {
+ sLinkStatus.bLink = FALSE;
+ }
+ if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
+ result = -EFAULT;
+ break;
+ };
+
+ break;
+
+ case WLAN_CMD_GET_LISTLEN:
+ cbListCount = 0;
+ pBSS = &(pMgmt->sBSSList[0]);
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pBSS = &(pMgmt->sBSSList[ii]);
+ if (!pBSS->bActive)
+ continue;
+ cbListCount++;
+ };
+ sList.uItem = cbListCount;
+ if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
+ result = -EFAULT;
+ break;
+ };
+ pReq->wResult = 0;
+ break;
+
+ case WLAN_CMD_GET_LIST:
+ if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
+ result = -EFAULT;
+ break;
+ };
+ pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
+ if (pList == NULL) {
+ result = -ENOMEM;
+ break;
+ }
+ pList->uItem = sList.uItem;
+ pBSS = &(pMgmt->sBSSList[0]);
+ for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
+ pBSS = &(pMgmt->sBSSList[jj]);
+ if (pBSS->bActive) {
+ pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
+ pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
+ pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
+// pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI;
+ RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
+ pList->sBSSIDList[ii].uRSSI = (UINT)ldBm;
+ memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
+ pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
+ memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
+ memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
+ if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
+ pList->sBSSIDList[ii].byNetType = INFRA;
+ }
+ else {
+ pList->sBSSIDList[ii].byNetType = ADHOC;
+ }
+ if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
+ pList->sBSSIDList[ii].bWEPOn = TRUE;
+ }
+ else {
+ pList->sBSSIDList[ii].bWEPOn = FALSE;
+ }
+ ii ++;
+ if (ii >= pList->uItem)
+ break;
+ }
+ }
+
+ if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
+ result = -EFAULT;
+ break;
+ };
+ kfree(pList);
+ pReq->wResult = 0;
+ break;
+
+ case WLAN_CMD_GET_MIB:
+ if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
+ result = -EFAULT;
+ break;
+ };
+ break;
+
+ case WLAN_CMD_GET_STAT:
+ if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
+ result = -EFAULT;
+ break;
+ };
+ break;
+ case WLAN_CMD_STOP_MAC:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
+ netif_stop_queue(pDevice->dev);
+
+ spin_lock_irq(&pDevice->lock);
+ if (pDevice->bRadioOff == FALSE) {
+ CARDbRadioPowerOff(pDevice);
+ }
+ pDevice->bLinkPass = FALSE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ del_timer(&pDevice->sTimerCommand);
+ del_timer(&pMgmt->sTimerSecondCallback);
+ pDevice->bCmdRunning = FALSE;
+ pDevice->bMACSuspend = TRUE;
+ MACvIntDisable(pDevice->PortOffset);
+ spin_unlock_irq(&pDevice->lock);
+
+ break;
+
+ case WLAN_CMD_START_MAC:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
+
+ if (pDevice->bMACSuspend == TRUE) {
+ if (pDevice->bRadioOff == TRUE)
+ CARDbRadioPowerOn(pDevice);
+ vMgrTimerInit(pDevice);
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+ add_timer(&pMgmt->sTimerSecondCallback);
+ pDevice->bMACSuspend = FALSE;
+ }
+ break;
+
+ case WLAN_CMD_SET_HOSTAPD:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
+
+ if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
+ result = -EFAULT;
+ break;
+ };
+ if (sValue.dwValue == 1) {
+ if (hostap_set_hostapd(pDevice, 1, 1) == 0){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
+ }
+ else {
+ result = -EFAULT;
+ break;
+ }
+ }
+ else {
+ hostap_set_hostapd(pDevice, 0, 1);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
+ }
+
+ break;
+
+ case WLAN_CMD_SET_HOSTAPD_STA:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
+
+ break;
+ case WLAN_CMD_SET_802_1X:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
+ if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
+ result = -EFAULT;
+ break;
+ };
+
+ if (sValue.dwValue == 1) {
+ pDevice->bEnable8021x = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
+ }
+ else {
+ pDevice->bEnable8021x = FALSE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
+ }
+
+ break;
+
+
+ case WLAN_CMD_SET_HOST_WEP:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
+ if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
+ result = -EFAULT;
+ break;
+ };
+
+ if (sValue.dwValue == 1) {
+ pDevice->bEnableHostWEP = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
+ }
+ else {
+ pDevice->bEnableHostWEP = FALSE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
+ }
+
+ break;
+
+ case WLAN_CMD_SET_WPA:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
+
+ if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
+ result = -EFAULT;
+ break;
+ };
+ if (sValue.dwValue == 1) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
+ memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, U_ETHER_ADDR_LEN);
+ pDevice->bWPADEVUp = TRUE;
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
+ pDevice->bWPADEVUp = FALSE;
+ }
+
+ break;
+
+ case WLAN_CMD_AP_START:
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
+ if (pDevice->bRadioOff == TRUE) {
+ CARDbRadioPowerOn(pDevice);
+ vMgrTimerInit(pDevice);
+ MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+ add_timer(&pMgmt->sTimerSecondCallback);
+ }
+ if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
+ result = -EFAULT;
+ break;
+ };
+
+ if (sStartAPCmd.wBSSType == AP) {
+ pMgmt->eConfigMode = WMAC_CONFIG_AP;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
+ result = -EFAULT;
+ break;
+ }
+
+
+ if (sStartAPCmd.wBBPType == PHY80211g) {
+ pMgmt->byAPBBType = PHY_TYPE_11G;
+ }
+ else if (sStartAPCmd.wBBPType == PHY80211a) {
+ pMgmt->byAPBBType = PHY_TYPE_11A;
+ }
+ else {
+ pMgmt->byAPBBType = PHY_TYPE_11B;
+ }
+
+ pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
+
+ if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14))
+ pDevice->uChannel = sStartAPCmd.uChannel;
+
+ if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
+ pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
+ else
+ pMgmt->wIBSSBeaconPeriod = 100;
+
+ if (sStartAPCmd.bShareKeyAuth == TRUE){
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
+ }
+ else {
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
+ }
+ memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
+
+ if (sStartAPCmd.byBasicRate & BIT3) {
+ pMgmt->abyIBSSSuppRates[2] |= BIT7;
+ pMgmt->abyIBSSSuppRates[3] |= BIT7;
+ pMgmt->abyIBSSSuppRates[4] |= BIT7;
+ pMgmt->abyIBSSSuppRates[5] |= BIT7;
+ }else if (sStartAPCmd.byBasicRate & BIT2) {
+ pMgmt->abyIBSSSuppRates[2] |= BIT7;
+ pMgmt->abyIBSSSuppRates[3] |= BIT7;
+ pMgmt->abyIBSSSuppRates[4] |= BIT7;
+ }else if (sStartAPCmd.byBasicRate & BIT1) {
+ pMgmt->abyIBSSSuppRates[2] |= BIT7;
+ pMgmt->abyIBSSSuppRates[3] |= BIT7;
+ }else if (sStartAPCmd.byBasicRate & BIT1) {
+ pMgmt->abyIBSSSuppRates[2] |= BIT7;
+ }else {
+ //default 1,2M
+ pMgmt->abyIBSSSuppRates[2] |= BIT7;
+ pMgmt->abyIBSSSuppRates[3] |= BIT7;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
+ pMgmt->abyIBSSSuppRates[2],
+ pMgmt->abyIBSSSuppRates[3],
+ pMgmt->abyIBSSSuppRates[4],
+ pMgmt->abyIBSSSuppRates[5]
+ );
+
+ netif_stop_queue(pDevice->dev);
+ spin_lock_irq(&pDevice->lock);
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+
+ case WLAN_CMD_GET_NODE_CNT:
+
+ cbListCount = 0;
+ pNode = &(pMgmt->sNodeDBTable[0]);
+ for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
+ pNode = &(pMgmt->sNodeDBTable[ii]);
+ if (!pNode->bActive)
+ continue;
+ cbListCount++;
+ };
+
+ sNodeList.uItem = cbListCount;
+ if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
+ result = -EFAULT;
+ break;
+ };
+ pReq->wResult = 0;
+ break;
+
+ case WLAN_CMD_GET_NODE_LIST:
+
+ if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
+ result = -EFAULT;
+ break;
+ };
+ pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
+ if (pNodeList == NULL) {
+ result = -ENOMEM;
+ break;
+ }
+ pNodeList->uItem = sNodeList.uItem;
+ pNode = &(pMgmt->sNodeDBTable[0]);
+ for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
+ pNode = &(pMgmt->sNodeDBTable[ii]);
+ if (pNode->bActive) {
+ pNodeList->sNodeList[jj].wAID = pNode->wAID;
+ memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
+ pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
+ pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;
+ pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;
+ pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;
+ pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
+ pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
+ pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
+ memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+ pNodeList->sNodeList[jj].abyWepKey[0],
+ pNodeList->sNodeList[jj].abyWepKey[1],
+ pNodeList->sNodeList[jj].abyWepKey[2],
+ pNodeList->sNodeList[jj].abyWepKey[3],
+ pNodeList->sNodeList[jj].abyWepKey[4]
+ );
+ pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
+ pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
+ pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
+ pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;
+ jj ++;
+ if (jj >= pNodeList->uItem)
+ break;
+ }
+ };
+ if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
+ result = -EFAULT;
+ break;
+ };
+ kfree(pNodeList);
+ pReq->wResult = 0;
+ break;
+
+#ifdef WPA_SM_Transtatus
+ case 0xFF:
+ memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
+ wpa_Result.proto = 0;
+ wpa_Result.key_mgmt = 0;
+ wpa_Result.eap_type = 0;
+ wpa_Result.authenticated = FALSE;
+ pDevice->fWPA_Authened = FALSE;
+ if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
+ result = -EFAULT;
+ break;
+ }
+
+ if(wpa_Result.authenticated==TRUE) {
+ #ifdef SndEvt_ToAPI
+ {
+ union iwreq_data wrqu;
+
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
+ wrqu.data.length =pItemSSID->len;
+ wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
+ }
+ #endif
+ pDevice->fWPA_Authened = TRUE; //is sucessful peer to wpa_Result.authenticated?
+}
+
+ //printk("get private wpa_supplicant announce WPA SM\n");
+ //printk("wpa-->ifname=%s\n",wpa_Result.ifname);
+ //printk("wpa-->proto=%d\n",wpa_Result.proto);
+ //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt);
+ //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type);
+ //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE");
+
+ pReq->wResult = 0;
+ break;
+#endif
+
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
+ }
+
+ return result;
+}
+
+/*
+VOID
+vConfigWEPKey (
+ IN PSDevice pDevice,
+ IN DWORD dwKeyIndex,
+ IN PBYTE pbyKey,
+ IN ULONG uKeyLength
+ )
+{
+ int ii;
+
+
+ ZERO_MEMORY(&pDevice->abyWepKey[dwKeyIndex][0], WLAN_WEPMAX_KEYLEN);
+ MEMvCopy(&pDevice->abyWepKey[dwKeyIndex][0], pbyKey, uKeyLength);
+
+ pDevice->bWepKeyAvailable[dwKeyIndex] = TRUE;
+ pDevice->auWepKeyLength[dwKeyIndex] = uKeyLength;
+
+ MACvSetDefaultKeyEntry(pDevice->PortOffset, uKeyLength, dwKeyIndex,
+ (PDWORD) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID);
+
+ if (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported) {
+ for(ii=0; ii<MAX_GROUP_KEY; ii++) {
+ if ((pDevice->bWepKeyAvailable[ii] == TRUE) &&
+ (pDevice->auWepKeyLength[ii] == WLAN_WEP232_KEYLEN)) {
+ pDevice->uCurrentWEPMode = TX_WEP_SW232;
+ MACvDisableDefaultKey(pDevice->PortOffset);
+ break;
+ }
+ }
+ if ((ii == MAX_GROUP_KEY) &&
+ (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported)) {
+ MACvEnableDefaultKey(pDevice->PortOffset, pDevice->byLocalID);
+ }
+ }
+}
+*/
diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h
new file mode 100644
index 000000000000..9c6816eab46c
--- /dev/null
+++ b/drivers/staging/vt6655/ioctl.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: hostap.h
+ *
+ * Purpose:
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 21, 2003
+ *
+ */
+
+
+#ifndef __IOCTL_H__
+#define __IOCTL_H__
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+int private_ioctl(PSDevice pDevice, struct ifreq *rq);
+
+/*
+VOID vConfigWEPKey (
+ IN PSDevice pDevice,
+ IN DWORD dwKeyIndex,
+ IN PBYTE pbyKey,
+ IN ULONG uKeyLength
+ );
+*/
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __IOCTL_H__
+
+
+
diff --git a/drivers/staging/vt6655/iowpa.h b/drivers/staging/vt6655/iowpa.h
new file mode 100644
index 000000000000..451e2efc5ce5
--- /dev/null
+++ b/drivers/staging/vt6655/iowpa.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: iowpa.h
+ *
+ * Purpose: Handles wpa supplicant ioctl interface
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2002
+ *
+ */
+
+#ifndef __IOWPA_H__
+#define __IOWPA_H__
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+#define WPA_IE_LEN 64
+
+
+//WPA related
+/*
+typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg;
+typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
+ CIPHER_WEP104 } wpa_cipher;
+typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
+ KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt;
+*/
+
+enum {
+ VIAWGET_SET_WPA = 1,
+ VIAWGET_SET_KEY = 2,
+ VIAWGET_SET_SCAN = 3,
+ VIAWGET_GET_SCAN = 4,
+ VIAWGET_GET_SSID = 5,
+ VIAWGET_GET_BSSID = 6,
+ VIAWGET_SET_DROP_UNENCRYPT = 7,
+ VIAWGET_SET_DEAUTHENTICATE = 8,
+ VIAWGET_SET_ASSOCIATE = 9,
+ VIAWGET_SET_DISASSOCIATE= 10
+};
+
+
+enum {
+ VIAWGET_ASSOC_MSG = 1,
+ VIAWGET_DISASSOC_MSG = 2,
+ VIAWGET_PTK_MIC_MSG = 3,
+ VIAWGET_GTK_MIC_MSG = 4,
+ VIAWGET_CCKM_ROAM_MSG = 5,
+ VIAWGET_DEVICECLOSE_MSG = 6
+};
+
+
+
+#pragma pack(1)
+typedef struct viawget_wpa_header {
+ u8 type;
+ u16 req_ie_len;
+ u16 resp_ie_len;
+} viawget_wpa_header;
+
+
+
+struct viawget_wpa_param {
+ u32 cmd;
+ u8 addr[6];
+ union {
+ struct {
+ u8 len;
+ u8 data[0];
+ } generic_elem;
+
+ struct {
+ u8 bssid[6];
+ u8 ssid[32];
+ u8 ssid_len;
+ u8 *wpa_ie;
+ u16 wpa_ie_len;
+ int pairwise_suite;
+ int group_suite;
+ int key_mgmt_suite;
+ int auth_alg;
+ int mode;
+
+ } wpa_associate;
+
+ struct {
+ int alg_name;
+ u16 key_index;
+ u16 set_tx;
+ u8 *seq;
+ u16 seq_len;
+ u8 *key;
+ u16 key_len;
+ } wpa_key;
+
+ struct {
+ u8 ssid_len;
+ u8 ssid[32];
+ } scan_req;
+
+ struct {
+ u16 scan_count;
+ u8 *buf;
+ } scan_results;
+
+ } u;
+
+};
+
+#pragma pack(1)
+struct viawget_scan_result {
+ u8 bssid[6];
+ u8 ssid[32];
+ u16 ssid_len;
+ u8 wpa_ie[WPA_IE_LEN];
+ u16 wpa_ie_len;
+ u8 rsn_ie[WPA_IE_LEN];
+ u16 rsn_ie_len;
+ int freq; // MHz
+ int caps; // e.g. privacy
+ int qual; // signal quality
+ int noise;
+ int level;
+ int maxrate;
+};
+
+//2006-1116-01,<Add> by NomadZhao
+#pragma pack()
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+#endif //__IOWPA_H__
diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
new file mode 100644
index 000000000000..160baf0abc09
--- /dev/null
+++ b/drivers/staging/vt6655/iwctl.c
@@ -0,0 +1,2453 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: iwctl.c
+ *
+ * Purpose: wireless ext & ioctl functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 5, 2006
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__IOCTL_H__)
+#include "ioctl.h"
+#endif
+#if !defined(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+#if !defined(__WPACTL_H__)
+#include "wpactl.h"
+#endif
+#endif
+
+#if WIRELESS_EXT > 12
+#include <net/iw_handler.h>
+#endif
+extern WORD TxRate_iwconfig;//2008-5-8 <add> by chester
+
+/*--------------------- Static Definitions -------------------------*/
+
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#define SUPPORTED_WIRELESS_EXT 18
+#else
+#define SUPPORTED_WIRELESS_EXT 17
+#endif
+
+#ifdef WIRELESS_EXT
+
+static const long frequency_list[] = {
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
+ 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
+ 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
+ 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
+ 5700, 5745, 5765, 5785, 5805, 5825
+ };
+
+#endif
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+
+/*--------------------- Static Variables --------------------------*/
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+#ifdef WIRELESS_EXT
+
+#if WIRELESS_EXT > 12
+
+struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
+{
+ PSDevice pDevice = dev->priv;
+ long ldBm;
+ pDevice->wstats.status = pDevice->eOPMode;
+ #ifdef Calcu_LinkQual
+ #if 0
+ if(pDevice->byBBType == BB_TYPE_11B) {
+ if(pDevice->byCurrSQ > 120)
+ pDevice->scStatistic.LinkQuality = 100;
+ else
+ pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
+ }
+ else if(pDevice->byBBType == BB_TYPE_11G) {
+ if(pDevice->byCurrSQ < 20)
+ pDevice->scStatistic.LinkQuality = 100;
+ else if(pDevice->byCurrSQ >96)
+ pDevice->scStatistic.LinkQuality = 0;
+ else
+ pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
+ }
+ if(pDevice->bLinkPass !=TRUE)
+ pDevice->scStatistic.LinkQuality = 0;
+ #endif
+ if(pDevice->scStatistic.LinkQuality > 100)
+ pDevice->scStatistic.LinkQuality = 100;
+ pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
+ #else
+ pDevice->wstats.qual.qual = pDevice->byCurrSQ;
+ #endif
+ RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
+ pDevice->wstats.qual.level = ldBm;
+ //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
+ pDevice->wstats.qual.noise = 0;
+ pDevice->wstats.qual.updated = 1;
+ pDevice->wstats.discard.nwid = 0;
+ pDevice->wstats.discard.code = 0;
+ pDevice->wstats.discard.fragment = 0;
+ pDevice->wstats.discard.retries = (U32)pDevice->scStatistic.dwTsrErr;
+ pDevice->wstats.discard.misc = 0;
+ pDevice->wstats.miss.beacon = 0;
+
+ return &pDevice->wstats;
+}
+
+#endif
+
+
+
+/*------------------------------------------------------------------*/
+
+
+static int iwctl_commit(struct net_device *dev,
+ struct iw_request_info *info,
+ void *wrq,
+ char *extra)
+{
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWCOMMIT \n");
+
+ return 0;
+
+}
+
+/*
+ * Wireless Handler : get protocol name
+ */
+
+int iwctl_giwname(struct net_device *dev,
+ struct iw_request_info *info,
+ char *wrq,
+ char *extra)
+{
+ strcpy(wrq, "802.11-a/b/g");
+ return 0;
+}
+
+int iwctl_giwnwid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ //wrq->value = 0x100;
+ //wrq->disabled = 0;
+ //wrq->fixed = 1;
+ //return 0;
+ return -EOPNOTSUPP;
+}
+#if WIRELESS_EXT > 13
+
+/*
+ * Wireless Handler : set scan
+ */
+
+int iwctl_siwscan(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ struct iw_scan_req *req = (struct iw_scan_req *)extra;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ PWLAN_IE_SSID pItemSSID=NULL;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSCAN \n");
+
+
+if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
+//send scan event to wpa_Supplicant
+ union iwreq_data wrqu;
+ printk("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
+ memset(&wrqu, 0, sizeof(wrqu));
+ wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
+ return 0;
+}
+
+ spin_lock_irq(&pDevice->lock);
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+
+//mike add: active scan OR passive scan OR desire_ssid scan
+ if(wrq->length == sizeof(struct iw_scan_req)) {
+ if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
+ memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
+ pItemSSID->byElementID = WLAN_EID_SSID;
+ memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
+ if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
+ if(req->essid_len>0)
+ pItemSSID->len = req->essid_len - 1;
+ }
+ else
+ pItemSSID->len = req->essid_len;
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ printk("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
+ ((PWLAN_IE_SSID)abyScanSSID)->len);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
+ spin_unlock_irq(&pDevice->lock);
+
+ return 0;
+ }
+ else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ }
+ }
+ else { //active scan
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ }
+
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ spin_unlock_irq(&pDevice->lock);
+
+ return 0;
+}
+
+
+/*
+ * Wireless Handler : get scan results
+ */
+
+int iwctl_giwscan(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ int ii, jj, kk;
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PKnownBSS pBSS;
+ PWLAN_IE_SSID pItemSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
+ char *current_ev = extra;
+ char *end_buf = extra + IW_SCAN_MAX_DATA;
+ char *current_val = NULL;
+ struct iw_event iwe;
+ long ldBm;
+#if WIRELESS_EXT > 14
+ char buf[MAX_WPA_IE_LEN * 2 + 30];
+#endif /* WIRELESS_EXT > 14 */
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN \n");
+
+ if (pMgmt->eScanState == WMAC_IS_SCANNING) {
+ // In scanning..
+ return -EAGAIN;
+ }
+ pBSS = &(pMgmt->sBSSList[0]);
+ for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
+ if (current_ev >= end_buf)
+ break;
+ pBSS = &(pMgmt->sBSSList[jj]);
+ if (pBSS->bActive) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWAP;
+ iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+ memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
+ #else
+ current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
+ #endif
+ //ADD ssid
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWESSID;
+ pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
+ iwe.u.data.length = pItemSSID->len;
+ iwe.u.data.flags = 1;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
+ #else
+ current_ev = iwe_stream_add_point(current_ev,end_buf, &iwe, pItemSSID->abySSID);
+ #endif
+ //ADD mode
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWMODE;
+ if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
+ iwe.u.mode = IW_MODE_INFRA;
+ }
+ else {
+ iwe.u.mode = IW_MODE_ADHOC;
+ }
+ iwe.len = IW_EV_UINT_LEN;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
+ #else
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
+ #endif
+ //ADD frequency
+ pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
+ pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWFREQ;
+ iwe.u.freq.m = pBSS->uChannel;
+ iwe.u.freq.e = 0;
+ iwe.u.freq.i = 0;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ #else
+ current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ #endif
+
+
+ //2008-0409-04, <Add> by Einsn Liu
+ {
+ int f = (int)pBSS->uChannel - 1;
+ if(f < 0)f = 0;
+ iwe.u.freq.m = frequency_list[f] * 100000;
+ iwe.u.freq.e = 1;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ #else
+ current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ #endif
+ //ADD quality
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVQUAL;
+ RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
+ iwe.u.qual.level = ldBm;
+ iwe.u.qual.noise = 0;
+//2008-0409-01, <Add> by Einsn Liu
+ if(-ldBm<50){
+ iwe.u.qual.qual = 100;
+ }else if(-ldBm > 90) {
+ iwe.u.qual.qual = 0;
+ }else {
+ iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
+ }
+ iwe.u.qual.updated=7;
+
+ // iwe.u.qual.qual = 0;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+ #else
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+ #endif
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWENCODE;
+ iwe.u.data.length = 0;
+ if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
+ iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+ }else {
+ iwe.u.data.flags = IW_ENCODE_DISABLED;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
+ #else
+ current_ev = iwe_stream_add_point(current_ev,end_buf, &iwe, pItemSSID->abySSID);
+ #endif
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWRATE;
+ iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
+ current_val = current_ev + IW_EV_LCP_LEN;
+
+ for (kk = 0 ; kk < 12 ; kk++) {
+ if (pSuppRates->abyRates[kk] == 0)
+ break;
+ // Bit rate given in 500 kb/s units (+ 0x80)
+ iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ #else
+ current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ #endif
+ }
+ for (kk = 0 ; kk < 8 ; kk++) {
+ if (pExtSuppRates->abyRates[kk] == 0)
+ break;
+ // Bit rate given in 500 kb/s units (+ 0x80)
+ iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ #else
+ current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ #endif
+ }
+
+ if((current_val - current_ev) > IW_EV_LCP_LEN)
+ current_ev = current_val;
+
+#if WIRELESS_EXT > 14
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
+ iwe.u.data.length = strlen(buf);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
+ #else
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
+ #endif
+
+#if WIRELESS_EXT > 17
+ if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = pBSS->wWPALen;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
+ #else
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, pBSS->byWPAIE);
+ #endif
+ }
+
+ if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = pBSS->wRSNLen;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
+ #else
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, pBSS->byRSNIE);
+ #endif
+ }
+
+#else // WIRELESS_EXT > 17
+ if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
+ u8 *p = buf;
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ p += sprintf(p, "wpa_ie=");
+ for (ii = 0; ii < pBSS->wWPALen; ii++) {
+ p += sprintf(p, "%02x", pBSS->byWPAIE[ii]);
+ }
+ iwe.u.data.length = strlen(buf);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
+ #else
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
+ #endif
+ }
+
+
+ if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
+ u8 *p = buf;
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ p += sprintf(p, "rsn_ie=");
+ for (ii = 0; ii < pBSS->wRSNLen; ii++) {
+ p += sprintf(p, "%02x", pBSS->byRSNIE[ii]);
+ }
+ iwe.u.data.length = strlen(buf);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
+ #else
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
+ #endif
+ }
+#endif
+#endif
+ }
+ }// for
+
+ wrq->length = current_ev - extra;
+ return 0;
+
+}
+
+#endif /* WIRELESS_EXT > 13 */
+
+
+/*
+ * Wireless Handler : set frequence or channel
+ */
+
+int iwctl_siwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ int rc = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
+
+ // If setting by frequency, convert to a channel
+ if((wrq->e == 1) &&
+ (wrq->m >= (int) 2.412e8) &&
+ (wrq->m <= (int) 2.487e8)) {
+ int f = wrq->m / 100000;
+ int c = 0;
+ while((c < 14) && (f != frequency_list[c]))
+ c++;
+ wrq->e = 0;
+ wrq->m = c + 1;
+ }
+ // Setting by channel number
+ if((wrq->m > 14) || (wrq->e > 0))
+ rc = -EOPNOTSUPP;
+ else {
+ int channel = wrq->m;
+ if((channel < 1) || (channel > 14)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
+ rc = -EINVAL;
+ } else {
+ // Yes ! We can set it !!!
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
+ pDevice->uChannel = channel;
+ //2007-0207-04,<Add> by EinsnLiu
+ //Make change effect at once
+ pDevice->bCommit = TRUE;
+ }
+ }
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get frequence or channel
+ */
+
+int iwctl_giwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
+
+#ifdef WEXT_USECHANNELS
+ wrq->m = (int)pMgmt->uCurrChannel;
+ wrq->e = 0;
+#else
+ {
+ int f = (int)pMgmt->uCurrChannel - 1;
+ if(f < 0)
+ f = 0;
+ wrq->m = frequency_list[f] * 100000;
+ wrq->e = 1;
+ }
+#endif
+
+ return 0;
+}
+
+/*
+ * Wireless Handler : set operation mode
+ */
+
+int iwctl_siwmode(struct net_device *dev,
+ struct iw_request_info *info,
+ __u32 *wmode,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
+ return rc;
+ }
+
+ switch(*wmode) {
+
+ case IW_MODE_ADHOC:
+ if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
+ pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ pDevice->bCommit = TRUE;
+ }
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
+ break;
+ case IW_MODE_AUTO:
+ case IW_MODE_INFRA:
+ if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ pDevice->bCommit = TRUE;
+ }
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
+ break;
+ case IW_MODE_MASTER:
+
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ rc = -EOPNOTSUPP;
+ break;
+
+ if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
+ pMgmt->eConfigMode = WMAC_CONFIG_AP;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ pDevice->bCommit = TRUE;
+ }
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
+ break;
+
+ case IW_MODE_REPEAT:
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ rc = -EOPNOTSUPP;
+ break;
+ default:
+ rc = -EINVAL;
+ }
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get operation mode
+ */
+
+int iwctl_giwmode(struct net_device *dev,
+ struct iw_request_info *info,
+ __u32 *wmode,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
+ // If not managed, assume it's ad-hoc
+ switch (pMgmt->eConfigMode) {
+ case WMAC_CONFIG_ESS_STA:
+ *wmode = IW_MODE_INFRA;
+ break;
+ case WMAC_CONFIG_IBSS_STA:
+ *wmode = IW_MODE_ADHOC;
+ break;
+ case WMAC_CONFIG_AUTO:
+ *wmode = IW_MODE_INFRA;
+ break;
+ case WMAC_CONFIG_AP:
+ *wmode = IW_MODE_MASTER;
+ break;
+ default:
+ *wmode = IW_MODE_ADHOC;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Wireless Handler : get capability range
+ */
+
+int iwctl_giwrange(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ struct iw_range *range = (struct iw_range *) extra;
+ int i,k;
+ BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE \n");
+ if (wrq->pointer) {
+ wrq->length = sizeof(struct iw_range);
+ memset(range, 0, sizeof(struct iw_range));
+ range->min_nwid = 0x0000;
+ range->max_nwid = 0x0000;
+ range->num_channels = 14;
+ // Should be based on cap_rid.country to give only
+ // what the current card support
+ k = 0;
+ for(i = 0; i < 14; i++) {
+ range->freq[k].i = i + 1; // List index
+ range->freq[k].m = frequency_list[i] * 100000;
+ range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
+ }
+ range->num_frequency = k;
+ // Hum... Should put the right values there
+ #ifdef Calcu_LinkQual
+ range->max_qual.qual = 100;
+ #else
+ range->max_qual.qual = 255;
+ #endif
+ range->max_qual.level = 0;
+ range->max_qual.noise = 0;
+ range->sensitivity = 255;
+
+ for(i = 0 ; i < 13 ; i++) {
+ range->bitrate[i] = abySupportedRates[i] * 500000;
+ if(range->bitrate[i] == 0)
+ break;
+ }
+ range->num_bitrates = i;
+
+ // Set an indication of the max TCP throughput
+ // in bit/s that we can expect using this interface.
+ // May be use for QoS stuff... Jean II
+ if(i > 2)
+ range->throughput = 5 * 1000 * 1000;
+ else
+ range->throughput = 1.5 * 1000 * 1000;
+
+ range->min_rts = 0;
+ range->max_rts = 2312;
+ range->min_frag = 256;
+ range->max_frag = 2312;
+
+
+ // the encoding capabilities
+ range->num_encoding_sizes = 3;
+ // 64(40) bits WEP
+ range->encoding_size[0] = 5;
+ // 128(104) bits WEP
+ range->encoding_size[1] = 13;
+ // 256 bits for WPA-PSK
+ range->encoding_size[2] = 32;
+ // 4 keys are allowed
+ range->max_encoding_tokens = 4;
+
+#if WIRELESS_EXT > 17
+ range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
+ IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+#endif
+
+#if WIRELESS_EXT > 9
+ range->min_pmp = 0;
+ range->max_pmp = 1000000;// 1 secs
+ range->min_pmt = 0;
+ range->max_pmt = 1000000;// 1 secs
+ range->pmp_flags = IW_POWER_PERIOD;
+ range->pmt_flags = IW_POWER_TIMEOUT;
+ range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
+
+ // Transmit Power - values are in mW
+
+ range->txpower[0] = 100;
+ range->num_txpower = 1;
+ range->txpower_capa = IW_TXPOW_MWATT;
+#endif // WIRELESS_EXT > 9
+#if WIRELESS_EXT > 10
+ range->we_version_source = SUPPORTED_WIRELESS_EXT;
+ range->we_version_compiled = WIRELESS_EXT;
+ range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
+ range->retry_flags = IW_RETRY_LIMIT;
+ range->r_time_flags = IW_RETRY_LIFETIME;
+ range->min_retry = 1;
+ range->max_retry = 65535;
+ range->min_r_time = 1024;
+ range->max_r_time = 65535 * 1024;
+#endif // WIRELESS_EXT > 10
+#if WIRELESS_EXT > 11
+ // Experimental measurements - boundary 11/5.5 Mb/s
+ // Note : with or without the (local->rssi), results
+ // are somewhat different. - Jean II
+ range->avg_qual.qual = 6;
+ range->avg_qual.level = 176; // -80 dBm
+ range->avg_qual.noise = 0;
+#endif // WIRELESS_EXT > 11
+ }
+
+
+ return 0;
+}
+
+
+/*
+ * Wireless Handler : set ap mac address
+ */
+
+int iwctl_siwap(struct net_device *dev,
+ struct iw_request_info *info,
+ struct sockaddr *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+ BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAP \n");
+if (pMgmt->eScanState == WMAC_IS_SCANNING) {
+ // In scanning..
+ printk("SIOCSIWAP(??)-->In scanning...\n");
+ // return -EAGAIN;
+ }
+ if (wrq->sa_family != ARPHRD_ETHER)
+ rc = -EINVAL;
+ else {
+ memset(pMgmt->abyDesireBSSID, 0xFF, 6);
+ memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
+ //2008-0409-05, <Add> by Einsn Liu
+ if((pDevice->bLinkPass == TRUE) &&
+ (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6)== 0)){
+ return rc;
+ }
+ //mike :add
+ if ((IS_BROADCAST_ADDRESS(pMgmt->abyDesireBSSID)) ||
+ (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
+ printk("SIOCSIWAP:invalid desired BSSID return!\n");
+ return rc;
+ }
+ //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
+ // then ignore,because you don't known which one to be connect with??
+ {
+ UINT ii , uSameBssidNum=0;
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (pMgmt->sBSSList[ii].bActive &&
+ IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID,pMgmt->abyDesireBSSID)) {
+ uSameBssidNum++;
+ }
+ }
+ if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
+ printk("SIOCSIWAP:ignore for desired AP in hidden mode\n");
+ return rc;
+ }
+ }
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ pDevice->bCommit = TRUE;
+ }
+ }
+ return rc;
+}
+
+/*
+ * Wireless Handler : get ap mac address
+ */
+
+int iwctl_giwap(struct net_device *dev,
+ struct iw_request_info *info,
+ struct sockaddr *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
+
+ memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
+ //2008-0410,<Modify> by Einsn Liu
+ if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
+ memset(wrq->sa_data, 0, 6);
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
+ }
+
+ wrq->sa_family = ARPHRD_ETHER;
+
+ return 0;
+
+}
+
+
+/*
+ * Wireless Handler : get ap list
+ */
+
+int iwctl_giwaplist(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ int ii,jj, rc = 0;
+ struct sockaddr sock[IW_MAX_AP];
+ struct iw_quality qual[IW_MAX_AP];
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
+ // Only super-user can see AP list
+
+ if (!capable(CAP_NET_ADMIN)) {
+ rc = -EPERM;
+ return rc;
+ }
+
+ if (wrq->pointer) {
+
+ PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
+
+ for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
+ pBSS = &(pMgmt->sBSSList[ii]);
+ if (!pBSS->bActive)
+ continue;
+ if ( jj >= IW_MAX_AP)
+ break;
+ memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
+ sock[jj].sa_family = ARPHRD_ETHER;
+ qual[jj].level = pBSS->uRSSI;
+ qual[jj].qual = qual[jj].noise = 0;
+ qual[jj].updated = 2;
+ jj++;
+ }
+
+ wrq->flags = 1; // Should be define'd
+ wrq->length = jj;
+ memcpy(extra, sock, sizeof(struct sockaddr)*jj);
+ memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
+ }
+
+ return rc;
+}
+
+
+/*
+ * Wireless Handler : set essid
+ */
+
+int iwctl_siwessid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
+ //2008-0409-05, <Add> by Einsn Liu
+ BYTE len;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID \n");
+ pDevice->fWPA_Authened = FALSE;
+if (pMgmt->eScanState == WMAC_IS_SCANNING) {
+ // In scanning..
+ printk("SIOCSIWESSID(??)-->In scanning...\n");
+ // return -EAGAIN;
+ }
+ // Check if we asked for `any'
+ if(wrq->flags == 0) {
+ // Just send an empty SSID list
+ // Just send an empty SSID list
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ printk("set essid to 'any' \n");
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //Unknown desired AP,so here need not associate??
+ //if(pDevice->bWPASuppWextEnabled == TRUE) {
+ return 0;
+ // }
+ #endif
+ } else {
+ // Set the SSID
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pItemSSID->byElementID = WLAN_EID_SSID;
+ memcpy(pItemSSID->abySSID, extra, wrq->length);
+ if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
+ if(wrq->length>0)
+ pItemSSID->len = wrq->length - 1;
+ }
+ else
+ pItemSSID->len = wrq->length;
+ printk("set essid to %s \n",pItemSSID->abySSID);
+ //2008-0409-05, <Add> by Einsn Liu
+ len=(pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)?pItemSSID->len:((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len;
+ if((pDevice->bLinkPass == TRUE) &&
+ (memcmp(pItemSSID->abySSID,((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,len)==0))
+ return 0;
+
+ //mike:need clear desiredBSSID
+ if(pItemSSID->len==0) {
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ return 0;
+ }
+
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //Wext wil order another command of siwap to link with desired AP,
+ //so here need not associate??
+ if(pDevice->bWPASuppWextEnabled == TRUE) {
+ /*******search if in hidden ssid mode ****/
+ {
+ PKnownBSS pCurr = NULL;
+ BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ UINT ii , uSameBssidNum=0;
+
+ memset(abyTmpDesireSSID,0,sizeof(abyTmpDesireSSID));
+ memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
+ pCurr = BSSpSearchBSSList(pDevice,
+ NULL,
+ abyTmpDesireSSID,
+ pMgmt->eConfigPHYMode
+ );
+
+ if (pCurr == NULL){
+ printk("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
+ vResetCommandTimer((HANDLE) pDevice);
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
+ }
+ else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
+ // by means of judging if there are two same BSSID exist in list ?
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (pMgmt->sBSSList[ii].bActive &&
+ IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
+ uSameBssidNum++;
+ }
+ }
+ if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
+ printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
+ vResetCommandTimer((HANDLE) pDevice);
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
+ }
+ }
+ }
+ return 0;
+ }
+ #endif
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
+/*
+ #if WIRELESS_EXT < 21
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO " SIOCSIWESSID1 \n");
+ pItemSSID->len = wrq->length - 1;
+ #else
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO " SIOCSIWESSID2 \n");
+ pItemSSID->len = wrq->length;
+ #endif
+ */
+ }
+
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ pDevice->bCommit = TRUE;
+ }
+
+
+ return 0;
+}
+
+
+/*
+ * Wireless Handler : get essid
+ */
+
+int iwctl_giwessid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
+
+ // Note : if wrq->u.data.flags != 0, we should
+ // get the relevant SSID from the SSID list...
+
+ // Get the current SSID
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
+ extra[pItemSSID->len] = '\0';
+ wrq->length = pItemSSID->len + 1;
+ //2008-0409-03, <Add> by Einsn Liu
+ #if WIRELESS_EXT < 21
+ wrq->length = pItemSSID->len + 1;
+ #else
+ wrq->length = pItemSSID->len;
+ #endif
+ wrq->flags = 1; // active
+
+
+ return 0;
+}
+
+/*
+ * Wireless Handler : set data rate
+ */
+
+int iwctl_siwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ int rc = 0;
+ u8 brate = 0;
+ int i;
+ BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ // First : get a valid bit rate value
+
+ // Which type of value
+ if((wrq->value < 13) &&
+ (wrq->value >= 0)) {
+ // Setting by rate index
+ // Find value in the magic rate table
+ brate = wrq->value;
+ } else {
+ // Setting by frequency value
+ u8 normvalue = (u8) (wrq->value/500000);
+
+ // Check if rate is valid
+ for(i = 0 ; i < 13 ; i++) {
+ if(normvalue == abySupportedRates[i]) {
+ brate = i;
+ break;
+ }
+ }
+ }
+ // -1 designed the max rate (mostly auto mode)
+ if(wrq->value == -1) {
+ // Get the highest available rate
+ for(i = 0 ; i < 13 ; i++) {
+ if(abySupportedRates[i] == 0)
+ break;
+ }
+ if(i != 0)
+ brate = i - 1;
+
+ }
+ // Check that it is valid
+ // brate is index of abySupportedRates[]
+ if(brate > 13 ) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ // Now, check if we want a fixed or auto value
+ if(wrq->fixed != 0) {
+ // Fixed mode
+ // One rate, fixed
+ printk("Rate Fix\n");
+ pDevice->bFixRate = TRUE;
+ if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
+
+ pDevice->uConnectionRate = 3;
+ }
+ else {
+ pDevice->uConnectionRate = brate;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
+ }
+
+ }
+ else {
+ pDevice->bFixRate = FALSE;
+ pDevice->uConnectionRate = 13;
+ printk("auto rate:connection_rate is 13\n");
+}
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get data rate
+ */
+
+int iwctl_giwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+//2007-0118-05,<Mark> by EinsnLiu
+//Mark the unnecessary sentences.
+// PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
+ {
+ BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
+ int brate = 0;
+//2008-5-8 <modify> by chester
+if(pDevice->bLinkPass){
+if(pDevice->bFixRate == TRUE){
+ if (pDevice->uConnectionRate < 13) {
+ brate = abySupportedRates[pDevice->uConnectionRate];
+ }else {
+ if (pDevice->byBBType == BB_TYPE_11B)
+ brate = 0x16;
+ if (pDevice->byBBType == BB_TYPE_11G)
+ brate = 0x6C;
+ if (pDevice->byBBType == BB_TYPE_11A)
+ brate = 0x6C;
+ }
+}
+else
+{
+
+ brate = abySupportedRates[TxRate_iwconfig];
+}
+}
+else brate =0;
+//2007-0118-05,<Mark> by EinsnLiu
+//Mark the unnecessary sentences.
+/*
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (pDevice->byBBType == BB_TYPE_11B)
+ brate = 0x16;
+ if (pDevice->byBBType == BB_TYPE_11G)
+ brate = 0x6C;
+ if (pDevice->byBBType == BB_TYPE_11A)
+ brate = 0x6C;
+ }
+*/
+
+// if (pDevice->uConnectionRate == 13)
+// brate = abySupportedRates[pDevice->wCurrentRate];
+ wrq->value = brate * 500000;
+ // If more than one rate, set auto
+ if (pDevice->bFixRate == TRUE)
+ wrq->fixed = TRUE;
+ }
+
+
+ return 0;
+}
+
+
+
+/*
+ * Wireless Handler : set rts threshold
+ */
+
+int iwctl_siwrts(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ int rc = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n");
+
+ {
+ int rthr = wrq->value;
+ if(wrq->disabled)
+ rthr = 2312;
+ if((rthr < 0) || (rthr > 2312)) {
+ rc = -EINVAL;
+ }else {
+ pDevice->wRTSThreshold = rthr;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * Wireless Handler : get rts
+ */
+
+int iwctl_giwrts(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
+ wrq->value = pDevice->wRTSThreshold;
+ wrq->disabled = (wrq->value >= 2312);
+ wrq->fixed = 1;
+
+ return 0;
+}
+
+/*
+ * Wireless Handler : set fragment threshold
+ */
+
+int iwctl_siwfrag(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ int rc = 0;
+ int fthr = wrq->value;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
+
+
+ if (wrq->disabled)
+ fthr = 2312;
+ if((fthr < 256) || (fthr > 2312)) {
+ rc = -EINVAL;
+ }else {
+ fthr &= ~0x1; // Get an even value
+ pDevice->wFragmentationThreshold = (u16)fthr;
+ }
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get fragment threshold
+ */
+
+int iwctl_giwfrag(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
+ wrq->value = pDevice->wFragmentationThreshold;
+ wrq->disabled = (wrq->value >= 2312);
+ wrq->fixed = 1;
+
+ return 0;
+}
+
+
+
+/*
+ * Wireless Handler : set retry threshold
+ */
+int iwctl_siwretry(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ int rc = 0;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
+
+ if (wrq->disabled) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ if (wrq->flags & IW_RETRY_LIMIT) {
+ if(wrq->flags & IW_RETRY_MAX)
+ pDevice->byLongRetryLimit = wrq->value;
+ else if (wrq->flags & IW_RETRY_MIN)
+ pDevice->byShortRetryLimit = wrq->value;
+ else {
+ // No modifier : set both
+ pDevice->byShortRetryLimit = wrq->value;
+ pDevice->byLongRetryLimit = wrq->value;
+ }
+ }
+ if (wrq->flags & IW_RETRY_LIFETIME) {
+ pDevice->wMaxTransmitMSDULifetime = wrq->value;
+ }
+
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get retry threshold
+ */
+int iwctl_giwretry(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
+ wrq->disabled = 0; // Can't be disabled
+
+ // Note : by default, display the min retry number
+ if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
+ wrq->flags = IW_RETRY_LIFETIME;
+ wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
+ } else if((wrq->flags & IW_RETRY_MAX)) {
+ wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+ wrq->value = (int)pDevice->byLongRetryLimit;
+ } else {
+ wrq->flags = IW_RETRY_LIMIT;
+ wrq->value = (int)pDevice->byShortRetryLimit;
+ if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
+ wrq->flags |= IW_RETRY_MIN;
+ }
+
+
+ return 0;
+}
+
+
+/*
+ * Wireless Handler : set encode mode
+ */
+int iwctl_siwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
+ int ii,uu, rc = 0;
+ int index = (wrq->flags & IW_ENCODE_INDEX);
+
+//2007-0207-07,<Modify> by EinsnLiu
+//There are some problems when using iwconfig encode/key command to set the WEP key.
+//I almost rewrite this function.
+//now it support:(assume the wireless interface's name is eth0)
+//iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
+//iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
+//iwconfig eth0 key 1122334455 /*set key string to driver using index*/
+//iwconfig eth0 key restricted /*enable share key*/
+
+ PSKeyTable pkeytab;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
+
+if((wrq->flags & IW_ENCODE_DISABLED)==0){
+ //Not disable encryption
+
+ if (dwKeyIndex > WLAN_WEP_NKEYS) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ if(dwKeyIndex<1&&((wrq->flags&IW_ENCODE_NOKEY)==0)){//set default key
+ if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
+ dwKeyIndex=pDevice->byKeyIndex;
+ }
+ else dwKeyIndex=0;
+ }else dwKeyIndex--;
+
+
+ // Check the size of the key
+ if (wrq->length > WLAN_WEP232_KEYLEN) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ if(wrq->length>0){//have key
+
+ if (wrq->length == WLAN_WEP232_KEYLEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
+ }
+ else if (wrq->length == WLAN_WEP104_KEYLEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
+ }
+ else if (wrq->length == WLAN_WEP40_KEYLEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
+ }else {//no support length
+ rc = -EINVAL;
+ return rc;
+ }
+ memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
+ memcpy(pDevice->abyKey, extra, wrq->length);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
+ for (ii = 0; ii < wrq->length; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
+ }
+
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ KeybSetDefaultKey(&(pDevice->sKey),
+ (DWORD)(dwKeyIndex | (1 << 31)),
+ wrq->length,
+ NULL,
+ pDevice->abyKey,
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID
+ );
+ spin_unlock_irq(&pDevice->lock);
+ }
+ pDevice->byKeyIndex = (BYTE)dwKeyIndex;
+ pDevice->uKeyLength = wrq->length;
+ pDevice->bTransmitKey = TRUE;
+ pDevice->bEncryptionEnable = TRUE;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+
+ }else if(index>0){
+ //when the length is 0 the request only changes the default transmit key index
+ //check the new key has a non zero lenget
+ if(pDevice->bEncryptionEnable==FALSE)
+ {
+ rc = -EINVAL;
+ return rc;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Just set Default key Index:\n");
+ pkeytab=&(pDevice->sKey.KeyTable[MAX_KEY_TABLE-1]);
+ if(pkeytab->GroupKey[(BYTE)dwKeyIndex].uKeyLength==0){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Default key len is 0\n");
+ rc = -EINVAL;
+ return rc;
+ }
+ pDevice->byKeyIndex =(BYTE)dwKeyIndex;
+ pkeytab->dwGTKeyIndex =dwKeyIndex | (1 << 31);
+ pkeytab->GroupKey[(BYTE)dwKeyIndex].dwKeyIndex=dwKeyIndex | (1 << 31);
+ }
+
+}else {//disable the key
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
+ if(pDevice->bEncryptionEnable==FALSE)
+ return 0;
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ for(uu=0;uu<MAX_KEY_TABLE;uu++)
+ MACvDisableKeyEntry(pDevice->PortOffset, uu);
+ spin_unlock_irq(&pDevice->lock);
+ }
+}
+//End Modify,Einsn
+
+/*
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
+
+ // Check the size of the key
+ if (wrq->length > WLAN_WEP232_KEYLEN) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ if (dwKeyIndex > WLAN_WEP_NKEYS) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ if (dwKeyIndex > 0)
+ dwKeyIndex--;
+
+ // Send the key to the card
+ if (wrq->length > 0) {
+
+ if (wrq->length == WLAN_WEP232_KEYLEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
+ }
+ else if (wrq->length == WLAN_WEP104_KEYLEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
+ }
+ else if (wrq->length == WLAN_WEP40_KEYLEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
+ }
+ memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
+ memcpy(pDevice->abyKey, extra, wrq->length);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
+ for (ii = 0; ii < wrq->length; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
+ }
+
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ KeybSetDefaultKey(&(pDevice->sKey),
+ (DWORD)(pDevice->byKeyIndex | (1 << 31)),
+ pDevice->uKeyLength,
+ NULL,
+ pDevice->abyKey,
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID
+ );
+ spin_unlock_irq(&pDevice->lock);
+ }
+ pDevice->byKeyIndex = (BYTE)dwKeyIndex;
+ pDevice->uKeyLength = wrq->length;
+ pDevice->bTransmitKey = TRUE;
+ pDevice->bEncryptionEnable = TRUE;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+
+ // Do we want to just set the transmit key index ?
+ if ( index < 4 ) {
+ pDevice->byKeyIndex = index;
+ }
+ else if(!wrq->flags & IW_ENCODE_MODE) {
+ rc = -EINVAL;
+ return rc;
+ }
+ }
+ // Read the flags
+ if(wrq->flags & IW_ENCODE_DISABLED){
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ for(uu=0;uu<MAX_KEY_TABLE;uu++)
+ MACvDisableKeyEntry(pDevice->PortOffset, uu);
+ spin_unlock_irq(&pDevice->lock);
+ }
+ }
+*/
+
+ if(wrq->flags & IW_ENCODE_RESTRICTED) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ }
+ if(wrq->flags & IW_ENCODE_OPEN) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ }
+ return rc;
+}
+
+/*
+ * Wireless Handler : get encode mode
+ */
+ /*
+int iwctl_giwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+ char abyKey[WLAN_WEP232_KEYLEN];
+ UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
+ PSKeyItem pKey = NULL;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
+//2007-0207-06,<Add> by EinsnLiu
+//the key index in iwconfig is 1-4 when our driver is 0-3
+//so it can't be used directly.
+//if the index is 0,we should used the index set by driver.
+ if (index > WLAN_WEP_NKEYS) {
+ rc = -EINVAL;
+ return rc;
+ }
+ if(index<1){//set default key
+ if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
+ index=pDevice->byKeyIndex;
+ }
+ else index=0;
+ }else index--;
+//End Add,Einsn
+
+ memset(abyKey, 0, sizeof(abyKey));
+ // Check encryption mode
+ wrq->flags = IW_ENCODE_NOKEY;
+ // Is WEP enabled ???
+ if (pDevice->bEncryptionEnable)
+ wrq->flags |= IW_ENCODE_ENABLED;
+ else
+ wrq->flags |= IW_ENCODE_DISABLED;
+
+ if (pMgmt->bShareKeyAlgorithm)
+ wrq->flags |= IW_ENCODE_RESTRICTED;
+ else
+ wrq->flags |= IW_ENCODE_OPEN;
+
+ if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
+ wrq->length = pKey->uKeyLength;
+ memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
+//2007-0207-06,<Modify> by EinsnLiu
+//only get key success need to copy data
+//index should +1.
+//there is not necessary to return -EINVAL when get key failed
+//if return -EINVAL,the encryption item can't be display by the command "iwconfig".
+ wrq->flags |= index+1;
+ memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
+ }
+
+ //else {
+ // rc = -EINVAL;
+ // return rc;
+ // }
+
+
+//End Modify,Einsn
+
+ return 0;
+}
+*/
+
+//2008-0409-06, <Add> by Einsn Liu
+
+int iwctl_giwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ char abyKey[WLAN_WEP232_KEYLEN];
+
+ UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
+ PSKeyItem pKey = NULL;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
+
+ if (index > WLAN_WEP_NKEYS) {
+ return -EINVAL;
+ }
+ if(index<1){//get default key
+ if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
+ index=pDevice->byKeyIndex;
+ } else
+ index=0;
+ }else
+ index--;
+
+ memset(abyKey, 0, WLAN_WEP232_KEYLEN);
+ // Check encryption mode
+ wrq->flags = IW_ENCODE_NOKEY;
+ // Is WEP enabled ???
+ if (pDevice->bEncryptionEnable)
+ wrq->flags |= IW_ENCODE_ENABLED;
+ else
+ wrq->flags |= IW_ENCODE_DISABLED;
+
+ if (pMgmt->bShareKeyAlgorithm)
+ wrq->flags |= IW_ENCODE_RESTRICTED;
+ else
+ wrq->flags |= IW_ENCODE_OPEN;
+ wrq->length=0;
+
+ if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
+ pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
+ if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
+ wrq->length = pKey->uKeyLength;
+ memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
+ memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
+ }
+ }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
+ wrq->length = pKey->uKeyLength;
+ memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
+ memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
+ }
+
+ wrq->flags |= index+1;
+
+ return 0;
+}
+
+/*
+ * Wireless Handler : set power mode
+ */
+int iwctl_siwpower(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
+
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EINVAL;
+ return rc;
+ }
+
+ if (wrq->disabled) {
+ pDevice->ePSMode = WMAC_POWER_CAM;
+ PSvDisablePowerSaving(pDevice);
+ return rc;
+ }
+ if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
+ pDevice->ePSMode = WMAC_POWER_FAST;
+ PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
+
+ } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
+ pDevice->ePSMode = WMAC_POWER_FAST;
+ PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
+ }
+ switch (wrq->flags & IW_POWER_MODE) {
+ case IW_POWER_UNICAST_R:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
+ rc = -EINVAL;
+ break;
+ case IW_POWER_ALL_R:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
+ rc = -EINVAL;
+ case IW_POWER_ON:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
+ break;
+ default:
+ rc = -EINVAL;
+ }
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get power mode
+ */
+int iwctl_giwpower(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int mode = pDevice->ePSMode;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
+
+
+ if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
+ return 0;
+
+ if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
+ wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
+ wrq->flags = IW_POWER_TIMEOUT;
+ } else {
+ wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
+ wrq->flags = IW_POWER_PERIOD;
+ }
+ wrq->flags |= IW_POWER_ALL_R;
+
+ return 0;
+}
+
+
+/*
+ * Wireless Handler : get Sensitivity
+ */
+int iwctl_giwsens(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ long ldBm;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
+ if (pDevice->bLinkPass == TRUE) {
+ RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
+ wrq->value = ldBm;
+ }
+ else {
+ wrq->value = 0;
+ };
+ wrq->disabled = (wrq->value == 0);
+ wrq->fixed = 1;
+
+
+ return 0;
+}
+
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+
+int iwctl_siwauth(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int ret=0;
+ static int wpa_version=0; //must be static to save the last value,einsn liu
+ static int pairwise=0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
+ switch (wrq->flags & IW_AUTH_INDEX) {
+ case IW_AUTH_WPA_VERSION:
+ wpa_version = wrq->value;
+ if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
+ printk("iwctl_siwauth:set WPADEV to disable at 1??????\n");
+ //pDevice->bWPADevEnable = FALSE;
+ }
+ else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
+ printk("iwctl_siwauth:set WPADEV to WPA1******\n");
+ }
+ else {
+ printk("iwctl_siwauth:set WPADEV to WPA2******\n");
+ }
+ //pDevice->bWPASuppWextEnabled =TRUE;
+ break;
+ case IW_AUTH_CIPHER_PAIRWISE:
+ pairwise = wrq->value;
+
+ if(pairwise == IW_AUTH_CIPHER_CCMP){
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
+ }else if(pairwise == IW_AUTH_CIPHER_TKIP){
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
+ }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ }else if(pairwise == IW_AUTH_CIPHER_NONE){
+ //do nothing,einsn liu
+ }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+
+ break;
+ case IW_AUTH_CIPHER_GROUP:
+ if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
+ break;
+ if(pairwise == IW_AUTH_CIPHER_NONE){
+ if(wrq->value == IW_AUTH_CIPHER_CCMP){
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
+ }else {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
+ }
+ }
+ break;
+ case IW_AUTH_KEY_MGMT:
+
+ if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
+ if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
+ pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
+ else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
+ }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
+ if(wrq->value == 0){
+ pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
+ }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
+ pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
+ else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
+ }
+
+ break;
+ case IW_AUTH_TKIP_COUNTERMEASURES:
+ break; /* FIXME */
+ case IW_AUTH_DROP_UNENCRYPTED:
+ break;
+ case IW_AUTH_80211_AUTH_ALG:
+ if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
+ pMgmt->bShareKeyAlgorithm=FALSE;
+ }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
+ pMgmt->bShareKeyAlgorithm=TRUE;
+ }
+ break;
+ case IW_AUTH_WPA_ENABLED:
+ //pDevice->bWPADevEnable = !! wrq->value;
+ break;
+ case IW_AUTH_RX_UNENCRYPTED_EAPOL:
+ break;
+ case IW_AUTH_ROAMING_CONTROL:
+ ret = -EOPNOTSUPP;
+ break;
+ case IW_AUTH_PRIVACY_INVOKED:
+ pDevice->bEncryptionEnable = !!wrq->value;
+ if(pDevice->bEncryptionEnable == FALSE){
+ wpa_version = 0;
+ pairwise = 0;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ pMgmt->eAuthenMode = FALSE;
+ //pDevice->bWPADevEnable = FALSE;
+ }
+
+ break;
+ default:
+ ret = -EOPNOTSUPP;
+ break;
+ }
+/*
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"TRUE":"FALSE");
+*/
+ return ret;
+}
+
+
+int iwctl_giwauth(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra)
+{
+ return -EOPNOTSUPP;
+}
+
+
+
+int iwctl_siwgenie(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int ret=0;
+
+ if(wrq->length){
+ if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
+ ret = -EINVAL;
+ goto out;
+ }
+ if(wrq->length > MAX_WPA_IE_LEN){
+ ret = -ENOMEM;
+ goto out;
+ }
+ memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
+ if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
+ ret = -EFAULT;
+ goto out;
+ }
+ pMgmt->wWPAIELen = wrq->length;
+ }else {
+ memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
+ pMgmt->wWPAIELen = 0;
+ }
+
+ out://not completely ...not necessary in wpa_supplicant 0.5.8
+ return 0;
+}
+
+int iwctl_giwgenie(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int ret=0;
+ int space = wrq->length;
+
+ wrq->length = 0;
+ if(pMgmt->wWPAIELen > 0){
+ wrq->length = pMgmt->wWPAIELen;
+ if(pMgmt->wWPAIELen <= space){
+ if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
+ ret = -EFAULT;
+ }
+ }else
+ ret = -E2BIG;
+ }
+
+ return ret;
+}
+
+
+int iwctl_siwencodeext(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
+ struct viawget_wpa_param *param=NULL;
+//original member
+ wpa_alg alg_name;
+ u8 addr[6];
+ int key_idx, set_tx;
+ u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
+ u8 key[64];
+ size_t seq_len,key_len=0;
+//
+ // int ii;
+ u8 *buf;
+ size_t blen;
+ u8 key_array[64];
+ int ret=0;
+
+printk("SIOCSIWENCODEEXT...... \n");
+
+blen = sizeof(*param);
+buf = kmalloc((int)blen, (int)GFP_KERNEL);
+if (buf == NULL)
+ return -ENOMEM;
+memset(buf, 0, blen);
+param = (struct viawget_wpa_param *) buf;
+
+//recover alg_name
+switch (ext->alg) {
+ case IW_ENCODE_ALG_NONE:
+ alg_name = WPA_ALG_NONE;
+ break;
+ case IW_ENCODE_ALG_WEP:
+ alg_name = WPA_ALG_WEP;
+ break;
+ case IW_ENCODE_ALG_TKIP:
+ alg_name = WPA_ALG_TKIP;
+ break;
+ case IW_ENCODE_ALG_CCMP:
+ alg_name = WPA_ALG_CCMP;
+ break;
+ default:
+ printk("Unknown alg = %d\n",ext->alg);
+ ret= -ENOMEM;
+ goto error;
+ }
+//recover addr
+ memcpy(addr, ext->addr.sa_data, ETH_ALEN);
+//recover key_idx
+ key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
+//recover set_tx
+if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
+ set_tx = 1;
+//recover seq,seq_len
+ if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
+ seq_len=IW_ENCODE_SEQ_MAX_SIZE;
+ memcpy(seq, ext->rx_seq, seq_len);
+ }
+//recover key,key_len
+if(ext->key_len) {
+ key_len=ext->key_len;
+ memcpy(key, &ext->key[0], key_len);
+ }
+
+memset(key_array, 0, 64);
+if ( key_len > 0) {
+ memcpy(key_array, key, key_len);
+ if (key_len == 32) {
+ // notice ! the oder
+ memcpy(&key_array[16], &key[24], 8);
+ memcpy(&key_array[24], &key[16], 8);
+ }
+ }
+
+/**************Translate iw_encode_ext to viawget_wpa_param****************/
+memcpy(param->addr, addr, ETH_ALEN);
+param->u.wpa_key.alg_name = (int)alg_name;
+param->u.wpa_key.set_tx = set_tx;
+param->u.wpa_key.key_index = key_idx;
+param->u.wpa_key.key_len = key_len;
+param->u.wpa_key.key = (u8 *)key_array;
+param->u.wpa_key.seq = (u8 *)seq;
+param->u.wpa_key.seq_len = seq_len;
+
+#if 0
+int ii;
+printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name);
+printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ param->addr[0],param->addr[1],param->addr[2],
+ param->addr[3],param->addr[4],param->addr[5]);
+printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx);
+printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index);
+printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len);
+printk("param->u.wpa_key.key =");
+for(ii=0;ii<param->u.wpa_key.key_len;ii++)
+ printk("%02x:",param->u.wpa_key.key[ii]);
+ printk("\n");
+printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len);
+printk("param->u.wpa_key.seq =");
+for(ii=0;ii<param->u.wpa_key.seq_len;ii++)
+ printk("%02x:",param->u.wpa_key.seq[ii]);
+ printk("\n");
+
+printk("...........\n");
+#endif
+//****set if current action is Network Manager count??
+//****this method is so foolish,but there is no other way???
+if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
+ if(param->u.wpa_key.key_index ==0) {
+ pDevice->bwextcount++;
+ }
+ if((pDevice->bwextcount == 1)&&(param->u.wpa_key.key_index ==1)) {
+ pDevice->bwextcount++;
+ }
+ if((pDevice->bwextcount ==2)&&(param->u.wpa_key.key_index ==2)) {
+ pDevice->bwextcount++;
+ }
+ if((pDevice->bwextcount ==3)&&(param->u.wpa_key.key_index ==3)) {
+ pDevice->bwextcount++;
+ }
+ }
+if( pDevice->bwextcount == 4) {
+ printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
+ pDevice->bwextcount=0;
+ pDevice->bWPASuppWextEnabled = TRUE;
+ }
+//******
+
+ spin_lock_irq(&pDevice->lock);
+ ret = wpa_set_keys(pDevice, param, TRUE);
+ spin_unlock_irq(&pDevice->lock);
+
+error:
+kfree(param);
+ return ret;
+}
+
+
+
+int iwctl_giwencodeext(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ return -EOPNOTSUPP;;
+}
+
+int iwctl_siwmlme(struct net_device *dev,
+ struct iw_request_info * info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)dev->priv;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ struct iw_mlme *mlme = (struct iw_mlme *)extra;
+ //u16 reason = cpu_to_le16(mlme->reason_code);
+ int ret = 0;
+
+ if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
+ ret = -EINVAL;
+ return ret;
+ }
+ switch(mlme->cmd){
+ case IW_MLME_DEAUTH:
+ //this command seems to be not complete,please test it --einsnliu
+ //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
+ break;
+ case IW_MLME_DISASSOC:
+ if(pDevice->bLinkPass == TRUE){
+ printk("iwctl_siwmlme--->send DISASSOCIATE\n");
+ //clear related flags
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+ }
+ break;
+ default:
+ ret = -EOPNOTSUPP;
+ }
+
+ return ret;
+
+}
+
+#endif
+
+
+/*------------------------------------------------------------------*/
+/*
+ * Structures to export the Wireless Handlers
+ */
+
+
+#if WIRELESS_EXT > 12
+
+/*
+static const iw_handler iwctl_handler[] =
+{
+ (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
+ (iw_handler) iwctl_giwname, // SIOCGIWNAME
+ (iw_handler) NULL, // SIOCSIWNWID
+ (iw_handler) NULL, // SIOCGIWNWID
+ (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
+ (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
+ (iw_handler) iwctl_siwmode, // SIOCSIWMODE
+ (iw_handler) iwctl_giwmode, // SIOCGIWMODE
+ (iw_handler) NULL, // SIOCSIWSENS
+ (iw_handler) iwctl_giwsens, // SIOCGIWSENS
+ (iw_handler) NULL, // SIOCSIWRANGE
+ (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
+ (iw_handler) NULL, // SIOCSIWPRIV
+ (iw_handler) NULL, // SIOCGIWPRIV
+ (iw_handler) NULL, // SIOCSIWSTATS
+ (iw_handler) NULL, // SIOCGIWSTATS
+ (iw_handler) NULL, // SIOCSIWSPY
+ (iw_handler) NULL, // SIOCGIWSPY
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) iwctl_siwap, // SIOCSIWAP
+ (iw_handler) iwctl_giwap, // SIOCGIWAP
+ (iw_handler) NULL, // -- hole -- 0x16
+ (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
+#if WIRELESS_EXT > 13
+ (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
+ (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
+#else
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+#endif
+ (iw_handler) iwctl_siwessid, // SIOCSIWESSID
+ (iw_handler) iwctl_giwessid, // SIOCGIWESSID
+ (iw_handler) NULL, // SIOCSIWNICKN
+ (iw_handler) NULL, // SIOCGIWNICKN
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
+ (iw_handler) iwctl_giwrate, // SIOCGIWRATE
+ (iw_handler) iwctl_siwrts, // SIOCSIWRTS
+ (iw_handler) iwctl_giwrts, // SIOCGIWRTS
+ (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
+ (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
+ (iw_handler) NULL, // SIOCSIWTXPOW
+ (iw_handler) NULL, // SIOCGIWTXPOW
+ (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
+ (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
+ (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
+ (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
+ (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
+ (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
+#if WIRELESS_EXT > 17
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
+ (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
+ (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
+ (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
+ (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
+ (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
+ (iw_handler) NULL, // SIOCSIWPMKSA
+ (iw_handler) NULL, // -- hole --
+#endif // WIRELESS_EXT > 17
+
+};
+*/
+
+static const iw_handler iwctl_handler[] =
+{
+ (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
+ (iw_handler) NULL, // SIOCGIWNAME
+ (iw_handler) NULL, // SIOCSIWNWID
+ (iw_handler) NULL, // SIOCGIWNWID
+ (iw_handler) NULL, // SIOCSIWFREQ
+ (iw_handler) NULL, // SIOCGIWFREQ
+ (iw_handler) NULL, // SIOCSIWMODE
+ (iw_handler) NULL, // SIOCGIWMODE
+ (iw_handler) NULL, // SIOCSIWSENS
+ (iw_handler) NULL, // SIOCGIWSENS
+ (iw_handler) NULL, // SIOCSIWRANGE
+ (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
+ (iw_handler) NULL, // SIOCSIWPRIV
+ (iw_handler) NULL, // SIOCGIWPRIV
+ (iw_handler) NULL, // SIOCSIWSTATS
+ (iw_handler) NULL, // SIOCGIWSTATS
+ (iw_handler) NULL, // SIOCSIWSPY
+ (iw_handler) NULL, // SIOCGIWSPY
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // SIOCSIWAP
+ (iw_handler) NULL, // SIOCGIWAP
+ (iw_handler) NULL, // -- hole -- 0x16
+ (iw_handler) NULL, // SIOCGIWAPLIST
+#if WIRELESS_EXT > 13
+ (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
+ (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
+#else
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+#endif
+ (iw_handler) NULL, // SIOCSIWESSID
+ (iw_handler) NULL, // SIOCGIWESSID
+ (iw_handler) NULL, // SIOCSIWNICKN
+ (iw_handler) NULL, // SIOCGIWNICKN
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // SIOCSIWRATE 0x20
+ (iw_handler) NULL, // SIOCGIWRATE
+ (iw_handler) NULL, // SIOCSIWRTS
+ (iw_handler) NULL, // SIOCGIWRTS
+ (iw_handler) NULL, // SIOCSIWFRAG
+ (iw_handler) NULL, // SIOCGIWFRAG
+ (iw_handler) NULL, // SIOCSIWTXPOW
+ (iw_handler) NULL, // SIOCGIWTXPOW
+ (iw_handler) NULL, // SIOCSIWRETRY
+ (iw_handler) NULL, // SIOCGIWRETRY
+ (iw_handler) NULL, // SIOCSIWENCODE
+ (iw_handler) NULL, // SIOCGIWENCODE
+ (iw_handler) NULL, // SIOCSIWPOWER
+ (iw_handler) NULL, // SIOCGIWPOWER
+
+//2008-0409-07, <Add> by Einsn Liu
+#if WIRELESS_EXT > 17
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // -- hole --
+ (iw_handler) NULL, // SIOCSIWGENIE
+ (iw_handler) NULL, // SIOCGIWGENIE
+ (iw_handler) NULL, // SIOCSIWAUTH
+ (iw_handler) NULL, // SIOCGIWAUTH
+ (iw_handler) NULL, // SIOCSIWENCODEEXT
+ (iw_handler) NULL, // SIOCGIWENCODEEXT
+ (iw_handler) NULL, // SIOCSIWPMKSA
+ (iw_handler) NULL, // -- hole --
+#endif // WIRELESS_EXT > 17
+};
+
+
+static const iw_handler iwctl_private_handler[] =
+{
+ NULL, // SIOCIWFIRSTPRIV
+};
+
+
+struct iw_priv_args iwctl_private_args[] = {
+{ IOCTL_CMD_SET,
+ IW_PRIV_TYPE_CHAR | 1024, 0,
+ "set"},
+};
+
+
+
+const struct iw_handler_def iwctl_handler_def =
+{
+#if WIRELESS_EXT > 16
+ .get_wireless_stats = &iwctl_get_wireless_stats,
+#endif
+ .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
+// .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
+// .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
+ .num_private = 0,
+ .num_private_args = 0,
+ .standard = (iw_handler *) iwctl_handler,
+// .private = (iw_handler *) iwctl_private_handler,
+// .private_args = (struct iw_priv_args *)iwctl_private_args,
+ .private = NULL,
+ .private_args = NULL,
+};
+
+
+#endif // WIRELESS_EXT > 12
+
+
+#endif // WIRELESS_EXT
diff --git a/drivers/staging/vt6655/iwctl.h b/drivers/staging/vt6655/iwctl.h
new file mode 100644
index 000000000000..07554e14d5f2
--- /dev/null
+++ b/drivers/staging/vt6655/iwctl.h
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: iwctl.h
+ *
+ * Purpose:
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 21, 2004
+ *
+ */
+
+
+#ifndef __IWCTL_H__
+#define __IWCTL_H__
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+#if WIRELESS_EXT < 18
+
+
+#define SIOCSIWMLME 0x8B16
+#define SIOCSIWGENIE 0x8B30
+
+// WPA : Authentication mode parameters
+#define SIOCSIWAUTH 0x8B32
+#define SIOCGIWAUTH 0x8B33
+
+// WPA : Extended version of encoding configuration
+#define SIOCSIWENCODEEXT 0x8B34
+#define SIOCGIWENCODEEXT 0x8B35
+
+#define IW_AUTH_WPA_VERSION 0
+#define IW_AUTH_CIPHER_PAIRWISE 1
+#define IW_AUTH_CIPHER_GROUP 2
+#define IW_AUTH_KEY_MGMT 3
+#define IW_AUTH_TKIP_COUNTERMEASURES 4
+#define IW_AUTH_DROP_UNENCRYPTED 5
+#define IW_AUTH_80211_AUTH_ALG 6
+#define IW_AUTH_WPA_ENABLED 7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
+#define IW_AUTH_ROAMING_CONTROL 9
+#define IW_AUTH_PRIVACY_INVOKED 10
+
+#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
+#define IW_AUTH_WPA_VERSION_WPA 0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
+
+#define IW_AUTH_CIPHER_NONE 0x00000001
+#define IW_AUTH_CIPHER_WEP40 0x00000002
+#define IW_AUTH_CIPHER_TKIP 0x00000004
+#define IW_AUTH_CIPHER_CCMP 0x00000008
+#define IW_AUTH_CIPHER_WEP104 0x00000010
+
+#define IW_AUTH_KEY_MGMT_802_1X 1
+#define IW_AUTH_KEY_MGMT_PSK 2
+
+#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP 0x00000004
+
+#define IW_AUTH_ROAMING_ENABLE 0
+#define IW_AUTH_ROAMING_DISABLE 1
+
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+
+#define IW_ENCODE_ALG_NONE 0
+#define IW_ENCODE_ALG_WEP 1
+#define IW_ENCODE_ALG_TKIP 2
+#define IW_ENCODE_ALG_CCMP 3
+
+
+struct iw_encode_ext
+{
+ __u32 ext_flags; // IW_ENCODE_EXT_*
+ __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; // LSB first
+ __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; // LSB first
+ struct sockaddr addr; // ff:ff:ff:ff:ff:ff for broadcast/multicast
+ // (group) keys or unicast address for
+ // individual keys
+ __u16 alg; // IW_ENCODE_ALG_*
+ __u16 key_len;
+ __u8 key[0];
+};
+
+
+struct iw_mlme
+{
+ __u16 cmd; /* IW_MLME_* */
+ __u16 reason_code;
+ struct sockaddr addr;
+};
+
+#endif // WIRELESS_EXT < 18
+
+
+
+#ifdef WIRELESS_EXT
+
+struct iw_statistics *iwctl_get_wireless_stats (struct net_device *dev);
+
+
+int iwctl_siwap(struct net_device *dev,
+ struct iw_request_info *info,
+ struct sockaddr *wrq,
+ char *extra);
+
+int iwctl_giwrange(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+
+int iwctl_giwmode(struct net_device *dev,
+ struct iw_request_info *info,
+ __u32 *wmode,
+ char *extra);
+
+int iwctl_siwmode(struct net_device *dev,
+ struct iw_request_info *info,
+ __u32 *wmode,
+ char *extra);
+
+int iwctl_giwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *wrq,
+ char *extra);
+
+int iwctl_siwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *wrq,
+ char *extra);
+
+int iwctl_giwname(struct net_device *dev,
+ struct iw_request_info *info,
+ char *wrq,
+ char *extra);
+
+int iwctl_giwnwid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra) ;
+
+int iwctl_giwsens(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwap(struct net_device *dev,
+ struct iw_request_info *info,
+ struct sockaddr *wrq,
+ char *extra);
+
+int iwctl_giwaplist(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_siwessid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_giwessid(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_siwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwrate(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_siwrts(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+
+int iwctl_giwrts(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_siwfrag(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwfrag(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_siwretry(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwretry(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_siwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_giwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_siwpower(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwpower(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwscan(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_siwscan(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+int iwctl_siwauth(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_giwauth(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_param *wrq,
+ char *extra);
+
+int iwctl_siwgenie(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_giwgenie(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_siwencodeext(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_giwencodeext(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra);
+
+int iwctl_siwmlme(struct net_device *dev,
+ struct iw_request_info * info,
+ struct iw_point *wrq,
+ char *extra);
+#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+
+
+#endif
+
+#if WIRELESS_EXT > 12
+extern const struct iw_handler_def iwctl_handler_def;
+extern const struct iw_priv_args iwctl_private_args;
+#else
+struct iw_request_info {};
+#endif //WIRELESS_EXT > 12
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __IWCTL_H__
+
+
+
diff --git a/drivers/staging/vt6655/kcompat.h b/drivers/staging/vt6655/kcompat.h
new file mode 100644
index 000000000000..693939df6675
--- /dev/null
+++ b/drivers/staging/vt6655/kcompat.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: kcompat.h
+ *
+ * Purpose: define kernel compatibility header
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Apr 8, 2002
+ *
+ */
+#ifndef _KCOMPAT_H
+#define _KCOMPAT_H
+
+#include <linux/version.h>
+
+#ifndef __init
+#define __init
+#endif
+
+#ifndef __exit
+#define __exit
+#endif
+
+#ifndef __devexit
+#define __devexit
+#endif
+
+#ifndef __devinitdata
+#define __devinitdata
+#endif
+
+#ifndef MODULE_LICENSE
+#define MODULE_LICENSE(license)
+#endif
+
+#ifndef MOD_INC_USE_COUNT
+#define MOD_INC_USE_COUNT do {} while (0)
+#endif
+
+#ifndef MOD_DEC_USE_COUNT
+#define MOD_DEC_USE_COUNT do {} while (0)
+#endif
+
+#ifndef HAVE_NETDEV_PRIV
+#define netdev_priv(dev) (dev->priv)
+#endif
+
+#ifndef IRQ_RETVAL
+typedef void irqreturn_t;
+
+#ifdef PRIVATE_OBJ
+#define IRQ_RETVAL(x) (int)x
+#else
+#define IRQ_RETVAL(x)
+#endif
+
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
+
+typedef unsigned long dma_addr_t;
+typedef struct wait_queue *wait_queue_head_t;
+#define init_waitqueue_head(x) *(x)=NULL
+#define set_current_state(status) { current->state = (status); mb(); }
+
+#ifdef MODULE
+
+#define module_init(fn) int init_module (void) { return fn(); }
+#define module_exit(fn) void cleanup_module(void) { return fn(); }
+
+#else /* MODULE */
+
+#define module_init(fn) int e100_probe (void) { return fn(); }
+#define module_exit(fn) /* NOTHING */
+
+#endif /* MODULE */
+
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
+
+#ifdef MODVERSIONS
+#include <linux/modversions.h>
+#endif
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
+#include <asm/io.h>
+
+#define pci_resource_start(dev, bar) \
+ (((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_SPACE_IO) ? \
+ ((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_IO_MASK) : \
+ ((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_MEM_MASK))
+
+static inline int pci_enable_device(struct pci_dev *dev)
+{
+ 1112
+ return 0;
+}
+#define __constant_cpu_to_le32 cpu_to_le32
+#define __constant_cpu_to_le16 cpu_to_le16
+
+#define PCI_DMA_TODEVICE 1
+#define PCI_DMA_FROMDEVICE 2
+
+extern inline void *pci_alloc_consistent (struct pci_dev *dev,
+ size_t size,
+ dma_addr_t *dma_handle) {
+ void *vaddr = kmalloc(size, GFP_ATOMIC);
+ if(vaddr != NULL) {
+ *dma_handle = virt_to_bus(vaddr);
+ }
+ return vaddr;
+}
+
+#define pci_dma_sync_single(dev,dma_handle,size,direction) do{} while(0)
+#define pci_dma_supported(dev, addr_mask) (1)
+#define pci_free_consistent(dev, size, cpu_addr, dma_handle) kfree(cpu_addr)
+#define pci_map_single(dev, addr, size, direction) virt_to_bus(addr)
+#define pci_unmap_single(dev, dma_handle, size, direction) do{} while(0)
+
+
+#define spin_lock_bh spin_lock_irq
+#define spin_unlock_bh spin_unlock_irq
+#define del_timer_sync(timer) del_timer(timer)
+#define net_device device
+
+#define netif_start_queue(dev) ( clear_bit(0, &(dev)->tbusy))
+#define netif_stop_queue(dev) ( set_bit(0, &(dev)->tbusy))
+#define netif_wake_queue(dev) { clear_bit(0, &(dev)->tbusy); \
+ mark_bh(NET_BH); }
+#define netif_running(dev) ( test_bit(0, &(dev)->start))
+#define netif_queue_stopped(dev) ( test_bit(0, &(dev)->tbusy))
+
+#define netif_device_attach(dev) \
+ do{ (dev)->start = 1; netif_start_queue(dev); } while (0)
+#define netif_device_detach(dev) \
+ do{ (dev)->start = 0; netif_stop_queue(dev); } while (0)
+
+#define dev_kfree_skb_irq(skb) dev_kfree_skb(skb)
+
+#define netif_carrier_on(dev) do {} while (0)
+#define netif_carrier_off(dev) do {} while (0)
+
+
+#define PCI_ANY_ID (~0U)
+
+struct pci_device_id {
+ unsigned int vendor, device;
+ unsigned int subvendor, subdevice;
+ unsigned int class, classmask;
+ unsigned long driver_data;
+};
+
+#define MODULE_DEVICE_TABLE(bus, dev_table)
+#define PCI_MAX_NUM_NICS 256
+
+struct pci_driver {
+ char *name;
+ struct pci_device_id *id_table;
+ int (*probe)(struct pci_dev *dev, const struct pci_device_id *id);
+ void (*remove)(struct pci_dev *dev);
+ void (*suspend)(struct pci_dev *dev);
+ void (*resume)(struct pci_dev *dev);
+ struct pci_dev *pcimap[PCI_MAX_NUM_NICS];
+};
+
+static inline int pci_module_init(struct pci_driver *drv)
+{
+ struct pci_dev *pdev;
+ struct pci_device_id *pcid;
+ uint16_t subvendor, subdevice;
+ int board_count = 0;
+
+ /* walk the global pci device list looking for matches */
+ for (pdev = pci_devices; pdev && (board_count < PCI_MAX_NUM_NICS); pdev = pdev->next) {
+
+ pcid = &drv->id_table[0];
+ pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor);
+ pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subdevice);
+
+ while (pcid->vendor != 0) {
+ if (((pcid->vendor == pdev->vendor) || (pcid->vendor == PCI_ANY_ID)) &&
+ ((pcid->device == pdev->device) || (pcid->device == PCI_ANY_ID)) &&
+ ((pcid->subvendor == subvendor) || (pcid->subvendor == PCI_ANY_ID)) &&
+ ((pcid->subdevice == subdevice) || (pcid->subdevice == PCI_ANY_ID))) {
+
+ if (drv->probe(pdev, pcid) == 0) {
+ drv->pcimap[board_count] = pdev;
+ board_count++;
+ }
+ break;
+ }
+ pcid++;
+ }
+ }
+
+ if (board_count < PCI_MAX_NUM_NICS) {
+ drv->pcimap[board_count] = NULL;
+ }
+
+ return (board_count > 0) ? 0 : -ENODEV;
+}
+
+static inline void pci_unregister_driver(struct pci_driver *drv)
+{
+ int i;
+
+ for (i = 0; i < PCI_MAX_NUM_NICS; i++) {
+ if (!drv->pcimap[i])
+ break;
+
+ drv->remove(drv->pcimap[i]);
+ }
+}
+
+
+#define pci_set_drvdata(pcid, data)
+
+#define pci_get_drvdata(pcid) ({ \
+ PSDevice pInfo; \
+ for (pInfo = pDevice_Infos; \
+ pInfo; pInfo = pInfo->next) { \
+ if (pInfo->pcid == pcid) \
+ break; \
+ } \
+ pInfo; })
+
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5)
+
+#define skb_linearize(skb, gfp_mask) ({ \
+ struct sk_buff *tmp_skb; \
+ tmp_skb = skb; \
+ skb = skb_copy(tmp_skb, gfp_mask); \
+ dev_kfree_skb_irq(tmp_skb); })
+
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) */
+
+#ifndef MODULE_LICESEN
+#define MODULE_LICESEN(x)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6)
+
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,2)
+static inline int pci_set_power_state(struct pci_dev* pcid, int state) { return 0; }
+#endif
+
+#define PMCSR 0xe0
+#define PM_ENABLE_BIT 0x0100
+#define PM_CLEAR_BIT 0x8000
+#define PM_STATE_MASK 0xFFFC
+#define PM_STATE_D1 0x0001
+
+static inline int
+pci_enable_wake(struct pci_dev *dev, u32 state, int enable)
+{
+ u16 p_state;
+
+ pci_read_config_word(dev, PMCSR, &p_state);
+ pci_write_config_word(dev, PMCSR, p_state | PM_CLEAR_BIT);
+
+ if (enable == 0) {
+ p_state &= ~PM_ENABLE_BIT;
+ } else {
+ p_state |= PM_ENABLE_BIT;
+ }
+ p_state &= PM_STATE_MASK;
+ p_state |= state;
+
+ pci_write_config_word(dev, PMCSR, p_state);
+
+ return 0;
+}
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) */
+
+#endif
+
diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c
new file mode 100644
index 000000000000..168ebd3be944
--- /dev/null
+++ b/drivers/staging/vt6655/key.c
@@ -0,0 +1,836 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: key.c
+ *
+ * Purpose: Implement functions for 802.11i Key management
+ *
+ * Author: Jerry Chen
+ *
+ * Date: May 29, 2003
+ *
+ * Functions:
+ * KeyvInitTable - Init Key management table
+ * KeybGetKey - Get Key from table
+ * KeybSetKey - Set Key to table
+ * KeybRemoveKey - Remove Key from table
+ * KeybGetTransmitKey - Get Transmit Key from table
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__KEY_H__)
+#include "key.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+static VOID
+s_vCheckKeyTableValid (PSKeyManagement pTable, DWORD_PTR dwIoBase)
+{
+ int i;
+
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ (pTable->KeyTable[i].PairwiseKey.bKeyValid == FALSE) &&
+ (pTable->KeyTable[i].GroupKey[0].bKeyValid == FALSE) &&
+ (pTable->KeyTable[i].GroupKey[1].bKeyValid == FALSE) &&
+ (pTable->KeyTable[i].GroupKey[2].bKeyValid == FALSE) &&
+ (pTable->KeyTable[i].GroupKey[3].bKeyValid == FALSE)
+ ) {
+ pTable->KeyTable[i].bInUse = FALSE;
+ pTable->KeyTable[i].wKeyCtl = 0;
+ pTable->KeyTable[i].bSoftWEP = FALSE;
+ MACvDisableKeyEntry(dwIoBase, i);
+ }
+ }
+}
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*
+ * Description: Init Key management table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID KeyvInitTable (PSKeyManagement pTable, DWORD_PTR dwIoBase)
+{
+ int i;
+ int jj;
+
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ pTable->KeyTable[i].bInUse = FALSE;
+ pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
+ pTable->KeyTable[i].PairwiseKey.pvKeyTable = (PVOID)&pTable->KeyTable[i];
+ for (jj=0; jj < MAX_GROUP_KEY; jj++) {
+ pTable->KeyTable[i].GroupKey[jj].bKeyValid = FALSE;
+ pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (PVOID)&pTable->KeyTable[i];
+ }
+ pTable->KeyTable[i].wKeyCtl = 0;
+ pTable->KeyTable[i].dwGTKeyIndex = 0;
+ pTable->KeyTable[i].bSoftWEP = FALSE;
+ MACvDisableKeyEntry(dwIoBase, i);
+ }
+}
+
+
+/*
+ * Description: Get Key from table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * pbyBSSID - BSSID of Key
+ * dwKeyIndex - Key Index (0xFFFFFFFF means pairwise key)
+ * Out:
+ * pKey - Key return
+ *
+ * Return Value: TRUE if found otherwise FALSE
+ *
+ */
+BOOL KeybGetKey (
+ IN PSKeyManagement pTable,
+ IN PBYTE pbyBSSID,
+ IN DWORD dwKeyIndex,
+ OUT PSKeyItem *pKey
+ )
+{
+ int i;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n");
+
+ *pKey = NULL;
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
+ if (dwKeyIndex == 0xFFFFFFFF) {
+ if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) {
+ *pKey = &(pTable->KeyTable[i].PairwiseKey);
+ return (TRUE);
+ }
+ else {
+ return (FALSE);
+ }
+ } else if (dwKeyIndex < MAX_GROUP_KEY) {
+ if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == TRUE) {
+ *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]);
+ return (TRUE);
+ }
+ else {
+ return (FALSE);
+ }
+ }
+ else {
+ return (FALSE);
+ }
+ }
+ }
+ return (FALSE);
+}
+
+
+/*
+ * Description: Set Key to table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * pbyBSSID - BSSID of Key
+ * dwKeyIndex - Key index (reference to NDIS DDK)
+ * uKeyLength - Key length
+ * KeyRSC - Key RSC
+ * pbyKey - Pointer to key
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success otherwise FALSE
+ *
+ */
+BOOL KeybSetKey (
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode,
+ DWORD_PTR dwIoBase,
+ BYTE byLocalID
+ )
+{
+ int i,j;
+ UINT ii;
+ PSKeyItem pKey;
+ UINT uKeyIdx;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetKey: %lX\n", dwKeyIndex);
+
+ j = (MAX_KEY_TABLE-1);
+ for (i=0;i<(MAX_KEY_TABLE-1);i++) {
+ if ((pTable->KeyTable[i].bInUse == FALSE) &&
+ (j == (MAX_KEY_TABLE-1))) {
+ // found empty table
+ j = i;
+ }
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
+ // found table already exist
+ if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
+ // Pairwise key
+ pKey = &(pTable->KeyTable[i].PairwiseKey);
+ pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed
+ pTable->KeyTable[i].wKeyCtl |= byKeyDecMode;
+ uKeyIdx = 4; // use HW key entry 4 for pairwise key
+ } else {
+ // Group key
+ if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
+ return (FALSE);
+ pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
+ if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
+ // Group transmit key
+ pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i);
+ }
+ pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
+ pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
+ pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address
+ uKeyIdx = (dwKeyIndex & 0x000000FF);
+ }
+ pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly
+
+ pKey->bKeyValid = TRUE;
+ pKey->uKeyLength = uKeyLength;
+ pKey->dwKeyIndex = dwKeyIndex;
+ pKey->byCipherSuite = byKeyDecMode;
+ MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
+ if (byKeyDecMode == KEY_CTL_WEP) {
+ if (uKeyLength == WLAN_WEP40_KEYLEN)
+ pKey->abyKey[15] &= 0x7F;
+ if (uKeyLength == WLAN_WEP104_KEYLEN)
+ pKey->abyKey[15] |= 0x80;
+ }
+ MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey, byLocalID);
+
+ if ((dwKeyIndex & USE_KEYRSC) == 0) {
+ // RSC set by NIC
+ ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
+ }
+ else {
+ MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
+ }
+ pKey->dwTSC47_16 = 0;
+ pKey->wTSC15_0 = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", pKey->uKeyLength);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
+
+ return (TRUE);
+ }
+ }
+ if (j < (MAX_KEY_TABLE-1)) {
+ MEMvCopy(pTable->KeyTable[j].abyBSSID,pbyBSSID,U_ETHER_ADDR_LEN);
+ pTable->KeyTable[j].bInUse = TRUE;
+ if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
+ // Pairwise key
+ pKey = &(pTable->KeyTable[j].PairwiseKey);
+ pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed
+ pTable->KeyTable[j].wKeyCtl |= byKeyDecMode;
+ uKeyIdx = 4; // use HW key entry 4 for pairwise key
+ } else {
+ // Group key
+ if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
+ return (FALSE);
+ pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]);
+ if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
+ // Group transmit key
+ pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(N)[%lX]: %d\n", pTable->KeyTable[j].dwGTKeyIndex, j);
+ }
+ pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed
+ pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4);
+ pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address
+ uKeyIdx = (dwKeyIndex & 0x000000FF);
+ }
+ pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly
+
+ pKey->bKeyValid = TRUE;
+ pKey->uKeyLength = uKeyLength;
+ pKey->dwKeyIndex = dwKeyIndex;
+ pKey->byCipherSuite = byKeyDecMode;
+ MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
+ if (byKeyDecMode == KEY_CTL_WEP) {
+ if (uKeyLength == WLAN_WEP40_KEYLEN)
+ pKey->abyKey[15] &= 0x7F;
+ if (uKeyLength == WLAN_WEP104_KEYLEN)
+ pKey->abyKey[15] |= 0x80;
+ }
+ MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey, byLocalID);
+
+ if ((dwKeyIndex & USE_KEYRSC) == 0) {
+ // RSC set by NIC
+ ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
+ }
+ else {
+ MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
+ }
+ pKey->dwTSC47_16 = 0;
+ pKey->wTSC15_0 = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(N): \n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
+
+ return (TRUE);
+ }
+ return (FALSE);
+}
+
+
+/*
+ * Description: Remove Key from table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * pbyBSSID - BSSID of Key
+ * dwKeyIndex - Key Index (reference to NDIS DDK)
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success otherwise FALSE
+ *
+ */
+BOOL KeybRemoveKey (
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex,
+ DWORD_PTR dwIoBase
+ )
+{
+ int i;
+
+ if (IS_BROADCAST_ADDRESS(pbyBSSID)) {
+ // dealte all key
+ if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
+ }
+ s_vCheckKeyTableValid(pTable, dwIoBase);
+ return TRUE;
+ }
+ else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE;
+ if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
+ // remove Group transmit key
+ pTable->KeyTable[i].dwGTKeyIndex = 0;
+ }
+ }
+ s_vCheckKeyTableValid(pTable, dwIoBase);
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
+ if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
+ pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
+ s_vCheckKeyTableValid(pTable, dwIoBase);
+ return (TRUE);
+ }
+ else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
+ pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE;
+ if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
+ // remove Group transmit key
+ pTable->KeyTable[i].dwGTKeyIndex = 0;
+ }
+ s_vCheckKeyTableValid(pTable, dwIoBase);
+ return (TRUE);
+ }
+ else {
+ return (FALSE);
+ }
+ }
+ }
+ return (FALSE);
+}
+
+
+/*
+ * Description: Remove Key from table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * pbyBSSID - BSSID of Key
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success otherwise FALSE
+ *
+ */
+BOOL KeybRemoveAllKey (
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD_PTR dwIoBase
+ )
+{
+ int i,u;
+
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
+ pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
+ for(u=0;u<MAX_GROUP_KEY;u++) {
+ pTable->KeyTable[i].GroupKey[u].bKeyValid = FALSE;
+ }
+ pTable->KeyTable[i].dwGTKeyIndex = 0;
+ s_vCheckKeyTableValid(pTable, dwIoBase);
+ return (TRUE);
+ }
+ }
+ return (FALSE);
+}
+
+/*
+ * Description: Remove WEP Key from table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success otherwise FALSE
+ *
+ */
+VOID KeyvRemoveWEPKey (
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ DWORD_PTR dwIoBase
+ )
+{
+
+ if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
+ if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == TRUE) {
+ if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) {
+ pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE;
+ if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) {
+ // remove Group transmit key
+ pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0;
+ }
+ }
+ }
+ s_vCheckKeyTableValid(pTable, dwIoBase);
+ }
+ return;
+}
+
+VOID KeyvRemoveAllWEPKey (
+ PSKeyManagement pTable,
+ DWORD_PTR dwIoBase
+ )
+{
+ int i;
+
+ for(i=0;i<MAX_GROUP_KEY;i++) {
+ KeyvRemoveWEPKey(pTable, i, dwIoBase);
+ }
+}
+
+/*
+ * Description: Get Transmit Key from table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * pbyBSSID - BSSID of Key
+ * Out:
+ * pKey - Key return
+ *
+ * Return Value: TRUE if found otherwise FALSE
+ *
+ */
+BOOL KeybGetTransmitKey (
+ IN PSKeyManagement pTable,
+ IN PBYTE pbyBSSID,
+ IN DWORD dwKeyType,
+ OUT PSKeyItem *pKey
+ )
+{
+ int i, ii;
+
+ *pKey = NULL;
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
+
+ if (dwKeyType == PAIRWISE_KEY) {
+
+ if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) {
+ *pKey = &(pTable->KeyTable[i].PairwiseKey);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PAIRWISE_KEY: KeyTable.abyBSSID: ");
+ for (ii = 0; ii < 6; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+
+ return (TRUE);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == FALSE\n");
+ return (FALSE);
+ }
+ } // End of Type == PAIRWISE
+ else {
+ if (pTable->KeyTable[i].dwGTKeyIndex == 0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: dwGTKeyIndex == 0 !!!\n");
+ return FALSE;
+ }
+ if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == TRUE) {
+ *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GROUP_KEY: KeyTable.abyBSSID\n");
+ for (ii = 0; ii < 6; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex);
+
+ return (TRUE);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == FALSE\n");
+ return (FALSE);
+ }
+ } // End of Type = GROUP
+ } // BSSID match
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: NO Match BSSID !!! ");
+ for (ii = 0; ii < 6; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+ return (FALSE);
+}
+
+
+/*
+ * Description: Check Pairewise Key
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if found otherwise FALSE
+ *
+ */
+BOOL KeybCheckPairewiseKey (
+ IN PSKeyManagement pTable,
+ OUT PSKeyItem *pKey
+ )
+{
+ int i;
+
+ *pKey = NULL;
+ for (i=0;i<MAX_KEY_TABLE;i++) {
+ if ((pTable->KeyTable[i].bInUse == TRUE) &&
+ (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE)) {
+ *pKey = &(pTable->KeyTable[i].PairwiseKey);
+ return (TRUE);
+ }
+ }
+ return (FALSE);
+}
+
+/*
+ * Description: Set Key to table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * dwKeyIndex - Key index (reference to NDIS DDK)
+ * uKeyLength - Key length
+ * KeyRSC - Key RSC
+ * pbyKey - Pointer to key
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success otherwise FALSE
+ *
+ */
+BOOL KeybSetDefaultKey (
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode,
+ DWORD_PTR dwIoBase,
+ BYTE byLocalID
+ )
+{
+ UINT ii;
+ PSKeyItem pKey;
+ UINT uKeyIdx;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetDefaultKey: %1x, %d \n", (int)dwKeyIndex, (int)uKeyLength);
+
+
+ if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
+ return (FALSE);
+ } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) {
+ return (FALSE);
+ }
+
+ pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = TRUE;
+ for(ii=0;ii<U_ETHER_ADDR_LEN;ii++)
+ pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF;
+
+ // Group key
+ pKey = &(pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF]);
+ if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
+ // Group transmit key
+ pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, MAX_KEY_TABLE-1);
+
+ }
+ pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed
+ pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4);
+ pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode);
+ pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address
+ uKeyIdx = (dwKeyIndex & 0x000000FF);
+
+ if ((uKeyLength == WLAN_WEP232_KEYLEN) &&
+ (byKeyDecMode == KEY_CTL_WEP)) {
+ pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match
+ pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = TRUE;
+ } else {
+ if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == FALSE)
+ pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match
+ }
+
+ pKey->bKeyValid = TRUE;
+ pKey->uKeyLength = uKeyLength;
+ pKey->dwKeyIndex = dwKeyIndex;
+ pKey->byCipherSuite = byKeyDecMode;
+ MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
+ if (byKeyDecMode == KEY_CTL_WEP) {
+ if (uKeyLength == WLAN_WEP40_KEYLEN)
+ pKey->abyKey[15] &= 0x7F;
+ if (uKeyLength == WLAN_WEP104_KEYLEN)
+ pKey->abyKey[15] |= 0x80;
+ }
+ MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (PDWORD)pKey->abyKey, byLocalID);
+
+ if ((dwKeyIndex & USE_KEYRSC) == 0) {
+ // RSC set by NIC
+ ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
+ } else {
+ MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
+ }
+ pKey->dwTSC47_16 = 0;
+ pKey->wTSC15_0 = 0;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n", pKey->bKeyValid);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n", (int)pKey->uKeyLength);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: \n");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x", pKey->abyKey[ii]);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex);
+
+ return (TRUE);
+}
+
+
+/*
+ * Description: Set Key to table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * dwKeyIndex - Key index (reference to NDIS DDK)
+ * uKeyLength - Key length
+ * KeyRSC - Key RSC
+ * pbyKey - Pointer to key
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success otherwise FALSE
+ *
+ */
+BOOL KeybSetAllGroupKey (
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode,
+ DWORD_PTR dwIoBase,
+ BYTE byLocalID
+ )
+{
+ int i;
+ UINT ii;
+ PSKeyItem pKey;
+ UINT uKeyIdx;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex);
+
+
+ if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
+ return (FALSE);
+ } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) {
+ return (FALSE);
+ }
+
+ for (i=0; i < MAX_KEY_TABLE-1; i++) {
+ if (pTable->KeyTable[i].bInUse == TRUE) {
+ // found table already exist
+ // Group key
+ pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
+ if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
+ // Group transmit key
+ pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i);
+
+ }
+ pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
+ pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
+ pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address
+ uKeyIdx = (dwKeyIndex & 0x000000FF);
+
+ pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly
+
+ pKey->bKeyValid = TRUE;
+ pKey->uKeyLength = uKeyLength;
+ pKey->dwKeyIndex = dwKeyIndex;
+ pKey->byCipherSuite = byKeyDecMode;
+ MEMvCopy(pKey->abyKey, pbyKey, uKeyLength);
+ if (byKeyDecMode == KEY_CTL_WEP) {
+ if (uKeyLength == WLAN_WEP40_KEYLEN)
+ pKey->abyKey[15] &= 0x7F;
+ if (uKeyLength == WLAN_WEP104_KEYLEN)
+ pKey->abyKey[15] |= 0x80;
+ }
+ MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD)pKey->abyKey, byLocalID);
+
+ if ((dwKeyIndex & USE_KEYRSC) == 0) {
+ // RSC set by NIC
+ ZERO_MEMORY(&(pKey->KeyRSC), sizeof(QWORD));
+ }
+ else {
+ MEMvCopy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD));
+ }
+ pKey->dwTSC47_16 = 0;
+ pKey->wTSC15_0 = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ //DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16));
+ //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0));
+ //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex));
+
+ } // (pTable->KeyTable[i].bInUse == TRUE)
+ }
+ return (TRUE);
+}
diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h
new file mode 100644
index 000000000000..9c7d335ea088
--- /dev/null
+++ b/drivers/staging/vt6655/key.h
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: key.h
+ *
+ * Purpose: Implement functions for 802.11i Key management
+ *
+ * Author: Jerry Chen
+ *
+ * Date: May 29, 2003
+ *
+ */
+
+
+#ifndef __KEY_H__
+#define __KEY_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+#define MAX_GROUP_KEY 4
+#define MAX_KEY_TABLE 11
+#define MAX_KEY_LEN 32
+#define AES_KEY_LEN 16
+
+
+#define AUTHENTICATOR_KEY 0x10000000
+#define USE_KEYRSC 0x20000000
+#define PAIRWISE_KEY 0x40000000
+#define TRANSMIT_KEY 0x80000000
+
+#define GROUP_KEY 0x00000000
+
+#define KEY_CTL_WEP 0x00
+#define KEY_CTL_NONE 0x01
+#define KEY_CTL_TKIP 0x02
+#define KEY_CTL_CCMP 0x03
+#define KEY_CTL_INVALID 0xFF
+
+
+typedef struct tagSKeyItem
+{
+ BOOL bKeyValid;
+ ULONG uKeyLength;
+ BYTE abyKey[MAX_KEY_LEN];
+ QWORD KeyRSC;
+ DWORD dwTSC47_16;
+ WORD wTSC15_0;
+ BYTE byCipherSuite;
+ BYTE byReserved0;
+ DWORD dwKeyIndex;
+ PVOID pvKeyTable;
+} SKeyItem, DEF* PSKeyItem; //64
+
+typedef struct tagSKeyTable
+{
+ BYTE abyBSSID[U_ETHER_ADDR_LEN]; //6
+ BYTE byReserved0[2]; //8
+ SKeyItem PairwiseKey;
+ SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
+ DWORD dwGTKeyIndex; // GroupTransmitKey Index
+ BOOL bInUse;
+ //2006-1116-01,<Modify> by NomadZhao
+ //WORD wKeyCtl;
+ //BOOL bSoftWEP;
+ BOOL bSoftWEP;
+ WORD wKeyCtl; // for address of wKeyCtl at align 4
+
+ BYTE byReserved1[6];
+} SKeyTable, DEF* PSKeyTable; //348
+
+typedef struct tagSKeyManagement
+{
+ SKeyTable KeyTable[MAX_KEY_TABLE];
+} SKeyManagement, DEF* PSKeyManagement;
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+VOID KeyvInitTable(PSKeyManagement pTable, DWORD_PTR dwIoBase);
+
+BOOL KeybGetKey(
+ IN PSKeyManagement pTable,
+ IN PBYTE pbyBSSID,
+ IN DWORD dwKeyIndex,
+ OUT PSKeyItem *pKey
+ );
+
+BOOL KeybSetKey(
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode,
+ DWORD_PTR dwIoBase,
+ BYTE byLocalID
+ );
+
+BOOL KeybSetDefaultKey(
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode,
+ DWORD_PTR dwIoBase,
+ BYTE byLocalID
+ );
+
+BOOL KeybRemoveKey(
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex,
+ DWORD_PTR dwIoBase
+ );
+
+BOOL KeybGetTransmitKey(
+ IN PSKeyManagement pTable,
+ IN PBYTE pbyBSSID,
+ IN DWORD dwKeyType,
+ OUT PSKeyItem *pKey
+ );
+
+BOOL KeybCheckPairewiseKey(
+ IN PSKeyManagement pTable,
+ OUT PSKeyItem *pKey
+ );
+
+BOOL KeybRemoveAllKey(
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD_PTR dwIoBase
+ );
+
+VOID KeyvRemoveWEPKey(
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ DWORD_PTR dwIoBase
+ );
+
+VOID KeyvRemoveAllWEPKey(
+ PSKeyManagement pTable,
+ DWORD_PTR dwIoBase
+ );
+
+BOOL KeybSetAllGroupKey (
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode,
+ DWORD_PTR dwIoBase,
+ BYTE byLocalID
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+
+#endif /* __cplusplus */
+
+
+#endif // __KEY_H__
+
diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c
new file mode 100644
index 000000000000..0283ed3bedd4
--- /dev/null
+++ b/drivers/staging/vt6655/mac.c
@@ -0,0 +1,1752 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: mac.c
+ *
+ * Purpose: MAC routines
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ * Functions:
+ * MACvReadAllRegs - Read All MAC Registers to buffer
+ * MACbIsRegBitsOn - Test if All test Bits On
+ * MACbIsRegBitsOff - Test if All test Bits Off
+ * MACbIsIntDisable - Test if MAC interrupt disable
+ * MACbyReadMultiAddr - Read Multicast Address Mask Pattern
+ * MACvWriteMultiAddr - Write Multicast Address Mask Pattern
+ * MACvSetMultiAddrByHash - Set Multicast Address Mask by Hash value
+ * MACvResetMultiAddrByHash - Clear Multicast Address Mask by Hash value
+ * MACvSetRxThreshold - Set Rx Threshold value
+ * MACvGetRxThreshold - Get Rx Threshold value
+ * MACvSetTxThreshold - Set Tx Threshold value
+ * MACvGetTxThreshold - Get Tx Threshold value
+ * MACvSetDmaLength - Set Dma Length value
+ * MACvGetDmaLength - Get Dma Length value
+ * MACvSetShortRetryLimit - Set 802.11 Short Retry limit
+ * MACvGetShortRetryLimit - Get 802.11 Short Retry limit
+ * MACvSetLongRetryLimit - Set 802.11 Long Retry limit
+ * MACvGetLongRetryLimit - Get 802.11 Long Retry limit
+ * MACvSetLoopbackMode - Set MAC Loopback Mode
+ * MACbIsInLoopbackMode - Test if MAC in Loopback mode
+ * MACvSetPacketFilter - Set MAC Address Filter
+ * MACvSaveContext - Save Context of MAC Registers
+ * MACvRestoreContext - Restore Context of MAC Registers
+ * MACbCompareContext - Compare if values of MAC Registers same as Context
+ * MACbSoftwareReset - Software Reset MAC
+ * MACbSafeRxOff - Turn Off MAC Rx
+ * MACbSafeTxOff - Turn Off MAC Tx
+ * MACbSafeStop - Stop MAC function
+ * MACbShutdown - Shut down MAC
+ * MACvInitialize - Initialize MAC
+ * MACvSetCurrRxDescAddr - Set Rx Descriptos Address
+ * MACvSetCurrTx0DescAddr - Set Tx0 Descriptos Address
+ * MACvSetCurrTx1DescAddr - Set Tx1 Descriptos Address
+ * MACvTimer0MicroSDelay - Micro Second Delay Loop by MAC
+ *
+ * Revision History:
+ * 08-22-2003 Kyle Hsu : Porting MAC functions from sim53
+ * 09-03-2003 Bryan YC Fan : Add MACvClearBusSusInd()& MACvEnableBusSusEn()
+ * 09-18-2003 Jerry Chen : Add MACvSetKeyEntry & MACvDisableKeyEntry
+ *
+ */
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+
+
+WORD TxRate_iwconfig;//2008-5-8 <add> by chester
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+/*
+ * Description:
+ * Read All MAC Registers to buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyMacRegs - buffer to read
+ *
+ * Return Value: none
+ *
+ */
+VOID MACvReadAllRegs (DWORD_PTR dwIoBase, PBYTE pbyMacRegs)
+{
+ int ii;
+
+ // read page0 register
+ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++) {
+ VNSvInPortB(dwIoBase + ii, pbyMacRegs);
+ pbyMacRegs++;
+ }
+
+ MACvSelectPage1(dwIoBase);
+
+ // read page1 register
+ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) {
+ VNSvInPortB(dwIoBase + ii, pbyMacRegs);
+ pbyMacRegs++;
+ }
+
+ MACvSelectPage0(dwIoBase);
+
+}
+
+/*
+ * Description:
+ * Test if all test bits on
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byRegOfs - Offset of MAC Register
+ * byTestBits - Test bits
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all test bits On; otherwise FALSE
+ *
+ */
+BOOL MACbIsRegBitsOn (DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits)
+{
+ BYTE byData;
+
+ VNSvInPortB(dwIoBase + byRegOfs, &byData);
+ return BITbIsAllBitsOn(byData, byTestBits);
+}
+
+/*
+ * Description:
+ * Test if all test bits off
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byRegOfs - Offset of MAC Register
+ * byTestBits - Test bits
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all test bits Off; otherwise FALSE
+ *
+ */
+BOOL MACbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits)
+{
+ BYTE byData;
+
+ VNSvInPortB(dwIoBase + byRegOfs, &byData);
+ return BITbIsAllBitsOff(byData, byTestBits);
+}
+
+/*
+ * Description:
+ * Test if MAC interrupt disable
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if interrupt is disable; otherwise FALSE
+ *
+ */
+BOOL MACbIsIntDisable (DWORD_PTR dwIoBase)
+{
+ DWORD dwData;
+
+ VNSvInPortD(dwIoBase + MAC_REG_IMR, &dwData);
+ if (dwData != 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Read MAC Multicast Address Mask
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * uByteidx - Index of Mask
+ * Out:
+ * none
+ *
+ * Return Value: Mask Value read
+ *
+ */
+BYTE MACbyReadMultiAddr (DWORD_PTR dwIoBase, UINT uByteIdx)
+{
+ BYTE byData;
+
+ MACvSelectPage1(dwIoBase);
+ VNSvInPortB(dwIoBase + MAC_REG_MAR0 + uByteIdx, &byData);
+ MACvSelectPage0(dwIoBase);
+ return byData;
+}
+
+/*
+ * Description:
+ * Write MAC Multicast Address Mask
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * uByteidx - Index of Mask
+ * byData - Mask Value to write
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID MACvWriteMultiAddr (DWORD_PTR dwIoBase, UINT uByteIdx, BYTE byData)
+{
+ MACvSelectPage1(dwIoBase);
+ VNSvOutPortB(dwIoBase + MAC_REG_MAR0 + uByteIdx, byData);
+ MACvSelectPage0(dwIoBase);
+}
+
+/*
+ * Description:
+ * Set this hash index into multicast address register bit
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byHashIdx - Hash index to set
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetMultiAddrByHash (DWORD_PTR dwIoBase, BYTE byHashIdx)
+{
+ UINT uByteIdx;
+ BYTE byBitMask;
+ BYTE byOrgValue;
+
+ // calculate byte position
+ uByteIdx = byHashIdx / 8;
+ ASSERT(uByteIdx < 8);
+ // calculate bit position
+ byBitMask = 1;
+ byBitMask <<= (byHashIdx % 8);
+ // turn on the bit
+ byOrgValue = MACbyReadMultiAddr(dwIoBase, uByteIdx);
+ MACvWriteMultiAddr(dwIoBase, uByteIdx, (BYTE)(byOrgValue | byBitMask));
+}
+
+/*
+ * Description:
+ * Reset this hash index into multicast address register bit
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byHashIdx - Hash index to clear
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvResetMultiAddrByHash (DWORD_PTR dwIoBase, BYTE byHashIdx)
+{
+ UINT uByteIdx;
+ BYTE byBitMask;
+ BYTE byOrgValue;
+
+ // calculate byte position
+ uByteIdx = byHashIdx / 8;
+ ASSERT(uByteIdx < 8);
+ // calculate bit position
+ byBitMask = 1;
+ byBitMask <<= (byHashIdx % 8);
+ // turn off the bit
+ byOrgValue = MACbyReadMultiAddr(dwIoBase, uByteIdx);
+ MACvWriteMultiAddr(dwIoBase, uByteIdx, (BYTE)(byOrgValue & (~byBitMask)));
+}
+
+/*
+ * Description:
+ * Set Rx Threshold
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byThreshold - Threshold Value
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetRxThreshold (DWORD_PTR dwIoBase, BYTE byThreshold)
+{
+ BYTE byOrgValue;
+
+ ASSERT(byThreshold < 4);
+
+ // set FCR0
+ VNSvInPortB(dwIoBase + MAC_REG_FCR0, &byOrgValue);
+ byOrgValue = (byOrgValue & 0xCF) | (byThreshold << 4);
+ VNSvOutPortB(dwIoBase + MAC_REG_FCR0, byOrgValue);
+}
+
+/*
+ * Description:
+ * Get Rx Threshold
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyThreshold- Threshold Value Get
+ *
+ * Return Value: none
+ *
+ */
+void MACvGetRxThreshold (DWORD_PTR dwIoBase, PBYTE pbyThreshold)
+{
+ // get FCR0
+ VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold);
+ *pbyThreshold = (*pbyThreshold >> 4) & 0x03;
+}
+
+/*
+ * Description:
+ * Set Tx Threshold
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byThreshold - Threshold Value
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetTxThreshold (DWORD_PTR dwIoBase, BYTE byThreshold)
+{
+ BYTE byOrgValue;
+
+ ASSERT(byThreshold < 4);
+
+ // set FCR0
+ VNSvInPortB(dwIoBase + MAC_REG_FCR0, &byOrgValue);
+ byOrgValue = (byOrgValue & 0xF3) | (byThreshold << 2);
+ VNSvOutPortB(dwIoBase + MAC_REG_FCR0, byOrgValue);
+}
+
+/*
+ * Description:
+ * Get Tx Threshold
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyThreshold- Threshold Value Get
+ *
+ * Return Value: none
+ *
+ */
+void MACvGetTxThreshold (DWORD_PTR dwIoBase, PBYTE pbyThreshold)
+{
+ // get FCR0
+ VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold);
+ *pbyThreshold = (*pbyThreshold >> 2) & 0x03;
+}
+
+/*
+ * Description:
+ * Set Dma Length
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byDmaLength - Dma Length Value
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetDmaLength (DWORD_PTR dwIoBase, BYTE byDmaLength)
+{
+ BYTE byOrgValue;
+
+ ASSERT(byDmaLength < 4);
+
+ // set FCR0
+ VNSvInPortB(dwIoBase + MAC_REG_FCR0, &byOrgValue);
+ byOrgValue = (byOrgValue & 0xFC) | byDmaLength;
+ VNSvOutPortB(dwIoBase + MAC_REG_FCR0, byOrgValue);
+}
+
+/*
+ * Description:
+ * Get Dma Length
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyDmaLength- Dma Length Value Get
+ *
+ * Return Value: none
+ *
+ */
+void MACvGetDmaLength (DWORD_PTR dwIoBase, PBYTE pbyDmaLength)
+{
+ // get FCR0
+ VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyDmaLength);
+ *pbyDmaLength &= 0x03;
+}
+
+/*
+ * Description:
+ * Set 802.11 Short Retry Limit
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byRetryLimit- Retry Limit
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetShortRetryLimit (DWORD_PTR dwIoBase, BYTE byRetryLimit)
+{
+ // set SRT
+ VNSvOutPortB(dwIoBase + MAC_REG_SRT, byRetryLimit);
+}
+
+/*
+ * Description:
+ * Get 802.11 Short Retry Limit
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyRetryLimit - Retry Limit Get
+ *
+ * Return Value: none
+ *
+ */
+void MACvGetShortRetryLimit (DWORD_PTR dwIoBase, PBYTE pbyRetryLimit)
+{
+ // get SRT
+ VNSvInPortB(dwIoBase + MAC_REG_SRT, pbyRetryLimit);
+}
+
+/*
+ * Description:
+ * Set 802.11 Long Retry Limit
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byRetryLimit- Retry Limit
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetLongRetryLimit (DWORD_PTR dwIoBase, BYTE byRetryLimit)
+{
+ // set LRT
+ VNSvOutPortB(dwIoBase + MAC_REG_LRT, byRetryLimit);
+}
+
+/*
+ * Description:
+ * Get 802.11 Long Retry Limit
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyRetryLimit - Retry Limit Get
+ *
+ * Return Value: none
+ *
+ */
+void MACvGetLongRetryLimit (DWORD_PTR dwIoBase, PBYTE pbyRetryLimit)
+{
+ // get LRT
+ VNSvInPortB(dwIoBase + MAC_REG_LRT, pbyRetryLimit);
+}
+
+/*
+ * Description:
+ * Set MAC Loopback mode
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * byLoopbackMode - Loopback Mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetLoopbackMode (DWORD_PTR dwIoBase, BYTE byLoopbackMode)
+{
+ BYTE byOrgValue;
+
+ ASSERT(byLoopbackMode < 3);
+ byLoopbackMode <<= 6;
+ // set TCR
+ VNSvInPortB(dwIoBase + MAC_REG_TEST, &byOrgValue);
+ byOrgValue = byOrgValue & 0x3F;
+ byOrgValue = byOrgValue | byLoopbackMode;
+ VNSvOutPortB(dwIoBase + MAC_REG_TEST, byOrgValue);
+}
+
+/*
+ * Description:
+ * Test if MAC in Loopback mode
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if in Loopback mode; otherwise FALSE
+ *
+ */
+BOOL MACbIsInLoopbackMode (DWORD_PTR dwIoBase)
+{
+ BYTE byOrgValue;
+
+ VNSvInPortB(dwIoBase + MAC_REG_TEST, &byOrgValue);
+ if (BITbIsAnyBitsOn(byOrgValue, (TEST_LBINT | TEST_LBEXT)))
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Description:
+ * Set MAC Address filter
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * wFilterType - Filter Type
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetPacketFilter (DWORD_PTR dwIoBase, WORD wFilterType)
+{
+ BYTE byOldRCR;
+ BYTE byNewRCR = 0;
+
+ // if only in DIRECTED mode, multicast-address will set to zero,
+ // but if other mode exist (e.g. PROMISCUOUS), multicast-address
+ // will be open
+ if (BITbIsBitOn(wFilterType, PKT_TYPE_DIRECTED)) {
+ // set multicast address to accept none
+ MACvSelectPage1(dwIoBase);
+ VNSvOutPortD(dwIoBase + MAC_REG_MAR0, 0L);
+ VNSvOutPortD(dwIoBase + MAC_REG_MAR0 + sizeof(DWORD), 0L);
+ MACvSelectPage0(dwIoBase);
+ }
+
+ if (BITbIsAnyBitsOn(wFilterType, PKT_TYPE_PROMISCUOUS | PKT_TYPE_ALL_MULTICAST)) {
+ // set multicast address to accept all
+ MACvSelectPage1(dwIoBase);
+ VNSvOutPortD(dwIoBase + MAC_REG_MAR0, 0xFFFFFFFFL);
+ VNSvOutPortD(dwIoBase + MAC_REG_MAR0 + sizeof(DWORD), 0xFFFFFFFFL);
+ MACvSelectPage0(dwIoBase);
+ }
+
+ if (BITbIsBitOn(wFilterType, PKT_TYPE_PROMISCUOUS)) {
+
+ byNewRCR |= (RCR_RXALLTYPE | RCR_UNICAST | RCR_MULTICAST | RCR_BROADCAST);
+
+ byNewRCR &= ~RCR_BSSID;
+ }
+
+ if (BITbIsAnyBitsOn(wFilterType, (PKT_TYPE_ALL_MULTICAST | PKT_TYPE_MULTICAST)))
+ byNewRCR |= RCR_MULTICAST;
+
+ if (BITbIsBitOn(wFilterType, PKT_TYPE_BROADCAST))
+ byNewRCR |= RCR_BROADCAST;
+
+ if (BITbIsBitOn(wFilterType, PKT_TYPE_ERROR_CRC))
+ byNewRCR |= RCR_ERRCRC;
+
+ VNSvInPortB(dwIoBase + MAC_REG_RCR, &byOldRCR);
+ if (byNewRCR != byOldRCR) {
+ // Modify the Receive Command Register
+ VNSvOutPortB(dwIoBase + MAC_REG_RCR, byNewRCR);
+ }
+}
+
+/*
+ * Description:
+ * Save MAC registers to context buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * pbyCxtBuf - Context buffer
+ *
+ * Return Value: none
+ *
+ */
+void MACvSaveContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf)
+{
+ int ii;
+
+ // read page0 register
+ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++) {
+ VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + ii));
+ }
+
+ MACvSelectPage1(dwIoBase);
+
+ // read page1 register
+ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) {
+ VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
+ }
+
+ MACvSelectPage0(dwIoBase);
+}
+
+/*
+ * Description:
+ * Restore MAC registers from context buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * pbyCxtBuf - Context buffer
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID MACvRestoreContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf)
+{
+ int ii;
+
+ MACvSelectPage1(dwIoBase);
+ // restore page1
+ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) {
+ VNSvOutPortB((dwIoBase + ii), *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
+ }
+ MACvSelectPage0(dwIoBase);
+
+ // restore RCR,TCR,IMR...
+ for (ii = MAC_REG_RCR; ii < MAC_REG_ISR; ii++) {
+ VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
+ }
+ // restore MAC Config.
+ for (ii = MAC_REG_LRT; ii < MAC_REG_PAGE1SEL; ii++) {
+ VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
+ }
+ VNSvOutPortB(dwIoBase + MAC_REG_CFG, *(pbyCxtBuf + MAC_REG_CFG));
+
+ // restore PS Config.
+ for (ii = MAC_REG_PSCFG; ii < MAC_REG_BBREGCTL; ii++) {
+ VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
+ }
+
+ // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
+ VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(PDWORD)(pbyCxtBuf + MAC_REG_TXDMAPTR0));
+ VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(PDWORD)(pbyCxtBuf + MAC_REG_AC0DMAPTR));
+ VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(PDWORD)(pbyCxtBuf + MAC_REG_BCNDMAPTR));
+
+
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR0));
+
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR1));
+
+}
+
+/*
+ * Description:
+ * Compare if MAC registers same as context buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * pbyCxtBuf - Context buffer
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all values are the same; otherwise FALSE
+ *
+ */
+BOOL MACbCompareContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf)
+{
+ DWORD dwData;
+
+ // compare MAC context to determine if this is a power lost init,
+ // return TRUE for power remaining init, return FALSE for power lost init
+
+ // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
+ VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, &dwData);
+ if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_TXDMAPTR0)) {
+ return FALSE;
+ }
+
+ VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, &dwData);
+ if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_AC0DMAPTR)) {
+ return FALSE;
+ }
+
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, &dwData);
+ if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR0)) {
+ return FALSE;
+ }
+
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, &dwData);
+ if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR1)) {
+ return FALSE;
+ }
+
+
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Software Reset MAC
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if Reset Success; otherwise FALSE
+ *
+ */
+BOOL MACbSoftwareReset (DWORD_PTR dwIoBase)
+{
+ BYTE byData;
+ WORD ww;
+
+ // turn on HOSTCR_SOFTRST, just write 0x01 to reset
+ //MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_SOFTRST);
+ VNSvOutPortB(dwIoBase+ MAC_REG_HOSTCR, 0x01);
+
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData);
+ if (BITbIsBitOff(byData, HOSTCR_SOFTRST))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT)
+ return FALSE;
+ return TRUE;
+
+}
+
+/*
+ * Description:
+ * save some important register's value, then do reset, then restore register's value
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL MACbSafeSoftwareReset (DWORD_PTR dwIoBase)
+{
+ BYTE abyTmpRegData[MAC_MAX_CONTEXT_SIZE_PAGE0+MAC_MAX_CONTEXT_SIZE_PAGE1];
+ BOOL bRetVal;
+
+ // PATCH....
+ // save some important register's value, then do
+ // reset, then restore register's value
+
+ // save MAC context
+ MACvSaveContext(dwIoBase, abyTmpRegData);
+ // do reset
+ bRetVal = MACbSoftwareReset(dwIoBase);
+ //BBvSoftwareReset(pDevice->PortOffset);
+ // restore MAC context, except CR0
+ MACvRestoreContext(dwIoBase, abyTmpRegData);
+
+ return bRetVal;
+}
+
+/*
+ * Description:
+ * Trun Off MAC Rx
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL MACbSafeRxOff (DWORD_PTR dwIoBase)
+{
+ WORD ww;
+ DWORD dwData;
+ BYTE byData;
+
+ // turn off wow temp for turn off Rx safely
+
+ // Clear RX DMA0,1
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_CLRRUN);
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_CLRRUN);
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL0, &dwData);
+ if (BITbIsAllBitsOff(dwData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x10);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x10)\n");
+ return(FALSE);
+ }
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL1, &dwData);
+ if (BITbIsAllBitsOff(dwData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x11);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x11)\n");
+ return(FALSE);
+ }
+
+ // try to safe shutdown RX
+ MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_RXON);
+ // W_MAX_TIMEOUT is the timeout period
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData);
+ if (BITbIsAllBitsOff(byData, HOSTCR_RXONST))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x12);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x12)\n");
+ return(FALSE);
+ }
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Trun Off MAC Tx
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL MACbSafeTxOff (DWORD_PTR dwIoBase)
+{
+ WORD ww;
+ DWORD dwData;
+ BYTE byData;
+
+ // Clear TX DMA
+ //Tx0
+ VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_CLRRUN);
+ //AC0
+ VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_CLRRUN);
+
+
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_TXDMACTL0, &dwData);
+ if (BITbIsAllBitsOff(dwData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x20);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x20)\n");
+ return(FALSE);
+ }
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_AC0DMACTL, &dwData);
+ if (BITbIsAllBitsOff(dwData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x21);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x21)\n");
+ return(FALSE);
+ }
+
+ // try to safe shutdown TX
+ MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_TXON);
+
+ // W_MAX_TIMEOUT is the timeout period
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData);
+ if (BITbIsAllBitsOff(byData, HOSTCR_TXONST))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x24);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x24)\n");
+ return(FALSE);
+ }
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Stop MAC function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL MACbSafeStop (DWORD_PTR dwIoBase)
+{
+ MACvRegBitsOff(dwIoBase, MAC_REG_TCR, TCR_AUTOBCNTX);
+
+ if (MACbSafeRxOff(dwIoBase) == FALSE) {
+ DBG_PORT80(0xA1);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" MACbSafeRxOff == FALSE)\n");
+ MACbSafeSoftwareReset(dwIoBase);
+ return FALSE;
+ }
+ if (MACbSafeTxOff(dwIoBase) == FALSE) {
+ DBG_PORT80(0xA2);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" MACbSafeTxOff == FALSE)\n");
+ MACbSafeSoftwareReset(dwIoBase);
+ return FALSE;
+ }
+
+ MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_MACEN);
+
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Shut Down MAC
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL MACbShutdown (DWORD_PTR dwIoBase)
+{
+ // disable MAC IMR
+ MACvIntDisable(dwIoBase);
+ MACvSetLoopbackMode(dwIoBase, MAC_LB_INTERNAL);
+ // stop the adapter
+ if (!MACbSafeStop(dwIoBase)) {
+ MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE);
+ return FALSE;
+ }
+ MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE);
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Initialize MAC
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvInitialize (DWORD_PTR dwIoBase)
+{
+ // clear sticky bits
+ MACvClearStckDS(dwIoBase);
+ // disable force PME-enable
+ VNSvOutPortB(dwIoBase + MAC_REG_PMC1, PME_OVR);
+ // only 3253 A
+ /*
+ MACvPwrEvntDisable(dwIoBase);
+ // clear power status
+ VNSvOutPortW(dwIoBase + MAC_REG_WAKEUPSR0, 0x0F0F);
+ */
+
+ // do reset
+ MACbSoftwareReset(dwIoBase);
+
+ // issue AUTOLD in EECSR to reload eeprom
+ //MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD);
+ // wait until EEPROM loading complete
+ //while (TRUE) {
+ // U8 u8Data;
+ // VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &u8Data);
+ // if (BITbIsBitOff(u8Data, I2MCSR_AUTOLD))
+ // break;
+ //}
+
+ // reset TSF counter
+ VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
+ // enable TSF counter
+ VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
+
+
+ // set packet filter
+ // receive directed and broadcast address
+
+ MACvSetPacketFilter(dwIoBase, PKT_TYPE_DIRECTED | PKT_TYPE_BROADCAST);
+
+}
+
+/*
+ * Description:
+ * Set the chip with current rx descriptor address
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * dwCurrDescAddr - Descriptor Address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetCurrRx0DescAddr (DWORD_PTR dwIoBase, DWORD dwCurrDescAddr)
+{
+WORD ww;
+BYTE byData;
+BYTE byOrgDMACtl;
+
+ VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL0, &byOrgDMACtl);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL0+2, DMACTL_RUN);
+ }
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL0, &byData);
+ if (BITbIsAllBitsOff(byData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x13);
+ }
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, dwCurrDescAddr);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_RUN);
+ }
+}
+
+/*
+ * Description:
+ * Set the chip with current rx descriptor address
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * dwCurrDescAddr - Descriptor Address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetCurrRx1DescAddr (DWORD_PTR dwIoBase, DWORD dwCurrDescAddr)
+{
+WORD ww;
+BYTE byData;
+BYTE byOrgDMACtl;
+
+ VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL1, &byOrgDMACtl);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL1+2, DMACTL_RUN);
+ }
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL1, &byData);
+ if (BITbIsAllBitsOff(byData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x14);
+ }
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, dwCurrDescAddr);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_RUN);
+ }
+}
+
+/*
+ * Description:
+ * Set the chip with current tx0 descriptor address
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * dwCurrDescAddr - Descriptor Address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetCurrTx0DescAddrEx (DWORD_PTR dwIoBase, DWORD dwCurrDescAddr)
+{
+WORD ww;
+BYTE byData;
+BYTE byOrgDMACtl;
+
+ VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byOrgDMACtl);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0+2, DMACTL_RUN);
+ }
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byData);
+ if (BITbIsAllBitsOff(byData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x25);
+ }
+ VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, dwCurrDescAddr);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_RUN);
+ }
+}
+
+/*
+ * Description:
+ * Set the chip with current AC0 descriptor address
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * dwCurrDescAddr - Descriptor Address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+ //TxDMA1 = AC0DMA
+void MACvSetCurrAC0DescAddrEx (DWORD_PTR dwIoBase, DWORD dwCurrDescAddr)
+{
+WORD ww;
+BYTE byData;
+BYTE byOrgDMACtl;
+
+ VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byOrgDMACtl);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL+2, DMACTL_RUN);
+ }
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byData);
+ if (BITbIsAllBitsOff(byData, DMACTL_RUN))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x26);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x26)\n");
+ }
+ VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, dwCurrDescAddr);
+ if (BITbIsAllBitsOn(byOrgDMACtl, DMACTL_RUN)) {
+ VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN);
+ }
+}
+
+
+
+void MACvSetCurrTXDescAddr (int iTxType, DWORD_PTR dwIoBase, DWORD dwCurrDescAddr)
+{
+ if(iTxType == TYPE_AC0DMA){
+ MACvSetCurrAC0DescAddrEx(dwIoBase, dwCurrDescAddr);
+ }else if(iTxType == TYPE_TXDMA0){
+ MACvSetCurrTx0DescAddrEx(dwIoBase, dwCurrDescAddr);
+ }
+}
+
+/*
+ * Description:
+ * Micro Second Delay via MAC
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * uDelay - Delay time (timer resolution is 4 us)
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID MACvTimer0MicroSDelay (DWORD_PTR dwIoBase, UINT uDelay)
+{
+BYTE byValue;
+UINT uu,ii;
+
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0);
+ VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelay);
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, (TMCTL_TMD | TMCTL_TE));
+ for(ii=0;ii<66;ii++) { // assume max PCI clock is 66Mhz
+ for (uu = 0; uu < uDelay; uu++) {
+ VNSvInPortB(dwIoBase + MAC_REG_TMCTL0, &byValue);
+ if ((byValue == 0) ||
+ (BITbIsAllBitsOn(byValue, TMCTL_TSUSP))) {
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0);
+ return;
+ }
+ }
+ }
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0);
+
+}
+
+/*
+ * Description:
+ * Micro Second One shot timer via MAC
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * uDelay - Delay time
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvOneShotTimer0MicroSec (DWORD_PTR dwIoBase, UINT uDelayTime)
+{
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0);
+ VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelayTime);
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, (TMCTL_TMD | TMCTL_TE));
+}
+
+/*
+ * Description:
+ * Micro Second One shot timer via MAC
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ * uDelay - Delay time
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvOneShotTimer1MicroSec (DWORD_PTR dwIoBase, UINT uDelayTime)
+{
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, 0);
+ VNSvOutPortD(dwIoBase + MAC_REG_TMDATA1, uDelayTime);
+ VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, (TMCTL_TMD | TMCTL_TE));
+}
+
+
+void MACvSetMISCFifo (DWORD_PTR dwIoBase, WORD wOffset, DWORD dwData)
+{
+ if (wOffset > 273)
+ return;
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+}
+
+
+BOOL MACbTxDMAOff (DWORD_PTR dwIoBase, UINT idx)
+{
+BYTE byData;
+UINT ww = 0;
+
+ if (idx == TYPE_TXDMA0) {
+ VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0+2, DMACTL_RUN);
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byData);
+ if (BITbIsAllBitsOff(byData, DMACTL_RUN))
+ break;
+ }
+ } else if (idx == TYPE_AC0DMA) {
+ VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL+2, DMACTL_RUN);
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byData);
+ if (BITbIsAllBitsOff(byData, DMACTL_RUN))
+ break;
+ }
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x29);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x29)\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void MACvClearBusSusInd (DWORD_PTR dwIoBase)
+{
+ DWORD dwOrgValue;
+ UINT ww;
+ // check if BcnSusInd enabled
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue);
+ if(BITbIsBitOff(dwOrgValue, EnCFG_BcnSusInd))
+ return;
+ //Set BcnSusClr
+ dwOrgValue = dwOrgValue | EnCFG_BcnSusClr;
+ VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue);
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue);
+ if(BITbIsBitOff(dwOrgValue, EnCFG_BcnSusInd))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x33);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x33)\n");
+ }
+}
+
+void MACvEnableBusSusEn (DWORD_PTR dwIoBase)
+{
+ BYTE byOrgValue;
+ DWORD dwOrgValue;
+ UINT ww;
+ // check if BcnSusInd enabled
+ VNSvInPortB(dwIoBase + MAC_REG_CFG , &byOrgValue);
+
+ //Set BcnSusEn
+ byOrgValue = byOrgValue | CFG_BCNSUSEN;
+ VNSvOutPortB(dwIoBase + MAC_REG_ENCFG, byOrgValue);
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue);
+ if(BITbIsBitOn(dwOrgValue, EnCFG_BcnSusInd))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x34);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x34)\n");
+ }
+}
+
+BOOL MACbFlushSYNCFifo (DWORD_PTR dwIoBase)
+{
+ BYTE byOrgValue;
+ UINT ww;
+ // Read MACCR
+ VNSvInPortB(dwIoBase + MAC_REG_MACCR , &byOrgValue);
+
+ // Set SYNCFLUSH
+ byOrgValue = byOrgValue | MACCR_SYNCFLUSH;
+ VNSvOutPortB(dwIoBase + MAC_REG_MACCR, byOrgValue);
+
+ // Check if SyncFlushOK
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_MACCR , &byOrgValue);
+ if(BITbIsBitOn(byOrgValue, MACCR_SYNCFLUSHOK))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x35);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x33)\n");
+ }
+ return TRUE;
+}
+
+BOOL MACbPSWakeup (DWORD_PTR dwIoBase)
+{
+ BYTE byOrgValue;
+ UINT ww;
+ // Read PSCTL
+ if (MACbIsRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PS)) {
+ return TRUE;
+ }
+ // Disable PS
+ MACvRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PSEN);
+
+ // Check if SyncFlushOK
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortB(dwIoBase + MAC_REG_PSCTL , &byOrgValue);
+ if(BITbIsBitOn(byOrgValue, PSCTL_WAKEDONE))
+ break;
+ }
+ if (ww == W_MAX_TIMEOUT) {
+ DBG_PORT80(0x36);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" DBG_PORT80(0x33)\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Description:
+ * Set the Key by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+void MACvSetKeyEntry (DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, UINT uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID)
+{
+WORD wOffset;
+DWORD dwData;
+int ii;
+
+ if (byLocalID <= 1)
+ return;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvSetKeyEntry\n");
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
+
+ dwData = 0;
+ dwData |= wKeyCtl;
+ dwData <<= 16;
+ dwData |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset, dwData, wKeyCtl);
+
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ wOffset++;
+
+ dwData = 0;
+ dwData |= *(pbyAddr+3);
+ dwData <<= 8;
+ dwData |= *(pbyAddr+2);
+ dwData <<= 8;
+ dwData |= *(pbyAddr+1);
+ dwData <<= 8;
+ dwData |= *(pbyAddr+0);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %lX\n", wOffset, dwData);
+
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ wOffset++;
+
+ wOffset += (uKeyIdx * 4);
+ for (ii=0;ii<4;ii++) {
+ // alway push 128 bits
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"3.(%d) wOffset: %d, Data: %lX\n", ii, wOffset+ii, *pdwKey);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, *pdwKey++);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ }
+}
+
+
+
+/*
+ * Description:
+ * Disable the Key Entry by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvDisableKeyEntry (DWORD_PTR dwIoBase, UINT uEntryIdx)
+{
+WORD wOffset;
+
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
+
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, 0);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+}
+
+
+/*
+ * Description:
+ * Set the default Key (KeyEntry[10]) by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+void MACvSetDefaultKeyEntry (DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID)
+{
+WORD wOffset;
+DWORD dwData;
+int ii;
+
+ if (byLocalID <= 1)
+ return;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvSetDefaultKeyEntry\n");
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
+
+ wOffset++;
+ wOffset++;
+ wOffset += (uKeyIdx * 4);
+ // alway push 128 bits
+ for (ii=0; ii<3; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"(%d) wOffset: %d, Data: %lX\n", ii, wOffset+ii, *pdwKey);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, *pdwKey++);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ }
+ dwData = *pdwKey;
+ if (uKeyLen == WLAN_WEP104_KEYLEN) {
+ dwData |= 0x80000000;
+ }
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+3);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"End. wOffset: %d, Data: %lX\n", wOffset+3, dwData);
+
+}
+
+
+/*
+ * Description:
+ * Enable default Key (KeyEntry[10]) by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+/*
+void MACvEnableDefaultKey (DWORD_PTR dwIoBase, BYTE byLocalID)
+{
+WORD wOffset;
+DWORD dwData;
+
+
+ if (byLocalID <= 1)
+ return;
+
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
+
+ dwData = 0xC0440000;
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvEnableDefaultKey: wOffset: %d, Data: %lX\n", wOffset, dwData);
+
+}
+*/
+
+/*
+ * Description:
+ * Disable default Key (KeyEntry[10]) by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvDisableDefaultKey (DWORD_PTR dwIoBase)
+{
+WORD wOffset;
+DWORD dwData;
+
+
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
+
+ dwData = 0x0;
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvDisableDefaultKey: wOffset: %d, Data: %lX\n", wOffset, dwData);
+}
+
+/*
+ * Description:
+ * Set the default TKIP Group Key (KeyEntry[10]) by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetDefaultTKIPKeyEntry (DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID)
+{
+WORD wOffset;
+DWORD dwData;
+int ii;
+
+ if (byLocalID <= 1)
+ return;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvSetDefaultTKIPKeyEntry\n");
+ wOffset = MISCFIFO_KEYETRY0;
+ // Kyle test : change offset from 10 -> 0
+ wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
+
+ dwData = 0xC0660000;
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ wOffset++;
+
+ dwData = 0;
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ wOffset++;
+
+ wOffset += (uKeyIdx * 4);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %lX, idx:%d\n", wOffset, *pdwKey, uKeyIdx);
+ // alway push 128 bits
+ for (ii=0; ii<4; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2.(%d) wOffset: %d, Data: %lX\n", ii, wOffset+ii, *pdwKey);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, *pdwKey++);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+ }
+
+}
+
+
+
+/*
+ * Description:
+ * Set the Key Control by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+void MACvSetDefaultKeyCtl (DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, BYTE byLocalID)
+{
+WORD wOffset;
+DWORD dwData;
+
+ if (byLocalID <= 1)
+ return;
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvSetKeyEntry\n");
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
+
+ dwData = 0;
+ dwData |= wKeyCtl;
+ dwData <<= 16;
+ dwData |= 0xffff;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset, dwData, wKeyCtl);
+
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+
+}
+
diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h
new file mode 100644
index 000000000000..edb70965d4dc
--- /dev/null
+++ b/drivers/staging/vt6655/mac.h
@@ -0,0 +1,1166 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: mac.h
+ *
+ * Purpose: MAC routines
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ * Revision History:
+ * 07-01-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
+ * 08-25-2003 Kyle Hsu: Porting MAC functions from sim53.
+ * 09-03-2003 Bryan YC Fan: Add MACvDisableProtectMD & MACvEnableProtectMD
+ *
+ */
+
+#ifndef __MAC_H__
+#define __MAC_H__
+
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__UPC_H__)
+#include "upc.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+//
+// Registers in the MAC
+//
+#define MAC_MAX_CONTEXT_SIZE_PAGE0 256
+#define MAC_MAX_CONTEXT_SIZE_PAGE1 128
+#define MAC_MAX_CONTEXT_SIZE MAC_MAX_CONTEXT_SIZE_PAGE0 + MAC_MAX_CONTEXT_SIZE_PAGE1
+
+// Registers not related to 802.11b
+#define MAC_REG_BCFG0 0x00
+#define MAC_REG_BCFG1 0x01
+#define MAC_REG_FCR0 0x02
+#define MAC_REG_FCR1 0x03
+#define MAC_REG_BISTCMD 0x04
+#define MAC_REG_BISTSR0 0x05
+#define MAC_REG_BISTSR1 0x06
+#define MAC_REG_BISTSR2 0x07
+#define MAC_REG_I2MCSR 0x08
+#define MAC_REG_I2MTGID 0x09
+#define MAC_REG_I2MTGAD 0x0A
+#define MAC_REG_I2MCFG 0x0B
+#define MAC_REG_I2MDIPT 0x0C
+#define MAC_REG_I2MDOPT 0x0E
+#define MAC_REG_PMC0 0x10
+#define MAC_REG_PMC1 0x11
+#define MAC_REG_STICKHW 0x12
+#define MAC_REG_LOCALID 0x14
+#define MAC_REG_TESTCFG 0x15
+#define MAC_REG_JUMPER0 0x16
+#define MAC_REG_JUMPER1 0x17
+#define MAC_REG_TMCTL0 0x18
+#define MAC_REG_TMCTL1 0x19
+#define MAC_REG_TMDATA0 0x1C
+// MAC Parameter related
+#define MAC_REG_LRT 0x20 //
+#define MAC_REG_SRT 0x21 //
+#define MAC_REG_SIFS 0x22 //
+#define MAC_REG_DIFS 0x23 //
+#define MAC_REG_EIFS 0x24 //
+#define MAC_REG_SLOT 0x25 //
+#define MAC_REG_BI 0x26 //
+#define MAC_REG_CWMAXMIN0 0x28 //
+#define MAC_REG_LINKOFFTOTM 0x2A
+#define MAC_REG_SWTMOT 0x2B
+#define MAC_REG_MIBCNTR 0x2C
+#define MAC_REG_RTSOKCNT 0x2C
+#define MAC_REG_RTSFAILCNT 0x2D
+#define MAC_REG_ACKFAILCNT 0x2E
+#define MAC_REG_FCSERRCNT 0x2F
+// TSF Related
+#define MAC_REG_TSFCNTR 0x30 //
+#define MAC_REG_NEXTTBTT 0x38 //
+#define MAC_REG_TSFOFST 0x40 //
+#define MAC_REG_TFTCTL 0x48 //
+// WMAC Control/Status Related
+#define MAC_REG_ENCFG 0x4C //
+#define MAC_REG_PAGE1SEL 0x4F //
+#define MAC_REG_CFG 0x50 //
+#define MAC_REG_TEST 0x52 //
+#define MAC_REG_HOSTCR 0x54 //
+#define MAC_REG_MACCR 0x55 //
+#define MAC_REG_RCR 0x56 //
+#define MAC_REG_TCR 0x57 //
+#define MAC_REG_IMR 0x58 //
+#define MAC_REG_ISR 0x5C
+// Power Saving Related
+#define MAC_REG_PSCFG 0x60 //
+#define MAC_REG_PSCTL 0x61 //
+#define MAC_REG_PSPWRSIG 0x62 //
+#define MAC_REG_BBCR13 0x63
+#define MAC_REG_AIDATIM 0x64
+#define MAC_REG_PWBT 0x66
+#define MAC_REG_WAKEOKTMR 0x68
+#define MAC_REG_CALTMR 0x69
+#define MAC_REG_SYNSPACCNT 0x6A
+#define MAC_REG_WAKSYNOPT 0x6B
+// Baseband/IF Control Group
+#define MAC_REG_BBREGCTL 0x6C //
+#define MAC_REG_CHANNEL 0x6D
+#define MAC_REG_BBREGADR 0x6E
+#define MAC_REG_BBREGDATA 0x6F
+#define MAC_REG_IFREGCTL 0x70 //
+#define MAC_REG_IFDATA 0x71 //
+#define MAC_REG_ITRTMSET 0x74 //
+#define MAC_REG_PAPEDELAY 0x77 //
+#define MAC_REG_SOFTPWRCTL 0x78 //
+#define MAC_REG_GPIOCTL0 0x7A //
+#define MAC_REG_GPIOCTL1 0x7B //
+
+// MAC DMA Related Group
+#define MAC_REG_TXDMACTL0 0x7C //
+#define MAC_REG_TXDMAPTR0 0x80 //
+#define MAC_REG_AC0DMACTL 0x84 //
+#define MAC_REG_AC0DMAPTR 0x88 //
+#define MAC_REG_BCNDMACTL 0x8C //
+#define MAC_REG_BCNDMAPTR 0x90 //
+#define MAC_REG_RXDMACTL0 0x94 //
+#define MAC_REG_RXDMAPTR0 0x98 //
+#define MAC_REG_RXDMACTL1 0x9C //
+#define MAC_REG_RXDMAPTR1 0xA0 //
+#define MAC_REG_SYNCDMACTL 0xA4 //
+#define MAC_REG_SYNCDMAPTR 0xA8
+#define MAC_REG_ATIMDMACTL 0xAC
+#define MAC_REG_ATIMDMAPTR 0xB0
+// MiscFF PIO related
+#define MAC_REG_MISCFFNDEX 0xB4
+#define MAC_REG_MISCFFCTL 0xB6
+#define MAC_REG_MISCFFDATA 0xB8
+// Extend SW Timer
+#define MAC_REG_TMDATA1 0xBC
+// WOW Related Group
+#define MAC_REG_WAKEUPEN0 0xC0
+#define MAC_REG_WAKEUPEN1 0xC1
+#define MAC_REG_WAKEUPSR0 0xC2
+#define MAC_REG_WAKEUPSR1 0xC3
+#define MAC_REG_WAKE128_0 0xC4
+#define MAC_REG_WAKE128_1 0xD4
+#define MAC_REG_WAKE128_2 0xE4
+#define MAC_REG_WAKE128_3 0xF4
+
+/////////////// Page 1 ///////////////////
+#define MAC_REG_CRC_128_0 0x04
+#define MAC_REG_CRC_128_1 0x06
+#define MAC_REG_CRC_128_2 0x08
+#define MAC_REG_CRC_128_3 0x0A
+// MAC Configuration Group
+#define MAC_REG_PAR0 0x0C
+#define MAC_REG_PAR4 0x10
+#define MAC_REG_BSSID0 0x14
+#define MAC_REG_BSSID4 0x18
+#define MAC_REG_MAR0 0x1C
+#define MAC_REG_MAR4 0x20
+// MAC RSPPKT INFO Group
+#define MAC_REG_RSPINF_B_1 0x24
+#define MAC_REG_RSPINF_B_2 0x28
+#define MAC_REG_RSPINF_B_5 0x2C
+#define MAC_REG_RSPINF_B_11 0x30
+#define MAC_REG_RSPINF_A_6 0x34
+#define MAC_REG_RSPINF_A_9 0x36
+#define MAC_REG_RSPINF_A_12 0x38
+#define MAC_REG_RSPINF_A_18 0x3A
+#define MAC_REG_RSPINF_A_24 0x3C
+#define MAC_REG_RSPINF_A_36 0x3E
+#define MAC_REG_RSPINF_A_48 0x40
+#define MAC_REG_RSPINF_A_54 0x42
+#define MAC_REG_RSPINF_A_72 0x44
+
+// 802.11h relative
+#define MAC_REG_QUIETINIT 0x60
+#define MAC_REG_QUIETGAP 0x62
+#define MAC_REG_QUIETDUR 0x64
+#define MAC_REG_MSRCTL 0x66
+#define MAC_REG_MSRBBSTS 0x67
+#define MAC_REG_MSRSTART 0x68
+#define MAC_REG_MSRDURATION 0x70
+#define MAC_REG_CCAFRACTION 0x72
+#define MAC_REG_PWRCCK 0x73
+#define MAC_REG_PWROFDM 0x7C
+
+
+//
+// Bits in the BCFG0 register
+//
+#define BCFG0_PERROFF 0x40
+#define BCFG0_MRDMDIS 0x20
+#define BCFG0_MRDLDIS 0x10
+#define BCFG0_MWMEN 0x08
+#define BCFG0_VSERREN 0x02
+#define BCFG0_LATMEN 0x01
+
+//
+// Bits in the BCFG1 register
+//
+#define BCFG1_CFUNOPT 0x80
+#define BCFG1_CREQOPT 0x40
+#define BCFG1_DMA8 0x10
+#define BCFG1_ARBITOPT 0x08
+#define BCFG1_PCIMEN 0x04
+#define BCFG1_MIOEN 0x02
+#define BCFG1_CISDLYEN 0x01
+
+// Bits in RAMBIST registers
+#define BISTCMD_TSTPAT5 0x00 //
+#define BISTCMD_TSTPATA 0x80 //
+#define BISTCMD_TSTERR 0x20 //
+#define BISTCMD_TSTPATF 0x18 //
+#define BISTCMD_TSTPAT0 0x10 //
+#define BISTCMD_TSTMODE 0x04 //
+#define BISTCMD_TSTITTX 0x03 //
+#define BISTCMD_TSTATRX 0x02 //
+#define BISTCMD_TSTATTX 0x01 //
+#define BISTCMD_TSTRX 0x00 //
+#define BISTSR0_BISTGO 0x01 //
+#define BISTSR1_TSTSR 0x01 //
+#define BISTSR2_CMDPRTEN 0x02 //
+#define BISTSR2_RAMTSTEN 0x01 //
+
+//
+// Bits in the I2MCFG EEPROM register
+//
+#define I2MCFG_BOUNDCTL 0x80
+#define I2MCFG_WAITCTL 0x20
+#define I2MCFG_SCLOECTL 0x10
+#define I2MCFG_WBUSYCTL 0x08
+#define I2MCFG_NORETRY 0x04
+#define I2MCFG_I2MLDSEQ 0x02
+#define I2MCFG_I2CMFAST 0x01
+
+//
+// Bits in the I2MCSR EEPROM register
+//
+#define I2MCSR_EEMW 0x80
+#define I2MCSR_EEMR 0x40
+#define I2MCSR_AUTOLD 0x08
+#define I2MCSR_NACK 0x02
+#define I2MCSR_DONE 0x01
+
+//
+// Bits in the PMC1 register
+//
+#define SPS_RST 0x80
+#define PCISTIKY 0x40
+#define PME_OVR 0x02
+
+//
+// Bits in the STICKYHW register
+//
+#define STICKHW_DS1_SHADOW 0x02
+#define STICKHW_DS0_SHADOW 0x01
+
+//
+// Bits in the TMCTL register
+//
+#define TMCTL_TSUSP 0x04
+#define TMCTL_TMD 0x02
+#define TMCTL_TE 0x01
+
+//
+// Bits in the TFTCTL register
+//
+#define TFTCTL_HWUTSF 0x80 //
+#define TFTCTL_TBTTSYNC 0x40
+#define TFTCTL_HWUTSFEN 0x20
+#define TFTCTL_TSFCNTRRD 0x10 //
+#define TFTCTL_TBTTSYNCEN 0x08 //
+#define TFTCTL_TSFSYNCEN 0x04 //
+#define TFTCTL_TSFCNTRST 0x02 //
+#define TFTCTL_TSFCNTREN 0x01 //
+
+//
+// Bits in the EnhanceCFG register
+//
+#define EnCFG_BarkerPream 0x00020000
+#define EnCFG_NXTBTTCFPSTR 0x00010000
+//#define EnCFG_TXLMT3UPDATE 0x00008000
+//#define EnCFG_TXLMT2UPDATE 0x00004000
+//#define EnCFG_TXLMT1UPDATE 0x00002000
+//#define EnCFG_TXLMT3EN 0x00001000
+//#define EnCFG_TXLMT2EN 0x00000800
+//#define EnCFG_TXLMT1EN 0x00000400
+#define EnCFG_BcnSusClr 0x00000200
+#define EnCFG_BcnSusInd 0x00000100
+//#define EnCFG_CWOFF1 0x00000080
+#define EnCFG_CFP_ProtectEn 0x00000040
+#define EnCFG_ProtectMd 0x00000020
+#define EnCFG_HwParCFP 0x00000010
+//#define EnCFG_QOS 0x00000008
+#define EnCFG_CFNULRSP 0x00000004
+#define EnCFG_BBType_MASK 0x00000003
+#define EnCFG_BBType_g 0x00000002
+#define EnCFG_BBType_b 0x00000001
+#define EnCFG_BBType_a 0x00000000
+
+//
+// Bits in the Page1Sel register
+//
+#define PAGE1_SEL 0x01
+
+//
+// Bits in the CFG register
+//
+#define CFG_TKIPOPT 0x80
+#define CFG_RXDMAOPT 0x40
+#define CFG_TMOT_SW 0x20
+#define CFG_TMOT_HWLONG 0x10
+#define CFG_TMOT_HW 0x00
+#define CFG_CFPENDOPT 0x08
+#define CFG_BCNSUSEN 0x04
+#define CFG_NOTXTIMEOUT 0x02
+#define CFG_NOBUFOPT 0x01
+
+//
+// Bits in the TEST register
+//
+#define TEST_LBEXT 0x80 //
+#define TEST_LBINT 0x40 //
+#define TEST_LBNONE 0x00 //
+#define TEST_SOFTINT 0x20 //
+#define TEST_CONTTX 0x10 //
+#define TEST_TXPE 0x08 //
+#define TEST_NAVDIS 0x04 //
+#define TEST_NOCTS 0x02 //
+#define TEST_NOACK 0x01 //
+
+//
+// Bits in the HOSTCR register
+//
+#define HOSTCR_TXONST 0x80 //
+#define HOSTCR_RXONST 0x40 //
+#define HOSTCR_ADHOC 0x20 // Network Type 1 = Ad-hoc
+#define HOSTCR_AP 0x10 // Port Type 1 = AP
+#define HOSTCR_TXON 0x08 //0000 1000
+#define HOSTCR_RXON 0x04 //0000 0100
+#define HOSTCR_MACEN 0x02 //0000 0010
+#define HOSTCR_SOFTRST 0x01 //0000 0001
+
+//
+// Bits in the MACCR register
+//
+#define MACCR_SYNCFLUSHOK 0x04 //
+#define MACCR_SYNCFLUSH 0x02 //
+#define MACCR_CLRNAV 0x01 //
+
+// Bits in the MAC_REG_GPIOCTL0 register
+//
+#define LED_ACTSET 0x01 //
+#define LED_RFOFF 0x02 //
+#define LED_NOCONNECT 0x04 //
+//
+// Bits in the RCR register
+//
+#define RCR_SSID 0x80
+#define RCR_RXALLTYPE 0x40 //
+#define RCR_UNICAST 0x20 //
+#define RCR_BROADCAST 0x10 //
+#define RCR_MULTICAST 0x08 //
+#define RCR_WPAERR 0x04 //
+#define RCR_ERRCRC 0x02 //
+#define RCR_BSSID 0x01 //
+
+//
+// Bits in the TCR register
+//
+#define TCR_SYNCDCFOPT 0x02 //
+#define TCR_AUTOBCNTX 0x01 // Beacon automatically transmit enable
+
+//
+// Bits in the IMR register
+//
+#define IMR_MEASURESTART 0x80000000 //
+#define IMR_QUIETSTART 0x20000000 //
+#define IMR_RADARDETECT 0x10000000 //
+#define IMR_MEASUREEND 0x08000000 //
+#define IMR_SOFTTIMER1 0x00200000 //
+//#define IMR_SYNCFLUSHOK 0x00100000 //
+//#define IMR_ATIMEND 0x00080000 //0000 1000 0000 0000 0000 0000
+//#define IMR_CFPEND 0x00040000 //0000 0100 0000 0000 0000 0000
+//#define IMR_AC3DMA 0x00020000 //0000 0010 0000 0000 0000 0000
+//#define IMR_AC2DMA 0x00010000 //0000 0001 0000 0000 0000 0000
+//#define IMR_AC1DMA 0x00008000 //0000 0000 1000 0000 0000 0000
+//#define IMR_SYNCTX 0x00004000 //0000 0000 0100 0000 0000 0000
+//#define IMR_ATIMTX 0x00002000 //0000 0000 0010 0000 0000 0000
+#define IMR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000
+#define IMR_RXNOBUF 0x00000800 //
+#define IMR_MIBNEARFULL 0x00000400 //
+#define IMR_SOFTINT 0x00000200 //
+#define IMR_FETALERR 0x00000100 //
+#define IMR_WATCHDOG 0x00000080 //
+#define IMR_SOFTTIMER 0x00000040 //
+#define IMR_GPIO 0x00000020 //
+#define IMR_TBTT 0x00000010 //
+#define IMR_RXDMA0 0x00000008 //
+#define IMR_BNTX 0x00000004 //
+#define IMR_AC0DMA 0x00000002 //
+#define IMR_TXDMA0 0x00000001 //
+
+
+//
+// Bits in the ISR register
+//
+
+#define ISR_MEASURESTART 0x80000000 //
+#define ISR_QUIETSTART 0x20000000 //
+#define ISR_RADARDETECT 0x10000000 //
+#define ISR_MEASUREEND 0x08000000 //
+#define ISR_SOFTTIMER1 0x00200000 //
+//#define ISR_SYNCFLUSHOK 0x00100000 //0001 0000 0000 0000 0000 0000
+//#define ISR_ATIMEND 0x00080000 //0000 1000 0000 0000 0000 0000
+//#define ISR_CFPEND 0x00040000 //0000 0100 0000 0000 0000 0000
+//#define ISR_AC3DMA 0x00020000 //0000 0010 0000 0000 0000 0000
+//#define ISR_AC2DMA 0x00010000 //0000 0001 0000 0000 0000 0000
+//#define ISR_AC1DMA 0x00008000 //0000 0000 1000 0000 0000 0000
+//#define ISR_SYNCTX 0x00004000 //0000 0000 0100 0000 0000 0000
+//#define ISR_ATIMTX 0x00002000 //0000 0000 0010 0000 0000 0000
+#define ISR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000
+#define ISR_RXNOBUF 0x00000800 //0000 0000 0000 1000 0000 0000
+#define ISR_MIBNEARFULL 0x00000400 //0000 0000 0000 0100 0000 0000
+#define ISR_SOFTINT 0x00000200 //
+#define ISR_FETALERR 0x00000100 //
+#define ISR_WATCHDOG 0x00000080 //
+#define ISR_SOFTTIMER 0x00000040 //
+#define ISR_GPIO 0x00000020 //
+#define ISR_TBTT 0x00000010 //
+#define ISR_RXDMA0 0x00000008 //
+#define ISR_BNTX 0x00000004 //
+#define ISR_AC0DMA 0x00000002 //
+#define ISR_TXDMA0 0x00000001 //
+
+
+//
+// Bits in the PSCFG register
+//
+#define PSCFG_PHILIPMD 0x40 //
+#define PSCFG_WAKECALEN 0x20 //
+#define PSCFG_WAKETMREN 0x10 //
+#define PSCFG_BBPSPROG 0x08 //
+#define PSCFG_WAKESYN 0x04 //
+#define PSCFG_SLEEPSYN 0x02 //
+#define PSCFG_AUTOSLEEP 0x01 //
+
+//
+// Bits in the PSCTL register
+//
+#define PSCTL_WAKEDONE 0x20 //
+#define PSCTL_PS 0x10 //
+#define PSCTL_GO2DOZE 0x08 //
+#define PSCTL_LNBCN 0x04 //
+#define PSCTL_ALBCN 0x02 //
+#define PSCTL_PSEN 0x01 //
+
+//
+// Bits in the PSPWSIG register
+//
+#define PSSIG_WPE3 0x80 //
+#define PSSIG_WPE2 0x40 //
+#define PSSIG_WPE1 0x20 //
+#define PSSIG_WRADIOPE 0x10 //
+#define PSSIG_SPE3 0x08 //
+#define PSSIG_SPE2 0x04 //
+#define PSSIG_SPE1 0x02 //
+#define PSSIG_SRADIOPE 0x01 //
+
+//
+// Bits in the BBREGCTL register
+//
+#define BBREGCTL_DONE 0x04 //
+#define BBREGCTL_REGR 0x02 //
+#define BBREGCTL_REGW 0x01 //
+
+//
+// Bits in the IFREGCTL register
+//
+#define IFREGCTL_DONE 0x04 //
+#define IFREGCTL_IFRF 0x02 //
+#define IFREGCTL_REGW 0x01 //
+
+//
+// Bits in the SOFTPWRCTL register
+//
+#define SOFTPWRCTL_RFLEOPT 0x0800 //
+#define SOFTPWRCTL_TXPEINV 0x0200 //
+#define SOFTPWRCTL_SWPECTI 0x0100 //
+#define SOFTPWRCTL_SWPAPE 0x0020 //
+#define SOFTPWRCTL_SWCALEN 0x0010 //
+#define SOFTPWRCTL_SWRADIO_PE 0x0008 //
+#define SOFTPWRCTL_SWPE2 0x0004 //
+#define SOFTPWRCTL_SWPE1 0x0002 //
+#define SOFTPWRCTL_SWPE3 0x0001 //
+
+//
+// Bits in the GPIOCTL1 register
+//
+#define GPIO1_DATA1 0x20 //
+#define GPIO1_MD1 0x10 //
+#define GPIO1_DATA0 0x02 //
+#define GPIO1_MD0 0x01 //
+
+//
+// Bits in the DMACTL register
+//
+#define DMACTL_CLRRUN 0x00080000 //
+#define DMACTL_RUN 0x00000008 //
+#define DMACTL_WAKE 0x00000004 //
+#define DMACTL_DEAD 0x00000002 //
+#define DMACTL_ACTIVE 0x00000001 //
+//
+// Bits in the RXDMACTL0 register
+//
+#define RX_PERPKT 0x00000100 //
+#define RX_PERPKTCLR 0x01000000 //
+//
+// Bits in the BCNDMACTL register
+//
+#define BEACON_READY 0x01 //
+//
+// Bits in the MISCFFCTL register
+//
+#define MISCFFCTL_WRITE 0x0001 //
+
+
+//
+// Bits in WAKEUPEN0
+//
+#define WAKEUPEN0_DIRPKT 0x10
+#define WAKEUPEN0_LINKOFF 0x08
+#define WAKEUPEN0_ATIMEN 0x04
+#define WAKEUPEN0_TIMEN 0x02
+#define WAKEUPEN0_MAGICEN 0x01
+
+//
+// Bits in WAKEUPEN1
+//
+#define WAKEUPEN1_128_3 0x08
+#define WAKEUPEN1_128_2 0x04
+#define WAKEUPEN1_128_1 0x02
+#define WAKEUPEN1_128_0 0x01
+
+//
+// Bits in WAKEUPSR0
+//
+#define WAKEUPSR0_DIRPKT 0x10
+#define WAKEUPSR0_LINKOFF 0x08
+#define WAKEUPSR0_ATIMEN 0x04
+#define WAKEUPSR0_TIMEN 0x02
+#define WAKEUPSR0_MAGICEN 0x01
+
+//
+// Bits in WAKEUPSR1
+//
+#define WAKEUPSR1_128_3 0x08
+#define WAKEUPSR1_128_2 0x04
+#define WAKEUPSR1_128_1 0x02
+#define WAKEUPSR1_128_0 0x01
+
+//
+// Bits in the MAC_REG_GPIOCTL register
+//
+#define GPIO0_MD 0x01 //
+#define GPIO0_DATA 0x02 //
+#define GPIO0_INTMD 0x04 //
+#define GPIO1_MD 0x10 //
+#define GPIO1_DATA 0x20 //
+
+
+//
+// Bits in the MSRCTL register
+//
+#define MSRCTL_FINISH 0x80
+#define MSRCTL_READY 0x40
+#define MSRCTL_RADARDETECT 0x20
+#define MSRCTL_EN 0x10
+#define MSRCTL_QUIETTXCHK 0x08
+#define MSRCTL_QUIETRPT 0x04
+#define MSRCTL_QUIETINT 0x02
+#define MSRCTL_QUIETEN 0x01
+//
+// Bits in the MSRCTL1 register
+//
+#define MSRCTL1_TXPWR 0x08
+#define MSRCTL1_CSAPAREN 0x04
+#define MSRCTL1_TXPAUSE 0x01
+
+
+// Loopback mode
+#define MAC_LB_EXT 0x02 //
+#define MAC_LB_INTERNAL 0x01 //
+#define MAC_LB_NONE 0x00 //
+
+// Ethernet address filter type
+#define PKT_TYPE_NONE 0x00 // turn off receiver
+#define PKT_TYPE_ALL_MULTICAST 0x80
+#define PKT_TYPE_PROMISCUOUS 0x40
+#define PKT_TYPE_DIRECTED 0x20 // obselete, directed address is always accepted
+#define PKT_TYPE_BROADCAST 0x10
+#define PKT_TYPE_MULTICAST 0x08
+#define PKT_TYPE_ERROR_WPA 0x04
+#define PKT_TYPE_ERROR_CRC 0x02
+#define PKT_TYPE_BSSID 0x01
+
+#define Default_BI 0x200
+
+
+// MiscFIFO Offset
+#define MISCFIFO_KEYETRY0 32
+#define MISCFIFO_KEYENTRYSIZE 22
+#define MISCFIFO_SYNINFO_IDX 10
+#define MISCFIFO_SYNDATA_IDX 11
+#define MISCFIFO_SYNDATASIZE 21
+
+// enabled mask value of irq
+#define IMR_MASK_VALUE (IMR_SOFTTIMER1 | \
+ IMR_RXDMA1 | \
+ IMR_RXNOBUF | \
+ IMR_MIBNEARFULL | \
+ IMR_SOFTINT | \
+ IMR_FETALERR | \
+ IMR_WATCHDOG | \
+ IMR_SOFTTIMER | \
+ IMR_GPIO | \
+ IMR_TBTT | \
+ IMR_RXDMA0 | \
+ IMR_BNTX | \
+ IMR_AC0DMA | \
+ IMR_TXDMA0)
+
+// max time out delay time
+#define W_MAX_TIMEOUT 0xFFF0U //
+
+// wait time within loop
+#define CB_DELAY_LOOP_WAIT 10 // 10ms
+
+//
+// revision id
+//
+#define REV_ID_VT3253_A0 0x00
+#define REV_ID_VT3253_A1 0x01
+#define REV_ID_VT3253_B0 0x08
+#define REV_ID_VT3253_B1 0x09
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+#define MACvRegBitsOn(dwIoBase, byRegOfs, byBits) \
+{ \
+ BYTE byData; \
+ VNSvInPortB(dwIoBase + byRegOfs, &byData); \
+ VNSvOutPortB(dwIoBase + byRegOfs, byData | (byBits)); \
+}
+
+#define MACvWordRegBitsOn(dwIoBase, byRegOfs, wBits) \
+{ \
+ WORD wData; \
+ VNSvInPortW(dwIoBase + byRegOfs, &wData); \
+ VNSvOutPortW(dwIoBase + byRegOfs, wData | (wBits)); \
+}
+
+#define MACvDWordRegBitsOn(dwIoBase, byRegOfs, dwBits) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + byRegOfs, &dwData); \
+ VNSvOutPortD(dwIoBase + byRegOfs, dwData | (dwBits)); \
+}
+
+#define MACvRegBitsOnEx(dwIoBase, byRegOfs, byMask, byBits) \
+{ \
+ BYTE byData; \
+ VNSvInPortB(dwIoBase + byRegOfs, &byData); \
+ byData &= byMask; \
+ VNSvOutPortB(dwIoBase + byRegOfs, byData | (byBits)); \
+}
+
+#define MACvRegBitsOff(dwIoBase, byRegOfs, byBits) \
+{ \
+ BYTE byData; \
+ VNSvInPortB(dwIoBase + byRegOfs, &byData); \
+ VNSvOutPortB(dwIoBase + byRegOfs, byData & ~(byBits)); \
+}
+
+#define MACvWordRegBitsOff(dwIoBase, byRegOfs, wBits) \
+{ \
+ WORD wData; \
+ VNSvInPortW(dwIoBase + byRegOfs, &wData); \
+ VNSvOutPortW(dwIoBase + byRegOfs, wData & ~(wBits)); \
+}
+
+#define MACvDWordRegBitsOff(dwIoBase, byRegOfs, dwBits) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + byRegOfs, &dwData); \
+ VNSvOutPortD(dwIoBase + byRegOfs, dwData & ~(dwBits)); \
+}
+
+#define MACvGetCurrRx0DescAddr(dwIoBase, pdwCurrDescAddr) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, \
+ (PDWORD)pdwCurrDescAddr); \
+}
+
+#define MACvGetCurrRx1DescAddr(dwIoBase, pdwCurrDescAddr) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, \
+ (PDWORD)pdwCurrDescAddr); \
+}
+
+#define MACvGetCurrTx0DescAddr(dwIoBase, pdwCurrDescAddr) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, \
+ (PDWORD)pdwCurrDescAddr); \
+}
+
+#define MACvGetCurrAC0DescAddr(dwIoBase, pdwCurrDescAddr) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, \
+ (PDWORD)pdwCurrDescAddr); \
+}
+
+#define MACvGetCurrSyncDescAddr(dwIoBase, pdwCurrDescAddr) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_SYNCDMAPTR, \
+ (PDWORD)pdwCurrDescAddr); \
+}
+
+#define MACvGetCurrATIMDescAddr(dwIoBase, pdwCurrDescAddr) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_ATIMDMAPTR, \
+ (PDWORD)pdwCurrDescAddr); \
+} \
+
+// set the chip with current BCN tx descriptor address
+#define MACvSetCurrBCNTxDescAddr(dwIoBase, dwCurrDescAddr) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, \
+ dwCurrDescAddr); \
+}
+
+// set the chip with current BCN length
+#define MACvSetCurrBCNLength(dwIoBase, wCurrBCNLength) \
+{ \
+ VNSvOutPortW(dwIoBase + MAC_REG_BCNDMACTL+2, \
+ wCurrBCNLength); \
+}
+
+#define MACvReadBSSIDAddress(dwIoBase, pbyEtherAddr) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
+ VNSvInPortB(dwIoBase + MAC_REG_BSSID0, \
+ (PBYTE)pbyEtherAddr); \
+ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 1, \
+ pbyEtherAddr + 1); \
+ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 2, \
+ pbyEtherAddr + 2); \
+ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 3, \
+ pbyEtherAddr + 3); \
+ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 4, \
+ pbyEtherAddr + 4); \
+ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 5, \
+ pbyEtherAddr + 5); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
+}
+
+#define MACvWriteBSSIDAddress(dwIoBase, pbyEtherAddr) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
+ VNSvOutPortB(dwIoBase + MAC_REG_BSSID0, \
+ *(pbyEtherAddr)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 1, \
+ *(pbyEtherAddr + 1)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 2, \
+ *(pbyEtherAddr + 2)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 3, \
+ *(pbyEtherAddr + 3)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 4, \
+ *(pbyEtherAddr + 4)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 5, \
+ *(pbyEtherAddr + 5)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
+}
+
+#define MACvReadEtherAddress(dwIoBase, pbyEtherAddr) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
+ VNSvInPortB(dwIoBase + MAC_REG_PAR0, \
+ (PBYTE)pbyEtherAddr); \
+ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 1, \
+ pbyEtherAddr + 1); \
+ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 2, \
+ pbyEtherAddr + 2); \
+ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 3, \
+ pbyEtherAddr + 3); \
+ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 4, \
+ pbyEtherAddr + 4); \
+ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 5, \
+ pbyEtherAddr + 5); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
+}
+
+
+#define MACvWriteEtherAddress(dwIoBase, pbyEtherAddr) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAR0, \
+ *pbyEtherAddr); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 1, \
+ *(pbyEtherAddr + 1)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 2, \
+ *(pbyEtherAddr + 2)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 3, \
+ *(pbyEtherAddr + 3)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 4, \
+ *(pbyEtherAddr + 4)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 5, \
+ *(pbyEtherAddr + 5)); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
+}
+
+
+#define MACvClearISR(dwIoBase) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_ISR, IMR_MASK_VALUE); \
+}
+
+#define MACvStart(dwIoBase) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_HOSTCR, \
+ (HOSTCR_MACEN | HOSTCR_RXON | HOSTCR_TXON)); \
+}
+
+#define MACvRx0PerPktMode(dwIoBase) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, RX_PERPKT); \
+}
+
+#define MACvRx0BufferFillMode(dwIoBase) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, RX_PERPKTCLR); \
+}
+
+#define MACvRx1PerPktMode(dwIoBase) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, RX_PERPKT); \
+}
+
+#define MACvRx1BufferFillMode(dwIoBase) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, RX_PERPKTCLR); \
+}
+
+#define MACvRxOn(dwIoBase) \
+{ \
+ MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_RXON); \
+}
+
+#define MACvReceive0(dwIoBase) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL0, &dwData); \
+ if (dwData & DMACTL_RUN) { \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_WAKE);\
+ } \
+ else { \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_RUN); \
+ } \
+}
+
+#define MACvReceive1(dwIoBase) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL1, &dwData); \
+ if (dwData & DMACTL_RUN) { \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_WAKE);\
+ } \
+ else { \
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_RUN); \
+ } \
+}
+
+#define MACvTxOn(dwIoBase) \
+{ \
+ MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_TXON); \
+}
+
+#define MACvTransmit0(dwIoBase) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + MAC_REG_TXDMACTL0, &dwData); \
+ if (dwData & DMACTL_RUN) { \
+ VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_WAKE);\
+ } \
+ else { \
+ VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_RUN); \
+ } \
+}
+
+#define MACvTransmitAC0(dwIoBase) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + MAC_REG_AC0DMACTL, &dwData); \
+ if (dwData & DMACTL_RUN) { \
+ VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_WAKE);\
+ } \
+ else { \
+ VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN); \
+ } \
+}
+
+#define MACvTransmitSYNC(dwIoBase) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + MAC_REG_SYNCDMACTL, &dwData); \
+ if (dwData & DMACTL_RUN) { \
+ VNSvOutPortD(dwIoBase + MAC_REG_SYNCDMACTL, DMACTL_WAKE);\
+ } \
+ else { \
+ VNSvOutPortD(dwIoBase + MAC_REG_SYNCDMACTL, DMACTL_RUN); \
+ } \
+}
+
+#define MACvTransmitATIM(dwIoBase) \
+{ \
+ DWORD dwData; \
+ VNSvInPortD(dwIoBase + MAC_REG_ATIMDMACTL, &dwData); \
+ if (dwData & DMACTL_RUN) { \
+ VNSvOutPortD(dwIoBase + MAC_REG_ATIMDMACTL, DMACTL_WAKE);\
+ } \
+ else { \
+ VNSvOutPortD(dwIoBase + MAC_REG_ATIMDMACTL, DMACTL_RUN); \
+ } \
+}
+
+#define MACvTransmitBCN(dwIoBase) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_BCNDMACTL, BEACON_READY); \
+}
+
+#define MACvClearStckDS(dwIoBase) \
+{ \
+ BYTE byOrgValue; \
+ VNSvInPortB(dwIoBase + MAC_REG_STICKHW, &byOrgValue); \
+ byOrgValue = byOrgValue & 0xFC; \
+ VNSvOutPortB(dwIoBase + MAC_REG_STICKHW, byOrgValue); \
+}
+
+#define MACvReadISR(dwIoBase, pdwValue) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_ISR, pdwValue); \
+}
+
+#define MACvWriteISR(dwIoBase, dwValue) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_ISR, dwValue); \
+}
+
+#define MACvIntEnable(dwIoBase, dwMask) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_IMR, dwMask); \
+}
+
+#define MACvIntDisable(dwIoBase) \
+{ \
+ VNSvOutPortD(dwIoBase + MAC_REG_IMR, 0); \
+}
+
+#define MACvSelectPage0(dwIoBase) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
+}
+#define MACvSelectPage1(dwIoBase) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
+}
+
+#define MACvReadMIBCounter(dwIoBase, pdwCounter) \
+{ \
+ VNSvInPortD(dwIoBase + MAC_REG_MIBCNTR , pdwCounter); \
+}
+
+#define MACvPwrEvntDisable(dwIoBase) \
+{ \
+ VNSvOutPortW(dwIoBase + MAC_REG_WAKEUPEN0, 0x0000); \
+}
+
+#define MACvEnableProtectMD(dwIoBase) \
+{ \
+ DWORD dwOrgValue; \
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
+ dwOrgValue = dwOrgValue | EnCFG_ProtectMd; \
+ VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
+}
+
+#define MACvDisableProtectMD(dwIoBase) \
+{ \
+ DWORD dwOrgValue; \
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
+ dwOrgValue = dwOrgValue & ~EnCFG_ProtectMd; \
+ VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
+}
+
+#define MACvEnableBarkerPreambleMd(dwIoBase) \
+{ \
+ DWORD dwOrgValue; \
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
+ dwOrgValue = dwOrgValue | EnCFG_BarkerPream; \
+ VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
+}
+
+#define MACvDisableBarkerPreambleMd(dwIoBase) \
+{ \
+ DWORD dwOrgValue; \
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
+ dwOrgValue = dwOrgValue & ~EnCFG_BarkerPream; \
+ VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
+}
+
+#define MACvSetBBType(dwIoBase, byTyp) \
+{ \
+ DWORD dwOrgValue; \
+ VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
+ dwOrgValue = dwOrgValue & ~EnCFG_BBType_MASK; \
+ dwOrgValue = dwOrgValue | (DWORD) byTyp; \
+ VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
+}
+
+#define MACvReadATIMW(dwIoBase, pwCounter) \
+{ \
+ VNSvInPortW(dwIoBase + MAC_REG_AIDATIM , pwCounter); \
+}
+
+#define MACvWriteATIMW(dwIoBase, wCounter) \
+{ \
+ VNSvOutPortW(dwIoBase + MAC_REG_AIDATIM , wCounter); \
+}
+
+#define MACvWriteCRC16_128(dwIoBase, byRegOfs, wCRC) \
+{ \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
+ VNSvOutPortW(dwIoBase + byRegOfs, wCRC); \
+ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
+}
+
+#define MACvGPIOIn(dwIoBase, pbyValue) \
+{ \
+ VNSvInPortB(dwIoBase + MAC_REG_GPIOCTL1, pbyValue); \
+}
+
+#define MACvSetRFLE_LatchBase(dwIoBase) \
+{ \
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT); \
+}
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+extern WORD TxRate_iwconfig;//2008-5-8 <add> by chester
+VOID MACvReadAllRegs(DWORD_PTR dwIoBase, PBYTE pbyMacRegs);
+
+BOOL MACbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits);
+BOOL MACbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits);
+
+BOOL MACbIsIntDisable(DWORD_PTR dwIoBase);
+
+BYTE MACbyReadMultiAddr(DWORD_PTR dwIoBase, UINT uByteIdx);
+VOID MACvWriteMultiAddr(DWORD_PTR dwIoBase, UINT uByteIdx, BYTE byData);
+VOID MACvSetMultiAddrByHash(DWORD_PTR dwIoBase, BYTE byHashIdx);
+VOID MACvResetMultiAddrByHash(DWORD_PTR dwIoBase, BYTE byHashIdx);
+
+VOID MACvSetRxThreshold(DWORD_PTR dwIoBase, BYTE byThreshold);
+VOID MACvGetRxThreshold(DWORD_PTR dwIoBase, PBYTE pbyThreshold);
+
+VOID MACvSetTxThreshold(DWORD_PTR dwIoBase, BYTE byThreshold);
+VOID MACvGetTxThreshold(DWORD_PTR dwIoBase, PBYTE pbyThreshold);
+
+VOID MACvSetDmaLength(DWORD_PTR dwIoBase, BYTE byDmaLength);
+VOID MACvGetDmaLength(DWORD_PTR dwIoBase, PBYTE pbyDmaLength);
+
+VOID MACvSetShortRetryLimit(DWORD_PTR dwIoBase, BYTE byRetryLimit);
+VOID MACvGetShortRetryLimit(DWORD_PTR dwIoBase, PBYTE pbyRetryLimit);
+
+VOID MACvSetLongRetryLimit(DWORD_PTR dwIoBase, BYTE byRetryLimit);
+VOID MACvGetLongRetryLimit(DWORD_PTR dwIoBase, PBYTE pbyRetryLimit);
+
+VOID MACvSetLoopbackMode(DWORD_PTR dwIoBase, BYTE byLoopbackMode);
+BOOL MACbIsInLoopbackMode(DWORD_PTR dwIoBase);
+
+VOID MACvSetPacketFilter(DWORD_PTR dwIoBase, WORD wFilterType);
+
+VOID MACvSaveContext(DWORD_PTR dwIoBase, PBYTE pbyCxtBuf);
+VOID MACvRestoreContext(DWORD_PTR dwIoBase, PBYTE pbyCxtBuf);
+BOOL MACbCompareContext(DWORD_PTR dwIoBase, PBYTE pbyCxtBuf);
+
+BOOL MACbSoftwareReset(DWORD_PTR dwIoBase);
+BOOL MACbSafeSoftwareReset(DWORD_PTR dwIoBase);
+BOOL MACbSafeRxOff(DWORD_PTR dwIoBase);
+BOOL MACbSafeTxOff(DWORD_PTR dwIoBase);
+BOOL MACbSafeStop(DWORD_PTR dwIoBase);
+BOOL MACbShutdown(DWORD_PTR dwIoBase);
+VOID MACvInitialize(DWORD_PTR dwIoBase);
+VOID MACvSetCurrRx0DescAddr(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+VOID MACvSetCurrRx1DescAddr(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+VOID MACvSetCurrTXDescAddr(int iTxType, DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+VOID MACvSetCurrTx0DescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+VOID MACvSetCurrAC0DescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+VOID MACvSetCurrSyncDescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+VOID MACvSetCurrATIMDescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr);
+void MACvTimer0MicroSDelay(DWORD_PTR dwIoBase, UINT uDelay);
+void MACvOneShotTimer0MicroSec(DWORD_PTR dwIoBase, UINT uDelayTime);
+void MACvOneShotTimer1MicroSec(DWORD_PTR dwIoBase, UINT uDelayTime);
+
+void MACvSetMISCFifo(DWORD_PTR dwIoBase, WORD wOffset, DWORD dwData);
+
+BOOL MACbTxDMAOff (DWORD_PTR dwIoBase, UINT idx);
+
+void MACvClearBusSusInd(DWORD_PTR dwIoBase);
+void MACvEnableBusSusEn(DWORD_PTR dwIoBase);
+
+BOOL MACbFlushSYNCFifo(DWORD_PTR dwIoBase);
+BOOL MACbPSWakeup(DWORD_PTR dwIoBase);
+
+void MACvSetKeyEntry(DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, UINT uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID);
+void MACvDisableKeyEntry(DWORD_PTR dwIoBase, UINT uEntryIdx);
+void MACvSetDefaultKeyEntry(DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID);
+//void MACvEnableDefaultKey(DWORD_PTR dwIoBase, BYTE byLocalID);
+void MACvDisableDefaultKey(DWORD_PTR dwIoBase);
+void MACvSetDefaultTKIPKeyEntry(DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID);
+void MACvSetDefaultKeyCtl(DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, BYTE byLocalID);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+#endif // __MAC_H__
+
diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c
new file mode 100644
index 000000000000..3f06de141a84
--- /dev/null
+++ b/drivers/staging/vt6655/mib.c
@@ -0,0 +1,616 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: mib.c
+ *
+ * Purpose: Implement MIB Data Structure
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ * Functions:
+ * STAvClearAllCounter - Clear All MIB Counter
+ * STAvUpdateIstStatCounter - Update ISR statistic counter
+ * STAvUpdateRDStatCounter - Update Rx statistic counter
+ * STAvUpdateRDStatCounterEx - Update Rx statistic counter and copy rcv data
+ * STAvUpdateTDStatCounter - Update Tx statistic counter
+ * STAvUpdateTDStatCounterEx - Update Tx statistic counter and copy tx data
+ * STAvUpdate802_11Counter - Update 802.11 mib counter
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__UPC_H__)
+#include "upc.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__MIB_H__)
+#include "mib.h"
+#endif
+#if !defined(__WCTL_H__)
+#include "wctl.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+/*
+ * Description: Clear All Statistic Counter
+ *
+ * Parameters:
+ * In:
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void STAvClearAllCounter (PSStatCounter pStatistic)
+{
+ // set memory to zero
+ ZERO_MEMORY(pStatistic, sizeof(SStatCounter));
+}
+
+
+/*
+ * Description: Update Isr Statistic Counter
+ *
+ * Parameters:
+ * In:
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * wisr - Interrupt status
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, DWORD dwIsr)
+{
+ /**********************/
+ /* ABNORMAL interrupt */
+ /**********************/
+ // not any IMR bit invoke irq
+
+ if (dwIsr == 0) {
+ pStatistic->ISRStat.dwIsrUnknown++;
+ return;
+ }
+
+//Added by Kyle
+ if (BITbIsBitOn(dwIsr, ISR_TXDMA0)) // ISR, bit0
+ pStatistic->ISRStat.dwIsrTx0OK++; // TXDMA0 successful
+
+ if (BITbIsBitOn(dwIsr, ISR_AC0DMA)) // ISR, bit1
+ pStatistic->ISRStat.dwIsrAC0TxOK++; // AC0DMA successful
+
+ if (BITbIsBitOn(dwIsr, ISR_BNTX)) // ISR, bit2
+ pStatistic->ISRStat.dwIsrBeaconTxOK++; // BeaconTx successful
+
+ if (BITbIsBitOn(dwIsr, ISR_RXDMA0)) // ISR, bit3
+ pStatistic->ISRStat.dwIsrRx0OK++; // Rx0 successful
+
+ if (BITbIsBitOn(dwIsr, ISR_TBTT)) // ISR, bit4
+ pStatistic->ISRStat.dwIsrTBTTInt++; // TBTT successful
+
+ if (BITbIsBitOn(dwIsr, ISR_SOFTTIMER)) // ISR, bit6
+ pStatistic->ISRStat.dwIsrSTIMERInt++;
+
+ if (BITbIsBitOn(dwIsr, ISR_WATCHDOG)) // ISR, bit7
+ pStatistic->ISRStat.dwIsrWatchDog++;
+
+ if (BITbIsBitOn(dwIsr, ISR_FETALERR)) // ISR, bit8
+ pStatistic->ISRStat.dwIsrUnrecoverableError++;
+
+ if (BITbIsBitOn(dwIsr, ISR_SOFTINT)) // ISR, bit9
+ pStatistic->ISRStat.dwIsrSoftInterrupt++; // software interrupt
+
+ if (BITbIsBitOn(dwIsr, ISR_MIBNEARFULL)) // ISR, bit10
+ pStatistic->ISRStat.dwIsrMIBNearfull++;
+
+ if (BITbIsBitOn(dwIsr, ISR_RXNOBUF)) // ISR, bit11
+ pStatistic->ISRStat.dwIsrRxNoBuf++; // Rx No Buff
+
+ if (BITbIsBitOn(dwIsr, ISR_RXDMA1)) // ISR, bit12
+ pStatistic->ISRStat.dwIsrRx1OK++; // Rx1 successful
+
+// if (BITbIsBitOn(dwIsr, ISR_ATIMTX)) // ISR, bit13
+// pStatistic->ISRStat.dwIsrATIMTxOK++; // ATIMTX successful
+
+// if (BITbIsBitOn(dwIsr, ISR_SYNCTX)) // ISR, bit14
+// pStatistic->ISRStat.dwIsrSYNCTxOK++; // SYNCTX successful
+
+// if (BITbIsBitOn(dwIsr, ISR_CFPEND)) // ISR, bit18
+// pStatistic->ISRStat.dwIsrCFPEnd++;
+
+// if (BITbIsBitOn(dwIsr, ISR_ATIMEND)) // ISR, bit19
+// pStatistic->ISRStat.dwIsrATIMEnd++;
+
+// if (BITbIsBitOn(dwIsr, ISR_SYNCFLUSHOK)) // ISR, bit20
+// pStatistic->ISRStat.dwIsrSYNCFlushOK++;
+
+ if (BITbIsBitOn(dwIsr, ISR_SOFTTIMER1)) // ISR, bit21
+ pStatistic->ISRStat.dwIsrSTIMER1Int++;
+
+}
+
+
+/*
+ * Description: Update Rx Statistic Counter
+ *
+ * Parameters:
+ * In:
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * byRSR - Rx Status
+ * byNewRSR - Rx Status
+ * pbyBuffer - Rx Buffer
+ * cbFrameLength - Rx Length
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void STAvUpdateRDStatCounter (PSStatCounter pStatistic,
+ BYTE byRSR, BYTE byNewRSR, BYTE byRxRate,
+ PBYTE pbyBuffer, UINT cbFrameLength)
+{
+ //need change
+ PS802_11Header pHeader = (PS802_11Header)pbyBuffer;
+
+ if (BITbIsBitOn(byRSR, RSR_ADDROK))
+ pStatistic->dwRsrADDROk++;
+ if (BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->dwRsrCRCOk++;
+
+ pStatistic->ullRsrOK++;
+
+ if (cbFrameLength >= U_ETHER_ADDR_LEN) {
+ // update counters in case that successful transmit
+ if (BITbIsBitOn(byRSR, RSR_ADDRBROAD)) {
+ pStatistic->ullRxBroadcastFrames++;
+ pStatistic->ullRxBroadcastBytes += (ULONGLONG)cbFrameLength;
+ }
+ else if (BITbIsBitOn(byRSR, RSR_ADDRMULTI)) {
+ pStatistic->ullRxMulticastFrames++;
+ pStatistic->ullRxMulticastBytes += (ULONGLONG)cbFrameLength;
+ }
+ else {
+ pStatistic->ullRxDirectedFrames++;
+ pStatistic->ullRxDirectedBytes += (ULONGLONG)cbFrameLength;
+ }
+ }
+ }
+
+ if(byRxRate==22) {
+ pStatistic->CustomStat.ullRsr11M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr11MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr11M, (INT)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR);
+ }
+ else if(byRxRate==11) {
+ pStatistic->CustomStat.ullRsr5M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr5MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr5M, (INT)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR);
+ }
+ else if(byRxRate==4) {
+ pStatistic->CustomStat.ullRsr2M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr2MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr2M, (INT)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR);
+ }
+ else if(byRxRate==2){
+ pStatistic->CustomStat.ullRsr1M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr1MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr1M, (INT)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR);
+ }
+ else if(byRxRate==12){
+ pStatistic->CustomStat.ullRsr6M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr6MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr6M, (INT)pStatistic->CustomStat.ullRsr6MCRCOk);
+ }
+ else if(byRxRate==18){
+ pStatistic->CustomStat.ullRsr9M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr9MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr9M, (INT)pStatistic->CustomStat.ullRsr9MCRCOk);
+ }
+ else if(byRxRate==24){
+ pStatistic->CustomStat.ullRsr12M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr12MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr12M, (INT)pStatistic->CustomStat.ullRsr12MCRCOk);
+ }
+ else if(byRxRate==36){
+ pStatistic->CustomStat.ullRsr18M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr18MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr18M, (INT)pStatistic->CustomStat.ullRsr18MCRCOk);
+ }
+ else if(byRxRate==48){
+ pStatistic->CustomStat.ullRsr24M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr24MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr24M, (INT)pStatistic->CustomStat.ullRsr24MCRCOk);
+ }
+ else if(byRxRate==72){
+ pStatistic->CustomStat.ullRsr36M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr36MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr36M, (INT)pStatistic->CustomStat.ullRsr36MCRCOk);
+ }
+ else if(byRxRate==96){
+ pStatistic->CustomStat.ullRsr48M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr48MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr48M, (INT)pStatistic->CustomStat.ullRsr48MCRCOk);
+ }
+ else if(byRxRate==108){
+ pStatistic->CustomStat.ullRsr54M++;
+ if(BITbIsBitOn(byRSR, RSR_CRCOK)) {
+ pStatistic->CustomStat.ullRsr54MCRCOk++;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr54M, (INT)pStatistic->CustomStat.ullRsr54MCRCOk);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (INT)pStatistic->dwRsrRxPacket+1, (INT)pStatistic->dwRsrCRCOk);
+ }
+
+ if (BITbIsBitOn(byRSR, RSR_BSSIDOK))
+ pStatistic->dwRsrBSSIDOk++;
+
+ if (BITbIsBitOn(byRSR, RSR_BCNSSIDOK))
+ pStatistic->dwRsrBCNSSIDOk++;
+ if (BITbIsBitOn(byRSR, RSR_IVLDLEN)) //invalid len (> 2312 byte)
+ pStatistic->dwRsrLENErr++;
+ if (BITbIsBitOn(byRSR, RSR_IVLDTYP)) //invalid packet type
+ pStatistic->dwRsrTYPErr++;
+ if (BITbIsBitOn(byRSR, (RSR_IVLDTYP | RSR_IVLDLEN)))
+ pStatistic->dwRsrErr++;
+
+ if (BITbIsBitOn(byNewRSR, NEWRSR_DECRYPTOK))
+ pStatistic->dwNewRsrDECRYPTOK++;
+ if (BITbIsBitOn(byNewRSR, NEWRSR_CFPIND))
+ pStatistic->dwNewRsrCFP++;
+ if (BITbIsBitOn(byNewRSR, NEWRSR_HWUTSF))
+ pStatistic->dwNewRsrUTSF++;
+ if (BITbIsBitOn(byNewRSR, NEWRSR_BCNHITAID))
+ pStatistic->dwNewRsrHITAID++;
+ if (BITbIsBitOn(byNewRSR, NEWRSR_BCNHITAID0))
+ pStatistic->dwNewRsrHITAID0++;
+
+ // increase rx packet count
+ pStatistic->dwRsrRxPacket++;
+ pStatistic->dwRsrRxOctet += cbFrameLength;
+
+
+ if (IS_TYPE_DATA(pbyBuffer)) {
+ pStatistic->dwRsrRxData++;
+ } else if (IS_TYPE_MGMT(pbyBuffer)){
+ pStatistic->dwRsrRxManage++;
+ } else if (IS_TYPE_CONTROL(pbyBuffer)){
+ pStatistic->dwRsrRxControl++;
+ }
+
+ if (BITbIsBitOn(byRSR, RSR_ADDRBROAD))
+ pStatistic->dwRsrBroadcast++;
+ else if (BITbIsBitOn(byRSR, RSR_ADDRMULTI))
+ pStatistic->dwRsrMulticast++;
+ else
+ pStatistic->dwRsrDirected++;
+
+ if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl))
+ pStatistic->dwRsrRxFragment++;
+
+ if (cbFrameLength < MIN_PACKET_LEN + 4) {
+ pStatistic->dwRsrRunt++;
+ }
+ else if (cbFrameLength == MIN_PACKET_LEN + 4) {
+ pStatistic->dwRsrRxFrmLen64++;
+ }
+ else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) {
+ pStatistic->dwRsrRxFrmLen65_127++;
+ }
+ else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) {
+ pStatistic->dwRsrRxFrmLen128_255++;
+ }
+ else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) {
+ pStatistic->dwRsrRxFrmLen256_511++;
+ }
+ else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) {
+ pStatistic->dwRsrRxFrmLen512_1023++;
+ }
+ else if ((1024 <= cbFrameLength) && (cbFrameLength <= MAX_PACKET_LEN + 4)) {
+ pStatistic->dwRsrRxFrmLen1024_1518++;
+ } else if (cbFrameLength > MAX_PACKET_LEN + 4) {
+ pStatistic->dwRsrLong++;
+ }
+
+}
+
+
+
+/*
+ * Description: Update Rx Statistic Counter and copy Rx buffer
+ *
+ * Parameters:
+ * In:
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * byRSR - Rx Status
+ * byNewRSR - Rx Status
+ * pbyBuffer - Rx Buffer
+ * cbFrameLength - Rx Length
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+void
+STAvUpdateRDStatCounterEx (
+ PSStatCounter pStatistic,
+ BYTE byRSR,
+ BYTE byNewRSR,
+ BYTE byRxRate,
+ PBYTE pbyBuffer,
+ UINT cbFrameLength
+ )
+{
+ STAvUpdateRDStatCounter(
+ pStatistic,
+ byRSR,
+ byNewRSR,
+ byRxRate,
+ pbyBuffer,
+ cbFrameLength
+ );
+
+ // rx length
+ pStatistic->dwCntRxFrmLength = cbFrameLength;
+ // rx pattern, we just see 10 bytes for sample
+ MEMvCopy(pStatistic->abyCntRxPattern, (PBYTE)pbyBuffer, 10);
+}
+
+
+/*
+ * Description: Update Tx Statistic Counter
+ *
+ * Parameters:
+ * In:
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * byTSR0 - Tx Status
+ * byTSR1 - Tx Status
+ * pbyBuffer - Tx Buffer
+ * cbFrameLength - Tx Length
+ * uIdx - Index of Tx DMA
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void
+STAvUpdateTDStatCounter (
+ PSStatCounter pStatistic,
+ BYTE byTSR0,
+ BYTE byTSR1,
+ PBYTE pbyBuffer,
+ UINT cbFrameLength,
+ UINT uIdx
+ )
+{
+ PWLAN_80211HDR_A4 pHeader;
+ PBYTE pbyDestAddr;
+ BYTE byTSR0_NCR = byTSR0 & TSR0_NCR;
+
+
+
+ pHeader = (PWLAN_80211HDR_A4) pbyBuffer;
+ if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) {
+ pbyDestAddr = &(pHeader->abyAddr1[0]);
+ }
+ else {
+ pbyDestAddr = &(pHeader->abyAddr3[0]);
+ }
+ // increase tx packet count
+ pStatistic->dwTsrTxPacket[uIdx]++;
+ pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength;
+
+ if (byTSR0_NCR != 0) {
+ pStatistic->dwTsrRetry[uIdx]++;
+ pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR;
+
+ if (byTSR0_NCR == 1)
+ pStatistic->dwTsrOnceRetry[uIdx]++;
+ else
+ pStatistic->dwTsrMoreThanOnceRetry[uIdx]++;
+ }
+
+ if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) {
+ pStatistic->ullTsrOK[uIdx]++;
+ pStatistic->CustomStat.ullTsrAllOK =
+ (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]);
+ // update counters in case that successful transmit
+ if (IS_BROADCAST_ADDRESS(pbyDestAddr)) {
+ pStatistic->ullTxBroadcastFrames[uIdx]++;
+ pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength;
+ }
+ else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) {
+ pStatistic->ullTxMulticastFrames[uIdx]++;
+ pStatistic->ullTxMulticastBytes[uIdx] += (ULONGLONG)cbFrameLength;
+ }
+ else {
+ pStatistic->ullTxDirectedFrames[uIdx]++;
+ pStatistic->ullTxDirectedBytes[uIdx] += (ULONGLONG)cbFrameLength;
+ }
+ }
+ else {
+ if (BITbIsBitOn(byTSR1, TSR1_TERR))
+ pStatistic->dwTsrErr[uIdx]++;
+ if (BITbIsBitOn(byTSR1, TSR1_RETRYTMO))
+ pStatistic->dwTsrRetryTimeout[uIdx]++;
+ if (BITbIsBitOn(byTSR1, TSR1_TMO))
+ pStatistic->dwTsrTransmitTimeout[uIdx]++;
+ if (BITbIsBitOn(byTSR1, ACK_DATA))
+ pStatistic->dwTsrACKData[uIdx]++;
+ }
+
+ if (IS_BROADCAST_ADDRESS(pbyDestAddr))
+ pStatistic->dwTsrBroadcast[uIdx]++;
+ else if (IS_MULTICAST_ADDRESS(pbyDestAddr))
+ pStatistic->dwTsrMulticast[uIdx]++;
+ else
+ pStatistic->dwTsrDirected[uIdx]++;
+
+}
+
+
+/*
+ * Description: Update Tx Statistic Counter and copy Tx buffer
+ *
+ * Parameters:
+ * In:
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * pbyBuffer - Tx Buffer
+ * cbFrameLength - Tx Length
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void
+STAvUpdateTDStatCounterEx (
+ PSStatCounter pStatistic,
+ PBYTE pbyBuffer,
+ DWORD cbFrameLength
+ )
+{
+ UINT uPktLength;
+
+ uPktLength = (UINT)cbFrameLength;
+
+ // tx length
+ pStatistic->dwCntTxBufLength = uPktLength;
+ // tx pattern, we just see 16 bytes for sample
+ MEMvCopy(pStatistic->abyCntTxPattern, pbyBuffer, 16);
+}
+
+
+/*
+ * Description: Update 802.11 mib counter
+ *
+ * Parameters:
+ * In:
+ * p802_11Counter - Pointer to 802.11 mib counter
+ * pStatistic - Pointer to Statistic Counter Data Structure
+ * dwCounter - hardware counter for 802.11 mib
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void
+STAvUpdate802_11Counter(
+ PSDot11Counters p802_11Counter,
+ PSStatCounter pStatistic,
+ DWORD dwCounter
+ )
+{
+ //p802_11Counter->TransmittedFragmentCount
+ p802_11Counter->MulticastTransmittedFrameCount = (ULONGLONG) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] +
+ pStatistic->dwTsrBroadcast[TYPE_TXDMA0] +
+ pStatistic->dwTsrMulticast[TYPE_AC0DMA] +
+ pStatistic->dwTsrMulticast[TYPE_TXDMA0]);
+ p802_11Counter->FailedCount = (ULONGLONG) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]);
+ p802_11Counter->RetryCount = (ULONGLONG) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]);
+ p802_11Counter->MultipleRetryCount = (ULONGLONG) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] +
+ pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]);
+ //p802_11Counter->FrameDuplicateCount
+ p802_11Counter->RTSSuccessCount += (ULONGLONG) (dwCounter & 0x000000ff);
+ p802_11Counter->RTSFailureCount += (ULONGLONG) ((dwCounter & 0x0000ff00) >> 8);
+ p802_11Counter->ACKFailureCount += (ULONGLONG) ((dwCounter & 0x00ff0000) >> 16);
+ p802_11Counter->FCSErrorCount += (ULONGLONG) ((dwCounter & 0xff000000) >> 24);
+ //p802_11Counter->ReceivedFragmentCount
+ p802_11Counter->MulticastReceivedFrameCount = (ULONGLONG) (pStatistic->dwRsrBroadcast +
+ pStatistic->dwRsrMulticast);
+}
+
+/*
+ * Description: Clear 802.11 mib counter
+ *
+ * Parameters:
+ * In:
+ * p802_11Counter - Pointer to 802.11 mib counter
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void
+STAvClear802_11Counter(PSDot11Counters p802_11Counter)
+{
+ // set memory to zero
+ ZERO_MEMORY(p802_11Counter, sizeof(SDot11Counters));
+}
diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h
new file mode 100644
index 000000000000..b4e1c4a19a7d
--- /dev/null
+++ b/drivers/staging/vt6655/mib.h
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: mib.h
+ *
+ * Purpose: Implement MIB Data Structure
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+#ifndef __MIB_H__
+#define __MIB_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__DESC_H__)
+#include "desc.h"
+#endif
+
+
+
+//#define ULONGLONG ULONG
+
+/*--------------------- Export Definitions -------------------------*/
+//
+// 802.11 counter
+//
+
+typedef struct tagSDot11Counters {
+ ULONG Length; // Length of structure
+ ULONGLONG TransmittedFragmentCount;
+ ULONGLONG MulticastTransmittedFrameCount;
+ ULONGLONG FailedCount;
+ ULONGLONG RetryCount;
+ ULONGLONG MultipleRetryCount;
+ ULONGLONG RTSSuccessCount;
+ ULONGLONG RTSFailureCount;
+ ULONGLONG ACKFailureCount;
+ ULONGLONG FrameDuplicateCount;
+ ULONGLONG ReceivedFragmentCount;
+ ULONGLONG MulticastReceivedFrameCount;
+ ULONGLONG FCSErrorCount;
+ ULONGLONG TKIPLocalMICFailures;
+ ULONGLONG TKIPRemoteMICFailures;
+ ULONGLONG TKIPICVErrors;
+ ULONGLONG TKIPCounterMeasuresInvoked;
+ ULONGLONG TKIPReplays;
+ ULONGLONG CCMPFormatErrors;
+ ULONGLONG CCMPReplays;
+ ULONGLONG CCMPDecryptErrors;
+ ULONGLONG FourWayHandshakeFailures;
+// ULONGLONG WEPUndecryptableCount;
+// ULONGLONG WEPICVErrorCount;
+// ULONGLONG DecryptSuccessCount;
+// ULONGLONG DecryptFailureCount;
+} SDot11Counters, DEF* PSDot11Counters;
+
+
+//
+// MIB2 counter
+//
+typedef struct tagSMib2Counter {
+ LONG ifIndex;
+ TCHAR ifDescr[256]; // max size 255 plus zero ending
+ // e.g. "interface 1"
+ LONG ifType;
+ LONG ifMtu;
+ DWORD ifSpeed;
+ BYTE ifPhysAddress[U_ETHER_ADDR_LEN];
+ LONG ifAdminStatus;
+ LONG ifOperStatus;
+ DWORD ifLastChange;
+ DWORD ifInOctets;
+ DWORD ifInUcastPkts;
+ DWORD ifInNUcastPkts;
+ DWORD ifInDiscards;
+ DWORD ifInErrors;
+ DWORD ifInUnknownProtos;
+ DWORD ifOutOctets;
+ DWORD ifOutUcastPkts;
+ DWORD ifOutNUcastPkts;
+ DWORD ifOutDiscards;
+ DWORD ifOutErrors;
+ DWORD ifOutQLen;
+ DWORD ifSpecific;
+} SMib2Counter, DEF* PSMib2Counter;
+
+// Value in the ifType entry
+//#define ETHERNETCSMACD 6 //
+#define WIRELESSLANIEEE80211b 6 //
+
+// Value in the ifAdminStatus/ifOperStatus entry
+#define UP 1 //
+#define DOWN 2 //
+#define TESTING 3 //
+
+
+//
+// RMON counter
+//
+typedef struct tagSRmonCounter {
+ LONG etherStatsIndex;
+ DWORD etherStatsDataSource;
+ DWORD etherStatsDropEvents;
+ DWORD etherStatsOctets;
+ DWORD etherStatsPkts;
+ DWORD etherStatsBroadcastPkts;
+ DWORD etherStatsMulticastPkts;
+ DWORD etherStatsCRCAlignErrors;
+ DWORD etherStatsUndersizePkts;
+ DWORD etherStatsOversizePkts;
+ DWORD etherStatsFragments;
+ DWORD etherStatsJabbers;
+ DWORD etherStatsCollisions;
+ DWORD etherStatsPkt64Octets;
+ DWORD etherStatsPkt65to127Octets;
+ DWORD etherStatsPkt128to255Octets;
+ DWORD etherStatsPkt256to511Octets;
+ DWORD etherStatsPkt512to1023Octets;
+ DWORD etherStatsPkt1024to1518Octets;
+ DWORD etherStatsOwners;
+ DWORD etherStatsStatus;
+} SRmonCounter, DEF* PSRmonCounter;
+
+//
+// Custom counter
+//
+typedef struct tagSCustomCounters {
+ ULONG Length;
+
+ ULONGLONG ullTsrAllOK;
+
+ ULONGLONG ullRsr11M;
+ ULONGLONG ullRsr5M;
+ ULONGLONG ullRsr2M;
+ ULONGLONG ullRsr1M;
+
+ ULONGLONG ullRsr11MCRCOk;
+ ULONGLONG ullRsr5MCRCOk;
+ ULONGLONG ullRsr2MCRCOk;
+ ULONGLONG ullRsr1MCRCOk;
+
+ ULONGLONG ullRsr54M;
+ ULONGLONG ullRsr48M;
+ ULONGLONG ullRsr36M;
+ ULONGLONG ullRsr24M;
+ ULONGLONG ullRsr18M;
+ ULONGLONG ullRsr12M;
+ ULONGLONG ullRsr9M;
+ ULONGLONG ullRsr6M;
+
+ ULONGLONG ullRsr54MCRCOk;
+ ULONGLONG ullRsr48MCRCOk;
+ ULONGLONG ullRsr36MCRCOk;
+ ULONGLONG ullRsr24MCRCOk;
+ ULONGLONG ullRsr18MCRCOk;
+ ULONGLONG ullRsr12MCRCOk;
+ ULONGLONG ullRsr9MCRCOk;
+ ULONGLONG ullRsr6MCRCOk;
+
+} SCustomCounters, DEF* PSCustomCounters;
+
+
+//
+// Custom counter
+//
+typedef struct tagSISRCounters {
+ ULONG Length;
+
+ DWORD dwIsrTx0OK;
+ DWORD dwIsrAC0TxOK;
+ DWORD dwIsrBeaconTxOK;
+ DWORD dwIsrRx0OK;
+ DWORD dwIsrTBTTInt;
+ DWORD dwIsrSTIMERInt;
+ DWORD dwIsrWatchDog;
+ DWORD dwIsrUnrecoverableError;
+ DWORD dwIsrSoftInterrupt;
+ DWORD dwIsrMIBNearfull;
+ DWORD dwIsrRxNoBuf;
+
+ DWORD dwIsrUnknown; // unknown interrupt count
+
+ DWORD dwIsrRx1OK;
+ DWORD dwIsrATIMTxOK;
+ DWORD dwIsrSYNCTxOK;
+ DWORD dwIsrCFPEnd;
+ DWORD dwIsrATIMEnd;
+ DWORD dwIsrSYNCFlushOK;
+ DWORD dwIsrSTIMER1Int;
+ /////////////////////////////////////
+} SISRCounters, DEF* PSISRCounters;
+
+
+// Value in the etherStatsStatus entry
+#define VALID 1 //
+#define CREATE_REQUEST 2 //
+#define UNDER_CREATION 3 //
+#define INVALID 4 //
+
+//#define MAX_RATE 12
+//
+// statistic counter
+//
+typedef struct tagSStatCounter {
+ //
+ // ISR status count
+ //
+
+
+ // RSR status count
+ //
+ DWORD dwRsrFrmAlgnErr;
+ DWORD dwRsrErr;
+ DWORD dwRsrCRCErr;
+ DWORD dwRsrCRCOk;
+ DWORD dwRsrBSSIDOk;
+ DWORD dwRsrADDROk;
+ DWORD dwRsrBCNSSIDOk;
+ DWORD dwRsrLENErr;
+ DWORD dwRsrTYPErr;
+
+ DWORD dwNewRsrDECRYPTOK;
+ DWORD dwNewRsrCFP;
+ DWORD dwNewRsrUTSF;
+ DWORD dwNewRsrHITAID;
+ DWORD dwNewRsrHITAID0;
+
+ DWORD dwRsrLong;
+ DWORD dwRsrRunt;
+
+ DWORD dwRsrRxControl;
+ DWORD dwRsrRxData;
+ DWORD dwRsrRxManage;
+
+ DWORD dwRsrRxPacket;
+ DWORD dwRsrRxOctet;
+ DWORD dwRsrBroadcast;
+ DWORD dwRsrMulticast;
+ DWORD dwRsrDirected;
+ // 64-bit OID
+ ULONGLONG ullRsrOK;
+
+ // for some optional OIDs (64 bits) and DMI support
+ ULONGLONG ullRxBroadcastBytes;
+ ULONGLONG ullRxMulticastBytes;
+ ULONGLONG ullRxDirectedBytes;
+ ULONGLONG ullRxBroadcastFrames;
+ ULONGLONG ullRxMulticastFrames;
+ ULONGLONG ullRxDirectedFrames;
+
+ DWORD dwRsrRxFragment;
+ DWORD dwRsrRxFrmLen64;
+ DWORD dwRsrRxFrmLen65_127;
+ DWORD dwRsrRxFrmLen128_255;
+ DWORD dwRsrRxFrmLen256_511;
+ DWORD dwRsrRxFrmLen512_1023;
+ DWORD dwRsrRxFrmLen1024_1518;
+
+ // TSR status count
+ //
+ DWORD dwTsrTotalRetry[TYPE_MAXTD]; // total collision retry count
+ DWORD dwTsrOnceRetry[TYPE_MAXTD]; // this packet only occur one collision
+ DWORD dwTsrMoreThanOnceRetry[TYPE_MAXTD]; // this packet occur more than one collision
+ DWORD dwTsrRetry[TYPE_MAXTD]; // this packet has ever occur collision,
+ // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
+ DWORD dwTsrACKData[TYPE_MAXTD];
+ DWORD dwTsrErr[TYPE_MAXTD];
+ DWORD dwAllTsrOK[TYPE_MAXTD];
+ DWORD dwTsrRetryTimeout[TYPE_MAXTD];
+ DWORD dwTsrTransmitTimeout[TYPE_MAXTD];
+
+ DWORD dwTsrTxPacket[TYPE_MAXTD];
+ DWORD dwTsrTxOctet[TYPE_MAXTD];
+ DWORD dwTsrBroadcast[TYPE_MAXTD];
+ DWORD dwTsrMulticast[TYPE_MAXTD];
+ DWORD dwTsrDirected[TYPE_MAXTD];
+
+ // RD/TD count
+ DWORD dwCntRxFrmLength;
+ DWORD dwCntTxBufLength;
+
+ BYTE abyCntRxPattern[16];
+ BYTE abyCntTxPattern[16];
+
+
+
+ // Software check....
+ DWORD dwCntRxDataErr; // rx buffer data software compare CRC err count
+ DWORD dwCntDecryptErr; // rx buffer data software compare CRC err count
+ DWORD dwCntRxICVErr; // rx buffer data software compare CRC err count
+ UINT idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD
+
+ // 64-bit OID
+ ULONGLONG ullTsrOK[TYPE_MAXTD];
+
+ // for some optional OIDs (64 bits) and DMI support
+ ULONGLONG ullTxBroadcastFrames[TYPE_MAXTD];
+ ULONGLONG ullTxMulticastFrames[TYPE_MAXTD];
+ ULONGLONG ullTxDirectedFrames[TYPE_MAXTD];
+ ULONGLONG ullTxBroadcastBytes[TYPE_MAXTD];
+ ULONGLONG ullTxMulticastBytes[TYPE_MAXTD];
+ ULONGLONG ullTxDirectedBytes[TYPE_MAXTD];
+
+// DWORD dwTxRetryCount[8];
+ //
+ // ISR status count
+ //
+ SISRCounters ISRStat;
+
+ SCustomCounters CustomStat;
+
+ #ifdef Calcu_LinkQual
+ //Tx count:
+ ULONG TxNoRetryOkCount; //success tx no retry !
+ ULONG TxRetryOkCount; //sucess tx but retry !
+ ULONG TxFailCount; //fail tx ?
+ //Rx count:
+ ULONG RxOkCnt; //sucess rx !
+ ULONG RxFcsErrCnt; //fail rx ?
+ //statistic
+ ULONG SignalStren;
+ ULONG LinkQuality;
+ #endif
+} SStatCounter, DEF* PSStatCounter;
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+void STAvClearAllCounter(PSStatCounter pStatistic);
+
+void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, DWORD dwIsr);
+
+void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
+ BYTE byRSR, BYTE byNewRSR, BYTE byRxRate,
+ PBYTE pbyBuffer, UINT cbFrameLength);
+
+void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic,
+ BYTE byRSR, BYTE byNewRsr, BYTE byRxRate,
+ PBYTE pbyBuffer, UINT cbFrameLength);
+
+void STAvUpdateTDStatCounter(PSStatCounter pStatistic,
+ BYTE byTSR0, BYTE byTSR1,
+ PBYTE pbyBuffer, UINT cbFrameLength, UINT uIdx );
+
+void STAvUpdateTDStatCounterEx(
+ PSStatCounter pStatistic,
+ PBYTE pbyBuffer,
+ DWORD cbFrameLength
+ );
+
+void STAvUpdate802_11Counter(
+ PSDot11Counters p802_11Counter,
+ PSStatCounter pStatistic,
+ DWORD dwCounter
+ );
+
+void STAvClear802_11Counter(PSDot11Counters p802_11Counter);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __MIB_H__
+
+
+
diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c
new file mode 100644
index 000000000000..7bda4c19e903
--- /dev/null
+++ b/drivers/staging/vt6655/michael.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: michael.cpp
+ *
+ * Purpose: The implementation of LIST data structure.
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: Sep 4, 2002
+ *
+ * Functions:
+ * s_dwGetUINT32 - Convert from BYTE[] to DWORD in a portable way
+ * s_vPutUINT32 - Convert from DWORD to BYTE[] in a portable way
+ * s_vClear - Reset the state to the empty message.
+ * s_vSetKey - Set the key.
+ * MIC_vInit - Set the key.
+ * s_vAppendByte - Append the byte to our word-sized buffer.
+ * MIC_vAppend - call s_vAppendByte.
+ * MIC_vGetMIC - Append the minimum padding and call s_vAppendByte.
+ *
+ * Revision History:
+ *
+ */
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__MICHAEL_H__)
+#include "michael.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+/*
+static DWORD s_dwGetUINT32(BYTE * p); // Get DWORD from 4 bytes LSByte first
+static VOID s_vPutUINT32(BYTE* p, DWORD val); // Put DWORD into 4 bytes LSByte first
+*/
+static VOID s_vClear(void); // Clear the internal message,
+ // resets the object to the state just after construction.
+static VOID s_vSetKey(DWORD dwK0, DWORD dwK1);
+static VOID s_vAppendByte(BYTE b); // Add a single byte to the internal message
+
+/*--------------------- Export Variables --------------------------*/
+static DWORD L, R; // Current state
+
+static DWORD K0, K1; // Key
+static DWORD M; // Message accumulator (single word)
+static UINT nBytesInM; // # bytes in M
+
+/*--------------------- Export Functions --------------------------*/
+
+/*
+static DWORD s_dwGetUINT32 (BYTE * p)
+// Convert from BYTE[] to DWORD in a portable way
+{
+ DWORD res = 0;
+ UINT i;
+ for(i=0; i<4; i++ )
+ {
+ res |= (*p++) << (8*i);
+ }
+ return res;
+}
+
+static VOID s_vPutUINT32 (BYTE* p, DWORD val)
+// Convert from DWORD to BYTE[] in a portable way
+{
+ UINT i;
+ for(i=0; i<4; i++ )
+ {
+ *p++ = (BYTE) (val & 0xff);
+ val >>= 8;
+ }
+}
+*/
+
+static VOID s_vClear (void)
+{
+ // Reset the state to the empty message.
+ L = K0;
+ R = K1;
+ nBytesInM = 0;
+ M = 0;
+}
+
+static VOID s_vSetKey (DWORD dwK0, DWORD dwK1)
+{
+ // Set the key
+ K0 = dwK0;
+ K1 = dwK1;
+ // and reset the message
+ s_vClear();
+}
+
+static VOID s_vAppendByte (BYTE b)
+{
+ // Append the byte to our word-sized buffer
+ M |= b << (8*nBytesInM);
+ nBytesInM++;
+ // Process the word if it is full.
+ if( nBytesInM >= 4 )
+ {
+ L ^= M;
+ R ^= ROL32( L, 17 );
+ L += R;
+ R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8);
+ L += R;
+ R ^= ROL32( L, 3 );
+ L += R;
+ R ^= ROR32( L, 2 );
+ L += R;
+ // Clear the buffer
+ M = 0;
+ nBytesInM = 0;
+ }
+}
+
+VOID MIC_vInit (DWORD dwK0, DWORD dwK1)
+{
+ // Set the key
+ s_vSetKey(dwK0, dwK1);
+}
+
+
+VOID MIC_vUnInit (void)
+{
+ // Wipe the key material
+ K0 = 0;
+ K1 = 0;
+
+ // And the other fields as well.
+ //Note that this sets (L,R) to (K0,K1) which is just fine.
+ s_vClear();
+}
+
+VOID MIC_vAppend (PBYTE src, UINT nBytes)
+{
+ // This is simple
+ while (nBytes > 0)
+ {
+ s_vAppendByte(*src++);
+ nBytes--;
+ }
+}
+
+VOID MIC_vGetMIC (PDWORD pdwL, PDWORD pdwR)
+{
+ // Append the minimum padding
+ s_vAppendByte(0x5a);
+ s_vAppendByte(0);
+ s_vAppendByte(0);
+ s_vAppendByte(0);
+ s_vAppendByte(0);
+ // and then zeroes until the length is a multiple of 4
+ while( nBytesInM != 0 )
+ {
+ s_vAppendByte(0);
+ }
+ // The s_vAppendByte function has already computed the result.
+ *pdwL = L;
+ *pdwR = R;
+ // Reset to the empty message.
+ s_vClear();
+}
+
diff --git a/drivers/staging/vt6655/michael.h b/drivers/staging/vt6655/michael.h
new file mode 100644
index 000000000000..62a24a6083aa
--- /dev/null
+++ b/drivers/staging/vt6655/michael.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: Michael.h
+ *
+ * Purpose: Reference implementation for Michael
+ * written by Niels Ferguson
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: Jan 2, 2003
+ *
+ */
+
+
+#ifndef __MICHAEL_H__
+#define __MICHAEL_H__
+
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+VOID MIC_vInit(DWORD dwK0, DWORD dwK1);
+
+VOID MIC_vUnInit(void);
+
+// Append bytes to the message to be MICed
+VOID MIC_vAppend(PBYTE src, UINT nBytes);
+
+// Get the MIC result. Destination should accept 8 bytes of result.
+// This also resets the message to empty.
+VOID MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR);
+
+/*--------------------- Export Macros ------------------------------*/
+
+// Rotation functions on 32 bit values
+#define ROL32( A, n ) \
+ ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
+#define ROR32( A, n ) ROL32( (A), 32-(n) )
+
+#endif //__MICHAEL_H__
+
+
diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c
new file mode 100644
index 000000000000..edd8336712a2
--- /dev/null
+++ b/drivers/staging/vt6655/power.c
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: power.c
+ *
+ * Purpose: Handles 802.11 power managment functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 17, 2002
+ *
+ * Functions:
+ * PSvEnablePowerSaving - Enable Power Saving Mode
+ * PSvDiasblePowerSaving - Disable Power Saving Mode
+ * PSbConsiderPowerDown - Decide if we can Power Down
+ * PSvSendPSPOLL - Send PS-POLL packet
+ * PSbSendNullPacket - Send Null packet
+ * PSbIsNextTBTTWakeUp - Decide if we need to wake up at next Beacon
+ *
+ * Revision History:
+ *
+ */
+
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+/*--------------------- Static Functions --------------------------*/
+
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+/*+
+ *
+ * Routine Description:
+ * Enable hw power saving functions
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+PSvEnablePowerSaving(
+ IN HANDLE hDeviceContext,
+ IN WORD wListenInterval
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15;
+
+ // set period of power up before TBTT
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_PWBT, C_PWBT);
+ if (pDevice->eOPMode != OP_MODE_ADHOC) {
+ // set AID
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_AIDATIM, wAID);
+ } else {
+ // set ATIM Window
+ MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
+ }
+ // Set AutoSleep
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
+ // Set HWUTSF
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_HWUTSF);
+
+ if (wListenInterval >= 2) {
+ // clear always listen beacon
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
+ //pDevice->wCFG &= ~CFG_ALB;
+ // first time set listen next beacon
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
+ pMgmt->wCountToWakeUp = wListenInterval;
+ }
+ else {
+ // always listen beacon
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
+ //pDevice->wCFG |= CFG_ALB;
+ pMgmt->wCountToWakeUp = 0;
+ }
+
+ // enable power saving hw function
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
+ pDevice->bEnablePSMode = TRUE;
+
+ if (pDevice->eOPMode == OP_MODE_ADHOC) {
+// bMgrPrepareBeaconToSend((HANDLE)pDevice, pMgmt);
+ }
+ // We don't send null pkt in ad hoc mode since beacon will handle this.
+ else if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) {
+ PSbSendNullPacket(pDevice);
+ }
+ pDevice->bPWBitOn = TRUE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS:Power Saving Mode Enable... \n");
+ return;
+}
+
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Disable hw power saving functions
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+PSvDisablePowerSaving(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+// PSMgmtObject pMgmt = pDevice->pMgmt;
+
+ // disable power saving hw function
+ MACbPSWakeup(pDevice->PortOffset);
+ //clear AutoSleep
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
+ //clear HWUTSF
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_HWUTSF);
+ // set always listen beacon
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
+
+ pDevice->bEnablePSMode = FALSE;
+
+ if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) {
+ PSbSendNullPacket(pDevice);
+ }
+ pDevice->bPWBitOn = FALSE;
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Consider to power down when no more packets to tx or rx.
+ *
+ * Return Value:
+ * TRUE, if power down success
+ * FALSE, if fail
+-*/
+
+
+BOOL
+PSbConsiderPowerDown(
+ IN HANDLE hDeviceContext,
+ IN BOOL bCheckRxDMA,
+ IN BOOL bCheckCountToWakeUp
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uIdx;
+
+ // check if already in Doze mode
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
+ return TRUE;
+
+ if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
+ // check if in TIM wake period
+ if (pMgmt->bInTIMWake)
+ return FALSE;
+ }
+
+ // check scan state
+ if (pDevice->bCmdRunning)
+ return FALSE;
+
+ // Froce PSEN on
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
+
+ // check if all TD are empty,
+ for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
+ if (pDevice->iTDUsed[uIdx] != 0)
+ return FALSE;
+ }
+
+ // check if rx isr is clear
+ if (bCheckRxDMA &&
+ ((pDevice->dwIsr& ISR_RXDMA0) != 0) &&
+ ((pDevice->dwIsr & ISR_RXDMA1) != 0)){
+ return FALSE;
+ };
+
+ if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
+ if (bCheckCountToWakeUp &&
+ (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) {
+ return FALSE;
+ }
+ }
+
+ // no Tx, no Rx isr, now go to Doze
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n");
+ return TRUE;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Send PS-POLL packet
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+
+VOID
+PSvSendPSPOLL(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSTxMgmtPacket pTxPacket = NULL;
+
+
+ memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN);
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PSPOLL) |
+ WLAN_SET_FC_PWRMGT(0)
+ ));
+ pTxPacket->p80211Header->sA2.wDurationID = pMgmt->wCurrAID | BIT14 | BIT15;
+ memcpy(pTxPacket->p80211Header->sA2.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
+ memcpy(pTxPacket->p80211Header->sA2.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ pTxPacket->cbMPDULen = WLAN_HDR_ADDR2_LEN;
+ pTxPacket->cbPayloadLen = 0;
+ // send the frame
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet failed..\n");
+ }
+ else {
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet success..\n");
+ };
+
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Send NULL packet to AP for notification power state of STA
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+BOOL
+PSbSendNullPacket(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSTxMgmtPacket pTxPacket = NULL;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT uIdx;
+
+
+ if (pDevice->bLinkPass == FALSE) {
+ return FALSE;
+ }
+ #ifdef TxInSleep
+ if ((pDevice->bEnablePSMode == FALSE) &&
+ (pDevice->fTxDataInSleep == FALSE)){
+ return FALSE;
+ }
+#else
+ if (pDevice->bEnablePSMode == FALSE) {
+ return FALSE;
+ }
+#endif
+ if (pDevice->bEnablePSMode) {
+ for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
+ if (pDevice->iTDUsed[uIdx] != 0)
+ return FALSE;
+ }
+ }
+
+ memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN);
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+
+ if (pDevice->bEnablePSMode) {
+
+ pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) |
+ WLAN_SET_FC_PWRMGT(1)
+ ));
+ }
+ else {
+ pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) |
+ WLAN_SET_FC_PWRMGT(0)
+ ));
+ }
+
+ if(pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
+ pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_TODS(1));
+ }
+
+ memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
+ memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN;
+ pTxPacket->cbPayloadLen = 0;
+ // send the frame
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n");
+ return FALSE;
+ }
+ else {
+
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet success....\n");
+ }
+
+
+ return TRUE ;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Check if Next TBTT must wake up
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+BOOL
+PSbIsNextTBTTWakeUp(
+ IN HANDLE hDeviceContext
+ )
+{
+
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ BOOL bWakeUp = FALSE;
+
+ if (pMgmt->wListenInterval >= 2) {
+ if (pMgmt->wCountToWakeUp == 0) {
+ pMgmt->wCountToWakeUp = pMgmt->wListenInterval;
+ }
+
+ pMgmt->wCountToWakeUp --;
+
+ if (pMgmt->wCountToWakeUp == 1) {
+ // Turn on wake up to listen next beacon
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
+ bWakeUp = TRUE;
+ }
+
+ }
+
+ return bWakeUp;
+}
+
diff --git a/drivers/staging/vt6655/power.h b/drivers/staging/vt6655/power.h
new file mode 100644
index 000000000000..a01e7e9aaf67
--- /dev/null
+++ b/drivers/staging/vt6655/power.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: power.h
+ *
+ * Purpose: Handles 802.11 power managment functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: July 17, 2002
+ *
+ */
+
+#ifndef __POWER_H__
+#define __POWER_H__
+
+
+/*--------------------- Export Definitions -------------------------*/
+#define C_PWBT 1000 // micro sec. power up before TBTT
+#define PS_FAST_INTERVAL 1 // Fast power saving listen interval
+#define PS_MAX_INTERVAL 4 // MAX power saving listen interval
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+// IN PSDevice pDevice
+// IN PSDevice hDeviceContext
+
+BOOL
+PSbConsiderPowerDown(
+ IN HANDLE hDeviceContext,
+ IN BOOL bCheckRxDMA,
+ IN BOOL bCheckCountToWakeUp
+ );
+
+VOID
+PSvDisablePowerSaving(
+ IN HANDLE hDeviceContext
+ );
+
+VOID
+PSvEnablePowerSaving(
+ IN HANDLE hDeviceContext,
+ IN WORD wListenInterval
+ );
+
+VOID
+PSvSendPSPOLL(
+ IN HANDLE hDeviceContext
+ );
+
+BOOL
+PSbSendNullPacket(
+ IN HANDLE hDeviceContext
+ );
+
+BOOL
+PSbIsNextTBTTWakeUp(
+ IN HANDLE hDeviceContext
+ );
+
+#endif //__POWER_H__
diff --git a/drivers/staging/vt6655/rc4.c b/drivers/staging/vt6655/rc4.c
new file mode 100644
index 000000000000..0345e3247f4d
--- /dev/null
+++ b/drivers/staging/vt6655/rc4.c
@@ -0,0 +1,86 @@
+/*
+ * File: rc4.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Purpose:
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: Sep 4, 2002
+ *
+ */
+
+#if !defined(__RC4_H__)
+#include "rc4.h"
+#endif
+
+VOID rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len)
+{
+ UINT ust1, ust2;
+ UINT keyindex;
+ UINT stateindex;
+ PBYTE pbyst;
+ UINT idx;
+
+ pbyst = pRC4->abystate;
+ pRC4->ux = 0;
+ pRC4->uy = 0;
+ for (idx = 0; idx < 256; idx++)
+ pbyst[idx] = (BYTE)idx;
+ keyindex = 0;
+ stateindex = 0;
+ for (idx = 0; idx < 256; idx++) {
+ ust1 = pbyst[idx];
+ stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff;
+ ust2 = pbyst[stateindex];
+ pbyst[stateindex] = (BYTE)ust1;
+ pbyst[idx] = (BYTE)ust2;
+ if (++keyindex >= cbKey_len)
+ keyindex = 0;
+ }
+}
+
+UINT rc4_byte(PRC4Ext pRC4)
+{
+ UINT ux;
+ UINT uy;
+ UINT ustx, usty;
+ PBYTE pbyst;
+
+ pbyst = pRC4->abystate;
+ ux = (pRC4->ux + 1) & 0xff;
+ ustx = pbyst[ux];
+ uy = (ustx + pRC4->uy) & 0xff;
+ usty = pbyst[uy];
+ pRC4->ux = ux;
+ pRC4->uy = uy;
+ pbyst[uy] = (BYTE)ustx;
+ pbyst[ux] = (BYTE)usty;
+
+ return pbyst[(ustx + usty) & 0xff];
+}
+
+VOID rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest,
+ PBYTE pbySrc, UINT cbData_len)
+{
+ UINT ii;
+ for (ii = 0; ii < cbData_len; ii++)
+ pbyDest[ii] = (BYTE)(pbySrc[ii] ^ rc4_byte(pRC4));
+}
diff --git a/drivers/staging/vt6655/rc4.h b/drivers/staging/vt6655/rc4.h
new file mode 100644
index 000000000000..4e3ccc559c8f
--- /dev/null
+++ b/drivers/staging/vt6655/rc4.h
@@ -0,0 +1,51 @@
+/*
+ * File: rc4.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Purpose:
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: Sep 4, 2002
+ *
+ */
+
+#ifndef __RC4_H__
+#define __RC4_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+/*--------------------- Export Types ------------------------------*/
+typedef struct {
+ UINT ux;
+ UINT uy;
+ BYTE abystate[256];
+} RC4Ext, DEF* PRC4Ext;
+
+VOID rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len);
+UINT rc4_byte(PRC4Ext pRC4);
+void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, PBYTE pbySrc, UINT cbData_len);
+
+#endif //__RC4_H__
diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c
new file mode 100644
index 000000000000..9d4e3eb7c8e5
--- /dev/null
+++ b/drivers/staging/vt6655/rf.c
@@ -0,0 +1,1283 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: rf.c
+ *
+ * Purpose: rf function code
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Feb. 19, 2004
+ *
+ * Functions:
+ * IFRFbWriteEmbeded - Embeded write RF register via MAC
+ *
+ * Revision History:
+ *
+ */
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__SROM_H__)
+#include "srom.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+//static int msglevel =MSG_LEVEL_INFO;
+
+#define BY_RF2959_REG_LEN 23 //24bits
+#define CB_RF2959_INIT_SEQ 15
+#define SWITCH_CHANNEL_DELAY_RF2959 200 //us
+#define RF2959_PWR_IDX_LEN 32
+
+#define BY_MA2825_REG_LEN 23 //24bit
+#define CB_MA2825_INIT_SEQ 13
+#define SWITCH_CHANNEL_DELAY_MA2825 200 //us
+#define MA2825_PWR_IDX_LEN 31
+
+#define BY_AL2230_REG_LEN 23 //24bit
+#define CB_AL2230_INIT_SEQ 15
+#define SWITCH_CHANNEL_DELAY_AL2230 200 //us
+#define AL2230_PWR_IDX_LEN 64
+
+
+#define BY_UW2451_REG_LEN 23
+#define CB_UW2451_INIT_SEQ 6
+#define SWITCH_CHANNEL_DELAY_UW2451 200 //us
+#define UW2451_PWR_IDX_LEN 25
+
+//{{ RobertYu: 20041118
+#define BY_MA2829_REG_LEN 23 //24bit
+#define CB_MA2829_INIT_SEQ 13
+#define SWITCH_CHANNEL_DELAY_MA2829 200 //us
+#define MA2829_PWR_IDX_LEN 64
+//}} RobertYu
+
+//{{ RobertYu:20050103
+#define BY_AL7230_REG_LEN 23 //24bit
+#define CB_AL7230_INIT_SEQ 16
+#define SWITCH_CHANNEL_DELAY_AL7230 200 //us
+#define AL7230_PWR_IDX_LEN 64
+//}} RobertYu
+
+//{{ RobertYu: 20041210
+#define BY_UW2452_REG_LEN 23
+#define CB_UW2452_INIT_SEQ 5 //RoberYu:20050113, Rev0.2 Programming Guide(remove R3, so 6-->5)
+#define SWITCH_CHANNEL_DELAY_UW2452 100 //us
+#define UW2452_PWR_IDX_LEN 64
+//}} RobertYu
+
+#define BY_VT3226_REG_LEN 23
+#define CB_VT3226_INIT_SEQ 12
+#define SWITCH_CHANNEL_DELAY_VT3226 200 //us
+#define VT3226_PWR_IDX_LEN 16
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+
+
+const DWORD dwAL2230InitTable[CB_AL2230_INIT_SEQ] = {
+ 0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x01A00200+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x00FFF300+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x0F4DC500+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x0805B600+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x0146C700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x00068800+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x0403B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x00DBBA00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+ 0x0BDFFC00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x00000D00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x00580F00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW
+ };
+
+const DWORD dwAL2230ChannelTable0[CB_MAX_CHANNEL] = {
+ 0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
+ 0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
+ 0x03E79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
+ 0x03E79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
+ 0x03F7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
+ 0x03F7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
+ 0x03E7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
+ 0x03E7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
+ 0x03F7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
+ 0x03F7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
+ 0x03E7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
+ 0x03E7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
+ 0x03F7C000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
+ 0x03E7C000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW // channel = 14, Tf = 2412M
+ };
+
+const DWORD dwAL2230ChannelTable1[CB_MAX_CHANNEL] = {
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
+ 0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
+ 0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
+ 0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
+ 0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
+ 0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
+ 0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
+ 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
+ 0x06666100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW // channel = 14, Tf = 2412M
+ };
+
+DWORD dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = {
+ 0x04040900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04041900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04042900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04043900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04044900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04045900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04046900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04047900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04048900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04049900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0404A900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0404B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0404C900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0404D900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0404E900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0404F900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04050900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04051900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04052900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04053900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04054900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04055900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04056900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04057900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04058900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04059900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0405A900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0405B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0405C900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0405D900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0405E900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0405F900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04060900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04061900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04062900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04063900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04064900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04065900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04066900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04067900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04068900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04069900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0406A900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0406B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0406C900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0406D900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0406E900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0406F900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04070900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04071900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04072900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04073900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04074900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04075900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04076900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04077900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04078900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x04079900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0407A900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0407B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0407C900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0407D900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0407E900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x0407F900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW
+ };
+
+//{{ RobertYu:20050104
+// 40MHz reference frequency
+// Need to Pull PLLON(PE3) low when writing channel registers through 3-wire.
+const DWORD dwAL7230InitTable[CB_AL7230_INIT_SEQ] = {
+ 0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel1 // Need modify for 11a
+ 0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel1 // Need modify for 11a
+ 0x841FF200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 451FE2
+ 0x3FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 5FDFA3
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // 11b/g // Need modify for 11a
+ //0x802B4500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 8D1B45
+ // RoberYu:20050113, Rev0.47 Regsiter Setting Guide
+ 0x802B5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 8D1B55
+ 0x56AF3600+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0xCE020700+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 860207
+ 0x6EBC0800+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0xE0000A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: E0600A
+ 0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10)
+ //0x00093C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 00143C
+ // RoberYu:20050113, Rev0.47 Regsiter Setting Guide
+ 0x000A3C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 00143C
+ 0xFFFFFD00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x00000E00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x1ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // Need modify for 11a: 12BACF
+ };
+
+const DWORD dwAL7230InitTableAMode[CB_AL7230_INIT_SEQ] = {
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel184 // Need modify for 11b/g
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel184 // Need modify for 11b/g
+ 0x451FE200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+ 0x5FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+ 0x67F78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // 11a // Need modify for 11b/g
+ 0x853F5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g, RoberYu:20050113
+ 0x56AF3600+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0xCE020700+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+ 0x6EBC0800+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0xE0600A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+ 0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10)
+ 0x00147C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+ 0xFFFFFD00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x00000E00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
+ 0x12BACF00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // Need modify for 11b/g
+ };
+
+
+const DWORD dwAL7230ChannelTable0[CB_MAX_CHANNEL] = {
+ 0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
+ 0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
+ 0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
+ 0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
+ 0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
+ 0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
+ 0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
+ 0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz //RobertYu: 20050218, update for APNode 0.49
+ 0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz //RobertYu: 20050218, update for APNode 0.49
+ 0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz //RobertYu: 20050218, update for APNode 0.49
+ 0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz //RobertYu: 20050218, update for APNode 0.49
+ 0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz //RobertYu: 20050218, update for APNode 0.49
+ 0x0037C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz //RobertYu: 20050218, update for APNode 0.49
+ 0x0037C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 183, Tf = 4915MHz (15)
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 184, Tf = 4920MHz (16)
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 185, Tf = 4925MHz (17)
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 187, Tf = 4935MHz (18)
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 188, Tf = 4940MHz (19)
+ 0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 189, Tf = 4945MHz (20)
+ 0x0FF53000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 192, Tf = 4960MHz (21)
+ 0x0FF53000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 196, Tf = 4980MHz (22)
+
+ // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+ // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
+
+ 0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 5035MHz (23)
+ 0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 5040MHz (24)
+ 0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 5045MHz (25)
+ 0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 5055MHz (26)
+ 0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 5060MHz (27)
+ 0x0FF55000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 16, Tf = 5080MHz (28)
+ 0x0FF56000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 34, Tf = 5170MHz (29)
+ 0x0FF56000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 36, Tf = 5180MHz (30)
+ 0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 38, Tf = 5190MHz (31) //RobertYu: 20050218, update for APNode 0.49
+ 0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 40, Tf = 5200MHz (32)
+ 0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 42, Tf = 5210MHz (33)
+ 0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 44, Tf = 5220MHz (34)
+ 0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 46, Tf = 5230MHz (35)
+ 0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 48, Tf = 5240MHz (36)
+ 0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 52, Tf = 5260MHz (37)
+ 0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 56, Tf = 5280MHz (38)
+ 0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 60, Tf = 5300MHz (39)
+ 0x0FF59000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 64, Tf = 5320MHz (40)
+
+ 0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 100, Tf = 5500MHz (41)
+ 0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 104, Tf = 5520MHz (42)
+ 0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 108, Tf = 5540MHz (43)
+ 0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 112, Tf = 5560MHz (44)
+ 0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 116, Tf = 5580MHz (45)
+ 0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 120, Tf = 5600MHz (46)
+ 0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 124, Tf = 5620MHz (47)
+ 0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 128, Tf = 5640MHz (48)
+ 0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 132, Tf = 5660MHz (49)
+ 0x0FF5F000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 136, Tf = 5680MHz (50)
+ 0x0FF5F000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 140, Tf = 5700MHz (51)
+ 0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 149, Tf = 5745MHz (52)
+ 0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 153, Tf = 5765MHz (53)
+ 0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 157, Tf = 5785MHz (54)
+ 0x0FF61000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55)
+ 0x0FF61000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // channel = 165, Tf = 5825MHz (56)
+ };
+
+const DWORD dwAL7230ChannelTable1[CB_MAX_CHANNEL] = {
+ 0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
+ 0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
+ 0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
+ 0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
+ 0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
+ 0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
+ 0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
+ 0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
+ 0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
+ 0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
+ 0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
+ 0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
+ 0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
+ 0x06666100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ 0x1D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 183, Tf = 4915MHz (15)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 184, Tf = 4920MHz (16)
+ 0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 185, Tf = 4925MHz (17)
+ 0x08000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 187, Tf = 4935MHz (18)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 188, Tf = 4940MHz (19)
+ 0x0D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 189, Tf = 4945MHz (20)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 192, Tf = 4960MHz (21)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 196, Tf = 4980MHz (22)
+
+ // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+ // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
+ 0x1D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 5035MHz (23)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 5040MHz (24)
+ 0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 5045MHz (25)
+ 0x08000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 5055MHz (26)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 5060MHz (27)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 16, Tf = 5080MHz (28)
+ 0x05555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 34, Tf = 5170MHz (29)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 36, Tf = 5180MHz (30)
+ 0x10000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 38, Tf = 5190MHz (31)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 40, Tf = 5200MHz (32)
+ 0x1AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 42, Tf = 5210MHz (33)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 44, Tf = 5220MHz (34)
+ 0x05555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 46, Tf = 5230MHz (35)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 48, Tf = 5240MHz (36)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 52, Tf = 5260MHz (37)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 56, Tf = 5280MHz (38)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 60, Tf = 5300MHz (39)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 64, Tf = 5320MHz (40)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 100, Tf = 5500MHz (41)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 104, Tf = 5520MHz (42)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 108, Tf = 5540MHz (43)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 112, Tf = 5560MHz (44)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 116, Tf = 5580MHz (45)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 120, Tf = 5600MHz (46)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 124, Tf = 5620MHz (47)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 128, Tf = 5640MHz (48)
+ 0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 132, Tf = 5660MHz (49)
+ 0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 136, Tf = 5680MHz (50)
+ 0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 140, Tf = 5700MHz (51)
+ 0x18000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 149, Tf = 5745MHz (52)
+ 0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 153, Tf = 5765MHz (53)
+ 0x0D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 157, Tf = 5785MHz (54)
+ 0x18000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55)
+ 0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // channel = 165, Tf = 5825MHz (56)
+ };
+
+const DWORD dwAL7230ChannelTable2[CB_MAX_CHANNEL] = {
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
+ 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 183, Tf = 4915MHz (15)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 184, Tf = 4920MHz (16)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 185, Tf = 4925MHz (17)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 187, Tf = 4935MHz (18)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 188, Tf = 4940MHz (19)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 189, Tf = 4945MHz (20)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 192, Tf = 4960MHz (21)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 196, Tf = 4980MHz (22)
+
+ // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+ // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 5035MHz (23)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 5040MHz (24)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 5045MHz (25)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 5055MHz (26)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 5060MHz (27)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 16, Tf = 5080MHz (28)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 34, Tf = 5170MHz (29)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 36, Tf = 5180MHz (30)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 38, Tf = 5190MHz (31)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 40, Tf = 5200MHz (32)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 42, Tf = 5210MHz (33)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 44, Tf = 5220MHz (34)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 46, Tf = 5230MHz (35)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 48, Tf = 5240MHz (36)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 52, Tf = 5260MHz (37)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 56, Tf = 5280MHz (38)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 60, Tf = 5300MHz (39)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 64, Tf = 5320MHz (40)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 100, Tf = 5500MHz (41)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 104, Tf = 5520MHz (42)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 108, Tf = 5540MHz (43)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 112, Tf = 5560MHz (44)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 116, Tf = 5580MHz (45)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 120, Tf = 5600MHz (46)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 124, Tf = 5620MHz (47)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 128, Tf = 5640MHz (48)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 132, Tf = 5660MHz (49)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 136, Tf = 5680MHz (50)
+ 0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 140, Tf = 5700MHz (51)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 149, Tf = 5745MHz (52)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 153, Tf = 5765MHz (53)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 157, Tf = 5785MHz (54)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55)
+ 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // channel = 165, Tf = 5825MHz (56)
+ };
+//}} RobertYu
+
+
+
+
+/*--------------------- Static Functions --------------------------*/
+
+
+
+
+/*
+ * Description: AIROHA IFRF chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL s_bAL7230Init (DWORD_PTR dwIoBase)
+{
+ int ii;
+ BOOL bResult;
+
+ bResult = TRUE;
+
+ //3-wire control for normal mode
+ VNSvOutPortB(dwIoBase + MAC_REG_SOFTPWRCTL, 0);
+
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPECTI |
+ SOFTPWRCTL_TXPEINV));
+ BBvPowerSaveModeOFF(dwIoBase); //RobertYu:20050106, have DC value for Calibration
+
+ for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++)
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[ii]);
+
+ // PLL On
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
+
+ //Calibration
+ MACvTimer0MicroSDelay(dwIoBase, 150);//150us
+ bResult &= IFRFbWriteEmbeded(dwIoBase, (0x9ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); //TXDCOC:active, RCK:diable
+ MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+ bResult &= IFRFbWriteEmbeded(dwIoBase, (0x3ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); //TXDCOC:diable, RCK:active
+ MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[CB_AL7230_INIT_SEQ-1]); //TXDCOC:diable, RCK:diable
+
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 |
+ SOFTPWRCTL_SWPE2 |
+ SOFTPWRCTL_SWPECTI |
+ SOFTPWRCTL_TXPEINV));
+
+ BBvPowerSaveModeON(dwIoBase); // RobertYu:20050106
+
+ // PE1: TX_ON, PE2: RX_ON, PE3: PLLON
+ //3-wire control for power saving mode
+ VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); //1100 0000
+
+ return bResult;
+}
+
+// Need to Pull PLLON low when writing channel registers through 3-wire interface
+BOOL s_bAL7230SelectChannel (DWORD_PTR dwIoBase, BYTE byChannel)
+{
+ BOOL bResult;
+
+ bResult = TRUE;
+
+ // PLLON Off
+ MACvWordRegBitsOff(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
+
+ bResult &= IFRFbWriteEmbeded (dwIoBase, dwAL7230ChannelTable0[byChannel-1]); //Reg0
+ bResult &= IFRFbWriteEmbeded (dwIoBase, dwAL7230ChannelTable1[byChannel-1]); //Reg1
+ bResult &= IFRFbWriteEmbeded (dwIoBase, dwAL7230ChannelTable2[byChannel-1]); //Reg4
+
+ // PLLOn On
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
+
+ // Set Channel[7] = 0 to tell H/W channel is changing now.
+ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel & 0x7F));
+ MACvTimer0MicroSDelay(dwIoBase, SWITCH_CHANNEL_DELAY_AL7230);
+ // Set Channel[7] = 1 to tell H/W channel change is done.
+ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel | 0x80));
+
+ return bResult;
+}
+
+/*
+ * Description: Select channel with UW2452 chip
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * uChannel - Channel number
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+
+//{{ RobertYu: 20041210
+/*
+ * Description: UW2452 IFRF chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+
+
+//}} RobertYu
+////////////////////////////////////////////////////////////////////////////////
+
+/*
+ * Description: VT3226 IFRF chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+/*
+ * Description: Select channel with VT3226 chip
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * uChannel - Channel number
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+/*
+ * Description: Write to IF/RF, by embeded programming
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * dwData - data to write
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL IFRFbWriteEmbeded (DWORD_PTR dwIoBase, DWORD dwData)
+{
+ WORD ww;
+ DWORD dwValue;
+
+ VNSvOutPortD(dwIoBase + MAC_REG_IFREGCTL, dwData);
+
+ // W_MAX_TIMEOUT is the timeout period
+ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
+ VNSvInPortD(dwIoBase + MAC_REG_IFREGCTL, &dwValue);
+ if (BITbIsBitOn(dwValue, IFREGCTL_DONE))
+ break;
+ }
+
+ if (ww == W_MAX_TIMEOUT) {
+// DBG_PORT80_ALWAYS(0x32);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+
+/*
+ * Description: RFMD RF2959 IFRF chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+/*
+ * Description: Select channel with RFMD 2959 chip
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * uChannel - Channel number
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+/*
+ * Description: AIROHA IFRF chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL RFbAL2230Init (DWORD_PTR dwIoBase)
+{
+ int ii;
+ BOOL bResult;
+
+ bResult = TRUE;
+
+ //3-wire control for normal mode
+ VNSvOutPortB(dwIoBase + MAC_REG_SOFTPWRCTL, 0);
+
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPECTI |
+ SOFTPWRCTL_TXPEINV));
+//2008-8-21 chester <add>
+ // PLL Off
+
+ MACvWordRegBitsOff(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
+
+
+
+ //patch abnormal AL2230 frequency output
+//2008-8-21 chester <add>
+ IFRFbWriteEmbeded(dwIoBase, (0x07168700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW));
+
+
+ for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++)
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL2230InitTable[ii]);
+//2008-8-21 chester <add>
+MACvTimer0MicroSDelay(dwIoBase, 30); //delay 30 us
+
+ // PLL On
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
+
+ MACvTimer0MicroSDelay(dwIoBase, 150);//150us
+ bResult &= IFRFbWriteEmbeded(dwIoBase, (0x00d80f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW));
+ MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+ bResult &= IFRFbWriteEmbeded(dwIoBase, (0x00780f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW));
+ MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL2230InitTable[CB_AL2230_INIT_SEQ-1]);
+
+ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 |
+ SOFTPWRCTL_SWPE2 |
+ SOFTPWRCTL_SWPECTI |
+ SOFTPWRCTL_TXPEINV));
+
+ //3-wire control for power saving mode
+ VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); //1100 0000
+
+ return bResult;
+}
+
+BOOL RFbAL2230SelectChannel (DWORD_PTR dwIoBase, BYTE byChannel)
+{
+ BOOL bResult;
+
+ bResult = TRUE;
+
+ bResult &= IFRFbWriteEmbeded (dwIoBase, dwAL2230ChannelTable0[byChannel-1]);
+ bResult &= IFRFbWriteEmbeded (dwIoBase, dwAL2230ChannelTable1[byChannel-1]);
+
+ // Set Channel[7] = 0 to tell H/W channel is changing now.
+ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel & 0x7F));
+ MACvTimer0MicroSDelay(dwIoBase, SWITCH_CHANNEL_DELAY_AL2230);
+ // Set Channel[7] = 1 to tell H/W channel change is done.
+ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel | 0x80));
+
+ return bResult;
+}
+
+/*
+ * Description: UW2451 IFRF chip init function
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+
+/*
+ * Description: Select channel with UW2451 chip
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * uChannel - Channel number
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+/*
+ * Description: Set sleep mode to UW2451 chip
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * uChannel - Channel number
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+/*
+ * Description: RF init function
+ *
+ * Parameters:
+ * In:
+ * byBBType
+ * byRFType
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL RFbInit (
+ IN PSDevice pDevice
+ )
+{
+BOOL bResult = TRUE;
+ switch (pDevice->byRFType) {
+ case RF_AIROHA :
+ case RF_AL2230S:
+ pDevice->byMaxPwrLevel = AL2230_PWR_IDX_LEN;
+ bResult = RFbAL2230Init(pDevice->PortOffset);
+ break;
+ case RF_AIROHA7230 :
+ pDevice->byMaxPwrLevel = AL7230_PWR_IDX_LEN;
+ bResult = s_bAL7230Init(pDevice->PortOffset);
+ break;
+ case RF_NOTHING :
+ bResult = TRUE;
+ break;
+ default :
+ bResult = FALSE;
+ break;
+ }
+ return bResult;
+}
+
+/*
+ * Description: RF ShutDown function
+ *
+ * Parameters:
+ * In:
+ * byBBType
+ * byRFType
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL RFbShutDown (
+ IN PSDevice pDevice
+ )
+{
+BOOL bResult = TRUE;
+
+ switch (pDevice->byRFType) {
+ case RF_AIROHA7230 :
+ bResult = IFRFbWriteEmbeded (pDevice->PortOffset, 0x1ABAEF00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW);
+ break;
+ default :
+ bResult = TRUE;
+ break;
+ }
+ return bResult;
+}
+
+/*
+ * Description: Select channel
+ *
+ * Parameters:
+ * In:
+ * byRFType
+ * byChannel - Channel number
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL RFbSelectChannel (DWORD_PTR dwIoBase, BYTE byRFType, BYTE byChannel)
+{
+BOOL bResult = TRUE;
+ switch (byRFType) {
+
+ case RF_AIROHA :
+ case RF_AL2230S:
+ bResult = RFbAL2230SelectChannel(dwIoBase, byChannel);
+ break;
+ //{{ RobertYu: 20050104
+ case RF_AIROHA7230 :
+ bResult = s_bAL7230SelectChannel(dwIoBase, byChannel);
+ break;
+ //}} RobertYu
+ case RF_NOTHING :
+ bResult = TRUE;
+ break;
+ default:
+ bResult = FALSE;
+ break;
+ }
+ return bResult;
+}
+
+/*
+ * Description: Write WakeProgSyn
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * uChannel - channel number
+ * bySleepCnt - SleepProgSyn count
+ *
+ * Return Value: None.
+ *
+ */
+BOOL RFvWriteWakeProgSyn (DWORD_PTR dwIoBase, BYTE byRFType, UINT uChannel)
+{
+ int ii;
+ BYTE byInitCount = 0;
+ BYTE bySleepCount = 0;
+
+ VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, 0);
+ switch (byRFType) {
+ case RF_AIROHA:
+ case RF_AL2230S:
+
+ if (uChannel > CB_MAX_CHANNEL_24G)
+ return FALSE;
+
+ byInitCount = CB_AL2230_INIT_SEQ + 2; // Init Reg + Channel Reg (2)
+ bySleepCount = 0;
+ if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) {
+ return FALSE;
+ }
+
+ for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++ ) {
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230InitTable[ii]);
+ }
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230ChannelTable0[uChannel-1]);
+ ii ++;
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230ChannelTable1[uChannel-1]);
+ break;
+
+ //{{ RobertYu: 20050104
+ // Need to check, PLLON need to be low for channel setting
+ case RF_AIROHA7230:
+ byInitCount = CB_AL7230_INIT_SEQ + 3; // Init Reg + Channel Reg (3)
+ bySleepCount = 0;
+ if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) {
+ return FALSE;
+ }
+
+ if (uChannel <= CB_MAX_CHANNEL_24G)
+ {
+ for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++ ) {
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230InitTable[ii]);
+ }
+ }
+ else
+ {
+ for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++ ) {
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230InitTableAMode[ii]);
+ }
+ }
+
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230ChannelTable0[uChannel-1]);
+ ii ++;
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230ChannelTable1[uChannel-1]);
+ ii ++;
+ MACvSetMISCFifo(dwIoBase, (WORD)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230ChannelTable2[uChannel-1]);
+ break;
+ //}} RobertYu
+
+ case RF_NOTHING :
+ return TRUE;
+ break;
+
+ default:
+ return FALSE;
+ break;
+ }
+
+ MACvSetMISCFifo(dwIoBase, MISCFIFO_SYNINFO_IDX, (DWORD)MAKEWORD(bySleepCount, byInitCount));
+
+ return TRUE;
+}
+
+/*
+ * Description: Set Tx power
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * dwRFPowerTable - RF Tx Power Setting
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL RFbSetPower (
+ IN PSDevice pDevice,
+ IN UINT uRATE,
+ IN UINT uCH
+ )
+{
+BOOL bResult = TRUE;
+BYTE byPwr = 0;
+BYTE byDec = 0;
+BYTE byPwrdBm = 0;
+
+ if (pDevice->dwDiagRefCount != 0) {
+ return TRUE;
+ }
+ if ((uCH < 1) || (uCH > CB_MAX_CHANNEL)) {
+ return FALSE;
+ }
+
+ switch (uRATE) {
+ case RATE_1M:
+ case RATE_2M:
+ case RATE_5M:
+ case RATE_11M:
+ byPwr = pDevice->abyCCKPwrTbl[uCH];
+ byPwrdBm = pDevice->abyCCKDefaultPwr[uCH];
+//PLICE_DEBUG->
+ //byPwr+=5;
+//PLICE_DEBUG <-
+
+//printk("Rate <11:byPwr is %d\n",byPwr);
+ break;
+ case RATE_6M:
+ case RATE_9M:
+ case RATE_18M:
+ byPwr = pDevice->abyOFDMPwrTbl[uCH];
+ if (pDevice->byRFType == RF_UW2452) {
+ byDec = byPwr + 14;
+ } else {
+ byDec = byPwr + 10;
+ }
+ if (byDec >= pDevice->byMaxPwrLevel) {
+ byDec = pDevice->byMaxPwrLevel-1;
+ }
+ if (pDevice->byRFType == RF_UW2452) {
+ byPwrdBm = byDec - byPwr;
+ byPwrdBm /= 3;
+ } else {
+ byPwrdBm = byDec - byPwr;
+ byPwrdBm >>= 1;
+ }
+ byPwrdBm += pDevice->abyOFDMDefaultPwr[uCH];
+ byPwr = byDec;
+//PLICE_DEBUG->
+ //byPwr+=5;
+//PLICE_DEBUG<-
+
+//printk("Rate <24:byPwr is %d\n",byPwr);
+ break;
+ case RATE_24M:
+ case RATE_36M:
+ case RATE_48M:
+ case RATE_54M:
+ byPwr = pDevice->abyOFDMPwrTbl[uCH];
+ byPwrdBm = pDevice->abyOFDMDefaultPwr[uCH];
+//PLICE_DEBUG->
+ //byPwr+=5;
+//PLICE_DEBUG<-
+//printk("Rate < 54:byPwr is %d\n",byPwr);
+ break;
+ }
+
+#if 0
+
+ // 802.11h TPC
+ if (pDevice->bLinkPass == TRUE) {
+ // do not over local constraint
+ if (byPwrdBm > pDevice->abyLocalPwr[uCH]) {
+ pDevice->byCurPwrdBm = pDevice->abyLocalPwr[uCH];
+ byDec = byPwrdBm - pDevice->abyLocalPwr[uCH];
+ if (pDevice->byRFType == RF_UW2452) {
+ byDec *= 3;
+ } else {
+ byDec <<= 1;
+ }
+ if (byPwr > byDec) {
+ byPwr -= byDec;
+ } else {
+ byPwr = 0;
+ }
+ } else {
+ pDevice->byCurPwrdBm = byPwrdBm;
+ }
+ } else {
+ // do not over regulatory constraint
+ if (byPwrdBm > pDevice->abyRegPwr[uCH]) {
+ pDevice->byCurPwrdBm = pDevice->abyRegPwr[uCH];
+ byDec = byPwrdBm - pDevice->abyRegPwr[uCH];
+ if (pDevice->byRFType == RF_UW2452) {
+ byDec *= 3;
+ } else {
+ byDec <<= 1;
+ }
+ if (byPwr > byDec) {
+ byPwr -= byDec;
+ } else {
+ byPwr = 0;
+ }
+ } else {
+ pDevice->byCurPwrdBm = byPwrdBm;
+ }
+ }
+#endif
+
+// if (pDevice->byLocalID <= REV_ID_VT3253_B1) {
+ if (pDevice->byCurPwr == byPwr) {
+ return TRUE;
+ }
+ bResult = RFbRawSetPower(pDevice, byPwr, uRATE);
+// }
+ if (bResult == TRUE) {
+ pDevice->byCurPwr = byPwr;
+ }
+ return bResult;
+}
+
+/*
+ * Description: Set Tx power
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * dwRFPowerTable - RF Tx Power Setting
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+
+BOOL RFbRawSetPower (
+ IN PSDevice pDevice,
+ IN BYTE byPwr,
+ IN UINT uRATE
+ )
+{
+BOOL bResult = TRUE;
+DWORD dwMax7230Pwr = 0;
+
+ if (byPwr >= pDevice->byMaxPwrLevel) {
+ return (FALSE);
+ }
+ switch (pDevice->byRFType) {
+
+ case RF_AIROHA :
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, dwAL2230PowerTable[byPwr]);
+ if (uRATE <= RATE_11M) {
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ } else {
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ }
+ break;
+
+
+ case RF_AL2230S :
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, dwAL2230PowerTable[byPwr]);
+ if (uRATE <= RATE_11M) {
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ }else {
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ }
+
+ break;
+
+ case RF_AIROHA7230:
+ // 0x080F1B00 for 3 wire control TxGain(D10) and 0x31 as TX Gain value
+ dwMax7230Pwr = 0x080C0B00 | ( (byPwr) << 12 ) |
+ (BY_AL7230_REG_LEN << 3 ) | IFREGCTL_REGW;
+
+ bResult &= IFRFbWriteEmbeded(pDevice->PortOffset, dwMax7230Pwr);
+ break;
+
+
+ default :
+ break;
+ }
+ return bResult;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Translate RSSI to dBm
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be translated
+ * byCurrRSSI - RSSI to be translated
+ * Out:
+ * pdwdbm - Translated dbm number
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+RFvRSSITodBm (
+ IN PSDevice pDevice,
+ IN BYTE byCurrRSSI,
+ OUT PLONG pldBm
+ )
+{
+ BYTE byIdx = (((byCurrRSSI & 0xC0) >> 6) & 0x03);
+ LONG b = (byCurrRSSI & 0x3F);
+ LONG a = 0;
+ BYTE abyAIROHARF[4] = {0, 18, 0, 40};
+
+ switch (pDevice->byRFType) {
+ case RF_AIROHA:
+ case RF_AL2230S:
+ case RF_AIROHA7230: //RobertYu: 20040104
+ a = abyAIROHARF[byIdx];
+ break;
+ default:
+ break;
+ }
+
+ *pldBm = -1 * (a + b * 2);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//{{ RobertYu: 20050104
+
+
+// Post processing for the 11b/g and 11a.
+// for save time on changing Reg2,3,5,7,10,12,15
+BOOL RFbAL7230SelectChannelPostProcess (DWORD_PTR dwIoBase, BYTE byOldChannel, BYTE byNewChannel)
+{
+ BOOL bResult;
+
+ bResult = TRUE;
+
+ // if change between 11 b/g and 11a need to update the following register
+ // Channel Index 1~14
+
+ if( (byOldChannel <= CB_MAX_CHANNEL_24G) && (byNewChannel > CB_MAX_CHANNEL_24G) )
+ {
+ // Change from 2.4G to 5G
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[2]); //Reg2
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[3]); //Reg3
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[5]); //Reg5
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[7]); //Reg7
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[10]);//Reg10
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[12]);//Reg12
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTableAMode[15]);//Reg15
+ }
+ else if( (byOldChannel > CB_MAX_CHANNEL_24G) && (byNewChannel <= CB_MAX_CHANNEL_24G) )
+ {
+ // change from 5G to 2.4G
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[2]); //Reg2
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[3]); //Reg3
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[5]); //Reg5
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[7]); //Reg7
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[10]);//Reg10
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[12]);//Reg12
+ bResult &= IFRFbWriteEmbeded(dwIoBase, dwAL7230InitTable[15]);//Reg15
+ }
+
+ return bResult;
+}
+
+
+//}} RobertYu
+////////////////////////////////////////////////////////////////////////////////
+
diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h
new file mode 100644
index 000000000000..05fe17b2cfb7
--- /dev/null
+++ b/drivers/staging/vt6655/rf.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: rf.h
+ *
+ * Purpose:
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Feb. 19, 2004
+ *
+ */
+
+
+#ifndef __RF_H__
+#define __RF_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+/*--------------------- Export Definitions -------------------------*/
+//
+// Baseband RF pair definition in eeprom (Bits 6..0)
+//
+#define RF_RFMD2959 0x01
+#define RF_MAXIMAG 0x02
+#define RF_AIROHA 0x03
+
+//#define RF_GCT5103 0x04
+#define RF_UW2451 0x05
+#define RF_MAXIMG 0x06
+#define RF_MAXIM2829 0x07 // RobertYu: 20041118
+#define RF_UW2452 0x08 // RobertYu: 20041210
+#define RF_AIROHA7230 0x0a // RobertYu: 20050104
+#define RF_UW2453 0x0b
+
+#define RF_VT3226 0x09
+#define RF_AL2230S 0x0e
+
+#define RF_NOTHING 0x7E
+#define RF_EMU 0x80
+#define RF_MASK 0x7F
+
+#define ZONE_FCC 0
+#define ZONE_MKK1 1
+#define ZONE_ETSI 2
+#define ZONE_IC 3
+#define ZONE_SPAIN 4
+#define ZONE_FRANCE 5
+#define ZONE_MKK 6
+#define ZONE_ISRAEL 7
+
+//[20050104] CB_MAXIM2829_CHANNEL_5G_HIGH, CB_UW2452_CHANNEL_5G_HIGH: 40==>41
+#define CB_MAXIM2829_CHANNEL_5G_HIGH 41 //Index41: channel = 100, Tf = 5500MHz, set the (A3:A0=0101) D6=1
+#define CB_UW2452_CHANNEL_5G_HIGH 41 //[20041210] Index41: channel = 100, Tf = 5500MHz, change VCO2->VCO3
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+BOOL IFRFbWriteEmbeded(DWORD_PTR dwIoBase, DWORD dwData);
+BOOL RFbSelectChannel(DWORD_PTR dwIoBase, BYTE byRFType, BYTE byChannel);
+BOOL RFbInit (
+ IN PSDevice pDevice
+ );
+BOOL RFvWriteWakeProgSyn(DWORD_PTR dwIoBase, BYTE byRFType, UINT uChannel);
+BOOL RFbSetPower(PSDevice pDevice, UINT uRATE, UINT uCH);
+BOOL RFbRawSetPower(
+ IN PSDevice pDevice,
+ IN BYTE byPwr,
+ IN UINT uRATE
+ );
+
+VOID
+RFvRSSITodBm(
+ IN PSDevice pDevice,
+ IN BYTE byCurrRSSI,
+ OUT PLONG pldBm
+ );
+
+//{{ RobertYu: 20050104
+BOOL RFbAL7230SelectChannelPostProcess(DWORD_PTR dwIoBase, BYTE byOldChannel, BYTE byNewChannel);
+//}} RobertYu
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __RF_H__
+
+
+
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
new file mode 100644
index 000000000000..c8a4a5533c7e
--- /dev/null
+++ b/drivers/staging/vt6655/rxtx.c
@@ -0,0 +1,3269 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: rxtx.c
+ *
+ * Purpose: handle WMAC/802.3/802.11 rx & tx functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 20, 2003
+ *
+ * Functions:
+ * s_vGenerateTxParameter - Generate tx dma requried parameter.
+ * vGenerateMACHeader - Translate 802.3 to 802.11 header
+ * cbGetFragCount - Caculate fragement number count
+ * csBeacon_xmit - beacon tx function
+ * csMgmt_xmit - management tx function
+ * s_cbFillTxBufHead - fulfill tx dma buffer header
+ * s_uGetDataDuration - get tx data required duration
+ * s_uFillDataHead- fulfill tx data duration header
+ * s_uGetRTSCTSDuration- get rtx/cts requried duration
+ * s_uGetRTSCTSRsvTime- get rts/cts reserved time
+ * s_uGetTxRsvTime- get frame reserved time
+ * s_vFillCTSHead- fulfill CTS ctl header
+ * s_vFillFragParameter- Set fragement ctl parameter.
+ * s_vFillRTSHead- fulfill RTS ctl header
+ * s_vFillTxKey- fulfill tx encrypt key
+ * s_vSWencryption- Software encrypt header
+ * vDMA0_tx_80211- tx 802.11 frame via dma0
+ * vGenerateFIFOHeader- Generate tx FIFO ctl header
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__MICHAEL_H__)
+#include "michael.h"
+#endif
+#if !defined(__TKIP_H__)
+#include "tkip.h"
+#endif
+#if !defined(__TCRC_H__)
+#include "tcrc.h"
+#endif
+#if !defined(__WCTL_H__)
+#include "wctl.h"
+#endif
+#if !defined(__WROUTE_H__)
+#include "wroute.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+#define PLICE_DEBUG
+
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Static Definitions -------------------------*/
+#define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send
+ // packet size >= 256 -> direct send
+
+const WORD wTimeStampOff[2][MAX_RATE] = {
+ {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble
+ {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble
+ };
+
+const WORD wFB_Opt0[2][5] = {
+ {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, // fallback_rate0
+ {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, // fallback_rate1
+ };
+const WORD wFB_Opt1[2][5] = {
+ {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, // fallback_rate0
+ {RATE_6M , RATE_6M, RATE_12M, RATE_12M, RATE_18M}, // fallback_rate1
+ };
+
+
+#define RTSDUR_BB 0
+#define RTSDUR_BA 1
+#define RTSDUR_AA 2
+#define CTSDUR_BA 3
+#define RTSDUR_BA_F0 4
+#define RTSDUR_AA_F0 5
+#define RTSDUR_BA_F1 6
+#define RTSDUR_AA_F1 7
+#define CTSDUR_BA_F0 8
+#define CTSDUR_BA_F1 9
+#define DATADUR_B 10
+#define DATADUR_A 11
+#define DATADUR_A_F0 12
+#define DATADUR_A_F1 13
+
+/*--------------------- Static Functions --------------------------*/
+
+
+
+static
+VOID
+s_vFillTxKey(
+ IN PSDevice pDevice,
+ IN PBYTE pbyBuf,
+ IN PBYTE pbyIVHead,
+ IN PSKeyItem pTransmitKey,
+ IN PBYTE pbyHdrBuf,
+ IN WORD wPayloadLen,
+ OUT PBYTE pMICHDR
+ );
+
+
+
+static
+VOID
+s_vFillRTSHead(
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PVOID pvRTS,
+ IN UINT cbFrameLength,
+ IN BOOL bNeedAck,
+ IN BOOL bDisCRC,
+ IN PSEthernetHeader psEthHeader,
+ IN WORD wCurrentRate,
+ IN BYTE byFBOption
+ );
+
+static
+VOID
+s_vGenerateTxParameter(
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PVOID pTxBufHead,
+ IN PVOID pvRrvTime,
+ IN PVOID pvRTS,
+ IN PVOID pvCTS,
+ IN UINT cbFrameSize,
+ IN BOOL bNeedACK,
+ IN UINT uDMAIdx,
+ IN PSEthernetHeader psEthHeader,
+ IN WORD wCurrentRate
+ );
+
+
+
+static void s_vFillFragParameter(
+ IN PSDevice pDevice,
+ IN PBYTE pbyBuffer,
+ IN UINT uTxType,
+ IN PVOID pvtdCurr,
+ IN WORD wFragType,
+ IN UINT cbReqCount
+ );
+
+
+static
+UINT
+s_cbFillTxBufHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PBYTE pbyTxBufferAddr,
+ IN UINT cbFrameBodySize,
+ IN UINT uDMAIdx,
+ IN PSTxDesc pHeadTD,
+ IN PSEthernetHeader psEthHeader,
+ IN PBYTE pPacket,
+ IN BOOL bNeedEncrypt,
+ IN PSKeyItem pTransmitKey,
+ IN UINT uNodeIndex,
+ OUT PUINT puMACfragNum
+ );
+
+
+static
+UINT
+s_uFillDataHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PVOID pTxDataHead,
+ IN UINT cbFrameLength,
+ IN UINT uDMAIdx,
+ IN BOOL bNeedAck,
+ IN UINT uFragIdx,
+ IN UINT cbLastFragmentSize,
+ IN UINT uMACfragNum,
+ IN BYTE byFBOption,
+ IN WORD wCurrentRate
+ );
+
+
+/*--------------------- Export Variables --------------------------*/
+
+
+
+static
+VOID
+s_vFillTxKey (
+ IN PSDevice pDevice,
+ IN PBYTE pbyBuf,
+ IN PBYTE pbyIVHead,
+ IN PSKeyItem pTransmitKey,
+ IN PBYTE pbyHdrBuf,
+ IN WORD wPayloadLen,
+ OUT PBYTE pMICHDR
+ )
+{
+ PDWORD pdwIV = (PDWORD) pbyIVHead;
+ PDWORD pdwExtIV = (PDWORD) ((PBYTE)pbyIVHead+4);
+ WORD wValue;
+ PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf;
+ DWORD dwRevIVCounter;
+ BYTE byKeyIndex = 0;
+
+
+
+ //Fill TXKEY
+ if (pTransmitKey == NULL)
+ return;
+
+ dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter);
+ *pdwIV = pDevice->dwIVCounter;
+ byKeyIndex = pTransmitKey->dwKeyIndex & 0xf;
+
+ if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
+ if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN ){
+ MEMvCopy(pDevice->abyPRNG, (PBYTE)&(dwRevIVCounter), 3);
+ MEMvCopy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength);
+ } else {
+ MEMvCopy(pbyBuf, (PBYTE)&(dwRevIVCounter), 3);
+ MEMvCopy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength);
+ if(pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) {
+ MEMvCopy(pbyBuf+8, (PBYTE)&(dwRevIVCounter), 3);
+ MEMvCopy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength);
+ }
+ MEMvCopy(pDevice->abyPRNG, pbyBuf, 16);
+ }
+ // Append IV after Mac Header
+ *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111
+ *pdwIV |= (byKeyIndex << 30);
+ *pdwIV = cpu_to_le32(*pdwIV);
+ pDevice->dwIVCounter++;
+ if (pDevice->dwIVCounter > WEP_IV_MASK) {
+ pDevice->dwIVCounter = 0;
+ }
+ } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
+ pTransmitKey->wTSC15_0++;
+ if (pTransmitKey->wTSC15_0 == 0) {
+ pTransmitKey->dwTSC47_16++;
+ }
+ TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
+ pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
+ MEMvCopy(pbyBuf, pDevice->abyPRNG, 16);
+ // Make IV
+ MEMvCopy(pdwIV, pDevice->abyPRNG, 3);
+
+ *(pbyIVHead+3) = (BYTE)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV
+ // Append IV&ExtIV after Mac Header
+ *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV);
+
+ } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
+ pTransmitKey->wTSC15_0++;
+ if (pTransmitKey->wTSC15_0 == 0) {
+ pTransmitKey->dwTSC47_16++;
+ }
+ MEMvCopy(pbyBuf, pTransmitKey->abyKey, 16);
+
+ // Make IV
+ *pdwIV = 0;
+ *(pbyIVHead+3) = (BYTE)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV
+ *pdwIV |= cpu_to_le16((WORD)(pTransmitKey->wTSC15_0));
+ //Append IV&ExtIV after Mac Header
+ *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
+
+ //Fill MICHDR0
+ *pMICHDR = 0x59;
+ *((PBYTE)(pMICHDR+1)) = 0; // TxPriority
+ MEMvCopy(pMICHDR+2, &(pMACHeader->abyAddr2[0]), 6);
+ *((PBYTE)(pMICHDR+8)) = HIBYTE(HIWORD(pTransmitKey->dwTSC47_16));
+ *((PBYTE)(pMICHDR+9)) = LOBYTE(HIWORD(pTransmitKey->dwTSC47_16));
+ *((PBYTE)(pMICHDR+10)) = HIBYTE(LOWORD(pTransmitKey->dwTSC47_16));
+ *((PBYTE)(pMICHDR+11)) = LOBYTE(LOWORD(pTransmitKey->dwTSC47_16));
+ *((PBYTE)(pMICHDR+12)) = HIBYTE(pTransmitKey->wTSC15_0);
+ *((PBYTE)(pMICHDR+13)) = LOBYTE(pTransmitKey->wTSC15_0);
+ *((PBYTE)(pMICHDR+14)) = HIBYTE(wPayloadLen);
+ *((PBYTE)(pMICHDR+15)) = LOBYTE(wPayloadLen);
+
+ //Fill MICHDR1
+ *((PBYTE)(pMICHDR+16)) = 0; // HLEN[15:8]
+ if (pDevice->bLongHeader) {
+ *((PBYTE)(pMICHDR+17)) = 28; // HLEN[7:0]
+ } else {
+ *((PBYTE)(pMICHDR+17)) = 22; // HLEN[7:0]
+ }
+ wValue = cpu_to_le16(pMACHeader->wFrameCtl & 0xC78F);
+ MEMvCopy(pMICHDR+18, (PBYTE)&wValue, 2); // MSKFRACTL
+ MEMvCopy(pMICHDR+20, &(pMACHeader->abyAddr1[0]), 6);
+ MEMvCopy(pMICHDR+26, &(pMACHeader->abyAddr2[0]), 6);
+
+ //Fill MICHDR2
+ MEMvCopy(pMICHDR+32, &(pMACHeader->abyAddr3[0]), 6);
+ wValue = pMACHeader->wSeqCtl;
+ wValue &= 0x000F;
+ wValue = cpu_to_le16(wValue);
+ MEMvCopy(pMICHDR+38, (PBYTE)&wValue, 2); // MSKSEQCTL
+ if (pDevice->bLongHeader) {
+ MEMvCopy(pMICHDR+40, &(pMACHeader->abyAddr4[0]), 6);
+ }
+ }
+}
+
+
+static
+VOID
+s_vSWencryption (
+ IN PSDevice pDevice,
+ IN PSKeyItem pTransmitKey,
+ IN PBYTE pbyPayloadHead,
+ IN WORD wPayloadSize
+ )
+{
+ UINT cbICVlen = 4;
+ DWORD dwICV = 0xFFFFFFFFL;
+ PDWORD pdwICV;
+
+ if (pTransmitKey == NULL)
+ return;
+
+ if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
+ //=======================================================================
+ // Append ICV after payload
+ dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload)
+ pdwICV = (PDWORD)(pbyPayloadHead + wPayloadSize);
+ // finally, we must invert dwCRC to get the correct answer
+ *pdwICV = cpu_to_le32(~dwICV);
+ // RC4 encryption
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength + 3);
+ rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen);
+ //=======================================================================
+ } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
+ //=======================================================================
+ //Append ICV after payload
+ dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload)
+ pdwICV = (PDWORD)(pbyPayloadHead + wPayloadSize);
+ // finally, we must invert dwCRC to get the correct answer
+ *pdwICV = cpu_to_le32(~dwICV);
+ // RC4 encryption
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
+ rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen);
+ //=======================================================================
+ }
+}
+
+
+
+
+/*byPktTyp : PK_TYPE_11A 0
+ PK_TYPE_11B 1
+ PK_TYPE_11GB 2
+ PK_TYPE_11GA 3
+*/
+static
+UINT
+s_uGetTxRsvTime (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN UINT cbFrameLength,
+ IN WORD wRate,
+ IN BOOL bNeedAck
+ )
+{
+ UINT uDataTime, uAckTime;
+
+ uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, cbFrameLength, wRate);
+#ifdef PLICE_DEBUG
+ //printk("s_uGetTxRsvTime is %d\n",uDataTime);
+#endif
+ if (byPktTyp == PK_TYPE_11B) {//llb,CCK mode
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, (WORD)pDevice->byTopCCKBasicRate);
+ } else {//11g 2.4G OFDM mode & 11a 5G OFDM mode
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, (WORD)pDevice->byTopOFDMBasicRate);
+ }
+
+ if (bNeedAck) {
+ return (uDataTime + pDevice->uSIFS + uAckTime);
+ }
+ else {
+ return uDataTime;
+ }
+}
+
+//byFreqType: 0=>5GHZ 1=>2.4GHZ
+static
+UINT
+s_uGetRTSCTSRsvTime (
+ IN PSDevice pDevice,
+ IN BYTE byRTSRsvType,
+ IN BYTE byPktTyp,
+ IN UINT cbFrameLength,
+ IN WORD wCurrentRate
+ )
+{
+ UINT uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime;
+
+ uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0;
+
+
+ uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, cbFrameLength, wCurrentRate);
+ if (byRTSRsvType == 0) { //RTSTxRrvTime_bb
+ uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 20, pDevice->byTopCCKBasicRate);
+ uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, pDevice->byTopCCKBasicRate);
+ }
+ else if (byRTSRsvType == 1){ //RTSTxRrvTime_ba, only in 2.4GHZ
+ uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 20, pDevice->byTopCCKBasicRate);
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, pDevice->byTopCCKBasicRate);
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, pDevice->byTopOFDMBasicRate);
+ }
+ else if (byRTSRsvType == 2) { //RTSTxRrvTime_aa
+ uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 20, pDevice->byTopOFDMBasicRate);
+ uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, pDevice->byTopOFDMBasicRate);
+ }
+ else if (byRTSRsvType == 3) { //CTSTxRrvTime_ba, only in 2.4GHZ
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, pDevice->byTopCCKBasicRate);
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktTyp, 14, pDevice->byTopOFDMBasicRate);
+ uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->uSIFS;
+ return uRrvTime;
+ }
+
+ //RTSRrvTime
+ uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS;
+ return uRrvTime;
+}
+
+//byFreqType 0: 5GHz, 1:2.4Ghz
+static
+UINT
+s_uGetDataDuration (
+ IN PSDevice pDevice,
+ IN BYTE byDurType,
+ IN UINT cbFrameLength,
+ IN BYTE byPktType,
+ IN WORD wRate,
+ IN BOOL bNeedAck,
+ IN UINT uFragIdx,
+ IN UINT cbLastFragmentSize,
+ IN UINT uMACfragNum,
+ IN BYTE byFBOption
+ )
+{
+ BOOL bLastFrag = 0;
+ UINT uAckTime =0, uNextPktTime = 0;
+
+
+
+ if (uFragIdx == (uMACfragNum-1)) {
+ bLastFrag = 1;
+ }
+
+
+ switch (byDurType) {
+
+ case DATADUR_B: //DATADUR_B
+ if (((uMACfragNum == 1)) || (bLastFrag == 1)) {//Non Frag or Last Frag
+ if (bNeedAck) {
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ return (pDevice->uSIFS + uAckTime);
+ } else {
+ return 0;
+ }
+ }
+ else {//First Frag or Mid Frag
+ if (uFragIdx == (uMACfragNum-2)) {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
+ } else {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
+ }
+ if (bNeedAck) {
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ return (pDevice->uSIFS + uAckTime + uNextPktTime);
+ } else {
+ return (pDevice->uSIFS + uNextPktTime);
+ }
+ }
+ break;
+
+ case DATADUR_A: //DATADUR_A
+ if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag
+ if(bNeedAck){
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ return (pDevice->uSIFS + uAckTime);
+ } else {
+ return 0;
+ }
+ }
+ else {//First Frag or Mid Frag
+ if(uFragIdx == (uMACfragNum-2)){
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
+ } else {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
+ }
+ if(bNeedAck){
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ return (pDevice->uSIFS + uAckTime + uNextPktTime);
+ } else {
+ return (pDevice->uSIFS + uNextPktTime);
+ }
+ }
+ break;
+
+ case DATADUR_A_F0: //DATADUR_A_F0
+ if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag
+ if(bNeedAck){
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ return (pDevice->uSIFS + uAckTime);
+ } else {
+ return 0;
+ }
+ }
+ else { //First Frag or Mid Frag
+ if (byFBOption == AUTO_FB_0) {
+ if (wRate < RATE_18M)
+ wRate = RATE_18M;
+ else if (wRate > RATE_54M)
+ wRate = RATE_54M;
+
+ if(uFragIdx == (uMACfragNum-2)){
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ } else {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ }
+ } else { // (byFBOption == AUTO_FB_1)
+ if (wRate < RATE_18M)
+ wRate = RATE_18M;
+ else if (wRate > RATE_54M)
+ wRate = RATE_54M;
+
+ if(uFragIdx == (uMACfragNum-2)){
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ } else {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ }
+ }
+
+ if(bNeedAck){
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ return (pDevice->uSIFS + uAckTime + uNextPktTime);
+ } else {
+ return (pDevice->uSIFS + uNextPktTime);
+ }
+ }
+ break;
+
+ case DATADUR_A_F1: //DATADUR_A_F1
+ if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag
+ if(bNeedAck){
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ return (pDevice->uSIFS + uAckTime);
+ } else {
+ return 0;
+ }
+ }
+ else { //First Frag or Mid Frag
+ if (byFBOption == AUTO_FB_0) {
+ if (wRate < RATE_18M)
+ wRate = RATE_18M;
+ else if (wRate > RATE_54M)
+ wRate = RATE_54M;
+
+ if(uFragIdx == (uMACfragNum-2)){
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ } else {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ }
+
+ } else { // (byFBOption == AUTO_FB_1)
+ if (wRate < RATE_18M)
+ wRate = RATE_18M;
+ else if (wRate > RATE_54M)
+ wRate = RATE_54M;
+
+ if(uFragIdx == (uMACfragNum-2)){
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ } else {
+ uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ }
+ }
+ if(bNeedAck){
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ return (pDevice->uSIFS + uAckTime + uNextPktTime);
+ } else {
+ return (pDevice->uSIFS + uNextPktTime);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ ASSERT(FALSE);
+ return 0;
+}
+
+
+//byFreqType: 0=>5GHZ 1=>2.4GHZ
+static
+UINT
+s_uGetRTSCTSDuration (
+ IN PSDevice pDevice,
+ IN BYTE byDurType,
+ IN UINT cbFrameLength,
+ IN BYTE byPktType,
+ IN WORD wRate,
+ IN BOOL bNeedAck,
+ IN BYTE byFBOption
+ )
+{
+ UINT uCTSTime = 0, uDurTime = 0;
+
+
+ switch (byDurType) {
+
+ case RTSDUR_BB: //RTSDuration_bb
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
+ break;
+
+ case RTSDUR_BA: //RTSDuration_ba
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
+ break;
+
+ case RTSDUR_AA: //RTSDuration_aa
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
+ break;
+
+ case CTSDUR_BA: //CTSDuration_ba
+ uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
+ break;
+
+ case RTSDUR_BA_F0: //RTSDuration_ba_f0
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ }
+ break;
+
+ case RTSDUR_AA_F0: //RTSDuration_aa_f0
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ }
+ break;
+
+ case RTSDUR_BA_F1: //RTSDuration_ba_f1
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ }
+ break;
+
+ case RTSDUR_AA_F1: //RTSDuration_aa_f1
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ }
+ break;
+
+ case CTSDUR_BA_F0: //CTSDuration_ba_f0
+ if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
+ }
+ break;
+
+ case CTSDUR_BA_F1: //CTSDuration_ba_f1
+ if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) {
+ uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return uDurTime;
+
+}
+
+
+
+static
+UINT
+s_uFillDataHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PVOID pTxDataHead,
+ IN UINT cbFrameLength,
+ IN UINT uDMAIdx,
+ IN BOOL bNeedAck,
+ IN UINT uFragIdx,
+ IN UINT cbLastFragmentSize,
+ IN UINT uMACfragNum,
+ IN BYTE byFBOption,
+ IN WORD wCurrentRate
+ )
+{
+ WORD wLen = 0x0000;
+
+ if (pTxDataHead == NULL) {
+ return 0;
+ }
+
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {
+ if (byFBOption == AUTO_FB_NONE) {
+ PSTxDataHead_g pBuf = (PSTxDataHead_g)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a)
+ );
+ pBuf->wTransmitLength_a = cpu_to_le16(wLen);
+ BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ pBuf->wTransmitLength_b = cpu_to_le16(wLen);
+ //Get Duration and TimeStamp
+ pBuf->wDuration_a = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength,
+ byPktTyp, wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption)); //1: 2.4GHz
+ pBuf->wDuration_b = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength,
+ PK_TYPE_11B, pDevice->byTopCCKBasicRate,
+ bNeedAck, uFragIdx, cbLastFragmentSize,
+ uMACfragNum, byFBOption)); //1: 2.4
+
+ pBuf->wTimeStampOff_a = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]);
+ pBuf->wTimeStampOff_b = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]);
+
+ return (pBuf->wDuration_a);
+ } else {
+ // Auto Fallback
+ PSTxDataHead_g_FB pBuf = (PSTxDataHead_g_FB)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a)
+ );
+ pBuf->wTransmitLength_a = cpu_to_le16(wLen);
+ BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ pBuf->wTransmitLength_b = cpu_to_le16(wLen);
+ //Get Duration and TimeStamp
+ pBuf->wDuration_a = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //1: 2.4GHz
+ pBuf->wDuration_b = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B,
+ pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //1: 2.4GHz
+ pBuf->wDuration_a_f0 = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //1: 2.4GHz
+ pBuf->wDuration_a_f1 = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //1: 2.4GHz
+
+ pBuf->wTimeStampOff_a = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]);
+ pBuf->wTimeStampOff_b = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]);
+
+ return (pBuf->wDuration_a);
+ } //if (byFBOption == AUTO_FB_NONE)
+ }
+ else if (byPktTyp == PK_TYPE_11A) {
+ if ((byFBOption != AUTO_FB_NONE)) {
+ // Auto Fallback
+ PSTxDataHead_a_FB pBuf = (PSTxDataHead_a_FB)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ pBuf->wTransmitLength = cpu_to_le16(wLen);
+ //Get Duration and TimeStampOff
+
+ pBuf->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //0: 5GHz
+ pBuf->wDuration_f0 = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //0: 5GHz
+ pBuf->wDuration_f1 = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); //0: 5GHz
+ pBuf->wTimeStampOff = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]);
+ return (pBuf->wDuration);
+ } else {
+ PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ pBuf->wTransmitLength = cpu_to_le16(wLen);
+ //Get Duration and TimeStampOff
+
+ pBuf->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption));
+
+ pBuf->wTimeStampOff = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]);
+ return (pBuf->wDuration);
+ }
+ }
+ else {
+ PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ pBuf->wTransmitLength = cpu_to_le16(wLen);
+ //Get Duration and TimeStampOff
+ pBuf->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktTyp,
+ wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption));
+ pBuf->wTimeStampOff = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]);
+ return (pBuf->wDuration);
+ }
+ return 0;
+}
+
+
+static
+VOID
+s_vFillRTSHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PVOID pvRTS,
+ IN UINT cbFrameLength,
+ IN BOOL bNeedAck,
+ IN BOOL bDisCRC,
+ IN PSEthernetHeader psEthHeader,
+ IN WORD wCurrentRate,
+ IN BYTE byFBOption
+ )
+{
+ UINT uRTSFrameLen = 20;
+ WORD wLen = 0x0000;
+
+ // dummy code, only to avoid compiler warning message
+ UNREFERENCED_PARAMETER(bNeedAck);
+
+ if (pvRTS == NULL)
+ return;
+
+ if (bDisCRC) {
+ // When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame,
+ // in this case we need to decrease its length by 4.
+ uRTSFrameLen -= 4;
+ }
+
+ // Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
+ // Otherwise, we need to modified codes for them.
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {
+ if (byFBOption == AUTO_FB_NONE) {
+ PSRTS_g pBuf = (PSRTS_g)pvRTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ pBuf->wTransmitLength_b = cpu_to_le16(wLen);
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a)
+ );
+ pBuf->wTransmitLength_a = cpu_to_le16(wLen);
+ //Get Duration
+ pBuf->wDuration_bb = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData
+ pBuf->wDuration_aa = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3: 2.4G OFDMData
+ pBuf->wDuration_ba = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
+
+ pBuf->Data.wDurationID = pBuf->wDuration_aa;
+ //Get RTS Frame body
+ pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ }
+ else {
+ PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ pBuf->wTransmitLength_b = cpu_to_le16(wLen);
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a)
+ );
+ pBuf->wTransmitLength_a = cpu_to_le16(wLen);
+
+ //Get Duration
+ pBuf->wDuration_bb = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData
+ pBuf->wDuration_aa = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3:2.4G OFDMData
+ pBuf->wDuration_ba = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDMData
+ pBuf->wRTSDuration_ba_f0 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F0, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //4:wRTSDuration_ba_f0, 1:2.4G, 1:CCKData
+ pBuf->wRTSDuration_aa_f0 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //5:wRTSDuration_aa_f0, 1:2.4G, 1:CCKData
+ pBuf->wRTSDuration_ba_f1 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F1, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //6:wRTSDuration_ba_f1, 1:2.4G, 1:CCKData
+ pBuf->wRTSDuration_aa_f1 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //7:wRTSDuration_aa_f1, 1:2.4G, 1:CCKData
+ pBuf->Data.wDurationID = pBuf->wDuration_aa;
+ //Get RTS Frame body
+ pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
+
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ }
+
+ } // if (byFBOption == AUTO_FB_NONE)
+ }
+ else if (byPktTyp == PK_TYPE_11A) {
+ if (byFBOption == AUTO_FB_NONE) {
+ PSRTS_ab pBuf = (PSRTS_ab)pvRTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ pBuf->wTransmitLength = cpu_to_le16(wLen);
+ //Get Duration
+ pBuf->wDuration = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData
+ pBuf->Data.wDurationID = pBuf->wDuration;
+ //Get RTS Frame body
+ pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
+
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ }
+
+ }
+ else {
+ PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ pBuf->wTransmitLength = cpu_to_le16(wLen);
+ //Get Duration
+ pBuf->wDuration = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData
+ pBuf->wRTSDuration_f0 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //5:RTSDuration_aa_f0, 0:5G, 0: 5G OFDMData
+ pBuf->wRTSDuration_f1 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //7:RTSDuration_aa_f1, 0:5G, 0:
+ pBuf->Data.wDurationID = pBuf->wDuration;
+ //Get RTS Frame body
+ pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
+
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ }
+ }
+ else if (byPktTyp == PK_TYPE_11B) {
+ PSRTS_ab pBuf = (PSRTS_ab)pvRTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ pBuf->wTransmitLength = cpu_to_le16(wLen);
+ //Get Duration
+ pBuf->wDuration = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData
+ pBuf->Data.wDurationID = pBuf->wDuration;
+ //Get RTS Frame body
+ pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
+
+
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ }
+}
+
+static
+VOID
+s_vFillCTSHead (
+ IN PSDevice pDevice,
+ IN UINT uDMAIdx,
+ IN BYTE byPktTyp,
+ IN PVOID pvCTS,
+ IN UINT cbFrameLength,
+ IN BOOL bNeedAck,
+ IN BOOL bDisCRC,
+ IN WORD wCurrentRate,
+ IN BYTE byFBOption
+ )
+{
+ UINT uCTSFrameLen = 14;
+ WORD wLen = 0x0000;
+
+ if (pvCTS == NULL) {
+ return;
+ }
+
+ if (bDisCRC) {
+ // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame,
+ // in this case we need to decrease its length by 4.
+ uCTSFrameLen -= 4;
+ }
+
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {
+ if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) {
+ // Auto Fall back
+ PSCTS_FB pBuf = (PSCTS_FB)pvCTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+
+
+ pBuf->wTransmitLength_b = cpu_to_le16(wLen);
+
+ pBuf->wDuration_ba = (WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
+ pBuf->wDuration_ba += pDevice->wCTSDuration;
+ pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba);
+ //Get CTSDuration_ba_f0
+ pBuf->wCTSDuration_ba_f0 = (WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F0, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption); //8:CTSDuration_ba_f0, 1:2.4G, 2,3:2.4G OFDM Data
+ pBuf->wCTSDuration_ba_f0 += pDevice->wCTSDuration;
+ pBuf->wCTSDuration_ba_f0 = cpu_to_le16(pBuf->wCTSDuration_ba_f0);
+ //Get CTSDuration_ba_f1
+ pBuf->wCTSDuration_ba_f1 = (WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption); //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data
+ pBuf->wCTSDuration_ba_f1 += pDevice->wCTSDuration;
+ pBuf->wCTSDuration_ba_f1 = cpu_to_le16(pBuf->wCTSDuration_ba_f1);
+ //Get CTS Frame body
+ pBuf->Data.wDurationID = pBuf->wDuration_ba;
+ pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4
+ pBuf->Data.wReserved = 0x0000;
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN);
+
+ } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
+ PSCTS pBuf = (PSCTS)pvCTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ pBuf->wTransmitLength_b = cpu_to_le16(wLen);
+ //Get CTSDuration_ba
+ pBuf->wDuration_ba = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktTyp, wCurrentRate, bNeedAck, byFBOption)); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
+ pBuf->wDuration_ba += pDevice->wCTSDuration;
+ pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba);
+
+ //Get CTS Frame body
+ pBuf->Data.wDurationID = pBuf->wDuration_ba;
+ pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4
+ pBuf->Data.wReserved = 0x0000;
+ MEMvCopy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN);
+ }
+ }
+}
+
+
+
+
+
+
+/*+
+ *
+ * Description:
+ * Generate FIFO control for MAC & Baseband controller
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to adpater
+ * pTxDataHead - Transmit Data Buffer
+ * pTxBufHead - pTxBufHead
+ * pvRrvTime - pvRrvTime
+ * pvRTS - RTS Buffer
+ * pCTS - CTS Buffer
+ * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS)
+ * bNeedACK - If need ACK
+ * uDescIdx - Desc Index
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+// UINT cbFrameSize,//Hdr+Payload+FCS
+static
+VOID
+s_vGenerateTxParameter (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PVOID pTxBufHead,
+ IN PVOID pvRrvTime,
+ IN PVOID pvRTS,
+ IN PVOID pvCTS,
+ IN UINT cbFrameSize,
+ IN BOOL bNeedACK,
+ IN UINT uDMAIdx,
+ IN PSEthernetHeader psEthHeader,
+ IN WORD wCurrentRate
+ )
+{
+ UINT cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24
+ WORD wFifoCtl;
+ BOOL bDisCRC = FALSE;
+ BYTE byFBOption = AUTO_FB_NONE;
+// WORD wCurrentRate = pDevice->wCurrentRate;
+
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n");
+ PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead;
+ pFifoHead->wReserved = wCurrentRate;
+ wFifoCtl = pFifoHead->wFIFOCtl;
+
+ if (wFifoCtl & FIFOCTL_CRCDIS) {
+ bDisCRC = TRUE;
+ }
+
+ if (wFifoCtl & FIFOCTL_AUTO_FB_0) {
+ byFBOption = AUTO_FB_0;
+ }
+ else if (wFifoCtl & FIFOCTL_AUTO_FB_1) {
+ byFBOption = AUTO_FB_1;
+ }
+
+ if (pDevice->bLongHeader)
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
+
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {
+
+ if (pvRTS != NULL) { //RTS_need
+ //Fill RsvTime
+ if (pvRrvTime) {
+ PSRrvTime_gRTS pBuf = (PSRrvTime_gRTS)pvRrvTime;
+ pBuf->wRTSTxRrvTime_aa = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 2, byPktTyp, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 1:2.4GHz
+ pBuf->wRTSTxRrvTime_ba = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 1, byPktTyp, cbFrameSize, wCurrentRate));//1:RTSTxRrvTime_ba, 1:2.4GHz
+ pBuf->wRTSTxRrvTime_bb = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 0, byPktTyp, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz
+ pBuf->wTxRrvTime_a = cpu_to_le16((WORD) s_uGetTxRsvTime(pDevice, byPktTyp, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM
+ pBuf->wTxRrvTime_b = cpu_to_le16((WORD) s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK
+ }
+ //Fill RTS
+ s_vFillRTSHead(pDevice, byPktTyp, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
+ }
+ else {//RTS_needless, PCF mode
+
+ //Fill RsvTime
+ if (pvRrvTime) {
+ PSRrvTime_gCTS pBuf = (PSRrvTime_gCTS)pvRrvTime;
+ pBuf->wTxRrvTime_a = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, byPktTyp, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM
+ pBuf->wTxRrvTime_b = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK
+ pBuf->wCTSTxRrvTime_ba = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 3, byPktTyp, cbFrameSize, wCurrentRate));//3:CTSTxRrvTime_Ba, 1:2.4GHz
+ }
+
+
+ //Fill CTS
+ s_vFillCTSHead(pDevice, uDMAIdx, byPktTyp, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption);
+ }
+ }
+ else if (byPktTyp == PK_TYPE_11A) {
+
+ if (pvRTS != NULL) {//RTS_need, non PCF mode
+ //Fill RsvTime
+ if (pvRrvTime) {
+ PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime;
+ pBuf->wRTSTxRrvTime = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 2, byPktTyp, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 0:5GHz
+ pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, byPktTyp, cbFrameSize, wCurrentRate, bNeedACK));//0:OFDM
+ }
+ //Fill RTS
+ s_vFillRTSHead(pDevice, byPktTyp, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
+ }
+ else if (pvRTS == NULL) {//RTS_needless, non PCF mode
+ //Fill RsvTime
+ if (pvRrvTime) {
+ PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime;
+ pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK)); //0:OFDM
+ }
+ }
+ }
+ else if (byPktTyp == PK_TYPE_11B) {
+
+ if ((pvRTS != NULL)) {//RTS_need, non PCF mode
+ //Fill RsvTime
+ if (pvRrvTime) {
+ PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime;
+ pBuf->wRTSTxRrvTime = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 0, byPktTyp, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz
+ pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));//1:CCK
+ }
+ //Fill RTS
+ s_vFillRTSHead(pDevice, byPktTyp, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
+ }
+ else { //RTS_needless, non PCF mode
+ //Fill RsvTime
+ if (pvRrvTime) {
+ PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime;
+ pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK)); //1:CCK
+ }
+ }
+ }
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n");
+}
+/*
+ PBYTE pbyBuffer,//point to pTxBufHead
+ WORD wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last
+ UINT cbFragmentSize,//Hdr+payoad+FCS
+*/
+static
+VOID
+s_vFillFragParameter(
+ IN PSDevice pDevice,
+ IN PBYTE pbyBuffer,
+ IN UINT uTxType,
+ IN PVOID pvtdCurr,
+ IN WORD wFragType,
+ IN UINT cbReqCount
+ )
+{
+ PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer;
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vFillFragParameter...\n");
+
+ if (uTxType == TYPE_SYNCDMA) {
+ //PSTxSyncDesc ptdCurr = (PSTxSyncDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx);
+ PSTxSyncDesc ptdCurr = (PSTxSyncDesc)pvtdCurr;
+
+ //Set FIFOCtl & TimeStamp in TxSyncDesc
+ ptdCurr->m_wFIFOCtl = pTxBufHead->wFIFOCtl;
+ ptdCurr->m_wTimeStamp = pTxBufHead->wTimeStamp;
+ //Set TSR1 & ReqCount in TxDescHead
+ ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((WORD)(cbReqCount));
+ if (wFragType == FRAGCTL_ENDFRAG) { //Last Fragmentation
+ ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
+ }
+ else {
+ ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP);
+ }
+ }
+ else {
+ //PSTxDesc ptdCurr = (PSTxDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx);
+ PSTxDesc ptdCurr = (PSTxDesc)pvtdCurr;
+ //Set TSR1 & ReqCount in TxDescHead
+ ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((WORD)(cbReqCount));
+ if (wFragType == FRAGCTL_ENDFRAG) { //Last Fragmentation
+ ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
+ }
+ else {
+ ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP);
+ }
+ }
+
+ pTxBufHead->wFragCtl |= (WORD)wFragType;//0x0001; //0000 0000 0000 0001
+
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vFillFragParameter END\n");
+}
+
+static
+UINT
+s_cbFillTxBufHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PBYTE pbyTxBufferAddr,
+ IN UINT cbFrameBodySize,
+ IN UINT uDMAIdx,
+ IN PSTxDesc pHeadTD,
+ IN PSEthernetHeader psEthHeader,
+ IN PBYTE pPacket,
+ IN BOOL bNeedEncrypt,
+ IN PSKeyItem pTransmitKey,
+ IN UINT uNodeIndex,
+ OUT PUINT puMACfragNum
+ )
+{
+ UINT cbMACHdLen;
+ UINT cbFrameSize;
+ UINT cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
+ UINT cbFragPayloadSize;
+ UINT cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
+ UINT cbLastFragPayloadSize;
+ UINT uFragIdx;
+ PBYTE pbyPayloadHead;
+ PBYTE pbyIVHead;
+ PBYTE pbyMacHdr;
+ WORD wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last
+ UINT uDuration;
+ PBYTE pbyBuffer;
+// UINT uKeyEntryIdx = NUM_KEY_ENTRY+1;
+// BYTE byKeySel = 0xFF;
+ UINT cbIVlen = 0;
+ UINT cbICVlen = 0;
+ UINT cbMIClen = 0;
+ UINT cbFCSlen = 4;
+ UINT cb802_1_H_len = 0;
+ UINT uLength = 0;
+ UINT uTmpLen = 0;
+// BYTE abyTmp[8];
+// DWORD dwCRC;
+ UINT cbMICHDR = 0;
+ DWORD dwMICKey0, dwMICKey1;
+ DWORD dwMIC_Priority;
+ PDWORD pdwMIC_L;
+ PDWORD pdwMIC_R;
+ DWORD dwSafeMIC_L, dwSafeMIC_R; //Fix "Last Frag Size" < "MIC length".
+ BOOL bMIC2Frag = FALSE;
+ UINT uMICFragLen = 0;
+ UINT uMACfragNum = 1;
+ UINT uPadding = 0;
+ UINT cbReqCount = 0;
+
+ BOOL bNeedACK;
+ BOOL bRTS;
+ BOOL bIsAdhoc;
+ PBYTE pbyType;
+ PSTxDesc ptdCurr;
+ PSTxBufHead psTxBufHd = (PSTxBufHead) pbyTxBufferAddr;
+// UINT tmpDescIdx;
+ UINT cbHeaderLength = 0;
+ PVOID pvRrvTime;
+ PSMICHDRHead pMICHDR;
+ PVOID pvRTS;
+ PVOID pvCTS;
+ PVOID pvTxDataHd;
+ WORD wTxBufSize; // FFinfo size
+ UINT uTotalCopyLength = 0;
+ BYTE byFBOption = AUTO_FB_NONE;
+ BOOL bIsWEP256 = FALSE;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+
+ pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
+
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_cbFillTxBufHead...\n");
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+
+ if (IS_MULTICAST_ADDRESS(&(psEthHeader->abyDstAddr[0])) ||
+ IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) {
+ bNeedACK = FALSE;
+ }
+ else {
+ bNeedACK = TRUE;
+ }
+ bIsAdhoc = TRUE;
+ }
+ else {
+ // MSDUs in Infra mode always need ACK
+ bNeedACK = TRUE;
+ bIsAdhoc = FALSE;
+ }
+
+ if (pDevice->bLongHeader)
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
+ else
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN;
+
+
+ if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL)) {
+ if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
+ cbIVlen = 4;
+ cbICVlen = 4;
+ if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) {
+ bIsWEP256 = TRUE;
+ }
+ }
+ if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
+ cbIVlen = 8;//IV+ExtIV
+ cbMIClen = 8;
+ cbICVlen = 4;
+ }
+ if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
+ cbIVlen = 8;//RSN Header
+ cbICVlen = 8;//MIC
+ cbMICHDR = sizeof(SMICHDRHead);
+ }
+ if (pDevice->byLocalID > REV_ID_VT3253_A1) {
+ //MAC Header should be padding 0 to DW alignment.
+ uPadding = 4 - (cbMACHdLen%4);
+ uPadding %= 4;
+ }
+ }
+
+
+ cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen;
+
+ if ((bNeedACK == FALSE) ||
+ (cbFrameSize < pDevice->wRTSThreshold) ||
+ ((cbFrameSize >= pDevice->wFragmentationThreshold) && (pDevice->wFragmentationThreshold <= pDevice->wRTSThreshold))
+ ) {
+ bRTS = FALSE;
+ }
+ else {
+ bRTS = TRUE;
+ psTxBufHd->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY);
+ }
+ //
+ // Use for AUTO FALL BACK
+ //
+ if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0) {
+ byFBOption = AUTO_FB_0;
+ }
+ else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1) {
+ byFBOption = AUTO_FB_1;
+ }
+
+ //////////////////////////////////////////////////////
+ //Set RrvTime/RTS/CTS Buffer
+ wTxBufSize = sizeof(STxBufHead);
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {//802.11g packet
+
+ if (byFBOption == AUTO_FB_NONE) {
+ if (bRTS == TRUE) {//RTS_need
+ pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS));
+ pvRTS = (PSRTS_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR);
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g));
+ cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g) + sizeof(STxDataHead_g);
+ }
+ else { //RTS_needless
+ pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS));
+ pvRTS = NULL;
+ pvCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR);
+ pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS));
+ cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS) + sizeof(STxDataHead_g);
+ }
+ } else {
+ // Auto Fall Back
+ if (bRTS == TRUE) {//RTS_need
+ pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS));
+ pvRTS = (PSRTS_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR);
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB));
+ cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB) + sizeof(STxDataHead_g_FB);
+ }
+ else { //RTS_needless
+ pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS));
+ pvRTS = NULL;
+ pvCTS = (PSCTS_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR);
+ pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS_FB));
+ cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS_FB) + sizeof(STxDataHead_g_FB);
+ }
+ } // Auto Fall Back
+ }
+ else {//802.11a/b packet
+
+ if (byFBOption == AUTO_FB_NONE) {
+ if (bRTS == TRUE) {
+ pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab));
+ pvRTS = (PSRTS_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR);
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab));
+ cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab) + sizeof(STxDataHead_ab);
+ }
+ else { //RTS_needless, need MICHDR
+ pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab));
+ pvRTS = NULL;
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR);
+ cbHeaderLength = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab);
+ }
+ } else {
+ // Auto Fall Back
+ if (bRTS == TRUE) {//RTS_need
+ pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab));
+ pvRTS = (PSRTS_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR);
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB));
+ cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB) + sizeof(STxDataHead_a_FB);
+ }
+ else { //RTS_needless
+ pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab));
+ pvRTS = NULL;
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR);
+ cbHeaderLength = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_a_FB);
+ }
+ } // Auto Fall Back
+ }
+ ZERO_MEMORY((PVOID)(pbyTxBufferAddr + wTxBufSize), (cbHeaderLength - wTxBufSize));
+
+//////////////////////////////////////////////////////////////////
+ if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
+ if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+ dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]);
+ dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]);
+ }
+ else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) {
+ dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]);
+ dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]);
+ }
+ else {
+ dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[24]);
+ dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[28]);
+ }
+ // DO Software Michael
+ MIC_vInit(dwMICKey0, dwMICKey1);
+ MIC_vAppend((PBYTE)&(psEthHeader->abyDstAddr[0]), 12);
+ dwMIC_Priority = 0;
+ MIC_vAppend((PBYTE)&dwMIC_Priority, 4);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1);
+ }
+
+///////////////////////////////////////////////////////////////////
+
+ pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderLength);
+ pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen);
+ pbyIVHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding);
+
+ if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == TRUE) && (bIsWEP256 == FALSE)) {
+ // Fragmentation
+ // FragThreshold = Fragment size(Hdr+(IV)+fragment payload+(MIC)+(ICV)+FCS)
+ cbFragmentSize = pDevice->wFragmentationThreshold;
+ cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen;
+ //FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS)))
+ uMACfragNum = (WORD) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize);
+ cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize;
+ if (cbLastFragPayloadSize == 0) {
+ cbLastFragPayloadSize = cbFragPayloadSize;
+ } else {
+ uMACfragNum++;
+ }
+ //[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS]
+ cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen;
+
+ for (uFragIdx = 0; uFragIdx < uMACfragNum; uFragIdx ++) {
+ if (uFragIdx == 0) {
+ //=========================
+ // Start Fragmentation
+ //=========================
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Start Fragmentation...\n");
+ wFragType = FRAGCTL_STAFRAG;
+
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktTyp, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+ cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktTyp, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK,
+ uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate);
+ // Generate TX MAC Header
+ vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncrypt,
+ wFragType, uDMAIdx, uFragIdx);
+
+ if (bNeedEncrypt == TRUE) {
+ //Fill TXKEY
+ s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
+ pbyMacHdr, (WORD)cbFragPayloadSize, (PBYTE)pMICHDR);
+ //Fill IV(ExtIV,RSNHDR)
+ if (pDevice->bEnableHostWEP) {
+ pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
+ pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
+ }
+ }
+
+
+ // 802.1H
+ if (ntohs(psEthHeader->wType) > MAX_DATA_LEN) {
+ if ((psEthHeader->wType == TYPE_PKT_IPX) ||
+ (psEthHeader->wType == cpu_to_le16(0xF380))) {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6);
+ }
+ else {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6);
+ }
+ pbyType = (PBYTE) (pbyPayloadHead + 6);
+ MEMvCopy(pbyType, &(psEthHeader->wType), sizeof(WORD));
+ cb802_1_H_len = 8;
+ }
+
+ cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize;
+ //---------------------------
+ // S/W or H/W Encryption
+ //---------------------------
+ //Fill MICHDR
+ //if (pDevice->bAES) {
+ // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize);
+ //}
+ //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (PVOID)psTxBufHd, byKeySel,
+ // pbyPayloadHead, (WORD)cbFragPayloadSize, uDMAIdx);
+
+
+
+ //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr;
+ pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf;
+
+ uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
+ //copy TxBufferHeader + MacHeader to desc
+ MEMvCopy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+
+ // Copy the Packet into a tx Buffer
+ MEMvCopy((pbyBuffer + uLength), (pPacket + 14), (cbFragPayloadSize - cb802_1_H_len));
+
+
+ uTotalCopyLength += cbFragPayloadSize - cb802_1_H_len;
+
+ if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Start MIC: %d\n", cbFragPayloadSize);
+ MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFragPayloadSize);
+
+ }
+
+ //---------------------------
+ // S/W Encryption
+ //---------------------------
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
+ if (bNeedEncrypt) {
+ s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), (WORD)cbFragPayloadSize);
+ cbReqCount += cbICVlen;
+ }
+ }
+
+ ptdCurr = (PSTxDesc)pHeadTD;
+ //--------------------
+ //1.Set TSR1 & ReqCount in TxDescHead
+ //2.Set FragCtl in TxBufferHead
+ //3.Set Frame Control
+ //4.Set Sequence Control
+ //5.Get S/W generate FCS
+ //--------------------
+ s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (PVOID)ptdCurr, wFragType, cbReqCount);
+
+ ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
+ ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
+ ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
+ ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
+ pDevice->iTDUsed[uDMAIdx]++;
+ pHeadTD = ptdCurr->next;
+ }
+ else if (uFragIdx == (uMACfragNum-1)) {
+ //=========================
+ // Last Fragmentation
+ //=========================
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Last Fragmentation...\n");
+ //tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx];
+
+ wFragType = FRAGCTL_ENDFRAG;
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktTyp, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+ cbLastFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktTyp, pvTxDataHd, cbLastFragmentSize, uDMAIdx, bNeedACK,
+ uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate);
+
+ // Generate TX MAC Header
+ vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncrypt,
+ wFragType, uDMAIdx, uFragIdx);
+
+ if (bNeedEncrypt == TRUE) {
+ //Fill TXKEY
+ s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
+ pbyMacHdr, (WORD)cbLastFragPayloadSize, (PBYTE)pMICHDR);
+
+ if (pDevice->bEnableHostWEP) {
+ pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
+ pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
+ }
+
+ }
+
+
+ cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbLastFragPayloadSize;
+ //---------------------------
+ // S/W or H/W Encryption
+ //---------------------------
+
+
+
+ pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf;
+ //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr;
+
+ uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
+
+ //copy TxBufferHeader + MacHeader to desc
+ MEMvCopy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+
+ // Copy the Packet into a tx Buffer
+ if (bMIC2Frag == FALSE) {
+
+ MEMvCopy((pbyBuffer + uLength),
+ (pPacket + 14 + uTotalCopyLength),
+ (cbLastFragPayloadSize - cbMIClen)
+ );
+ //TODO check uTmpLen !
+ uTmpLen = cbLastFragPayloadSize - cbMIClen;
+
+ }
+ if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LAST: uMICFragLen:%d, cbLastFragPayloadSize:%d, uTmpLen:%d\n",
+ uMICFragLen, cbLastFragPayloadSize, uTmpLen);
+
+ if (bMIC2Frag == FALSE) {
+ if (uTmpLen != 0)
+ MIC_vAppend((pbyBuffer + uLength), uTmpLen);
+ pdwMIC_L = (PDWORD)(pbyBuffer + uLength + uTmpLen);
+ pdwMIC_R = (PDWORD)(pbyBuffer + uLength + uTmpLen + 4);
+ MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Last MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R);
+ } else {
+ if (uMICFragLen >= 4) {
+ MEMvCopy((pbyBuffer + uLength), ((PBYTE)&dwSafeMIC_R + (uMICFragLen - 4)),
+ (cbMIClen - uMICFragLen));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LAST: uMICFragLen >= 4: %X, %d\n",
+ *(PBYTE)((PBYTE)&dwSafeMIC_R + (uMICFragLen - 4)),
+ (cbMIClen - uMICFragLen));
+
+ } else {
+ MEMvCopy((pbyBuffer + uLength), ((PBYTE)&dwSafeMIC_L + uMICFragLen),
+ (4 - uMICFragLen));
+ MEMvCopy((pbyBuffer + uLength + (4 - uMICFragLen)), &dwSafeMIC_R, 4);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LAST: uMICFragLen < 4: %X, %d\n",
+ *(PBYTE)((PBYTE)&dwSafeMIC_R + uMICFragLen - 4),
+ (cbMIClen - uMICFragLen));
+ }
+ /*
+ for (ii = 0; ii < cbLastFragPayloadSize + 8 + 24; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength) + ii - 8 - 24)));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n\n");
+ */
+ }
+ MIC_vUnInit();
+ } else {
+ ASSERT(uTmpLen == (cbLastFragPayloadSize - cbMIClen));
+ }
+
+
+ //---------------------------
+ // S/W Encryption
+ //---------------------------
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
+ if (bNeedEncrypt) {
+ s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (WORD)cbLastFragPayloadSize);
+ cbReqCount += cbICVlen;
+ }
+ }
+
+ ptdCurr = (PSTxDesc)pHeadTD;
+
+ //--------------------
+ //1.Set TSR1 & ReqCount in TxDescHead
+ //2.Set FragCtl in TxBufferHead
+ //3.Set Frame Control
+ //4.Set Sequence Control
+ //5.Get S/W generate FCS
+ //--------------------
+
+
+ s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (PVOID)ptdCurr, wFragType, cbReqCount);
+
+ ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
+ ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
+ ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
+ ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
+ pDevice->iTDUsed[uDMAIdx]++;
+ pHeadTD = ptdCurr->next;
+
+ }
+ else {
+ //=========================
+ // Middle Fragmentation
+ //=========================
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Middle Fragmentation...\n");
+ //tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx];
+
+ wFragType = FRAGCTL_MIDFRAG;
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktTyp, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+ cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktTyp, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK,
+ uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate);
+
+ // Generate TX MAC Header
+ vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncrypt,
+ wFragType, uDMAIdx, uFragIdx);
+
+
+ if (bNeedEncrypt == TRUE) {
+ //Fill TXKEY
+ s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
+ pbyMacHdr, (WORD)cbFragPayloadSize, (PBYTE)pMICHDR);
+
+ if (pDevice->bEnableHostWEP) {
+ pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
+ pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
+ }
+ }
+
+ cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize;
+ //---------------------------
+ // S/W or H/W Encryption
+ //---------------------------
+ //Fill MICHDR
+ //if (pDevice->bAES) {
+ // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize);
+ //}
+ //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (PVOID)psTxBufHd, byKeySel,
+ // pbyPayloadHead, (WORD)cbFragPayloadSize, uDMAIdx);
+
+
+ pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf;
+ //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr;
+
+
+ uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
+
+ //copy TxBufferHeader + MacHeader to desc
+ MEMvCopy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+
+ // Copy the Packet into a tx Buffer
+ MEMvCopy((pbyBuffer + uLength),
+ (pPacket + 14 + uTotalCopyLength),
+ cbFragPayloadSize
+ );
+ uTmpLen = cbFragPayloadSize;
+
+ uTotalCopyLength += uTmpLen;
+
+ if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
+
+ MIC_vAppend((pbyBuffer + uLength), uTmpLen);
+
+ if (uTmpLen < cbFragPayloadSize) {
+ bMIC2Frag = TRUE;
+ uMICFragLen = cbFragPayloadSize - uTmpLen;
+ ASSERT(uMICFragLen < cbMIClen);
+
+ pdwMIC_L = (PDWORD)(pbyBuffer + uLength + uTmpLen);
+ pdwMIC_R = (PDWORD)(pbyBuffer + uLength + uTmpLen + 4);
+ MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
+ dwSafeMIC_L = *pdwMIC_L;
+ dwSafeMIC_R = *pdwMIC_R;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d\n",
+ uMICFragLen, cbFragPayloadSize, uTmpLen);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Fill MIC in Middle frag [%d]\n", uMICFragLen);
+ /*
+ for (ii = 0; ii < uMICFragLen; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength + uTmpLen) + ii)));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+ */
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R);
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Middle frag len: %d\n", uTmpLen);
+ /*
+ for (ii = 0; ii < uTmpLen; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength) + ii)));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n\n");
+ */
+
+ } else {
+ ASSERT(uTmpLen == (cbFragPayloadSize));
+ }
+
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
+ if (bNeedEncrypt) {
+ s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (WORD)cbFragPayloadSize);
+ cbReqCount += cbICVlen;
+ }
+ }
+
+ ptdCurr = (PSTxDesc)pHeadTD;
+
+ //--------------------
+ //1.Set TSR1 & ReqCount in TxDescHead
+ //2.Set FragCtl in TxBufferHead
+ //3.Set Frame Control
+ //4.Set Sequence Control
+ //5.Get S/W generate FCS
+ //--------------------
+
+ s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (PVOID)ptdCurr, wFragType, cbReqCount);
+
+ ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
+ ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
+ ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
+ ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
+ pDevice->iTDUsed[uDMAIdx]++;
+ pHeadTD = ptdCurr->next;
+ }
+ } // for (uMACfragNum)
+ }
+ else {
+ //=========================
+ // No Fragmentation
+ //=========================
+ //DEVICE_PRTGRP03(("No Fragmentation...\n"));
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n");
+ wFragType = FRAGCTL_NONFRAG;
+
+ //Set FragCtl in TxBufferHead
+ psTxBufHd->wFragCtl |= (WORD)wFragType;
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktTyp, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+ cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktTyp, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK,
+ 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate);
+
+ // Generate TX MAC Header
+ vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncrypt,
+ wFragType, uDMAIdx, 0);
+
+ if (bNeedEncrypt == TRUE) {
+ //Fill TXKEY
+ s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey,
+ pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR);
+
+ if (pDevice->bEnableHostWEP) {
+ pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
+ pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
+ }
+ }
+
+ // 802.1H
+ if (ntohs(psEthHeader->wType) > MAX_DATA_LEN) {
+ if ((psEthHeader->wType == TYPE_PKT_IPX) ||
+ (psEthHeader->wType == cpu_to_le16(0xF380))) {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6);
+ }
+ else {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6);
+ }
+ pbyType = (PBYTE) (pbyPayloadHead + 6);
+ MEMvCopy(pbyType, &(psEthHeader->wType), sizeof(WORD));
+ cb802_1_H_len = 8;
+ }
+
+ cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen);
+ //---------------------------
+ // S/W or H/W Encryption
+ //---------------------------
+ //Fill MICHDR
+ //if (pDevice->bAES) {
+ // DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Fill MICHDR...\n");
+ // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFrameBodySize);
+ //}
+
+ pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf;
+ //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr;
+
+ uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
+
+ //copy TxBufferHeader + MacHeader to desc
+ MEMvCopy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+
+ // Copy the Packet into a tx Buffer
+ MEMvCopy((pbyBuffer + uLength),
+ (pPacket + 14),
+ cbFrameBodySize - cb802_1_H_len
+ );
+
+ if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)){
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Length:%d, %d\n", cbFrameBodySize - cb802_1_H_len, uLength);
+ /*
+ for (ii = 0; ii < (cbFrameBodySize - cb802_1_H_len); ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength) + ii)));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+ */
+
+ MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFrameBodySize);
+
+ pdwMIC_L = (PDWORD)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize);
+ pdwMIC_R = (PDWORD)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4);
+
+ MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
+ MIC_vUnInit();
+
+
+ if (pDevice->bTxMICFail == TRUE) {
+ *pdwMIC_L = 0;
+ *pdwMIC_R = 0;
+ pDevice->bTxMICFail = FALSE;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lx, %lx\n", *pdwMIC_L, *pdwMIC_R);
+/*
+ for (ii = 0; ii < 8; ii++) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(((PBYTE)(pdwMIC_L) + ii)));
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+*/
+
+ }
+
+
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1)){
+ if (bNeedEncrypt) {
+ s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len),
+ (WORD)(cbFrameBodySize + cbMIClen));
+ cbReqCount += cbICVlen;
+ }
+ }
+
+
+ ptdCurr = (PSTxDesc)pHeadTD;
+
+ ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
+ ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
+ ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma;
+ ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma);
+ //Set TSR1 & ReqCount in TxDescHead
+ ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
+ ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((WORD)(cbReqCount));
+
+ pDevice->iTDUsed[uDMAIdx]++;
+
+
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" ptdCurr->m_dwReserved0[%d] ptdCurr->m_dwReserved1[%d].\n", ptdCurr->pTDInfo->dwReqCount, ptdCurr->pTDInfo->dwHeaderLength);
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cbHeaderLength[%d]\n", cbHeaderLength);
+
+ }
+ *puMACfragNum = uMACfragNum;
+ //DEVICE_PRTGRP03(("s_cbFillTxBufHead END\n"));
+ return cbHeaderLength;
+}
+
+
+VOID
+vGenerateFIFOHeader (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PBYTE pbyTxBufferAddr,
+ IN BOOL bNeedEncrypt,
+ IN UINT cbPayloadSize,
+ IN UINT uDMAIdx,
+ IN PSTxDesc pHeadTD,
+ IN PSEthernetHeader psEthHeader,
+ IN PBYTE pPacket,
+ IN PSKeyItem pTransmitKey,
+ IN UINT uNodeIndex,
+ OUT PUINT puMACfragNum,
+ OUT PUINT pcbHeaderSize
+ )
+{
+ UINT wTxBufSize; // FFinfo size
+ BOOL bNeedACK;
+ BOOL bIsAdhoc;
+ WORD cbMacHdLen;
+ PSTxBufHead pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
+
+ wTxBufSize = sizeof(STxBufHead);
+
+ ZERO_MEMORY(pTxBufHead, wTxBufSize);
+ //Set FIFOCTL_NEEDACK
+
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ if (IS_MULTICAST_ADDRESS(&(psEthHeader->abyDstAddr[0])) ||
+ IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) {
+ bNeedACK = FALSE;
+ pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK);
+ }
+ else {
+ bNeedACK = TRUE;
+ pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
+ }
+ bIsAdhoc = TRUE;
+ }
+ else {
+ // MSDUs in Infra mode always need ACK
+ bNeedACK = TRUE;
+ pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
+ bIsAdhoc = FALSE;
+ }
+
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
+ pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us);
+
+ //Set FIFOCTL_LHEAD
+ if (pDevice->bLongHeader)
+ pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD;
+
+ //Set FIFOCTL_GENINT
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_GENINT;
+
+
+ //Set FIFOCTL_ISDMA0
+ if (TYPE_TXDMA0 == uDMAIdx) {
+ pTxBufHead->wFIFOCtl |= FIFOCTL_ISDMA0;
+ }
+
+ //Set FRAGCTL_MACHDCNT
+ if (pDevice->bLongHeader) {
+ cbMacHdLen = WLAN_HDR_ADDR3_LEN + 6;
+ } else {
+ cbMacHdLen = WLAN_HDR_ADDR3_LEN;
+ }
+ pTxBufHead->wFragCtl |= cpu_to_le16((WORD)(cbMacHdLen << 10));
+
+ //Set packet type
+ if (byPktTyp == PK_TYPE_11A) {//0000 0000 0000 0000
+ ;
+ }
+ else if (byPktTyp == PK_TYPE_11B) {//0000 0001 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ }
+ else if (byPktTyp == PK_TYPE_11GB) {//0000 0010 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
+ }
+ else if (byPktTyp == PK_TYPE_11GA) {//0000 0011 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GA;
+ }
+ //Set FIFOCTL_GrpAckPolicy
+ if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
+ }
+
+ //Set Auto Fallback Ctl
+ if (pDevice->wCurrentRate >= RATE_18M) {
+ if (pDevice->byAutoFBCtrl == AUTO_FB_0) {
+ pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0;
+ } else if (pDevice->byAutoFBCtrl == AUTO_FB_1) {
+ pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1;
+ }
+ }
+
+ //Set FRAGCTL_WEPTYP
+ pDevice->bAES = FALSE;
+
+ //Set FRAGCTL_WEPTYP
+ if (pDevice->byLocalID > REV_ID_VT3253_A1) {
+ if ((bNeedEncrypt) && (pTransmitKey != NULL)) { //WEP enabled
+ if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
+ pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
+ }
+ else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104
+ if (pTransmitKey->uKeyLength != WLAN_WEP232_KEYLEN)
+ pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
+ }
+ else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP
+ pTxBufHead->wFragCtl |= FRAGCTL_AES;
+ }
+ }
+ }
+
+#ifdef PLICE_DEBUG
+ //printk("Func:vGenerateFIFOHeader:TxDataRate is %d,TxPower is %d\n",pDevice->wCurrentRate,pDevice->byCurPwr);
+
+ //if (pDevice->wCurrentRate <= 3)
+ //{
+ // RFbRawSetPower(pDevice,36,pDevice->wCurrentRate);
+ //}
+ //else
+
+ RFbSetPower(pDevice, pDevice->wCurrentRate, pDevice->byCurrentCh);
+#endif
+ //if (pDevice->wCurrentRate == 3)
+ //pDevice->byCurPwr = 46;
+ pTxBufHead->byTxPower = pDevice->byCurPwr;
+
+
+
+
+/*
+ if(pDevice->bEnableHostWEP)
+ pTxBufHead->wFragCtl &= ~(FRAGCTL_TKIP | FRAGCTL_LEGACY |FRAGCTL_AES);
+*/
+ *pcbHeaderSize = s_cbFillTxBufHead(pDevice, byPktTyp, pbyTxBufferAddr, cbPayloadSize,
+ uDMAIdx, pHeadTD, psEthHeader, pPacket, bNeedEncrypt,
+ pTransmitKey, uNodeIndex, puMACfragNum);
+
+ return;
+}
+
+
+
+
+/*+
+ *
+ * Description:
+ * Translate 802.3 to 802.11 header
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to adpater
+ * dwTxBufferAddr - Transmit Buffer
+ * pPacket - Packet from upper layer
+ * cbPacketSize - Transmit Data Length
+ * Out:
+ * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header
+ * pcbAppendPayload - size of append payload for 802.1H translation
+ *
+ * Return Value: none
+ *
+-*/
+
+VOID
+vGenerateMACHeader (
+ IN PSDevice pDevice,
+ IN PBYTE pbyBufferAddr,
+ IN WORD wDuration,
+ IN PSEthernetHeader psEthHeader,
+ IN BOOL bNeedEncrypt,
+ IN WORD wFragType,
+ IN UINT uDMAIdx,
+ IN UINT uFragIdx
+ )
+{
+ PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr;
+
+ ZERO_MEMORY(pMACHeader, (sizeof(S802_11Header))); //- sizeof(pMACHeader->dwIV)));
+
+ if (uDMAIdx == TYPE_ATIMDMA) {
+ pMACHeader->wFrameCtl = TYPE_802_11_ATIM;
+ } else {
+ pMACHeader->wFrameCtl = TYPE_802_11_DATA;
+ }
+
+ if (pDevice->eOPMode == OP_MODE_AP) {
+ MEMvCopy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ pMACHeader->wFrameCtl |= FC_FROMDS;
+ }
+ else {
+ if (pDevice->eOPMode == OP_MODE_ADHOC) {
+ MEMvCopy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ }
+ else {
+ MEMvCopy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+ pMACHeader->wFrameCtl |= FC_TODS;
+ }
+ }
+
+ if (bNeedEncrypt)
+ pMACHeader->wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_ISWEP(1));
+
+ pMACHeader->wDurationID = cpu_to_le16(wDuration);
+
+ if (pDevice->bLongHeader) {
+ PWLAN_80211HDR_A4 pMACA4Header = (PWLAN_80211HDR_A4) pbyBufferAddr;
+ pMACHeader->wFrameCtl |= (FC_TODS | FC_FROMDS);
+ MEMvCopy(pMACA4Header->abyAddr4, pDevice->abyBSSID, WLAN_ADDR_LEN);
+ }
+ pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
+
+ //Set FragNumber in Sequence Control
+ pMACHeader->wSeqCtl |= cpu_to_le16((WORD)uFragIdx);
+
+ if ((wFragType == FRAGCTL_ENDFRAG) || (wFragType == FRAGCTL_NONFRAG)) {
+ pDevice->wSeqCounter++;
+ if (pDevice->wSeqCounter > 0x0fff)
+ pDevice->wSeqCounter = 0;
+ }
+
+ if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) { //StartFrag or MidFrag
+ pMACHeader->wFrameCtl |= FC_MOREFRAG;
+ }
+}
+
+
+
+
+
+
+CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) {
+
+ PSTxDesc pFrstTD;
+ BYTE byPktTyp;
+ PBYTE pbyTxBufferAddr;
+ PVOID pvRTS;
+ PSCTS pCTS;
+ PVOID pvTxDataHd;
+ UINT uDuration;
+ UINT cbReqCount;
+ PS802_11Header pMACHeader;
+ UINT cbHeaderSize;
+ UINT cbFrameBodySize;
+ BOOL bNeedACK;
+ BOOL bIsPSPOLL = FALSE;
+ PSTxBufHead pTxBufHead;
+ UINT cbFrameSize;
+ UINT cbIVlen = 0;
+ UINT cbICVlen = 0;
+ UINT cbMIClen = 0;
+ UINT cbFCSlen = 4;
+ UINT uPadding = 0;
+ WORD wTxBufSize;
+ UINT cbMacHdLen;
+ SEthernetHeader sEthHeader;
+ PVOID pvRrvTime;
+ PVOID pMICHDR;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ WORD wCurrentRate = RATE_1M;
+
+
+ if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) {
+ return CMD_STATUS_RESOURCES;
+ }
+
+ pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0];
+ pbyTxBufferAddr = (PBYTE)pFrstTD->pTDInfo->buf;
+ cbFrameBodySize = pPacket->cbPayloadLen;
+ pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
+ wTxBufSize = sizeof(STxBufHead);
+ memset(pTxBufHead, 0, wTxBufSize);
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ byPktTyp = PK_TYPE_11A;
+ } else {
+ wCurrentRate = RATE_1M;
+ byPktTyp = PK_TYPE_11B;
+ }
+
+ // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
+ // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
+ // And cmd timer will wait data pkt TX finish before scanning so it's OK
+ // to set power here.
+ if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) {
+
+ RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
+ } else {
+ RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
+ }
+ pTxBufHead->byTxPower = pDevice->byCurPwr;
+ //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
+ if (pDevice->byFOETuning) {
+ if ((pPacket->p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) {
+ wCurrentRate = RATE_24M;
+ byPktTyp = PK_TYPE_11GA;
+ }
+ }
+
+ //Set packet type
+ if (byPktTyp == PK_TYPE_11A) {//0000 0000 0000 0000
+ pTxBufHead->wFIFOCtl = 0;
+ }
+ else if (byPktTyp == PK_TYPE_11B) {//0000 0001 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ }
+ else if (byPktTyp == PK_TYPE_11GB) {//0000 0010 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
+ }
+ else if (byPktTyp == PK_TYPE_11GA) {//0000 0011 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GA;
+ }
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
+ pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
+
+
+ if (IS_MULTICAST_ADDRESS(&(pPacket->p80211Header->sA3.abyAddr1[0])) ||
+ IS_BROADCAST_ADDRESS(&(pPacket->p80211Header->sA3.abyAddr1[0]))) {
+ bNeedACK = FALSE;
+ }
+ else {
+ bNeedACK = TRUE;
+ pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
+ };
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
+ (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) {
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY;
+ //Set Preamble type always long
+ //pDevice->byPreambleType = PREAMBLE_LONG;
+ // probe-response don't retry
+ //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
+ // bNeedACK = FALSE;
+ // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
+ //}
+ }
+
+ pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0);
+
+ if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) {
+ bIsPSPOLL = TRUE;
+ cbMacHdLen = WLAN_HDR_ADDR2_LEN;
+ } else {
+ cbMacHdLen = WLAN_HDR_ADDR3_LEN;
+ }
+
+ //Set FRAGCTL_MACHDCNT
+ pTxBufHead->wFragCtl |= cpu_to_le16((WORD)(cbMacHdLen << 10));
+
+ // Notes:
+ // Although spec says MMPDU can be fragmented; In most case,
+ // no one will send a MMPDU under fragmentation. With RTS may occur.
+ pDevice->bAES = FALSE; //Set FRAGCTL_WEPTYP
+
+ if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) {
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) {
+ cbIVlen = 4;
+ cbICVlen = 4;
+ pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
+ }
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ cbIVlen = 8;//IV+ExtIV
+ cbMIClen = 8;
+ cbICVlen = 4;
+ pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
+ //We need to get seed here for filling TxKey entry.
+ //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
+ // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
+ }
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ cbIVlen = 8;//RSN Header
+ cbICVlen = 8;//MIC
+ pTxBufHead->wFragCtl |= FRAGCTL_AES;
+ pDevice->bAES = TRUE;
+ }
+ //MAC Header should be padding 0 to DW alignment.
+ uPadding = 4 - (cbMacHdLen%4);
+ uPadding %= 4;
+ }
+
+ cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen;
+
+ //Set FIFOCTL_GrpAckPolicy
+ if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
+ }
+ //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
+
+ //Set RrvTime/RTS/CTS Buffer
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {//802.11g packet
+
+ pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = NULL;
+ pvRTS = NULL;
+ pCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS));
+ pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + sizeof(SCTS));
+ cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + sizeof(SCTS) + sizeof(STxDataHead_g);
+ }
+ else { // 802.11a/b packet
+ pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = NULL;
+ pvRTS = NULL;
+ pCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab));
+ cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + sizeof(STxDataHead_ab);
+ }
+
+ ZERO_MEMORY((PVOID)(pbyTxBufferAddr + wTxBufSize), (cbHeaderSize - wTxBufSize));
+
+ MEMvCopy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN);
+ //=========================
+ // No Fragmentation
+ //=========================
+ pTxBufHead->wFragCtl |= (WORD)FRAGCTL_NONFRAG;
+
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktTyp, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS,
+ cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate);
+
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktTyp, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK,
+ 0, 0, 1, AUTO_FB_NONE, wCurrentRate);
+
+ pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize);
+
+ cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize;
+
+ if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) {
+ PBYTE pbyIVHead;
+ PBYTE pbyPayloadHead;
+ PBYTE pbyBSSID;
+ PSKeyItem pTransmitKey = NULL;
+
+ pbyIVHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding);
+ pbyPayloadHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen);
+
+ //Fill TXKEY
+ //Kyle: Need fix: TKIP and AES did't encryt Mnt Packet.
+ //s_vFillTxKey(pDevice, (PBYTE)pTxBufHead->adwTxKey, NULL);
+
+ //Fill IV(ExtIV,RSNHDR)
+ //s_vFillPrePayload(pDevice, pbyIVHead, NULL);
+ //---------------------------
+ // S/W or H/W Encryption
+ //---------------------------
+ //Fill MICHDR
+ //if (pDevice->bAES) {
+ // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, (PBYTE)pMACHeader, (WORD)cbFrameBodySize);
+ //}
+ do {
+ if ((pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) &&
+ (pDevice->bLinkPass == TRUE)) {
+ pbyBSSID = pDevice->abyBSSID;
+ // get pairwise key
+ if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == FALSE) {
+ // get group key
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == TRUE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n");
+ break;
+ }
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get PTK.\n");
+ break;
+ }
+ }
+ // get group key
+ pbyBSSID = pDevice->abyBroadcastAddr;
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) {
+ pTransmitKey = NULL;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->eOPMode);
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n");
+ }
+ } while(FALSE);
+ //Fill TXKEY
+ s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey,
+ (PBYTE)pMACHeader, (WORD)cbFrameBodySize, NULL);
+
+ MEMvCopy(pMACHeader, pPacket->p80211Header, cbMacHdLen);
+ MEMvCopy(pbyPayloadHead, ((PBYTE)(pPacket->p80211Header) + cbMacHdLen),
+ cbFrameBodySize);
+ }
+ else {
+ // Copy the Packet into a tx Buffer
+ MEMvCopy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen);
+ }
+
+ pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
+ pDevice->wSeqCounter++ ;
+ if (pDevice->wSeqCounter > 0x0fff)
+ pDevice->wSeqCounter = 0;
+
+ if (bIsPSPOLL) {
+ // The MAC will automatically replace the Duration-field of MAC header by Duration-field
+ // of FIFO control header.
+ // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
+ // in the same place of other packet's Duration-field).
+ // And it will cause Cisco-AP to issue Disassociation-packet
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {
+ ((PSTxDataHead_g)pvTxDataHd)->wDuration_a = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID);
+ ((PSTxDataHead_g)pvTxDataHd)->wDuration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID);
+ } else {
+ ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID);
+ }
+ }
+
+
+ // first TD is the only TD
+ //Set TSR1 & ReqCount in TxDescHead
+ pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU);
+ pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma;
+ pFrstTD->m_td1TD1.wReqCount = cpu_to_le16((WORD)(cbReqCount));
+ pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma);
+ pFrstTD->pTDInfo->byFlags = 0;
+
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
+ // Disable PS
+ MACbPSWakeup(pDevice->PortOffset);
+ }
+ pDevice->bPWBitOn = FALSE;
+
+ wmb();
+ pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
+ wmb();
+
+ pDevice->iTDUsed[TYPE_TXDMA0]++;
+
+ if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " available td0 <= 1\n");
+ }
+
+ pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next;
+#ifdef PLICE_DEBUG
+ //printk("SCAN:CurrentRate is %d,TxPower is %d\n",wCurrentRate,pTxBufHead->byTxPower);
+#endif
+
+#ifdef TxInSleep
+ pDevice->nTxDataTimeCout=0; //2008-8-21 chester <add> for send null packet
+ #endif
+
+ // Poll Transmit the adapter
+ MACvTransmit0(pDevice->PortOffset);
+
+ return CMD_STATUS_PENDING;
+
+}
+
+
+CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) {
+
+ BYTE byPktTyp;
+ PBYTE pbyBuffer = (PBYTE)pDevice->tx_beacon_bufs;
+ UINT cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
+ UINT cbHeaderSize = 0;
+ WORD wTxBufSize = sizeof(STxShortBufHead);
+ PSTxShortBufHead pTxBufHead = (PSTxShortBufHead) pbyBuffer;
+ PSTxDataHead_ab pTxDataHead = (PSTxDataHead_ab) (pbyBuffer + wTxBufSize);
+ PS802_11Header pMACHeader;
+ WORD wCurrentRate;
+ WORD wLen = 0x0000;
+
+
+ memset(pTxBufHead, 0, wTxBufSize);
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ byPktTyp = PK_TYPE_11A;
+ } else {
+ wCurrentRate = RATE_2M;
+ byPktTyp = PK_TYPE_11B;
+ }
+
+ //Set Preamble type always long
+ pDevice->byPreambleType = PREAMBLE_LONG;
+
+ //Set FIFOCTL_GENINT
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_GENINT;
+
+
+ //Set packet type & Get Duration
+ if (byPktTyp == PK_TYPE_11A) {//0000 0000 0000 0000
+ pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameSize, byPktTyp,
+ wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE));
+ }
+ else if (byPktTyp == PK_TYPE_11B) {//0000 0001 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameSize, byPktTyp,
+ wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE));
+ }
+
+ BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, byPktTyp,
+ (PWORD)&(wLen), (PBYTE)&(pTxDataHead->byServiceField), (PBYTE)&(pTxDataHead->bySignalField)
+ );
+ pTxDataHead->wTransmitLength = cpu_to_le16(wLen);
+ //Get TimeStampOff
+ pTxDataHead->wTimeStampOff = cpu_to_le16(wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]);
+ cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab);
+
+ //Generate Beacon Header
+ pMACHeader = (PS802_11Header)(pbyBuffer + cbHeaderSize);
+ MEMvCopy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen);
+
+ pMACHeader->wDurationID = 0;
+ pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
+ pDevice->wSeqCounter++ ;
+ if (pDevice->wSeqCounter > 0x0fff)
+ pDevice->wSeqCounter = 0;
+
+ // Set Beacon buffer length
+ pDevice->wBCNBufLen = pPacket->cbMPDULen + cbHeaderSize;
+
+ MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, (pDevice->tx_beacon_dma));
+
+ MACvSetCurrBCNLength(pDevice->PortOffset, pDevice->wBCNBufLen);
+ // Set auto Transmit on
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+ // Poll Transmit the adapter
+ MACvTransmitBCN(pDevice->PortOffset);
+
+ return CMD_STATUS_PENDING;
+}
+
+
+
+UINT
+cbGetFragCount (
+ IN PSDevice pDevice,
+ IN PSKeyItem pTransmitKey,
+ IN UINT cbFrameBodySize,
+ IN PSEthernetHeader psEthHeader
+ )
+{
+ UINT cbMACHdLen;
+ UINT cbFrameSize;
+ UINT cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
+ UINT cbFragPayloadSize;
+ UINT cbLastFragPayloadSize;
+ UINT cbIVlen = 0;
+ UINT cbICVlen = 0;
+ UINT cbMIClen = 0;
+ UINT cbFCSlen = 4;
+ UINT uMACfragNum = 1;
+ BOOL bNeedACK;
+
+
+
+ if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+ (pDevice->eOPMode == OP_MODE_AP)) {
+ if (IS_MULTICAST_ADDRESS(&(psEthHeader->abyDstAddr[0])) ||
+ IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) {
+ bNeedACK = FALSE;
+ }
+ else {
+ bNeedACK = TRUE;
+ }
+ }
+ else {
+ // MSDUs in Infra mode always need ACK
+ bNeedACK = TRUE;
+ }
+
+ if (pDevice->bLongHeader)
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
+ else
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN;
+
+
+ if (pDevice->bEncryptionEnable == TRUE) {
+
+ if (pTransmitKey == NULL) {
+ if ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) ||
+ (pDevice->pMgmt->eAuthenMode < WMAC_AUTH_WPA)) {
+ cbIVlen = 4;
+ cbICVlen = 4;
+ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ cbIVlen = 8;//IV+ExtIV
+ cbMIClen = 8;
+ cbICVlen = 4;
+ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ cbIVlen = 8;//RSN Header
+ cbICVlen = 8;//MIC
+ }
+ } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) {
+ cbIVlen = 4;
+ cbICVlen = 4;
+ } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
+ cbIVlen = 8;//IV+ExtIV
+ cbMIClen = 8;
+ cbICVlen = 4;
+ } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
+ cbIVlen = 8;//RSN Header
+ cbICVlen = 8;//MIC
+ }
+ }
+
+ cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen;
+
+ if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == TRUE)) {
+ // Fragmentation
+ cbFragmentSize = pDevice->wFragmentationThreshold;
+ cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen;
+ uMACfragNum = (WORD) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize);
+ cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize;
+ if (cbLastFragPayloadSize == 0) {
+ cbLastFragPayloadSize = cbFragPayloadSize;
+ } else {
+ uMACfragNum++;
+ }
+ }
+ return uMACfragNum;
+}
+
+
+VOID
+vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDULen) {
+
+ PSTxDesc pFrstTD;
+ BYTE byPktTyp;
+ PBYTE pbyTxBufferAddr;
+ PVOID pvRTS;
+ PVOID pvCTS;
+ PVOID pvTxDataHd;
+ UINT uDuration;
+ UINT cbReqCount;
+ PS802_11Header pMACHeader;
+ UINT cbHeaderSize;
+ UINT cbFrameBodySize;
+ BOOL bNeedACK;
+ BOOL bIsPSPOLL = FALSE;
+ PSTxBufHead pTxBufHead;
+ UINT cbFrameSize;
+ UINT cbIVlen = 0;
+ UINT cbICVlen = 0;
+ UINT cbMIClen = 0;
+ UINT cbFCSlen = 4;
+ UINT uPadding = 0;
+ UINT cbMICHDR = 0;
+ UINT uLength = 0;
+ DWORD dwMICKey0, dwMICKey1;
+ DWORD dwMIC_Priority;
+ PDWORD pdwMIC_L;
+ PDWORD pdwMIC_R;
+ WORD wTxBufSize;
+ UINT cbMacHdLen;
+ SEthernetHeader sEthHeader;
+ PVOID pvRrvTime;
+ PVOID pMICHDR;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ WORD wCurrentRate = RATE_1M;
+ PUWLAN_80211HDR p80211Header;
+ UINT uNodeIndex = 0;
+ BOOL bNodeExist = FALSE;
+ SKeyItem STempKey;
+ PSKeyItem pTransmitKey = NULL;
+ PBYTE pbyIVHead;
+ PBYTE pbyPayloadHead;
+ PBYTE pbyMacHdr;
+
+ UINT cbExtSuppRate = 0;
+// PWLAN_IE pItem;
+
+
+ pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
+
+ if(cbMPDULen <= WLAN_HDR_ADDR3_LEN) {
+ cbFrameBodySize = 0;
+ }
+ else {
+ cbFrameBodySize = cbMPDULen - WLAN_HDR_ADDR3_LEN;
+ }
+ p80211Header = (PUWLAN_80211HDR)pbMPDU;
+
+
+ pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0];
+ pbyTxBufferAddr = (PBYTE)pFrstTD->pTDInfo->buf;
+ pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
+ wTxBufSize = sizeof(STxBufHead);
+ memset(pTxBufHead, 0, wTxBufSize);
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ byPktTyp = PK_TYPE_11A;
+ } else {
+ wCurrentRate = RATE_1M;
+ byPktTyp = PK_TYPE_11B;
+ }
+
+ // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
+ // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
+ // And cmd timer will wait data pkt TX finish before scanning so it's OK
+ // to set power here.
+ if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) {
+ RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
+ } else {
+ RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
+ }
+ pTxBufHead->byTxPower = pDevice->byCurPwr;
+
+ //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
+ if (pDevice->byFOETuning) {
+ if ((p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) {
+ wCurrentRate = RATE_24M;
+ byPktTyp = PK_TYPE_11GA;
+ }
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl);
+
+ //Set packet type
+ if (byPktTyp == PK_TYPE_11A) {//0000 0000 0000 0000
+ pTxBufHead->wFIFOCtl = 0;
+ }
+ else if (byPktTyp == PK_TYPE_11B) {//0000 0001 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ }
+ else if (byPktTyp == PK_TYPE_11GB) {//0000 0010 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
+ }
+ else if (byPktTyp == PK_TYPE_11GA) {//0000 0011 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GA;
+ }
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN;
+ pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
+
+
+ if (IS_MULTICAST_ADDRESS(&(p80211Header->sA3.abyAddr1[0])) ||
+ IS_BROADCAST_ADDRESS(&(p80211Header->sA3.abyAddr1[0]))) {
+ bNeedACK = FALSE;
+ if (pDevice->bEnableHostWEP) {
+ uNodeIndex = 0;
+ bNodeExist = TRUE;
+ };
+ }
+ else {
+ if (pDevice->bEnableHostWEP) {
+ if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (PBYTE)(p80211Header->sA3.abyAddr1), &uNodeIndex))
+ bNodeExist = TRUE;
+ };
+ bNeedACK = TRUE;
+ pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
+ };
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
+ (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) {
+
+ pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY;
+ //Set Preamble type always long
+ //pDevice->byPreambleType = PREAMBLE_LONG;
+
+ // probe-response don't retry
+ //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
+ // bNeedACK = FALSE;
+ // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
+ //}
+ }
+
+ pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0);
+
+ if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) {
+ bIsPSPOLL = TRUE;
+ cbMacHdLen = WLAN_HDR_ADDR2_LEN;
+ } else {
+ cbMacHdLen = WLAN_HDR_ADDR3_LEN;
+ }
+
+ // hostapd deamon ext support rate patch
+ if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) {
+
+ if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) {
+ cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN;
+ }
+
+ if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) {
+ cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
+ }
+
+ if (cbExtSuppRate >0) {
+ cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES;
+ }
+ }
+
+
+ //Set FRAGCTL_MACHDCNT
+ pTxBufHead->wFragCtl |= cpu_to_le16((WORD)cbMacHdLen << 10);
+
+ // Notes:
+ // Although spec says MMPDU can be fragmented; In most case,
+ // no one will send a MMPDU under fragmentation. With RTS may occur.
+ pDevice->bAES = FALSE; //Set FRAGCTL_WEPTYP
+
+
+ if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) {
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) {
+ cbIVlen = 4;
+ cbICVlen = 4;
+ pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
+ }
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ cbIVlen = 8;//IV+ExtIV
+ cbMIClen = 8;
+ cbICVlen = 4;
+ pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
+ //We need to get seed here for filling TxKey entry.
+ //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
+ // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
+ }
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ cbIVlen = 8;//RSN Header
+ cbICVlen = 8;//MIC
+ cbMICHDR = sizeof(SMICHDRHead);
+ pTxBufHead->wFragCtl |= FRAGCTL_AES;
+ pDevice->bAES = TRUE;
+ }
+ //MAC Header should be padding 0 to DW alignment.
+ uPadding = 4 - (cbMacHdLen%4);
+ uPadding %= 4;
+ }
+
+ cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate;
+
+ //Set FIFOCTL_GrpAckPolicy
+ if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
+ }
+ //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
+
+
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {//802.11g packet
+
+ pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS));
+ pvRTS = NULL;
+ pvCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR);
+ pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS));
+ cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS) + sizeof(STxDataHead_g);
+
+ }
+ else {//802.11a/b packet
+
+ pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
+ pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab));
+ pvRTS = NULL;
+ pvCTS = NULL;
+ pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR);
+ cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab);
+
+ }
+
+ ZERO_MEMORY((PVOID)(pbyTxBufferAddr + wTxBufSize), (cbHeaderSize - wTxBufSize));
+ MEMvCopy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN);
+ MEMvCopy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN);
+ //=========================
+ // No Fragmentation
+ //=========================
+ pTxBufHead->wFragCtl |= (WORD)FRAGCTL_NONFRAG;
+
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktTyp, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS,
+ cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate);
+
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktTyp, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK,
+ 0, 0, 1, AUTO_FB_NONE, wCurrentRate);
+
+ pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize);
+
+ cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate;
+
+ pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderSize);
+ pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen);
+ pbyIVHead = (PBYTE)(pbyMacHdr + cbMacHdLen + uPadding);
+
+ // Copy the Packet into a tx Buffer
+ memcpy(pbyMacHdr, pbMPDU, cbMacHdLen);
+
+ // version set to 0, patch for hostapd deamon
+ pMACHeader->wFrameCtl &= cpu_to_le16(0xfffc);
+ memcpy(pbyPayloadHead, (pbMPDU + cbMacHdLen), cbFrameBodySize);
+
+ // replace support rate, patch for hostapd deamon( only support 11M)
+ if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) {
+ if (cbExtSuppRate != 0) {
+ if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0)
+ memcpy((pbyPayloadHead + cbFrameBodySize),
+ pMgmt->abyCurrSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0)
+ memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN,
+ pMgmt->abyCurrExtSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ }
+ }
+
+ // Set wep
+ if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) {
+
+ if (pDevice->bEnableHostWEP) {
+ pTransmitKey = &STempKey;
+ pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
+ pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
+ pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
+ pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
+ pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
+ memcpy(pTransmitKey->abyKey,
+ &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
+ pTransmitKey->uKeyLength
+ );
+ }
+
+ if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
+
+ dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]);
+ dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]);
+
+ // DO Software Michael
+ MIC_vInit(dwMICKey0, dwMICKey1);
+ MIC_vAppend((PBYTE)&(sEthHeader.abyDstAddr[0]), 12);
+ dwMIC_Priority = 0;
+ MIC_vAppend((PBYTE)&dwMIC_Priority, 4);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1);
+
+ uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen;
+
+ MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize);
+
+ pdwMIC_L = (PDWORD)(pbyTxBufferAddr + uLength + cbFrameBodySize);
+ pdwMIC_R = (PDWORD)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4);
+
+ MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
+ MIC_vUnInit();
+
+ if (pDevice->bTxMICFail == TRUE) {
+ *pdwMIC_L = 0;
+ *pdwMIC_R = 0;
+ pDevice->bTxMICFail = FALSE;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lx, %lx\n", *pdwMIC_L, *pdwMIC_R);
+
+ }
+
+
+ s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey,
+ pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR);
+
+ if (pDevice->bEnableHostWEP) {
+ pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16;
+ pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0;
+ }
+
+ if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) {
+ s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (WORD)(cbFrameBodySize + cbMIClen));
+ }
+ }
+
+ pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4);
+ pDevice->wSeqCounter++ ;
+ if (pDevice->wSeqCounter > 0x0fff)
+ pDevice->wSeqCounter = 0;
+
+
+ if (bIsPSPOLL) {
+ // The MAC will automatically replace the Duration-field of MAC header by Duration-field
+ // of FIFO control header.
+ // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
+ // in the same place of other packet's Duration-field).
+ // And it will cause Cisco-AP to issue Disassociation-packet
+ if (byPktTyp == PK_TYPE_11GB || byPktTyp == PK_TYPE_11GA) {
+ ((PSTxDataHead_g)pvTxDataHd)->wDuration_a = cpu_to_le16(p80211Header->sA2.wDurationID);
+ ((PSTxDataHead_g)pvTxDataHd)->wDuration_b = cpu_to_le16(p80211Header->sA2.wDurationID);
+ } else {
+ ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(p80211Header->sA2.wDurationID);
+ }
+ }
+
+
+ // first TD is the only TD
+ //Set TSR1 & ReqCount in TxDescHead
+ pFrstTD->pTDInfo->skb = skb;
+ pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU);
+ pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma;
+ pFrstTD->m_td1TD1.wReqCount = cpu_to_le16(cbReqCount);
+ pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma);
+ pFrstTD->pTDInfo->byFlags = 0;
+ pFrstTD->pTDInfo->byFlags |= TD_FLAGS_PRIV_SKB;
+
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
+ // Disable PS
+ MACbPSWakeup(pDevice->PortOffset);
+ }
+ pDevice->bPWBitOn = FALSE;
+
+ wmb();
+ pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
+ wmb();
+
+ pDevice->iTDUsed[TYPE_TXDMA0]++;
+
+ if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " available td0 <= 1\n");
+ }
+
+ pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next;
+
+ // Poll Transmit the adapter
+ MACvTransmit0(pDevice->PortOffset);
+
+ return;
+}
+
+
diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h
new file mode 100644
index 000000000000..3e85264e2843
--- /dev/null
+++ b/drivers/staging/vt6655/rxtx.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: whdr.h
+ *
+ * Purpose:
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jun. 27, 2002
+ *
+ */
+
+
+#ifndef __RXTX_H__
+#define __RXTX_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+/*
+VOID vGenerateMACHeader(
+ IN PSDevice pDevice,
+ IN DWORD dwTxBufferAddr,
+ IN PBYTE pbySkbData,
+ IN UINT cbPacketSize,
+ IN BOOL bDMA0Used,
+ OUT PUINT pcbHeadSize,
+ OUT PUINT pcbAppendPayload
+ );
+
+VOID vProcessRxMACHeader (
+ IN PSDevice pDevice,
+ IN DWORD dwRxBufferAddr,
+ IN UINT cbPacketSize,
+ IN BOOL bIsWEP,
+ OUT PUINT pcbHeadSize
+ );
+*/
+
+
+VOID
+vGenerateMACHeader (
+ IN PSDevice pDevice,
+ IN PBYTE pbyBufferAddr,
+ IN WORD wDuration,
+ IN PSEthernetHeader psEthHeader,
+ IN BOOL bNeedEncrypt,
+ IN WORD wFragType,
+ IN UINT uDMAIdx,
+ IN UINT uFragIdx
+ );
+
+
+UINT
+cbGetFragCount(
+ IN PSDevice pDevice,
+ IN PSKeyItem pTransmitKey,
+ IN UINT cbFrameBodySize,
+ IN PSEthernetHeader psEthHeader
+ );
+
+
+VOID
+vGenerateFIFOHeader (
+ IN PSDevice pDevice,
+ IN BYTE byPktTyp,
+ IN PBYTE pbyTxBufferAddr,
+ IN BOOL bNeedEncrypt,
+ IN UINT cbPayloadSize,
+ IN UINT uDMAIdx,
+ IN PSTxDesc pHeadTD,
+ IN PSEthernetHeader psEthHeader,
+ IN PBYTE pPacket,
+ IN PSKeyItem pTransmitKey,
+ IN UINT uNodeIndex,
+ OUT PUINT puMACfragNum,
+ OUT PUINT pcbHeaderSize
+ );
+
+
+VOID vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDULen);
+CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
+CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __RXTX_H__
+
+
+
diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c
new file mode 100644
index 000000000000..655d68593701
--- /dev/null
+++ b/drivers/staging/vt6655/srom.c
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: srom.c
+ *
+ * Purpose:Implement functions to access eeprom
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jan 29, 2003
+ *
+ * Functions:
+ * SROMbyReadEmbedded - Embedded read eeprom via MAC
+ * SROMbWriteEmbedded - Embedded write eeprom via MAC
+ * SROMvRegBitsOn - Set Bits On in eeprom
+ * SROMvRegBitsOff - Clear Bits Off in eeprom
+ * SROMbIsRegBitsOn - Test if Bits On in eeprom
+ * SROMbIsRegBitsOff - Test if Bits Off in eeprom
+ * SROMvReadAllContents - Read all contents in eeprom
+ * SROMvWriteAllContents - Write all contents in eeprom
+ * SROMvReadEtherAddress - Read Ethernet Address in eeprom
+ * SROMvWriteEtherAddress - Write Ethernet Address in eeprom
+ * SROMvReadSubSysVenId - Read Sub_VID and Sub_SysId in eeprom
+ * SROMbAutoLoad - Auto Load eeprom to MAC register
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__UPC_H__)
+#include "upc.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__SROM_H__)
+#include "srom.h"
+#endif
+
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+
+/*
+ * Description: Read a byte from EEPROM, by MAC I2C
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byContntOffset - address of EEPROM
+ * Out:
+ * none
+ *
+ * Return Value: data read
+ *
+ */
+BYTE SROMbyReadEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset)
+{
+ WORD wDelay, wNoACK;
+ BYTE byWait;
+ BYTE byData;
+ BYTE byOrg;
+
+ byData = 0xFF;
+ VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg);
+ // turn off hardware retry for getting NACK
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY)));
+ for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) {
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID);
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset);
+
+ // issue read command
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMR);
+ // wait DONE be set
+ for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) {
+ VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait);
+ if (BITbIsAnyBitsOn(byWait, (I2MCSR_DONE | I2MCSR_NACK)))
+ break;
+ PCAvDelayByIO(CB_DELAY_LOOP_WAIT);
+ }
+ if ((wDelay < W_MAX_TIMEOUT) &&
+ (BITbIsBitOff(byWait, I2MCSR_NACK))) {
+ break;
+ }
+ }
+ VNSvInPortB(dwIoBase + MAC_REG_I2MDIPT, &byData);
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
+ return byData;
+}
+
+
+/*
+ * Description: Write a byte to EEPROM, by MAC I2C
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byContntOffset - address of EEPROM
+ * wData - data to write
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL SROMbWriteEmbedded (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData)
+{
+ WORD wDelay, wNoACK;
+ BYTE byWait;
+
+ BYTE byOrg;
+
+ VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg);
+ // turn off hardware retry for getting NACK
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY)));
+ for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) {
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID);
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset);
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MDOPT, byData);
+
+ // issue write command
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMW);
+ // wait DONE be set
+ for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) {
+ VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait);
+ if (BITbIsAnyBitsOn(byWait, (I2MCSR_DONE | I2MCSR_NACK)))
+ break;
+ PCAvDelayByIO(CB_DELAY_LOOP_WAIT);
+ }
+
+ if ((wDelay < W_MAX_TIMEOUT) &&
+ (BITbIsBitOff(byWait, I2MCSR_NACK))) {
+ break;
+ }
+ }
+ if (wNoACK == W_MAX_I2CRETRY) {
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
+ return FALSE;
+ }
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
+ return TRUE;
+}
+
+
+/*
+ * Description: Turn bits on in eeprom
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byContntOffset - address of EEPROM
+ * byBits - bits to turn on
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void SROMvRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits)
+{
+ BYTE byOrgData;
+
+ byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
+ SROMbWriteEmbedded(dwIoBase, byContntOffset,(BYTE)(byOrgData | byBits));
+}
+
+
+/*
+ * Description: Turn bits off in eeprom
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byContntOffset - address of EEPROM
+ * byBits - bits to turn off
+ * Out:
+ * none
+ *
+ */
+void SROMvRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits)
+{
+ BYTE byOrgData;
+
+ byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
+ SROMbWriteEmbedded(dwIoBase, byContntOffset,(BYTE)(byOrgData & (~byBits)));
+}
+
+
+/*
+ * Description: Test if bits on in eeprom
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byContntOffset - address of EEPROM
+ * byTestBits - bits to test
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all test bits on; otherwise FALSE
+ *
+ */
+BOOL SROMbIsRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits)
+{
+ BYTE byOrgData;
+
+ byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
+ return BITbIsAllBitsOn(byOrgData, byTestBits);
+}
+
+
+/*
+ * Description: Test if bits off in eeprom
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * byContntOffset - address of EEPROM
+ * byTestBits - bits to test
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if all test bits off; otherwise FALSE
+ *
+ */
+BOOL SROMbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits)
+{
+ BYTE byOrgData;
+
+ byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset);
+ return BITbIsAllBitsOff(byOrgData, byTestBits);
+}
+
+
+/*
+ * Description: Read all contents of eeprom to buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * pbyEepromRegs - EEPROM content Buffer
+ *
+ * Return Value: none
+ *
+ */
+void SROMvReadAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs)
+{
+ int ii;
+
+ // ii = Rom Address
+ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) {
+ *pbyEepromRegs = SROMbyReadEmbedded(dwIoBase,(BYTE) ii);
+ pbyEepromRegs++;
+ }
+}
+
+
+/*
+ * Description: Write all contents of buffer to eeprom
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * pbyEepromRegs - EEPROM content Buffer
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void SROMvWriteAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs)
+{
+ int ii;
+
+ // ii = Rom Address
+ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) {
+ SROMbWriteEmbedded(dwIoBase,(BYTE) ii, *pbyEepromRegs);
+ pbyEepromRegs++;
+ }
+}
+
+
+/*
+ * Description: Read Ethernet Address from eeprom to buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * pbyEtherAddress - Ethernet Address buffer
+ *
+ * Return Value: none
+ *
+ */
+void SROMvReadEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress)
+{
+ BYTE ii;
+
+ // ii = Rom Address
+ for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) {
+ *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii);
+ pbyEtherAddress++;
+ }
+}
+
+
+/*
+ * Description: Write Ethernet Address from buffer to eeprom
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * pbyEtherAddress - Ethernet Address buffer
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void SROMvWriteEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress)
+{
+ BYTE ii;
+
+ // ii = Rom Address
+ for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) {
+ SROMbWriteEmbedded(dwIoBase, ii, *pbyEtherAddress);
+ pbyEtherAddress++;
+ }
+}
+
+
+/*
+ * Description: Read Sub_VID and Sub_SysId from eeprom to buffer
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * pdwSubSysVenId - Sub_VID and Sub_SysId read
+ *
+ * Return Value: none
+ *
+ */
+void SROMvReadSubSysVenId (DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId)
+{
+ PBYTE pbyData;
+
+ pbyData = (PBYTE)pdwSubSysVenId;
+ // sub vendor
+ *pbyData = SROMbyReadEmbedded(dwIoBase, 6);
+ *(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7);
+ // sub system
+ *(pbyData+2) = SROMbyReadEmbedded(dwIoBase, 8);
+ *(pbyData+3) = SROMbyReadEmbedded(dwIoBase, 9);
+}
+
+/*
+ * Description: Auto Load EEPROM to MAC register
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL SROMbAutoLoad (DWORD_PTR dwIoBase)
+{
+ BYTE byWait;
+ int ii;
+
+ BYTE byOrg;
+
+ VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg);
+ // turn on hardware retry
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg | I2MCFG_NORETRY));
+
+ MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD);
+
+ // ii = Rom Address
+ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) {
+ MACvTimer0MicroSDelay(dwIoBase, CB_EEPROM_READBYTE_WAIT);
+ VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait);
+ if (BITbIsBitOff(byWait, I2MCSR_AUTOLD))
+ break;
+ }
+
+ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg);
+
+ if (ii == EEP_MAX_CONTEXT_SIZE)
+ return FALSE;
+ return TRUE;
+}
+
+
diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h
new file mode 100644
index 000000000000..a4ca5f0b196d
--- /dev/null
+++ b/drivers/staging/vt6655/srom.h
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: srom.h
+ *
+ * Purpose: Implement functions to access eeprom
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jan 29, 2003
+ *
+ */
+
+
+#ifndef __SROM_H__
+#define __SROM_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+#define EEP_MAX_CONTEXT_SIZE 256
+
+#define CB_EEPROM_READBYTE_WAIT 900 //us
+
+#define W_MAX_I2CRETRY 0x0fff
+
+//
+// Contents in the EEPROM
+//
+
+#define EEP_OFS_PAR 0x00 // physical address
+#define EEP_OFS_ANTENNA 0x16
+#define EEP_OFS_RADIOCTL 0x17
+#define EEP_OFS_RFTYPE 0x1B // for select RF
+#define EEP_OFS_MINCHANNEL 0x1C // Min Channel #
+#define EEP_OFS_MAXCHANNEL 0x1D // Max Channel #
+#define EEP_OFS_SIGNATURE 0x1E //
+#define EEP_OFS_ZONETYPE 0x1F //
+#define EEP_OFS_RFTABLE 0x20 // RF POWER TABLE
+#define EEP_OFS_PWR_CCK 0x20
+#define EEP_OFS_SETPT_CCK 0x21
+#define EEP_OFS_PWR_OFDMG 0x23
+#define EEP_OFS_SETPT_OFDMG 0x24
+#define EEP_OFS_PWR_FORMULA_OST 0x26 //
+#define EEP_OFS_MAJOR_VER 0x2E
+#define EEP_OFS_MINOR_VER 0x2F
+#define EEP_OFS_CCK_PWR_TBL 0x30
+#define EEP_OFS_CCK_PWR_dBm 0x3F
+#define EEP_OFS_OFDM_PWR_TBL 0x40
+#define EEP_OFS_OFDM_PWR_dBm 0x4F
+//{{ RobertYu: 20041124
+#define EEP_OFS_SETPT_OFDMA 0x4E
+#define EEP_OFS_OFDMA_PWR_TBL 0x50
+//}}
+#define EEP_OFS_OFDMA_PWR_dBm 0xD2
+
+
+//----------need to remove --------------------
+#define EEP_OFS_BBTAB_LEN 0x70 // BB Table Length
+#define EEP_OFS_BBTAB_ADR 0x71 // BB Table Offset
+#define EEP_OFS_CHECKSUM 0xFF // reserved area for baseband 28h ~ 78h
+
+#define EEP_I2C_DEV_ID 0x50 // EEPROM device address on the I2C bus
+
+
+//
+// Bits in EEP_OFS_ANTENNA
+//
+#define EEP_ANTENNA_MAIN 0x01
+#define EEP_ANTENNA_AUX 0x02
+#define EEP_ANTINV 0x04
+
+//
+// Bits in EEP_OFS_RADIOCTL
+//
+#define EEP_RADIOCTL_ENABLE 0x80
+#define EEP_RADIOCTL_INV 0x01
+
+
+
+/*--------------------- Export Types ------------------------------*/
+
+// AT24C02 eeprom contents
+// 2048 bits = 256 bytes = 128 words
+//
+typedef struct tagSSromReg {
+ BYTE abyPAR[6]; // 0x00 (WORD)
+
+ WORD wSUB_VID; // 0x03 (WORD)
+ WORD wSUB_SID;
+
+ BYTE byBCFG0; // 0x05 (WORD)
+ BYTE byBCFG1;
+
+ BYTE byFCR0; // 0x06 (WORD)
+ BYTE byFCR1;
+ BYTE byPMC0; // 0x07 (WORD)
+ BYTE byPMC1;
+ BYTE byMAXLAT; // 0x08 (WORD)
+ BYTE byMINGNT;
+ BYTE byCFG0; // 0x09 (WORD)
+ BYTE byCFG1;
+ WORD wCISPTR; // 0x0A (WORD)
+ WORD wRsv0; // 0x0B (WORD)
+ WORD wRsv1; // 0x0C (WORD)
+ BYTE byBBPAIR; // 0x0D (WORD)
+ BYTE byRFTYPE;
+ BYTE byMinChannel; // 0x0E (WORD)
+ BYTE byMaxChannel;
+ BYTE bySignature; // 0x0F (WORD)
+ BYTE byCheckSum;
+
+ BYTE abyReserved0[96]; // 0x10 (WORD)
+ BYTE abyCIS[128]; // 0x80 (WORD)
+} SSromReg, DEF* PSSromReg;
+
+/*--------------------- Export Macros ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+BYTE SROMbyReadEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset);
+BOOL SROMbWriteEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData);
+
+void SROMvRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits);
+void SROMvRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits);
+
+BOOL SROMbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits);
+BOOL SROMbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits);
+
+void SROMvReadAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs);
+void SROMvWriteAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs);
+
+void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress);
+void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress);
+
+VOID SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId);
+
+BOOL SROMbAutoLoad (DWORD_PTR dwIoBase);
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __EEPROM_H__
+
+
diff --git a/drivers/staging/vt6655/tbit.h b/drivers/staging/vt6655/tbit.h
new file mode 100644
index 000000000000..7c3a82e9b608
--- /dev/null
+++ b/drivers/staging/vt6655/tbit.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tbit.h
+ *
+ * Purpose: Bit routines
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+
+#ifndef __TBIT_H__
+#define __TBIT_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+// test single bit on
+#define BITbIsBitOn(tData, tTestBit) \
+ (((tData) & (tTestBit)) != 0)
+
+// test single bit off
+#define BITbIsBitOff(tData, tTestBit) \
+ (((tData) & (tTestBit)) == 0)
+
+
+#define BITbIsAllBitsOn(tData, tTestBit) \
+ (((tData) & (tTestBit)) == (tTestBit))
+
+#define BITbIsAllBitsOff(tData, tTestBit) \
+ (((tData) & (tTestBit)) == 0)
+
+#define BITbIsAnyBitsOn(tData, tTestBit) \
+ (((tData) & (tTestBit)) != 0)
+
+#define BITbIsAnyBitsOff(tData, tTestBit) \
+ (((tData) & (tTestBit)) != (tTestBit))
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+#endif // __TBIT_H__
+
+
+
diff --git a/drivers/staging/vt6655/tcrc.c b/drivers/staging/vt6655/tcrc.c
new file mode 100644
index 000000000000..b70080c267c8
--- /dev/null
+++ b/drivers/staging/vt6655/tcrc.c
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tcrc.c
+ *
+ * Purpose: Implement functions to caculate CRC
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ * Functions:
+ * CRCdwCrc32 -
+ * CRCdwGetCrc32 -
+ * CRCdwGetCrc32Ex -
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TCRC_H__)
+#include "tcrc.h"
+#endif
+
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+// 32-bit CRC table
+static const DWORD s_adwCrc32Table[256] = {
+ 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
+ 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
+ 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
+ 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
+ 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
+ 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
+ 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL,
+ 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
+ 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L,
+ 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
+ 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L,
+ 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
+ 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L,
+ 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
+ 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
+ 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
+ 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL,
+ 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
+ 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L,
+ 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
+ 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL,
+ 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
+ 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL,
+ 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
+ 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
+ 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
+ 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L,
+ 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
+ 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L,
+ 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
+ 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L,
+ 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
+ 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL,
+ 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
+ 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
+ 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
+ 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL,
+ 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
+ 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL,
+ 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
+ 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L,
+ 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
+ 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L,
+ 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
+ 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
+ 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
+ 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L,
+ 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
+ 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL,
+ 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
+ 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L,
+ 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
+ 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL,
+ 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
+ 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
+ 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
+ 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L,
+ 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
+ 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L,
+ 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
+ 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L,
+ 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
+ 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
+ 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
+};
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+
+
+/*+
+ *
+ * Description:
+ * Generate a CRC-32 from the data stream
+ *
+ * Parameters:
+ * In:
+ * pbyData - the data stream
+ * cbByte - the length of the stream
+ * dwCrcSeed - Seed for CRC32
+ * Out:
+ * none
+ *
+ * Return Value: CRC-32
+ *
+-*/
+DWORD CRCdwCrc32 (PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed)
+{
+ DWORD dwCrc;
+
+ dwCrc = dwCrcSeed;
+ while (cbByte--) {
+ dwCrc = s_adwCrc32Table[(BYTE)((dwCrc ^ (*pbyData)) & 0xFF)] ^ (dwCrc >> 8);
+ pbyData++;
+ }
+
+ return dwCrc;
+}
+
+
+/*+
+ *
+ * Description:
+ * To test CRC generator, input 8 bytes packet
+ * -- 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00
+ * the generated CRC should be
+ * -- 0xff 0xff 0xff 0xff
+ *
+ * Parameters:
+ * In:
+ * pbyData - the data stream
+ * cbByte - the length of the stream
+ * Out:
+ * none
+ *
+ * Return Value: CRC-32
+ *
+-*/
+DWORD CRCdwGetCrc32 (PBYTE pbyData, UINT cbByte)
+{
+ return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL);
+}
+
+
+/*+
+ *
+ * Description:
+ *
+ * NOTE.... Because CRCdwGetCrc32Ex() is an iteration function,
+ * this means we will use the output of CRCdwGetCrc32Ex()
+ * to be a new argument to do next CRCdwGetCrc32Ex() calculation.
+ * Thus, the final result must be inverted to be the
+ * correct answer.
+ *
+ * Parameters:
+ * In:
+ * pbyData - the data stream
+ * cbByte - the length of the stream
+ * Out:
+ * none
+ *
+ * Return Value: CRC-32
+ *
+-*/
+DWORD CRCdwGetCrc32Ex(PBYTE pbyData, UINT cbByte, DWORD dwPreCRC)
+{
+ return CRCdwCrc32(pbyData, cbByte, dwPreCRC);
+}
+
+
diff --git a/drivers/staging/vt6655/tcrc.h b/drivers/staging/vt6655/tcrc.h
new file mode 100644
index 000000000000..ebea22ed2da6
--- /dev/null
+++ b/drivers/staging/vt6655/tcrc.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tcrc.h
+ *
+ * Purpose: Implement functions to caculate CRC
+ *
+ * Author: Tevin Chen
+ *
+ * Date: Jan. 28, 1997
+ *
+ */
+
+
+#ifndef __TCRC_H__
+#define __TCRC_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+DWORD CRCdwCrc32(PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed);
+DWORD CRCdwGetCrc32(PBYTE pbyData, UINT cbByte);
+DWORD CRCdwGetCrc32Ex(PBYTE pbyData, UINT cbByte, DWORD dwPreCRC);
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __TCRC_H__
+
+
+
diff --git a/drivers/staging/vt6655/test b/drivers/staging/vt6655/test
new file mode 100644
index 000000000000..039f7d71c537
--- /dev/null
+++ b/drivers/staging/vt6655/test
@@ -0,0 +1,9 @@
+KSP := /lib/modules/$(shell uname -r)/build \
+ /usr/src/linux-$(shell uname -r) \
+ /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
+# /usr/src/kernel-headers-$(shell uname -r) \
+# /usr/src/kernel-source-$(shell uname -r) \
+# /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
+# /usr/src/linux /home/plice
+test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
+KSP := $(foreach dir, $(KSP), $(test_dir)) \ No newline at end of file
diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c
new file mode 100644
index 000000000000..fd69423fe14b
--- /dev/null
+++ b/drivers/staging/vt6655/tether.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tether.c
+ *
+ * Purpose:
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ * Functions:
+ * ETHbyGetHashIndexByCrc32 - Caculate multicast hash value by CRC32
+ * ETHbIsBufferCrc32Ok - Check CRC value of the buffer if Ok or not
+ *
+ * Revision History:
+ *
+ */
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TCRC_H__)
+#include "tcrc.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+
+/*
+ * Description: Caculate multicast hash value by CRC32
+ *
+ * Parameters:
+ * In:
+ * pbyMultiAddr - Multicast Address
+ * Out:
+ * none
+ *
+ * Return Value: Hash value
+ *
+ */
+BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr)
+{
+ int ii;
+ BYTE byTmpHash;
+ BYTE byHash = 0;
+
+ // get the least 6-bits from CRC generator
+ byTmpHash = (BYTE)(CRCdwCrc32(pbyMultiAddr, U_ETHER_ADDR_LEN,
+ 0xFFFFFFFFL) & 0x3F);
+ // reverse most bit to least bit
+ for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) {
+ byHash <<= 1;
+ if (BITbIsBitOn(byTmpHash, 0x01))
+ byHash |= 1;
+ byTmpHash >>= 1;
+ }
+
+ // adjust 6-bits to the right most
+ return (byHash >> 2);
+}
+
+
+/*
+ * Description: Check CRC value of the buffer if Ok or not
+ *
+ * Parameters:
+ * In:
+ * pbyBuffer - pointer of buffer (normally is rx buffer)
+ * cbFrameLength - length of buffer, including CRC portion
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if ok; FALSE if error.
+ *
+ */
+BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, UINT cbFrameLength)
+{
+ DWORD dwCRC;
+
+ dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4);
+ if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h
new file mode 100644
index 000000000000..920a8bb68356
--- /dev/null
+++ b/drivers/staging/vt6655/tether.h
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: tether.h
+ *
+ * Purpose:
+ *
+ * Author: Tevin Chen
+ *
+ * Date: Jan. 28, 1997
+ *
+ */
+
+
+
+#ifndef __TETHER_H__
+#define __TETHER_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+//
+// constants
+//
+#define U_ETHER_ADDR_LEN 6 // Ethernet address length
+#define U_TYPE_LEN 2 //
+#define U_CRC_LEN 4 //
+#define U_HEADER_LEN (U_ETHER_ADDR_LEN * 2 + U_TYPE_LEN)
+#define U_ETHER_ADDR_STR_LEN (U_ETHER_ADDR_LEN * 2 + 1)
+ // Ethernet address string length
+
+#define MIN_DATA_LEN 46 // min data length
+#define MAX_DATA_LEN 1500 // max data length
+
+#define MIN_PACKET_LEN (MIN_DATA_LEN + U_HEADER_LEN)
+ // 60
+ // min total packet length (tx)
+#define MAX_PACKET_LEN (MAX_DATA_LEN + U_HEADER_LEN)
+ // 1514
+ // max total packet length (tx)
+
+#define MAX_LOOKAHEAD_SIZE MAX_PACKET_LEN
+
+#define U_MULTI_ADDR_LEN 8 // multicast address length
+
+
+#ifdef __BIG_ENDIAN
+
+#define TYPE_PKT_IP 0x0800 //
+#define TYPE_PKT_ARP 0x0806 //
+#define TYPE_PKT_RARP 0x8035 //
+#define TYPE_PKT_IPX 0x8137 //
+#define TYPE_PKT_802_1x 0x888e
+#define TYPE_PKT_PreAuth 0x88C7
+
+#define TYPE_PKT_PING_M_REQ 0x8011 // master reguest
+#define TYPE_PKT_PING_S_GNT 0x8022 // slave grant
+#define TYPE_PKT_PING_M 0x8077 // pingpong master packet
+#define TYPE_PKT_PING_S 0x8088 // pingpong slave packet
+#define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request
+#define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant
+#define TYPE_MGMT_PROBE_RSP 0x5000
+#define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt
+#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
+//
+// wFrameCtl field in the S802_11Header
+//
+// NOTE....
+// in network byte order, high byte is going first
+#define FC_TODS 0x0001
+#define FC_FROMDS 0x0002
+#define FC_MOREFRAG 0x0004
+#define FC_RETRY 0x0008
+#define FC_POWERMGT 0x0010
+#define FC_MOREDATA 0x0020
+#define FC_WEP 0x0040
+#define TYPE_802_11_ATIM 0x9000
+
+#define TYPE_802_11_DATA 0x0800
+#define TYPE_802_11_CTL 0x0400
+#define TYPE_802_11_MGMT 0x0000
+#define TYPE_802_11_MASK 0x0C00
+#define TYPE_SUBTYPE_MASK 0xFC00
+#define TYPE_802_11_NODATA 0x4000
+#define TYPE_DATE_NULL 0x4800
+
+#define TYPE_CTL_PSPOLL 0xa400
+#define TYPE_CTL_RTS 0xb400
+#define TYPE_CTL_CTS 0xc400
+#define TYPE_CTL_ACK 0xd400
+
+
+//#define WEP_IV_MASK 0xFFFFFF00
+
+#else //if LITTLE_ENDIAN
+//
+// wType field in the SEthernetHeader
+//
+// NOTE....
+// in network byte order, high byte is going first
+#define TYPE_PKT_IP 0x0008 //
+#define TYPE_PKT_ARP 0x0608 //
+#define TYPE_PKT_RARP 0x3580 //
+#define TYPE_PKT_IPX 0x3781 //
+
+#define TYPE_PKT_802_1x 0x8e88
+#define TYPE_PKT_PreAuth 0xC788
+
+#define TYPE_PKT_PING_M_REQ 0x1180 // master reguest
+#define TYPE_PKT_PING_S_GNT 0x2280 // slave grant
+#define TYPE_PKT_PING_M 0x7780 // pingpong master packet
+#define TYPE_PKT_PING_S 0x8880 // pingpong slave packet
+#define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request
+#define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant
+#define TYPE_MGMT_PROBE_RSP 0x0050
+#define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt
+#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
+//
+// wFrameCtl field in the S802_11Header
+//
+// NOTE....
+// in network byte order, high byte is going first
+#define FC_TODS 0x0100
+#define FC_FROMDS 0x0200
+#define FC_MOREFRAG 0x0400
+#define FC_RETRY 0x0800
+#define FC_POWERMGT 0x1000
+#define FC_MOREDATA 0x2000
+#define FC_WEP 0x4000
+#define TYPE_802_11_ATIM 0x0090
+
+#define TYPE_802_11_DATA 0x0008
+#define TYPE_802_11_CTL 0x0004
+#define TYPE_802_11_MGMT 0x0000
+#define TYPE_802_11_MASK 0x000C
+#define TYPE_SUBTYPE_MASK 0x00FC
+#define TYPE_802_11_NODATA 0x0040
+#define TYPE_DATE_NULL 0x0048
+
+#define TYPE_CTL_PSPOLL 0x00a4
+#define TYPE_CTL_RTS 0x00b4
+#define TYPE_CTL_CTS 0x00c4
+#define TYPE_CTL_ACK 0x00d4
+
+
+//#define WEP_IV_MASK 0x00FFFFFF
+
+#endif //#ifdef __BIG_ENDIAN
+
+#define WEP_IV_MASK 0x00FFFFFF
+
+/*--------------------- Export Types ------------------------------*/
+//
+// Ethernet packet
+//
+typedef struct tagSEthernetHeader {
+ BYTE abyDstAddr[U_ETHER_ADDR_LEN];
+ BYTE abySrcAddr[U_ETHER_ADDR_LEN];
+ WORD wType;
+}__attribute__ ((__packed__))
+SEthernetHeader, DEF* PSEthernetHeader;
+
+
+//
+// 802_3 packet
+//
+typedef struct tagS802_3Header {
+ BYTE abyDstAddr[U_ETHER_ADDR_LEN];
+ BYTE abySrcAddr[U_ETHER_ADDR_LEN];
+ WORD wLen;
+}__attribute__ ((__packed__))
+S802_3Header, DEF* PS802_3Header;
+
+//
+// 802_11 packet
+//
+typedef struct tagS802_11Header {
+ WORD wFrameCtl;
+ WORD wDurationID;
+ BYTE abyAddr1[U_ETHER_ADDR_LEN];
+ BYTE abyAddr2[U_ETHER_ADDR_LEN];
+ BYTE abyAddr3[U_ETHER_ADDR_LEN];
+ WORD wSeqCtl;
+ BYTE abyAddr4[U_ETHER_ADDR_LEN];
+}__attribute__ ((__packed__))
+S802_11Header, DEF* PS802_11Header;
+
+/*--------------------- Export Macros ------------------------------*/
+// Frame type macro
+
+#define IS_MULTICAST_ADDRESS(pbyEtherAddr) \
+ ((*(PBYTE)(pbyEtherAddr) & 0x01) == 1)
+
+#define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \
+ (*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \
+ (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \
+)
+
+#define IS_NULL_ADDRESS(pbyEtherAddr) ( \
+ (*(PDWORD)(pbyEtherAddr) == 0L) && \
+ (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \
+)
+
+#define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \
+ (*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \
+ (*(PWORD)((PBYTE)(pbyAddr1) + 4) == \
+ *(PWORD)((PBYTE)(pbyAddr2) + 4)) \
+)
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr);
+//BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr);
+BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength);
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __TETHER_H__
+
+
+
diff --git a/drivers/staging/vt6655/tkip.c b/drivers/staging/vt6655/tkip.c
new file mode 100644
index 000000000000..2ded8420c390
--- /dev/null
+++ b/drivers/staging/vt6655/tkip.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tkip.c
+ *
+ * Purpose: Implement functions for 802.11i TKIP
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Mar. 11, 2003
+ *
+ * Functions:
+ * TKIPvMixKey - Get TKIP RC4 Key from TK,TA, and TSC
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TKIP_H__)
+#include "tkip.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/* The Sbox is reduced to 2 16-bit wide tables, each with 256 entries. */
+/* The 2nd table is the same as the 1st but with the upper and lower */
+/* bytes swapped. To allow an endian tolerant implementation, the byte */
+/* halves have been expressed independently here. */
+const BYTE TKIP_Sbox_Lower[256] = {
+ 0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54,
+ 0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A,
+ 0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B,
+ 0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B,
+ 0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F,
+ 0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F,
+ 0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5,
+ 0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F,
+ 0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB,
+ 0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97,
+ 0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED,
+ 0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A,
+ 0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94,
+ 0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3,
+ 0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04,
+ 0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D,
+ 0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39,
+ 0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95,
+ 0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83,
+ 0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76,
+ 0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4,
+ 0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B,
+ 0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0,
+ 0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18,
+ 0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51,
+ 0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85,
+ 0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12,
+ 0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9,
+ 0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7,
+ 0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A,
+ 0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8,
+ 0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A
+};
+
+const BYTE TKIP_Sbox_Upper[256] = {
+ 0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91,
+ 0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC,
+ 0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB,
+ 0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B,
+ 0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83,
+ 0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A,
+ 0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F,
+ 0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA,
+ 0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B,
+ 0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13,
+ 0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6,
+ 0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85,
+ 0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11,
+ 0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B,
+ 0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1,
+ 0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF,
+ 0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E,
+ 0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6,
+ 0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B,
+ 0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD,
+ 0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8,
+ 0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2,
+ 0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49,
+ 0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10,
+ 0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97,
+ 0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F,
+ 0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C,
+ 0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27,
+ 0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33,
+ 0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5,
+ 0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0,
+ 0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C
+};
+
+
+//STKIPKeyManagement sTKIPKeyTable[MAX_TKIP_KEY];
+
+/*--------------------- Static Functions --------------------------*/
+unsigned int tkip_sbox(unsigned int index);
+unsigned int rotr1(unsigned int a);
+
+/*--------------------- Export Variables --------------------------*/
+
+/************************************************************/
+/* tkip_sbox() */
+/* Returns a 16 bit value from a 64K entry table. The Table */
+/* is synthesized from two 256 entry byte wide tables. */
+/************************************************************/
+unsigned int tkip_sbox(unsigned int index)
+{
+ unsigned int index_low;
+ unsigned int index_high;
+ unsigned int left, right;
+
+ index_low = (index % 256);
+ index_high = ((index >> 8) % 256);
+
+ left = TKIP_Sbox_Lower[index_low] + (TKIP_Sbox_Upper[index_low] * 256);
+ right = TKIP_Sbox_Upper[index_high] + (TKIP_Sbox_Lower[index_high] * 256);
+
+ return (left ^ right);
+};
+
+
+unsigned int rotr1(unsigned int a)
+{
+ unsigned int b;
+
+ if ((a & 0x01) == 0x01) {
+ b = (a >> 1) | 0x8000;
+ } else {
+ b = (a >> 1) & 0x7fff;
+ }
+ b = b % 65536;
+ return b;
+}
+
+
+/*
+ * Description: Caculate RC4Key fom TK, TA, and TSC
+ *
+ * Parameters:
+ * In:
+ * pbyTKey - TKey
+ * pbyTA - TA
+ * dwTSC - TSC
+ * Out:
+ * pbyRC4Key - RC4Key
+ *
+ * Return Value: none
+ *
+ */
+VOID TKIPvMixKey(
+ PBYTE pbyTKey,
+ PBYTE pbyTA,
+ WORD wTSC15_0,
+ DWORD dwTSC47_16,
+ PBYTE pbyRC4Key
+ )
+{
+ unsigned int p1k[5];
+// unsigned int ttak0, ttak1, ttak2, ttak3, ttak4;
+ unsigned int tsc0, tsc1, tsc2;
+ unsigned int ppk0, ppk1, ppk2, ppk3, ppk4, ppk5;
+ unsigned long int pnl,pnh;
+
+ int i, j;
+
+ pnl = wTSC15_0;
+ pnh = dwTSC47_16;
+
+ tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
+ tsc1 = (unsigned int)(pnh % 65536);
+ tsc2 = (unsigned int)(pnl % 65536); /* lsb */
+
+ /* Phase 1, step 1 */
+ p1k[0] = tsc1;
+ p1k[1] = tsc0;
+ p1k[2] = (unsigned int)(pbyTA[0] + (pbyTA[1]*256));
+ p1k[3] = (unsigned int)(pbyTA[2] + (pbyTA[3]*256));
+ p1k[4] = (unsigned int)(pbyTA[4] + (pbyTA[5]*256));
+
+ /* Phase 1, step 2 */
+ for (i=0; i<8; i++) {
+ j = 2*(i & 1);
+ p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*pbyTKey[1+j]) + pbyTKey[j])) % 65536 )) % 65536;
+ p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*pbyTKey[5+j]) + pbyTKey[4+j])) % 65536 )) % 65536;
+ p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*pbyTKey[9+j]) + pbyTKey[8+j])) % 65536 )) % 65536;
+ p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*pbyTKey[13+j]) + pbyTKey[12+j])) % 65536 )) % 65536;
+ p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*pbyTKey[1+j]) + pbyTKey[j]))) % 65536 )) % 65536;
+ p1k[4] = (p1k[4] + i) % 65536;
+ }
+ /* Phase 2, Step 1 */
+ ppk0 = p1k[0];
+ ppk1 = p1k[1];
+ ppk2 = p1k[2];
+ ppk3 = p1k[3];
+ ppk4 = p1k[4];
+ ppk5 = (p1k[4] + tsc2) % 65536;
+
+ /* Phase2, Step 2 */
+ ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) % 65536);
+ ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*pbyTKey[3]) + pbyTKey[2])) % 65536);
+ ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*pbyTKey[5]) + pbyTKey[4])) % 65536);
+ ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*pbyTKey[7]) + pbyTKey[6])) % 65536);
+ ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*pbyTKey[9]) + pbyTKey[8])) % 65536);
+ ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*pbyTKey[11]) + pbyTKey[10])) % 65536);
+
+ ppk0 = ppk0 + rotr1(ppk5 ^ ((256*pbyTKey[13]) + pbyTKey[12]));
+ ppk1 = ppk1 + rotr1(ppk0 ^ ((256*pbyTKey[15]) + pbyTKey[14]));
+ ppk2 = ppk2 + rotr1(ppk1);
+ ppk3 = ppk3 + rotr1(ppk2);
+ ppk4 = ppk4 + rotr1(ppk3);
+ ppk5 = ppk5 + rotr1(ppk4);
+
+ /* Phase 2, Step 3 */
+ pbyRC4Key[0] = (tsc2 >> 8) % 256;
+ pbyRC4Key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
+ pbyRC4Key[2] = tsc2 % 256;
+ pbyRC4Key[3] = ((ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) >> 1) % 256;
+
+ pbyRC4Key[4] = ppk0 % 256;
+ pbyRC4Key[5] = (ppk0 >> 8) % 256;
+
+ pbyRC4Key[6] = ppk1 % 256;
+ pbyRC4Key[7] = (ppk1 >> 8) % 256;
+
+ pbyRC4Key[8] = ppk2 % 256;
+ pbyRC4Key[9] = (ppk2 >> 8) % 256;
+
+ pbyRC4Key[10] = ppk3 % 256;
+ pbyRC4Key[11] = (ppk3 >> 8) % 256;
+
+ pbyRC4Key[12] = ppk4 % 256;
+ pbyRC4Key[13] = (ppk4 >> 8) % 256;
+
+ pbyRC4Key[14] = ppk5 % 256;
+ pbyRC4Key[15] = (ppk5 >> 8) % 256;
+}
diff --git a/drivers/staging/vt6655/tkip.h b/drivers/staging/vt6655/tkip.h
new file mode 100644
index 000000000000..dc8382b67019
--- /dev/null
+++ b/drivers/staging/vt6655/tkip.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tkip.h
+ *
+ * Purpose: Implement functions for 802.11i TKIP
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Mar. 11, 2003
+ *
+ */
+
+
+#ifndef __TKIP_H__
+#define __TKIP_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+#define TKIP_KEY_LEN 16
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+VOID TKIPvMixKey(
+ PBYTE pbyTKey,
+ PBYTE pbyTA,
+ WORD wTSC15_0,
+ DWORD dwTSC47_16,
+ PBYTE pbyRC4Key
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __TKIP_H__
+
+
+
diff --git a/drivers/staging/vt6655/tmacro.h b/drivers/staging/vt6655/tmacro.h
new file mode 100644
index 000000000000..3d932a258dd1
--- /dev/null
+++ b/drivers/staging/vt6655/tmacro.h
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: tmacro.h
+ *
+ * Purpose: define basic common types and macros
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+
+#ifndef __TMACRO_H__
+#define __TMACRO_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+
+/****** Common helper macros ***********************************************/
+
+#if !defined(LONIBBLE)
+#define LONIBBLE(b) ((BYTE)(b) & 0x0F)
+#endif
+#if !defined(HINIBBLE)
+#define HINIBBLE(b) ((BYTE)(((WORD)(b) >> 4) & 0x0F))
+#endif
+
+#if !defined(LOBYTE)
+#define LOBYTE(w) ((BYTE)(w))
+#endif
+#if !defined(HIBYTE)
+#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
+#endif
+
+#if !defined(LOWORD)
+#define LOWORD(d) ((WORD)(d))
+#endif
+#if !defined(HIWORD)
+#define HIWORD(d) ((WORD)((((DWORD)(d)) >> 16) & 0xFFFF))
+#endif
+
+#define LODWORD(q) ((q).u.dwLowDword)
+#define HIDWORD(q) ((q).u.dwHighDword)
+
+
+
+#if !defined(MAKEBYTE)
+#define MAKEBYTE(ln, hn) ((BYTE)(((BYTE)(ln) & 0x0F) | ((BYTE)(hn) << 4)))
+#endif
+#if !defined(MAKEWORD)
+#define MAKEWORD(lb, hb) ((WORD)(((BYTE)(lb)) | (((WORD)((BYTE)(hb))) << 8)))
+#endif
+#if !defined(MAKEDWORD)
+#define MAKEDWORD(lw, hw) ((DWORD)(((WORD)(lw)) | (((DWORD)((WORD)(hw))) << 16)))
+#endif
+#if !defined(MAKEQWORD)
+#define MAKEQWORD(ld, hd, pq) {pq->u.dwLowDword = ld; pq->u.dwHighDword = hd;}
+#endif
+
+#if !defined(MAKELONG)
+#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
+#endif
+
+
+
+// Bytes Reverse: big endian to little endian convert
+#if !defined(REVWORD)
+#define REVWORD(w) ((WORD)( ((WORD)(w) >> 8) | ((WORD)(w) << 8) ))
+#endif
+#if !defined(REVDWORD)
+#define REVDWORD(d) (MAKEDWORD(MAKEWORD(HIBYTE(HIWORD(d)),LOBYTE(HIWORD(d))),MAKEWORD(HIBYTE(LOWORD(d)),LOBYTE(LOWORD(d)))))
+#endif
+
+/* map to known network names */
+/*
+#define ntohs(x) REVWORD(x)
+#define ntohl(x) REVDWORD(x)
+#define htons(x) REVWORD(x)
+#define htonl(x) REVDWORD(x)
+*/
+
+
+/*
+#ifndef NOMINMAX
+#ifndef max
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+#endif // NOMINMAX
+*/
+
+
+
+/****** Misc macros ********************************************************/
+
+// get the field offset in the type(struct, class, ...)
+#define OFFSET(type, field) ((int)(&((type NEAR*)1)->field)-1)
+
+
+/* string equality shorthand */
+#define STR_EQ(x, y) (strcmp(x, y) == 0)
+#define STR_NE(x, y) (strcmp(x, y) != 0)
+
+
+// calculate element # of array
+#define ELEMENT_NUM(array) (sizeof(array) / sizeof(array[0]))
+//#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+
+// null statement
+#define NULL_FUNC()
+
+
+/* Since not all compilers support structure assignment, the ASSIGN()
+ * macro is used. This controls how it's actually implemented.
+ */
+#ifdef NOSTRUCTASSIGN /* Version for old compilers that don't support it */
+#define ASSIGN(a,b) memcpy((char *)&(a),(char *)&(b),sizeof(b);
+#else /* Version for compilers that do */
+#define ASSIGN(a,b) ((a) = (b))
+#endif
+
+
+
+
+#endif // __TMACRO_H__
+
+
diff --git a/drivers/staging/vt6655/tpci.h b/drivers/staging/vt6655/tpci.h
new file mode 100644
index 000000000000..4a1c8ed75ca6
--- /dev/null
+++ b/drivers/staging/vt6655/tpci.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: tpci.h
+ *
+ * Purpose: PCI routines
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+
+#ifndef __TPCI_H__
+#define __TPCI_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+#define MAX_PCI_BUS 4 // max. # of PCI bus that we support
+#define MAX_PCI_DEVICE 32 // max. # of PCI devices
+
+
+//
+// Registers in the PCI configuration space
+//
+#define PCI_REG_VENDOR_ID 0x00 //
+#define PCI_REG_DEVICE_ID 0x02 //
+#define PCI_REG_COMMAND 0x04 //
+#define PCI_REG_STATUS 0x06 //
+#define PCI_REG_REV_ID 0x08 //
+#define PCI_REG_CLASS_CODE 0x09 //
+#define PCI_REG_CACHELINE_SIZE 0x0C //
+#define PCI_REG_LAT_TIMER 0x0D //
+#define PCI_REG_HDR_TYPE 0x0E //
+#define PCI_REG_BIST 0x0F //
+
+#define PCI_REG_BAR0 0x10 //
+#define PCI_REG_BAR1 0x14 //
+#define PCI_REG_BAR2 0x18 //
+#define PCI_REG_CARDBUS_CIS_PTR 0x28 //
+
+#define PCI_REG_SUB_VEN_ID 0x2C //
+#define PCI_REG_SUB_SYS_ID 0x2E //
+#define PCI_REG_EXP_ROM_BAR 0x30 //
+#define PCI_REG_CAP 0x34 //
+
+#define PCI_REG_INT_LINE 0x3C //
+#define PCI_REG_INT_PIN 0x3D //
+#define PCI_REG_MIN_GNT 0x3E //
+#define PCI_REG_MAX_LAT 0x3F //
+
+#define PCI_REG_MAX_SIZE 0x100 // maximun total PCI registers
+
+
+//
+// Bits in the COMMAND register
+//
+#define COMMAND_BUSM 0x04 //
+#define COMMAND_WAIT 0x80 //
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+// macro MAKE Bus Dev Fun ID into WORD
+#define MAKE_BDF_TO_WORD(byBusId, byDevId, byFunId) \
+ MAKEWORD( \
+ ((((BYTE)(byDevId)) & 0x1F) << 3) + \
+ (((BYTE)(byFunId)) & 0x07), \
+ (byBusId) \
+ )
+
+#define GET_BUSID(wBusDevFunId) \
+ HIBYTE(wBusDevFunId)
+
+#define GET_DEVID(wBusDevFunId) \
+ (LOBYTE(wBusDevFunId) >> 3)
+
+#define GET_FUNID(wBusDevFunId) \
+ (LOBYTE(wBusDevFunId) & 0x07)
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+
+#endif // __TPCI_H__
+
+
diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h
new file mode 100644
index 000000000000..1f26702cabf6
--- /dev/null
+++ b/drivers/staging/vt6655/ttype.h
@@ -0,0 +1,386 @@
+/*
+ * File: ttype.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Purpose: define basic common types and macros
+ *
+ * Author: Tevin Chen
+ *
+ * Date: May 21, 1996
+ *
+ */
+
+
+#ifndef __TTYPE_H__
+#define __TTYPE_H__
+
+
+/******* Common definitions and typedefs ***********************************/
+
+#ifndef VOID
+#define VOID void
+#endif
+
+#ifndef CONST
+#define CONST const
+#endif
+
+#ifndef STATIC
+#define STATIC static
+#endif
+
+#ifndef IN
+#define IN
+#endif
+
+#ifndef OUT
+#define OUT
+#endif
+
+#ifndef TxInSleep
+#define TxInSleep
+#endif
+#if! defined(__CPU8051)
+typedef int BOOL;
+#else // __CPU8051
+#define BOOL int
+#endif // __CPU8051
+
+#if !defined(TRUE)
+#define TRUE 1
+#endif
+#if !defined(FALSE)
+#define FALSE 0
+#endif
+
+
+#if !defined(SUCCESS)
+#define SUCCESS 0
+#endif
+#if !defined(FAILED)
+#define FAILED -1
+#endif
+
+//2007-0809-01<Add>by MikeLiu
+#ifndef update_BssList
+#define update_BssList
+#endif
+
+
+
+#ifndef WPA_SM_Transtatus
+#define WPA_SM_Transtatus
+#endif
+
+#ifndef Calcu_LinkQual
+#define Calcu_LinkQual
+#endif
+
+#ifndef Calcu_LinkQual
+#define Calcu_LinkQual
+#endif
+
+/****** Simple typedefs ***************************************************/
+
+#if! defined(__CPU8051)
+
+/* These lines assume that your compiler's longs are 32 bits and
+ * shorts are 16 bits. It is already assumed that chars are 8 bits,
+ * but it doesn't matter if they're signed or unsigned.
+ */
+
+typedef signed char I8; /* 8-bit signed integer */
+typedef signed short I16; /* 16-bit signed integer */
+typedef signed long I32; /* 32-bit signed integer */
+
+typedef unsigned char U8; /* 8-bit unsigned integer */
+typedef unsigned short U16; /* 16-bit unsigned integer */
+typedef unsigned long U32; /* 32-bit unsigned integer */
+
+
+#if defined(__WIN32)
+typedef signed __int64 I64; /* 64-bit signed integer */
+typedef unsigned __int64 U64; /* 64-bit unsigned integer */
+#endif // __WIN32
+
+
+typedef char CHAR;
+typedef signed short SHORT;
+typedef signed int INT;
+typedef signed long LONG;
+
+typedef unsigned char UCHAR;
+typedef unsigned short USHORT;
+typedef unsigned int UINT;
+typedef unsigned long ULONG;
+typedef unsigned long long ULONGLONG; //64 bit
+typedef unsigned long long ULONGULONG;
+
+
+
+typedef unsigned char BYTE; // 8-bit
+typedef unsigned short WORD; // 16-bit
+typedef unsigned long DWORD; // 32-bit
+
+// QWORD is for those situation that we want
+// an 8-byte-aligned 8 byte long structure
+// which is NOT really a floating point number.
+typedef union tagUQuadWord {
+ struct {
+ DWORD dwLowDword;
+ DWORD dwHighDword;
+ } u;
+ double DoNotUseThisField;
+} UQuadWord;
+typedef UQuadWord QWORD; // 64-bit
+
+
+
+#ifndef _TCHAR_DEFINED
+typedef char TCHAR;
+typedef char* PTCHAR;
+typedef unsigned char TBYTE;
+typedef unsigned char* PTBYTE;
+#define _TCHAR_DEFINED
+#endif
+
+#else // __CPU8051
+
+#define U8 unsigned char
+#define U16 unsigned short
+#define U32 unsigned long
+
+#define USHORT unsigned short
+#define UINT unsigned int
+
+#define BYTE unsigned char
+#define WORD unsigned short
+#define DWORD unsigned long
+
+
+#endif // __CPU8051
+
+
+// maybe this should be defined in <limits.h>
+#define U8_MAX 0xFFU
+#define U16_MAX 0xFFFFU
+#define U32_MAX 0xFFFFFFFFUL
+
+#define BYTE_MAX 0xFFU
+#define WORD_MAX 0xFFFFU
+#define DWORD_MAX 0xFFFFFFFFUL
+
+
+
+
+/******* 32-bit vs. 16-bit definitions and typedefs ************************/
+
+#if !defined(NULL)
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL ((void *)0)
+#endif // __cplusplus
+#endif // !NULL
+
+
+
+
+#if defined(__WIN32) || defined(__CPU8051)
+
+#if !defined(FAR)
+#define FAR
+#endif
+#if !defined(NEAR)
+#define NEAR
+#endif
+#if !defined(DEF)
+#define DEF
+#endif
+#if !defined(CALLBACK)
+#define CALLBACK
+#endif
+
+#else // !__WIN32__
+
+#if !defined(FAR)
+#define FAR
+#endif
+#if !defined(NEAR)
+#define NEAR
+#endif
+#if !defined(DEF)
+// default pointer type is FAR, if you want near pointer just redefine it to NEAR
+#define DEF
+#endif
+#if !defined(CALLBACK)
+#define CALLBACK
+#endif
+
+#endif // !__WIN32__
+
+
+
+
+/****** Common pointer types ***********************************************/
+
+#if! defined(__CPU8051)
+
+typedef signed char DEF* PI8;
+typedef signed short DEF* PI16;
+typedef signed long DEF* PI32;
+
+typedef unsigned char DEF* PU8;
+typedef unsigned short DEF* PU16;
+typedef unsigned long DEF* PU32;
+
+#if defined(__WIN32)
+typedef signed __int64 DEF* PI64;
+typedef unsigned __int64 DEF* PU64;
+#endif // __WIN32
+
+#if !defined(_WIN64)
+typedef unsigned long ULONG_PTR; // 32-bit
+typedef unsigned long DWORD_PTR; // 32-bit
+#endif // _WIN64
+
+
+// boolean pointer
+typedef int DEF* PBOOL;
+typedef int NEAR* NPBOOL;
+typedef int FAR* LPBOOL;
+
+typedef int DEF* PINT;
+typedef int NEAR* NPINT;
+typedef int FAR* LPINT;
+typedef const int DEF* PCINT;
+typedef const int NEAR* NPCINT;
+typedef const int FAR* LPCINT;
+
+typedef unsigned int DEF* PUINT;
+typedef const unsigned int DEF* PCUINT;
+
+typedef long DEF* PLONG;
+typedef long NEAR* NPLONG;
+typedef long FAR* LPLONG;
+//typedef const long DEF* PCLONG;
+typedef const long NEAR* NPCLONG;
+typedef const long FAR* LPCLONG;
+
+typedef BYTE DEF* PBYTE;
+typedef BYTE NEAR* NPBYTE;
+typedef BYTE FAR* LPBYTE;
+typedef const BYTE DEF* PCBYTE;
+typedef const BYTE NEAR* NPCBYTE;
+typedef const BYTE FAR* LPCBYTE;
+
+typedef WORD DEF* PWORD;
+typedef WORD NEAR* NPWORD;
+typedef WORD FAR* LPWORD;
+typedef const WORD DEF* PCWORD;
+typedef const WORD NEAR* NPCWORD;
+typedef const WORD FAR* LPCWORD;
+
+typedef DWORD DEF* PDWORD;
+typedef DWORD NEAR* NPDWORD;
+typedef DWORD FAR* LPDWORD;
+typedef const DWORD DEF* PCDWORD;
+typedef const DWORD NEAR* NPCDWORD;
+typedef const DWORD FAR* LPCDWORD;
+
+typedef QWORD DEF* PQWORD;
+typedef QWORD NEAR* NPQWORD;
+typedef QWORD FAR* LPQWORD;
+typedef const QWORD DEF* PCQWORD;
+typedef const QWORD NEAR* NPCQWORD;
+typedef const QWORD FAR* LPCQWORD;
+
+typedef void DEF* PVOID;
+typedef void NEAR* NPVOID;
+typedef void FAR* LPVOID;
+
+// handle declaration
+#ifdef STRICT
+typedef void *HANDLE;
+#else
+typedef PVOID HANDLE;
+#endif
+
+//
+// ANSI (Single-byte Character) types
+//
+typedef char DEF* PCH;
+typedef char NEAR* NPCH;
+typedef char FAR* LPCH;
+typedef const char DEF* PCCH;
+typedef const char NEAR* NPCCH;
+typedef const char FAR* LPCCH;
+
+typedef char DEF* PSTR;
+typedef char NEAR* NPSTR;
+typedef char FAR* LPSTR;
+typedef const char DEF* PCSTR;
+typedef const char NEAR* NPCSTR;
+typedef const char FAR* LPCSTR;
+
+#endif // !__CPU8051
+
+
+
+
+/****** Misc definitions, types ********************************************/
+
+// parameter prefix
+#ifndef IN
+#define IN
+#endif
+
+#ifndef OUT
+#define OUT
+#endif
+
+
+// unreferenced parameter macro to avoid warning message in MS C
+#if defined(__TURBOC__)
+
+//you should use "#pragma argsused" to avoid warning message in Borland C
+#ifndef UNREFERENCED_PARAMETER
+#define UNREFERENCED_PARAMETER(x)
+#endif
+
+#else
+
+#ifndef UNREFERENCED_PARAMETER
+//#define UNREFERENCED_PARAMETER(x) x
+#define UNREFERENCED_PARAMETER(x)
+#endif
+
+#endif
+
+
+// in-line assembly prefix
+#if defined(__TURBOC__)
+#define ASM asm
+#else // !__TURBOC__
+#define ASM _asm
+#endif // !__TURBOC__
+
+
+
+
+#endif // __TTYPE_H__
+
+
diff --git a/drivers/staging/vt6655/umem.h b/drivers/staging/vt6655/umem.h
new file mode 100644
index 000000000000..2c3eafa038e7
--- /dev/null
+++ b/drivers/staging/vt6655/umem.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: umem.h
+ *
+ * Purpose: Define Memory macros
+ *
+ * Author: Tevin Chen
+ *
+ * Date: Mar 17, 1997
+ *
+ */
+
+
+#ifndef __UMEM_H__
+#define __UMEM_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+// 4-byte memory tag
+#define MEM_TAG 'mTEW'
+
+// Macros used for memory allocation and deallocation.
+
+
+
+#define ZERO_MEMORY(Destination,Length) { \
+ memset((PVOID)(Destination), \
+ 0, \
+ (ULONG)(Length) \
+ ); \
+}
+
+#define MEMvCopy(pvDest, pvSource, uCount) { \
+ memcpy((PVOID)(pvDest), \
+ (PVOID)(pvSource), \
+ (ULONG)(uCount) \
+ ); \
+}
+
+
+#define MEMEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+
+#endif // __UMEM_H__
+
+
diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h
new file mode 100644
index 000000000000..113fc2c88c11
--- /dev/null
+++ b/drivers/staging/vt6655/upc.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: upc.h
+ *
+ * Purpose: Macros to access device
+ *
+ * Author: Tevin Chen
+ *
+ * Date: Mar 17, 1997
+ *
+ */
+
+
+#ifndef __UPC_H__
+#define __UPC_H__
+
+#if !defined(DEVICE_H)
+#include "device.h"
+#endif
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+//
+// For IO mapped
+//
+
+#ifdef IO_MAP
+
+#define VNSvInPortB(dwIOAddress, pbyData) { \
+ *(pbyData) = inb(dwIOAddress); \
+}
+
+
+#define VNSvInPortW(dwIOAddress, pwData) { \
+ *(pwData) = inw(dwIOAddress); \
+}
+
+#define VNSvInPortD(dwIOAddress, pdwData) { \
+ *(pdwData) = inl(dwIOAddress); \
+}
+
+
+#define VNSvOutPortB(dwIOAddress, byData) { \
+ outb(byData, dwIOAddress); \
+}
+
+
+#define VNSvOutPortW(dwIOAddress, wData) { \
+ outw(wData, dwIOAddress); \
+}
+
+#define VNSvOutPortD(dwIOAddress, dwData) { \
+ outl(dwData, dwIOAddress); \
+}
+
+#else
+
+//
+// For memory mapped IO
+//
+
+
+#define VNSvInPortB(dwIOAddress, pbyData) { \
+ volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
+ *(pbyData) = readb(pbyAddr); \
+}
+
+
+#define VNSvInPortW(dwIOAddress, pwData) { \
+ volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
+ *(pwData) = readw(pwAddr); \
+}
+
+#define VNSvInPortD(dwIOAddress, pdwData) { \
+ volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
+ *(pdwData) = readl(pdwAddr); \
+}
+
+
+#define VNSvOutPortB(dwIOAddress, byData) { \
+ volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
+ writeb((BYTE)byData, pbyAddr); \
+}
+
+
+#define VNSvOutPortW(dwIOAddress, wData) { \
+ volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
+ writew((WORD)wData, pwAddr); \
+}
+
+#define VNSvOutPortD(dwIOAddress, dwData) { \
+ volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
+ writel((DWORD)dwData, pdwAddr); \
+}
+
+#endif
+
+
+//
+// ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
+//
+#define PCBvInPortB(dwIOAddress, pbyData) { \
+ *(pbyData) = inb(dwIOAddress); \
+}
+
+#define PCBvInPortW(dwIOAddress, pwData) { \
+ *(pwData) = inw(dwIOAddress); \
+}
+
+#define PCBvInPortD(dwIOAddress, pdwData) { \
+ *(pdwData) = inl(dwIOAddress); \
+}
+
+#define PCBvOutPortB(dwIOAddress, byData) { \
+ outb(byData, dwIOAddress); \
+}
+
+#define PCBvOutPortW(dwIOAddress, wData) { \
+ outw(wData, dwIOAddress); \
+}
+
+#define PCBvOutPortD(dwIOAddress, dwData) { \
+ outl(dwData, dwIOAddress); \
+}
+
+
+#define PCAvDelayByIO(uDelayUnit) { \
+ BYTE byData; \
+ ULONG ii; \
+ \
+ if (uDelayUnit <= 50) { \
+ udelay(uDelayUnit); \
+ } \
+ else { \
+ for (ii = 0; ii < (uDelayUnit); ii++) \
+ byData = inb(0x61); \
+ } \
+}
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+
+#endif // __UPC_H__
+
diff --git a/drivers/staging/vt6655/vntconfiguration.dat b/drivers/staging/vt6655/vntconfiguration.dat
new file mode 100644
index 000000000000..0064ddce7c11
--- /dev/null
+++ b/drivers/staging/vt6655/vntconfiguration.dat
@@ -0,0 +1 @@
+ZONETYPE=EUROPE \ No newline at end of file
diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c
new file mode 100644
index 000000000000..58a1ba0eac07
--- /dev/null
+++ b/drivers/staging/vt6655/vntwifi.c
@@ -0,0 +1,832 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: vntwifi.c
+ *
+ * Purpose: export functions for vntwifi lib
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ * Author: Yiching Chen
+ *
+ * Date: feb. 2, 2005
+ *
+ */
+
+#if !defined(__VNTWIFI_H__)
+#include "vntwifi.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+
+
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__IEEE11h_H__)
+#include "IEEE11h.h"
+#endif
+#if !defined(__COUNTRY_H__)
+#include "country.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+//#define PLICE_DEBUG
+
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+//static int msglevel =MSG_LEVEL_INFO;
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+/*+
+ *
+ * Description:
+ * Set Operation Mode
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * eOPMode - Opreation Mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+VNTWIFIvSetOPMode (
+ IN PVOID pMgmtHandle,
+ IN WMAC_CONFIG_MODE eOPMode
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ pMgmt->eConfigMode = eOPMode;
+}
+
+
+/*+
+ *
+ * Description:
+ * Set Operation Mode
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * wBeaconPeriod - Beacon Period
+ * wATIMWindow - ATIM window
+ * uChannel - channel number
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+VNTWIFIvSetIBSSParameter (
+ IN PVOID pMgmtHandle,
+ IN WORD wBeaconPeriod,
+ IN WORD wATIMWindow,
+ IN UINT uChannel
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
+ pMgmt->wIBSSATIMWindow = wATIMWindow;
+ pMgmt->uIBSSChannel = uChannel;
+}
+
+/*+
+ *
+ * Description:
+ * Get current SSID
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * Out:
+ * none
+ *
+ * Return Value: current SSID pointer.
+ *
+-*/
+PWLAN_IE_SSID
+VNTWIFIpGetCurrentSSID (
+ IN PVOID pMgmtHandle
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+ return((PWLAN_IE_SSID) pMgmt->abyCurrSSID);
+}
+
+/*+
+ *
+ * Description:
+ * Get current link channel
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * Out:
+ * none
+ *
+ * Return Value: current Channel.
+ *
+-*/
+UINT
+VNTWIFIpGetCurrentChannel (
+ IN PVOID pMgmtHandle
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+ if (pMgmtHandle != NULL) {
+ return (pMgmt->uCurrChannel);
+ }
+ return 0;
+}
+
+/*+
+ *
+ * Description:
+ * Get current Assoc ID
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * Out:
+ * none
+ *
+ * Return Value: current Assoc ID
+ *
+-*/
+WORD
+VNTWIFIwGetAssocID (
+ IN PVOID pMgmtHandle
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+ return(pMgmt->wCurrAID);
+}
+
+
+
+/*+
+ *
+ * Description:
+ * This routine return max support rate of IES
+ *
+ * Parameters:
+ * In:
+ * pSupportRateIEs
+ * pExtSupportRateIEs
+ *
+ * Out:
+ *
+ * Return Value: max support rate
+ *
+-*/
+BYTE
+VNTWIFIbyGetMaxSupportRate (
+ IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
+ IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
+ )
+{
+ BYTE byMaxSupportRate = RATE_1M;
+ BYTE bySupportRate = RATE_1M;
+ UINT ii = 0;
+
+ if (pSupportRateIEs) {
+ for (ii = 0; ii < pSupportRateIEs->len; ii++) {
+ bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
+ if (bySupportRate > byMaxSupportRate) {
+ byMaxSupportRate = bySupportRate;
+ }
+ }
+ }
+ if (pExtSupportRateIEs) {
+ for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
+ bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
+ if (bySupportRate > byMaxSupportRate) {
+ byMaxSupportRate = bySupportRate;
+ }
+ }
+ }
+
+ return byMaxSupportRate;
+}
+
+/*+
+ *
+ * Description:
+ * This routine return data rate of ACK packtet
+ *
+ * Parameters:
+ * In:
+ * byRxDataRate
+ * pSupportRateIEs
+ * pExtSupportRateIEs
+ *
+ * Out:
+ *
+ * Return Value: max support rate
+ *
+-*/
+BYTE
+VNTWIFIbyGetACKTxRate (
+ IN BYTE byRxDataRate,
+ IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
+ IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
+ )
+{
+ BYTE byMaxAckRate;
+ BYTE byBasicRate;
+ UINT ii;
+
+ if (byRxDataRate <= RATE_11M) {
+ byMaxAckRate = RATE_1M;
+ } else {
+ // 24M is mandatory for 802.11a and 802.11g
+ byMaxAckRate = RATE_24M;
+ }
+ if (pSupportRateIEs) {
+ for (ii = 0; ii < pSupportRateIEs->len; ii++) {
+ if (pSupportRateIEs->abyRates[ii] & 0x80) {
+ byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
+ if ((byBasicRate <= byRxDataRate) &&
+ (byBasicRate > byMaxAckRate)) {
+ byMaxAckRate = byBasicRate;
+ }
+ }
+ }
+ }
+ if (pExtSupportRateIEs) {
+ for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
+ if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
+ byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
+ if ((byBasicRate <= byRxDataRate) &&
+ (byBasicRate > byMaxAckRate)) {
+ byMaxAckRate = byBasicRate;
+ }
+ }
+ }
+ }
+
+ return byMaxAckRate;
+}
+
+/*+
+ *
+ * Description:
+ * Set Authentication Mode
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * eAuthMode - Authentication mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+VNTWIFIvSetAuthenticationMode (
+ IN PVOID pMgmtHandle,
+ IN WMAC_AUTHENTICATION_MODE eAuthMode
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ pMgmt->eAuthenMode = eAuthMode;
+ if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
+ (eAuthMode == WMAC_AUTH_AUTO)) {
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ } else {
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ }
+}
+
+/*+
+ *
+ * Description:
+ * Set Encryption Mode
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - pointer to management object
+ * eAuthMode - Authentication mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+VNTWIFIvSetEncryptionMode (
+ IN PVOID pMgmtHandle,
+ IN WMAC_ENCRYPTION_MODE eEncryptionMode
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ pMgmt->eEncryptionMode = eEncryptionMode;
+ if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
+ (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
+ (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled) ) {
+ pMgmt->bPrivacyInvoked = TRUE;
+ } else {
+ pMgmt->bPrivacyInvoked = FALSE;
+ }
+}
+
+
+
+BOOL
+VNTWIFIbConfigPhyMode (
+ IN PVOID pMgmtHandle,
+ IN CARD_PHY_TYPE ePhyType
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ if ((ePhyType != PHY_TYPE_AUTO) &&
+ (ePhyType != pMgmt->eCurrentPHYMode)) {
+ if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL)==TRUE) {
+ pMgmt->eCurrentPHYMode = ePhyType;
+ } else {
+ return(FALSE);
+ }
+ }
+ pMgmt->eConfigPHYMode = ePhyType;
+ return(TRUE);
+}
+
+
+VOID
+VNTWIFIbGetConfigPhyMode (
+ IN PVOID pMgmtHandle,
+ OUT PVOID pePhyType
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ if ((pMgmt != NULL) && (pePhyType != NULL)) {
+ *(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
+ }
+}
+
+/*+
+ *
+ * Description:
+ * Clear BSS List Database except current assoc BSS
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - Management Object structure
+ * bLinkPass - Current Link status
+ * Out:
+ *
+ * Return Value: None.
+ *
+-*/
+
+
+/*+
+ *
+ * Description:
+ * Query BSS List in management database
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - Management Object structure
+ * Out:
+ * puBSSCount - BSS count
+ * pvFirstBSS - pointer to first BSS
+ *
+ * Return Value: None.
+ *
+-*/
+
+VOID
+VNTWIFIvQueryBSSList (
+ IN PVOID pMgmtHandle,
+ OUT PUINT puBSSCount,
+ OUT PVOID *pvFirstBSS
+ )
+{
+ UINT ii = 0;
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+ PKnownBSS pBSS = NULL;
+ UINT uCount = 0;
+
+ *pvFirstBSS = NULL;
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pBSS = &(pMgmt->sBSSList[ii]);
+ if (!pBSS->bActive) {
+ continue;
+ }
+ if (*pvFirstBSS == NULL) {
+ *pvFirstBSS = &(pMgmt->sBSSList[ii]);
+ }
+ uCount++;
+ }
+ *puBSSCount = uCount;
+}
+
+
+
+
+VOID
+VNTWIFIvGetNextBSS (
+ IN PVOID pMgmtHandle,
+ IN PVOID pvCurrentBSS,
+ OUT PVOID *pvNextBSS
+ )
+{
+ PKnownBSS pBSS = (PKnownBSS) pvCurrentBSS;
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ *pvNextBSS = NULL;
+
+ while (*pvNextBSS == NULL) {
+ pBSS++;
+ if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) {
+ return;
+ }
+ if (pBSS->bActive == TRUE) {
+ *pvNextBSS = pBSS;
+ return;
+ }
+ }
+}
+
+
+
+
+
+/*+
+ *
+ * Description:
+ * Update Tx attemps, Tx failure counter in Node DB
+ *
+ * In:
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+VOID
+VNTWIFIvUpdateNodeTxCounter(
+ IN PVOID pMgmtHandle,
+ IN PBYTE pbyDestAddress,
+ IN BOOL bTxOk,
+ IN WORD wRate,
+ IN PBYTE pbyTxFailCount
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+ UINT uNodeIndex = 0;
+ UINT ii;
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
+ if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == FALSE) {
+ return;
+ }
+ }
+ pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
+ if (bTxOk == TRUE) {
+ // transmit success, TxAttempts at least plus one
+ pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
+ pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
+ } else {
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
+ }
+ pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
+ for(ii=0;ii<MAX_RATE;ii++) {
+ pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
+ }
+ return;
+}
+
+
+VOID
+VNTWIFIvGetTxRate(
+ IN PVOID pMgmtHandle,
+ IN PBYTE pbyDestAddress,
+ OUT PWORD pwTxDataRate,
+ OUT PBYTE pbyACKRate,
+ OUT PBYTE pbyCCKBasicRate,
+ OUT PBYTE pbyOFDMBasicRate
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+ UINT uNodeIndex = 0;
+ WORD wTxDataRate = RATE_1M;
+ BYTE byACKRate = RATE_1M;
+ BYTE byCCKBasicRate = RATE_1M;
+ BYTE byOFDMBasicRate = RATE_24M;
+ PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
+ PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
+
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
+ // Adhoc Tx rate decided from node DB
+ if(BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
+ wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
+ pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
+ pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
+ } else {
+ if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
+ wTxDataRate = RATE_2M;
+ } else {
+ wTxDataRate = RATE_24M;
+ }
+ pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
+ pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
+ }
+ } else { // Infrastructure: rate decided from AP Node, index = 0
+
+ wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
+#ifdef PLICE_DEBUG
+ printk("GetTxRate:AP MAC is %02x:%02x:%02x:%02x:%02x:%02x,TxRate is %d\n",
+ pMgmt->sNodeDBTable[0].abyMACAddr[0],pMgmt->sNodeDBTable[0].abyMACAddr[1],
+ pMgmt->sNodeDBTable[0].abyMACAddr[2],pMgmt->sNodeDBTable[0].abyMACAddr[3],
+ pMgmt->sNodeDBTable[0].abyMACAddr[4],pMgmt->sNodeDBTable[0].abyMACAddr[5],wTxDataRate);
+#endif
+
+
+ pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
+ pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
+ }
+ byACKRate = VNTWIFIbyGetACKTxRate( (BYTE) wTxDataRate,
+ pSupportRateIEs,
+ pExtSupportRateIEs
+ );
+ if (byACKRate > (BYTE) wTxDataRate) {
+ byACKRate = (BYTE) wTxDataRate;
+ }
+ byCCKBasicRate = VNTWIFIbyGetACKTxRate( RATE_11M,
+ pSupportRateIEs,
+ pExtSupportRateIEs
+ );
+ byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
+ pSupportRateIEs,
+ pExtSupportRateIEs
+ );
+ *pwTxDataRate = wTxDataRate;
+ *pbyACKRate = byACKRate;
+ *pbyCCKBasicRate = byCCKBasicRate;
+ *pbyOFDMBasicRate = byOFDMBasicRate;
+ return;
+}
+
+BYTE
+VNTWIFIbyGetKeyCypher(
+ IN PVOID pMgmtHandle,
+ IN BOOL bGroupKey
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
+
+ if (bGroupKey == TRUE) {
+ return (pMgmt->byCSSGK);
+ } else {
+ return (pMgmt->byCSSPK);
+ }
+}
+
+
+/*
+BOOL
+VNTWIFIbInit(
+ IN PVOID pAdapterHandler,
+ OUT PVOID *pMgmtHandler
+ )
+{
+
+ PSMgmtObject pMgmt = NULL;
+ UINT ii;
+
+
+ pMgmt = (PSMgmtObject)kmalloc(sizeof(SMgmtObject), (int)GFP_ATOMIC);
+ if (pMgmt == NULL) {
+ *pMgmtHandler = NULL;
+ return FALSE;
+ }
+
+ memset(pMgmt, 0, sizeof(SMgmtObject));
+ pMgmt->pAdapter = (PVOID) pAdapterHandler;
+
+ // should initial MAC address abyMACAddr
+ for(ii=0;ii<WLAN_BSSID_LEN;ii++) {
+ pMgmt->abyDesireBSSID[ii] = 0xFF;
+ }
+ pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
+ pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0];
+ pMgmt->byCSSPK = KEY_CTL_NONE;
+ pMgmt->byCSSGK = KEY_CTL_NONE;
+ pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
+
+ pMgmt->cbFreeCmdQueue = CMD_Q_SIZE;
+ pMgmt->uCmdDequeueIdx = 0;
+ pMgmt->uCmdEnqueueIdx = 0;
+ pMgmt->eCommandState = WLAN_CMD_STATE_IDLE;
+ pMgmt->bCmdStop = FALSE;
+ pMgmt->bCmdRunning = FALSE;
+
+ *pMgmtHandler = pMgmt;
+ return TRUE;
+}
+*/
+
+
+
+BOOL
+VNTWIFIbSetPMKIDCache (
+ IN PVOID pMgmtObject,
+ IN ULONG ulCount,
+ IN PVOID pPMKIDInfo
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+
+ if (ulCount > MAX_PMKID_CACHE) {
+ return (FALSE);
+ }
+ pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
+ MEMvCopy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
+ return (TRUE);
+}
+
+
+
+WORD
+VNTWIFIwGetMaxSupportRate(
+ IN PVOID pMgmtObject
+ )
+{
+ WORD wRate = RATE_54M;
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+
+ for(wRate = RATE_54M; wRate > RATE_1M; wRate--) {
+ if (BITbIsBitOn(pMgmt->sNodeDBTable[0].wSuppRate, (1<<wRate))) {
+ return (wRate);
+ }
+ }
+ if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A) {
+ return (RATE_6M);
+ } else {
+ return (RATE_1M);
+ }
+}
+
+
+VOID
+VNTWIFIvSet11h (
+ IN PVOID pMgmtObject,
+ IN BOOL b11hEnable
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+
+ pMgmt->b11hEnable = b11hEnable;
+}
+
+BOOL
+VNTWIFIbMeasureReport(
+ IN PVOID pMgmtObject,
+ IN BOOL bEndOfReport,
+ IN PVOID pvMeasureEID,
+ IN BYTE byReportMode,
+ IN BYTE byBasicMap,
+ IN BYTE byCCAFraction,
+ IN PBYTE pbyRPIs
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+ PBYTE pbyCurrentEID = (PBYTE) (pMgmt->pCurrMeasureEIDRep);
+
+ //spin_lock_irq(&pDevice->lock);
+ if ((pvMeasureEID != NULL) &&
+ (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
+ ) {
+ pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
+ pMgmt->pCurrMeasureEIDRep->len = 3;
+ pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byToken;
+ pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
+ pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
+ switch (pMgmt->pCurrMeasureEIDRep->byType) {
+ case MEASURE_TYPE_BASIC :
+ pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
+ MEMvCopy( &(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
+ &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
+ sizeof(MEASEURE_REQ));
+ pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
+ break;
+ case MEASURE_TYPE_CCA :
+ pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
+ MEMvCopy( &(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
+ &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
+ sizeof(MEASEURE_REQ));
+ pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
+ break;
+ case MEASURE_TYPE_RPI :
+ pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
+ MEMvCopy( &(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
+ &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
+ sizeof(MEASEURE_REQ));
+ MEMvCopy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
+ break;
+ default :
+ break;
+ }
+ pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
+ pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
+ pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
+ }
+ if (bEndOfReport == TRUE) {
+ IEEE11hbMSRRepTx(pMgmt);
+ }
+ //spin_unlock_irq(&pDevice->lock);
+ return (TRUE);
+}
+
+
+BOOL
+VNTWIFIbChannelSwitch(
+ IN PVOID pMgmtObject,
+ IN BYTE byNewChannel
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+
+ //spin_lock_irq(&pDevice->lock);
+ pMgmt->uCurrChannel = byNewChannel;
+ pMgmt->bSwitchChannel = FALSE;
+ //spin_unlock_irq(&pDevice->lock);
+ return TRUE;
+}
+
+/*
+BOOL
+VNTWIFIbRadarPresent(
+ IN PVOID pMgmtObject,
+ IN BYTE byChannel
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
+ (byChannel == (BYTE) pMgmt->uCurrChannel) &&
+ (pMgmt->bSwitchChannel != TRUE) &&
+ (pMgmt->b11hEnable == TRUE)) {
+ if (IS_ETH_ADDRESS_EQUAL(pMgmt->abyIBSSDFSOwner, CARDpGetCurrentAddress(pMgmt->pAdapter))) {
+ pMgmt->byNewChannel = CARDbyAutoChannelSelect(pMgmt->pAdapter,(BYTE) pMgmt->uCurrChannel);
+ pMgmt->bSwitchChannel = TRUE;
+ }
+ BEACONbSendBeacon(pMgmt);
+ CARDbChannelSwitch(pMgmt->pAdapter, 0, pMgmt->byNewChannel, 10);
+ }
+ return TRUE;
+}
+*/
+
diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h
new file mode 100644
index 000000000000..3e620a726212
--- /dev/null
+++ b/drivers/staging/vt6655/vntwifi.h
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: vntwifi.h
+ *
+ * Purpose: export VNT Host WiFi library function
+ *
+ * Author: Yiching Chen
+ *
+ * Date: Jan 7, 2004
+ *
+ */
+
+#ifndef __VNTWIFI_H__
+#define __VNTWIFI_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+#define RATE_1M 0
+#define RATE_2M 1
+#define RATE_5M 2
+#define RATE_11M 3
+#define RATE_6M 4
+#define RATE_9M 5
+#define RATE_12M 6
+#define RATE_18M 7
+#define RATE_24M 8
+#define RATE_36M 9
+#define RATE_48M 10
+#define RATE_54M 11
+#define RATE_AUTO 12
+#define MAX_RATE 12
+
+// key CipherSuite
+#define KEY_CTL_WEP 0x00
+#define KEY_CTL_NONE 0x01
+#define KEY_CTL_TKIP 0x02
+#define KEY_CTL_CCMP 0x03
+#define KEY_CTL_INVALID 0xFF
+
+#define CHANNEL_MAX_24G 14
+
+#define MAX_BSS_NUM 42
+
+#define MAX_PMKID_CACHE 16
+
+// Pre-configured Authenticaiton Mode (from XP)
+typedef enum tagWMAC_AUTHENTICATION_MODE {
+
+ WMAC_AUTH_OPEN,
+ WMAC_AUTH_SHAREKEY,
+ WMAC_AUTH_AUTO,
+ WMAC_AUTH_WPA,
+ WMAC_AUTH_WPAPSK,
+ WMAC_AUTH_WPANONE,
+ WMAC_AUTH_WPA2,
+ WMAC_AUTH_WPA2PSK,
+ WMAC_AUTH_MAX // Not a real mode, defined as upper bound
+
+} WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
+
+typedef enum tagWMAC_ENCRYPTION_MODE {
+
+ WMAC_ENCRYPTION_WEPEnabled,
+ WMAC_ENCRYPTION_WEPDisabled,
+ WMAC_ENCRYPTION_WEPKeyAbsent,
+ WMAC_ENCRYPTION_WEPNotSupported,
+ WMAC_ENCRYPTION_TKIPEnabled,
+ WMAC_ENCRYPTION_TKIPKeyAbsent,
+ WMAC_ENCRYPTION_AESEnabled,
+ WMAC_ENCRYPTION_AESKeyAbsent
+
+} WMAC_ENCRYPTION_MODE, *PWMAC_ENCRYPTION_MODE;
+
+// Pre-configured Mode (from XP)
+
+typedef enum tagWMAC_CONFIG_MODE {
+
+ WMAC_CONFIG_ESS_STA = 0,
+ WMAC_CONFIG_IBSS_STA,
+ WMAC_CONFIG_AUTO,
+ WMAC_CONFIG_AP
+
+} WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
+
+
+
+typedef enum tagWMAC_POWER_MODE {
+
+ WMAC_POWER_CAM,
+ WMAC_POWER_FAST,
+ WMAC_POWER_MAX
+
+} WMAC_POWER_MODE, *PWMAC_POWER_MODE;
+
+#define VNTWIFIbIsShortSlotTime(wCapInfo) \
+ WLAN_GET_CAP_INFO_SHORTSLOTTIME(wCapInfo) \
+
+#define VNTWIFIbIsProtectMode(byERP) \
+ ((byERP & WLAN_EID_ERP_USE_PROTECTION) != 0) \
+
+#define VNTWIFIbIsBarkerMode(byERP) \
+ ((byERP & WLAN_EID_ERP_BARKER_MODE) != 0) \
+
+#define VNTWIFIbIsShortPreamble(wCapInfo) \
+ WLAN_GET_CAP_INFO_SHORTPREAMBLE(wCapInfo) \
+
+#define VNTWIFIbIsEncryption(wCapInfo) \
+ WLAN_GET_CAP_INFO_PRIVACY(wCapInfo) \
+
+#define VNTWIFIbIsESS(wCapInfo) \
+ WLAN_GET_CAP_INFO_ESS(wCapInfo) \
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+VOID
+VNTWIFIvSetIBSSParameter (
+ IN PVOID pMgmtHandle,
+ IN WORD wBeaconPeriod,
+ IN WORD wATIMWindow,
+ IN UINT uChannel
+ );
+
+VOID
+VNTWIFIvSetOPMode (
+ IN PVOID pMgmtHandle,
+ IN WMAC_CONFIG_MODE eOPMode
+ );
+
+PWLAN_IE_SSID
+VNTWIFIpGetCurrentSSID(
+ IN PVOID pMgmtHandle
+ );
+
+UINT
+VNTWIFIpGetCurrentChannel(
+ IN PVOID pMgmtHandle
+ );
+
+WORD
+VNTWIFIwGetAssocID (
+ IN PVOID pMgmtHandle
+ );
+
+BYTE
+VNTWIFIbyGetMaxSupportRate (
+ IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
+ IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
+ );
+
+BYTE
+VNTWIFIbyGetACKTxRate (
+ IN BYTE byRxDataRate,
+ IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
+ IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
+ );
+
+VOID
+VNTWIFIvSetAuthenticationMode (
+ IN PVOID pMgmtHandle,
+ IN WMAC_AUTHENTICATION_MODE eAuthMode
+ );
+
+VOID
+VNTWIFIvSetEncryptionMode (
+ IN PVOID pMgmtHandle,
+ IN WMAC_ENCRYPTION_MODE eEncryptionMode
+ );
+
+
+BOOL
+VNTWIFIbConfigPhyMode(
+ IN PVOID pMgmtHandle,
+ IN CARD_PHY_TYPE ePhyType
+ );
+
+VOID
+VNTWIFIbGetConfigPhyMode(
+ IN PVOID pMgmtHandle,
+ OUT PVOID pePhyType
+ );
+
+VOID
+VNTWIFIvQueryBSSList(
+ IN PVOID pMgmtHandle,
+ OUT PUINT puBSSCount,
+ OUT PVOID *pvFirstBSS
+ );
+
+
+
+
+VOID
+VNTWIFIvGetNextBSS (
+ IN PVOID pMgmtHandle,
+ IN PVOID pvCurrentBSS,
+ OUT PVOID *pvNextBSS
+ );
+
+
+
+VOID
+VNTWIFIvUpdateNodeTxCounter(
+ IN PVOID pMgmtHandle,
+ IN PBYTE pbyDestAddress,
+ IN BOOL bTxOk,
+ IN WORD wRate,
+ IN PBYTE pbyTxFailCount
+ );
+
+
+VOID
+VNTWIFIvGetTxRate(
+ IN PVOID pMgmtHandle,
+ IN PBYTE pbyDestAddress,
+ OUT PWORD pwTxDataRate,
+ OUT PBYTE pbyACKRate,
+ OUT PBYTE pbyCCKBasicRate,
+ OUT PBYTE pbyOFDMBasicRate
+ );
+/*
+BOOL
+VNTWIFIbInit(
+ IN PVOID pAdapterHandler,
+ OUT PVOID *pMgmtHandler
+ );
+*/
+
+BYTE
+VNTWIFIbyGetKeyCypher(
+ IN PVOID pMgmtHandle,
+ IN BOOL bGroupKey
+ );
+
+
+
+
+BOOL
+VNTWIFIbSetPMKIDCache (
+ IN PVOID pMgmtObject,
+ IN ULONG ulCount,
+ IN PVOID pPMKIDInfo
+ );
+
+BOOL
+VNTWIFIbCommandRunning (
+ IN PVOID pMgmtObject
+ );
+
+WORD
+VNTWIFIwGetMaxSupportRate(
+ IN PVOID pMgmtObject
+ );
+
+// for 802.11h
+VOID
+VNTWIFIvSet11h (
+ IN PVOID pMgmtObject,
+ IN BOOL b11hEnable
+ );
+
+BOOL
+VNTWIFIbMeasureReport(
+ IN PVOID pMgmtObject,
+ IN BOOL bEndOfReport,
+ IN PVOID pvMeasureEID,
+ IN BYTE byReportMode,
+ IN BYTE byBasicMap,
+ IN BYTE byCCAFraction,
+ IN PBYTE pbyRPIs
+ );
+
+BOOL
+VNTWIFIbChannelSwitch(
+ IN PVOID pMgmtObject,
+ IN BYTE byNewChannel
+ );
+/*
+BOOL
+VNTWIFIbRadarPresent(
+ IN PVOID pMgmtObject,
+ IN BYTE byChannel
+ );
+*/
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif //__VNTWIFI_H__
diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c
new file mode 100644
index 000000000000..92563bd011b2
--- /dev/null
+++ b/drivers/staging/vt6655/wcmd.c
@@ -0,0 +1,1178 @@
+ /*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: wcmd.c
+ *
+ * Purpose: Handles the management command interface functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2003
+ *
+ * Functions:
+ * s_vProbeChannel - Active scan channel
+ * s_MgrMakeProbeRequest - Make ProbeRequest packet
+ * CommandTimer - Timer function to handle command
+ * s_bCommandComplete - Command Complete function
+ * bScheduleCommand - Push Command and wait Command Scheduler to do
+ * vCommandTimer- Command call back functions
+ * vCommandTimerWait- Call back timer
+ * bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
+ *
+ * Revision History:
+ *
+ */
+
+
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__WCTL_H__)
+#include "wctl.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+//DavidWang
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Functions --------------------------*/
+
+static
+VOID
+s_vProbeChannel(
+ IN PSDevice pDevice
+ );
+
+
+static
+PSTxMgmtPacket
+s_MgrMakeProbeRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pScanBSSID,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ );
+
+static
+BOOL
+s_bCommandComplete (
+ PSDevice pDevice
+ );
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*
+ * Description:
+ * Stop AdHoc beacon during scan process
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+static
+void
+vAdHocBeaconStop(PSDevice pDevice)
+{
+
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ BOOL bStop;
+
+ /*
+ * temporarily stop Beacon packet for AdHoc Server
+ * if all of the following coditions are met:
+ * (1) STA is in AdHoc mode
+ * (2) VT3253 is programmed as automatic Beacon Transmitting
+ * (3) One of the following conditions is met
+ * (3.1) AdHoc channel is in B/G band and the
+ * current scan channel is in A band
+ * or
+ * (3.2) AdHoc channel is in A mode
+ */
+ bStop = FALSE;
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
+ (pMgmt->eCurrState >= WMAC_STATE_STARTED))
+ {
+ if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
+ (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
+ {
+ bStop = TRUE;
+ }
+ if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
+ {
+ bStop = TRUE;
+ }
+ }
+
+ if (bStop)
+ {
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+
+}
+
+/*
+ * Description:
+ * Restart AdHoc beacon after scan process complete
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+static
+void
+vAdHocBeaconRestart(PSDevice pDevice)
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ /*
+ * Restart Beacon packet for AdHoc Server
+ * if all of the following coditions are met:
+ * (1) STA is in AdHoc mode
+ * (2) VT3253 is programmed as automatic Beacon Transmitting
+ */
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
+ (pMgmt->eCurrState >= WMAC_STATE_STARTED))
+ {
+ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+
+}
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Prepare and send probe request management frames.
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+
+static
+VOID
+s_vProbeChannel(
+ IN PSDevice pDevice
+ )
+{
+ //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
+ BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
+ BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
+ //6M, 9M, 12M, 48M
+ BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+ BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
+ PBYTE pbyRate;
+ PSTxMgmtPacket pTxPacket;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ UINT ii;
+
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
+ pbyRate = &abyCurrSuppRatesA[0];
+ } else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ pbyRate = &abyCurrSuppRatesB[0];
+ } else {
+ pbyRate = &abyCurrSuppRatesG[0];
+ }
+ // build an assocreq frame and send it
+ pTxPacket = s_MgrMakeProbeRequest
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->abyScanBSSID,
+ (PWLAN_IE_SSID)pMgmt->abyScanSSID,
+ (PWLAN_IE_SUPP_RATES)pbyRate,
+ (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
+ );
+
+ if (pTxPacket != NULL ){
+ for (ii = 0; ii < 2 ; ii++) {
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
+ }
+ }
+ }
+
+}
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an probe request frame
+ *
+ *
+ * Return Value:
+ * A ptr to Tx frame or NULL on allocation failue
+ *
+-*/
+
+
+PSTxMgmtPacket
+s_MgrMakeProbeRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pScanBSSID,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_PROBEREQ sFrame;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
+ vMgrEncodeProbeRequest(&sFrame);
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
+ // Copy the SSID, pSSID->len=0 indicate broadcast SSID
+ sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
+ // Copy the extension rate set
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
+ }
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ return pTxPacket;
+}
+
+
+
+
+VOID
+vCommandTimerWait(
+ IN HANDLE hDeviceContext,
+ IN UINT MSecond
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ init_timer(&pDevice->sTimerCommand);
+ pDevice->sTimerCommand.data = (ULONG)pDevice;
+ pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
+ // RUN_AT :1 msec ~= (HZ/1024)
+ pDevice->sTimerCommand.expires = (UINT)RUN_AT((MSecond * HZ) >> 10);
+ add_timer(&pDevice->sTimerCommand);
+ return;
+}
+
+
+
+VOID
+vCommandTimer (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PWLAN_IE_SSID pItemSSID;
+ PWLAN_IE_SSID pItemSSIDCurr;
+ CMD_STATUS Status;
+ UINT ii;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ struct sk_buff *skb;
+
+
+ if (pDevice->dwDiagRefCount != 0)
+ return;
+ if (pDevice->bCmdRunning != TRUE)
+ return;
+
+ spin_lock_irq(&pDevice->lock);
+
+ switch ( pDevice->eCommandState ) {
+
+ case WLAN_CMD_SCAN_START:
+
+ pDevice->byReAssocCount = 0;
+ if (pDevice->bRadioOff == TRUE) {
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ s_bCommandComplete(pDevice);
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_AP);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SCAN_START\n");
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
+ // wait all Data TD complete
+ if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
+ spin_unlock_irq(&pDevice->lock);
+ vCommandTimerWait((HANDLE)pDevice, 10);
+ return;
+ };
+
+ if (pMgmt->uScanChannel == 0 ) {
+ pMgmt->uScanChannel = pDevice->byMinChannel;
+ // Set Baseband to be more sensitive.
+
+ }
+ if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
+ pMgmt->eScanState = WMAC_NO_SCANNING;
+
+ // Set Baseband's sensitivity back.
+ // Set channel back
+ CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
+ } else {
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE);
+ }
+ vAdHocBeaconRestart(pDevice);
+ s_bCommandComplete(pDevice);
+
+ } else {
+//2008-8-4 <add> by chester
+ if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
+ s_bCommandComplete(pDevice);
+ return;
+ }
+//printk("chester-pMgmt->uScanChannel=%d,pDevice->byMaxChannel=%d\n",pMgmt->uScanChannel,pDevice->byMaxChannel);
+ if (pMgmt->uScanChannel == pDevice->byMinChannel) {
+ //pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ pMgmt->abyScanBSSID[0] = 0xFF;
+ pMgmt->abyScanBSSID[1] = 0xFF;
+ pMgmt->abyScanBSSID[2] = 0xFF;
+ pMgmt->abyScanBSSID[3] = 0xFF;
+ pMgmt->abyScanBSSID[4] = 0xFF;
+ pMgmt->abyScanBSSID[5] = 0xFF;
+ pItemSSID->byElementID = WLAN_EID_SSID;
+ // clear bssid list
+ // BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ pMgmt->eScanState = WMAC_IS_SCANNING;
+
+ }
+
+ vAdHocBeaconStop(pDevice);
+
+ if (CARDbSetChannel(pMgmt->pAdapter, pMgmt->uScanChannel) == TRUE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SCAN Channel: %d\n", pMgmt->uScanChannel);
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SET SCAN Channel Fail: %d\n", pMgmt->uScanChannel);
+ }
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_UNKNOWN);
+// printk("chester-mxch=%d\n",pDevice->byMaxChannel);
+ // printk("chester-ch=%d\n",pMgmt->uScanChannel);
+ pMgmt->uScanChannel++;
+//2008-8-4 <modify> by chester
+ if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
+ pMgmt->uScanChannel <= pDevice->byMaxChannel ){
+ pMgmt->uScanChannel=pDevice->byMaxChannel+1;
+ pMgmt->eCommandState = WLAN_CMD_SCAN_END;
+
+ }
+
+
+ if ((pMgmt->b11hEnable == FALSE) ||
+ (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
+ s_vProbeChannel(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ vCommandTimerWait((HANDLE)pDevice, WCMD_ACTIVE_SCAN_TIME);
+ return;
+ } else {
+ spin_unlock_irq(&pDevice->lock);
+ vCommandTimerWait((HANDLE)pDevice, WCMD_PASSIVE_SCAN_TIME);
+ return;
+ }
+
+ }
+
+ break;
+
+ case WLAN_CMD_SCAN_END:
+
+ // Set Baseband's sensitivity back.
+ // Set channel back
+ CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
+ } else {
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE);
+ }
+
+ pMgmt->eScanState = WMAC_NO_SCANNING;
+ vAdHocBeaconRestart(pDevice);
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ if(pMgmt->eScanType == WMAC_SCAN_PASSIVE)
+ {//send scan event to wpa_Supplicant
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof(wrqu));
+ wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
+ }
+#endif
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_DISASSOCIATE_START :
+ pDevice->byReAssocCount = 0;
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
+ // reason = 8 : disassoc because sta has left
+ vMgrDisassocBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status);
+ pDevice->bLinkPass = FALSE;
+ // unlock command busy
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ pItemSSID->len = 0;
+ memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+// pDevice->bBeaconBufReady = FALSE;
+ }
+ netif_stop_queue(pDevice->dev);
+ pDevice->eCommandState = WLAN_DISASSOCIATE_WAIT;
+ // wait all Control TD complete
+ if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
+ vCommandTimerWait((HANDLE)pDevice, 10);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ };
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" CARDbRadioPowerOff\n");
+ //2008-09-02 <mark> by chester
+ // CARDbRadioPowerOff(pDevice);
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_DISASSOCIATE_WAIT :
+ // wait all Control TD complete
+ if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
+ vCommandTimerWait((HANDLE)pDevice, 10);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ };
+//2008-09-02 <mark> by chester
+ // CARDbRadioPowerOff(pDevice);
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_SSID_START:
+ pDevice->byReAssocCount = 0;
+ if (pDevice->bRadioOff == TRUE) {
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+//printk("chester-currmode=%d\n",pMgmt->eCurrMode);
+printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID);
+ //memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
+ //((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
+
+ if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
+ }
+
+ if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
+ ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)&& (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
+
+ if (pItemSSID->len == pItemSSIDCurr->len) {
+ if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+ }
+
+ netif_stop_queue(pDevice->dev);
+ pDevice->bLinkPass = FALSE;
+ }
+ // set initial state
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ PSvDisablePowerSaving((HANDLE)pDevice);
+ BSSvClearNodeDBTable(pDevice, 0);
+
+ vMgrJoinBSSBegin((HANDLE)pDevice, &Status);
+ // if Infra mode
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
+
+ // Call mgr to begin the deauthentication
+ // reason = (3) beacuse sta has left ESS
+ if (pMgmt->eCurrState>= WMAC_STATE_AUTH) {
+ vMgrDeAuthenBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (3), &Status);
+ }
+ // Call mgr to begin the authentication
+ vMgrAuthenBeginSta((HANDLE)pDevice, pMgmt, &Status);
+ if (Status == CMD_STATUS_SUCCESS) {
+ pDevice->byLinkWaitCount = 0;
+ pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
+ vCommandTimerWait((HANDLE)pDevice, AUTHENTICATE_TIMEOUT);
+ spin_unlock_irq(&pDevice->lock);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
+ return;
+ }
+ }
+ // if Adhoc mode
+ else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+ pDevice->bLinkPass = TRUE;
+
+ pMgmt->sNodeDBTable[0].bActive = TRUE;
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+ bClearBSSID_SCAN(pDevice);
+ }
+ else {
+ // start own IBSS
+ vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
+ if (Status != CMD_STATUS_SUCCESS){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n");
+ };
+ BSSvAddMulticastNode(pDevice);
+ }
+ }
+ // if SSID not found
+ else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
+ if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
+ pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
+ // start own IBSS
+ vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
+ if (Status != CMD_STATUS_SUCCESS){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_IBSS_CREATE fail ! \n");
+ };
+ BSSvAddMulticastNode(pDevice);
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+ pDevice->bLinkPass = TRUE;
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+
+ }
+ }
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_AUTHENTICATE_WAIT :
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
+ if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
+ // Call mgr to begin the association
+ pDevice->byLinkWaitCount = 0;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
+ vMgrAssocBeginSta((HANDLE)pDevice, pMgmt, &Status);
+ if (Status == CMD_STATUS_SUCCESS) {
+ pDevice->byLinkWaitCount = 0;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
+ pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
+ vCommandTimerWait((HANDLE)pDevice, ASSOCIATE_TIMEOUT);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+ }
+
+ else if(pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
+ printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
+ }
+ else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
+ pDevice->byLinkWaitCount ++;
+ printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
+ spin_unlock_irq(&pDevice->lock);
+ vCommandTimerWait((HANDLE)pDevice, AUTHENTICATE_TIMEOUT/2);
+ return;
+ }
+ pDevice->byLinkWaitCount = 0;
+ #if 0
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disassociated:AUTHENTICATE_WAIT_timeout)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ #endif
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_ASSOCIATE_WAIT :
+ if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
+ if (pDevice->ePSMode != WMAC_POWER_CAM) {
+ PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
+ }
+ if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
+ KeybRemoveAllKey(&(pDevice->sKey), pDevice->abyBSSID, pDevice->PortOffset);
+ }
+ pDevice->bLinkPass = TRUE;
+ pDevice->byLinkWaitCount = 0;
+ pDevice->byReAssocCount = 0;
+ bClearBSSID_SCAN(pDevice);
+ if (pDevice->byFOETuning) {
+ BBvSetFOE(pDevice->PortOffset);
+ PSbSendNullPacket(pDevice);
+ }
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+ #ifdef TxInSleep
+ if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time
+ // printk("Re-initial TxDataTimer****\n");
+ del_timer(&pDevice->sTimerTxData);
+ init_timer(&pDevice->sTimerTxData);
+ pDevice->sTimerTxData.data = (ULONG)pDevice;
+ pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
+ pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
+ pDevice->fTxDataInSleep = FALSE;
+ pDevice->nTxDataTimeCout = 0;
+ }
+ else {
+ // printk("mike:-->First time triger TimerTxData InSleep\n");
+ }
+ pDevice->IsTxDataTrigger = TRUE;
+ add_timer(&pDevice->sTimerTxData);
+ #endif
+ }
+ else if(pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
+ printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
+ }
+ else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if associated_frame delay!
+ pDevice->byLinkWaitCount ++;
+ printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
+ spin_unlock_irq(&pDevice->lock);
+ vCommandTimerWait((HANDLE)pDevice, ASSOCIATE_TIMEOUT/2);
+ return;
+ }
+ pDevice->byLinkWaitCount = 0;
+ #if 0
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disassociated:ASSOCIATE_WAIT_timeout)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ #endif
+
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_AP_MODE_START :
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ del_timer(&pMgmt->sTimerSecondCallback);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pDevice->bLinkPass = FALSE;
+ if (pDevice->bEnableHostWEP == TRUE)
+ BSSvClearNodeDBTable(pDevice, 1);
+ else
+ BSSvClearNodeDBTable(pDevice, 0);
+ pDevice->uAssocCount = 0;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pDevice->bFixRate = FALSE;
+
+ vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
+ if (Status != CMD_STATUS_SUCCESS){
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " vMgrCreateOwnIBSS fail ! \n");
+ };
+ // alway turn off unicast bit
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST);
+ pDevice->byRxMode &= ~RCR_UNICAST;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
+ BSSvAddMulticastNode(pDevice);
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+ pDevice->bLinkPass = TRUE;
+ add_timer(&pMgmt->sTimerSecondCallback);
+ }
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_TX_PSPACKET_START :
+ // DTIM Multicast tx
+ if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
+ while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
+ if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
+ pMgmt->abyPSTxMap[0] &= ~byMask[0];
+ pDevice->bMoreData = FALSE;
+ }
+ else {
+ pDevice->bMoreData = TRUE;
+ }
+ if (!device_dma0_xmit(pDevice, skb, 0)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
+ }
+ pMgmt->sNodeDBTable[0].wEnQueueCnt--;
+ }
+ };
+
+ // PS nodes tx
+ for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
+ if (pMgmt->sNodeDBTable[ii].bActive &&
+ pMgmt->sNodeDBTable[ii].bRxPSPoll) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
+ ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
+ while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
+ if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
+ // clear tx map
+ pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
+ ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
+ pDevice->bMoreData = FALSE;
+ }
+ else {
+ pDevice->bMoreData = TRUE;
+ }
+ if (!device_dma0_xmit(pDevice, skb, ii)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
+ }
+ pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
+ // check if sta ps enable, wait next pspoll
+ // if sta ps disable, send all pending buffers.
+ if (pMgmt->sNodeDBTable[ii].bPSEnable)
+ break;
+ }
+ if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
+ // clear tx map
+ pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
+ ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
+ }
+ pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE;
+ }
+ }
+
+ s_bCommandComplete(pDevice);
+ break;
+
+
+ case WLAN_CMD_RADIO_START :
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
+ if (pDevice->bRadioCmd == TRUE)
+ CARDbRadioPowerOn(pDevice);
+ else
+ CARDbRadioPowerOff(pDevice);
+
+ s_bCommandComplete(pDevice);
+ break;
+
+
+ case WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE :
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_CHECK_BBSENSITIVITY_START\n");
+ // wait all TD complete
+ if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
+ vCommandTimerWait((HANDLE)pDevice, 10);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+ if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
+ vCommandTimerWait((HANDLE)pDevice, 10);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+ pDevice->byBBVGACurrent = pDevice->byBBVGANew;
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SetVGAGainOffset %02X\n", pDevice->byBBVGACurrent);
+ s_bCommandComplete(pDevice);
+ break;
+
+ default :
+ s_bCommandComplete(pDevice);
+ break;
+
+ } //switch
+ spin_unlock_irq(&pDevice->lock);
+ return;
+
+}
+
+
+static
+BOOL
+s_bCommandComplete (
+ PSDevice pDevice
+ )
+{
+ PWLAN_IE_SSID pSSID;
+ BOOL bRadioCmd = FALSE;
+ //WORD wDeAuthenReason = 0;
+ BOOL bForceSCAN = TRUE;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+
+ pDevice->eCommandState = WLAN_CMD_IDLE;
+ if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
+ //Command Queue Empty
+ pDevice->bCmdRunning = FALSE;
+ return TRUE;
+ }
+ else {
+ pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
+ pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
+ bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
+ bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
+ ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
+ pDevice->cbFreeCmdQueue++;
+ pDevice->bCmdRunning = TRUE;
+ switch ( pDevice->eCommand ) {
+ case WLAN_CMD_BSSID_SCAN:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
+ pDevice->eCommandState = WLAN_CMD_SCAN_START;
+ pMgmt->uScanChannel = 0;
+ if (pSSID->len != 0) {
+ MEMvCopy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ } else {
+ memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ }
+/*
+ if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
+ if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
+ (MEMEqualMemory(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
+ pDevice->eCommandState = WLAN_CMD_IDLE;
+ }
+ }
+*/
+ break;
+ case WLAN_CMD_SSID:
+ pDevice->eCommandState = WLAN_CMD_SSID_START;
+ if (pSSID->len > WLAN_SSID_MAXLEN)
+ pSSID->len = WLAN_SSID_MAXLEN;
+ if (pSSID->len != 0)
+ MEMvCopy(pDevice->pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
+ break;
+ case WLAN_CMD_DISASSOCIATE:
+ pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
+ break;
+ case WLAN_CMD_RX_PSPOLL:
+ pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
+ break;
+ case WLAN_CMD_RUN_AP:
+ pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
+ break;
+ case WLAN_CMD_RADIO:
+ pDevice->eCommandState = WLAN_CMD_RADIO_START;
+ pDevice->bRadioCmd = bRadioCmd;
+ break;
+ case WLAN_CMD_CHANGE_BBSENSITIVITY:
+ pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
+ break;
+
+ default:
+ break;
+
+ }
+
+ vCommandTimerWait((HANDLE)pDevice, 0);
+ }
+
+ return TRUE;
+}
+
+
+
+BOOL bScheduleCommand (
+ IN HANDLE hDeviceContext,
+ IN CMD_CODE eCommand,
+ IN PBYTE pbyItem0
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+
+ if (pDevice->cbFreeCmdQueue == 0) {
+ return (FALSE);
+ }
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE;
+ memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+
+ if (pbyItem0 != NULL) {
+ switch (eCommand) {
+
+ case WLAN_CMD_BSSID_SCAN:
+ MEMvCopy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
+ pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
+ break;
+
+ case WLAN_CMD_SSID:
+ MEMvCopy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
+ pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ break;
+
+ case WLAN_CMD_DISASSOCIATE:
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((PBOOL)pbyItem0);
+ break;
+/*
+ case WLAN_CMD_DEAUTH:
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
+ break;
+*/
+
+ case WLAN_CMD_RX_PSPOLL:
+ break;
+
+ case WLAN_CMD_RADIO:
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((PBOOL)pbyItem0);
+ break;
+
+ case WLAN_CMD_CHANGE_BBSENSITIVITY:
+ pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
+ pDevice->cbFreeCmdQueue--;
+
+ if (pDevice->bCmdRunning == FALSE) {
+ s_bCommandComplete(pDevice);
+ }
+ else {
+ }
+ return (TRUE);
+
+}
+
+/*
+ * Description:
+ * Clear BSSID_SCAN cmd in CMD Queue
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - Pointer to the adapter
+ * eCommand - Command
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL bClearBSSID_SCAN (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ UINT uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
+ UINT ii;
+
+ if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
+ for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) {
+ if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
+ pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
+ ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
+ if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
+ break;
+ }
+ }
+ return TRUE;
+}
+
+//mike add:reset command timer
+VOID
+vResetCommandTimer(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ //delete timer
+ del_timer(&pDevice->sTimerCommand);
+ //init timer
+ init_timer(&pDevice->sTimerCommand);
+ pDevice->sTimerCommand.data = (ULONG)pDevice;
+ pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
+ pDevice->sTimerCommand.expires = RUN_AT(HZ);
+ pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
+ pDevice->uCmdDequeueIdx = 0;
+ pDevice->uCmdEnqueueIdx = 0;
+ pDevice->eCommandState = WLAN_CMD_IDLE;
+ pDevice->bCmdRunning = FALSE;
+ pDevice->bCmdClear = FALSE;
+}
+
+
+#ifdef TxInSleep
+VOID
+BSSvSecondTxData(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ pDevice->nTxDataTimeCout++;
+
+ if(pDevice->nTxDataTimeCout<4) //don't tx data if timer less than 40s
+ {
+ // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
+ // (int)pDevice->nTxDataTimeCout);
+ pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
+ add_timer(&pDevice->sTimerTxData);
+ return;
+ }
+
+ spin_lock_irq(&pDevice->lock);
+ #if 1
+ if(((pDevice->bLinkPass ==TRUE)&&(pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
+ (pDevice->fWPA_Authened == TRUE)) { //wpa linking
+ #else
+ if(pDevice->bLinkPass ==TRUE) {
+ #endif
+
+ // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
+ pDevice->fTxDataInSleep = TRUE;
+ PSbSendNullPacket(pDevice); //send null packet
+ pDevice->fTxDataInSleep = FALSE;
+ }
+ spin_unlock_irq(&pDevice->lock);
+
+ pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
+ add_timer(&pDevice->sTimerTxData);
+ return;
+}
+#endif
+
diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h
new file mode 100644
index 000000000000..8c6bbc49f0bc
--- /dev/null
+++ b/drivers/staging/vt6655/wcmd.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wcmd.h
+ *
+ * Purpose: Handles the management command interface functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2002
+ *
+ */
+
+#ifndef __WCMD_H__
+#define __WCMD_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+
+#define AUTHENTICATE_TIMEOUT 1000 //ms
+#define ASSOCIATE_TIMEOUT 1000 //ms
+
+// Command code
+typedef enum tagCMD_CODE {
+ WLAN_CMD_BSSID_SCAN,
+ WLAN_CMD_SSID,
+ WLAN_CMD_DISASSOCIATE,
+ WLAN_CMD_DEAUTH,
+ WLAN_CMD_RX_PSPOLL,
+ WLAN_CMD_RADIO,
+ WLAN_CMD_CHANGE_BBSENSITIVITY,
+ WLAN_CMD_SETPOWER,
+ WLAN_CMD_TBTT_WAKEUP,
+ WLAN_CMD_BECON_SEND,
+ WLAN_CMD_CHANGE_ANTENNA,
+ WLAN_CMD_REMOVE_ALLKEY,
+ WLAN_CMD_MAC_DISPOWERSAVING,
+ WLAN_CMD_11H_CHSW,
+ WLAN_CMD_RUN_AP
+} CMD_CODE, DEF* PCMD_CODE;
+
+#define CMD_Q_SIZE 32
+
+
+// Command code
+typedef enum tagCMD_STATUS {
+
+ CMD_STATUS_SUCCESS,
+ CMD_STATUS_FAILURE,
+ CMD_STATUS_RESOURCES,
+ CMD_STATUS_TIMEOUT,
+ CMD_STATUS_PENDING
+
+} CMD_STATUS, DEF* PCMD_STATUS;
+
+
+typedef struct tagCMD_ITEM {
+ CMD_CODE eCmd;
+ BYTE abyCmdDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ BOOL bNeedRadioOFF;
+ WORD wDeAuthenReason;
+ BOOL bRadioCmd;
+ BOOL bForceSCAN;
+} CMD_ITEM, DEF* PCMD_ITEM;
+
+// Command state
+typedef enum tagCMD_STATE {
+ WLAN_CMD_SCAN_START,
+ WLAN_CMD_SCAN_END,
+ WLAN_CMD_DISASSOCIATE_START,
+ WLAN_CMD_SSID_START,
+ WLAN_AUTHENTICATE_WAIT,
+ WLAN_ASSOCIATE_WAIT,
+ WLAN_DISASSOCIATE_WAIT,
+ WLAN_CMD_TX_PSPACKET_START,
+ WLAN_CMD_AP_MODE_START,
+ WLAN_CMD_RADIO_START,
+ WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE,
+ WLAN_CMD_IDLE
+} CMD_STATE, DEF* PCMD_STATE;
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+VOID
+vResetCommandTimer(
+ IN HANDLE hDeviceContext
+ );
+
+VOID
+vCommandTimer (
+ IN HANDLE hDeviceContext
+ );
+
+BOOL bClearBSSID_SCAN(
+ IN HANDLE hDeviceContext
+ );
+
+BOOL
+bScheduleCommand(
+ IN HANDLE hDeviceContext,
+ IN CMD_CODE eCommand,
+ IN PBYTE pbyItem0
+ );
+
+VOID
+vCommandTimerWait(
+ IN HANDLE hDeviceContext,
+ IN UINT MSecond
+ );
+#ifdef TxInSleep
+VOID
+BSSvSecondTxData(
+ IN HANDLE hDeviceContext
+ );
+#endif
+#endif //__WCMD_H__
diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c
new file mode 100644
index 000000000000..b4fecc2ed55c
--- /dev/null
+++ b/drivers/staging/vt6655/wctl.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wctl.c
+ *
+ * Purpose: handle WMAC duplicate filter & defragment
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jun. 27, 2002
+ *
+ * Functions:
+ * WCTLbIsDuplicate - Test if duplicate packet
+ * WCTLuSearchDFCB - Search DeFragment Control Database
+ * WCTLuInsertDFCB - Insert DeFragment Control Database
+ * WCTLbHandleFragment - Handle received fragment packet
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__WCTL_H__)
+#include "wctl.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+// static int msglevel =MSG_LEVEL_INFO;
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+
+/*
+ * Description:
+ * Scan Rx cache. Return TRUE if packet is duplicate, else
+ * inserts in receive cache and returns FALSE.
+ *
+ * Parameters:
+ * In:
+ * pCache - Receive packets history
+ * pMACHeader - 802.11 MAC Header of received packet
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if packet duplicate; otherwise FALSE
+ *
+ */
+
+BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader)
+{
+ UINT uIndex;
+ UINT ii;
+ PSCacheEntry pCacheEntry;
+
+ if (IS_FC_RETRY(pMACHeader)) {
+
+ uIndex = pCache->uInPtr;
+ for (ii = 0; ii < DUPLICATE_RX_CACHE_LENGTH; ii++) {
+ pCacheEntry = &(pCache->asCacheEntry[uIndex]);
+ if ((pCacheEntry->wFmSequence == pMACHeader->wSeqCtl) &&
+ (IS_ETH_ADDRESS_EQUAL (&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0])))
+ ) {
+ /* Duplicate match */
+ return TRUE;
+ }
+ ADD_ONE_WITH_WRAP_AROUND(uIndex, DUPLICATE_RX_CACHE_LENGTH);
+ }
+ }
+ /* Not fount in cache - insert */
+ pCacheEntry = &pCache->asCacheEntry[pCache->uInPtr];
+ pCacheEntry->wFmSequence = pMACHeader->wSeqCtl;
+ memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), U_ETHER_ADDR_LEN);
+ ADD_ONE_WITH_WRAP_AROUND(pCache->uInPtr, DUPLICATE_RX_CACHE_LENGTH);
+ return FALSE;
+}
+
+/*
+ * Description:
+ * Found if sequence number of received fragment packet in Defragment Database
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to adapter
+ * pMACHeader - 802.11 MAC Header of received packet
+ * Out:
+ * none
+ *
+ * Return Value: index number in Defragment Database
+ *
+ */
+UINT WCTLuSearchDFCB (PSDevice pDevice, PS802_11Header pMACHeader)
+{
+UINT ii;
+
+ for(ii=0;ii<pDevice->cbDFCB;ii++) {
+ if ((pDevice->sRxDFCB[ii].bInUse == TRUE) &&
+ (IS_ETH_ADDRESS_EQUAL (&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0])))
+ ) {
+ //
+ return(ii);
+ }
+ }
+ return(pDevice->cbDFCB);
+}
+
+
+/*
+ * Description:
+ * Insert received fragment packet in Defragment Database
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to adapter
+ * pMACHeader - 802.11 MAC Header of received packet
+ * Out:
+ * none
+ *
+ * Return Value: index number in Defragment Database
+ *
+ */
+UINT WCTLuInsertDFCB (PSDevice pDevice, PS802_11Header pMACHeader)
+{
+UINT ii;
+
+ if (pDevice->cbFreeDFCB == 0)
+ return(pDevice->cbDFCB);
+ for(ii=0;ii<pDevice->cbDFCB;ii++) {
+ if (pDevice->sRxDFCB[ii].bInUse == FALSE) {
+ pDevice->cbFreeDFCB--;
+ pDevice->sRxDFCB[ii].uLifetime = pDevice->dwMaxReceiveLifetime;
+ pDevice->sRxDFCB[ii].bInUse = TRUE;
+ pDevice->sRxDFCB[ii].wSequence = (pMACHeader->wSeqCtl >> 4);
+ pDevice->sRxDFCB[ii].wFragNum = (pMACHeader->wSeqCtl & 0x000F);
+ memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]), U_ETHER_ADDR_LEN);
+ return(ii);
+ }
+ }
+ return(pDevice->cbDFCB);
+}
+
+
+/*
+ * Description:
+ * Handle received fragment packet
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to adapter
+ * pMACHeader - 802.11 MAC Header of received packet
+ * cbFrameLength - Frame length
+ * bWEP - is WEP packet
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if it is valid fragment packet and we have resource to defragment; otherwise FALSE
+ *
+ */
+BOOL WCTLbHandleFragment (PSDevice pDevice, PS802_11Header pMACHeader, UINT cbFrameLength, BOOL bWEP, BOOL bExtIV)
+{
+UINT uHeaderSize;
+
+
+ if (bWEP == TRUE) {
+ uHeaderSize = 28;
+ if (bExtIV)
+ // ExtIV
+ uHeaderSize +=4;
+ }
+ else {
+ uHeaderSize = 24;
+ }
+
+ if (IS_FIRST_FRAGMENT_PKT(pMACHeader)) {
+ pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader);
+ if (pDevice->uCurrentDFCBIdx < pDevice->cbDFCB) {
+ // duplicate, we must flush previous DCB
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].uLifetime = pDevice->dwMaxReceiveLifetime;
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence = (pMACHeader->wSeqCtl >> 4);
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum = (pMACHeader->wSeqCtl & 0x000F);
+ }
+ else {
+ pDevice->uCurrentDFCBIdx = WCTLuInsertDFCB(pDevice, pMACHeader);
+ if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB) {
+ return(FALSE);
+ }
+ }
+ // reserve 4 byte to match MAC RX Buffer
+#ifdef PRIVATE_OBJ
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].ref_skb.data + 4);
+#else
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4);
+#endif
+ memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, pMACHeader, cbFrameLength);
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength = cbFrameLength;
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength;
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++;
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "First pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
+ return(FALSE);
+ }
+ else {
+ pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader);
+ if (pDevice->uCurrentDFCBIdx != pDevice->cbDFCB) {
+ if ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence == (pMACHeader->wSeqCtl >> 4)) &&
+ (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum == (pMACHeader->wSeqCtl & 0x000F)) &&
+ ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength + cbFrameLength - uHeaderSize) < 2346)) {
+
+ memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, ((PBYTE) (pMACHeader) + uHeaderSize), (cbFrameLength - uHeaderSize));
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength += (cbFrameLength - uHeaderSize);
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += (cbFrameLength - uHeaderSize);
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++;
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Second pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
+ }
+ else {
+ // seq error or frag # error flush DFCB
+ pDevice->cbFreeDFCB++;
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = FALSE;
+ return(FALSE);
+ }
+ }
+ else {
+ return(FALSE);
+ }
+ if (IS_LAST_FRAGMENT_PKT(pMACHeader)) {
+ //enq defragcontrolblock
+ pDevice->cbFreeDFCB++;
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = FALSE;
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Last pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
+ return(TRUE);
+ }
+ return(FALSE);
+ }
+}
+
+
diff --git a/drivers/staging/vt6655/wctl.h b/drivers/staging/vt6655/wctl.h
new file mode 100644
index 000000000000..f75ca59f6c61
--- /dev/null
+++ b/drivers/staging/vt6655/wctl.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wctl.h
+ *
+ * Purpose:
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Jun. 27, 2002
+ *
+ */
+
+
+#ifndef __WCTL_H__
+#define __WCTL_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define IS_TYPE_DATA(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_DATA)
+
+#define IS_TYPE_MGMT(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_MGMT)
+
+#define IS_TYPE_CONTROL(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_CTL)
+
+#define IS_FC_MOREDATA(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREDATA) == FC_MOREDATA)
+
+#define IS_FC_POWERMGT(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_POWERMGT) == FC_POWERMGT)
+
+#define IS_FC_RETRY(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_RETRY) == FC_RETRY)
+
+#define IS_FC_WEP(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_WEP) == FC_WEP)
+
+#ifdef __BIG_ENDIAN
+
+#define IS_FRAGMENT_PKT(pMACHeader) \
+ (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
+ ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) != 0))
+
+#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) == 0)
+
+#else
+
+#define IS_FRAGMENT_PKT(pMACHeader) \
+ (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
+ ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) != 0))
+
+#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) == 0)
+
+#endif//#ifdef __BIG_ENDIAN
+
+#define IS_LAST_FRAGMENT_PKT(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) == 0)
+
+#define IS_CTL_PSPOLL(pMACHeader) \
+ ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL)
+
+
+#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \
+ if ((uVar) >= ((uModulo) - 1)) \
+ (uVar) = 0; \
+ else \
+ (uVar)++; \
+}
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+BOOL WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader);
+BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, UINT cbFrameLength, BOOL bWEP, BOOL bExtIV);
+UINT WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
+UINT WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __WCTL_H__
+
+
+
diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c
new file mode 100644
index 000000000000..c5f52e990bd6
--- /dev/null
+++ b/drivers/staging/vt6655/wmgr.c
@@ -0,0 +1,5100 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wmgr.c
+ *
+ * Purpose: Handles the 802.11 management functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 8, 2002
+ *
+ * Functions:
+ * nsMgrObjectInitial - Initialize Management Objet data structure
+ * vMgrObjectReset - Reset Management Objet data structure
+ * vMgrAssocBeginSta - Start associate function
+ * vMgrReAssocBeginSta - Start reassociate function
+ * vMgrDisassocBeginSta - Start disassociate function
+ * s_vMgrRxAssocRequest - Handle Rcv associate_request
+ * s_vMgrRxAssocResponse - Handle Rcv associate_response
+ * vMrgAuthenBeginSta - Start authentication function
+ * vMgrDeAuthenDeginSta - Start deauthentication function
+ * s_vMgrRxAuthentication - Handle Rcv authentication
+ * s_vMgrRxAuthenSequence_1 - Handle Rcv authentication sequence 1
+ * s_vMgrRxAuthenSequence_2 - Handle Rcv authentication sequence 2
+ * s_vMgrRxAuthenSequence_3 - Handle Rcv authentication sequence 3
+ * s_vMgrRxAuthenSequence_4 - Handle Rcv authentication sequence 4
+ * s_vMgrRxDisassociation - Handle Rcv disassociation
+ * s_vMgrRxBeacon - Handle Rcv Beacon
+ * vMgrCreateOwnIBSS - Create ad_hoc IBSS or AP BSS
+ * vMgrJoinBSSBegin - Join BSS function
+ * s_vMgrSynchBSS - Synch & adopt BSS parameters
+ * s_MgrMakeBeacon - Create Baecon frame
+ * s_MgrMakeProbeResponse - Create Probe Response frame
+ * s_MgrMakeAssocRequest - Create Associate Request frame
+ * s_MgrMakeReAssocRequest - Create ReAssociate Request frame
+ * s_vMgrRxProbeResponse - Handle Rcv probe_response
+ * s_vMrgRxProbeRequest - Handle Rcv probe_request
+ * bMgrPrepareBeaconToSend - Prepare Beacon frame
+ * s_vMgrLogStatus - Log 802.11 Status
+ * vMgrRxManagePacket - Rcv management frame dispatch function
+ * s_vMgrFormatTIM- Assember TIM field of beacon
+ * vMgrTimerInit- Initial 1-sec and command call back funtions
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__DESC_H__)
+#include "desc.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__WPA_H__)
+#include "wpa.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+
+#define PLICE_DEBUG
+
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+
+/*--------------------- Static Functions --------------------------*/
+//2008-8-4 <add> by chester
+static BOOL ChannelExceedZoneType(
+ IN PSDevice pDevice,
+ IN BYTE byCurrChannel
+ );
+// Association/diassociation functions
+static
+PSTxMgmtPacket
+s_MgrMakeAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pDAddr,
+ IN WORD wCurrCapInfo,
+ IN WORD wListenInterval,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ );
+
+static
+VOID
+s_vMgrRxAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN UINT uNodeIndex
+ );
+
+static
+PSTxMgmtPacket
+s_MgrMakeReAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pDAddr,
+ IN WORD wCurrCapInfo,
+ IN WORD wListenInterval,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ );
+
+static
+VOID
+s_vMgrRxAssocResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN BOOL bReAssocType
+ );
+
+static
+VOID
+s_vMgrRxDisassociation(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ );
+
+// Authentication/deauthen functions
+static
+VOID
+s_vMgrRxAuthenSequence_1(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ );
+
+static
+VOID
+s_vMgrRxAuthenSequence_2(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ );
+
+static
+VOID
+s_vMgrRxAuthenSequence_3(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ );
+
+static
+VOID
+s_vMgrRxAuthenSequence_4(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ );
+
+static
+VOID
+s_vMgrRxAuthentication(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ );
+
+static
+VOID
+s_vMgrRxDeauthentication(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ );
+
+// Scan functions
+// probe request/response functions
+static
+VOID
+s_vMgrRxProbeRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ );
+
+static
+VOID
+s_vMgrRxProbeResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ );
+
+// beacon functions
+static
+VOID
+s_vMgrRxBeacon(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN BOOL bInScan
+ );
+
+static
+VOID
+s_vMgrFormatTIM(
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_IE_TIM pTIM
+ );
+
+static
+PSTxMgmtPacket
+s_MgrMakeBeacon(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wCurrBeaconPeriod,
+ IN UINT uCurrChannel,
+ IN WORD wCurrATIMWinodw,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PBYTE pCurrBSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ );
+
+
+// Association response
+static
+PSTxMgmtPacket
+s_MgrMakeAssocResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wAssocStatus,
+ IN WORD wAssocAID,
+ IN PBYTE pDstAddr,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ );
+
+// ReAssociation response
+static
+PSTxMgmtPacket
+s_MgrMakeReAssocResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wAssocStatus,
+ IN WORD wAssocAID,
+ IN PBYTE pDstAddr,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ );
+
+// Probe response
+static
+PSTxMgmtPacket
+s_MgrMakeProbeResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wCurrBeaconPeriod,
+ IN UINT uCurrChannel,
+ IN WORD wCurrATIMWinodw,
+ IN PBYTE pDstAddr,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PBYTE pCurrBSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates,
+ IN BYTE byPHYType
+ );
+
+// received status
+static
+VOID
+s_vMgrLogStatus(
+ IN PSMgmtObject pMgmt,
+ IN WORD wStatus
+ );
+
+
+static
+VOID
+s_vMgrSynchBSS (
+ IN PSDevice pDevice,
+ IN UINT uBSSMode,
+ IN PKnownBSS pCurr,
+ OUT PCMD_STATUS pStatus
+ );
+
+
+static BOOL
+s_bCipherMatch (
+ IN PKnownBSS pBSSNode,
+ IN NDIS_802_11_ENCRYPTION_STATUS EncStatus,
+ OUT PBYTE pbyCCSPK,
+ OUT PBYTE pbyCCSGK
+ );
+
+
+ static VOID Encyption_Rebuild(
+ IN PSDevice pDevice,
+ IN PKnownBSS pCurr
+ );
+/*
+static
+VOID
+s_vProbeChannel(
+ IN PSDevice pDevice
+ );
+
+static
+VOID
+s_vListenChannel(
+ IN PSDevice pDevice
+ );
+
+static
+PSTxMgmtPacket
+s_MgrMakeProbeRequest(
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pScanBSSID,
+ IN PWLAN_IE_SSID pSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates
+ );
+*/
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*+
+ *
+ * Routine Description:
+ * Allocates and initializes the Management object.
+ *
+ * Return Value:
+ * Ndis_staus.
+ *
+-*/
+
+VOID
+vMgrObjectInit(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int ii;
+
+
+ pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
+ pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0];
+ pMgmt->uCurrChannel = pDevice->uChannel;
+ for(ii=0;ii<WLAN_BSSID_LEN;ii++) {
+ pMgmt->abyDesireBSSID[ii] = 0xFF;
+ }
+ pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
+ //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1);
+ pMgmt->byCSSPK = KEY_CTL_NONE;
+ pMgmt->byCSSGK = KEY_CTL_NONE;
+ pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
+ BSSvClearBSSList((HANDLE)pDevice, FALSE);
+
+ return;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Initializes timer object
+ *
+ * Return Value:
+ * Ndis_staus.
+ *
+-*/
+
+void
+vMgrTimerInit(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+
+ init_timer(&pMgmt->sTimerSecondCallback);
+ pMgmt->sTimerSecondCallback.data = (ULONG)pDevice;
+ pMgmt->sTimerSecondCallback.function = (TimerFunction)BSSvSecondCallBack;
+ pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);
+
+ init_timer(&pDevice->sTimerCommand);
+ pDevice->sTimerCommand.data = (ULONG)pDevice;
+ pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
+ pDevice->sTimerCommand.expires = RUN_AT(HZ);
+
+ #ifdef TxInSleep
+ init_timer(&pDevice->sTimerTxData);
+ pDevice->sTimerTxData.data = (ULONG)pDevice;
+ pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
+ pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
+ pDevice->fTxDataInSleep = FALSE;
+ pDevice->IsTxDataTrigger = FALSE;
+ pDevice->nTxDataTimeCout = 0;
+ #endif
+
+ pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
+ pDevice->uCmdDequeueIdx = 0;
+ pDevice->uCmdEnqueueIdx = 0;
+
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Reset the management object structure.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrObjectReset(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pDevice->bEnablePSMode = FALSE;
+ // TODO: timer
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Start the station association procedure. Namely, send an
+ * association request frame to the AP.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+VOID
+vMgrAssocBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSTxMgmtPacket pTxPacket;
+
+
+ pMgmt->wCurrCapInfo = 0;
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
+ if (pDevice->bEncryptionEnable) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
+ }
+ // always allow receive short preamble
+ //if (pDevice->byPreambleType == 1) {
+ // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ //}
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ if (pMgmt->wListenInterval == 0)
+ pMgmt->wListenInterval = 1; // at least one.
+
+ // ERP Phy (802.11g) should support short preamble.
+ if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ if (CARDbIsShorSlotTime(pMgmt->pAdapter) == TRUE) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
+ }
+ } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
+ if (CARDbIsShortPreamble(pMgmt->pAdapter) == TRUE) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ }
+ }
+ if (pMgmt->b11hEnable == TRUE)
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
+
+ /* build an assocreq frame and send it */
+ pTxPacket = s_MgrMakeAssocRequest
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->abyCurrBSSID,
+ pMgmt->wCurrCapInfo,
+ pMgmt->wListenInterval,
+ (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
+ );
+
+ if (pTxPacket != NULL ){
+ /* send the frame */
+ *pStatus = csMgmt_xmit(pDevice, pTxPacket);
+ if (*pStatus == CMD_STATUS_PENDING) {
+ pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING;
+ *pStatus = CMD_STATUS_SUCCESS;
+ }
+ }
+ else
+ *pStatus = CMD_STATUS_RESOURCES;
+
+ return ;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Start the station re-association procedure.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrReAssocBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSTxMgmtPacket pTxPacket;
+
+
+
+ pMgmt->wCurrCapInfo = 0;
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
+ if (pDevice->bEncryptionEnable) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
+ }
+
+ //if (pDevice->byPreambleType == 1) {
+ // pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ //}
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+
+ if (pMgmt->wListenInterval == 0)
+ pMgmt->wListenInterval = 1; // at least one.
+
+
+ // ERP Phy (802.11g) should support short preamble.
+ if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ if (CARDbIsShorSlotTime(pMgmt->pAdapter) == TRUE) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
+ }
+ } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
+ if (CARDbIsShortPreamble(pMgmt->pAdapter) == TRUE) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ }
+ }
+ if (pMgmt->b11hEnable == TRUE)
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
+
+
+ pTxPacket = s_MgrMakeReAssocRequest
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->abyCurrBSSID,
+ pMgmt->wCurrCapInfo,
+ pMgmt->wListenInterval,
+ (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
+ );
+
+ if (pTxPacket != NULL ){
+ /* send the frame */
+ *pStatus = csMgmt_xmit(pDevice, pTxPacket);
+ if (*pStatus != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx failed.\n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx sending.\n");
+ }
+ }
+
+
+ return ;
+}
+
+/*+
+ *
+ * Routine Description:
+ * Send an dis-association request frame to the AP.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDisassocBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE abyDestAddress,
+ IN WORD wReason,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_DISASSOC sFrame;
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+
+ // Setup the sFrame structure
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_DISASSOC_FR_MAXLEN;
+
+ // format fixed field frame structure
+ vMgrEncodeDisassociation(&sFrame);
+
+ // Setup the header
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC)
+ ));
+
+ memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ // Set reason code
+ *(sFrame.pwReason) = cpu_to_le16(wReason);
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ // send the frame
+ *pStatus = csMgmt_xmit(pDevice, pTxPacket);
+ if (*pStatus == CMD_STATUS_PENDING) {
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ *pStatus = CMD_STATUS_SUCCESS;
+ };
+
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:(AP function)
+ * Handle incoming station association request frames.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN UINT uNodeIndex
+ )
+{
+ WLAN_FR_ASSOCREQ sFrame;
+ CMD_STATUS Status;
+ PSTxMgmtPacket pTxPacket;
+ WORD wAssocStatus = 0;
+ WORD wAssocAID = 0;
+ UINT uRateLen = WLAN_RATES_MAXLEN;
+ BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+
+
+ if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
+ return;
+ // node index not found
+ if (!uNodeIndex)
+ return;
+
+ //check if node is authenticated
+ //decode the frame
+ memset(&sFrame, 0, sizeof(WLAN_FR_ASSOCREQ));
+ memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
+ memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+
+ vMgrDecodeAssocRequest(&sFrame);
+
+ if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {
+ pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
+ pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);
+ pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =
+ WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? TRUE : FALSE;
+ // Todo: check sta basic rate, if ap can't support, set status code
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ uRateLen = WLAN_RATES_MAXLEN_11B;
+ }
+ abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
+ abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
+ (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
+ uRateLen);
+ abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
+ abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,
+ (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
+ uRateLen);
+ } else {
+ abyCurrExtSuppRates[1] = 0;
+ }
+
+
+ RATEvParseMaxRate((PVOID)pDevice,
+ (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
+ FALSE, // do not change our basic rate
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
+ );
+
+ // set max tx rate
+ pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
+#ifdef PLICE_DEBUG
+ printk("RxAssocRequest:wTxDataRate is %d\n",pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
+#endif
+ // Todo: check sta preamble, if ap can't support, set status code
+ pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
+ WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =
+ WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].wAID = (WORD)uNodeIndex;
+ wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;
+ wAssocAID = (WORD)uNodeIndex;
+ // check if ERP support
+ if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
+ pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE;
+
+ if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {
+ // B only STA join
+ pDevice->bProtectMode = TRUE;
+ pDevice->bNonERPPresent = TRUE;
+ }
+ if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == FALSE) {
+ pDevice->bBarkerPreambleMd = TRUE;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID);
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
+ sFrame.pHdr->sA3.abyAddr2[0],
+ sFrame.pHdr->sA3.abyAddr2[1],
+ sFrame.pHdr->sA3.abyAddr2[2],
+ sFrame.pHdr->sA3.abyAddr2[3],
+ sFrame.pHdr->sA3.abyAddr2[4],
+ sFrame.pHdr->sA3.abyAddr2[5]
+ ) ;
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n",
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
+ }//else { TODO: received STA under state1 handle }
+ else {
+ return;
+ }
+
+
+ // assoc response reply..
+ pTxPacket = s_MgrMakeAssocResponse
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->wCurrCapInfo,
+ wAssocStatus,
+ wAssocAID,
+ sFrame.pHdr->sA3.abyAddr2,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
+ );
+ if (pTxPacket != NULL ){
+
+ if (pDevice->bEnableHostapd) {
+ return;
+ }
+ /* send the frame */
+ Status = csMgmt_xmit(pDevice, pTxPacket);
+ if (Status != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx failed\n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx sending..\n");
+ }
+
+ }
+
+ return;
+}
+
+
+/*+
+ *
+ * Description:(AP function)
+ * Handle incoming station re-association request frames.
+ *
+ * Parameters:
+ * In:
+ * pMgmt - Management Object structure
+ * pRxPacket - Received Packet
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxReAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN UINT uNodeIndex
+ )
+{
+ WLAN_FR_REASSOCREQ sFrame;
+ CMD_STATUS Status;
+ PSTxMgmtPacket pTxPacket;
+ WORD wAssocStatus = 0;
+ WORD wAssocAID = 0;
+ UINT uRateLen = WLAN_RATES_MAXLEN;
+ BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+
+ if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
+ return;
+ // node index not found
+ if (!uNodeIndex)
+ return;
+ //check if node is authenticated
+ //decode the frame
+ memset(&sFrame, 0, sizeof(WLAN_FR_REASSOCREQ));
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ vMgrDecodeReassocRequest(&sFrame);
+
+ if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {
+ pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;
+ pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);
+ pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =
+ WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? TRUE : FALSE;
+ // Todo: check sta basic rate, if ap can't support, set status code
+
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ uRateLen = WLAN_RATES_MAXLEN_11B;
+ }
+
+ abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
+ abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
+ (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
+ uRateLen);
+ abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
+ abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,
+ (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
+ uRateLen);
+ } else {
+ abyCurrExtSuppRates[1] = 0;
+ }
+
+
+ RATEvParseMaxRate((PVOID)pDevice,
+ (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,
+ FALSE, // do not change our basic rate
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
+ );
+
+ // set max tx rate
+ pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
+#ifdef PLICE_DEBUG
+ printk("RxReAssocRequest:TxDataRate is %d\n",pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
+#endif
+ // Todo: check sta preamble, if ap can't support, set status code
+ pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =
+ WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =
+ WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].wAID = (WORD)uNodeIndex;
+ wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;
+ wAssocAID = (WORD)uNodeIndex;
+
+ // if suppurt ERP
+ if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
+ pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE;
+
+ if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {
+ // B only STA join
+ pDevice->bProtectMode = TRUE;
+ pDevice->bNonERPPresent = TRUE;
+ }
+ if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == FALSE) {
+ pDevice->bBarkerPreambleMd = TRUE;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Rx ReAssociate AID= %d \n", wAssocAID);
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
+ sFrame.pHdr->sA3.abyAddr2[0],
+ sFrame.pHdr->sA3.abyAddr2[1],
+ sFrame.pHdr->sA3.abyAddr2[2],
+ sFrame.pHdr->sA3.abyAddr2[3],
+ sFrame.pHdr->sA3.abyAddr2[4],
+ sFrame.pHdr->sA3.abyAddr2[5]
+ ) ;
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n",
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
+
+ }
+
+
+ // assoc response reply..
+ pTxPacket = s_MgrMakeReAssocResponse
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->wCurrCapInfo,
+ wAssocStatus,
+ wAssocAID,
+ sFrame.pHdr->sA3.abyAddr2,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
+ );
+
+ if (pTxPacket != NULL ){
+ /* send the frame */
+ if (pDevice->bEnableHostapd) {
+ return;
+ }
+ Status = csMgmt_xmit(pDevice, pTxPacket);
+ if (Status != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx sending..\n");
+ }
+ }
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Handle incoming association response frames.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxAssocResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN BOOL bReAssocType
+ )
+{
+ WLAN_FR_ASSOCRESP sFrame;
+ PWLAN_IE_SSID pItemSSID;
+ PBYTE pbyIEs;
+ viawget_wpa_header *wpahdr;
+
+
+
+ if (pMgmt->eCurrState == WMAC_STATE_ASSOCPENDING ||
+ pMgmt->eCurrState == WMAC_STATE_ASSOC) {
+
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ // decode the frame
+ vMgrDecodeAssocResponse(&sFrame);
+ if ((sFrame.pwCapInfo == 0) ||
+ (sFrame.pwStatus == 0) ||
+ (sFrame.pwAid == 0) ||
+ (sFrame.pSuppRates == 0)){
+ DBG_PORT80(0xCC);
+ return;
+ };
+
+ pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo);
+ pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus);
+ pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.AssociationId = *(sFrame.pwAid);
+ pMgmt->sAssocInfo.AssocInfo.AvailableResponseFixedIEs |= 0x07;
+
+ pMgmt->sAssocInfo.AssocInfo.ResponseIELength = sFrame.len - 24 - 6;
+ pMgmt->sAssocInfo.AssocInfo.OffsetResponseIEs = pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs + pMgmt->sAssocInfo.AssocInfo.RequestIELength;
+ pbyIEs = pMgmt->sAssocInfo.abyIEs;
+ pbyIEs += pMgmt->sAssocInfo.AssocInfo.RequestIELength;
+ memcpy(pbyIEs, (sFrame.pBuf + 24 +6), pMgmt->sAssocInfo.AssocInfo.ResponseIELength);
+
+ // save values and set current BSS state
+ if (cpu_to_le16((*(sFrame.pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
+ // set AID
+ pMgmt->wCurrAID = cpu_to_le16((*(sFrame.pwAid)));
+ if ( (pMgmt->wCurrAID >> 14) != (BIT0 | BIT1) )
+ {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n");
+ };
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Association Successful, AID=%d.\n", pMgmt->wCurrAID & ~(BIT14|BIT15));
+ pMgmt->eCurrState = WMAC_STATE_ASSOC;
+ BSSvUpdateAPNode((HANDLE)pDevice, sFrame.pwCapInfo, sFrame.pSuppRates, sFrame.pExtSuppRates);
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID);
+ pDevice->bLinkPass = TRUE;
+ pDevice->uBBVGADiffCount = 0;
+ if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ if(skb_tailroom(pDevice->skb) <(sizeof(viawget_wpa_header)+pMgmt->sAssocInfo.AssocInfo.ResponseIELength+
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength)) { //data room not enough
+ dev_kfree_skb(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ }
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ wpahdr->type = VIAWGET_ASSOC_MSG;
+ wpahdr->resp_ie_len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength;
+ wpahdr->req_ie_len = pMgmt->sAssocInfo.AssocInfo.RequestIELength;
+ memcpy(pDevice->skb->data + sizeof(viawget_wpa_header), pMgmt->sAssocInfo.abyIEs, wpahdr->req_ie_len);
+ memcpy(pDevice->skb->data + sizeof(viawget_wpa_header) + wpahdr->req_ie_len,
+ pbyIEs,
+ wpahdr->resp_ie_len
+ );
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header) + wpahdr->resp_ie_len + wpahdr->req_ie_len);
+ pDevice->skb->dev = pDevice->wpadev;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ pDevice->skb->mac_header = pDevice->skb->data;
+#else
+ pDevice->skb->mac.raw = pDevice->skb->data;
+#endif
+ pDevice->skb->pkt_type = PACKET_HOST;
+ pDevice->skb->protocol = htons(ETH_P_802_2);
+ memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
+ netif_rx(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ }
+
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //if(pDevice->bWPADevEnable == TRUE)
+ {
+ BYTE buf[512];
+ size_t len;
+ union iwreq_data wrqu;
+ int we_event;
+
+ memset(buf, 0, 512);
+
+ len = pMgmt->sAssocInfo.AssocInfo.RequestIELength;
+ if(len) {
+ memcpy(buf, pMgmt->sAssocInfo.abyIEs, len);
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.data.length = len;
+ we_event = IWEVASSOCREQIE;
+ wireless_send_event(pDevice->dev, we_event, &wrqu, buf);
+ }
+
+ memset(buf, 0, 512);
+ len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength;
+
+ if(len) {
+ memcpy(buf, pbyIEs, len);
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.data.length = len;
+ we_event = IWEVASSOCRESPIE;
+ wireless_send_event(pDevice->dev, we_event, &wrqu, buf);
+ }
+
+
+ memset(&wrqu, 0, sizeof (wrqu));
+ memcpy(wrqu.ap_addr.sa_data, &pMgmt->abyCurrBSSID[0], ETH_ALEN);
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+#endif //#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+//End Add -- //2008-0409-07, <Add> by Einsn Liu
+ }
+ else {
+ if (bReAssocType) {
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ }
+ else {
+ // jump back to the auth state and indicate the error
+ pMgmt->eCurrState = WMAC_STATE_AUTH;
+ }
+ s_vMgrLogStatus(pMgmt,cpu_to_le16((*(sFrame.pwStatus))));
+ }
+
+ }
+
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+//need clear flags related to Networkmanager
+
+ pDevice->bwextcount = 0;
+ pDevice->bWPASuppWextEnabled = FALSE;
+#endif
+
+
+if(pMgmt->eCurrState == WMAC_STATE_ASSOC)
+ timer_expire(pDevice->sTimerCommand, 0);
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Start the station authentication procedure. Namely, send an
+ * authentication frame to the AP.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrAuthenBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ WLAN_FR_AUTHEN sFrame;
+ PSTxMgmtPacket pTxPacket = NULL;
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
+ vMgrEncodeAuthen(&sFrame);
+ /* insert values */
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ if (pMgmt->bShareKeyAlgorithm)
+ *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY);
+ else
+ *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM);
+
+ *(sFrame.pwAuthSequence) = cpu_to_le16(1);
+ /* Adjust the length fields */
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ *pStatus = csMgmt_xmit(pDevice, pTxPacket);
+ if (*pStatus == CMD_STATUS_PENDING){
+ pMgmt->eCurrState = WMAC_STATE_AUTHPENDING;
+ *pStatus = CMD_STATUS_SUCCESS;
+ }
+
+ return ;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Start the station(AP) deauthentication procedure. Namely, send an
+ * deauthentication frame to the AP or Sta.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrDeAuthenBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE abyDestAddress,
+ IN WORD wReason,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ WLAN_FR_DEAUTHEN sFrame;
+ PSTxMgmtPacket pTxPacket = NULL;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DEAUTHEN_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN;
+ vMgrEncodeDeauthen(&sFrame);
+ /* insert values */
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN)
+ ));
+
+ memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ *(sFrame.pwReason) = cpu_to_le16(wReason); // deauthen. bcs left BSS
+ /* Adjust the length fields */
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ *pStatus = csMgmt_xmit(pDevice, pTxPacket);
+ if (*pStatus == CMD_STATUS_PENDING){
+ *pStatus = CMD_STATUS_SUCCESS;
+ }
+
+
+ return ;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Handle incoming authentication frames.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxAuthentication(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ )
+{
+ WLAN_FR_AUTHEN sFrame;
+
+ // we better be an AP or a STA in AUTHPENDING otherwise ignore
+ if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP ||
+ pMgmt->eCurrState == WMAC_STATE_AUTHPENDING)) {
+ return;
+ }
+
+ // decode the frame
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ vMgrDecodeAuthen(&sFrame);
+ switch (cpu_to_le16((*(sFrame.pwAuthSequence )))){
+ case 1:
+ //AP funciton
+ s_vMgrRxAuthenSequence_1(pDevice,pMgmt, &sFrame);
+ break;
+ case 2:
+ s_vMgrRxAuthenSequence_2(pDevice, pMgmt, &sFrame);
+ break;
+ case 3:
+ //AP funciton
+ s_vMgrRxAuthenSequence_3(pDevice, pMgmt, &sFrame);
+ break;
+ case 4:
+ s_vMgrRxAuthenSequence_4(pDevice, pMgmt, &sFrame);
+ break;
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Auth Sequence error, seq = %d\n",
+ cpu_to_le16((*(sFrame.pwAuthSequence))));
+ break;
+ }
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles incoming authen frames with sequence 1. Currently
+ * assumes we're an AP. So far, no one appears to use authentication
+ * in Ad-Hoc mode.
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+
+static
+VOID
+s_vMgrRxAuthenSequence_1(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ UINT uNodeIndex;
+ WLAN_FR_AUTHEN sFrame;
+ PSKeyItem pTransmitKey;
+
+ // Insert a Node entry
+ if (!BSSDBbIsSTAInNodeDB(pMgmt, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) {
+ BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex);
+ memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, pFrame->pHdr->sA3.abyAddr2,
+ WLAN_ADDR_LEN);
+ }
+
+ if (pMgmt->bShareKeyAlgorithm) {
+ pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_KNOWN;
+ pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 1;
+ }
+ else {
+ pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH;
+ }
+
+ // send auth reply
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
+ // format buffer structure
+ vMgrEncodeAuthen(&sFrame);
+ // insert values
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
+ WLAN_SET_FC_ISWEP(0)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
+ *(sFrame.pwAuthSequence) = cpu_to_le16(2);
+
+ if (cpu_to_le16(*(pFrame->pwAuthAlgorithm)) == WLAN_AUTH_ALG_SHAREDKEY) {
+ if (pMgmt->bShareKeyAlgorithm)
+ *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
+ else
+ *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG);
+ }
+ else {
+ if (pMgmt->bShareKeyAlgorithm)
+ *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG);
+ else
+ *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
+ }
+
+ if (pMgmt->bShareKeyAlgorithm &&
+ (cpu_to_le16(*(sFrame.pwStatus)) == WLAN_MGMT_STATUS_SUCCESS)) {
+
+ sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len);
+ sFrame.len += WLAN_CHALLENGE_IE_LEN;
+ sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE;
+ sFrame.pChallenge->len = WLAN_CHALLENGE_LEN;
+ memset(pMgmt->abyChallenge, 0, WLAN_CHALLENGE_LEN);
+ // get group key
+ if(KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == TRUE) {
+ rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength+3);
+ rc4_encrypt(&pDevice->SBox, pMgmt->abyChallenge, pMgmt->abyChallenge, WLAN_CHALLENGE_LEN);
+ }
+ memcpy(sFrame.pChallenge->abyChallenge, pMgmt->abyChallenge , WLAN_CHALLENGE_LEN);
+ }
+
+ /* Adjust the length fields */
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+ // send the frame
+ if (pDevice->bEnableHostapd) {
+ return;
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n");
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx failed.\n");
+ }
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles incoming auth frames with sequence number 2. Currently
+ * assumes we're a station.
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxAuthenSequence_2(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ )
+{
+ WLAN_FR_AUTHEN sFrame;
+ PSTxMgmtPacket pTxPacket = NULL;
+
+
+ switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm))))
+ {
+ case WLAN_AUTH_ALG_OPENSYSTEM:
+ if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Successful.\n");
+ pMgmt->eCurrState = WMAC_STATE_AUTH;
+ timer_expire(pDevice->sTimerCommand, 0);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Failed.\n");
+ s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ }
+ if (pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) {
+// spin_unlock_irq(&pDevice->lock);
+// vCommandTimerWait((HANDLE)pDevice, 0);
+// spin_lock_irq(&pDevice->lock);
+ }
+
+ break;
+
+ case WLAN_AUTH_ALG_SHAREDKEY:
+
+ if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) {
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
+ // format buffer structure
+ vMgrEncodeAuthen(&sFrame);
+ // insert values
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
+ WLAN_SET_FC_ISWEP(1)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
+ *(sFrame.pwAuthSequence) = cpu_to_le16(3);
+ *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS);
+ sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len);
+ sFrame.len += WLAN_CHALLENGE_IE_LEN;
+ sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE;
+ sFrame.pChallenge->len = WLAN_CHALLENGE_LEN;
+ memcpy( sFrame.pChallenge->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN);
+ // Adjust the length fields
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+ // send the frame
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx failed.\n");
+ }
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx ...\n");
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:rx Auth_reply sequence_2 status error ...\n");
+ if ( pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) {
+// spin_unlock_irq(&pDevice->lock);
+// vCommandTimerWait((HANDLE)pDevice, 0);
+// spin_lock_irq(&pDevice->lock);
+ }
+ s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))));
+ }
+ break;
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", cpu_to_le16((*(pFrame->pwAuthAlgorithm))));
+ break;
+ }
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles incoming authen frames with sequence 3. Currently
+ * assumes we're an AP. This function assumes the frame has
+ * already been successfully decrypted.
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxAuthenSequence_3(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ UINT uStatusCode = 0 ;
+ UINT uNodeIndex = 0;
+ WLAN_FR_AUTHEN sFrame;
+
+ if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) {
+ uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
+ goto reply;
+ }
+ if (BSSDBbIsSTAInNodeDB(pMgmt, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) {
+ if (pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence != 1) {
+ uStatusCode = WLAN_MGMT_STATUS_RX_AUTH_NOSEQ;
+ goto reply;
+ }
+ if (memcmp(pMgmt->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN) != 0) {
+ uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
+ goto reply;
+ }
+ }
+ else {
+ uStatusCode = WLAN_MGMT_STATUS_UNSPEC_FAILURE;
+ goto reply;
+ }
+
+ if (uNodeIndex) {
+ pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH;
+ pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 0;
+ }
+ uStatusCode = WLAN_MGMT_STATUS_SUCCESS;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Challenge text check ok..\n");
+
+reply:
+ // send auth reply
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
+ // format buffer structure
+ vMgrEncodeAuthen(&sFrame);
+ /* insert values */
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)|
+ WLAN_SET_FC_ISWEP(0)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm);
+ *(sFrame.pwAuthSequence) = cpu_to_le16(4);
+ *(sFrame.pwStatus) = cpu_to_le16(uStatusCode);
+
+ /* Adjust the length fields */
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+ // send the frame
+ if (pDevice->bEnableHostapd) {
+ return;
+ }
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_4 tx failed.\n");
+ }
+ return;
+
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles incoming authen frames with sequence 4
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+static
+VOID
+s_vMgrRxAuthenSequence_4(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_FR_AUTHEN pFrame
+ )
+{
+
+ if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Successful.\n");
+ pMgmt->eCurrState = WMAC_STATE_AUTH;
+ timer_expire(pDevice->sTimerCommand, 0);
+ }
+ else{
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Failed.\n");
+ s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus))) );
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ }
+
+ if ( pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT ) {
+// spin_unlock_irq(&pDevice->lock);
+// vCommandTimerWait((HANDLE)pDevice, 0);
+// spin_lock_irq(&pDevice->lock);
+ }
+
+}
+
+/*+
+ *
+ * Routine Description:
+ * Handles incoming disassociation frames
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxDisassociation(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ )
+{
+ WLAN_FR_DISASSOC sFrame;
+ UINT uNodeIndex = 0;
+// CMD_STATUS CmdStatus;
+ viawget_wpa_header *wpahdr;
+
+ if ( pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){
+ // if is acting an AP..
+ // a STA is leaving this BSS..
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) {
+ BSSvRemoveOneNode(pDevice, uNodeIndex);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx disassoc, sta not found\n");
+ }
+ }
+ else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ){
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ vMgrDecodeDisassociation(&sFrame);
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame.pwReason)));
+ //TODO: do something let upper layer know or
+ //try to send associate packet again because of inactivity timeout
+ // if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
+ // vMgrReAssocBeginSta((PSDevice)pDevice, pMgmt, &CmdStatus);
+ // };
+ if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ wpahdr->type = VIAWGET_DISASSOC_MSG;
+ wpahdr->resp_ie_len = 0;
+ wpahdr->req_ie_len = 0;
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header));
+ pDevice->skb->dev = pDevice->wpadev;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ pDevice->skb->mac_header = pDevice->skb->data;
+#else
+ pDevice->skb->mac.raw = pDevice->skb->data;
+#endif
+
+ pDevice->skb->pkt_type = PACKET_HOST;
+ pDevice->skb->protocol = htons(ETH_P_802_2);
+ memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
+ netif_rx(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ };
+
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disassociated)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+
+ }
+ /* else, ignore it */
+
+ return;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles incoming deauthentication frames
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxDeauthentication(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ )
+{
+ WLAN_FR_DEAUTHEN sFrame;
+ UINT uNodeIndex = 0;
+ viawget_wpa_header *wpahdr;
+
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){
+ //Todo:
+ // if is acting an AP..
+ // a STA is leaving this BSS..
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) {
+ BSSvRemoveOneNode(pDevice, uNodeIndex);
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Rx deauth, sta not found\n");
+ }
+ }
+ else {
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ) {
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ vMgrDecodeDeauthen(&sFrame);
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason))));
+ // TODO: update BSS list for specific BSSID if pre-authentication case
+ if (IS_ETH_ADDRESS_EQUAL(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID)) {
+ if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) {
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ pMgmt->eCurrMode = WMAC_MODE_STANDBY;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ netif_stop_queue(pDevice->dev);
+ pDevice->bLinkPass = FALSE;
+ }
+ };
+
+ if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ wpahdr->type = VIAWGET_DISASSOC_MSG;
+ wpahdr->resp_ie_len = 0;
+ wpahdr->req_ie_len = 0;
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header));
+ pDevice->skb->dev = pDevice->wpadev;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)
+ pDevice->skb->mac_header = pDevice->skb->data;
+#else
+ pDevice->skb->mac.raw = pDevice->skb->data;
+#endif
+ pDevice->skb->pkt_type = PACKET_HOST;
+ pDevice->skb->protocol = htons(ETH_P_802_2);
+ memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
+ netif_rx(pDevice->skb);
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ };
+
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // if(pDevice->bWPASuppWextEnabled == TRUE)
+ {
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof (wrqu));
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ printk("wireless_send_event--->SIOCGIWAP(disauthen)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+
+ }
+ /* else, ignore it. TODO: IBSS authentication service
+ would be implemented here */
+ };
+ return;
+}
+
+
+//2008-8-4 <add> by chester
+/*+
+ *
+ * Routine Description:
+ * check if current channel is match ZoneType.
+ *for USA:1~11;
+ * Japan:1~13;
+ * Europe:1~13
+ * Return Value:
+ * True:exceed;
+ * False:normal case
+-*/
+static BOOL
+ChannelExceedZoneType(
+ IN PSDevice pDevice,
+ IN BYTE byCurrChannel
+ )
+{
+ BOOL exceed=FALSE;
+
+ switch(pDevice->byZoneType) {
+ case 0x00: //USA:1~11
+ if((byCurrChannel<1) ||(byCurrChannel>11))
+ exceed = TRUE;
+ break;
+ case 0x01: //Japan:1~13
+ case 0x02: //Europe:1~13
+ if((byCurrChannel<1) ||(byCurrChannel>13))
+ exceed = TRUE;
+ break;
+ default: //reserve for other zonetype
+ break;
+ }
+
+ return exceed;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles and analysis incoming beacon frames.
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxBeacon(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket,
+ IN BOOL bInScan
+ )
+{
+
+ PKnownBSS pBSSList;
+ WLAN_FR_BEACON sFrame;
+ QWORD qwTSFOffset;
+ BOOL bIsBSSIDEqual = FALSE;
+ BOOL bIsSSIDEqual = FALSE;
+ BOOL bTSFLargeDiff = FALSE;
+ BOOL bTSFOffsetPostive = FALSE;
+ BOOL bUpdateTSF = FALSE;
+ BOOL bIsAPBeacon = FALSE;
+ BOOL bIsChannelEqual = FALSE;
+ UINT uLocateByteIndex;
+ BYTE byTIMBitOn = 0;
+ WORD wAIDNumber = 0;
+ UINT uNodeIndex;
+ QWORD qwTimestamp, qwLocalTSF;
+ QWORD qwCurrTSF;
+ WORD wStartIndex = 0;
+ WORD wAIDIndex = 0;
+ BYTE byCurrChannel = pRxPacket->byRxChannel;
+ ERPObject sERP;
+ UINT uRateLen = WLAN_RATES_MAXLEN;
+ BOOL bChannelHit = FALSE;
+ BOOL bUpdatePhyParameter = FALSE;
+ BYTE byIEChannel = 0;
+
+
+ memset(&sFrame, 0, sizeof(WLAN_FR_BEACON));
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+
+ // decode the beacon frame
+ vMgrDecodeBeacon(&sFrame);
+
+ if ((sFrame.pwBeaconInterval == 0) ||
+ (sFrame.pwCapInfo == 0) ||
+ (sFrame.pSSID == 0) ||
+ (sFrame.pSuppRates == 0) ) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx beacon frame error\n");
+ return;
+ };
+
+
+ if (sFrame.pDSParms != NULL) {
+ if (byCurrChannel > CB_MAX_CHANNEL_24G) {
+ // channel remapping to
+ byIEChannel = CARDbyGetChannelMapping(pDevice, sFrame.pDSParms->byCurrChannel, PHY_TYPE_11A);
+ } else {
+ byIEChannel = sFrame.pDSParms->byCurrChannel;
+ }
+ if (byCurrChannel != byIEChannel) {
+ // adjust channel info. bcs we rcv adjcent channel pakckets
+ bChannelHit = FALSE;
+ byCurrChannel = byIEChannel;
+ }
+ } else {
+ // no DS channel info
+ bChannelHit = TRUE;
+ }
+//2008-0730-01<Add>by MikeLiu
+if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
+ return;
+
+ if (sFrame.pERP != NULL) {
+ sERP.byERP = sFrame.pERP->byContext;
+ sERP.bERPExist = TRUE;
+
+ } else {
+ sERP.bERPExist = FALSE;
+ sERP.byERP = 0;
+ }
+
+ pBSSList = BSSpAddrIsInBSSList((HANDLE)pDevice, sFrame.pHdr->sA3.abyAddr3, sFrame.pSSID);
+ if (pBSSList == NULL) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon/insert: RxChannel = : %d\n", byCurrChannel);
+ BSSbInsertToBSSList((HANDLE)pDevice,
+ sFrame.pHdr->sA3.abyAddr3,
+ *sFrame.pqwTimestamp,
+ *sFrame.pwBeaconInterval,
+ *sFrame.pwCapInfo,
+ byCurrChannel,
+ sFrame.pSSID,
+ sFrame.pSuppRates,
+ sFrame.pExtSuppRates,
+ &sERP,
+ sFrame.pRSN,
+ sFrame.pRSNWPA,
+ sFrame.pIE_Country,
+ sFrame.pIE_Quiet,
+ sFrame.len - WLAN_HDR_ADDR3_LEN,
+ sFrame.pHdr->sA4.abyAddr4, // payload of beacon
+ (HANDLE)pRxPacket
+ );
+ }
+ else {
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"update bcn: RxChannel = : %d\n", byCurrChannel);
+ BSSbUpdateToBSSList((HANDLE)pDevice,
+ *sFrame.pqwTimestamp,
+ *sFrame.pwBeaconInterval,
+ *sFrame.pwCapInfo,
+ byCurrChannel,
+ bChannelHit,
+ sFrame.pSSID,
+ sFrame.pSuppRates,
+ sFrame.pExtSuppRates,
+ &sERP,
+ sFrame.pRSN,
+ sFrame.pRSNWPA,
+ sFrame.pIE_Country,
+ sFrame.pIE_Quiet,
+ pBSSList,
+ sFrame.len - WLAN_HDR_ADDR3_LEN,
+ sFrame.pHdr->sA4.abyAddr4, // payload of probresponse
+ (HANDLE)pRxPacket
+ );
+
+ }
+
+ if (bInScan) {
+ return;
+ }
+
+ if(byCurrChannel == (BYTE)pMgmt->uCurrChannel)
+ bIsChannelEqual = TRUE;
+
+ if (bIsChannelEqual && (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
+
+ // if rx beacon without ERP field
+ if (sERP.bERPExist) {
+ if (WLAN_GET_ERP_USE_PROTECTION(sERP.byERP)){
+ pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
+ pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD;
+ }
+ }
+ else {
+ pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
+ pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD;
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ if(!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo))
+ pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
+ if(!sERP.bERPExist)
+ pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
+ }
+
+ // set to MAC&BBP
+ if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)){
+ if (!pDevice->bProtectMode) {
+ MACvEnableProtectMD(pDevice->PortOffset);
+ pDevice->bProtectMode = TRUE;
+ }
+ }
+ }
+
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
+ return;
+
+ // check if BSSID the same
+ if (memcmp(sFrame.pHdr->sA3.abyAddr3,
+ pMgmt->abyCurrBSSID,
+ WLAN_BSSID_LEN) == 0) {
+
+ bIsBSSIDEqual = TRUE;
+
+// 2008-05-21 <add> by Richardtai
+ pDevice->uCurrRSSI = pRxPacket->uRSSI;
+ pDevice->byCurrSQ = pRxPacket->bySQ;
+
+ if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) {
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp);
+ }
+ }
+ // check if SSID the same
+ if (sFrame.pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) {
+ if (memcmp(sFrame.pSSID->abySSID,
+ ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,
+ sFrame.pSSID->len
+ ) == 0) {
+ bIsSSIDEqual = TRUE;
+ };
+ }
+
+ if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== TRUE) &&
+ (bIsBSSIDEqual == TRUE) &&
+ (bIsSSIDEqual == TRUE) &&
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ // add state check to prevent reconnect fail since we'll receive Beacon
+
+ bIsAPBeacon = TRUE;
+
+ if (pBSSList != NULL) {
+
+ // Compare PHY paramater setting
+ if (pMgmt->wCurrCapInfo != pBSSList->wCapInfo) {
+ bUpdatePhyParameter = TRUE;
+ pMgmt->wCurrCapInfo = pBSSList->wCapInfo;
+ }
+ if (sFrame.pERP != NULL) {
+ if ((sFrame.pERP->byElementID == WLAN_EID_ERP) &&
+ (pMgmt->byERPContext != sFrame.pERP->byContext)) {
+ bUpdatePhyParameter = TRUE;
+ pMgmt->byERPContext = sFrame.pERP->byContext;
+ }
+ }
+ //
+ // Basic Rate Set may change dynamiclly
+ //
+ if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B) {
+ uRateLen = WLAN_RATES_MAXLEN_11B;
+ }
+ pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abySuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ uRateLen);
+ pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abyExtSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
+ uRateLen);
+ RATEvParseMaxRate( (PVOID)pDevice,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
+ TRUE,
+ &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[0].wSuppRate),
+ &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
+ );
+#ifdef PLICE_DEBUG
+ //printk("RxBeacon:MaxSuppRate is %d\n",pMgmt->sNodeDBTable[0].wMaxSuppRate);
+#endif
+ if (bUpdatePhyParameter == TRUE) {
+ CARDbSetPhyParameter( pMgmt->pAdapter,
+ pMgmt->eCurrentPHYMode,
+ pMgmt->wCurrCapInfo,
+ pMgmt->byERPContext,
+ pMgmt->abyCurrSuppRates,
+ pMgmt->abyCurrExtSuppRates
+ );
+ }
+ if (sFrame.pIE_PowerConstraint != NULL) {
+ CARDvSetPowerConstraint(pMgmt->pAdapter,
+ (BYTE) pBSSList->uChannel,
+ sFrame.pIE_PowerConstraint->byPower
+ );
+ }
+ if (sFrame.pIE_CHSW != NULL) {
+ CARDbChannelSwitch( pMgmt->pAdapter,
+ sFrame.pIE_CHSW->byMode,
+ CARDbyGetChannelMapping(pMgmt->pAdapter, sFrame.pIE_CHSW->byMode, pMgmt->eCurrentPHYMode),
+ sFrame.pIE_CHSW->byCount
+ );
+
+ } else if (bIsChannelEqual == FALSE) {
+ CARDbSetChannel(pMgmt->pAdapter, pBSSList->uChannel);
+ }
+ }
+ }
+
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Beacon 2 \n");
+ // check if CF field exisit
+ if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) {
+ if (sFrame.pCFParms->wCFPDurRemaining > 0) {
+ // TODO: deal with CFP period to set NAV
+ };
+ };
+
+ HIDWORD(qwTimestamp) = cpu_to_le32(HIDWORD(*sFrame.pqwTimestamp));
+ LODWORD(qwTimestamp) = cpu_to_le32(LODWORD(*sFrame.pqwTimestamp));
+ HIDWORD(qwLocalTSF) = HIDWORD(pRxPacket->qwLocalTSF);
+ LODWORD(qwLocalTSF) = LODWORD(pRxPacket->qwLocalTSF);
+
+ // check if beacon TSF larger or small than our local TSF
+ if (HIDWORD(qwTimestamp) == HIDWORD(qwLocalTSF)) {
+ if (LODWORD(qwTimestamp) >= LODWORD(qwLocalTSF)) {
+ bTSFOffsetPostive = TRUE;
+ }
+ else {
+ bTSFOffsetPostive = FALSE;
+ }
+ }
+ else if (HIDWORD(qwTimestamp) > HIDWORD(qwLocalTSF)) {
+ bTSFOffsetPostive = TRUE;
+ }
+ else if (HIDWORD(qwTimestamp) < HIDWORD(qwLocalTSF)) {
+ bTSFOffsetPostive = FALSE;
+ };
+
+ if (bTSFOffsetPostive) {
+ qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF));
+ }
+ else {
+ qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp));
+ }
+
+ if (HIDWORD(qwTSFOffset) != 0 ||
+ (LODWORD(qwTSFOffset) > TRIVIAL_SYNC_DIFFERENCE )) {
+ bTSFLargeDiff = TRUE;
+ }
+
+
+ // if infra mode
+ if (bIsAPBeacon == TRUE) {
+
+ // Infra mode: Local TSF always follow AP's TSF if Difference huge.
+ if (bTSFLargeDiff)
+ bUpdateTSF = TRUE;
+
+ if ((pDevice->bEnablePSMode == TRUE) &&(sFrame.pTIM != 0)) {
+
+ // deal with DTIM, analysis TIM
+ pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? TRUE : FALSE ;
+ pMgmt->byDTIMCount = sFrame.pTIM->byDTIMCount;
+ pMgmt->byDTIMPeriod = sFrame.pTIM->byDTIMPeriod;
+ wAIDNumber = pMgmt->wCurrAID & ~(BIT14|BIT15);
+
+ // check if AID in TIM field bit on
+ // wStartIndex = N1
+ wStartIndex = WLAN_MGMT_GET_TIM_OFFSET(sFrame.pTIM->byBitMapCtl) << 1;
+ // AIDIndex = N2
+ wAIDIndex = (wAIDNumber >> 3);
+ if ((wAIDNumber > 0) && (wAIDIndex >= wStartIndex)) {
+ uLocateByteIndex = wAIDIndex - wStartIndex;
+ // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250]
+ if (sFrame.pTIM->len >= (uLocateByteIndex + 4)) {
+ byTIMBitOn = (0x01) << ((wAIDNumber) % 8);
+ pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? TRUE : FALSE;
+ }
+ else {
+ pMgmt->bInTIM = FALSE;
+ };
+ }
+ else {
+ pMgmt->bInTIM = FALSE;
+ };
+
+ if (pMgmt->bInTIM ||
+ (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) {
+ pMgmt->bInTIMWake = TRUE;
+ // send out ps-poll packet
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n");
+ if (pMgmt->bInTIM) {
+ PSvSendPSPOLL((PSDevice)pDevice);
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
+ };
+
+ }
+ else {
+ pMgmt->bInTIMWake = FALSE;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Not In TIM..\n");
+ if (pDevice->bPWBitOn == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Send Null Packet\n");
+ if (PSbSendNullPacket(pDevice))
+ pDevice->bPWBitOn = TRUE;
+ }
+ if(PSbConsiderPowerDown(pDevice, FALSE, FALSE)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n");
+ };
+ }
+
+ }
+
+ }
+ // if adhoc mode
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && !bIsAPBeacon && bIsChannelEqual) {
+ if (bIsBSSIDEqual) {
+ // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count.
+ if (pMgmt->sNodeDBTable[0].uInActiveCount != 0)
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+
+ // adhoc mode:TSF updated only when beacon larger then local TSF
+ if (bTSFLargeDiff && bTSFOffsetPostive &&
+ (pMgmt->eCurrState == WMAC_STATE_JOINTED))
+ bUpdateTSF = TRUE;
+
+ // During dpc, already in spinlocked.
+ if (BSSDBbIsSTAInNodeDB(pMgmt, sFrame.pHdr->sA3.abyAddr2, &uNodeIndex)) {
+
+ // Update the STA, (Techically the Beacons of all the IBSS nodes
+ // should be identical, but that's not happening in practice.
+ pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ WLAN_RATES_MAXLEN_11B);
+ RATEvParseMaxRate( (PVOID)pDevice,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ NULL,
+ TRUE,
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
+ );
+ pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0;
+ }
+ else {
+ // Todo, initial Node content
+ BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex);
+
+ pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ WLAN_RATES_MAXLEN_11B);
+ RATEvParseMaxRate( (PVOID)pDevice,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ NULL,
+ TRUE,
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),
+ &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)
+ );
+
+ memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, sFrame.pHdr->sA3.abyAddr2, WLAN_ADDR_LEN);
+ pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);
+ pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;
+#ifdef PLICE_DEBUG
+ //if (uNodeIndex == 0)
+ {
+ printk("s_vMgrRxBeacon:TxDataRate is %d,Index is %d\n",pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate,uNodeIndex);
+ }
+#endif
+/*
+ pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);
+ if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)
+ pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE;
+*/
+ }
+
+ // if other stations jointed, indicate connect to upper layer..
+ if (pMgmt->eCurrState == WMAC_STATE_STARTED) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n");
+ pMgmt->eCurrState = WMAC_STATE_JOINTED;
+ pDevice->bLinkPass = TRUE;
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+ pMgmt->sNodeDBTable[0].bActive = TRUE;
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+
+ };
+ }
+ else if (bIsSSIDEqual) {
+
+ // See other adhoc sta with the same SSID but BSSID is different.
+ // adpot this vars only when TSF larger then us.
+ if (bTSFLargeDiff && bTSFOffsetPostive) {
+ // we don't support ATIM under adhoc mode
+ // if ( sFrame.pIBSSParms->wATIMWindow == 0) {
+ // adpot this vars
+ // TODO: check sFrame cap if privacy on, and support rate syn
+ memcpy(pMgmt->abyCurrBSSID, sFrame.pHdr->sA3.abyAddr3, WLAN_BSSID_LEN);
+ memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ pMgmt->wCurrATIMWindow = cpu_to_le16(sFrame.pIBSSParms->wATIMWindow);
+ pMgmt->wCurrBeaconPeriod = cpu_to_le16(*sFrame.pwBeaconInterval);
+ pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ WLAN_RATES_MAXLEN_11B);
+ // set HW beacon interval and re-synchronizing....
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rejoining to Other Adhoc group with same SSID........\n");
+ VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, pMgmt->wCurrBeaconPeriod);
+ CARDbUpdateTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, qwLocalTSF);
+ CARDvUpdateNextTBTT(pDevice->PortOffset, qwTimestamp, pMgmt->wCurrBeaconPeriod);
+ // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
+ MACvWriteBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID);
+
+ CARDbSetPhyParameter ( pMgmt->pAdapter,
+ pMgmt->eCurrentPHYMode,
+ pMgmt->wCurrCapInfo,
+ pMgmt->byERPContext,
+ pMgmt->abyCurrSuppRates,
+ pMgmt->abyCurrExtSuppRates);
+
+
+ // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
+ // set highest basic rate
+ // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates);
+ // Prepare beacon frame
+ bMgrPrepareBeaconToSend((HANDLE)pDevice, pMgmt);
+ // }
+ };
+ }
+ };
+ // endian issue ???
+ // Update TSF
+ if (bUpdateTSF) {
+ CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
+ CARDbUpdateTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, pRxPacket->qwLocalTSF);
+ CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
+ CARDvUpdateNextTBTT(pDevice->PortOffset, qwTimestamp, pMgmt->wCurrBeaconPeriod);
+ }
+
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Instructs the hw to create a bss using the supplied
+ * attributes. Note that this implementation only supports Ad-Hoc
+ * BSS creation.
+ *
+ *
+ * Return Value:
+ * CMD_STATUS
+ *
+-*/
+VOID
+vMgrCreateOwnIBSS(
+ IN HANDLE hDeviceContext,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ WORD wMaxBasicRate;
+ WORD wMaxSuppRate;
+ BYTE byTopCCKBasicRate;
+ BYTE byTopOFDMBasicRate;
+ QWORD qwCurrTSF;
+ UINT ii;
+ BYTE abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60};
+ BYTE abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96};
+ BYTE abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+ WORD wSuppRate;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create Basic Service Set .......\n");
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
+ if ((pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) &&
+ (pDevice->eEncryptionStatus != Ndis802_11Encryption2Enabled) &&
+ (pDevice->eEncryptionStatus != Ndis802_11Encryption3Enabled)) {
+ // encryption mode error
+ *pStatus = CMD_STATUS_FAILURE;
+ return;
+ }
+ }
+
+ pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
+ pMgmt->abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ pMgmt->eCurrentPHYMode = pMgmt->byAPBBType;
+ } else {
+ if (pDevice->byBBType == BB_TYPE_11G)
+ pMgmt->eCurrentPHYMode = PHY_TYPE_11G;
+ if (pDevice->byBBType == BB_TYPE_11B)
+ pMgmt->eCurrentPHYMode = PHY_TYPE_11B;
+ if (pDevice->byBBType == BB_TYPE_11A)
+ pMgmt->eCurrentPHYMode = PHY_TYPE_11A;
+ }
+
+ if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
+ pMgmt->abyCurrSuppRates[1] = WLAN_RATES_MAXLEN_11B;
+ pMgmt->abyCurrExtSuppRates[1] = 0;
+ for (ii = 0; ii < 4; ii++)
+ pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii];
+ } else {
+ pMgmt->abyCurrSuppRates[1] = 8;
+ pMgmt->abyCurrExtSuppRates[1] = 0;
+ for (ii = 0; ii < 8; ii++)
+ pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii];
+ }
+
+
+ if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
+ pMgmt->abyCurrSuppRates[1] = 8;
+ pMgmt->abyCurrExtSuppRates[1] = 4;
+ for (ii = 0; ii < 4; ii++)
+ pMgmt->abyCurrSuppRates[2+ii] = abyCCK_RATE[ii];
+ for (ii = 4; ii < 8; ii++)
+ pMgmt->abyCurrSuppRates[2+ii] = abyOFDM_RATE[ii-4];
+ for (ii = 0; ii < 4; ii++)
+ pMgmt->abyCurrExtSuppRates[2+ii] = abyOFDM_RATE[ii+4];
+ }
+
+
+ // Disable Protect Mode
+ pDevice->bProtectMode = 0;
+ MACvDisableProtectMD(pDevice->PortOffset);
+
+ pDevice->bBarkerPreambleMd = 0;
+ MACvDisableBarkerPreambleMd(pDevice->PortOffset);
+
+ // Kyle Test 2003.11.04
+
+ // set HW beacon interval
+ if (pMgmt->wIBSSBeaconPeriod == 0)
+ pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
+
+
+ CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
+ // clear TSF counter
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
+ // enable TSF counter
+ VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
+
+ // set Next TBTT
+ CARDvSetFirstNextTBTT(pDevice->PortOffset, pMgmt->wIBSSBeaconPeriod);
+
+ pMgmt->uIBSSChannel = pDevice->uChannel;
+
+ if (pMgmt->uIBSSChannel == 0)
+ pMgmt->uIBSSChannel = DEFAULT_IBSS_CHANNEL;
+
+
+ // set basic rate
+
+ RATEvParseMaxRate((PVOID)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, TRUE,
+ &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
+ &byTopCCKBasicRate, &byTopOFDMBasicRate);
+
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ pMgmt->eCurrMode = WMAC_MODE_ESS_AP;
+ }
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
+ MEMvCopy(pMgmt->abyIBSSDFSOwner, pDevice->abyCurrentNetAddr, 6);
+ pMgmt->byIBSSDFSRecovery = 10;
+ pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
+ }
+
+ // Adopt pre-configured IBSS vars to current vars
+ pMgmt->eCurrState = WMAC_STATE_STARTED;
+ pMgmt->wCurrBeaconPeriod = pMgmt->wIBSSBeaconPeriod;
+ pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
+ pMgmt->wCurrATIMWindow = pMgmt->wIBSSATIMWindow;
+ MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
+ pDevice->uCurrRSSI = 0;
+ pDevice->byCurrSQ = 0;
+ //memcpy(pMgmt->abyDesireSSID,pMgmt->abyAdHocSSID,
+ // ((PWLAN_IE_SSID)pMgmt->abyAdHocSSID)->len + WLAN_IEHDR_LEN);
+ memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memcpy(pMgmt->abyCurrSSID,
+ pMgmt->abyDesireSSID,
+ ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN
+ );
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ // AP mode BSSID = MAC addr
+ memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO"AP beacon created BSSID:%02x-%02x-%02x-%02x-%02x-%02x \n",
+ pMgmt->abyCurrBSSID[0],
+ pMgmt->abyCurrBSSID[1],
+ pMgmt->abyCurrBSSID[2],
+ pMgmt->abyCurrBSSID[3],
+ pMgmt->abyCurrBSSID[4],
+ pMgmt->abyCurrBSSID[5]
+ );
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+
+ // BSSID selected must be randomized as spec 11.1.3
+ pMgmt->abyCurrBSSID[5] = (BYTE) (LODWORD(qwCurrTSF)& 0x000000ff);
+ pMgmt->abyCurrBSSID[4] = (BYTE)((LODWORD(qwCurrTSF)& 0x0000ff00) >> 8);
+ pMgmt->abyCurrBSSID[3] = (BYTE)((LODWORD(qwCurrTSF)& 0x00ff0000) >> 16);
+ pMgmt->abyCurrBSSID[2] = (BYTE)((LODWORD(qwCurrTSF)& 0x00000ff0) >> 4);
+ pMgmt->abyCurrBSSID[1] = (BYTE)((LODWORD(qwCurrTSF)& 0x000ff000) >> 12);
+ pMgmt->abyCurrBSSID[0] = (BYTE)((LODWORD(qwCurrTSF)& 0x0ff00000) >> 20);
+ pMgmt->abyCurrBSSID[5] ^= pMgmt->abyMACAddr[0];
+ pMgmt->abyCurrBSSID[4] ^= pMgmt->abyMACAddr[1];
+ pMgmt->abyCurrBSSID[3] ^= pMgmt->abyMACAddr[2];
+ pMgmt->abyCurrBSSID[2] ^= pMgmt->abyMACAddr[3];
+ pMgmt->abyCurrBSSID[1] ^= pMgmt->abyMACAddr[4];
+ pMgmt->abyCurrBSSID[0] ^= pMgmt->abyMACAddr[5];
+ pMgmt->abyCurrBSSID[0] &= ~IEEE_ADDR_GROUP;
+ pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL;
+
+
+ DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO"Adhoc beacon created bssid:%02x-%02x-%02x-%02x-%02x-%02x \n",
+ pMgmt->abyCurrBSSID[0],
+ pMgmt->abyCurrBSSID[1],
+ pMgmt->abyCurrBSSID[2],
+ pMgmt->abyCurrBSSID[3],
+ pMgmt->abyCurrBSSID[4],
+ pMgmt->abyCurrBSSID[5]
+ );
+ }
+
+ // Set Capability Info
+ pMgmt->wCurrCapInfo = 0;
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
+ pMgmt->byDTIMPeriod = DEFAULT_DTIM_PERIOD;
+ pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1);
+ }
+
+ if (pDevice->bEncryptionEnable) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ pMgmt->byCSSPK = KEY_CTL_CCMP;
+ pMgmt->byCSSGK = KEY_CTL_CCMP;
+ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ pMgmt->byCSSPK = KEY_CTL_TKIP;
+ pMgmt->byCSSGK = KEY_CTL_TKIP;
+ } else {
+ pMgmt->byCSSPK = KEY_CTL_NONE;
+ pMgmt->byCSSGK = KEY_CTL_WEP;
+ }
+ } else {
+ pMgmt->byCSSPK = KEY_CTL_WEP;
+ pMgmt->byCSSGK = KEY_CTL_WEP;
+ }
+ };
+
+ pMgmt->byERPContext = 0;
+
+// memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_AP);
+ } else {
+ CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
+ }
+
+ CARDbSetPhyParameter( pMgmt->pAdapter,
+ pMgmt->eCurrentPHYMode,
+ pMgmt->wCurrCapInfo,
+ pMgmt->byERPContext,
+ pMgmt->abyCurrSuppRates,
+ pMgmt->abyCurrExtSuppRates
+ );
+
+ CARDbSetBeaconPeriod(pMgmt->pAdapter, pMgmt->wIBSSBeaconPeriod);
+ // set channel and clear NAV
+ CARDbSetChannel(pMgmt->pAdapter, pMgmt->uIBSSChannel);
+ pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
+
+ if (CARDbIsShortPreamble(pMgmt->pAdapter)) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ } else {
+ pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1));
+ }
+
+ if ((pMgmt->b11hEnable == TRUE) &&
+ (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);
+ } else {
+ pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SPECTRUMMNG(1));
+ }
+
+ pMgmt->eCurrState = WMAC_STATE_STARTED;
+ // Prepare beacon to send
+ if (bMgrPrepareBeaconToSend((HANDLE)pDevice, pMgmt)) {
+ *pStatus = CMD_STATUS_SUCCESS;
+ }
+
+ return ;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Instructs wmac to join a bss using the supplied attributes.
+ * The arguments may the BSSID or SSID and the rest of the
+ * attributes are obtained from the scan result of known bss list.
+ *
+ *
+ * Return Value:
+ * None.
+ *
+-*/
+
+VOID
+vMgrJoinBSSBegin(
+ IN HANDLE hDeviceContext,
+ OUT PCMD_STATUS pStatus
+ )
+{
+
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PKnownBSS pCurr = NULL;
+ UINT ii, uu;
+ PWLAN_IE_SUPP_RATES pItemRates = NULL;
+ PWLAN_IE_SUPP_RATES pItemExtRates = NULL;
+ PWLAN_IE_SSID pItemSSID;
+ UINT uRateLen = WLAN_RATES_MAXLEN;
+ WORD wMaxBasicRate = RATE_1M;
+ WORD wMaxSuppRate = RATE_1M;
+ WORD wSuppRate;
+ BYTE byTopCCKBasicRate = RATE_1M;
+ BYTE byTopOFDMBasicRate = RATE_1M;
+
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (pMgmt->sBSSList[ii].bActive == TRUE)
+ break;
+ }
+
+ if (ii == MAX_BSS_NUM) {
+ *pStatus = CMD_STATUS_RESOURCES;
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "BSS finding:BSS list is empty.\n");
+ return;
+ };
+
+ // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN);
+ // Search known BSS list for prefer BSSID or SSID
+
+ pCurr = BSSpSearchBSSList(pDevice,
+ pMgmt->abyDesireBSSID,
+ pMgmt->abyDesireSSID,
+ pMgmt->eConfigPHYMode
+ );
+
+ if (pCurr == NULL){
+ *pStatus = CMD_STATUS_RESOURCES;
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Scanning [%s] not found, disconnected !\n", pItemSSID->abySSID);
+ return;
+ };
+
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP(BSS) finding:Found a AP(BSS)..\n");
+ if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))){
+
+ if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA)||(pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
+
+ // patch for CISCO migration mode
+/*
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ // encryption mode error
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ return;
+ }
+ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ // encryption mode error
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ return;
+ }
+ }
+*/
+ }
+
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //if(pDevice->bWPASuppWextEnabled == TRUE)
+ Encyption_Rebuild(pDevice, pCurr);
+#endif
+ // Infrastructure BSS
+ s_vMgrSynchBSS(pDevice,
+ WMAC_MODE_ESS_STA,
+ pCurr,
+ pStatus
+ );
+
+ if (*pStatus == CMD_STATUS_SUCCESS){
+
+ // Adopt this BSS state vars in Mgmt Object
+ pMgmt->uCurrChannel = pCurr->uChannel;
+
+ memset(pMgmt->abyCurrSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
+ memset(pMgmt->abyCurrExtSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
+
+ if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) {
+ uRateLen = WLAN_RATES_MAXLEN_11B;
+ }
+
+ pItemRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates;
+ pItemExtRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates;
+
+ // Parse Support Rate IE
+ pItemRates->byElementID = WLAN_EID_SUPP_RATES;
+ pItemRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates,
+ pItemRates,
+ uRateLen);
+
+ // Parse Extension Support Rate IE
+ pItemExtRates->byElementID = WLAN_EID_EXTSUPP_RATES;
+ pItemExtRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abyExtSuppRates,
+ pItemExtRates,
+ uRateLen);
+ // Stuffing Rate IE
+ if ((pItemExtRates->len > 0) && (pItemRates->len < 8)) {
+ for (ii = 0; ii < (UINT)(8 - pItemRates->len); ) {
+ pItemRates->abyRates[pItemRates->len + ii] = pItemExtRates->abyRates[ii];
+ ii ++;
+ if (pItemExtRates->len <= ii)
+ break;
+ }
+ pItemRates->len += (BYTE)ii;
+ if (pItemExtRates->len - ii > 0) {
+ pItemExtRates->len -= (BYTE)ii;
+ for (uu = 0; uu < pItemExtRates->len; uu ++) {
+ pItemExtRates->abyRates[uu] = pItemExtRates->abyRates[uu + ii];
+ }
+ } else {
+ pItemExtRates->len = 0;
+ }
+ }
+
+ RATEvParseMaxRate((PVOID)pDevice, pItemRates, pItemExtRates, TRUE,
+ &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
+ &byTopCCKBasicRate, &byTopOFDMBasicRate);
+
+ // TODO: deal with if wCapInfo the privacy is on, but station WEP is off
+ // TODO: deal with if wCapInfo the PS-Pollable is on.
+ pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval;
+ memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
+ memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+
+ pMgmt->eCurrMode = WMAC_MODE_ESS_STA;
+
+ pMgmt->eCurrState = WMAC_STATE_JOINTED;
+ // Adopt BSS state in Adapter Device Object
+ //pDevice->byOpMode = OP_MODE_INFRASTRUCTURE;
+// memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
+
+ // Add current BSS to Candidate list
+ // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
+ BOOL bResult = bAdd_PMKID_Candidate((HANDLE)pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate: 1(%d)\n", bResult);
+ if (bResult == FALSE) {
+ vFlush_PMKID_Candidate((HANDLE)pDevice);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFlush_PMKID_Candidate: 4\n");
+ bAdd_PMKID_Candidate((HANDLE)pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj);
+ }
+ }
+
+ // Preamble type auto-switch: if AP can receive short-preamble cap,
+ // we can turn on too.
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join ESS\n");
+
+
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"End of Join AP -- A/B/G Action\n");
+ }
+ else {
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ };
+
+
+ }
+ else {
+ // ad-hoc mode BSS
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) {
+ // encryption mode error
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ return;
+ }
+ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == FALSE) {
+ // encryption mode error
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ return;
+ }
+ } else {
+ // encryption mode error
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ return;
+ }
+ }
+
+ s_vMgrSynchBSS(pDevice,
+ WMAC_MODE_IBSS_STA,
+ pCurr,
+ pStatus
+ );
+
+ if (*pStatus == CMD_STATUS_SUCCESS){
+ // Adopt this BSS state vars in Mgmt Object
+ // TODO: check if CapInfo privacy on, but we don't..
+ pMgmt->uCurrChannel = pCurr->uChannel;
+
+
+ // Parse Support Rate IE
+ pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;
+ pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ WLAN_RATES_MAXLEN_11B);
+ // set basic rate
+ RATEvParseMaxRate((PVOID)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ NULL, TRUE, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate,
+ &byTopCCKBasicRate, &byTopOFDMBasicRate);
+
+ pMgmt->wCurrCapInfo = pCurr->wCapInfo;
+ pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval;
+ memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN);
+ memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
+ memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN);
+// pMgmt->wCurrATIMWindow = pCurr->wATIMWindow;
+ MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
+ pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
+
+ pMgmt->eCurrState = WMAC_STATE_STARTED;
+ // Adopt BSS state in Adapter Device Object
+ //pDevice->byOpMode = OP_MODE_ADHOC;
+// pDevice->bLinkPass = TRUE;
+// memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%02x-%02x-%02x-%02x-%02x-%02x \n",
+ pMgmt->abyCurrBSSID[0],
+ pMgmt->abyCurrBSSID[1],
+ pMgmt->abyCurrBSSID[2],
+ pMgmt->abyCurrBSSID[3],
+ pMgmt->abyCurrBSSID[4],
+ pMgmt->abyCurrBSSID[5]
+ );
+ // Preamble type auto-switch: if AP can receive short-preamble cap,
+ // and if registry setting is short preamble we can turn on too.
+
+ // Prepare beacon
+ bMgrPrepareBeaconToSend((HANDLE)pDevice, pMgmt);
+ }
+ else {
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ };
+ };
+ return;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Set HW to synchronize a specific BSS from known BSS list.
+ *
+ *
+ * Return Value:
+ * PCM_STATUS
+ *
+-*/
+static
+VOID
+s_vMgrSynchBSS (
+ IN PSDevice pDevice,
+ IN UINT uBSSMode,
+ IN PKnownBSS pCurr,
+ OUT PCMD_STATUS pStatus
+ )
+{
+ CARD_PHY_TYPE ePhyType = PHY_TYPE_11B;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+// int ii;
+ //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
+ BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
+ BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
+ //6M, 9M, 12M, 48M
+ BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+ BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
+
+
+ *pStatus = CMD_STATUS_FAILURE;
+
+ if (s_bCipherMatch(pCurr,
+ pDevice->eEncryptionStatus,
+ &(pMgmt->byCSSPK),
+ &(pMgmt->byCSSGK)) == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "s_bCipherMatch Fail .......\n");
+ return;
+ }
+
+ pMgmt->pCurrBSS = pCurr;
+
+ // if previous mode is IBSS.
+ if(pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_BCNDMACTL, BEACON_READY);
+ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+
+ // Init the BSS informations
+ pDevice->bCCK = TRUE;
+ pDevice->bProtectMode = FALSE;
+ MACvDisableProtectMD(pDevice->PortOffset);
+ pDevice->bBarkerPreambleMd = FALSE;
+ MACvDisableBarkerPreambleMd(pDevice->PortOffset);
+ pDevice->bNonERPPresent = FALSE;
+ pDevice->byPreambleType = 0;
+ pDevice->wBasicRate = 0;
+ // Set Basic Rate
+ CARDbAddBasicRate((PVOID)pDevice, RATE_1M);
+ // calculate TSF offset
+ // TSF Offset = Received Timestamp TSF - Marked Local's TSF
+ CARDbUpdateTSF(pDevice, pCurr->byRxRate, pCurr->qwBSSTimestamp, pCurr->qwLocalTSF);
+
+ CARDbSetBeaconPeriod(pDevice, pCurr->wBeaconInterval);
+
+ // set Next TBTT
+ // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
+ CARDvSetFirstNextTBTT(pDevice->PortOffset, pCurr->wBeaconInterval);
+
+ // set BSSID
+ MACvWriteBSSIDAddress(pDevice->PortOffset, pCurr->abyBSSID);
+
+ MACvReadBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:set CurrBSSID address = %02x-%02x-%02x=%02x-%02x-%02x\n",
+ pMgmt->abyCurrBSSID[0],
+ pMgmt->abyCurrBSSID[1],
+ pMgmt->abyCurrBSSID[2],
+ pMgmt->abyCurrBSSID[3],
+ pMgmt->abyCurrBSSID[4],
+ pMgmt->abyCurrBSSID[5]);
+
+ if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) {
+ if ((pMgmt->eConfigPHYMode == PHY_TYPE_11A) ||
+ (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) {
+ ePhyType = PHY_TYPE_11A;
+ } else {
+ return;
+ }
+ } else if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) {
+ if ((pMgmt->eConfigPHYMode == PHY_TYPE_11B) ||
+ (pMgmt->eConfigPHYMode == PHY_TYPE_11G) ||
+ (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) {
+ ePhyType = PHY_TYPE_11B;
+ } else {
+ return;
+ }
+ } else {
+ if ((pMgmt->eConfigPHYMode == PHY_TYPE_11G) ||
+ (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) {
+ ePhyType = PHY_TYPE_11G;
+ } else if (pMgmt->eConfigPHYMode == PHY_TYPE_11B) {
+ ePhyType = PHY_TYPE_11B;
+ } else {
+ return;
+ }
+ }
+
+ if (ePhyType == PHY_TYPE_11A) {
+ MEMvCopy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA));
+ pMgmt->abyCurrExtSuppRates[1] = 0;
+ } else if (ePhyType == PHY_TYPE_11B) {
+ MEMvCopy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesB[0], sizeof(abyCurrSuppRatesB));
+ pMgmt->abyCurrExtSuppRates[1] = 0;
+ } else {
+ MEMvCopy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesG[0], sizeof(abyCurrSuppRatesG));
+ MEMvCopy(pMgmt->abyCurrExtSuppRates, &abyCurrExtSuppRatesG[0], sizeof(abyCurrExtSuppRatesG));
+ }
+
+
+ if (WLAN_GET_CAP_INFO_ESS(pCurr->wCapInfo)) {
+ CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, OP_MODE_INFRASTRUCTURE);
+ // Add current BSS to Candidate list
+ // This should only works for WPA2 BSS, and WPA2 BSS check must be done before.
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
+ CARDbAdd_PMKID_Candidate(pMgmt->pAdapter, pMgmt->abyCurrBSSID, pCurr->sRSNCapObj.bRSNCapExist, pCurr->sRSNCapObj.wRSNCap);
+ }
+ } else {
+ CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, OP_MODE_ADHOC);
+ }
+
+ if (CARDbSetPhyParameter( pMgmt->pAdapter,
+ ePhyType,
+ pCurr->wCapInfo,
+ pCurr->sERP.byERP,
+ pMgmt->abyCurrSuppRates,
+ pMgmt->abyCurrExtSuppRates
+ ) != TRUE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Phy Mode Fail [%d]\n", ePhyType);
+ return;
+ }
+ // set channel and clear NAV
+ if (CARDbSetChannel(pMgmt->pAdapter, pCurr->uChannel) == FALSE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Channel [%d]\n", pCurr->uChannel);
+ return;
+ }
+
+/*
+ for (ii=0;ii<BB_VGA_LEVEL;ii++) {
+ if (pCurr->ldBmMAX< pDevice->ldBmThreshold[ii]) {
+ pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
+ break;
+ }
+ }
+
+ if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RSSI[%d] NewGain[%d] OldGain[%d] \n",
+ (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent);
+ printk("RSSI[%d] NewGain[%d] OldGain[%d] \n",
+ (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent);
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew);
+ }
+ printk("ldBmMAX[%d] NewGain[%d] OldGain[%d] \n",
+ (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent);
+*/
+ pMgmt->uCurrChannel = pCurr->uChannel;
+ pMgmt->eCurrentPHYMode = ePhyType;
+ pMgmt->byERPContext = pCurr->sERP.byERP;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:Set to channel = [%d]\n", (INT)pCurr->uChannel);
+
+
+ *pStatus = CMD_STATUS_SUCCESS;
+
+
+ return;
+};
+
+//mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption
+// ,need reset eAuthenMode and eEncryptionStatus
+ static VOID Encyption_Rebuild(
+ IN PSDevice pDevice,
+ IN PKnownBSS pCurr
+ )
+ {
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ // UINT ii , uSameBssidNum=0;
+
+ // for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ // if (pMgmt->sBSSList[ii].bActive &&
+ // IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
+ // uSameBssidNum++;
+ // }
+ // }
+ // if( uSameBssidNum>=2) { //we only check AP in hidden sssid mode
+ if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || //networkmanager 0.7.0 does not give the pairwise-key selsection,
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { // so we need re-selsect it according to real pairwise-key info.
+ if(pCurr->bWPAValid == TRUE) { //WPA-PSK
+ pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
+ if(pCurr->abyPKType[0] == WPA_TKIP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP
+ printk("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
+ }
+ else if(pCurr->abyPKType[0] == WPA_AESCCMP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES
+ printk("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n");
+ }
+ }
+ else if(pCurr->bWPA2Valid == TRUE) { //WPA2-PSK
+ pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
+ if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_TKIP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP
+ printk("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
+ }
+ else if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_CCMP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES
+ printk("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n");
+ }
+ }
+ }
+ // }
+ return;
+ }
+
+
+/*+
+ *
+ * Routine Description:
+ * Format TIM field
+ *
+ *
+ * Return Value:
+ * VOID
+ *
+-*/
+
+static
+VOID
+s_vMgrFormatTIM(
+ IN PSMgmtObject pMgmt,
+ IN PWLAN_IE_TIM pTIM
+ )
+{
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ BYTE byMap;
+ UINT ii, jj;
+ BOOL bStartFound = FALSE;
+ BOOL bMulticast = FALSE;
+ WORD wStartIndex = 0;
+ WORD wEndIndex = 0;
+
+
+ // Find size of partial virtual bitmap
+ for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
+ byMap = pMgmt->abyPSTxMap[ii];
+ if (!ii) {
+ // Mask out the broadcast bit which is indicated separately.
+ bMulticast = (byMap & byMask[0]) != 0;
+ if(bMulticast) {
+ pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE;
+ }
+ byMap = 0;
+ }
+ if (byMap) {
+ if (!bStartFound) {
+ bStartFound = TRUE;
+ wStartIndex = ii;
+ }
+ wEndIndex = ii;
+ }
+ };
+
+
+ // Round start index down to nearest even number
+ wStartIndex &= ~BIT0;
+
+ // Round end index up to nearest even number
+ wEndIndex = ((wEndIndex + 1) & ~BIT0);
+
+ // Size of element payload
+
+ pTIM->len = 3 + (wEndIndex - wStartIndex) + 1;
+
+ // Fill in the Fixed parts of the TIM
+ pTIM->byDTIMCount = pMgmt->byDTIMCount;
+ pTIM->byDTIMPeriod = pMgmt->byDTIMPeriod;
+ pTIM->byBitMapCtl = (bMulticast ? TIM_MULTICAST_MASK : 0) |
+ (((wStartIndex >> 1) << 1) & TIM_BITMAPOFFSET_MASK);
+
+ // Append variable part of TIM
+
+ for (ii = wStartIndex, jj =0 ; ii <= wEndIndex; ii++, jj++) {
+ pTIM->byVirtBitMap[jj] = pMgmt->abyPSTxMap[ii];
+ }
+
+ // Aid = 0 don't used.
+ pTIM->byVirtBitMap[0] &= ~BIT0;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an Beacon frame( Ad-hoc mode)
+ *
+ *
+ * Return Value:
+ * PTR to frame; or NULL on allocation failue
+ *
+-*/
+
+static
+PSTxMgmtPacket
+s_MgrMakeBeacon(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wCurrBeaconPeriod,
+ IN UINT uCurrChannel,
+ IN WORD wCurrATIMWinodw,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PBYTE pCurrBSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_BEACON sFrame;
+ BYTE abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ PBYTE pbyBuffer;
+ UINT uLength = 0;
+ PWLAN_IE_IBSS_DFS pIBSSDFS = NULL;
+ UINT ii;
+
+ // prepare beacon frame
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_BEACON_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ // Setup the sFrame structure.
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_BEACON_FR_MAXLEN;
+ vMgrEncodeBeacon(&sFrame);
+ // Setup the header
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON)
+ ));
+
+ if (pDevice->bEnablePSMode) {
+ sFrame.pHdr->sA3.wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_PWRMGT(1));
+ }
+
+ memcpy( sFrame.pHdr->sA3.abyAddr1, abyBroadcastAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN);
+ *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod);
+ *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
+ // Copy SSID
+ sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSSID,
+ pCurrSSID,
+ ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN
+ );
+ // Copy the rate set
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates,
+ pCurrSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ // DS parameter
+ if (pDevice->eCurrentPHYType != PHY_TYPE_11A) {
+ sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len);
+ sFrame.len += (1) + WLAN_IEHDR_LEN;
+ sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS;
+ sFrame.pDSParms->len = 1;
+ sFrame.pDSParms->byCurrChannel = (BYTE)uCurrChannel;
+ }
+ // TIM field
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ sFrame.pTIM = (PWLAN_IE_TIM)(sFrame.pBuf + sFrame.len);
+ sFrame.pTIM->byElementID = WLAN_EID_TIM;
+ s_vMgrFormatTIM(pMgmt, sFrame.pTIM);
+ sFrame.len += (WLAN_IEHDR_LEN + sFrame.pTIM->len);
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+
+ // IBSS parameter
+ sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len);
+ sFrame.len += (2) + WLAN_IEHDR_LEN;
+ sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS;
+ sFrame.pIBSSParms->len = 2;
+ sFrame.pIBSSParms->wATIMWindow = wCurrATIMWinodw;
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+ /* RSN parameter */
+ sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
+ sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
+ sFrame.pRSNWPA->len = 12;
+ sFrame.pRSNWPA->abyOUI[0] = 0x00;
+ sFrame.pRSNWPA->abyOUI[1] = 0x50;
+ sFrame.pRSNWPA->abyOUI[2] = 0xf2;
+ sFrame.pRSNWPA->abyOUI[3] = 0x01;
+ sFrame.pRSNWPA->wVersion = 1;
+ sFrame.pRSNWPA->abyMulticast[0] = 0x00;
+ sFrame.pRSNWPA->abyMulticast[1] = 0x50;
+ sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)
+ sFrame.pRSNWPA->abyMulticast[3] = 0x04;//AES
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled)
+ sFrame.pRSNWPA->abyMulticast[3] = 0x02;//TKIP
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled)
+ sFrame.pRSNWPA->abyMulticast[3] = 0x01;//WEP40
+ else
+ sFrame.pRSNWPA->abyMulticast[3] = 0x00;//NONE
+
+ // Pairwise Key Cipher Suite
+ sFrame.pRSNWPA->wPKCount = 0;
+ // Auth Key Management Suite
+ *((PWORD)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0;
+ sFrame.pRSNWPA->len +=2;
+
+ // RSN Capabilites
+ *((PWORD)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0;
+ sFrame.pRSNWPA->len +=2;
+ sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+ }
+ }
+
+ if ((pMgmt->b11hEnable == TRUE) &&
+ (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) {
+ // Country IE
+ pbyBuffer = (PBYTE)(sFrame.pBuf + sFrame.len);
+ CARDvSetCountryIE(pMgmt->pAdapter, pbyBuffer);
+ CARDvSetCountryInfo(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer);
+ uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN;
+ pbyBuffer += (((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN);
+ // Power Constrain IE
+ ((PWLAN_IE_PW_CONST) pbyBuffer)->byElementID = WLAN_EID_PWR_CONSTRAINT;
+ ((PWLAN_IE_PW_CONST) pbyBuffer)->len = 1;
+ ((PWLAN_IE_PW_CONST) pbyBuffer)->byPower = 0;
+ pbyBuffer += (1) + WLAN_IEHDR_LEN;
+ uLength += (1) + WLAN_IEHDR_LEN;
+ if (pMgmt->bSwitchChannel == TRUE) {
+ // Channel Switch IE
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byElementID = WLAN_EID_CH_SWITCH;
+ ((PWLAN_IE_CH_SW) pbyBuffer)->len = 3;
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byMode = 1;
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byChannel = CARDbyGetChannelNumber(pMgmt->pAdapter, pMgmt->byNewChannel);
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byCount = 0;
+ pbyBuffer += (3) + WLAN_IEHDR_LEN;
+ uLength += (3) + WLAN_IEHDR_LEN;
+ }
+ // TPC report
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->byElementID = WLAN_EID_TPC_REP;
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->len = 2;
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->byLinkMargin = 0;
+ pbyBuffer += (2) + WLAN_IEHDR_LEN;
+ uLength += (2) + WLAN_IEHDR_LEN;
+ // IBSS DFS
+ if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
+ pIBSSDFS = (PWLAN_IE_IBSS_DFS) pbyBuffer;
+ pIBSSDFS->byElementID = WLAN_EID_IBSS_DFS;
+ pIBSSDFS->len = 7;
+ MEMvCopy( pIBSSDFS->abyDFSOwner,
+ pMgmt->abyIBSSDFSOwner,
+ 6);
+ pIBSSDFS->byDFSRecovery = pMgmt->byIBSSDFSRecovery;
+ pbyBuffer += (7) + WLAN_IEHDR_LEN;
+ uLength += (7) + WLAN_IEHDR_LEN;
+ for(ii=CB_MAX_CHANNEL_24G+1; ii<=CB_MAX_CHANNEL; ii++ ) {
+ if (CARDbGetChannelMapInfo(pMgmt->pAdapter, ii, pbyBuffer, pbyBuffer+1) == TRUE) {
+ pbyBuffer += 2;
+ uLength += 2;
+ pIBSSDFS->len += 2;
+ }
+ }
+ }
+ sFrame.len += uLength;
+ }
+
+ if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {
+ sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len);
+ sFrame.len += 1 + WLAN_IEHDR_LEN;
+ sFrame.pERP->byElementID = WLAN_EID_ERP;
+ sFrame.pERP->len = 1;
+ sFrame.pERP->byContext = 0;
+ if (pDevice->bProtectMode == TRUE)
+ sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION;
+ if (pDevice->bNonERPPresent == TRUE)
+ sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT;
+ if (pDevice->bBarkerPreambleMd == TRUE)
+ sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE;
+ }
+ if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
+ MEMvCopy(sFrame.pExtSuppRates,
+ pCurrExtSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ }
+ // hostapd wpa/wpa2 IE
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == TRUE)) {
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+ if (pMgmt->wWPAIELen != 0) {
+ sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
+ memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen);
+ sFrame.len += pMgmt->wWPAIELen;
+ }
+ }
+ }
+
+ /* Adjust the length fields */
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ return pTxPacket;
+}
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an Prob-response frame
+ *
+ *
+ * Return Value:
+ * PTR to frame; or NULL on allocation failue
+ *
+-*/
+
+
+
+
+PSTxMgmtPacket
+s_MgrMakeProbeResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wCurrBeaconPeriod,
+ IN UINT uCurrChannel,
+ IN WORD wCurrATIMWinodw,
+ IN PBYTE pDstAddr,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PBYTE pCurrBSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates,
+ IN BYTE byPHYType
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_PROBERESP sFrame;
+ PBYTE pbyBuffer;
+ UINT uLength = 0;
+ PWLAN_IE_IBSS_DFS pIBSSDFS = NULL;
+ UINT ii;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBERESP_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ // Setup the sFrame structure.
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_PROBERESP_FR_MAXLEN;
+ vMgrEncodeProbeResponse(&sFrame);
+ // Setup the header
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN);
+ *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod);
+ *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
+
+ if (byPHYType == BB_TYPE_11B) {
+ *sFrame.pwCapInfo &= cpu_to_le16((WORD)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)));
+ }
+
+ // Copy SSID
+ sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSSID,
+ pCurrSSID,
+ ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN
+ );
+ // Copy the rate set
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates,
+ pCurrSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
+ );
+
+ // DS parameter
+ if (pDevice->eCurrentPHYType != PHY_TYPE_11A) {
+ sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len);
+ sFrame.len += (1) + WLAN_IEHDR_LEN;
+ sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS;
+ sFrame.pDSParms->len = 1;
+ sFrame.pDSParms->byCurrChannel = (BYTE)uCurrChannel;
+ }
+
+ if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
+ // IBSS parameter
+ sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len);
+ sFrame.len += (2) + WLAN_IEHDR_LEN;
+ sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS;
+ sFrame.pIBSSParms->len = 2;
+ sFrame.pIBSSParms->wATIMWindow = 0;
+ }
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
+ sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len);
+ sFrame.len += 1 + WLAN_IEHDR_LEN;
+ sFrame.pERP->byElementID = WLAN_EID_ERP;
+ sFrame.pERP->len = 1;
+ sFrame.pERP->byContext = 0;
+ if (pDevice->bProtectMode == TRUE)
+ sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION;
+ if (pDevice->bNonERPPresent == TRUE)
+ sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT;
+ if (pDevice->bBarkerPreambleMd == TRUE)
+ sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE;
+ }
+
+ if ((pMgmt->b11hEnable == TRUE) &&
+ (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) {
+ // Country IE
+ pbyBuffer = (PBYTE)(sFrame.pBuf + sFrame.len);
+ CARDvSetCountryIE(pMgmt->pAdapter, pbyBuffer);
+ CARDvSetCountryInfo(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer);
+ uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN;
+ pbyBuffer += (((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN);
+ // Power Constrain IE
+ ((PWLAN_IE_PW_CONST) pbyBuffer)->byElementID = WLAN_EID_PWR_CONSTRAINT;
+ ((PWLAN_IE_PW_CONST) pbyBuffer)->len = 1;
+ ((PWLAN_IE_PW_CONST) pbyBuffer)->byPower = 0;
+ pbyBuffer += (1) + WLAN_IEHDR_LEN;
+ uLength += (1) + WLAN_IEHDR_LEN;
+ if (pMgmt->bSwitchChannel == TRUE) {
+ // Channel Switch IE
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byElementID = WLAN_EID_CH_SWITCH;
+ ((PWLAN_IE_CH_SW) pbyBuffer)->len = 3;
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byMode = 1;
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byChannel = CARDbyGetChannelNumber(pMgmt->pAdapter, pMgmt->byNewChannel);
+ ((PWLAN_IE_CH_SW) pbyBuffer)->byCount = 0;
+ pbyBuffer += (3) + WLAN_IEHDR_LEN;
+ uLength += (3) + WLAN_IEHDR_LEN;
+ }
+ // TPC report
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->byElementID = WLAN_EID_TPC_REP;
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->len = 2;
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
+ ((PWLAN_IE_TPC_REP) pbyBuffer)->byLinkMargin = 0;
+ pbyBuffer += (2) + WLAN_IEHDR_LEN;
+ uLength += (2) + WLAN_IEHDR_LEN;
+ // IBSS DFS
+ if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) {
+ pIBSSDFS = (PWLAN_IE_IBSS_DFS) pbyBuffer;
+ pIBSSDFS->byElementID = WLAN_EID_IBSS_DFS;
+ pIBSSDFS->len = 7;
+ MEMvCopy( pIBSSDFS->abyDFSOwner,
+ pMgmt->abyIBSSDFSOwner,
+ 6);
+ pIBSSDFS->byDFSRecovery = pMgmt->byIBSSDFSRecovery;
+ pbyBuffer += (7) + WLAN_IEHDR_LEN;
+ uLength += (7) + WLAN_IEHDR_LEN;
+ for(ii=CB_MAX_CHANNEL_24G+1; ii<=CB_MAX_CHANNEL; ii++ ) {
+ if (CARDbGetChannelMapInfo(pMgmt->pAdapter, ii, pbyBuffer, pbyBuffer+1) == TRUE) {
+ pbyBuffer += 2;
+ uLength += 2;
+ pIBSSDFS->len += 2;
+ }
+ }
+ }
+ sFrame.len += uLength;
+ }
+
+
+ if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
+ MEMvCopy(sFrame.pExtSuppRates,
+ pCurrExtSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ }
+
+ // hostapd wpa/wpa2 IE
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == TRUE)) {
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
+ if (pMgmt->wWPAIELen != 0) {
+ sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
+ memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen);
+ sFrame.len += pMgmt->wWPAIELen;
+ }
+ }
+ }
+
+ // Adjust the length fields
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ return pTxPacket;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an association request frame
+ *
+ *
+ * Return Value:
+ * A ptr to frame or NULL on allocation failue
+ *
+-*/
+
+
+PSTxMgmtPacket
+s_MgrMakeAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pDAddr,
+ IN WORD wCurrCapInfo,
+ IN WORD wListenInterval,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_ASSOCREQ sFrame;
+ PBYTE pbyIEs;
+ PBYTE pbyRSN;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ // Setup the sFrame structure.
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN;
+ // format fixed field frame structure
+ vMgrEncodeAssocRequest(&sFrame);
+ // Setup the header
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ // Set the capibility and listen interval
+ *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo);
+ *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval);
+
+ // sFrame.len point to end of fixed field
+ sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
+
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN;
+ pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
+ pbyIEs = pMgmt->sAssocInfo.abyIEs;
+ MEMvCopy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
+ pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN;
+
+ // Copy the rate set
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ if ((pDevice->eCurrentPHYType == PHY_TYPE_11B) && (pCurrRates->len > 4))
+ sFrame.len += 4 + WLAN_IEHDR_LEN;
+ else
+ sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
+
+ // Copy the extension rate set
+ if ((pDevice->eCurrentPHYType == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
+ }
+
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN;
+ MEMvCopy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
+ pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN;
+
+ // for 802.11h
+ if (pMgmt->b11hEnable == TRUE) {
+ if (sFrame.pCurrPowerCap == NULL) {
+ sFrame.pCurrPowerCap = (PWLAN_IE_PW_CAP)(sFrame.pBuf + sFrame.len);
+ sFrame.len += (2 + WLAN_IEHDR_LEN);
+ sFrame.pCurrPowerCap->byElementID = WLAN_EID_PWR_CAPABILITY;
+ sFrame.pCurrPowerCap->len = 2;
+ CARDvGetPowerCapability(pMgmt->pAdapter,
+ &(sFrame.pCurrPowerCap->byMinPower),
+ &(sFrame.pCurrPowerCap->byMaxPower)
+ );
+ }
+ if (sFrame.pCurrSuppCh == NULL) {
+ sFrame.pCurrSuppCh = (PWLAN_IE_SUPP_CH)(sFrame.pBuf + sFrame.len);
+ sFrame.len += CARDbySetSupportChannels(pMgmt->pAdapter,(PBYTE)sFrame.pCurrSuppCh);
+ }
+ }
+
+ if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) &&
+ (pMgmt->pCurrBSS != NULL)) {
+ /* WPA IE */
+ sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
+ sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
+ sFrame.pRSNWPA->len = 16;
+ sFrame.pRSNWPA->abyOUI[0] = 0x00;
+ sFrame.pRSNWPA->abyOUI[1] = 0x50;
+ sFrame.pRSNWPA->abyOUI[2] = 0xf2;
+ sFrame.pRSNWPA->abyOUI[3] = 0x01;
+ sFrame.pRSNWPA->wVersion = 1;
+ //Group Key Cipher Suite
+ sFrame.pRSNWPA->abyMulticast[0] = 0x00;
+ sFrame.pRSNWPA->abyMulticast[1] = 0x50;
+ sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
+ if (pMgmt->byCSSGK == KEY_CTL_WEP) {
+ sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType;
+ } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
+ sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP;
+ } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
+ sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP;
+ } else {
+ sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE;
+ }
+ // Pairwise Key Cipher Suite
+ sFrame.pRSNWPA->wPKCount = 1;
+ sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00;
+ sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50;
+ sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2;
+ if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
+ sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
+ sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP;
+ } else {
+ sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE;
+ }
+ // Auth Key Management Suite
+ pbyRSN = (PBYTE)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len);
+ *pbyRSN++=0x01;
+ *pbyRSN++=0x00;
+ *pbyRSN++=0x00;
+ *pbyRSN++=0x50;
+ *pbyRSN++=0xf2;
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) {
+ *pbyRSN++=WPA_AUTH_PSK;
+ }
+ else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) {
+ *pbyRSN++=WPA_AUTH_IEEE802_1X;
+ }
+ else {
+ *pbyRSN++=WPA_NONE;
+ }
+ sFrame.pRSNWPA->len +=6;
+
+ // RSN Capabilites
+ *pbyRSN++=0x00;
+ *pbyRSN++=0x00;
+ sFrame.pRSNWPA->len +=2;
+ sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+ // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+ MEMvCopy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN);
+ pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+
+ } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
+ (pMgmt->pCurrBSS != NULL)) {
+ UINT ii;
+ PWORD pwPMKID;
+
+ // WPA IE
+ sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
+ sFrame.pRSN->byElementID = WLAN_EID_RSN;
+ sFrame.pRSN->len = 6; //Version(2)+GK(4)
+ sFrame.pRSN->wVersion = 1;
+ //Group Key Cipher Suite
+ sFrame.pRSN->abyRSN[0] = 0x00;
+ sFrame.pRSN->abyRSN[1] = 0x0F;
+ sFrame.pRSN->abyRSN[2] = 0xAC;
+ if (pMgmt->byCSSGK == KEY_CTL_WEP) {
+ sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
+ } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
+ sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP;
+ } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
+ sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP;
+ } else {
+ sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
+ }
+
+ // Pairwise Key Cipher Suite
+ sFrame.pRSN->abyRSN[4] = 1;
+ sFrame.pRSN->abyRSN[5] = 0;
+ sFrame.pRSN->abyRSN[6] = 0x00;
+ sFrame.pRSN->abyRSN[7] = 0x0F;
+ sFrame.pRSN->abyRSN[8] = 0xAC;
+ if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_NONE) {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
+ } else {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
+ }
+ sFrame.pRSN->len += 6;
+
+ // Auth Key Management Suite
+ sFrame.pRSN->abyRSN[10] = 1;
+ sFrame.pRSN->abyRSN[11] = 0;
+ sFrame.pRSN->abyRSN[12] = 0x00;
+ sFrame.pRSN->abyRSN[13] = 0x0F;
+ sFrame.pRSN->abyRSN[14] = 0xAC;
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) {
+ sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK;
+ } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
+ sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
+ } else {
+ sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
+ }
+ sFrame.pRSN->len +=6;
+
+ // RSN Capabilites
+ if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) {
+ MEMvCopy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
+ } else {
+ sFrame.pRSN->abyRSN[16] = 0;
+ sFrame.pRSN->abyRSN[17] = 0;
+ }
+ sFrame.pRSN->len +=2;
+
+ if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
+ // RSN PMKID
+ pbyRSN = &sFrame.pRSN->abyRSN[18];
+ pwPMKID = (PWORD)pbyRSN; // Point to PMKID count
+ *pwPMKID = 0; // Initialize PMKID count
+ pbyRSN += 2; // Point to PMKID list
+ for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) {
+ if (MEMEqualMemory(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) {
+ (*pwPMKID) ++;
+ MEMvCopy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16);
+ pbyRSN += 16;
+ }
+ }
+ if (*pwPMKID != 0) {
+ sFrame.pRSN->len += (2 + (*pwPMKID)*16);
+ }
+ }
+
+ sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN;
+ // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN;
+ MEMvCopy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN);
+ pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN;
+ }
+
+
+ // Adjust the length fields
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+ return pTxPacket;
+}
+
+
+
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an re-association request frame
+ *
+ *
+ * Return Value:
+ * A ptr to frame or NULL on allocation failue
+ *
+-*/
+
+
+PSTxMgmtPacket
+s_MgrMakeReAssocRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE pDAddr,
+ IN WORD wCurrCapInfo,
+ IN WORD wListenInterval,
+ IN PWLAN_IE_SSID pCurrSSID,
+ IN PWLAN_IE_SUPP_RATES pCurrRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_REASSOCREQ sFrame;
+ PBYTE pbyIEs;
+ PBYTE pbyRSN;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset( pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_REASSOCREQ_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ /* Setup the sFrame structure. */
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN;
+
+ // format fixed field frame structure
+ vMgrEncodeReassocRequest(&sFrame);
+
+ /* Setup the header */
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ /* Set the capibility and listen interval */
+ *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo);
+ *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval);
+
+ memcpy(sFrame.pAddrCurrAP, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+ /* Copy the SSID */
+ /* sFrame.len point to end of fixed field */
+ sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
+
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN;
+ pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
+ pbyIEs = pMgmt->sAssocInfo.abyIEs;
+ MEMvCopy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN);
+ pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN;
+
+ /* Copy the rate set */
+ /* sFrame.len point to end of SSID */
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
+
+ // Copy the extension rate set
+ if ((pMgmt->eCurrentPHYMode == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
+ }
+
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN;
+ MEMvCopy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
+ pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN;
+
+ if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) &&
+ (pMgmt->pCurrBSS != NULL)) {
+ /* WPA IE */
+ sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len);
+ sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA;
+ sFrame.pRSNWPA->len = 16;
+ sFrame.pRSNWPA->abyOUI[0] = 0x00;
+ sFrame.pRSNWPA->abyOUI[1] = 0x50;
+ sFrame.pRSNWPA->abyOUI[2] = 0xf2;
+ sFrame.pRSNWPA->abyOUI[3] = 0x01;
+ sFrame.pRSNWPA->wVersion = 1;
+ //Group Key Cipher Suite
+ sFrame.pRSNWPA->abyMulticast[0] = 0x00;
+ sFrame.pRSNWPA->abyMulticast[1] = 0x50;
+ sFrame.pRSNWPA->abyMulticast[2] = 0xf2;
+ if (pMgmt->byCSSGK == KEY_CTL_WEP) {
+ sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType;
+ } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
+ sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP;
+ } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
+ sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP;
+ } else {
+ sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE;
+ }
+ // Pairwise Key Cipher Suite
+ sFrame.pRSNWPA->wPKCount = 1;
+ sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00;
+ sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50;
+ sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2;
+ if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
+ sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
+ sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP;
+ } else {
+ sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE;
+ }
+ // Auth Key Management Suite
+ pbyRSN = (PBYTE)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len);
+ *pbyRSN++=0x01;
+ *pbyRSN++=0x00;
+ *pbyRSN++=0x00;
+ *pbyRSN++=0x50;
+ *pbyRSN++=0xf2;
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) {
+ *pbyRSN++=WPA_AUTH_PSK;
+ } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) {
+ *pbyRSN++=WPA_AUTH_IEEE802_1X;
+ } else {
+ *pbyRSN++=WPA_NONE;
+ }
+ sFrame.pRSNWPA->len +=6;
+
+ // RSN Capabilites
+ *pbyRSN++=0x00;
+ *pbyRSN++=0x00;
+ sFrame.pRSNWPA->len +=2;
+ sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+ // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+ MEMvCopy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN);
+ pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN;
+
+ } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
+ (pMgmt->pCurrBSS != NULL)) {
+ UINT ii;
+ PWORD pwPMKID;
+
+ /* WPA IE */
+ sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len);
+ sFrame.pRSN->byElementID = WLAN_EID_RSN;
+ sFrame.pRSN->len = 6; //Version(2)+GK(4)
+ sFrame.pRSN->wVersion = 1;
+ //Group Key Cipher Suite
+ sFrame.pRSN->abyRSN[0] = 0x00;
+ sFrame.pRSN->abyRSN[1] = 0x0F;
+ sFrame.pRSN->abyRSN[2] = 0xAC;
+ if (pMgmt->byCSSGK == KEY_CTL_WEP) {
+ sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
+ } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
+ sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP;
+ } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
+ sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP;
+ } else {
+ sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
+ }
+
+ // Pairwise Key Cipher Suite
+ sFrame.pRSN->abyRSN[4] = 1;
+ sFrame.pRSN->abyRSN[5] = 0;
+ sFrame.pRSN->abyRSN[6] = 0x00;
+ sFrame.pRSN->abyRSN[7] = 0x0F;
+ sFrame.pRSN->abyRSN[8] = 0xAC;
+ if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_NONE) {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
+ } else {
+ sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
+ }
+ sFrame.pRSN->len += 6;
+
+ // Auth Key Management Suite
+ sFrame.pRSN->abyRSN[10] = 1;
+ sFrame.pRSN->abyRSN[11] = 0;
+ sFrame.pRSN->abyRSN[12] = 0x00;
+ sFrame.pRSN->abyRSN[13] = 0x0F;
+ sFrame.pRSN->abyRSN[14] = 0xAC;
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) {
+ sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK;
+ } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
+ sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
+ } else {
+ sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
+ }
+ sFrame.pRSN->len +=6;
+
+ // RSN Capabilites
+ if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) {
+ MEMvCopy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
+ } else {
+ sFrame.pRSN->abyRSN[16] = 0;
+ sFrame.pRSN->abyRSN[17] = 0;
+ }
+ sFrame.pRSN->len +=2;
+
+ if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
+ // RSN PMKID
+ pbyRSN = &sFrame.pRSN->abyRSN[18];
+ pwPMKID = (PWORD)pbyRSN; // Point to PMKID count
+ *pwPMKID = 0; // Initialize PMKID count
+ pbyRSN += 2; // Point to PMKID list
+ for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) {
+ if (MEMEqualMemory(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) {
+ (*pwPMKID) ++;
+ MEMvCopy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16);
+ pbyRSN += 16;
+ }
+ }
+ if (*pwPMKID != 0) {
+ sFrame.pRSN->len += (2 + (*pwPMKID)*16);
+ }
+ }
+
+ sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN;
+ // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION
+ pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN;
+ MEMvCopy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN);
+ pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN;
+ }
+
+
+ /* Adjust the length fields */
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ return pTxPacket;
+}
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an assoc-response frame
+ *
+ *
+ * Return Value:
+ * PTR to frame; or NULL on allocation failue
+ *
+-*/
+
+
+PSTxMgmtPacket
+s_MgrMakeAssocResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wAssocStatus,
+ IN WORD wAssocAID,
+ IN PBYTE pDstAddr,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_ASSOCRESP sFrame;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ // Setup the sFrame structure
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
+ vMgrEncodeAssocResponse(&sFrame);
+ // Setup the header
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
+ *sFrame.pwStatus = cpu_to_le16(wAssocStatus);
+ *sFrame.pwAid = cpu_to_le16((WORD)(wAssocAID | BIT14 | BIT15));
+
+ // Copy the rate set
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates,
+ pCurrSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
+ );
+
+ if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
+ MEMvCopy(sFrame.pExtSuppRates,
+ pCurrExtSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ }
+
+ // Adjust the length fields
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ return pTxPacket;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Constructs an reassoc-response frame
+ *
+ *
+ * Return Value:
+ * PTR to frame; or NULL on allocation failue
+ *
+-*/
+
+
+PSTxMgmtPacket
+s_MgrMakeReAssocResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN WORD wCurrCapInfo,
+ IN WORD wAssocStatus,
+ IN WORD wAssocAID,
+ IN PBYTE pDstAddr,
+ IN PWLAN_IE_SUPP_RATES pCurrSuppRates,
+ IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
+ )
+{
+ PSTxMgmtPacket pTxPacket = NULL;
+ WLAN_FR_REASSOCRESP sFrame;
+
+
+ pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
+ memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
+ pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+ // Setup the sFrame structure
+ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
+ sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
+ vMgrEncodeReassocResponse(&sFrame);
+ // Setup the header
+ sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
+ (
+ WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
+ WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP)
+ ));
+ memcpy( sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
+ memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
+
+ *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo);
+ *sFrame.pwStatus = cpu_to_le16(wAssocStatus);
+ *sFrame.pwAid = cpu_to_le16((WORD)(wAssocAID | BIT14 | BIT15));
+
+ // Copy the rate set
+ sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN;
+ memcpy(sFrame.pSuppRates,
+ pCurrSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN
+ );
+
+ if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) {
+ sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
+ sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN;
+ MEMvCopy(sFrame.pExtSuppRates,
+ pCurrExtSuppRates,
+ ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN
+ );
+ }
+
+ // Adjust the length fields
+ pTxPacket->cbMPDULen = sFrame.len;
+ pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
+
+ return pTxPacket;
+}
+
+
+/*+
+ *
+ * Routine Description:
+ * Handles probe response management frames.
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+
+static
+VOID
+s_vMgrRxProbeResponse(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ )
+{
+ PKnownBSS pBSSList = NULL;
+ WLAN_FR_PROBERESP sFrame;
+ BYTE byCurrChannel = pRxPacket->byRxChannel;
+ ERPObject sERP;
+ BYTE byIEChannel = 0;
+ BOOL bChannelHit = TRUE;
+
+
+ memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP));
+ // decode the frame
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ vMgrDecodeProbeResponse(&sFrame);
+
+ if ((sFrame.pqwTimestamp == 0) ||
+ (sFrame.pwBeaconInterval == 0) ||
+ (sFrame.pwCapInfo == 0) ||
+ (sFrame.pSSID == 0) ||
+ (sFrame.pSuppRates == 0)) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe resp:Fail addr:[%p] \n", pRxPacket->p80211Header);
+ DBG_PORT80(0xCC);
+ return;
+ };
+
+ if(sFrame.pSSID->len == 0)
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx Probe resp: SSID len = 0 \n");
+
+ if (sFrame.pDSParms != 0) {
+ if (byCurrChannel > CB_MAX_CHANNEL_24G) {
+ // channel remapping to
+ byIEChannel = CARDbyGetChannelMapping(pMgmt->pAdapter, sFrame.pDSParms->byCurrChannel, PHY_TYPE_11A);
+ } else {
+ byIEChannel = sFrame.pDSParms->byCurrChannel;
+ }
+ if (byCurrChannel != byIEChannel) {
+ // adjust channel info. bcs we rcv adjcent channel pakckets
+ bChannelHit = FALSE;
+ byCurrChannel = byIEChannel;
+ }
+ } else {
+ // no DS channel info
+ bChannelHit = TRUE;
+ }
+
+//2008-0730-01<Add>by MikeLiu
+if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
+ return;
+
+ if (sFrame.pERP != NULL) {
+ sERP.byERP = sFrame.pERP->byContext;
+ sERP.bERPExist = TRUE;
+ } else {
+ sERP.bERPExist = FALSE;
+ sERP.byERP = 0;
+ }
+
+
+ // update or insert the bss
+ pBSSList = BSSpAddrIsInBSSList((HANDLE)pDevice, sFrame.pHdr->sA3.abyAddr3, sFrame.pSSID);
+ if (pBSSList) {
+ BSSbUpdateToBSSList((HANDLE)pDevice,
+ *sFrame.pqwTimestamp,
+ *sFrame.pwBeaconInterval,
+ *sFrame.pwCapInfo,
+ byCurrChannel,
+ bChannelHit,
+ sFrame.pSSID,
+ sFrame.pSuppRates,
+ sFrame.pExtSuppRates,
+ &sERP,
+ sFrame.pRSN,
+ sFrame.pRSNWPA,
+ sFrame.pIE_Country,
+ sFrame.pIE_Quiet,
+ pBSSList,
+ sFrame.len - WLAN_HDR_ADDR3_LEN,
+ sFrame.pHdr->sA4.abyAddr4, // payload of probresponse
+ (HANDLE)pRxPacket
+ );
+ }
+ else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Probe resp/insert: RxChannel = : %d\n", byCurrChannel);
+ BSSbInsertToBSSList((HANDLE)pDevice,
+ sFrame.pHdr->sA3.abyAddr3,
+ *sFrame.pqwTimestamp,
+ *sFrame.pwBeaconInterval,
+ *sFrame.pwCapInfo,
+ byCurrChannel,
+ sFrame.pSSID,
+ sFrame.pSuppRates,
+ sFrame.pExtSuppRates,
+ &sERP,
+ sFrame.pRSN,
+ sFrame.pRSNWPA,
+ sFrame.pIE_Country,
+ sFrame.pIE_Quiet,
+ sFrame.len - WLAN_HDR_ADDR3_LEN,
+ sFrame.pHdr->sA4.abyAddr4, // payload of beacon
+ (HANDLE)pRxPacket
+ );
+ }
+ return;
+
+}
+
+/*+
+ *
+ * Routine Description:(AP)or(Ad-hoc STA)
+ * Handles probe request management frames.
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+
+
+static
+VOID
+s_vMgrRxProbeRequest(
+ IN PSDevice pDevice,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ )
+{
+ WLAN_FR_PROBEREQ sFrame;
+ CMD_STATUS Status;
+ PSTxMgmtPacket pTxPacket;
+ BYTE byPHYType = BB_TYPE_11B;
+
+ // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
+ // STA have to response this request.
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) ||
+ ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && pDevice->bBeaconSent)) {
+
+ memset(&sFrame, 0, sizeof(WLAN_FR_PROBEREQ));
+ // decode the frame
+ sFrame.len = pRxPacket->cbMPDULen;
+ sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;
+ vMgrDecodeProbeRequest(&sFrame);
+/*
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%02x-%02x-%02x=%02x-%02x-%02x \n",
+ sFrame.pHdr->sA3.abyAddr2[0],
+ sFrame.pHdr->sA3.abyAddr2[1],
+ sFrame.pHdr->sA3.abyAddr2[2],
+ sFrame.pHdr->sA3.abyAddr2[3],
+ sFrame.pHdr->sA3.abyAddr2[4],
+ sFrame.pHdr->sA3.abyAddr2[5]
+ );
+*/
+ if (sFrame.pSSID->len != 0) {
+ if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)
+ return;
+ if (memcmp(sFrame.pSSID->abySSID,
+ ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,
+ ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) != 0) {
+ return;
+ }
+ }
+
+ if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL)) {
+ byPHYType = BB_TYPE_11G;
+ }
+
+ // Probe response reply..
+ pTxPacket = s_MgrMakeProbeResponse
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->wCurrCapInfo,
+ pMgmt->wCurrBeaconPeriod,
+ pMgmt->uCurrChannel,
+ 0,
+ sFrame.pHdr->sA3.abyAddr2,
+ (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
+ (PBYTE)pMgmt->abyCurrBSSID,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
+ byPHYType
+ );
+ if (pTxPacket != NULL ){
+ /* send the frame */
+ Status = csMgmt_xmit(pDevice, pTxPacket);
+ if (Status != CMD_STATUS_PENDING) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx failed\n");
+ }
+ else {
+// DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n");
+ }
+ }
+ }
+
+ return;
+}
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ *
+ * Entry point for the reception and handling of 802.11 management
+ * frames. Makes a determination of the frame type and then calls
+ * the appropriate function.
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+
+
+VOID
+vMgrRxManagePacket(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ BOOL bInScan = FALSE;
+ UINT uNodeIndex = 0;
+ NODE_STATE eNodeState = 0;
+ CMD_STATUS Status;
+
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex))
+ eNodeState = pMgmt->sNodeDBTable[uNodeIndex].eNodeState;
+ }
+
+ switch( WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) ){
+
+ case WLAN_FSTYPE_ASSOCREQ:
+ // Frame Clase = 2
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocreq\n");
+ if (eNodeState < NODE_AUTH) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ pRxPacket->p80211Header->sA3.abyAddr2,
+ (6),
+ &Status
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 1\n");
+ }
+ else {
+ s_vMgrRxAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex);
+ }
+ break;
+
+ case WLAN_FSTYPE_ASSOCRESP:
+ // Frame Clase = 2
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp1\n");
+ s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, FALSE);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp2\n");
+ break;
+
+ case WLAN_FSTYPE_REASSOCREQ:
+ // Frame Clase = 2
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocreq\n");
+ // Todo: reassoc
+ if (eNodeState < NODE_AUTH) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ pRxPacket->p80211Header->sA3.abyAddr2,
+ (6),
+ &Status
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 2\n");
+
+ }
+ s_vMgrRxReAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex);
+ break;
+
+ case WLAN_FSTYPE_REASSOCRESP:
+ // Frame Clase = 2
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocresp\n");
+ s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, TRUE);
+ break;
+
+ case WLAN_FSTYPE_PROBEREQ:
+ // Frame Clase = 0
+ //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
+ s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_PROBERESP:
+ // Frame Clase = 0
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx proberesp\n");
+
+ s_vMgrRxProbeResponse(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_BEACON:
+ // Frame Clase = 0
+ // DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
+ if (pMgmt->eScanState != WMAC_NO_SCANNING) {
+ bInScan = TRUE;
+ };
+ s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan);
+ break;
+
+ case WLAN_FSTYPE_ATIM:
+ // Frame Clase = 1
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx atim\n");
+ break;
+
+ case WLAN_FSTYPE_DISASSOC:
+ // Frame Clase = 2
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx disassoc\n");
+ if (eNodeState < NODE_AUTH) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ pRxPacket->p80211Header->sA3.abyAddr2,
+ (6),
+ &Status
+ );
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 3\n");
+ }
+ s_vMgrRxDisassociation(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_AUTHEN:
+ // Frame Clase = 1
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx authen\n");
+ s_vMgrRxAuthentication(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_DEAUTHEN:
+ // Frame Clase = 1
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx deauthen\n");
+ s_vMgrRxDeauthentication(pDevice, pMgmt, pRxPacket);
+ break;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx unknown mgmt\n");
+ }
+
+ return;
+}
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ *
+ *
+ * Prepare beacon to send
+ *
+ * Return Value:
+ * TRUE if success; FALSE if failed.
+ *
+-*/
+BOOL
+bMgrPrepareBeaconToSend(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSTxMgmtPacket pTxPacket;
+
+// pDevice->bBeaconBufReady = FALSE;
+ if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);
+ }
+ else {
+ pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1);
+ }
+ pTxPacket = s_MgrMakeBeacon
+ (
+ pDevice,
+ pMgmt,
+ pMgmt->wCurrCapInfo,
+ pMgmt->wCurrBeaconPeriod,
+ pMgmt->uCurrChannel,
+ pMgmt->wCurrATIMWindow, //0,
+ (PWLAN_IE_SSID)pMgmt->abyCurrSSID,
+ (PBYTE)pMgmt->abyCurrBSSID,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
+ (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates
+ );
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
+ (pMgmt->abyCurrBSSID[0] == 0))
+ return FALSE;
+
+ csBeacon_xmit(pDevice, pTxPacket);
+
+ return TRUE;
+}
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ *
+ * Log a warning message based on the contents of the Status
+ * Code field of an 802.11 management frame. Defines are
+ * derived from 802.11-1997 SPEC.
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+static
+VOID
+s_vMgrLogStatus(
+ IN PSMgmtObject pMgmt,
+ IN WORD wStatus
+ )
+{
+ switch( wStatus ){
+ case WLAN_MGMT_STATUS_UNSPEC_FAILURE:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Unspecified error.\n");
+ break;
+ case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Can't support all requested capabilities.\n");
+ break;
+ case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Reassoc denied, can't confirm original Association.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, undefine in spec\n");
+ break;
+ case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Peer doesn't support authen algorithm.\n");
+ break;
+ case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen frame received out of sequence.\n");
+ break;
+ case WLAN_MGMT_STATUS_CHALLENGE_FAIL:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, challenge failure.\n");
+ break;
+ case WLAN_MGMT_STATUS_AUTH_TIMEOUT:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, timeout waiting for next frame.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, AP too busy.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we haven't enough basic rates.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support short preamble.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support PBCC.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support channel agility.\n");
+ break;
+ default:
+ DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Unknown status code %d.\n", wStatus);
+ break;
+ }
+}
+
+
+/*
+ *
+ * Description:
+ * Add BSSID in PMKID Candidate list.
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * pbyBSSID - BSSID address for adding
+ * wRSNCap - BSS's RSN capability
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+bAdd_PMKID_Candidate (
+ IN HANDLE hDeviceContext,
+ IN PBYTE pbyBSSID,
+ IN PSRSNCapObject psRSNCapObj
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PPMKID_CANDIDATE pCandidateList;
+ UINT ii = 0;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
+
+ if ((pDevice == NULL) || (pbyBSSID == NULL) || (psRSNCapObj == NULL))
+ return FALSE;
+
+ if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST)
+ return FALSE;
+
+
+
+ // Update Old Candidate
+ for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
+ pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
+ if (MEMEqualMemory(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN)) {
+ if ((psRSNCapObj->bRSNCapExist == TRUE) && (psRSNCapObj->wRSNCap & BIT0)) {
+ pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
+ } else {
+ pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
+ }
+ return TRUE;
+ }
+ }
+
+ // New Candidate
+ pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
+ if ((psRSNCapObj->bRSNCapExist == TRUE) && (psRSNCapObj->wRSNCap & BIT0)) {
+ pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
+ } else {
+ pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
+ }
+ MEMvCopy(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN);
+ pDevice->gsPMKIDCandidate.NumCandidates++;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
+ return TRUE;
+}
+
+/*
+ *
+ * Description:
+ * Flush PMKID Candidate list.
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - device structure point
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+vFlush_PMKID_Candidate (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ if (pDevice == NULL)
+ return;
+
+ ZERO_MEMORY(&pDevice->gsPMKIDCandidate, sizeof(SPMKIDCandidateEvent));
+}
+
+static BOOL
+s_bCipherMatch (
+ IN PKnownBSS pBSSNode,
+ IN NDIS_802_11_ENCRYPTION_STATUS EncStatus,
+ OUT PBYTE pbyCCSPK,
+ OUT PBYTE pbyCCSGK
+ )
+{
+ BYTE byMulticastCipher = KEY_CTL_INVALID;
+ BYTE byCipherMask = 0x00;
+ int i;
+
+ if (pBSSNode == NULL)
+ return FALSE;
+
+ // check cap. of BSS
+
+ if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
+ (EncStatus == Ndis802_11Encryption1Enabled)) {
+ // default is WEP only
+ byMulticastCipher = KEY_CTL_WEP;
+ }
+
+ if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
+ (pBSSNode->bWPA2Valid == TRUE) &&
+ ((EncStatus == Ndis802_11Encryption3Enabled)||(EncStatus == Ndis802_11Encryption2Enabled))) {
+
+ //WPA2
+ // check Group Key Cipher
+ if ((pBSSNode->byCSSGK == WLAN_11i_CSS_WEP40) ||
+ (pBSSNode->byCSSGK == WLAN_11i_CSS_WEP104)) {
+ byMulticastCipher = KEY_CTL_WEP;
+ } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_TKIP) {
+ byMulticastCipher = KEY_CTL_TKIP;
+ } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) {
+ byMulticastCipher = KEY_CTL_CCMP;
+ } else {
+ byMulticastCipher = KEY_CTL_INVALID;
+ }
+
+ // check Pairwise Key Cipher
+ for(i=0;i<pBSSNode->wCSSPKCount;i++) {
+ if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) ||
+ (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) {
+ // this should not happen as defined 802.11i
+ byCipherMask |= 0x01;
+ } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) {
+ byCipherMask |= 0x02;
+ } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) {
+ byCipherMask |= 0x04;
+ } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) {
+ // use group key only ignore all others
+ byCipherMask = 0;
+ i = pBSSNode->wCSSPKCount;
+ }
+ }
+ } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
+ (pBSSNode->bWPAValid == TRUE) &&
+ ((EncStatus == Ndis802_11Encryption3Enabled)||(EncStatus == Ndis802_11Encryption2Enabled))) {
+
+ //WPA
+ // check Group Key Cipher
+ if ((pBSSNode->byGKType == WPA_WEP40) ||
+ (pBSSNode->byGKType == WPA_WEP104)) {
+ byMulticastCipher = KEY_CTL_WEP;
+ } else if (pBSSNode->byGKType == WPA_TKIP) {
+ byMulticastCipher = KEY_CTL_TKIP;
+ } else if (pBSSNode->byGKType == WPA_AESCCMP) {
+ byMulticastCipher = KEY_CTL_CCMP;
+ } else {
+ byMulticastCipher = KEY_CTL_INVALID;
+ }
+
+ // check Pairwise Key Cipher
+ for(i=0;i<pBSSNode->wPKCount;i++) {
+ if (pBSSNode->abyPKType[i] == WPA_TKIP) {
+ byCipherMask |= 0x02;
+ } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) {
+ byCipherMask |= 0x04;
+ } else if (pBSSNode->abyPKType[i] == WPA_NONE) {
+ // use group key only ignore all others
+ byCipherMask = 0;
+ i = pBSSNode->wPKCount;
+ }
+ }
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%d, %d, %d, %d, EncStatus:%d\n",
+ byMulticastCipher, byCipherMask, pBSSNode->bWPAValid, pBSSNode->bWPA2Valid, EncStatus);
+
+ // mask our cap. with BSS
+ if (EncStatus == Ndis802_11Encryption1Enabled) {
+ // For supporting Cisco migration mode, don't care pairwise key cipher
+ if ((byMulticastCipher == KEY_CTL_WEP) &&
+ (byCipherMask == 0)) {
+ *pbyCCSGK = KEY_CTL_WEP;
+ *pbyCCSPK = KEY_CTL_NONE;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+
+ } else if (EncStatus == Ndis802_11Encryption2Enabled) {
+ if ((byMulticastCipher == KEY_CTL_TKIP) &&
+ (byCipherMask == 0)) {
+ *pbyCCSGK = KEY_CTL_TKIP;
+ *pbyCCSPK = KEY_CTL_NONE;
+ return TRUE;
+ } else if ((byMulticastCipher == KEY_CTL_WEP) &&
+ ((byCipherMask & 0x02) != 0)) {
+ *pbyCCSGK = KEY_CTL_WEP;
+ *pbyCCSPK = KEY_CTL_TKIP;
+ return TRUE;
+ } else if ((byMulticastCipher == KEY_CTL_TKIP) &&
+ ((byCipherMask & 0x02) != 0)) {
+ *pbyCCSGK = KEY_CTL_TKIP;
+ *pbyCCSPK = KEY_CTL_TKIP;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if (EncStatus == Ndis802_11Encryption3Enabled) {
+ if ((byMulticastCipher == KEY_CTL_CCMP) &&
+ (byCipherMask == 0)) {
+ // When CCMP is enable, "Use group cipher suite" shall not be a valid option.
+ return FALSE;
+ } else if ((byMulticastCipher == KEY_CTL_WEP) &&
+ ((byCipherMask & 0x04) != 0)) {
+ *pbyCCSGK = KEY_CTL_WEP;
+ *pbyCCSPK = KEY_CTL_CCMP;
+ return TRUE;
+ } else if ((byMulticastCipher == KEY_CTL_TKIP) &&
+ ((byCipherMask & 0x04) != 0)) {
+ *pbyCCSGK = KEY_CTL_TKIP;
+ *pbyCCSPK = KEY_CTL_CCMP;
+ return TRUE;
+ } else if ((byMulticastCipher == KEY_CTL_CCMP) &&
+ ((byCipherMask & 0x04) != 0)) {
+ *pbyCCSGK = KEY_CTL_CCMP;
+ *pbyCCSPK = KEY_CTL_CCMP;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+
diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h
new file mode 100644
index 000000000000..5b526ab2d912
--- /dev/null
+++ b/drivers/staging/vt6655/wmgr.h
@@ -0,0 +1,521 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: wmgr.h
+ *
+ * Purpose:
+ *
+ * Author: lyndon chen
+ *
+ * Date: Jan 2, 2003
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ */
+
+
+#ifndef __WMGR_H__
+#define __WMGR_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__WCMD_H__)
+#include "wcmd.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__WPA2_H__)
+#include "wpa2.h"
+#endif
+#if !defined(__VNTWIFI_H__)
+#include "vntwifi.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+
+// Scan time
+#define PROBE_DELAY 100 // (us)
+#define SWITCH_CHANNEL_DELAY 200 // (us)
+#define WLAN_SCAN_MINITIME 25 // (ms)
+#define WLAN_SCAN_MAXTIME 100 // (ms)
+#define TRIVIAL_SYNC_DIFFERENCE 0 // (us)
+#define DEFAULT_IBSS_BI 100 // (ms)
+
+#define WCMD_ACTIVE_SCAN_TIME 50 //(ms)
+#define WCMD_PASSIVE_SCAN_TIME 100 //(ms)
+
+
+#define DEFAULT_MSDU_LIFETIME 512 // ms
+#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us
+
+#define DEFAULT_MGN_LIFETIME 8 // ms
+#define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us
+
+#define MAKE_BEACON_RESERVED 10 //(us)
+
+
+#define TIM_MULTICAST_MASK 0x01
+#define TIM_BITMAPOFFSET_MASK 0xFE
+#define DEFAULT_DTIM_PERIOD 1
+
+#define AP_LONG_RETRY_LIMIT 4
+
+#define DEFAULT_IBSS_CHANNEL 6 //2.4G
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+#define timer_expire(timer,next_tick) mod_timer(&timer, RUN_AT(next_tick))
+typedef void (*TimerFunction)(ULONG);
+
+
+//+++ NDIS related
+
+typedef UCHAR NDIS_802_11_MAC_ADDRESS[6];
+typedef struct _NDIS_802_11_AI_REQFI
+{
+ USHORT Capabilities;
+ USHORT ListenInterval;
+ NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
+} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
+
+typedef struct _NDIS_802_11_AI_RESFI
+{
+ USHORT Capabilities;
+ USHORT StatusCode;
+ USHORT AssociationId;
+} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
+
+typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
+{
+ ULONG Length;
+ USHORT AvailableRequestFixedIEs;
+ NDIS_802_11_AI_REQFI RequestFixedIEs;
+ ULONG RequestIELength;
+ ULONG OffsetRequestIEs;
+ USHORT AvailableResponseFixedIEs;
+ NDIS_802_11_AI_RESFI ResponseFixedIEs;
+ ULONG ResponseIELength;
+ ULONG OffsetResponseIEs;
+} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
+
+
+
+typedef struct tagSAssocInfo {
+ NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
+ BYTE abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN];
+ // store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION
+ ULONG RequestIELength;
+ BYTE abyReqIEs[WLAN_BEACON_FR_MAXLEN];
+} SAssocInfo, DEF* PSAssocInfo;
+//---
+
+
+/*
+typedef enum tagWMAC_AUTHENTICATION_MODE {
+
+
+ WMAC_AUTH_OPEN,
+ WMAC_AUTH_SHAREKEY,
+ WMAC_AUTH_AUTO,
+ WMAC_AUTH_WPA,
+ WMAC_AUTH_WPAPSK,
+ WMAC_AUTH_WPANONE,
+ WMAC_AUTH_WPA2,
+ WMAC_AUTH_WPA2PSK,
+ WMAC_AUTH_MAX // Not a real mode, defined as upper bound
+
+
+} WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
+*/
+
+
+// Pre-configured Mode (from XP)
+/*
+typedef enum tagWMAC_CONFIG_MODE {
+ WMAC_CONFIG_ESS_STA,
+ WMAC_CONFIG_IBSS_STA,
+ WMAC_CONFIG_AUTO,
+ WMAC_CONFIG_AP
+
+} WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
+*/
+
+typedef enum tagWMAC_SCAN_TYPE {
+
+ WMAC_SCAN_ACTIVE,
+ WMAC_SCAN_PASSIVE,
+ WMAC_SCAN_HYBRID
+
+} WMAC_SCAN_TYPE, *PWMAC_SCAN_TYPE;
+
+
+typedef enum tagWMAC_SCAN_STATE {
+
+ WMAC_NO_SCANNING,
+ WMAC_IS_SCANNING,
+ WMAC_IS_PROBEPENDING
+
+} WMAC_SCAN_STATE, *PWMAC_SCAN_STATE;
+
+
+
+// Notes:
+// Basic Service Set state explained as following:
+// WMAC_STATE_IDLE : no BSS is selected (Adhoc or Infra)
+// WMAC_STATE_STARTED : no BSS is selected, start own IBSS (Adhoc only)
+// WMAC_STATE_JOINTED : BSS is selected and synchronized (Adhoc or Infra)
+// WMAC_STATE_AUTHPENDING : Authentication pending (Infra)
+// WMAC_STATE_AUTH : Authenticated (Infra)
+// WMAC_STATE_ASSOCPENDING : Association pending (Infra)
+// WMAC_STATE_ASSOC : Associated (Infra)
+
+typedef enum tagWMAC_BSS_STATE {
+
+ WMAC_STATE_IDLE,
+ WMAC_STATE_STARTED,
+ WMAC_STATE_JOINTED,
+ WMAC_STATE_AUTHPENDING,
+ WMAC_STATE_AUTH,
+ WMAC_STATE_ASSOCPENDING,
+ WMAC_STATE_ASSOC
+
+} WMAC_BSS_STATE, *PWMAC_BSS_STATE;
+
+// WMAC selected running mode
+typedef enum tagWMAC_CURRENT_MODE {
+
+ WMAC_MODE_STANDBY,
+ WMAC_MODE_ESS_STA,
+ WMAC_MODE_IBSS_STA,
+ WMAC_MODE_ESS_AP
+
+} WMAC_CURRENT_MODE, *PWMAC_CURRENT_MODE;
+
+/*
+typedef enum tagWMAC_POWER_MODE {
+
+ WMAC_POWER_CAM,
+ WMAC_POWER_FAST,
+ WMAC_POWER_MAX
+
+} WMAC_POWER_MODE, *PWMAC_POWER_MODE;
+*/
+
+
+// Tx Managment Packet descriptor
+typedef struct tagSTxMgmtPacket {
+
+ PUWLAN_80211HDR p80211Header;
+ UINT cbMPDULen;
+ UINT cbPayloadLen;
+
+} STxMgmtPacket, DEF* PSTxMgmtPacket;
+
+
+// Rx Managment Packet descriptor
+typedef struct tagSRxMgmtPacket {
+
+ PUWLAN_80211HDR p80211Header;
+ QWORD qwLocalTSF;
+ UINT cbMPDULen;
+ UINT cbPayloadLen;
+ UINT uRSSI;
+ BYTE bySQ;
+ BYTE byRxRate;
+ BYTE byRxChannel;
+
+} SRxMgmtPacket, DEF* PSRxMgmtPacket;
+
+
+
+typedef struct tagSMgmtObject
+{
+
+ PVOID pAdapter;
+ // MAC address
+ BYTE abyMACAddr[WLAN_ADDR_LEN];
+
+ // Configuration Mode
+ WMAC_CONFIG_MODE eConfigMode; // MAC pre-configed mode
+ CARD_PHY_TYPE eCurrentPHYMode;
+ CARD_PHY_TYPE eConfigPHYMode;
+
+
+ // Operation state variables
+ WMAC_CURRENT_MODE eCurrMode; // MAC current connection mode
+ WMAC_BSS_STATE eCurrState; // MAC current BSS state
+
+ PKnownBSS pCurrBSS;
+ BYTE byCSSGK;
+ BYTE byCSSPK;
+
+// BYTE abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
+// BYTE abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
+
+ // Current state vars
+ UINT uCurrChannel;
+ BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ BYTE abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ BYTE abyCurrBSSID[WLAN_BSSID_LEN];
+ WORD wCurrCapInfo;
+ WORD wCurrAID;
+ WORD wCurrATIMWindow;
+ WORD wCurrBeaconPeriod;
+ BOOL bIsDS;
+ BYTE byERPContext;
+
+ CMD_STATE eCommandState;
+ UINT uScanChannel;
+
+ // Desire joinning BSS vars
+ BYTE abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ BYTE abyDesireBSSID[WLAN_BSSID_LEN];
+
+ // Adhoc or AP configuration vars
+ //BYTE abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ WORD wIBSSBeaconPeriod;
+ WORD wIBSSATIMWindow;
+ UINT uIBSSChannel;
+ BYTE abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+ BYTE byAPBBType;
+ BYTE abyWPAIE[MAX_WPA_IE_LEN];
+ WORD wWPAIELen;
+
+ UINT uAssocCount;
+ BOOL bMoreData;
+
+ // Scan state vars
+ WMAC_SCAN_STATE eScanState;
+ WMAC_SCAN_TYPE eScanType;
+ UINT uScanStartCh;
+ UINT uScanEndCh;
+ WORD wScanSteps;
+ UINT uScanBSSType;
+ // Desire scannig vars
+ BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ BYTE abyScanBSSID[WLAN_BSSID_LEN];
+
+ // Privacy
+ WMAC_AUTHENTICATION_MODE eAuthenMode;
+ WMAC_ENCRYPTION_MODE eEncryptionMode;
+ BOOL bShareKeyAlgorithm;
+ BYTE abyChallenge[WLAN_CHALLENGE_LEN];
+ BOOL bPrivacyInvoked;
+
+ // Received beacon state vars
+ BOOL bInTIM;
+ BOOL bMulticastTIM;
+ BYTE byDTIMCount;
+ BYTE byDTIMPeriod;
+
+ // Power saving state vars
+ WMAC_POWER_MODE ePSMode;
+ WORD wListenInterval;
+ WORD wCountToWakeUp;
+ BOOL bInTIMWake;
+ PBYTE pbyPSPacketPool;
+ BYTE byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN];
+ BOOL bRxBeaconInTBTTWake;
+ BYTE abyPSTxMap[MAX_NODE_NUM + 1];
+
+ // managment command related
+ UINT uCmdBusy;
+ UINT uCmdHostAPBusy;
+
+ // managment packet pool
+ PBYTE pbyMgmtPacketPool;
+ BYTE byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
+
+
+ // One second callback timer
+ struct timer_list sTimerSecondCallback;
+
+ // Temporarily Rx Mgmt Packet Descriptor
+ SRxMgmtPacket sRxPacket;
+
+ // link list of known bss's (scan results)
+ KnownBSS sBSSList[MAX_BSS_NUM];
+
+
+
+ // table list of known node
+ // sNodeDBList[0] is reserved for AP under Infra mode
+ // sNodeDBList[0] is reserved for Multicast under adhoc/AP mode
+ KnownNodeDB sNodeDBTable[MAX_NODE_NUM + 1];
+
+
+
+ // WPA2 PMKID Cache
+ SPMKIDCache gsPMKIDCache;
+ BOOL bRoaming;
+
+ // rate fall back vars
+
+
+
+ // associate info
+ SAssocInfo sAssocInfo;
+
+
+ // for 802.11h
+ BOOL b11hEnable;
+ BOOL bSwitchChannel;
+ BYTE byNewChannel;
+ PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep;
+ UINT uLengthOfRepEIDs;
+ BYTE abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
+ BYTE abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
+ BYTE abyIECountry[WLAN_A3FR_MAXLEN];
+ BYTE abyIBSSDFSOwner[6];
+ BYTE byIBSSDFSRecovery;
+
+ struct sk_buff skb;
+
+} SMgmtObject, DEF *PSMgmtObject;
+
+
+/*--------------------- Export Macros ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+void
+vMgrObjectInit(
+ IN HANDLE hDeviceContext
+ );
+
+void
+vMgrTimerInit(
+ IN HANDLE hDeviceContext
+ );
+
+VOID
+vMgrObjectReset(
+ IN HANDLE hDeviceContext
+ );
+
+void
+vMgrAssocBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ OUT PCMD_STATUS pStatus
+ );
+
+VOID
+vMgrReAssocBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ OUT PCMD_STATUS pStatus
+ );
+
+VOID
+vMgrDisassocBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE abyDestAddress,
+ IN WORD wReason,
+ OUT PCMD_STATUS pStatus
+ );
+
+VOID
+vMgrAuthenBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ OUT PCMD_STATUS pStatus
+ );
+
+VOID
+vMgrCreateOwnIBSS(
+ IN HANDLE hDeviceContext,
+ OUT PCMD_STATUS pStatus
+ );
+
+VOID
+vMgrJoinBSSBegin(
+ IN HANDLE hDeviceContext,
+ OUT PCMD_STATUS pStatus
+ );
+
+VOID
+vMgrRxManagePacket(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ IN PSRxMgmtPacket pRxPacket
+ );
+
+/*
+VOID
+vMgrScanBegin(
+ IN HANDLE hDeviceContext,
+ OUT PCMD_STATUS pStatus
+ );
+*/
+
+VOID
+vMgrDeAuthenBeginSta(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt,
+ IN PBYTE abyDestAddress,
+ IN WORD wReason,
+ OUT PCMD_STATUS pStatus
+ );
+
+BOOL
+bMgrPrepareBeaconToSend(
+ IN HANDLE hDeviceContext,
+ IN PSMgmtObject pMgmt
+ );
+
+
+BOOL
+bAdd_PMKID_Candidate (
+ IN HANDLE hDeviceContext,
+ IN PBYTE pbyBSSID,
+ IN PSRSNCapObject psRSNCapObj
+ );
+
+VOID
+vFlush_PMKID_Candidate (
+ IN HANDLE hDeviceContext
+ );
+
+#endif // __WMGR_H__
diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c
new file mode 100644
index 000000000000..8b4e7fc31efa
--- /dev/null
+++ b/drivers/staging/vt6655/wpa.c
@@ -0,0 +1,339 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: wpa.c
+ *
+ * Purpose: Handles the Basic Service Set & Node Database functions
+ *
+ * Functions:
+ * WPA_ParseRSN - Parse RSN IE.
+ *
+ * Revision History:
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: July 14, 2003
+ *
+ */
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__TETHER_H__)
+#include "tether.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__WPA_H__)
+#include "wpa.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+
+const BYTE abyOUI00[4] = { 0x00, 0x50, 0xf2, 0x00 };
+const BYTE abyOUI01[4] = { 0x00, 0x50, 0xf2, 0x01 };
+const BYTE abyOUI02[4] = { 0x00, 0x50, 0xf2, 0x02 };
+const BYTE abyOUI03[4] = { 0x00, 0x50, 0xf2, 0x03 };
+const BYTE abyOUI04[4] = { 0x00, 0x50, 0xf2, 0x04 };
+const BYTE abyOUI05[4] = { 0x00, 0x50, 0xf2, 0x05 };
+
+
+/*+
+ *
+ * Description:
+ * Clear RSN information in BSSList.
+ *
+ * Parameters:
+ * In:
+ * pBSSList - BSS list.
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+
+VOID
+WPA_ClearRSN (
+ IN PKnownBSS pBSSList
+ )
+{
+ int ii;
+ pBSSList->byGKType = WPA_TKIP;
+ for (ii=0; ii < 4; ii ++)
+ pBSSList->abyPKType[ii] = WPA_TKIP;
+ pBSSList->wPKCount = 0;
+ for (ii=0; ii < 4; ii ++)
+ pBSSList->abyAuthType[ii] = WPA_AUTH_IEEE802_1X;
+ pBSSList->wAuthCount = 0;
+ pBSSList->byDefaultK_as_PK = 0;
+ pBSSList->byReplayIdx = 0;
+ pBSSList->sRSNCapObj.bRSNCapExist = FALSE;
+ pBSSList->sRSNCapObj.wRSNCap = 0;
+ pBSSList->bWPAValid = FALSE;
+}
+
+
+/*+
+ *
+ * Description:
+ * Parse RSN IE.
+ *
+ * Parameters:
+ * In:
+ * pBSSList - BSS list.
+ * pRSN - Pointer to the RSN IE.
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+WPA_ParseRSN (
+ IN PKnownBSS pBSSList,
+ IN PWLAN_IE_RSN_EXT pRSN
+ )
+{
+ PWLAN_IE_RSN_AUTH pIE_RSN_Auth = NULL;
+ int i, j, m, n = 0;
+ PBYTE pbyCaps;
+
+ WPA_ClearRSN(pBSSList);
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA_ParseRSN: [%d]\n", pRSN->len);
+
+ // information element header makes sense
+ if ((pRSN->len >= 6) // oui1(4)+ver(2)
+ && (pRSN->byElementID == WLAN_EID_RSN_WPA) && MEMEqualMemory(pRSN->abyOUI, abyOUI01, 4)
+ && (pRSN->wVersion == 1)) {
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Legal RSN\n");
+ // update each variable if pRSN is long enough to contain the variable
+ if (pRSN->len >= 10) //oui1(4)+ver(2)+GKSuite(4)
+ {
+ if (MEMEqualMemory(pRSN->abyMulticast, abyOUI01, 4))
+ pBSSList->byGKType = WPA_WEP40;
+ else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI02, 4))
+ pBSSList->byGKType = WPA_TKIP;
+ else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI03, 4))
+ pBSSList->byGKType = WPA_AESWRAP;
+ else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI04, 4))
+ pBSSList->byGKType = WPA_AESCCMP;
+ else if (MEMEqualMemory(pRSN->abyMulticast, abyOUI05, 4))
+ pBSSList->byGKType = WPA_WEP104;
+ else
+ // any vendor checks here
+ pBSSList->byGKType = WPA_NONE;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byGKType: %x\n", pBSSList->byGKType);
+ }
+
+ if (pRSN->len >= 12) //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)
+ {
+ j = 0;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %d\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType));
+ for(i = 0; (i < pRSN->wPKCount) && (j < sizeof(pBSSList->abyPKType)/sizeof(BYTE)); i++) {
+ if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
+ if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
+ pBSSList->abyPKType[j++] = WPA_NONE;
+ else if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI02, 4))
+ pBSSList->abyPKType[j++] = WPA_TKIP;
+ else if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI03, 4))
+ pBSSList->abyPKType[j++] = WPA_AESWRAP;
+ else if (MEMEqualMemory(pRSN->PKSList[i].abyOUI, abyOUI04, 4))
+ pBSSList->abyPKType[j++] = WPA_AESCCMP;
+ else
+ // any vendor checks here
+ ;
+ }
+ else
+ break;
+ //DBG_PRN_GRP14(("abyPKType[%d]: %X\n", j-1, pBSSList->abyPKType[j-1]));
+ } //for
+ pBSSList->wPKCount = (WORD)j;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d\n", pBSSList->wPKCount);
+ }
+
+ m = pRSN->wPKCount;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"m: %d\n", m);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"14+m*4: %d\n", 14+m*4);
+
+ if (pRSN->len >= 14+m*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)
+ // overlay IE_RSN_Auth structure into correct place
+ pIE_RSN_Auth = (PWLAN_IE_RSN_AUTH) pRSN->PKSList[m].abyOUI;
+ j = 0;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %d\n",
+ pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType));
+ for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < sizeof(pBSSList->abyAuthType)/sizeof(BYTE)); i++) {
+ if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
+ if (MEMEqualMemory(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
+ pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;
+ else if (MEMEqualMemory(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI02, 4))
+ pBSSList->abyAuthType[j++] = WPA_AUTH_PSK;
+ else
+ // any vendor checks here
+ ;
+ }
+ else
+ break;
+ //DBG_PRN_GRP14(("abyAuthType[%d]: %X\n", j-1, pBSSList->abyAuthType[j-1]));
+ }
+ if(j > 0)
+ pBSSList->wAuthCount = (WORD)j;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d\n", pBSSList->wAuthCount);
+ }
+
+ if (pIE_RSN_Auth != NULL) {
+
+ n = pIE_RSN_Auth->wAuthCount;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"n: %d\n", n);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"14+4+(m+n)*4: %d\n", 14+4+(m+n)*4);
+
+ if(pRSN->len+2 >= 14+4+(m+n)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*n)+Cap(2)
+ pbyCaps = (PBYTE)pIE_RSN_Auth->AuthKSList[n].abyOUI;
+ pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG;
+ pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS);
+ pBSSList->sRSNCapObj.bRSNCapExist = TRUE;
+ pBSSList->sRSNCapObj.wRSNCap = *(PWORD)pbyCaps;
+ //DBG_PRN_GRP14(("pbyCaps: %X\n", *pbyCaps));
+ //DBG_PRN_GRP14(("byDefaultK_as_PK: %X\n", pBSSList->byDefaultK_as_PK));
+ //DBG_PRN_GRP14(("byReplayIdx: %X\n", pBSSList->byReplayIdx));
+ }
+ }
+ pBSSList->bWPAValid = TRUE;
+ }
+}
+
+/*+
+ *
+ * Description:
+ * Search RSN information in BSSList.
+ *
+ * Parameters:
+ * In:
+ * byCmd - Search type
+ * byEncrypt- Encrcypt Type
+ * pBSSList - BSS list
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+WPA_SearchRSN (
+ BYTE byCmd,
+ BYTE byEncrypt,
+ IN PKnownBSS pBSSList
+ )
+{
+ int ii;
+ BYTE byPKType = WPA_NONE;
+
+ if (pBSSList->bWPAValid == FALSE)
+ return FALSE;
+
+ switch(byCmd) {
+ case 0:
+
+ if (byEncrypt != pBSSList->byGKType)
+ return FALSE;
+
+ if (pBSSList->wPKCount > 0) {
+ for (ii = 0; ii < pBSSList->wPKCount; ii ++) {
+ if (pBSSList->abyPKType[ii] == WPA_AESCCMP)
+ byPKType = WPA_AESCCMP;
+ else if ((pBSSList->abyPKType[ii] == WPA_TKIP) && (byPKType != WPA_AESCCMP))
+ byPKType = WPA_TKIP;
+ else if ((pBSSList->abyPKType[ii] == WPA_WEP40) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP))
+ byPKType = WPA_WEP40;
+ else if ((pBSSList->abyPKType[ii] == WPA_WEP104) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP))
+ byPKType = WPA_WEP104;
+ }
+ if (byEncrypt != byPKType)
+ return FALSE;
+ }
+ return TRUE;
+// if (pBSSList->wAuthCount > 0)
+// for (ii=0; ii < pBSSList->wAuthCount; ii ++)
+// if (byAuth == pBSSList->abyAuthType[ii])
+// break;
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+/*+
+ *
+ * Description:
+ * Check if RSN IE makes sense.
+ *
+ * Parameters:
+ * In:
+ * pRSN - Pointer to the RSN IE.
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+BOOL
+WPAb_Is_RSN (
+ IN PWLAN_IE_RSN_EXT pRSN
+ )
+{
+ if (pRSN == NULL)
+ return FALSE;
+
+ if ((pRSN->len >= 6) && // oui1(4)+ver(2)
+ (pRSN->byElementID == WLAN_EID_RSN_WPA) && MEMEqualMemory(pRSN->abyOUI, abyOUI01, 4) &&
+ (pRSN->wVersion == 1)) {
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
diff --git a/drivers/staging/vt6655/wpa.h b/drivers/staging/vt6655/wpa.h
new file mode 100644
index 000000000000..8000a37c6fc3
--- /dev/null
+++ b/drivers/staging/vt6655/wpa.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: wpa.h
+ *
+ * Purpose: Defines the macros, types, and functions for dealing
+ * with WPA informations.
+ *
+ * Author: Kyle Hsu
+ *
+ * Date: Jul 14, 2003
+ *
+ */
+
+#ifndef __WPA_H__
+#define __WPA_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define WPA_NONE 0
+#define WPA_WEP40 1
+#define WPA_TKIP 2
+#define WPA_AESWRAP 3
+#define WPA_AESCCMP 4
+#define WPA_WEP104 5
+#define WPA_AUTH_IEEE802_1X 1
+#define WPA_AUTH_PSK 2
+
+#define WPA_GROUPFLAG 0x02
+#define WPA_REPLAYBITSSHIFT 2
+#define WPA_REPLAYBITS 0x03
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+VOID
+WPA_ClearRSN(
+ IN PKnownBSS pBSSList
+ );
+
+VOID
+WPA_ParseRSN(
+ IN PKnownBSS pBSSList,
+ IN PWLAN_IE_RSN_EXT pRSN
+ );
+
+BOOL
+WPA_SearchRSN(
+ BYTE byCmd,
+ BYTE byEncrypt,
+ IN PKnownBSS pBSSList
+ );
+
+BOOL
+WPAb_Is_RSN(
+ IN PWLAN_IE_RSN_EXT pRSN
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __WPA_H__
diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c
new file mode 100644
index 000000000000..e2fdb331069e
--- /dev/null
+++ b/drivers/staging/vt6655/wpa2.c
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: wpa2.c
+ *
+ * Purpose: Handles the Basic Service Set & Node Database functions
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ * Author: Yiching Chen
+ *
+ * Date: Oct. 4, 2004
+ *
+ */
+#if !defined(__WPA2_H__)
+#include "wpa2.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+const BYTE abyOUIGK[4] = { 0x00, 0x0F, 0xAC, 0x00 };
+const BYTE abyOUIWEP40[4] = { 0x00, 0x0F, 0xAC, 0x01 };
+const BYTE abyOUIWEP104[4] = { 0x00, 0x0F, 0xAC, 0x05 };
+const BYTE abyOUITKIP[4] = { 0x00, 0x0F, 0xAC, 0x02 };
+const BYTE abyOUICCMP[4] = { 0x00, 0x0F, 0xAC, 0x04 };
+
+const BYTE abyOUI8021X[4] = { 0x00, 0x0F, 0xAC, 0x01 };
+const BYTE abyOUIPSK[4] = { 0x00, 0x0F, 0xAC, 0x02 };
+
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+/*+
+ *
+ * Description:
+ * Clear RSN information in BSSList.
+ *
+ * Parameters:
+ * In:
+ * pBSSNode - BSS list.
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+WPA2_ClearRSN (
+ IN PKnownBSS pBSSNode
+ )
+{
+ int ii;
+
+ pBSSNode->bWPA2Valid = FALSE;
+
+ pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP;
+ for (ii=0; ii < 4; ii ++)
+ pBSSNode->abyCSSPK[ii] = WLAN_11i_CSS_CCMP;
+ pBSSNode->wCSSPKCount = 1;
+ for (ii=0; ii < 4; ii ++)
+ pBSSNode->abyAKMSSAuthType[ii] = WLAN_11i_AKMSS_802_1X;
+ pBSSNode->wAKMSSAuthCount = 1;
+ pBSSNode->sRSNCapObj.bRSNCapExist = FALSE;
+ pBSSNode->sRSNCapObj.wRSNCap = 0;
+}
+
+/*+
+ *
+ * Description:
+ * Parse RSN IE.
+ *
+ * Parameters:
+ * In:
+ * pBSSNode - BSS list.
+ * pRSN - Pointer to the RSN IE.
+ * Out:
+ * none
+ *
+ * Return Value: none.
+ *
+-*/
+VOID
+WPA2vParseRSN (
+ IN PKnownBSS pBSSNode,
+ IN PWLAN_IE_RSN pRSN
+ )
+{
+ int i, j;
+ WORD m = 0, n = 0;
+ PBYTE pbyOUI;
+ BOOL bUseGK = FALSE;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA2_ParseRSN: [%d]\n", pRSN->len);
+
+ WPA2_ClearRSN(pBSSNode);
+
+ if (pRSN->len == 2) { // ver(2)
+ if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1)) {
+ pBSSNode->bWPA2Valid = TRUE;
+ }
+ return;
+ }
+
+ if (pRSN->len < 6) { // ver(2) + GK(4)
+ // invalid CSS, P802.11i/D10.0, p31
+ return;
+ }
+
+ // information element header makes sense
+ if ((pRSN->byElementID == WLAN_EID_RSN) &&
+ (pRSN->wVersion == 1)) {
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Legal 802.11i RSN\n");
+
+ pbyOUI = &(pRSN->abyRSN[0]);
+ if (MEMEqualMemory(pbyOUI, abyOUIWEP40, 4))
+ pBSSNode->byCSSGK = WLAN_11i_CSS_WEP40;
+ else if (MEMEqualMemory(pbyOUI, abyOUITKIP, 4))
+ pBSSNode->byCSSGK = WLAN_11i_CSS_TKIP;
+ else if (MEMEqualMemory(pbyOUI, abyOUICCMP, 4))
+ pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP;
+ else if (MEMEqualMemory(pbyOUI, abyOUIWEP104, 4))
+ pBSSNode->byCSSGK = WLAN_11i_CSS_WEP104;
+ else if (MEMEqualMemory(pbyOUI, abyOUIGK, 4)) {
+ // invalid CSS, P802.11i/D10.0, p32
+ return;
+ } else
+ // any vendor checks here
+ pBSSNode->byCSSGK = WLAN_11i_CSS_UNKNOWN;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"802.11i CSS: %X\n", pBSSNode->byCSSGK);
+
+ if (pRSN->len == 6) {
+ pBSSNode->bWPA2Valid = TRUE;
+ return;
+ }
+
+ if (pRSN->len >= 8) { // ver(2) + GK(4) + PK count(2)
+ pBSSNode->wCSSPKCount = *((PWORD) &(pRSN->abyRSN[4]));
+ j = 0;
+ pbyOUI = &(pRSN->abyRSN[6]);
+
+ for (i = 0; (i < pBSSNode->wCSSPKCount) && (j < sizeof(pBSSNode->abyCSSPK)/sizeof(BYTE)); i++) {
+
+ if (pRSN->len >= 8+i*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i)
+ if (MEMEqualMemory(pbyOUI, abyOUIGK, 4)) {
+ pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_USE_GROUP;
+ bUseGK = TRUE;
+ } else if (MEMEqualMemory(pbyOUI, abyOUIWEP40, 4)) {
+ // Invialid CSS, continue to parsing
+ } else if (MEMEqualMemory(pbyOUI, abyOUITKIP, 4)) {
+ if (pBSSNode->byCSSGK != WLAN_11i_CSS_CCMP)
+ pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_TKIP;
+ else
+ ; // Invialid CSS, continue to parsing
+ } else if (MEMEqualMemory(pbyOUI, abyOUICCMP, 4)) {
+ pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_CCMP;
+ } else if (MEMEqualMemory(pbyOUI, abyOUIWEP104, 4)) {
+ // Invialid CSS, continue to parsing
+ } else {
+ // any vendor checks here
+ pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_UNKNOWN;
+ }
+ pbyOUI += 4;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyCSSPK[%d]: %X\n", j-1, pBSSNode->abyCSSPK[j-1]);
+ } else
+ break;
+ } //for
+
+ if (bUseGK == TRUE) {
+ if (j != 1) {
+ // invalid CSS, This should be only PK CSS.
+ return;
+ }
+ if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) {
+ // invalid CSS, If CCMP is enable , PK can't be CSSGK.
+ return;
+ }
+ }
+ if ((pBSSNode->wCSSPKCount != 0) && (j == 0)) {
+ // invalid CSS, No valid PK.
+ return;
+ }
+ pBSSNode->wCSSPKCount = (WORD)j;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wCSSPKCount: %d\n", pBSSNode->wCSSPKCount);
+ }
+
+ m = *((PWORD) &(pRSN->abyRSN[4]));
+
+ if (pRSN->len >= 10+m*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2)
+ pBSSNode->wAKMSSAuthCount = *((PWORD) &(pRSN->abyRSN[6+4*m]));;
+ j = 0;
+ pbyOUI = &(pRSN->abyRSN[8+4*m]);
+ for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(BYTE)); i++) {
+ if (pRSN->len >= 10+(m+i)*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSS(2)+AKS(4*i)
+ if (MEMEqualMemory(pbyOUI, abyOUI8021X, 4))
+ pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_802_1X;
+ else if (MEMEqualMemory(pbyOUI, abyOUIPSK, 4))
+ pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_PSK;
+ else
+ // any vendor checks here
+ pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_UNKNOWN;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyAKMSSAuthType[%d]: %X\n", j-1, pBSSNode->abyAKMSSAuthType[j-1]);
+ } else
+ break;
+ }
+ pBSSNode->wAKMSSAuthCount = (WORD)j;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAKMSSAuthCount: %d\n", pBSSNode->wAKMSSAuthCount);
+
+ n = *((PWORD) &(pRSN->abyRSN[6+4*m]));;
+ if (pRSN->len >= 12+4*m+4*n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2)
+ pBSSNode->sRSNCapObj.bRSNCapExist = TRUE;
+ pBSSNode->sRSNCapObj.wRSNCap = *((PWORD) &(pRSN->abyRSN[8+4*m+4*n]));
+ }
+ }
+ //ignore PMKID lists bcs only (Re)Assocrequest has this field
+ pBSSNode->bWPA2Valid = TRUE;
+ }
+}
+
+
+/*+
+ *
+ * Description:
+ * Set WPA IEs
+ *
+ * Parameters:
+ * In:
+ * pMgmtHandle - Pointer to management object
+ * Out:
+ * pRSNIEs - Pointer to the RSN IE to set.
+ *
+ * Return Value: length of IEs.
+ *
+-*/
+UINT
+WPA2uSetIEs(
+ IN PVOID pMgmtHandle,
+ OUT PWLAN_IE_RSN pRSNIEs
+ )
+{
+ PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
+ PBYTE pbyBuffer = NULL;
+ UINT ii = 0;
+ PWORD pwPMKID = NULL;
+
+ if (pRSNIEs == NULL) {
+ return(0);
+ }
+ if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
+ (pMgmt->pCurrBSS != NULL)) {
+ /* WPA2 IE */
+ pbyBuffer = (PBYTE) pRSNIEs;
+ pRSNIEs->byElementID = WLAN_EID_RSN;
+ pRSNIEs->len = 6; //Version(2)+GK(4)
+ pRSNIEs->wVersion = 1;
+ //Group Key Cipher Suite
+ pRSNIEs->abyRSN[0] = 0x00;
+ pRSNIEs->abyRSN[1] = 0x0F;
+ pRSNIEs->abyRSN[2] = 0xAC;
+ if (pMgmt->byCSSGK == KEY_CTL_WEP) {
+ pRSNIEs->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK;
+ } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) {
+ pRSNIEs->abyRSN[3] = WLAN_11i_CSS_TKIP;
+ } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) {
+ pRSNIEs->abyRSN[3] = WLAN_11i_CSS_CCMP;
+ } else {
+ pRSNIEs->abyRSN[3] = WLAN_11i_CSS_UNKNOWN;
+ }
+
+ // Pairwise Key Cipher Suite
+ pRSNIEs->abyRSN[4] = 1;
+ pRSNIEs->abyRSN[5] = 0;
+ pRSNIEs->abyRSN[6] = 0x00;
+ pRSNIEs->abyRSN[7] = 0x0F;
+ pRSNIEs->abyRSN[8] = 0xAC;
+ if (pMgmt->byCSSPK == KEY_CTL_TKIP) {
+ pRSNIEs->abyRSN[9] = WLAN_11i_CSS_TKIP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) {
+ pRSNIEs->abyRSN[9] = WLAN_11i_CSS_CCMP;
+ } else if (pMgmt->byCSSPK == KEY_CTL_NONE) {
+ pRSNIEs->abyRSN[9] = WLAN_11i_CSS_USE_GROUP;
+ } else {
+ pRSNIEs->abyRSN[9] = WLAN_11i_CSS_UNKNOWN;
+ }
+ pRSNIEs->len += 6;
+
+ // Auth Key Management Suite
+ pRSNIEs->abyRSN[10] = 1;
+ pRSNIEs->abyRSN[11] = 0;
+ pRSNIEs->abyRSN[12] = 0x00;
+ pRSNIEs->abyRSN[13] = 0x0F;
+ pRSNIEs->abyRSN[14] = 0xAC;
+ if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) {
+ pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_PSK;
+ } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) {
+ pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_802_1X;
+ } else {
+ pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN;
+ }
+ pRSNIEs->len +=6;
+
+ // RSN Capabilites
+ if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) {
+ MEMvCopy(&pRSNIEs->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2);
+ } else {
+ pRSNIEs->abyRSN[16] = 0;
+ pRSNIEs->abyRSN[17] = 0;
+ }
+ pRSNIEs->len +=2;
+
+ if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) &&
+ (pMgmt->bRoaming == TRUE) &&
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) {
+ // RSN PMKID
+ pwPMKID = (PWORD)(&pRSNIEs->abyRSN[18]); // Point to PMKID count
+ *pwPMKID = 0; // Initialize PMKID count
+ pbyBuffer = &pRSNIEs->abyRSN[20]; // Point to PMKID list
+ for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) {
+ if (MEMEqualMemory(&pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) {
+ (*pwPMKID) ++;
+ MEMvCopy(pbyBuffer, pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, 16);
+ pbyBuffer += 16;
+ }
+ }
+ if (*pwPMKID != 0) {
+ pRSNIEs->len += (2 + (*pwPMKID)*16);
+ } else {
+ pbyBuffer = &pRSNIEs->abyRSN[18];
+ }
+ }
+ return(pRSNIEs->len + WLAN_IEHDR_LEN);
+ }
+ return(0);
+}
diff --git a/drivers/staging/vt6655/wpa2.h b/drivers/staging/vt6655/wpa2.h
new file mode 100644
index 000000000000..bda045b313b9
--- /dev/null
+++ b/drivers/staging/vt6655/wpa2.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ * File: wpa2.h
+ *
+ * Purpose: Defines the macros, types, and functions for dealing
+ * with WPA2 informations.
+ *
+ * Author: Yiching Chen
+ *
+ * Date: Oct. 4, 2004
+ *
+ */
+
+#ifndef __WPA2_H__
+#define __WPA2_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__80211MGR_H__)
+#include "80211mgr.h"
+#endif
+#if !defined(__80211HDR_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__VNTWIFI_H__)
+#include "vntwifi.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+typedef struct tagsPMKIDInfo {
+ BYTE abyBSSID[6];
+ BYTE abyPMKID[16];
+} PMKIDInfo, *PPMKIDInfo;
+
+typedef struct tagSPMKIDCache {
+ ULONG BSSIDInfoCount;
+ PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE];
+} SPMKIDCache, *PSPMKIDCache;
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+VOID
+WPA2_ClearRSN (
+ IN PKnownBSS pBSSNode
+ );
+
+VOID
+WPA2vParseRSN (
+ IN PKnownBSS pBSSNode,
+ IN PWLAN_IE_RSN pRSN
+ );
+
+UINT
+WPA2uSetIEs(
+ IN PVOID pMgmtHandle,
+ OUT PWLAN_IE_RSN pRSNIEs
+ );
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __WPA2_H__
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
new file mode 100644
index 000000000000..ee7109d1b8ec
--- /dev/null
+++ b/drivers/staging/vt6655/wpactl.c
@@ -0,0 +1,1014 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wpactl.c
+ *
+ * Purpose: handle wpa supplicant ioctl input/out functions
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Oct. 20, 2003
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__WPACTL_H__)
+#include "wpactl.h"
+#endif
+#if !defined(__KEY_H__)
+#include "key.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__WMGR_H__)
+#include "wmgr.h"
+#endif
+#if !defined(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+//2008-0717-05, <Add> by James
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+
+#define VIAWGET_WPA_MAX_BUF_SIZE 1024
+
+
+
+static const int frequency_list[] = {
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442,
+ 2447, 2452, 2457, 2462, 2467, 2472, 2484
+};
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+/*--------------------- Static Functions --------------------------*/
+
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+
+static void wpadev_setup(struct net_device *dev)
+{
+ dev->type = ARPHRD_IEEE80211;
+ dev->hard_header_len = ETH_HLEN;
+ dev->mtu = 2048;
+ dev->addr_len = ETH_ALEN;
+ dev->tx_queue_len = 1000;
+
+ memset(dev->broadcast,0xFF, ETH_ALEN);
+
+ dev->flags = IFF_BROADCAST|IFF_MULTICAST;
+}
+
+
+
+/*
+ * Description:
+ * register netdev for wpa supplicant deamon
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * enable -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_init_wpadev(PSDevice pDevice)
+{
+ struct net_device *dev = pDevice->dev;
+ int ret=0;
+
+ pDevice->wpadev = alloc_netdev(0, "vntwpa", wpadev_setup);
+ if (pDevice->wpadev == NULL)
+ return -ENOMEM;
+
+ pDevice->wpadev->priv = pDevice;
+ memcpy(pDevice->wpadev->dev_addr, dev->dev_addr, U_ETHER_ADDR_LEN);
+ pDevice->wpadev->base_addr = dev->base_addr;
+ pDevice->wpadev->irq = dev->irq;
+ pDevice->wpadev->mem_start = dev->mem_start;
+ pDevice->wpadev->mem_end = dev->mem_end;
+ ret = register_netdev(pDevice->wpadev);
+ if (ret) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdev(WPA) failed!\n",
+ dev->name);
+ free_netdev(pDevice->wpadev);
+ return -1;
+ }
+
+ if (pDevice->skb == NULL) {
+ pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ if (pDevice->skb == NULL)
+ return -ENOMEM;
+ }
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdev %s for WPA management\n",
+ dev->name, pDevice->wpadev->name);
+
+ return 0;
+}
+
+
+/*
+ * Description:
+ * unregister net_device (wpadev)
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_release_wpadev(PSDevice pDevice)
+{
+
+ if (pDevice->skb) {
+ dev_kfree_skb(pDevice->skb);
+ pDevice->skb = NULL;
+ }
+
+ if (pDevice->wpadev) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
+ pDevice->dev->name, pDevice->wpadev->name);
+ unregister_netdev(pDevice->wpadev);
+ free_netdev(pDevice->wpadev);
+ pDevice->wpadev = NULL;
+ }
+
+ return 0;
+}
+
+
+
+
+
+/*
+ * Description:
+ * Set enable/disable dev for wpa supplicant deamon
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * val -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+int wpa_set_wpadev(PSDevice pDevice, int val)
+{
+
+
+ if (val)
+ return wpa_init_wpadev(pDevice);
+ else
+ return wpa_release_wpadev(pDevice);
+}
+
+
+/*
+ * Description:
+ * Set WPA algorithm & keys
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+int wpa_set_keys(PSDevice pDevice, void *ctx, BOOL fcpfkernel)
+{
+ struct viawget_wpa_param *param=ctx;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ DWORD dwKeyIndex = 0;
+ BYTE abyKey[MAX_KEY_LEN];
+ BYTE abySeq[MAX_KEY_LEN];
+ QWORD KeyRSC;
+// NDIS_802_11_KEY_RSC KeyRSC;
+ BYTE byKeyDecMode = KEY_CTL_WEP;
+ int ret = 0;
+ int uu, ii;
+
+
+ if (param->u.wpa_key.alg_name > WPA_ALG_CCMP)
+ return -EINVAL;
+
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "param->u.wpa_key.alg_name = %d \n", param->u.wpa_key.alg_name);
+ if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->byKeyIndex = 0;
+ pDevice->bTransmitKey = FALSE;
+ KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset);
+ for (uu=0; uu<MAX_KEY_TABLE; uu++) {
+ MACvDisableKeyEntry(pDevice->PortOffset, uu);
+ }
+ return ret;
+ }
+
+ //spin_unlock_irq(&pDevice->lock);
+ if(param->u.wpa_key.key && fcpfkernel) {
+ memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len);
+ }
+ else {
+ spin_unlock_irq(&pDevice->lock);
+ if (param->u.wpa_key.key &&
+ copy_from_user(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len)){
+ spin_lock_irq(&pDevice->lock);
+ return -EINVAL;
+ }
+spin_lock_irq(&pDevice->lock);
+ }
+
+ dwKeyIndex = (DWORD)(param->u.wpa_key.key_index);
+
+ if (param->u.wpa_key.alg_name == WPA_ALG_WEP) {
+ if (dwKeyIndex > 3) {
+ return -EINVAL;
+ }
+ else {
+ if (param->u.wpa_key.set_tx) {
+ pDevice->byKeyIndex = (BYTE)dwKeyIndex;
+ pDevice->bTransmitKey = TRUE;
+ dwKeyIndex |= (1 << 31);
+ }
+ KeybSetDefaultKey(&(pDevice->sKey),
+ dwKeyIndex & ~(BIT30 | USE_KEYRSC),
+ param->u.wpa_key.key_len,
+ NULL,
+ abyKey,
+ KEY_CTL_WEP,
+ pDevice->PortOffset,
+ pDevice->byLocalID);
+
+ }
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ pDevice->bEncryptionEnable = TRUE;
+ return ret;
+ }
+
+ //spin_unlock_irq(&pDevice->lock);
+ if(param->u.wpa_key.seq && fcpfkernel) {
+ memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len);
+ }
+ else {
+ spin_unlock_irq(&pDevice->lock);
+ if (param->u.wpa_key.seq &&
+ copy_from_user(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len)){
+
+ spin_lock_irq(&pDevice->lock);
+ return -EINVAL;
+ }
+spin_lock_irq(&pDevice->lock);
+}
+
+ if (param->u.wpa_key.seq_len > 0) {
+ for (ii = 0 ; ii < param->u.wpa_key.seq_len ; ii++) {
+ if (ii < 4)
+ LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8));
+ else
+ HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8));
+ //KeyRSC |= (abySeq[ii] << (ii * 8));
+ }
+ dwKeyIndex |= 1 << 29;
+ }
+
+ if (param->u.wpa_key.key_index >= MAX_GROUP_KEY) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "return dwKeyIndex > 3\n");
+ return -EINVAL;
+ }
+
+ if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
+ }
+
+ if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
+ }
+
+ if (param->u.wpa_key.set_tx)
+ dwKeyIndex |= (1 << 31);
+
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)
+ byKeyDecMode = KEY_CTL_CCMP;
+ else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled)
+ byKeyDecMode = KEY_CTL_TKIP;
+ else
+ byKeyDecMode = KEY_CTL_WEP;
+
+ // Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {
+ if (param->u.wpa_key.key_len == MAX_KEY_LEN)
+ byKeyDecMode = KEY_CTL_TKIP;
+ else if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN)
+ byKeyDecMode = KEY_CTL_WEP;
+ else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN)
+ byKeyDecMode = KEY_CTL_WEP;
+ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN)
+ byKeyDecMode = KEY_CTL_WEP;
+ else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN)
+ byKeyDecMode = KEY_CTL_WEP;
+ }
+
+
+ // Check TKIP key length
+ if ((byKeyDecMode == KEY_CTL_TKIP) &&
+ (param->u.wpa_key.key_len != MAX_KEY_LEN)) {
+ // TKIP Key must be 256 bits
+ //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - TKIP Key must be 256 bits\n"));
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "return- TKIP Key must be 256 bits!\n");
+ return -EINVAL;
+ }
+ // Check AES key length
+ if ((byKeyDecMode == KEY_CTL_CCMP) &&
+ (param->u.wpa_key.key_len != AES_KEY_LEN)) {
+ // AES Key must be 128 bits
+ //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - AES Key must be 128 bits\n"));
+ return -EINVAL;
+ }
+
+ // spin_lock_irq(&pDevice->lock);
+ if (IS_BROADCAST_ADDRESS(&param->addr[0]) || (param->addr == NULL)) {
+ // If IS_BROADCAST_ADDRESS, set the key as every key entry's group key.
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n");
+
+ if ((KeybSetAllGroupKey(&(pDevice->sKey),
+ dwKeyIndex,
+ param->u.wpa_key.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode,
+ pDevice->PortOffset,
+ pDevice->byLocalID) == TRUE) &&
+ (KeybSetDefaultKey(&(pDevice->sKey),
+ dwKeyIndex,
+ param->u.wpa_key.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode,
+ pDevice->PortOffset,
+ pDevice->byLocalID) == TRUE) ) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n");
+
+ } else {
+ //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n"));
+ // spin_unlock_irq(&pDevice->lock);
+ return -EINVAL;
+ }
+
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Assign.\n");
+ // BSSID not 0xffffffffffff
+ // Pairwise Key can't be WEP
+ if (byKeyDecMode == KEY_CTL_WEP) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key can't be WEP\n");
+ //spin_unlock_irq(&pDevice->lock);
+ return -EINVAL;
+ }
+
+ dwKeyIndex |= (1 << 30); // set pairwise key
+ if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
+ //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n"));
+ //spin_unlock_irq(&pDevice->lock);
+ return -EINVAL;
+ }
+ if (KeybSetKey(&(pDevice->sKey),
+ &param->addr[0],
+ dwKeyIndex,
+ param->u.wpa_key.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode,
+ pDevice->PortOffset,
+ pDevice->byLocalID) == TRUE) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Set\n");
+
+ } else {
+ // Key Table Full
+ if (IS_ETH_ADDRESS_EQUAL(&param->addr[0], pDevice->abyBSSID)) {
+ //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
+ //spin_unlock_irq(&pDevice->lock);
+ return -EINVAL;
+
+ } else {
+ // Save Key and configure just before associate/reassociate to BSSID
+ // we do not implement now
+ //spin_unlock_irq(&pDevice->lock);
+ return -EINVAL;
+ }
+ }
+ } // BSSID not 0xffffffffffff
+ if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) {
+ pDevice->byKeyIndex = (BYTE)param->u.wpa_key.key_index;
+ pDevice->bTransmitKey = TRUE;
+ }
+ pDevice->bEncryptionEnable = TRUE;
+ //spin_unlock_irq(&pDevice->lock);
+
+/*
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n",
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][0],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][1],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][2],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][3],
+ pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][4]
+ );
+*/
+
+ return ret;
+
+}
+
+
+/*
+ * Description:
+ * enable wpa auth & mode
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_set_wpa(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int ret = 0;
+
+ pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
+ pMgmt->bShareKeyAlgorithm = FALSE;
+
+ return ret;
+}
+
+
+
+
+ /*
+ * Description:
+ * set disassociate
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_set_disassociate(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int ret = 0;
+
+ spin_lock_irq(&pDevice->lock);
+ if (pDevice->bLinkPass) {
+ if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6))
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+ }
+ spin_unlock_irq(&pDevice->lock);
+
+ return ret;
+}
+
+
+
+/*
+ * Description:
+ * enable scan process
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_set_scan(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+ int ret = 0;
+
+ spin_lock_irq(&pDevice->lock);
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ spin_unlock_irq(&pDevice->lock);
+
+ return ret;
+}
+
+
+
+/*
+ * Description:
+ * get bssid
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_get_bssid(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ int ret = 0;
+
+ memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6);
+
+ return ret;
+
+}
+
+
+/*
+ * Description:
+ * get bssid
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_get_ssid(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PWLAN_IE_SSID pItemSSID;
+ int ret = 0;
+
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+
+ memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len);
+ param->u.wpa_associate.ssid_len = pItemSSID->len;
+
+ return ret;
+}
+
+
+
+/*
+ * Description:
+ * get scan results
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_get_scan(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+ struct viawget_scan_result *scan_buf;
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PWLAN_IE_SSID pItemSSID;
+ PKnownBSS pBSS;
+ PBYTE pBuf;
+ int ret = 0;
+ u16 count = 0;
+ u16 ii, jj;
+#if 1
+
+ PBYTE ptempBSS;
+
+
+
+ ptempBSS = kmalloc(sizeof(KnownBSS), (int)GFP_ATOMIC);
+
+ if (ptempBSS == NULL) {
+
+ printk("bubble sort kmalloc memory fail@@@\n");
+
+ ret = -ENOMEM;
+
+ return ret;
+
+ }
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+
+ for(jj=0;jj<MAX_BSS_NUM-ii-1;jj++) {
+
+ if((pMgmt->sBSSList[jj].bActive!=TRUE) ||
+
+ ((pMgmt->sBSSList[jj].uRSSI>pMgmt->sBSSList[jj+1].uRSSI) &&(pMgmt->sBSSList[jj+1].bActive!=FALSE))) {
+
+ memcpy(ptempBSS,&pMgmt->sBSSList[jj],sizeof(KnownBSS));
+
+ memcpy(&pMgmt->sBSSList[jj],&pMgmt->sBSSList[jj+1],sizeof(KnownBSS));
+
+ memcpy(&pMgmt->sBSSList[jj+1],ptempBSS,sizeof(KnownBSS));
+
+ }
+
+ }
+
+ };
+
+ kfree(ptempBSS);
+
+ // printk("bubble sort result:\n");
+
+ //for (ii = 0; ii < MAX_BSS_NUM; ii++)
+
+ // printk("%d [%s]:RSSI=%d\n",ii,((PWLAN_IE_SSID)(pMgmt->sBSSList[ii].abySSID))->abySSID,
+
+ // pMgmt->sBSSList[ii].uRSSI);
+
+ #endif
+
+//******mike:bubble sort by stronger RSSI*****//
+
+
+
+
+ count = 0;
+ pBSS = &(pMgmt->sBSSList[0]);
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pBSS = &(pMgmt->sBSSList[ii]);
+ if (!pBSS->bActive)
+ continue;
+ count++;
+ };
+
+ pBuf = kmalloc(sizeof(struct viawget_scan_result) * count, (int)GFP_ATOMIC);
+
+ if (pBuf == NULL) {
+ ret = -ENOMEM;
+ return ret;
+ }
+ memset(pBuf, 0, sizeof(struct viawget_scan_result) * count);
+ scan_buf = (struct viawget_scan_result *)pBuf;
+ pBSS = &(pMgmt->sBSSList[0]);
+ for (ii = 0, jj = 0; ii < MAX_BSS_NUM ; ii++) {
+ pBSS = &(pMgmt->sBSSList[ii]);
+ if (pBSS->bActive) {
+ if (jj >= count)
+ break;
+ memcpy(scan_buf->bssid, pBSS->abyBSSID, WLAN_BSSID_LEN);
+ pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
+ memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len);
+ scan_buf->ssid_len = pItemSSID->len;
+ scan_buf->freq = frequency_list[pBSS->uChannel-1];
+ scan_buf->caps = pBSS->wCapInfo;
+ //scan_buf->caps = pBSS->wCapInfo;
+ //scan_buf->qual =
+ //scan_buf->noise =
+ //scan_buf->level =
+ //scan_buf->maxrate =
+ if (pBSS->wWPALen != 0) {
+ scan_buf->wpa_ie_len = pBSS->wWPALen;
+ memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen);
+ }
+ if (pBSS->wRSNLen != 0) {
+ scan_buf->rsn_ie_len = pBSS->wRSNLen;
+ memcpy(scan_buf->rsn_ie, pBSS->byRSNIE, pBSS->wRSNLen);
+ }
+ scan_buf = (struct viawget_scan_result *)((PBYTE)scan_buf + sizeof(struct viawget_scan_result));
+ jj ++;
+ }
+ }
+
+ if (jj < count)
+ count = jj;
+
+ if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) {
+ ret = -EFAULT;
+ };
+ param->u.scan_results.scan_count = count;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count)
+
+ kfree(pBuf);
+ return ret;
+}
+
+
+
+/*
+ * Description:
+ * set associate with AP
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * param -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+static int wpa_set_associate(PSDevice pDevice,
+ struct viawget_wpa_param *param)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PWLAN_IE_SSID pItemSSID;
+ BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ BYTE abyWPAIE[64];
+ int ret = 0;
+ BOOL bWepEnabled=FALSE;
+
+ // set key type & algorithm
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise_suite = %d\n", param->u.wpa_associate.pairwise_suite);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "group_suite = %d\n", param->u.wpa_associate.group_suite);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key_mgmt_suite = %d\n", param->u.wpa_associate.key_mgmt_suite);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "auth_alg = %d\n", param->u.wpa_associate.auth_alg);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "mode = %d\n", param->u.wpa_associate.mode);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len);
+
+
+ if (param->u.wpa_associate.wpa_ie &&
+ copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, param->u.wpa_associate.wpa_ie_len))
+ return -EINVAL;
+
+ if (param->u.wpa_associate.mode == 1)
+ pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
+ else
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ // set ssid
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pItemSSID->byElementID = WLAN_EID_SSID;
+ pItemSSID->len = param->u.wpa_associate.ssid_len;
+ memcpy(pItemSSID->abySSID, param->u.wpa_associate.ssid, pItemSSID->len);
+ // set bssid
+ if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0)
+ memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6);
+else
+{
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID);
+}
+
+ if (param->u.wpa_associate.wpa_ie_len == 0) {
+ if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY)
+ pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY;
+ else
+ pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
+ } else if (abyWPAIE[0] == RSN_INFO_ELEM) {
+ if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK)
+ pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
+ else
+ pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
+ } else {
+ if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_WPA_NONE)
+ pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
+ else if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK)
+ pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
+ else
+ pMgmt->eAuthenMode = WMAC_AUTH_WPA;
+ }
+
+ switch (param->u.wpa_associate.pairwise_suite) {
+ case CIPHER_CCMP:
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
+ break;
+ case CIPHER_TKIP:
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
+ break;
+ case CIPHER_WEP40:
+ case CIPHER_WEP104:
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ bWepEnabled=TRUE;
+ break;
+ case CIPHER_NONE:
+ if (param->u.wpa_associate.group_suite == CIPHER_CCMP)
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
+ else
+ pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
+ break;
+ default:
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ };
+
+//DavidWang add for WPA_supplicant support open/share mode
+
+ if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ //pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY;
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ }
+ else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) {
+ if(!bWepEnabled) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ //pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
+ //pMgmt->bShareKeyAlgorithm = FALSE; //20080717-06,<Modify> by chester//Fix Open mode, WEP encrytion
+ }
+//mike save old encryption status
+ pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus;
+
+ if (pDevice->eEncryptionStatus != Ndis802_11EncryptionDisabled)
+ pDevice->bEncryptionEnable = TRUE;
+ else
+ pDevice->bEncryptionEnable = FALSE;
+if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) ||
+ ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && (bWepEnabled==TRUE))) ) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP
+ KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
+ spin_lock_irq(&pDevice->lock);
+ pDevice->bLinkPass = FALSE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ netif_stop_queue(pDevice->dev);
+ //20080701-02,<Add> by Mike Liu
+/*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
+{
+ PKnownBSS pCurr = NULL;
+ pCurr = BSSpSearchBSSList(pDevice,
+ pMgmt->abyDesireBSSID,
+ pMgmt->abyDesireSSID,
+ pMgmt->eConfigPHYMode
+ );
+
+ if (pCurr == NULL){
+ printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ };
+}
+/****************************************************************/
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+ spin_unlock_irq(&pDevice->lock);
+
+ return ret;
+}
+
+
+/*
+ * Description:
+ * wpa_ioctl main function supported for wpa supplicant
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * iw_point -
+ * Out:
+ *
+ * Return Value:
+ *
+ */
+
+int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
+{
+ struct viawget_wpa_param *param;
+ int ret = 0;
+ int wpa_ioctl = 0;
+
+ if (p->length < sizeof(struct viawget_wpa_param) ||
+ p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer)
+ return -EINVAL;
+
+ param = (struct viawget_wpa_param *) kmalloc((int)p->length, (int)GFP_KERNEL);
+ if (param == NULL)
+ return -ENOMEM;
+
+ if (copy_from_user(param, p->pointer, p->length)) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ switch (param->cmd) {
+ case VIAWGET_SET_WPA:
+ ret = wpa_set_wpa(pDevice, param);
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_WPA \n");
+ break;
+
+ case VIAWGET_SET_KEY:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_KEY \n");
+ spin_lock_irq(&pDevice->lock);
+ ret = wpa_set_keys(pDevice, param, FALSE);
+ spin_unlock_irq(&pDevice->lock);
+ break;
+
+ case VIAWGET_SET_SCAN:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_SCAN \n");
+ ret = wpa_set_scan(pDevice, param);
+ break;
+
+ case VIAWGET_GET_SCAN:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_SCAN\n");
+ ret = wpa_get_scan(pDevice, param);
+ wpa_ioctl = 1;
+ break;
+
+ case VIAWGET_GET_SSID:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_SSID \n");
+ ret = wpa_get_ssid(pDevice, param);
+ wpa_ioctl = 1;
+ break;
+
+ case VIAWGET_GET_BSSID:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_BSSID \n");
+ ret = wpa_get_bssid(pDevice, param);
+ wpa_ioctl = 1;
+ break;
+
+ case VIAWGET_SET_ASSOCIATE:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_ASSOCIATE \n");
+ ret = wpa_set_associate(pDevice, param);
+ break;
+
+ case VIAWGET_SET_DISASSOCIATE:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DISASSOCIATE \n");
+ ret = wpa_set_disassociate(pDevice, param);
+ break;
+
+ case VIAWGET_SET_DROP_UNENCRYPT:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DROP_UNENCRYPT \n");
+ break;
+
+ case VIAWGET_SET_DEAUTHENTICATE:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DEAUTHENTICATE \n");
+ break;
+
+ default:
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ioctl: unknown cmd=%d\n",
+ param->cmd);
+ return -EOPNOTSUPP;
+ break;
+ }
+
+ if ((ret == 0) && wpa_ioctl) {
+ if (copy_to_user(p->pointer, param, p->length)) {
+ ret = -EFAULT;
+ goto out;
+ }
+ }
+
+out:
+ if (param != NULL)
+ kfree(param);
+
+ return ret;
+}
+
diff --git a/drivers/staging/vt6655/wpactl.h b/drivers/staging/vt6655/wpactl.h
new file mode 100644
index 000000000000..9e7889785306
--- /dev/null
+++ b/drivers/staging/vt6655/wpactl.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wpactl.h
+ *
+ * Purpose:
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: March 1, 2005
+ *
+ */
+
+
+#ifndef __WPACTL_H__
+#define __WPACTL_H__
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+//WPA related
+
+typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg;
+typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
+ CIPHER_WEP104 } wpa_cipher;
+typedef enum { KEY_MGMT_802_1X, KEY_MGMT_CCKM,KEY_MGMT_PSK, KEY_MGMT_NONE,
+ KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt;
+
+#define AUTH_ALG_OPEN_SYSTEM 0x01
+#define AUTH_ALG_SHARED_KEY 0x02
+#define AUTH_ALG_LEAP 0x04
+
+#define GENERIC_INFO_ELEM 0xdd
+#define RSN_INFO_ELEM 0x30
+
+
+
+typedef ULONGLONG NDIS_802_11_KEY_RSC;
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+int wpa_set_wpadev(PSDevice pDevice, int val);
+int wpa_ioctl(PSDevice pDevice, struct iw_point *p);
+int wpa_set_keys(PSDevice pDevice, void *ctx, BOOL fcpfkernel);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __WPACL_H__
+
+
+
diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c
new file mode 100644
index 000000000000..219ae21654e2
--- /dev/null
+++ b/drivers/staging/vt6655/wroute.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wroute.c
+ *
+ * Purpose: handle WMAC frame relay & filterring
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 20, 2003
+ *
+ * Functions:
+ * ROUTEbRelay - Relay packet
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__TCRC_H__)
+#include "tcrc.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__WROUTE_H__)
+#include "wroute.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+
+/*
+ * Description:
+ * Relay packet. Return TRUE if packet is copy to DMA1
+ *
+ * Parameters:
+ * In:
+ * pDevice -
+ * pbySkbData - rx packet skb data
+ * Out:
+ * TURE, FALSE
+ *
+ * Return Value: TRUE if packet duplicate; otherwise FALSE
+ *
+ */
+BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex)
+{
+ PSMgmtObject pMgmt = pDevice->pMgmt;
+ PSTxDesc pHeadTD, pLastTD;
+ UINT cbFrameBodySize;
+ UINT uMACfragNum;
+ BYTE byPktTyp;
+ BOOL bNeedEncryption = FALSE;
+ SKeyItem STempKey;
+ PSKeyItem pTransmitKey = NULL;
+ UINT cbHeaderSize;
+ UINT ii;
+ PBYTE pbyBSSID;
+
+
+
+
+ if (AVAIL_TD(pDevice, TYPE_AC0DMA)<=0) {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Relay can't allocate TD1..\n");
+ return FALSE;
+ }
+
+ pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
+
+ pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
+
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, U_HEADER_LEN);
+
+ cbFrameBodySize = uDataLen - U_HEADER_LEN;
+
+ if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
+ cbFrameBodySize += 8;
+ }
+
+ if (pDevice->bEncryptionEnable == TRUE) {
+ bNeedEncryption = TRUE;
+
+ // get group key
+ pbyBSSID = pDevice->abyBroadcastAddr;
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) {
+ pTransmitKey = NULL;
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode);
+ } else {
+ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
+ }
+ }
+
+ if (pDevice->bEnableHostWEP) {
+ if (uNodeIndex >= 0) {
+ pTransmitKey = &STempKey;
+ pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
+ pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
+ pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
+ pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
+ pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
+ memcpy(pTransmitKey->abyKey,
+ &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
+ pTransmitKey->uKeyLength
+ );
+ }
+ }
+
+ uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
+
+ if (uMACfragNum > AVAIL_TD(pDevice,TYPE_AC0DMA)) {
+ return FALSE;
+ }
+ byPktTyp = (BYTE)pDevice->byPacketType;
+
+ if (pDevice->bFixRate) {
+ if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
+ if (pDevice->uConnectionRate >= RATE_11M) {
+ pDevice->wCurrentRate = RATE_11M;
+ } else {
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ } else {
+ if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
+ (pDevice->uConnectionRate <= RATE_6M)) {
+ pDevice->wCurrentRate = RATE_6M;
+ } else {
+ if (pDevice->uConnectionRate >= RATE_54M)
+ pDevice->wCurrentRate = RATE_54M;
+ else
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ }
+ }
+ else {
+ pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
+ }
+
+ if (pDevice->wCurrentRate <= RATE_11M)
+ byPktTyp = PK_TYPE_11B;
+
+ vGenerateFIFOHeader(pDevice, byPktTyp, pDevice->pbyTmpBuff, bNeedEncryption,
+ cbFrameBodySize, TYPE_AC0DMA, pHeadTD,
+ &pDevice->sTxEthHeader, pbySkbData, pTransmitKey, uNodeIndex,
+ &uMACfragNum,
+ &cbHeaderSize
+ );
+
+ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
+ // Disable PS
+ MACbPSWakeup(pDevice->PortOffset);
+ }
+
+ pDevice->bPWBitOn = FALSE;
+
+ pLastTD = pHeadTD;
+ for (ii = 0; ii < uMACfragNum; ii++) {
+ // Poll Transmit the adapter
+ wmb();
+ pHeadTD->m_td0TD0.f1Owner=OWNED_BY_NIC;
+ wmb();
+ if (ii == (uMACfragNum - 1))
+ pLastTD = pHeadTD;
+ pHeadTD = pHeadTD->next;
+ }
+
+ pLastTD->pTDInfo->skb = 0;
+ pLastTD->pTDInfo->byFlags = 0;
+
+ pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
+
+ MACvTransmitAC0(pDevice->PortOffset);
+
+ return TRUE;
+}
+
+
+
diff --git a/drivers/staging/vt6655/wroute.h b/drivers/staging/vt6655/wroute.h
new file mode 100644
index 000000000000..ea5f5896e9ba
--- /dev/null
+++ b/drivers/staging/vt6655/wroute.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * File: wroute.h
+ *
+ * Purpose:
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: May 21, 2003
+ *
+ */
+
+
+#ifndef __WROUTE_H__
+#define __WROUTE_H__
+
+
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __WROUTE_H__
+
+
+
diff --git a/drivers/staging/winbond/Makefile b/drivers/staging/winbond/Makefile
index b49c9730eddf..fb2b7d432b43 100644
--- a/drivers/staging/winbond/Makefile
+++ b/drivers/staging/winbond/Makefile
@@ -7,7 +7,6 @@ w35und-objs := \
wb35reg.o \
wb35rx.o \
wb35tx.o \
- wbhal.o \
wbusb.o \
diff --git a/drivers/staging/winbond/mds.c b/drivers/staging/winbond/mds.c
index c7af09257e6f..59d6d67a9f7e 100644
--- a/drivers/staging/winbond/mds.c
+++ b/drivers/staging/winbond/mds.c
@@ -432,7 +432,7 @@ Mds_Tx(struct wbsoft_priv * adapter)
return;
//Only one thread can be run here
- if (!atomic_inc_return(&pMds->TxThreadCount) == 1)
+ if (atomic_inc_return(&pMds->TxThreadCount) != 1)
goto cleanup;
// Start to fill the data
diff --git a/drivers/staging/winbond/mto.c b/drivers/staging/winbond/mto.c
index 94a060bcc628..7deb5c769763 100644
--- a/drivers/staging/winbond/mto.c
+++ b/drivers/staging/winbond/mto.c
@@ -175,7 +175,7 @@ void MTO_Init(struct wbsoft_priv *adapter)
}
else //follow the setting from EEPROM
MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM;
- hal_set_rf_power(MTO_HAL(), (u8)MTOPARA_TXPOWER_INDEX());
+ RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8)MTOPARA_TXPOWER_INDEX());
//------------------------------------------------
// For RSSI turning 20060808.4 Cancel load from EEPROM
diff --git a/drivers/staging/winbond/phy_calibration.c b/drivers/staging/winbond/phy_calibration.c
index af8c01e313b0..8c56962ab80c 100644
--- a/drivers/staging/winbond/phy_calibration.c
+++ b/drivers/staging/winbond/phy_calibration.c
@@ -340,6 +340,25 @@ void _sin_cos(s32 angle, s32 *sin, s32 *cos)
}
}
+static unsigned char hal_get_dxx_reg(struct hw_data *pHwData, u16 number, u32 * pValue)
+{
+ if (number < 0x1000)
+ number += 0x1000;
+ return Wb35Reg_ReadSync(pHwData, number, pValue);
+}
+#define hw_get_dxx_reg( _A, _B, _C ) hal_get_dxx_reg( _A, _B, (u32 *)_C )
+
+static unsigned char hal_set_dxx_reg(struct hw_data *pHwData, u16 number, u32 value)
+{
+ unsigned char ret;
+
+ if (number < 0x1000)
+ number += 0x1000;
+ ret = Wb35Reg_WriteSync(pHwData, number, value);
+ return ret;
+}
+#define hw_set_dxx_reg( _A, _B, _C ) hal_set_dxx_reg( _A, _B, (u32)_C )
+
void _reset_rx_cal(struct hw_data *phw_data)
{
diff --git a/drivers/staging/winbond/wbhal.c b/drivers/staging/winbond/wbhal.c
deleted file mode 100644
index c985ad065238..000000000000
--- a/drivers/staging/winbond/wbhal.c
+++ /dev/null
@@ -1,568 +0,0 @@
-#include "sysdef.h"
-#include "wbhal_f.h"
-#include "wblinux_f.h"
-
-void hal_set_ethernet_address( struct hw_data * pHwData, u8 *current_address )
-{
- u32 ltmp[2];
-
- if( pHwData->SurpriseRemove ) return;
-
- memcpy( pHwData->CurrentMacAddress, current_address, ETH_ALEN );
-
- ltmp[0]= cpu_to_le32( *(u32 *)pHwData->CurrentMacAddress );
- ltmp[1]= cpu_to_le32( *(u32 *)(pHwData->CurrentMacAddress + 4) ) & 0xffff;
-
- Wb35Reg_BurstWrite( pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT );
-}
-
-void hal_get_permanent_address( struct hw_data * pHwData, u8 *pethernet_address )
-{
- if( pHwData->SurpriseRemove ) return;
-
- memcpy( pethernet_address, pHwData->PermanentMacAddress, 6 );
-}
-
-static void hal_led_control(unsigned long data)
-{
- struct wbsoft_priv *adapter = (struct wbsoft_priv *) data;
- struct hw_data * pHwData = &adapter->sHwData;
- struct wb35_reg *reg = &pHwData->reg;
- u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT;
- u8 LEDgray[20] = { 0,3,4,6,8,10,11,12,13,14,15,14,13,12,11,10,8,6,4,2 };
- u8 LEDgray2[30] = { 7,8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,15,14,13,12,11,10,9,8 };
- u32 TimeInterval = 500, ltmp, ltmp2;
- ltmp=0;
-
- if( pHwData->SurpriseRemove ) return;
-
- if( pHwData->LED_control ) {
- ltmp2 = pHwData->LED_control & 0xff;
- if( ltmp2 == 5 ) // 5 is WPS mode
- {
- TimeInterval = 100;
- ltmp2 = (pHwData->LED_control>>8) & 0xff;
- switch( ltmp2 )
- {
- case 1: // [0.2 On][0.1 Off]...
- pHwData->LED_Blinking %= 3;
- ltmp = 0x1010; // Led 1 & 0 Green and Red
- if( pHwData->LED_Blinking == 2 ) // Turn off
- ltmp = 0;
- break;
- case 2: // [0.1 On][0.1 Off]...
- pHwData->LED_Blinking %= 2;
- ltmp = 0x0010; // Led 0 red color
- if( pHwData->LED_Blinking ) // Turn off
- ltmp = 0;
- break;
- case 3: // [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]...
- pHwData->LED_Blinking %= 15;
- ltmp = 0x0010; // Led 0 red color
- if( (pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking%2) ) // Turn off 0.6 sec
- ltmp = 0;
- break;
- case 4: // [300 On][ off ]
- ltmp = 0x1000; // Led 1 Green color
- if( pHwData->LED_Blinking >= 3000 )
- ltmp = 0; // led maybe on after 300sec * 32bit counter overlap.
- break;
- }
- pHwData->LED_Blinking++;
-
- reg->U1BC_LEDConfigure = ltmp;
- if( LEDSet != 7 ) // Only 111 mode has 2 LEDs on PCB.
- {
- reg->U1BC_LEDConfigure |= (ltmp &0xff)<<8; // Copy LED result to each LED control register
- reg->U1BC_LEDConfigure |= (ltmp &0xff00)>>8;
- }
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
- }
- }
- else if( pHwData->CurrentRadioSw || pHwData->CurrentRadioHw ) // If radio off
- {
- if( reg->U1BC_LEDConfigure & 0x1010 )
- {
- reg->U1BC_LEDConfigure &= ~0x1010;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
- }
- }
- else
- {
- switch( LEDSet )
- {
- case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
- if( !pHwData->LED_LinkOn ) // Blink only if not Link On
- {
- // Blinking if scanning is on progress
- if( pHwData->LED_Scanning )
- {
- if( pHwData->LED_Blinking == 0 )
- {
- reg->U1BC_LEDConfigure |= 0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
- pHwData->LED_Blinking = 1;
- TimeInterval = 300;
- }
- else
- {
- reg->U1BC_LEDConfigure &= ~0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
- pHwData->LED_Blinking = 0;
- TimeInterval = 300;
- }
- }
- else
- {
- //Turn Off LED_0
- if( reg->U1BC_LEDConfigure & 0x10 )
- {
- reg->U1BC_LEDConfigure &= ~0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
- }
- }
- }
- else
- {
- // Turn On LED_0
- if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
- {
- reg->U1BC_LEDConfigure |= 0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
- }
- }
- break;
-
- case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
- if( !pHwData->LED_LinkOn ) // Blink only if not Link On
- {
- // Blinking if scanning is on progress
- if( pHwData->LED_Scanning )
- {
- if( pHwData->LED_Blinking == 0 )
- {
- reg->U1BC_LEDConfigure &= ~0xf;
- reg->U1BC_LEDConfigure |= 0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
- pHwData->LED_Blinking = 1;
- TimeInterval = 300;
- }
- else
- {
- reg->U1BC_LEDConfigure &= ~0x1f;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
- pHwData->LED_Blinking = 0;
- TimeInterval = 300;
- }
- }
- else
- {
- // 20060901 Gray blinking if in disconnect state and not scanning
- ltmp = reg->U1BC_LEDConfigure;
- reg->U1BC_LEDConfigure &= ~0x1f;
- if( LEDgray2[(pHwData->LED_Blinking%30)] )
- {
- reg->U1BC_LEDConfigure |= 0x10;
- reg->U1BC_LEDConfigure |= LEDgray2[ (pHwData->LED_Blinking%30) ];
- }
- pHwData->LED_Blinking++;
- if( reg->U1BC_LEDConfigure != ltmp )
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
- TimeInterval = 100;
- }
- }
- else
- {
- // Turn On LED_0
- if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
- {
- reg->U1BC_LEDConfigure |= 0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
- }
- }
- break;
-
- case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
- if( !pHwData->LED_LinkOn ) // Blink only if not Link On
- {
- // Blinking if scanning is on progress
- if( pHwData->LED_Scanning )
- {
- if( pHwData->LED_Blinking == 0 )
- {
- reg->U1BC_LEDConfigure |= 0x1000;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
- pHwData->LED_Blinking = 1;
- TimeInterval = 300;
- }
- else
- {
- reg->U1BC_LEDConfigure &= ~0x1000;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
- pHwData->LED_Blinking = 0;
- TimeInterval = 300;
- }
- }
- else
- {
- //Turn Off LED_1
- if( reg->U1BC_LEDConfigure & 0x1000 )
- {
- reg->U1BC_LEDConfigure &= ~0x1000;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
- }
- }
- }
- else
- {
- // Is transmitting/receiving ??
- if( (adapter->RxByteCount != pHwData->RxByteCountLast ) ||
- (adapter->TxByteCount != pHwData->TxByteCountLast ) )
- {
- if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
- {
- reg->U1BC_LEDConfigure |= 0x3000;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
- }
-
- // Update variable
- pHwData->RxByteCountLast = adapter->RxByteCount;
- pHwData->TxByteCountLast = adapter->TxByteCount;
- TimeInterval = 200;
- }
- else
- {
- // Turn On LED_1 and blinking if transmitting/receiving
- if( (reg->U1BC_LEDConfigure & 0x3000) != 0x1000 )
- {
- reg->U1BC_LEDConfigure &= ~0x3000;
- reg->U1BC_LEDConfigure |= 0x1000;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
- }
- }
- }
- break;
-
- default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
- if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
- {
- reg->U1BC_LEDConfigure |= 0x3000;// LED_1 is always on and event enable
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
- }
-
- if( pHwData->LED_Blinking )
- {
- // Gray blinking
- reg->U1BC_LEDConfigure &= ~0x0f;
- reg->U1BC_LEDConfigure |= 0x10;
- reg->U1BC_LEDConfigure |= LEDgray[ (pHwData->LED_Blinking-1)%20 ];
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
-
- pHwData->LED_Blinking += 2;
- if( pHwData->LED_Blinking < 40 )
- TimeInterval = 100;
- else
- {
- pHwData->LED_Blinking = 0; // Stop blinking
- reg->U1BC_LEDConfigure &= ~0x0f;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
- }
- break;
- }
-
- if( pHwData->LED_LinkOn )
- {
- if( !(reg->U1BC_LEDConfigure & 0x10) ) // Check the LED_0
- {
- //Try to turn ON LED_0 after gray blinking
- reg->U1BC_LEDConfigure |= 0x10;
- pHwData->LED_Blinking = 1; //Start blinking
- TimeInterval = 50;
- }
- }
- else
- {
- if( reg->U1BC_LEDConfigure & 0x10 ) // Check the LED_0
- {
- reg->U1BC_LEDConfigure &= ~0x10;
- Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
- }
- }
- break;
- }
-
- //20060828.1 Active send null packet to avoid AP disconnect
- if( pHwData->LED_LinkOn )
- {
- pHwData->NullPacketCount += TimeInterval;
- if( pHwData->NullPacketCount >= DEFAULT_NULL_PACKET_COUNT )
- {
- pHwData->NullPacketCount = 0;
- }
- }
- }
-
- pHwData->time_count += TimeInterval;
- Wb35Tx_CurrentTime(adapter, pHwData->time_count); // 20060928 add
- pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval);
- add_timer(&pHwData->LEDTimer);
-}
-
-u8 hal_init_hardware(struct ieee80211_hw *hw)
-{
- struct wbsoft_priv *priv = hw->priv;
- struct hw_data * pHwData = &priv->sHwData;
- u16 SoftwareSet;
-
- // Initial the variable
- pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME; // Setting Rx maximum MSDU life time
- pHwData->FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; // Setting default fragment threshold
-
- pHwData->InitialResource = 1;
- if( Wb35Reg_initial(pHwData)) {
- pHwData->InitialResource = 2;
- if (Wb35Tx_initial(pHwData)) {
- pHwData->InitialResource = 3;
- if (Wb35Rx_initial(pHwData)) {
- pHwData->InitialResource = 4;
- init_timer(&pHwData->LEDTimer);
- pHwData->LEDTimer.function = hal_led_control;
- pHwData->LEDTimer.data = (unsigned long) priv;
- pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
- add_timer(&pHwData->LEDTimer);
-
- //
- // For restrict to vendor's hardware
- //
- SoftwareSet = hal_software_set( pHwData );
-
- #ifdef Vendor2
- // Try to make sure the EEPROM contain
- SoftwareSet >>= 8;
- if( SoftwareSet != 0x82 )
- return false;
- #endif
-
- Wb35Rx_start(hw);
- Wb35Tx_EP2VM_start(priv);
-
- return true;
- }
- }
- }
-
- pHwData->SurpriseRemove = 1;
- return false;
-}
-
-
-void hal_halt(struct hw_data * pHwData, void *ppa_data)
-{
- switch( pHwData->InitialResource )
- {
- case 4:
- case 3: del_timer_sync(&pHwData->LEDTimer);
- msleep(100); // Wait for Timer DPC exit 940623.2
- Wb35Rx_destroy( pHwData ); // Release the Rx
- case 2: Wb35Tx_destroy( pHwData ); // Release the Tx
- case 1: Wb35Reg_destroy( pHwData ); // Release the Wb35 Regisster resources
- }
-}
-
-//---------------------------------------------------------------------------------------------------
-void hal_set_beacon_period( struct hw_data * pHwData, u16 beacon_period )
-{
- u32 tmp;
-
- if( pHwData->SurpriseRemove ) return;
-
- pHwData->BeaconPeriod = beacon_period;
- tmp = pHwData->BeaconPeriod << 16;
- tmp |= pHwData->ProbeDelay;
- Wb35Reg_Write( pHwData, 0x0848, tmp );
-}
-
-
-static void hal_set_current_channel_ex( struct hw_data * pHwData, ChanInfo channel )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if( pHwData->SurpriseRemove )
- return;
-
- printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
-
- RFSynthesizer_SwitchingChannel( pHwData, channel );// Switch channel
- pHwData->Channel = channel.ChanNo;
- pHwData->band = channel.band;
- #ifdef _PE_STATE_DUMP_
- printk("Set channel is %d, band =%d\n", pHwData->Channel, pHwData->band);
- #endif
- reg->M28_MacControl &= ~0xff; // Clean channel information field
- reg->M28_MacControl |= channel.ChanNo;
- Wb35Reg_WriteWithCallbackValue( pHwData, 0x0828, reg->M28_MacControl,
- (s8 *)&channel, sizeof(ChanInfo));
-}
-//---------------------------------------------------------------------------------------------------
-void hal_set_current_channel( struct hw_data * pHwData, ChanInfo channel )
-{
- hal_set_current_channel_ex( pHwData, channel );
-}
-//---------------------------------------------------------------------------------------------------
-void hal_set_accept_broadcast( struct hw_data * pHwData, u8 enable )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if( pHwData->SurpriseRemove ) return;
-
- reg->M00_MacControl &= ~0x02000000;//The HW value
-
- if (enable)
- reg->M00_MacControl |= 0x02000000;//The HW value
-
- Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
-}
-
-//for wep key error detection, we need to accept broadcast packets to be received temporary.
-void hal_set_accept_promiscuous( struct hw_data * pHwData, u8 enable)
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if (pHwData->SurpriseRemove) return;
- if (enable) {
- reg->M00_MacControl |= 0x00400000;
- Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
- } else {
- reg->M00_MacControl&=~0x00400000;
- Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
- }
-}
-
-void hal_set_accept_multicast( struct hw_data * pHwData, u8 enable )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if( pHwData->SurpriseRemove ) return;
-
- reg->M00_MacControl &= ~0x01000000;//The HW value
- if (enable) reg->M00_MacControl |= 0x01000000;//The HW value
- Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
-}
-
-void hal_set_accept_beacon( struct hw_data * pHwData, u8 enable )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if( pHwData->SurpriseRemove ) return;
-
- // 20040108 debug
- if( !enable )//Due to SME and MLME are not suitable for 35
- return;
-
- reg->M00_MacControl &= ~0x04000000;//The HW value
- if( enable )
- reg->M00_MacControl |= 0x04000000;//The HW value
-
- Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
-}
-//---------------------------------------------------------------------------------------------------
-
-void hal_stop( struct hw_data * pHwData )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- pHwData->Wb35Rx.rx_halt = 1;
- Wb35Rx_stop( pHwData );
-
- pHwData->Wb35Tx.tx_halt = 1;
- Wb35Tx_stop( pHwData );
-
- reg->D00_DmaControl &= ~0xc0000000;//Tx Off, Rx Off
- Wb35Reg_Write( pHwData, 0x0400, reg->D00_DmaControl );
-}
-
-unsigned char hal_idle(struct hw_data * pHwData)
-{
- struct wb35_reg *reg = &pHwData->reg;
- struct wb_usb *pWbUsb = &pHwData->WbUsb;
-
- if( !pHwData->SurpriseRemove && ( pWbUsb->DetectCount || reg->EP0vm_state!=VM_STOP ) )
- return false;
-
- return true;
-}
-//---------------------------------------------------------------------------------------------------
-void hal_set_phy_type( struct hw_data * pHwData, u8 PhyType )
-{
- pHwData->phy_type = PhyType;
-}
-
-void hal_set_radio_mode( struct hw_data * pHwData, unsigned char radio_off)
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if( pHwData->SurpriseRemove ) return;
-
- if (radio_off) //disable Baseband receive off
- {
- pHwData->CurrentRadioSw = 1; // off
- reg->M24_MacControl &= 0xffffffbf;
- }
- else
- {
- pHwData->CurrentRadioSw = 0; // on
- reg->M24_MacControl |= 0x00000040;
- }
- Wb35Reg_Write( pHwData, 0x0824, reg->M24_MacControl );
-}
-
-u8 hal_get_antenna_number( struct hw_data * pHwData )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if ((reg->BB2C & BIT(11)) == 0)
- return 0;
- else
- return 1;
-}
-
-//----------------------------------------------------------------------------------------------------
-//0 : radio on; 1: radio off
-u8 hal_get_hw_radio_off( struct hw_data * pHwData )
-{
- struct wb35_reg *reg = &pHwData->reg;
-
- if( pHwData->SurpriseRemove ) return 1;
-
- //read the bit16 of register U1B0
- Wb35Reg_Read( pHwData, 0x3b0, &reg->U1B0 );
- if ((reg->U1B0 & 0x00010000)) {
- pHwData->CurrentRadioHw = 1;
- return 1;
- } else {
- pHwData->CurrentRadioHw = 0;
- return 0;
- }
-}
-
-unsigned char hal_get_dxx_reg( struct hw_data * pHwData, u16 number, u32 * pValue )
-{
- if( number < 0x1000 )
- number += 0x1000;
- return Wb35Reg_ReadSync( pHwData, number, pValue );
-}
-
-unsigned char hal_set_dxx_reg( struct hw_data * pHwData, u16 number, u32 value )
-{
- unsigned char ret;
-
- if( number < 0x1000 )
- number += 0x1000;
- ret = Wb35Reg_WriteSync( pHwData, number, value );
- return ret;
-}
-
-void hal_set_rf_power(struct hw_data * pHwData, u8 PowerIndex)
-{
- RFSynthesizer_SetPowerIndex( pHwData, PowerIndex );
-}
diff --git a/drivers/staging/winbond/wbhal_f.h b/drivers/staging/winbond/wbhal_f.h
index efcaefb6aa59..bfdf05d489f0 100644
--- a/drivers/staging/winbond/wbhal_f.h
+++ b/drivers/staging/winbond/wbhal_f.h
@@ -18,10 +18,6 @@ void hal_clear_all_default_key( struct hw_data * pHwData );
void hal_clear_all_group_key( struct hw_data * pHwData );
void hal_clear_all_mapping_key( struct hw_data * pHwData );
void hal_clear_all_key( struct hw_data * pHwData );
-void hal_get_ethernet_address( struct hw_data * pHwData, u8 *current_address );
-void hal_set_ethernet_address( struct hw_data * pHwData, u8 *current_address );
-void hal_get_permanent_address( struct hw_data * pHwData, u8 *pethernet_address );
-u8 hal_init_hardware(struct ieee80211_hw *hw);
void hal_set_power_save_mode( struct hw_data * pHwData, unsigned char power_save, unsigned char wakeup, unsigned char dtim );
void hal_get_power_save_mode( struct hw_data * pHwData, u8 *pin_pwr_save );
void hal_set_slot_time( struct hw_data * pHwData, u8 type );
@@ -33,33 +29,21 @@ void hal_resume_sync_bss( struct hw_data * pHwData);
void hal_set_aid( struct hw_data * pHwData, u16 aid );
void hal_set_bssid( struct hw_data * pHwData, u8 *pbssid );
void hal_get_bssid( struct hw_data * pHwData, u8 *pbssid );
-void hal_set_beacon_period( struct hw_data * pHwData, u16 beacon_period );
void hal_set_listen_interval( struct hw_data * pHwData, u16 listen_interval );
void hal_set_cap_info( struct hw_data * pHwData, u16 capability_info );
void hal_set_ssid( struct hw_data * pHwData, u8 *pssid, u8 ssid_len );
-void hal_set_current_channel( struct hw_data * pHwData, ChanInfo channel );
-void hal_set_accept_broadcast( struct hw_data * pHwData, u8 enable );
-void hal_set_accept_multicast( struct hw_data * pHwData, u8 enable );
-void hal_set_accept_beacon( struct hw_data * pHwData, u8 enable );
-void hal_stop( struct hw_data * pHwData );
-void hal_halt( struct hw_data * pHwData, void *ppa_data );
void hal_start_tx0( struct hw_data * pHwData );
-void hal_set_phy_type( struct hw_data * pHwData, u8 PhyType );
#define hal_get_cwmin( _A ) ( (_A)->cwmin )
void hal_set_cwmax( struct hw_data * pHwData, u16 cwin_max );
#define hal_get_cwmax( _A ) ( (_A)->cwmax )
void hal_set_rsn_wpa( struct hw_data * pHwData, u32 * RSN_IE_Bitmap , u32 * RSN_OUI_type , unsigned char bDesiredAuthMode);
void hal_set_connect_info( struct hw_data * pHwData, unsigned char boConnect );
u8 hal_get_est_sq3( struct hw_data * pHwData, u8 Count );
-void hal_set_rf_power( struct hw_data * pHwData, u8 PowerIndex ); // 20060621 Modify
-void hal_set_radio_mode( struct hw_data * pHwData, unsigned char boValue);
void hal_descriptor_indicate( struct hw_data * pHwData, PDESCRIPTOR pDes );
u8 hal_get_antenna_number( struct hw_data * pHwData );
u32 hal_get_bss_pk_cnt( struct hw_data * pHwData );
#define hal_get_region_from_EEPROM( _A ) ( (_A)->reg.EEPROMRegion )
-void hal_set_accept_promiscuous ( struct hw_data * pHwData, u8 enable);
#define hal_get_tx_buffer( _A, _B ) Wb35Tx_get_tx_buffer( _A, _B )
-u8 hal_get_hw_radio_off ( struct hw_data * pHwData );
#define hal_software_set( _A ) (_A->SoftwareSet)
#define hal_driver_init_OK( _A ) (_A->IsInitOK)
#define hal_rssi_boundary_high( _A ) (_A->RSSI_high)
@@ -68,8 +52,6 @@ u8 hal_get_hw_radio_off ( struct hw_data * pHwData );
#define PHY_DEBUG( msg, args... )
-unsigned char hal_get_dxx_reg( struct hw_data * pHwData, u16 number, u32 * pValue );
-unsigned char hal_set_dxx_reg( struct hw_data * pHwData, u16 number, u32 value );
#define hal_get_time_count( _P ) (_P->time_count/10) // return 100ms count
#define hal_detect_error( _P ) (_P->WbUsb.DetectCount)
@@ -82,10 +64,7 @@ unsigned char hal_set_dxx_reg( struct hw_data * pHwData, u16 number, u32 valu
#define hal_get_clear_interrupt(_A)
#define hal_ibss_disconnect(_A) hal_stop_sync_bss(_A)
#define hal_join_request_stop(_A)
-unsigned char hal_idle( struct hw_data * pHwData );
#define hw_get_cxx_reg( _A, _B, _C )
#define hw_set_cxx_reg( _A, _B, _C )
-#define hw_get_dxx_reg( _A, _B, _C ) hal_get_dxx_reg( _A, _B, (u32 *)_C )
-#define hw_set_dxx_reg( _A, _B, _C ) hal_set_dxx_reg( _A, _B, (u32)_C )
diff --git a/drivers/staging/winbond/wbhal_s.h b/drivers/staging/winbond/wbhal_s.h
index acfebf05d9d7..16d0e6f83113 100644
--- a/drivers/staging/winbond/wbhal_s.h
+++ b/drivers/staging/winbond/wbhal_s.h
@@ -401,7 +401,6 @@ struct hw_data {
// For surprise remove
u32 SurpriseRemove; // 0: Normal 1: Surprise remove
- u8 InitialResource;
u8 IsKeyPreSet;
u8 CalOneTime; // 20060630.1
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index 3b2d52819b4c..745279c528a2 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -2,6 +2,12 @@
* Copyright 2008 Pavel Machek <pavel@suse.cz>
*
* Distribute under GPLv2.
+ *
+ * The original driver was written by:
+ * Jeff Lee <YY_Lee@issc.com.tw>
+ *
+ * and was adapted to the 2.6 kernel by:
+ * Costantino Leandro (Rxart Desktop) <le_costantino@pixartargentina.com.ar>
*/
#include <net/mac80211.h>
#include <linux/usb.h>
@@ -13,19 +19,18 @@
#include "wbhal_f.h"
#include "wblinux_f.h"
-MODULE_AUTHOR("Original by: Jeff Lee<YY_Lee@issc.com.tw> Adapted to 2.6.x by Costantino Leandro (Rxart Desktop) <le_costantino@pixartargentina.com.ar>");
MODULE_DESCRIPTION("IS89C35 802.11bg WLAN USB Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("0.1");
static struct usb_device_id wb35_table[] __devinitdata = {
- {USB_DEVICE(0x0416, 0x0035)},
- {USB_DEVICE(0x18E8, 0x6201)},
- {USB_DEVICE(0x18E8, 0x6206)},
- {USB_DEVICE(0x18E8, 0x6217)},
- {USB_DEVICE(0x18E8, 0x6230)},
- {USB_DEVICE(0x18E8, 0x6233)},
- {USB_DEVICE(0x1131, 0x2035)},
+ { USB_DEVICE(0x0416, 0x0035) },
+ { USB_DEVICE(0x18E8, 0x6201) },
+ { USB_DEVICE(0x18E8, 0x6206) },
+ { USB_DEVICE(0x18E8, 0x6217) },
+ { USB_DEVICE(0x18E8, 0x6230) },
+ { USB_DEVICE(0x18E8, 0x6233) },
+ { USB_DEVICE(0x1131, 0x2035) },
{ 0, }
};
@@ -36,7 +41,7 @@ static struct ieee80211_rate wbsoft_rates[] = {
};
static struct ieee80211_channel wbsoft_channels[] = {
- { .center_freq = 2412},
+ { .center_freq = 2412 },
};
static struct ieee80211_supported_band wbsoft_band_2GHz = {
@@ -47,14 +52,14 @@ static struct ieee80211_supported_band wbsoft_band_2GHz = {
};
static int wbsoft_add_interface(struct ieee80211_hw *dev,
- struct ieee80211_if_init_conf *conf)
+ struct ieee80211_if_init_conf *conf)
{
printk("wbsoft_add interface called\n");
return 0;
}
static void wbsoft_remove_interface(struct ieee80211_hw *dev,
- struct ieee80211_if_init_conf *conf)
+ struct ieee80211_if_init_conf *conf)
{
printk("wbsoft_remove interface called\n");
}
@@ -79,36 +84,18 @@ static int wbsoft_get_tx_stats(struct ieee80211_hw *hw,
}
static void wbsoft_configure_filter(struct ieee80211_hw *dev,
- unsigned int changed_flags,
- unsigned int *total_flags,
- int mc_count, struct dev_mc_list *mclist)
+ unsigned int changed_flags,
+ unsigned int *total_flags,
+ int mc_count, struct dev_mc_list *mclist)
{
- unsigned int bit_nr, new_flags;
- u32 mc_filter[2];
- int i;
+ unsigned int new_flags;
new_flags = 0;
- if (*total_flags & FIF_PROMISC_IN_BSS) {
+ if (*total_flags & FIF_PROMISC_IN_BSS)
new_flags |= FIF_PROMISC_IN_BSS;
- mc_filter[1] = mc_filter[0] = ~0;
- } else if ((*total_flags & FIF_ALLMULTI) || (mc_count > 32)) {
+ else if ((*total_flags & FIF_ALLMULTI) || (mc_count > 32))
new_flags |= FIF_ALLMULTI;
- mc_filter[1] = mc_filter[0] = ~0;
- } else {
- mc_filter[1] = mc_filter[0] = 0;
- for (i = 0; i < mc_count; i++) {
- if (!mclist)
- break;
- printk("Should call ether_crc here\n");
- //bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
- bit_nr = 0;
-
- bit_nr &= 0x3F;
- mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
- mclist = mclist->next;
- }
- }
dev->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
@@ -124,7 +111,6 @@ static int wbsoft_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
return NETDEV_TX_OK;
}
-
static int wbsoft_start(struct ieee80211_hw *dev)
{
struct wbsoft_priv *priv = dev->priv;
@@ -134,6 +120,127 @@ static int wbsoft_start(struct ieee80211_hw *dev)
return 0;
}
+static void hal_set_radio_mode(struct hw_data *pHwData, unsigned char radio_off)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ if (radio_off) //disable Baseband receive off
+ {
+ pHwData->CurrentRadioSw = 1; // off
+ reg->M24_MacControl &= 0xffffffbf;
+ } else {
+ pHwData->CurrentRadioSw = 0; // on
+ reg->M24_MacControl |= 0x00000040;
+ }
+ Wb35Reg_Write(pHwData, 0x0824, reg->M24_MacControl);
+}
+
+static void hal_set_beacon_period(struct hw_data *pHwData, u16 beacon_period)
+{
+ u32 tmp;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ pHwData->BeaconPeriod = beacon_period;
+ tmp = pHwData->BeaconPeriod << 16;
+ tmp |= pHwData->ProbeDelay;
+ Wb35Reg_Write(pHwData, 0x0848, tmp);
+}
+
+static void
+hal_set_current_channel_ex(struct hw_data *pHwData, ChanInfo channel)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
+
+ RFSynthesizer_SwitchingChannel(pHwData, channel); // Switch channel
+ pHwData->Channel = channel.ChanNo;
+ pHwData->band = channel.band;
+#ifdef _PE_STATE_DUMP_
+ printk("Set channel is %d, band =%d\n", pHwData->Channel,
+ pHwData->band);
+#endif
+ reg->M28_MacControl &= ~0xff; // Clean channel information field
+ reg->M28_MacControl |= channel.ChanNo;
+ Wb35Reg_WriteWithCallbackValue(pHwData, 0x0828, reg->M28_MacControl,
+ (s8 *) & channel, sizeof(ChanInfo));
+}
+
+static void hal_set_current_channel(struct hw_data *pHwData, ChanInfo channel)
+{
+ hal_set_current_channel_ex(pHwData, channel);
+}
+
+static void hal_set_accept_broadcast(struct hw_data *pHwData, u8 enable)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ reg->M00_MacControl &= ~0x02000000; //The HW value
+
+ if (enable)
+ reg->M00_MacControl |= 0x02000000; //The HW value
+
+ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
+}
+
+//for wep key error detection, we need to accept broadcast packets to be received temporary.
+static void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return;
+ if (enable) {
+ reg->M00_MacControl |= 0x00400000;
+ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
+ } else {
+ reg->M00_MacControl &= ~0x00400000;
+ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
+ }
+}
+
+static void hal_set_accept_multicast(struct hw_data *pHwData, u8 enable)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ reg->M00_MacControl &= ~0x01000000; //The HW value
+ if (enable)
+ reg->M00_MacControl |= 0x01000000; //The HW value
+ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
+}
+
+static void hal_set_accept_beacon(struct hw_data *pHwData, u8 enable)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ // 20040108 debug
+ if (!enable) //Due to SME and MLME are not suitable for 35
+ return;
+
+ reg->M00_MacControl &= ~0x04000000; //The HW value
+ if (enable)
+ reg->M00_MacControl |= 0x04000000; //The HW value
+
+ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
+}
+
static int wbsoft_config(struct ieee80211_hw *dev, u32 changed)
{
struct wbsoft_priv *priv = dev->priv;
@@ -142,36 +249,18 @@ static int wbsoft_config(struct ieee80211_hw *dev, u32 changed)
printk("wbsoft_config called\n");
+ /* Should use channel_num, or something, as that is already pre-translated */
ch.band = 1;
- ch.ChanNo = 1; /* Should use channel_num, or something, as that is already pre-translated */
-
+ ch.ChanNo = 1;
hal_set_current_channel(&priv->sHwData, ch);
hal_set_beacon_period(&priv->sHwData, conf->beacon_int);
-// hal_set_cap_info(&priv->sHwData, ?? );
-// hal_set_ssid(struct hw_data * pHwData, u8 * pssid, u8 ssid_len); ??
hal_set_accept_broadcast(&priv->sHwData, 1);
- hal_set_accept_promiscuous(&priv->sHwData, 1);
- hal_set_accept_multicast(&priv->sHwData, 1);
- hal_set_accept_beacon(&priv->sHwData, 1);
- hal_set_radio_mode(&priv->sHwData, 0);
- //hal_set_antenna_number( struct hw_data * pHwData, u8 number )
- //hal_set_rf_power(struct hw_data * pHwData, u8 PowerIndex)
-
-
-// hal_start_bss(&priv->sHwData, WLAN_BSSTYPE_INFRASTRUCTURE); ??
+ hal_set_accept_promiscuous(&priv->sHwData, 1);
+ hal_set_accept_multicast(&priv->sHwData, 1);
+ hal_set_accept_beacon(&priv->sHwData, 1);
+ hal_set_radio_mode(&priv->sHwData, 0);
-//void hal_set_rates(struct hw_data * pHwData, u8 * pbss_rates,
-// u8 length, unsigned char basic_rate_set)
-
- return 0;
-}
-
-static int wbsoft_config_interface(struct ieee80211_hw *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- printk("wbsoft_config_interface called\n");
return 0;
}
@@ -183,63 +272,448 @@ static u64 wbsoft_get_tsf(struct ieee80211_hw *dev)
static const struct ieee80211_ops wbsoft_ops = {
.tx = wbsoft_tx,
- .start = wbsoft_start, /* Start can be pretty much empty as we do wb35_hw_init() during probe? */
+ .start = wbsoft_start,
.stop = wbsoft_stop,
.add_interface = wbsoft_add_interface,
.remove_interface = wbsoft_remove_interface,
.config = wbsoft_config,
- .config_interface = wbsoft_config_interface,
.configure_filter = wbsoft_configure_filter,
.get_stats = wbsoft_get_stats,
.get_tx_stats = wbsoft_get_tx_stats,
.get_tsf = wbsoft_get_tsf,
-// conf_tx: hal_set_cwmin()/hal_set_cwmax;
};
-static unsigned char wb35_hw_init(struct ieee80211_hw *hw)
+static void
+hal_set_ethernet_address(struct hw_data *pHwData, u8 * current_address)
+{
+ u32 ltmp[2];
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ memcpy(pHwData->CurrentMacAddress, current_address, ETH_ALEN);
+
+ ltmp[0] = cpu_to_le32(*(u32 *) pHwData->CurrentMacAddress);
+ ltmp[1] =
+ cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff;
+
+ Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT);
+}
+
+static void
+hal_get_permanent_address(struct hw_data *pHwData, u8 * pethernet_address)
+{
+ if (pHwData->SurpriseRemove)
+ return;
+
+ memcpy(pethernet_address, pHwData->PermanentMacAddress, 6);
+}
+
+static void hal_stop(struct hw_data *pHwData)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ pHwData->Wb35Rx.rx_halt = 1;
+ Wb35Rx_stop(pHwData);
+
+ pHwData->Wb35Tx.tx_halt = 1;
+ Wb35Tx_stop(pHwData);
+
+ reg->D00_DmaControl &= ~0xc0000000; //Tx Off, Rx Off
+ Wb35Reg_Write(pHwData, 0x0400, reg->D00_DmaControl);
+}
+
+static unsigned char hal_idle(struct hw_data *pHwData)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+ struct wb_usb *pWbUsb = &pHwData->WbUsb;
+
+ if (!pHwData->SurpriseRemove
+ && (pWbUsb->DetectCount || reg->EP0vm_state != VM_STOP))
+ return false;
+
+ return true;
+}
+
+u8 hal_get_antenna_number(struct hw_data *pHwData)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if ((reg->BB2C & BIT(11)) == 0)
+ return 0;
+ else
+ return 1;
+}
+
+/* 0 : radio on; 1: radio off */
+static u8 hal_get_hw_radio_off(struct hw_data * pHwData)
+{
+ struct wb35_reg *reg = &pHwData->reg;
+
+ if (pHwData->SurpriseRemove)
+ return 1;
+
+ //read the bit16 of register U1B0
+ Wb35Reg_Read(pHwData, 0x3b0, &reg->U1B0);
+ if ((reg->U1B0 & 0x00010000)) {
+ pHwData->CurrentRadioHw = 1;
+ return 1;
+ } else {
+ pHwData->CurrentRadioHw = 0;
+ return 0;
+ }
+}
+
+static u8 LED_GRAY[20] = {
+ 0, 3, 4, 6, 8, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 8, 6, 4, 2
+};
+
+static u8 LED_GRAY2[30] = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 15, 14, 13, 12, 11, 10, 9, 8
+};
+
+static void hal_led_control(unsigned long data)
+{
+ struct wbsoft_priv *adapter = (struct wbsoft_priv *)data;
+ struct hw_data *pHwData = &adapter->sHwData;
+ struct wb35_reg *reg = &pHwData->reg;
+ u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT;
+ u32 TimeInterval = 500, ltmp, ltmp2;
+ ltmp = 0;
+
+ if (pHwData->SurpriseRemove)
+ return;
+
+ if (pHwData->LED_control) {
+ ltmp2 = pHwData->LED_control & 0xff;
+ if (ltmp2 == 5) // 5 is WPS mode
+ {
+ TimeInterval = 100;
+ ltmp2 = (pHwData->LED_control >> 8) & 0xff;
+ switch (ltmp2) {
+ case 1: // [0.2 On][0.1 Off]...
+ pHwData->LED_Blinking %= 3;
+ ltmp = 0x1010; // Led 1 & 0 Green and Red
+ if (pHwData->LED_Blinking == 2) // Turn off
+ ltmp = 0;
+ break;
+ case 2: // [0.1 On][0.1 Off]...
+ pHwData->LED_Blinking %= 2;
+ ltmp = 0x0010; // Led 0 red color
+ if (pHwData->LED_Blinking) // Turn off
+ ltmp = 0;
+ break;
+ case 3: // [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]...
+ pHwData->LED_Blinking %= 15;
+ ltmp = 0x0010; // Led 0 red color
+ if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2)) // Turn off 0.6 sec
+ ltmp = 0;
+ break;
+ case 4: // [300 On][ off ]
+ ltmp = 0x1000; // Led 1 Green color
+ if (pHwData->LED_Blinking >= 3000)
+ ltmp = 0; // led maybe on after 300sec * 32bit counter overlap.
+ break;
+ }
+ pHwData->LED_Blinking++;
+
+ reg->U1BC_LEDConfigure = ltmp;
+ if (LEDSet != 7) // Only 111 mode has 2 LEDs on PCB.
+ {
+ reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8; // Copy LED result to each LED control register
+ reg->U1BC_LEDConfigure |= (ltmp & 0xff00) >> 8;
+ }
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure);
+ }
+ } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw) // If radio off
+ {
+ if (reg->U1BC_LEDConfigure & 0x1010) {
+ reg->U1BC_LEDConfigure &= ~0x1010;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure);
+ }
+ } else {
+ switch (LEDSet) {
+ case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
+ if (!pHwData->LED_LinkOn) // Blink only if not Link On
+ {
+ // Blinking if scanning is on progress
+ if (pHwData->LED_Scanning) {
+ if (pHwData->LED_Blinking == 0) {
+ reg->U1BC_LEDConfigure |= 0x10;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On
+ pHwData->LED_Blinking = 1;
+ TimeInterval = 300;
+ } else {
+ reg->U1BC_LEDConfigure &= ~0x10;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+ pHwData->LED_Blinking = 0;
+ TimeInterval = 300;
+ }
+ } else {
+ //Turn Off LED_0
+ if (reg->U1BC_LEDConfigure & 0x10) {
+ reg->U1BC_LEDConfigure &= ~0x10;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+ }
+ }
+ } else {
+ // Turn On LED_0
+ if ((reg->U1BC_LEDConfigure & 0x10) == 0) {
+ reg->U1BC_LEDConfigure |= 0x10;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+ }
+ }
+ break;
+
+ case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
+ if (!pHwData->LED_LinkOn) // Blink only if not Link On
+ {
+ // Blinking if scanning is on progress
+ if (pHwData->LED_Scanning) {
+ if (pHwData->LED_Blinking == 0) {
+ reg->U1BC_LEDConfigure &= ~0xf;
+ reg->U1BC_LEDConfigure |= 0x10;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On
+ pHwData->LED_Blinking = 1;
+ TimeInterval = 300;
+ } else {
+ reg->U1BC_LEDConfigure &= ~0x1f;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+ pHwData->LED_Blinking = 0;
+ TimeInterval = 300;
+ }
+ } else {
+ // 20060901 Gray blinking if in disconnect state and not scanning
+ ltmp = reg->U1BC_LEDConfigure;
+ reg->U1BC_LEDConfigure &= ~0x1f;
+ if (LED_GRAY2[(pHwData->LED_Blinking % 30)]) {
+ reg->U1BC_LEDConfigure |= 0x10;
+ reg->U1BC_LEDConfigure |=
+ LED_GRAY2[(pHwData->LED_Blinking % 30)];
+ }
+ pHwData->LED_Blinking++;
+ if (reg->U1BC_LEDConfigure != ltmp)
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+ TimeInterval = 100;
+ }
+ } else {
+ // Turn On LED_0
+ if ((reg->U1BC_LEDConfigure & 0x10) == 0) {
+ reg->U1BC_LEDConfigure |= 0x10;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+ }
+ }
+ break;
+
+ case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
+ if (!pHwData->LED_LinkOn) // Blink only if not Link On
+ {
+ // Blinking if scanning is on progress
+ if (pHwData->LED_Scanning) {
+ if (pHwData->LED_Blinking == 0) {
+ reg->U1BC_LEDConfigure |=
+ 0x1000;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
+ pHwData->LED_Blinking = 1;
+ TimeInterval = 300;
+ } else {
+ reg->U1BC_LEDConfigure &=
+ ~0x1000;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off
+ pHwData->LED_Blinking = 0;
+ TimeInterval = 300;
+ }
+ } else {
+ //Turn Off LED_1
+ if (reg->U1BC_LEDConfigure & 0x1000) {
+ reg->U1BC_LEDConfigure &=
+ ~0x1000;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off
+ }
+ }
+ } else {
+ // Is transmitting/receiving ??
+ if ((adapter->RxByteCount !=
+ pHwData->RxByteCountLast)
+ || (adapter->TxByteCount !=
+ pHwData->TxByteCountLast)) {
+ if ((reg->U1BC_LEDConfigure & 0x3000) !=
+ 0x3000) {
+ reg->U1BC_LEDConfigure |=
+ 0x3000;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
+ }
+ // Update variable
+ pHwData->RxByteCountLast =
+ adapter->RxByteCount;
+ pHwData->TxByteCountLast =
+ adapter->TxByteCount;
+ TimeInterval = 200;
+ } else {
+ // Turn On LED_1 and blinking if transmitting/receiving
+ if ((reg->U1BC_LEDConfigure & 0x3000) !=
+ 0x1000) {
+ reg->U1BC_LEDConfigure &=
+ ~0x3000;
+ reg->U1BC_LEDConfigure |=
+ 0x1000;
+ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
+ }
+ }
+ }
+ break;
+
+ default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
+ if ((reg->U1BC_LEDConfigure & 0x3000) != 0x3000) {
+ reg->U1BC_LEDConfigure |= 0x3000; // LED_1 is always on and event enable
+ Wb35Reg_Write(pHwData, 0x03bc,
+ reg->U1BC_LEDConfigure);
+ }
+
+ if (pHwData->LED_Blinking) {
+ // Gray blinking
+ reg->U1BC_LEDConfigure &= ~0x0f;
+ reg->U1BC_LEDConfigure |= 0x10;
+ reg->U1BC_LEDConfigure |=
+ LED_GRAY[(pHwData->LED_Blinking - 1) % 20];
+ Wb35Reg_Write(pHwData, 0x03bc,
+ reg->U1BC_LEDConfigure);
+
+ pHwData->LED_Blinking += 2;
+ if (pHwData->LED_Blinking < 40)
+ TimeInterval = 100;
+ else {
+ pHwData->LED_Blinking = 0; // Stop blinking
+ reg->U1BC_LEDConfigure &= ~0x0f;
+ Wb35Reg_Write(pHwData, 0x03bc,
+ reg->U1BC_LEDConfigure);
+ }
+ break;
+ }
+
+ if (pHwData->LED_LinkOn) {
+ if (!(reg->U1BC_LEDConfigure & 0x10)) // Check the LED_0
+ {
+ //Try to turn ON LED_0 after gray blinking
+ reg->U1BC_LEDConfigure |= 0x10;
+ pHwData->LED_Blinking = 1; //Start blinking
+ TimeInterval = 50;
+ }
+ } else {
+ if (reg->U1BC_LEDConfigure & 0x10) // Check the LED_0
+ {
+ reg->U1BC_LEDConfigure &= ~0x10;
+ Wb35Reg_Write(pHwData, 0x03bc,
+ reg->U1BC_LEDConfigure);
+ }
+ }
+ break;
+ }
+
+ //20060828.1 Active send null packet to avoid AP disconnect
+ if (pHwData->LED_LinkOn) {
+ pHwData->NullPacketCount += TimeInterval;
+ if (pHwData->NullPacketCount >=
+ DEFAULT_NULL_PACKET_COUNT) {
+ pHwData->NullPacketCount = 0;
+ }
+ }
+ }
+
+ pHwData->time_count += TimeInterval;
+ Wb35Tx_CurrentTime(adapter, pHwData->time_count); // 20060928 add
+ pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval);
+ add_timer(&pHwData->LEDTimer);
+}
+
+static int hal_init_hardware(struct ieee80211_hw *hw)
{
struct wbsoft_priv *priv = hw->priv;
- struct hw_data * pHwData;
- u8 *pMacAddr;
- u8 *pMacAddr2;
- u32 InitStep = 0;
- u8 EEPROM_region;
- u8 HwRadioOff;
-
- //
- // Setting default value for Linux
- //
- priv->sLocalPara.region_INF = REGION_AUTO;
- priv->sLocalPara.TxRateMode = RATE_AUTO;
- priv->sLocalPara.bMacOperationMode = MODE_802_11_BG; // B/G mode
- priv->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
- priv->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
- hal_set_phy_type( &priv->sHwData, RF_WB_242_1 );
- priv->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
- priv->sLocalPara.bPreambleMode = AUTO_MODE;
+ struct hw_data *pHwData = &priv->sHwData;
+ u16 SoftwareSet;
+
+ pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME;
+ pHwData->FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
+
+ if (!Wb35Reg_initial(pHwData))
+ goto error_reg_destroy;
+
+ if (!Wb35Tx_initial(pHwData))
+ goto error_tx_destroy;
+
+ if (!Wb35Rx_initial(pHwData))
+ goto error_rx_destroy;
+
+ init_timer(&pHwData->LEDTimer);
+ pHwData->LEDTimer.function = hal_led_control;
+ pHwData->LEDTimer.data = (unsigned long)priv;
+ pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
+ add_timer(&pHwData->LEDTimer);
+
+ SoftwareSet = hal_software_set(pHwData);
+
+#ifdef Vendor2
+ // Try to make sure the EEPROM contain
+ SoftwareSet >>= 8;
+ if (SoftwareSet != 0x82)
+ return false;
+#endif
+
+ Wb35Rx_start(hw);
+ Wb35Tx_EP2VM_start(priv);
+
+ return 0;
+
+error_rx_destroy:
+ Wb35Rx_destroy(pHwData);
+error_tx_destroy:
+ Wb35Tx_destroy(pHwData);
+error_reg_destroy:
+ Wb35Reg_destroy(pHwData);
+
+ pHwData->SurpriseRemove = 1;
+ return -EINVAL;
+}
+
+static int wb35_hw_init(struct ieee80211_hw *hw)
+{
+ struct wbsoft_priv *priv = hw->priv;
+ struct hw_data *pHwData = &priv->sHwData;
+ u8 EEPROM_region;
+ u8 HwRadioOff;
+ u8 *pMacAddr2;
+ u8 *pMacAddr;
+ int err;
+
+ pHwData->phy_type = RF_DECIDE_BY_INF;
+
+ priv->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
+ priv->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
+
+ priv->sLocalPara.region_INF = REGION_AUTO;
+ priv->sLocalPara.TxRateMode = RATE_AUTO;
+ priv->sLocalPara.bMacOperationMode = MODE_802_11_BG;
+ priv->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
+ priv->sLocalPara.bPreambleMode = AUTO_MODE;
+ priv->sLocalPara.bWepKeyError = false;
+ priv->sLocalPara.bToSelfPacketReceived = false;
+ priv->sLocalPara.WepKeyDetectTimerCount = 2 * 100; /* 2 seconds */
+
priv->sLocalPara.RadioOffStatus.boSwRadioOff = false;
- pHwData = &priv->sHwData;
- hal_set_phy_type( pHwData, RF_DECIDE_BY_INF );
-
- //added by ws for wep key error detection
- priv->sLocalPara.bWepKeyError= false;
- priv->sLocalPara.bToSelfPacketReceived = false;
- priv->sLocalPara.WepKeyDetectTimerCount= 2 * 100; /// 2 seconds
-
- // Initial USB hal
- InitStep = 1;
- pHwData = &priv->sHwData;
- if (!hal_init_hardware(hw))
+
+ err = hal_init_hardware(hw);
+ if (err)
goto error;
- EEPROM_region = hal_get_region_from_EEPROM( pHwData );
+ EEPROM_region = hal_get_region_from_EEPROM(pHwData);
if (EEPROM_region != REGION_AUTO)
priv->sLocalPara.region = EEPROM_region;
else {
if (priv->sLocalPara.region_INF != REGION_AUTO)
priv->sLocalPara.region = priv->sLocalPara.region_INF;
else
- priv->sLocalPara.region = REGION_USA; //default setting
+ priv->sLocalPara.region = REGION_USA; /* default setting */
}
// Get Software setting flag from hal
@@ -247,93 +721,80 @@ static unsigned char wb35_hw_init(struct ieee80211_hw *hw)
if (hal_software_set(pHwData) & 0x00000001)
priv->sLocalPara.boAntennaDiversity = true;
- //
- // For TS module
- //
- InitStep = 2;
-
- // For MDS module
- InitStep = 3;
Mds_initial(priv);
- //=======================================
- // Initialize the SME, SCAN, MLME, ROAM
- //=======================================
- InitStep = 4;
- InitStep = 5;
- InitStep = 6;
-
- // If no user-defined address in the registry, use the addresss "burned" on the NIC instead.
+ /*
+ * If no user-defined address in the registry, use the addresss
+ * "burned" on the NIC instead.
+ */
pMacAddr = priv->sLocalPara.ThisMacAddress;
pMacAddr2 = priv->sLocalPara.PermanentAddress;
- hal_get_permanent_address( pHwData, priv->sLocalPara.PermanentAddress );// Reading ethernet address from EEPROM
+
+ /* Reading ethernet address from EEPROM */
+ hal_get_permanent_address(pHwData, priv->sLocalPara.PermanentAddress);
if (memcmp(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH) == 0)
memcpy(pMacAddr, pMacAddr2, MAC_ADDR_LENGTH);
else {
- // Set the user define MAC address
- hal_set_ethernet_address(pHwData, priv->sLocalPara.ThisMacAddress);
+ /* Set the user define MAC address */
+ hal_set_ethernet_address(pHwData,
+ priv->sLocalPara.ThisMacAddress);
}
- //get current antenna
priv->sLocalPara.bAntennaNo = hal_get_antenna_number(pHwData);
#ifdef _PE_STATE_DUMP_
printk("Driver init, antenna no = %d\n", psLOCAL->bAntennaNo);
#endif
- hal_get_hw_radio_off( pHwData );
+ hal_get_hw_radio_off(pHwData);
- // Waiting for HAL setting OK
+ /* Waiting for HAL setting OK */
while (!hal_idle(pHwData))
msleep(10);
MTO_Init(priv);
- HwRadioOff = hal_get_hw_radio_off( pHwData );
+ HwRadioOff = hal_get_hw_radio_off(pHwData);
priv->sLocalPara.RadioOffStatus.boHwRadioOff = !!HwRadioOff;
- hal_set_radio_mode( pHwData, (unsigned char)(priv->sLocalPara.RadioOffStatus.boSwRadioOff || priv->sLocalPara.RadioOffStatus.boHwRadioOff) );
+ hal_set_radio_mode(pHwData,
+ (unsigned char)(priv->sLocalPara.RadioOffStatus.
+ boSwRadioOff
+ || priv->sLocalPara.RadioOffStatus.
+ boHwRadioOff));
- hal_driver_init_OK(pHwData) = 1; // Notify hal that the driver is ready now.
- //set a tx power for reference.....
-// sme_set_tx_power_level(priv, 12); FIXME?
- return true;
+ /* Notify hal that the driver is ready now. */
+ hal_driver_init_OK(pHwData) = 1;
error:
- switch (InitStep) {
- case 5:
- case 4:
- case 3: Mds_Destroy( priv );
- case 2:
- case 1: hal_halt( pHwData, NULL );
- case 0: break;
- }
-
- return false;
+ return err;
}
-static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
+static int wb35_probe(struct usb_interface *intf,
+ const struct usb_device_id *id_table)
{
- struct wb_usb *pWbUsb;
- struct usb_host_interface *interface;
- struct usb_endpoint_descriptor *endpoint;
- u32 ltmp;
struct usb_device *udev = interface_to_usbdev(intf);
- struct wbsoft_priv *priv;
+ struct usb_endpoint_descriptor *endpoint;
+ struct usb_host_interface *interface;
struct ieee80211_hw *dev;
+ struct wbsoft_priv *priv;
+ struct wb_usb *pWbUsb;
int nr, err;
+ u32 ltmp;
usb_get_dev(udev);
- // 20060630.2 Check the device if it already be opened
- nr = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
- 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
- 0x0, 0x400, &ltmp, 4, HZ*100 );
+ /* Check the device if it already be opened */
+ nr = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ 0x01,
+ USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
+ 0x0, 0x400, &ltmp, 4, HZ * 100);
if (nr < 0) {
err = nr;
goto error;
}
+ /* Is already initialized? */
ltmp = cpu_to_le32(ltmp);
- if (ltmp) { // Is already initialized?
+ if (ltmp) {
err = -EBUSY;
goto error;
}
@@ -351,23 +812,22 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
pWbUsb = &priv->sHwData.WbUsb;
pWbUsb->udev = udev;
- interface = intf->cur_altsetting;
- endpoint = &interface->endpoint[0].desc;
+ interface = intf->cur_altsetting;
+ endpoint = &interface->endpoint[0].desc;
if (endpoint[2].wMaxPacketSize == 512) {
printk("[w35und] Working on USB 2.0\n");
pWbUsb->IsUsb20 = 1;
}
- if (!wb35_hw_init(dev)) {
- err = -EINVAL;
+ err = wb35_hw_init(dev);
+ if (err)
goto error_free_hw;
- }
SET_IEEE80211_DEV(dev, &udev->dev);
{
- struct hw_data * pHwData = &priv->sHwData;
- unsigned char dev_addr[MAX_ADDR_LEN];
+ struct hw_data *pHwData = &priv->sHwData;
+ unsigned char dev_addr[MAX_ADDR_LEN];
hal_get_permanent_address(pHwData, dev_addr);
SET_IEEE80211_PERM_ADDR(dev, dev_addr);
}
@@ -397,22 +857,31 @@ error:
return err;
}
+static void hal_halt(struct hw_data *pHwData)
+{
+ del_timer_sync(&pHwData->LEDTimer);
+ /* XXX: Wait for Timer DPC exit. */
+ msleep(100);
+ Wb35Rx_destroy(pHwData);
+ Wb35Tx_destroy(pHwData);
+ Wb35Reg_destroy(pHwData);
+}
+
static void wb35_hw_halt(struct wbsoft_priv *adapter)
{
- Mds_Destroy( adapter );
+ Mds_Destroy(adapter);
- // Turn off Rx and Tx hardware ability
- hal_stop( &adapter->sHwData );
+ /* Turn off Rx and Tx hardware ability */
+ hal_stop(&adapter->sHwData);
#ifdef _PE_USB_INI_DUMP_
printk("[w35und] Hal_stop O.K.\n");
#endif
- msleep(100);// Waiting Irp completed
+ /* Waiting Irp completed */
+ msleep(100);
- // Halt the HAL
- hal_halt(&adapter->sHwData, NULL);
+ hal_halt(&adapter->sHwData);
}
-
static void wb35_disconnect(struct usb_interface *intf)
{
struct ieee80211_hw *hw = usb_get_intfdata(intf);
diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h
index f3e87173471e..24d8708ec121 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -64,6 +64,7 @@
#define HFA384x_PORTID_MAX ((u16)7)
#define HFA384x_NUMPORTS_MAX ((u16)(HFA384x_PORTID_MAX+1))
#define HFA384x_PDR_LEN_MAX ((u16)512) /* in bytes, from EK */
+#define HFA384x_PDA_RECS_MAX ((u16)200) /* a guess */
#define HFA384x_PDA_LEN_MAX ((u16)1024) /* in bytes, from EK */
#define HFA384x_SCANRESULT_MAX ((u16)31)
#define HFA384x_HSCANRESULT_MAX ((u16)31)
@@ -882,6 +883,249 @@ typedef union hfa384x_usbin {
u8 boguspad[3000];
} __attribute__ ((packed)) hfa384x_usbin_t;
+/*--------------------------------------------------------------------
+PD record structures.
+--------------------------------------------------------------------*/
+
+typedef struct hfa384x_pdr_pcb_partnum
+{
+ u8 num[8];
+} __attribute__ ((packed)) hfa384x_pdr_pcb_partnum_t;
+
+typedef struct hfa384x_pdr_pcb_tracenum
+{
+ u8 num[8];
+} __attribute__ ((packed)) hfa384x_pdr_pcb_tracenum_t;
+
+typedef struct hfa384x_pdr_nic_serial
+{
+ u8 num[12];
+} __attribute__ ((packed)) hfa384x_pdr_nic_serial_t;
+
+typedef struct hfa384x_pdr_mkk_measurements
+{
+ double carrier_freq;
+ double occupied_band;
+ double power_density;
+ double tx_spur_f1;
+ double tx_spur_f2;
+ double tx_spur_f3;
+ double tx_spur_f4;
+ double tx_spur_l1;
+ double tx_spur_l2;
+ double tx_spur_l3;
+ double tx_spur_l4;
+ double rx_spur_f1;
+ double rx_spur_f2;
+ double rx_spur_l1;
+ double rx_spur_l2;
+} __attribute__ ((packed)) hfa384x_pdr_mkk_measurements_t;
+
+typedef struct hfa384x_pdr_nic_ramsize
+{
+ u8 size[12]; /* units of KB */
+} __attribute__ ((packed)) hfa384x_pdr_nic_ramsize_t;
+
+typedef struct hfa384x_pdr_mfisuprange
+{
+ u16 id;
+ u16 variant;
+ u16 bottom;
+ u16 top;
+} __attribute__ ((packed)) hfa384x_pdr_mfisuprange_t;
+
+typedef struct hfa384x_pdr_cfisuprange
+{
+ u16 id;
+ u16 variant;
+ u16 bottom;
+ u16 top;
+} __attribute__ ((packed)) hfa384x_pdr_cfisuprange_t;
+
+typedef struct hfa384x_pdr_nicid
+{
+ u16 id;
+ u16 variant;
+ u16 major;
+ u16 minor;
+} __attribute__ ((packed)) hfa384x_pdr_nicid_t;
+
+
+typedef struct hfa384x_pdr_refdac_measurements
+{
+ u16 value[0];
+} __attribute__ ((packed)) hfa384x_pdr_refdac_measurements_t;
+
+typedef struct hfa384x_pdr_vgdac_measurements
+{
+ u16 value[0];
+} __attribute__ ((packed)) hfa384x_pdr_vgdac_measurements_t;
+
+typedef struct hfa384x_pdr_level_comp_measurements
+{
+ u16 value[0];
+} __attribute__ ((packed)) hfa384x_pdr_level_compc_measurements_t;
+
+typedef struct hfa384x_pdr_mac_address
+{
+ u8 addr[6];
+} __attribute__ ((packed)) hfa384x_pdr_mac_address_t;
+
+typedef struct hfa384x_pdr_mkk_callname
+{
+ u8 callname[8];
+} __attribute__ ((packed)) hfa384x_pdr_mkk_callname_t;
+
+typedef struct hfa384x_pdr_regdomain
+{
+ u16 numdomains;
+ u16 domain[5];
+} __attribute__ ((packed)) hfa384x_pdr_regdomain_t;
+
+typedef struct hfa384x_pdr_allowed_channel
+{
+ u16 ch_bitmap;
+} __attribute__ ((packed)) hfa384x_pdr_allowed_channel_t;
+
+typedef struct hfa384x_pdr_default_channel
+{
+ u16 channel;
+} __attribute__ ((packed)) hfa384x_pdr_default_channel_t;
+
+typedef struct hfa384x_pdr_privacy_option
+{
+ u16 available;
+} __attribute__ ((packed)) hfa384x_pdr_privacy_option_t;
+
+typedef struct hfa384x_pdr_temptype
+{
+ u16 type;
+} __attribute__ ((packed)) hfa384x_pdr_temptype_t;
+
+typedef struct hfa384x_pdr_refdac_setup
+{
+ u16 ch_value[14];
+} __attribute__ ((packed)) hfa384x_pdr_refdac_setup_t;
+
+typedef struct hfa384x_pdr_vgdac_setup
+{
+ u16 ch_value[14];
+} __attribute__ ((packed)) hfa384x_pdr_vgdac_setup_t;
+
+typedef struct hfa384x_pdr_level_comp_setup
+{
+ u16 ch_value[14];
+} __attribute__ ((packed)) hfa384x_pdr_level_comp_setup_t;
+
+typedef struct hfa384x_pdr_trimdac_setup
+{
+ u16 trimidac;
+ u16 trimqdac;
+} __attribute__ ((packed)) hfa384x_pdr_trimdac_setup_t;
+
+typedef struct hfa384x_pdr_ifr_setting
+{
+ u16 value[3];
+} __attribute__ ((packed)) hfa384x_pdr_ifr_setting_t;
+
+typedef struct hfa384x_pdr_rfr_setting
+{
+ u16 value[3];
+} __attribute__ ((packed)) hfa384x_pdr_rfr_setting_t;
+
+typedef struct hfa384x_pdr_hfa3861_baseline
+{
+ u16 value[50];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_baseline_t;
+
+typedef struct hfa384x_pdr_hfa3861_shadow
+{
+ u32 value[32];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_shadow_t;
+
+typedef struct hfa384x_pdr_hfa3861_ifrf
+{
+ u32 value[20];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_ifrf_t;
+
+typedef struct hfa384x_pdr_hfa3861_chcalsp
+{
+ u16 value[14];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_chcalsp_t;
+
+typedef struct hfa384x_pdr_hfa3861_chcali
+{
+ u16 value[17];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_chcali_t;
+
+typedef struct hfa384x_pdr_hfa3861_nic_config
+{
+ u16 config_bitmap;
+} __attribute__ ((packed)) hfa384x_pdr_nic_config_t;
+
+typedef struct hfa384x_pdr_hfo_delay
+{
+ u8 hfo_delay;
+} __attribute__ ((packed)) hfa384x_hfo_delay_t;
+
+typedef struct hfa384x_pdr_hfa3861_manf_testsp
+{
+ u16 value[30];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_manf_testsp_t;
+
+typedef struct hfa384x_pdr_hfa3861_manf_testi
+{
+ u16 value[30];
+} __attribute__ ((packed)) hfa384x_pdr_hfa3861_manf_testi_t;
+
+typedef struct hfa384x_end_of_pda
+{
+ u16 crc;
+} __attribute__ ((packed)) hfa384x_pdr_end_of_pda_t;
+
+typedef struct hfa384x_pdrec
+{
+ u16 len; /* in words */
+ u16 code;
+ union pdr {
+ hfa384x_pdr_pcb_partnum_t pcb_partnum;
+ hfa384x_pdr_pcb_tracenum_t pcb_tracenum;
+ hfa384x_pdr_nic_serial_t nic_serial;
+ hfa384x_pdr_mkk_measurements_t mkk_measurements;
+ hfa384x_pdr_nic_ramsize_t nic_ramsize;
+ hfa384x_pdr_mfisuprange_t mfisuprange;
+ hfa384x_pdr_cfisuprange_t cfisuprange;
+ hfa384x_pdr_nicid_t nicid;
+ hfa384x_pdr_refdac_measurements_t refdac_measurements;
+ hfa384x_pdr_vgdac_measurements_t vgdac_measurements;
+ hfa384x_pdr_level_compc_measurements_t level_compc_measurements;
+ hfa384x_pdr_mac_address_t mac_address;
+ hfa384x_pdr_mkk_callname_t mkk_callname;
+ hfa384x_pdr_regdomain_t regdomain;
+ hfa384x_pdr_allowed_channel_t allowed_channel;
+ hfa384x_pdr_default_channel_t default_channel;
+ hfa384x_pdr_privacy_option_t privacy_option;
+ hfa384x_pdr_temptype_t temptype;
+ hfa384x_pdr_refdac_setup_t refdac_setup;
+ hfa384x_pdr_vgdac_setup_t vgdac_setup;
+ hfa384x_pdr_level_comp_setup_t level_comp_setup;
+ hfa384x_pdr_trimdac_setup_t trimdac_setup;
+ hfa384x_pdr_ifr_setting_t ifr_setting;
+ hfa384x_pdr_rfr_setting_t rfr_setting;
+ hfa384x_pdr_hfa3861_baseline_t hfa3861_baseline;
+ hfa384x_pdr_hfa3861_shadow_t hfa3861_shadow;
+ hfa384x_pdr_hfa3861_ifrf_t hfa3861_ifrf;
+ hfa384x_pdr_hfa3861_chcalsp_t hfa3861_chcalsp;
+ hfa384x_pdr_hfa3861_chcali_t hfa3861_chcali;
+ hfa384x_pdr_nic_config_t nic_config;
+ hfa384x_hfo_delay_t hfo_delay;
+ hfa384x_pdr_hfa3861_manf_testsp_t hfa3861_manf_testsp;
+ hfa384x_pdr_hfa3861_manf_testi_t hfa3861_manf_testi;
+ hfa384x_pdr_end_of_pda_t end_of_pda;
+
+ } data;
+} __attribute__ ((packed)) hfa384x_pdrec_t;
+
#ifdef __KERNEL__
/*--------------------------------------------------------------------
--- MAC state structure, argument to all functions --
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 888198c9a106..05af493c805d 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -110,7 +110,6 @@
* --------------------------------------------------------------------
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -1175,7 +1174,7 @@ int hfa384x_cmd_download(hfa384x_t *hw, u16 mode, u16 lowaddr,
int result = 0;
hfa384x_metacmd_t cmd;
- printk(KERN_DEBUG
+ pr_debug(
"mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
mode, lowaddr, highaddr, codelen);
@@ -1652,7 +1651,7 @@ hfa384x_dormem(hfa384x_t *hw,
ctlx->outbufsize = sizeof(ctlx->outbuf.rmemreq);
- printk(KERN_DEBUG
+ pr_debug(
"type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
ctlx->outbuf.rmemreq.type,
ctlx->outbuf.rmemreq.frmlen,
@@ -2036,7 +2035,7 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len)
/* NOTE: dlbuffer RID stores the address in AUX format */
dlbufaddr =
HFA384x_ADDR_AUX_MKFLAT(hw->bufinfo.page, hw->bufinfo.offset);
- printk(KERN_DEBUG
+ pr_debug(
"dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr);
@@ -2324,7 +2323,7 @@ int hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr)
/* Set the download state */
hw->dlstate = HFA384x_DLSTATE_RAMENABLED;
} else {
- printk(KERN_DEBUG
+ pr_debug(
"cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
lowaddr, hiaddr, result);
}
@@ -2630,10 +2629,10 @@ int hfa384x_drvr_start(hfa384x_t *hw)
usb_kill_urb(&hw->rx_urb);
goto done;
} else {
- printk(KERN_DEBUG
+ pr_debug(
"First cmd_initialize() failed (result %d),\n",
result1);
- printk(KERN_DEBUG
+ pr_debug(
"but second attempt succeeded. All should be ok\n");
}
} else if (result2 != 0) {
@@ -3302,7 +3301,7 @@ static void hfa384x_usbin_callback(struct urb *urb)
break;
default:
- printk(KERN_DEBUG
+ pr_debug(
"Unrecognized USBIN packet, type=%x, status=%d\n",
usbin->type, urb_status);
break;
@@ -3400,7 +3399,7 @@ retry:
* our request has been acknowledged. Odd,
* but our OUT URB is still alive...
*/
- printk(KERN_DEBUG
+ pr_debug(
"Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n");
ctlx->state = CTLX_RESP_COMPLETE;
break;
@@ -3553,7 +3552,7 @@ static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb)
hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm);
dev_kfree_skb(skb);
} else {
- printk(KERN_DEBUG
+ pr_debug(
"Received monitor frame: FCSerr set\n");
}
break;
@@ -4172,13 +4171,13 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode)
default:
if (pdrcode < 0x1000) {
/* code is OK, but we don't know exactly what it is */
- printk(KERN_DEBUG
+ pr_debug(
"Encountered unknown PDR#=0x%04x, "
"assuming it's ok.\n", pdrcode);
return 1;
} else {
/* bad code */
- printk(KERN_DEBUG
+ pr_debug(
"Encountered unknown PDR#=0x%04x, "
"(>=0x1000), assuming it's bad.\n", pdrcode);
return 0;
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 2abce0c34444..44266b8618c9 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -329,7 +329,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
skb->data + payload_offset +
payload_length - 4))) {
/* de-wep failed, drop skb. */
- printk(KERN_DEBUG
+ pr_debug(
"Host de-WEP failed, dropping frame (%d).\n",
foo);
wlandev->rx.decrypt_err++;
diff --git a/drivers/staging/wlan-ng/p80211metadef.h b/drivers/staging/wlan-ng/p80211metadef.h
index a29d6ae3e770..da8b6f53c74f 100644
--- a/drivers/staging/wlan-ng/p80211metadef.h
+++ b/drivers/staging/wlan-ng/p80211metadef.h
@@ -50,6 +50,14 @@
#define DIDmsg_dot11req_mibget \
(P80211DID_MKSECTION(1) | \
P80211DID_MKGROUP(1))
+#define DIDmsg_dot11req_mibget_mibattribute \
+ (P80211DID_MKSECTION(1) | \
+ P80211DID_MKGROUP(1) | \
+ P80211DID_MKITEM(1) | 0x00000000)
+#define DIDmsg_dot11req_mibget_resultcode \
+ (P80211DID_MKSECTION(1) | \
+ P80211DID_MKGROUP(1) | \
+ P80211DID_MKITEM(2) | 0x00000000)
#define DIDmsg_dot11req_mibset \
(P80211DID_MKSECTION(1) | \
P80211DID_MKGROUP(2))
@@ -94,12 +102,48 @@
#define DIDmsg_p2req_readpda \
(P80211DID_MKSECTION(5) | \
P80211DID_MKGROUP(2))
+#define DIDmsg_p2req_readpda_pda \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(2) | \
+ P80211DID_MKITEM(1) | 0x00000000)
+#define DIDmsg_p2req_readpda_resultcode \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(2) | \
+ P80211DID_MKITEM(2) | 0x00000000)
#define DIDmsg_p2req_ramdl_state \
(P80211DID_MKSECTION(5) | \
P80211DID_MKGROUP(11))
+#define DIDmsg_p2req_ramdl_state_enable \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(11) | \
+ P80211DID_MKITEM(1) | 0x00000000)
+#define DIDmsg_p2req_ramdl_state_exeaddr \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(11) | \
+ P80211DID_MKITEM(2) | 0x00000000)
+#define DIDmsg_p2req_ramdl_state_resultcode \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(11) | \
+ P80211DID_MKITEM(3) | 0x00000000)
#define DIDmsg_p2req_ramdl_write \
(P80211DID_MKSECTION(5) | \
P80211DID_MKGROUP(12))
+#define DIDmsg_p2req_ramdl_write_addr \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(12) | \
+ P80211DID_MKITEM(1) | 0x00000000)
+#define DIDmsg_p2req_ramdl_write_len \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(12) | \
+ P80211DID_MKITEM(2) | 0x00000000)
+#define DIDmsg_p2req_ramdl_write_data \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(12) | \
+ P80211DID_MKITEM(3) | 0x00000000)
+#define DIDmsg_p2req_ramdl_write_resultcode \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(12) | \
+ P80211DID_MKITEM(4) | 0x00000000)
#define DIDmsg_p2req_flashdl_state \
(P80211DID_MKSECTION(5) | \
P80211DID_MKGROUP(13))
@@ -203,6 +247,10 @@
(P80211DID_MKSECTION(5) | \
P80211DID_MKGROUP(2) | \
P80211DID_MKITEM(1) | 0x18000000)
+#define DIDmib_p2_p2NIC_p2PRISupRange \
+ (P80211DID_MKSECTION(5) | \
+ P80211DID_MKGROUP(5) | \
+ P80211DID_MKITEM(6) | 0x10000000)
#define DIDmib_p2_p2MAC \
(P80211DID_MKSECTION(5) | \
P80211DID_MKGROUP(6))
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 393e4df70dfd..c29c6b1aa1a9 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -49,7 +49,6 @@
* --------------------------------------------------------------------
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -567,8 +566,6 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
pr_debug("rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len);
- mutex_lock(&wlandev->ioctl_lock);
-
#ifdef SIOCETHTOOL
if (cmd == SIOCETHTOOL) {
result =
@@ -609,8 +606,6 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
result = -ENOMEM;
}
bail:
- mutex_unlock(&wlandev->ioctl_lock);
-
return result; /* If allocate,copyfrom or copyto fails, return errno */
}
@@ -772,11 +767,6 @@ int wlan_setup(wlandevice_t *wlandev)
dev->ml_priv = wlandev;
dev->netdev_ops = &p80211_netdev_ops;
- mutex_init(&wlandev->ioctl_lock);
- /* block ioctls until fully initialised. Don't forget to call
- allow_ioctls at some point!*/
- mutex_lock(&wlandev->ioctl_lock);
-
#if (WIRELESS_EXT < 21)
dev->get_wireless_stats = p80211wext_get_wireless_stats;
#endif
@@ -1117,8 +1107,3 @@ static void p80211knetdev_tx_timeout(netdevice_t *netdev)
netif_wake_queue(wlandev->netdev);
}
}
-
-void p80211_allow_ioctls(wlandevice_t *wlandev)
-{
- mutex_unlock(&wlandev->ioctl_lock);
-}
diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h
index b96090d87880..94a91b910b2b 100644
--- a/drivers/staging/wlan-ng/p80211netdev.h
+++ b/drivers/staging/wlan-ng/p80211netdev.h
@@ -227,8 +227,6 @@ typedef struct wlandevice {
u8 spy_number;
char spy_address[IW_MAX_SPY][ETH_ALEN];
struct iw_quality spy_stat[IW_MAX_SPY];
-
- struct mutex ioctl_lock;
} wlandevice_t;
/* WEP stuff */
@@ -244,5 +242,4 @@ int register_wlandev(wlandevice_t *wlandev);
int unregister_wlandev(wlandevice_t *wlandev);
void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
void p80211netdev_hwremoved(wlandevice_t *wlandev);
-void p80211_allow_ioctls(wlandevice_t *wlandev);
#endif
diff --git a/drivers/staging/wlan-ng/p80211wep.c b/drivers/staging/wlan-ng/p80211wep.c
index 405ce89e4e6e..ad052377ffd5 100644
--- a/drivers/staging/wlan-ng/p80211wep.c
+++ b/drivers/staging/wlan-ng/p80211wep.c
@@ -49,7 +49,6 @@
/* System Includes */
-#include <linux/version.h>
#include <linux/netdevice.h>
#include <linux/wireless.h>
diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c
index 96078b0ea6aa..e73123b26df7 100644
--- a/drivers/staging/wlan-ng/p80211wext.c
+++ b/drivers/staging/wlan-ng/p80211wext.c
@@ -1487,8 +1487,8 @@ static int p80211wext_set_encodeext(struct net_device *dev,
}
if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
- if (!(ext->alg & IW_ENCODE_ALG_WEP)) {
- pr_debug("asked to set a non wep key :(");
+ if (ext->alg != IW_ENCODE_ALG_WEP) {
+ pr_debug("asked to set a non wep key :(\n");
return -EINVAL;
}
if (idx) {
@@ -1561,7 +1561,7 @@ static int p80211wext_get_encodeext(struct net_device *dev,
if (idx) {
if (idx < 1 || idx > NUM_WEPKEYS) {
- printk(KERN_DEBUG
+ pr_debug(
"get_encode_ext invalid key index [%d]\n", idx);
result = -EINVAL;
goto exit;
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
new file mode 100644
index 000000000000..48bfb8331ddb
--- /dev/null
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -0,0 +1,1410 @@
+/* from src/prism2/download/prism2dl.c
+*
+* utility for downloading prism2 images moved into kernelspace
+*
+* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
+* --------------------------------------------------------------------
+*
+* linux-wlan
+*
+* The contents of this file are subject to the Mozilla Public
+* License Version 1.1 (the "License"); you may not use this file
+* except in compliance with the License. You may obtain a copy of
+* the License at http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS
+* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+* implied. See the License for the specific language governing
+* rights and limitations under the License.
+*
+* Alternatively, the contents of this file may be used under the
+* terms of the GNU Public License version 2 (the "GPL"), in which
+* case the provisions of the GPL are applicable instead of the
+* above. If you wish to allow the use of your version of this file
+* only under the terms of the GPL and not to allow others to use
+* your version of this file under the MPL, indicate your decision
+* by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL. If you do not delete
+* the provisions above, a recipient may use your version of this
+* file under either the MPL or the GPL.
+*
+* --------------------------------------------------------------------
+*
+* Inquiries regarding the linux-wlan Open Source project can be
+* made directly to:
+*
+* AbsoluteValue Systems Inc.
+* info@linux-wlan.com
+* http://www.linux-wlan.com
+*
+* --------------------------------------------------------------------
+*
+* Portions of the development of this software were funded by
+* Intersil Corporation as part of PRISM(R) chipset product development.
+*
+* --------------------------------------------------------------------
+*/
+
+/*================================================================*/
+/* System Includes */
+#include <linux/sort.h>
+#include <linux/firmware.h>
+
+
+/*================================================================*/
+/* Local Constants */
+
+#define PRISM2_USB_FWFILE "prism2_ru.hex"
+
+#define S3DATA_MAX 5000
+#define S3PLUG_MAX 200
+#define S3CRC_MAX 200
+#define S3INFO_MAX 50
+#define SREC_LINE_MAX 264
+#define S3LEN_TXTOFFSET 2
+#define S3LEN_TXTLEN 2
+#define S3ADDR_TXTOFFSET 4
+#define S3ADDR_TXTLEN 8
+#define S3DATA_TXTOFFSET 12
+/*S3DATA_TXTLEN variable, depends on len field */
+/*S3CKSUM_TXTOFFSET variable, depends on len field */
+#define S3CKSUM_TXTLEN 2
+#define SERNUM_LEN_MAX 12
+
+#define S3PLUG_ITEMCODE_TXTOFFSET (S3DATA_TXTOFFSET)
+#define S3PLUG_ITEMCODE_TXTLEN 8
+#define S3PLUG_ADDR_TXTOFFSET (S3DATA_TXTOFFSET+8)
+#define S3PLUG_ADDR_TXTLEN 8
+#define S3PLUG_LEN_TXTOFFSET (S3DATA_TXTOFFSET+16)
+#define S3PLUG_LEN_TXTLEN 8
+
+#define S3CRC_ADDR_TXTOFFSET (S3DATA_TXTOFFSET)
+#define S3CRC_ADDR_TXTLEN 8
+#define S3CRC_LEN_TXTOFFSET (S3DATA_TXTOFFSET+8)
+#define S3CRC_LEN_TXTLEN 8
+#define S3CRC_DOWRITE_TXTOFFSET (S3DATA_TXTOFFSET+16)
+#define S3CRC_DOWRITE_TXTLEN 8
+
+#define S3INFO_LEN_TXTOFFSET (S3DATA_TXTOFFSET)
+#define S3INFO_LEN_TXTLEN 4
+#define S3INFO_TYPE_TXTOFFSET (S3DATA_TXTOFFSET+4)
+#define S3INFO_TYPE_TXTLEN 4
+#define S3INFO_DATA_TXTOFFSET (S3DATA_TXTOFFSET+8)
+/* S3INFO_DATA_TXTLEN variable, depends on INFO_LEN field */
+
+#define S3ADDR_PLUG (0xff000000UL)
+#define S3ADDR_CRC (0xff100000UL)
+#define S3ADDR_INFO (0xff200000UL)
+
+#define PDAFILE_LINE_MAX 1024
+
+#define CHUNKS_MAX 100
+
+#define WRITESIZE_MAX 4096
+
+/*================================================================*/
+/* Local Macros */
+
+#define bswap_16(x) \
+ (__extension__ \
+ ({ register unsigned short int __v, __x = (x); \
+ __asm__ ("rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (__x) \
+ : "cc"); \
+ __v; }))
+
+#define bswap_32(x) \
+ (__extension__ \
+ ({ register unsigned int __v, __x = (x); \
+ __asm__ ("rorw $8, %w0;" \
+ "rorl $16, %0;" \
+ "rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (__x) \
+ : "cc"); \
+ __v; }))
+
+
+
+/*================================================================*/
+/* Local Types */
+
+typedef struct s3datarec
+{
+ u32 len;
+ u32 addr;
+ u8 checksum;
+ u8 *data;
+} s3datarec_t;
+
+typedef struct s3plugrec
+{
+ u32 itemcode;
+ u32 addr;
+ u32 len;
+} s3plugrec_t;
+
+typedef struct s3crcrec
+{
+ u32 addr;
+ u32 len;
+ unsigned int dowrite;
+} s3crcrec_t;
+
+typedef struct s3inforec
+{
+ u16 len;
+ u16 type;
+ union {
+ hfa384x_compident_t version;
+ hfa384x_caplevel_t compat;
+ u16 buildseq;
+ hfa384x_compident_t platform;
+ } info;
+} s3inforec_t;
+
+typedef struct pda
+{
+ u8 buf[HFA384x_PDA_LEN_MAX];
+ hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX];
+ unsigned int nrec;
+} pda_t;
+
+typedef struct imgchunk
+{
+ u32 addr; /* start address */
+ u32 len; /* in bytes */
+ u16 crc; /* CRC value (if it falls at a chunk boundary) */
+ u8 *data;
+} imgchunk_t;
+
+/*================================================================*/
+/* Local Static Definitions */
+
+
+/*----------------------------------------------------------------*/
+/* s-record image processing */
+
+/* Data records */
+unsigned int ns3data = 0;
+s3datarec_t s3data[S3DATA_MAX];
+
+/* Plug records */
+unsigned int ns3plug = 0;
+s3plugrec_t s3plug[S3PLUG_MAX];
+
+/* CRC records */
+unsigned int ns3crc = 0;
+s3crcrec_t s3crc[S3CRC_MAX];
+
+/* Info records */
+unsigned int ns3info = 0;
+s3inforec_t s3info[S3INFO_MAX];
+
+/* S7 record (there _better_ be only one) */
+u32 startaddr;
+
+/* Load image chunks */
+unsigned int nfchunks;
+imgchunk_t fchunk[CHUNKS_MAX];
+
+/* Note that for the following pdrec_t arrays, the len and code */
+/* fields are stored in HOST byte order. The mkpdrlist() function */
+/* does the conversion. */
+/*----------------------------------------------------------------*/
+/* PDA, built from [card|newfile]+[addfile1+addfile2...] */
+
+pda_t pda;
+hfa384x_compident_t nicid;
+hfa384x_caplevel_t rfid;
+hfa384x_caplevel_t macid;
+hfa384x_caplevel_t priid;
+
+
+/*================================================================*/
+/* Local Function Declarations */
+
+int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev);
+int read_srecfile(char *rfptr, int rfsize);
+int mkimage(imgchunk_t *clist, unsigned int *ccnt);
+int read_cardpda(pda_t *pda, wlandevice_t *wlandev);
+int mkpdrlist( pda_t *pda);
+int s3datarec_compare(const void *p1, const void *p2);
+int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
+ s3plugrec_t* s3plug, unsigned int ns3plug, pda_t *pda);
+int crcimage( imgchunk_t *fchunk, unsigned int nfchunks,
+ s3crcrec_t *s3crc, unsigned int ns3crc);
+int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, unsigned int nfchunks);
+void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks);
+void free_srecs(void);
+
+int validate_identity(void);
+
+/*================================================================*/
+/* Function Definitions */
+
+
+/*----------------------------------------------------------------
+* prism2_fwtry
+*
+* Try and get firmware into memory
+*
+* Arguments:
+* udev usb device structure
+* wlandev wlan device structure
+*
+* Returns:
+* 0 - success
+* ~0 - failure
+----------------------------------------------------------------*/
+int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
+{
+ const struct firmware *fw_entry = NULL;
+
+ printk(KERN_INFO "prism2_usb: Checking for firmware %s\n", PRISM2_USB_FWFILE);
+ if(request_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0)
+ {
+ printk(KERN_INFO
+ "prism2_usb: Firmware not available, but not essential\n");
+ printk(KERN_INFO
+ "prism2_usb: can continue to use card anyway.\n");
+ return 1;
+ }
+
+ printk(KERN_INFO "prism2_usb: %s will be processed, size %d\n", PRISM2_USB_FWFILE, fw_entry->size);
+ prism2_fwapply((char *)fw_entry->data, fw_entry->size, wlandev);
+
+ release_firmware(fw_entry);
+ return 0;
+}
+
+
+/*----------------------------------------------------------------
+* prism2_fwapply
+*
+* Apply the firmware loaded into memory
+*
+* Arguments:
+* rfptr firmware image in kernel memory
+* rfsize firmware size in kernel memory
+* wlandev device
+*
+* Returns:
+* 0 - success
+* ~0 - failure
+----------------------------------------------------------------*/
+int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
+{
+ signed int result = 0;
+ p80211msg_dot11req_mibget_t getmsg;
+ p80211itemd_t *item;
+ u32 *data;
+
+ /* Initialize the data structures */
+ ns3data = 0;
+ memset(s3data, 0, sizeof(s3data));
+ ns3plug = 0;
+ memset(s3plug, 0, sizeof(s3plug));
+ ns3crc = 0;
+ memset(s3crc, 0, sizeof(s3crc));
+ ns3info = 0;
+ memset(s3info, 0, sizeof(s3info));
+ startaddr = 0;
+
+ nfchunks = 0;
+ memset( fchunk, 0, sizeof(fchunk));
+ memset( &nicid, 0, sizeof(nicid));
+ memset( &rfid, 0, sizeof(rfid));
+ memset( &macid, 0, sizeof(macid));
+ memset( &priid, 0, sizeof(priid));
+
+ /* clear the pda and add an initial END record */
+ memset(&pda, 0, sizeof(pda));
+ pda.rec[0] = (hfa384x_pdrec_t*)pda.buf;
+ pda.rec[0]->len = cpu_to_le16(2); /* len in words */ /* len in words */
+ pda.rec[0]->code = cpu_to_le16(HFA384x_PDR_END_OF_PDA);
+ pda.nrec = 1;
+
+
+ /*-----------------------------------------------------*/
+ /* Put card into fwload state */
+ prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
+
+ /* Build the PDA we're going to use. */
+ if (read_cardpda(&pda, wlandev)) {
+ printk(KERN_ERR "load_cardpda failed, exiting.\n");
+ return(1);
+ }
+
+ /* read the card's PRI-SUP */
+ memset(&getmsg, 0, sizeof(getmsg));
+ getmsg.msgcode = DIDmsg_dot11req_mibget;
+ getmsg.msglen = sizeof(getmsg);
+ strcpy(getmsg.devname, wlandev->name);
+
+ getmsg.mibattribute.did = DIDmsg_dot11req_mibget_mibattribute;
+ getmsg.mibattribute.status = P80211ENUM_msgitem_status_data_ok;
+ getmsg.resultcode.did = DIDmsg_dot11req_mibget_resultcode;
+ getmsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+
+ item = (p80211itemd_t *) getmsg.mibattribute.data;
+ item->did = DIDmib_p2_p2NIC_p2PRISupRange;
+ item->status = P80211ENUM_msgitem_status_no_value;
+
+ data = (u32*) item->data;
+
+ /* DIDmsg_dot11req_mibget */
+ prism2mgmt_mibset_mibget(wlandev, &getmsg);
+ if (getmsg.resultcode.data != P80211ENUM_resultcode_success) {
+ printk(KERN_ERR "Couldn't fetch PRI-SUP info\n");
+ }
+
+ /* Already in host order */
+ priid.role = *data++;
+ priid.id = *data++;
+ priid.variant = *data++;
+ priid.bottom = *data++;
+ priid.top = *data++;
+
+
+ /* Read the S3 file */
+ result = read_srecfile(rfptr, rfsize);
+ if ( result ) {
+ printk(KERN_ERR "Failed to read the data exiting.\n");
+ return(1);
+ }
+ /* Sort the S3 data records */
+ sort( s3data,
+ ns3data,
+ sizeof(s3datarec_t),
+ s3datarec_compare, NULL);
+
+ result = validate_identity();
+
+ if ( result ) {
+ printk(KERN_ERR "Incompatible firmware image.\n");
+ return(1);
+ }
+
+ if (startaddr == 0x00000000) {
+ printk(KERN_ERR "Can't RAM download a Flash image!\n");
+ return(1);
+ }
+
+ /* Make the image chunks */
+ result = mkimage(fchunk, &nfchunks);
+
+ /* Do any plugging */
+ result = plugimage(fchunk, nfchunks, s3plug, ns3plug,
+ &pda);
+ if ( result ) {
+ printk(KERN_ERR "Failed to plug data.\n");
+ return(1);
+ }
+
+ /* Insert any CRCs */
+ if (crcimage(fchunk, nfchunks, s3crc, ns3crc) ) {
+ printk(KERN_ERR "Failed to insert all CRCs\n");
+ return(1);
+ }
+
+ /* Write the image */
+ result = writeimage(wlandev, fchunk, nfchunks);
+ if ( result ) {
+ printk(KERN_ERR "Failed to ramwrite image data.\n");
+ return(1);
+ }
+
+ /* clear any allocated memory */
+ free_chunks(fchunk, &nfchunks);
+ free_srecs();
+
+ printk(KERN_INFO "prism2_usb: firmware loading finished.\n");
+
+ return result;
+}
+
+
+/*----------------------------------------------------------------
+* crcimage
+*
+* Adds a CRC16 in the two bytes prior to each block identified by
+* an S3 CRC record. Currently, we don't actually do a CRC we just
+* insert the value 0xC0DE in hfa384x order.
+*
+* Arguments:
+* fchunk Array of image chunks
+* nfchunks Number of image chunks
+* s3crc Array of crc records
+* ns3crc Number of crc records
+*
+* Returns:
+* 0 success
+* ~0 failure
+----------------------------------------------------------------*/
+int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc,
+ unsigned int ns3crc)
+{
+ int result = 0;
+ int i;
+ int c;
+ u32 crcstart;
+ u32 crcend;
+ u32 cstart = 0;
+ u32 cend;
+ u8 *dest;
+ u32 chunkoff;
+
+ for ( i = 0; i < ns3crc; i++ ) {
+ if ( !s3crc[i].dowrite ) continue;
+ crcstart = s3crc[i].addr;
+ crcend = s3crc[i].addr + s3crc[i].len;
+ /* Find chunk */
+ for ( c = 0; c < nfchunks; c++) {
+ cstart = fchunk[c].addr;
+ cend = fchunk[c].addr + fchunk[c].len;
+ /* the line below does an address & len match search */
+ /* unfortunately, I've found that the len fields of */
+ /* some crc records don't match with the length of */
+ /* the actual data, so we're not checking right */
+ /* now */
+ /* if ( crcstart-2 >= cstart && crcend <= cend ) break;*/
+
+ /* note the -2 below, it's to make sure the chunk has */
+ /* space for the CRC value */
+ if ( crcstart-2 >= cstart && crcstart < cend ) break;
+ }
+ if ( c >= nfchunks ) {
+ printk(KERN_ERR
+ "Failed to find chunk for "
+ "crcrec[%d], addr=0x%06x len=%d , "
+ "aborting crc.\n",
+ i, s3crc[i].addr, s3crc[i].len);
+ return 1;
+ }
+
+ /* Insert crc */
+ pr_debug("Adding crc @ 0x%06x\n", s3crc[i].addr-2);
+ chunkoff = crcstart - cstart - 2;
+ dest = fchunk[c].data + chunkoff;
+ *dest = 0xde;
+ *(dest+1) = 0xc0;
+
+ }
+ return result;
+}
+
+
+/*----------------------------------------------------------------
+* free_chunks
+*
+* Clears the chunklist data structures in preparation for a new file.
+*
+* Arguments:
+* none
+*
+* Returns:
+* nothing
+----------------------------------------------------------------*/
+void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
+{
+ int i;
+ for ( i = 0; i < *nfchunks; i++) {
+ if ( fchunk[i].data != NULL ) {
+ kfree(fchunk[i].data);
+ }
+ }
+ *nfchunks = 0;
+ memset( fchunk, 0, sizeof(fchunk));
+
+}
+
+
+/*----------------------------------------------------------------
+* free_srecs
+*
+* Clears the srec data structures in preparation for a new file.
+*
+* Arguments:
+* none
+*
+* Returns:
+* nothing
+----------------------------------------------------------------*/
+void free_srecs(void)
+{
+ int i;
+ for ( i = 0; i < ns3data; i++) {
+ kfree(s3data[i].data);
+ }
+ ns3data = 0;
+ memset(s3data, 0, sizeof(s3data));
+ ns3plug = 0;
+ memset(s3plug, 0, sizeof(s3plug));
+ ns3crc = 0;
+ memset(s3crc, 0, sizeof(s3crc));
+ ns3info = 0;
+ memset(s3info, 0, sizeof(s3info));
+ startaddr = 0;
+}
+
+
+/*----------------------------------------------------------------
+* mkimage
+*
+* Scans the currently loaded set of S records for data residing
+* in contiguous memory regions. Each contiguous region is then
+* made into a 'chunk'. This function assumes that we're building
+* a new chunk list. Assumes the s3data items are in sorted order.
+*
+* Arguments: none
+*
+* Returns:
+* 0 - success
+* ~0 - failure (probably an errno)
+----------------------------------------------------------------*/
+int mkimage(imgchunk_t *clist, unsigned int *ccnt)
+{
+ int result = 0;
+ int i;
+ int j;
+ int currchunk = 0;
+ u32 nextaddr = 0;
+ u32 s3start;
+ u32 s3end;
+ u32 cstart = 0;
+ u32 cend;
+ u32 coffset;
+
+ /* There may already be data in the chunklist */
+ *ccnt = 0;
+
+ /* Establish the location and size of each chunk */
+ for ( i = 0; i < ns3data; i++) {
+ if ( s3data[i].addr == nextaddr ) {
+ /* existing chunk, grow it */
+ clist[currchunk].len += s3data[i].len;
+ nextaddr += s3data[i].len;
+ } else {
+ /* New chunk */
+ (*ccnt)++;
+ currchunk = *ccnt - 1;
+ clist[currchunk].addr = s3data[i].addr;
+ clist[currchunk].len = s3data[i].len;
+ nextaddr = s3data[i].addr + s3data[i].len;
+ /* Expand the chunk if there is a CRC record at */
+ /* their beginning bound */
+ for ( j = 0; j < ns3crc; j++) {
+ if ( s3crc[j].dowrite &&
+ s3crc[j].addr == clist[currchunk].addr ) {
+ clist[currchunk].addr -= 2;
+ clist[currchunk].len += 2;
+ }
+ }
+ }
+ }
+
+ /* We're currently assuming there aren't any overlapping chunks */
+ /* if this proves false, we'll need to add code to coalesce. */
+
+ /* Allocate buffer space for chunks */
+ for ( i = 0; i < *ccnt; i++) {
+ clist[i].data = kmalloc(clist[i].len, GFP_KERNEL);
+ if ( clist[i].data == NULL ) {
+ printk(KERN_ERR "failed to allocate image space, exitting.\n");
+ return(1);
+ }
+ memset(clist[i].data, 0, clist[i].len);
+ }
+
+
+ /* Display chunks */
+ for ( i = 0; i < *ccnt; i++) {
+ pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
+ i, clist[i].addr, clist[i].len);
+ }
+
+ /* Copy srec data to chunks */
+ for ( i = 0; i < ns3data; i++) {
+ s3start = s3data[i].addr;
+ s3end = s3start + s3data[i].len - 1;
+ for ( j = 0; j < *ccnt; j++) {
+ cstart = clist[j].addr;
+ cend = cstart + clist[j].len - 1;
+ if ( s3start >= cstart && s3end <= cend ) {
+ break;
+ }
+ }
+ if ( ((unsigned int)j) >= (*ccnt) ) {
+ printk(KERN_ERR
+ "s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n",
+ s3start, s3data[i].len);
+ return(1);
+ }
+ coffset = s3start - cstart;
+ memcpy( clist[j].data + coffset, s3data[i].data, s3data[i].len);
+ }
+
+ return result;
+}
+
+/*----------------------------------------------------------------
+* mkpdrlist
+*
+* Reads a raw PDA and builds an array of pdrec_t structures.
+*
+* Arguments:
+* pda buffer containing raw PDA bytes
+* pdrec ptr to an array of pdrec_t's. Will be filled on exit.
+* nrec ptr to a variable that will contain the count of PDRs
+*
+* Returns:
+* 0 - success
+* ~0 - failure (probably an errno)
+----------------------------------------------------------------*/
+int mkpdrlist( pda_t *pda)
+{
+ int result = 0;
+ u16 *pda16 = (u16*)pda->buf;
+ int curroff; /* in 'words' */
+
+ pda->nrec = 0;
+ curroff = 0;
+ while ( curroff < (HFA384x_PDA_LEN_MAX / 2) &&
+ le16_to_cpu(pda16[curroff + 1]) !=
+ HFA384x_PDR_END_OF_PDA ) {
+ pda->rec[pda->nrec] = (hfa384x_pdrec_t*)&(pda16[curroff]);
+
+ if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
+ HFA384x_PDR_NICID) {
+ memcpy(&nicid, &pda->rec[pda->nrec]->data.nicid,
+ sizeof(nicid));
+ nicid.id = le16_to_cpu(nicid.id);
+ nicid.variant = le16_to_cpu(nicid.variant);
+ nicid.major = le16_to_cpu(nicid.major);
+ nicid.minor = le16_to_cpu(nicid.minor);
+ }
+ if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
+ HFA384x_PDR_MFISUPRANGE) {
+ memcpy(&rfid, &pda->rec[pda->nrec]->data.mfisuprange,
+ sizeof(rfid));
+ rfid.id = le16_to_cpu(rfid.id);
+ rfid.variant = le16_to_cpu(rfid.variant);
+ rfid.bottom = le16_to_cpu(rfid.bottom);
+ rfid.top = le16_to_cpu(rfid.top);
+ }
+ if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
+ HFA384x_PDR_CFISUPRANGE) {
+ memcpy(&macid, &pda->rec[pda->nrec]->data.cfisuprange,
+ sizeof(macid));
+ macid.id = le16_to_cpu(macid.id);
+ macid.variant = le16_to_cpu(macid.variant);
+ macid.bottom = le16_to_cpu(macid.bottom);
+ macid.top = le16_to_cpu(macid.top);
+ }
+
+ (pda->nrec)++;
+ curroff += le16_to_cpu(pda16[curroff]) + 1;
+
+ }
+ if ( curroff >= (HFA384x_PDA_LEN_MAX / 2) ) {
+ printk(KERN_ERR
+ "no end record found or invalid lengths in "
+ "PDR data, exiting. %x %d\n", curroff, pda->nrec);
+ return(1);
+ }
+ if (le16_to_cpu(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA ) {
+ pda->rec[pda->nrec] = (hfa384x_pdrec_t*)&(pda16[curroff]);
+ (pda->nrec)++;
+ }
+ return result;
+}
+
+
+
+/*----------------------------------------------------------------
+* plugimage
+*
+* Plugs the given image using the given plug records from the given
+* PDA and filename.
+*
+* Arguments:
+* fchunk Array of image chunks
+* nfchunks Number of image chunks
+* s3plug Array of plug records
+* ns3plug Number of plug records
+* pda Current pda data
+*
+* Returns:
+* 0 success
+* ~0 failure
+----------------------------------------------------------------*/
+int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
+ s3plugrec_t* s3plug, unsigned int ns3plug, pda_t *pda)
+{
+ int result = 0;
+ int i; /* plug index */
+ int j; /* index of PDR or -1 if fname plug */
+ int c; /* chunk index */
+ u32 pstart;
+ u32 pend;
+ u32 cstart = 0;
+ u32 cend;
+ u32 chunkoff;
+ u8 *dest;
+
+ /* for each plug record */
+ for ( i = 0; i < ns3plug; i++) {
+ pstart = s3plug[i].addr;
+ pend = s3plug[i].addr + s3plug[i].len;
+ /* find the matching PDR (or filename) */
+ if ( s3plug[i].itemcode != 0xffffffffUL ) { /* not filename */
+ for ( j = 0; j < pda->nrec; j++) {
+ if ( s3plug[i].itemcode ==
+ le16_to_cpu(pda->rec[j]->code) ) break;
+ }
+ } else {
+ j = -1;
+ }
+ if ( j >= pda->nrec && j != -1 ) { /* if no matching PDR, fail */
+ printk(KERN_WARNING
+ "warning: Failed to find PDR for "
+ "plugrec 0x%04x.\n",
+ s3plug[i].itemcode);
+ continue; /* and move on to the next PDR */
+#if 0
+ /* MSM: They swear that unless it's the MAC address,
+ * the serial number, or the TX calibration records,
+ * then there's reasonable defaults in the f/w
+ * image. Therefore, missing PDRs in the card
+ * should only be a warning, not fatal.
+ * TODO: add fatals for the PDRs mentioned above.
+ */
+ result = 1;
+ continue;
+#endif
+ }
+
+ /* Validate plug len against PDR len */
+ if ( j != -1 &&
+ s3plug[i].len < le16_to_cpu(pda->rec[j]->len) ) {
+ printk(KERN_ERR
+ "error: Plug vs. PDR len mismatch for "
+ "plugrec 0x%04x, abort plugging.\n",
+ s3plug[i].itemcode);
+ result = 1;
+ continue;
+ }
+
+ /* Validate plug address against chunk data and identify chunk */
+ for ( c = 0; c < nfchunks; c++) {
+ cstart = fchunk[c].addr;
+ cend = fchunk[c].addr + fchunk[c].len;
+ if ( pstart >= cstart && pend <= cend ) break;
+ }
+ if ( c >= nfchunks ) {
+ printk(KERN_ERR
+ "error: Failed to find image chunk for "
+ "plugrec 0x%04x.\n",
+ s3plug[i].itemcode);
+ result = 1;
+ continue;
+ }
+
+ /* Plug data */
+ chunkoff = pstart - cstart;
+ dest = fchunk[c].data + chunkoff;
+ pr_debug("Plugging item 0x%04x @ 0x%06x, len=%d, "
+ "cnum=%d coff=0x%06x\n",
+ s3plug[i].itemcode, pstart, s3plug[i].len,
+ c, chunkoff);
+
+ if ( j == -1 ) { /* plug the filename */
+ memset(dest, 0, s3plug[i].len);
+ strncpy(dest, PRISM2_USB_FWFILE, s3plug[i].len - 1);
+ } else { /* plug a PDR */
+ memcpy( dest, &(pda->rec[j]->data), s3plug[i].len);
+ }
+ }
+ return result;
+
+}
+
+
+/*----------------------------------------------------------------
+* read_cardpda
+*
+* Sends the command for the driver to read the pda from the card
+* named in the device variable. Upon success, the card pda is
+* stored in the "cardpda" variables. Note that the pda structure
+* is considered 'well formed' after this function. That means
+* that the nrecs is valid, the rec array has been set up, and there's
+* a valid PDAEND record in the raw PDA data.
+*
+* Arguments:
+* pda pda structure
+* wlandev device
+*
+* Returns:
+* 0 - success
+* ~0 - failure (probably an errno)
+----------------------------------------------------------------*/
+int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
+{
+ int result = 0;
+ p80211msg_p2req_readpda_t msg;
+
+ /* set up the msg */
+ msg.msgcode = DIDmsg_p2req_readpda;
+ msg.msglen = sizeof(msg);
+ strcpy(msg.devname, wlandev->name);
+ msg.pda.did = DIDmsg_p2req_readpda_pda;
+ msg.pda.len = HFA384x_PDA_LEN_MAX;
+ msg.pda.status = P80211ENUM_msgitem_status_no_value;
+ msg.resultcode.did = DIDmsg_p2req_readpda_resultcode;
+ msg.resultcode.len = sizeof(u32);
+ msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+
+ if ( prism2mgmt_readpda(wlandev, &msg) != 0 ) {
+ /* prism2mgmt_readpda prints an errno if appropriate */
+ result = -1;
+ } else if ( msg.resultcode.data == P80211ENUM_resultcode_success ) {
+ memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
+ result = mkpdrlist(pda);
+ } else {
+ /* resultcode must've been something other than success */
+ result = -1;
+ }
+
+ return result;
+}
+
+
+/*----------------------------------------------------------------
+* copy_line
+*
+* Copies a line of text, up to \n, \0, or SREC_LINE_MAX, or limit of
+* From array
+*
+* Arguments:
+* from From addr
+* to To addr
+* limit Addr of last character in From array that can be copied
+*
+* Returns:
+* Num characters copied
+----------------------------------------------------------------*/
+int copyline(char *from, char *to, char *limit)
+{
+ int c = 0;
+
+ while ((c < SREC_LINE_MAX - 1) && (from + c <= limit) &&
+ (from[c] != '\n') && (from[c] != '\0')) {
+ to[c] = from[c];
+ c++;
+ }
+
+ to[c] = '\0';
+ return (c < SREC_LINE_MAX - 1) ? c + 1 : c;
+}
+
+
+/*----------------------------------------------------------------
+* read_srecfile
+*
+* Reads the given srecord file and loads the records into the
+* s3xxx arrays. This function can be called repeatedly (once for
+* each of a set of files), if necessary. This function performs
+* no validation of the data except for the grossest of S-record
+* line format checks. Don't forget that these will be DOS files...
+* CR/LF at the end of each line.
+*
+* Here's the SREC format we're dealing with:
+* S[37]nnaaaaaaaaddd...dddcc
+*
+* nn - number of bytes starting with the address field
+* aaaaaaaa - address in readable (or big endian) format
+* dd....dd - 0-245 data bytes (two chars per byte)
+* cc - checksum
+*
+* The S7 record's (there should be only one) address value gets
+* saved in startaddr. It's the start execution address used
+* for RAM downloads.
+*
+* The S3 records have a collection of subformats indicated by the
+* value of aaaaaaaa:
+* 0xff000000 - Plug record, data field format:
+* xxxxxxxxaaaaaaaassssssss
+* x - PDR code number (little endian)
+* a - Address in load image to plug (little endian)
+* s - Length of plug data area (little endian)
+*
+* 0xff100000 - CRC16 generation record, data field format:
+* aaaaaaaassssssssbbbbbbbb
+* a - Start address for CRC calculation (little endian)
+* s - Length of data to calculate over (little endian)
+* b - Boolean, true=write crc, false=don't write
+*
+* 0xff200000 - Info record, data field format:
+* ssssttttdd..dd
+* s - Size in words (little endian)
+* t - Info type (little endian), see #defines and
+* s3inforec_t for details about types.
+* d - (s - 1) little endian words giving the contents of
+* the given info type.
+*
+* Arguments:
+* rfptr firmware image (s-record structure) in kernel memory
+* rfsize firmware size in kernel memory
+*
+* Returns:
+* 0 - success
+* ~0 - failure (probably an errno)
+----------------------------------------------------------------*/
+int read_srecfile(char *rfptr, int rfsize)
+{
+ int result = 0;
+ char buf[SREC_LINE_MAX];
+ char tmpbuf[30];
+ s3datarec_t tmprec;
+ int i, c;
+ int line = 0;
+ u16 *tmpinfo;
+ char *endptr = rfptr + rfsize;
+
+
+ pr_debug("Reading S-record file ...\n");
+
+ while ( (c = copyline(rfptr, buf, endptr)) >= 12 ) {
+ rfptr = rfptr + c;
+ line++;
+ if ( buf[0] != 'S' ) {
+ printk(KERN_ERR "%d warning: No initial \'S\'\n", line);
+ return 1;
+ }
+ if ( buf[1] == '7' ) { /* S7 record, start address */
+ buf[12] = '\0';
+ startaddr = simple_strtoul(buf+4, NULL, 16);
+ pr_debug(" S7 start addr, line=%d "
+ " addr=0x%08x\n",
+ line,
+ startaddr);
+ continue;
+ } else if ( buf[1] == '3') {
+ /* Ok, it's an S3, parse and put it in the right array */
+ /* Record Length field (we only want datalen) */
+ memcpy(tmpbuf, buf+S3LEN_TXTOFFSET, S3LEN_TXTLEN);
+ tmpbuf[S3LEN_TXTLEN] = '\0';
+ tmprec.len = simple_strtoul( tmpbuf, NULL, 16) - 4 - 1; /* 4=addr, 1=cksum */
+ /* Address field */
+ memcpy(tmpbuf, buf+S3ADDR_TXTOFFSET, S3ADDR_TXTLEN);
+ tmpbuf[S3ADDR_TXTLEN] = '\0';
+ tmprec.addr = simple_strtoul( tmpbuf, NULL, 16);
+ /* Checksum field */
+ tmprec.checksum = simple_strtoul( buf+strlen(buf)-2, NULL, 16);
+
+ switch( tmprec.addr )
+ {
+ case S3ADDR_PLUG:
+ memcpy(tmpbuf, buf+S3PLUG_ITEMCODE_TXTOFFSET, S3PLUG_ITEMCODE_TXTLEN);
+ tmpbuf[S3PLUG_ITEMCODE_TXTLEN] = '\0';
+ s3plug[ns3plug].itemcode = simple_strtoul(tmpbuf,NULL,16);
+ s3plug[ns3plug].itemcode = bswap_32(s3plug[ns3plug].itemcode);
+
+ memcpy(tmpbuf, buf+S3PLUG_ADDR_TXTOFFSET, S3PLUG_ADDR_TXTLEN);
+ tmpbuf[S3PLUG_ADDR_TXTLEN] = '\0';
+ s3plug[ns3plug].addr = simple_strtoul(tmpbuf,NULL,16);
+ s3plug[ns3plug].addr = bswap_32(s3plug[ns3plug].addr);
+
+ memcpy(tmpbuf, buf+S3PLUG_LEN_TXTOFFSET, S3PLUG_LEN_TXTLEN);
+ tmpbuf[S3PLUG_LEN_TXTLEN] = '\0';
+ s3plug[ns3plug].len = simple_strtoul(tmpbuf,NULL,16);
+ s3plug[ns3plug].len = bswap_32(s3plug[ns3plug].len);
+
+ pr_debug(" S3 plugrec, line=%d "
+ "itemcode=0x%04x addr=0x%08x len=%d\n",
+ line,
+ s3plug[ns3plug].itemcode,
+ s3plug[ns3plug].addr,
+ s3plug[ns3plug].len);
+
+ ns3plug++;
+ if ( ns3plug == S3PLUG_MAX ) {
+ printk(KERN_ERR "S3 plugrec limit reached - aborting\n");
+ return 1;
+ }
+ break;
+ case S3ADDR_CRC:
+ memcpy(tmpbuf, buf+S3CRC_ADDR_TXTOFFSET, S3CRC_ADDR_TXTLEN);
+ tmpbuf[S3CRC_ADDR_TXTLEN] = '\0';
+ s3crc[ns3crc].addr = simple_strtoul(tmpbuf,NULL,16);
+ s3crc[ns3crc].addr = bswap_32(s3crc[ns3crc].addr);
+
+ memcpy(tmpbuf, buf+S3CRC_LEN_TXTOFFSET, S3CRC_LEN_TXTLEN);
+ tmpbuf[S3CRC_LEN_TXTLEN] = '\0';
+ s3crc[ns3crc].len = simple_strtoul(tmpbuf,NULL,16);
+ s3crc[ns3crc].len = bswap_32(s3crc[ns3crc].len);
+
+ memcpy(tmpbuf, buf+S3CRC_DOWRITE_TXTOFFSET, S3CRC_DOWRITE_TXTLEN);
+ tmpbuf[S3CRC_DOWRITE_TXTLEN] = '\0';
+ s3crc[ns3crc].dowrite = simple_strtoul(tmpbuf,NULL,16);
+ s3crc[ns3crc].dowrite = bswap_32(s3crc[ns3crc].dowrite);
+
+ pr_debug(" S3 crcrec, line=%d "
+ "addr=0x%08x len=%d write=0x%08x\n",
+ line,
+ s3crc[ns3crc].addr,
+ s3crc[ns3crc].len,
+ s3crc[ns3crc].dowrite);
+ ns3crc++;
+ if ( ns3crc == S3CRC_MAX ) {
+ printk(KERN_ERR "S3 crcrec limit reached - aborting\n");
+ return 1;
+ }
+ break;
+ case S3ADDR_INFO:
+ memcpy(tmpbuf, buf+S3INFO_LEN_TXTOFFSET, S3INFO_LEN_TXTLEN);
+ tmpbuf[S3INFO_LEN_TXTLEN] = '\0';
+ s3info[ns3info].len = simple_strtoul(tmpbuf,NULL,16);
+ s3info[ns3info].len = bswap_16(s3info[ns3info].len);
+
+ memcpy(tmpbuf, buf+S3INFO_TYPE_TXTOFFSET, S3INFO_TYPE_TXTLEN);
+ tmpbuf[S3INFO_TYPE_TXTLEN] = '\0';
+ s3info[ns3info].type = simple_strtoul(tmpbuf,NULL,16);
+ s3info[ns3info].type = bswap_16(s3info[ns3info].type);
+
+ pr_debug(" S3 inforec, line=%d "
+ "len=0x%04x type=0x%04x\n",
+ line,
+ s3info[ns3info].len,
+ s3info[ns3info].type);
+ if ( ((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info) ) {
+ printk(KERN_ERR " S3 inforec length too long - aborting\n");
+ return 1;
+ }
+
+ tmpinfo = (u16*)&(s3info[ns3info].info.version);
+ for (i = 0; i < s3info[ns3info].len - 1; i++) {
+ memcpy( tmpbuf, buf+S3INFO_DATA_TXTOFFSET+(i*4), 4);
+ tmpbuf[4] = '\0';
+ tmpinfo[i] = simple_strtoul(tmpbuf,NULL,16);
+ tmpinfo[i] = bswap_16(tmpinfo[i]);
+ }
+ pr_debug(" info=");
+ for (i = 0; i < s3info[ns3info].len - 1; i++) {
+ pr_debug("%04x ", tmpinfo[i]);
+ }
+ pr_debug("\n");
+
+ ns3info++;
+ if ( ns3info == S3INFO_MAX ) {
+ printk(KERN_ERR "S3 inforec limit reached - aborting\n");
+ return 1;
+ }
+ break;
+ default: /* Data record */
+ s3data[ns3data].addr = tmprec.addr;
+ s3data[ns3data].len = tmprec.len;
+ s3data[ns3data].checksum = tmprec.checksum;
+ s3data[ns3data].data = kmalloc(tmprec.len, GFP_KERNEL);
+ for ( i = 0; i < tmprec.len; i++) {
+ memcpy(tmpbuf, buf+S3DATA_TXTOFFSET+(i*2), 2);
+ tmpbuf[2] = '\0';
+ s3data[ns3data].data[i] = simple_strtoul(tmpbuf, NULL, 16);
+ }
+ ns3data++;
+ if ( ns3data == S3DATA_MAX ) {
+ printk(KERN_ERR "S3 datarec limit reached - aborting\n");
+ return 1;
+ }
+ break;
+ }
+ } else {
+ printk(KERN_WARNING "%d warning: Unknown S-record detected.\n", line);
+ }
+ }
+ return result;
+}
+
+
+/*----------------------------------------------------------------
+* s3datarec_compare
+*
+* Comparison function for sort().
+*
+* Arguments:
+* p1 ptr to the first item
+* p2 ptr to the second item
+* Returns:
+* 0 items are equal
+* <0 p1 < p2
+* >0 p1 > p2
+----------------------------------------------------------------*/
+int s3datarec_compare(const void *p1, const void *p2)
+{
+ const s3datarec_t *s1 = p1;
+ const s3datarec_t *s2 = p2;
+ if ( s1->addr == s2->addr ) return 0;
+ if ( s1->addr < s2->addr ) return -1;
+ return 1;
+}
+
+
+/*----------------------------------------------------------------
+* writeimage
+*
+* Takes the chunks, builds p80211 messages and sends them down
+* to the driver for writing to the card.
+*
+* Arguments:
+* wlandev device
+* fchunk Array of image chunks
+* nfchunks Number of image chunks
+*
+* Returns:
+* 0 success
+* ~0 failure
+----------------------------------------------------------------*/
+int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, unsigned int nfchunks)
+{
+ int result = 0;
+ p80211msg_p2req_ramdl_state_t rstatemsg;
+ p80211msg_p2req_ramdl_write_t rwritemsg;
+ p80211msg_t *msgp;
+ u32 resultcode;
+ int i;
+ int j;
+ unsigned int nwrites;
+ u32 curroff;
+ u32 currlen;
+ u32 currdaddr;
+
+ /* Initialize the messages */
+ memset(&rstatemsg, 0, sizeof(rstatemsg));
+ strcpy(rstatemsg.devname, wlandev->name);
+ rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
+ rstatemsg.msglen = sizeof(rstatemsg);
+ rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
+ rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
+ rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
+ rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
+ rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
+ rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+ rstatemsg.enable.len = sizeof(u32);
+ rstatemsg.exeaddr.len = sizeof(u32);
+ rstatemsg.resultcode.len = sizeof(u32);
+
+ memset(&rwritemsg, 0, sizeof(rwritemsg));
+ strcpy(rwritemsg.devname, wlandev->name);
+ rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
+ rwritemsg.msglen = sizeof(rwritemsg);
+ rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
+ rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
+ rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
+ rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
+ rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
+ rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
+ rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
+ rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+ rwritemsg.addr.len = sizeof(u32);
+ rwritemsg.len.len = sizeof(u32);
+ rwritemsg.data.len = WRITESIZE_MAX;
+ rwritemsg.resultcode.len = sizeof(u32);
+
+ /* Send xxx_state(enable) */
+ pr_debug("Sending dl_state(enable) message.\n");
+ rstatemsg.enable.data = P80211ENUM_truth_true;
+ rstatemsg.exeaddr.data = startaddr;
+
+ msgp = (p80211msg_t*)&rstatemsg;
+ result = prism2mgmt_ramdl_state(wlandev, msgp);
+ if ( result ) {
+ printk(KERN_ERR
+ "writeimage state enable failed w/ result=%d, "
+ "aborting download\n", result);
+ return result;
+ }
+ resultcode = rstatemsg.resultcode.data;
+ if ( resultcode != P80211ENUM_resultcode_success ) {
+ printk(KERN_ERR
+ "writeimage()->xxxdl_state msg indicates failure, "
+ "w/ resultcode=%d, aborting download.\n",
+ resultcode);
+ return 1;
+ }
+
+ /* Now, loop through the data chunks and send WRITESIZE_MAX data */
+ for ( i = 0; i < nfchunks; i++) {
+ nwrites = fchunk[i].len / WRITESIZE_MAX;
+ nwrites += (fchunk[i].len % WRITESIZE_MAX) ? 1 : 0;
+ curroff = 0;
+ for ( j = 0; j < nwrites; j++) {
+ currlen =
+ (fchunk[i].len - (WRITESIZE_MAX * j)) > WRITESIZE_MAX ?
+ WRITESIZE_MAX :
+ (fchunk[i].len - (WRITESIZE_MAX * j));
+ curroff = j * WRITESIZE_MAX;
+ currdaddr = fchunk[i].addr + curroff;
+ /* Setup the message */
+ rwritemsg.addr.data = currdaddr;
+ rwritemsg.len.data = currlen;
+ memcpy(rwritemsg.data.data,
+ fchunk[i].data + curroff,
+ currlen);
+
+ /* Send flashdl_write(pda) */
+ pr_debug("Sending xxxdl_write message addr=%06x len=%d.\n",
+ currdaddr, currlen);
+
+ msgp = (p80211msg_t*)&rwritemsg;
+ result = prism2mgmt_ramdl_write(wlandev, msgp);
+
+ /* Check the results */
+ if ( result ) {
+ printk(KERN_ERR
+ "writeimage chunk write failed w/ result=%d, "
+ "aborting download\n", result);
+ return result;
+ }
+ resultcode = rstatemsg.resultcode.data;
+ if ( resultcode != P80211ENUM_resultcode_success ) {
+ printk(KERN_ERR
+ "writeimage()->xxxdl_write msg indicates failure, "
+ "w/ resultcode=%d, aborting download.\n",
+ resultcode);
+ return 1;
+ }
+
+ }
+ }
+
+ /* Send xxx_state(disable) */
+ pr_debug("Sending dl_state(disable) message.\n");
+ rstatemsg.enable.data = P80211ENUM_truth_false;
+ rstatemsg.exeaddr.data = 0;
+
+ msgp = (p80211msg_t*)&rstatemsg;
+ result = prism2mgmt_ramdl_state(wlandev, msgp);
+ if ( result ) {
+ printk(KERN_ERR
+ "writeimage state disable failed w/ result=%d, "
+ "aborting download\n", result);
+ return result;
+ }
+ resultcode = rstatemsg.resultcode.data;
+ if ( resultcode != P80211ENUM_resultcode_success ) {
+ printk(KERN_ERR
+ "writeimage()->xxxdl_state msg indicates failure, "
+ "w/ resultcode=%d, aborting download.\n",
+ resultcode);
+ return 1;
+ }
+ return result;
+}
+
+
+
+int validate_identity(void)
+{
+ int i;
+ int result = 1;
+
+ pr_debug("NIC ID: %#x v%d.%d.%d\n",
+ nicid.id,
+ nicid.major,
+ nicid.minor,
+ nicid.variant);
+ pr_debug("MFI ID: %#x v%d %d->%d\n",
+ rfid.id,
+ rfid.variant,
+ rfid.bottom,
+ rfid.top);
+ pr_debug("CFI ID: %#x v%d %d->%d\n",
+ macid.id,
+ macid.variant,
+ macid.bottom,
+ macid.top);
+ pr_debug("PRI ID: %#x v%d %d->%d\n",
+ priid.id,
+ priid.variant,
+ priid.bottom,
+ priid.top);
+
+ for (i = 0 ; i < ns3info ; i ++) {
+ switch (s3info[i].type) {
+ case 1:
+ pr_debug("Version: ID %#x %d.%d.%d\n",
+ s3info[i].info.version.id,
+ s3info[i].info.version.major,
+ s3info[i].info.version.minor,
+ s3info[i].info.version.variant);
+ break;
+ case 2:
+ pr_debug("Compat: Role %#x Id %#x v%d %d->%d\n",
+ s3info[i].info.compat.role,
+ s3info[i].info.compat.id,
+ s3info[i].info.compat.variant,
+ s3info[i].info.compat.bottom,
+ s3info[i].info.compat.top);
+
+ /* MAC compat range */
+ if ((s3info[i].info.compat.role == 1) &&
+ (s3info[i].info.compat.id == 2)) {
+ if (s3info[i].info.compat.variant !=
+ macid.variant) {
+ result = 2;
+ }
+ }
+
+ /* PRI compat range */
+ if ((s3info[i].info.compat.role == 1) &&
+ (s3info[i].info.compat.id == 3)) {
+ if ((s3info[i].info.compat.bottom > priid.top) ||
+ (s3info[i].info.compat.top < priid.bottom)){
+ result = 3;
+ }
+ }
+ /* SEC compat range */
+ if ((s3info[i].info.compat.role == 1) &&
+ (s3info[i].info.compat.id == 4)) {
+
+ }
+
+ break;
+ case 3:
+ pr_debug("Seq: %#x\n", s3info[i].info.buildseq);
+
+ break;
+ case 4:
+ pr_debug("Platform: ID %#x %d.%d.%d\n",
+ s3info[i].info.version.id,
+ s3info[i].info.version.major,
+ s3info[i].info.version.minor,
+ s3info[i].info.version.variant);
+
+ if (nicid.id != s3info[i].info.version.id)
+ continue;
+ if (nicid.major != s3info[i].info.version.major)
+ continue;
+ if (nicid.minor != s3info[i].info.version.minor)
+ continue;
+ if ((nicid.variant != s3info[i].info.version.variant) &&
+ (nicid.id != 0x8008))
+ continue;
+
+ if (result != 2)
+ result = 0;
+ break;
+ case 0x8001:
+ pr_debug("name inforec len %d\n", s3info[i].len);
+
+ break;
+ default:
+ pr_debug("Unknown inforec type %d\n", s3info[i].type);
+ }
+ }
+ // walk through
+
+ return result;
+}
diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
index e7a7939b4280..d2e5fccb629f 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -1096,7 +1096,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Disable monitor mode */
result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to disable monitor mode, result=%d\n",
result);
goto failed;
@@ -1104,7 +1104,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Disable port 0 */
result = hfa384x_drvr_disable(hw, 0);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to disable port 0 after sniffing, result=%d\n",
result);
goto failed;
@@ -1117,7 +1117,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
HFA384x_RID_CNFWEPFLAGS,
hw->presniff_wepflags);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to restore wepflags=0x%04x, result=%d\n",
hw->presniff_wepflags, result);
goto failed;
@@ -1130,7 +1130,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
HFA384x_RID_CNFPORTTYPE,
word);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to restore porttype, result=%d\n",
result);
goto failed;
@@ -1139,7 +1139,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Enable the port */
result = hfa384x_drvr_enable(hw, 0);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to enable port to presniff setting, result=%d\n",
result);
goto failed;
@@ -1164,7 +1164,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
&(hw->
presniff_port_type));
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to read porttype, result=%d\n",
result);
goto failed;
@@ -1175,7 +1175,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
&(hw->
presniff_wepflags));
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to read wepflags, result=%d\n",
result);
goto failed;
@@ -1183,7 +1183,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
hfa384x_drvr_stop(hw);
result = hfa384x_drvr_start(hw);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to restart the card for sniffing, result=%d\n",
result);
goto failed;
@@ -1192,7 +1192,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Disable the port */
result = hfa384x_drvr_disable(hw, 0);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to enable port for sniffing, result=%d\n",
result);
goto failed;
@@ -1210,7 +1210,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
hw->sniff_channel = word;
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to set channel %d, result=%d\n",
word, result);
goto failed;
@@ -1224,7 +1224,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
HFA384x_RID_CNFPORTTYPE,
word);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to set porttype %d, result=%d\n",
word, result);
goto failed;
@@ -1243,7 +1243,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
}
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to set wepflags=0x%04x, result=%d\n",
word, result);
goto failed;
@@ -1269,7 +1269,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Enable the port */
result = hfa384x_drvr_enable(hw, 0);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to enable port for sniffing, result=%d\n",
result);
goto failed;
@@ -1277,7 +1277,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Enable monitor mode */
result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"failed to enable monitor mode, result=%d\n",
result);
goto failed;
diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c
index 5a6ba86009df..7a082c17f54a 100644
--- a/drivers/staging/wlan-ng/prism2mib.c
+++ b/drivers/staging/wlan-ng/prism2mib.c
@@ -50,7 +50,6 @@
* --------------------------------------------------------------------
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 9d57f82f4a25..573e93ae7d42 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1188,7 +1188,7 @@ static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
chinforesult->active =
le16_to_cpu(inf->info.chinforesult.result[n].
active);
- printk(KERN_DEBUG
+ pr_debug(
"chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
channel + 1,
chinforesult->
@@ -1276,7 +1276,7 @@ void prism2sta_processing_defer(struct work_struct *data)
wlandev->bssid,
WLAN_BSSID_LEN);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_CURRENTBSSID, result);
goto failed;
@@ -1286,7 +1286,7 @@ void prism2sta_processing_defer(struct work_struct *data)
HFA384x_RID_CURRENTSSID,
&ssid, sizeof(ssid));
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_CURRENTSSID, result);
goto failed;
@@ -1300,7 +1300,7 @@ void prism2sta_processing_defer(struct work_struct *data)
HFA384x_RID_PORTSTATUS,
&portstatus);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_PORTSTATUS, result);
goto failed;
@@ -1366,7 +1366,7 @@ void prism2sta_processing_defer(struct work_struct *data)
HFA384x_RID_CURRENTBSSID,
wlandev->bssid, WLAN_BSSID_LEN);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_CURRENTBSSID, result);
goto failed;
@@ -1376,7 +1376,7 @@ void prism2sta_processing_defer(struct work_struct *data)
HFA384x_RID_CURRENTSSID,
&ssid, sizeof(ssid));
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_CURRENTSSID, result);
goto failed;
@@ -2030,7 +2030,7 @@ void prism2sta_commsqual_defer(struct work_struct *data)
HFA384x_RID_CURRENTBSSID,
wlandev->bssid, WLAN_BSSID_LEN);
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_CURRENTBSSID, result);
goto done;
@@ -2040,7 +2040,7 @@ void prism2sta_commsqual_defer(struct work_struct *data)
HFA384x_RID_CURRENTSSID,
&ssid, sizeof(ssid));
if (result) {
- printk(KERN_DEBUG
+ pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
HFA384x_RID_CURRENTSSID, result);
goto done;
diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c
index d8a12982135d..d9c6f5a97cf0 100644
--- a/drivers/staging/wlan-ng/prism2usb.c
+++ b/drivers/staging/wlan-ng/prism2usb.c
@@ -2,6 +2,7 @@
#include "prism2mgmt.c"
#include "prism2mib.c"
#include "prism2sta.c"
+#include "prism2fw.c"
#define PRISM_USB_DEVICE(vid, pid, name) \
USB_DEVICE(vid, pid), \
@@ -153,15 +154,16 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
wlandev->msdstate = WLAN_MSD_HWPRESENT;
+ /* Try and load firmware, then enable card before we register */
+ prism2_fwtry(dev, wlandev);
+ prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable);
+
if (register_wlandev(wlandev) != 0) {
printk(KERN_ERR "%s: register_wlandev() failed.\n", dev_info);
result = -EIO;
goto failed;
}
-/* enable the card */
- prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable);
-
goto done;
failed:
@@ -170,7 +172,6 @@ failed:
wlandev = NULL;
done:
- p80211_allow_ioctls(wlandev);
usb_set_intfdata(interface, wlandev);
return result;
}
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 5e38ba10a3a9..0a69672097a8 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -417,7 +417,7 @@ static LIST_HEAD(thermal_hwmon_list);
static ssize_t
name_show(struct device *dev, struct device_attribute *attr, char *buf)
{
- struct thermal_hwmon_device *hwmon = dev->driver_data;
+ struct thermal_hwmon_device *hwmon = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", hwmon->type);
}
static DEVICE_ATTR(name, 0444, name_show, NULL);
@@ -488,7 +488,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
result = PTR_ERR(hwmon->device);
goto free_mem;
}
- hwmon->device->driver_data = hwmon;
+ dev_set_drvdata(hwmon->device, hwmon);
result = device_create_file(hwmon->device, &dev_attr_name);
if (result)
goto unregister_hwmon_device;
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 5eee3f82be5d..dcd49f1e96d0 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -64,6 +64,7 @@ config USB_ARCH_HAS_EHCI
config USB
tristate "Support for Host-side USB"
depends on USB_ARCH_HAS_HCD
+ select NLS # for UTF-8 strings
---help---
Universal Serial Bus (USB) is a specification for a serial bus
subsystem which offers higher speeds and more features than the
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 0716cdb44cd8..f752f0da8cf4 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_USB_ISP1760_HCD) += host/
obj-$(CONFIG_USB_OHCI_HCD) += host/
obj-$(CONFIG_USB_UHCI_HCD) += host/
obj-$(CONFIG_USB_FHCI_HCD) += host/
+obj-$(CONFIG_USB_XHCI_HCD) += host/
obj-$(CONFIG_USB_SL811_HCD) += host/
obj-$(CONFIG_USB_U132_HCD) += host/
obj-$(CONFIG_USB_R8A66597_HCD) += host/
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0a69c0977e3f..ddeb69192537 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -16,7 +16,8 @@
* v0.9 - thorough cleaning, URBification, almost a rewrite
* v0.10 - some more cleanups
* v0.11 - fixed flow control, read error doesn't stop reads
- * v0.12 - added TIOCM ioctls, added break handling, made struct acm kmalloced
+ * v0.12 - added TIOCM ioctls, added break handling, made struct acm
+ * kmalloced
* v0.13 - added termios, added hangup
* v0.14 - sized down struct acm
* v0.15 - fixed flow control again - characters could be lost
@@ -62,7 +63,7 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/mutex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/cdc.h>
#include <asm/byteorder.h>
@@ -87,7 +88,10 @@ static struct acm *acm_table[ACM_TTY_MINORS];
static DEFINE_MUTEX(open_mutex);
-#define ACM_READY(acm) (acm && acm->dev && acm->used)
+#define ACM_READY(acm) (acm && acm->dev && acm->port.count)
+
+static const struct tty_port_operations acm_port_ops = {
+};
#ifdef VERBOSE_DEBUG
#define verbose 1
@@ -99,13 +103,15 @@ static DEFINE_MUTEX(open_mutex);
* Functions for ACM control messages.
*/
-static int acm_ctrl_msg(struct acm *acm, int request, int value, void *buf, int len)
+static int acm_ctrl_msg(struct acm *acm, int request, int value,
+ void *buf, int len)
{
int retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0),
request, USB_RT_ACM, value,
acm->control->altsetting[0].desc.bInterfaceNumber,
buf, len, 5000);
- dbg("acm_control_msg: rq: 0x%02x val: %#x len: %#x result: %d", request, value, len, retval);
+ dbg("acm_control_msg: rq: 0x%02x val: %#x len: %#x result: %d",
+ request, value, len, retval);
return retval < 0 ? retval : 0;
}
@@ -150,9 +156,8 @@ static int acm_wb_is_avail(struct acm *acm)
n = ACM_NW;
spin_lock_irqsave(&acm->write_lock, flags);
- for (i = 0; i < ACM_NW; i++) {
+ for (i = 0; i < ACM_NW; i++)
n -= acm->wb[i].use;
- }
spin_unlock_irqrestore(&acm->write_lock, flags);
return n;
}
@@ -183,7 +188,8 @@ static int acm_start_wb(struct acm *acm, struct acm_wb *wb)
wb->urb->transfer_buffer_length = wb->len;
wb->urb->dev = acm->dev;
- if ((rc = usb_submit_urb(wb->urb, GFP_ATOMIC)) < 0) {
+ rc = usb_submit_urb(wb->urb, GFP_ATOMIC);
+ if (rc < 0) {
dbg("usb_submit_urb(write bulk) failed: %d", rc);
acm_write_done(acm, wb);
}
@@ -262,6 +268,7 @@ static void acm_ctrl_irq(struct urb *urb)
{
struct acm *acm = urb->context;
struct usb_cdc_notification *dr = urb->transfer_buffer;
+ struct tty_struct *tty;
unsigned char *data;
int newctrl;
int retval;
@@ -287,40 +294,45 @@ static void acm_ctrl_irq(struct urb *urb)
data = (unsigned char *)(dr + 1);
switch (dr->bNotificationType) {
+ case USB_CDC_NOTIFY_NETWORK_CONNECTION:
+ dbg("%s network", dr->wValue ?
+ "connected to" : "disconnected from");
+ break;
- case USB_CDC_NOTIFY_NETWORK_CONNECTION:
-
- dbg("%s network", dr->wValue ? "connected to" : "disconnected from");
- break;
-
- case USB_CDC_NOTIFY_SERIAL_STATE:
-
- newctrl = get_unaligned_le16(data);
+ case USB_CDC_NOTIFY_SERIAL_STATE:
+ tty = tty_port_tty_get(&acm->port);
+ newctrl = get_unaligned_le16(data);
- if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
+ if (tty) {
+ if (!acm->clocal &&
+ (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
dbg("calling hangup");
- tty_hangup(acm->tty);
+ tty_hangup(tty);
}
+ tty_kref_put(tty);
+ }
- acm->ctrlin = newctrl;
-
- dbg("input control lines: dcd%c dsr%c break%c ring%c framing%c parity%c overrun%c",
- acm->ctrlin & ACM_CTRL_DCD ? '+' : '-', acm->ctrlin & ACM_CTRL_DSR ? '+' : '-',
- acm->ctrlin & ACM_CTRL_BRK ? '+' : '-', acm->ctrlin & ACM_CTRL_RI ? '+' : '-',
- acm->ctrlin & ACM_CTRL_FRAMING ? '+' : '-', acm->ctrlin & ACM_CTRL_PARITY ? '+' : '-',
- acm->ctrlin & ACM_CTRL_OVERRUN ? '+' : '-');
+ acm->ctrlin = newctrl;
+ dbg("input control lines: dcd%c dsr%c break%c ring%c framing%c parity%c overrun%c",
+ acm->ctrlin & ACM_CTRL_DCD ? '+' : '-',
+ acm->ctrlin & ACM_CTRL_DSR ? '+' : '-',
+ acm->ctrlin & ACM_CTRL_BRK ? '+' : '-',
+ acm->ctrlin & ACM_CTRL_RI ? '+' : '-',
+ acm->ctrlin & ACM_CTRL_FRAMING ? '+' : '-',
+ acm->ctrlin & ACM_CTRL_PARITY ? '+' : '-',
+ acm->ctrlin & ACM_CTRL_OVERRUN ? '+' : '-');
break;
- default:
- dbg("unknown notification %d received: index %d len %d data0 %d data1 %d",
- dr->bNotificationType, dr->wIndex,
- dr->wLength, data[0], data[1]);
- break;
+ default:
+ dbg("unknown notification %d received: index %d len %d data0 %d data1 %d",
+ dr->bNotificationType, dr->wIndex,
+ dr->wLength, data[0], data[1]);
+ break;
}
exit:
usb_mark_last_busy(acm->dev);
- retval = usb_submit_urb (urb, GFP_ATOMIC);
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval)
dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with "
"result %d", __func__, retval);
@@ -371,15 +383,14 @@ static void acm_rx_tasklet(unsigned long _acm)
{
struct acm *acm = (void *)_acm;
struct acm_rb *buf;
- struct tty_struct *tty = acm->tty;
+ struct tty_struct *tty;
struct acm_ru *rcv;
unsigned long flags;
unsigned char throttled;
dbg("Entering acm_rx_tasklet");
- if (!ACM_READY(acm))
- {
+ if (!ACM_READY(acm)) {
dbg("acm_rx_tasklet: ACM not ready");
return;
}
@@ -387,12 +398,13 @@ static void acm_rx_tasklet(unsigned long _acm)
spin_lock_irqsave(&acm->throttle_lock, flags);
throttled = acm->throttle;
spin_unlock_irqrestore(&acm->throttle_lock, flags);
- if (throttled)
- {
+ if (throttled) {
dbg("acm_rx_tasklet: throttled");
return;
}
+ tty = tty_port_tty_get(&acm->port);
+
next_buffer:
spin_lock_irqsave(&acm->read_lock, flags);
if (list_empty(&acm->filled_read_bufs)) {
@@ -406,20 +418,22 @@ next_buffer:
dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size);
- tty_buffer_request_room(tty, buf->size);
- spin_lock_irqsave(&acm->throttle_lock, flags);
- throttled = acm->throttle;
- spin_unlock_irqrestore(&acm->throttle_lock, flags);
- if (!throttled)
- tty_insert_flip_string(tty, buf->base, buf->size);
- tty_flip_buffer_push(tty);
-
- if (throttled) {
- dbg("Throttling noticed");
- spin_lock_irqsave(&acm->read_lock, flags);
- list_add(&buf->list, &acm->filled_read_bufs);
- spin_unlock_irqrestore(&acm->read_lock, flags);
- return;
+ if (tty) {
+ spin_lock_irqsave(&acm->throttle_lock, flags);
+ throttled = acm->throttle;
+ spin_unlock_irqrestore(&acm->throttle_lock, flags);
+ if (!throttled) {
+ tty_buffer_request_room(tty, buf->size);
+ tty_insert_flip_string(tty, buf->base, buf->size);
+ tty_flip_buffer_push(tty);
+ } else {
+ tty_kref_put(tty);
+ dbg("Throttling noticed");
+ spin_lock_irqsave(&acm->read_lock, flags);
+ list_add(&buf->list, &acm->filled_read_bufs);
+ spin_unlock_irqrestore(&acm->read_lock, flags);
+ return;
+ }
}
spin_lock_irqsave(&acm->read_lock, flags);
@@ -428,6 +442,8 @@ next_buffer:
goto next_buffer;
urbs:
+ tty_kref_put(tty);
+
while (!list_empty(&acm->spare_read_bufs)) {
spin_lock_irqsave(&acm->read_lock, flags);
if (list_empty(&acm->spare_read_urbs)) {
@@ -454,10 +470,11 @@ urbs:
rcv->urb->transfer_dma = buf->dma;
rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
- /* This shouldn't kill the driver as unsuccessful URBs are returned to the
- free-urbs-pool and resubmited ASAP */
+ /* This shouldn't kill the driver as unsuccessful URBs are
+ returned to the free-urbs-pool and resubmited ASAP */
spin_lock_irqsave(&acm->read_lock, flags);
- if (acm->susp_count || usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
+ if (acm->susp_count ||
+ usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
list_add(&buf->list, &acm->spare_read_bufs);
list_add(&rcv->list, &acm->spare_read_urbs);
acm->processing = 0;
@@ -499,11 +516,14 @@ static void acm_write_bulk(struct urb *urb)
static void acm_softint(struct work_struct *work)
{
struct acm *acm = container_of(work, struct acm, work);
+ struct tty_struct *tty;
dev_vdbg(&acm->data->dev, "tx work\n");
if (!ACM_READY(acm))
return;
- tty_wakeup(acm->tty);
+ tty = tty_port_tty_get(&acm->port);
+ tty_wakeup(tty);
+ tty_kref_put(tty);
}
static void acm_waker(struct work_struct *waker)
@@ -543,8 +563,9 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
rv = 0;
set_bit(TTY_NO_WRITE_SPLIT, &tty->flags);
+
tty->driver_data = acm;
- acm->tty = tty;
+ tty_port_tty_set(&acm->port, tty);
if (usb_autopm_get_interface(acm->control) < 0)
goto early_bail;
@@ -552,11 +573,10 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
acm->control->needs_remote_wakeup = 1;
mutex_lock(&acm->mutex);
- if (acm->used++) {
+ if (acm->port.count++) {
usb_autopm_put_interface(acm->control);
goto done;
- }
-
+ }
acm->ctrlurb->dev = acm->dev;
if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) {
@@ -567,22 +587,22 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS) &&
(acm->ctrl_caps & USB_CDC_CAP_LINE))
goto full_bailout;
+
usb_autopm_put_interface(acm->control);
INIT_LIST_HEAD(&acm->spare_read_urbs);
INIT_LIST_HEAD(&acm->spare_read_bufs);
INIT_LIST_HEAD(&acm->filled_read_bufs);
- for (i = 0; i < acm->rx_buflimit; i++) {
+
+ for (i = 0; i < acm->rx_buflimit; i++)
list_add(&(acm->ru[i].list), &acm->spare_read_urbs);
- }
- for (i = 0; i < acm->rx_buflimit; i++) {
+ for (i = 0; i < acm->rx_buflimit; i++)
list_add(&(acm->rb[i].list), &acm->spare_read_bufs);
- }
acm->throttle = 0;
tasklet_schedule(&acm->urb_task);
-
+ rv = tty_port_block_til_ready(&acm->port, tty, filp);
done:
mutex_unlock(&acm->mutex);
err_out:
@@ -593,16 +613,17 @@ full_bailout:
usb_kill_urb(acm->ctrlurb);
bail_out:
usb_autopm_put_interface(acm->control);
- acm->used--;
+ acm->port.count--;
mutex_unlock(&acm->mutex);
early_bail:
mutex_unlock(&open_mutex);
+ tty_port_tty_set(&acm->port, NULL);
return -EIO;
}
static void acm_tty_unregister(struct acm *acm)
{
- int i,nr;
+ int i, nr;
nr = acm->rx_buflimit;
tty_unregister_device(acm_tty_driver, acm->minor);
@@ -619,41 +640,56 @@ static void acm_tty_unregister(struct acm *acm)
static int acm_tty_chars_in_buffer(struct tty_struct *tty);
+static void acm_port_down(struct acm *acm, int drain)
+{
+ int i, nr = acm->rx_buflimit;
+ mutex_lock(&open_mutex);
+ if (acm->dev) {
+ usb_autopm_get_interface(acm->control);
+ acm_set_control(acm, acm->ctrlout = 0);
+ /* try letting the last writes drain naturally */
+ if (drain) {
+ wait_event_interruptible_timeout(acm->drain_wait,
+ (ACM_NW == acm_wb_is_avail(acm)) || !acm->dev,
+ ACM_CLOSE_TIMEOUT * HZ);
+ }
+ usb_kill_urb(acm->ctrlurb);
+ for (i = 0; i < ACM_NW; i++)
+ usb_kill_urb(acm->wb[i].urb);
+ for (i = 0; i < nr; i++)
+ usb_kill_urb(acm->ru[i].urb);
+ acm->control->needs_remote_wakeup = 0;
+ usb_autopm_put_interface(acm->control);
+ }
+ mutex_unlock(&open_mutex);
+}
+
+static void acm_tty_hangup(struct tty_struct *tty)
+{
+ struct acm *acm = tty->driver_data;
+ tty_port_hangup(&acm->port);
+ acm_port_down(acm, 0);
+}
+
static void acm_tty_close(struct tty_struct *tty, struct file *filp)
{
struct acm *acm = tty->driver_data;
- int i,nr;
- if (!acm || !acm->used)
+ /* Perform the closing process and see if we need to do the hardware
+ shutdown */
+ if (tty_port_close_start(&acm->port, tty, filp) == 0)
return;
-
- nr = acm->rx_buflimit;
+ acm_port_down(acm, 0);
+ tty_port_close_end(&acm->port, tty);
mutex_lock(&open_mutex);
- if (!--acm->used) {
- if (acm->dev) {
- usb_autopm_get_interface(acm->control);
- acm_set_control(acm, acm->ctrlout = 0);
-
- /* try letting the last writes drain naturally */
- wait_event_interruptible_timeout(acm->drain_wait,
- (ACM_NW == acm_wb_is_avail(acm))
- || !acm->dev,
- ACM_CLOSE_TIMEOUT * HZ);
-
- usb_kill_urb(acm->ctrlurb);
- for (i = 0; i < ACM_NW; i++)
- usb_kill_urb(acm->wb[i].urb);
- for (i = 0; i < nr; i++)
- usb_kill_urb(acm->ru[i].urb);
- acm->control->needs_remote_wakeup = 0;
- usb_autopm_put_interface(acm->control);
- } else
- acm_tty_unregister(acm);
- }
+ tty_port_tty_set(&acm->port, NULL);
+ if (!acm->dev)
+ acm_tty_unregister(acm);
mutex_unlock(&open_mutex);
}
-static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
+static int acm_tty_write(struct tty_struct *tty,
+ const unsigned char *buf, int count)
{
struct acm *acm = tty->driver_data;
int stat;
@@ -669,7 +705,8 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c
return 0;
spin_lock_irqsave(&acm->write_lock, flags);
- if ((wbn = acm_wb_alloc(acm)) < 0) {
+ wbn = acm_wb_alloc(acm);
+ if (wbn < 0) {
spin_unlock_irqrestore(&acm->write_lock, flags);
return 0;
}
@@ -681,7 +718,8 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c
wb->len = count;
spin_unlock_irqrestore(&acm->write_lock, flags);
- if ((stat = acm_write_start(acm, wbn)) < 0)
+ stat = acm_write_start(acm, wbn);
+ if (stat < 0)
return stat;
return count;
}
@@ -767,8 +805,10 @@ static int acm_tty_tiocmset(struct tty_struct *tty, struct file *file,
return -EINVAL;
newctrl = acm->ctrlout;
- set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
- clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
+ set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) |
+ (set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
+ clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) |
+ (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
newctrl = (newctrl & ~clear) | set;
@@ -777,7 +817,8 @@ static int acm_tty_tiocmset(struct tty_struct *tty, struct file *file,
return acm_set_control(acm, acm->ctrlout = newctrl);
}
-static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
+static int acm_tty_ioctl(struct tty_struct *tty, struct file *file,
+ unsigned int cmd, unsigned long arg)
{
struct acm *acm = tty->driver_data;
@@ -799,7 +840,8 @@ static const __u8 acm_tty_size[] = {
5, 6, 7, 8
};
-static void acm_tty_set_termios(struct tty_struct *tty, struct ktermios *termios_old)
+static void acm_tty_set_termios(struct tty_struct *tty,
+ struct ktermios *termios_old)
{
struct acm *acm = tty->driver_data;
struct ktermios *termios = tty->termios;
@@ -809,19 +851,23 @@ static void acm_tty_set_termios(struct tty_struct *tty, struct ktermios *termios
if (!ACM_READY(acm))
return;
+ /* FIXME: Needs to support the tty_baud interface */
+ /* FIXME: Broken on sparc */
newline.dwDTERate = cpu_to_le32p(acm_tty_speed +
(termios->c_cflag & CBAUD & ~CBAUDEX) + (termios->c_cflag & CBAUDEX ? 15 : 0));
newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0;
newline.bParityType = termios->c_cflag & PARENB ?
- (termios->c_cflag & PARODD ? 1 : 2) + (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
+ (termios->c_cflag & PARODD ? 1 : 2) +
+ (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4];
-
+ /* FIXME: Needs to clear unsupported bits in the termios */
acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
if (!newline.dwDTERate) {
newline.dwDTERate = acm->line.dwDTERate;
newctrl &= ~ACM_CTRL_DTR;
- } else newctrl |= ACM_CTRL_DTR;
+ } else
+ newctrl |= ACM_CTRL_DTR;
if (newctrl != acm->ctrlout)
acm_set_control(acm, acm->ctrlout = newctrl);
@@ -846,9 +892,8 @@ static void acm_write_buffers_free(struct acm *acm)
struct acm_wb *wb;
struct usb_device *usb_dev = interface_to_usbdev(acm->control);
- for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++) {
+ for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++)
usb_buffer_free(usb_dev, acm->writesize, wb->buf, wb->dmah);
- }
}
static void acm_read_buffers_free(struct acm *acm)
@@ -857,7 +902,8 @@ static void acm_read_buffers_free(struct acm *acm)
int i, n = acm->rx_buflimit;
for (i = 0; i < n; i++)
- usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
+ usb_buffer_free(usb_dev, acm->readsize,
+ acm->rb[i].base, acm->rb[i].dma);
}
/* Little helper: write buffers allocate */
@@ -882,8 +928,8 @@ static int acm_write_buffers_alloc(struct acm *acm)
return 0;
}
-static int acm_probe (struct usb_interface *intf,
- const struct usb_device_id *id)
+static int acm_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
{
struct usb_cdc_union_desc *union_header = NULL;
struct usb_cdc_country_functional_desc *cfd = NULL;
@@ -897,7 +943,7 @@ static int acm_probe (struct usb_interface *intf,
struct usb_device *usb_dev = interface_to_usbdev(intf);
struct acm *acm;
int minor;
- int ctrlsize,readsize;
+ int ctrlsize, readsize;
u8 *buf;
u8 ac_management_function = 0;
u8 call_management_function = 0;
@@ -917,7 +963,7 @@ static int acm_probe (struct usb_interface *intf,
control_interface = usb_ifnum_to_if(usb_dev, 0);
goto skip_normal_probe;
}
-
+
/* normal probing*/
if (!buffer) {
dev_err(&intf->dev, "Weird descriptor references\n");
@@ -925,8 +971,10 @@ static int acm_probe (struct usb_interface *intf,
}
if (!buflen) {
- if (intf->cur_altsetting->endpoint->extralen && intf->cur_altsetting->endpoint->extra) {
- dev_dbg(&intf->dev,"Seeking extra descriptors on endpoint\n");
+ if (intf->cur_altsetting->endpoint->extralen &&
+ intf->cur_altsetting->endpoint->extra) {
+ dev_dbg(&intf->dev,
+ "Seeking extra descriptors on endpoint\n");
buflen = intf->cur_altsetting->endpoint->extralen;
buffer = intf->cur_altsetting->endpoint->extra;
} else {
@@ -937,47 +985,43 @@ static int acm_probe (struct usb_interface *intf,
}
while (buflen > 0) {
- if (buffer [1] != USB_DT_CS_INTERFACE) {
+ if (buffer[1] != USB_DT_CS_INTERFACE) {
dev_err(&intf->dev, "skipping garbage\n");
goto next_desc;
}
- switch (buffer [2]) {
- case USB_CDC_UNION_TYPE: /* we've found it */
- if (union_header) {
- dev_err(&intf->dev, "More than one "
- "union descriptor, "
- "skipping ...\n");
- goto next_desc;
- }
- union_header = (struct usb_cdc_union_desc *)
- buffer;
- break;
- case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/
- cfd = (struct usb_cdc_country_functional_desc *)buffer;
- break;
- case USB_CDC_HEADER_TYPE: /* maybe check version */
- break; /* for now we ignore it */
- case USB_CDC_ACM_TYPE:
- ac_management_function = buffer[3];
- break;
- case USB_CDC_CALL_MANAGEMENT_TYPE:
- call_management_function = buffer[3];
- call_interface_num = buffer[4];
- if ((call_management_function & 3) != 3)
- dev_err(&intf->dev, "This device "
- "cannot do calls on its own. "
- "It is no modem.\n");
- break;
- default:
- /* there are LOTS more CDC descriptors that
- * could legitimately be found here.
- */
- dev_dbg(&intf->dev, "Ignoring descriptor: "
- "type %02x, length %d\n",
- buffer[2], buffer[0]);
- break;
+ switch (buffer[2]) {
+ case USB_CDC_UNION_TYPE: /* we've found it */
+ if (union_header) {
+ dev_err(&intf->dev, "More than one "
+ "union descriptor, skipping ...\n");
+ goto next_desc;
}
+ union_header = (struct usb_cdc_union_desc *)buffer;
+ break;
+ case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/
+ cfd = (struct usb_cdc_country_functional_desc *)buffer;
+ break;
+ case USB_CDC_HEADER_TYPE: /* maybe check version */
+ break; /* for now we ignore it */
+ case USB_CDC_ACM_TYPE:
+ ac_management_function = buffer[3];
+ break;
+ case USB_CDC_CALL_MANAGEMENT_TYPE:
+ call_management_function = buffer[3];
+ call_interface_num = buffer[4];
+ if ((call_management_function & 3) != 3)
+ dev_err(&intf->dev, "This device cannot do calls on its own. It is not a modem.\n");
+ break;
+ default:
+ /* there are LOTS more CDC descriptors that
+ * could legitimately be found here.
+ */
+ dev_dbg(&intf->dev, "Ignoring descriptor: "
+ "type %02x, length %d\n",
+ buffer[2], buffer[0]);
+ break;
+ }
next_desc:
buflen -= buffer[0];
buffer += buffer[0];
@@ -985,33 +1029,36 @@ next_desc:
if (!union_header) {
if (call_interface_num > 0) {
- dev_dbg(&intf->dev,"No union descriptor, using call management descriptor\n");
+ dev_dbg(&intf->dev, "No union descriptor, using call management descriptor\n");
data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_num));
control_interface = intf;
} else {
- dev_dbg(&intf->dev,"No union descriptor, giving up\n");
+ dev_dbg(&intf->dev,
+ "No union descriptor, giving up\n");
return -ENODEV;
}
} else {
control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0));
if (!control_interface || !data_interface) {
- dev_dbg(&intf->dev,"no interfaces\n");
+ dev_dbg(&intf->dev, "no interfaces\n");
return -ENODEV;
}
}
-
+
if (data_interface_num != call_interface_num)
- dev_dbg(&intf->dev,"Separate call control interface. That is not fully supported.\n");
+ dev_dbg(&intf->dev, "Separate call control interface. That is not fully supported.\n");
skip_normal_probe:
/*workaround for switched interfaces */
- if (data_interface->cur_altsetting->desc.bInterfaceClass != CDC_DATA_INTERFACE_TYPE) {
- if (control_interface->cur_altsetting->desc.bInterfaceClass == CDC_DATA_INTERFACE_TYPE) {
+ if (data_interface->cur_altsetting->desc.bInterfaceClass
+ != CDC_DATA_INTERFACE_TYPE) {
+ if (control_interface->cur_altsetting->desc.bInterfaceClass
+ == CDC_DATA_INTERFACE_TYPE) {
struct usb_interface *t;
- dev_dbg(&intf->dev,"Your device has switched interfaces.\n");
-
+ dev_dbg(&intf->dev,
+ "Your device has switched interfaces.\n");
t = control_interface;
control_interface = data_interface;
data_interface = t;
@@ -1023,9 +1070,9 @@ skip_normal_probe:
/* Accept probe requests only for the control interface */
if (intf != control_interface)
return -ENODEV;
-
+
if (usb_interface_claimed(data_interface)) { /* valid in this context */
- dev_dbg(&intf->dev,"The data interface isn't available\n");
+ dev_dbg(&intf->dev, "The data interface isn't available\n");
return -EBUSY;
}
@@ -1042,8 +1089,8 @@ skip_normal_probe:
if (!usb_endpoint_dir_in(epread)) {
/* descriptors are swapped */
struct usb_endpoint_descriptor *t;
- dev_dbg(&intf->dev,"The data interface has switched endpoints\n");
-
+ dev_dbg(&intf->dev,
+ "The data interface has switched endpoints\n");
t = epread;
epread = epwrite;
epwrite = t;
@@ -1056,13 +1103,15 @@ skip_normal_probe:
return -ENODEV;
}
- if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) {
+ acm = kzalloc(sizeof(struct acm), GFP_KERNEL);
+ if (acm == NULL) {
dev_dbg(&intf->dev, "out of memory (acm kzalloc)\n");
goto alloc_fail;
}
ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);
- readsize = le16_to_cpu(epread->wMaxPacketSize)* ( quirks == SINGLE_RX_URB ? 1 : 2);
+ readsize = le16_to_cpu(epread->wMaxPacketSize) *
+ (quirks == SINGLE_RX_URB ? 1 : 2);
acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20;
acm->control = control_interface;
acm->data = data_interface;
@@ -1082,6 +1131,8 @@ skip_normal_probe:
spin_lock_init(&acm->read_lock);
mutex_init(&acm->mutex);
acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
+ tty_port_init(&acm->port);
+ acm->port.ops = &acm_port_ops;
buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
if (!buf) {
@@ -1103,8 +1154,10 @@ skip_normal_probe:
for (i = 0; i < num_rx_buf; i++) {
struct acm_ru *rcv = &(acm->ru[i]);
- if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) {
- dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)\n");
+ rcv->urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (rcv->urb == NULL) {
+ dev_dbg(&intf->dev,
+ "out of memory (read urbs usb_alloc_urb)\n");
goto alloc_fail7;
}
@@ -1117,26 +1170,29 @@ skip_normal_probe:
rb->base = usb_buffer_alloc(acm->dev, readsize,
GFP_KERNEL, &rb->dma);
if (!rb->base) {
- dev_dbg(&intf->dev, "out of memory (read bufs usb_buffer_alloc)\n");
+ dev_dbg(&intf->dev,
+ "out of memory (read bufs usb_buffer_alloc)\n");
goto alloc_fail7;
}
}
- for(i = 0; i < ACM_NW; i++)
- {
+ for (i = 0; i < ACM_NW; i++) {
struct acm_wb *snd = &(acm->wb[i]);
- if (!(snd->urb = usb_alloc_urb(0, GFP_KERNEL))) {
- dev_dbg(&intf->dev, "out of memory (write urbs usb_alloc_urb)");
+ snd->urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (snd->urb == NULL) {
+ dev_dbg(&intf->dev,
+ "out of memory (write urbs usb_alloc_urb)");
goto alloc_fail7;
}
- usb_fill_bulk_urb(snd->urb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
- NULL, acm->writesize, acm_write_bulk, snd);
+ usb_fill_bulk_urb(snd->urb, usb_dev,
+ usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
+ NULL, acm->writesize, acm_write_bulk, snd);
snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
snd->instance = acm;
}
- usb_set_intfdata (intf, acm);
+ usb_set_intfdata(intf, acm);
i = device_create_file(&intf->dev, &dev_attr_bmCapabilities);
if (i < 0)
@@ -1147,7 +1203,8 @@ skip_normal_probe:
if (!acm->country_codes)
goto skip_countries;
acm->country_code_size = cfd->bLength - 4;
- memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0, cfd->bLength - 4);
+ memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0,
+ cfd->bLength - 4);
acm->country_rel_date = cfd->iCountryCodeRelDate;
i = device_create_file(&intf->dev, &dev_attr_wCountryCodes);
@@ -1156,7 +1213,8 @@ skip_normal_probe:
goto skip_countries;
}
- i = device_create_file(&intf->dev, &dev_attr_iCountryCodeRelDate);
+ i = device_create_file(&intf->dev,
+ &dev_attr_iCountryCodeRelDate);
if (i < 0) {
kfree(acm->country_codes);
goto skip_countries;
@@ -1164,8 +1222,10 @@ skip_normal_probe:
}
skip_countries:
- usb_fill_int_urb(acm->ctrlurb, usb_dev, usb_rcvintpipe(usb_dev, epctrl->bEndpointAddress),
- acm->ctrl_buffer, ctrlsize, acm_ctrl_irq, acm, epctrl->bInterval);
+ usb_fill_int_urb(acm->ctrlurb, usb_dev,
+ usb_rcvintpipe(usb_dev, epctrl->bEndpointAddress),
+ acm->ctrl_buffer, ctrlsize, acm_ctrl_irq, acm,
+ epctrl->bInterval);
acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
acm->ctrlurb->transfer_dma = acm->ctrl_dma;
@@ -1212,7 +1272,7 @@ static void stop_data_traffic(struct acm *acm)
tasklet_disable(&acm->urb_task);
usb_kill_urb(acm->ctrlurb);
- for(i = 0; i < ACM_NW; i++)
+ for (i = 0; i < ACM_NW; i++)
usb_kill_urb(acm->wb[i].urb);
for (i = 0; i < acm->rx_buflimit; i++)
usb_kill_urb(acm->ru[i].urb);
@@ -1227,13 +1287,14 @@ static void acm_disconnect(struct usb_interface *intf)
{
struct acm *acm = usb_get_intfdata(intf);
struct usb_device *usb_dev = interface_to_usbdev(intf);
+ struct tty_struct *tty;
/* sibling interface is already cleaning up */
if (!acm)
return;
mutex_lock(&open_mutex);
- if (acm->country_codes){
+ if (acm->country_codes) {
device_remove_file(&acm->control->dev,
&dev_attr_wCountryCodes);
device_remove_file(&acm->control->dev,
@@ -1247,22 +1308,25 @@ static void acm_disconnect(struct usb_interface *intf)
stop_data_traffic(acm);
acm_write_buffers_free(acm);
- usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
+ usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer,
+ acm->ctrl_dma);
acm_read_buffers_free(acm);
usb_driver_release_interface(&acm_driver, intf == acm->control ?
acm->data : acm->control);
- if (!acm->used) {
+ if (acm->port.count == 0) {
acm_tty_unregister(acm);
mutex_unlock(&open_mutex);
return;
}
mutex_unlock(&open_mutex);
-
- if (acm->tty)
- tty_hangup(acm->tty);
+ tty = tty_port_tty_get(&acm->port);
+ if (tty) {
+ tty_hangup(tty);
+ tty_kref_put(tty);
+ }
}
#ifdef CONFIG_PM
@@ -1297,7 +1361,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)
*/
mutex_lock(&acm->mutex);
- if (acm->used)
+ if (acm->port.count)
stop_data_traffic(acm);
mutex_unlock(&acm->mutex);
@@ -1319,7 +1383,7 @@ static int acm_resume(struct usb_interface *intf)
return 0;
mutex_lock(&acm->mutex);
- if (acm->used) {
+ if (acm->port.count) {
rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO);
if (rv < 0)
goto err_out;
@@ -1375,6 +1439,9 @@ static struct usb_device_id acm_ids[] = {
{ USB_DEVICE(0x0572, 0x1324), /* Conexant USB MODEM RD02-D400 */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
+ { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
+ .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
+ },
{ USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */
},
{ USB_DEVICE(0x0572, 0x1329), /* Hummingbird huc56s (Conexant) */
@@ -1395,7 +1462,7 @@ static struct usb_device_id acm_ids[] = {
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_GSM) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_3G ) },
+ USB_CDC_ACM_PROTO_AT_3G) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_CDMA) },
@@ -1403,7 +1470,7 @@ static struct usb_device_id acm_ids[] = {
{ }
};
-MODULE_DEVICE_TABLE (usb, acm_ids);
+MODULE_DEVICE_TABLE(usb, acm_ids);
static struct usb_driver acm_driver = {
.name = "cdc_acm",
@@ -1426,6 +1493,7 @@ static struct usb_driver acm_driver = {
static const struct tty_operations acm_ops = {
.open = acm_tty_open,
.close = acm_tty_close,
+ .hangup = acm_tty_hangup,
.write = acm_tty_write,
.write_room = acm_tty_write_room,
.ioctl = acm_tty_ioctl,
@@ -1457,7 +1525,8 @@ static int __init acm_init(void)
acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
acm_tty_driver->init_termios = tty_std_termios;
- acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+ acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD |
+ HUPCL | CLOCAL;
tty_set_operations(acm_tty_driver, &acm_ops);
retval = tty_register_driver(acm_tty_driver);
@@ -1489,7 +1558,7 @@ static void __exit acm_exit(void)
module_init(acm_init);
module_exit(acm_exit);
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
MODULE_ALIAS_CHARDEV_MAJOR(ACM_TTY_MAJOR);
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 1f95e7aa1b66..4c3856420add 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -89,8 +89,8 @@ struct acm {
struct usb_device *dev; /* the corresponding usb device */
struct usb_interface *control; /* control interface */
struct usb_interface *data; /* data interface */
- struct tty_struct *tty; /* the corresponding tty */
- struct urb *ctrlurb; /* urbs */
+ struct tty_port port; /* our tty port data */
+ struct urb *ctrlurb; /* urbs */
u8 *ctrl_buffer; /* buffers of urbs */
dma_addr_t ctrl_dma; /* dma handles of buffers */
u8 *country_codes; /* country codes from device */
@@ -120,7 +120,6 @@ struct acm {
unsigned int ctrlout; /* output control lines (DTR, RTS) */
unsigned int writesize; /* max packet size for the output bulk endpoint */
unsigned int readsize,ctrlsize; /* buffer sizes for freeing */
- unsigned int used; /* someone has this acm's device open */
unsigned int minor; /* acm minor number */
unsigned char throttle; /* throttled by tty layer */
unsigned char clocal; /* termios CLOCAL */
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index d2747a49b974..26c09f0257db 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1057,8 +1057,14 @@ static const struct file_operations usblp_fops = {
.release = usblp_release,
};
+static char *usblp_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
static struct usb_class_driver usblp_class = {
.name = "lp%d",
+ .nodename = usblp_nodename,
.fops = &usblp_fops,
.minor_base = USBLP_MINOR_BASE,
};
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index e1759d17ac5d..69280c35b5cb 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -28,7 +28,7 @@ comment "Miscellaneous USB options"
depends on USB
config USB_DEVICEFS
- bool "USB device filesystem"
+ bool "USB device filesystem (DEPRECATED)" if EMBEDDED
depends on USB
---help---
If you say Y here (and to "/proc file system support" in the "File
@@ -46,11 +46,15 @@ config USB_DEVICEFS
For the format of the various /proc/bus/usb/ files, please read
<file:Documentation/usb/proc_usb_info.txt>.
- Usbfs files can't handle Access Control Lists (ACL), which are the
- default way to grant access to USB devices for untrusted users of a
- desktop system. The usbfs functionality is replaced by real
- device-nodes managed by udev. These nodes live in /dev/bus/usb and
- are used by libusb.
+ Modern Linux systems do not use this.
+
+ Usbfs entries are files and not character devices; usbfs can't
+ handle Access Control Lists (ACL) which are the default way to
+ grant access to USB devices for untrusted users of a desktop
+ system.
+
+ The usbfs functionality is replaced by real device-nodes managed by
+ udev. These nodes lived in /dev/bus/usb and are used by libusb.
config USB_DEVICE_CLASS
bool "USB device class-devices (DEPRECATED)"
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index b6078706fb93..ec16e6029905 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -4,14 +4,14 @@
usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \
config.o file.o buffer.o sysfs.o endpoint.o \
- devio.o notify.o generic.o quirks.o
+ devio.o notify.o generic.o quirks.o devices.o
ifeq ($(CONFIG_PCI),y)
usbcore-objs += hcd-pci.o
endif
ifeq ($(CONFIG_USB_DEVICEFS),y)
- usbcore-objs += inode.o devices.o
+ usbcore-objs += inode.o
endif
obj-$(CONFIG_USB) += usbcore.o
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 568244c99bdc..24dfb33f90cb 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -19,6 +19,32 @@ static inline const char *plural(int n)
return (n == 1 ? "" : "s");
}
+/* FIXME: this is a kludge */
+static int find_next_descriptor_more(unsigned char *buffer, int size,
+ int dt1, int dt2, int dt3, int *num_skipped)
+{
+ struct usb_descriptor_header *h;
+ int n = 0;
+ unsigned char *buffer0 = buffer;
+
+ /* Find the next descriptor of type dt1 or dt2 or dt3 */
+ while (size > 0) {
+ h = (struct usb_descriptor_header *) buffer;
+ if (h->bDescriptorType == dt1 || h->bDescriptorType == dt2 ||
+ h->bDescriptorType == dt3)
+ break;
+ buffer += h->bLength;
+ size -= h->bLength;
+ ++n;
+ }
+
+ /* Store the number of descriptors skipped and return the
+ * number of bytes skipped */
+ if (num_skipped)
+ *num_skipped = n;
+ return buffer - buffer0;
+}
+
static int find_next_descriptor(unsigned char *buffer, int size,
int dt1, int dt2, int *num_skipped)
{
@@ -43,6 +69,129 @@ static int find_next_descriptor(unsigned char *buffer, int size,
return buffer - buffer0;
}
+static int usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
+ int inum, int asnum, struct usb_host_endpoint *ep,
+ int num_ep, unsigned char *buffer, int size)
+{
+ unsigned char *buffer_start = buffer;
+ struct usb_ss_ep_comp_descriptor *desc;
+ int retval;
+ int num_skipped;
+ int max_tx;
+ int i;
+
+ /* Allocate space for the SS endpoint companion descriptor */
+ ep->ss_ep_comp = kzalloc(sizeof(struct usb_host_ss_ep_comp),
+ GFP_KERNEL);
+ if (!ep->ss_ep_comp)
+ return -ENOMEM;
+ desc = (struct usb_ss_ep_comp_descriptor *) buffer;
+ if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP) {
+ dev_warn(ddev, "No SuperSpeed endpoint companion for config %d "
+ " interface %d altsetting %d ep %d: "
+ "using minimum values\n",
+ cfgno, inum, asnum, ep->desc.bEndpointAddress);
+ ep->ss_ep_comp->desc.bLength = USB_DT_SS_EP_COMP_SIZE;
+ ep->ss_ep_comp->desc.bDescriptorType = USB_DT_SS_ENDPOINT_COMP;
+ ep->ss_ep_comp->desc.bMaxBurst = 0;
+ /*
+ * Leave bmAttributes as zero, which will mean no streams for
+ * bulk, and isoc won't support multiple bursts of packets.
+ * With bursts of only one packet, and a Mult of 1, the max
+ * amount of data moved per endpoint service interval is one
+ * packet.
+ */
+ if (usb_endpoint_xfer_isoc(&ep->desc) ||
+ usb_endpoint_xfer_int(&ep->desc))
+ ep->ss_ep_comp->desc.wBytesPerInterval =
+ ep->desc.wMaxPacketSize;
+ /*
+ * The next descriptor is for an Endpoint or Interface,
+ * no extra descriptors to copy into the companion structure,
+ * and we didn't eat up any of the buffer.
+ */
+ retval = 0;
+ goto valid;
+ }
+ memcpy(&ep->ss_ep_comp->desc, desc, USB_DT_SS_EP_COMP_SIZE);
+ desc = &ep->ss_ep_comp->desc;
+ buffer += desc->bLength;
+ size -= desc->bLength;
+
+ /* Eat up the other descriptors we don't care about */
+ ep->ss_ep_comp->extra = buffer;
+ i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
+ USB_DT_INTERFACE, &num_skipped);
+ ep->ss_ep_comp->extralen = i;
+ buffer += i;
+ size -= i;
+ retval = buffer - buffer_start + i;
+ if (num_skipped > 0)
+ dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
+ num_skipped, plural(num_skipped),
+ "SuperSpeed endpoint companion");
+
+ /* Check the various values */
+ if (usb_endpoint_xfer_control(&ep->desc) && desc->bMaxBurst != 0) {
+ dev_warn(ddev, "Control endpoint with bMaxBurst = %d in "
+ "config %d interface %d altsetting %d ep %d: "
+ "setting to zero\n", desc->bMaxBurst,
+ cfgno, inum, asnum, ep->desc.bEndpointAddress);
+ desc->bMaxBurst = 0;
+ }
+ if (desc->bMaxBurst > 15) {
+ dev_warn(ddev, "Endpoint with bMaxBurst = %d in "
+ "config %d interface %d altsetting %d ep %d: "
+ "setting to 15\n", desc->bMaxBurst,
+ cfgno, inum, asnum, ep->desc.bEndpointAddress);
+ desc->bMaxBurst = 15;
+ }
+ if ((usb_endpoint_xfer_control(&ep->desc) || usb_endpoint_xfer_int(&ep->desc))
+ && desc->bmAttributes != 0) {
+ dev_warn(ddev, "%s endpoint with bmAttributes = %d in "
+ "config %d interface %d altsetting %d ep %d: "
+ "setting to zero\n",
+ usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",
+ desc->bmAttributes,
+ cfgno, inum, asnum, ep->desc.bEndpointAddress);
+ desc->bmAttributes = 0;
+ }
+ if (usb_endpoint_xfer_bulk(&ep->desc) && desc->bmAttributes > 16) {
+ dev_warn(ddev, "Bulk endpoint with more than 65536 streams in "
+ "config %d interface %d altsetting %d ep %d: "
+ "setting to max\n",
+ cfgno, inum, asnum, ep->desc.bEndpointAddress);
+ desc->bmAttributes = 16;
+ }
+ if (usb_endpoint_xfer_isoc(&ep->desc) && desc->bmAttributes > 2) {
+ dev_warn(ddev, "Isoc endpoint has Mult of %d in "
+ "config %d interface %d altsetting %d ep %d: "
+ "setting to 3\n", desc->bmAttributes + 1,
+ cfgno, inum, asnum, ep->desc.bEndpointAddress);
+ desc->bmAttributes = 2;
+ }
+ if (usb_endpoint_xfer_isoc(&ep->desc)) {
+ max_tx = ep->desc.wMaxPacketSize * (desc->bMaxBurst + 1) *
+ (desc->bmAttributes + 1);
+ } else if (usb_endpoint_xfer_int(&ep->desc)) {
+ max_tx = ep->desc.wMaxPacketSize * (desc->bMaxBurst + 1);
+ } else {
+ goto valid;
+ }
+ if (desc->wBytesPerInterval > max_tx) {
+ dev_warn(ddev, "%s endpoint with wBytesPerInterval of %d in "
+ "config %d interface %d altsetting %d ep %d: "
+ "setting to %d\n",
+ usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int",
+ desc->wBytesPerInterval,
+ cfgno, inum, asnum, ep->desc.bEndpointAddress,
+ max_tx);
+ desc->wBytesPerInterval = max_tx;
+ }
+valid:
+ return retval;
+}
+
static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
int asnum, struct usb_host_interface *ifp, int num_ep,
unsigned char *buffer, int size)
@@ -50,7 +199,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
unsigned char *buffer0 = buffer;
struct usb_endpoint_descriptor *d;
struct usb_host_endpoint *endpoint;
- int n, i, j;
+ int n, i, j, retval;
d = (struct usb_endpoint_descriptor *) buffer;
buffer += d->bLength;
@@ -92,6 +241,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
if (usb_endpoint_xfer_int(d)) {
i = 1;
switch (to_usb_device(ddev)->speed) {
+ case USB_SPEED_SUPER:
case USB_SPEED_HIGH:
/* Many device manufacturers are using full-speed
* bInterval values in high-speed interrupt endpoint
@@ -161,17 +311,39 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
cfgno, inum, asnum, d->bEndpointAddress,
maxp);
}
-
- /* Skip over any Class Specific or Vendor Specific descriptors;
- * find the next endpoint or interface descriptor */
- endpoint->extra = buffer;
- i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
- USB_DT_INTERFACE, &n);
- endpoint->extralen = i;
+ /* Allocate room for and parse any SS endpoint companion descriptors */
+ if (to_usb_device(ddev)->speed == USB_SPEED_SUPER) {
+ endpoint->extra = buffer;
+ i = find_next_descriptor_more(buffer, size, USB_DT_SS_ENDPOINT_COMP,
+ USB_DT_ENDPOINT, USB_DT_INTERFACE, &n);
+ endpoint->extralen = i;
+ buffer += i;
+ size -= i;
+
+ if (size > 0) {
+ retval = usb_parse_ss_endpoint_companion(ddev, cfgno,
+ inum, asnum, endpoint, num_ep, buffer,
+ size);
+ if (retval >= 0) {
+ buffer += retval;
+ retval = buffer - buffer0;
+ }
+ } else {
+ retval = buffer - buffer0;
+ }
+ } else {
+ /* Skip over any Class Specific or Vendor Specific descriptors;
+ * find the next endpoint or interface descriptor */
+ endpoint->extra = buffer;
+ i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
+ USB_DT_INTERFACE, &n);
+ endpoint->extralen = i;
+ retval = buffer - buffer0 + i;
+ }
if (n > 0)
dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
n, plural(n), "endpoint");
- return buffer - buffer0 + i;
+ return retval;
skip_to_next_endpoint_or_interface_descriptor:
i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
@@ -452,6 +624,8 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx,
kref_init(&intfc->ref);
}
+ /* FIXME: parse the BOS descriptor */
+
/* Skip over any Class Specific or Vendor Specific descriptors;
* find the first interface descriptor */
config->extra = buffer;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d0a21a5f8201..c115eed0fdc3 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -385,7 +385,6 @@ void usb_driver_release_interface(struct usb_driver *driver,
struct usb_interface *iface)
{
struct device *dev = &iface->dev;
- struct usb_device *udev = interface_to_usbdev(iface);
/* this should never happen, don't release something that's not ours */
if (!dev->driver || dev->driver != &driver->drvwrap.driver)
@@ -394,23 +393,19 @@ void usb_driver_release_interface(struct usb_driver *driver,
/* don't release from within disconnect() */
if (iface->condition != USB_INTERFACE_BOUND)
return;
+ iface->condition = USB_INTERFACE_UNBINDING;
- /* don't release if the interface hasn't been added yet */
+ /* Release via the driver core only if the interface
+ * has already been registered
+ */
if (device_is_registered(dev)) {
- iface->condition = USB_INTERFACE_UNBINDING;
device_release_driver(dev);
} else {
- iface->condition = USB_INTERFACE_UNBOUND;
- usb_cancel_queued_reset(iface);
+ down(&dev->sem);
+ usb_unbind_interface(dev);
+ dev->driver = NULL;
+ up(&dev->sem);
}
- dev->driver = NULL;
- usb_set_intfdata(iface, NULL);
-
- usb_pm_lock(udev);
- iface->condition = USB_INTERFACE_UNBOUND;
- mark_quiesced(iface);
- iface->needs_remote_wakeup = 0;
- usb_pm_unlock(udev);
}
EXPORT_SYMBOL_GPL(usb_driver_release_interface);
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 997e659ff693..5cef88929b3e 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -67,6 +67,16 @@ static struct usb_class {
struct class *class;
} *usb_class;
+static char *usb_nodename(struct device *dev)
+{
+ struct usb_class_driver *drv;
+
+ drv = dev_get_drvdata(dev);
+ if (!drv || !drv->nodename)
+ return NULL;
+ return drv->nodename(dev);
+}
+
static int init_usb_class(void)
{
int result = 0;
@@ -90,6 +100,7 @@ static int init_usb_class(void)
kfree(usb_class);
usb_class = NULL;
}
+ usb_class->class->nodename = usb_nodename;
exit:
return result;
@@ -198,7 +209,7 @@ int usb_register_dev(struct usb_interface *intf,
else
temp = name;
intf->usb_dev = device_create(usb_class->class, &intf->dev,
- MKDEV(USB_MAJOR, minor), NULL,
+ MKDEV(USB_MAJOR, minor), class_driver,
"%s", temp);
if (IS_ERR(intf->usb_dev)) {
down_write(&minor_rwsem);
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index a4301dc02d27..91f2885b6ee1 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -185,194 +185,198 @@ void usb_hcd_pci_remove(struct pci_dev *dev)
}
EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);
-
-#ifdef CONFIG_PM
-
/**
- * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD
- * @dev: USB Host Controller being suspended
- * @message: Power Management message describing this state transition
- *
- * Store this function in the HCD's struct pci_driver as .suspend.
+ * usb_hcd_pci_shutdown - shutdown host controller
+ * @dev: USB Host Controller being shutdown
*/
-int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
+void usb_hcd_pci_shutdown(struct pci_dev *dev)
+{
+ struct usb_hcd *hcd;
+
+ hcd = pci_get_drvdata(dev);
+ if (!hcd)
+ return;
+
+ if (hcd->driver->shutdown)
+ hcd->driver->shutdown(hcd);
+}
+EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
+
+#ifdef CONFIG_PM_SLEEP
+
+static int check_root_hub_suspended(struct device *dev)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+ struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
+
+ if (!(hcd->state == HC_STATE_SUSPENDED ||
+ hcd->state == HC_STATE_HALT)) {
+ dev_warn(dev, "Root hub is not suspended\n");
+ return -EBUSY;
+ }
+ return 0;
+}
+
+static int hcd_pci_suspend(struct device *dev)
{
- struct usb_hcd *hcd = pci_get_drvdata(dev);
- int retval = 0;
- int wake, w;
- int has_pci_pm;
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+ struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
+ int retval;
/* Root hub suspend should have stopped all downstream traffic,
* and all bus master traffic. And done so for both the interface
* and the stub usb_device (which we check here). But maybe it
* didn't; writing sysfs power/state files ignores such rules...
- *
- * We must ignore the FREEZE vs SUSPEND distinction here, because
- * otherwise the swsusp will save (and restore) garbage state.
*/
- if (!(hcd->state == HC_STATE_SUSPENDED ||
- hcd->state == HC_STATE_HALT)) {
- dev_warn(&dev->dev, "Root hub is not suspended\n");
- retval = -EBUSY;
- goto done;
- }
+ retval = check_root_hub_suspended(dev);
+ if (retval)
+ return retval;
/* We might already be suspended (runtime PM -- not yet written) */
- if (dev->current_state != PCI_D0)
- goto done;
+ if (pci_dev->current_state != PCI_D0)
+ return retval;
if (hcd->driver->pci_suspend) {
- retval = hcd->driver->pci_suspend(hcd, message);
+ retval = hcd->driver->pci_suspend(hcd);
suspend_report_result(hcd->driver->pci_suspend, retval);
if (retval)
- goto done;
+ return retval;
}
- synchronize_irq(dev->irq);
+ synchronize_irq(pci_dev->irq);
/* Downstream ports from this root hub should already be quiesced, so
* there will be no DMA activity. Now we can shut down the upstream
- * link (except maybe for PME# resume signaling) and enter some PCI
- * low power state, if the hardware allows.
+ * link (except maybe for PME# resume signaling). We'll enter a
+ * low power state during suspend_noirq, if the hardware allows.
*/
- pci_disable_device(dev);
+ pci_disable_device(pci_dev);
+ return retval;
+}
+
+static int hcd_pci_suspend_noirq(struct device *dev)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+ struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
+ int retval;
+
+ retval = check_root_hub_suspended(dev);
+ if (retval)
+ return retval;
- pci_save_state(dev);
+ pci_save_state(pci_dev);
- /* Don't fail on error to enable wakeup. We rely on pci code
- * to reject requests the hardware can't implement, rather
- * than coding the same thing.
+ /* If the root hub is HALTed rather than SUSPENDed,
+ * disallow remote wakeup.
*/
- wake = (hcd->state == HC_STATE_SUSPENDED &&
- device_may_wakeup(&dev->dev));
- w = pci_wake_from_d3(dev, wake);
- if (w < 0)
- wake = w;
- dev_dbg(&dev->dev, "wakeup: %d\n", wake);
-
- /* Don't change state if we don't need to */
- if (message.event == PM_EVENT_FREEZE ||
- message.event == PM_EVENT_PRETHAW) {
- dev_dbg(&dev->dev, "--> no state change\n");
- goto done;
- }
+ if (hcd->state == HC_STATE_HALT)
+ device_set_wakeup_enable(dev, 0);
+ dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev));
- has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
- if (!has_pci_pm) {
- dev_dbg(&dev->dev, "--> PCI D0 legacy\n");
+ /* Possibly enable remote wakeup,
+ * choose the appropriate low-power state, and go to that state.
+ */
+ retval = pci_prepare_to_sleep(pci_dev);
+ if (retval == -EIO) { /* Low-power not supported */
+ dev_dbg(dev, "--> PCI D0 legacy\n");
+ retval = 0;
+ } else if (retval == 0) {
+ dev_dbg(dev, "--> PCI %s\n",
+ pci_power_name(pci_dev->current_state));
} else {
-
- /* NOTE: dev->current_state becomes nonzero only here, and
- * only for devices that support PCI PM. Also, exiting
- * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset
- * some device state (e.g. as part of clock reinit).
- */
- retval = pci_set_power_state(dev, PCI_D3hot);
- suspend_report_result(pci_set_power_state, retval);
- if (retval == 0) {
- dev_dbg(&dev->dev, "--> PCI D3\n");
- } else {
- dev_dbg(&dev->dev, "PCI D3 suspend fail, %d\n",
- retval);
- pci_restore_state(dev);
- }
+ suspend_report_result(pci_prepare_to_sleep, retval);
+ return retval;
}
#ifdef CONFIG_PPC_PMAC
- if (retval == 0) {
- /* Disable ASIC clocks for USB */
- if (machine_is(powermac)) {
- struct device_node *of_node;
-
- of_node = pci_device_to_OF_node(dev);
- if (of_node)
- pmac_call_feature(PMAC_FTR_USB_ENABLE,
- of_node, 0, 0);
- }
+ /* Disable ASIC clocks for USB */
+ if (machine_is(powermac)) {
+ struct device_node *of_node;
+
+ of_node = pci_device_to_OF_node(pci_dev);
+ if (of_node)
+ pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
}
#endif
-
- done:
return retval;
}
-EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend);
-/**
- * usb_hcd_pci_resume - power management resume of a PCI-based HCD
- * @dev: USB Host Controller being resumed
- *
- * Store this function in the HCD's struct pci_driver as .resume.
- */
-int usb_hcd_pci_resume(struct pci_dev *dev)
+static int hcd_pci_resume_noirq(struct device *dev)
{
- struct usb_hcd *hcd;
- int retval;
+ struct pci_dev *pci_dev = to_pci_dev(dev);
#ifdef CONFIG_PPC_PMAC
/* Reenable ASIC clocks for USB */
if (machine_is(powermac)) {
struct device_node *of_node;
- of_node = pci_device_to_OF_node(dev);
+ of_node = pci_device_to_OF_node(pci_dev);
if (of_node)
pmac_call_feature(PMAC_FTR_USB_ENABLE,
of_node, 0, 1);
}
#endif
- pci_restore_state(dev);
+ /* Go back to D0 and disable remote wakeup */
+ pci_back_from_sleep(pci_dev);
+ return 0;
+}
+
+static int resume_common(struct device *dev, bool hibernated)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+ struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
+ int retval;
- hcd = pci_get_drvdata(dev);
if (hcd->state != HC_STATE_SUSPENDED) {
- dev_dbg(hcd->self.controller,
- "can't resume, not suspended!\n");
+ dev_dbg(dev, "can't resume, not suspended!\n");
return 0;
}
- pci_enable_wake(dev, PCI_D0, false);
-
- retval = pci_enable_device(dev);
+ retval = pci_enable_device(pci_dev);
if (retval < 0) {
- dev_err(&dev->dev, "can't re-enable after resume, %d!\n",
- retval);
+ dev_err(dev, "can't re-enable after resume, %d!\n", retval);
return retval;
}
- pci_set_master(dev);
-
- /* yes, ignore this result too... */
- (void) pci_wake_from_d3(dev, 0);
+ pci_set_master(pci_dev);
clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
if (hcd->driver->pci_resume) {
- retval = hcd->driver->pci_resume(hcd);
+ retval = hcd->driver->pci_resume(hcd, hibernated);
if (retval) {
- dev_err(hcd->self.controller,
- "PCI post-resume error %d!\n", retval);
+ dev_err(dev, "PCI post-resume error %d!\n", retval);
usb_hc_died(hcd);
}
}
return retval;
}
-EXPORT_SYMBOL_GPL(usb_hcd_pci_resume);
-#endif /* CONFIG_PM */
-
-/**
- * usb_hcd_pci_shutdown - shutdown host controller
- * @dev: USB Host Controller being shutdown
- */
-void usb_hcd_pci_shutdown(struct pci_dev *dev)
+static int hcd_pci_resume(struct device *dev)
{
- struct usb_hcd *hcd;
-
- hcd = pci_get_drvdata(dev);
- if (!hcd)
- return;
+ return resume_common(dev, false);
+}
- if (hcd->driver->shutdown)
- hcd->driver->shutdown(hcd);
+static int hcd_pci_restore(struct device *dev)
+{
+ return resume_common(dev, true);
}
-EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
+struct dev_pm_ops usb_hcd_pci_pm_ops = {
+ .suspend = hcd_pci_suspend,
+ .suspend_noirq = hcd_pci_suspend_noirq,
+ .resume_noirq = hcd_pci_resume_noirq,
+ .resume = hcd_pci_resume,
+ .freeze = check_root_hub_suspended,
+ .freeze_noirq = check_root_hub_suspended,
+ .thaw_noirq = NULL,
+ .thaw = NULL,
+ .poweroff = hcd_pci_suspend,
+ .poweroff_noirq = hcd_pci_suspend_noirq,
+ .restore_noirq = hcd_pci_resume_noirq,
+ .restore = hcd_pci_restore,
+};
+EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops);
+
+#endif /* CONFIG_PM_SLEEP */
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 42b93da1085d..ce3f453f02ef 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -128,6 +128,27 @@ static inline int is_root_hub(struct usb_device *udev)
#define KERNEL_REL ((LINUX_VERSION_CODE >> 16) & 0x0ff)
#define KERNEL_VER ((LINUX_VERSION_CODE >> 8) & 0x0ff)
+/* usb 3.0 root hub device descriptor */
+static const u8 usb3_rh_dev_descriptor[18] = {
+ 0x12, /* __u8 bLength; */
+ 0x01, /* __u8 bDescriptorType; Device */
+ 0x00, 0x03, /* __le16 bcdUSB; v3.0 */
+
+ 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
+ 0x00, /* __u8 bDeviceSubClass; */
+ 0x03, /* __u8 bDeviceProtocol; USB 3.0 hub */
+ 0x09, /* __u8 bMaxPacketSize0; 2^9 = 512 Bytes */
+
+ 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */
+ 0x02, 0x00, /* __le16 idProduct; device 0x0002 */
+ KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */
+
+ 0x03, /* __u8 iManufacturer; */
+ 0x02, /* __u8 iProduct; */
+ 0x01, /* __u8 iSerialNumber; */
+ 0x01 /* __u8 bNumConfigurations; */
+};
+
/* usb 2.0 root hub device descriptor */
static const u8 usb2_rh_dev_descriptor [18] = {
0x12, /* __u8 bLength; */
@@ -273,6 +294,47 @@ static const u8 hs_rh_config_descriptor [] = {
0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */
};
+static const u8 ss_rh_config_descriptor[] = {
+ /* one configuration */
+ 0x09, /* __u8 bLength; */
+ 0x02, /* __u8 bDescriptorType; Configuration */
+ 0x19, 0x00, /* __le16 wTotalLength; FIXME */
+ 0x01, /* __u8 bNumInterfaces; (1) */
+ 0x01, /* __u8 bConfigurationValue; */
+ 0x00, /* __u8 iConfiguration; */
+ 0xc0, /* __u8 bmAttributes;
+ Bit 7: must be set,
+ 6: Self-powered,
+ 5: Remote wakeup,
+ 4..0: resvd */
+ 0x00, /* __u8 MaxPower; */
+
+ /* one interface */
+ 0x09, /* __u8 if_bLength; */
+ 0x04, /* __u8 if_bDescriptorType; Interface */
+ 0x00, /* __u8 if_bInterfaceNumber; */
+ 0x00, /* __u8 if_bAlternateSetting; */
+ 0x01, /* __u8 if_bNumEndpoints; */
+ 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
+ 0x00, /* __u8 if_bInterfaceSubClass; */
+ 0x00, /* __u8 if_bInterfaceProtocol; */
+ 0x00, /* __u8 if_iInterface; */
+
+ /* one endpoint (status change endpoint) */
+ 0x07, /* __u8 ep_bLength; */
+ 0x05, /* __u8 ep_bDescriptorType; Endpoint */
+ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
+ 0x03, /* __u8 ep_bmAttributes; Interrupt */
+ /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8)
+ * see hub.c:hub_configure() for details. */
+ (USB_MAXCHILDREN + 1 + 7) / 8, 0x00,
+ 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */
+ /*
+ * All 3.0 hubs should have an endpoint companion descriptor,
+ * but we're ignoring that for now. FIXME?
+ */
+};
+
/*-------------------------------------------------------------------------*/
/*
@@ -426,23 +488,39 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch (wValue & 0xff00) {
case USB_DT_DEVICE << 8:
- if (hcd->driver->flags & HCD_USB2)
+ switch (hcd->driver->flags & HCD_MASK) {
+ case HCD_USB3:
+ bufp = usb3_rh_dev_descriptor;
+ break;
+ case HCD_USB2:
bufp = usb2_rh_dev_descriptor;
- else if (hcd->driver->flags & HCD_USB11)
+ break;
+ case HCD_USB11:
bufp = usb11_rh_dev_descriptor;
- else
+ break;
+ default:
goto error;
+ }
len = 18;
if (hcd->has_tt)
patch_protocol = 1;
break;
case USB_DT_CONFIG << 8:
- if (hcd->driver->flags & HCD_USB2) {
+ switch (hcd->driver->flags & HCD_MASK) {
+ case HCD_USB3:
+ bufp = ss_rh_config_descriptor;
+ len = sizeof ss_rh_config_descriptor;
+ break;
+ case HCD_USB2:
bufp = hs_rh_config_descriptor;
len = sizeof hs_rh_config_descriptor;
- } else {
+ break;
+ case HCD_USB11:
bufp = fs_rh_config_descriptor;
len = sizeof fs_rh_config_descriptor;
+ break;
+ default:
+ goto error;
}
if (device_can_wakeup(&hcd->self.root_hub->dev))
patch_wakeup = 1;
@@ -755,23 +833,6 @@ static struct attribute_group usb_bus_attr_group = {
/*-------------------------------------------------------------------------*/
-static struct class *usb_host_class;
-
-int usb_host_init(void)
-{
- int retval = 0;
-
- usb_host_class = class_create(THIS_MODULE, "usb_host");
- if (IS_ERR(usb_host_class))
- retval = PTR_ERR(usb_host_class);
- return retval;
-}
-
-void usb_host_cleanup(void)
-{
- class_destroy(usb_host_class);
-}
-
/**
* usb_bus_init - shared initialization code
* @bus: the bus structure being initialized
@@ -818,12 +879,6 @@ static int usb_register_bus(struct usb_bus *bus)
set_bit (busnum, busmap.busmap);
bus->busnum = busnum;
- bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0),
- bus, "usb_host%d", busnum);
- result = PTR_ERR(bus->dev);
- if (IS_ERR(bus->dev))
- goto error_create_class_dev;
-
/* Add it to the local list of buses */
list_add (&bus->bus_list, &usb_bus_list);
mutex_unlock(&usb_bus_list_lock);
@@ -834,8 +889,6 @@ static int usb_register_bus(struct usb_bus *bus)
"number %d\n", bus->busnum);
return 0;
-error_create_class_dev:
- clear_bit(busnum, busmap.busmap);
error_find_busnum:
mutex_unlock(&usb_bus_list_lock);
return result;
@@ -865,8 +918,6 @@ static void usb_deregister_bus (struct usb_bus *bus)
usb_notify_remove_bus(bus);
clear_bit (bus->busnum, busmap.busmap);
-
- device_unregister(bus->dev);
}
/**
@@ -1199,7 +1250,8 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
/* Map the URB's buffers for DMA access.
* Lower level HCD code should use *_dma exclusively,
- * unless it uses pio or talks to another transport.
+ * unless it uses pio or talks to another transport,
+ * or uses the provided scatter gather list for bulk.
*/
if (is_root_hub(urb->dev))
return 0;
@@ -1520,6 +1572,92 @@ rescan:
}
}
+/* Check whether a new configuration or alt setting for an interface
+ * will exceed the bandwidth for the bus (or the host controller resources).
+ * Only pass in a non-NULL config or interface, not both!
+ * Passing NULL for both new_config and new_intf means the device will be
+ * de-configured by issuing a set configuration 0 command.
+ */
+int usb_hcd_check_bandwidth(struct usb_device *udev,
+ struct usb_host_config *new_config,
+ struct usb_interface *new_intf)
+{
+ int num_intfs, i, j;
+ struct usb_interface_cache *intf_cache;
+ struct usb_host_interface *alt = 0;
+ int ret = 0;
+ struct usb_hcd *hcd;
+ struct usb_host_endpoint *ep;
+
+ hcd = bus_to_hcd(udev->bus);
+ if (!hcd->driver->check_bandwidth)
+ return 0;
+
+ /* Configuration is being removed - set configuration 0 */
+ if (!new_config && !new_intf) {
+ for (i = 1; i < 16; ++i) {
+ ep = udev->ep_out[i];
+ if (ep)
+ hcd->driver->drop_endpoint(hcd, udev, ep);
+ ep = udev->ep_in[i];
+ if (ep)
+ hcd->driver->drop_endpoint(hcd, udev, ep);
+ }
+ hcd->driver->check_bandwidth(hcd, udev);
+ return 0;
+ }
+ /* Check if the HCD says there's enough bandwidth. Enable all endpoints
+ * each interface's alt setting 0 and ask the HCD to check the bandwidth
+ * of the bus. There will always be bandwidth for endpoint 0, so it's
+ * ok to exclude it.
+ */
+ if (new_config) {
+ num_intfs = new_config->desc.bNumInterfaces;
+ /* Remove endpoints (except endpoint 0, which is always on the
+ * schedule) from the old config from the schedule
+ */
+ for (i = 1; i < 16; ++i) {
+ ep = udev->ep_out[i];
+ if (ep) {
+ ret = hcd->driver->drop_endpoint(hcd, udev, ep);
+ if (ret < 0)
+ goto reset;
+ }
+ ep = udev->ep_in[i];
+ if (ep) {
+ ret = hcd->driver->drop_endpoint(hcd, udev, ep);
+ if (ret < 0)
+ goto reset;
+ }
+ }
+ for (i = 0; i < num_intfs; ++i) {
+
+ /* Dig the endpoints for alt setting 0 out of the
+ * interface cache for this interface
+ */
+ intf_cache = new_config->intf_cache[i];
+ for (j = 0; j < intf_cache->num_altsetting; j++) {
+ if (intf_cache->altsetting[j].desc.bAlternateSetting == 0)
+ alt = &intf_cache->altsetting[j];
+ }
+ if (!alt) {
+ printk(KERN_DEBUG "Did not find alt setting 0 for intf %d\n", i);
+ continue;
+ }
+ for (j = 0; j < alt->desc.bNumEndpoints; j++) {
+ ret = hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]);
+ if (ret < 0)
+ goto reset;
+ }
+ }
+ }
+ ret = hcd->driver->check_bandwidth(hcd, udev);
+reset:
+ if (ret < 0)
+ hcd->driver->reset_bandwidth(hcd, udev);
+ return ret;
+}
+
/* Disables the endpoint: synchronizes with the hcd to make sure all
* endpoint state is gone from hardware. usb_hcd_flush_endpoint() must
* have been called previously. Use for set_configuration, set_interface,
@@ -1897,8 +2035,20 @@ int usb_add_hcd(struct usb_hcd *hcd,
retval = -ENOMEM;
goto err_allocate_root_hub;
}
- rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH :
- USB_SPEED_FULL;
+
+ switch (hcd->driver->flags & HCD_MASK) {
+ case HCD_USB11:
+ rhdev->speed = USB_SPEED_FULL;
+ break;
+ case HCD_USB2:
+ rhdev->speed = USB_SPEED_HIGH;
+ break;
+ case HCD_USB3:
+ rhdev->speed = USB_SPEED_SUPER;
+ break;
+ default:
+ goto err_allocate_root_hub;
+ }
hcd->self.root_hub = rhdev;
/* wakeup flag init defaults to "everything works" for root hubs,
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index e7d4479de41c..d397ecfd5b17 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -173,6 +173,8 @@ struct hc_driver {
#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */
#define HCD_USB11 0x0010 /* USB 1.1 */
#define HCD_USB2 0x0020 /* USB 2.0 */
+#define HCD_USB3 0x0040 /* USB 3.0 */
+#define HCD_MASK 0x0070
/* called to init HCD and root hub */
int (*reset) (struct usb_hcd *hcd);
@@ -182,10 +184,10 @@ struct hc_driver {
* a whole, not just the root hub; they're for PCI bus glue.
*/
/* called after suspending the hub, before entering D3 etc */
- int (*pci_suspend) (struct usb_hcd *hcd, pm_message_t message);
+ int (*pci_suspend)(struct usb_hcd *hcd);
/* called after entering D0 (etc), before resuming the hub */
- int (*pci_resume) (struct usb_hcd *hcd);
+ int (*pci_resume)(struct usb_hcd *hcd, bool hibernated);
/* cleanly make HCD stop writing memory and doing I/O */
void (*stop) (struct usb_hcd *hcd);
@@ -224,6 +226,43 @@ struct hc_driver {
void (*relinquish_port)(struct usb_hcd *, int);
/* has a port been handed over to a companion? */
int (*port_handed_over)(struct usb_hcd *, int);
+
+ /* xHCI specific functions */
+ /* Called by usb_alloc_dev to alloc HC device structures */
+ int (*alloc_dev)(struct usb_hcd *, struct usb_device *);
+ /* Called by usb_release_dev to free HC device structures */
+ void (*free_dev)(struct usb_hcd *, struct usb_device *);
+
+ /* Bandwidth computation functions */
+ /* Note that add_endpoint() can only be called once per endpoint before
+ * check_bandwidth() or reset_bandwidth() must be called.
+ * drop_endpoint() can only be called once per endpoint also.
+ * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
+ * add the endpoint to the schedule with possibly new parameters denoted by a
+ * different endpoint descriptor in usb_host_endpoint.
+ * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
+ * not allowed.
+ */
+ /* Allocate endpoint resources and add them to a new schedule */
+ int (*add_endpoint)(struct usb_hcd *, struct usb_device *, struct usb_host_endpoint *);
+ /* Drop an endpoint from a new schedule */
+ int (*drop_endpoint)(struct usb_hcd *, struct usb_device *, struct usb_host_endpoint *);
+ /* Check that a new hardware configuration, set using
+ * endpoint_enable and endpoint_disable, does not exceed bus
+ * bandwidth. This must be called before any set configuration
+ * or set interface requests are sent to the device.
+ */
+ int (*check_bandwidth)(struct usb_hcd *, struct usb_device *);
+ /* Reset the device schedule to the last known good schedule,
+ * which was set from a previous successful call to
+ * check_bandwidth(). This reverts any add_endpoint() and
+ * drop_endpoint() calls since that last successful call.
+ * Used for when a check_bandwidth() call fails due to resource
+ * or bandwidth constraints.
+ */
+ void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
+ /* Returns the hardware-chosen device address */
+ int (*address_device)(struct usb_hcd *, struct usb_device *udev);
};
extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
@@ -242,6 +281,9 @@ extern void usb_hcd_disable_endpoint(struct usb_device *udev,
extern void usb_hcd_reset_endpoint(struct usb_device *udev,
struct usb_host_endpoint *ep);
extern void usb_hcd_synchronize_unlinks(struct usb_device *udev);
+extern int usb_hcd_check_bandwidth(struct usb_device *udev,
+ struct usb_host_config *new_config,
+ struct usb_interface *new_intf);
extern int usb_hcd_get_frame_number(struct usb_device *udev);
extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver,
@@ -261,14 +303,11 @@ struct pci_device_id;
extern int usb_hcd_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id);
extern void usb_hcd_pci_remove(struct pci_dev *dev);
-
-#ifdef CONFIG_PM
-extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t msg);
-extern int usb_hcd_pci_resume(struct pci_dev *dev);
-#endif /* CONFIG_PM */
-
extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
+#ifdef CONFIG_PM_SLEEP
+extern struct dev_pm_ops usb_hcd_pci_pm_ops;
+#endif
#endif /* CONFIG_PCI */
/* pci-ish (pdev null is ok) buffer alloc/mapping support */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index be86ae3f4088..2af3b4f06054 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -155,6 +155,8 @@ static inline char *portspeed(int portstatus)
return "480 Mb/s";
else if (portstatus & (1 << USB_PORT_FEAT_LOWSPEED))
return "1.5 Mb/s";
+ else if (portstatus & (1 << USB_PORT_FEAT_SUPERSPEED))
+ return "5.0 Gb/s";
else
return "12 Mb/s";
}
@@ -457,13 +459,13 @@ static void hub_tt_kevent (struct work_struct *work)
spin_lock_irqsave (&hub->tt.lock, flags);
while (--limit && !list_empty (&hub->tt.clear_list)) {
- struct list_head *temp;
+ struct list_head *next;
struct usb_tt_clear *clear;
struct usb_device *hdev = hub->hdev;
int status;
- temp = hub->tt.clear_list.next;
- clear = list_entry (temp, struct usb_tt_clear, clear_list);
+ next = hub->tt.clear_list.next;
+ clear = list_entry (next, struct usb_tt_clear, clear_list);
list_del (&clear->clear_list);
/* drop lock so HCD can concurrently report other TT errors */
@@ -951,6 +953,9 @@ static int hub_configure(struct usb_hub *hub,
ret);
hub->tt.hub = hdev;
break;
+ case 3:
+ /* USB 3.0 hubs don't have a TT */
+ break;
default:
dev_dbg(hub_dev, "Unrecognized hub protocol %d\n",
hdev->descriptor.bDeviceProtocol);
@@ -1323,6 +1328,11 @@ EXPORT_SYMBOL_GPL(usb_set_device_state);
* 0 is reserved by USB for default address; (b) Linux's USB stack
* uses always #1 for the root hub of the controller. So USB stack's
* port #1, which is wusb virtual-port #0 has address #2.
+ *
+ * Devices connected under xHCI are not as simple. The host controller
+ * supports virtualization, so the hardware assigns device addresses and
+ * the HCD must setup data structures before issuing a set address
+ * command to the hardware.
*/
static void choose_address(struct usb_device *udev)
{
@@ -1642,6 +1652,9 @@ int usb_new_device(struct usb_device *udev)
err = usb_configure_device(udev); /* detect & probe dev/intfs */
if (err < 0)
goto fail;
+ dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n",
+ udev->devnum, udev->bus->busnum,
+ (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
/* export the usbdev device-node for libusb */
udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
(((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
@@ -2395,19 +2408,29 @@ EXPORT_SYMBOL_GPL(usb_ep0_reinit);
static int hub_set_address(struct usb_device *udev, int devnum)
{
int retval;
+ struct usb_hcd *hcd = bus_to_hcd(udev->bus);
- if (devnum <= 1)
+ /*
+ * The host controller will choose the device address,
+ * instead of the core having chosen it earlier
+ */
+ if (!hcd->driver->address_device && devnum <= 1)
return -EINVAL;
if (udev->state == USB_STATE_ADDRESS)
return 0;
if (udev->state != USB_STATE_DEFAULT)
return -EINVAL;
- retval = usb_control_msg(udev, usb_sndaddr0pipe(),
- USB_REQ_SET_ADDRESS, 0, devnum, 0,
- NULL, 0, USB_CTRL_SET_TIMEOUT);
+ if (hcd->driver->address_device) {
+ retval = hcd->driver->address_device(hcd, udev);
+ } else {
+ retval = usb_control_msg(udev, usb_sndaddr0pipe(),
+ USB_REQ_SET_ADDRESS, 0, devnum, 0,
+ NULL, 0, USB_CTRL_SET_TIMEOUT);
+ if (retval == 0)
+ update_address(udev, devnum);
+ }
if (retval == 0) {
/* Device now using proper address. */
- update_address(udev, devnum);
usb_set_device_state(udev, USB_STATE_ADDRESS);
usb_ep0_reinit(udev);
}
@@ -2430,6 +2453,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
static DEFINE_MUTEX(usb_address0_mutex);
struct usb_device *hdev = hub->hdev;
+ struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
int i, j, retval;
unsigned delay = HUB_SHORT_RESET_TIME;
enum usb_device_speed oldspeed = udev->speed;
@@ -2452,11 +2476,24 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
mutex_lock(&usb_address0_mutex);
- /* Reset the device; full speed may morph to high speed */
- retval = hub_port_reset(hub, port1, udev, delay);
- if (retval < 0) /* error or disconnect */
+ if ((hcd->driver->flags & HCD_USB3) && udev->config) {
+ /* FIXME this will need special handling by the xHCI driver. */
+ dev_dbg(&udev->dev,
+ "xHCI reset of configured device "
+ "not supported yet.\n");
+ retval = -EINVAL;
goto fail;
- /* success, speed is known */
+ } else if (!udev->config && oldspeed == USB_SPEED_SUPER) {
+ /* Don't reset USB 3.0 devices during an initial setup */
+ usb_set_device_state(udev, USB_STATE_DEFAULT);
+ } else {
+ /* Reset the device; full speed may morph to high speed */
+ /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */
+ retval = hub_port_reset(hub, port1, udev, delay);
+ if (retval < 0) /* error or disconnect */
+ goto fail;
+ /* success, speed is known */
+ }
retval = -ENODEV;
if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) {
@@ -2471,6 +2508,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
* reported as 0xff in the device descriptor). WUSB1.0[4.8.1].
*/
switch (udev->speed) {
+ case USB_SPEED_SUPER:
case USB_SPEED_VARIABLE: /* fixed at 512 */
udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512);
break;
@@ -2496,16 +2534,20 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
case USB_SPEED_LOW: speed = "low"; break;
case USB_SPEED_FULL: speed = "full"; break;
case USB_SPEED_HIGH: speed = "high"; break;
+ case USB_SPEED_SUPER:
+ speed = "super";
+ break;
case USB_SPEED_VARIABLE:
speed = "variable";
type = "Wireless ";
break;
default: speed = "?"; break;
}
- dev_info (&udev->dev,
- "%s %s speed %sUSB device using %s and address %d\n",
- (udev->config) ? "reset" : "new", speed, type,
- udev->bus->controller->driver->name, devnum);
+ if (udev->speed != USB_SPEED_SUPER)
+ dev_info(&udev->dev,
+ "%s %s speed %sUSB device using %s and address %d\n",
+ (udev->config) ? "reset" : "new", speed, type,
+ udev->bus->controller->driver->name, devnum);
/* Set up TT records, if needed */
if (hdev->tt) {
@@ -2530,7 +2572,11 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
* value.
*/
for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
- if (USE_NEW_SCHEME(retry_counter)) {
+ /*
+ * An xHCI controller cannot send any packets to a device until
+ * a set address command successfully completes.
+ */
+ if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) {
struct usb_device_descriptor *buf;
int r = 0;
@@ -2596,7 +2642,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
* unauthorized address in the Connect Ack sequence;
* authorization will assign the final address.
*/
- if (udev->wusb == 0) {
+ if (udev->wusb == 0) {
for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
retval = hub_set_address(udev, devnum);
if (retval >= 0)
@@ -2609,13 +2655,20 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
devnum, retval);
goto fail;
}
+ if (udev->speed == USB_SPEED_SUPER) {
+ devnum = udev->devnum;
+ dev_info(&udev->dev,
+ "%s SuperSpeed USB device using %s and address %d\n",
+ (udev->config) ? "reset" : "new",
+ udev->bus->controller->driver->name, devnum);
+ }
/* cope with hardware quirkiness:
* - let SET_ADDRESS settle, some device hardware wants it
* - read ep0 maxpacket even for high and low speed,
*/
msleep(10);
- if (USE_NEW_SCHEME(retry_counter))
+ if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3))
break;
}
@@ -2634,8 +2687,11 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
if (retval)
goto fail;
- i = udev->descriptor.bMaxPacketSize0 == 0xff? /* wusb device? */
- 512 : udev->descriptor.bMaxPacketSize0;
+ if (udev->descriptor.bMaxPacketSize0 == 0xff ||
+ udev->speed == USB_SPEED_SUPER)
+ i = 512;
+ else
+ i = udev->descriptor.bMaxPacketSize0;
if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
if (udev->speed != USB_SPEED_FULL ||
!(i == 8 || i == 16 || i == 32 || i == 64)) {
@@ -2847,19 +2903,41 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
}
usb_set_device_state(udev, USB_STATE_POWERED);
- udev->speed = USB_SPEED_UNKNOWN;
udev->bus_mA = hub->mA_per_port;
udev->level = hdev->level + 1;
udev->wusb = hub_is_wusb(hub);
- /* set the address */
- choose_address(udev);
- if (udev->devnum <= 0) {
- status = -ENOTCONN; /* Don't retry */
- goto loop;
+ /*
+ * USB 3.0 devices are reset automatically before the connect
+ * port status change appears, and the root hub port status
+ * shows the correct speed. We also get port change
+ * notifications for USB 3.0 devices from the USB 3.0 portion of
+ * an external USB 3.0 hub, but this isn't handled correctly yet
+ * FIXME.
+ */
+
+ if (!(hcd->driver->flags & HCD_USB3))
+ udev->speed = USB_SPEED_UNKNOWN;
+ else if ((hdev->parent == NULL) &&
+ (portstatus & (1 << USB_PORT_FEAT_SUPERSPEED)))
+ udev->speed = USB_SPEED_SUPER;
+ else
+ udev->speed = USB_SPEED_UNKNOWN;
+
+ /*
+ * xHCI needs to issue an address device command later
+ * in the hub_port_init sequence for SS/HS/FS/LS devices.
+ */
+ if (!(hcd->driver->flags & HCD_USB3)) {
+ /* set the address */
+ choose_address(udev);
+ if (udev->devnum <= 0) {
+ status = -ENOTCONN; /* Don't retry */
+ goto loop;
+ }
}
- /* reset and get descriptor */
+ /* reset (non-USB 3.0 devices) and get descriptor */
status = hub_port_init(hub, udev, port1, i);
if (status < 0)
goto loop;
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 2a116ce53c9b..889c0f32a40b 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -47,7 +47,10 @@
#define USB_PORT_FEAT_L1 5 /* L1 suspend */
#define USB_PORT_FEAT_POWER 8
#define USB_PORT_FEAT_LOWSPEED 9
+/* This value was never in Table 11-17 */
#define USB_PORT_FEAT_HIGHSPEED 10
+/* This value is also fake */
+#define USB_PORT_FEAT_SUPERSPEED 11
#define USB_PORT_FEAT_C_CONNECTION 16
#define USB_PORT_FEAT_C_ENABLE 17
#define USB_PORT_FEAT_C_SUSPEND 18
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index b62628377654..2bed83caacb1 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -10,6 +10,7 @@
#include <linux/mm.h>
#include <linux/timer.h>
#include <linux/ctype.h>
+#include <linux/nls.h>
#include <linux/device.h>
#include <linux/scatterlist.h>
#include <linux/usb/quirks.h>
@@ -364,6 +365,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
int i;
int urb_flags;
int dma;
+ int use_sg;
if (!io || !dev || !sg
|| usb_pipecontrol(pipe)
@@ -391,7 +393,19 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
if (io->entries <= 0)
return io->entries;
- io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags);
+ /* If we're running on an xHCI host controller, queue the whole scatter
+ * gather list with one call to urb_enqueue(). This is only for bulk,
+ * as that endpoint type does not care how the data gets broken up
+ * across frames.
+ */
+ if (usb_pipebulk(pipe) &&
+ bus_to_hcd(dev->bus)->driver->flags & HCD_USB3) {
+ io->urbs = kmalloc(sizeof *io->urbs, mem_flags);
+ use_sg = true;
+ } else {
+ io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags);
+ use_sg = false;
+ }
if (!io->urbs)
goto nomem;
@@ -401,62 +415,92 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
if (usb_pipein(pipe))
urb_flags |= URB_SHORT_NOT_OK;
- for_each_sg(sg, sg, io->entries, i) {
- unsigned len;
-
- io->urbs[i] = usb_alloc_urb(0, mem_flags);
- if (!io->urbs[i]) {
- io->entries = i;
+ if (use_sg) {
+ io->urbs[0] = usb_alloc_urb(0, mem_flags);
+ if (!io->urbs[0]) {
+ io->entries = 0;
goto nomem;
}
- io->urbs[i]->dev = NULL;
- io->urbs[i]->pipe = pipe;
- io->urbs[i]->interval = period;
- io->urbs[i]->transfer_flags = urb_flags;
-
- io->urbs[i]->complete = sg_complete;
- io->urbs[i]->context = io;
-
- /*
- * Some systems need to revert to PIO when DMA is temporarily
- * unavailable. For their sakes, both transfer_buffer and
- * transfer_dma are set when possible. However this can only
- * work on systems without:
- *
- * - HIGHMEM, since DMA buffers located in high memory are
- * not directly addressable by the CPU for PIO;
- *
- * - IOMMU, since dma_map_sg() is allowed to use an IOMMU to
- * make virtually discontiguous buffers be "dma-contiguous"
- * so that PIO and DMA need diferent numbers of URBs.
- *
- * So when HIGHMEM or IOMMU are in use, transfer_buffer is NULL
- * to prevent stale pointers and to help spot bugs.
- */
- if (dma) {
- io->urbs[i]->transfer_dma = sg_dma_address(sg);
- len = sg_dma_len(sg);
+ io->urbs[0]->dev = NULL;
+ io->urbs[0]->pipe = pipe;
+ io->urbs[0]->interval = period;
+ io->urbs[0]->transfer_flags = urb_flags;
+
+ io->urbs[0]->complete = sg_complete;
+ io->urbs[0]->context = io;
+ /* A length of zero means transfer the whole sg list */
+ io->urbs[0]->transfer_buffer_length = length;
+ if (length == 0) {
+ for_each_sg(sg, sg, io->entries, i) {
+ io->urbs[0]->transfer_buffer_length +=
+ sg_dma_len(sg);
+ }
+ }
+ io->urbs[0]->sg = io;
+ io->urbs[0]->num_sgs = io->entries;
+ io->entries = 1;
+ } else {
+ for_each_sg(sg, sg, io->entries, i) {
+ unsigned len;
+
+ io->urbs[i] = usb_alloc_urb(0, mem_flags);
+ if (!io->urbs[i]) {
+ io->entries = i;
+ goto nomem;
+ }
+
+ io->urbs[i]->dev = NULL;
+ io->urbs[i]->pipe = pipe;
+ io->urbs[i]->interval = period;
+ io->urbs[i]->transfer_flags = urb_flags;
+
+ io->urbs[i]->complete = sg_complete;
+ io->urbs[i]->context = io;
+
+ /*
+ * Some systems need to revert to PIO when DMA is
+ * temporarily unavailable. For their sakes, both
+ * transfer_buffer and transfer_dma are set when
+ * possible. However this can only work on systems
+ * without:
+ *
+ * - HIGHMEM, since DMA buffers located in high memory
+ * are not directly addressable by the CPU for PIO;
+ *
+ * - IOMMU, since dma_map_sg() is allowed to use an
+ * IOMMU to make virtually discontiguous buffers be
+ * "dma-contiguous" so that PIO and DMA need diferent
+ * numbers of URBs.
+ *
+ * So when HIGHMEM or IOMMU are in use, transfer_buffer
+ * is NULL to prevent stale pointers and to help spot
+ * bugs.
+ */
+ if (dma) {
+ io->urbs[i]->transfer_dma = sg_dma_address(sg);
+ len = sg_dma_len(sg);
#if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU)
- io->urbs[i]->transfer_buffer = NULL;
+ io->urbs[i]->transfer_buffer = NULL;
#else
- io->urbs[i]->transfer_buffer = sg_virt(sg);
+ io->urbs[i]->transfer_buffer = sg_virt(sg);
#endif
- } else {
- /* hc may use _only_ transfer_buffer */
- io->urbs[i]->transfer_buffer = sg_virt(sg);
- len = sg->length;
- }
+ } else {
+ /* hc may use _only_ transfer_buffer */
+ io->urbs[i]->transfer_buffer = sg_virt(sg);
+ len = sg->length;
+ }
- if (length) {
- len = min_t(unsigned, len, length);
- length -= len;
- if (length == 0)
- io->entries = i + 1;
+ if (length) {
+ len = min_t(unsigned, len, length);
+ length -= len;
+ if (length == 0)
+ io->entries = i + 1;
+ }
+ io->urbs[i]->transfer_buffer_length = len;
}
- io->urbs[i]->transfer_buffer_length = len;
+ io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
}
- io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
/* transaction state */
io->count = io->entries;
@@ -509,6 +553,10 @@ EXPORT_SYMBOL_GPL(usb_sg_init);
* could be transferred. That capability is less useful for low or full
* speed interrupt endpoints, which allow at most one packet per millisecond,
* of at most 8 or 64 bytes (respectively).
+ *
+ * It is not necessary to call this function to reserve bandwidth for devices
+ * under an xHCI host controller, as the bandwidth is reserved when the
+ * configuration or interface alt setting is selected.
*/
void usb_sg_wait(struct usb_sg_request *io)
{
@@ -759,7 +807,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid,
}
/**
- * usb_string - returns ISO 8859-1 version of a string descriptor
+ * usb_string - returns UTF-8 version of a string descriptor
* @dev: the device whose string descriptor is being retrieved
* @index: the number of the descriptor
* @buf: where to put the string
@@ -767,17 +815,10 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid,
* Context: !in_interrupt ()
*
* This converts the UTF-16LE encoded strings returned by devices, from
- * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones
- * that are more usable in most kernel contexts. Note that all characters
- * in the chosen descriptor that can't be encoded using ISO-8859-1
- * are converted to the question mark ("?") character, and this function
+ * usb_get_string_descriptor(), to null-terminated UTF-8 encoded ones
+ * that are more usable in most kernel contexts. Note that this function
* chooses strings in the first language supported by the device.
*
- * The ASCII (or, redundantly, "US-ASCII") character set is the seven-bit
- * subset of ISO 8859-1. ISO-8859-1 is the eight-bit subset of Unicode,
- * and is appropriate for use many uses of English and several other
- * Western European languages. (But it doesn't include the "Euro" symbol.)
- *
* This call is synchronous, and may not be used in an interrupt context.
*
* Returns length of the string (>= 0) or usb_control_msg status (< 0).
@@ -786,7 +827,6 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
{
unsigned char *tbuf;
int err;
- unsigned int u, idx;
if (dev->state == USB_STATE_SUSPENDED)
return -EHOSTUNREACH;
@@ -821,16 +861,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
goto errout;
size--; /* leave room for trailing NULL char in output buffer */
- for (idx = 0, u = 2; u < err; u += 2) {
- if (idx >= size)
- break;
- if (tbuf[u+1]) /* high byte */
- buf[idx++] = '?'; /* non ISO-8859-1 character */
- else
- buf[idx++] = tbuf[u];
- }
- buf[idx] = 0;
- err = idx;
+ err = utf16s_to_utf8s((wchar_t *) &tbuf[2], (err - 2) / 2,
+ UTF16_LITTLE_ENDIAN, buf, size);
+ buf[err] = 0;
if (tbuf[1] != USB_DT_STRING)
dev_dbg(&dev->dev,
@@ -843,6 +876,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
}
EXPORT_SYMBOL_GPL(usb_string);
+/* one UTF-8-encoded 16-bit character has at most three bytes */
+#define MAX_USB_STRING_SIZE (127 * 3 + 1)
+
/**
* usb_cache_string - read a string descriptor and cache it for later use
* @udev: the device whose string descriptor is being read
@@ -860,9 +896,9 @@ char *usb_cache_string(struct usb_device *udev, int index)
if (index <= 0)
return NULL;
- buf = kmalloc(256, GFP_KERNEL);
+ buf = kmalloc(MAX_USB_STRING_SIZE, GFP_KERNEL);
if (buf) {
- len = usb_string(udev, index, buf, 256);
+ len = usb_string(udev, index, buf, MAX_USB_STRING_SIZE);
if (len > 0) {
smallbuf = kmalloc(++len, GFP_KERNEL);
if (!smallbuf)
@@ -1664,6 +1700,21 @@ free_interfaces:
if (ret)
goto free_interfaces;
+ /* Make sure we have bandwidth (and available HCD resources) for this
+ * configuration. Remove endpoints from the schedule if we're dropping
+ * this configuration to set configuration 0. After this point, the
+ * host controller will not allow submissions to dropped endpoints. If
+ * this call fails, the device state is unchanged.
+ */
+ if (cp)
+ ret = usb_hcd_check_bandwidth(dev, cp, NULL);
+ else
+ ret = usb_hcd_check_bandwidth(dev, NULL, NULL);
+ if (ret < 0) {
+ usb_autosuspend_device(dev);
+ goto free_interfaces;
+ }
+
/* if it's already configured, clear out old state first.
* getting rid of old interfaces means unbinding their drivers.
*/
@@ -1686,6 +1737,7 @@ free_interfaces:
dev->actconfig = cp;
if (!cp) {
usb_set_device_state(dev, USB_STATE_ADDRESS);
+ usb_hcd_check_bandwidth(dev, NULL, NULL);
usb_autosuspend_device(dev);
goto free_interfaces;
}
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index c66789197927..b5c72e458943 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -552,8 +552,8 @@ static struct attribute *dev_string_attrs[] = {
static mode_t dev_string_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
- struct usb_device *udev = to_usb_device(
- container_of(kobj, struct device, kobj));
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct usb_device *udev = to_usb_device(dev);
if (a == &dev_attr_manufacturer.attr) {
if (udev->manufacturer == NULL)
@@ -585,8 +585,8 @@ static ssize_t
read_descriptors(struct kobject *kobj, struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
- struct usb_device *udev = to_usb_device(
- container_of(kobj, struct device, kobj));
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct usb_device *udev = to_usb_device(dev);
size_t nleft = count;
size_t srclen, n;
int cfgno;
@@ -786,8 +786,8 @@ static struct attribute *intf_assoc_attrs[] = {
static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
- struct usb_interface *intf = to_usb_interface(
- container_of(kobj, struct device, kobj));
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct usb_interface *intf = to_usb_interface(dev);
if (intf->intf_assoc == NULL)
return 0;
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 3376055f36e7..0885d4abdc62 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -241,6 +241,12 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
* If the USB subsystem can't allocate sufficient bandwidth to perform
* the periodic request, submitting such a periodic request should fail.
*
+ * For devices under xHCI, the bandwidth is reserved at configuration time, or
+ * when the alt setting is selected. If there is not enough bus bandwidth, the
+ * configuration/alt setting request will fail. Therefore, submissions to
+ * periodic endpoints on devices under xHCI should never fail due to bandwidth
+ * constraints.
+ *
* Device drivers must explicitly request that repetition, by ensuring that
* some URB is always on the endpoint's queue (except possibly for short
* periods during completion callacks). When there is no longer an urb
@@ -351,6 +357,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
if (xfertype == USB_ENDPOINT_XFER_ISOC) {
int n, len;
+ /* FIXME SuperSpeed isoc endpoints have up to 16 bursts */
/* "high bandwidth" mode, 1-3 packets/uframe? */
if (dev->speed == USB_SPEED_HIGH) {
int mult = 1 + ((max >> 11) & 0x03);
@@ -426,6 +433,11 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
return -EINVAL;
/* too big? */
switch (dev->speed) {
+ case USB_SPEED_SUPER: /* units are 125us */
+ /* Handle up to 2^(16-1) microframes */
+ if (urb->interval > (1 << 15))
+ return -EINVAL;
+ max = 1 << 15;
case USB_SPEED_HIGH: /* units are microframes */
/* NOTE usb handles 2^15 */
if (urb->interval > (1024 * 8))
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 7eee400d3e32..00f1fc8bcc92 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -34,6 +34,7 @@
#include <linux/usb.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>
+#include <linux/debugfs.h>
#include <asm/io.h>
#include <linux/scatterlist.h>
@@ -184,11 +185,16 @@ EXPORT_SYMBOL_GPL(usb_find_interface);
static void usb_release_dev(struct device *dev)
{
struct usb_device *udev;
+ struct usb_hcd *hcd;
udev = to_usb_device(dev);
+ hcd = bus_to_hcd(udev->bus);
usb_destroy_configuration(udev);
- usb_put_hcd(bus_to_hcd(udev->bus));
+ /* Root hubs aren't real devices, so don't free HCD resources */
+ if (hcd->driver->free_dev && udev->parent)
+ hcd->driver->free_dev(hcd, udev);
+ usb_put_hcd(hcd);
kfree(udev->product);
kfree(udev->manufacturer);
kfree(udev->serial);
@@ -305,10 +311,21 @@ static struct dev_pm_ops usb_device_pm_ops = {
#endif /* CONFIG_PM */
+
+static char *usb_nodename(struct device *dev)
+{
+ struct usb_device *usb_dev;
+
+ usb_dev = to_usb_device(dev);
+ return kasprintf(GFP_KERNEL, "bus/usb/%03d/%03d",
+ usb_dev->bus->busnum, usb_dev->devnum);
+}
+
struct device_type usb_device_type = {
.name = "usb_device",
.release = usb_release_dev,
.uevent = usb_dev_uevent,
+ .nodename = usb_nodename,
.pm = &usb_device_pm_ops,
};
@@ -348,6 +365,13 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
kfree(dev);
return NULL;
}
+ /* Root hubs aren't true devices, so don't allocate HCD resources */
+ if (usb_hcd->driver->alloc_dev && parent &&
+ !usb_hcd->driver->alloc_dev(usb_hcd, dev)) {
+ usb_put_hcd(bus_to_hcd(bus));
+ kfree(dev);
+ return NULL;
+ }
device_initialize(&dev->dev);
dev->dev.bus = &usb_bus_type;
@@ -375,18 +399,24 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
*/
if (unlikely(!parent)) {
dev->devpath[0] = '0';
+ dev->route = 0;
dev->dev.parent = bus->controller;
dev_set_name(&dev->dev, "usb%d", bus->busnum);
root_hub = 1;
} else {
/* match any labeling on the hubs; it's one-based */
- if (parent->devpath[0] == '0')
+ if (parent->devpath[0] == '0') {
snprintf(dev->devpath, sizeof dev->devpath,
"%d", port1);
- else
+ /* Root ports are not counted in route string */
+ dev->route = 0;
+ } else {
snprintf(dev->devpath, sizeof dev->devpath,
"%s.%d", parent->devpath, port1);
+ dev->route = parent->route +
+ (port1 << ((parent->level - 1)*4));
+ }
dev->dev.parent = &parent->dev;
dev_set_name(&dev->dev, "%d-%s", bus->busnum, dev->devpath);
@@ -1001,6 +1031,35 @@ static struct notifier_block usb_bus_nb = {
.notifier_call = usb_bus_notify,
};
+struct dentry *usb_debug_root;
+EXPORT_SYMBOL_GPL(usb_debug_root);
+
+struct dentry *usb_debug_devices;
+
+static int usb_debugfs_init(void)
+{
+ usb_debug_root = debugfs_create_dir("usb", NULL);
+ if (!usb_debug_root)
+ return -ENOENT;
+
+ usb_debug_devices = debugfs_create_file("devices", 0444,
+ usb_debug_root, NULL,
+ &usbfs_devices_fops);
+ if (!usb_debug_devices) {
+ debugfs_remove(usb_debug_root);
+ usb_debug_root = NULL;
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
+static void usb_debugfs_cleanup(void)
+{
+ debugfs_remove(usb_debug_devices);
+ debugfs_remove(usb_debug_root);
+}
+
/*
* Init
*/
@@ -1012,6 +1071,10 @@ static int __init usb_init(void)
return 0;
}
+ retval = usb_debugfs_init();
+ if (retval)
+ goto out;
+
retval = ksuspend_usb_init();
if (retval)
goto out;
@@ -1021,9 +1084,6 @@ static int __init usb_init(void)
retval = bus_register_notifier(&usb_bus_type, &usb_bus_nb);
if (retval)
goto bus_notifier_failed;
- retval = usb_host_init();
- if (retval)
- goto host_init_failed;
retval = usb_major_init();
if (retval)
goto major_init_failed;
@@ -1053,8 +1113,6 @@ usb_devio_init_failed:
driver_register_failed:
usb_major_cleanup();
major_init_failed:
- usb_host_cleanup();
-host_init_failed:
bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
bus_notifier_failed:
bus_unregister(&usb_bus_type);
@@ -1079,10 +1137,10 @@ static void __exit usb_exit(void)
usb_deregister(&usbfs_driver);
usb_devio_cleanup();
usb_hub_cleanup();
- usb_host_cleanup();
bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
bus_unregister(&usb_bus_type);
ksuspend_usb_cleanup();
+ usb_debugfs_cleanup();
}
subsys_initcall(usb_init);
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 79d8a9ea559b..dabf9255a10e 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -41,8 +41,6 @@ extern int usb_hub_init(void);
extern void usb_hub_cleanup(void);
extern int usb_major_init(void);
extern void usb_major_cleanup(void);
-extern int usb_host_init(void);
-extern void usb_host_cleanup(void);
#ifdef CONFIG_PM
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 080bb1e4b847..772dd3b9bab9 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -253,7 +253,7 @@ config USB_PXA25X_SMALL
config USB_GADGET_PXA27X
boolean "PXA 27x"
- depends on ARCH_PXA && PXA27x
+ depends on ARCH_PXA && (PXA27x || PXA3xx)
select USB_OTG_UTILS
help
Intel's PXA 27x series XScale ARM v5TE processors include
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 0b2bb8f0706d..72bae8f39d81 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -485,7 +485,7 @@ static int at91_ep_enable(struct usb_ep *_ep,
return -ESHUTDOWN;
}
- tmp = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+ tmp = usb_endpoint_type(desc);
switch (tmp) {
case USB_ENDPOINT_XFER_CONTROL:
DBG("only one control endpoint\n");
@@ -517,7 +517,7 @@ ok:
local_irq_save(flags);
/* initialize endpoint to match this descriptor */
- ep->is_in = (desc->bEndpointAddress & USB_DIR_IN) != 0;
+ ep->is_in = usb_endpoint_dir_in(desc);
ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
ep->stopped = 0;
if (ep->is_in)
@@ -1574,7 +1574,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
udc->driver = driver;
udc->gadget.dev.driver = &driver->driver;
- udc->gadget.dev.driver_data = &driver->driver;
+ dev_set_drvdata(&udc->gadget.dev, &driver->driver);
udc->enabled = 1;
udc->selfpowered = 1;
@@ -1583,7 +1583,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
DBG("driver->bind() returned %d\n", retval);
udc->driver = NULL;
udc->gadget.dev.driver = NULL;
- udc->gadget.dev.driver_data = NULL;
+ dev_set_drvdata(&udc->gadget.dev, NULL);
udc->enabled = 0;
udc->selfpowered = 0;
return retval;
@@ -1613,7 +1613,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
driver->unbind(&udc->gadget);
udc->gadget.dev.driver = NULL;
- udc->gadget.dev.driver_data = NULL;
+ dev_set_drvdata(&udc->gadget.dev, NULL);
udc->driver = NULL;
DBG("unbound from %s\n", driver->driver.name);
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 563d57275448..7a8f4421924c 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -550,12 +550,12 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
DBG(DBG_HW, "%s: EPT_SIZE = %lu (maxpacket = %lu)\n",
ep->ep.name, ept_cfg, maxpacket);
- if ((desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) {
+ if (usb_endpoint_dir_in(desc)) {
ep->is_in = 1;
ept_cfg |= USBA_EPT_DIR_IN;
}
- switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
+ switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_CONTROL:
ept_cfg |= USBA_BF(EPT_TYPE, USBA_EPT_TYPE_CONTROL);
ept_cfg |= USBA_BF(BK_NUMBER, USBA_BK_NUMBER_ONE);
@@ -794,7 +794,8 @@ usba_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
if (ep->desc) {
list_add_tail(&req->queue, &ep->queue);
- if (ep->is_in || (ep_is_control(ep)
+ if ((!ep_is_control(ep) && ep->is_in) ||
+ (ep_is_control(ep)
&& (ep->state == DATA_STAGE_IN
|| ep->state == STATUS_STAGE_IN)))
usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY);
@@ -1940,7 +1941,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
clk_disable(pclk);
- usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
+ usba_ep = kzalloc(sizeof(struct usba_ep) * pdata->num_ep,
GFP_KERNEL);
if (!usba_ep)
goto err_alloc_ep;
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 38e531ecae4d..c7cb87a6fee2 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -1977,9 +1977,9 @@ static int ep_enable(struct usb_ep *ep,
if (!list_empty(&mEp->qh[mEp->dir].queue))
warn("enabling a non-empty endpoint!");
- mEp->dir = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? TX : RX;
- mEp->num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
- mEp->type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+ mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX;
+ mEp->num = usb_endpoint_num(desc);
+ mEp->type = usb_endpoint_type(desc);
mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize);
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 381a53b3e11c..1e6aa504d58a 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -248,6 +248,8 @@
#include <linux/freezer.h>
#include <linux/utsname.h>
+#include <asm/unaligned.h>
+
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
@@ -799,29 +801,9 @@ static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
/* Routines for unaligned data access */
-static u16 get_be16(u8 *buf)
-{
- return ((u16) buf[0] << 8) | ((u16) buf[1]);
-}
-
-static u32 get_be32(u8 *buf)
-{
- return ((u32) buf[0] << 24) | ((u32) buf[1] << 16) |
- ((u32) buf[2] << 8) | ((u32) buf[3]);
-}
-
-static void put_be16(u8 *buf, u16 val)
-{
- buf[0] = val >> 8;
- buf[1] = val;
-}
-
-static void put_be32(u8 *buf, u32 val)
+static u32 get_unaligned_be24(u8 *buf)
{
- buf[0] = val >> 24;
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val & 0xff;
+ return 0xffffff & (u32) get_unaligned_be32(buf - 1);
}
@@ -1582,9 +1564,9 @@ static int do_read(struct fsg_dev *fsg)
/* Get the starting Logical Block Address and check that it's
* not too big */
if (fsg->cmnd[0] == SC_READ_6)
- lba = (fsg->cmnd[1] << 16) | get_be16(&fsg->cmnd[2]);
+ lba = get_unaligned_be24(&fsg->cmnd[1]);
else {
- lba = get_be32(&fsg->cmnd[2]);
+ lba = get_unaligned_be32(&fsg->cmnd[2]);
/* We allow DPO (Disable Page Out = don't save data in the
* cache) and FUA (Force Unit Access = don't read from the
@@ -1717,9 +1699,9 @@ static int do_write(struct fsg_dev *fsg)
/* Get the starting Logical Block Address and check that it's
* not too big */
if (fsg->cmnd[0] == SC_WRITE_6)
- lba = (fsg->cmnd[1] << 16) | get_be16(&fsg->cmnd[2]);
+ lba = get_unaligned_be24(&fsg->cmnd[1]);
else {
- lba = get_be32(&fsg->cmnd[2]);
+ lba = get_unaligned_be32(&fsg->cmnd[2]);
/* We allow DPO (Disable Page Out = don't save data in the
* cache) and FUA (Force Unit Access = write directly to the
@@ -1940,7 +1922,7 @@ static int do_verify(struct fsg_dev *fsg)
/* Get the starting Logical Block Address and check that it's
* not too big */
- lba = get_be32(&fsg->cmnd[2]);
+ lba = get_unaligned_be32(&fsg->cmnd[2]);
if (lba >= curlun->num_sectors) {
curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
return -EINVAL;
@@ -1953,7 +1935,7 @@ static int do_verify(struct fsg_dev *fsg)
return -EINVAL;
}
- verification_length = get_be16(&fsg->cmnd[7]);
+ verification_length = get_unaligned_be16(&fsg->cmnd[7]);
if (unlikely(verification_length == 0))
return -EIO; // No default reply
@@ -2103,7 +2085,7 @@ static int do_request_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
memset(buf, 0, 18);
buf[0] = valid | 0x70; // Valid, current error
buf[2] = SK(sd);
- put_be32(&buf[3], sdinfo); // Sense information
+ put_unaligned_be32(sdinfo, &buf[3]); /* Sense information */
buf[7] = 18 - 8; // Additional sense length
buf[12] = ASC(sd);
buf[13] = ASCQ(sd);
@@ -2114,7 +2096,7 @@ static int do_request_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
static int do_read_capacity(struct fsg_dev *fsg, struct fsg_buffhd *bh)
{
struct lun *curlun = fsg->curlun;
- u32 lba = get_be32(&fsg->cmnd[2]);
+ u32 lba = get_unaligned_be32(&fsg->cmnd[2]);
int pmi = fsg->cmnd[8];
u8 *buf = (u8 *) bh->buf;
@@ -2124,8 +2106,9 @@ static int do_read_capacity(struct fsg_dev *fsg, struct fsg_buffhd *bh)
return -EINVAL;
}
- put_be32(&buf[0], curlun->num_sectors - 1); // Max logical block
- put_be32(&buf[4], 512); // Block length
+ put_unaligned_be32(curlun->num_sectors - 1, &buf[0]);
+ /* Max logical block */
+ put_unaligned_be32(512, &buf[4]); /* Block length */
return 8;
}
@@ -2144,7 +2127,7 @@ static void store_cdrom_address(u8 *dest, int msf, u32 addr)
dest[0] = 0; /* Reserved */
} else {
/* Absolute sector */
- put_be32(dest, addr);
+ put_unaligned_be32(addr, dest);
}
}
@@ -2152,7 +2135,7 @@ static int do_read_header(struct fsg_dev *fsg, struct fsg_buffhd *bh)
{
struct lun *curlun = fsg->curlun;
int msf = fsg->cmnd[1] & 0x02;
- u32 lba = get_be32(&fsg->cmnd[2]);
+ u32 lba = get_unaligned_be32(&fsg->cmnd[2]);
u8 *buf = (u8 *) bh->buf;
if ((fsg->cmnd[1] & ~0x02) != 0) { /* Mask away MSF */
@@ -2252,10 +2235,13 @@ static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
buf[2] = 0x04; // Write cache enable,
// Read cache not disabled
// No cache retention priorities
- put_be16(&buf[4], 0xffff); // Don't disable prefetch
- // Minimum prefetch = 0
- put_be16(&buf[8], 0xffff); // Maximum prefetch
- put_be16(&buf[10], 0xffff); // Maximum prefetch ceiling
+ put_unaligned_be16(0xffff, &buf[4]);
+ /* Don't disable prefetch */
+ /* Minimum prefetch = 0 */
+ put_unaligned_be16(0xffff, &buf[8]);
+ /* Maximum prefetch */
+ put_unaligned_be16(0xffff, &buf[10]);
+ /* Maximum prefetch ceiling */
}
buf += 12;
}
@@ -2272,7 +2258,7 @@ static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
if (mscmnd == SC_MODE_SENSE_6)
buf0[0] = len - 1;
else
- put_be16(buf0, len - 2);
+ put_unaligned_be16(len - 2, buf0);
return len;
}
@@ -2360,9 +2346,10 @@ static int do_read_format_capacities(struct fsg_dev *fsg,
buf[3] = 8; // Only the Current/Maximum Capacity Descriptor
buf += 4;
- put_be32(&buf[0], curlun->num_sectors); // Number of blocks
- put_be32(&buf[4], 512); // Block length
- buf[4] = 0x02; // Current capacity
+ put_unaligned_be32(curlun->num_sectors, &buf[0]);
+ /* Number of blocks */
+ put_unaligned_be32(512, &buf[4]); /* Block length */
+ buf[4] = 0x02; /* Current capacity */
return 12;
}
@@ -2882,7 +2869,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_MODE_SELECT_10:
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
+ fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
(1<<1) | (3<<7), 0,
"MODE SELECT(10)")) == 0)
@@ -2898,7 +2885,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_MODE_SENSE_10:
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
+ fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(1<<1) | (1<<2) | (3<<7), 0,
"MODE SENSE(10)")) == 0)
@@ -2923,7 +2910,8 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_READ_10:
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]) << 9;
+ fsg->data_size_from_cmnd =
+ get_unaligned_be16(&fsg->cmnd[7]) << 9;
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(1<<1) | (0xf<<2) | (3<<7), 1,
"READ(10)")) == 0)
@@ -2931,7 +2919,8 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_READ_12:
- fsg->data_size_from_cmnd = get_be32(&fsg->cmnd[6]) << 9;
+ fsg->data_size_from_cmnd =
+ get_unaligned_be32(&fsg->cmnd[6]) << 9;
if ((reply = check_command(fsg, 12, DATA_DIR_TO_HOST,
(1<<1) | (0xf<<2) | (0xf<<6), 1,
"READ(12)")) == 0)
@@ -2949,7 +2938,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
case SC_READ_HEADER:
if (!mod_data.cdrom)
goto unknown_cmnd;
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
+ fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(3<<7) | (0x1f<<1), 1,
"READ HEADER")) == 0)
@@ -2959,7 +2948,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
case SC_READ_TOC:
if (!mod_data.cdrom)
goto unknown_cmnd;
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
+ fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(7<<6) | (1<<1), 1,
"READ TOC")) == 0)
@@ -2967,7 +2956,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_READ_FORMAT_CAPACITIES:
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
+ fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(3<<7), 1,
"READ FORMAT CAPACITIES")) == 0)
@@ -3025,7 +3014,8 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_WRITE_10:
- fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]) << 9;
+ fsg->data_size_from_cmnd =
+ get_unaligned_be16(&fsg->cmnd[7]) << 9;
if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
(1<<1) | (0xf<<2) | (3<<7), 1,
"WRITE(10)")) == 0)
@@ -3033,7 +3023,8 @@ static int do_scsi_command(struct fsg_dev *fsg)
break;
case SC_WRITE_12:
- fsg->data_size_from_cmnd = get_be32(&fsg->cmnd[6]) << 9;
+ fsg->data_size_from_cmnd =
+ get_unaligned_be32(&fsg->cmnd[6]) << 9;
if ((reply = check_command(fsg, 12, DATA_DIR_FROM_HOST,
(1<<1) | (0xf<<2) | (0xf<<6), 1,
"WRITE(12)")) == 0)
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index de010c939dbb..112bb40a427c 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -110,10 +110,10 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
return -EINVAL;
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN;
- if (ep->num != (desc->bEndpointAddress & 0x0f))
+ if (ep->num != usb_endpoint_num(desc))
return -EINVAL;
- switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
+ switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_BULK:
case USB_ENDPOINT_XFER_INT:
break;
@@ -142,7 +142,7 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
/* ep1/ep2 dma direction is chosen early; it works in the other
* direction, with pio. be cautious with out-dma.
*/
- ep->is_in = (USB_DIR_IN & desc->bEndpointAddress) != 0;
+ ep->is_in = usb_endpoint_dir_in(desc);
if (ep->is_in) {
mode |= 1;
ep->dma = (use_dma != 0) && (ep->num == UDC_MSTRD_ENDPOINT);
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index d20937f28a19..7d33f50b5874 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -384,9 +384,8 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
return value;
/* halt any endpoint by doing a "wrong direction" i/o call */
- if (data->desc.bEndpointAddress & USB_DIR_IN) {
- if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
- == USB_ENDPOINT_XFER_ISOC)
+ if (usb_endpoint_dir_in(&data->desc)) {
+ if (usb_endpoint_xfer_isoc(&data->desc))
return -EINVAL;
DBG (data->dev, "%s halt\n", data->name);
spin_lock_irq (&data->dev->lock);
@@ -428,9 +427,8 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
return value;
/* halt any endpoint by doing a "wrong direction" i/o call */
- if (!(data->desc.bEndpointAddress & USB_DIR_IN)) {
- if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
- == USB_ENDPOINT_XFER_ISOC)
+ if (!usb_endpoint_dir_in(&data->desc)) {
+ if (usb_endpoint_xfer_isoc(&data->desc))
return -EINVAL;
DBG (data->dev, "%s halt\n", data->name);
spin_lock_irq (&data->dev->lock);
@@ -691,7 +689,7 @@ ep_aio_read(struct kiocb *iocb, const struct iovec *iov,
struct ep_data *epdata = iocb->ki_filp->private_data;
char *buf;
- if (unlikely(epdata->desc.bEndpointAddress & USB_DIR_IN))
+ if (unlikely(usb_endpoint_dir_in(&epdata->desc)))
return -EINVAL;
buf = kmalloc(iocb->ki_left, GFP_KERNEL);
@@ -711,7 +709,7 @@ ep_aio_write(struct kiocb *iocb, const struct iovec *iov,
size_t len = 0;
int i = 0;
- if (unlikely(!(epdata->desc.bEndpointAddress & USB_DIR_IN)))
+ if (unlikely(!usb_endpoint_dir_in(&epdata->desc)))
return -EINVAL;
buf = kmalloc(iocb->ki_left, GFP_KERNEL);
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 8cc676ecbb23..1937d8c7b433 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -38,7 +38,6 @@
#include <linux/usb.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
-#include <mach/pxa2xx-regs.h> /* FIXME: for PSSR */
#include <mach/udc.h>
#include "pxa27x_udc.h"
@@ -474,6 +473,23 @@ static inline void udc_clear_mask_UDCCR(struct pxa_udc *udc, int mask)
}
/**
+ * ep_write_UDCCSR - set bits in UDCCSR
+ * @udc: udc device
+ * @mask: bits to set in UDCCR
+ *
+ * Sets bits in UDCCSR (UDCCSR0 and UDCCSR*).
+ *
+ * A specific case is applied to ep0 : the ACM bit is always set to 1, for
+ * SET_INTERFACE and SET_CONFIGURATION.
+ */
+static inline void ep_write_UDCCSR(struct pxa_ep *ep, int mask)
+{
+ if (is_ep0(ep))
+ mask |= UDCCSR0_ACM;
+ udc_ep_writel(ep, UDCCSR, mask);
+}
+
+/**
* ep_count_bytes_remain - get how many bytes in udc endpoint
* @ep: udc endpoint
*
@@ -861,7 +877,7 @@ static int read_packet(struct pxa_ep *ep, struct pxa27x_request *req)
*buf++ = udc_ep_readl(ep, UDCDR);
req->req.actual += count;
- udc_ep_writel(ep, UDCCSR, UDCCSR_PC);
+ ep_write_UDCCSR(ep, UDCCSR_PC);
return count;
}
@@ -969,12 +985,12 @@ static int write_fifo(struct pxa_ep *ep, struct pxa27x_request *req)
if (udccsr & UDCCSR_PC) {
ep_vdbg(ep, "Clearing Transmit Complete, udccsr=%x\n",
udccsr);
- udc_ep_writel(ep, UDCCSR, UDCCSR_PC);
+ ep_write_UDCCSR(ep, UDCCSR_PC);
}
if (udccsr & UDCCSR_TRN) {
ep_vdbg(ep, "Clearing Underrun on, udccsr=%x\n",
udccsr);
- udc_ep_writel(ep, UDCCSR, UDCCSR_TRN);
+ ep_write_UDCCSR(ep, UDCCSR_TRN);
}
count = write_packet(ep, req, max);
@@ -996,7 +1012,7 @@ static int write_fifo(struct pxa_ep *ep, struct pxa27x_request *req)
}
if (is_short)
- udc_ep_writel(ep, UDCCSR, UDCCSR_SP);
+ ep_write_UDCCSR(ep, UDCCSR_SP);
/* requests complete when all IN data is in the FIFO */
if (is_last) {
@@ -1029,7 +1045,7 @@ static int read_ep0_fifo(struct pxa_ep *ep, struct pxa27x_request *req)
while (epout_has_pkt(ep)) {
count = read_packet(ep, req);
- udc_ep_writel(ep, UDCCSR, UDCCSR0_OPC);
+ ep_write_UDCCSR(ep, UDCCSR0_OPC);
inc_ep_stats_bytes(ep, count, !USB_DIR_IN);
is_short = (count < ep->fifo_size);
@@ -1074,7 +1090,7 @@ static int write_ep0_fifo(struct pxa_ep *ep, struct pxa27x_request *req)
/* Sends either a short packet or a 0 length packet */
if (unlikely(is_short))
- udc_ep_writel(ep, UDCCSR, UDCCSR0_IPR);
+ ep_write_UDCCSR(ep, UDCCSR0_IPR);
ep_dbg(ep, "in %d bytes%s%s, %d left, req=%p, udccsr0=0x%03x\n",
count, is_short ? "/S" : "", is_last ? "/L" : "",
@@ -1277,7 +1293,7 @@ static int pxa_ep_set_halt(struct usb_ep *_ep, int value)
/* FST, FEF bits are the same for control and non control endpoints */
rc = 0;
- udc_ep_writel(ep, UDCCSR, UDCCSR_FST | UDCCSR_FEF);
+ ep_write_UDCCSR(ep, UDCCSR_FST | UDCCSR_FEF);
if (is_ep0(ep))
set_ep0state(ep->dev, STALL);
@@ -1343,7 +1359,7 @@ static void pxa_ep_fifo_flush(struct usb_ep *_ep)
udc_ep_readl(ep, UDCDR);
} else {
/* most IN status is the same, but ISO can't stall */
- udc_ep_writel(ep, UDCCSR,
+ ep_write_UDCCSR(ep,
UDCCSR_PC | UDCCSR_FEF | UDCCSR_TRN
| (EPXFERTYPE_is_ISO(ep) ? 0 : UDCCSR_SST));
}
@@ -1728,6 +1744,7 @@ static void udc_enable(struct pxa_udc *udc)
memset(&udc->stats, 0, sizeof(udc->stats));
udc_set_mask_UDCCR(udc, UDCCR_UDE);
+ ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_ACM);
udelay(2);
if (udc_readl(udc, UDCCR) & UDCCR_EMCE)
dev_err(udc->dev, "Configuration errors, udc disabled\n");
@@ -1893,6 +1910,15 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc,
nuke(ep, -EPROTO);
+ /*
+ * In the PXA320 manual, in the section about Back-to-Back setup
+ * packets, it describes this situation. The solution is to set OPC to
+ * get rid of the status packet, and then continue with the setup
+ * packet. Generalize to pxa27x CPUs.
+ */
+ if (epout_has_pkt(ep) && (ep_count_bytes_remain(ep) == 0))
+ ep_write_UDCCSR(ep, UDCCSR0_OPC);
+
/* read SETUP packet */
for (i = 0; i < 2; i++) {
if (unlikely(ep_is_empty(ep)))
@@ -1919,7 +1945,7 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc,
set_ep0state(udc, OUT_DATA_STAGE);
/* Tell UDC to enter Data Stage */
- udc_ep_writel(ep, UDCCSR, UDCCSR0_SA | UDCCSR0_OPC);
+ ep_write_UDCCSR(ep, UDCCSR0_SA | UDCCSR0_OPC);
i = udc->driver->setup(&udc->gadget, &u.r);
if (i < 0)
@@ -1929,7 +1955,7 @@ out:
stall:
ep_dbg(ep, "protocol STALL, udccsr0=%03x err %d\n",
udc_ep_readl(ep, UDCCSR), i);
- udc_ep_writel(ep, UDCCSR, UDCCSR0_FST | UDCCSR0_FTF);
+ ep_write_UDCCSR(ep, UDCCSR0_FST | UDCCSR0_FTF);
set_ep0state(udc, STALL);
goto out;
}
@@ -1966,6 +1992,8 @@ stall:
* cleared by software.
* - clearing UDCCSR0_OPC always flushes ep0. If in setup stage, never do it
* before reading ep0.
+ * This is true only for PXA27x. This is not true anymore for PXA3xx family
+ * (check Back-to-Back setup packet in developers guide).
* - irq can be called on a "packet complete" event (opc_irq=1), while
* UDCCSR0_OPC is not yet raised (delta can be as big as 100ms
* from experimentation).
@@ -1998,7 +2026,7 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq)
if (udccsr0 & UDCCSR0_SST) {
ep_dbg(ep, "clearing stall status\n");
nuke(ep, -EPIPE);
- udc_ep_writel(ep, UDCCSR, UDCCSR0_SST);
+ ep_write_UDCCSR(ep, UDCCSR0_SST);
ep0_idle(udc);
}
@@ -2023,7 +2051,7 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq)
break;
case IN_DATA_STAGE: /* GET_DESCRIPTOR */
if (epout_has_pkt(ep))
- udc_ep_writel(ep, UDCCSR, UDCCSR0_OPC);
+ ep_write_UDCCSR(ep, UDCCSR0_OPC);
if (req && !ep_is_full(ep))
completed = write_ep0_fifo(ep, req);
if (completed)
@@ -2036,7 +2064,7 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq)
ep0_end_out_req(ep, req);
break;
case STALL:
- udc_ep_writel(ep, UDCCSR, UDCCSR0_FST);
+ ep_write_UDCCSR(ep, UDCCSR0_FST);
break;
case IN_STATUS_STAGE:
/*
@@ -2131,6 +2159,7 @@ static void pxa27x_change_configuration(struct pxa_udc *udc, int config)
set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF);
udc->driver->setup(&udc->gadget, &req);
+ ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_AREN);
}
/**
@@ -2159,6 +2188,7 @@ static void pxa27x_change_interface(struct pxa_udc *udc, int iface, int alt)
set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF);
udc->driver->setup(&udc->gadget, &req);
+ ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_AREN);
}
/*
@@ -2280,7 +2310,7 @@ static void irq_udc_reset(struct pxa_udc *udc)
memset(&udc->stats, 0, sizeof udc->stats);
nuke(ep, -EPROTO);
- udc_ep_writel(ep, UDCCSR, UDCCSR0_FTF | UDCCSR0_OPC);
+ ep_write_UDCCSR(ep, UDCCSR0_FTF | UDCCSR0_OPC);
ep0_idle(udc);
}
@@ -2479,6 +2509,12 @@ static void pxa_udc_shutdown(struct platform_device *_dev)
udc_disable(udc);
}
+#ifdef CONFIG_CPU_PXA27x
+extern void pxa27x_clear_otgph(void);
+#else
+#define pxa27x_clear_otgph() do {} while (0)
+#endif
+
#ifdef CONFIG_PM
/**
* pxa_udc_suspend - Suspend udc device
@@ -2546,8 +2582,7 @@ static int pxa_udc_resume(struct platform_device *_dev)
* Software must configure the USB OTG pad, UDC, and UHC
* to the state they were in before entering sleep mode.
*/
- if (cpu_is_pxa27x())
- PSSR |= PSSR_OTGPH;
+ pxa27x_clear_otgph();
return 0;
}
@@ -2571,7 +2606,7 @@ static struct platform_driver udc_driver = {
static int __init udc_init(void)
{
- if (!cpu_is_pxa27x())
+ if (!cpu_is_pxa27x() && !cpu_is_pxa3xx())
return -ENODEV;
printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index db58125331da..e25225e26586 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -130,6 +130,8 @@
#define UP2OCR_HXOE (1 << 17) /* Transceiver Output Enable */
#define UP2OCR_SEOS (1 << 24) /* Single-Ended Output Select */
+#define UDCCSR0_ACM (1 << 9) /* Ack Control Mode */
+#define UDCCSR0_AREN (1 << 8) /* Ack Response Enable */
#define UDCCSR0_SA (1 << 7) /* Setup Active */
#define UDCCSR0_RNE (1 << 6) /* Receive FIFO Not Empty */
#define UDCCSR0_FST (1 << 5) /* Force Stall */
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 845479f7c707..1576a0520adf 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -17,6 +17,26 @@ config USB_C67X00_HCD
To compile this driver as a module, choose M here: the
module will be called c67x00.
+config USB_XHCI_HCD
+ tristate "xHCI HCD (USB 3.0) support (EXPERIMENTAL)"
+ depends on USB && PCI && EXPERIMENTAL
+ ---help---
+ The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0
+ "SuperSpeed" host controller hardware.
+
+ To compile this driver as a module, choose M here: the
+ module will be called xhci-hcd.
+
+config USB_XHCI_HCD_DEBUGGING
+ bool "Debugging for the xHCI host controller"
+ depends on USB_XHCI_HCD
+ ---help---
+ Say 'Y' to turn on debugging for the xHCI host controller driver.
+ This will spew debugging output, even in interrupt context.
+ This should only be used for debugging xHCI driver bugs.
+
+ If unsure, say N.
+
config USB_EHCI_HCD
tristate "EHCI HCD (USB 2.0) support"
depends on USB && USB_ARCH_HAS_EHCI
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index f163571e33d8..289d748bb414 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -12,6 +12,7 @@ fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
ifeq ($(CONFIG_FHCI_DEBUG),y)
fhci-objs += fhci-dbg.o
endif
+xhci-objs := xhci-hcd.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o
obj-$(CONFIG_USB_WHCI_HCD) += whci/
@@ -23,6 +24,7 @@ obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
+obj-$(CONFIG_USB_XHCI_HCD) += xhci.o
obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o
obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c637207a1c80..a2ca9cbf2809 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1097,7 +1097,7 @@ static int __init ehci_hcd_init(void)
sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
#ifdef DEBUG
- ehci_debug_root = debugfs_create_dir("ehci", NULL);
+ ehci_debug_root = debugfs_create_dir("ehci", usb_debug_root);
if (!ehci_debug_root) {
retval = -ENOENT;
goto err_debug;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 97a53a48a3d8..f46ad27c9a90 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -391,7 +391,7 @@ static inline void create_companion_file(struct ehci_hcd *ehci)
/* with integrated TT there is no companion! */
if (!ehci_is_TDI(ehci))
- i = device_create_file(ehci_to_hcd(ehci)->self.dev,
+ i = device_create_file(ehci_to_hcd(ehci)->self.controller,
&dev_attr_companion);
}
@@ -399,7 +399,7 @@ static inline void remove_companion_file(struct ehci_hcd *ehci)
{
/* with integrated TT there is no companion! */
if (!ehci_is_TDI(ehci))
- device_remove_file(ehci_to_hcd(ehci)->self.dev,
+ device_remove_file(ehci_to_hcd(ehci)->self.controller,
&dev_attr_companion);
}
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9d487908012e..17dc15407a07 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -187,7 +187,7 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
}
}
-static int __init ehci_orion_drv_probe(struct platform_device *pdev)
+static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)
{
struct orion_ehci_data *pd = pdev->dev.platform_data;
struct resource *res;
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 5aa8bce90e1f..e74948898f76 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -268,7 +268,7 @@ done:
* Also they depend on separate root hub suspend/resume.
*/
-static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
+static int ehci_pci_suspend(struct usb_hcd *hcd)
{
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
unsigned long flags;
@@ -293,12 +293,6 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
ehci_writel(ehci, 0, &ehci->regs->intr_enable);
(void)ehci_readl(ehci, &ehci->regs->intr_enable);
- /* make sure snapshot being resumed re-enumerates everything */
- if (message.event == PM_EVENT_PRETHAW) {
- ehci_halt(ehci);
- ehci_reset(ehci);
- }
-
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
bail:
spin_unlock_irqrestore (&ehci->lock, flags);
@@ -309,7 +303,7 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
return rc;
}
-static int ehci_pci_resume(struct usb_hcd *hcd)
+static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated)
{
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
@@ -322,10 +316,12 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
/* Mark hardware accessible again as we are out of D3 state by now */
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
- /* If CF is still set, we maintained PCI Vaux power.
+ /* If CF is still set and we aren't resuming from hibernation
+ * then we maintained PCI Vaux power.
* Just undo the effect of ehci_pci_suspend().
*/
- if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) {
+ if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF &&
+ !hibernated) {
int mask = INTR_MASK;
if (!hcd->self.root_hub->do_remote_wakeup)
@@ -335,7 +331,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
return 0;
}
- ehci_dbg(ehci, "lost power, restarting\n");
usb_root_hub_lost_power(hcd->self.root_hub);
/* Else reset, to cope with power loss or flush-to-storage
@@ -429,10 +424,11 @@ static struct pci_driver ehci_pci_driver = {
.probe = usb_hcd_pci_probe,
.remove = usb_hcd_pci_remove,
+ .shutdown = usb_hcd_pci_shutdown,
-#ifdef CONFIG_PM
- .suspend = usb_hcd_pci_suspend,
- .resume = usb_hcd_pci_resume,
+#ifdef CONFIG_PM_SLEEP
+ .driver = {
+ .pm = &usb_hcd_pci_pm_ops
+ },
#endif
- .shutdown = usb_hcd_pci_shutdown,
};
diff --git a/drivers/usb/host/fhci-dbg.c b/drivers/usb/host/fhci-dbg.c
index ea8a4255c5da..e799f86dab11 100644
--- a/drivers/usb/host/fhci-dbg.c
+++ b/drivers/usb/host/fhci-dbg.c
@@ -108,7 +108,7 @@ void fhci_dfs_create(struct fhci_hcd *fhci)
{
struct device *dev = fhci_to_hcd(fhci)->self.controller;
- fhci->dfs_root = debugfs_create_dir(dev_name(dev), NULL);
+ fhci->dfs_root = debugfs_create_dir(dev_name(dev), usb_debug_root);
if (!fhci->dfs_root) {
WARN_ON(1);
return;
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index cbf30e515f29..88b03214622b 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -172,25 +172,6 @@ error_cluster_id_get:
}
-static int hwahc_op_suspend(struct usb_hcd *usb_hcd, pm_message_t msg)
-{
- struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
- struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
- dev_err(wusbhc->dev, "%s (%p [%p], 0x%lx) UNIMPLEMENTED\n", __func__,
- usb_hcd, hwahc, *(unsigned long *) &msg);
- return -ENOSYS;
-}
-
-static int hwahc_op_resume(struct usb_hcd *usb_hcd)
-{
- struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
- struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
-
- dev_err(wusbhc->dev, "%s (%p [%p]) UNIMPLEMENTED\n", __func__,
- usb_hcd, hwahc);
- return -ENOSYS;
-}
-
/*
* No need to abort pipes, as when this is called, all the children
* has been disconnected and that has done it [through
@@ -598,8 +579,6 @@ static struct hc_driver hwahc_hc_driver = {
.flags = HCD_USB2, /* FIXME */
.reset = hwahc_op_reset,
.start = hwahc_op_start,
- .pci_suspend = hwahc_op_suspend,
- .pci_resume = hwahc_op_resume,
.stop = hwahc_op_stop,
.get_frame_number = hwahc_op_get_frame_number,
.urb_enqueue = hwahc_op_urb_enqueue,
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index cd07ea3f0c63..15438469f21a 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -1658,6 +1658,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
u32 reg_base, or_reg, skip_reg;
unsigned long flags;
struct ptd ptd;
+ packet_enqueue *pe;
switch (usb_pipetype(urb->pipe)) {
case PIPE_ISOCHRONOUS:
@@ -1669,6 +1670,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
reg_base = INT_REGS_OFFSET;
or_reg = HC_INT_IRQ_MASK_OR_REG;
skip_reg = HC_INT_PTD_SKIPMAP_REG;
+ pe = enqueue_an_INT_packet;
break;
default:
@@ -1676,6 +1678,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
reg_base = ATL_REGS_OFFSET;
or_reg = HC_ATL_IRQ_MASK_OR_REG;
skip_reg = HC_ATL_PTD_SKIPMAP_REG;
+ pe = enqueue_an_ATL_packet;
break;
}
@@ -1687,6 +1690,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
u32 skip_map;
u32 or_map;
struct isp1760_qtd *qtd;
+ struct isp1760_qh *qh = ints->qh;
skip_map = isp1760_readl(hcd->regs + skip_reg);
skip_map |= 1 << i;
@@ -1699,8 +1703,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
priv_write_copy(priv, (u32 *)&ptd, hcd->regs + reg_base
+ i * sizeof(ptd), sizeof(ptd));
qtd = ints->qtd;
-
- clean_up_qtdlist(qtd);
+ qtd = clean_up_qtdlist(qtd);
free_mem(priv, ints->payload);
@@ -1711,7 +1714,24 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
ints->payload = 0;
isp1760_urb_done(priv, urb, status);
+ if (qtd)
+ pe(hcd, qh, qtd);
break;
+
+ } else if (ints->qtd) {
+ struct isp1760_qtd *qtd, *prev_qtd = ints->qtd;
+
+ for (qtd = ints->qtd->hw_next; qtd; qtd = qtd->hw_next) {
+ if (qtd->urb == urb) {
+ prev_qtd->hw_next = clean_up_qtdlist(qtd);
+ isp1760_urb_done(priv, urb, status);
+ break;
+ }
+ prev_qtd = qtd;
+ }
+ /* we found the urb before the end of the list */
+ if (qtd)
+ break;
}
ints++;
}
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index d3269656aa4d..811f5dfdc582 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -431,7 +431,7 @@ static struct dentry *ohci_debug_root;
struct debug_buffer {
ssize_t (*fill_func)(struct debug_buffer *); /* fill method */
- struct device *dev;
+ struct ohci_hcd *ohci;
struct mutex mutex; /* protect filling of buffer */
size_t count; /* number of characters filled into buffer */
char *page;
@@ -505,15 +505,11 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
static ssize_t fill_async_buffer(struct debug_buffer *buf)
{
- struct usb_bus *bus;
- struct usb_hcd *hcd;
struct ohci_hcd *ohci;
size_t temp;
unsigned long flags;
- bus = dev_get_drvdata(buf->dev);
- hcd = bus_to_hcd(bus);
- ohci = hcd_to_ohci(hcd);
+ ohci = buf->ohci;
/* display control and bulk lists together, for simplicity */
spin_lock_irqsave (&ohci->lock, flags);
@@ -529,8 +525,6 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
{
- struct usb_bus *bus;
- struct usb_hcd *hcd;
struct ohci_hcd *ohci;
struct ed **seen, *ed;
unsigned long flags;
@@ -542,9 +536,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
return 0;
seen_count = 0;
- bus = (struct usb_bus *)dev_get_drvdata(buf->dev);
- hcd = bus_to_hcd(bus);
- ohci = hcd_to_ohci(hcd);
+ ohci = buf->ohci;
next = buf->page;
size = PAGE_SIZE;
@@ -626,7 +618,6 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
static ssize_t fill_registers_buffer(struct debug_buffer *buf)
{
- struct usb_bus *bus;
struct usb_hcd *hcd;
struct ohci_hcd *ohci;
struct ohci_regs __iomem *regs;
@@ -635,9 +626,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
char *next;
u32 rdata;
- bus = (struct usb_bus *)dev_get_drvdata(buf->dev);
- hcd = bus_to_hcd(bus);
- ohci = hcd_to_ohci(hcd);
+ ohci = buf->ohci;
+ hcd = ohci_to_hcd(ohci);
regs = ohci->regs;
next = buf->page;
size = PAGE_SIZE;
@@ -710,7 +700,7 @@ done:
return PAGE_SIZE - size;
}
-static struct debug_buffer *alloc_buffer(struct device *dev,
+static struct debug_buffer *alloc_buffer(struct ohci_hcd *ohci,
ssize_t (*fill_func)(struct debug_buffer *))
{
struct debug_buffer *buf;
@@ -718,7 +708,7 @@ static struct debug_buffer *alloc_buffer(struct device *dev,
buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL);
if (buf) {
- buf->dev = dev;
+ buf->ohci = ohci;
buf->fill_func = fill_func;
mutex_init(&buf->mutex);
}
@@ -810,26 +800,25 @@ static int debug_registers_open(struct inode *inode, struct file *file)
static inline void create_debug_files (struct ohci_hcd *ohci)
{
struct usb_bus *bus = &ohci_to_hcd(ohci)->self;
- struct device *dev = bus->dev;
ohci->debug_dir = debugfs_create_dir(bus->bus_name, ohci_debug_root);
if (!ohci->debug_dir)
goto dir_error;
ohci->debug_async = debugfs_create_file("async", S_IRUGO,
- ohci->debug_dir, dev,
+ ohci->debug_dir, ohci,
&debug_async_fops);
if (!ohci->debug_async)
goto async_error;
ohci->debug_periodic = debugfs_create_file("periodic", S_IRUGO,
- ohci->debug_dir, dev,
+ ohci->debug_dir, ohci,
&debug_periodic_fops);
if (!ohci->debug_periodic)
goto periodic_error;
ohci->debug_registers = debugfs_create_file("registers", S_IRUGO,
- ohci->debug_dir, dev,
+ ohci->debug_dir, ohci,
&debug_registers_fops);
if (!ohci->debug_registers)
goto registers_error;
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 25db704f3a2a..58151687d351 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -571,7 +571,7 @@ static int ohci_init (struct ohci_hcd *ohci)
*/
static int ohci_run (struct ohci_hcd *ohci)
{
- u32 mask, temp;
+ u32 mask, val;
int first = ohci->fminterval == 0;
struct usb_hcd *hcd = ohci_to_hcd(ohci);
@@ -580,8 +580,8 @@ static int ohci_run (struct ohci_hcd *ohci)
/* boot firmware should have set this up (5.1.1.3.1) */
if (first) {
- temp = ohci_readl (ohci, &ohci->regs->fminterval);
- ohci->fminterval = temp & 0x3fff;
+ val = ohci_readl (ohci, &ohci->regs->fminterval);
+ ohci->fminterval = val & 0x3fff;
if (ohci->fminterval != FI)
ohci_dbg (ohci, "fminterval delta %d\n",
ohci->fminterval - FI);
@@ -600,25 +600,25 @@ static int ohci_run (struct ohci_hcd *ohci)
switch (ohci->hc_control & OHCI_CTRL_HCFS) {
case OHCI_USB_OPER:
- temp = 0;
+ val = 0;
break;
case OHCI_USB_SUSPEND:
case OHCI_USB_RESUME:
ohci->hc_control &= OHCI_CTRL_RWC;
ohci->hc_control |= OHCI_USB_RESUME;
- temp = 10 /* msec wait */;
+ val = 10 /* msec wait */;
break;
// case OHCI_USB_RESET:
default:
ohci->hc_control &= OHCI_CTRL_RWC;
ohci->hc_control |= OHCI_USB_RESET;
- temp = 50 /* msec wait */;
+ val = 50 /* msec wait */;
break;
}
ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
// flush the writes
(void) ohci_readl (ohci, &ohci->regs->control);
- msleep(temp);
+ msleep(val);
memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
@@ -628,9 +628,9 @@ static int ohci_run (struct ohci_hcd *ohci)
retry:
/* HC Reset requires max 10 us delay */
ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
- temp = 30; /* ... allow extra time */
+ val = 30; /* ... allow extra time */
while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
- if (--temp == 0) {
+ if (--val == 0) {
spin_unlock_irq (&ohci->lock);
ohci_err (ohci, "USB HC reset timed out!\n");
return -1;
@@ -699,23 +699,23 @@ retry:
ohci_writel (ohci, mask, &ohci->regs->intrenable);
/* handle root hub init quirks ... */
- temp = roothub_a (ohci);
- temp &= ~(RH_A_PSM | RH_A_OCPM);
+ val = roothub_a (ohci);
+ val &= ~(RH_A_PSM | RH_A_OCPM);
if (ohci->flags & OHCI_QUIRK_SUPERIO) {
/* NSC 87560 and maybe others */
- temp |= RH_A_NOCP;
- temp &= ~(RH_A_POTPGT | RH_A_NPS);
- ohci_writel (ohci, temp, &ohci->regs->roothub.a);
+ val |= RH_A_NOCP;
+ val &= ~(RH_A_POTPGT | RH_A_NPS);
+ ohci_writel (ohci, val, &ohci->regs->roothub.a);
} else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
(ohci->flags & OHCI_QUIRK_HUB_POWER)) {
/* hub power always on; required for AMD-756 and some
* Mac platforms. ganged overcurrent reporting, if any.
*/
- temp |= RH_A_NPS;
- ohci_writel (ohci, temp, &ohci->regs->roothub.a);
+ val |= RH_A_NPS;
+ ohci_writel (ohci, val, &ohci->regs->roothub.a);
}
ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
- ohci_writel (ohci, (temp & RH_A_NPS) ? 0 : RH_B_PPCM,
+ ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM,
&ohci->regs->roothub.b);
// flush those writes
(void) ohci_readl (ohci, &ohci->regs->control);
@@ -724,7 +724,7 @@ retry:
spin_unlock_irq (&ohci->lock);
// POTPGT delay is bits 24-31, in 2 ms units.
- mdelay ((temp >> 23) & 0x1fe);
+ mdelay ((val >> 23) & 0x1fe);
hcd->state = HC_STATE_RUNNING;
if (quirk_zfmicro(ohci)) {
@@ -1105,7 +1105,7 @@ static int __init ohci_hcd_mod_init(void)
set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
#ifdef DEBUG
- ohci_debug_root = debugfs_create_dir("ohci", NULL);
+ ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);
if (!ohci_debug_root) {
retval = -ENOENT;
goto error_debug;
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index f9961b4c0da3..d2ba04dd785e 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -372,7 +372,7 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd)
#ifdef CONFIG_PM
-static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
+static int ohci_pci_suspend(struct usb_hcd *hcd)
{
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
unsigned long flags;
@@ -394,10 +394,6 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
(void)ohci_readl(ohci, &ohci->regs->intrdisable);
- /* make sure snapshot being resumed re-enumerates everything */
- if (message.event == PM_EVENT_PRETHAW)
- ohci_usb_reset(ohci);
-
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
bail:
spin_unlock_irqrestore (&ohci->lock, flags);
@@ -406,9 +402,14 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
}
-static int ohci_pci_resume (struct usb_hcd *hcd)
+static int ohci_pci_resume(struct usb_hcd *hcd, bool hibernated)
{
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+
+ /* Make sure resume from hibernation re-enumerates everything */
+ if (hibernated)
+ ohci_usb_reset(hcd_to_ohci(hcd));
+
ohci_finish_controller_resume(hcd);
return 0;
}
@@ -484,12 +485,11 @@ static struct pci_driver ohci_pci_driver = {
.probe = usb_hcd_pci_probe,
.remove = usb_hcd_pci_remove,
+ .shutdown = usb_hcd_pci_shutdown,
-#ifdef CONFIG_PM
- .suspend = usb_hcd_pci_suspend,
- .resume = usb_hcd_pci_resume,
+#ifdef CONFIG_PM_SLEEP
+ .driver = {
+ .pm = &usb_hcd_pci_pm_ops
+ },
#endif
-
- .shutdown = usb_hcd_pci_shutdown,
};
-
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 033c2846ce59..83b5f9cea85a 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/acpi.h>
#include "pci-quirks.h"
+#include "xhci-ext-caps.h"
#define UHCI_USBLEGSUP 0xc0 /* legacy support */
@@ -341,7 +342,127 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
return;
}
+/*
+ * handshake - spin reading a register until handshake completes
+ * @ptr: address of hc register to be read
+ * @mask: bits to look at in result of read
+ * @done: value of those bits when handshake succeeds
+ * @wait_usec: timeout in microseconds
+ * @delay_usec: delay in microseconds to wait between polling
+ *
+ * Polls a register every delay_usec microseconds.
+ * Returns 0 when the mask bits have the value done.
+ * Returns -ETIMEDOUT if this condition is not true after
+ * wait_usec microseconds have passed.
+ */
+static int handshake(void __iomem *ptr, u32 mask, u32 done,
+ int wait_usec, int delay_usec)
+{
+ u32 result;
+
+ do {
+ result = readl(ptr);
+ result &= mask;
+ if (result == done)
+ return 0;
+ udelay(delay_usec);
+ wait_usec -= delay_usec;
+ } while (wait_usec > 0);
+ return -ETIMEDOUT;
+}
+
+/**
+ * PCI Quirks for xHCI.
+ *
+ * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS.
+ * It signals to the BIOS that the OS wants control of the host controller,
+ * and then waits 5 seconds for the BIOS to hand over control.
+ * If we timeout, assume the BIOS is broken and take control anyway.
+ */
+static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev)
+{
+ void __iomem *base;
+ int ext_cap_offset;
+ void __iomem *op_reg_base;
+ u32 val;
+ int timeout;
+
+ if (!mmio_resource_enabled(pdev, 0))
+ return;
+
+ base = ioremap_nocache(pci_resource_start(pdev, 0),
+ pci_resource_len(pdev, 0));
+ if (base == NULL)
+ return;
+ /*
+ * Find the Legacy Support Capability register -
+ * this is optional for xHCI host controllers.
+ */
+ ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET);
+ do {
+ if (!ext_cap_offset)
+ /* We've reached the end of the extended capabilities */
+ goto hc_init;
+ val = readl(base + ext_cap_offset);
+ if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY)
+ break;
+ ext_cap_offset = xhci_find_next_cap_offset(base, ext_cap_offset);
+ } while (1);
+
+ /* If the BIOS owns the HC, signal that the OS wants it, and wait */
+ if (val & XHCI_HC_BIOS_OWNED) {
+ writel(val & XHCI_HC_OS_OWNED, base + ext_cap_offset);
+
+ /* Wait for 5 seconds with 10 microsecond polling interval */
+ timeout = handshake(base + ext_cap_offset, XHCI_HC_BIOS_OWNED,
+ 0, 5000, 10);
+
+ /* Assume a buggy BIOS and take HC ownership anyway */
+ if (timeout) {
+ dev_warn(&pdev->dev, "xHCI BIOS handoff failed"
+ " (BIOS bug ?) %08x\n", val);
+ writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
+ }
+ }
+
+ /* Disable any BIOS SMIs */
+ writel(XHCI_LEGACY_DISABLE_SMI,
+ base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
+
+hc_init:
+ op_reg_base = base + XHCI_HC_LENGTH(readl(base));
+
+ /* Wait for the host controller to be ready before writing any
+ * operational or runtime registers. Wait 5 seconds and no more.
+ */
+ timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_CNR, 0,
+ 5000, 10);
+ /* Assume a buggy HC and start HC initialization anyway */
+ if (timeout) {
+ val = readl(op_reg_base + XHCI_STS_OFFSET);
+ dev_warn(&pdev->dev,
+ "xHCI HW not ready after 5 sec (HC bug?) "
+ "status = 0x%x\n", val);
+ }
+
+ /* Send the halt and disable interrupts command */
+ val = readl(op_reg_base + XHCI_CMD_OFFSET);
+ val &= ~(XHCI_CMD_RUN | XHCI_IRQS);
+ writel(val, op_reg_base + XHCI_CMD_OFFSET);
+
+ /* Wait for the HC to halt - poll every 125 usec (one microframe). */
+ timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_HALT, 1,
+ XHCI_MAX_HALT_USEC, 125);
+ if (timeout) {
+ val = readl(op_reg_base + XHCI_STS_OFFSET);
+ dev_warn(&pdev->dev,
+ "xHCI HW did not halt within %d usec "
+ "status = 0x%x\n", XHCI_MAX_HALT_USEC, val);
+ }
+
+ iounmap(base);
+}
static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
{
@@ -351,5 +472,7 @@ static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
quirk_usb_handoff_ohci(pdev);
else if (pdev->class == PCI_CLASS_SERIAL_USB_EHCI)
quirk_usb_disable_ehci(pdev);
+ else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI)
+ quirk_usb_handoff_xhci(pdev);
}
DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff);
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index f1626e58c141..3e1216ad86bd 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2373,7 +2373,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
return 0;
}
-static int __init r8a66597_probe(struct platform_device *pdev)
+static int __devinit r8a66597_probe(struct platform_device *pdev)
{
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
char clk_name[8];
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index cf5e4cf7ea42..274751b4409c 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -769,7 +769,7 @@ static int uhci_rh_resume(struct usb_hcd *hcd)
return rc;
}
-static int uhci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
+static int uhci_pci_suspend(struct usb_hcd *hcd)
{
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
int rc = 0;
@@ -795,10 +795,6 @@ static int uhci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
/* FIXME: Enable non-PME# remote wakeup? */
- /* make sure snapshot being resumed re-enumerates everything */
- if (message.event == PM_EVENT_PRETHAW)
- uhci_hc_died(uhci);
-
done_okay:
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
done:
@@ -806,7 +802,7 @@ done:
return rc;
}
-static int uhci_pci_resume(struct usb_hcd *hcd)
+static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
{
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
@@ -820,6 +816,10 @@ static int uhci_pci_resume(struct usb_hcd *hcd)
spin_lock_irq(&uhci->lock);
+ /* Make sure resume from hibernation re-enumerates everything */
+ if (hibernated)
+ uhci_hc_died(uhci);
+
/* FIXME: Disable non-PME# remote wakeup? */
/* The firmware or a boot kernel may have changed the controller
@@ -940,10 +940,11 @@ static struct pci_driver uhci_pci_driver = {
.remove = usb_hcd_pci_remove,
.shutdown = uhci_shutdown,
-#ifdef CONFIG_PM
- .suspend = usb_hcd_pci_suspend,
- .resume = usb_hcd_pci_resume,
-#endif /* PM */
+#ifdef CONFIG_PM_SLEEP
+ .driver = {
+ .pm = &usb_hcd_pci_pm_ops
+ },
+#endif
};
static int __init uhci_hcd_init(void)
@@ -961,7 +962,7 @@ static int __init uhci_hcd_init(void)
errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL);
if (!errbuf)
goto errbuf_failed;
- uhci_debugfs_root = debugfs_create_dir("uhci", NULL);
+ uhci_debugfs_root = debugfs_create_dir("uhci", usb_debug_root);
if (!uhci_debugfs_root)
goto debug_failed;
}
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 3e5807d14ffb..64e57bfe236b 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -260,7 +260,7 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
INIT_LIST_HEAD(&qh->node);
if (udev) { /* Normal QH */
- qh->type = hep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+ qh->type = usb_endpoint_type(&hep->desc);
if (qh->type != USB_ENDPOINT_XFER_ISOC) {
qh->dummy_td = uhci_alloc_td(uhci);
if (!qh->dummy_td) {
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
new file mode 100644
index 000000000000..6473cbf329f9
--- /dev/null
+++ b/drivers/usb/host/xhci-dbg.c
@@ -0,0 +1,485 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "xhci.h"
+
+#define XHCI_INIT_VALUE 0x0
+
+/* Add verbose debugging later, just print everything for now */
+
+void xhci_dbg_regs(struct xhci_hcd *xhci)
+{
+ u32 temp;
+
+ xhci_dbg(xhci, "// xHCI capability registers at %p:\n",
+ xhci->cap_regs);
+ temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
+ xhci_dbg(xhci, "// @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n",
+ &xhci->cap_regs->hc_capbase, temp);
+ xhci_dbg(xhci, "// CAPLENGTH: 0x%x\n",
+ (unsigned int) HC_LENGTH(temp));
+#if 0
+ xhci_dbg(xhci, "// HCIVERSION: 0x%x\n",
+ (unsigned int) HC_VERSION(temp));
+#endif
+
+ xhci_dbg(xhci, "// xHCI operational registers at %p:\n", xhci->op_regs);
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->run_regs_off);
+ xhci_dbg(xhci, "// @%p = 0x%x RTSOFF\n",
+ &xhci->cap_regs->run_regs_off,
+ (unsigned int) temp & RTSOFF_MASK);
+ xhci_dbg(xhci, "// xHCI runtime registers at %p:\n", xhci->run_regs);
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->db_off);
+ xhci_dbg(xhci, "// @%p = 0x%x DBOFF\n", &xhci->cap_regs->db_off, temp);
+ xhci_dbg(xhci, "// Doorbell array at %p:\n", xhci->dba);
+}
+
+static void xhci_print_cap_regs(struct xhci_hcd *xhci)
+{
+ u32 temp;
+
+ xhci_dbg(xhci, "xHCI capability registers at %p:\n", xhci->cap_regs);
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
+ xhci_dbg(xhci, "CAPLENGTH AND HCIVERSION 0x%x:\n",
+ (unsigned int) temp);
+ xhci_dbg(xhci, "CAPLENGTH: 0x%x\n",
+ (unsigned int) HC_LENGTH(temp));
+ xhci_dbg(xhci, "HCIVERSION: 0x%x\n",
+ (unsigned int) HC_VERSION(temp));
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params1);
+ xhci_dbg(xhci, "HCSPARAMS 1: 0x%x\n",
+ (unsigned int) temp);
+ xhci_dbg(xhci, " Max device slots: %u\n",
+ (unsigned int) HCS_MAX_SLOTS(temp));
+ xhci_dbg(xhci, " Max interrupters: %u\n",
+ (unsigned int) HCS_MAX_INTRS(temp));
+ xhci_dbg(xhci, " Max ports: %u\n",
+ (unsigned int) HCS_MAX_PORTS(temp));
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params2);
+ xhci_dbg(xhci, "HCSPARAMS 2: 0x%x\n",
+ (unsigned int) temp);
+ xhci_dbg(xhci, " Isoc scheduling threshold: %u\n",
+ (unsigned int) HCS_IST(temp));
+ xhci_dbg(xhci, " Maximum allowed segments in event ring: %u\n",
+ (unsigned int) HCS_ERST_MAX(temp));
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
+ xhci_dbg(xhci, "HCSPARAMS 3 0x%x:\n",
+ (unsigned int) temp);
+ xhci_dbg(xhci, " Worst case U1 device exit latency: %u\n",
+ (unsigned int) HCS_U1_LATENCY(temp));
+ xhci_dbg(xhci, " Worst case U2 device exit latency: %u\n",
+ (unsigned int) HCS_U2_LATENCY(temp));
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
+ xhci_dbg(xhci, "HCC PARAMS 0x%x:\n", (unsigned int) temp);
+ xhci_dbg(xhci, " HC generates %s bit addresses\n",
+ HCC_64BIT_ADDR(temp) ? "64" : "32");
+ /* FIXME */
+ xhci_dbg(xhci, " FIXME: more HCCPARAMS debugging\n");
+
+ temp = xhci_readl(xhci, &xhci->cap_regs->run_regs_off);
+ xhci_dbg(xhci, "RTSOFF 0x%x:\n", temp & RTSOFF_MASK);
+}
+
+static void xhci_print_command_reg(struct xhci_hcd *xhci)
+{
+ u32 temp;
+
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+ xhci_dbg(xhci, "USBCMD 0x%x:\n", temp);
+ xhci_dbg(xhci, " HC is %s\n",
+ (temp & CMD_RUN) ? "running" : "being stopped");
+ xhci_dbg(xhci, " HC has %sfinished hard reset\n",
+ (temp & CMD_RESET) ? "not " : "");
+ xhci_dbg(xhci, " Event Interrupts %s\n",
+ (temp & CMD_EIE) ? "enabled " : "disabled");
+ xhci_dbg(xhci, " Host System Error Interrupts %s\n",
+ (temp & CMD_EIE) ? "enabled " : "disabled");
+ xhci_dbg(xhci, " HC has %sfinished light reset\n",
+ (temp & CMD_LRESET) ? "not " : "");
+}
+
+static void xhci_print_status(struct xhci_hcd *xhci)
+{
+ u32 temp;
+
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ xhci_dbg(xhci, "USBSTS 0x%x:\n", temp);
+ xhci_dbg(xhci, " Event ring is %sempty\n",
+ (temp & STS_EINT) ? "not " : "");
+ xhci_dbg(xhci, " %sHost System Error\n",
+ (temp & STS_FATAL) ? "WARNING: " : "No ");
+ xhci_dbg(xhci, " HC is %s\n",
+ (temp & STS_HALT) ? "halted" : "running");
+}
+
+static void xhci_print_op_regs(struct xhci_hcd *xhci)
+{
+ xhci_dbg(xhci, "xHCI operational registers at %p:\n", xhci->op_regs);
+ xhci_print_command_reg(xhci);
+ xhci_print_status(xhci);
+}
+
+static void xhci_print_ports(struct xhci_hcd *xhci)
+{
+ u32 __iomem *addr;
+ int i, j;
+ int ports;
+ char *names[NUM_PORT_REGS] = {
+ "status",
+ "power",
+ "link",
+ "reserved",
+ };
+
+ ports = HCS_MAX_PORTS(xhci->hcs_params1);
+ addr = &xhci->op_regs->port_status_base;
+ for (i = 0; i < ports; i++) {
+ for (j = 0; j < NUM_PORT_REGS; ++j) {
+ xhci_dbg(xhci, "%p port %s reg = 0x%x\n",
+ addr, names[j],
+ (unsigned int) xhci_readl(xhci, addr));
+ addr++;
+ }
+ }
+}
+
+void xhci_print_ir_set(struct xhci_hcd *xhci, struct intr_reg *ir_set, int set_num)
+{
+ void *addr;
+ u32 temp;
+
+ addr = &ir_set->irq_pending;
+ temp = xhci_readl(xhci, addr);
+ if (temp == XHCI_INIT_VALUE)
+ return;
+
+ xhci_dbg(xhci, " %p: ir_set[%i]\n", ir_set, set_num);
+
+ xhci_dbg(xhci, " %p: ir_set.pending = 0x%x\n", addr,
+ (unsigned int)temp);
+
+ addr = &ir_set->irq_control;
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, " %p: ir_set.control = 0x%x\n", addr,
+ (unsigned int)temp);
+
+ addr = &ir_set->erst_size;
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, " %p: ir_set.erst_size = 0x%x\n", addr,
+ (unsigned int)temp);
+
+ addr = &ir_set->rsvd;
+ temp = xhci_readl(xhci, addr);
+ if (temp != XHCI_INIT_VALUE)
+ xhci_dbg(xhci, " WARN: %p: ir_set.rsvd = 0x%x\n",
+ addr, (unsigned int)temp);
+
+ addr = &ir_set->erst_base[0];
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, " %p: ir_set.erst_base[0] = 0x%x\n",
+ addr, (unsigned int) temp);
+
+ addr = &ir_set->erst_base[1];
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, " %p: ir_set.erst_base[1] = 0x%x\n",
+ addr, (unsigned int) temp);
+
+ addr = &ir_set->erst_dequeue[0];
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, " %p: ir_set.erst_dequeue[0] = 0x%x\n",
+ addr, (unsigned int) temp);
+
+ addr = &ir_set->erst_dequeue[1];
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, " %p: ir_set.erst_dequeue[1] = 0x%x\n",
+ addr, (unsigned int) temp);
+}
+
+void xhci_print_run_regs(struct xhci_hcd *xhci)
+{
+ u32 temp;
+ int i;
+
+ xhci_dbg(xhci, "xHCI runtime registers at %p:\n", xhci->run_regs);
+ temp = xhci_readl(xhci, &xhci->run_regs->microframe_index);
+ xhci_dbg(xhci, " %p: Microframe index = 0x%x\n",
+ &xhci->run_regs->microframe_index,
+ (unsigned int) temp);
+ for (i = 0; i < 7; ++i) {
+ temp = xhci_readl(xhci, &xhci->run_regs->rsvd[i]);
+ if (temp != XHCI_INIT_VALUE)
+ xhci_dbg(xhci, " WARN: %p: Rsvd[%i] = 0x%x\n",
+ &xhci->run_regs->rsvd[i],
+ i, (unsigned int) temp);
+ }
+}
+
+void xhci_print_registers(struct xhci_hcd *xhci)
+{
+ xhci_print_cap_regs(xhci);
+ xhci_print_op_regs(xhci);
+ xhci_print_ports(xhci);
+}
+
+void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb)
+{
+ int i;
+ for (i = 0; i < 4; ++i)
+ xhci_dbg(xhci, "Offset 0x%x = 0x%x\n",
+ i*4, trb->generic.field[i]);
+}
+
+/**
+ * Debug a transfer request block (TRB).
+ */
+void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb)
+{
+ u64 address;
+ u32 type = xhci_readl(xhci, &trb->link.control) & TRB_TYPE_BITMASK;
+
+ switch (type) {
+ case TRB_TYPE(TRB_LINK):
+ xhci_dbg(xhci, "Link TRB:\n");
+ xhci_print_trb_offsets(xhci, trb);
+
+ address = trb->link.segment_ptr[0] +
+ (((u64) trb->link.segment_ptr[1]) << 32);
+ xhci_dbg(xhci, "Next ring segment DMA address = 0x%llx\n", address);
+
+ xhci_dbg(xhci, "Interrupter target = 0x%x\n",
+ GET_INTR_TARGET(trb->link.intr_target));
+ xhci_dbg(xhci, "Cycle bit = %u\n",
+ (unsigned int) (trb->link.control & TRB_CYCLE));
+ xhci_dbg(xhci, "Toggle cycle bit = %u\n",
+ (unsigned int) (trb->link.control & LINK_TOGGLE));
+ xhci_dbg(xhci, "No Snoop bit = %u\n",
+ (unsigned int) (trb->link.control & TRB_NO_SNOOP));
+ break;
+ case TRB_TYPE(TRB_TRANSFER):
+ address = trb->trans_event.buffer[0] +
+ (((u64) trb->trans_event.buffer[1]) << 32);
+ /*
+ * FIXME: look at flags to figure out if it's an address or if
+ * the data is directly in the buffer field.
+ */
+ xhci_dbg(xhci, "DMA address or buffer contents= %llu\n", address);
+ break;
+ case TRB_TYPE(TRB_COMPLETION):
+ address = trb->event_cmd.cmd_trb[0] +
+ (((u64) trb->event_cmd.cmd_trb[1]) << 32);
+ xhci_dbg(xhci, "Command TRB pointer = %llu\n", address);
+ xhci_dbg(xhci, "Completion status = %u\n",
+ (unsigned int) GET_COMP_CODE(trb->event_cmd.status));
+ xhci_dbg(xhci, "Flags = 0x%x\n", (unsigned int) trb->event_cmd.flags);
+ break;
+ default:
+ xhci_dbg(xhci, "Unknown TRB with TRB type ID %u\n",
+ (unsigned int) type>>10);
+ xhci_print_trb_offsets(xhci, trb);
+ break;
+ }
+}
+
+/**
+ * Debug a segment with an xHCI ring.
+ *
+ * @return The Link TRB of the segment, or NULL if there is no Link TRB
+ * (which is a bug, since all segments must have a Link TRB).
+ *
+ * Prints out all TRBs in the segment, even those after the Link TRB.
+ *
+ * XXX: should we print out TRBs that the HC owns? As long as we don't
+ * write, that should be fine... We shouldn't expect that the memory pointed to
+ * by the TRB is valid at all. Do we care about ones the HC owns? Probably,
+ * for HC debugging.
+ */
+void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg)
+{
+ int i;
+ u32 addr = (u32) seg->dma;
+ union xhci_trb *trb = seg->trbs;
+
+ for (i = 0; i < TRBS_PER_SEGMENT; ++i) {
+ trb = &seg->trbs[i];
+ xhci_dbg(xhci, "@%08x %08x %08x %08x %08x\n", addr,
+ (unsigned int) trb->link.segment_ptr[0],
+ (unsigned int) trb->link.segment_ptr[1],
+ (unsigned int) trb->link.intr_target,
+ (unsigned int) trb->link.control);
+ addr += sizeof(*trb);
+ }
+}
+
+void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring)
+{
+ xhci_dbg(xhci, "Ring deq = %p (virt), 0x%llx (dma)\n",
+ ring->dequeue,
+ (unsigned long long)xhci_trb_virt_to_dma(ring->deq_seg,
+ ring->dequeue));
+ xhci_dbg(xhci, "Ring deq updated %u times\n",
+ ring->deq_updates);
+ xhci_dbg(xhci, "Ring enq = %p (virt), 0x%llx (dma)\n",
+ ring->enqueue,
+ (unsigned long long)xhci_trb_virt_to_dma(ring->enq_seg,
+ ring->enqueue));
+ xhci_dbg(xhci, "Ring enq updated %u times\n",
+ ring->enq_updates);
+}
+
+/**
+ * Debugging for an xHCI ring, which is a queue broken into multiple segments.
+ *
+ * Print out each segment in the ring. Check that the DMA address in
+ * each link segment actually matches the segment's stored DMA address.
+ * Check that the link end bit is only set at the end of the ring.
+ * Check that the dequeue and enqueue pointers point to real data in this ring
+ * (not some other ring).
+ */
+void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring)
+{
+ /* FIXME: Throw an error if any segment doesn't have a Link TRB */
+ struct xhci_segment *seg;
+ struct xhci_segment *first_seg = ring->first_seg;
+ xhci_debug_segment(xhci, first_seg);
+
+ if (!ring->enq_updates && !ring->deq_updates) {
+ xhci_dbg(xhci, " Ring has not been updated\n");
+ return;
+ }
+ for (seg = first_seg->next; seg != first_seg; seg = seg->next)
+ xhci_debug_segment(xhci, seg);
+}
+
+void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst)
+{
+ u32 addr = (u32) erst->erst_dma_addr;
+ int i;
+ struct xhci_erst_entry *entry;
+
+ for (i = 0; i < erst->num_entries; ++i) {
+ entry = &erst->entries[i];
+ xhci_dbg(xhci, "@%08x %08x %08x %08x %08x\n",
+ (unsigned int) addr,
+ (unsigned int) entry->seg_addr[0],
+ (unsigned int) entry->seg_addr[1],
+ (unsigned int) entry->seg_size,
+ (unsigned int) entry->rsvd);
+ addr += sizeof(*entry);
+ }
+}
+
+void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci)
+{
+ u32 val;
+
+ val = xhci_readl(xhci, &xhci->op_regs->cmd_ring[0]);
+ xhci_dbg(xhci, "// xHC command ring deq ptr low bits + flags = 0x%x\n", val);
+ val = xhci_readl(xhci, &xhci->op_regs->cmd_ring[1]);
+ xhci_dbg(xhci, "// xHC command ring deq ptr high bits = 0x%x\n", val);
+}
+
+void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_device_control *ctx, dma_addr_t dma, unsigned int last_ep)
+{
+ int i, j;
+ int last_ep_ctx = 31;
+ /* Fields are 32 bits wide, DMA addresses are in bytes */
+ int field_size = 32 / 8;
+
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - drop flags\n",
+ &ctx->drop_flags, (unsigned long long)dma,
+ ctx->drop_flags);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - add flags\n",
+ &ctx->add_flags, (unsigned long long)dma,
+ ctx->add_flags);
+ dma += field_size;
+ for (i = 0; i > 6; ++i) {
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
+ &ctx->rsvd[i], (unsigned long long)dma,
+ ctx->rsvd[i], i);
+ dma += field_size;
+ }
+
+ xhci_dbg(xhci, "Slot Context:\n");
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - dev_info\n",
+ &ctx->slot.dev_info,
+ (unsigned long long)dma, ctx->slot.dev_info);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - dev_info2\n",
+ &ctx->slot.dev_info2,
+ (unsigned long long)dma, ctx->slot.dev_info2);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - tt_info\n",
+ &ctx->slot.tt_info,
+ (unsigned long long)dma, ctx->slot.tt_info);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - dev_state\n",
+ &ctx->slot.dev_state,
+ (unsigned long long)dma, ctx->slot.dev_state);
+ dma += field_size;
+ for (i = 0; i > 4; ++i) {
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
+ &ctx->slot.reserved[i], (unsigned long long)dma,
+ ctx->slot.reserved[i], i);
+ dma += field_size;
+ }
+
+ if (last_ep < 31)
+ last_ep_ctx = last_ep + 1;
+ for (i = 0; i < last_ep_ctx; ++i) {
+ xhci_dbg(xhci, "Endpoint %02d Context:\n", i);
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info\n",
+ &ctx->ep[i].ep_info,
+ (unsigned long long)dma, ctx->ep[i].ep_info);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info2\n",
+ &ctx->ep[i].ep_info2,
+ (unsigned long long)dma, ctx->ep[i].ep_info2);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - deq[0]\n",
+ &ctx->ep[i].deq[0],
+ (unsigned long long)dma, ctx->ep[i].deq[0]);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - deq[1]\n",
+ &ctx->ep[i].deq[1],
+ (unsigned long long)dma, ctx->ep[i].deq[1]);
+ dma += field_size;
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - tx_info\n",
+ &ctx->ep[i].tx_info,
+ (unsigned long long)dma, ctx->ep[i].tx_info);
+ dma += field_size;
+ for (j = 0; j < 3; ++j) {
+ xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
+ &ctx->ep[i].reserved[j],
+ (unsigned long long)dma,
+ ctx->ep[i].reserved[j], j);
+ dma += field_size;
+ }
+ }
+}
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
new file mode 100644
index 000000000000..ecc131c3fe33
--- /dev/null
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -0,0 +1,145 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* Up to 16 microframes to halt an HC - one microframe is 125 microsectonds */
+#define XHCI_MAX_HALT_USEC (16*125)
+/* HC not running - set to 1 when run/stop bit is cleared. */
+#define XHCI_STS_HALT (1<<0)
+
+/* HCCPARAMS offset from PCI base address */
+#define XHCI_HCC_PARAMS_OFFSET 0x10
+/* HCCPARAMS contains the first extended capability pointer */
+#define XHCI_HCC_EXT_CAPS(p) (((p)>>16)&0xffff)
+
+/* Command and Status registers offset from the Operational Registers address */
+#define XHCI_CMD_OFFSET 0x00
+#define XHCI_STS_OFFSET 0x04
+
+#define XHCI_MAX_EXT_CAPS 50
+
+/* Capability Register */
+/* bits 7:0 - how long is the Capabilities register */
+#define XHCI_HC_LENGTH(p) (((p)>>00)&0x00ff)
+
+/* Extended capability register fields */
+#define XHCI_EXT_CAPS_ID(p) (((p)>>0)&0xff)
+#define XHCI_EXT_CAPS_NEXT(p) (((p)>>8)&0xff)
+#define XHCI_EXT_CAPS_VAL(p) ((p)>>16)
+/* Extended capability IDs - ID 0 reserved */
+#define XHCI_EXT_CAPS_LEGACY 1
+#define XHCI_EXT_CAPS_PROTOCOL 2
+#define XHCI_EXT_CAPS_PM 3
+#define XHCI_EXT_CAPS_VIRT 4
+#define XHCI_EXT_CAPS_ROUTE 5
+/* IDs 6-9 reserved */
+#define XHCI_EXT_CAPS_DEBUG 10
+/* USB Legacy Support Capability - section 7.1.1 */
+#define XHCI_HC_BIOS_OWNED (1 << 16)
+#define XHCI_HC_OS_OWNED (1 << 24)
+
+/* USB Legacy Support Capability - section 7.1.1 */
+/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */
+#define XHCI_LEGACY_SUPPORT_OFFSET (0x00)
+
+/* USB Legacy Support Control and Status Register - section 7.1.2 */
+/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */
+#define XHCI_LEGACY_CONTROL_OFFSET (0x04)
+/* bits 1:2, 5:12, and 17:19 need to be preserved; bits 21:28 should be zero */
+#define XHCI_LEGACY_DISABLE_SMI ((0x3 << 1) + (0xff << 5) + (0x7 << 17))
+
+/* command register values to disable interrupts and halt the HC */
+/* start/stop HC execution - do not write unless HC is halted*/
+#define XHCI_CMD_RUN (1 << 0)
+/* Event Interrupt Enable - get irq when EINT bit is set in USBSTS register */
+#define XHCI_CMD_EIE (1 << 2)
+/* Host System Error Interrupt Enable - get irq when HSEIE bit set in USBSTS */
+#define XHCI_CMD_HSEIE (1 << 3)
+/* Enable Wrap Event - '1' means xHC generates an event when MFINDEX wraps. */
+#define XHCI_CMD_EWE (1 << 10)
+
+#define XHCI_IRQS (XHCI_CMD_EIE | XHCI_CMD_HSEIE | XHCI_CMD_EWE)
+
+/* true: Controller Not Ready to accept doorbell or op reg writes after reset */
+#define XHCI_STS_CNR (1 << 11)
+
+#include <linux/io.h>
+
+/**
+ * Return the next extended capability pointer register.
+ *
+ * @base PCI register base address.
+ *
+ * @ext_offset Offset of the 32-bit register that contains the extended
+ * capabilites pointer. If searching for the first extended capability, pass
+ * in XHCI_HCC_PARAMS_OFFSET. If searching for the next extended capability,
+ * pass in the offset of the current extended capability register.
+ *
+ * Returns 0 if there is no next extended capability register or returns the register offset
+ * from the PCI registers base address.
+ */
+static inline int xhci_find_next_cap_offset(void __iomem *base, int ext_offset)
+{
+ u32 next;
+
+ next = readl(base + ext_offset);
+
+ if (ext_offset == XHCI_HCC_PARAMS_OFFSET)
+ /* Find the first extended capability */
+ next = XHCI_HCC_EXT_CAPS(next);
+ else
+ /* Find the next extended capability */
+ next = XHCI_EXT_CAPS_NEXT(next);
+ if (!next)
+ return 0;
+ /*
+ * Address calculation from offset of extended capabilities
+ * (or HCCPARAMS) register - see section 5.3.6 and section 7.
+ */
+ return ext_offset + (next << 2);
+}
+
+/**
+ * Find the offset of the extended capabilities with capability ID id.
+ *
+ * @base PCI MMIO registers base address.
+ * @ext_offset Offset from base of the first extended capability to look at,
+ * or the address of HCCPARAMS.
+ * @id Extended capability ID to search for.
+ *
+ * This uses an arbitrary limit of XHCI_MAX_EXT_CAPS extended capabilities
+ * to make sure that the list doesn't contain a loop.
+ */
+static inline int xhci_find_ext_cap_by_id(void __iomem *base, int ext_offset, int id)
+{
+ u32 val;
+ int limit = XHCI_MAX_EXT_CAPS;
+
+ while (ext_offset && limit > 0) {
+ val = readl(base + ext_offset);
+ if (XHCI_EXT_CAPS_ID(val) == id)
+ break;
+ ext_offset = xhci_find_next_cap_offset(base, ext_offset);
+ limit--;
+ }
+ if (limit > 0)
+ return ext_offset;
+ return 0;
+}
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
new file mode 100644
index 000000000000..c6b921994b28
--- /dev/null
+++ b/drivers/usb/host/xhci-hcd.c
@@ -0,0 +1,1256 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/irq.h>
+#include <linux/module.h>
+
+#include "xhci.h"
+
+#define DRIVER_AUTHOR "Sarah Sharp"
+#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver"
+
+/* TODO: copied from ehci-hcd.c - can this be refactored? */
+/*
+ * handshake - spin reading hc until handshake completes or fails
+ * @ptr: address of hc register to be read
+ * @mask: bits to look at in result of read
+ * @done: value of those bits when handshake succeeds
+ * @usec: timeout in microseconds
+ *
+ * Returns negative errno, or zero on success
+ *
+ * Success happens when the "mask" bits have the specified value (hardware
+ * handshake done). There are two failure modes: "usec" have passed (major
+ * hardware flakeout), or the register reads as all-ones (hardware removed).
+ */
+static int handshake(struct xhci_hcd *xhci, void __iomem *ptr,
+ u32 mask, u32 done, int usec)
+{
+ u32 result;
+
+ do {
+ result = xhci_readl(xhci, ptr);
+ if (result == ~(u32)0) /* card removed */
+ return -ENODEV;
+ result &= mask;
+ if (result == done)
+ return 0;
+ udelay(1);
+ usec--;
+ } while (usec > 0);
+ return -ETIMEDOUT;
+}
+
+/*
+ * Force HC into halt state.
+ *
+ * Disable any IRQs and clear the run/stop bit.
+ * HC will complete any current and actively pipelined transactions, and
+ * should halt within 16 microframes of the run/stop bit being cleared.
+ * Read HC Halted bit in the status register to see when the HC is finished.
+ * XXX: shouldn't we set HC_STATE_HALT here somewhere?
+ */
+int xhci_halt(struct xhci_hcd *xhci)
+{
+ u32 halted;
+ u32 cmd;
+ u32 mask;
+
+ xhci_dbg(xhci, "// Halt the HC\n");
+ /* Disable all interrupts from the host controller */
+ mask = ~(XHCI_IRQS);
+ halted = xhci_readl(xhci, &xhci->op_regs->status) & STS_HALT;
+ if (!halted)
+ mask &= ~CMD_RUN;
+
+ cmd = xhci_readl(xhci, &xhci->op_regs->command);
+ cmd &= mask;
+ xhci_writel(xhci, cmd, &xhci->op_regs->command);
+
+ return handshake(xhci, &xhci->op_regs->status,
+ STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
+}
+
+/*
+ * Reset a halted HC, and set the internal HC state to HC_STATE_HALT.
+ *
+ * This resets pipelines, timers, counters, state machines, etc.
+ * Transactions will be terminated immediately, and operational registers
+ * will be set to their defaults.
+ */
+int xhci_reset(struct xhci_hcd *xhci)
+{
+ u32 command;
+ u32 state;
+
+ state = xhci_readl(xhci, &xhci->op_regs->status);
+ BUG_ON((state & STS_HALT) == 0);
+
+ xhci_dbg(xhci, "// Reset the HC\n");
+ command = xhci_readl(xhci, &xhci->op_regs->command);
+ command |= CMD_RESET;
+ xhci_writel(xhci, command, &xhci->op_regs->command);
+ /* XXX: Why does EHCI set this here? Shouldn't other code do this? */
+ xhci_to_hcd(xhci)->state = HC_STATE_HALT;
+
+ return handshake(xhci, &xhci->op_regs->command, CMD_RESET, 0, 250 * 1000);
+}
+
+/*
+ * Stop the HC from processing the endpoint queues.
+ */
+static void xhci_quiesce(struct xhci_hcd *xhci)
+{
+ /*
+ * Queues are per endpoint, so we need to disable an endpoint or slot.
+ *
+ * To disable a slot, we need to insert a disable slot command on the
+ * command ring and ring the doorbell. This will also free any internal
+ * resources associated with the slot (which might not be what we want).
+ *
+ * A Release Endpoint command sounds better - doesn't free internal HC
+ * memory, but removes the endpoints from the schedule and releases the
+ * bandwidth, disables the doorbells, and clears the endpoint enable
+ * flag. Usually used prior to a set interface command.
+ *
+ * TODO: Implement after command ring code is done.
+ */
+ BUG_ON(!HC_IS_RUNNING(xhci_to_hcd(xhci)->state));
+ xhci_dbg(xhci, "Finished quiescing -- code not written yet\n");
+}
+
+#if 0
+/* Set up MSI-X table for entry 0 (may claim other entries later) */
+static int xhci_setup_msix(struct xhci_hcd *xhci)
+{
+ int ret;
+ struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
+
+ xhci->msix_count = 0;
+ /* XXX: did I do this right? ixgbe does kcalloc for more than one */
+ xhci->msix_entries = kmalloc(sizeof(struct msix_entry), GFP_KERNEL);
+ if (!xhci->msix_entries) {
+ xhci_err(xhci, "Failed to allocate MSI-X entries\n");
+ return -ENOMEM;
+ }
+ xhci->msix_entries[0].entry = 0;
+
+ ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count);
+ if (ret) {
+ xhci_err(xhci, "Failed to enable MSI-X\n");
+ goto free_entries;
+ }
+
+ /*
+ * Pass the xhci pointer value as the request_irq "cookie".
+ * If more irqs are added, this will need to be unique for each one.
+ */
+ ret = request_irq(xhci->msix_entries[0].vector, &xhci_irq, 0,
+ "xHCI", xhci_to_hcd(xhci));
+ if (ret) {
+ xhci_err(xhci, "Failed to allocate MSI-X interrupt\n");
+ goto disable_msix;
+ }
+ xhci_dbg(xhci, "Finished setting up MSI-X\n");
+ return 0;
+
+disable_msix:
+ pci_disable_msix(pdev);
+free_entries:
+ kfree(xhci->msix_entries);
+ xhci->msix_entries = NULL;
+ return ret;
+}
+
+/* XXX: code duplication; can xhci_setup_msix call this? */
+/* Free any IRQs and disable MSI-X */
+static void xhci_cleanup_msix(struct xhci_hcd *xhci)
+{
+ struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
+ if (!xhci->msix_entries)
+ return;
+
+ free_irq(xhci->msix_entries[0].vector, xhci);
+ pci_disable_msix(pdev);
+ kfree(xhci->msix_entries);
+ xhci->msix_entries = NULL;
+ xhci_dbg(xhci, "Finished cleaning up MSI-X\n");
+}
+#endif
+
+/*
+ * Initialize memory for HCD and xHC (one-time init).
+ *
+ * Program the PAGESIZE register, initialize the device context array, create
+ * device contexts (?), set up a command ring segment (or two?), create event
+ * ring (one for now).
+ */
+int xhci_init(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int retval = 0;
+
+ xhci_dbg(xhci, "xhci_init\n");
+ spin_lock_init(&xhci->lock);
+ retval = xhci_mem_init(xhci, GFP_KERNEL);
+ xhci_dbg(xhci, "Finished xhci_init\n");
+
+ return retval;
+}
+
+/*
+ * Called in interrupt context when there might be work
+ * queued on the event ring
+ *
+ * xhci->lock must be held by caller.
+ */
+static void xhci_work(struct xhci_hcd *xhci)
+{
+ u32 temp;
+
+ /*
+ * Clear the op reg interrupt status first,
+ * so we can receive interrupts from other MSI-X interrupters.
+ * Write 1 to clear the interrupt status.
+ */
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ temp |= STS_EINT;
+ xhci_writel(xhci, temp, &xhci->op_regs->status);
+ /* FIXME when MSI-X is supported and there are multiple vectors */
+ /* Clear the MSI-X event interrupt status */
+
+ /* Acknowledge the interrupt */
+ temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ temp |= 0x3;
+ xhci_writel(xhci, temp, &xhci->ir_set->irq_pending);
+ /* Flush posted writes */
+ xhci_readl(xhci, &xhci->ir_set->irq_pending);
+
+ /* FIXME this should be a delayed service routine that clears the EHB */
+ xhci_handle_event(xhci);
+
+ /* Clear the event handler busy flag; the event ring should be empty. */
+ temp = xhci_readl(xhci, &xhci->ir_set->erst_dequeue[0]);
+ xhci_writel(xhci, temp & ~ERST_EHB, &xhci->ir_set->erst_dequeue[0]);
+ /* Flush posted writes -- FIXME is this necessary? */
+ xhci_readl(xhci, &xhci->ir_set->irq_pending);
+}
+
+/*-------------------------------------------------------------------------*/
+
+/*
+ * xHCI spec says we can get an interrupt, and if the HC has an error condition,
+ * we might get bad data out of the event ring. Section 4.10.2.7 has a list of
+ * indicators of an event TRB error, but we check the status *first* to be safe.
+ */
+irqreturn_t xhci_irq(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ u32 temp, temp2;
+
+ spin_lock(&xhci->lock);
+ /* Check if the xHC generated the interrupt, or the irq is shared */
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ temp2 = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ if (!(temp & STS_EINT) && !ER_IRQ_PENDING(temp2)) {
+ spin_unlock(&xhci->lock);
+ return IRQ_NONE;
+ }
+
+ if (temp & STS_FATAL) {
+ xhci_warn(xhci, "WARNING: Host System Error\n");
+ xhci_halt(xhci);
+ xhci_to_hcd(xhci)->state = HC_STATE_HALT;
+ spin_unlock(&xhci->lock);
+ return -ESHUTDOWN;
+ }
+
+ xhci_work(xhci);
+ spin_unlock(&xhci->lock);
+
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+void xhci_event_ring_work(unsigned long arg)
+{
+ unsigned long flags;
+ int temp;
+ struct xhci_hcd *xhci = (struct xhci_hcd *) arg;
+ int i, j;
+
+ xhci_dbg(xhci, "Poll event ring: %lu\n", jiffies);
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ xhci_dbg(xhci, "op reg status = 0x%x\n", temp);
+ temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ xhci_dbg(xhci, "ir_set 0 pending = 0x%x\n", temp);
+ xhci_dbg(xhci, "No-op commands handled = %d\n", xhci->noops_handled);
+ xhci_dbg(xhci, "HC error bitmask = 0x%x\n", xhci->error_bitmask);
+ xhci->error_bitmask = 0;
+ xhci_dbg(xhci, "Event ring:\n");
+ xhci_debug_segment(xhci, xhci->event_ring->deq_seg);
+ xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
+ temp = xhci_readl(xhci, &xhci->ir_set->erst_dequeue[0]);
+ temp &= ERST_PTR_MASK;
+ xhci_dbg(xhci, "ERST deq = 0x%x\n", temp);
+ xhci_dbg(xhci, "Command ring:\n");
+ xhci_debug_segment(xhci, xhci->cmd_ring->deq_seg);
+ xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
+ xhci_dbg_cmd_ptrs(xhci);
+ for (i = 0; i < MAX_HC_SLOTS; ++i) {
+ if (xhci->devs[i]) {
+ for (j = 0; j < 31; ++j) {
+ if (xhci->devs[i]->ep_rings[j]) {
+ xhci_dbg(xhci, "Dev %d endpoint ring %d:\n", i, j);
+ xhci_debug_segment(xhci, xhci->devs[i]->ep_rings[j]->deq_seg);
+ }
+ }
+ }
+ }
+
+ if (xhci->noops_submitted != NUM_TEST_NOOPS)
+ if (xhci_setup_one_noop(xhci))
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ if (!xhci->zombie)
+ mod_timer(&xhci->event_ring_timer, jiffies + POLL_TIMEOUT * HZ);
+ else
+ xhci_dbg(xhci, "Quit polling the event ring.\n");
+}
+#endif
+
+/*
+ * Start the HC after it was halted.
+ *
+ * This function is called by the USB core when the HC driver is added.
+ * Its opposite is xhci_stop().
+ *
+ * xhci_init() must be called once before this function can be called.
+ * Reset the HC, enable device slot contexts, program DCBAAP, and
+ * set command ring pointer and event ring pointer.
+ *
+ * Setup MSI-X vectors and enable interrupts.
+ */
+int xhci_run(struct usb_hcd *hcd)
+{
+ u32 temp;
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ void (*doorbell)(struct xhci_hcd *) = NULL;
+
+ hcd->uses_new_polling = 1;
+ hcd->poll_rh = 0;
+
+ xhci_dbg(xhci, "xhci_run\n");
+#if 0 /* FIXME: MSI not setup yet */
+ /* Do this at the very last minute */
+ ret = xhci_setup_msix(xhci);
+ if (!ret)
+ return ret;
+
+ return -ENOSYS;
+#endif
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+ init_timer(&xhci->event_ring_timer);
+ xhci->event_ring_timer.data = (unsigned long) xhci;
+ xhci->event_ring_timer.function = xhci_event_ring_work;
+ /* Poll the event ring */
+ xhci->event_ring_timer.expires = jiffies + POLL_TIMEOUT * HZ;
+ xhci->zombie = 0;
+ xhci_dbg(xhci, "Setting event ring polling timer\n");
+ add_timer(&xhci->event_ring_timer);
+#endif
+
+ xhci_dbg(xhci, "// Set the interrupt modulation register\n");
+ temp = xhci_readl(xhci, &xhci->ir_set->irq_control);
+ temp &= 0xffff;
+ temp |= (u32) 160;
+ xhci_writel(xhci, temp, &xhci->ir_set->irq_control);
+
+ /* Set the HCD state before we enable the irqs */
+ hcd->state = HC_STATE_RUNNING;
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+ temp |= (CMD_EIE);
+ xhci_dbg(xhci, "// Enable interrupts, cmd = 0x%x.\n",
+ temp);
+ xhci_writel(xhci, temp, &xhci->op_regs->command);
+
+ temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ xhci_dbg(xhci, "// Enabling event ring interrupter %p by writing 0x%x to irq_pending\n",
+ xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp));
+ xhci_writel(xhci, ER_IRQ_ENABLE(temp),
+ &xhci->ir_set->irq_pending);
+ xhci_print_ir_set(xhci, xhci->ir_set, 0);
+
+ if (NUM_TEST_NOOPS > 0)
+ doorbell = xhci_setup_one_noop(xhci);
+
+ xhci_dbg(xhci, "Command ring memory map follows:\n");
+ xhci_debug_ring(xhci, xhci->cmd_ring);
+ xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
+ xhci_dbg_cmd_ptrs(xhci);
+
+ xhci_dbg(xhci, "ERST memory map follows:\n");
+ xhci_dbg_erst(xhci, &xhci->erst);
+ xhci_dbg(xhci, "Event ring:\n");
+ xhci_debug_ring(xhci, xhci->event_ring);
+ xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
+ temp = xhci_readl(xhci, &xhci->ir_set->erst_dequeue[0]);
+ temp &= ERST_PTR_MASK;
+ xhci_dbg(xhci, "ERST deq = 0x%x\n", temp);
+ temp = xhci_readl(xhci, &xhci->ir_set->erst_dequeue[1]);
+ xhci_dbg(xhci, "ERST deq upper = 0x%x\n", temp);
+
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+ temp |= (CMD_RUN);
+ xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n",
+ temp);
+ xhci_writel(xhci, temp, &xhci->op_regs->command);
+ /* Flush PCI posted writes */
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+ xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp);
+ if (doorbell)
+ (*doorbell)(xhci);
+
+ xhci_dbg(xhci, "Finished xhci_run\n");
+ return 0;
+}
+
+/*
+ * Stop xHCI driver.
+ *
+ * This function is called by the USB core when the HC driver is removed.
+ * Its opposite is xhci_run().
+ *
+ * Disable device contexts, disable IRQs, and quiesce the HC.
+ * Reset the HC, finish any completed transactions, and cleanup memory.
+ */
+void xhci_stop(struct usb_hcd *hcd)
+{
+ u32 temp;
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+ spin_lock_irq(&xhci->lock);
+ if (HC_IS_RUNNING(hcd->state))
+ xhci_quiesce(xhci);
+ xhci_halt(xhci);
+ xhci_reset(xhci);
+ spin_unlock_irq(&xhci->lock);
+
+#if 0 /* No MSI yet */
+ xhci_cleanup_msix(xhci);
+#endif
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+ /* Tell the event ring poll function not to reschedule */
+ xhci->zombie = 1;
+ del_timer_sync(&xhci->event_ring_timer);
+#endif
+
+ xhci_dbg(xhci, "// Disabling event ring interrupts\n");
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
+ temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ xhci_writel(xhci, ER_IRQ_DISABLE(temp),
+ &xhci->ir_set->irq_pending);
+ xhci_print_ir_set(xhci, xhci->ir_set, 0);
+
+ xhci_dbg(xhci, "cleaning up memory\n");
+ xhci_mem_cleanup(xhci);
+ xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
+ xhci_readl(xhci, &xhci->op_regs->status));
+}
+
+/*
+ * Shutdown HC (not bus-specific)
+ *
+ * This is called when the machine is rebooting or halting. We assume that the
+ * machine will be powered off, and the HC's internal state will be reset.
+ * Don't bother to free memory.
+ */
+void xhci_shutdown(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+ spin_lock_irq(&xhci->lock);
+ xhci_halt(xhci);
+ spin_unlock_irq(&xhci->lock);
+
+#if 0
+ xhci_cleanup_msix(xhci);
+#endif
+
+ xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",
+ xhci_readl(xhci, &xhci->op_regs->status));
+}
+
+/*-------------------------------------------------------------------------*/
+
+/**
+ * xhci_get_endpoint_index - Used for passing endpoint bitmasks between the core and
+ * HCDs. Find the index for an endpoint given its descriptor. Use the return
+ * value to right shift 1 for the bitmask.
+ *
+ * Index = (epnum * 2) + direction - 1,
+ * where direction = 0 for OUT, 1 for IN.
+ * For control endpoints, the IN index is used (OUT index is unused), so
+ * index = (epnum * 2) + direction - 1 = (epnum * 2) + 1 - 1 = (epnum * 2)
+ */
+unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc)
+{
+ unsigned int index;
+ if (usb_endpoint_xfer_control(desc))
+ index = (unsigned int) (usb_endpoint_num(desc)*2);
+ else
+ index = (unsigned int) (usb_endpoint_num(desc)*2) +
+ (usb_endpoint_dir_in(desc) ? 1 : 0) - 1;
+ return index;
+}
+
+/* Find the flag for this endpoint (for use in the control context). Use the
+ * endpoint index to create a bitmask. The slot context is bit 0, endpoint 0 is
+ * bit 1, etc.
+ */
+unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc)
+{
+ return 1 << (xhci_get_endpoint_index(desc) + 1);
+}
+
+/* Compute the last valid endpoint context index. Basically, this is the
+ * endpoint index plus one. For slot contexts with more than valid endpoint,
+ * we find the most significant bit set in the added contexts flags.
+ * e.g. ep 1 IN (with epnum 0x81) => added_ctxs = 0b1000
+ * fls(0b1000) = 4, but the endpoint context index is 3, so subtract one.
+ */
+static inline unsigned int xhci_last_valid_endpoint(u32 added_ctxs)
+{
+ return fls(added_ctxs) - 1;
+}
+
+/* Returns 1 if the arguments are OK;
+ * returns 0 this is a root hub; returns -EINVAL for NULL pointers.
+ */
+int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
+ struct usb_host_endpoint *ep, int check_ep, const char *func) {
+ if (!hcd || (check_ep && !ep) || !udev) {
+ printk(KERN_DEBUG "xHCI %s called with invalid args\n",
+ func);
+ return -EINVAL;
+ }
+ if (!udev->parent) {
+ printk(KERN_DEBUG "xHCI %s called for root hub\n",
+ func);
+ return 0;
+ }
+ if (!udev->slot_id) {
+ printk(KERN_DEBUG "xHCI %s called with unaddressed device\n",
+ func);
+ return -EINVAL;
+ }
+ return 1;
+}
+
+/*
+ * non-error returns are a promise to giveback() the urb later
+ * we drop ownership so next owner (or urb unlink) can get it
+ */
+int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ unsigned long flags;
+ int ret = 0;
+ unsigned int slot_id, ep_index;
+
+ if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0)
+ return -EINVAL;
+
+ slot_id = urb->dev->slot_id;
+ ep_index = xhci_get_endpoint_index(&urb->ep->desc);
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!xhci->devs || !xhci->devs[slot_id]) {
+ if (!in_interrupt())
+ dev_warn(&urb->dev->dev, "WARN: urb submitted for dev with no Slot ID\n");
+ ret = -EINVAL;
+ goto exit;
+ }
+ if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
+ if (!in_interrupt())
+ xhci_dbg(xhci, "urb submitted during PCI suspend\n");
+ ret = -ESHUTDOWN;
+ goto exit;
+ }
+ if (usb_endpoint_xfer_control(&urb->ep->desc))
+ ret = xhci_queue_ctrl_tx(xhci, mem_flags, urb,
+ slot_id, ep_index);
+ else if (usb_endpoint_xfer_bulk(&urb->ep->desc))
+ ret = xhci_queue_bulk_tx(xhci, mem_flags, urb,
+ slot_id, ep_index);
+ else
+ ret = -EINVAL;
+exit:
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return ret;
+}
+
+/*
+ * Remove the URB's TD from the endpoint ring. This may cause the HC to stop
+ * USB transfers, potentially stopping in the middle of a TRB buffer. The HC
+ * should pick up where it left off in the TD, unless a Set Transfer Ring
+ * Dequeue Pointer is issued.
+ *
+ * The TRBs that make up the buffers for the canceled URB will be "removed" from
+ * the ring. Since the ring is a contiguous structure, they can't be physically
+ * removed. Instead, there are two options:
+ *
+ * 1) If the HC is in the middle of processing the URB to be canceled, we
+ * simply move the ring's dequeue pointer past those TRBs using the Set
+ * Transfer Ring Dequeue Pointer command. This will be the common case,
+ * when drivers timeout on the last submitted URB and attempt to cancel.
+ *
+ * 2) If the HC is in the middle of a different TD, we turn the TRBs into a
+ * series of 1-TRB transfer no-op TDs. (No-ops shouldn't be chained.) The
+ * HC will need to invalidate the any TRBs it has cached after the stop
+ * endpoint command, as noted in the xHCI 0.95 errata.
+ *
+ * 3) The TD may have completed by the time the Stop Endpoint Command
+ * completes, so software needs to handle that case too.
+ *
+ * This function should protect against the TD enqueueing code ringing the
+ * doorbell while this code is waiting for a Stop Endpoint command to complete.
+ * It also needs to account for multiple cancellations on happening at the same
+ * time for the same endpoint.
+ *
+ * Note that this function can be called in any context, or so says
+ * usb_hcd_unlink_urb()
+ */
+int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
+{
+ unsigned long flags;
+ int ret;
+ struct xhci_hcd *xhci;
+ struct xhci_td *td;
+ unsigned int ep_index;
+ struct xhci_ring *ep_ring;
+
+ xhci = hcd_to_xhci(hcd);
+ spin_lock_irqsave(&xhci->lock, flags);
+ /* Make sure the URB hasn't completed or been unlinked already */
+ ret = usb_hcd_check_unlink_urb(hcd, urb, status);
+ if (ret || !urb->hcpriv)
+ goto done;
+
+ xhci_dbg(xhci, "Cancel URB %p\n", urb);
+ ep_index = xhci_get_endpoint_index(&urb->ep->desc);
+ ep_ring = xhci->devs[urb->dev->slot_id]->ep_rings[ep_index];
+ td = (struct xhci_td *) urb->hcpriv;
+
+ ep_ring->cancels_pending++;
+ list_add_tail(&td->cancelled_td_list, &ep_ring->cancelled_td_list);
+ /* Queue a stop endpoint command, but only if this is
+ * the first cancellation to be handled.
+ */
+ if (ep_ring->cancels_pending == 1) {
+ xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index);
+ xhci_ring_cmd_db(xhci);
+ }
+done:
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return ret;
+}
+
+/* Drop an endpoint from a new bandwidth configuration for this device.
+ * Only one call to this function is allowed per endpoint before
+ * check_bandwidth() or reset_bandwidth() must be called.
+ * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
+ * add the endpoint to the schedule with possibly new parameters denoted by a
+ * different endpoint descriptor in usb_host_endpoint.
+ * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
+ * not allowed.
+ */
+int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
+ struct usb_host_endpoint *ep)
+{
+ unsigned long flags;
+ struct xhci_hcd *xhci;
+ struct xhci_device_control *in_ctx;
+ unsigned int last_ctx;
+ unsigned int ep_index;
+ struct xhci_ep_ctx *ep_ctx;
+ u32 drop_flag;
+ u32 new_add_flags, new_drop_flags, new_slot_info;
+ int ret;
+
+ ret = xhci_check_args(hcd, udev, ep, 1, __func__);
+ if (ret <= 0)
+ return ret;
+ xhci = hcd_to_xhci(hcd);
+ xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
+
+ drop_flag = xhci_get_endpoint_flag(&ep->desc);
+ if (drop_flag == SLOT_FLAG || drop_flag == EP0_FLAG) {
+ xhci_dbg(xhci, "xHCI %s - can't drop slot or ep 0 %#x\n",
+ __func__, drop_flag);
+ return 0;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!xhci->devs || !xhci->devs[udev->slot_id]) {
+ xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+ __func__);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return -EINVAL;
+ }
+
+ in_ctx = xhci->devs[udev->slot_id]->in_ctx;
+ ep_index = xhci_get_endpoint_index(&ep->desc);
+ ep_ctx = &xhci->devs[udev->slot_id]->out_ctx->ep[ep_index];
+ /* If the HC already knows the endpoint is disabled,
+ * or the HCD has noted it is disabled, ignore this request
+ */
+ if ((ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_DISABLED ||
+ in_ctx->drop_flags & xhci_get_endpoint_flag(&ep->desc)) {
+ xhci_warn(xhci, "xHCI %s called with disabled ep %p\n",
+ __func__, ep);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 0;
+ }
+
+ in_ctx->drop_flags |= drop_flag;
+ new_drop_flags = in_ctx->drop_flags;
+
+ in_ctx->add_flags = ~drop_flag;
+ new_add_flags = in_ctx->add_flags;
+
+ last_ctx = xhci_last_valid_endpoint(in_ctx->add_flags);
+ /* Update the last valid endpoint context, if we deleted the last one */
+ if ((in_ctx->slot.dev_info & LAST_CTX_MASK) > LAST_CTX(last_ctx)) {
+ in_ctx->slot.dev_info &= ~LAST_CTX_MASK;
+ in_ctx->slot.dev_info |= LAST_CTX(last_ctx);
+ }
+ new_slot_info = in_ctx->slot.dev_info;
+
+ xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
+
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ xhci_dbg(xhci, "drop ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
+ (unsigned int) ep->desc.bEndpointAddress,
+ udev->slot_id,
+ (unsigned int) new_drop_flags,
+ (unsigned int) new_add_flags,
+ (unsigned int) new_slot_info);
+ return 0;
+}
+
+/* Add an endpoint to a new possible bandwidth configuration for this device.
+ * Only one call to this function is allowed per endpoint before
+ * check_bandwidth() or reset_bandwidth() must be called.
+ * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
+ * add the endpoint to the schedule with possibly new parameters denoted by a
+ * different endpoint descriptor in usb_host_endpoint.
+ * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
+ * not allowed.
+ */
+int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
+ struct usb_host_endpoint *ep)
+{
+ unsigned long flags;
+ struct xhci_hcd *xhci;
+ struct xhci_device_control *in_ctx;
+ unsigned int ep_index;
+ struct xhci_ep_ctx *ep_ctx;
+ u32 added_ctxs;
+ unsigned int last_ctx;
+ u32 new_add_flags, new_drop_flags, new_slot_info;
+ int ret = 0;
+
+ ret = xhci_check_args(hcd, udev, ep, 1, __func__);
+ if (ret <= 0)
+ return ret;
+ xhci = hcd_to_xhci(hcd);
+
+ added_ctxs = xhci_get_endpoint_flag(&ep->desc);
+ last_ctx = xhci_last_valid_endpoint(added_ctxs);
+ if (added_ctxs == SLOT_FLAG || added_ctxs == EP0_FLAG) {
+ /* FIXME when we have to issue an evaluate endpoint command to
+ * deal with ep0 max packet size changing once we get the
+ * descriptors
+ */
+ xhci_dbg(xhci, "xHCI %s - can't add slot or ep 0 %#x\n",
+ __func__, added_ctxs);
+ return 0;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!xhci->devs || !xhci->devs[udev->slot_id]) {
+ xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+ __func__);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return -EINVAL;
+ }
+
+ in_ctx = xhci->devs[udev->slot_id]->in_ctx;
+ ep_index = xhci_get_endpoint_index(&ep->desc);
+ ep_ctx = &xhci->devs[udev->slot_id]->out_ctx->ep[ep_index];
+ /* If the HCD has already noted the endpoint is enabled,
+ * ignore this request.
+ */
+ if (in_ctx->add_flags & xhci_get_endpoint_flag(&ep->desc)) {
+ xhci_warn(xhci, "xHCI %s called with enabled ep %p\n",
+ __func__, ep);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 0;
+ }
+
+ if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id], udev, ep) < 0) {
+ dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
+ __func__, ep->desc.bEndpointAddress);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return -ENOMEM;
+ }
+
+ in_ctx->add_flags |= added_ctxs;
+ new_add_flags = in_ctx->add_flags;
+
+ /* If xhci_endpoint_disable() was called for this endpoint, but the
+ * xHC hasn't been notified yet through the check_bandwidth() call,
+ * this re-adds a new state for the endpoint from the new endpoint
+ * descriptors. We must drop and re-add this endpoint, so we leave the
+ * drop flags alone.
+ */
+ new_drop_flags = in_ctx->drop_flags;
+
+ /* Update the last valid endpoint context, if we just added one past */
+ if ((in_ctx->slot.dev_info & LAST_CTX_MASK) < LAST_CTX(last_ctx)) {
+ in_ctx->slot.dev_info &= ~LAST_CTX_MASK;
+ in_ctx->slot.dev_info |= LAST_CTX(last_ctx);
+ }
+ new_slot_info = in_ctx->slot.dev_info;
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
+ (unsigned int) ep->desc.bEndpointAddress,
+ udev->slot_id,
+ (unsigned int) new_drop_flags,
+ (unsigned int) new_add_flags,
+ (unsigned int) new_slot_info);
+ return 0;
+}
+
+static void xhci_zero_in_ctx(struct xhci_virt_device *virt_dev)
+{
+ struct xhci_ep_ctx *ep_ctx;
+ int i;
+
+ /* When a device's add flag and drop flag are zero, any subsequent
+ * configure endpoint command will leave that endpoint's state
+ * untouched. Make sure we don't leave any old state in the input
+ * endpoint contexts.
+ */
+ virt_dev->in_ctx->drop_flags = 0;
+ virt_dev->in_ctx->add_flags = 0;
+ virt_dev->in_ctx->slot.dev_info &= ~LAST_CTX_MASK;
+ /* Endpoint 0 is always valid */
+ virt_dev->in_ctx->slot.dev_info |= LAST_CTX(1);
+ for (i = 1; i < 31; ++i) {
+ ep_ctx = &virt_dev->in_ctx->ep[i];
+ ep_ctx->ep_info = 0;
+ ep_ctx->ep_info2 = 0;
+ ep_ctx->deq[0] = 0;
+ ep_ctx->deq[1] = 0;
+ ep_ctx->tx_info = 0;
+ }
+}
+
+int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+{
+ int i;
+ int ret = 0;
+ int timeleft;
+ unsigned long flags;
+ struct xhci_hcd *xhci;
+ struct xhci_virt_device *virt_dev;
+
+ ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+ if (ret <= 0)
+ return ret;
+ xhci = hcd_to_xhci(hcd);
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!udev->slot_id || !xhci->devs || !xhci->devs[udev->slot_id]) {
+ xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+ __func__);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return -EINVAL;
+ }
+ xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
+ virt_dev = xhci->devs[udev->slot_id];
+
+ /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */
+ virt_dev->in_ctx->add_flags |= SLOT_FLAG;
+ virt_dev->in_ctx->add_flags &= ~EP0_FLAG;
+ virt_dev->in_ctx->drop_flags &= ~SLOT_FLAG;
+ virt_dev->in_ctx->drop_flags &= ~EP0_FLAG;
+ xhci_dbg(xhci, "New Input Control Context:\n");
+ xhci_dbg_ctx(xhci, virt_dev->in_ctx, virt_dev->in_ctx_dma,
+ LAST_CTX_TO_EP_NUM(virt_dev->in_ctx->slot.dev_info));
+
+ ret = xhci_queue_configure_endpoint(xhci, virt_dev->in_ctx_dma,
+ udev->slot_id);
+ if (ret < 0) {
+ xhci_dbg(xhci, "FIXME allocate a new ring segment\n");
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return -ENOMEM;
+ }
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ /* Wait for the configure endpoint command to complete */
+ timeleft = wait_for_completion_interruptible_timeout(
+ &virt_dev->cmd_completion,
+ USB_CTRL_SET_TIMEOUT);
+ if (timeleft <= 0) {
+ xhci_warn(xhci, "%s while waiting for configure endpoint command\n",
+ timeleft == 0 ? "Timeout" : "Signal");
+ /* FIXME cancel the configure endpoint command */
+ return -ETIME;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ switch (virt_dev->cmd_status) {
+ case COMP_ENOMEM:
+ dev_warn(&udev->dev, "Not enough host controller resources "
+ "for new device state.\n");
+ ret = -ENOMEM;
+ /* FIXME: can we allocate more resources for the HC? */
+ break;
+ case COMP_BW_ERR:
+ dev_warn(&udev->dev, "Not enough bandwidth "
+ "for new device state.\n");
+ ret = -ENOSPC;
+ /* FIXME: can we go back to the old state? */
+ break;
+ case COMP_TRB_ERR:
+ /* the HCD set up something wrong */
+ dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, add flag = 1, "
+ "and endpoint is not disabled.\n");
+ ret = -EINVAL;
+ break;
+ case COMP_SUCCESS:
+ dev_dbg(&udev->dev, "Successful Endpoint Configure command\n");
+ break;
+ default:
+ xhci_err(xhci, "ERROR: unexpected command completion "
+ "code 0x%x.\n", virt_dev->cmd_status);
+ ret = -EINVAL;
+ break;
+ }
+ if (ret) {
+ /* Callee should call reset_bandwidth() */
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return ret;
+ }
+
+ xhci_dbg(xhci, "Output context after successful config ep cmd:\n");
+ xhci_dbg_ctx(xhci, virt_dev->out_ctx, virt_dev->out_ctx_dma,
+ LAST_CTX_TO_EP_NUM(virt_dev->in_ctx->slot.dev_info));
+
+ xhci_zero_in_ctx(virt_dev);
+ /* Free any old rings */
+ for (i = 1; i < 31; ++i) {
+ if (virt_dev->new_ep_rings[i]) {
+ xhci_ring_free(xhci, virt_dev->ep_rings[i]);
+ virt_dev->ep_rings[i] = virt_dev->new_ep_rings[i];
+ virt_dev->new_ep_rings[i] = NULL;
+ }
+ }
+
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ return ret;
+}
+
+void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+{
+ unsigned long flags;
+ struct xhci_hcd *xhci;
+ struct xhci_virt_device *virt_dev;
+ int i, ret;
+
+ ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+ if (ret <= 0)
+ return;
+ xhci = hcd_to_xhci(hcd);
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!xhci->devs || !xhci->devs[udev->slot_id]) {
+ xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+ __func__);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return;
+ }
+ xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
+ virt_dev = xhci->devs[udev->slot_id];
+ /* Free any rings allocated for added endpoints */
+ for (i = 0; i < 31; ++i) {
+ if (virt_dev->new_ep_rings[i]) {
+ xhci_ring_free(xhci, virt_dev->new_ep_rings[i]);
+ virt_dev->new_ep_rings[i] = NULL;
+ }
+ }
+ xhci_zero_in_ctx(virt_dev);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+}
+
+/*
+ * At this point, the struct usb_device is about to go away, the device has
+ * disconnected, and all traffic has been stopped and the endpoints have been
+ * disabled. Free any HC data structures associated with that device.
+ */
+void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ unsigned long flags;
+
+ if (udev->slot_id == 0)
+ return;
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id)) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+ return;
+ }
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ /*
+ * Event command completion handler will free any data structures
+ * associated with the slot
+ */
+}
+
+/*
+ * Returns 0 if the xHC ran out of device slots, the Enable Slot command
+ * timed out, or allocating memory failed. Returns 1 on success.
+ */
+int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ unsigned long flags;
+ int timeleft;
+ int ret;
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0);
+ if (ret) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+ return 0;
+ }
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ /* XXX: how much time for xHC slot assignment? */
+ timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev,
+ USB_CTRL_SET_TIMEOUT);
+ if (timeleft <= 0) {
+ xhci_warn(xhci, "%s while waiting for a slot\n",
+ timeleft == 0 ? "Timeout" : "Signal");
+ /* FIXME cancel the enable slot request */
+ return 0;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!xhci->slot_id) {
+ xhci_err(xhci, "Error while assigning device slot ID\n");
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 0;
+ }
+ if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) {
+ /* Disable slot, if we can do it without mem alloc */
+ xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
+ if (!xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id))
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 0;
+ }
+ udev->slot_id = xhci->slot_id;
+ /* Is this a LS or FS device under a HS hub? */
+ /* Hub or peripherial? */
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 1;
+}
+
+/*
+ * Issue an Address Device command (which will issue a SetAddress request to
+ * the device).
+ * We should be protected by the usb_address0_mutex in khubd's hub_port_init, so
+ * we should only issue and wait on one address command at the same time.
+ *
+ * We add one to the device address issued by the hardware because the USB core
+ * uses address 1 for the root hubs (even though they're not really devices).
+ */
+int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
+{
+ unsigned long flags;
+ int timeleft;
+ struct xhci_virt_device *virt_dev;
+ int ret = 0;
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ u32 temp;
+
+ if (!udev->slot_id) {
+ xhci_dbg(xhci, "Bad Slot ID %d\n", udev->slot_id);
+ return -EINVAL;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ virt_dev = xhci->devs[udev->slot_id];
+
+ /* If this is a Set Address to an unconfigured device, setup ep 0 */
+ if (!udev->config)
+ xhci_setup_addressable_virt_dev(xhci, udev);
+ /* Otherwise, assume the core has the device configured how it wants */
+
+ ret = xhci_queue_address_device(xhci, virt_dev->in_ctx_dma,
+ udev->slot_id);
+ if (ret) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+ return ret;
+ }
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ /* ctrl tx can take up to 5 sec; XXX: need more time for xHC? */
+ timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev,
+ USB_CTRL_SET_TIMEOUT);
+ /* FIXME: From section 4.3.4: "Software shall be responsible for timing
+ * the SetAddress() "recovery interval" required by USB and aborting the
+ * command on a timeout.
+ */
+ if (timeleft <= 0) {
+ xhci_warn(xhci, "%s while waiting for a slot\n",
+ timeleft == 0 ? "Timeout" : "Signal");
+ /* FIXME cancel the address device command */
+ return -ETIME;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ switch (virt_dev->cmd_status) {
+ case COMP_CTX_STATE:
+ case COMP_EBADSLT:
+ xhci_err(xhci, "Setup ERROR: address device command for slot %d.\n",
+ udev->slot_id);
+ ret = -EINVAL;
+ break;
+ case COMP_TX_ERR:
+ dev_warn(&udev->dev, "Device not responding to set address.\n");
+ ret = -EPROTO;
+ break;
+ case COMP_SUCCESS:
+ xhci_dbg(xhci, "Successful Address Device command\n");
+ break;
+ default:
+ xhci_err(xhci, "ERROR: unexpected command completion "
+ "code 0x%x.\n", virt_dev->cmd_status);
+ ret = -EINVAL;
+ break;
+ }
+ if (ret) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return ret;
+ }
+ temp = xhci_readl(xhci, &xhci->op_regs->dcbaa_ptr[0]);
+ xhci_dbg(xhci, "Op regs DCBAA ptr[0] = %#08x\n", temp);
+ temp = xhci_readl(xhci, &xhci->op_regs->dcbaa_ptr[1]);
+ xhci_dbg(xhci, "Op regs DCBAA ptr[1] = %#08x\n", temp);
+ xhci_dbg(xhci, "Slot ID %d dcbaa entry[0] @%p = %#08x\n",
+ udev->slot_id,
+ &xhci->dcbaa->dev_context_ptrs[2*udev->slot_id],
+ xhci->dcbaa->dev_context_ptrs[2*udev->slot_id]);
+ xhci_dbg(xhci, "Slot ID %d dcbaa entry[1] @%p = %#08x\n",
+ udev->slot_id,
+ &xhci->dcbaa->dev_context_ptrs[2*udev->slot_id+1],
+ xhci->dcbaa->dev_context_ptrs[2*udev->slot_id+1]);
+ xhci_dbg(xhci, "Output Context DMA address = %#08llx\n",
+ (unsigned long long)virt_dev->out_ctx_dma);
+ xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
+ xhci_dbg_ctx(xhci, virt_dev->in_ctx, virt_dev->in_ctx_dma, 2);
+ xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
+ xhci_dbg_ctx(xhci, virt_dev->out_ctx, virt_dev->out_ctx_dma, 2);
+ /*
+ * USB core uses address 1 for the roothubs, so we add one to the
+ * address given back to us by the HC.
+ */
+ udev->devnum = (virt_dev->out_ctx->slot.dev_state & DEV_ADDR_MASK) + 1;
+ /* Zero the input context control for later use */
+ virt_dev->in_ctx->add_flags = 0;
+ virt_dev->in_ctx->drop_flags = 0;
+ /* Mirror flags in the output context for future ep enable/disable */
+ virt_dev->out_ctx->add_flags = SLOT_FLAG | EP0_FLAG;
+ virt_dev->out_ctx->drop_flags = 0;
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ xhci_dbg(xhci, "Device address = %d\n", udev->devnum);
+ /* XXX Meh, not sure if anyone else but choose_address uses this. */
+ set_bit(udev->devnum, udev->bus->devmap.devicemap);
+
+ return 0;
+}
+
+int xhci_get_frame(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ /* EHCI mods by the periodic size. Why? */
+ return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3;
+}
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_LICENSE("GPL");
+
+static int __init xhci_hcd_init(void)
+{
+#ifdef CONFIG_PCI
+ int retval = 0;
+
+ retval = xhci_register_pci();
+
+ if (retval < 0) {
+ printk(KERN_DEBUG "Problem registering PCI driver.");
+ return retval;
+ }
+#endif
+ return 0;
+}
+module_init(xhci_hcd_init);
+
+static void __exit xhci_hcd_cleanup(void)
+{
+#ifdef CONFIG_PCI
+ xhci_unregister_pci();
+#endif
+}
+module_exit(xhci_hcd_cleanup);
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
new file mode 100644
index 000000000000..eac5b53aa9e7
--- /dev/null
+++ b/drivers/usb/host/xhci-hub.c
@@ -0,0 +1,308 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <asm/unaligned.h>
+
+#include "xhci.h"
+
+static void xhci_hub_descriptor(struct xhci_hcd *xhci,
+ struct usb_hub_descriptor *desc)
+{
+ int ports;
+ u16 temp;
+
+ ports = HCS_MAX_PORTS(xhci->hcs_params1);
+
+ /* USB 3.0 hubs have a different descriptor, but we fake this for now */
+ desc->bDescriptorType = 0x29;
+ desc->bPwrOn2PwrGood = 10; /* xhci section 5.4.9 says 20ms max */
+ desc->bHubContrCurrent = 0;
+
+ desc->bNbrPorts = ports;
+ temp = 1 + (ports / 8);
+ desc->bDescLength = 7 + 2 * temp;
+
+ /* Why does core/hcd.h define bitmap? It's just confusing. */
+ memset(&desc->DeviceRemovable[0], 0, temp);
+ memset(&desc->DeviceRemovable[temp], 0xff, temp);
+
+ /* Ugh, these should be #defines, FIXME */
+ /* Using table 11-13 in USB 2.0 spec. */
+ temp = 0;
+ /* Bits 1:0 - support port power switching, or power always on */
+ if (HCC_PPC(xhci->hcc_params))
+ temp |= 0x0001;
+ else
+ temp |= 0x0002;
+ /* Bit 2 - root hubs are not part of a compound device */
+ /* Bits 4:3 - individual port over current protection */
+ temp |= 0x0008;
+ /* Bits 6:5 - no TTs in root ports */
+ /* Bit 7 - no port indicators */
+ desc->wHubCharacteristics = (__force __u16) cpu_to_le16(temp);
+}
+
+static unsigned int xhci_port_speed(unsigned int port_status)
+{
+ if (DEV_LOWSPEED(port_status))
+ return 1 << USB_PORT_FEAT_LOWSPEED;
+ if (DEV_HIGHSPEED(port_status))
+ return 1 << USB_PORT_FEAT_HIGHSPEED;
+ if (DEV_SUPERSPEED(port_status))
+ return 1 << USB_PORT_FEAT_SUPERSPEED;
+ /*
+ * FIXME: Yes, we should check for full speed, but the core uses that as
+ * a default in portspeed() in usb/core/hub.c (which is the only place
+ * USB_PORT_FEAT_*SPEED is used).
+ */
+ return 0;
+}
+
+/*
+ * These bits are Read Only (RO) and should be saved and written to the
+ * registers: 0, 3, 10:13, 30
+ * connect status, over-current status, port speed, and device removable.
+ * connect status and port speed are also sticky - meaning they're in
+ * the AUX well and they aren't changed by a hot, warm, or cold reset.
+ */
+#define XHCI_PORT_RO ((1<<0) | (1<<3) | (0xf<<10) | (1<<30))
+/*
+ * These bits are RW; writing a 0 clears the bit, writing a 1 sets the bit:
+ * bits 5:8, 9, 14:15, 25:27
+ * link state, port power, port indicator state, "wake on" enable state
+ */
+#define XHCI_PORT_RWS ((0xf<<5) | (1<<9) | (0x3<<14) | (0x7<<25))
+/*
+ * These bits are RW; writing a 1 sets the bit, writing a 0 has no effect:
+ * bit 4 (port reset)
+ */
+#define XHCI_PORT_RW1S ((1<<4))
+/*
+ * These bits are RW; writing a 1 clears the bit, writing a 0 has no effect:
+ * bits 1, 17, 18, 19, 20, 21, 22, 23
+ * port enable/disable, and
+ * change bits: connect, PED, warm port reset changed (reserved zero for USB 2.0 ports),
+ * over-current, reset, link state, and L1 change
+ */
+#define XHCI_PORT_RW1CS ((1<<1) | (0x7f<<17))
+/*
+ * Bit 16 is RW, and writing a '1' to it causes the link state control to be
+ * latched in
+ */
+#define XHCI_PORT_RW ((1<<16))
+/*
+ * These bits are Reserved Zero (RsvdZ) and zero should be written to them:
+ * bits 2, 24, 28:31
+ */
+#define XHCI_PORT_RZ ((1<<2) | (1<<24) | (0xf<<28))
+
+/*
+ * Given a port state, this function returns a value that would result in the
+ * port being in the same state, if the value was written to the port status
+ * control register.
+ * Save Read Only (RO) bits and save read/write bits where
+ * writing a 0 clears the bit and writing a 1 sets the bit (RWS).
+ * For all other types (RW1S, RW1CS, RW, and RZ), writing a '0' has no effect.
+ */
+static u32 xhci_port_state_to_neutral(u32 state)
+{
+ /* Save read-only status and port state */
+ return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS);
+}
+
+int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int ports;
+ unsigned long flags;
+ u32 temp, status;
+ int retval = 0;
+ u32 __iomem *addr;
+ char *port_change_bit;
+
+ ports = HCS_MAX_PORTS(xhci->hcs_params1);
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ switch (typeReq) {
+ case GetHubStatus:
+ /* No power source, over-current reported per port */
+ memset(buf, 0, 4);
+ break;
+ case GetHubDescriptor:
+ xhci_hub_descriptor(xhci, (struct usb_hub_descriptor *) buf);
+ break;
+ case GetPortStatus:
+ if (!wIndex || wIndex > ports)
+ goto error;
+ wIndex--;
+ status = 0;
+ addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS*(wIndex & 0xff);
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, "get port status, actual port %d status = 0x%x\n", wIndex, temp);
+
+ /* wPortChange bits */
+ if (temp & PORT_CSC)
+ status |= 1 << USB_PORT_FEAT_C_CONNECTION;
+ if (temp & PORT_PEC)
+ status |= 1 << USB_PORT_FEAT_C_ENABLE;
+ if ((temp & PORT_OCC))
+ status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
+ /*
+ * FIXME ignoring suspend, reset, and USB 2.1/3.0 specific
+ * changes
+ */
+ if (temp & PORT_CONNECT) {
+ status |= 1 << USB_PORT_FEAT_CONNECTION;
+ status |= xhci_port_speed(temp);
+ }
+ if (temp & PORT_PE)
+ status |= 1 << USB_PORT_FEAT_ENABLE;
+ if (temp & PORT_OC)
+ status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
+ if (temp & PORT_RESET)
+ status |= 1 << USB_PORT_FEAT_RESET;
+ if (temp & PORT_POWER)
+ status |= 1 << USB_PORT_FEAT_POWER;
+ xhci_dbg(xhci, "Get port status returned 0x%x\n", status);
+ put_unaligned(cpu_to_le32(status), (__le32 *) buf);
+ break;
+ case SetPortFeature:
+ wIndex &= 0xff;
+ if (!wIndex || wIndex > ports)
+ goto error;
+ wIndex--;
+ addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS*(wIndex & 0xff);
+ temp = xhci_readl(xhci, addr);
+ temp = xhci_port_state_to_neutral(temp);
+ switch (wValue) {
+ case USB_PORT_FEAT_POWER:
+ /*
+ * Turn on ports, even if there isn't per-port switching.
+ * HC will report connect events even before this is set.
+ * However, khubd will ignore the roothub events until
+ * the roothub is registered.
+ */
+ xhci_writel(xhci, temp | PORT_POWER, addr);
+
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp);
+ break;
+ case USB_PORT_FEAT_RESET:
+ temp = (temp | PORT_RESET);
+ xhci_writel(xhci, temp, addr);
+
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp);
+ break;
+ default:
+ goto error;
+ }
+ temp = xhci_readl(xhci, addr); /* unblock any posted writes */
+ break;
+ case ClearPortFeature:
+ if (!wIndex || wIndex > ports)
+ goto error;
+ wIndex--;
+ addr = &xhci->op_regs->port_status_base +
+ NUM_PORT_REGS*(wIndex & 0xff);
+ temp = xhci_readl(xhci, addr);
+ temp = xhci_port_state_to_neutral(temp);
+ switch (wValue) {
+ case USB_PORT_FEAT_C_RESET:
+ status = PORT_RC;
+ port_change_bit = "reset";
+ break;
+ case USB_PORT_FEAT_C_CONNECTION:
+ status = PORT_CSC;
+ port_change_bit = "connect";
+ break;
+ case USB_PORT_FEAT_C_OVER_CURRENT:
+ status = PORT_OCC;
+ port_change_bit = "over-current";
+ break;
+ default:
+ goto error;
+ }
+ /* Change bits are all write 1 to clear */
+ xhci_writel(xhci, temp | status, addr);
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n",
+ port_change_bit, wIndex, temp);
+ temp = xhci_readl(xhci, addr); /* unblock any posted writes */
+ break;
+ default:
+error:
+ /* "stall" on error */
+ retval = -EPIPE;
+ }
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return retval;
+}
+
+/*
+ * Returns 0 if the status hasn't changed, or the number of bytes in buf.
+ * Ports are 0-indexed from the HCD point of view,
+ * and 1-indexed from the USB core pointer of view.
+ * xHCI instances can have up to 127 ports, so FIXME if you see more than 15.
+ *
+ * Note that the status change bits will be cleared as soon as a port status
+ * change event is generated, so we use the saved status from that event.
+ */
+int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+ unsigned long flags;
+ u32 temp, status;
+ int i, retval;
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int ports;
+ u32 __iomem *addr;
+
+ ports = HCS_MAX_PORTS(xhci->hcs_params1);
+
+ /* Initial status is no changes */
+ buf[0] = 0;
+ status = 0;
+ if (ports > 7) {
+ buf[1] = 0;
+ retval = 2;
+ } else {
+ retval = 1;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ /* For each port, did anything change? If so, set that bit in buf. */
+ for (i = 0; i < ports; i++) {
+ addr = &xhci->op_regs->port_status_base +
+ NUM_PORT_REGS*i;
+ temp = xhci_readl(xhci, addr);
+ if (temp & (PORT_CSC | PORT_PEC | PORT_OCC)) {
+ if (i < 7)
+ buf[0] |= 1 << (i + 1);
+ else
+ buf[1] |= 1 << (i - 7);
+ status = 1;
+ }
+ }
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return status ? retval : 0;
+}
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
new file mode 100644
index 000000000000..37a83878a064
--- /dev/null
+++ b/drivers/usb/host/xhci-mem.c
@@ -0,0 +1,768 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/usb.h>
+#include <linux/pci.h>
+#include <linux/dmapool.h>
+
+#include "xhci.h"
+
+/*
+ * Allocates a generic ring segment from the ring pool, sets the dma address,
+ * initializes the segment to zero, and sets the private next pointer to NULL.
+ *
+ * Section 4.11.1.1:
+ * "All components of all Command and Transfer TRBs shall be initialized to '0'"
+ */
+static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flags)
+{
+ struct xhci_segment *seg;
+ dma_addr_t dma;
+
+ seg = kzalloc(sizeof *seg, flags);
+ if (!seg)
+ return 0;
+ xhci_dbg(xhci, "Allocating priv segment structure at %p\n", seg);
+
+ seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma);
+ if (!seg->trbs) {
+ kfree(seg);
+ return 0;
+ }
+ xhci_dbg(xhci, "// Allocating segment at %p (virtual) 0x%llx (DMA)\n",
+ seg->trbs, (unsigned long long)dma);
+
+ memset(seg->trbs, 0, SEGMENT_SIZE);
+ seg->dma = dma;
+ seg->next = NULL;
+
+ return seg;
+}
+
+static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
+{
+ if (!seg)
+ return;
+ if (seg->trbs) {
+ xhci_dbg(xhci, "Freeing DMA segment at %p (virtual) 0x%llx (DMA)\n",
+ seg->trbs, (unsigned long long)seg->dma);
+ dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma);
+ seg->trbs = NULL;
+ }
+ xhci_dbg(xhci, "Freeing priv segment structure at %p\n", seg);
+ kfree(seg);
+}
+
+/*
+ * Make the prev segment point to the next segment.
+ *
+ * Change the last TRB in the prev segment to be a Link TRB which points to the
+ * DMA address of the next segment. The caller needs to set any Link TRB
+ * related flags, such as End TRB, Toggle Cycle, and no snoop.
+ */
+static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev,
+ struct xhci_segment *next, bool link_trbs)
+{
+ u32 val;
+
+ if (!prev || !next)
+ return;
+ prev->next = next;
+ if (link_trbs) {
+ prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr[0] = next->dma;
+
+ /* Set the last TRB in the segment to have a TRB type ID of Link TRB */
+ val = prev->trbs[TRBS_PER_SEGMENT-1].link.control;
+ val &= ~TRB_TYPE_BITMASK;
+ val |= TRB_TYPE(TRB_LINK);
+ prev->trbs[TRBS_PER_SEGMENT-1].link.control = val;
+ }
+ xhci_dbg(xhci, "Linking segment 0x%llx to segment 0x%llx (DMA)\n",
+ (unsigned long long)prev->dma,
+ (unsigned long long)next->dma);
+}
+
+/* XXX: Do we need the hcd structure in all these functions? */
+void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
+{
+ struct xhci_segment *seg;
+ struct xhci_segment *first_seg;
+
+ if (!ring || !ring->first_seg)
+ return;
+ first_seg = ring->first_seg;
+ seg = first_seg->next;
+ xhci_dbg(xhci, "Freeing ring at %p\n", ring);
+ while (seg != first_seg) {
+ struct xhci_segment *next = seg->next;
+ xhci_segment_free(xhci, seg);
+ seg = next;
+ }
+ xhci_segment_free(xhci, first_seg);
+ ring->first_seg = NULL;
+ kfree(ring);
+}
+
+/**
+ * Create a new ring with zero or more segments.
+ *
+ * Link each segment together into a ring.
+ * Set the end flag and the cycle toggle bit on the last segment.
+ * See section 4.9.1 and figures 15 and 16.
+ */
+static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
+ unsigned int num_segs, bool link_trbs, gfp_t flags)
+{
+ struct xhci_ring *ring;
+ struct xhci_segment *prev;
+
+ ring = kzalloc(sizeof *(ring), flags);
+ xhci_dbg(xhci, "Allocating ring at %p\n", ring);
+ if (!ring)
+ return 0;
+
+ INIT_LIST_HEAD(&ring->td_list);
+ INIT_LIST_HEAD(&ring->cancelled_td_list);
+ if (num_segs == 0)
+ return ring;
+
+ ring->first_seg = xhci_segment_alloc(xhci, flags);
+ if (!ring->first_seg)
+ goto fail;
+ num_segs--;
+
+ prev = ring->first_seg;
+ while (num_segs > 0) {
+ struct xhci_segment *next;
+
+ next = xhci_segment_alloc(xhci, flags);
+ if (!next)
+ goto fail;
+ xhci_link_segments(xhci, prev, next, link_trbs);
+
+ prev = next;
+ num_segs--;
+ }
+ xhci_link_segments(xhci, prev, ring->first_seg, link_trbs);
+
+ if (link_trbs) {
+ /* See section 4.9.2.1 and 6.4.4.1 */
+ prev->trbs[TRBS_PER_SEGMENT-1].link.control |= (LINK_TOGGLE);
+ xhci_dbg(xhci, "Wrote link toggle flag to"
+ " segment %p (virtual), 0x%llx (DMA)\n",
+ prev, (unsigned long long)prev->dma);
+ }
+ /* The ring is empty, so the enqueue pointer == dequeue pointer */
+ ring->enqueue = ring->first_seg->trbs;
+ ring->enq_seg = ring->first_seg;
+ ring->dequeue = ring->enqueue;
+ ring->deq_seg = ring->first_seg;
+ /* The ring is initialized to 0. The producer must write 1 to the cycle
+ * bit to handover ownership of the TRB, so PCS = 1. The consumer must
+ * compare CCS to the cycle bit to check ownership, so CCS = 1.
+ */
+ ring->cycle_state = 1;
+
+ return ring;
+
+fail:
+ xhci_ring_free(xhci, ring);
+ return 0;
+}
+
+/* All the xhci_tds in the ring's TD list should be freed at this point */
+void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
+{
+ struct xhci_virt_device *dev;
+ int i;
+
+ /* Slot ID 0 is reserved */
+ if (slot_id == 0 || !xhci->devs[slot_id])
+ return;
+
+ dev = xhci->devs[slot_id];
+ xhci->dcbaa->dev_context_ptrs[2*slot_id] = 0;
+ xhci->dcbaa->dev_context_ptrs[2*slot_id + 1] = 0;
+ if (!dev)
+ return;
+
+ for (i = 0; i < 31; ++i)
+ if (dev->ep_rings[i])
+ xhci_ring_free(xhci, dev->ep_rings[i]);
+
+ if (dev->in_ctx)
+ dma_pool_free(xhci->device_pool,
+ dev->in_ctx, dev->in_ctx_dma);
+ if (dev->out_ctx)
+ dma_pool_free(xhci->device_pool,
+ dev->out_ctx, dev->out_ctx_dma);
+ kfree(xhci->devs[slot_id]);
+ xhci->devs[slot_id] = 0;
+}
+
+int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
+ struct usb_device *udev, gfp_t flags)
+{
+ dma_addr_t dma;
+ struct xhci_virt_device *dev;
+
+ /* Slot ID 0 is reserved */
+ if (slot_id == 0 || xhci->devs[slot_id]) {
+ xhci_warn(xhci, "Bad Slot ID %d\n", slot_id);
+ return 0;
+ }
+
+ xhci->devs[slot_id] = kzalloc(sizeof(*xhci->devs[slot_id]), flags);
+ if (!xhci->devs[slot_id])
+ return 0;
+ dev = xhci->devs[slot_id];
+
+ /* Allocate the (output) device context that will be used in the HC */
+ dev->out_ctx = dma_pool_alloc(xhci->device_pool, flags, &dma);
+ if (!dev->out_ctx)
+ goto fail;
+ dev->out_ctx_dma = dma;
+ xhci_dbg(xhci, "Slot %d output ctx = 0x%llx (dma)\n", slot_id,
+ (unsigned long long)dma);
+ memset(dev->out_ctx, 0, sizeof(*dev->out_ctx));
+
+ /* Allocate the (input) device context for address device command */
+ dev->in_ctx = dma_pool_alloc(xhci->device_pool, flags, &dma);
+ if (!dev->in_ctx)
+ goto fail;
+ dev->in_ctx_dma = dma;
+ xhci_dbg(xhci, "Slot %d input ctx = 0x%llx (dma)\n", slot_id,
+ (unsigned long long)dma);
+ memset(dev->in_ctx, 0, sizeof(*dev->in_ctx));
+
+ /* Allocate endpoint 0 ring */
+ dev->ep_rings[0] = xhci_ring_alloc(xhci, 1, true, flags);
+ if (!dev->ep_rings[0])
+ goto fail;
+
+ init_completion(&dev->cmd_completion);
+
+ /*
+ * Point to output device context in dcbaa; skip the output control
+ * context, which is eight 32 bit fields (or 32 bytes long)
+ */
+ xhci->dcbaa->dev_context_ptrs[2*slot_id] =
+ (u32) dev->out_ctx_dma + (32);
+ xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n",
+ slot_id,
+ &xhci->dcbaa->dev_context_ptrs[2*slot_id],
+ (unsigned long long)dev->out_ctx_dma);
+ xhci->dcbaa->dev_context_ptrs[2*slot_id + 1] = 0;
+
+ return 1;
+fail:
+ xhci_free_virt_device(xhci, slot_id);
+ return 0;
+}
+
+/* Setup an xHCI virtual device for a Set Address command */
+int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev)
+{
+ struct xhci_virt_device *dev;
+ struct xhci_ep_ctx *ep0_ctx;
+ struct usb_device *top_dev;
+
+ dev = xhci->devs[udev->slot_id];
+ /* Slot ID 0 is reserved */
+ if (udev->slot_id == 0 || !dev) {
+ xhci_warn(xhci, "Slot ID %d is not assigned to this device\n",
+ udev->slot_id);
+ return -EINVAL;
+ }
+ ep0_ctx = &dev->in_ctx->ep[0];
+
+ /* 2) New slot context and endpoint 0 context are valid*/
+ dev->in_ctx->add_flags = SLOT_FLAG | EP0_FLAG;
+
+ /* 3) Only the control endpoint is valid - one endpoint context */
+ dev->in_ctx->slot.dev_info |= LAST_CTX(1);
+
+ switch (udev->speed) {
+ case USB_SPEED_SUPER:
+ dev->in_ctx->slot.dev_info |= (u32) udev->route;
+ dev->in_ctx->slot.dev_info |= (u32) SLOT_SPEED_SS;
+ break;
+ case USB_SPEED_HIGH:
+ dev->in_ctx->slot.dev_info |= (u32) SLOT_SPEED_HS;
+ break;
+ case USB_SPEED_FULL:
+ dev->in_ctx->slot.dev_info |= (u32) SLOT_SPEED_FS;
+ break;
+ case USB_SPEED_LOW:
+ dev->in_ctx->slot.dev_info |= (u32) SLOT_SPEED_LS;
+ break;
+ case USB_SPEED_VARIABLE:
+ xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
+ return -EINVAL;
+ break;
+ default:
+ /* Speed was set earlier, this shouldn't happen. */
+ BUG();
+ }
+ /* Find the root hub port this device is under */
+ for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
+ top_dev = top_dev->parent)
+ /* Found device below root hub */;
+ dev->in_ctx->slot.dev_info2 |= (u32) ROOT_HUB_PORT(top_dev->portnum);
+ xhci_dbg(xhci, "Set root hub portnum to %d\n", top_dev->portnum);
+
+ /* Is this a LS/FS device under a HS hub? */
+ /*
+ * FIXME: I don't think this is right, where does the TT info for the
+ * roothub or parent hub come from?
+ */
+ if ((udev->speed == USB_SPEED_LOW || udev->speed == USB_SPEED_FULL) &&
+ udev->tt) {
+ dev->in_ctx->slot.tt_info = udev->tt->hub->slot_id;
+ dev->in_ctx->slot.tt_info |= udev->ttport << 8;
+ }
+ xhci_dbg(xhci, "udev->tt = %p\n", udev->tt);
+ xhci_dbg(xhci, "udev->ttport = 0x%x\n", udev->ttport);
+
+ /* Step 4 - ring already allocated */
+ /* Step 5 */
+ ep0_ctx->ep_info2 = EP_TYPE(CTRL_EP);
+ /*
+ * See section 4.3 bullet 6:
+ * The default Max Packet size for ep0 is "8 bytes for a USB2
+ * LS/FS/HS device or 512 bytes for a USB3 SS device"
+ * XXX: Not sure about wireless USB devices.
+ */
+ if (udev->speed == USB_SPEED_SUPER)
+ ep0_ctx->ep_info2 |= MAX_PACKET(512);
+ else
+ ep0_ctx->ep_info2 |= MAX_PACKET(8);
+ /* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
+ ep0_ctx->ep_info2 |= MAX_BURST(0);
+ ep0_ctx->ep_info2 |= ERROR_COUNT(3);
+
+ ep0_ctx->deq[0] =
+ dev->ep_rings[0]->first_seg->dma;
+ ep0_ctx->deq[0] |= dev->ep_rings[0]->cycle_state;
+ ep0_ctx->deq[1] = 0;
+
+ /* Steps 7 and 8 were done in xhci_alloc_virt_device() */
+
+ return 0;
+}
+
+/* Return the polling or NAK interval.
+ *
+ * The polling interval is expressed in "microframes". If xHCI's Interval field
+ * is set to N, it will service the endpoint every 2^(Interval)*125us.
+ *
+ * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval
+ * is set to 0.
+ */
+static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
+ struct usb_host_endpoint *ep)
+{
+ unsigned int interval = 0;
+
+ switch (udev->speed) {
+ case USB_SPEED_HIGH:
+ /* Max NAK rate */
+ if (usb_endpoint_xfer_control(&ep->desc) ||
+ usb_endpoint_xfer_bulk(&ep->desc))
+ interval = ep->desc.bInterval;
+ /* Fall through - SS and HS isoc/int have same decoding */
+ case USB_SPEED_SUPER:
+ if (usb_endpoint_xfer_int(&ep->desc) ||
+ usb_endpoint_xfer_isoc(&ep->desc)) {
+ if (ep->desc.bInterval == 0)
+ interval = 0;
+ else
+ interval = ep->desc.bInterval - 1;
+ if (interval > 15)
+ interval = 15;
+ if (interval != ep->desc.bInterval + 1)
+ dev_warn(&udev->dev, "ep %#x - rounding interval to %d microframes\n",
+ ep->desc.bEndpointAddress, 1 << interval);
+ }
+ break;
+ /* Convert bInterval (in 1-255 frames) to microframes and round down to
+ * nearest power of 2.
+ */
+ case USB_SPEED_FULL:
+ case USB_SPEED_LOW:
+ if (usb_endpoint_xfer_int(&ep->desc) ||
+ usb_endpoint_xfer_isoc(&ep->desc)) {
+ interval = fls(8*ep->desc.bInterval) - 1;
+ if (interval > 10)
+ interval = 10;
+ if (interval < 3)
+ interval = 3;
+ if ((1 << interval) != 8*ep->desc.bInterval)
+ dev_warn(&udev->dev, "ep %#x - rounding interval to %d microframes\n",
+ ep->desc.bEndpointAddress, 1 << interval);
+ }
+ break;
+ default:
+ BUG();
+ }
+ return EP_INTERVAL(interval);
+}
+
+static inline u32 xhci_get_endpoint_type(struct usb_device *udev,
+ struct usb_host_endpoint *ep)
+{
+ int in;
+ u32 type;
+
+ in = usb_endpoint_dir_in(&ep->desc);
+ if (usb_endpoint_xfer_control(&ep->desc)) {
+ type = EP_TYPE(CTRL_EP);
+ } else if (usb_endpoint_xfer_bulk(&ep->desc)) {
+ if (in)
+ type = EP_TYPE(BULK_IN_EP);
+ else
+ type = EP_TYPE(BULK_OUT_EP);
+ } else if (usb_endpoint_xfer_isoc(&ep->desc)) {
+ if (in)
+ type = EP_TYPE(ISOC_IN_EP);
+ else
+ type = EP_TYPE(ISOC_OUT_EP);
+ } else if (usb_endpoint_xfer_int(&ep->desc)) {
+ if (in)
+ type = EP_TYPE(INT_IN_EP);
+ else
+ type = EP_TYPE(INT_OUT_EP);
+ } else {
+ BUG();
+ }
+ return type;
+}
+
+int xhci_endpoint_init(struct xhci_hcd *xhci,
+ struct xhci_virt_device *virt_dev,
+ struct usb_device *udev,
+ struct usb_host_endpoint *ep)
+{
+ unsigned int ep_index;
+ struct xhci_ep_ctx *ep_ctx;
+ struct xhci_ring *ep_ring;
+ unsigned int max_packet;
+ unsigned int max_burst;
+
+ ep_index = xhci_get_endpoint_index(&ep->desc);
+ ep_ctx = &virt_dev->in_ctx->ep[ep_index];
+
+ /* Set up the endpoint ring */
+ virt_dev->new_ep_rings[ep_index] = xhci_ring_alloc(xhci, 1, true, GFP_KERNEL);
+ if (!virt_dev->new_ep_rings[ep_index])
+ return -ENOMEM;
+ ep_ring = virt_dev->new_ep_rings[ep_index];
+ ep_ctx->deq[0] = ep_ring->first_seg->dma | ep_ring->cycle_state;
+ ep_ctx->deq[1] = 0;
+
+ ep_ctx->ep_info = xhci_get_endpoint_interval(udev, ep);
+
+ /* FIXME dig Mult and streams info out of ep companion desc */
+
+ /* Allow 3 retries for everything but isoc */
+ if (!usb_endpoint_xfer_isoc(&ep->desc))
+ ep_ctx->ep_info2 = ERROR_COUNT(3);
+ else
+ ep_ctx->ep_info2 = ERROR_COUNT(0);
+
+ ep_ctx->ep_info2 |= xhci_get_endpoint_type(udev, ep);
+
+ /* Set the max packet size and max burst */
+ switch (udev->speed) {
+ case USB_SPEED_SUPER:
+ max_packet = ep->desc.wMaxPacketSize;
+ ep_ctx->ep_info2 |= MAX_PACKET(max_packet);
+ /* dig out max burst from ep companion desc */
+ max_packet = ep->ss_ep_comp->desc.bMaxBurst;
+ ep_ctx->ep_info2 |= MAX_BURST(max_packet);
+ break;
+ case USB_SPEED_HIGH:
+ /* bits 11:12 specify the number of additional transaction
+ * opportunities per microframe (USB 2.0, section 9.6.6)
+ */
+ if (usb_endpoint_xfer_isoc(&ep->desc) ||
+ usb_endpoint_xfer_int(&ep->desc)) {
+ max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11;
+ ep_ctx->ep_info2 |= MAX_BURST(max_burst);
+ }
+ /* Fall through */
+ case USB_SPEED_FULL:
+ case USB_SPEED_LOW:
+ max_packet = ep->desc.wMaxPacketSize & 0x3ff;
+ ep_ctx->ep_info2 |= MAX_PACKET(max_packet);
+ break;
+ default:
+ BUG();
+ }
+ /* FIXME Debug endpoint context */
+ return 0;
+}
+
+void xhci_endpoint_zero(struct xhci_hcd *xhci,
+ struct xhci_virt_device *virt_dev,
+ struct usb_host_endpoint *ep)
+{
+ unsigned int ep_index;
+ struct xhci_ep_ctx *ep_ctx;
+
+ ep_index = xhci_get_endpoint_index(&ep->desc);
+ ep_ctx = &virt_dev->in_ctx->ep[ep_index];
+
+ ep_ctx->ep_info = 0;
+ ep_ctx->ep_info2 = 0;
+ ep_ctx->deq[0] = 0;
+ ep_ctx->deq[1] = 0;
+ ep_ctx->tx_info = 0;
+ /* Don't free the endpoint ring until the set interface or configuration
+ * request succeeds.
+ */
+}
+
+void xhci_mem_cleanup(struct xhci_hcd *xhci)
+{
+ struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
+ int size;
+ int i;
+
+ /* Free the Event Ring Segment Table and the actual Event Ring */
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_size);
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_base[0]);
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_base[1]);
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_dequeue[0]);
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_dequeue[1]);
+ size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
+ if (xhci->erst.entries)
+ pci_free_consistent(pdev, size,
+ xhci->erst.entries, xhci->erst.erst_dma_addr);
+ xhci->erst.entries = NULL;
+ xhci_dbg(xhci, "Freed ERST\n");
+ if (xhci->event_ring)
+ xhci_ring_free(xhci, xhci->event_ring);
+ xhci->event_ring = NULL;
+ xhci_dbg(xhci, "Freed event ring\n");
+
+ xhci_writel(xhci, 0, &xhci->op_regs->cmd_ring[0]);
+ xhci_writel(xhci, 0, &xhci->op_regs->cmd_ring[1]);
+ if (xhci->cmd_ring)
+ xhci_ring_free(xhci, xhci->cmd_ring);
+ xhci->cmd_ring = NULL;
+ xhci_dbg(xhci, "Freed command ring\n");
+
+ for (i = 1; i < MAX_HC_SLOTS; ++i)
+ xhci_free_virt_device(xhci, i);
+
+ if (xhci->segment_pool)
+ dma_pool_destroy(xhci->segment_pool);
+ xhci->segment_pool = NULL;
+ xhci_dbg(xhci, "Freed segment pool\n");
+
+ if (xhci->device_pool)
+ dma_pool_destroy(xhci->device_pool);
+ xhci->device_pool = NULL;
+ xhci_dbg(xhci, "Freed device context pool\n");
+
+ xhci_writel(xhci, 0, &xhci->op_regs->dcbaa_ptr[0]);
+ xhci_writel(xhci, 0, &xhci->op_regs->dcbaa_ptr[1]);
+ if (xhci->dcbaa)
+ pci_free_consistent(pdev, sizeof(*xhci->dcbaa),
+ xhci->dcbaa, xhci->dcbaa->dma);
+ xhci->dcbaa = NULL;
+
+ xhci->page_size = 0;
+ xhci->page_shift = 0;
+}
+
+int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
+{
+ dma_addr_t dma;
+ struct device *dev = xhci_to_hcd(xhci)->self.controller;
+ unsigned int val, val2;
+ struct xhci_segment *seg;
+ u32 page_size;
+ int i;
+
+ page_size = xhci_readl(xhci, &xhci->op_regs->page_size);
+ xhci_dbg(xhci, "Supported page size register = 0x%x\n", page_size);
+ for (i = 0; i < 16; i++) {
+ if ((0x1 & page_size) != 0)
+ break;
+ page_size = page_size >> 1;
+ }
+ if (i < 16)
+ xhci_dbg(xhci, "Supported page size of %iK\n", (1 << (i+12)) / 1024);
+ else
+ xhci_warn(xhci, "WARN: no supported page size\n");
+ /* Use 4K pages, since that's common and the minimum the HC supports */
+ xhci->page_shift = 12;
+ xhci->page_size = 1 << xhci->page_shift;
+ xhci_dbg(xhci, "HCD page size set to %iK\n", xhci->page_size / 1024);
+
+ /*
+ * Program the Number of Device Slots Enabled field in the CONFIG
+ * register with the max value of slots the HC can handle.
+ */
+ val = HCS_MAX_SLOTS(xhci_readl(xhci, &xhci->cap_regs->hcs_params1));
+ xhci_dbg(xhci, "// xHC can handle at most %d device slots.\n",
+ (unsigned int) val);
+ val2 = xhci_readl(xhci, &xhci->op_regs->config_reg);
+ val |= (val2 & ~HCS_SLOTS_MASK);
+ xhci_dbg(xhci, "// Setting Max device slots reg = 0x%x.\n",
+ (unsigned int) val);
+ xhci_writel(xhci, val, &xhci->op_regs->config_reg);
+
+ /*
+ * Section 5.4.8 - doorbell array must be
+ * "physically contiguous and 64-byte (cache line) aligned".
+ */
+ xhci->dcbaa = pci_alloc_consistent(to_pci_dev(dev),
+ sizeof(*xhci->dcbaa), &dma);
+ if (!xhci->dcbaa)
+ goto fail;
+ memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa));
+ xhci->dcbaa->dma = dma;
+ xhci_dbg(xhci, "// Device context base array address = 0x%llx (DMA), %p (virt)\n",
+ (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa);
+ xhci_writel(xhci, dma, &xhci->op_regs->dcbaa_ptr[0]);
+ xhci_writel(xhci, (u32) 0, &xhci->op_regs->dcbaa_ptr[1]);
+
+ /*
+ * Initialize the ring segment pool. The ring must be a contiguous
+ * structure comprised of TRBs. The TRBs must be 16 byte aligned,
+ * however, the command ring segment needs 64-byte aligned segments,
+ * so we pick the greater alignment need.
+ */
+ xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
+ SEGMENT_SIZE, 64, xhci->page_size);
+ /* See Table 46 and Note on Figure 55 */
+ /* FIXME support 64-byte contexts */
+ xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev,
+ sizeof(struct xhci_device_control),
+ 64, xhci->page_size);
+ if (!xhci->segment_pool || !xhci->device_pool)
+ goto fail;
+
+ /* Set up the command ring to have one segments for now. */
+ xhci->cmd_ring = xhci_ring_alloc(xhci, 1, true, flags);
+ if (!xhci->cmd_ring)
+ goto fail;
+ xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring);
+ xhci_dbg(xhci, "First segment DMA is 0x%llx\n",
+ (unsigned long long)xhci->cmd_ring->first_seg->dma);
+
+ /* Set the address in the Command Ring Control register */
+ val = xhci_readl(xhci, &xhci->op_regs->cmd_ring[0]);
+ val = (val & ~CMD_RING_ADDR_MASK) |
+ (xhci->cmd_ring->first_seg->dma & CMD_RING_ADDR_MASK) |
+ xhci->cmd_ring->cycle_state;
+ xhci_dbg(xhci, "// Setting command ring address low bits to 0x%x\n", val);
+ xhci_writel(xhci, val, &xhci->op_regs->cmd_ring[0]);
+ xhci_dbg(xhci, "// Setting command ring address high bits to 0x0\n");
+ xhci_writel(xhci, (u32) 0, &xhci->op_regs->cmd_ring[1]);
+ xhci_dbg_cmd_ptrs(xhci);
+
+ val = xhci_readl(xhci, &xhci->cap_regs->db_off);
+ val &= DBOFF_MASK;
+ xhci_dbg(xhci, "// Doorbell array is located at offset 0x%x"
+ " from cap regs base addr\n", val);
+ xhci->dba = (void *) xhci->cap_regs + val;
+ xhci_dbg_regs(xhci);
+ xhci_print_run_regs(xhci);
+ /* Set ir_set to interrupt register set 0 */
+ xhci->ir_set = (void *) xhci->run_regs->ir_set;
+
+ /*
+ * Event ring setup: Allocate a normal ring, but also setup
+ * the event ring segment table (ERST). Section 4.9.3.
+ */
+ xhci_dbg(xhci, "// Allocating event ring\n");
+ xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, false, flags);
+ if (!xhci->event_ring)
+ goto fail;
+
+ xhci->erst.entries = pci_alloc_consistent(to_pci_dev(dev),
+ sizeof(struct xhci_erst_entry)*ERST_NUM_SEGS, &dma);
+ if (!xhci->erst.entries)
+ goto fail;
+ xhci_dbg(xhci, "// Allocated event ring segment table at 0x%llx\n",
+ (unsigned long long)dma);
+
+ memset(xhci->erst.entries, 0, sizeof(struct xhci_erst_entry)*ERST_NUM_SEGS);
+ xhci->erst.num_entries = ERST_NUM_SEGS;
+ xhci->erst.erst_dma_addr = dma;
+ xhci_dbg(xhci, "Set ERST to 0; private num segs = %i, virt addr = %p, dma addr = 0x%llx\n",
+ xhci->erst.num_entries,
+ xhci->erst.entries,
+ (unsigned long long)xhci->erst.erst_dma_addr);
+
+ /* set ring base address and size for each segment table entry */
+ for (val = 0, seg = xhci->event_ring->first_seg; val < ERST_NUM_SEGS; val++) {
+ struct xhci_erst_entry *entry = &xhci->erst.entries[val];
+ entry->seg_addr[0] = seg->dma;
+ entry->seg_addr[1] = 0;
+ entry->seg_size = TRBS_PER_SEGMENT;
+ entry->rsvd = 0;
+ seg = seg->next;
+ }
+
+ /* set ERST count with the number of entries in the segment table */
+ val = xhci_readl(xhci, &xhci->ir_set->erst_size);
+ val &= ERST_SIZE_MASK;
+ val |= ERST_NUM_SEGS;
+ xhci_dbg(xhci, "// Write ERST size = %i to ir_set 0 (some bits preserved)\n",
+ val);
+ xhci_writel(xhci, val, &xhci->ir_set->erst_size);
+
+ xhci_dbg(xhci, "// Set ERST entries to point to event ring.\n");
+ /* set the segment table base address */
+ xhci_dbg(xhci, "// Set ERST base address for ir_set 0 = 0x%llx\n",
+ (unsigned long long)xhci->erst.erst_dma_addr);
+ val = xhci_readl(xhci, &xhci->ir_set->erst_base[0]);
+ val &= ERST_PTR_MASK;
+ val |= (xhci->erst.erst_dma_addr & ~ERST_PTR_MASK);
+ xhci_writel(xhci, val, &xhci->ir_set->erst_base[0]);
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_base[1]);
+
+ /* Set the event ring dequeue address */
+ xhci_set_hc_event_deq(xhci);
+ xhci_dbg(xhci, "Wrote ERST address to ir_set 0.\n");
+ xhci_print_ir_set(xhci, xhci->ir_set, 0);
+
+ /*
+ * XXX: Might need to set the Interrupter Moderation Register to
+ * something other than the default (~1ms minimum between interrupts).
+ * See section 5.5.1.2.
+ */
+ init_completion(&xhci->addr_dev);
+ for (i = 0; i < MAX_HC_SLOTS; ++i)
+ xhci->devs[i] = 0;
+
+ return 0;
+fail:
+ xhci_warn(xhci, "Couldn't initialize memory\n");
+ xhci_mem_cleanup(xhci);
+ return -ENOMEM;
+}
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
new file mode 100644
index 000000000000..1462709e26c0
--- /dev/null
+++ b/drivers/usb/host/xhci-pci.c
@@ -0,0 +1,166 @@
+/*
+ * xHCI host controller driver PCI Bus Glue.
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/pci.h>
+
+#include "xhci.h"
+
+static const char hcd_name[] = "xhci_hcd";
+
+/* called after powerup, by probe or system-pm "wakeup" */
+static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
+{
+ /*
+ * TODO: Implement finding debug ports later.
+ * TODO: see if there are any quirks that need to be added to handle
+ * new extended capabilities.
+ */
+
+ /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
+ if (!pci_set_mwi(pdev))
+ xhci_dbg(xhci, "MWI active\n");
+
+ xhci_dbg(xhci, "Finished xhci_pci_reinit\n");
+ return 0;
+}
+
+/* called during probe() after chip reset completes */
+static int xhci_pci_setup(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
+ int retval;
+
+ xhci->cap_regs = hcd->regs;
+ xhci->op_regs = hcd->regs +
+ HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase));
+ xhci->run_regs = hcd->regs +
+ (xhci_readl(xhci, &xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
+ /* Cache read-only capability registers */
+ xhci->hcs_params1 = xhci_readl(xhci, &xhci->cap_regs->hcs_params1);
+ xhci->hcs_params2 = xhci_readl(xhci, &xhci->cap_regs->hcs_params2);
+ xhci->hcs_params3 = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
+ xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
+ xhci_print_registers(xhci);
+
+ /* Make sure the HC is halted. */
+ retval = xhci_halt(xhci);
+ if (retval)
+ return retval;
+
+ xhci_dbg(xhci, "Resetting HCD\n");
+ /* Reset the internal HC memory state and registers. */
+ retval = xhci_reset(xhci);
+ if (retval)
+ return retval;
+ xhci_dbg(xhci, "Reset complete\n");
+
+ xhci_dbg(xhci, "Calling HCD init\n");
+ /* Initialize HCD and host controller data structures. */
+ retval = xhci_init(hcd);
+ if (retval)
+ return retval;
+ xhci_dbg(xhci, "Called HCD init\n");
+
+ pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
+ xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
+
+ /* Find any debug ports */
+ return xhci_pci_reinit(xhci, pdev);
+}
+
+static const struct hc_driver xhci_pci_hc_driver = {
+ .description = hcd_name,
+ .product_desc = "xHCI Host Controller",
+ .hcd_priv_size = sizeof(struct xhci_hcd),
+
+ /*
+ * generic hardware linkage
+ */
+ .irq = xhci_irq,
+ .flags = HCD_MEMORY | HCD_USB3,
+
+ /*
+ * basic lifecycle operations
+ */
+ .reset = xhci_pci_setup,
+ .start = xhci_run,
+ /* suspend and resume implemented later */
+ .stop = xhci_stop,
+ .shutdown = xhci_shutdown,
+
+ /*
+ * managing i/o requests and associated device resources
+ */
+ .urb_enqueue = xhci_urb_enqueue,
+ .urb_dequeue = xhci_urb_dequeue,
+ .alloc_dev = xhci_alloc_dev,
+ .free_dev = xhci_free_dev,
+ .add_endpoint = xhci_add_endpoint,
+ .drop_endpoint = xhci_drop_endpoint,
+ .check_bandwidth = xhci_check_bandwidth,
+ .reset_bandwidth = xhci_reset_bandwidth,
+ .address_device = xhci_address_device,
+
+ /*
+ * scheduling support
+ */
+ .get_frame_number = xhci_get_frame,
+
+ /* Root hub support */
+ .hub_control = xhci_hub_control,
+ .hub_status_data = xhci_hub_status_data,
+};
+
+/*-------------------------------------------------------------------------*/
+
+/* PCI driver selection metadata; PCI hotplugging uses this */
+static const struct pci_device_id pci_ids[] = { {
+ /* handle any USB 3.0 xHCI controller */
+ PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
+ .driver_data = (unsigned long) &xhci_pci_hc_driver,
+ },
+ { /* end: all zeroes */ }
+};
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+/* pci driver glue; this is a "new style" PCI driver module */
+static struct pci_driver xhci_pci_driver = {
+ .name = (char *) hcd_name,
+ .id_table = pci_ids,
+
+ .probe = usb_hcd_pci_probe,
+ .remove = usb_hcd_pci_remove,
+ /* suspend and resume implemented later */
+
+ .shutdown = usb_hcd_pci_shutdown,
+};
+
+int xhci_register_pci()
+{
+ return pci_register_driver(&xhci_pci_driver);
+}
+
+void xhci_unregister_pci()
+{
+ pci_unregister_driver(&xhci_pci_driver);
+}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
new file mode 100644
index 000000000000..d42a738cdaa7
--- /dev/null
+++ b/drivers/usb/host/xhci-ring.c
@@ -0,0 +1,1649 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*
+ * Ring initialization rules:
+ * 1. Each segment is initialized to zero, except for link TRBs.
+ * 2. Ring cycle state = 0. This represents Producer Cycle State (PCS) or
+ * Consumer Cycle State (CCS), depending on ring function.
+ * 3. Enqueue pointer = dequeue pointer = address of first TRB in the segment.
+ *
+ * Ring behavior rules:
+ * 1. A ring is empty if enqueue == dequeue. This means there will always be at
+ * least one free TRB in the ring. This is useful if you want to turn that
+ * into a link TRB and expand the ring.
+ * 2. When incrementing an enqueue or dequeue pointer, if the next TRB is a
+ * link TRB, then load the pointer with the address in the link TRB. If the
+ * link TRB had its toggle bit set, you may need to update the ring cycle
+ * state (see cycle bit rules). You may have to do this multiple times
+ * until you reach a non-link TRB.
+ * 3. A ring is full if enqueue++ (for the definition of increment above)
+ * equals the dequeue pointer.
+ *
+ * Cycle bit rules:
+ * 1. When a consumer increments a dequeue pointer and encounters a toggle bit
+ * in a link TRB, it must toggle the ring cycle state.
+ * 2. When a producer increments an enqueue pointer and encounters a toggle bit
+ * in a link TRB, it must toggle the ring cycle state.
+ *
+ * Producer rules:
+ * 1. Check if ring is full before you enqueue.
+ * 2. Write the ring cycle state to the cycle bit in the TRB you're enqueuing.
+ * Update enqueue pointer between each write (which may update the ring
+ * cycle state).
+ * 3. Notify consumer. If SW is producer, it rings the doorbell for command
+ * and endpoint rings. If HC is the producer for the event ring,
+ * and it generates an interrupt according to interrupt modulation rules.
+ *
+ * Consumer rules:
+ * 1. Check if TRB belongs to you. If the cycle bit == your ring cycle state,
+ * the TRB is owned by the consumer.
+ * 2. Update dequeue pointer (which may update the ring cycle state) and
+ * continue processing TRBs until you reach a TRB which is not owned by you.
+ * 3. Notify the producer. SW is the consumer for the event ring, and it
+ * updates event ring dequeue pointer. HC is the consumer for the command and
+ * endpoint rings; it generates events on the event ring for these.
+ */
+
+#include <linux/scatterlist.h>
+#include "xhci.h"
+
+/*
+ * Returns zero if the TRB isn't in this segment, otherwise it returns the DMA
+ * address of the TRB.
+ */
+dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg,
+ union xhci_trb *trb)
+{
+ dma_addr_t offset;
+
+ if (!seg || !trb || (void *) trb < (void *) seg->trbs)
+ return 0;
+ /* offset in bytes, since these are byte-addressable */
+ offset = trb - seg->trbs;
+ /* SEGMENT_SIZE in bytes, trbs are 16-byte aligned */
+ if (offset > SEGMENT_SIZE || (offset % sizeof(*trb)) != 0)
+ return 0;
+ return seg->dma + offset;
+}
+
+/* Does this link TRB point to the first segment in a ring,
+ * or was the previous TRB the last TRB on the last segment in the ERST?
+ */
+static inline bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring,
+ struct xhci_segment *seg, union xhci_trb *trb)
+{
+ if (ring == xhci->event_ring)
+ return (trb == &seg->trbs[TRBS_PER_SEGMENT]) &&
+ (seg->next == xhci->event_ring->first_seg);
+ else
+ return trb->link.control & LINK_TOGGLE;
+}
+
+/* Is this TRB a link TRB or was the last TRB the last TRB in this event ring
+ * segment? I.e. would the updated event TRB pointer step off the end of the
+ * event seg?
+ */
+static inline int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
+ struct xhci_segment *seg, union xhci_trb *trb)
+{
+ if (ring == xhci->event_ring)
+ return trb == &seg->trbs[TRBS_PER_SEGMENT];
+ else
+ return (trb->link.control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK);
+}
+
+/* Updates trb to point to the next TRB in the ring, and updates seg if the next
+ * TRB is in a new segment. This does not skip over link TRBs, and it does not
+ * effect the ring dequeue or enqueue pointers.
+ */
+static void next_trb(struct xhci_hcd *xhci,
+ struct xhci_ring *ring,
+ struct xhci_segment **seg,
+ union xhci_trb **trb)
+{
+ if (last_trb(xhci, ring, *seg, *trb)) {
+ *seg = (*seg)->next;
+ *trb = ((*seg)->trbs);
+ } else {
+ *trb = (*trb)++;
+ }
+}
+
+/*
+ * See Cycle bit rules. SW is the consumer for the event ring only.
+ * Don't make a ring full of link TRBs. That would be dumb and this would loop.
+ */
+static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer)
+{
+ union xhci_trb *next = ++(ring->dequeue);
+
+ ring->deq_updates++;
+ /* Update the dequeue pointer further if that was a link TRB or we're at
+ * the end of an event ring segment (which doesn't have link TRBS)
+ */
+ while (last_trb(xhci, ring, ring->deq_seg, next)) {
+ if (consumer && last_trb_on_last_seg(xhci, ring, ring->deq_seg, next)) {
+ ring->cycle_state = (ring->cycle_state ? 0 : 1);
+ if (!in_interrupt())
+ xhci_dbg(xhci, "Toggle cycle state for ring %p = %i\n",
+ ring,
+ (unsigned int) ring->cycle_state);
+ }
+ ring->deq_seg = ring->deq_seg->next;
+ ring->dequeue = ring->deq_seg->trbs;
+ next = ring->dequeue;
+ }
+}
+
+/*
+ * See Cycle bit rules. SW is the consumer for the event ring only.
+ * Don't make a ring full of link TRBs. That would be dumb and this would loop.
+ *
+ * If we've just enqueued a TRB that is in the middle of a TD (meaning the
+ * chain bit is set), then set the chain bit in all the following link TRBs.
+ * If we've enqueued the last TRB in a TD, make sure the following link TRBs
+ * have their chain bit cleared (so that each Link TRB is a separate TD).
+ *
+ * Section 6.4.4.1 of the 0.95 spec says link TRBs cannot have the chain bit
+ * set, but other sections talk about dealing with the chain bit set.
+ * Assume section 6.4.4.1 is wrong, and the chain bit can be set in a Link TRB.
+ */
+static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer)
+{
+ u32 chain;
+ union xhci_trb *next;
+
+ chain = ring->enqueue->generic.field[3] & TRB_CHAIN;
+ next = ++(ring->enqueue);
+
+ ring->enq_updates++;
+ /* Update the dequeue pointer further if that was a link TRB or we're at
+ * the end of an event ring segment (which doesn't have link TRBS)
+ */
+ while (last_trb(xhci, ring, ring->enq_seg, next)) {
+ if (!consumer) {
+ if (ring != xhci->event_ring) {
+ next->link.control &= ~TRB_CHAIN;
+ next->link.control |= chain;
+ /* Give this link TRB to the hardware */
+ wmb();
+ if (next->link.control & TRB_CYCLE)
+ next->link.control &= (u32) ~TRB_CYCLE;
+ else
+ next->link.control |= (u32) TRB_CYCLE;
+ }
+ /* Toggle the cycle bit after the last ring segment. */
+ if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) {
+ ring->cycle_state = (ring->cycle_state ? 0 : 1);
+ if (!in_interrupt())
+ xhci_dbg(xhci, "Toggle cycle state for ring %p = %i\n",
+ ring,
+ (unsigned int) ring->cycle_state);
+ }
+ }
+ ring->enq_seg = ring->enq_seg->next;
+ ring->enqueue = ring->enq_seg->trbs;
+ next = ring->enqueue;
+ }
+}
+
+/*
+ * Check to see if there's room to enqueue num_trbs on the ring. See rules
+ * above.
+ * FIXME: this would be simpler and faster if we just kept track of the number
+ * of free TRBs in a ring.
+ */
+static int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring,
+ unsigned int num_trbs)
+{
+ int i;
+ union xhci_trb *enq = ring->enqueue;
+ struct xhci_segment *enq_seg = ring->enq_seg;
+
+ /* Check if ring is empty */
+ if (enq == ring->dequeue)
+ return 1;
+ /* Make sure there's an extra empty TRB available */
+ for (i = 0; i <= num_trbs; ++i) {
+ if (enq == ring->dequeue)
+ return 0;
+ enq++;
+ while (last_trb(xhci, ring, enq_seg, enq)) {
+ enq_seg = enq_seg->next;
+ enq = enq_seg->trbs;
+ }
+ }
+ return 1;
+}
+
+void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
+{
+ u32 temp;
+ dma_addr_t deq;
+
+ deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg,
+ xhci->event_ring->dequeue);
+ if (deq == 0 && !in_interrupt())
+ xhci_warn(xhci, "WARN something wrong with SW event ring "
+ "dequeue ptr.\n");
+ /* Update HC event ring dequeue pointer */
+ temp = xhci_readl(xhci, &xhci->ir_set->erst_dequeue[0]);
+ temp &= ERST_PTR_MASK;
+ if (!in_interrupt())
+ xhci_dbg(xhci, "// Write event ring dequeue pointer\n");
+ xhci_writel(xhci, 0, &xhci->ir_set->erst_dequeue[1]);
+ xhci_writel(xhci, (deq & ~ERST_PTR_MASK) | temp,
+ &xhci->ir_set->erst_dequeue[0]);
+}
+
+/* Ring the host controller doorbell after placing a command on the ring */
+void xhci_ring_cmd_db(struct xhci_hcd *xhci)
+{
+ u32 temp;
+
+ xhci_dbg(xhci, "// Ding dong!\n");
+ temp = xhci_readl(xhci, &xhci->dba->doorbell[0]) & DB_MASK;
+ xhci_writel(xhci, temp | DB_TARGET_HOST, &xhci->dba->doorbell[0]);
+ /* Flush PCI posted writes */
+ xhci_readl(xhci, &xhci->dba->doorbell[0]);
+}
+
+static void ring_ep_doorbell(struct xhci_hcd *xhci,
+ unsigned int slot_id,
+ unsigned int ep_index)
+{
+ struct xhci_ring *ep_ring;
+ u32 field;
+ __u32 __iomem *db_addr = &xhci->dba->doorbell[slot_id];
+
+ ep_ring = xhci->devs[slot_id]->ep_rings[ep_index];
+ /* Don't ring the doorbell for this endpoint if there are pending
+ * cancellations because the we don't want to interrupt processing.
+ */
+ if (!ep_ring->cancels_pending && !(ep_ring->state & SET_DEQ_PENDING)) {
+ field = xhci_readl(xhci, db_addr) & DB_MASK;
+ xhci_writel(xhci, field | EPI_TO_DB(ep_index), db_addr);
+ /* Flush PCI posted writes - FIXME Matthew Wilcox says this
+ * isn't time-critical and we shouldn't make the CPU wait for
+ * the flush.
+ */
+ xhci_readl(xhci, db_addr);
+ }
+}
+
+/*
+ * Find the segment that trb is in. Start searching in start_seg.
+ * If we must move past a segment that has a link TRB with a toggle cycle state
+ * bit set, then we will toggle the value pointed at by cycle_state.
+ */
+static struct xhci_segment *find_trb_seg(
+ struct xhci_segment *start_seg,
+ union xhci_trb *trb, int *cycle_state)
+{
+ struct xhci_segment *cur_seg = start_seg;
+ struct xhci_generic_trb *generic_trb;
+
+ while (cur_seg->trbs > trb ||
+ &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
+ generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic;
+ if (TRB_TYPE(generic_trb->field[3]) == TRB_LINK &&
+ (generic_trb->field[3] & LINK_TOGGLE))
+ *cycle_state = ~(*cycle_state) & 0x1;
+ cur_seg = cur_seg->next;
+ if (cur_seg == start_seg)
+ /* Looped over the entire list. Oops! */
+ return 0;
+ }
+ return cur_seg;
+}
+
+struct dequeue_state {
+ struct xhci_segment *new_deq_seg;
+ union xhci_trb *new_deq_ptr;
+ int new_cycle_state;
+};
+
+/*
+ * Move the xHC's endpoint ring dequeue pointer past cur_td.
+ * Record the new state of the xHC's endpoint ring dequeue segment,
+ * dequeue pointer, and new consumer cycle state in state.
+ * Update our internal representation of the ring's dequeue pointer.
+ *
+ * We do this in three jumps:
+ * - First we update our new ring state to be the same as when the xHC stopped.
+ * - Then we traverse the ring to find the segment that contains
+ * the last TRB in the TD. We toggle the xHC's new cycle state when we pass
+ * any link TRBs with the toggle cycle bit set.
+ * - Finally we move the dequeue state one TRB further, toggling the cycle bit
+ * if we've moved it past a link TRB with the toggle cycle bit set.
+ */
+static void find_new_dequeue_state(struct xhci_hcd *xhci,
+ unsigned int slot_id, unsigned int ep_index,
+ struct xhci_td *cur_td, struct dequeue_state *state)
+{
+ struct xhci_virt_device *dev = xhci->devs[slot_id];
+ struct xhci_ring *ep_ring = dev->ep_rings[ep_index];
+ struct xhci_generic_trb *trb;
+
+ state->new_cycle_state = 0;
+ state->new_deq_seg = find_trb_seg(cur_td->start_seg,
+ ep_ring->stopped_trb,
+ &state->new_cycle_state);
+ if (!state->new_deq_seg)
+ BUG();
+ /* Dig out the cycle state saved by the xHC during the stop ep cmd */
+ state->new_cycle_state = 0x1 & dev->out_ctx->ep[ep_index].deq[0];
+
+ state->new_deq_ptr = cur_td->last_trb;
+ state->new_deq_seg = find_trb_seg(state->new_deq_seg,
+ state->new_deq_ptr,
+ &state->new_cycle_state);
+ if (!state->new_deq_seg)
+ BUG();
+
+ trb = &state->new_deq_ptr->generic;
+ if (TRB_TYPE(trb->field[3]) == TRB_LINK &&
+ (trb->field[3] & LINK_TOGGLE))
+ state->new_cycle_state = ~(state->new_cycle_state) & 0x1;
+ next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
+
+ /* Don't update the ring cycle state for the producer (us). */
+ ep_ring->dequeue = state->new_deq_ptr;
+ ep_ring->deq_seg = state->new_deq_seg;
+}
+
+static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
+ struct xhci_td *cur_td)
+{
+ struct xhci_segment *cur_seg;
+ union xhci_trb *cur_trb;
+
+ for (cur_seg = cur_td->start_seg, cur_trb = cur_td->first_trb;
+ true;
+ next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) {
+ if ((cur_trb->generic.field[3] & TRB_TYPE_BITMASK) ==
+ TRB_TYPE(TRB_LINK)) {
+ /* Unchain any chained Link TRBs, but
+ * leave the pointers intact.
+ */
+ cur_trb->generic.field[3] &= ~TRB_CHAIN;
+ xhci_dbg(xhci, "Cancel (unchain) link TRB\n");
+ xhci_dbg(xhci, "Address = %p (0x%llx dma); "
+ "in seg %p (0x%llx dma)\n",
+ cur_trb,
+ (unsigned long long)xhci_trb_virt_to_dma(cur_seg, cur_trb),
+ cur_seg,
+ (unsigned long long)cur_seg->dma);
+ } else {
+ cur_trb->generic.field[0] = 0;
+ cur_trb->generic.field[1] = 0;
+ cur_trb->generic.field[2] = 0;
+ /* Preserve only the cycle bit of this TRB */
+ cur_trb->generic.field[3] &= TRB_CYCLE;
+ cur_trb->generic.field[3] |= TRB_TYPE(TRB_TR_NOOP);
+ xhci_dbg(xhci, "Cancel TRB %p (0x%llx dma) "
+ "in seg %p (0x%llx dma)\n",
+ cur_trb,
+ (unsigned long long)xhci_trb_virt_to_dma(cur_seg, cur_trb),
+ cur_seg,
+ (unsigned long long)cur_seg->dma);
+ }
+ if (cur_trb == cur_td->last_trb)
+ break;
+ }
+}
+
+static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id,
+ unsigned int ep_index, struct xhci_segment *deq_seg,
+ union xhci_trb *deq_ptr, u32 cycle_state);
+
+/*
+ * When we get a command completion for a Stop Endpoint Command, we need to
+ * unlink any cancelled TDs from the ring. There are two ways to do that:
+ *
+ * 1. If the HW was in the middle of processing the TD that needs to be
+ * cancelled, then we must move the ring's dequeue pointer past the last TRB
+ * in the TD with a Set Dequeue Pointer Command.
+ * 2. Otherwise, we turn all the TRBs in the TD into No-op TRBs (with the chain
+ * bit cleared) so that the HW will skip over them.
+ */
+static void handle_stopped_endpoint(struct xhci_hcd *xhci,
+ union xhci_trb *trb)
+{
+ unsigned int slot_id;
+ unsigned int ep_index;
+ struct xhci_ring *ep_ring;
+ struct list_head *entry;
+ struct xhci_td *cur_td = 0;
+ struct xhci_td *last_unlinked_td;
+
+ struct dequeue_state deq_state;
+#ifdef CONFIG_USB_HCD_STAT
+ ktime_t stop_time = ktime_get();
+#endif
+
+ memset(&deq_state, 0, sizeof(deq_state));
+ slot_id = TRB_TO_SLOT_ID(trb->generic.field[3]);
+ ep_index = TRB_TO_EP_INDEX(trb->generic.field[3]);
+ ep_ring = xhci->devs[slot_id]->ep_rings[ep_index];
+
+ if (list_empty(&ep_ring->cancelled_td_list))
+ return;
+
+ /* Fix up the ep ring first, so HW stops executing cancelled TDs.
+ * We have the xHCI lock, so nothing can modify this list until we drop
+ * it. We're also in the event handler, so we can't get re-interrupted
+ * if another Stop Endpoint command completes
+ */
+ list_for_each(entry, &ep_ring->cancelled_td_list) {
+ cur_td = list_entry(entry, struct xhci_td, cancelled_td_list);
+ xhci_dbg(xhci, "Cancelling TD starting at %p, 0x%llx (dma).\n",
+ cur_td->first_trb,
+ (unsigned long long)xhci_trb_virt_to_dma(cur_td->start_seg, cur_td->first_trb));
+ /*
+ * If we stopped on the TD we need to cancel, then we have to
+ * move the xHC endpoint ring dequeue pointer past this TD.
+ */
+ if (cur_td == ep_ring->stopped_td)
+ find_new_dequeue_state(xhci, slot_id, ep_index, cur_td,
+ &deq_state);
+ else
+ td_to_noop(xhci, ep_ring, cur_td);
+ /*
+ * The event handler won't see a completion for this TD anymore,
+ * so remove it from the endpoint ring's TD list. Keep it in
+ * the cancelled TD list for URB completion later.
+ */
+ list_del(&cur_td->td_list);
+ ep_ring->cancels_pending--;
+ }
+ last_unlinked_td = cur_td;
+
+ /* If necessary, queue a Set Transfer Ring Dequeue Pointer command */
+ if (deq_state.new_deq_ptr && deq_state.new_deq_seg) {
+ xhci_dbg(xhci, "Set TR Deq Ptr cmd, new deq seg = %p (0x%llx dma), "
+ "new deq ptr = %p (0x%llx dma), new cycle = %u\n",
+ deq_state.new_deq_seg,
+ (unsigned long long)deq_state.new_deq_seg->dma,
+ deq_state.new_deq_ptr,
+ (unsigned long long)xhci_trb_virt_to_dma(deq_state.new_deq_seg, deq_state.new_deq_ptr),
+ deq_state.new_cycle_state);
+ queue_set_tr_deq(xhci, slot_id, ep_index,
+ deq_state.new_deq_seg,
+ deq_state.new_deq_ptr,
+ (u32) deq_state.new_cycle_state);
+ /* Stop the TD queueing code from ringing the doorbell until
+ * this command completes. The HC won't set the dequeue pointer
+ * if the ring is running, and ringing the doorbell starts the
+ * ring running.
+ */
+ ep_ring->state |= SET_DEQ_PENDING;
+ xhci_ring_cmd_db(xhci);
+ } else {
+ /* Otherwise just ring the doorbell to restart the ring */
+ ring_ep_doorbell(xhci, slot_id, ep_index);
+ }
+
+ /*
+ * Drop the lock and complete the URBs in the cancelled TD list.
+ * New TDs to be cancelled might be added to the end of the list before
+ * we can complete all the URBs for the TDs we already unlinked.
+ * So stop when we've completed the URB for the last TD we unlinked.
+ */
+ do {
+ cur_td = list_entry(ep_ring->cancelled_td_list.next,
+ struct xhci_td, cancelled_td_list);
+ list_del(&cur_td->cancelled_td_list);
+
+ /* Clean up the cancelled URB */
+#ifdef CONFIG_USB_HCD_STAT
+ hcd_stat_update(xhci->tp_stat, cur_td->urb->actual_length,
+ ktime_sub(stop_time, cur_td->start_time));
+#endif
+ cur_td->urb->hcpriv = NULL;
+ usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), cur_td->urb);
+
+ xhci_dbg(xhci, "Giveback cancelled URB %p\n", cur_td->urb);
+ spin_unlock(&xhci->lock);
+ /* Doesn't matter what we pass for status, since the core will
+ * just overwrite it (because the URB has been unlinked).
+ */
+ usb_hcd_giveback_urb(xhci_to_hcd(xhci), cur_td->urb, 0);
+ kfree(cur_td);
+
+ spin_lock(&xhci->lock);
+ } while (cur_td != last_unlinked_td);
+
+ /* Return to the event handler with xhci->lock re-acquired */
+}
+
+/*
+ * When we get a completion for a Set Transfer Ring Dequeue Pointer command,
+ * we need to clear the set deq pending flag in the endpoint ring state, so that
+ * the TD queueing code can ring the doorbell again. We also need to ring the
+ * endpoint doorbell to restart the ring, but only if there aren't more
+ * cancellations pending.
+ */
+static void handle_set_deq_completion(struct xhci_hcd *xhci,
+ struct xhci_event_cmd *event,
+ union xhci_trb *trb)
+{
+ unsigned int slot_id;
+ unsigned int ep_index;
+ struct xhci_ring *ep_ring;
+ struct xhci_virt_device *dev;
+
+ slot_id = TRB_TO_SLOT_ID(trb->generic.field[3]);
+ ep_index = TRB_TO_EP_INDEX(trb->generic.field[3]);
+ dev = xhci->devs[slot_id];
+ ep_ring = dev->ep_rings[ep_index];
+
+ if (GET_COMP_CODE(event->status) != COMP_SUCCESS) {
+ unsigned int ep_state;
+ unsigned int slot_state;
+
+ switch (GET_COMP_CODE(event->status)) {
+ case COMP_TRB_ERR:
+ xhci_warn(xhci, "WARN Set TR Deq Ptr cmd invalid because "
+ "of stream ID configuration\n");
+ break;
+ case COMP_CTX_STATE:
+ xhci_warn(xhci, "WARN Set TR Deq Ptr cmd failed due "
+ "to incorrect slot or ep state.\n");
+ ep_state = dev->out_ctx->ep[ep_index].ep_info;
+ ep_state &= EP_STATE_MASK;
+ slot_state = dev->out_ctx->slot.dev_state;
+ slot_state = GET_SLOT_STATE(slot_state);
+ xhci_dbg(xhci, "Slot state = %u, EP state = %u\n",
+ slot_state, ep_state);
+ break;
+ case COMP_EBADSLT:
+ xhci_warn(xhci, "WARN Set TR Deq Ptr cmd failed because "
+ "slot %u was not enabled.\n", slot_id);
+ break;
+ default:
+ xhci_warn(xhci, "WARN Set TR Deq Ptr cmd with unknown "
+ "completion code of %u.\n",
+ GET_COMP_CODE(event->status));
+ break;
+ }
+ /* OK what do we do now? The endpoint state is hosed, and we
+ * should never get to this point if the synchronization between
+ * queueing, and endpoint state are correct. This might happen
+ * if the device gets disconnected after we've finished
+ * cancelling URBs, which might not be an error...
+ */
+ } else {
+ xhci_dbg(xhci, "Successful Set TR Deq Ptr cmd, deq[0] = 0x%x, "
+ "deq[1] = 0x%x.\n",
+ dev->out_ctx->ep[ep_index].deq[0],
+ dev->out_ctx->ep[ep_index].deq[1]);
+ }
+
+ ep_ring->state &= ~SET_DEQ_PENDING;
+ ring_ep_doorbell(xhci, slot_id, ep_index);
+}
+
+
+static void handle_cmd_completion(struct xhci_hcd *xhci,
+ struct xhci_event_cmd *event)
+{
+ int slot_id = TRB_TO_SLOT_ID(event->flags);
+ u64 cmd_dma;
+ dma_addr_t cmd_dequeue_dma;
+
+ cmd_dma = (((u64) event->cmd_trb[1]) << 32) + event->cmd_trb[0];
+ cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
+ xhci->cmd_ring->dequeue);
+ /* Is the command ring deq ptr out of sync with the deq seg ptr? */
+ if (cmd_dequeue_dma == 0) {
+ xhci->error_bitmask |= 1 << 4;
+ return;
+ }
+ /* Does the DMA address match our internal dequeue pointer address? */
+ if (cmd_dma != (u64) cmd_dequeue_dma) {
+ xhci->error_bitmask |= 1 << 5;
+ return;
+ }
+ switch (xhci->cmd_ring->dequeue->generic.field[3] & TRB_TYPE_BITMASK) {
+ case TRB_TYPE(TRB_ENABLE_SLOT):
+ if (GET_COMP_CODE(event->status) == COMP_SUCCESS)
+ xhci->slot_id = slot_id;
+ else
+ xhci->slot_id = 0;
+ complete(&xhci->addr_dev);
+ break;
+ case TRB_TYPE(TRB_DISABLE_SLOT):
+ if (xhci->devs[slot_id])
+ xhci_free_virt_device(xhci, slot_id);
+ break;
+ case TRB_TYPE(TRB_CONFIG_EP):
+ xhci->devs[slot_id]->cmd_status = GET_COMP_CODE(event->status);
+ complete(&xhci->devs[slot_id]->cmd_completion);
+ break;
+ case TRB_TYPE(TRB_ADDR_DEV):
+ xhci->devs[slot_id]->cmd_status = GET_COMP_CODE(event->status);
+ complete(&xhci->addr_dev);
+ break;
+ case TRB_TYPE(TRB_STOP_RING):
+ handle_stopped_endpoint(xhci, xhci->cmd_ring->dequeue);
+ break;
+ case TRB_TYPE(TRB_SET_DEQ):
+ handle_set_deq_completion(xhci, event, xhci->cmd_ring->dequeue);
+ break;
+ case TRB_TYPE(TRB_CMD_NOOP):
+ ++xhci->noops_handled;
+ break;
+ default:
+ /* Skip over unknown commands on the event ring */
+ xhci->error_bitmask |= 1 << 6;
+ break;
+ }
+ inc_deq(xhci, xhci->cmd_ring, false);
+}
+
+static void handle_port_status(struct xhci_hcd *xhci,
+ union xhci_trb *event)
+{
+ u32 port_id;
+
+ /* Port status change events always have a successful completion code */
+ if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) {
+ xhci_warn(xhci, "WARN: xHC returned failed port status event\n");
+ xhci->error_bitmask |= 1 << 8;
+ }
+ /* FIXME: core doesn't care about all port link state changes yet */
+ port_id = GET_PORT_ID(event->generic.field[0]);
+ xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id);
+
+ /* Update event ring dequeue pointer before dropping the lock */
+ inc_deq(xhci, xhci->event_ring, true);
+ xhci_set_hc_event_deq(xhci);
+
+ spin_unlock(&xhci->lock);
+ /* Pass this up to the core */
+ usb_hcd_poll_rh_status(xhci_to_hcd(xhci));
+ spin_lock(&xhci->lock);
+}
+
+/*
+ * This TD is defined by the TRBs starting at start_trb in start_seg and ending
+ * at end_trb, which may be in another segment. If the suspect DMA address is a
+ * TRB in this TD, this function returns that TRB's segment. Otherwise it
+ * returns 0.
+ */
+static struct xhci_segment *trb_in_td(
+ struct xhci_segment *start_seg,
+ union xhci_trb *start_trb,
+ union xhci_trb *end_trb,
+ dma_addr_t suspect_dma)
+{
+ dma_addr_t start_dma;
+ dma_addr_t end_seg_dma;
+ dma_addr_t end_trb_dma;
+ struct xhci_segment *cur_seg;
+
+ start_dma = xhci_trb_virt_to_dma(start_seg, start_trb);
+ cur_seg = start_seg;
+
+ do {
+ /* We may get an event for a Link TRB in the middle of a TD */
+ end_seg_dma = xhci_trb_virt_to_dma(cur_seg,
+ &start_seg->trbs[TRBS_PER_SEGMENT - 1]);
+ /* If the end TRB isn't in this segment, this is set to 0 */
+ end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb);
+
+ if (end_trb_dma > 0) {
+ /* The end TRB is in this segment, so suspect should be here */
+ if (start_dma <= end_trb_dma) {
+ if (suspect_dma >= start_dma && suspect_dma <= end_trb_dma)
+ return cur_seg;
+ } else {
+ /* Case for one segment with
+ * a TD wrapped around to the top
+ */
+ if ((suspect_dma >= start_dma &&
+ suspect_dma <= end_seg_dma) ||
+ (suspect_dma >= cur_seg->dma &&
+ suspect_dma <= end_trb_dma))
+ return cur_seg;
+ }
+ return 0;
+ } else {
+ /* Might still be somewhere in this segment */
+ if (suspect_dma >= start_dma && suspect_dma <= end_seg_dma)
+ return cur_seg;
+ }
+ cur_seg = cur_seg->next;
+ start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]);
+ } while (1);
+
+}
+
+/*
+ * If this function returns an error condition, it means it got a Transfer
+ * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address.
+ * At this point, the host controller is probably hosed and should be reset.
+ */
+static int handle_tx_event(struct xhci_hcd *xhci,
+ struct xhci_transfer_event *event)
+{
+ struct xhci_virt_device *xdev;
+ struct xhci_ring *ep_ring;
+ int ep_index;
+ struct xhci_td *td = 0;
+ dma_addr_t event_dma;
+ struct xhci_segment *event_seg;
+ union xhci_trb *event_trb;
+ struct urb *urb = 0;
+ int status = -EINPROGRESS;
+
+ xdev = xhci->devs[TRB_TO_SLOT_ID(event->flags)];
+ if (!xdev) {
+ xhci_err(xhci, "ERROR Transfer event pointed to bad slot\n");
+ return -ENODEV;
+ }
+
+ /* Endpoint ID is 1 based, our index is zero based */
+ ep_index = TRB_TO_EP_ID(event->flags) - 1;
+ ep_ring = xdev->ep_rings[ep_index];
+ if (!ep_ring || (xdev->out_ctx->ep[ep_index].ep_info & EP_STATE_MASK) == EP_STATE_DISABLED) {
+ xhci_err(xhci, "ERROR Transfer event pointed to disabled endpoint\n");
+ return -ENODEV;
+ }
+
+ event_dma = event->buffer[0];
+ if (event->buffer[1] != 0)
+ xhci_warn(xhci, "WARN ignoring upper 32-bits of 64-bit TRB dma address\n");
+
+ /* This TRB should be in the TD at the head of this ring's TD list */
+ if (list_empty(&ep_ring->td_list)) {
+ xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n",
+ TRB_TO_SLOT_ID(event->flags), ep_index);
+ xhci_dbg(xhci, "Event TRB with TRB type ID %u\n",
+ (unsigned int) (event->flags & TRB_TYPE_BITMASK)>>10);
+ xhci_print_trb_offsets(xhci, (union xhci_trb *) event);
+ urb = NULL;
+ goto cleanup;
+ }
+ td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list);
+
+ /* Is this a TRB in the currently executing TD? */
+ event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue,
+ td->last_trb, event_dma);
+ if (!event_seg) {
+ /* HC is busted, give up! */
+ xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not part of current TD\n");
+ return -ESHUTDOWN;
+ }
+ event_trb = &event_seg->trbs[(event_dma - event_seg->dma) / sizeof(*event_trb)];
+ xhci_dbg(xhci, "Event TRB with TRB type ID %u\n",
+ (unsigned int) (event->flags & TRB_TYPE_BITMASK)>>10);
+ xhci_dbg(xhci, "Offset 0x00 (buffer[0]) = 0x%x\n",
+ (unsigned int) event->buffer[0]);
+ xhci_dbg(xhci, "Offset 0x04 (buffer[0]) = 0x%x\n",
+ (unsigned int) event->buffer[1]);
+ xhci_dbg(xhci, "Offset 0x08 (transfer length) = 0x%x\n",
+ (unsigned int) event->transfer_len);
+ xhci_dbg(xhci, "Offset 0x0C (flags) = 0x%x\n",
+ (unsigned int) event->flags);
+
+ /* Look for common error cases */
+ switch (GET_COMP_CODE(event->transfer_len)) {
+ /* Skip codes that require special handling depending on
+ * transfer type
+ */
+ case COMP_SUCCESS:
+ case COMP_SHORT_TX:
+ break;
+ case COMP_STOP:
+ xhci_dbg(xhci, "Stopped on Transfer TRB\n");
+ break;
+ case COMP_STOP_INVAL:
+ xhci_dbg(xhci, "Stopped on No-op or Link TRB\n");
+ break;
+ case COMP_STALL:
+ xhci_warn(xhci, "WARN: Stalled endpoint\n");
+ status = -EPIPE;
+ break;
+ case COMP_TRB_ERR:
+ xhci_warn(xhci, "WARN: TRB error on endpoint\n");
+ status = -EILSEQ;
+ break;
+ case COMP_TX_ERR:
+ xhci_warn(xhci, "WARN: transfer error on endpoint\n");
+ status = -EPROTO;
+ break;
+ case COMP_DB_ERR:
+ xhci_warn(xhci, "WARN: HC couldn't access mem fast enough\n");
+ status = -ENOSR;
+ break;
+ default:
+ xhci_warn(xhci, "ERROR Unknown event condition, HC probably busted\n");
+ urb = NULL;
+ goto cleanup;
+ }
+ /* Now update the urb's actual_length and give back to the core */
+ /* Was this a control transfer? */
+ if (usb_endpoint_xfer_control(&td->urb->ep->desc)) {
+ xhci_debug_trb(xhci, xhci->event_ring->dequeue);
+ switch (GET_COMP_CODE(event->transfer_len)) {
+ case COMP_SUCCESS:
+ if (event_trb == ep_ring->dequeue) {
+ xhci_warn(xhci, "WARN: Success on ctrl setup TRB without IOC set??\n");
+ status = -ESHUTDOWN;
+ } else if (event_trb != td->last_trb) {
+ xhci_warn(xhci, "WARN: Success on ctrl data TRB without IOC set??\n");
+ status = -ESHUTDOWN;
+ } else {
+ xhci_dbg(xhci, "Successful control transfer!\n");
+ status = 0;
+ }
+ break;
+ case COMP_SHORT_TX:
+ xhci_warn(xhci, "WARN: short transfer on control ep\n");
+ status = -EREMOTEIO;
+ break;
+ default:
+ /* Others already handled above */
+ break;
+ }
+ /*
+ * Did we transfer any data, despite the errors that might have
+ * happened? I.e. did we get past the setup stage?
+ */
+ if (event_trb != ep_ring->dequeue) {
+ /* The event was for the status stage */
+ if (event_trb == td->last_trb) {
+ td->urb->actual_length =
+ td->urb->transfer_buffer_length;
+ } else {
+ /* Maybe the event was for the data stage? */
+ if (GET_COMP_CODE(event->transfer_len) != COMP_STOP_INVAL)
+ /* We didn't stop on a link TRB in the middle */
+ td->urb->actual_length =
+ td->urb->transfer_buffer_length -
+ TRB_LEN(event->transfer_len);
+ }
+ }
+ } else {
+ switch (GET_COMP_CODE(event->transfer_len)) {
+ case COMP_SUCCESS:
+ /* Double check that the HW transferred everything. */
+ if (event_trb != td->last_trb) {
+ xhci_warn(xhci, "WARN Successful completion "
+ "on short TX\n");
+ if (td->urb->transfer_flags & URB_SHORT_NOT_OK)
+ status = -EREMOTEIO;
+ else
+ status = 0;
+ } else {
+ xhci_dbg(xhci, "Successful bulk transfer!\n");
+ status = 0;
+ }
+ break;
+ case COMP_SHORT_TX:
+ if (td->urb->transfer_flags & URB_SHORT_NOT_OK)
+ status = -EREMOTEIO;
+ else
+ status = 0;
+ break;
+ default:
+ /* Others already handled above */
+ break;
+ }
+ dev_dbg(&td->urb->dev->dev,
+ "ep %#x - asked for %d bytes, "
+ "%d bytes untransferred\n",
+ td->urb->ep->desc.bEndpointAddress,
+ td->urb->transfer_buffer_length,
+ TRB_LEN(event->transfer_len));
+ /* Fast path - was this the last TRB in the TD for this URB? */
+ if (event_trb == td->last_trb) {
+ if (TRB_LEN(event->transfer_len) != 0) {
+ td->urb->actual_length =
+ td->urb->transfer_buffer_length -
+ TRB_LEN(event->transfer_len);
+ if (td->urb->actual_length < 0) {
+ xhci_warn(xhci, "HC gave bad length "
+ "of %d bytes left\n",
+ TRB_LEN(event->transfer_len));
+ td->urb->actual_length = 0;
+ }
+ if (td->urb->transfer_flags & URB_SHORT_NOT_OK)
+ status = -EREMOTEIO;
+ else
+ status = 0;
+ } else {
+ td->urb->actual_length = td->urb->transfer_buffer_length;
+ /* Ignore a short packet completion if the
+ * untransferred length was zero.
+ */
+ status = 0;
+ }
+ } else {
+ /* Slow path - walk the list, starting from the dequeue
+ * pointer, to get the actual length transferred.
+ */
+ union xhci_trb *cur_trb;
+ struct xhci_segment *cur_seg;
+
+ td->urb->actual_length = 0;
+ for (cur_trb = ep_ring->dequeue, cur_seg = ep_ring->deq_seg;
+ cur_trb != event_trb;
+ next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) {
+ if (TRB_TYPE(cur_trb->generic.field[3]) != TRB_TR_NOOP &&
+ TRB_TYPE(cur_trb->generic.field[3]) != TRB_LINK)
+ td->urb->actual_length +=
+ TRB_LEN(cur_trb->generic.field[2]);
+ }
+ /* If the ring didn't stop on a Link or No-op TRB, add
+ * in the actual bytes transferred from the Normal TRB
+ */
+ if (GET_COMP_CODE(event->transfer_len) != COMP_STOP_INVAL)
+ td->urb->actual_length +=
+ TRB_LEN(cur_trb->generic.field[2]) -
+ TRB_LEN(event->transfer_len);
+ }
+ }
+ /* The Endpoint Stop Command completion will take care of
+ * any stopped TDs. A stopped TD may be restarted, so don't update the
+ * ring dequeue pointer or take this TD off any lists yet.
+ */
+ if (GET_COMP_CODE(event->transfer_len) == COMP_STOP_INVAL ||
+ GET_COMP_CODE(event->transfer_len) == COMP_STOP) {
+ ep_ring->stopped_td = td;
+ ep_ring->stopped_trb = event_trb;
+ } else {
+ /* Update ring dequeue pointer */
+ while (ep_ring->dequeue != td->last_trb)
+ inc_deq(xhci, ep_ring, false);
+ inc_deq(xhci, ep_ring, false);
+
+ /* Clean up the endpoint's TD list */
+ urb = td->urb;
+ list_del(&td->td_list);
+ /* Was this TD slated to be cancelled but completed anyway? */
+ if (!list_empty(&td->cancelled_td_list)) {
+ list_del(&td->cancelled_td_list);
+ ep_ring->cancels_pending--;
+ }
+ kfree(td);
+ urb->hcpriv = NULL;
+ }
+cleanup:
+ inc_deq(xhci, xhci->event_ring, true);
+ xhci_set_hc_event_deq(xhci);
+
+ /* FIXME for multi-TD URBs (who have buffers bigger than 64MB) */
+ if (urb) {
+ usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), urb);
+ spin_unlock(&xhci->lock);
+ usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, status);
+ spin_lock(&xhci->lock);
+ }
+ return 0;
+}
+
+/*
+ * This function handles all OS-owned events on the event ring. It may drop
+ * xhci->lock between event processing (e.g. to pass up port status changes).
+ */
+void xhci_handle_event(struct xhci_hcd *xhci)
+{
+ union xhci_trb *event;
+ int update_ptrs = 1;
+ int ret;
+
+ if (!xhci->event_ring || !xhci->event_ring->dequeue) {
+ xhci->error_bitmask |= 1 << 1;
+ return;
+ }
+
+ event = xhci->event_ring->dequeue;
+ /* Does the HC or OS own the TRB? */
+ if ((event->event_cmd.flags & TRB_CYCLE) !=
+ xhci->event_ring->cycle_state) {
+ xhci->error_bitmask |= 1 << 2;
+ return;
+ }
+
+ /* FIXME: Handle more event types. */
+ switch ((event->event_cmd.flags & TRB_TYPE_BITMASK)) {
+ case TRB_TYPE(TRB_COMPLETION):
+ handle_cmd_completion(xhci, &event->event_cmd);
+ break;
+ case TRB_TYPE(TRB_PORT_STATUS):
+ handle_port_status(xhci, event);
+ update_ptrs = 0;
+ break;
+ case TRB_TYPE(TRB_TRANSFER):
+ ret = handle_tx_event(xhci, &event->trans_event);
+ if (ret < 0)
+ xhci->error_bitmask |= 1 << 9;
+ else
+ update_ptrs = 0;
+ break;
+ default:
+ xhci->error_bitmask |= 1 << 3;
+ }
+
+ if (update_ptrs) {
+ /* Update SW and HC event ring dequeue pointer */
+ inc_deq(xhci, xhci->event_ring, true);
+ xhci_set_hc_event_deq(xhci);
+ }
+ /* Are there more items on the event ring? */
+ xhci_handle_event(xhci);
+}
+
+/**** Endpoint Ring Operations ****/
+
+/*
+ * Generic function for queueing a TRB on a ring.
+ * The caller must have checked to make sure there's room on the ring.
+ */
+static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
+ bool consumer,
+ u32 field1, u32 field2, u32 field3, u32 field4)
+{
+ struct xhci_generic_trb *trb;
+
+ trb = &ring->enqueue->generic;
+ trb->field[0] = field1;
+ trb->field[1] = field2;
+ trb->field[2] = field3;
+ trb->field[3] = field4;
+ inc_enq(xhci, ring, consumer);
+}
+
+/*
+ * Does various checks on the endpoint ring, and makes it ready to queue num_trbs.
+ * FIXME allocate segments if the ring is full.
+ */
+static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
+ u32 ep_state, unsigned int num_trbs, gfp_t mem_flags)
+{
+ /* Make sure the endpoint has been added to xHC schedule */
+ xhci_dbg(xhci, "Endpoint state = 0x%x\n", ep_state);
+ switch (ep_state) {
+ case EP_STATE_DISABLED:
+ /*
+ * USB core changed config/interfaces without notifying us,
+ * or hardware is reporting the wrong state.
+ */
+ xhci_warn(xhci, "WARN urb submitted to disabled ep\n");
+ return -ENOENT;
+ case EP_STATE_HALTED:
+ case EP_STATE_ERROR:
+ xhci_warn(xhci, "WARN waiting for halt or error on ep "
+ "to be cleared\n");
+ /* FIXME event handling code for error needs to clear it */
+ /* XXX not sure if this should be -ENOENT or not */
+ return -EINVAL;
+ case EP_STATE_STOPPED:
+ case EP_STATE_RUNNING:
+ break;
+ default:
+ xhci_err(xhci, "ERROR unknown endpoint state for ep\n");
+ /*
+ * FIXME issue Configure Endpoint command to try to get the HC
+ * back into a known state.
+ */
+ return -EINVAL;
+ }
+ if (!room_on_ring(xhci, ep_ring, num_trbs)) {
+ /* FIXME allocate more room */
+ xhci_err(xhci, "ERROR no room on ep ring\n");
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+static int prepare_transfer(struct xhci_hcd *xhci,
+ struct xhci_virt_device *xdev,
+ unsigned int ep_index,
+ unsigned int num_trbs,
+ struct urb *urb,
+ struct xhci_td **td,
+ gfp_t mem_flags)
+{
+ int ret;
+
+ ret = prepare_ring(xhci, xdev->ep_rings[ep_index],
+ xdev->out_ctx->ep[ep_index].ep_info & EP_STATE_MASK,
+ num_trbs, mem_flags);
+ if (ret)
+ return ret;
+ *td = kzalloc(sizeof(struct xhci_td), mem_flags);
+ if (!*td)
+ return -ENOMEM;
+ INIT_LIST_HEAD(&(*td)->td_list);
+ INIT_LIST_HEAD(&(*td)->cancelled_td_list);
+
+ ret = usb_hcd_link_urb_to_ep(xhci_to_hcd(xhci), urb);
+ if (unlikely(ret)) {
+ kfree(*td);
+ return ret;
+ }
+
+ (*td)->urb = urb;
+ urb->hcpriv = (void *) (*td);
+ /* Add this TD to the tail of the endpoint ring's TD list */
+ list_add_tail(&(*td)->td_list, &xdev->ep_rings[ep_index]->td_list);
+ (*td)->start_seg = xdev->ep_rings[ep_index]->enq_seg;
+ (*td)->first_trb = xdev->ep_rings[ep_index]->enqueue;
+
+ return 0;
+}
+
+static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb)
+{
+ int num_sgs, num_trbs, running_total, temp, i;
+ struct scatterlist *sg;
+
+ sg = NULL;
+ num_sgs = urb->num_sgs;
+ temp = urb->transfer_buffer_length;
+
+ xhci_dbg(xhci, "count sg list trbs: \n");
+ num_trbs = 0;
+ for_each_sg(urb->sg->sg, sg, num_sgs, i) {
+ unsigned int previous_total_trbs = num_trbs;
+ unsigned int len = sg_dma_len(sg);
+
+ /* Scatter gather list entries may cross 64KB boundaries */
+ running_total = TRB_MAX_BUFF_SIZE -
+ (sg_dma_address(sg) & ((1 << TRB_MAX_BUFF_SHIFT) - 1));
+ if (running_total != 0)
+ num_trbs++;
+
+ /* How many more 64KB chunks to transfer, how many more TRBs? */
+ while (running_total < sg_dma_len(sg)) {
+ num_trbs++;
+ running_total += TRB_MAX_BUFF_SIZE;
+ }
+ xhci_dbg(xhci, " sg #%d: dma = %#llx, len = %#x (%d), num_trbs = %d\n",
+ i, (unsigned long long)sg_dma_address(sg),
+ len, len, num_trbs - previous_total_trbs);
+
+ len = min_t(int, len, temp);
+ temp -= len;
+ if (temp == 0)
+ break;
+ }
+ xhci_dbg(xhci, "\n");
+ if (!in_interrupt())
+ dev_dbg(&urb->dev->dev, "ep %#x - urb len = %d, sglist used, num_trbs = %d\n",
+ urb->ep->desc.bEndpointAddress,
+ urb->transfer_buffer_length,
+ num_trbs);
+ return num_trbs;
+}
+
+static void check_trb_math(struct urb *urb, int num_trbs, int running_total)
+{
+ if (num_trbs != 0)
+ dev_dbg(&urb->dev->dev, "%s - ep %#x - Miscalculated number of "
+ "TRBs, %d left\n", __func__,
+ urb->ep->desc.bEndpointAddress, num_trbs);
+ if (running_total != urb->transfer_buffer_length)
+ dev_dbg(&urb->dev->dev, "%s - ep %#x - Miscalculated tx length, "
+ "queued %#x (%d), asked for %#x (%d)\n",
+ __func__,
+ urb->ep->desc.bEndpointAddress,
+ running_total, running_total,
+ urb->transfer_buffer_length,
+ urb->transfer_buffer_length);
+}
+
+static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id,
+ unsigned int ep_index, int start_cycle,
+ struct xhci_generic_trb *start_trb, struct xhci_td *td)
+{
+ /*
+ * Pass all the TRBs to the hardware at once and make sure this write
+ * isn't reordered.
+ */
+ wmb();
+ start_trb->field[3] |= start_cycle;
+ ring_ep_doorbell(xhci, slot_id, ep_index);
+}
+
+static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
+ struct urb *urb, int slot_id, unsigned int ep_index)
+{
+ struct xhci_ring *ep_ring;
+ unsigned int num_trbs;
+ struct xhci_td *td;
+ struct scatterlist *sg;
+ int num_sgs;
+ int trb_buff_len, this_sg_len, running_total;
+ bool first_trb;
+ u64 addr;
+
+ struct xhci_generic_trb *start_trb;
+ int start_cycle;
+
+ ep_ring = xhci->devs[slot_id]->ep_rings[ep_index];
+ num_trbs = count_sg_trbs_needed(xhci, urb);
+ num_sgs = urb->num_sgs;
+
+ trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
+ ep_index, num_trbs, urb, &td, mem_flags);
+ if (trb_buff_len < 0)
+ return trb_buff_len;
+ /*
+ * Don't give the first TRB to the hardware (by toggling the cycle bit)
+ * until we've finished creating all the other TRBs. The ring's cycle
+ * state may change as we enqueue the other TRBs, so save it too.
+ */
+ start_trb = &ep_ring->enqueue->generic;
+ start_cycle = ep_ring->cycle_state;
+
+ running_total = 0;
+ /*
+ * How much data is in the first TRB?
+ *
+ * There are three forces at work for TRB buffer pointers and lengths:
+ * 1. We don't want to walk off the end of this sg-list entry buffer.
+ * 2. The transfer length that the driver requested may be smaller than
+ * the amount of memory allocated for this scatter-gather list.
+ * 3. TRBs buffers can't cross 64KB boundaries.
+ */
+ sg = urb->sg->sg;
+ addr = (u64) sg_dma_address(sg);
+ this_sg_len = sg_dma_len(sg);
+ trb_buff_len = TRB_MAX_BUFF_SIZE -
+ (addr & ((1 << TRB_MAX_BUFF_SHIFT) - 1));
+ trb_buff_len = min_t(int, trb_buff_len, this_sg_len);
+ if (trb_buff_len > urb->transfer_buffer_length)
+ trb_buff_len = urb->transfer_buffer_length;
+ xhci_dbg(xhci, "First length to xfer from 1st sglist entry = %u\n",
+ trb_buff_len);
+
+ first_trb = true;
+ /* Queue the first TRB, even if it's zero-length */
+ do {
+ u32 field = 0;
+
+ /* Don't change the cycle bit of the first TRB until later */
+ if (first_trb)
+ first_trb = false;
+ else
+ field |= ep_ring->cycle_state;
+
+ /* Chain all the TRBs together; clear the chain bit in the last
+ * TRB to indicate it's the last TRB in the chain.
+ */
+ if (num_trbs > 1) {
+ field |= TRB_CHAIN;
+ } else {
+ /* FIXME - add check for ZERO_PACKET flag before this */
+ td->last_trb = ep_ring->enqueue;
+ field |= TRB_IOC;
+ }
+ xhci_dbg(xhci, " sg entry: dma = %#x, len = %#x (%d), "
+ "64KB boundary at %#x, end dma = %#x\n",
+ (unsigned int) addr, trb_buff_len, trb_buff_len,
+ (unsigned int) (addr + TRB_MAX_BUFF_SIZE) & ~(TRB_MAX_BUFF_SIZE - 1),
+ (unsigned int) addr + trb_buff_len);
+ if (TRB_MAX_BUFF_SIZE -
+ (addr & ((1 << TRB_MAX_BUFF_SHIFT) - 1)) < trb_buff_len) {
+ xhci_warn(xhci, "WARN: sg dma xfer crosses 64KB boundaries!\n");
+ xhci_dbg(xhci, "Next boundary at %#x, end dma = %#x\n",
+ (unsigned int) (addr + TRB_MAX_BUFF_SIZE) & ~(TRB_MAX_BUFF_SIZE - 1),
+ (unsigned int) addr + trb_buff_len);
+ }
+ queue_trb(xhci, ep_ring, false,
+ (u32) addr,
+ (u32) ((u64) addr >> 32),
+ TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0),
+ /* We always want to know if the TRB was short,
+ * or we won't get an event when it completes.
+ * (Unless we use event data TRBs, which are a
+ * waste of space and HC resources.)
+ */
+ field | TRB_ISP | TRB_TYPE(TRB_NORMAL));
+ --num_trbs;
+ running_total += trb_buff_len;
+
+ /* Calculate length for next transfer --
+ * Are we done queueing all the TRBs for this sg entry?
+ */
+ this_sg_len -= trb_buff_len;
+ if (this_sg_len == 0) {
+ --num_sgs;
+ if (num_sgs == 0)
+ break;
+ sg = sg_next(sg);
+ addr = (u64) sg_dma_address(sg);
+ this_sg_len = sg_dma_len(sg);
+ } else {
+ addr += trb_buff_len;
+ }
+
+ trb_buff_len = TRB_MAX_BUFF_SIZE -
+ (addr & ((1 << TRB_MAX_BUFF_SHIFT) - 1));
+ trb_buff_len = min_t(int, trb_buff_len, this_sg_len);
+ if (running_total + trb_buff_len > urb->transfer_buffer_length)
+ trb_buff_len =
+ urb->transfer_buffer_length - running_total;
+ } while (running_total < urb->transfer_buffer_length);
+
+ check_trb_math(urb, num_trbs, running_total);
+ giveback_first_trb(xhci, slot_id, ep_index, start_cycle, start_trb, td);
+ return 0;
+}
+
+/* This is very similar to what ehci-q.c qtd_fill() does */
+int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
+ struct urb *urb, int slot_id, unsigned int ep_index)
+{
+ struct xhci_ring *ep_ring;
+ struct xhci_td *td;
+ int num_trbs;
+ struct xhci_generic_trb *start_trb;
+ bool first_trb;
+ int start_cycle;
+ u32 field;
+
+ int running_total, trb_buff_len, ret;
+ u64 addr;
+
+ if (urb->sg)
+ return queue_bulk_sg_tx(xhci, mem_flags, urb, slot_id, ep_index);
+
+ ep_ring = xhci->devs[slot_id]->ep_rings[ep_index];
+
+ num_trbs = 0;
+ /* How much data is (potentially) left before the 64KB boundary? */
+ running_total = TRB_MAX_BUFF_SIZE -
+ (urb->transfer_dma & ((1 << TRB_MAX_BUFF_SHIFT) - 1));
+
+ /* If there's some data on this 64KB chunk, or we have to send a
+ * zero-length transfer, we need at least one TRB
+ */
+ if (running_total != 0 || urb->transfer_buffer_length == 0)
+ num_trbs++;
+ /* How many more 64KB chunks to transfer, how many more TRBs? */
+ while (running_total < urb->transfer_buffer_length) {
+ num_trbs++;
+ running_total += TRB_MAX_BUFF_SIZE;
+ }
+ /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */
+
+ if (!in_interrupt())
+ dev_dbg(&urb->dev->dev, "ep %#x - urb len = %#x (%d), addr = %#llx, num_trbs = %d\n",
+ urb->ep->desc.bEndpointAddress,
+ urb->transfer_buffer_length,
+ urb->transfer_buffer_length,
+ (unsigned long long)urb->transfer_dma,
+ num_trbs);
+
+ ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index,
+ num_trbs, urb, &td, mem_flags);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * Don't give the first TRB to the hardware (by toggling the cycle bit)
+ * until we've finished creating all the other TRBs. The ring's cycle
+ * state may change as we enqueue the other TRBs, so save it too.
+ */
+ start_trb = &ep_ring->enqueue->generic;
+ start_cycle = ep_ring->cycle_state;
+
+ running_total = 0;
+ /* How much data is in the first TRB? */
+ addr = (u64) urb->transfer_dma;
+ trb_buff_len = TRB_MAX_BUFF_SIZE -
+ (urb->transfer_dma & ((1 << TRB_MAX_BUFF_SHIFT) - 1));
+ if (urb->transfer_buffer_length < trb_buff_len)
+ trb_buff_len = urb->transfer_buffer_length;
+
+ first_trb = true;
+
+ /* Queue the first TRB, even if it's zero-length */
+ do {
+ field = 0;
+
+ /* Don't change the cycle bit of the first TRB until later */
+ if (first_trb)
+ first_trb = false;
+ else
+ field |= ep_ring->cycle_state;
+
+ /* Chain all the TRBs together; clear the chain bit in the last
+ * TRB to indicate it's the last TRB in the chain.
+ */
+ if (num_trbs > 1) {
+ field |= TRB_CHAIN;
+ } else {
+ /* FIXME - add check for ZERO_PACKET flag before this */
+ td->last_trb = ep_ring->enqueue;
+ field |= TRB_IOC;
+ }
+ queue_trb(xhci, ep_ring, false,
+ (u32) addr,
+ (u32) ((u64) addr >> 32),
+ TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0),
+ /* We always want to know if the TRB was short,
+ * or we won't get an event when it completes.
+ * (Unless we use event data TRBs, which are a
+ * waste of space and HC resources.)
+ */
+ field | TRB_ISP | TRB_TYPE(TRB_NORMAL));
+ --num_trbs;
+ running_total += trb_buff_len;
+
+ /* Calculate length for next transfer */
+ addr += trb_buff_len;
+ trb_buff_len = urb->transfer_buffer_length - running_total;
+ if (trb_buff_len > TRB_MAX_BUFF_SIZE)
+ trb_buff_len = TRB_MAX_BUFF_SIZE;
+ } while (running_total < urb->transfer_buffer_length);
+
+ check_trb_math(urb, num_trbs, running_total);
+ giveback_first_trb(xhci, slot_id, ep_index, start_cycle, start_trb, td);
+ return 0;
+}
+
+/* Caller must have locked xhci->lock */
+int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
+ struct urb *urb, int slot_id, unsigned int ep_index)
+{
+ struct xhci_ring *ep_ring;
+ int num_trbs;
+ int ret;
+ struct usb_ctrlrequest *setup;
+ struct xhci_generic_trb *start_trb;
+ int start_cycle;
+ u32 field;
+ struct xhci_td *td;
+
+ ep_ring = xhci->devs[slot_id]->ep_rings[ep_index];
+
+ /*
+ * Need to copy setup packet into setup TRB, so we can't use the setup
+ * DMA address.
+ */
+ if (!urb->setup_packet)
+ return -EINVAL;
+
+ if (!in_interrupt())
+ xhci_dbg(xhci, "Queueing ctrl tx for slot id %d, ep %d\n",
+ slot_id, ep_index);
+ /* 1 TRB for setup, 1 for status */
+ num_trbs = 2;
+ /*
+ * Don't need to check if we need additional event data and normal TRBs,
+ * since data in control transfers will never get bigger than 16MB
+ * XXX: can we get a buffer that crosses 64KB boundaries?
+ */
+ if (urb->transfer_buffer_length > 0)
+ num_trbs++;
+ ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, num_trbs,
+ urb, &td, mem_flags);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * Don't give the first TRB to the hardware (by toggling the cycle bit)
+ * until we've finished creating all the other TRBs. The ring's cycle
+ * state may change as we enqueue the other TRBs, so save it too.
+ */
+ start_trb = &ep_ring->enqueue->generic;
+ start_cycle = ep_ring->cycle_state;
+
+ /* Queue setup TRB - see section 6.4.1.2.1 */
+ /* FIXME better way to translate setup_packet into two u32 fields? */
+ setup = (struct usb_ctrlrequest *) urb->setup_packet;
+ queue_trb(xhci, ep_ring, false,
+ /* FIXME endianness is probably going to bite my ass here. */
+ setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16,
+ setup->wIndex | setup->wLength << 16,
+ TRB_LEN(8) | TRB_INTR_TARGET(0),
+ /* Immediate data in pointer */
+ TRB_IDT | TRB_TYPE(TRB_SETUP));
+
+ /* If there's data, queue data TRBs */
+ field = 0;
+ if (urb->transfer_buffer_length > 0) {
+ if (setup->bRequestType & USB_DIR_IN)
+ field |= TRB_DIR_IN;
+ queue_trb(xhci, ep_ring, false,
+ lower_32_bits(urb->transfer_dma),
+ upper_32_bits(urb->transfer_dma),
+ TRB_LEN(urb->transfer_buffer_length) | TRB_INTR_TARGET(0),
+ /* Event on short tx */
+ field | TRB_ISP | TRB_TYPE(TRB_DATA) | ep_ring->cycle_state);
+ }
+
+ /* Save the DMA address of the last TRB in the TD */
+ td->last_trb = ep_ring->enqueue;
+
+ /* Queue status TRB - see Table 7 and sections 4.11.2.2 and 6.4.1.2.3 */
+ /* If the device sent data, the status stage is an OUT transfer */
+ if (urb->transfer_buffer_length > 0 && setup->bRequestType & USB_DIR_IN)
+ field = 0;
+ else
+ field = TRB_DIR_IN;
+ queue_trb(xhci, ep_ring, false,
+ 0,
+ 0,
+ TRB_INTR_TARGET(0),
+ /* Event on completion */
+ field | TRB_IOC | TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state);
+
+ giveback_first_trb(xhci, slot_id, ep_index, start_cycle, start_trb, td);
+ return 0;
+}
+
+/**** Command Ring Operations ****/
+
+/* Generic function for queueing a command TRB on the command ring */
+static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, u32 field3, u32 field4)
+{
+ if (!room_on_ring(xhci, xhci->cmd_ring, 1)) {
+ if (!in_interrupt())
+ xhci_err(xhci, "ERR: No room for command on command ring\n");
+ return -ENOMEM;
+ }
+ queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
+ field4 | xhci->cmd_ring->cycle_state);
+ return 0;
+}
+
+/* Queue a no-op command on the command ring */
+static int queue_cmd_noop(struct xhci_hcd *xhci)
+{
+ return queue_command(xhci, 0, 0, 0, TRB_TYPE(TRB_CMD_NOOP));
+}
+
+/*
+ * Place a no-op command on the command ring to test the command and
+ * event ring.
+ */
+void *xhci_setup_one_noop(struct xhci_hcd *xhci)
+{
+ if (queue_cmd_noop(xhci) < 0)
+ return NULL;
+ xhci->noops_submitted++;
+ return xhci_ring_cmd_db;
+}
+
+/* Queue a slot enable or disable request on the command ring */
+int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id)
+{
+ return queue_command(xhci, 0, 0, 0,
+ TRB_TYPE(trb_type) | SLOT_ID_FOR_TRB(slot_id));
+}
+
+/* Queue an address device command TRB */
+int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
+ u32 slot_id)
+{
+ return queue_command(xhci, in_ctx_ptr, 0, 0,
+ TRB_TYPE(TRB_ADDR_DEV) | SLOT_ID_FOR_TRB(slot_id));
+}
+
+/* Queue a configure endpoint command TRB */
+int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
+ u32 slot_id)
+{
+ return queue_command(xhci, in_ctx_ptr, 0, 0,
+ TRB_TYPE(TRB_CONFIG_EP) | SLOT_ID_FOR_TRB(slot_id));
+}
+
+int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
+ unsigned int ep_index)
+{
+ u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id);
+ u32 trb_ep_index = EP_ID_FOR_TRB(ep_index);
+ u32 type = TRB_TYPE(TRB_STOP_RING);
+
+ return queue_command(xhci, 0, 0, 0,
+ trb_slot_id | trb_ep_index | type);
+}
+
+/* Set Transfer Ring Dequeue Pointer command.
+ * This should not be used for endpoints that have streams enabled.
+ */
+static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id,
+ unsigned int ep_index, struct xhci_segment *deq_seg,
+ union xhci_trb *deq_ptr, u32 cycle_state)
+{
+ dma_addr_t addr;
+ u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id);
+ u32 trb_ep_index = EP_ID_FOR_TRB(ep_index);
+ u32 type = TRB_TYPE(TRB_SET_DEQ);
+
+ addr = xhci_trb_virt_to_dma(deq_seg, deq_ptr);
+ if (addr == 0)
+ xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr\n");
+ xhci_warn(xhci, "WARN deq seg = %p, deq pt = %p\n",
+ deq_seg, deq_ptr);
+ return queue_command(xhci, (u32) addr | cycle_state, 0, 0,
+ trb_slot_id | trb_ep_index | type);
+}
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
new file mode 100644
index 000000000000..df8778e1cfc6
--- /dev/null
+++ b/drivers/usb/host/xhci.h
@@ -0,0 +1,1155 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __LINUX_XHCI_HCD_H
+#define __LINUX_XHCI_HCD_H
+
+#include <linux/usb.h>
+#include <linux/timer.h>
+
+#include "../core/hcd.h"
+/* Code sharing between pci-quirks and xhci hcd */
+#include "xhci-ext-caps.h"
+
+/* xHCI PCI Configuration Registers */
+#define XHCI_SBRN_OFFSET (0x60)
+
+/* Max number of USB devices for any host controller - limit in section 6.1 */
+#define MAX_HC_SLOTS 256
+/* Section 5.3.3 - MaxPorts */
+#define MAX_HC_PORTS 127
+
+/*
+ * xHCI register interface.
+ * This corresponds to the eXtensible Host Controller Interface (xHCI)
+ * Revision 0.95 specification
+ *
+ * Registers should always be accessed with double word or quad word accesses.
+ *
+ * Some xHCI implementations may support 64-bit address pointers. Registers
+ * with 64-bit address pointers should be written to with dword accesses by
+ * writing the low dword first (ptr[0]), then the high dword (ptr[1]) second.
+ * xHCI implementations that do not support 64-bit address pointers will ignore
+ * the high dword, and write order is irrelevant.
+ */
+
+/**
+ * struct xhci_cap_regs - xHCI Host Controller Capability Registers.
+ * @hc_capbase: length of the capabilities register and HC version number
+ * @hcs_params1: HCSPARAMS1 - Structural Parameters 1
+ * @hcs_params2: HCSPARAMS2 - Structural Parameters 2
+ * @hcs_params3: HCSPARAMS3 - Structural Parameters 3
+ * @hcc_params: HCCPARAMS - Capability Parameters
+ * @db_off: DBOFF - Doorbell array offset
+ * @run_regs_off: RTSOFF - Runtime register space offset
+ */
+struct xhci_cap_regs {
+ u32 hc_capbase;
+ u32 hcs_params1;
+ u32 hcs_params2;
+ u32 hcs_params3;
+ u32 hcc_params;
+ u32 db_off;
+ u32 run_regs_off;
+ /* Reserved up to (CAPLENGTH - 0x1C) */
+} __attribute__ ((packed));
+
+/* hc_capbase bitmasks */
+/* bits 7:0 - how long is the Capabilities register */
+#define HC_LENGTH(p) XHCI_HC_LENGTH(p)
+/* bits 31:16 */
+#define HC_VERSION(p) (((p) >> 16) & 0xffff)
+
+/* HCSPARAMS1 - hcs_params1 - bitmasks */
+/* bits 0:7, Max Device Slots */
+#define HCS_MAX_SLOTS(p) (((p) >> 0) & 0xff)
+#define HCS_SLOTS_MASK 0xff
+/* bits 8:18, Max Interrupters */
+#define HCS_MAX_INTRS(p) (((p) >> 8) & 0x7ff)
+/* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
+#define HCS_MAX_PORTS(p) (((p) >> 24) & 0x7f)
+
+/* HCSPARAMS2 - hcs_params2 - bitmasks */
+/* bits 0:3, frames or uframes that SW needs to queue transactions
+ * ahead of the HW to meet periodic deadlines */
+#define HCS_IST(p) (((p) >> 0) & 0xf)
+/* bits 4:7, max number of Event Ring segments */
+#define HCS_ERST_MAX(p) (((p) >> 4) & 0xf)
+/* bit 26 Scratchpad restore - for save/restore HW state - not used yet */
+/* bits 27:31 number of Scratchpad buffers SW must allocate for the HW */
+
+/* HCSPARAMS3 - hcs_params3 - bitmasks */
+/* bits 0:7, Max U1 to U0 latency for the roothub ports */
+#define HCS_U1_LATENCY(p) (((p) >> 0) & 0xff)
+/* bits 16:31, Max U2 to U0 latency for the roothub ports */
+#define HCS_U2_LATENCY(p) (((p) >> 16) & 0xffff)
+
+/* HCCPARAMS - hcc_params - bitmasks */
+/* true: HC can use 64-bit address pointers */
+#define HCC_64BIT_ADDR(p) ((p) & (1 << 0))
+/* true: HC can do bandwidth negotiation */
+#define HCC_BANDWIDTH_NEG(p) ((p) & (1 << 1))
+/* true: HC uses 64-byte Device Context structures
+ * FIXME 64-byte context structures aren't supported yet.
+ */
+#define HCC_64BYTE_CONTEXT(p) ((p) & (1 << 2))
+/* true: HC has port power switches */
+#define HCC_PPC(p) ((p) & (1 << 3))
+/* true: HC has port indicators */
+#define HCS_INDICATOR(p) ((p) & (1 << 4))
+/* true: HC has Light HC Reset Capability */
+#define HCC_LIGHT_RESET(p) ((p) & (1 << 5))
+/* true: HC supports latency tolerance messaging */
+#define HCC_LTC(p) ((p) & (1 << 6))
+/* true: no secondary Stream ID Support */
+#define HCC_NSS(p) ((p) & (1 << 7))
+/* Max size for Primary Stream Arrays - 2^(n+1), where n is bits 12:15 */
+#define HCC_MAX_PSA (1 << ((((p) >> 12) & 0xf) + 1))
+/* Extended Capabilities pointer from PCI base - section 5.3.6 */
+#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p)
+
+/* db_off bitmask - bits 0:1 reserved */
+#define DBOFF_MASK (~0x3)
+
+/* run_regs_off bitmask - bits 0:4 reserved */
+#define RTSOFF_MASK (~0x1f)
+
+
+/* Number of registers per port */
+#define NUM_PORT_REGS 4
+
+/**
+ * struct xhci_op_regs - xHCI Host Controller Operational Registers.
+ * @command: USBCMD - xHC command register
+ * @status: USBSTS - xHC status register
+ * @page_size: This indicates the page size that the host controller
+ * supports. If bit n is set, the HC supports a page size
+ * of 2^(n+12), up to a 128MB page size.
+ * 4K is the minimum page size.
+ * @cmd_ring: CRP - 64-bit Command Ring Pointer
+ * @dcbaa_ptr: DCBAAP - 64-bit Device Context Base Address Array Pointer
+ * @config_reg: CONFIG - Configure Register
+ * @port_status_base: PORTSCn - base address for Port Status and Control
+ * Each port has a Port Status and Control register,
+ * followed by a Port Power Management Status and Control
+ * register, a Port Link Info register, and a reserved
+ * register.
+ * @port_power_base: PORTPMSCn - base address for
+ * Port Power Management Status and Control
+ * @port_link_base: PORTLIn - base address for Port Link Info (current
+ * Link PM state and control) for USB 2.1 and USB 3.0
+ * devices.
+ */
+struct xhci_op_regs {
+ u32 command;
+ u32 status;
+ u32 page_size;
+ u32 reserved1;
+ u32 reserved2;
+ u32 dev_notification;
+ u32 cmd_ring[2];
+ /* rsvd: offset 0x20-2F */
+ u32 reserved3[4];
+ u32 dcbaa_ptr[2];
+ u32 config_reg;
+ /* rsvd: offset 0x3C-3FF */
+ u32 reserved4[241];
+ /* port 1 registers, which serve as a base address for other ports */
+ u32 port_status_base;
+ u32 port_power_base;
+ u32 port_link_base;
+ u32 reserved5;
+ /* registers for ports 2-255 */
+ u32 reserved6[NUM_PORT_REGS*254];
+} __attribute__ ((packed));
+
+/* USBCMD - USB command - command bitmasks */
+/* start/stop HC execution - do not write unless HC is halted*/
+#define CMD_RUN XHCI_CMD_RUN
+/* Reset HC - resets internal HC state machine and all registers (except
+ * PCI config regs). HC does NOT drive a USB reset on the downstream ports.
+ * The xHCI driver must reinitialize the xHC after setting this bit.
+ */
+#define CMD_RESET (1 << 1)
+/* Event Interrupt Enable - a '1' allows interrupts from the host controller */
+#define CMD_EIE XHCI_CMD_EIE
+/* Host System Error Interrupt Enable - get out-of-band signal for HC errors */
+#define CMD_HSEIE XHCI_CMD_HSEIE
+/* bits 4:6 are reserved (and should be preserved on writes). */
+/* light reset (port status stays unchanged) - reset completed when this is 0 */
+#define CMD_LRESET (1 << 7)
+/* FIXME: ignoring host controller save/restore state for now. */
+#define CMD_CSS (1 << 8)
+#define CMD_CRS (1 << 9)
+/* Enable Wrap Event - '1' means xHC generates an event when MFINDEX wraps. */
+#define CMD_EWE XHCI_CMD_EWE
+/* MFINDEX power management - '1' means xHC can stop MFINDEX counter if all root
+ * hubs are in U3 (selective suspend), disconnect, disabled, or powered-off.
+ * '0' means the xHC can power it off if all ports are in the disconnect,
+ * disabled, or powered-off state.
+ */
+#define CMD_PM_INDEX (1 << 11)
+/* bits 12:31 are reserved (and should be preserved on writes). */
+
+/* USBSTS - USB status - status bitmasks */
+/* HC not running - set to 1 when run/stop bit is cleared. */
+#define STS_HALT XHCI_STS_HALT
+/* serious error, e.g. PCI parity error. The HC will clear the run/stop bit. */
+#define STS_FATAL (1 << 2)
+/* event interrupt - clear this prior to clearing any IP flags in IR set*/
+#define STS_EINT (1 << 3)
+/* port change detect */
+#define STS_PORT (1 << 4)
+/* bits 5:7 reserved and zeroed */
+/* save state status - '1' means xHC is saving state */
+#define STS_SAVE (1 << 8)
+/* restore state status - '1' means xHC is restoring state */
+#define STS_RESTORE (1 << 9)
+/* true: save or restore error */
+#define STS_SRE (1 << 10)
+/* true: Controller Not Ready to accept doorbell or op reg writes after reset */
+#define STS_CNR XHCI_STS_CNR
+/* true: internal Host Controller Error - SW needs to reset and reinitialize */
+#define STS_HCE (1 << 12)
+/* bits 13:31 reserved and should be preserved */
+
+/*
+ * DNCTRL - Device Notification Control Register - dev_notification bitmasks
+ * Generate a device notification event when the HC sees a transaction with a
+ * notification type that matches a bit set in this bit field.
+ */
+#define DEV_NOTE_MASK (0xffff)
+#define ENABLE_DEV_NOTE(x) (1 << x)
+/* Most of the device notification types should only be used for debug.
+ * SW does need to pay attention to function wake notifications.
+ */
+#define DEV_NOTE_FWAKE ENABLE_DEV_NOTE(1)
+
+/* CRCR - Command Ring Control Register - cmd_ring bitmasks */
+/* bit 0 is the command ring cycle state */
+/* stop ring operation after completion of the currently executing command */
+#define CMD_RING_PAUSE (1 << 1)
+/* stop ring immediately - abort the currently executing command */
+#define CMD_RING_ABORT (1 << 2)
+/* true: command ring is running */
+#define CMD_RING_RUNNING (1 << 3)
+/* bits 4:5 reserved and should be preserved */
+/* Command Ring pointer - bit mask for the lower 32 bits. */
+#define CMD_RING_ADDR_MASK (0xffffffc0)
+
+/* CONFIG - Configure Register - config_reg bitmasks */
+/* bits 0:7 - maximum number of device slots enabled (NumSlotsEn) */
+#define MAX_DEVS(p) ((p) & 0xff)
+/* bits 8:31 - reserved and should be preserved */
+
+/* PORTSC - Port Status and Control Register - port_status_base bitmasks */
+/* true: device connected */
+#define PORT_CONNECT (1 << 0)
+/* true: port enabled */
+#define PORT_PE (1 << 1)
+/* bit 2 reserved and zeroed */
+/* true: port has an over-current condition */
+#define PORT_OC (1 << 3)
+/* true: port reset signaling asserted */
+#define PORT_RESET (1 << 4)
+/* Port Link State - bits 5:8
+ * A read gives the current link PM state of the port,
+ * a write with Link State Write Strobe set sets the link state.
+ */
+/* true: port has power (see HCC_PPC) */
+#define PORT_POWER (1 << 9)
+/* bits 10:13 indicate device speed:
+ * 0 - undefined speed - port hasn't be initialized by a reset yet
+ * 1 - full speed
+ * 2 - low speed
+ * 3 - high speed
+ * 4 - super speed
+ * 5-15 reserved
+ */
+#define DEV_SPEED_MASK (0xf << 10)
+#define XDEV_FS (0x1 << 10)
+#define XDEV_LS (0x2 << 10)
+#define XDEV_HS (0x3 << 10)
+#define XDEV_SS (0x4 << 10)
+#define DEV_UNDEFSPEED(p) (((p) & DEV_SPEED_MASK) == (0x0<<10))
+#define DEV_FULLSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_FS)
+#define DEV_LOWSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_LS)
+#define DEV_HIGHSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_HS)
+#define DEV_SUPERSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_SS)
+/* Bits 20:23 in the Slot Context are the speed for the device */
+#define SLOT_SPEED_FS (XDEV_FS << 10)
+#define SLOT_SPEED_LS (XDEV_LS << 10)
+#define SLOT_SPEED_HS (XDEV_HS << 10)
+#define SLOT_SPEED_SS (XDEV_SS << 10)
+/* Port Indicator Control */
+#define PORT_LED_OFF (0 << 14)
+#define PORT_LED_AMBER (1 << 14)
+#define PORT_LED_GREEN (2 << 14)
+#define PORT_LED_MASK (3 << 14)
+/* Port Link State Write Strobe - set this when changing link state */
+#define PORT_LINK_STROBE (1 << 16)
+/* true: connect status change */
+#define PORT_CSC (1 << 17)
+/* true: port enable change */
+#define PORT_PEC (1 << 18)
+/* true: warm reset for a USB 3.0 device is done. A "hot" reset puts the port
+ * into an enabled state, and the device into the default state. A "warm" reset
+ * also resets the link, forcing the device through the link training sequence.
+ * SW can also look at the Port Reset register to see when warm reset is done.
+ */
+#define PORT_WRC (1 << 19)
+/* true: over-current change */
+#define PORT_OCC (1 << 20)
+/* true: reset change - 1 to 0 transition of PORT_RESET */
+#define PORT_RC (1 << 21)
+/* port link status change - set on some port link state transitions:
+ * Transition Reason
+ * ------------------------------------------------------------------------------
+ * - U3 to Resume Wakeup signaling from a device
+ * - Resume to Recovery to U0 USB 3.0 device resume
+ * - Resume to U0 USB 2.0 device resume
+ * - U3 to Recovery to U0 Software resume of USB 3.0 device complete
+ * - U3 to U0 Software resume of USB 2.0 device complete
+ * - U2 to U0 L1 resume of USB 2.1 device complete
+ * - U0 to U0 (???) L1 entry rejection by USB 2.1 device
+ * - U0 to disabled L1 entry error with USB 2.1 device
+ * - Any state to inactive Error on USB 3.0 port
+ */
+#define PORT_PLC (1 << 22)
+/* port configure error change - port failed to configure its link partner */
+#define PORT_CEC (1 << 23)
+/* bit 24 reserved */
+/* wake on connect (enable) */
+#define PORT_WKCONN_E (1 << 25)
+/* wake on disconnect (enable) */
+#define PORT_WKDISC_E (1 << 26)
+/* wake on over-current (enable) */
+#define PORT_WKOC_E (1 << 27)
+/* bits 28:29 reserved */
+/* true: device is removable - for USB 3.0 roothub emulation */
+#define PORT_DEV_REMOVE (1 << 30)
+/* Initiate a warm port reset - complete when PORT_WRC is '1' */
+#define PORT_WR (1 << 31)
+
+/* Port Power Management Status and Control - port_power_base bitmasks */
+/* Inactivity timer value for transitions into U1, in microseconds.
+ * Timeout can be up to 127us. 0xFF means an infinite timeout.
+ */
+#define PORT_U1_TIMEOUT(p) ((p) & 0xff)
+/* Inactivity timer value for transitions into U2 */
+#define PORT_U2_TIMEOUT(p) (((p) & 0xff) << 8)
+/* Bits 24:31 for port testing */
+
+
+/**
+ * struct intr_reg - Interrupt Register Set
+ * @irq_pending: IMAN - Interrupt Management Register. Used to enable
+ * interrupts and check for pending interrupts.
+ * @irq_control: IMOD - Interrupt Moderation Register.
+ * Used to throttle interrupts.
+ * @erst_size: Number of segments in the Event Ring Segment Table (ERST).
+ * @erst_base: ERST base address.
+ * @erst_dequeue: Event ring dequeue pointer.
+ *
+ * Each interrupter (defined by a MSI-X vector) has an event ring and an Event
+ * Ring Segment Table (ERST) associated with it. The event ring is comprised of
+ * multiple segments of the same size. The HC places events on the ring and
+ * "updates the Cycle bit in the TRBs to indicate to software the current
+ * position of the Enqueue Pointer." The HCD (Linux) processes those events and
+ * updates the dequeue pointer.
+ */
+struct intr_reg {
+ u32 irq_pending;
+ u32 irq_control;
+ u32 erst_size;
+ u32 rsvd;
+ u32 erst_base[2];
+ u32 erst_dequeue[2];
+} __attribute__ ((packed));
+
+/* irq_pending bitmasks */
+#define ER_IRQ_PENDING(p) ((p) & 0x1)
+/* bits 2:31 need to be preserved */
+/* THIS IS BUGGY - FIXME - IP IS WRITE 1 TO CLEAR */
+#define ER_IRQ_CLEAR(p) ((p) & 0xfffffffe)
+#define ER_IRQ_ENABLE(p) ((ER_IRQ_CLEAR(p)) | 0x2)
+#define ER_IRQ_DISABLE(p) ((ER_IRQ_CLEAR(p)) & ~(0x2))
+
+/* irq_control bitmasks */
+/* Minimum interval between interrupts (in 250ns intervals). The interval
+ * between interrupts will be longer if there are no events on the event ring.
+ * Default is 4000 (1 ms).
+ */
+#define ER_IRQ_INTERVAL_MASK (0xffff)
+/* Counter used to count down the time to the next interrupt - HW use only */
+#define ER_IRQ_COUNTER_MASK (0xffff << 16)
+
+/* erst_size bitmasks */
+/* Preserve bits 16:31 of erst_size */
+#define ERST_SIZE_MASK (0xffff << 16)
+
+/* erst_dequeue bitmasks */
+/* Dequeue ERST Segment Index (DESI) - Segment number (or alias)
+ * where the current dequeue pointer lies. This is an optional HW hint.
+ */
+#define ERST_DESI_MASK (0x7)
+/* Event Handler Busy (EHB) - is the event ring scheduled to be serviced by
+ * a work queue (or delayed service routine)?
+ */
+#define ERST_EHB (1 << 3)
+#define ERST_PTR_MASK (0xf)
+
+/**
+ * struct xhci_run_regs
+ * @microframe_index:
+ * MFINDEX - current microframe number
+ *
+ * Section 5.5 Host Controller Runtime Registers:
+ * "Software should read and write these registers using only Dword (32 bit)
+ * or larger accesses"
+ */
+struct xhci_run_regs {
+ u32 microframe_index;
+ u32 rsvd[7];
+ struct intr_reg ir_set[128];
+} __attribute__ ((packed));
+
+/**
+ * struct doorbell_array
+ *
+ * Section 5.6
+ */
+struct xhci_doorbell_array {
+ u32 doorbell[256];
+} __attribute__ ((packed));
+
+#define DB_TARGET_MASK 0xFFFFFF00
+#define DB_STREAM_ID_MASK 0x0000FFFF
+#define DB_TARGET_HOST 0x0
+#define DB_STREAM_ID_HOST 0x0
+#define DB_MASK (0xff << 8)
+
+/* Endpoint Target - bits 0:7 */
+#define EPI_TO_DB(p) (((p) + 1) & 0xff)
+
+
+/**
+ * struct xhci_slot_ctx
+ * @dev_info: Route string, device speed, hub info, and last valid endpoint
+ * @dev_info2: Max exit latency for device number, root hub port number
+ * @tt_info: tt_info is used to construct split transaction tokens
+ * @dev_state: slot state and device address
+ *
+ * Slot Context - section 6.2.1.1. This assumes the HC uses 32-byte context
+ * structures. If the HC uses 64-byte contexts, there is an additional 32 bytes
+ * reserved at the end of the slot context for HC internal use.
+ */
+struct xhci_slot_ctx {
+ u32 dev_info;
+ u32 dev_info2;
+ u32 tt_info;
+ u32 dev_state;
+ /* offset 0x10 to 0x1f reserved for HC internal use */
+ u32 reserved[4];
+} __attribute__ ((packed));
+
+/* dev_info bitmasks */
+/* Route String - 0:19 */
+#define ROUTE_STRING_MASK (0xfffff)
+/* Device speed - values defined by PORTSC Device Speed field - 20:23 */
+#define DEV_SPEED (0xf << 20)
+/* bit 24 reserved */
+/* Is this LS/FS device connected through a HS hub? - bit 25 */
+#define DEV_MTT (0x1 << 25)
+/* Set if the device is a hub - bit 26 */
+#define DEV_HUB (0x1 << 26)
+/* Index of the last valid endpoint context in this device context - 27:31 */
+#define LAST_CTX_MASK (0x1f << 27)
+#define LAST_CTX(p) ((p) << 27)
+#define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1)
+#define SLOT_FLAG (1 << 0)
+#define EP0_FLAG (1 << 1)
+
+/* dev_info2 bitmasks */
+/* Max Exit Latency (ms) - worst case time to wake up all links in dev path */
+#define MAX_EXIT (0xffff)
+/* Root hub port number that is needed to access the USB device */
+#define ROOT_HUB_PORT(p) (((p) & 0xff) << 16)
+
+/* tt_info bitmasks */
+/*
+ * TT Hub Slot ID - for low or full speed devices attached to a high-speed hub
+ * The Slot ID of the hub that isolates the high speed signaling from
+ * this low or full-speed device. '0' if attached to root hub port.
+ */
+#define TT_SLOT (0xff)
+/*
+ * The number of the downstream facing port of the high-speed hub
+ * '0' if the device is not low or full speed.
+ */
+#define TT_PORT (0xff << 8)
+
+/* dev_state bitmasks */
+/* USB device address - assigned by the HC */
+#define DEV_ADDR_MASK (0xff)
+/* bits 8:26 reserved */
+/* Slot state */
+#define SLOT_STATE (0x1f << 27)
+#define GET_SLOT_STATE(p) (((p) & (0x1f << 27)) >> 27)
+
+
+/**
+ * struct xhci_ep_ctx
+ * @ep_info: endpoint state, streams, mult, and interval information.
+ * @ep_info2: information on endpoint type, max packet size, max burst size,
+ * error count, and whether the HC will force an event for all
+ * transactions.
+ * @deq: 64-bit ring dequeue pointer address. If the endpoint only
+ * defines one stream, this points to the endpoint transfer ring.
+ * Otherwise, it points to a stream context array, which has a
+ * ring pointer for each flow.
+ * @tx_info:
+ * Average TRB lengths for the endpoint ring and
+ * max payload within an Endpoint Service Interval Time (ESIT).
+ *
+ * Endpoint Context - section 6.2.1.2. This assumes the HC uses 32-byte context
+ * structures. If the HC uses 64-byte contexts, there is an additional 32 bytes
+ * reserved at the end of the endpoint context for HC internal use.
+ */
+struct xhci_ep_ctx {
+ u32 ep_info;
+ u32 ep_info2;
+ u32 deq[2];
+ u32 tx_info;
+ /* offset 0x14 - 0x1f reserved for HC internal use */
+ u32 reserved[3];
+} __attribute__ ((packed));
+
+/* ep_info bitmasks */
+/*
+ * Endpoint State - bits 0:2
+ * 0 - disabled
+ * 1 - running
+ * 2 - halted due to halt condition - ok to manipulate endpoint ring
+ * 3 - stopped
+ * 4 - TRB error
+ * 5-7 - reserved
+ */
+#define EP_STATE_MASK (0xf)
+#define EP_STATE_DISABLED 0
+#define EP_STATE_RUNNING 1
+#define EP_STATE_HALTED 2
+#define EP_STATE_STOPPED 3
+#define EP_STATE_ERROR 4
+/* Mult - Max number of burtst within an interval, in EP companion desc. */
+#define EP_MULT(p) ((p & 0x3) << 8)
+/* bits 10:14 are Max Primary Streams */
+/* bit 15 is Linear Stream Array */
+/* Interval - period between requests to an endpoint - 125u increments. */
+#define EP_INTERVAL(p) ((p & 0xff) << 16)
+
+/* ep_info2 bitmasks */
+/*
+ * Force Event - generate transfer events for all TRBs for this endpoint
+ * This will tell the HC to ignore the IOC and ISP flags (for debugging only).
+ */
+#define FORCE_EVENT (0x1)
+#define ERROR_COUNT(p) (((p) & 0x3) << 1)
+#define EP_TYPE(p) ((p) << 3)
+#define ISOC_OUT_EP 1
+#define BULK_OUT_EP 2
+#define INT_OUT_EP 3
+#define CTRL_EP 4
+#define ISOC_IN_EP 5
+#define BULK_IN_EP 6
+#define INT_IN_EP 7
+/* bit 6 reserved */
+/* bit 7 is Host Initiate Disable - for disabling stream selection */
+#define MAX_BURST(p) (((p)&0xff) << 8)
+#define MAX_PACKET(p) (((p)&0xffff) << 16)
+
+
+/**
+ * struct xhci_device_control
+ * Input/Output context; see section 6.2.5.
+ *
+ * @drop_context: set the bit of the endpoint context you want to disable
+ * @add_context: set the bit of the endpoint context you want to enable
+ */
+struct xhci_device_control {
+ u32 drop_flags;
+ u32 add_flags;
+ u32 rsvd[6];
+ struct xhci_slot_ctx slot;
+ struct xhci_ep_ctx ep[31];
+} __attribute__ ((packed));
+
+/* drop context bitmasks */
+#define DROP_EP(x) (0x1 << x)
+/* add context bitmasks */
+#define ADD_EP(x) (0x1 << x)
+
+
+struct xhci_virt_device {
+ /*
+ * Commands to the hardware are passed an "input context" that
+ * tells the hardware what to change in its data structures.
+ * The hardware will return changes in an "output context" that
+ * software must allocate for the hardware. We need to keep
+ * track of input and output contexts separately because
+ * these commands might fail and we don't trust the hardware.
+ */
+ struct xhci_device_control *out_ctx;
+ dma_addr_t out_ctx_dma;
+ /* Used for addressing devices and configuration changes */
+ struct xhci_device_control *in_ctx;
+ dma_addr_t in_ctx_dma;
+ /* FIXME when stream support is added */
+ struct xhci_ring *ep_rings[31];
+ /* Temporary storage in case the configure endpoint command fails and we
+ * have to restore the device state to the previous state
+ */
+ struct xhci_ring *new_ep_rings[31];
+ struct completion cmd_completion;
+ /* Status of the last command issued for this device */
+ u32 cmd_status;
+};
+
+
+/**
+ * struct xhci_device_context_array
+ * @dev_context_ptr array of 64-bit DMA addresses for device contexts
+ */
+struct xhci_device_context_array {
+ /* 64-bit device addresses; we only write 32-bit addresses */
+ u32 dev_context_ptrs[2*MAX_HC_SLOTS];
+ /* private xHCD pointers */
+ dma_addr_t dma;
+} __attribute__ ((packed));
+/* TODO: write function to set the 64-bit device DMA address */
+/*
+ * TODO: change this to be dynamically sized at HC mem init time since the HC
+ * might not be able to handle the maximum number of devices possible.
+ */
+
+
+struct xhci_stream_ctx {
+ /* 64-bit stream ring address, cycle state, and stream type */
+ u32 stream_ring[2];
+ /* offset 0x14 - 0x1f reserved for HC internal use */
+ u32 reserved[2];
+} __attribute__ ((packed));
+
+
+struct xhci_transfer_event {
+ /* 64-bit buffer address, or immediate data */
+ u32 buffer[2];
+ u32 transfer_len;
+ /* This field is interpreted differently based on the type of TRB */
+ u32 flags;
+} __attribute__ ((packed));
+
+/** Transfer Event bit fields **/
+#define TRB_TO_EP_ID(p) (((p) >> 16) & 0x1f)
+
+/* Completion Code - only applicable for some types of TRBs */
+#define COMP_CODE_MASK (0xff << 24)
+#define GET_COMP_CODE(p) (((p) & COMP_CODE_MASK) >> 24)
+#define COMP_SUCCESS 1
+/* Data Buffer Error */
+#define COMP_DB_ERR 2
+/* Babble Detected Error */
+#define COMP_BABBLE 3
+/* USB Transaction Error */
+#define COMP_TX_ERR 4
+/* TRB Error - some TRB field is invalid */
+#define COMP_TRB_ERR 5
+/* Stall Error - USB device is stalled */
+#define COMP_STALL 6
+/* Resource Error - HC doesn't have memory for that device configuration */
+#define COMP_ENOMEM 7
+/* Bandwidth Error - not enough room in schedule for this dev config */
+#define COMP_BW_ERR 8
+/* No Slots Available Error - HC ran out of device slots */
+#define COMP_ENOSLOTS 9
+/* Invalid Stream Type Error */
+#define COMP_STREAM_ERR 10
+/* Slot Not Enabled Error - doorbell rung for disabled device slot */
+#define COMP_EBADSLT 11
+/* Endpoint Not Enabled Error */
+#define COMP_EBADEP 12
+/* Short Packet */
+#define COMP_SHORT_TX 13
+/* Ring Underrun - doorbell rung for an empty isoc OUT ep ring */
+#define COMP_UNDERRUN 14
+/* Ring Overrun - isoc IN ep ring is empty when ep is scheduled to RX */
+#define COMP_OVERRUN 15
+/* Virtual Function Event Ring Full Error */
+#define COMP_VF_FULL 16
+/* Parameter Error - Context parameter is invalid */
+#define COMP_EINVAL 17
+/* Bandwidth Overrun Error - isoc ep exceeded its allocated bandwidth */
+#define COMP_BW_OVER 18
+/* Context State Error - illegal context state transition requested */
+#define COMP_CTX_STATE 19
+/* No Ping Response Error - HC didn't get PING_RESPONSE in time to TX */
+#define COMP_PING_ERR 20
+/* Event Ring is full */
+#define COMP_ER_FULL 21
+/* Missed Service Error - HC couldn't service an isoc ep within interval */
+#define COMP_MISSED_INT 23
+/* Successfully stopped command ring */
+#define COMP_CMD_STOP 24
+/* Successfully aborted current command and stopped command ring */
+#define COMP_CMD_ABORT 25
+/* Stopped - transfer was terminated by a stop endpoint command */
+#define COMP_STOP 26
+/* Same as COMP_EP_STOPPED, but the transfered length in the event is invalid */
+#define COMP_STOP_INVAL 27
+/* Control Abort Error - Debug Capability - control pipe aborted */
+#define COMP_DBG_ABORT 28
+/* TRB type 29 and 30 reserved */
+/* Isoc Buffer Overrun - an isoc IN ep sent more data than could fit in TD */
+#define COMP_BUFF_OVER 31
+/* Event Lost Error - xHC has an "internal event overrun condition" */
+#define COMP_ISSUES 32
+/* Undefined Error - reported when other error codes don't apply */
+#define COMP_UNKNOWN 33
+/* Invalid Stream ID Error */
+#define COMP_STRID_ERR 34
+/* Secondary Bandwidth Error - may be returned by a Configure Endpoint cmd */
+/* FIXME - check for this */
+#define COMP_2ND_BW_ERR 35
+/* Split Transaction Error */
+#define COMP_SPLIT_ERR 36
+
+struct xhci_link_trb {
+ /* 64-bit segment pointer*/
+ u32 segment_ptr[2];
+ u32 intr_target;
+ u32 control;
+} __attribute__ ((packed));
+
+/* control bitfields */
+#define LINK_TOGGLE (0x1<<1)
+
+/* Command completion event TRB */
+struct xhci_event_cmd {
+ /* Pointer to command TRB, or the value passed by the event data trb */
+ u32 cmd_trb[2];
+ u32 status;
+ u32 flags;
+} __attribute__ ((packed));
+
+/* flags bitmasks */
+/* bits 16:23 are the virtual function ID */
+/* bits 24:31 are the slot ID */
+#define TRB_TO_SLOT_ID(p) (((p) & (0xff<<24)) >> 24)
+#define SLOT_ID_FOR_TRB(p) (((p) & 0xff) << 24)
+
+/* Stop Endpoint TRB - ep_index to endpoint ID for this TRB */
+#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1)
+#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16)
+
+
+/* Port Status Change Event TRB fields */
+/* Port ID - bits 31:24 */
+#define GET_PORT_ID(p) (((p) & (0xff << 24)) >> 24)
+
+/* Normal TRB fields */
+/* transfer_len bitmasks - bits 0:16 */
+#define TRB_LEN(p) ((p) & 0x1ffff)
+/* TD size - number of bytes remaining in the TD (including this TRB):
+ * bits 17 - 21. Shift the number of bytes by 10. */
+#define TD_REMAINDER(p) ((((p) >> 10) & 0x1f) << 17)
+/* Interrupter Target - which MSI-X vector to target the completion event at */
+#define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
+#define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
+
+/* Cycle bit - indicates TRB ownership by HC or HCD */
+#define TRB_CYCLE (1<<0)
+/*
+ * Force next event data TRB to be evaluated before task switch.
+ * Used to pass OS data back after a TD completes.
+ */
+#define TRB_ENT (1<<1)
+/* Interrupt on short packet */
+#define TRB_ISP (1<<2)
+/* Set PCIe no snoop attribute */
+#define TRB_NO_SNOOP (1<<3)
+/* Chain multiple TRBs into a TD */
+#define TRB_CHAIN (1<<4)
+/* Interrupt on completion */
+#define TRB_IOC (1<<5)
+/* The buffer pointer contains immediate data */
+#define TRB_IDT (1<<6)
+
+
+/* Control transfer TRB specific fields */
+#define TRB_DIR_IN (1<<16)
+
+struct xhci_generic_trb {
+ u32 field[4];
+} __attribute__ ((packed));
+
+union xhci_trb {
+ struct xhci_link_trb link;
+ struct xhci_transfer_event trans_event;
+ struct xhci_event_cmd event_cmd;
+ struct xhci_generic_trb generic;
+};
+
+/* TRB bit mask */
+#define TRB_TYPE_BITMASK (0xfc00)
+#define TRB_TYPE(p) ((p) << 10)
+/* TRB type IDs */
+/* bulk, interrupt, isoc scatter/gather, and control data stage */
+#define TRB_NORMAL 1
+/* setup stage for control transfers */
+#define TRB_SETUP 2
+/* data stage for control transfers */
+#define TRB_DATA 3
+/* status stage for control transfers */
+#define TRB_STATUS 4
+/* isoc transfers */
+#define TRB_ISOC 5
+/* TRB for linking ring segments */
+#define TRB_LINK 6
+#define TRB_EVENT_DATA 7
+/* Transfer Ring No-op (not for the command ring) */
+#define TRB_TR_NOOP 8
+/* Command TRBs */
+/* Enable Slot Command */
+#define TRB_ENABLE_SLOT 9
+/* Disable Slot Command */
+#define TRB_DISABLE_SLOT 10
+/* Address Device Command */
+#define TRB_ADDR_DEV 11
+/* Configure Endpoint Command */
+#define TRB_CONFIG_EP 12
+/* Evaluate Context Command */
+#define TRB_EVAL_CONTEXT 13
+/* Reset Transfer Ring Command */
+#define TRB_RESET_RING 14
+/* Stop Transfer Ring Command */
+#define TRB_STOP_RING 15
+/* Set Transfer Ring Dequeue Pointer Command */
+#define TRB_SET_DEQ 16
+/* Reset Device Command */
+#define TRB_RESET_DEV 17
+/* Force Event Command (opt) */
+#define TRB_FORCE_EVENT 18
+/* Negotiate Bandwidth Command (opt) */
+#define TRB_NEG_BANDWIDTH 19
+/* Set Latency Tolerance Value Command (opt) */
+#define TRB_SET_LT 20
+/* Get port bandwidth Command */
+#define TRB_GET_BW 21
+/* Force Header Command - generate a transaction or link management packet */
+#define TRB_FORCE_HEADER 22
+/* No-op Command - not for transfer rings */
+#define TRB_CMD_NOOP 23
+/* TRB IDs 24-31 reserved */
+/* Event TRBS */
+/* Transfer Event */
+#define TRB_TRANSFER 32
+/* Command Completion Event */
+#define TRB_COMPLETION 33
+/* Port Status Change Event */
+#define TRB_PORT_STATUS 34
+/* Bandwidth Request Event (opt) */
+#define TRB_BANDWIDTH_EVENT 35
+/* Doorbell Event (opt) */
+#define TRB_DOORBELL 36
+/* Host Controller Event */
+#define TRB_HC_EVENT 37
+/* Device Notification Event - device sent function wake notification */
+#define TRB_DEV_NOTE 38
+/* MFINDEX Wrap Event - microframe counter wrapped */
+#define TRB_MFINDEX_WRAP 39
+/* TRB IDs 40-47 reserved, 48-63 is vendor-defined */
+
+/*
+ * TRBS_PER_SEGMENT must be a multiple of 4,
+ * since the command ring is 64-byte aligned.
+ * It must also be greater than 16.
+ */
+#define TRBS_PER_SEGMENT 64
+#define SEGMENT_SIZE (TRBS_PER_SEGMENT*16)
+/* TRB buffer pointers can't cross 64KB boundaries */
+#define TRB_MAX_BUFF_SHIFT 16
+#define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT)
+
+struct xhci_segment {
+ union xhci_trb *trbs;
+ /* private to HCD */
+ struct xhci_segment *next;
+ dma_addr_t dma;
+} __attribute__ ((packed));
+
+struct xhci_td {
+ struct list_head td_list;
+ struct list_head cancelled_td_list;
+ struct urb *urb;
+ struct xhci_segment *start_seg;
+ union xhci_trb *first_trb;
+ union xhci_trb *last_trb;
+};
+
+struct xhci_ring {
+ struct xhci_segment *first_seg;
+ union xhci_trb *enqueue;
+ struct xhci_segment *enq_seg;
+ unsigned int enq_updates;
+ union xhci_trb *dequeue;
+ struct xhci_segment *deq_seg;
+ unsigned int deq_updates;
+ struct list_head td_list;
+ /* ---- Related to URB cancellation ---- */
+ struct list_head cancelled_td_list;
+ unsigned int cancels_pending;
+ unsigned int state;
+#define SET_DEQ_PENDING (1 << 0)
+ /* The TRB that was last reported in a stopped endpoint ring */
+ union xhci_trb *stopped_trb;
+ struct xhci_td *stopped_td;
+ /*
+ * Write the cycle state into the TRB cycle field to give ownership of
+ * the TRB to the host controller (if we are the producer), or to check
+ * if we own the TRB (if we are the consumer). See section 4.9.1.
+ */
+ u32 cycle_state;
+};
+
+struct xhci_erst_entry {
+ /* 64-bit event ring segment address */
+ u32 seg_addr[2];
+ u32 seg_size;
+ /* Set to zero */
+ u32 rsvd;
+} __attribute__ ((packed));
+
+struct xhci_erst {
+ struct xhci_erst_entry *entries;
+ unsigned int num_entries;
+ /* xhci->event_ring keeps track of segment dma addresses */
+ dma_addr_t erst_dma_addr;
+ /* Num entries the ERST can contain */
+ unsigned int erst_size;
+};
+
+/*
+ * Each segment table entry is 4*32bits long. 1K seems like an ok size:
+ * (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table,
+ * meaning 64 ring segments.
+ * Initial allocated size of the ERST, in number of entries */
+#define ERST_NUM_SEGS 1
+/* Initial allocated size of the ERST, in number of entries */
+#define ERST_SIZE 64
+/* Initial number of event segment rings allocated */
+#define ERST_ENTRIES 1
+/* Poll every 60 seconds */
+#define POLL_TIMEOUT 60
+/* XXX: Make these module parameters */
+
+
+/* There is one ehci_hci structure per controller */
+struct xhci_hcd {
+ /* glue to PCI and HCD framework */
+ struct xhci_cap_regs __iomem *cap_regs;
+ struct xhci_op_regs __iomem *op_regs;
+ struct xhci_run_regs __iomem *run_regs;
+ struct xhci_doorbell_array __iomem *dba;
+ /* Our HCD's current interrupter register set */
+ struct intr_reg __iomem *ir_set;
+
+ /* Cached register copies of read-only HC data */
+ __u32 hcs_params1;
+ __u32 hcs_params2;
+ __u32 hcs_params3;
+ __u32 hcc_params;
+
+ spinlock_t lock;
+
+ /* packed release number */
+ u8 sbrn;
+ u16 hci_version;
+ u8 max_slots;
+ u8 max_interrupters;
+ u8 max_ports;
+ u8 isoc_threshold;
+ int event_ring_max;
+ int addr_64;
+ /* 4KB min, 128MB max */
+ int page_size;
+ /* Valid values are 12 to 20, inclusive */
+ int page_shift;
+ /* only one MSI vector for now, but might need more later */
+ int msix_count;
+ struct msix_entry *msix_entries;
+ /* data structures */
+ struct xhci_device_context_array *dcbaa;
+ struct xhci_ring *cmd_ring;
+ struct xhci_ring *event_ring;
+ struct xhci_erst erst;
+ /* slot enabling and address device helpers */
+ struct completion addr_dev;
+ int slot_id;
+ /* Internal mirror of the HW's dcbaa */
+ struct xhci_virt_device *devs[MAX_HC_SLOTS];
+
+ /* DMA pools */
+ struct dma_pool *device_pool;
+ struct dma_pool *segment_pool;
+
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+ /* Poll the rings - for debugging */
+ struct timer_list event_ring_timer;
+ int zombie;
+#endif
+ /* Statistics */
+ int noops_submitted;
+ int noops_handled;
+ int error_bitmask;
+};
+
+/* For testing purposes */
+#define NUM_TEST_NOOPS 0
+
+/* convert between an HCD pointer and the corresponding EHCI_HCD */
+static inline struct xhci_hcd *hcd_to_xhci(struct usb_hcd *hcd)
+{
+ return (struct xhci_hcd *) (hcd->hcd_priv);
+}
+
+static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci)
+{
+ return container_of((void *) xhci, struct usb_hcd, hcd_priv);
+}
+
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+#define XHCI_DEBUG 1
+#else
+#define XHCI_DEBUG 0
+#endif
+
+#define xhci_dbg(xhci, fmt, args...) \
+ do { if (XHCI_DEBUG) dev_dbg(xhci_to_hcd(xhci)->self.controller , fmt , ## args); } while (0)
+#define xhci_info(xhci, fmt, args...) \
+ do { if (XHCI_DEBUG) dev_info(xhci_to_hcd(xhci)->self.controller , fmt , ## args); } while (0)
+#define xhci_err(xhci, fmt, args...) \
+ dev_err(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
+#define xhci_warn(xhci, fmt, args...) \
+ dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
+
+/* TODO: copied from ehci.h - can be refactored? */
+/* xHCI spec says all registers are little endian */
+static inline unsigned int xhci_readl(const struct xhci_hcd *xhci,
+ __u32 __iomem *regs)
+{
+ return readl(regs);
+}
+static inline void xhci_writel(struct xhci_hcd *xhci,
+ const unsigned int val, __u32 __iomem *regs)
+{
+ if (!in_interrupt())
+ xhci_dbg(xhci,
+ "`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n",
+ regs, val);
+ writel(val, regs);
+}
+
+/* xHCI debugging */
+void xhci_print_ir_set(struct xhci_hcd *xhci, struct intr_reg *ir_set, int set_num);
+void xhci_print_registers(struct xhci_hcd *xhci);
+void xhci_dbg_regs(struct xhci_hcd *xhci);
+void xhci_print_run_regs(struct xhci_hcd *xhci);
+void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb);
+void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb);
+void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg);
+void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring);
+void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst);
+void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci);
+void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring);
+void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_device_control *ctx, dma_addr_t dma, unsigned int last_ep);
+
+/* xHCI memory managment */
+void xhci_mem_cleanup(struct xhci_hcd *xhci);
+int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags);
+void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id);
+int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags);
+int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev);
+unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc);
+unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc);
+void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep);
+int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_device *udev, struct usb_host_endpoint *ep);
+void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring);
+
+#ifdef CONFIG_PCI
+/* xHCI PCI glue */
+int xhci_register_pci(void);
+void xhci_unregister_pci(void);
+#endif
+
+/* xHCI host controller glue */
+int xhci_halt(struct xhci_hcd *xhci);
+int xhci_reset(struct xhci_hcd *xhci);
+int xhci_init(struct usb_hcd *hcd);
+int xhci_run(struct usb_hcd *hcd);
+void xhci_stop(struct usb_hcd *hcd);
+void xhci_shutdown(struct usb_hcd *hcd);
+int xhci_get_frame(struct usb_hcd *hcd);
+irqreturn_t xhci_irq(struct usb_hcd *hcd);
+int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev);
+void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev);
+int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev);
+int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
+int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
+int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep);
+int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep);
+int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
+void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
+
+/* xHCI ring, segment, TRB, and TD functions */
+dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb);
+void xhci_ring_cmd_db(struct xhci_hcd *xhci);
+void *xhci_setup_one_noop(struct xhci_hcd *xhci);
+void xhci_handle_event(struct xhci_hcd *xhci);
+void xhci_set_hc_event_deq(struct xhci_hcd *xhci);
+int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id);
+int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
+ u32 slot_id);
+int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
+ unsigned int ep_index);
+int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
+ int slot_id, unsigned int ep_index);
+int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
+ int slot_id, unsigned int ep_index);
+int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
+ u32 slot_id);
+
+/* xHCI roothub code */
+int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
+ char *buf, u16 wLength);
+int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
+
+#endif /* __LINUX_XHCI_HCD_H */
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index a4ef77ef917d..3c5fe5cee05a 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -726,12 +726,18 @@ static const struct file_operations iowarrior_fops = {
.poll = iowarrior_poll,
};
+static char *iowarrior_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
/*
* usb class driver info in order to get a minor number from the usb core,
* and to have the device registered with devfs and the driver core
*/
static struct usb_class_driver iowarrior_class = {
.name = "iowarrior%d",
+ .nodename = iowarrior_nodename,
.fops = &iowarrior_fops,
.minor_base = IOWARRIOR_MINOR_BASE,
};
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index ab0f3226158b..c1e2433f640d 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -266,12 +266,18 @@ static const struct file_operations tower_fops = {
.llseek = tower_llseek,
};
+static char *legousbtower_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
/*
* usb class driver info in order to get a minor number from the usb core,
* and to have the device registered with the driver core
*/
static struct usb_class_driver tower_class = {
.name = "legousbtower%d",
+ .nodename = legousbtower_nodename,
.fops = &tower_fops,
.minor_base = LEGO_USB_TOWER_MINOR_BASE,
};
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 1f715436d6d3..a7eb4c99342c 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -733,7 +733,7 @@ int __init mon_text_init(void)
{
struct dentry *mondir;
- mondir = debugfs_create_dir("usbmon", NULL);
+ mondir = debugfs_create_dir("usbmon", usb_debug_root);
if (IS_ERR(mondir)) {
printk(KERN_NOTICE TAG ": debugfs is not available\n");
return -ENODEV;
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index b66e8544d8b9..70073b157f0a 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -10,6 +10,7 @@ comment "Enable Host or Gadget support to see Inventra options"
config USB_MUSB_HDRC
depends on (USB || USB_GADGET) && HAVE_CLK
depends on !SUPERH
+ select NOP_USB_XCEIV if ARCH_DAVINCI
select TWL4030_USB if MACH_OMAP_3430SDP
select USB_OTG_UTILS
tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
@@ -55,6 +56,7 @@ comment "Blackfin high speed USB Support"
config USB_TUSB6010
boolean "TUSB 6010 support"
depends on USB_MUSB_HDRC && !USB_MUSB_SOC
+ select NOP_USB_XCEIV
default y
help
The TUSB 6010 chip, from Texas Instruments, connects a discrete
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 786134852092..f2f66ebc7362 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -143,7 +143,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
u16 val;
spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_IDLE:
case OTG_STATE_A_WAIT_BCON:
/* Start a new session */
@@ -154,7 +154,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
val = musb_readw(musb->mregs, MUSB_DEVCTL);
if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);
@@ -247,6 +247,11 @@ int __init musb_platform_init(struct musb *musb)
}
gpio_direction_output(musb->config->gpio_vrsel, 0);
+ usb_nop_xceiv_register();
+ musb->xceiv = otg_get_transceiver();
+ if (!musb->xceiv)
+ return -ENODEV;
+
if (ANOMALY_05000346) {
bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
SSYNC();
@@ -291,7 +296,7 @@ int __init musb_platform_init(struct musb *musb)
musb_conn_timer_handler, (unsigned long) musb);
}
if (is_peripheral_enabled(musb))
- musb->xceiv.set_power = bfin_set_power;
+ musb->xceiv->set_power = bfin_set_power;
musb->isr = blackfin_interrupt;
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 1976e9b41800..c3577bbbae6c 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -6,6 +6,7 @@
* The TUSB6020, using VLYNQ, has CPPI that looks much like DaVinci.
*/
+#include <linux/platform_device.h>
#include <linux/usb.h>
#include "musb_core.h"
@@ -1145,17 +1146,27 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
return completed;
}
-void cppi_completion(struct musb *musb, u32 rx, u32 tx)
+irqreturn_t cppi_interrupt(int irq, void *dev_id)
{
- void __iomem *tibase;
- int i, index;
+ struct musb *musb = dev_id;
struct cppi *cppi;
+ void __iomem *tibase;
struct musb_hw_ep *hw_ep = NULL;
+ u32 rx, tx;
+ int i, index;
cppi = container_of(musb->dma_controller, struct cppi, controller);
tibase = musb->ctrl_base;
+ tx = musb_readl(tibase, DAVINCI_TXCPPI_MASKED_REG);
+ rx = musb_readl(tibase, DAVINCI_RXCPPI_MASKED_REG);
+
+ if (!tx && !rx)
+ return IRQ_NONE;
+
+ DBG(4, "CPPI IRQ Tx%x Rx%x\n", tx, rx);
+
/* process TX channels */
for (index = 0; tx; tx = tx >> 1, index++) {
struct cppi_channel *tx_ch;
@@ -1273,6 +1284,8 @@ void cppi_completion(struct musb *musb, u32 rx, u32 tx)
/* write to CPPI EOI register to re-enable interrupts */
musb_writel(tibase, DAVINCI_CPPI_EOI_REG, 0);
+
+ return IRQ_HANDLED;
}
/* Instantiate a software object representing a DMA controller. */
@@ -1280,6 +1293,9 @@ struct dma_controller *__init
dma_controller_create(struct musb *musb, void __iomem *mregs)
{
struct cppi *controller;
+ struct device *dev = musb->controller;
+ struct platform_device *pdev = to_platform_device(dev);
+ int irq = platform_get_irq(pdev, 1);
controller = kzalloc(sizeof *controller, GFP_KERNEL);
if (!controller)
@@ -1310,6 +1326,15 @@ dma_controller_create(struct musb *musb, void __iomem *mregs)
return NULL;
}
+ if (irq > 0) {
+ if (request_irq(irq, cppi_interrupt, 0, "cppi-dma", musb)) {
+ dev_err(dev, "request_irq %d failed!\n", irq);
+ dma_controller_destroy(&controller->controller);
+ return NULL;
+ }
+ controller->irq = irq;
+ }
+
return &controller->controller;
}
@@ -1322,6 +1347,9 @@ void dma_controller_destroy(struct dma_controller *c)
cppi = container_of(c, struct cppi, controller);
+ if (cppi->irq)
+ free_irq(cppi->irq, cppi->musb);
+
/* assert: caller stopped the controller first */
dma_pool_destroy(cppi->pool);
diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h
index 729b4071787b..8a39de3e6e47 100644
--- a/drivers/usb/musb/cppi_dma.h
+++ b/drivers/usb/musb/cppi_dma.h
@@ -119,6 +119,8 @@ struct cppi {
void __iomem *mregs; /* Mentor regs */
void __iomem *tibase; /* TI/CPPI regs */
+ int irq;
+
struct cppi_channel tx[4];
struct cppi_channel rx[4];
@@ -127,7 +129,7 @@ struct cppi {
struct list_head tx_complete;
};
-/* irq handling hook */
-extern void cppi_completion(struct musb *, u32 rx, u32 tx);
+/* CPPI IRQ handler */
+extern irqreturn_t cppi_interrupt(int, void *);
#endif /* end of ifndef _CPPI_DMA_H_ */
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 10d11ab113ab..180d7daa4099 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -215,7 +215,7 @@ static void otg_timer(unsigned long _musb)
DBG(7, "poll devctl %02x (%s)\n", devctl, otg_state_string(musb));
spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_WAIT_VFALL:
/* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
* seems to mis-handle session "start" otherwise (or in our
@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break;
@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -265,6 +265,7 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
irqreturn_t retval = IRQ_NONE;
struct musb *musb = __hci;
void __iomem *tibase = musb->ctrl_base;
+ struct cppi *cppi;
u32 tmp;
spin_lock_irqsave(&musb->lock, flags);
@@ -281,16 +282,9 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
/* CPPI interrupts share the same IRQ line, but have their own
* mask, state, "vector", and EOI registers.
*/
- if (is_cppi_enabled()) {
- u32 cppi_tx = musb_readl(tibase, DAVINCI_TXCPPI_MASKED_REG);
- u32 cppi_rx = musb_readl(tibase, DAVINCI_RXCPPI_MASKED_REG);
-
- if (cppi_tx || cppi_rx) {
- DBG(4, "CPPI IRQ t%x r%x\n", cppi_tx, cppi_rx);
- cppi_completion(musb, cppi_rx, cppi_tx);
- retval = IRQ_HANDLED;
- }
- }
+ cppi = container_of(musb->dma_controller, struct cppi, controller);
+ if (is_cppi_enabled() && musb->dma_controller && !cppi->irq)
+ retval = cppi_interrupt(irq, __hci);
/* ack and handle non-CPPI interrupts */
tmp = musb_readl(tibase, DAVINCI_USB_INT_SRC_MASKED_REG);
@@ -331,21 +325,21 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
* to stop registering in devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) {
musb->is_active = 1;
MUSB_HST_MODE(musb);
- musb->xceiv.default_a = 1;
- musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->default_a = 1;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
- musb->xceiv.default_a = 0;
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->default_a = 0;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}
@@ -367,17 +361,12 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
/* poll for ID change */
if (is_otg_enabled(musb)
- && musb->xceiv.state == OTG_STATE_B_IDLE)
+ && musb->xceiv->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
spin_unlock_irqrestore(&musb->lock, flags);
- /* REVISIT we sometimes get unhandled IRQs
- * (e.g. ep0). not clear why...
- */
- if (retval != IRQ_HANDLED)
- DBG(5, "unhandled? %08x\n", tmp);
- return IRQ_HANDLED;
+ return retval;
}
int musb_platform_set_mode(struct musb *musb, u8 mode)
@@ -391,6 +380,11 @@ int __init musb_platform_init(struct musb *musb)
void __iomem *tibase = musb->ctrl_base;
u32 revision;
+ usb_nop_xceiv_register();
+ musb->xceiv = otg_get_transceiver();
+ if (!musb->xceiv)
+ return -ENODEV;
+
musb->mregs += DAVINCI_BASE_OFFSET;
clk_enable(musb->clock);
@@ -398,7 +392,7 @@ int __init musb_platform_init(struct musb *musb)
/* returns zero if e.g. not clocked */
revision = musb_readl(tibase, DAVINCI_USB_VERSION_REG);
if (revision == 0)
- return -ENODEV;
+ goto fail;
if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
@@ -432,6 +426,10 @@ int __init musb_platform_init(struct musb *musb)
musb->isr = davinci_interrupt;
return 0;
+
+fail:
+ usb_nop_xceiv_unregister();
+ return -ENODEV;
}
int musb_platform_exit(struct musb *musb)
@@ -442,7 +440,7 @@ int musb_platform_exit(struct musb *musb)
davinci_source_power(musb, 0 /*off*/, 1);
/* delay, to avoid problems with module reload */
- if (is_host_enabled(musb) && musb->xceiv.default_a) {
+ if (is_host_enabled(musb) && musb->xceiv->default_a) {
int maxdelay = 30;
u8 devctl, warn = 0;
@@ -471,5 +469,7 @@ int musb_platform_exit(struct musb *musb)
clk_disable(musb->clock);
+ usb_nop_xceiv_unregister();
+
return 0;
}
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 4000cf6d1e81..554a414f65d1 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -112,6 +112,7 @@
#include "davinci.h"
#endif
+#define TA_WAIT_BCON(m) max_t(int, (m)->a_wait_bcon, OTG_TIME_A_WAIT_BCON)
unsigned musb_debug;
@@ -267,7 +268,7 @@ void musb_load_testpacket(struct musb *musb)
const char *otg_state_string(struct musb *musb)
{
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_IDLE: return "a_idle";
case OTG_STATE_A_WAIT_VRISE: return "a_wait_vrise";
case OTG_STATE_A_WAIT_BCON: return "a_wait_bcon";
@@ -288,12 +289,6 @@ const char *otg_state_string(struct musb *musb)
#ifdef CONFIG_USB_MUSB_OTG
/*
- * See also USB_OTG_1-3.pdf 6.6.5 Timers
- * REVISIT: Are the other timers done in the hardware?
- */
-#define TB_ASE0_BRST 100 /* Min 3.125 ms */
-
-/*
* Handles OTG hnp timeouts, such as b_ase0_brst
*/
void musb_otg_timer_func(unsigned long data)
@@ -302,16 +297,18 @@ void musb_otg_timer_func(unsigned long data)
unsigned long flags;
spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_B_WAIT_ACON:
DBG(1, "HNP: b_wait_acon timeout; back to b_peripheral\n");
musb_g_disconnect(musb);
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
break;
+ case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON:
- DBG(1, "HNP: a_wait_bcon timeout; back to a_host\n");
- musb_hnp_stop(musb);
+ DBG(1, "HNP: %s timeout\n", otg_state_string(musb));
+ musb_set_vbus(musb, 0);
+ musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
break;
default:
DBG(1, "HNP: Unhandled mode %s\n", otg_state_string(musb));
@@ -320,10 +317,8 @@ void musb_otg_timer_func(unsigned long data)
spin_unlock_irqrestore(&musb->lock, flags);
}
-static DEFINE_TIMER(musb_otg_timer, musb_otg_timer_func, 0, 0);
-
/*
- * Stops the B-device HNP state. Caller must take care of locking.
+ * Stops the HNP transition. Caller must take care of locking.
*/
void musb_hnp_stop(struct musb *musb)
{
@@ -331,20 +326,17 @@ void musb_hnp_stop(struct musb *musb)
void __iomem *mbase = musb->mregs;
u8 reg;
- switch (musb->xceiv.state) {
+ DBG(1, "HNP: stop from %s\n", otg_state_string(musb));
+
+ switch (musb->xceiv->state) {
case OTG_STATE_A_PERIPHERAL:
- case OTG_STATE_A_WAIT_VFALL:
- case OTG_STATE_A_WAIT_BCON:
- DBG(1, "HNP: Switching back to A-host\n");
musb_g_disconnect(musb);
- musb->xceiv.state = OTG_STATE_A_IDLE;
- MUSB_HST_MODE(musb);
- musb->is_active = 0;
+ DBG(1, "HNP: back to %s\n", otg_state_string(musb));
break;
case OTG_STATE_B_HOST:
DBG(1, "HNP: Disabling HR\n");
hcd->self.is_b_host = 0;
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
reg |= MUSB_POWER_SUSPENDM;
@@ -402,7 +394,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
if (devctl & MUSB_DEVCTL_HM) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_SUSPEND:
/* remote wakeup? later, GetPortStatus
* will stop RESUME signaling
@@ -425,12 +417,12 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->rh_timer = jiffies
+ msecs_to_jiffies(20);
- musb->xceiv.state = OTG_STATE_A_HOST;
+ musb->xceiv->state = OTG_STATE_A_HOST;
musb->is_active = 1;
usb_hcd_resume_root_hub(musb_to_hcd(musb));
break;
case OTG_STATE_B_WAIT_ACON:
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 1;
MUSB_DEV_MODE(musb);
break;
@@ -441,11 +433,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
}
#endif
} else {
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
- musb->xceiv.state = OTG_STATE_A_HOST;
+ musb->xceiv->state = OTG_STATE_A_HOST;
usb_hcd_resume_root_hub(musb_to_hcd(musb));
break;
#endif
@@ -490,7 +482,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
musb->ep0_stage = MUSB_EP0_START;
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
musb_set_vbus(musb, 1);
@@ -516,7 +508,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_HOST:
/* recovery is dicey once we've gotten past the
* initial stages of enumeration, but if VBUS
@@ -594,37 +586,40 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
if (devctl & MUSB_DEVCTL_LSDEV)
musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
- if (hcd->status_urb)
- usb_hcd_poll_rh_status(hcd);
- else
- usb_hcd_resume_root_hub(hcd);
-
- MUSB_HST_MODE(musb);
-
/* indicate new connection to OTG machine */
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_B_PERIPHERAL:
if (int_usb & MUSB_INTR_SUSPEND) {
DBG(1, "HNP: SUSPEND+CONNECT, now b_host\n");
- musb->xceiv.state = OTG_STATE_B_HOST;
- hcd->self.is_b_host = 1;
int_usb &= ~MUSB_INTR_SUSPEND;
+ goto b_host;
} else
DBG(1, "CONNECT as b_peripheral???\n");
break;
case OTG_STATE_B_WAIT_ACON:
- DBG(1, "HNP: Waiting to switch to b_host state\n");
- musb->xceiv.state = OTG_STATE_B_HOST;
+ DBG(1, "HNP: CONNECT, now b_host\n");
+b_host:
+ musb->xceiv->state = OTG_STATE_B_HOST;
hcd->self.is_b_host = 1;
+ musb->ignore_disconnect = 0;
+ del_timer(&musb->otg_timer);
break;
default:
if ((devctl & MUSB_DEVCTL_VBUS)
== (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
- musb->xceiv.state = OTG_STATE_A_HOST;
+ musb->xceiv->state = OTG_STATE_A_HOST;
hcd->self.is_b_host = 0;
}
break;
}
+
+ /* poke the root hub */
+ MUSB_HST_MODE(musb);
+ if (hcd->status_urb)
+ usb_hcd_poll_rh_status(hcd);
+ else
+ usb_hcd_resume_root_hub(hcd);
+
DBG(1, "CONNECT (%s) devctl %02x\n",
otg_state_string(musb), devctl);
}
@@ -650,7 +645,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
}
} else if (is_peripheral_capable()) {
DBG(1, "BUS RESET as %s\n", otg_state_string(musb));
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
#ifdef CONFIG_USB_OTG
case OTG_STATE_A_SUSPEND:
/* We need to ignore disconnect on suspend
@@ -661,24 +656,27 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb_g_reset(musb);
/* FALLTHROUGH */
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
- DBG(1, "HNP: Setting timer as %s\n",
- otg_state_string(musb));
- musb_otg_timer.data = (unsigned long)musb;
- mod_timer(&musb_otg_timer, jiffies
- + msecs_to_jiffies(100));
+ /* never use invalid T(a_wait_bcon) */
+ DBG(1, "HNP: in %s, %d msec timeout\n",
+ otg_state_string(musb),
+ TA_WAIT_BCON(musb));
+ mod_timer(&musb->otg_timer, jiffies
+ + msecs_to_jiffies(TA_WAIT_BCON(musb)));
break;
case OTG_STATE_A_PERIPHERAL:
- musb_hnp_stop(musb);
+ musb->ignore_disconnect = 0;
+ del_timer(&musb->otg_timer);
+ musb_g_reset(musb);
break;
case OTG_STATE_B_WAIT_ACON:
DBG(1, "HNP: RESET (%s), to b_peripheral\n",
otg_state_string(musb));
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
musb_g_reset(musb);
break;
#endif
case OTG_STATE_B_IDLE:
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
/* FALLTHROUGH */
case OTG_STATE_B_PERIPHERAL:
musb_g_reset(musb);
@@ -763,7 +761,7 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
MUSB_MODE(musb), devctl);
handled = IRQ_HANDLED;
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
@@ -776,7 +774,16 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
#endif /* HOST */
#ifdef CONFIG_USB_MUSB_OTG
case OTG_STATE_B_HOST:
- musb_hnp_stop(musb);
+ /* REVISIT this behaves for "real disconnect"
+ * cases; make sure the other transitions from
+ * from B_HOST act right too. The B_HOST code
+ * in hnp_stop() is currently not used...
+ */
+ musb_root_disconnect(musb);
+ musb_to_hcd(musb)->self.is_b_host = 0;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ MUSB_DEV_MODE(musb);
+ musb_g_disconnect(musb);
break;
case OTG_STATE_A_PERIPHERAL:
musb_hnp_stop(musb);
@@ -805,26 +812,35 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
otg_state_string(musb), devctl, power);
handled = IRQ_HANDLED;
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
#ifdef CONFIG_USB_MUSB_OTG
case OTG_STATE_A_PERIPHERAL:
- /*
- * We cannot stop HNP here, devctl BDEVICE might be
- * still set.
+ /* We also come here if the cable is removed, since
+ * this silicon doesn't report ID-no-longer-grounded.
+ *
+ * We depend on T(a_wait_bcon) to shut us down, and
+ * hope users don't do anything dicey during this
+ * undesired detour through A_WAIT_BCON.
*/
+ musb_hnp_stop(musb);
+ usb_hcd_resume_root_hub(musb_to_hcd(musb));
+ musb_root_disconnect(musb);
+ musb_platform_try_idle(musb, jiffies
+ + msecs_to_jiffies(musb->a_wait_bcon
+ ? : OTG_TIME_A_WAIT_BCON));
break;
#endif
case OTG_STATE_B_PERIPHERAL:
musb_g_suspend(musb);
musb->is_active = is_otg_enabled(musb)
- && musb->xceiv.gadget->b_hnp_enable;
+ && musb->xceiv->gadget->b_hnp_enable;
if (musb->is_active) {
#ifdef CONFIG_USB_MUSB_OTG
- musb->xceiv.state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
DBG(1, "HNP: Setting timer for b_ase0_brst\n");
- musb_otg_timer.data = (unsigned long)musb;
- mod_timer(&musb_otg_timer, jiffies
- + msecs_to_jiffies(TB_ASE0_BRST));
+ mod_timer(&musb->otg_timer, jiffies
+ + msecs_to_jiffies(
+ OTG_TIME_B_ASE0_BRST));
#endif
}
break;
@@ -834,9 +850,9 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
+ msecs_to_jiffies(musb->a_wait_bcon));
break;
case OTG_STATE_A_HOST:
- musb->xceiv.state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->state = OTG_STATE_A_SUSPEND;
musb->is_active = is_otg_enabled(musb)
- && musb->xceiv.host->b_hnp_enable;
+ && musb->xceiv->host->b_hnp_enable;
break;
case OTG_STATE_B_HOST:
/* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */
@@ -1068,14 +1084,13 @@ static struct fifo_cfg __initdata mode_4_cfg[] = {
{ .hw_ep_num = 8, .style = FIFO_RX, .maxpacket = 512, },
{ .hw_ep_num = 9, .style = FIFO_TX, .maxpacket = 512, },
{ .hw_ep_num = 9, .style = FIFO_RX, .maxpacket = 512, },
-{ .hw_ep_num = 10, .style = FIFO_TX, .maxpacket = 512, },
-{ .hw_ep_num = 10, .style = FIFO_RX, .maxpacket = 512, },
-{ .hw_ep_num = 11, .style = FIFO_TX, .maxpacket = 512, },
-{ .hw_ep_num = 11, .style = FIFO_RX, .maxpacket = 512, },
-{ .hw_ep_num = 12, .style = FIFO_TX, .maxpacket = 512, },
-{ .hw_ep_num = 12, .style = FIFO_RX, .maxpacket = 512, },
-{ .hw_ep_num = 13, .style = FIFO_TX, .maxpacket = 512, },
-{ .hw_ep_num = 13, .style = FIFO_RX, .maxpacket = 512, },
+{ .hw_ep_num = 10, .style = FIFO_TX, .maxpacket = 256, },
+{ .hw_ep_num = 10, .style = FIFO_RX, .maxpacket = 64, },
+{ .hw_ep_num = 11, .style = FIFO_TX, .maxpacket = 256, },
+{ .hw_ep_num = 11, .style = FIFO_RX, .maxpacket = 64, },
+{ .hw_ep_num = 12, .style = FIFO_TX, .maxpacket = 256, },
+{ .hw_ep_num = 12, .style = FIFO_RX, .maxpacket = 64, },
+{ .hw_ep_num = 13, .style = FIFO_RXTX, .maxpacket = 4096, },
{ .hw_ep_num = 14, .style = FIFO_RXTX, .maxpacket = 1024, },
{ .hw_ep_num = 15, .style = FIFO_RXTX, .maxpacket = 1024, },
};
@@ -1335,11 +1350,11 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
}
if (reg & MUSB_CONFIGDATA_HBRXE) {
strcat(aInfo, ", HB-ISO Rx");
- strcat(aInfo, " (X)"); /* no driver support */
+ musb->hb_iso_rx = true;
}
if (reg & MUSB_CONFIGDATA_HBTXE) {
strcat(aInfo, ", HB-ISO Tx");
- strcat(aInfo, " (X)"); /* no driver support */
+ musb->hb_iso_tx = true;
}
if (reg & MUSB_CONFIGDATA_SOFTCONE)
strcat(aInfo, ", SoftConn");
@@ -1481,13 +1496,7 @@ static irqreturn_t generic_interrupt(int irq, void *__hci)
spin_unlock_irqrestore(&musb->lock, flags);
- /* REVISIT we sometimes get spurious IRQs on g_ep0
- * not clear why...
- */
- if (retval != IRQ_HANDLED)
- DBG(5, "spurious?\n");
-
- return IRQ_HANDLED;
+ return retval;
}
#else
@@ -1687,8 +1696,9 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
}
spin_lock_irqsave(&musb->lock, flags);
- musb->a_wait_bcon = val;
- if (musb->xceiv.state == OTG_STATE_A_WAIT_BCON)
+ /* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
+ musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
+ if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
musb->is_active = 0;
musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1706,10 +1716,13 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
spin_lock_irqsave(&musb->lock, flags);
val = musb->a_wait_bcon;
+ /* FIXME get_vbus_status() is normally #defined as false...
+ * and is effectively TUSB-specific.
+ */
vbus = musb_platform_get_vbus_status(musb);
spin_unlock_irqrestore(&musb->lock, flags);
- return sprintf(buf, "Vbus %s, timeout %lu\n",
+ return sprintf(buf, "Vbus %s, timeout %lu msec\n",
vbus ? "on" : "off", val);
}
static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
@@ -1749,8 +1762,8 @@ static void musb_irq_work(struct work_struct *data)
struct musb *musb = container_of(data, struct musb, irq_work);
static int old_state;
- if (musb->xceiv.state != old_state) {
- old_state = musb->xceiv.state;
+ if (musb->xceiv->state != old_state) {
+ old_state = musb->xceiv->state;
sysfs_notify(&musb->controller->kobj, NULL, "mode");
}
}
@@ -1782,6 +1795,7 @@ allocate_instance(struct device *dev,
hcd->uses_new_polling = 1;
musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
+ musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON;
#else
musb = kzalloc(sizeof *musb, GFP_KERNEL);
if (!musb)
@@ -1847,7 +1861,7 @@ static void musb_free(struct musb *musb)
}
#ifdef CONFIG_USB_MUSB_OTG
- put_device(musb->xceiv.dev);
+ put_device(musb->xceiv->dev);
#endif
#ifdef CONFIG_USB_MUSB_HDRC_HCD
@@ -1928,10 +1942,18 @@ bad_config:
}
}
- /* assume vbus is off */
-
- /* platform adjusts musb->mregs and musb->isr if needed,
- * and activates clocks
+ /* The musb_platform_init() call:
+ * - adjusts musb->mregs and musb->isr if needed,
+ * - may initialize an integrated tranceiver
+ * - initializes musb->xceiv, usually by otg_get_transceiver()
+ * - activates clocks.
+ * - stops powering VBUS
+ * - assigns musb->board_set_vbus if host mode is enabled
+ *
+ * There are various transciever configurations. Blackfin,
+ * DaVinci, TUSB60x0, and others integrate them. OMAP3 uses
+ * external/discrete ones in various flavors (twl4030 family,
+ * isp1504, non-OTG, etc) mostly hooking up through ULPI.
*/
musb->isr = generic_interrupt;
status = musb_platform_init(musb);
@@ -1968,6 +1990,10 @@ bad_config:
if (status < 0)
goto fail2;
+#ifdef CONFIG_USB_OTG
+ setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
+#endif
+
/* Init IRQ workqueue before request_irq */
INIT_WORK(&musb->irq_work, musb_irq_work);
@@ -1999,17 +2025,17 @@ bad_config:
? "DMA" : "PIO",
musb->nIrq);
-#ifdef CONFIG_USB_MUSB_HDRC_HCD
- /* host side needs more setup, except for no-host modes */
- if (musb->board_mode != MUSB_PERIPHERAL) {
+ /* host side needs more setup */
+ if (is_host_enabled(musb)) {
struct usb_hcd *hcd = musb_to_hcd(musb);
- if (musb->board_mode == MUSB_OTG)
+ otg_set_host(musb->xceiv, &hcd->self);
+
+ if (is_otg_enabled(musb))
hcd->self.otg_port = 1;
- musb->xceiv.host = &hcd->self;
+ musb->xceiv->host = &hcd->self;
hcd->power_budget = 2 * (plat->power ? : 250);
}
-#endif /* CONFIG_USB_MUSB_HDRC_HCD */
/* For the host-only role, we can activate right away.
* (We expect the ID pin to be forcibly grounded!!)
@@ -2017,8 +2043,8 @@ bad_config:
*/
if (!is_otg_enabled(musb) && is_host_enabled(musb)) {
MUSB_HST_MODE(musb);
- musb->xceiv.default_a = 1;
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->default_a = 1;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
if (status)
@@ -2033,8 +2059,8 @@ bad_config:
} else /* peripheral is enabled */ {
MUSB_DEV_MODE(musb);
- musb->xceiv.default_a = 0;
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->default_a = 0;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
status = musb_gadget_setup(musb);
if (status)
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index efb39b5e55b5..f3772ca3b2cf 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -40,6 +40,7 @@
#include <linux/interrupt.h>
#include <linux/smp_lock.h>
#include <linux/errno.h>
+#include <linux/timer.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/usb/ch9.h>
@@ -171,7 +172,8 @@ enum musb_h_ep0_state {
/* peripheral side ep0 states */
enum musb_g_ep0_state {
- MUSB_EP0_STAGE_SETUP, /* idle, waiting for setup */
+ MUSB_EP0_STAGE_IDLE, /* idle, waiting for SETUP */
+ MUSB_EP0_STAGE_SETUP, /* received SETUP */
MUSB_EP0_STAGE_TX, /* IN data */
MUSB_EP0_STAGE_RX, /* OUT data */
MUSB_EP0_STAGE_STATUSIN, /* (after OUT data) */
@@ -179,10 +181,15 @@ enum musb_g_ep0_state {
MUSB_EP0_STAGE_ACKWAIT, /* after zlp, before statusin */
} __attribute__ ((packed));
-/* OTG protocol constants */
+/*
+ * OTG protocol constants. See USB OTG 1.3 spec,
+ * sections 5.5 "Device Timings" and 6.6.5 "Timers".
+ */
#define OTG_TIME_A_WAIT_VRISE 100 /* msec (max) */
-#define OTG_TIME_A_WAIT_BCON 0 /* 0=infinite; min 1000 msec */
-#define OTG_TIME_A_IDLE_BDIS 200 /* msec (min) */
+#define OTG_TIME_A_WAIT_BCON 1100 /* min 1 second */
+#define OTG_TIME_A_AIDL_BDIS 200 /* min 200 msec */
+#define OTG_TIME_B_ASE0_BRST 100 /* min 3.125 ms */
+
/*************************** REGISTER ACCESS ********************************/
@@ -331,6 +338,8 @@ struct musb {
struct list_head control; /* of musb_qh */
struct list_head in_bulk; /* of musb_qh */
struct list_head out_bulk; /* of musb_qh */
+
+ struct timer_list otg_timer;
#endif
/* called with IRQs blocked; ON/nonzero implies starting a session,
@@ -355,7 +364,7 @@ struct musb {
u16 int_rx;
u16 int_tx;
- struct otg_transceiver xceiv;
+ struct otg_transceiver *xceiv;
int nIrq;
unsigned irq_wake:1;
@@ -386,6 +395,9 @@ struct musb {
unsigned is_multipoint:1;
unsigned ignore_disconnect:1; /* during bus resets */
+ unsigned hb_iso_rx:1; /* high bandwidth iso rx? */
+ unsigned hb_iso_tx:1; /* high bandwidth iso tx? */
+
#ifdef C_MP_TX
unsigned bulk_split:1;
#define can_bulk_split(musb,type) \
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index f79440cdfe7e..8b3c4e2ed7b8 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -310,7 +310,7 @@ static void txstate(struct musb *musb, struct musb_request *req)
/* setup DMA, then program endpoint CSR */
request_size = min(request->length,
musb_ep->dma->max_len);
- if (request_size <= musb_ep->packet_sz)
+ if (request_size < musb_ep->packet_sz)
musb_ep->dma->desired_mode = 0;
else
musb_ep->dma->desired_mode = 1;
@@ -349,7 +349,8 @@ static void txstate(struct musb *musb, struct musb_request *req)
#elif defined(CONFIG_USB_TI_CPPI_DMA)
/* program endpoint CSR first, then setup DMA */
csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY);
- csr |= MUSB_TXCSR_MODE | MUSB_TXCSR_DMAENAB;
+ csr |= MUSB_TXCSR_DMAENAB | MUSB_TXCSR_DMAMODE |
+ MUSB_TXCSR_MODE;
musb_writew(epio, MUSB_TXCSR,
(MUSB_TXCSR_P_WZC_BITS & ~MUSB_TXCSR_P_UNDERRUN)
| csr);
@@ -1405,7 +1406,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_B_PERIPHERAL:
/* NOTE: OTG state machine doesn't include B_SUSPENDED;
* that's part of the standard usb 1.1 state machine, and
@@ -1507,9 +1508,9 @@ static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
{
struct musb *musb = gadget_to_musb(gadget);
- if (!musb->xceiv.set_power)
+ if (!musb->xceiv->set_power)
return -EOPNOTSUPP;
- return otg_set_power(&musb->xceiv, mA);
+ return otg_set_power(musb->xceiv, mA);
}
static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on)
@@ -1732,11 +1733,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
spin_lock_irqsave(&musb->lock, flags);
- /* REVISIT always use otg_set_peripheral(), handling
- * issues including the root hub one below ...
- */
- musb->xceiv.gadget = &musb->g;
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ otg_set_peripheral(musb->xceiv, &musb->g);
musb->is_active = 1;
/* FIXME this ignores the softconnect flag. Drivers are
@@ -1748,6 +1745,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!is_otg_enabled(musb))
musb_start(musb);
+ otg_set_peripheral(musb->xceiv, &musb->g);
+
spin_unlock_irqrestore(&musb->lock, flags);
if (is_otg_enabled(musb)) {
@@ -1761,8 +1760,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (retval < 0) {
DBG(1, "add_hcd failed, %d\n", retval);
spin_lock_irqsave(&musb->lock, flags);
- musb->xceiv.gadget = NULL;
- musb->xceiv.state = OTG_STATE_UNDEFINED;
+ otg_set_peripheral(musb->xceiv, NULL);
musb->gadget_driver = NULL;
musb->g.dev.driver = NULL;
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1845,8 +1843,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
(void) musb_gadget_vbus_draw(&musb->g, 0);
- musb->xceiv.state = OTG_STATE_UNDEFINED;
+ musb->xceiv->state = OTG_STATE_UNDEFINED;
stop_activity(musb, driver);
+ otg_set_peripheral(musb->xceiv, NULL);
DBG(3, "unregistering driver %s\n", driver->function);
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1882,7 +1881,7 @@ EXPORT_SYMBOL(usb_gadget_unregister_driver);
void musb_g_resume(struct musb *musb)
{
musb->is_suspended = 0;
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_B_IDLE:
break;
case OTG_STATE_B_WAIT_ACON:
@@ -1908,10 +1907,10 @@ void musb_g_suspend(struct musb *musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
DBG(3, "devctl %02x\n", devctl);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_B_IDLE:
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
musb->is_suspended = 1;
@@ -1957,22 +1956,24 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(&musb->lock);
}
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
default:
#ifdef CONFIG_USB_MUSB_OTG
DBG(2, "Unhandled disconnect %s, setting a_idle\n",
otg_state_string(musb));
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
+ MUSB_HST_MODE(musb);
break;
case OTG_STATE_A_PERIPHERAL:
- musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ MUSB_HST_MODE(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST:
#endif
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE:
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_B_SRP_INIT:
break;
@@ -2028,10 +2029,10 @@ __acquires(musb->lock)
* or else after HNP, as A-Device
*/
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else if (is_otg_enabled(musb)) {
- musb->xceiv.state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
} else
WARN_ON(1);
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 3f5e30ddfa27..40ed50ecedff 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -4,6 +4,7 @@
* Copyright 2005 Mentor Graphics Corporation
* Copyright (C) 2005-2006 by Texas Instruments
* Copyright (C) 2006-2007 Nokia Corporation
+ * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -58,7 +59,8 @@
static char *decode_ep0stage(u8 stage)
{
switch (stage) {
- case MUSB_EP0_STAGE_SETUP: return "idle";
+ case MUSB_EP0_STAGE_IDLE: return "idle";
+ case MUSB_EP0_STAGE_SETUP: return "setup";
case MUSB_EP0_STAGE_TX: return "in";
case MUSB_EP0_STAGE_RX: return "out";
case MUSB_EP0_STAGE_ACKWAIT: return "wait";
@@ -628,7 +630,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
musb_writew(regs, MUSB_CSR0,
csr & ~MUSB_CSR0_P_SENTSTALL);
retval = IRQ_HANDLED;
- musb->ep0_state = MUSB_EP0_STAGE_SETUP;
+ musb->ep0_state = MUSB_EP0_STAGE_IDLE;
csr = musb_readw(regs, MUSB_CSR0);
}
@@ -636,7 +638,18 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
if (csr & MUSB_CSR0_P_SETUPEND) {
musb_writew(regs, MUSB_CSR0, MUSB_CSR0_P_SVDSETUPEND);
retval = IRQ_HANDLED;
- musb->ep0_state = MUSB_EP0_STAGE_SETUP;
+ /* Transition into the early status phase */
+ switch (musb->ep0_state) {
+ case MUSB_EP0_STAGE_TX:
+ musb->ep0_state = MUSB_EP0_STAGE_STATUSOUT;
+ break;
+ case MUSB_EP0_STAGE_RX:
+ musb->ep0_state = MUSB_EP0_STAGE_STATUSIN;
+ break;
+ default:
+ ERR("SetupEnd came in a wrong ep0stage %s",
+ decode_ep0stage(musb->ep0_state));
+ }
csr = musb_readw(regs, MUSB_CSR0);
/* NOTE: request may need completion */
}
@@ -697,11 +710,31 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
if (req)
musb_g_ep0_giveback(musb, req);
}
+
+ /*
+ * In case when several interrupts can get coalesced,
+ * check to see if we've already received a SETUP packet...
+ */
+ if (csr & MUSB_CSR0_RXPKTRDY)
+ goto setup;
+
+ retval = IRQ_HANDLED;
+ musb->ep0_state = MUSB_EP0_STAGE_IDLE;
+ break;
+
+ case MUSB_EP0_STAGE_IDLE:
+ /*
+ * This state is typically (but not always) indiscernible
+ * from the status states since the corresponding interrupts
+ * tend to happen within too little period of time (with only
+ * a zero-length packet in between) and so get coalesced...
+ */
retval = IRQ_HANDLED;
musb->ep0_state = MUSB_EP0_STAGE_SETUP;
/* FALLTHROUGH */
case MUSB_EP0_STAGE_SETUP:
+setup:
if (csr & MUSB_CSR0_RXPKTRDY) {
struct usb_ctrlrequest setup;
int handled = 0;
@@ -783,7 +816,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
stall:
DBG(3, "stall (%d)\n", handled);
musb->ackpend |= MUSB_CSR0_P_SENDSTALL;
- musb->ep0_state = MUSB_EP0_STAGE_SETUP;
+ musb->ep0_state = MUSB_EP0_STAGE_IDLE;
finish:
musb_writew(regs, MUSB_CSR0,
musb->ackpend);
@@ -803,7 +836,7 @@ finish:
/* "can't happen" */
WARN_ON(1);
musb_writew(regs, MUSB_CSR0, MUSB_CSR0_P_SENDSTALL);
- musb->ep0_state = MUSB_EP0_STAGE_SETUP;
+ musb->ep0_state = MUSB_EP0_STAGE_IDLE;
break;
}
@@ -959,7 +992,7 @@ static int musb_g_ep0_halt(struct usb_ep *e, int value)
csr |= MUSB_CSR0_P_SENDSTALL;
musb_writew(regs, MUSB_CSR0, csr);
- musb->ep0_state = MUSB_EP0_STAGE_SETUP;
+ musb->ep0_state = MUSB_EP0_STAGE_IDLE;
musb->ackpend = 0;
break;
default:
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index db1b57415ec7..94a2a350a414 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -181,6 +181,19 @@ static inline void musb_h_tx_dma_start(struct musb_hw_ep *ep)
musb_writew(ep->regs, MUSB_TXCSR, txcsr);
}
+static void musb_ep_set_qh(struct musb_hw_ep *ep, int is_in, struct musb_qh *qh)
+{
+ if (is_in != 0 || ep->is_shared_fifo)
+ ep->in_qh = qh;
+ if (is_in == 0 || ep->is_shared_fifo)
+ ep->out_qh = qh;
+}
+
+static struct musb_qh *musb_ep_get_qh(struct musb_hw_ep *ep, int is_in)
+{
+ return is_in ? ep->in_qh : ep->out_qh;
+}
+
/*
* Start the URB at the front of an endpoint's queue
* end must be claimed from the caller.
@@ -210,7 +223,6 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
case USB_ENDPOINT_XFER_CONTROL:
/* control transfers always start with SETUP */
is_in = 0;
- hw_ep->out_qh = qh;
musb->ep0_stage = MUSB_EP0_START;
buf = urb->setup_packet;
len = 8;
@@ -239,10 +251,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
epnum, buf + offset, len);
/* Configure endpoint */
- if (is_in || hw_ep->is_shared_fifo)
- hw_ep->in_qh = qh;
- else
- hw_ep->out_qh = qh;
+ musb_ep_set_qh(hw_ep, is_in, qh);
musb_ep_program(musb, epnum, urb, !is_in, buf, offset, len);
/* transmit may have more work: start it when it is time */
@@ -286,9 +295,8 @@ start:
}
}
-/* caller owns controller lock, irqs are blocked */
-static void
-__musb_giveback(struct musb *musb, struct urb *urb, int status)
+/* Context: caller owns controller lock, IRQs are blocked */
+static void musb_giveback(struct musb *musb, struct urb *urb, int status)
__releases(musb->lock)
__acquires(musb->lock)
{
@@ -321,60 +329,57 @@ __acquires(musb->lock)
spin_lock(&musb->lock);
}
-/* for bulk/interrupt endpoints only */
-static inline void
-musb_save_toggle(struct musb_hw_ep *ep, int is_in, struct urb *urb)
+/* For bulk/interrupt endpoints only */
+static inline void musb_save_toggle(struct musb_qh *qh, int is_in,
+ struct urb *urb)
{
- struct usb_device *udev = urb->dev;
+ void __iomem *epio = qh->hw_ep->regs;
u16 csr;
- void __iomem *epio = ep->regs;
- struct musb_qh *qh;
- /* FIXME: the current Mentor DMA code seems to have
+ /*
+ * FIXME: the current Mentor DMA code seems to have
* problems getting toggle correct.
*/
- if (is_in || ep->is_shared_fifo)
- qh = ep->in_qh;
+ if (is_in)
+ csr = musb_readw(epio, MUSB_RXCSR) & MUSB_RXCSR_H_DATATOGGLE;
else
- qh = ep->out_qh;
+ csr = musb_readw(epio, MUSB_TXCSR) & MUSB_TXCSR_H_DATATOGGLE;
- if (!is_in) {
- csr = musb_readw(epio, MUSB_TXCSR);
- usb_settoggle(udev, qh->epnum, 1,
- (csr & MUSB_TXCSR_H_DATATOGGLE)
- ? 1 : 0);
- } else {
- csr = musb_readw(epio, MUSB_RXCSR);
- usb_settoggle(udev, qh->epnum, 0,
- (csr & MUSB_RXCSR_H_DATATOGGLE)
- ? 1 : 0);
- }
+ usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0);
}
-/* caller owns controller lock, irqs are blocked */
-static struct musb_qh *
-musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
+/*
+ * Advance this hardware endpoint's queue, completing the specified URB and
+ * advancing to either the next URB queued to that qh, or else invalidating
+ * that qh and advancing to the next qh scheduled after the current one.
+ *
+ * Context: caller owns controller lock, IRQs are blocked
+ */
+static void musb_advance_schedule(struct musb *musb, struct urb *urb,
+ struct musb_hw_ep *hw_ep, int is_in)
{
+ struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in);
struct musb_hw_ep *ep = qh->hw_ep;
- struct musb *musb = ep->musb;
- int is_in = usb_pipein(urb->pipe);
int ready = qh->is_ready;
+ int status;
+
+ status = (urb->status == -EINPROGRESS) ? 0 : urb->status;
/* save toggle eagerly, for paranoia */
switch (qh->type) {
case USB_ENDPOINT_XFER_BULK:
case USB_ENDPOINT_XFER_INT:
- musb_save_toggle(ep, is_in, urb);
+ musb_save_toggle(qh, is_in, urb);
break;
case USB_ENDPOINT_XFER_ISOC:
- if (status == 0 && urb->error_count)
+ if (urb->error_count)
status = -EXDEV;
break;
}
qh->is_ready = 0;
- __musb_giveback(musb, urb, status);
+ musb_giveback(musb, urb, status);
qh->is_ready = ready;
/* reclaim resources (and bandwidth) ASAP; deschedule it, and
@@ -388,11 +393,8 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
else
ep->tx_reinit = 1;
- /* clobber old pointers to this qh */
- if (is_in || ep->is_shared_fifo)
- ep->in_qh = NULL;
- else
- ep->out_qh = NULL;
+ /* Clobber old pointers to this qh */
+ musb_ep_set_qh(ep, is_in, NULL);
qh->hep->hcpriv = NULL;
switch (qh->type) {
@@ -421,36 +423,10 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
break;
}
}
- return qh;
-}
-
-/*
- * Advance this hardware endpoint's queue, completing the specified urb and
- * advancing to either the next urb queued to that qh, or else invalidating
- * that qh and advancing to the next qh scheduled after the current one.
- *
- * Context: caller owns controller lock, irqs are blocked
- */
-static void
-musb_advance_schedule(struct musb *musb, struct urb *urb,
- struct musb_hw_ep *hw_ep, int is_in)
-{
- struct musb_qh *qh;
-
- if (is_in || hw_ep->is_shared_fifo)
- qh = hw_ep->in_qh;
- else
- qh = hw_ep->out_qh;
-
- if (urb->status == -EINPROGRESS)
- qh = musb_giveback(qh, urb, 0);
- else
- qh = musb_giveback(qh, urb, urb->status);
if (qh != NULL && qh->is_ready) {
DBG(4, "... next ep%d %cX urb %p\n",
- hw_ep->epnum, is_in ? 'R' : 'T',
- next_urb(qh));
+ hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
musb_start_urb(musb, is_in, qh);
}
}
@@ -629,7 +605,8 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)
musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg);
musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg);
/* NOTE: bulk combining rewrites high bits of maxpacket */
- musb_writew(ep->regs, MUSB_RXMAXP, qh->maxpacket);
+ musb_writew(ep->regs, MUSB_RXMAXP,
+ qh->maxpacket | ((qh->hb_mult - 1) << 11));
ep->rx_reinit = 0;
}
@@ -651,9 +628,10 @@ static bool musb_tx_dma_program(struct dma_controller *dma,
csr = musb_readw(epio, MUSB_TXCSR);
if (length > pkt_size) {
mode = 1;
- csr |= MUSB_TXCSR_AUTOSET
- | MUSB_TXCSR_DMAMODE
- | MUSB_TXCSR_DMAENAB;
+ csr |= MUSB_TXCSR_DMAMODE | MUSB_TXCSR_DMAENAB;
+ /* autoset shouldn't be set in high bandwidth */
+ if (qh->hb_mult == 1)
+ csr |= MUSB_TXCSR_AUTOSET;
} else {
mode = 0;
csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAMODE);
@@ -703,15 +681,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
void __iomem *mbase = musb->mregs;
struct musb_hw_ep *hw_ep = musb->endpoints + epnum;
void __iomem *epio = hw_ep->regs;
- struct musb_qh *qh;
- u16 packet_sz;
-
- if (!is_out || hw_ep->is_shared_fifo)
- qh = hw_ep->in_qh;
- else
- qh = hw_ep->out_qh;
-
- packet_sz = qh->maxpacket;
+ struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out);
+ u16 packet_sz = qh->maxpacket;
DBG(3, "%s hw%d urb %p spd%d dev%d ep%d%s "
"h_addr%02x h_port%02x bytes %d\n",
@@ -1129,17 +1100,14 @@ void musb_host_tx(struct musb *musb, u8 epnum)
u16 tx_csr;
size_t length = 0;
size_t offset = 0;
- struct urb *urb;
struct musb_hw_ep *hw_ep = musb->endpoints + epnum;
void __iomem *epio = hw_ep->regs;
- struct musb_qh *qh = hw_ep->is_shared_fifo ? hw_ep->in_qh
- : hw_ep->out_qh;
+ struct musb_qh *qh = hw_ep->out_qh;
+ struct urb *urb = next_urb(qh);
u32 status = 0;
void __iomem *mbase = musb->mregs;
struct dma_channel *dma;
- urb = next_urb(qh);
-
musb_ep_select(mbase, epnum);
tx_csr = musb_readw(epio, MUSB_TXCSR);
@@ -1427,7 +1395,7 @@ static void musb_bulk_rx_nak_timeout(struct musb *musb, struct musb_hw_ep *ep)
urb->actual_length += dma->actual_len;
dma->actual_len = 0L;
}
- musb_save_toggle(ep, 1, urb);
+ musb_save_toggle(cur_qh, 1, urb);
/* move cur_qh to end of queue */
list_move_tail(&cur_qh->ring, &musb->in_bulk);
@@ -1531,6 +1499,10 @@ void musb_host_rx(struct musb *musb, u8 epnum)
/* packet error reported later */
iso_err = true;
}
+ } else if (rx_csr & MUSB_RXCSR_INCOMPRX) {
+ DBG(3, "end %d high bandwidth incomplete ISO packet RX\n",
+ epnum);
+ status = -EPROTO;
}
/* faults abort the transfer */
@@ -1738,7 +1710,11 @@ void musb_host_rx(struct musb *musb, u8 epnum)
val &= ~MUSB_RXCSR_H_AUTOREQ;
else
val |= MUSB_RXCSR_H_AUTOREQ;
- val |= MUSB_RXCSR_AUTOCLEAR | MUSB_RXCSR_DMAENAB;
+ val |= MUSB_RXCSR_DMAENAB;
+
+ /* autoclear shouldn't be set in high bandwidth */
+ if (qh->hb_mult == 1)
+ val |= MUSB_RXCSR_AUTOCLEAR;
musb_writew(epio, MUSB_RXCSR,
MUSB_RXCSR_H_WZC_BITS | val);
@@ -1817,19 +1793,17 @@ static int musb_schedule(
epnum++, hw_ep++) {
int diff;
- if (is_in || hw_ep->is_shared_fifo) {
- if (hw_ep->in_qh != NULL)
- continue;
- } else if (hw_ep->out_qh != NULL)
+ if (musb_ep_get_qh(hw_ep, is_in) != NULL)
continue;
if (hw_ep == musb->bulk_ep)
continue;
if (is_in)
- diff = hw_ep->max_packet_sz_rx - qh->maxpacket;
+ diff = hw_ep->max_packet_sz_rx;
else
- diff = hw_ep->max_packet_sz_tx - qh->maxpacket;
+ diff = hw_ep->max_packet_sz_tx;
+ diff -= (qh->maxpacket * qh->hb_mult);
if (diff >= 0 && best_diff > diff) {
best_diff = diff;
@@ -1932,15 +1906,27 @@ static int musb_urb_enqueue(
qh->is_ready = 1;
qh->maxpacket = le16_to_cpu(epd->wMaxPacketSize);
+ qh->type = usb_endpoint_type(epd);
- /* no high bandwidth support yet */
- if (qh->maxpacket & ~0x7ff) {
- ret = -EMSGSIZE;
- goto done;
+ /* Bits 11 & 12 of wMaxPacketSize encode high bandwidth multiplier.
+ * Some musb cores don't support high bandwidth ISO transfers; and
+ * we don't (yet!) support high bandwidth interrupt transfers.
+ */
+ qh->hb_mult = 1 + ((qh->maxpacket >> 11) & 0x03);
+ if (qh->hb_mult > 1) {
+ int ok = (qh->type == USB_ENDPOINT_XFER_ISOC);
+
+ if (ok)
+ ok = (usb_pipein(urb->pipe) && musb->hb_iso_rx)
+ || (usb_pipeout(urb->pipe) && musb->hb_iso_tx);
+ if (!ok) {
+ ret = -EMSGSIZE;
+ goto done;
+ }
+ qh->maxpacket &= 0x7ff;
}
qh->epnum = usb_endpoint_num(epd);
- qh->type = usb_endpoint_type(epd);
/* NOTE: urb->dev->devnum is wrong during SET_ADDRESS */
qh->addr_reg = (u8) usb_pipedevice(urb->pipe);
@@ -2052,14 +2038,15 @@ done:
* called with controller locked, irqs blocked
* that hardware queue advances to the next transfer, unless prevented
*/
-static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh, int is_in)
+static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
{
struct musb_hw_ep *ep = qh->hw_ep;
void __iomem *epio = ep->regs;
unsigned hw_end = ep->epnum;
void __iomem *regs = ep->musb->mregs;
- u16 csr;
+ int is_in = usb_pipein(urb->pipe);
int status = 0;
+ u16 csr;
musb_ep_select(regs, hw_end);
@@ -2112,14 +2099,14 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
struct musb *musb = hcd_to_musb(hcd);
struct musb_qh *qh;
- struct list_head *sched;
unsigned long flags;
+ int is_in = usb_pipein(urb->pipe);
int ret;
DBG(4, "urb=%p, dev%d ep%d%s\n", urb,
usb_pipedevice(urb->pipe),
usb_pipeendpoint(urb->pipe),
- usb_pipein(urb->pipe) ? "in" : "out");
+ is_in ? "in" : "out");
spin_lock_irqsave(&musb->lock, flags);
ret = usb_hcd_check_unlink_urb(hcd, urb, status);
@@ -2130,47 +2117,25 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
if (!qh)
goto done;
- /* Any URB not actively programmed into endpoint hardware can be
+ /*
+ * Any URB not actively programmed into endpoint hardware can be
* immediately given back; that's any URB not at the head of an
* endpoint queue, unless someday we get real DMA queues. And even
* if it's at the head, it might not be known to the hardware...
*
- * Otherwise abort current transfer, pending dma, etc.; urb->status
+ * Otherwise abort current transfer, pending DMA, etc.; urb->status
* has already been updated. This is a synchronous abort; it'd be
* OK to hold off until after some IRQ, though.
+ *
+ * NOTE: qh is invalid unless !list_empty(&hep->urb_list)
*/
- if (!qh->is_ready || urb->urb_list.prev != &qh->hep->urb_list)
- ret = -EINPROGRESS;
- else {
- switch (qh->type) {
- case USB_ENDPOINT_XFER_CONTROL:
- sched = &musb->control;
- break;
- case USB_ENDPOINT_XFER_BULK:
- if (qh->mux == 1) {
- if (usb_pipein(urb->pipe))
- sched = &musb->in_bulk;
- else
- sched = &musb->out_bulk;
- break;
- }
- default:
- /* REVISIT when we get a schedule tree, periodic
- * transfers won't always be at the head of a
- * singleton queue...
- */
- sched = NULL;
- break;
- }
- }
-
- /* NOTE: qh is invalid unless !list_empty(&hep->urb_list) */
- if (ret < 0 || (sched && qh != first_qh(sched))) {
+ if (!qh->is_ready
+ || urb->urb_list.prev != &qh->hep->urb_list
+ || musb_ep_get_qh(qh->hw_ep, is_in) != qh) {
int ready = qh->is_ready;
- ret = 0;
qh->is_ready = 0;
- __musb_giveback(musb, urb, 0);
+ musb_giveback(musb, urb, 0);
qh->is_ready = ready;
/* If nothing else (usually musb_giveback) is using it
@@ -2182,7 +2147,7 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
kfree(qh);
}
} else
- ret = musb_cleanup_urb(urb, qh, urb->pipe & USB_DIR_IN);
+ ret = musb_cleanup_urb(urb, qh);
done:
spin_unlock_irqrestore(&musb->lock, flags);
return ret;
@@ -2192,13 +2157,11 @@ done:
static void
musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
{
- u8 epnum = hep->desc.bEndpointAddress;
+ u8 is_in = hep->desc.bEndpointAddress & USB_DIR_IN;
unsigned long flags;
struct musb *musb = hcd_to_musb(hcd);
- u8 is_in = epnum & USB_DIR_IN;
struct musb_qh *qh;
struct urb *urb;
- struct list_head *sched;
spin_lock_irqsave(&musb->lock, flags);
@@ -2206,31 +2169,11 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
if (qh == NULL)
goto exit;
- switch (qh->type) {
- case USB_ENDPOINT_XFER_CONTROL:
- sched = &musb->control;
- break;
- case USB_ENDPOINT_XFER_BULK:
- if (qh->mux == 1) {
- if (is_in)
- sched = &musb->in_bulk;
- else
- sched = &musb->out_bulk;
- break;
- }
- default:
- /* REVISIT when we get a schedule tree, periodic transfers
- * won't always be at the head of a singleton queue...
- */
- sched = NULL;
- break;
- }
-
- /* NOTE: qh is invalid unless !list_empty(&hep->urb_list) */
+ /* NOTE: qh is invalid unless !list_empty(&hep->urb_list) */
- /* kick first urb off the hardware, if needed */
+ /* Kick the first URB off the hardware, if needed */
qh->is_ready = 0;
- if (!sched || qh == first_qh(sched)) {
+ if (musb_ep_get_qh(qh->hw_ep, is_in) == qh) {
urb = next_urb(qh);
/* make software (then hardware) stop ASAP */
@@ -2238,7 +2181,7 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
urb->status = -ESHUTDOWN;
/* cleanup */
- musb_cleanup_urb(urb, qh, urb->pipe & USB_DIR_IN);
+ musb_cleanup_urb(urb, qh);
/* Then nuke all the others ... and advance the
* queue on hw_ep (e.g. bulk ring) when we're done.
@@ -2254,7 +2197,7 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
* will activate any of these as it advances.
*/
while (!list_empty(&hep->urb_list))
- __musb_giveback(musb, next_urb(qh), -ESHUTDOWN);
+ musb_giveback(musb, next_urb(qh), -ESHUTDOWN);
hep->hcpriv = NULL;
list_del(&qh->ring);
@@ -2293,7 +2236,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
{
struct musb *musb = hcd_to_musb(hcd);
- if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
+ if (musb->xceiv->state == OTG_STATE_A_SUSPEND)
return 0;
if (is_host_active(musb) && musb->is_active) {
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 0b7fbcd21963..14b00776638d 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -67,6 +67,7 @@ struct musb_qh {
u8 is_ready; /* safe to modify hw_ep */
u8 type; /* XFERTYPE_* */
u8 epnum;
+ u8 hb_mult; /* high bandwidth pkts per uf */
u16 maxpacket;
u16 frame; /* for periodic schedule */
unsigned iso_idx; /* in urb->iso_frame_desc[] */
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index bf677acc83db..bfe5fe4ebfee 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -78,18 +78,22 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend)
DBG(3, "Root port suspended, power %02x\n", power);
musb->port1_status |= USB_PORT_STAT_SUSPEND;
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_HOST:
- musb->xceiv.state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->state = OTG_STATE_A_SUSPEND;
musb->is_active = is_otg_enabled(musb)
- && musb->xceiv.host->b_hnp_enable;
+ && musb->xceiv->host->b_hnp_enable;
+ if (musb->is_active)
+ mod_timer(&musb->otg_timer, jiffies
+ + msecs_to_jiffies(
+ OTG_TIME_A_AIDL_BDIS));
musb_platform_try_idle(musb, 0);
break;
#ifdef CONFIG_USB_MUSB_OTG
case OTG_STATE_B_HOST:
- musb->xceiv.state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = is_otg_enabled(musb)
- && musb->xceiv.host->b_hnp_enable;
+ && musb->xceiv->host->b_hnp_enable;
musb_platform_try_idle(musb, 0);
break;
#endif
@@ -116,7 +120,7 @@ static void musb_port_reset(struct musb *musb, bool do_reset)
void __iomem *mbase = musb->mregs;
#ifdef CONFIG_USB_MUSB_OTG
- if (musb->xceiv.state == OTG_STATE_B_IDLE) {
+ if (musb->xceiv->state == OTG_STATE_B_IDLE) {
DBG(2, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET;
return;
@@ -186,14 +190,23 @@ void musb_root_disconnect(struct musb *musb)
usb_hcd_poll_rh_status(musb_to_hcd(musb));
musb->is_active = 0;
- switch (musb->xceiv.state) {
- case OTG_STATE_A_HOST:
+ switch (musb->xceiv->state) {
case OTG_STATE_A_SUSPEND:
- musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
+#ifdef CONFIG_USB_MUSB_OTG
+ if (is_otg_enabled(musb)
+ && musb->xceiv->host->b_hnp_enable) {
+ musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->g.is_a_peripheral = 1;
+ break;
+ }
+#endif
+ /* FALLTHROUGH */
+ case OTG_STATE_A_HOST:
+ musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
break;
default:
DBG(1, "host disconnect (%s)\n", otg_state_string(musb));
@@ -332,7 +345,7 @@ int musb_hub_control(
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb_to_hcd(musb));
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv.state = OTG_STATE_A_HOST;
+ musb->xceiv->state = OTG_STATE_A_HOST;
}
put_unaligned(cpu_to_le32(musb->port1_status
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 60924ce08493..48930f25c450 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -44,7 +44,6 @@
#define get_cpu_rev() 2
#endif
-#define MUSB_TIMEOUT_A_WAIT_BCON 1100
static struct timer_list musb_idle_timer;
@@ -61,17 +60,17 @@ static void musb_do_idle(unsigned long _musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -89,7 +88,7 @@ static void musb_do_idle(unsigned long _musb)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb_to_hcd(musb));
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv.state = OTG_STATE_A_HOST;
+ musb->xceiv->state = OTG_STATE_A_HOST;
}
break;
#endif
@@ -97,9 +96,9 @@ static void musb_do_idle(unsigned long _musb)
case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
else
- musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
#endif
default:
break;
@@ -118,7 +117,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv.state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
del_timer(&musb_idle_timer);
last_timer = jiffies;
@@ -163,8 +162,8 @@ static void omap_set_vbus(struct musb *musb, int is_on)
if (is_on) {
musb->is_active = 1;
- musb->xceiv.default_a = 1;
- musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->default_a = 1;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
@@ -175,8 +174,8 @@ static void omap_set_vbus(struct musb *musb, int is_on)
* jumping right to B_IDLE...
*/
- musb->xceiv.default_a = 0;
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->default_a = 0;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION;
MUSB_DEV_MODE(musb);
@@ -188,10 +187,6 @@ static void omap_set_vbus(struct musb *musb, int is_on)
otg_state_string(musb),
musb_readb(musb->mregs, MUSB_DEVCTL));
}
-static int omap_set_power(struct otg_transceiver *x, unsigned mA)
-{
- return 0;
-}
static int musb_platform_resume(struct musb *musb);
@@ -202,24 +197,6 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
- switch (musb_mode) {
-#ifdef CONFIG_USB_MUSB_HDRC_HCD
- case MUSB_HOST:
- otg_set_host(&musb->xceiv, musb->xceiv.host);
- break;
-#endif
-#ifdef CONFIG_USB_GADGET_MUSB_HDRC
- case MUSB_PERIPHERAL:
- otg_set_peripheral(&musb->xceiv, musb->xceiv.gadget);
- break;
-#endif
-#ifdef CONFIG_USB_MUSB_OTG
- case MUSB_OTG:
- break;
-#endif
- default:
- return -EINVAL;
- }
return 0;
}
@@ -231,6 +208,16 @@ int __init musb_platform_init(struct musb *musb)
omap_cfg_reg(AE5_2430_USB0HS_STP);
#endif
+ /* We require some kind of external transceiver, hooked
+ * up through ULPI. TWL4030-family PMICs include one,
+ * which needs a driver, drivers aren't always needed.
+ */
+ musb->xceiv = otg_get_transceiver();
+ if (!musb->xceiv) {
+ pr_err("HS USB OTG: no transceiver configured\n");
+ return -ENODEV;
+ }
+
musb_platform_resume(musb);
l = omap_readl(OTG_SYSCONFIG);
@@ -257,9 +244,6 @@ int __init musb_platform_init(struct musb *musb)
if (is_host_enabled(musb))
musb->board_set_vbus = omap_set_vbus;
- if (is_peripheral_enabled(musb))
- musb->xceiv.set_power = omap_set_power;
- musb->a_wait_bcon = MUSB_TIMEOUT_A_WAIT_BCON;
setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
@@ -282,8 +266,7 @@ int musb_platform_suspend(struct musb *musb)
l |= ENABLEWAKEUP; /* enable wakeup */
omap_writel(l, OTG_SYSCONFIG);
- if (musb->xceiv.set_suspend)
- musb->xceiv.set_suspend(&musb->xceiv, 1);
+ otg_set_suspend(musb->xceiv, 1);
if (musb->set_clock)
musb->set_clock(musb->clock, 0);
@@ -300,8 +283,7 @@ static int musb_platform_resume(struct musb *musb)
if (!musb->clock)
return 0;
- if (musb->xceiv.set_suspend)
- musb->xceiv.set_suspend(&musb->xceiv, 0);
+ otg_set_suspend(musb->xceiv, 0);
if (musb->set_clock)
musb->set_clock(musb->clock, 1);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 4ac1477d3569..88b587c703e9 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -259,6 +259,8 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf)
tusb_fifo_read_unaligned(fifo, buf, len);
}
+static struct musb *the_musb;
+
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
/* This is used by gadget drivers, and OTG transceiver logic, allowing
@@ -269,7 +271,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf)
*/
static int tusb_draw_power(struct otg_transceiver *x, unsigned mA)
{
- struct musb *musb = container_of(x, struct musb, xceiv);
+ struct musb *musb = the_musb;
void __iomem *tbase = musb->ctrl_base;
u32 reg;
@@ -419,7 +421,7 @@ static void musb_do_idle(unsigned long _musb)
spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_WAIT_BCON:
if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0
@@ -483,7 +485,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv.state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
del_timer(&musb_idle_timer);
last_timer = jiffies;
@@ -532,8 +534,8 @@ static void tusb_source_power(struct musb *musb, int is_on)
if (musb->set_clock)
musb->set_clock(musb->clock, 1);
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
- musb->xceiv.default_a = 1;
- musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->default_a = 1;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
conf |= TUSB_DEV_CONF_USB_HOST_MODE;
@@ -546,24 +548,24 @@ static void tusb_source_power(struct musb *musb, int is_on)
/* If ID pin is grounded, we want to be a_idle */
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON:
- musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
break;
default:
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv->state = OTG_STATE_A_IDLE;
}
musb->is_active = 0;
- musb->xceiv.default_a = 1;
+ musb->xceiv->default_a = 1;
MUSB_HST_MODE(musb);
} else {
musb->is_active = 0;
- musb->xceiv.default_a = 0;
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->default_a = 0;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
}
@@ -674,7 +676,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
else
default_a = is_host_enabled(musb);
DBG(2, "Default-%c\n", default_a ? 'A' : 'B');
- musb->xceiv.default_a = default_a;
+ musb->xceiv->default_a = default_a;
tusb_source_power(musb, default_a);
/* Don't allow idling immediately */
@@ -686,7 +688,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) {
/* B-dev state machine: no vbus ~= disconnect */
- if ((is_otg_enabled(musb) && !musb->xceiv.default_a)
+ if ((is_otg_enabled(musb) && !musb->xceiv->default_a)
|| !is_host_enabled(musb)) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
/* ? musb_root_disconnect(musb); */
@@ -701,9 +703,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
DBG(1, "Forcing disconnect (no interrupt)\n");
- if (musb->xceiv.state != OTG_STATE_B_IDLE) {
+ if (musb->xceiv->state != OTG_STATE_B_IDLE) {
/* INTR_DISCONNECT can hide... */
- musb->xceiv.state = OTG_STATE_B_IDLE;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
musb->int_usb |= MUSB_INTR_DISCONNECT;
}
musb->is_active = 0;
@@ -717,7 +719,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
DBG(2, "vbus change, %s, otg %03x\n",
otg_state_string(musb), otg_stat);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_IDLE:
DBG(2, "Got SRP, turning on VBUS\n");
musb_set_vbus(musb, 1);
@@ -765,7 +767,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
DBG(4, "%s timer, %03x\n", otg_state_string(musb), otg_stat);
- switch (musb->xceiv.state) {
+ switch (musb->xceiv->state) {
case OTG_STATE_A_WAIT_VRISE:
/* VBUS has probably been valid for a while now,
* but may well have bounced out of range a bit
@@ -777,7 +779,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
DBG(2, "devctl %02x\n", devctl);
break;
}
- musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon);
@@ -1093,9 +1095,14 @@ int __init musb_platform_init(struct musb *musb)
{
struct platform_device *pdev;
struct resource *mem;
- void __iomem *sync;
+ void __iomem *sync = NULL;
int ret;
+ usb_nop_xceiv_register();
+ musb->xceiv = otg_get_transceiver();
+ if (!musb->xceiv)
+ return -ENODEV;
+
pdev = to_platform_device(musb->controller);
/* dma address for async dma */
@@ -1106,14 +1113,16 @@ int __init musb_platform_init(struct musb *musb)
mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!mem) {
pr_debug("no sync dma resource?\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto done;
}
musb->sync = mem->start;
sync = ioremap(mem->start, mem->end - mem->start + 1);
if (!sync) {
pr_debug("ioremap for sync failed\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto done;
}
musb->sync_va = sync;
@@ -1126,28 +1135,37 @@ int __init musb_platform_init(struct musb *musb)
if (ret) {
printk(KERN_ERR "Could not start tusb6010 (%d)\n",
ret);
- return -ENODEV;
+ goto done;
}
musb->isr = tusb_interrupt;
if (is_host_enabled(musb))
musb->board_set_vbus = tusb_source_power;
- if (is_peripheral_enabled(musb))
- musb->xceiv.set_power = tusb_draw_power;
+ if (is_peripheral_enabled(musb)) {
+ musb->xceiv->set_power = tusb_draw_power;
+ the_musb = musb;
+ }
setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
+done:
+ if (ret < 0) {
+ if (sync)
+ iounmap(sync);
+ usb_nop_xceiv_unregister();
+ }
return ret;
}
int musb_platform_exit(struct musb *musb)
{
del_timer_sync(&musb_idle_timer);
+ the_musb = NULL;
if (musb->board_set_power)
musb->board_set_power(0);
iounmap(musb->sync_va);
-
+ usb_nop_xceiv_unregister();
return 0;
}
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index c567168f89af..9ed5ea568679 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -22,8 +22,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Current status:
- * this is to add "nop" transceiver for all those phy which is
- * autonomous such as isp1504 etc.
+ * This provides a "nop" transceiver for PHYs which are
+ * autonomous such as isp1504, isp1707, etc.
*/
#include <linux/module.h>
@@ -36,30 +36,25 @@ struct nop_usb_xceiv {
struct device *dev;
};
-static u64 nop_xceiv_dmamask = DMA_BIT_MASK(32);
-
-static struct platform_device nop_xceiv_device = {
- .name = "nop_usb_xceiv",
- .id = -1,
- .dev = {
- .dma_mask = &nop_xceiv_dmamask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- .platform_data = NULL,
- },
-};
+static struct platform_device *pd;
void usb_nop_xceiv_register(void)
{
- if (platform_device_register(&nop_xceiv_device) < 0) {
+ if (pd)
+ return;
+ pd = platform_device_register_simple("nop_usb_xceiv", -1, NULL, 0);
+ if (!pd) {
printk(KERN_ERR "Unable to register usb nop transceiver\n");
return;
}
}
+EXPORT_SYMBOL(usb_nop_xceiv_register);
void usb_nop_xceiv_unregister(void)
{
- platform_device_unregister(&nop_xceiv_device);
+ platform_device_unregister(pd);
}
+EXPORT_SYMBOL(usb_nop_xceiv_unregister);
static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x)
{
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index d9478d0e1c8b..9e3e7a5c258b 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -217,6 +217,7 @@
/* In module TWL4030_MODULE_PM_MASTER */
#define PROTECT_KEY 0x0E
+#define STS_HW_CONDITIONS 0x0F
/* In module TWL4030_MODULE_PM_RECEIVER */
#define VUSB_DEDICATED1 0x7D
@@ -351,15 +352,26 @@ static enum linkstat twl4030_usb_linkstat(struct twl4030_usb *twl)
int status;
int linkstat = USB_LINK_UNKNOWN;
- /* STS_HW_CONDITIONS */
- status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, 0x0f);
+ /*
+ * For ID/VBUS sensing, see manual section 15.4.8 ...
+ * except when using only battery backup power, two
+ * comparators produce VBUS_PRES and ID_PRES signals,
+ * which don't match docs elsewhere. But ... BIT(7)
+ * and BIT(2) of STS_HW_CONDITIONS, respectively, do
+ * seem to match up. If either is true the USB_PRES
+ * signal is active, the OTG module is activated, and
+ * its interrupt may be raised (may wake the system).
+ */
+ status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER,
+ STS_HW_CONDITIONS);
if (status < 0)
dev_err(twl->dev, "USB link status err %d\n", status);
- else if (status & BIT(7))
- linkstat = USB_LINK_VBUS;
- else if (status & BIT(2))
- linkstat = USB_LINK_ID;
- else
+ else if (status & (BIT(7) | BIT(2))) {
+ if (status & BIT(2))
+ linkstat = USB_LINK_ID;
+ else
+ linkstat = USB_LINK_VBUS;
+ } else
linkstat = USB_LINK_NONE;
dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n",
@@ -641,7 +653,7 @@ static int twl4030_set_host(struct otg_transceiver *x, struct usb_bus *host)
return 0;
}
-static int __init twl4030_usb_probe(struct platform_device *pdev)
+static int __devinit twl4030_usb_probe(struct platform_device *pdev)
{
struct twl4030_usb_data *pdata = pdev->dev.platform_data;
struct twl4030_usb *twl;
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index b7eacad4d48c..2bfd6dd85b5a 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -93,8 +93,7 @@ static int belkin_sa_startup(struct usb_serial *serial);
static void belkin_sa_shutdown(struct usb_serial *serial);
static int belkin_sa_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void belkin_sa_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void belkin_sa_close(struct usb_serial_port *port);
static void belkin_sa_read_int_callback(struct urb *urb);
static void belkin_sa_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios * old);
@@ -244,8 +243,7 @@ exit:
} /* belkin_sa_open */
-static void belkin_sa_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void belkin_sa_close(struct usb_serial_port *port)
{
dbg("%s port %d", __func__, port->number);
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index ab4cc277aa65..2830766f5b39 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -262,32 +262,40 @@ error: kfree(priv);
return r;
}
-static void ch341_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static int ch341_carrier_raised(struct usb_serial_port *port)
+{
+ struct ch341_private *priv = usb_get_serial_port_data(port);
+ if (priv->line_status & CH341_BIT_DCD)
+ return 1;
+ return 0;
+}
+
+static void ch341_dtr_rts(struct usb_serial_port *port, int on)
{
struct ch341_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
- unsigned int c_cflag;
dbg("%s - port %d", __func__, port->number);
+ /* drop DTR and RTS */
+ spin_lock_irqsave(&priv->lock, flags);
+ if (on)
+ priv->line_control |= CH341_BIT_RTS | CH341_BIT_DTR;
+ else
+ priv->line_control &= ~(CH341_BIT_RTS | CH341_BIT_DTR);
+ spin_unlock_irqrestore(&priv->lock, flags);
+ ch341_set_handshake(port->serial->dev, priv->line_control);
+ wake_up_interruptible(&priv->delta_msr_wait);
+}
+
+static void ch341_close(struct usb_serial_port *port)
+{
+ dbg("%s - port %d", __func__, port->number);
/* shutdown our urbs */
dbg("%s - shutting down urbs", __func__);
usb_kill_urb(port->write_urb);
usb_kill_urb(port->read_urb);
usb_kill_urb(port->interrupt_in_urb);
-
- if (tty) {
- c_cflag = tty->termios->c_cflag;
- if (c_cflag & HUPCL) {
- /* drop DTR and RTS */
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
- ch341_set_handshake(port->serial->dev, 0);
- }
- }
- wake_up_interruptible(&priv->delta_msr_wait);
}
@@ -302,7 +310,6 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
dbg("ch341_open()");
priv->baud_rate = DEFAULT_BAUD_RATE;
- priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;
r = ch341_configure(serial->dev, priv);
if (r)
@@ -322,7 +329,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
if (r) {
dev_err(&port->dev, "%s - failed submitting interrupt urb,"
" error %d\n", __func__, r);
- ch341_close(tty, port, NULL);
+ ch341_close(port);
return -EPROTO;
}
@@ -343,9 +350,6 @@ static void ch341_set_termios(struct tty_struct *tty,
dbg("ch341_set_termios()");
- if (!tty || !tty->termios)
- return;
-
baud_rate = tty_get_baud_rate(tty);
priv->baud_rate = baud_rate;
@@ -568,6 +572,8 @@ static struct usb_serial_driver ch341_device = {
.usb_driver = &ch341_driver,
.num_ports = 1,
.open = ch341_open,
+ .dtr_rts = ch341_dtr_rts,
+ .carrier_raised = ch341_carrier_raised,
.close = ch341_close,
.ioctl = ch341_ioctl,
.set_termios = ch341_set_termios,
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 19e24045b137..247b61bfb7f4 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -169,7 +169,9 @@ static int usb_console_setup(struct console *co, char *options)
kfree(tty);
}
}
-
+ /* So we know not to kill the hardware on a hangup on this
+ port. We have also bumped the use count by one so it won't go
+ idle */
port->console = 1;
retval = 0;
@@ -182,7 +184,7 @@ free_tty:
kfree(tty);
reset_open_count:
port->port.count = 0;
-goto out;
+ goto out;
}
static void usb_console_write(struct console *co,
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index e8d5133ce9c8..d9f586dc6ecc 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -36,8 +36,7 @@
static int cp2101_open(struct tty_struct *, struct usb_serial_port *,
struct file *);
static void cp2101_cleanup(struct usb_serial_port *);
-static void cp2101_close(struct tty_struct *, struct usb_serial_port *,
- struct file*);
+static void cp2101_close(struct usb_serial_port *);
static void cp2101_get_termios(struct tty_struct *,
struct usb_serial_port *port);
static void cp2101_get_termios_port(struct usb_serial_port *port,
@@ -398,8 +397,7 @@ static void cp2101_cleanup(struct usb_serial_port *port)
}
}
-static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static void cp2101_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index dd501bb63ed6..933ba913e66c 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -61,8 +61,7 @@ static int cyberjack_startup(struct usb_serial *serial);
static void cyberjack_shutdown(struct usb_serial *serial);
static int cyberjack_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void cyberjack_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void cyberjack_close(struct usb_serial_port *port);
static int cyberjack_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count);
static int cyberjack_write_room(struct tty_struct *tty);
@@ -185,8 +184,7 @@ static int cyberjack_open(struct tty_struct *tty,
return result;
}
-static void cyberjack_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void cyberjack_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index e568710b263f..669f93848539 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -174,8 +174,8 @@ static int cypress_ca42v2_startup(struct usb_serial *serial);
static void cypress_shutdown(struct usb_serial *serial);
static int cypress_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void cypress_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void cypress_close(struct usb_serial_port *port);
+static void cypress_dtr_rts(struct usb_serial_port *port, int on);
static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static void cypress_send(struct usb_serial_port *port);
@@ -218,6 +218,7 @@ static struct usb_serial_driver cypress_earthmate_device = {
.shutdown = cypress_shutdown,
.open = cypress_open,
.close = cypress_close,
+ .dtr_rts = cypress_dtr_rts,
.write = cypress_write,
.write_room = cypress_write_room,
.ioctl = cypress_ioctl,
@@ -244,6 +245,7 @@ static struct usb_serial_driver cypress_hidcom_device = {
.shutdown = cypress_shutdown,
.open = cypress_open,
.close = cypress_close,
+ .dtr_rts = cypress_dtr_rts,
.write = cypress_write,
.write_room = cypress_write_room,
.ioctl = cypress_ioctl,
@@ -270,6 +272,7 @@ static struct usb_serial_driver cypress_ca42v2_device = {
.shutdown = cypress_shutdown,
.open = cypress_open,
.close = cypress_close,
+ .dtr_rts = cypress_dtr_rts,
.write = cypress_write,
.write_room = cypress_write_room,
.ioctl = cypress_ioctl,
@@ -656,11 +659,7 @@ static int cypress_open(struct tty_struct *tty,
priv->rx_flags = 0;
spin_unlock_irqrestore(&priv->lock, flags);
- /* raise both lines and set termios */
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control = CONTROL_DTR | CONTROL_RTS;
- priv->cmd_ctrl = 1;
- spin_unlock_irqrestore(&priv->lock, flags);
+ /* Set termios */
result = cypress_write(tty, port, NULL, 0);
if (result) {
@@ -694,76 +693,42 @@ static int cypress_open(struct tty_struct *tty,
__func__, result);
cypress_set_dead(port);
}
-
+ port->port.drain_delay = 256;
return result;
} /* cypress_open */
+static void cypress_dtr_rts(struct usb_serial_port *port, int on)
+{
+ struct cypress_private *priv = usb_get_serial_port_data(port);
+ /* drop dtr and rts */
+ priv = usb_get_serial_port_data(port);
+ spin_lock_irq(&priv->lock);
+ if (on == 0)
+ priv->line_control = 0;
+ else
+ priv->line_control = CONTROL_DTR | CONTROL_RTS;
+ priv->cmd_ctrl = 1;
+ spin_unlock_irq(&priv->lock);
+ cypress_write(NULL, port, NULL, 0);
+}
-static void cypress_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void cypress_close(struct usb_serial_port *port)
{
struct cypress_private *priv = usb_get_serial_port_data(port);
- unsigned int c_cflag;
- int bps;
- long timeout;
- wait_queue_t wait;
dbg("%s - port %d", __func__, port->number);
- /* wait for data to drain from buffer */
- spin_lock_irq(&priv->lock);
- timeout = CYPRESS_CLOSING_WAIT;
- init_waitqueue_entry(&wait, current);
- add_wait_queue(&tty->write_wait, &wait);
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (cypress_buf_data_avail(priv->buf) == 0
- || timeout == 0 || signal_pending(current)
- /* without mutex, allowed due to harmless failure mode */
- || port->serial->disconnected)
- break;
- spin_unlock_irq(&priv->lock);
- timeout = schedule_timeout(timeout);
- spin_lock_irq(&priv->lock);
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&tty->write_wait, &wait);
- /* clear out any remaining data in the buffer */
- cypress_buf_clear(priv->buf);
- spin_unlock_irq(&priv->lock);
-
/* writing is potentially harmful, lock must be taken */
mutex_lock(&port->serial->disc_mutex);
if (port->serial->disconnected) {
mutex_unlock(&port->serial->disc_mutex);
return;
}
- /* wait for characters to drain from device */
- if (tty) {
- bps = tty_get_baud_rate(tty);
- if (bps > 1200)
- timeout = max((HZ * 2560) / bps, HZ / 10);
- else
- timeout = 2 * HZ;
- schedule_timeout_interruptible(timeout);
- }
-
+ cypress_buf_clear(priv->buf);
dbg("%s - stopping urbs", __func__);
usb_kill_urb(port->interrupt_in_urb);
usb_kill_urb(port->interrupt_out_urb);
- if (tty) {
- c_cflag = tty->termios->c_cflag;
- if (c_cflag & HUPCL) {
- /* drop dtr and rts */
- priv = usb_get_serial_port_data(port);
- spin_lock_irq(&priv->lock);
- priv->line_control = 0;
- priv->cmd_ctrl = 1;
- spin_unlock_irq(&priv->lock);
- cypress_write(tty, port, NULL, 0);
- }
- }
if (stats)
dev_info(&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 38ba4ea8b6bf..30f5140eff03 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -422,7 +422,6 @@ struct digi_port {
int dp_throttled;
int dp_throttle_restart;
wait_queue_head_t dp_flush_wait;
- int dp_in_close; /* close in progress */
wait_queue_head_t dp_close_wait; /* wait queue for close */
struct work_struct dp_wakeup_work;
struct usb_serial_port *dp_port;
@@ -456,8 +455,9 @@ static int digi_write_room(struct tty_struct *tty);
static int digi_chars_in_buffer(struct tty_struct *tty);
static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
-static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void digi_close(struct usb_serial_port *port);
+static int digi_carrier_raised(struct usb_serial_port *port);
+static void digi_dtr_rts(struct usb_serial_port *port, int on);
static int digi_startup_device(struct usb_serial *serial);
static int digi_startup(struct usb_serial *serial);
static void digi_shutdown(struct usb_serial *serial);
@@ -510,6 +510,8 @@ static struct usb_serial_driver digi_acceleport_2_device = {
.num_ports = 3,
.open = digi_open,
.close = digi_close,
+ .dtr_rts = digi_dtr_rts,
+ .carrier_raised = digi_carrier_raised,
.write = digi_write,
.write_room = digi_write_room,
.write_bulk_callback = digi_write_bulk_callback,
@@ -1328,6 +1330,19 @@ static int digi_chars_in_buffer(struct tty_struct *tty)
}
+static void digi_dtr_rts(struct usb_serial_port *port, int on)
+{
+ /* Adjust DTR and RTS */
+ digi_set_modem_signals(port, on * (TIOCM_DTR|TIOCM_RTS), 1);
+}
+
+static int digi_carrier_raised(struct usb_serial_port *port)
+{
+ struct digi_port *priv = usb_get_serial_port_data(port);
+ if (priv->dp_modem_signals & TIOCM_CD)
+ return 1;
+ return 0;
+}
static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
@@ -1336,7 +1351,6 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
unsigned char buf[32];
struct digi_port *priv = usb_get_serial_port_data(port);
struct ktermios not_termios;
- unsigned long flags = 0;
dbg("digi_open: TOP: port=%d, open_count=%d",
priv->dp_port_num, port->port.count);
@@ -1345,26 +1359,6 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
if (digi_startup_device(port->serial) != 0)
return -ENXIO;
- spin_lock_irqsave(&priv->dp_port_lock, flags);
-
- /* don't wait on a close in progress for non-blocking opens */
- if (priv->dp_in_close && (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) {
- spin_unlock_irqrestore(&priv->dp_port_lock, flags);
- return -EAGAIN;
- }
-
- /* wait for a close in progress to finish */
- while (priv->dp_in_close) {
- cond_wait_interruptible_timeout_irqrestore(
- &priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
- &priv->dp_port_lock, flags);
- if (signal_pending(current))
- return -EINTR;
- spin_lock_irqsave(&priv->dp_port_lock, flags);
- }
-
- spin_unlock_irqrestore(&priv->dp_port_lock, flags);
-
/* read modem signals automatically whenever they change */
buf[0] = DIGI_CMD_READ_INPUT_SIGNALS;
buf[1] = priv->dp_port_num;
@@ -1387,16 +1381,11 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
not_termios.c_iflag = ~tty->termios->c_iflag;
digi_set_termios(tty, port, &not_termios);
}
-
- /* set DTR and RTS */
- digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1);
-
return 0;
}
-static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static void digi_close(struct usb_serial_port *port)
{
DEFINE_WAIT(wait);
int ret;
@@ -1411,28 +1400,9 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
if (port->serial->disconnected)
goto exit;
- /* do cleanup only after final close on this port */
- spin_lock_irq(&priv->dp_port_lock);
- priv->dp_in_close = 1;
- spin_unlock_irq(&priv->dp_port_lock);
-
- /* tell line discipline to process only XON/XOFF */
- tty->closing = 1;
-
- /* wait for output to drain */
- if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0)
- tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT);
-
- /* flush driver and line discipline buffers */
- tty_driver_flush_buffer(tty);
- tty_ldisc_flush(tty);
-
if (port->serial->dev) {
- /* wait for transmit idle */
- if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0)
- digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT);
- /* drop DTR and RTS */
- digi_set_modem_signals(port, 0, 0);
+ /* FIXME: Transmit idle belongs in the wait_unti_sent path */
+ digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT);
/* disable input flow control */
buf[0] = DIGI_CMD_SET_INPUT_FLOW_CONTROL;
@@ -1477,11 +1447,9 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
/* shutdown any outstanding bulk writes */
usb_kill_urb(port->write_urb);
}
- tty->closing = 0;
exit:
spin_lock_irq(&priv->dp_port_lock);
priv->dp_write_urb_in_use = 0;
- priv->dp_in_close = 0;
wake_up_interruptible(&priv->dp_close_wait);
spin_unlock_irq(&priv->dp_port_lock);
mutex_unlock(&port->serial->disc_mutex);
@@ -1560,7 +1528,6 @@ static int digi_startup(struct usb_serial *serial)
priv->dp_throttled = 0;
priv->dp_throttle_restart = 0;
init_waitqueue_head(&priv->dp_flush_wait);
- priv->dp_in_close = 0;
init_waitqueue_head(&priv->dp_close_wait);
INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
priv->dp_port = serial->port[i];
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index c709ec474a80..2b141ccb0cd9 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -81,8 +81,7 @@ static int debug;
/* function prototypes for an empeg-car player */
static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
-static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void empeg_close(struct usb_serial_port *port);
static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf,
int count);
@@ -181,8 +180,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
}
-static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static void empeg_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d9fcdaedf389..20e49d290044 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -47,7 +47,7 @@
/*
* Version Information
*/
-#define DRIVER_VERSION "v1.4.3"
+#define DRIVER_VERSION "v1.5.0"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>"
#define DRIVER_DESC "USB FTDI Serial Converters Driver"
@@ -82,7 +82,8 @@ struct ftdi_private {
int rx_processed;
unsigned long rx_bytes;
- __u16 interface; /* FT2232C port interface (0 for FT232/245) */
+ __u16 interface; /* FT2232C, FT2232H or FT4232H port interface
+ (0 for FT232/245) */
speed_t force_baud; /* if non-zero, force the baud rate to
this value */
@@ -93,6 +94,7 @@ struct ftdi_private {
unsigned long tx_bytes;
unsigned long tx_outstanding_bytes;
unsigned long tx_outstanding_urbs;
+ unsigned short max_packet_size;
};
/* struct ftdi_sio_quirk is used by devices requiring special attention. */
@@ -163,6 +165,7 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_232RL_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
@@ -692,12 +695,13 @@ static const char *ftdi_chip_name[] = {
[FT232BM] = "FT232BM",
[FT2232C] = "FT2232C",
[FT232RL] = "FT232RL",
+ [FT2232H] = "FT2232H",
+ [FT4232H] = "FT4232H"
};
/* Constants for read urb and write urb */
#define BUFSZ 512
-#define PKTSZ 64
/* rx_flags */
#define THROTTLED 0x01
@@ -719,8 +723,8 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port);
static int ftdi_sio_port_remove(struct usb_serial_port *port);
static int ftdi_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void ftdi_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void ftdi_close(struct usb_serial_port *port);
+static void ftdi_dtr_rts(struct usb_serial_port *port, int on);
static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static int ftdi_write_room(struct tty_struct *tty);
@@ -743,6 +747,8 @@ static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
static unsigned short int ftdi_232am_baud_to_divisor(int baud);
static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base);
static __u32 ftdi_232bm_baud_to_divisor(int baud);
+static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base);
+static __u32 ftdi_2232h_baud_to_divisor(int baud);
static struct usb_serial_driver ftdi_sio_device = {
.driver = {
@@ -758,6 +764,7 @@ static struct usb_serial_driver ftdi_sio_device = {
.port_remove = ftdi_sio_port_remove,
.open = ftdi_open,
.close = ftdi_close,
+ .dtr_rts = ftdi_dtr_rts,
.throttle = ftdi_throttle,
.unthrottle = ftdi_unthrottle,
.write = ftdi_write,
@@ -836,6 +843,36 @@ static __u32 ftdi_232bm_baud_to_divisor(int baud)
return ftdi_232bm_baud_base_to_divisor(baud, 48000000);
}
+static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base)
+{
+ static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
+ __u32 divisor;
+ int divisor3;
+
+ /* hi-speed baud rate is 10-bit sampling instead of 16-bit */
+ divisor3 = (base / 10 / baud) * 8;
+
+ divisor = divisor3 >> 3;
+ divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
+ /* Deal with special cases for highest baud rates. */
+ if (divisor == 1)
+ divisor = 0;
+ else if (divisor == 0x4001)
+ divisor = 1;
+ /*
+ * Set this bit to turn off a divide by 2.5 on baud rate generator
+ * This enables baud rates up to 12Mbaud but cannot reach below 1200
+ * baud with this bit set
+ */
+ divisor |= 0x00020000;
+ return divisor;
+}
+
+static __u32 ftdi_2232h_baud_to_divisor(int baud)
+{
+ return ftdi_2232h_baud_base_to_divisor(baud, 120000000);
+}
+
#define set_mctrl(port, set) update_mctrl((port), (set), 0)
#define clear_mctrl(port, clear) update_mctrl((port), 0, (clear))
@@ -994,6 +1031,19 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
baud = 9600;
}
break;
+ case FT2232H: /* FT2232H chip */
+ case FT4232H: /* FT4232H chip */
+ if ((baud <= 12000000) & (baud >= 1200)) {
+ div_value = ftdi_2232h_baud_to_divisor(baud);
+ } else if (baud < 1200) {
+ div_value = ftdi_232bm_baud_to_divisor(baud);
+ } else {
+ dbg("%s - Baud rate too high!", __func__);
+ div_value = ftdi_232bm_baud_to_divisor(9600);
+ div_okay = 0;
+ baud = 9600;
+ }
+ break;
} /* priv->chip_type */
if (div_okay) {
@@ -1146,14 +1196,29 @@ static void ftdi_determine_type(struct usb_serial_port *port)
if (interfaces > 1) {
int inter;
- /* Multiple interfaces. Assume FT2232C. */
- priv->chip_type = FT2232C;
+ /* Multiple interfaces.*/
+ if (version == 0x0800) {
+ priv->chip_type = FT4232H;
+ /* Hi-speed - baud clock runs at 120MHz */
+ priv->baud_base = 120000000 / 2;
+ } else if (version == 0x0700) {
+ priv->chip_type = FT2232H;
+ /* Hi-speed - baud clock runs at 120MHz */
+ priv->baud_base = 120000000 / 2;
+ } else
+ priv->chip_type = FT2232C;
+
/* Determine interface code. */
inter = serial->interface->altsetting->desc.bInterfaceNumber;
- if (inter == 0)
- priv->interface = PIT_SIOA;
- else
- priv->interface = PIT_SIOB;
+ if (inter == 0) {
+ priv->interface = INTERFACE_A;
+ } else if (inter == 1) {
+ priv->interface = INTERFACE_B;
+ } else if (inter == 2) {
+ priv->interface = INTERFACE_C;
+ } else if (inter == 3) {
+ priv->interface = INTERFACE_D;
+ }
/* BM-type devices have a bug where bcdDevice gets set
* to 0x200 when iSerialNumber is 0. */
if (version < 0x500) {
@@ -1181,6 +1246,45 @@ static void ftdi_determine_type(struct usb_serial_port *port)
}
+/* Determine the maximum packet size for the device. This depends on the chip
+ * type and the USB host capabilities. The value should be obtained from the
+ * device descriptor as the chip will use the appropriate values for the host.*/
+static void ftdi_set_max_packet_size(struct usb_serial_port *port)
+{
+ struct ftdi_private *priv = usb_get_serial_port_data(port);
+ struct usb_serial *serial = port->serial;
+ struct usb_device *udev = serial->dev;
+
+ struct usb_interface *interface = serial->interface;
+ struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc;
+
+ unsigned num_endpoints;
+ int i = 0;
+
+ num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
+ dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
+
+ /* NOTE: some customers have programmed FT232R/FT245R devices
+ * with an endpoint size of 0 - not good. In this case, we
+ * want to override the endpoint descriptor setting and use a
+ * value of 64 for wMaxPacketSize */
+ for (i = 0; i < num_endpoints; i++) {
+ dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1,
+ interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
+ ep_desc = &interface->cur_altsetting->endpoint[i].desc;
+ if (ep_desc->wMaxPacketSize == 0) {
+ ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
+ dev_info(&udev->dev, "Overriding wMaxPacketSize on endpoint %d\n", i);
+ }
+ }
+
+ /* set max packet size based on descriptor */
+ priv->max_packet_size = ep_desc->wMaxPacketSize;
+
+ dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
+}
+
+
/*
* ***************************************************************************
* Sysfs Attribute
@@ -1290,7 +1394,9 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
if ((!retval) &&
(priv->chip_type == FT232BM ||
priv->chip_type == FT2232C ||
- priv->chip_type == FT232RL)) {
+ priv->chip_type == FT232RL ||
+ priv->chip_type == FT2232H ||
+ priv->chip_type == FT4232H)) {
retval = device_create_file(&port->dev,
&dev_attr_latency_timer);
}
@@ -1309,7 +1415,9 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
device_remove_file(&port->dev, &dev_attr_event_char);
if (priv->chip_type == FT232BM ||
priv->chip_type == FT2232C ||
- priv->chip_type == FT232RL) {
+ priv->chip_type == FT232RL ||
+ priv->chip_type == FT2232H ||
+ priv->chip_type == FT4232H) {
device_remove_file(&port->dev, &dev_attr_latency_timer);
}
}
@@ -1392,6 +1500,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
usb_set_serial_port_data(port, priv);
ftdi_determine_type(port);
+ ftdi_set_max_packet_size(port);
create_sysfs_attrs(port);
return 0;
}
@@ -1558,6 +1667,30 @@ static int ftdi_open(struct tty_struct *tty,
} /* ftdi_open */
+static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
+{
+ struct ftdi_private *priv = usb_get_serial_port_data(port);
+ char buf[1];
+
+ mutex_lock(&port->serial->disc_mutex);
+ if (!port->serial->disconnected) {
+ /* Disable flow control */
+ if (!on && usb_control_msg(port->serial->dev,
+ usb_sndctrlpipe(port->serial->dev, 0),
+ FTDI_SIO_SET_FLOW_CTRL_REQUEST,
+ FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
+ 0, priv->interface, buf, 0,
+ WDR_TIMEOUT) < 0) {
+ dev_err(&port->dev, "error from flowcontrol urb\n");
+ }
+ /* drop RTS and DTR */
+ if (on)
+ set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+ else
+ clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+ }
+ mutex_unlock(&port->serial->disc_mutex);
+}
/*
* usbserial:__serial_close only calls ftdi_close if the point is open
@@ -1567,31 +1700,12 @@ static int ftdi_open(struct tty_struct *tty,
*
*/
-static void ftdi_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void ftdi_close(struct usb_serial_port *port)
{ /* ftdi_close */
- unsigned int c_cflag = tty->termios->c_cflag;
struct ftdi_private *priv = usb_get_serial_port_data(port);
- char buf[1];
dbg("%s", __func__);
- mutex_lock(&port->serial->disc_mutex);
- if (c_cflag & HUPCL && !port->serial->disconnected) {
- /* Disable flow control */
- if (usb_control_msg(port->serial->dev,
- usb_sndctrlpipe(port->serial->dev, 0),
- FTDI_SIO_SET_FLOW_CTRL_REQUEST,
- FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
- 0, priv->interface, buf, 0,
- WDR_TIMEOUT) < 0) {
- dev_err(&port->dev, "error from flowcontrol urb\n");
- }
-
- /* drop RTS and DTR */
- clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
- } /* Note change no line if hupcl is off */
- mutex_unlock(&port->serial->disc_mutex);
/* cancel any scheduled reading */
cancel_delayed_work_sync(&priv->rx_work);
@@ -1644,8 +1758,8 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
if (data_offset > 0) {
/* Original sio needs control bytes too... */
transfer_size += (data_offset *
- ((count + (PKTSZ - 1 - data_offset)) /
- (PKTSZ - data_offset)));
+ ((count + (priv->max_packet_size - 1 - data_offset)) /
+ (priv->max_packet_size - data_offset)));
}
buffer = kmalloc(transfer_size, GFP_ATOMIC);
@@ -1667,7 +1781,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
if (data_offset > 0) {
/* Original sio requires control byte at start of
each packet. */
- int user_pktsz = PKTSZ - data_offset;
+ int user_pktsz = priv->max_packet_size - data_offset;
int todo = count;
unsigned char *first_byte = buffer;
const unsigned char *current_position = buf;
@@ -1748,11 +1862,6 @@ static void ftdi_write_bulk_callback(struct urb *urb)
dbg("%s - port %d", __func__, port->number);
- if (status) {
- dbg("nonzero write bulk status received: %d", status);
- return;
- }
-
priv = usb_get_serial_port_data(port);
if (!priv) {
dbg("%s - bad port private data pointer - exiting", __func__);
@@ -1763,13 +1872,18 @@ static void ftdi_write_bulk_callback(struct urb *urb)
data_offset = priv->write_offset;
if (data_offset > 0) {
/* Subtract the control bytes */
- countback -= (data_offset * DIV_ROUND_UP(countback, PKTSZ));
+ countback -= (data_offset * DIV_ROUND_UP(countback, priv->max_packet_size));
}
spin_lock_irqsave(&priv->tx_lock, flags);
--priv->tx_outstanding_urbs;
priv->tx_outstanding_bytes -= countback;
spin_unlock_irqrestore(&priv->tx_lock, flags);
+ if (status) {
+ dbg("nonzero write bulk status received: %d", status);
+ return;
+ }
+
usb_serial_port_softint(port);
} /* ftdi_write_bulk_callback */
@@ -1865,7 +1979,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
/* count data bytes, but not status bytes */
countread = urb->actual_length;
- countread -= 2 * DIV_ROUND_UP(countread, PKTSZ);
+ countread -= 2 * DIV_ROUND_UP(countread, priv->max_packet_size);
spin_lock_irqsave(&priv->rx_lock, flags);
priv->rx_bytes += countread;
spin_unlock_irqrestore(&priv->rx_lock, flags);
@@ -1938,7 +2052,7 @@ static void ftdi_process_read(struct work_struct *work)
need_flip = 0;
for (packet_offset = priv->rx_processed;
- packet_offset < urb->actual_length; packet_offset += PKTSZ) {
+ packet_offset < urb->actual_length; packet_offset += priv->max_packet_size) {
int length;
/* Compare new line status to the old one, signal if different/
@@ -1953,7 +2067,7 @@ static void ftdi_process_read(struct work_struct *work)
priv->prev_status = new_status;
}
- length = min_t(u32, PKTSZ, urb->actual_length-packet_offset)-2;
+ length = min_t(u32, priv->max_packet_size, urb->actual_length-packet_offset)-2;
if (length < 0) {
dev_err(&port->dev, "%s - bad packet length: %d\n",
__func__, length+2);
@@ -1984,6 +2098,7 @@ static void ftdi_process_read(struct work_struct *work)
if (data[packet_offset+1] & FTDI_RS_BI) {
error_flag = TTY_BREAK;
dbg("BREAK received");
+ usb_serial_handle_break(port);
}
if (data[packet_offset+1] & FTDI_RS_PE) {
error_flag = TTY_PARITY;
@@ -1998,8 +2113,11 @@ static void ftdi_process_read(struct work_struct *work)
/* Note that the error flag is duplicated for
every character received since we don't know
which character it applied to */
- tty_insert_flip_char(tty,
- data[packet_offset + i], error_flag);
+ if (!usb_serial_handle_sysrq_char(port,
+ data[packet_offset + i]))
+ tty_insert_flip_char(tty,
+ data[packet_offset + i],
+ error_flag);
}
need_flip = 1;
}
@@ -2305,6 +2423,8 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
case FT232BM:
case FT2232C:
case FT232RL:
+ case FT2232H:
+ case FT4232H:
/* the 8U232AM returns a two byte value (the sio is a 1 byte
value) - in the same format as the data returned from the in
point */
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 12330fa1c095..2d1f676beaed 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -10,7 +10,7 @@
* The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
* USB on the other.
*
- * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details
+ * Thanx to FTDI (http://www.ftdichip.com) for so kindly providing details
* of the protocol required to talk to the device and ongoing assistence
* during development.
*
@@ -28,6 +28,7 @@
#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
+#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
#define FTDI_NF_RIC_PID 0x0001 /* Product Id */
@@ -873,6 +874,11 @@
#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
+/* Interface indicies for FT2232, FT2232H and FT4232H devices*/
+#define INTERFACE_A 1
+#define INTERFACE_B 2
+#define INTERFACE_C 3
+#define INTERFACE_D 4
/*
* FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3
@@ -1036,6 +1042,8 @@ typedef enum {
FT232BM = 3,
FT2232C = 4,
FT232RL = 5,
+ FT2232H = 6,
+ FT4232H = 7
} ftdi_chip_type_t;
typedef enum {
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 586d30ff450b..5092d6aba659 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1,7 +1,7 @@
/*
* Garmin GPS driver
*
- * Copyright (C) 2006,2007 Hermann Kneissel herkne@users.sourceforge.net
+ * Copyright (C) 2006-2009 Hermann Kneissel herkne@users.sourceforge.net
*
* The latest version of the driver can be found at
* http://sourceforge.net/projects/garmin-gps/
@@ -51,7 +51,7 @@ static int debug;
*/
#define VERSION_MAJOR 0
-#define VERSION_MINOR 31
+#define VERSION_MINOR 33
#define _STR(s) #s
#define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b)
@@ -129,7 +129,6 @@ struct garmin_data {
__u8 state;
__u16 flags;
__u8 mode;
- __u8 ignorePkts;
__u8 count;
__u8 pkt_id;
__u32 serial_num;
@@ -141,8 +140,6 @@ struct garmin_data {
__u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */
__u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */
__u8 privpkt[4*6];
- atomic_t req_count;
- atomic_t resp_count;
spinlock_t lock;
struct list_head pktlist;
};
@@ -170,6 +167,8 @@ struct garmin_data {
#define FLAGS_BULK_IN_ACTIVE 0x0020
#define FLAGS_BULK_IN_RESTART 0x0010
#define FLAGS_THROTTLED 0x0008
+#define APP_REQ_SEEN 0x0004
+#define APP_RESP_SEEN 0x0002
#define CLEAR_HALT_REQUIRED 0x0001
#define FLAGS_QUEUING 0x0100
@@ -184,20 +183,16 @@ struct garmin_data {
/* function prototypes */
-static void gsp_next_packet(struct garmin_data *garmin_data_p);
-static int garmin_write_bulk(struct usb_serial_port *port,
+static int gsp_next_packet(struct garmin_data *garmin_data_p);
+static int garmin_write_bulk(struct usb_serial_port *port,
const unsigned char *buf, int count,
int dismiss_ack);
/* some special packets to be send or received */
static unsigned char const GARMIN_START_SESSION_REQ[]
= { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0 };
-static unsigned char const GARMIN_START_SESSION_REQ2[]
- = { 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0 };
static unsigned char const GARMIN_START_SESSION_REPLY[]
= { 0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0 };
-static unsigned char const GARMIN_SESSION_ACTIVE_REPLY[]
- = { 0, 0, 0, 0, 17, 0, 0, 0, 4, 0, 0, 0, 0, 16, 0, 0 };
static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[]
= { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 };
static unsigned char const GARMIN_APP_LAYER_REPLY[]
@@ -233,13 +228,6 @@ static struct usb_driver garmin_driver = {
};
-static inline int noResponseFromAppLayer(struct garmin_data *garmin_data_p)
-{
- return atomic_read(&garmin_data_p->req_count) ==
- atomic_read(&garmin_data_p->resp_count);
-}
-
-
static inline int getLayerId(const __u8 *usbPacket)
{
return __le32_to_cpup((__le32 *)(usbPacket));
@@ -325,8 +313,11 @@ static int pkt_add(struct garmin_data *garmin_data_p,
state = garmin_data_p->state;
spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+ dbg("%s - added: pkt: %d - %d bytes",
+ __func__, pkt->seq, data_length);
+
/* in serial mode, if someone is waiting for data from
- the device, iconvert and send the next packet to tty. */
+ the device, convert and send the next packet to tty. */
if (result && (state == STATE_GSP_WAIT_DATA))
gsp_next_packet(garmin_data_p);
}
@@ -411,7 +402,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
/*
* called for a complete packet received from tty layer
*
- * the complete packet (pkzid ... cksum) is in garmin_data_p->inbuf starting
+ * the complete packet (pktid ... cksum) is in garmin_data_p->inbuf starting
* at GSP_INITIAL_OFFSET.
*
* count - number of bytes in the input buffer including space reserved for
@@ -501,7 +492,6 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
unsigned long flags;
int offs = 0;
int ack_or_nak_seen = 0;
- int i = 0;
__u8 *dest;
int size;
/* dleSeen: set if last byte read was a DLE */
@@ -519,8 +509,8 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
skip = garmin_data_p->flags & FLAGS_GSP_SKIP;
spin_unlock_irqrestore(&garmin_data_p->lock, flags);
- dbg("%s - dle=%d skip=%d size=%d count=%d",
- __func__, dleSeen, skip, size, count);
+ /* dbg("%s - dle=%d skip=%d size=%d count=%d",
+ __func__, dleSeen, skip, size, count); */
if (size == 0)
size = GSP_INITIAL_OFFSET;
@@ -568,7 +558,6 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
} else if (!skip) {
if (dleSeen) {
- dbg("non-masked DLE at %d - restarting", i);
size = GSP_INITIAL_OFFSET;
dleSeen = 0;
}
@@ -599,19 +588,19 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
else
garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN;
- if (ack_or_nak_seen)
- garmin_data_p->state = STATE_GSP_WAIT_DATA;
-
spin_unlock_irqrestore(&garmin_data_p->lock, flags);
- if (ack_or_nak_seen)
- gsp_next_packet(garmin_data_p);
+ if (ack_or_nak_seen) {
+ if (gsp_next_packet(garmin_data_p) > 0)
+ garmin_data_p->state = STATE_ACTIVE;
+ else
+ garmin_data_p->state = STATE_GSP_WAIT_DATA;
+ }
return count;
}
-
/*
* Sends a usb packet to the tty
*
@@ -733,29 +722,28 @@ static int gsp_send(struct garmin_data *garmin_data_p,
}
-
-
-
/*
* Process the next pending data packet - if there is one
*/
-static void gsp_next_packet(struct garmin_data *garmin_data_p)
+static int gsp_next_packet(struct garmin_data *garmin_data_p)
{
+ int result = 0;
struct garmin_packet *pkt = NULL;
while ((pkt = pkt_pop(garmin_data_p)) != NULL) {
dbg("%s - next pkt: %d", __func__, pkt->seq);
- if (gsp_send(garmin_data_p, pkt->data, pkt->size) > 0) {
+ result = gsp_send(garmin_data_p, pkt->data, pkt->size);
+ if (result > 0) {
kfree(pkt);
- return;
+ return result;
}
kfree(pkt);
}
+ return result;
}
-
/******************************************************************************
* garmin native mode
******************************************************************************/
@@ -888,14 +876,6 @@ static int garmin_clear(struct garmin_data *garmin_data_p)
unsigned long flags;
int status = 0;
- struct usb_serial_port *port = garmin_data_p->port;
-
- if (port != NULL && atomic_read(&garmin_data_p->resp_count)) {
- /* send a terminate command */
- status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ,
- sizeof(GARMIN_STOP_TRANSFER_REQ), 1);
- }
-
/* flush all queued data */
pkt_clear(garmin_data_p);
@@ -908,16 +888,12 @@ static int garmin_clear(struct garmin_data *garmin_data_p)
}
-
-
-
-
static int garmin_init_session(struct usb_serial_port *port)
{
- unsigned long flags;
struct usb_serial *serial = port->serial;
struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
int status = 0;
+ int i = 0;
if (status == 0) {
usb_kill_urb(port->interrupt_in_urb);
@@ -931,30 +907,25 @@ static int garmin_init_session(struct usb_serial_port *port)
__func__, status);
}
+ /*
+ * using the initialization method from gpsbabel. See comments in
+ * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles()
+ */
if (status == 0) {
dbg("%s - starting session ...", __func__);
garmin_data_p->state = STATE_ACTIVE;
- status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ,
- sizeof(GARMIN_START_SESSION_REQ), 0);
- if (status >= 0) {
-
- spin_lock_irqsave(&garmin_data_p->lock, flags);
- garmin_data_p->ignorePkts++;
- spin_unlock_irqrestore(&garmin_data_p->lock, flags);
-
- /* not needed, but the win32 driver does it too ... */
+ for (i = 0; i < 3; i++) {
status = garmin_write_bulk(port,
- GARMIN_START_SESSION_REQ2,
- sizeof(GARMIN_START_SESSION_REQ2), 0);
- if (status >= 0) {
- status = 0;
- spin_lock_irqsave(&garmin_data_p->lock, flags);
- garmin_data_p->ignorePkts++;
- spin_unlock_irqrestore(&garmin_data_p->lock,
- flags);
- }
+ GARMIN_START_SESSION_REQ,
+ sizeof(GARMIN_START_SESSION_REQ), 0);
+
+ if (status < 0)
+ break;
}
+
+ if (status > 0)
+ status = 0;
}
return status;
@@ -962,8 +933,6 @@ static int garmin_init_session(struct usb_serial_port *port)
-
-
static int garmin_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{
@@ -977,8 +946,6 @@ static int garmin_open(struct tty_struct *tty,
garmin_data_p->mode = initial_mode;
garmin_data_p->count = 0;
garmin_data_p->flags = 0;
- atomic_set(&garmin_data_p->req_count, 0);
- atomic_set(&garmin_data_p->resp_count, 0);
spin_unlock_irqrestore(&garmin_data_p->lock, flags);
/* shutdown any bulk reads that might be going on */
@@ -993,8 +960,7 @@ static int garmin_open(struct tty_struct *tty,
}
-static void garmin_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void garmin_close(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
@@ -1007,6 +973,7 @@ static void garmin_close(struct tty_struct *tty,
return;
mutex_lock(&port->serial->disc_mutex);
+
if (!port->serial->disconnected)
garmin_clear(garmin_data_p);
@@ -1014,25 +981,17 @@ static void garmin_close(struct tty_struct *tty,
usb_kill_urb(port->read_urb);
usb_kill_urb(port->write_urb);
- if (!port->serial->disconnected) {
- if (noResponseFromAppLayer(garmin_data_p) ||
- ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) {
- process_resetdev_request(port);
- garmin_data_p->state = STATE_RESET;
- } else {
- garmin_data_p->state = STATE_DISCONNECTED;
- }
- } else {
+ /* keep reset state so we know that we must start a new session */
+ if (garmin_data_p->state != STATE_RESET)
garmin_data_p->state = STATE_DISCONNECTED;
- }
+
mutex_unlock(&port->serial->disc_mutex);
}
+
static void garmin_write_bulk_callback(struct urb *urb)
{
- unsigned long flags;
struct usb_serial_port *port = urb->context;
- int status = urb->status;
if (port) {
struct garmin_data *garmin_data_p =
@@ -1040,20 +999,13 @@ static void garmin_write_bulk_callback(struct urb *urb)
dbg("%s - port %d", __func__, port->number);
- if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)
- && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) {
- gsp_send_ack(garmin_data_p,
- ((__u8 *)urb->transfer_buffer)[4]);
- }
+ if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)) {
- if (status) {
- dbg("%s - nonzero write bulk status received: %d",
- __func__, status);
- spin_lock_irqsave(&garmin_data_p->lock, flags);
- garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
- spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+ if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
+ gsp_send_ack(garmin_data_p,
+ ((__u8 *)urb->transfer_buffer)[4]);
+ }
}
-
usb_serial_port_softint(port);
}
@@ -1109,7 +1061,11 @@ static int garmin_write_bulk(struct usb_serial_port *port,
urb->transfer_flags |= URB_ZERO_PACKET;
if (GARMIN_LAYERID_APPL == getLayerId(buffer)) {
- atomic_inc(&garmin_data_p->req_count);
+
+ spin_lock_irqsave(&garmin_data_p->lock, flags);
+ garmin_data_p->flags |= APP_REQ_SEEN;
+ spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+
if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
pkt_clear(garmin_data_p);
garmin_data_p->state = STATE_GSP_WAIT_DATA;
@@ -1141,6 +1097,9 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
usb_serial_debug_data(debug, &port->dev, __func__, count, buf);
+ if (garmin_data_p->state == STATE_RESET)
+ return -EIO;
+
/* check for our private packets */
if (count >= GARMIN_PKTHDR_LENGTH) {
len = PRIVPKTSIZ;
@@ -1185,7 +1144,7 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
break;
case PRIV_PKTID_RESET_REQ:
- atomic_inc(&garmin_data_p->req_count);
+ process_resetdev_request(port);
break;
case PRIV_PKTID_SET_DEF_MODE:
@@ -1201,8 +1160,6 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
}
}
- garmin_data_p->ignorePkts = 0;
-
if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
return gsp_receive(garmin_data_p, buf, count);
} else { /* MODE_NATIVE */
@@ -1225,31 +1182,33 @@ static int garmin_write_room(struct tty_struct *tty)
static void garmin_read_process(struct garmin_data *garmin_data_p,
unsigned char *data, unsigned data_length)
{
+ unsigned long flags;
+
if (garmin_data_p->flags & FLAGS_DROP_DATA) {
/* abort-transfer cmd is actice */
dbg("%s - pkt dropped", __func__);
} else if (garmin_data_p->state != STATE_DISCONNECTED &&
garmin_data_p->state != STATE_RESET) {
- /* remember any appl.layer packets, so we know
- if a reset is required or not when closing
- the device */
- if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY,
- sizeof(GARMIN_APP_LAYER_REPLY))) {
- atomic_inc(&garmin_data_p->resp_count);
- }
-
/* if throttling is active or postprecessing is required
put the received data in the input queue, otherwise
send it directly to the tty port */
if (garmin_data_p->flags & FLAGS_QUEUING) {
pkt_add(garmin_data_p, data, data_length);
- } else if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
- if (getLayerId(data) == GARMIN_LAYERID_APPL)
+ } else if (getLayerId(data) == GARMIN_LAYERID_APPL) {
+
+ spin_lock_irqsave(&garmin_data_p->lock, flags);
+ garmin_data_p->flags |= APP_RESP_SEEN;
+ spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+
+ if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
pkt_add(garmin_data_p, data, data_length);
- } else {
- send_to_tty(garmin_data_p->port, data, data_length);
+ } else {
+ send_to_tty(garmin_data_p->port, data,
+ data_length);
+ }
}
+ /* ignore system layer packets ... */
}
}
@@ -1364,8 +1323,6 @@ static void garmin_read_int_callback(struct urb *urb)
} else {
spin_lock_irqsave(&garmin_data_p->lock, flags);
garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE;
- /* do not send this packet to the user */
- garmin_data_p->ignorePkts = 1;
spin_unlock_irqrestore(&garmin_data_p->lock,
flags);
}
@@ -1392,17 +1349,7 @@ static void garmin_read_int_callback(struct urb *urb)
__func__, garmin_data_p->serial_num);
}
- if (garmin_data_p->ignorePkts) {
- /* this reply belongs to a request generated by the driver,
- ignore it. */
- dbg("%s - pkt ignored (%d)",
- __func__, garmin_data_p->ignorePkts);
- spin_lock_irqsave(&garmin_data_p->lock, flags);
- garmin_data_p->ignorePkts--;
- spin_unlock_irqrestore(&garmin_data_p->lock, flags);
- } else {
- garmin_read_process(garmin_data_p, data, urb->actual_length);
- }
+ garmin_read_process(garmin_data_p, data, urb->actual_length);
port->interrupt_in_urb->dev = port->serial->dev;
retval = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 4cec9906ccf3..9fccc26235a2 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -184,13 +184,94 @@ int usb_serial_generic_resume(struct usb_serial *serial)
}
EXPORT_SYMBOL_GPL(usb_serial_generic_resume);
-void usb_serial_generic_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+void usb_serial_generic_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
generic_cleanup(port);
}
+static int usb_serial_multi_urb_write(struct tty_struct *tty,
+ struct usb_serial_port *port, const unsigned char *buf, int count)
+{
+ unsigned long flags;
+ struct urb *urb;
+ unsigned char *buffer;
+ int status;
+ int towrite;
+ int bwrite = 0;
+
+ dbg("%s - port %d", __func__, port->number);
+
+ if (count == 0)
+ dbg("%s - write request of 0 bytes", __func__);
+
+ while (count > 0) {
+ towrite = (count > port->bulk_out_size) ?
+ port->bulk_out_size : count;
+ spin_lock_irqsave(&port->lock, flags);
+ if (port->urbs_in_flight >
+ port->serial->type->max_in_flight_urbs) {
+ spin_unlock_irqrestore(&port->lock, flags);
+ dbg("%s - write limit hit\n", __func__);
+ return bwrite;
+ }
+ port->tx_bytes_flight += towrite;
+ port->urbs_in_flight++;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ buffer = kmalloc(towrite, GFP_ATOMIC);
+ if (!buffer) {
+ dev_err(&port->dev,
+ "%s ran out of kernel memory for urb ...\n", __func__);
+ goto error_no_buffer;
+ }
+
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
+ if (!urb) {
+ dev_err(&port->dev, "%s - no more free urbs\n",
+ __func__);
+ goto error_no_urb;
+ }
+
+ /* Copy data */
+ memcpy(buffer, buf + bwrite, towrite);
+ usb_serial_debug_data(debug, &port->dev, __func__,
+ towrite, buffer);
+ /* fill the buffer and send it */
+ usb_fill_bulk_urb(urb, port->serial->dev,
+ usb_sndbulkpipe(port->serial->dev,
+ port->bulk_out_endpointAddress),
+ buffer, towrite,
+ usb_serial_generic_write_bulk_callback, port);
+
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status) {
+ dev_err(&port->dev,
+ "%s - failed submitting write urb, error %d\n",
+ __func__, status);
+ goto error;
+ }
+
+ /* This urb is the responsibility of the host driver now */
+ usb_free_urb(urb);
+ dbg("%s write: %d", __func__, towrite);
+ count -= towrite;
+ bwrite += towrite;
+ }
+ return bwrite;
+
+error:
+ usb_free_urb(urb);
+error_no_urb:
+ kfree(buffer);
+error_no_buffer:
+ spin_lock_irqsave(&port->lock, flags);
+ port->urbs_in_flight--;
+ port->tx_bytes_flight -= towrite;
+ spin_unlock_irqrestore(&port->lock, flags);
+ return bwrite;
+}
+
int usb_serial_generic_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count)
{
@@ -208,6 +289,11 @@ int usb_serial_generic_write(struct tty_struct *tty,
/* only do something if we have a bulk out endpoint */
if (serial->num_bulk_out) {
unsigned long flags;
+
+ if (serial->type->max_in_flight_urbs)
+ return usb_serial_multi_urb_write(tty, port,
+ buf, count);
+
spin_lock_irqsave(&port->lock, flags);
if (port->write_urb_busy) {
spin_unlock_irqrestore(&port->lock, flags);
@@ -253,20 +339,26 @@ int usb_serial_generic_write(struct tty_struct *tty,
/* no bulk out, so return 0 bytes written */
return 0;
}
+EXPORT_SYMBOL_GPL(usb_serial_generic_write);
int usb_serial_generic_write_room(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial;
+ unsigned long flags;
int room = 0;
dbg("%s - port %d", __func__, port->number);
-
- /* FIXME: Locking */
- if (serial->num_bulk_out) {
- if (!(port->write_urb_busy))
- room = port->bulk_out_size;
+ spin_lock_irqsave(&port->lock, flags);
+ if (serial->type->max_in_flight_urbs) {
+ if (port->urbs_in_flight < serial->type->max_in_flight_urbs)
+ room = port->bulk_out_size *
+ (serial->type->max_in_flight_urbs -
+ port->urbs_in_flight);
+ } else if (serial->num_bulk_out && !(port->write_urb_busy)) {
+ room = port->bulk_out_size;
}
+ spin_unlock_irqrestore(&port->lock, flags);
dbg("%s - returns %d", __func__, room);
return room;
@@ -277,11 +369,16 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial;
int chars = 0;
+ unsigned long flags;
dbg("%s - port %d", __func__, port->number);
- /* FIXME: Locking */
- if (serial->num_bulk_out) {
+ if (serial->type->max_in_flight_urbs) {
+ spin_lock_irqsave(&port->lock, flags);
+ chars = port->tx_bytes_flight;
+ spin_unlock_irqrestore(&port->lock, flags);
+ } else if (serial->num_bulk_out) {
+ /* FIXME: Locking */
if (port->write_urb_busy)
chars = port->write_urb->transfer_buffer_length;
}
@@ -291,7 +388,8 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
}
-static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
+void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
+ gfp_t mem_flags)
{
struct urb *urb = port->read_urb;
struct usb_serial *serial = port->serial;
@@ -312,25 +410,28 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
"%s - failed resubmitting read urb, error %d\n",
__func__, result);
}
+EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb);
/* Push data to tty layer and resubmit the bulk read URB */
static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
{
struct urb *urb = port->read_urb;
struct tty_struct *tty = tty_port_tty_get(&port->port);
- int room;
+ char *ch = (char *)urb->transfer_buffer;
+ int i;
+
+ if (!tty)
+ goto done;
/* Push data to tty */
- if (tty && urb->actual_length) {
- room = tty_buffer_request_room(tty, urb->actual_length);
- if (room) {
- tty_insert_flip_string(tty, urb->transfer_buffer, room);
- tty_flip_buffer_push(tty);
- }
+ for (i = 0; i < urb->actual_length; i++, ch++) {
+ if (!usb_serial_handle_sysrq_char(port, *ch))
+ tty_insert_flip_char(tty, *ch, TTY_NORMAL);
}
+ tty_flip_buffer_push(tty);
tty_kref_put(tty);
-
- resubmit_read_urb(port, GFP_ATOMIC);
+done:
+ usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC);
}
void usb_serial_generic_read_bulk_callback(struct urb *urb)
@@ -364,12 +465,24 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
void usb_serial_generic_write_bulk_callback(struct urb *urb)
{
+ unsigned long flags;
struct usb_serial_port *port = urb->context;
int status = urb->status;
dbg("%s - port %d", __func__, port->number);
- port->write_urb_busy = 0;
+ if (port->serial->type->max_in_flight_urbs) {
+ spin_lock_irqsave(&port->lock, flags);
+ --port->urbs_in_flight;
+ port->tx_bytes_flight -= urb->transfer_buffer_length;
+ if (port->urbs_in_flight < 0)
+ port->urbs_in_flight = 0;
+ spin_unlock_irqrestore(&port->lock, flags);
+ } else {
+ /* Handle the case for single urb mode */
+ port->write_urb_busy = 0;
+ }
+
if (status) {
dbg("%s - nonzero write bulk status received: %d",
__func__, status);
@@ -409,10 +522,35 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
if (was_throttled) {
/* Resume reading from device */
- resubmit_read_urb(port, GFP_KERNEL);
+ usb_serial_generic_resubmit_read_urb(port, GFP_KERNEL);
}
}
+int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
+{
+ if (port->sysrq) {
+ if (ch && time_before(jiffies, port->sysrq)) {
+ handle_sysrq(ch, tty_port_tty_get(&port->port));
+ port->sysrq = 0;
+ return 1;
+ }
+ port->sysrq = 0;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
+
+int usb_serial_handle_break(struct usb_serial_port *port)
+{
+ if (!port->sysrq) {
+ port->sysrq = jiffies + HZ*5;
+ return 1;
+ }
+ port->sysrq = 0;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(usb_serial_handle_break);
+
void usb_serial_generic_shutdown(struct usb_serial *serial)
{
int i;
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index fb4a73d090f6..53ef5996e33d 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -207,8 +207,7 @@ static void edge_bulk_out_cmd_callback(struct urb *urb);
/* function prototypes for the usbserial callbacks */
static int edge_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
-static void edge_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void edge_close(struct usb_serial_port *port);
static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static int edge_write_room(struct tty_struct *tty);
@@ -965,7 +964,7 @@ static int edge_open(struct tty_struct *tty,
if (!edge_port->txfifo.fifo) {
dbg("%s - no memory", __func__);
- edge_close(tty, port, filp);
+ edge_close(port);
return -ENOMEM;
}
@@ -975,7 +974,7 @@ static int edge_open(struct tty_struct *tty,
if (!edge_port->write_urb) {
dbg("%s - no memory", __func__);
- edge_close(tty, port, filp);
+ edge_close(port);
return -ENOMEM;
}
@@ -1099,8 +1098,7 @@ static void block_until_tx_empty(struct edgeport_port *edge_port)
* edge_close
* this function is called by the tty driver when a port is closed
*****************************************************************************/
-static void edge_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void edge_close(struct usb_serial_port *port)
{
struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port;
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 513b25e044c1..db964db42d3c 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -102,7 +102,7 @@ struct edgeport_port {
__u8 shadow_mcr;
__u8 shadow_lsr;
__u8 lsr_mask;
- __u32 ump_read_timeout; /* Number of miliseconds the UMP will
+ __u32 ump_read_timeout; /* Number of milliseconds the UMP will
wait without data before completing
a read short */
int baud_rate;
@@ -2009,8 +2009,7 @@ release_es_lock:
return status;
}
-static void edge_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void edge_close(struct usb_serial_port *port)
{
struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port;
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index cd62825a9ac3..c610a99fa477 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -76,8 +76,7 @@ static int initial_wait;
/* Function prototypes for an ipaq */
static int ipaq_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void ipaq_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void ipaq_close(struct usb_serial_port *port);
static int ipaq_calc_num_ports(struct usb_serial *serial);
static int ipaq_startup(struct usb_serial *serial);
static void ipaq_shutdown(struct usb_serial *serial);
@@ -714,8 +713,7 @@ error:
}
-static void ipaq_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void ipaq_close(struct usb_serial_port *port)
{
struct ipaq_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index da2a2b46644a..29ad038b9c8d 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -302,23 +302,17 @@ static int ipw_open(struct tty_struct *tty,
return 0;
}
-static void ipw_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void ipw_dtr_rts(struct usb_serial_port *port, int on)
{
struct usb_device *dev = port->serial->dev;
int result;
- if (tty_hung_up_p(filp)) {
- dbg("%s: tty_hung_up_p ...", __func__);
- return;
- }
-
/*--1: drop the dtr */
dbg("%s:dropping dtr", __func__);
result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
IPW_SIO_SET_PIN,
USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
- IPW_PIN_CLRDTR,
+ on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR,
0,
NULL,
0,
@@ -332,7 +326,7 @@ static void ipw_close(struct tty_struct *tty,
result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
IPW_SIO_SET_PIN, USB_TYPE_VENDOR |
USB_RECIP_INTERFACE | USB_DIR_OUT,
- IPW_PIN_CLRRTS,
+ on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS,
0,
NULL,
0,
@@ -340,7 +334,12 @@ static void ipw_close(struct tty_struct *tty,
if (result < 0)
dev_err(&port->dev,
"dropping rts failed (error = %d)\n", result);
+}
+static void ipw_close(struct usb_serial_port *port)
+{
+ struct usb_device *dev = port->serial->dev;
+ int result;
/*--3: purge */
dbg("%s:sending purge", __func__);
@@ -461,6 +460,7 @@ static struct usb_serial_driver ipw_device = {
.num_ports = 1,
.open = ipw_open,
.close = ipw_close,
+ .dtr_rts = ipw_dtr_rts,
.port_probe = ipw_probe,
.port_remove = ipw_disconnect,
.write = ipw_write,
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 4e2cda93da59..66009b6b763a 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -88,8 +88,7 @@ static int xbof = -1;
static int ir_startup (struct usb_serial *serial);
static int ir_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filep);
-static void ir_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filep);
+static void ir_close(struct usb_serial_port *port);
static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static void ir_write_bulk_callback (struct urb *urb);
@@ -346,8 +345,7 @@ static int ir_open(struct tty_struct *tty,
return result;
}
-static void ir_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file * filp)
+static void ir_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 4473d442b2aa..bb572cee6ecd 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -70,7 +70,6 @@ static void read_rxcmd_callback(struct urb *urb);
struct iuu_private {
spinlock_t lock; /* store irq state */
wait_queue_head_t delta_msr_wait;
- u8 line_control;
u8 line_status;
u8 termios_initialized;
int tiostatus; /* store IUART SIGNAL for tiocmget call */
@@ -946,19 +945,10 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud,
return status;
}
-static int set_control_lines(struct usb_device *dev, u8 value)
-{
- return 0;
-}
-
-static void iuu_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void iuu_close(struct usb_serial_port *port)
{
/* iuu_led (port,255,0,0,0); */
struct usb_serial *serial;
- struct iuu_private *priv = usb_get_serial_port_data(port);
- unsigned long flags;
- unsigned int c_cflag;
serial = port->serial;
if (!serial)
@@ -968,17 +958,6 @@ static void iuu_close(struct tty_struct *tty,
iuu_uart_off(port);
if (serial->dev) {
- if (tty) {
- c_cflag = tty->termios->c_cflag;
- if (c_cflag & HUPCL) {
- /* drop DTR and RTS */
- priv = usb_get_serial_port_data(port);
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
- set_control_lines(port->serial->dev, 0);
- }
- }
/* free writebuf */
/* shutdown our urbs */
dbg("%s - shutting down urbs", __func__);
@@ -1154,7 +1133,7 @@ static int iuu_open(struct tty_struct *tty,
if (result) {
dev_err(&port->dev, "%s - failed submitting read urb,"
" error %d\n", __func__, result);
- iuu_close(tty, port, NULL);
+ iuu_close(port);
return -EPROTO;
} else {
dbg("%s - rxcmd OK", __func__);
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 00daa8f7759a..f1195a98f316 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1298,8 +1298,16 @@ static inline void stop_urb(struct urb *urb)
usb_kill_urb(urb);
}
-static void keyspan_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void keyspan_dtr_rts(struct usb_serial_port *port, int on)
+{
+ struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
+
+ p_priv->rts_state = on;
+ p_priv->dtr_state = on;
+ keyspan_send_setup(port, 0);
+}
+
+static void keyspan_close(struct usb_serial_port *port)
{
int i;
struct usb_serial *serial = port->serial;
@@ -1336,7 +1344,6 @@ static void keyspan_close(struct tty_struct *tty,
stop_urb(p_priv->out_urbs[i]);
}
}
- tty_port_tty_set(&port->port, NULL);
}
/* download the firmware to a pre-renumeration device */
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 38b4582e0734..0d4569b60768 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -38,9 +38,8 @@
static int keyspan_open (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp);
-static void keyspan_close (struct tty_struct *tty,
- struct usb_serial_port *port,
- struct file *filp);
+static void keyspan_close (struct usb_serial_port *port);
+static void keyspan_dtr_rts (struct usb_serial_port *port, int on);
static int keyspan_startup (struct usb_serial *serial);
static void keyspan_shutdown (struct usb_serial *serial);
static int keyspan_write_room (struct tty_struct *tty);
@@ -562,6 +561,7 @@ static struct usb_serial_driver keyspan_1port_device = {
.num_ports = 1,
.open = keyspan_open,
.close = keyspan_close,
+ .dtr_rts = keyspan_dtr_rts,
.write = keyspan_write,
.write_room = keyspan_write_room,
.set_termios = keyspan_set_termios,
@@ -582,6 +582,7 @@ static struct usb_serial_driver keyspan_2port_device = {
.num_ports = 2,
.open = keyspan_open,
.close = keyspan_close,
+ .dtr_rts = keyspan_dtr_rts,
.write = keyspan_write,
.write_room = keyspan_write_room,
.set_termios = keyspan_set_termios,
@@ -602,6 +603,7 @@ static struct usb_serial_driver keyspan_4port_device = {
.num_ports = 4,
.open = keyspan_open,
.close = keyspan_close,
+ .dtr_rts = keyspan_dtr_rts,
.write = keyspan_write,
.write_room = keyspan_write_room,
.set_termios = keyspan_set_termios,
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index bf1ae247da66..ab769dbea1b3 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -651,6 +651,35 @@ static int keyspan_pda_chars_in_buffer(struct tty_struct *tty)
}
+static void keyspan_pda_dtr_rts(struct usb_serial_port *port, int on)
+{
+ struct usb_serial *serial = port->serial;
+
+ if (serial->dev) {
+ if (on)
+ keyspan_pda_set_modem_info(serial, (1<<7) | (1<< 2));
+ else
+ keyspan_pda_set_modem_info(serial, 0);
+ }
+}
+
+static int keyspan_pda_carrier_raised(struct usb_serial_port *port)
+{
+ struct usb_serial *serial = port->serial;
+ unsigned char modembits;
+
+ /* If we can read the modem status and the DCD is low then
+ carrier is not raised yet */
+ if (keyspan_pda_get_modem_info(serial, &modembits) >= 0) {
+ if (!(modembits & (1>>6)))
+ return 0;
+ }
+ /* Carrier raised, or we failed (eg disconnected) so
+ progress accordingly */
+ return 1;
+}
+
+
static int keyspan_pda_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{
@@ -682,13 +711,6 @@ static int keyspan_pda_open(struct tty_struct *tty,
priv->tx_room = room;
priv->tx_throttled = room ? 0 : 1;
- /* the normal serial device seems to always turn on DTR and RTS here,
- so do the same */
- if (tty && (tty->termios->c_cflag & CBAUD))
- keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2));
- else
- keyspan_pda_set_modem_info(serial, 0);
-
/*Start reading from the device*/
port->interrupt_in_urb->dev = serial->dev;
rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
@@ -700,19 +722,11 @@ static int keyspan_pda_open(struct tty_struct *tty,
error:
return rc;
}
-
-
-static void keyspan_pda_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void keyspan_pda_close(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
if (serial->dev) {
- /* the normal serial device seems to always shut
- off DTR and RTS now */
- if (tty->termios->c_cflag & HUPCL)
- keyspan_pda_set_modem_info(serial, 0);
-
/* shutdown our bulk reads and writes */
usb_kill_urb(port->write_urb);
usb_kill_urb(port->interrupt_in_urb);
@@ -839,6 +853,8 @@ static struct usb_serial_driver keyspan_pda_device = {
.usb_driver = &keyspan_pda_driver,
.id_table = id_table_std,
.num_ports = 1,
+ .dtr_rts = keyspan_pda_dtr_rts,
+ .carrier_raised = keyspan_pda_carrier_raised,
.open = keyspan_pda_open,
.close = keyspan_pda_close,
.write = keyspan_pda_write,
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index fcd9082f3e7f..fa817c66b3e8 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -76,8 +76,7 @@ static int klsi_105_startup(struct usb_serial *serial);
static void klsi_105_shutdown(struct usb_serial *serial);
static int klsi_105_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void klsi_105_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void klsi_105_close(struct usb_serial_port *port);
static int klsi_105_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count);
static void klsi_105_write_bulk_callback(struct urb *urb);
@@ -447,8 +446,7 @@ exit:
} /* klsi_105_open */
-static void klsi_105_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void klsi_105_close(struct usb_serial_port *port)
{
struct klsi_105_private *priv = usb_get_serial_port_data(port);
int rc;
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index c148544953b3..6b570498287f 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -72,8 +72,7 @@ static int kobil_startup(struct usb_serial *serial);
static void kobil_shutdown(struct usb_serial *serial);
static int kobil_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void kobil_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void kobil_close(struct usb_serial_port *port);
static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static int kobil_write_room(struct tty_struct *tty);
@@ -209,7 +208,7 @@ static void kobil_shutdown(struct usb_serial *serial)
for (i = 0; i < serial->num_ports; ++i) {
while (serial->port[i]->port.count > 0)
- kobil_close(NULL, serial->port[i], NULL);
+ kobil_close(serial->port[i]);
kfree(usb_get_serial_port_data(serial->port[i]));
usb_set_serial_port_data(serial->port[i], NULL);
}
@@ -346,11 +345,11 @@ static int kobil_open(struct tty_struct *tty,
}
-static void kobil_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void kobil_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
+ /* FIXME: Add rts/dtr methods */
if (port->write_urb) {
usb_kill_urb(port->write_urb);
usb_free_urb(port->write_urb);
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 82930a7d5093..873795548fc0 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -95,8 +95,8 @@ static int mct_u232_startup(struct usb_serial *serial);
static void mct_u232_shutdown(struct usb_serial *serial);
static int mct_u232_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void mct_u232_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void mct_u232_close(struct usb_serial_port *port);
+static void mct_u232_dtr_rts(struct usb_serial_port *port, int on);
static void mct_u232_read_int_callback(struct urb *urb);
static void mct_u232_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old);
@@ -140,6 +140,7 @@ static struct usb_serial_driver mct_u232_device = {
.num_ports = 1,
.open = mct_u232_open,
.close = mct_u232_close,
+ .dtr_rts = mct_u232_dtr_rts,
.throttle = mct_u232_throttle,
.unthrottle = mct_u232_unthrottle,
.read_int_callback = mct_u232_read_int_callback,
@@ -496,29 +497,29 @@ error:
return retval;
} /* mct_u232_open */
-
-static void mct_u232_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void mct_u232_dtr_rts(struct usb_serial_port *port, int on)
{
- unsigned int c_cflag;
unsigned int control_state;
struct mct_u232_private *priv = usb_get_serial_port_data(port);
- dbg("%s port %d", __func__, port->number);
- if (tty) {
- c_cflag = tty->termios->c_cflag;
- mutex_lock(&port->serial->disc_mutex);
- if (c_cflag & HUPCL && !port->serial->disconnected) {
- /* drop DTR and RTS */
- spin_lock_irq(&priv->lock);
+ mutex_lock(&port->serial->disc_mutex);
+ if (!port->serial->disconnected) {
+ /* drop DTR and RTS */
+ spin_lock_irq(&priv->lock);
+ if (on)
+ priv->control_state |= TIOCM_DTR | TIOCM_RTS;
+ else
priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
- control_state = priv->control_state;
- spin_unlock_irq(&priv->lock);
- mct_u232_set_modem_ctrl(port->serial, control_state);
- }
- mutex_unlock(&port->serial->disc_mutex);
+ control_state = priv->control_state;
+ spin_unlock_irq(&priv->lock);
+ mct_u232_set_modem_ctrl(port->serial, control_state);
}
+ mutex_unlock(&port->serial->disc_mutex);
+}
+static void mct_u232_close(struct usb_serial_port *port)
+{
+ dbg("%s port %d", __func__, port->number);
if (port->serial->dev) {
/* shutdown our urbs */
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 24e3b5d4b4d4..9e1a013ee7f6 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -533,8 +533,7 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty)
return chars;
}
-static void mos7720_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void mos7720_close(struct usb_serial_port *port)
{
struct usb_serial *serial;
struct moschip_port *mos7720_port;
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 84fb1dcd30dc..5fe9fe3df772 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -238,7 +238,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
{
struct usb_device *dev = port->serial->dev;
val = val & 0x00ff;
- dbg("mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
+ dbg("mos7840_set_reg_sync offset is %x, value %x", reg, val);
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
MCS_WR_RTYPE, val, reg, NULL, 0,
@@ -260,7 +260,7 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH,
MOS_WDR_TIMEOUT);
- dbg("mos7840_get_reg_sync offset is %x, return val %x\n", reg, *val);
+ dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val);
*val = (*val) & 0x00ff;
return ret;
}
@@ -282,18 +282,18 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
if (port->serial->num_ports == 4) {
val |= (((__u16) port->number -
(__u16) (port->serial->minor)) + 1) << 8;
- dbg("mos7840_set_uart_reg application number is %x\n", val);
+ dbg("mos7840_set_uart_reg application number is %x", val);
} else {
if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
val |= (((__u16) port->number -
(__u16) (port->serial->minor)) + 1) << 8;
- dbg("mos7840_set_uart_reg application number is %x\n",
+ dbg("mos7840_set_uart_reg application number is %x",
val);
} else {
val |=
(((__u16) port->number -
(__u16) (port->serial->minor)) + 2) << 8;
- dbg("mos7840_set_uart_reg application number is %x\n",
+ dbg("mos7840_set_uart_reg application number is %x",
val);
}
}
@@ -315,24 +315,24 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
int ret = 0;
__u16 Wval;
- /* dbg("application number is %4x \n",
+ /* dbg("application number is %4x",
(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
/* Wval is same as application number */
if (port->serial->num_ports == 4) {
Wval =
(((__u16) port->number - (__u16) (port->serial->minor)) +
1) << 8;
- dbg("mos7840_get_uart_reg application number is %x\n", Wval);
+ dbg("mos7840_get_uart_reg application number is %x", Wval);
} else {
if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
Wval = (((__u16) port->number -
(__u16) (port->serial->minor)) + 1) << 8;
- dbg("mos7840_get_uart_reg application number is %x\n",
+ dbg("mos7840_get_uart_reg application number is %x",
Wval);
} else {
Wval = (((__u16) port->number -
(__u16) (port->serial->minor)) + 2) << 8;
- dbg("mos7840_get_uart_reg application number is %x\n",
+ dbg("mos7840_get_uart_reg application number is %x",
Wval);
}
}
@@ -346,11 +346,11 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
static void mos7840_dump_serial_port(struct moschip_port *mos7840_port)
{
- dbg("***************************************\n");
- dbg("SpRegOffset is %2x\n", mos7840_port->SpRegOffset);
- dbg("ControlRegOffset is %2x \n", mos7840_port->ControlRegOffset);
- dbg("DCRRegOffset is %2x \n", mos7840_port->DcrRegOffset);
- dbg("***************************************\n");
+ dbg("***************************************");
+ dbg("SpRegOffset is %2x", mos7840_port->SpRegOffset);
+ dbg("ControlRegOffset is %2x", mos7840_port->ControlRegOffset);
+ dbg("DCRRegOffset is %2x", mos7840_port->DcrRegOffset);
+ dbg("***************************************");
}
@@ -474,12 +474,12 @@ static void mos7840_control_callback(struct urb *urb)
goto exit;
}
- dbg("%s urb buffer size is %d\n", __func__, urb->actual_length);
- dbg("%s mos7840_port->MsrLsr is %d port %d\n", __func__,
+ dbg("%s urb buffer size is %d", __func__, urb->actual_length);
+ dbg("%s mos7840_port->MsrLsr is %d port %d", __func__,
mos7840_port->MsrLsr, mos7840_port->port_num);
data = urb->transfer_buffer;
regval = (__u8) data[0];
- dbg("%s data is %x\n", __func__, regval);
+ dbg("%s data is %x", __func__, regval);
if (mos7840_port->MsrLsr == 0)
mos7840_handle_new_msr(mos7840_port, regval);
else if (mos7840_port->MsrLsr == 1)
@@ -538,7 +538,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
__u16 wval, wreg = 0;
int status = urb->status;
- dbg("%s", " : Entering\n");
+ dbg("%s", " : Entering");
switch (status) {
case 0:
@@ -570,7 +570,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
* Byte 5 FIFO status for both */
if (length && length > 5) {
- dbg("%s \n", "Wrong data !!!");
+ dbg("%s", "Wrong data !!!");
return;
}
@@ -587,17 +587,17 @@ static void mos7840_interrupt_callback(struct urb *urb)
(__u16) (serial->minor)) + 1) << 8;
if (mos7840_port->open) {
if (sp[i] & 0x01) {
- dbg("SP%d No Interrupt !!!\n", i);
+ dbg("SP%d No Interrupt !!!", i);
} else {
switch (sp[i] & 0x0f) {
case SERIAL_IIR_RLS:
dbg("Serial Port %d: Receiver status error or ", i);
- dbg("address bit detected in 9-bit mode\n");
+ dbg("address bit detected in 9-bit mode");
mos7840_port->MsrLsr = 1;
wreg = LINE_STATUS_REGISTER;
break;
case SERIAL_IIR_MS:
- dbg("Serial Port %d: Modem status change\n", i);
+ dbg("Serial Port %d: Modem status change", i);
mos7840_port->MsrLsr = 0;
wreg = MODEM_STATUS_REGISTER;
break;
@@ -689,7 +689,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
mos7840_port = urb->context;
if (!mos7840_port) {
- dbg("%s", "NULL mos7840_port pointer \n");
+ dbg("%s", "NULL mos7840_port pointer");
mos7840_port->read_urb_busy = false;
return;
}
@@ -702,41 +702,41 @@ static void mos7840_bulk_in_callback(struct urb *urb)
port = (struct usb_serial_port *)mos7840_port->port;
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Port Paranoia failed \n");
+ dbg("%s", "Port Paranoia failed");
mos7840_port->read_urb_busy = false;
return;
}
serial = mos7840_get_usb_serial(port, __func__);
if (!serial) {
- dbg("%s\n", "Bad serial pointer ");
+ dbg("%s", "Bad serial pointer");
mos7840_port->read_urb_busy = false;
return;
}
- dbg("%s\n", "Entering... \n");
+ dbg("%s", "Entering... ");
data = urb->transfer_buffer;
- dbg("%s", "Entering ........... \n");
+ dbg("%s", "Entering ...........");
if (urb->actual_length) {
tty = tty_port_tty_get(&mos7840_port->port->port);
if (tty) {
tty_buffer_request_room(tty, urb->actual_length);
tty_insert_flip_string(tty, data, urb->actual_length);
- dbg(" %s \n", data);
+ dbg(" %s ", data);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}
mos7840_port->icount.rx += urb->actual_length;
smp_wmb();
- dbg("mos7840_port->icount.rx is %d:\n",
+ dbg("mos7840_port->icount.rx is %d:",
mos7840_port->icount.rx);
}
if (!mos7840_port->read_urb) {
- dbg("%s", "URB KILLED !!!\n");
+ dbg("%s", "URB KILLED !!!");
mos7840_port->read_urb_busy = false;
return;
}
@@ -777,16 +777,16 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
spin_unlock(&mos7840_port->pool_lock);
if (status) {
- dbg("nonzero write bulk status received:%d\n", status);
+ dbg("nonzero write bulk status received:%d", status);
return;
}
if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) {
- dbg("%s", "Port Paranoia failed \n");
+ dbg("%s", "Port Paranoia failed");
return;
}
- dbg("%s \n", "Entering .........");
+ dbg("%s", "Entering .........");
tty = tty_port_tty_get(&mos7840_port->port->port);
if (tty && mos7840_port->open)
@@ -830,15 +830,17 @@ static int mos7840_open(struct tty_struct *tty,
struct moschip_port *mos7840_port;
struct moschip_port *port0;
+ dbg ("%s enter", __func__);
+
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Port Paranoia failed \n");
+ dbg("%s", "Port Paranoia failed");
return -ENODEV;
}
serial = port->serial;
if (mos7840_serial_paranoia_check(serial, __func__)) {
- dbg("%s", "Serial Paranoia failed \n");
+ dbg("%s", "Serial Paranoia failed");
return -ENODEV;
}
@@ -891,20 +893,20 @@ static int mos7840_open(struct tty_struct *tty,
Data = 0x0;
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
if (status < 0) {
- dbg("Reading Spreg failed\n");
+ dbg("Reading Spreg failed");
return -1;
}
Data |= 0x80;
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
if (status < 0) {
- dbg("writing Spreg failed\n");
+ dbg("writing Spreg failed");
return -1;
}
Data &= ~0x80;
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
if (status < 0) {
- dbg("writing Spreg failed\n");
+ dbg("writing Spreg failed");
return -1;
}
/* End of block to be checked */
@@ -913,7 +915,7 @@ static int mos7840_open(struct tty_struct *tty,
status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
&Data);
if (status < 0) {
- dbg("Reading Controlreg failed\n");
+ dbg("Reading Controlreg failed");
return -1;
}
Data |= 0x08; /* Driver done bit */
@@ -921,7 +923,7 @@ static int mos7840_open(struct tty_struct *tty,
status = mos7840_set_reg_sync(port,
mos7840_port->ControlRegOffset, Data);
if (status < 0) {
- dbg("writing Controlreg failed\n");
+ dbg("writing Controlreg failed");
return -1;
}
/* do register settings here */
@@ -932,21 +934,21 @@ static int mos7840_open(struct tty_struct *tty,
Data = 0x00;
status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
if (status < 0) {
- dbg("disableing interrupts failed\n");
+ dbg("disabling interrupts failed");
return -1;
}
/* Set FIFO_CONTROL_REGISTER to the default value */
Data = 0x00;
status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
if (status < 0) {
- dbg("Writing FIFO_CONTROL_REGISTER failed\n");
+ dbg("Writing FIFO_CONTROL_REGISTER failed");
return -1;
}
Data = 0xcf;
status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
if (status < 0) {
- dbg("Writing FIFO_CONTROL_REGISTER failed\n");
+ dbg("Writing FIFO_CONTROL_REGISTER failed");
return -1;
}
@@ -1043,12 +1045,12 @@ static int mos7840_open(struct tty_struct *tty,
* (can't set it up in mos7840_startup as the *
* structures were not set up at that time.) */
- dbg("port number is %d \n", port->number);
- dbg("serial number is %d \n", port->serial->minor);
- dbg("Bulkin endpoint is %d \n", port->bulk_in_endpointAddress);
- dbg("BulkOut endpoint is %d \n", port->bulk_out_endpointAddress);
- dbg("Interrupt endpoint is %d \n", port->interrupt_in_endpointAddress);
- dbg("port's number in the device is %d\n", mos7840_port->port_num);
+ dbg("port number is %d", port->number);
+ dbg("serial number is %d", port->serial->minor);
+ dbg("Bulkin endpoint is %d", port->bulk_in_endpointAddress);
+ dbg("BulkOut endpoint is %d", port->bulk_out_endpointAddress);
+ dbg("Interrupt endpoint is %d", port->interrupt_in_endpointAddress);
+ dbg("port's number in the device is %d", mos7840_port->port_num);
mos7840_port->read_urb = port->read_urb;
/* set up our bulk in urb */
@@ -1061,7 +1063,7 @@ static int mos7840_open(struct tty_struct *tty,
mos7840_port->read_urb->transfer_buffer_length,
mos7840_bulk_in_callback, mos7840_port);
- dbg("mos7840_open: bulkin endpoint is %d\n",
+ dbg("mos7840_open: bulkin endpoint is %d",
port->bulk_in_endpointAddress);
mos7840_port->read_urb_busy = true;
response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
@@ -1087,9 +1089,11 @@ static int mos7840_open(struct tty_struct *tty,
mos7840_port->icount.tx = 0;
mos7840_port->icount.rx = 0;
- dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n",
+ dbg("usb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p",
serial, mos7840_port, port);
+ dbg ("%s leave", __func__);
+
return 0;
}
@@ -1112,16 +1116,16 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
unsigned long flags;
struct moschip_port *mos7840_port;
- dbg("%s \n", " mos7840_chars_in_buffer:entering ...........");
+ dbg("%s", " mos7840_chars_in_buffer:entering ...........");
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return 0;
}
mos7840_port = mos7840_get_port_private(port);
if (mos7840_port == NULL) {
- dbg("%s \n", "mos7840_break:leaving ...........");
+ dbg("%s", "mos7840_break:leaving ...........");
return 0;
}
@@ -1135,54 +1139,12 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
}
-/************************************************************************
- *
- * mos7840_block_until_tx_empty
- *
- * This function will block the close until one of the following:
- * 1. TX count are 0
- * 2. The mos7840 has stopped
- * 3. A timeout of 3 seconds without activity has expired
- *
- ************************************************************************/
-static void mos7840_block_until_tx_empty(struct tty_struct *tty,
- struct moschip_port *mos7840_port)
-{
- int timeout = HZ / 10;
- int wait = 30;
- int count;
-
- while (1) {
-
- count = mos7840_chars_in_buffer(tty);
-
- /* Check for Buffer status */
- if (count <= 0)
- return;
-
- /* Block the thread for a while */
- interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
- timeout);
-
- /* No activity.. count down section */
- wait--;
- if (wait == 0) {
- dbg("%s - TIMEOUT", __func__);
- return;
- } else {
- /* Reset timeout value back to seconds */
- wait = 30;
- }
- }
-}
-
/*****************************************************************************
* mos7840_close
* this function is called by the tty driver when a port is closed
*****************************************************************************/
-static void mos7840_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void mos7840_close(struct usb_serial_port *port)
{
struct usb_serial *serial;
struct moschip_port *mos7840_port;
@@ -1190,16 +1152,16 @@ static void mos7840_close(struct tty_struct *tty,
int j;
__u16 Data;
- dbg("%s\n", "mos7840_close:entering...");
+ dbg("%s", "mos7840_close:entering...");
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Port Paranoia failed \n");
+ dbg("%s", "Port Paranoia failed");
return;
}
serial = mos7840_get_usb_serial(port, __func__);
if (!serial) {
- dbg("%s", "Serial Paranoia failed \n");
+ dbg("%s", "Serial Paranoia failed");
return;
}
@@ -1223,35 +1185,31 @@ static void mos7840_close(struct tty_struct *tty,
}
}
- if (serial->dev)
- /* flush and block until tx is empty */
- mos7840_block_until_tx_empty(tty, mos7840_port);
-
/* While closing port, shutdown all bulk read, write *
* and interrupt read if they exists */
if (serial->dev) {
if (mos7840_port->write_urb) {
- dbg("%s", "Shutdown bulk write\n");
+ dbg("%s", "Shutdown bulk write");
usb_kill_urb(mos7840_port->write_urb);
}
if (mos7840_port->read_urb) {
- dbg("%s", "Shutdown bulk read\n");
+ dbg("%s", "Shutdown bulk read");
usb_kill_urb(mos7840_port->read_urb);
mos7840_port->read_urb_busy = false;
}
if ((&mos7840_port->control_urb)) {
- dbg("%s", "Shutdown control read\n");
+ dbg("%s", "Shutdown control read");
/*/ usb_kill_urb (mos7840_port->control_urb); */
}
}
/* if(mos7840_port->ctrl_buf != NULL) */
/* kfree(mos7840_port->ctrl_buf); */
port0->open_ports--;
- dbg("mos7840_num_open_ports in close%d:in port%d\n",
+ dbg("mos7840_num_open_ports in close%d:in port%d",
port0->open_ports, port->number);
if (port0->open_ports == 0) {
if (serial->port[0]->interrupt_in_urb) {
- dbg("%s", "Shutdown interrupt_in_urb\n");
+ dbg("%s", "Shutdown interrupt_in_urb");
usb_kill_urb(serial->port[0]->interrupt_in_urb);
}
}
@@ -1271,7 +1229,7 @@ static void mos7840_close(struct tty_struct *tty,
mos7840_port->open = 0;
- dbg("%s \n", "Leaving ............");
+ dbg("%s", "Leaving ............");
}
/************************************************************************
@@ -1326,17 +1284,17 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
struct usb_serial *serial;
struct moschip_port *mos7840_port;
- dbg("%s \n", "Entering ...........");
- dbg("mos7840_break: Start\n");
+ dbg("%s", "Entering ...........");
+ dbg("mos7840_break: Start");
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Port Paranoia failed \n");
+ dbg("%s", "Port Paranoia failed");
return;
}
serial = mos7840_get_usb_serial(port, __func__);
if (!serial) {
- dbg("%s", "Serial Paranoia failed \n");
+ dbg("%s", "Serial Paranoia failed");
return;
}
@@ -1356,7 +1314,7 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
/* FIXME: no locking on shadowLCR anywhere in driver */
mos7840_port->shadowLCR = data;
- dbg("mcs7840_break mos7840_port->shadowLCR is %x\n",
+ dbg("mcs7840_break mos7840_port->shadowLCR is %x",
mos7840_port->shadowLCR);
mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER,
mos7840_port->shadowLCR);
@@ -1380,17 +1338,17 @@ static int mos7840_write_room(struct tty_struct *tty)
unsigned long flags;
struct moschip_port *mos7840_port;
- dbg("%s \n", " mos7840_write_room:entering ...........");
+ dbg("%s", " mos7840_write_room:entering ...........");
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
- dbg("%s \n", " mos7840_write_room:leaving ...........");
+ dbg("%s", "Invalid port");
+ dbg("%s", " mos7840_write_room:leaving ...........");
return -1;
}
mos7840_port = mos7840_get_port_private(port);
if (mos7840_port == NULL) {
- dbg("%s \n", "mos7840_break:leaving ...........");
+ dbg("%s", "mos7840_break:leaving ...........");
return -1;
}
@@ -1430,16 +1388,16 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
/* __u16 Data; */
const unsigned char *current_position = data;
unsigned char *data1;
- dbg("%s \n", "entering ...........");
- /* dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
+ dbg("%s", "entering ...........");
+ /* dbg("mos7840_write: mos7840_port->shadowLCR is %x",
mos7840_port->shadowLCR); */
#ifdef NOTMOS7840
Data = 0x00;
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
mos7840_port->shadowLCR = Data;
- dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data);
- dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
+ dbg("mos7840_write: LINE_CONTROL_REGISTER is %x", Data);
+ dbg("mos7840_write: mos7840_port->shadowLCR is %x",
mos7840_port->shadowLCR);
/* Data = 0x03; */
@@ -1453,32 +1411,32 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
/* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
Data = 0x00;
status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
- dbg("mos7840_write:DLL value is %x\n", Data);
+ dbg("mos7840_write:DLL value is %x", Data);
Data = 0x0;
status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
- dbg("mos7840_write:DLM value is %x\n", Data);
+ dbg("mos7840_write:DLM value is %x", Data);
Data = Data & ~SERIAL_LCR_DLAB;
- dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
+ dbg("mos7840_write: mos7840_port->shadowLCR is %x",
mos7840_port->shadowLCR);
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
#endif
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Port Paranoia failed \n");
+ dbg("%s", "Port Paranoia failed");
return -1;
}
serial = port->serial;
if (mos7840_serial_paranoia_check(serial, __func__)) {
- dbg("%s", "Serial Paranoia failed \n");
+ dbg("%s", "Serial Paranoia failed");
return -1;
}
mos7840_port = mos7840_get_port_private(port);
if (mos7840_port == NULL) {
- dbg("%s", "mos7840_port is NULL\n");
+ dbg("%s", "mos7840_port is NULL");
return -1;
}
@@ -1490,7 +1448,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
if (!mos7840_port->busy[i]) {
mos7840_port->busy[i] = 1;
urb = mos7840_port->write_urb_pool[i];
- dbg("\nURB:%d", i);
+ dbg("URB:%d", i);
break;
}
}
@@ -1525,7 +1483,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
mos7840_bulk_out_data_callback, mos7840_port);
data1 = urb->transfer_buffer;
- dbg("\nbulkout endpoint is %d", port->bulk_out_endpointAddress);
+ dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress);
/* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -1540,7 +1498,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
bytes_sent = transfer_size;
mos7840_port->icount.tx += transfer_size;
smp_wmb();
- dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
+ dbg("mos7840_port->icount.tx is %d:", mos7840_port->icount.tx);
exit:
return bytes_sent;
@@ -1559,11 +1517,11 @@ static void mos7840_throttle(struct tty_struct *tty)
int status;
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return;
}
- dbg("- port %d\n", port->number);
+ dbg("- port %d", port->number);
mos7840_port = mos7840_get_port_private(port);
@@ -1571,11 +1529,11 @@ static void mos7840_throttle(struct tty_struct *tty)
return;
if (!mos7840_port->open) {
- dbg("%s\n", "port not opened");
+ dbg("%s", "port not opened");
return;
}
- dbg("%s", "Entering .......... \n");
+ dbg("%s", "Entering ..........");
/* if we are implementing XON/XOFF, send the stop character */
if (I_IXOFF(tty)) {
@@ -1609,7 +1567,7 @@ static void mos7840_unthrottle(struct tty_struct *tty)
struct moschip_port *mos7840_port = mos7840_get_port_private(port);
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return;
}
@@ -1621,7 +1579,7 @@ static void mos7840_unthrottle(struct tty_struct *tty)
return;
}
- dbg("%s", "Entering .......... \n");
+ dbg("%s", "Entering ..........");
/* if we are implementing XON/XOFF, send the start character */
if (I_IXOFF(tty)) {
@@ -1706,7 +1664,7 @@ static int mos7840_tiocmset(struct tty_struct *tty, struct file *file,
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr);
if (status < 0) {
- dbg("setting MODEM_CONTROL_REGISTER Failed\n");
+ dbg("setting MODEM_CONTROL_REGISTER Failed");
return status;
}
@@ -1775,11 +1733,11 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
custom++;
*divisor = custom;
- dbg(" Baud %d = %d\n", baudrate, custom);
+ dbg(" Baud %d = %d", baudrate, custom);
return 0;
}
- dbg("%s\n", " Baud calculation Failed...");
+ dbg("%s", " Baud calculation Failed...");
return -1;
#endif
}
@@ -1805,16 +1763,16 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
port = (struct usb_serial_port *)mos7840_port->port;
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return -1;
}
if (mos7840_serial_paranoia_check(port->serial, __func__)) {
- dbg("%s", "Invalid Serial \n");
+ dbg("%s", "Invalid Serial");
return -1;
}
- dbg("%s", "Entering .......... \n");
+ dbg("%s", "Entering ..........");
number = mos7840_port->port->number - mos7840_port->port->serial->minor;
@@ -1830,7 +1788,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
Data);
if (status < 0) {
- dbg("Writing spreg failed in set_serial_baud\n");
+ dbg("Writing spreg failed in set_serial_baud");
return -1;
}
#endif
@@ -1843,7 +1801,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
Data);
if (status < 0) {
- dbg("Writing spreg failed in set_serial_baud\n");
+ dbg("Writing spreg failed in set_serial_baud");
return -1;
}
#endif
@@ -1858,14 +1816,14 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
&Data);
if (status < 0) {
- dbg("reading spreg failed in set_serial_baud\n");
+ dbg("reading spreg failed in set_serial_baud");
return -1;
}
Data = (Data & 0x8f) | clk_sel_val;
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset,
Data);
if (status < 0) {
- dbg("Writing spreg failed in set_serial_baud\n");
+ dbg("Writing spreg failed in set_serial_baud");
return -1;
}
/* Calculate the Divisor */
@@ -1881,11 +1839,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
/* Write the divisor */
Data = (unsigned char)(divisor & 0xff);
- dbg("set_serial_baud Value to write DLL is %x\n", Data);
+ dbg("set_serial_baud Value to write DLL is %x", Data);
mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
Data = (unsigned char)((divisor & 0xff00) >> 8);
- dbg("set_serial_baud Value to write DLM is %x\n", Data);
+ dbg("set_serial_baud Value to write DLM is %x", Data);
mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
/* Disable access to divisor latch */
@@ -1923,12 +1881,12 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
port = (struct usb_serial_port *)mos7840_port->port;
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return;
}
if (mos7840_serial_paranoia_check(port->serial, __func__)) {
- dbg("%s", "Invalid Serial \n");
+ dbg("%s", "Invalid Serial");
return;
}
@@ -1941,7 +1899,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
return;
}
- dbg("%s", "Entering .......... \n");
+ dbg("%s", "Entering ..........");
lData = LCR_BITS_8;
lStop = LCR_STOP_1;
@@ -2001,7 +1959,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
mos7840_port->shadowLCR |= (lData | lParity | lStop);
- dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x\n",
+ dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x",
mos7840_port->shadowLCR);
/* Disable Interrupts */
Data = 0x00;
@@ -2043,7 +2001,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
if (!baud) {
/* pick a default, any default... */
- dbg("%s\n", "Picked default baud...");
+ dbg("%s", "Picked default baud...");
baud = 9600;
}
@@ -2066,7 +2024,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
}
wake_up(&mos7840_port->delta_msr_wait);
mos7840_port->delta_msr_cond = 1;
- dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x\n",
+ dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x",
mos7840_port->shadowLCR);
return;
@@ -2086,16 +2044,16 @@ static void mos7840_set_termios(struct tty_struct *tty,
unsigned int cflag;
struct usb_serial *serial;
struct moschip_port *mos7840_port;
- dbg("mos7840_set_termios: START\n");
+ dbg("mos7840_set_termios: START");
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return;
}
serial = port->serial;
if (mos7840_serial_paranoia_check(serial, __func__)) {
- dbg("%s", "Invalid Serial \n");
+ dbg("%s", "Invalid Serial");
return;
}
@@ -2109,7 +2067,7 @@ static void mos7840_set_termios(struct tty_struct *tty,
return;
}
- dbg("%s\n", "setting termios - ");
+ dbg("%s", "setting termios - ");
cflag = tty->termios->c_cflag;
@@ -2124,7 +2082,7 @@ static void mos7840_set_termios(struct tty_struct *tty,
mos7840_change_port_settings(tty, mos7840_port, old_termios);
if (!mos7840_port->read_urb) {
- dbg("%s", "URB KILLED !!!!!\n");
+ dbg("%s", "URB KILLED !!!!!");
return;
}
@@ -2190,7 +2148,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
port = (struct usb_serial_port *)mos7840_port->port;
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return -1;
}
@@ -2235,7 +2193,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
unlock_kernel();
if (status < 0) {
- dbg("setting MODEM_CONTROL_REGISTER Failed\n");
+ dbg("setting MODEM_CONTROL_REGISTER Failed");
return -1;
}
@@ -2320,7 +2278,7 @@ static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
int mosret = 0;
if (mos7840_port_paranoia_check(port, __func__)) {
- dbg("%s", "Invalid port \n");
+ dbg("%s", "Invalid port");
return -1;
}
@@ -2420,9 +2378,8 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
{
int mos7840_num_ports = 0;
- dbg("numberofendpoints: %d \n",
- (int)serial->interface->cur_altsetting->desc.bNumEndpoints);
- dbg("numberofendpoints: %d \n",
+ dbg("numberofendpoints: cur %d, alt %d",
+ (int)serial->interface->cur_altsetting->desc.bNumEndpoints,
(int)serial->interface->altsetting->desc.bNumEndpoints);
if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) {
mos7840_num_ports = serial->num_ports = 2;
@@ -2431,7 +2388,7 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
serial->num_bulk_out = 4;
mos7840_num_ports = serial->num_ports = 4;
}
-
+ dbg ("mos7840_num_ports = %d", mos7840_num_ports);
return mos7840_num_ports;
}
@@ -2446,22 +2403,24 @@ static int mos7840_startup(struct usb_serial *serial)
int i, status;
__u16 Data;
- dbg("%s \n", " mos7840_startup :entering..........");
+ dbg("%s", "mos7840_startup :Entering..........");
if (!serial) {
- dbg("%s\n", "Invalid Handler");
+ dbg("%s", "Invalid Handler");
return -1;
}
dev = serial->dev;
- dbg("%s\n", "Entering...");
+ dbg("%s", "Entering...");
+ dbg ("mos7840_startup: serial = %p", serial);
/* we set up the pointers to the endpoints in the mos7840_open *
* function, as the structures aren't created yet. */
/* set up port private structures */
for (i = 0; i < serial->num_ports; ++i) {
+ dbg ("mos7840_startup: configuring port %d............", i);
mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
if (mos7840_port == NULL) {
dev_err(&dev->dev, "%s - Out of memory\n", __func__);
@@ -2519,10 +2478,10 @@ static int mos7840_startup(struct usb_serial *serial)
status = mos7840_get_reg_sync(serial->port[i],
mos7840_port->ControlRegOffset, &Data);
if (status < 0) {
- dbg("Reading ControlReg failed status-0x%x\n", status);
+ dbg("Reading ControlReg failed status-0x%x", status);
break;
} else
- dbg("ControlReg Reading success val is %x, status%d\n",
+ dbg("ControlReg Reading success val is %x, status%d",
Data, status);
Data |= 0x08; /* setting driver done bit */
Data |= 0x04; /* sp1_bit to have cts change reflect in
@@ -2532,10 +2491,10 @@ static int mos7840_startup(struct usb_serial *serial)
status = mos7840_set_reg_sync(serial->port[i],
mos7840_port->ControlRegOffset, Data);
if (status < 0) {
- dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status);
+ dbg("Writing ControlReg failed(rx_disable) status-0x%x", status);
break;
} else
- dbg("ControlReg Writing success(rx_disable) status%d\n",
+ dbg("ControlReg Writing success(rx_disable) status%d",
status);
/* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2
@@ -2544,48 +2503,48 @@ static int mos7840_startup(struct usb_serial *serial)
status = mos7840_set_reg_sync(serial->port[i],
(__u16) (mos7840_port->DcrRegOffset + 0), Data);
if (status < 0) {
- dbg("Writing DCR0 failed status-0x%x\n", status);
+ dbg("Writing DCR0 failed status-0x%x", status);
break;
} else
- dbg("DCR0 Writing success status%d\n", status);
+ dbg("DCR0 Writing success status%d", status);
Data = 0x05;
status = mos7840_set_reg_sync(serial->port[i],
(__u16) (mos7840_port->DcrRegOffset + 1), Data);
if (status < 0) {
- dbg("Writing DCR1 failed status-0x%x\n", status);
+ dbg("Writing DCR1 failed status-0x%x", status);
break;
} else
- dbg("DCR1 Writing success status%d\n", status);
+ dbg("DCR1 Writing success status%d", status);
Data = 0x24;
status = mos7840_set_reg_sync(serial->port[i],
(__u16) (mos7840_port->DcrRegOffset + 2), Data);
if (status < 0) {
- dbg("Writing DCR2 failed status-0x%x\n", status);
+ dbg("Writing DCR2 failed status-0x%x", status);
break;
} else
- dbg("DCR2 Writing success status%d\n", status);
+ dbg("DCR2 Writing success status%d", status);
/* write values in clkstart0x0 and clkmulti 0x20 */
Data = 0x0;
status = mos7840_set_reg_sync(serial->port[i],
CLK_START_VALUE_REGISTER, Data);
if (status < 0) {
- dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
+ dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x", status);
break;
} else
- dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status);
+ dbg("CLK_START_VALUE_REGISTER Writing success status%d", status);
Data = 0x20;
status = mos7840_set_reg_sync(serial->port[i],
CLK_MULTI_REGISTER, Data);
if (status < 0) {
- dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n",
+ dbg("Writing CLK_MULTI_REGISTER failed status-0x%x",
status);
goto error;
} else
- dbg("CLK_MULTI_REGISTER Writing success status%d\n",
+ dbg("CLK_MULTI_REGISTER Writing success status%d",
status);
/* write value 0x0 to scratchpad register */
@@ -2593,11 +2552,11 @@ static int mos7840_startup(struct usb_serial *serial)
status = mos7840_set_uart_reg(serial->port[i],
SCRATCH_PAD_REGISTER, Data);
if (status < 0) {
- dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n",
+ dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x",
status);
break;
} else
- dbg("SCRATCH_PAD_REGISTER Writing success status%d\n",
+ dbg("SCRATCH_PAD_REGISTER Writing success status%d",
status);
/* Zero Length flag register */
@@ -2608,30 +2567,30 @@ static int mos7840_startup(struct usb_serial *serial)
status = mos7840_set_reg_sync(serial->port[i],
(__u16) (ZLP_REG1 +
((__u16)mos7840_port->port_num)), Data);
- dbg("ZLIP offset%x\n",
+ dbg("ZLIP offset %x",
(__u16) (ZLP_REG1 +
((__u16) mos7840_port->port_num)));
if (status < 0) {
- dbg("Writing ZLP_REG%d failed status-0x%x\n",
+ dbg("Writing ZLP_REG%d failed status-0x%x",
i + 2, status);
break;
} else
- dbg("ZLP_REG%d Writing success status%d\n",
+ dbg("ZLP_REG%d Writing success status%d",
i + 2, status);
} else {
Data = 0xff;
status = mos7840_set_reg_sync(serial->port[i],
(__u16) (ZLP_REG1 +
((__u16)mos7840_port->port_num) - 0x1), Data);
- dbg("ZLIP offset%x\n",
+ dbg("ZLIP offset %x",
(__u16) (ZLP_REG1 +
((__u16) mos7840_port->port_num) - 0x1));
if (status < 0) {
- dbg("Writing ZLP_REG%d failed status-0x%x\n",
+ dbg("Writing ZLP_REG%d failed status-0x%x",
i + 1, status);
break;
} else
- dbg("ZLP_REG%d Writing success status%d\n",
+ dbg("ZLP_REG%d Writing success status%d",
i + 1, status);
}
@@ -2645,15 +2604,16 @@ static int mos7840_startup(struct usb_serial *serial)
goto error;
}
}
+ dbg ("mos7840_startup: all ports configured...........");
/* Zero Length flag enable */
Data = 0x0f;
status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
if (status < 0) {
- dbg("Writing ZLP_REG5 failed status-0x%x\n", status);
+ dbg("Writing ZLP_REG5 failed status-0x%x", status);
goto error;
} else
- dbg("ZLP_REG5 Writing success status%d\n", status);
+ dbg("ZLP_REG5 Writing success status%d", status);
/* setting configuration feature to one */
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
@@ -2682,10 +2642,10 @@ static void mos7840_shutdown(struct usb_serial *serial)
int i;
unsigned long flags;
struct moschip_port *mos7840_port;
- dbg("%s \n", " shutdown :entering..........");
+ dbg("%s", " shutdown :entering..........");
if (!serial) {
- dbg("%s", "Invalid Handler \n");
+ dbg("%s", "Invalid Handler");
return;
}
@@ -2709,7 +2669,7 @@ static void mos7840_shutdown(struct usb_serial *serial)
mos7840_set_port_private(serial->port[i], NULL);
}
- dbg("%s\n", "Thank u :: ");
+ dbg("%s", "Thank u :: ");
}
@@ -2760,7 +2720,7 @@ static int __init moschip7840_init(void)
{
int retval;
- dbg("%s \n", " mos7840_init :entering..........");
+ dbg("%s", " mos7840_init :entering..........");
/* Register with the usb serial */
retval = usb_serial_register(&moschip7840_4port_device);
@@ -2768,14 +2728,14 @@ static int __init moschip7840_init(void)
if (retval)
goto failed_port_device_register;
- dbg("%s\n", "Entring...");
+ dbg("%s", "Entering...");
printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
DRIVER_DESC "\n");
/* Register with the usb */
retval = usb_register(&io_driver);
if (retval == 0) {
- dbg("%s\n", "Leaving...");
+ dbg("%s", "Leaving...");
return 0;
}
usb_serial_deregister(&moschip7840_4port_device);
@@ -2790,13 +2750,13 @@ failed_port_device_register:
static void __exit moschip7840_exit(void)
{
- dbg("%s \n", " mos7840_exit :entering..........");
+ dbg("%s", " mos7840_exit :entering..........");
usb_deregister(&io_driver);
usb_serial_deregister(&moschip7840_4port_device);
- dbg("%s\n", "Entring...");
+ dbg("%s", "Entering...");
}
module_init(moschip7840_init);
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index bcdcbb822705..f5f3751a888c 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -98,8 +98,7 @@ static int navman_open(struct tty_struct *tty,
return result;
}
-static void navman_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void navman_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index df6539712726..1104617334f5 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -66,8 +66,7 @@ static int debug;
/* function prototypes */
static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
-static void omninet_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void omninet_close(struct usb_serial_port *port);
static void omninet_read_bulk_callback(struct urb *urb);
static void omninet_write_bulk_callback(struct urb *urb);
static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -189,8 +188,7 @@ static int omninet_open(struct tty_struct *tty,
return result;
}
-static void omninet_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void omninet_close(struct usb_serial_port *port)
{
dbg("%s - port %d", __func__, port->number);
usb_kill_urb(port->read_urb);
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index b500ad10b758..c20480aa9755 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -173,8 +173,7 @@ static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port,
return result;
}
-static void opticon_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static void opticon_close(struct usb_serial_port *port)
{
struct opticon_private *priv = usb_get_serial_data(port->serial);
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 7817b82889ca..3f95719524aa 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -43,10 +43,13 @@
#include <linux/usb/serial.h>
/* Function prototypes */
+static int option_probe(struct usb_serial *serial,
+ const struct usb_device_id *id);
static int option_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
-static void option_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void option_close(struct usb_serial_port *port);
+static void option_dtr_rts(struct usb_serial_port *port, int on);
+
static int option_startup(struct usb_serial *serial);
static void option_shutdown(struct usb_serial *serial);
static int option_write_room(struct tty_struct *tty);
@@ -61,7 +64,7 @@ static void option_set_termios(struct tty_struct *tty,
static int option_tiocmget(struct tty_struct *tty, struct file *file);
static int option_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear);
-static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port);
+static int option_send_setup(struct usb_serial_port *port);
static int option_suspend(struct usb_serial *serial, pm_message_t message);
static int option_resume(struct usb_serial *serial);
@@ -201,9 +204,9 @@ static int option_resume(struct usb_serial *serial);
#define NOVATELWIRELESS_PRODUCT_MC727 0x4100
#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
#define NOVATELWIRELESS_PRODUCT_U727 0x5010
+#define NOVATELWIRELESS_PRODUCT_MC760 0x6000
/* FUTURE NOVATEL PRODUCTS */
-#define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0X6000
#define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001
#define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0X7000
#define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0X7001
@@ -421,7 +424,7 @@ static struct usb_device_id option_ids[] = {
{ USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
{ USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
{ USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel MC727/U727/USB727 */
- { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, /* Novatel EVDO product */
+ { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC760) }, /* Novatel MC760/U760/USB760 */
{ USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */
{ USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */
{ USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */
@@ -549,8 +552,10 @@ static struct usb_serial_driver option_1port_device = {
.usb_driver = &option_driver,
.id_table = option_ids,
.num_ports = 1,
+ .probe = option_probe,
.open = option_open,
.close = option_close,
+ .dtr_rts = option_dtr_rts,
.write = option_write,
.write_room = option_write_room,
.chars_in_buffer = option_chars_in_buffer,
@@ -624,13 +629,25 @@ static void __exit option_exit(void)
module_init(option_init);
module_exit(option_exit);
+static int option_probe(struct usb_serial *serial,
+ const struct usb_device_id *id)
+{
+ /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */
+ if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID &&
+ serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 &&
+ serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8)
+ return -ENODEV;
+
+ return 0;
+}
+
static void option_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
dbg("%s", __func__);
/* Doesn't support option setting */
tty_termios_copy_hw(tty->termios, old_termios);
- option_send_setup(tty, port);
+ option_send_setup(port);
}
static int option_tiocmget(struct tty_struct *tty, struct file *file)
@@ -669,7 +686,7 @@ static int option_tiocmset(struct tty_struct *tty, struct file *file,
portdata->rts_state = 0;
if (clear & TIOCM_DTR)
portdata->dtr_state = 0;
- return option_send_setup(tty, port);
+ return option_send_setup(port);
}
/* Write */
@@ -897,10 +914,6 @@ static int option_open(struct tty_struct *tty,
dbg("%s", __func__);
- /* Set some sane defaults */
- portdata->rts_state = 1;
- portdata->dtr_state = 1;
-
/* Reset low level data toggle and start reading from endpoints */
for (i = 0; i < N_IN_URB; i++) {
urb = portdata->in_urbs[i];
@@ -936,37 +949,43 @@ static int option_open(struct tty_struct *tty,
usb_pipeout(urb->pipe), 0); */
}
- option_send_setup(tty, port);
+ option_send_setup(port);
return 0;
}
-static void option_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void option_dtr_rts(struct usb_serial_port *port, int on)
{
- int i;
struct usb_serial *serial = port->serial;
struct option_port_private *portdata;
dbg("%s", __func__);
portdata = usb_get_serial_port_data(port);
+ mutex_lock(&serial->disc_mutex);
+ portdata->rts_state = on;
+ portdata->dtr_state = on;
+ if (serial->dev)
+ option_send_setup(port);
+ mutex_unlock(&serial->disc_mutex);
+}
- portdata->rts_state = 0;
- portdata->dtr_state = 0;
- if (serial->dev) {
- mutex_lock(&serial->disc_mutex);
- if (!serial->disconnected)
- option_send_setup(tty, port);
- mutex_unlock(&serial->disc_mutex);
+static void option_close(struct usb_serial_port *port)
+{
+ int i;
+ struct usb_serial *serial = port->serial;
+ struct option_port_private *portdata;
+ dbg("%s", __func__);
+ portdata = usb_get_serial_port_data(port);
+
+ if (serial->dev) {
/* Stop reading/writing urbs */
for (i = 0; i < N_IN_URB; i++)
usb_kill_urb(portdata->in_urbs[i]);
for (i = 0; i < N_OUT_URB; i++)
usb_kill_urb(portdata->out_urbs[i]);
}
- tty_port_tty_set(&port->port, NULL);
}
/* Helper functions used by option_setup_urbs */
@@ -1032,28 +1051,24 @@ static void option_setup_urbs(struct usb_serial *serial)
* This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
* CDC.
*/
-static int option_send_setup(struct tty_struct *tty,
- struct usb_serial_port *port)
+static int option_send_setup(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct option_port_private *portdata;
int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
+ int val = 0;
dbg("%s", __func__);
portdata = usb_get_serial_port_data(port);
- if (tty) {
- int val = 0;
- if (portdata->dtr_state)
- val |= 0x01;
- if (portdata->rts_state)
- val |= 0x02;
+ if (portdata->dtr_state)
+ val |= 0x01;
+ if (portdata->rts_state)
+ val |= 0x02;
- return usb_control_msg(serial->dev,
- usb_rcvctrlpipe(serial->dev, 0),
- 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT);
- }
- return 0;
+ return usb_control_msg(serial->dev,
+ usb_rcvctrlpipe(serial->dev, 0),
+ 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT);
}
static int option_startup(struct usb_serial *serial)
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index ba551f00f16f..7de54781fe61 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -143,8 +143,7 @@ struct oti6858_control_pkt {
/* function prototypes */
static int oti6858_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void oti6858_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void oti6858_close(struct usb_serial_port *port);
static void oti6858_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old);
static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
@@ -622,67 +621,30 @@ static int oti6858_open(struct tty_struct *tty,
if (result != 0) {
dev_err(&port->dev, "%s(): usb_submit_urb() failed"
" with error %d\n", __func__, result);
- oti6858_close(tty, port, NULL);
+ oti6858_close(port);
return -EPROTO;
}
/* setup termios */
if (tty)
oti6858_set_termios(tty, port, &tmp_termios);
-
+ port->port.drain_delay = 256; /* FIXME: check the FIFO length */
return 0;
}
-static void oti6858_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void oti6858_close(struct usb_serial_port *port)
{
struct oti6858_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
- long timeout;
- wait_queue_t wait;
dbg("%s(port = %d)", __func__, port->number);
- /* wait for data to drain from the buffer */
spin_lock_irqsave(&priv->lock, flags);
- timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */
- init_waitqueue_entry(&wait, current);
- add_wait_queue(&tty->write_wait, &wait);
- dbg("%s(): entering wait loop", __func__);
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (oti6858_buf_data_avail(priv->buf) == 0
- || timeout == 0 || signal_pending(current)
- || port->serial->disconnected)
- break;
- spin_unlock_irqrestore(&priv->lock, flags);
- timeout = schedule_timeout(timeout);
- spin_lock_irqsave(&priv->lock, flags);
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&tty->write_wait, &wait);
- dbg("%s(): after wait loop", __func__);
-
/* clear out any remaining data in the buffer */
oti6858_buf_clear(priv->buf);
spin_unlock_irqrestore(&priv->lock, flags);
- /* wait for characters to drain from the device */
- /* (this is long enough for the entire 256 byte */
- /* pl2303 hardware buffer to drain with no flow */
- /* control for data rates of 1200 bps or more, */
- /* for lower rates we should really know how much */
- /* data is in the buffer to compute a delay */
- /* that is not unnecessarily long) */
- /* FIXME
- bps = tty_get_baud_rate(tty);
- if (bps > 1200)
- timeout = max((HZ*2560)/bps,HZ/10);
- else
- */
- timeout = 2*HZ;
- schedule_timeout_interruptible(timeout);
- dbg("%s(): after schedule_timeout_interruptible()", __func__);
+ dbg("%s(): after buf_clear()", __func__);
/* cancel scheduled setup */
cancel_delayed_work(&priv->delayed_setup_work);
@@ -694,15 +656,6 @@ static void oti6858_close(struct tty_struct *tty,
usb_kill_urb(port->write_urb);
usb_kill_urb(port->read_urb);
usb_kill_urb(port->interrupt_in_urb);
-
- /*
- if (tty && (tty->termios->c_cflag) & HUPCL) {
- // drop DTR and RTS
- spin_lock_irqsave(&priv->lock, flags);
- priv->pending_setup.control &= ~CONTROL_MASK;
- spin_unlock_irqrestore(&priv->lock, flags);
- }
- */
}
static int oti6858_tiocmset(struct tty_struct *tty, struct file *file,
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 751a533a4347..e02dc3d643c7 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -652,69 +652,41 @@ static void pl2303_set_termios(struct tty_struct *tty,
kfree(buf);
}
-static void pl2303_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void pl2303_dtr_rts(struct usb_serial_port *port, int on)
+{
+ struct pl2303_private *priv = usb_get_serial_port_data(port);
+ unsigned long flags;
+ u8 control;
+
+ spin_lock_irqsave(&priv->lock, flags);
+ /* Change DTR and RTS */
+ if (on)
+ priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
+ else
+ priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
+ control = priv->line_control;
+ spin_unlock_irqrestore(&priv->lock, flags);
+ set_control_lines(port->serial->dev, control);
+}
+
+static void pl2303_close(struct usb_serial_port *port)
{
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
- unsigned int c_cflag;
- int bps;
- long timeout;
- wait_queue_t wait;
dbg("%s - port %d", __func__, port->number);
- /* wait for data to drain from the buffer */
spin_lock_irqsave(&priv->lock, flags);
- timeout = PL2303_CLOSING_WAIT;
- init_waitqueue_entry(&wait, current);
- add_wait_queue(&tty->write_wait, &wait);
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (pl2303_buf_data_avail(priv->buf) == 0 ||
- timeout == 0 || signal_pending(current) ||
- port->serial->disconnected)
- break;
- spin_unlock_irqrestore(&priv->lock, flags);
- timeout = schedule_timeout(timeout);
- spin_lock_irqsave(&priv->lock, flags);
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&tty->write_wait, &wait);
/* clear out any remaining data in the buffer */
pl2303_buf_clear(priv->buf);
spin_unlock_irqrestore(&priv->lock, flags);
- /* wait for characters to drain from the device */
- /* (this is long enough for the entire 256 byte */
- /* pl2303 hardware buffer to drain with no flow */
- /* control for data rates of 1200 bps or more, */
- /* for lower rates we should really know how much */
- /* data is in the buffer to compute a delay */
- /* that is not unnecessarily long) */
- bps = tty_get_baud_rate(tty);
- if (bps > 1200)
- timeout = max((HZ*2560)/bps, HZ/10);
- else
- timeout = 2*HZ;
- schedule_timeout_interruptible(timeout);
-
/* shutdown our urbs */
dbg("%s - shutting down urbs", __func__);
usb_kill_urb(port->write_urb);
usb_kill_urb(port->read_urb);
usb_kill_urb(port->interrupt_in_urb);
- if (tty) {
- c_cflag = tty->termios->c_cflag;
- if (c_cflag & HUPCL) {
- /* drop DTR and RTS */
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
- set_control_lines(port->serial->dev, 0);
- }
- }
}
static int pl2303_open(struct tty_struct *tty,
@@ -748,7 +720,7 @@ static int pl2303_open(struct tty_struct *tty,
if (result) {
dev_err(&port->dev, "%s - failed submitting read urb,"
" error %d\n", __func__, result);
- pl2303_close(tty, port, NULL);
+ pl2303_close(port);
return -EPROTO;
}
@@ -758,9 +730,10 @@ static int pl2303_open(struct tty_struct *tty,
if (result) {
dev_err(&port->dev, "%s - failed submitting interrupt urb,"
" error %d\n", __func__, result);
- pl2303_close(tty, port, NULL);
+ pl2303_close(port);
return -EPROTO;
}
+ port->port.drain_delay = 256;
return 0;
}
@@ -821,6 +794,14 @@ static int pl2303_tiocmget(struct tty_struct *tty, struct file *file)
return result;
}
+static int pl2303_carrier_raised(struct usb_serial_port *port)
+{
+ struct pl2303_private *priv = usb_get_serial_port_data(port);
+ if (priv->line_status & UART_DCD)
+ return 1;
+ return 0;
+}
+
static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
{
struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -1125,6 +1106,8 @@ static struct usb_serial_driver pl2303_device = {
.num_ports = 1,
.open = pl2303_open,
.close = pl2303_close,
+ .dtr_rts = pl2303_dtr_rts,
+ .carrier_raised = pl2303_carrier_raised,
.write = pl2303_write,
.ioctl = pl2303_ioctl,
.break_ctl = pl2303_break_ctl,
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 913225c61610..57ae3d7274b1 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,7 +1,10 @@
/*
USB Driver for Sierra Wireless
- Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com>
+ Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com>,
+
+ Copyright (C) 2008, 2009 Elina Pasheva, Matthew Safar, Rory Filer
+ <linux@sierrawireless.com>
IMPORTANT DISCLAIMER: This driver is not commercially supported by
Sierra Wireless. Use at your own risk.
@@ -14,8 +17,8 @@
Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
*/
-#define DRIVER_VERSION "v.1.3.3"
-#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>"
+#define DRIVER_VERSION "v.1.3.7"
+#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer"
#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
#include <linux/kernel.h>
@@ -32,17 +35,22 @@
#define SWIMS_USB_REQUEST_SetNmea 0x07
/* per port private data */
-#define N_IN_URB 4
-#define N_OUT_URB 4
+#define N_IN_URB 8
+#define N_OUT_URB 64
#define IN_BUFLEN 4096
+#define MAX_TRANSFER (PAGE_SIZE - 512)
+/* MAX_TRANSFER is chosen so that the VM is not stressed by
+ allocations > PAGE_SIZE and the number of packets in a page
+ is an integer 512 is the largest possible packet on EHCI */
+
static int debug;
static int nmea;
static int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
{
int result;
- dev_dbg(&udev->dev, "%s", __func__);
+ dev_dbg(&udev->dev, "%s\n", __func__);
result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
SWIMS_USB_REQUEST_SetPower, /* __u8 request */
USB_TYPE_VENDOR, /* __u8 request type */
@@ -57,7 +65,7 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable)
{
int result;
- dev_dbg(&udev->dev, "%s", __func__);
+ dev_dbg(&udev->dev, "%s\n", __func__);
result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
SWIMS_USB_REQUEST_SetNmea, /* __u8 request */
USB_TYPE_VENDOR, /* __u8 request type */
@@ -71,18 +79,22 @@ static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable)
static int sierra_calc_num_ports(struct usb_serial *serial)
{
- int result;
- int *num_ports = usb_get_serial_data(serial);
- dev_dbg(&serial->dev->dev, "%s", __func__);
+ int num_ports = 0;
+ u8 ifnum, numendpoints;
- result = *num_ports;
+ dev_dbg(&serial->dev->dev, "%s\n", __func__);
- if (result) {
- kfree(num_ports);
- usb_set_serial_data(serial, NULL);
- }
+ ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
+ numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints;
- return result;
+ /* Dummy interface present on some SKUs should be ignored */
+ if (ifnum == 0x99)
+ num_ports = 0;
+ else if (numendpoints <= 3)
+ num_ports = 1;
+ else
+ num_ports = (numendpoints-1)/2;
+ return num_ports;
}
static int sierra_calc_interface(struct usb_serial *serial)
@@ -90,7 +102,7 @@ static int sierra_calc_interface(struct usb_serial *serial)
int interface;
struct usb_interface *p_interface;
struct usb_host_interface *p_host_interface;
- dev_dbg(&serial->dev->dev, "%s", __func__);
+ dev_dbg(&serial->dev->dev, "%s\n", __func__);
/* Get the interface structure pointer from the serial struct */
p_interface = serial->interface;
@@ -111,23 +123,12 @@ static int sierra_probe(struct usb_serial *serial,
{
int result = 0;
struct usb_device *udev;
- int *num_ports;
u8 ifnum;
- u8 numendpoints;
-
- dev_dbg(&serial->dev->dev, "%s", __func__);
- num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL);
- if (!num_ports)
- return -ENOMEM;
-
- ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
- numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints;
udev = serial->dev;
+ dev_dbg(&udev->dev, "%s\n", __func__);
- /* Figure out the interface number from the serial structure */
ifnum = sierra_calc_interface(serial);
-
/*
* If this interface supports more than 1 alternate
* select the 2nd one
@@ -139,20 +140,6 @@ static int sierra_probe(struct usb_serial *serial,
usb_set_interface(udev, ifnum, 1);
}
- /* Dummy interface present on some SKUs should be ignored */
- if (ifnum == 0x99)
- *num_ports = 0;
- else if (numendpoints <= 3)
- *num_ports = 1;
- else
- *num_ports = (numendpoints-1)/2;
-
- /*
- * save off our num_ports info so that we can use it in the
- * calc_num_ports callback
- */
- usb_set_serial_data(serial, (void *)num_ports);
-
return result;
}
@@ -240,66 +227,48 @@ struct sierra_port_private {
int ri_state;
};
-static int sierra_send_setup(struct tty_struct *tty,
- struct usb_serial_port *port)
+static int sierra_send_setup(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct sierra_port_private *portdata;
__u16 interface = 0;
+ int val = 0;
- dev_dbg(&port->dev, "%s", __func__);
+ dev_dbg(&port->dev, "%s\n", __func__);
portdata = usb_get_serial_port_data(port);
- if (tty) {
- int val = 0;
- if (portdata->dtr_state)
- val |= 0x01;
- if (portdata->rts_state)
- val |= 0x02;
-
- /* If composite device then properly report interface */
- if (serial->num_ports == 1) {
- interface = sierra_calc_interface(serial);
-
- /* Control message is sent only to interfaces with
- * interrupt_in endpoints
- */
- if (port->interrupt_in_urb) {
- /* send control message */
- return usb_control_msg(serial->dev,
- usb_rcvctrlpipe(serial->dev, 0),
- 0x22, 0x21, val, interface,
- NULL, 0, USB_CTRL_SET_TIMEOUT);
- }
- }
-
- /* Otherwise the need to do non-composite mapping */
- else {
- if (port->bulk_out_endpointAddress == 2)
- interface = 0;
- else if (port->bulk_out_endpointAddress == 4)
- interface = 1;
- else if (port->bulk_out_endpointAddress == 5)
- interface = 2;
-
- return usb_control_msg(serial->dev,
- usb_rcvctrlpipe(serial->dev, 0),
- 0x22, 0x21, val, interface,
- NULL, 0, USB_CTRL_SET_TIMEOUT);
-
- }
+ if (portdata->dtr_state)
+ val |= 0x01;
+ if (portdata->rts_state)
+ val |= 0x02;
+
+ /* If composite device then properly report interface */
+ if (serial->num_ports == 1)
+ interface = sierra_calc_interface(serial);
+
+ /* Otherwise the need to do non-composite mapping */
+ else {
+ if (port->bulk_out_endpointAddress == 2)
+ interface = 0;
+ else if (port->bulk_out_endpointAddress == 4)
+ interface = 1;
+ else if (port->bulk_out_endpointAddress == 5)
+ interface = 2;
}
-
+ return usb_control_msg(serial->dev,
+ usb_rcvctrlpipe(serial->dev, 0),
+ 0x22, 0x21, val, interface,
+ NULL, 0, USB_CTRL_SET_TIMEOUT);
return 0;
}
static void sierra_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
- dev_dbg(&port->dev, "%s", __func__);
+ dev_dbg(&port->dev, "%s\n", __func__);
tty_termios_copy_hw(tty->termios, old_termios);
- sierra_send_setup(tty, port);
+ sierra_send_setup(port);
}
static int sierra_tiocmget(struct tty_struct *tty, struct file *file)
@@ -308,7 +277,7 @@ static int sierra_tiocmget(struct tty_struct *tty, struct file *file)
unsigned int value;
struct sierra_port_private *portdata;
- dev_dbg(&port->dev, "%s", __func__);
+ dev_dbg(&port->dev, "%s\n", __func__);
portdata = usb_get_serial_port_data(port);
value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
@@ -338,7 +307,7 @@ static int sierra_tiocmset(struct tty_struct *tty, struct file *file,
portdata->rts_state = 0;
if (clear & TIOCM_DTR)
portdata->dtr_state = 0;
- return sierra_send_setup(tty, port);
+ return sierra_send_setup(port);
}
static void sierra_outdat_callback(struct urb *urb)
@@ -348,14 +317,14 @@ static void sierra_outdat_callback(struct urb *urb)
int status = urb->status;
unsigned long flags;
- dev_dbg(&port->dev, "%s - port %d", __func__, port->number);
+ dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
/* free up the transfer buffer, as usb_free_urb() does not do this */
kfree(urb->transfer_buffer);
if (status)
dev_dbg(&port->dev, "%s - nonzero write bulk status "
- "received: %d", __func__, status);
+ "received: %d\n", __func__, status);
spin_lock_irqsave(&portdata->lock, flags);
--portdata->outstanding_urbs;
@@ -373,50 +342,61 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
unsigned long flags;
unsigned char *buffer;
struct urb *urb;
- int status;
+ size_t writesize = min((size_t)count, (size_t)MAX_TRANSFER);
+ int retval = 0;
+
+ /* verify that we actually have some data to write */
+ if (count == 0)
+ return 0;
portdata = usb_get_serial_port_data(port);
- dev_dbg(&port->dev, "%s: write (%d chars)", __func__, count);
+ dev_dbg(&port->dev, "%s: write (%d bytes)\n", __func__, writesize);
spin_lock_irqsave(&portdata->lock, flags);
+ dev_dbg(&port->dev, "%s - outstanding_urbs: %d\n", __func__,
+ portdata->outstanding_urbs);
if (portdata->outstanding_urbs > N_OUT_URB) {
spin_unlock_irqrestore(&portdata->lock, flags);
dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
return 0;
}
portdata->outstanding_urbs++;
+ dev_dbg(&port->dev, "%s - 1, outstanding_urbs: %d\n", __func__,
+ portdata->outstanding_urbs);
spin_unlock_irqrestore(&portdata->lock, flags);
- buffer = kmalloc(count, GFP_ATOMIC);
+ buffer = kmalloc(writesize, GFP_ATOMIC);
if (!buffer) {
dev_err(&port->dev, "out of memory\n");
- count = -ENOMEM;
+ retval = -ENOMEM;
goto error_no_buffer;
}
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
dev_err(&port->dev, "no more free urbs\n");
- count = -ENOMEM;
+ retval = -ENOMEM;
goto error_no_urb;
}
- memcpy(buffer, buf, count);
+ memcpy(buffer, buf, writesize);
- usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
+ usb_serial_debug_data(debug, &port->dev, __func__, writesize, buffer);
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev,
port->bulk_out_endpointAddress),
- buffer, count, sierra_outdat_callback, port);
+ buffer, writesize, sierra_outdat_callback, port);
+
+ /* Handle the need to send a zero length packet */
+ urb->transfer_flags |= URB_ZERO_PACKET;
/* send it down the pipe */
- status = usb_submit_urb(urb, GFP_ATOMIC);
- if (status) {
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval) {
dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed "
- "with status = %d\n", __func__, status);
- count = status;
+ "with status = %d\n", __func__, retval);
goto error;
}
@@ -424,7 +404,7 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
* really free it when it is finished with it */
usb_free_urb(urb);
- return count;
+ return writesize;
error:
usb_free_urb(urb);
error_no_urb:
@@ -432,8 +412,10 @@ error_no_urb:
error_no_buffer:
spin_lock_irqsave(&portdata->lock, flags);
--portdata->outstanding_urbs;
+ dev_dbg(&port->dev, "%s - 2. outstanding_urbs: %d\n", __func__,
+ portdata->outstanding_urbs);
spin_unlock_irqrestore(&portdata->lock, flags);
- return count;
+ return retval;
}
static void sierra_indat_callback(struct urb *urb)
@@ -445,33 +427,39 @@ static void sierra_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer;
int status = urb->status;
- dbg("%s: %p", __func__, urb);
-
endpoint = usb_pipeendpoint(urb->pipe);
port = urb->context;
+ dev_dbg(&port->dev, "%s: %p\n", __func__, urb);
+
if (status) {
dev_dbg(&port->dev, "%s: nonzero status: %d on"
- " endpoint %02x.", __func__, status, endpoint);
+ " endpoint %02x\n", __func__, status, endpoint);
} else {
if (urb->actual_length) {
tty = tty_port_tty_get(&port->port);
+
tty_buffer_request_room(tty, urb->actual_length);
tty_insert_flip_string(tty, data, urb->actual_length);
tty_flip_buffer_push(tty);
+
tty_kref_put(tty);
- } else
+ usb_serial_debug_data(debug, &port->dev, __func__,
+ urb->actual_length, data);
+ } else {
dev_dbg(&port->dev, "%s: empty read urb"
- " received", __func__);
-
- /* Resubmit urb so we continue receiving */
- if (port->port.count && status != -ESHUTDOWN) {
- err = usb_submit_urb(urb, GFP_ATOMIC);
- if (err)
- dev_err(&port->dev, "resubmit read urb failed."
- "(%d)\n", err);
+ " received\n", __func__);
}
}
+
+ /* Resubmit urb so we continue receiving */
+ if (port->port.count && status != -ESHUTDOWN && status != -ENOENT) {
+ err = usb_submit_urb(urb, GFP_ATOMIC);
+ if (err)
+ dev_err(&port->dev, "resubmit read urb failed."
+ "(%d)\n", err);
+ }
+
return;
}
@@ -483,8 +471,7 @@ static void sierra_instat_callback(struct urb *urb)
struct sierra_port_private *portdata = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial;
- dev_dbg(&port->dev, "%s", __func__);
- dev_dbg(&port->dev, "%s: urb %p port %p has data %p", __func__,
+ dev_dbg(&port->dev, "%s: urb %p port %p has data %p\n", __func__,
urb, port, portdata);
if (status == 0) {
@@ -504,7 +491,7 @@ static void sierra_instat_callback(struct urb *urb)
sizeof(struct usb_ctrlrequest));
struct tty_struct *tty;
- dev_dbg(&port->dev, "%s: signal x%x", __func__,
+ dev_dbg(&port->dev, "%s: signal x%x\n", __func__,
signals);
old_dcd_state = portdata->dcd_state;
@@ -519,20 +506,20 @@ static void sierra_instat_callback(struct urb *urb)
tty_hangup(tty);
tty_kref_put(tty);
} else {
- dev_dbg(&port->dev, "%s: type %x req %x",
+ dev_dbg(&port->dev, "%s: type %x req %x\n",
__func__, req_pkt->bRequestType,
req_pkt->bRequest);
}
} else
- dev_dbg(&port->dev, "%s: error %d", __func__, status);
+ dev_dbg(&port->dev, "%s: error %d\n", __func__, status);
/* Resubmit urb so we continue receiving IRQ data */
- if (status != -ESHUTDOWN) {
+ if (port->port.count && status != -ESHUTDOWN && status != -ENOENT) {
urb->dev = serial->dev;
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err)
- dev_dbg(&port->dev, "%s: resubmit intr urb "
- "failed. (%d)", __func__, err);
+ dev_err(&port->dev, "%s: resubmit intr urb "
+ "failed. (%d)\n", __func__, err);
}
}
@@ -542,7 +529,7 @@ static int sierra_write_room(struct tty_struct *tty)
struct sierra_port_private *portdata = usb_get_serial_port_data(port);
unsigned long flags;
- dev_dbg(&port->dev, "%s - port %d", __func__, port->number);
+ dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
/* try to give a good number back based on if we have any free urbs at
* this point in time */
@@ -568,7 +555,7 @@ static int sierra_open(struct tty_struct *tty,
portdata = usb_get_serial_port_data(port);
- dev_dbg(&port->dev, "%s", __func__);
+ dev_dbg(&port->dev, "%s\n", __func__);
/* Set some sane defaults */
portdata->rts_state = 1;
@@ -580,7 +567,7 @@ static int sierra_open(struct tty_struct *tty,
if (!urb)
continue;
if (urb->dev != serial->dev) {
- dev_dbg(&port->dev, "%s: dev %p != %p",
+ dev_dbg(&port->dev, "%s: dev %p != %p\n",
__func__, urb->dev, serial->dev);
continue;
}
@@ -598,7 +585,7 @@ static int sierra_open(struct tty_struct *tty,
}
}
- sierra_send_setup(tty, port);
+ sierra_send_setup(port);
/* start up the interrupt endpoint if we have one */
if (port->interrupt_in_urb) {
@@ -610,32 +597,38 @@ static int sierra_open(struct tty_struct *tty,
return 0;
}
-static void sierra_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void sierra_dtr_rts(struct usb_serial_port *port, int on)
{
- int i;
struct usb_serial *serial = port->serial;
struct sierra_port_private *portdata;
- dev_dbg(&port->dev, "%s", __func__);
portdata = usb_get_serial_port_data(port);
-
- portdata->rts_state = 0;
- portdata->dtr_state = 0;
+ portdata->rts_state = on;
+ portdata->dtr_state = on;
if (serial->dev) {
mutex_lock(&serial->disc_mutex);
if (!serial->disconnected)
- sierra_send_setup(tty, port);
+ sierra_send_setup(port);
mutex_unlock(&serial->disc_mutex);
+ }
+}
+static void sierra_close(struct usb_serial_port *port)
+{
+ int i;
+ struct usb_serial *serial = port->serial;
+ struct sierra_port_private *portdata;
+
+ dev_dbg(&port->dev, "%s\n", __func__);
+ portdata = usb_get_serial_port_data(port);
+
+ if (serial->dev) {
/* Stop reading/writing urbs */
for (i = 0; i < N_IN_URB; i++)
usb_kill_urb(portdata->in_urbs[i]);
}
-
usb_kill_urb(port->interrupt_in_urb);
- tty_port_tty_set(&port->port, NULL);
}
static int sierra_startup(struct usb_serial *serial)
@@ -646,7 +639,7 @@ static int sierra_startup(struct usb_serial *serial)
int i;
int j;
- dev_dbg(&serial->dev->dev, "%s", __func__);
+ dev_dbg(&serial->dev->dev, "%s\n", __func__);
/* Set Device mode to D0 */
sierra_set_power_state(serial->dev, 0x0000);
@@ -661,7 +654,7 @@ static int sierra_startup(struct usb_serial *serial)
portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
if (!portdata) {
dev_dbg(&port->dev, "%s: kmalloc for "
- "sierra_port_private (%d) failed!.",
+ "sierra_port_private (%d) failed!\n",
__func__, i);
return -ENOMEM;
}
@@ -683,7 +676,7 @@ static int sierra_startup(struct usb_serial *serial)
urb = usb_alloc_urb(0, GFP_KERNEL);
if (urb == NULL) {
dev_dbg(&port->dev, "%s: alloc for in "
- "port failed.", __func__);
+ "port failed.\n", __func__);
continue;
}
/* Fill URB using supplied data. */
@@ -705,7 +698,7 @@ static void sierra_shutdown(struct usb_serial *serial)
struct usb_serial_port *port;
struct sierra_port_private *portdata;
- dev_dbg(&serial->dev->dev, "%s", __func__);
+ dev_dbg(&serial->dev->dev, "%s\n", __func__);
for (i = 0; i < serial->num_ports; ++i) {
port = serial->port[i];
@@ -737,6 +730,7 @@ static struct usb_serial_driver sierra_device = {
.probe = sierra_probe,
.open = sierra_open,
.close = sierra_close,
+ .dtr_rts = sierra_dtr_rts,
.write = sierra_write,
.write_room = sierra_write_room,
.set_termios = sierra_set_termios,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 5e7528cc81a8..8f7ed8f13996 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -446,66 +446,47 @@ static void spcp8x5_set_workMode(struct usb_device *dev, u16 value,
"RTSCTS usb_control_msg(enable flowctrl) = %d\n", ret);
}
+static int spcp8x5_carrier_raised(struct usb_serial_port *port)
+{
+ struct spcp8x5_private *priv = usb_get_serial_port_data(port);
+ if (priv->line_status & MSR_STATUS_LINE_DCD)
+ return 1;
+ return 0;
+}
+
+static void spcp8x5_dtr_rts(struct usb_serial_port *port, int on)
+{
+ struct spcp8x5_private *priv = usb_get_serial_port_data(port);
+ unsigned long flags;
+ u8 control;
+
+ spin_lock_irqsave(&priv->lock, flags);
+ if (on)
+ priv->line_control = MCR_CONTROL_LINE_DTR
+ | MCR_CONTROL_LINE_RTS;
+ else
+ priv->line_control &= ~ (MCR_CONTROL_LINE_DTR
+ | MCR_CONTROL_LINE_RTS);
+ control = priv->line_control;
+ spin_unlock_irqrestore(&priv->lock, flags);
+ spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type);
+}
+
/* close the serial port. We should wait for data sending to device 1st and
* then kill all urb. */
-static void spcp8x5_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void spcp8x5_close(struct usb_serial_port *port)
{
struct spcp8x5_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
- unsigned int c_cflag;
- int bps;
- long timeout;
- wait_queue_t wait;
int result;
dbg("%s - port %d", __func__, port->number);
- /* wait for data to drain from the buffer */
spin_lock_irqsave(&priv->lock, flags);
- timeout = SPCP8x5_CLOSING_WAIT;
- init_waitqueue_entry(&wait, current);
- add_wait_queue(&tty->write_wait, &wait);
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (ringbuf_avail_data(priv->buf) == 0 ||
- timeout == 0 || signal_pending(current))
- break;
- spin_unlock_irqrestore(&priv->lock, flags);
- timeout = schedule_timeout(timeout);
- spin_lock_irqsave(&priv->lock, flags);
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&tty->write_wait, &wait);
-
/* clear out any remaining data in the buffer */
clear_ringbuf(priv->buf);
spin_unlock_irqrestore(&priv->lock, flags);
- /* wait for characters to drain from the device (this is long enough
- * for the entire all byte spcp8x5 hardware buffer to drain with no
- * flow control for data rates of 1200 bps or more, for lower rates we
- * should really know how much data is in the buffer to compute a delay
- * that is not unnecessarily long) */
- bps = tty_get_baud_rate(tty);
- if (bps > 1200)
- timeout = max((HZ*2560) / bps, HZ/10);
- else
- timeout = 2*HZ;
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(timeout);
-
- /* clear control lines */
- if (tty) {
- c_cflag = tty->termios->c_cflag;
- if (c_cflag & HUPCL) {
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
- spcp8x5_set_ctrlLine(port->serial->dev, 0 , priv->type);
- }
- }
-
/* kill urb */
if (port->write_urb != NULL) {
result = usb_unlink_urb(port->write_urb);
@@ -665,13 +646,6 @@ static int spcp8x5_open(struct tty_struct *tty,
if (ret)
return ret;
- spin_lock_irqsave(&priv->lock, flags);
- if (tty && (tty->termios->c_cflag & CBAUD))
- priv->line_control = MCR_DTR | MCR_RTS;
- else
- priv->line_control = 0;
- spin_unlock_irqrestore(&priv->lock, flags);
-
spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type);
/* Setup termios */
@@ -691,9 +665,10 @@ static int spcp8x5_open(struct tty_struct *tty,
port->read_urb->dev = serial->dev;
ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (ret) {
- spcp8x5_close(tty, port, NULL);
+ spcp8x5_close(port);
return -EPROTO;
}
+ port->port.drain_delay = 256;
return 0;
}
@@ -1033,6 +1008,8 @@ static struct usb_serial_driver spcp8x5_device = {
.num_ports = 1,
.open = spcp8x5_open,
.close = spcp8x5_close,
+ .dtr_rts = spcp8x5_dtr_rts,
+ .carrier_raised = spcp8x5_carrier_raised,
.write = spcp8x5_write,
.set_termios = spcp8x5_set_termios,
.ioctl = spcp8x5_ioctl,
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index 69879e437940..8b07ebc6baeb 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -152,8 +152,7 @@ static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port,
return result;
}
-static void symbol_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static void symbol_close(struct usb_serial_port *port)
{
struct symbol_private *priv = usb_get_serial_data(port->serial);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 0a64bac306ee..42cb04c403be 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -100,8 +100,7 @@ static int ti_startup(struct usb_serial *serial);
static void ti_shutdown(struct usb_serial *serial);
static int ti_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *file);
-static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *file);
+static void ti_close(struct usb_serial_port *port);
static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *data, int count);
static int ti_write_room(struct tty_struct *tty);
@@ -647,8 +646,7 @@ release_lock:
}
-static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *file)
+static void ti_close(struct usb_serial_port *port)
{
struct ti_device *tdev;
struct ti_port *tport;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 0a566eea49c0..f1eb80537d8d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -238,9 +238,11 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
goto bailout_interface_put;
mutex_unlock(&serial->disc_mutex);
}
-
mutex_unlock(&port->mutex);
- return 0;
+ /* Now do the correct tty layer semantics */
+ retval = tty_port_block_til_ready(&port->port, tty, filp);
+ if (retval == 0)
+ return 0;
bailout_interface_put:
usb_autopm_put_interface(serial->interface);
@@ -259,64 +261,89 @@ bailout_serial_put:
return retval;
}
-static void serial_close(struct tty_struct *tty, struct file *filp)
+/**
+ * serial_do_down - shut down hardware
+ * @port: port to shut down
+ *
+ * Shut down a USB port unless it is the console. We never shut down the
+ * console hardware as it will always be in use.
+ *
+ * Don't free any resources at this point
+ */
+static void serial_do_down(struct usb_serial_port *port)
{
- struct usb_serial_port *port = tty->driver_data;
+ struct usb_serial_driver *drv = port->serial->type;
struct usb_serial *serial;
struct module *owner;
- int count;
- if (!port)
+ /* The console is magical, do not hang up the console hardware
+ or there will be tears */
+ if (port->console)
return;
- dbg("%s - port %d", __func__, port->number);
-
mutex_lock(&port->mutex);
serial = port->serial;
owner = serial->type->driver.owner;
- if (port->port.count == 0) {
- mutex_unlock(&port->mutex);
- return;
- }
-
- if (port->port.count == 1)
- /* only call the device specific close if this
- * port is being closed by the last owner. Ensure we do
- * this before we drop the port count. The call is protected
- * by the port mutex
- */
- serial->type->close(tty, port, filp);
-
- if (port->port.count == (port->console ? 2 : 1)) {
- struct tty_struct *tty = tty_port_tty_get(&port->port);
- if (tty) {
- /* We must do this before we drop the port count to
- zero. */
- if (tty->driver_data)
- tty->driver_data = NULL;
- tty_port_tty_set(&port->port, NULL);
- tty_kref_put(tty);
- }
- }
+ if (drv->close)
+ drv->close(port);
- --port->port.count;
- count = port->port.count;
mutex_unlock(&port->mutex);
- put_device(&port->dev);
+}
+
+/**
+ * serial_do_free - free resources post close/hangup
+ * @port: port to free up
+ *
+ * Do the resource freeing and refcount dropping for the port. We must
+ * be careful about ordering and we must avoid freeing up the console.
+ */
+static void serial_do_free(struct usb_serial_port *port)
+{
+ struct usb_serial *serial;
+ struct module *owner;
+
+ /* The console is magical, do not hang up the console hardware
+ or there will be tears */
+ if (port->console)
+ return;
+
+ serial = port->serial;
+ owner = serial->type->driver.owner;
+ put_device(&port->dev);
/* Mustn't dereference port any more */
- if (count == 0) {
- mutex_lock(&serial->disc_mutex);
- if (!serial->disconnected)
- usb_autopm_put_interface(serial->interface);
- mutex_unlock(&serial->disc_mutex);
- }
+ mutex_lock(&serial->disc_mutex);
+ if (!serial->disconnected)
+ usb_autopm_put_interface(serial->interface);
+ mutex_unlock(&serial->disc_mutex);
usb_serial_put(serial);
-
/* Mustn't dereference serial any more */
- if (count == 0)
- module_put(owner);
+ module_put(owner);
+}
+
+static void serial_close(struct tty_struct *tty, struct file *filp)
+{
+ struct usb_serial_port *port = tty->driver_data;
+
+ dbg("%s - port %d", __func__, port->number);
+
+
+ if (tty_port_close_start(&port->port, tty, filp) == 0)
+ return;
+
+ serial_do_down(port);
+ tty_port_close_end(&port->port, tty);
+ tty_port_tty_set(&port->port, NULL);
+ serial_do_free(port);
+}
+
+static void serial_hangup(struct tty_struct *tty)
+{
+ struct usb_serial_port *port = tty->driver_data;
+ serial_do_down(port);
+ tty_port_hangup(&port->port);
+ serial_do_free(port);
}
static int serial_write(struct tty_struct *tty, const unsigned char *buf,
@@ -648,6 +675,29 @@ static struct usb_serial_driver *search_serial_device(
return NULL;
}
+static int serial_carrier_raised(struct tty_port *port)
+{
+ struct usb_serial_port *p = container_of(port, struct usb_serial_port, port);
+ struct usb_serial_driver *drv = p->serial->type;
+ if (drv->carrier_raised)
+ return drv->carrier_raised(p);
+ /* No carrier control - don't block */
+ return 1;
+}
+
+static void serial_dtr_rts(struct tty_port *port, int on)
+{
+ struct usb_serial_port *p = container_of(port, struct usb_serial_port, port);
+ struct usb_serial_driver *drv = p->serial->type;
+ if (drv->dtr_rts)
+ drv->dtr_rts(p, on);
+}
+
+static const struct tty_port_operations serial_port_ops = {
+ .carrier_raised = serial_carrier_raised,
+ .dtr_rts = serial_dtr_rts,
+};
+
int usb_serial_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
@@ -841,6 +891,7 @@ int usb_serial_probe(struct usb_interface *interface,
if (!port)
goto probe_error;
tty_port_init(&port->port);
+ port->port.ops = &serial_port_ops;
port->serial = serial;
spin_lock_init(&port->lock);
mutex_init(&port->mutex);
@@ -1070,6 +1121,9 @@ void usb_serial_disconnect(struct usb_interface *interface)
if (port) {
struct tty_struct *tty = tty_port_tty_get(&port->port);
if (tty) {
+ /* The hangup will occur asynchronously but
+ the object refcounts will sort out all the
+ cleanup */
tty_hangup(tty);
tty_kref_put(tty);
}
@@ -1134,6 +1188,7 @@ static const struct tty_operations serial_ops = {
.open = serial_open,
.close = serial_close,
.write = serial_write,
+ .hangup = serial_hangup,
.write_room = serial_write_room,
.ioctl = serial_ioctl,
.set_termios = serial_set_termios,
@@ -1146,6 +1201,7 @@ static const struct tty_operations serial_ops = {
.proc_fops = &serial_proc_fops,
};
+
struct tty_driver *usb_serial_tty_driver;
static int __init usb_serial_init(void)
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 6c9cbb59552a..614800972dc3 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -15,7 +15,19 @@
#include <linux/usb.h>
#include <linux/usb/serial.h>
+#define URB_DEBUG_MAX_IN_FLIGHT_URBS 4000
#define USB_DEBUG_MAX_PACKET_SIZE 8
+#define USB_DEBUG_BRK_SIZE 8
+static char USB_DEBUG_BRK[USB_DEBUG_BRK_SIZE] = {
+ 0x00,
+ 0xff,
+ 0x01,
+ 0xfe,
+ 0x00,
+ 0xfe,
+ 0x01,
+ 0xff,
+};
static struct usb_device_id id_table [] = {
{ USB_DEVICE(0x0525, 0x127a) },
@@ -38,6 +50,32 @@ static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
return usb_serial_generic_open(tty, port, filp);
}
+/* This HW really does not support a serial break, so one will be
+ * emulated when ever the break state is set to true.
+ */
+static void usb_debug_break_ctl(struct tty_struct *tty, int break_state)
+{
+ struct usb_serial_port *port = tty->driver_data;
+ if (!break_state)
+ return;
+ usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE);
+}
+
+static void usb_debug_read_bulk_callback(struct urb *urb)
+{
+ struct usb_serial_port *port = urb->context;
+
+ if (urb->actual_length == USB_DEBUG_BRK_SIZE &&
+ memcmp(urb->transfer_buffer, USB_DEBUG_BRK,
+ USB_DEBUG_BRK_SIZE) == 0) {
+ usb_serial_handle_break(port);
+ usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC);
+ return;
+ }
+
+ usb_serial_generic_read_bulk_callback(urb);
+}
+
static struct usb_serial_driver debug_device = {
.driver = {
.owner = THIS_MODULE,
@@ -46,6 +84,9 @@ static struct usb_serial_driver debug_device = {
.id_table = id_table,
.num_ports = 1,
.open = usb_debug_open,
+ .max_in_flight_urbs = URB_DEBUG_MAX_IN_FLIGHT_URBS,
+ .break_ctl = usb_debug_break_ctl,
+ .read_bulk_callback = usb_debug_read_bulk_callback,
};
static int __init debug_init(void)
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 5ac414bda718..b15f1c0e1d4a 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -38,8 +38,7 @@
/* function prototypes for a handspring visor */
static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
-static void visor_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp);
+static void visor_close(struct usb_serial_port *port);
static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static int visor_write_room(struct tty_struct *tty);
@@ -324,8 +323,7 @@ exit:
}
-static void visor_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void visor_close(struct usb_serial_port *port)
{
struct visor_private *priv = usb_get_serial_port_data(port);
unsigned char *transfer_buffer;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 5335d3211c07..7c7295d09f34 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -147,8 +147,7 @@ static int whiteheat_attach(struct usb_serial *serial);
static void whiteheat_shutdown(struct usb_serial *serial);
static int whiteheat_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp);
-static void whiteheat_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp);
+static void whiteheat_close(struct usb_serial_port *port);
static int whiteheat_write(struct tty_struct *tty,
struct usb_serial_port *port,
const unsigned char *buf, int count);
@@ -712,8 +711,7 @@ exit:
}
-static void whiteheat_close(struct tty_struct *tty,
- struct usb_serial_port *port, struct file *filp)
+static void whiteheat_close(struct usb_serial_port *port)
{
struct whiteheat_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap;
@@ -723,31 +721,7 @@ static void whiteheat_close(struct tty_struct *tty,
dbg("%s - port %d", __func__, port->number);
- mutex_lock(&port->serial->disc_mutex);
- /* filp is NULL when called from usb_serial_disconnect */
- if ((filp && (tty_hung_up_p(filp))) || port->serial->disconnected) {
- mutex_unlock(&port->serial->disc_mutex);
- return;
- }
- mutex_unlock(&port->serial->disc_mutex);
-
- tty->closing = 1;
-
-/*
- * Not currently in use; tty_wait_until_sent() calls
- * serial_chars_in_buffer() which deadlocks on the second semaphore
- * acquisition. This should be fixed at some point. Greg's been
- * notified.
- if ((filp->f_flags & (O_NDELAY | O_NONBLOCK)) == 0) {
- tty_wait_until_sent(tty, CLOSING_DELAY);
- }
-*/
-
- tty_driver_flush_buffer(tty);
- tty_ldisc_flush(tty);
-
firm_report_tx_done(port);
-
firm_close(port);
/* shutdown our bulk reads and writes */
@@ -775,10 +749,7 @@ static void whiteheat_close(struct tty_struct *tty,
}
spin_unlock_irq(&info->lock);
mutex_unlock(&info->deathwarrant);
-
stop_command_port(port->serial);
-
- tty->closing = 0;
}
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index 2dd9bd4bff56..ec17c96371af 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -52,7 +52,7 @@ int usb_stor_euscsi_init(struct us_data *us)
us->iobuf[0] = 0x1;
result = usb_stor_control_msg(us, us->send_ctrl_pipe,
0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR,
- 0x01, 0x0, us->iobuf, 0x1, 5*HZ);
+ 0x01, 0x0, us->iobuf, 0x1, 5000);
US_DEBUGP("-- result is %d\n", result);
return 0;
@@ -80,14 +80,16 @@ int usb_stor_ucr61s2b_init(struct us_data *us)
res = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb,
US_BULK_CB_WRAP_LEN, &partial);
- if(res)
- return res;
+ if (res)
+ return -EIO;
US_DEBUGP("Getting status packet...\n");
res = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
US_BULK_CS_WRAP_LEN, &partial);
+ if (res)
+ return -EIO;
- return (res ? -1 : 0);
+ return 0;
}
/* This places the HUAWEI E220 devices in multi-port mode */
@@ -99,6 +101,6 @@ int usb_stor_huawei_e220_init(struct us_data *us)
USB_REQ_SET_FEATURE,
USB_TYPE_STANDARD | USB_RECIP_DEVICE,
0x01, 0x0, NULL, 0x0, 1000);
- US_DEBUGP("usb_control_msg performing result is %d\n", result);
- return (result ? 0 : -1);
+ US_DEBUGP("Huawei mode set result is %d\n", result);
+ return (result ? 0 : -ENODEV);
}
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 353f922939a4..126ea3424c03 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -94,7 +94,8 @@ int option_ms_init(struct us_data *us)
*/
if (udev->descriptor.bDeviceClass != 0 ||
udev->descriptor.bDeviceSubClass != 0 ||
- udev->descriptor.bDeviceProtocol != 0)
+ udev->descriptor.bDeviceProtocol != 0 ||
+ udev->actconfig->desc.bNumInterfaces == 3)
return USB_STOR_TRANSPORT_GOOD;
US_DEBUGP("Option MS: option_ms_init called\n");
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 4ca3b5860643..cfa26d56ce60 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -132,7 +132,7 @@ static int slave_configure(struct scsi_device *sdev)
if (us->fflags & US_FL_MAX_SECTORS_MIN)
max_sectors = PAGE_CACHE_SIZE >> 9;
- if (sdev->request_queue->max_sectors > max_sectors)
+ if (queue_max_sectors(sdev->request_queue) > max_sectors)
blk_queue_max_sectors(sdev->request_queue,
max_sectors);
} else if (sdev->type == TYPE_TAPE) {
@@ -483,7 +483,7 @@ static ssize_t show_max_sectors(struct device *dev, struct device_attribute *att
{
struct scsi_device *sdev = to_scsi_device(dev);
- return sprintf(buf, "%u\n", sdev->request_queue->max_sectors);
+ return sprintf(buf, "%u\n", queue_max_sectors(sdev->request_queue));
}
/* Input routine for the sysfs max_sectors file */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 4b8b69045fe6..1b9c5dd0fb27 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1385,7 +1385,7 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000,
"D-Link",
"USB Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, option_ms_init, 0),
+ US_SC_DEVICE, US_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE),
/* Reported by Kevin Lloyd <linux@sierrawireless.com>
* Entry is needed for the initializer function override,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 74712cb8399a..2b5a691064b7 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -397,7 +397,7 @@ config FB_SA1100
config FB_IMX
tristate "Motorola i.MX LCD support"
- depends on FB && (ARCH_IMX || ARCH_MX2)
+ depends on FB && (ARCH_MX1 || ARCH_MX2)
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
@@ -1759,6 +1759,16 @@ config FB_68328
Say Y here if you want to support the built-in frame buffer of
the Motorola 68328 CPU family.
+config FB_PXA168
+ tristate "PXA168/910 LCD framebuffer support"
+ depends on FB && (CPU_PXA168 || CPU_PXA910)
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ ---help---
+ Frame buffer driver for the built-in LCD controller in the Marvell
+ MMP processor.
+
config FB_PXA
tristate "PXA LCD framebuffer support"
depends on FB && ARCH_PXA
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index d8d0be5151e3..01a819f47371 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_FB_GBE) += gbefb.o
obj-$(CONFIG_FB_CIRRUS) += cirrusfb.o
obj-$(CONFIG_FB_ASILIANT) += asiliantfb.o
obj-$(CONFIG_FB_PXA) += pxafb.o
+obj-$(CONFIG_FB_PXA168) += pxa168fb.o
obj-$(CONFIG_FB_W100) += w100fb.o
obj-$(CONFIG_FB_TMIO) += tmiofb.o
obj-$(CONFIG_FB_AU1100) += au1100fb.o
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 35e8eb02b9e9..e4e4d433b007 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -354,7 +354,7 @@ static int default_crt_on __devinitdata = 0;
static int default_lcd_on __devinitdata = 1;
#ifdef CONFIG_MTRR
-static int mtrr = 1;
+static bool mtrr = true;
#endif
#ifdef CONFIG_PMAC_BACKLIGHT
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 83c5cefc266c..da7c01b39be2 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -1736,10 +1736,8 @@ static int __init cyber2000fb_init(void)
#ifdef CONFIG_ARCH_SHARK
err = cyberpro_vl_probe();
- if (!err) {
+ if (!err)
ret = 0;
- __module_get(THIS_MODULE);
- }
#endif
#ifdef CONFIG_PCI
err = pci_register_driver(&cyberpro_driver);
@@ -1749,14 +1747,15 @@ static int __init cyber2000fb_init(void)
return ret ? err : 0;
}
+module_init(cyber2000fb_init);
+#ifndef CONFIG_ARCH_SHARK
static void __exit cyberpro_exit(void)
{
pci_unregister_driver(&cyberpro_driver);
}
-
-module_init(cyber2000fb_init);
module_exit(cyberpro_exit);
+#endif
MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("CyberPro 2000, 2010 and 5000 framebuffer driver");
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index e6467cf9f19f..020db7fc9153 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -335,9 +335,9 @@ static int __init hitfb_probe(struct platform_device *dev)
if (fb_get_options("hitfb", NULL))
return -ENODEV;
- hitfb_fix.mmio_start = CONFIG_HD64461_IOBASE+0x1000;
+ hitfb_fix.mmio_start = HD64461_IO_OFFSET(0x1000);
hitfb_fix.mmio_len = 0x1000;
- hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000;
+ hitfb_fix.smem_start = HD64461_IO_OFFSET(0x02000000);
hitfb_fix.smem_len = 512 * 1024;
lcdclor = fb_readw(HD64461_LCDCLOR);
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index 9894de1c9b9f..b7af5256e887 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -706,7 +706,7 @@ static void mx3fb_dma_done(void *arg)
dev_dbg(mx3fb->dev, "irq %d callback\n", ichannel->eof_irq);
/* We only need one interrupt, it will be re-enabled as needed */
- disable_irq(ichannel->eof_irq);
+ disable_irq_nosync(ichannel->eof_irq);
complete(&mx3_fbi->flip_cmpl);
}
@@ -1366,7 +1366,7 @@ static int init_fb_chan(struct mx3fb_data *mx3fb, struct idmac_channel *ichan)
mx3fb_blank(FB_BLANK_UNBLANK, fbi);
- dev_info(dev, "mx3fb: fb registered, using mode %s\n", fb_mode);
+ dev_info(dev, "registered, using mode %s\n", fb_mode);
ret = register_framebuffer(fbi);
if (ret < 0)
diff --git a/drivers/video/omap/hwa742.c b/drivers/video/omap/hwa742.c
index 8aa6e47202b9..12304763d7f7 100644
--- a/drivers/video/omap/hwa742.c
+++ b/drivers/video/omap/hwa742.c
@@ -133,8 +133,7 @@ struct {
struct lcd_ctrl_extif *extif;
struct lcd_ctrl *int_ctrl;
- void (*power_up)(struct device *dev);
- void (*power_down)(struct device *dev);
+ struct clk *sys_ck;
} hwa742;
struct lcd_ctrl hwa742_ctrl;
@@ -915,14 +914,13 @@ static void hwa742_suspend(void)
hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED);
/* Enable sleep mode */
hwa742_write_reg(HWA742_POWER_SAVE, 1 << 1);
- if (hwa742.power_down != NULL)
- hwa742.power_down(hwa742.fbdev->dev);
+ clk_disable(hwa742.sys_ck);
}
static void hwa742_resume(void)
{
- if (hwa742.power_up != NULL)
- hwa742.power_up(hwa742.fbdev->dev);
+ clk_enable(hwa742.sys_ck);
+
/* Disable sleep mode */
hwa742_write_reg(HWA742_POWER_SAVE, 0);
while (1) {
@@ -955,14 +953,13 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
omapfb_conf = fbdev->dev->platform_data;
ctrl_conf = omapfb_conf->ctrl_platform_data;
- if (ctrl_conf == NULL || ctrl_conf->get_clock_rate == NULL) {
+ if (ctrl_conf == NULL || ctrl_conf->sys_ck == NULL) {
dev_err(fbdev->dev, "HWA742: missing platform data\n");
r = -ENOENT;
goto err1;
}
- hwa742.power_down = ctrl_conf->power_down;
- hwa742.power_up = ctrl_conf->power_up;
+ hwa742.sys_ck = ctrl_conf->sys_ck;
spin_lock_init(&hwa742.req_lock);
@@ -972,12 +969,11 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
if ((r = hwa742.extif->init(fbdev)) < 0)
goto err2;
- ext_clk = ctrl_conf->get_clock_rate(fbdev->dev);
+ ext_clk = clk_get_rate(hwa742.sys_ck);
if ((r = calc_extif_timings(ext_clk, &extif_mem_div)) < 0)
goto err3;
hwa742.extif->set_timings(&hwa742.reg_timings);
- if (hwa742.power_up != NULL)
- hwa742.power_up(fbdev->dev);
+ clk_enable(hwa742.sys_ck);
calc_hwa742_clk_rates(ext_clk, &sys_clk, &pix_clk);
if ((r = calc_extif_timings(sys_clk, &extif_mem_div)) < 0)
@@ -1040,8 +1036,7 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
return 0;
err4:
- if (hwa742.power_down != NULL)
- hwa742.power_down(fbdev->dev);
+ clk_disable(hwa742.sys_ck);
err3:
hwa742.extif->cleanup();
err2:
@@ -1055,8 +1050,7 @@ static void hwa742_cleanup(void)
hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED);
hwa742.extif->cleanup();
hwa742.int_ctrl->cleanup();
- if (hwa742.power_down != NULL)
- hwa742.power_down(hwa742.fbdev->dev);
+ clk_disable(hwa742.sys_ck);
}
struct lcd_ctrl hwa742_ctrl = {
diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
new file mode 100644
index 000000000000..707f20c0079b
--- /dev/null
+++ b/drivers/video/pxa168fb.c
@@ -0,0 +1,798 @@
+/*
+ * linux/drivers/video/pxa168fb.c -- Marvell PXA168 LCD Controller
+ *
+ * Copyright (C) 2008 Marvell International Ltd.
+ * All rights reserved.
+ *
+ * 2009-02-16 adapted from original version for PXA168/910
+ * Jun Nie <njun@marvell.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/fb.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/uaccess.h>
+#include <video/pxa168fb.h>
+
+#include "pxa168fb.h"
+
+#define DEFAULT_REFRESH 60 /* Hz */
+
+static int determine_best_pix_fmt(struct fb_var_screeninfo *var)
+{
+ /*
+ * Pseudocolor mode?
+ */
+ if (var->bits_per_pixel == 8)
+ return PIX_FMT_PSEUDOCOLOR;
+
+ /*
+ * Check for 565/1555.
+ */
+ if (var->bits_per_pixel == 16 && var->red.length <= 5 &&
+ var->green.length <= 6 && var->blue.length <= 5) {
+ if (var->transp.length == 0) {
+ if (var->red.offset >= var->blue.offset)
+ return PIX_FMT_RGB565;
+ else
+ return PIX_FMT_BGR565;
+ }
+
+ if (var->transp.length == 1 && var->green.length <= 5) {
+ if (var->red.offset >= var->blue.offset)
+ return PIX_FMT_RGB1555;
+ else
+ return PIX_FMT_BGR1555;
+ }
+
+ /* fall through */
+ }
+
+ /*
+ * Check for 888/A888.
+ */
+ if (var->bits_per_pixel <= 32 && var->red.length <= 8 &&
+ var->green.length <= 8 && var->blue.length <= 8) {
+ if (var->bits_per_pixel == 24 && var->transp.length == 0) {
+ if (var->red.offset >= var->blue.offset)
+ return PIX_FMT_RGB888PACK;
+ else
+ return PIX_FMT_BGR888PACK;
+ }
+
+ if (var->bits_per_pixel == 32 && var->transp.length == 8) {
+ if (var->red.offset >= var->blue.offset)
+ return PIX_FMT_RGBA888;
+ else
+ return PIX_FMT_BGRA888;
+ } else {
+ if (var->red.offset >= var->blue.offset)
+ return PIX_FMT_RGB888UNPACK;
+ else
+ return PIX_FMT_BGR888UNPACK;
+ }
+
+ /* fall through */
+ }
+
+ return -EINVAL;
+}
+
+static void set_pix_fmt(struct fb_var_screeninfo *var, int pix_fmt)
+{
+ switch (pix_fmt) {
+ case PIX_FMT_RGB565:
+ var->bits_per_pixel = 16;
+ var->red.offset = 11; var->red.length = 5;
+ var->green.offset = 5; var->green.length = 6;
+ var->blue.offset = 0; var->blue.length = 5;
+ var->transp.offset = 0; var->transp.length = 0;
+ break;
+ case PIX_FMT_BGR565:
+ var->bits_per_pixel = 16;
+ var->red.offset = 0; var->red.length = 5;
+ var->green.offset = 5; var->green.length = 6;
+ var->blue.offset = 11; var->blue.length = 5;
+ var->transp.offset = 0; var->transp.length = 0;
+ break;
+ case PIX_FMT_RGB1555:
+ var->bits_per_pixel = 16;
+ var->red.offset = 10; var->red.length = 5;
+ var->green.offset = 5; var->green.length = 5;
+ var->blue.offset = 0; var->blue.length = 5;
+ var->transp.offset = 15; var->transp.length = 1;
+ break;
+ case PIX_FMT_BGR1555:
+ var->bits_per_pixel = 16;
+ var->red.offset = 0; var->red.length = 5;
+ var->green.offset = 5; var->green.length = 5;
+ var->blue.offset = 10; var->blue.length = 5;
+ var->transp.offset = 15; var->transp.length = 1;
+ break;
+ case PIX_FMT_RGB888PACK:
+ var->bits_per_pixel = 24;
+ var->red.offset = 16; var->red.length = 8;
+ var->green.offset = 8; var->green.length = 8;
+ var->blue.offset = 0; var->blue.length = 8;
+ var->transp.offset = 0; var->transp.length = 0;
+ break;
+ case PIX_FMT_BGR888PACK:
+ var->bits_per_pixel = 24;
+ var->red.offset = 0; var->red.length = 8;
+ var->green.offset = 8; var->green.length = 8;
+ var->blue.offset = 16; var->blue.length = 8;
+ var->transp.offset = 0; var->transp.length = 0;
+ break;
+ case PIX_FMT_RGBA888:
+ var->bits_per_pixel = 32;
+ var->red.offset = 16; var->red.length = 8;
+ var->green.offset = 8; var->green.length = 8;
+ var->blue.offset = 0; var->blue.length = 8;
+ var->transp.offset = 24; var->transp.length = 8;
+ break;
+ case PIX_FMT_BGRA888:
+ var->bits_per_pixel = 32;
+ var->red.offset = 0; var->red.length = 8;
+ var->green.offset = 8; var->green.length = 8;
+ var->blue.offset = 16; var->blue.length = 8;
+ var->transp.offset = 24; var->transp.length = 8;
+ break;
+ case PIX_FMT_PSEUDOCOLOR:
+ var->bits_per_pixel = 8;
+ var->red.offset = 0; var->red.length = 8;
+ var->green.offset = 0; var->green.length = 8;
+ var->blue.offset = 0; var->blue.length = 8;
+ var->transp.offset = 0; var->transp.length = 0;
+ break;
+ }
+}
+
+static void set_mode(struct pxa168fb_info *fbi, struct fb_var_screeninfo *var,
+ struct fb_videomode *mode, int pix_fmt, int ystretch)
+{
+ set_pix_fmt(var, pix_fmt);
+
+ var->xres = mode->xres;
+ var->yres = mode->yres;
+ var->xres_virtual = max(var->xres, var->xres_virtual);
+ if (ystretch)
+ var->yres_virtual = fbi->fb_size /
+ (var->xres_virtual * (var->bits_per_pixel >> 3));
+ else
+ var->yres_virtual = max(var->yres, var->yres_virtual);
+ var->grayscale = 0;
+ var->accel_flags = FB_ACCEL_NONE;
+ var->pixclock = mode->pixclock;
+ var->left_margin = mode->left_margin;
+ var->right_margin = mode->right_margin;
+ var->upper_margin = mode->upper_margin;
+ var->lower_margin = mode->lower_margin;
+ var->hsync_len = mode->hsync_len;
+ var->vsync_len = mode->vsync_len;
+ var->sync = mode->sync;
+ var->vmode = FB_VMODE_NONINTERLACED;
+ var->rotate = FB_ROTATE_UR;
+}
+
+static int pxa168fb_check_var(struct fb_var_screeninfo *var,
+ struct fb_info *info)
+{
+ struct pxa168fb_info *fbi = info->par;
+
+ if (var->bits_per_pixel == 8)
+ return -EINVAL;
+ /*
+ * Basic geometry sanity checks.
+ */
+ if (var->xoffset + var->xres > var->xres_virtual)
+ return -EINVAL;
+ if (var->yoffset + var->yres > var->yres_virtual)
+ return -EINVAL;
+ if (var->xres + var->right_margin +
+ var->hsync_len + var->left_margin > 2048)
+ return -EINVAL;
+ if (var->yres + var->lower_margin +
+ var->vsync_len + var->upper_margin > 2048)
+ return -EINVAL;
+
+ /*
+ * Check size of framebuffer.
+ */
+ if (var->xres_virtual * var->yres_virtual *
+ (var->bits_per_pixel >> 3) > fbi->fb_size)
+ return -EINVAL;
+
+ return 0;
+}
+
+/*
+ * The hardware clock divider has an integer and a fractional
+ * stage:
+ *
+ * clk2 = clk_in / integer_divider
+ * clk_out = clk2 * (1 - (fractional_divider >> 12))
+ *
+ * Calculate integer and fractional divider for given clk_in
+ * and clk_out.
+ */
+static void set_clock_divider(struct pxa168fb_info *fbi,
+ const struct fb_videomode *m)
+{
+ int divider_int;
+ int needed_pixclk;
+ u64 div_result;
+ u32 x = 0;
+
+ /*
+ * Notice: The field pixclock is used by linux fb
+ * is in pixel second. E.g. struct fb_videomode &
+ * struct fb_var_screeninfo
+ */
+
+ /*
+ * Check input values.
+ */
+ if (!m || !m->pixclock || !m->refresh) {
+ dev_err(fbi->dev, "Input refresh or pixclock is wrong.\n");
+ return;
+ }
+
+ /*
+ * Using PLL/AXI clock.
+ */
+ x = 0x80000000;
+
+ /*
+ * Calc divider according to refresh rate.
+ */
+ div_result = 1000000000000ll;
+ do_div(div_result, m->pixclock);
+ needed_pixclk = (u32)div_result;
+
+ divider_int = clk_get_rate(fbi->clk) / needed_pixclk;
+
+ /* check whether divisor is too small. */
+ if (divider_int < 2) {
+ dev_warn(fbi->dev, "Warning: clock source is too slow."
+ "Try smaller resolution\n");
+ divider_int = 2;
+ }
+
+ /*
+ * Set setting to reg.
+ */
+ x |= divider_int;
+ writel(x, fbi->reg_base + LCD_CFG_SCLK_DIV);
+}
+
+static void set_dma_control0(struct pxa168fb_info *fbi)
+{
+ u32 x;
+
+ /*
+ * Set bit to enable graphics DMA.
+ */
+ x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
+ x |= fbi->active ? 0x00000100 : 0;
+ fbi->active = 0;
+
+ /*
+ * If we are in a pseudo-color mode, we need to enable
+ * palette lookup.
+ */
+ if (fbi->pix_fmt == PIX_FMT_PSEUDOCOLOR)
+ x |= 0x10000000;
+
+ /*
+ * Configure hardware pixel format.
+ */
+ x &= ~(0xF << 16);
+ x |= (fbi->pix_fmt >> 1) << 16;
+
+ /*
+ * Check red and blue pixel swap.
+ * 1. source data swap
+ * 2. panel output data swap
+ */
+ x &= ~(1 << 12);
+ x |= ((fbi->pix_fmt & 1) ^ (fbi->panel_rbswap)) << 12;
+
+ writel(x, fbi->reg_base + LCD_SPU_DMA_CTRL0);
+}
+
+static void set_dma_control1(struct pxa168fb_info *fbi, int sync)
+{
+ u32 x;
+
+ /*
+ * Configure default bits: vsync triggers DMA, gated clock
+ * enable, power save enable, configure alpha registers to
+ * display 100% graphics, and set pixel command.
+ */
+ x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL1);
+ x |= 0x2032ff81;
+
+ /*
+ * We trigger DMA on the falling edge of vsync if vsync is
+ * active low, or on the rising edge if vsync is active high.
+ */
+ if (!(sync & FB_SYNC_VERT_HIGH_ACT))
+ x |= 0x08000000;
+
+ writel(x, fbi->reg_base + LCD_SPU_DMA_CTRL1);
+}
+
+static void set_graphics_start(struct fb_info *info, int xoffset, int yoffset)
+{
+ struct pxa168fb_info *fbi = info->par;
+ struct fb_var_screeninfo *var = &info->var;
+ int pixel_offset;
+ unsigned long addr;
+
+ pixel_offset = (yoffset * var->xres_virtual) + xoffset;
+
+ addr = fbi->fb_start_dma + (pixel_offset * (var->bits_per_pixel >> 3));
+ writel(addr, fbi->reg_base + LCD_CFG_GRA_START_ADDR0);
+}
+
+static void set_dumb_panel_control(struct fb_info *info)
+{
+ struct pxa168fb_info *fbi = info->par;
+ struct pxa168fb_mach_info *mi = fbi->dev->platform_data;
+ u32 x;
+
+ /*
+ * Preserve enable flag.
+ */
+ x = readl(fbi->reg_base + LCD_SPU_DUMB_CTRL) & 0x00000001;
+
+ x |= (fbi->is_blanked ? 0x7 : mi->dumb_mode) << 28;
+ x |= mi->gpio_output_data << 20;
+ x |= mi->gpio_output_mask << 12;
+ x |= mi->panel_rgb_reverse_lanes ? 0x00000080 : 0;
+ x |= mi->invert_composite_blank ? 0x00000040 : 0;
+ x |= (info->var.sync & FB_SYNC_COMP_HIGH_ACT) ? 0x00000020 : 0;
+ x |= mi->invert_pix_val_ena ? 0x00000010 : 0;
+ x |= (info->var.sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 0x00000008;
+ x |= (info->var.sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 0x00000004;
+ x |= mi->invert_pixclock ? 0x00000002 : 0;
+
+ writel(x, fbi->reg_base + LCD_SPU_DUMB_CTRL);
+}
+
+static void set_dumb_screen_dimensions(struct fb_info *info)
+{
+ struct pxa168fb_info *fbi = info->par;
+ struct fb_var_screeninfo *v = &info->var;
+ int x;
+ int y;
+
+ x = v->xres + v->right_margin + v->hsync_len + v->left_margin;
+ y = v->yres + v->lower_margin + v->vsync_len + v->upper_margin;
+
+ writel((y << 16) | x, fbi->reg_base + LCD_SPUT_V_H_TOTAL);
+}
+
+static int pxa168fb_set_par(struct fb_info *info)
+{
+ struct pxa168fb_info *fbi = info->par;
+ struct fb_var_screeninfo *var = &info->var;
+ struct fb_videomode mode;
+ int pix_fmt;
+ u32 x;
+ struct pxa168fb_mach_info *mi;
+
+ mi = fbi->dev->platform_data;
+ /*
+ * Determine which pixel format we're going to use.
+ */
+ pix_fmt = determine_best_pix_fmt(&info->var);
+ if (pix_fmt < 0)
+ return pix_fmt;
+ fbi->pix_fmt = pix_fmt;
+
+ /*
+ * Set additional mode info.
+ */
+ if (pix_fmt == PIX_FMT_PSEUDOCOLOR)
+ info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ else
+ info->fix.visual = FB_VISUAL_TRUECOLOR;
+ info->fix.line_length = var->xres_virtual * var->bits_per_pixel / 8;
+ info->fix.ypanstep = var->yres;
+
+ /*
+ * Disable panel output while we setup the display.
+ */
+ x = readl(fbi->reg_base + LCD_SPU_DUMB_CTRL);
+ writel(x & ~1, fbi->reg_base + LCD_SPU_DUMB_CTRL);
+
+ /*
+ * Configure global panel parameters.
+ */
+ writel((var->yres << 16) | var->xres,
+ fbi->reg_base + LCD_SPU_V_H_ACTIVE);
+
+ /*
+ * convet var to video mode
+ */
+ fb_var_to_videomode(&mode, &info->var);
+
+ /* Calculate clock divisor. */
+ set_clock_divider(fbi, &mode);
+
+ /* Configure dma ctrl regs. */
+ set_dma_control0(fbi);
+ set_dma_control1(fbi, info->var.sync);
+
+ /*
+ * Configure graphics DMA parameters.
+ */
+ set_graphics_start(info, info->var.xoffset, info->var.yoffset);
+ x = readl(fbi->reg_base + LCD_CFG_GRA_PITCH);
+ x = (x & ~0xFFFF) | ((var->xres_virtual * var->bits_per_pixel) >> 3);
+ writel(x, fbi->reg_base + LCD_CFG_GRA_PITCH);
+ writel((var->yres << 16) | var->xres,
+ fbi->reg_base + LCD_SPU_GRA_HPXL_VLN);
+ writel((var->yres << 16) | var->xres,
+ fbi->reg_base + LCD_SPU_GZM_HPXL_VLN);
+
+ /*
+ * Configure dumb panel ctrl regs & timings.
+ */
+ set_dumb_panel_control(info);
+ set_dumb_screen_dimensions(info);
+
+ writel((var->left_margin << 16) | var->right_margin,
+ fbi->reg_base + LCD_SPU_H_PORCH);
+ writel((var->upper_margin << 16) | var->lower_margin,
+ fbi->reg_base + LCD_SPU_V_PORCH);
+
+ /*
+ * Re-enable panel output.
+ */
+ x = readl(fbi->reg_base + LCD_SPU_DUMB_CTRL);
+ writel(x | 1, fbi->reg_base + LCD_SPU_DUMB_CTRL);
+
+ return 0;
+}
+
+static unsigned int chan_to_field(unsigned int chan, struct fb_bitfield *bf)
+{
+ return ((chan & 0xffff) >> (16 - bf->length)) << bf->offset;
+}
+
+static u32 to_rgb(u16 red, u16 green, u16 blue)
+{
+ red >>= 8;
+ green >>= 8;
+ blue >>= 8;
+
+ return (red << 16) | (green << 8) | blue;
+}
+
+static int
+pxa168fb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,
+ unsigned int blue, unsigned int trans, struct fb_info *info)
+{
+ struct pxa168fb_info *fbi = info->par;
+ u32 val;
+
+ if (info->var.grayscale)
+ red = green = blue = (19595 * red + 38470 * green +
+ 7471 * blue) >> 16;
+
+ if (info->fix.visual == FB_VISUAL_TRUECOLOR && regno < 16) {
+ val = chan_to_field(red, &info->var.red);
+ val |= chan_to_field(green, &info->var.green);
+ val |= chan_to_field(blue , &info->var.blue);
+ fbi->pseudo_palette[regno] = val;
+ }
+
+ if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) {
+ val = to_rgb(red, green, blue);
+ writel(val, fbi->reg_base + LCD_SPU_SRAM_WRDAT);
+ writel(0x8300 | regno, fbi->reg_base + LCD_SPU_SRAM_CTRL);
+ }
+
+ return 0;
+}
+
+static int pxa168fb_blank(int blank, struct fb_info *info)
+{
+ struct pxa168fb_info *fbi = info->par;
+
+ fbi->is_blanked = (blank == FB_BLANK_UNBLANK) ? 0 : 1;
+ set_dumb_panel_control(info);
+
+ return 0;
+}
+
+static int pxa168fb_pan_display(struct fb_var_screeninfo *var,
+ struct fb_info *info)
+{
+ set_graphics_start(info, var->xoffset, var->yoffset);
+
+ return 0;
+}
+
+static irqreturn_t pxa168fb_handle_irq(int irq, void *dev_id)
+{
+ struct pxa168fb_info *fbi = dev_id;
+ u32 isr = readl(fbi->reg_base + SPU_IRQ_ISR);
+
+ if ((isr & GRA_FRAME_IRQ0_ENA_MASK)) {
+
+ writel(isr & (~GRA_FRAME_IRQ0_ENA_MASK),
+ fbi->reg_base + SPU_IRQ_ISR);
+
+ return IRQ_HANDLED;
+ }
+ return IRQ_NONE;
+}
+
+static struct fb_ops pxa168fb_ops = {
+ .owner = THIS_MODULE,
+ .fb_check_var = pxa168fb_check_var,
+ .fb_set_par = pxa168fb_set_par,
+ .fb_setcolreg = pxa168fb_setcolreg,
+ .fb_blank = pxa168fb_blank,
+ .fb_pan_display = pxa168fb_pan_display,
+ .fb_fillrect = cfb_fillrect,
+ .fb_copyarea = cfb_copyarea,
+ .fb_imageblit = cfb_imageblit,
+};
+
+static int pxa168fb_init_mode(struct fb_info *info,
+ struct pxa168fb_mach_info *mi)
+{
+ struct pxa168fb_info *fbi = info->par;
+ struct fb_var_screeninfo *var = &info->var;
+ int ret = 0;
+ u32 total_w, total_h, refresh;
+ u64 div_result;
+ const struct fb_videomode *m;
+
+ /*
+ * Set default value
+ */
+ refresh = DEFAULT_REFRESH;
+
+ /* try to find best video mode. */
+ m = fb_find_best_mode(&info->var, &info->modelist);
+ if (m)
+ fb_videomode_to_var(&info->var, m);
+
+ /* Init settings. */
+ var->xres_virtual = var->xres;
+ var->yres_virtual = fbi->fb_size /
+ (var->xres_virtual * (var->bits_per_pixel >> 3));
+ dev_dbg(fbi->dev, "pxa168fb: find best mode: res = %dx%d\n",
+ var->xres, var->yres);
+
+ /* correct pixclock. */
+ total_w = var->xres + var->left_margin + var->right_margin +
+ var->hsync_len;
+ total_h = var->yres + var->upper_margin + var->lower_margin +
+ var->vsync_len;
+
+ div_result = 1000000000000ll;
+ do_div(div_result, total_w * total_h * refresh);
+ var->pixclock = (u32)div_result;
+
+ return ret;
+}
+
+static int __init pxa168fb_probe(struct platform_device *pdev)
+{
+ struct pxa168fb_mach_info *mi;
+ struct fb_info *info = 0;
+ struct pxa168fb_info *fbi = 0;
+ struct resource *res;
+ struct clk *clk;
+ int irq, ret;
+
+ mi = pdev->dev.platform_data;
+ if (mi == NULL) {
+ dev_err(&pdev->dev, "no platform data defined\n");
+ return -EINVAL;
+ }
+
+ clk = clk_get(&pdev->dev, "LCDCLK");
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "unable to get LCDCLK");
+ return PTR_ERR(clk);
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res == NULL) {
+ dev_err(&pdev->dev, "no IO memory defined\n");
+ return -ENOENT;
+ }
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ dev_err(&pdev->dev, "no IRQ defined\n");
+ return -ENOENT;
+ }
+
+ info = framebuffer_alloc(sizeof(struct pxa168fb_info), &pdev->dev);
+ if (info == NULL)
+ return -ENOMEM;
+
+ /* Initialize private data */
+ fbi = info->par;
+ platform_set_drvdata(pdev, fbi);
+ fbi->clk = clk;
+ fbi->dev = info->dev = &pdev->dev;
+ fbi->panel_rbswap = mi->panel_rbswap;
+ fbi->is_blanked = 0;
+ fbi->active = mi->active;
+
+ /*
+ * Initialise static fb parameters.
+ */
+ info->flags = FBINFO_DEFAULT | FBINFO_PARTIAL_PAN_OK |
+ FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN;
+ info->node = -1;
+ strlcpy(info->fix.id, mi->id, 16);
+ info->fix.type = FB_TYPE_PACKED_PIXELS;
+ info->fix.type_aux = 0;
+ info->fix.xpanstep = 0;
+ info->fix.ypanstep = 0;
+ info->fix.ywrapstep = 0;
+ info->fix.mmio_start = res->start;
+ info->fix.mmio_len = res->end - res->start + 1;
+ info->fix.accel = FB_ACCEL_NONE;
+ info->fbops = &pxa168fb_ops;
+ info->pseudo_palette = fbi->pseudo_palette;
+
+ /*
+ * Map LCD controller registers.
+ */
+ fbi->reg_base = ioremap_nocache(res->start, res->end - res->start);
+ if (fbi->reg_base == NULL) {
+ ret = -ENOMEM;
+ goto failed;
+ }
+
+ /*
+ * Allocate framebuffer memory.
+ */
+ fbi->fb_size = PAGE_ALIGN(DEFAULT_FB_SIZE);
+
+ fbi->fb_start = dma_alloc_writecombine(fbi->dev, fbi->fb_size,
+ &fbi->fb_start_dma,
+ GFP_KERNEL);
+ if (fbi->fb_start == NULL) {
+ ret = -ENOMEM;
+ goto failed;
+ }
+
+ info->fix.smem_start = fbi->fb_start_dma;
+ info->fix.smem_len = fbi->fb_size;
+ info->screen_base = fbi->fb_start;
+ info->screen_size = fbi->fb_size;
+
+ /*
+ * Set video mode according to platform data.
+ */
+ set_mode(fbi, &info->var, mi->modes, mi->pix_fmt, 1);
+
+ fb_videomode_to_modelist(mi->modes, mi->num_modes, &info->modelist);
+
+ /*
+ * init video mode data.
+ */
+ pxa168fb_init_mode(info, mi);
+
+ /*
+ * enable controller clock
+ */
+ clk_enable(fbi->clk);
+
+ /*
+ * Fill in sane defaults.
+ */
+ pxa168fb_set_par(info);
+
+ /*
+ * Configure default register values.
+ */
+ writel(0, fbi->reg_base + LCD_SPU_BLANKCOLOR);
+ writel(mi->io_pin_allocation_mode, fbi->reg_base + SPU_IOPAD_CONTROL);
+ writel(0, fbi->reg_base + LCD_CFG_GRA_START_ADDR1);
+ writel(0, fbi->reg_base + LCD_SPU_GRA_OVSA_HPXL_VLN);
+ writel(0, fbi->reg_base + LCD_SPU_SRAM_PARA0);
+ writel(CFG_CSB_256x32(0x1)|CFG_CSB_256x24(0x1)|CFG_CSB_256x8(0x1),
+ fbi->reg_base + LCD_SPU_SRAM_PARA1);
+
+ /*
+ * Allocate color map.
+ */
+ if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
+ ret = -ENOMEM;
+ goto failed_free_clk;
+ }
+
+ /*
+ * Register irq handler.
+ */
+ ret = request_irq(irq, pxa168fb_handle_irq, IRQF_SHARED,
+ info->fix.id, fbi);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "unable to request IRQ\n");
+ ret = -ENXIO;
+ goto failed_free_cmap;
+ }
+
+ /*
+ * Enable GFX interrupt
+ */
+ writel(GRA_FRAME_IRQ0_ENA(0x1), fbi->reg_base + SPU_IRQ_ENA);
+
+ /*
+ * Register framebuffer.
+ */
+ ret = register_framebuffer(info);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "Failed to register pxa168-fb: %d\n", ret);
+ ret = -ENXIO;
+ goto failed_free_irq;
+ }
+
+ return 0;
+
+failed_free_irq:
+ free_irq(irq, fbi);
+failed_free_cmap:
+ fb_dealloc_cmap(&info->cmap);
+failed_free_clk:
+ clk_disable(fbi->clk);
+ clk_put(fbi->clk);
+failed:
+ pr_err("pxa168-fb: frame buffer device init failed\n");
+ platform_set_drvdata(pdev, NULL);
+ fb_dealloc_cmap(&info->cmap);
+
+ if (fbi && fbi->reg_base) {
+ iounmap(fbi->reg_base);
+ kfree(fbi);
+ }
+
+ return ret;
+}
+
+static struct platform_driver pxa168fb_driver = {
+ .driver = {
+ .name = "pxa168-fb",
+ .owner = THIS_MODULE,
+ },
+ .probe = pxa168fb_probe,
+};
+
+static int __devinit pxa168fb_init(void)
+{
+ return platform_driver_register(&pxa168fb_driver);
+}
+module_init(pxa168fb_init);
+
+MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com> "
+ "Green Wan <gwan@marvell.com>");
+MODULE_DESCRIPTION("Framebuffer driver for PXA168/910");
+MODULE_LICENSE("GPL");
diff --git a/drivers/video/pxa168fb.h b/drivers/video/pxa168fb.h
new file mode 100644
index 000000000000..eee09279c524
--- /dev/null
+++ b/drivers/video/pxa168fb.h
@@ -0,0 +1,558 @@
+#ifndef __PXA168FB_H__
+#define __PXA168FB_H__
+
+/* ------------< LCD register >------------ */
+/* Video Frame 0&1 start address registers */
+#define LCD_SPU_DMA_START_ADDR_Y0 0x00C0
+#define LCD_SPU_DMA_START_ADDR_U0 0x00C4
+#define LCD_SPU_DMA_START_ADDR_V0 0x00C8
+#define LCD_CFG_DMA_START_ADDR_0 0x00CC /* Cmd address */
+#define LCD_SPU_DMA_START_ADDR_Y1 0x00D0
+#define LCD_SPU_DMA_START_ADDR_U1 0x00D4
+#define LCD_SPU_DMA_START_ADDR_V1 0x00D8
+#define LCD_CFG_DMA_START_ADDR_1 0x00DC /* Cmd address */
+
+/* YC & UV Pitch */
+#define LCD_SPU_DMA_PITCH_YC 0x00E0
+#define SPU_DMA_PITCH_C(c) ((c) << 16)
+#define SPU_DMA_PITCH_Y(y) (y)
+#define LCD_SPU_DMA_PITCH_UV 0x00E4
+#define SPU_DMA_PITCH_V(v) ((v) << 16)
+#define SPU_DMA_PITCH_U(u) (u)
+
+/* Video Starting Point on Screen Register */
+#define LCD_SPUT_DMA_OVSA_HPXL_VLN 0x00E8
+#define CFG_DMA_OVSA_VLN(y) ((y) << 16) /* 0~0xfff */
+#define CFG_DMA_OVSA_HPXL(x) (x) /* 0~0xfff */
+
+/* Video Size Register */
+#define LCD_SPU_DMA_HPXL_VLN 0x00EC
+#define CFG_DMA_VLN(y) ((y) << 16)
+#define CFG_DMA_HPXL(x) (x)
+
+/* Video Size After zooming Register */
+#define LCD_SPU_DZM_HPXL_VLN 0x00F0
+#define CFG_DZM_VLN(y) ((y) << 16)
+#define CFG_DZM_HPXL(x) (x)
+
+/* Graphic Frame 0&1 Starting Address Register */
+#define LCD_CFG_GRA_START_ADDR0 0x00F4
+#define LCD_CFG_GRA_START_ADDR1 0x00F8
+
+/* Graphic Frame Pitch */
+#define LCD_CFG_GRA_PITCH 0x00FC
+
+/* Graphic Starting Point on Screen Register */
+#define LCD_SPU_GRA_OVSA_HPXL_VLN 0x0100
+#define CFG_GRA_OVSA_VLN(y) ((y) << 16)
+#define CFG_GRA_OVSA_HPXL(x) (x)
+
+/* Graphic Size Register */
+#define LCD_SPU_GRA_HPXL_VLN 0x0104
+#define CFG_GRA_VLN(y) ((y) << 16)
+#define CFG_GRA_HPXL(x) (x)
+
+/* Graphic Size after Zooming Register */
+#define LCD_SPU_GZM_HPXL_VLN 0x0108
+#define CFG_GZM_VLN(y) ((y) << 16)
+#define CFG_GZM_HPXL(x) (x)
+
+/* HW Cursor Starting Point on Screen Register */
+#define LCD_SPU_HWC_OVSA_HPXL_VLN 0x010C
+#define CFG_HWC_OVSA_VLN(y) ((y) << 16)
+#define CFG_HWC_OVSA_HPXL(x) (x)
+
+/* HW Cursor Size */
+#define LCD_SPU_HWC_HPXL_VLN 0x0110
+#define CFG_HWC_VLN(y) ((y) << 16)
+#define CFG_HWC_HPXL(x) (x)
+
+/* Total Screen Size Register */
+#define LCD_SPUT_V_H_TOTAL 0x0114
+#define CFG_V_TOTAL(y) ((y) << 16)
+#define CFG_H_TOTAL(x) (x)
+
+/* Total Screen Active Size Register */
+#define LCD_SPU_V_H_ACTIVE 0x0118
+#define CFG_V_ACTIVE(y) ((y) << 16)
+#define CFG_H_ACTIVE(x) (x)
+
+/* Screen H&V Porch Register */
+#define LCD_SPU_H_PORCH 0x011C
+#define CFG_H_BACK_PORCH(b) ((b) << 16)
+#define CFG_H_FRONT_PORCH(f) (f)
+#define LCD_SPU_V_PORCH 0x0120
+#define CFG_V_BACK_PORCH(b) ((b) << 16)
+#define CFG_V_FRONT_PORCH(f) (f)
+
+/* Screen Blank Color Register */
+#define LCD_SPU_BLANKCOLOR 0x0124
+#define CFG_BLANKCOLOR_MASK 0x00FFFFFF
+#define CFG_BLANKCOLOR_R_MASK 0x000000FF
+#define CFG_BLANKCOLOR_G_MASK 0x0000FF00
+#define CFG_BLANKCOLOR_B_MASK 0x00FF0000
+
+/* HW Cursor Color 1&2 Register */
+#define LCD_SPU_ALPHA_COLOR1 0x0128
+#define CFG_HWC_COLOR1 0x00FFFFFF
+#define CFG_HWC_COLOR1_R(red) ((red) << 16)
+#define CFG_HWC_COLOR1_G(green) ((green) << 8)
+#define CFG_HWC_COLOR1_B(blue) (blue)
+#define CFG_HWC_COLOR1_R_MASK 0x000000FF
+#define CFG_HWC_COLOR1_G_MASK 0x0000FF00
+#define CFG_HWC_COLOR1_B_MASK 0x00FF0000
+#define LCD_SPU_ALPHA_COLOR2 0x012C
+#define CFG_HWC_COLOR2 0x00FFFFFF
+#define CFG_HWC_COLOR2_R_MASK 0x000000FF
+#define CFG_HWC_COLOR2_G_MASK 0x0000FF00
+#define CFG_HWC_COLOR2_B_MASK 0x00FF0000
+
+/* Video YUV Color Key Control */
+#define LCD_SPU_COLORKEY_Y 0x0130
+#define CFG_CKEY_Y2(y2) ((y2) << 24)
+#define CFG_CKEY_Y2_MASK 0xFF000000
+#define CFG_CKEY_Y1(y1) ((y1) << 16)
+#define CFG_CKEY_Y1_MASK 0x00FF0000
+#define CFG_CKEY_Y(y) ((y) << 8)
+#define CFG_CKEY_Y_MASK 0x0000FF00
+#define CFG_ALPHA_Y(y) (y)
+#define CFG_ALPHA_Y_MASK 0x000000FF
+#define LCD_SPU_COLORKEY_U 0x0134
+#define CFG_CKEY_U2(u2) ((u2) << 24)
+#define CFG_CKEY_U2_MASK 0xFF000000
+#define CFG_CKEY_U1(u1) ((u1) << 16)
+#define CFG_CKEY_U1_MASK 0x00FF0000
+#define CFG_CKEY_U(u) ((u) << 8)
+#define CFG_CKEY_U_MASK 0x0000FF00
+#define CFG_ALPHA_U(u) (u)
+#define CFG_ALPHA_U_MASK 0x000000FF
+#define LCD_SPU_COLORKEY_V 0x0138
+#define CFG_CKEY_V2(v2) ((v2) << 24)
+#define CFG_CKEY_V2_MASK 0xFF000000
+#define CFG_CKEY_V1(v1) ((v1) << 16)
+#define CFG_CKEY_V1_MASK 0x00FF0000
+#define CFG_CKEY_V(v) ((v) << 8)
+#define CFG_CKEY_V_MASK 0x0000FF00
+#define CFG_ALPHA_V(v) (v)
+#define CFG_ALPHA_V_MASK 0x000000FF
+
+/* SPI Read Data Register */
+#define LCD_SPU_SPI_RXDATA 0x0140
+
+/* Smart Panel Read Data Register */
+#define LCD_SPU_ISA_RSDATA 0x0144
+#define ISA_RXDATA_16BIT_1_DATA_MASK 0x000000FF
+#define ISA_RXDATA_16BIT_2_DATA_MASK 0x0000FF00
+#define ISA_RXDATA_16BIT_3_DATA_MASK 0x00FF0000
+#define ISA_RXDATA_16BIT_4_DATA_MASK 0xFF000000
+#define ISA_RXDATA_32BIT_1_DATA_MASK 0x00FFFFFF
+
+/* HWC SRAM Read Data Register */
+#define LCD_SPU_HWC_RDDAT 0x0158
+
+/* Gamma Table SRAM Read Data Register */
+#define LCD_SPU_GAMMA_RDDAT 0x015c
+#define CFG_GAMMA_RDDAT_MASK 0x000000FF
+
+/* Palette Table SRAM Read Data Register */
+#define LCD_SPU_PALETTE_RDDAT 0x0160
+#define CFG_PALETTE_RDDAT_MASK 0x00FFFFFF
+
+/* I/O Pads Input Read Only Register */
+#define LCD_SPU_IOPAD_IN 0x0178
+#define CFG_IOPAD_IN_MASK 0x0FFFFFFF
+
+/* Reserved Read Only Registers */
+#define LCD_CFG_RDREG5F 0x017C
+#define IRE_FRAME_CNT_MASK 0x000000C0
+#define IPE_FRAME_CNT_MASK 0x00000030
+#define GRA_FRAME_CNT_MASK 0x0000000C /* Graphic */
+#define DMA_FRAME_CNT_MASK 0x00000003 /* Video */
+
+/* SPI Control Register. */
+#define LCD_SPU_SPI_CTRL 0x0180
+#define CFG_SCLKCNT(div) ((div) << 24) /* 0xFF~0x2 */
+#define CFG_SCLKCNT_MASK 0xFF000000
+#define CFG_RXBITS(rx) ((rx) << 16) /* 0x1F~0x1 */
+#define CFG_RXBITS_MASK 0x00FF0000
+#define CFG_TXBITS(tx) ((tx) << 8) /* 0x1F~0x1 */
+#define CFG_TXBITS_MASK 0x0000FF00
+#define CFG_CLKINV(clk) ((clk) << 7)
+#define CFG_CLKINV_MASK 0x00000080
+#define CFG_KEEPXFER(transfer) ((transfer) << 6)
+#define CFG_KEEPXFER_MASK 0x00000040
+#define CFG_RXBITSTO0(rx) ((rx) << 5)
+#define CFG_RXBITSTO0_MASK 0x00000020
+#define CFG_TXBITSTO0(tx) ((tx) << 4)
+#define CFG_TXBITSTO0_MASK 0x00000010
+#define CFG_SPI_ENA(spi) ((spi) << 3)
+#define CFG_SPI_ENA_MASK 0x00000008
+#define CFG_SPI_SEL(spi) ((spi) << 2)
+#define CFG_SPI_SEL_MASK 0x00000004
+#define CFG_SPI_3W4WB(wire) ((wire) << 1)
+#define CFG_SPI_3W4WB_MASK 0x00000002
+#define CFG_SPI_START(start) (start)
+#define CFG_SPI_START_MASK 0x00000001
+
+/* SPI Tx Data Register */
+#define LCD_SPU_SPI_TXDATA 0x0184
+
+/*
+ 1. Smart Pannel 8-bit Bus Control Register.
+ 2. AHB Slave Path Data Port Register
+*/
+#define LCD_SPU_SMPN_CTRL 0x0188
+
+/* DMA Control 0 Register */
+#define LCD_SPU_DMA_CTRL0 0x0190
+#define CFG_NOBLENDING(nb) ((nb) << 31)
+#define CFG_NOBLENDING_MASK 0x80000000
+#define CFG_GAMMA_ENA(gn) ((gn) << 30)
+#define CFG_GAMMA_ENA_MASK 0x40000000
+#define CFG_CBSH_ENA(cn) ((cn) << 29)
+#define CFG_CBSH_ENA_MASK 0x20000000
+#define CFG_PALETTE_ENA(pn) ((pn) << 28)
+#define CFG_PALETTE_ENA_MASK 0x10000000
+#define CFG_ARBFAST_ENA(an) ((an) << 27)
+#define CFG_ARBFAST_ENA_MASK 0x08000000
+#define CFG_HWC_1BITMOD(mode) ((mode) << 26)
+#define CFG_HWC_1BITMOD_MASK 0x04000000
+#define CFG_HWC_1BITENA(mn) ((mn) << 25)
+#define CFG_HWC_1BITENA_MASK 0x02000000
+#define CFG_HWC_ENA(cn) ((cn) << 24)
+#define CFG_HWC_ENA_MASK 0x01000000
+#define CFG_DMAFORMAT(dmaformat) ((dmaformat) << 20)
+#define CFG_DMAFORMAT_MASK 0x00F00000
+#define CFG_GRAFORMAT(graformat) ((graformat) << 16)
+#define CFG_GRAFORMAT_MASK 0x000F0000
+/* for graphic part */
+#define CFG_GRA_FTOGGLE(toggle) ((toggle) << 15)
+#define CFG_GRA_FTOGGLE_MASK 0x00008000
+#define CFG_GRA_HSMOOTH(smooth) ((smooth) << 14)
+#define CFG_GRA_HSMOOTH_MASK 0x00004000
+#define CFG_GRA_TSTMODE(test) ((test) << 13)
+#define CFG_GRA_TSTMODE_MASK 0x00002000
+#define CFG_GRA_SWAPRB(swap) ((swap) << 12)
+#define CFG_GRA_SWAPRB_MASK 0x00001000
+#define CFG_GRA_SWAPUV(swap) ((swap) << 11)
+#define CFG_GRA_SWAPUV_MASK 0x00000800
+#define CFG_GRA_SWAPYU(swap) ((swap) << 10)
+#define CFG_GRA_SWAPYU_MASK 0x00000400
+#define CFG_YUV2RGB_GRA(cvrt) ((cvrt) << 9)
+#define CFG_YUV2RGB_GRA_MASK 0x00000200
+#define CFG_GRA_ENA(gra) ((gra) << 8)
+#define CFG_GRA_ENA_MASK 0x00000100
+/* for video part */
+#define CFG_DMA_FTOGGLE(toggle) ((toggle) << 7)
+#define CFG_DMA_FTOGGLE_MASK 0x00000080
+#define CFG_DMA_HSMOOTH(smooth) ((smooth) << 6)
+#define CFG_DMA_HSMOOTH_MASK 0x00000040
+#define CFG_DMA_TSTMODE(test) ((test) << 5)
+#define CFG_DMA_TSTMODE_MASK 0x00000020
+#define CFG_DMA_SWAPRB(swap) ((swap) << 4)
+#define CFG_DMA_SWAPRB_MASK 0x00000010
+#define CFG_DMA_SWAPUV(swap) ((swap) << 3)
+#define CFG_DMA_SWAPUV_MASK 0x00000008
+#define CFG_DMA_SWAPYU(swap) ((swap) << 2)
+#define CFG_DMA_SWAPYU_MASK 0x00000004
+#define CFG_DMA_SWAP_MASK 0x0000001C
+#define CFG_YUV2RGB_DMA(cvrt) ((cvrt) << 1)
+#define CFG_YUV2RGB_DMA_MASK 0x00000002
+#define CFG_DMA_ENA(video) (video)
+#define CFG_DMA_ENA_MASK 0x00000001
+
+/* DMA Control 1 Register */
+#define LCD_SPU_DMA_CTRL1 0x0194
+#define CFG_FRAME_TRIG(trig) ((trig) << 31)
+#define CFG_FRAME_TRIG_MASK 0x80000000
+#define CFG_VSYNC_TRIG(trig) ((trig) << 28)
+#define CFG_VSYNC_TRIG_MASK 0x70000000
+#define CFG_VSYNC_INV(inv) ((inv) << 27)
+#define CFG_VSYNC_INV_MASK 0x08000000
+#define CFG_COLOR_KEY_MODE(cmode) ((cmode) << 24)
+#define CFG_COLOR_KEY_MASK 0x07000000
+#define CFG_CARRY(carry) ((carry) << 23)
+#define CFG_CARRY_MASK 0x00800000
+#define CFG_LNBUF_ENA(lnbuf) ((lnbuf) << 22)
+#define CFG_LNBUF_ENA_MASK 0x00400000
+#define CFG_GATED_ENA(gated) ((gated) << 21)
+#define CFG_GATED_ENA_MASK 0x00200000
+#define CFG_PWRDN_ENA(power) ((power) << 20)
+#define CFG_PWRDN_ENA_MASK 0x00100000
+#define CFG_DSCALE(dscale) ((dscale) << 18)
+#define CFG_DSCALE_MASK 0x000C0000
+#define CFG_ALPHA_MODE(amode) ((amode) << 16)
+#define CFG_ALPHA_MODE_MASK 0x00030000
+#define CFG_ALPHA(alpha) ((alpha) << 8)
+#define CFG_ALPHA_MASK 0x0000FF00
+#define CFG_PXLCMD(pxlcmd) (pxlcmd)
+#define CFG_PXLCMD_MASK 0x000000FF
+
+/* SRAM Control Register */
+#define LCD_SPU_SRAM_CTRL 0x0198
+#define CFG_SRAM_INIT_WR_RD(mode) ((mode) << 14)
+#define CFG_SRAM_INIT_WR_RD_MASK 0x0000C000
+#define CFG_SRAM_ADDR_LCDID(id) ((id) << 8)
+#define CFG_SRAM_ADDR_LCDID_MASK 0x00000F00
+#define CFG_SRAM_ADDR(addr) (addr)
+#define CFG_SRAM_ADDR_MASK 0x000000FF
+
+/* SRAM Write Data Register */
+#define LCD_SPU_SRAM_WRDAT 0x019C
+
+/* SRAM RTC/WTC Control Register */
+#define LCD_SPU_SRAM_PARA0 0x01A0
+
+/* SRAM Power Down Control Register */
+#define LCD_SPU_SRAM_PARA1 0x01A4
+#define CFG_CSB_256x32(hwc) ((hwc) << 15) /* HWC */
+#define CFG_CSB_256x32_MASK 0x00008000
+#define CFG_CSB_256x24(palette) ((palette) << 14) /* Palette */
+#define CFG_CSB_256x24_MASK 0x00004000
+#define CFG_CSB_256x8(gamma) ((gamma) << 13) /* Gamma */
+#define CFG_CSB_256x8_MASK 0x00002000
+#define CFG_PDWN256x32(pdwn) ((pdwn) << 7) /* HWC */
+#define CFG_PDWN256x32_MASK 0x00000080
+#define CFG_PDWN256x24(pdwn) ((pdwn) << 6) /* Palette */
+#define CFG_PDWN256x24_MASK 0x00000040
+#define CFG_PDWN256x8(pdwn) ((pdwn) << 5) /* Gamma */
+#define CFG_PDWN256x8_MASK 0x00000020
+#define CFG_PDWN32x32(pdwn) ((pdwn) << 3)
+#define CFG_PDWN32x32_MASK 0x00000008
+#define CFG_PDWN16x66(pdwn) ((pdwn) << 2)
+#define CFG_PDWN16x66_MASK 0x00000004
+#define CFG_PDWN32x66(pdwn) ((pdwn) << 1)
+#define CFG_PDWN32x66_MASK 0x00000002
+#define CFG_PDWN64x66(pdwn) (pdwn)
+#define CFG_PDWN64x66_MASK 0x00000001
+
+/* Smart or Dumb Panel Clock Divider */
+#define LCD_CFG_SCLK_DIV 0x01A8
+#define SCLK_SOURCE_SELECT(src) ((src) << 31)
+#define SCLK_SOURCE_SELECT_MASK 0x80000000
+#define CLK_FRACDIV(frac) ((frac) << 16)
+#define CLK_FRACDIV_MASK 0x0FFF0000
+#define CLK_INT_DIV(div) (div)
+#define CLK_INT_DIV_MASK 0x0000FFFF
+
+/* Video Contrast Register */
+#define LCD_SPU_CONTRAST 0x01AC
+#define CFG_BRIGHTNESS(bright) ((bright) << 16)
+#define CFG_BRIGHTNESS_MASK 0xFFFF0000
+#define CFG_CONTRAST(contrast) (contrast)
+#define CFG_CONTRAST_MASK 0x0000FFFF
+
+/* Video Saturation Register */
+#define LCD_SPU_SATURATION 0x01B0
+#define CFG_C_MULTS(mult) ((mult) << 16)
+#define CFG_C_MULTS_MASK 0xFFFF0000
+#define CFG_SATURATION(sat) (sat)
+#define CFG_SATURATION_MASK 0x0000FFFF
+
+/* Video Hue Adjust Register */
+#define LCD_SPU_CBSH_HUE 0x01B4
+#define CFG_SIN0(sin0) ((sin0) << 16)
+#define CFG_SIN0_MASK 0xFFFF0000
+#define CFG_COS0(con0) (con0)
+#define CFG_COS0_MASK 0x0000FFFF
+
+/* Dump LCD Panel Control Register */
+#define LCD_SPU_DUMB_CTRL 0x01B8
+#define CFG_DUMBMODE(mode) ((mode) << 28)
+#define CFG_DUMBMODE_MASK 0xF0000000
+#define CFG_LCDGPIO_O(data) ((data) << 20)
+#define CFG_LCDGPIO_O_MASK 0x0FF00000
+#define CFG_LCDGPIO_ENA(gpio) ((gpio) << 12)
+#define CFG_LCDGPIO_ENA_MASK 0x000FF000
+#define CFG_BIAS_OUT(bias) ((bias) << 8)
+#define CFG_BIAS_OUT_MASK 0x00000100
+#define CFG_REVERSE_RGB(rRGB) ((rRGB) << 7)
+#define CFG_REVERSE_RGB_MASK 0x00000080
+#define CFG_INV_COMPBLANK(blank) ((blank) << 6)
+#define CFG_INV_COMPBLANK_MASK 0x00000040
+#define CFG_INV_COMPSYNC(sync) ((sync) << 5)
+#define CFG_INV_COMPSYNC_MASK 0x00000020
+#define CFG_INV_HENA(hena) ((hena) << 4)
+#define CFG_INV_HENA_MASK 0x00000010
+#define CFG_INV_VSYNC(vsync) ((vsync) << 3)
+#define CFG_INV_VSYNC_MASK 0x00000008
+#define CFG_INV_HSYNC(hsync) ((hsync) << 2)
+#define CFG_INV_HSYNC_MASK 0x00000004
+#define CFG_INV_PCLK(pclk) ((pclk) << 1)
+#define CFG_INV_PCLK_MASK 0x00000002
+#define CFG_DUMB_ENA(dumb) (dumb)
+#define CFG_DUMB_ENA_MASK 0x00000001
+
+/* LCD I/O Pads Control Register */
+#define SPU_IOPAD_CONTROL 0x01BC
+#define CFG_GRA_VM_ENA(vm) ((vm) << 15) /* gfx */
+#define CFG_GRA_VM_ENA_MASK 0x00008000
+#define CFG_DMA_VM_ENA(vm) ((vm) << 13) /* video */
+#define CFG_DMA_VM_ENA_MASK 0x00002000
+#define CFG_CMD_VM_ENA(vm) ((vm) << 13)
+#define CFG_CMD_VM_ENA_MASK 0x00000800
+#define CFG_CSC(csc) ((csc) << 8) /* csc */
+#define CFG_CSC_MASK 0x00000300
+#define CFG_AXICTRL(axi) ((axi) << 4)
+#define CFG_AXICTRL_MASK 0x000000F0
+#define CFG_IOPADMODE(iopad) (iopad)
+#define CFG_IOPADMODE_MASK 0x0000000F
+
+/* LCD Interrupt Control Register */
+#define SPU_IRQ_ENA 0x01C0
+#define DMA_FRAME_IRQ0_ENA(irq) ((irq) << 31)
+#define DMA_FRAME_IRQ0_ENA_MASK 0x80000000
+#define DMA_FRAME_IRQ1_ENA(irq) ((irq) << 30)
+#define DMA_FRAME_IRQ1_ENA_MASK 0x40000000
+#define DMA_FF_UNDERFLOW_ENA(ff) ((ff) << 29)
+#define DMA_FF_UNDERFLOW_ENA_MASK 0x20000000
+#define GRA_FRAME_IRQ0_ENA(irq) ((irq) << 27)
+#define GRA_FRAME_IRQ0_ENA_MASK 0x08000000
+#define GRA_FRAME_IRQ1_ENA(irq) ((irq) << 26)
+#define GRA_FRAME_IRQ1_ENA_MASK 0x04000000
+#define GRA_FF_UNDERFLOW_ENA(ff) ((ff) << 25)
+#define GRA_FF_UNDERFLOW_ENA_MASK 0x02000000
+#define VSYNC_IRQ_ENA(vsync_irq) ((vsync_irq) << 23)
+#define VSYNC_IRQ_ENA_MASK 0x00800000
+#define DUMB_FRAMEDONE_ENA(fdone) ((fdone) << 22)
+#define DUMB_FRAMEDONE_ENA_MASK 0x00400000
+#define TWC_FRAMEDONE_ENA(fdone) ((fdone) << 21)
+#define TWC_FRAMEDONE_ENA_MASK 0x00200000
+#define HWC_FRAMEDONE_ENA(fdone) ((fdone) << 20)
+#define HWC_FRAMEDONE_ENA_MASK 0x00100000
+#define SLV_IRQ_ENA(irq) ((irq) << 19)
+#define SLV_IRQ_ENA_MASK 0x00080000
+#define SPI_IRQ_ENA(irq) ((irq) << 18)
+#define SPI_IRQ_ENA_MASK 0x00040000
+#define PWRDN_IRQ_ENA(irq) ((irq) << 17)
+#define PWRDN_IRQ_ENA_MASK 0x00020000
+#define ERR_IRQ_ENA(irq) ((irq) << 16)
+#define ERR_IRQ_ENA_MASK 0x00010000
+#define CLEAN_SPU_IRQ_ISR(irq) (irq)
+#define CLEAN_SPU_IRQ_ISR_MASK 0x0000FFFF
+
+/* LCD Interrupt Status Register */
+#define SPU_IRQ_ISR 0x01C4
+#define DMA_FRAME_IRQ0(irq) ((irq) << 31)
+#define DMA_FRAME_IRQ0_MASK 0x80000000
+#define DMA_FRAME_IRQ1(irq) ((irq) << 30)
+#define DMA_FRAME_IRQ1_MASK 0x40000000
+#define DMA_FF_UNDERFLOW(ff) ((ff) << 29)
+#define DMA_FF_UNDERFLOW_MASK 0x20000000
+#define GRA_FRAME_IRQ0(irq) ((irq) << 27)
+#define GRA_FRAME_IRQ0_MASK 0x08000000
+#define GRA_FRAME_IRQ1(irq) ((irq) << 26)
+#define GRA_FRAME_IRQ1_MASK 0x04000000
+#define GRA_FF_UNDERFLOW(ff) ((ff) << 25)
+#define GRA_FF_UNDERFLOW_MASK 0x02000000
+#define VSYNC_IRQ(vsync_irq) ((vsync_irq) << 23)
+#define VSYNC_IRQ_MASK 0x00800000
+#define DUMB_FRAMEDONE(fdone) ((fdone) << 22)
+#define DUMB_FRAMEDONE_MASK 0x00400000
+#define TWC_FRAMEDONE(fdone) ((fdone) << 21)
+#define TWC_FRAMEDONE_MASK 0x00200000
+#define HWC_FRAMEDONE(fdone) ((fdone) << 20)
+#define HWC_FRAMEDONE_MASK 0x00100000
+#define SLV_IRQ(irq) ((irq) << 19)
+#define SLV_IRQ_MASK 0x00080000
+#define SPI_IRQ(irq) ((irq) << 18)
+#define SPI_IRQ_MASK 0x00040000
+#define PWRDN_IRQ(irq) ((irq) << 17)
+#define PWRDN_IRQ_MASK 0x00020000
+#define ERR_IRQ(irq) ((irq) << 16)
+#define ERR_IRQ_MASK 0x00010000
+/* read-only */
+#define DMA_FRAME_IRQ0_LEVEL_MASK 0x00008000
+#define DMA_FRAME_IRQ1_LEVEL_MASK 0x00004000
+#define DMA_FRAME_CNT_ISR_MASK 0x00003000
+#define GRA_FRAME_IRQ0_LEVEL_MASK 0x00000800
+#define GRA_FRAME_IRQ1_LEVEL_MASK 0x00000400
+#define GRA_FRAME_CNT_ISR_MASK 0x00000300
+#define VSYNC_IRQ_LEVEL_MASK 0x00000080
+#define DUMB_FRAMEDONE_LEVEL_MASK 0x00000040
+#define TWC_FRAMEDONE_LEVEL_MASK 0x00000020
+#define HWC_FRAMEDONE_LEVEL_MASK 0x00000010
+#define SLV_FF_EMPTY_MASK 0x00000008
+#define DMA_FF_ALLEMPTY_MASK 0x00000004
+#define GRA_FF_ALLEMPTY_MASK 0x00000002
+#define PWRDN_IRQ_LEVEL_MASK 0x00000001
+
+
+/*
+ * defined Video Memory Color format for DMA control 0 register
+ * DMA0 bit[23:20]
+ */
+#define VMODE_RGB565 0x0
+#define VMODE_RGB1555 0x1
+#define VMODE_RGB888PACKED 0x2
+#define VMODE_RGB888UNPACKED 0x3
+#define VMODE_RGBA888 0x4
+#define VMODE_YUV422PACKED 0x5
+#define VMODE_YUV422PLANAR 0x6
+#define VMODE_YUV420PLANAR 0x7
+#define VMODE_SMPNCMD 0x8
+#define VMODE_PALETTE4BIT 0x9
+#define VMODE_PALETTE8BIT 0xa
+#define VMODE_RESERVED 0xb
+
+/*
+ * defined Graphic Memory Color format for DMA control 0 register
+ * DMA0 bit[19:16]
+ */
+#define GMODE_RGB565 0x0
+#define GMODE_RGB1555 0x1
+#define GMODE_RGB888PACKED 0x2
+#define GMODE_RGB888UNPACKED 0x3
+#define GMODE_RGBA888 0x4
+#define GMODE_YUV422PACKED 0x5
+#define GMODE_YUV422PLANAR 0x6
+#define GMODE_YUV420PLANAR 0x7
+#define GMODE_SMPNCMD 0x8
+#define GMODE_PALETTE4BIT 0x9
+#define GMODE_PALETTE8BIT 0xa
+#define GMODE_RESERVED 0xb
+
+/*
+ * define for DMA control 1 register
+ */
+#define DMA1_FRAME_TRIG 31 /* bit location */
+#define DMA1_VSYNC_MODE 28
+#define DMA1_VSYNC_INV 27
+#define DMA1_CKEY 24
+#define DMA1_CARRY 23
+#define DMA1_LNBUF_ENA 22
+#define DMA1_GATED_ENA 21
+#define DMA1_PWRDN_ENA 20
+#define DMA1_DSCALE 18
+#define DMA1_ALPHA_MODE 16
+#define DMA1_ALPHA 08
+#define DMA1_PXLCMD 00
+
+/*
+ * defined for Configure Dumb Mode
+ * DUMB LCD Panel bit[31:28]
+ */
+#define DUMB16_RGB565_0 0x0
+#define DUMB16_RGB565_1 0x1
+#define DUMB18_RGB666_0 0x2
+#define DUMB18_RGB666_1 0x3
+#define DUMB12_RGB444_0 0x4
+#define DUMB12_RGB444_1 0x5
+#define DUMB24_RGB888_0 0x6
+#define DUMB_BLANK 0x7
+
+/*
+ * defined for Configure I/O Pin Allocation Mode
+ * LCD LCD I/O Pads control register bit[3:0]
+ */
+#define IOPAD_DUMB24 0x0
+#define IOPAD_DUMB18SPI 0x1
+#define IOPAD_DUMB18GPIO 0x2
+#define IOPAD_DUMB16SPI 0x3
+#define IOPAD_DUMB16GPIO 0x4
+#define IOPAD_DUMB12 0x5
+#define IOPAD_SMART18SPI 0x6
+#define IOPAD_SMART16SPI 0x7
+#define IOPAD_SMART8BOTH 0x8
+
+#endif /* __PXA168FB_H__ */
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 92ea0ab44ce2..f10d2fbeda06 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -47,6 +47,7 @@ struct sh_mobile_lcdc_priv {
#endif
unsigned long lddckr;
struct sh_mobile_lcdc_chan ch[2];
+ int started;
};
/* shared registers */
@@ -451,6 +452,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
/* start the lcdc */
sh_mobile_lcdc_start_stop(priv, 1);
+ priv->started = 1;
/* tell the board code to enable the panel */
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
@@ -493,7 +495,10 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
}
/* stop the lcdc */
- sh_mobile_lcdc_start_stop(priv, 0);
+ if (priv->started) {
+ sh_mobile_lcdc_start_stop(priv, 0);
+ priv->started = 0;
+ }
/* stop clocks */
for (k = 0; k < ARRAY_SIZE(priv->ch); k++)
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 89f231dc443f..ff43c8885028 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -1315,7 +1315,6 @@ static int __devinit tdfxfb_setup_i2c_bus(struct tdfxfb_i2c_chan *chan,
strlcpy(chan->adapter.name, name, sizeof(chan->adapter.name));
chan->adapter.owner = THIS_MODULE;
- chan->adapter.class = I2C_CLASS_TV_ANALOG;
chan->adapter.algo_data = &chan->algo;
chan->adapter.dev.parent = dev;
chan->algo.setsda = tdfxfb_i2c_setsda;
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 421770b5e6ab..ca5b4643a401 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -45,7 +45,7 @@ static struct fb_fix_screeninfo uvesafb_fix __devinitdata = {
static int mtrr __devinitdata = 3; /* enable mtrr by default */
static int blank = 1; /* enable blanking by default */
static int ypan = 1; /* 0: scroll, 1: ypan, 2: ywrap */
-static int pmi_setpal __devinitdata = 1; /* use PMI for palette changes */
+static bool pmi_setpal __devinitdata = true; /* use PMI for palette changes */
static int nocrtc __devinitdata; /* ignore CRTC settings */
static int noedid __devinitdata; /* don't try DDC transfers */
static int vram_remap __devinitdata; /* set amt. of memory to be used */
@@ -2002,11 +2002,7 @@ static void __devexit uvesafb_exit(void)
module_exit(uvesafb_exit);
-static int param_get_scroll(char *buffer, struct kernel_param *kp)
-{
- return 0;
-}
-
+#define param_get_scroll NULL
static int param_set_scroll(const char *val, struct kernel_param *kp)
{
ypan = 0;
@@ -2017,6 +2013,8 @@ static int param_set_scroll(const char *val, struct kernel_param *kp)
ypan = 1;
else if (!strcmp(val, "ywrap"))
ypan = 2;
+ else
+ return -EINVAL;
return 0;
}
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 2493f05e9f61..15502d5e3641 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -384,7 +384,7 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
fb_size = XENFB_DEFAULT_FB_LEN;
}
- dev->dev.driver_data = info;
+ dev_set_drvdata(&dev->dev, info);
info->xbdev = dev;
info->irq = -1;
info->x1 = info->y1 = INT_MAX;
@@ -503,7 +503,7 @@ xenfb_make_preferred_console(void)
static int xenfb_resume(struct xenbus_device *dev)
{
- struct xenfb_info *info = dev->dev.driver_data;
+ struct xenfb_info *info = dev_get_drvdata(&dev->dev);
xenfb_disconnect_backend(info);
xenfb_init_shared_page(info, info->fb_info);
@@ -512,7 +512,7 @@ static int xenfb_resume(struct xenbus_device *dev)
static int xenfb_remove(struct xenbus_device *dev)
{
- struct xenfb_info *info = dev->dev.driver_data;
+ struct xenfb_info *info = dev_get_drvdata(&dev->dev);
xenfb_disconnect_backend(info);
if (info->fb_info) {
@@ -621,7 +621,7 @@ static void xenfb_disconnect_backend(struct xenfb_info *info)
static void xenfb_backend_changed(struct xenbus_device *dev,
enum xenbus_state backend_state)
{
- struct xenfb_info *info = dev->dev.driver_data;
+ struct xenfb_info *info = dev_get_drvdata(&dev->dev);
int val;
switch (backend_state) {
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 018c070a357f..bd0745250fd9 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -31,11 +31,27 @@ static ssize_t modalias_show(struct device *_d,
return sprintf(buf, "virtio:d%08Xv%08X\n",
dev->id.device, dev->id.vendor);
}
+static ssize_t features_show(struct device *_d,
+ struct device_attribute *attr, char *buf)
+{
+ struct virtio_device *dev = container_of(_d, struct virtio_device, dev);
+ unsigned int i;
+ ssize_t len = 0;
+
+ /* We actually represent this as a bitstring, as it could be
+ * arbitrary length in future. */
+ for (i = 0; i < ARRAY_SIZE(dev->features)*BITS_PER_LONG; i++)
+ len += sprintf(buf+len, "%c",
+ test_bit(i, dev->features) ? '1' : '0');
+ len += sprintf(buf+len, "\n");
+ return len;
+}
static struct device_attribute virtio_dev_attrs[] = {
__ATTR_RO(device),
__ATTR_RO(vendor),
__ATTR_RO(status),
__ATTR_RO(modalias),
+ __ATTR_RO(features),
__ATTR_NULL
};
@@ -118,13 +134,14 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1 << i))
set_bit(i, dev->features);
+ dev->config->finalize_features(dev);
+
err = drv->probe(dev);
if (err)
add_status(dev, VIRTIO_CONFIG_S_FAILED);
- else {
- dev->config->finalize_features(dev);
+ else
add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
- }
+
return err;
}
@@ -185,6 +202,8 @@ int register_virtio_device(struct virtio_device *dev)
/* Acknowledge that we've seen the device. */
add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
+ INIT_LIST_HEAD(&dev->vqs);
+
/* device_register() causes the bus infrastructure to look for a
* matching driver. */
err = device_register(&dev->dev);
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 9c76a061a04d..26b278264796 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -204,6 +204,9 @@ static int balloon(void *_vballoon)
static int virtballoon_probe(struct virtio_device *vdev)
{
struct virtio_balloon *vb;
+ struct virtqueue *vqs[2];
+ vq_callback_t *callbacks[] = { balloon_ack, balloon_ack };
+ const char *names[] = { "inflate", "deflate" };
int err;
vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL);
@@ -218,22 +221,17 @@ static int virtballoon_probe(struct virtio_device *vdev)
vb->vdev = vdev;
/* We expect two virtqueues. */
- vb->inflate_vq = vdev->config->find_vq(vdev, 0, balloon_ack);
- if (IS_ERR(vb->inflate_vq)) {
- err = PTR_ERR(vb->inflate_vq);
+ err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names);
+ if (err)
goto out_free_vb;
- }
- vb->deflate_vq = vdev->config->find_vq(vdev, 1, balloon_ack);
- if (IS_ERR(vb->deflate_vq)) {
- err = PTR_ERR(vb->deflate_vq);
- goto out_del_inflate_vq;
- }
+ vb->inflate_vq = vqs[0];
+ vb->deflate_vq = vqs[1];
vb->thread = kthread_run(balloon, vb, "vballoon");
if (IS_ERR(vb->thread)) {
err = PTR_ERR(vb->thread);
- goto out_del_deflate_vq;
+ goto out_del_vqs;
}
vb->tell_host_first
@@ -241,10 +239,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
return 0;
-out_del_deflate_vq:
- vdev->config->del_vq(vb->deflate_vq);
-out_del_inflate_vq:
- vdev->config->del_vq(vb->inflate_vq);
+out_del_vqs:
+ vdev->config->del_vqs(vdev);
out_free_vb:
kfree(vb);
out:
@@ -264,8 +260,7 @@ static void virtballoon_remove(struct virtio_device *vdev)
/* Now we reset the device so we can clean up the queues. */
vdev->config->reset(vdev);
- vdev->config->del_vq(vb->deflate_vq);
- vdev->config->del_vq(vb->inflate_vq);
+ vdev->config->del_vqs(vdev);
kfree(vb);
}
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 330aacbdec1f..193c8f0e5cc5 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -42,6 +42,26 @@ struct virtio_pci_device
/* a list of queues so we can dispatch IRQs */
spinlock_t lock;
struct list_head virtqueues;
+
+ /* MSI-X support */
+ int msix_enabled;
+ int intx_enabled;
+ struct msix_entry *msix_entries;
+ /* Name strings for interrupts. This size should be enough,
+ * and I'm too lazy to allocate each name separately. */
+ char (*msix_names)[256];
+ /* Number of available vectors */
+ unsigned msix_vectors;
+ /* Vectors allocated */
+ unsigned msix_used_vectors;
+};
+
+/* Constants for MSI-X */
+/* Use first vector for configuration changes, second and the rest for
+ * virtqueues Thus, we need at least 2 vectors for MSI. */
+enum {
+ VP_MSIX_CONFIG_VECTOR = 0,
+ VP_MSIX_VQ_VECTOR = 1,
};
struct virtio_pci_vq_info
@@ -60,6 +80,9 @@ struct virtio_pci_vq_info
/* the list node for the virtqueues list */
struct list_head node;
+
+ /* MSI-X vector (or none) */
+ unsigned vector;
};
/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */
@@ -109,7 +132,8 @@ static void vp_get(struct virtio_device *vdev, unsigned offset,
void *buf, unsigned len)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
- void __iomem *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset;
+ void __iomem *ioaddr = vp_dev->ioaddr +
+ VIRTIO_PCI_CONFIG(vp_dev) + offset;
u8 *ptr = buf;
int i;
@@ -123,7 +147,8 @@ static void vp_set(struct virtio_device *vdev, unsigned offset,
const void *buf, unsigned len)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
- void __iomem *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset;
+ void __iomem *ioaddr = vp_dev->ioaddr +
+ VIRTIO_PCI_CONFIG(vp_dev) + offset;
const u8 *ptr = buf;
int i;
@@ -164,6 +189,37 @@ static void vp_notify(struct virtqueue *vq)
iowrite16(info->queue_index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_NOTIFY);
}
+/* Handle a configuration change: Tell driver if it wants to know. */
+static irqreturn_t vp_config_changed(int irq, void *opaque)
+{
+ struct virtio_pci_device *vp_dev = opaque;
+ struct virtio_driver *drv;
+ drv = container_of(vp_dev->vdev.dev.driver,
+ struct virtio_driver, driver);
+
+ if (drv && drv->config_changed)
+ drv->config_changed(&vp_dev->vdev);
+ return IRQ_HANDLED;
+}
+
+/* Notify all virtqueues on an interrupt. */
+static irqreturn_t vp_vring_interrupt(int irq, void *opaque)
+{
+ struct virtio_pci_device *vp_dev = opaque;
+ struct virtio_pci_vq_info *info;
+ irqreturn_t ret = IRQ_NONE;
+ unsigned long flags;
+
+ spin_lock_irqsave(&vp_dev->lock, flags);
+ list_for_each_entry(info, &vp_dev->virtqueues, node) {
+ if (vring_interrupt(irq, info->vq) == IRQ_HANDLED)
+ ret = IRQ_HANDLED;
+ }
+ spin_unlock_irqrestore(&vp_dev->lock, flags);
+
+ return ret;
+}
+
/* A small wrapper to also acknowledge the interrupt when it's handled.
* I really need an EIO hook for the vring so I can ack the interrupt once we
* know that we'll be handling the IRQ but before we invoke the callback since
@@ -173,9 +229,6 @@ static void vp_notify(struct virtqueue *vq)
static irqreturn_t vp_interrupt(int irq, void *opaque)
{
struct virtio_pci_device *vp_dev = opaque;
- struct virtio_pci_vq_info *info;
- irqreturn_t ret = IRQ_NONE;
- unsigned long flags;
u8 isr;
/* reading the ISR has the effect of also clearing it so it's very
@@ -187,34 +240,137 @@ static irqreturn_t vp_interrupt(int irq, void *opaque)
return IRQ_NONE;
/* Configuration change? Tell driver if it wants to know. */
- if (isr & VIRTIO_PCI_ISR_CONFIG) {
- struct virtio_driver *drv;
- drv = container_of(vp_dev->vdev.dev.driver,
- struct virtio_driver, driver);
+ if (isr & VIRTIO_PCI_ISR_CONFIG)
+ vp_config_changed(irq, opaque);
- if (drv && drv->config_changed)
- drv->config_changed(&vp_dev->vdev);
+ return vp_vring_interrupt(irq, opaque);
+}
+
+static void vp_free_vectors(struct virtio_device *vdev)
+{
+ struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+ int i;
+
+ if (vp_dev->intx_enabled) {
+ free_irq(vp_dev->pci_dev->irq, vp_dev);
+ vp_dev->intx_enabled = 0;
}
- spin_lock_irqsave(&vp_dev->lock, flags);
- list_for_each_entry(info, &vp_dev->virtqueues, node) {
- if (vring_interrupt(irq, info->vq) == IRQ_HANDLED)
- ret = IRQ_HANDLED;
+ for (i = 0; i < vp_dev->msix_used_vectors; ++i)
+ free_irq(vp_dev->msix_entries[i].vector, vp_dev);
+ vp_dev->msix_used_vectors = 0;
+
+ if (vp_dev->msix_enabled) {
+ /* Disable the vector used for configuration */
+ iowrite16(VIRTIO_MSI_NO_VECTOR,
+ vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
+ /* Flush the write out to device */
+ ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
+
+ vp_dev->msix_enabled = 0;
+ pci_disable_msix(vp_dev->pci_dev);
}
- spin_unlock_irqrestore(&vp_dev->lock, flags);
+}
- return ret;
+static int vp_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
+ int *options, int noptions)
+{
+ int i;
+ for (i = 0; i < noptions; ++i)
+ if (!pci_enable_msix(dev, entries, options[i]))
+ return options[i];
+ return -EBUSY;
+}
+
+static int vp_request_vectors(struct virtio_device *vdev, unsigned max_vqs)
+{
+ struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+ const char *name = dev_name(&vp_dev->vdev.dev);
+ unsigned i, v;
+ int err = -ENOMEM;
+ /* We want at most one vector per queue and one for config changes.
+ * Fallback to separate vectors for config and a shared for queues.
+ * Finally fall back to regular interrupts. */
+ int options[] = { max_vqs + 1, 2 };
+ int nvectors = max(options[0], options[1]);
+
+ vp_dev->msix_entries = kmalloc(nvectors * sizeof *vp_dev->msix_entries,
+ GFP_KERNEL);
+ if (!vp_dev->msix_entries)
+ goto error_entries;
+ vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names,
+ GFP_KERNEL);
+ if (!vp_dev->msix_names)
+ goto error_names;
+
+ for (i = 0; i < nvectors; ++i)
+ vp_dev->msix_entries[i].entry = i;
+
+ err = vp_enable_msix(vp_dev->pci_dev, vp_dev->msix_entries,
+ options, ARRAY_SIZE(options));
+ if (err < 0) {
+ /* Can't allocate enough MSI-X vectors, use regular interrupt */
+ vp_dev->msix_vectors = 0;
+ err = request_irq(vp_dev->pci_dev->irq, vp_interrupt,
+ IRQF_SHARED, name, vp_dev);
+ if (err)
+ goto error_irq;
+ vp_dev->intx_enabled = 1;
+ } else {
+ vp_dev->msix_vectors = err;
+ vp_dev->msix_enabled = 1;
+
+ /* Set the vector used for configuration */
+ v = vp_dev->msix_used_vectors;
+ snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names,
+ "%s-config", name);
+ err = request_irq(vp_dev->msix_entries[v].vector,
+ vp_config_changed, 0, vp_dev->msix_names[v],
+ vp_dev);
+ if (err)
+ goto error_irq;
+ ++vp_dev->msix_used_vectors;
+
+ iowrite16(v, vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
+ /* Verify we had enough resources to assign the vector */
+ v = ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
+ if (v == VIRTIO_MSI_NO_VECTOR) {
+ err = -EBUSY;
+ goto error_irq;
+ }
+ }
+
+ if (vp_dev->msix_vectors && vp_dev->msix_vectors != max_vqs + 1) {
+ /* Shared vector for all VQs */
+ v = vp_dev->msix_used_vectors;
+ snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names,
+ "%s-virtqueues", name);
+ err = request_irq(vp_dev->msix_entries[v].vector,
+ vp_vring_interrupt, 0, vp_dev->msix_names[v],
+ vp_dev);
+ if (err)
+ goto error_irq;
+ ++vp_dev->msix_used_vectors;
+ }
+ return 0;
+error_irq:
+ vp_free_vectors(vdev);
+ kfree(vp_dev->msix_names);
+error_names:
+ kfree(vp_dev->msix_entries);
+error_entries:
+ return err;
}
-/* the config->find_vq() implementation */
static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index,
- void (*callback)(struct virtqueue *vq))
+ void (*callback)(struct virtqueue *vq),
+ const char *name)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
struct virtio_pci_vq_info *info;
struct virtqueue *vq;
unsigned long flags, size;
- u16 num;
+ u16 num, vector;
int err;
/* Select the queue we're interested in */
@@ -233,6 +389,7 @@ static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index,
info->queue_index = index;
info->num = num;
+ info->vector = VIRTIO_MSI_NO_VECTOR;
size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN));
info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO);
@@ -247,7 +404,7 @@ static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index,
/* create the vring */
vq = vring_new_virtqueue(info->num, VIRTIO_PCI_VRING_ALIGN,
- vdev, info->queue, vp_notify, callback);
+ vdev, info->queue, vp_notify, callback, name);
if (!vq) {
err = -ENOMEM;
goto out_activate_queue;
@@ -256,12 +413,43 @@ static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index,
vq->priv = info;
info->vq = vq;
+ /* allocate per-vq vector if available and necessary */
+ if (callback && vp_dev->msix_used_vectors < vp_dev->msix_vectors) {
+ vector = vp_dev->msix_used_vectors;
+ snprintf(vp_dev->msix_names[vector], sizeof *vp_dev->msix_names,
+ "%s-%s", dev_name(&vp_dev->vdev.dev), name);
+ err = request_irq(vp_dev->msix_entries[vector].vector,
+ vring_interrupt, 0,
+ vp_dev->msix_names[vector], vq);
+ if (err)
+ goto out_request_irq;
+ info->vector = vector;
+ ++vp_dev->msix_used_vectors;
+ } else
+ vector = VP_MSIX_VQ_VECTOR;
+
+ if (callback && vp_dev->msix_enabled) {
+ iowrite16(vector, vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR);
+ vector = ioread16(vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR);
+ if (vector == VIRTIO_MSI_NO_VECTOR) {
+ err = -EBUSY;
+ goto out_assign;
+ }
+ }
+
spin_lock_irqsave(&vp_dev->lock, flags);
list_add(&info->node, &vp_dev->virtqueues);
spin_unlock_irqrestore(&vp_dev->lock, flags);
return vq;
+out_assign:
+ if (info->vector != VIRTIO_MSI_NO_VECTOR) {
+ free_irq(vp_dev->msix_entries[info->vector].vector, vq);
+ --vp_dev->msix_used_vectors;
+ }
+out_request_irq:
+ vring_del_virtqueue(vq);
out_activate_queue:
iowrite32(0, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
free_pages_exact(info->queue, size);
@@ -270,21 +458,27 @@ out_info:
return ERR_PTR(err);
}
-/* the config->del_vq() implementation */
static void vp_del_vq(struct virtqueue *vq)
{
struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
struct virtio_pci_vq_info *info = vq->priv;
- unsigned long flags, size;
+ unsigned long size;
- spin_lock_irqsave(&vp_dev->lock, flags);
- list_del(&info->node);
- spin_unlock_irqrestore(&vp_dev->lock, flags);
+ iowrite16(info->queue_index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
+
+ if (info->vector != VIRTIO_MSI_NO_VECTOR)
+ free_irq(vp_dev->msix_entries[info->vector].vector, vq);
+
+ if (vp_dev->msix_enabled) {
+ iowrite16(VIRTIO_MSI_NO_VECTOR,
+ vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR);
+ /* Flush the write out to device */
+ ioread8(vp_dev->ioaddr + VIRTIO_PCI_ISR);
+ }
vring_del_virtqueue(vq);
/* Select and deactivate the queue */
- iowrite16(info->queue_index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
iowrite32(0, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
size = PAGE_ALIGN(vring_size(info->num, VIRTIO_PCI_VRING_ALIGN));
@@ -292,14 +486,57 @@ static void vp_del_vq(struct virtqueue *vq)
kfree(info);
}
+/* the config->del_vqs() implementation */
+static void vp_del_vqs(struct virtio_device *vdev)
+{
+ struct virtqueue *vq, *n;
+
+ list_for_each_entry_safe(vq, n, &vdev->vqs, list)
+ vp_del_vq(vq);
+
+ vp_free_vectors(vdev);
+}
+
+/* the config->find_vqs() implementation */
+static int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs,
+ struct virtqueue *vqs[],
+ vq_callback_t *callbacks[],
+ const char *names[])
+{
+ int vectors = 0;
+ int i, err;
+
+ /* How many vectors would we like? */
+ for (i = 0; i < nvqs; ++i)
+ if (callbacks[i])
+ ++vectors;
+
+ err = vp_request_vectors(vdev, vectors);
+ if (err)
+ goto error_request;
+
+ for (i = 0; i < nvqs; ++i) {
+ vqs[i] = vp_find_vq(vdev, i, callbacks[i], names[i]);
+ if (IS_ERR(vqs[i]))
+ goto error_find;
+ }
+ return 0;
+
+error_find:
+ vp_del_vqs(vdev);
+
+error_request:
+ return PTR_ERR(vqs[i]);
+}
+
static struct virtio_config_ops virtio_pci_config_ops = {
.get = vp_get,
.set = vp_set,
.get_status = vp_get_status,
.set_status = vp_set_status,
.reset = vp_reset,
- .find_vq = vp_find_vq,
- .del_vq = vp_del_vq,
+ .find_vqs = vp_find_vqs,
+ .del_vqs = vp_del_vqs,
.get_features = vp_get_features,
.finalize_features = vp_finalize_features,
};
@@ -310,7 +547,7 @@ static void virtio_pci_release_dev(struct device *_d)
struct virtio_pci_device *vp_dev = to_vp_device(dev);
struct pci_dev *pci_dev = vp_dev->pci_dev;
- free_irq(pci_dev->irq, vp_dev);
+ vp_del_vqs(dev);
pci_set_drvdata(pci_dev, NULL);
pci_iounmap(pci_dev, vp_dev->ioaddr);
pci_release_regions(pci_dev);
@@ -369,21 +606,13 @@ static int __devinit virtio_pci_probe(struct pci_dev *pci_dev,
vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor;
vp_dev->vdev.id.device = pci_dev->subsystem_device;
- /* register a handler for the queue with the PCI device's interrupt */
- err = request_irq(vp_dev->pci_dev->irq, vp_interrupt, IRQF_SHARED,
- dev_name(&vp_dev->vdev.dev), vp_dev);
- if (err)
- goto out_set_drvdata;
-
/* finally register the virtio device */
err = register_virtio_device(&vp_dev->vdev);
if (err)
- goto out_req_irq;
+ goto out_set_drvdata;
return 0;
-out_req_irq:
- free_irq(pci_dev->irq, vp_dev);
out_set_drvdata:
pci_set_drvdata(pci_dev, NULL);
pci_iounmap(pci_dev, vp_dev->ioaddr);
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 5c52369ab9bb..a882f2606515 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -23,21 +23,30 @@
#ifdef DEBUG
/* For development, we want to crash whenever the ring is screwed. */
-#define BAD_RING(_vq, fmt...) \
- do { dev_err(&(_vq)->vq.vdev->dev, fmt); BUG(); } while(0)
+#define BAD_RING(_vq, fmt, args...) \
+ do { \
+ dev_err(&(_vq)->vq.vdev->dev, \
+ "%s:"fmt, (_vq)->vq.name, ##args); \
+ BUG(); \
+ } while (0)
/* Caller is supposed to guarantee no reentry. */
#define START_USE(_vq) \
do { \
if ((_vq)->in_use) \
- panic("in_use = %i\n", (_vq)->in_use); \
+ panic("%s:in_use = %i\n", \
+ (_vq)->vq.name, (_vq)->in_use); \
(_vq)->in_use = __LINE__; \
mb(); \
- } while(0)
+ } while (0)
#define END_USE(_vq) \
do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0)
#else
-#define BAD_RING(_vq, fmt...) \
- do { dev_err(&_vq->vq.vdev->dev, fmt); (_vq)->broken = true; } while(0)
+#define BAD_RING(_vq, fmt, args...) \
+ do { \
+ dev_err(&_vq->vq.vdev->dev, \
+ "%s:"fmt, (_vq)->vq.name, ##args); \
+ (_vq)->broken = true; \
+ } while (0)
#define START_USE(vq)
#define END_USE(vq)
#endif
@@ -52,6 +61,9 @@ struct vring_virtqueue
/* Other side has made a mess, don't try any more. */
bool broken;
+ /* Host supports indirect buffers */
+ bool indirect;
+
/* Number of free buffers */
unsigned int num_free;
/* Head of free buffer list. */
@@ -76,6 +88,55 @@ struct vring_virtqueue
#define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq)
+/* Set up an indirect table of descriptors and add it to the queue. */
+static int vring_add_indirect(struct vring_virtqueue *vq,
+ struct scatterlist sg[],
+ unsigned int out,
+ unsigned int in)
+{
+ struct vring_desc *desc;
+ unsigned head;
+ int i;
+
+ desc = kmalloc((out + in) * sizeof(struct vring_desc), GFP_ATOMIC);
+ if (!desc)
+ return vq->vring.num;
+
+ /* Transfer entries from the sg list into the indirect page */
+ for (i = 0; i < out; i++) {
+ desc[i].flags = VRING_DESC_F_NEXT;
+ desc[i].addr = sg_phys(sg);
+ desc[i].len = sg->length;
+ desc[i].next = i+1;
+ sg++;
+ }
+ for (; i < (out + in); i++) {
+ desc[i].flags = VRING_DESC_F_NEXT|VRING_DESC_F_WRITE;
+ desc[i].addr = sg_phys(sg);
+ desc[i].len = sg->length;
+ desc[i].next = i+1;
+ sg++;
+ }
+
+ /* Last one doesn't continue. */
+ desc[i-1].flags &= ~VRING_DESC_F_NEXT;
+ desc[i-1].next = 0;
+
+ /* We're about to use a buffer */
+ vq->num_free--;
+
+ /* Use a single buffer which doesn't continue */
+ head = vq->free_head;
+ vq->vring.desc[head].flags = VRING_DESC_F_INDIRECT;
+ vq->vring.desc[head].addr = virt_to_phys(desc);
+ vq->vring.desc[head].len = i * sizeof(struct vring_desc);
+
+ /* Update free pointer */
+ vq->free_head = vq->vring.desc[head].next;
+
+ return head;
+}
+
static int vring_add_buf(struct virtqueue *_vq,
struct scatterlist sg[],
unsigned int out,
@@ -85,12 +146,21 @@ static int vring_add_buf(struct virtqueue *_vq,
struct vring_virtqueue *vq = to_vvq(_vq);
unsigned int i, avail, head, uninitialized_var(prev);
+ START_USE(vq);
+
BUG_ON(data == NULL);
+
+ /* If the host supports indirect descriptor tables, and we have multiple
+ * buffers, then go indirect. FIXME: tune this threshold */
+ if (vq->indirect && (out + in) > 1 && vq->num_free) {
+ head = vring_add_indirect(vq, sg, out, in);
+ if (head != vq->vring.num)
+ goto add_head;
+ }
+
BUG_ON(out + in > vq->vring.num);
BUG_ON(out + in == 0);
- START_USE(vq);
-
if (vq->num_free < out + in) {
pr_debug("Can't add buf len %i - avail = %i\n",
out + in, vq->num_free);
@@ -127,6 +197,7 @@ static int vring_add_buf(struct virtqueue *_vq,
/* Update free pointer */
vq->free_head = i;
+add_head:
/* Set token. */
vq->data[head] = data;
@@ -170,6 +241,11 @@ static void detach_buf(struct vring_virtqueue *vq, unsigned int head)
/* Put back on free list: find end */
i = head;
+
+ /* Free the indirect table */
+ if (vq->vring.desc[i].flags & VRING_DESC_F_INDIRECT)
+ kfree(phys_to_virt(vq->vring.desc[i].addr));
+
while (vq->vring.desc[i].flags & VRING_DESC_F_NEXT) {
i = vq->vring.desc[i].next;
vq->num_free++;
@@ -284,7 +360,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
struct virtio_device *vdev,
void *pages,
void (*notify)(struct virtqueue *),
- void (*callback)(struct virtqueue *))
+ void (*callback)(struct virtqueue *),
+ const char *name)
{
struct vring_virtqueue *vq;
unsigned int i;
@@ -303,14 +380,18 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
vq->vq.callback = callback;
vq->vq.vdev = vdev;
vq->vq.vq_ops = &vring_vq_ops;
+ vq->vq.name = name;
vq->notify = notify;
vq->broken = false;
vq->last_used_idx = 0;
vq->num_added = 0;
+ list_add_tail(&vq->vq.list, &vdev->vqs);
#ifdef DEBUG
vq->in_use = false;
#endif
+ vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC);
+
/* No callback? Tell other side not to bother us. */
if (!callback)
vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
@@ -327,6 +408,7 @@ EXPORT_SYMBOL_GPL(vring_new_virtqueue);
void vring_del_virtqueue(struct virtqueue *vq)
{
+ list_del(&vq->list);
kfree(to_vvq(vq));
}
EXPORT_SYMBOL_GPL(vring_del_virtqueue);
@@ -338,6 +420,8 @@ void vring_transport_features(struct virtio_device *vdev)
for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) {
switch (i) {
+ case VIRTIO_RING_F_INDIRECT_DESC:
+ break;
default:
/* We don't understand this bit. */
clear_bit(i, vdev->features);
diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c
index 90f98df5f106..f90afdb1b255 100644
--- a/drivers/watchdog/alim7101_wdt.c
+++ b/drivers/watchdog/alim7101_wdt.c
@@ -322,7 +322,8 @@ static int wdt_notify_sys(struct notifier_block *this,
* watchdog on reboot with no heartbeat
*/
wdt_change(WDT_ENABLE);
- printk(KERN_INFO PFX "Watchdog timer is now enabled with no heartbeat - should reboot in ~1 second.\n");
+ printk(KERN_INFO PFX "Watchdog timer is now enabled "
+ "with no heartbeat - should reboot in ~1 second.\n");
}
return NOTIFY_DONE;
}
@@ -374,12 +375,17 @@ static int __init alim7101_wdt_init(void)
pci_dev_put(ali1543_south);
if ((tmp & 0x1e) == 0x00) {
if (!use_gpio) {
- printk(KERN_INFO PFX "Detected old alim7101 revision 'a1d'. If this is a cobalt board, set the 'use_gpio' module parameter.\n");
+ printk(KERN_INFO PFX
+ "Detected old alim7101 revision 'a1d'. "
+ "If this is a cobalt board, set the 'use_gpio' "
+ "module parameter.\n");
goto err_out;
}
nowayout = 1;
} else if ((tmp & 0x1e) != 0x12 && (tmp & 0x1e) != 0x00) {
- printk(KERN_INFO PFX "ALi 1543 South-Bridge does not have the correct revision number (???1001?) - WDT not set\n");
+ printk(KERN_INFO PFX
+ "ALi 1543 South-Bridge does not have the correct "
+ "revision number (???1001?) - WDT not set\n");
goto err_out;
}
@@ -409,7 +415,8 @@ static int __init alim7101_wdt_init(void)
if (nowayout)
__module_get(THIS_MODULE);
- printk(KERN_INFO PFX "WDT driver for ALi M7101 initialised. timeout=%d sec (nowayout=%d)\n",
+ printk(KERN_INFO PFX "WDT driver for ALi M7101 initialised. "
+ "timeout=%d sec (nowayout=%d)\n",
timeout, nowayout);
return 0;
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c
index 55dcbfe2bb72..3fe9742c23ca 100644
--- a/drivers/watchdog/ar7_wdt.c
+++ b/drivers/watchdog/ar7_wdt.c
@@ -246,7 +246,8 @@ static long ar7_wdt_ioctl(struct file *file,
static struct watchdog_info ident = {
.identity = LONGNAME,
.firmware_version = 1,
- .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING),
+ .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
+ WDIOF_MAGICCLOSE),
};
int new_margin;
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index 29e52c237a3b..b185dafe1494 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -268,7 +268,8 @@ static int __init at91_wdt_init(void)
if not reset to the default */
if (at91_wdt_settimeout(wdt_time)) {
at91_wdt_settimeout(WDT_DEFAULT_TIME);
- pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
+ pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256"
+ ", using %d\n", wdt_time);
}
return platform_driver_register(&at91wdt_driver);
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 435b0573fb0a..eac26021e8da 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -156,7 +156,8 @@ static int at91_wdt_settimeout(unsigned int timeout)
static const struct watchdog_info at91_wdt_info = {
.identity = DRV_NAME,
- .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+ .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
+ WDIOF_MAGICCLOSE,
};
/*
diff --git a/drivers/watchdog/bfin_wdt.c b/drivers/watchdog/bfin_wdt.c
index 067a57cb3f82..c7b3f9df2317 100644
--- a/drivers/watchdog/bfin_wdt.c
+++ b/drivers/watchdog/bfin_wdt.c
@@ -27,10 +27,15 @@
#include <linux/uaccess.h>
#include <asm/blackfin.h>
-#define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
+#define stamp(fmt, args...) \
+ pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
#define stampit() stamp("here i am")
-#define pr_devinit(fmt, args...) ({ static const __devinitconst char __fmt[] = fmt; printk(__fmt, ## args); })
-#define pr_init(fmt, args...) ({ static const __initconst char __fmt[] = fmt; printk(__fmt, ## args); })
+#define pr_devinit(fmt, args...) \
+ ({ static const __devinitconst char __fmt[] = fmt; \
+ printk(__fmt, ## args); })
+#define pr_init(fmt, args...) \
+ ({ static const __initconst char __fmt[] = fmt; \
+ printk(__fmt, ## args); })
#define WATCHDOG_NAME "bfin-wdt"
#define PFX WATCHDOG_NAME ": "
@@ -476,7 +481,8 @@ static int __init bfin_wdt_init(void)
return ret;
}
- bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME, -1, NULL, 0);
+ bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME,
+ -1, NULL, 0);
if (IS_ERR(bfin_wdt_device)) {
pr_init(KERN_ERR PFX "unable to register device\n");
platform_driver_unregister(&bfin_wdt_driver);
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 41070e4771a0..081f2955419e 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -154,9 +154,9 @@ static struct cpwd *cpwd_device;
static struct timer_list cpwd_timer;
-static int wd0_timeout = 0;
-static int wd1_timeout = 0;
-static int wd2_timeout = 0;
+static int wd0_timeout;
+static int wd1_timeout;
+static int wd2_timeout;
module_param(wd0_timeout, int, 0);
MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index c51d0b0ea0c4..83e22e7ea4a2 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -193,7 +193,7 @@ static struct miscdevice davinci_wdt_miscdev = {
.fops = &davinci_wdt_fops,
};
-static int davinci_wdt_probe(struct platform_device *pdev)
+static int __devinit davinci_wdt_probe(struct platform_device *pdev)
{
int ret = 0, size;
struct resource *res;
@@ -237,7 +237,7 @@ static int davinci_wdt_probe(struct platform_device *pdev)
return ret;
}
-static int davinci_wdt_remove(struct platform_device *pdev)
+static int __devexit davinci_wdt_remove(struct platform_device *pdev)
{
misc_deregister(&davinci_wdt_miscdev);
if (wdt_mem) {
@@ -254,7 +254,7 @@ static struct platform_driver platform_wdt_driver = {
.owner = THIS_MODULE,
},
.probe = davinci_wdt_probe,
- .remove = davinci_wdt_remove,
+ .remove = __devexit_p(davinci_wdt_remove),
};
static int __init davinci_wdt_init(void)
diff --git a/drivers/watchdog/iTCO_vendor_support.c b/drivers/watchdog/iTCO_vendor_support.c
index d3c0f6de5523..843ef626bc50 100644
--- a/drivers/watchdog/iTCO_vendor_support.c
+++ b/drivers/watchdog/iTCO_vendor_support.c
@@ -35,9 +35,9 @@
#include "iTCO_vendor.h"
/* iTCO defines */
-#define SMI_EN acpibase + 0x30 /* SMI Control and Enable Register */
-#define TCOBASE acpibase + 0x60 /* TCO base address */
-#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */
+#define SMI_EN (acpibase + 0x30) /* SMI Control and Enable Register */
+#define TCOBASE (acpibase + 0x60) /* TCO base address */
+#define TCO1_STS (TCOBASE + 0x04) /* TCO1 Status Register */
/* List of vendor support modes */
/* SuperMicro Pentium 3 Era 370SSE+-OEM1/P3TSSE */
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 648250b998c4..6284961eff5b 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -236,19 +236,19 @@ MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
/* Address definitions for the TCO */
/* TCO base address */
-#define TCOBASE iTCO_wdt_private.ACPIBASE + 0x60
+#define TCOBASE (iTCO_wdt_private.ACPIBASE + 0x60)
/* SMI Control and Enable Register */
-#define SMI_EN iTCO_wdt_private.ACPIBASE + 0x30
-
-#define TCO_RLD TCOBASE + 0x00 /* TCO Timer Reload and Curr. Value */
-#define TCOv1_TMR TCOBASE + 0x01 /* TCOv1 Timer Initial Value */
-#define TCO_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */
-#define TCO_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */
-#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */
-#define TCO2_STS TCOBASE + 0x06 /* TCO2 Status Register */
-#define TCO1_CNT TCOBASE + 0x08 /* TCO1 Control Register */
-#define TCO2_CNT TCOBASE + 0x0a /* TCO2 Control Register */
-#define TCOv2_TMR TCOBASE + 0x12 /* TCOv2 Timer Initial Value */
+#define SMI_EN (iTCO_wdt_private.ACPIBASE + 0x30)
+
+#define TCO_RLD (TCOBASE + 0x00) /* TCO Timer Reload and Curr. Value */
+#define TCOv1_TMR (TCOBASE + 0x01) /* TCOv1 Timer Initial Value */
+#define TCO_DAT_IN (TCOBASE + 0x02) /* TCO Data In Register */
+#define TCO_DAT_OUT (TCOBASE + 0x03) /* TCO Data Out Register */
+#define TCO1_STS (TCOBASE + 0x04) /* TCO1 Status Register */
+#define TCO2_STS (TCOBASE + 0x06) /* TCO2 Status Register */
+#define TCO1_CNT (TCOBASE + 0x08) /* TCO1 Control Register */
+#define TCO2_CNT (TCOBASE + 0x0a) /* TCO2 Control Register */
+#define TCOv2_TMR (TCOBASE + 0x12) /* TCOv2 Timer Initial Value */
/* internal variables */
static unsigned long is_active;
diff --git a/drivers/watchdog/indydog.c b/drivers/watchdog/indydog.c
index 0f761db9a27c..bea8a124a559 100644
--- a/drivers/watchdog/indydog.c
+++ b/drivers/watchdog/indydog.c
@@ -83,7 +83,6 @@ static int indydog_open(struct inode *inode, struct file *file)
indydog_start();
indydog_ping();
- indydog_alive = 1;
printk(KERN_INFO "Started watchdog timer.\n");
return nonseekable_open(inode, file);
@@ -113,8 +112,7 @@ static long indydog_ioctl(struct file *file, unsigned int cmd,
{
int options, retval = -EINVAL;
static struct watchdog_info ident = {
- .options = WDIOF_KEEPALIVEPING |
- WDIOF_MAGICCLOSE,
+ .options = WDIOF_KEEPALIVEPING,
.firmware_version = 0,
.identity = "Hardware Watchdog for SGI IP22",
};
diff --git a/drivers/watchdog/iop_wdt.c b/drivers/watchdog/iop_wdt.c
index 96eb2cbe5874..0c9059676690 100644
--- a/drivers/watchdog/iop_wdt.c
+++ b/drivers/watchdog/iop_wdt.c
@@ -192,7 +192,7 @@ static int iop_wdt_release(struct inode *inode, struct file *file)
if (test_bit(WDT_ENABLED, &wdt_status))
state = wdt_disable();
- /* if the timer is not disbaled reload and notify that we are still
+ /* if the timer is not disabled reload and notify that we are still
* going down
*/
if (state != 0) {
diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c
index 2270ee07c01b..daed48ded7fe 100644
--- a/drivers/watchdog/it8712f_wdt.c
+++ b/drivers/watchdog/it8712f_wdt.c
@@ -239,7 +239,8 @@ static long it8712f_wdt_ioctl(struct file *file, unsigned int cmd,
static struct watchdog_info ident = {
.identity = "IT8712F Watchdog",
.firmware_version = 1,
- .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+ .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
+ WDIOF_MAGICCLOSE,
};
int value;
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c
index ae3832110acb..00b03eb43bf0 100644
--- a/drivers/watchdog/ks8695_wdt.c
+++ b/drivers/watchdog/ks8695_wdt.c
@@ -293,8 +293,8 @@ static int __init ks8695_wdt_init(void)
if not reset to the default */
if (ks8695_wdt_settimeout(wdt_time)) {
ks8695_wdt_settimeout(WDT_DEFAULT_TIME);
- pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i, using %d\n",
- wdt_time, WDT_MAX_TIME);
+ pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i"
+ ", using %d\n", wdt_time, WDT_MAX_TIME);
}
return platform_driver_register(&ks8695wdt_driver);
}
diff --git a/drivers/watchdog/machzwd.c b/drivers/watchdog/machzwd.c
index 2dfc27559bf7..b6b3f59ab446 100644
--- a/drivers/watchdog/machzwd.c
+++ b/drivers/watchdog/machzwd.c
@@ -118,7 +118,8 @@ static struct watchdog_info zf_info = {
*/
static int action;
module_param(action, int, 0);
-MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI");
+MODULE_PARM_DESC(action, "after watchdog resets, generate: "
+ "0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI");
static void zf_ping(unsigned long data);
@@ -142,7 +143,8 @@ static unsigned long next_heartbeat;
#ifndef ZF_DEBUG
# define dprintk(format, args...)
#else
-# define dprintk(format, args...) printk(KERN_DEBUG PFX ":%s:%d: " format, __func__, __LINE__ , ## args)
+# define dprintk(format, args...) printk(KERN_DEBUG PFX
+ ":%s:%d: " format, __func__, __LINE__ , ## args)
#endif
@@ -340,7 +342,8 @@ static int zf_close(struct inode *inode, struct file *file)
zf_timer_off();
else {
del_timer(&zf_timer);
- printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
+ printk(KERN_ERR PFX ": device file closed unexpectedly. "
+ "Will not stop the WDT!\n");
}
clear_bit(0, &zf_is_open);
zf_expect_close = 0;
diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c
index 1512ab8b175b..83fa34b214b4 100644
--- a/drivers/watchdog/mpcore_wdt.c
+++ b/drivers/watchdog/mpcore_wdt.c
@@ -61,7 +61,9 @@ MODULE_PARM_DESC(nowayout,
#define ONLY_TESTING 0
static int mpcore_noboot = ONLY_TESTING;
module_param(mpcore_noboot, int, 0);
-MODULE_PARM_DESC(mpcore_noboot, "MPcore watchdog action, set to 1 to ignore reboots, 0 to reboot (default=" __MODULE_STRING(ONLY_TESTING) ")");
+MODULE_PARM_DESC(mpcore_noboot, "MPcore watchdog action, "
+ "set to 1 to ignore reboots, 0 to reboot (default="
+ __MODULE_STRING(ONLY_TESTING) ")");
/*
* This is the interrupt handler. Note that we only use this
@@ -416,7 +418,8 @@ static struct platform_driver mpcore_wdt_driver = {
},
};
-static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n";
+static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. "
+ "mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n";
static int __init mpcore_wdt_init(void)
{
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 539b6f6ba7f1..08e8a6ab74e1 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -206,7 +206,7 @@ static struct miscdevice mtx1_wdt_misc = {
};
-static int mtx1_wdt_probe(struct platform_device *pdev)
+static int __devinit mtx1_wdt_probe(struct platform_device *pdev)
{
int ret;
@@ -229,7 +229,7 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
return 0;
}
-static int mtx1_wdt_remove(struct platform_device *pdev)
+static int __devexit mtx1_wdt_remove(struct platform_device *pdev)
{
/* FIXME: do we need to lock this test ? */
if (mtx1_wdt_device.queue) {
@@ -242,7 +242,7 @@ static int mtx1_wdt_remove(struct platform_device *pdev)
static struct platform_driver mtx1_wdt = {
.probe = mtx1_wdt_probe,
- .remove = mtx1_wdt_remove,
+ .remove = __devexit_p(mtx1_wdt_remove),
.driver.name = "mtx1-wdt",
.driver.owner = THIS_MODULE,
};
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 64135195f827..f24d04132eda 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -246,7 +246,7 @@ static struct miscdevice pnx4008_wdt_miscdev = {
.fops = &pnx4008_wdt_fops,
};
-static int pnx4008_wdt_probe(struct platform_device *pdev)
+static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
{
int ret = 0, size;
struct resource *res;
@@ -299,7 +299,7 @@ out:
return ret;
}
-static int pnx4008_wdt_remove(struct platform_device *pdev)
+static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
{
misc_deregister(&pnx4008_wdt_miscdev);
if (wdt_clk) {
@@ -321,7 +321,7 @@ static struct platform_driver platform_wdt_driver = {
.owner = THIS_MODULE,
},
.probe = pnx4008_wdt_probe,
- .remove = pnx4008_wdt_remove,
+ .remove = __devexit_p(pnx4008_wdt_remove),
};
static int __init pnx4008_wdt_init(void)
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c
index 36e221beedcd..4976bfd1fce6 100644
--- a/drivers/watchdog/rdc321x_wdt.c
+++ b/drivers/watchdog/rdc321x_wdt.c
@@ -245,7 +245,7 @@ static int __devinit rdc321x_wdt_probe(struct platform_device *pdev)
return 0;
}
-static int rdc321x_wdt_remove(struct platform_device *pdev)
+static int __devexit rdc321x_wdt_remove(struct platform_device *pdev)
{
if (rdc321x_wdt_device.queue) {
rdc321x_wdt_device.queue = 0;
@@ -259,7 +259,7 @@ static int rdc321x_wdt_remove(struct platform_device *pdev)
static struct platform_driver rdc321x_wdt_driver = {
.probe = rdc321x_wdt_probe,
- .remove = rdc321x_wdt_remove,
+ .remove = __devexit_p(rdc321x_wdt_remove),
.driver = {
.owner = THIS_MODULE,
.name = "rdc321x-wdt",
diff --git a/drivers/watchdog/rm9k_wdt.c b/drivers/watchdog/rm9k_wdt.c
index cce1982a1b58..2e4442642262 100644
--- a/drivers/watchdog/rm9k_wdt.c
+++ b/drivers/watchdog/rm9k_wdt.c
@@ -345,8 +345,8 @@ static const struct resource *wdt_gpi_get_resource(struct platform_device *pdv,
return platform_get_resource_byname(pdv, type, buf);
}
-/* No hotplugging on the platform bus - use __init */
-static int __init wdt_gpi_probe(struct platform_device *pdv)
+/* No hotplugging on the platform bus - use __devinit */
+static int __devinit wdt_gpi_probe(struct platform_device *pdv)
{
int res;
const struct resource
@@ -373,7 +373,7 @@ static int __init wdt_gpi_probe(struct platform_device *pdv)
return res;
}
-static int __exit wdt_gpi_remove(struct platform_device *dev)
+static int __devexit wdt_gpi_remove(struct platform_device *dev)
{
int res;
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index e31925ee8346..b57ac6b49147 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -68,15 +68,10 @@ MODULE_PARM_DESC(tmr_atboot,
__MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT));
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
-MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)");
+MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, "
+ "0 to reboot (default depends on ONLY_TESTING)");
MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)");
-
-typedef enum close_state {
- CLOSE_STATE_NOT,
- CLOSE_STATE_ALLOW = 0x4021
-} close_state_t;
-
static unsigned long open_lock;
static struct device *wdt_dev; /* platform device attached to */
static struct resource *wdt_mem;
@@ -84,7 +79,7 @@ static struct resource *wdt_irq;
static struct clk *wdt_clock;
static void __iomem *wdt_base;
static unsigned int wdt_count;
-static close_state_t allow_close;
+static char expect_close;
static DEFINE_SPINLOCK(wdt_lock);
/* watchdog control routines */
@@ -211,7 +206,7 @@ static int s3c2410wdt_open(struct inode *inode, struct file *file)
if (nowayout)
__module_get(THIS_MODULE);
- allow_close = CLOSE_STATE_NOT;
+ expect_close = 0;
/* start the timer */
s3c2410wdt_start();
@@ -225,13 +220,13 @@ static int s3c2410wdt_release(struct inode *inode, struct file *file)
* Lock it in if it's a module and we set nowayout
*/
- if (allow_close == CLOSE_STATE_ALLOW)
+ if (expect_close == 42)
s3c2410wdt_stop();
else {
dev_err(wdt_dev, "Unexpected close, not stopping watchdog\n");
s3c2410wdt_keepalive();
}
- allow_close = CLOSE_STATE_NOT;
+ expect_close = 0;
clear_bit(0, &open_lock);
return 0;
}
@@ -247,7 +242,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
size_t i;
/* In case it was set long ago */
- allow_close = CLOSE_STATE_NOT;
+ expect_close = 0;
for (i = 0; i != len; i++) {
char c;
@@ -255,7 +250,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
- allow_close = CLOSE_STATE_ALLOW;
+ expect_close = 42;
}
}
s3c2410wdt_keepalive();
@@ -263,7 +258,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
return len;
}
-#define OPTIONS WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE
+#define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE)
static const struct watchdog_info s3c2410_wdt_ident = {
.options = OPTIONS,
@@ -331,7 +326,7 @@ static irqreturn_t s3c2410wdt_irq(int irqno, void *param)
}
/* device interface */
-static int s3c2410wdt_probe(struct platform_device *pdev)
+static int __devinit s3c2410wdt_probe(struct platform_device *pdev)
{
struct resource *res;
struct device *dev;
@@ -404,7 +399,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
"tmr_margin value out of range, default %d used\n",
CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
else
- dev_info(dev, "default timer value is out of range, cannot start\n");
+ dev_info(dev, "default timer value is out of range, "
+ "cannot start\n");
}
ret = misc_register(&s3c2410wdt_miscdev);
@@ -453,7 +449,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
return ret;
}
-static int s3c2410wdt_remove(struct platform_device *dev)
+static int __devexit s3c2410wdt_remove(struct platform_device *dev)
{
release_resource(wdt_mem);
kfree(wdt_mem);
@@ -515,7 +511,7 @@ static int s3c2410wdt_resume(struct platform_device *dev)
static struct platform_driver s3c2410wdt_driver = {
.probe = s3c2410wdt_probe,
- .remove = s3c2410wdt_remove,
+ .remove = __devexit_p(s3c2410wdt_remove),
.shutdown = s3c2410wdt_shutdown,
.suspend = s3c2410wdt_suspend,
.resume = s3c2410wdt_resume,
diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c
index 38f5831c9291..9748eed73196 100644
--- a/drivers/watchdog/sb_wdog.c
+++ b/drivers/watchdog/sb_wdog.c
@@ -93,7 +93,7 @@ static int expect_close;
static const struct watchdog_info ident = {
.options = WDIOF_CARDRESET | WDIOF_SETTIMEOUT |
- WDIOF_KEEPALIVEPING,
+ WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.identity = "SiByte Watchdog",
};
@@ -269,9 +269,10 @@ irqreturn_t sbwdog_interrupt(int irq, void *addr)
* if it's the second watchdog timer, it's for those users
*/
if (wd_cfg_reg == user_dog)
- printk(KERN_CRIT
- "%s in danger of initiating system reset in %ld.%01ld seconds\n",
- ident.identity, wd_init / 1000000, (wd_init / 100000) % 10);
+ printk(KERN_CRIT "%s in danger of initiating system reset "
+ "in %ld.%01ld seconds\n",
+ ident.identity,
+ wd_init / 1000000, (wd_init / 100000) % 10);
else
cfg |= 1;
diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c
index d1c390c7155c..626d0e8e56c3 100644
--- a/drivers/watchdog/sbc60xxwdt.c
+++ b/drivers/watchdog/sbc60xxwdt.c
@@ -372,8 +372,9 @@ static int __init sbc60xxwdt_init(void)
wdt_miscdev.minor, rc);
goto err_out_reboot;
}
- printk(KERN_INFO PFX "WDT driver for 60XX single board computer initialised. timeout=%d sec (nowayout=%d)\n",
- timeout, nowayout);
+ printk(KERN_INFO PFX
+ "WDT driver for 60XX single board computer initialised. "
+ "timeout=%d sec (nowayout=%d)\n", timeout, nowayout);
return 0;
diff --git a/drivers/watchdog/sbc8360.c b/drivers/watchdog/sbc8360.c
index b6e6799ec45d..68e2e2d6f73d 100644
--- a/drivers/watchdog/sbc8360.c
+++ b/drivers/watchdog/sbc8360.c
@@ -280,8 +280,8 @@ static int sbc8360_close(struct inode *inode, struct file *file)
if (expect_close == 42)
sbc8360_stop();
else
- printk(KERN_CRIT PFX
- "SBC8360 device closed unexpectedly. SBC8360 will not stop!\n");
+ printk(KERN_CRIT PFX "SBC8360 device closed unexpectedly. "
+ "SBC8360 will not stop!\n");
clear_bit(0, &sbc8360_is_open);
expect_close = 0;
diff --git a/drivers/watchdog/sbc_epx_c3.c b/drivers/watchdog/sbc_epx_c3.c
index e467ddcf796a..28f1214457bd 100644
--- a/drivers/watchdog/sbc_epx_c3.c
+++ b/drivers/watchdog/sbc_epx_c3.c
@@ -107,8 +107,7 @@ static long epx_c3_ioctl(struct file *file, unsigned int cmd,
int options, retval = -EINVAL;
int __user *argp = (void __user *)arg;
static const struct watchdog_info ident = {
- .options = WDIOF_KEEPALIVEPING |
- WDIOF_MAGICCLOSE,
+ .options = WDIOF_KEEPALIVEPING,
.firmware_version = 0,
.identity = "Winsystems EPX-C3 H/W Watchdog",
};
@@ -174,8 +173,8 @@ static struct notifier_block epx_c3_notifier = {
.notifier_call = epx_c3_notify_sys,
};
-static const char banner[] __initdata =
- KERN_INFO PFX "Hardware Watchdog Timer for Winsystems EPX-C3 SBC: 0.1\n";
+static const char banner[] __initdata = KERN_INFO PFX
+ "Hardware Watchdog Timer for Winsystems EPX-C3 SBC: 0.1\n";
static int __init watchdog_init(void)
{
@@ -219,6 +218,9 @@ module_init(watchdog_init);
module_exit(watchdog_exit);
MODULE_AUTHOR("Calin A. Culianu <calin@ajvar.org>");
-MODULE_DESCRIPTION("Hardware Watchdog Device for Winsystems EPX-C3 SBC. Note that there is no way to probe for this device -- so only use it if you are *sure* you are runnning on this specific SBC system from Winsystems! It writes to IO ports 0x1ee and 0x1ef!");
+MODULE_DESCRIPTION("Hardware Watchdog Device for Winsystems EPX-C3 SBC. "
+ "Note that there is no way to probe for this device -- "
+ "so only use it if you are *sure* you are runnning on this specific "
+ "SBC system from Winsystems! It writes to IO ports 0x1ee and 0x1ef!");
MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/watchdog/scx200_wdt.c b/drivers/watchdog/scx200_wdt.c
index 9e19a10a5bb9..e67b76c0526c 100644
--- a/drivers/watchdog/scx200_wdt.c
+++ b/drivers/watchdog/scx200_wdt.c
@@ -108,7 +108,9 @@ static int scx200_wdt_open(struct inode *inode, struct file *file)
static int scx200_wdt_release(struct inode *inode, struct file *file)
{
if (expect_close != 42)
- printk(KERN_WARNING NAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n");
+ printk(KERN_WARNING NAME
+ ": watchdog device closed unexpectedly, "
+ "will not disable the watchdog timer\n");
else if (!nowayout)
scx200_wdt_disable();
expect_close = 0;
@@ -163,7 +165,8 @@ static long scx200_wdt_ioctl(struct file *file, unsigned int cmd,
static const struct watchdog_info ident = {
.identity = "NatSemi SCx200 Watchdog",
.firmware_version = 1,
- .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+ .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
+ WDIOF_MAGICCLOSE,
};
int new_margin;
diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c
index cdc7138be301..a03f84e5ee1f 100644
--- a/drivers/watchdog/shwdt.c
+++ b/drivers/watchdog/shwdt.c
@@ -494,7 +494,9 @@ MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
module_param(clock_division_ratio, int, 0);
-MODULE_PARM_DESC(clock_division_ratio, "Clock division ratio. Valid ranges are from 0x5 (1.31ms) to 0x7 (5.25ms). (default=" __MODULE_STRING(clock_division_ratio) ")");
+MODULE_PARM_DESC(clock_division_ratio,
+ "Clock division ratio. Valid ranges are from 0x5 (1.31ms) "
+ "to 0x7 (5.25ms). (default=" __MODULE_STRING(clock_division_ratio) ")");
module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat,
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index ebcc9cea5e99..833f49f43d43 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -71,7 +71,9 @@ static int soft_noboot = 0;
#endif /* ONLY_TESTING */
module_param(soft_noboot, int, 0);
-MODULE_PARM_DESC(soft_noboot, "Softdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)");
+MODULE_PARM_DESC(soft_noboot,
+ "Softdog action, set to 1 to ignore reboots, 0 to reboot "
+ "(default depends on ONLY_TESTING)");
/*
* Our timer
@@ -264,7 +266,8 @@ static struct notifier_block softdog_notifier = {
.notifier_call = softdog_notify_sys,
};
-static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.07 initialized. soft_noboot=%d soft_margin=%d sec (nowayout= %d)\n";
+static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.07 "
+ "initialized. soft_noboot=%d soft_margin=%d sec (nowayout= %d)\n";
static int __init watchdog_init(void)
{
diff --git a/drivers/watchdog/w83697hf_wdt.c b/drivers/watchdog/w83697hf_wdt.c
index a9c7f352fcbf..af08972de506 100644
--- a/drivers/watchdog/w83697hf_wdt.c
+++ b/drivers/watchdog/w83697hf_wdt.c
@@ -413,7 +413,8 @@ static int __init wdt_init(void)
w83697hf_init();
if (early_disable) {
if (wdt_running())
- printk(KERN_WARNING PFX "Stopping previously enabled watchdog until userland kicks in\n");
+ printk(KERN_WARNING PFX "Stopping previously enabled "
+ "watchdog until userland kicks in\n");
wdt_disable();
}
diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c
index a38fa4907c92..a4fe7a38d9b0 100644
--- a/drivers/watchdog/wdrtas.c
+++ b/drivers/watchdog/wdrtas.c
@@ -49,12 +49,7 @@ MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
MODULE_ALIAS_MISCDEV(TEMP_MINOR);
-#ifdef CONFIG_WATCHDOG_NOWAYOUT
-static int wdrtas_nowayout = 1;
-#else
-static int wdrtas_nowayout = 0;
-#endif
-
+static int wdrtas_nowayout = WATCHDOG_NOWAYOUT;
static atomic_t wdrtas_miscdev_open = ATOMIC_INIT(0);
static char wdrtas_expect_close;
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 8ac9cddac575..cab100acf983 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -18,6 +18,16 @@ config XEN_SCRUB_PAGES
secure, but slightly less efficient.
If in doubt, say yes.
+config XEN_DEV_EVTCHN
+ tristate "Xen /dev/xen/evtchn device"
+ depends on XEN
+ default y
+ help
+ The evtchn driver allows a userspace process to triger event
+ channels and to receive notification of an event channel
+ firing.
+ If in doubt, say yes.
+
config XENFS
tristate "Xen filesystem"
depends on XEN
@@ -41,3 +51,13 @@ config XEN_COMPAT_XENFS
a xen platform.
If in doubt, say yes.
+config XEN_SYS_HYPERVISOR
+ bool "Create xen entries under /sys/hypervisor"
+ depends on XEN && SYSFS
+ select SYS_HYPERVISOR
+ default y
+ help
+ Create entries under /sys/hypervisor describing the Xen
+ hypervisor environment. When running native or in another
+ virtual environment, /sys/hypervisor will still be present,
+ but will have no xen contents. \ No newline at end of file
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index ff8accc9e103..ec2a39b1e26f 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -4,4 +4,6 @@ obj-y += xenbus/
obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
obj-$(CONFIG_XEN_BALLOON) += balloon.o
-obj-$(CONFIG_XENFS) += xenfs/ \ No newline at end of file
+obj-$(CONFIG_XEN_DEV_EVTCHN) += evtchn.o
+obj-$(CONFIG_XENFS) += xenfs/
+obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o \ No newline at end of file
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 30963af5dba0..891d2e90753a 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -151,6 +151,12 @@ static unsigned int evtchn_from_irq(unsigned irq)
return info_for_irq(irq)->evtchn;
}
+unsigned irq_from_evtchn(unsigned int evtchn)
+{
+ return evtchn_to_irq[evtchn];
+}
+EXPORT_SYMBOL_GPL(irq_from_evtchn);
+
static enum ipi_vector ipi_from_irq(unsigned irq)
{
struct irq_info *info = info_for_irq(irq);
@@ -335,7 +341,7 @@ static int find_unbound_irq(void)
if (irq == nr_irqs)
panic("No available IRQ to bind to: increase nr_irqs!\n");
- desc = irq_to_desc_alloc_cpu(irq, 0);
+ desc = irq_to_desc_alloc_node(irq, 0);
if (WARN_ON(desc == NULL))
return -1;
@@ -688,13 +694,13 @@ void rebind_evtchn_irq(int evtchn, int irq)
}
/* Rebind an evtchn so that it gets delivered to a specific cpu */
-static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
+static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
{
struct evtchn_bind_vcpu bind_vcpu;
int evtchn = evtchn_from_irq(irq);
if (!VALID_EVTCHN(evtchn))
- return;
+ return -1;
/* Send future instances of this interrupt to other vcpu. */
bind_vcpu.port = evtchn;
@@ -707,13 +713,15 @@ static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
*/
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
bind_evtchn_to_cpu(evtchn, tcpu);
-}
+ return 0;
+}
-static void set_affinity_irq(unsigned irq, const struct cpumask *dest)
+static int set_affinity_irq(unsigned irq, const struct cpumask *dest)
{
unsigned tcpu = cpumask_first(dest);
- rebind_irq_to_cpu(irq, tcpu);
+
+ return rebind_irq_to_cpu(irq, tcpu);
}
int resend_irq_on_evtchn(unsigned int irq)
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
new file mode 100644
index 000000000000..af031950f9b1
--- /dev/null
+++ b/drivers/xen/evtchn.c
@@ -0,0 +1,507 @@
+/******************************************************************************
+ * evtchn.c
+ *
+ * Driver for receiving and demuxing event-channel signals.
+ *
+ * Copyright (c) 2004-2005, K A Fraser
+ * Multi-process extensions Copyright (c) 2004, Steven Smith
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/errno.h>
+#include <linux/miscdevice.h>
+#include <linux/major.h>
+#include <linux/proc_fs.h>
+#include <linux/stat.h>
+#include <linux/poll.h>
+#include <linux/irq.h>
+#include <linux/init.h>
+#include <linux/gfp.h>
+#include <linux/mutex.h>
+#include <linux/cpu.h>
+#include <xen/events.h>
+#include <xen/evtchn.h>
+#include <asm/xen/hypervisor.h>
+
+struct per_user_data {
+ struct mutex bind_mutex; /* serialize bind/unbind operations */
+
+ /* Notification ring, accessed via /dev/xen/evtchn. */
+#define EVTCHN_RING_SIZE (PAGE_SIZE / sizeof(evtchn_port_t))
+#define EVTCHN_RING_MASK(_i) ((_i)&(EVTCHN_RING_SIZE-1))
+ evtchn_port_t *ring;
+ unsigned int ring_cons, ring_prod, ring_overflow;
+ struct mutex ring_cons_mutex; /* protect against concurrent readers */
+
+ /* Processes wait on this queue when ring is empty. */
+ wait_queue_head_t evtchn_wait;
+ struct fasync_struct *evtchn_async_queue;
+ const char *name;
+};
+
+/* Who's bound to each port? */
+static struct per_user_data *port_user[NR_EVENT_CHANNELS];
+static DEFINE_SPINLOCK(port_user_lock); /* protects port_user[] and ring_prod */
+
+irqreturn_t evtchn_interrupt(int irq, void *data)
+{
+ unsigned int port = (unsigned long)data;
+ struct per_user_data *u;
+
+ spin_lock(&port_user_lock);
+
+ u = port_user[port];
+
+ disable_irq_nosync(irq);
+
+ if ((u->ring_prod - u->ring_cons) < EVTCHN_RING_SIZE) {
+ u->ring[EVTCHN_RING_MASK(u->ring_prod)] = port;
+ wmb(); /* Ensure ring contents visible */
+ if (u->ring_cons == u->ring_prod++) {
+ wake_up_interruptible(&u->evtchn_wait);
+ kill_fasync(&u->evtchn_async_queue,
+ SIGIO, POLL_IN);
+ }
+ } else {
+ u->ring_overflow = 1;
+ }
+
+ spin_unlock(&port_user_lock);
+
+ return IRQ_HANDLED;
+}
+
+static ssize_t evtchn_read(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ int rc;
+ unsigned int c, p, bytes1 = 0, bytes2 = 0;
+ struct per_user_data *u = file->private_data;
+
+ /* Whole number of ports. */
+ count &= ~(sizeof(evtchn_port_t)-1);
+
+ if (count == 0)
+ return 0;
+
+ if (count > PAGE_SIZE)
+ count = PAGE_SIZE;
+
+ for (;;) {
+ mutex_lock(&u->ring_cons_mutex);
+
+ rc = -EFBIG;
+ if (u->ring_overflow)
+ goto unlock_out;
+
+ c = u->ring_cons;
+ p = u->ring_prod;
+ if (c != p)
+ break;
+
+ mutex_unlock(&u->ring_cons_mutex);
+
+ if (file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ rc = wait_event_interruptible(u->evtchn_wait,
+ u->ring_cons != u->ring_prod);
+ if (rc)
+ return rc;
+ }
+
+ /* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */
+ if (((c ^ p) & EVTCHN_RING_SIZE) != 0) {
+ bytes1 = (EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c)) *
+ sizeof(evtchn_port_t);
+ bytes2 = EVTCHN_RING_MASK(p) * sizeof(evtchn_port_t);
+ } else {
+ bytes1 = (p - c) * sizeof(evtchn_port_t);
+ bytes2 = 0;
+ }
+
+ /* Truncate chunks according to caller's maximum byte count. */
+ if (bytes1 > count) {
+ bytes1 = count;
+ bytes2 = 0;
+ } else if ((bytes1 + bytes2) > count) {
+ bytes2 = count - bytes1;
+ }
+
+ rc = -EFAULT;
+ rmb(); /* Ensure that we see the port before we copy it. */
+ if (copy_to_user(buf, &u->ring[EVTCHN_RING_MASK(c)], bytes1) ||
+ ((bytes2 != 0) &&
+ copy_to_user(&buf[bytes1], &u->ring[0], bytes2)))
+ goto unlock_out;
+
+ u->ring_cons += (bytes1 + bytes2) / sizeof(evtchn_port_t);
+ rc = bytes1 + bytes2;
+
+ unlock_out:
+ mutex_unlock(&u->ring_cons_mutex);
+ return rc;
+}
+
+static ssize_t evtchn_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ int rc, i;
+ evtchn_port_t *kbuf = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
+ struct per_user_data *u = file->private_data;
+
+ if (kbuf == NULL)
+ return -ENOMEM;
+
+ /* Whole number of ports. */
+ count &= ~(sizeof(evtchn_port_t)-1);
+
+ rc = 0;
+ if (count == 0)
+ goto out;
+
+ if (count > PAGE_SIZE)
+ count = PAGE_SIZE;
+
+ rc = -EFAULT;
+ if (copy_from_user(kbuf, buf, count) != 0)
+ goto out;
+
+ spin_lock_irq(&port_user_lock);
+ for (i = 0; i < (count/sizeof(evtchn_port_t)); i++)
+ if ((kbuf[i] < NR_EVENT_CHANNELS) && (port_user[kbuf[i]] == u))
+ enable_irq(irq_from_evtchn(kbuf[i]));
+ spin_unlock_irq(&port_user_lock);
+
+ rc = count;
+
+ out:
+ free_page((unsigned long)kbuf);
+ return rc;
+}
+
+static int evtchn_bind_to_user(struct per_user_data *u, int port)
+{
+ int rc = 0;
+
+ /*
+ * Ports are never reused, so every caller should pass in a
+ * unique port.
+ *
+ * (Locking not necessary because we haven't registered the
+ * interrupt handler yet, and our caller has already
+ * serialized bind operations.)
+ */
+ BUG_ON(port_user[port] != NULL);
+ port_user[port] = u;
+
+ rc = bind_evtchn_to_irqhandler(port, evtchn_interrupt, IRQF_DISABLED,
+ u->name, (void *)(unsigned long)port);
+ if (rc >= 0)
+ rc = 0;
+
+ return rc;
+}
+
+static void evtchn_unbind_from_user(struct per_user_data *u, int port)
+{
+ int irq = irq_from_evtchn(port);
+
+ unbind_from_irqhandler(irq, (void *)(unsigned long)port);
+
+ /* make sure we unbind the irq handler before clearing the port */
+ barrier();
+
+ port_user[port] = NULL;
+}
+
+static long evtchn_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ int rc;
+ struct per_user_data *u = file->private_data;
+ void __user *uarg = (void __user *) arg;
+
+ /* Prevent bind from racing with unbind */
+ mutex_lock(&u->bind_mutex);
+
+ switch (cmd) {
+ case IOCTL_EVTCHN_BIND_VIRQ: {
+ struct ioctl_evtchn_bind_virq bind;
+ struct evtchn_bind_virq bind_virq;
+
+ rc = -EFAULT;
+ if (copy_from_user(&bind, uarg, sizeof(bind)))
+ break;
+
+ bind_virq.virq = bind.virq;
+ bind_virq.vcpu = 0;
+ rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
+ &bind_virq);
+ if (rc != 0)
+ break;
+
+ rc = evtchn_bind_to_user(u, bind_virq.port);
+ if (rc == 0)
+ rc = bind_virq.port;
+ break;
+ }
+
+ case IOCTL_EVTCHN_BIND_INTERDOMAIN: {
+ struct ioctl_evtchn_bind_interdomain bind;
+ struct evtchn_bind_interdomain bind_interdomain;
+
+ rc = -EFAULT;
+ if (copy_from_user(&bind, uarg, sizeof(bind)))
+ break;
+
+ bind_interdomain.remote_dom = bind.remote_domain;
+ bind_interdomain.remote_port = bind.remote_port;
+ rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
+ &bind_interdomain);
+ if (rc != 0)
+ break;
+
+ rc = evtchn_bind_to_user(u, bind_interdomain.local_port);
+ if (rc == 0)
+ rc = bind_interdomain.local_port;
+ break;
+ }
+
+ case IOCTL_EVTCHN_BIND_UNBOUND_PORT: {
+ struct ioctl_evtchn_bind_unbound_port bind;
+ struct evtchn_alloc_unbound alloc_unbound;
+
+ rc = -EFAULT;
+ if (copy_from_user(&bind, uarg, sizeof(bind)))
+ break;
+
+ alloc_unbound.dom = DOMID_SELF;
+ alloc_unbound.remote_dom = bind.remote_domain;
+ rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
+ &alloc_unbound);
+ if (rc != 0)
+ break;
+
+ rc = evtchn_bind_to_user(u, alloc_unbound.port);
+ if (rc == 0)
+ rc = alloc_unbound.port;
+ break;
+ }
+
+ case IOCTL_EVTCHN_UNBIND: {
+ struct ioctl_evtchn_unbind unbind;
+
+ rc = -EFAULT;
+ if (copy_from_user(&unbind, uarg, sizeof(unbind)))
+ break;
+
+ rc = -EINVAL;
+ if (unbind.port >= NR_EVENT_CHANNELS)
+ break;
+
+ spin_lock_irq(&port_user_lock);
+
+ rc = -ENOTCONN;
+ if (port_user[unbind.port] != u) {
+ spin_unlock_irq(&port_user_lock);
+ break;
+ }
+
+ evtchn_unbind_from_user(u, unbind.port);
+
+ spin_unlock_irq(&port_user_lock);
+
+ rc = 0;
+ break;
+ }
+
+ case IOCTL_EVTCHN_NOTIFY: {
+ struct ioctl_evtchn_notify notify;
+
+ rc = -EFAULT;
+ if (copy_from_user(&notify, uarg, sizeof(notify)))
+ break;
+
+ if (notify.port >= NR_EVENT_CHANNELS) {
+ rc = -EINVAL;
+ } else if (port_user[notify.port] != u) {
+ rc = -ENOTCONN;
+ } else {
+ notify_remote_via_evtchn(notify.port);
+ rc = 0;
+ }
+ break;
+ }
+
+ case IOCTL_EVTCHN_RESET: {
+ /* Initialise the ring to empty. Clear errors. */
+ mutex_lock(&u->ring_cons_mutex);
+ spin_lock_irq(&port_user_lock);
+ u->ring_cons = u->ring_prod = u->ring_overflow = 0;
+ spin_unlock_irq(&port_user_lock);
+ mutex_unlock(&u->ring_cons_mutex);
+ rc = 0;
+ break;
+ }
+
+ default:
+ rc = -ENOSYS;
+ break;
+ }
+ mutex_unlock(&u->bind_mutex);
+
+ return rc;
+}
+
+static unsigned int evtchn_poll(struct file *file, poll_table *wait)
+{
+ unsigned int mask = POLLOUT | POLLWRNORM;
+ struct per_user_data *u = file->private_data;
+
+ poll_wait(file, &u->evtchn_wait, wait);
+ if (u->ring_cons != u->ring_prod)
+ mask |= POLLIN | POLLRDNORM;
+ if (u->ring_overflow)
+ mask = POLLERR;
+ return mask;
+}
+
+static int evtchn_fasync(int fd, struct file *filp, int on)
+{
+ struct per_user_data *u = filp->private_data;
+ return fasync_helper(fd, filp, on, &u->evtchn_async_queue);
+}
+
+static int evtchn_open(struct inode *inode, struct file *filp)
+{
+ struct per_user_data *u;
+
+ u = kzalloc(sizeof(*u), GFP_KERNEL);
+ if (u == NULL)
+ return -ENOMEM;
+
+ u->name = kasprintf(GFP_KERNEL, "evtchn:%s", current->comm);
+ if (u->name == NULL) {
+ kfree(u);
+ return -ENOMEM;
+ }
+
+ init_waitqueue_head(&u->evtchn_wait);
+
+ u->ring = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
+ if (u->ring == NULL) {
+ kfree(u->name);
+ kfree(u);
+ return -ENOMEM;
+ }
+
+ mutex_init(&u->bind_mutex);
+ mutex_init(&u->ring_cons_mutex);
+
+ filp->private_data = u;
+
+ return 0;
+}
+
+static int evtchn_release(struct inode *inode, struct file *filp)
+{
+ int i;
+ struct per_user_data *u = filp->private_data;
+
+ spin_lock_irq(&port_user_lock);
+
+ free_page((unsigned long)u->ring);
+
+ for (i = 0; i < NR_EVENT_CHANNELS; i++) {
+ if (port_user[i] != u)
+ continue;
+
+ evtchn_unbind_from_user(port_user[i], i);
+ }
+
+ spin_unlock_irq(&port_user_lock);
+
+ kfree(u->name);
+ kfree(u);
+
+ return 0;
+}
+
+static const struct file_operations evtchn_fops = {
+ .owner = THIS_MODULE,
+ .read = evtchn_read,
+ .write = evtchn_write,
+ .unlocked_ioctl = evtchn_ioctl,
+ .poll = evtchn_poll,
+ .fasync = evtchn_fasync,
+ .open = evtchn_open,
+ .release = evtchn_release,
+};
+
+static struct miscdevice evtchn_miscdev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "evtchn",
+ .fops = &evtchn_fops,
+};
+static int __init evtchn_init(void)
+{
+ int err;
+
+ if (!xen_domain())
+ return -ENODEV;
+
+ spin_lock_init(&port_user_lock);
+ memset(port_user, 0, sizeof(port_user));
+
+ /* Create '/dev/misc/evtchn'. */
+ err = misc_register(&evtchn_miscdev);
+ if (err != 0) {
+ printk(KERN_ALERT "Could not register /dev/misc/evtchn\n");
+ return err;
+ }
+
+ printk(KERN_INFO "Event-channel device installed.\n");
+
+ return 0;
+}
+
+static void __exit evtchn_cleanup(void)
+{
+ misc_deregister(&evtchn_miscdev);
+}
+
+module_init(evtchn_init);
+module_exit(evtchn_cleanup);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 4b5b84837ee1..10d03d7931c4 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -43,7 +43,7 @@ static int xen_suspend(void *data)
if (err) {
printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
err);
- device_power_up(PMSG_RESUME);
+ dpm_resume_noirq(PMSG_RESUME);
return err;
}
@@ -69,7 +69,7 @@ static int xen_suspend(void *data)
}
sysdev_resume();
- device_power_up(PMSG_RESUME);
+ dpm_resume_noirq(PMSG_RESUME);
return 0;
}
@@ -92,19 +92,18 @@ static void do_suspend(void)
}
#endif
- err = device_suspend(PMSG_SUSPEND);
+ err = dpm_suspend_start(PMSG_SUSPEND);
if (err) {
- printk(KERN_ERR "xen suspend: device_suspend %d\n", err);
+ printk(KERN_ERR "xen suspend: dpm_suspend_start %d\n", err);
goto out;
}
- printk("suspending xenbus...\n");
- /* XXX use normal device tree? */
- xenbus_suspend();
+ printk(KERN_DEBUG "suspending xenstore...\n");
+ xs_suspend();
- err = device_power_down(PMSG_SUSPEND);
+ err = dpm_suspend_noirq(PMSG_SUSPEND);
if (err) {
- printk(KERN_ERR "device_power_down failed: %d\n", err);
+ printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
goto resume_devices;
}
@@ -116,14 +115,14 @@ static void do_suspend(void)
if (!cancelled) {
xen_arch_resume();
- xenbus_resume();
+ xs_resume();
} else
- xenbus_suspend_cancel();
+ xs_suspend_cancel();
- device_power_up(PMSG_RESUME);
+ dpm_resume_noirq(PMSG_RESUME);
resume_devices:
- device_resume(PMSG_RESUME);
+ dpm_resume_end(PMSG_RESUME);
/* Make sure timer events get retriggered on all CPUs */
clock_was_set();
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
new file mode 100644
index 000000000000..88a60e03ccf0
--- /dev/null
+++ b/drivers/xen/sys-hypervisor.c
@@ -0,0 +1,445 @@
+/*
+ * copyright (c) 2006 IBM Corporation
+ * Authored by: Mike D. Day <ncmike@us.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/kobject.h>
+
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+#include <xen/xenbus.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/version.h>
+
+#define HYPERVISOR_ATTR_RO(_name) \
+static struct hyp_sysfs_attr _name##_attr = __ATTR_RO(_name)
+
+#define HYPERVISOR_ATTR_RW(_name) \
+static struct hyp_sysfs_attr _name##_attr = \
+ __ATTR(_name, 0644, _name##_show, _name##_store)
+
+struct hyp_sysfs_attr {
+ struct attribute attr;
+ ssize_t (*show)(struct hyp_sysfs_attr *, char *);
+ ssize_t (*store)(struct hyp_sysfs_attr *, const char *, size_t);
+ void *hyp_attr_data;
+};
+
+static ssize_t type_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ return sprintf(buffer, "xen\n");
+}
+
+HYPERVISOR_ATTR_RO(type);
+
+static int __init xen_sysfs_type_init(void)
+{
+ return sysfs_create_file(hypervisor_kobj, &type_attr.attr);
+}
+
+static void xen_sysfs_type_destroy(void)
+{
+ sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
+}
+
+/* xen version attributes */
+static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int version = HYPERVISOR_xen_version(XENVER_version, NULL);
+ if (version)
+ return sprintf(buffer, "%d\n", version >> 16);
+ return -ENODEV;
+}
+
+HYPERVISOR_ATTR_RO(major);
+
+static ssize_t minor_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int version = HYPERVISOR_xen_version(XENVER_version, NULL);
+ if (version)
+ return sprintf(buffer, "%d\n", version & 0xff);
+ return -ENODEV;
+}
+
+HYPERVISOR_ATTR_RO(minor);
+
+static ssize_t extra_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ char *extra;
+
+ extra = kmalloc(XEN_EXTRAVERSION_LEN, GFP_KERNEL);
+ if (extra) {
+ ret = HYPERVISOR_xen_version(XENVER_extraversion, extra);
+ if (!ret)
+ ret = sprintf(buffer, "%s\n", extra);
+ kfree(extra);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(extra);
+
+static struct attribute *version_attrs[] = {
+ &major_attr.attr,
+ &minor_attr.attr,
+ &extra_attr.attr,
+ NULL
+};
+
+static struct attribute_group version_group = {
+ .name = "version",
+ .attrs = version_attrs,
+};
+
+static int __init xen_sysfs_version_init(void)
+{
+ return sysfs_create_group(hypervisor_kobj, &version_group);
+}
+
+static void xen_sysfs_version_destroy(void)
+{
+ sysfs_remove_group(hypervisor_kobj, &version_group);
+}
+
+/* UUID */
+
+static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ char *vm, *val;
+ int ret;
+ extern int xenstored_ready;
+
+ if (!xenstored_ready)
+ return -EBUSY;
+
+ vm = xenbus_read(XBT_NIL, "vm", "", NULL);
+ if (IS_ERR(vm))
+ return PTR_ERR(vm);
+ val = xenbus_read(XBT_NIL, vm, "uuid", NULL);
+ kfree(vm);
+ if (IS_ERR(val))
+ return PTR_ERR(val);
+ ret = sprintf(buffer, "%s\n", val);
+ kfree(val);
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(uuid);
+
+static int __init xen_sysfs_uuid_init(void)
+{
+ return sysfs_create_file(hypervisor_kobj, &uuid_attr.attr);
+}
+
+static void xen_sysfs_uuid_destroy(void)
+{
+ sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr);
+}
+
+/* xen compilation attributes */
+
+static ssize_t compiler_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ struct xen_compile_info *info;
+
+ info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
+ if (info) {
+ ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
+ if (!ret)
+ ret = sprintf(buffer, "%s\n", info->compiler);
+ kfree(info);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(compiler);
+
+static ssize_t compiled_by_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ struct xen_compile_info *info;
+
+ info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
+ if (info) {
+ ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
+ if (!ret)
+ ret = sprintf(buffer, "%s\n", info->compile_by);
+ kfree(info);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(compiled_by);
+
+static ssize_t compile_date_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ struct xen_compile_info *info;
+
+ info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
+ if (info) {
+ ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
+ if (!ret)
+ ret = sprintf(buffer, "%s\n", info->compile_date);
+ kfree(info);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(compile_date);
+
+static struct attribute *xen_compile_attrs[] = {
+ &compiler_attr.attr,
+ &compiled_by_attr.attr,
+ &compile_date_attr.attr,
+ NULL
+};
+
+static struct attribute_group xen_compilation_group = {
+ .name = "compilation",
+ .attrs = xen_compile_attrs,
+};
+
+int __init static xen_compilation_init(void)
+{
+ return sysfs_create_group(hypervisor_kobj, &xen_compilation_group);
+}
+
+static void xen_compilation_destroy(void)
+{
+ sysfs_remove_group(hypervisor_kobj, &xen_compilation_group);
+}
+
+/* xen properties info */
+
+static ssize_t capabilities_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ char *caps;
+
+ caps = kmalloc(XEN_CAPABILITIES_INFO_LEN, GFP_KERNEL);
+ if (caps) {
+ ret = HYPERVISOR_xen_version(XENVER_capabilities, caps);
+ if (!ret)
+ ret = sprintf(buffer, "%s\n", caps);
+ kfree(caps);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(capabilities);
+
+static ssize_t changeset_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ char *cset;
+
+ cset = kmalloc(XEN_CHANGESET_INFO_LEN, GFP_KERNEL);
+ if (cset) {
+ ret = HYPERVISOR_xen_version(XENVER_changeset, cset);
+ if (!ret)
+ ret = sprintf(buffer, "%s\n", cset);
+ kfree(cset);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(changeset);
+
+static ssize_t virtual_start_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret = -ENOMEM;
+ struct xen_platform_parameters *parms;
+
+ parms = kmalloc(sizeof(struct xen_platform_parameters), GFP_KERNEL);
+ if (parms) {
+ ret = HYPERVISOR_xen_version(XENVER_platform_parameters,
+ parms);
+ if (!ret)
+ ret = sprintf(buffer, "%lx\n", parms->virt_start);
+ kfree(parms);
+ }
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(virtual_start);
+
+static ssize_t pagesize_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ int ret;
+
+ ret = HYPERVISOR_xen_version(XENVER_pagesize, NULL);
+ if (ret > 0)
+ ret = sprintf(buffer, "%x\n", ret);
+
+ return ret;
+}
+
+HYPERVISOR_ATTR_RO(pagesize);
+
+static ssize_t xen_feature_show(int index, char *buffer)
+{
+ ssize_t ret;
+ struct xen_feature_info info;
+
+ info.submap_idx = index;
+ ret = HYPERVISOR_xen_version(XENVER_get_features, &info);
+ if (!ret)
+ ret = sprintf(buffer, "%08x", info.submap);
+
+ return ret;
+}
+
+static ssize_t features_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ ssize_t len;
+ int i;
+
+ len = 0;
+ for (i = XENFEAT_NR_SUBMAPS-1; i >= 0; i--) {
+ int ret = xen_feature_show(i, buffer + len);
+ if (ret < 0) {
+ if (len == 0)
+ len = ret;
+ break;
+ }
+ len += ret;
+ }
+ if (len > 0)
+ buffer[len++] = '\n';
+
+ return len;
+}
+
+HYPERVISOR_ATTR_RO(features);
+
+static struct attribute *xen_properties_attrs[] = {
+ &capabilities_attr.attr,
+ &changeset_attr.attr,
+ &virtual_start_attr.attr,
+ &pagesize_attr.attr,
+ &features_attr.attr,
+ NULL
+};
+
+static struct attribute_group xen_properties_group = {
+ .name = "properties",
+ .attrs = xen_properties_attrs,
+};
+
+static int __init xen_properties_init(void)
+{
+ return sysfs_create_group(hypervisor_kobj, &xen_properties_group);
+}
+
+static void xen_properties_destroy(void)
+{
+ sysfs_remove_group(hypervisor_kobj, &xen_properties_group);
+}
+
+static int __init hyper_sysfs_init(void)
+{
+ int ret;
+
+ if (!xen_domain())
+ return -ENODEV;
+
+ ret = xen_sysfs_type_init();
+ if (ret)
+ goto out;
+ ret = xen_sysfs_version_init();
+ if (ret)
+ goto version_out;
+ ret = xen_compilation_init();
+ if (ret)
+ goto comp_out;
+ ret = xen_sysfs_uuid_init();
+ if (ret)
+ goto uuid_out;
+ ret = xen_properties_init();
+ if (ret)
+ goto prop_out;
+
+ goto out;
+
+prop_out:
+ xen_sysfs_uuid_destroy();
+uuid_out:
+ xen_compilation_destroy();
+comp_out:
+ xen_sysfs_version_destroy();
+version_out:
+ xen_sysfs_type_destroy();
+out:
+ return ret;
+}
+
+static void __exit hyper_sysfs_exit(void)
+{
+ xen_properties_destroy();
+ xen_compilation_destroy();
+ xen_sysfs_uuid_destroy();
+ xen_sysfs_version_destroy();
+ xen_sysfs_type_destroy();
+
+}
+module_init(hyper_sysfs_init);
+module_exit(hyper_sysfs_exit);
+
+static ssize_t hyp_sysfs_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buffer)
+{
+ struct hyp_sysfs_attr *hyp_attr;
+ hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
+ if (hyp_attr->show)
+ return hyp_attr->show(hyp_attr, buffer);
+ return 0;
+}
+
+static ssize_t hyp_sysfs_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t len)
+{
+ struct hyp_sysfs_attr *hyp_attr;
+ hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
+ if (hyp_attr->store)
+ return hyp_attr->store(hyp_attr, buffer, len);
+ return 0;
+}
+
+static struct sysfs_ops hyp_sysfs_ops = {
+ .show = hyp_sysfs_show,
+ .store = hyp_sysfs_store,
+};
+
+static struct kobj_type hyp_sysfs_kobj_type = {
+ .sysfs_ops = &hyp_sysfs_ops,
+};
+
+static int __init hypervisor_subsys_init(void)
+{
+ if (!xen_domain())
+ return -ENODEV;
+
+ hypervisor_kobj->ktype = &hyp_sysfs_kobj_type;
+ return 0;
+}
+device_initcall(hypervisor_subsys_init);
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 773d1cf23283..d42e25d5968d 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -71,6 +71,9 @@ static int xenbus_probe_frontend(const char *type, const char *name);
static void xenbus_dev_shutdown(struct device *_dev);
+static int xenbus_dev_suspend(struct device *dev, pm_message_t state);
+static int xenbus_dev_resume(struct device *dev);
+
/* If something in array of ids matches this device, return it. */
static const struct xenbus_device_id *
match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
@@ -188,6 +191,9 @@ static struct xen_bus_type xenbus_frontend = {
.remove = xenbus_dev_remove,
.shutdown = xenbus_dev_shutdown,
.dev_attrs = xenbus_dev_attrs,
+
+ .suspend = xenbus_dev_suspend,
+ .resume = xenbus_dev_resume,
},
};
@@ -654,6 +660,7 @@ void xenbus_dev_changed(const char *node, struct xen_bus_type *bus)
kfree(root);
}
+EXPORT_SYMBOL_GPL(xenbus_dev_changed);
static void frontend_changed(struct xenbus_watch *watch,
const char **vec, unsigned int len)
@@ -669,7 +676,7 @@ static struct xenbus_watch fe_watch = {
.callback = frontend_changed,
};
-static int suspend_dev(struct device *dev, void *data)
+static int xenbus_dev_suspend(struct device *dev, pm_message_t state)
{
int err = 0;
struct xenbus_driver *drv;
@@ -682,35 +689,14 @@ static int suspend_dev(struct device *dev, void *data)
drv = to_xenbus_driver(dev->driver);
xdev = container_of(dev, struct xenbus_device, dev);
if (drv->suspend)
- err = drv->suspend(xdev);
+ err = drv->suspend(xdev, state);
if (err)
printk(KERN_WARNING
"xenbus: suspend %s failed: %i\n", dev_name(dev), err);
return 0;
}
-static int suspend_cancel_dev(struct device *dev, void *data)
-{
- int err = 0;
- struct xenbus_driver *drv;
- struct xenbus_device *xdev;
-
- DPRINTK("");
-
- if (dev->driver == NULL)
- return 0;
- drv = to_xenbus_driver(dev->driver);
- xdev = container_of(dev, struct xenbus_device, dev);
- if (drv->suspend_cancel)
- err = drv->suspend_cancel(xdev);
- if (err)
- printk(KERN_WARNING
- "xenbus: suspend_cancel %s failed: %i\n",
- dev_name(dev), err);
- return 0;
-}
-
-static int resume_dev(struct device *dev, void *data)
+static int xenbus_dev_resume(struct device *dev)
{
int err;
struct xenbus_driver *drv;
@@ -755,33 +741,6 @@ static int resume_dev(struct device *dev, void *data)
return 0;
}
-void xenbus_suspend(void)
-{
- DPRINTK("");
-
- bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
- xenbus_backend_suspend(suspend_dev);
- xs_suspend();
-}
-EXPORT_SYMBOL_GPL(xenbus_suspend);
-
-void xenbus_resume(void)
-{
- xb_init_comms();
- xs_resume();
- bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
- xenbus_backend_resume(resume_dev);
-}
-EXPORT_SYMBOL_GPL(xenbus_resume);
-
-void xenbus_suspend_cancel(void)
-{
- xs_suspend_cancel();
- bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_cancel_dev);
- xenbus_backend_resume(suspend_cancel_dev);
-}
-EXPORT_SYMBOL_GPL(xenbus_suspend_cancel);
-
/* A flag to determine if xenstored is 'ready' (i.e. has started) */
int xenstored_ready = 0;
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index e325eab4724d..eab33f1dbdf7 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -673,6 +673,8 @@ void xs_resume(void)
struct xenbus_watch *watch;
char token[sizeof(watch) * 2 + 1];
+ xb_init_comms();
+
mutex_unlock(&xs_state.response_mutex);
mutex_unlock(&xs_state.request_mutex);
up_write(&xs_state.transaction_mutex);
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index 515741a8e6b8..6559e0c752ce 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -20,10 +20,27 @@
MODULE_DESCRIPTION("Xen filesystem");
MODULE_LICENSE("GPL");
+static ssize_t capabilities_read(struct file *file, char __user *buf,
+ size_t size, loff_t *off)
+{
+ char *tmp = "";
+
+ if (xen_initial_domain())
+ tmp = "control_d\n";
+
+ return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
+}
+
+static const struct file_operations capabilities_file_ops = {
+ .read = capabilities_read,
+};
+
static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
{
static struct tree_descr xenfs_files[] = {
- [2] = {"xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR},
+ [1] = {},
+ { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR },
+ { "capabilities", &capabilities_file_ops, S_IRUGO },
{""},
};